diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedStageParameters.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedStageParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7e7d167634d0bdc0f65ca8e70941203c9c30334 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedStageParameters.lean @@ -0,0 +1,79 @@ +import OAI.Combinatorics.EditApproximation.Refinement.StageParameterBounds +import OAI.Combinatorics.EditApproximation.Geometry.TreeParameters + +namespace OAI + +/-! Numerical premises for the computed physical refinement stage. -/ + +namespace EditApproximation + + theorem computed_stage_grid_bounds (N : ℕ) (hN : 0 < N) : + 66 ≤ (integerParameters N).P ∧ + (800 * (inputHeight N : ℝ) ^ 2) ≤ (integerParameters N).P ∧ + 4 * ((integerParameters N).M : ℝ) / (integerParameters N).P ≤ 1 := by + let H := inputHeight N + let P := (integerParameters N).P + let M := (integerParameters N).M + have hHtwo : 2 ≤ H := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (heightExponent_pos N hN) + simpa only [H, inputHeight, pow_one] using h + have hHone : 1 ≤ H := by omega + have hM : M ≤ H := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (Nat.div_le_self _ _) + have hH18 : 800 ≤ H ^ 18 := by + have h := Nat.pow_le_pow_left hHtwo 18 + norm_num only [show (2 : ℕ) ^ 18 = 262144 by norm_num] at h + omega + have hP20 : H ^ 20 ≤ P := pow_le_pow_right₀ hHone (by omega : 20 ≤ coarseExponent (inputSmallLog N) + 20) + have hP800 : 800 * H ^ 2 ≤ P := by + calc + 800 * H ^ 2 ≤ H ^ 18 * H ^ 2 := Nat.mul_le_mul_right _ hH18 + _ = H ^ 20 := by rw [← pow_add] + _ ≤ P := hP20 + have hHP : (800 * (H : ℝ) ^ 2) ≤ P := by exact_mod_cast hP800 + have hP66 : 66 ≤ P := by + have h : 4 ≤ H ^ 2 := by nlinarith only [hHtwo] + nlinarith only [hP800, h] + have hPr : (0 : ℝ) < P := by exact_mod_cast (show 0 < P by omega) + have hHr : (2 : ℝ) ≤ H := by exact_mod_cast hHtwo + have hMr : (M : ℝ) ≤ H := by exact_mod_cast hM + refine ⟨hP66, hHP, ?_⟩ + apply (div_le_one₀ hPr).2 + nlinarith only [hHP, hHr, hMr] + + theorem computed_stage_tree_small (N nx : ℕ) (hN : 0 < N) (hnx : nx ≤ N) + (hell : 200 ≤ inputSmallLog N) : + (intervalTreeDepth (integerParameters N).M nx : ℝ) * + (4 * ((integerParameters N).M : ℝ) / (integerParameters N).P) ≤ 1 / 2 := by + let H := inputHeight N + let M := (integerParameters N).M + let P := (integerParameters N).P + let J := intervalTreeDepth M nx + have hdepth := computed_tree_depth_bound N nx hN hnx hell + have hellone : 1 ≤ inputSmallLog N := Nat.one_le_two_pow + have hJ : J ≤ 100 * H := by + calc + J = J * 1 := (Nat.mul_one J).symm + _ ≤ J * inputSmallLog N := Nat.mul_le_mul_left J hellone + _ ≤ 100 * H := hdepth + have hJR : (J : ℝ) ≤ 100 * H := by exact_mod_cast hJ + have hM : M ≤ H := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (Nat.div_le_self _ _) + have hMR : (M : ℝ) ≤ H := by exact_mod_cast hM + have hP800 := (computed_stage_grid_bounds N hN).2.1 + have hPr : (0 : ℝ) < P := by exact_mod_cast (show 0 < P from lt_of_lt_of_le (by decide) (computed_stage_grid_bounds N hN).1) + have hproduct := mul_le_mul hJR hMR (Nat.cast_nonneg M) (by positivity : (0 : ℝ) ≤ 100 * H) + change (J : ℝ) * (4 * (M : ℝ) / P) ≤ _ + rw [← mul_div_assoc] + apply (div_le_iff₀ hPr).2 + nlinarith only [hproduct, hP800] + + theorem computed_stage_positive_counts (N : ℕ) (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) : + 0 < (integerParameters N).T ∧ 0 < (integerParameters N).S := by + have hellone : (1 : ℝ) ≤ inputSmallLog N := by exact_mod_cast (Nat.one_le_two_pow (n := smallLogExponent N)) + have hpow := (pow_le_pow_right₀ hellone (by decide : 2 ≤ 20000)).trans (inputHeight_polynomial_slack N hN hell) + have hpowN : inputSmallLog N ^ 2 ≤ inputHeight N := by exact_mod_cast hpow + have hellpos : 0 < inputSmallLog N := Nat.two_pow_pos _ + exact ⟨Nat.two_pow_pos _, Nat.div_pos hpowN (pow_pos hellpos 2)⟩ + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedStageTime.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedStageTime.lean new file mode 100644 index 0000000000000000000000000000000000000000..e22925053e0a491ce0ead19416ab39487e155cb0 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedStageTime.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.EditApproximation.Refinement.ComputedStageParameters + +namespace OAI + +/-! Exact divisibility and power bounds for the computed time counts. -/ + +namespace EditApproximation + +theorem computed_refinement_count_exact (N : ℕ) (hN : 0 < N) + (hell : 2 ^ 1000 ≤ inputSmallLog N) : + (integerParameters N).S * inputSmallLog N ^ 2 = inputHeight N := by + have hellone : (1 : ℝ) ≤ inputSmallLog N := by exact_mod_cast (Nat.one_le_two_pow (n := smallLogExponent N)) + have hpowR := (pow_le_pow_right₀ hellone (by decide : 2 ≤ 20000)).trans + (inputHeight_polynomial_slack N hN hell) + have hpow : inputSmallLog N ^ 2 ≤ inputHeight N := by exact_mod_cast hpowR + have hexponent : smallLogExponent N * 2 ≤ heightExponent N := by + apply (Nat.pow_le_pow_iff_right (by decide : 1 < 2)).1 + simpa only [inputSmallLog, inputHeight, ← pow_mul] using hpow + have hdiv : inputSmallLog N ^ 2 ∣ inputHeight N := by + simpa only [inputSmallLog, inputHeight, ← pow_mul] using Nat.pow_dvd_pow 2 hexponent + exact Nat.div_mul_cancel hdiv + +theorem computed_refinement_count_real (N : ℕ) (hN : 0 < N) + (hell : 2 ^ 1000 ≤ inputSmallLog N) : + ((integerParameters N).S : ℝ) = (inputHeight N : ℝ) / (inputSmallLog N : ℝ) ^ 2 := by + have hpos : (0 : ℝ) < inputSmallLog N := by exact_mod_cast Nat.two_pow_pos (smallLogExponent N) + apply (eq_div_iff (pow_ne_zero 2 hpos.ne')).2 + exact_mod_cast computed_refinement_count_exact N hN hell + +theorem computed_warmup_count_power (N : ℕ) : + inputHeight N ^ 3 ≤ (integerParameters N).T ^ 4 ∧ + (integerParameters N).T ^ 4 ≤ 16 * inputHeight N ^ 3 := by + let k := heightExponent N + have hlow : 3 * k ≤ ((3 * k + 3) / 4) * 4 := by omega + have hhigh : ((3 * k + 3) / 4) * 4 ≤ 3 * k + 4 := by omega + constructor + · simpa only [integerParameters, inputHeight, ← pow_mul, k, mul_comm] using + pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) hlow + · have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) hhigh + simpa only [integerParameters, inputHeight, ← pow_mul, pow_add, k, + show (2 : ℕ) ^ 4 = 16 by norm_num, mul_comm] using h + +theorem computed_warmup_count_root (N : ℕ) : + heightQuarterRoot N ^ 3 ≤ ((integerParameters N).T : ℝ) ∧ + ((integerParameters N).T : ℝ) ≤ 2 * heightQuarterRoot N ^ 3 := by + have hroot : 0 ≤ heightQuarterRoot N := Real.sqrt_nonneg _ + have hT : (0 : ℝ) ≤ (integerParameters N).T := Nat.cast_nonneg _ + have hpower := computed_warmup_count_power N + have hlow : (inputHeight N : ℝ) ^ 3 ≤ ((integerParameters N).T : ℝ) ^ 4 := by exact_mod_cast hpower.1 + have hhigh : ((integerParameters N).T : ℝ) ^ 4 ≤ 16 * (inputHeight N : ℝ) ^ 3 := by exact_mod_cast hpower.2 + have hrootPower := heightQuarterRoot_fourth_power N + constructor + · apply (pow_le_pow_iff_left₀ (pow_nonneg hroot 3) hT (by decide : 4 ≠ 0)).1 + calc + (heightQuarterRoot N ^ 3) ^ 4 = (inputHeight N : ℝ) ^ 3 := by + rw [← pow_mul, Nat.mul_comm 3 4, pow_mul, hrootPower] + _ ≤ _ := hlow + · apply (pow_le_pow_iff_left₀ hT (mul_nonneg (by norm_num) (pow_nonneg hroot 3)) (by decide : 4 ≠ 0)).1 + calc + _ ≤ 16 * (inputHeight N : ℝ) ^ 3 := hhigh + _ = (2 * heightQuarterRoot N ^ 3) ^ 4 := by + rw [mul_pow, ← pow_mul, Nat.mul_comm 3 4, pow_mul, hrootPower] + norm_num + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedWarmupReadBudget.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedWarmupReadBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7970085ea9b1988a1675e38fbc7826fa43cbf12 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedWarmupReadBudget.lean @@ -0,0 +1,168 @@ +import OAI.Combinatorics.EditApproximation.Geometry.WarmupReadWork +import OAI.Combinatorics.EditApproximation.Refinement.ComputedRefinementReadBudget + +namespace OAI + +/-! A polynomial earlier-edge bound for the complete charged warmup +query. It includes all preceding-pass copy reads and pass-zero coarse +reads used by its initial cones. -/ + +namespace EditApproximation + +def warmupReadBudget (scales window P F Amax M copies : ℕ) : ℕ := + (1 + window * (64 * F * P + 2) ^ 2) * + ((1 + scales * (64 * Amax ^ 2 * P + 2) ^ 2) * max 1 copies) + + window * (64 * F * P + 2) ^ 2 * M * (40 * P + 2) ^ 2 + +theorem warmupReadBudget_box (Z scales window P F Amax M copies : ℕ) + (hZ : 64 ≤ Z) (hscales : scales ≤ Z) (hwindow : window ≤ Z) + (hP : P ≤ Z) (hF : F ≤ Z) (hA : Amax ≤ Z) (hM : M ≤ Z) + (hcopies : copies ≤ Z) : warmupReadBudget scales window P F Amax M copies ≤ Z ^ 24 := by + have hZone : 1 ≤ Z := by omega + have hZtwo : 2 ≤ Z := by omega + have hbase (c x : ℕ) (hc : c ≤ Z) (hx : 2 ≤ x) : c * x + 2 ≤ Z ^ 2 * x := by + have hcx := Nat.mul_le_mul_right x hc + have hzx : 2 ≤ Z * x := hx.trans (Nat.le_mul_of_pos_left x hZone) + have hcoeff := Nat.mul_le_mul_right x (show 2 * Z ≤ Z ^ 2 by nlinarith only [hZtwo]) + nlinarith only [hcx, hzx, hcoeff] + have hadd (k : ℕ) : 1 + Z ^ k ≤ Z ^ (k + 1) := by + have hp : 1 ≤ Z ^ k := one_le_pow₀ hZone + have hm := Nat.mul_le_mul_right (Z ^ k) hZtwo + rw [pow_succ] + nlinarith only [hp, hm] + have h64 : 64 ≤ Z := hZ + have h40 : 40 ≤ Z := by omega + have hsmall : 64 * F * P + 2 ≤ Z ^ 4 := by + calc + _ ≤ 64 * Z * Z + 2 := Nat.add_le_add_right (Nat.mul_le_mul (Nat.mul_le_mul_left 64 hF) hP) 2 + _ ≤ _ := by + convert hbase 64 (Z ^ 2) h64 ((Nat.pow_le_pow_left hZtwo 2).trans' (by norm_num)) using 1 <;> ring + have hinitialBase : 64 * Amax ^ 2 * P + 2 ≤ Z ^ 5 := by + calc + _ ≤ 64 * Z ^ 2 * Z + 2 := + Nat.add_le_add_right (Nat.mul_le_mul (Nat.mul_le_mul_left 64 (Nat.pow_le_pow_left hA 2)) hP) 2 + _ ≤ _ := by + convert hbase 64 (Z ^ 3) h64 ((Nat.pow_le_pow_left hZtwo 3).trans' (by norm_num)) using 1 <;> ring + have hwideBase : 40 * P + 2 ≤ Z ^ 3 := by + calc + _ ≤ 40 * Z + 2 := Nat.add_le_add_right (Nat.mul_le_mul_left 40 hP) 2 + _ ≤ _ := by convert hbase 40 Z h40 hZtwo using 1; ring + have hraw : window * (64 * F * P + 2) ^ 2 ≤ Z ^ 9 := by + exact (Nat.mul_le_mul hwindow (Nat.pow_le_pow_left hsmall 2)).trans_eq (by ring) + have hrawInitial : scales * (64 * Amax ^ 2 * P + 2) ^ 2 ≤ Z ^ 11 := by + exact (Nat.mul_le_mul hscales (Nat.pow_le_pow_left hinitialBase 2)).trans_eq (by ring) + have hinit : (1 + scales * (64 * Amax ^ 2 * P + 2) ^ 2) * max 1 copies ≤ Z ^ 13 := by + exact (Nat.mul_le_mul ((Nat.add_le_add_left hrawInitial 1).trans (hadd 11)) + (max_le hZone hcopies)).trans_eq (by ring) + have hfirst : (1 + window * (64 * F * P + 2) ^ 2) * + ((1 + scales * (64 * Amax ^ 2 * P + 2) ^ 2) * max 1 copies) ≤ Z ^ 23 := by + exact (Nat.mul_le_mul ((Nat.add_le_add_left hraw 1).trans (hadd 9)) hinit).trans_eq (by ring) + have hsecond : window * (64 * F * P + 2) ^ 2 * M * (40 * P + 2) ^ 2 ≤ Z ^ 23 := by + calc + _ ≤ Z ^ 9 * Z * (Z ^ 3) ^ 2 := + Nat.mul_le_mul (Nat.mul_le_mul hraw hM) (Nat.pow_le_pow_left hwideBase 2) + _ = Z ^ 16 := by ring + _ ≤ _ := pow_le_pow_right₀ hZone (by decide) + exact (Nat.add_le_add hfirst hsecond).trans (by + have hm := Nat.mul_le_mul_right (Z ^ 23) hZtwo + have heq : Z ^ 24 = Z ^ 23 * Z := pow_succ Z 23 + calc + Z ^ 23 + Z ^ 23 = 2 * Z ^ 23 := (two_mul _).symm + _ ≤ Z * Z ^ 23 := hm + _ = Z ^ 24 := by rw [heq]; exact Nat.mul_comm _ _) + +theorem computed_dyadicScales_length (N : ℕ) (hH : 2 ≤ inputHeight N) : + (dyadicScales N).length ≤ inputHeight N ^ 2 := by + have hlog : Nat.log 2 N ≤ inputHeight N := by + apply (Nat.log_le_clog 2 N).trans + apply (Nat.clog_mono_right 2 (Nat.le_add_right N 2)).trans + exact Nat.le_pow_clog (by decide : 1 < (2 : ℕ)) (Nat.clog 2 (N + 2)) + simp only [dyadicScales, List.length_map, List.length_range] + nlinarith only [hlog, hH] + +theorem computed_warmupReadBudget_le (N M P copies : ℕ) (hN : 0 < N) + (hell : 200 ≤ inputSmallLog N) (hM : M = (integerParameters N).M) + (hP : P = (integerParameters N).P) (hcopies : copies ≤ inputHeight N ^ 2) : + warmupReadBudget (dyadicScales N).length (computedSeedInitialExponent N + 8) + P (inputSmallLog N) (integerParameters N).initialFactor M copies ≤ + inputHeight N ^ (512 * (coarseExponent (inputSmallLog N) + 1)) := by + let H := inputHeight N + let p := coarseExponent (inputSmallLog N) + let Z := H ^ (p + 20) + have hF := computed_smallLog_le_height N + have hH : 64 ≤ H := (by omega : 64 ≤ inputSmallLog N).trans hF + have hZone : 1 ≤ H := by omega + have hHZ : H ≤ Z := by + calc + H = H ^ 1 := (pow_one H).symm + _ ≤ H ^ (p + 20) := pow_le_pow_right₀ hZone (by omega) + have hH2Z : H ^ 2 ≤ Z := pow_le_pow_right₀ hZone (by omega) + have hH3Z : H ^ 3 ≤ Z := pow_le_pow_right₀ hZone (by omega) + have hscales : (dyadicScales N).length ≤ Z := (computed_dyadicScales_length N (by omega)).trans hH2Z + have hwindow : computedSeedInitialExponent N + 8 ≤ Z := + (computed_window_le_height_cube N hN (by omega) (by omega)).trans hH3Z + have hPZ : P ≤ Z := by change P ≤ (integerParameters N).P; exact hP.le + have hAZ : (integerParameters N).initialFactor ≤ Z := + pow_le_pow_right₀ hZone (by omega) + have hMZ : M ≤ Z := by + rw [hM] + exact (pow_le_pow_right₀ (by decide : (1 : ℕ) ≤ 2) (Nat.div_le_self _ _)).trans hHZ + have hbound := warmupReadBudget_box Z (dyadicScales N).length (computedSeedInitialExponent N + 8) + P (inputSmallLog N) (integerParameters N).initialFactor M copies (hH.trans hHZ) + hscales hwindow hPZ (hF.trans hHZ) hAZ hMZ (hcopies.trans hH2Z) + apply hbound.trans + dsimp only [Z] + rw [← pow_mul] + exact pow_le_pow_right₀ hZone (by dsimp only [p]; omega) + +theorem computed_chargedWarmupQuery_reads {α : Type*} [DecidableEq α] + {M J passes copies T S : ℕ} (source target : List α) (N P : ℕ) + (hN : 0 < N) (hell : 200 ≤ inputSmallLog N) + (hM : M = (integerParameters N).M) (hP : P = (integerParameters N).P) + (hcopies : copies ≤ inputHeight N ^ 2) (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) + (parent : {r : PhysicalTableRequest M J target.length // r.Bounded passes copies T S}) + (oracle) (hA : 1 ≤ factor parent.val.pass) + (hAmax : factor parent.val.pass ≤ ((integerParameters N).initialFactor : ℚ)) : + (chargedWarmupQuery source target N P (inputSmallLog N) factor multiplier parent).cost + oracle (fun _ => 1) ≤ inputHeight N ^ (512 * (coarseExponent (inputSmallLog N) + 1)) := by + have hPpos : 0 < P := by + rw [hP] + change 0 < inputHeight N ^ _ + exact pow_pos (Nat.two_pow_pos _) _ + exact (chargedWarmupQuery_cost_le source target N P (inputSmallLog N) + (integerParameters N).initialFactor (computedSeedInitialExponent N + 8) factor multiplier parent oracle + hPpos (by omega) hA hAmax (fun w => computed_refinement_window N hN (by omega) + (factor parent.val.pass) w hAmax)).trans + (computed_warmupReadBudget_le N M P copies hN hell hM hP hcopies) + +theorem computed_chargedInitialQuery_reads {α : Type*} [DecidableEq α] + {M J passes copies T S : ℕ} (source target : List α) (N P : ℕ) + (hN : 0 < N) (hell : 200 ≤ inputSmallLog N) + (hM : M = (integerParameters N).M) (hP : P = (integerParameters N).P) + (hcopies : copies ≤ inputHeight N ^ 2) (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) + (parent : {r : PhysicalTableRequest M J target.length // r.Bounded passes copies T S}) + (oracle) (hA : 1 ≤ factor parent.val.pass) + (hAmax : factor parent.val.pass ≤ ((integerParameters N).initialFactor : ℚ)) : + (physicalInitialQuery source target N P (inputSmallLog N) (factor parent.val.pass) + (chargedSeedQuery N multiplier parent) (parent.val.node, parent.val.state)).cost oracle (fun _ => 1) ≤ + inputHeight N ^ (512 * (coarseExponent (inputSmallLog N) + 1)) := by + have hPpos : 0 < P := by + rw [hP] + change 0 < inputHeight N ^ _ + exact pow_pos (Nat.two_pow_pos _) _ + let initialCost := (1 + (dyadicScales N).length * + (64 * (integerParameters N).initialFactor ^ 2 * P + 2) ^ 2) * max 1 copies + have hi : (physicalInitialQuery source target N P (inputSmallLog N) (factor parent.val.pass) + (chargedSeedQuery N multiplier parent) (parent.val.node, parent.val.state)).cost oracle (fun _ => 1) ≤ + initialCost := + physicalInitialQuery_cost_le source target N P (inputSmallLog N) (integerParameters N).initialFactor + (max 1 copies) _ _ _ _ oracle hPpos hA hAmax + (fun r => chargedSeedQuery_cost_le N multiplier parent _ oracle) + have hb : initialCost ≤ warmupReadBudget (dyadicScales N).length + (computedSeedInitialExponent N + 8) P (inputSmallLog N) (integerParameters N).initialFactor M copies := by + exact (Nat.le_mul_of_pos_left initialCost (by omega)).trans (Nat.le_add_right _ _) + exact hi.trans (hb.trans (computed_warmupReadBudget_le N M P copies hN hell hM hP hcopies)) + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedWidthEnvelope.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedWidthEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..188086d695e8272c59006271a17b590bae121943 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/ComputedWidthEnvelope.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.EditApproximation.Refinement.ComputedActualBandWork + +namespace OAI + +/-! A parameter-only majorant for every executed dependency tree. It is +independent of the accepted random values and of all accuracy events. -/ + +namespace EditApproximation + +open Filter +open scoped Topology + +noncomputable def computedWidthEnvelope (N : ℕ) : ℝ := + (N + 2 : ℝ) * (inputHeight N : ℝ) ^ 2 * + Real.exp (computedDependencyOverheadExponent 257 512 N) + +theorem computedWidthEnvelope_nonneg (N : ℕ) : 0 ≤ computedWidthEnvelope N := by + unfold computedWidthEnvelope + positivity + +theorem computed_widthWork_le_envelope (N n : ℕ) (hN : 0 < N) (hn : n ≤ N) + (hell : 200 ≤ inputSmallLog N) (hH : 105 ≤ inputHeight N) + (tree : DependencyExpansion) + (hv : tree.Valid ((integerParameters N).M * inputSmallLog N ^ 257) + (inputHeight N ^ (512 * (coarseExponent (inputSmallLog N) + 1)))) + (hd : tree.depth = intervalTreeDepth (integerParameters N).M n) + (hk : tree.rank ≤ computedDependencyIndexCount N) : + (tree.widthWork (integerParameters N).M n : ℝ) ≤ computedWidthEnvelope N := by + have hw := DependencyExpansion.widthWork_le (integerParameters N).M n _ _ _ + (computed_branching_bounds N hN hell).1 tree hv hd hk + (Real.exp (computedDependencyOverheadExponent 257 512 N)) (Real.exp_nonneg _) (by + intro j hj + exact computed_dependency_path_envelope N 257 512 j + (hj.trans (intervalTreeDepth_le_computedMax N n hn))) + have hpref := computed_width_prefactor_le N n hN hn hell hH + have hprefR : (((intervalTreeDepth (integerParameters N).M n + 1) * n + + 4 * (integerParameters N).M * max 1 n : ℕ) : ℝ) ≤ + (N + 2 : ℝ) * (inputHeight N : ℝ) ^ 2 := by exact_mod_cast hpref + exact hw.trans (mul_le_mul_of_nonneg_right hprefR (Real.exp_nonneg _)) + +theorem computedWidthEnvelope_mul_exp_near_linear (f : ℕ → ℝ) + (hf : Tendsto (fun N => f N / inputHeight N) atTop (𝓝 0)) + (epsilon : ℝ) (hepsilon : 0 < epsilon) : + ∀ᶠ N in atTop, computedWidthEnvelope N * Real.exp (f N) ≤ + (N + 2 : ℝ) ^ (1 + epsilon) := by + have hlog : Tendsto (fun N => Real.log (inputHeight N : ℝ) / inputHeight N) + atTop (𝓝 0) := + Real.isLittleO_log_id_atTop.tendsto_div_nhds_zero.comp inputHeight_real_tendsto + have hlimit := ((computedDependencyOverheadExponent_tendsto 257 512).add + (hlog.const_mul 2)).add hf + simp only [mul_zero, add_zero] at hlimit + have hfinal := sublinear_height_near_linear + (fun N => computedDependencyOverheadExponent 257 512 N + + 2 * Real.log (inputHeight N : ℝ) + f N) (by + convert hlimit using 1 + ext N + ring) epsilon hepsilon + filter_upwards [hfinal] with N hN + convert hN using 1 + unfold computedWidthEnvelope + rw [Real.exp_add, Real.exp_add] + have hp : Real.exp (2 * Real.log (inputHeight N : ℝ)) = (inputHeight N : ℝ) ^ 2 := by + simpa using (nat_pow_eq_exp_log (inputHeight N) 2 (Nat.two_pow_pos _)).symm + rw [hp] + ring + +theorem computedWidthEnvelope_weighted_near_linear (C : ℕ) + (epsilon : ℝ) (hepsilon : 0 < epsilon) : + ∀ᶠ N in atTop, computedWidthEnvelope N * (inputHeight N : ℝ) ^ C ≤ + (N + 2 : ℝ) ^ (1 + epsilon) := by + have hlog : Tendsto (fun N => Real.log (inputHeight N : ℝ) / inputHeight N) + atTop (𝓝 0) := + Real.isLittleO_log_id_atTop.tendsto_div_nhds_zero.comp inputHeight_real_tendsto + have hlimit := hlog.const_mul (C : ℝ) + simp only [mul_zero] at hlimit + have hf : Tendsto (fun N => ((C : ℝ) * Real.log (inputHeight N : ℝ)) / inputHeight N) + atTop (𝓝 0) := by convert hlimit using 1; ext N; ring + filter_upwards [computedWidthEnvelope_mul_exp_near_linear _ hf epsilon hepsilon] with N hN + rwa [← nat_pow_eq_exp_log (inputHeight N) C (Nat.two_pow_pos _)] at hN + +theorem computedWidthEnvelope_coarse_near_linear (epsilon : ℝ) (hepsilon : 0 < epsilon) : + ∀ᶠ N in atTop, computedWidthEnvelope N * computedCoarseWidthOverhead N ≤ + (N + 2 : ℝ) ^ (1 + epsilon) := by + filter_upwards [computedWidthEnvelope_mul_exp_near_linear _ + (computedCoarseOverheadExponent_tendsto 10) epsilon hepsilon, eventually_ge_atTop 1] with N hN hpos + exact (mul_le_mul_of_nonneg_left (computedCoarseWidthOverhead_exp_le N (by omega)) + (computedWidthEnvelope_nonneg N)).trans hN + +theorem computedWidthEnvelope_band_near_linear (C : ℕ) + (epsilon : ℝ) (hepsilon : 0 < epsilon) : + ∀ᶠ N in atTop, computedWidthEnvelope N * computedActualBandBitBudget C N ≤ + (N + 2 : ℝ) ^ (1 + epsilon) := by + filter_upwards [computedWidthEnvelope_mul_exp_near_linear _ + (computedActualBandBitExponent_tendsto C) epsilon hepsilon, eventually_ge_atTop 1] with N hN hpos + exact (mul_le_mul_of_nonneg_left (computedActualBandBitBudget_exp_bound C N (by omega)) + (computedWidthEnvelope_nonneg N)).trans hN + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBinaryMass.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBinaryMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..48078302f5737df86025142120eef002696cfad9 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBinaryMass.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.EditApproximation.Binary.BinaryWarmupAverage +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalRefinement + +namespace OAI + +/-! The child mass is built from the actual gathered warmup words. The +mean and construction of its finite input list both contribute to work. -/ + +namespace EditApproximation + +def physicalWarmupMassWithWork {ny : ℕ} (T : ℕ) + (words : ℕ → TargetInterval ny → BinaryFraction) (query : TargetInterval ny) : + BinaryFraction × ℕ := + let mean := BinaryFraction.warmupAverageWithWork (List.ofFn fun j : Fin T => words j.val query) + (mean.1, mean.2 + T + 1) + +theorem physicalWarmupMassWithWork_value {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F T : ℕ) (A : ℚ) (node : PhysicalNode M J) + (words : ℕ → TargetInterval target.length → BinaryFraction) + (hwords : ∀ j < T, ∀ r, (words j r).value = physicalLocalWarmup source target U N P F A j (node, r)) + (query : TargetInterval target.length) : + (physicalWarmupMassWithWork T words query).1.value = + physicalLocalWarmupMass source target U N P F A T (node, query) := by + rw [physicalWarmupMassWithWork, BinaryFraction.warmupAverageWithWork_ofFn_value] + unfold physicalLocalWarmupMass + congr 1 + rw [← Fin.sum_univ_eq_sum_range (fun j => + physicalLocalWarmup source target U N P F A j (node, query))] + apply Finset.sum_congr rfl + intro j _hj + exact hwords j.val j.isLt query + +theorem physicalWarmupMassWithWork_bounds {ny : ℕ} (T B : ℕ) + (words : ℕ → TargetInterval ny → BinaryFraction) + (hwords : ∀ j < T, ∀ r, (words j r).width ≤ B) (query : TargetInterval ny) : + (physicalWarmupMassWithWork T words query).1.width ≤ BinaryFraction.warmupAverageWordBudget T B ∧ + (physicalWarmupMassWithWork T words query).2 ≤ BinaryFraction.warmupAverageBitBudget T B + T + 1 := by + have hmean := BinaryFraction.warmupAverageWithWork_bounds + (List.ofFn fun j : Fin T => words j.val query) B (by + intro value hv + obtain ⟨j, rfl⟩ := List.mem_ofFn.mp hv + exact hwords j.val j.isLt query) + simp only [List.length_ofFn] at hmean + exact ⟨hmean.1, Nat.add_le_add_right (Nat.add_le_add_right hmean.2 T) 1⟩ + +theorem warmupAverageWordBudget_le_power (H T B : ℕ) (hH : 64 ≤ H) + (hT : T ≤ H ^ 2) (hB : B ≤ H ^ 3) : + BinaryFraction.warmupAverageWordBudget T B ≤ H ^ 8 := by + have hHp : 0 < H := by omega + have hHone : 1 ≤ H := by omega + have hsize : Nat.size T ≤ H ^ 2 := (Nat.size_le.mpr Nat.lt_two_pow_self).trans hT + have h23 : H ^ 2 ≤ H ^ 3 := Nat.pow_le_pow_right hHp (by decide) + have h35 : H ^ 3 ≤ H ^ 5 := Nat.pow_le_pow_right hHp (by decide) + have hone : 1 ≤ H ^ 3 := one_le_pow₀ hHone + have hproduct : T * (B + 1) ≤ 2 * H ^ 5 := by + calc + _ ≤ H ^ 2 * (2 * H ^ 3) := Nat.mul_le_mul hT (by omega) + _ = 2 * H ^ 5 := by ring + have hsmall : BinaryFraction.warmupAverageWordBudget T B ≤ 64 * H ^ 5 := by + unfold BinaryFraction.warmupAverageWordBudget BinaryFraction.bandMassTotalStorageBudget + nlinarith only [hsize, hB, h23, h35, hproduct, hone] + have h64 : 64 ≤ H ^ 3 := (by omega : 64 ≤ H).trans (Nat.le_pow (by decide)) + exact hsmall.trans (by + calc + 64 * H ^ 5 ≤ H ^ 3 * H ^ 5 := Nat.mul_le_mul_right _ h64 + _ = H ^ 8 := by ring) + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBinaryStep.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBinaryStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4c2dea9b783576458240233eb447b2ffaa4e394 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBinaryStep.lean @@ -0,0 +1,170 @@ +import OAI.Combinatorics.EditApproximation.Geometry.PreparedCachedKernelWork +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCachedWords + +namespace OAI + +/-! The Boolean refinement kernel at a physical node uses cached words +for its child and table requests. -/ + +namespace EditApproximation + +attribute [local irreducible] BinaryFraction.preparedLocalKernelWithWork + +section Step + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) + (tauWord aWord etaWord kappaWord deltaWord : BinaryFraction) + (parentWords : TargetInterval target.length → BinaryFraction) + (massWords initialWords : Fin M → TargetInterval target.length → BinaryFraction) + (historyWords : ℕ → Fin M × TargetInterval target.length → BinaryFraction) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (integer : PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (t : ℕ) + (query : TargetInterval target.length) + +def physicalPreparedStepWithWork : BinaryFraction × ℕ := + BinaryFraction.preparedLocalKernelWithWork source target (physicalSourceInterval source.length node) + N P F exponent H Q eM eF hP hM hF tauWord aWord etaWord kappaWord deltaWord + parentWords massWords initialWords (historyWords t) (historyWords (t + 1)) historyWords t + (draw ⟨node, hbelow⟩ (t + 1)) (integer ⟨node, hbelow⟩ (Fin.ofNat R t)) query + +omit [DecidableEq α] in +theorem physicalPreparedStepWithWork_bounds (B E S : ℕ) (hPdyadic : ∃ j : ℕ, P = 2 ^ j) + (hb : BinaryFraction.PreparedKernelInputBounds (nx := source.length) + N P F exponent H Q eM eF B E S t tauWord aWord etaWord kappaWord deltaWord + parentWords massWords initialWords (historyWords t) (historyWords (t + 1)) historyWords + (integer ⟨node, hbelow⟩ (Fin.ofNat R t))) : + (physicalPreparedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query).1.width ≤ BinaryFraction.preparedKernelWordBudget M B ∧ + (physicalPreparedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query).2 ≤ BinaryFraction.preparedKernelBitBudget N M P F exponent eM eF B S := + BinaryFraction.preparedLocalKernelWithWork_bounds source target (physicalSourceInterval source.length node) + N P F exponent H Q eM eF B E S hP hM hF hPdyadic tauWord aWord etaWord kappaWord deltaWord + parentWords massWords initialWords (historyWords t) (historyWords (t + 1)) historyWords t + (draw ⟨node, hbelow⟩ (t + 1)) (integer ⟨node, hbelow⟩ (Fin.ofNat R t)) query hb + +variable (U : PhysicalEntry M J target.length → ℕ) (A tau eta kappa delta : ℚ) (T : ℕ) + (ha : aWord.value = refinementFactor A F) (htau : tauWord.value = tau) + (heta : etaWord.value = eta) (hkappa : kappaWord.value = kappa) + (hdelta : deltaWord.value = delta) + (hparent : ∀ r, (parentWords r).value = stageInitial source target U N P F A (node, r)) + (hmass : ∀ i r, (massWords i r).value = + physicalLocalChildMass source target U N P F A T node hbelow i r) + (hinitial : ∀ i r, (initialWords i r).value = + stageInitial source target U N P F A (physicalChild node hbelow i, r)) + (hhistory : ∀ s i r, (historyWords s (i, r)).value = + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + (physicalChild node hbelow i) s r) + (hwide : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + +include ha htau heta hkappa hdelta hparent hmass hinitial hhistory hwide in +theorem physicalPreparedStepWithWork_value : + (physicalPreparedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query).1.value = + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + node (t + 1) query := by + let children : PhysicalChildTables M target.length := fun i => + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + (physicalChild node hbelow i) + have honline : physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer + node children (t + 1) query = + localOnlineCandidates source target (physicalSourceInterval source.length node) + N P F exponent H tau (refinementFactor A F) eta kappa + (fun r => stageInitial source target U N P F A (node, r)) + (physicalLocalChildMass source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + children t (integer ⟨node, hbelow⟩ (Fin.ofNat R t)) query := by + rw [physicalLocalOnline, dite_eq_left hbelow] + simp only [Nat.add_sub_cancel] + unfold physicalPreparedStepWithWork + rw [BinaryFraction.preparedLocalKernelWithWork_value] + simp_rw [ha, htau, heta, hkappa, hdelta, hparent, hmass, hinitial, hhistory] + conv_rhs => rw [physicalLocalRefinement] + rw [dite_eq_left hbelow, ite_eq_right hwide] + dsimp only + rw [honline] + rfl + +include hparent hinitial hhistory in +theorem physicalPreparedStep_input_ranges (hd : 0 ≤ delta) : + (∀ r, 0 ≤ (parentWords r).value) ∧ + (∀ s ≤ t + 1, ∀ i r, 0 ≤ (historyWords s (i, r)).value ∧ + (historyWords s (i, r)).value ≤ (initialWords i r).value) := by + constructor + · intro r + rw [hparent] + exact stageInitial_nonneg_all_seeds source target U N P F A (node, r) + · intro s _hs i r + rw [hhistory, hinitial] + exact physicalLocalRefinement_bounds source target U N P F exponent Q A tau delta T hd draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + (physicalChild node hbelow i) s r + +def physicalCachedStepWithWork (base : List Bool) (hbase : 0 < bitWordValue base) : + BinaryFraction × ℕ := + BinaryFraction.finishCachedWithWork + (physicalPreparedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query) base hbase (J - node.1.val) + +omit [DecidableEq α] in +theorem physicalCachedStepWithWork_cost (base : List Bool) (hbase : 0 < bitWordValue base) + (B E S D : ℕ) (hbaseWidth : base.length ≤ D) (hPdyadic : ∃ j : ℕ, P = 2 ^ j) + (hb : BinaryFraction.PreparedKernelInputBounds (nx := source.length) + N P F exponent H Q eM eF B E S t tauWord aWord etaWord kappaWord deltaWord + parentWords massWords initialWords (historyWords t) (historyWords (t + 1)) historyWords + (integer ⟨node, hbelow⟩ (Fin.ofNat R t))) : + (physicalCachedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query base hbase).2 ≤ + BinaryFraction.preparedKernelBitBudget N M P F exponent eM eF B S + + BinaryFraction.powerDenominatorBitBudget (J - node.1.val) + (BinaryFraction.preparedKernelWordBudget M B) D + 1 := by + have hk := physicalPreparedStepWithWork_bounds source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query B E S hPdyadic hb + have hc := BinaryFraction.powerDenominatorWithWork_cost + (physicalPreparedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query).1 base hbase (J - node.1.val) + (BinaryFraction.preparedKernelWordBudget M B) D hk.1 hbaseWidth + exact Nat.add_le_add_right (Nat.add_le_add hk.2 hc) 1 + +include ha htau heta hkappa hdelta hparent hmass hinitial hhistory hwide in +theorem physicalCachedStepWithWork_value_width (ell : ℕ) (hell : 0 < ell) + (hdeltaExact : delta = 1 / (ell : ℚ) ^ 10) + (hsize : source.length + target.length ≤ N) (base : List Bool) + (hbase : bitWordValue base = ell ^ 10 + 1) : + (physicalCachedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query base (by rw [hbase]; omega)).1.value = + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + node (t + 1) query ∧ + (physicalCachedStepWithWork source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query base (by rw [hbase]; omega)).1.width ≤ + Nat.size ((32 * F + 1) * N) + 2 * (J - node.1.val) * base.length + 3 := by + rcases hdeltaExact with rfl + have hraw := physicalPreparedStepWithWork_value source target N P F exponent H Q eM eF hP hM hF + tauWord aWord etaWord kappaWord deltaWord parentWords massWords initialWords historyWords + draw integer node hbelow t query U A tau eta kappa _ T ha htau heta hkappa hdelta + hparent hmass hinitial hhistory hwide + have hstored := physicalLocalOnlineRefinement_cached_word source target U N P F exponent H Q A tau eta kappa + hsize T ell hell draw integer node (t + 1) query _ hraw base hbase + exact ⟨hstored.1.trans hraw, hstored.2⟩ + +end Step + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBoundedQuery.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBoundedQuery.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd6c5c0f0d52bb46c202d1a9a8cb27ac1732f492 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBoundedQuery.lean @@ -0,0 +1,162 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalGlobalValue +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementReadWork +import OAI.Combinatorics.EditApproximation.Geometry.WarmupQueryKeys +import OAI.Combinatorics.EditApproximation.Geometry.RankedProgramRestriction +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRequestEncoding + +namespace OAI + +/-! The actual global read program stays within the bounded cache-key +domain. Restricting its type therefore preserves the complete local-pass +value and gives an injectively encoded memo evaluator. -/ + +namespace EditApproximation + +instance PhysicalTableRequest.decidableBounded {M J ny : ℕ} (passes copies T S : ℕ) : + DecidablePred (PhysicalTableRequest.Bounded (M := M) (J := J) (ny := ny) passes copies T S) := + fun request => inferInstanceAs (Decidable + (request.pass < passes ∧ request.copy < copies ∧ request.index ≤ T + S)) + +theorem globalSeedRead_keys_bounded {M J ny : ℕ} (N T S passes copies : ℕ) + (multiplier : ℕ → ℕ) (initial : PhysicalEntry M J ny → ℕ) + (parent : PhysicalTableRequest M J ny) (hparent : parent.Bounded passes copies T S) + (state : PhysicalEntry M J ny) (oracle) : + ∀ key ∈ (globalSeedRead N T S copies multiplier initial parent state).keys oracle, + key.val.Bounded passes copies T S := by + unfold globalSeedRead + split_ifs with hnode hpass + · intro key hk + exact False.elim (List.not_mem_nil hk) + · unfold physicalMedianSeedQuery + apply FiniteQuery.keys_all_collect + · intro copy _ key hk + simp only [previousPassRead, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact ⟨Nat.lt_of_le_of_lt (Nat.sub_le _ _) hparent.1, copy.isLt, le_rfl⟩ + · intro values key hk + exact False.elim (List.not_mem_nil hk) + · intro key hk + exact False.elim (List.not_mem_nil hk) + +section Bounded + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) + +theorem physicalGlobalQuery_keys_bounded (request : PhysicalTableRequest M J target.length) + (hrequest : request.Bounded passes copies T S) (oracle) : + ∀ key ∈ (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request).keys oracle, + key.val.Bounded passes copies T S := by + rcases request with ⟨pass, copy, node, index, q⟩ + obtain ⟨hpass, hcopy, hindex⟩ := hrequest + dsimp only at hpass hcopy hindex + by_cases hj : index ≤ T + · change ∀ key ∈ (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.warmup pass copy node index q)).keys oracle, + key.val.Bounded passes copies T S + rw [physicalGlobalQuery_warmup source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass copy node index hj q] + apply physicalWarmupRequestQuery_keys_bounded source target N P F (factor pass) + passes copies pass copy T S index hpass hcopy hj node q _ oracle + intro r key hk + exact globalSeedRead_keys_bounded N T S passes copies multiplier initial _ + ⟨hpass, hcopy, hindex⟩ _ oracle key hk + · obtain ⟨t, hi⟩ : ∃ t, index = T + t := ⟨index - T, by omega⟩ + subst index + have ht : 0 < t := by omega + have htS : t ≤ S := by omega + change ∀ key ∈ (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.refinement pass copy node T t q)).keys oracle, + key.val.Bounded passes copies T S + by_cases hbelow : node.1.val < J + · by_cases hshort : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · unfold physicalGlobalQuery + dsimp only + erw [dite_eq_right (show ¬ (PhysicalTableRequest.refinement pass copy node T t q).index ≤ T + from hj), dite_eq_left hbelow, dite_eq_left hshort] + apply physicalInitialQuery_keys_all + intro r key hk + exact globalSeedRead_keys_bounded N T S passes copies multiplier initial _ + ⟨hpass, hcopy, hindex⟩ _ oracle key hk + · unfold physicalGlobalQuery + dsimp only + erw [dite_eq_right (show ¬ (PhysicalTableRequest.refinement pass copy node T t q).index ≤ T + from hj), dite_eq_left hbelow, dite_eq_right hshort] + erw [FiniteQuery.mapKeys_keys] + intro key hk + obtain ⟨child, hc, rfl⟩ := List.mem_map.mp hk + exact physicalRefinementDataRequest_keys_bounded source target N P F exponent H Q tau + (refinementFactor (factor pass) F) eta kappa delta passes copies pass copy T S + (T + t - T) (by omega) (by omega) hpass hcopy node hbelow _ _ q _ child hc + · unfold physicalGlobalQuery + dsimp only + erw [dite_eq_right (show ¬ (PhysicalTableRequest.refinement pass copy node T t q).index ≤ T + from hj), dite_eq_right hbelow] + apply physicalInitialQuery_keys_all + intro r key hk + exact globalSeedRead_keys_bounded N T S passes copies multiplier initial _ + ⟨hpass, hcopy, hindex⟩ _ oracle key hk + +def physicalBoundedQuery + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) : + FiniteQuery {child : {child : PhysicalTableRequest M J target.length // child.Bounded passes copies T S} // + child.val.combinedRank T S < request.val.combinedRank T S} := + restrictRankedProgram (PhysicalTableRequest.combinedRank T S) + (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial) (PhysicalTableRequest.Bounded passes copies T S) request + +theorem physicalBoundedQuery_value + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) : + (physicalBoundedQuery source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta group integer initial request).value + (fun child => localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial child.val.val) = + localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request.val := by + unfold physicalBoundedQuery + rw [restrictRankedProgram_value _ _ _ _ request + (physicalGlobalQuery_keys_bounded source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta group integer initial request.val request.property _)] + exact physicalGlobalQuery_value source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request.val + +def physicalMemoEvaluate + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) := + rankedMemoEvaluate (fun request : + {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S} => + request.val.combinedRank T S) + (physicalBoundedQuery source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta group integer initial) + (PhysicalTableRequest.bits M J target.length passes copies T S) + (fun request => PhysicalTableRequest.code copies T S request.val) request .empty + +theorem physicalMemoEvaluate_value (hM : 1 ≤ M) + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) : + (physicalMemoEvaluate source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta group integer initial request).value = + localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request.val := by + unfold physicalMemoEvaluate + exact rankedMemoEvaluate_specification + (fun request : {request : PhysicalTableRequest M J target.length // + request.Bounded passes copies T S} => request.val.combinedRank T S) + (physicalBoundedQuery source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta group integer initial) + (fun request => localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request.val) + (physicalBoundedQuery_value source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta group integer initial) + _ _ (PhysicalTableRequest.code_injective hM passes copies T S) + (PhysicalTableRequest.code_fits hM passes copies T S) request + +end Bounded + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBoundsAllSeeds.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBoundsAllSeeds.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4179e429c5eff031c1e6964348b66f50069289a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalBoundsAllSeeds.lean @@ -0,0 +1,162 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementInvariants + +namespace OAI + +/-! Nonnegativity and size bounds hold on every seed and every sample outcome. -/ + +namespace EditApproximation + +open Finset + +theorem rationalActualWideActions_connection_nonneg {nx ny M : ℕ} (parent : TargetInterval nx) + (representatives : List (ℕ × TargetInterval ny)) (P : ℕ) + (action : PhysicalRationalAction M ny) + (ha : action ∈ rationalActualWideActions parent representatives P) : 0 ≤ action.connection := by + obtain ⟨br, _, hmem⟩ := List.mem_flatMap.mp ha + obtain ⟨states, _, rfl⟩ := List.mem_map.mp hmem + exact Nat.cast_nonneg _ + +theorem localInitialConeTable_nonneg {α : Type*} (source target : List α) + (U : TargetInterval target.length → ℕ) (N P F : ℕ) (A a : ℚ) (q : TargetInterval target.length) : + 0 ≤ localInitialConeTable source target U N P F A a q := by + unfold localInitialConeTable + split_ifs + · exact le_rfl + · apply (le_rationalMinimum_iff _ _ _).2 + refine ⟨by positivity, ?_⟩ + intro v hv + obtain ⟨r, _, rfl⟩ := List.mem_map.mp hv + unfold initialConeValue scaledSeedValue + positivity + + theorem stageInitial_nonneg_all_seeds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (state : PhysicalEntry M J target.length) : + 0 ≤ stageInitial source target U N P F A state := by + unfold stageInitial physicalInitialTable + dsimp only + split_ifs + · exact Nat.cast_nonneg _ + · exact localInitialConeTable_nonneg _ _ _ _ _ _ _ _ _ + + theorem stageInitial_upper_all_seeds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (state : PhysicalEntry M J target.length) : + stageInitial source target U N P F A state ≤ (32 * F + 1 : ℚ) * N := by + unfold stageInitial physicalInitialTable + dsimp only + split_ifs with hleaf + · rw [shortSourceCost_eq_edit _ _ hleaf] + have hcost : (stateEditCost (physicalSource source state.1) target state.2 : ℚ) ≤ N := by + exact_mod_cast physical_state_cost_le source target N hsize state + change (stateEditCost (physicalSource source state.1) target state.2 : ℚ) ≤ _ + have hcoef : (1 : ℚ) ≤ 32 * F + 1 := by + have hF : (0 : ℚ) ≤ F := Nat.cast_nonneg _ + linarith + exact hcost.trans (by simpa only [one_mul] using mul_le_mul_of_nonneg_right hcoef (Nat.cast_nonneg (α := ℚ) N)) + · unfold localInitialConeTable + split_ifs + · positivity + · exact rationalMinimum_le_fallback _ _ + + theorem rationalPhysicalBellman_nonneg {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (hL : 0 ≤ L) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (hinitial : ∀ state, 0 ≤ initial state) + (value : PhysicalEntry M J target.length → ℚ) (hvalue : ∀ state, 0 ≤ value state) + (state : PhysicalEntry M J target.length) : + 0 ≤ rationalPhysicalBellman source target P L initial representatives value state := by + unfold rationalPhysicalBellman + dsimp only + split_ifs + · exact hinitial state + · apply (le_rationalMinimum_iff _ _ _).2 + refine ⟨hinitial state, ?_⟩ + intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + unfold rationalActionValue + exact add_nonneg (add_nonneg (mul_nonneg hL (Nat.cast_nonneg _)) + (rationalActualWideActions_connection_nonneg _ _ _ action ha)) (sum_nonneg fun i _ => hvalue _) + · exact hinitial state + + theorem stageWarmup_nonneg_all_seeds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (t : ℕ) (state : PhysicalEntry M J target.length) : + 0 ≤ stageWarmup source target U N P F A t state := by + induction t generalizing state with + | zero => exact stageInitial_nonneg_all_seeds source target U N P F A state + | succ t ih => + exact rationalPhysicalBellman_nonneg source target P (128 * F) (by positivity) _ _ + (stageInitial_nonneg_all_seeds source target U N P F A) _ ih state + + theorem stageWarmup_le_initial_all_seeds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (t : ℕ) (state : PhysicalEntry M J target.length) : + stageWarmup source target U N P F A t state ≤ stageInitial source target U N P F A state := by + cases t with + | zero => exact le_rfl + | succ t => + change rationalPhysicalBellman source target P (128 * F) _ _ _ state ≤ _ + unfold rationalPhysicalBellman + dsimp only + split_ifs + · exact le_rfl + · exact rationalMinimum_le_fallback _ _ + · exact le_rfl + + theorem physicalRefinement_upper_all_seeds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) (t : ℕ) + (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node t q ≤ (32 * F + 1 : ℚ) * N := by + exact (physicalRefinement_le_warmup source target U N P F A T delta choices node t q).trans + ((stageWarmup_le_initial_all_seeds source target U N P F A T (node, q)).trans + (stageInitial_upper_all_seeds source target U N P F A hsize (node, q))) + + theorem physicalRefinement_nonneg_all_seeds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) (t : ℕ) + (q : TargetInterval target.length) : + 0 ≤ physicalRefinement source target U N P F A T delta choices node t q := by + by_cases hbelow : node.1.val < J + · by_cases hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · rw [physicalRefinement_at_terminal source target U N P F A T delta choices node (Or.inr hleaf)] + exact stageInitial_nonneg_all_seeds source target U N P F A (node, q) + · have hpost := (physicalRefinement_bellman_invariants source target U N P F A T delta choices node t q).1 + have hnonneg : 0 ≤ rationalPhysicalBellman source target P (128 * F) + (stageInitial source target U N P F A) (stageRepresentatives source target U N P F A) + (fun state => physicalRefinement source target U N P F A T delta choices state.1 t state.2) (node, q) := by + unfold rationalPhysicalBellman + dsimp only + rw [dite_eq_left hbelow, ite_eq_right hleaf] + apply (le_rationalMinimum_iff _ _ _).2 + refine ⟨stageInitial_nonneg_all_seeds source target U N P F A (node, q), ?_⟩ + intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + unfold rationalActionValue + apply add_nonneg + · exact add_nonneg (mul_nonneg (by positivity) (Nat.cast_nonneg _)) + (rationalActualWideActions_connection_nonneg _ _ _ action ha) + · apply sum_nonneg + intro i _ + exact physicalRefinement_nonneg_all_seeds source target U N P F A T delta choices + (physicalChild node hbelow (action.childState i).1) t (action.childState i).2 + exact hnonneg.trans hpost + · rw [physicalRefinement_at_terminal source target U N P F A T delta choices node (Or.inl hbelow)] + exact stageInitial_nonneg_all_seeds source target U N P F A (node, q) +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCachedWords.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCachedWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..e610c76b4847ed6e374e381fd21a66851b9986a9 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCachedWords.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.EditApproximation.Binary.BinaryPowerStorage +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalDenominator + +namespace OAI + +/-! The cache normalization algorithm applied to the actual all-seed local +table invariants. These word bounds require neither a good-seed event nor a +bound on the temporary numerator and denominator before normalization. -/ + +namespace EditApproximation + +theorem physicalLocalRefinement_cached_word {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A tau : ℚ) (hsize : source.length + target.length ≤ N) + (T ell : ℕ) (hell : 0 < ell) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (online : PhysicalNode M J → PhysicalChildTables M target.length → ℕ → + TargetInterval target.length → List (PhysicalRationalAction M target.length)) + (honline : ∀ node children t q action, action ∈ online node children t q → action.connection.den = 1) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) + (raw : BinaryFraction) (hraw : raw.value = + physicalLocalRefinement source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T draw online node t q) + (base : List Bool) (hbase : bitWordValue base = ell ^ 10 + 1) : + let result := BinaryFraction.powerDenominatorWithWork raw base + (by rw [hbase]; omega) (J - node.1.val) + result.1.value = raw.value ∧ result.1.width ≤ + Nat.size ((32 * F + 1) * N) + 2 * (J - node.1.val) * base.length + 3 := by + dsimp only + have hd : raw.value.den ∣ bitWordValue base ^ (J - node.1.val) := by + rw [hraw, hbase] + exact physicalLocalRefinement_den_dvd source target U N P F exponent Q A tau T ell hell + draw online honline node t q + have hb := physicalLocalRefinement_bounds source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T (by positivity) draw online node t q + have hv : |raw.value| ≤ (((32 * F + 1) * N : ℕ) : ℚ) := by + rw [hraw, abs_of_nonneg hb.1] + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using + hb.2.trans (stageInitial_upper_all_seeds source target U N P F A hsize (node, q)) + refine ⟨BinaryFraction.powerDenominatorWithWork_value raw base _ _ hd, ?_⟩ + have hw := BinaryFraction.powerDenominatorWithWork_width raw base (by rw [hbase]; omega) + (J - node.1.val) ((32 * F + 1) * N) base.length le_rfl hd hv + simpa only [Nat.mul_add, Nat.mul_one, Nat.mul_assoc, Nat.add_assoc] using hw + +theorem physicalLocalOnlineRefinement_cached_word {α : Type*} [DecidableEq α] + {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent H Q : ℕ) (A tau eta kappa : ℚ) + (hsize : source.length + target.length ≤ N) (T ell : ℕ) (hell : 0 < ell) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (integer : PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) + (raw : BinaryFraction) (hraw : raw.value = + physicalLocalRefinement source target U N P F exponent Q A tau (1 / (ell : ℚ) ^ 10) + T draw (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) node t q) + (base : List Bool) (hbase : bitWordValue base = ell ^ 10 + 1) : + let result := BinaryFraction.powerDenominatorWithWork raw base + (by rw [hbase]; omega) (J - node.1.val) + result.1.value = raw.value ∧ result.1.width ≤ + Nat.size ((32 * F + 1) * N) + 2 * (J - node.1.val) * base.length + 3 := + physicalLocalRefinement_cached_word source target U N P F exponent Q A tau hsize T ell hell + draw _ (physicalLocalOnline_connection_den source target U N P F exponent H T A tau eta kappa integer) + node t q raw hraw base hbase + +theorem physicalLocalWarmup_cached_word {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (t : ℕ) (state : PhysicalEntry M J target.length) + (raw : BinaryFraction) (hraw : raw.value = physicalLocalWarmup source target U N P F A t state) : + let result := BinaryFraction.fixedDenominatorWithWork raw [true] (by decide) + result.1.value = raw.value ∧ result.1.width ≤ Nat.size ((32 * F + 1) * N) + 3 := by + dsimp only + have hd : raw.value.den ∣ bitWordValue [true] := by + rw [hraw, physicalLocalWarmup_den_one] + exact one_dvd _ + have hb := physicalLocalWarmup_bounds source target U N P F A t state + have hv : |raw.value| ≤ (((32 * F + 1) * N : ℕ) : ℚ) := by + rw [hraw, abs_of_nonneg hb.1] + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using + hb.2.trans (stageInitial_upper_all_seeds source target U N P F A hsize state) + exact ⟨BinaryFraction.fixedDenominatorWithWork_value raw [true] (by decide) hd, + BinaryFraction.fixedDenominatorWithWork_width raw [true] (by decide) hd + ((32 * F + 1) * N) 1 hv (by decide)⟩ + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseBitWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseBitWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f28ba87d2f4f97fe939cb41846dfcff3a292695 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseBitWork.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.EditApproximation.Coarse.CoarseEntryCostSum +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseInputWork + +namespace OAI + +namespace EditApproximation + +section Coarse +variable {M J R B : ℕ} [NeZero M] [NeZero R] [NeZero B] + (source target : List ℕ) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + (depth : PhysicalEntry M J target.length → ℕ) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) copies T S +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw + +/-- Bit arithmetic is executed once for each fresh coarse source request. -/ +noncomputable def physicalFamilyCoarseBitWork (bits : ℕ) (encode : Sum Key Table → ℕ) + (root : Table) (coarse : PhysicalCoarseDraw source target B depth) : ℝ := + let initial := clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse) + let result := chargedRandomMemoEvaluate source target N P ell exponent H (ell ^ 80) + T S (passes + 1) copies factor multiplier tau eta kappa delta readGroup readInteger initial + answer bits encode root + coarseEntryCostSum source target N depth coarse + (fun entry => Sum.inr (Sum.inl entry) ∈ result.freshKeys) + +theorem physicalFamilyCoarseBitWork_bound (bits : ℕ) (encode : Sum Key Table → ℕ) + (root : Table) (coarse : PhysicalCoarseDraw source target B depth) (C : ℝ) + (hc : ∀ entry : PhysicalEntry M J target.length, + (coarseEntryBinaryCost N B (depth entry) (physicalSource source entry.1) + (substring target entry.2.lo entry.2.hi) (coarse entry) : ℝ) ≤ + C * ((coarseInitialArrayWork B (depth entry) (initialThresholdQ N) (initialLambda N) + (physicalSource source entry.1) (substring target entry.2.lo entry.2.hi) (coarse entry) : ℝ) + + ((physicalSource source entry.1).length + 1 : ℕ))) : + physicalFamilyCoarseBitWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw depth bits encode root coarse ≤ C * + (physicalFamilyMemoCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth bits encode root coarse + + physicalFamilyCoarseInputWork source target N P H T S passes copies factor multiplier + tau eta kappa delta + (clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse)) + draw bits encode root) := by + unfold physicalFamilyCoarseBitWork physicalFamilyMemoCoarseWork physicalFamilyCoarseInputWork + exact coarseEntryCostSum_bound source target N depth coarse _ C hc + +end Coarse +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseExecution.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseExecution.lean new file mode 100644 index 0000000000000000000000000000000000000000..96a6a7b7671f639110b0bfacefc0485da15726b5 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseExecution.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseSeedLaw +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyRuntime +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation +open MeasureTheory + +section Execution +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P H B : ℕ) + (depth : PhysicalEntry M J target.length → ℕ) + + + + + +variable [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] + +noncomputable def physicalCoarseExecutionLaw : + Measure (PhysicalCoarseExecution (R := R) source target N P H B depth) := + (coarseFullSeedMeasure B depth + (fun entry => physicalSource source entry.1) + (fun entry => substring target entry.2.lo entry.2.hi)).prod + (rejectionRuntimeArrayLaw (physicalFamilyRange (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H + (inputSmallLog N ^ 80) (computedSeedPassCount N) (H ^ 2))) + +omit [NeZero M] [NeZero R] [NeZero B] in + theorem physicalCoarseExecutionProjection_measurable : + Measurable (physicalCoarseExecutionProjection (R := R) source target N P H B depth) := by + unfold physicalCoarseExecutionProjection + exact ((measurable_of_finite (physicalCoarseSeedTable source target N B depth)).comp + measurable_fst).prodMk measurable_snd + +omit [NeZero R] in + theorem physicalCoarseExecutionProjection_law : + (physicalCoarseExecutionLaw (R := R) source target N P H B depth).map + (physicalCoarseExecutionProjection (R := R) source target N P H B depth) = + physicalFamilyRuntimeLaw (R := R) target N P H + (physicalCoarseSeedLaw source target N B depth) := by + unfold physicalCoarseExecutionLaw physicalCoarseExecutionProjection physicalFamilyRuntimeLaw + change ((_ : Measure (PhysicalCoarseDraw source target B depth)).prod _).map + (Prod.map (physicalCoarseSeedTable source target N B depth) id) = _ + rw [← Measure.map_prod_map _ _ (measurable_of_finite _) measurable_id, Measure.map_id] + rfl + +end Execution +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseInputWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseInputWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7bb5b74cd613762f7812ef8a376539a46fe2868 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseInputWork.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyMemoCoarse + +namespace OAI + +namespace EditApproximation + +section Coarse +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (initial : PhysicalEntry M J target.length → ℕ) (hP : 0 < P) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) copies T S +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw + +/-- Source scans and a constant setup charge for each first coarse request. -/ +noncomputable def physicalFamilyCoarseInputWork (bits : ℕ) (encode : Sum Key Table → ℕ) + (root : Table) : ℝ := + let result := chargedRandomMemoEvaluate source target N P ell exponent H (ell ^ 80) + T S (passes + 1) copies factor multiplier tau eta kappa delta readGroup readInteger initial + answer bits encode root + ∑ entry, selectionIndicator (Sum.inr (Sum.inl entry) ∈ result.freshKeys) * + ((physicalSource source entry.1).length + 1 : ℕ) + +theorem physicalFamilyCoarseQuery_input_cost_le_width (root : Table) (hroot : root.depth = J) : + (physicalFamilyCoarseQuery source target N P H T S passes copies factor multiplier + tau eta kappa delta draw root).cost (fun entry => (initial entry : ℚ)) + (fun entry => (physicalSource source entry.1).length + 1) ≤ + (physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hP draw root).widthWork M source.length := by + apply (FiniteQuery.cost_mono_weights _ _ _ _ ?_).trans + (chargedRandomCoarseQuery_width_cost_le source target N P H T S (passes + 1) copies + factor multiplier tau eta kappa delta readGroup readInteger answer initial + (physicalFamilyGroup target N P ell exponent H (ell ^ 80) passes copies draw) + (physicalFamilyInteger source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta hP draw initial) + (physicalFamilyProgram_value source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta initial hP draw) root hroot) + intro entry + rw [physicalSource_length_eq] + simpa only [physicalSourceInterval, Nat.add_comm] using Nat.add_le_add_right + (sourceIntervalAt_width M source.length entry.1.1.val (Nat.pos_of_neZero M) entry.1.2) 1 + +theorem physicalFamilyCoarseInputWork_le (bits : ℕ) (encode : Sum Key Table → ℕ) + (hinjective : Function.Injective encode) (hbounded : ∀ key, encode key < 2 ^ bits) + (root : Table) (hroot : root.depth = J) : + physicalFamilyCoarseInputWork source target N P H T S passes copies factor multiplier + tau eta kappa delta initial draw bits encode root ≤ + ((physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hP draw root).widthWork M source.length : ℝ) := by + classical + let query := physicalFamilyCoarseQuery source target N P H T S passes copies factor multiplier + tau eta kappa delta draw root + have hkey (entry : PhysicalEntry M J target.length) := + chargedRandomMemo_coarse_key source target N P ell exponent H (ell ^ 80) T S + (passes + 1) copies factor multiplier tau eta kappa delta readGroup readInteger answer initial + (physicalFamilyRequestValue source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta initial hP draw) + (physicalFamilyProgram_value source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta initial hP draw) + bits encode hinjective hbounded root entry + have hs := sum_selected_nat_weights_le (query.keys (fun entry => (initial entry : ℚ))) + (fun entry => (physicalSource source entry.1).length + 1) + have hc := physicalFamilyCoarseQuery_input_cost_le_width source target N P H T S passes copies + factor multiplier tau eta kappa delta initial hP draw root hroot + change query.cost (fun entry => (initial entry : ℚ)) + (fun entry => (physicalSource source entry.1).length + 1) ≤ _ at hc + rw [FiniteQuery.cost_eq_sum] at hc + apply le_trans (b := ∑ entry, selectionIndicator (entry ∈ query.keys + (fun entry => (initial entry : ℚ))) * ((physicalSource source entry.1).length + 1 : ℕ)) + · unfold physicalFamilyCoarseInputWork + apply Finset.sum_le_sum + intro entry _ + apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) + by_cases he : Sum.inr (Sum.inl entry) ∈ + (chargedRandomMemoEvaluate source target N P ell exponent H (ell ^ 80) T S (passes + 1) + copies factor multiplier tau eta kappa delta readGroup readInteger initial answer + bits encode root).freshKeys + · have hq := hkey entry he + change entry ∈ query.keys (fun entry => (initial entry : ℚ)) at hq + simp only [selectionIndicator, he, hq, ite_true, le_refl] + · simp only [selectionIndicator, he, ite_false] + split <;> norm_num + · exact hs.trans (by exact_mod_cast hc) + +end Coarse +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarsePreparation.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarsePreparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..acdd38e13e4f1abaa72008ced921e7c88530e0d0 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarsePreparation.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.EditApproximation.Coarse.CoarseInputPreparation +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseInputWork +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + + + +theorem physicalCoarsePreparationCost_bound {M J : ℕ} (source target : List ℕ) (H : ℕ) + (hH : 100 ≤ H) (hs : Nat.size source.length ≤ H ^ 3) (ht : Nat.size target.length ≤ H ^ 3) + (hsymbol : ∀ a ∈ source ++ target, Nat.size a ≤ H ^ 3) + (entry : PhysicalEntry M J target.length) : + physicalCoarsePreparationCost source target entry ≤ H ^ 6 * ((physicalSource source entry.1).length + 1) := by + unfold physicalCoarsePreparationCost + rw [physicalSource_length_eq] + exact coarsePreparedSlicesWithWork_height_bound source target + (physicalSourceInterval source.length entry.1).lo (physicalSourceInterval source.length entry.1).hi + entry.2.lo entry.2.hi H (physicalSourceInterval source.length entry.1).ordered + (physicalSourceInterval source.length entry.1).valid entry.2.ordered entry.2.valid hH hs ht hsymbol + +section Coarse +variable {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List ℕ) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (initial : PhysicalEntry M J target.length → ℕ) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) copies T S +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw + + + +theorem physicalFamilyCoarsePreparationWork_bound (bits : ℕ) (encode : Sum Key Table → ℕ) + (root : Table) (hH : 100 ≤ H) (hs : Nat.size source.length ≤ H ^ 3) + (ht : Nat.size target.length ≤ H ^ 3) + (hsymbol : ∀ a ∈ source ++ target, Nat.size a ≤ H ^ 3) : + physicalFamilyCoarsePreparationWork source target N P H T S passes copies factor multiplier + tau eta kappa delta initial draw bits encode root ≤ + (H : ℝ) ^ 6 * physicalFamilyCoarseInputWork source target N P H T S passes copies factor multiplier + tau eta kappa delta initial draw bits encode root := by + classical + unfold physicalFamilyCoarsePreparationWork physicalFamilyCoarseInputWork + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro entry _ + have hc : (physicalCoarsePreparationCost source target entry : ℝ) ≤ + (H : ℝ) ^ 6 * ((physicalSource source entry.1).length + 1 : ℕ) := by + exact_mod_cast physicalCoarsePreparationCost_bound source target H hH hs ht hsymbol entry + have hp := mul_le_mul_of_nonneg_left hc + (show 0 ≤ selectionIndicator (Sum.inr (Sum.inl entry) ∈ + (chargedRandomMemoEvaluate source target N P ell exponent H (ell ^ 80) T S (passes + 1) + copies factor multiplier tau eta kappa delta readGroup readInteger initial answer bits encode root).freshKeys) by + unfold selectionIndicator; split <;> norm_num) + exact hp.trans_eq (by ring) + +end Coarse +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseSamplingWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseSamplingWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ae3dbd9d995f200811c2bb5b5eac34392b8d785 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseSamplingWork.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.EditApproximation.Coarse.CoarseInitialLabels +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseInputWork +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +section Coarse +variable {M J R B : ℕ} [NeZero M] [NeZero R] [NeZero B] + (source target : List ℕ) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + (depth : PhysicalEntry M J target.length → ℕ) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) copies T S +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw + +/- One binary word is consumed for every threshold label actually exposed. -/ + + +omit [NeZero B] in +theorem physicalFamilyCoarseSamplingWork_bound (bits : ℕ) (encode : Sum Key Table → ℕ) + (root : Table) (coarse : PhysicalCoarseDraw source target B depth) : + physicalFamilyCoarseSamplingWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw depth bits encode root coarse ≤ (Nat.size B : ℝ) * + physicalFamilyMemoCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth bits encode root coarse := by + classical + unfold physicalFamilyCoarseSamplingWork physicalFamilyMemoCoarseWork + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro entry _ + have h := coarseInitialLabelCount_le_arrayWork B (depth entry) (initialThresholdQ N) (initialLambda N) + (physicalSource source entry.1) (substring target entry.2.lo entry.2.hi) (coarse entry) + have hs : 0 ≤ selectionIndicator (Sum.inr (Sum.inl entry) ∈ + (chargedRandomMemoEvaluate source target N P ell exponent H (ell ^ 80) + T S (passes + 1) copies factor multiplier tau eta kappa delta readGroup readInteger + (clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse)) + answer bits encode root).freshKeys) := by + unfold selectionIndicator + split <;> norm_num + push_cast + exact (mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (Nat.cast_le.mpr h) (Nat.cast_nonneg (Nat.size B))) hs).trans_eq (by ring) + +end Coarse +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseSeedLaw.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseSeedLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..caafda6a0992a5b405371dffe6795195248cff3d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCoarseSeedLaw.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSeedTables +import OAI.Combinatorics.EditApproximation.Coarse.CoarseGlobalSeed +import OAI.Combinatorics.EditApproximation.Geometry.StateDomain +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The clamped incoming seed table is the image of the actual complete +coarse sampler. Its simultaneous initial accuracy is a derived fact. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section CoarseLaw + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N B : ℕ) + (depth : PhysicalEntry M J target.length → ℕ) + + + + + +variable [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] + +noncomputable def physicalCoarseSeedLaw : Measure (ClampedPhysicalSeed M J target.length N) := by + classical + exact (coarseFullSeedMeasure B depth + (fun state : PhysicalEntry M J target.length => physicalSource source state.1) + (fun state : PhysicalEntry M J target.length => substring target state.2.lo state.2.hi)).map + (physicalCoarseSeedTable source target N B depth) + +instance physicalCoarseSeedLaw_probability : + IsProbabilityMeasure (physicalCoarseSeedLaw source target N B depth) := by + unfold physicalCoarseSeedLaw + infer_instance + +theorem physicalCoarseSeedLaw_failure (hN : 0 < N) + (hsize : source.length + target.length ≤ N) (hell : 200 ≤ inputSmallLog N) + (hB : B = (integerParameters N).B) (hM : M = (integerParameters N).M) + (hJ : J = intervalTreeDepth M source.length) + (hdepth : ∀ state, depth state = computedCoarseDepth N + (coarseEntryWidth (physicalSource source state.1) (substring target state.2.lo state.2.hi))) + (bernstein : FiniteBernsteinInput (Measure.pi fun _ : Fin B => + (PMF.uniformOfFintype (Fin B)).toMeasure)) : + (physicalCoarseSeedLaw source target N B depth).real + {seed | ¬ physicalSeedGood source target ((integerParameters N).initialFactor : ℚ) seed} < 1 / 100 := by + classical + have hwidth (state : PhysicalEntry M J target.length) : + coarseEntryWidth (physicalSource source state.1) (substring target state.2.lo state.2.hi) ≤ N := by + apply max_le + · exact (physicalSource_length_le source state.1).trans (by omega) + · have hlen : (substring target state.2.lo state.2.hi).length ≤ target.length := by + simp only [substring, List.length_drop, List.length_take] + exact (Nat.sub_le _ _).trans (min_le_right _ _) + exact hlen.trans (by omega) + have hcount : Fintype.card (PhysicalEntry M J target.length) ≤ 2 ^ (5 * inputHeight N) := by + rw [hJ, hM] + exact computed_labeledEntry_card_le N source.length target.length hN (by omega) (by omega) hell + have h := computed_fullSeedTable_accuracy N B depth + (fun state : PhysicalEntry M J target.length => physicalSource source state.1) + (fun state : PhysicalEntry M J target.length => substring target state.2.lo state.2.hi) + hB hdepth hN hwidth hcount hell bernstein + rw [physicalCoarseSeedLaw, map_measureReal_apply (measurable_of_finite _) (Set.toFinite _).measurableSet] + have hevents : (physicalCoarseSeedTable source target N B depth) ⁻¹' + {seed | ¬ physicalSeedGood source target ((integerParameters N).initialFactor : ℚ) seed} = + {draw : PhysicalCoarseDraw source target B depth | ¬ ∀ state : PhysicalEntry M J target.length, + stateEditCost (physicalSource source state.1) target state.2 ≤ + coarseFullSeedTable N B depth + (fun state : PhysicalEntry M J target.length => physicalSource source state.1) + (fun state : PhysicalEntry M J target.length => substring target state.2.lo state.2.hi) draw state ∧ + coarseFullSeedTable N B depth + (fun state : PhysicalEntry M J target.length => physicalSource source state.1) + (fun state : PhysicalEntry M J target.length => substring target state.2.lo state.2.hi) draw state ≤ + (integerParameters N).initialFactor * stateEditCost (physicalSource source state.1) target state.2} := by + ext draw + apply not_congr + unfold physicalSeedGood clampedSeedNat physicalCoarseSeedTable + constructor + · intro hg state + exact ⟨(hg state).1, by exact_mod_cast (hg state).2⟩ + · intro hg state + exact ⟨(hg state).1, by exact_mod_cast (hg state).2⟩ + rw [hevents] + exact h + +end CoarseLaw + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCommonSource.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCommonSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..778d17678823a984c4bc6b8f05544d8fce715a03 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalCommonSource.lean @@ -0,0 +1,153 @@ +import OAI.Combinatorics.EditApproximation.Geometry.CommonRangeSource +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalProgramLaw +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The actual bounded physical program can share one source universe +across incoming seed tables. Online coordinates include their requested +range; group coordinates share whole-cell arrays. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + + + +abbrev PhysicalCommonCoordinate (M J N n exponent F Q R B : ℕ) + (key : PhysicalCommonKey M J N n exponent B) : Type := + match key with + | .inl online => Fin R → Fin online.2.val.val + | .inr group => PhysicalLocalGroupArray M J N n exponent F Q R group + +section Source + +variable (M J N n exponent F Q R B : ℕ) + [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + +instance physicalCommonCoordinateFintype (key : PhysicalCommonKey M J N n exponent B) : + Fintype (PhysicalCommonCoordinate M J N n exponent F Q R B key) := by + cases key <;> dsimp only [PhysicalCommonCoordinate] <;> infer_instance + +instance physicalCommonCoordinateMeasurable (key : PhysicalCommonKey M J N n exponent B) : + MeasurableSpace (PhysicalCommonCoordinate M J N n exponent F Q R B key) := by + cases key <;> dsimp only [PhysicalCommonCoordinate] <;> infer_instance + +instance physicalCommonCoordinateSingleton (key : PhysicalCommonKey M J N n exponent B) : + MeasurableSingletonClass (PhysicalCommonCoordinate M J N n exponent F Q R B key) := by + cases key <;> dsimp only [PhysicalCommonCoordinate, physicalCommonCoordinateMeasurable] <;> infer_instance + +noncomputable def physicalCommonCoordinateLaw (key : PhysicalCommonKey M J N n exponent B) : + Measure (PhysicalCommonCoordinate M J N n exponent F Q R B key) := + match key with + | .inl online => Measure.pi fun _ : Fin R => + (PMF.uniformOfFintype (Fin online.2.val.val)).toMeasure + | .inr group => physicalLocalGroupArrayLaw M J N n exponent F Q R group + +instance physicalCommonCoordinateLaw_probability (key : PhysicalCommonKey M J N n exponent B) : + IsProbabilityMeasure (physicalCommonCoordinateLaw M J N n exponent F Q R B key) := by + cases key <;> dsimp only [physicalCommonCoordinateLaw, PhysicalCommonCoordinate, + physicalCommonCoordinateMeasurable] <;> infer_instance + +abbrev PhysicalCommonDraw := ∀ key : PhysicalCommonKey M J N n exponent B, + PhysicalCommonCoordinate M J N n exponent F Q R B key + +noncomputable def physicalCommonLaw : Measure (PhysicalCommonDraw M J N n exponent F Q R B) := + Measure.pi (physicalCommonCoordinateLaw M J N n exponent F Q R B) + +instance physicalCommonLaw_probability : IsProbabilityMeasure + (physicalCommonLaw M J N n exponent F Q R B) := by + unfold physicalCommonLaw + infer_instance + +end Source + +section Selection + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T exponent H Q R B : ℕ) (tau : ℚ) + (hbound : ∀ key, physicalLocalOnlineMass source target U N P F A T exponent H tau key ≤ B) + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalCommonMass_positive (key : PhysicalLocalOnlineKey M J N target.length) : + 0 < physicalLocalOnlineMass source target U N P F A T exponent H tau key := + optimizerTriangularMass_positive _ + (pow_pos (physicalLocalOnlineBandG_positive source target U N P F A T exponent H tau key) 80) + +def physicalCommonSelectedOnlineKey (online : PhysicalLocalOnlineKey M J N target.length) : + CommonRangeKey (PhysicalLocalOnlineKey M J N target.length) B := + (online, positiveDrawRangeOfLE B + (physicalLocalOnlineMass source target U N P F A T exponent H tau online) + (physicalCommonMass_positive source target U N P F A T exponent H tau online) (hbound online)) + +def physicalCommonSelectedKey (key : PhysicalLocalProgramKey M J N target.length exponent) : + PhysicalCommonKey M J N target.length exponent B := + match key with + | .inl online => .inl (physicalCommonSelectedOnlineKey source target U N P F A T exponent H B tau hbound online) + | .inr group => .inr group + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalCommonSelectedKey_injective : Function.Injective + (physicalCommonSelectedKey source target U N P F A T exponent H B tau hbound) := by + intro left right heq + cases left with + | inl left => + cases right with + | inl right => exact congrArg Sum.inl (congrArg Prod.fst (Sum.inl.inj heq)) + | inr right => exact False.elim (Sum.inl_ne_inr heq) + | inr left => + cases right with + | inl right => exact False.elim (Sum.inr_ne_inl heq) + | inr right => exact congrArg Sum.inr (Sum.inr.inj heq) + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalCommonSelectedOnlineKey_range (online : PhysicalLocalOnlineKey M J N target.length) : + (physicalCommonSelectedOnlineKey source target U N P F A T exponent H B tau hbound online).2.val.val = + physicalLocalOnlineMass source target U N P F A T exponent H tau online := by + exact positiveDrawRangeOfLE_val B _ + (physicalCommonMass_positive source target U N P F A T exponent H tau online) (hbound online) + +def physicalCommonCoordinateImage (key : PhysicalLocalProgramKey M J N target.length exponent) : + PhysicalCommonCoordinate M J N target.length exponent F Q R B + (physicalCommonSelectedKey source target U N P F A T exponent H B tau hbound key) → + PhysicalLocalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau key := + match key with + | .inl online => fun array time => Fin.cast + (physicalCommonSelectedOnlineKey_range source target U N P F A T exponent H B tau hbound online) + (array time) + | .inr _ => id + +def physicalCommonSample + (draw : PhysicalCommonDraw M J N target.length exponent F Q R B) : + PhysicalLocalProgramDraw (R := R) source target U N P F A T exponent H Q tau := + fun key => physicalCommonCoordinateImage source target U N P F A T exponent H Q R B tau hbound key + (draw (physicalCommonSelectedKey source target U N P F A T exponent H B tau hbound key)) + +theorem physicalCommonSample_law : + (physicalCommonLaw M J N target.length exponent F Q R B).map + (physicalCommonSample source target U N P F A T exponent H Q R B tau hbound) = + physicalLocalProgramDrawLaw (R := R) source target U N P F A T exponent H Q tau := by + have h := finite_pi_restrict_image_map + (physicalCommonCoordinateLaw M J N target.length exponent F Q R B) + (physicalCommonSelectedKey source target U N P F A T exponent H B tau hbound) + (physicalCommonSelectedKey_injective source target U N P F A T exponent H B tau hbound) + (physicalCommonCoordinateImage source target U N P F A T exponent H Q R B tau hbound) + (fun _ => measurable_of_finite _) + refine h.trans ?_ + unfold physicalLocalProgramDrawLaw + congr 1 + funext key + cases key with + | inl online => + exact finite_uniform_array_cast R _ _ + (physicalCommonSelectedOnlineKey_range source target U N P F A T exponent H B tau hbound online) + | inr group => exact Measure.map_id + +end Selection + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalComparisonBand.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalComparisonBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..931b68afcd25a56e7c12742c2d749f97ee0ac241 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalComparisonBand.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalUnskippedComparison +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalNodeRegret +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonEnergy +import OAI.Combinatorics.EditApproximation.Refinement.ComputedBandSpacing + +namespace OAI + +/-! Non-bad, low-velocity comparison children belong to an actual unskipped cell band. -/ + +namespace EditApproximation + +open Finset + +section Node + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P : ℕ) (A : ℚ) + (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hMeq : M = (integerParameters N).M) (hPeq : P = (integerParameters N).P) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (q : TargetInterval target.length) (hc : 0 < stateEditCost (physicalSource source node) target q) + +local notation "F" => inputSmallLog N +local notation "parent" => physicalSourceInterval source.length node +local notation "b" => (2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) : ℕ) +local notation "r" => roundInterval (seedGridSpacing b P) q +local notation "action" => comparisonChildren source target hM P hP parent q hc +local notation "child" => physicalBandChildMassTable source target U N P F A T node hbelow +local notation "childR" => fun i s => (child i s : ℝ) +local notation "initial" => physicalBandChildInitial source target U N P F A node hbelow +local notation "tau" => RationalParameters.tau (rationalParameters (inputSmallLog N)) +local notation "theta" => RationalParameters.theta (rationalParameters (inputSmallLog N)) +local notation "thetaExponent" => 40 * smallLogExponent N + +include hN hell hMeq hPeq hsize hA hseed hT in + theorem physicalComparison_unskipped + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hnonempty : wideActionList M parent r b P ≠ []) + (hvelocity : |rationalStateGap (physicalSource source node) target r / + rationalWideActionMinimum parent r b P hnonempty child| ≤ 1 - tau) + (hKsmall : comparisonActionCurvature source target parent r action childR ≤ b / heightQuarterRoot N) + (hGsmall : comparisonActionMass action childR - wideActionMinimum parent r b P hnonempty childR ≤ + b / heightQuarterRoot N) : + ∃ member : UnskippedBand source target parent b P thetaExponent tau F child initial, + member ∈ physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau + (targetCell (theta * b) r) ∧ member.center = r ∧ action ∈ member.actions := by + have hF : 1 ≤ F := Nat.one_le_two_pow + have hell2 : 2 ≤ F := by + have h : 2 ≤ (2 : ℕ) ^ 1000 := by + simpa only [pow_one] using pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 1 ≤ 1000) + exact h.trans hell + have hspec := comparisonChildren_spec source target hM P hP parent q hc + have hrep := stageRounded_representative_mem source target U N P F A hsize hP hF hA hseed node q hc + have hdyadic := cost_dyadicScale _ _ hc le_rfl + have hcR : (stateEditCost (physicalSource source node) target q : ℝ) ≤ 2 * (b : ℝ) := by + exact_mod_cast hdyadic.2.2.le + have hcost := comparisonChildren_cost_bound source target hM P hP parent q hc + change (∑ i, (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) : ℝ)) ≤ + (1 + 4 * (M : ℝ) / P) * stateEditCost (physicalSource source node) target q at hcost + have hcostSum : (∑ i, (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) : ℝ)) ≤ + 4 * b := by + have h := mul_le_mul_of_nonneg_right hMP + (Nat.cast_nonneg (α := ℝ) (stateEditCost (physicalSource source node) target q)) + nlinarith only [hcost, hcR, h] + have ha : (1 : ℝ) ≤ refinementFactor A F := by + simpa only [Rat.cast_one] using (Rat.cast_le (K := ℝ)).mpr (refinementFactor_spec A F (by omega)).1 + have hlower := stageWarmupMass_child_lower source target hM U N P F A hsize hP hF hA hseed T hT node hbelow + have hupper (i : Fin M) : (child i (action i) : ℝ) ≤ + 2 * F * stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) := by + dsimp only [physicalBandChildMassTable] + have h := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT + (physicalChild node hbelow i, action i) + simpa only [Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast] using + (Rat.cast_le (K := ℝ)).mpr (h.2.2.1.trans h.2.2.2) + have hpositive := (stageComparison_positive_movement source target hM U N P F A hsize hP hF hA hseed + T hT node q hc hscale).1 + have hband := computed_comparison_band_mem source target N hN hell hM hMeq parent r action + hspec.1 hnonempty child (refinementFactor A F : ℝ) ha hlower hupper hcostSum hpositive + hspec.2.1 hspec.2.2.2.1 hvelocity hKsmall hGsmall + have hnum := computed_band_basic_constants N hell2 + have hspacing := computed_band_spacing_dominates N hN hell + rw [← hMeq, ← hPeq, computed_theta_dyadic] at hspacing + rw [computed_theta_dyadic] at hnum + have hmember := physical_comparison_unskipped source target hM U N P F A hsize hP hF hA hseed + T node hbelow b thetaExponent (Nat.two_pow_pos _) ⟨_, rfl⟩ + ⟨_, hPeq.trans (computed_P_dyadic N)⟩ tau hnum.1 hnum.2.2.1 hnum.2.2.2.1 hnum.2.2.2.2 hspacing + r hrep action (by simpa only [← computed_theta_dyadic, physicalSource] using hband) + (by exact_mod_cast hcostSum) + simpa only [physicalNodeCellBands, computed_theta_dyadic] using hmember + +end Node + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalConditionalAccuracy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalConditionalAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..60df88021794d3ec5fa064bac0749caa4fe98a87 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalConditionalAccuracy.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFinalAccuracy +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseSeedLaw +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Conditional accuracy of coarse sampling, adaptive median passes and the final fresh query. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + + + +section Conditional + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N P T S H B : ℕ) + [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] + (depth : PhysicalEntry M J target.length → ℕ) + +noncomputable def wholeFinalAnswer + (pair : FinalProgramOutcome (M := M) (J := J) (R := R) source target N P T H) : ℕ := + finalProgramAnswer (R := R) source target N P T S H (finalTargetState target.length) pair + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem wholeFinalAnswer_equal (heq : source = target) + (pair : FinalProgramOutcome (M := M) (J := J) (R := R) source target N P T H) : + wholeFinalAnswer (R := R) source target N P T S H pair = 0 := by + apply finalProgramAnswer_equal + simpa only [finalTargetState, substring, List.take_length, List.drop_zero] using heq + +theorem physical_conditional_accuracy (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hsize : source.length + target.length ≤ N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (hPeq : P = (integerParameters N).P) (hTeq : T = (integerParameters N).T) + (hSeq : S = (integerParameters N).S) (hHeq : H = inputHeight N) + (hB : B = (integerParameters N).B) + (hdepth : ∀ state, depth state = computedCoarseDepth N + (coarseEntryWidth (physicalSource source state.1) (substring target state.2.lo state.2.hi))) + (coarseBernstein : FiniteBernsteinInput (Measure.pi fun _ : Fin B => + (PMF.uniformOfFintype (Fin B)).toMeasure)) + (groupBernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (epsilon : ℝ) (hepsilon : 0 < epsilon) (haccuracy : 10 ≤ (inputSmallLog N : ℝ) * epsilon) : + (2 / 3 : ℝ) ≤ (finalProgramLaw (R := R) source target N P T S H + (physicalCoarseSeedLaw source target N B depth)).real + {pair | EditDistortion.edit source target ≤ wholeFinalAnswer (R := R) source target N P T S H pair ∧ + (wholeFinalAnswer (R := R) source target N P T S H pair : ℝ) ≤ + (1 + epsilon) * EditDistortion.edit source target} := by + classical + have hsmall : 256 ≤ (2 : ℕ) ^ 1000 := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 8 ≤ 1000) + norm_num only [show (2 : ℕ) ^ 8 = 256 by norm_num] at h + exact h + have hcut : 200 ≤ inputSmallLog N := by omega + have hinitial := physicalCoarseSeedLaw_failure source target N B depth hN hsize hcut + hB hMeq hJeq hdepth coarseBernstein + have h := finalProgram_accuracy (R := R) source target N P T S H hN hell hMeq hJeq hPeq + hTeq hSeq hHeq hsize groupBernstein (physicalCoarseSeedLaw source target N B depth) + hinitial.le (finalTargetState target.length) epsilon hepsilon haccuracy + apply (by norm_num : (2 / 3 : ℝ) ≤ 4 / 5).trans + simpa only [wholeFinalAnswer, stateEditCost, finalTargetState, substring, + List.take_length, List.drop_zero] using h + +end Conditional + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalConditionalNode.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalConditionalNode.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d3d6e60cc5169f102a5b26e2bf8667a2b929272 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalConditionalNode.lean @@ -0,0 +1,165 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalParentDraw +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalResampledRegret + +namespace OAI + +/-! +# Conditional expected regret in a fixed child environment + +Finite Bernstein bounds control the parent product draws. Agreement of +deeper selection functions fixes all child histories by locality, and +list membership connects the sampled actions to the refinement recurrence. +-/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +abbrev BandParentSpace (R M b F Q K : ℕ) := + ParentRandomSpace R (optimizerTriangularMass K) M (groupDyadicScales M b F).length + (fun scale => groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) + +noncomputable def bandParentLaw (R M b F Q K : ℕ) [NeZero M] [NeZero (optimizerTriangularMass K)] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] : Measure (BandParentSpace R M b F Q K) := + parentDrawLaw R (optimizerTriangularMass K) M (groupDyadicScales M b F).length + (fun scale => groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) + +theorem physical_conditional_node_regret {α : Type*} [DecidableEq α] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 1764 ≤ inputSmallLog N) + {M J P F b Q thetaExponent R H G K : ℕ} + [NeZero M] [NeZero R] [NeZero (optimizerTriangularMass K)] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (hM : 0 < M) (hMeq : M = (integerParameters N).M) + (hPeq : P = (integerParameters N).P) (hFeq : F = inputSmallLog N) + (eb : ℕ) (hbeq : b = 2 ^ eb) (hQeq : Q = inputSmallLog N ^ 80) + (hthetaeq : thetaExponent = 40 * smallLogExponent N) (hHeq : H = inputHeight N) (hH : 4 ≤ H) + (U : PhysicalEntry M J target.length → ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta η κ : ℚ) + (hdelta : 0 < delta) (hη : 0 < η) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (reference : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (cell : ℕ × ℕ) + (hnonempty : physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent + (rationalParameters F).tau cell ≠ []) + (specified : UnskippedBand source target (physicalSourceInterval source.length node) + b P thetaExponent (rationalParameters F).tau F + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow)) + (hspecified : specified ∈ physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent + (rationalParameters F).tau cell) + (hrep : (b, specified.center) ∈ stageRepresentatives source target U N P F A node) + (q : TargetInterval target.length) + (hb : (b : ℝ) ≤ stateEditCost (physicalSource source node) target q) + (comparison : Fin M → TargetInterval target.length) (hc : comparison ∈ specified.actions) + (hG : G = H + (bandCoordinates specified.actions.toFinset).card + 2) (hK : K = G ^ 80) + (htau : 0 < (rationalParameters F).tau) + (hηrange : (η : ℝ) * (2 * (delta : ℝ) + 8 * ((128 * F : ℚ) : ℝ) * + (((2 : ℚ) ^ (-(thetaExponent : ℤ))) : ℝ)) ≤ (κ : ℝ)) + (herror : 2 * (rationalParameters F).gamma + + 512 * (128 * F : ℚ) * F * (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ κ * delta) + (realizations : BandParentSpace R M b F Q K → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (hgroupsFixed : ∀ ω label, node.1.val < label.1.val → + (realizations ω).groups label = reference.groups label) + (honlineFixed : ∀ ω label, node.1.val < label.1.val → + (realizations ω).online label = reference.online label) + (honlineWire : ∀ ω t, sharedBandRationalAction specified.center + (physicalBandOnlineDraw source target U N P F A T delta reference node hbelow + b thetaExponent (rationalParameters F).tau specified.center specified.nonempty η κ G K t + (parentOnlineDraw ω t)) ∈ + physicalNodeOnline source target U N P F A T delta (realizations ω) node hbelow t q) + (hgroupWire : ∀ ω t, + (physicalNodeSelectedGroup source target U N P F A T delta reference node hbelow + b thetaExponent Q (rationalParameters F).tau cell hnonempty t (parentGroupDraw ω t)).rationalAction ∈ + physicalNodeGroups source target U N P F A T delta (realizations ω) node hbelow t) + (bernstein : ∀ scale : Fin (groupDyadicScales M b F).length, FiniteBernsteinInput + (Measure.pi fun _ : Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) (S : ℕ) : + let c : ℝ := stateEditCost (physicalSource source node) target q + let charge : ℝ := ((128 * F : ℚ) : ℝ) * targetEndpointDistance q specified.center + let clipped := physicalComparisonClipped source target U N P F A T delta reference node hbelow comparison + (∫ ω, (∑ t ∈ range S, + (max c (physicalRefinement source target U N P F A T delta (realizations ω) node (t + 1) q : ℝ) - + charge - clipped (t + 1))) ∂bandParentLaw R M b F Q K) ≤ + ((∑ child, specified.envelope child : ℚ) : ℝ) * + (Real.log (bandCoordinates specified.actions.toFinset).card / (η : ℝ) + 2 * (κ : ℝ) + + (S : ℝ) / (H : ℝ) ^ 3) + + 2 * (delta : ℝ) * c + 2 * S * (1 / (H : ℝ) ^ 4) * F * c := by + let c : ℝ := stateEditCost (physicalSource source node) target q + let charge : ℝ := ((128 * F : ℚ) : ℝ) * targetEndpointDistance q specified.center + let history := physicalBandHistory source target U N P F A T delta reference node hbelow + let clipped := physicalComparisonClipped source target U N P F A T delta reference node hbelow comparison + let sample := fun t integer => physicalBandOnlineDraw source target U N P F A T delta reference node hbelow + b thetaExponent (rationalParameters F).tau specified.center specified.nonempty η κ G K t integer + let failure := fun t draw => physicalNodeGroupFailure source target U N P F A T delta reference node hbelow + b thetaExponent Q (rationalParameters F).tau cell t draw (rationalParameters F).gamma + let crossing := firstCrossing specified.actions.toFinset S + (fun t => bandActionCost charge (fun t coordinate => (history t coordinate : ℝ)) (t + 1)) c + let prefixPayoff := fun t integer => sampledPrefixRegret charge (κ : ℝ) + (fun t coordinate => (history t coordinate : ℝ)) clipped (fun j => sample j integer) t + let regret := fun ω t => max c + (physicalRefinement source target U N P F A T delta (realizations ω) node (t + 1) q : ℝ) - charge - clipped (t + 1) + let budget := ((∑ child, specified.envelope child : ℚ) : ℝ) * + (Real.log (bandCoordinates specified.actions.toFinset).card / (η : ℝ) + 2 * (κ : ℝ) + (S : ℝ) / (H : ℝ) ^ 3) + have hpoint (ω : BandParentSpace R M b F Q K) : (∑ t ∈ range S, regret ω t) ≤ + (∑ t ∈ range crossing, prefixPayoff t (parentOnlineDraw ω t)) + 2 * (delta : ℝ) * c + + (2 * (F : ℝ) * c) * ∑ t ∈ range S, (if failure t (parentGroupDraw ω t) then (1 : ℝ) else 0) := by + have hdet := physicalNode_resampled_regret source target U N P F A T delta + reference (realizations ω) node hbelow hM hsize hP hF hA hseed hT + (hgroupsFixed ω) (honlineFixed ω) hleaf b thetaExponent Q (rationalParameters F).tau + (rationalParameters F).gamma κ htau hdelta hκ hκhalf cell hnonempty specified hspecified hrep q hb comparison hc + (fun t => sample t (parentOnlineDraw ω t)) + (fun t => physicalBandOnlineDraw_mem source target U N P F A T delta reference node hbelow + b thetaExponent (rationalParameters F).tau specified.center specified.nonempty η κ G K t (parentOnlineDraw ω t)) + (fun t => parentGroupDraw ω t) (honlineWire ω) (hgroupWire ω) herror S + have hprefixEq : (∑ t ∈ range crossing, sampledPrefixRegret charge (κ : ℝ) + (fun t coordinate => (history t coordinate : ℝ)) clipped + (fun j => sample j (parentOnlineDraw ω j)) t) = + ∑ t ∈ range crossing, prefixPayoff t (parentOnlineDraw ω t) := by + apply sum_congr rfl + intro t _ + exact sampledPrefixRegret_current_sample_congr charge (κ : ℝ) + (fun t coordinate => (history t coordinate : ℝ)) clipped + (fun j => sample j (parentOnlineDraw ω j)) + (fun j => sample j (parentOnlineDraw ω t)) t rfl + change (∑ t ∈ range S, regret ω t) ≤ + (∑ t ∈ range crossing, sampledPrefixRegret charge (κ : ℝ) + (fun t coordinate => (history t coordinate : ℝ)) clipped + (fun j => sample j (parentOnlineDraw ω j)) t) + 2 * (delta : ℝ) * c + + (2 * (F : ℝ) * c) * ∑ t ∈ range S, + (if failure t (parentGroupDraw ω t) then (1 : ℝ) else 0) at hdet + rw [hprefixEq] at hdet + exact hdet + have hprefix : (∑ t ∈ range crossing, uniformMean (prefixPayoff t)) ≤ budget := by + exact physicalBand_prefix_expected_regret source target U N P F A T delta reference node hbelow + b thetaExponent (rationalParameters F).tau specified.center hM hsize hP hF hA hseed hT htau hdelta.le + specified.nonempty crossing S H G K (firstCrossing_le _ _ _ _) η κ hG hK comparison hc hH hη hκ hκhalf hηrange charge + have hfailure t (_ht : t < S) : + (groupSharedDrawLaw (M := M) (fun scale : Fin (groupDyadicScales M b F).length => + groupSampleCount M Q b (groupDyadicScaleAt M b F scale))).real {draw | failure t draw = true} ≤ + 1 / (H : ℝ) ^ 4 := by + rw [hHeq] + exact physicalNode_groupFailure_probability source target N hN hell hM hMeq hPeq hFeq eb hbeq hQeq hthetaeq + U A hsize hP hA hseed T hT delta reference node hbelow t cell bernstein + have hbound := parentDrawLaw_firstCrossing_bound R (optimizerTriangularMass K) M + (groupDyadicScales M b F).length + (fun scale => groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) S crossing regret prefixPayoff failure + budget (2 * (delta : ℝ) * c) (2 * (F : ℝ) * c) (1 / (H : ℝ) ^ 4) + (mul_nonneg (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) (Nat.cast_nonneg F)) + (Nat.cast_nonneg _)) hpoint hprefix hfailure + dsimp only + change (∫ ω, (∑ t ∈ range S, regret ω t) ∂bandParentLaw R M b F Q K) ≤ + budget + 2 * (delta : ℝ) * c + 2 * S * (1 / (H : ℝ) ^ 4) * F * c + have hchargeEq : (2 * (F : ℝ) * c) * (S : ℝ) * (1 / (H : ℝ) ^ 4) = + 2 * S * (1 / (H : ℝ) ^ 4) * F * c := by ring + exact hbound.trans_eq (by rw [hchargeEq]) + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalDenominator.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalDenominator.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc5bf760ca7109a90b80c474062860d920bfc7d6 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalDenominator.lean @@ -0,0 +1,256 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalBoundsAllSeeds +import Mathlib.Data.Rat.Lemmas + +namespace OAI + +/-! The actual returned values have one additional fixed denominator per tree level. -/ + +namespace EditApproximation + +open Finset + +theorem rat_den_add_dvd {D : ℕ} {x y : ℚ} (hx : x.den ∣ D) (hy : y.den ∣ D) : + (x + y).den ∣ D := (Rat.add_den_dvd_lcm x y).trans (Nat.lcm_dvd hx hy) + +theorem rat_den_min_dvd {D : ℕ} {x y : ℚ} (hx : x.den ∣ D) (hy : y.den ∣ D) : + (min x y).den ∣ D := by + by_cases h : x ≤ y + · simpa only [min_eq_left h] using hx + · simpa only [min_eq_right (le_of_not_ge h)] using hy + +theorem rat_den_max_dvd {D : ℕ} {x y : ℚ} (hx : x.den ∣ D) (hy : y.den ∣ D) : + (max x y).den ∣ D := by + by_cases h : x ≤ y + · simpa only [max_eq_right h] using hy + · simpa only [max_eq_left (le_of_not_ge h)] using hx + +theorem rat_den_sum_dvd {ι : Type*} (s : Finset ι) (f : ι → ℚ) (D : ℕ) + (hf : ∀ i ∈ s, (f i).den ∣ D) : (∑ i ∈ s, f i).den ∣ D := by + classical + induction s using Finset.induction_on with + | empty => simp only [sum_empty, Rat.den_zero, one_dvd] + | @insert i s hi ih => + rw [sum_insert hi] + exact rat_den_add_dvd (hf i (mem_insert_self _ _)) + (ih fun j hj => hf j (mem_insert_of_mem hj)) + +theorem rationalMinimum_den_dvd (fallback : ℚ) (values : List ℚ) (D : ℕ) + (hfallback : fallback.den ∣ D) (hvalues : ∀ v ∈ values, v.den ∣ D) : + (rationalMinimum fallback values).den ∣ D := by + induction values with + | nil => exact hfallback + | cons v rest ih => + exact rat_den_min_dvd (hvalues v (by simp)) (ih fun w hw => hvalues w (by simp [hw])) + +theorem rationalActualWideActions_connection_den {nx ny M : ℕ} (parent : TargetInterval nx) + (representatives : List (ℕ × TargetInterval ny)) (P : ℕ) + (action : PhysicalRationalAction M ny) + (ha : action ∈ rationalActualWideActions parent representatives P) : action.connection.den = 1 := by + obtain ⟨br, _, hmem⟩ := List.mem_flatMap.mp ha + obtain ⟨states, _, rfl⟩ := List.mem_map.mp hmem + exact Rat.den_natCast _ + +theorem rationalActionValue_den_dvd {Parent Child : Type*} {M D : ℕ} + (distance : Parent → Parent → ℚ) (L : ℚ) (child : Child → ℚ) + (q : Parent) (action : RationalBellmanAction Parent Child M) + (hdistance : (distance q action.center).den = 1) (hL : L.den = 1) + (ha : action.connection.den = 1) (hchild : ∀ i, (child (action.childState i)).den ∣ D) : + (rationalActionValue distance L child q action).den ∣ D := by + unfold rationalActionValue + apply rat_den_add_dvd + · apply rat_den_add_dvd + · have h := Rat.mul_den_dvd L (distance q action.center) + rw [hL, hdistance, one_mul] at h + exact h.trans (one_dvd D) + · rw [ha] + exact one_dvd D + · exact rat_den_sum_dvd univ _ D (fun i _ => hchild i) + +theorem stageInitial_den_one {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (state : PhysicalEntry M J target.length) : + (stageInitial source target U N P F A state).den = 1 := by + have hmin (fallback : ℚ) (values : List ℚ) (hf : fallback.den = 1) + (hv : ∀ v ∈ values, v.den = 1) : (rationalMinimum fallback values).den = 1 := + Nat.eq_one_of_dvd_one (rationalMinimum_den_dvd fallback values 1 (by rw [hf]) + (fun v h => by rw [hv v h])) + unfold stageInitial physicalInitialTable + dsimp only + split_ifs + · exact Rat.den_natCast _ + · unfold localInitialConeTable + split_ifs + · exact Rat.den_zero + · apply hmin + · simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using + Rat.den_natCast ((32 * F + 1) * N) + · intro v hv + obtain ⟨r, _, rfl⟩ := List.mem_map.mp hv + unfold initialConeValue scaledSeedValue + apply Nat.eq_one_of_dvd_one + apply rat_den_add_dvd + · apply rat_den_max_dvd + · simp only [Rat.den_natCast, dvd_refl] + · have heq : rationalStateGap (physicalSource source state.1) target r = + (((r.hi : ℤ) - r.lo - (physicalSource source state.1).length : ℤ) : ℚ) := by + simp only [rationalStateGap, Int.cast_sub, Int.cast_natCast] + rw [heq, ← Int.cast_abs] + simp only [Rat.den_intCast, dvd_refl] + · have heq : (32 * F : ℚ) * targetEndpointDistance state.2 r = + ((32 * F * targetEndpointDistance state.2 r : ℕ) : ℚ) := by push_cast; rfl + rw [heq, Rat.den_natCast] + +theorem rationalPhysicalBellman_den_dvd {α : Type*} {M J D : ℕ} + (source target : List α) (P F : ℕ) + (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (hinitial : ∀ state, (initial state).den ∣ D) + (value : PhysicalEntry M J target.length → ℚ) + (hvalue : ∀ state, (value state).den ∣ D) (state : PhysicalEntry M J target.length) : + (rationalPhysicalBellman source target P (128 * F) initial representatives value state).den ∣ D := by + unfold rationalPhysicalBellman + dsimp only + split_ifs + · exact hinitial state + · apply rationalMinimum_den_dvd _ _ D (hinitial state) + intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + exact rationalActionValue_den_dvd _ _ _ _ _ (Rat.den_natCast _) + (by simpa only [Nat.cast_mul, Nat.cast_ofNat] using Rat.den_natCast (128 * F)) + (rationalActualWideActions_connection_den _ _ _ action ha) (fun i => hvalue _) + · exact hinitial state + +theorem stageWarmup_den_one {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (t : ℕ) (state : PhysicalEntry M J target.length) : + (stageWarmup source target U N P F A t state).den = 1 := by + induction t generalizing state with + | zero => exact stageInitial_den_one source target U N P F A state + | succ t ih => + apply Nat.eq_one_of_dvd_one + exact rationalPhysicalBellman_den_dvd source target P F _ _ + (fun s => by rw [stageInitial_den_one source target U N P F A s]) _ (fun s => by + change (stageWarmup source target U N P F A t s).den ∣ 1 + rw [ih s]) state + +theorem rat_inverse_shift_den_dvd (m : ℕ) (hm : 0 < m) : + (1 / (1 + 1 / (m : ℚ))).den ∣ m + 1 := by + have hmp : (0 : ℚ) < m := by exact_mod_cast hm + have heq : (1 / (1 + 1 / (m : ℚ))) = (m : ℚ) / (m + 1 : ℕ) := by + push_cast + field_simp + rw [heq] + have h : (((m : ℚ) / (m + 1 : ℕ)).den : ℤ) ∣ (m + 1 : ℕ) := by + simpa only [Rat.divInt_eq_div, Int.cast_natCast] using Rat.den_dvd (m : ℤ) (m + 1 : ℕ) + exact Int.natCast_dvd_natCast.mp h + +theorem rationalRefinementUpdate_den_dvd (m D : ℕ) (hm : 0 < m) + (cone : ℚ) (online : Option ℚ) (hcone : cone.den ∣ D) + (honline : ∀ v, online = some v → v.den ∣ D) : + (rationalRefinementUpdate (1 / (m : ℚ)) cone online).den ∣ D * (m + 1) := by + have hstep : D ∣ D * (m + 1) := dvd_mul_right _ _ + cases online with + | none => exact hcone.trans hstep + | some v => + apply rat_den_min_dvd (hcone.trans hstep) + apply rat_den_max_dvd _ ((honline v rfl).trans hstep) + rw [div_eq_mul_one_div] + exact (Rat.mul_den_dvd cone _).trans (Nat.mul_dvd_mul hcone (rat_inverse_shift_den_dvd m hm)) + +theorem rationalOnlineMinimum_den_dvd (values : List ℚ) (D : ℕ) + (hvalues : ∀ v ∈ values, v.den ∣ D) (v : ℚ) + (heq : rationalOnlineMinimum values = some v) : v.den ∣ D := by + cases values with + | nil => cases heq + | cons first rest => + have hv : rationalMinimum first rest = v := Option.some.inj heq + rw [← hv] + exact rationalMinimum_den_dvd first rest D (hvalues first (by simp)) + (fun w hw => hvalues w (by simp [hw])) + +theorem rationalWideStep_den_dvd {nx ny M D : ℕ} (parent : TargetInterval nx) + (representatives : List (ℕ × TargetInterval ny)) (P F m : ℕ) (hm : 0 < m) + (initial : TargetInterval ny → ℚ) (hinitial : ∀ q, (initial q).den ∣ D) + (old current : Fin M × TargetInterval ny → ℚ) + (hold : ∀ is, (old is).den ∣ D) (hcurrent : ∀ is, (current is).den ∣ D) + (groups online : List (PhysicalRationalAction M ny)) + (hgroups : ∀ a ∈ groups, a ∈ rationalActualWideActions parent representatives P) + (honline : ∀ a ∈ online, a ∈ rationalActualWideActions parent representatives P) + (q : TargetInterval ny) : + (rationalWideStep parent representatives P initial (128 * F) (1 / (m : ℚ)) + old current groups online q).den ∣ D * (m + 1) := by + have hvalue (child : Fin M × TargetInterval ny → ℚ) (hchild : ∀ is, (child is).den ∣ D) + (action : PhysicalRationalAction M ny) (ha : action ∈ rationalActualWideActions parent representatives P) : + (rationalActionValue (fun q r => targetEndpointDistance q r) (128 * F) child q action).den ∣ D := + rationalActionValue_den_dvd _ _ _ _ _ (Rat.den_natCast _) + (by simpa only [Nat.cast_mul, Nat.cast_ofNat] using Rat.den_natCast (128 * F)) + (rationalActualWideActions_connection_den _ _ _ action ha) (fun i => hchild _) + unfold rationalWideStep + apply rationalRefinementUpdate_den_dvd m D hm + · unfold rationalWideStepCone rationalBellman + apply rationalMinimum_den_dvd + · apply rationalMinimum_den_dvd _ _ D (hinitial q) + intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + exact hvalue old hold action ha + · intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + exact hvalue current hcurrent action (hgroups action ha) + · intro v hv + apply rationalOnlineMinimum_den_dvd _ D _ v hv + intro w hw + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hw + exact hvalue current hcurrent action (honline action ha) + +theorem physicalRefinement_den_dvd {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T ell : ℕ) (hell : 0 < ell) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) (t : ℕ) + (q : TargetInterval target.length) : + (physicalRefinement source target U N P F A T (1 / (ell : ℚ) ^ 10) choices node t q).den ∣ + (ell ^ 10 + 1) ^ (J - node.1.val) := by + have hdelta : (1 / (ell : ℚ) ^ 10) = 1 / ((ell ^ 10 : ℕ) : ℚ) := by rw [Nat.cast_pow] + by_cases hbelow : node.1.val < J + · by_cases hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · rw [physicalRefinement_at_terminal source target U N P F A T _ choices node (Or.inr hleaf), + stageInitial_den_one source target U N P F A] + exact one_dvd _ + · cases t with + | zero => + rw [physicalRefinement_zero source target U N P F A T _ choices node q, + stageWarmup_den_one source target U N P F A] + exact one_dvd _ + | succ t => + rw [physicalRefinement_succ source target U N P F A T _ choices node hbelow hleaf] + dsimp only + have hheight : J - node.1.val = (J - (node.1.val + 1)) + 1 := by omega + rw [hheight] + conv_rhs => rw [pow_succ] + rw [hdelta] + apply rationalWideStep_den_dvd _ _ P F (ell ^ 10) (pow_pos hell 10) + · intro r + rw [stageInitial_den_one source target U N P F A] + exact one_dvd _ + · intro is + simpa only [Nat.cast_pow, physicalChild] using physicalRefinement_den_dvd source target U N P F A T ell hell choices + (physicalChild node hbelow is.1) t is.2 + · intro is + simpa only [Nat.cast_pow, physicalChild] using physicalRefinement_den_dvd source target U N P F A T ell hell choices + (physicalChild node hbelow is.1) (t + 1) is.2 + · exact choices.groups_mem node _ (t + 1) + · exact choices.online_mem node _ (t + 1) q + · rw [physicalRefinement_at_terminal source target U N P F A T _ choices node (Or.inl hbelow), + stageInitial_den_one source target U N P F A] + exact one_dvd _ +termination_by J - node.1.val +decreasing_by + all_goals + unfold physicalChild + dsimp only + omega + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalDependencyRank.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalDependencyRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..385575ea69471d16d640552f8ccae46a16c34f65 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalDependencyRank.lean @@ -0,0 +1,240 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalWarmup +import OAI.Combinatorics.EditApproximation.Geometry.DependencyExpansion +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Concrete table requests and their dependency order. A single table +index identifies the end of warmup with refinement time zero. Copy labels +remain part of a request but do not reset its dependency rank. -/ + +namespace EditApproximation + + + + + +namespace PhysicalTableRequest + +variable {M J ny : ℕ} + + + + + + + + + + + +theorem refinement_zero_eq_warmup (pass copy : ℕ) (node : PhysicalNode M J) + (T : ℕ) (state : TargetInterval ny) : + refinement pass copy node T 0 state = warmup pass copy node T state := by + simp only [refinement, warmup, Nat.add_zero] + +def changeCopy (request : PhysicalTableRequest M J ny) (copy : ℕ) : + PhysicalTableRequest M J ny := { request with copy := copy } + +@[simp] theorem rank_changeCopy (T S : ℕ) (request : PhysicalTableRequest M J ny) (copy : ℕ) : + rank T S (changeCopy request copy) = rank T S request := rfl + +@[simp] theorem remainingDepth_changeCopy (request : PhysicalTableRequest M J ny) (copy : ℕ) : + remainingDepth (changeCopy request copy) = remainingDepth request := rfl + +@[simp] theorem warmup_rank (pass copy : ℕ) (node : PhysicalNode M J) + (T S j : ℕ) (state : TargetInterval ny) : + rank T S (warmup pass copy node j state) = pass * (T + S + 1) + j := rfl + +@[simp] theorem refinement_rank (pass copy : ℕ) (node : PhysicalNode M J) + (T S t : ℕ) (state : TargetInterval ny) : + rank T S (refinement pass copy node T t state) = pass * (T + S + 1) + (T + t) := rfl + +theorem remainingDepth_le_of_no_ancestor (first second : PhysicalTableRequest M J ny) + (hnode : first.node.1.val ≤ second.node.1.val) : + second.remainingDepth ≤ first.remainingDepth := + Nat.sub_le_sub_left hnode J + +theorem remainingDepth_lt_of_descendant (first second : PhysicalTableRequest M J ny) + (hnode : first.node.1.val < second.node.1.val) : + second.remainingDepth < first.remainingDepth := by + have hsecond : second.node.1.val ≤ J := Nat.le_of_lt_succ second.node.1.isLt + unfold remainingDepth + omega + + + +theorem sameIndexChild_progress (T S : ℕ) (request : PhysicalTableRequest M J ny) + (hbelow : request.node.1.val < J) (i : Fin M) (state : TargetInterval ny) : + (sameIndexChild request hbelow i state).remainingDepth < request.remainingDepth ∧ + rank T S (sameIndexChild request hbelow i state) ≤ rank T S request := by + constructor + · unfold remainingDepth sameIndexChild physicalChild + dsimp only + omega + · exact le_rfl + +theorem rank_lt_same_pass (T S : ℕ) (first second : PhysicalTableRequest M J ny) + (hpass : second.pass = first.pass) (hindex : second.index < first.index) : + rank T S second < rank T S first := by + unfold rank + rw [hpass] + exact Nat.add_lt_add_left hindex _ + +/-- A warmup predecessor lies at the physical child and at the preceding +unified table index. -/ +theorem warmup_previous_child_progress (pass copy T S j : ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (i : Fin M) + (state previousState : TargetInterval ny) (hj : 0 < j) : + (warmup pass copy (physicalChild node hbelow i) (j - 1) previousState).remainingDepth < + (warmup pass copy node j state).remainingDepth ∧ + rank T S (warmup pass copy (physicalChild node hbelow i) (j - 1) previousState) < + rank T S (warmup pass copy node j state) := by + constructor + · unfold remainingDepth warmup physicalChild + dsimp only + omega + · dsimp only [rank, warmup] + omega + +/-- Old refinement values and all optimistic-history values have +strictly smaller rank, even if their copy label changes. -/ +theorem refinement_history_progress (pass copy previousCopy T S t s : ℕ) + (node previousNode : PhysicalNode M J) (state previousState : TargetInterval ny) + (hnode : node.1.val ≤ previousNode.1.val) (hs : s < t) : + (refinement pass previousCopy previousNode T s previousState).remainingDepth ≤ + (refinement pass copy node T t state).remainingDepth ∧ + rank T S (refinement pass previousCopy previousNode T s previousState) < + rank T S (refinement pass copy node T t state) := by + constructor + · exact Nat.sub_le_sub_left hnode J + · simp only [refinement_rank] + omega + +theorem refinement_history_child_progress (pass copy T S t s : ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (i : Fin M) + (state previousState : TargetInterval ny) (hs : s < t) : + (refinement pass copy (physicalChild node hbelow i) T s previousState).remainingDepth < + (refinement pass copy node T t state).remainingDepth ∧ + rank T S (refinement pass copy (physicalChild node hbelow i) T s previousState) < + rank T S (refinement pass copy node T t state) := by + constructor + · unfold remainingDepth refinement physicalChild + dsimp only + omega + · dsimp only [rank, refinement] + omega + +/-- A previous pass can request any of its warmup/refinement indices. +The added one in the pass stride makes its last index strictly earlier +than the next pass's first index. -/ +theorem rank_lt_previous_pass (T S : ℕ) (first second : PhysicalTableRequest M J ny) + (hpass : second.pass < first.pass) (hindex : second.index ≤ T + S) : + rank T S second < rank T S first := by + have hblock : second.pass * (T + S + 1) + second.index < + (second.pass + 1) * (T + S + 1) := by + nlinarith only [hindex] + have hnext := Nat.mul_le_mul_right (T + S + 1) (Nat.succ_le_of_lt hpass) + exact hblock.trans_le (hnext.trans (Nat.le_add_right _ _)) + +theorem previous_pass_progress (T S : ℕ) (first second : PhysicalTableRequest M J ny) + (hpass : second.pass < first.pass) (hindex : second.index ≤ T + S) + (hnode : first.node.1.val ≤ second.node.1.val) : + second.remainingDepth ≤ first.remainingDepth ∧ rank T S second < rank T S first := + ⟨remainingDepth_le_of_no_ancestor first second hnode, + rank_lt_previous_pass T S first second hpass hindex⟩ + +theorem rank_lt_pass_bound (T S passes : ℕ) (request : PhysicalTableRequest M J ny) + (hpass : request.pass < passes) (hindex : request.index ≤ T + S) : + rank T S request < passes * (T + S + 1) := by + have hblock : request.pass * (T + S + 1) + request.index < + (request.pass + 1) * (T + S + 1) := by + nlinarith only [hindex] + exact hblock.trans_le (Nat.mul_le_mul_right (T + S + 1) (Nat.succ_le_of_lt hpass)) + +theorem warmup_index_bound (pass copy : ℕ) (node : PhysicalNode M J) + (T S j : ℕ) (state : TargetInterval ny) (hj : j ≤ T) : + (warmup pass copy node j state).index ≤ T + S := by + change j ≤ T + S + omega + +theorem refinement_index_bound (pass copy : ℕ) (node : PhysicalNode M J) + (T S t : ℕ) (state : TargetInterval ny) (ht : t ≤ S) : + (refinement pass copy node T t state).index ≤ T + S := by + change T + t ≤ T + S + omega + +theorem warmup_bounded (passes copies pass copy : ℕ) (node : PhysicalNode M J) + (T S j : ℕ) (state : TargetInterval ny) + (hpass : pass < passes) (hcopy : copy < copies) (hj : j ≤ T) : + Bounded passes copies T S (warmup pass copy node j state) := + ⟨hpass, hcopy, warmup_index_bound pass copy node T S j state hj⟩ + +theorem refinement_bounded (passes copies pass copy : ℕ) (node : PhysicalNode M J) + (T S t : ℕ) (state : TargetInterval ny) + (hpass : pass < passes) (hcopy : copy < copies) (ht : t ≤ S) : + Bounded passes copies T S (refinement pass copy node T t state) := + ⟨hpass, hcopy, refinement_index_bound pass copy node T S t state ht⟩ + +theorem bounded_changeCopy (passes copies T S : ℕ) (request : PhysicalTableRequest M J ny) + (hrequest : Bounded passes copies T S request) (copy : ℕ) (hcopy : copy < copies) : + Bounded passes copies T S (changeCopy request copy) := + ⟨hrequest.1, hcopy, hrequest.2.2⟩ + +theorem bounded_sameIndexChild (passes copies T S : ℕ) (request : PhysicalTableRequest M J ny) + (hrequest : Bounded passes copies T S request) + (hbelow : request.node.1.val < J) (i : Fin M) (state : TargetInterval ny) : + Bounded passes copies T S (sameIndexChild request hbelow i state) := hrequest + +theorem bounded_of_earlier_same_pass (passes copies T S : ℕ) + (first second : PhysicalTableRequest M J ny) (hfirst : Bounded passes copies T S first) + (hpass : second.pass = first.pass) (hcopy : second.copy < copies) + (hindex : second.index ≤ first.index) : Bounded passes copies T S second := by + exact ⟨hpass.symm ▸ hfirst.1, hcopy, hindex.trans hfirst.2.2⟩ + +theorem bounded_of_previous_pass (passes copies T S : ℕ) + (first second : PhysicalTableRequest M J ny) (hfirst : Bounded passes copies T S first) + (hpass : second.pass < first.pass) (hcopy : second.copy < copies) + (hindex : second.index ≤ T + S) : Bounded passes copies T S second := + ⟨hpass.trans hfirst.1, hcopy, hindex⟩ + +/-- Bounded requests have an explicit finite coordinate representation; +the copy coordinate is retained even though the progress rank ignores it. -/ +def boundedTuple (passes copies T S : ℕ) + (request : {r : PhysicalTableRequest M J ny // Bounded passes copies T S r}) : + Fin passes × Fin copies × PhysicalNode M J × Fin (T + S + 1) × TargetInterval ny := + (⟨request.1.pass, request.2.1⟩, ⟨request.1.copy, request.2.2.1⟩, request.1.node, + ⟨request.1.index, Nat.lt_succ_of_le request.2.2.2⟩, request.1.state) + +theorem boundedTuple_injective (passes copies T S : ℕ) : + Function.Injective (@boundedTuple M J ny passes copies T S) := by + intro first second heq + apply Subtype.ext + have hpass := congrArg (fun t => t.1.val) heq + have hcopy := congrArg (fun t => t.2.1.val) heq + have hnode := congrArg (fun t => t.2.2.1) heq + have hindex := congrArg (fun t => t.2.2.2.1.val) heq + have hstate := congrArg (fun t => t.2.2.2.2) heq + cases first with + | mk first hf => + cases second with + | mk second hs => + cases first + cases second + simp only [boundedTuple] at hpass hcopy hnode hindex hstate + cases hpass + cases hcopy + cases hnode + cases hindex + cases hstate + rfl + +instance boundedRequestFinite (passes copies T S : ℕ) : + Finite {r : PhysicalTableRequest M J ny // Bounded passes copies T S r} := + Finite.of_injective (boundedTuple passes copies T S) (boundedTuple_injective passes copies T S) + +end PhysicalTableRequest +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalExpectedRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalExpectedRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9a7eff95206f93c2b98ac6b40a939d8028c625f --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalExpectedRegret.lean @@ -0,0 +1,159 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalNodeRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalGroupAccuracy + +namespace OAI + +/-! Conditional prefix regret from the exact physical-band sampler. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +theorem uniformMean_sub {Ω : Type*} [Fintype Ω] (f g : Ω → ℝ) : + uniformMean (fun ω => f ω - g ω) = uniformMean f - uniformMean g := by + simp only [uniformMean, sum_sub_distrib, sub_div] + +theorem sampledPrefixRegret_child_identity {β σ : Type*} [Fintype β] + (charge κ : ℝ) (table : ℕ → β × σ → ℝ) + (clipped : ℕ → ℝ) (sample : ℕ → β → σ) (t : ℕ) : + sampledPrefixRegret charge κ table clipped sample t = + (∑ child, table (t + 1) (child, sample t child)) + + κ * ((∑ child, table t (child, sample t child)) - + ∑ child, table (t + 1) (child, sample t child)) - clipped (t + 1) := by + unfold sampledPrefixRegret bandActionCost + ring + +section PhysicalPrefix + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (b thetaExponent : ℕ) (tau : ℚ) (r : TargetInterval target.length) + +local notation "band" => physicalBandActions source target U N P F A T node hbelow b thetaExponent tau r +local notation "mass" => physicalBandEnvelope source target U N P F A T node hbelow b thetaExponent tau r +local notation "history" => physicalBandHistory source target U N P F A T delta choices node hbelow +local notation "theta" => (2 : ℚ) ^ (-(thetaExponent : ℤ)) + +variable (hM : 0 < M) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (hT : 0 < T) + +include hM hsize hP hF hA hseed hT in +/-- Every deterministic prefix uses the same actual computed online mixtures. +Clipping comparison children only decreases the prefix regret. -/ +theorem physicalBand_prefix_expected_regret (htau : 0 < tau) (hdelta : 0 ≤ delta) + (hband : band ≠ []) (C S H G K : ℕ) (hCS : C ≤ S) (η κ : ℚ) + (hG : G = H + (bandCoordinates (band).toFinset).card + 2) (hK : K = G ^ 80) + (comparison : Fin M → TargetInterval target.length) (hc : comparison ∈ band) + (hH : 4 ≤ H) (hη : 0 < η) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (hηrange : (η : ℝ) * + (2 * (delta : ℝ) + 8 * ((128 * F : ℚ) : ℝ) * (theta : ℝ)) ≤ (κ : ℝ)) (charge : ℝ) : + (∑ t ∈ range C, uniformMean (fun integer : Fin (optimizerTriangularMass K) => + sampledPrefixRegret charge (κ : ℝ) (fun t coordinate => (history t coordinate : ℝ)) + (physicalComparisonClipped source target U N P F A T delta choices node hbelow comparison) + (fun j => physicalBandOnlineDraw source target U N P F A T delta choices node hbelow + b thetaExponent tau r hband η κ G K j integer) t)) ≤ + ((∑ child, mass child : ℚ) : ℝ) * + (Real.log (bandCoordinates (band).toFinset).card / (η : ℝ) + 2 * (κ : ℝ) + + (S : ℝ) / (H : ℝ) ^ 3) := by + have hGpos : 0 < G := by omega + have hKpos : 0 < K := by rw [hK]; exact pow_pos hGpos 80 + let : NeZero (optimizerTriangularMass K) := ⟨Nat.ne_of_gt (optimizerTriangularMass_positive K hKpos)⟩ + have hcost := physicalBandOnlineDraw_cost_regret source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT htau hdelta hband C H G K η κ hG hK + hc hH hη hκ hκhalf hηrange + have hcomparison : (∑ t ∈ range C, ∑ child, (history (t + 1) (child, comparison child) : ℝ)) ≤ + ∑ t ∈ range C, + physicalComparisonClipped source target U N P F A T delta choices node hbelow comparison (t + 1) := by + apply sum_le_sum + intro t _ + exact sum_le_sum fun i _ => le_max_right _ _ + have hmass : (0 : ℝ) ≤ ((∑ child, mass child : ℚ) : ℝ) := + (Rat.cast_nonneg (K := ℝ)).mpr (sum_nonneg fun i _ => + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r i).le) + have hprefix : (C : ℝ) / (H : ℝ) ^ 3 ≤ (S : ℝ) / (H : ℝ) ^ 3 := + div_le_div_of_nonneg_right (by exact_mod_cast hCS) (pow_nonneg (Nat.cast_nonneg H) 3) + have hbudget := mul_le_mul_of_nonneg_left hprefix hmass + simp_rw [sampledPrefixRegret_child_identity, uniformMean_sub, uniformMean_const] + rw [sum_sub_distrib] + nlinarith only [hcost, hcomparison, hbudget] + +end PhysicalPrefix + + +theorem unskippedGroupFailure_true {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (b P thetaExponent : ℕ) (tau F : ℚ) + (child initial value : Fin M → TargetInterval target.length → ℚ) (Q : ℕ) + (members : List (UnskippedBand source target parent b P thetaExponent tau F child initial)) + (draw : ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) (gamma : ℚ) : + unskippedGroupFailure source target parent b P thetaExponent tau F child initial value Q members draw gamma = true ↔ + ∃ member ∈ members, gamma * b < |dyadicUnskippedGroupEstimate Q value member draw - + rationalEndpointActionValue member.center member.rounded value| := by + simp only [unskippedGroupFailure, List.any_eq_true, decide_eq_true_eq] + +/-- Per-scale finite Bernstein bounds imply the whole-cell failure probability. -/ +theorem physicalNode_groupFailure_probability {α : Type*} [DecidableEq α] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 1764 ≤ inputSmallLog N) + {M J P F b Q thetaExponent : ℕ} [NeZero M] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (hM : 0 < M) (hMeq : M = (integerParameters N).M) + (hPeq : P = (integerParameters N).P) (hFeq : F = inputSmallLog N) + (eb : ℕ) (hbeq : b = 2 ^ eb) (hQeq : Q = inputSmallLog N ^ 80) + (hthetaeq : thetaExponent = 40 * smallLogExponent N) + (U : PhysicalEntry M J target.length → ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (t : ℕ) (cell : ℕ × ℕ) + (bernstein : ∀ scale : Fin (groupDyadicScales M b F).length, FiniteBernsteinInput + (Measure.pi fun _ : Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) : + (groupSharedDrawLaw (fun scale : Fin (groupDyadicScales M b F).length => + groupSampleCount M Q b (groupDyadicScaleAt M b F scale))).real + {draw | physicalNodeGroupFailure source target U N P F A T delta choices node hbelow + b thetaExponent Q (rationalParameters F).tau cell t draw (rationalParameters F).gamma = true} ≤ + 1 / (inputHeight N : ℝ) ^ 4 := by + subst F + let F := inputSmallLog N + let scales := groupDyadicScaleAt M b (F : ℚ) + let count := fun scale : Fin (groupDyadicScales M b F).length => groupSampleCount M Q b (scales scale) + have hscales : List.ofFn scales = groupDyadicScales M b F := List.ofFn_get _ + have hprob := physical_cellGroupEstimate_failure source target N hN hell hM hMeq hPeq eb hbeq hQeq hthetaeq + U A hsize hP hA hseed T hT delta choices node hbelow (t + 1) cell scales count hscales (fun _ => rfl) bernstein + dsimp only at hprob + let members := physicalNodeCellBands source target U N P F A T node hbelow + b thetaExponent (rationalParameters F).tau cell + let value := fun i s => physicalBandHistory source target U N P F A T delta choices node hbelow (t + 1) (i, s) + have hevent : {draw | physicalNodeGroupFailure source target U N P F A T delta choices node hbelow + b thetaExponent Q (rationalParameters F).tau cell t draw (rationalParameters F).gamma = true} = + {draw | ∃ member ∈ members, ((rationalParameters F).gamma : ℝ) * b < + |((dyadicUnskippedGroupEstimate Q value member draw - + rationalEndpointActionValue member.center member.rounded value : ℚ) : ℝ)|} := by + ext draw + simp only [Set.mem_ofPred_eq, physicalNodeGroupFailure, unskippedGroupFailure_true] + change (∃ member ∈ members, (rationalParameters F).gamma * b < + |dyadicUnskippedGroupEstimate Q value member draw - + rationalEndpointActionValue member.center member.rounded value|) ↔ _ + constructor + · rintro ⟨member, hm, he⟩ + refine ⟨member, hm, ?_⟩ + exact_mod_cast he + · rintro ⟨member, hm, he⟩ + refine ⟨member, hm, ?_⟩ + exact_mod_cast he + rw [hevent] + exact hprob + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyAccuracy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..72bd9420189cdf7a6d56a75adc374332fde40691 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyAccuracy.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyMemo +import OAI.Combinatorics.EditApproximation.Geometry.LocalFinalAccuracy + +namespace OAI + +/-! The finite family is consumed through actual source reads in the shared +memo evaluator. Its final value and law agree with the proved local answer. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section Accuracy + +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P T S H : ℕ) + +local notation "Seed" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "passes" => computedSeedPassCount N +local notation "tau" => RationalParameters.tau (rationalParameters ell) +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Family" => PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) (H ^ 2) T S + + + theorem physicalFamilyMemoAnswer_event (hP : 0 < P) (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) (hinjective : Function.Injective encode) + (hbounded : ∀ key, encode key < 2 ^ bits) (incoming : Measure Seed) + [IsProbabilityMeasure incoming] (rootQ : TargetInterval target.length) (event : Set ℕ) : + (incoming.prod (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2))).real + {input | physicalFamilyMemoAnswer source target N P T S H hH bits encode rootQ input ∈ event} = + (localFinalProgramLaw (R := R) source target N P T S H incoming).real + {input | localFinalProgramAnswer (R := R) source target N P T S H rootQ input ∈ event} := by + classical + have h := congrArg (fun law : Measure ℕ => law.real event) + (physicalFamilyMemoAnswer_law source target N P T S H hP hH bits encode hinjective hbounded incoming rootQ) + simpa only [map_measureReal_apply (measurable_of_finite _) (Set.to_countable _).measurableSet, + Set.preimage] using h + +variable (B : ℕ) [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] + (depth : PhysicalEntry M J target.length → ℕ) + +/-- Accuracy of the shared source/table memo evaluator under finite Bernstein bounds. -/ + theorem physicalFamilyMemoAnswer_conditional_accuracy (hP : 0 < P) (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) (hinjective : Function.Injective encode) + (hbounded : ∀ key, encode key < 2 ^ bits) + (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hsize : source.length + target.length ≤ N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (hPeq : P = (integerParameters N).P) (hTeq : T = (integerParameters N).T) + (hSeq : S = (integerParameters N).S) (hHeq : H = inputHeight N) + (hB : B = (integerParameters N).B) + (hdepth : ∀ state, depth state = computedCoarseDepth N + (coarseEntryWidth (physicalSource source state.1) (substring target state.2.lo state.2.hi))) + (coarseBernstein : FiniteBernsteinInput (Measure.pi fun _ : Fin B => + (PMF.uniformOfFintype (Fin B)).toMeasure)) + (groupBernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (epsilon : ℝ) (hepsilon : 0 < epsilon) (haccuracy : 10 ≤ (inputSmallLog N : ℝ) * epsilon) : + (2 / 3 : ℝ) ≤ ((physicalCoarseSeedLaw source target N B depth).prod + (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2))).real + {input | EditDistortion.edit source target ≤ physicalFamilyMemoAnswer source target N P T S H + hH bits encode (finalTargetState target.length) input ∧ + (physicalFamilyMemoAnswer source target N P T S H hH bits encode + (finalTargetState target.length) input : ℝ) ≤ + (1 + epsilon) * EditDistortion.edit source target} := by + have hevent := physicalFamilyMemoAnswer_event source target N P T S H hP hH bits encode hinjective hbounded + (physicalCoarseSeedLaw source target N B depth) (finalTargetState target.length) + {answer | EditDistortion.edit source target ≤ answer ∧ + (answer : ℝ) ≤ (1 + epsilon) * EditDistortion.edit source target} + simp only [Set.mem_ofPred_eq] at hevent + rw [hevent] + exact local_physical_conditional_accuracy source target N P T S H B depth hN hell hsize + hMeq hJeq hPeq hTeq hSeq hHeq hB hdepth coarseBernstein groupBernstein epsilon hepsilon haccuracy + +end Accuracy + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyCoarseWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyCoarseWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..c90ea2f86fa65edbeb2fdfb538f273cd8a8861e3 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyCoarseWork.lean @@ -0,0 +1,105 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyWork +import OAI.Combinatorics.EditApproximation.Geometry.ChargedRandomCoarseWork +import OAI.Combinatorics.EditApproximation.Coarse.CoarseFirstRequestCost +import OAI.Combinatorics.EditApproximation.Geometry.BalancedWidths +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseSeedLaw + +namespace OAI + +namespace EditApproximation + +section Coarse + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "group" => physicalFamilyGroup target N P ell exponent H (ell ^ 80) passes copies draw +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw + +noncomputable def physicalFamilyCoarseQuery + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : + FiniteQuery (PhysicalEntry M J target.length) := + chargedRandomCoarseQuery source target N P ell exponent H (ell ^ 80) T S (passes + 1) + copies factor multiplier tau eta kappa delta readGroup readInteger answer root + + theorem physicalFamilyCoarseQuery_cost_le_width + (initial : PhysicalEntry M J target.length → ℕ) (hP : 0 < P) + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) + (hroot : root.depth = J) : + (physicalFamilyCoarseQuery source target N P H T S passes copies factor multiplier + tau eta kappa delta draw root).cost (fun entry => (initial entry : ℚ)) + (fun entry => (physicalSource source entry.1).length) ≤ + (physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hP draw root).widthWork M source.length := by + apply (FiniteQuery.cost_mono_weights _ _ _ _ ?_).trans + (chargedRandomCoarseQuery_width_cost_le source target N P H T S (passes + 1) copies + factor multiplier tau eta kappa delta readGroup readInteger answer initial group + (physicalFamilyInteger source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta hP draw initial) + (physicalFamilyProgram_value source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta initial hP draw) root hroot) + intro entry + rw [physicalSource_length_eq] + exact (sourceIntervalAt_width M source.length entry.1.1.val (Nat.pos_of_neZero M) entry.1.2).trans + (Nat.le_add_left _ 1) + +variable (B : ℕ) [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] + (depth : PhysicalEntry M J target.length → ℕ) + +noncomputable def physicalFamilyCoarseWork + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) + (coarse : PhysicalCoarseDraw source target B depth) : ℝ := + coarseFirstRequestWork N B depth + (fun entry => physicalSource source entry.1) + (fun entry => substring target entry.2.lo entry.2.hi) + (physicalFamilyCoarseQuery source target N P H T S passes copies factor multiplier + tau eta kappa delta draw root) coarse + + theorem physicalFamilyCoarseWork_expected_le + (hP : 0 < P) (hN : 0 < N) (hell : 200 ≤ ell) + (hB : B = (integerParameters N).B) (hsize : source.length + target.length ≤ N) + (hdepth : ∀ entry, depth entry = computedCoarseDepth N + (coarseEntryWidth (physicalSource source entry.1) (substring target entry.2.lo entry.2.hi))) + (hinverse : coarseInverseAllowanceFactor B (initialThresholdQ N) (initialLambda N) ≤ + (inputHeight N : ℝ) ^ 8) + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) + (hroot : root.depth = J) (budget : ℝ) + (hwidth : ∀ coarse : PhysicalCoarseDraw source target B depth, + ((physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta (clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse)) + hP draw root).widthWork M source.length : ℝ) ≤ budget) : + (∫ coarse, physicalFamilyCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth root coarse + ∂coarseFullSeedMeasure B depth + (fun entry => physicalSource source entry.1) + (fun entry => substring target entry.2.lo entry.2.hi)) ≤ + budget * computedCoarseWidthOverhead N := by + have hentries (entry : PhysicalEntry M J target.length) : + coarseEntryWidth (physicalSource source entry.1) (substring target entry.2.lo entry.2.hi) ≤ N := by + apply max_le + · exact (physicalSource_length_le source entry.1).trans (by omega) + · have hl : (substring target entry.2.lo entry.2.hi).length ≤ target.length := by + simp only [substring, List.length_drop, List.length_take] + exact (Nat.sub_le _ _).trans (min_le_right _ _) + exact hl.trans (by omega) + apply coarseFirstRequestWork_expected_le N B depth _ _ _ hB hN hell hdepth hentries hinverse budget + intro coarse + have hc := physicalFamilyCoarseQuery_cost_le_width source target N P H T S passes copies + factor multiplier tau eta kappa delta draw + (clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse)) hP root hroot + exact ((Nat.cast_le (α := ℝ)).mpr hc).trans (hwidth coarse) + +end Coarse + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyEncoding.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4cf29b9d477dfcf4c81734179f450263095ec5a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyEncoding.lean @@ -0,0 +1,47 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarCodeBits +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarFamily +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +section Encoding + +variable {α : Type*} {M J R : ℕ} (target : List α) (N P F exponent H Q passes copies : ℕ) + +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies + + + + theorem physicalFamilyCode_injective (hM : 1 ≤ M) : + Function.Injective (physicalFamilyCode (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies) := by + intro first second h + obtain ⟨hp, h⟩ := Nat.pair_eq_pair.mp h + obtain ⟨hc, hs⟩ := Nat.pair_eq_pair.mp h + exact Prod.ext (Fin.ext hp) (Prod.ext (Fin.ext hc) (physicalScalarCode_injective hM hs)) + + theorem physicalFamilyCode_bound (k : ℕ) + (hpass : passes + 1 ≤ 2 ^ k) (hcopy : copies + 1 ≤ 2 ^ k) + (hscalar : ∀ key : PhysicalScalarKey M J N target.length exponent F Q R + (localOnlineMassBound M P H), physicalScalarCode key < 2 ^ (64 * k + 1)) + (key : Key) : physicalFamilyCode target N P F exponent H Q passes copies key < + 2 ^ (256 * k + 4) := by + have hk : k ≤ 64 * k + 1 := by omega + have hp := key.1.isLt.trans_le (hpass.trans (Nat.pow_le_pow_right (by decide) hk)) + have hc := key.2.1.isLt.trans_le (hcopy.trans (Nat.pow_le_pow_right (by decide) hk)) + have hi := natPair_lt_two_pow hc (hscalar key.2.2) + have ho := natPair_lt_two_pow_scaled hp hi (by decide : 1 ≤ 2) + change Nat.pair _ (Nat.pair _ _) < _ + convert ho using 1 + congr 1 + omega + +end Encoding + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyMemo.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyMemo.lean new file mode 100644 index 0000000000000000000000000000000000000000..74be8c5daaffb17d543a4adb60a93dee2b4e632a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyMemo.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyOutput +import OAI.Combinatorics.EditApproximation.Geometry.ChargedRandomMemo +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The finite family is consumed through actual source reads in the shared +memo evaluator. Its final value and law agree with the proved local answer. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section Memo + +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P T S H : ℕ) + +local notation "Seed" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "passes" => computedSeedPassCount N +local notation "tau" => RationalParameters.tau (rationalParameters ell) +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Family" => PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) (H ^ 2) T S + + + + theorem physicalFamilyMemoResult_value (hP : 0 < P) (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) (hinjective : Function.Injective encode) + (hbounded : ∀ key, encode key < 2 ^ bits) (rootQ : TargetInterval target.length) + (input : Seed × Family) : + ((physicalFamilyMemoResult source target N P T S H hH bits encode rootQ input).value : ℝ) = + physicalFamilyFinalValue source target N P T S H hP rootQ input := by + unfold physicalFamilyMemoResult + rw [chargedRandomMemoEvaluate_value source target N P ell exponent H (ell ^ 80) T S + (passes + 1) (H ^ 2) (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta + (physicalFamilyGroupRead target N P ell exponent H (ell ^ 80) passes (H ^ 2)) + (physicalFamilyOnlineRead target N P ell exponent H (ell ^ 80) passes (H ^ 2)) + (clampedSeedNat input.1) + (physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes (H ^ 2) input.2) + (physicalFamilyGroup target N P ell exponent H (ell ^ 80) passes (H ^ 2) input.2) + (physicalFamilyInteger source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP input.2 + (clampedSeedNat input.1))] + · rfl + · exact physicalFamilyGroupRead_value target N P ell exponent H (ell ^ 80) passes (H ^ 2) input.2 + · exact physicalFamilyOnlineRead_value source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP input.2 + (clampedSeedNat input.1) + · exact hinjective + · exact hbounded + +noncomputable def physicalFamilyMemoAnswer (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) (rootQ : TargetInterval target.length) (input : Seed × Family) : ℕ := + if source = substring target rootQ.lo rootQ.hi then 0 else + integerAnswer N ((physicalFamilyMemoResult source target N P T S H hH bits encode rootQ input).value : ℝ) + + theorem physicalFamilyMemoAnswer_eq (hP : 0 < P) (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) (hinjective : Function.Injective encode) + (hbounded : ∀ key, encode key < 2 ^ bits) (rootQ : TargetInterval target.length) + (input : Seed × Family) : + physicalFamilyMemoAnswer source target N P T S H hH bits encode rootQ input = + physicalFamilyFinalAnswer source target N P T S H hP rootQ input := by + unfold physicalFamilyMemoAnswer physicalFamilyFinalAnswer + rw [physicalFamilyMemoResult_value source target N P T S H hP hH bits encode hinjective hbounded] + + theorem physicalFamilyMemoAnswer_law (hP : 0 < P) (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) (hinjective : Function.Injective encode) + (hbounded : ∀ key, encode key < 2 ^ bits) (incoming : Measure Seed) + [IsProbabilityMeasure incoming] (rootQ : TargetInterval target.length) : + (incoming.prod (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2))).map + (physicalFamilyMemoAnswer source target N P T S H hH bits encode rootQ) = + (localFinalProgramLaw (R := R) source target N P T S H incoming).map + (localFinalProgramAnswer (R := R) source target N P T S H rootQ) := by + have heq : physicalFamilyMemoAnswer (R := R) source target N P T S H hH bits encode rootQ = + physicalFamilyFinalAnswer source target N P T S H hP rootQ := by + funext input + exact physicalFamilyMemoAnswer_eq source target N P T S H hP hH bits encode hinjective hbounded rootQ input + rw [heq] + exact physicalFamilyFinalAnswer_law source target N P T S H hP hH incoming rootQ + +end Memo + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyMemoCoarse.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyMemoCoarse.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9e4bccd6d047c6501156039a213e9754fd5f5a8 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyMemoCoarse.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyCoarseWork +import OAI.Combinatorics.EditApproximation.Geometry.ChargedRandomCoarseKeys +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +open MeasureTheory + +private theorem selectionIndicator_le {p q : Prop} (h : p → q) : + selectionIndicator p ≤ selectionIndicator q := by + classical + by_cases hp : p + · have hq := h hp + simp only [selectionIndicator, hp, hq, ite_true, le_refl] + · simp only [selectionIndicator, hp, ite_false] + split <;> norm_num + +section Coarse + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + (B : ℕ) [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] + (depth : PhysicalEntry M J target.length → ℕ) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) copies T S +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw + + + +omit [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] in + theorem physicalFamilyMemoCoarseWork_le (hP : 0 < P) (bits : ℕ) (encode : Sum Key Table → ℕ) + (hinjective : Function.Injective encode) (hbounded : ∀ key, encode key < 2 ^ bits) + (root : Table) (coarse : PhysicalCoarseDraw source target B depth) : + physicalFamilyMemoCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth bits encode root coarse ≤ + physicalFamilyCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth root coarse := by + classical + let initial := clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse) + have hkey (entry : PhysicalEntry M J target.length) := + chargedRandomMemo_coarse_key source target N P ell exponent H (ell ^ 80) T S + (passes + 1) copies factor multiplier tau eta kappa delta readGroup readInteger answer initial + (physicalFamilyRequestValue source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta initial hP draw) + (physicalFamilyProgram_value source target N P ell exponent H (ell ^ 80) T S passes copies + factor multiplier tau eta kappa delta initial hP draw) + bits encode hinjective hbounded root entry + unfold physicalFamilyMemoCoarseWork physicalFamilyCoarseWork coarseFirstRequestWork + apply Finset.sum_le_sum + intro entry _ + apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) + exact selectionIndicator_le (hkey entry) + + + theorem physicalFamilyMemoCoarseWork_expected_le (hP : 0 < P) (hN : 0 < N) + (hell : 200 ≤ ell) (hB : B = (integerParameters N).B) + (hsize : source.length + target.length ≤ N) + (hdepth : ∀ entry, depth entry = computedCoarseDepth N + (coarseEntryWidth (physicalSource source entry.1) (substring target entry.2.lo entry.2.hi))) + (hinverse : coarseInverseAllowanceFactor B (initialThresholdQ N) (initialLambda N) ≤ + (inputHeight N : ℝ) ^ 8) + (bits : ℕ) (encode : Sum Key Table → ℕ) (hinjective : Function.Injective encode) + (hbounded : ∀ key, encode key < 2 ^ bits) (root : Table) (hroot : root.depth = J) + (budget : ℝ) + (hwidth : ∀ coarse : PhysicalCoarseDraw source target B depth, + ((physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta (clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse)) + hP draw root).widthWork M source.length : ℝ) ≤ budget) : + (∫ coarse, physicalFamilyMemoCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth bits encode root coarse + ∂coarseFullSeedMeasure B depth + (fun entry => physicalSource source entry.1) + (fun entry => substring target entry.2.lo entry.2.hi)) ≤ + budget * computedCoarseWidthOverhead N := by + classical + apply (integral_mono Integrable.of_finite Integrable.of_finite (fun coarse => + physicalFamilyMemoCoarseWork_le source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth hP bits encode hinjective hbounded root coarse)).trans + exact physicalFamilyCoarseWork_expected_le source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth hP hN hell hB hsize hdepth hinverse root hroot budget hwidth + +end Coarse + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyOutput.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce18ed2154e08ba6aca3a33528f8d75b893f08a4 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyOutput.lean @@ -0,0 +1,128 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilySeedTrace +import OAI.Combinatorics.EditApproximation.Geometry.LocalCommonOutput + +namespace OAI + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section Output + +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P T S H : ℕ) (hP : 0 < P) + +local notation "SeedState" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "passes" => computedSeedPassCount N +local notation "tau" => RationalParameters.tau (rationalParameters ell) +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "Family" => PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) + +noncomputable def physicalFamilyFinalValue (rootQ : TargetInterval target.length) + (input : SeedState × Family) : ℝ := + localRequestValue source target N P ell exponent H (ell ^ 80) T S (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta + (physicalFamilyGroup target N P ell exponent H (ell ^ 80) passes (H ^ 2) input.2) + (physicalFamilyInteger source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP input.2 + (clampedSeedNat input.1)) + (clampedSeedNat input.1) + (PhysicalTableRequest.refinement passes 0 + (Sigma.mk (Fin.mk 0 (Nat.zero_lt_succ J)) PUnit.unit) T S rootQ) + +noncomputable def physicalFamilyFinalAnswer (rootQ : TargetInterval target.length) + (input : SeedState × Family) : ℕ := + if source = substring target rootQ.lo rootQ.hi then 0 else + integerAnswer N (physicalFamilyFinalValue source target N P T S H hP rootQ input) + + theorem physicalFamily_localPassValue (seed : SeedState) (draw : Family) (pass copy : ℕ) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + localPassValue source target N P ell exponent H (ell ^ 80) T + (scheduledSeedFactor N) tau eta kappa delta + (physicalFamilyGroup target N P ell exponent H (ell ^ 80) passes (H ^ 2) draw) + (physicalFamilyInteger source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP draw + (clampedSeedNat seed)) + (physicalFamilySeed source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP draw + (clampedSeedNat seed) pass) pass copy node t q = + physicalLocalJointValue source target + (physicalFamilySeed source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP draw + (clampedSeedNat seed) pass) + N P ell (scheduledSeedFactor N pass) T exponent H (ell ^ 80) tau eta kappa delta + (physicalFamilySample source target N P ell exponent H (ell ^ 80) T passes (H ^ 2) + (scheduledSeedFactor N) tau hP draw + (physicalFamilySeed source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP draw + (clampedSeedNat seed) pass) pass copy) node t q := rfl + + theorem physicalFamilyFinalValue_eq (rootQ : TargetInterval target.length) (input : SeedState × Family) : + physicalFamilyFinalValue source target N P T S H hP rootQ input = + let outcome := physicalFamilyToTrace target N P ell exponent H (ell ^ 80) passes (H ^ 2) input + localFinalProgramValue source target N P T S H rootQ + (localCommonSeed source target N P T S H hP passes outcome.1) + (localCommonTerminalSample source target N P T H hP + (localCommonSeed source target N P T S H hP passes outcome.1) outcome.2) := by + rcases input with ⟨seed, draw⟩ + dsimp only + rw [physicalFamilyToTrace_fst, physicalFamilyToTrace_snd] + unfold physicalFamilyFinalValue + rw [localRequestValue_refinement, physicalFamilySeed_eq, physicalFamily_localPassValue] + have hseed := physicalFamilySeed_prefix source target N P T S H passes hP draw seed passes le_rfl + rw [hseed] + unfold localFinalProgramValue localCommonTerminalSample + dsimp only [Prod.snd] + have hs := physicalFamilySample_fin source target N P T H passes hP draw + (localCommonSeed source target N P T S H hP passes + (physicalFamilyPrefix target N P H passes draw seed passes le_rfl)) (Fin.last passes) 0 + simp only [Fin.val_last, Fin.val_zero] at hs + rw [hs] + + theorem physicalFamilyFinalAnswer_eq (hH : 0 < H) (rootQ : TargetInterval target.length) + (input : SeedState × Family) : + physicalFamilyFinalAnswer source target N P T S H hP rootQ input = + localCommonMemoAnswer (M := M) (J := J) (R := R) source target N P T S H hP hH rootQ + (physicalFamilyToTrace target N P ell exponent H (ell ^ 80) passes (H ^ 2) input) := by + rw [localCommonMemoAnswer_eq] + unfold physicalFamilyFinalAnswer localFinalProgramAnswer freshSeedValue + rw [physicalFamilyFinalValue_eq] + + theorem physicalFamilyFinalAnswer_law (hH : 0 < H) (incoming : Measure SeedState) + [IsProbabilityMeasure incoming] (rootQ : TargetInterval target.length) : + (incoming.prod (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2))).map + (physicalFamilyFinalAnswer source target N P T S H hP rootQ) = + (localFinalProgramLaw (R := R) source target N P T S H incoming).map + (localFinalProgramAnswer (R := R) source target N P T S H rootQ) := by + classical + let : MeasurableSingletonClass (PhysicalCommonDraw M J N target.length exponent ell + (ell ^ 80) R (localOnlineMassBound M P H)) := inferInstance + let := commonSeedTraceFintype SeedState + (fun _ => LocalCommonDraw (M := M) (J := J) (R := R) target N P H) passes + let := commonSeedTraceSingleton SeedState + (fun _ => LocalCommonDraw (M := M) (J := J) (R := R) target N P H) passes + have heq : physicalFamilyFinalAnswer (R := R) source target N P T S H hP rootQ = + localCommonMemoAnswer (M := M) (J := J) (R := R) source target N P T S H hP hH rootQ ∘ + physicalFamilyToTrace target N P ell exponent H (ell ^ 80) passes (H ^ 2) := by + funext input + exact physicalFamilyFinalAnswer_eq source target N P T S H hP hH rootQ input + have htrace : (incoming.prod (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2))).map + (physicalFamilyToTrace target N P ell exponent H (ell ^ 80) passes (H ^ 2)) = + localCommonFinalLaw (M := M) (J := J) (R := R) target N P H incoming := by + exact physicalFamilyToTrace_law (Seed := SeedState) (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) incoming + rw [heq, ← Measure.map_map (measurable_of_finite _) (measurable_of_finite _), htrace] + exact localCommonMemoAnswer_law source target N P T S H hP hH incoming rootQ + +end Output + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyProgram.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1d908f24208da3f17b0a1f2498faecbff10ff21 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyProgram.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarReadCost +import OAI.Combinatorics.EditApproximation.Geometry.ChargedRandomMemo +import OAI.Combinatorics.EditApproximation.Refinement.ComputedChargedRandomSourceCost +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The actual scalar family supplies the body-value and source-read +bounds required by the mixed source/table dependency analysis. -/ + +namespace EditApproximation + +section Program + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (initial : PhysicalEntry M J target.length → ℕ) + + + +variable (hP : 0 < P) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies) + +noncomputable def physicalFamilyRequestValue := + chargedRequestValue source target N P F exponent H Q T S (passes + 1) copies + factor multiplier tau eta kappa delta + (physicalFamilyGroup target N P F exponent H Q passes copies draw) + (physicalFamilyInteger source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta hP draw initial) initial + + theorem physicalFamilyProgram_value + (request : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : + (physicalFamilyProgram source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta initial request).value + (Sum.elim (physicalFamilyAnswer target N P F exponent H Q passes copies draw) + (fun child => physicalFamilyRequestValue source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta initial hP draw child.val)) = + physicalFamilyRequestValue source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta initial hP draw request := by + exact chargedRandomGlobalQuery_value source target N P F exponent H Q T S (passes + 1) + copies factor multiplier tau eta kappa delta _ _ initial _ _ _ + (physicalRandomBoundedQuery_localValue source target N P F exponent H Q T S (passes + 1) + copies factor multiplier tau eta kappa delta _ _ initial _ _ _ + (physicalFamilyGroupRead_value target N P F exponent H Q passes copies draw) + (physicalFamilyOnlineRead_value source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta hP draw initial)) request + +end Program + +section ComputedCost + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (initial : PhysicalEntry M J target.length → ℕ) (hP : 0 < P) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H + (inputSmallLog N ^ 80) passes copies) + + theorem computed_physicalFamilyProgram_source_cost + (hN : 0 < N) (hell : 200 ≤ inputSmallLog N) (hM : M = (integerParameters N).M) + (hA : ∀ pass, factor pass ≤ ((integerParameters N).initialFactor : ℚ)) + (request : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : + (physicalFamilyProgram source target N P (inputSmallLog N) (40 * smallLogExponent N) + H (inputSmallLog N ^ 80) T S passes copies factor multiplier tau eta kappa delta initial request).cost + (Sum.elim (physicalFamilyAnswer target N P (inputSmallLog N) (40 * smallLogExponent N) + H (inputSmallLog N ^ 80) passes copies draw) + (fun child => physicalFamilyRequestValue source target N P (inputSmallLog N) + (40 * smallLogExponent N) H (inputSmallLog N ^ 80) T S passes copies factor multiplier + tau eta kappa delta initial hP draw child.val)) + (Sum.elim (fun _ => 1) (fun _ => 0)) ≤ inputHeight N ^ 91 := by + have hg := physicalFamilyGroupRead_cost_le target N P (inputSmallLog N) + (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies + (physicalFamilyAnswer target N P (inputSmallLog N) (40 * smallLogExponent N) + H (inputSmallLog N ^ 80) passes copies draw) (fun _ => 1) 1 (fun _ => le_rfl) + have ho := physicalFamilyOnlineRead_cost_le target N P (inputSmallLog N) + (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies + (physicalFamilyAnswer target N P (inputSmallLog N) (40 * smallLogExponent N) + H (inputSmallLog N ^ 80) passes copies draw) (fun _ => 1) 1 (fun _ => le_rfl) + simpa only [physicalFamilyProgram, physicalFamilyRequestValue, Nat.mul_one] using + (computed_chargedRandomGlobalQuery_source_cost source target N P H T S (passes + 1) copies + factor multiplier tau eta kappa delta + (physicalFamilyGroup target N P (inputSmallLog N) (40 * smallLogExponent N) + H (inputSmallLog N ^ 80) passes copies draw) + (physicalFamilyInteger source target N P (inputSmallLog N) (40 * smallLogExponent N) + H (inputSmallLog N ^ 80) T S passes copies factor multiplier tau eta kappa delta hP draw initial) + initial _ _ _ (fun _ => 1) 1 hN hell hM hA hg ho request) + +end ComputedCost + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyRejectionWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyRejectionWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7289f28721df279eb955f759e167c1d911b9960 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyRejectionWork.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyMemo +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilySampling +import OAI.Combinatorics.EditApproximation.Probability.RejectionMemoCost +import OAI.Combinatorics.EditApproximation.Refinement.ComputedFamilyEncoding +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section Work + +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P T S H : ℕ) + +local notation "SeedState" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "passes" => computedSeedPassCount N +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) (H ^ 2) T S +local notation "FamilyRange" => physicalFamilyRange (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) + + + + theorem physicalFamilyMemoBits_integrable (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) (rootQ : TargetInterval target.length) (seed : SeedState) : + Integrable (physicalFamilyMemoBits source target N P T S H hH bits encode rootQ seed) + (rejectionRuntimeArrayLaw FamilyRange) := rejectionSelectedBits_integrable _ _ + + theorem physicalFamilyMemoBits_expected_le (hH : 0 < H) (bits sourceBits : ℕ) + (encode : Sum Key Table → ℕ) (rootQ : TargetInterval target.length) (seed : SeedState) + (budget : ℝ) + (hrequests : ∀ draw, ((physicalFamilyMemoResult source target N P T S H hH bits encode rootQ + (seed, draw)).requests : ℝ) ≤ budget) + (hbits : ∀ key, rejectionBitCount (FamilyRange key) ≤ sourceBits) : + (∫ execution, physicalFamilyMemoBits source target N P T S H hH bits encode rootQ seed execution + ∂rejectionRuntimeArrayLaw FamilyRange) ≤ 2 * (budget * sourceBits) := by + classical + let : Fintype Table := Fintype.ofInjective + (fun key : Table => (⟨ChargedPhysicalRequest.code key, + ChargedPhysicalRequest.code_bound (Nat.one_le_iff_ne_zero.mpr (NeZero.ne M)) key⟩ : + Fin (ChargedPhysicalRequest.capacity M J target.length (passes + 1) (H ^ 2) T S))) + (fun _ _ h => ChargedPhysicalRequest.code_injective + (Nat.one_le_iff_ne_zero.mpr (NeZero.ne M)) (congrArg Fin.val h)) + apply memo_rejectionBits_expected_le_real FamilyRange _ budget sourceBits _ hbits + intro draw + have hf : (physicalFamilyMemoResult source target N P T S H hH bits encode rootQ + (seed, draw)).freshKeys.length ≤ + (physicalFamilyMemoResult source target N P T S H hH bits encode rootQ (seed, draw)).requests := + (rankedMemoEvaluate_resource_bounds _ _ _ _ _ _).1 + exact (Nat.cast_le (α := ℝ)).mpr hf |>.trans (hrequests draw) + + theorem physicalFamilyMemo_nodes_polynomial (hH : 0 < H) + (encode : Sum Key Table → ℕ) (rootQ : TargetInterval target.length) + (input : SeedState × PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2)) : + (physicalFamilyMemoResult source target N P T S H hH (16384 * inputHeight N + 5) + encode rootQ input).memory.nodes + 1 ≤ (N + 2) ^ 65542 := + computed_mixed_cache_nodes N _ _ encode _ + +end Work + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyRuntime.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyRuntime.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f79c7576e5297670ae9b550ce2bc88b8cfa8a27 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyRuntime.lean @@ -0,0 +1,81 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyAccuracy +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilySampling +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The source family is the projection of terminating rejection-sampling executions. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section Runtime + +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P T S H : ℕ) + +local notation "SeedState" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "passes" => computedSeedPassCount N +local notation "FamilyRange" => physicalFamilyRange (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Family" => PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) (H ^ 2) T S + + + +noncomputable def physicalFamilyRuntimeLaw (incoming : Measure SeedState) : + Measure (PhysicalFamilyRuntimeOutcome (M := M) (J := J) (R := R) target N P H) := + incoming.prod (rejectionRuntimeArrayLaw FamilyRange) + +instance physicalFamilyRuntimeLaw_probability (incoming : Measure SeedState) + [IsProbabilityMeasure incoming] : + IsProbabilityMeasure (physicalFamilyRuntimeLaw (R := R) target N P H incoming) := by + unfold physicalFamilyRuntimeLaw + infer_instance + + + +omit [DecidableEq α] [NeZero R] in + theorem physicalFamilyRuntimeAccepted_law (incoming : Measure SeedState) [IsProbabilityMeasure incoming] : + (physicalFamilyRuntimeLaw (R := R) target N P H incoming).map + (physicalFamilyRuntimeAccepted (R := R) target N P H) = + incoming.prod (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2)) := by + change (incoming.prod (rejectionRuntimeArrayLaw FamilyRange)).map + (Prod.map id Prod.snd) = _ + rw [← Measure.map_prod_map _ _ measurable_id measurable_snd, Measure.map_id, + physicalFamily_rejection_runtime_law] + +noncomputable def physicalFamilyRuntimeAnswer (hH : 0 < H) (bits : ℕ) + (encode : Sum (PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2)) Table → ℕ) + (rootQ : TargetInterval target.length) + (execution : PhysicalFamilyRuntimeOutcome (M := M) (J := J) (R := R) target N P H) : ℕ := + physicalFamilyMemoAnswer source target N P T S H hH bits encode rootQ + (physicalFamilyRuntimeAccepted target N P H execution) + + theorem physicalFamilyRuntimeAnswer_event (hP : 0 < P) (hH : 0 < H) (bits : ℕ) + (encode : Sum (PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2)) Table → ℕ) + (hinjective : Function.Injective encode) (hbounded : ∀ key, encode key < 2 ^ bits) + (incoming : Measure SeedState) [IsProbabilityMeasure incoming] + (rootQ : TargetInterval target.length) (event : Set ℕ) : + (physicalFamilyRuntimeLaw (R := R) target N P H incoming).real + {execution | physicalFamilyRuntimeAnswer source target N P T S H hH bits encode rootQ execution ∈ event} = + (localFinalProgramLaw (R := R) source target N P T S H incoming).real + {input | localFinalProgramAnswer (R := R) source target N P T S H rootQ input ∈ event} := by + rw [← physicalFamilyMemoAnswer_event source target N P T S H hP hH bits encode hinjective hbounded + incoming rootQ event, ← physicalFamilyRuntimeAccepted_law target N P H incoming, + map_measureReal_apply (by unfold physicalFamilyRuntimeAccepted; fun_prop) (by exact (Set.toFinite _).measurableSet)] + rfl + +end Runtime + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilySampling.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilySampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..9975a8078db21980d33fe8318c4641dd2f09982f --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilySampling.lean @@ -0,0 +1,54 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarFamilyLaw +import OAI.Combinatorics.EditApproximation.Probability.RejectionSelectedLaw +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The finite scalar family is exactly the accepted output of the +independent literal rejection samplers. Only requested coordinates need +be generated; their failure counts have a product law. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section Family + +variable {α : Type*} {M J R : ℕ} [NeZero M] + (target : List α) (N P F exponent H Q passes copies : ℕ) + + + + + + theorem physicalFamilyLaw_eq_rejectionAcceptedLaw : + physicalFamilyLaw (M := M) (J := J) (R := R) target N P F exponent H Q passes copies = + rejectionAcceptedLaw (physicalFamilyRange (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies) := rfl + + theorem physicalFamily_rejection_runtime_law : + (rejectionRuntimeArrayLaw (physicalFamilyRange (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies)).map Prod.snd = + physicalFamilyLaw (M := M) (J := J) (R := R) target N P F exponent H Q passes copies := + rejectionRuntimeArrayLaw_accepted _ + +omit [NeZero M] in + theorem physicalFamilyRange_bits_le (bits : ℕ) + (hM : M ≤ 2 ^ bits) (hB : localOnlineMassBound M P H ≤ 2 ^ bits) + (key : PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies) : + rejectionBitCount (physicalFamilyRange target N P F exponent H Q passes copies key) ≤ bits := by + apply (Nat.clog_le_iff_le_pow (by decide : 1 < (2 : ℕ))).2 + rcases key with ⟨pass, copy, scalar, index⟩ + cases scalar with + | inl online => + change online.2.val.val ≤ 2 ^ bits + exact (Nat.le_of_lt_succ online.2.val.isLt).trans hB + | inr group => exact hM + +end Family + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilySeedTrace.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilySeedTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..3adcbe0776657a37b97824ae6dc52729ac0f5913 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilySeedTrace.lean @@ -0,0 +1,133 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyTrace +import OAI.Combinatorics.EditApproximation.Geometry.LocalCommonTrace + +namespace OAI + +namespace EditApproximation + +section SourceFamily + +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P T S H passes : ℕ) (hP : 0 < P) + +local notation "SeedState" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "tau" => RationalParameters.tau (rationalParameters ell) +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "Family" => PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) + +variable (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H ((inputSmallLog N) ^ 80) passes (H ^ 2)) + + +noncomputable def physicalFamilyPrefix (seed : SeedState) (n : ℕ) (hn : n ≤ passes) : + LocalCommonTrace (M := M) (J := J) (R := R) target N P H n := + let rows : Fin n → LocalCommonDraw (M := M) (J := J) (R := R) target N P H := + fun p copy => physicalFamilyPack (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) draw + ⟨p.val, Nat.lt_succ_of_le (p.isLt.le.trans hn)⟩ copy.castSucc + commonArrayToTrace (Seed := SeedState) + (Ω := LocalCommonDraw (M := M) (J := J) (R := R) target N P H) n (seed, rows) + + +omit [DecidableEq α] [NeZero M] [NeZero R] in + theorem physicalFamilyDraw_fin (pass : Fin (passes + 1)) (copy : Fin (H ^ 2 + 1)) : + physicalFamilyDraw (M := M) (J := J) (R := R) target N P ell exponent H (ell ^ 80) passes (H ^ 2) draw pass.val copy.val = + physicalFamilyCurry (M := M) (J := J) (R := R) target N P ell exponent H (ell ^ 80) passes (H ^ 2) draw pass copy := by + funext key + unfold physicalFamilyDraw physicalFamilyCurry + have hp : Fin.ofNat (passes + 1) pass.val = pass := Fin.ext (Nat.mod_eq_of_lt pass.isLt) + have hc : Fin.ofNat (H ^ 2 + 1) copy.val = copy := Fin.ext (Nat.mod_eq_of_lt copy.isLt) + rw [hp, hc] + + +omit [DecidableEq α] [NeZero M] [NeZero R] in + theorem physicalFamilyPrefix_succ (seed : SeedState) (n : ℕ) (hn : n + 1 ≤ passes) : + physicalFamilyPrefix target N P H passes draw seed (n + 1) hn = + (physicalFamilyPrefix target N P H passes draw seed n (by omega), + fun copy : Fin (H ^ 2) => physicalFamilyPack (M := M) (J := J) (R := R) target N P ell exponent H (ell ^ 80) + passes (H ^ 2) draw ⟨n, by omega⟩ copy.castSucc) := rfl + + +omit [DecidableEq α] [NeZero M] [NeZero R] in + theorem physicalFamilyToTrace_fst (seed : SeedState) : + (physicalFamilyToTrace target N P ell exponent H (ell ^ 80) passes (H ^ 2) + (seed, draw)).1 = physicalFamilyPrefix target N P H passes draw seed passes le_rfl := by + unfold physicalFamilyToTrace commonArrayFinal + dsimp only + rw [mapCommonTrace_array] + rfl + + +omit [DecidableEq α] [NeZero M] [NeZero R] in + theorem physicalFamilyToTrace_snd (seed : SeedState) : + (physicalFamilyToTrace target N P ell exponent H (ell ^ 80) passes (H ^ 2) + (seed, draw)).2 = + physicalFamilyPack (M := M) (J := J) (R := R) target N P ell exponent H (ell ^ 80) passes (H ^ 2) draw + (Fin.last passes) 0 := rfl + + +omit [NeZero M] [NeZero R] in + theorem physicalFamilySample_fin + (seed : SeedState) (pass : Fin (passes + 1)) (copy : Fin (H ^ 2 + 1)) : + physicalFamilySample source target N P ell exponent H (ell ^ 80) T passes (H ^ 2) + (scheduledSeedFactor N) tau hP draw (clampedSeedNat seed) pass.val copy.val = + physicalCommonSample source target (clampedSeedNat seed) N P ell + (scheduledSeedFactor N pass.val) T exponent H (ell ^ 80) R + (localOnlineMassBound M P H) tau + (physicalLocalOnlineMass_le source target (clampedSeedNat seed) N P ell + (scheduledSeedFactor N pass.val) T exponent H tau hP) + (physicalFamilyPack (M := M) (J := J) (R := R) target N P ell exponent H (ell ^ 80) passes (H ^ 2) draw pass copy) := by + unfold physicalFamilySample physicalFamilyPack + rw [physicalFamilyDraw_fin] + + + theorem localScheduledSeedNext_nat_value (pass : ℕ) (previous : SeedState) + (samples : LocalScheduledSeedDraw (R := R) source target N P T H pass previous) : + clampedSeedNat (localScheduledSeedNext source target N P T S H pass previous samples) = + fun state => min N (upperMedian (List.ofFn fun copy : Fin (H ^ 2) => + ⌈(scheduledSeedMultiplier N pass : ℚ) * physicalLocalJointValue source target + (clampedSeedNat previous) N P ell (scheduledSeedFactor N pass) T exponent H (ell ^ 80) + tau eta kappa delta (samples copy) state.1 S state.2⌉₊)) := rfl + + + theorem physicalFamilySeed_prefix [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (seed : SeedState) : ∀ (n : ℕ) (hn : n ≤ passes), + physicalFamilySeed source target N P ell exponent H (ell ^ 80) T S passes (H ^ 2) + (scheduledSeedFactor N) (scheduledSeedMultiplier N) tau eta kappa delta hP draw + (clampedSeedNat seed) n = + clampedSeedNat (localCommonSeed source target N P T S H hP n + (physicalFamilyPrefix target N P H passes draw seed n hn)) := by + intro n + induction n with + | zero => intro hn; rfl + | succ n ih => + intro hn + let previous := localCommonSeed source target N P T S H hP n + (physicalFamilyPrefix target N P H passes draw seed n (by omega)) + let row := fun copy : Fin (H ^ 2) => physicalFamilyPack (M := M) (J := J) (R := R) target N P ell exponent H + (ell ^ 80) passes (H ^ 2) draw ⟨n, by omega⟩ copy.castSucc + have hnext : localCommonSeed source target N P T S H hP (n + 1) + (physicalFamilyPrefix target N P H passes draw seed (n + 1) hn) = + localScheduledSeedNext source target N P T S H n previous + (localCommonSample source target N P T H hP n previous row) := rfl + have hsamples : + (fun copy : Fin (H ^ 2) => physicalFamilySample source target N P ell exponent H + (ell ^ 80) T passes (H ^ 2) (scheduledSeedFactor N) tau hP draw + (clampedSeedNat previous) n copy.val) = + localCommonSample source target N P T H hP n previous row := by + funext copy + exact physicalFamilySample_fin source target N P T H passes hP draw previous + ⟨n, by omega⟩ copy.castSucc + rw [hnext, localScheduledSeedNext_nat_value, physicalFamilySeed, ih (by omega)] + rw [← hsamples] + +end SourceFamily + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyTrace.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab1b87a7f9fb9294b003d4489a47105caa190dac --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyTrace.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarFamilyLaw +import OAI.Combinatorics.EditApproximation.Probability.FiniteArrayMarginal + +namespace OAI + +/-! The literal finite scalar family supplies the independent common +source trace and its final draw, after removing unused extra copies. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section SourceFamily + +variable {Seed α : Type} {M J R : ℕ} [NeZero M] + (target : List α) (N P F exponent H Q passes copies : ℕ) + +local notation "Draw" => PhysicalCommonDraw M J N target.length exponent F Q R (localOnlineMassBound M P H) +local notation "Family" => PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies +local notation "μ" => physicalCommonLaw M J N target.length exponent F Q R (localOnlineMassBound M P H) + +def physicalFamilyToTrace (input : Seed × Family) : + CommonSeedTrace Seed (fun _ => Fin copies → Draw) passes × Draw := + let packed := physicalFamilyPack target N P F exponent H Q passes copies input.2 + let rows := commonArrayFinal passes (input.1, packed) + (mapCommonTrace (fun row (copy : Fin copies) => row copy.castSucc) passes rows.1, + rows.2 0) + +variable [Fintype Seed] [MeasurableSpace Seed] [MeasurableSingletonClass Seed] + (incoming : Measure Seed) + + theorem physicalFamilyToTrace_law : + (incoming.prod (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies)).map + (physicalFamilyToTrace (Seed := Seed) target N P F exponent H Q passes copies) = + (commonTraceLaw (fun _ => Measure.pi fun _ : Fin copies => μ) incoming passes).prod μ := by + classical + let : MeasurableSingletonClass Draw := inferInstance + let : MeasurableSingletonClass (Fin (copies + 1) → Draw) := inferInstance + let : MeasurableSingletonClass (Fin (passes + 1) → Fin (copies + 1) → Draw) := inferInstance + let := commonSeedTraceFintype Seed (fun _ => Fin (copies + 1) → Draw) passes + let := commonSeedTraceSingleton Seed (fun _ => Fin (copies + 1) → Draw) passes + let rowLaw : Measure (Fin (copies + 1) → Draw) := Measure.pi fun _ => μ + let trim : (Fin (copies + 1) → Draw) → (Fin copies → Draw) := fun row copy => row copy.castSucc + let finish : (Fin (copies + 1) → Draw) → Draw := fun row => row 0 + let pack : Seed × Family → Seed × (Fin (passes + 1) → Fin (copies + 1) → Draw) := + Prod.map (id : Seed → Seed) + (physicalFamilyPack target N P F exponent H Q passes copies) + let finalMap := Prod.map (mapCommonTrace (Seed := Seed) trim passes) finish + have hpack : (incoming.prod (physicalFamilyLaw (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies)).map pack = + incoming.prod (Measure.pi fun _ : Fin (passes + 1) => rowLaw) := by + dsimp only [pack, rowLaw] + rw [← Measure.map_prod_map _ _ measurable_id (measurable_of_finite _), Measure.map_id, + physicalFamilyPack_law] + have hrow : rowLaw.map trim = Measure.pi fun _ : Fin copies => μ := + finite_init_law μ copies + have hlast : rowLaw.map finish = μ := by + simpa only [measure_univ, Finset.prod_const_one, one_smul] using + (Measure.pi_map_eval (fun _ : Fin (copies + 1) => μ) 0) + have hmap : ((commonTraceLaw (fun _ => rowLaw) incoming passes).prod rowLaw).map finalMap = + (commonTraceLaw (fun _ => Measure.pi fun _ : Fin copies => μ) incoming passes).prod μ := by + dsimp only [finalMap] + rw [← Measure.map_prod_map _ _ (measurable_of_finite _) (measurable_of_finite _), + mapCommonTrace_law incoming rowLaw trim passes, hrow, hlast] + have heq : physicalFamilyToTrace (Seed := Seed) target N P F exponent H Q passes copies = + finalMap ∘ commonArrayFinal passes ∘ pack := rfl + rw [heq, ← Measure.map_map (measurable_of_finite _) (measurable_of_finite _), + ← Measure.map_map (measurable_of_finite _) (measurable_of_finite _), hpack, + commonArrayFinal_law incoming rowLaw passes] + exact hmap + +end SourceFamily + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b06741561c8f0c8fa5dc6323a73a37fdf7dac9d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFamilyWork.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyProgram +import OAI.Combinatorics.EditApproximation.Geometry.ChargedRandomMemoWork + +namespace OAI + +namespace EditApproximation + +section Work + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (initial : PhysicalEntry M J target.length → ℕ) (hPpos : 0 < P) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "group" => physicalFamilyGroup target N P ell exponent H (ell ^ 80) passes copies draw +local notation "integer" => physicalFamilyInteger source target N P ell exponent H (ell ^ 80) + T S passes copies factor multiplier tau eta kappa delta hPpos draw initial +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw +local notation "bodyValue" => physicalFamilyProgram_value source target N P ell exponent H (ell ^ 80) + T S passes copies factor multiplier tau eta kappa delta initial hPpos draw + +noncomputable def physicalFamilyDependencyTree + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : DependencyExpansion := + chargedRandomDependencyTree source target N P H T S (passes + 1) copies factor multiplier + tau eta kappa delta group integer initial readGroup readInteger answer bodyValue root + + theorem physicalFamilyDependencyTree_depth + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : + (physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hPpos draw root).depth = root.depth := by + exact queryDependencyExpansion_depth _ _ _ + (chargedRandomRequestList_progress source target N P H T S (passes + 1) copies factor multiplier + tau eta kappa delta group integer initial readGroup readInteger answer bodyValue) root + + theorem physicalFamilyDependencyTree_rank + (hpasses : passes = computedSeedPassCount N) (hT : T = (integerParameters N).T) + (hS : S = (integerParameters N).S) + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : + (physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hPpos draw root).rank ≤ computedDependencyIndexCount N := by + have heq : (physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hPpos draw root).rank = root.index := + queryDependencyExpansion_index _ _ _ + (chargedRandomRequestList_progress source target N P H T S (passes + 1) copies factor multiplier + tau eta kappa delta group integer initial readGroup readInteger answer bodyValue) root + rw [heq] + apply (chargedRequest_index_le root).trans_eq + simp only [computedDependencyIndexCount, hpasses, hT, hS] + + theorem physicalFamilyDependencyTree_valid + (hN : 0 < N) (hell : 200 ≤ ell) (hM : M = (integerParameters N).M) + (hP : P = (integerParameters N).P) (hT : T = (integerParameters N).T) + (hS : S = (integerParameters N).S) (hcopies : copies ≤ inputHeight N ^ 2) + (hAmin : ∀ pass, 1 ≤ factor pass) + (hAmax : ∀ pass, factor pass ≤ ((integerParameters N).initialFactor : ℚ)) + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : + (physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hPpos draw root).Valid + (M * ell ^ 257) (inputHeight N ^ (512 * (coarseExponent ell + 1))) := + chargedRandomDependencyTree_valid source target N P H T S (passes + 1) copies factor multiplier + tau eta kappa delta group integer initial readGroup readInteger answer bodyValue + hN hell hM hP hT hS hcopies hAmin hAmax root + + theorem physicalFamilyMemo_requests_le_width + (hN : 0 < N) (hell : 200 ≤ ell) (hM : M = (integerParameters N).M) + (hAmax : ∀ pass, factor pass ≤ ((integerParameters N).initialFactor : ℚ)) + (bits : ℕ) (encode : Sum + (PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies) + (ChargedPhysicalRequest M J target.length (passes + 1) copies T S) → ℕ) + (hinjective : Function.Injective encode) (hbounded : ∀ key, encode key < 2 ^ bits) + (root : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : + (chargedRandomMemoEvaluate source target N P ell exponent H (ell ^ 80) T S (passes + 1) + copies factor multiplier tau eta kappa delta readGroup readInteger initial answer bits encode root).requests ≤ + (inputHeight N ^ 91 + 1) * + (physicalFamilyDependencyTree source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hPpos draw root).widthWork M source.length := + chargedRandomMemoEvaluate_requests_le_widthWork source target N P H T S (passes + 1) + copies factor multiplier tau eta kappa delta group integer initial readGroup readInteger answer + bodyValue (inputHeight N ^ 91) bits encode hinjective hbounded + (computed_physicalFamilyProgram_source_cost source target N P H T S passes copies factor multiplier + tau eta kappa delta initial hPpos draw hN hell hM hAmax) root + +end Work + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFinalAccuracy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFinalAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..90ca9aca5001bba5d17ecfb293d2b5e240d20de0 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalFinalAccuracy.lean @@ -0,0 +1,160 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSeedSchedule +import OAI.Combinatorics.EditApproximation.Probability.FiniteSeedFinal + +namespace OAI + +/-! Accuracy of the final fresh refinement after adaptive median seed passes, +under finite Bernstein bounds and an explicit incoming seed failure bound. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section Final + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N P T S H : ℕ) + +local notation "Seed" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "terminalFactor" => scheduledSeedFactor N (computedSeedPassCount N) +local notation "thetaExponent" => (40 * smallLogExponent N : ℕ) +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "tau" => RationalParameters.tau (rationalParameters ell) + +abbrev FinalProgramDraw (seed : Seed) := + PhysicalProgramDraw (R := R) source target (clampedSeedNat seed) N P ell terminalFactor + T thetaExponent H (ell ^ 80) tau + +noncomputable def finalProgramDrawLaw (seed : Seed) : + Measure (FinalProgramDraw (R := R) source target N P T H seed) := + physicalProgramDrawLaw (R := R) source target (clampedSeedNat seed) N P ell terminalFactor + T thetaExponent H (ell ^ 80) tau + +instance finalProgramDrawLaw_probability (seed : Seed) : + IsProbabilityMeasure (finalProgramDrawLaw (R := R) source target N P T H seed) := by + unfold finalProgramDrawLaw + infer_instance + +noncomputable def finalProgramValue (rootQ : TargetInterval target.length) (seed : Seed) + (draw : FinalProgramDraw (R := R) source target N P T H seed) : ℝ := + physicalRefinement source target (clampedSeedNat seed) N P ell terminalFactor T delta + (physicalProgramDrawSelections source target (clampedSeedNat seed) N P ell terminalFactor + T thetaExponent H (ell ^ 80) tau eta kappa draw) + (Sigma.mk (Fin.mk 0 (Nat.zero_lt_succ J)) PUnit.unit : PhysicalNode M J) S rootQ + +abbrev FinalProgramOutcome := Seed × (∀ seed : Seed, FinalProgramDraw (R := R) source target N P T H seed) + +noncomputable def finalProgramLaw (incoming : Measure Seed) : + Measure (FinalProgramOutcome (M := M) (J := J) (R := R) source target N P T H) := by + classical + exact (scheduledSeedLaw (R := R) source target N P T S H incoming (computedSeedPassCount N)).prod + (Measure.pi (finalProgramDrawLaw (R := R) source target N P T H)) + +instance finalProgramLaw_probability (incoming : Measure Seed) [IsProbabilityMeasure incoming] : + IsProbabilityMeasure (finalProgramLaw (R := R) source target N P T S H incoming) := by + unfold finalProgramLaw + infer_instance + +/-- Equality is tested before the final query, so equal strings return zero +on every execution, including executions with a bad seed. -/ +noncomputable def finalProgramAnswer (rootQ : TargetInterval target.length) + (pair : FinalProgramOutcome (M := M) (J := J) (R := R) source target N P T H) : ℕ := + if source = substring target rootQ.lo rootQ.hi then 0 else + integerAnswer N (freshSeedValue (finalProgramValue (M := M) (J := J) (R := R) source target N P T S H rootQ) pair) + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem finalProgramAnswer_equal (rootQ : TargetInterval target.length) + (heq : source = substring target rootQ.lo rootQ.hi) + (pair : FinalProgramOutcome (M := M) (J := J) (R := R) source target N P T H) : + finalProgramAnswer (R := R) source target N P T S H rootQ pair = 0 := by + simp only [finalProgramAnswer, heq, ite_true] + +variable (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (hPeq : P = (integerParameters N).P) (hTeq : T = (integerParameters N).T) + (hSeq : S = (integerParameters N).S) (hHeq : H = inputHeight N) + (hsize : source.length + target.length ≤ N) + (bernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + +include hN hell hMeq hJeq hPeq hTeq hSeq hHeq hsize bernstein in +theorem finalProgram_accuracy (incoming : Measure Seed) [IsProbabilityMeasure incoming] + (hinitial : incoming.real {seed | ¬ physicalSeedGood source target + ((integerParameters N).initialFactor : ℚ) seed} ≤ 1 / 100) + (rootQ : TargetInterval target.length) (epsilon : ℝ) (hepsilon : 0 < epsilon) + (haccuracy : 10 ≤ (inputSmallLog N : ℝ) * epsilon) : + (4 / 5 : ℝ) ≤ (finalProgramLaw (R := R) source target N P T S H incoming).real + {pair | stateEditCost source target rootQ ≤ + finalProgramAnswer (R := R) source target N P T S H rootQ pair ∧ + (finalProgramAnswer (R := R) source target N P T S H rootQ pair : ℝ) ≤ + (1 + epsilon) * stateEditCost source target rootQ} := by + classical + by_cases heq : source = substring target rootQ.lo rootQ.hi + · have hcost : stateEditCost source target rootQ = 0 := + (EditDistortion.cost_eq_zero_iff (s := true)).mpr heq + have hans (pair : FinalProgramOutcome (M := M) (J := J) (R := R) source target N P T H) : + finalProgramAnswer (R := R) source target N P T S H rootQ pair = 0 := + finalProgramAnswer_equal source target N P T S H rootQ heq pair + simp only [hans, hcost, Nat.cast_zero, mul_zero, le_refl, and_self, Set.ofPred_true, probReal_univ] + norm_num + have hD : 0 < stateEditCost source target rootQ := + Nat.pos_of_ne_zero (fun h => heq ((EditDistortion.cost_eq_zero_iff (s := true)).mp h)) + have hf : 3 ≤ smallLogExponent N := by + have h := (Nat.pow_le_pow_iff_right (by decide : 1 < (2 : ℕ))).mp hell + omega + have hA : (1 : ℚ) ≤ terminalFactor := by + unfold scheduledSeedFactor + exact one_le_pow₀ (by norm_num) + have hAupper : terminalFactor ≤ ((integerParameters N).initialFactor : ℚ) := by + unfold scheduledSeedFactor + rw [← computedSeed_initial_factor] + exact dyadicSeedFactor_bound _ _ _ + have ha := scheduledSeedFactor_terminal_refinement N hf + have hbranch : 0 < M := Nat.pos_of_ne_zero (NeZero.ne M) + have hP := computed_program_grid_lower N P hN hPeq + have hF : 1 ≤ ell := Nat.one_le_two_pow + have hT : 0 < T := by rw [hTeq]; exact (computed_stage_positive_counts N hN hell).1 + have hEll : (0 : ℝ) < ell := Nat.cast_pos.2 (Nat.two_pow_pos _) + let terminalLaw := scheduledSeedLaw (R := R) source target N P T S H incoming (computedSeedPassCount N) + let good : Seed → Prop := physicalSeedGood source target terminalFactor + let value := finalProgramValue (M := M) (J := J) (R := R) source target N P T S H rootQ + have hseed : terminalLaw.real {seed | ¬ good seed} ≤ 1 / 10 := + (scheduledSeedLaw_failure_lt (R := R) source target N P T S H hN hell hMeq hJeq hPeq + hTeq hSeq hHeq hsize bernstein incoming hinitial).le + have hlower (seed : Seed) (hg : good seed) (draw : FinalProgramDraw (R := R) source target N P T H seed) : + (stateEditCost source target rootQ : ℝ) ≤ value seed draw := by + have h := (physicalRefinement_stage_bounds source target hbranch (clampedSeedNat seed) N P ell + terminalFactor hsize hP hF hA hg T hT delta + (physicalProgramDrawSelections source target (clampedSeedNat seed) N P ell terminalFactor + T thetaExponent H (ell ^ 80) tau eta kappa draw) + (Sigma.mk (Fin.mk 0 (Nat.zero_lt_succ J)) PUnit.unit : PhysicalNode M J) S rootQ).1 + have hleft := (le_max_left _ _).trans h + simpa only [value, finalProgramValue, ha, Rat.cast_one, div_one, physicalSource, physicalSourceInterval, + sourceIntervalAt, substring, List.take_length, List.drop_zero] using hleft + have hmoment (seed : Seed) (hg : good seed) : + (∫ draw, max (value seed draw - stateEditCost source target rootQ) 0 + ∂finalProgramDrawLaw (R := R) source target N P T H seed) ≤ + (stateEditCost source target rootQ : ℝ) / ell := by + have h := physicalProgram_expected_root_excess (R := R) source target N hN hell hMeq hJeq + (clampedSeedNat seed) P hPeq terminalFactor hA hAupper hsize hg T S hTeq hSeq hHeq bernstein rootQ + simpa only [value, finalProgramValue, finalProgramDrawLaw, one_div_mul_eq_div] using h + have hDN : stateEditCost source target rootQ ≤ N := by + have h := physical_state_cost_le (M := M) (J := J) source target N hsize + ((Sigma.mk (Fin.mk 0 (Nat.zero_lt_succ J)) PUnit.unit : PhysicalNode M J), rootQ) + simpa only [physicalSource, physicalSourceInterval, sourceIntervalAt, substring, + List.take_length, List.drop_zero] using h + have h := freshSeed_answer_accuracy (finalProgramDrawLaw (R := R) source target N P T H) + terminalLaw good value hDN hD hEll hepsilon haccuracy hseed hlower hmoment + simpa only [finalProgramLaw, finalProgramAnswer, heq, ite_false, terminalLaw, value] using h + +end Final + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGenericRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGenericRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..9022c82112257c36f1fd36c1ed4f85f73e725b5d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGenericRegret.lean @@ -0,0 +1,181 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalNodeRegret +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonEnergy + +namespace OAI + +/-! The generic regret bound for the actual complete physical recurrence. -/ + +namespace EditApproximation + +open Finset + +section Node + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (q : TargetInterval target.length) + (hc : 0 < stateEditCost (physicalSource source node) target q) + +local notation "parent" => physicalSourceInterval source.length node +local notation "b" => 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) +local notation "r" => roundInterval (seedGridSpacing b P) q +local notation "action" => comparisonChildren source target hM P hP parent q hc +local notation "mass" => fun i s => (stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) : ℝ) +local notation "W" => comparisonActionMass action mass +local notation "value" => fun t (s : PhysicalEntry M J target.length) => + (physicalRefinement source target U N P F A T delta choices (Prod.fst s) t (Prod.snd s) : ℝ) +local notation "regret" => fun t => + max (stateEditCost (physicalSource source node) target q : ℝ) (value (t + 1) (node, q)) - + (128 * (F : ℝ)) * targetEndpointDistance q r - + physicalComparisonClipped source target U N P F A T delta choices node hbelow action (t + 1) + +include hsize hF hA hseed hT hleaf in + theorem physicalNode_generic_regret (S : ℕ) : + (∑ t ∈ range S, regret t) ≤ W - |stateLengthGap (physicalSource source node) target r| := by + have hspec := comparisonChildren_spec source target hM P hP parent q hc + have hzero : endpointActionConnection r action = 0 := hspec.2.1 + have hrep := stageRounded_representative_mem source target U N P F A hsize hP hF hA hseed node q hc + have hL : (1 : ℝ) ≤ 128 * F := by + have hFR : (1 : ℝ) ≤ F := by exact_mod_cast hF + linarith only [hFR] + have hsplit : (stateEditCost (physicalSource source node) target q : ℝ) ≤ + (128 * (F : ℝ)) * targetEndpointDistance q r + + ∑ i, (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) : ℝ) := by + have h := comparisonChildren_lower source target hM P hP parent q hc + have he := mul_le_mul_of_nonneg_right hL (Nat.cast_nonneg (α := ℝ) (targetEndpointDistance q r)) + change (stateEditCost (physicalSource source node) target q : ℝ) ≤ + (∑ i, (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) : ℝ)) + + targetEndpointDistance q r at h + simp only [one_mul] at he + linarith only [h, he] + have hbellman (t : ℕ) (_ht : t < S) : + value (t + 1) (node, q) ≤ (128 * (F : ℝ)) * targetEndpointDistance q r + + ∑ i, value t (physicalChild node hbelow i, action i) := by + have hQ := (physicalRefinement_bellman_invariants source target U N P F A T delta choices node t q).2 + have hR := (Rat.cast_le (K := ℝ)).mpr hQ + rw [rationalPhysicalBellman_cast] at hR + have h := physicalBellman_le_action source target P ((128 * F : ℚ) : ℝ) + (fun s => (stageInitial source target U N P F A s : ℝ)) + (stageRepresentatives source target U N P F A) (value t) node hbelow hleaf q r b hrep action hspec.1 + rw [hzero, Nat.cast_zero, add_zero] at h + simpa only [Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast] using hR.trans h + have hmono (i : Fin M) (_hi : i ∈ (univ : Finset (Fin M))) : + value S (physicalChild node hbelow i, action i) ≤ value 0 (physicalChild node hbelow i, action i) := by + apply Rat.cast_le.mpr + have hantitone : Antitone (fun t => physicalRefinement source target U N P F A T delta choices + (physicalChild node hbelow i) t (action i)) := + antitone_nat_of_succ_le (fun t => physicalRefinement_nonincreasing source target U N P F A T delta choices + (physicalChild node hbelow i) t (action i)) + exact hantitone (Nat.zero_le S) + have hinv (i : Fin M) := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed + T hT (physicalChild node hbelow i, action i) + have hinit (i : Fin M) (_hi : i ∈ (univ : Finset (Fin M))) : + value 0 (physicalChild node hbelow i, action i) ≤ mass i (action i) := by + dsimp only + rw [physicalRefinement_zero] + exact Rat.cast_le.mpr (hinv i).2.1 + have hgapMass (i : Fin M) (_hi : i ∈ (univ : Finset (Fin M))) : + |stateLengthGap (physicalSource source (physicalChild node hbelow i)) target (action i)| ≤ mass i (action i) := + ((le_max_right _ _).trans (hinv i).1).trans (Rat.cast_le.mpr (hinv i).2.1) + have h := generic_regret_mass_bound univ S + (stateEditCost (physicalSource source node) target q : ℝ) + ((128 * (F : ℝ)) * targetEndpointDistance q r) + (fun i => (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) : ℝ)) + (fun i => mass i (action i)) + (fun i => stateLengthGap (physicalSource source (physicalChild node hbelow i)) target (action i)) + (fun t => value t (node, q)) (fun t i => value t (physicalChild node hbelow i, action i)) + hsplit hbellman hmono hinit + (fun i _ => stateEditCost_length_lower _ _ _) hgapMass + apply h.trans + have hsum := sum_mass_sub_abs_le univ (fun i => mass i (action i)) + (fun i => stateLengthGap (physicalSource source (physicalChild node hbelow i)) target (action i)) + have hgapSum : (∑ i, stateLengthGap (physicalSource source (physicalChild node hbelow i)) target (action i)) = + stateLengthGap (physicalSource source node) target r := + zero_connection_gap_sum source target hM parent r action hzero + rw [hgapSum] at hsum + exact hsum + +include hsize hF hA hseed hT in + theorem physicalComparison_mass_upper (hMP : 4 * (M : ℝ) / P ≤ 1) : + W ≤ 4 * F * stateEditCost (physicalSource source node) target q := by + have hcost := comparisonChildren_cost_bound source target hM P hP parent q hc + change (∑ i, (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) : ℝ)) ≤ + (1 + 4 * (M : ℝ) / P) * stateEditCost (physicalSource source node) target q at hcost + have hsum : W ≤ 2 * (F : ℝ) * ∑ i, + (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (action i) : ℝ) := by + change (∑ i, mass i (action i)) ≤ _ + rw [mul_sum] + apply sum_le_sum + intro i _ + have h := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT + (physicalChild node hbelow i, action i) + have hQ := h.2.2.1.trans h.2.2.2 + simpa only [Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast] using (Rat.cast_le (K := ℝ)).mpr hQ + have hfactor := mul_le_mul_of_nonneg_left hcost (show (0 : ℝ) ≤ 2 * F by positivity) + have hcost0 : (0 : ℝ) ≤ stateEditCost (physicalSource source node) target q := Nat.cast_nonneg _ + have hfactor2 := mul_le_mul_of_nonneg_right hMP hcost0 + have hfactor3 := mul_le_mul_of_nonneg_left hfactor2 (show (0 : ℝ) ≤ 2 * F by positivity) + nlinarith only [hsum, hfactor, hfactor3] + +include hsize hF hA hseed hT hleaf in + theorem physicalNode_generic_regret_upper (hMP : 4 * (M : ℝ) / P ≤ 1) (S : ℕ) : + (∑ t ∈ range S, regret t) ≤ 4 * F * stateEditCost (physicalSource source node) target q := by + exact (physicalNode_generic_regret source target hM U N P F A hsize hP hF hA hseed T hT delta choices node + hbelow hleaf q hc S).trans ((sub_le_self _ (abs_nonneg _)).trans + (physicalComparison_mass_upper source target hM U N P F A hsize hP hF hA hseed T hT node hbelow q hc hMP)) + +include hsize hF hA hseed hT hleaf in + theorem physicalNode_near_length_gap_regret + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hnonempty : wideActionList M parent r b P ≠ []) (tau : ℚ) (htau : 0 ≤ tau) + (hprediction : 1 - tau < |rationalStateGap (physicalSource source node) target r / + rationalWideActionMinimum parent r b P hnonempty + (physicalBandChildMassTable source target U N P F A T node hbelow)|) + (ratio : ℝ) + (hdiscrepancy : W - wideActionMinimum parent r b P hnonempty mass ≤ + ratio * stateEditCost (physicalSource source node) target q) (S : ℕ) : + (∑ t ∈ range S, regret t) ≤ + (ratio + 4 * (tau : ℝ) * F) * stateEditCost (physicalSource source node) target q := by + let Z := wideActionMinimum parent r b P hnonempty mass + have hspec := comparisonChildren_spec source target hM P hP parent q hc + have ha : (1 : ℝ) ≤ refinementFactor A F := by + simpa only [Rat.cast_one] using (Rat.cast_le (K := ℝ)).mpr (refinementFactor_spec A F (by omega)).1 + have hlower := wideActionMinimum_lower source target hM parent r b P hnonempty + (refinementFactor A F : ℝ) ha mass + (stageWarmupMass_child_lower source target hM U N P F A hsize hP hF hA hseed T hT node hbelow) + have hpositive := (stageComparison_positive_movement source target hM U N P F A hsize hP hF hA hseed + T hT node q hc hscale).1 + have hcostPos : (0 : ℝ) < stateEditCost (physicalSource source node) target r := by exact_mod_cast hpositive + have hZ : 0 < Z := (div_pos hcostPos (by linarith only [ha])).trans_le ((le_max_left _ _).trans hlower) + have hZW : Z ≤ W := by + have h := wideActionMinimum_le_member parent r hnonempty mass action hspec.1 + have hzero : endpointActionConnection r action = 0 := hspec.2.1 + simpa only [Z, endpointActionValue, hzero, Nat.cast_zero, zero_add, comparisonActionMass] using h + have hpred : 1 - (tau : ℝ) < |stateLengthGap (physicalSource source node) target r| / Z := by + have h := (Rat.cast_lt (K := ℝ)).mpr hprediction + simp only [Rat.cast_sub, Rat.cast_one, Rat.cast_abs, Rat.cast_div, rationalStateGap_cast, + rationalWideActionMinimum_cast, abs_div] at h + change 1 - (tau : ℝ) < |stateLengthGap (physicalSource source node) target r| / |Z| at h + rwa [abs_of_pos hZ] at h + have hnear := near_length_gap_regret_bound W Z (stateLengthGap (physicalSource source node) target r) + (tau : ℝ) ratio F (stateEditCost (physicalSource source node) target q) hZ hZW + ((Rat.cast_nonneg (K := ℝ)).mpr htau) hpred hdiscrepancy + (physicalComparison_mass_upper source target hM U N P F A hsize hP hF hA hseed T hT node hbelow q hc hMP) + exact (physicalNode_generic_regret source target hM U N P F A hsize hP hF hA hseed T hT delta choices + node hbelow hleaf q hc S).trans hnear + +end Node + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGlobalQuery.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGlobalQuery.lean new file mode 100644 index 0000000000000000000000000000000000000000..3346394e7cd3abc742d81a9c71b0a4e4e154cbdc --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGlobalQuery.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.EditApproximation.Probability.FiniteQueryRestriction +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementDataRequest +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalMedianQuery +import OAI.Combinatorics.EditApproximation.Geometry.LocalSeedSequence +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The global query body. A seed read at pass zero evaluates the coarse +seed entry; every later pass reads the preceding pass's copy medians. +All warmup and refinement dependencies carry strict physical ranks. -/ + +namespace EditApproximation + + + +section Program + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q T S copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) + +def physicalGlobalQuery (request : PhysicalTableRequest M J target.length) : + FiniteQuery {child : PhysicalTableRequest M J target.length // + child.combinedRank T S < request.combinedRank T S} := by + let seedRead := globalSeedRead N T S copies multiplier initial request + by_cases hwarmup : request.index ≤ T + · exact physicalWarmupRequestQuery source target N P F (factor request.pass) + request.pass request.copy T S request.index request.node request.state seedRead + · by_cases hbelow : request.node.1.val < J + · by_cases hshort : (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1 + · exact physicalInitialQuery source target N P F (factor request.pass) seedRead + (request.node, request.state) + · have ht : 0 < request.index - T := by omega + have hrequest : PhysicalTableRequest.refinement request.pass request.copy request.node + T (request.index - T) request.state = request := by + have hi : T + (request.index - T) = request.index := by omega + unfold PhysicalTableRequest.refinement + rw [hi] + have program := physicalRefinementDataRequestQuery source target N P F exponent H Q + tau (refinementFactor (factor request.pass) F) eta kappa delta + request.pass request.copy T S (request.index - T) ht request.node hbelow + (group request.pass request.copy ⟨request.node, hbelow⟩ (Fin.ofNat R (request.index - T - 1))) + (integer request.pass request.copy ⟨request.node, hbelow⟩ (Fin.ofNat R (request.index - T - 1))) + request.state + exact FiniteQuery.mapKeys + (fun child => ⟨child.val, by simpa only [hrequest] using child.property⟩) program + · exact physicalInitialQuery source target N P F (factor request.pass) seedRead + (request.node, request.state) + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGlobalValue.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGlobalValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..82ba97dec80b6cb7c4ce2ab04e4128eb552e9c05 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGlobalValue.lean @@ -0,0 +1,250 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalGlobalQuery +import OAI.Combinatorics.EditApproximation.Geometry.RankedMemoSimulation + +namespace OAI + +/-! The global query body computes the local pass recurrence on every seed and draw. -/ + +namespace EditApproximation + +section Value + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q T S copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) + +theorem physicalGlobalQuery_warmup (pass copy : ℕ) (node : PhysicalNode M J) + (j : ℕ) (hj : j ≤ T) (q : TargetInterval target.length) : + physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.warmup pass copy node j q) = + physicalWarmupRequestQuery source target N P F (factor pass) pass copy T S j node q + (globalSeedRead N T S copies multiplier initial (PhysicalTableRequest.warmup pass copy node j q)) := by + unfold physicalGlobalQuery + dsimp only + erw [dite_eq_left (show (PhysicalTableRequest.warmup pass copy node j q).index ≤ T from hj)] + rfl + +theorem physicalGlobalQuery_refinement_value (request : PhysicalTableRequest M J target.length) + (hindex : T < request.index) (hbelow : request.node.1.val < J) + (hshort : ¬ (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1) + (values : PhysicalTableRequest M J target.length → ℚ) : + (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request).value (fun child => values child.val) = + (physicalRefinementDataRequestQuery source target N P F exponent H Q tau + (refinementFactor (factor request.pass) F) eta kappa delta request.pass request.copy T S + (request.index - T) (Nat.sub_pos_of_lt hindex) request.node hbelow + (group request.pass request.copy ⟨request.node, hbelow⟩ (Fin.ofNat R (request.index - T - 1))) + (integer request.pass request.copy ⟨request.node, hbelow⟩ (Fin.ofNat R (request.index - T - 1))) + request.state).value (fun child => values child.val) := by + unfold physicalGlobalQuery + dsimp only + erw [dite_eq_right (Nat.not_le.mpr hindex), dite_eq_left hbelow, dite_eq_right hshort] + rw [FiniteQuery.mapKeys_value] + rfl + + +theorem globalSeedRead_value (parent : PhysicalTableRequest M J target.length) + (q : TargetInterval target.length) : + (globalSeedRead N T S copies multiplier initial parent (parent.node, q)).value + (fun child => localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial child.val) = + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial parent.pass (parent.node, q) : ℚ) := by + by_cases hp : parent.pass = 0 + · rw [globalSeedRead, ite_eq_left rfl, dite_eq_left hp] + change (initial (parent.node, q) : ℚ) = _ + rw [hp] + rfl + · simp only [globalSeedRead, ite_true, dite_eq_right hp] + rw [physicalMedianSeedQuery_value] + have hprev (copy : Fin copies) : + previousPassRequest T S copy.val parent q = + PhysicalTableRequest.refinement (parent.pass - 1) copy.val parent.node T S q := rfl + simp only [hprev, localRequestValue_refinement] + obtain ⟨pass, hpass⟩ := Nat.exists_eq_succ_of_ne_zero hp + simp only [hpass, Nat.succ_eq_add_one, Nat.add_sub_cancel, localSeedSequence] + +theorem localRequestValue_initial (pass copy : ℕ) (node : PhysicalNode M J) + (q : TargetInterval target.length) : + localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.warmup pass copy node 0 q) = + stageInitial source target + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) N P F (factor pass) (node, q) := by + rw [localRequestValue_warmup source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass copy node 0 (Nat.zero_le T)] + rfl + +theorem localRequestValue_mass (pass copy : ℕ) (node : PhysicalNode M J) + (q : TargetInterval target.length) : + (∑ j : Fin T, localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.warmup pass copy node j.val q)) / T = + physicalLocalWarmupMass source target + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) N P F (factor pass) T (node, q) := by + unfold physicalLocalWarmupMass + rw [← Fin.sum_univ_eq_sum_range] + congr 1 + exact Finset.sum_congr rfl (fun j _ => localRequestValue_warmup source target N P F exponent H Q + T S copies factor multiplier tau eta kappa delta group integer initial pass copy node j.val + (Nat.le_of_lt j.isLt) q) + + +theorem localPassValue_step (seed : PhysicalEntry M J target.length → ℕ) + (pass copy : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hshort : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (t : ℕ) (ht : 0 < t) (q : TargetInterval target.length) : + let children := fun i s r => localPassValue source target N P F exponent H Q T factor + tau eta kappa delta group integer seed pass copy (physicalChild node hbelow i) s r + localPassValue source target N P F exponent H Q T factor tau eta kappa delta group integer + seed pass copy node t q = + rationalLocalWideStep source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor (factor pass) F) delta + (fun r => stageInitial source target seed N P F (factor pass) (node, r)) + (physicalLocalChildMass source target seed N P F (factor pass) T node hbelow) + (fun i r => stageInitial source target seed N P F (factor pass) (physicalChild node hbelow i, r)) + (fun i r => children i (t - 1) r) (fun i r => children i t r) + (group pass copy ⟨node, hbelow⟩ (Fin.ofNat R (t - 1))) + (localOnlineCandidates source target (physicalSourceInterval source.length node) + N P F exponent H tau (refinementFactor (factor pass) F) eta kappa + (fun r => stageInitial source target seed N P F (factor pass) (node, r)) + (physicalLocalChildMass source target seed N P F (factor pass) T node hbelow) + (fun i r => stageInitial source target seed N P F (factor pass) (physicalChild node hbelow i, r)) + children (t - 1) (integer pass copy ⟨node, hbelow⟩ (Fin.ofNat R (t - 1))) q) q := by + dsimp only + cases t with + | zero => omega + | succ t => + unfold localPassValue + rw [physicalLocalRefinement] + simp only [dite_eq_left hbelow, ite_eq_right hshort, Nat.add_sub_cancel, + physicalLocalOnline] + rfl + +theorem physicalRefinementDataRequestQuery_localValue (pass copy : ℕ) (node : PhysicalNode M J) + (hbelow : node.1.val < J) + (hshort : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (t : ℕ) (ht : 0 < t) (q : TargetInterval target.length) : + (physicalRefinementDataRequestQuery source target N P F exponent H Q tau + (refinementFactor (factor pass) F) eta kappa delta pass copy T S t ht node hbelow + (group pass copy ⟨node, hbelow⟩ (Fin.ofNat R (t - 1))) + (integer pass copy ⟨node, hbelow⟩ (Fin.ofNat R (t - 1))) q).value + (fun child => localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial child.val) = + localPassValue source target N P F exponent H Q T factor tau eta kappa delta group integer + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) pass copy node t q := by + rw [physicalRefinementDataRequestQuery_value] + dsimp only + simp_rw [localRequestValue_initial source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial, + localRequestValue_mass source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial, + localRequestValue_refinement source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial] + exact (localPassValue_step source target N P F exponent H Q T factor tau eta kappa delta + group integer _ pass copy node hbelow hshort t ht q).symm + + +theorem physicalGlobalQuery_value (request : PhysicalTableRequest M J target.length) : + (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request).value + (fun child => localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial child.val) = + localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request := by + rcases request with ⟨pass, copy, node, index, q⟩ + by_cases hj : index ≤ T + · change (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.warmup pass copy node index q)).value _ = _ + rw [physicalGlobalQuery_warmup source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass copy node index hj q] + change _ = localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.warmup pass copy node index q) + rw [localRequestValue_warmup source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass copy node index hj q] + apply physicalWarmupRequestQuery_value_local + · intro r + exact globalSeedRead_value source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial _ r + · intro hbelow input + exact localRequestValue_warmup source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass copy (physicalChild node hbelow input.1) + (index - 1) (by omega) input.2 + · obtain ⟨t, hi⟩ : ∃ t, index = T + t := ⟨index - T, by omega⟩ + subst index + have ht : 0 < t := by omega + change (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.refinement pass copy node T t q)).value _ = + localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial (PhysicalTableRequest.refinement pass copy node T t q) + rw [localRequestValue_refinement source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass copy node t q] + by_cases hbelow : node.1.val < J + · by_cases hshort : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · have hterminal : localPassValue source target N P F exponent H Q T factor tau eta kappa delta + group integer (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) pass copy node t q = + stageInitial source target + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) N P F (factor pass) (node, q) := by + unfold localPassValue + rw [physicalLocalRefinement, dite_eq_left hbelow, ite_eq_left hshort] + rw [hterminal] + unfold physicalGlobalQuery + dsimp only + erw [dite_eq_right (show ¬ (PhysicalTableRequest.refinement pass copy node T t q).index ≤ T + from hj), dite_eq_left hbelow, dite_eq_left hshort] + apply physicalInitialQuery_value_local + intro r + exact globalSeedRead_value source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial _ r + · erw [physicalGlobalQuery_refinement_value source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta group integer initial + (PhysicalTableRequest.refinement pass copy node T t q) (by change T < T + t; omega) + hbelow hshort] + refine (physicalRefinementDataRequestQuery_localValue source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta group integer initial pass copy node hbelow hshort + (T + t - T) (by omega) q).trans ?_ + rw [Nat.add_sub_cancel_left] + · have hterminal : localPassValue source target N P F exponent H Q T factor tau eta kappa delta + group integer (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) pass copy node t q = + stageInitial source target + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) N P F (factor pass) (node, q) := by + unfold localPassValue + rw [physicalLocalRefinement, dite_eq_right hbelow] + rw [hterminal] + unfold physicalGlobalQuery + dsimp only + erw [dite_eq_right (show ¬ (PhysicalTableRequest.refinement pass copy node T t q).index ≤ T + from hj), dite_eq_right hbelow] + apply physicalInitialQuery_value_local + intro r + exact globalSeedRead_value source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial _ r + +theorem physicalGlobalProgramValue (request : PhysicalTableRequest M J target.length) : + rankedProgramValue (PhysicalTableRequest.combinedRank T S) + (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial) request = + localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request := + rankedProgramValue_eq _ _ _ + (physicalGlobalQuery_value source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial) request + + +end Value + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGroupAccuracy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGroupAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..85595a8b57652032e92ec7a1e8b5ac39a29d8bd3 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalGroupAccuracy.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.EditApproximation.Refinement.ComputedGroupAccuracy +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementSpatial + +namespace OAI + +/-! Group concentration specialized to the actual stage and complete child histories. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +theorem physical_cellGroupEstimate_failure {α : Type*} [DecidableEq α] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 1764 ≤ inputSmallLog N) + {M J P b Q thetaExponent K : ℕ} [NeZero M] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (hM : 0 < M) (hMeq : M = (integerParameters N).M) + (hPeq : P = (integerParameters N).P) (eb : ℕ) (hbeq : b = 2 ^ eb) + (hQeq : Q = inputSmallLog N ^ 80) (hthetaeq : thetaExponent = 40 * smallLogExponent N) + (U : PhysicalEntry M J target.length → ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P (inputSmallLog N) A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (t : ℕ) (cell : ℕ × ℕ) + (scales : Fin K → ℚ) (count : Fin K → ℕ) + (hscales : List.ofFn scales = groupDyadicScales M b (inputSmallLog N)) + (hcount : ∀ scale, count scale = groupSampleCount M Q b (scales scale)) + (bernstein : ∀ scale : Fin K, FiniteBernsteinInput + (Measure.pi fun _ : Fin (count scale) => (PMF.uniformOfFintype (Fin M)).toMeasure)) : + let F := inputSmallLog N + let initial := fun i s => stageInitial source target U N P F A (physicalChild node hbelow i, s) + let child := fun i s => stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) + let value := fun i s => physicalRefinement source target U N P F A T delta choices + (physicalChild node hbelow i) t s + let members := cellUnskippedBands source target (physicalSourceInterval source.length node) + b P F thetaExponent (rationalParameters F).tau (refinementFactor A F) + (fun s => stageInitial source target U N P F A (node, s)) child initial cell + (groupSharedDrawLaw count).real + {draw | ∃ member ∈ members, ((rationalParameters F).gamma : ℝ) * b < + |((unskippedGroupEstimate scales count value member draw - + rationalEndpointActionValue member.center member.rounded value : ℚ) : ℝ)|} ≤ + 1 / (inputHeight N : ℝ) ^ 4 := by + have hF : 1 ≤ inputSmallLog N := Nat.one_le_two_pow + apply computed_cellGroupEstimate_failure source target N hN hell hM hMeq hPeq eb hbeq hQeq hthetaeq + (physicalSourceInterval source.length node) (refinementFactor A (inputSmallLog N)) + (fun s => stageInitial source target U N P (inputSmallLog N) A (node, s)) + (fun i s => stageWarmupMass source target U N P (inputSmallLog N) A T (physicalChild node hbelow i, s)) + (fun i s => stageInitial source target U N P (inputSmallLog N) A (physicalChild node hbelow i, s)) + (fun i s => physicalRefinement source target U N P (inputSmallLog N) A T delta choices + (physicalChild node hbelow i) t s) cell scales count hscales hcount + · intro i s r + have hf := refinementFactor_spec A (inputSmallLog N) (by omega) + exact physicalInitialTable_spatial source target U N P (inputSmallLog N) A + (refinementFactor A (inputSmallLog N)) hsize hP hF hA hf.1 hf.2 hseed + (physicalChild node hbelow i) s r + · intro i s + have h := physicalRefinement_stage_bounds source target hM U N P (inputSmallLog N) A + hsize hP hF hA hseed T hT delta choices (physicalChild node hbelow i) t s + exact ⟨physicalRefinement_nonneg source target hM U N P (inputSmallLog N) A + hsize hP hF hA hseed T hT delta choices (physicalChild node hbelow i) t s, + h.2.1.trans (h.2.2.1.trans h.2.2.2.1)⟩ + · exact bernstein + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalIndexedCoarseWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalIndexedCoarseWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fa2c3eb27db2062c2d1794e4acbb4a8bddd3779 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalIndexedCoarseWork.lean @@ -0,0 +1,54 @@ +import OAI.Combinatorics.EditApproximation.Coarse.CoarseIndexedEntryCost +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseInputWork +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +section Coarse +variable {M J R B : ℕ} [NeZero M] [NeZero R] [NeZero B] + (source target : List ℕ) (N P H T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P (inputSmallLog N) (40 * smallLogExponent N) H (inputSmallLog N ^ 80) passes copies) + (depth : PhysicalEntry M J target.length → ℕ) + +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) copies T S +local notation "readGroup" => physicalFamilyGroupRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "readInteger" => physicalFamilyOnlineRead (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes copies +local notation "answer" => physicalFamilyAnswer target N P ell exponent H (ell ^ 80) passes copies draw + +/-- Bit arithmetic is executed once for each fresh coarse source request. -/ + + +theorem physicalFamilyIndexedCoarseWork_bound (bits : ℕ) (encode : Sum Key Table → ℕ) + (root : Table) (coarse : PhysicalCoarseDraw source target B depth) (C : ℝ) + (hc : ∀ entry : PhysicalEntry M J target.length, + (coarseIndexedEntryBinaryCost N B (depth entry) (physicalSource source entry.1) + (substring target entry.2.lo entry.2.hi) (coarse entry) : ℝ) ≤ + C * ((coarseInitialArrayWork B (depth entry) (initialThresholdQ N) (initialLambda N) + (physicalSource source entry.1) (substring target entry.2.lo entry.2.hi) (coarse entry) : ℝ) + + ((physicalSource source entry.1).length + 1 : ℕ))) : + physicalFamilyIndexedCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw depth bits encode root coarse ≤ C * + (physicalFamilyMemoCoarseWork source target N P H T S passes copies factor multiplier + tau eta kappa delta draw B depth bits encode root coarse + + physicalFamilyCoarseInputWork source target N P H T S passes copies factor multiplier + tau eta kappa delta + (clampedSeedNat (physicalCoarseSeedTable source target N B depth coarse)) + draw bits encode root) := by + unfold physicalFamilyIndexedCoarseWork physicalFamilyMemoCoarseWork physicalFamilyCoarseInputWork + exact coarseIndexedEntryCostSum_bound source target N depth coarse _ C hc + +end Coarse +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInitial.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInitial.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1297d0d403fed7a6ce78f22e5b3506510d09b78 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInitial.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalWarmup +import OAI.Combinatorics.EditApproximation.Geometry.LocalInitialCones +import OAI.Combinatorics.EditApproximation.Geometry.Leaves +import OAI.Combinatorics.EditApproximation.Probability.Exact +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The actual initial table uses exact empty/singleton leaves and local cones elsewhere. -/ + +namespace EditApproximation + +open EditDistortion + + + +theorem shortSourceCost_eq_edit {α : Type*} [DecidableEq α] (source target : List α) + (hsource : source.length ≤ 1) : shortSourceCost source target = edit source target := by + cases source with + | nil => + exact (edit_nil_left target).symm + | cons a rest => + have hrest : rest = [] := List.length_eq_zero_iff.mp (by + simp only [List.length_cons] at hsource + omega) + subst rest + exact singletonCost_eq_edit a target + +def physicalInitialTable {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A a : ℚ) + (state : PhysicalEntry M J target.length) : ℚ := + let piece := physicalSource source state.1 + if piece.length ≤ 1 then shortSourceCost piece (substring target state.2.lo state.2.hi) + else localInitialConeTable piece target (fun q => U (state.1, q)) N P F A a state.2 + +theorem physicalSource_length_le {α : Type*} {M J : ℕ} (source : List α) + (node : PhysicalNode M J) : (physicalSource source node).length ≤ source.length := by + simp only [physicalSource, substring, List.length_drop, List.length_take] + exact (Nat.sub_le _ _).trans (min_le_right _ _) + +theorem physical_state_cost_le {α : Type*} {M J : ℕ} (source target : List α) + (N : ℕ) (hsize : source.length + target.length ≤ N) + (state : PhysicalEntry M J target.length) : + stateEditCost (physicalSource source state.1) target state.2 ≤ N := by + apply (edit_le_max_length _ _).trans + apply max_le + · exact (physicalSource_length_le source state.1).trans (by omega) + · have hlen : (substring target state.2.lo state.2.hi).length ≤ target.length := by + simp only [substring, List.length_drop, List.length_take] + exact (Nat.sub_le _ _).trans (min_le_right _ _) + exact hlen.trans (by omega) + +theorem physicalInitialTable_bounds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A a : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) (ha : 1 ≤ a) (hfactor : A ≤ a * F) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (state : PhysicalEntry M J target.length) : + max ((stateEditCost (physicalSource source state.1) target state.2 : ℚ) / a) + |rationalStateGap (physicalSource source state.1) target state.2| ≤ + physicalInitialTable source target U N P F A a state ∧ + physicalInitialTable source target U N P F A a state ≤ + 2 * F * stateEditCost (physicalSource source state.1) target state.2 := by + unfold physicalInitialTable + dsimp only + split_ifs with hleaf + · rw [shortSourceCost_eq_edit _ _ hleaf] + change max ((stateEditCost _ _ _ : ℚ) / a) |rationalStateGap _ _ _| ≤ + stateEditCost _ _ _ ∧ (stateEditCost _ _ _ : ℚ) ≤ 2 * F * stateEditCost _ _ _ + have hc : (0 : ℚ) ≤ stateEditCost (physicalSource source state.1) target state.2 := Nat.cast_nonneg _ + have hFQ : (1 : ℚ) ≤ F := by exact_mod_cast hF + have hgap := stateEditCost_length_lower (physicalSource source state.1) target state.2 + rw [← rationalStateGap_cast] at hgap + constructor + · apply max_le + · apply (div_le_iff₀ (by linarith : 0 < a)).2 + nlinarith + · exact_mod_cast hgap + · nlinarith + · rw [localInitialConeTable_eq_global _ _ _ N P F A a hP hF hA ha hfactor + (fun q => physical_state_cost_le source target N hsize (state.1, q)) + (fun q => hseed (state.1, q))] + exact globalInitialConeTable_bounds _ _ _ N P F A a hP hF hA ha hfactor + (fun q => physical_state_cost_le source target N hsize (state.1, q)) + (fun q => hseed (state.1, q)) state.2 + +theorem physicalInitialTable_real_lower {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A a : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) (ha : 1 ≤ a) (hfactor : A ≤ a * F) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) : + physicalLower source target (a : ℝ) ≤ + fun state => (physicalInitialTable source target U N P F A a state : ℝ) := by + intro state + have h := (physicalInitialTable_bounds source target U N P F A a hsize hP hF hA ha hfactor hseed state).1 + have hR : ((max ((stateEditCost (physicalSource source state.1) target state.2 : ℚ) / a) + |rationalStateGap (physicalSource source state.1) target state.2| : ℚ) : ℝ) ≤ + (physicalInitialTable source target U N P F A a state : ℝ) := Rat.cast_le.mpr h + simpa only [Rat.cast_max, Rat.cast_div, Rat.cast_natCast, Rat.cast_abs, + rationalStateGap_cast, physicalLower] using hR + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInputEncoding.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInputEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eb09d230abbc87363a16e692329ce8d98c77cde --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInputEncoding.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.EditApproximation.Geometry.GatheredLocalStep +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Fixed-width binary keys for gathered child states. The encoding uses +mixed radix arithmetic on the child label and the two state endpoints. -/ + +namespace EditApproximation + +theorem mixedRadix_injective {radix lo lo' hi hi' : ℕ} + (hlo : lo < radix) (hlo' : lo' < radix) + (heq : lo + radix * hi = lo' + radix * hi') : lo = lo' ∧ hi = hi' := by + have hmod := congrArg (fun n => n % radix) heq + simp only [Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt hlo, Nat.mod_eq_of_lt hlo'] at hmod + refine ⟨hmod, ?_⟩ + apply Nat.mul_left_cancel (by omega : 0 < radix) + omega + + + +theorem childInputCode_injective (M n : ℕ) : + Function.Injective (@childInputCode M n) := by + rintro ⟨i, q⟩ ⟨i', q'⟩ heq + obtain ⟨hi, hq⟩ := mixedRadix_injective i.isLt i'.isLt heq + have hqlo : q.lo < n + 1 := by have := q.ordered.trans q.valid; omega + have hqlo' : q'.lo < n + 1 := by have := q'.ordered.trans q'.valid; omega + obtain ⟨hlo, hhi⟩ := mixedRadix_injective hqlo hqlo' hq + have hqeq : q = q' := by cases q; cases q'; cases hlo; cases hhi; rfl + exact Prod.ext (Fin.ext hi) hqeq + +theorem childInputCode_bound {M n : ℕ} (input : Fin M × TargetInterval n) : + childInputCode input < M * (n + 1) ^ 2 := by + have hlow := input.2.ordered.trans input.2.valid + have hhigh := input.2.valid + have hlabel := input.1.isLt + have hM : 0 < M := by omega + have hinner : input.2.lo + (n + 1) * input.2.hi < (n + 1) ^ 2 := by + nlinarith only [hlow, hhigh] + unfold childInputCode + nlinarith only [hlabel, Nat.mul_le_mul_left M (Nat.succ_le_of_lt hinner)] + +def childInputBits (M n : ℕ) : ℕ := Nat.clog 2 (M * (n + 1) ^ 2 + 1) + +theorem childInputCode_fits {M n : ℕ} (input : Fin M × TargetInterval n) : + childInputCode input < 2 ^ childInputBits M n := by + exact (childInputCode_bound input).trans_le + ((Nat.le_succ _).trans (Nat.le_pow_clog (by decide : 1 < 2) _)) + +theorem childInputBinaryKey_injective (M n : ℕ) : + Function.Injective (fun input : Fin M × TargetInterval n => + binaryMemoKey (childInputBits M n) (childInputCode input)) := by + intro input other heq + apply childInputCode_injective M n + exact binaryMemoKey_injective _ (childInputCode_fits input) (childInputCode_fits other) heq + +theorem childInputBits_le (M n H : ℕ) (hM : M ≤ 2 ^ H) (hn : n + 1 ≤ 2 ^ H) : + childInputBits M n ≤ 3 * H + 1 := by + apply (Nat.clog_le_iff_le_pow (by decide : 1 < 2)).2 + have hproduct : M * (n + 1) ^ 2 ≤ 2 ^ (3 * H) := by + calc + _ ≤ 2 ^ H * (2 ^ H) ^ 2 := Nat.mul_le_mul hM (Nat.pow_le_pow_left hn 2) + _ = _ := by rw [← pow_mul, ← pow_add]; congr 1; omega + have hone : 1 ≤ 2 ^ (3 * H) := one_le_pow₀ (by decide : 1 ≤ (2 : ℕ)) + calc + _ ≤ 2 ^ (3 * H) + 2 ^ (3 * H) := Nat.add_le_add hproduct hone + _ = 2 ^ (3 * H + 1) := by rw [pow_succ]; omega + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInputGuard.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInputGuard.lean new file mode 100644 index 0000000000000000000000000000000000000000..7945ffdc7c97372021ca3cc2ff8973470ffca54c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalInputGuard.lean @@ -0,0 +1,92 @@ +import OAI.Combinatorics.EditApproximation.Geometry.ParameterNumericalConstruction +import OAI.Combinatorics.EditApproximation.Binary.BinaryAffineGuard +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalUniformAccuracy +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +/-- Prefix rejection precedes arithmetic involving the accuracy word. -/ + + + theorem physicalLargeInputWithWork_value (N : ℕ) (epsilon : BinaryFraction) : + (physicalLargeInputWithWork N epsilon).1 = decide (physicalLargeInput N epsilon) := by + apply Bool.eq_iff_iff.mpr + by_cases hi : (inspectAccuracyWithWork (inputHeight N) epsilon).1.isSome = true + · have hc : (binaryNaturalCompareWithWork (inputSmallLog N) (2 ^ 1000)).1 ≠ .lt ↔ + 2 ^ 1000 ≤ inputSmallLog N := by + rw [ne_eq, binaryNaturalCompareWithWork_lt, not_lt] + have ha : (BinaryFraction.ltWithWork + (BinaryFraction.canonicalMulWithWork (BinaryFraction.nat (inputSmallLog N)) epsilon).1 + (BinaryFraction.nat 10)).1 ≠ true ↔ 10 ≤ (inputSmallLog N : ℚ) * epsilon.value := by + rw [ne_eq, BinaryFraction.ltWithWork_value, BinaryFraction.canonicalMulWithWork_value, + BinaryFraction.nat_value, BinaryFraction.nat_value, not_lt] + norm_num + have hm : (binaryNaturalCompareWithWork (inputHeight N) + (inputBitLengthWithWork + (onlineMassWithWork (integerParameters N).M (integerParameters N).P (inputHeight N)).1).1).1 ≠ .lt ↔ + Nat.size (localOnlineMassBound (integerParameters N).M (integerParameters N).P + (inputHeight N)) ≤ inputHeight N := by + rw [ne_eq, binaryNaturalCompareWithWork_lt, inputBitLengthWithWork_spec, + onlineMassWithWork_value, not_lt] + simp only [physicalLargeInputWithWork, hi, ite_true, decide_eq_true_eq, + physicalLargeInput, largeAccuracyInput, hc, ha, hm, true_and, and_assoc] + · simp only [physicalLargeInputWithWork, hi, ite_false, Bool.false_eq_true, decide_eq_true_eq, + physicalLargeInput, false_and] + + theorem physicalLargeInputWithWork_cost (N : ℕ) (epsilon : BinaryFraction) + (hmass : Nat.size (localOnlineMassBound (integerParameters N).M (integerParameters N).P + (inputHeight N)) ≤ inputHeight N) : + (physicalLargeInputWithWork N epsilon).2 ≤ 100000 * (inputHeight N + 1005) ^ 2 := by + let B := (inputHeight N) + 1005 + have hi := inspectAccuracyWithWork_cost (inputHeight N) epsilon + by_cases haccepted : (inspectAccuracyWithWork (inputHeight N) epsilon).1.isSome = true + · have hepsilon : epsilon.width ≤ (inputHeight N) := by + rw [inspectAccuracyWithWork_spec] at haccepted + split_ifs at haccepted with he + · exact he + · cases haccepted + have hell : Nat.size (inputSmallLog N) + 2 ≤ B := by + have hs := Nat.size_le_size (computed_smallLog_le_height N) + have hh : Nat.size (inputHeight N) ≤ (inputHeight N) + 1 := by + apply Nat.size_le.mpr + exact Nat.lt_two_pow_self.trans_le (Nat.pow_le_pow_right (by decide) (Nat.le_succ (inputHeight N))) + dsimp only [B] + omega + have hleft : (BinaryFraction.nat (inputSmallLog N)).width ≤ B := + (BinaryFraction.nat_width_le _).trans hell + have hright : epsilon.width ≤ B := hepsilon.trans (by dsimp [B]; omega) + have hten : (BinaryFraction.nat 10).width ≤ 4 * B + 2 := by + have ht := BinaryFraction.nat_width_le 10 + rw [show Nat.size 10 = 4 from by decide] at ht + dsimp only [B] + omega + have hp := BinaryFraction.canonicalMulWithWork_cost + (BinaryFraction.nat (inputSmallLog N)) epsilon B hleft hright + have hpw := BinaryFraction.canonicalMulWithWork_width + (BinaryFraction.nat (inputSmallLog N)) epsilon B hleft hright + have ha := BinaryFraction.ltWithWork_cost + (BinaryFraction.canonicalMulWithWork (BinaryFraction.nat (inputSmallLog N)) epsilon).1 + (BinaryFraction.nat 10) (4 * B + 2) hpw hten + have ht := binaryNaturalCompareWithWork_cost (inputSmallLog N) (2 ^ 1000) + have hc := binaryNaturalCompareWithWork_cost (inputHeight N) + (Nat.size (localOnlineMassBound (integerParameters N).M (integerParameters N).P (inputHeight N))) + have hHsize : Nat.size (inputHeight N) ≤ (inputHeight N) + 1 := by + apply Nat.size_le.mpr + exact Nat.lt_two_pow_self.trans_le (Nat.pow_le_pow_right (by decide) (Nat.le_succ (inputHeight N))) + have hmsize : Nat.size (Nat.size (localOnlineMassBound (integerParameters N).M + (integerParameters N).P (inputHeight N))) ≤ (inputHeight N) + 1 := (Nat.size_le_size hmass).trans hHsize + simp only [Nat.size_pow] at ht + simp only [physicalLargeInputWithWork, haccepted, ite_true, inputBitLengthWithWork_spec, + onlineMassWithWork_value, onlineMassWithWork_cost] + change _ ≤ 100000 * B ^ 2 + dsimp only [B] at hp ha hell ⊢ + nlinarith only [hp, ha, ht, hi, hc, hHsize, hmsize, hmass, hell] + · simp only [physicalLargeInputWithWork, haccepted, Bool.false_eq_true, ite_false] + nlinarith only [hi, Nat.zero_le (inputHeight N)] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLeaves.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLeaves.lean new file mode 100644 index 0000000000000000000000000000000000000000..9de73e0b230c48b220bf624483b507c016bc9e3a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLeaves.lean @@ -0,0 +1,80 @@ +import OAI.Combinatorics.EditApproximation.Refinement.StageWarmup + +namespace OAI + +/-! Exact source leaves remain exact throughout the actual physical warmup. -/ + +namespace EditApproximation + +open Finset + +theorem physicalSource_length_eq {α : Type*} {M J : ℕ} (source : List α) + (node : PhysicalNode M J) : (physicalSource source node).length = + (physicalSourceInterval source.length node).hi - (physicalSourceInterval source.length node).lo := by + simp only [physicalSource, substring, List.length_drop, List.length_take, + Nat.min_eq_left (physicalSourceInterval source.length node).valid] + +theorem physicalBellman_at_leaf {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (value : PhysicalEntry M J target.length → ℝ) (node : PhysicalNode M J) + (hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (q : TargetInterval target.length) : + physicalBellman source target P L initial representatives value (node, q) = initial (node, q) := by + classical + unfold physicalBellman + dsimp only + split_ifs <;> rfl + +theorem physicalWarmup_at_leaf {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (t : ℕ) (node : PhysicalNode M J) + (hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (q : TargetInterval target.length) : + physicalWarmup source target P L initial representatives t (node, q) = initial (node, q) := by + cases t with + | zero => rfl + | succ t => exact physicalBellman_at_leaf source target P L initial representatives _ node hleaf q + +theorem rationalPhysicalWarmup_at_leaf {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (t : ℕ) (node : PhysicalNode M J) + (hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (q : TargetInterval target.length) : + rationalPhysicalWarmup source target P L initial representatives t (node, q) = initial (node, q) := by + apply (Rat.cast_inj (α := ℝ)).mp + rw [rationalPhysicalWarmup_cast] + exact physicalWarmup_at_leaf source target P (L : ℝ) (fun s => (initial s : ℝ)) representatives t node hleaf q + +theorem stageWarmup_at_leaf {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (t : ℕ) (node : PhysicalNode M J) + (hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (q : TargetInterval target.length) : + stageWarmup source target U N P F A t (node, q) = + stateEditCost (physicalSource source node) target q := by + unfold stageWarmup + rw [rationalPhysicalWarmup_at_leaf source target P (128 * F) _ _ t node hleaf q] + have hlength : (physicalSource source node).length ≤ 1 := (physicalSource_length_eq source node).trans_le hleaf + simp only [stageInitial, physicalInitialTable, ite_eq_left hlength] + rw [shortSourceCost_eq_edit _ _ hlength] + rfl + +theorem stageWarmupMass_at_leaf {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) + (hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (q : TargetInterval target.length) : + stageWarmupMass source target U N P F A T (node, q) = + stateEditCost (physicalSource source node) target q := by + change (∑ t ∈ range T, stageWarmup source target U N P F A t (node, q)) / T = _ + simp_rw [stageWarmup_at_leaf source target U N P F A _ node hleaf q] + simp only [sum_const, card_range, nsmul_eq_mul] + have hTr : (T : ℚ) ≠ 0 := by exact_mod_cast hT.ne' + exact mul_div_cancel_left₀ _ hTr + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalDenominator.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalDenominator.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0fd149b8e131d7c1e70958f3d420070ecc50587 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalDenominator.lean @@ -0,0 +1,241 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalValueBits +import OAI.Combinatorics.EditApproximation.Geometry.LocalOnlineProgram + +namespace OAI + +/-! Denominator and bit bounds for the local evaluator on every incoming +seed. The proofs use the literal local candidates and do not pass through +the good-seed equality with the complete evaluator. -/ + +namespace EditApproximation + +open Finset + +theorem physicalLocalWarmup_den_one {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (t : ℕ) (state : PhysicalEntry M J target.length) : + (physicalLocalWarmup source target U N P F A t state).den = 1 := by + induction t generalizing state with + | zero => exact stageInitial_den_one source target U N P F A state + | succ t ih => + rw [physicalLocalWarmup] + split_ifs + · exact stageInitial_den_one source target U N P F A state + · apply Nat.eq_one_of_dvd_one + apply rationalMinimum_den_dvd + · rw [stageInitial_den_one source target U N P F A] + · intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + exact rationalActionValue_den_dvd _ _ _ _ _ (Rat.den_natCast _) + (by simpa only [Nat.cast_mul, Nat.cast_ofNat] using Rat.den_natCast (128 * F)) + (rationalActualWideActions_connection_den _ _ _ action ha) + (fun i => by rw [ih]) + · exact stageInitial_den_one source target U N P F A state + +theorem rationalLocalWideStep_den_dvd {α : Type*} (source target : List α) {M D : ℕ} + (parent : TargetInterval source.length) (N P F exponent Q m : ℕ) (hm : 0 < m) + (tau a : ℚ) (parentInitial : TargetInterval target.length → ℚ) + (childMass childInitial old current : Fin M → TargetInterval target.length → ℚ) + (draw : CellGroupDraws M F Q) (online : List (PhysicalRationalAction M target.length)) + (hinitial : ∀ q, (parentInitial q).den ∣ D) + (hold : ∀ i r, (old i r).den ∣ D) (hcurrent : ∀ i r, (current i r).den ∣ D) + (honline : ∀ action ∈ online, action.connection.den = 1) + (q : TargetInterval target.length) : + (rationalLocalWideStep source target parent N P F exponent Q tau a (1 / (m : ℚ)) + parentInitial childMass childInitial old current draw online q).den ∣ D * (m + 1) := by + have hvalue (child : Fin M → TargetInterval target.length → ℚ) + (hchild : ∀ i r, (child i r).den ∣ D) + (action : PhysicalRationalAction M target.length) (hconn : action.connection.den = 1) : + (rationalActionValue (fun q r => targetEndpointDistance q r) (128 * F) + (fun is => child is.1 is.2) q action).den ∣ D := + rationalActionValue_den_dvd _ _ _ _ _ (Rat.den_natCast _) + (by simpa only [Nat.cast_mul, Nat.cast_ofNat] using Rat.den_natCast (128 * F)) + hconn (fun i => hchild _ _) + unfold rationalLocalWideStep + apply rationalRefinementUpdate_den_dvd m D hm + · apply rationalMinimum_den_dvd + · apply rationalMinimum_den_dvd _ _ D (hinitial q) + intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + exact hvalue old hold action (rationalActualWideActions_connection_den _ _ _ action ha) + · intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + have hwide := completeCellGroupActions_wide source target parent N P F exponent Q tau a + parentInitial childMass childInitial current draw action + (localCellGroupActions_subset source target parent N P F exponent Q tau a parentInitial + childMass childInitial current draw q action ha) + exact hvalue current hcurrent action (rationalActualWideActions_connection_den _ _ _ action hwide) + · intro v hv + apply rationalOnlineMinimum_den_dvd _ D _ v hv + intro value hvalueMem + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hvalueMem + exact hvalue current hcurrent action (honline action ha) + +theorem keyedOnlineCandidate_connection_den {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (P F exponent H b : ℕ) (tau eta kappa : ℚ) + (child initial : Fin M → TargetInterval target.length → ℚ) + (children : PhysicalChildTables M target.length) (t : ℕ) + (r : TargetInterval target.length) (integer : ℕ) (action : PhysicalRationalAction M target.length) + (h : keyedOnlineCandidate source target parent P F exponent H b tau eta kappa + child initial children t r integer = some action) : action.connection.den = 1 := by + unfold keyedOnlineCandidate at h + dsimp only at h + split_ifs at h + split at h + · cases h + · cases Option.some.inj h + exact Rat.den_zero + +theorem localOnlineCandidates_connection_den {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (N P F exponent H : ℕ) (tau a eta kappa : ℚ) + (parentInitial : TargetInterval target.length → ℚ) + (child initial : Fin M → TargetInterval target.length → ℚ) + (children : PhysicalChildTables M target.length) (t : ℕ) + (integer : ℕ → TargetInterval target.length → ℕ) (q : TargetInterval target.length) + (action : PhysicalRationalAction M target.length) + (ha : action ∈ localOnlineCandidates source target parent N P F exponent H tau a eta kappa + parentInitial child initial children t integer q) : action.connection.den = 1 := by + obtain ⟨b, _, _, hcandidate⟩ := + (localOnlineCandidates_mem source target parent N P F exponent H tau a eta kappa + parentInitial child initial children t integer q action).mp ha + exact keyedOnlineCandidate_connection_den source target parent P F exponent H b tau eta kappa + child initial children t _ _ action hcandidate + +theorem physicalLocalOnline_connection_den {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent H T : ℕ) (A tau eta kappa : ℚ) + (integer : PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (node : PhysicalNode M J) (children : PhysicalChildTables M target.length) + (t : ℕ) (q : TargetInterval target.length) (action : PhysicalRationalAction M target.length) + (ha : action ∈ physicalLocalOnline source target U N P F exponent H T A tau eta kappa + integer node children t q) : action.connection.den = 1 := by + unfold physicalLocalOnline at ha + split_ifs at ha with hbelow + · exact localOnlineCandidates_connection_den source target (physicalSourceInterval source.length node) + N P F exponent H tau (refinementFactor A F) eta kappa _ _ _ children (t - 1) _ q action ha + · exact False.elim (List.not_mem_nil ha) + +theorem physicalLocalRefinement_den_dvd {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A tau : ℚ) (T ell : ℕ) (hell : 0 < ell) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (online : PhysicalNode M J → PhysicalChildTables M target.length → ℕ → + TargetInterval target.length → List (PhysicalRationalAction M target.length)) + (honline : ∀ node children t q action, action ∈ online node children t q → action.connection.den = 1) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + (physicalLocalRefinement source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T draw online node t q).den ∣ (ell ^ 10 + 1) ^ (J - node.1.val) := by + rw [physicalLocalRefinement] + split_ifs with hbelow hleaf + · rw [stageInitial_den_one source target U N P F A] + exact one_dvd _ + · dsimp only + cases t with + | zero => + rw [physicalLocalWarmup_den_one source target U N P F A] + exact one_dvd _ + | succ t => + have hheight : J - node.1.val = (J - (node.1.val + 1)) + 1 := by omega + rw [hheight] + conv_rhs => rw [pow_succ] + have hdelta : (1 / (ell : ℚ) ^ 10) = 1 / ((ell ^ 10 : ℕ) : ℚ) := by rw [Nat.cast_pow] + rw [hdelta] + apply rationalLocalWideStep_den_dvd source target _ N P F exponent Q (ell ^ 10) + (pow_pos hell 10) tau (refinementFactor A F) + · intro r + rw [stageInitial_den_one source target U N P F A] + exact one_dvd _ + · intro i r + simpa only [Nat.cast_pow, physicalChild] using + physicalLocalRefinement_den_dvd source target U N P F exponent Q A tau T ell hell + draw online honline (physicalChild node hbelow i) t r + · intro i r + simpa only [Nat.cast_pow, physicalChild] using + physicalLocalRefinement_den_dvd source target U N P F exponent Q A tau T ell hell + draw online honline (physicalChild node hbelow i) (t + 1) r + · exact honline _ _ _ _ + · rw [stageInitial_den_one source target U N P F A] + exact one_dvd _ +termination_by J - node.1.val +decreasing_by + all_goals + unfold physicalChild + dsimp only + omega + +theorem physicalLocalRefinement_encoding_bits {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A tau : ℚ) (hsize : source.length + target.length ≤ N) + (T ell : ℕ) (hell : 0 < ell) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (online : PhysicalNode M J → PhysicalChildTables M target.length → ℕ → + TargetInterval target.length → List (PhysicalRationalAction M target.length)) + (honline : ∀ node children t q action, action ∈ online node children t q → action.connection.den = 1) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + rationalEncodingBits (physicalLocalRefinement source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T draw online node t q) ≤ + Nat.size ((32 * F + 1) * N) + 2 * (J - node.1.val) * Nat.size (ell ^ 10 + 1) + 3 := by + let value := physicalLocalRefinement source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T draw online node t q + have hbounds := physicalLocalRefinement_bounds source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T (by positivity) draw online node t q + have hupper : value ≤ (((32 * F + 1) * N : ℕ) : ℚ) := by + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using + hbounds.2.trans (stageInitial_upper_all_seeds source target U N P F A hsize (node, q)) + have h := rationalEncodingBits_of_den_dvd value ((32 * F + 1) * N) + ((ell ^ 10 + 1) ^ (J - node.1.val)) (by rw [abs_of_nonneg hbounds.1]; exact hupper) + (pow_pos (by omega) _) (physicalLocalRefinement_den_dvd source target U N P F exponent Q + A tau T ell hell draw online honline node t q) + have hpower := natural_power_bit_length (ell ^ 10 + 1) (J - node.1.val) + have hpowerTwice := Nat.mul_le_mul_left 2 hpower + simp only [Nat.mul_add, Nat.mul_one, ← Nat.mul_assoc] at hpowerTwice + change rationalEncodingBits value ≤ _ + omega + +theorem physicalLocalOnlineRefinement_den_dvd {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent H Q : ℕ) (A tau eta kappa : ℚ) (T ell : ℕ) (hell : 0 < ell) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (integer : PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + (physicalLocalRefinement source target U N P F exponent Q A tau (1 / (ell : ℚ) ^ 10) + T draw (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + node t q).den ∣ (ell ^ 10 + 1) ^ (J - node.1.val) := + physicalLocalRefinement_den_dvd source target U N P F exponent Q A tau T ell hell draw _ + (physicalLocalOnline_connection_den source target U N P F exponent H T A tau eta kappa integer) node t q + +theorem physicalLocalWarmup_encoding_bits {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (t : ℕ) (state : PhysicalEntry M J target.length) : + rationalEncodingBits (physicalLocalWarmup source target U N P F A t state) ≤ + Nat.size ((32 * F + 1) * N) + 3 := by + let value := physicalLocalWarmup source target U N P F A t state + have hbounds := physicalLocalWarmup_bounds source target U N P F A t state + have hupper : value ≤ (((32 * F + 1) * N : ℕ) : ℚ) := by + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using + hbounds.2.trans (stageInitial_upper_all_seeds source target U N P F A hsize state) + have hden : value.den ∣ 1 := by + rw [physicalLocalWarmup_den_one source target U N P F A] + have h := rationalEncodingBits_of_den_dvd value ((32 * F + 1) * N) 1 + (by rw [abs_of_nonneg hbounds.1]; exact hupper) (by decide) hden + simpa only [Nat.size_one, Nat.mul_one, Nat.add_assoc] using h + +theorem physicalLocalOnlineRefinement_encoding_bits {α : Type*} [DecidableEq α] + {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent H Q : ℕ) (A tau eta kappa : ℚ) + (hsize : source.length + target.length ≤ N) (T ell : ℕ) (hell : 0 < ell) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (integer : PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + rationalEncodingBits (physicalLocalRefinement source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) node t q) ≤ + Nat.size ((32 * F + 1) * N) + 2 * (J - node.1.val) * Nat.size (ell ^ 10 + 1) + 3 := + physicalLocalRefinement_encoding_bits source target U N P F exponent Q A tau hsize T ell hell draw _ + (physicalLocalOnline_connection_den source target U N P F exponent H T A tau eta kappa integer) node t q + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalGroupKeys.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalGroupKeys.lean new file mode 100644 index 0000000000000000000000000000000000000000..74aa28cbf196af574323835c1ebfdc1bf94fbeec --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalGroupKeys.lean @@ -0,0 +1,136 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalOnlineKeys +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Every whole-cell stream used by the complete program has a bounded +physical key. Its two cell coordinates are at most n*2^exponent. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +theorem list_eraseDups_nodup {α : Type*} [BEq α] [LawfulBEq α] (items : List α) : + items.eraseDups.Nodup := by + cases items with + | nil => simp + | cons first rest => + rw [List.eraseDups_cons, List.nodup_cons] + refine ⟨?_, list_eraseDups_nodup _⟩ + intro hmem + have hfalse := (List.mem_filter.mp (List.mem_eraseDups.mp hmem)).2 + simp at hfalse +termination_by items.length +decreasing_by + simpa only [List.length_cons] using + Nat.lt_succ_of_le (List.length_filter_le (fun item => !(item == first)) rest) + +theorem targetCell_coordinate_bound {n : ℕ} (exponent b : ℕ) (hb : 1 ≤ b) + (q : TargetInterval n) : + (targetCell ((2 : ℚ) ^ (-(exponent : ℤ)) * b) q).1 ≤ n * 2 ^ exponent ∧ + (targetCell ((2 : ℚ) ^ (-(exponent : ℤ)) * b) q).2 ≤ n * 2 ^ exponent := by + have hside : (0 : ℚ) < (2 : ℚ) ^ (-(exponent : ℤ)) * b := by positivity + have hcoordinate (p : ℕ) (hp : p ≤ n) : + ⌊(p : ℚ) / ((2 : ℚ) ^ (-(exponent : ℤ)) * b)⌋₊ ≤ n * 2 ^ exponent := by + have hcancel : ((n * 2 ^ exponent : ℕ) : ℚ) * + ((2 : ℚ) ^ (-(exponent : ℤ)) * b) = n * b := by + push_cast + rw [zpow_neg, zpow_natCast] + field_simp + have hmul : (p : ℚ) ≤ ((n * 2 ^ exponent : ℕ) : ℚ) * + ((2 : ℚ) ^ (-(exponent : ℤ)) * b) := by + rw [hcancel] + exact_mod_cast hp.trans (Nat.le_mul_of_pos_right n (by omega)) + have h := Nat.floor_le_floor ((div_le_iff₀ hside).2 hmul) + simpa only [Nat.floor_natCast] using h + exact ⟨hcoordinate q.lo (q.ordered.trans q.valid), hcoordinate q.hi q.valid⟩ + + + +section Keys + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent : ℕ) (A : ℚ) + +theorem physicalProgramCells_bounds (node : PhysicalNode M J) + (b : ℕ) (hb : 1 ≤ b) (cell : ℕ × ℕ) + (hcell : cell ∈ physicalProgramCells source target U N P F A exponent node b) : + cell.1 ≤ target.length * 2 ^ exponent ∧ cell.2 ≤ target.length * 2 ^ exponent := by + obtain ⟨br, _, rfl⟩ := List.mem_map.mp (List.mem_eraseDups.mp hcell) + exact targetCell_coordinate_bound exponent b hb br.2 + +theorem physicalGroupScale_positive + (key : PhysicalGroupKey source target U N P F A exponent) : + 1 ≤ (dyadicScales N).get key.2.1 := by + have hm := List.get_mem (dyadicScales N) key.2.1 + obtain ⟨e, _, heq⟩ := List.mem_map.mp hm + exact heq ▸ Nat.one_le_two_pow + +def physicalGroupRawKey (key : PhysicalGroupKey source target U N P F A exponent) : + PhysicalLocalGroupKey M J N target.length exponent := + let cell := (physicalProgramCells source target U N P F A exponent key.1.1 + ((dyadicScales N).get key.2.1)).get key.2.2 + let bounds := physicalProgramCells_bounds source target U N P F exponent A key.1.1 + ((dyadicScales N).get key.2.1) (physicalGroupScale_positive source target U N P F exponent A key) + cell (List.get_mem _ key.2.2) + (key.1, key.2.1, ⟨cell.1, Nat.lt_succ_of_le bounds.1⟩, ⟨cell.2, Nat.lt_succ_of_le bounds.2⟩) + +theorem physicalGroupRawKey_injective : + Function.Injective (physicalGroupRawKey source target U N P F exponent A) := by + rintro ⟨node, scale, cell⟩ ⟨node', scale', cell'⟩ heq + have hn := congrArg Prod.fst heq + change node = node' at hn + subst node' + have hs := congrArg (fun key : PhysicalLocalGroupKey M J N target.length exponent => key.2.1) heq + change scale = scale' at hs + subst scale' + have hlo := congrArg (fun key : PhysicalLocalGroupKey M J N target.length exponent => key.2.2.1.val) heq + have hhi := congrArg (fun key : PhysicalLocalGroupKey M J N target.length exponent => key.2.2.2.val) heq + simp only [physicalGroupRawKey] at hlo hhi + have hnodup : (physicalProgramCells source target U N P F A exponent node.1 + ((dyadicScales N).get scale)).Nodup := list_eraseDups_nodup _ + have hcell := hnodup.injective_get (Prod.ext hlo hhi) + cases hcell + rfl + +end Keys + +abbrev PhysicalLocalGroupArray (M J N n exponent F Q R : ℕ) + (key : PhysicalLocalGroupKey M J N n exponent) := + Fin R → ParentGroupDraw M (groupDyadicScales M ((dyadicScales N).get key.2.1) F).length + (fun h => groupSampleCount M Q ((dyadicScales N).get key.2.1) + (groupDyadicScaleAt M ((dyadicScales N).get key.2.1) F h)) + +noncomputable def physicalLocalGroupArrayLaw (M J N n exponent F Q R : ℕ) + [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (key : PhysicalLocalGroupKey M J N n exponent) : + Measure (PhysicalLocalGroupArray M J N n exponent F Q R key) := + Measure.pi fun _ : Fin R => groupSharedDrawLaw (M := M) + (fun h => groupSampleCount M Q ((dyadicScales N).get key.2.1) + (groupDyadicScaleAt M ((dyadicScales N).get key.2.1) F h)) + +instance physicalLocalGroupArrayLaw_probability (M J N n exponent F Q R : ℕ) + [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (key : PhysicalLocalGroupKey M J N n exponent) : + IsProbabilityMeasure (physicalLocalGroupArrayLaw M J N n exponent F Q R key) := by + unfold physicalLocalGroupArrayLaw + infer_instance + +theorem physicalLocalGroupDrawLaw_restrict {α : Type*} [DecidableEq α] {M J : ℕ} + [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q R : ℕ) (A : ℚ) : + (Measure.pi (physicalLocalGroupArrayLaw M J N target.length exponent F Q R)).map + (fun draw (key : PhysicalGroupKey source target U N P F A exponent) => + draw (physicalGroupRawKey source target U N P F exponent A key)) = + Measure.pi (fun key : PhysicalGroupKey source target U N P F A exponent => + Measure.pi (fun _ : Fin R => groupSharedDrawLaw (M := M) + (fun h => groupSampleCount M Q ((dyadicScales N).get key.2.1) + (groupDyadicScaleAt M ((dyadicScales N).get key.2.1) F h)))) := + finite_pi_restrict_map _ _ (physicalGroupRawKey_injective source target U N P F exponent A) + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalGroupProgram.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalGroupProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ee5ce204cd1871a47f6e72c8b548dbc6c9f6029 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalGroupProgram.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.EditApproximation.Geometry.LocalGroupCones +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSelectionProgram + +namespace OAI + +/-! The finite indexed group program has an equivalent cell-keyed +realization. Good initial seeds permit its whole cone to be evaluated +using only the directly enumerated query cells. -/ + +namespace EditApproximation + +section Program + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A : ℚ) + +def physicalGroupStreamsOfKeys {R : ℕ} + (draw : PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) : + PhysicalGroupStreams source target U N P F A exponent Q R := + fun node scale cell time => draw node time ((dyadicScales N).get scale) + ((physicalProgramCells source target U N P F A exponent node.1 + ((dyadicScales N).get scale)).get cell) + +theorem physicalProgramCells_keyed (node : PhysicalNode M J) (b : ℕ) : + physicalProgramCells source target U N P F A exponent node b = + representativeCells N P F b (refinementFactor A F) ((2 : ℚ) ^ (-(exponent : ℤ))) + (fun q => stageInitial source target U N P F A (node, q)) := rfl + +theorem physicalProgramGroups_keyed (T : ℕ) (tau : ℚ) {R : ℕ} [NeZero R] + (draw : PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (children : PhysicalChildTables M target.length) (t : ℕ) : + physicalProgramGroups source target U N P F A T exponent Q tau + (physicalGroupStreamsOfKeys source target U N P F exponent Q A draw) node children t = + completeCellGroupActions source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor A F) + (fun q => stageInitial source target U N P F A (node, q)) + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (fun i q => children i t q) (draw ⟨node, hbelow⟩ (Fin.ofNat R (t - 1))) := by + unfold physicalProgramGroups + rw [dite_eq_left hbelow] + unfold completeCellGroupActions + conv_rhs => rw [← List.map_get_finRange (dyadicScales N)] + rw [List.flatMap_map] + apply List.flatMap_congr + intro scale _ + rw [← physicalProgramCells_keyed source target U N P F exponent A node] + conv_rhs => rw [← List.map_get_finRange (physicalProgramCells source target U N P F A exponent node + ((dyadicScales N).get scale))] + simp only [List.filterMap_map, Function.comp_def, physicalGroupStreamsOfKeys] + +/-- Actual chosen-group cone at one node, evaluated by bounded query +cell loops. The old-child fallback is arbitrary provided it is at most +the literal initial value. -/ +theorem physicalProgramGroups_local_minimum (T : ℕ) (tau : ℚ) {R : ℕ} [NeZero R] + (draw : PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (children : PhysicalChildTables M target.length) (t : ℕ) + (q : TargetInterval target.length) (fallback : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (hfallback : fallback ≤ stageInitial source target U N P F A (node, q)) + (hchild : ∀ i r, 0 ≤ children i t r) : + rationalMinimum fallback + ((localCellGroupActions source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor A F) + (fun r => stageInitial source target U N P F A (node, r)) + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (fun i r => children i t r) (draw ⟨node, hbelow⟩ (Fin.ofNat R (t - 1))) q).map + (rationalActionValue (fun q r => targetEndpointDistance q r) (128 * F) + (fun is => children is.1 t is.2) q)) = + rationalMinimum fallback + ((physicalProgramGroups source target U N P F A T exponent Q tau + (physicalGroupStreamsOfKeys source target U N P F exponent Q A draw) node children t).map + (rationalActionValue (fun q r => targetEndpointDistance q r) (128 * F) + (fun is => children is.1 t is.2) q)) := by + rw [physicalProgramGroups_keyed source target U N P F exponent Q A T tau draw node hbelow children t] + have hfactor := refinementFactor_spec A F (by omega : 0 < F) + have hspatial : ∀ r, |stageInitial source target U N P F A (node, q) - + stageInitial source target U N P F A (node, r)| ≤ 32 * F * targetEndpointDistance q r := by + intro r + have hqr := physicalInitialTable_spatial source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed node q r + have hrq := physicalInitialTable_spatial source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed node r q + have hsym : targetEndpointDistance r q = targetEndpointDistance q r := by + exact congrArg₂ (· + ·) (Nat.dist_comm _ _) (Nat.dist_comm _ _) + rw [hsym] at hrq + apply abs_le.mpr + constructor <;> dsimp only [stageInitial] <;> linarith only [hqr, hrq] + exact localCellGroupMinimum_eq source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor A F) + (fun r => stageInitial source target U N P F A (node, r)) + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (fun i r => children i t r) (draw ⟨node, hbelow⟩ (Fin.ofNat R (t - 1))) q fallback + hfactor.1 hF hfallback hchild hspatial + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalJointProgram.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalJointProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..48b3fc6270dcca436c58ecb279e204a5f7a0331a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalJointProgram.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalProgramLaw +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRawOnlineProgram +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRawGroupProgram + +namespace OAI + +/-! Direct evaluation from the bounded joint random source agrees with +complete refinement. All complete-table indexing occurs in the proof. -/ + +namespace EditApproximation + +section Joint + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T exponent H Q : ℕ) (tau eta kappa delta : ℚ) + (draw : PhysicalLocalProgramDraw (R := R) source target U N P F A T exponent H Q tau) + +def physicalLocalJointValue (node : PhysicalNode M J) (t : ℕ) + (q : TargetInterval target.length) : ℚ := + physicalLocalRefinement source target U N P F exponent Q A tau delta T + (fun label s => physicalRawGroupDraws M J N target.length exponent F Q R + (fun key => draw (.inr key)) label (Fin.ofNat R (s - 1))) + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa + (physicalRawOnlineIntegers source target U N P F A T exponent H tau + (fun key => draw (.inl key)))) node t q + +variable (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + +theorem physicalLocalJointValue_eq (node : PhysicalNode M J) (t : ℕ) + (q : TargetInterval target.length) : + physicalLocalJointValue source target U N P F A T exponent H Q tau eta kappa delta draw node t q = + physicalRefinement source target U N P F A T delta + (physicalProgramDrawSelections source target U N P F A T exponent H Q tau eta kappa + (physicalLocalProgramToComplete source target U N P F A T exponent H Q tau + hsize hP hF hA hseed draw)) node t q := by + unfold physicalLocalJointValue + rw [physicalRawOnlineProgram_eq source target U N P F A T exponent H tau eta kappa + (fun key => draw (.inl key)) hsize hP hF hA hseed] + rw [physicalGroupStreamsOfRaw] + rfl + +end Joint + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalOnlineEquality.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalOnlineEquality.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f7512565e954ff37632e14035b985f3813bf731 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalOnlineEquality.lean @@ -0,0 +1,109 @@ +import OAI.Combinatorics.EditApproximation.Geometry.LocalOnlineProgram + +namespace OAI + +/-! A proof adapter couples the bounded online query loop to the original +finite product slots. The adapter is used only to compare laws: local +execution uses scale/center keys and never searches a complete table. -/ + +namespace EditApproximation + +section Program + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent H T : ℕ) (A tau eta kappa : ℚ) + (online : PhysicalOnlineStreams source target U N P F A T exponent H tau R) + +local notation "representatives" => stageRepresentatives source target U N P F A + +noncomputable def physicalRepresentativeFin (node : PhysicalNode M J) + (br : ℕ × TargetInterval target.length) (hbr : br ∈ representatives node) : + Fin (representatives node).length := Classical.choose (List.mem_iff_get.mp hbr) + +theorem physicalRepresentativeFin_get (node : PhysicalNode M J) + (br : ℕ × TargetInterval target.length) (hbr : br ∈ representatives node) : + (representatives node).get (physicalRepresentativeFin source target U N P F A node br hbr) = br := + Classical.choose_spec (List.mem_iff_get.mp hbr) + +noncomputable def physicalOnlineIntegersOfStreams + (node : PhysicalInternalNode M J) (time : Fin R) (b : ℕ) (r : TargetInterval target.length) : ℕ := + if hbr : (b, r) ∈ representatives node.1 then + (online node (physicalRepresentativeFin source target U N P F A node.1 (b, r) hbr) time).val + else 0 + +omit [NeZero R] in +theorem physicalOnlineIntegersOfStreams_get (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) (time : Fin R) : + physicalOnlineIntegersOfStreams source target U N P F exponent H T A tau online node time + ((representatives node.1).get representative).1 ((representatives node.1).get representative).2 = + (online node representative time).val := by + unfold physicalOnlineIntegersOfStreams + rw [dite_eq_left (List.get_mem _ _)] + have heq : physicalRepresentativeFin source target U N P F A node.1 + ((representatives node.1).get representative) (List.get_mem _ _) = representative := by + apply (representativeList_nodup N P F _ _).injective_get + exact physicalRepresentativeFin_get source target U N P F A node.1 _ _ + rw [heq] + +theorem physicalLocalOnline_mem_iff + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalInternalNode M J) (children : PhysicalChildTables M target.length) + (t : ℕ) (q : TargetInterval target.length) (action : PhysicalRationalAction M target.length) : + action ∈ physicalLocalOnline source target U N P F exponent H T A tau eta kappa + (physicalOnlineIntegersOfStreams source target U N P F exponent H T A tau online) + node.1 children t q ↔ + action ∈ physicalProgramOnline source target U N P F A T exponent H tau eta kappa + online node.1 children t q := by + have hmass : physicalLocalChildMass source target U N P F A T node.1 node.2 = + physicalBandChildMassTable source target U N P F A T node.1 node.2 := by + funext i r + exact physicalLocalWarmupMass_eq source target U N P F A hsize hP hF hA hseed T + (physicalChild node.1 node.2 i, r) + unfold physicalLocalOnline physicalProgramOnline + rw [dite_eq_left node.2, dite_eq_left node.2] + rw [localOnlineCandidates_mem] + constructor + · rintro ⟨b, hb, hrep, hselected⟩ + obtain ⟨representative, hget⟩ := List.mem_iff_get.mp hrep + change (representatives node.1).get representative = + (b, roundInterval (seedGridSpacing b P) q) at hget + have hinteger := physicalOnlineIntegersOfStreams_get source target U N P F exponent H T A tau online + node representative (Fin.ofNat R (t - 1)) + rw [hget] at hinteger + rw [hmass, hinteger] at hselected + have heq := keyedOnlineCandidate_eq_physical source target U N P F exponent H T A tau eta kappa + node representative children (t - 1) (online node representative (Fin.ofNat R (t - 1))) + rw [hget] at heq + rw [heq] at hselected + apply List.mem_filterMap.mpr + refine ⟨representative, List.mem_filter.mpr ⟨List.mem_finRange _, ?_⟩, hselected⟩ + apply decide_eq_true + unfold physicalProgramOnlineGuard + rw [hget] + exact ⟨rfl, of_decide_eq_true (List.mem_filter.mp hb).2⟩ + · intro ha + obtain ⟨representative, hrep, hselected⟩ := List.mem_filterMap.mp ha + have hguard := of_decide_eq_true (List.mem_filter.mp hrep).2 + let br := (representatives node.1).get representative + have hget : (representatives node.1).get representative = + (br.1, roundInterval (seedGridSpacing br.1 P) q) := Prod.ext rfl hguard.1 + refine ⟨br.1, List.mem_filter.mpr ⟨?_, decide_eq_true hguard.2⟩, ?_, ?_⟩ + · exact representativeList_scale_mem _ _ (List.get_mem _ representative) + · exact hget ▸ List.get_mem _ representative + · have hinteger := physicalOnlineIntegersOfStreams_get source target U N P F exponent H T A tau online + node representative (Fin.ofNat R (t - 1)) + rw [hget] at hinteger + rw [hmass, hinteger] + have heq := keyedOnlineCandidate_eq_physical source target U N P F exponent H T A tau eta kappa + node representative children (t - 1) (online node representative (Fin.ofNat R (t - 1))) + rw [hget] at heq + exact heq.trans hselected + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalOnlineKeys.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalOnlineKeys.lean new file mode 100644 index 0000000000000000000000000000000000000000..79d97ded4c7adda644d56388e9c77ba753a0c74e --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalOnlineKeys.lean @@ -0,0 +1,137 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalOnlineEquality +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramLaw +import OAI.Combinatorics.EditApproximation.Probability.FiniteKeyRestriction +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Online random streams have bounded physical keys. The embedding of +the complete representative table is used only in the proof of the law; +the local program requests the scale and rounded center directly. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + + + + + +theorem physicalScaleIndex_get (N b : ℕ) (hb : b ∈ dyadicScales N) : + (dyadicScales N).get (physicalScaleIndex N b hb) = b := + List.getElem_idxOf (List.idxOf_lt_length_of_mem hb) + +section Keys + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) + +def physicalOnlineRawKey + (key : PhysicalOnlineKey source target U N P F A) : + PhysicalLocalOnlineKey M J N target.length := + (key.1, physicalScaleIndex N + ((stageRepresentatives source target U N P F A key.1.1).get key.2).1 + (representativeList_scale_mem _ _ (List.get_mem _ key.2)), + ((stageRepresentatives source target U N P F A key.1.1).get key.2).2) + +theorem physicalOnlineRawKey_injective : + Function.Injective (physicalOnlineRawKey source target U N P F A) := by + rintro ⟨node, representative⟩ ⟨node', representative'⟩ heq + have hnode := congrArg Prod.fst heq + change node = node' at hnode + subst node' + have hscale := congrArg (fun key : PhysicalLocalOnlineKey M J N target.length => + (dyadicScales N).get key.2.1) heq + have hcenter := congrArg (fun key : PhysicalLocalOnlineKey M J N target.length => key.2.2) heq + simp only [physicalOnlineRawKey, physicalScaleIndex_get] at hscale hcenter + have hrep := (representativeList_nodup N P F _ _).injective_get (Prod.ext hscale hcenter) + cases hrep + rfl + +def physicalLocalOnlineBandG (T exponent H : ℕ) (tau : ℚ) + (key : PhysicalLocalOnlineKey M J N target.length) : ℕ := + keyedOnlineBandG source target (physicalSourceInterval source.length key.1.1) + P exponent H ((dyadicScales N).get key.2.1) tau + (physicalLocalChildMass source target U N P F A T key.1.1 key.1.2) key.2.2 + +theorem physicalLocalOnlineBandG_positive (T exponent H : ℕ) (tau : ℚ) + (key : PhysicalLocalOnlineKey M J N target.length) : + 0 < physicalLocalOnlineBandG source target U N P F A T exponent H tau key := + keyedOnlineBandG_positive _ _ _ _ _ _ _ _ _ _ + +theorem physicalLocalOnlineBandG_on_key (T exponent H : ℕ) (tau : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (key : PhysicalOnlineKey source target U N P F A) : + physicalLocalOnlineBandG source target U N P F A T exponent H tau + (physicalOnlineRawKey source target U N P F A key) = + physicalProgramBandG source target U N P F A T exponent H tau key.1 key.2 := by + have hmass : physicalLocalChildMass source target U N P F A T key.1.1 key.1.2 = + physicalBandChildMassTable source target U N P F A T key.1.1 key.1.2 := by + funext i r + exact physicalLocalWarmupMass_eq source target U N P F A hsize hP hF hA hseed T + (physicalChild key.1.1 key.1.2 i, r) + simp only [physicalLocalOnlineBandG, physicalOnlineRawKey, physicalScaleIndex_get, hmass, + keyedOnlineBandG, physicalProgramBandG, physicalBandActions] + +def physicalLocalOnlineMass (T exponent H : ℕ) (tau : ℚ) + (key : PhysicalLocalOnlineKey M J N target.length) : ℕ := + optimizerTriangularMass + (physicalLocalOnlineBandG source target U N P F A T exponent H tau key ^ 80) + +instance physicalLocalOnlineMass_nezero (T exponent H : ℕ) (tau : ℚ) + (key : PhysicalLocalOnlineKey M J N target.length) : + NeZero (physicalLocalOnlineMass source target U N P F A T exponent H tau key) := + ⟨Nat.ne_of_gt (optimizerTriangularMass_positive _ + (pow_pos (physicalLocalOnlineBandG_positive source target U N P F A T exponent H tau key) 80))⟩ + +theorem physicalLocalOnlineMass_on_key (T exponent H : ℕ) (tau : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (key : PhysicalOnlineKey source target U N P F A) : + physicalLocalOnlineMass source target U N P F A T exponent H tau + (physicalOnlineRawKey source target U N P F A key) = + optimizerTriangularMass + (physicalProgramBandK source target U N P F A T exponent H tau key.1 key.2) := by + unfold physicalLocalOnlineMass physicalProgramBandK + rw [physicalLocalOnlineBandG_on_key source target U N P F A T exponent H tau + hsize hP hF hA hseed key] + +abbrev PhysicalLocalOnlineDraw (R T exponent H : ℕ) (tau : ℚ) := + ∀ key : PhysicalLocalOnlineKey M J N target.length, + Fin R → Fin (physicalLocalOnlineMass source target U N P F A T exponent H tau key) + +noncomputable def physicalLocalOnlineDrawLaw (R T exponent H : ℕ) (tau : ℚ) : + Measure (PhysicalLocalOnlineDraw source target U N P F A R T exponent H tau) := + Measure.pi fun key => Measure.pi fun _ : Fin R => + (PMF.uniformOfFintype + (Fin (physicalLocalOnlineMass source target U N P F A T exponent H tau key))).toMeasure + +/-- The bounded-key independent arrays restrict to the original online +coordinates with exactly their prescribed finite uniform laws. -/ +theorem physicalLocalOnlineDrawLaw_restrict (R T exponent H : ℕ) (tau : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) : + (physicalLocalOnlineDrawLaw source target U N P F A R T exponent H tau).map + (fun draw (key : PhysicalOnlineKey source target U N P F A) t => + Fin.cast (physicalLocalOnlineMass_on_key source target U N P F A T exponent H tau + hsize hP hF hA hseed key) + (draw (physicalOnlineRawKey source target U N P F A key) t)) = + Measure.pi (fun key : PhysicalOnlineKey source target U N P F A => + Measure.pi (fun _ : Fin R => (PMF.uniformOfFintype (Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T exponent H tau key.1 key.2)))).toMeasure)) := by + exact finite_uniform_arrays_restrict_cast R _ _ + (physicalOnlineRawKey source target U N P F A) + (physicalOnlineRawKey_injective source target U N P F A) + (physicalLocalOnlineMass_on_key source target U N P F A T exponent H tau hsize hP hF hA hseed) + +end Keys + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalProgramEquality.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalProgramEquality.lean new file mode 100644 index 0000000000000000000000000000000000000000..77f9f825de118cb31c75410d5a00e013f3731cf5 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalProgramEquality.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalOnlineEquality +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalRefinementEquality + +namespace OAI + +/-! The complete refinement is reproduced, on good incoming seeds, by +bounded cell and rounded-center loops with local warmup data throughout. -/ + +namespace EditApproximation + +theorem physicalLocalRefinement_online_mem_congr {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A tau delta : ℚ) (T : ℕ) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (left right : PhysicalNode M J → PhysicalChildTables M target.length → ℕ → + TargetInterval target.length → List (PhysicalRationalAction M target.length)) + (hmem : ∀ node children t q action, + action ∈ left node children t q ↔ action ∈ right node children t q) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw left node t q = + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw right node t q := by + rw [physicalLocalRefinement, physicalLocalRefinement] + split_ifs with hbelow hleaf + · rfl + · have hchild (i : Fin M) : physicalLocalRefinement source target U N P F exponent Q A tau delta T + draw left (physicalChild node hbelow i) = + physicalLocalRefinement source target U N P F exponent Q A tau delta T + draw right (physicalChild node hbelow i) := by + funext s r + exact physicalLocalRefinement_online_mem_congr source target U N P F exponent Q A tau delta T + draw left right hmem (physicalChild node hbelow i) s r + dsimp only + simp_rw [hchild] + cases t with + | zero => rfl + | succ t => + unfold rationalLocalWideStep + dsimp only + apply rationalRefinementUpdate_online_mem_ext + exact hmem _ _ _ _ + · rfl +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +section Program + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q H T : ℕ) (A tau delta eta kappa : ℚ) + (online : PhysicalOnlineStreams source target U N P F A T exponent H tau R) + (draw : PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + +local notation "localDraw" => (fun node t => draw node (Fin.ofNat R (t - 1))) +local notation "localProvider" => physicalLocalOnline source target U N P F exponent H T A tau eta kappa + (physicalOnlineIntegersOfStreams source target U N P F exponent H T A tau online) +local notation "provider" => physicalProgramOnline source target U N P F A T exponent H tau eta kappa online +local notation "choices" => physicalProgramSelections source target U N P F A T exponent H Q tau eta kappa online + (physicalGroupStreamsOfKeys source target U N P F exponent Q A draw) + +theorem physicalLocalProgram_eq + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + physicalLocalRefinement source target U N P F exponent Q A tau delta T localDraw localProvider node t q = + physicalRefinement source target U N P F A T delta choices node t q := by + have hmem : ∀ label children s r action, + action ∈ localProvider label children s r ↔ action ∈ provider label children s r := by + intro label children s r action + by_cases hbelow : label.1.val < J + · exact physicalLocalOnline_mem_iff source target U N P F exponent H T A tau eta kappa online + hsize hP hF hA hseed ⟨label, hbelow⟩ children s r action + · simp only [physicalLocalOnline, physicalProgramOnline, dite_eq_right hbelow, List.not_mem_nil] + rw [physicalLocalRefinement_online_mem_congr source target U N P F exponent Q A tau delta T + localDraw localProvider provider hmem node t q] + exact physicalLocalRefinement_keyed_eq source target U N P F exponent Q H T A tau delta eta kappa + online draw hsize hP hF hA hseed node t q + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalProgramLaw.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalProgramLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2165aa230f99c12353f47bd7255658185626cce --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalProgramLaw.lean @@ -0,0 +1,139 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalGroupKeys + +namespace OAI + +/-! A single bounded-key product supplies both online and whole-cell +streams. Restriction to the complete program preserves their joint law, +including independence between the two kinds of stream. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +abbrev PhysicalLocalProgramKey (M J N n exponent : ℕ) := + Sum (PhysicalLocalOnlineKey M J N n) (PhysicalLocalGroupKey M J N n exponent) + +section Law + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} + [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T exponent H Q : ℕ) (tau : ℚ) + +abbrev PhysicalLocalProgramCoordinate + (key : PhysicalLocalProgramKey M J N target.length exponent) : Type := + match key with + | .inl online => Fin R → Fin (physicalLocalOnlineMass source target U N P F A T exponent H tau online) + | .inr group => PhysicalLocalGroupArray M J N target.length exponent F Q R group + +instance physicalLocalProgramCoordinateFintype + (key : PhysicalLocalProgramKey M J N target.length exponent) : + Fintype (PhysicalLocalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau key) := by + cases key <;> dsimp only [PhysicalLocalProgramCoordinate] <;> infer_instance + +instance physicalLocalProgramCoordinateMeasurableSpace + (key : PhysicalLocalProgramKey M J N target.length exponent) : + MeasurableSpace (PhysicalLocalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau key) := by + cases key <;> dsimp only [PhysicalLocalProgramCoordinate] <;> infer_instance + +instance physicalLocalProgramCoordinateMeasurableSingleton + (key : PhysicalLocalProgramKey M J N target.length exponent) : + MeasurableSingletonClass + (PhysicalLocalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau key) := by + cases key <;> dsimp only [physicalLocalProgramCoordinateMeasurableSpace, + PhysicalLocalProgramCoordinate] <;> infer_instance + +noncomputable def physicalLocalProgramCoordinateLaw + (key : PhysicalLocalProgramKey M J N target.length exponent) : + Measure (PhysicalLocalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau key) := + match key with + | .inl online => Measure.pi fun _ : Fin R => + (PMF.uniformOfFintype + (Fin (physicalLocalOnlineMass source target U N P F A T exponent H tau online))).toMeasure + | .inr group => physicalLocalGroupArrayLaw M J N target.length exponent F Q R group + +instance physicalLocalProgramCoordinateLaw_probability + (key : PhysicalLocalProgramKey M J N target.length exponent) : + IsProbabilityMeasure + (physicalLocalProgramCoordinateLaw (R := R) source target U N P F A T exponent H Q tau key) := by + cases key <;> dsimp only [physicalLocalProgramCoordinateLaw, + physicalLocalProgramCoordinateMeasurableSpace, PhysicalLocalProgramCoordinate] <;> infer_instance + +abbrev PhysicalLocalProgramDraw := ∀ key : PhysicalLocalProgramKey M J N target.length exponent, + PhysicalLocalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau key + +noncomputable def physicalLocalProgramDrawLaw : + Measure (PhysicalLocalProgramDraw (R := R) source target U N P F A T exponent H Q tau) := + Measure.pi (physicalLocalProgramCoordinateLaw (R := R) source target U N P F A T exponent H Q tau) + +def physicalLocalProgramOldKey + (key : PhysicalProgramKey source target U N P F A exponent) : + PhysicalLocalProgramKey M J N target.length exponent := + match key with + | .inl online => .inl (physicalOnlineRawKey source target U N P F A online) + | .inr group => .inr (physicalGroupRawKey source target U N P F exponent A group) + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalLocalProgramOldKey_injective : + Function.Injective (physicalLocalProgramOldKey source target U N P F A exponent) := by + intro first second heq + cases first with + | inl first => + cases second with + | inl second => + exact congrArg Sum.inl + (physicalOnlineRawKey_injective source target U N P F A (Sum.inl.inj heq)) + | inr second => exact False.elim (Sum.inl_ne_inr heq) + | inr first => + cases second with + | inl second => exact False.elim (Sum.inr_ne_inl heq) + | inr second => + exact congrArg Sum.inr + (physicalGroupRawKey_injective source target U N P F exponent A (Sum.inr.inj heq)) + +variable (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + +def physicalLocalProgramCoordinateImage + (key : PhysicalProgramKey source target U N P F A exponent) : + PhysicalLocalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau + (physicalLocalProgramOldKey source target U N P F A exponent key) → + PhysicalProgramCoordinate (R := R) source target U N P F A T exponent H Q tau key := + match key with + | .inl online => fun array time => Fin.cast + (physicalLocalOnlineMass_on_key source target U N P F A T exponent H tau hsize hP hF hA hseed online) + (array time) + | .inr _ => id + +def physicalLocalProgramToComplete + (draw : PhysicalLocalProgramDraw (R := R) source target U N P F A T exponent H Q tau) : + PhysicalProgramDraw (R := R) source target U N P F A T exponent H Q tau := + fun key => physicalLocalProgramCoordinateImage source target U N P F A T exponent H Q tau + hsize hP hF hA hseed key (draw (physicalLocalProgramOldKey source target U N P F A exponent key)) + +theorem physicalLocalProgramDrawLaw_map : + (physicalLocalProgramDrawLaw (R := R) source target U N P F A T exponent H Q tau).map + (physicalLocalProgramToComplete source target U N P F A T exponent H Q tau hsize hP hF hA hseed) = + physicalProgramDrawLaw (R := R) source target U N P F A T exponent H Q tau := by + have hmap := finite_pi_restrict_image_map + (physicalLocalProgramCoordinateLaw (R := R) source target U N P F A T exponent H Q tau) + (physicalLocalProgramOldKey source target U N P F A exponent) + (physicalLocalProgramOldKey_injective source target U N P F A exponent) + (physicalLocalProgramCoordinateImage source target U N P F A T exponent H Q tau hsize hP hF hA hseed) + (fun _ => measurable_of_finite _) + refine hmap.trans ?_ + unfold physicalProgramDrawLaw + congr 1 + funext key + cases key with + | inl online => + exact finite_uniform_array_cast R _ _ + (physicalLocalOnlineMass_on_key source target U N P F A T exponent H tau hsize hP hF hA hseed online) + | inr group => exact Measure.map_id + +end Law + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalRefinement.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalRefinement.lean new file mode 100644 index 0000000000000000000000000000000000000000..6988e4d050b0316b04edf6fc0049b1c2588ce5d7 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalRefinement.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.EditApproximation.Geometry.LocalWideStep +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalWarmup + +namespace OAI + +/-! The local finite refinement recurrence, with direct query groups and +local warmup data. Current-index dependencies go only to physical children; +the recurrence is well founded before any accuracy assertion. -/ + +namespace EditApproximation + +def physicalLocalChildMass {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) : + Fin M → TargetInterval target.length → ℚ := + fun i r => physicalLocalWarmupMass source target U N P F A T (physicalChild node hbelow i, r) + +def physicalLocalRefinement {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A tau delta : ℚ) (T : ℕ) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (online : PhysicalNode M J → PhysicalChildTables M target.length → ℕ → + TargetInterval target.length → List (PhysicalRationalAction M target.length)) + (node : PhysicalNode M J) : ℕ → TargetInterval target.length → ℚ := + if hbelow : node.1.val < J then + if (physicalSourceInterval source.length node).hi - (physicalSourceInterval source.length node).lo ≤ 1 then + fun _ q => stageInitial source target U N P F A (node, q) + else + let children : PhysicalChildTables M target.length := fun i => + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw online + (physicalChild node hbelow i) + fun t q => match t with + | 0 => physicalLocalWarmup source target U N P F A T (node, q) + | s + 1 => rationalLocalWideStep source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor A F) delta + (fun r => stageInitial source target U N P F A (node, r)) + (physicalLocalChildMass source target U N P F A T node hbelow) + (fun i r => stageInitial source target U N P F A (physicalChild node hbelow i, r)) + (fun i r => children i s r) (fun i r => children i (s + 1) r) + (draw ⟨node, hbelow⟩ (s + 1)) (online node children (s + 1) q) q + else fun _ q => stageInitial source target U N P F A (node, q) +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +theorem physicalLocalRefinement_bounds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A tau delta : ℚ) (T : ℕ) (hdelta : 0 ≤ delta) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (online : PhysicalNode M J → PhysicalChildTables M target.length → ℕ → + TargetInterval target.length → List (PhysicalRationalAction M target.length)) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + 0 ≤ physicalLocalRefinement source target U N P F exponent Q A tau delta T draw online node t q ∧ + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw online node t q ≤ + stageInitial source target U N P F A (node, q) := by + rw [physicalLocalRefinement] + split_ifs with hbelow hleaf + · exact ⟨stageInitial_nonneg_all_seeds source target U N P F A (node, q), le_rfl⟩ + · cases t with + | zero => exact physicalLocalWarmup_bounds source target U N P F A T (node, q) + | succ t => + let children : PhysicalChildTables M target.length := fun i => + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw online + (physicalChild node hbelow i) + have hold (i : Fin M) (r : TargetInterval target.length) : 0 ≤ children i t r := + (physicalLocalRefinement_bounds source target U N P F exponent Q A tau delta T hdelta + draw online (physicalChild node hbelow i) t r).1 + have hcurrent (i : Fin M) (r : TargetInterval target.length) : 0 ≤ children i (t + 1) r := + (physicalLocalRefinement_bounds source target U N P F exponent Q A tau delta T hdelta + draw online (physicalChild node hbelow i) (t + 1) r).1 + exact rationalLocalWideStep_bounds source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor A F) delta + (fun r => stageInitial source target U N P F A (node, r)) + (physicalLocalChildMass source target U N P F A T node hbelow) + (fun i r => stageInitial source target U N P F A (physicalChild node hbelow i, r)) + (fun i r => children i t r) (fun i r => children i (t + 1) r) + (draw ⟨node, hbelow⟩ (t + 1)) (online node children (t + 1) q) q hdelta + (stageInitial_nonneg_all_seeds source target U N P F A (node, q)) hold hcurrent + · exact ⟨stageInitial_nonneg_all_seeds source target U N P F A (node, q), le_rfl⟩ +termination_by J - node.1.val +decreasing_by + all_goals + unfold physicalChild + dsimp only + omega + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalRefinementEquality.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalRefinementEquality.lean new file mode 100644 index 0000000000000000000000000000000000000000..903eb5aa7ec5f2ea7c3ffb2623e20583c25f5760 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalRefinementEquality.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalRefinement +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalGroupProgram + +namespace OAI + +/-! On good seeds, the query-local recurrence equals the complete refinement recurrence. -/ + +namespace EditApproximation + +section Program + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q H T : ℕ) (A tau delta eta kappa : ℚ) + (online : PhysicalOnlineStreams source target U N P F A T exponent H tau R) + (draw : PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + +local notation "provider" => physicalProgramOnline source target U N P F A T exponent H tau eta kappa online +local notation "choices" => physicalProgramSelections source target U N P F A T exponent H Q tau eta kappa online + (physicalGroupStreamsOfKeys source target U N P F exponent Q A draw) +local notation "localDraw" => (fun node t => draw node (Fin.ofNat R (t - 1))) + +theorem physicalLocalRefinement_keyed_eq + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + physicalLocalRefinement source target U N P F exponent Q A tau delta T localDraw provider node t q = + physicalRefinement source target U N P F A T delta choices node t q := by + rw [physicalLocalRefinement, physicalRefinement] + split_ifs with hbelow hleaf + · rfl + · have hchild (i : Fin M) : physicalLocalRefinement source target U N P F exponent Q A tau delta T + localDraw provider (physicalChild node hbelow i) = + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow i) := by + funext s r + exact physicalLocalRefinement_keyed_eq hsize hP hF hA hseed (physicalChild node hbelow i) s r + dsimp only + simp_rw [hchild] + cases t with + | zero => exact physicalLocalWarmup_eq source target U N P F A hsize hP hF hA hseed T (node, q) + | succ t => + let children : PhysicalChildTables M target.length := fun i => + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow i) + have hmass : physicalLocalChildMass source target U N P F A T node hbelow = + physicalBandChildMassTable source target U N P F A T node hbelow := by + funext i r + exact physicalLocalWarmupMass_eq source target U N P F A hsize hP hF hA hseed T + (physicalChild node hbelow i, r) + have hfactor := refinementFactor_spec A F (by omega : 0 < F) + have hspatial : ∀ r, |stageInitial source target U N P F A (node, q) - + stageInitial source target U N P F A (node, r)| ≤ 32 * F * targetEndpointDistance q r := by + intro r + have hqr := physicalInitialTable_spatial source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed node q r + have hrq := physicalInitialTable_spatial source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed node r q + have hsym : targetEndpointDistance r q = targetEndpointDistance q r := by + exact congrArg₂ (· + ·) (Nat.dist_comm _ _) (Nat.dist_comm _ _) + rw [hsym] at hrq + apply abs_le.mpr + constructor <;> dsimp only [stageInitial] <;> linarith only [hqr, hrq] + have hold (i : Fin M) (r : TargetInterval target.length) : 0 ≤ children i t r := + physicalRefinement_nonneg_all_seeds source target U N P F A T delta choices + (physicalChild node hbelow i) t r + have hcurrent (i : Fin M) (r : TargetInterval target.length) : 0 ≤ children i (t + 1) r := + physicalRefinement_nonneg_all_seeds source target U N P F A T delta choices + (physicalChild node hbelow i) (t + 1) r + have hstep := rationalLocalWideStep_eq source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor A F) delta + (fun r => stageInitial source target U N P F A (node, r)) + (physicalLocalChildMass source target U N P F A T node hbelow) + (fun i r => stageInitial source target U N P F A (physicalChild node hbelow i, r)) + (fun i r => children i t r) (fun i r => children i (t + 1) r) + (draw ⟨node, hbelow⟩ (Fin.ofNat R t)) (provider node children (t + 1) q) q + hfactor.1 hF (stageInitial_nonneg_all_seeds source target U N P F A (node, q)) hold hcurrent hspatial + rw [hmass] at hstep + have hkey := physicalProgramGroups_keyed source target U N P F exponent Q A T tau draw node hbelow children (t + 1) + simp only [Nat.add_sub_cancel] at hkey + unfold physicalBandChildInitial at hkey + rw [← hkey] at hstep + change rationalLocalWideStep source target (physicalSourceInterval source.length node) + N P F exponent Q tau (refinementFactor A F) delta + (fun r => stageInitial source target U N P F A (node, r)) + (physicalLocalChildMass source target U N P F A T node hbelow) + (fun i r => stageInitial source target U N P F A (physicalChild node hbelow i, r)) + (fun i r => children i t r) (fun i r => children i (t + 1) r) + (draw ⟨node, hbelow⟩ (Fin.ofNat R t)) (provider node children (t + 1) q) q = _ + rw [hmass] + exact hstep + · rfl +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalValueBits.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalValueBits.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4e4989df076efed768cd645745576d194a160ba --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalValueBits.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalDenominator +import OAI.Combinatorics.EditApproximation.Geometry.ChargedGlobalQuery +import OAI.Combinatorics.EditApproximation.Numerics.RationalIntermediateBits + +namespace OAI + +/-! Actual cached local values have short canonical rational encodings on +every seed, without an accuracy event. -/ + +namespace EditApproximation + + theorem unifiedPhysicalValue_encoding_bits {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A tau : ℚ) (hsize : source.length + target.length ≤ N) + (T ell : ℕ) (hell : 0 < ell) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (online : PhysicalNode M J → PhysicalChildTables M target.length → ℕ → + TargetInterval target.length → List (PhysicalRationalAction M target.length)) + (honline : ∀ node children t q action, action ∈ online node children t q → action.connection.den = 1) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + rationalEncodingBits (unifiedPhysicalValue source target U N P F exponent Q A tau + (1 / (ell : ℚ) ^ 10) T draw online node t q) ≤ + Nat.size ((32 * F + 1) * N) + 2 * (J - node.1.val) * Nat.size (ell ^ 10 + 1) + 3 := by + unfold unifiedPhysicalValue + split + · exact (physicalLocalWarmup_encoding_bits source target U N P F A hsize t (node, q)).trans + (by omega) + · exact physicalLocalRefinement_encoding_bits source target U N P F exponent Q A tau hsize T ell hell + draw online honline node (t - T) q + + theorem localRequestValue_encoding_bits {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q T S copies ell : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) (hell : 0 < ell) + (hsize : source.length + target.length ≤ N) (request : PhysicalTableRequest M J target.length) : + rationalEncodingBits (localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa (1 / (ell : ℚ) ^ 10) group integer initial request) ≤ + Nat.size ((32 * F + 1) * N) + 2 * J * Nat.size (ell ^ 10 + 1) + 3 := by + unfold localRequestValue + apply (unifiedPhysicalValue_encoding_bits source target _ N P F exponent Q _ tau hsize T ell hell _ _ + (physicalLocalOnline_connection_den source target _ N P F exponent H T _ tau eta kappa _) + request.node request.index request.state).trans + have hm := Nat.mul_le_mul_right (Nat.size (ell ^ 10 + 1)) + (Nat.mul_le_mul_left 2 (Nat.sub_le J request.node.1.val)) + omega + + theorem chargedRequestValue_encoding_bits {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies ell : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) (hell : 0 < ell) + (hsize : source.length + target.length ≤ N) (hinitial : ∀ entry, initial entry ≤ N) + (request : ChargedPhysicalRequest M J target.length passes copies T S) : + rationalEncodingBits (chargedRequestValue source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa (1 / (ell : ℚ) ^ 10) group integer initial request) ≤ + Nat.size ((32 * F + 1) * N) + 2 * J * Nat.size (ell ^ 10 + 1) + 3 := by + cases request with + | inl entry => + change rationalEncodingBits (initial entry : ℚ) ≤ _ + rw [rationalEncodingBits_natCast] + have hn : N ≤ (32 * F + 1) * N := by nlinarith + have hs := Nat.size_le_size ((hinitial entry).trans hn) + omega + | inr request => + exact localRequestValue_encoding_bits source target N P F exponent H Q T S copies ell + factor multiplier tau eta kappa group integer initial hell hsize request.val + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalValueLaw.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalValueLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a13b0b88817e440b4f47be0af402cb1679ac6b0 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalValueLaw.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalJointProgram + +namespace OAI + +/-! The direct local program has the same returned-value law as the +complete refinement on each good incoming seed. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +section ValueLaw + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T exponent H Q : ℕ) (tau eta kappa delta : ℚ) + +instance physicalLocalProgramDrawLaw_probability : + IsProbabilityMeasure + (physicalLocalProgramDrawLaw (R := R) source target U N P F A T exponent H Q tau) := by + unfold physicalLocalProgramDrawLaw + infer_instance + +theorem physicalLocalJointValue_law + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + (physicalLocalProgramDrawLaw (R := R) source target U N P F A T exponent H Q tau).map + (fun draw => physicalLocalJointValue source target U N P F A T exponent H Q tau eta kappa delta + draw node t q) = + (physicalProgramDrawLaw (R := R) source target U N P F A T exponent H Q tau).map + (fun draw => physicalRefinement source target U N P F A T delta + (physicalProgramDrawSelections source target U N P F A T exponent H Q tau eta kappa draw) + node t q) := by + let complete := fun draw : PhysicalProgramDraw (R := R) source target U N P F A T exponent H Q tau => + physicalRefinement source target U N P F A T delta + (physicalProgramDrawSelections source target U N P F A T exponent H Q tau eta kappa draw) node t q + let restrict := physicalLocalProgramToComplete (R := R) source target U N P F A T exponent H Q tau + hsize hP hF hA hseed + have heq : (fun draw => physicalLocalJointValue source target U N P F A T exponent H Q tau + eta kappa delta draw node t q) = complete ∘ restrict := by + funext draw + exact physicalLocalJointValue_eq source target U N P F A T exponent H Q tau eta kappa delta + draw hsize hP hF hA hseed node t q + rw [heq, ← Measure.map_map (measurable_of_finite complete) (measurable_of_finite restrict)] + rw [physicalLocalProgramDrawLaw_map source target U N P F A T exponent H Q tau + hsize hP hF hA hseed] + +end ValueLaw + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalWarmup.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalWarmup.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6ec73c4fa013e2cfd911e6e083e278a54cd6d0c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalLocalWarmup.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.EditApproximation.Geometry.LocalRefinementCones + +namespace OAI + +/-! The literal warmup can be calculated by direct bounded endpoint +loops. Equality with the complete tables is only asserted on good seeds; +the local rules themselves remain finite and bounded on every seed. -/ + +namespace EditApproximation + +open Finset + +def physicalLocalWarmup {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) : ℕ → PhysicalEntry M J target.length → ℚ + | 0, state => stageInitial source target U N P F A state + | t + 1, state => + if hbelow : state.1.1.val < J then + if (physicalSourceInterval source.length state.1).hi - + (physicalSourceInterval source.length state.1).lo ≤ 1 then + stageInitial source target U N P F A state + else rationalBellman (fun q => stageInitial source target U N P F A (state.1, q)) + (fun q r => targetEndpointDistance q r) (128 * F) + (rationalActualWideActions (physicalSourceInterval source.length state.1) + (localRefinementRepresentatives N P F (refinementFactor A F) + (fun q => stageInitial source target U N P F A (state.1, q)) state.2) P) + (fun is => physicalLocalWarmup source target U N P F A t + (physicalChild state.1 hbelow is.1, is.2)) state.2 + else stageInitial source target U N P F A state + +theorem physicalLocalWarmup_bounds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (t : ℕ) (state : PhysicalEntry M J target.length) : + 0 ≤ physicalLocalWarmup source target U N P F A t state ∧ + physicalLocalWarmup source target U N P F A t state ≤ stageInitial source target U N P F A state := by + induction t generalizing state with + | zero => exact ⟨stageInitial_nonneg_all_seeds source target U N P F A state, le_rfl⟩ + | succ t ih => + rw [physicalLocalWarmup] + split_ifs + · exact ⟨stageInitial_nonneg_all_seeds source target U N P F A state, le_rfl⟩ + · refine ⟨?_, rationalMinimum_le_fallback _ _⟩ + apply (le_rationalMinimum_iff _ _ _).2 + refine ⟨stageInitial_nonneg_all_seeds source target U N P F A state, ?_⟩ + intro v hv + obtain ⟨action, ha, rfl⟩ := List.mem_map.mp hv + unfold rationalActionValue + apply add_nonneg + · exact add_nonneg (by positivity) + (rationalActualWideActions_connection_nonneg _ _ _ action ha) + · exact Finset.sum_nonneg (fun i _ => (ih _).1) + · exact ⟨stageInitial_nonneg_all_seeds source target U N P F A state, le_rfl⟩ + +theorem physicalLocalWarmup_eq {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (t : ℕ) (state : PhysicalEntry M J target.length) : + physicalLocalWarmup source target U N P F A t state = + stageWarmup source target U N P F A t state := by + induction t generalizing state with + | zero => rfl + | succ t ih => + change _ = rationalPhysicalBellman source target P (128 * F) + (stageInitial source target U N P F A) (stageRepresentatives source target U N P F A) + (stageWarmup source target U N P F A t) state + rw [physicalLocalWarmup] + unfold rationalPhysicalBellman + dsimp only + split_ifs + · rfl + · simp_rw [ih] + exact physical_localRefinementBellman_eq source target U N P F A hsize hP hF hA hseed + state.1 _ (fun is => stageWarmup_nonneg_all_seeds source target U N P F A t _) state.2 + · rfl + +def physicalLocalWarmupMass {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (state : PhysicalEntry M J target.length) : ℚ := + (∑ t ∈ Finset.range T, physicalLocalWarmup source target U N P F A t state) / T + +theorem physicalLocalWarmupMass_eq {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (state : PhysicalEntry M J target.length) : + physicalLocalWarmupMass source target U N P F A T state = + stageWarmupMass source target U N P F A T state := by + unfold physicalLocalWarmupMass stageWarmupMass rationalPhysicalWarmupAverage + simp_rw [physicalLocalWarmup_eq source target U N P F A hsize hP hF hA hseed] + rfl + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalMedianQuery.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalMedianQuery.lean new file mode 100644 index 0000000000000000000000000000000000000000..d99914b53cdaf7e8479480625830f02f13c736d5 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalMedianQuery.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.EditApproximation.Probability.FiniteQueryWork +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSeedPass +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! A seed entry is computed by querying the previous pass at the same +physical node in each copy, then applying the literal clamped median. +The copy coordinate never changes the dependency rank. -/ + +namespace EditApproximation + + + +theorem previousPassRequest_progress {M J ny : ℕ} (T S copy : ℕ) + (parent : PhysicalTableRequest M J ny) (hpass : 0 < parent.pass) (state : TargetInterval ny) : + (previousPassRequest T S copy parent state).remainingDepth = parent.remainingDepth ∧ + (previousPassRequest T S copy parent state).rank T S < parent.rank T S := by + refine ⟨rfl, ?_⟩ + exact PhysicalTableRequest.rank_lt_previous_pass T S parent _ (by + change parent.pass - 1 < parent.pass + omega) le_rfl + + + + + +theorem physicalMedianSeedQuery_value {M J ny : ℕ} (N T S copies multiplier : ℕ) + (parent : PhysicalTableRequest M J ny) (hpass : 0 < parent.pass) (state : TargetInterval ny) + (values : PhysicalTableRequest M J ny → ℚ) : + (physicalMedianSeedQuery N T S copies multiplier parent hpass state).value + (fun child => values child.val) = + (min N (upperMedian (List.ofFn fun copy : Fin copies => + ⌈(multiplier : ℚ) * values (previousPassRequest T S copy.val parent state)⌉₊)) : ℕ) := by + unfold physicalMedianSeedQuery + rw [FiniteQuery.collect_value] + simp only [previousPassRead, FiniteQuery.value, List.map_map, List.ofFn_eq_map, Function.comp_def] + +theorem physicalMedianSeedQuery_cost {M J ny : ℕ} (N T S copies multiplier : ℕ) + (parent : PhysicalTableRequest M J ny) (hpass : 0 < parent.pass) (state : TargetInterval ny) + (oracle : {child : PhysicalTableRequest M J ny // + child.combinedRank T S < parent.combinedRank T S} → ℚ) : + (physicalMedianSeedQuery N T S copies multiplier parent hpass state).cost oracle (fun _ => 1) = copies := by + unfold physicalMedianSeedQuery + rw [FiniteQuery.cost_collect] + simp only [previousPassRead, FiniteQuery.cost, Nat.add_zero, List.map_const', + List.length_finRange, List.sum_replicate, smul_eq_mul, Nat.mul_one] + +theorem physicalMedianSeedQuery_eq_update {α Ω : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) (a S copies : ℕ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (draws : Fin copies → Ω) + (parent : PhysicalTableRequest M J target.length) (hpass : 0 < parent.pass) + (state : TargetInterval target.length) (values : PhysicalTableRequest M J target.length → ℚ) + (hvalues : ∀ copy : Fin copies, + values (previousPassRequest T S copy.val parent state) = + physicalRefinement source target U N P F A T delta (choices (draws copy)) parent.node S state) : + (physicalMedianSeedQuery N T S copies a parent hpass state).value (fun child => values child.val) = + (physicalMedianUpdate source target U N P F A T delta a S copies choices draws (parent.node, state) : ℚ) := by + rw [physicalMedianSeedQuery_value] + simp only [hvalues, physicalMedianUpdate, finiteMedianSeed, physicalScaledCopy] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalNodeEncoding.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalNodeEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..43ce6ab5c4d1be5a2c54aa296e12458039e213b1 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalNodeEncoding.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalInputEncoding +import OAI.Combinatorics.EditApproximation.Geometry.StateDomain +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Computable base-M node labels and mixed-radix table-entry keys. +Equal source intervals at different physical nodes keep distinct keys. -/ + +namespace EditApproximation + + + +theorem treeLayerCode_bound (M d : ℕ) (path : TreeLayer M d) : + treeLayerCode M d path < M ^ d := by + induction d with + | zero => exact Nat.zero_lt_one + | succ d ih => + have hp := ih path.1 + have hi := path.2.isLt + change path.2.val + M * treeLayerCode M d path.1 < M ^ (d + 1) + rw [pow_succ] + nlinarith only [hi, Nat.mul_le_mul_left M (Nat.succ_le_of_lt hp)] + +theorem treeLayerCode_injective (M d : ℕ) : Function.Injective (treeLayerCode M d) := by + induction d with + | zero => intro first second _; cases first; cases second; rfl + | succ d ih => + rintro ⟨first, i⟩ ⟨second, j⟩ heq + obtain ⟨hlabel, hpath⟩ := mixedRadix_injective i.isLt j.isLt heq + exact Prod.ext (ih hpath) (Fin.ext hlabel) + + + +theorem physicalNode_layer_bound {M J : ℕ} (hM : 1 ≤ M) (node : PhysicalNode M J) : + treeLayerCode M node.1.val node.2 < M ^ J := + (treeLayerCode_bound M node.1.val node.2).trans_le + (pow_le_pow_right₀ hM (Nat.le_of_lt_succ node.1.isLt)) + +theorem physicalNodeCode_injective {M J : ℕ} (hM : 1 ≤ M) : + Function.Injective (@physicalNodeCode M J) := by + rintro ⟨depth, path⟩ ⟨depth', path'⟩ heq + obtain ⟨hp, hd⟩ := mixedRadix_injective + (physicalNode_layer_bound hM ⟨depth, path⟩) + (physicalNode_layer_bound hM ⟨depth', path'⟩) heq + have hdepth : depth = depth' := Fin.ext hd + subst depth' + have hpath := treeLayerCode_injective M depth.val hp + change path = path' at hpath + subst path' + rfl + +theorem physicalNodeCode_bound {M J : ℕ} (hM : 1 ≤ M) (node : PhysicalNode M J) : + physicalNodeCode node < M ^ J * (J + 1) := by + have hpath := physicalNode_layer_bound hM node + have hdepth := node.1.isLt + unfold physicalNodeCode + nlinarith only [hpath, Nat.mul_le_mul_left (M ^ J) (Nat.succ_le_of_lt hdepth)] + + + +theorem physicalEntryCode_injective {M J n : ℕ} (hM : 1 ≤ M) : + Function.Injective (@physicalEntryCode M J n) := by + rintro ⟨node, q⟩ ⟨node', q'⟩ heq + obtain ⟨hq, hn⟩ := mixedRadix_injective + (by simpa only [Nat.one_mul] using childInputCode_bound ((0 : Fin 1), q)) + (by simpa only [Nat.one_mul] using childInputCode_bound ((0 : Fin 1), q')) heq + have hstate := childInputCode_injective 1 n hq + have hqeq : q = q' := congrArg (fun pair : Fin 1 × TargetInterval n => pair.2) hstate + exact Prod.ext (physicalNodeCode_injective hM hn) hqeq + +theorem physicalEntryCode_bound {M J n : ℕ} (hM : 1 ≤ M) (state : PhysicalEntry M J n) : + physicalEntryCode state < (n + 1) ^ 2 * (M ^ J * (J + 1)) := by + have hstate : childInputCode ((0 : Fin 1), state.2) < (n + 1) ^ 2 := by + simpa only [Nat.one_mul] using childInputCode_bound ((0 : Fin 1), state.2) + have hnode := physicalNodeCode_bound hM state.1 + unfold physicalEntryCode + nlinarith only [hstate, Nat.mul_le_mul_left ((n + 1) ^ 2) (Nat.succ_le_of_lt hnode)] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalNodeRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalNodeRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..39e8fec27764a58164f33302fbc087f954687846 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalNodeRegret.lean @@ -0,0 +1,480 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalOnlineBand +import OAI.Combinatorics.EditApproximation.Geometry.CellGroupSelection +import OAI.Combinatorics.EditApproximation.Probability.ExpectedRegret +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! +# First crossing for the literal physical refinement + +Online and selected-group candidates are connected to the complete +refinement by membership in its actual finite lists. Group success is the +literal simultaneous estimator-error test, rather than a cone-bound +assumption. The child environment remains fixed throughout this argument. +-/ + +namespace EditApproximation + +open Finset + + + +theorem representativeBandActions_zero_connection {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (r : TargetInterval target.length) + (b P : ℕ) (tau theta : ℚ) (child : Fin M → TargetInterval target.length → ℚ) + (action : Fin M → TargetInterval target.length) + (haction : action ∈ representativeBandActions source target parent r b P tau theta child) : + endpointActionConnection r action = 0 := by + by_cases hwide : wideActionList M parent r b P = [] + · simp only [representativeBandActions, dite_eq_left hwide, List.not_mem_nil] at haction + · by_cases hZ : 0 < rationalWideActionMinimum parent r b P hwide child + · simp only [representativeBandActions, dite_eq_right hwide, ite_eq_left hZ] at haction + exact (computedBandActions_mem parent r b P tau theta _ child action haction).choose_spec.2.2.1 + · simp only [representativeBandActions, dite_eq_right hwide, ite_eq_right hZ, List.not_mem_nil] at haction + +theorem sharedBandRationalAction_wide {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (r : TargetInterval target.length) + (representatives : List (ℕ × TargetInterval target.length)) (b P : ℕ) (tau theta : ℚ) + (child : Fin M → TargetInterval target.length → ℚ) (hrep : (b, r) ∈ representatives) + (action : Fin M → TargetInterval target.length) + (haction : action ∈ representativeBandActions source target parent r b P tau theta child) : + sharedBandRationalAction r action ∈ rationalActualWideActions parent representatives P := by + apply List.mem_flatMap.mpr + refine ⟨(b, r), hrep, List.mem_map.mpr ⟨action, + representativeBandActions_wide source target parent r b P tau theta child action haction, ?_⟩⟩ + simp only [sharedBandRationalAction, + representativeBandActions_zero_connection source target parent r b P tau theta child action haction, + Nat.cast_zero] + +theorem rationalOnlineMinimum_le_member (values : List ℚ) (value : ℚ) (hvalue : value ∈ values) : + ∃ online, rationalOnlineMinimum values = some online ∧ online ≤ value := by + cases values with + | nil => simp only [List.not_mem_nil] at hvalue + | cons first rest => + refine ⟨rationalMinimum first rest, rfl, ?_⟩ + rcases List.mem_cons.mp hvalue with rfl | hrest + · exact rationalMinimum_le_fallback _ _ + · exact rationalMinimum_le_member _ _ hrest + +theorem rationalWideStep_online_exists {nx ny M : ℕ} (parent : TargetInterval nx) + (representatives : List (ℕ × TargetInterval ny)) (P : ℕ) + (initial : TargetInterval ny → ℚ) (L delta : ℚ) + (old current : Fin M × TargetInterval ny → ℚ) + (groups online : List (PhysicalRationalAction M ny)) (q : TargetInterval ny) + (action : PhysicalRationalAction M ny) (haction : action ∈ online) : + ∃ value, rationalOnlineMinimum + (online.map (rationalActionValue (fun q r => targetEndpointDistance q r) L current q)) = some value ∧ + value ≤ rationalActionValue (fun q r => targetEndpointDistance q r) L current q action ∧ + (rationalWideStep parent representatives P initial L delta old current groups online q : ℝ) = + refinementUpdate (delta : ℝ) + (rationalWideStepCone parent representatives P initial L old current groups q : ℝ) (value : ℝ) := by + obtain ⟨value, hvalue, hle⟩ := rationalOnlineMinimum_le_member _ _ + (List.mem_map.mpr ⟨action, haction, rfl⟩) + refine ⟨value, hvalue, hle, ?_⟩ + rw [rationalWideStep, hvalue, rationalRefinementUpdate_cast] + +theorem rationalWideStepCone_le_group {nx ny M : ℕ} (parent : TargetInterval nx) + (representatives : List (ℕ × TargetInterval ny)) (P : ℕ) + (initial : TargetInterval ny → ℚ) (L : ℚ) + (old current : Fin M × TargetInterval ny → ℚ) + (groups : List (PhysicalRationalAction M ny)) (q : TargetInterval ny) + (action : PhysicalRationalAction M ny) (haction : action ∈ groups) : + rationalWideStepCone parent representatives P initial L old current groups q ≤ + rationalActionValue (fun q r => targetEndpointDistance q r) L current q action := + rationalMinimum_le_member _ _ (List.mem_map.mpr ⟨action, haction, rfl⟩) + +theorem rationalWideStepCone_le_wide {nx ny M : ℕ} (parent : TargetInterval nx) + (representatives : List (ℕ × TargetInterval ny)) (P : ℕ) + (initial : TargetInterval ny → ℚ) (L : ℚ) + (old current : Fin M × TargetInterval ny → ℚ) + (groups : List (PhysicalRationalAction M ny)) (q : TargetInterval ny) + (action : PhysicalRationalAction M ny) + (haction : action ∈ rationalActualWideActions parent representatives P) : + rationalWideStepCone parent representatives P initial L old current groups q ≤ + rationalActionValue (fun q r => targetEndpointDistance q r) L old q action := + (rationalMinimum_le_fallback _ _).trans (rationalBellman_le_action _ _ _ _ _ _ action haction) + +/-- The actual per-group failure test uses the rational estimated costs. -/ +def unskippedGroupFailure {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (b P thetaExponent : ℕ) (tau F : ℚ) + (child initial value : Fin M → TargetInterval target.length → ℚ) (Q : ℕ) + (members : List (UnskippedBand source target parent b P thetaExponent tau F child initial)) + (draw : ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) + (gamma : ℚ) : Bool := + members.any fun member => decide (gamma * b < + |dyadicUnskippedGroupEstimate Q value member draw - + rationalEndpointActionValue member.center member.rounded value|) + +theorem unskippedGroupFailure_false {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (b P thetaExponent : ℕ) (tau F : ℚ) + (child initial value : Fin M → TargetInterval target.length → ℚ) (Q : ℕ) + (members : List (UnskippedBand source target parent b P thetaExponent tau F child initial)) + (draw : ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) + (gamma : ℚ) (hfailure : unskippedGroupFailure source target parent b P thetaExponent tau F + child initial value Q members draw gamma = false) : + ∀ member ∈ members, |dyadicUnskippedGroupEstimate Q value member draw - + rationalEndpointActionValue member.center member.rounded value| ≤ gamma * b := by + intro member hmember + by_contra hnot + have hlt := lt_of_not_ge hnot + have htrue : unskippedGroupFailure source target parent b P thetaExponent tau F + child initial value Q members draw gamma = true := by + exact List.any_eq_true.mpr ⟨member, hmember, by simp only [hlt, decide_true]⟩ + rw [hfailure] at htrue + cases htrue + +/-- A selected group candidate in the actual list supplies the cone bound +on the literal estimator-success event. -/ +theorem rationalWideStepCone_group_bound {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (representatives : List (ℕ × TargetInterval target.length)) + (b P F thetaExponent Q : ℕ) (tau a : ℚ) + (parentInitial : TargetInterval target.length → ℚ) + (child initial : Fin M → TargetInterval target.length → ℚ) + (old current : Fin M × TargetInterval target.length → ℚ) (cell : ℕ × ℕ) + (hnonempty : cellUnskippedBands source target parent b P F thetaExponent tau a + parentInitial child initial cell ≠ []) + (draw : ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) + (specified : UnskippedBand source target parent b P thetaExponent tau F child initial) + (hspecified : specified ∈ cellUnskippedBands source target parent b P F thetaExponent tau a + parentInitial child initial cell) + (groups : List (PhysicalRationalAction M target.length)) + (hselected : (chooseUnskippedGroup Q (fun i s => current (i, s)) + (cellUnskippedBands source target parent b P F thetaExponent tau a parentInitial child initial cell) + hnonempty draw).rationalAction ∈ groups) + (delta L gamma : ℚ) (hF : 1 ≤ F) (hL : 2 ≤ L) (htau : 0 < tau) + (hspatial : ∀ i s t, current (i, s) ≤ (1 + delta) * current (i, t) + L * targetEndpointDistance s t) + (hfailure : unskippedGroupFailure source target parent b P thetaExponent tau F child initial + (fun i s => current (i, s)) Q + (cellUnskippedBands source target parent b P F thetaExponent tau a parentInitial child initial cell) + draw gamma = false) + (action : Fin M → TargetInterval target.length) (haction : action ∈ specified.actions) + (q : TargetInterval target.length) : + rationalWideStepCone parent representatives P parentInitial L old current groups q ≤ + L * targetEndpointDistance q specified.center + (1 + delta) * (∑ i, current (i, action i)) + + (2 * gamma + 512 * L * F * (2 : ℚ) ^ (-(thetaExponent : ℤ))) * b := by + have haccurate := unskippedGroupFailure_false source target parent b P thetaExponent tau F child initial + (fun i s => current (i, s)) Q _ draw gamma hfailure + exact (rationalWideStepCone_le_group parent representatives P parentInitial L old current groups q _ hselected).trans + (chooseCellGroup_cone_bound source target parent b P F thetaExponent Q tau a parentInitial child initial + (fun i s => current (i, s)) cell hnonempty draw specified hspecified delta L gamma hF hL htau + hspatial haccurate action haction q) + + +section PhysicalNode + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + +def physicalNodeChildren : PhysicalChildTables M target.length := fun i => + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow i) + +def physicalNodeGroups (t : ℕ) : List (PhysicalRationalAction M target.length) := + choices.groups node (physicalNodeChildren source target U N P F A T delta choices node hbelow) (t + 1) + +def physicalNodeOnline (t : ℕ) (q : TargetInterval target.length) : List (PhysicalRationalAction M target.length) := + choices.online node (physicalNodeChildren source target U N P F A T delta choices node hbelow) (t + 1) q + +def physicalNodeCone (t : ℕ) (q : TargetInterval target.length) : ℚ := + rationalWideStepCone (physicalSourceInterval source.length node) + (stageRepresentatives source target U N P F A node) P + (fun r => stageInitial source target U N P F A (node, r)) (128 * F) + (physicalBandHistory source target U N P F A T delta choices node hbelow t) + (physicalBandHistory source target U N P F A T delta choices node hbelow (t + 1)) + (physicalNodeGroups source target U N P F A T delta choices node hbelow t) q + +def physicalNodeOnlineValue (t : ℕ) (q : TargetInterval target.length) : ℚ := + (rationalOnlineMinimum ((physicalNodeOnline source target U N P F A T delta choices node hbelow t q).map + (rationalActionValue (fun q r => targetEndpointDistance q r) (128 * F) + (physicalBandHistory source target U N P F A T delta choices node hbelow (t + 1)) q))).getD 0 + +local notation "history" => physicalBandHistory source target U N P F A T delta choices node hbelow +local notation "groups" => physicalNodeGroups source target U N P F A T delta choices node hbelow +local notation "online" => physicalNodeOnline source target U N P F A T delta choices node hbelow +local notation "cone" => physicalNodeCone source target U N P F A T delta choices node hbelow +local notation "onlineValue" => physicalNodeOnlineValue source target U N P F A T delta choices node hbelow +local notation "parent" => physicalSourceInterval source.length node +local notation "representatives" => stageRepresentatives source target U N P F A node +local notation "initialParent" => fun r => stageInitial source target U N P F A (node, r) +local notation "L" => (128 * F : ℚ) + +/-- Literal candidate membership makes the online option present. -/ +theorem physicalNode_next_eq (hleaf : ¬ (parent).hi - (parent).lo ≤ 1) + (t : ℕ) (q : TargetInterval target.length) (action : PhysicalRationalAction M target.length) + (haction : action ∈ online t q) : + (physicalRefinement source target U N P F A T delta choices node (t + 1) q : ℝ) = + refinementUpdate (delta : ℝ) (cone t q : ℝ) (onlineValue t q : ℝ) := by + obtain ⟨value, hvalue, _, hstep⟩ := rationalWideStep_online_exists parent representatives P initialParent L delta + (history t) (history (t + 1)) (groups t) (online t q) q action haction + rw [physicalRefinement_succ source target U N P F A T delta choices node hbelow hleaf] + change (rationalWideStep parent representatives P initialParent L delta + (history t) (history (t + 1)) (groups t) (online t q) q : ℝ) = _ + rw [hstep] + congr 1 + simp only [physicalNodeOnlineValue, hvalue, Option.getD_some] + +/-- The actual online minimum is at most any listed shared band action. -/ +theorem physicalNode_online_le (t : ℕ) (q r : TargetInterval target.length) + (action : Fin M → TargetInterval target.length) + (haction : sharedBandRationalAction r action ∈ online t q) : + (onlineValue t q : ℝ) ≤ (L : ℝ) * targetEndpointDistance q r + + ∑ i, (history (t + 1) (i, action i) : ℝ) := by + obtain ⟨value, hvalue, hle⟩ := rationalOnlineMinimum_le_member + ((online t q).map (rationalActionValue (fun q r => targetEndpointDistance q r) L (history (t + 1)) q)) + (rationalActionValue (fun q r => targetEndpointDistance q r) L (history (t + 1)) q + (sharedBandRationalAction r action)) + (List.mem_map.mpr ⟨sharedBandRationalAction r action, haction, rfl⟩) + have hvalueEq : onlineValue t q = value := by + simp only [physicalNodeOnlineValue, hvalue, Option.getD_some] + rw [hvalueEq] + simpa only [rationalActionValue, sharedBandRationalAction, Rat.cast_add, Rat.cast_mul, + Rat.cast_sum, Rat.cast_natCast, Rat.cast_zero, add_zero] using (Rat.cast_le (K := ℝ)).mpr hle + +/-- The old-index wide candidate remains one of the literal cone options. -/ +theorem physicalNode_cone_le_old (b : ℕ) (tau theta : ℚ) (r q : TargetInterval target.length) + (child : Fin M → TargetInterval target.length → ℚ) (hrep : (b, r) ∈ representatives) + (action : Fin M → TargetInterval target.length) + (haction : action ∈ representativeBandActions source target parent r b P tau theta child) (t : ℕ) : + (cone t q : ℝ) ≤ (L : ℝ) * targetEndpointDistance q r + ∑ i, (history t (i, action i) : ℝ) := by + have hwide := sharedBandRationalAction_wide source target parent r representatives b P tau theta + child hrep action haction + have hcone := rationalWideStepCone_le_wide parent representatives P initialParent L + (history t) (history (t + 1)) (groups t) q _ hwide + simpa only [physicalNodeCone, rationalActionValue, sharedBandRationalAction, + Rat.cast_add, Rat.cast_mul, Rat.cast_sum, Rat.cast_natCast, Rat.cast_zero, add_zero] using + (Rat.cast_le (K := ℝ)).mpr hcone + +/-- True cost is bounded by the actual connection charge and clipped +comparison children; no assumption about clipped warmup masses is needed. -/ +theorem physicalNode_comparison_lower (hM : 0 < M) (hF : 1 ≤ F) + (b : ℕ) (tau theta : ℚ) (r q : TargetInterval target.length) + (child : Fin M → TargetInterval target.length → ℚ) + (comparison : Fin M → TargetInterval target.length) + (hc : comparison ∈ representativeBandActions source target parent r b P tau theta child) (t : ℕ) : + (stateEditCost (physicalSource source node) target q : ℝ) ≤ + (L : ℝ) * targetEndpointDistance q r + ∑ i, + max (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (comparison i) : ℝ) + (history t (i, comparison i) : ℝ) := by + have hzero := representativeBandActions_zero_connection source target parent r b P tau theta child comparison hc + have hsplit := zero_connection_cost_sum_lower source target hM parent r comparison hzero + have hspatial : (stateEditCost (physicalSource source node) target q : ℝ) ≤ + stateEditCost (physicalSource source node) target r + (targetEndpointDistance q r : ℝ) := by + exact_mod_cast stateEditCost_spatial (physicalSource source node) target q r + have hsum : (∑ i, (stateEditCost + (physicalSource source (physicalChild node hbelow i)) target (comparison i) : ℝ)) ≤ + ∑ i, max (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (comparison i) : ℝ) + (history t (i, comparison i) : ℝ) := sum_le_sum fun i _ => le_max_left _ _ + have hLR : (1 : ℝ) ≤ (L : ℝ) := by + have hFQ : (1 : ℚ) ≤ F := by exact_mod_cast hF + simpa only [Rat.cast_one] using + (Rat.cast_le (K := ℝ)).mpr (by linarith only [hFQ] : (1 : ℚ) ≤ L) + have hcharge := mul_le_mul_of_nonneg_right hLR (Nat.cast_nonneg (α := ℝ) (targetEndpointDistance q r)) + change (stateEditCost (physicalSource source node) target r : ℝ) ≤ + ∑ i, (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (comparison i) : ℝ) at hsplit + linarith only [hsplit, hspatial, hsum, hcharge] + + +noncomputable def physicalComparisonClipped + (comparison : Fin M → TargetInterval target.length) (t : ℕ) : ℝ := + ∑ i, max (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (comparison i) : ℝ) + (history t (i, comparison i) : ℝ) + +def physicalNodeCellBands (b thetaExponent : ℕ) (tau : ℚ) (cell : ℕ × ℕ) := + cellUnskippedBands source target parent b P F thetaExponent tau (refinementFactor A F) + initialParent (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) cell + +def physicalNodeSelectedGroup (b thetaExponent Q : ℕ) (tau : ℚ) (cell : ℕ × ℕ) + (hnonempty : physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell ≠ []) + (t : ℕ) (draw : ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) := + chooseUnskippedGroup Q (fun i s => history (t + 1) (i, s)) + (physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell) hnonempty draw + +def physicalNodeGroupFailure (b thetaExponent Q : ℕ) (tau : ℚ) (cell : ℕ × ℕ) + (t : ℕ) (draw : ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) (gamma : ℚ) : Bool := + unskippedGroupFailure source target parent b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (fun i s => history (t + 1) (i, s)) Q + (physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell) draw gamma + +variable (hM : 0 < M) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (hT : 0 < T) + +include hM hsize hP hF hA hseed hT in +/-- The selected whole-cell representative supplies the actual physical +cone inequality on the actual estimator-success event. -/ +theorem physicalNode_group_bound (b thetaExponent Q : ℕ) (tau gamma : ℚ) + (htau : 0 < tau) (hdelta : 0 ≤ delta) (cell : ℕ × ℕ) + (hnonempty : physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell ≠ []) + (specified : UnskippedBand source target parent b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow)) + (hspecified : specified ∈ physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell) + (t : ℕ) (draw : ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) + (hselected : (physicalNodeSelectedGroup source target U N P F A T delta choices node hbelow + b thetaExponent Q tau cell hnonempty t draw).rationalAction ∈ groups t) + (hfailure : physicalNodeGroupFailure source target U N P F A T delta choices node hbelow + b thetaExponent Q tau cell t draw gamma = false) + (action : Fin M → TargetInterval target.length) (haction : action ∈ specified.actions) + (q : TargetInterval target.length) : + (cone t q : ℝ) ≤ (1 + (delta : ℝ)) * + ((L : ℝ) * targetEndpointDistance q specified.center + ∑ i, (history (t + 1) (i, action i) : ℝ)) + + ((2 * gamma + 512 * L * F * (2 : ℚ) ^ (-(thetaExponent : ℤ)) : ℚ) : ℝ) * b := by + have hLR : (2 : ℚ) ≤ L := by + have hFQ : (1 : ℚ) ≤ F := by exact_mod_cast hF + linarith only [hFQ] + have hgroup := rationalWideStepCone_group_bound source target parent representatives b P F thetaExponent Q tau + (refinementFactor A F) initialParent + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (history t) (history (t + 1)) cell hnonempty draw specified hspecified (groups t) hselected + delta L gamma hF hLR htau + (fun i s s' => physicalRefinement_spatial source target hM U N P F A hsize hP hF hA hseed + T hT delta hdelta choices (physicalChild node hbelow i) (t + 1) s s') + hfailure action haction q + have hcharge : (0 : ℚ) ≤ L * targetEndpointDistance q specified.center := + mul_nonneg (by linarith only [hLR]) (Nat.cast_nonneg _) + have hslack := mul_nonneg hdelta hcharge + have hbound : cone t q ≤ (1 + delta) * + (L * targetEndpointDistance q specified.center + ∑ i, history (t + 1) (i, action i)) + + (2 * gamma + 512 * L * F * (2 : ℚ) ^ (-(thetaExponent : ℤ))) * b := by + change cone t q ≤ _ at hgroup + nlinarith only [hgroup, hslack] + exact_mod_cast hbound + + +include hM hsize hP hF hA hseed hT in + theorem physicalNode_clipped_upper (t : ℕ) (q : TargetInterval target.length) : + max (stateEditCost (physicalSource source node) target q : ℝ) + (physicalRefinement source target U N P F A T delta choices node t q : ℝ) ≤ + 2 * (F : ℝ) * stateEditCost (physicalSource source node) target q := by + have hstage := physicalRefinement_stage_bounds source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q + have hupperQ := (hstage.2.1.trans (hstage.2.2.1.trans hstage.2.2.2.1)).trans hstage.2.2.2.2 + have hupper : (physicalRefinement source target U N P F A T delta choices node t q : ℝ) ≤ + 2 * (F : ℝ) * stateEditCost (physicalSource source node) target q := by exact_mod_cast hupperQ + have hFR : (1 : ℝ) ≤ F := by exact_mod_cast hF + have hc : (0 : ℝ) ≤ stateEditCost (physicalSource source node) target q := Nat.cast_nonneg _ + exact max_le (by nlinarith only [hFR, hc]) hupper + +include hM hsize hP hF hA hseed hT in +/-- Deterministic first-crossing transfer for the complete physical +recurrence, using its actual sampled candidate lists and group-error test. -/ +theorem physicalNode_firstCrossing_regret + (hleaf : ¬ (parent).hi - (parent).lo ≤ 1) + (b thetaExponent Q : ℕ) (tau gamma κ : ℚ) (htau : 0 < tau) + (hdelta : 0 < delta) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (cell : ℕ × ℕ) + (hnonempty : physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell ≠ []) + (specified : UnskippedBand source target parent b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow)) + (hspecified : specified ∈ physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell) + (hrep : (b, specified.center) ∈ representatives) + (q : TargetInterval target.length) + (hb : (b : ℝ) ≤ stateEditCost (physicalSource source node) target q) + (comparison : Fin M → TargetInterval target.length) (hc : comparison ∈ specified.actions) + (sample : ℕ → Fin M → TargetInterval target.length) (hsample : ∀ t, sample t ∈ specified.actions) + (draw : ℕ → ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) + (honline : ∀ t, sharedBandRationalAction specified.center (sample t) ∈ online t q) + (hselected : ∀ t, (physicalNodeSelectedGroup source target U N P F A T delta choices node hbelow + b thetaExponent Q tau cell hnonempty t (draw t)).rationalAction ∈ groups t) + (herror : 2 * gamma + 512 * L * F * (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ κ * delta) + (S : ℕ) : + let c : ℝ := stateEditCost (physicalSource source node) target q + let charge : ℝ := (L : ℝ) * targetEndpointDistance q specified.center + let clipped := physicalComparisonClipped source target U N P F A T delta choices node hbelow comparison + let failure := fun t => physicalNodeGroupFailure source target U N P F A T delta choices node hbelow + b thetaExponent Q tau cell t (draw t) gamma + let crossing := firstCrossing specified.actions.toFinset S + (fun t => bandActionCost charge (fun t coordinate => (history t coordinate : ℝ)) (t + 1)) c + (∑ t ∈ range S, + (max c (physicalRefinement source target U N P F A T delta choices node (t + 1) q : ℝ) - + charge - clipped (t + 1))) ≤ + (∑ t ∈ range crossing, sampledPrefixRegret charge (κ : ℝ) + (fun t coordinate => (history t coordinate : ℝ)) clipped sample t) + + 2 * (delta : ℝ) * c + 2 * (F : ℝ) * c * + ∑ t ∈ range S, (if failure t then (1 : ℝ) else 0) := by + let c : ℝ := stateEditCost (physicalSource source node) target q + let charge : ℝ := (L : ℝ) * targetEndpointDistance q specified.center + let table := fun t coordinate => (history t coordinate : ℝ) + let clipped := physicalComparisonClipped source target U N P F A T delta choices node hbelow comparison + let failure := fun t => physicalNodeGroupFailure source target U N P F A T delta choices node hbelow + b thetaExponent Q tau cell t (draw t) gamma + let error : ℚ := 2 * gamma + 512 * L * F * (2 : ℚ) ^ (-(thetaExponent : ℤ)) + have hc0 : 0 ≤ c := Nat.cast_nonneg _ + have hFR : (1 : ℝ) ≤ F := by exact_mod_cast hF + have hδR : (0 : ℝ) < delta := (Rat.cast_pos (K := ℝ)).mpr hdelta + have hκR : (0 : ℝ) ≤ κ := (Rat.cast_nonneg (K := ℝ)).mpr hκ + have hκone : (κ : ℝ) ≤ 1 := by + have h := (Rat.cast_le (K := ℝ)).mpr hκhalf + norm_num only [Rat.cast_div, Rat.cast_one, Rat.cast_ofNat] at h + linarith only [h] + have herrorQ : error ≤ κ * delta := herror + have herrorR : (error : ℝ) ≤ (κ : ℝ) * delta := by + simpa only [Rat.cast_mul] using (Rat.cast_le (K := ℝ)).mpr herrorQ + have herrorScaled := mul_le_mul_of_nonneg_right herrorR (Nat.cast_nonneg (α := ℝ) b) + have hκδ := mul_le_mul_of_nonneg_right hκone hδR.le + have hκδb := mul_le_mul_of_nonneg_right hκδ (Nat.cast_nonneg (α := ℝ) b) + have hδbc := mul_le_mul_of_nonneg_left hb hδR.le + have herrorCross : (error : ℝ) * b ≤ (delta : ℝ) * c := by + nlinarith only [herrorScaled, hκδb, hδbc] + have hnext (t : ℕ) := physicalNode_next_eq source target U N P F A T delta choices node hbelow + hleaf t q _ (honline t) + dsimp only + simp_rw [hnext] + apply refinement_firstCrossing_regret specified.actions.toFinset S table clipped sample + (fun t => (cone t q : ℝ)) (fun t => (onlineValue t q : ℝ)) failure charge c b F delta κ error + hc0 hFR hδR hκR hb herrorScaled herrorCross + · intro action _ + apply antitone_nat_of_succ_le + intro t + unfold bandActionCost + apply add_le_add le_rfl + apply sum_le_sum + intro i _ + exact (Rat.cast_le (K := ℝ)).mpr + (physicalBandHistory_nonincreasing source target U N P F A T delta choices node hbelow t (i, action i)) + · intro t _ + exact List.mem_toFinset.mpr (hsample t) + · intro t _ + exact physicalNode_comparison_lower source target U N P F A T delta choices node hbelow hM hF + b tau ((2 : ℚ) ^ (-(thetaExponent : ℤ))) specified.center q + (physicalBandChildMassTable source target U N P F A T node hbelow) comparison hc t + · intro t _ + exact physicalNode_online_le source target U N P F A T delta choices node hbelow t q specified.center + (sample t) (honline t) + · intro t _ action ha + exact physicalNode_cone_le_old source target U N P F A T delta choices node hbelow + b tau ((2 : ℚ) ^ (-(thetaExponent : ℤ))) specified.center q + (physicalBandChildMassTable source target U N P F A T node hbelow) hrep action + (List.mem_toFinset.mp ha) t + · intro t _ hf action ha + exact physicalNode_group_bound source target U N P F A T delta choices node hbelow hM hsize hP hF hA hseed hT + b thetaExponent Q tau gamma htau hdelta.le cell hnonempty specified hspecified t (draw t) + (hselected t) hf action (List.mem_toFinset.mp ha) q + · intro t _ + rw [← hnext t] + exact physicalNode_clipped_upper source target U N P F A T delta choices node hM hsize hP hF hA hseed hT + (t + 1) q + +end PhysicalNode + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalOnlineBand.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalOnlineBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..857efa7b75b6357a508dd4509dd8279b73a309a3 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalOnlineBand.lean @@ -0,0 +1,453 @@ +import OAI.Combinatorics.EditApproximation.Geometry.ListBandRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementSpatial +import OAI.Combinatorics.EditApproximation.Geometry.BandGroupSampling + +namespace OAI + +/-! +# Online actions from the actual physical child histories + +The fixed representative band uses the rational warmup-average child +table. Its envelopes scan the literal initial child table. Online gains +and decrements are computed from the full physical refinement histories. +-/ + +namespace EditApproximation + +open Finset + +theorem bandCoordinate_restriction {β σ : Type*} [Fintype β] [DecidableEq β] [DecidableEq σ] + (band : List (β → σ)) (coordinate : β × σ) + (hcoordinate : coordinate ∈ bandCoordinates (band).toFinset) : + ∃ action ∈ band, action coordinate.1 = coordinate.2 := by + obtain ⟨action, haction, hcoordinate⟩ := mem_biUnion.mp hcoordinate + obtain ⟨child, _, hequal⟩ := mem_image.mp hcoordinate + cases hequal + exact ⟨action, List.mem_toFinset.mp haction, rfl⟩ + +theorem representativeBandActions_wide {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (r : TargetInterval target.length) + (b P : ℕ) (tau theta : ℚ) (child : Fin M → TargetInterval target.length → ℚ) + (action : Fin M → TargetInterval target.length) + (haction : action ∈ representativeBandActions source target parent r b P tau theta child) : + action ∈ wideActionList M parent r b P := by + by_cases hwide : wideActionList M parent r b P = [] + · simp only [representativeBandActions, dite_eq_left hwide, List.not_mem_nil] at haction + · by_cases hZ : 0 < rationalWideActionMinimum parent r b P hwide child + · simp only [representativeBandActions, dite_eq_right hwide, ite_eq_left hZ] at haction + exact (computedBandActions_mem parent r b P tau theta _ child action haction).choose_spec.1 + · simp only [representativeBandActions, dite_eq_right hwide, ite_eq_right hZ, List.not_mem_nil] at haction + +theorem representativeBandActions_diameter {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (r : TargetInterval target.length) + (b P : ℕ) (tau theta : ℚ) (htau : 0 < tau) (htheta : 0 ≤ theta) + (child : Fin M → TargetInterval target.length → ℚ) + (first second : Fin M → TargetInterval target.length) + (hfirst : first ∈ representativeBandActions source target parent r b P tau theta child) + (hsecond : second ∈ representativeBandActions source target parent r b P tau theta child) (i : Fin M) : + (targetEndpointDistance (first i) (second i) : ℝ) ≤ 4 * (theta : ℝ) * b / M := by + by_cases hwide : wideActionList M parent r b P = [] + · simp only [representativeBandActions, dite_eq_left hwide, List.not_mem_nil] at hfirst + · by_cases hZ : 0 < rationalWideActionMinimum parent r b P hwide child + · simp only [representativeBandActions, dite_eq_right hwide, ite_eq_left hZ] at hfirst hsecond + exact computedBand_child_endpoint_diameter parent r b P tau theta _ htau htheta child + first second hfirst hsecond i + · simp only [representativeBandActions, dite_eq_right hwide, ite_eq_right hZ, List.not_mem_nil] at hfirst + + +theorem canonicalRoundedBandAction_congr {ny M : ℕ} (thetaExponent b : ℕ) + (first second : List (Fin M → TargetInterval ny)) + (hfirst : first ≠ []) (hsecond : second ≠ []) + (initial : Fin M → TargetInterval ny → ℚ) (hequal : first = second) : + canonicalRoundedBandAction thetaExponent b first hfirst initial = + canonicalRoundedBandAction thetaExponent b second hsecond initial := by + subst second + rfl + +/-- The representative wrapper preserves the literal rounded-band cost bound. -/ +theorem representativeBandActions_canonical_cost {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (r : TargetInterval target.length) + (thetaExponent b P : ℕ) (tau : ℚ) (htau : 0 < tau) + (child initial value : Fin M → TargetInterval target.length → ℚ) + (hnonempty : representativeBandActions source target parent r b P tau + ((2 : ℚ) ^ (-(thetaExponent : ℤ))) child ≠ []) + (action : Fin M → TargetInterval target.length) + (haction : action ∈ representativeBandActions source target parent r b P tau + ((2 : ℚ) ^ (-(thetaExponent : ℤ))) child) + (delta L : ℚ) (hL : 0 ≤ L) + (hspatial : ∀ i s t, value i s ≤ (1 + delta) * value i t + L * targetEndpointDistance s t) : + let band := representativeBandActions source target parent r b P tau + ((2 : ℚ) ^ (-(thetaExponent : ℤ))) child + rationalEndpointActionValue r (canonicalRoundedBandAction thetaExponent b band hnonempty initial) value ≤ + (1 + delta) * (∑ i, value i (action i)) + + (6 * L + 2) * (2 : ℚ) ^ (-(thetaExponent : ℤ)) * ∑ i, bandChildEnvelope b band initial i := by + by_cases hwide : wideActionList M parent r b P = [] + · simp only [representativeBandActions, dite_eq_left hwide, List.not_mem_nil] at haction + · by_cases hZ : 0 < rationalWideActionMinimum parent r b P hwide child + · let velocity := rationalStateGap (substring source parent.lo parent.hi) target r / + rationalWideActionMinimum parent r b P hwide child + have hequal : representativeBandActions source target parent r b P tau + ((2 : ℚ) ^ (-(thetaExponent : ℤ))) child = + computedBandActions parent r b P tau ((2 : ℚ) ^ (-(thetaExponent : ℤ))) velocity child := by + simp only [representativeBandActions, dite_eq_right hwide, ite_eq_left hZ, velocity] + have hn : computedBandActions parent r b P tau + ((2 : ℚ) ^ (-(thetaExponent : ℤ))) velocity child ≠ [] := by + rw [← hequal] + exact hnonempty + have ha : action ∈ computedBandActions parent r b P tau + ((2 : ℚ) ^ (-(thetaExponent : ℤ))) velocity child := hequal ▸ haction + have hbound := canonicalRoundedBandAction_cost parent r thetaExponent b P tau velocity htau + child initial value hn action ha delta L hL hspatial + have hcanonical := canonicalRoundedBandAction_congr thetaExponent b _ _ hnonempty hn initial hequal + dsimp only + rw [hcanonical] + simpa only [hequal] using hbound + · simp only [representativeBandActions, dite_eq_right hwide, ite_eq_right hZ, List.not_mem_nil] at haction + + +section PhysicalBand + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + +def physicalBandChildInitial (i : Fin M) (s : TargetInterval target.length) : ℚ := + stageInitial source target U N P F A (physicalChild node hbelow i, s) + +def physicalBandChildMassTable (i : Fin M) (s : TargetInterval target.length) : ℚ := + stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) + +def physicalBandHistory (t : ℕ) (coordinate : Fin M × TargetInterval target.length) : ℚ := + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow coordinate.1) t coordinate.2 + +def physicalBandActions (b thetaExponent : ℕ) (tau : ℚ) (r : TargetInterval target.length) : + List (Fin M → TargetInterval target.length) := + representativeBandActions source target (physicalSourceInterval source.length node) r b P tau + ((2 : ℚ) ^ (-(thetaExponent : ℤ))) (physicalBandChildMassTable source target U N P F A T node hbelow) + +def physicalBandEnvelope (b thetaExponent : ℕ) (tau : ℚ) (r : TargetInterval target.length) (i : Fin M) : ℚ := + bandChildEnvelope b (physicalBandActions source target U N P F A T node hbelow b thetaExponent tau r) + (physicalBandChildInitial source target U N P F A node hbelow) i + +variable (b thetaExponent : ℕ) (tau : ℚ) (r : TargetInterval target.length) + +local notation "band" => physicalBandActions source target U N P F A T node hbelow b thetaExponent tau r +local notation "mass" => physicalBandEnvelope source target U N P F A T node hbelow b thetaExponent tau r +local notation "history" => physicalBandHistory source target U N P F A T delta choices node hbelow +local notation "initial" => physicalBandChildInitial source target U N P F A node hbelow +local notation "theta" => (2 : ℚ) ^ (-(thetaExponent : ℤ)) + +theorem physicalBandEnvelope_pos (i : Fin M) : 0 < mass i := + bandChildEnvelope_pos b band initial i + +theorem physicalBandHistory_nonincreasing (t : ℕ) (coordinate : Fin M × TargetInterval target.length) : + history (t + 1) coordinate ≤ history t coordinate := + physicalRefinement_nonincreasing source target U N P F A T delta choices + (physicalChild node hbelow coordinate.1) t coordinate.2 + +variable (hM : 0 < M) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (hT : 0 < T) + +include hM hsize hP hF hA hseed hT in + theorem physicalBandHistory_bounds (t : ℕ) (coordinate : Fin M × TargetInterval target.length) + (hcoordinate : coordinate ∈ bandCoordinates (band).toFinset) : + 0 ≤ history t coordinate ∧ history t coordinate ≤ mass coordinate.1 := by + obtain ⟨action, haction, hequal⟩ := bandCoordinate_restriction band coordinate hcoordinate + have hstage := physicalRefinement_stage_bounds source target hM U N P F A hsize hP hF hA hseed + T hT delta choices (physicalChild node hbelow coordinate.1) t coordinate.2 + have hupper := (bandChildEnvelope_lower b band initial coordinate.1).2 action haction + change initial coordinate.1 (action coordinate.1) ≤ mass coordinate.1 at hupper + rw [hequal] at hupper + exact ⟨physicalRefinement_nonneg source target hM U N P F A hsize hP hF hA hseed + T hT delta choices (physicalChild node hbelow coordinate.1) t coordinate.2, + (hstage.2.1.trans (hstage.2.2.1.trans hstage.2.2.2.1)).trans hupper⟩ + +theorem physicalBand_coordinate_distance (htau : 0 < tau) + (first second : Fin M × TargetInterval target.length) + (hfirst : first ∈ bandCoordinates (band).toFinset) (hsecond : second ∈ bandCoordinates (band).toFinset) + (hsame : first.1 = second.1) : + (targetEndpointDistance first.2 second.2 : ℝ) ≤ 4 * (theta : ℝ) * (mass first.1 : ℝ) := by + obtain ⟨action, haction, hactionState⟩ := bandCoordinate_restriction band first hfirst + obtain ⟨action', haction', hactionState'⟩ := bandCoordinate_restriction band second hsecond + rw [← hsame] at hactionState' + have htheta : 0 ≤ theta := (zpow_pos (by norm_num : (0 : ℚ) < 2) _).le + have hdiameter := representativeBandActions_diameter source target + (physicalSourceInterval source.length node) r b P tau theta htau htheta + (physicalBandChildMassTable source target U N P F A T node hbelow) + action action' haction haction' first.1 + rw [hactionState, hactionState'] at hdiameter + have hfloorQ : (b : ℚ) / M ≤ mass first.1 := (bandChildEnvelope_lower b band initial first.1).1 + have hfloor : (b : ℝ) / M ≤ (mass first.1 : ℝ) := by + simpa only [Rat.cast_div, Rat.cast_natCast] using (Rat.cast_le (K := ℝ)).mpr hfloorQ + have hweighted := mul_le_mul_of_nonneg_left hfloor + (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) ((Rat.cast_nonneg (K := ℝ)).mpr htheta)) + simp only [Rat.cast_zpow] at hdiameter hweighted ⊢ + calc + _ ≤ 4 * (theta : ℝ) * ((b : ℝ) / M) := by simpa only [mul_div_assoc] using hdiameter + _ ≤ _ := hweighted + +include hM hsize hP hF hA hseed hT in + theorem physicalBand_decrement_total (S : ℕ) (coordinate : Fin M × TargetInterval target.length) + (hcoordinate : coordinate ∈ bandCoordinates (band).toFinset) : + (∑ t ∈ range S, (childDecrement mass history t coordinate : ℝ)) ≤ 1 := by + exact childDecrement_total_le mass history S coordinate + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r coordinate.1) + (physicalBandHistory_bounds source target U N P F A T delta choices node hbelow b thetaExponent tau r + hM hsize hP hF hA hseed hT S coordinate hcoordinate).1 + (physicalBandHistory_bounds source target U N P F A T delta choices node hbelow b thetaExponent tau r + hM hsize hP hF hA hseed hT 0 coordinate hcoordinate).2 + + +include hM hsize hP hF hA hseed hT in + theorem physicalBandHistory_absolute (htau : 0 < tau) (hdelta : 0 ≤ delta) + (t : ℕ) (first second : Fin M × TargetInterval target.length) + (hfirst : first ∈ bandCoordinates (band).toFinset) (hsecond : second ∈ bandCoordinates (band).toFinset) + (hsame : first.1 = second.1) : + |(history t first : ℝ) - (history t second : ℝ)| ≤ + (delta : ℝ) * (mass first.1 : ℝ) + + 4 * ((128 * F : ℚ) : ℝ) * (theta : ℝ) * (mass first.1 : ℝ) := by + have hfirstBounds := physicalBandHistory_bounds source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT t first hfirst + have hsecondBounds := physicalBandHistory_bounds source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT t second hsecond + have hmassSame : mass second.1 = mass first.1 := congrArg (fun child => mass child) hsame.symm + rw [hmassSame] at hsecondBounds + have hforward : history t first ≤ (1 + delta) * history t second + + (128 * F : ℚ) * targetEndpointDistance first.2 second.2 := by + simpa only [physicalBandHistory, hsame] using physicalRefinement_spatial source target hM U N P F A + hsize hP hF hA hseed T hT delta hdelta choices (physicalChild node hbelow first.1) t first.2 second.2 + have hbackward : history t second ≤ (1 + delta) * history t first + + (128 * F : ℚ) * targetEndpointDistance second.2 first.2 := by + simpa only [physicalBandHistory, hsame] using physicalRefinement_spatial source target hM U N P F A + hsize hP hF hA hseed T hT delta hdelta choices (physicalChild node hbelow second.1) t second.2 first.2 + have hsym : targetEndpointDistance second.2 first.2 = targetEndpointDistance first.2 second.2 := by + unfold targetEndpointDistance + rw [Nat.dist_comm second.2.lo, Nat.dist_comm second.2.hi] + rw [hsym] at hbackward + have hforwardR : (history t first : ℝ) ≤ (1 + (delta : ℝ)) * (history t second : ℝ) + + ((128 * F : ℚ) : ℝ) * targetEndpointDistance first.2 second.2 := by exact_mod_cast hforward + have hbackwardR : (history t second : ℝ) ≤ (1 + (delta : ℝ)) * (history t first : ℝ) + + ((128 * F : ℚ) : ℝ) * targetEndpointDistance first.2 second.2 := by exact_mod_cast hbackward + have habsolute := multiplicative_spatial_absolute + ((Rat.cast_nonneg (K := ℝ)).mpr hdelta) + ((Rat.cast_le (K := ℝ)).mpr hfirstBounds.2) ((Rat.cast_le (K := ℝ)).mpr hsecondBounds.2) + hforwardR hbackwardR + have hdiameter := physicalBand_coordinate_distance source target U N P F A T node hbelow + b thetaExponent tau r htau first second hfirst hsecond hsame + have hL : (0 : ℝ) ≤ ((128 * F : ℚ) : ℝ) := by positivity + have hcharge := mul_le_mul_of_nonneg_left hdiameter hL + nlinarith only [habsolute, hcharge] + +include hM hsize hP hF hA hseed hT in + theorem physicalBand_decrement_range (htau : 0 < tau) (hdelta : 0 ≤ delta) + (t : ℕ) (first second : Fin M × TargetInterval target.length) + (hfirst : first ∈ bandCoordinates (band).toFinset) (hsecond : second ∈ bandCoordinates (band).toFinset) + (hsame : first.1 = second.1) : + |(childDecrement mass history t first : ℝ) - (childDecrement mass history t second : ℝ)| ≤ + 2 * (delta : ℝ) + 8 * ((128 * F : ℚ) : ℝ) * (theta : ℝ) := by + have hmass : (0 : ℝ) < (mass first.1 : ℝ) := + (Rat.cast_pos (K := ℝ)).mpr (physicalBandEnvelope_pos source target U N P F A T node hbelow + b thetaExponent tau r first.1) + have hold := physicalBandHistory_absolute source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT htau hdelta t first second hfirst hsecond hsame + have hnew := physicalBandHistory_absolute source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT htau hdelta (t + 1) first second hfirst hsecond hsame + have hrange := normalized_decrement_range hmass hold hnew + have hcancel : 2 * (4 * ((128 * F : ℚ) : ℝ) * (theta : ℝ) * (mass first.1 : ℝ)) / + (mass first.1 : ℝ) = 8 * ((128 * F : ℚ) : ℝ) * (theta : ℝ) := by + calc + _ = 2 * (4 * ((128 * F : ℚ) : ℝ) * (theta : ℝ)) * + ((mass first.1 : ℝ) / (mass first.1 : ℝ)) := by ring + _ = _ := by rw [div_self hmass.ne']; ring + rw [hcancel] at hrange + simp only [childDecrement, Rat.cast_div, Rat.cast_sub, ← hsame] + exact hrange + +include hM hsize hP hF hA hseed hT in + theorem physicalBand_gain_bounds (κ : ℚ) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (t : ℕ) (coordinate : Fin M × TargetInterval target.length) + (hcoordinate : coordinate ∈ bandCoordinates (band).toFinset) : + -1 ≤ (childGain mass history t coordinate : ℝ) + + (1 - (κ : ℝ)) * childDecrement mass history t coordinate ∧ + (childGain mass history t coordinate : ℝ) + + (1 - (κ : ℝ)) * childDecrement mass history t coordinate ≤ 0 := by + exact childGain_decrement_bounds mass history κ t coordinate + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r coordinate.1) + hκ (by linarith only [hκhalf]) + (physicalBandHistory_bounds source target U N P F A T delta choices node hbelow b thetaExponent tau r + hM hsize hP hF hA hseed hT t coordinate hcoordinate) + (physicalBandHistory_bounds source target U N P F A T delta choices node hbelow b thetaExponent tau r + hM hsize hP hF hA hseed hT (t + 1) coordinate hcoordinate) + + +/-- The exact action sampler retains the order of the literal physical band. -/ +def physicalBandOnlineDraw (hband : band ≠ []) (η κ : ℚ) (G K t : ℕ) + (integer : Fin (optimizerTriangularMass K)) : Fin M → TargetInterval target.length := + finiteOptimizerActionDraw band hband mass + (rationalOnlineLinear η κ (childGain mass history) (childDecrement mass history) t) G K integer + +theorem physicalBandOnlineDraw_mem (hband : band ≠ []) (η κ : ℚ) (G K t : ℕ) + (integer : Fin (optimizerTriangularMass K)) : + physicalBandOnlineDraw source target U N P F A T delta choices node hbelow + b thetaExponent tau r hband η κ G K t integer ∈ band := + finiteOptimizerActionDraw_mem band hband mass _ G K integer + +theorem physicalBandOnlineDraw_wide (hband : band ≠ []) (η κ : ℚ) (G K t : ℕ) + (integer : Fin (optimizerTriangularMass K)) : + physicalBandOnlineDraw source target U N P F A T delta choices node hbelow + b thetaExponent tau r hband η κ G K t integer ∈ + wideActionList M (physicalSourceInterval source.length node) r b P := by + exact representativeBandActions_wide source target (physicalSourceInterval source.length node) + r b P tau theta (physicalBandChildMassTable source target U N P F A T node hbelow) _ + (physicalBandOnlineDraw_mem source target U N P F A T delta choices node hbelow + b thetaExponent tau r hband η κ G K t integer) + +include hM in +/-- Exact conditional mean: only the current finite integer draw is averaged. -/ +theorem physicalBandOnlineDraw_child_cost_mean (hband : band ≠ []) (η κ : ℚ) + (G K t : ℕ) (hK : 0 < K) : + uniformMean (fun integer : Fin (optimizerTriangularMass K) => + let action := physicalBandOnlineDraw source target U N P F A T delta choices node hbelow + b thetaExponent tau r hband η κ G K t integer + (∑ child, (history (t + 1) (child, action child) : ℝ)) + + (κ : ℝ) * ((∑ child, (history t (child, action child) : ℝ)) - + ∑ child, (history (t + 1) (child, action child) : ℝ))) = + -((∑ child, mass child : ℚ) : ℝ) * + ∑ coordinate ∈ bandCoordinates (band).toFinset, + ((childGain mass history t coordinate : ℝ) + + (1 - (κ : ℝ)) * childDecrement mass history t coordinate) * + (finiteRationalOptimizer (bandCoordinates (band).toFinset) + ((band).map (actionVector mass)) + (rationalOnlineLinear η κ (childGain mass history) (childDecrement mass history) t) + G K coordinate : ℝ) := by + let : Nonempty (Fin M) := ⟨⟨0, hM⟩⟩ + exact finiteOptimizerActionDraw_child_cost_mean band hband mass + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r) + history κ t _ G K hK + +include hM in + theorem physicalBandOnlineDraw_computed_mean (hband : band ≠ []) (η κ : ℚ) + (G K H t : ℕ) (hG : G = H + (bandCoordinates (band).toFinset).card + 2) + (hK : K = G ^ 80) (hH : 4 ≤ H) : + uniformMean (fun integer : Fin (optimizerTriangularMass K) => + let action := physicalBandOnlineDraw source target U N P F A T delta choices node hbelow + b thetaExponent tau r hband η κ G K t integer + (∑ child, (history (t + 1) (child, action child) : ℝ)) + + (κ : ℝ) * ((∑ child, (history t (child, action child) : ℝ)) - + ∑ child, (history (t + 1) (child, action child) : ℝ))) = + -((∑ child, mass child : ℚ) : ℝ) * + ∑ coordinate ∈ bandCoordinates (band).toFinset, + ((childGain mass history t coordinate : ℝ) + + (1 - (κ : ℝ)) * childDecrement mass history t coordinate) * + (computedOnlineVector (bandCoordinates (band).toFinset) + ((band).map (actionVector mass)) η κ + (childGain mass history) (childDecrement mass history) H t coordinate : ℝ) := by + have hGpos : 0 < G := by omega + have hKpos : 0 < K := by rw [hK]; exact pow_pos hGpos 80 + have hmean := physicalBandOnlineDraw_child_cost_mean source target U N P F A T delta choices + node hbelow b thetaExponent tau r hM hband η κ G K t hKpos + simpa only [computedOnlineVector, ← hG, ← hK] using hmean + +include hM hsize hP hF hA hseed hT in +/-- The regret hypotheses are proved from the actual physical recurrence. -/ +theorem physicalBand_computed_entropy_regret (htau : 0 < tau) (hdelta : 0 ≤ delta) + (S H : ℕ) (η κ : ℚ) {comparison : Fin M → TargetInterval target.length} + (hc : comparison ∈ band) (hH : 4 ≤ H) (hη : 0 < η) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (hηrange : (η : ℝ) * + (2 * (delta : ℝ) + 8 * ((128 * F : ℚ) : ℝ) * (theta : ℝ)) ≤ (κ : ℝ)) : + (∑ t ∈ range S, ∑ coordinate ∈ bandCoordinates (band).toFinset, + ((childGain mass history t coordinate : ℝ) + childDecrement mass history t coordinate) * + (actionVector mass comparison coordinate : ℝ)) - + Real.log (bandCoordinates (band).toFinset).card / (η : ℝ) - 2 * (κ : ℝ) - + (S : ℝ) / (H : ℝ) ^ 3 ≤ + ∑ t ∈ range S, ∑ coordinate ∈ bandCoordinates (band).toFinset, + ((childGain mass history t coordinate : ℝ) + + (1 - (κ : ℝ)) * childDecrement mass history t coordinate) * + (computedOnlineVector (bandCoordinates (band).toFinset) + ((band).map (actionVector mass)) η κ + (childGain mass history) (childDecrement mass history) H t coordinate : ℝ) := by + let : Nonempty (Fin M) := ⟨⟨0, hM⟩⟩ + have hband : band ≠ [] := List.ne_nil_of_mem hc + apply list_band_computed_entropy_regret band hband mass + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r) + S H η κ _ (childGain mass history) (childDecrement mass history) hc hH hη hκ hκhalf hηrange + · intro t _ coordinate _ + exact childDecrement_nonneg mass history t coordinate + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r coordinate.1) + (physicalBandHistory_nonincreasing source target U N P F A T delta choices node hbelow t coordinate) + · intro t _ first hfirst second hsecond hsame + exact physicalBand_decrement_range source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT htau hdelta t first second hfirst hsecond hsame + · intro coordinate hcoordinate + exact physicalBand_decrement_total source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT S coordinate hcoordinate + · intro t _ coordinate hcoordinate + exact physicalBand_gain_bounds source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT κ hκ hκhalf t coordinate hcoordinate + +include hM hsize hP hF hA hseed hT in +/-- Expected weighted cost regret of the returned physical-band action. -/ +theorem physicalBandOnlineDraw_cost_regret (htau : 0 < tau) (hdelta : 0 ≤ delta) + (hband : band ≠ []) (S H G K : ℕ) (η κ : ℚ) + (hG : G = H + (bandCoordinates (band).toFinset).card + 2) (hK : K = G ^ 80) + {comparison : Fin M → TargetInterval target.length} (hc : comparison ∈ band) + (hH : 4 ≤ H) (hη : 0 < η) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (hηrange : (η : ℝ) * + (2 * (delta : ℝ) + 8 * ((128 * F : ℚ) : ℝ) * (theta : ℝ)) ≤ (κ : ℝ)) : + (∑ t ∈ range S, uniformMean (fun integer : Fin (optimizerTriangularMass K) => + let action := physicalBandOnlineDraw source target U N P F A T delta choices node hbelow + b thetaExponent tau r hband η κ G K t integer + (∑ child, (history (t + 1) (child, action child) : ℝ)) + + (κ : ℝ) * ((∑ child, (history t (child, action child) : ℝ)) - + ∑ child, (history (t + 1) (child, action child) : ℝ)))) ≤ + (∑ t ∈ range S, ∑ child, (history (t + 1) (child, comparison child) : ℝ)) + + ((∑ child, mass child : ℚ) : ℝ) * + (Real.log (bandCoordinates (band).toFinset).card / (η : ℝ) + 2 * (κ : ℝ) + + (S : ℝ) / (H : ℝ) ^ 3) := by + let : Nonempty (Fin M) := ⟨⟨0, hM⟩⟩ + have hregret := physicalBand_computed_entropy_regret source target U N P F A T delta choices node hbelow + b thetaExponent tau r hM hsize hP hF hA hseed hT htau hdelta S H η κ hc hH hη hκ hκhalf hηrange + have hmass : (0 : ℝ) ≤ ((∑ child, mass child : ℚ) : ℝ) := by + exact (Rat.cast_nonneg (K := ℝ)).mpr (sum_nonneg fun child _ => + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r child).le) + have hscaled := mul_le_mul_of_nonpos_left hregret (neg_nonpos.mpr hmass) + have hmean t := physicalBandOnlineDraw_computed_mean source target U N P F A T delta choices + node hbelow b thetaExponent tau r hM hband η κ G K H t hG hK hH + simp_rw [hmean] + rw [← mul_sum] + have hcomparison t := actionVector_comparator_cost_identity (band).toFinset mass + (physicalBandEnvelope_pos source target U N P F A T node hbelow b thetaExponent tau r) + history t (List.mem_toFinset.mpr hc) + have hcomparisonSum := congrArg (fun value : ℕ → ℝ => ∑ t ∈ range S, value t) (funext hcomparison) + rw [← mul_sum] at hcomparisonSum + nlinarith only [hscaled, hcomparisonSum] + + +include hM hsize hP hF hA hseed hT in +/-- Rounding is charged using the actual spatial regularity of child histories. -/ +theorem physicalBand_canonical_cost (htau : 0 < tau) (hdelta : 0 ≤ delta) + (hband : band ≠ []) (t : ℕ) (action : Fin M → TargetInterval target.length) + (haction : action ∈ band) : + rationalEndpointActionValue r + (canonicalRoundedBandAction thetaExponent b band hband initial) + (fun child state => history t (child, state)) ≤ + (1 + delta) * (∑ child, history t (child, action child)) + + (6 * (128 * F : ℚ) + 2) * theta * ∑ child, mass child := by + exact representativeBandActions_canonical_cost source target (physicalSourceInterval source.length node) + r thetaExponent b P tau htau (physicalBandChildMassTable source target U N P F A T node hbelow) + initial (fun child state => history t (child, state)) hband action haction delta (128 * F : ℚ) + (by positivity) (fun child s s' => physicalRefinement_spatial source target hM U N P F A + hsize hP hF hA hseed T hT delta hdelta choices (physicalChild node hbelow child) t s s') + + +end PhysicalBand + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalOnlineLocality.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalOnlineLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..56b62467bb56a1e7ac1d410d5d20db3432a3dcea --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalOnlineLocality.lean @@ -0,0 +1,109 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSelectionProgram + +namespace OAI + +/-! The literal query-filtered online loop has at most one candidate per scale. -/ + +namespace EditApproximation + +open Finset + +theorem makeTargetState_endpoints {n lo hi : ℕ} {q : TargetInterval n} + (h : makeTargetState n lo hi = some q) : q.lo = lo ∧ q.hi = hi := by + unfold makeTargetState at h + split_ifs at h with hv + · cases h + exact ⟨rfl, rfl⟩ + +theorem targetStates_nodup (n : ℕ) : (targetStates n).Nodup := by + unfold targetStates + apply List.nodup_flatMap.mpr + constructor + · intro lo _ + apply (List.nodup_range (n := n + 1)).filterMap + intro hi hi' q hq hq' + have h := (makeTargetState_endpoints (Option.mem_def.mp hq)).2 + have h' := (makeTargetState_endpoints (Option.mem_def.mp hq')).2 + exact h.symm.trans h' + · apply (List.nodup_range (n := n + 1)).imp + intro lo lo' hne q hq hq' + obtain ⟨hi, _, hq⟩ := List.mem_filterMap.mp hq + obtain ⟨hi', _, hq'⟩ := List.mem_filterMap.mp hq' + exact hne ((makeTargetState_endpoints hq).1.symm.trans (makeTargetState_endpoints hq').1) + +theorem dyadicScales_nodup (N : ℕ) : (dyadicScales N).Nodup := + (List.nodup_range (n := Nat.log 2 N + 1)).map (Nat.pow_right_injective (by decide : 2 ≤ (2 : ℕ))) + +theorem representativeList_nodup {n : ℕ} (N P F : ℕ) (a : ℚ) + (initial : TargetInterval n → ℚ) : (representativeList N P F a initial).Nodup := by + unfold representativeList + apply List.nodup_flatMap.mpr + constructor + · intro b _ + exact ((targetStates_nodup n).filter _).map (fun _ _ heq => congrArg Prod.snd heq) + · apply (dyadicScales_nodup N).imp + intro b b' hne pair hp hp' + obtain ⟨r, _, heq⟩ := List.mem_map.mp hp + obtain ⟨r', _, heq'⟩ := List.mem_map.mp hp' + exact hne ((congrArg Prod.fst heq).trans (congrArg Prod.fst heq').symm) + +theorem representativeList_scale_mem {n N P F : ℕ} (a : ℚ) + (initial : TargetInterval n → ℚ) {br : ℕ × TargetInterval n} + (hbr : br ∈ representativeList N P F a initial) : br.1 ∈ dyadicScales N := by + obtain ⟨b, hb, hbr⟩ := List.mem_flatMap.mp hbr + obtain ⟨r, _, heq⟩ := List.mem_map.mp hbr + exact (congrArg Prod.fst heq) ▸ hb + +section Online + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T thetaExponent H : ℕ) (tau η κ : ℚ) + +local notation "representatives" => stageRepresentatives source target U N P F A + +/-- A fixed query retains at most one original representative index for +each scale. This is a pathwise statement on every initial seed. -/ +theorem physicalProgramOnline_query_indices_length (node : PhysicalNode M J) + (q : TargetInterval target.length) : + ((List.finRange (representatives node).length).filter fun representative => decide + (physicalProgramOnlineGuard source target U N P F A node q + ((representatives node).get representative))).length ≤ (dyadicScales N).length := by + let indices := (List.finRange (representatives node).length).filter fun representative => decide + (physicalProgramOnlineGuard source target U N P F A node q ((representatives node).get representative)) + let scales := indices.map fun representative => ((representatives node).get representative).1 + have hrep : (representatives node).Nodup := representativeList_nodup N P F _ _ + have hscales : scales.Nodup := by + apply ((List.nodup_finRange _).filter _).map_on + intro i hi j hj hscale + have hqi := of_decide_eq_true (List.mem_filter.mp hi).2 + have hqj := of_decide_eq_true (List.mem_filter.mp hj).2 + have hcenter : ((representatives node).get i).2 = ((representatives node).get j).2 := by + exact hqi.1.trans ((congrArg (fun b => roundInterval (seedGridSpacing b P) q) hscale).trans hqj.1.symm) + exact hrep.injective_get (Prod.ext hscale hcenter) + have hsub : scales.toFinset ⊆ (dyadicScales N).toFinset := by + intro b hb + obtain ⟨i, _, rfl⟩ := List.mem_map.mp (List.mem_toFinset.mp hb) + exact List.mem_toFinset.mpr (representativeList_scale_mem _ _ (List.get_mem (representatives node) i)) + have hcard := (Finset.card_le_card hsub).trans (List.toFinset_card_le _) + simpa only [List.toFinset_card_of_nodup hscales, scales, List.length_map] using hcard + +/-- The actual online action loop produces at most one action per dyadic +scale, including failed band tests and every initial seed. -/ +theorem physicalProgramOnline_length {R : ℕ} [NeZero R] + (stream : PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R) + (node : PhysicalNode M J) (children : PhysicalChildTables M target.length) (t : ℕ) + (q : TargetInterval target.length) : + (physicalProgramOnline source target U N P F A T thetaExponent H tau η κ stream node children t q).length ≤ + (dyadicScales N).length := by + unfold physicalProgramOnline + split_ifs with hbelow + · exact (List.length_filterMap_le _ _).trans + (physicalProgramOnline_query_indices_length source target U N P F A node q) + · exact Nat.zero_le _ + +end Online + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalParentDraw.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalParentDraw.lean new file mode 100644 index 0000000000000000000000000000000000000000..56ca7fc34de186818658a22ee9df912bc146d12c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalParentDraw.lean @@ -0,0 +1,114 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalExpectedRegret + +namespace OAI + +/-! +# Parent random streams in a fixed child environment + +Finite parent arrays contain independent uniform optimizer integers and +actual shared-group draws. The projection laws are exact. Their use in the +node bound needs only the individual marginals, so no independence between +an online payoff and a group-failure indicator is asserted there. +-/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +abbrev ParentGroupDraw (M K : ℕ) (count : Fin K → ℕ) := + ∀ scale : Fin K, Fin (count scale) → Fin M + +abbrev ParentRandomSpace (R O M K : ℕ) (count : Fin K → ℕ) := + (Fin R → Fin O) × (Fin R → ParentGroupDraw M K count) + +noncomputable def parentDrawLaw (R O M K : ℕ) [NeZero M] [NeZero O] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] (count : Fin K → ℕ) : + Measure (ParentRandomSpace R O M K count) := + (Measure.pi fun _ : Fin R => (PMF.uniformOfFintype (Fin O)).toMeasure).prod + (Measure.pi fun _ : Fin R => groupSharedDrawLaw (M := M) count) + +instance parentDrawLaw_probability (R O M K : ℕ) [NeZero M] [NeZero O] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] (count : Fin K → ℕ) : + IsProbabilityMeasure (parentDrawLaw R O M K count) := by + dsimp only [parentDrawLaw] + infer_instance + +def parentOnlineDraw {R O M K : ℕ} [NeZero R] {count : Fin K → ℕ} + (ω : ParentRandomSpace R O M K count) (t : ℕ) : Fin O := ω.1 (Fin.ofNat R t) + +def parentGroupDraw {R O M K : ℕ} [NeZero R] {count : Fin K → ℕ} + (ω : ParentRandomSpace R O M K count) (t : ℕ) : ParentGroupDraw M K count := ω.2 (Fin.ofNat R t) + +theorem parentDrawLaw_online_mean (R O M K : ℕ) [NeZero R] [NeZero M] [NeZero O] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (count : Fin K → ℕ) (t : ℕ) (payoff : Fin O → ℝ) : + (∫ ω, payoff (parentOnlineDraw ω t) ∂parentDrawLaw R O M K count) = uniformMean payoff := by + unfold parentOnlineDraw parentDrawLaw + rw [integral_fun_fst (fun array : Fin R → Fin O => payoff (array (Fin.ofNat R t))), probReal_univ, one_smul, integral_comp_eval + (μ := fun _ : Fin R => (PMF.uniformOfFintype (Fin O)).toMeasure) + (i := Fin.ofNat R t) (f := payoff) (measurable_of_finite _).aestronglyMeasurable] + exact uniform_integral payoff + +theorem parentDrawLaw_group_mean (R O M K : ℕ) [NeZero R] [NeZero M] [NeZero O] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (count : Fin K → ℕ) (t : ℕ) (payoff : ParentGroupDraw M K count → ℝ) : + (∫ ω, payoff (parentGroupDraw ω t) ∂parentDrawLaw R O M K count) = + ∫ draw, payoff draw ∂groupSharedDrawLaw (M := M) count := by + unfold parentGroupDraw parentDrawLaw + rw [integral_fun_snd (fun array : Fin R → ParentGroupDraw M K count => payoff (array (Fin.ofNat R t))), probReal_univ, one_smul, integral_comp_eval + (μ := fun _ : Fin R => groupSharedDrawLaw (M := M) count) + (i := Fin.ofNat R t) (f := payoff) (measurable_of_finite _).aestronglyMeasurable] + +/-- A finite Boolean event has precisely its probability as expected indicator. -/ +theorem bool_indicator_integral {Ω : Type*} [Fintype Ω] + [MeasurableSpace Ω] [MeasurableSingletonClass Ω] (μ : Measure Ω) (failure : Ω → Bool) : + (∫ ω, (if failure ω then (1 : ℝ) else 0) ∂μ) = μ.real {ω | failure ω = true} := by + have hmeas : MeasurableSet {ω | failure ω = true} := Set.toFinite _ |>.measurableSet + simpa only [Set.indicator, Pi.one_apply, Set.mem_ofPred_eq] using + (integral_indicator_one (μ := μ) hmeas) + + +theorem parentDrawLaw_group_failure_mean (R O M K : ℕ) [NeZero R] [NeZero M] [NeZero O] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (count : Fin K → ℕ) (t : ℕ) (failure : ParentGroupDraw M K count → Bool) : + (∫ ω, (if failure (parentGroupDraw ω t) then (1 : ℝ) else 0) + ∂parentDrawLaw R O M K count) = + (groupSharedDrawLaw (M := M) count).real {draw | failure draw = true} := by + rw [parentDrawLaw_group_mean R O M K count t (fun draw => if failure draw then (1 : ℝ) else 0), + bool_indicator_integral] + +/-- Integrating the deterministic first-crossing transfer needs only the +exact online marginals and per-time group probabilities. -/ +theorem parentDrawLaw_firstCrossing_bound (R O M K : ℕ) [NeZero R] [NeZero M] [NeZero O] + [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (count : Fin K → ℕ) (S C : ℕ) + (regret : ParentRandomSpace R O M K count → ℕ → ℝ) + (prefixPayoff : ℕ → Fin O → ℝ) (failure : ℕ → ParentGroupDraw M K count → Bool) + (budget crossingCharge failureCharge q : ℝ) (hcharge : 0 ≤ failureCharge) + (hpoint : ∀ ω, (∑ t ∈ range S, regret ω t) ≤ + (∑ t ∈ range C, prefixPayoff t (parentOnlineDraw ω t)) + crossingCharge + + failureCharge * ∑ t ∈ range S, (if failure t (parentGroupDraw ω t) then (1 : ℝ) else 0)) + (hprefix : (∑ t ∈ range C, uniformMean (prefixPayoff t)) ≤ budget) + (hfailure : ∀ t < S, (groupSharedDrawLaw (M := M) count).real {draw | failure t draw = true} ≤ q) : + (∫ ω, (∑ t ∈ range S, regret ω t) ∂parentDrawLaw R O M K count) ≤ + budget + crossingCharge + failureCharge * S * q := by + let μ := parentDrawLaw R O M K count + have hmean := integral_mono (μ := μ) (.of_finite) (.of_finite) hpoint + have hprefixMean : (∫ ω, (∑ t ∈ range C, prefixPayoff t (parentOnlineDraw ω t)) ∂μ) = + ∑ t ∈ range C, uniformMean (prefixPayoff t) := by + rw [integral_finsetSum _ (by intro t ht; exact .of_finite)] + exact sum_congr rfl fun t _ => parentDrawLaw_online_mean R O M K count t (prefixPayoff t) + have hfailureMean : (∫ ω, (∑ t ∈ range S, + (if failure t (parentGroupDraw ω t) then (1 : ℝ) else 0)) ∂μ) ≤ (S : ℝ) * q := by + rw [integral_finsetSum _ (by intro t ht; exact .of_finite)] + have hsum := sum_le_sum (s := range S) fun t ht => + (parentDrawLaw_group_failure_mean R O M K count t (failure t)).trans_le (hfailure t (mem_range.mp ht)) + simpa only [sum_const, card_range, nsmul_eq_mul] using hsum + rw [integral_add (.of_finite) (.of_finite), integral_add (.of_finite) (integrable_const _), + integral_const, probReal_univ, one_smul, integral_const_mul, hprefixMean] at hmean + have hfailureCost := mul_le_mul_of_nonneg_left hfailureMean hcharge + nlinarith only [hmean, hprefix, hfailureCost] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalPreparedInputBounds.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalPreparedInputBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..1558e1cd806826cc9ef4ce263d1be06362163109 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalPreparedInputBounds.lean @@ -0,0 +1,149 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalBinaryStep +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalBinaryMass + +namespace OAI + +namespace EditApproximation +namespace BinaryFraction + +/-- Numeric register and loop bounds, independent of previously cached values. -/ +structure PreparedKernelNumericBounds {nx ny M : ℕ} + (N P F exponent H Q eM eF B E S t : ℕ) + (tau a eta kappa delta : BinaryFraction) + (integer : ℕ → TargetInterval ny → ℕ) : Prop where + largeBits : 10 ≤ B + inputSize : Nat.size N ≤ B + sourceSize : Nat.size nx + 2 ≤ B + targetSize : Nat.size ny + 2 ≤ B + aritySize : Nat.size M + 2 ≤ B + precisionSize : Nat.size P ≤ B + factorSize : Nat.size F + 2 ≤ B + sampleSize : Nat.size Q + 2 ≤ B + thetaSize : exponent + 1 ≤ B + scaleSizes : eM + eF + 7 ≤ B + heightSize : Nat.size H ≤ B + coordinateSize : Nat.size (M * (40 * P + 2) ^ 2) ≤ B + iterationSize : Nat.size ((H + M * (40 * P + 2) ^ 2 + 2) ^ 80) ≤ B + drawSize : ∀ b r, Nat.size (integer b r) ≤ B + tauSize : tau.width ≤ B + factorWidth : a.width ≤ B + rateSize : eta.width ≤ B + optimismSize : kappa.width ≤ B + decrementSize : delta.width ≤ B + rateMagnitude : |eta.value| ≤ E + optimismRange : 0 ≤ kappa.value ∧ kappa.value ≤ 1 + scalePositive : 2 ≤ S + arityCap : M ≤ S + precisionCap : P ≤ S + rateCap : E ≤ S + timeCap : t ≤ S + wordCap : 3 * (B + 4) + 4 ≤ S + actionCap : (40 * P + 2) ^ (2 * M) ≤ S + cartesianCap : ((40 * P + 2) ^ 2 + 1) ^ (M + 1) ≤ S + iterationCap : (H + M * (40 * P + 2) ^ 2 + 2) ^ 80 ≤ S + +theorem PreparedKernelNumericBounds.with_cached_values {nx ny M : ℕ} + {N P F exponent H Q eM eF B E S t : ℕ} + {tau a eta kappa delta : BinaryFraction} + {integer : ℕ → TargetInterval ny → ℕ} + (hn : PreparedKernelNumericBounds (nx := nx) (M := M) + N P F exponent H Q eM eF B E S t tau a eta kappa delta integer) + (parentInitial : TargetInterval ny → BinaryFraction) + (childMass childInitial : Fin M → TargetInterval ny → BinaryFraction) + (history : ℕ → Fin M × TargetInterval ny → BinaryFraction) + (hp : ∀ r, (parentInitial r).width ≤ B) + (hm : ∀ i r, (childMass i r).width ≤ B) + (hi : ∀ i r, (childInitial i r).width ≤ B) + (hh : ∀ s ≤ t + 1, ∀ i r, (history s (i, r)).width ≤ B) + (hpnonneg : ∀ r, 0 ≤ (parentInitial r).value) + (hrange : ∀ s ≤ t + 1, ∀ i r, 0 ≤ (history s (i, r)).value ∧ + (history s (i, r)).value ≤ (childInitial i r).value) : + PreparedKernelInputBounds (nx := nx) N P F exponent H Q eM eF B E S t + tau a eta kappa delta parentInitial childMass childInitial + (history t) (history (t + 1)) history integer where + largeBits := hn.largeBits + inputSize := hn.inputSize + sourceSize := hn.sourceSize + targetSize := hn.targetSize + aritySize := hn.aritySize + precisionSize := hn.precisionSize + factorSize := hn.factorSize + sampleSize := hn.sampleSize + thetaSize := hn.thetaSize + scaleSizes := hn.scaleSizes + heightSize := hn.heightSize + coordinateSize := hn.coordinateSize + iterationSize := hn.iterationSize + drawSize := hn.drawSize + tauSize := hn.tauSize + factorWidth := hn.factorWidth + rateSize := hn.rateSize + optimismSize := hn.optimismSize + decrementSize := hn.decrementSize + parentSize := hp + massSize := hm + initialSize := hi + oldSize := fun s => hh t (Nat.le_succ _) s.1 s.2 + currentSize := fun s => hh (t + 1) le_rfl s.1 s.2 + historySize := hh + parentNonneg := hpnonneg + rateMagnitude := hn.rateMagnitude + optimismRange := hn.optimismRange + historyRange := hrange + scalePositive := hn.scalePositive + arityCap := hn.arityCap + precisionCap := hn.precisionCap + rateCap := hn.rateCap + timeCap := hn.timeCap + wordCap := hn.wordCap + actionCap := hn.actionCap + cartesianCap := hn.cartesianCap + iterationCap := hn.iterationCap + +end BinaryFraction + +/-- The actual all-seed physical invariants discharge the value premises +of the prepared evaluator; only representation and scalar register bounds remain. -/ +theorem physicalPreparedStep_inputBounds {α : Type*} [DecidableEq α] + {M J R : ℕ} [NeZero R] (source target : List α) + (N P F exponent H Q eM eF B E S : ℕ) + (tauWord aWord etaWord kappaWord deltaWord : BinaryFraction) + (parentWords : TargetInterval target.length → BinaryFraction) + (massWords initialWords : Fin M → TargetInterval target.length → BinaryFraction) + (historyWords : ℕ → Fin M × TargetInterval target.length → BinaryFraction) + (draw : PhysicalInternalNode M J → ℕ → CellGroupDraws M F Q) + (integer : PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (t : ℕ) + (U : PhysicalEntry M J target.length → ℕ) (A tau eta kappa delta : ℚ) (T : ℕ) + (hd : 0 ≤ delta) + (hparent : ∀ r, (parentWords r).value = stageInitial source target U N P F A (node, r)) + (hinitial : ∀ i r, (initialWords i r).value = + stageInitial source target U N P F A (physicalChild node hbelow i, r)) + (hhistory : ∀ s i r, (historyWords s (i, r)).value = + physicalLocalRefinement source target U N P F exponent Q A tau delta T draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + (physicalChild node hbelow i) s r) + (hn : BinaryFraction.PreparedKernelNumericBounds (nx := source.length) (M := M) + N P F exponent H Q eM eF B E S t tauWord aWord etaWord kappaWord deltaWord + (integer ⟨node, hbelow⟩ (Fin.ofNat R t))) + (hp : ∀ r, (parentWords r).width ≤ B) + (hm : ∀ i r, (massWords i r).width ≤ B) + (hi : ∀ i r, (initialWords i r).width ≤ B) + (hh : ∀ s ≤ t + 1, ∀ i r, (historyWords s (i, r)).width ≤ B) : + BinaryFraction.PreparedKernelInputBounds (nx := source.length) + N P F exponent H Q eM eF B E S t tauWord aWord etaWord kappaWord deltaWord + parentWords massWords initialWords (historyWords t) (historyWords (t + 1)) historyWords + (integer ⟨node, hbelow⟩ (Fin.ofNat R t)) := by + apply hn.with_cached_values parentWords massWords initialWords historyWords hp hm hi hh + · intro r + rw [hparent] + exact stageInitial_nonneg_all_seeds source target U N P F A (node, r) + · intro s _hs i r + rw [hhistory, hinitial] + exact physicalLocalRefinement_bounds source target U N P F exponent Q A tau delta T hd draw + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa integer) + (physicalChild node hbelow i) s r + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramAccuracy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..26b59b61ae1a2bfc113573d59b0620108e65384d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramAccuracy.lean @@ -0,0 +1,135 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramComparisonRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeBudget +import OAI.Combinatorics.EditApproximation.Geometry.RefinementErrorTerms + +namespace OAI + +/-! Expected root-excess accuracy of the finite selection program under finite Bernstein bounds. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +theorem physicalProgramNodeCoefficient_nonneg (N F S H : ℕ) (eta kappa delta : ℚ) + (heta : (0 : ℝ) ≤ eta) (hkappa : (0 : ℝ) ≤ kappa) (hdelta : (0 : ℝ) ≤ delta) : + 0 ≤ physicalProgramNodeCoefficient N F eta kappa delta S H := by + unfold physicalProgramNodeCoefficient + positivity + +section Accuracy + +variable {α : Type*} [DecidableEq α] {M J R H : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (U : PhysicalEntry M J target.length → ℕ) (P : ℕ) (hPeq : P = (integerParameters N).P) + (A : ℚ) (hA : 1 ≤ A) (hAupper : A ≤ (integerParameters N).initialFactor) + (hsize : source.length + target.length ≤ N) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T S : ℕ) (hTeq : T = (integerParameters N).T) (hSeq : S = (integerParameters N).S) + (hHeq : H = inputHeight N) + (bernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (rootQ : TargetInterval target.length) + +local notation "ell" => inputSmallLog N +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "tau" => RationalParameters.tau (rationalParameters ell) +local notation "thetaExponent" => (40 * smallLogExponent N : ℕ) +local notation "Draw" => PhysicalProgramDraw (R := R) source target U N P ell A T thetaExponent H (ell ^ 80) tau +local notation "choices" => physicalProgramDrawSelections source target U N P ell A T thetaExponent H (ell ^ 80) tau eta kappa +local notation "globalLaw" => physicalProgramDrawLaw (R := R) source target U N P ell A T thetaExponent H (ell ^ 80) tau + +include hN hell hMeq hJeq hPeq hA hAupper hsize hseed hTeq hSeq hHeq bernstein + +/-- A pass of the actual rational recurrence has expected positive root +error at most the actual edit cost divided by the computed small logarithm. -/ +theorem physicalProgram_expected_root_excess : + (∫ draw : Draw, max ((physicalRefinement source target U N P ell A T delta (choices draw) + (Sigma.mk (Fin.mk 0 (Nat.zero_lt_succ J)) PUnit.unit : PhysicalNode M J) S rootQ : ℝ) - + stateEditCost source target rootQ) 0 ∂globalLaw) ≤ + (1 / (ell : ℝ)) * stateEditCost source target rootQ := by + classical + have hell1764 : 1764 ≤ ell := by + have hlarge : 4096 ≤ (2 : ℕ) ^ 1000 := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 12 ≤ 1000) + norm_num only [show (2 : ℕ) ^ 12 = 4096 by norm_num] at h + exact h + omega + have hell200 : 200 ≤ ell := by omega + have hF : 1 ≤ ell := Nat.one_le_two_pow + have hEllQ : (8 : ℚ) ≤ ell := by exact_mod_cast (show 8 ≤ ell by omega) + have hEllPos : (0 : ℚ) < ell := Nat.cast_pos.2 (Nat.two_pow_pos _) + have hbranch : 2 ≤ M := by + rw [hMeq] + exact (computed_branching_bounds N hN hell200).1 + have hM : 0 < M := by omega + have hP := computed_program_grid_lower N P hN hPeq + have hcounts := computed_stage_positive_counts N hN hell + have hT : 0 < T := by rw [hTeq]; exact hcounts.1 + have hS : 0 < S := by rw [hSeq]; exact hcounts.2 + have hpoly : ell ^ 20000 ≤ inputHeight N := by exact_mod_cast inputHeight_polynomial_slack N hN hell + have hEllHeight : ell ≤ inputHeight N := by + have hpow : ell ≤ ell ^ 20000 := by + simpa only [pow_one] using pow_le_pow_right₀ hF (by decide : 1 ≤ 20000) + exact hpow.trans hpoly + have hH : 4 ≤ H := by rw [hHeq]; omega + have hrange := computed_online_range ell (by omega : 8 ≤ ell) + have hdelta : 0 < delta := div_pos zero_lt_one (pow_pos hEllPos 10) + have htau : 0 ≤ tau := (div_pos zero_lt_one (pow_pos hEllPos 4)).le + have hηrange : (eta : ℝ) * (2 * (delta : ℝ) + 8 * ((128 * ell : ℚ) : ℝ) * + (((2 : ℚ) ^ (-(thetaExponent : ℤ))) : ℝ)) ≤ (kappa : ℝ) := by + simpa only [Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast, computed_theta_dyadic, + Rat.cast_zpow] using hrange.2.2.2 + have herror : 2 * (rationalParameters ell).gamma + 512 * (128 * ell : ℚ) * ell * + (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ kappa * delta := by + simpa only [← computed_theta_dyadic, rationalParameters] using group_rounded_error_small hEllQ + have hscale : 2 * (refinementFactor A ell : ℝ) ≤ P := by + rw [hPeq] + exact computed_refinementFactor_spacing N hN A hA hAupper + have hMP : 4 * (M : ℝ) / P ≤ 1 := by + rw [hMeq, hPeq] + exact (computed_stage_grid_bounds N hN).2.2 + have hcapacity : source.length ≤ M ^ J := by + rw [hJeq] + exact intervalTreeDepth_capacity M source.length hbranch + have hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2 := by + rw [hJeq, hMeq, hPeq] + exact computed_stage_tree_small N source.length hN (by omega) hell200 + have hratio : 0 < heightQuarterRoot N := by + unfold heightQuarterRoot + exact Real.sqrt_pos.2 (Real.sqrt_pos.2 (Nat.cast_pos.2 (Nat.two_pow_pos _))) + have hηR : (0 : ℝ) < eta := (Rat.cast_pos (K := ℝ)).mpr hrange.1 + have hκR : (0 : ℝ) ≤ kappa := (Rat.cast_nonneg (K := ℝ)).mpr hrange.2.1 + have hdeltaR : (0 : ℝ) < delta := (Rat.cast_pos (K := ℝ)).mpr hdelta + have hcoef := physicalProgramNodeCoefficient_nonneg N ell S H eta kappa delta hηR.le hκR hdeltaR.le + have hgood := fun (d : Fin J) (path : TreeLayer M d.val) => + physicalProgram_comparison_node_regret (R := R) source target N hN hell hM hMeq U P hPeq A hA hAupper + hsize hseed T hT hHeq hH delta eta kappa hdelta hrange.1 hrange.2.1 hrange.2.2.1 + hηrange herror bernstein rootQ S d path + have hbound := physical_tree_expected_excess_of_good_nodes source target hM U N P ell A + hsize hP hF hA hseed T hT delta choices rootQ globalLaw (heightQuarterRoot N) hratio tau htau + hscale hMP hcapacity hsmall S hS (physicalProgramNodeCoefficient N ell eta kappa delta S H) hcoef hgood + have hbudget : ((8 * (M : ℝ) + 512 * ell) * J / P + + (40000 * heightQuarterRoot N * (ell : ℝ) ^ 2 * (1 + (J : ℝ) / P + (J : ℝ) / T) + + 2 * J * (1 / heightQuarterRoot N + 4 * (tau : ℝ) * ell + + physicalProgramNodeCoefficient N ell eta kappa delta S H)) / S) = + computedRefinementError N source.length := by + dsimp only [physicalProgramNodeCoefficient, computedRefinementError] + rw [hJeq, hMeq, hPeq, hTeq, hSeq, hHeq] + simp only [rationalParameters, Rat.cast_div, Rat.cast_pow, Rat.cast_one, Rat.cast_natCast, + Nat.cast_add, Nat.cast_ofNat] + rw [hbudget] at hbound + exact hbound.trans (mul_le_mul_of_nonneg_right + (computedRefinementError_lt N source.length hN (by omega) hell).le (Nat.cast_nonneg _)) + +end Accuracy + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramComparisonRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramComparisonRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..803e5baed7dd7d1c8bb9d4168b71af464d9a3002 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramComparisonRegret.lean @@ -0,0 +1,185 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramNodeRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalComparisonBand +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonPrediction +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeGeneric +import OAI.Combinatorics.EditApproximation.Refinement.ComputedStageParameters + +namespace OAI + +/-! The actual selection program supplies the good-node premise of the +comparison-tree expected-regret telescope. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +theorem computed_program_grid_lower (N P : ℕ) (hN : 0 < N) + (hPeq : P = (integerParameters N).P) : 66 ≤ P := by + rw [hPeq] + exact (computed_stage_grid_bounds N hN).1 + +section Comparison + +variable {α : Type*} [DecidableEq α] {M J R H : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hM : 0 < M) (hMeq : M = (integerParameters N).M) + (U : PhysicalEntry M J target.length → ℕ) (P : ℕ) (hPeq : P = (integerParameters N).P) + (A : ℚ) (hA : 1 ≤ A) (hAupper : A ≤ (integerParameters N).initialFactor) + (hsize : source.length + target.length ≤ N) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (hHeq : H = inputHeight N) (hH : 4 ≤ H) + (delta η κ : ℚ) (hdelta : 0 < delta) (hη : 0 < η) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (hηrange : (η : ℝ) * (2 * (delta : ℝ) + 8 * ((128 * inputSmallLog N : ℚ) : ℝ) * + (((2 : ℚ) ^ (-((40 * smallLogExponent N : ℕ) : ℤ))) : ℝ)) ≤ (κ : ℝ)) + (herror : 2 * (rationalParameters (inputSmallLog N)).gamma + + 512 * (128 * inputSmallLog N : ℚ) * inputSmallLog N * + (2 : ℚ) ^ (-((40 * smallLogExponent N : ℕ) : ℤ)) ≤ κ * delta) + (bernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (rootQ : TargetInterval target.length) + +local notation "F" => inputSmallLog N +local notation "thetaExponent" => 40 * smallLogExponent N +local notation "tau" => RationalParameters.tau (rationalParameters F) +local notation "hP" => computed_program_grid_lower N P hN hPeq +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) +local notation "charges" => stageComparisonCharges source target hM U N P F A hP T rootQ +local notation "prediction" => stageComparisonPrediction source target hM U N P F A hP T rootQ +local notation "Draw" => PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H (F ^ 80) tau +local notation "choices" => physicalProgramDrawSelections source target U N P F A T thetaExponent H (F ^ 80) tau η κ +local notation "globalLaw" => physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H (F ^ 80) tau + +include hell hM hMeq hA hAupper hsize hseed hT hHeq hH hdelta hη hκ hκhalf hηrange herror bernstein + +/-- Non-bad, low-prediction comparison slots use their literal accepted +representative and whole-cell random coordinates in the global program. -/ +theorem physicalProgram_comparison_node_regret (S : ℕ) (d : Fin J) (path : TreeLayer M d.val) + (hnotbad : ¬ (comparisonActiveScale source target (frontier d.val path) < + heightQuarterRoot N * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < heightQuarterRoot N * (charges d path).2)) + (hvelocity : |prediction d path| ≤ 1 - tau) : + (∫ draw : Draw, (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta + (choices draw) rootQ t d path) ∂globalLaw) ≤ + physicalProgramNodeCoefficient N F η κ delta S H * comparisonActiveCost source target (frontier d.val path) := by + classical + have hF : 1 ≤ F := Nat.one_le_two_pow + have hell1764 : 1764 ≤ F := by + have hlarge : 4096 ≤ (2 : ℕ) ^ 1000 := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 12 ≤ 1000) + norm_num only [show (2 : ℕ) ^ 12 = 4096 by norm_num] at h + exact h + omega + have hscale : 2 * (refinementFactor A F : ℝ) ≤ P := by + rw [hPeq] + exact computed_refinementFactor_spacing N hN A hA hAupper + have hMP : 4 * (M : ℝ) / P ≤ 1 := by + rw [hMeq, hPeq] + exact (computed_stage_grid_bounds N hN).2.2 + generalize heq : frontier d.val path = state at hnotbad ⊢ + cases state with + | none => + have hpoint (draw : Draw) (t : ℕ) := physicalComparisonTreeRegret_none source target hM U N P F A hP T delta + (choices draw) rootQ t d path heq + simp_rw [hpoint] + simp only [sum_const_zero, integral_zero, comparisonActiveCost, mul_zero, le_refl] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · have hpoint (draw : Draw) (t : ℕ) := physicalComparisonTreeRegret_stopped source target hM U N P F A hP T delta + (choices draw) rootQ t d path parent q heq hstop + simp_rw [hpoint] + simp only [sum_const_zero, integral_zero, comparisonActiveCost, ite_eq_left hstop, mul_zero, le_refl] + · have hp := comparisonFrontier_active_source source target hM P hP rootQ d.val path parent q heq hstop + let node : PhysicalNode M J := ⟨⟨d.val, by omega⟩, path⟩ + have hp' : parent = physicalSourceInterval source.length node := hp + subst parent + change ¬ comparisonStopped source target (physicalSourceInterval source.length node) q at hstop + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change ¬ ((physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 ∨ + stateEditCost (physicalSource source node) target q = 0) at hstop + omega + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + let b : ℕ := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc + have hspec := comparisonChildren_spec source target hM P hP (physicalSourceInterval source.length node) q hc + have hn : wideActionList M (physicalSourceInterval source.length node) r b P ≠ [] := by + intro hnil + have hmem := hspec.1 + change action ∈ wideActionList M (physicalSourceInterval source.length node) r b P at hmem + rw [hnil] at hmem + exact List.not_mem_nil hmem + have hcharges := stageComparisonCharges_active source target hM U N P F A hP T rootQ d path q heq hstop hc hn + have hprediction := stageComparisonPrediction_active source target hM U N P F A hP T rootQ d path q heq hstop hn + have hratio : 0 < heightQuarterRoot N := by + unfold heightQuarterRoot + exact Real.sqrt_pos.2 (Real.sqrt_pos.2 (Nat.cast_pos.2 (Nat.two_pow_pos _))) + have hKG := nonbad_charge_bounds _ _ _ _ hratio hnotbad + change (charges d path).1 ≤ comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) / heightQuarterRoot N ∧ + (charges d path).2 ≤ comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) / heightQuarterRoot N at hKG + have hscaleEq : comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) = (b : ℝ) := by + simp only [comparisonActiveScale, ite_eq_right hstop] + rfl + rw [hscaleEq, hcharges] at hKG + rw [hprediction] at hvelocity + obtain ⟨member, hmember, hcenter, haction⟩ := physicalComparison_unskipped source target hM U N P A hN hell + hMeq hPeq hsize hP hA hseed T hT node d.isLt q hc hscale hMP hn hvelocity hKG.1 hKG.2 + have hrep := stageRounded_representative_mem source target U N P F A hsize hP hF hA hseed node q hc + obtain ⟨representative, hget⟩ := List.mem_iff_get.mp hrep + have hget' : (stageRepresentatives source target U N P F A node).get representative = (b, member.center) := by + simpa only [hcenter] using hget + have hdyadic := cost_dyadicScale _ N hc (physical_state_cost_le source target N hsize (node, q)) + obtain ⟨scale, hgetScale⟩ := List.mem_iff_get.mp hdyadic.1 + have hcellmem := physicalProgramCells_complete source target U N P F A thetaExponent node b r hrep + have hmember' : member ∈ physicalNodeCellBands source target U N P F A T node d.isLt b thetaExponent tau + (targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * b) r) := by + simpa only [computed_theta_dyadic, Nat.cast_mul, Nat.cast_ofNat, b, r] using hmember + have hnonempty : physicalNodeCellBands source target U N P F A T node d.isLt b thetaExponent tau + (targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * b) r) ≠ [] := by + intro he + rw [he] at hmember' + exact List.not_mem_nil hmember' + have hcellmem' : targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * ((dyadicScales N).get scale)) r ∈ + physicalProgramCells source target U N P F A thetaExponent node ((dyadicScales N).get scale) := by + simpa only [hgetScale, Nat.cast_mul, Nat.cast_ofNat, b] using hcellmem + obtain ⟨actualCellIndex, hgetActualCell⟩ := List.mem_iff_get.mp hcellmem' + have htau : 0 < tau := by + dsimp only [rationalParameters] + exact div_pos zero_lt_one (pow_pos (Nat.cast_pos.2 (Nat.two_pow_pos _)) 4) + have hb : (b : ℝ) ≤ stateEditCost (physicalSource source node) target q := by + exact_mod_cast hdyadic.2.1 + have hquery : physicalProgramOnlineGuard source target U N P F A node q (b, member.center) := by + simpa only [hcenter] using physicalProgramOnlineGuard_comparison source target U N P F A + hsize hP hF hA hseed node q hc + have hbound := physicalProgram_global_node_regret (R := R) source target N hN hell1764 hM hMeq hPeq rfl + (Nat.log 2 (stateEditCost (physicalSource source node) target q)) rfl rfl rfl hHeq hH + U A hsize hP hF hA hseed T hT delta η κ hdelta hη hκ hκhalf + (⟨node, d.isLt⟩ : PhysicalInternalNode M J) hleaf representative scale hgetScale + (targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * b) r) actualCellIndex + (by simpa only [hgetScale] using hgetActualCell) hnonempty member + hmember' hget' q hb hquery action haction + htau hηrange herror (bernstein b) S + have hpoint (draw : Draw) (t : ℕ) : + physicalComparisonTreeRegret source target hM U N P F A hP T delta (choices draw) rootQ t d path = _ := + physicalComparisonTreeRegret_active source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices draw) rootQ t node d.isLt q heq hstop + simp_rw [hpoint] + have hstop' : ¬ comparisonStopped source target (sourceIntervalAt M source.length d.val path) q := hstop + simpa only [hcenter, Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast, comparisonActiveCost, + ite_eq_right hstop', action, physicalSource, physicalSourceInterval, node] using hbound + +end Comparison + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramLaw.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..588609c1fd4a5cd5b55743a8e6ecb4076ae96bfa --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramLaw.lean @@ -0,0 +1,284 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSelectionResampling +import OAI.Combinatorics.EditApproximation.Probability.FiniteResampling + +namespace OAI + +/-! +# The global finite product of actual selection streams + +Online slots and whole-cell slots form a finite disjoint union. Each slot +contains its complete finite time array with the prescribed product law. +Mapping the flattened product produces +the actual online/group stream pair without independence hypotheses. +-/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +section GlobalLaw + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T thetaExponent H Q : ℕ) (tau : ℚ) + [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + +abbrev PhysicalOnlineKey := Σ node : PhysicalInternalNode M J, + Fin (stageRepresentatives source target U N P F A node.1).length + +abbrev PhysicalGroupKey := Σ node : PhysicalInternalNode M J, + Σ scale : Fin (dyadicScales N).length, + Fin (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).length + +abbrev PhysicalProgramKey := Sum (PhysicalOnlineKey source target U N P F A) + (PhysicalGroupKey source target U N P F A thetaExponent) + +abbrev PhysicalOnlineArray (key : PhysicalOnlineKey source target U N P F A) := + Fin R → Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau key.1 key.2)) + +abbrev PhysicalGroupArray (key : PhysicalGroupKey source target U N P F A thetaExponent) := + Fin R → ParentGroupDraw M (groupDyadicScales M ((dyadicScales N).get key.2.1) F).length + (fun h => groupSampleCount M Q ((dyadicScales N).get key.2.1) + (groupDyadicScaleAt M ((dyadicScales N).get key.2.1) F h)) + +abbrev PhysicalProgramCoordinate (key : PhysicalProgramKey source target U N P F A thetaExponent) : Type := + match key with + | .inl online => PhysicalOnlineArray (R := R) source target U N P F A T thetaExponent H tau online + | .inr group => PhysicalGroupArray (R := R) source target U N P F A thetaExponent Q group + +instance physicalProgramCoordinateFintype (key : PhysicalProgramKey source target U N P F A thetaExponent) : + Fintype (PhysicalProgramCoordinate (R := R) source target U N P F A T thetaExponent H Q tau key) := by + cases key <;> dsimp only [PhysicalProgramCoordinate] <;> infer_instance + +instance physicalProgramCoordinateMeasurableSpace + (key : PhysicalProgramKey source target U N P F A thetaExponent) : + MeasurableSpace (PhysicalProgramCoordinate (R := R) source target U N P F A T thetaExponent H Q tau key) := by + cases key <;> dsimp only [PhysicalProgramCoordinate] <;> infer_instance + +instance physicalProgramCoordinateMeasurableSingleton + (key : PhysicalProgramKey source target U N P F A thetaExponent) : + MeasurableSingletonClass + (PhysicalProgramCoordinate (R := R) source target U N P F A T thetaExponent H Q tau key) := by + cases key <;> dsimp only [PhysicalProgramCoordinate, physicalProgramCoordinateMeasurableSpace] <;> infer_instance + +abbrev PhysicalProgramDraw := ∀ key : PhysicalProgramKey source target U N P F A thetaExponent, + PhysicalProgramCoordinate (R := R) source target U N P F A T thetaExponent H Q tau key + +instance physicalProgramBandMass_nezero (node : PhysicalInternalNode M J) + (representative : Fin (stageRepresentatives source target U N P F A node.1).length) : + NeZero (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative)) := + ⟨Nat.ne_of_gt (optimizerTriangularMass_positive _ + (physicalProgramBandK_positive source target U N P F A T thetaExponent H tau node representative))⟩ + + +noncomputable def physicalProgramCoordinateLaw + (key : PhysicalProgramKey source target U N P F A thetaExponent) : + Measure (PhysicalProgramCoordinate (R := R) source target U N P F A T thetaExponent H Q tau key) := + match key with + | .inl online => + let : NeZero (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau online.1 online.2)) := + ⟨Nat.ne_of_gt (optimizerTriangularMass_positive _ + (physicalProgramBandK_positive source target U N P F A T thetaExponent H tau online.1 online.2))⟩ + Measure.pi fun _ : Fin R => (PMF.uniformOfFintype (Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau online.1 online.2)))).toMeasure + | .inr group => Measure.pi fun _ : Fin R => groupSharedDrawLaw (M := M) + (fun h => groupSampleCount M Q ((dyadicScales N).get group.2.1) + (groupDyadicScaleAt M ((dyadicScales N).get group.2.1) F h)) + +instance physicalProgramCoordinateLaw_probability + (key : PhysicalProgramKey source target U N P F A thetaExponent) : + IsProbabilityMeasure + (physicalProgramCoordinateLaw (R := R) source target U N P F A T thetaExponent H Q tau key) := by + cases key <;> dsimp only [physicalProgramCoordinateLaw, physicalProgramCoordinateMeasurableSpace, + PhysicalProgramCoordinate] <;> infer_instance + +noncomputable def physicalProgramDrawLaw : + Measure (PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) := + Measure.pi (physicalProgramCoordinateLaw (R := R) source target U N P F A T thetaExponent H Q tau) + +instance physicalProgramDrawLaw_probability : + IsProbabilityMeasure (physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H Q tau) := by + unfold physicalProgramDrawLaw + infer_instance + +def physicalProgramDrawStreams + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) : + PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R × + PhysicalGroupStreams source target U N P F A thetaExponent Q R := + (fun node representative => draw (.inl ⟨node, representative⟩), + fun node scale cell => draw (.inr ⟨node, scale, cell⟩)) + +noncomputable def physicalProgramStreamLaw : + Measure (PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R × + PhysicalGroupStreams source target U N P F A thetaExponent Q R) := + (physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H Q tau).map + (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau) + +instance physicalProgramStreamLaw_probability : + IsProbabilityMeasure (physicalProgramStreamLaw (R := R) source target U N P F A T thetaExponent H Q tau) := by + unfold physicalProgramStreamLaw + infer_instance + +/-- The transported law is the law of the complete literal stream pair. -/ +theorem physicalProgramStreamLaw_integral + (payoff : PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R × + PhysicalGroupStreams source target U N P F A thetaExponent Q R → ℝ) : + (∫ streams, payoff streams ∂physicalProgramStreamLaw (R := R) source target U N P F A T thetaExponent H Q tau) = + ∫ draw, payoff (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau draw) + ∂physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H Q tau := by + exact integral_map_of_stronglyMeasurable (measurable_of_finite _) + (measurable_of_finite payoff).stronglyMeasurable + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +/-- Refresh exactly one online band and one shared whole-cell coordinate. -/ +noncomputable def physicalProgramRefresh + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) + (online : PhysicalOnlineKey source target U N P F A) + (group : PhysicalGroupKey source target U N P F A thetaExponent) + (fresh : PhysicalOnlineArray (R := R) source target U N P F A T thetaExponent H tau online × + PhysicalGroupArray (R := R) source target U N P F A thetaExponent Q group) : + PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau := by + classical + exact Function.update (Function.update draw (.inl online) fresh.1) (.inr group) fresh.2 + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalProgramRefresh_online + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) + (online : PhysicalOnlineKey source target U N P F A) + (group : PhysicalGroupKey source target U N P F A thetaExponent) (fresh) : + (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau + (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh)).1 + online.1 online.2 = fresh.1 := by + classical + rcases online with ⟨node, representative⟩ + rcases group with ⟨groupNode, scale, cell⟩ + dsimp only [physicalProgramDrawStreams, physicalProgramRefresh] + rw [Function.update_of_ne (show (Sum.inl ⟨node, representative⟩ : + PhysicalProgramKey source target U N P F A thetaExponent) ≠ Sum.inr ⟨groupNode, scale, cell⟩ from Sum.inl_ne_inr)] + exact Function.update_self _ _ _ + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalProgramRefresh_group + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) + (online : PhysicalOnlineKey source target U N P F A) + (group : PhysicalGroupKey source target U N P F A thetaExponent) (fresh) : + (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau + (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh)).2 + group.1 group.2.1 group.2.2 = fresh.2 := by + classical + rcases group with ⟨node, scale, cell⟩ + dsimp only [physicalProgramDrawStreams, physicalProgramRefresh] + exact Function.update_self _ _ _ + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalProgramRefresh_online_other + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) + (online : PhysicalOnlineKey source target U N P F A) + (group : PhysicalGroupKey source target U N P F A thetaExponent) (fresh) + (label : PhysicalInternalNode M J) (hne : label ≠ online.1) : + (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau + (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh)).1 label = + (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau draw).1 label := by + classical + funext representative + have hkey : (Sum.inl ⟨label, representative⟩ : PhysicalProgramKey source target U N P F A thetaExponent) ≠ + Sum.inl online := by + intro heq + exact hne (congrArg Sigma.fst (Sum.inl.inj heq)) + dsimp only [physicalProgramDrawStreams, physicalProgramRefresh] + rw [Function.update_of_ne (show (Sum.inl ⟨label, representative⟩ : + PhysicalProgramKey source target U N P F A thetaExponent) ≠ Sum.inr group from Sum.inl_ne_inr), + Function.update_of_ne hkey] + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +theorem physicalProgramRefresh_group_other + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) + (online : PhysicalOnlineKey source target U N P F A) + (group : PhysicalGroupKey source target U N P F A thetaExponent) (fresh) + (label : PhysicalInternalNode M J) (hne : label ≠ group.1) : + (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau + (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh)).2 label = + (physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau draw).2 label := by + classical + funext scale cell + have hkey : (Sum.inr ⟨label, scale, cell⟩ : PhysicalProgramKey source target U N P F A thetaExponent) ≠ + Sum.inr group := by + intro heq + exact hne (congrArg Sigma.fst (Sum.inr.inj heq)) + dsimp only [physicalProgramDrawStreams, physicalProgramRefresh] + rw [Function.update_of_ne hkey, + Function.update_of_ne (show (Sum.inr ⟨label, scale, cell⟩ : + PhysicalProgramKey source target U N P F A thetaExponent) ≠ Sum.inl online from Sum.inr_ne_inl)] + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +/-- The actual complete selection program evaluated on its global array. -/ +def physicalProgramDrawSelections [NeZero R] (η κ : ℚ) + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) : + PhysicalSelections M J source.length target.length P (stageRepresentatives source target U N P F A) := + let streams := physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau draw + physicalProgramSelections source target U N P F A T thetaExponent H Q tau η κ streams.1 streams.2 + +omit [NeZero M] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +/-- Refreshing a parent's chosen band/cell coordinates leaves every +strictly deeper raw selection function unchanged. -/ +theorem physicalProgramDrawSelections_refresh_deeper [NeZero R] (η κ : ℚ) + (draw : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau) + (online : PhysicalOnlineKey source target U N P F A) + (group : PhysicalGroupKey source target U N P F A thetaExponent) (fresh) + (label : PhysicalNode M J) + (honline : online.1.1.1.val < label.1.val) (hgroup : group.1.1.1.val < label.1.val) : + (physicalProgramDrawSelections source target U N P F A T thetaExponent H Q tau η κ + (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh)).groups label = + (physicalProgramDrawSelections source target U N P F A T thetaExponent H Q tau η κ draw).groups label ∧ + (physicalProgramDrawSelections source target U N P F A T thetaExponent H Q tau η κ + (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh)).online label = + (physicalProgramDrawSelections source target U N P F A T thetaExponent H Q tau η κ draw).online label := by + have hneOnline (hbelow : label.1.val < J) : (⟨label, hbelow⟩ : PhysicalInternalNode M J) ≠ online.1 := by + intro heq + have hdepth := congrArg (fun node : PhysicalInternalNode M J => node.1.1.val) heq + change label.1.val = online.1.1.1.val at hdepth + omega + have hneGroup (hbelow : label.1.val < J) : (⟨label, hbelow⟩ : PhysicalInternalNode M J) ≠ group.1 := by + intro heq + have hdepth := congrArg (fun node : PhysicalInternalNode M J => node.1.1.val) heq + change label.1.val = group.1.1.1.val at hdepth + omega + let oldStreams := physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau draw + let nextStreams := physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau + (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh) + constructor + · exact physicalProgramSelections_groups_congr_at source target U N P F A T thetaExponent H Q tau η κ + oldStreams.1 nextStreams.2 oldStreams.2 label (fun hbelow => physicalProgramRefresh_group_other source target U N P F A T thetaExponent H Q tau + draw online group fresh ⟨label, hbelow⟩ (hneGroup hbelow)) + · exact physicalProgramSelections_online_congr_at source target U N P F A T thetaExponent H Q tau η κ + nextStreams.1 oldStreams.1 oldStreams.2 label (fun hbelow => physicalProgramRefresh_online_other source target U N P F A T thetaExponent H Q tau + draw online group fresh ⟨label, hbelow⟩ (hneOnline hbelow)) + + +/-- Exact finite-product disintegration into an original global array and +fresh local parent arrays. The unused old values are integrated out. -/ +theorem physicalProgramDrawLaw_refresh_integral + (online : PhysicalOnlineKey source target U N P F A) + (group : PhysicalGroupKey source target U N P F A thetaExponent) + (payoff : PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau → ℝ) : + (∫ draw, ∫ fresh, + payoff (physicalProgramRefresh source target U N P F A T thetaExponent H Q tau draw online group fresh) + ∂(physicalProgramCoordinateLaw (R := R) source target U N P F A T thetaExponent H Q tau (.inl online)).prod + (physicalProgramCoordinateLaw (R := R) source target U N P F A T thetaExponent H Q tau (.inr group)) + ∂physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H Q tau) = + ∫ draw, payoff draw ∂physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H Q tau := by + classical + exact finite_pi_integral_update_pair + (physicalProgramCoordinateLaw (R := R) source target U N P F A T thetaExponent H Q tau) + (.inl online) (.inr group) payoff + + +end GlobalLaw + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramNodeRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramNodeRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..76a3ef0f2ef5cfbb19ad8b6bda26e63f543bc71e --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramNodeRegret.lean @@ -0,0 +1,175 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramRefreshWiring +import OAI.Combinatorics.EditApproximation.Geometry.UnskippedRegretBudget + +namespace OAI + +/-! Actual local and global expected regret of the complete finite selection program. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +noncomputable def physicalProgramNodeCoefficient (N F : ℕ) (η κ delta : ℚ) (S H : ℕ) : ℝ := + 64 * (F : ℝ) * + ((4 * (coarseExponent (inputSmallLog N) + 21 : ℕ) * (inputSmallLog N : ℝ)) / (η : ℝ) + + 2 * (κ : ℝ) + (S : ℝ) / (H : ℝ) ^ 3) + + 2 * (delta : ℝ) + 2 * S * (1 / (H : ℝ) ^ 4) * F + +section Node + +variable {α : Type*} [DecidableEq α] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 1764 ≤ inputSmallLog N) + {M J P F b Q thetaExponent R H : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (hM : 0 < M) (hMeq : M = (integerParameters N).M) + (hPeq : P = (integerParameters N).P) (hFeq : F = inputSmallLog N) + (eb : ℕ) (hbeq : b = 2 ^ eb) (hQeq : Q = inputSmallLog N ^ 80) + (hthetaeq : thetaExponent = 40 * smallLogExponent N) (hHeq : H = inputHeight N) (hH : 4 ≤ H) + (U : PhysicalEntry M J target.length → ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta η κ : ℚ) + (hdelta : 0 < delta) (hη : 0 < η) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (node : PhysicalInternalNode M J) + (hleaf : ¬ (physicalSourceInterval source.length node.1).hi - + (physicalSourceInterval source.length node.1).lo ≤ 1) + (representative : Fin (stageRepresentatives source target U N P F A node.1).length) + (scale : Fin (dyadicScales N).length) (hscale : (dyadicScales N).get scale = b) + (cell : ℕ × ℕ) + (cellIndex : Fin (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).length) + (hcell : (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).get cellIndex = cell) + (hnonempty : physicalNodeCellBands source target U N P F A T node.1 node.2 b thetaExponent + (rationalParameters F).tau cell ≠ []) + (specified : UnskippedBand source target (physicalSourceInterval source.length node.1) + b P thetaExponent (rationalParameters F).tau F + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2)) + (hspecified : specified ∈ physicalNodeCellBands source target U N P F A T node.1 node.2 b thetaExponent + (rationalParameters F).tau cell) + (hget : (stageRepresentatives source target U N P F A node.1).get representative = (b, specified.center)) + (q : TargetInterval target.length) (hb : (b : ℝ) ≤ stateEditCost (physicalSource source node.1) target q) + (hquery : physicalProgramOnlineGuard source target U N P F A node.1 q (b, specified.center)) + (comparison : Fin M → TargetInterval target.length) (hc : comparison ∈ specified.actions) + (htau : 0 < (rationalParameters F).tau) + (hηrange : (η : ℝ) * (2 * (delta : ℝ) + 8 * ((128 * F : ℚ) : ℝ) * + (((2 : ℚ) ^ (-(thetaExponent : ℤ))) : ℝ)) ≤ (κ : ℝ)) + (herror : 2 * (rationalParameters F).gamma + + 512 * (128 * F : ℚ) * F * (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ κ * delta) + (bernstein : ∀ h : Fin (groupDyadicScales M b F).length, FiniteBernsteinInput + (Measure.pi fun _ : Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + +local notation "tau" => RationalParameters.tau (rationalParameters F) +local notation "onlineKey" => (Sigma.mk node representative : PhysicalOnlineKey source target U N P F A) +local notation "groupKey" => (Sigma.mk node (Sigma.mk scale cellIndex) : PhysicalGroupKey source target U N P F A thetaExponent) +local notation "bandG" => physicalProgramBandG source target U N P F A T thetaExponent H tau node representative +local notation "bandK" => physicalProgramBandK source target U N P F A T thetaExponent H tau node representative +local notation "Draw" => PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau +local notation "Fresh" => PhysicalOnlineArray (R := R) source target U N P F A T thetaExponent H tau onlineKey × + PhysicalGroupArray (R := R) source target U N P F A thetaExponent Q groupKey +local notation "choices" => physicalProgramDrawSelections source target U N P F A T thetaExponent H Q tau η κ +local notation "refresh" => physicalProgramRefresh source target U N P F A T thetaExponent H Q tau +local notation "localLaw" => + Measure.prod (physicalProgramCoordinateLaw (R := R) source target U N P F A T thetaExponent H Q tau (Sum.inl onlineKey)) + (physicalProgramCoordinateLaw (R := R) source target U N P F A T thetaExponent H Q tau (Sum.inr groupKey)) +local notation "globalLaw" => physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H Q tau + +include hN hell hM hMeq hPeq hFeq hbeq hQeq hthetaeq hHeq hH hsize hP hF hA hseed hT + hdelta hη hκ hκhalf hleaf hscale hcell hnonempty hspecified hget hb hquery hc htau hηrange herror bernstein + +/-- The actual program satisfies the fixed-child conditional node bound; +both candidate-list premises and both deeper-agreement premises are proved. -/ +theorem physicalProgram_conditional_node_regret (draw : Draw) (S : ℕ) : + let c : ℝ := stateEditCost (physicalSource source node.1) target q + let charge : ℝ := ((128 * F : ℚ) : ℝ) * targetEndpointDistance q specified.center + let clipped := physicalComparisonClipped source target U N P F A T delta (choices draw) node.1 node.2 comparison + (∫ fresh : Fresh, (∑ t ∈ range S, (max c + (physicalRefinement source target U N P F A T delta (choices (refresh draw onlineKey groupKey fresh)) + node.1 (t + 1) q : ℝ) - charge - clipped (t + 1))) ∂localLaw) ≤ + ((∑ child, specified.envelope child : ℚ) : ℝ) * + (Real.log (bandCoordinates specified.actions.toFinset).card / (η : ℝ) + 2 * (κ : ℝ) + + (S : ℝ) / (H : ℝ) ^ 3) + + 2 * (delta : ℝ) * c + 2 * S * (1 / (H : ℝ) ^ 4) * F * c := by + have hscalePow : (dyadicScales N).get scale = 2 ^ eb := hscale.trans hbeq + clear hbeq + subst b cell + have hrep : (((dyadicScales N).get scale), specified.center) ∈ + stageRepresentatives source target U N P F A node.1 := by + simpa only [hget] using List.get_mem (stageRepresentatives source target U N P F A node.1) representative + have hbound := physical_conditional_node_regret (G := bandG) (K := bandK) source target N hN hell hM hMeq hPeq hFeq + eb hscalePow hQeq hthetaeq hHeq hH U A hsize hP hF hA hseed T hT delta η κ hdelta hη hκ hκhalf + (choices draw) node.1 node.2 hleaf + ((physicalProgramCells source target U N P F A thetaExponent node.1 ((dyadicScales N).get scale)).get cellIndex) + hnonempty specified hspecified hrep q hb comparison hc + (physicalProgramBandG_spec source target U N P F A T thetaExponent H tau node representative _ specified hget) + rfl htau hηrange herror + (fun fresh => choices (refresh draw onlineKey groupKey fresh)) + (fun fresh label hdeeper => + (physicalProgramDrawSelections_refresh_deeper source target U N P F A T thetaExponent H Q tau η κ + draw onlineKey groupKey fresh label hdeeper hdeeper).1) + (fun fresh label hdeeper => + (physicalProgramDrawSelections_refresh_deeper source target U N P F A T thetaExponent H Q tau η κ + draw onlineKey groupKey fresh label hdeeper hdeeper).2) + (fun fresh t => physicalProgramRefresh_online_mem source target U N P F A T thetaExponent H Q tau delta η κ + node representative scale cellIndex draw fresh specified hget t q hquery) + (fun fresh t => physicalProgramRefresh_group_mem source target U N P F A T thetaExponent H Q tau delta η κ + node representative scale cellIndex draw fresh hnonempty t) + bernstein S + exact hbound + +/-- The actual complete program has the node budget in its original +finite product law. The two selected arrays are independently refreshed, +and all complete child histories stay fixed. -/ +theorem physicalProgram_global_node_regret (S : ℕ) : + let c : ℝ := stateEditCost (physicalSource source node.1) target q + let charge : ℝ := ((128 * F : ℚ) : ℝ) * targetEndpointDistance q specified.center + (∫ draw : Draw, (∑ t ∈ range S, (max c + (physicalRefinement source target U N P F A T delta (choices draw) + node.1 (t + 1) q : ℝ) - charge - + physicalComparisonClipped source target U N P F A T delta (choices draw) + node.1 node.2 comparison (t + 1))) ∂globalLaw) ≤ + physicalProgramNodeCoefficient N F η κ delta S H * c := by + let c : ℝ := stateEditCost (physicalSource source node.1) target q + let charge : ℝ := ((128 * F : ℚ) : ℝ) * targetEndpointDistance q specified.center + let payoff : Draw → ℝ := fun draw => ∑ t ∈ range S, + (max c (physicalRefinement source target U N P F A T delta (choices draw) + node.1 (t + 1) q : ℝ) - charge - + physicalComparisonClipped source target U N P F A T delta (choices draw) + node.1 node.2 comparison (t + 1)) + change (∫ draw, payoff draw ∂globalLaw) ≤ physicalProgramNodeCoefficient N F η κ delta S H * c + rw [← physicalProgramDrawLaw_refresh_integral source target U N P F A T thetaExponent H Q tau + onlineKey groupKey payoff] + have hlocal (draw : Draw) : (∫ fresh : Fresh, payoff (refresh draw onlineKey groupKey fresh) ∂localLaw) ≤ + physicalProgramNodeCoefficient N F η κ delta S H * c := by + have hbound := physicalProgram_conditional_node_regret source target N hN hell hM hMeq hPeq hFeq + eb hbeq hQeq hthetaeq hHeq hH U A hsize hP hF hA hseed T hT delta η κ hdelta hη hκ hκhalf + node hleaf representative scale hscale cell cellIndex hcell hnonempty specified hspecified hget + q hb hquery comparison hc htau hηrange herror bernstein draw S + have hpayoff (fresh : Fresh) : payoff (refresh draw onlineKey groupKey fresh) = + ∑ t ∈ range S, (max c + (physicalRefinement source target U N P F A T delta (choices (refresh draw onlineKey groupKey fresh)) + node.1 (t + 1) q : ℝ) - charge - + physicalComparisonClipped source target U N P F A T delta (choices draw) + node.1 node.2 comparison (t + 1)) := by + dsimp only [payoff] + rw [physicalProgramRefresh_clipped source target U N P F A T thetaExponent H Q tau delta η κ + node representative scale cellIndex draw fresh comparison] + simp_rw [hpayoff] + have hbudget := unskipped_expected_regret_budget source target N hN (by omega : 42 ≤ inputSmallLog N) + hMeq hPeq (physicalSourceInterval source.length node.1) tau (F : ℚ) + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2) + specified (Nat.cast_nonneg F) c hb η κ delta hη hκ S H + apply hbound.trans + simpa only [physicalProgramNodeCoefficient, Rat.cast_natCast] using hbudget + have hmean := integral_mono (μ := globalLaw) (.of_finite) (.of_finite) hlocal + simpa only [integral_const, probReal_univ, one_smul] using hmean + +end Node + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramRefreshWiring.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramRefreshWiring.lean new file mode 100644 index 0000000000000000000000000000000000000000..d94a7d34743b819ff9682ff9b1519f143db40a9d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramRefreshWiring.lean @@ -0,0 +1,118 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramLaw +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalConditionalNode + +namespace OAI + +/-! Exact candidate wiring and complete-child locality under actual two-key refresh. -/ + +namespace EditApproximation + +section RefreshWiring + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T thetaExponent H Q : ℕ) (tau delta η κ : ℚ) + (node : PhysicalInternalNode M J) + (representative : Fin (stageRepresentatives source target U N P F A node.1).length) + (scale : Fin (dyadicScales N).length) + (cell : Fin (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).length) + +local notation "onlineKey" => (Sigma.mk node representative : PhysicalOnlineKey source target U N P F A) +local notation "groupKey" => (Sigma.mk node (Sigma.mk scale cell) : PhysicalGroupKey source target U N P F A thetaExponent) +local notation "b" => List.get (dyadicScales N) scale +local notation "groupCell" => List.get (physicalProgramCells source target U N P F A thetaExponent (Subtype.val node) b) cell +local notation "G" => physicalProgramBandG source target U N P F A T thetaExponent H tau node representative +local notation "K" => physicalProgramBandK source target U N P F A T thetaExponent H tau node representative +local notation "Draw" => PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H Q tau +local notation "Fresh" => PhysicalOnlineArray (R := R) source target U N P F A T thetaExponent H tau onlineKey × + PhysicalGroupArray (R := R) source target U N P F A thetaExponent Q groupKey +local notation "choices" => physicalProgramDrawSelections source target U N P F A T thetaExponent H Q tau η κ +local notation "refresh" => physicalProgramRefresh source target U N P F A T thetaExponent H Q tau + +/-- Complete child histories remain fixed under replacement of the two +actual random arrays at this parent. -/ +theorem physicalProgramRefresh_history (draw : Draw) (fresh : Fresh) : + physicalBandHistory source target U N P F A T delta (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 = + physicalBandHistory source target U N P F A T delta (choices draw) node.1 node.2 := by + have hchildren := physicalRefinement_children_fixed source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) (choices draw) node.1 node.2 + (fun label hdeeper => (physicalProgramDrawSelections_refresh_deeper source target U N P F A T thetaExponent H Q tau η κ + draw onlineKey groupKey fresh label hdeeper hdeeper).1) + (fun label hdeeper => (physicalProgramDrawSelections_refresh_deeper source target U N P F A T thetaExponent H Q tau η κ + draw onlineKey groupKey fresh label hdeeper hdeeper).2) + funext t coordinate + exact congrFun (congrFun (congrFun hchildren coordinate.1) t) coordinate.2 + +theorem physicalProgramRefresh_clipped (draw : Draw) (fresh : Fresh) + (comparison : Fin M → TargetInterval target.length) : + physicalComparisonClipped source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 comparison = + physicalComparisonClipped source target U N P F A T delta (choices draw) node.1 node.2 comparison := by + funext t + simp only [physicalComparisonClipped, + physicalProgramRefresh_history source target U N P F A T thetaExponent H Q tau delta η κ + node representative scale cell draw fresh] + +/-- The literal online slot supplies the reference-environment sampler +at the refreshed integer; no candidate-list premise remains. -/ +theorem physicalProgramRefresh_online_mem (draw : Draw) (fresh : Fresh) + (member : UnskippedBand source target (physicalSourceInterval source.length node.1) + b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2)) + (hget : (stageRepresentatives source target U N P F A node.1).get representative = (b, member.center)) + (t : ℕ) (q : TargetInterval target.length) + (hquery : physicalProgramOnlineGuard source target U N P F A node.1 q (b, member.center)) : + sharedBandRationalAction member.center + (physicalBandOnlineDraw source target U N P F A T delta (choices draw) node.1 node.2 + b thetaExponent tau member.center member.nonempty η κ G K t (parentOnlineDraw fresh t)) ∈ + physicalNodeOnline source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 t q := by + let streams := physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau + (refresh draw onlineKey groupKey fresh) + have hmem := physicalProgram_online_action_mem source target U N P F A T thetaExponent H Q tau η κ + streams.1 streams.2 delta node representative b member hget t q hquery + have hhistory := physicalProgramRefresh_history source target U N P F A T thetaExponent H Q tau delta η κ + node representative scale cell draw fresh + have hinteger := congrFun (physicalProgramRefresh_online source target U N P F A T thetaExponent H Q tau + draw onlineKey groupKey fresh) (Fin.ofNat R t) + change streams.1 node representative (Fin.ofNat R t) = parentOnlineDraw fresh t at hinteger + change sharedBandRationalAction member.center + (physicalBandOnlineDraw source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 b thetaExponent tau member.center + member.nonempty η κ G K t (streams.1 node representative (Fin.ofNat R t))) ∈ + physicalNodeOnline source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 t q at hmem + simpa only [physicalBandOnlineDraw, hhistory, hinteger] using hmem + +/-- The literal whole-cell slot supplies the selected group computed from +the unchanged complete child environment and refreshed shared arrays. -/ +theorem physicalProgramRefresh_group_mem (draw : Draw) (fresh : Fresh) + (hnonempty : physicalNodeCellBands source target U N P F A T node.1 node.2 b thetaExponent tau groupCell ≠ []) + (t : ℕ) : + (physicalNodeSelectedGroup source target U N P F A T delta (choices draw) node.1 node.2 + b thetaExponent Q tau groupCell hnonempty t (parentGroupDraw fresh t)).rationalAction ∈ + physicalNodeGroups source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 t := by + let streams := physicalProgramDrawStreams source target U N P F A T thetaExponent H Q tau + (refresh draw onlineKey groupKey fresh) + have hmem := physicalProgram_group_action_mem source target U N P F A T thetaExponent H Q tau η κ + streams.1 streams.2 delta node scale cell hnonempty t + have hhistory := physicalProgramRefresh_history source target U N P F A T thetaExponent H Q tau delta η κ + node representative scale cell draw fresh + have hdraw := congrFun (physicalProgramRefresh_group source target U N P F A T thetaExponent H Q tau + draw onlineKey groupKey fresh) (Fin.ofNat R t) + change streams.2 node scale cell (Fin.ofNat R t) = parentGroupDraw fresh t at hdraw + change (physicalNodeSelectedGroup source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 b thetaExponent Q tau groupCell hnonempty t + (streams.2 node scale cell (Fin.ofNat R t))).rationalAction ∈ + physicalNodeGroups source target U N P F A T delta + (choices (refresh draw onlineKey groupKey fresh)) node.1 node.2 t at hmem + simpa only [physicalNodeSelectedGroup, hhistory, hdraw] using hmem + +end RefreshWiring + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramStateAccuracy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramStateAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..b91b98d20c661efa07d17aed8b661fd8530d10bb --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramStateAccuracy.lean @@ -0,0 +1,154 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramAccuracy +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramSubtreeRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeBudget + +namespace OAI + +/-! Expected excess at every original physical table entry, under the same +query-filtered global stream law. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +theorem rooted_refinement_budget_mono {M F P T S ratio velocityTolerance coefficient K J : ℝ} + (hM : 0 ≤ M) (hF : 0 ≤ F) (hP : 0 ≤ P) (hT : 0 ≤ T) (hS : 0 ≤ S) + (hratio : 0 ≤ ratio) (htau : 0 ≤ velocityTolerance) (hcoef : 0 ≤ coefficient) + (hKJ : K ≤ J) : + (8 * M + 512 * F) * K / P + + (40000 * ratio * F ^ 2 * (1 + K / P + K / T) + + 2 * K * (1 / ratio + 4 * velocityTolerance * F + coefficient)) / S ≤ + (8 * M + 512 * F) * J / P + + (40000 * ratio * F ^ 2 * (1 + J / P + J / T) + + 2 * J * (1 / ratio + 4 * velocityTolerance * F + coefficient)) / S := by + gcongr + +section Accuracy + +variable {α : Type*} [DecidableEq α] {M J R H : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (U : PhysicalEntry M J target.length → ℕ) (P : ℕ) (hPeq : P = (integerParameters N).P) + (A : ℚ) (hA : 1 ≤ A) (hAupper : A ≤ (integerParameters N).initialFactor) + (hsize : source.length + target.length ≤ N) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T S : ℕ) (hTeq : T = (integerParameters N).T) (hSeq : S = (integerParameters N).S) + (hHeq : H = inputHeight N) + (bernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) + +local notation "ell" => inputSmallLog N +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "tau" => RationalParameters.tau (rationalParameters ell) +local notation "thetaExponent" => (40 * smallLogExponent N : ℕ) +local notation "Draw" => PhysicalProgramDraw (R := R) source target U N P ell A T thetaExponent H (ell ^ 80) tau +local notation "choices" => physicalProgramDrawSelections source target U N P ell A T thetaExponent H (ell ^ 80) tau eta kappa +local notation "globalLaw" => physicalProgramDrawLaw (R := R) source target U N P ell A T thetaExponent H (ell ^ 80) tau + +include hN hell hMeq hJeq hPeq hA hAupper hsize hseed hTeq hSeq hHeq bernstein + +/-- A pass of the actual rational recurrence has expected positive root +error at most the actual edit cost divided by the computed small logarithm. -/ +theorem physicalProgram_expected_state_excess : + (∫ draw : Draw, max ((physicalRefinement source target U N P ell A T delta (choices draw) + root S rootQ : ℝ) - + stateEditCost (physicalSource source root) target rootQ) 0 ∂globalLaw) ≤ + (1 / (ell : ℝ)) * stateEditCost (physicalSource source root) target rootQ := by + classical + have hell1764 : 1764 ≤ ell := by + have hlarge : 4096 ≤ (2 : ℕ) ^ 1000 := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 12 ≤ 1000) + norm_num only [show (2 : ℕ) ^ 12 = 4096 by norm_num] at h + exact h + omega + have hell200 : 200 ≤ ell := by omega + have hF : 1 ≤ ell := Nat.one_le_two_pow + have hEllQ : (8 : ℚ) ≤ ell := by exact_mod_cast (show 8 ≤ ell by omega) + have hEllPos : (0 : ℚ) < ell := Nat.cast_pos.2 (Nat.two_pow_pos _) + have hbranch : 2 ≤ M := by + rw [hMeq] + exact (computed_branching_bounds N hN hell200).1 + have hM : 0 < M := by omega + have hP := computed_program_grid_lower N P hN hPeq + have hcounts := computed_stage_positive_counts N hN hell + have hT : 0 < T := by rw [hTeq]; exact hcounts.1 + have hS : 0 < S := by rw [hSeq]; exact hcounts.2 + have hpoly : ell ^ 20000 ≤ inputHeight N := by exact_mod_cast inputHeight_polynomial_slack N hN hell + have hEllHeight : ell ≤ inputHeight N := by + have hpow : ell ≤ ell ^ 20000 := by + simpa only [pow_one] using pow_le_pow_right₀ hF (by decide : 1 ≤ 20000) + exact hpow.trans hpoly + have hH : 4 ≤ H := by rw [hHeq]; omega + have hrange := computed_online_range ell (by omega : 8 ≤ ell) + have hdelta : 0 < delta := div_pos zero_lt_one (pow_pos hEllPos 10) + have htau : 0 ≤ tau := (div_pos zero_lt_one (pow_pos hEllPos 4)).le + have hηrange : (eta : ℝ) * (2 * (delta : ℝ) + 8 * ((128 * ell : ℚ) : ℝ) * + (((2 : ℚ) ^ (-(thetaExponent : ℤ))) : ℝ)) ≤ (kappa : ℝ) := by + simpa only [Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast, computed_theta_dyadic, + Rat.cast_zpow] using hrange.2.2.2 + have herror : 2 * (rationalParameters ell).gamma + 512 * (128 * ell : ℚ) * ell * + (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ kappa * delta := by + simpa only [← computed_theta_dyadic, rationalParameters] using group_rounded_error_small hEllQ + have hscale : 2 * (refinementFactor A ell : ℝ) ≤ P := by + rw [hPeq] + exact computed_refinementFactor_spacing N hN A hA hAupper + have hMP : 4 * (M : ℝ) / P ≤ 1 := by + rw [hMeq, hPeq] + exact (computed_stage_grid_bounds N hN).2.2 + have hcapacity : source.length ≤ M ^ J := by + rw [hJeq] + exact intervalTreeDepth_capacity M source.length hbranch + have hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2 := by + rw [hJeq, hMeq, hPeq] + exact computed_stage_tree_small N source.length hN (by omega) hell200 + have hratio : 0 < heightQuarterRoot N := by + unfold heightQuarterRoot + exact Real.sqrt_pos.2 (Real.sqrt_pos.2 (Nat.cast_pos.2 (Nat.two_pow_pos _))) + have hηR : (0 : ℝ) < eta := (Rat.cast_pos (K := ℝ)).mpr hrange.1 + have hκR : (0 : ℝ) ≤ kappa := (Rat.cast_nonneg (K := ℝ)).mpr hrange.2.1 + have hdeltaR : (0 : ℝ) < delta := (Rat.cast_pos (K := ℝ)).mpr hdelta + have hcoef := physicalProgramNodeCoefficient_nonneg N ell S H eta kappa delta hηR.le hκR hdeltaR.le + let K := J - root.1.val + have hK : K ≤ J := Nat.sub_le _ _ + have hheight : root.1.val + K = J := by dsimp only [K]; omega + have hsmallK : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2 := + (mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hK) + (div_nonneg (mul_nonneg (by norm_num) (Nat.cast_nonneg _)) (Nat.cast_nonneg _))).trans hsmall + have hgood := fun (d : Fin K) (path : TreeLayer M d.val) => + physicalProgram_subtree_node_regret (R := R) source target N hN hell hM hMeq U P hPeq A hA hAupper + hsize hseed T hT hHeq hH delta eta kappa hdelta hrange.1 hrange.2.1 hrange.2.2.1 + hηrange herror bernstein root K hheight rootQ S d path + have hbound := subtree_expected_excess_of_good_nodes source target hM U N P ell A + hsize hP hF hA hseed T hT delta choices root K hheight rootQ globalLaw (heightQuarterRoot N) hratio tau htau + hscale hMP hcapacity hsmallK S hS (physicalProgramNodeCoefficient N ell eta kappa delta S H) hcoef hgood + have hbudget : ((8 * (M : ℝ) + 512 * ell) * J / P + + (40000 * heightQuarterRoot N * (ell : ℝ) ^ 2 * (1 + (J : ℝ) / P + (J : ℝ) / T) + + 2 * J * (1 / heightQuarterRoot N + 4 * (tau : ℝ) * ell + + physicalProgramNodeCoefficient N ell eta kappa delta S H)) / S) = + computedRefinementError N source.length := by + dsimp only [physicalProgramNodeCoefficient, computedRefinementError] + rw [hJeq, hMeq, hPeq, hTeq, hSeq, hHeq] + simp only [rationalParameters, Rat.cast_div, Rat.cast_pow, Rat.cast_one, Rat.cast_natCast, + Nat.cast_add, Nat.cast_ofNat] + have hbudget_le := rooted_refinement_budget_mono (M := (M : ℝ)) (F := (ell : ℝ)) + (P := (P : ℝ)) (T := (T : ℝ)) (S := (S : ℝ)) (ratio := heightQuarterRoot N) + (velocityTolerance := (tau : ℝ)) (coefficient := physicalProgramNodeCoefficient N ell eta kappa delta S H) + (Nat.cast_nonneg _) (Nat.cast_nonneg _) (Nat.cast_nonneg _) (Nat.cast_nonneg _) + (Nat.cast_nonneg _) hratio.le ((Rat.cast_nonneg (K := ℝ)).mpr htau) hcoef + (Nat.cast_le.mpr hK) + rw [hbudget] at hbudget_le + exact (hbound.trans (mul_le_mul_of_nonneg_right hbudget_le (Nat.cast_nonneg _))).trans (mul_le_mul_of_nonneg_right + (computedRefinementError_lt N source.length hN (by omega) hell).le (Nat.cast_nonneg _)) + +end Accuracy + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramSubtreeRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramSubtreeRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..9af0df1f433b1d00253929a1eda1585373fc1180 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalProgramSubtreeRegret.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramComparisonRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeGeneric +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreePrediction + +namespace OAI + +/-! Arbitrary physical subtree slots retain the actual full-table product law. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +section Comparison + +variable {α : Type*} [DecidableEq α] {M J R H : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hM : 0 < M) (hMeq : M = (integerParameters N).M) + (U : PhysicalEntry M J target.length → ℕ) (P : ℕ) (hPeq : P = (integerParameters N).P) + (A : ℚ) (hA : 1 ≤ A) (hAupper : A ≤ (integerParameters N).initialFactor) + (hsize : source.length + target.length ≤ N) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (hHeq : H = inputHeight N) (hH : 4 ≤ H) + (delta η κ : ℚ) (hdelta : 0 < delta) (hη : 0 < η) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) + (hηrange : (η : ℝ) * (2 * (delta : ℝ) + 8 * ((128 * inputSmallLog N : ℚ) : ℝ) * + (((2 : ℚ) ^ (-((40 * smallLogExponent N : ℕ) : ℤ))) : ℝ)) ≤ (κ : ℝ)) + (herror : 2 * (rationalParameters (inputSmallLog N)).gamma + + 512 * (128 * inputSmallLog N : ℚ) * inputSmallLog N * + (2 : ℚ) ^ (-((40 * smallLogExponent N : ℕ) : ℤ)) ≤ κ * delta) + (bernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (root : PhysicalNode M J) (K : ℕ) (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + +local notation "F" => inputSmallLog N +local notation "thetaExponent" => 40 * smallLogExponent N +local notation "tau" => RationalParameters.tau (rationalParameters F) +local notation "hP" => computed_program_grid_lower N P hN hPeq +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) +local notation "charges" => subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ +local notation "prediction" => subtreeComparisonPrediction source target hM U N P F A hP T root K hheight rootQ +local notation "Draw" => PhysicalProgramDraw (R := R) source target U N P F A T thetaExponent H (F ^ 80) tau +local notation "choices" => physicalProgramDrawSelections source target U N P F A T thetaExponent H (F ^ 80) tau η κ +local notation "globalLaw" => physicalProgramDrawLaw (R := R) source target U N P F A T thetaExponent H (F ^ 80) tau + +include hell hM hMeq hA hAupper hsize hseed hT hHeq hH hdelta hη hκ hκhalf hηrange herror bernstein + +/-- Non-bad, low-prediction comparison slots use their literal accepted +representative and whole-cell random coordinates in the global program. -/ +theorem physicalProgram_subtree_node_regret (S : ℕ) (d : Fin K) (path : TreeLayer M d.val) + (hnotbad : ¬ (comparisonActiveScale source target (frontier d.val path) < + heightQuarterRoot N * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < heightQuarterRoot N * (charges d path).2)) + (hvelocity : |prediction d path| ≤ 1 - tau) : + (∫ draw : Draw, (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta + (choices draw) root K rootQ t d path) ∂globalLaw) ≤ + physicalProgramNodeCoefficient N F η κ delta S H * comparisonActiveCost source target (frontier d.val path) := by + classical + have hF : 1 ≤ F := Nat.one_le_two_pow + have hell1764 : 1764 ≤ F := by + have hlarge : 4096 ≤ (2 : ℕ) ^ 1000 := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 12 ≤ 1000) + norm_num only [show (2 : ℕ) ^ 12 = 4096 by norm_num] at h + exact h + omega + have hscale : 2 * (refinementFactor A F : ℝ) ≤ P := by + rw [hPeq] + exact computed_refinementFactor_spacing N hN A hA hAupper + have hMP : 4 * (M : ℝ) / P ≤ 1 := by + rw [hMeq, hPeq] + exact (computed_stage_grid_bounds N hN).2.2 + generalize heq : frontier d.val path = state at hnotbad ⊢ + cases state with + | none => + have hpoint (draw : Draw) (t : ℕ) := subtreeComparisonTreeRegret_none source target hM U N P F A hP T delta + (choices draw) root K rootQ t d path heq + simp_rw [hpoint] + simp only [sum_const_zero, integral_zero, comparisonActiveCost, mul_zero, le_refl] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · have hpoint (draw : Draw) (t : ℕ) := subtreeComparisonTreeRegret_stopped source target hM U N P F A hP T delta + (choices draw) root K rootQ t d path parent q heq hstop + simp_rw [hpoint] + simp only [sum_const_zero, integral_zero, comparisonActiveCost, ite_eq_left hstop, mul_zero, le_refl] + · have hp := comparisonSubtree_active_source source target hM P hP root rootQ d.val path parent q heq hstop + let node : PhysicalNode M J := physicalSubtreeNode root d.val path (by omega) + have hbelow : node.1.val < J := by dsimp only [node, physicalSubtreeNode]; omega + have hp' : parent = physicalSourceInterval source.length node := hp + subst parent + change ¬ comparisonStopped source target (physicalSourceInterval source.length node) q at hstop + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change ¬ ((physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 ∨ + stateEditCost (physicalSource source node) target q = 0) at hstop + omega + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + let b : ℕ := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc + have hspec := comparisonChildren_spec source target hM P hP (physicalSourceInterval source.length node) q hc + have hn : wideActionList M (physicalSourceInterval source.length node) r b P ≠ [] := by + intro hnil + have hmem := hspec.1 + change action ∈ wideActionList M (physicalSourceInterval source.length node) r b P at hmem + rw [hnil] at hmem + exact List.not_mem_nil hmem + have hcharges := subtreeComparisonCharges_active source target hM U N P F A hP T root K hheight rootQ d path q heq hstop hc hn + have hprediction := subtreeComparisonPrediction_active source target hM U N P F A hP T root K hheight rootQ d path q heq hstop hn + have hratio : 0 < heightQuarterRoot N := by + unfold heightQuarterRoot + exact Real.sqrt_pos.2 (Real.sqrt_pos.2 (Nat.cast_pos.2 (Nat.two_pow_pos _))) + have hKG := nonbad_charge_bounds _ _ _ _ hratio hnotbad + change (charges d path).1 ≤ comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) / heightQuarterRoot N ∧ + (charges d path).2 ≤ comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) / heightQuarterRoot N at hKG + have hscaleEq : comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) = (b : ℝ) := by + simp only [comparisonActiveScale, ite_eq_right hstop] + rfl + rw [hscaleEq, hcharges] at hKG + rw [hprediction] at hvelocity + obtain ⟨member, hmember, hcenter, haction⟩ := physicalComparison_unskipped source target hM U N P A hN hell + hMeq hPeq hsize hP hA hseed T hT node hbelow q hc hscale hMP hn hvelocity hKG.1 hKG.2 + have hrep := stageRounded_representative_mem source target U N P F A hsize hP hF hA hseed node q hc + obtain ⟨representative, hget⟩ := List.mem_iff_get.mp hrep + have hget' : (stageRepresentatives source target U N P F A node).get representative = (b, member.center) := by + simpa only [hcenter] using hget + have hdyadic := cost_dyadicScale _ N hc (physical_state_cost_le source target N hsize (node, q)) + obtain ⟨scale, hgetScale⟩ := List.mem_iff_get.mp hdyadic.1 + have hcellmem := physicalProgramCells_complete source target U N P F A thetaExponent node b r hrep + have hmember' : member ∈ physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau + (targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * b) r) := by + simpa only [computed_theta_dyadic, Nat.cast_mul, Nat.cast_ofNat, b, r] using hmember + have hnonempty : physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau + (targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * b) r) ≠ [] := by + intro he + rw [he] at hmember' + exact List.not_mem_nil hmember' + have hcellmem' : targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * ((dyadicScales N).get scale)) r ∈ + physicalProgramCells source target U N P F A thetaExponent node ((dyadicScales N).get scale) := by + simpa only [hgetScale, Nat.cast_mul, Nat.cast_ofNat, b] using hcellmem + obtain ⟨actualCellIndex, hgetActualCell⟩ := List.mem_iff_get.mp hcellmem' + have htau : 0 < tau := by + dsimp only [rationalParameters] + exact div_pos zero_lt_one (pow_pos (Nat.cast_pos.2 (Nat.two_pow_pos _)) 4) + have hb : (b : ℝ) ≤ stateEditCost (physicalSource source node) target q := by + exact_mod_cast hdyadic.2.1 + have hquery : physicalProgramOnlineGuard source target U N P F A node q (b, member.center) := by + simpa only [hcenter] using physicalProgramOnlineGuard_comparison source target U N P F A + hsize hP hF hA hseed node q hc + have hbound := physicalProgram_global_node_regret (R := R) source target N hN hell1764 hM hMeq hPeq rfl + (Nat.log 2 (stateEditCost (physicalSource source node) target q)) rfl rfl rfl hHeq hH + U A hsize hP hF hA hseed T hT delta η κ hdelta hη hκ hκhalf + (⟨node, by dsimp only [node, physicalSubtreeNode]; omega⟩ : PhysicalInternalNode M J) hleaf representative scale hgetScale + (targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * b) r) actualCellIndex + (by simpa only [hgetScale] using hgetActualCell) hnonempty member + hmember' hget' q hb hquery action haction + htau hηrange herror (bernstein b) S + have hpoint (draw : Draw) (t : ℕ) : + subtreeComparisonTreeRegret source target hM U N P F A hP T delta (choices draw) root K rootQ t d path = _ := + subtreeComparisonTreeRegret_active source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices draw) root K hheight rootQ t d path q heq hstop + simp_rw [hpoint] + have hstop' : ¬ comparisonStopped source target (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) q := hstop + simpa only [hcenter, Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast, comparisonActiveCost, + ite_eq_right hstop', action, physicalSource, physicalSourceInterval, node, physicalSubtreeNode] using hbound + +end Comparison + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalQueryBudget.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalQueryBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f53f03112d4142037bedd93ef902a9229a5ce30 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalQueryBudget.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.EditApproximation.Geometry.DyadicQueryWindow +import OAI.Combinatorics.EditApproximation.Geometry.SeedFactorSchedule + +namespace OAI + +/-! The literal online loop is bounded by the applicable scale window, +which is polynomial in ell throughout the computed factor schedule. -/ + +namespace EditApproximation + +open Finset + +theorem refinement_query_window_length (N F initialExponent : ℕ) (A w : ℚ) + (hF : 1 ≤ F) (hFbound : (F : ℚ) ≤ (2 : ℚ) ^ initialExponent) + (hAbound : A ≤ (2 : ℚ) ^ initialExponent) : + (dyadicQueryWindow N w (refinementFactor A F) F).length ≤ initialExponent + 8 := by + have hFpos : (0 : ℚ) < F := by exact_mod_cast (by omega : 0 < F) + have hfactor : refinementFactor A F ≤ (2 : ℚ) ^ initialExponent / F := by + apply max_le + · exact (le_div_iff₀ hFpos).2 (by simpa only [one_mul] using hFbound) + · exact div_le_div_of_nonneg_right hAbound hFpos.le + have hproduct := mul_le_mul_of_nonneg_right hfactor hFpos.le + rw [div_mul_cancel₀ _ hFpos.ne'] at hproduct + have hbudget : 128 * refinementFactor A F * F ≤ (2 : ℚ) ^ (initialExponent + 7) := by + have h := mul_le_mul_of_nonneg_left hproduct (by norm_num : (0 : ℚ) ≤ 128) + rw [pow_add] + norm_num only [show (2 : ℚ) ^ 7 = 128 by norm_num] + nlinarith only [h] + simpa only [Nat.add_assoc, show (7 : ℕ) + 1 = 8 by rfl] using + dyadicQueryWindow_length_le N (initialExponent + 7) w (refinementFactor A F) F + (le_max_left _ _) (by exact_mod_cast hF) hbudget + +section PhysicalQuery + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) + +local notation "representatives" => stageRepresentatives source target U N P F A + +theorem physicalProgramOnline_query_indices_window (node : PhysicalNode M J) + (q : TargetInterval target.length) : + ((List.finRange (representatives node).length).filter fun representative => decide + (physicalProgramOnlineGuard source target U N P F A node q + ((representatives node).get representative))).length ≤ + (dyadicQueryWindow N (stageInitial source target U N P F A (node, q)) (refinementFactor A F) F).length := by + let indices := (List.finRange (representatives node).length).filter fun representative => decide + (physicalProgramOnlineGuard source target U N P F A node q ((representatives node).get representative)) + let scales := indices.map fun representative => ((representatives node).get representative).1 + have hrep : (representatives node).Nodup := representativeList_nodup N P F _ _ + have hscales : scales.Nodup := by + apply ((List.nodup_finRange _).filter _).map_on + intro i hi j hj hscale + have hqi := of_decide_eq_true (List.mem_filter.mp hi).2 + have hqj := of_decide_eq_true (List.mem_filter.mp hj).2 + have hcenter : ((representatives node).get i).2 = ((representatives node).get j).2 := + hqi.1.trans ((congrArg (fun b => roundInterval (seedGridSpacing b P) q) hscale).trans hqj.1.symm) + exact hrep.injective_get (Prod.ext hscale hcenter) + have hsub : scales.toFinset ⊆ + (dyadicQueryWindow N (stageInitial source target U N P F A (node, q)) (refinementFactor A F) F).toFinset := by + intro b hb + obtain ⟨i, hi, rfl⟩ := List.mem_map.mp (List.mem_toFinset.mp hb) + have hguard := of_decide_eq_true (List.mem_filter.mp hi).2 + apply List.mem_toFinset.mpr + exact List.mem_filter.mpr ⟨representativeList_scale_mem _ _ (List.get_mem (representatives node) i), + decide_eq_true hguard.2⟩ + have hcard := (Finset.card_le_card hsub).trans (List.toFinset_card_le _) + simpa only [List.toFinset_card_of_nodup hscales, scales, List.length_map] using hcard + +theorem physicalProgramOnline_length_window (T exponent H : ℕ) (tau η κ : ℚ) + {R : ℕ} [NeZero R] + (stream : PhysicalOnlineStreams source target U N P F A T exponent H tau R) + (node : PhysicalNode M J) (children : PhysicalChildTables M target.length) (t : ℕ) + (q : TargetInterval target.length) : + (physicalProgramOnline source target U N P F A T exponent H tau η κ stream node children t q).length ≤ + (dyadicQueryWindow N (stageInitial source target U N P F A (node, q)) (refinementFactor A F) F).length := by + unfold physicalProgramOnline + split_ifs with hbelow + · exact (List.length_filterMap_le _ _).trans + (physicalProgramOnline_query_indices_window source target U N P F A node q) + · exact Nat.zero_le _ + +end PhysicalQuery + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalQueryProgress.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalQueryProgress.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7da0292aaeed242d4ad4a4fc1da07bafe13a5ad --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalQueryProgress.lean @@ -0,0 +1,195 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementReadWork +import OAI.Combinatorics.EditApproximation.Geometry.WarmupQueryKeys + +namespace OAI + +/-! The dependency split for keys actually emitted by the adaptive local +queries. Current-index edges descend in the physical tree; older reads +decrease the table rank and never move to an ancestor. -/ + +namespace EditApproximation + +namespace PhysicalTableRequest + +def DependencyProgress {M J ny : ℕ} (T S : ℕ) + (parent child : PhysicalTableRequest M J ny) : Prop := + (child.remainingDepth < parent.remainingDepth ∧ child.rank T S ≤ parent.rank T S) ∨ + (child.remainingDepth ≤ parent.remainingDepth ∧ child.rank T S < parent.rank T S) + +theorem warmup_before_refinement_progress {M J ny : ℕ} + (pass copy T S t : ℕ) (ht : 0 < t) + (node otherNode : PhysicalNode M J) (hnode : node.1.val ≤ otherNode.1.val) + (j : ℕ) (hj : j ≤ T) (q r : TargetInterval ny) : + DependencyProgress T S (refinement pass copy node T t q) + (warmup pass copy otherNode j r) := by + apply Or.inr + refine ⟨remainingDepth_le_of_no_ancestor _ _ hnode, ?_⟩ + exact rank_lt_same_pass T S _ _ rfl (by change j < T + t; omega) + +theorem refinement_child_same_progress {M J ny : ℕ} + (pass copy T S t : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (i : Fin M) (q r : TargetInterval ny) : + DependencyProgress T S (refinement pass copy node T t q) + (refinement pass copy (physicalChild node hbelow i) T t r) := by + apply Or.inl + refine ⟨?_, le_rfl⟩ + apply remainingDepth_lt_of_descendant + change node.1.val < node.1.val + 1 + omega + +theorem refinement_child_earlier_progress {M J ny : ℕ} + (pass copy T S t s : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (i : Fin M) (q r : TargetInterval ny) (hs : s < t) : + DependencyProgress T S (refinement pass copy node T t q) + (refinement pass copy (physicalChild node hbelow i) T s r) := by + obtain ⟨hd, hr⟩ := refinement_history_child_progress pass copy T S t s node hbelow i q r hs + exact Or.inr ⟨hd.le, hr⟩ + +theorem previous_pass_dependencyProgress {M J ny : ℕ} + (T S : ℕ) (parent child : PhysicalTableRequest M J ny) + (hpass : child.pass < parent.pass) (hindex : child.index ≤ T + S) + (hnode : parent.node.1.val ≤ child.node.1.val) : DependencyProgress T S parent child := + Or.inr (previous_pass_progress T S parent child hpass hindex hnode) + +theorem rank_lt_iff_index_lt_of_pass {M J ny : ℕ} (T S : ℕ) + (parent child : PhysicalTableRequest M J ny) (hpass : child.pass = parent.pass) : + child.rank T S < parent.rank T S ↔ child.index < parent.index := by + unfold rank + rw [hpass] + omega + +theorem rank_not_lt_iff_index_eq_of_pass {M J ny : ℕ} (T S : ℕ) + (parent child : PhysicalTableRequest M J ny) (hpass : child.pass = parent.pass) + (hindex : child.index ≤ parent.index) : + ¬ child.rank T S < parent.rank T S ↔ child.index = parent.index := by + rw [rank_lt_iff_index_lt_of_pass T S parent child hpass] + omega + +end PhysicalTableRequest + +theorem physicalRefinementWarmupRead_keys_progress {M J ny : ℕ} + (pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (q : TargetInterval ny) + (otherNode : PhysicalNode M J) (hnode : node.1.val ≤ otherNode.1.val) + (j : ℕ) (hj : j ≤ T) (r : TargetInterval ny) (oracle) : + ∀ key ∈ (physicalRefinementWarmupRead pass copy T S t ht node q otherNode hnode j hj r).keys oracle, + PhysicalTableRequest.DependencyProgress T S + (PhysicalTableRequest.refinement pass copy node T t q) key.val := by + intro key hk + simp only [physicalRefinementWarmupRead, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.warmup_before_refinement_progress pass copy T S t ht + node otherNode hnode j hj q r + +theorem physicalRefinementDataRequest_keys_progress {α : Type*} (source target : List α) {M J : ℕ} + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (draw : CellGroupDraws M F Q) (integer : ℕ → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) (oracle) : + ∀ key ∈ (physicalRefinementDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow draw integer q).keys oracle, + PhysicalTableRequest.DependencyProgress T S + (PhysicalTableRequest.refinement pass copy node T t q) key.val := by + unfold physicalRefinementDataRequestQuery + apply localRefinementDataQuery_keys_all + · intro r key hk + exact physicalRefinementWarmupRead_keys_progress pass copy T S t ht node q node le_rfl + 0 (Nat.zero_le T) r oracle key hk + · intro input + unfold physicalRefinementMassQuery + apply FiniteQuery.keys_all_collect + · intro j _ key hk + exact physicalRefinementWarmupRead_keys_progress pass copy T S t ht node q + (physicalChild node hbelow input.1) _ j.val (Nat.le_of_lt j.isLt) input.2 oracle key hk + · intro values key hk + exact False.elim (List.not_mem_nil hk) + · intro input key hk + exact physicalRefinementWarmupRead_keys_progress pass copy T S t ht node q + (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 oracle key hk + · intro input key hk + unfold physicalRefinementEarlierQuery at hk + split_ifs at hk with hs + · simp only [FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_child_earlier_progress pass copy T S t input.2.1 + node hbelow input.1 q input.2.2 hs + · exact False.elim (List.not_mem_nil hk) + · intro input key hk + simp only [physicalRefinementCurrentQuery, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_child_same_progress pass copy T S t node hbelow input.1 q input.2 + +theorem physicalRefinementWarmupRead_keys_pass_copy {M J ny : ℕ} + (pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (q : TargetInterval ny) + (otherNode : PhysicalNode M J) (hnode : node.1.val ≤ otherNode.1.val) + (j : ℕ) (hj : j ≤ T) (r : TargetInterval ny) (oracle) : + ∀ key ∈ (physicalRefinementWarmupRead pass copy T S t ht node q otherNode hnode j hj r).keys oracle, + key.val.pass = pass ∧ key.val.copy = copy ∧ key.val.index ≤ T + t := by + intro key hk + simp only [physicalRefinementWarmupRead, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact ⟨rfl, rfl, hj.trans (Nat.le_add_right T t)⟩ + +theorem physicalRefinementDataRequest_keys_pass_copy {α : Type*} (source target : List α) {M J : ℕ} + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (draw : CellGroupDraws M F Q) (integer : ℕ → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) (oracle) : + ∀ key ∈ (physicalRefinementDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow draw integer q).keys oracle, + key.val.pass = pass ∧ key.val.copy = copy ∧ key.val.index ≤ T + t := by + unfold physicalRefinementDataRequestQuery + apply localRefinementDataQuery_keys_all + · intro r key hk + exact physicalRefinementWarmupRead_keys_pass_copy pass copy T S t ht node q node le_rfl + 0 (Nat.zero_le T) r oracle key hk + · intro input + unfold physicalRefinementMassQuery + apply FiniteQuery.keys_all_collect + · intro j _ key hk + exact physicalRefinementWarmupRead_keys_pass_copy pass copy T S t ht node q + (physicalChild node hbelow input.1) _ j.val (Nat.le_of_lt j.isLt) input.2 oracle key hk + · intro values key hk + exact False.elim (List.not_mem_nil hk) + · intro input key hk + exact physicalRefinementWarmupRead_keys_pass_copy pass copy T S t ht node q + (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 oracle key hk + · intro input key hk + unfold physicalRefinementEarlierQuery at hk + split_ifs at hk with hs + · simp only [FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact ⟨rfl, rfl, by change T + input.2.1 ≤ T + t; omega⟩ + · exact False.elim (List.not_mem_nil hk) + · intro input key hk + simp only [physicalRefinementCurrentQuery, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact ⟨rfl, rfl, le_rfl⟩ + +theorem physicalWarmupRequestQuery_keys_progress {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N P F : ℕ) (A : ℚ) + (pass copy T S j : ℕ) (node : PhysicalNode M J) (q : TargetInterval target.length) + (seedRead : PhysicalEntry M J target.length → + FiniteQuery {child : PhysicalTableRequest M J target.length // + child.combinedRank T S < (PhysicalTableRequest.warmup pass copy node j q).combinedRank T S}) + (oracle) + (hseed : ∀ r key, key ∈ (seedRead (node, r)).keys oracle → + PhysicalTableRequest.DependencyProgress T S + (PhysicalTableRequest.warmup pass copy node j q) key.val) : + ∀ key ∈ (physicalWarmupRequestQuery source target N P F A pass copy T S j node q seedRead).keys oracle, + PhysicalTableRequest.DependencyProgress T S + (PhysicalTableRequest.warmup pass copy node j q) key.val := by + cases j with + | zero => exact physicalInitialQuery_keys_all source target N P F A seedRead node q oracle _ hseed + | succ j => + apply physicalWarmupRequestQuery_keys_all source target N P F A pass copy T S (j + 1) node q + seedRead oracle _ hseed + intro hbelow input + obtain ⟨hd, hr⟩ := PhysicalTableRequest.warmup_previous_child_progress pass copy T S (j + 1) + node hbelow input.1 q input.2 (Nat.succ_pos j) + exact Or.inr ⟨hd.le, hr⟩ + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomBoundedCost.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomBoundedCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..2504ae59e20eab0cd6c87273a55471ab8b8bcfc5 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomBoundedCost.lean @@ -0,0 +1,62 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomBoundedQuery +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomGlobalProgress + +namespace OAI + +namespace EditApproximation + +section Bounded + +variable {σ α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (readGroup : ℕ → ℕ → PhysicalInternalNode M J → Fin R → GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : ℕ → ℕ → PhysicalInternalNode M J → Fin R → + (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (initial : PhysicalEntry M J target.length → ℕ) + (sourceValue : σ → ℚ) (tableValue : PhysicalTableRequest M J target.length → ℚ) + + theorem physicalRandomBoundedQuery_cost (sourceWeight : σ → ℕ) + (tableWeight : PhysicalTableRequest M J target.length → ℕ) + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) : + (physicalRandomBoundedQuery source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta readGroup readInteger initial request).cost + (Sum.elim sourceValue (fun child => tableValue child.val.val)) + (Sum.elim sourceWeight (fun child => tableWeight child.val.val)) = + (physicalRandomGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial request.val).cost + (Sum.elim sourceValue (fun child => tableValue child.val)) + (Sum.elim sourceWeight (fun child => tableWeight child.val)) := by + unfold physicalRandomBoundedQuery + exact SourceRanked.restrictBody_cost _ _ _ _ _ _ _ request + (physicalRandomGlobalQuery_keys_bounded source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta readGroup readInteger initial request.val request.property _) + + theorem physicalRandomBoundedQuery_progress + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) : + ∀ key ∈ (physicalRandomBoundedQuery source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta readGroup readInteger initial request).keys + (Sum.elim sourceValue (fun child => tableValue child.val.val)), + match key with + | .inl _ => True + | .inr child => PhysicalTableRequest.DependencyProgress T S request.val child.val.val := by + unfold physicalRandomBoundedQuery + have hall := SourceRanked.restrictBody_keys_all _ _ _ sourceValue tableValue (fun _ => True) + (PhysicalTableRequest.DependencyProgress T S request.val) request + (physicalRandomGlobalQuery_keys_bounded source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta readGroup readInteger initial request.val request.property _) + (by + intro key hk + have h := physicalRandomGlobalQuery_keys_progress source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta readGroup readInteger initial request.val + (Sum.elim sourceValue (fun child => tableValue child.val)) key hk + cases key <;> exact h) + intro key hk + have h := hall key hk + cases key <;> exact h + +end Bounded + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomBoundedQuery.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomBoundedQuery.lean new file mode 100644 index 0000000000000000000000000000000000000000..822bbda6932a4f10e991dce1551814ac551a5740 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomBoundedQuery.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomGlobalQuery +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomRequestBounds +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalBoundedQuery +import OAI.Combinatorics.EditApproximation.Geometry.SourceRankedRestriction +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +section Bounded + +variable {σ α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (readGroup : ℕ → ℕ → PhysicalInternalNode M J → Fin R → GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : ℕ → ℕ → PhysicalInternalNode M J → Fin R → + (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (initial : PhysicalEntry M J target.length → ℕ) + + theorem physicalRandomGlobalQuery_keys_bounded (request : PhysicalTableRequest M J target.length) + (hrequest : request.Bounded passes copies T S) (oracle) : + ∀ key ∈ (physicalRandomGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial request).keys oracle, + SourceRanked.supportedChild (PhysicalTableRequest.combinedRank T S) + (PhysicalTableRequest.Bounded passes copies T S) request key := by + unfold physicalRandomGlobalQuery + by_cases ha : T < request.index ∧ request.node.1.val < J ∧ + ¬ (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1 + · rw [dite_eq_left ha, FiniteQuery.mapKeys_keys] + intro key hk + obtain ⟨other, ho, rfl⟩ := List.mem_map.mp hk + have hi := physicalRandomDataRequest_keys_bounded source target N P F exponent H Q tau + (refinementFactor (factor request.pass) F) eta kappa delta passes copies request.pass request.copy T S + (request.index - T) (Nat.sub_pos_of_lt ha.1) (by have := hrequest.2.2; omega) + hrequest.1 hrequest.2.1 request.node ha.2.1 + (readGroup request.pass request.copy ⟨request.node, ha.2.1⟩ (Fin.ofNat R (request.index - T - 1))) + (readInteger request.pass request.copy ⟨request.node, ha.2.1⟩ (Fin.ofNat R (request.index - T - 1))) + request.state _ other ho + cases other <;> exact hi + · rw [dite_eq_right ha, FiniteQuery.mapKeys_keys] + intro key hk + obtain ⟨other, ho, rfl⟩ := List.mem_map.mp hk + rw [physicalGlobalQuery_inactive (R := R) source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta initial (fun _ _ _ _ _ _ _ _ => 0) (fun _ _ _ _ _ _ => 0) request ha] at ho + exact physicalGlobalQuery_keys_bounded (R := R) source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta (fun _ _ _ _ _ _ _ _ => 0) (fun _ _ _ _ _ _ => 0) + initial request hrequest _ other ho + + + + theorem physicalRandomBoundedQuery_value + (sourceValue : σ → ℚ) (tableValue : PhysicalTableRequest M J target.length → ℚ) + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) : + (physicalRandomBoundedQuery source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta readGroup readInteger initial request).value + (Sum.elim sourceValue (fun key => tableValue key.val.val)) = + (physicalRandomGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial request.val).value + (Sum.elim sourceValue (fun key => tableValue key.val)) := by + unfold physicalRandomBoundedQuery + exact SourceRanked.restrictBody_value _ _ _ _ _ request + (physicalRandomGlobalQuery_keys_bounded source target N P F exponent H Q T S passes copies + factor multiplier tau eta kappa delta readGroup readInteger initial request.val request.property _) + +end Bounded + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomDataRequest.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomDataRequest.lean new file mode 100644 index 0000000000000000000000000000000000000000..172470730f528a0ca6c14e07766bbeec7e2da156 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomDataRequest.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.EditApproximation.Geometry.LocalRandomDataQuery +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementDataRequest +import OAI.Combinatorics.EditApproximation.Probability.FiniteQueryRestriction +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! A physical refinement request with source reads interleaved with ranked +table requests. The requested online range is calculated after the child +mass values are returned. -/ + +namespace EditApproximation + +section CompleteStep + +variable {σ α : Type*} (source target : List α) {M J : ℕ} [NeZero M] + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (readGroup : GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (q : TargetInterval target.length) + + + +theorem physicalRandomDataRequestQuery_value (answer : PhysicalTableRequest M J target.length → ℚ) + (sourceAnswer : σ → ℚ) (draw : CellGroupDraws M F Q) + (integer : ℕ → TargetInterval target.length → ℕ) + (hgroup : ∀ key, (readGroup key).value sourceAnswer = groupScalarValue draw key) + (honline : ∀ key, + (readInteger key (keyedOnlineSourceRange source target (physicalSourceInterval source.length node) + P exponent H tau (fun i r => (∑ j : Fin T, answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow i) j.val r)) / T) key)).value sourceAnswer = + (integer key.1 key.2 : ℚ)) : + let parentInitial := fun r => answer (PhysicalTableRequest.warmup pass copy node 0 r) + let child := fun i r => (∑ j : Fin T, answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow i) j.val r)) / T + let initial := fun i r => answer (PhysicalTableRequest.warmup pass copy (physicalChild node hbelow i) 0 r) + let children := fun i s r => answer (PhysicalTableRequest.refinement pass copy + (physicalChild node hbelow i) T s r) + (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).value (Sum.elim sourceAnswer (fun request => answer request.val)) = + rationalLocalWideStep source target (physicalSourceInterval source.length node) + N P F exponent Q tau a delta parentInitial child initial + (fun i r => children i (t - 1) r) (fun i r => children i t r) draw + (localOnlineCandidates source target (physicalSourceInterval source.length node) + N P F exponent H tau a eta kappa parentInitial child initial children (t - 1) integer q) q := by + dsimp only + let earlier := fun i s r => answer (PhysicalTableRequest.refinement pass copy (physicalChild node hbelow i) T s r) + let masked := fun i s r => if s < t then earlier i s r else 0 + let parentInitial := fun r => answer (PhysicalTableRequest.warmup pass copy node 0 r) + let child := fun i r => (∑ j : Fin T, answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow i) j.val r)) / T + let initial := fun i r => answer (PhysicalTableRequest.warmup pass copy (physicalChild node hbelow i) 0 r) + have he (input : Fin M × ℕ × TargetInterval target.length) : + (physicalRefinementEarlierQuery pass copy T S t node hbelow q input).value + (fun request => answer request.val) = masked input.1 input.2.1 input.2.2 := by + unfold physicalRefinementEarlierQuery + split_ifs with hs + · simp only [FiniteQuery.value, masked, ite_eq_left hs, earlier] + · simp only [FiniteQuery.value, masked, ite_eq_right hs] + rw [physicalRandomDataRequestQuery, + localRandomDataQuery_value source target (physicalSourceInterval source.length node) + N P F exponent H Q tau a eta kappa delta t _ _ _ _ _ q _ _ _ draw integer + parentInitial child initial masked (fun i r => earlier i t r) ht] + · have hprev : (fun i r => masked i (t - 1) r) = fun i r => earlier i (t - 1) r := by + funext i r + exact ite_eq_left (by omega : t - 1 < t) + have honline := localOnlineCandidates_congr_earlier_cover source target + (physicalSourceInterval source.length node) N P F exponent H t tau a eta kappa + parentInitial child initial masked earlier (t - 1) integer q (by omega) + (fun i s r hr => ite_eq_left (wideEarlierInputCover_time _ P t _ (i, s, r) hr)) + rw [hprev, honline] + · intro r + rw [FiniteQuery.mapKeys_value] + rfl + · intro input + rw [FiniteQuery.mapKeys_value] + exact physicalRefinementMassQuery_value pass copy T S t ht node hbelow q input answer + · intro input + rw [FiniteQuery.mapKeys_value] + rfl + · intro input + rw [FiniteQuery.mapKeys_value] + exact he input + · intro key + rw [FiniteQuery.mapKeys_value] + exact hgroup key + · intro key + rw [FiniteQuery.mapKeys_value] + exact honline key + · intro input + rw [FiniteQuery.mapKeys_value] + rfl + +end CompleteStep + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomGlobalProgress.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomGlobalProgress.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5cc7388492df8a333f311f7feb9ed264a3b26da --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomGlobalProgress.lean @@ -0,0 +1,61 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomGlobalQuery +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomRequestProgress +import OAI.Combinatorics.EditApproximation.Geometry.GlobalQueryProgress + +namespace OAI + +namespace EditApproximation + +section Progress + +variable {σ α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P F exponent H Q T S copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (readGroup : ℕ → ℕ → PhysicalInternalNode M J → Fin R → GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : ℕ → ℕ → PhysicalInternalNode M J → Fin R → + (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (initial : PhysicalEntry M J target.length → ℕ) + + theorem physicalRandomGlobalQuery_keys_progress (request : PhysicalTableRequest M J target.length) + (oracle) : + ∀ key ∈ (physicalRandomGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial request).keys oracle, + match key with + | .inl _ => True + | .inr table => PhysicalTableRequest.DependencyProgress T S request table.val := by + unfold physicalRandomGlobalQuery + by_cases ha : T < request.index ∧ request.node.1.val < J ∧ + ¬ (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1 + · rw [dite_eq_left ha, FiniteQuery.mapKeys_keys] + intro key hk + obtain ⟨other, ho, rfl⟩ := List.mem_map.mp hk + have hi := physicalRandomDataRequest_keys_progress source target N P F exponent H Q tau + (refinementFactor (factor request.pass) F) eta kappa delta request.pass request.copy T S + (request.index - T) (Nat.sub_pos_of_lt ha.1) request.node ha.2.1 + (readGroup request.pass request.copy ⟨request.node, ha.2.1⟩ (Fin.ofNat R (request.index - T - 1))) + (readInteger request.pass request.copy ⟨request.node, ha.2.1⟩ (Fin.ofNat R (request.index - T - 1))) + request.state _ other ho + have heq : PhysicalTableRequest.refinement request.pass request.copy request.node + T (request.index - T) request.state = request := by + unfold PhysicalTableRequest.refinement + have ht : T + (request.index - T) = request.index := + Nat.add_sub_of_le (Nat.le_of_lt ha.1) + rw [ht] + cases other with + | inl key => trivial + | inr table => simpa only [Sum.map_inr, heq] using hi + · rw [dite_eq_right ha, FiniteQuery.mapKeys_keys] + intro key hk + obtain ⟨other, ho, rfl⟩ := List.mem_map.mp hk + rw [physicalGlobalQuery_inactive (R := R) source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta initial (fun _ _ _ _ _ _ _ _ => 0) (fun _ _ _ _ _ _ => 0) request ha] at ho + exact physicalGlobalQuery_keys_progress (R := R) source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta (fun _ _ _ _ _ _ _ _ => 0) (fun _ _ _ _ _ _ => 0) + initial request _ other ho + +end Progress + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomGlobalQuery.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomGlobalQuery.lean new file mode 100644 index 0000000000000000000000000000000000000000..82ed57449a92539da500f6b03676e59f3f1e3d05 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomGlobalQuery.lean @@ -0,0 +1,145 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomDataRequest +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalGlobalValue +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Global physical table bodies with explicit random reads. Only positive +internal refinement steps request random coordinates. All other cases +use finite warmup and initial queries. -/ + +namespace EditApproximation + +private theorem inactiveIfEq {β : Type*} (a b c : Prop) [Decidable a] [Decidable b] [Decidable c] + (x y : β) (z : ¬ a → b → ¬ c → β) (h : ¬ (¬ a ∧ b ∧ ¬ c)) : + (if a then x else y) = + (if ha : a then x else if hb : b then if hc : c then y else z ha hb hc else y) := by + by_cases ha : a + · simp only [ite_eq_left ha, dite_eq_left ha] + · by_cases hb : b + · have hc : c := by + by_contra hc + exact h ⟨ha, hb, hc⟩ + simp only [ite_eq_right ha, dite_eq_right ha, dite_eq_left hb, dite_eq_left hc] + · simp only [ite_eq_right ha, dite_eq_right ha, dite_eq_right hb] + +section Global + +variable {σ α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P F exponent H Q T S copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (readGroup : ℕ → ℕ → PhysicalInternalNode M J → Fin R → GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : ℕ → ℕ → PhysicalInternalNode M J → Fin R → + (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (initial : PhysicalEntry M J target.length → ℕ) + + + + + +omit [NeZero M] in + theorem physicalGlobalQuery_inactive + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (request : PhysicalTableRequest M J target.length) + (hinactive : ¬ (T < request.index ∧ request.node.1.val < J ∧ + ¬ (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1)) : + physicalInactiveGlobalQuery source target N P F T S copies factor multiplier initial request = + physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request := by + unfold physicalInactiveGlobalQuery physicalGlobalQuery + dsimp only + apply inactiveIfEq + rintro ⟨hi, hb, hs⟩ + exact hinactive ⟨Nat.lt_of_not_ge hi, hb, hs⟩ + + theorem physicalRandomGlobalQuery_inactive + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (request : PhysicalTableRequest M J target.length) + (hinactive : ¬ (T < request.index ∧ request.node.1.val < J ∧ + ¬ (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1)) : + physicalRandomGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial request = + FiniteQuery.mapKeys Sum.inr (physicalGlobalQuery source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta group integer initial request) := by + unfold physicalRandomGlobalQuery + rw [dite_eq_right hinactive, + physicalGlobalQuery_inactive source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta initial group integer request hinactive] + + theorem physicalRandomGlobalQuery_active_value (request : PhysicalTableRequest M J target.length) + (hactive : T < request.index ∧ request.node.1.val < J ∧ + ¬ (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1) + (sourceAnswer : σ → ℚ) (values : PhysicalTableRequest M J target.length → ℚ) : + (physicalRandomGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial request).value + (Sum.elim sourceAnswer (fun child => values child.val)) = + (physicalRandomDataRequestQuery source target N P F exponent H Q tau + (refinementFactor (factor request.pass) F) eta kappa delta request.pass request.copy T S + (request.index - T) (Nat.sub_pos_of_lt hactive.1) request.node hactive.2.1 + (readGroup request.pass request.copy ⟨request.node, hactive.2.1⟩ + (Fin.ofNat R (request.index - T - 1))) + (readInteger request.pass request.copy ⟨request.node, hactive.2.1⟩ + (Fin.ofNat R (request.index - T - 1))) request.state).value + (Sum.elim sourceAnswer (fun child => values child.val)) := by + unfold physicalRandomGlobalQuery + rw [dite_eq_left hactive, FiniteQuery.mapKeys_value] + congr 1 + funext next + cases next <;> rfl + + theorem physicalRandomGlobalQuery_compare + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (sourceAnswer : σ → ℚ) (values : PhysicalTableRequest M J target.length → ℚ) + (hgroup : ∀ pass copy node time key, (readGroup pass copy node time key).value sourceAnswer = + groupScalarValue (group pass copy node time) key) + (honline : ∀ pass copy (node : PhysicalInternalNode M J) time key, + (readInteger pass copy node time key + (keyedOnlineSourceRange source target (physicalSourceInterval source.length node.val) + P exponent H tau (fun i r => (∑ j : Fin T, values (PhysicalTableRequest.warmup pass copy + (physicalChild node.val node.property i) j.val r)) / T) key)).value sourceAnswer = + (integer pass copy node time key.1 key.2 : ℚ)) + (request : PhysicalTableRequest M J target.length) : + (physicalRandomGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial request).value + (Sum.elim sourceAnswer (fun child => values child.val)) = + (physicalGlobalQuery source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request).value (fun child => values child.val) := by + by_cases ha : T < request.index ∧ request.node.1.val < J ∧ + ¬ (physicalSourceInterval source.length request.node).hi - + (physicalSourceInterval source.length request.node).lo ≤ 1 + · rw [physicalRandomGlobalQuery_active_value source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta readGroup readInteger initial request ha sourceAnswer values] + rw [physicalGlobalQuery_refinement_value source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta group integer initial request ha.1 ha.2.1 ha.2.2 values] + let node : PhysicalInternalNode M J := ⟨request.node, ha.2.1⟩ + let time : Fin R := Fin.ofNat R (request.index - T - 1) + have hg := hgroup request.pass request.copy node time + have hi := honline request.pass request.copy node time + have hnew := physicalRandomDataRequestQuery_value source target N P F exponent H Q tau + (refinementFactor (factor request.pass) F) eta kappa delta request.pass request.copy T S + (request.index - T) (Nat.sub_pos_of_lt ha.1) request.node ha.2.1 + (readGroup request.pass request.copy node time) (readInteger request.pass request.copy node time) + request.state values sourceAnswer (group request.pass request.copy node time) + (integer request.pass request.copy node time) hg hi + have hold := physicalRefinementDataRequestQuery_value source target N P F exponent H Q tau + (refinementFactor (factor request.pass) F) eta kappa delta request.pass request.copy T S + (request.index - T) (Nat.sub_pos_of_lt ha.1) request.node ha.2.1 + (group request.pass request.copy node time) (integer request.pass request.copy node time) + request.state values + exact hnew.trans hold.symm + · rw [physicalRandomGlobalQuery_inactive source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial group integer request ha, FiniteQuery.mapKeys_value] + rfl + +end Global + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomPassCopy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomPassCopy.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1730d289ab599d4d56b38e73b0c852fbabfc993 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomPassCopy.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomDataRequest +import OAI.Combinatorics.EditApproximation.Geometry.LocalRandomQueryKeys +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalQueryProgress + +namespace OAI + +/-! Every recursive table read of an adaptive random query stays in the same +pass and copy and has no larger local index. -/ + +namespace EditApproximation + + theorem physicalRandomDataRequest_keys_pass_copy {σ α : Type*} (source target : List α) + {M J : ℕ} [NeZero M] (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (readGroup : GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (q : TargetInterval target.length) (oracle) : + ∀ key ∈ (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).keys oracle, + match key with + | .inl _ => True + | .inr table => table.val.pass = pass ∧ table.val.copy = copy ∧ table.val.index ≤ T + t := by + unfold physicalRandomDataRequestQuery + apply localRandomDataQuery_keys_all + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key _ + trivial + · intro input range + apply FiniteQuery.keys_all_mapKeys + intro key _ + trivial + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + unfold physicalRefinementEarlierQuery at hk + split_ifs at hk with hs + · simp only [FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact ⟨rfl, rfl, by change T + input.2.1 ≤ T + t; omega⟩ + · exact False.elim (List.not_mem_nil hk) + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + simp only [physicalRefinementCurrentQuery, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact ⟨rfl, rfl, le_rfl⟩ + · intro r + apply FiniteQuery.keys_all_mapKeys + intro key hk + exact physicalRefinementWarmupRead_keys_pass_copy pass copy T S t ht node q node le_rfl + 0 (Nat.zero_le T) r _ key hk + · intro input + apply FiniteQuery.keys_all_mapKeys + unfold physicalRefinementMassQuery + apply FiniteQuery.keys_all_collect + · intro j _ key hk + exact physicalRefinementWarmupRead_keys_pass_copy pass copy T S t ht node q + (physicalChild node hbelow input.1) _ j.val (Nat.le_of_lt j.isLt) input.2 _ key hk + · intro values key hk + exact False.elim (List.not_mem_nil hk) + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + exact physicalRefinementWarmupRead_keys_pass_copy pass copy T S t ht node q + (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 _ key hk + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRankCost.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRankCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..46a7b8c7bd5cb876026f80ab5f6850da234da274 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRankCost.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomPassCopy +import OAI.Combinatorics.EditApproximation.Geometry.GlobalQueryCost + +namespace OAI + +/-! For a fixed pass, the physical rank partition equals the concrete +warmup/refinement index partition on every emitted data-query key. -/ + +namespace EditApproximation + +section Costs + +variable {σ α : Type*} (source target : List α) {M J : ℕ} [NeZero M] + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (readGroup : GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (sourceAnswer : σ → ℚ) + (q : TargetInterval target.length) (answer : PhysicalTableRequest M J target.length → ℚ) + +theorem physicalRandomDataRequest_same_rank_cost : + (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).cost (Sum.elim sourceAnswer (fun child => answer child.val)) + (Sum.elim (fun _ => 0) (fun child => if ¬ child.val.rank T S < + (PhysicalTableRequest.refinement pass copy node T t q).rank T S then 1 else 0)) = + (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).cost (Sum.elim sourceAnswer (fun child => answer child.val)) + (Sum.elim (fun _ => 0) (fun child => physicalCurrentReadWeight (T + t) child.val)) := by + apply FiniteQuery.cost_congr_weights + intro key hk + have hkey := physicalRandomDataRequest_keys_pass_copy source target N P F exponent H Q + tau a eta kappa delta pass copy T S t ht node hbelow readGroup readInteger q _ key hk + cases key with + | inl key => rfl + | inr key => + simp only [Sum.elim_inr] + have heq := PhysicalTableRequest.rank_not_lt_iff_index_eq_of_pass T S + (PhysicalTableRequest.refinement pass copy node T t q) key.val hkey.1 hkey.2.2 + by_cases hi : key.val.index = T + t + · have hr := heq.mpr hi + simp only [ite_eq_left hr, physicalCurrentReadWeight, ite_eq_left hi] + · have hr : ¬ ¬ key.val.rank T S < + (PhysicalTableRequest.refinement pass copy node T t q).rank T S := fun h => hi (heq.mp h) + simp only [ite_eq_right hr, physicalCurrentReadWeight, ite_eq_right hi] + +theorem physicalRandomDataRequest_earlier_rank_cost : + (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).cost (Sum.elim sourceAnswer (fun child => answer child.val)) + (Sum.elim (fun _ => 0) (fun child => if child.val.rank T S < + (PhysicalTableRequest.refinement pass copy node T t q).rank T S then 1 else 0)) = + (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).cost (Sum.elim sourceAnswer (fun child => answer child.val)) + (Sum.elim (fun _ => 0) (fun child => physicalEarlierReadWeight (T + t) child.val)) := by + apply FiniteQuery.cost_congr_weights + intro key hk + have hkey := physicalRandomDataRequest_keys_pass_copy source target N P F exponent H Q + tau a eta kappa delta pass copy T S t ht node hbelow readGroup readInteger q _ key hk + cases key with + | inl key => rfl + | inr key => + simp only [Sum.elim_inr] + have heq := PhysicalTableRequest.rank_lt_iff_index_lt_of_pass T S + (PhysicalTableRequest.refinement pass copy node T t q) key.val hkey.1 + by_cases hi : key.val.index < T + t + · have hr := heq.mpr hi + simp only [ite_eq_left hr, physicalEarlierReadWeight, ite_eq_left hi] + · have hr : ¬ key.val.rank T S < + (PhysicalTableRequest.refinement pass copy node T t q).rank T S := fun h => hi (heq.mp h) + simp only [ite_eq_right hr, physicalEarlierReadWeight, ite_eq_right hi] + +end Costs + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRequestBounds.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRequestBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..637bdc794e01d2911ee46c6f123376579067a49c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRequestBounds.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomDataRequest +import OAI.Combinatorics.EditApproximation.Geometry.LocalRandomQueryKeys +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementReadWork + +namespace OAI + +namespace EditApproximation + +theorem physicalRandomDataRequest_keys_bounded {σ α : Type*} (source target : List α) {M J : ℕ} [NeZero M] + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (passes copies pass copy T S t : ℕ) (ht : 0 < t) (htS : t ≤ S) + (hpass : pass < passes) (hcopy : copy < copies) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (readGroup : GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (q : TargetInterval target.length) (oracle) : + ∀ key ∈ (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).keys oracle, + (match key with | .inl _ => True | .inr table => table.val.Bounded passes copies T S) := by + unfold physicalRandomDataRequestQuery + apply localRandomDataQuery_keys_all + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key _ + trivial + · intro input range + apply FiniteQuery.keys_all_mapKeys + intro key _ + trivial + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + unfold physicalRefinementEarlierQuery at hk + split_ifs at hk with hs + · simp only [FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_bounded passes copies pass copy + (physicalChild node hbelow input.1) T S input.2.1 input.2.2 hpass hcopy (by omega) + · exact False.elim (List.not_mem_nil hk) + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + simp only [physicalRefinementCurrentQuery, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_bounded passes copies pass copy + (physicalChild node hbelow input.1) T S t input.2 hpass hcopy htS + · intro r + apply FiniteQuery.keys_all_mapKeys + intro key hk + exact physicalRefinementWarmupRead_keys_bounded passes copies pass copy T S t ht hpass hcopy + node q node le_rfl 0 (Nat.zero_le T) r _ key hk + · intro input + apply FiniteQuery.keys_all_mapKeys + unfold physicalRefinementMassQuery + apply FiniteQuery.keys_all_collect + · intro j _ key hk + exact physicalRefinementWarmupRead_keys_bounded passes copies pass copy T S t ht hpass hcopy + node q (physicalChild node hbelow input.1) _ j.val (Nat.le_of_lt j.isLt) input.2 _ key hk + · intro values key hk + exact False.elim (List.not_mem_nil hk) + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + exact physicalRefinementWarmupRead_keys_bounded passes copies pass copy T S t ht hpass hcopy + node q (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 _ key hk + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRequestProgress.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRequestProgress.lean new file mode 100644 index 0000000000000000000000000000000000000000..85e1489d3c761b6b1d3659b4c710325c74d099c1 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomRequestProgress.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomDataRequest +import OAI.Combinatorics.EditApproximation.Geometry.LocalRandomQueryKeys +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalQueryProgress + +namespace OAI + +/-! Adding source reads preserves the actual tree/index progress of all +physical table dependencies. Source coordinates have no table dependency. -/ + +namespace EditApproximation + + theorem physicalRandomDataRequest_keys_progress {σ α : Type*} (source target : List α) + {M J : ℕ} [NeZero M] (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (readGroup : GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (q : TargetInterval target.length) (oracle) : + ∀ key ∈ (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).keys oracle, + match key with + | .inl _ => True + | .inr table => PhysicalTableRequest.DependencyProgress T S + (PhysicalTableRequest.refinement pass copy node T t q) table.val := by + unfold physicalRandomDataRequestQuery + apply localRandomDataQuery_keys_all + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key _ + trivial + · intro input range + apply FiniteQuery.keys_all_mapKeys + intro key _ + trivial + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + unfold physicalRefinementEarlierQuery at hk + split_ifs at hk with hs + · simp only [FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_child_earlier_progress pass copy T S t input.2.1 + node hbelow input.1 q input.2.2 hs + · exact False.elim (List.not_mem_nil hk) + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + simp only [physicalRefinementCurrentQuery, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_child_same_progress pass copy T S t node hbelow input.1 q input.2 + · intro r + apply FiniteQuery.keys_all_mapKeys + intro key hk + exact physicalRefinementWarmupRead_keys_progress pass copy T S t ht node q node le_rfl + 0 (Nat.zero_le T) r _ key hk + · intro input + apply FiniteQuery.keys_all_mapKeys + unfold physicalRefinementMassQuery + apply FiniteQuery.keys_all_collect + · intro j _ key hk + exact physicalRefinementWarmupRead_keys_progress pass copy T S t ht node q + (physicalChild node hbelow input.1) _ j.val (Nat.le_of_lt j.isLt) input.2 _ key hk + · intro values key hk + exact False.elim (List.not_mem_nil hk) + · intro input + apply FiniteQuery.keys_all_mapKeys + intro key hk + exact physicalRefinementWarmupRead_keys_progress pass copy T S t ht node q + (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 _ key hk + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomSourceCost.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomSourceCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e12786cdd24f8e71ea89e8a4f2015aa42dcdd01 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomSourceCost.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomDataRequest +import OAI.Combinatorics.EditApproximation.Geometry.LocalRandomSourceCost + +namespace OAI + +namespace EditApproximation + +namespace FiniteQuery + + theorem mapRight_source_cost {σ κ : Type*} (query : FiniteQuery κ) + (source : σ → ℚ) (table : κ → ℚ) (weight : σ → ℕ) : + (mapKeys Sum.inr query).cost (Sum.elim source table) (Sum.elim weight (fun _ => 0)) = 0 := by + rw [mapKeys_cost] + exact cost_zero table query + + theorem mapRight_source_keys {σ κ : Type*} (query : FiniteQuery κ) + (source : σ → ℚ) (table : κ → ℚ) (weight : σ → ℕ) : + ∀ key ∈ (mapKeys Sum.inr query).keys (Sum.elim source table), + (Sum.elim weight (fun _ => 0)) key = 0 := by + rw [mapKeys_keys] + intro key hk + obtain ⟨other, _, rfl⟩ := List.mem_map.mp hk + rfl + +end FiniteQuery + + theorem physicalRandomDataRequest_source_cost_le {σ α : Type*} (source target : List α) + {M J : ℕ} [NeZero M] (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (readGroup : GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (q : TargetInterval target.length) (sourceAnswer : σ → ℚ) + (answer : PhysicalTableRequest M J target.length → ℚ) (weight : σ → ℕ) + (groupBound onlineBound : ℕ) + (hgroup : ∀ key, (readGroup key).cost sourceAnswer weight ≤ groupBound) + (honline : ∀ key range, (readInteger key range).cost sourceAnswer weight ≤ onlineBound) : + let initial := fun r => answer (PhysicalTableRequest.warmup pass copy node 0 r) + (physicalRandomDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow readGroup readInteger q).cost + (Sum.elim sourceAnswer (fun key => answer key.val)) (Sum.elim weight (fun _ => 0)) ≤ + (groupScalarKeys M F Q (localGroupQueryKeys N F exponent a initial q)).length * groupBound + + (localOnlineSourceKeys N P F a initial q).length * onlineBound := by + dsimp only + unfold physicalRandomDataRequestQuery + apply localRandomDataQuery_source_cost_le + · intro input + exact FiniteQuery.mapRight_source_cost _ _ _ _ + · intro input + exact FiniteQuery.mapRight_source_cost _ _ _ _ + · intro input + exact FiniteQuery.mapRight_source_keys _ _ _ _ + · intro input + exact FiniteQuery.mapRight_source_keys _ _ _ _ + · intro key + rw [FiniteQuery.mapKeys_cost] + exact hgroup key + · intro key range + rw [FiniteQuery.mapKeys_cost] + exact honline key range + · intro r + exact FiniteQuery.mapRight_source_cost _ _ _ _ + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomValue.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7a5aa95e319046d1457ab4ab5ed762227ac42b4 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRandomValue.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomBoundedQuery +import OAI.Combinatorics.EditApproximation.Geometry.LocalOnlineSourceQuery + +namespace OAI + +namespace EditApproximation + +section Values + +variable {σ α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) + +omit [NeZero M] in + theorem localRequestValue_onlineRange (pass copy : ℕ) (node : PhysicalInternalNode M J) + (key : ℕ × TargetInterval target.length) (hb : key.1 ∈ dyadicScales N) : + keyedOnlineSourceRange source target (physicalSourceInterval source.length node.val) P exponent H tau + (fun i r => (∑ j : Fin T, localRequestValue source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta group integer initial + (PhysicalTableRequest.warmup pass copy (physicalChild node.val node.property i) j.val r)) / T) key = + physicalLocalOnlineMass source target + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) N P F (factor pass) T exponent H tau + (node, physicalScaleIndex N key.1 hb, key.2) := by + have hmass : + (fun i r => (∑ j : Fin T, localRequestValue source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta group integer initial + (PhysicalTableRequest.warmup pass copy (physicalChild node.val node.property i) j.val r)) / T) = + physicalLocalChildMass source target + (localSeedSequence source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass) N P F (factor pass) T node.val node.property := by + funext i r + exact localRequestValue_mass source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial pass copy (physicalChild node.val node.property i) r + unfold keyedOnlineSourceRange physicalLocalOnlineMass physicalLocalOnlineBandG + rw [physicalScaleIndex_get, hmass] + +variable + (readGroup : ℕ → ℕ → PhysicalInternalNode M J → Fin R → GroupScalarKey M F Q → FiniteQuery σ) + (readInteger : ℕ → ℕ → PhysicalInternalNode M J → Fin R → + (ℕ × TargetInterval target.length) → ℕ → FiniteQuery σ) + (sourceAnswer : σ → ℚ) + (hgroup : ∀ pass copy node time key, (readGroup pass copy node time key).value sourceAnswer = + groupScalarValue (group pass copy node time) key) + (honline : ∀ pass copy (node : PhysicalInternalNode M J) time key, + (readInteger pass copy node time key + (keyedOnlineSourceRange source target (physicalSourceInterval source.length node.val) + P exponent H tau (fun i r => (∑ j : Fin T, localRequestValue source target N P F exponent H Q T S + copies factor multiplier tau eta kappa delta group integer initial (PhysicalTableRequest.warmup + pass copy (physicalChild node.val node.property i) j.val r)) / T) key)).value sourceAnswer = + (integer pass copy node time key.1 key.2 : ℚ)) + +include hgroup honline in + theorem physicalRandomBoundedQuery_localValue + (request : {request : PhysicalTableRequest M J target.length // request.Bounded passes copies T S}) : + (physicalRandomBoundedQuery source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta readGroup readInteger initial request).value + (Sum.elim sourceAnswer (fun key => localRequestValue source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta group integer initial key.val.val)) = + localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request.val := by + rw [physicalRandomBoundedQuery_value] + exact (physicalRandomGlobalQuery_compare source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta readGroup readInteger initial group integer sourceAnswer + (localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial) hgroup honline request.val).trans + (physicalGlobalQuery_value source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta group integer initial request.val) + +end Values + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRationalWarmup.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRationalWarmup.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b4b169b67422be871e129ea05345e54cfd18662 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRationalWarmup.lean @@ -0,0 +1,82 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalWarmup +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Rational execution of the physical wide-action warmup, with exact real casts. -/ + +namespace EditApproximation + +open Finset + + + +theorem rationalActualWideActions_toReal {nx ny M : ℕ} (parent : TargetInterval nx) + (representatives : List (ℕ × TargetInterval ny)) (P : ℕ) : + (rationalActualWideActions (M := M) parent representatives P).map RationalBellmanAction.toReal = + actualWideActions (M := M) parent representatives P := by + simp only [rationalActualWideActions, actualWideActions, List.map_flatMap, + List.map_map, Function.comp_def, RationalBellmanAction.toReal, Rat.cast_natCast] + +def rationalPhysicalBellman {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (value : PhysicalEntry M J target.length → ℚ) (state : PhysicalEntry M J target.length) : ℚ := + let parent := physicalSourceInterval source.length state.1 + if hbelow : state.1.1.val < J then + if parent.hi - parent.lo ≤ 1 then initial state else + rationalBellman (fun q => initial (state.1, q)) + (fun q r => targetEndpointDistance q r) L + (rationalActualWideActions parent (representatives state.1) P) + (fun is => value (physicalChild state.1 hbelow is.1, is.2)) state.2 + else initial state + +theorem rationalPhysicalBellman_cast {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (value : PhysicalEntry M J target.length → ℚ) (state : PhysicalEntry M J target.length) : + (rationalPhysicalBellman source target P L initial representatives value state : ℝ) = + physicalBellman source target P (L : ℝ) (fun s => (initial s : ℝ)) representatives + (fun s => (value s : ℝ)) state := by + classical + unfold rationalPhysicalBellman physicalBellman + dsimp only + split_ifs + · rfl + · rw [rationalBellman_cast, rationalActualWideActions_toReal] + simp only [actualWideBellman, Rat.cast_natCast] + · rfl + +def rationalPhysicalWarmup {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) : + ℕ → PhysicalEntry M J target.length → ℚ := + rationalWarmup (rationalPhysicalBellman source target P L initial representatives) initial + +theorem rationalPhysicalWarmup_cast {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (t : ℕ) (state : PhysicalEntry M J target.length) : + (rationalPhysicalWarmup source target P L initial representatives t state : ℝ) = + physicalWarmup source target P (L : ℝ) (fun s => (initial s : ℝ)) representatives t state := + rationalWarmup_cast _ _ _ (rationalPhysicalBellman_cast source target P L initial representatives) t state + +def rationalPhysicalWarmupAverage {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (T : ℕ) (state : PhysicalEntry M J target.length) : ℚ := + (∑ t ∈ range T, rationalPhysicalWarmup source target P L initial representatives t state) / T + +theorem rationalPhysicalWarmupAverage_cast {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℚ) (initial : PhysicalEntry M J target.length → ℚ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (T : ℕ) (state : PhysicalEntry M J target.length) : + (rationalPhysicalWarmupAverage source target P L initial representatives T state : ℝ) = + physicalWarmupAverage source target P (L : ℝ) (fun s => (initial s : ℝ)) representatives T state := by + simp only [rationalPhysicalWarmupAverage, physicalWarmupAverage, warmupAverage, + Rat.cast_div, Rat.cast_sum, Rat.cast_natCast, rationalPhysicalWarmup_cast, physicalWarmup] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRawGroupProgram.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRawGroupProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3fa60abe9235d477fd0078d504267917154d26d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRawGroupProgram.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalGroupKeys +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalGroupProgram + +namespace OAI + +/-! Whole-cell draws are read by their bounded scale and endpoint keys. +No list of all representatives or cells is searched by the provider. -/ + +namespace EditApproximation + +theorem physicalScaleIndex_of_get (N : ℕ) (scale : Fin (dyadicScales N).length) : + physicalScaleIndex N ((dyadicScales N).get scale) (List.get_mem _ scale) = scale := by + apply (dyadicScales_nodup N).injective_get + exact physicalScaleIndex_get N _ _ + +theorem dependentKeyTransport {ι κ : Type*} (label : ι → κ) (family : κ → Type*) + (value : ∀ index, family (label index)) (first second : ι) + (heq : first = second) (hlabel : label first = label second) : + Eq.mp (congrArg family hlabel) (value first) = value second := by + subst second + rfl + +section Raw + +variable (M J N n exponent F Q R : ℕ) [NeZero M] + (draw : ∀ key : PhysicalLocalGroupKey M J N n exponent, + PhysicalLocalGroupArray M J N n exponent F Q R key) + +def physicalRawGroupDraws (node : PhysicalInternalNode M J) (time : Fin R) : + CellGroupDraws M F Q := + fun b cell => + if hb : b ∈ dyadicScales N then + if hc : cell.1 ≤ n * 2 ^ exponent ∧ cell.2 ≤ n * 2 ^ exponent then + let key : PhysicalLocalGroupKey M J N n exponent := + (node, physicalScaleIndex N b hb, + ⟨cell.1, Nat.lt_succ_of_le hc.1⟩, ⟨cell.2, Nat.lt_succ_of_le hc.2⟩) + Eq.mp (congrArg (fun b => ParentGroupDraw M (groupDyadicScales M b F).length + (fun h => groupSampleCount M Q b (groupDyadicScaleAt M b F h))) + (physicalScaleIndex_get N b hb)) (draw key time) + else fun _ _ => 0 + else fun _ _ => 0 + +end Raw + +section Agreement + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F exponent Q : ℕ) (A : ℚ) + (draw : ∀ key : PhysicalLocalGroupKey M J N target.length exponent, + PhysicalLocalGroupArray M J N target.length exponent F Q R key) + +theorem physicalRawGroupDraws_get + (key : PhysicalGroupKey source target U N P F A exponent) (time : Fin R) : + physicalRawGroupDraws M J N target.length exponent F Q R draw key.1 time + ((dyadicScales N).get key.2.1) + ((physicalProgramCells source target U N P F A exponent key.1.1 + ((dyadicScales N).get key.2.1)).get key.2.2) = + draw (physicalGroupRawKey source target U N P F exponent A key) time := by + have hcell := physicalProgramCells_bounds source target U N P F exponent A key.1.1 + ((dyadicScales N).get key.2.1) (physicalGroupScale_positive source target U N P F exponent A key) + _ (List.get_mem _ key.2.2) + simp only [physicalRawGroupDraws, dite_eq_left (List.get_mem _ key.2.1), dite_eq_left hcell] + exact dependentKeyTransport (fun scale => (dyadicScales N).get scale) + (fun b => ParentGroupDraw M (groupDyadicScales M b F).length + (fun h => groupSampleCount M Q b (groupDyadicScaleAt M b F h))) + (fun scale => draw (key.1, scale, + ⟨_, Nat.lt_succ_of_le hcell.1⟩, ⟨_, Nat.lt_succ_of_le hcell.2⟩) time) + _ key.2.1 (physicalScaleIndex_of_get N key.2.1) + (physicalScaleIndex_get N _ (List.get_mem _ key.2.1)) + +theorem physicalGroupStreamsOfRaw : + physicalGroupStreamsOfKeys source target U N P F exponent Q A + (physicalRawGroupDraws M J N target.length exponent F Q R draw) = + fun node scale cell => draw + (physicalGroupRawKey source target U N P F exponent A ⟨node, scale, cell⟩) := by + funext node scale cell time + exact physicalRawGroupDraws_get source target U N P F exponent Q A draw ⟨node, scale, cell⟩ time + +end Agreement + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRawOnlineProgram.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRawOnlineProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..4dc0171e4f422c71a71852bc28a3d1d4013b19b2 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRawOnlineProgram.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalOnlineKeys +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalProgramEquality + +namespace OAI + +/-! The local online provider reads a scale/center key directly; the +complete representative index identifies the corresponding action. -/ + +namespace EditApproximation + +theorem localOnlineCandidates_integer_congr {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (N P F exponent H : ℕ) (tau a eta kappa : ℚ) + (parentInitial : TargetInterval target.length → ℚ) + (child initial : Fin M → TargetInterval target.length → ℚ) + (children : PhysicalChildTables M target.length) (t : ℕ) + (left right : ℕ → TargetInterval target.length → ℕ) (q : TargetInterval target.length) + (hequal : ∀ b ∈ dyadicQueryWindow N (parentInitial q) a F, + (b, roundInterval (seedGridSpacing b P) q) ∈ representativeList N P F a parentInitial → + left b (roundInterval (seedGridSpacing b P) q) = right b (roundInterval (seedGridSpacing b P) q)) : + localOnlineCandidates source target parent N P F exponent H tau a eta kappa + parentInitial child initial children t left q = + localOnlineCandidates source target parent N P F exponent H tau a eta kappa + parentInitial child initial children t right q := by + unfold localOnlineCandidates + apply List.filterMap_congr + intro b hb + dsimp only + split_ifs with heligible + · have hrep := representativeList_mem a parentInitial _ (List.mem_filter.mp hb).1 + (roundInterval_on_grid _ q) heligible.1 heligible.2 + rw [hequal b hb hrep] + · rfl + +section Program + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T exponent H : ℕ) (tau eta kappa : ℚ) + (draw : PhysicalLocalOnlineDraw source target U N P F A R T exponent H tau) + +def physicalRawOnlineIntegers (node : PhysicalInternalNode M J) (time : Fin R) + (b : ℕ) (r : TargetInterval target.length) : ℕ := + if hb : b ∈ dyadicScales N then + (draw (node, physicalScaleIndex N b hb, r) time).val + else 0 + +variable (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + +def physicalOnlineStreamsOfRaw : + PhysicalOnlineStreams source target U N P F A T exponent H tau R := + fun node representative time => + Fin.cast (physicalLocalOnlineMass_on_key source target U N P F A T exponent H tau + hsize hP hF hA hseed ⟨node, representative⟩) + (draw (physicalOnlineRawKey source target U N P F A ⟨node, representative⟩) time) + +omit [NeZero R] in +theorem physicalRawOnlineIntegers_get (node : PhysicalInternalNode M J) + (representative : Fin (stageRepresentatives source target U N P F A node.1).length) + (time : Fin R) : + physicalRawOnlineIntegers source target U N P F A T exponent H tau draw node time + ((stageRepresentatives source target U N P F A node.1).get representative).1 + ((stageRepresentatives source target U N P F A node.1).get representative).2 = + (physicalOnlineStreamsOfRaw source target U N P F A T exponent H tau draw + hsize hP hF hA hseed node representative time).val := by + unfold physicalRawOnlineIntegers physicalOnlineStreamsOfRaw + rw [dite_eq_left (representativeList_scale_mem _ _ (List.get_mem _ representative))] + exact (Fin.val_cast + (physicalLocalOnlineMass_on_key source target U N P F A T exponent H tau + hsize hP hF hA hseed ⟨node, representative⟩) + (draw (physicalOnlineRawKey source target U N P F A ⟨node, representative⟩) time)).symm + +theorem physicalRawOnline_eq_adapter : + physicalLocalOnline source target U N P F exponent H T A tau eta kappa + (physicalRawOnlineIntegers source target U N P F A T exponent H tau draw) = + physicalLocalOnline source target U N P F exponent H T A tau eta kappa + (physicalOnlineIntegersOfStreams source target U N P F exponent H T A tau + (physicalOnlineStreamsOfRaw source target U N P F A T exponent H tau draw + hsize hP hF hA hseed)) := by + funext node children t q + unfold physicalLocalOnline + split_ifs with hbelow + · apply localOnlineCandidates_integer_congr + intro b _hb hrep + obtain ⟨representative, hget⟩ := List.mem_iff_get.mp hrep + change (stageRepresentatives source target U N P F A node).get representative = + (b, roundInterval (seedGridSpacing b P) q) at hget + have hraw := physicalRawOnlineIntegers_get source target U N P F A T exponent H tau draw + hsize hP hF hA hseed ⟨node, hbelow⟩ representative (Fin.ofNat R (t - 1)) + have hold := physicalOnlineIntegersOfStreams_get source target U N P F exponent H T A tau + (physicalOnlineStreamsOfRaw source target U N P F A T exponent H tau draw + hsize hP hF hA hseed) ⟨node, hbelow⟩ representative (Fin.ofNat R (t - 1)) + rw [hget] at hraw hold + exact hraw.trans hold.symm + · rfl + +theorem physicalRawOnlineProgram_eq (Q : ℕ) (delta : ℚ) + (groups : PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (node : PhysicalNode M J) (t : ℕ) (q : TargetInterval target.length) : + physicalLocalRefinement source target U N P F exponent Q A tau delta T + (fun label s => groups label (Fin.ofNat R (s - 1))) + (physicalLocalOnline source target U N P F exponent H T A tau eta kappa + (physicalRawOnlineIntegers source target U N P F A T exponent H tau draw)) node t q = + physicalRefinement source target U N P F A T delta + (physicalProgramSelections source target U N P F A T exponent H Q tau eta kappa + (physicalOnlineStreamsOfRaw source target U N P F A T exponent H tau draw + hsize hP hF hA hseed) + (physicalGroupStreamsOfKeys source target U N P F exponent Q A groups)) node t q := by + rw [physicalRawOnline_eq_adapter source target U N P F A T exponent H tau eta kappa draw + hsize hP hF hA hseed] + exact physicalLocalProgram_eq source target U N P F exponent Q H T A tau delta eta kappa + _ groups hsize hP hF hA hseed node t q + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinement.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinement.lean new file mode 100644 index 0000000000000000000000000000000000000000..217c809378e191b03ae2d2c9d7fc6f1678ef0ba6 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinement.lean @@ -0,0 +1,101 @@ +import OAI.Combinatorics.EditApproximation.Numerics.RationalWideStep +import OAI.Combinatorics.EditApproximation.Refinement.StageWarmup +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLeaves +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! +The complete physical refinement recurrence. Current-index recursive requests +go only to physical children. The selection interface records literal wide +list membership, and carries no approximation or probability assumption. +-/ + +namespace EditApproximation + + + + + +structure PhysicalSelections (M J nx ny P : ℕ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval ny)) where + groups : PhysicalNode M J → PhysicalChildTables M ny → ℕ → List (PhysicalRationalAction M ny) + online : PhysicalNode M J → PhysicalChildTables M ny → ℕ → TargetInterval ny → + List (PhysicalRationalAction M ny) + groups_mem : ∀ node children t action, action ∈ groups node children t → + action ∈ rationalActualWideActions (physicalSourceInterval nx node) (representatives node) P + online_mem : ∀ node children t q action, action ∈ online node children t q → + action ∈ rationalActualWideActions (physicalSourceInterval nx node) (representatives node) P + +def physicalRefinement {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) : ℕ → TargetInterval target.length → ℚ := + if hbelow : node.1.val < J then + if (physicalSourceInterval source.length node).hi - (physicalSourceInterval source.length node).lo ≤ 1 then + fun _ q => stageInitial source target U N P F A (node, q) + else + let children : PhysicalChildTables M target.length := fun i => + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow i) + fun t q => match t with + | 0 => stageWarmup source target U N P F A T (node, q) + | s + 1 => rationalWideStep (physicalSourceInterval source.length node) + (stageRepresentatives source target U N P F A node) P + (fun r => stageInitial source target U N P F A (node, r)) (128 * F) delta + (fun is => children is.1 s is.2) (fun is => children is.1 (s + 1) is.2) + (choices.groups node children (s + 1)) (choices.online node children (s + 1) q) q + else fun _ q => stageInitial source target U N P F A (node, q) +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +theorem physicalRefinement_at_leaf {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) + (hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (t : ℕ) (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node t q = + stateEditCost (physicalSource source node) target q := by + rw [physicalRefinement] + have hlength : (physicalSource source node).length ≤ 1 := (physicalSource_length_eq source node).trans_le hleaf + split_ifs <;> + simp only [stageInitial, physicalInitialTable, ite_eq_left hlength, + shortSourceCost_eq_edit _ _ hlength] <;> rfl + +theorem physicalRefinement_at_last_level {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hlast : node.1.val = J) (t : ℕ) (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node t q = + stageInitial source target U N P F A (node, q) := by + rw [physicalRefinement] + rw [dite_eq_right (by omega : ¬ node.1.val < J)] + +theorem physicalRefinement_succ {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (t : ℕ) (q : TargetInterval target.length) : + let children : PhysicalChildTables M target.length := fun i => + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow i) + physicalRefinement source target U N P F A T delta choices node (t + 1) q = + rationalWideStep (physicalSourceInterval source.length node) + (stageRepresentatives source target U N P F A node) P + (fun r => stageInitial source target U N P F A (node, r)) (128 * F) delta + (fun is => children is.1 t is.2) (fun is => children is.1 (t + 1) is.2) + (choices.groups node children (t + 1)) (choices.online node children (t + 1) q) q := by + rw [physicalRefinement] + rw [dite_eq_left hbelow, ite_eq_right hleaf] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementDataRequest.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementDataRequest.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7cf2ef829cd1696bd641a03d89bb3d511012a01 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementDataRequest.lean @@ -0,0 +1,180 @@ +import OAI.Combinatorics.EditApproximation.Geometry.RefinementDataQuery +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementRequest +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! All initial and warmup-mass data are ordinary earlier table +requests. A positive refinement step therefore has no fixed-table oracle +arguments. Parent initial data use the same node's warmup-zero entry; +child data and histories use the concrete physical children. -/ + +namespace EditApproximation + +theorem physicalInitialQuery_value_local {ι α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N P F : ℕ) (A : ℚ) + (seedRead : PhysicalEntry M J target.length → FiniteQuery ι) + (oracle : ι → ℚ) (U : PhysicalEntry M J target.length → ℕ) + (node : PhysicalNode M J) (q : TargetInterval target.length) + (hseed : ∀ r, (seedRead (node, r)).value oracle = (U (node, r) : ℚ)) : + (physicalInitialQuery source target N P F A seedRead (node, q)).value oracle = + stageInitial source target U N P F A (node, q) := by + unfold physicalInitialQuery stageInitial physicalInitialTable + dsimp only + split_ifs with hleaf + · rfl + · rw [FiniteQuery.bind_value, hseed q] + simp only [Nat.ceil_natCast] + rw [FiniteQuery.collect_value] + simp only [hseed, FiniteQuery.value] + symm + apply localInitialConeTable_congr_raw + · simp only [ite_true] + · intro r hr + by_cases heq : r = q + · subst r + simp only [ite_true] + · rw [ite_eq_right heq, finiteAnswerTable_map _ _ r hr, Nat.ceil_natCast] + +theorem physicalWarmupStepQuery_value_local {ι α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N P F : ℕ) (A : ℚ) + (seedRead : PhysicalEntry M J target.length → FiniteQuery ι) + (childRead : Fin M × TargetInterval target.length → FiniteQuery ι) (oracle : ι → ℚ) + (U : PhysicalEntry M J target.length → ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (t : ℕ) (q : TargetInterval target.length) + (hseed : ∀ r, (seedRead (node, r)).value oracle = (U (node, r) : ℚ)) + (hchild : ∀ input, (childRead input).value oracle = + physicalLocalWarmup source target U N P F A t (physicalChild node hbelow input.1, input.2)) : + (physicalWarmupStepQuery source target N P F A seedRead childRead node q).value oracle = + physicalLocalWarmup source target U N P F A (t + 1) (node, q) := by + rw [physicalLocalWarmup] + simp only [dite_eq_left hbelow, ite_eq_right hleaf] + exact localWarmupStepQuery_value _ N P F (refinementFactor A F) _ _ oracle _ _ + (fun r => physicalInitialQuery_value_local source target N P F A seedRead oracle U node r hseed) + hchild q + +theorem physicalWarmupRequestQuery_value_local {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N P F : ℕ) (A : ℚ) + (pass copy T S j : ℕ) (node : PhysicalNode M J) (q : TargetInterval target.length) + (seedRead : PhysicalEntry M J target.length → + FiniteQuery {child : PhysicalTableRequest M J target.length // + child.combinedRank T S < (PhysicalTableRequest.warmup pass copy node j q).combinedRank T S}) + (values : PhysicalTableRequest M J target.length → ℚ) + (U : PhysicalEntry M J target.length → ℕ) + (hseed : ∀ r, (seedRead (node, r)).value (fun child => values child.val) = (U (node, r) : ℚ)) + (hchild : ∀ (hbelow : node.1.val < J) (input : Fin M × TargetInterval target.length), + values (PhysicalTableRequest.warmup pass copy (physicalChild node hbelow input.1) (j - 1) input.2) = + physicalLocalWarmup source target U N P F A (j - 1) + (physicalChild node hbelow input.1, input.2)) : + (physicalWarmupRequestQuery source target N P F A pass copy T S j node q seedRead).value + (fun child => values child.val) = physicalLocalWarmup source target U N P F A j (node, q) := by + cases j with + | zero => exact physicalInitialQuery_value_local source target N P F A seedRead _ U node q hseed + | succ t => + dsimp only [physicalWarmupRequestQuery] + split_ifs with hbelow hleaf + · rw [physicalLocalWarmup] + simp only [dite_eq_left hbelow, ite_eq_left hleaf] + exact physicalInitialQuery_value_local source target N P F A seedRead _ U node q hseed + · apply physicalWarmupStepQuery_value_local source target N P F A seedRead _ _ U + node hbelow hleaf t q hseed + intro input + exact hchild hbelow input + · rw [physicalLocalWarmup] + simp only [dite_eq_right hbelow] + exact physicalInitialQuery_value_local source target N P F A seedRead _ U node q hseed + + + + + +theorem physicalRefinementMassQuery_value {M J ny : ℕ} (pass copy T S t : ℕ) (ht : 0 < t) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (q : TargetInterval ny) + (input : Fin M × TargetInterval ny) (answer : PhysicalTableRequest M J ny → ℚ) : + (physicalRefinementMassQuery pass copy T S t ht node hbelow q input).value + (fun request => answer request.val) = + (∑ j : Fin T, answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow input.1) j.val input.2)) / T := by + simp only [physicalRefinementMassQuery, FiniteQuery.collect_value, physicalRefinementWarmupRead, + FiniteQuery.value, List.map_ofFn, List.sum_ofFn, Function.comp_def] + +section CompleteStep + +variable {α : Type*} (source target : List α) {M J : ℕ} + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (draw : CellGroupDraws M F Q) (integer : ℕ → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) + +def physicalRefinementDataRequestQuery : + FiniteQuery {child : PhysicalTableRequest M J target.length // + child.combinedRank T S < (PhysicalTableRequest.refinement pass copy node T t q).combinedRank T S} := + localRefinementDataQuery source target (physicalSourceInterval source.length node) + N P F exponent H Q tau a eta kappa delta t + (physicalRefinementWarmupRead pass copy T S t ht node q node le_rfl 0 (Nat.zero_le T)) + (physicalRefinementMassQuery pass copy T S t ht node hbelow q) + (fun input => physicalRefinementWarmupRead pass copy T S t ht node q + (physicalChild node hbelow input.1) (by change node.1.val ≤ node.1.val + 1; omega) + 0 (Nat.zero_le T) input.2) + draw integer q (physicalRefinementEarlierQuery pass copy T S t node hbelow q) + (physicalRefinementCurrentQuery pass copy T S t node hbelow q) + +theorem physicalRefinementDataRequestQuery_value (answer : PhysicalTableRequest M J target.length → ℚ) : + let parentInitial := fun r => answer (PhysicalTableRequest.warmup pass copy node 0 r) + let child := fun i r => (∑ j : Fin T, answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow i) j.val r)) / T + let initial := fun i r => answer (PhysicalTableRequest.warmup pass copy (physicalChild node hbelow i) 0 r) + let children := fun i s r => answer (PhysicalTableRequest.refinement pass copy + (physicalChild node hbelow i) T s r) + (physicalRefinementDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow draw integer q).value (fun request => answer request.val) = + rationalLocalWideStep source target (physicalSourceInterval source.length node) + N P F exponent Q tau a delta parentInitial child initial + (fun i r => children i (t - 1) r) (fun i r => children i t r) draw + (localOnlineCandidates source target (physicalSourceInterval source.length node) + N P F exponent H tau a eta kappa parentInitial child initial children (t - 1) integer q) q := by + dsimp only + let earlier := fun i s r => answer (PhysicalTableRequest.refinement pass copy (physicalChild node hbelow i) T s r) + let masked := fun i s r => if s < t then earlier i s r else 0 + let parentInitial := fun r => answer (PhysicalTableRequest.warmup pass copy node 0 r) + let child := fun i r => (∑ j : Fin T, answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow i) j.val r)) / T + let initial := fun i r => answer (PhysicalTableRequest.warmup pass copy (physicalChild node hbelow i) 0 r) + have he (input : Fin M × ℕ × TargetInterval target.length) : + (physicalRefinementEarlierQuery pass copy T S t node hbelow q input).value + (fun request => answer request.val) = masked input.1 input.2.1 input.2.2 := by + unfold physicalRefinementEarlierQuery + split_ifs with hs + · simp only [FiniteQuery.value, masked, ite_eq_left hs, earlier] + · simp only [FiniteQuery.value, masked, ite_eq_right hs] + rw [physicalRefinementDataRequestQuery, + localRefinementDataQuery_value source target (physicalSourceInterval source.length node) + N P F exponent H Q tau a eta kappa delta t _ _ _ draw integer q _ _ _ + parentInitial child initial masked (fun i r => earlier i t r) ht] + · have hprev : (fun i r => masked i (t - 1) r) = fun i r => earlier i (t - 1) r := by + funext i r + exact ite_eq_left (by omega : t - 1 < t) + have honline := localOnlineCandidates_congr_earlier_cover source target + (physicalSourceInterval source.length node) N P F exponent H t tau a eta kappa + parentInitial child initial masked earlier (t - 1) integer q (by omega) + (fun i s r hr => ite_eq_left (wideEarlierInputCover_time _ P t _ (i, s, r) hr)) + rw [hprev, honline] + · intro r + rfl + · intro input + exact physicalRefinementMassQuery_value pass copy T S t ht node hbelow q input answer + · intro input + rfl + · exact he + · intro input + rfl + +end CompleteStep + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementInvariants.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementInvariants.lean new file mode 100644 index 0000000000000000000000000000000000000000..62cdbcb1dbc19a4bb4b88e3e91d9548da498557c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementInvariants.lean @@ -0,0 +1,238 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinement + +namespace OAI + +/-! Deterministic Bellman invariants of the complete physical recurrence. -/ + +namespace EditApproximation + +theorem stageWarmup_at_terminal {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (t : ℕ) (node : PhysicalNode M J) + (hterminal : ¬ node.1.val < J ∨ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (q : TargetInterval target.length) : + stageWarmup source target U N P F A t (node, q) = + stageInitial source target U N P F A (node, q) := by + cases t with + | zero => rfl + | succ t => + change rationalPhysicalBellman source target P (128 * F) _ _ _ (node, q) = _ + unfold rationalPhysicalBellman + dsimp only + rcases hterminal with hlast | hleaf + · rw [dite_eq_right hlast] + · split_ifs <;> rfl + +theorem physicalRefinement_at_terminal {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) + (hterminal : ¬ node.1.val < J ∨ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) (t : ℕ) (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node t q = + stageInitial source target U N P F A (node, q) := by + rw [physicalRefinement] + rcases hterminal with hlast | hleaf + · rw [dite_eq_right hlast] + · split_ifs <;> rfl + +theorem physicalRefinement_zero {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node 0 q = + stageWarmup source target U N P F A T (node, q) := by + by_cases hbelow : node.1.val < J + · by_cases hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inr hleaf), + stageWarmup_at_terminal _ _ _ _ _ _ _ _ node (Or.inr hleaf)] + · rw [physicalRefinement, dite_eq_left hbelow, ite_eq_right hleaf] + · rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inl hbelow), + stageWarmup_at_terminal _ _ _ _ _ _ _ _ node (Or.inl hbelow)] + +theorem stageWarmup_postfixed {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (state : PhysicalEntry M J target.length) : + rationalPhysicalBellman source target P (128 * F) (stageInitial source target U N P F A) + (stageRepresentatives source target U N P F A) + (stageWarmup source target U N P F A T) state ≤ + stageWarmup source target U N P F A T state := by + have h := physicalWarmup_nonincreasing source target P ((128 * F : ℚ) : ℝ) + (fun s => (stageInitial source target U N P F A s : ℝ)) + (stageRepresentatives source target U N P F A) T state + apply (Rat.cast_le (K := ℝ)).mp + rw [rationalPhysicalBellman_cast] + simpa only [stageWarmup, rationalPhysicalWarmup_cast, physicalWarmup, warmup] using h + +/-- The full recurrence is postfixed for the current-child Bellman operator, +and each next value is at most the previous-child Bellman value. Selected +actions require only their literal wide-list membership certificates. -/ +theorem physicalRefinement_bellman_invariants {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) : + let value := fun t (s : PhysicalEntry M J target.length) => + physicalRefinement source target U N P F A T delta choices s.1 t s.2 + let bellman := rationalPhysicalBellman source target P (128 * F) + (stageInitial source target U N P F A) (stageRepresentatives source target U N P F A) + ∀ t q, bellman (value t) (node, q) ≤ value t (node, q) ∧ + value (t + 1) (node, q) ≤ bellman (value t) (node, q) := by + dsimp only + by_cases hbelow : node.1.val < J + · by_cases hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · intro t q + rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inr hleaf), + physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inr hleaf)] + simp only [rationalPhysicalBellman, dite_eq_left hbelow, ite_eq_left hleaf] + exact ⟨le_rfl, le_rfl⟩ + · let children : PhysicalChildTables M target.length := fun i => + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow i) + have hchildren : ∀ t, (fun is : Fin M × TargetInterval target.length => + children is.1 (t + 1) is.2) ≤ fun is => children is.1 t is.2 := by + intro t is + have ih := physicalRefinement_bellman_invariants source target U N P F A T delta choices + (physicalChild node hbelow is.1) t is.2 + exact ih.2.trans ih.1 + have hsandwich (t : ℕ) (q : TargetInterval target.length) := + rationalWideStep_bellman_sandwich (physicalSourceInterval source.length node) + (stageRepresentatives source target U N P F A node) P + (fun r => stageInitial source target U N P F A (node, r)) (128 * F) delta + (fun is => children is.1 t is.2) (fun is => children is.1 (t + 1) is.2) + (hchildren t) (choices.groups node children (t + 1)) (choices.online node children (t + 1) q) + (choices.groups_mem node children (t + 1)) (choices.online_mem node children (t + 1) q) q + intro t q + constructor + · cases t with + | zero => + simp_rw [physicalRefinement_zero] + exact stageWarmup_postfixed source target U N P F A T (node, q) + | succ t => + rw [physicalRefinement_succ _ _ _ _ _ _ _ _ _ _ node hbelow hleaf] + simpa only [rationalPhysicalBellman, dite_eq_left hbelow, ite_eq_right hleaf] + using (hsandwich t q).1 + · rw [physicalRefinement_succ _ _ _ _ _ _ _ _ _ _ node hbelow hleaf] + simpa only [rationalPhysicalBellman, dite_eq_left hbelow, ite_eq_right hleaf] + using (hsandwich t q).2 + · intro t q + rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inl hbelow), + physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inl hbelow)] + simp only [rationalPhysicalBellman, dite_eq_right hbelow] + exact ⟨le_rfl, le_rfl⟩ +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +theorem physicalRefinement_nonincreasing {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node (t + 1) q ≤ + physicalRefinement source target U N P F A T delta choices node t q := by + have h := physicalRefinement_bellman_invariants source target U N P F A T delta choices node t q + exact h.2.trans h.1 + +theorem physicalRefinement_le_warmup {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node t q ≤ + stageWarmup source target U N P F A T (node, q) := by + induction t with + | zero => exact (physicalRefinement_zero source target U N P F A T delta choices node q).le + | succ t ih => + exact (physicalRefinement_nonincreasing source target U N P F A T delta choices node t q).trans ih + +/-- Lower invariants propagate down the physical tree from the initial table bounds. -/ +theorem physicalRefinement_lower {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) (a : ℝ) (ha : 1 ≤ a) + (hL : (1 : ℝ) ≤ ((128 * F : ℚ) : ℝ)) + (hinit : physicalLower source target a ≤ fun s => (stageInitial source target U N P F A s : ℝ)) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q : TargetInterval target.length) : + physicalLower source target a (node, q) ≤ + (physicalRefinement source target U N P F A T delta choices node t q : ℝ) := by + by_cases hbelow : node.1.val < J + · by_cases hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inr hleaf)] + exact hinit (node, q) + · cases t with + | zero => + rw [physicalRefinement_zero] + simpa only [stageWarmup, rationalPhysicalWarmup_cast] using + physicalWarmup_lower source target hM P a ((128 * F : ℚ) : ℝ) ha hL + (fun s => (stageInitial source target U N P F A s : ℝ)) + (stageRepresentatives source target U N P F A) hinit T (node, q) + | succ t => + have hpost := (physicalRefinement_bellman_invariants source target U N P F A T delta choices + node (t + 1) q).1 + have hpostR := (Rat.cast_le (K := ℝ)).mpr hpost + rw [rationalPhysicalBellman_cast] at hpostR + unfold physicalBellman at hpostR + dsimp only at hpostR + rw [dite_eq_left hbelow, ite_eq_right hleaf] at hpostR + apply le_trans ?_ hpostR + apply actualWideBellman_lower source target hM _ _ P _ a _ ha hL + · intro r + exact hinit (node, r) + · intro i r + exact physicalRefinement_lower source target hM U N P F A T delta a ha hL hinit choices + (physicalChild node hbelow i) (t + 1) r + · rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inl hbelow)] + exact hinit (node, q) +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +theorem physicalRefinement_stage_bounds {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q : TargetInterval target.length) : + physicalLower source target (refinementFactor A F : ℝ) (node, q) ≤ + (physicalRefinement source target U N P F A T delta choices node t q : ℝ) ∧ + physicalRefinement source target U N P F A T delta choices node t q ≤ + stageWarmup source target U N P F A T (node, q) ∧ + stageWarmup source target U N P F A T (node, q) ≤ stageWarmupMass source target U N P F A T (node, q) ∧ + stageWarmupMass source target U N P F A T (node, q) ≤ stageInitial source target U N P F A (node, q) ∧ + stageInitial source target U N P F A (node, q) ≤ + 2 * F * stateEditCost (physicalSource source node) target q := by + have hfactor := refinementFactor_spec A F (by omega) + have hinit := physicalInitialTable_real_lower source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed + have haR : (1 : ℝ) ≤ refinementFactor A F := by + simpa only [Rat.cast_one] using (Rat.cast_le (K := ℝ)).mpr hfactor.1 + have hLR : (1 : ℝ) ≤ ((128 * F : ℚ) : ℝ) := by + have hFr : (1 : ℚ) ≤ F := by exact_mod_cast hF + simpa only [Rat.cast_one] using + (Rat.cast_le (K := ℝ)).mpr (by linarith : (1 : ℚ) ≤ 128 * F) + have hw := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT (node, q) + exact ⟨physicalRefinement_lower source target hM U N P F A T delta _ haR hLR hinit choices node t q, + physicalRefinement_le_warmup source target U N P F A T delta choices node t q, + hw.2.1, hw.2.2.1, hw.2.2.2⟩ + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementLocality.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..db616c694383f33b74916fffd0ef84b033f4bc97 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementLocality.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementInvariants + +namespace OAI + +/-! +# Locality of the complete physical refinement + +Changing selection streams above a fixed level cannot alter histories at +that level or below. This proves the fixed-child environment under +parent-only resampling directly from the executable recurrence. +-/ + +namespace EditApproximation + +/-- The complete history depends only on selection functions at its own +physical level and deeper levels. -/ +theorem physicalRefinement_congr_from_level {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (first second : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (d : ℕ) (hgroups : ∀ node, d ≤ node.1.val → first.groups node = second.groups node) + (honline : ∀ node, d ≤ node.1.val → first.online node = second.online node) + (node : PhysicalNode M J) (hnode : d ≤ node.1.val) (t : ℕ) (q : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta first node t q = + physicalRefinement source target U N P F A T delta second node t q := by + by_cases hbelow : node.1.val < J + · by_cases hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · rw [physicalRefinement_at_leaf source target U N P F A T delta first node hleaf, + physicalRefinement_at_leaf source target U N P F A T delta second node hleaf] + · have hchildren (i : Fin M) : + physicalRefinement source target U N P F A T delta first (physicalChild node hbelow i) = + physicalRefinement source target U N P F A T delta second (physicalChild node hbelow i) := by + funext t q + exact physicalRefinement_congr_from_level source target U N P F A T delta first second d hgroups honline + (physicalChild node hbelow i) (by change d ≤ node.1.val + 1; omega) t q + cases t with + | zero => + rw [physicalRefinement_zero source target U N P F A T delta first, + physicalRefinement_zero source target U N P F A T delta second] + | succ t => + rw [physicalRefinement_succ source target U N P F A T delta first node hbelow hleaf, + physicalRefinement_succ source target U N P F A T delta second node hbelow hleaf] + simp only [hchildren, hgroups node hnode, honline node hnode] + · have hlast : node.1.val = J := by have hbound := node.1.isLt; omega + rw [physicalRefinement_at_last_level source target U N P F A T delta first node hlast, + physicalRefinement_at_last_level source target U N P F A T delta second node hlast] +termination_by J - node.1.val +decreasing_by + unfold physicalChild + dsimp only + omega + +/-- Parent-only resampling fixes every child table, at every refinement +index and target state, without independence assumptions about children. -/ +theorem physicalRefinement_children_fixed {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (first second : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hgroups : ∀ label, node.1.val < label.1.val → first.groups label = second.groups label) + (honline : ∀ label, node.1.val < label.1.val → first.online label = second.online label) : + (fun i : Fin M => physicalRefinement source target U N P F A T delta first (physicalChild node hbelow i)) = + fun i : Fin M => physicalRefinement source target U N P F A T delta second (physicalChild node hbelow i) := by + funext i t q + apply physicalRefinement_congr_from_level source target U N P F A T delta first second (node.1.val + 1) + · intro label hlabel + exact hgroups label (by omega) + · intro label hlabel + exact honline label (by omega) + · change node.1.val + 1 ≤ node.1.val + 1 + rfl + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementReadWork.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementReadWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5805035fe178884a2030df61c74a24d4eb23635 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementReadWork.lean @@ -0,0 +1,256 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementDataRequest +import OAI.Combinatorics.EditApproximation.Geometry.RefinementDataQueryWork + +namespace OAI + +/-! Split the literal recursive reads by the unified table index. The +current-index reads are physical-child requests; initial data, warmup +mass and old history have strictly smaller indices. -/ + +namespace EditApproximation + +def physicalCurrentReadWeight {M J ny : ℕ} (index : ℕ) + (request : PhysicalTableRequest M J ny) : ℕ := if request.index = index then 1 else 0 + +def physicalEarlierReadWeight {M J ny : ℕ} (index : ℕ) + (request : PhysicalTableRequest M J ny) : ℕ := if request.index < index then 1 else 0 + +theorem physicalRefinementWarmupRead_cost_current {M J ny : ℕ} (pass copy T S t : ℕ) + (ht : 0 < t) (node : PhysicalNode M J) (q : TargetInterval ny) + (otherNode : PhysicalNode M J) (hnode : node.1.val ≤ otherNode.1.val) + (j : ℕ) (hj : j ≤ T) (r : TargetInterval ny) (oracle) : + (physicalRefinementWarmupRead pass copy T S t ht node q otherNode hnode j hj r).cost + oracle (fun request => physicalCurrentReadWeight (T + t) request.val) = 0 := by + have hne : j ≠ T + t := by omega + simp only [physicalRefinementWarmupRead, FiniteQuery.cost, physicalCurrentReadWeight, + PhysicalTableRequest.warmup, ite_eq_right hne, Nat.add_zero] + +theorem physicalRefinementWarmupRead_cost_earlier {M J ny : ℕ} (pass copy T S t : ℕ) + (ht : 0 < t) (node : PhysicalNode M J) (q : TargetInterval ny) + (otherNode : PhysicalNode M J) (hnode : node.1.val ≤ otherNode.1.val) + (j : ℕ) (hj : j ≤ T) (r : TargetInterval ny) (oracle) : + (physicalRefinementWarmupRead pass copy T S t ht node q otherNode hnode j hj r).cost + oracle (fun request => physicalEarlierReadWeight (T + t) request.val) = 1 := by + have hlt : j < T + t := by omega + simp only [physicalRefinementWarmupRead, FiniteQuery.cost, physicalEarlierReadWeight, + PhysicalTableRequest.warmup, ite_eq_left hlt, Nat.add_zero] + +theorem physicalRefinementMassQuery_cost_current {M J ny : ℕ} (pass copy T S t : ℕ) + (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (q : TargetInterval ny) (input : Fin M × TargetInterval ny) (oracle) : + (physicalRefinementMassQuery pass copy T S t ht node hbelow q input).cost + oracle (fun request => physicalCurrentReadWeight (T + t) request.val) = 0 := by + simp only [physicalRefinementMassQuery, FiniteQuery.cost_collect, FiniteQuery.cost, + physicalRefinementWarmupRead_cost_current, List.map_ofFn, Function.comp_def, + List.sum_ofFn, Finset.sum_const_zero, Nat.add_zero] + +theorem physicalRefinementMassQuery_cost_earlier {M J ny : ℕ} (pass copy T S t : ℕ) + (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (q : TargetInterval ny) (input : Fin M × TargetInterval ny) (oracle) : + (physicalRefinementMassQuery pass copy T S t ht node hbelow q input).cost + oracle (fun request => physicalEarlierReadWeight (T + t) request.val) = T := by + simp only [physicalRefinementMassQuery, FiniteQuery.cost_collect, FiniteQuery.cost, + physicalRefinementWarmupRead_cost_earlier, List.map_ofFn, Function.comp_def, + List.sum_ofFn, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + smul_eq_mul, Nat.mul_one, Nat.add_zero] + +theorem physicalRefinementCurrentQuery_cost_current {M J ny : ℕ} (pass copy T S t : ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (q : TargetInterval ny) + (input : Fin M × TargetInterval ny) (oracle) : + (physicalRefinementCurrentQuery pass copy T S t node hbelow q input).cost + oracle (fun request => physicalCurrentReadWeight (T + t) request.val) = 1 := by + simp only [physicalRefinementCurrentQuery, FiniteQuery.cost, physicalCurrentReadWeight, + PhysicalTableRequest.refinement, ite_true, Nat.add_zero] + +theorem physicalRefinementCurrentQuery_cost_earlier {M J ny : ℕ} (pass copy T S t : ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (q : TargetInterval ny) + (input : Fin M × TargetInterval ny) (oracle) : + (physicalRefinementCurrentQuery pass copy T S t node hbelow q input).cost + oracle (fun request => physicalEarlierReadWeight (T + t) request.val) = 0 := by + simp only [physicalRefinementCurrentQuery, FiniteQuery.cost, physicalEarlierReadWeight, + PhysicalTableRequest.refinement, lt_self_iff_false, ite_false, Nat.add_zero] + +theorem physicalRefinementEarlierQuery_cost_current {M J ny : ℕ} (pass copy T S t : ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (q : TargetInterval ny) + (input : Fin M × ℕ × TargetInterval ny) (oracle) : + (physicalRefinementEarlierQuery pass copy T S t node hbelow q input).cost + oracle (fun request => physicalCurrentReadWeight (T + t) request.val) = 0 := by + unfold physicalRefinementEarlierQuery + split_ifs with hs + · have hne : T + input.2.1 ≠ T + t := by omega + simp only [FiniteQuery.cost, physicalCurrentReadWeight, PhysicalTableRequest.refinement, + hne, ↓reduceIte, Nat.add_zero] + · rfl + +theorem physicalRefinementEarlierQuery_cost_earlier {M J ny : ℕ} (pass copy T S t : ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (q : TargetInterval ny) + (input : Fin M × ℕ × TargetInterval ny) (oracle) : + (physicalRefinementEarlierQuery pass copy T S t node hbelow q input).cost + oracle (fun request => physicalEarlierReadWeight (T + t) request.val) ≤ 1 := by + unfold physicalRefinementEarlierQuery + split_ifs with hs + · have hlt : T + input.2.1 < T + t := by omega + simp only [FiniteQuery.cost, physicalEarlierReadWeight, PhysicalTableRequest.refinement, + hlt, ↓reduceIte, Nat.add_zero, le_refl] + · exact Nat.zero_le 1 + +private def physicalReadMaskedAnswers {M J ny : ℕ} + (pass copy T t : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (answer : PhysicalTableRequest M J ny → ℚ) (i : Fin M) (s : ℕ) + (r : TargetInterval ny) : ℚ := + if s < t then answer (PhysicalTableRequest.refinement pass copy + (physicalChild node hbelow i) T s r) else 0 + +section Full + +variable {α : Type*} (source target : List α) {M J : ℕ} + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (draw : CellGroupDraws M F Q) (integer : ℕ → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) (answer : PhysicalTableRequest M J target.length → ℚ) + +local notation "requestType" => {child : PhysicalTableRequest M J target.length // + PhysicalTableRequest.combinedRank T S child < + PhysicalTableRequest.combinedRank T S (PhysicalTableRequest.refinement pass copy node T t q)} +local notation "oracle" => (fun request : requestType => answer (Subtype.val request)) +local notation "parentInitial" => (fun r => answer (PhysicalTableRequest.warmup pass copy node 0 r)) +local notation "childMass" => (fun (i : Fin M) (r : TargetInterval target.length) => + (∑ j : Fin T, answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow i) (Fin.val j) r)) / T) +local notation "childInitial" => (fun i r => answer (PhysicalTableRequest.warmup pass copy + (physicalChild node hbelow i) 0 r)) +local notation "masked" => physicalReadMaskedAnswers pass copy T t node hbelow answer +local notation "current" => (fun i r => answer (PhysicalTableRequest.refinement pass copy + (physicalChild node hbelow i) T t r)) +local notation "program" => physicalRefinementDataRequestQuery source target N P F exponent H Q + tau a eta kappa delta pass copy T S t ht node hbelow draw integer q +local notation "parentRead" => physicalRefinementWarmupRead pass copy T S t ht node q node le_rfl 0 (Nat.zero_le T) +local notation "massRead" => physicalRefinementMassQuery pass copy T S t ht node hbelow q +local notation "initialRead" => (fun input : Fin M × TargetInterval target.length => + physicalRefinementWarmupRead pass copy T S t ht node q (physicalChild node hbelow (Prod.fst input)) + (Nat.le_succ (Fin.val (Sigma.fst node))) + 0 (Nat.zero_le T) (Prod.snd input)) +local notation "earlierRead" => physicalRefinementEarlierQuery pass copy T S t node hbelow q +local notation "currentRead" => physicalRefinementCurrentQuery pass copy T S t node hbelow q +local notation "currentCover" => currentQueryInputCover source target (physicalSourceInterval source.length node) + N P F exponent Q tau a parentInitial childMass childInitial current draw q + (localOnlineCandidates source target (physicalSourceInterval source.length node) + N P F exponent H tau a eta kappa parentInitial childMass childInitial masked (t - 1) integer q) + +theorem physicalRefinementDataRequest_cost_le (weight : requestType → ℕ) + (parentCost massCost initialCost earlierCost currentCost : ℕ) + (hparent : ∀ r, (parentRead r).cost oracle weight ≤ parentCost) + (hmass : ∀ input, (massRead input).cost oracle weight ≤ massCost) + (hinitial : ∀ input, (initialRead input).cost oracle weight ≤ initialCost) + (hearlier : ∀ input, (earlierRead input).cost oracle weight ≤ earlierCost) + (hcurrent : ∀ input, (currentRead input).cost oracle weight ≤ currentCost) : + (program).cost oracle weight ≤ + (1 + (refinementInitialSupport N P F exponent a (parentInitial q) q).length) * parentCost + + (refinementBandInputList (M := M) (physicalSourceInterval source.length node) + N P F exponent a parentInitial q).length * (massCost + initialCost) + + (queryEarlierInputCover (M := M) (physicalSourceInterval source.length node) + N P F exponent t a parentInitial q).card * earlierCost + + 2 * (currentCover).card * currentCost := by + have hreadEarlier (input : Fin M × ℕ × TargetInterval target.length) : + (earlierRead input).value oracle = masked input.1 input.2.1 input.2.2 := by + unfold physicalRefinementEarlierQuery physicalReadMaskedAnswers + split_ifs with hs <;> rfl + exact localRefinementDataQuery_cost_le source target (physicalSourceInterval source.length node) + N P F exponent H Q tau a eta kappa delta t parentRead massRead initialRead draw integer q + earlierRead currentRead oracle weight parentInitial childMass childInitial masked current ht + (fun _ => rfl) (fun input => physicalRefinementMassQuery_value pass copy T S t ht node hbelow q input answer) + (fun _ => rfl) hreadEarlier (fun _ => rfl) + parentCost massCost initialCost earlierCost currentCost hparent hmass hinitial hearlier hcurrent + +theorem physicalRefinementDataRequest_current_reads : + (program).cost oracle (fun request => physicalCurrentReadWeight (T + t) request.val) ≤ + 2 * (currentCover).card := by + have h := physicalRefinementDataRequest_cost_le source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow draw integer q answer + (fun request => physicalCurrentReadWeight (T + t) request.val) 0 0 0 0 1 + (fun r => (physicalRefinementWarmupRead_cost_current pass copy T S t ht node q node le_rfl + 0 (Nat.zero_le T) r oracle).le) + (fun input => (physicalRefinementMassQuery_cost_current pass copy T S t ht node hbelow q input oracle).le) + (fun input => (physicalRefinementWarmupRead_cost_current pass copy T S t ht node q + (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 oracle).le) + (fun input => (physicalRefinementEarlierQuery_cost_current pass copy T S t node hbelow q input oracle).le) + (fun input => (physicalRefinementCurrentQuery_cost_current pass copy T S t node hbelow q input oracle).le) + simpa only [Nat.add_zero, Nat.mul_zero, Nat.zero_add, Nat.mul_one] using h + +theorem physicalRefinementDataRequest_earlier_reads : + (program).cost oracle (fun request => physicalEarlierReadWeight (T + t) request.val) ≤ + 1 + (refinementInitialSupport N P F exponent a (parentInitial q) q).length + + (refinementBandInputList (M := M) (physicalSourceInterval source.length node) + N P F exponent a parentInitial q).length * (T + 1) + + (queryEarlierInputCover (M := M) (physicalSourceInterval source.length node) + N P F exponent t a parentInitial q).card := by + have h := physicalRefinementDataRequest_cost_le source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow draw integer q answer + (fun request => physicalEarlierReadWeight (T + t) request.val) 1 T 1 1 0 + (fun r => (physicalRefinementWarmupRead_cost_earlier pass copy T S t ht node q node le_rfl + 0 (Nat.zero_le T) r oracle).le) + (fun input => (physicalRefinementMassQuery_cost_earlier pass copy T S t ht node hbelow q input oracle).le) + (fun input => (physicalRefinementWarmupRead_cost_earlier pass copy T S t ht node q + (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 oracle).le) + (fun input => physicalRefinementEarlierQuery_cost_earlier pass copy T S t node hbelow q input oracle) + (fun input => (physicalRefinementCurrentQuery_cost_earlier pass copy T S t node hbelow q input oracle).le) + simpa only [Nat.mul_one, Nat.mul_zero, Nat.add_zero] using h + +end Full + +theorem physicalRefinementWarmupRead_keys_bounded {M J ny : ℕ} + (passes copies pass copy T S t : ℕ) (ht : 0 < t) + (hpass : pass < passes) (hcopy : copy < copies) + (node : PhysicalNode M J) (q : TargetInterval ny) + (otherNode : PhysicalNode M J) (hnode : node.1.val ≤ otherNode.1.val) + (j : ℕ) (hj : j ≤ T) (r : TargetInterval ny) (oracle) : + ∀ key ∈ (physicalRefinementWarmupRead pass copy T S t ht node q otherNode hnode j hj r).keys oracle, + key.val.Bounded passes copies T S := by + intro key hk + simp only [physicalRefinementWarmupRead, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.warmup_bounded passes copies pass copy otherNode T S j r hpass hcopy hj + +theorem physicalRefinementDataRequest_keys_bounded {α : Type*} (source target : List α) {M J : ℕ} + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (passes copies pass copy T S t : ℕ) (ht : 0 < t) (htS : t ≤ S) + (hpass : pass < passes) (hcopy : copy < copies) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (draw : CellGroupDraws M F Q) (integer : ℕ → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) (oracle) : + ∀ key ∈ (physicalRefinementDataRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t ht node hbelow draw integer q).keys oracle, + key.val.Bounded passes copies T S := by + unfold physicalRefinementDataRequestQuery + apply localRefinementDataQuery_keys_all + · intro r key hk + exact physicalRefinementWarmupRead_keys_bounded passes copies pass copy T S t ht hpass hcopy + node q node le_rfl 0 (Nat.zero_le T) r oracle key hk + · intro input + unfold physicalRefinementMassQuery + apply FiniteQuery.keys_all_collect + · intro j _ key hk + exact physicalRefinementWarmupRead_keys_bounded passes copies pass copy T S t ht hpass hcopy + node q (physicalChild node hbelow input.1) _ j.val (Nat.le_of_lt j.isLt) input.2 oracle key hk + · intro values key hk + exact False.elim (List.not_mem_nil hk) + · intro input key hk + exact physicalRefinementWarmupRead_keys_bounded passes copies pass copy T S t ht hpass hcopy + node q (physicalChild node hbelow input.1) _ 0 (Nat.zero_le T) input.2 oracle key hk + · intro input key hk + unfold physicalRefinementEarlierQuery at hk + split_ifs at hk with hs + · simp only [FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_bounded passes copies pass copy + (physicalChild node hbelow input.1) T S input.2.1 input.2.2 hpass hcopy (by omega) + · exact False.elim (List.not_mem_nil hk) + · intro input key hk + simp only [physicalRefinementCurrentQuery, FiniteQuery.keys, List.mem_singleton] at hk + subst key + exact PhysicalTableRequest.refinement_bounded passes copies pass copy + (physicalChild node hbelow input.1) T S t input.2 hpass hcopy htS + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementRequest.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementRequest.lean new file mode 100644 index 0000000000000000000000000000000000000000..db94be33f6fdc02144aeff4a5d4723100d607223 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementRequest.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.EditApproximation.Geometry.LocalRefinementQuery +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Concrete current and earlier child requests for refinement. The +history reader is total, with unused future times returning zero; the +local program only asks times below the current one. -/ + +namespace EditApproximation + +theorem wideEarlierInputCover_time {nx ny M : ℕ} (parent : TargetInterval nx) + (P history : ℕ) (representatives : List (ℕ × TargetInterval ny)) + (input : Fin M × ℕ × TargetInterval ny) + (hinput : input ∈ wideEarlierInputCover parent P history representatives) : input.2.1 < history := by + obtain ⟨br, _, hinput⟩ := Finset.mem_biUnion.mp hinput + obtain ⟨i, _, hinput⟩ := Finset.mem_biUnion.mp hinput + obtain ⟨t, ht, hinput⟩ := Finset.mem_biUnion.mp hinput + obtain ⟨r, _, heq⟩ := Finset.mem_image.mp hinput + have hs := congrArg (fun input : Fin M × ℕ × TargetInterval ny => input.2.1) heq + exact hs ▸ Finset.mem_range.mp ht + + + + + +section Physical + +variable {α : Type*} (source target : List α) {M J : ℕ} + (N P F exponent H Q : ℕ) (tau a eta kappa delta : ℚ) + (pass copy T S t : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (parentInitial : TargetInterval target.length → ℚ) + (child initial : Fin M → TargetInterval target.length → ℚ) + (draw : CellGroupDraws M F Q) (integer : ℕ → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) + +def physicalRefinementRequestQuery : + FiniteQuery {child : PhysicalTableRequest M J target.length // + child.combinedRank T S < (PhysicalTableRequest.refinement pass copy node T t q).combinedRank T S} := + localRefinementStepQuery source target (physicalSourceInterval source.length node) + N P F exponent H Q tau a eta kappa delta t parentInitial child initial draw integer q + (physicalRefinementEarlierQuery pass copy T S t node hbelow q) + (physicalRefinementCurrentQuery pass copy T S t node hbelow q) + +theorem physicalRefinementRequestQuery_value (ht : 0 < t) + (answer : PhysicalTableRequest M J target.length → ℚ) : + (physicalRefinementRequestQuery source target N P F exponent H Q tau a eta kappa delta + pass copy T S t node hbelow parentInitial child initial draw integer q).value + (fun request => answer request.val) = + rationalLocalWideStep source target (physicalSourceInterval source.length node) + N P F exponent Q tau a delta parentInitial child initial + (fun i r => answer (PhysicalTableRequest.refinement pass copy (physicalChild node hbelow i) T (t - 1) r)) + (fun i r => answer (PhysicalTableRequest.refinement pass copy (physicalChild node hbelow i) T t r)) + draw + (localOnlineCandidates source target (physicalSourceInterval source.length node) + N P F exponent H tau a eta kappa parentInitial child initial + (fun i s r => answer (PhysicalTableRequest.refinement pass copy (physicalChild node hbelow i) T s r)) + (t - 1) integer q) q := by + let earlier := fun i s r => answer (PhysicalTableRequest.refinement pass copy (physicalChild node hbelow i) T s r) + let masked := fun i s r => if s < t then earlier i s r else 0 + let current := fun i r => earlier i t r + have he (input : Fin M × ℕ × TargetInterval target.length) : + (physicalRefinementEarlierQuery pass copy T S t node hbelow q input).value + (fun request => answer request.val) = masked input.1 input.2.1 input.2.2 := by + unfold physicalRefinementEarlierQuery + split_ifs with hs + · simp only [FiniteQuery.value, masked, ite_eq_left hs, earlier] + · simp only [FiniteQuery.value, masked, ite_eq_right hs] + have hc (input : Fin M × TargetInterval target.length) : + (physicalRefinementCurrentQuery pass copy T S t node hbelow q input).value + (fun request => answer request.val) = current input.1 input.2 := rfl + rw [physicalRefinementRequestQuery, + localRefinementStepQuery_value source target (physicalSourceInterval source.length node) + N P F exponent H Q tau a eta kappa delta t parentInitial child initial draw integer q + _ _ _ masked current ht he hc] + have hprev : (fun i r => masked i (t - 1) r) = fun i r => earlier i (t - 1) r := by + funext i r + exact ite_eq_left (by omega : t - 1 < t) + have honline := localOnlineCandidates_congr_earlier_cover source target + (physicalSourceInterval source.length node) N P F exponent H t tau a eta kappa + parentInitial child initial masked earlier (t - 1) integer q (by omega) + (fun i s r hr => ite_eq_left (wideEarlierInputCover_time _ P t _ (i, s, r) hr)) + rw [hprev, honline] + +end Physical + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementSpatial.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementSpatial.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa9dc6c684063962d898cc75821f270245d9b57d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRefinementSpatial.lean @@ -0,0 +1,137 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementInvariants +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSpatial +import OAI.Combinatorics.EditApproximation.Numerics.RationalWideSpatial + +namespace OAI + +/-! Nonnegativity, exact zero states and spatial regularity of the full stage. -/ + +namespace EditApproximation + +theorem stageInitial_spatial {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalNode M J) (q q' : TargetInterval target.length) : + stageInitial source target U N P F A (node, q) ≤ + stageInitial source target U N P F A (node, q') + (128 * F : ℚ) * targetEndpointDistance q q' := by + have hfactor := refinementFactor_spec A F (by omega) + have h32 := physicalInitialTable_spatial source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed node q q' + have hcharge : (32 * F : ℚ) * targetEndpointDistance q q' ≤ + (128 * F : ℚ) * targetEndpointDistance q q' := by + apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) + exact mul_le_mul_of_nonneg_right (by norm_num : (32 : ℚ) ≤ 128) (Nat.cast_nonneg F) + change physicalInitialTable source target U N P F A (refinementFactor A F) (node, q) ≤ + physicalInitialTable source target U N P F A (refinementFactor A F) (node, q') + + (128 * F : ℚ) * targetEndpointDistance q q' + exact le_trans h32 (add_le_add_right hcharge + (physicalInitialTable source target U N P F A (refinementFactor A F) (node, q'))) + +theorem physicalRefinement_nonneg {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q : TargetInterval target.length) : + 0 ≤ physicalRefinement source target U N P F A T delta choices node t q := by + have h := (physicalRefinement_stage_bounds source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q).1 + have hzero : 0 ≤ physicalLower source target (refinementFactor A F : ℝ) (node, q) := + (abs_nonneg _).trans (le_max_right _ _) + exact (Rat.cast_nonneg (K := ℝ)).mp (hzero.trans h) + +theorem physicalRefinement_zero_cost {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q : TargetInterval target.length) + (hcost : stateEditCost (physicalSource source node) target q = 0) : + physicalRefinement source target U N P F A T delta choices node t q = 0 := by + have hb := physicalRefinement_stage_bounds source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q + have hu := hb.2.1.trans (hb.2.2.1.trans (hb.2.2.2.1.trans hb.2.2.2.2)) + rw [hcost] at hu + simp only [Nat.cast_zero, mul_zero] at hu + exact le_antisymm hu (physicalRefinement_nonneg source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q) + +theorem physicalRefinement_spatial {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) (hdelta : 0 ≤ delta) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q q' : TargetInterval target.length) : + physicalRefinement source target U N P F A T delta choices node t q ≤ + (1 + delta) * physicalRefinement source target U N P F A T delta choices node t q' + + (128 * F : ℚ) * targetEndpointDistance q q' := by + have hL : (0 : ℚ) ≤ 128 * F := mul_nonneg (by norm_num) (Nat.cast_nonneg _) + have hinit (node : PhysicalNode M J) (r r' : TargetInterval target.length) : + stageInitial source target U N P F A (node, r) ≤ + stageInitial source target U N P F A (node, r') + (128 * F : ℚ) * targetEndpointDistance r r' := by + exact stageInitial_spatial source target U N P F A hsize hP hF hA hseed node r r' + have hnonneg := physicalRefinement_nonneg source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q' + have hmul := mul_nonneg hdelta hnonneg + by_cases hbelow : node.1.val < J + · by_cases hleaf : (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 + · rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inr hleaf)] at hmul ⊢ + rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inr hleaf)] + nlinarith only [hinit node q q', hmul] + · cases t with + | zero => + rw [physicalRefinement_zero] at hmul ⊢ + rw [physicalRefinement_zero] + have hinitR (n : PhysicalNode M J) (r r' : TargetInterval target.length) : + (stageInitial source target U N P F A (n, r) : ℝ) ≤ + (stageInitial source target U N P F A (n, r') : ℝ) + + ((128 * F : ℚ) : ℝ) * targetEndpointDistance r r' := by + exact_mod_cast hinit n r r' + have hw := physicalWarmup_spatial source target P ((128 * F : ℚ) : ℝ) + ((Rat.cast_nonneg (K := ℝ)).mpr hL) + (fun s => (stageInitial source target U N P F A s : ℝ)) + (stageRepresentatives source target U N P F A) hinitR T node q q' + have hwQ : stageWarmup source target U N P F A T (node, q) ≤ + stageWarmup source target U N P F A T (node, q') + + (128 * F : ℚ) * targetEndpointDistance q q' := by + apply (Rat.cast_le (K := ℝ)).mp + simpa only [stageWarmup, rationalPhysicalWarmup_cast, Rat.cast_add, Rat.cast_mul, + Rat.cast_natCast] using hw + nlinarith only [hwQ, hmul] + | succ t => + let children : PhysicalChildTables M target.length := fun i => + physicalRefinement source target U N P F A T delta choices (physicalChild node hbelow i) + have hcone : 0 ≤ rationalWideStepCone (physicalSourceInterval source.length node) + (stageRepresentatives source target U N P F A node) P + (fun r => stageInitial source target U N P F A (node, r)) (128 * F) + (fun is => children is.1 t is.2) (fun is => children is.1 (t + 1) is.2) + (choices.groups node children (t + 1)) q' := by + rw [physicalRefinement_succ _ _ _ _ _ _ _ _ _ _ node hbelow hleaf] at hnonneg + exact hnonneg.trans (rationalRefinementUpdate_le_cone _ _ _) + rw [physicalRefinement_succ _ _ _ _ _ _ _ _ _ _ node hbelow hleaf, + physicalRefinement_succ _ _ _ _ _ _ _ _ _ _ node hbelow hleaf] + exact rationalWideStep_spatial _ _ P _ (128 * F) delta hL hdelta _ _ _ + (choices.online node children (t + 1)) q q' (hinit node q q') hcone + · rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inl hbelow)] at hmul ⊢ + rw [physicalRefinement_at_terminal _ _ _ _ _ _ _ _ _ _ node (Or.inl hbelow)] + nlinarith only [hinit node q q', hmul] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestBits.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestBits.lean new file mode 100644 index 0000000000000000000000000000000000000000..68b97991c9ce3c129523036a787cbf010aad6583 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestBits.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRequestEncoding +import OAI.Combinatorics.EditApproximation.Refinement.ComputedEarlierInputBudget + +namespace OAI + +/-! The cache key width is linear in the input height, once the actual +pass and copy bounds are substituted. The numerical capacity is only a +bound: no array of that capacity is allocated. -/ + +namespace EditApproximation + +theorem computed_entryCapacity_bound (N nx ny : ℕ) (hN : 0 < N) + (hell : 200 ≤ inputSmallLog N) (hnx : nx ≤ N) (hny : ny ≤ N) : + PhysicalTableRequest.entryCapacity (integerParameters N).M + (intervalTreeDepth (integerParameters N).M nx) ny ≤ 2 ^ (5 * inputHeight N) := by + let H := inputHeight N + let M := (integerParameters N).M + let J := intervalTreeDepth M nx + have hM : M ≤ H := pow_le_pow_right₀ (by decide : (1 : ℕ) ≤ 2) (Nat.div_le_self _ _) + have hMH : M ≤ 2 ^ H := hM.trans (Nat.lt_two_pow_self.le) + have hnx' : max 1 nx ≤ 2 ^ H := max_le Nat.one_le_two_pow + (hnx.trans ((Nat.le_add_right N 2).trans (inputHeight_covers_length N))) + have htree : M ^ J ≤ 2 ^ (2 * H) := by + calc + _ ≤ M * max 1 nx := intervalTreeDepth_power_le M nx (computed_branching_bounds N hN hell).1 + _ ≤ 2 ^ H * 2 ^ H := Nat.mul_le_mul hMH hnx' + _ = _ := by rw [← pow_add]; congr 1; omega + have hJ : J ≤ H := by + have hj := computed_tree_depth_bound N nx hN hnx hell + change J * inputSmallLog N ≤ 100 * H at hj + nlinarith only [hj, hell] + have hJ' : J + 1 ≤ 2 ^ H := (Nat.add_le_add_right hJ 1).trans (Nat.lt_two_pow_self) + have hny' : ny + 1 ≤ 2 ^ H := (by omega : ny + 1 ≤ N + 2).trans (inputHeight_covers_length N) + unfold PhysicalTableRequest.entryCapacity + calc + (ny + 1) ^ 2 * (M ^ J * (J + 1)) ≤ (2 ^ H) ^ 2 * (2 ^ (2 * H) * 2 ^ H) := + Nat.mul_le_mul (Nat.pow_le_pow_left hny' 2) (Nat.mul_le_mul htree hJ') + _ = 2 ^ (5 * H) := by rw [← pow_mul, ← pow_add, ← pow_add]; congr 1; omega + +theorem computed_request_bits_le (N nx ny passes copies : ℕ) (hN : 0 < N) + (hell : 200 ≤ inputSmallLog N) (hnx : nx ≤ N) (hny : ny ≤ N) + (hpasses : passes ≤ inputHeight N ^ 2) (hcopies : copies ≤ inputHeight N ^ 2) : + PhysicalTableRequest.bits (integerParameters N).M + (intervalTreeDepth (integerParameters N).M nx) ny passes copies + (integerParameters N).T (integerParameters N).S ≤ 11 * inputHeight N + 1 := by + let H := inputHeight N + have hH : 4 ≤ H := (by omega : 4 ≤ inputSmallLog N).trans (computed_smallLog_le_height N) + have hHpow : H ^ 2 ≤ 2 ^ (2 * H) := by + calc + _ ≤ (2 ^ H) ^ 2 := Nat.pow_le_pow_left Nat.lt_two_pow_self.le 2 + _ = _ := by rw [← pow_mul]; congr 1; omega + have hstride := (computed_history_budget_le_height_sq N hH).trans hHpow + have hentry := computed_entryCapacity_bound N nx ny hN hell hnx hny + have hcapacity : PhysicalTableRequest.capacity (integerParameters N).M + (intervalTreeDepth (integerParameters N).M nx) ny passes copies + (integerParameters N).T (integerParameters N).S ≤ 2 ^ (11 * H) := by + unfold PhysicalTableRequest.capacity + calc + _ ≤ 2 ^ (2 * H) * (2 ^ (2 * H) * (2 ^ (5 * H) * 2 ^ (2 * H))) := + Nat.mul_le_mul hstride + (Nat.mul_le_mul (hcopies.trans hHpow) (Nat.mul_le_mul hentry (hpasses.trans hHpow))) + _ = _ := by rw [← pow_add, ← pow_add, ← pow_add]; congr 1; omega + unfold PhysicalTableRequest.bits + apply (Nat.clog_le_iff_le_pow (by decide : 1 < 2)).2 + calc + _ ≤ 2 ^ (11 * H) + 2 ^ (11 * H) := Nat.add_le_add hcapacity Nat.one_le_two_pow + _ = _ := by + change 2 ^ (11 * H) + 2 ^ (11 * H) = 2 ^ (11 * H + 1) + rw [pow_succ] + omega + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestEncoding.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..073f804e91ac9dd5d19eecfa174caf5d42349bda --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestEncoding.lean @@ -0,0 +1,76 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalDependencyRank +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalNodeEncoding +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Fixed-width keys for the bounded physical cache. Their construction +uses only the request's coordinates, without enumerating table entries. -/ + +namespace EditApproximation +namespace PhysicalTableRequest + + + + + +def capacity (M J n passes copies T S : ℕ) : ℕ := + (T + S + 1) * (copies * (entryCapacity M J n * passes)) + +def bits (M J n passes copies T S : ℕ) : ℕ := + Nat.clog 2 (capacity M J n passes copies T S + 1) + +theorem code_injective {M J n : ℕ} (hM : 1 ≤ M) (passes copies T S : ℕ) : + Function.Injective (fun request : {r : PhysicalTableRequest M J n // Bounded passes copies T S r} => + code copies T S request.val) := by + intro first second heq + obtain ⟨hindex, hrest⟩ := mixedRadix_injective + (Nat.lt_succ_of_le first.2.2.2) (Nat.lt_succ_of_le second.2.2.2) heq + obtain ⟨hcopy, hrest⟩ := mixedRadix_injective first.2.2.1 second.2.2.1 hrest + obtain ⟨hentry, hpass⟩ := mixedRadix_injective + (physicalEntryCode_bound hM (first.1.node, first.1.state)) + (physicalEntryCode_bound hM (second.1.node, second.1.state)) hrest + have he := physicalEntryCode_injective hM hentry + have hnode := congrArg Prod.fst he + have hstate := congrArg Prod.snd he + apply Subtype.ext + cases first with + | mk first hf => + cases second with + | mk second hs => + cases first + cases second + simp only at hpass hcopy hnode hindex hstate + cases hpass + cases hcopy + cases hnode + cases hindex + cases hstate + rfl + +theorem code_bound {M J n : ℕ} (hM : 1 ≤ M) (passes copies T S : ℕ) + (request : PhysicalTableRequest M J n) (hrequest : Bounded passes copies T S request) : + code copies T S request < capacity M J n passes copies T S := by + have he := physicalEntryCode_bound hM (request.node, request.state) + change physicalEntryCode (request.node, request.state) < entryCapacity M J n at he + have hinner : physicalEntryCode (request.node, request.state) + + entryCapacity M J n * request.pass < entryCapacity M J n * passes := by + nlinarith only [he, Nat.mul_le_mul_left (entryCapacity M J n) (Nat.succ_le_of_lt hrequest.1)] + have hmiddle : request.copy + copies * + (physicalEntryCode (request.node, request.state) + entryCapacity M J n * request.pass) < + copies * (entryCapacity M J n * passes) := by + nlinarith only [hrequest.2.1, Nat.mul_le_mul_left copies (Nat.succ_le_of_lt hinner)] + unfold code capacity + nlinarith only [hrequest.2.2, Nat.mul_le_mul_left (T + S + 1) (Nat.succ_le_of_lt hmiddle)] + +theorem code_fits {M J n : ℕ} (hM : 1 ≤ M) (passes copies T S : ℕ) + (request : {r : PhysicalTableRequest M J n // Bounded passes copies T S r}) : + code copies T S request.val < 2 ^ bits M J n passes copies T S := + (code_bound hM passes copies T S request.val request.property).trans_le + ((Nat.le_succ _).trans (Nat.le_pow_clog (by decide : 1 < 2) _)) + +end PhysicalTableRequest +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestGrid.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..9872c499cf24173949459adc8f186259fdab0611 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalRequestGrid.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalDenominator +import OAI.Combinatorics.EditApproximation.Geometry.ChargedGlobalQuery +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The canonical cache grid for every request, including terminal and +warmup branches. This invariant holds for all incoming seeds and draws. -/ + +namespace EditApproximation + + + +theorem localRequestValue_den_dvd {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q T S copies ell : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) (hell : 0 < ell) + (request : PhysicalTableRequest M J target.length) : + (localRequestValue source target N P F exponent H Q T S copies factor multiplier + tau eta kappa (1 / (ell : ℚ) ^ 10) group integer initial request).den ∣ + (ell ^ 10 + 1) ^ request.remainingDepth := by + unfold localRequestValue unifiedPhysicalValue + split + · rw [physicalLocalWarmup_den_one] + exact one_dvd _ + · exact physicalLocalOnlineRefinement_den_dvd source target _ N P F exponent H Q _ tau eta kappa + T ell hell _ _ request.node (request.index - T) request.state + +theorem chargedRequestValue_den_dvd {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies ell : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa : ℚ) + (group : ℕ → ℕ → PhysicalInternalNode M J → Fin R → CellGroupDraws M F Q) + (integer : ℕ → ℕ → PhysicalInternalNode M J → Fin R → ℕ → TargetInterval target.length → ℕ) + (initial : PhysicalEntry M J target.length → ℕ) (hell : 0 < ell) + (request : ChargedPhysicalRequest M J target.length passes copies T S) : + (chargedRequestValue source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa (1 / (ell : ℚ) ^ 10) group integer initial request).den ∣ + (ell ^ 10 + 1) ^ chargedPhysicalRemaining request := by + cases request with + | inl entry => simp only [chargedRequestValue, chargedPhysicalRemaining, Rat.den_natCast, one_dvd] + | inr request => + exact localRequestValue_den_dvd (R := R) source target N P F exponent H Q T S copies ell + factor multiplier tau eta kappa group integer initial hell request.val + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalResampledRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalResampledRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..1df03733e447904a44893ff5986443b7f6d7f916 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalResampledRegret.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalNodeRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementLocality + +namespace OAI + +/-! The deterministic first-crossing transfer under literal parent-only resampling. -/ + +namespace EditApproximation + +open Finset + +/-- A sampled regret at time t uses only the action sampled at that time. -/ +theorem sampledPrefixRegret_current_sample_congr {β σ : Type*} [Fintype β] + (charge κ : ℝ) (table : ℕ → β × σ → ℝ) (clipped : ℕ → ℝ) + (first second : ℕ → β → σ) (t : ℕ) (heq : first t = second t) : + sampledPrefixRegret charge κ table clipped first t = + sampledPrefixRegret charge κ table clipped second t := by + simp only [sampledPrefixRegret, heq] + +theorem physicalNode_resampled_regret {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) + (reference choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hM : 0 < M) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (hT : 0 < T) + (hgroupsFixed : ∀ label, node.1.val < label.1.val → choices.groups label = reference.groups label) + (honlineFixed : ∀ label, node.1.val < label.1.val → choices.online label = reference.online label) + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (b thetaExponent Q : ℕ) (tau gamma κ : ℚ) (htau : 0 < tau) + (hdelta : 0 < delta) (hκ : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (cell : ℕ × ℕ) + (hnonempty : physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell ≠ []) + (specified : UnskippedBand source target (physicalSourceInterval source.length node) + b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow)) + (hspecified : specified ∈ physicalNodeCellBands source target U N P F A T node hbelow b thetaExponent tau cell) + (hrep : (b, specified.center) ∈ stageRepresentatives source target U N P F A node) + (q : TargetInterval target.length) (hb : (b : ℝ) ≤ stateEditCost (physicalSource source node) target q) + (comparison : Fin M → TargetInterval target.length) (hc : comparison ∈ specified.actions) + (sample : ℕ → Fin M → TargetInterval target.length) (hsample : ∀ t, sample t ∈ specified.actions) + (draw : ℕ → ∀ scale : Fin (groupDyadicScales M b F).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) → Fin M) + (honline : ∀ t, sharedBandRationalAction specified.center (sample t) ∈ + physicalNodeOnline source target U N P F A T delta choices node hbelow t q) + (hselected : ∀ t, (physicalNodeSelectedGroup source target U N P F A T delta reference node hbelow + b thetaExponent Q tau cell hnonempty t (draw t)).rationalAction ∈ + physicalNodeGroups source target U N P F A T delta choices node hbelow t) + (herror : 2 * gamma + 512 * (128 * F : ℚ) * F * (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ κ * delta) + (S : ℕ) : + let c : ℝ := stateEditCost (physicalSource source node) target q + let charge : ℝ := ((128 * F : ℚ) : ℝ) * targetEndpointDistance q specified.center + let history := physicalBandHistory source target U N P F A T delta reference node hbelow + let clipped := physicalComparisonClipped source target U N P F A T delta reference node hbelow comparison + let failure := fun t => physicalNodeGroupFailure source target U N P F A T delta reference node hbelow + b thetaExponent Q tau cell t (draw t) gamma + let crossing := firstCrossing specified.actions.toFinset S + (fun t => bandActionCost charge (fun t coordinate => (history t coordinate : ℝ)) (t + 1)) c + (∑ t ∈ range S, (max c + (physicalRefinement source target U N P F A T delta choices node (t + 1) q : ℝ) - charge - clipped (t + 1))) ≤ + (∑ t ∈ range crossing, sampledPrefixRegret charge (κ : ℝ) + (fun t coordinate => (history t coordinate : ℝ)) clipped sample t) + 2 * (delta : ℝ) * c + + 2 * (F : ℝ) * c * ∑ t ∈ range S, (if failure t then (1 : ℝ) else 0) := by + have hchildren := physicalRefinement_children_fixed source target U N P F A T delta + choices reference node hbelow hgroupsFixed honlineFixed + have hhistory : physicalBandHistory source target U N P F A T delta choices node hbelow = + physicalBandHistory source target U N P F A T delta reference node hbelow := by + funext t coordinate + exact congrFun (congrFun (congrFun hchildren coordinate.1) t) coordinate.2 + have hselected' t : + (physicalNodeSelectedGroup source target U N P F A T delta choices node hbelow + b thetaExponent Q tau cell hnonempty t (draw t)).rationalAction ∈ + physicalNodeGroups source target U N P F A T delta choices node hbelow t := by + simpa only [physicalNodeSelectedGroup, hhistory] using hselected t + have hdet := physicalNode_firstCrossing_regret source target U N P F A T delta choices node hbelow + hM hsize hP hF hA hseed hT hleaf b thetaExponent Q tau gamma κ htau hdelta hκ hκhalf + cell hnonempty specified hspecified hrep q hb comparison hc sample hsample draw honline hselected' herror S + have hclipped : physicalComparisonClipped source target U N P F A T delta choices node hbelow comparison = + physicalComparisonClipped source target U N P F A T delta reference node hbelow comparison := by + funext t + simp only [physicalComparisonClipped, hhistory] + have hfailure : physicalNodeGroupFailure source target U N P F A T delta choices node hbelow + b thetaExponent Q tau cell = physicalNodeGroupFailure source target U N P F A T delta reference node hbelow + b thetaExponent Q tau cell := by + funext t draw gamma + simp only [physicalNodeGroupFailure, hhistory] + dsimp only at hdet ⊢ + rw [hhistory, hclipped, hfailure] at hdet + exact hdet + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarCodeBits.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarCodeBits.lean new file mode 100644 index 0000000000000000000000000000000000000000..514661fedf89ba0f8e4707c52c13bf36a2ab07f1 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarCodeBits.lean @@ -0,0 +1,61 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarEncoding + +namespace OAI + +/-! Concrete coordinate pairing has constant-factor bit overhead. The +addresses are computed from coordinates, without enumerating a key space. -/ + +namespace EditApproximation + + theorem natPair_lt_two_pow {a b k : ℕ} (ha : a < 2 ^ k) (hb : b < 2 ^ k) : + Nat.pair a b < 2 ^ (2 * k) := by + calc + _ < (max a b + 1) ^ 2 := Nat.pair_lt_max_add_one_sq a b + _ ≤ (2 ^ k) ^ 2 := Nat.pow_le_pow_left (by omega) 2 + _ = _ := by rw [← pow_mul]; congr 1; omega + + theorem natPair_lt_two_pow_scaled {a b k d : ℕ} (ha : a < 2 ^ k) + (hb : b < 2 ^ (d * k)) (hd : 1 ≤ d) : Nat.pair a b < 2 ^ ((2 * d) * k) := by + have hk : k ≤ d * k := by simpa only [one_mul] using Nat.mul_le_mul_right k hd + have h := natPair_lt_two_pow (ha.trans_le (Nat.pow_le_pow_right (by decide) hk)) hb + simpa only [Nat.mul_assoc] using h + + theorem physicalScalarCode_bound {M J N n exponent F Q R B : ℕ} (k : ℕ) + (hnode : ∀ node : PhysicalNode M J, physicalNodeCode node < 2 ^ k) + (hentry : ∀ entry : PhysicalEntry M J n, physicalEntryCode entry < 2 ^ k) + (hscale : (dyadicScales N).length ≤ 2 ^ k) + (hcell : n * 2 ^ exponent + 1 ≤ 2 ^ k) + (hrange : B + 1 ≤ 2 ^ k) (htime : R ≤ 2 ^ k) (hM : M ≤ 2 ^ k) + (hlabels : ∀ scale : Fin (dyadicScales N).length, + (groupDyadicScales M ((dyadicScales N).get scale) F).length ≤ 2 ^ k) + (key : PhysicalScalarKey M J N n exponent F Q R B) : + physicalScalarCode key < 2 ^ (64 * k + 1) := by + rcases key with ⟨key, index⟩ + cases key with + | inl online => + have h0 := natPair_lt_two_pow (online.2.val.isLt.trans_le hrange) (index.isLt.trans_le htime) + have h1 := natPair_lt_two_pow_scaled (online.1.2.1.isLt.trans_le hscale) h0 (by decide : 1 ≤ 2) + have h2 := natPair_lt_two_pow_scaled (hentry (online.1.1.val, online.1.2.2)) h1 (by decide : 1 ≤ 4) + have h2' : Nat.pair (physicalEntryCode (online.1.1.val, online.1.2.2)) + (Nat.pair online.1.2.1.val (Nat.pair online.2.val.val index.val)) < 2 ^ (64 * k) := + h2.trans_le (Nat.pow_le_pow_right (by decide) (by omega)) + change 2 * _ < _ + rw [pow_succ] + omega + | inr group => + have h0 := natPair_lt_two_pow + (index.2.1.isLt.trans_le (hlabels group.2.1)) + (index.2.2.isLt.trans_le ((min_le_left _ _).trans hM)) + have h1 := natPair_lt_two_pow_scaled (index.1.isLt.trans_le htime) h0 (by decide : 1 ≤ 2) + have h2 := natPair_lt_two_pow_scaled (group.2.2.2.isLt.trans_le hcell) h1 (by decide : 1 ≤ 4) + have h3 := natPair_lt_two_pow_scaled (group.2.2.1.isLt.trans_le hcell) h2 (by decide : 1 ≤ 8) + have h4 := natPair_lt_two_pow_scaled (group.2.1.isLt.trans_le hscale) h3 (by decide : 1 ≤ 16) + have h5 := natPair_lt_two_pow_scaled (hnode group.1.val) h4 (by decide : 1 ≤ 32) + norm_num only at h5 + change 2 * _ + 1 < _ + rw [pow_succ] + omega + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarEncoding.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..64e5a8bc987bdd995c2f88cb7c249dd601619ccc --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarEncoding.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarSource +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalNodeEncoding +import Mathlib.Data.Nat.Pairing +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Scalar-source addresses are computed from physical coordinates by +integer pairing. No enumeration of the probability space is performed. -/ + +namespace EditApproximation + +variable {M J N n exponent F Q R B : ℕ} + + + + theorem physicalScalarCode_injective (hM : 1 ≤ M) : + Function.Injective (@physicalScalarCode M J N n exponent F Q R B) := by + intro left right heq + rcases left with ⟨left, li⟩ + rcases right with ⟨right, ri⟩ + cases left with + | inl left => + cases right with + | inl right => + have hp : Nat.pair (physicalEntryCode (left.1.1.val, left.1.2.2)) + (Nat.pair left.1.2.1.val (Nat.pair left.2.val.val li.val)) = + Nat.pair (physicalEntryCode (right.1.1.val, right.1.2.2)) + (Nat.pair right.1.2.1.val (Nat.pair right.2.val.val ri.val)) := by + change 2 * _ = 2 * _ at heq + omega + rcases Nat.pair_eq_pair.mp hp with ⟨he, hs⟩ + rcases Nat.pair_eq_pair.mp hs with ⟨hs, hr⟩ + rcases Nat.pair_eq_pair.mp hr with ⟨hr, ht⟩ + have he := physicalEntryCode_injective hM he + have hn : left.1.1 = right.1.1 := Subtype.ext (congrArg Prod.fst he) + have hq := congrArg Prod.snd he + have hs : left.1.2.1 = right.1.2.1 := Fin.ext hs + have hr : left.2 = right.2 := Subtype.ext (Fin.ext hr) + have ht : li = ri := Fin.ext ht + rcases left with ⟨⟨node, scale, q⟩, range⟩ + rcases right with ⟨⟨node', scale', q'⟩, range'⟩ + dsimp only at hn hq hs hr + subst node' + subst scale' + subst q' + subst range' + cases ht + rfl + | inr right => + change 2 * _ = 2 * _ + 1 at heq + omega + | inr left => + cases right with + | inl right => + change 2 * _ + 1 = 2 * _ at heq + omega + | inr right => + have hp : Nat.pair (physicalNodeCode left.1.val) + (Nat.pair left.2.1.val (Nat.pair left.2.2.1.val (Nat.pair left.2.2.2.val + (Nat.pair li.1.val (Nat.pair li.2.1.val li.2.2.val))))) = + Nat.pair (physicalNodeCode right.1.val) + (Nat.pair right.2.1.val (Nat.pair right.2.2.1.val (Nat.pair right.2.2.2.val + (Nat.pair ri.1.val (Nat.pair ri.2.1.val ri.2.2.val))))) := by + change 2 * _ + 1 = 2 * _ + 1 at heq + omega + rcases Nat.pair_eq_pair.mp hp with ⟨hn, hp⟩ + rcases Nat.pair_eq_pair.mp hp with ⟨hs, hp⟩ + rcases Nat.pair_eq_pair.mp hp with ⟨hx, hp⟩ + rcases Nat.pair_eq_pair.mp hp with ⟨hy, hp⟩ + rcases Nat.pair_eq_pair.mp hp with ⟨ht, hp⟩ + rcases Nat.pair_eq_pair.mp hp with ⟨hl, hv⟩ + have hn : left.1 = right.1 := Subtype.ext (physicalNodeCode_injective hM hn) + have hs : left.2.1 = right.2.1 := Fin.ext hs + have hx : left.2.2.1 = right.2.2.1 := Fin.ext hx + have hy : left.2.2.2 = right.2.2.2 := Fin.ext hy + rcases left with ⟨node, scale, x, y⟩ + rcases right with ⟨node', scale', x', y'⟩ + dsimp only at hn hs hx hy + subst node' + subst scale' + subst x' + subst y' + rcases li with ⟨time, label, value⟩ + rcases ri with ⟨time', label', value'⟩ + have ht : time = time' := Fin.ext ht + cases ht + have hl : label = label' := Fin.ext hl + cases hl + have hv : value = value' := Fin.ext hv + cases hv + rfl + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarFamily.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..042342a8350e265e612acb745e91fa632229c8ea --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarFamily.lean @@ -0,0 +1,121 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarReads +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRandomValue +import OAI.Combinatorics.EditApproximation.Geometry.LocalOnlineMassBound +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalJointProgram +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Finite independent scalar sources for all passes and copies. The +incoming seed selects the range only after the earlier passes are evaluated. -/ + +namespace EditApproximation + +section Family + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P F exponent H Q T S passes copies : ℕ) + (factor : ℕ → ℚ) (multiplier : ℕ → ℕ) (tau eta kappa delta : ℚ) (hP : 0 < P) + + + + + +variable (draw : PhysicalFamilyScalarDraw + (M := M) (J := J) (R := R) target N P F exponent H Q passes copies) + +def physicalFamilyDraw (pass copy : ℕ) : + PhysicalScalarDraw M J N target.length exponent F Q R (localOnlineMassBound M P H) := + fun key => draw (Fin.ofNat (passes + 1) pass, Fin.ofNat (copies + 1) copy, key) + + + + + + + +noncomputable def physicalFamilySample (seed : PhysicalEntry M J target.length → ℕ) (pass copy : ℕ) := + physicalCommonSample source target seed N P F (factor pass) T exponent H Q R + (localOnlineMassBound M P H) tau + (physicalLocalOnlineMass_le source target seed N P F (factor pass) T exponent H tau hP) + (physicalScalarPack M J N target.length exponent F Q R (localOnlineMassBound M P H) + (physicalFamilyDraw target N P F exponent H Q passes copies draw pass copy)) + +noncomputable def physicalFamilySeed (initial : PhysicalEntry M J target.length → ℕ) : + ℕ → PhysicalEntry M J target.length → ℕ + | 0 => initial + | pass + 1 => fun state => min N (upperMedian (List.ofFn fun copy : Fin copies => + ⌈(multiplier pass : ℚ) * physicalLocalJointValue source target + (physicalFamilySeed initial pass) N P F (factor pass) T exponent H Q tau eta kappa delta + (physicalFamilySample source target N P F exponent H Q T passes copies factor tau hP draw + (physicalFamilySeed initial pass) pass copy.val) state.1 S state.2⌉₊)) + +noncomputable def physicalFamilyGroup (pass copy : ℕ) := + physicalRawGroupDraws M J N target.length exponent F Q R + (fun group => physicalScalarPack M J N target.length exponent F Q R (localOnlineMassBound M P H) + (physicalFamilyDraw target N P F exponent H Q passes copies draw pass copy) (.inr group)) + +noncomputable def physicalFamilyInteger (initial : PhysicalEntry M J target.length → ℕ) + (pass copy : ℕ) := + physicalRawOnlineIntegers source target + (physicalFamilySeed source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta hP draw initial pass) + N P F (factor pass) T exponent H tau + (fun online => physicalFamilySample source target N P F exponent H Q T passes copies factor tau hP draw + (physicalFamilySeed source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta hP draw initial pass) pass copy (.inl online)) + + theorem physicalFamilySeed_eq (initial : PhysicalEntry M J target.length → ℕ) (pass : ℕ) : + localSeedSequence source target N P F exponent H Q T S copies factor multiplier tau eta kappa delta + (physicalFamilyGroup target N P F exponent H Q passes copies draw) + (physicalFamilyInteger source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta hP draw initial) initial pass = + physicalFamilySeed source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta hP draw initial pass := by + induction pass with + | zero => rfl + | succ pass ih => + rw [localSeedSequence, physicalFamilySeed, ih] + rfl + +omit [DecidableEq α] [NeZero R] in + theorem physicalFamilyGroupRead_value (pass copy : ℕ) (node : PhysicalInternalNode M J) + (time : Fin R) (key : GroupScalarKey M F Q) : + (physicalFamilyGroupRead target N P F exponent H Q passes copies pass copy node time key).value + (physicalFamilyAnswer target N P F exponent H Q passes copies draw) = + groupScalarValue (physicalFamilyGroup target N P F exponent H Q passes copies draw pass copy node time) key := by + rw [physicalFamilyGroupRead, FiniteQuery.mapKeys_value] + exact physicalScalarGroupRead_value M J N target.length exponent F Q R (localOnlineMassBound M P H) + (physicalFamilyDraw target N P F exponent H Q passes copies draw pass copy) node time key + + theorem physicalFamilyOnlineRead_value (initial : PhysicalEntry M J target.length → ℕ) + (pass copy : ℕ) (node : PhysicalInternalNode M J) (time : Fin R) + (key : ℕ × TargetInterval target.length) : + (physicalFamilyOnlineRead target N P F exponent H Q passes copies pass copy node time key + (keyedOnlineSourceRange source target (physicalSourceInterval source.length node.val) P exponent H tau + (fun i r => (∑ j : Fin T, localRequestValue source target N P F exponent H Q T S copies + factor multiplier tau eta kappa delta + (physicalFamilyGroup target N P F exponent H Q passes copies draw) + (physicalFamilyInteger source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta hP draw initial) initial + (PhysicalTableRequest.warmup pass copy (physicalChild node.val node.property i) j.val r)) / T) key)).value + (physicalFamilyAnswer target N P F exponent H Q passes copies draw) = + (physicalFamilyInteger source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta hP draw initial pass copy node time key.1 key.2 : ℚ) := by + rw [physicalFamilyOnlineRead, FiniteQuery.mapKeys_value] + apply physicalScalarOnlineRead_value source target + (physicalFamilySeed source target N P F exponent H Q T S passes copies factor multiplier + tau eta kappa delta hP draw initial pass) N P F (factor pass) T exponent H Q R + (localOnlineMassBound M P H) tau + (physicalLocalOnlineMass_le source target _ N P F (factor pass) T exponent H tau hP) + (physicalFamilyDraw target N P F exponent H Q passes copies draw pass copy) node time key + intro hb + rw [localRequestValue_onlineRange source target N P F exponent H Q T S copies factor multiplier + tau eta kappa delta, physicalFamilySeed_eq] + +end Family + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarFamilyLaw.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarFamilyLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9c7dbf3baf0b72b5da7395c1143e6d5bae3b0bd --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarFamilyLaw.lean @@ -0,0 +1,117 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarFamily + +namespace OAI + +/-! Regrouping the finite physical scalar source gives exactly one fresh +common draw for each pass and copy. This is equality of product laws, +not an assumption about the sampler. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + + theorem finite_pi_product_curry {ι κ : Type*} [Fintype ι] [Fintype κ] + {X : κ → Type*} [∀ j, Fintype (X j)] [∀ j, MeasurableSpace (X j)] + [∀ j, MeasurableSingletonClass (X j)] (μ : ∀ j, Measure (X j)) + [∀ j, IsProbabilityMeasure (μ j)] : + (Measure.pi fun pair : ι × κ => μ pair.2).map (fun draw i j => draw (i, j)) = + Measure.pi fun _ : ι => Measure.pi μ := by + classical + apply Measure.ext_of_singleton + intro result + rw [Measure.map_apply (by fun_prop) (measurableSet_singleton _)] + have hpre : (fun draw i j => draw (i, j)) ⁻¹' {result} = + {fun pair : ι × κ => result pair.1 pair.2} := by + ext draw + simp only [Set.mem_preimage, Set.mem_singleton_iff] + constructor + · intro h + funext pair + exact congrFun (congrFun h pair.1) pair.2 + · rintro rfl + rfl + rw [hpre] + simp only [Measure.pi_singleton] + simpa only [Finset.univ_product_univ] using + (Finset.prod_product (Finset.univ : Finset ι) (Finset.univ : Finset κ) + (fun pair => μ pair.2 {result pair.1 pair.2})) + +section FamilyLaw + +variable {α : Type*} {M J R : ℕ} [NeZero M] + (target : List α) (N P F exponent H Q passes copies : ℕ) + +local notation "Key" => PhysicalScalarKey M J N target.length exponent F Q R (localOnlineMassBound M P H) +local notation "range" => physicalScalarRange M J N target.length exponent F Q R (localOnlineMassBound M P H) + +noncomputable def physicalFamilyLaw : Measure (PhysicalFamilyScalarDraw + (M := M) (J := J) (R := R) target N P F exponent H Q passes copies) := + Measure.pi fun key => (PMF.uniformOfFintype (Fin (range key.2.2))).toMeasure + +instance physicalFamilyLaw_probability : IsProbabilityMeasure + (physicalFamilyLaw (M := M) (J := J) (R := R) target N P F exponent H Q passes copies) := by + unfold physicalFamilyLaw + infer_instance + +def physicalFamilyCurry (draw : PhysicalFamilyScalarDraw + (M := M) (J := J) (R := R) target N P F exponent H Q passes copies) + (pass : Fin (passes + 1)) (copy : Fin (copies + 1)) : + PhysicalScalarDraw M J N target.length exponent F Q R (localOnlineMassBound M P H) := + fun key => draw (pass, copy, key) + + theorem physicalFamilyCurry_law : + (physicalFamilyLaw (M := M) (J := J) (R := R) target N P F exponent H Q passes copies).map + (physicalFamilyCurry target N P F exponent H Q passes copies) = + Measure.pi fun _ : Fin (passes + 1) => Measure.pi fun _ : Fin (copies + 1) => + physicalScalarLaw M J N target.length exponent F Q R (localOnlineMassBound M P H) := by + let μ : ∀ key : Key, Measure (Fin (range key)) := fun key => + (PMF.uniformOfFintype (Fin (range key))).toMeasure + have hfirst := finite_pi_product_curry (ι := Fin (passes + 1)) + (κ := Fin (copies + 1) × Key) (fun pair => μ pair.2) + have hsecond := Measure.pi_map_pi + (μ := fun _ : Fin (passes + 1) => Measure.pi fun pair : Fin (copies + 1) × Key => μ pair.2) + (f := fun (_ : Fin (passes + 1)) draw (copy : Fin (copies + 1)) (key : Key) => draw (copy, key)) + (fun _ => (measurable_of_finite _).aemeasurable) + have hrow := finite_pi_product_curry (ι := Fin (copies + 1)) μ + have htarget : (Measure.pi fun _ : Fin (passes + 1) => + (Measure.pi fun pair : Fin (copies + 1) × Key => μ pair.2).map + (fun draw copy key => draw (copy, key))) = + Measure.pi fun _ : Fin (passes + 1) => Measure.pi fun _ : Fin (copies + 1) => Measure.pi μ := by + simp only [hrow] + rw [← hfirst, Measure.map_map (by fun_prop) (by fun_prop)] at hsecond + exact hsecond.trans htarget + +def physicalFamilyPack (draw : PhysicalFamilyScalarDraw + (M := M) (J := J) (R := R) target N P F exponent H Q passes copies) + (pass : Fin (passes + 1)) (copy : Fin (copies + 1)) := + physicalScalarPack M J N target.length exponent F Q R (localOnlineMassBound M P H) + (physicalFamilyCurry target N P F exponent H Q passes copies draw pass copy) + + theorem physicalFamilyPack_law : + (physicalFamilyLaw (M := M) (J := J) (R := R) target N P F exponent H Q passes copies).map + (physicalFamilyPack target N P F exponent H Q passes copies) = + Measure.pi fun _ : Fin (passes + 1) => Measure.pi fun _ : Fin (copies + 1) => + physicalCommonLaw M J N target.length exponent F Q R (localOnlineMassBound M P H) := by + let pack := physicalScalarPack M J N target.length exponent F Q R (localOnlineMassBound M P H) + have hrow := Measure.pi_map_pi + (μ := fun _ : Fin (copies + 1) => physicalScalarLaw M J N target.length exponent F Q R (localOnlineMassBound M P H)) + (f := fun _ => pack) (fun _ => (measurable_of_finite _).aemeasurable) + have hrow' : (Measure.pi fun _ : Fin (copies + 1) => + physicalScalarLaw M J N target.length exponent F Q R (localOnlineMassBound M P H)).map + (fun row copy => pack (row copy)) = + Measure.pi fun _ : Fin (copies + 1) => + physicalCommonLaw M J N target.length exponent F Q R (localOnlineMassBound M P H) := by + exact hrow.trans (by simp only [pack, physicalScalarPack_law]) + have h := Measure.pi_map_pi + (μ := fun _ : Fin (passes + 1) => Measure.pi fun _ : Fin (copies + 1) => + physicalScalarLaw M J N target.length exponent F Q R (localOnlineMassBound M P H)) + (f := fun _ row copy => pack (row copy)) (fun _ => (measurable_of_finite _).aemeasurable) + rw [← physicalFamilyCurry_law target N P F exponent H Q passes copies, + Measure.map_map (by fun_prop) (by fun_prop)] at h + exact h.trans (by simp only [hrow']) + +end FamilyLaw + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarReadCost.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarReadCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d23a706b3ddedd0faf349da8e0c53de4bd69063 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarReadCost.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarFamily +import OAI.Combinatorics.EditApproximation.Probability.FiniteQueryCostOrder + +namespace OAI + +/-! Each physical group or online source reader requests at most one +scalar. The guards and dependent index transports do not create reads. -/ + +namespace EditApproximation + +section Cost + +variable (M J N n exponent F Q R B : ℕ) [NeZero M] + (oracle : PhysicalScalarKey M J N n exponent F Q R B → ℚ) + (weight : PhysicalScalarKey M J N n exponent F Q R B → ℕ) + (bound : ℕ) (hweight : ∀ key, weight key ≤ bound) + +omit [NeZero M] in +private theorem groupQuery_transport_cost (b c : ℕ) (h : b = c) + (queries : PhysicalGroupQueries M J N n exponent F Q R B b) + (hq : ∀ scale sample, (queries scale sample).cost oracle weight ≤ bound) : + ∀ scale sample, + ((Eq.mp (congrArg (PhysicalGroupQueries M J N n exponent F Q R B) h) queries) scale sample).cost + oracle weight ≤ bound := by + subst c + exact hq + +omit [NeZero M] in +include hweight in + theorem physicalScalarGroupRead_cost_le (node : PhysicalInternalNode M J) (time : Fin R) + (key : GroupScalarKey M F Q) : + (physicalScalarGroupRead M J N n exponent F Q R B node time key).cost oracle weight ≤ bound := by + rcases key with ⟨⟨b, cell⟩, scale, sample⟩ + unfold physicalScalarGroupRead physicalScalarGroupQueries + dsimp only + split_ifs with hb hc + · let group : PhysicalLocalGroupKey M J N n exponent := + (node, physicalScaleIndex N b hb, + ⟨cell.1, Nat.lt_succ_of_le hc.1⟩, ⟨cell.2, Nat.lt_succ_of_le hc.2⟩) + exact groupQuery_transport_cost M J N n exponent F Q R B oracle weight bound + ((dyadicScales N).get group.2.1) b (physicalScaleIndex_get N b hb) + (physicalScalarGroupQueriesAt M J N n exponent F Q R B group time) + (fun _ _ => by simpa only [physicalScalarGroupQueriesAt, FiniteQuery.cost, Nat.add_zero] using hweight _) + scale sample + · exact Nat.zero_le _ + · exact Nat.zero_le _ + +omit [NeZero M] in +include hweight in + theorem physicalScalarOnlineRead_cost_le (node : PhysicalInternalNode M J) (time : Fin R) + (key : ℕ × TargetInterval n) (range : ℕ) : + (physicalScalarOnlineRead M J N n exponent F Q R B node time key range).cost oracle weight ≤ bound := by + unfold physicalScalarOnlineRead + split_ifs <;> simp only [FiniteQuery.cost, Nat.add_zero] + · exact hweight _ + · exact Nat.zero_le _ + · exact Nat.zero_le _ + +end Cost + +section Family + +variable {α : Type*} {M J R : ℕ} [NeZero M] + (target : List α) (N P F exponent H Q passes copies : ℕ) + (oracle : PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies → ℚ) + (weight : PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies → ℕ) + (bound : ℕ) (hweight : ∀ key, weight key ≤ bound) + +omit [NeZero M] in +include hweight in + theorem physicalFamilyGroupRead_cost_le (pass copy : ℕ) (node : PhysicalInternalNode M J) + (time : Fin R) (key : GroupScalarKey M F Q) : + (physicalFamilyGroupRead target N P F exponent H Q passes copies pass copy node time key).cost + oracle weight ≤ bound := by + rw [physicalFamilyGroupRead, FiniteQuery.mapKeys_cost] + exact physicalScalarGroupRead_cost_le M J N target.length exponent F Q R (localOnlineMassBound M P H) + _ _ bound (fun _ => hweight _) node time key + +omit [NeZero M] in +include hweight in + theorem physicalFamilyOnlineRead_cost_le (pass copy : ℕ) (node : PhysicalInternalNode M J) + (time : Fin R) (key : ℕ × TargetInterval target.length) (range : ℕ) : + (physicalFamilyOnlineRead target N P F exponent H Q passes copies pass copy node time key range).cost + oracle weight ≤ bound := by + rw [physicalFamilyOnlineRead, FiniteQuery.mapKeys_cost] + exact physicalScalarOnlineRead_cost_le M J N target.length exponent F Q R (localOnlineMassBound M P H) + _ _ bound (fun _ => hweight _) node time key range + +end Family + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarReads.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarReads.lean new file mode 100644 index 0000000000000000000000000000000000000000..65aa574c649160d7ea92c3e08194ebd98ece1540 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarReads.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalScalarSource +import OAI.Combinatorics.EditApproximation.Geometry.LocalGroupSourceQuery +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRawGroupProgram +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRawOnlineProgram +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Direct scalar source requests. The physical scale/cell guards agree +with the original raw providers, and an online request carries its range. -/ + +namespace EditApproximation + +section Reads + +variable (M J N n exponent F Q R B : ℕ) [NeZero M] + + + +def physicalScalarAnswer (draw : PhysicalScalarDraw M J N n exponent F Q R B) + (key : PhysicalScalarKey M J N n exponent F Q R B) : ℚ := (draw key).val + + + + + + + + + +end Reads + +section GroupCorrectness + +variable (M J N n exponent F Q R B : ℕ) [NeZero M] + (draw : PhysicalScalarDraw M J N n exponent F Q R B) + +omit [NeZero M] in +private theorem groupQuery_transport (b c : ℕ) (h : b = c) + (queries : PhysicalGroupQueries M J N n exponent F Q R B b) + (values : ParentGroupDraw M (groupDyadicScales M b F).length + (fun scale => groupSampleCount M Q b (groupDyadicScaleAt M b F scale))) + (hq : ∀ scale sample, (queries scale sample).value + (physicalScalarAnswer M J N n exponent F Q R B draw) = (values scale sample).val) : + ∀ scale sample, + ((Eq.mp (congrArg (PhysicalGroupQueries M J N n exponent F Q R B) h) queries) scale sample).value + (physicalScalarAnswer M J N n exponent F Q R B draw) = + ((Eq.mp (congrArg (fun b => ParentGroupDraw M (groupDyadicScales M b F).length + (fun scale => groupSampleCount M Q b (groupDyadicScaleAt M b F scale))) h) values) scale sample).val := by + subst c + exact hq + + theorem physicalScalarGroupRead_value (node : PhysicalInternalNode M J) (time : Fin R) + (key : GroupScalarKey M F Q) : + (physicalScalarGroupRead M J N n exponent F Q R B node time key).value + (physicalScalarAnswer M J N n exponent F Q R B draw) = + groupScalarValue (physicalRawGroupDraws M J N n exponent F Q R + (fun group => physicalScalarPack M J N n exponent F Q R B draw (.inr group)) node time) key := by + rcases key with ⟨⟨b, cell⟩, scale, sample⟩ + unfold physicalScalarGroupRead physicalScalarGroupQueries groupScalarValue physicalRawGroupDraws + dsimp only + split_ifs with hb hc + · let group : PhysicalLocalGroupKey M J N n exponent := + (node, physicalScaleIndex N b hb, + ⟨cell.1, Nat.lt_succ_of_le hc.1⟩, ⟨cell.2, Nat.lt_succ_of_le hc.2⟩) + exact groupQuery_transport M J N n exponent F Q R B draw + ((dyadicScales N).get group.2.1) b (physicalScaleIndex_get N b hb) + (physicalScalarGroupQueriesAt M J N n exponent F Q R B group time) + (physicalScalarPack M J N n exponent F Q R B draw (.inr group) time) + (fun _ _ => rfl) scale sample + · rfl + · rfl + +end GroupCorrectness + +section OnlineCorrectness + +variable {α : Type*} [DecidableEq α] {M J : ℕ} [NeZero M] + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T exponent H Q R B : ℕ) (tau : ℚ) + (hbound : ∀ key, physicalLocalOnlineMass source target U N P F A T exponent H tau key ≤ B) + (draw : PhysicalScalarDraw M J N target.length exponent F Q R B) + +omit [NeZero M] in + theorem physicalScalarOnlineRead_value [NeZero R] + (node : PhysicalInternalNode M J) (time : Fin R) (key : ℕ × TargetInterval target.length) + (range : ℕ) + (hrange : ∀ hb : key.1 ∈ dyadicScales N, range = + physicalLocalOnlineMass source target U N P F A T exponent H tau + (node, physicalScaleIndex N key.1 hb, key.2)) : + (physicalScalarOnlineRead M J N target.length exponent F Q R B node time key range).value + (physicalScalarAnswer M J N target.length exponent F Q R B draw) = + (physicalRawOnlineIntegers source target U N P F A T exponent H tau + (fun online => physicalCommonSample source target U N P F A T exponent H Q R B tau hbound + (physicalScalarPack M J N target.length exponent F Q R B draw) (.inl online)) + node time key.1 key.2 : ℚ) := by + unfold physicalScalarOnlineRead physicalRawOnlineIntegers + by_cases hb : key.1 ∈ dyadicScales N + · rw [dite_eq_left hb, dite_eq_left hb, hrange hb] + have hpos := physicalCommonMass_positive source target U N P F A T exponent H tau + (node, physicalScaleIndex N key.1 hb, key.2) + rw [dite_eq_left ⟨hpos, hbound _⟩] + simp only [FiniteQuery.value, physicalCommonSample, physicalCommonCoordinateImage, + physicalScalarPack, physicalScalarCoordinatePack, physicalScalarAnswer, + physicalCommonSelectedKey, physicalCommonSelectedOnlineKey] + exact (congrArg (fun z : ℕ => (z : ℚ)) (Fin.val_cast _ _)).symm + · rw [dite_eq_right hb, dite_eq_right hb] + rfl + +end OnlineCorrectness + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarSource.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fea774a3b284bd9a7e7ddbfab9447f7acc20f36 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalScalarSource.lean @@ -0,0 +1,131 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCommonSource +import OAI.Combinatorics.EditApproximation.Probability.RejectionArrayLaw +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Each common array source is realized by scalar exact uniform draws. +Regrouping finite coordinates recovers the common source law; unused +coordinates belong only to the probability space. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + +theorem finite_pi_curry {ι : Type*} [Fintype ι] {κ : ι → Type*} [∀ i, Fintype (κ i)] + {X : (i : ι) → κ i → Type*} [∀ i j, MeasurableSpace (X i j)] + (μ : ∀ i j, Measure (X i j)) [∀ i j, IsProbabilityMeasure (μ i j)] : + (Measure.pi fun p : Sigma κ => μ p.1 p.2).map (fun draw i j => draw ⟨i, j⟩) = + Measure.pi fun i => Measure.pi (μ i) := by + have h := Measure.infinitePi_map_piCurry μ + simp only [Measure.infinitePi_eq_pi, MeasurableEquiv.coe_piCurry] at h + convert h using 1 + congr 1 + +theorem finite_uniform_three_curry {ι : Type*} [Fintype ι] + {κ : ι → Type*} [∀ i, Fintype (κ i)] + {κ₂ : (i : ι) → κ i → Type*} [∀ i j, Fintype (κ₂ i j)] + (M : ℕ) [NeZero M] : + (Measure.pi fun _ : Σ i, Σ j : κ i, κ₂ i j => (PMF.uniformOfFintype (Fin M)).toMeasure).map + (fun draw i j k => draw ⟨i, j, k⟩) = + Measure.pi fun i => Measure.pi fun j : κ i => Measure.pi fun _ : κ₂ i j => + (PMF.uniformOfFintype (Fin M)).toMeasure := by + let μ := fun (i : ι) (_ : Σ j : κ i, κ₂ i j) => (PMF.uniformOfFintype (Fin M)).toMeasure + have hfirst := finite_pi_curry μ + have hsecond := Measure.pi_map_pi + (μ := fun i => Measure.pi (μ i)) + (f := fun (i : ι) (draw : (Σ j : κ i, κ₂ i j) → Fin M) (j : κ i) (k : κ₂ i j) => draw ⟨j, k⟩) + (fun _ => (measurable_of_finite _).aemeasurable) + have heach (i : ι) := finite_pi_curry (fun (j : κ i) (_ : κ₂ i j) => + (PMF.uniformOfFintype (Fin M)).toMeasure) + dsimp only [μ] at hsecond + simp_rw [heach] at hsecond + rw [← hfirst, Measure.map_map (by fun_prop) (by fun_prop)] at hsecond + exact hsecond + + + + + + + + + + + +abbrev PhysicalScalarDraw (M J N n exponent F Q R B : ℕ) := + ∀ key : PhysicalScalarKey M J N n exponent F Q R B, + Fin (physicalScalarRange M J N n exponent F Q R B key) + +noncomputable def physicalScalarLaw (M J N n exponent F Q R B : ℕ) [NeZero M] : + Measure (PhysicalScalarDraw M J N n exponent F Q R B) := + Measure.pi fun key => (PMF.uniformOfFintype + (Fin (physicalScalarRange M J N n exponent F Q R B key))).toMeasure + +instance physicalScalarLaw_probability (M J N n exponent F Q R B : ℕ) [NeZero M] : + IsProbabilityMeasure (physicalScalarLaw M J N n exponent F Q R B) := by + unfold physicalScalarLaw + infer_instance + +def physicalScalarCoordinatePack (M J N n exponent F Q R B : ℕ) + (key : PhysicalCommonKey M J N n exponent B) + (draw : ∀ index : PhysicalScalarIndex M J N n exponent F Q R B key, + Fin (physicalScalarRange M J N n exponent F Q R B ⟨key, index⟩)) : + PhysicalCommonCoordinate M J N n exponent F Q R B key := + match key with + | .inl _ => draw + | .inr _ => fun time scale sample => draw ⟨time, scale, sample⟩ + +def physicalScalarPack (M J N n exponent F Q R B : ℕ) + (draw : PhysicalScalarDraw M J N n exponent F Q R B) : + PhysicalCommonDraw M J N n exponent F Q R B := + fun key => physicalScalarCoordinatePack M J N n exponent F Q R B key (fun index => draw ⟨key, index⟩) + +section Laws + +variable (M J N n exponent F Q R B : ℕ) [NeZero M] + + theorem physicalScalarCoordinatePack_law (key : PhysicalCommonKey M J N n exponent B) : + (Measure.pi fun index : PhysicalScalarIndex M J N n exponent F Q R B key => + (PMF.uniformOfFintype (Fin (physicalScalarRange M J N n exponent F Q R B ⟨key, index⟩))).toMeasure).map + (physicalScalarCoordinatePack M J N n exponent F Q R B key) = + physicalCommonCoordinateLaw M J N n exponent F Q R B key := by + cases key with + | inl online => exact Measure.map_id + | inr group => exact finite_uniform_three_curry M + + theorem physicalScalarPack_law : + (physicalScalarLaw M J N n exponent F Q R B).map + (physicalScalarPack M J N n exponent F Q R B) = + physicalCommonLaw M J N n exponent F Q R B := by + let μ := fun (key : PhysicalCommonKey M J N n exponent B) + (index : PhysicalScalarIndex M J N n exponent F Q R B key) => + (PMF.uniformOfFintype (Fin (physicalScalarRange M J N n exponent F Q R B ⟨key, index⟩))).toMeasure + have hfirst := finite_pi_curry μ + have hsecond := Measure.pi_map_pi (μ := fun key => Measure.pi (μ key)) + (f := physicalScalarCoordinatePack M J N n exponent F Q R B) + (fun _ => (measurable_of_finite _).aemeasurable) + have heach := physicalScalarCoordinatePack_law M J N n exponent F Q R B + dsimp only [μ] at hsecond + simp_rw [heach] at hsecond + rw [← hfirst, Measure.map_map (measurable_of_finite _) (measurable_of_finite _)] at hsecond + exact hsecond + + theorem physicalRejectionArray_pack_law : + (rejectionArrayLaw (physicalScalarRange M J N n exponent F Q R B)).map + (fun execution => physicalScalarPack M J N n exponent F Q R B + (rejectionArrayAccepted (physicalScalarRange M J N n exponent F Q R B) execution)) = + physicalCommonLaw M J N n exponent F Q R B := by + change (rejectionArrayLaw (physicalScalarRange M J N n exponent F Q R B)).map + (physicalScalarPack M J N n exponent F Q R B ∘ + rejectionArrayAccepted (physicalScalarRange M J N n exponent F Q R B)) = _ + rw [← Measure.map_map (measurable_of_finite _) (by fun_prop)] + rw [rejectionArrayLaw_accepted] + exact physicalScalarPack_law M J N n exponent F Q R B + +end Laws + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedMedian.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedMedian.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ba29c2aaef2e1fe354927340735bbc5488da388 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedMedian.lean @@ -0,0 +1,160 @@ +import OAI.Combinatorics.EditApproximation.Probability.Median +import OAI.Combinatorics.EditApproximation.Geometry.Accuracy +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementInvariants + +namespace OAI + +/-! The seed update uses the actual integer ceilings, upper median and clamp. +Copies share an entire table within each run and are independent between runs. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +def finiteMedianSeed {Ω : Type*} (N copies : ℕ) (output : Ω → ℕ) (draws : Fin copies → Ω) : ℕ := + min N (upperMedian (List.ofFn fun i => output (draws i))) + +theorem ofFn_countP_filter {β : Type*} {copies : ℕ} (output : Fin copies → β) (p : β → Bool) : + (List.ofFn output).countP p = (univ.filter fun i => p (output i)).card := by + rw [List.ofFn_eq_map, List.countP_map] + simpa only [List.toFinset_finRange, Bool.decide_eq_true, Function.comp_def] using + ((List.nodup_finRange copies).card_eq_countP (P := fun i => p (output i))).symm + +theorem finiteMedianSeed_lower {Ω : Type*} (N copies c : ℕ) (hcopies : 0 < copies) + (hcN : c ≤ N) (output : Ω → ℕ) (hlower : ∀ ω, c ≤ output ω) (draws : Fin copies → Ω) : + c ≤ finiteMedianSeed N copies output draws := by + apply le_min hcN + apply upperMedian_lower _ (by simpa using hcopies.ne') + intro v hv + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp hv + exact hlower (draws i) + +theorem finiteMedianSeed_upper {Ω : Type*} (N copies upper : ℕ) (hcopies : 0 < copies) + (output : Ω → ℕ) (draws : Fin copies → Ω) + (hfew : (univ.filter fun i => upper < output (draws i)).card < copies - copies / 2) : + finiteMedianSeed N copies output draws ≤ upper := by + apply (min_le_right _ _).trans + apply upperMedian_upper _ (by simpa using hcopies.ne') + rw [List.length_ofFn, ofFn_countP_filter] + simp only [decide_eq_true_eq] + have hsum := card_filter_add_card_filter_not (s := (univ : Finset (Fin copies))) + (p := fun i => upper < output (draws i)) + simp only [card_univ, Fintype.card_fin, not_lt] at hsum + omega + +theorem finiteMedianSeed_failure_bound {Ω : Type*} [Fintype Ω] + [MeasurableSpace Ω] [MeasurableSingletonClass Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (N copies upper : ℕ) (hcopies : 0 < copies) + (output : Ω → ℕ) (q : ℝ) (hq : 0 ≤ q) + (hsingle : μ.real {ω | upper < output ω} ≤ q) : + (Measure.pi fun _ : Fin copies => μ).real + {draws | upper < finiteMedianSeed N copies output draws} ≤ + (2 : ℝ) ^ copies * q ^ (copies - copies / 2) := by + classical + let bad : Fin copies → Set (Fin copies → Ω) := fun i => {draws | upper < output (draws i)} + have hindepFun : iIndepFun (fun i (draws : Fin copies → Ω) => draws i) + (Measure.pi fun _ : Fin copies => μ) := + iIndepFun_pi (μ := fun _ : Fin copies => μ) (X := fun _ => id) (fun _ => aemeasurable_id) + have hindep : iIndepSet bad (Measure.pi fun _ : Fin copies => μ) := by + apply (iIndepSet_iff_meas_biInter (fun _ => (Set.toFinite _).measurableSet)).2 + intro s + exact hindepFun.meas_biInter (fun i _ => + ⟨{ω | upper < output ω}, (Set.toFinite _).measurableSet, rfl⟩) + have hbad (i : Fin copies) : (Measure.pi fun _ : Fin copies => μ).real (bad i) ≤ q := by + have hmap := measurePreserving_eval (fun _ : Fin copies => μ) i + have heq := hmap.measure_preimage ((Set.toFinite {ω | upper < output ω}).measurableSet.nullMeasurableSet) + have heq' : (Measure.pi fun _ : Fin copies => μ) (bad i) = μ {ω | upper < output ω} := by + simpa only [bad, Function.eval, Set.preimage, Set.mem_ofPred_eq] using heq + unfold Measure.real + rw [heq'] + exact hsingle + have htail := independent_failure_count_binary_bound (Measure.pi fun _ : Fin copies => μ) + bad hindep (copies - copies / 2) q hq hbad + apply (measureReal_mono (μ := Measure.pi fun _ : Fin copies => μ) ?_ (measure_ne_top _ _)).trans + (by simpa only [Fintype.card_fin] using htail) + intro draws hfail + by_contra hfew + have hfew' : ¬ copies - copies / 2 ≤ (univ.filter fun i => upper < output (draws i)).card := by + simpa only [bad, Set.mem_ofPred_eq] using hfew + have hupper := finiteMedianSeed_upper N copies upper hcopies output draws (lt_of_not_ge hfew') + exact (not_lt_of_ge hupper) hfail + +/-- The integer multiplication and ceiling used before the median preserve +both the deterministic lower approximation and a successful copy's upper bound. -/ +theorem scaledCopy_rounding (c a : ℕ) (ha : 0 < a) (value : ℚ) + (hlower : (c : ℚ) / a ≤ value) (hupper : value ≤ 2 * c) : + c ≤ ⌈(a : ℚ) * value⌉₊ ∧ ⌈(a : ℚ) * value⌉₊ ≤ 2 * a * c := by + have haQ : (0 : ℚ) < a := Nat.cast_pos.2 ha + constructor + · have h := (div_le_iff₀ haQ).1 hlower + have hceil := Nat.le_ceil ((a : ℚ) * value) + have hmul : (c : ℚ) ≤ a * value := by simpa only [mul_comm] using h + exact_mod_cast hmul.trans hceil + · apply Nat.ceil_le.mpr + have h := mul_le_mul_of_nonneg_left hupper haQ.le + push_cast + nlinarith only [h] + +theorem finite_positive_excess_tail {Ω : Type*} [Fintype Ω] + [MeasurableSpace Ω] [MeasurableSingletonClass Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (value : Ω → ℚ) (c : ℕ) (hc : 0 < c) + (ell : ℝ) (_hell : 0 < ell) + (hexcess : (∫ ω, max ((value ω : ℝ) - c) 0 ∂μ) ≤ (1 / ell) * c) : + μ.real {ω | 2 * (c : ℚ) < value ω} ≤ 1 / ell := by + let excess := fun ω => max ((value ω : ℝ) - c) 0 + have hmarkov := mul_meas_ge_le_integral_of_nonneg + (ae_of_all μ (fun ω => le_max_right ((value ω : ℝ) - c) 0)) + (show Integrable excess μ from .of_finite) (c : ℝ) + have hcr : (0 : ℝ) < c := Nat.cast_pos.2 hc + have htail : μ.real {ω | (c : ℝ) ≤ excess ω} ≤ 1 / ell := by + apply (mul_le_mul_iff_left₀ hcr).mp + simpa only [mul_comm] using hmarkov.trans hexcess + apply (measureReal_mono (μ := μ) ?_).trans htail + intro ω hω + have hR : 2 * (c : ℝ) < value ω := by exact_mod_cast hω + exact (by dsimp only [excess]; exact (by linarith : (c : ℝ) ≤ (value ω : ℝ) - c).trans (le_max_left _ _)) + +noncomputable def physicalScaledCopy {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) (a S : ℕ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (state : PhysicalEntry M J target.length) : ℕ := + ⌈(a : ℚ) * physicalRefinement source target U N P F A T delta choices state.1 S state.2⌉₊ + +theorem physicalScaledCopy_lower {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) (a S : ℕ) + (ha : (a : ℚ) = refinementFactor A F) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (state : PhysicalEntry M J target.length) : + stateEditCost (physicalSource source state.1) target state.2 ≤ + physicalScaledCopy source target U N P F A T delta a S choices state := by + have haQ : (0 : ℚ) < a := by + rw [ha] + exact lt_of_lt_of_le zero_lt_one (refinementFactor_spec A F (by omega)).1 + have hinv := (physicalRefinement_stage_bounds source target hM U N P F A hsize hP hF hA hseed + T hT delta choices state.1 S state.2).1 + have hlower : (stateEditCost (physicalSource source state.1) target state.2 : ℝ) / + (a : ℝ) ≤ (physicalRefinement source target U N P F A T delta choices state.1 S state.2 : ℝ) := by + have h := (le_max_left _ _).trans hinv + simpa only [physicalLower, ← ha, Rat.cast_natCast] using h + have hlowerQ : (stateEditCost (physicalSource source state.1) target state.2 : ℚ) / a ≤ + physicalRefinement source target U N P F A T delta choices state.1 S state.2 := by + apply (Rat.cast_le (K := ℝ)).mp + simpa only [Rat.cast_div, Rat.cast_natCast] using hlower + have hm := (div_le_iff₀ haQ).1 hlowerQ + have hc := Nat.le_ceil ((a : ℚ) * physicalRefinement source target U N P F A T delta choices state.1 S state.2) + have hm' : (stateEditCost (physicalSource source state.1) target state.2 : ℚ) ≤ + a * physicalRefinement source target U N P F A T delta choices state.1 S state.2 := by + simpa only [mul_comm] using hm + have hscaled : (stateEditCost (physicalSource source state.1) target state.2 : ℚ) ≤ + (physicalScaledCopy source target U N P F A T delta a S choices state : ℚ) := hm'.trans hc + exact_mod_cast hscaled + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedPass.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedPass.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b57738f55b7d317327b5baa0233ee635c4d30c2 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedPass.lean @@ -0,0 +1,166 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSeedMedian +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalProgramStateAccuracy +import OAI.Combinatorics.EditApproximation.Geometry.SeedPassNumerics + +namespace OAI + +/-! A full-table median seed pass from independent refinement copies under finite Bernstein bounds. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +noncomputable def physicalMedianUpdate {α Ω : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) (a S copies : ℕ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (draws : Fin copies → Ω) + (state : PhysicalEntry M J target.length) : ℕ := + finiteMedianSeed N copies + (fun draw => physicalScaledCopy source target U N P F A T delta a S (choices draw) state) draws + +section Pass + +variable {α : Type*} [DecidableEq α] {M J R H : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N : ℕ) (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (U : PhysicalEntry M J target.length → ℕ) (P : ℕ) (hPeq : P = (integerParameters N).P) + (A : ℚ) (hA : 1 ≤ A) (hAupper : A ≤ (integerParameters N).initialFactor) + (hsize : source.length + target.length ≤ N) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T S : ℕ) (hTeq : T = (integerParameters N).T) (hSeq : S = (integerParameters N).S) + (hHeq : H = inputHeight N) + (bernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (a copies : ℕ) (ha : (a : ℚ) = refinementFactor A (inputSmallLog N)) (hcopies : 0 < copies) + +local notation "ell" => inputSmallLog N +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "tau" => RationalParameters.tau (rationalParameters ell) +local notation "thetaExponent" => (40 * smallLogExponent N : ℕ) +local notation "Draw" => PhysicalProgramDraw (R := R) source target U N P ell A T thetaExponent H (ell ^ 80) tau +local notation "choices" => physicalProgramDrawSelections source target U N P ell A T thetaExponent H (ell ^ 80) tau eta kappa +local notation "law" => physicalProgramDrawLaw (R := R) source target U N P ell A T thetaExponent H (ell ^ 80) tau +local notation "copyLaw" => Measure.pi (fun _ : Fin copies => law) +local notation "update" => physicalMedianUpdate source target U N P ell A T delta a S copies choices + +omit [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] in +include hN hell hPeq hA hsize hseed hTeq ha hcopies in + theorem physicalMedianUpdate_lower (draws : Fin copies → Draw) (state : PhysicalEntry M J target.length) : + stateEditCost (physicalSource source state.1) target state.2 ≤ update draws state := by + classical + have hbranch : 0 < M := Nat.pos_of_ne_zero (NeZero.ne M) + have hP := computed_program_grid_lower N P hN hPeq + have hF : 1 ≤ ell := Nat.one_le_two_pow + have hT : 0 < T := by rw [hTeq]; exact (computed_stage_positive_counts N hN hell).1 + exact finiteMedianSeed_lower N copies _ hcopies (physical_state_cost_le source target N hsize state) _ + (fun draw => physicalScaledCopy_lower source target hbranch U N P ell A hsize hP hF hA hseed + T hT delta a S ha (choices draw) state) draws + +include hN hell hMeq hJeq hPeq hA hAupper hsize hseed hTeq hSeq hHeq bernstein ha hcopies in + theorem physicalMedianUpdate_state_failure (state : PhysicalEntry M J target.length) : + (copyLaw).real {draws | 2 * a * stateEditCost (physicalSource source state.1) target state.2 < update draws state} ≤ + (2 : ℝ) ^ copies * (1 / (ell : ℝ)) ^ (copies - copies / 2) := by + classical + let c := stateEditCost (physicalSource source state.1) target state.2 + let value : Draw → ℚ := fun draw => physicalRefinement source target U N P ell A T delta (choices draw) state.1 S state.2 + let output : Draw → ℕ := fun draw => physicalScaledCopy source target U N P ell A T delta a S (choices draw) state + have hbranch : 0 < M := Nat.pos_of_ne_zero (NeZero.ne M) + have hP := computed_program_grid_lower N P hN hPeq + have hF : 1 ≤ ell := Nat.one_le_two_pow + have hT : 0 < T := by rw [hTeq]; exact (computed_stage_positive_counts N hN hell).1 + have haQ : (0 : ℚ) < a := by + rw [ha] + exact lt_of_lt_of_le zero_lt_one (refinementFactor_spec A ell (by omega)).1 + have hsingle : (law).real {draw | 2 * a * c < output draw} ≤ 1 / (ell : ℝ) := by + by_cases hzero : c = 0 + · have hout (draw : Draw) : output draw = 0 := by + have hz := physicalRefinement_zero_cost source target hbranch U N P ell A hsize hP hF hA hseed + T hT delta (choices draw) state.1 S state.2 hzero + simp only [output, physicalScaledCopy, hz, mul_zero, Nat.ceil_zero] + simp only [hzero, mul_zero, hout, lt_self_iff_false, Set.ofPred_false, measureReal_empty] + exact div_nonneg zero_le_one (Nat.cast_nonneg _) + · have hexcess := physicalProgram_expected_state_excess (R := R) source target N hN hell hMeq hJeq + U P hPeq A hA hAupper hsize hseed T S hTeq hSeq hHeq bernstein state.1 state.2 + have hraw := finite_positive_excess_tail law value c (Nat.pos_of_ne_zero hzero) + (ell : ℝ) (Nat.cast_pos.2 (Nat.two_pow_pos _)) hexcess + apply (measureReal_mono (μ := law) ?_ (measure_ne_top _ _)).trans hraw + intro draw hbad + by_contra hnot + have hvalue : value draw ≤ 2 * c := le_of_not_gt hnot + have hround : output draw ≤ 2 * a * c := by + apply Nat.ceil_le.mpr + have hm := mul_le_mul_of_nonneg_left hvalue haQ.le + push_cast + nlinarith only [hm] + exact (not_lt_of_ge hround) hbad + exact finiteMedianSeed_failure_bound law N copies (2 * a * c) hcopies output + (1 / (ell : ℝ)) (div_nonneg zero_le_one (Nat.cast_nonneg _)) hsingle + +include hN hell hMeq hJeq hPeq hA hAupper hsize hseed hTeq hSeq hHeq bernstein ha hcopies in + theorem physicalMedianUpdate_all_failure : + (copyLaw).real {draws | ¬ ∀ state : PhysicalEntry M J target.length, + stateEditCost (physicalSource source state.1) target state.2 ≤ update draws state ∧ + update draws state ≤ 4 * a * stateEditCost (physicalSource source state.1) target state.2} ≤ + Fintype.card (PhysicalEntry M J target.length) * + ((2 : ℝ) ^ copies * (1 / (ell : ℝ)) ^ (copies - copies / 2)) := by + classical + let bad := fun state : PhysicalEntry M J target.length => + {draws : Fin copies → Draw | 2 * a * stateEditCost (physicalSource source state.1) target state.2 < update draws state} + have hcover : {draws | ¬ ∀ state : PhysicalEntry M J target.length, + stateEditCost (physicalSource source state.1) target state.2 ≤ update draws state ∧ + update draws state ≤ 4 * a * stateEditCost (physicalSource source state.1) target state.2} ⊆ ⋃ state, bad state := by + intro draws hfail + obtain ⟨state, hstate⟩ := not_forall.mp hfail + apply Set.mem_iUnion.mpr + refine ⟨state, ?_⟩ + have hlower := physicalMedianUpdate_lower (R := R) source target N hN hell U P hPeq A hA + hsize hseed T S hTeq a copies ha hcopies draws state + have hu : 4 * a * stateEditCost (physicalSource source state.1) target state.2 < update draws state := by + exact lt_of_not_ge (fun h => hstate ⟨hlower, h⟩) + exact lt_of_le_of_lt (Nat.mul_le_mul_right _ (Nat.mul_le_mul_right a (by decide : 2 ≤ 4))) hu + apply (measureReal_mono (μ := copyLaw) hcover (measure_ne_top _ _)).trans + apply (measureReal_iUnion_fintype_le bad).trans + have hsum := sum_le_sum (fun state (_ : state ∈ (univ : Finset (PhysicalEntry M J target.length))) => + physicalMedianUpdate_state_failure (R := R) source target N hN hell hMeq hJeq U P hPeq A hA hAupper + hsize hseed T S hTeq hSeq hHeq bernstein a copies ha hcopies state) + simpa only [sum_const, card_univ, nsmul_eq_mul] using hsum + +include hN hell hMeq hJeq hPeq hA hAupper hsize hseed hTeq hSeq hHeq bernstein ha hcopies in + theorem physicalMedianUpdate_computed_failure (hcopiesEq : copies = H ^ 2) : + (copyLaw).real {draws | ¬ ∀ state : PhysicalEntry M J target.length, + stateEditCost (physicalSource source state.1) target state.2 ≤ update draws state ∧ + update draws state ≤ 4 * a * stateEditCost (physicalSource source state.1) target state.2} ≤ + Real.exp (10 * H - (H : ℝ) ^ 2) := by + classical + have hsmall : 256 ≤ (2 : ℕ) ^ 1000 := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 8 ≤ 1000) + norm_num only [show (2 : ℕ) ^ 8 = 256 by norm_num] at h + exact h + have hcut : 200 ≤ ell := by omega + have hcard : Fintype.card (PhysicalEntry M J target.length) ≤ labeledStateCount M source.length target.length := by + rw [hJeq] + exact labeledEntry_card_le M source.length target.length + have hcardR : (Fintype.card (PhysicalEntry M J target.length) : ℝ) ≤ Real.exp (10 * H) := by + apply (Nat.cast_le.mpr hcard).trans + rw [hMeq, hHeq] + exact computed_labeledStateCount_exp N source.length target.length hN (by omega) (by omega) hcut + have htail := seed_copy_binary_tail copies ell (by omega : 64 ≤ ell) + have hbound := physicalMedianUpdate_all_failure (R := R) source target N hN hell hMeq hJeq U P hPeq + A hA hAupper hsize hseed T S hTeq hSeq hHeq bernstein a copies ha hcopies + apply hbound.trans + apply (mul_le_mul_of_nonneg_left htail (Nat.cast_nonneg _)).trans + rw [hcopiesEq, Nat.cast_pow] + exact seed_state_union_numeric (H : ℝ) (Fintype.card (PhysicalEntry M J target.length) : ℝ) hcardR + +end Pass + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedSchedule.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..02f13ba36fb61d5a67ea4010a75e67e72a573c53 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedSchedule.lean @@ -0,0 +1,193 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSeedTables +import OAI.Combinatorics.EditApproximation.Geometry.SeedFactorSchedule +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The actual finite adaptive sequence of median seed passes. Every chosen +incoming table uses its own fresh product of full-table copy streams. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + + + + + +theorem scheduledSeedMultiplier_spec (N pass : ℕ) (hf : 3 ≤ smallLogExponent N) + (hpass : pass < computedSeedPassCount N) : + (scheduledSeedMultiplier N pass : ℚ) = refinementFactor (scheduledSeedFactor N pass) (inputSmallLog N) := by + unfold scheduledSeedMultiplier scheduledSeedFactor + simpa only [inputSmallLog] using + (dyadicSeedFactor_integer (smallLogExponent N) (computedSeedInitialExponent N) pass hf hpass).symm + +theorem scheduledSeedFactor_succ (N pass : ℕ) (hf : 3 ≤ smallLogExponent N) + (hpass : pass < computedSeedPassCount N) : + scheduledSeedFactor N (pass + 1) = 4 * (scheduledSeedMultiplier N pass : ℚ) := by + have hactive := dyadicSeedExponent_active (smallLogExponent N) (computedSeedInitialExponent N) pass hf hpass + have heq : dyadicSeedExponent (smallLogExponent N) (computedSeedInitialExponent N) (pass + 1) = + (dyadicSeedExponent (smallLogExponent N) (computedSeedInitialExponent N) pass - smallLogExponent N) + 2 := by + rw [dyadicSeedExponent_succ] + omega + unfold scheduledSeedFactor scheduledSeedMultiplier + rw [heq, pow_add] + push_cast + norm_num + ring + +theorem scheduledSeedFactor_zero (N : ℕ) : + scheduledSeedFactor N 0 = ((integerParameters N).initialFactor : ℚ) := by + simpa only [scheduledSeedFactor, dyadicSeedExponent, zero_mul, Nat.sub_zero] using computedSeed_initial_factor N + +theorem scheduledSeedFactor_terminal (N : ℕ) (hf : 3 ≤ smallLogExponent N) : + scheduledSeedFactor N (computedSeedPassCount N) ≤ inputSmallLog N := by + exact dyadicSeedFactor_terminal (smallLogExponent N) (computedSeedInitialExponent N) hf + +theorem scheduledSeedFactor_terminal_refinement (N : ℕ) (hf : 3 ≤ smallLogExponent N) : + refinementFactor (scheduledSeedFactor N (computedSeedPassCount N)) (inputSmallLog N) = 1 := by + exact dyadicSeedFactor_terminal_refinement (smallLogExponent N) (computedSeedInitialExponent N) hf + +section Program + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} + [NeZero M] [NeZero R] [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)] + (source target : List α) (N P T S H : ℕ) + +local notation "Seed" => ClampedPhysicalSeed M J target.length N +local notation "ell" => inputSmallLog N +local notation "thetaExponent" => (40 * smallLogExponent N : ℕ) +local notation "eta" => RationalParameters.eta (rationalParameters ell) +local notation "kappa" => RationalParameters.kappa (rationalParameters ell) +local notation "delta" => RationalParameters.delta (rationalParameters ell) +local notation "tau" => RationalParameters.tau (rationalParameters ell) + +abbrev ScheduledSeedDraw (pass : ℕ) (seed : Seed) := Fin (H ^ 2) → + PhysicalProgramDraw (R := R) source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) + T thetaExponent H (ell ^ 80) tau + +noncomputable instance scheduledSeedDrawFintype (pass : ℕ) (seed : Seed) : + Fintype (ScheduledSeedDraw (R := R) source target N P T H pass seed) := by + classical + exact Fintype.ofFinite _ + +noncomputable def scheduledSeedDrawLaw (pass : ℕ) (seed : Seed) : + Measure (ScheduledSeedDraw (R := R) source target N P T H pass seed) := + Measure.pi fun _ : Fin (H ^ 2) => physicalProgramDrawLaw (R := R) + source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) T thetaExponent H (ell ^ 80) tau + +instance scheduledSeedDrawLaw_probability (pass : ℕ) (seed : Seed) : + IsProbabilityMeasure (scheduledSeedDrawLaw (R := R) source target N P T H pass seed) := by + unfold scheduledSeedDrawLaw + infer_instance + +noncomputable def scheduledSeedNext (pass : ℕ) (seed : Seed) + (draw : ScheduledSeedDraw (R := R) source target N P T H pass seed) : Seed := + physicalMedianUpdateTable source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) T delta + (scheduledSeedMultiplier N pass) S (H ^ 2) + (physicalProgramDrawSelections source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) + T thetaExponent H (ell ^ 80) tau eta kappa) draw + +noncomputable def scheduledSeedLaw (incoming : Measure Seed) (passes : ℕ) : Measure Seed := by + classical + exact adaptiveSeedSequence (scheduledSeedDrawLaw (R := R) source target N P T H) incoming + (scheduledSeedNext (R := R) source target N P T S H) passes + +instance scheduledSeedLaw_probability (incoming : Measure Seed) [IsProbabilityMeasure incoming] (passes : ℕ) : + IsProbabilityMeasure (scheduledSeedLaw (R := R) source target N P T S H incoming passes) := by + unfold scheduledSeedLaw + infer_instance + +variable (hN : 0 < N) (hell : 2 ^ 1000 ≤ inputSmallLog N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (hPeq : P = (integerParameters N).P) (hTeq : T = (integerParameters N).T) + (hSeq : S = (integerParameters N).S) (hHeq : H = inputHeight N) + (hsize : source.length + target.length ≤ N) + (bernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b (inputSmallLog N)).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (inputSmallLog N ^ 80) b (groupDyadicScaleAt M b (inputSmallLog N) h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + +include hN hell hMeq hJeq hPeq hTeq hSeq hHeq hsize bernstein in + theorem scheduledSeedNext_failure (pass : ℕ) (hpass : pass < computedSeedPassCount N) + (seed : Seed) (hseed : physicalSeedGood source target (scheduledSeedFactor N pass) seed) : + (scheduledSeedDrawLaw (R := R) source target N P T H pass seed).real + {draw | ¬ physicalSeedGood source target (scheduledSeedFactor N (pass + 1)) + (scheduledSeedNext (R := R) source target N P T S H pass seed draw)} ≤ + Real.exp (10 * H - (H : ℝ) ^ 2) := by + classical + have hf : 3 ≤ smallLogExponent N := by + have h := (Nat.pow_le_pow_iff_right (by decide : 1 < (2 : ℕ))).mp hell + omega + have hA : (1 : ℚ) ≤ scheduledSeedFactor N pass := by + unfold scheduledSeedFactor + exact one_le_pow₀ (by norm_num) + have hAupper : scheduledSeedFactor N pass ≤ ((integerParameters N).initialFactor : ℚ) := by + unfold scheduledSeedFactor + rw [← computedSeed_initial_factor] + exact dyadicSeedFactor_bound _ _ _ + have hcopies : 0 < H ^ 2 := by rw [hHeq]; exact pow_pos (Nat.two_pow_pos _) 2 + have h := physicalMedianUpdate_computed_failure (R := R) source target N hN hell hMeq hJeq + (clampedSeedNat seed) P hPeq (scheduledSeedFactor N pass) hA hAupper hsize hseed T S hTeq hSeq hHeq + bernstein (scheduledSeedMultiplier N pass) (H ^ 2) (scheduledSeedMultiplier_spec N pass hf hpass) hcopies rfl + have hevents : {draw | ¬ physicalSeedGood source target (scheduledSeedFactor N (pass + 1)) + (scheduledSeedNext (R := R) source target N P T S H pass seed draw)} = + {draw : ScheduledSeedDraw (R := R) source target N P T H pass seed | ¬ ∀ state : PhysicalEntry M J target.length, + stateEditCost (physicalSource source state.1) target state.2 ≤ + physicalMedianUpdate source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) + T delta (scheduledSeedMultiplier N pass) S (H ^ 2) + (physicalProgramDrawSelections source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) + T thetaExponent H (ell ^ 80) tau eta kappa) draw state ∧ + physicalMedianUpdate source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) + T delta (scheduledSeedMultiplier N pass) S (H ^ 2) + (physicalProgramDrawSelections source target (clampedSeedNat seed) N P ell (scheduledSeedFactor N pass) + T thetaExponent H (ell ^ 80) tau eta kappa) draw state ≤ + 4 * scheduledSeedMultiplier N pass * stateEditCost (physicalSource source state.1) target state.2} := by + ext draw + rw [scheduledSeedFactor_succ N pass hf hpass] + exact not_congr (physicalMedianUpdateTable_good_iff _ _ _ _ _ _ _ _ _ _ _ _ _ draw) + rw [hevents] + exact h + +include hN hell hMeq hJeq hPeq hTeq hSeq hHeq hsize bernstein in + theorem scheduledSeedLaw_failure (incoming : Measure Seed) [IsProbabilityMeasure incoming] : + (scheduledSeedLaw (R := R) source target N P T S H incoming (computedSeedPassCount N)).real + {seed | ¬ physicalSeedGood source target (scheduledSeedFactor N (computedSeedPassCount N)) seed} ≤ + incoming.real {seed | ¬ physicalSeedGood source target (scheduledSeedFactor N 0) seed} + + computedSeedPassCount N * Real.exp (10 * H - (H : ℝ) ^ 2) := by + classical + have h := adaptiveSeedSequence_failure + (scheduledSeedDrawLaw (R := R) source target N P T H) incoming + (scheduledSeedNext (R := R) source target N P T S H) + (fun pass => physicalSeedGood source target (scheduledSeedFactor N pass)) + (fun _ => Real.exp (10 * H - (H : ℝ) ^ 2)) (fun _ => (Real.exp_pos _).le) (computedSeedPassCount N) + (fun pass hp seed hg => scheduledSeedNext_failure source target N P T S H hN hell hMeq hJeq + hPeq hTeq hSeq hHeq hsize bernstein pass hp seed hg) + simpa only [scheduledSeedLaw, Finset.sum_const, Finset.card_range, nsmul_eq_mul] using h + +include hN hell hMeq hJeq hPeq hTeq hSeq hHeq hsize bernstein in + theorem scheduledSeedLaw_failure_lt (incoming : Measure Seed) [IsProbabilityMeasure incoming] + (hinitial : incoming.real {seed | ¬ physicalSeedGood source target + ((integerParameters N).initialFactor : ℚ) seed} ≤ 1 / 100) : + (scheduledSeedLaw (R := R) source target N P T S H incoming (computedSeedPassCount N)).real + {seed | ¬ physicalSeedGood source target (scheduledSeedFactor N (computedSeedPassCount N)) seed} < 1 / 10 := by + classical + have hbound := scheduledSeedLaw_failure (R := R) source target N P T S H hN hell hMeq hJeq hPeq + hTeq hSeq hHeq hsize bernstein incoming + rw [scheduledSeedFactor_zero] at hbound + have hsmall : 256 ≤ (2 : ℕ) ^ 1000 := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (by decide : 8 ≤ 1000) + norm_num only [show (2 : ℕ) ^ 8 = 256 by norm_num] at h + exact h + have hcut : 200 ≤ ell := by omega + apply (hbound.trans (add_le_add hinitial le_rfl)).trans_lt + rw [hHeq] + exact computed_seed_total_failure N (computedSeedPassCount N) hN hcut + (computedSeedPassCount_le_height N hN hell) + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedTables.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..dad38a0cf78de2a787e9977967cb0c202466b9ee --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSeedTables.lean @@ -0,0 +1,63 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSeedPass +import OAI.Combinatorics.EditApproximation.Probability.AdaptiveSeedLaw +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Finite clamped seed tables and the exact table returned by a median pass. -/ + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory + + + + + +def physicalSeedGood {α : Type*} {M J N : ℕ} (source target : List α) (A : ℚ) + (seed : ClampedPhysicalSeed M J target.length N) : Prop := + ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ clampedSeedNat seed state ∧ + (clampedSeedNat seed state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2 + +noncomputable def physicalMedianUpdateTable {α Ω : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) (a S copies : ℕ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (draws : Fin copies → Ω) : + ClampedPhysicalSeed M J target.length N := fun state => + ⟨physicalMedianUpdate source target U N P F A T delta a S copies choices draws state, + Nat.lt_succ_of_le (min_le_left _ _)⟩ + +@[simp] theorem physicalMedianUpdateTable_value {α Ω : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) (a S copies : ℕ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (draws : Fin copies → Ω) + (state : PhysicalEntry M J target.length) : + clampedSeedNat (physicalMedianUpdateTable source target U N P F A T delta a S copies choices draws) state = + physicalMedianUpdate source target U N P F A T delta a S copies choices draws state := rfl + +theorem physicalMedianUpdateTable_good_iff {α Ω : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T : ℕ) (delta : ℚ) (a S copies : ℕ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (draws : Fin copies → Ω) : + physicalSeedGood source target (4 * a : ℚ) + (physicalMedianUpdateTable source target U N P F A T delta a S copies choices draws) ↔ + ∀ state : PhysicalEntry M J target.length, + stateEditCost (physicalSource source state.1) target state.2 ≤ + physicalMedianUpdate source target U N P F A T delta a S copies choices draws state ∧ + physicalMedianUpdate source target U N P F A T delta a S copies choices draws state ≤ + 4 * a * stateEditCost (physicalSource source state.1) target state.2 := by + unfold physicalSeedGood + simp only [physicalMedianUpdateTable_value] + constructor + · intro h state + exact ⟨(h state).1, by exact_mod_cast (h state).2⟩ + · intro h state + exact ⟨(h state).1, by exact_mod_cast (h state).2⟩ + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSelectionProgram.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSelectionProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..55ca39f0a99578bc7a1d22c885199259dc8dd5e3 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSelectionProgram.lean @@ -0,0 +1,364 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalNodeRegret +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! +# Finite online and whole-cell candidate programs + +Physical selections use the representative and guarded band lists. Each +band has its own finite optimizer stream; every whole cell has shared +per-scale child streams. These streams define coherent finite tables. +-/ + +namespace EditApproximation + +open Finset + + + +section Program + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T thetaExponent H Q : ℕ) (tau η κ : ℚ) + +local notation "representatives" => stageRepresentatives source target U N P F A +local notation "theta" => (2 : ℚ) ^ (-(thetaExponent : ℤ)) + +def physicalProgramBandG (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) : ℕ := + let br := (representatives node.1).get representative + H + (bandCoordinates (physicalBandActions source target U N P F A T node.1 node.2 + br.1 thetaExponent tau br.2).toFinset).card + 2 + +def physicalProgramBandK (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) : ℕ := + (physicalProgramBandG source target U N P F A T thetaExponent H tau node representative) ^ 80 + +theorem physicalProgramBandG_spec (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) (b : ℕ) + (member : UnskippedBand source target (physicalSourceInterval source.length node.1) + b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2)) + (hget : (representatives node.1).get representative = (b, member.center)) : + physicalProgramBandG source target U N P F A T thetaExponent H tau node representative = + H + (bandCoordinates member.actions.toFinset).card + 2 := by + simp only [physicalProgramBandG, hget, physicalBandActions, UnskippedBand.actions] + + +theorem physicalProgramBandG_ge_two (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) : + 2 ≤ physicalProgramBandG source target U N P F A T thetaExponent H tau node representative := by + dsimp only [physicalProgramBandG] + omega + +theorem physicalProgramBandK_positive (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) : + 0 < physicalProgramBandK source target U N P F A T thetaExponent H tau node representative := by + exact pow_pos (lt_of_lt_of_le (by norm_num : 0 < 2) + (physicalProgramBandG_ge_two source target U N P F A T thetaExponent H tau node representative)) 80 + + +def physicalProgramCells (node : PhysicalNode M J) (b : ℕ) : List (ℕ × ℕ) := + (((representatives node).filter fun br => decide (br.1 = b)).map + fun br => targetCell (theta * b) br.2).eraseDups + +def physicalBandOnlineCandidate (node : PhysicalInternalNode M J) + (br : ℕ × TargetInterval target.length) (children : PhysicalChildTables M target.length) + (t G K : ℕ) (integer : Fin (optimizerTriangularMass K)) : + Option (PhysicalRationalAction M target.length) := + let band := physicalBandActions source target U N P F A T node.1 node.2 br.1 thetaExponent tau br.2 + if hband : band = [] then none else + match testUnskippedBand source target (physicalSourceInterval source.length node.1) + br.1 P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2) br.2 with + | none => none + | some _ => some (sharedBandRationalAction br.2 + (finiteOptimizerActionDraw band hband + (physicalBandEnvelope source target U N P F A T node.1 node.2 br.1 thetaExponent tau br.2) + (rationalOnlineLinear η κ + (childGain (physicalBandEnvelope source target U N P F A T node.1 node.2 br.1 thetaExponent tau br.2) + (fun t coordinate => children coordinate.1 t coordinate.2)) + (childDecrement (physicalBandEnvelope source target U N P F A T node.1 node.2 br.1 thetaExponent tau br.2) + (fun t coordinate => children coordinate.1 t coordinate.2)) t) + G + K integer)) + +def physicalProgramOnlineCandidate (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) (children : PhysicalChildTables M target.length) + (t : ℕ) + (integer : Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative))) : + Option (PhysicalRationalAction M target.length) := + physicalBandOnlineCandidate source target U N P F A T thetaExponent tau η κ node + ((representatives node.1).get representative) children t + (physicalProgramBandG source target U N P F A T thetaExponent H tau node representative) + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative) integer + +abbrev PhysicalOnlineStreams (R : ℕ) := ∀ node : PhysicalInternalNode M J, + ∀ representative : Fin (representatives node.1).length, + Fin R → Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative)) + +abbrev PhysicalGroupStreams (R : ℕ) := ∀ node : PhysicalInternalNode M J, + ∀ scale : Fin (dyadicScales N).length, + ∀ _cell : Fin (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).length, + Fin R → ∀ h : Fin (groupDyadicScales M ((dyadicScales N).get scale) F).length, + Fin (groupSampleCount M Q ((dyadicScales N).get scale) + (groupDyadicScaleAt M ((dyadicScales N).get scale) F h)) → Fin M + +/-- The literal online query uses its one rounded center at each allowed +scale, with the scale window tested against the literal initial table. -/ +def physicalProgramOnlineGuard (node : PhysicalNode M J) (q : TargetInterval target.length) + (br : ℕ × TargetInterval target.length) : Prop := + br.2 = roundInterval (seedGridSpacing br.1 P) q ∧ + stageInitial source target U N P F A (node, q) / (16 * F) ≤ br.1 ∧ + (br.1 : ℚ) ≤ 8 * refinementFactor A F * stageInitial source target U N P F A (node, q) + +instance physicalProgramOnlineGuard_decidable (node : PhysicalNode M J) (q : TargetInterval target.length) + (br : ℕ × TargetInterval target.length) : + Decidable (physicalProgramOnlineGuard source target U N P F A node q br) := by + unfold physicalProgramOnlineGuard + infer_instance + +/-- The actual dyadic comparison center passes the query filter on every +good initial seed; no local scale premise is assumed. -/ +theorem physicalProgramOnlineGuard_comparison + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalNode M J) (q : TargetInterval target.length) + (hc : 0 < stateEditCost (physicalSource source node) target q) : + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + physicalProgramOnlineGuard source target U N P F A node q + (b, roundInterval (seedGridSpacing b P) q) := by + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let a := refinementFactor A F + let w := stageInitial source target U N P F A (node, q) + have hfactor := refinementFactor_spec A F (by omega : 0 < F) + have ha : (0 : ℚ) < a := lt_of_lt_of_le zero_lt_one hfactor.1 + have hFpos : (0 : ℚ) < F := Nat.cast_pos.2 (by omega : 0 < F) + have hbounds := physicalInitialTable_bounds source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed (node, q) + have hlower : (stateEditCost (physicalSource source node) target q : ℚ) / a ≤ w := + (le_max_left _ _).trans hbounds.1 + have hupper : w ≤ 2 * F * stateEditCost (physicalSource source node) target q := hbounds.2 + have hdyadic := cost_dyadicScale _ _ hc le_rfl + have hblo : (b : ℚ) ≤ stateEditCost (physicalSource source node) target q := by exact_mod_cast hdyadic.2.1 + have hchi : (stateEditCost (physicalSource source node) target q : ℚ) ≤ 2 * b := by exact_mod_cast hdyadic.2.2.le + have hw : 0 ≤ w := (div_nonneg (Nat.cast_nonneg _) ha.le).trans hlower + change _ ∧ w / (16 * F) ≤ b ∧ (b : ℚ) ≤ 8 * a * w + refine ⟨rfl, ?_, ?_⟩ + · apply (div_le_iff₀ (mul_pos (by norm_num : (0 : ℚ) < 16) hFpos)).2 + have hmul := mul_le_mul_of_nonneg_left hchi (show (0 : ℚ) ≤ 2 * F by positivity) + have hwb : w ≤ 4 * F * b := by nlinarith only [hupper, hmul] + have hFb : (0 : ℚ) ≤ F * b := mul_nonneg hFpos.le (Nat.cast_nonneg b) + nlinarith only [hwb, hFb] + · have hca : (stateEditCost (physicalSource source node) target q : ℚ) ≤ a * w := by + simpa only [mul_comm] using (div_le_iff₀ ha).mp hlower + have haw : (0 : ℚ) ≤ a * w := mul_nonneg ha.le hw + nlinarith only [hblo, hca, haw] + +def physicalProgramOnline {R : ℕ} [NeZero R] + (stream : PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R) + (node : PhysicalNode M J) (children : PhysicalChildTables M target.length) (t : ℕ) + (q : TargetInterval target.length) : List (PhysicalRationalAction M target.length) := + if hbelow : node.1.val < J then + ((List.finRange (representatives node).length).filter fun representative => decide + (physicalProgramOnlineGuard source target U N P F A node q ((representatives node).get representative))).filterMap fun representative => + physicalProgramOnlineCandidate source target U N P F A T thetaExponent H tau η κ + ⟨node, hbelow⟩ representative children (t - 1) + (stream ⟨node, hbelow⟩ representative (Fin.ofNat R (t - 1))) + else [] + +def physicalProgramGroups {R : ℕ} [NeZero R] + (stream : PhysicalGroupStreams source target U N P F A thetaExponent Q R) + (node : PhysicalNode M J) (children : PhysicalChildTables M target.length) (t : ℕ) : + List (PhysicalRationalAction M target.length) := + if hbelow : node.1.val < J then + (List.finRange (dyadicScales N).length).flatMap fun scale => + (List.finRange (physicalProgramCells source target U N P F A thetaExponent node + ((dyadicScales N).get scale)).length).filterMap fun cell => + chooseCellGroupAction source target (physicalSourceInterval source.length node) + ((dyadicScales N).get scale) P F thetaExponent Q tau (refinementFactor A F) + (fun q => stageInitial source target U N P F A (node, q)) + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (fun i q => children i t q) + ((physicalProgramCells source target U N P F A thetaExponent node + ((dyadicScales N).get scale)).get cell) + (stream ⟨node, hbelow⟩ scale cell (Fin.ofNat R (t - 1))) + else [] + +/-- Every produced online candidate is literally one of the parent wide actions. -/ +theorem physicalProgramOnlineCandidate_wide (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) (children : PhysicalChildTables M target.length) + (t : ℕ) + (integer : Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative))) + (action : PhysicalRationalAction M target.length) + (hselected : physicalProgramOnlineCandidate source target U N P F A T thetaExponent H tau η κ + node representative children t integer = some action) : + action ∈ rationalActualWideActions (physicalSourceInterval source.length node.1) + (representatives node.1) P := by + let br := (representatives node.1).get representative + have hrep : br ∈ representatives node.1 := List.get_mem _ _ + unfold physicalProgramOnlineCandidate physicalBandOnlineCandidate at hselected + dsimp only at hselected + split_ifs at hselected with hband + split at hselected + · cases hselected + · cases hselected + exact sharedBandRationalAction_wide source target (physicalSourceInterval source.length node.1) br.2 + (representatives node.1) br.1 P tau theta + (physicalBandChildMassTable source target U N P F A T node.1 node.2) hrep _ + (finiteOptimizerActionDraw_mem _ hband _ _ _ _ _) + +theorem physicalProgramOnline_wide {R : ℕ} [NeZero R] + (stream : PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R) + (node : PhysicalNode M J) (children : PhysicalChildTables M target.length) (t : ℕ) + (q : TargetInterval target.length) (action : PhysicalRationalAction M target.length) + (hselected : action ∈ physicalProgramOnline source target U N P F A T thetaExponent H tau η κ + stream node children t q) : + action ∈ rationalActualWideActions (physicalSourceInterval source.length node) + (representatives node) P := by + unfold physicalProgramOnline at hselected + split_ifs at hselected with hbelow + · obtain ⟨representative, _, hselected⟩ := List.mem_filterMap.mp hselected + exact physicalProgramOnlineCandidate_wide source target U N P F A T thetaExponent H tau η κ + ⟨node, hbelow⟩ representative children _ _ action hselected + · exact False.elim (List.not_mem_nil hselected) + +theorem physicalProgramGroups_wide {R : ℕ} [NeZero R] + (stream : PhysicalGroupStreams source target U N P F A thetaExponent Q R) + (node : PhysicalNode M J) (children : PhysicalChildTables M target.length) (t : ℕ) + (action : PhysicalRationalAction M target.length) + (hselected : action ∈ physicalProgramGroups source target U N P F A T thetaExponent Q tau + stream node children t) : + action ∈ rationalActualWideActions (physicalSourceInterval source.length node) + (representatives node) P := by + unfold physicalProgramGroups at hselected + split_ifs at hselected with hbelow + · obtain ⟨scale, _, hscale⟩ := List.mem_flatMap.mp hselected + obtain ⟨cell, _, hselected⟩ := List.mem_filterMap.mp hscale + exact chooseCellGroupAction_wide_mem source target (physicalSourceInterval source.length node) + N ((dyadicScales N).get scale) P F thetaExponent Q tau (refinementFactor A F) + (fun q => stageInitial source target U N P F A (node, q)) + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (fun i q => children i t q) _ _ (List.get_mem _ _) action hselected + · exact False.elim (List.not_mem_nil hselected) + +/-- The actual complete selection interface contains exactly the finite +online and shared whole-cell candidates produced by the streams. -/ +def physicalProgramSelections {R : ℕ} [NeZero R] + (online : PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R) + (groups : PhysicalGroupStreams source target U N P F A thetaExponent Q R) : + PhysicalSelections M J source.length target.length P representatives where + groups := physicalProgramGroups source target U N P F A T thetaExponent Q tau groups + online := physicalProgramOnline source target U N P F A T thetaExponent H tau η κ online + groups_mem := physicalProgramGroups_wide source target U N P F A T thetaExponent Q tau groups + online_mem := physicalProgramOnline_wide source target U N P F A T thetaExponent H tau η κ online + +/-- An accepted literal band is retained in its online representative slot. -/ +theorem physicalProgramOnlineCandidate_accepted (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) (b : ℕ) + (member : UnskippedBand source target (physicalSourceInterval source.length node.1) + b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2)) + (hget : (representatives node.1).get representative = (b, member.center)) + (children : PhysicalChildTables M target.length) (t : ℕ) + (integer : Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative))) : + physicalProgramOnlineCandidate source target U N P F A T thetaExponent H tau η κ + node representative children t integer = some (sharedBandRationalAction member.center + (finiteOptimizerActionDraw member.actions member.nonempty member.envelope + (rationalOnlineLinear η κ (childGain member.envelope + (fun t coordinate => children coordinate.1 t coordinate.2)) + (childDecrement member.envelope (fun t coordinate => children coordinate.1 t coordinate.2)) t) + (physicalProgramBandG source target U N P F A T thetaExponent H tau node representative) + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative) integer)) := by + unfold physicalProgramOnlineCandidate + rw [hget] + simp only [physicalBandOnlineCandidate, physicalBandActions, + testUnskippedBand_accept member, dite_eq_right member.nonempty] + rfl + +/-- Every eligible center contributes its whole cell to the actual cell loop. -/ +theorem physicalProgramCells_complete (node : PhysicalNode M J) (b : ℕ) + (r : TargetInterval target.length) (hrep : (b, r) ∈ representatives node) : + targetCell (theta * b) r ∈ physicalProgramCells source target U N P F A thetaExponent node b := by + apply List.mem_eraseDups.mpr + apply List.mem_map.mpr + refine ⟨(b, r), List.mem_filter.mpr ⟨hrep, by simp⟩, rfl⟩ + + +/-- The candidate list contains the sampled shared action at every accepted +representative slot, with the supplied child history and current integer. -/ +theorem physicalProgramOnline_contains_accepted {R : ℕ} [NeZero R] + (stream : PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R) + (node : PhysicalInternalNode M J) + (representative : Fin (representatives node.1).length) (b : ℕ) + (member : UnskippedBand source target (physicalSourceInterval source.length node.1) + b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2)) + (hget : (representatives node.1).get representative = (b, member.center)) + (children : PhysicalChildTables M target.length) (t : ℕ) (q : TargetInterval target.length) + (hquery : physicalProgramOnlineGuard source target U N P F A node.1 q (b, member.center)) : + sharedBandRationalAction member.center + (finiteOptimizerActionDraw member.actions member.nonempty member.envelope + (rationalOnlineLinear η κ (childGain member.envelope + (fun t coordinate => children coordinate.1 t coordinate.2)) + (childDecrement member.envelope (fun t coordinate => children coordinate.1 t coordinate.2)) t) + (physicalProgramBandG source target U N P F A T thetaExponent H tau node representative) + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative) + (stream node representative (Fin.ofNat R t))) ∈ + physicalProgramOnline source target U N P F A T thetaExponent H tau η κ + stream node.1 children (t + 1) q := by + rw [physicalProgramOnline, dite_eq_left node.2] + apply List.mem_filterMap.mpr + refine ⟨representative, List.mem_filter.mpr ⟨by simp, ?_⟩, ?_⟩ + · simpa only [hget, decide_eq_true_eq] using hquery + · simpa only [Nat.add_sub_cancel] using + physicalProgramOnlineCandidate_accepted source target U N P F A T thetaExponent H tau η κ + node representative b member hget children t (stream node representative (Fin.ofNat R t)) + +/-- Whole-cell sampling uses the same per-scale arrays for all its members; +the literal selected member is included in the parent candidate list. -/ +theorem physicalProgramGroups_contains_selected {R : ℕ} [NeZero R] + (stream : PhysicalGroupStreams source target U N P F A thetaExponent Q R) + (node : PhysicalInternalNode M J) (scale : Fin (dyadicScales N).length) + (cell : Fin (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).length) + (hnonempty : physicalNodeCellBands source target U N P F A T node.1 node.2 + ((dyadicScales N).get scale) thetaExponent tau + ((physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).get cell) ≠ []) + (children : PhysicalChildTables M target.length) (t : ℕ) : + (chooseUnskippedGroup Q (fun i q => children i (t + 1) q) + (physicalNodeCellBands source target U N P F A T node.1 node.2 + ((dyadicScales N).get scale) thetaExponent tau + ((physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).get cell)) hnonempty + (stream node scale cell (Fin.ofNat R t))).rationalAction ∈ + physicalProgramGroups source target U N P F A T thetaExponent Q tau stream node.1 children (t + 1) := by + rw [physicalProgramGroups, dite_eq_left node.2] + apply List.mem_flatMap.mpr + refine ⟨scale, by simp, List.mem_filterMap.mpr ⟨cell, by simp, ?_⟩⟩ + unfold physicalNodeCellBands at hnonempty + simp only [chooseCellGroupAction, Nat.add_sub_cancel, dite_eq_right hnonempty] + rfl + + +end Program + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSelectionResampling.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSelectionResampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..f56daf02f36279167257de2a537fca22c397a638 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSelectionResampling.lean @@ -0,0 +1,155 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSelectionProgram +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementLocality + +namespace OAI + +/-! Literal parent-coordinate replacement in the finite selection program. -/ + +namespace EditApproximation + +section Resampling + +variable {α : Type*} [DecidableEq α] {M J R : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (T thetaExponent H Q : ℕ) (tau η κ : ℚ) + +local notation "Online" => PhysicalOnlineStreams source target U N P F A T thetaExponent H tau R +local notation "Groups" => PhysicalGroupStreams source target U N P F A thetaExponent Q R +local notation "program" => physicalProgramSelections source target U N P F A T thetaExponent H Q tau η κ + +/-- Replacing exactly one parent's arrays leaves every other raw parent +selection function unchanged. The replacement arrays retain their literal +finite coordinate types. -/ +noncomputable def physicalProgramResampleOnline (stream : Online) (node : PhysicalInternalNode M J) + (fresh : ∀ representative : Fin (stageRepresentatives source target U N P F A node.1).length, + Fin R → Fin (optimizerTriangularMass + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative))) : Online := by + classical + exact Function.update stream node fresh + +noncomputable def physicalProgramResampleGroups (stream : Groups) (node : PhysicalInternalNode M J) + (fresh : ∀ scale : Fin (dyadicScales N).length, + ∀ _cell : Fin (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).length, + Fin R → ∀ h : Fin (groupDyadicScales M ((dyadicScales N).get scale) F).length, + Fin (groupSampleCount M Q ((dyadicScales N).get scale) + (groupDyadicScaleAt M ((dyadicScales N).get scale) F h)) → Fin M) : Groups := by + classical + exact Function.update stream node fresh + +theorem physicalProgramResampleOnline_same (stream : Online) (node : PhysicalInternalNode M J) + (fresh) : physicalProgramResampleOnline source target U N P F A T thetaExponent H tau stream node fresh node = fresh := by + classical + exact Function.update_self node fresh stream + +theorem physicalProgramResampleGroups_same (stream : Groups) (node : PhysicalInternalNode M J) + (fresh) : physicalProgramResampleGroups source target U N P F A thetaExponent Q stream node fresh node = fresh := by + classical + exact Function.update_self node fresh stream + +theorem physicalProgramResampleOnline_other (stream : Online) (node label : PhysicalInternalNode M J) + (fresh) (hne : label ≠ node) : + physicalProgramResampleOnline source target U N P F A T thetaExponent H tau stream node fresh label = stream label := by + classical + exact Function.update_of_ne hne _ _ + +theorem physicalProgramResampleGroups_other (stream : Groups) (node label : PhysicalInternalNode M J) + (fresh) (hne : label ≠ node) : + physicalProgramResampleGroups source target U N P F A thetaExponent Q stream node fresh label = stream label := by + classical + exact Function.update_of_ne hne _ _ + +variable [NeZero R] + +theorem physicalProgramSelections_online_congr_at (online first : Online) (groups : Groups) + (node : PhysicalNode M J) + (hlocal : ∀ hbelow : node.1.val < J, online ⟨node, hbelow⟩ = first ⟨node, hbelow⟩) : + (program online groups).online node = (program first groups).online node := by + funext children t q + dsimp only [physicalProgramSelections] + unfold physicalProgramOnline + split_ifs with hbelow + · rw [hlocal hbelow] + · rfl + +theorem physicalProgramSelections_groups_congr_at (online : Online) (groups first : Groups) + (node : PhysicalNode M J) + (hlocal : ∀ hbelow : node.1.val < J, groups ⟨node, hbelow⟩ = first ⟨node, hbelow⟩) : + (program online groups).groups node = (program online first).groups node := by + funext children t + dsimp only [physicalProgramSelections] + unfold physicalProgramGroups + split_ifs with hbelow + · rw [hlocal hbelow] + · rfl + +theorem physicalProgramResample_deeper (online : Online) (groups : Groups) + (node : PhysicalInternalNode M J) (freshOnline) (freshGroups) + (label : PhysicalNode M J) (hdeeper : node.1.1.val < label.1.val) : + let nextOnline := physicalProgramResampleOnline source target U N P F A T thetaExponent H tau online node freshOnline + let nextGroups := physicalProgramResampleGroups source target U N P F A thetaExponent Q groups node freshGroups + (program nextOnline nextGroups).groups label = (program online groups).groups label ∧ + (program nextOnline nextGroups).online label = (program online groups).online label := by + have hne (hbelow : label.1.val < J) : (⟨label, hbelow⟩ : PhysicalInternalNode M J) ≠ node := by + intro heq + have hdepth := congrArg (fun n : PhysicalInternalNode M J => n.1.1.val) heq + change label.1.val = node.1.1.val at hdepth + omega + dsimp only + constructor + · exact physicalProgramSelections_groups_congr_at source target U N P F A T thetaExponent H Q tau η κ + online (physicalProgramResampleGroups source target U N P F A thetaExponent Q groups node freshGroups) + groups label (fun hbelow => physicalProgramResampleGroups_other source target U N P F A thetaExponent Q + groups node ⟨label, hbelow⟩ freshGroups (hne hbelow)) + · exact physicalProgramSelections_online_congr_at source target U N P F A T thetaExponent H Q tau η κ + (physicalProgramResampleOnline source target U N P F A T thetaExponent H tau online node freshOnline) + online groups label (fun hbelow => physicalProgramResampleOnline_other source target U N P F A T thetaExponent H tau + online node ⟨label, hbelow⟩ freshOnline (hne hbelow)) + +/-- Literal query-filtered selections contain the accepted physical sampler +using the same complete child history. -/ +theorem physicalProgram_online_action_mem (online : Online) (groups : Groups) (delta : ℚ) + (node : PhysicalInternalNode M J) + (representative : Fin (stageRepresentatives source target U N P F A node.1).length) (b : ℕ) + (member : UnskippedBand source target (physicalSourceInterval source.length node.1) + b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node.1 node.2) + (physicalBandChildInitial source target U N P F A node.1 node.2)) + (hget : (stageRepresentatives source target U N P F A node.1).get representative = (b, member.center)) + (t : ℕ) (q : TargetInterval target.length) + (hquery : physicalProgramOnlineGuard source target U N P F A node.1 q (b, member.center)) : + sharedBandRationalAction member.center + (physicalBandOnlineDraw source target U N P F A T delta (program online groups) node.1 node.2 + b thetaExponent tau member.center member.nonempty η κ + (physicalProgramBandG source target U N P F A T thetaExponent H tau node representative) + (physicalProgramBandK source target U N P F A T thetaExponent H tau node representative) t + (online node representative (Fin.ofNat R t))) ∈ + physicalNodeOnline source target U N P F A T delta (program online groups) node.1 node.2 t q := by + exact physicalProgramOnline_contains_accepted source target U N P F A T thetaExponent H tau η κ + online node representative b member hget + (physicalNodeChildren source target U N P F A T delta (program online groups) node.1 node.2) t q hquery + +theorem physicalProgram_group_action_mem (online : Online) (groups : Groups) (delta : ℚ) + (node : PhysicalInternalNode M J) (scale : Fin (dyadicScales N).length) + (cell : Fin (physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).length) + (hnonempty : physicalNodeCellBands source target U N P F A T node.1 node.2 + ((dyadicScales N).get scale) thetaExponent tau + ((physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).get cell) ≠ []) (t : ℕ) : + (physicalNodeSelectedGroup source target U N P F A T delta (program online groups) node.1 node.2 + ((dyadicScales N).get scale) thetaExponent Q tau + ((physicalProgramCells source target U N P F A thetaExponent node.1 + ((dyadicScales N).get scale)).get cell) hnonempty t + (groups node scale cell (Fin.ofNat R t))).rationalAction ∈ + physicalNodeGroups source target U N P F A T delta (program online groups) node.1 node.2 t := by + exact physicalProgramGroups_contains_selected source target U N P F A T thetaExponent Q tau groups + node scale cell hnonempty + (physicalNodeChildren source target U N P F A T delta (program online groups) node.1 node.2) t + + +end Resampling + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSpatial.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSpatial.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f13db618641baa0ad462718348cba0f26b0d25b --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSpatial.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalInitial + +namespace OAI + +/-! Spatial regularity of the actual local initial table and physical warmup. -/ + +namespace EditApproximation + +theorem physicalInitialTable_spatial {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A a : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) (ha : 1 ≤ a) (hfactor : A ≤ a * F) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalNode M J) (q q' : TargetInterval target.length) : + physicalInitialTable source target U N P F A a (node, q) ≤ + physicalInitialTable source target U N P F A a (node, q') + + (32 * F : ℚ) * targetEndpointDistance q q' := by + unfold physicalInitialTable + dsimp only + split_ifs with hleaf + · rw [shortSourceCost_eq_edit _ _ hleaf, shortSourceCost_eq_edit _ _ hleaf] + have hcost : (stateEditCost (physicalSource source node) target q : ℚ) ≤ + stateEditCost (physicalSource source node) target q' + targetEndpointDistance q q' := by + exact_mod_cast stateEditCost_spatial (physicalSource source node) target q q' + have hFr : (1 : ℚ) ≤ F := by exact_mod_cast hF + have hcharge : (targetEndpointDistance q q' : ℚ) ≤ + (32 * F : ℚ) * targetEndpointDistance q q' := by + nlinarith only [hFr, Nat.cast_nonneg (α := ℚ) (targetEndpointDistance q q')] + change (stateEditCost (physicalSource source node) target q : ℚ) ≤ + stateEditCost (physicalSource source node) target q' + _ + linarith only [hcost, hcharge] + · rw [localInitialConeTable_eq_global _ _ _ N P F A a hP hF hA ha hfactor + (fun r => physical_state_cost_le source target N hsize (node, r)) (fun r => hseed (node, r)) q, + localInitialConeTable_eq_global _ _ _ N P F A a hP hF hA ha hfactor + (fun r => physical_state_cost_le source target N hsize (node, r)) (fun r => hseed (node, r)) q'] + exact globalInitialConeTable_spatial _ _ _ N P F A a q q' + +theorem physicalBellman_spatial {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (hL : 0 ≤ L) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (hinit : ∀ node q q', initial (node, q) ≤ initial (node, q') + L * targetEndpointDistance q q') + (value : PhysicalEntry M J target.length → ℝ) (node : PhysicalNode M J) + (q q' : TargetInterval target.length) : + physicalBellman source target P L initial representatives value (node, q) ≤ + physicalBellman source target P L initial representatives value (node, q') + + L * targetEndpointDistance q q' := by + classical + unfold physicalBellman + dsimp only + split_ifs with hbelow hleaf + · exact hinit node q q' + · exact finiteBellman_spatial (fun s => initial (node, s)) + (fun s t => targetEndpointDistance s t) L + (actualWideActions (physicalSourceInterval source.length node) (representatives node) P) + (fun is => value (physicalChild node hbelow is.1, is.2)) hL q q' (hinit node q q') + (fun center => by exact_mod_cast targetEndpointDistance_triangle q q' center) + · exact hinit node q q' + +theorem physicalWarmup_spatial {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (hL : 0 ≤ L) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (hinit : ∀ node q q', initial (node, q) ≤ initial (node, q') + L * targetEndpointDistance q q') + (t : ℕ) (node : PhysicalNode M J) (q q' : TargetInterval target.length) : + physicalWarmup source target P L initial representatives t (node, q) ≤ + physicalWarmup source target P L initial representatives t (node, q') + + L * targetEndpointDistance q q' := by + cases t with + | zero => exact hinit node q q' + | succ t => exact physicalBellman_spatial source target P L hL initial representatives hinit _ node q q' + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtree.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtree.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ab2a42c9c08c94ae943ef5910126342bbd4c3f9 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtree.lean @@ -0,0 +1,203 @@ +import OAI.Combinatorics.EditApproximation.Geometry.ComparisonLiftBounds + +namespace OAI + +/-! Comparison paths below an arbitrary physical node retain their original +global table labels. No refinement program or random law is changed. -/ + +namespace EditApproximation + +def treeLayerAppend {M k : ℕ} (initialPath : TreeLayer M k) : + (d : ℕ) → TreeLayer M d → TreeLayer M (k + d) + | 0, _ => initialPath + | d + 1, path => (treeLayerAppend initialPath d path.1, path.2) + +def physicalSubtreeNode {M J : ℕ} (root : PhysicalNode M J) (d : ℕ) (path : TreeLayer M d) + (hd : root.1.val + d ≤ J) : PhysicalNode M J := + ⟨⟨root.1.val + d, by omega⟩, treeLayerAppend root.2 d path⟩ + +@[simp] theorem physicalSubtreeNode_zero {M J : ℕ} (root : PhysicalNode M J) + (hd : root.1.val + 0 ≤ J) : physicalSubtreeNode root 0 PUnit.unit hd = root := by + cases root + rfl + +theorem physicalSubtreeNode_child {M J : ℕ} (root : PhysicalNode M J) + (d : ℕ) (path : TreeLayer M d) (hd : root.1.val + d < J) (i : Fin M) : + physicalChild (physicalSubtreeNode root d path hd.le) hd i = + physicalSubtreeNode root (d + 1) (path, i) (by omega) := rfl + +theorem comparisonSubtree_active_source {α : Type*} (source target : List α) + {M J : ℕ} (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) + (d : ℕ) (path : TreeLayer M d) (parent : TargetInterval source.length) (q : TargetInterval target.length) + (heq : comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path = some (parent, q)) + (hactive : ¬ comparisonStopped source target parent q) : + parent = sourceIntervalAt M source.length (root.1.val + d) (treeLayerAppend root.2 d path) := by + induction d generalizing parent q with + | zero => + exact (congrArg Prod.fst (Option.some.inj heq)).symm + | succ d ih => + obtain ⟨previousParent, previousQ, hprevious, hpreviousActive, hchild⟩ := + comparisonStep_active_parent source target hM P hP _ path.2 parent q heq hactive + rw [ih path.1 previousParent previousQ hprevious hpreviousActive] at hchild + exact hchild + +noncomputable def comparisonSubtreeLift {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) (table : PhysicalEntry M J target.length → ℝ) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) + (d : ℕ) (path : TreeLayer M d) : ℝ := by + classical + exact stoppedComparisonValue source target + (if hd : root.1.val + d ≤ J then fun q => table (physicalSubtreeNode root d path hd, q) else fun _ => 0) + (comparisonFrontier source target hM P hP (some (physicalSourceInterval source.length root, rootQ)) d path) + +theorem comparisonSubtreeLift_root {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) (table : PhysicalEntry M J target.length → ℝ) + (hterminal : ∀ node q, comparisonStopped source target (physicalSourceInterval source.length node) q → + table (node, q) = stateEditCost (physicalSource source node) target q) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) : + comparisonSubtreeLift source target hM P hP table root rootQ 0 PUnit.unit = table (root, rootQ) := by + classical + unfold comparisonSubtreeLift + rw [dite_eq_left (by omega : root.1.val + 0 ≤ J), physicalSubtreeNode_zero] + exact stoppedComparisonValue_physical source target table hterminal root rootQ + +theorem comparisonSubtreeLift_step_active {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) (table : PhysicalEntry M J target.length → ℝ) + (hterminal : ∀ node q, comparisonStopped source target (physicalSourceInterval source.length node) q → + table (node, q) = stateEditCost (physicalSource source node) target q) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) + (d : ℕ) (path : TreeLayer M d) (hd : root.1.val + d < J) (q : TargetInterval target.length) + (hfrontier : comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path = + some (physicalSourceInterval source.length (physicalSubtreeNode root d path hd.le), q)) + (hactive : ¬ comparisonStopped source target + (physicalSourceInterval source.length (physicalSubtreeNode root d path hd.le)) q) (i : Fin M) : + let node := physicalSubtreeNode root d path hd.le + let hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + dsimp only [node] + unfold comparisonStopped at hactive + omega + comparisonSubtreeLift source target hM P hP table root rootQ (d + 1) (path, i) = + table (physicalChild node hd i, + comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc i) := by + classical + dsimp only + unfold comparisonSubtreeLift + rw [dite_eq_left (by omega : root.1.val + (d + 1) ≤ J)] + change stoppedComparisonValue source target _ + (comparisonStep source target hM P hP + (comparisonFrontier source target hM P hP _ d path) i) = _ + rw [hfrontier] + simp only [comparisonStep, dite_eq_right hactive] + rw [← physicalSubtreeNode_child root d path hd i] + exact stoppedComparisonValue_physical source target table hterminal _ _ + +theorem comparisonSubtreeLift_terminal {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) (table : PhysicalEntry M J target.length → ℝ) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) (K : ℕ) + (hheight : root.1.val + K = J) (hcapacity : source.length ≤ M ^ J) (path : TreeLayer M K) : + comparisonSubtreeLift source target hM P hP table root rootQ K path = + comparisonStateCost source target (comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K path) := by + classical + unfold comparisonSubtreeLift + generalize heq : comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K path = state + cases state with + | none => rfl + | some state => + rcases state with ⟨parent, q⟩ + have hstop : comparisonStopped source target parent q := by + by_contra hactive + have hp := comparisonSubtree_active_source source target hM P hP root rootQ K path parent q heq hactive + have hcapacity' : source.length ≤ M ^ (root.1.val + K) := by rw [hheight]; exact hcapacity + have hwidth := sourceIntervalAt_leaf_width M source.length (root.1.val + K) hM hcapacity' + (treeLayerAppend root.2 K path) + rw [← hp] at hwidth + exact hactive (Or.inl hwidth) + simp only [stoppedComparisonValue, ite_eq_left hstop, comparisonStateCost] + +theorem comparisonSubtreeLift_mono {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) + (table table' : PhysicalEntry M J target.length → ℝ) (hle : table ≤ table') + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) (d : ℕ) (path : TreeLayer M d) : + comparisonSubtreeLift source target hM P hP table root rootQ d path ≤ + comparisonSubtreeLift source target hM P hP table' root rootQ d path := by + classical + unfold comparisonSubtreeLift stoppedComparisonValue + generalize comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path = state + cases state with + | none => exact le_rfl + | some state => + rcases state with ⟨parent, q⟩ + dsimp only + split_ifs + · exact le_rfl + · exact hle _ + · exact le_rfl + +theorem comparisonSubtreeLift_bounds {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) (F : ℝ) (hF : 1 ≤ F) + (table : PhysicalEntry M J target.length → ℝ) + (htable : ∀ state, 0 ≤ table state ∧ table state ≤ + 2 * F * stateEditCost (physicalSource source state.1) target state.2) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) (d : ℕ) (path : TreeLayer M d) : + 0 ≤ comparisonSubtreeLift source target hM P hP table root rootQ d path ∧ + comparisonSubtreeLift source target hM P hP table root rootQ d path ≤ + 2 * F * comparisonStateCost source target (comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path) := by + classical + unfold comparisonSubtreeLift + generalize heq : comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path = state + cases state with + | none => simp only [stoppedComparisonValue, comparisonStateCost, mul_zero, le_refl, and_self] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · simp only [stoppedComparisonValue, ite_eq_left hstop, comparisonStateCost] + refine ⟨Nat.cast_nonneg _, ?_⟩ + have h := mul_le_mul_of_nonneg_right (show (1 : ℝ) ≤ 2 * F by linarith) (Nat.cast_nonneg + (stateEditCost (substring source parent.lo parent.hi) target q)) + simpa only [one_mul] using h + · simp only [stoppedComparisonValue, ite_eq_right hstop, comparisonStateCost] + split_ifs with hd + · have hp := comparisonSubtree_active_source source target hM P hP root rootQ d path parent q heq hstop + have h := htable (physicalSubtreeNode root d path hd, q) + simpa only [physicalSource, physicalSourceInterval, physicalSubtreeNode, ← hp] using h + · exact ⟨le_rfl, mul_nonneg (by linarith) (Nat.cast_nonneg _)⟩ + +theorem comparisonSubtreeLift_gap {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) + (table : PhysicalEntry M J target.length → ℝ) + (htable : ∀ state, |stateLengthGap (physicalSource source state.1) target state.2| ≤ table state) + (root : PhysicalNode M J) (rootQ : TargetInterval target.length) + (d : ℕ) (hd : root.1.val + d ≤ J) (path : TreeLayer M d) : + |comparisonStateGap source target (comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path)| ≤ + comparisonSubtreeLift source target hM P hP table root rootQ d path := by + classical + unfold comparisonSubtreeLift + rw [dite_eq_left hd] + generalize heq : comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path = state + cases state with + | none => simp only [comparisonStateGap, stoppedComparisonValue, abs_zero, le_refl] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · simp only [stoppedComparisonValue, ite_eq_left hstop, comparisonStateGap] + exact stateEditCost_length_lower (substring source parent.lo parent.hi) target q + · simp only [stoppedComparisonValue, ite_eq_right hstop, comparisonStateGap] + have hp := comparisonSubtree_active_source source target hM P hP root rootQ d path parent q heq hstop + have h := htable (physicalSubtreeNode root d path hd, q) + simpa only [physicalSource, physicalSourceInterval, physicalSubtreeNode, ← hp] using h + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeBad.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeBad.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9b0be85f904047c1ff1c97614a4bf6f4575a7ee --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeBad.lean @@ -0,0 +1,62 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeCharges +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonBad + +namespace OAI + +namespace EditApproximation + +open Finset + +section Stage + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (root : PhysicalNode M J) (K : ℕ) + (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) + +noncomputable def subtreeComparisonBadCost (ratio : ℝ) : ℝ := by + classical + exact ∑ v : (Σ d : Fin K, TreeLayer M d.val) with + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).2, + comparisonActiveCost source target (frontier v.1.val v.2) + +include hsize hF hA hseed hT in + theorem subtreeComparisonBadCost_bound (ratio : ℝ) (hratio : 0 ≤ ratio) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hcapacity : source.length ≤ M ^ J) + (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) : + subtreeComparisonBadCost source target hM U N P F A hP T root K hheight rootQ ratio ≤ + 10000 * ratio * F * (1 + (K : ℝ) / P + (K : ℝ) / T) * + comparisonStateCost source target (some (physicalSourceInterval source.length root, rootQ)) := by + classical + let ι := Σ d : Fin K, TreeLayer M d.val + let cost : ι → ℝ := fun v => comparisonActiveCost source target (frontier v.1.val v.2) + let scale : ι → ℝ := fun v => comparisonActiveScale source target (frontier v.1.val v.2) + let curvature : ι → ℝ := fun v => (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).1 + let G : ι → ℝ := fun v => (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).2 + have h := bad_node_cost_from_curvature (univ : Finset ι) cost scale curvature G ratio _ hratio + (fun v _ => (comparisonActiveCost_scale source target _).2) + (fun v _ => (subtreeComparisonCharges_local source target hM U N P F A hsize hP hF hA hseed + T hT root K hheight rootQ hscale v.1 v.2).1) + (fun v _ => (subtreeComparisonCharges_local source target hM U N P F A hsize hP hF hA hseed + T hT root K hheight rootQ hscale v.1 v.2).2.1) + (subtreeComparisonCharges_total source target hM U N P F A hsize hP hF hA hseed + T hT root K hheight rootQ hscale hcapacity hsmall) + change subtreeComparisonBadCost source target hM U N P F A hP T root K hheight rootQ ratio ≤ _ at h + convert h using 1 + ring + +end Stage + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeBudget.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..3359025b50e4509c3df0c63dc46ca0a7e5f3e6a9 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeBudget.lean @@ -0,0 +1,142 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeNear +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeExpectation +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeBudget + +namespace OAI + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +section Tree + +variable {α Ω : Type*} [DecidableEq α] [Fintype Ω] + [MeasurableSpace Ω] [MeasurableSingletonClass Ω] + {M J : ℕ} (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (root : PhysicalNode M J) (K : ℕ) (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + (μ : Measure Ω) [IsProbabilityMeasure μ] + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) +local notation "charges" => subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ +local notation "prediction" => subtreeComparisonPrediction source target hM U N P F A hP T root K hheight rootQ +local notation "D" => comparisonStateCost source target + (some (physicalSourceInterval source.length root, rootQ)) + +include hsize hF hA hseed hT in + theorem subtree_comparison_expected_regret_sum (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hcapacity : source.length ≤ M ^ J) (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) + (S : ℕ) (coefficient : ℝ) (hcoef : 0 ≤ coefficient) + (hgood : ∀ (d : Fin K) (path : TreeLayer M d.val), + ¬ (comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).2) → + |prediction d path| ≤ 1 - tau → + (∫ ω, (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) root K rootQ t d path) ∂μ) ≤ coefficient * comparisonActiveCost source target (frontier d.val path)) : + (∑ v : (Σ d : Fin K, TreeLayer M d.val), + ∫ ω, (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) root K rootQ t v.1 v.2) ∂μ) ≤ + (40000 * ratio * (F : ℝ) ^ 2 * (1 + (K : ℝ) / P + (K : ℝ) / T) + + 2 * K * (1 / ratio + 4 * (tau : ℝ) * F + coefficient)) * D := by + classical + let cost := fun (v : Σ d : Fin K, TreeLayer M d.val) => comparisonActiveCost source target (frontier v.1.val v.2) + let regret := fun (v : Σ d : Fin K, TreeLayer M d.val) => + ∫ ω, (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) root K rootQ t v.1 v.2) ∂μ + let bad := fun (v : Σ d : Fin K, TreeLayer M d.val) => + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).2 + let near := fun (v : Σ d : Fin K, TreeLayer M d.val) => 1 - tau < |prediction v.1 v.2| + have hbad : (∑ v with bad v, regret v) ≤ + 40000 * ratio * (F : ℝ) ^ 2 * (1 + (K : ℝ) / P + (K : ℝ) / T) * D := by + rw [← integral_finsetSum _ (by intro v hv; exact .of_finite)] + have h := integral_mono (μ := μ) (.of_finite) (integrable_const _) (fun ω => + subtreeComparisonBadRegret_bound source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices ω) root K hheight rootQ ratio hratio.le hscale hMP hcapacity hsmall S) + simpa only [integral_const, probReal_univ, one_smul] using h + have hnear : (∑ v with ¬ bad v ∧ near v, regret v) ≤ + 2 * K * (1 / ratio + 4 * (tau : ℝ) * F) * D := by + rw [← integral_finsetSum _ (by intro v hv; exact .of_finite)] + have h := integral_mono (μ := μ) (.of_finite) (integrable_const _) (fun ω => + subtreeComparisonNearRegret_bound source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices ω) root K hheight rootQ ratio hratio tau htau hscale hMP hsmall S) + simpa only [integral_const, probReal_univ, one_smul] using h + have hcost : (∑ v, cost v) ≤ 2 * K * D := by + have heq := treeLayer_sigma_sum M K (fun (d : ℕ) (path : TreeLayer M d) => + comparisonActiveCost source target (frontier d path)) + exact heq.le.trans (comparison_total_active_cost_bound source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K hsmall) + have h := finite_three_region_budget cost regret bad near _ _ coefficient (2 * K * D) + hbad hnear (fun v hb hn => hgood v.1 v.2 hb (le_of_not_gt hn)) hcoef + (fun v => (comparisonActiveCost_bounds source target _).1) hcost + convert h using 1 + ring + +include hsize hF hA hseed hT in + theorem subtree_expected_excess_of_good_nodes (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hcapacity : source.length ≤ M ^ J) (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) + (S : ℕ) (hS : 0 < S) (coefficient : ℝ) (hcoef : 0 ≤ coefficient) + (hgood : ∀ (d : Fin K) (path : TreeLayer M d.val), + ¬ (comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).2) → + |prediction d path| ≤ 1 - tau → + (∫ ω, (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) root K rootQ t d path) ∂μ) ≤ coefficient * comparisonActiveCost source target (frontier d.val path)) : + (∫ ω, max ((physicalRefinement source target U N P F A T delta (choices ω) + root S rootQ : ℝ) - + stateEditCost (physicalSource source root) target rootQ) 0 ∂μ) ≤ + ((8 * (M : ℝ) + 512 * F) * K / P + + (40000 * ratio * (F : ℝ) ^ 2 * (1 + (K : ℝ) / P + (K : ℝ) / T) + + 2 * K * (1 / ratio + 4 * (tau : ℝ) * F + coefficient)) / S) * + stateEditCost (physicalSource source root) target rootQ := by + classical + let budget := fun (d : ℕ) (path : TreeLayer M d) => if hd : d < K then + ∫ ω, (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) root K rootQ t ⟨d, hd⟩ path) ∂μ else 0 + have hnode (d : ℕ) (hd : d < K) (path : TreeLayer M d) : + (∫ ω, (∑ t ∈ range S, + (subtreeClippedLift source target hM U N P F A hP T delta (choices ω) root rootQ (t + 1) d path - + (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) - + ∑ i : Fin M, subtreeClippedLift source target hM U N P F A hP T delta + (choices ω) root rootQ (t + 1) (d + 1) (path, i))) ∂μ) ≤ budget d path := by + simp only [budget, dite_eq_left hd, subtreeComparisonTreeRegret, le_refl] + have htelescope := subtree_expected_excess source target hM U N P F A hsize hP hF hA hseed + T hT delta choices root K hheight rootQ μ S hS hcapacity hsmall budget hnode + have hsum := subtree_comparison_expected_regret_sum source target hM U N P F A hsize hP hF hA hseed + T hT delta choices root K hheight rootQ μ ratio hratio tau htau hscale hMP hcapacity hsmall S coefficient hcoef hgood + have heq : (∑ d ∈ range K, ∑ path : TreeLayer M d, budget d path) = + ∑ v : (Σ d : Fin K, TreeLayer M d.val), + ∫ ω, (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) root K rootQ t v.1 v.2) ∂μ := by + rw [← treeLayer_sigma_sum M K budget] + apply sum_congr rfl + intro v _ + simp only [budget, dite_eq_left v.1.isLt] + rw [heq] at htelescope + have hroot : D = (stateEditCost (physicalSource source root) target rootQ : ℝ) := by + rfl + rw [hroot] at hsum + have hdiv := div_le_div_of_nonneg_right hsum (Nat.cast_nonneg (α := ℝ) S) + calc + _ ≤ _ := htelescope + _ ≤ ((8 * (M : ℝ) + 512 * F) * K / P) * stateEditCost (physicalSource source root) target rootQ + + ((40000 * ratio * (F : ℝ) ^ 2 * (1 + (K : ℝ) / P + (K : ℝ) / T) + + 2 * K * (1 / ratio + 4 * (tau : ℝ) * F + coefficient)) * + stateEditCost (physicalSource source root) target rootQ) / S := add_le_add_right hdiv _ + _ = _ := by ring + +end Tree + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeCharges.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a89b48c7d5570566a16bac1f6a2d6867a5afb61 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeCharges.lean @@ -0,0 +1,226 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeMass +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonCharges +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonEnergy +import OAI.Combinatorics.EditApproximation.Refinement.StageParameterBounds + +namespace OAI + +/-! Curvature and discrepancy are computed from the actual comparison-tree warmup masses. -/ + +namespace EditApproximation + +open Finset + +section Stage + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (root : PhysicalNode M J) (K : ℕ) + (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + +local notation "mass" => subtreeComparisonMass source target hM U N P F A hP T root rootQ +local notation "energy" => subtreeComparisonEnergy source target hM U N P F A hP T root rootQ +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) + +noncomputable def subtreeComparisonCharges (d : Fin K) (path : TreeLayer M d.val) : ℝ × ℝ := by + classical + exact match frontier d.val path with + | none => (0, 0) + | some (parent, q) => if hstop : comparisonStopped source target parent q then (0, 0) else + let hc : 0 < stateEditCost (substring source parent.lo parent.hi) target q := by + unfold comparisonStopped at hstop + omega + let node : PhysicalNode M J := physicalSubtreeNode root d.val path (by omega) + let child := fun i s => (stageWarmupMass source target U N P F A T (physicalChild node (by dsimp only [node, physicalSubtreeNode]; omega) i, s) : ℝ) + let b := 2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP parent q hc + let hnonempty : wideActionList M parent r b P ≠ [] := by + have hmem : action ∈ wideActionList M parent r b P := + (comparisonChildren_spec source target hM P hP parent q hc).1 + intro heq + rw [heq] at hmem + exact List.not_mem_nil hmem + (comparisonActionCurvature source target parent r action child, + comparisonActionMass action child - wideActionMinimum parent r b P hnonempty child) + +include hsize hF hA hseed hT in + theorem subtreeComparisonCharges_local (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) + (d : Fin K) (path : TreeLayer M d.val) : + let charges := subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ d path + let R := mass d.val path - ∑ i : Fin M, mass (d.val + 1) (path, i) + let E := (∑ i : Fin M, energy (d.val + 1) (path, i)) - energy d.val path + let movement := comparisonMovement source target P (frontier d.val path) + let cost := comparisonActiveCost source target (frontier d.val path) + 0 ≤ charges.1 ∧ 0 ≤ charges.2 ∧ + R + charges.2 ≤ (128 * (F : ℝ)) * movement + (2 * F / (T : ℝ)) * cost ∧ + charges.1 ≤ E + 3 * movement + 2 * max (-R) 0 := by + classical + dsimp only + generalize heq : frontier d.val path = state + cases state with + | none => + have hzero := subtreeComparison_step_none source target hM U N P F A hP T root rootQ d.val path heq + have hcharges : subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ d path = (0, 0) := by + unfold subtreeComparisonCharges + rw [heq] + rw [hcharges, hzero.1, hzero.2.1, hzero.2.2.1, hzero.2.2.2] + simp only [comparisonMovement, comparisonActiveCost, sub_self, neg_zero, max_self, + mul_zero, add_zero, le_refl, and_self] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · have hm := subtreeComparisonMass_step_stopped source target hM U N P F A hP T root rootQ d.val path parent q heq hstop + have he := subtreeComparisonEnergy_step_stopped source target hM U N P F A hP T root rootQ d.val path parent q heq hstop + have hcharges : subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ d path = (0, 0) := by + unfold subtreeComparisonCharges + rw [heq] + simp only [dite_eq_left hstop] + rw [hcharges, hm, he] + simp only [comparisonMovement, comparisonActiveCost, ite_eq_left hstop, sub_self, neg_zero, + max_self, mul_zero, add_zero, le_refl, and_self] + · have hp := comparisonSubtree_active_source source target hM P hP root rootQ d.val path parent q heq hstop + subst parent + let node : PhysicalNode M J := physicalSubtreeNode root d.val path (by omega) + have hbelow : node.1.val < J := by dsimp only [node, physicalSubtreeNode]; omega + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q + unfold comparisonStopped at hstop + omega + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc + let child := fun i s => (stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) : ℝ) + let mp := (stageWarmupMass source target U N P F A T (node, q) : ℝ) + let W := comparisonActionMass action child + let curvature := comparisonActionCurvature source target (physicalSourceInterval source.length node) r action child + obtain ⟨hnonempty, hK, hG, hslack, henergy⟩ := + stageComparison_energy source target hM U N P F A hsize hP hF hA hseed T hT node hbelow q hc hleaf hscale + let Z := wideActionMinimum (physicalSourceInterval source.length node) r b P hnonempty child + have hcharges : subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ d path = (curvature, W - Z) := by + unfold subtreeComparisonCharges + rw [heq] + dsimp only + rw [dite_eq_right hstop] + rfl + have hparent : mass d.val path = mp := by + unfold subtreeComparisonMass comparisonSubtreeLift + rw [dite_eq_left (by omega : root.1.val + d.val ≤ J), heq] + simp only [stoppedComparisonValue, ite_eq_right hstop] + rfl + have hchild (i : Fin M) : mass (d.val + 1) (path, i) = child i (action i) := + subtreeComparisonMass_step_active source target hM U N P F A hsize hP hF hA hseed T hT root rootQ + d.val path (by omega) q heq hstop i + have hparentEnergy : energy d.val path = (stateLengthGap (physicalSource source node) target q) ^ 2 / mp := by + unfold subtreeComparisonEnergy + rw [heq, hparent] + rfl + have hchildEnergy (i : Fin M) : energy (d.val + 1) (path, i) = + (stateLengthGap (physicalSource source (physicalChild node hbelow i)) target (action i)) ^ 2 / + child i (action i) := + subtreeComparisonEnergy_step_active source target hM U N P F A hsize hP hF hA hseed T hT root rootQ + d.val path (by omega) q heq hstop i + rw [hcharges, hparent, hparentEnergy] + simp_rw [hchild, hchildEnergy] + simp only [comparisonMovement, comparisonActiveCost, ite_eq_right hstop] + change 0 ≤ curvature ∧ 0 ≤ W - Z ∧ + mp - W + (W - Z) ≤ (128 * (F : ℝ)) * targetEndpointDistance q r + + (2 * F / (T : ℝ)) * stateEditCost (physicalSource source node) target q ∧ + curvature ≤ ((∑ i, (stateLengthGap (physicalSource source (physicalChild node hbelow i)) target + (action i)) ^ 2 / child i (action i)) - + (stateLengthGap (physicalSource source node) target q) ^ 2 / mp) + + 3 * targetEndpointDistance q r + 2 * max (-(mp - W)) 0 + have hu := (stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT (node, q)).2.2.2 + have huR : (stageInitial source target U N P F A (node, q) : ℝ) ≤ + 2 * F * stateEditCost (physicalSource source node) target q := by exact_mod_cast hu + have hdiv := div_le_div_of_nonneg_right huR (Nat.cast_nonneg (α := ℝ) T) + have hid : (2 * (F : ℝ) * stateEditCost (physicalSource source node) target q) / T = + (2 * F / (T : ℝ)) * stateEditCost (physicalSource source node) target q := by ring + rw [hid] at hdiv + exact ⟨hK, hG, hslack.trans (add_le_add_right hdiv _), henergy⟩ + +include hsize hF hA hseed hT in + theorem subtreeComparisonCharges_total (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) + (hcapacity : source.length ≤ M ^ J) + (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) : + (∑ v : (Σ d : Fin K, TreeLayer M d.val), + ((subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).1 + + (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).2)) ≤ + 5000 * F * (1 + (K : ℝ) / P + (K : ℝ) / T) * + comparisonStateCost source target (some (physicalSourceInterval source.length root, rootQ)) := by + let ι := Σ d : Fin K, TreeLayer M d.val + let D := comparisonStateCost source target (some (physicalSourceInterval source.length root, rootQ)) + let curvatures : ι → ℝ := fun v => (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).1 + let G : ι → ℝ := fun v => (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).2 + let R : ι → ℝ := fun v => mass v.1.val v.2 - ∑ i : Fin M, mass (v.1.val + 1) (v.2, i) + let E : ι → ℝ := fun v => (∑ i : Fin M, energy (v.1.val + 1) (v.2, i)) - energy v.1.val v.2 + let movement : ι → ℝ := fun v => comparisonMovement source target P (frontier v.1.val v.2) + let slack : ι → ℝ := fun v => (128 * (F : ℝ)) * movement v + + (2 * F / (T : ℝ)) * comparisonActiveCost source target (frontier v.1.val v.2) + have hlocal (v : ι) := subtreeComparisonCharges_local source target hM U N P F A hsize hP hF hA hseed + T hT root K hheight rootQ hscale v.1 v.2 + have hroot := (subtreeComparisonMass_bounds source target hM U N P F A hsize hP hF hA hseed T hT root rootQ + 0 PUnit.unit).1 + have hterminal : (∑ path : TreeLayer M K, mass K path) ≤ 2 * D := by + simp_rw [subtreeComparisonMass_terminal source target hM U N P F A hP T root rootQ K hheight hcapacity] + exact comparison_frontier_cost_le_twice source target hM P hP _ K K le_rfl hsmall + have hconservation : (∑ v : ι, R v) = mass 0 PUnit.unit - ∑ path : TreeLayer M K, mass K path := by + dsimp only [R, ι] + have h := treeLayer_sigma_sum M K (fun d path => mass d path - ∑ i : Fin M, mass (d + 1) (path, i)) + exact h.trans (tree_frontier_telescope M K mass) + have henergy : (∑ v : ι, E v) ≤ 2 * D := by + dsimp only [E, ι] + have h := treeLayer_sigma_sum M K (fun d path => (∑ i : Fin M, energy (d + 1) (path, i)) - energy d path) + apply h.le.trans + exact subtreeComparisonEnergy_telescope source target hM U N P F A hsize hP hF hA hseed T hT root rootQ + K hheight hcapacity hsmall + have hF0 : (0 : ℝ) ≤ F := Nat.cast_nonneg _ + have hslack (v : ι) : 0 ≤ slack v := by + exact add_nonneg (mul_nonneg (mul_nonneg (by norm_num) hF0) + (comparisonMovement_nonneg source target P _)) + (mul_nonneg (div_nonneg (mul_nonneg (by norm_num) hF0) (Nat.cast_nonneg _)) + (comparisonActiveCost_bounds source target _).1) + have htotal := curvature_total_from_telescope (univ : Finset ι) curvatures G R movement slack E D + (mass 0 PUnit.unit) (∑ path : TreeLayer M K, mass K path) hroot hterminal hconservation henergy + (fun v _ => (hlocal v).2.1) (fun v _ => hslack v) + (fun v _ => (hlocal v).2.2.1) (fun v _ => (hlocal v).2.2.2) + have hmove : (∑ v : ι, movement v) ≤ 4 * ((K : ℝ) / P) * D := by + dsimp only [movement, ι] + have heq := treeLayer_sigma_sum M K (fun d path => comparisonMovement source target P (frontier d path)) + apply heq.le.trans + have h := comparison_total_movement_bound source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K hsmall + convert h using 1 + ring + have hactive : (∑ v : ι, comparisonActiveCost source target (frontier v.1.val v.2)) ≤ 2 * K * D := by + dsimp only [ι] + have heq := treeLayer_sigma_sum M K (fun d path => comparisonActiveCost source target (frontier d path)) + apply heq.le.trans + exact comparison_total_active_cost_bound source target hM P hP _ K hsmall + have hslackSum : (∑ v : ι, slack v) ≤ + 512 * F * ((K : ℝ) / P) * D + 4 * F * ((K : ℝ) / T) * D := by + dsimp only [slack] + rw [sum_add_distrib, ← mul_sum, ← mul_sum] + have hm := mul_le_mul_of_nonneg_left hmove (show 0 ≤ 128 * (F : ℝ) from mul_nonneg (by norm_num) hF0) + have ha := mul_le_mul_of_nonneg_left hactive (show 0 ≤ 2 * (F : ℝ) / (T : ℝ) from + div_nonneg (mul_nonneg (by norm_num) hF0) (Nat.cast_nonneg _)) + calc + _ ≤ (128 * (F : ℝ)) * (4 * ((K : ℝ) / P) * D) + (2 * F / (T : ℝ)) * (2 * K * D) := add_le_add hm ha + _ = _ := by ring + exact curvature_total_parameter_bound (comparisonStateCost_nonneg source target _) + (by exact_mod_cast hF) (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) htotal hmove hslackSum + +end Stage + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeExpectation.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c10afdc298d67fffdcfd29c97718572ebf77e20 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeExpectation.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeRegret + +namespace OAI + +/-! Finite expectation of the actual clipped refinement telescope. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +section Expectation + +variable {α Ω : Type*} [DecidableEq α] [Fintype Ω] + [MeasurableSpace Ω] [MeasurableSingletonClass Ω] + {M J : ℕ} (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (root : PhysicalNode M J) (K : ℕ) (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + (μ : Measure Ω) [IsProbabilityMeasure μ] + +local notation "D" => (stateEditCost (physicalSource source root) target rootQ : ℝ) +local notation "lifted" => fun ω => subtreeClippedLift source target hM U N P F A hP T delta (choices ω) root rootQ +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) + +include hsize hF hA hseed hT hheight in + theorem subtree_expected_excess (S : ℕ) (hS : 0 < S) + (hcapacity : source.length ≤ M ^ J) (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) + (budget : (d : ℕ) → TreeLayer M d → ℝ) + (hnode : ∀ d < K, ∀ path : TreeLayer M d, + (∫ ω, (∑ t ∈ range S, + (lifted ω (t + 1) d path - (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) - + ∑ i : Fin M, lifted ω (t + 1) (d + 1) (path, i))) ∂μ) ≤ budget d path) : + (∫ ω, max ((physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) - D) 0 ∂μ) ≤ + ((8 * (M : ℝ) + 512 * F) * K / P) * D + + (∑ d ∈ range K, ∑ path : TreeLayer M d, budget d path) / S := by + let charge := fun d (path : TreeLayer M d) => (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) + let regret := fun ω t d (path : TreeLayer M d) => + lifted ω (t + 1) d path - charge d path - ∑ i : Fin M, lifted ω (t + 1) (d + 1) (path, i) + let coefficient : ℝ := (8 * (M : ℝ) + 512 * F) * K / P + have hpoint (ω : Ω) := subtree_regret_time source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices ω) root rootQ K hheight S hcapacity hsmall + have hmean := integral_mono (μ := μ) (.of_finite) (.of_finite) hpoint + have hregret : (∫ ω, (∑ t ∈ range S, ∑ d ∈ range K, ∑ path : TreeLayer M d, regret ω t d path) ∂μ) ≤ + ∑ d ∈ range K, ∑ path : TreeLayer M d, budget d path := by + have hswap (ω : Ω) : (∑ t ∈ range S, ∑ d ∈ range K, ∑ path : TreeLayer M d, regret ω t d path) = + ∑ d ∈ range K, ∑ path : TreeLayer M d, ∑ t ∈ range S, regret ω t d path := by + rw [sum_comm] + apply sum_congr rfl + intro d _ + rw [sum_comm] + simp_rw [hswap] + rw [integral_finsetSum _ (by intro d hd; exact .of_finite)] + apply sum_le_sum + intro d hd + rw [integral_finsetSum _ (by intro path hp; exact .of_finite)] + exact sum_le_sum fun path _ => hnode d (mem_range.mp hd) path + have hroot : (∫ ω, max D + (physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) ∂μ) = + (∫ ω, max ((physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) - D) 0 ∂μ) + D := by + have heq (ω : Ω) : max D + (physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) = + max ((physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) - D) 0 + D := by + rw [← max_add_add_right, sub_add_cancel, zero_add, max_comm] + simp_rw [heq] + rw [integral_add (.of_finite) (integrable_const _), integral_const, probReal_univ, one_smul] + change (∫ ω, (S : ℝ) * max D + (physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) ∂μ) ≤ + (∫ ω, (S : ℝ) * ((1 + coefficient) * D) + + (∑ t ∈ range S, ∑ d ∈ range K, ∑ path : TreeLayer M d, regret ω t d path) ∂μ) at hmean + rw [integral_const_mul, integral_add (integrable_const _) (.of_finite), + integral_const, probReal_univ, one_smul, hroot] at hmean + have hSR : (0 : ℝ) < S := by exact_mod_cast hS + apply (sub_le_iff_le_add').mp + apply (le_div_iff₀ hSR).2 + nlinarith only [hmean, hregret] + +end Expectation + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeGeneric.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..50ca29cc90eff266834e2626de1fc8e2695642e2 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeGeneric.lean @@ -0,0 +1,179 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalGenericRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeGeneric +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeBad + +namespace OAI + +/-! Generic cumulative regret at actual comparison-tree slots, including stopped slots. -/ + +namespace EditApproximation + +open Finset + +section Tree + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (root : PhysicalNode M J) (K : ℕ) (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) +local notation "lifted" => subtreeClippedLift source target hM U N P F A hP T delta choices root rootQ + +noncomputable def subtreeComparisonTreeRegret (t : ℕ) (d : Fin K) (path : TreeLayer M d.val) : ℝ := + lifted (t + 1) d.val path - (128 * (F : ℝ)) * comparisonMovement source target P (frontier d.val path) - + ∑ i : Fin M, lifted (t + 1) (d.val + 1) (path, i) + + theorem subtreeComparisonTreeRegret_none (t : ℕ) (d : Fin K) (path : TreeLayer M d.val) + (heq : frontier d.val path = none) : + subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t d path = 0 := by + have hnext (i : Fin M) : frontier (d.val + 1) (path, i) = none := by + change comparisonStep source target hM P hP (frontier d.val path) i = none + rw [heq] + rfl + simp only [subtreeComparisonTreeRegret, subtreeClippedLift, comparisonSubtreeLift, heq, hnext, + stoppedComparisonValue, comparisonMovement, mul_zero, sub_self, sum_const_zero] + + theorem subtreeComparisonTreeRegret_stopped (t : ℕ) (d : Fin K) (path : TreeLayer M d.val) + (parent : TargetInterval source.length) (q : TargetInterval target.length) + (heq : frontier d.val path = some (parent, q)) (hstop : comparisonStopped source target parent q) : + subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t d path = 0 := by + classical + have hpoint (i : Fin M) : lifted (t + 1) (d.val + 1) (path, i) = + if i = ⟨0, hM⟩ then (stateEditCost (substring source parent.lo parent.hi) target q : ℝ) else 0 := by + unfold subtreeClippedLift comparisonSubtreeLift + change stoppedComparisonValue source target _ + (comparisonStep source target hM P hP (frontier d.val path) i) = _ + rw [heq] + simp only [comparisonStep, dite_eq_left hstop] + split_ifs <;> simp only [stoppedComparisonValue, ite_eq_left hstop] + unfold subtreeComparisonTreeRegret + simp_rw [hpoint] + simp only [subtreeClippedLift, comparisonSubtreeLift, heq, stoppedComparisonValue, ite_eq_left hstop, + comparisonMovement, mul_zero, sub_zero, sum_ite_eq', mem_univ, ite_true, sub_self] + +include hsize hF hA hseed hT in + theorem subtreeComparisonTreeRegret_active (t : ℕ) (d : Fin K) (path : TreeLayer M d.val) + (q : TargetInterval target.length) + (heq : frontier d.val path = some + (physicalSourceInterval source.length (physicalSubtreeNode root d.val path (by omega)), q)) + (hactive : ¬ comparisonStopped source target + (physicalSourceInterval source.length (physicalSubtreeNode root d.val path (by omega))) q) : + let node := physicalSubtreeNode root d.val path (by omega) + let hbelow : node.1.val < J := by dsimp only [node, physicalSubtreeNode]; omega + let hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + dsimp only [node] + unfold comparisonStopped at hactive + omega + let r := roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q)) P) q + subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t d path = + max (stateEditCost (physicalSource source node) target q : ℝ) + (physicalRefinement source target U N P F A T delta choices node (t + 1) q : ℝ) - + (128 * (F : ℝ)) * targetEndpointDistance q r - + physicalComparisonClipped source target U N P F A T delta choices node hbelow + (comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc) (t + 1) := by + classical + dsimp only + have hnext (i : Fin M) := comparisonSubtreeLift_step_active source target hM P hP + (physicalClippedTable source target U N P F A T delta choices (t + 1)) + (fun label s hstop => physicalClippedTable_at_stopped source target hM U N P F A hsize hP hF hA hseed + T hT delta choices label s hstop (t + 1)) root rootQ d.val path (by omega) q heq hactive i + have hcurrent : comparisonSubtreeLift source target hM P hP + (physicalClippedTable source target U N P F A T delta choices (t + 1)) root rootQ d.val path = + physicalClippedTable source target U N P F A T delta choices (t + 1) + (physicalSubtreeNode root d.val path (by omega), q) := by + unfold comparisonSubtreeLift + rw [heq] + simp only [stoppedComparisonValue, ite_eq_right hactive] + rw [dite_eq_left (by omega : root.1.val + d.val ≤ J)] + have hmovement : comparisonMovement source target P (frontier d.val path) = + targetEndpointDistance q (roundInterval (seedGridSpacing + (2 ^ Nat.log 2 (stateEditCost (physicalSource source (physicalSubtreeNode root d.val path (by omega))) target q)) P) q) := by + rw [heq] + simp only [comparisonMovement, ite_eq_right hactive] + rfl + unfold subtreeComparisonTreeRegret subtreeClippedLift + rw [hcurrent, hmovement] + simp_rw [hnext] + rfl + +include hsize hF hA hseed hT hheight in + theorem subtreeComparisonTreeRegret_generic (hMP : 4 * (M : ℝ) / P ≤ 1) + (S : ℕ) (d : Fin K) (path : TreeLayer M d.val) : + (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t d path) ≤ + 4 * F * comparisonActiveCost source target (frontier d.val path) := by + classical + generalize heq : frontier d.val path = state + cases state with + | none => + simp only [subtreeComparisonTreeRegret_none source target hM U N P F A hP T delta choices root K rootQ + _ d path heq, sum_const_zero, comparisonActiveCost, mul_zero, le_refl] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · simp only [subtreeComparisonTreeRegret_stopped source target hM U N P F A hP T delta choices root K rootQ + _ d path parent q heq hstop, sum_const_zero, comparisonActiveCost, ite_eq_left hstop, mul_zero, le_refl] + · have hp := comparisonSubtree_active_source source target hM P hP root rootQ d.val path parent q heq hstop + let node : PhysicalNode M J := physicalSubtreeNode root d.val path (by omega) + have hp' : parent = physicalSourceInterval source.length node := hp + subst parent + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + change ¬ ((physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 ∨ + stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q = 0) at hstop + omega + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + have h := physicalNode_generic_regret_upper source target hM U N P F A hsize hP hF hA hseed T hT + delta choices node (by dsimp only [node, physicalSubtreeNode]; omega) hleaf q hc hMP S + have hpoint (t : ℕ) : subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t d path = _ := + subtreeComparisonTreeRegret_active source target hM U N P F A hsize hP hF hA hseed + T hT delta choices root K hheight rootQ t d path q heq hstop + simp_rw [hpoint] + have hstop' : ¬ comparisonStopped source target + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) q := hstop + simpa only [comparisonActiveCost, ite_eq_right hstop', physicalSource, physicalSourceInterval, + node, physicalSubtreeNode] using h + +include hsize hF hA hseed hT in + theorem subtreeComparisonBadRegret_bound (ratio : ℝ) (hratio : 0 ≤ ratio) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hcapacity : source.length ≤ M ^ J) (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) (S : ℕ) : + (∑ v : (Σ d : Fin K, TreeLayer M d.val) with + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ v.1 v.2).2, + ∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t v.1 v.2) ≤ + 40000 * ratio * (F : ℝ) ^ 2 * (1 + (K : ℝ) / P + (K : ℝ) / T) * + comparisonStateCost source target (some (physicalSourceInterval source.length root, rootQ)) := by + classical + have htotal := subtreeComparisonBadCost_bound source target hM U N P F A hsize hP hF hA hseed + T hT root K hheight rootQ ratio hratio hscale hcapacity hsmall + have hpoint := fun (v : Σ d : Fin K, TreeLayer M d.val) => + subtreeComparisonTreeRegret_generic source target hM U N P F A hsize hP hF hA hseed + T hT delta choices root K hheight rootQ hMP S v.1 v.2 + apply (sum_le_sum (fun v _ => hpoint v)).trans + rw [← mul_sum] + have h := mul_le_mul_of_nonneg_left htotal (show (0 : ℝ) ≤ 4 * F by positivity) + unfold subtreeComparisonBadCost at h + convert h using 1 + ring + +end Tree + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeMass.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..803e0ee83b536b0acb4d0bfde8e3f3a8c90a818f --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeMass.lean @@ -0,0 +1,216 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtree +import OAI.Combinatorics.EditApproximation.Refinement.StageTerminal + +namespace OAI + +/-! Actual original-table warmup masses below an arbitrary physical node. -/ + +namespace EditApproximation + +open Finset + +section Warmup + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (root : PhysicalNode M J) (rootQ : TargetInterval target.length) + +/-- The comparison mass is the actual averaged warmup at active states and +true cost at carried stopped states. -/ +noncomputable def subtreeComparisonMass (d : ℕ) (path : TreeLayer M d) : ℝ := + comparisonSubtreeLift source target hM P hP + (fun state => (stageWarmupMass source target U N P F A T state : ℝ)) root rootQ d path + +noncomputable def subtreeComparisonEnergy (d : ℕ) (path : TreeLayer M d) : ℝ := + (comparisonStateGap source target (comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path)) ^ 2 / + subtreeComparisonMass source target hM U N P F A hP T root rootQ d path + +include hsize hF hA hseed hT in + theorem subtreeComparisonMass_bounds (d : ℕ) (path : TreeLayer M d) : + 0 ≤ subtreeComparisonMass source target hM U N P F A hP T root rootQ d path ∧ + subtreeComparisonMass source target hM U N P F A hP T root rootQ d path ≤ + 2 * F * comparisonStateCost source target (comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) d path) := by + exact comparisonSubtreeLift_bounds source target hM P hP F (by exact_mod_cast hF) _ + (fun state => by + have h := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT state + have hlower := ((le_max_right _ _).trans h.1).trans (Rat.cast_le.mpr h.2.1) + have hupper : (stageWarmupMass source target U N P F A T state : ℝ) ≤ + ((2 * F * stateEditCost (physicalSource source state.1) target state.2 : ℚ) : ℝ) := + Rat.cast_le.mpr (h.2.2.1.trans h.2.2.2) + exact ⟨(abs_nonneg _).trans hlower, by simpa only [Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast] using hupper⟩) + root rootQ d path + +include hsize hF hA hseed hT in + theorem subtreeComparisonEnergy_bounds (d : ℕ) (hd : root.1.val + d ≤ J) (path : TreeLayer M d) : + 0 ≤ subtreeComparisonEnergy source target hM U N P F A hP T root rootQ d path ∧ + subtreeComparisonEnergy source target hM U N P F A hP T root rootQ d path ≤ + subtreeComparisonMass source target hM U N P F A hP T root rootQ d path := by + apply gap_energy_bounds + exact comparisonSubtreeLift_gap source target hM P hP _ + (fun state => by + have h := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT state + exact ((le_max_right _ _).trans h.1).trans (Rat.cast_le.mpr h.2.1)) root rootQ d hd path + +include hsize hF hA hseed hT in + theorem subtreeComparisonMass_root : + subtreeComparisonMass source target hM U N P F A hP T root rootQ 0 PUnit.unit = + stageWarmupMass source target U N P F A T (root, rootQ) := by + exact comparisonSubtreeLift_root source target hM P hP _ + (fun node q hstop => by + exact_mod_cast stageWarmupMass_at_stopped source target hM U N P F A hsize hP hF hA hseed + T hT node q hstop) root rootQ + + theorem subtreeComparisonMass_terminal (K : ℕ) (hheight : root.1.val + K = J) (hcapacity : source.length ≤ M ^ J) (path : TreeLayer M K) : + subtreeComparisonMass source target hM U N P F A hP T root rootQ K path = + comparisonStateCost source target (comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K path) := by + exact comparisonSubtreeLift_terminal source target hM P hP _ root rootQ K hheight hcapacity path + +include hsize hF hA hseed hT in + theorem subtreeComparisonEnergy_telescope (K : ℕ) (hheight : root.1.val + K = J) (hcapacity : source.length ≤ M ^ J) + (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) : + (∑ d ∈ range K, ∑ path : TreeLayer M d, + ((∑ i : Fin M, subtreeComparisonEnergy source target hM U N P F A hP T root rootQ (d + 1) (path, i)) - + subtreeComparisonEnergy source target hM U N P F A hP T root rootQ d path)) ≤ + 2 * comparisonStateCost source target (some (physicalSourceInterval source.length root, rootQ)) := by + have htel := tree_frontier_telescope M K (subtreeComparisonEnergy source target hM U N P F A hP T root rootQ) + have heq : (∑ d ∈ range K, ∑ path : TreeLayer M d, + ((∑ i : Fin M, subtreeComparisonEnergy source target hM U N P F A hP T root rootQ (d + 1) (path, i)) - + subtreeComparisonEnergy source target hM U N P F A hP T root rootQ d path)) = + (∑ path : TreeLayer M K, subtreeComparisonEnergy source target hM U N P F A hP T root rootQ K path) - + subtreeComparisonEnergy source target hM U N P F A hP T root rootQ 0 PUnit.unit := by + have h := congrArg Neg.neg htel + simp only [← sum_neg_distrib, neg_sub] at h + exact h + rw [heq] + have hroot := (subtreeComparisonEnergy_bounds source target hM U N P F A hsize hP hF hA hseed T hT root rootQ + 0 (by omega) PUnit.unit).1 + have hterminal := sum_le_sum (fun path (_ : path ∈ (univ : Finset (TreeLayer M K))) => + (subtreeComparisonEnergy_bounds source target hM U N P F A hsize hP hF hA hseed T hT root rootQ K (by omega) path).2) + simp_rw [subtreeComparisonMass_terminal source target hM U N P F A hP T root rootQ K hheight hcapacity] at hterminal + have hcost := comparison_frontier_cost_le_twice source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K K le_rfl hsmall + linarith only [hroot, hterminal, hcost] + +local notation "mass" => subtreeComparisonMass source target hM U N P F A hP T root rootQ +local notation "energy" => subtreeComparisonEnergy source target hM U N P F A hP T root rootQ +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) + + theorem subtreeComparisonMass_step_stopped (d : ℕ) (path : TreeLayer M d) + (parent : TargetInterval source.length) (q : TargetInterval target.length) + (heq : frontier d path = some (parent, q)) (hstop : comparisonStopped source target parent q) : + (∑ i : Fin M, mass (d + 1) (path, i)) = mass d path := by + classical + unfold subtreeComparisonMass comparisonSubtreeLift + have hpoint (i : Fin M) : + stoppedComparisonValue source target + (if hd : root.1.val + (d + 1) ≤ J then fun q => (stageWarmupMass source target U N P F A T + (physicalSubtreeNode root (d + 1) (path, i) hd, q) : ℝ) else fun _ => 0) + (frontier (d + 1) (path, i)) = + if i = ⟨0, hM⟩ then (stateEditCost (substring source parent.lo parent.hi) target q : ℝ) else 0 := by + change stoppedComparisonValue source target _ + (comparisonStep source target hM P hP (frontier d path) i) = _ + rw [heq] + simp only [comparisonStep, dite_eq_left hstop] + split_ifs <;> simp only [stoppedComparisonValue, ite_eq_left hstop] + simp_rw [hpoint] + rw [heq] + simp only [sum_ite_eq', mem_univ, ite_true, stoppedComparisonValue, ite_eq_left hstop] + + theorem subtreeComparisonEnergy_step_stopped (d : ℕ) (path : TreeLayer M d) + (parent : TargetInterval source.length) (q : TargetInterval target.length) + (heq : frontier d path = some (parent, q)) (hstop : comparisonStopped source target parent q) : + (∑ i : Fin M, energy (d + 1) (path, i)) = energy d path := by + classical + unfold subtreeComparisonEnergy subtreeComparisonMass comparisonSubtreeLift + have hpoint (i : Fin M) : + (comparisonStateGap source target (frontier (d + 1) (path, i))) ^ 2 / + stoppedComparisonValue source target + (if hd : root.1.val + (d + 1) ≤ J then fun q => (stageWarmupMass source target U N P F A T + (physicalSubtreeNode root (d + 1) (path, i) hd, q) : ℝ) else fun _ => 0) + (frontier (d + 1) (path, i)) = + if i = ⟨0, hM⟩ then (stateLengthGap (substring source parent.lo parent.hi) target q) ^ 2 / + stateEditCost (substring source parent.lo parent.hi) target q else 0 := by + change (comparisonStateGap source target (comparisonStep source target hM P hP (frontier d path) i)) ^ 2 / + stoppedComparisonValue source target _ (comparisonStep source target hM P hP (frontier d path) i) = _ + rw [heq] + simp only [comparisonStep, dite_eq_left hstop] + split_ifs <;> simp only [comparisonStateGap, stoppedComparisonValue, ite_eq_left hstop, + zero_pow (by decide : 2 ≠ 0), zero_div] + simp_rw [hpoint] + rw [heq] + simp only [sum_ite_eq', mem_univ, ite_true, comparisonStateGap, stoppedComparisonValue, ite_eq_left hstop] + + theorem subtreeComparison_step_none (d : ℕ) (path : TreeLayer M d) (heq : frontier d path = none) : + mass d path = 0 ∧ (∑ i : Fin M, mass (d + 1) (path, i)) = 0 ∧ + energy d path = 0 ∧ (∑ i : Fin M, energy (d + 1) (path, i)) = 0 := by + have hnext (i : Fin M) : frontier (d + 1) (path, i) = none := by + change comparisonStep source target hM P hP (frontier d path) i = none + rw [heq] + rfl + simp only [subtreeComparisonEnergy, subtreeComparisonMass, comparisonSubtreeLift, heq, hnext, + comparisonStateGap, stoppedComparisonValue, zero_pow (by decide : 2 ≠ 0), zero_div, + sum_const_zero, and_self] + +include hsize hF hA hseed hT in + theorem subtreeComparisonMass_step_active (d : ℕ) (path : TreeLayer M d) + (hd : root.1.val + d < J) (q : TargetInterval target.length) + (heq : frontier d path = some (physicalSourceInterval source.length (physicalSubtreeNode root d path hd.le), q)) + (hactive : ¬ comparisonStopped source target + (physicalSourceInterval source.length (physicalSubtreeNode root d path hd.le)) q) + (i : Fin M) : + let node := physicalSubtreeNode root d path hd.le + let hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + dsimp only [node] + unfold comparisonStopped at hactive + omega + mass (d + 1) (path, i) = stageWarmupMass source target U N P F A T + (physicalChild node hd i, comparisonChildren source target hM P hP + (physicalSourceInterval source.length node) q hc i) := by + exact comparisonSubtreeLift_step_active source target hM P hP _ + (fun node q hstop => by + exact_mod_cast stageWarmupMass_at_stopped source target hM U N P F A hsize hP hF hA hseed + T hT node q hstop) root rootQ d path hd q heq hactive i + +include hsize hF hA hseed hT in + theorem subtreeComparisonEnergy_step_active (d : ℕ) (path : TreeLayer M d) + (hd : root.1.val + d < J) (q : TargetInterval target.length) + (heq : frontier d path = some (physicalSourceInterval source.length (physicalSubtreeNode root d path hd.le), q)) + (hactive : ¬ comparisonStopped source target + (physicalSourceInterval source.length (physicalSubtreeNode root d path hd.le)) q) + (i : Fin M) : + let node := physicalSubtreeNode root d path hd.le + let hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + dsimp only [node] + unfold comparisonStopped at hactive + omega + let childQ := comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc i + energy (d + 1) (path, i) = + (stateLengthGap (physicalSource source (physicalChild node hd i)) target childQ) ^ 2 / + (stageWarmupMass source target U N P F A T (physicalChild node hd i, childQ) : ℝ) := by + dsimp only + unfold subtreeComparisonEnergy + rw [subtreeComparisonMass_step_active source target hM U N P F A hsize hP hF hA hseed T hT root rootQ + d path hd q heq hactive i] + change (comparisonStateGap source target (comparisonStep source target hM P hP + (frontier d path) i)) ^ 2 / _ = _ + rw [heq] + simp only [comparisonStep, dite_eq_right hactive, comparisonStateGap] + rfl + +end Warmup + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeNear.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeNear.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6e14a646c1160278cb404d985384258c1c88640 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeNear.lean @@ -0,0 +1,145 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeGeneric +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreePrediction + +namespace OAI + +/-! Actual non-bad nodes with near-unit length-gap prediction have small regret. -/ + +namespace EditApproximation + +open Finset + +section Tree + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (root : PhysicalNode M J) (K : ℕ) (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) +local notation "charges" => subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ +local notation "prediction" => subtreeComparisonPrediction source target hM U N P F A hP T root K hheight rootQ + +include hsize hF hA hseed hT in + theorem subtreeComparisonTreeRegret_near (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (S : ℕ) (d : Fin K) (path : TreeLayer M d.val) + (hnotbad : ¬ (comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).2)) + (hnear : 1 - tau < |prediction d path|) : + (∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t d path) ≤ + (1 / ratio + 4 * (tau : ℝ) * F) * comparisonActiveCost source target (frontier d.val path) := by + classical + generalize heq : frontier d.val path = state at hnotbad ⊢ + cases state with + | none => + simp only [subtreeComparisonTreeRegret_none source target hM U N P F A hP T delta choices root K rootQ + _ d path heq, sum_const_zero, comparisonActiveCost, mul_zero, le_refl] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · simp only [subtreeComparisonTreeRegret_stopped source target hM U N P F A hP T delta choices root K rootQ + _ d path parent q heq hstop, sum_const_zero, comparisonActiveCost, ite_eq_left hstop, mul_zero, le_refl] + · have hp := comparisonSubtree_active_source source target hM P hP root rootQ d.val path parent q heq hstop + let node : PhysicalNode M J := physicalSubtreeNode root d.val path (by omega) + have hp' : parent = physicalSourceInterval source.length node := hp + subst parent + change ¬ comparisonStopped source target (physicalSourceInterval source.length node) q at hstop + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + change ¬ ((physicalSourceInterval source.length node).hi - (physicalSourceInterval source.length node).lo ≤ 1 ∨ + stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q = 0) at hstop + omega + let b : ℕ := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc + let child := physicalBandChildMassTable source target U N P F A T node (by dsimp only [node, physicalSubtreeNode]; omega) + have hspec := comparisonChildren_spec source target hM P hP (physicalSourceInterval source.length node) q hc + have hn : wideActionList M (physicalSourceInterval source.length node) r b P ≠ [] := by + intro hnil + have hmem := hspec.1 + change action ∈ wideActionList M (physicalSourceInterval source.length node) r b P at hmem + rw [hnil] at hmem + exact List.not_mem_nil hmem + have hcharges := subtreeComparisonCharges_active source target hM U N P F A hP T root K hheight rootQ d path q heq hstop hc hn + have hprediction := subtreeComparisonPrediction_active source target hM U N P F A hP T root K hheight rootQ d path q heq hstop hn + have hG := (nonbad_charge_bounds _ ratio _ _ hratio hnotbad).2 + change (charges d path).2 ≤ comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) / ratio at hG + have hscaleEq : comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) = (b : ℝ) := by + simp only [comparisonActiveScale, ite_eq_right hstop] + rfl + rw [hscaleEq, hcharges] at hG + have hb : (b : ℝ) ≤ stateEditCost (physicalSource source node) target q := by + exact_mod_cast (cost_dyadicScale _ _ hc le_rfl).2.1 + have hGcost : comparisonActionMass action (fun i s => (child i s : ℝ)) - + wideActionMinimum (physicalSourceInterval source.length node) r b P hn (fun i s => (child i s : ℝ)) ≤ + (1 / ratio) * stateEditCost (physicalSource source node) target q := by + have h := hG.trans (div_le_div_of_nonneg_right hb hratio.le) + simpa only [one_div_mul_eq_div, action, child, r, b, node, + physicalSource, physicalSourceInterval, physicalSubtreeNode] using h + rw [hprediction] at hnear + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + have h := physicalNode_near_length_gap_regret source target hM U N P F A hsize hP hF hA hseed T hT + delta choices node (by dsimp only [node, physicalSubtreeNode]; omega) hleaf q hc hscale hMP hn tau htau hnear (1 / ratio) hGcost S + have hpoint (t : ℕ) : subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t d path = _ := + subtreeComparisonTreeRegret_active source target hM U N P F A hsize hP hF hA hseed + T hT delta choices root K hheight rootQ t d path q heq hstop + simp_rw [hpoint] + have hstop' : ¬ comparisonStopped source target (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) q := hstop + simpa only [comparisonActiveCost, ite_eq_right hstop', physicalSource, physicalSourceInterval, node, physicalSubtreeNode] using h + +include hsize hF hA hseed hT in + theorem subtreeComparisonNearRegret_bound (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) (S : ℕ) : + (∑ v : (Σ d : Fin K, TreeLayer M d.val) with + (¬ (comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).2)) ∧ + 1 - tau < |prediction v.1 v.2|, + ∑ t ∈ range S, subtreeComparisonTreeRegret source target hM U N P F A hP T delta choices root K rootQ t v.1 v.2) ≤ + 2 * (K : ℝ) * (1 / ratio + 4 * (tau : ℝ) * F) * + comparisonStateCost source target (some (physicalSourceInterval source.length root, rootQ)) := by + classical + let coefficient : ℝ := 1 / ratio + 4 * (tau : ℝ) * F + have hcoef : 0 ≤ coefficient := add_nonneg (div_nonneg zero_le_one hratio.le) + (mul_nonneg (mul_nonneg (by norm_num) ((Rat.cast_nonneg (K := ℝ)).mpr htau)) (Nat.cast_nonneg _)) + have hcost : (∑ v : (Σ d : Fin K, TreeLayer M d.val), comparisonActiveCost source target (frontier v.1.val v.2)) ≤ + 2 * K * comparisonStateCost source target (some (physicalSourceInterval source.length root, rootQ)) := by + have heq := treeLayer_sigma_sum M K (fun (d : ℕ) (path : TreeLayer M d) => + comparisonActiveCost source target (frontier d path)) + exact heq.le.trans (comparison_total_active_cost_bound source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K hsmall) + apply (sum_le_sum (fun v hv => subtreeComparisonTreeRegret_near source target hM U N P F A hsize hP hF hA hseed + T hT delta choices root K hheight rootQ ratio hratio tau htau hscale hMP S v.1 v.2 + (mem_filter.mp hv).2.1 (mem_filter.mp hv).2.2)).trans + rw [← mul_sum] + have hsub : (∑ v : (Σ d : Fin K, TreeLayer M d.val) with + (¬ (comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).2)) ∧ + 1 - tau < |prediction v.1 v.2|, + comparisonActiveCost source target (frontier v.1.val v.2)) ≤ + ∑ v : (Σ d : Fin K, TreeLayer M d.val), comparisonActiveCost source target (frontier v.1.val v.2) := by + exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + (fun v _ _ => (comparisonActiveCost_bounds source target _).1) + have h := mul_le_mul_of_nonneg_left (hsub.trans hcost) hcoef + convert h using 1 + ring + +end Tree + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreePrediction.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreePrediction.lean new file mode 100644 index 0000000000000000000000000000000000000000..0115efc69f6b3e3667f926746aa12ed75906271d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreePrediction.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtreeCharges +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonPrediction +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalOnlineBand + +namespace OAI + +/-! The actual comparison charges and rational velocity predictor at a physical slot. -/ + +namespace EditApproximation + +open Finset + +section Stage + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hP : 66 ≤ P) (T : ℕ) (root : PhysicalNode M J) (K : ℕ) + (hheight : root.1.val + K = J) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) + +noncomputable def subtreeComparisonPrediction (d : Fin K) (path : TreeLayer M d.val) : ℚ := by + classical + exact match frontier d.val path with + | none => 0 + | some (parent, q) => if hstop : comparisonStopped source target parent q then 0 else + let hc : 0 < stateEditCost (substring source parent.lo parent.hi) target q := by + unfold comparisonStopped at hstop + omega + let node : PhysicalNode M J := physicalSubtreeNode root d.val path (by omega) + let b := 2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP parent q hc + let hn : wideActionList M parent r b P ≠ [] := by + have hmem := (comparisonChildren_spec source target hM P hP parent q hc).1 + intro heq + rw [heq] at hmem + exact List.not_mem_nil hmem + rationalStateGap (substring source parent.lo parent.hi) target r / + rationalWideActionMinimum parent r b P hn + (physicalBandChildMassTable source target U N P F A T node (by dsimp only [node, physicalSubtreeNode]; omega)) + + theorem subtreeComparisonPrediction_active (d : Fin K) (path : TreeLayer M d.val) + (q : TargetInterval target.length) + (heq : frontier d.val path = some (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path), q)) + (hactive : ¬ comparisonStopped source target (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) q) + (hn : wideActionList M (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q)) P) q) + (2 ^ Nat.log 2 (stateEditCost (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q)) P ≠ []) : + subtreeComparisonPrediction source target hM U N P F A hP T root K hheight rootQ d path = + rationalStateGap (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q)) P) q) / + rationalWideActionMinimum (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q)) P) q) + (2 ^ Nat.log 2 (stateEditCost (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q)) P hn + (physicalBandChildMassTable source target U N P F A T + (physicalSubtreeNode root d.val path (by omega) : PhysicalNode M J) (by dsimp only [physicalSubtreeNode]; omega)) := by + unfold subtreeComparisonPrediction + rw [heq] + simp only [dite_eq_right hactive] + + theorem subtreeComparisonCharges_active (d : Fin K) (path : TreeLayer M d.val) + (q : TargetInterval target.length) + (heq : frontier d.val path = some (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path), q)) + (hactive : ¬ comparisonStopped source target (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) q) + (hc : 0 < stateEditCost (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q) + (hn : wideActionList M (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)) + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q)) P) q) + (2 ^ Nat.log 2 (stateEditCost (substring source (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).lo + (sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path)).hi) target q)) P ≠ []) : + let parent := sourceIntervalAt M source.length (root.1.val + d.val) (treeLayerAppend root.2 d.val path) + let node : PhysicalNode M J := physicalSubtreeNode root d.val path (by omega) + let r := roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q)) P) q + let action := comparisonChildren source target hM P hP parent q hc + let child := fun i s => (physicalBandChildMassTable source target U N P F A T node (by dsimp only [node, physicalSubtreeNode]; omega) i s : ℝ) + subtreeComparisonCharges source target hM U N P F A hP T root K hheight rootQ d path = + (comparisonActionCurvature source target parent r action child, + comparisonActionMass action child - wideActionMinimum parent r + (2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q)) P hn child) := by + unfold subtreeComparisonCharges + rw [heq] + simp only [dite_eq_right hactive] + rfl + +end Stage + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..52892298c0fa7a0b002d76c6c865a5ff44518dbc --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalSubtreeRegret.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalSubtree +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeRegret + +namespace OAI + +/-! The actual clipped refinement telescope below any original physical label. -/ + +namespace EditApproximation + +open Finset + +section Refinement + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (root : PhysicalNode M J) (rootQ : TargetInterval target.length) + +noncomputable def subtreeClippedLift (t d : ℕ) (path : TreeLayer M d) : ℝ := + comparisonSubtreeLift source target hM P hP + (physicalClippedTable source target U N P F A T delta choices t) root rootQ d path + +local notation "lifted" => subtreeClippedLift source target hM U N P F A hP T delta choices root rootQ +local notation "frontier" => comparisonFrontier source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) + + theorem subtreeClippedLift_antitone (d : ℕ) (path : TreeLayer M d) : Antitone (fun t => lifted t d path) := by + apply antitone_nat_of_succ_le + intro t + apply comparisonSubtreeLift_mono + intro state + apply max_le_max_left + exact Rat.cast_le.mpr (physicalRefinement_nonincreasing source target U N P F A T delta choices state.1 t state.2) + +include hsize hF hA hseed hT in + theorem subtreeClippedLift_root (t : ℕ) : lifted t 0 PUnit.unit = + max (stateEditCost (physicalSource source root) target rootQ : ℝ) + (physicalRefinement source target U N P F A T delta choices + root t rootQ : ℝ) := by + have h := comparisonSubtreeLift_root source target hM P hP + (physicalClippedTable source target U N P F A T delta choices t) + (fun node q hstop => by + have heq := physicalRefinement_at_stopped source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q hstop + simp only [physicalClippedTable, heq, Rat.cast_natCast, max_self]) root rootQ + simpa only [subtreeClippedLift, physicalClippedTable] using h + + theorem subtreeClippedLift_terminal (t K : ℕ) (hheight : root.1.val + K = J) (hcapacity : source.length ≤ M ^ J) (path : TreeLayer M K) : + lifted t K path = comparisonStateCost source target (frontier K path) := + comparisonSubtreeLift_terminal source target hM P hP _ root rootQ K hheight hcapacity path + +include hsize hF hA hseed hT in + theorem subtree_regret_time (K : ℕ) (hheight : root.1.val + K = J) (S : ℕ) (hcapacity : source.length ≤ M ^ J) + (hsmall : (K : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) : + (S : ℝ) * max (stateEditCost (physicalSource source root) target rootQ : ℝ) + (physicalRefinement source target U N P F A T delta choices + root S rootQ : ℝ) ≤ + (S : ℝ) * ((1 + (8 * (M : ℝ) + 512 * F) * K / P) * stateEditCost (physicalSource source root) target rootQ) + + ∑ t ∈ range S, ∑ d ∈ range K, ∑ path : TreeLayer M d, + (lifted (t + 1) d path - (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) - + ∑ i : Fin M, lifted (t + 1) (d + 1) (path, i)) := by + let D : ℝ := stateEditCost (physicalSource source root) target rootQ + let charge := fun d (path : TreeLayer M d) => (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) + let terminal := (1 + 8 * (M : ℝ) * K / P) * D + have hrootCost : comparisonStateCost source target + (some (physicalSourceInterval source.length root, rootQ)) = D := by + rfl + have hterminal (t : ℕ) (_ht : t < S) : (∑ path : TreeLayer M K, lifted (t + 1) K path) ≤ terminal := by + simp_rw [subtreeClippedLift_terminal source target hM U N P F A hP T delta choices root rootQ (t + 1) K hheight hcapacity] + have h := comparison_frontier_cost_slack source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K hsmall + rw [hrootCost] at h + exact h + have htime := tree_regret_time_bound M K S lifted charge terminal + (fun t ht => subtreeClippedLift_antitone source target hM U N P F A hP T delta choices root rootQ + 0 PUnit.unit (by omega)) hterminal + rw [subtreeClippedLift_root source target hM U N P F A hsize hP hF hA hseed T hT delta choices root rootQ S] at htime + have hmovement := comparison_total_movement_bound source target hM P hP + (some (physicalSourceInterval source.length root, rootQ)) K hsmall + rw [hrootCost] at hmovement + have hcharge : (∑ d ∈ range K, ∑ path : TreeLayer M d, charge d path) ≤ 512 * F * K * D / P := by + dsimp only [charge] + simp only [← mul_sum] + have h := mul_le_mul_of_nonneg_left hmovement + (show (0 : ℝ) ≤ 128 * F from mul_nonneg (by norm_num) (Nat.cast_nonneg _)) + convert h using 1 + ring + have hterm : terminal + (∑ d ∈ range K, ∑ path : TreeLayer M d, charge d path) ≤ + (1 + (8 * (M : ℝ) + 512 * F) * K / P) * D := by + calc + _ ≤ terminal + 512 * F * K * D / P := add_le_add_right hcharge terminal + _ = _ := by dsimp only [terminal]; ring + exact htime.trans (add_le_add_left (mul_le_mul_of_nonneg_left hterm (Nat.cast_nonneg S)) _) + +end Refinement + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeBudget.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8b9430184025d394a8a9c3ddd82a0ab3c2a4b28 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeBudget.lean @@ -0,0 +1,171 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeNear +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeExpectation + +namespace OAI + +/-! Summing the three actual comparison-node classes in the expected telescope. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +theorem finite_three_region_budget {ι : Type*} [Fintype ι] + (cost regret : ι → ℝ) (bad near : ι → Prop) [DecidablePred bad] [DecidablePred near] + (badBudget nearBudget coefficient costBudget : ℝ) + (hbad : (∑ i with bad i, regret i) ≤ badBudget) + (hnear : (∑ i with ¬ bad i ∧ near i, regret i) ≤ nearBudget) + (hgood : ∀ i, ¬ bad i → ¬ near i → regret i ≤ coefficient * cost i) + (hcoef : 0 ≤ coefficient) (hcost : ∀ i, 0 ≤ cost i) + (htotal : (∑ i, cost i) ≤ costBudget) : + (∑ i, regret i) ≤ badBudget + nearBudget + coefficient * costBudget := by + classical + have hsplit : (∑ i, regret i) = (∑ i with bad i, regret i) + + (∑ i with ¬ bad i ∧ near i, regret i) + + (∑ i with ¬ bad i ∧ ¬ near i, regret i) := by + simp only [sum_filter] + rw [← sum_add_distrib, ← sum_add_distrib] + apply sum_congr rfl + intro i _ + by_cases hb : bad i <;> by_cases hn : near i <;> simp only [hb, hn, not_true_eq_false, + not_false_eq_true, and_false, and_true, ite_true, ite_false, add_zero, zero_add] + have hgoodSum : (∑ i with ¬ bad i ∧ ¬ near i, regret i) ≤ coefficient * costBudget := by + apply (sum_le_sum (fun i hi => hgood i (mem_filter.mp hi).2.1 (mem_filter.mp hi).2.2)).trans + rw [← mul_sum] + apply mul_le_mul_of_nonneg_left _ hcoef + apply le_trans _ htotal + exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (fun i _ _ => hcost i) + rw [hsplit] + linarith only [hbad, hnear, hgoodSum] + +section Tree + +variable {α Ω : Type*} [DecidableEq α] [Fintype Ω] + [MeasurableSpace Ω] [MeasurableSingletonClass Ω] + {M J : ℕ} (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (rootQ : TargetInterval target.length) + (μ : Measure Ω) [IsProbabilityMeasure μ] + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) +local notation "charges" => stageComparisonCharges source target hM U N P F A hP T rootQ +local notation "prediction" => stageComparisonPrediction source target hM U N P F A hP T rootQ +local notation "D" => comparisonStateCost source target + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) + +include hsize hF hA hseed hT in + theorem physical_comparison_expected_regret_sum (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hcapacity : source.length ≤ M ^ J) (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) + (S : ℕ) (coefficient : ℝ) (hcoef : 0 ≤ coefficient) + (hgood : ∀ (d : Fin J) (path : TreeLayer M d.val), + ¬ (comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).2) → + |prediction d path| ≤ 1 - tau → + (∫ ω, (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) rootQ t d path) ∂μ) ≤ coefficient * comparisonActiveCost source target (frontier d.val path)) : + (∑ v : (Σ d : Fin J, TreeLayer M d.val), + ∫ ω, (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) rootQ t v.1 v.2) ∂μ) ≤ + (40000 * ratio * (F : ℝ) ^ 2 * (1 + (J : ℝ) / P + (J : ℝ) / T) + + 2 * J * (1 / ratio + 4 * (tau : ℝ) * F + coefficient)) * D := by + classical + let cost := fun (v : Σ d : Fin J, TreeLayer M d.val) => comparisonActiveCost source target (frontier v.1.val v.2) + let regret := fun (v : Σ d : Fin J, TreeLayer M d.val) => + ∫ ω, (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) rootQ t v.1 v.2) ∂μ + let bad := fun (v : Σ d : Fin J, TreeLayer M d.val) => + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).2 + let near := fun (v : Σ d : Fin J, TreeLayer M d.val) => 1 - tau < |prediction v.1 v.2| + have hbad : (∑ v with bad v, regret v) ≤ + 40000 * ratio * (F : ℝ) ^ 2 * (1 + (J : ℝ) / P + (J : ℝ) / T) * D := by + rw [← integral_finsetSum _ (by intro v hv; exact .of_finite)] + have h := integral_mono (μ := μ) (.of_finite) (integrable_const _) (fun ω => + physicalComparisonBadRegret_bound source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices ω) rootQ ratio hratio.le hscale hMP hcapacity hsmall S) + simpa only [integral_const, probReal_univ, one_smul] using h + have hnear : (∑ v with ¬ bad v ∧ near v, regret v) ≤ + 2 * J * (1 / ratio + 4 * (tau : ℝ) * F) * D := by + rw [← integral_finsetSum _ (by intro v hv; exact .of_finite)] + have h := integral_mono (μ := μ) (.of_finite) (integrable_const _) (fun ω => + physicalComparisonNearRegret_bound source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices ω) rootQ ratio hratio tau htau hscale hMP hsmall S) + simpa only [integral_const, probReal_univ, one_smul] using h + have hcost : (∑ v, cost v) ≤ 2 * J * D := by + have heq := treeLayer_sigma_sum M J (fun (d : ℕ) (path : TreeLayer M d) => + comparisonActiveCost source target (frontier d path)) + exact heq.le.trans (comparison_total_active_cost_bound source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) J hsmall) + have h := finite_three_region_budget cost regret bad near _ _ coefficient (2 * J * D) + hbad hnear (fun v hb hn => hgood v.1 v.2 hb (le_of_not_gt hn)) hcoef + (fun v => (comparisonActiveCost_bounds source target _).1) hcost + convert h using 1 + ring + +include hsize hF hA hseed hT in + theorem physical_tree_expected_excess_of_good_nodes (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hcapacity : source.length ≤ M ^ J) (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) + (S : ℕ) (hS : 0 < S) (coefficient : ℝ) (hcoef : 0 ≤ coefficient) + (hgood : ∀ (d : Fin J) (path : TreeLayer M d.val), + ¬ (comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).2) → + |prediction d path| ≤ 1 - tau → + (∫ ω, (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) rootQ t d path) ∂μ) ≤ coefficient * comparisonActiveCost source target (frontier d.val path)) : + (∫ ω, max ((physicalRefinement source target U N P F A T delta (choices ω) + (Sigma.mk (Fin.mk 0 (Nat.zero_lt_succ J)) PUnit.unit : PhysicalNode M J) S rootQ : ℝ) - + stateEditCost source target rootQ) 0 ∂μ) ≤ + ((8 * (M : ℝ) + 512 * F) * J / P + + (40000 * ratio * (F : ℝ) ^ 2 * (1 + (J : ℝ) / P + (J : ℝ) / T) + + 2 * J * (1 / ratio + 4 * (tau : ℝ) * F + coefficient)) / S) * + stateEditCost source target rootQ := by + classical + let budget := fun (d : ℕ) (path : TreeLayer M d) => if hd : d < J then + ∫ ω, (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) rootQ t ⟨d, hd⟩ path) ∂μ else 0 + have hnode (d : ℕ) (hd : d < J) (path : TreeLayer M d) : + (∫ ω, (∑ t ∈ range S, + (physicalClippedLift source target hM U N P F A hP T delta (choices ω) rootQ (t + 1) d path - + (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) - + ∑ i : Fin M, physicalClippedLift source target hM U N P F A hP T delta + (choices ω) rootQ (t + 1) (d + 1) (path, i))) ∂μ) ≤ budget d path := by + simp only [budget, dite_eq_left hd, physicalComparisonTreeRegret, le_refl] + have htelescope := physical_tree_expected_excess source target hM U N P F A hsize hP hF hA hseed + T hT delta choices rootQ μ S hS hcapacity hsmall budget hnode + have hsum := physical_comparison_expected_regret_sum source target hM U N P F A hsize hP hF hA hseed + T hT delta choices rootQ μ ratio hratio tau htau hscale hMP hcapacity hsmall S coefficient hcoef hgood + have heq : (∑ d ∈ range J, ∑ path : TreeLayer M d, budget d path) = + ∑ v : (Σ d : Fin J, TreeLayer M d.val), + ∫ ω, (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta + (choices ω) rootQ t v.1 v.2) ∂μ := by + rw [← treeLayer_sigma_sum M J budget] + apply sum_congr rfl + intro v _ + simp only [budget, dite_eq_left v.1.isLt] + rw [heq] at htelescope + have hroot : D = (stateEditCost source target rootQ : ℝ) := by + simp only [comparisonStateCost, sourceIntervalAt, substring, List.take_length, List.drop_zero] + rw [hroot] at hsum + have hdiv := div_le_div_of_nonneg_right hsum (Nat.cast_nonneg (α := ℝ) S) + calc + _ ≤ _ := htelescope + _ ≤ ((8 * (M : ℝ) + 512 * F) * J / P) * stateEditCost source target rootQ + + ((40000 * ratio * (F : ℝ) ^ 2 * (1 + (J : ℝ) / P + (J : ℝ) / T) + + 2 * J * (1 / ratio + 4 * (tau : ℝ) * F + coefficient)) * + stateEditCost source target rootQ) / S := add_le_add_right hdiv _ + _ = _ := by ring + +end Tree + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeExpectation.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc6cff8be63898a6c9c31907cdb62a34d793ded3 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeExpectation.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeRegret + +namespace OAI + +/-! Finite expectation of the actual clipped refinement telescope. -/ + +namespace EditApproximation + +open Finset MeasureTheory ProbabilityTheory + +section Expectation + +variable {α Ω : Type*} [DecidableEq α] [Fintype Ω] + [MeasurableSpace Ω] [MeasurableSingletonClass Ω] + {M J : ℕ} (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : Ω → PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (rootQ : TargetInterval target.length) + (μ : Measure Ω) [IsProbabilityMeasure μ] + +local notation "D" => (stateEditCost source target rootQ : ℝ) +local notation "root" => (Sigma.mk (Fin.mk 0 (Nat.zero_lt_succ J)) PUnit.unit : PhysicalNode M J) +local notation "lifted" => fun ω => physicalClippedLift source target hM U N P F A hP T delta (choices ω) rootQ +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) + +include hsize hF hA hseed hT in + theorem physical_tree_expected_excess (S : ℕ) (hS : 0 < S) + (hcapacity : source.length ≤ M ^ J) (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) + (budget : (d : ℕ) → TreeLayer M d → ℝ) + (hnode : ∀ d < J, ∀ path : TreeLayer M d, + (∫ ω, (∑ t ∈ range S, + (lifted ω (t + 1) d path - (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) - + ∑ i : Fin M, lifted ω (t + 1) (d + 1) (path, i))) ∂μ) ≤ budget d path) : + (∫ ω, max ((physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) - D) 0 ∂μ) ≤ + ((8 * (M : ℝ) + 512 * F) * J / P) * D + + (∑ d ∈ range J, ∑ path : TreeLayer M d, budget d path) / S := by + let charge := fun d (path : TreeLayer M d) => (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) + let regret := fun ω t d (path : TreeLayer M d) => + lifted ω (t + 1) d path - charge d path - ∑ i : Fin M, lifted ω (t + 1) (d + 1) (path, i) + let coefficient : ℝ := (8 * (M : ℝ) + 512 * F) * J / P + have hpoint (ω : Ω) := physical_tree_regret_time source target hM U N P F A hsize hP hF hA hseed + T hT delta (choices ω) rootQ S hcapacity hsmall + have hmean := integral_mono (μ := μ) (.of_finite) (.of_finite) hpoint + have hregret : (∫ ω, (∑ t ∈ range S, ∑ d ∈ range J, ∑ path : TreeLayer M d, regret ω t d path) ∂μ) ≤ + ∑ d ∈ range J, ∑ path : TreeLayer M d, budget d path := by + have hswap (ω : Ω) : (∑ t ∈ range S, ∑ d ∈ range J, ∑ path : TreeLayer M d, regret ω t d path) = + ∑ d ∈ range J, ∑ path : TreeLayer M d, ∑ t ∈ range S, regret ω t d path := by + rw [sum_comm] + apply sum_congr rfl + intro d _ + rw [sum_comm] + simp_rw [hswap] + rw [integral_finsetSum _ (by intro d hd; exact .of_finite)] + apply sum_le_sum + intro d hd + rw [integral_finsetSum _ (by intro path hp; exact .of_finite)] + exact sum_le_sum fun path _ => hnode d (mem_range.mp hd) path + have hroot : (∫ ω, max D + (physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) ∂μ) = + (∫ ω, max ((physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) - D) 0 ∂μ) + D := by + have heq (ω : Ω) : max D + (physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) = + max ((physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) - D) 0 + D := by + rw [← max_add_add_right, sub_add_cancel, zero_add, max_comm] + simp_rw [heq] + rw [integral_add (.of_finite) (integrable_const _), integral_const, probReal_univ, one_smul] + change (∫ ω, (S : ℝ) * max D + (physicalRefinement source target U N P F A T delta (choices ω) root S rootQ : ℝ) ∂μ) ≤ + (∫ ω, (S : ℝ) * ((1 + coefficient) * D) + + (∑ t ∈ range S, ∑ d ∈ range J, ∑ path : TreeLayer M d, regret ω t d path) ∂μ) at hmean + rw [integral_const_mul, integral_add (integrable_const _) (.of_finite), + integral_const, probReal_univ, one_smul, hroot] at hmean + have hSR : (0 : ℝ) < S := by exact_mod_cast hS + apply (sub_le_iff_le_add').mp + apply (le_div_iff₀ hSR).2 + nlinarith only [hmean, hregret] + +end Expectation + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeGeneric.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..e165137a3733650cce1f22d7139e40e543f99c5c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeGeneric.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalGenericRegret +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeRegret +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonBad + +namespace OAI + +/-! Generic cumulative regret at actual comparison-tree slots, including stopped slots. -/ + +namespace EditApproximation + +open Finset + +section Tree + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) +local notation "lifted" => physicalClippedLift source target hM U N P F A hP T delta choices rootQ + +noncomputable def physicalComparisonTreeRegret (t : ℕ) (d : Fin J) (path : TreeLayer M d.val) : ℝ := + lifted (t + 1) d.val path - (128 * (F : ℝ)) * comparisonMovement source target P (frontier d.val path) - + ∑ i : Fin M, lifted (t + 1) (d.val + 1) (path, i) + +include hM hsize hP hF hA hseed hT in + theorem physicalClippedTable_at_stopped (node : PhysicalNode M J) (q : TargetInterval target.length) + (hstop : comparisonStopped source target (physicalSourceInterval source.length node) q) (t : ℕ) : + physicalClippedTable source target U N P F A T delta choices t (node, q) = + stateEditCost (physicalSource source node) target q := by + have h := physicalRefinement_at_stopped source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q hstop + simp only [physicalClippedTable, h, Rat.cast_natCast, max_self] + + theorem physicalComparisonTreeRegret_none (t : ℕ) (d : Fin J) (path : TreeLayer M d.val) + (heq : frontier d.val path = none) : + physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t d path = 0 := by + have hnext (i : Fin M) : frontier (d.val + 1) (path, i) = none := by + change comparisonStep source target hM P hP (frontier d.val path) i = none + rw [heq] + rfl + simp only [physicalComparisonTreeRegret, physicalClippedLift, comparisonPhysicalLift, heq, hnext, + stoppedComparisonValue, comparisonMovement, mul_zero, sub_self, sum_const_zero] + + theorem physicalComparisonTreeRegret_stopped (t : ℕ) (d : Fin J) (path : TreeLayer M d.val) + (parent : TargetInterval source.length) (q : TargetInterval target.length) + (heq : frontier d.val path = some (parent, q)) (hstop : comparisonStopped source target parent q) : + physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t d path = 0 := by + classical + have hpoint (i : Fin M) : lifted (t + 1) (d.val + 1) (path, i) = + if i = ⟨0, hM⟩ then (stateEditCost (substring source parent.lo parent.hi) target q : ℝ) else 0 := by + unfold physicalClippedLift comparisonPhysicalLift + change stoppedComparisonValue source target _ + (comparisonStep source target hM P hP (frontier d.val path) i) = _ + rw [heq] + simp only [comparisonStep, dite_eq_left hstop] + split_ifs <;> simp only [stoppedComparisonValue, ite_eq_left hstop] + unfold physicalComparisonTreeRegret + simp_rw [hpoint] + simp only [physicalClippedLift, comparisonPhysicalLift, heq, stoppedComparisonValue, ite_eq_left hstop, + comparisonMovement, mul_zero, sub_zero, sum_ite_eq', mem_univ, ite_true, sub_self] + +include hsize hF hA hseed hT in + theorem physicalComparisonTreeRegret_active (t : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (q : TargetInterval target.length) + (heq : frontier node.1.val node.2 = some (physicalSourceInterval source.length node, q)) + (hactive : ¬ comparisonStopped source target (physicalSourceInterval source.length node) q) : + let hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + unfold comparisonStopped at hactive + omega + let r := roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q)) P) q + physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t ⟨node.1.val, hbelow⟩ node.2 = + max (stateEditCost (physicalSource source node) target q : ℝ) + (physicalRefinement source target U N P F A T delta choices node (t + 1) q : ℝ) - + (128 * (F : ℝ)) * targetEndpointDistance q r - + physicalComparisonClipped source target U N P F A T delta choices node hbelow + (comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc) (t + 1) := by + classical + dsimp only + have hnext (i : Fin M) := comparisonPhysicalLift_step_active source target hM P hP + (physicalClippedTable source target U N P F A T delta choices (t + 1)) + (fun label s hstop => physicalClippedTable_at_stopped source target hM U N P F A hsize hP hF hA hseed + T hT delta choices label s hstop (t + 1)) rootQ node hbelow q heq hactive i + have hcurrent : comparisonPhysicalLift source target hM P hP + (physicalClippedTable source target U N P F A T delta choices (t + 1)) rootQ node.1.val node.2 = + physicalClippedTable source target U N P F A T delta choices (t + 1) (node, q) := by + unfold comparisonPhysicalLift + rw [heq] + simp only [stoppedComparisonValue, ite_eq_right hactive] + rw [dite_eq_left (by omega : node.1.val ≤ J)] + have hmovement : comparisonMovement source target P (frontier node.1.val node.2) = + targetEndpointDistance q (roundInterval (seedGridSpacing + (2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q)) P) q) := by + rw [heq] + simp only [comparisonMovement, ite_eq_right hactive] + rfl + unfold physicalComparisonTreeRegret physicalClippedLift + rw [hcurrent, hmovement] + simp_rw [hnext] + rfl + +include hsize hF hA hseed hT in + theorem physicalComparisonTreeRegret_generic (hMP : 4 * (M : ℝ) / P ≤ 1) + (S : ℕ) (d : Fin J) (path : TreeLayer M d.val) : + (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t d path) ≤ + 4 * F * comparisonActiveCost source target (frontier d.val path) := by + classical + generalize heq : frontier d.val path = state + cases state with + | none => + simp only [physicalComparisonTreeRegret_none source target hM U N P F A hP T delta choices rootQ + _ d path heq, sum_const_zero, comparisonActiveCost, mul_zero, le_refl] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · simp only [physicalComparisonTreeRegret_stopped source target hM U N P F A hP T delta choices rootQ + _ d path parent q heq hstop, sum_const_zero, comparisonActiveCost, ite_eq_left hstop, mul_zero, le_refl] + · have hp := comparisonFrontier_active_source source target hM P hP rootQ d.val path parent q heq hstop + let node : PhysicalNode M J := ⟨⟨d.val, by omega⟩, path⟩ + have hp' : parent = physicalSourceInterval source.length node := hp + subst parent + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + change ¬ ((physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 ∨ + stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q = 0) at hstop + omega + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + have h := physicalNode_generic_regret_upper source target hM U N P F A hsize hP hF hA hseed T hT + delta choices node d.isLt hleaf q hc hMP S + have hpoint (t : ℕ) : physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t d path = _ := + physicalComparisonTreeRegret_active source target hM U N P F A hsize hP hF hA hseed + T hT delta choices rootQ t node d.isLt q heq hstop + simp_rw [hpoint] + simpa only [comparisonActiveCost, ite_eq_right hstop, physicalSource, physicalSourceInterval, node] using h + +include hsize hF hA hseed hT in + theorem physicalComparisonBadRegret_bound (ratio : ℝ) (hratio : 0 ≤ ratio) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hcapacity : source.length ≤ M ^ J) (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) (S : ℕ) : + (∑ v : (Σ d : Fin J, TreeLayer M d.val) with + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).2, + ∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t v.1 v.2) ≤ + 40000 * ratio * (F : ℝ) ^ 2 * (1 + (J : ℝ) / P + (J : ℝ) / T) * + comparisonStateCost source target (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) := by + classical + have htotal := stageComparisonBadCost_bound source target hM U N P F A hsize hP hF hA hseed + T hT rootQ ratio hratio hscale hcapacity hsmall + have hpoint := fun (v : Σ d : Fin J, TreeLayer M d.val) => + physicalComparisonTreeRegret_generic source target hM U N P F A hsize hP hF hA hseed + T hT delta choices rootQ hMP S v.1 v.2 + apply (sum_le_sum (fun v _ => hpoint v)).trans + rw [← mul_sum] + have h := mul_le_mul_of_nonneg_left htotal (show (0 : ℝ) ≤ 4 * F by positivity) + unfold stageComparisonBadCost at h + convert h using 1 + ring + +end Tree + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeNear.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeNear.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0bf6ee63da79b6e1d59d206a142000eed3d7272 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeNear.lean @@ -0,0 +1,145 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalTreeGeneric +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonPrediction + +namespace OAI + +/-! Actual non-bad nodes with near-unit length-gap prediction have small regret. -/ + +namespace EditApproximation + +open Finset + +section Tree + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) +local notation "charges" => stageComparisonCharges source target hM U N P F A hP T rootQ +local notation "prediction" => stageComparisonPrediction source target hM U N P F A hP T rootQ + +include hsize hF hA hseed hT in + theorem physicalComparisonTreeRegret_near (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (S : ℕ) (d : Fin J) (path : TreeLayer M d.val) + (hnotbad : ¬ (comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).1 ∨ + comparisonActiveScale source target (frontier d.val path) < ratio * (charges d path).2)) + (hnear : 1 - tau < |prediction d path|) : + (∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t d path) ≤ + (1 / ratio + 4 * (tau : ℝ) * F) * comparisonActiveCost source target (frontier d.val path) := by + classical + generalize heq : frontier d.val path = state at hnotbad ⊢ + cases state with + | none => + simp only [physicalComparisonTreeRegret_none source target hM U N P F A hP T delta choices rootQ + _ d path heq, sum_const_zero, comparisonActiveCost, mul_zero, le_refl] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · simp only [physicalComparisonTreeRegret_stopped source target hM U N P F A hP T delta choices rootQ + _ d path parent q heq hstop, sum_const_zero, comparisonActiveCost, ite_eq_left hstop, mul_zero, le_refl] + · have hp := comparisonFrontier_active_source source target hM P hP rootQ d.val path parent q heq hstop + let node : PhysicalNode M J := ⟨⟨d.val, by omega⟩, path⟩ + have hp' : parent = physicalSourceInterval source.length node := hp + subst parent + change ¬ comparisonStopped source target (physicalSourceInterval source.length node) q at hstop + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q + change ¬ ((physicalSourceInterval source.length node).hi - (physicalSourceInterval source.length node).lo ≤ 1 ∨ + stateEditCost (substring source (physicalSourceInterval source.length node).lo + (physicalSourceInterval source.length node).hi) target q = 0) at hstop + omega + let b : ℕ := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc + let child := physicalBandChildMassTable source target U N P F A T node d.isLt + have hspec := comparisonChildren_spec source target hM P hP (physicalSourceInterval source.length node) q hc + have hn : wideActionList M (physicalSourceInterval source.length node) r b P ≠ [] := by + intro hnil + have hmem := hspec.1 + change action ∈ wideActionList M (physicalSourceInterval source.length node) r b P at hmem + rw [hnil] at hmem + exact List.not_mem_nil hmem + have hcharges := stageComparisonCharges_active source target hM U N P F A hP T rootQ d path q heq hstop hc hn + have hprediction := stageComparisonPrediction_active source target hM U N P F A hP T rootQ d path q heq hstop hn + have hG := (nonbad_charge_bounds _ ratio _ _ hratio hnotbad).2 + change (charges d path).2 ≤ comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) / ratio at hG + have hscaleEq : comparisonActiveScale source target + (some (physicalSourceInterval source.length node, q)) = (b : ℝ) := by + simp only [comparisonActiveScale, ite_eq_right hstop] + rfl + rw [hscaleEq, hcharges] at hG + have hb : (b : ℝ) ≤ stateEditCost (physicalSource source node) target q := by + exact_mod_cast (cost_dyadicScale _ _ hc le_rfl).2.1 + have hGcost : comparisonActionMass action (fun i s => (child i s : ℝ)) - + wideActionMinimum (physicalSourceInterval source.length node) r b P hn (fun i s => (child i s : ℝ)) ≤ + (1 / ratio) * stateEditCost (physicalSource source node) target q := by + have h := hG.trans (div_le_div_of_nonneg_right hb hratio.le) + simpa only [one_div_mul_eq_div, action, child, r, b, node, + physicalSource, physicalSourceInterval] using h + rw [hprediction] at hnear + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + have h := physicalNode_near_length_gap_regret source target hM U N P F A hsize hP hF hA hseed T hT + delta choices node d.isLt hleaf q hc hscale hMP hn tau htau hnear (1 / ratio) hGcost S + have hpoint (t : ℕ) : physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t d path = _ := + physicalComparisonTreeRegret_active source target hM U N P F A hsize hP hF hA hseed + T hT delta choices rootQ t node d.isLt q heq hstop + simp_rw [hpoint] + have hstop' : ¬ comparisonStopped source target (sourceIntervalAt M source.length d.val path) q := hstop + simpa only [comparisonActiveCost, ite_eq_right hstop', physicalSource, physicalSourceInterval, node] using h + +include hsize hF hA hseed hT in + theorem physicalComparisonNearRegret_bound (ratio : ℝ) (hratio : 0 < ratio) + (tau : ℚ) (htau : 0 ≤ tau) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hMP : 4 * (M : ℝ) / P ≤ 1) + (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) (S : ℕ) : + (∑ v : (Σ d : Fin J, TreeLayer M d.val) with + (¬ (comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).2)) ∧ + 1 - tau < |prediction v.1 v.2|, + ∑ t ∈ range S, physicalComparisonTreeRegret source target hM U N P F A hP T delta choices rootQ t v.1 v.2) ≤ + 2 * (J : ℝ) * (1 / ratio + 4 * (tau : ℝ) * F) * + comparisonStateCost source target (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) := by + classical + let coefficient : ℝ := 1 / ratio + 4 * (tau : ℝ) * F + have hcoef : 0 ≤ coefficient := add_nonneg (div_nonneg zero_le_one hratio.le) + (mul_nonneg (mul_nonneg (by norm_num) ((Rat.cast_nonneg (K := ℝ)).mpr htau)) (Nat.cast_nonneg _)) + have hcost : (∑ v : (Σ d : Fin J, TreeLayer M d.val), comparisonActiveCost source target (frontier v.1.val v.2)) ≤ + 2 * J * comparisonStateCost source target (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) := by + have heq := treeLayer_sigma_sum M J (fun (d : ℕ) (path : TreeLayer M d) => + comparisonActiveCost source target (frontier d path)) + exact heq.le.trans (comparison_total_active_cost_bound source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) J hsmall) + apply (sum_le_sum (fun v hv => physicalComparisonTreeRegret_near source target hM U N P F A hsize hP hF hA hseed + T hT delta choices rootQ ratio hratio tau htau hscale hMP S v.1 v.2 + (mem_filter.mp hv).2.1 (mem_filter.mp hv).2.2)).trans + rw [← mul_sum] + have hsub : (∑ v : (Σ d : Fin J, TreeLayer M d.val) with + (¬ (comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < ratio * (charges v.1 v.2).2)) ∧ + 1 - tau < |prediction v.1 v.2|, + comparisonActiveCost source target (frontier v.1.val v.2)) ≤ + ∑ v : (Σ d : Fin J, TreeLayer M d.val), comparisonActiveCost source target (frontier v.1.val v.2) := by + exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + (fun v _ _ => (comparisonActiveCost_bounds source target _).1) + have h := mul_le_mul_of_nonneg_left (hsub.trans hcost) hcoef + convert h using 1 + ring + +end Tree + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeRegret.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeRegret.lean new file mode 100644 index 0000000000000000000000000000000000000000..48be497f24c8e6968df4a4063d0a262f940f624a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalTreeRegret.lean @@ -0,0 +1,130 @@ +import OAI.Combinatorics.EditApproximation.Geometry.ComparisonLift +import OAI.Combinatorics.EditApproximation.Refinement.StageTerminal +import OAI.Combinatorics.EditApproximation.Geometry.ComparisonAccounting + +namespace OAI + +/-! The time and comparison-tree telescope for the actual clipped refinement values. -/ + +namespace EditApproximation + +open Finset + +theorem comparisonPhysicalLift_mono {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (hP : 66 ≤ P) + (table table' : PhysicalEntry M J target.length → ℝ) (hle : table ≤ table') + (rootQ : TargetInterval target.length) (d : ℕ) (path : TreeLayer M d) : + comparisonPhysicalLift source target hM P hP table rootQ d path ≤ + comparisonPhysicalLift source target hM P hP table' rootQ d path := by + classical + unfold comparisonPhysicalLift stoppedComparisonValue + generalize comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) d path = state + cases state with + | none => exact le_rfl + | some state => + rcases state with ⟨parent, q⟩ + dsimp only + split_ifs + · exact le_rfl + · exact hle _ + · exact le_rfl + +section Refinement + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (rootQ : TargetInterval target.length) + +noncomputable def physicalClippedTable (t : ℕ) (state : PhysicalEntry M J target.length) : ℝ := + max (stateEditCost (physicalSource source state.1) target state.2) + (physicalRefinement source target U N P F A T delta choices state.1 t state.2 : ℝ) + +noncomputable def physicalClippedLift (t d : ℕ) (path : TreeLayer M d) : ℝ := + comparisonPhysicalLift source target hM P hP + (physicalClippedTable source target U N P F A T delta choices t) rootQ d path + +local notation "lifted" => physicalClippedLift source target hM U N P F A hP T delta choices rootQ +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) + + theorem physicalClippedLift_antitone (d : ℕ) (path : TreeLayer M d) : Antitone (fun t => lifted t d path) := by + apply antitone_nat_of_succ_le + intro t + apply comparisonPhysicalLift_mono + intro state + apply max_le_max_left + exact Rat.cast_le.mpr (physicalRefinement_nonincreasing source target U N P F A T delta choices state.1 t state.2) + +include hsize hF hA hseed hT in + theorem physicalClippedLift_root (t : ℕ) : lifted t 0 PUnit.unit = + max (stateEditCost source target rootQ : ℝ) + (physicalRefinement source target U N P F A T delta choices + (⟨⟨0, by omega⟩, PUnit.unit⟩ : PhysicalNode M J) t rootQ : ℝ) := by + have h := comparisonPhysicalLift_root source target hM P hP + (physicalClippedTable source target U N P F A T delta choices t) + (fun node q hstop => by + have heq := physicalRefinement_at_stopped source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q hstop + simp only [physicalClippedTable, heq, Rat.cast_natCast, max_self]) rootQ + simpa only [physicalClippedLift, physicalClippedTable, physicalSource, physicalSourceInterval, + sourceIntervalAt, substring, List.take_length, List.drop_zero] using h + + theorem physicalClippedLift_terminal (t : ℕ) (hcapacity : source.length ≤ M ^ J) (path : TreeLayer M J) : + lifted t J path = comparisonStateCost source target (frontier J path) := + comparisonPhysicalLift_terminal source target hM P hP _ rootQ hcapacity path + +include hsize hF hA hseed hT in + theorem physical_tree_regret_time (S : ℕ) (hcapacity : source.length ≤ M ^ J) + (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) : + (S : ℝ) * max (stateEditCost source target rootQ : ℝ) + (physicalRefinement source target U N P F A T delta choices + (⟨⟨0, by omega⟩, PUnit.unit⟩ : PhysicalNode M J) S rootQ : ℝ) ≤ + (S : ℝ) * ((1 + (8 * (M : ℝ) + 512 * F) * J / P) * stateEditCost source target rootQ) + + ∑ t ∈ range S, ∑ d ∈ range J, ∑ path : TreeLayer M d, + (lifted (t + 1) d path - (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) - + ∑ i : Fin M, lifted (t + 1) (d + 1) (path, i)) := by + let D : ℝ := stateEditCost source target rootQ + let charge := fun d (path : TreeLayer M d) => (128 * (F : ℝ)) * comparisonMovement source target P (frontier d path) + let terminal := (1 + 8 * (M : ℝ) * J / P) * D + have hrootCost : comparisonStateCost source target + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) = D := by + simp only [comparisonStateCost, sourceIntervalAt, substring, List.take_length, List.drop_zero, D] + have hterminal (t : ℕ) (_ht : t < S) : (∑ path : TreeLayer M J, lifted (t + 1) J path) ≤ terminal := by + simp_rw [physicalClippedLift_terminal source target hM U N P F A hP T delta choices rootQ (t + 1) hcapacity] + have h := comparison_frontier_cost_slack source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) J hsmall + rw [hrootCost] at h + exact h + have htime := tree_regret_time_bound M J S lifted charge terminal + (fun t ht => physicalClippedLift_antitone source target hM U N P F A hP T delta choices rootQ + 0 PUnit.unit (by omega)) hterminal + rw [physicalClippedLift_root source target hM U N P F A hsize hP hF hA hseed T hT delta choices rootQ S] at htime + have hmovement := comparison_total_movement_bound source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) J hsmall + rw [hrootCost] at hmovement + have hcharge : (∑ d ∈ range J, ∑ path : TreeLayer M d, charge d path) ≤ 512 * F * J * D / P := by + dsimp only [charge] + simp only [← mul_sum] + have h := mul_le_mul_of_nonneg_left hmovement + (show (0 : ℝ) ≤ 128 * F from mul_nonneg (by norm_num) (Nat.cast_nonneg _)) + convert h using 1 + ring + have hterm : terminal + (∑ d ∈ range J, ∑ path : TreeLayer M d, charge d path) ≤ + (1 + (8 * (M : ℝ) + 512 * F) * J / P) * D := by + calc + _ ≤ terminal + 512 * F * J * D / P := add_le_add_right hcharge terminal + _ = _ := by dsimp only [terminal]; ring + exact htime.trans (add_le_add_left (mul_le_mul_of_nonneg_left hterm (Nat.cast_nonneg S)) _) + +end Refinement + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalUniformAccuracy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalUniformAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3cd53a0e8ecca24502b8048d2594b71529cb7bd --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalUniformAccuracy.lean @@ -0,0 +1,151 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalFamilyRuntime +import OAI.Combinatorics.EditApproximation.Geometry.AccuracyPrefixInspection +import OAI.Combinatorics.EditApproximation.Geometry.AccuracyCutoff +import OAI.Combinatorics.EditApproximation.Probability.ExactSuffixDP +import OAI.Combinatorics.EditApproximation.Refinement.ComputedSourceAddressBits +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditApproximation + +open MeasureTheory ProbabilityTheory Filter + +/-- Every test is on a bounded word prefix or on the computed input +parameters. Rejected inputs use the exact suffix dynamic program. -/ + + + + + theorem physicalLargeInput_eventually (epsilon : BinaryFraction) (hepsilon : 0 < epsilon.value) : + ∀ᶠ N in atTop, physicalLargeInput N epsilon := by + filter_upwards [inspectAccuracy_eventually_accepts epsilon, + eventually_ge_atTop (accuracyCutoff epsilon.value), computed_localOnlineMassBound_word] with N hi hc hw + exact ⟨by rw [hi]; rfl, accuracyCutoff_sufficient N epsilon.value hepsilon hc, hw⟩ + +section Uniform + +variable {α : Type} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] + (source target : List α) (N P T S H B : ℕ) + [NeZero B] [MeasurableSpace (Fin B)] [MeasurableSingletonClass (Fin B)] + (depth : PhysicalEntry M J target.length → ℕ) + +local notation "passes" => computedSeedPassCount N +local notation "ell" => inputSmallLog N +local notation "exponent" => (40 * smallLogExponent N : ℕ) +local notation "Key" => PhysicalFamilyScalarKey (M := M) (J := J) (R := R) + target N P ell exponent H (ell ^ 80) passes (H ^ 2) +local notation "Table" => ChargedPhysicalRequest M J target.length (passes + 1) (H ^ 2) T S + +abbrev PhysicalUniformOutcome := Unit ⊕ PhysicalFamilyRuntimeOutcome (M := M) (J := J) (R := R) + target N P H + +instance physicalUniformOutcome_measurableSingleton : + MeasurableSingletonClass (PhysicalUniformOutcome (M := M) (J := J) (R := R) target N P H) := by + refine ⟨fun outcome => ?_⟩ + exact measurableSet_sum_iff.mpr + ⟨(Set.to_countable _).measurableSet, (Set.to_countable _).measurableSet⟩ + +noncomputable def physicalUniformLaw (epsilon : BinaryFraction) : + Measure (PhysicalUniformOutcome (M := M) (J := J) (R := R) target N P H) := + if physicalLargeInput N epsilon then + (physicalFamilyRuntimeLaw (R := R) target N P H + (physicalCoarseSeedLaw source target N B depth)).map Sum.inr + else Measure.dirac (Sum.inl ()) + +instance physicalUniformLaw_probability (epsilon : BinaryFraction) : + IsProbabilityMeasure (physicalUniformLaw (R := R) source target N P H B depth epsilon) := by + classical + unfold physicalUniformLaw + split <;> infer_instance + +noncomputable def physicalUniformAnswer (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) + (outcome : PhysicalUniformOutcome (M := M) (J := J) (R := R) target N P H) : ℕ := + match outcome with + | .inl _ => exactSuffixAnswer source target + | .inr execution => physicalFamilyRuntimeAnswer source target N P T S H hH bits encode + (finalTargetState target.length) execution + + theorem physicalUniformAnswer_equal (hH : 0 < H) (bits : ℕ) (encode : Sum Key Table → ℕ) + (heq : source = target) + (outcome : PhysicalUniformOutcome (M := M) (J := J) (R := R) target N P H) : + physicalUniformAnswer source target N P T S H hH bits encode outcome = 0 := by + cases outcome with + | inl unitValue => exact exactSuffixAnswer_equal source target heq + | inr execution => + unfold physicalUniformAnswer physicalFamilyRuntimeAnswer physicalFamilyMemoAnswer + have htarget : source = substring target (finalTargetState target.length).lo + (finalTargetState target.length).hi := by simpa [finalTargetState, substring] using heq + dsimp only + rw [ite_eq_left htarget] + +/-- Uniform correctness of the memo evaluator driven by rejection trials, +under finite Bernstein bounds for coarse and group coordinates. -/ +theorem physical_uniform_conditional_accuracy (epsilon : BinaryFraction) (hH : 0 < H) (bits : ℕ) + (encode : Sum Key Table → ℕ) + (hcode : physicalLargeInput N epsilon → Function.Injective encode) + (hfits : physicalLargeInput N epsilon → ∀ key, encode key < 2 ^ bits) + (hsize : source.length + target.length ≤ N) + (hMeq : M = (integerParameters N).M) (hJeq : J = intervalTreeDepth M source.length) + (hPeq : P = (integerParameters N).P) (hTeq : T = (integerParameters N).T) + (hSeq : S = (integerParameters N).S) (hHeq : H = inputHeight N) + (hB : B = (integerParameters N).B) + (hdepth : ∀ state, depth state = computedCoarseDepth N + (coarseEntryWidth (physicalSource source state.1) (substring target state.2.lo state.2.hi))) + (coarseBernstein : FiniteBernsteinInput (Measure.pi fun _ : Fin B => + (PMF.uniformOfFintype (Fin B)).toMeasure)) + (groupBernstein : ∀ b : ℕ, ∀ h : Fin (groupDyadicScales M b ell).length, + FiniteBernsteinInput (Measure.pi fun _ : Fin + (groupSampleCount M (ell ^ 80) b (groupDyadicScaleAt M b ell h)) => + (PMF.uniformOfFintype (Fin M)).toMeasure)) + (hepsilon : 0 < epsilon.value) : + (2 / 3 : ℝ) ≤ (physicalUniformLaw (R := R) source target N P H B depth epsilon).real + {outcome | EditDistortion.edit source target ≤ + physicalUniformAnswer source target N P T S H hH bits encode outcome ∧ + (physicalUniformAnswer source target N P T S H hH bits encode outcome : ℝ) ≤ + (1 + (epsilon.value : ℝ)) * EditDistortion.edit source target} := by + classical + by_cases hlarge : physicalLargeInput N epsilon + · have hN := largeAccuracyInput_pos N epsilon.value hlarge.2.1 + have hreal := largeAccuracyInput_real N epsilon.value hlarge.2.1 + have hepsilonR : (0 : ℝ) < epsilon.value := by exact_mod_cast hepsilon + have hPpos : 0 < P := by + rw [hPeq] + exact Nat.pow_pos (Nat.two_pow_pos _) + rw [physicalUniformLaw, ite_eq_left hlarge, + map_measureReal_apply (by fun_prop) (Set.to_countable _).measurableSet] + change (2 / 3 : ℝ) ≤ (physicalFamilyRuntimeLaw (R := R) target N P H + (physicalCoarseSeedLaw source target N B depth)).real + {execution | EditDistortion.edit source target ≤ + physicalFamilyRuntimeAnswer source target N P T S H hH bits encode + (finalTargetState target.length) execution ∧ + (physicalFamilyRuntimeAnswer source target N P T S H hH bits encode + (finalTargetState target.length) execution : ℝ) ≤ + (1 + (epsilon.value : ℝ)) * EditDistortion.edit source target} + have hevent := physicalFamilyRuntimeAnswer_event source target N P T S H hPpos hH bits encode + (hcode hlarge) (hfits hlarge) (physicalCoarseSeedLaw source target N B depth) + (finalTargetState target.length) + {answer | EditDistortion.edit source target ≤ answer ∧ + (answer : ℝ) ≤ (1 + (epsilon.value : ℝ)) * EditDistortion.edit source target} + simp only [Set.mem_ofPred_eq] at hevent + rw [hevent] + exact local_physical_conditional_accuracy source target N P T S H B depth hN hreal.1 + hsize hMeq hJeq hPeq hTeq hSeq hHeq hB hdepth coarseBernstein groupBernstein + (epsilon.value : ℝ) hepsilonR hreal.2 + · rw [physicalUniformLaw, ite_eq_right hlarge] + have hgood : (Sum.inl () : PhysicalUniformOutcome (M := M) (J := J) (R := R) target N P H) ∈ + {outcome | EditDistortion.edit source target ≤ + physicalUniformAnswer source target N P T S H hH bits encode outcome ∧ + (physicalUniformAnswer source target N P T S H hH bits encode outcome : ℝ) ≤ + (1 + (epsilon.value : ℝ)) * EditDistortion.edit source target} := + exactSuffixAnswer_approximation source target epsilon.value (by exact_mod_cast hepsilon.le) + rw [Measure.real, Measure.dirac_apply_of_mem hgood, ENNReal.toReal_one] + norm_num + +end Uniform + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalUnskippedComparison.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalUnskippedComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..59c2a43014ed8eef1cd9d3c16d7f300beae0b8f1 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalUnskippedComparison.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalOnlineBand +import OAI.Combinatorics.EditApproximation.Geometry.CellGroupSelection + +namespace OAI + +/-! A comparison action in the physical band passes all literal guards and belongs to its whole cell. -/ + +namespace EditApproximation + +open Finset + +theorem representativeList_grid_eligibility {n N P F b : ℕ} (a : ℚ) + (initial : TargetInterval n → ℚ) (r : TargetInterval n) + (hrep : (b, r) ∈ representativeList N P F a initial) : + (seedGridSpacing b P ∣ r.lo ∧ seedGridSpacing b P ∣ r.hi) ∧ + (b : ℚ) / (4 * a) ≤ initial r ∧ initial r ≤ 8 * F * b := by + obtain ⟨bb, _, hmem⟩ := List.mem_flatMap.mp hrep + obtain ⟨rr, hrr, heq⟩ := List.mem_map.mp hmem + have hb : bb = b := congrArg Prod.fst heq + have hr : rr = r := congrArg Prod.snd heq + subst bb rr + have h := of_decide_eq_true (List.mem_filter.mp hrr).2 + exact ⟨⟨h.1, h.2.1⟩, h.2.2⟩ + +theorem physical_comparison_unskipped {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (b thetaExponent : ℕ) (hb : 0 < b) (hbPower : ∃ e : ℕ, b = 2 ^ e) + (hPPower : ∃ e : ℕ, P = 2 ^ e) (tau : ℚ) (htau : 0 < tau) + (htheta : (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ 1 / 2) + (hsmall : (32 * F : ℚ) * (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ 1) + (hsmall64 : (64 * F : ℚ) * (2 : ℚ) ^ (-(thetaExponent : ℤ)) ≤ 4) + (hscale : (M : ℚ) ≤ (2 : ℚ) ^ (-(thetaExponent : ℤ)) * P) + (r : TargetInterval target.length) (hrep : (b, r) ∈ stageRepresentatives source target U N P F A node) + (comparison : Fin M → TargetInterval target.length) + (hcomparison : comparison ∈ representativeBandActions source target (physicalSourceInterval source.length node) + r b P tau ((2 : ℚ) ^ (-(thetaExponent : ℤ))) + (physicalBandChildMassTable source target U N P F A T node hbelow)) + (hcost : (∑ i, (stateEditCost (physicalSource source (physicalChild node hbelow i)) target (comparison i) : ℚ)) ≤ + 4 * b) : + ∃ member : UnskippedBand source target (physicalSourceInterval source.length node) b P thetaExponent tau F + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow), + member ∈ cellUnskippedBands source target (physicalSourceInterval source.length node) + b P F thetaExponent tau (refinementFactor A F) + (fun s => stageInitial source target U N P F A (node, s)) + (physicalBandChildMassTable source target U N P F A T node hbelow) + (physicalBandChildInitial source target U N P F A node hbelow) + (targetCell ((2 : ℚ) ^ (-(thetaExponent : ℤ)) * b) r) ∧ + member.center = r ∧ comparison ∈ member.actions := by + let parent := physicalSourceInterval source.length node + let theta : ℚ := (2 : ℚ) ^ (-(thetaExponent : ℤ)) + let child := physicalBandChildMassTable source target U N P F A T node hbelow + let initial := physicalBandChildInitial source target U N P F A node hbelow + let band := representativeBandActions source target parent r b P tau theta child + change comparison ∈ band at hcomparison + have htheta0 : 0 < theta := zpow_pos (by norm_num : (0 : ℚ) < 2) _ + have hband : band ≠ [] := by + intro hnil + have h := hcomparison + change comparison ∈ band at h + rw [hnil] at h + exact List.not_mem_nil h + by_cases hwide : wideActionList M parent r b P = [] + · simp only [band, representativeBandActions, dite_eq_left hwide, List.not_mem_nil] at hcomparison + · by_cases hZ : 0 < rationalWideActionMinimum parent r b P hwide child + · let velocity := rationalStateGap (substring source parent.lo parent.hi) target r / + rationalWideActionMinimum parent r b P hwide child + let computed := computedBandActions parent r b P tau theta velocity child + have heq : band = computed := by + simp only [band, representativeBandActions, dite_eq_right hwide, ite_eq_left hZ, computed, velocity] + have hc : comparison ∈ computed := heq ▸ hcomparison + have hcn : computed ≠ [] := by rw [← heq]; exact hband + have hfactor := refinementFactor_spec A F (by omega) + have hinitial := physicalInitialTable_bounds source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed + have hgap (i : Fin M) (s : TargetInterval target.length) : + |rationalStateGap (physicalSource source (physicalChild node hbelow i)) target s| ≤ initial i s := by + exact (le_max_right _ _).trans (hinitial (physicalChild node hbelow i, s)).1 + have hinonneg (i : Fin M) : 0 ≤ initial i (comparison i) := (abs_nonneg _).trans (hgap i _) + have hispatial (i : Fin M) (s t : TargetInterval target.length) : + initial i s ≤ initial i t + (32 * F : ℚ) * targetEndpointDistance s t := + physicalInitialTable_spatial source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed (physicalChild node hbelow i) s t + have hiupper (i : Fin M) : initial i (comparison i) ≤ + 2 * F * stateEditCost (physicalSource source (physicalChild node hbelow i)) target (comparison i) := + (hinitial (physicalChild node hbelow i, comparison i)).2 + have hsumC := bandChildEnvelope_sum_guard source target parent r b P hb hM tau theta velocity + htau htheta0.le child initial comparison hc (32 * F) F (by positivity) + (by exact_mod_cast hF) hsmall hinonneg hispatial hiupper hcost + have hsum : (∑ i, bandChildEnvelope b band initial i) ≤ 64 * F * b := by + rw [heq] + exact hsumC + have hguards := roundedBandAction_guards source target parent r thetaExponent tau velocity child initial + (computed.head hcn) (List.head_mem hcn) hM (by omega) hbPower hPPower hscale F hsmall64 htheta hgap hsumC + have hcanonical : canonicalRoundedBandAction thetaExponent b band hband initial = + roundedBandAction thetaExponent b computed initial (computed.head hcn) := + canonicalRoundedBandAction_congr thetaExponent b band computed hband hcn initial heq + have hwideGuard : canonicalRoundedBandAction thetaExponent b band hband initial ∈ wideActionList M parent r b P := by + rw [hcanonical] + exact hguards.1 + have hgapGuard : ∀ i, |rationalStateGap (physicalSource source (physicalChild node hbelow i)) target + (canonicalRoundedBandAction thetaExponent b band hband initial i)| ≤ 2 * bandChildEnvelope b band initial i := by + intro i + rw [hcanonical, heq] + exact hguards.2 i + let member : UnskippedBand source target parent b P thetaExponent tau F child initial := + ⟨r, hband, hsum, hwideGuard, hgapGuard⟩ + refine ⟨member, ?_, rfl, hcomparison⟩ + apply (unskippedBandList_mem_iff _ member).mpr + have hgrid := representativeList_grid_eligibility (refinementFactor A F) + (fun s => stageInitial source target U N P F A (node, s)) r hrep + exact cellRepresentativeStates_contains _ _ theta r (mul_pos htheta0 (by exact_mod_cast hb)) hgrid.1 hgrid.2 + · simp only [band, representativeBandActions, dite_eq_right hwide, ite_eq_right hZ, List.not_mem_nil] at hcomparison + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalValueBits.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalValueBits.lean new file mode 100644 index 0000000000000000000000000000000000000000..71efda0b18b736f6c06ef3a677b2a483e113232b --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalValueBits.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalDenominator +import OAI.Combinatorics.EditApproximation.Numerics.NumericalWork + +namespace OAI + +/-! Explicit bit bounds for the actual returned physical table values. -/ + +namespace EditApproximation + +theorem rationalEncodingBits_of_den_dvd (r : ℚ) (V D : ℕ) + (hV : |r| ≤ V) (hD : 0 < D) (hden : r.den ∣ D) : + rationalEncodingBits r ≤ Nat.size V + 2 * Nat.size D + 1 := by + have hdenSize := Nat.size_le_size (Nat.le_of_dvd hD hden) + have hnumSize := (Nat.size_le_size (rational_numerator_bound r V hV)).trans + (natural_product_bit_length V r.den) + unfold rationalEncodingBits + omega + +theorem physicalRefinement_encoding_bits {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (T ell : ℕ) (hell : 0 < ell) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) (t : ℕ) + (q : TargetInterval target.length) : + rationalEncodingBits (physicalRefinement source target U N P F A T + (1 / (ell : ℚ) ^ 10) choices node t q) ≤ + Nat.size ((32 * F + 1) * N) + + 2 * (J - node.1.val) * Nat.size (ell ^ 10 + 1) + 3 := by + let value := physicalRefinement source target U N P F A T (1 / (ell : ℚ) ^ 10) choices node t q + have hnonneg : 0 ≤ value := physicalRefinement_nonneg_all_seeds source target U N P F A T _ choices node t q + have hupper : value ≤ (((32 * F + 1) * N : ℕ) : ℚ) := by + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using + physicalRefinement_upper_all_seeds source target U N P F A hsize T _ choices node t q + have h := rationalEncodingBits_of_den_dvd value ((32 * F + 1) * N) + ((ell ^ 10 + 1) ^ (J - node.1.val)) (by rw [abs_of_nonneg hnonneg]; exact hupper) + (pow_pos (by omega) _) (physicalRefinement_den_dvd source target U N P F A T ell hell choices node t q) + have hpower := natural_power_bit_length (ell ^ 10 + 1) (J - node.1.val) + have hpowerTwice := Nat.mul_le_mul_left 2 hpower + simp only [Nat.mul_add, Nat.mul_one, ← Nat.mul_assoc] at hpowerTwice + change rationalEncodingBits value ≤ _ + omega + +theorem refinement_denominator_base_bits (ell : ℕ) : + Nat.size (ell ^ 10 + 1) ≤ 10 * Nat.size ell + 3 := by + have hsum := natural_sum_bit_length (ell ^ 10) 1 + have hpower := natural_power_bit_length ell 10 + norm_num only [Nat.size_one] at hsum + omega + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmup.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmup.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb1a04fe2bf63c4f20e86d7770a907af523868d1 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmup.lean @@ -0,0 +1,189 @@ +import OAI.Combinatorics.EditApproximation.Geometry.StateDomain +import OAI.Combinatorics.EditApproximation.Geometry.WideBellman +import OAI.Combinatorics.EditApproximation.Numerics.RationalRefinement +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! +# Warmup on physical node labels + +The Bellman operator requests only physical children. Distinct child labels +are retained even at repeated cuts. Nodes at the last physical level, and +source intervals of width at most one, retain their initial value. +-/ + +namespace EditApproximation + + + + + + + + + +theorem physicalSourceInterval_child {M J nx : ℕ} (node : PhysicalNode M J) + (hbelow : node.1.val < J) (i : Fin M) : + physicalSourceInterval nx (physicalChild node hbelow i) = sourceChild (physicalSourceInterval nx node) i := rfl + +noncomputable def physicalLower {α : Type*} {M J : ℕ} (source target : List α) (a : ℝ) + (state : PhysicalEntry M J target.length) : ℝ := + max ((stateEditCost (physicalSource source state.1) target state.2 : ℝ) / a) + |stateLengthGap (physicalSource source state.1) target state.2| + +noncomputable def physicalBellman {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (value : PhysicalEntry M J target.length → ℝ) (state : PhysicalEntry M J target.length) : ℝ := by + classical + let parent := physicalSourceInterval source.length state.1 + exact if hbelow : state.1.1.val < J then + if parent.hi - parent.lo ≤ 1 then initial state else + actualWideBellman parent (representatives state.1) P (fun q => initial (state.1, q)) L + (fun i q => value (physicalChild state.1 hbelow i, q)) state.2 + else initial state + +theorem physicalBellman_monotone {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) : + Monotone (physicalBellman source target P L initial representatives) := by + classical + intro value value' hvalue state + unfold physicalBellman + dsimp only + split_ifs + · exact le_rfl + · apply finiteBellman_mono + intro is + exact hvalue _ + · exact le_rfl + +theorem physicalBellman_le_initial {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (value : PhysicalEntry M J target.length → ℝ) : + physicalBellman source target P L initial representatives value ≤ initial := by + classical + intro state + unfold physicalBellman + dsimp only + split_ifs + · exact le_rfl + · exact finiteBellman_le_fallback _ _ _ _ _ _ + · exact le_rfl + +theorem physicalBellman_lower {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (a L : ℝ) (ha : 1 ≤ a) (hL : 1 ≤ L) + (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (hinit : physicalLower source target a ≤ initial) + (value : PhysicalEntry M J target.length → ℝ) (hvalue : physicalLower source target a ≤ value) : + physicalLower source target a ≤ physicalBellman source target P L initial representatives value := by + classical + intro state + unfold physicalBellman + dsimp only + split_ifs with hbelow hleaf + · exact hinit state + · apply actualWideBellman_lower source target hM _ _ P _ a L ha hL _ + · intro q + exact hinit (state.1, q) + · intro i q + exact hvalue (physicalChild state.1 hbelow i, q) + · exact hinit state + +noncomputable def physicalWarmup {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) : + ℕ → PhysicalEntry M J target.length → ℝ := + warmup (physicalBellman source target P L initial representatives) initial + +noncomputable def physicalWarmupAverage {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (T : ℕ) : PhysicalEntry M J target.length → ℝ := + warmupAverage (physicalBellman source target P L initial representatives) initial T + +theorem physicalBellman_le_action {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (value : PhysicalEntry M J target.length → ℝ) (node : PhysicalNode M J) + (hbelow : node.1.val < J) (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (q r : TargetInterval target.length) (b : ℕ) + (hrep : (b, r) ∈ representatives node) + (states : Fin M → TargetInterval target.length) + (hstates : states ∈ wideActionList M (physicalSourceInterval source.length node) r b P) : + physicalBellman source target P L initial representatives value (node, q) ≤ + L * targetEndpointDistance q r + endpointActionConnection r states + + ∑ i, value (physicalChild node hbelow i, states i) := by + classical + unfold physicalBellman + dsimp only + rw [dite_eq_left hbelow, ite_eq_right hleaf] + let action : BellmanAction (TargetInterval target.length) (Fin M × TargetInterval target.length) M := + ⟨r, endpointActionConnection r states, fun i => (i, states i)⟩ + have haction : action ∈ actualWideActions (physicalSourceInterval source.length node) + (representatives node) P := by + apply List.mem_flatMap.mpr + refine ⟨(b, r), hrep, ?_⟩ + exact List.mem_map.mpr ⟨states, hstates, rfl⟩ + exact finiteBellman_le_action (fun s => initial (node, s)) + (fun s t => targetEndpointDistance s t) L + (actualWideActions (physicalSourceInterval source.length node) (representatives node) P) + (fun is => value (physicalChild node hbelow is.1, is.2)) q action haction + +theorem physicalWarmup_average_sandwich {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (T : ℕ) (hT : 0 < T) (state : PhysicalEntry M J target.length) : + physicalWarmup source target P L initial representatives T state ≤ + physicalWarmupAverage source target P L initial representatives T state ∧ + physicalWarmupAverage source target P L initial representatives T state ≤ initial state := + warmup_average_sandwich _ _ T hT + (physicalBellman_monotone source target P L initial representatives) + (physicalBellman_le_initial source target P L initial representatives initial) state + +theorem physicalWarmup_average_action_bound {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) + (hbelow : node.1.val < J) (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (q r : TargetInterval target.length) (b : ℕ) + (hrep : (b, r) ∈ representatives node) + (states : Fin M → TargetInterval target.length) + (hstates : states ∈ wideActionList M (physicalSourceInterval source.length node) r b P) : + physicalWarmupAverage source target P L initial representatives T (node, q) - + (initial (node, q) - physicalWarmup source target P L initial representatives T (node, q)) / T ≤ + L * targetEndpointDistance q r + endpointActionConnection r states + + ∑ i, physicalWarmupAverage source target P L initial representatives T + (physicalChild node hbelow i, states i) := by + apply warmup_average_action_bound _ _ T hT (node, q) + (fun i => (physicalChild node hbelow i, states i)) + (L * targetEndpointDistance q r + endpointActionConnection r states) + intro t _ + exact physicalBellman_le_action source target P L initial representatives _ node hbelow hleaf q r b hrep states hstates + +theorem physicalWarmup_nonincreasing {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) : + ∀ t, physicalWarmup source target P L initial representatives (t + 1) ≤ + physicalWarmup source target P L initial representatives t := + warmup_nonincreasing _ _ (physicalBellman_monotone source target P L initial representatives) + (physicalBellman_le_initial source target P L initial representatives initial) + +theorem physicalWarmup_lower {α : Type*} {M J : ℕ} (source target : List α) + (hM : 0 < M) (P : ℕ) (a L : ℝ) (ha : 1 ≤ a) (hL : 1 ≤ L) + (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (hinit : physicalLower source target a ≤ initial) : + ∀ t, physicalLower source target a ≤ physicalWarmup source target P L initial representatives t := + warmup_lower _ _ _ hinit + (fun value hvalue => physicalBellman_lower source target hM P a L ha hL initial representatives hinit value hvalue) + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupQuery.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupQuery.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee5fc8a2970115b483541da025f95373782620aa --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupQuery.lean @@ -0,0 +1,161 @@ +import OAI.Combinatorics.EditApproximation.Geometry.RankedMemoProgram +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalDependencyRank +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalLocalWarmup +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! Adaptive finite queries for the literal local initial cones and +warmup. Candidate lists are bounded local grid lists; no full target +domain is tabulated. -/ + +namespace EditApproximation + +namespace FiniteQuery + + + +theorem bind_value {ι : Type*} (oracle : ι → ℚ) (program : FiniteQuery ι) + (next : ℚ → FiniteQuery ι) : + (bind program next).value oracle = (next (program.value oracle)).value oracle := by + induction program with + | done result => rfl + | read key continuation ih => exact ih (oracle key) + + + +theorem collect_value {ι κ : Type*} (oracle : ι → ℚ) (reader : κ → FiniteQuery ι) + (keys : List κ) (next : List ℚ → FiniteQuery ι) : + (collect reader keys next).value oracle = + (next (keys.map fun key => (reader key).value oracle)).value oracle := by + induction keys generalizing next with + | nil => rfl + | cons key keys ih => + rw [collect, bind_value, ih] + rfl + +end FiniteQuery + + + +theorem finiteAnswerTable_map {κ : Type*} [DecidableEq κ] (keys : List κ) (value : κ → ℚ) + (query : κ) (hquery : query ∈ keys) : + finiteAnswerTable keys (keys.map value) query = value query := by + induction keys with + | nil => simp only [List.not_mem_nil] at hquery + | cons key keys ih => + simp only [List.map_cons, finiteAnswerTable] + by_cases heq : query = key + · subst query + rw [ite_eq_left rfl] + · rw [ite_eq_right heq] + exact ih (List.mem_of_ne_of_mem heq hquery) + + + +theorem localInitialConeCenters_raw {n : ℕ} (N P : ℕ) (A : ℚ) + (U : TargetInterval n → ℕ) (q r : TargetInterval n) + (hr : r ∈ localInitialConeCenters N P A U q) : + r ∈ rawInitialConeCenters N P A (U q) q := by + obtain ⟨b, hb, hr⟩ := List.mem_flatMap.mp hr + exact List.mem_flatMap.mpr ⟨b, hb, (List.mem_filter.mp hr).1⟩ + +theorem localInitialConeCenters_congr_raw {n : ℕ} (N P : ℕ) (A : ℚ) + (U V : TargetInterval n → ℕ) (q : TargetInterval n) (hq : U q = V q) + (heq : ∀ r ∈ rawInitialConeCenters N P A (U q) q, U r = V r) : + localInitialConeCenters N P A U q = localInitialConeCenters N P A V q := by + unfold localInitialConeCenters + rw [← hq] + apply List.flatMap_congr + intro b hb + apply List.filter_congr + intro r hr + rw [heq r (List.mem_flatMap.mpr ⟨b, hb, hr⟩)] + +theorem localInitialConeTable_congr_raw {α : Type*} (source target : List α) + (N P F : ℕ) (A a : ℚ) (U V : TargetInterval target.length → ℕ) + (q : TargetInterval target.length) (hq : U q = V q) + (heq : ∀ r ∈ rawInitialConeCenters N P A (U q) q, U r = V r) : + localInitialConeTable source target U N P F A a q = + localInitialConeTable source target V N P F A a q := by + have hcenters := localInitialConeCenters_congr_raw N P A U V q hq heq + unfold localInitialConeTable + rw [← hq, ← hcenters] + split_ifs + · rfl + · congr 1 + apply List.map_congr_left + intro r hr + unfold initialConeValue + rw [heq r (localInitialConeCenters_raw N P A U q r hr)] + + + +theorem physicalInitialQuery_value {ι α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N P F : ℕ) (A : ℚ) + (seedRead : PhysicalEntry M J target.length → FiniteQuery ι) + (oracle : ι → ℚ) (U : PhysicalEntry M J target.length → ℕ) + (hseed : ∀ state, (seedRead state).value oracle = (U state : ℚ)) + (state : PhysicalEntry M J target.length) : + (physicalInitialQuery source target N P F A seedRead state).value oracle = + stageInitial source target U N P F A state := by + unfold physicalInitialQuery stageInitial physicalInitialTable + dsimp only + split_ifs with hleaf + · rfl + · rw [FiniteQuery.bind_value, hseed state] + simp only [Nat.ceil_natCast] + rw [FiniteQuery.collect_value] + simp only [hseed, FiniteQuery.value] + symm + apply localInitialConeTable_congr_raw + · simp only [ite_true] + · intro r hr + by_cases heq : r = state.2 + · subst r + simp only [ite_true] + · rw [ite_eq_right heq, finiteAnswerTable_map _ _ r hr, Nat.ceil_natCast] + +namespace PhysicalTableRequest + +variable {M J ny : ℕ} + + + +theorem combinedRank_lt_of_progress (T S : ℕ) + (first second : PhysicalTableRequest M J ny) + (hprogress : second.remainingDepth < first.remainingDepth ∧ second.rank T S ≤ first.rank T S ∨ + second.remainingDepth ≤ first.remainingDepth ∧ second.rank T S < first.rank T S) : + combinedRank T S second < combinedRank T S first := by + unfold combinedRank + rcases hprogress with h | h + · exact Nat.add_lt_add_of_lt_of_le h.1 h.2 + · exact Nat.add_lt_add_of_le_of_lt h.1 h.2 + +theorem combinedRank_sameIndexChild (T S : ℕ) (request : PhysicalTableRequest M J ny) + (hbelow : request.node.1.val < J) (i : Fin M) (state : TargetInterval ny) : + combinedRank T S (sameIndexChild request hbelow i state) < combinedRank T S request := + combinedRank_lt_of_progress T S request _ (Or.inl (sameIndexChild_progress T S request hbelow i state)) + +theorem combinedRank_previous_pass (T S : ℕ) (first second : PhysicalTableRequest M J ny) + (hpass : second.pass < first.pass) (hindex : second.index ≤ T + S) + (hnode : first.node.1.val ≤ second.node.1.val) : + combinedRank T S second < combinedRank T S first := + combinedRank_lt_of_progress T S first second + (Or.inr (previous_pass_progress T S first second hpass hindex hnode)) + +theorem combinedRank_warmup_child (pass copy T S j : ℕ) + (node : PhysicalNode M J) (hbelow : node.1.val < J) (i : Fin M) + (state previousState : TargetInterval ny) (hj : 0 < j) : + combinedRank T S (warmup pass copy (physicalChild node hbelow i) (j - 1) previousState) < + combinedRank T S (warmup pass copy node j state) := + combinedRank_lt_of_progress T S _ _ (Or.inr + ⟨(warmup_previous_child_progress pass copy T S j node hbelow i state previousState hj).1.le, + (warmup_previous_child_progress pass copy T S j node hbelow i state previousState hj).2⟩) + +end PhysicalTableRequest + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupSlack.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupSlack.lean new file mode 100644 index 0000000000000000000000000000000000000000..38b4e0a9ed7ff393abb03945aa4a9590ee3605d9 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupSlack.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalWarmup +import OAI.Combinatorics.EditApproximation.Geometry.RepresentativeBands + +namespace OAI + +/-! Averaging the actual physical wide Bellman recurrence bounds its exact Z slack. -/ + +namespace EditApproximation + +open Finset + +theorem physicalWarmup_average_wide_slack {α : Type*} {M J : ℕ} (source target : List α) + (P : ℕ) (L : ℝ) (initial : PhysicalEntry M J target.length → ℝ) + (representatives : PhysicalNode M J → List (ℕ × TargetInterval target.length)) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) + (hbelow : node.1.val < J) (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (q r : TargetInterval target.length) (b : ℕ) + (hrep : (b, r) ∈ representatives node) + (hnonempty : wideActionList M (physicalSourceInterval source.length node) r b P ≠ []) + (hfinal : 0 ≤ physicalWarmup source target P L initial representatives T (node, q)) : + physicalWarmupAverage source target P L initial representatives T (node, q) - + wideActionMinimum (physicalSourceInterval source.length node) r b P hnonempty + (fun i s => physicalWarmupAverage source target P L initial representatives T + (physicalChild node hbelow i, s)) ≤ + L * targetEndpointDistance q r + initial (node, q) / T := by + let child := fun i s => physicalWarmupAverage source target P L initial representatives T + (physicalChild node hbelow i, s) + let parent := physicalWarmupAverage source target P L initial representatives T (node, q) + have hTr : (0 : ℝ) ≤ T := Nat.cast_nonneg _ + have hcorrection : (initial (node, q) - + physicalWarmup source target P L initial representatives T (node, q)) / T ≤ + initial (node, q) / T := + div_le_div_of_nonneg_right (sub_le_self _ hfinal) hTr + have haction (states : Fin M → TargetInterval target.length) + (hstates : states ∈ wideActionList M (physicalSourceInterval source.length node) r b P) : + parent - L * targetEndpointDistance q r - initial (node, q) / T ≤ + endpointActionValue r states child := by + have h := physicalWarmup_average_action_bound source target P L initial representatives + T hT node hbelow hleaf q r b hrep states hstates + dsimp only [parent, child, endpointActionValue] + linarith only [h, hcorrection] + have hlower : parent - L * targetEndpointDistance q r - initial (node, q) / T ≤ + wideActionMinimum (physicalSourceInterval source.length node) r b P hnonempty child := by + apply (le_finiteMinimum_iff _ _ _).2 + constructor + · exact haction _ (List.head_mem hnonempty) + · intro value hvalue + obtain ⟨states, hstates, rfl⟩ := List.mem_map.mp hvalue + exact haction states hstates + change parent - wideActionMinimum _ _ _ _ hnonempty child ≤ _ + linarith only [hlower] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupStepQuery.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupStepQuery.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d904ddf5051ae336470b88ffac411ac700c8732 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/PhysicalWarmupStepQuery.lean @@ -0,0 +1,153 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalWarmupQuery +import OAI.Combinatorics.EditApproximation.Geometry.DyadicQueryWindow +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! A local warmup step gathers its candidate initial values and each +distinct wide child coordinate before evaluating the finite Bellman +minimum. Wide action enumeration makes no recursive oracle calls. -/ + +namespace EditApproximation + + + +theorem localRefinementRepresentatives_congr_raw {n : ℕ} (N P F : ℕ) (a : ℚ) + (left right : TargetInterval n → ℚ) (q : TargetInterval n) (hq : left q = right q) + (heq : ∀ r ∈ rawRefinementCenters N P F a (left q) q, left r = right r) : + localRefinementRepresentatives N P F a left q = + localRefinementRepresentatives N P F a right q := by + unfold localRefinementRepresentatives + rw [← hq] + apply List.flatMap_congr + intro b hb + congr 1 + apply List.filter_congr + intro r hr + rw [heq r (List.mem_eraseDups.mpr (List.mem_flatMap.mpr ⟨b, hb, hr⟩))] + + + +theorem wideWarmupInputs_action {nx ny M : ℕ} (parent : TargetInterval nx) (P : ℕ) + (representatives : List (ℕ × TargetInterval ny)) + (action : RationalBellmanAction (TargetInterval ny) (Fin M × TargetInterval ny) M) + (ha : action ∈ rationalActualWideActions parent representatives P) (i : Fin M) : + action.childState i ∈ wideWarmupInputs parent P representatives := by + obtain ⟨br, hbr, ha⟩ := List.mem_flatMap.mp ha + obtain ⟨states, hs, rfl⟩ := List.mem_map.mp ha + apply List.mem_eraseDups.mpr + apply List.mem_flatMap.mpr + refine ⟨br, hbr, List.mem_flatMap.mpr ?_⟩ + exact ⟨i, List.mem_finRange i, List.mem_map.mpr + ⟨states i, finiteAssignments_sound M _ states hs i, rfl⟩⟩ + + + +theorem localWarmupStepQuery_value {ι : Type*} {nx ny M : ℕ} (parent : TargetInterval nx) + (N P F : ℕ) (a : ℚ) (initialRead : TargetInterval ny → FiniteQuery ι) + (childRead : Fin M × TargetInterval ny → FiniteQuery ι) (oracle : ι → ℚ) + (initial : TargetInterval ny → ℚ) (child : Fin M × TargetInterval ny → ℚ) + (hinitial : ∀ r, (initialRead r).value oracle = initial r) + (hchild : ∀ input, (childRead input).value oracle = child input) (q : TargetInterval ny) : + (localWarmupStepQuery parent N P F a initialRead childRead q).value oracle = + rationalBellman initial (fun q r => targetEndpointDistance q r) (128 * F) + (rationalActualWideActions parent (localRefinementRepresentatives N P F a initial q) P) child q := by + let centers := rawRefinementCenters N P F a (initial q) q + let table := fun r => if r = q then initial q else finiteAnswerTable centers (centers.map initial) r + have htable (r : TargetInterval ny) (hr : r ∈ centers) : table r = initial r := by + dsimp only [table] + split_ifs with heq + · exact congrArg initial heq.symm + · exact finiteAnswerTable_map centers initial r hr + have htableq : table q = initial q := by simp only [table, ite_true] + have hreps : localRefinementRepresentatives N P F a table q = + localRefinementRepresentatives N P F a initial q := + localRefinementRepresentatives_congr_raw N P F a table initial q htableq + (fun r hr => htable r (by simpa only [htableq] using hr)) + let representatives := localRefinementRepresentatives N P F a initial q + let inputs := wideWarmupInputs (M := M) parent P representatives + have hinputs : ∀ action ∈ rationalActualWideActions parent representatives P, ∀ i, + finiteAnswerTable inputs (inputs.map child) (action.childState i) = child (action.childState i) := by + intro action ha i + exact finiteAnswerTable_map inputs child _ (wideWarmupInputs_action parent P representatives action ha i) + simp only [localWarmupStepQuery, FiniteQuery.bind_value, hinitial, FiniteQuery.collect_value, + hchild, FiniteQuery.value] + change rationalBellman table _ _ + (rationalActualWideActions parent (localRefinementRepresentatives N P F a table q) P) + (finiteAnswerTable + (wideWarmupInputs parent P (localRefinementRepresentatives N P F a table q)) + ((wideWarmupInputs parent P (localRefinementRepresentatives N P F a table q)).map child)) q = _ + rw [hreps] + unfold rationalBellman + rw [htableq] + congr 1 + apply List.map_congr_left + intro action ha + unfold rationalActionValue + congr 1 + exact Finset.sum_congr rfl (fun i hi => hinputs action ha i) + + + +theorem physicalWarmupStepQuery_value {ι α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N P F : ℕ) (A : ℚ) + (seedRead : PhysicalEntry M J target.length → FiniteQuery ι) + (childRead : Fin M × TargetInterval target.length → FiniteQuery ι) (oracle : ι → ℚ) + (U : PhysicalEntry M J target.length → ℕ) + (hseed : ∀ state, (seedRead state).value oracle = (U state : ℚ)) + (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (t : ℕ) (q : TargetInterval target.length) + (hchild : ∀ input, (childRead input).value oracle = + physicalLocalWarmup source target U N P F A t (physicalChild node hbelow input.1, input.2)) : + (physicalWarmupStepQuery source target N P F A seedRead childRead node q).value oracle = + physicalLocalWarmup source target U N P F A (t + 1) (node, q) := by + rw [physicalLocalWarmup] + simp only [dite_eq_left hbelow, ite_eq_right hleaf] + exact localWarmupStepQuery_value _ N P F (refinementFactor A F) _ _ oracle _ _ + (fun r => physicalInitialQuery_value source target N P F A seedRead oracle U hseed (node, r)) + hchild q + +/-- Every child read of a positive warmup step carries its concrete +strict progress proof. The previous-pass seed reader is supplied by the +pass wrapper, so its own reads must carry the same strict proof. -/ + + + + +theorem physicalWarmupRequestQuery_value {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (N P F : ℕ) (A : ℚ) + (pass copy T S j : ℕ) (node : PhysicalNode M J) (q : TargetInterval target.length) + (seedRead : PhysicalEntry M J target.length → + FiniteQuery {child : PhysicalTableRequest M J target.length // + child.combinedRank T S < (PhysicalTableRequest.warmup pass copy node j q).combinedRank T S}) + (values : PhysicalTableRequest M J target.length → ℚ) + (U : PhysicalEntry M J target.length → ℕ) + (hseed : ∀ state, (seedRead state).value (fun child => values child.val) = (U state : ℚ)) + (hchild : ∀ (hbelow : node.1.val < J) (input : Fin M × TargetInterval target.length), + values (PhysicalTableRequest.warmup pass copy (physicalChild node hbelow input.1) (j - 1) input.2) = + physicalLocalWarmup source target U N P F A (j - 1) + (physicalChild node hbelow input.1, input.2)) : + (physicalWarmupRequestQuery source target N P F A pass copy T S j node q seedRead).value + (fun child => values child.val) = physicalLocalWarmup source target U N P F A j (node, q) := by + cases j with + | zero => exact physicalInitialQuery_value source target N P F A seedRead _ U hseed (node, q) + | succ t => + dsimp only [physicalWarmupRequestQuery] + split_ifs with hbelow hleaf + · rw [physicalLocalWarmup] + simp only [dite_eq_left hbelow, ite_eq_left hleaf] + exact physicalInitialQuery_value source target N P F A seedRead _ U hseed (node, q) + · apply physicalWarmupStepQuery_value source target N P F A seedRead _ _ U hseed + node hbelow hleaf t q + intro input + exact hchild hbelow input + · rw [physicalLocalWarmup] + simp only [dite_eq_right hbelow] + exact physicalInitialQuery_value source target N P F A seedRead _ U hseed (node, q) + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparison.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3142fa5204db98091d5dc4c5f368b5cc08b2ba5 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparison.lean @@ -0,0 +1,85 @@ +import OAI.Combinatorics.EditApproximation.Refinement.StageWarmup +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalWarmupSlack +import OAI.Combinatorics.EditApproximation.Geometry.ComparisonTree + +namespace OAI + +/-! Actual stage masses and representatives supply the comparison-node warmup hypotheses. -/ + +namespace EditApproximation + +theorem stageWarmupMass_child_lower {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) (hbelow : node.1.val < J) : + ∀ i s, max ((stateEditCost + (substring source (sourceChild (physicalSourceInterval source.length node) i).lo + (sourceChild (physicalSourceInterval source.length node) i).hi) target s : ℝ) / + (refinementFactor A F : ℝ)) + |stateLengthGap (substring source (sourceChild (physicalSourceInterval source.length node) i).lo + (sourceChild (physicalSourceInterval source.length node) i).hi) target s| ≤ + (stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) : ℝ) := by + intro i s + have h := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT + (physicalChild node hbelow i, s) + have hmass : (stageWarmup source target U N P F A T (physicalChild node hbelow i, s) : ℝ) ≤ + stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) := Rat.cast_le.mpr h.2.1 + exact h.1.trans hmass + +theorem stageRounded_representative_mem {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (node : PhysicalNode M J) (q : TargetInterval target.length) + (hc : 0 < stateEditCost (physicalSource source node) target q) : + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + (b, roundInterval (seedGridSpacing b P) q) ∈ stageRepresentatives source target U N P F A node := by + have hfactor := refinementFactor_spec A F (by omega) + have hbounds := physicalInitialTable_bounds source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed + exact rounded_comparison_representative (physicalSource source node) target N P F + (refinementFactor A F) (by omega) (Nat.cast_nonneg _) (by linarith only [hfactor.1]) + (fun r => stageInitial source target U N P F A (node, r)) + (fun r => (le_max_left _ _).trans (hbounds (node, r)).1) + (fun r => (hbounds (node, r)).2) q hc (physical_state_cost_le source target N hsize (node, q)) + +theorem stageWarmup_comparison_slack {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (q : TargetInterval target.length) + (hc : 0 < stateEditCost (physicalSource source node) target q) : + let parent := physicalSourceInterval source.length node + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + ∀ hnonempty : wideActionList M parent r b P ≠ [], + (stageWarmupMass source target U N P F A T (node, q) : ℝ) - + wideActionMinimum parent r b P hnonempty + (fun i s => (stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) : ℝ)) ≤ + (128 * (F : ℝ)) * targetEndpointDistance q r + (stageInitial source target U N P F A (node, q) : ℝ) / T := by + dsimp only + intro hnonempty + have hrep := stageRounded_representative_mem source target U N P F A hsize hP hF hA hseed node q hc + have hinvariants := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT (node, q) + have hfinal : 0 ≤ (stageWarmup source target U N P F A T (node, q) : ℝ) := + (abs_nonneg _).trans ((le_max_right _ _).trans hinvariants.1) + simp only [stageWarmup, rationalPhysicalWarmup_cast] at hfinal + have h := physicalWarmup_average_wide_slack source target P ((128 * F : ℚ) : ℝ) + (fun s => (stageInitial source target U N P F A s : ℝ)) + (stageRepresentatives source target U N P F A) T hT node hbelow hleaf q _ _ hrep hnonempty hfinal + simp only [stageWarmupMass, rationalPhysicalWarmupAverage_cast] + simpa only [Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast] using h + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonBad.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonBad.lean new file mode 100644 index 0000000000000000000000000000000000000000..06d2428c0ce211a45805484ab81728b48817b994 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonBad.lean @@ -0,0 +1,88 @@ +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonCharges + +namespace OAI + +/-! Exceptional comparison-node costs are bounded by the actual global curvature charge. -/ + +namespace EditApproximation + +open Finset + +noncomputable def comparisonActiveScale {α : Type*} (source target : List α) : + ComparisonState source.length target.length → ℝ := by + classical + exact fun state => match state with + | none => 0 + | some (parent, q) => if comparisonStopped source target parent q then 0 else + (2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q) : ℕ) + +theorem comparisonActiveCost_scale {α : Type*} (source target : List α) + (state : ComparisonState source.length target.length) : + comparisonActiveScale source target state ≤ comparisonActiveCost source target state ∧ + comparisonActiveCost source target state ≤ 2 * comparisonActiveScale source target state := by + classical + cases state with + | none => simp only [comparisonActiveScale, comparisonActiveCost, mul_zero, le_refl, and_self] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · simp only [comparisonActiveScale, comparisonActiveCost, ite_eq_left hstop, mul_zero, le_refl, and_self] + · have hc : 0 < stateEditCost (substring source parent.lo parent.hi) target q := by + unfold comparisonStopped at hstop + omega + have hb := cost_dyadicScale _ _ hc le_rfl + simp only [comparisonActiveScale, comparisonActiveCost, ite_eq_right hstop] + exact ⟨by exact_mod_cast hb.2.1, by exact_mod_cast hb.2.2.le⟩ + +section Stage + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) + +noncomputable def stageComparisonBadCost (ratio : ℝ) : ℝ := by + classical + exact ∑ v : (Σ d : Fin J, TreeLayer M d.val) with + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).1 ∨ + comparisonActiveScale source target (frontier v.1.val v.2) < + ratio * (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).2, + comparisonActiveCost source target (frontier v.1.val v.2) + +include hsize hF hA hseed hT in + theorem stageComparisonBadCost_bound (ratio : ℝ) (hratio : 0 ≤ ratio) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) (hcapacity : source.length ≤ M ^ J) + (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) : + stageComparisonBadCost source target hM U N P F A hP T rootQ ratio ≤ + 10000 * ratio * F * (1 + (J : ℝ) / P + (J : ℝ) / T) * + comparisonStateCost source target (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) := by + classical + let ι := Σ d : Fin J, TreeLayer M d.val + let cost : ι → ℝ := fun v => comparisonActiveCost source target (frontier v.1.val v.2) + let scale : ι → ℝ := fun v => comparisonActiveScale source target (frontier v.1.val v.2) + let K : ι → ℝ := fun v => (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).1 + let G : ι → ℝ := fun v => (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).2 + have h := bad_node_cost_from_curvature (univ : Finset ι) cost scale K G ratio _ hratio + (fun v _ => (comparisonActiveCost_scale source target _).2) + (fun v _ => (stageComparisonCharges_local source target hM U N P F A hsize hP hF hA hseed + T hT rootQ hscale v.1 v.2).1) + (fun v _ => (stageComparisonCharges_local source target hM U N P F A hsize hP hF hA hseed + T hT rootQ hscale v.1 v.2).2.1) + (stageComparisonCharges_total source target hM U N P F A hsize hP hF hA hseed + T hT rootQ hscale hcapacity hsmall) + change stageComparisonBadCost source target hM U N P F A hP T rootQ ratio ≤ _ at h + convert h using 1 + ring + +end Stage + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonCharges.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..a90f25292c5f3fe1ff266fe93775e83a96ac7055 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonCharges.lean @@ -0,0 +1,243 @@ +import OAI.Combinatorics.EditApproximation.Geometry.ComparisonLiftStep +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonEnergy +import OAI.Combinatorics.EditApproximation.Refinement.StageParameterBounds + +namespace OAI + +/-! Curvature and discrepancy are computed from the actual comparison-tree warmup masses. -/ + +namespace EditApproximation + +open Finset + +section Stage + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (rootQ : TargetInterval target.length) + +local notation "mass" => stageComparisonMass source target hM U N P F A hP T rootQ +local notation "energy" => stageComparisonEnergy source target hM U N P F A hP T rootQ +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) + +noncomputable def stageComparisonCharges (d : Fin J) (path : TreeLayer M d.val) : ℝ × ℝ := by + classical + exact match frontier d.val path with + | none => (0, 0) + | some (parent, q) => if hstop : comparisonStopped source target parent q then (0, 0) else + let hc : 0 < stateEditCost (substring source parent.lo parent.hi) target q := by + unfold comparisonStopped at hstop + omega + let node : PhysicalNode M J := ⟨⟨d.val, by omega⟩, path⟩ + let child := fun i s => (stageWarmupMass source target U N P F A T (physicalChild node d.isLt i, s) : ℝ) + let b := 2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP parent q hc + let hnonempty : wideActionList M parent r b P ≠ [] := by + have hmem : action ∈ wideActionList M parent r b P := + (comparisonChildren_spec source target hM P hP parent q hc).1 + intro heq + rw [heq] at hmem + exact List.not_mem_nil hmem + (comparisonActionCurvature source target parent r action child, + comparisonActionMass action child - wideActionMinimum parent r b P hnonempty child) + +include hsize hF hA hseed hT in + theorem stageComparisonCharges_local (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) + (d : Fin J) (path : TreeLayer M d.val) : + let charges := stageComparisonCharges source target hM U N P F A hP T rootQ d path + let R := mass d.val path - ∑ i : Fin M, mass (d.val + 1) (path, i) + let E := (∑ i : Fin M, energy (d.val + 1) (path, i)) - energy d.val path + let movement := comparisonMovement source target P (frontier d.val path) + let cost := comparisonActiveCost source target (frontier d.val path) + 0 ≤ charges.1 ∧ 0 ≤ charges.2 ∧ + R + charges.2 ≤ (128 * (F : ℝ)) * movement + (2 * F / (T : ℝ)) * cost ∧ + charges.1 ≤ E + 3 * movement + 2 * max (-R) 0 := by + classical + dsimp only + generalize heq : frontier d.val path = state + cases state with + | none => + have hzero := stageComparison_step_none source target hM U N P F A hP T rootQ d.val path heq + have hcharges : stageComparisonCharges source target hM U N P F A hP T rootQ d path = (0, 0) := by + unfold stageComparisonCharges + rw [heq] + rw [hcharges, hzero.1, hzero.2.1, hzero.2.2.1, hzero.2.2.2] + simp only [comparisonMovement, comparisonActiveCost, sub_self, neg_zero, max_self, + mul_zero, add_zero, le_refl, and_self] + | some state => + rcases state with ⟨parent, q⟩ + by_cases hstop : comparisonStopped source target parent q + · have hm := stageComparisonMass_step_stopped source target hM U N P F A hP T rootQ d.val path parent q heq hstop + have he := stageComparisonEnergy_step_stopped source target hM U N P F A hP T rootQ d.val path parent q heq hstop + have hcharges : stageComparisonCharges source target hM U N P F A hP T rootQ d path = (0, 0) := by + unfold stageComparisonCharges + rw [heq] + simp only [dite_eq_left hstop] + rw [hcharges, hm, he] + simp only [comparisonMovement, comparisonActiveCost, ite_eq_left hstop, sub_self, neg_zero, + max_self, mul_zero, add_zero, le_refl, and_self] + · have hp := comparisonFrontier_active_source source target hM P hP rootQ d.val path parent q heq hstop + subst parent + let node : PhysicalNode M J := ⟨⟨d.val, by omega⟩, path⟩ + have hbelow : node.1.val < J := d.isLt + have hc : 0 < stateEditCost (physicalSource source node) target q := by + change 0 < stateEditCost (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q + unfold comparisonStopped at hstop + omega + have hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1 := fun h => hstop (Or.inl h) + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP (physicalSourceInterval source.length node) q hc + let child := fun i s => (stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) : ℝ) + let mp := (stageWarmupMass source target U N P F A T (node, q) : ℝ) + let W := comparisonActionMass action child + let K := comparisonActionCurvature source target (physicalSourceInterval source.length node) r action child + obtain ⟨hnonempty, hK, hG, hslack, henergy⟩ := + stageComparison_energy source target hM U N P F A hsize hP hF hA hseed T hT node hbelow q hc hleaf hscale + let Z := wideActionMinimum (physicalSourceInterval source.length node) r b P hnonempty child + have hcharges : stageComparisonCharges source target hM U N P F A hP T rootQ d path = (K, W - Z) := by + unfold stageComparisonCharges + rw [heq] + dsimp only + rw [dite_eq_right hstop] + rfl + have hparent : mass d.val path = mp := by + unfold stageComparisonMass comparisonPhysicalLift + rw [dite_eq_left d.isLt.le, heq] + simp only [stoppedComparisonValue, ite_eq_right hstop] + rfl + have hchild (i : Fin M) : mass (d.val + 1) (path, i) = child i (action i) := + stageComparisonMass_step_active source target hM U N P F A hsize hP hF hA hseed T hT rootQ + node hbelow q heq hstop i + have hparentEnergy : energy d.val path = (stateLengthGap (physicalSource source node) target q) ^ 2 / mp := by + unfold stageComparisonEnergy + rw [heq, hparent] + rfl + have hchildEnergy (i : Fin M) : energy (d.val + 1) (path, i) = + (stateLengthGap (physicalSource source (physicalChild node hbelow i)) target (action i)) ^ 2 / + child i (action i) := + stageComparisonEnergy_step_active source target hM U N P F A hsize hP hF hA hseed T hT rootQ + node hbelow q heq hstop i + rw [hcharges, hparent, hparentEnergy] + simp_rw [hchild, hchildEnergy] + simp only [comparisonMovement, comparisonActiveCost, ite_eq_right hstop] + change 0 ≤ K ∧ 0 ≤ W - Z ∧ + mp - W + (W - Z) ≤ (128 * (F : ℝ)) * targetEndpointDistance q r + + (2 * F / (T : ℝ)) * stateEditCost (physicalSource source node) target q ∧ + K ≤ ((∑ i, (stateLengthGap (physicalSource source (physicalChild node hbelow i)) target + (action i)) ^ 2 / child i (action i)) - + (stateLengthGap (physicalSource source node) target q) ^ 2 / mp) + + 3 * targetEndpointDistance q r + 2 * max (-(mp - W)) 0 + have hu := (stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT (node, q)).2.2.2 + have huR : (stageInitial source target U N P F A (node, q) : ℝ) ≤ + 2 * F * stateEditCost (physicalSource source node) target q := by exact_mod_cast hu + have hdiv := div_le_div_of_nonneg_right huR (Nat.cast_nonneg (α := ℝ) T) + have hid : (2 * (F : ℝ) * stateEditCost (physicalSource source node) target q) / T = + (2 * F / (T : ℝ)) * stateEditCost (physicalSource source node) target q := by ring + rw [hid] at hdiv + exact ⟨hK, hG, hslack.trans (add_le_add_right hdiv _), henergy⟩ + +theorem comparisonMovement_nonneg {β : Type*} (x y : List β) (P : ℕ) + (state : ComparisonState x.length y.length) : 0 ≤ comparisonMovement x y P state := by + classical + cases state with + | none => exact le_rfl + | some state => + rcases state with ⟨parent, q⟩ + unfold comparisonMovement + dsimp only + split_ifs + · exact le_rfl + · exact Nat.cast_nonneg _ + +theorem treeLayer_sigma_sum (M J : ℕ) (f : (d : ℕ) → TreeLayer M d → ℝ) : + (∑ v : (Σ d : Fin J, TreeLayer M d.val), f v.1.val v.2) = + ∑ d ∈ range J, ∑ path : TreeLayer M d, f d path := by + rw [Fintype.sum_sigma] + exact Fin.sum_univ_eq_sum_range (fun d => ∑ path : TreeLayer M d, f d path) J + +include hsize hF hA hseed hT in + theorem stageComparisonCharges_total (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) + (hcapacity : source.length ≤ M ^ J) + (hsmall : (J : ℝ) * (4 * (M : ℝ) / P) ≤ 1 / 2) : + (∑ v : (Σ d : Fin J, TreeLayer M d.val), + ((stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).1 + + (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).2)) ≤ + 5000 * F * (1 + (J : ℝ) / P + (J : ℝ) / T) * + comparisonStateCost source target (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) := by + let ι := Σ d : Fin J, TreeLayer M d.val + let D := comparisonStateCost source target (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) + let K : ι → ℝ := fun v => (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).1 + let G : ι → ℝ := fun v => (stageComparisonCharges source target hM U N P F A hP T rootQ v.1 v.2).2 + let R : ι → ℝ := fun v => mass v.1.val v.2 - ∑ i : Fin M, mass (v.1.val + 1) (v.2, i) + let E : ι → ℝ := fun v => (∑ i : Fin M, energy (v.1.val + 1) (v.2, i)) - energy v.1.val v.2 + let movement : ι → ℝ := fun v => comparisonMovement source target P (frontier v.1.val v.2) + let slack : ι → ℝ := fun v => (128 * (F : ℝ)) * movement v + + (2 * F / (T : ℝ)) * comparisonActiveCost source target (frontier v.1.val v.2) + have hlocal (v : ι) := stageComparisonCharges_local source target hM U N P F A hsize hP hF hA hseed + T hT rootQ hscale v.1 v.2 + have hroot := (stageComparisonMass_bounds source target hM U N P F A hsize hP hF hA hseed T hT rootQ + 0 PUnit.unit).1 + have hterminal : (∑ path : TreeLayer M J, mass J path) ≤ 2 * D := by + simp_rw [stageComparisonMass_terminal source target hM U N P F A hP T rootQ hcapacity] + exact comparison_frontier_cost_le_twice source target hM P hP _ J J le_rfl hsmall + have hconservation : (∑ v : ι, R v) = mass 0 PUnit.unit - ∑ path : TreeLayer M J, mass J path := by + dsimp only [R, ι] + have h := treeLayer_sigma_sum M J (fun d path => mass d path - ∑ i : Fin M, mass (d + 1) (path, i)) + exact h.trans (tree_frontier_telescope M J mass) + have henergy : (∑ v : ι, E v) ≤ 2 * D := by + dsimp only [E, ι] + have h := treeLayer_sigma_sum M J (fun d path => (∑ i : Fin M, energy (d + 1) (path, i)) - energy d path) + apply h.le.trans + exact stageComparisonEnergy_telescope source target hM U N P F A hsize hP hF hA hseed T hT rootQ + hcapacity hsmall + have hF0 : (0 : ℝ) ≤ F := Nat.cast_nonneg _ + have hslack (v : ι) : 0 ≤ slack v := by + exact add_nonneg (mul_nonneg (mul_nonneg (by norm_num) hF0) + (comparisonMovement_nonneg source target P _)) + (mul_nonneg (div_nonneg (mul_nonneg (by norm_num) hF0) (Nat.cast_nonneg _)) + (comparisonActiveCost_bounds source target _).1) + have htotal := curvature_total_from_telescope (univ : Finset ι) K G R movement slack E D + (mass 0 PUnit.unit) (∑ path : TreeLayer M J, mass J path) hroot hterminal hconservation henergy + (fun v _ => (hlocal v).2.1) (fun v _ => hslack v) + (fun v _ => (hlocal v).2.2.1) (fun v _ => (hlocal v).2.2.2) + have hmove : (∑ v : ι, movement v) ≤ 4 * ((J : ℝ) / P) * D := by + dsimp only [movement, ι] + have heq := treeLayer_sigma_sum M J (fun d path => comparisonMovement source target P (frontier d path)) + apply heq.le.trans + have h := comparison_total_movement_bound source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) J hsmall + convert h using 1 + ring + have hactive : (∑ v : ι, comparisonActiveCost source target (frontier v.1.val v.2)) ≤ 2 * J * D := by + dsimp only [ι] + have heq := treeLayer_sigma_sum M J (fun d path => comparisonActiveCost source target (frontier d path)) + apply heq.le.trans + exact comparison_total_active_cost_bound source target hM P hP _ J hsmall + have hslackSum : (∑ v : ι, slack v) ≤ + 512 * F * ((J : ℝ) / P) * D + 4 * F * ((J : ℝ) / T) * D := by + dsimp only [slack] + rw [sum_add_distrib, ← mul_sum, ← mul_sum] + have hm := mul_le_mul_of_nonneg_left hmove (show 0 ≤ 128 * (F : ℝ) from mul_nonneg (by norm_num) hF0) + have ha := mul_le_mul_of_nonneg_left hactive (show 0 ≤ 2 * (F : ℝ) / (T : ℝ) from + div_nonneg (mul_nonneg (by norm_num) hF0) (Nat.cast_nonneg _)) + calc + _ ≤ (128 * (F : ℝ)) * (4 * ((J : ℝ) / P) * D) + (2 * F / (T : ℝ)) * (2 * J * D) := add_le_add hm ha + _ = _ := by ring + exact curvature_total_parameter_bound (comparisonStateCost_nonneg source target _) + (by exact_mod_cast hF) (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) htotal hmove hslackSum + +end Stage + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonEnergy.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..789430b440a015fb530c1587f920a7fcd11ba86a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonEnergy.lean @@ -0,0 +1,169 @@ +import OAI.Combinatorics.EditApproximation.Refinement.StageComparison +import OAI.Combinatorics.EditApproximation.Refinement.ComputedComparisonBand + +namespace OAI + +/-! The actual averaged warmup supplies the local mass and energy charges. -/ + +namespace EditApproximation + +open Finset + +theorem stateLengthGap_difference {α : Type*} (source target : List α) + (q r : TargetInterval target.length) : + |stateLengthGap source target q - stateLengthGap source target r| ≤ + (targetEndpointDistance q r : ℝ) := by + have hid : stateLengthGap source target q - stateLengthGap source target r = + ((q.hi : ℝ) - r.hi) - ((q.lo : ℝ) - r.lo) := by + unfold stateLengthGap + ring + rw [hid] + have h := abs_sub ((q.hi : ℝ) - r.hi) ((q.lo : ℝ) - r.lo) + rw [natural_distance_cast, natural_distance_cast] at h + simpa only [targetEndpointDistance, Nat.cast_add, add_comm] using h + +section Stage + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) (hbelow : node.1.val < J) + (q : TargetInterval target.length) + (hc : 0 < stateEditCost (physicalSource source node) target q) + +include hM hsize hP hF hA hseed hT hc in +/-- The rounded representative has positive true cost, and its movement is +smaller than the actual parent averaged warmup mass. -/ +theorem stageComparison_positive_movement + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) : + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + 0 < stateEditCost (physicalSource source node) target r ∧ + (targetEndpointDistance q r : ℝ) ≤ stageWarmupMass source target U N P F A T (node, q) := by + dsimp only + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let c : ℝ := stateEditCost (physicalSource source node) target q + let e : ℝ := targetEndpointDistance q r + let a : ℝ := refinementFactor A F + have ha : 1 ≤ a := by + dsimp only [a] + simpa only [Rat.cast_one] using (Rat.cast_le (K := ℝ)).mpr (refinementFactor_spec A F (by omega)).1 + have ha0 : 0 < a := by linarith only [ha] + have hc0 : 0 < c := by dsimp only [c]; exact_mod_cast hc + have he0 : 0 ≤ e := Nat.cast_nonneg _ + have hb : (b : ℝ) ≤ c := by + dsimp only [b, c] + exact_mod_cast (cost_dyadicScale _ _ hc le_rfl).2.1 + have herror : e * (P : ℝ) ≤ 2 * (b : ℝ) := by + dsimp only [e, r] + exact_mod_cast rounded_seedGrid_error b P (by omega) q + have hPfour : (4 : ℝ) ≤ P := by exact_mod_cast (show 4 ≤ P by omega) + have hmul := mul_le_mul_of_nonneg_left hPfour he0 + have hhalf : e ≤ c / 2 := by nlinarith only [hmul, herror, hb] + have hspatial : c ≤ stateEditCost (physicalSource source node) target r + e := by + dsimp only [c, e] + exact_mod_cast stateEditCost_spatial (physicalSource source node) target q r + have hsmall : e ≤ c / a := by + have h := mul_le_mul_of_nonneg_left hscale he0 + apply (le_div_iff₀ ha0).2 + nlinarith only [h, herror, hb] + have hinv := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT (node, q) + have hlower : c / a ≤ (stageWarmupMass source target U N P F A T (node, q) : ℝ) := + ((le_max_left _ _).trans hinv.1).trans (Rat.cast_le.mpr hinv.2.1) + exact ⟨by exact_mod_cast (show (0 : ℝ) < stateEditCost (physicalSource source node) target r by linarith), + hsmall.trans hlower⟩ + +include hsize hF hA hseed hT in +/-- No local energy or discrepancy hypothesis is assumed: these are the +charges of the input-determined comparison children and the actual warmup. -/ +theorem stageComparison_energy + (hleaf : ¬ (physicalSourceInterval source.length node).hi - + (physicalSourceInterval source.length node).lo ≤ 1) + (hscale : 2 * (refinementFactor A F : ℝ) ≤ P) : + let parent := physicalSourceInterval source.length node + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP parent q hc + let child := fun i s => (stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) : ℝ) + let mp := (stageWarmupMass source target U N P F A T (node, q) : ℝ) + let W := comparisonActionMass action child + let K := comparisonActionCurvature source target parent r action child + let energy := (stateLengthGap (physicalSource source node) target q) ^ 2 / mp + ∃ hnonempty : wideActionList M parent r b P ≠ [], + let Z := wideActionMinimum parent r b P hnonempty child + 0 ≤ K ∧ 0 ≤ W - Z ∧ + mp - W + (W - Z) ≤ + (128 * (F : ℝ)) * targetEndpointDistance q r + + (stageInitial source target U N P F A (node, q) : ℝ) / T ∧ + K ≤ ((∑ i, (stateLengthGap (physicalSource source (physicalChild node hbelow i)) target + (action i)) ^ 2 / child i (action i)) - energy) + + 3 * targetEndpointDistance q r + 2 * max (-(mp - W)) 0 := by + dsimp only + let parent := physicalSourceInterval source.length node + let b := 2 ^ Nat.log 2 (stateEditCost (physicalSource source node) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP parent q hc + let child := fun i s => (stageWarmupMass source target U N P F A T (physicalChild node hbelow i, s) : ℝ) + let mp := (stageWarmupMass source target U N P F A T (node, q) : ℝ) + let W := comparisonActionMass action child + let K := comparisonActionCurvature source target parent r action child + have hspec := comparisonChildren_spec source target hM P hP parent q hc + have hzero : endpointActionConnection r action = 0 := hspec.2.1 + have hnonempty : wideActionList M parent r b P ≠ [] := by + intro heq + have hmem := hspec.1 + change action ∈ wideActionList M parent r b P at hmem + rw [heq] at hmem + exact List.not_mem_nil hmem + let Z := wideActionMinimum parent r b P hnonempty child + have ha : (1 : ℝ) ≤ refinementFactor A F := by + simpa only [Rat.cast_one] using (Rat.cast_le (K := ℝ)).mpr (refinementFactor_spec A F (by omega)).1 + have hlower := stageWarmupMass_child_lower source target hM U N P F A hsize hP hF hA hseed T hT node hbelow + have hZlower := wideActionMinimum_lower source target hM parent r b P hnonempty + (refinementFactor A F : ℝ) ha child hlower + have hpositive := stageComparison_positive_movement source target hM U N P F A hsize hP hF hA hseed + T hT node q hc hscale + have hcr : (0 : ℝ) < stateEditCost (physicalSource source node) target r := by exact_mod_cast hpositive.1 + have hZpos : 0 < Z := (div_pos hcr (by linarith only [ha])).trans_le ((le_max_left _ _).trans hZlower) + have hZW : Z ≤ W := by + have h := wideActionMinimum_le_member parent r hnonempty child action hspec.1 + simpa only [Z, W, comparisonActionMass, endpointActionValue, hzero, Nat.cast_zero, zero_add] using h + have hWpos : 0 < W := hZpos.trans_le hZW + have hgap (i : Fin M) : |stateLengthGap (physicalSource source (physicalChild node hbelow i)) target + (action i)| ≤ child i (action i) := (le_max_right _ _).trans (hlower i (action i)) + have hK := comparisonActionCurvature_nonneg source target hM parent r action child hgap hspec.2.1 hWpos + have hinv := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT (node, q) + have hparentGap : |stateLengthGap (physicalSource source node) target q| ≤ mp := + ((le_max_right _ _).trans hinv.1).trans (Rat.cast_le.mpr hinv.2.1) + have hmp : 0 < mp := by + have hcR : (0 : ℝ) < stateEditCost (physicalSource source node) target q := by exact_mod_cast hc + have h := ((le_max_left _ _).trans hinv.1).trans (Rat.cast_le.mpr hinv.2.1) + exact (div_pos hcR (by linarith only [ha])).trans_le h + have hroundedGap : |stateLengthGap (physicalSource source node) target r| ≤ W := + ((le_max_right _ _).trans hZlower).trans hZW + have henergy := local_energy_discrepancy hmp hWpos hparentGap hroundedGap + (stateLengthGap_difference (physicalSource source node) target q r) hpositive.2 + have hslack := stageWarmup_comparison_slack source target hM U N P F A hsize hP hF hA hseed + T hT node hbelow hleaf q hc hnonempty + refine ⟨hnonempty, hK, sub_nonneg.mpr hZW, ?_, ?_⟩ + · change mp - W + (W - Z) ≤ _ + change mp - Z ≤ _ at hslack + linarith only [hslack] + · let Echild := ∑ i, (stateLengthGap (physicalSource source (physicalChild node hbelow i)) target + (action i)) ^ 2 / child i (action i) + change Echild - (stateLengthGap (physicalSource source node) target r) ^ 2 / W ≤ + (Echild - (stateLengthGap (physicalSource source node) target q) ^ 2 / mp) + + 3 * (targetEndpointDistance q r : ℝ) + 2 * max (-(mp - W)) 0 + have hid : -(mp - W) = W - mp := by ring + rw [hid] + linarith only [henergy] + +end Stage + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonPrediction.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonPrediction.lean new file mode 100644 index 0000000000000000000000000000000000000000..77b3bc71a26a6e4f8077604fb6a905eabf6b1a05 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageComparisonPrediction.lean @@ -0,0 +1,111 @@ +import OAI.Combinatorics.EditApproximation.Refinement.StageComparisonBad +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalOnlineBand + +namespace OAI + +/-! The actual comparison charges and rational velocity predictor at a physical slot. -/ + +namespace EditApproximation + +open Finset + +section Stage + +variable {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hP : 66 ≤ P) (T : ℕ) (rootQ : TargetInterval target.length) + +local notation "frontier" => comparisonFrontier source target hM P hP + (some (sourceIntervalAt M source.length 0 PUnit.unit, rootQ)) + +noncomputable def stageComparisonPrediction (d : Fin J) (path : TreeLayer M d.val) : ℚ := by + classical + exact match frontier d.val path with + | none => 0 + | some (parent, q) => if hstop : comparisonStopped source target parent q then 0 else + let hc : 0 < stateEditCost (substring source parent.lo parent.hi) target q := by + unfold comparisonStopped at hstop + omega + let node : PhysicalNode M J := ⟨⟨d.val, by omega⟩, path⟩ + let b := 2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q) + let r := roundInterval (seedGridSpacing b P) q + let action := comparisonChildren source target hM P hP parent q hc + let hn : wideActionList M parent r b P ≠ [] := by + have hmem := (comparisonChildren_spec source target hM P hP parent q hc).1 + intro heq + rw [heq] at hmem + exact List.not_mem_nil hmem + rationalStateGap (substring source parent.lo parent.hi) target r / + rationalWideActionMinimum parent r b P hn + (physicalBandChildMassTable source target U N P F A T node d.isLt) + + theorem stageComparisonPrediction_active (d : Fin J) (path : TreeLayer M d.val) + (q : TargetInterval target.length) + (heq : frontier d.val path = some (sourceIntervalAt M source.length d.val path, q)) + (hactive : ¬ comparisonStopped source target (sourceIntervalAt M source.length d.val path) q) + (hn : wideActionList M (sourceIntervalAt M source.length d.val path) + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q)) P) q) + (2 ^ Nat.log 2 (stateEditCost (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q)) P ≠ []) : + stageComparisonPrediction source target hM U N P F A hP T rootQ d path = + rationalStateGap (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q)) P) q) / + rationalWideActionMinimum (sourceIntervalAt M source.length d.val path) + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q)) P) q) + (2 ^ Nat.log 2 (stateEditCost (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q)) P hn + (physicalBandChildMassTable source target U N P F A T + (⟨⟨d.val, by omega⟩, path⟩ : PhysicalNode M J) d.isLt) := by + unfold stageComparisonPrediction + rw [heq] + simp only [dite_eq_right hactive] + + theorem stageComparisonCharges_active (d : Fin J) (path : TreeLayer M d.val) + (q : TargetInterval target.length) + (heq : frontier d.val path = some (sourceIntervalAt M source.length d.val path, q)) + (hactive : ¬ comparisonStopped source target (sourceIntervalAt M source.length d.val path) q) + (hc : 0 < stateEditCost (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q) + (hn : wideActionList M (sourceIntervalAt M source.length d.val path) + (roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost + (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q)) P) q) + (2 ^ Nat.log 2 (stateEditCost (substring source (sourceIntervalAt M source.length d.val path).lo + (sourceIntervalAt M source.length d.val path).hi) target q)) P ≠ []) : + let parent := sourceIntervalAt M source.length d.val path + let node : PhysicalNode M J := ⟨⟨d.val, by omega⟩, path⟩ + let r := roundInterval (seedGridSpacing (2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q)) P) q + let action := comparisonChildren source target hM P hP parent q hc + let child := fun i s => (physicalBandChildMassTable source target U N P F A T node d.isLt i s : ℝ) + stageComparisonCharges source target hM U N P F A hP T rootQ d path = + (comparisonActionCurvature source target parent r action child, + comparisonActionMass action child - wideActionMinimum parent r + (2 ^ Nat.log 2 (stateEditCost (substring source parent.lo parent.hi) target q)) P hn child) := by + unfold stageComparisonCharges + rw [heq] + simp only [dite_eq_right hactive] + rfl + +end Stage + +theorem nonbad_charge_bounds (scale ratio K G : ℝ) (hratio : 0 < ratio) + (hnotbad : ¬ (scale < ratio * K ∨ scale < ratio * G)) : + K ≤ scale / ratio ∧ G ≤ scale / ratio := by + have h := not_or.mp hnotbad + constructor + · apply (le_div_iff₀ hratio).2 + simpa only [mul_comm] using le_of_not_gt h.1 + · apply (le_div_iff₀ hratio).2 + simpa only [mul_comm] using le_of_not_gt h.2 + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageParameterBounds.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageParameterBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..64f990535a87d4e640e072244b33dadd055d1125 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageParameterBounds.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.EditApproximation.Refinement.StageWarmup +import OAI.Combinatorics.EditApproximation.Geometry.GroupSmallConstants + +namespace OAI + +/-! Computed parameters for the actual local energy and online inequalities. -/ + +namespace EditApproximation + +theorem refinementFactor_le {A : ℚ} {F : ℕ} (hA : 1 ≤ A) (hF : 1 ≤ F) : + refinementFactor A F ≤ A := by + apply max_le hA + have hFQ : (1 : ℚ) ≤ F := by exact_mod_cast hF + apply (div_le_iff₀ (by linarith only [hFQ] : (0 : ℚ) < F)).2 + have h := mul_le_mul_of_nonneg_left hFQ (by linarith only [hA] : 0 ≤ A) + simpa only [mul_one] using h + +theorem computed_initialFactor_twice_le_P (N : ℕ) (hN : 0 < N) : + 2 * (integerParameters N).initialFactor ≤ (integerParameters N).P := by + let H := inputHeight N + let p := coarseExponent (inputSmallLog N) + have hH : 2 ≤ H := by + have h := pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) (heightExponent_pos N hN) + simpa only [H, inputHeight, pow_one] using h + have hHone : 1 ≤ H := by omega + have hpow : 2 ≤ H ^ 16 := hH.trans (by + simpa only [pow_one] using pow_le_pow_right₀ hHone (by decide : 1 ≤ 16)) + change 2 * H ^ (p + 4) ≤ H ^ (p + 20) + calc + 2 * H ^ (p + 4) ≤ H ^ (p + 4) * H ^ 16 := by + simpa only [mul_comm] using Nat.mul_le_mul_left (H ^ (p + 4)) hpow + _ = H ^ (p + 20) := by + rw [← pow_add] + +theorem computed_refinementFactor_spacing (N : ℕ) (hN : 0 < N) (A : ℚ) + (hA : 1 ≤ A) (hupper : A ≤ (integerParameters N).initialFactor) : + 2 * (refinementFactor A (inputSmallLog N) : ℝ) ≤ (integerParameters N).P := by + have hfactor := refinementFactor_le hA (show 1 ≤ inputSmallLog N from Nat.one_le_two_pow) + have hnum : (2 : ℚ) * (integerParameters N).initialFactor ≤ (integerParameters N).P := by + exact_mod_cast computed_initialFactor_twice_le_P N hN + have hQ : (2 : ℚ) * refinementFactor A (inputSmallLog N) ≤ (integerParameters N).P := by + linarith only [hfactor, hupper, hnum] + exact_mod_cast hQ + +theorem computed_online_range (ell : ℕ) (hell : 8 ≤ ell) : + 0 < (rationalParameters ell).eta ∧ 0 ≤ (rationalParameters ell).kappa ∧ + (rationalParameters ell).kappa ≤ 1 / 2 ∧ + ((rationalParameters ell).eta : ℝ) * + (2 * ((rationalParameters ell).delta : ℝ) + + 8 * (128 * (ell : ℝ)) * ((rationalParameters ell).theta : ℝ)) ≤ + ((rationalParameters ell).kappa : ℝ) := by + have hellQ : (8 : ℚ) ≤ ell := by exact_mod_cast hell + have he0 : (0 : ℚ) < ell := by linarith only [hellQ] + have hpow : (2 : ℚ) ≤ (ell : ℚ) ^ 4 := by + exact (by linarith only [hellQ] : (2 : ℚ) ≤ ell).trans (by + simpa only [pow_one] using pow_le_pow_right₀ (by linarith only [hellQ] : (1 : ℚ) ≤ ell) + (by decide : 1 ≤ 4)) + have hhalf : (1 : ℚ) / (ell : ℚ) ^ 4 ≤ 1 / 2 := by + exact (div_le_div_iff₀ (pow_pos he0 4) (by norm_num : (0 : ℚ) < 2)).2 (by simpa using hpow) + have hrange := group_online_range_small hellQ + have heta := group_online_eta_range (by linarith only [hellQ] : (3 : ℚ) ≤ ell) + have h := mul_le_mul_of_nonneg_left hrange (pow_nonneg he0.le 5) + have hQ : (ell : ℚ) ^ 5 * (2 * (1 / (ell : ℚ) ^ 10) + + 8 * (128 * ell) * (1 / (ell : ℚ) ^ 40)) ≤ 1 / (ell : ℚ) ^ 4 := by + linarith only [h, heta] + refine ⟨pow_pos he0 5, (by positivity : (0 : ℚ) ≤ 1 / (ell : ℚ) ^ 4), hhalf, ?_⟩ + have hR := (Rat.cast_le (K := ℝ)).mpr hQ + simpa only [rationalParameters, Rat.cast_mul, Rat.cast_add, Rat.cast_div, Rat.cast_pow, + Rat.cast_one, Rat.cast_ofNat, Rat.cast_natCast, Nat.cast_mul, Nat.cast_ofNat] using hR + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageTerminal.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageTerminal.lean new file mode 100644 index 0000000000000000000000000000000000000000..c77d67e44bc97491919fad8df008f300f223212c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageTerminal.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRefinementSpatial +import OAI.Combinatorics.EditApproximation.Geometry.ComparisonTree + +namespace OAI + +/-! Warmup masses and refinement values equal the true cost at stopped states. -/ + +namespace EditApproximation + +theorem stageWarmupMass_zero_cost {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) (q : TargetInterval target.length) + (hcost : stateEditCost (physicalSource source node) target q = 0) : + stageWarmupMass source target U N P F A T (node, q) = 0 := by + have h := stageWarmup_invariants source target hM U N P F A hsize hP hF hA hseed T hT (node, q) + have hu := h.2.2.1.trans h.2.2.2 + rw [hcost] at hu + simp only [Nat.cast_zero, mul_zero] at hu + have hzero : 0 ≤ physicalLower source target (refinementFactor A F : ℝ) (node, q) := + (abs_nonneg _).trans (le_max_right _ _) + have hw : 0 ≤ stageWarmup source target U N P F A T (node, q) := + (Rat.cast_nonneg (K := ℝ)).mp (hzero.trans h.1) + exact le_antisymm hu (hw.trans h.2.1) + +theorem stageWarmupMass_at_stopped {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (node : PhysicalNode M J) (q : TargetInterval target.length) + (hstop : comparisonStopped source target (physicalSourceInterval source.length node) q) : + stageWarmupMass source target U N P F A T (node, q) = + stateEditCost (physicalSource source node) target q := by + rcases hstop with hleaf | hcost + · exact stageWarmupMass_at_leaf source target U N P F A T hT node hleaf q + · rw [stageWarmupMass_zero_cost source target hM U N P F A hsize hP hF hA hseed T hT node q hcost] + rw [show stateEditCost (physicalSource source node) target q = 0 from hcost, Nat.cast_zero] + +theorem physicalRefinement_at_stopped {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) (U : PhysicalEntry M J target.length → ℕ) + (N P F : ℕ) (A : ℚ) (hsize : source.length + target.length ≤ N) + (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (delta : ℚ) + (choices : PhysicalSelections M J source.length target.length P + (stageRepresentatives source target U N P F A)) (node : PhysicalNode M J) + (t : ℕ) (q : TargetInterval target.length) + (hstop : comparisonStopped source target (physicalSourceInterval source.length node) q) : + physicalRefinement source target U N P F A T delta choices node t q = + stateEditCost (physicalSource source node) target q := by + rcases hstop with hleaf | hcost + · exact physicalRefinement_at_leaf source target U N P F A T delta choices node hleaf t q + · rw [physicalRefinement_zero_cost source target hM U N P F A hsize hP hF hA hseed + T hT delta choices node t q hcost] + rw [show stateEditCost (physicalSource source node) target q = 0 from hcost, Nat.cast_zero] + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Refinement/StageWarmup.lean b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageWarmup.lean new file mode 100644 index 0000000000000000000000000000000000000000..59ceaf80ad6af91ebe8594b2c4845298dfeec61d --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Refinement/StageWarmup.lean @@ -0,0 +1,85 @@ +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalInitial +import OAI.Combinatorics.EditApproximation.Refinement.PhysicalRationalWarmup +import OAI.Combinatorics.EditApproximation.Geometry.ActualRepresentatives +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! The literal initial table, representative enumeration and rational warmup of one refinement pass. -/ + +namespace EditApproximation + + + +theorem refinementFactor_spec (A : ℚ) (F : ℕ) (hF : 0 < F) : + 1 ≤ refinementFactor A F ∧ A ≤ refinementFactor A F * F := by + have hFr : (0 : ℚ) < F := by exact_mod_cast hF + refine ⟨le_max_left _ _, ?_⟩ + have h := mul_le_mul_of_nonneg_right (le_max_right (1 : ℚ) (A / F)) hFr.le + rw [div_mul_cancel₀ _ hFr.ne'] at h + exact h + +def stageInitial {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) : + PhysicalEntry M J target.length → ℚ := + physicalInitialTable source target U N P F A (refinementFactor A F) + +def stageRepresentatives {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (node : PhysicalNode M J) : List (ℕ × TargetInterval target.length) := + representativeList N P F (refinementFactor A F) (fun q => stageInitial source target U N P F A (node, q)) + +def stageWarmup {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) : + ℕ → PhysicalEntry M J target.length → ℚ := + rationalPhysicalWarmup source target P (128 * F) (stageInitial source target U N P F A) + (stageRepresentatives source target U N P F A) + +def stageWarmupMass {α : Type*} [DecidableEq α] {M J : ℕ} (source target : List α) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) (T : ℕ) : + PhysicalEntry M J target.length → ℚ := + rationalPhysicalWarmupAverage source target P (128 * F) (stageInitial source target U N P F A) + (stageRepresentatives source target U N P F A) T + +theorem stageWarmup_invariants {α : Type*} [DecidableEq α] {M J : ℕ} + (source target : List α) (hM : 0 < M) + (U : PhysicalEntry M J target.length → ℕ) (N P F : ℕ) (A : ℚ) + (hsize : source.length + target.length ≤ N) (hP : 66 ≤ P) (hF : 1 ≤ F) (hA : 1 ≤ A) + (hseed : ∀ state, stateEditCost (physicalSource source state.1) target state.2 ≤ U state ∧ + (U state : ℚ) ≤ A * stateEditCost (physicalSource source state.1) target state.2) + (T : ℕ) (hT : 0 < T) (state : PhysicalEntry M J target.length) : + physicalLower source target (refinementFactor A F : ℝ) state ≤ + (stageWarmup source target U N P F A T state : ℝ) ∧ + stageWarmup source target U N P F A T state ≤ stageWarmupMass source target U N P F A T state ∧ + stageWarmupMass source target U N P F A T state ≤ stageInitial source target U N P F A state ∧ + stageInitial source target U N P F A state ≤ + 2 * F * stateEditCost (physicalSource source state.1) target state.2 := by + have hfactor := refinementFactor_spec A F (by omega) + have hinit := physicalInitialTable_real_lower source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed + have haR : (1 : ℝ) ≤ refinementFactor A F := by exact_mod_cast hfactor.1 + have hLR : (1 : ℝ) ≤ (128 * F : ℚ) := by + have hFr : (1 : ℚ) ≤ F := by exact_mod_cast hF + exact_mod_cast (show (1 : ℚ) ≤ 128 * F by linarith) + have hlower := physicalWarmup_lower source target hM P (refinementFactor A F : ℝ) + ((128 * F : ℚ) : ℝ) haR hLR + (fun s => (stageInitial source target U N P F A s : ℝ)) + (stageRepresentatives source target U N P F A) hinit T state + have hsandwich := physicalWarmup_average_sandwich source target P ((128 * F : ℚ) : ℝ) + (fun s => (stageInitial source target U N P F A s : ℝ)) + (stageRepresentatives source target U N P F A) T hT state + have hupper := (physicalInitialTable_bounds source target U N P F A (refinementFactor A F) + hsize hP hF hA hfactor.1 hfactor.2 hseed state).2 + refine ⟨?_, ?_, ?_, hupper⟩ + · simpa only [stageWarmup, rationalPhysicalWarmup_cast] using hlower + · have h := hsandwich.1 + rw [← rationalPhysicalWarmup_cast, ← rationalPhysicalWarmupAverage_cast] at h + exact Rat.cast_le.mp h + · have h := hsandwich.2 + rw [← rationalPhysicalWarmupAverage_cast] at h + exact Rat.cast_le.mp h + +end EditApproximation + +end OAI diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/ConcreteFootprintBridges.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/ConcreteFootprintBridges.lean new file mode 100644 index 0000000000000000000000000000000000000000..62ab7c82074aaed55dc7eee3f272afe32b8efa20 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/ConcreteFootprintBridges.lean @@ -0,0 +1,2468 @@ +import OAI.Combinatorics.EditApproximation.Specification.ConcreteFootprints +import OAI.Combinatorics.EditApproximation.Definitions + +namespace OAI.EditApproximation + +universe u_1 u_2 + +private theorem footprint_cases {ι β : Type*} {program : BitQuery ι β} + {p : Prop} (d : Decidable p) (no : ¬p → BitQuery.Heap program) + (yes : p → BitQuery.Heap program) : + (Decidable.casesOn (motive := fun _ => BitQuery.Heap program) d no yes).footprint = + Decidable.casesOn (motive := fun _ => BitQuery.Footprint program) d + (fun h => (no h).footprint) (fun h => (yes h).footprint) := by + cases d <;> rfl + +private theorem cases_congr {p : Prop} (d : Decidable p) {α : Sort*} + {no otherNo : ¬p → α} {yes otherYes : p → α} + (hn : ∀ h, no h = otherNo h) (hy : ∀ h, yes h = otherYes h) : + Decidable.casesOn (motive := fun _ => α) d no yes = + Decidable.casesOn (motive := fun _ => α) d otherNo otherYes := by + cases d with + | isFalse h => exact hn h + | isTrue h => exact hy h + +private theorem footprint_congr_seven {α₁ : Sort*} {α₂ : Sort*} {α₃ : Sort*} {α₄ : Sort*} + {α₅ : Sort*} {α₆ : Sort*} {α₇ : Sort*} {β : Sort*} + {f : α₁ → α₂ → α₃ → α₄ → α₅ → α₆ → α₇ → β} + {a₁ b₁ : α₁} {a₂ b₂ : α₂} {a₃ b₃ : α₃} {a₄ b₄ : α₄} + {a₅ b₅ : α₅} {a₆ b₆ : α₆} {a₇ b₇ : α₇} + (h₁ : a₁ = b₁) (h₂ : a₂ = b₂) (h₃ : a₃ = b₃) (h₄ : a₄ = b₄) + (h₅ : a₅ = b₅) (h₆ : a₆ = b₆) (h₇ : a₇ = b₇) : + f a₁ a₂ a₃ a₄ a₅ a₆ a₇ = f b₁ b₂ b₃ b₄ b₅ b₆ b₇ := by + cases h₁; cases h₂; cases h₃; cases h₄; cases h₅; cases h₆; cases h₇ + rfl + +private theorem footprint_mpr_congr {ι β : Type*} {p q : BitQuery ι β} + (eqn : p = q) (a : BitQuery.Heap q) (b : BitQuery.Footprint q) + (hab : a.footprint = b) : + ((congrArg BitQuery.Heap eqn).mpr a).footprint = + (congrArg BitQuery.Footprint eqn).mpr b := by + cases eqn + exact hab + +private def groupHeapTransportBridge (M J N n exponent F Q R B b c : ℕ) (h : b = c) + (actual : BitPhysicalGroupQueries M J N n exponent F Q R B b) + (heap : ∀ s j, BitQuery.Heap (actual s j)) : + ∀ s j, BitQuery.Heap + ((Eq.mp (congrArg (BitPhysicalGroupQueries M J N n exponent F Q R B) h) actual) s j) := by + cases h + exact heap + +private def groupFootprintTransportBridge (M J N n exponent F Q R B b c : ℕ) (h : b = c) + (actual : BitPhysicalGroupQueries M J N n exponent F Q R B b) + (heap : ∀ s j, BitQuery.Footprint (actual s j)) : + ∀ s j, BitQuery.Footprint + ((Eq.mp (congrArg (BitPhysicalGroupQueries M J N n exponent F Q R B) h) actual) s j) := by + cases h + exact heap + +private theorem footprint_groupTransport (M J N n exponent F Q R B b c : ℕ) (h : b = c) + (actual : BitPhysicalGroupQueries M J N n exponent F Q R B b) + (heap : ∀ s j, BitQuery.Heap (actual s j)) + (footprint : ∀ s j, BitQuery.Footprint (actual s j)) + (hfp : ∀ s j, (heap s j).footprint = footprint s j) : + ∀ s j, (groupHeapTransportBridge M J N n exponent F Q R B b c h actual heap s j).footprint = + groupFootprintTransportBridge M J N n exponent F Q R B b c h actual footprint s j := by + cases h + intro s j + exact hfp s j + +-- Supply case arguments directly so inference does not normalize indexed branch values. +universe u + +private theorem heq_decidable_cases_from {p : Prop} (left right : Decidable p → Sort u) + {α β : Sort u} (outerLeft : α) (outerRight : β) + (leftNo : ∀ h : ¬p, left (.isFalse h)) (leftYes : ∀ h : p, left (.isTrue h)) + (rightNo : ∀ h : ¬p, right (.isFalse h)) (rightYes : ∀ h : p, right (.isTrue h)) + (decision : Decidable p) + (hleft : HEq outerLeft (Decidable.casesOn (motive := left) decision leftNo leftYes)) + (hright : HEq (Decidable.casesOn (motive := right) decision rightNo rightYes) outerRight) + (hn : ∀ h, HEq (leftNo h) (rightNo h)) (hy : ∀ h, HEq (leftYes h) (rightYes h)) : + HEq outerLeft outerRight := by + refine hleft.trans ?_ + refine HEq.trans ?_ hright + cases decision with + | isFalse h => exact hn h + | isTrue h => exact hy h + +open Lean Meta Elab Tactic in +local elab "direct_decidable_heq" : tactic => withMainContext do + let initialTarget ← instantiateMVars (← (← getMainGoal).getType) + if initialTarget.isAppOfArity ``Eq 3 then + evalTactic (← `(tactic| apply eq_of_heq)) + let goal ← getMainGoal + goal.withContext do + let target ← instantiateMVars (← goal.getType) + unless target.isAppOfArity ``HEq 4 do + throwError "expected heterogeneous equality" + let sides := target.getAppArgs + let recArgs (value : Expr) : MetaM (Array Expr) := do + let value := value.consumeMData + let value := if value.getAppFn.isConstOf ``id && value.getAppArgs.size == 2 then + value.getAppArgs[1]!.consumeMData else value + let args := value.getAppArgs + unless args.size == 5 do + throwError "unexpected Decidable recursor arity {args.size} at {value.getAppFn}" + if value.getAppFn.isConstOf ``Decidable.rec then + pure args + else if value.getAppFn.isConstOf ``Decidable.casesOn then + pure #[args[0]!, args[1]!, args[3]!, args[4]!, args[2]!] + else + throwError "expected a Decidable recursor, got {value.getAppFn}" + let left ← recArgs sides[1]! + let right ← recArgs sides[3]! + unless left[0]! == right[0]! && left[4]! == right[4]! do + throwError "the case expressions use different propositions or decisions" + let proof ← withTransparency .default <| mkAppM ``heq_decidable_cases_from + #[left[1]!, right[1]!, sides[1]!, sides[3]!, left[2]!, left[3]!, right[2]!, right[3]!, left[4]!] + let goals ← withTransparency .default <| goal.apply proof + replaceMainGoal goals + +private theorem heq_mpr_both {α β γ δ : Sort u} (leftEq : α = β) (rightEq : γ = δ) + (left : β) (right : δ) (h : HEq left right) : HEq (leftEq.mpr left) (rightEq.mpr right) := by + cases leftEq + cases rightEq + exact h + +open Lean Meta Elab Tactic in +local elab "direct_mpr_heq" : tactic => withMainContext do + let initialTarget ← instantiateMVars (← (← getMainGoal).getType) + if initialTarget.isAppOfArity ``Eq 3 then + evalTactic (← `(tactic| apply eq_of_heq)) + let goal ← getMainGoal + goal.withContext do + let target ← instantiateMVars (← goal.getType) + unless target.isAppOfArity ``HEq 4 do + throwError "expected heterogeneous equality" + let sides := target.getAppArgs + let castArgs (value : Expr) : MetaM (Array Expr) := do + let value := value.consumeMData + unless value.getAppFn.isConstOf ``Eq.mpr && value.getAppArgs.size == 4 do + throwError "expected Eq.mpr, got {value.getAppFn}" + pure value.getAppArgs + let left ← castArgs sides[1]! + let right ← castArgs sides[3]! + let proof ← withTransparency .default <| mkAppM ``heq_mpr_both + #[left[2]!, right[2]!, left[3]!, right[3]!] + let goals ← withTransparency .default <| goal.apply proof + replaceMainGoal goals + +@[simp] theorem queryInitialGatherHeap_footprint : + ∀ {ι : Type u_1} {β : Type u_2} {n : Nat} (N P F exponent : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (a : OAI.EditApproximation.BinaryFraction) (q : OAI.EditApproximation.TargetInterval n) + (reader : + OAI.EditApproximation.TargetInterval n → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hr : + (key : OAI.EditApproximation.TargetInterval n) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader key)) + (next : + List.{0} (OAI.EditApproximation.TargetInterval n) → + List.{0} OAI.EditApproximation.BinaryFraction → OAI.EditApproximation.BitQuery.{u_1, u_2} ι β) + (hn : + (keys : List.{0} (OAI.EditApproximation.TargetInterval n)) → + (words : List.{0} OAI.EditApproximation.BinaryFraction) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, u_2} ι β (next keys words)), + @Eq.{(max u_1 u_2) + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryInitialGather.{u_1, u_2} ι β n N P F exponent hP a q reader next)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryInitialGather.{u_1, u_2} ι β n N P F exponent hP a q reader next) + (@OAI.EditApproximation.queryInitialGatherHeap.{u_1, u_2} ι β n N P F exponent hP a q reader hr next hn)) + (@OAI.EditApproximation.queryInitialGatherFootprint.{u_1, u_2} ι β n N P F exponent hP a q reader + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader key) + (hr key)) + next fun keys words => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β (next keys words) (hn keys words)) := by + intros + simp [queryInitialGatherHeap, queryInitialGatherFootprint, queryInitialGather] + +@[simp] theorem queryBandGatherHeap_footprint : + ∀ {ι : Type u_1} {β : Type u_2} {nx ny : Nat} (M : Nat) (parent : OAI.EditApproximation.TargetInterval nx) + (N P F exponent : Nat) (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (a : OAI.EditApproximation.BinaryFraction) + (initial : OAI.EditApproximation.TargetInterval ny → Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (allocation : OAI.EditApproximation.TargetInterval ny → Nat) + (ha : + ∀ (r : OAI.EditApproximation.TargetInterval ny), + @LE.le.{0} Nat instLENat (allocation r) (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (initial r))) + (q : OAI.EditApproximation.TargetInterval ny) + (massReader initialReader : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval ny) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hm : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval ny)) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (massReader key)) + (hi : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval ny)) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (initialReader key)) + (next : + List.{0} (Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval ny)) → + List.{0} OAI.EditApproximation.BinaryFraction → + List.{0} OAI.EditApproximation.BinaryFraction → OAI.EditApproximation.BitQuery.{u_1, u_2} ι β) + (hn : + (keys : List.{0} (Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval ny))) → + (mass words : List.{0} OAI.EditApproximation.BinaryFraction) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, u_2} ι β (next keys mass words)), + @Eq.{(max u_1 u_2) + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryBandGather.{u_1, u_2} ι β nx ny M parent N P F exponent hP a initial q massReader + initialReader next)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryBandGather.{u_1, u_2} ι β nx ny M parent N P F exponent hP a initial q massReader + initialReader next) + (@OAI.EditApproximation.queryBandGatherHeap.{u_1, u_2} ι β nx ny M parent N P F exponent hP a initial allocation + ha q massReader initialReader hm hi next hn)) + (@OAI.EditApproximation.queryBandGatherFootprint.{u_1, u_2} ι β nx ny M parent N P F exponent hP a initial + allocation q massReader initialReader + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (massReader key) + (hm key)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (initialReader key) (hi key)) + next fun keys mass words => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β (next keys mass words) (hn keys mass words)) := by + intros + simp [queryBandGatherHeap, queryBandGatherFootprint, queryBandGather] + +@[simp] theorem queryGroupSourceGatherHeap_footprint : + ∀ {ι : Type u_1} {β : Type u_2} {n : Nat} (M N F Q exponent eM eF : Nat) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (a : OAI.EditApproximation.BinaryFraction) + (initial : OAI.EditApproximation.TargetInterval n → Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (allocation : OAI.EditApproximation.TargetInterval n → Nat) + (ha : + ∀ (r : OAI.EditApproximation.TargetInterval n), + @LE.le.{0} Nat instLENat (allocation r) (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (initial r))) + (q : OAI.EditApproximation.TargetInterval n) + (reader : + OAI.EditApproximation.GroupScalarKey M F Q → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hr : + (key : OAI.EditApproximation.GroupScalarKey M F Q) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader key)) + (next : + List.{0} (OAI.EditApproximation.GroupScalarKey M F Q) → + List.{0} OAI.EditApproximation.BinaryFraction → OAI.EditApproximation.BitQuery.{u_1, u_2} ι β) + (hn : + (keys : List.{0} (OAI.EditApproximation.GroupScalarKey M F Q)) → + (words : List.{0} OAI.EditApproximation.BinaryFraction) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, u_2} ι β (next keys words)), + @Eq.{(max u_1 u_2) + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryGroupSourceGather.{u_1, u_2} ι β n M N F Q exponent eM eF hM hF a initial q reader + next)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryGroupSourceGather.{u_1, u_2} ι β n M N F Q exponent eM eF hM hF a initial q reader + next) + (@OAI.EditApproximation.queryGroupSourceGatherHeap.{u_1, u_2} ι β n M N F Q exponent eM eF hM hF a initial + allocation ha q reader hr next hn)) + (@OAI.EditApproximation.queryGroupSourceGatherFootprint.{u_1, u_2} ι β n M N F Q exponent eM eF hM hF a initial + allocation q reader + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader key) + (hr key)) + next fun keys words => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β (next keys words) (hn keys words)) := by + intros + simp [queryGroupSourceGatherHeap, queryGroupSourceGatherFootprint, queryGroupSourceGather] + +@[simp] theorem queryOnlineSourceGatherHeap_footprint : + ∀ {ι : Type u_1} {β : Type u_2} {nx ny M : Nat} (parent : OAI.EditApproximation.TargetInterval nx) + (N P F exponent H : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (tau a : OAI.EditApproximation.BinaryFraction) + (initial : OAI.EditApproximation.TargetInterval ny → Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (initialAllocation : OAI.EditApproximation.TargetInterval ny → Nat) + (child : Fin M → OAI.EditApproximation.TargetInterval ny → Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (childAllocation : Fin M → OAI.EditApproximation.TargetInterval ny → Nat) + (hi : + ∀ (r : OAI.EditApproximation.TargetInterval ny), + @LE.le.{0} Nat instLENat (initialAllocation r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (initial r))) + (hc : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval ny), + @LE.le.{0} Nat instLENat (childAllocation i r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (child i r))) + (q : OAI.EditApproximation.TargetInterval ny) + (reader : + Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval ny) → + Nat → OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hr : + (key : Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval ny)) → + (range : Nat) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader key range)) + (next : + List.{0} (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval ny)) → + List.{0} OAI.EditApproximation.BinaryFraction → OAI.EditApproximation.BitQuery.{u_1, u_2} ι β) + (hn : + (keys : List.{0} (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval ny))) → + (words : List.{0} OAI.EditApproximation.BinaryFraction) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, u_2} ι β (next keys words)), + @Eq.{(max u_1 u_2) + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryOnlineSourceGather.{u_1, u_2} ι β nx ny M parent N P F exponent H hP tau a initial + child q reader next)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β + (@OAI.EditApproximation.queryOnlineSourceGather.{u_1, u_2} ι β nx ny M parent N P F exponent H hP tau a initial + child q reader next) + (@OAI.EditApproximation.queryOnlineSourceGatherHeap.{u_1, u_2} ι β nx ny M parent N P F exponent H hP tau a + initial initialAllocation child childAllocation hi hc q reader hr next hn)) + (@OAI.EditApproximation.queryOnlineSourceGatherFootprint.{u_1, u_2} ι β nx ny M parent N P F exponent H hP tau a + initial initialAllocation child childAllocation q reader + (fun key range => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (reader key range) (hr key range)) + next fun keys words => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, u_2} ι β (next keys words) (hn keys words)) := by + intros + simp [queryOnlineSourceGatherHeap, queryOnlineSourceGatherFootprint, queryOnlineSourceGather] + +@[simp] theorem queryLocalRefinementHeap_footprint : + ∀ {ι : Type u_1} {α : Type u_2} (source target : List.{u_2} α) {M : Nat} + (parent : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α source)) (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (t : Nat) + (parentInitial : + OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → + Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (child initial : + Fin M → + OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → + Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (R : Nat) + (hc : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (child i r)) R) + (hi : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (initial i r)) R) + (draw : OAI.EditApproximation.CountedCellGroupDraws M F Q) + (integer : Nat → OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → Prod.{0, 0} Nat Nat) + (parentAllocation : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → Nat) + (childAllocation initialAllocation : Fin M → OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → Nat) + (drawAllocation : OAI.EditApproximation.CountedCellGroupAllocations M F Q) + (integerAllocation : Nat → OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → Nat) + (hp : + ∀ (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (parentAllocation r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (parentInitial r))) + (hca : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (childAllocation i r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (child i r))) + (hia : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (initialAllocation i r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (initial i r))) + (hd : + ∀ (b : Nat) (cell : Prod.{0, 0} Nat Nat) + (s : + Fin (@List.length.{0} Rat (OAI.EditApproximation.groupDyadicScales M b (@Nat.cast.{0} Rat Rat.instNatCast F)))) + (j : + Fin + (OAI.EditApproximation.groupSampleCount M Q b + (OAI.EditApproximation.groupDyadicScaleAt M b (@Nat.cast.{0} Rat Rat.instNatCast F) s))), + @LE.le.{0} Nat instLENat (drawAllocation b cell s j) (@Prod.snd.{0, 0} (Fin M) Nat (draw b cell s j))) + (hz : + ∀ (b : Nat) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (integerAllocation b r) (@Prod.snd.{0, 0} Nat Nat (integer b r))) + (q : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) + (readEarlier : + Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readCurrent : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (he : + (key : Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key)) + (hr : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalRefinement.{u_1, u_2} ι α source target M parent N P F exponent H Q eM eF hP hM + hF tau a eta kappa delta t parentInitial child initial R hc hi draw integer q readEarlier readCurrent)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalRefinement.{u_1, u_2} ι α source target M parent N P F exponent H Q eM eF hP hM + hF tau a eta kappa delta t parentInitial child initial R hc hi draw integer q readEarlier readCurrent) + (@OAI.EditApproximation.queryLocalRefinementHeap.{u_1, u_2} ι α source target M parent N P F exponent H Q eM eF hP + hM hF tau a eta kappa delta t parentInitial child initial R hc hi draw integer parentAllocation childAllocation + initialAllocation drawAllocation integerAllocation hp hca hia hd hz q readEarlier readCurrent he hr)) + (@OAI.EditApproximation.queryLocalRefinementFootprint.{u_1, u_2} ι α source target M parent N P F exponent H Q eM eF + hP hM hF tau a eta kappa delta t parentInitial child initial R hc hi draw integer parentAllocation childAllocation + initialAllocation drawAllocation integerAllocation q readEarlier readCurrent + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key) + (he key)) + fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key) + (hr key)) := by + intros + simp [queryLocalRefinementHeap, queryLocalRefinementFootprint, queryLocalRefinement, queryRefinementGather] + +@[simp] theorem queryLocalRandomSourcesHeap_footprint : + ∀ {ι : Type u_1} {α : Type u_2} (source target : List.{u_2} α) {M : Nat} + [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + (parent : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α source)) (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (t : Nat) + (parentInitial : + OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → + Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (child initial : + Fin M → + OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → + Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (R : Nat) + (hc : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (child i r)) R) + (hi : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (initial i r)) R) + (parentAllocation : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → Nat) + (childAllocation initialAllocation : Fin M → OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → Nat) + (hp : + ∀ (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (parentAllocation r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (parentInitial r))) + (hca : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (childAllocation i r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (child i r))) + (hia : + ∀ (i : Fin M) (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (initialAllocation i r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (initial i r))) + (q : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) + (readGroup : + OAI.EditApproximation.GroupScalarKey M F Q → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readInteger : + Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + Nat → OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readEarlier : + Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readCurrent : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hg : + (key : OAI.EditApproximation.GroupScalarKey M F Q) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readGroup key)) + (hz : + (key : Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + (range : Nat) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readInteger key range)) + (he : + (key : Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key)) + (hr : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalRandomSources.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM + eF hP hM hF tau a eta kappa delta t parentInitial child initial R hc hi q readGroup readInteger readEarlier + readCurrent)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalRandomSources.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM + eF hP hM hF tau a eta kappa delta t parentInitial child initial R hc hi q readGroup readInteger readEarlier + readCurrent) + (@OAI.EditApproximation.queryLocalRandomSourcesHeap.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q + eM eF hP hM hF tau a eta kappa delta t parentInitial child initial R hc hi parentAllocation childAllocation + initialAllocation hp hca hia q readGroup readInteger readEarlier readCurrent hg hz he hr)) + (@OAI.EditApproximation.queryLocalRandomSourcesFootprint.{u_1, u_2} ι α source target M _inst parent N P F exponent H + Q eM eF hP hM hF tau a eta kappa delta t parentInitial child initial R hc hi parentAllocation childAllocation + initialAllocation q readGroup readInteger readEarlier readCurrent + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readGroup key) + (hg key)) + (fun key range => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (readInteger key range) (hz key range)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key) + (he key)) + fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key) + (hr key)) := by + intros + simp [queryLocalRandomSourcesHeap, queryLocalRandomSourcesFootprint, queryLocalRandomSources] + +@[simp] theorem queryLocalBandHeap_footprint : + ∀ {ι : Type u_1} {α : Type u_2} (source target : List.{u_2} α) {M : Nat} + [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + (parent : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α source)) (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (t : Nat) + (parentInitial : + OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → + Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (parentAllocation : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → Nat) + (hp : + ∀ (r : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)), + @LE.le.{0} Nat instLENat (parentAllocation r) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (parentInitial r))) + (readMass readInitial : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readGroup : + OAI.EditApproximation.GroupScalarKey M F Q → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readInteger : + Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + Nat → OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (q : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) + (readEarlier : + Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readCurrent : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hm : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readMass key)) + (hi : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readInitial key)) + (hg : + (key : OAI.EditApproximation.GroupScalarKey M F Q) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readGroup key)) + (hz : + (key : Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + (range : Nat) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readInteger key range)) + (he : + (key : Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key)) + (hr : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalBand.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM eF hP hM + hF tau a eta kappa delta t parentInitial readMass readInitial readGroup readInteger q readEarlier readCurrent)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalBand.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM eF hP hM + hF tau a eta kappa delta t parentInitial readMass readInitial readGroup readInteger q readEarlier readCurrent) + (@OAI.EditApproximation.queryLocalBandHeap.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM eF hP + hM hF tau a eta kappa delta t parentInitial parentAllocation hp readMass readInitial readGroup readInteger q + readEarlier readCurrent hm hi hg hz he hr)) + (@OAI.EditApproximation.queryLocalBandFootprint.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM eF + hP hM hF tau a eta kappa delta t parentInitial parentAllocation readMass readInitial readGroup readInteger q + readEarlier readCurrent + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readMass key) + (hm key)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readInitial key) + (hi key)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readGroup key) + (hg key)) + (fun key range => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (readInteger key range) (hz key range)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key) + (he key)) + fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key) + (hr key)) := by + intros + simp [queryLocalBandHeap, queryLocalBandFootprint, queryLocalBand] + +@[simp] theorem queryLocalProgramHeap_footprint : + ∀ {ι : Type u_1} {α : Type u_2} (source target : List.{u_2} α) {M : Nat} + [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + (parent : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α source)) (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (t : Nat) + (readParent : + OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readMass readInitial : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readGroup : + OAI.EditApproximation.GroupScalarKey M F Q → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readInteger : + Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + Nat → OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (q : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) + (readEarlier : + Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (readCurrent : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hp : + (key : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readParent key)) + (hm : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readMass key)) + (hi : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readInitial key)) + (hg : + (key : OAI.EditApproximation.GroupScalarKey M F Q) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readGroup key)) + (hz : + (key : Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + (range : Nat) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readInteger key range)) + (he : + (key : Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key)) + (hr : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalProgram.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM eF hP + hM hF tau a eta kappa delta t readParent readMass readInitial readGroup readInteger q readEarlier readCurrent)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryLocalProgram.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM eF hP + hM hF tau a eta kappa delta t readParent readMass readInitial readGroup readInteger q readEarlier readCurrent) + (@OAI.EditApproximation.queryLocalProgramHeap.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM eF + hP hM hF tau a eta kappa delta t readParent readMass readInitial readGroup readInteger q readEarlier readCurrent + hp hm hi hg hz he hr)) + (@OAI.EditApproximation.queryLocalProgramFootprint.{u_1, u_2} ι α source target M _inst parent N P F exponent H Q eM + eF hP hM hF tau a eta kappa delta t readParent readMass readInitial readGroup readInteger q readEarlier + readCurrent + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readParent key) + (hp key)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readMass key) + (hm key)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readInitial key) + (hi key)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readGroup key) + (hg key)) + (fun key range => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (readInteger key range) (hz key range)) + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readEarlier key) + (he key)) + fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (readCurrent key) + (hr key)) := by + intros + simp [queryLocalProgramHeap, queryLocalProgramFootprint, queryLocalProgram] + +@[simp] theorem queryPhysicalTableReadHeap_footprint : + ∀ {M J n : Nat} (copies T S : Nat) (parent : OAI.EditApproximation.PhysicalTableRequest M J n) + (child : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S r) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S parent)), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S r) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S parent)) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryPhysicalTableRead M J n copies T S parent child)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S r) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S parent)) + OAI.EditApproximation.BinaryFraction (@OAI.EditApproximation.queryPhysicalTableRead M J n copies T S parent child) + (@OAI.EditApproximation.queryPhysicalTableReadHeap M J n copies T S parent child)) + (@OAI.EditApproximation.queryPhysicalTableReadFootprint M J n copies T S parent child) := by + intros + simp [queryPhysicalTableReadHeap, queryPhysicalTableReadFootprint, queryPhysicalTableRead] + +@[simp] theorem queryMeanReadHeap_footprint : + ∀ {ι : Type u_1} (count : Nat) + (reader : Fin count → OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (hr : + (i : Fin count) → @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader i)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryMeanRead.{u_1} ι count reader)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryMeanRead.{u_1} ι count reader) + (@OAI.EditApproximation.queryMeanReadHeap.{u_1} ι count reader hr)) + (@OAI.EditApproximation.queryMeanReadFootprint.{u_1} ι count reader fun i => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader i) (hr i)) := by + intros + simp [queryMeanReadHeap, queryMeanReadFootprint, queryMeanRead] + +@[simp] theorem queryPhysicalEarlierReadHeap_footprint : + ∀ {M J n : Nat} (copies pass copy T S t : Nat) (node : OAI.EditApproximation.PhysicalNode M J) + (hbelow : + @LT.lt.{0} Nat instLTNat + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@Sigma.fst.{0, 0} + (Fin + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))) + (fun d => + OAI.EditApproximation.TreeLayer M + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + d)) + node)) + J) + (q : OAI.EditApproximation.TargetInterval n) + (input : Prod.{0, 0} (Fin M) (Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval n))), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun child => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S + (@OAI.EditApproximation.PhysicalTableRequest.refinement M J n pass copy node T t q))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryPhysicalEarlierRead M J n copies pass copy T S t node hbelow q input)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun child => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S + (@OAI.EditApproximation.PhysicalTableRequest.refinement M J n pass copy node T t q))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryPhysicalEarlierRead M J n copies pass copy T S t node hbelow q input) + (@OAI.EditApproximation.queryPhysicalEarlierReadHeap M J n copies pass copy T S t node hbelow q input)) + (@OAI.EditApproximation.queryPhysicalEarlierReadFootprint M J n copies pass copy T S t node hbelow q input) := by + intros + unfold queryPhysicalEarlierReadHeap queryPhysicalEarlierReadFootprint + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + with_unfolding_all apply cases_congr + · intro h + apply footprint_mpr_congr (dite_eq_right h) + rfl + · intro h + apply footprint_mpr_congr (dite_eq_left h) + apply queryPhysicalTableReadHeap_footprint + +@[simp] theorem queryPhysicalRandomDataRequestHeap_footprint : + ∀ {σ : Type u_1} {α : Type u_2} (source target : List.{u_2} α) {M J : Nat} + [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (copies pass copy T S t : Nat) + (ht : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) t) + (node : OAI.EditApproximation.PhysicalNode M J) + (hbelow : + @LT.lt.{0} Nat instLTNat + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@Sigma.fst.{0, 0} + (Fin + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))) + (fun d => + OAI.EditApproximation.TreeLayer M + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + d)) + node)) + J) + (readGroup : + OAI.EditApproximation.GroupScalarKey M F Q → + OAI.EditApproximation.BitQuery.{u_1, 0} σ OAI.EditApproximation.BinaryFraction) + (readInteger : + Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) → + Nat → OAI.EditApproximation.BitQuery.{u_1, 0} σ OAI.EditApproximation.BinaryFraction) + (q : OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target)) + (hg : + (key : OAI.EditApproximation.GroupScalarKey M F Q) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} σ OAI.EditApproximation.BinaryFraction (readGroup key)) + (hz : + (key : Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_2} α target))) → + (range : Nat) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} σ OAI.EditApproximation.BinaryFraction (readInteger key range)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} + (Sum.{u_1, 0} σ + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_2} α target)) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_2} α target) T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_2} α target) T S + (@OAI.EditApproximation.PhysicalTableRequest.refinement M J (@List.length.{u_2} α target) pass copy node T + t q)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryPhysicalRandomDataRequest.{u_1, u_2} σ α source target M J _inst N P F exponent H Q eM + eF hP hM hF tau a eta kappa delta copies pass copy T S t ht node hbelow readGroup readInteger q)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} + (Sum.{u_1, 0} σ + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_2} α target)) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_2} α target) T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_2} α target) T S + (@OAI.EditApproximation.PhysicalTableRequest.refinement M J (@List.length.{u_2} α target) pass copy node T + t q)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryPhysicalRandomDataRequest.{u_1, u_2} σ α source target M J _inst N P F exponent H Q eM + eF hP hM hF tau a eta kappa delta copies pass copy T S t ht node hbelow readGroup readInteger q) + (@OAI.EditApproximation.queryPhysicalRandomDataRequestHeap.{u_1, u_2} σ α source target M J _inst N P F exponent H + Q eM eF hP hM hF tau a eta kappa delta copies pass copy T S t ht node hbelow readGroup readInteger q hg hz)) + (@OAI.EditApproximation.queryPhysicalRandomDataRequestFootprint.{u_1, u_2} σ α source target M J _inst N P F exponent + H Q eM eF hP hM hF tau a eta kappa delta copies pass copy T S t ht node hbelow readGroup readInteger q + (fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} σ OAI.EditApproximation.BinaryFraction (readGroup key) + (hg key)) + fun key range => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} σ OAI.EditApproximation.BinaryFraction + (readInteger key range) (hz key range)) := by + intros + unfold queryPhysicalRandomDataRequestHeap queryPhysicalRandomDataRequestFootprint queryPhysicalRandomDataRequest + refine (queryLocalProgramHeap_footprint ..).trans ?_ + apply footprint_congr_seven + all_goals funext input + all_goals try funext range + all_goals refine (BitQuery.Heap.footprint_mapKeysWithWork _ _ _ _).trans ?_ + all_goals apply congrArg (BitQuery.Footprint.mapKeysWithWork _ _) + all_goals first + | rfl + | apply queryPhysicalTableReadHeap_footprint + | apply queryPhysicalEarlierReadHeap_footprint + | (refine (queryMeanReadHeap_footprint ..).trans ?_; congr 1) + +@[simp] theorem queryPhysicalScalarReadHeap_footprint : + ∀ (M J N n exponent F Q R B : Nat) (key : OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) + OAI.EditApproximation.BinaryFraction (OAI.EditApproximation.queryPhysicalScalarRead M J N n exponent F Q R B key)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.queryPhysicalScalarRead M J N n exponent F Q R B key) + (OAI.EditApproximation.queryPhysicalScalarReadHeap M J N n exponent F Q R B key)) + (OAI.EditApproximation.queryPhysicalScalarReadFootprint M J N n exponent F Q R B key) := by + intros + simp [queryPhysicalScalarReadHeap, queryPhysicalScalarReadFootprint, queryPhysicalScalarRead] + +private def scalarGroupFootprintBridge (M J N n exponent F Q R B : ℕ) + (node : PhysicalInternalNode M J) (time : Fin R) (b : ℕ) (cell : ℕ × ℕ) : + ∀ s j, BitQuery.Footprint (queryPhysicalScalarGroupQueries M J N n exponent F Q R B node time b cell s j) := by + intro s j + refine (congrArg BitQuery.Footprint (congrArg + (fun f : BitPhysicalGroupQueries M J N n exponent F Q R B b => f s j) + (queryPhysicalScalarGroupQueries.eq_1 M J N n exponent F Q R B node time b cell))).mpr ?_ + split + · rename_i hb + split + · rename_i hc + let key : PhysicalLocalGroupKey M J N n exponent := + (node, physicalScaleIndex N b ((queryScalePresentWithWork_value N b).mp hb), + ⟨cell.1, Nat.lt_succ_of_le ((queryCellValidWithWork_value n exponent cell).mp hc).1⟩, + ⟨cell.2, Nat.lt_succ_of_le ((queryCellValidWithWork_value n exponent cell).mp hc).2⟩) + exact groupFootprintTransportBridge M J N n exponent F Q R B _ _ + (physicalScaleIndex_get N b ((queryScalePresentWithWork_value N b).mp hb)) + (queryPhysicalScalarGroupQueriesAt M J N n exponent F Q R B key time) + (fun s j => (congrArg BitQuery.Footprint + (queryPhysicalScalarGroupQueriesAt.eq_1 M J N n exponent F Q R B key time s j)).mpr + (queryPhysicalScalarReadFootprint M J N n exponent F Q R B + ⟨Sum.inr key, ⟨time, ⟨s, j⟩⟩⟩)) s j + · exact .done _ + · exact .done _ + +@[simp] theorem queryPhysicalScalarGroupQueriesHeap_footprint : + ∀ (M J N n exponent F Q R B : Nat) (node : OAI.EditApproximation.PhysicalInternalNode M J) (time : Fin R) (b : Nat) + (cell : Prod.{0, 0} Nat Nat) + (s : Fin (@List.length.{0} Rat (OAI.EditApproximation.groupDyadicScales M b (@Nat.cast.{0} Rat Rat.instNatCast F)))) + (j : + Fin + (OAI.EditApproximation.groupSampleCount M Q b + (OAI.EditApproximation.groupDyadicScaleAt M b (@Nat.cast.{0} Rat Rat.instNatCast F) s))), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) + OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.queryPhysicalScalarGroupQueries M J N n exponent F Q R B node time b cell s j)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.queryPhysicalScalarGroupQueries M J N n exponent F Q R B node time b cell s j) + (OAI.EditApproximation.queryPhysicalScalarGroupQueriesHeap M J N n exponent F Q R B node time b cell s j)) + (OAI.EditApproximation.queryPhysicalScalarGroupQueriesFootprint M J N n exponent F Q R B node time b cell s j) := by + intro M J N n exponent F Q R B node time b cell s j + have hbridge : (queryPhysicalScalarGroupQueriesHeap M J N n exponent F Q R B node time b cell s j).footprint = + scalarGroupFootprintBridge M J N n exponent F Q R B node time b cell s j := by + unfold queryPhysicalScalarGroupQueriesHeap scalarGroupFootprintBridge + apply footprint_mpr_congr (congrArg + (fun f : BitPhysicalGroupQueries M J N n exponent F Q R B b => f s j) + (queryPhysicalScalarGroupQueries.eq_1 M J N n exponent F Q R B node time b cell)) + dsimp only [id] + rw [footprint_cases (instDecidableEqBool (queryScalePresentWithWork N b).1 true)] + refine congrFun ?_ (instDecidableEqBool (queryScalePresentWithWork N b).1 true) + funext decision + cases decision with + | isFalse h => + apply footprint_mpr_congr (congrArg (fun f : BitPhysicalGroupQueries M J N n exponent F Q R B b => f s j) (dite_eq_right h)) + rfl + | isTrue h => + apply footprint_mpr_congr (congrArg (fun f : BitPhysicalGroupQueries M J N n exponent F Q R B b => f s j) (dite_eq_left h)) + rw [footprint_cases (instDecidableEqBool (queryCellValidWithWork n exponent cell).1 true)] + refine congrFun ?_ (instDecidableEqBool (queryCellValidWithWork n exponent cell).1 true) + funext decision + cases decision with + | isFalse h' => + apply footprint_mpr_congr (congrArg (fun f : BitPhysicalGroupQueries M J N n exponent F Q R B b => f s j) (dite_eq_right h')) + rfl + | isTrue h' => + apply footprint_mpr_congr (congrArg (fun f : BitPhysicalGroupQueries M J N n exponent F Q R B b => f s j) (dite_eq_left h')) + let key : PhysicalLocalGroupKey M J N n exponent := + (node, physicalScaleIndex N b ((queryScalePresentWithWork_value N b).mp h), + ⟨cell.1, Nat.lt_succ_of_le ((queryCellValidWithWork_value n exponent cell).mp h').1⟩, + ⟨cell.2, Nat.lt_succ_of_le ((queryCellValidWithWork_value n exponent cell).mp h').2⟩) + with_unfolding_all + apply footprint_groupTransport M J N n exponent F Q R B _ b + (physicalScaleIndex_get N b ((queryScalePresentWithWork_value N b).mp h)) + (queryPhysicalScalarGroupQueriesAt M J N n exponent F Q R B key time) + intro scale sample + apply footprint_mpr_congr + (queryPhysicalScalarGroupQueriesAt.eq_1 M J N n exponent F Q R B key time scale sample) + apply queryPhysicalScalarReadHeap_footprint + have hsame : queryPhysicalScalarGroupQueriesFootprint M J N n exponent F Q R B node time b cell s j = + scalarGroupFootprintBridge M J N n exponent F Q R B node time b cell s j := by + have heq_mpr_right {α β γ : Sort _} (eqn : α = β) (a : γ) (b : β) (hab : HEq a b) : + HEq a (eqn.mpr b) := by + cases eqn + exact hab + apply eq_of_heq + unfold scalarGroupFootprintBridge + apply heq_mpr_right (congrArg BitQuery.Footprint (congrArg + (fun f : BitPhysicalGroupQueries M J N n exponent F Q R B b => f s j) + (queryPhysicalScalarGroupQueries.eq_1 M J N n exponent F Q R B node time b cell))) + unfold queryPhysicalScalarGroupQueriesFootprint + direct_decidable_heq + · exact heq_of_eq (id_eq _) + · rfl + · intro h + direct_mpr_heq + rfl + · intro h + direct_mpr_heq + direct_decidable_heq + · rfl + · rfl + · intro h' + direct_mpr_heq + rfl + · intro h' + direct_mpr_heq + rfl + exact hbridge.trans hsame.symm + + +@[simp] theorem queryPhysicalScalarGroupReadHeap_footprint : + ∀ (M J N n exponent F Q R B : Nat) (node : OAI.EditApproximation.PhysicalInternalNode M J) (time : Fin R) + (key : OAI.EditApproximation.GroupScalarKey M F Q), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) + OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.queryPhysicalScalarGroupRead M J N n exponent F Q R B node time key)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.queryPhysicalScalarGroupRead M J N n exponent F Q R B node time key) + (OAI.EditApproximation.queryPhysicalScalarGroupReadHeap M J N n exponent F Q R B node time key)) + (OAI.EditApproximation.queryPhysicalScalarGroupReadFootprint M J N n exponent F Q R B node time key) := by + intros + simp [queryPhysicalScalarGroupReadHeap, queryPhysicalScalarGroupReadFootprint, queryPhysicalScalarGroupRead] + +private def scalarOnlineFootprintBridge (M J N n exponent F Q R B : ℕ) + (node : PhysicalInternalNode M J) (time : Fin R) (key : ℕ × TargetInterval n) (range : ℕ) : + BitQuery.Footprint (queryPhysicalScalarOnlineRead M J N n exponent F Q R B node time key range) := by + refine (congrArg BitQuery.Footprint + (queryPhysicalScalarOnlineRead.eq_1 M J N n exponent F Q R B node time key range)).mpr ?_ + refine BitQuery.Footprint.chargeOf + (queryScalePresentAllocation N key.1 + queryRangeValidAllocation B range) ?_ + split + · rename_i hb + split + · rename_i hr + exact queryPhysicalScalarReadFootprint M J N n exponent F Q R B + ⟨.inl ((node, physicalScaleIndex N key.1 ((queryScalePresentWithWork_value N key.1).mp hb), key.2), + positiveDrawRangeOfLE B range ((queryRangeValidWithWork_value B range).mp hr).1 + ((queryRangeValidWithWork_value B range).mp hr).2), time⟩ + · exact .done _ + · exact .done _ + +@[simp] theorem queryPhysicalScalarOnlineReadHeap_footprint : + ∀ (M J N n exponent F Q R B : Nat) (node : OAI.EditApproximation.PhysicalInternalNode M J) (time : Fin R) + (key : Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval n)) (range : Nat), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) + OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.queryPhysicalScalarOnlineRead M J N n exponent F Q R B node time key range)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (OAI.EditApproximation.PhysicalScalarKey M J N n exponent F Q R B) OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.queryPhysicalScalarOnlineRead M J N n exponent F Q R B node time key range) + (OAI.EditApproximation.queryPhysicalScalarOnlineReadHeap M J N n exponent F Q R B node time key range)) + (OAI.EditApproximation.queryPhysicalScalarOnlineReadFootprint M J N n exponent F Q R B node time key range) := by + intro M J N n exponent F Q R B node time key range + have hbridge : (queryPhysicalScalarOnlineReadHeap M J N n exponent F Q R B node time key range).footprint = + scalarOnlineFootprintBridge M J N n exponent F Q R B node time key range := by + unfold queryPhysicalScalarOnlineReadHeap scalarOnlineFootprintBridge + apply footprint_mpr_congr + (queryPhysicalScalarOnlineRead.eq_1 M J N n exponent F Q R B node time key range) + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases (instDecidableEqBool (queryScalePresentWithWork N key.1).1 true)] + congr! (config := {closePre := false, closePost := false, sameFun := true}) 1 + · funext h + apply footprint_mpr_congr (dite_eq_right h) + rfl + · funext h + apply footprint_mpr_congr (dite_eq_left h) + rw [footprint_cases (instDecidableEqBool (queryRangeValidWithWork B range).1 true)] + congr! (config := {closePre := false, closePost := false, sameFun := true}) 1 + · funext h' + apply footprint_mpr_congr (dite_eq_right h') + rfl + · funext h' + apply footprint_mpr_congr (dite_eq_left h') + apply queryPhysicalScalarReadHeap_footprint + have hsame : queryPhysicalScalarOnlineReadFootprint M J N n exponent F Q R B node time key range = + scalarOnlineFootprintBridge M J N n exponent F Q R B node time key range := by + have heq_mpr_right {α β γ : Sort _} (eqn : α = β) (a : γ) (b : β) (hab : HEq a b) : + HEq a (eqn.mpr b) := by + cases eqn + exact hab + apply eq_of_heq + unfold scalarOnlineFootprintBridge + apply heq_mpr_right (congrArg BitQuery.Footprint + (queryPhysicalScalarOnlineRead.eq_1 M J N n exponent F Q R B node time key range)) + unfold queryPhysicalScalarOnlineReadFootprint + dsimp (config := {beta := false, iota := false, proj := false}) only + apply heq_of_eq + apply congrArg (BitQuery.Footprint.chargeOf + (queryScalePresentAllocation N key.1 + queryRangeValidAllocation B range)) + direct_decidable_heq + · rfl + · rfl + · intro h + direct_mpr_heq + rfl + · intro h + direct_mpr_heq + direct_decidable_heq + · rfl + · rfl + · intro h' + direct_mpr_heq + rfl + · intro h' + direct_mpr_heq + rfl + exact hbridge.trans hsame.symm + +@[simp] theorem queryFamilyGroupReadHeap_footprint : + ∀ {α : Type u_1} {M J R : Nat} (target : List.{u_1} α) (N P F exponent H Q passes copies pass copy : Nat) + (node : OAI.EditApproximation.PhysicalInternalNode M J) (time : Fin R) + (key : OAI.EditApproximation.GroupScalarKey M F Q), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyGroupRead.{u_1} α M J R target N P F exponent H Q passes copies pass copy node + time key)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyGroupRead.{u_1} α M J R target N P F exponent H Q passes copies pass copy node + time key) + (@OAI.EditApproximation.queryFamilyGroupReadHeap.{u_1} α M J R target N P F exponent H Q passes copies pass copy + node time key)) + (@OAI.EditApproximation.queryFamilyGroupReadFootprint.{u_1} α M J R target N P F exponent H Q passes copies pass + copy node time key) := by + intros + simp [queryFamilyGroupReadHeap, queryFamilyGroupReadFootprint, queryFamilyGroupRead] + +@[simp] theorem queryFamilyOnlineReadHeap_footprint : + ∀ {α : Type u_1} {M J R : Nat} (target : List.{u_1} α) (N P F exponent H Q passes copies pass copy : Nat) + (node : OAI.EditApproximation.PhysicalInternalNode M J) (time : Fin R) + (key : Prod.{0, 0} Nat (OAI.EditApproximation.TargetInterval (@List.length.{u_1} α target))) (range : Nat), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyOnlineRead.{u_1} α M J R target N P F exponent H Q passes copies pass copy node + time key range)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyOnlineRead.{u_1} α M J R target N P F exponent H Q passes copies pass copy node + time key range) + (@OAI.EditApproximation.queryFamilyOnlineReadHeap.{u_1} α M J R target N P F exponent H Q passes copies pass copy + node time key range)) + (@OAI.EditApproximation.queryFamilyOnlineReadFootprint.{u_1} α M J R target N P F exponent H Q passes copies pass + copy node time key range) := by + intros + simp [queryFamilyOnlineReadHeap, queryFamilyOnlineReadFootprint, queryFamilyOnlineRead] + +@[simp] theorem queryRestrictPhysicalBodyHeap_footprint : + ∀ {σ : Type u_1} {M J n : Nat} (passes copies T S : Nat) + (parent : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) + (program : + OAI.EditApproximation.BitQuery.{u_1, 0} + (@OAI.EditApproximation.QueryPhysicalChild.{u_1} σ M J n passes copies T S parent) + OAI.EditApproximation.BinaryFraction) + (heap : + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} + (@OAI.EditApproximation.QueryPhysicalChild.{u_1} σ M J n passes copies T S parent) + OAI.EditApproximation.BinaryFraction program), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} + (Sum.{u_1, 0} σ + (@Subtype.{1} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) + (fun r => @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) child)) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) + (fun r => @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) parent)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryRestrictPhysicalBody.{u_1} σ M J n passes copies T S parent program)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} + (Sum.{u_1, 0} σ + (@Subtype.{1} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) + (fun r => @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) child)) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J n T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) + (fun r => @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) parent)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryRestrictPhysicalBody.{u_1} σ M J n passes copies T S parent program) + (@OAI.EditApproximation.queryRestrictPhysicalBodyHeap.{u_1} σ M J n passes copies T S parent program heap)) + (@OAI.EditApproximation.queryRestrictPhysicalBodyFootprint.{u_1} σ M J n passes copies T S parent program + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} + (@OAI.EditApproximation.QueryPhysicalChild.{u_1} σ M J n passes copies T S parent) + OAI.EditApproximation.BinaryFraction program heap)) := by + intros + simp [queryRestrictPhysicalBodyHeap, queryRestrictPhysicalBodyFootprint, queryRestrictPhysicalBody] + +@[simp] theorem queryFamilyRefinementHeap_footprint : + ∀ {α : Type u_1} {M J R : Nat} [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + (source target : List.{u_1} α) (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (passes copies pass copy T S t : Nat) + (ht : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) t) + (node : OAI.EditApproximation.PhysicalNode M J) + (hbelow : + @LT.lt.{0} Nat instLTNat + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@Sigma.fst.{0, 0} + (Fin + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))) + (fun d => + OAI.EditApproximation.TreeLayer M + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + d)) + node)) + J) + (time : Fin R) (q : OAI.EditApproximation.TargetInterval (@List.length.{u_1} α target)), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (Sum.{0, 0} (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S + (@OAI.EditApproximation.PhysicalTableRequest.refinement M J (@List.length.{u_1} α target) pass copy node T + t q)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyRefinement.{u_1} α M J R _inst source target N P F exponent H Q eM eF hP hM hF + tau a eta kappa delta passes copies pass copy T S t ht node hbelow time q)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (Sum.{0, 0} (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S + (@OAI.EditApproximation.PhysicalTableRequest.refinement M J (@List.length.{u_1} α target) pass copy node T + t q)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyRefinement.{u_1} α M J R _inst source target N P F exponent H Q eM eF hP hM hF + tau a eta kappa delta passes copies pass copy T S t ht node hbelow time q) + (@OAI.EditApproximation.queryFamilyRefinementHeap.{u_1} α M J R _inst source target N P F exponent H Q eM eF hP hM + hF tau a eta kappa delta passes copies pass copy T S t ht node hbelow time q)) + (@OAI.EditApproximation.queryFamilyRefinementFootprint.{u_1} α M J R _inst source target N P F exponent H Q eM eF hP + hM hF tau a eta kappa delta passes copies pass copy T S t ht node hbelow time q) := by + intros + simp [queryFamilyRefinementHeap, queryFamilyRefinementFootprint, queryFamilyRefinement] + +@[simp] theorem queryFamilyActiveHeap_footprint : + ∀ {α : Type u_1} {M J R : Nat} [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + [_inst_1 : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) R] (source target : List.{u_1} α) + (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (T S passes copies : Nat) + (request : OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) + (hindex : + @LT.lt.{0} Nat instLTNat T + (@OAI.EditApproximation.PhysicalTableRequest.index M J (@List.length.{u_1} α target) request)) + (hbelow : + @LT.lt.{0} Nat instLTNat + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@Sigma.fst.{0, 0} + (Fin + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))) + (fun d => + OAI.EditApproximation.TreeLayer M + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + d)) + (@OAI.EditApproximation.PhysicalTableRequest.node M J (@List.length.{u_1} α target) request))) + J), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (Sum.{0, 0} (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S request))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyActive.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q eM eF hP hM + hF tau a eta kappa delta T S passes copies request hindex hbelow)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (Sum.{0, 0} (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S child) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S request))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyActive.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q eM eF hP hM + hF tau a eta kappa delta T S passes copies request hindex hbelow) + (@OAI.EditApproximation.queryFamilyActiveHeap.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q eM eF hP + hM hF tau a eta kappa delta T S passes copies request hindex hbelow)) + (@OAI.EditApproximation.queryFamilyActiveFootprint.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q eM eF + hP hM hF tau a eta kappa delta T S passes copies request hindex hbelow) := by + intros + simp [queryFamilyActiveHeap, queryFamilyActiveFootprint, queryFamilyActive] + +@[simp] theorem queryFamilyBoundedActiveHeap_footprint : + ∀ {α : Type u_1} {M J R : Nat} [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + [_inst_1 : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) R] (source target : List.{u_1} α) + (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (tau a eta kappa delta : OAI.EditApproximation.BinaryFraction) (T S passes copies : Nat) + (parent : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + (hindex : + @LT.lt.{0} Nat instLTNat T + (@OAI.EditApproximation.PhysicalTableRequest.index M J (@List.length.{u_1} α target) + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) + (fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + parent))) + (hbelow : + @LT.lt.{0} Nat instLTNat + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@Sigma.fst.{0, 0} + (Fin + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))) + (fun d => + OAI.EditApproximation.TreeLayer M + (@Fin.val + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) J + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + d)) + (@OAI.EditApproximation.PhysicalTableRequest.node M J (@List.length.{u_1} α target) + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) + (fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + parent)))) + J), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (Sum.{0, 0} (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + (@Subtype.{1} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) + (fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + child)) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) + (fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + parent)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyBoundedActive.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q eM eF + hP hM hF tau a eta kappa delta T S passes copies parent hindex hbelow)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (Sum.{0, 0} (@OAI.EditApproximation.PhysicalFamilyScalarKey.{u_1} α M J R target N P F exponent H Q passes copies) + (@Subtype.{1} + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) + (fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + child)) + (@OAI.EditApproximation.PhysicalTableRequest.combinedRank M J (@List.length.{u_1} α target) T S + (@Subtype.val.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{u_1} α target)) + (fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{u_1} α target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r) + parent)))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyBoundedActive.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q eM eF + hP hM hF tau a eta kappa delta T S passes copies parent hindex hbelow) + (@OAI.EditApproximation.queryFamilyBoundedActiveHeap.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q eM + eF hP hM hF tau a eta kappa delta T S passes copies parent hindex hbelow)) + (@OAI.EditApproximation.queryFamilyBoundedActiveFootprint.{u_1} α M J R _inst _inst_1 source target N P F exponent H Q + eM eF hP hM hF tau a eta kappa delta T S passes copies parent hindex hbelow) := by + intros + simp [queryFamilyBoundedActiveHeap, queryFamilyBoundedActiveFootprint, queryFamilyBoundedActive] + +@[simp] theorem queryInitialConeProgramAtHeap_footprint : + ∀ {ι : Type u_1} {n : Nat} (sourceLength N P F : Nat) (A a : OAI.EditApproximation.BinaryFraction) + (reader : + OAI.EditApproximation.TargetInterval n → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (q : OAI.EditApproximation.TargetInterval n) + (hr : + (r : OAI.EditApproximation.TargetInterval n) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader r)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryInitialConeProgramAt.{u_1} ι n sourceLength N P F A a reader q)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryInitialConeProgramAt.{u_1} ι n sourceLength N P F A a reader q) + (@OAI.EditApproximation.queryInitialConeProgramAtHeap.{u_1} ι n sourceLength N P F A a reader q hr)) + (@OAI.EditApproximation.queryInitialConeProgramAtFootprint.{u_1} ι n sourceLength N P F A a reader q fun r => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (reader r) (hr r)) := by + intros + simp [queryInitialConeProgramAtHeap, queryInitialConeProgramAtFootprint, queryInitialConeProgramAt] + +@[simp] theorem queryChargedReadHeap_footprint : + ∀ {M J n passes copies T S : Nat} + (parent : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) + (key : + @Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J n passes copies T S) fun child => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J n) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S request) + parent))), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J n passes copies T S) fun child => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J n) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S request) + parent))) + OAI.EditApproximation.BinaryFraction (@OAI.EditApproximation.queryChargedRead M J n passes copies T S parent key)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J n passes copies T S) fun child => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J n) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S request) + parent))) + OAI.EditApproximation.BinaryFraction (@OAI.EditApproximation.queryChargedRead M J n passes copies T S parent key) + (@OAI.EditApproximation.queryChargedReadHeap M J n passes copies T S parent key)) + (@OAI.EditApproximation.queryChargedReadFootprint M J n passes copies T S parent key) := by + intros + simp [queryChargedReadHeap, queryChargedReadFootprint, queryChargedRead] + +@[simp] theorem queryChargedSeedAtHeap_footprint : + ∀ {M J n passes copies T S : Nat} + (parent : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S r) + (N : Nat) (multiplier : Nat → Nat) (q : OAI.EditApproximation.TargetInterval n), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J n passes copies T S) fun child => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J n) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S request) + parent))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedSeedAt M J n passes copies T S parent N multiplier q)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J n passes copies T S) fun child => + @LT.lt.{0} Nat instLTNat (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J n passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J n) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J n) fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J n passes copies T S request) + parent))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedSeedAt M J n passes copies T S parent N multiplier q) + (@OAI.EditApproximation.queryChargedSeedAtHeap M J n passes copies T S parent N multiplier q)) + (@OAI.EditApproximation.queryChargedSeedAtFootprint M J n passes copies T S parent N multiplier q) := by + intros + unfold queryChargedSeedAtHeap queryChargedSeedAtFootprint + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h + apply footprint_mpr_congr (dite_eq_right h) + refine (BitQuery.Heap.footprint_chargeOf _ _ _).trans ?_ + apply congrArg (BitQuery.Footprint.chargeOf _) + refine (BitQuery.Heap.footprint_collect _ _ _ _ _).trans ?_ + congr 1 + · intro h + apply footprint_mpr_congr (dite_eq_left h) + apply queryChargedReadHeap_footprint + +@[simp] theorem queryWarmupProgramHeap_footprint : + ∀ {ι : Type u_1} {nx ny M : Nat} (parent : OAI.EditApproximation.TargetInterval nx) (N P F : Nat) + (a : OAI.EditApproximation.BinaryFraction) + (initialRead : + OAI.EditApproximation.TargetInterval ny → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (childRead : + Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval ny) → + OAI.EditApproximation.BitQuery.{u_1, 0} ι OAI.EditApproximation.BinaryFraction) + (q : OAI.EditApproximation.TargetInterval ny) + (hi : + (r : OAI.EditApproximation.TargetInterval ny) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (initialRead r)) + (hc : + (key : Prod.{0, 0} (Fin M) (OAI.EditApproximation.TargetInterval ny)) → + @OAI.EditApproximation.BitQuery.Heap.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (childRead key)), + @Eq.{u_1 + 1} + (@OAI.EditApproximation.BitQuery.Footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryWarmupProgram.{u_1} ι nx ny M parent N P F a initialRead childRead q)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryWarmupProgram.{u_1} ι nx ny M parent N P F a initialRead childRead q) + (@OAI.EditApproximation.queryWarmupProgramHeap.{u_1} ι nx ny M parent N P F a initialRead childRead q hi hc)) + (@OAI.EditApproximation.queryWarmupProgramFootprint.{u_1} ι nx ny M parent N P F a initialRead childRead q + (fun r => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (initialRead r) + (hi r)) + fun key => + @OAI.EditApproximation.BitQuery.Heap.footprint.{u_1, 0} ι OAI.EditApproximation.BinaryFraction (childRead key) + (hc key)) := by + intros + simp [queryWarmupProgramHeap, queryWarmupProgramFootprint, queryWarmupProgram] + +@[simp] theorem queryPhysicalInitialHeap_footprint : + ∀ (source target : List.{0} Nat) {M J passes copies T S : Nat} (N P F : Nat) + (A a : OAI.EditApproximation.BinaryFraction) (multiplier : Nat → Nat) + (parent : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) passes copies T S r) + (occurrence : OAI.EditApproximation.BinaryMemo.{0} OAI.EditApproximation.PositionCounts) + (symbolBits positionBits : Nat) (q : OAI.EditApproximation.TargetInterval (@List.length.{0} Nat target)), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) passes copies T S) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) + fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) passes copies T S + request) + parent))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryPhysicalInitial source target M J passes copies T S N P F A a multiplier parent + occurrence symbolBits positionBits q)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) passes copies T S) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) + fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) passes copies T S + request) + parent))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryPhysicalInitial source target M J passes copies T S N P F A a multiplier parent + occurrence symbolBits positionBits q) + (@OAI.EditApproximation.queryPhysicalInitialHeap source target M J passes copies T S N P F A a multiplier parent + occurrence symbolBits positionBits q)) + (@OAI.EditApproximation.queryPhysicalInitialFootprint source target M J passes copies T S N P F A a multiplier + parent occurrence symbolBits positionBits q) := by + intros + unfold queryPhysicalInitialHeap queryPhysicalInitialFootprint + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h + apply footprint_mpr_congr (ite_eq_right h) + simp + · intro h + apply footprint_mpr_congr (ite_eq_left h) + rfl + +@[simp] theorem queryChargedWarmupHeap_footprint : + ∀ (source target : List.{0} Nat) {M J passes copies T S : Nat} (N P F : Nat) + (A a : OAI.EditApproximation.BinaryFraction) (multiplier : Nat → Nat) + (parent : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) passes copies T S r) + (occurrence : OAI.EditApproximation.BinaryMemo.{0} OAI.EditApproximation.PositionCounts) + (symbolBits positionBits : Nat), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) passes copies T S) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) + fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) passes copies T S + request) + parent))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedWarmup source target M J passes copies T S N P F A a multiplier parent + occurrence symbolBits positionBits)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) passes copies T S) + fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S child) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) passes copies T S + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) + fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) passes copies T S + request) + parent))) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedWarmup source target M J passes copies T S N P F A a multiplier parent + occurrence symbolBits positionBits) + (@OAI.EditApproximation.queryChargedWarmupHeap source target M J passes copies T S N P F A a multiplier parent + occurrence symbolBits positionBits)) + (@OAI.EditApproximation.queryChargedWarmupFootprint source target M J passes copies T S N P F A a multiplier parent + occurrence symbolBits positionBits) := by + intros + unfold queryChargedWarmupHeap queryChargedWarmupFootprint + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h + apply footprint_mpr_congr (dite_eq_right h) + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h' + apply footprint_mpr_congr (dite_eq_right h') + simp + · intro h' + apply footprint_mpr_congr (dite_eq_left h') + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h'' + apply footprint_mpr_congr (ite_eq_right h'') + refine (queryWarmupProgramHeap_footprint _ _ _ _ _ _ _ _ _ _).trans ?_ + congr 1 + funext r + apply queryPhysicalInitialHeap_footprint + · intro h'' + apply footprint_mpr_congr (ite_eq_left h'') + simp + · intro h + apply footprint_mpr_congr (dite_eq_left h) + simp + +@[simp] theorem queryChargedFamilyTableHeap_footprint : + ∀ {M J R passes copies T S : Nat} [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + [_inst_1 : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) R] (source target : List.{0} Nat) + (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (A a : Nat → OAI.EditApproximation.BinaryFraction) (tau eta kappa delta : OAI.EditApproximation.BinaryFraction) + (multiplier : Nat → Nat) (occurrence : OAI.EditApproximation.BinaryMemo.{0} OAI.EditApproximation.PositionCounts) + (symbolBits positionBits : Nat) + (parent : + @Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) fun r => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S r), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@OAI.EditApproximation.ChargedFamilyQueryKey M J R passes copies T S target N P F exponent H Q + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S request) + parent)) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedFamilyTable M J R passes copies T S _inst _inst_1 source target N P F exponent H + Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits parent)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@OAI.EditApproximation.ChargedFamilyQueryKey M J R passes copies T S target N P F exponent H Q + (@Sum.inr.{0, 0} (OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)) + (@Subtype.{1} (OAI.EditApproximation.PhysicalTableRequest M J (@List.length.{0} Nat target)) fun request => + @OAI.EditApproximation.PhysicalTableRequest.Bounded M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S request) + parent)) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedFamilyTable M J R passes copies T S _inst _inst_1 source target N P F exponent H + Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits parent) + (@OAI.EditApproximation.queryChargedFamilyTableHeap M J R passes copies T S _inst _inst_1 source target N P F + exponent H Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits parent)) + (@OAI.EditApproximation.queryChargedFamilyTableFootprint M J R passes copies T S _inst _inst_1 source target N P F + exponent H Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits parent) := by + intros + unfold queryChargedFamilyTableHeap queryChargedFamilyTableFootprint + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h + apply footprint_mpr_congr (dite_eq_right h) + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h' + apply footprint_mpr_congr (dite_eq_right h') + simp + · intro h' + apply footprint_mpr_congr (dite_eq_left h') + apply congrArg (BitQuery.Footprint.charge _) + rw [footprint_cases] + apply cases_congr + · intro h'' + apply footprint_mpr_congr (ite_eq_right h'') + simp + · intro h'' + apply footprint_mpr_congr (ite_eq_left h'') + simp + · intro h + apply footprint_mpr_congr (dite_eq_left h) + simp + +@[simp] theorem queryChargedFamilyGlobalHeap_footprint : + ∀ {M J R passes copies T S : Nat} [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + [_inst_1 : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) R] (source target : List.{0} Nat) + (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (A a : Nat → OAI.EditApproximation.BinaryFraction) (tau eta kappa delta : OAI.EditApproximation.BinaryFraction) + (multiplier : Nat → Nat) (occurrence : OAI.EditApproximation.BinaryMemo.{0} OAI.EditApproximation.PositionCounts) + (symbolBits positionBits : Nat) + (coarse : + OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target) → + Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (allocation : OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target) → Nat) + (hc : + ∀ (entry : OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)), + @LE.le.{0} Nat instLENat (allocation entry) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3))) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (coarse entry)))) + (request : + OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@OAI.EditApproximation.ChargedFamilyQueryKey M J R passes copies T S target N P F exponent H Q request) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedFamilyGlobal M J R passes copies T S _inst _inst_1 source target N P F exponent + H Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse request)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@OAI.EditApproximation.ChargedFamilyQueryKey M J R passes copies T S target N P F exponent H Q request) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryChargedFamilyGlobal M J R passes copies T S _inst _inst_1 source target N P F exponent + H Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse request) + (@OAI.EditApproximation.queryChargedFamilyGlobalHeap M J R passes copies T S _inst _inst_1 source target N P F + exponent H Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse + allocation hc request)) + (@OAI.EditApproximation.queryChargedFamilyGlobalFootprint M J R passes copies T S _inst _inst_1 source target N P F + exponent H Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse + allocation request) := by + intros + rename_i request + cases request <;> simp [queryChargedFamilyGlobalHeap, queryChargedFamilyGlobalFootprint, queryChargedFamilyGlobal] + +@[simp] theorem queryFamilyMemoRawHeap_footprint : + ∀ {M J R passes copies T S : Nat} [_inst : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) M] + [_inst_1 : @NeZero.{0} Nat (@MulZeroClass.toZero.{0} Nat Nat.instMulZeroClass) R] (source target : List.{0} Nat) + (N P F exponent H Q eM eF : Nat) + (hP : @LT.lt.{0} Nat instLTNat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) P) + (hM : + @Eq.{1} Nat M + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eM)) + (hF : + @Eq.{1} Nat F + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) eF)) + (A a : Nat → OAI.EditApproximation.BinaryFraction) (tau eta kappa delta : OAI.EditApproximation.BinaryFraction) + (multiplier : Nat → Nat) (occurrence : OAI.EditApproximation.BinaryMemo.{0} OAI.EditApproximation.PositionCounts) + (symbolBits positionBits : Nat) + (coarse : + OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target) → + Prod.{0, 0} OAI.EditApproximation.BinaryFraction Nat) + (allocation : OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target) → Nat) + (hc : + ∀ (entry : OAI.EditApproximation.PhysicalEntry M J (@List.length.{0} Nat target)), + @LE.le.{0} Nat instLENat (allocation entry) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3))) + (@Prod.snd.{0, 0} OAI.EditApproximation.BinaryFraction Nat (coarse entry)))) + (draw : @OAI.EditApproximation.PhysicalFamilyScalarDraw.{0} Nat M J R target N P F exponent H Q passes copies) + (key : @OAI.EditApproximation.QueryFamilyMemoKey M J R passes copies T S target N P F exponent H Q), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} + (Sum.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat M J R target N P F exponent H Q passes copies) + (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S)) + fun next => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat M J R target N P F exponent H Q passes copies) + (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + next) + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat M J R target N P F exponent H Q passes copies) + (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + key)) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyMemoRaw M J R passes copies T S _inst _inst_1 source target N P F exponent H Q eM + eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse draw key)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} + (Sum.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat M J R target N P F exponent H Q passes copies) + (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S)) + fun next => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat M J R target N P F exponent H Q passes copies) + (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + next) + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat M J R target N P F exponent H Q passes copies) + (OAI.EditApproximation.ChargedPhysicalRequest M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank M J (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) passes + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + copies T S) + key)) + OAI.EditApproximation.BinaryFraction + (@OAI.EditApproximation.queryFamilyMemoRaw M J R passes copies T S _inst _inst_1 source target N P F exponent H Q eM + eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse draw key) + (@OAI.EditApproximation.queryFamilyMemoRawHeap M J R passes copies T S _inst _inst_1 source target N P F exponent H + Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse allocation hc draw + key)) + (@OAI.EditApproximation.queryFamilyMemoRawFootprint M J R passes copies T S _inst _inst_1 source target N P F exponent + H Q eM eF hP hM hF A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse allocation draw + key) := by + intros + rename_i key + cases key <;> simp [queryFamilyMemoRawHeap, queryFamilyMemoRawFootprint, queryFamilyMemoRaw] + · apply BitQuery.Heap.footprint_computeOf + · refine (BitQuery.Heap.footprint_mapKeysWithWork _ _ _ _).trans ?_ + apply congrArg (BitQuery.Footprint.mapKeysWithWork _ _) + apply queryChargedFamilyGlobalHeap_footprint + +@[simp] theorem computedQueryMemoRawHeap_footprint : + ∀ (source target : List.{0} Nat) (N : Nat) + (occurrence : OAI.EditApproximation.BinaryMemo.{0} OAI.EditApproximation.PositionCounts) + (symbolBits positionBits : Nat) (input : OAI.EditApproximation.ComputedFamilyInput source target N) + (key : OAI.EditApproximation.ComputedFamilyMemoKey source target N), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} + (Sum.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + target N (OAI.EditApproximation.integerParameters N).P (OAI.EditApproximation.inputSmallLog N) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 40) (instOfNatNat (nat_lit 40))) + (OAI.EditApproximation.smallLogExponent N)) + (OAI.EditApproximation.inputHeight N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputSmallLog N) (@OfNat.ofNat.{0} Nat (nat_lit 80) (instOfNatNat (nat_lit 80)))) + (OAI.EditApproximation.computedSeedPassCount N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S)) + fun next => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + target N (OAI.EditApproximation.integerParameters N).P (OAI.EditApproximation.inputSmallLog N) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 40) (instOfNatNat (nat_lit 40))) + (OAI.EditApproximation.smallLogExponent N)) + (OAI.EditApproximation.inputHeight N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputSmallLog N) (@OfNat.ofNat.{0} Nat (nat_lit 80) (instOfNatNat (nat_lit 80)))) + (OAI.EditApproximation.computedSeedPassCount N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + next) + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + target N (OAI.EditApproximation.integerParameters N).P (OAI.EditApproximation.inputSmallLog N) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 40) (instOfNatNat (nat_lit 40))) + (OAI.EditApproximation.smallLogExponent N)) + (OAI.EditApproximation.inputHeight N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputSmallLog N) (@OfNat.ofNat.{0} Nat (nat_lit 80) (instOfNatNat (nat_lit 80)))) + (OAI.EditApproximation.computedSeedPassCount N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + key)) + OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.computedQueryMemoRaw source target N occurrence symbolBits positionBits input key)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} + (Sum.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + target N (OAI.EditApproximation.integerParameters N).P (OAI.EditApproximation.inputSmallLog N) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 40) (instOfNatNat (nat_lit 40))) + (OAI.EditApproximation.smallLogExponent N)) + (OAI.EditApproximation.inputHeight N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputSmallLog N) (@OfNat.ofNat.{0} Nat (nat_lit 80) (instOfNatNat (nat_lit 80)))) + (OAI.EditApproximation.computedSeedPassCount N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S)) + fun next => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + target N (OAI.EditApproximation.integerParameters N).P (OAI.EditApproximation.inputSmallLog N) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 40) (instOfNatNat (nat_lit 40))) + (OAI.EditApproximation.smallLogExponent N)) + (OAI.EditApproximation.inputHeight N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputSmallLog N) (@OfNat.ofNat.{0} Nat (nat_lit 80) (instOfNatNat (nat_lit 80)))) + (OAI.EditApproximation.computedSeedPassCount N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + next) + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (@OAI.EditApproximation.PhysicalFamilyScalarKey.{0} Nat + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + target N (OAI.EditApproximation.integerParameters N).P (OAI.EditApproximation.inputSmallLog N) + (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat) + (@OfNat.ofNat.{0} Nat (nat_lit 40) (instOfNatNat (nat_lit 40))) + (OAI.EditApproximation.smallLogExponent N)) + (OAI.EditApproximation.inputHeight N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputSmallLog N) (@OfNat.ofNat.{0} Nat (nat_lit 80) (instOfNatNat (nat_lit 80)))) + (OAI.EditApproximation.computedSeedPassCount N) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) + (@HDiv.hDiv.{0, 0, 0} Nat Nat Nat (@instHDiv.{0} Nat Nat.instDiv) + (OAI.EditApproximation.heightExponent N) + (@OfNat.ofNat.{0} Nat (nat_lit 20) (instOfNatNat (nat_lit 20))))) + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + key)) + OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.computedQueryMemoRaw source target N occurrence symbolBits positionBits input key) + (OAI.EditApproximation.computedQueryMemoRawHeap source target N occurrence symbolBits positionBits input key)) + (OAI.EditApproximation.computedQueryMemoRawFootprint source target N occurrence symbolBits positionBits input key) := by + intros + simp [computedQueryMemoRawHeap, computedQueryMemoRawFootprint, computedQueryMemoRaw] + with_unfolding_all apply queryFamilyMemoRawHeap_footprint + +@[simp] theorem computedQueryMemoHeap_footprint : + ∀ (source target : List.{0} Nat) (N : Nat) + (occurrence : OAI.EditApproximation.BinaryMemo.{0} OAI.EditApproximation.PositionCounts) + (symbolBits positionBits : Nat) (input : OAI.EditApproximation.ComputedFamilyInput source target N) + (key : OAI.EditApproximation.ComputedFamilyMemoKey source target N), + @Eq.{1} + (@OAI.EditApproximation.BitQuery.Footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ComputedFamilyMemoKey source target N) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (OAI.EditApproximation.ComputedFamilyScalarKey source target N + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + child) + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (OAI.EditApproximation.ComputedFamilyScalarKey source target N + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + key)) + OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.computedQueryMemoNormalized source target N occurrence symbolBits positionBits input key)) + (@OAI.EditApproximation.BitQuery.Heap.footprint.{0, 0} + (@Subtype.{1} (OAI.EditApproximation.ComputedFamilyMemoKey source target N) fun child => + @LT.lt.{0} Nat instLTNat + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (OAI.EditApproximation.ComputedFamilyScalarKey source target N + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + child) + (@OAI.EditApproximation.SourceRanked.rank.{0, 0} + (OAI.EditApproximation.ComputedFamilyScalarKey source target N + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) + (OAI.EditApproximation.ChargedPhysicalRequest (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + (@OAI.EditApproximation.ChargedPhysicalRequest.rank (OAI.EditApproximation.integerParameters N).M + (OAI.EditApproximation.intervalTreeDepth (OAI.EditApproximation.integerParameters N).M + (@List.length.{0} Nat source)) + (@List.length.{0} Nat target) + (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) + (OAI.EditApproximation.computedSeedPassCount N) + (@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))) + (@HPow.hPow.{0, 0, 0} Nat Nat Nat + (@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid))) + (OAI.EditApproximation.inputHeight N) (@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) + (OAI.EditApproximation.integerParameters N).T (OAI.EditApproximation.integerParameters N).S) + key)) + OAI.EditApproximation.BinaryFraction + (OAI.EditApproximation.computedQueryMemoNormalized source target N occurrence symbolBits positionBits input key) + (OAI.EditApproximation.computedQueryMemoHeap source target N occurrence symbolBits positionBits input key)) + (OAI.EditApproximation.computedQueryMemoFootprint source target N occurrence symbolBits positionBits input key) := by + intro source target N occurrence symbolBits positionBits input key + unfold computedQueryMemoHeap computedQueryMemoFootprint + refine (BitQuery.Heap.footprint_normalize _ _ _ _).trans ?_ + exact congrArg + (fun footprint : BitQuery.Footprint + (computedQueryMemoRaw source target N occurrence symbolBits positionBits input key) => + footprint.normalize (computedQueryBase N) (computedQueryBase_pos N) + (queryFamilyMemoRemaining target N (integerParameters N).P (inputSmallLog N) + (40 * smallLogExponent N) (inputHeight N) (inputSmallLog N ^ 80) key)) + (computedQueryMemoRawHeap_footprint source target N occurrence symbolBits positionBits input key) + +end OAI.EditApproximation diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/ConcreteFootprints.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/ConcreteFootprints.lean new file mode 100644 index 0000000000000000000000000000000000000000..6830c633f3a3be6f305750fb58680b11b5707719 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/ConcreteFootprints.lean @@ -0,0 +1,694 @@ +import OAI.Combinatorics.EditApproximation.AlmostLinear +import OAI.Combinatorics.EditApproximation.Specification.Footprint +import OAI.Combinatorics.EditApproximation.Definitions + +/-! Concrete allocation traces preserve the cells in the certified Heap +construction while keeping its allocation-bound certificates separate. -/ + +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + + + + + + + +def queryLocalRefinementFootprint.{u_1, u_2} + {ι : Type u_1} + {α : Type u_2} + (source target : List α) + {M : ℕ} + (parent : TargetInterval source.length) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (t : ℕ) + (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) + (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) + (R : ℕ) + (hc : ∀ (i : Fin M) (r : TargetInterval target.length), (child i r).2 ≤ R) + (hi : ∀ (i : Fin M) (r : TargetInterval target.length), (initial i r).2 ≤ R) + (draw : CountedCellGroupDraws M F Q) + (integer : ℕ → TargetInterval target.length → ℕ × ℕ) + (parentAllocation : TargetInterval target.length → ℕ) + (childAllocation initialAllocation : Fin M → TargetInterval target.length → ℕ) + (drawAllocation : CountedCellGroupAllocations M F Q) + (integerAllocation : ℕ → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) + (readEarlier : Fin M × ℕ × TargetInterval target.length → + BitQuery ι BinaryFraction) + (readCurrent : Fin M × TargetInterval target.length → + BitQuery ι BinaryFraction) + (he : (key : Fin M × ℕ × TargetInterval target.length) → (readEarlier key).Footprint) + (hr : (key : Fin M × TargetInterval target.length) → (readCurrent key).Footprint) : (queryLocalRefinement source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa delta + t parentInitial child initial R hc hi draw integer q readEarlier readCurrent).Footprint := +(BitQuery.Footprint.computeOf + (BinaryFraction.queryEarlierInputsWithWork M parent N P F exponent t hP a parentInitial q) + (BinaryFraction.queryEarlierInputsAllocation M parent N P F exponent t hP a parentInitial + parentAllocation q)).bind + (fun (earlierKeys : List (Fin M × ℕ × TargetInterval target.length)) => + BitQuery.collect readEarlier earlierKeys + fun (earlierWords : List BinaryFraction) => + (BitQuery.compute + (BinaryFraction.queryOnlineSelectWithWork source target parent N P F exponent H hP tau + a eta kappa parentInitial child initial R hc hi t integer earlierKeys earlierWords q)).bind + fun + (onlineActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + have word : BinaryFraction × ℕ := parentInitial q; + BitQuery.charge word.2 + ((BitQuery.compute + (BinaryFraction.querySharedInputsWithWork M N F Q exponent eM eF hM hF parent a + word.1 q draw)).bind + fun (sharedKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent sharedKeys + fun (sharedWords : List BinaryFraction) => + (BitQuery.compute + (BinaryFraction.queryGroupSelectWithWork source target parent N P F exponent Q + eM eF hP hM hF tau a parentInitial child initial R hc hi draw sharedKeys sharedWords q)).bind + fun + (selectedActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + (BitQuery.compute + (queryNeededInputsWithWork selectedActions onlineActions)).bind + fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent currentKeys + fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords selectedActions onlineActions currentKeys currentWords + q))) + fun (earlierKeys : List (Fin M × ℕ × TargetInterval target.length)) => + BitQuery.Footprint.collect readEarlier he earlierKeys + (fun (earlierWords : List BinaryFraction) => + (BitQuery.compute + (BinaryFraction.queryOnlineSelectWithWork source target parent N P F exponent H hP tau + a eta kappa parentInitial child initial R hc hi t integer earlierKeys earlierWords q)).bind + fun + (onlineActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + have word : BinaryFraction × ℕ := parentInitial q; + BitQuery.charge word.2 + ((BitQuery.compute + (BinaryFraction.querySharedInputsWithWork M N F Q exponent eM eF hM hF parent a + word.1 q draw)).bind + fun (sharedKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent sharedKeys + fun (sharedWords : List BinaryFraction) => + (BitQuery.compute + (BinaryFraction.queryGroupSelectWithWork source target parent N P F exponent Q + eM eF hP hM hF tau a parentInitial child initial R hc hi draw sharedKeys sharedWords q)).bind + fun + (selectedActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + (BitQuery.compute + (queryNeededInputsWithWork selectedActions onlineActions)).bind + fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent currentKeys + fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords selectedActions onlineActions currentKeys currentWords + q))) + fun (earlierWords : List BinaryFraction) => + (BitQuery.Footprint.compute + (BinaryFraction.queryOnlineSelectWithWork source target parent N P F exponent H hP tau a + eta kappa parentInitial child initial R hc hi t integer earlierKeys earlierWords q) + (BinaryFraction.queryOnlineSelectAllocation source target parent N P F exponent H hP tau + a eta kappa parentInitial child initial R hc hi parentAllocation childAllocation initialAllocation t integer + integerAllocation earlierKeys earlierWords q)).bind + (fun + (onlineActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + have word : BinaryFraction × ℕ := parentInitial q; + BitQuery.charge word.2 + ((BitQuery.compute + (BinaryFraction.querySharedInputsWithWork M N F Q exponent eM eF hM hF parent a + word.1 q draw)).bind + fun (sharedKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent sharedKeys + fun (sharedWords : List BinaryFraction) => + (BitQuery.compute + (BinaryFraction.queryGroupSelectWithWork source target parent N P F exponent Q + eM eF hP hM hF tau a parentInitial child initial R hc hi draw sharedKeys sharedWords q)).bind + fun + (selectedActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + (BitQuery.compute + (queryNeededInputsWithWork selectedActions onlineActions)).bind + fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent currentKeys + fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords selectedActions onlineActions currentKeys currentWords + q))) + fun + (online : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + BitQuery.Footprint.chargeOf (parentAllocation q) + ((BitQuery.Footprint.computeOf + (BinaryFraction.querySharedInputsWithWork M N F Q exponent eM eF hM hF parent a + (parentInitial q).1 q draw) + (BinaryFraction.querySharedInputsAllocation M N F Q exponent eM eF hM hF parent a + (parentInitial q).1 q draw drawAllocation)).bind + (fun (sharedKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent sharedKeys + fun (sharedWords : List BinaryFraction) => + (BitQuery.compute + (BinaryFraction.queryGroupSelectWithWork source target parent N P F exponent Q + eM eF hP hM hF tau a parentInitial child initial R hc hi draw sharedKeys sharedWords q)).bind + fun + (selectedActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + (BitQuery.compute + (queryNeededInputsWithWork selectedActions online)).bind + fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent currentKeys + fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords selectedActions online currentKeys currentWords q)) + fun (sharedKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.Footprint.collect readCurrent hr sharedKeys + (fun (sharedWords : List BinaryFraction) => + (BitQuery.compute + (BinaryFraction.queryGroupSelectWithWork source target parent N P F exponent Q + eM eF hP hM hF tau a parentInitial child initial R hc hi draw sharedKeys sharedWords q)).bind + fun + (selectedActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + (BitQuery.compute + (queryNeededInputsWithWork selectedActions online)).bind + fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent currentKeys + fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords selectedActions online currentKeys currentWords q)) + fun (sharedWords : List BinaryFraction) => + (BitQuery.Footprint.computeOf + (BinaryFraction.queryGroupSelectWithWork source target parent N P F exponent Q + eM eF hP hM hF tau a parentInitial child initial R hc hi draw sharedKeys sharedWords q) + (BinaryFraction.queryGroupSelectAllocation source target parent N P F exponent Q + eM eF hP hM hF tau a parentInitial child initial R hc hi parentAllocation childAllocation + initialAllocation draw drawAllocation sharedKeys sharedWords q)).bind + (fun + (selectedActions : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + (BitQuery.compute + (queryNeededInputsWithWork selectedActions online)).bind + fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent currentKeys + fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords selectedActions online currentKeys currentWords q)) + fun + (groups : + List + (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M)) => + (BitQuery.Footprint.computeOf + (queryNeededInputsWithWork groups online) + (queryNeededInputsAllocation groups online)).bind + (fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.collect readCurrent currentKeys + fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords groups online currentKeys currentWords q)) + fun (currentKeys : List (Fin M × TargetInterval target.length)) => + BitQuery.Footprint.collect readCurrent hr currentKeys + (fun (currentWords : List BinaryFraction) => + BitQuery.compute + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords groups online currentKeys currentWords q)) + fun (currentWords : List BinaryFraction) => + BitQuery.Footprint.computeOf + (BinaryFraction.queryRefinementFinishWithWork parent N P F a delta + parentInitial t earlierKeys earlierWords groups online currentKeys currentWords q) + (BinaryFraction.queryRefinementFinishAllocation parent N P F a delta + parentInitial parentAllocation t earlierKeys earlierWords groups online currentKeys currentWords + q)) + +def queryLocalRandomSourcesFootprint.{u_1, u_2} + {ι : Type u_1} + {α : Type u_2} + (source target : List α) + {M : ℕ} + [NeZero M] + (parent : TargetInterval source.length) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (t : ℕ) + (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) + (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) + (R : ℕ) + (hc : ∀ (i : Fin M) (r : TargetInterval target.length), (child i r).2 ≤ R) + (hi : ∀ (i : Fin M) (r : TargetInterval target.length), (initial i r).2 ≤ R) + (parentAllocation : TargetInterval target.length → ℕ) + (childAllocation initialAllocation : Fin M → TargetInterval target.length → ℕ) + (q : TargetInterval target.length) + (readGroup : GroupScalarKey M F Q → BitQuery ι BinaryFraction) + (readInteger : ℕ × TargetInterval target.length → + ℕ → BitQuery ι BinaryFraction) + (readEarlier : Fin M × ℕ × TargetInterval target.length → + BitQuery ι BinaryFraction) + (readCurrent : Fin M × TargetInterval target.length → + BitQuery ι BinaryFraction) + (hg : (key : GroupScalarKey M F Q) → (readGroup key).Footprint) + (hz : (key : ℕ × TargetInterval target.length) → (range : ℕ) → (readInteger key range).Footprint) + (he : (key : Fin M × ℕ × TargetInterval target.length) → (readEarlier key).Footprint) + (hr : (key : Fin M × TargetInterval target.length) → (readCurrent key).Footprint) : (queryLocalRandomSources source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa + delta t parentInitial child initial R hc hi q readGroup readInteger readEarlier readCurrent).Footprint := +queryGroupSourceGatherFootprint M N F Q exponent eM eF hM hF a parentInitial parentAllocation q + readGroup hg + (fun (groupKeys : List (GroupScalarKey M F Q)) + (groupWords : List BinaryFraction) => + queryOnlineSourceGather parent N P F exponent H hP tau a parentInitial child q readInteger + fun (onlineKeys : List (ℕ × TargetInterval target.length)) + (onlineWords : List BinaryFraction) => + queryLocalRefinement source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa + delta t parentInitial child initial R hc hi + (BinaryFraction.queryGroupDrawReadWithWork groupKeys groupWords) + (BinaryFraction.queryOnlineIntegerReadWithWork onlineKeys onlineWords) q readEarlier + readCurrent) + fun (groupKeys : List (GroupScalarKey M F Q)) + (groupWords : List BinaryFraction) => + queryOnlineSourceGatherFootprint parent N P F exponent H hP tau a parentInitial parentAllocation + child childAllocation q readInteger hz + (fun (onlineKeys : List (ℕ × TargetInterval target.length)) + (onlineWords : List BinaryFraction) => + queryLocalRefinement source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa + delta t parentInitial child initial R hc hi + (BinaryFraction.queryGroupDrawReadWithWork groupKeys groupWords) + (BinaryFraction.queryOnlineIntegerReadWithWork onlineKeys onlineWords) q readEarlier + readCurrent) + fun (onlineKeys : List (ℕ × TargetInterval target.length)) + (onlineWords : List BinaryFraction) => + queryLocalRefinementFootprint source target parent N P F exponent H Q eM eF hP hM hF tau a eta + kappa delta t parentInitial child initial R hc hi + (BinaryFraction.queryGroupDrawReadWithWork groupKeys groupWords) + (BinaryFraction.queryOnlineIntegerReadWithWork onlineKeys onlineWords) parentAllocation + childAllocation initialAllocation + (BinaryFraction.queryGroupDrawReadAllocation groupKeys groupWords) + (BinaryFraction.queryOnlineIntegerReadAllocation onlineKeys onlineWords) q readEarlier + readCurrent he hr + +def queryLocalBandFootprint.{u_1, u_2} + {ι : Type u_1} + {α : Type u_2} + (source target : List α) + {M : ℕ} + [NeZero M] + (parent : TargetInterval source.length) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (t : ℕ) + (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) + (parentAllocation : TargetInterval target.length → ℕ) + (readMass readInitial : Fin M × TargetInterval target.length → + BitQuery ι BinaryFraction) + (readGroup : GroupScalarKey M F Q → BitQuery ι BinaryFraction) + (readInteger : ℕ × TargetInterval target.length → + ℕ → BitQuery ι BinaryFraction) + (q : TargetInterval target.length) + (readEarlier : Fin M × ℕ × TargetInterval target.length → + BitQuery ι BinaryFraction) + (readCurrent : Fin M × TargetInterval target.length → + BitQuery ι BinaryFraction) + (hm : (key : Fin M × TargetInterval target.length) → (readMass key).Footprint) + (hi : (key : Fin M × TargetInterval target.length) → (readInitial key).Footprint) + (hg : (key : GroupScalarKey M F Q) → (readGroup key).Footprint) + (hz : (key : ℕ × TargetInterval target.length) → (range : ℕ) → (readInteger key range).Footprint) + (he : (key : Fin M × ℕ × TargetInterval target.length) → (readEarlier key).Footprint) + (hr : (key : Fin M × TargetInterval target.length) → (readCurrent key).Footprint) : (queryLocalBand source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa delta t + parentInitial readMass readInitial readGroup readInteger q readEarlier readCurrent).Footprint := +queryBandGatherFootprint M parent N P F exponent hP a parentInitial parentAllocation q readMass + readInitial hm hi + (fun (keys : List (Fin M × TargetInterval target.length)) + (massWords initialWords : List BinaryFraction) => + queryLocalRandomSources source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa + delta t parentInitial (BinaryFraction.queryChildReadWithWork keys massWords) + (BinaryFraction.queryChildReadWithWork keys initialWords) + (BinaryFraction.queryDataReadBudget M target.length keys) (BinaryFraction.queryChildReadWithWork_budget keys massWords) (BinaryFraction.queryChildReadWithWork_budget keys initialWords) q readGroup + readInteger readEarlier readCurrent) + fun (keys : List (Fin M × TargetInterval target.length)) + (massWords initialWords : List BinaryFraction) => + queryLocalRandomSourcesFootprint source target parent N P F exponent H Q eM eF hP hM hF tau a + eta kappa delta t parentInitial (BinaryFraction.queryChildReadWithWork keys massWords) + (BinaryFraction.queryChildReadWithWork keys initialWords) + (BinaryFraction.queryDataReadBudget M target.length keys) (BinaryFraction.queryChildReadWithWork_budget keys massWords) (BinaryFraction.queryChildReadWithWork_budget keys initialWords) + parentAllocation (BinaryFraction.queryChildReadAllocation keys massWords) + (BinaryFraction.queryChildReadAllocation keys initialWords) q readGroup readInteger + readEarlier readCurrent hg hz he hr + +def queryLocalProgramFootprint.{u_1, u_2} + {ι : Type u_1} + {α : Type u_2} + (source target : List α) + {M : ℕ} + [NeZero M] + (parent : TargetInterval source.length) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (t : ℕ) + (readParent : TargetInterval target.length → + BitQuery ι BinaryFraction) + (readMass readInitial : Fin M × TargetInterval target.length → + BitQuery ι BinaryFraction) + (readGroup : GroupScalarKey M F Q → BitQuery ι BinaryFraction) + (readInteger : ℕ × TargetInterval target.length → + ℕ → BitQuery ι BinaryFraction) + (q : TargetInterval target.length) + (readEarlier : Fin M × ℕ × TargetInterval target.length → + BitQuery ι BinaryFraction) + (readCurrent : Fin M × TargetInterval target.length → + BitQuery ι BinaryFraction) + (hp : (key : TargetInterval target.length) → (readParent key).Footprint) + (hm : (key : Fin M × TargetInterval target.length) → (readMass key).Footprint) + (hi : (key : Fin M × TargetInterval target.length) → (readInitial key).Footprint) + (hg : (key : GroupScalarKey M F Q) → (readGroup key).Footprint) + (hz : (key : ℕ × TargetInterval target.length) → (range : ℕ) → (readInteger key range).Footprint) + (he : (key : Fin M × ℕ × TargetInterval target.length) → (readEarlier key).Footprint) + (hr : (key : Fin M × TargetInterval target.length) → (readCurrent key).Footprint) : (queryLocalProgram source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa delta t + readParent readMass readInitial readGroup readInteger q readEarlier readCurrent).Footprint := +queryInitialGatherFootprint N P F exponent hP a q readParent hp + (fun (keys : List (TargetInterval target.length)) + (words : List BinaryFraction) => + queryLocalBand source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa delta t + (BinaryFraction.queryParentReadWithWork keys words) readMass readInitial readGroup + readInteger q readEarlier readCurrent) + fun (keys : List (TargetInterval target.length)) + (words : List BinaryFraction) => + queryLocalBandFootprint source target parent N P F exponent H Q eM eF hP hM hF tau a eta kappa + delta t (BinaryFraction.queryParentReadWithWork keys words) + (BinaryFraction.queryParentReadAllocation keys words) readMass readInitial readGroup + readInteger q readEarlier readCurrent hm hi hg hz he hr + + + + + + + + +def queryPhysicalRandomDataRequestFootprint.{u_1, u_2} + {σ : Type u_1} + {α : Type u_2} + (source target : List α) + {M J : ℕ} + [NeZero M] + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (copies pass copy T S t : ℕ) + (ht : 0 < t) + (node : PhysicalNode M J) + (hbelow : ↑node.fst < J) + (readGroup : GroupScalarKey M F Q → BitQuery σ BinaryFraction) + (readInteger : ℕ × TargetInterval target.length → + ℕ → BitQuery σ BinaryFraction) + (q : TargetInterval target.length) + (hg : (key : GroupScalarKey M F Q) → (readGroup key).Footprint) + (hz : (key : ℕ × TargetInterval target.length) → (range : ℕ) → (readInteger key range).Footprint) : (queryPhysicalRandomDataRequest source target N P F exponent H Q eM eF hP hM hF tau a eta kappa + delta copies pass copy T S t ht node hbelow readGroup readInteger q).Footprint := by + unfold queryPhysicalRandomDataRequest + apply queryLocalProgramFootprint + · intro r + exact (queryPhysicalTableReadFootprint copies T S _ _).mapKeysWithWork _ (fun _ => 1) + · intro input + apply Footprint.mapKeysWithWork _ (fun _ => 1) + apply queryMeanReadFootprint + intro j + exact queryPhysicalTableReadFootprint copies T S _ _ + · intro input + exact (queryPhysicalTableReadFootprint copies T S _ _).mapKeysWithWork _ (fun _ => 1) + · intro key + exact (hg key).mapKeysWithWork _ (fun _ => 1) + · intro key range + exact (hz key range).mapKeysWithWork _ (fun _ => 1) + · intro input + exact (queryPhysicalEarlierReadFootprint copies pass copy T S t node hbelow q input).mapKeysWithWork _ + (fun _ => 1) + · intro input + exact (queryPhysicalTableReadFootprint copies T S _ _).mapKeysWithWork _ (fun _ => 1) + + + + + + + + + + + + + + + + +def queryFamilyRefinementFootprint.{u_1} + {α : Type u_1} + {M J R : ℕ} + [NeZero M] + (source target : List α) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (passes copies pass copy T S t : ℕ) + (ht : 0 < t) + (node : PhysicalNode M J) + (hbelow : ↑node.fst < J) + (time : Fin R) + (q : TargetInterval target.length) : (queryFamilyRefinement source target N P F exponent H Q eM eF hP hM hF tau a eta kappa delta + passes copies pass copy T S t ht node hbelow time q).Footprint := +queryPhysicalRandomDataRequestFootprint source target N P F exponent H Q eM eF hP hM hF tau a eta + kappa delta copies pass copy T S t ht node hbelow + (queryFamilyGroupRead target N P F exponent H Q passes copies pass copy ⟨node, hbelow⟩ time) + (queryFamilyOnlineRead target N P F exponent H Q passes copies pass copy ⟨node, hbelow⟩ time) q + (queryFamilyGroupReadFootprint target N P F exponent H Q passes copies pass copy ⟨node, hbelow⟩ + time) + (queryFamilyOnlineReadFootprint target N P F exponent H Q passes copies pass copy ⟨node, hbelow⟩ + time) + +def queryFamilyActiveFootprint.{u_1} + {α : Type u_1} + {M J R : ℕ} + [NeZero M] + [NeZero R] + (source target : List α) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (T S passes copies : ℕ) + (request : PhysicalTableRequest M J target.length) + (hindex : T < request.index) + (hbelow : ↑request.node.fst < J) : (queryFamilyActive (R := R) source target N P F exponent H Q eM eF hP hM hF tau a eta kappa delta T S + passes copies request hindex hbelow).Footprint := + (queryFamilyRefinementFootprint source target N P F exponent H Q eM eF hP hM hF tau a eta kappa delta + passes copies request.pass request.copy T S (request.index - T) (Nat.sub_pos_of_lt hindex) + request.node hbelow (Fin.ofNat R (request.index - T - 1)) request.state).mapKeysWithWork _ (fun _ => 1) + +def queryFamilyBoundedActiveFootprint.{u_1} + {α : Type u_1} + {M J R : ℕ} + [NeZero M] + [NeZero R] + (source target : List α) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (tau a eta kappa delta : BinaryFraction) + (T S passes copies : ℕ) + (parent : { r : PhysicalTableRequest M J target.length // + PhysicalTableRequest.Bounded (passes + 1) copies T S r }) + (hindex : T < parent.val.index) + (hbelow : ↑parent.val.node.fst < J) : (queryFamilyBoundedActive (R := R) source target N P F exponent H Q eM eF hP hM hF tau a eta kappa delta T + S passes copies parent hindex hbelow).Footprint := + queryRestrictPhysicalBodyFootprint (passes + 1) copies T S parent _ + (queryFamilyActiveFootprint (R := R) source target N P F exponent H Q eM eF hP hM hF + tau a eta kappa delta T S passes copies parent.val hindex hbelow) + + + + + + + + + + + + + + + + +def queryChargedFamilyTableFootprint + {M J R passes copies T S : ℕ} + [NeZero M] + [NeZero R] + (source target : List ℕ) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (A a : ℕ → BinaryFraction) + (tau eta kappa delta : BinaryFraction) + (multiplier : ℕ → ℕ) + (occurrence : BinaryMemo PositionCounts) + (symbolBits positionBits : ℕ) + (parent : { r : PhysicalTableRequest M J target.length // + PhysicalTableRequest.Bounded (passes + 1) copies T S r }) : (queryChargedFamilyTable (R := R) source target N P F exponent H Q eM eF hP hM hF A a tau eta kappa delta + multiplier occurrence symbolBits positionBits parent).Footprint := by + have hinit := queryPhysicalInitialFootprint source target N P F (A parent.val.pass) (a parent.val.pass) + multiplier parent occurrence symbolBits positionBits parent.val.state + unfold queryChargedFamilyTable + refine BitQuery.Footprint.chargeOf (naturalWordLEAllocation parent.val.index.bits T.bits) ?_ + split + · exact (queryChargedWarmupFootprint source target N P F (A parent.val.pass) (a parent.val.pass) + multiplier parent occurrence symbolBits positionBits).mapKeysWithWork _ (fun _ => 1) + · refine BitQuery.Footprint.chargeOf (parent.val.node.1.val.bits.length + J.bits.length) ?_ + split + · let interval := physicalSourceInterval source.length parent.val.node + refine BitQuery.Footprint.chargeOf (saturatingSubtractAllocation interval.hi interval.lo + + naturalWordLEAllocation (saturatingSubtractWithWork interval.hi interval.lo).1 [true]) ?_ + split + · exact hinit.mapKeysWithWork _ (fun _ => 1) + · exact (queryFamilyBoundedActiveFootprint (R := R) source target N P F exponent H Q eM eF hP hM hF + tau (a parent.val.pass) eta kappa delta T S passes copies parent _ _).mapKeysWithWork _ + (fun _ => 1) + · exact hinit.mapKeysWithWork _ (fun _ => 1) + + +def queryChargedFamilyGlobalFootprint + {M J R passes copies T S : ℕ} + [NeZero M] + [NeZero R] + (source target : List ℕ) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (A a : ℕ → BinaryFraction) + (tau eta kappa delta : BinaryFraction) + (multiplier : ℕ → ℕ) + (occurrence : BinaryMemo PositionCounts) + (symbolBits positionBits : ℕ) + (coarse : PhysicalEntry M J target.length → BinaryFraction × ℕ) + (allocation : PhysicalEntry M J target.length → ℕ) + (request : ChargedPhysicalRequest M J target.length (passes + 1) copies T S) : (queryChargedFamilyGlobal (R := R) source target N P F exponent H Q eM eF hP hM hF A a tau eta kappa delta + multiplier occurrence symbolBits positionBits coarse request).Footprint := by + cases request with + | inl entry => exact Footprint.compute (coarse entry) (allocation entry) + | inr parent => + exact queryChargedFamilyTableFootprint (R := R) source target N P F exponent H Q eM eF hP hM hF + A a tau eta kappa delta multiplier occurrence symbolBits positionBits parent + +def queryFamilyMemoRawFootprint + {M J R passes copies T S : ℕ} + [NeZero M] + [NeZero R] + (source target : List ℕ) + (N P F exponent H Q eM eF : ℕ) + (hP : 0 < P) + (hM : M = 2 ^ eM) + (hF : F = 2 ^ eF) + (A a : ℕ → BinaryFraction) + (tau eta kappa delta : BinaryFraction) + (multiplier : ℕ → ℕ) + (occurrence : BinaryMemo PositionCounts) + (symbolBits positionBits : ℕ) + (coarse : PhysicalEntry M J target.length → BinaryFraction × ℕ) + (allocation : PhysicalEntry M J target.length → ℕ) + (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) target N P F exponent H Q passes copies) + (key : QueryFamilyMemoKey (M := M) (J := J) (R := R) (passes := passes) (copies := copies) (T := T) (S := S) target N P F exponent H Q) : (queryFamilyMemoRaw (R := R) source target N P F exponent H Q eM eF hP hM hF A a tau eta kappa delta + multiplier occurrence symbolBits positionBits coarse draw key).Footprint := by + cases key with + | inl scalar => + exact Footprint.computeOf (queryFamilySourceWordWithWork target N P F exponent H Q draw scalar) + (Nat.size (draw scalar).val + 2) + | inr request => + exact (queryChargedFamilyGlobalFootprint source target N P F exponent H Q eM eF hP hM hF + A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse allocation request).mapKeysWithWork + _ (fun _ => 1) + +def computedQueryMemoRawFootprint + (source target : List ℕ) + (N : ℕ) + (occurrence : BinaryMemo PositionCounts) + (symbolBits positionBits : ℕ) + (input : ComputedFamilyInput source target N) + (key : ComputedFamilyMemoKey source target N) : (computedQueryMemoRaw source target N occurrence symbolBits positionBits input key).Footprint := + queryFamilyMemoRawFootprint source target N (integerParameters N).P (inputSmallLog N) + (40 * smallLogExponent N) (inputHeight N) (inputSmallLog N ^ 80) + (heightExponent N / 20) (smallLogExponent N) (computedParameterP_pos N) rfl rfl + (fun pass => (scheduledSeedWordWithWork N pass).1) + (fun pass => (computedQueryParameters N pass).factor) + (computedQueryParameters N 0).tau (computedQueryParameters N 0).eta + (computedQueryParameters N 0).kappa (computedQueryParameters N 0).delta + (scheduledSeedMultiplier N) occurrence symbolBits positionBits + (fun entry => (BinaryFraction.nat (clampedSeedNat input.1 entry), 0)) + (fun _ => 0) input.2 key + +def computedQueryMemoFootprint + (source target : List ℕ) + (N : ℕ) + (occurrence : BinaryMemo PositionCounts) + (symbolBits positionBits : ℕ) + (input : ComputedFamilyInput source target N) + (key : ComputedFamilyMemoKey source target N) : (computedQueryMemoNormalized source target N occurrence symbolBits positionBits input + key).Footprint := +(computedQueryMemoRawFootprint source target N occurrence symbolBits positionBits input + key).normalize + (computedQueryBase N) (computedQueryBase_pos N) + (queryFamilyMemoRemaining target N (integerParameters N).P + (inputSmallLog N) (40 * smallLogExponent N) + (inputHeight N) (inputSmallLog N ^ 80) key) + +end OAI.EditApproximation diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/Footprint.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/Footprint.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2d16eba53f55b2c7834ed3cb5430f9a994b5220 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/Footprint.lean @@ -0,0 +1,224 @@ +import OAI.Combinatorics.EditApproximation.Binary.BitMemoHeap +import OAI.Combinatorics.EditApproximation.Binary.BitQueryKeysSpace +import OAI.Combinatorics.EditApproximation.Binary.BinaryNormalizationSpace +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI.EditApproximation.BitQuery + +/- The allocation trace of a query, without a proof relating allocations to work. +The trace retains every allocation and every adaptive continuation. -/ + + +namespace Footprint + +def cells {ι β : Type*} {program : BitQuery ι β} (oracle : ι → BinaryFraction) : + Footprint program → ℕ + | .done _ => 0 + | .read key _ next => 3 + cells oracle (next (oracle key)) + | .charge localCells next => localCells + cells oracle next + + + + + + + + + + + + + + + + + + + + + +theorem runCells_congr {ι κ : Type*} + (ask : ι → BinaryMemo BinaryFraction → BitRecursiveMemoResult κ) + (childCells otherCells : ι → BinaryMemo BinaryFraction → ℕ) + (h : ∀ key memory, childCells key memory = otherCells key memory) + {program : BitQuery ι BinaryFraction} (heap : Footprint program) + (memory : BinaryMemo BinaryFraction) : + heap.runCells ask childCells memory = heap.runCells ask otherCells memory := by + induction heap generalizing memory with + | done => rfl + | read key next continuation ih => simp only [runCells, h, ih] + | charge localCells next ih => simp only [runCells, ih] + +end Footprint + +namespace Heap + +/-- Forget only the local allocation/work certificates, preserving the exact trace. -/ +def footprint {ι β : Type*} {program : BitQuery ι β} : Heap program → Footprint program + | .done value => .done value + | .read key next continuation => .read key next (fun word => (continuation word).footprint) + | .charge localCells _ next => .charge localCells next.footprint + +@[simp] theorem footprint_done {ι β : Type*} (value : β) : + (Heap.done (ι := ι) value).footprint = .done value := rfl + +@[simp] theorem footprint_read {ι β : Type*} (key : ι) (next : BinaryFraction → BitQuery ι β) + (continuation : ∀ word, Heap (next word)) : + (Heap.read key next continuation).footprint = + .read key next (fun word => (continuation word).footprint) := rfl + +@[simp] theorem footprint_charge {ι β : Type*} {steps : ℕ} {program : BitQuery ι β} + (allocation : ℕ) (bound : allocation ≤ 3 * steps) (heap : Heap program) : + (Heap.charge allocation bound heap).footprint = .charge allocation heap.footprint := rfl + +@[simp] theorem footprint_cells {ι β : Type*} {program : BitQuery ι β} + (oracle : ι → BinaryFraction) (heap : Heap program) : + heap.footprint.cells oracle = heap.cells oracle := by + induction heap with + | done => rfl + | read key next continuation ih => simp only [footprint, Footprint.cells, cells, ih] + | charge localCells bound next ih => simp only [footprint, Footprint.cells, cells, ih] + +@[simp] theorem footprint_bind {ι α β : Type*} {program : BitQuery ι α} (heap : Heap program) + (next : α → BitQuery ι β) (allocation : ∀ value, Heap (next value)) : + (heap.bind next allocation).footprint = + heap.footprint.bind next (fun value => (allocation value).footprint) := by + induction heap with + | done => rfl + | read key continuation stored ih => + simp only [bind, footprint, Footprint.bind] + congr 1 + funext word + exact ih word + | charge localCells bound tail ih => + exact congrArg (Footprint.charge localCells) ih + +@[simp] theorem footprint_compute {ι β : Type*} (execution : β × ℕ) (allocation : ℕ) + (bound : allocation ≤ 3 * execution.2) : + (Heap.compute (ι := ι) execution allocation bound).footprint = + Footprint.compute execution allocation := rfl + +@[simp] theorem footprint_chargeOf {ι β : Type*} {steps : ℕ} {program : BitQuery ι β} + (allocation : ℕ) (bound : allocation ≤ steps) (heap : Heap program) : + (Heap.chargeOf allocation bound heap).footprint = Footprint.chargeOf allocation heap.footprint := rfl + +@[simp] theorem footprint_computeOf {ι β : Type*} (execution : β × ℕ) (allocation : ℕ) + (bound : allocation ≤ execution.2) : + (Heap.computeOf (ι := ι) execution allocation bound).footprint = + Footprint.computeOf execution allocation := rfl + +@[simp] theorem footprint_collect {ι κ β : Type*} (reader : κ → BitQuery ι BinaryFraction) + (allocation : ∀ key, Heap (reader key)) (inputs : List κ) + (next : List BinaryFraction → BitQuery ι β) (continuation : ∀ words, Heap (next words)) : + (Heap.collect reader allocation inputs next continuation).footprint = + Footprint.collect reader (fun key => (allocation key).footprint) inputs next + (fun words => (continuation words).footprint) := by + induction inputs generalizing next with + | nil => rfl + | cons key rest ih => + change ((allocation key).bind _ _).footprint = _ + rw [footprint_bind] + apply congrArg (Footprint.bind (allocation key).footprint _) + funext word + exact congrArg (Footprint.charge 1) (ih _ _) + +@[simp] theorem footprint_mapKeysWithWork {ι κ β : Type*} (f : ι → κ × ℕ) + (allocation : ι → ℕ) (ha : ∀ key, allocation key ≤ (f key).2) + {program : BitQuery ι β} (heap : Heap program) : + (heap.mapKeysWithWork f allocation ha).footprint = heap.footprint.mapKeysWithWork f allocation := by + induction heap with + | done => rfl + | read key next continuation ih => + change Footprint.charge (allocation key) + (Footprint.read (f key).1 _ (fun word => (mapKeysWithWork f allocation ha (continuation word)).footprint)) = + Footprint.charge (allocation key) + (Footprint.read (f key).1 _ (fun word => Footprint.mapKeysWithWork f allocation (continuation word).footprint)) + apply congrArg (Footprint.charge (allocation key)) + apply congrArg (Footprint.read (f key).1 _) + funext word + exact ih word + | charge localCells bound next ih => + exact congrArg (Footprint.charge localCells) ih + +private theorem map_decidable_cases {p : Prop} (d : Decidable p) {α β : Sort*} + (f : α → β) (no : ¬p → α) (yes : p → α) : + f (Decidable.casesOn d no yes) = + Decidable.casesOn d (fun h => f (no h)) (fun h => f (yes h)) := by + cases d <;> rfl + +private theorem footprint_mpr_congr {ι β : Type*} {p q : BitQuery ι β} + (eqn : p = q) (a : Heap q) (b : Footprint q) (hab : a.footprint = b) : + ((congrArg Heap eqn).mpr a).footprint = (congrArg Footprint eqn).mpr b := by + cases eqn + exact hab + +@[simp] theorem footprint_restrictWithWork {ι : Type*} (P : ι → Prop) + (test : ι → Bool × ℕ) (htest : ∀ key, (test key).1 = true ↔ P key) + (allocation : ι → ℕ) (ha : ∀ key, allocation key ≤ (test key).2) + {program : BitQuery ι BinaryFraction} (heap : Heap program) : + (heap.restrictWithWork P test htest allocation ha).footprint = + heap.footprint.restrictWithWork P test htest allocation := by + induction heap with + | done => rfl + | charge localCells bound next ih => + exact congrArg (Footprint.charge localCells) ih + | read key next continuation ih => + simp only [footprint_read] + unfold restrictWithWork Footprint.restrictWithWork + apply congrArg (Footprint.charge (allocation key)) + rw [map_decidable_cases (f := footprint)] + congr 1 + · funext h + apply footprint_mpr_congr (dite_eq_right h) + exact ih (BinaryFraction.nat 0) + · funext h + apply footprint_mpr_congr (dite_eq_left h) + apply congrArg (Footprint.read _ _) + funext word + exact ih word + +@[simp] theorem footprint_normalize {ι : Type*} {program : BitQuery ι BinaryFraction} + (heap : Heap program) (base : List Bool) (hbase : 0 < bitWordValue base) (remaining : ℕ) : + (heap.normalize base hbase remaining).footprint = heap.footprint.normalize base hbase remaining := by + exact footprint_bind heap _ _ + +@[simp] theorem footprint_runCells {ι κ : Type*} + (ask : ι → BinaryMemo BinaryFraction → BitRecursiveMemoResult κ) + (childCells : ι → BinaryMemo BinaryFraction → ℕ) + {program : BitQuery ι BinaryFraction} (heap : Heap program) (memory : BinaryMemo BinaryFraction) : + heap.footprint.runCells ask childCells memory = heap.runCells ask childCells memory := by + induction heap generalizing memory with + | done => rfl + | read key next continuation ih => simp only [footprint, Footprint.runCells, runCells, ih] + | charge localCells bound next ih => simp only [footprint, Footprint.runCells, runCells, ih] + +@[simp] theorem footprint_rankedBitMemoCells {κ : Type*} (rank : κ → ℕ) + (program : (key : κ) → BitQuery {child : κ // rank child < rank key} BinaryFraction) + (heap : ∀ key, Heap (program key)) + (bits : ℕ) (encode addressCells : κ → ℕ) (key : κ) (memory : BinaryMemo BinaryFraction) : + Footprint.rankedBitMemoCells rank program (fun key => (heap key).footprint) + bits encode addressCells key memory = + EditApproximation.rankedBitMemoCells rank program heap bits encode addressCells key memory := by + have hall : ∀ level key, rank key = level → ∀ memory, + Footprint.rankedBitMemoCells rank program (fun key => (heap key).footprint) + bits encode addressCells key memory = + EditApproximation.rankedBitMemoCells rank program heap bits encode addressCells key memory := by + intro level + induction level using Nat.strong_induction_on with + | h level ih => + intro key hlevel memory + rw [Footprint.rankedBitMemoCells, EditApproximation.rankedBitMemoCells] + cases hf : (memory.lookupCosted (binaryMemoKey bits (encode key))).1 with + | some value => rfl + | none => + dsimp only + congr 1 + rw [← footprint_runCells] + apply Footprint.runCells_congr + intro child previous + exact ih (rank child.val) (hlevel ▸ child.property) child.val rfl previous + exact hall (rank key) key rfl memory + +end Heap +end OAI.EditApproximation.BitQuery diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/FootprintMain.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/FootprintMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a1bf894309483be35506db6d1828274dad96fb1 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/FootprintMain.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.EditApproximation.Specification.ConcreteFootprintBridges +import OAI.Combinatorics.EditApproximation.Definitions + +namespace OAI.EditApproximation +open Filter MeasureTheory +attribute [local instance] queryRoundsNeZero + +def computedQueryTemporaryCellsFootprint (source target : List ℕ) (N : ℕ) + (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ) + (input : ComputedFamilyInput source target N) : ℕ := + BitQuery.Footprint.rankedBitMemoCells (SourceRanked.rank ChargedPhysicalRequest.rank) + (computedQueryMemoNormalized source target N occurrence symbolBits positionBits input) + (computedQueryMemoFootprint source target N occurrence symbolBits positionBits input) + (16384 * inputHeight N + 5) (computedFamilyMemoCode source target N (inputHeight N ^ 2)) + (fun key => (computedFamilyMemoCodeWithWork source target N (inputHeight N ^ 2) key).2) + (.inr (localFinalRootRequest target N (integerParameters N).T (integerParameters N).S + (inputHeight N) (Nat.two_pow_pos _) (finalTargetState target.length))) .empty + +noncomputable def integerAcceptedSpaceTermsFootprint (source target : List ℤ) (N : ℕ) + (epsilon : BinaryFraction) + (input : ComputedFamilyInput (source.map integerSymbolCode) (target.map integerSymbolCode) N) : List ℕ := + let x := source.map integerSymbolCode + let y := target.map integerSymbolCode + [8 * integerPreevaluationWork source target N epsilon, + 2 * integerStoredDataSpace source target, + computedQuerySetupAllocation N, + (computedQueryMemoResult x y N (integerOccurrenceIndex source target) + (integerInputSymbolBits source target) (integerInputPositionBits target) input).memory.fractionStorage, + computedQueryTemporaryCellsFootprint x y N (integerOccurrenceIndex source target) + (integerInputSymbolBits source target) (integerInputPositionBits target) input, + computedFamilyCoarseCopyStorage x y N input, + computedFamilyCoarseArrayCapacity x y N input, + computedFamilyCoarseScratchCapacity x y N input, + computedFamilyCoarseControlCapacity x y N input, + 4 * (inputHeight N + (integerParameters N).B + 4), + integerFinalAllocation source target N input, + 8 * (N + 1)] + +noncomputable def integerBinarySpaceFootprint (source target : List ℤ) (N : ℕ) (epsilon : BinaryFraction) + (outcome : ComputedFullOutcome (source.map integerSymbolCode) (target.map integerSymbolCode) N) : ℕ := + if physicalLargeInput N epsilon then + match outcome with + | .inl _ => 8 * integerPreevaluationWork source target N epsilon + + 2 * integerStoredDataSpace source target + + suffixDPAllocation (source.map integerSymbolCode) (target.map integerSymbolCode) + 8 * (N + 1) + | .inr execution => (integerAcceptedSpaceTermsFootprint source target N epsilon + (computedExecutionAccepted _ _ N execution)).sum + else 8 * integerPreevaluationWork source target N epsilon + + 2 * integerStoredDataSpace source target + + suffixDPAllocation (source.map integerSymbolCode) (target.map integerSymbolCode) + 8 * (N + 1) + +theorem computedQueryTemporaryCellsFootprint_eq (source target : List ℕ) (N : ℕ) + (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ) + (input : ComputedFamilyInput source target N) : + computedQueryTemporaryCellsFootprint source target N occurrence symbolBits positionBits input = + computedQueryTemporaryCells source target N occurrence symbolBits positionBits input := by + have h : computedQueryMemoFootprint source target N occurrence symbolBits positionBits input = + (fun key => (computedQueryMemoHeap source target N occurrence symbolBits positionBits input key).footprint) := by + funext key + exact (computedQueryMemoHeap_footprint source target N occurrence symbolBits positionBits input key).symm + unfold computedQueryTemporaryCellsFootprint computedQueryTemporaryCells + rw [h] + exact BitQuery.Heap.footprint_rankedBitMemoCells _ _ _ _ _ _ _ _ + +theorem integerAcceptedSpaceTermsFootprint_eq (source target : List ℤ) (N : ℕ) + (epsilon : BinaryFraction) + (input : ComputedFamilyInput (source.map integerSymbolCode) (target.map integerSymbolCode) N) : + integerAcceptedSpaceTermsFootprint source target N epsilon input = + integerAcceptedSpaceTerms source target N epsilon input := by + simp only [integerAcceptedSpaceTermsFootprint, integerAcceptedSpaceTerms, + computedQueryTemporaryCellsFootprint_eq] + +theorem integerBinarySpaceFootprint_eq (source target : List ℤ) (N : ℕ) (epsilon : BinaryFraction) + (outcome : ComputedFullOutcome (source.map integerSymbolCode) (target.map integerSymbolCode) N) : + integerBinarySpaceFootprint source target N epsilon outcome = + integerBinarySpace source target N epsilon outcome := by + simp only [integerBinarySpaceFootprint, integerBinarySpace, integerAcceptedSpaceTermsFootprint_eq] + rfl + +theorem almostLinearEditDistance_main (epsilon : BinaryFraction) + (hepsilon : 0 < epsilon.value) (_hepsilonOne : epsilon.value < 1) + : + (∀ (source target : List ℤ) (N : ℕ), source.length + target.length ≤ N → + (2 / 3 : ℝ) ≤ (computedFullLaw (source.map integerSymbolCode) (target.map integerSymbolCode) N epsilon).real + {outcome | EditDistortion.edit source target ≤ integerBinaryAnswer source target N epsilon outcome ∧ + (integerBinaryAnswer source target N epsilon outcome : ℝ) ≤ + (1 + (epsilon.value : ℝ)) * EditDistortion.edit source target}) ∧ + (∀ (source target : List ℤ) (N : ℕ), source = target → ∀ outcome, + integerBinaryAnswer source target N epsilon outcome = 0) ∧ + (∀ (C : ℕ) (eta : ℝ), 0 < eta → ∀ᶠ N : ℕ in atTop, + ∀ source target : List ℤ, source.length + target.length ≤ N → + (∀ z ∈ source ++ target, z.natAbs ≤ (N + 2) ^ C) → + (∫ outcome, integerBinaryWork source target N epsilon outcome + ∂computedFullLaw (source.map integerSymbolCode) (target.map integerSymbolCode) N epsilon) ≤ + (N + 2 : ℝ) ^ (1 + eta)) ∧ + (∀ C : ℕ, ∀ᶠ N : ℕ in atTop, ∀ source target : List ℤ, + source.length + target.length ≤ N → + (∀ z ∈ source ++ target, z.natAbs ≤ (N + 2) ^ C) → + ∀ outcome, integerBinarySpaceFootprint source target N epsilon outcome ≤ (N + 2) ^ (C + 65564)) := by + simpa only [integerBinarySpaceFootprint_eq] using + almostLinearEditDistance epsilon hepsilon _hepsilonOne + +end OAI.EditApproximation diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBand.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..d19dc8e4c1fea236aa5cb8fa757474b15f90155a --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBand.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.EditApproximation.AlmostLinear +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI.EditApproximation + +/-- The finite data used after accepting an unskipped band. -/ + + +def UnskippedBand.raw {α : Type*} {source target : List α} {M : ℕ} + {parent : TargetInterval source.length} {b P exponent : ℕ} + {tau F : ℚ} {child initial : Fin M → TargetInterval target.length → ℚ} + (member : UnskippedBand source target parent b P exponent tau F child initial) : + RawUnskippedBand M target.length := + ⟨member.center, member.actions, member.nonempty⟩ + +namespace BinaryFraction + + + +theorem preparedUnskippedReadWithWorkRaw_eq {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (b P exponent : ℕ) (hb : 0 < b) (hP : 0 < P) + (tau F : BinaryFraction) + (read initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) + (R C : ℕ) (hr : ∀ i q, (read i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ C) + (center : TargetInterval target.length) : + preparedUnskippedReadWithWorkRaw parent b P exponent tau F read initial center = + Prod.map (Option.map UnskippedBand.raw) id + (preparedUnskippedReadWithWork source target parent b P exponent hb hP tau F + read initial R C hr hi center) := by + have hbandValue : (preparedRepresentativeReadWithWork parent center (parent.hi - parent.lo) + b P tau (inversePowerTwo exponent) read).1 = + representativeBandActions source target parent center b P tau.value + ((2 : ℚ) ^ (-(exponent : ℤ))) (fun i q => (read i q).1.value) := by + apply (preparedRepresentativeReadWithWork_eq_cost parent center (parent.hi - parent.lo) + b P tau (inversePowerTwo exponent) read R hr).1.trans + simpa only [inversePowerTwo_value] using preparedRepresentativeWithWork_value source target + parent center b P hP tau (inversePowerTwo exponent) (fun i q => (read i q).1) + unfold preparedUnskippedReadWithWorkRaw preparedUnskippedReadWithWork + dsimp only + split_ifs with hempty hguard + · rfl + · simp only [Prod.map, Option.map_some, id_eq, UnskippedBand.raw, UnskippedBand.actions] + congr 3 + · rfl + +end BinaryFraction +end OAI.EditApproximation diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandBridges.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandBridges.lean new file mode 100644 index 0000000000000000000000000000000000000000..64efc4c2e2c088356b358c8e227b9100bd0e8137 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandBridges.lean @@ -0,0 +1,162 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBandConsumers +import OAI.Combinatorics.EditApproximation.Definitions + +namespace OAI.EditApproximation + +theorem filterMapWithWork_map_raw {α β γ : Type*} (f : α → Option β × ℕ) + (g : β → γ) (xs : List α) : + filterMapWithWork (fun x => Prod.map (Option.map g) id (f x)) xs = + Prod.map (List.map g) id (filterMapWithWork f xs) := by + induction xs with + | nil => rfl + | cons x xs ih => + simp only [Prod.map, id_eq] at ih + simp only [filterMapWithWork, Prod.map, id_eq, ih] + cases (f x).1 <;> rfl + +theorem filterMapAllocation_map_raw {α β γ : Type*} (f : α → Option β × ℕ) + (g : β → γ) (allocation : α → ℕ) (xs : List α) : + filterMapAllocation (fun x => Prod.map (Option.map g) id (f x)) allocation xs = + filterMapAllocation f allocation xs := by + induction xs with + | nil => rfl + | cons x xs ih => + simp only [Prod.map] at ih + simp only [filterMapAllocation, Prod.map, ih, Option.isSome_map] + +namespace BinaryFraction + +theorem scoredArgmaxWithWork_map_raw {α β : Type*} (mapping : α → β) + (score : β → BinaryFraction × ℕ) (values : List α) : + scoredArgmaxWithWork score (values.map mapping) = + Prod.map (Option.map (fun result => (mapping result.1, result.2))) id + (scoredArgmaxWithWork (fun a => score (mapping a)) values) := by + induction values with + | nil => rfl + | cons head tail ih => + simp only [List.map_cons, scoredArgmaxWithWork, ih, Prod.map, id_eq] + cases (scoredArgmaxWithWork (fun a => score (mapping a)) tail).1 with + | none => rfl + | some best => + simp only [Option.map_some] + split_ifs <;> rfl + +theorem selectGroupWithWork_map_raw {α β : Type*} (mapping : α → β) + (score : β → BinaryFraction × ℕ) (values : List α) (hne : values ≠ []) : + selectGroupWithWork (values.map mapping) (by simpa using hne) score = + Prod.map mapping id (selectGroupWithWork values hne (fun a => score (mapping a))) := by + unfold selectGroupWithWork + rw [scoredArgmaxWithWork_map_raw] + simp only [Prod.map, id_eq, Option.map_map, Function.comp_def] + cases values with + | nil => exact False.elim (hne rfl) + | cons head tail => + simp only [List.map_cons, List.head_cons] + cases (scoredArgmaxWithWork (fun a => ((score (mapping a)).1.neg, (score (mapping a)).2 + 1)) + (head :: tail)).1 <;> rfl + +theorem scoredArgmaxAllocation_map_raw {α β : Type*} (mapping : α → β) + (score : β → BinaryFraction × ℕ) (allocation : β → ℕ) (values : List α) : + scoredArgmaxAllocation score allocation (values.map mapping) = + scoredArgmaxAllocation (fun a => score (mapping a)) (fun a => allocation (mapping a)) values := by + induction values with + | nil => rfl + | cons head tail ih => + simp only [List.map_cons, scoredArgmaxAllocation, ih, scoredArgmaxWithWork_map_raw, Prod.map] + cases (scoredArgmaxWithWork (fun a => score (mapping a)) tail).1 <;> rfl + +theorem selectGroupAllocation_map_raw {α β : Type*} (mapping : α → β) + (score : β → BinaryFraction × ℕ) (allocation : β → ℕ) (values : List α) : + selectGroupAllocation (values.map mapping) score allocation = + selectGroupAllocation values (fun a => score (mapping a)) (fun a => allocation (mapping a)) := by + exact scoredArgmaxAllocation_map_raw mapping _ allocation values + +section Group +variable {α : Type*} (source target : List α) {M T : ℕ} + (parent : TargetInterval source.length) (b P exponent Q : ℕ) + (tau F : BinaryFraction) (child : Fin M → TargetInterval target.length → BinaryFraction) + (initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) + (initialAllocation currentAllocation : Fin M → TargetInterval target.length → ℕ) + (scales : Fin T → BinaryFraction) + (draw : ∀ t, Fin (groupSampleCount M Q b (scales t).value) → Fin M) + (drawSource : ∀ t, Fin (groupSampleCount M Q b (scales t).value) → Fin M × ℕ) + (drawAllocation : ∀ t, Fin (groupSampleCount M Q b (scales t).value) → ℕ) + +local notation "Member" => UnskippedBand source target parent b P exponent (value tau) (value F) + (fun i q => value (child i q)) (fun i q => value (Prod.fst (initial i q))) + +theorem unskippedEstimateReadWithWorkRaw_eq (member : Member) : + unskippedEstimateReadWithWorkRaw b exponent Q initial current scales draw member.raw = + unskippedEstimateReadWithWork source target parent b P exponent Q tau F child initial current + scales draw member := rfl + +theorem unskippedEstimateSourceWithWorkRaw_eq (member : Member) : + unskippedEstimateSourceWithWorkRaw b exponent Q initial current scales drawSource member.raw = + unskippedEstimateSourceWithWork source target parent b P exponent Q tau F child initial current + scales drawSource member := rfl + +theorem chooseUnskippedReadWithWorkRaw_eq (members : List Member) (hne : members ≠ []) : + chooseUnskippedReadWithWorkRaw b exponent Q initial current scales draw + (members.map UnskippedBand.raw) (by simpa using hne) = + Prod.map UnskippedBand.raw id + (chooseUnskippedReadWithWork source target parent b P exponent Q tau F child initial current + scales draw members hne) := by + exact selectGroupWithWork_map_raw UnskippedBand.raw _ members hne + +theorem chooseUnskippedSourceWithWorkRaw_eq (members : List Member) (hne : members ≠ []) : + chooseUnskippedSourceWithWorkRaw b exponent Q initial current scales drawSource + (members.map UnskippedBand.raw) (by simpa using hne) = + Prod.map UnskippedBand.raw id + (chooseUnskippedSourceWithWork source target parent b P exponent Q tau F child initial current + scales drawSource members hne) := by + exact selectGroupWithWork_map_raw UnskippedBand.raw _ members hne + +theorem sampledGroupActionReadWithWorkRaw_eq (members : List Member) (hne : members ≠ []) : + sampledGroupActionReadWithWorkRaw b exponent Q initial current scales draw + (members.map UnskippedBand.raw) (by simpa using hne) = + sampledGroupActionReadWithWork source target parent b P exponent Q tau F child initial current + scales draw members hne := by + let finish := fun selected : RawUnskippedBand M target.length × ℕ => + let rounded := roundedBandReadWithWork exponent b selected.1.actions selected.1.nonempty initial + let result := endpointActionWithWork selected.1.center rounded.1.get + (result.1, selected.2 + rounded.2 + result.2 + 3) + exact congrArg finish (chooseUnskippedReadWithWorkRaw_eq source target parent b P exponent Q + tau F child initial current scales draw members hne) + +theorem sampledGroupActionSourceWithWorkRaw_eq (members : List Member) (hne : members ≠ []) : + sampledGroupActionSourceWithWorkRaw b exponent Q initial current scales drawSource + (members.map UnskippedBand.raw) (by simpa using hne) = + sampledGroupActionSourceWithWork source target parent b P exponent Q tau F child initial current + scales drawSource members hne := by + let finish := fun selected : RawUnskippedBand M target.length × ℕ => + let rounded := roundedBandReadWithWork exponent b selected.1.actions selected.1.nonempty initial + let result := endpointActionWithWork selected.1.center rounded.1.get + (result.1, selected.2 + rounded.2 + result.2 + 3) + exact congrArg finish (chooseUnskippedSourceWithWorkRaw_eq source target parent b P exponent Q + tau F child initial current scales drawSource members hne) + +theorem unskippedEstimateSourceAllocationRaw_eq (member : Member) : + unskippedEstimateSourceAllocationRaw b exponent Q initial current initialAllocation currentAllocation + scales drawSource drawAllocation member.raw = + unskippedEstimateSourceAllocation source target parent b P exponent Q tau F child initial current + initialAllocation currentAllocation scales drawSource drawAllocation member := rfl + +theorem chooseUnskippedSourceAllocationRaw_eq (members : List Member) : + chooseUnskippedSourceAllocationRaw b exponent Q initial current initialAllocation currentAllocation + scales drawSource drawAllocation (members.map UnskippedBand.raw) = + chooseUnskippedSourceAllocation source target parent b P exponent Q tau F child initial current + initialAllocation currentAllocation scales drawSource drawAllocation members := by + exact selectGroupAllocation_map_raw UnskippedBand.raw _ _ members + +theorem sampledGroupActionSourceAllocationRaw_eq (members : List Member) (hne : members ≠ []) : + sampledGroupActionSourceAllocationRaw b exponent Q initial current initialAllocation currentAllocation + scales drawSource drawAllocation (members.map UnskippedBand.raw) (by simpa using hne) = + sampledGroupActionSourceAllocation source target parent b P exponent Q tau F child initial current + initialAllocation currentAllocation scales drawSource drawAllocation members hne := by + unfold sampledGroupActionSourceAllocationRaw sampledGroupActionSourceAllocation + rw [chooseUnskippedSourceWithWorkRaw_eq, chooseUnskippedSourceAllocationRaw_eq] + rfl + +end Group +end BinaryFraction +end OAI.EditApproximation diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandConsumers.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandConsumers.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3ec33577c16a603eaa1dd867bc373179dd8dcac --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandConsumers.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBand +import OAI.Combinatorics.EditApproximation.Definitions + +namespace OAI.EditApproximation.BinaryFraction + +section Group +variable {ny M T : ℕ} (b exponent Q : ℕ) + (initial current : Fin M → TargetInterval ny → BinaryFraction × ℕ) + (initialAllocation currentAllocation : Fin M → TargetInterval ny → ℕ) + (scales : Fin T → BinaryFraction) + (draw : ∀ t, Fin (groupSampleCount M Q b (scales t).value) → Fin M) + (drawSource : ∀ t, Fin (groupSampleCount M Q b (scales t).value) → Fin M × ℕ) + (drawAllocation : ∀ t, Fin (groupSampleCount M Q b (scales t).value) → ℕ) + +def unskippedEstimateReadWithWorkRaw (member : (RawUnskippedBand M ny)) : BinaryFraction × ℕ := + let mass := envelopeVectorReadWithWork b member.actions initial + let rounded := roundedBandReadWithWork exponent b member.actions member.nonempty initial + let values := vectorMapWithWork M fun i => current i (rounded.1.get i) + let connection := endpointConnectionWithWork member.center rounded.1.get + let result := countedGroupMemberWithWork Q b scales connection.1 mass.1 values.1 draw + (result.1, mass.2 + rounded.2 + values.2 + connection.2 + result.2 + 5) + +def chooseUnskippedReadWithWorkRaw (members : List (RawUnskippedBand M ny)) (hne : members ≠ []) : (RawUnskippedBand M ny) × ℕ := + selectGroupWithWork members hne + (unskippedEstimateReadWithWorkRaw b exponent Q initial current scales draw) + +def sampledGroupActionReadWithWorkRaw (members : List (RawUnskippedBand M ny)) (hne : members ≠ []) : + BinaryBellmanAction (TargetInterval ny) (Fin M × TargetInterval ny) M × ℕ := + let selected := chooseUnskippedReadWithWorkRaw b exponent Q initial current scales draw members hne + let rounded := roundedBandReadWithWork exponent b selected.1.actions selected.1.nonempty initial + let result := endpointActionWithWork selected.1.center rounded.1.get + (result.1, selected.2 + rounded.2 + result.2 + 3) + + + + + + + + + + + + + +end Group + +end OAI.EditApproximation.BinaryFraction diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandMain.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..54e5974a3d635ca2ec0ee4785d560859fd1e8649 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandMain.lean @@ -0,0 +1,32 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBandPipelineFootprintBridges +import OAI.Combinatorics.EditApproximation.Definitions + +namespace OAI.EditApproximation +open Filter MeasureTheory +attribute [local instance] queryRoundsNeZero + +theorem almostLinearEditDistanceRawBand (epsilon : BinaryFraction) + (hepsilon : 0 < epsilon.value) (_hepsilonOne : epsilon.value < 1) + : + (∀ (source target : List ℤ) (N : ℕ), source.length + target.length ≤ N → + (2 / 3 : ℝ) ≤ (computedFullLaw (source.map integerSymbolCode) (target.map integerSymbolCode) N epsilon).real + {outcome | EditDistortion.edit source target ≤ integerBinaryAnswerRawBand source target N epsilon outcome ∧ + (integerBinaryAnswerRawBand source target N epsilon outcome : ℝ) ≤ + (1 + (epsilon.value : ℝ)) * EditDistortion.edit source target}) ∧ + (∀ (source target : List ℤ) (N : ℕ), source = target → ∀ outcome, + integerBinaryAnswerRawBand source target N epsilon outcome = 0) ∧ + (∀ (C : ℕ) (eta : ℝ), 0 < eta → ∀ᶠ N : ℕ in atTop, + ∀ source target : List ℤ, source.length + target.length ≤ N → + (∀ z ∈ source ++ target, z.natAbs ≤ (N + 2) ^ C) → + (∫ outcome, integerBinaryWorkRawBand source target N epsilon outcome + ∂computedFullLaw (source.map integerSymbolCode) (target.map integerSymbolCode) N epsilon) ≤ + (N + 2 : ℝ) ^ (1 + eta)) ∧ + (∀ C : ℕ, ∀ᶠ N : ℕ in atTop, ∀ source target : List ℤ, + source.length + target.length ≤ N → + (∀ z ∈ source ++ target, z.natAbs ≤ (N + 2) ^ C) → + ∀ outcome, integerBinarySpaceFootprintRawBand source target N epsilon outcome ≤ (N + 2) ^ (C + 65564)) := by + simpa only [integerBinaryAnswerRawBand_eq, integerBinaryWorkRawBand_eq, + integerBinarySpaceFootprintRawBand_eq] using + almostLinearEditDistance_main epsilon hepsilon _hepsilonOne + +end OAI.EditApproximation diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandOuter.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandOuter.lean new file mode 100644 index 0000000000000000000000000000000000000000..3208c132fd8a5497b49169227621e4a67d23b50c --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandOuter.lean @@ -0,0 +1,47 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBandConsumers +import OAI.Combinatorics.EditApproximation.Definitions + +namespace OAI.EditApproximation.BinaryFraction + +def dyadicSampledGroupActionReadWithWorkRaw {ny M : ℕ} + (b exponent Q : ℕ) (F : BinaryFraction) + (initial current : Fin M → TargetInterval ny → BinaryFraction × ℕ) + (raw : List BinaryFraction) (hraw : raw.map value = groupDyadicScales M b F.value) + (draw : ∀ t : Fin (groupDyadicScales M b F.value).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F.value t)) → Fin M) + (members : List (RawUnskippedBand M ny)) (hne : members ≠ []) := + sampledGroupActionReadWithWorkRaw b exponent Q initial current + (indexedGroupScales raw M b F.value hraw) + (fun t j => draw t (Fin.cast (congrArg (groupSampleCount M Q b) + (indexedGroupScales_value raw M b F.value hraw t)) j)) members hne + +def preparedCellGroupReadWithWorkRaw {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (b P F exponent Q : ℕ) (_hb : 0 < b) (_hP : 0 < P) + (tau a : BinaryFraction) + (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) + (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) + (R C : ℕ) (_hr : ∀ i q, (child i q).2 ≤ R) (_hi : ∀ i q, (initial i q).2 ≤ C) + (raw : List BinaryFraction) (hraw : raw.map value = groupDyadicScales M b (nat F).value) + (draw : ∀ t : Fin (groupDyadicScales M b (nat F).value).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b (nat F).value t)) → Fin M) + + + (cell : ℕ × ℕ) : + Option (BinaryBellmanAction (TargetInterval target.length) + (Fin M × TargetInterval target.length) M) × ℕ := + let centers := cellCentersReadWithWork P F b a (inversePowerTwo exponent) parentInitial cell + let members := filterMapWithWork + (preparedUnskippedReadWithWorkRaw parent b P exponent tau (nat F) child initial) centers.1 + if h : members.1 = [] then (none, centers.2 + members.2 + 1) else + let selected := dyadicSampledGroupActionReadWithWorkRaw b exponent Q (nat F) initial current raw hraw draw members.1 h + (some selected.1, centers.2 + members.2 + selected.2 + 2) + + + + + + + + + +end OAI.EditApproximation.BinaryFraction diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandOuterBridges.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandOuterBridges.lean new file mode 100644 index 0000000000000000000000000000000000000000..531db3014a24e87341a90b802a1df01acb237122 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandOuterBridges.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBandOuter +import OAI.Combinatorics.EditApproximation.Specification.RawBandBridges +import OAI.Combinatorics.EditApproximation.Definitions + +namespace OAI.EditApproximation.BinaryFraction + +theorem dyadicSampledGroupActionReadWithWorkRaw_eq {α : Type*} (source target : List α) {M : ℕ} + (parent : TargetInterval source.length) (b P exponent Q : ℕ) (tau F : BinaryFraction) + (child : Fin M → TargetInterval target.length → BinaryFraction) + (initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) + (raw : List BinaryFraction) (hraw : raw.map value = groupDyadicScales M b F.value) + (draw : ∀ t : Fin (groupDyadicScales M b F.value).length, + Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F.value t)) → Fin M) + (members : List (UnskippedBand source target parent b P exponent tau.value F.value + (fun i q => (child i q).value) (fun i q => (initial i q).1.value))) (hne : members ≠ []) : + dyadicSampledGroupActionReadWithWorkRaw b exponent Q F initial current raw hraw draw + (members.map UnskippedBand.raw) (by simpa using hne) = + dyadicSampledGroupActionReadWithWork source target parent b P exponent Q tau F child initial current + raw hraw draw members hne := by + exact sampledGroupActionReadWithWorkRaw_eq source target parent b P exponent Q tau F child initial current + _ _ members hne + +theorem preparedOnlineReadWithWorkRaw_eq : @preparedOnlineReadWithWorkRaw = @preparedOnlineReadWithWork := by + funext α source target M parent P F exponent H b hb hP tau eta kappa child initial table R hc hi t center integer + unfold preparedOnlineReadWithWorkRaw preparedOnlineReadWithWork + rw [preparedUnskippedReadWithWorkRaw_eq source target parent b P exponent hb hP tau (nat F) + child initial R R hc hi center] + simp only [Prod.map, id_eq, Option.isSome_map] + +theorem preparedOnlineReadAllocationRaw_eq : @preparedOnlineReadAllocationRaw = @preparedOnlineReadAllocation := by + funext α source target M parent P F exponent H b hb hP tau eta kappa child initial table R hc hi + childAllocation initialAllocation tableAllocation t center integer + unfold preparedOnlineReadAllocationRaw preparedOnlineReadAllocation + rw [preparedUnskippedReadWithWorkRaw_eq source target parent b P exponent hb hP tau (nat F) + child initial R R hc hi center] + simp only [Prod.map, Option.isSome_map] + +theorem preparedCellGroupReadWithWorkRaw_eq : @preparedCellGroupReadWithWorkRaw = @preparedCellGroupReadWithWork := by + funext α source target M parent b P F exponent Q hb hP tau a parentInitial child initial current + R C hr hi raw hraw draw cell + have hreader := funext (preparedUnskippedReadWithWorkRaw_eq source target parent b P exponent hb hP tau (nat F) + child initial R C hr hi) + let centers := (cellCentersReadWithWork P F b a (inversePowerTwo exponent) parentInitial cell).1 + have hmembers : filterMapWithWork + (preparedUnskippedReadWithWorkRaw parent b P exponent tau (nat F) child initial) centers = + Prod.map (List.map UnskippedBand.raw) id (filterMapWithWork + (preparedUnskippedReadWithWork source target parent b P exponent hb hP tau (nat F) + child initial R C hr hi) centers) := by + rw [hreader] + exact filterMapWithWork_map_raw _ _ _ + dsimp only [centers] at hmembers + unfold preparedCellGroupReadWithWorkRaw preparedCellGroupReadWithWork + simp only [hmembers] + simp only [Prod.map, id_eq, List.map_eq_nil_iff] + split_ifs with h + · rfl + · rw [dyadicSampledGroupActionReadWithWorkRaw_eq] + +theorem preparedCellGroupSourceWithWorkRaw_eq : @preparedCellGroupSourceWithWorkRaw = @preparedCellGroupSourceWithWork := by + funext α source target M parent b P F exponent Q hb hP tau a parentInitial child initial current + R C hr hi raw hraw draw cell + have hreader := funext (preparedUnskippedReadWithWorkRaw_eq source target parent b P exponent hb hP tau (nat F) + child initial R C hr hi) + let centers := (cellCentersReadWithWork P F b a (inversePowerTwo exponent) parentInitial cell).1 + have hmembers : filterMapWithWork + (preparedUnskippedReadWithWorkRaw parent b P exponent tau (nat F) child initial) centers = + Prod.map (List.map UnskippedBand.raw) id (filterMapWithWork + (preparedUnskippedReadWithWork source target parent b P exponent hb hP tau (nat F) + child initial R C hr hi) centers) := by + rw [hreader] + exact filterMapWithWork_map_raw _ _ _ + dsimp only [centers] at hmembers + unfold preparedCellGroupSourceWithWorkRaw preparedCellGroupSourceWithWork + simp only [hmembers] + simp only [Prod.map, id_eq, List.map_eq_nil_iff] + split_ifs with h + · rfl + · rw [sampledGroupActionSourceWithWorkRaw_eq] + +theorem preparedCellGroupSourceAllocationRaw_eq : @preparedCellGroupSourceAllocationRaw = @preparedCellGroupSourceAllocation := by + funext α source target M parent b P F exponent Q hb hP tau a parentInitial child initial current + R C hr hi raw hraw draw parentAllocation childAllocation initialAllocation currentAllocation drawAllocation cell + have hreader := funext (preparedUnskippedReadWithWorkRaw_eq source target parent b P exponent hb hP tau (nat F) + child initial R C hr hi) + let centers := (cellCentersReadWithWork P F b a (inversePowerTwo exponent) parentInitial cell).1 + have hmembers : filterMapWithWork + (preparedUnskippedReadWithWorkRaw parent b P exponent tau (nat F) child initial) centers = + Prod.map (List.map UnskippedBand.raw) id (filterMapWithWork + (preparedUnskippedReadWithWork source target parent b P exponent hb hP tau (nat F) + child initial R C hr hi) centers) := by + rw [hreader] + exact filterMapWithWork_map_raw _ _ _ + have hallocation : filterMapAllocation + (preparedUnskippedReadWithWorkRaw parent b P exponent tau (nat F) child initial) + (fun center => preparedUnskippedReadAllocation parent center b P exponent tau (nat F) + child initial childAllocation initialAllocation) centers = + filterMapAllocation + (preparedUnskippedReadWithWork source target parent b P exponent hb hP tau (nat F) + child initial R C hr hi) + (fun center => preparedUnskippedReadAllocation parent center b P exponent tau (nat F) + child initial childAllocation initialAllocation) centers := by + rw [hreader] + exact filterMapAllocation_map_raw _ _ _ _ + dsimp only [centers] at hmembers hallocation + unfold preparedCellGroupSourceAllocationRaw preparedCellGroupSourceAllocation + simp only [hmembers, hallocation] + simp only [Prod.map, id_eq, List.map_eq_nil_iff] + split_ifs with h + · rfl + · rw [sampledGroupActionSourceAllocationRaw_eq] + +end OAI.EditApproximation.BinaryFraction diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipeline.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipeline.lean new file mode 100644 index 0000000000000000000000000000000000000000..a764824f75877ea189c144d1c690a2b1d7f89f4b --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipeline.lean @@ -0,0 +1,581 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBandOuter +import OAI.Combinatorics.EditApproximation.Specification.ConcreteFootprints +import OAI.Combinatorics.EditApproximation.Definitions + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent H : ℕ) (hP : 0 < P) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (table : ℕ → Fin M × TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (t : ℕ) (integer : ℕ → TargetInterval target.length → ℕ × ℕ) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent H : ℕ) (hP : 0 < P) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (table : ℕ → Fin M × TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (t : ℕ) (integer : ℕ → TargetInterval target.length → ℕ × ℕ) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i r, (child i r).2 ≤ R) (hi : ∀ i r, (initial i r).2 ≤ R) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i r, (child i r).2 ≤ R) (hi : ∀ i r, (initial i r).2 ≤ R) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {ι α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (t : ℕ) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i r, (child i r).2 ≤ R) (hi : ∀ i r, (initial i r).2 ≤ R) (draw : CountedCellGroupDraws M F Q) (integer : ℕ → TargetInterval target.length → ℕ × ℕ) (q : TargetInterval target.length) (readEarlier : (Fin M × ℕ × TargetInterval target.length) → BitQuery ι BinaryFraction) (readCurrent : (Fin M × TargetInterval target.length) → BitQuery ι BinaryFraction) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {ι α : Type*} (source target : List α) {M : ℕ} [NeZero M] (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (t : ℕ) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i r, (child i r).2 ≤ R) (hi : ∀ i r, (initial i r).2 ≤ R) (q : TargetInterval target.length) (readGroup : GroupScalarKey M F Q → BitQuery ι BinaryFraction) (readInteger : (ℕ × TargetInterval target.length) → ℕ → BitQuery ι BinaryFraction) (readEarlier : (Fin M × ℕ × TargetInterval target.length) → BitQuery ι BinaryFraction) (readCurrent : (Fin M × TargetInterval target.length) → BitQuery ι BinaryFraction) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {ι α : Type*} (source target : List α) {M : ℕ} [NeZero M] (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (t : ℕ) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (readMass readInitial : (Fin M × TargetInterval target.length) → BitQuery ι BinaryFraction) (readGroup : GroupScalarKey M F Q → BitQuery ι BinaryFraction) (readInteger : (ℕ × TargetInterval target.length) → ℕ → BitQuery ι BinaryFraction) (q : TargetInterval target.length) (readEarlier : (Fin M × ℕ × TargetInterval target.length) → BitQuery ι BinaryFraction) (readCurrent : (Fin M × TargetInterval target.length) → BitQuery ι BinaryFraction) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {ι α : Type*} (source target : List α) {M : ℕ} [NeZero M] (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (t : ℕ) (readParent : TargetInterval target.length → BitQuery ι BinaryFraction) (readMass readInitial : (Fin M × TargetInterval target.length) → BitQuery ι BinaryFraction) (readGroup : GroupScalarKey M F Q → BitQuery ι BinaryFraction) (readInteger : (ℕ × TargetInterval target.length) → ℕ → BitQuery ι BinaryFraction) (q : TargetInterval target.length) (readEarlier : (Fin M × ℕ × TargetInterval target.length) → BitQuery ι BinaryFraction) (readCurrent : (Fin M × TargetInterval target.length) → BitQuery ι BinaryFraction) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {σ α : Type*} (source target : List α) {M J : ℕ} [NeZero M] (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (copies pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) (readGroup : GroupScalarKey M F Q → BitQuery σ BinaryFraction) (readInteger : (ℕ × TargetInterval target.length) → ℕ → BitQuery σ BinaryFraction) (q : TargetInterval target.length) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {α : Type*} {M J R : ℕ} [NeZero M] (source target : List α) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (passes copies pass copy T S t : ℕ) (ht : 0 < t) (node : PhysicalNode M J) (hbelow : node.1.val < J) (time : Fin R) (q : TargetInterval target.length) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] (source target : List α) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (T S passes copies : ℕ) (request : PhysicalTableRequest M J target.length) (hindex : T < request.index) (hbelow : request.node.1.val < J) +include hindex in +omit [DecidableEq α] [NeZero M] in + +theorem active_request_eqRawBand : + PhysicalTableRequest.refinement request.pass request.copy request.node T (request.index - T) + request.state = request := by + have hi : T + (request.index - T) = request.index := by omega + unfold PhysicalTableRequest.refinement + rw [hi] + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] (source target : List α) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (T S passes copies : ℕ) (request : PhysicalTableRequest M J target.length) (hindex : T < request.index) (hbelow : request.node.1.val < J) + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {α : Type*} [DecidableEq α] {M J R : ℕ} [NeZero M] [NeZero R] (source target : List α) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa delta : BinaryFraction) (T S passes copies : ℕ) (parent : {r : PhysicalTableRequest M J target.length // r.Bounded (passes + 1) copies T S}) (hindex : T < parent.val.index) (hbelow : parent.val.node.1.val < J) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {M J R passes copies T S : ℕ} [NeZero M] [NeZero R] (source target : List ℕ) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (A a : ℕ → BinaryFraction) (tau eta kappa delta : BinaryFraction) (multiplier : ℕ → ℕ) (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {M J R passes copies T S : ℕ} [NeZero M] [NeZero R] (source target : List ℕ) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (A a : ℕ → BinaryFraction) (tau eta kappa delta : BinaryFraction) (multiplier : ℕ → ℕ) (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +variable {M J R passes copies T S : ℕ} [NeZero M] [NeZero R] (source target : List ℕ) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (A a : ℕ → BinaryFraction) (tau eta kappa delta : BinaryFraction) (multiplier : ℕ → ℕ) (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ) (coarse : PhysicalEntry M J target.length → BinaryFraction × ℕ) (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R) + target N P F exponent H Q passes copies) + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation + + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation + + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +attribute [local instance] queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +attribute [local instance] queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open Filter MeasureTheory + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +attribute [local instance] queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation + + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open MeasureTheory + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation currentAllocation : Fin M → TargetInterval target.length → ℕ) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation currentAllocation : Fin M → TargetInterval target.length → ℕ) +variable (draw : CellGroupReadDraws M F Q) (drawAllocation : CellGroupSourceAllocations M F Q) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation currentAllocation : Fin M → TargetInterval target.length → ℕ) +variable (draw : CellGroupReadDraws M F Q) (drawAllocation : CellGroupSourceAllocations M F Q) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation currentAllocation : Fin M → TargetInterval target.length → ℕ) +variable (draw : CellGroupReadDraws M F Q) (drawAllocation : CellGroupSourceAllocations M F Q) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation currentAllocation : Fin M → TargetInterval target.length → ℕ) +variable (draw : CellGroupReadDraws M F Q) (drawAllocation : CellGroupSourceAllocations M F Q) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent Q eM eF : ℕ) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (hP : 0 < P) (tau a : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial current : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation currentAllocation : Fin M → TargetInterval target.length → ℕ) +variable (draw : CellGroupReadDraws M F Q) (drawAllocation : CellGroupSourceAllocations M F Q) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent H : ℕ) (hP : 0 < P) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (table : ℕ → Fin M × TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (t : ℕ) (integer : ℕ → TargetInterval target.length → ℕ × ℕ) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation : Fin M → TargetInterval target.length → ℕ) (tableAllocation : ℕ → Fin M × TargetInterval target.length → ℕ) (integerAllocation : ℕ → TargetInterval target.length → ℕ) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (P F exponent H : ℕ) (hP : 0 < P) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (table : ℕ → Fin M × TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i q, (child i q).2 ≤ R) (hi : ∀ i q, (initial i q).2 ≤ R) (t : ℕ) (integer : ℕ → TargetInterval target.length → ℕ × ℕ) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation : Fin M → TargetInterval target.length → ℕ) (tableAllocation : ℕ → Fin M × TargetInterval target.length → ℕ) (integerAllocation : ℕ → TargetInterval target.length → ℕ) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i r, (child i r).2 ≤ R) (hi : ∀ i r, (initial i r).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation : Fin M → TargetInterval target.length → ℕ) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation.BinaryFraction +variable {α : Type*} (source target : List α) {M : ℕ} (parent : TargetInterval source.length) (N P F exponent H Q eM eF : ℕ) (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (tau a eta kappa : BinaryFraction) (parentInitial : TargetInterval target.length → BinaryFraction × ℕ) (child initial : Fin M → TargetInterval target.length → BinaryFraction × ℕ) (R : ℕ) (hc : ∀ i r, (child i r).2 ≤ R) (hi : ∀ i r, (initial i r).2 ≤ R) (parentAllocation : TargetInterval target.length → ℕ) (childAllocation initialAllocation : Fin M → TargetInterval target.length → ℕ) + + + +end OAI.EditApproximation.BinaryFraction +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open Filter MeasureTheory + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open Filter + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open BitQuery +attribute [local instance] queryArityNeZero queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open Filter MeasureTheory +attribute [local instance] queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open Filter MeasureTheory +attribute [local instance] queryRoundsNeZero + + + +end OAI.EditApproximation +end + +section +universe u v w u_1 u_2 u_3 +namespace OAI.EditApproximation +open Filter MeasureTheory +attribute [local instance] queryRoundsNeZero + + + +end OAI.EditApproximation +end diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipelineBridges.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipelineBridges.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c3cff2c3e34c6752a331c359e3c26b473750152 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipelineBridges.lean @@ -0,0 +1,154 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBandPipeline +import OAI.Combinatorics.EditApproximation.Specification.RawBandOuterBridges +import OAI.Combinatorics.EditApproximation.Definitions + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceWithWorkRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceWithWorkRawBand = @OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceWithWork := by + unfold OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceWithWorkRawBand OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceWithWork + simp only [OAI.EditApproximation.BinaryFraction.preparedCellGroupSourceWithWorkRaw_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceWithWorkRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceWithWorkRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceWithWork := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceWithWorkRawBand OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceWithWork + simp only [OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceWithWorkRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceWithWorkRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceWithWork := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceWithWorkRawBand OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceWithWork + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceWithWorkRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceWithWorkRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceWithWork := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceWithWorkRawBand OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceWithWork + simp only [OAI.EditApproximation.BinaryFraction.preparedOnlineReadWithWorkRaw_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceWithWorkRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceWithWorkRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceWithWork := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceWithWorkRawBand OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceWithWork + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.queryOnlineSelectWithWorkRawBand_eq : @OAI.EditApproximation.BinaryFraction.queryOnlineSelectWithWorkRawBand = @OAI.EditApproximation.BinaryFraction.queryOnlineSelectWithWork := by + unfold OAI.EditApproximation.BinaryFraction.queryOnlineSelectWithWorkRawBand OAI.EditApproximation.BinaryFraction.queryOnlineSelectWithWork + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.queryGroupSelectWithWorkRawBand_eq : @OAI.EditApproximation.BinaryFraction.queryGroupSelectWithWorkRawBand = @OAI.EditApproximation.BinaryFraction.queryGroupSelectWithWork := by + unfold OAI.EditApproximation.BinaryFraction.queryGroupSelectWithWorkRawBand OAI.EditApproximation.BinaryFraction.queryGroupSelectWithWork + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryLocalRefinementRawBand_eq : @OAI.EditApproximation.queryLocalRefinementRawBand = @OAI.EditApproximation.queryLocalRefinement := by + unfold OAI.EditApproximation.queryLocalRefinementRawBand OAI.EditApproximation.queryLocalRefinement + simp only [OAI.EditApproximation.BinaryFraction.queryOnlineSelectWithWorkRawBand_eq, OAI.EditApproximation.BinaryFraction.queryGroupSelectWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryLocalRandomSourcesRawBand_eq : @OAI.EditApproximation.queryLocalRandomSourcesRawBand = @OAI.EditApproximation.queryLocalRandomSources := by + unfold OAI.EditApproximation.queryLocalRandomSourcesRawBand OAI.EditApproximation.queryLocalRandomSources + simp only [OAI.EditApproximation.queryLocalRefinementRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryLocalBandRawBand_eq : @OAI.EditApproximation.queryLocalBandRawBand = @OAI.EditApproximation.queryLocalBand := by + unfold OAI.EditApproximation.queryLocalBandRawBand OAI.EditApproximation.queryLocalBand + simp only [OAI.EditApproximation.queryLocalRandomSourcesRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryLocalProgramRawBand_eq : @OAI.EditApproximation.queryLocalProgramRawBand = @OAI.EditApproximation.queryLocalProgram := by + unfold OAI.EditApproximation.queryLocalProgramRawBand OAI.EditApproximation.queryLocalProgram + simp only [OAI.EditApproximation.queryLocalBandRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryPhysicalRandomDataRequestRawBand_eq : @OAI.EditApproximation.queryPhysicalRandomDataRequestRawBand = @OAI.EditApproximation.queryPhysicalRandomDataRequest := by + unfold OAI.EditApproximation.queryPhysicalRandomDataRequestRawBand OAI.EditApproximation.queryPhysicalRandomDataRequest + simp only [OAI.EditApproximation.queryLocalProgramRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryFamilyRefinementRawBand_eq : @OAI.EditApproximation.queryFamilyRefinementRawBand = @OAI.EditApproximation.queryFamilyRefinement := by + unfold OAI.EditApproximation.queryFamilyRefinementRawBand OAI.EditApproximation.queryFamilyRefinement + simp only [OAI.EditApproximation.queryPhysicalRandomDataRequestRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryFamilyActiveRawBand_eq : @OAI.EditApproximation.queryFamilyActiveRawBand = @OAI.EditApproximation.queryFamilyActive := by + unfold OAI.EditApproximation.queryFamilyActiveRawBand OAI.EditApproximation.queryFamilyActive + simp only [OAI.EditApproximation.queryFamilyRefinementRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryFamilyBoundedActiveRawBand_eq : @OAI.EditApproximation.queryFamilyBoundedActiveRawBand = @OAI.EditApproximation.queryFamilyBoundedActive := by + unfold OAI.EditApproximation.queryFamilyBoundedActiveRawBand OAI.EditApproximation.queryFamilyBoundedActive + simp only [OAI.EditApproximation.queryFamilyActiveRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryChargedFamilyTableRawBand_eq : @OAI.EditApproximation.queryChargedFamilyTableRawBand = @OAI.EditApproximation.queryChargedFamilyTable := by + unfold OAI.EditApproximation.queryChargedFamilyTableRawBand OAI.EditApproximation.queryChargedFamilyTable + simp only [OAI.EditApproximation.queryFamilyBoundedActiveRawBand_eq] + +@[simp] theorem OAI.EditApproximation.queryChargedFamilyGlobalRawBand_eq : @OAI.EditApproximation.queryChargedFamilyGlobalRawBand = @OAI.EditApproximation.queryChargedFamilyGlobal := by + unfold OAI.EditApproximation.queryChargedFamilyGlobalRawBand OAI.EditApproximation.queryChargedFamilyGlobal + simp only [OAI.EditApproximation.queryChargedFamilyTableRawBand_eq] + rfl + +@[simp] theorem OAI.EditApproximation.queryFamilyMemoRawRawBand_eq : @OAI.EditApproximation.queryFamilyMemoRawRawBand = @OAI.EditApproximation.queryFamilyMemoRaw := by + unfold OAI.EditApproximation.queryFamilyMemoRawRawBand OAI.EditApproximation.queryFamilyMemoRaw + simp only [OAI.EditApproximation.queryChargedFamilyGlobalRawBand_eq] + +@[simp] theorem OAI.EditApproximation.computedQueryMemoRawRawBand_eq : @OAI.EditApproximation.computedQueryMemoRawRawBand = @OAI.EditApproximation.computedQueryMemoRaw := by + unfold OAI.EditApproximation.computedQueryMemoRawRawBand OAI.EditApproximation.computedQueryMemoRaw + simp only [OAI.EditApproximation.queryFamilyMemoRawRawBand_eq] + +@[simp] theorem OAI.EditApproximation.computedQueryMemoNormalizedRawBand_eq : @OAI.EditApproximation.computedQueryMemoNormalizedRawBand = @OAI.EditApproximation.computedQueryMemoNormalized := by + unfold OAI.EditApproximation.computedQueryMemoNormalizedRawBand OAI.EditApproximation.computedQueryMemoNormalized + simp only [OAI.EditApproximation.computedQueryMemoRawRawBand_eq] + +@[simp] theorem OAI.EditApproximation.computedQueryMemoResultRawBand_eq : @OAI.EditApproximation.computedQueryMemoResultRawBand = @OAI.EditApproximation.computedQueryMemoResult := by + unfold OAI.EditApproximation.computedQueryMemoResultRawBand OAI.EditApproximation.computedQueryMemoResult + simp only [OAI.EditApproximation.computedQueryMemoNormalizedRawBand_eq] + +@[simp] theorem OAI.EditApproximation.computedQueryLocalWorkRawBand_eq : @OAI.EditApproximation.computedQueryLocalWorkRawBand = @OAI.EditApproximation.computedQueryLocalWork := by + unfold OAI.EditApproximation.computedQueryLocalWorkRawBand OAI.EditApproximation.computedQueryLocalWork + simp only [OAI.EditApproximation.computedQueryMemoNormalizedRawBand_eq] + +@[simp] theorem OAI.EditApproximation.integerQueryLocalWorkRawBand_eq : @OAI.EditApproximation.integerQueryLocalWorkRawBand = @OAI.EditApproximation.integerQueryLocalWork := by + unfold OAI.EditApproximation.integerQueryLocalWorkRawBand OAI.EditApproximation.integerQueryLocalWork + simp only [OAI.EditApproximation.computedQueryLocalWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.computedQueryAnswerWithWorkRawBand_eq : @OAI.EditApproximation.computedQueryAnswerWithWorkRawBand = @OAI.EditApproximation.computedQueryAnswerWithWork := by + unfold OAI.EditApproximation.computedQueryAnswerWithWorkRawBand OAI.EditApproximation.computedQueryAnswerWithWork + simp only [OAI.EditApproximation.computedQueryMemoResultRawBand_eq] + +@[simp] theorem OAI.EditApproximation.integerBinaryOutputRawBand_eq : @OAI.EditApproximation.integerBinaryOutputRawBand = @OAI.EditApproximation.integerBinaryOutput := by + unfold OAI.EditApproximation.integerBinaryOutputRawBand OAI.EditApproximation.integerBinaryOutput + simp only [OAI.EditApproximation.computedQueryAnswerWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.integerBinaryAnswerRawBand_eq : @OAI.EditApproximation.integerBinaryAnswerRawBand = @OAI.EditApproximation.integerBinaryAnswer := by + unfold OAI.EditApproximation.integerBinaryAnswerRawBand OAI.EditApproximation.integerBinaryAnswer + simp only [OAI.EditApproximation.integerBinaryOutputRawBand_eq] + rfl + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceAllocationRawBand = @OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceAllocation := by + unfold OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceAllocationRawBand OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceAllocation + simp only [OAI.EditApproximation.BinaryFraction.preparedCellGroupSourceAllocationRaw_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceAllocationRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceAllocation := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceAllocationRawBand OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceAllocation + simp only [OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceWithWorkRawBand_eq, OAI.EditApproximation.BinaryFraction.preparedComputedCellSourceAllocationRawBand_eq] + rfl + +@[simp] theorem OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockRawBand_eq : @OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockRawBand = @OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlock := by + unfold OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockRawBand OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlock + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceWithWorkRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockAllocationRawBand = @OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockAllocation := by + unfold OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockAllocationRawBand OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockAllocation + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalGroupScaleSourceAllocationRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceAllocationRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceAllocation := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceAllocationRawBand OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceAllocation + simp only [OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockRawBand_eq, OAI.EditApproximation.BinaryFraction.localGroupSourceScaleBlockAllocationRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceAllocationRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceAllocation := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceAllocationRawBand OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceAllocation + simp only [OAI.EditApproximation.BinaryFraction.preparedOnlineReadAllocationRaw_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceAllocationRawBand = @OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceAllocation := by + unfold OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceAllocationRawBand OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceAllocation + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceWithWorkRawBand_eq, OAI.EditApproximation.BinaryFraction.preparedLocalOnlineScaleSourceAllocationRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.queryOnlineSelectAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.queryOnlineSelectAllocationRawBand = @OAI.EditApproximation.BinaryFraction.queryOnlineSelectAllocation := by + unfold OAI.EditApproximation.BinaryFraction.queryOnlineSelectAllocationRawBand OAI.EditApproximation.BinaryFraction.queryOnlineSelectAllocation + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalOnlineActionsSourceAllocationRawBand_eq] + +@[simp] theorem OAI.EditApproximation.BinaryFraction.queryGroupSelectAllocationRawBand_eq : @OAI.EditApproximation.BinaryFraction.queryGroupSelectAllocationRawBand = @OAI.EditApproximation.BinaryFraction.queryGroupSelectAllocation := by + unfold OAI.EditApproximation.BinaryFraction.queryGroupSelectAllocationRawBand OAI.EditApproximation.BinaryFraction.queryGroupSelectAllocation + simp only [OAI.EditApproximation.BinaryFraction.preparedLocalCellGroupsSourceAllocationRawBand_eq] + +@[simp] theorem OAI.EditApproximation.integerBinaryWorkRawBand_eq : @OAI.EditApproximation.integerBinaryWorkRawBand = @OAI.EditApproximation.integerBinaryWork := by + unfold OAI.EditApproximation.integerBinaryWorkRawBand OAI.EditApproximation.integerBinaryWork + simp only [OAI.EditApproximation.integerQueryLocalWorkRawBand_eq, OAI.EditApproximation.integerBinaryOutputRawBand_eq] + +@[simp] theorem OAI.EditApproximation.integerFinalAllocationRawBand_eq : @OAI.EditApproximation.integerFinalAllocationRawBand = @OAI.EditApproximation.integerFinalAllocation := by + unfold OAI.EditApproximation.integerFinalAllocationRawBand OAI.EditApproximation.integerFinalAllocation + simp only [OAI.EditApproximation.computedQueryMemoResultRawBand_eq] diff --git a/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipelineFootprintBridges.lean b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipelineFootprintBridges.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e520de56ea491bc1bc7aade350a12f409510562 --- /dev/null +++ b/lean/OAI/Combinatorics/EditApproximation/Specification/RawBandPipelineFootprintBridges.lean @@ -0,0 +1,290 @@ +import OAI.Combinatorics.EditApproximation.Specification.RawBandPipelineBridges +import OAI.Combinatorics.EditApproximation.Specification.FootprintMain +import OAI.Combinatorics.EditApproximation.Definitions + +-- Expose the index expressions inside compiler-generated equality transports. +-- The resulting proof terms are checked by the kernel with the rest of this module. +open Lean Meta Elab Tactic in +elab "unfold_footprint_transports" : tactic => do + let env ← getEnv + let names := #[`OAI.EditApproximation.queryChargedFamilyTable, + `OAI.EditApproximation.queryChargedFamilyTableRawBand, + `OAI.EditApproximation.queryFamilyBoundedActive, + `OAI.EditApproximation.queryFamilyBoundedActiveRawBand, + `OAI.EditApproximation.queryChargedFamilyTableFootprint, + `OAI.EditApproximation.queryChargedFamilyTableFootprintRawBand] + let mut goal ← getMainGoal + for _ in [:16] do + let target ← goal.getType + let mut selected : Array Name := #[] + for n in target.getUsedConstants do + if let some ci := env.find? n then + if ci.type.getUsedConstants.any names.contains then + if ← isProp ci.type then + selected := selected.push n + if selected.isEmpty then break + goal ← goal.change (← deltaExpand target selected.contains (allowOpaque := true)) (checkDefEq := false) + replaceMainGoal [goal] + + +namespace OAI.EditApproximation + +universe u v + +private theorem footprintRanked_congr {κ : Type*} (rank : κ → ℕ) + (p q : (key : κ) → BitQuery {child : κ // rank child < rank key} BinaryFraction) + (hp : p = q) (a : ∀ key, BitQuery.Footprint (p key)) + (b : ∀ key, BitQuery.Footprint (q key)) (hab : HEq a b) + (bits : ℕ) (encode addressCells : κ → ℕ) (key : κ) (memory : BinaryMemo BinaryFraction) : + BitQuery.Footprint.rankedBitMemoCells rank p a bits encode addressCells key memory = + BitQuery.Footprint.rankedBitMemoCells rank q b bits encode addressCells key memory := by + cases hp + cases eq_of_heq hab + rfl + +private theorem queryLocalRefinementFootprintRawBand_heq : + HEq @queryLocalRefinementFootprintRawBand.{u, v} @queryLocalRefinementFootprint.{u, v} := by + unfold queryLocalRefinementFootprintRawBand queryLocalRefinementFootprint + unfold queryLocalRefinementRawBand queryLocalRefinement + rw [BinaryFraction.queryOnlineSelectWithWorkRawBand_eq, + BinaryFraction.queryGroupSelectWithWorkRawBand_eq] + simp only [ + BinaryFraction.queryOnlineSelectAllocationRawBand_eq, + BinaryFraction.queryGroupSelectAllocationRawBand_eq] + rfl +private theorem queryLocalRandomSourcesFootprintRawBand_heq : + HEq @queryLocalRandomSourcesFootprintRawBand.{u, v} @queryLocalRandomSourcesFootprint.{u, v} := by + have hp : @queryLocalRefinementRawBand.{u, v} = @queryLocalRefinement.{u, v} := queryLocalRefinementRawBand_eq + have hfp : HEq @queryLocalRefinementFootprintRawBand.{u, v} @queryLocalRefinementFootprint.{u, v} := queryLocalRefinementFootprintRawBand_heq + delta queryLocalRandomSourcesFootprintRawBand queryLocalRandomSourcesFootprint + delta queryLocalRandomSourcesRawBand queryLocalRandomSources + generalize hfr : @queryLocalRefinementFootprintRawBand.{u, v} = fr at * + generalize hfo : @queryLocalRefinementFootprint.{u, v} = fo at * + clear hfr hfo + generalize hpr : @queryLocalRefinementRawBand.{u, v} = pr at * + generalize hpo : @queryLocalRefinement.{u, v} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryLocalBandFootprintRawBand_heq : + HEq @queryLocalBandFootprintRawBand.{u, v} @queryLocalBandFootprint.{u, v} := by + have hp : @queryLocalRandomSourcesRawBand.{u, v} = @queryLocalRandomSources.{u, v} := queryLocalRandomSourcesRawBand_eq + have hfp : HEq @queryLocalRandomSourcesFootprintRawBand.{u, v} @queryLocalRandomSourcesFootprint.{u, v} := queryLocalRandomSourcesFootprintRawBand_heq + delta queryLocalBandFootprintRawBand queryLocalBandFootprint + delta queryLocalBandRawBand queryLocalBand + generalize hfr : @queryLocalRandomSourcesFootprintRawBand.{u, v} = fr at * + generalize hfo : @queryLocalRandomSourcesFootprint.{u, v} = fo at * + clear hfr hfo + generalize hpr : @queryLocalRandomSourcesRawBand.{u, v} = pr at * + generalize hpo : @queryLocalRandomSources.{u, v} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryLocalProgramFootprintRawBand_heq : + HEq @queryLocalProgramFootprintRawBand.{u, v} @queryLocalProgramFootprint.{u, v} := by + have hp : @queryLocalBandRawBand.{u, v} = @queryLocalBand.{u, v} := queryLocalBandRawBand_eq + have hfp : HEq @queryLocalBandFootprintRawBand.{u, v} @queryLocalBandFootprint.{u, v} := queryLocalBandFootprintRawBand_heq + delta queryLocalProgramFootprintRawBand queryLocalProgramFootprint + delta queryLocalProgramRawBand queryLocalProgram + generalize hfr : @queryLocalBandFootprintRawBand.{u, v} = fr at * + generalize hfo : @queryLocalBandFootprint.{u, v} = fo at * + clear hfr hfo + generalize hpr : @queryLocalBandRawBand.{u, v} = pr at * + generalize hpo : @queryLocalBand.{u, v} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryPhysicalRandomDataRequestFootprintRawBand_heq : + HEq @queryPhysicalRandomDataRequestFootprintRawBand.{u, v} @queryPhysicalRandomDataRequestFootprint.{u, v} := by + have hp : @queryLocalProgramRawBand.{u, v} = @queryLocalProgram.{u, v} := queryLocalProgramRawBand_eq + have hfp : HEq @queryLocalProgramFootprintRawBand.{u, v} @queryLocalProgramFootprint.{u, v} := queryLocalProgramFootprintRawBand_heq + delta queryPhysicalRandomDataRequestFootprintRawBand queryPhysicalRandomDataRequestFootprint + delta queryPhysicalRandomDataRequestRawBand queryPhysicalRandomDataRequest + generalize hfr : @queryLocalProgramFootprintRawBand.{u, v} = fr at * + generalize hfo : @queryLocalProgramFootprint.{u, v} = fo at * + clear hfr hfo + generalize hpr : @queryLocalProgramRawBand.{u, v} = pr at * + generalize hpo : @queryLocalProgram.{u, v} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryFamilyRefinementFootprintRawBand_heq : + HEq @queryFamilyRefinementFootprintRawBand.{u} @queryFamilyRefinementFootprint.{u} := by + have hp : @queryPhysicalRandomDataRequestRawBand.{0, u} = @queryPhysicalRandomDataRequest.{0, u} := queryPhysicalRandomDataRequestRawBand_eq + have hfp : HEq @queryPhysicalRandomDataRequestFootprintRawBand.{0, u} @queryPhysicalRandomDataRequestFootprint.{0, u} := queryPhysicalRandomDataRequestFootprintRawBand_heq + delta queryFamilyRefinementFootprintRawBand queryFamilyRefinementFootprint + delta queryFamilyRefinementRawBand queryFamilyRefinement + generalize hfr : @queryPhysicalRandomDataRequestFootprintRawBand.{0, u} = fr at * + generalize hfo : @queryPhysicalRandomDataRequestFootprint.{0, u} = fo at * + clear hfr hfo + generalize hpr : @queryPhysicalRandomDataRequestRawBand.{0, u} = pr at * + generalize hpo : @queryPhysicalRandomDataRequest.{0, u} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryFamilyActiveFootprintRawBand_heq : + HEq @queryFamilyActiveFootprintRawBand.{u} @queryFamilyActiveFootprint.{u} := by + have hp : @queryFamilyRefinementRawBand.{u} = @queryFamilyRefinement.{u} := queryFamilyRefinementRawBand_eq + have hfp : HEq @queryFamilyRefinementFootprintRawBand.{u} @queryFamilyRefinementFootprint.{u} := queryFamilyRefinementFootprintRawBand_heq + delta queryFamilyActiveFootprintRawBand queryFamilyActiveFootprint + delta queryFamilyActiveRawBand queryFamilyActive + generalize hfr : @queryFamilyRefinementFootprintRawBand.{u} = fr at * + generalize hfo : @queryFamilyRefinementFootprint.{u} = fo at * + clear hfr hfo + generalize hpr : @queryFamilyRefinementRawBand.{u} = pr at * + generalize hpo : @queryFamilyRefinement.{u} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryFamilyBoundedActiveFootprintRawBand_heq : + HEq @queryFamilyBoundedActiveFootprintRawBand.{u} @queryFamilyBoundedActiveFootprint.{u} := by + have hp : @queryFamilyActiveRawBand.{u} = @queryFamilyActive.{u} := queryFamilyActiveRawBand_eq + have hfp : HEq @queryFamilyActiveFootprintRawBand.{u} @queryFamilyActiveFootprint.{u} := queryFamilyActiveFootprintRawBand_heq + delta queryFamilyBoundedActiveFootprintRawBand queryFamilyBoundedActiveFootprint + delta queryFamilyBoundedActiveRawBand queryFamilyBoundedActive + generalize hfr : @queryFamilyActiveFootprintRawBand.{u} = fr at * + generalize hfo : @queryFamilyActiveFootprint.{u} = fo at * + clear hfr hfo + generalize hpr : @queryFamilyActiveRawBand.{u} = pr at * + generalize hpo : @queryFamilyActive.{u} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryChargedFamilyTableFootprintRawBand_heq : + HEq @queryChargedFamilyTableFootprintRawBand @queryChargedFamilyTableFootprint := by + have hp : @queryFamilyBoundedActiveRawBand.{0} = @queryFamilyBoundedActive.{0} := queryFamilyBoundedActiveRawBand_eq + have hfp : HEq @queryFamilyBoundedActiveFootprintRawBand.{0} @queryFamilyBoundedActiveFootprint.{0} := queryFamilyBoundedActiveFootprintRawBand_heq + delta queryChargedFamilyTableFootprintRawBand queryChargedFamilyTableFootprint + unfold_footprint_transports + delta queryChargedFamilyTableRawBand queryChargedFamilyTable + generalize hfr : @queryFamilyBoundedActiveFootprintRawBand.{0} = fr at * + generalize hfo : @queryFamilyBoundedActiveFootprint.{0} = fo at * + clear hfr hfo + generalize hpr : @queryFamilyBoundedActiveRawBand.{0} = pr at * + generalize hpo : @queryFamilyBoundedActive.{0} = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryChargedFamilyGlobalFootprintRawBand_heq : + HEq @queryChargedFamilyGlobalFootprintRawBand @queryChargedFamilyGlobalFootprint := by + have hp : @queryChargedFamilyTableRawBand = @queryChargedFamilyTable := queryChargedFamilyTableRawBand_eq + have hfp : HEq @queryChargedFamilyTableFootprintRawBand @queryChargedFamilyTableFootprint := queryChargedFamilyTableFootprintRawBand_heq + delta queryChargedFamilyGlobalFootprintRawBand queryChargedFamilyGlobalFootprint + delta queryChargedFamilyGlobalRawBand queryChargedFamilyGlobal + generalize hfr : @queryChargedFamilyTableFootprintRawBand = fr at * + generalize hfo : @queryChargedFamilyTableFootprint = fo at * + clear hfr hfo + generalize hpr : @queryChargedFamilyTableRawBand = pr at * + generalize hpo : @queryChargedFamilyTable = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem queryFamilyMemoRawFootprintRawBand_heq : + HEq @queryFamilyMemoRawFootprintRawBand @queryFamilyMemoRawFootprint := by + have hp : @queryChargedFamilyGlobalRawBand = @queryChargedFamilyGlobal := queryChargedFamilyGlobalRawBand_eq + have hfp : HEq @queryChargedFamilyGlobalFootprintRawBand @queryChargedFamilyGlobalFootprint := queryChargedFamilyGlobalFootprintRawBand_heq + delta queryFamilyMemoRawFootprintRawBand queryFamilyMemoRawFootprint + delta queryFamilyMemoRawRawBand queryFamilyMemoRaw + generalize hfr : @queryChargedFamilyGlobalFootprintRawBand = fr at * + generalize hfo : @queryChargedFamilyGlobalFootprint = fo at * + clear hfr hfo + generalize hpr : @queryChargedFamilyGlobalRawBand = pr at * + generalize hpo : @queryChargedFamilyGlobal = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +private theorem computedQueryMemoRawFootprintRawBand_heq : + HEq @computedQueryMemoRawFootprintRawBand @computedQueryMemoRawFootprint := by + have hp : @queryFamilyMemoRawRawBand = @queryFamilyMemoRaw := queryFamilyMemoRawRawBand_eq + have hfp : HEq @queryFamilyMemoRawFootprintRawBand @queryFamilyMemoRawFootprint := queryFamilyMemoRawFootprintRawBand_heq + delta computedQueryMemoRawFootprintRawBand computedQueryMemoRawFootprint + delta computedQueryMemoRawRawBand computedQueryMemoRaw + generalize hfr : @queryFamilyMemoRawFootprintRawBand = fr at * + generalize hfo : @queryFamilyMemoRawFootprint = fo at * + clear hfr hfo + generalize hpr : @queryFamilyMemoRawRawBand = pr at * + generalize hpo : @queryFamilyMemoRaw = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +theorem computedQueryMemoFootprintRawBand_heq (source target : List ℕ) (N : ℕ) + (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ) + (input : ComputedFamilyInput source target N) : + HEq (computedQueryMemoFootprintRawBand source target N occurrence symbolBits positionBits input) + (computedQueryMemoFootprint source target N occurrence symbolBits positionBits input) := by + have hp : @computedQueryMemoRawRawBand = @computedQueryMemoRaw := computedQueryMemoRawRawBand_eq + have hfp : HEq @computedQueryMemoRawFootprintRawBand @computedQueryMemoRawFootprint := computedQueryMemoRawFootprintRawBand_heq + delta computedQueryMemoFootprintRawBand computedQueryMemoFootprint + delta computedQueryMemoNormalizedRawBand computedQueryMemoNormalized + generalize hfr : @computedQueryMemoRawFootprintRawBand = fr at * + generalize hfo : @computedQueryMemoRawFootprint = fo at * + clear hfr hfo + generalize hpr : @computedQueryMemoRawRawBand = pr at * + generalize hpo : @computedQueryMemoRaw = po at * + have hp' : @pr = @po := by simpa only [hpr, hpo] using hp + clear hp hpr hpo + cases hp' + cases eq_of_heq hfp + rfl + +theorem computedQueryTemporaryCellsFootprintRawBand_eq (source target : List ℕ) (N : ℕ) + (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ) + (input : ComputedFamilyInput source target N) : + computedQueryTemporaryCellsFootprintRawBand source target N occurrence symbolBits positionBits input = + computedQueryTemporaryCellsFootprint source target N occurrence symbolBits positionBits input := by + unfold computedQueryTemporaryCellsFootprintRawBand computedQueryTemporaryCellsFootprint + apply footprintRanked_congr + · rw [computedQueryMemoNormalizedRawBand_eq] + · exact computedQueryMemoFootprintRawBand_heq source target N occurrence symbolBits positionBits input + +theorem integerAcceptedSpaceTermsFootprintRawBand_eq (source target : List ℤ) (N : ℕ) + (epsilon : BinaryFraction) + (input : ComputedFamilyInput (source.map integerSymbolCode) (target.map integerSymbolCode) N) : + integerAcceptedSpaceTermsFootprintRawBand source target N epsilon input = + integerAcceptedSpaceTermsFootprint source target N epsilon input := by + simp only [integerAcceptedSpaceTermsFootprintRawBand, integerAcceptedSpaceTermsFootprint, + computedQueryTemporaryCellsFootprintRawBand_eq, computedQueryMemoResultRawBand_eq, + integerFinalAllocationRawBand_eq] + +theorem integerBinarySpaceFootprintRawBand_eq (source target : List ℤ) (N : ℕ) (epsilon : BinaryFraction) + (outcome : ComputedFullOutcome (source.map integerSymbolCode) (target.map integerSymbolCode) N) : + integerBinarySpaceFootprintRawBand source target N epsilon outcome = + integerBinarySpaceFootprint source target N epsilon outcome := by + simp only [integerBinarySpaceFootprintRawBand, integerBinarySpaceFootprint, + integerAcceptedSpaceTermsFootprintRawBand_eq] + rfl + +end OAI.EditApproximation diff --git a/lean/OAI/Combinatorics/EditDistance/AlphabetLower.lean b/lean/OAI/Combinatorics/EditDistance/AlphabetLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..46924e91d26f43e7b5bd64639a087bbe6aa739de --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/AlphabetLower.lean @@ -0,0 +1,101 @@ +import OAI.Combinatorics.EditDistance.LowerBound +import OAI.Combinatorics.EditDistance.DistortionMonotonicity + +namespace OAI + +/-! +# Uniform lower bounds under binary alphabet embeddings +-/ + +namespace EditDistortion +universe u + +lemma coordinate_norm {X : Type u} [Fintype X] (x : X) : ‖coordinateEmbedding X x‖ = 1 := by + classical + change ‖lp.single (E := fun _ : ℕ => ℝ) 1 ((Fintype.equivFin X x).val) (1 : ℝ)‖ = 1 + rw [lp.norm_single (by norm_num)] + norm_num + +lemma coordinate_separation {X : Type u} [Fintype X] (x y : X) (hxy : x ≠ y) : + 1 ≤ ‖coordinateEmbedding X x-coordinateEmbedding X y‖ := by + classical + let e : X ↪ ℕ := (Fintype.equivFin X).toEmbedding.trans ⟨Fin.val,Fin.val_injective⟩ + have hne : e x ≠ e y := fun h => hxy (e.injective h) + have h := lp.norm_apply_le_norm (by norm_num : (1 : ENNReal) ≠ 0) + (coordinateEmbedding X x - coordinateEmbedding X y) (e x) + have he : (coordinateEmbedding X x-coordinateEmbedding X y) (e x) = 1 := by + change lp.single (E := fun _ : ℕ => ℝ) 1 (e x) (1 : ℝ) (e x) - + lp.single (E := fun _ : ℕ => ℝ) 1 (e y) (1 : ℝ) (e x) = 1 + rw [lp.single_apply_self,lp.single_apply_ne (E := fun _ : ℕ => ℝ) 1 (e y) (1 : ℝ) hne] + norm_num + simpa only [he,norm_one] using h + +theorem alphabet_coarse_upper (Alpha : Type u) [Fintype Alpha] [Nonempty Alpha] + {d : ℕ} (hd : 1 ≤ d) : E Alpha d ≤ 2*(d : ℝ) := by + classical + let : Finite (Words Alpha d) := finite_words Alpha d + let : Fintype (Words Alpha d) := Fintype.ofFinite _ + let x : Words Alpha d := ⟨[],by simp⟩ + let y : Words Alpha d := ⟨[Classical.arbitrary Alpha],by simpa using hd⟩ + let : Nontrivial (Words Alpha d) := ⟨⟨x,y,by simp [x,y]⟩⟩ + let f := coordinateEmbedding (Words Alpha d) + apply (leastDistortion_le _ (fun v => edit_real_diag v.val) + (fun v w h => edit_real_pos v.val w.val (fun hh => h (Subtype.ext hh))) f).trans + apply distortion_le_of_bounds _ + (fun v w h => edit_real_pos v.val w.val (fun hh => h (Subtype.ext hh))) f (by norm_num) + · intro v w + by_cases h : v = w + · subst w + simp [edit_real_diag] + · have hp : (1 : ℝ) ≤ edit v.val w.val := by + exact_mod_cast Nat.one_le_iff_ne_zero.mpr + (mt (cost_eq_zero_iff (s := true)).mp (fun hh => h (Subtype.ext hh))) + have hh := norm_sub_le (f v) (f w) + have hv : ‖f v‖ = 1 := coordinate_norm v + have hw : ‖f w‖ = 1 := coordinate_norm w + nlinarith + · intro v w + by_cases h : v = w + · subst w + simp [edit_real_diag] + · have hs : (1 : ℝ) ≤ ‖f v-f w‖ := coordinate_separation v w h + have he : (edit v.val w.val : ℝ) ≤ d := by + exact_mod_cast (edit_le_max_length v.val w.val).trans + (max_le v.property w.property) + nlinarith [Nat.cast_nonneg (α := ℝ) d] + +lemma alphabet_values_bddAbove {d : ℕ} (hd : 1 ≤ d) : + BddAbove {r : ℝ | ∃ n : ℕ, 2 ≤ n ∧ r = E (Fin n) d} := by + refine ⟨2*(d : ℝ),?_⟩ + rintro r ⟨n,hn,rfl⟩ + let : NeZero n := ⟨by omega⟩ + exact alphabet_coarse_upper (Fin n) hd + +lemma alphabet_le_sup {d n : ℕ} (hd : 1 ≤ d) (hn : 2 ≤ n) : E (Fin n) d ≤ alphabetSup d := + le_csSup (alphabet_values_bddAbove hd) ⟨n,hn,rfl⟩ + +end EditDistortion + +namespace EditLower + +universe u + +open EditDistortion + +theorem all_lower_clauses : ∃ c : ℝ, 0 < c ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → + (∀ (Alpha : Type u) [Fintype Alpha], 2 ≤ Fintype.card Alpha → + exponentScale c d ≤ E Alpha d) ∧ BinaryWitness c d ∧ + exponentScale c d ≤ alphabetSup d := by + obtain ⟨D,hD⟩ := Filter.eventually_atTop.mp eventually_length_witness + refine ⟨1/1200,by norm_num,max D 1,?_⟩ + intro d hd + obtain ⟨n,hn,S,hfin,hne,hnt,hlen,hs⟩ := hD d ((le_max_left _ _).trans hd) + refine ⟨?_,⟨n,hn,S,hfin,hne,hlen,hs⟩,?_⟩ + · intro Alpha inst hAlpha + exact hs.trans (binary_subset_lower Alpha hAlpha hn S hfin hnt hlen) + · exact (hs.trans (binary_subset_lower (Fin 2) (by simp) hn S hfin hnt hlen)).trans + (alphabet_le_sup ((le_max_right _ _).trans hd) (by omega)) + +end EditLower + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/AlphabetSupremum.lean b/lean/OAI/Combinatorics/EditDistance/AlphabetSupremum.lean new file mode 100644 index 0000000000000000000000000000000000000000..74d85bb62be85ae14d46b183b7e4dbdfd3b01352 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/AlphabetSupremum.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.EditDistance.DistortionMonotonicity + +namespace OAI + +/-! +# Alphabet equivalences and universe-independent suprema +-/ + +namespace EditDistortion +universe u v + +lemma E_le_of_alphabet_embedding (A : Type u) (B : Type v) [Fintype A] [Fintype B] + [Nonempty A] (a : A ↪ B) {d : ℕ} (hd : 1 ≤ d) : E A d ≤ E B d := by + classical + let : Finite (Words A d) := finite_words A d + let : Finite (Words B d) := finite_words B d + let : Fintype (Words A d) := Fintype.ofFinite _ + let : Fintype (Words B d) := Fintype.ofFinite _ + let x : Words A d := ⟨[],by simp⟩ + let y : Words A d := ⟨[Classical.arbitrary A],by simpa using hd⟩ + let : Nontrivial (Words A d) := ⟨⟨x,y,by simp [x,y]⟩⟩ + let e : Words A d ↪ Words B d := + ⟨fun z => ⟨z.val.map a,by simpa only [List.length_map] using z.property⟩, + fun z w h => Subtype.ext ((List.map_inj_right a.injective).mp (congrArg Subtype.val h))⟩ + let : Nontrivial (Words B d) := by + obtain ⟨z,w,hzw⟩ := exists_pair_ne (Words A d) + exact ⟨⟨e z,e w,fun h => hzw (e.injective h)⟩⟩ + apply leastDistortion_mono _ _ + (fun z => edit_real_diag z.val) + (fun z w h => edit_real_pos z.val w.val (fun hh => h (Subtype.ext hh))) + (fun z => edit_real_diag z.val) + (fun z w h => edit_real_pos z.val w.val (fun hh => h (Subtype.ext hh))) e + intro z w + exact_mod_cast cost_map_eq_of_leftInverse (s := true) a (Function.invFun a) + (Function.leftInverse_invFun a.injective) z.val w.val + +lemma E_equiv (A : Type u) (B : Type v) [Fintype A] [Fintype B] + [Nonempty A] [Nonempty B] (e : A ≃ B) {d : ℕ} (hd : 1 ≤ d) : E A d = E B d := + le_antisymm (E_le_of_alphabet_embedding A B e.toEmbedding hd) + (E_le_of_alphabet_embedding B A e.symm.toEmbedding hd) + +theorem alphabet_values_eq_all {d : ℕ} (hd : 1 ≤ d) : + {r : ℝ | ∃ (A : Type u) (i : Fintype A), 2 ≤ @Fintype.card A i ∧ r = E A d} = + {r : ℝ | ∃ n : ℕ, 2 ≤ n ∧ r = E (Fin n) d} := by + ext r + constructor + · rintro ⟨A,i,hA,rfl⟩ + let := i + let : Nonempty A := Fintype.card_pos_iff.mp (by omega) + let : NeZero (Fintype.card A) := ⟨by omega⟩ + exact ⟨Fintype.card A,hA,E_equiv A (Fin (Fintype.card A)) (Fintype.equivFin A) hd⟩ + · rintro ⟨n,hn,rfl⟩ + let : NeZero n := ⟨by omega⟩ + refine ⟨ULift.{u} (Fin n),inferInstance,by simpa using hn,?_⟩ + exact (E_equiv (ULift.{u} (Fin n)) (Fin n) Equiv.ulift hd).symm + +theorem alphabetSup_eq_all {d : ℕ} (hd : 1 ≤ d) : + alphabetSup d = sSup {r : ℝ | ∃ (A : Type u) (i : Fintype A), + 2 ≤ @Fintype.card A i ∧ r = E A d} := by + rw [alphabet_values_eq_all hd] + rfl + +end EditDistortion + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/BinaryCode.lean b/lean/OAI/Combinatorics/EditDistance/BinaryCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..323de8b2a3c480bdc97645d0d5fd05f24c8db2bd --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/BinaryCode.lean @@ -0,0 +1,170 @@ +import OAI.Combinatorics.EditDistance.DelimiterAlignment + +namespace OAI + +/-! +# Binary delimiter codes and padding +-/ + +namespace EditCode +open EditDistortion +variable {A : Type*} {t : ℕ} + +def width (t : ℕ) : ℕ := 2 * t + 3 + +def bit (label : A → Fin t → Bool) (a : A) (r : ℕ) : Bool := + if r < 2 then true else + if h : r % 2 = 1 ∧ r / 2 - 1 < t then label a ⟨r / 2 - 1,h.2⟩ else false + +def block (label : A → Fin t → Bool) (a : A) : List Bool := + List.ofFn (fun r : Fin (width t) => bit label a r) + +def encode (label : A → Fin t → Bool) (x : List A) : List Bool := x.flatMap (block label) + +def padded (label : A → Fin t → Bool) (x : List A) (r : ℕ) : List Bool := + encode label x ++ List.replicate r false + +@[simp] lemma block_length (label : A → Fin t → Bool) (a : A) : + (block label a).length = width t := List.length_ofFn + +@[simp] lemma width_pos : 0 < width t := by unfold width; omega + +@[simp] lemma encode_length (label : A → Fin t → Bool) (x : List A) : + (encode label x).length = width t * x.length := by + induction x with + | nil => simp [encode] + | cons a x ih => simp_all [encode, Nat.mul_add, Nat.add_comm] + +@[simp] lemma padded_length (label : A → Fin t → Bool) (x : List A) (r : ℕ) : + (padded label x r).length = width t * x.length + r := by simp [padded] + +@[simp] lemma bit_zero (label : A → Fin t → Bool) (a : A) : bit label a 0 = true := by simp [bit] +@[simp] lemma bit_one (label : A → Fin t → Bool) (a : A) : bit label a 1 = true := by simp [bit] + +lemma bit_label (label : A → Fin t → Bool) (a : A) (i : Fin t) : + bit label a (2 * i.val + 3) = label a i := by + have hm : (2 * i.val + 3) % 2 = 1 := by omega + have hd : (2 * i.val + 3) / 2 - 1 = i.val := by omega + simp [bit, show ¬2*i.val+3<2 by omega, hm, hd] + +lemma bit_even (label : A → Fin t → Bool) (a : A) {r : ℕ} + (hr : 2 ≤ r) (he : r % 2 = 0) : bit label a r = false := by + simp [bit,show ¬r<2 by omega,he] + +lemma bit_last (label : A → Fin t → Bool) (a : A) : + bit label a (width t - 1) = false := by + apply bit_even + · unfold width; omega + · unfold width; omega + +lemma bit_consecutive (label : A → Fin t → Bool) {a : A} {r : ℕ} + (h₁ : bit label a r = true) (h₂ : bit label a (r+1) = true) : r = 0 := by + by_contra h + by_cases he : r % 2 = 0 + · have hr : 2 ≤ r := by omega + rw [bit_even label a hr he] at h₁ + cases h₁ + · have he : (r+1)%2=0 := by omega + rw [bit_even label a (by omega) he] at h₂ + cases h₂ + +lemma encode_get_block (label : A → Fin t → Bool) (x : List A) + (i : Fin x.length) (r : Fin (width t)) : + (encode label x)[width t * i.val + r.val]'(by + rw [encode_length] + have hm := Nat.mul_le_mul_left (width t) i.isLt + simp only [Nat.mul_succ] at hm + have := r.isLt + omega) = bit label (x.get i) r := by + induction x with + | nil => exact Fin.elim0 i + | cons a x ih => + by_cases hi : i.val = 0 + · simp only [encode, List.flatMap_cons] + rw [List.getElem_append_left (by simp [hi])] + simp [block,hi,List.get_eq_getElem] + · let j : Fin x.length := ⟨i.val-1,by simpa only [List.length_cons] using (show i.val-1 l[2*i.val+3]?) he + simp only [block, List.getElem?_ofFn] at hv + simp only [dite_eq_left hir] at hv + simpa only [bit_label, Option.some.injEq] using hv + +end EditCode + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/BinaryEmbedding.lean b/lean/OAI/Combinatorics/EditDistance/BinaryEmbedding.lean new file mode 100644 index 0000000000000000000000000000000000000000..6499d02d989c20f3936437d0ca2fe9bdf4a1de0c --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/BinaryEmbedding.lean @@ -0,0 +1,92 @@ +import OAI.Combinatorics.EditDistance.BlockAlignment + +namespace OAI + +/-! +# Fixed-length binary embeddings with unrestricted edit distance +-/ + +namespace EditDistortion +variable {A B : Type*} + +lemma Script.flatMap {n w : ℕ} {x y : List A} (h : Script false n x y) + (c : A → List B) (hc : ∀ a, (c a).length = w) : + Script false (w*n) (x.flatMap c) (y.flatMap c) := by + induction h with + | nil x => simpa using Script.nil (substitutions := false) (x.flatMap c) + | @cons n x y z first rest ih => + have he : Script false w (x.flatMap c) (y.flatMap c) := by + cases first with + | insert p q a => + have h := ((Script.to_nil (s := false) (c a)).symm.append_left (p.flatMap c)).append_right (q.flatMap c) + simpa only [hc,List.append_nil,List.flatMap_append,List.flatMap_cons,List.append_assoc] using h + | delete p q a => + have h := ((Script.to_nil (s := false) (c a)).append_left (p.flatMap c)).append_right (q.flatMap c) + simpa only [hc,List.append_nil,List.flatMap_append,List.flatMap_cons,List.append_assoc] using h + | substitute hf => cases hf + simpa only [Nat.mul_add,Nat.mul_one,Nat.add_comm] using he.trans ih + +lemma indel_flatMap_le (c : A → List B) (w : ℕ) (hc : ∀ a, (c a).length = w) (x y : List A) : + indel (x.flatMap c) (y.flatMap c) ≤ w * indel x y := + cost_le ((cost_spec (s := false) x y).flatMap c hc) + +lemma indel_replicate_le (a : A) (r s : ℕ) : + indel (List.replicate r a) (List.replicate s a) ≤ (r-s)+(s-r) := by + by_cases h : r ≤ s + · have hs : (List.replicate r a).Sublist (List.replicate s a) := (List.replicate_sublist_replicate a).mpr h + have he := (Script.of_sublist hs).symm + have hcost := cost_le he + simpa only [cost,indel,List.length_replicate,Nat.sub_eq_zero_of_le h,Nat.zero_add] using hcost + · have hs : (List.replicate s a).Sublist (List.replicate r a) := (List.replicate_sublist_replicate a).mpr (by omega) + have hcost := cost_le (Script.of_sublist hs) + simpa only [cost,indel,List.length_replicate,Nat.sub_eq_zero_of_le (show s ≤ r by omega),Nat.add_zero] using hcost + +end EditDistortion + +namespace EditCode +open EditDistortion +variable {A : Type*} {t : ℕ} + +theorem indel_code_upper (label : A → Fin t → Bool) (x y : List A) : + indel (encode label x) (encode label y) ≤ width t * indel x y := + indel_flatMap_le (block label) (width t) (block_length label) x y + +def fixed (label : A → Fin t → Bool) (D : ℕ) (x : List A) : List Bool := + padded label x (width t * (D-x.length)) + +@[simp] lemma fixed_length (label : A → Fin t → Bool) (D : ℕ) (x : List A) (hx : x.length ≤ D) : + (fixed label D x).length = width t * D := by + simp only [fixed,padded_length,←Nat.mul_add,Nat.add_sub_of_le hx] + +theorem indel_fixed_upper (label : A → Fin t → Bool) (D : ℕ) (x y : List A) + (hx : x.length ≤ D) (hy : y.length ≤ D) : + indel (fixed label D x) (fixed label D y) ≤ 2 * width t * indel x y := by + have h := cost_append_le (s := false) (encode label x) (encode label y) + (List.replicate (width t*(D-x.length)) false) (List.replicate (width t*(D-y.length)) false) + have hr := indel_replicate_le false (width t*(D-x.length)) (width t*(D-y.length)) + have hc := indel_code_upper label x y + have hl := cost_length_bounds (s := false) x y + change x.length ≤ y.length + indel x y ∧ y.length ≤ x.length + indel x y at hl + have hd : width t*(D-x.length)-width t*(D-y.length) + + (width t*(D-y.length)-width t*(D-x.length)) ≤ width t*indel x y := by + rw [←Nat.mul_sub_left_distrib,←Nat.mul_sub_left_distrib,←Nat.mul_add] + apply Nat.mul_le_mul_left + omega + change indel (fixed label D x) (fixed label D y) ≤ + indel (encode label x) (encode label y) + + indel (List.replicate (width t*(D-x.length)) false) (List.replicate (width t*(D-y.length)) false) at h + nlinarith + +end EditCode + +namespace EditCode +variable (A : Type*) [Fintype A] + +noncomputable def labels : A ↪ (Fin (Nat.clog 2 (Fintype.card A)) → Bool) := + Classical.choice (Function.Embedding.nonempty_of_card_le (by + simpa only [Fintype.card_fun,Fintype.card_fin,Fintype.card_bool] using + Nat.le_pow_clog (by norm_num : 1 < 2) (Fintype.card A))) + +end EditCode + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/BlockAlignment.lean b/lean/OAI/Combinatorics/EditDistance/BlockAlignment.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b9bcf276b1dfe86923ba72e67a776a97fe6a56b --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/BlockAlignment.lean @@ -0,0 +1,170 @@ +import OAI.Combinatorics.EditDistance.BinaryCode +import OAI.Combinatorics.EditDistance.RowSeparation + +namespace OAI + +/-! +# Contraction of arbitrary bit alignments to letter blocks +-/ + +namespace EditCode +open EditDistortion +open scoped BigOperators +attribute [local instance] Classical.propDecidable +variable {A : Type*} {t k : ℕ} + +def BlockPair (f g : Fin k → ℕ) (w i j : ℕ) : Prop := + ∀ r : ℕ, r < w → ∃ a : Fin k, f a = w*i+r ∧ g a = w*j+r + +lemma BlockPair.symm {f g : Fin k → ℕ} {w i j : ℕ} (h : BlockPair f g w i j) : + BlockPair g f w j i := by + intro r hr + obtain ⟨a,ha,hb⟩ := h r hr + exact ⟨a,hb,ha⟩ + +lemma BlockPair.span {f g : Fin k → ℕ} {w i j : ℕ} (h : BlockPair f g w i j) : + BlockSpan f g w i := ⟨w*j,h⟩ + +lemma pair_strict {f g : Fin k → ℕ} {w i j i' j' : ℕ} + (hf : StrictMono f) (hg : StrictMono g) (hw : 0 < w) + (h : BlockPair f g w i j) (h' : BlockPair f g w i' j') (hi : i < i') : j < j' := by + obtain ⟨a,ha,hga⟩ := h 0 hw + obtain ⟨b,hb,hgb⟩ := h' 0 hw + have hab : a < b := hf.lt_iff_lt.mp (by simpa only [ha,hb,Nat.add_zero] using Nat.mul_lt_mul_of_pos_left hi hw) + have := hg hab + nlinarith + +lemma pair_unique {f g : Fin k → ℕ} {w i j j' : ℕ} + (hf : Function.Injective f) (hw : 0 < w) + (h : BlockPair f g w i j) (h' : BlockPair f g w i j') : j = j' := by + obtain ⟨a,ha,hga⟩ := h 0 hw + obtain ⟨b,hb,hgb⟩ := h' 0 hw + have hab : a = b := hf (ha.trans hb.symm) + rw [hab] at hga + nlinarith + +lemma span_pair (label : A → Fin t → Bool) (x y : List A) (r s : ℕ) + {f g : Fin k → ℕ} + (hf : ∀ a, f a < (padded label x r).length) + (hg : ∀ a, g a < (padded label y s).length) + (heq : ∀ a, (padded label x r)[f a]'(hf a) = (padded label y s)[g a]'(hg a)) + (i : Fin x.length) (hi : BlockSpan f g (width t) i.val) : + ∃ j : Fin y.length, BlockPair f g (width t) i.val j.val := by + obtain ⟨q,hq⟩ := hi + obtain ⟨a,ha,hga⟩ := hq 0 width_pos + obtain ⟨b,hb,hgb⟩ := hq 1 (by unfold width; omega) + have hqLen : q+1 < (padded label y s).length := by rw [←hgb]; exact hg b + have hq₀ : (padded label y s)[q]'(by omega) = true := by + have he := heq a + have hv := padded_get_block label x r i ⟨0,width_pos⟩ + simp only [bit_zero,Nat.add_zero] at hv + simpa only [ha,hga,Nat.add_zero,hv] using he.symm + have hq₁ : (padded label y s)[q+1] = true := by + have he := heq b + have hv := padded_get_block label x r i ⟨1,by unfold width; omega⟩ + simp only [bit_one] at hv + simpa only [hb,hgb,hv] using he.symm + obtain ⟨j,hj⟩ := padded_delimiter label y s q hqLen hq₀ hq₁ + refine ⟨j,?_⟩ + intro a ha + simpa only [hj] using hq a ha + +lemma pair_letters (label : A → Fin t → Bool) (hinj : Function.Injective label) + (x y : List A) (r s : ℕ) {f g : Fin k → ℕ} + (hf : ∀ a, f a < (padded label x r).length) + (hg : ∀ a, g a < (padded label y s).length) + (heq : ∀ a, (padded label x r)[f a]'(hf a) = (padded label y s)[g a]'(hg a)) + (i : Fin x.length) (j : Fin y.length) (h : BlockPair f g (width t) i.val j.val) : + x.get i = y.get j := by + apply hinj + funext v + have hv : 2*v.val+3 BlockSpan f g (width t) i.val) + let B := {i : Fin x.length // BlockSpan f g (width t) i.val} + let C := {j : Fin y.length // BlockSpan g f (width t) j.val} + have hpair (i : B) : ∃ j : Fin y.length, BlockPair f g (width t) i.val j.val := + span_pair label x y r s hfB hgB heq i.val i.property + let next (i : B) : Fin y.length := (hpair i).choose + have next_pair (i : B) : BlockPair f g (width t) i.val (next i).val := (hpair i).choose_spec + let e : Fin K.card ↪o Fin x.length := K.orderEmbOfFin rfl + have he (i : Fin K.card) : BlockSpan f g (width t) (e i).val := + (Finset.mem_filter.mp (K.orderEmbOfFin_mem rfl i)).2 + let q (i : Fin K.card) : Fin y.length := next ⟨e i,he i⟩ + have hq : StrictMono q := by + intro i j hij + exact pair_strict hf hg width_pos (next_pair ⟨e i,he i⟩) (next_pair ⟨e j,he j⟩) + (e.strictMono hij) + have hletter : ∀ i, x.get (e i) = y.get (q i) := by + intro i + exact pair_letters label hinj x y r s hfB hgB heq _ _ (next_pair ⟨e i,he i⟩) + have hcost := indel_le_of_matching x.get y.get e (OrderEmbedding.ofStrictMono q hq) hletter + simp only [List.ofFn_get] at hcost + have hback (j : C) : ∃ i : Fin x.length, BlockPair g f (width t) j.val i.val := + span_pair label y x s r hgB hfB (fun a => (heq a).symm) j.val j.property + let back (j : C) : B := ⟨(hback j).choose,(hback j).choose_spec.symm.span⟩ + have hbackinj : Function.Injective back := by + intro j j' he + have hh : (hback j).choose.val = (hback j').choose.val := + congrArg (fun i : B => i.val.val) he + apply Subtype.ext + apply Fin.ext + apply pair_unique hf.injective width_pos (hback j).choose_spec.symm + rw [hh] + exact (hback j').choose_spec.symm + have hcard := Fintype.card_le_of_injective back hbackinj + have hcard' : (Finset.univ.filter (fun j : Fin y.length => BlockSpan g f (width t) j.val)).card ≤ K.card := by + simpa only [B,C,Fintype.card_subtype,K] using hcard + have hbadX := bad_blocks_le_loss hf hg width_pos hfB hgB + (show width t * x.length ≤ (padded label x r).length by simp) + have hbadY := bad_blocks_le_loss hg hf width_pos hgB hfB + (show width t * y.length ≤ (padded label y s).length by simp) + have hsplitX := Finset.card_filter_add_card_filter_not (s := Finset.univ) + (fun i : Fin x.length => BlockSpan f g (width t) i.val) + have hsplitY := Finset.card_filter_add_card_filter_not (s := Finset.univ) + (fun j : Fin y.length => BlockSpan g f (width t) j.val) + simp only [Finset.card_univ,Fintype.card_fin] at hsplitX hsplitY + change K.card + _ = _ at hsplitX + omega + +theorem indel_code_lower (label : A → Fin t → Bool) (hinj : Function.Injective label) + (x y : List A) (r s : ℕ) : + indel x y ≤ 2 * indel (padded label x r) (padded label y s) := by + obtain ⟨z,hx,hy,hcost⟩ := indel_matching (padded label x r) (padded label y s) + obtain ⟨f,hf⟩ := List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp hx + obtain ⟨g,hg⟩ := List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp hy + have h := letter_loss_le label hinj x y r s + (f := fun a => (f a).val) (g := fun a => (g a).val) + (fun _ _ h => f.strictMono h) (fun _ _ h => g.strictMono h) + (fun a => (f a).isLt) (fun a => (g a).isLt) + (fun a => (hf a).symm.trans (hg a)) + have hzX := hx.length_le + have hzY := hy.length_le + have he : (padded label x r).length-z.length + ((padded label y s).length-z.length) = + (padded label x r).length+(padded label y s).length-2*z.length := by omega + rwa [he,←hcost] at h + +end EditCode + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/CutModels.lean b/lean/OAI/Combinatorics/EditDistance/CutModels.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b49228fa20d16e7e8c3b7cfe85dbe04342e4268 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/CutModels.lean @@ -0,0 +1,166 @@ +import OAI.Combinatorics.EditDistance.MeanHistograms + +namespace OAI + +/-! +# Finite weighted cuts and histogram lifts +-/ + +namespace EditCutModel + +universe u v + +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset + +noncomputable def sep (a b : Bool) : ℝ := if a = b then 0 else 1 + +structure Model (X : Type u) where + Index : Type + finiteIndex : Fintype Index + weight : Index → ℝ + nonneg : ∀ i, 0 ≤ weight i + cut : Index → X → Bool + +attribute [instance] Model.finiteIndex + +noncomputable def Model.dist {X : Type u} (M : Model X) (x y : X) : ℝ := + ∑ i, M.weight i * sep (M.cut i x) (M.cut i y) + +lemma Model.dist_nonneg {X : Type u} (M : Model X) (x y : X) : 0 ≤ M.dist x y := by + apply sum_nonneg + intro i _ + apply mul_nonneg (M.nonneg i) + unfold sep + split <;> norm_num + +@[simp] lemma Model.dist_self {X : Type u} (M : Model X) (x : X) : M.dist x x = 0 := by + simp [Model.dist,sep] + +lemma Model.dist_symm {X : Type u} (M : Model X) (x y : X) : M.dist x y = M.dist y x := by + unfold Model.dist + apply sum_congr rfl + intro i _ + simp [sep,eq_comm] + +lemma Model.dist_triangle {X : Type u} (M : Model X) (x y z : X) : + M.dist x z ≤ M.dist x y+M.dist y z := by + unfold Model.dist + rw [←sum_add_distrib] + apply sum_le_sum + intro i _ + rw [←mul_add] + apply mul_le_mul_of_nonneg_left ?_ (M.nonneg i) + cases M.cut i x <;> cases M.cut i y <;> cases M.cut i z <;> norm_num [sep] + +noncomputable def Model.pullback {X : Type u} {Y : Type v} (M : Model X) (f : Y → X) : Model Y where + Index := M.Index + finiteIndex := M.finiteIndex + weight := M.weight + nonneg := M.nonneg + cut i y := M.cut i (f y) + +lemma Model.pullback_dist {X : Type u} {Y : Type v} (M : Model X) (f : Y → X) (x y : Y) : + (M.pullback f).dist x y = M.dist (f x) (f y) := rfl + +noncomputable def Model.scale {X : Type u} (M : Model X) (a : ℝ) (ha : 0 ≤ a) : Model X where + Index := M.Index + finiteIndex := M.finiteIndex + weight i := a*M.weight i + nonneg i := mul_nonneg ha (M.nonneg i) + cut := M.cut + +lemma Model.scale_dist {X : Type u} (M : Model X) (a : ℝ) (ha : 0 ≤ a) (x y : X) : + (M.scale a ha).dist x y = a*M.dist x y := by + simp only [Model.dist,Model.scale,mul_assoc,mul_sum] + rfl + +noncomputable def Model.total {X : Type u} {J : Type} [Fintype J] (M : J → Model X) : Model X where + Index := (j : J) × (M j).Index + finiteIndex := inferInstance + weight i := (M i.1).weight i.2 + nonneg i := (M i.1).nonneg i.2 + cut i x := (M i.1).cut i.2 x + +lemma Model.total_dist {X : Type u} {J : Type} [Fintype J] (M : J → Model X) (x y : X) : + (Model.total M).dist x y = ∑ j, (M j).dist x y := by + change (∑ i : (j : J) × (M j).Index, (M i.1).weight i.2 * sep ((M i.1).cut i.2 x) ((M i.1).cut i.2 y)) = _ + rw [Fintype.sum_sigma] + rfl + +lemma initial_cut_sum {s a : ℕ} (ha : a ≤ s) : + (∑ t : Fin s, if t.val < a then (1 : ℝ) else 0) = (a : ℝ) := by + simp only [sum_boole,Fin.card_filter_val_lt,min_eq_right ha] + +theorem threshold_sum {s a b : ℕ} (ha : a ≤ s) (hb : b ≤ s) : + (∑ t : Fin s, sep (decide (t.val < a)) (decide (t.val < b))) = |(a : ℝ)-(b : ℝ)| := by + wlog hab : a ≤ b generalizing a b + · rw [abs_sub_comm] + calc + _ = ∑ t : Fin s, sep (decide (t.val < b)) (decide (t.val < a)) := by + apply sum_congr rfl + intro t _ + simp only [sep,eq_comm] + _ = _ := this hb ha (by omega) + have he (t : Fin s) : sep (decide (t.val < a)) (decide (t.val < b)) = + (if t.val < b then (1 : ℝ) else 0)-(if t.val < a then (1 : ℝ) else 0) := by + by_cases hta : t.val < a <;> by_cases htb : t.val < b <;> simp [sep,hta,htb]; omega + simp_rw [he] + rw [sum_sub_distrib,initial_cut_sum hb,initial_cut_sum ha,abs_of_nonpos (sub_nonpos.mpr (Nat.cast_le.mpr hab))] + ring + +end EditCutModel + +namespace EditCutModel +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset + +noncomputable def countNat {J K : Type*} [Fintype J] (f : J → K) (z : K) : ℕ := + (univ.filter (fun j => f j = z)).card + +lemma count_cast {J K : Type*} [Fintype J] (f : J → K) (z : K) : + (countNat f z : ℝ) = EditCutHash.count f z := by + simp only [countNat,EditCutHash.count,EditCutHash.hit,sum_boole] + +lemma count_bound {J K : Type*} [Fintype J] (f : J → K) (z : K) : + countNat f z ≤ Fintype.card J := card_filter_le _ _ + +noncomputable def Model.histogram {X : Type*} (M : Model X) (s : ℕ) (a : ℝ) (ha : 0 ≤ a) : + Model (Fin s → X) where + Index := (M.Index → Bool) × (M.Index → Bool) × Fin s + finiteIndex := inferInstance + weight i := EditCutHash.probability M.weight a i.1 + nonneg i := EditCutHash.probability_nonneg M.nonneg ha i.1 + cut i f := decide (i.2.2.val < countNat (fun j : Fin s => EditCutHash.key M.cut i.1 (f j)) i.2.1) + +lemma Model.histogram_dist {X : Type*} (M : Model X) (s : ℕ) (a : ℝ) (ha : 0 ≤ a) + (f g : Fin s → X) : + (M.histogram s a ha).dist f g = EditCutHash.meanHistogram M.weight a M.cut f g := by + change (∑ i : (M.Index → Bool) × (M.Index → Bool) × Fin s, + EditCutHash.probability M.weight a i.1 * sep + (decide (i.2.2.val < countNat (fun j : Fin s => EditCutHash.key M.cut i.1 (f j)) i.2.1)) + (decide (i.2.2.val < countNat (fun j : Fin s => EditCutHash.key M.cut i.1 (g j)) i.2.1))) = _ + rw [Fintype.sum_prod_type] + apply sum_congr rfl + intro h _ + rw [Fintype.sum_prod_type] + simp_rw [←mul_sum] + congr 1 + apply sum_congr rfl + intro z _ + rw [threshold_sum (by simpa using count_bound (fun j => EditCutHash.key M.cut h (f j)) z) + (by simpa using count_bound (fun j => EditCutHash.key M.cut h (g j)) z),count_cast,count_cast] + +lemma Model.distance_eq {X : Type*} (M : Model X) (x y : X) : + EditCutHash.distance M.weight M.cut x y = M.dist x y := by + unfold EditCutHash.distance Model.dist + apply sum_congr rfl + intro i _ + congr 1 + cases M.cut i x <;> cases M.cut i y <;> norm_num [sep,EditCutHash.sep] + +end EditCutModel + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/CutRealization.lean b/lean/OAI/Combinatorics/EditDistance/CutRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..88fdaabc7cfd04a72117402814d7cf80d90bdc52 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/CutRealization.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.EditDistance.CutModels +import OAI.Combinatorics.EditDistance.DirectSums + +namespace OAI + +/-! +# Realization of all finite-cut distances by one summable vector map +-/ + +namespace EditCutModel +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset + +noncomputable def Model.vector {X : Type*} (M : Model X) (x : X) : EditL1.L1 := + EditL1.pack (fun j : Option M.Index => match j with + | none => 0 + | some i => lp.single (E := fun _ : ℕ => ℝ) 1 0 (if M.cut i x then M.weight i else 0)) + +lemma singleton_sub_norm (a b : ℝ) : + ‖lp.single (E := fun _ : ℕ => ℝ) 1 0 a - lp.single (E := fun _ : ℕ => ℝ) 1 0 b‖ = |a-b| := by + have he : lp.single (E := fun _ : ℕ => ℝ) 1 0 a - lp.single (E := fun _ : ℕ => ℝ) 1 0 b = + lp.single (E := fun _ : ℕ => ℝ) 1 0 (a-b) := by + ext i + change (lp.single (E := fun _ : ℕ => ℝ) 1 0 a) i - (lp.single (E := fun _ : ℕ => ℝ) 1 0 b) i = (lp.single (E := fun _ : ℕ => ℝ) 1 0 (a-b)) i + by_cases hi : i = 0 + · subst i + simp only [lp.single_apply_self] + · rw [lp.single_apply_ne (E := fun _ : ℕ => ℝ) 1 0 a hi, + lp.single_apply_ne (E := fun _ : ℕ => ℝ) 1 0 b hi, + lp.single_apply_ne (E := fun _ : ℕ => ℝ) 1 0 (a-b) hi,sub_self] + rw [he,lp.norm_single (by norm_num)] + exact Real.norm_eq_abs _ + +lemma Model.vector_distance {X : Type*} (M : Model X) (x y : X) : + ‖M.vector x-M.vector y‖ = M.dist x y := by + unfold Model.vector + rw [EditL1.pack_distance,Fintype.sum_option] + simp only [sub_self,norm_zero,zero_add] + unfold Model.dist + apply sum_congr rfl + intro i _ + rw [singleton_sub_norm] + cases hix : M.cut i x <;> cases hiy : M.cut i y <;> + simp [sep, abs_of_nonneg (M.nonneg i)] + +end EditCutModel + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Cuts.lean b/lean/OAI/Combinatorics/EditDistance/Cuts.lean new file mode 100644 index 0000000000000000000000000000000000000000..619baf40c2a4d43e03b04c82bb3dc65f5d46b160 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Cuts.lean @@ -0,0 +1,173 @@ +import OAI.Combinatorics.EditDistance.Model + +namespace OAI + +/-! +# Finite scalar and absolutely summable cut decompositions +-/ + +namespace EditCuts +open scoped BigOperators +open Finset + +lemma top_clipping_distance (a b x y : ℝ) (hba : b < a) + (hx : x = a ∨ x ≤ b) (hy : y = a ∨ y ≤ b) : + |x - y| = |min x b - min y b| + + (a - b) * |(if x = a then (1 : ℝ) else 0) - (if y = a then (1 : ℝ) else 0)| := by + rcases hx with hx | hx <;> rcases hy with hy | hy + · subst x; subst y; simp + · subst x + have hya : y < a := hy.trans_lt hba + simp [min_eq_right hba.le, min_eq_left hy, hya.ne, + abs_of_nonneg (sub_nonneg.mpr hya.le), abs_of_nonneg (sub_nonneg.mpr hy)] + · subst y + have hxa : x < a := hx.trans_lt hba + simp [min_eq_right hba.le, min_eq_left hx, hxa.ne, + abs_of_nonpos (sub_nonpos.mpr hxa.le), abs_of_nonpos (sub_nonpos.mpr hx)] + · have hxa : x < a := hx.trans_lt hba + have hya : y < a := hy.trans_lt hba + simp [min_eq_left hx, min_eq_left hy, hxa.ne, hya.ne] + +section Finite +variable {X : Type*} [Fintype X] [DecidableEq X] + +def cut (A : Finset X) (x : X) : ℝ := if x ∈ A then 1 else 0 + +theorem scalar_decomposition_aux (s : Finset ℝ) : + ∀ (f : X → ℝ), (∀ x, f x ∈ s) → + ∃ w : Finset X → ℝ, (∀ A, 0 ≤ w A) ∧ + ∀ x y, |f x - f y| = ∑ A : Finset X, w A * |cut A x - cut A y| := by + classical + induction s using Finset.induction_on_max with + | empty => + intro f hf + refine ⟨fun _ => 0, fun _ => le_rfl, ?_⟩ + intro x + simpa using hf x + | insert a s hmax ih => + intro f hf + by_cases hse : s = ∅ + · have hfconst (x : X) : f x = a := by simpa [hse] using hf x + refine ⟨fun _ => 0, fun _ => le_rfl, ?_⟩ + intro x y + simp [hfconst] + have hsn : s.Nonempty := nonempty_iff_ne_empty.mpr hse + let b : ℝ := s.max' hsn + have hb : b ∈ s := max'_mem s hsn + have hba : b < a := hmax b hb + have hfb (x : X) (hx : f x ≠ a) : f x ≤ b := by + exact le_max' s (f x) ((mem_insert.mp (hf x)).resolve_left hx) + let f' : X → ℝ := fun x => min (f x) b + have hf' (x : X) : f' x ∈ s := by + by_cases hx : f x = a + · simpa only [f', hx, min_eq_right hba.le] using hb + · simpa only [f', min_eq_left (hfb x hx)] using + ((mem_insert.mp (hf x)).resolve_left hx) + obtain ⟨w, hw, hwd⟩ := ih f' hf' + let A : Finset X := univ.filter (fun x => f x = a) + have hcut (x : X) : cut A x = if f x = a then 1 else 0 := by simp [cut, A] + have hcase (x : X) : f x = a ∨ f x ≤ b := by + by_cases hx : f x = a + · exact Or.inl hx + · exact Or.inr (hfb x hx) + have heq (x y : X) : |f x - f y| = |f' x - f' y| + + (a - b) * |cut A x - cut A y| := by + simpa only [f', hcut] using top_clipping_distance a b (f x) (f y) hba (hcase x) (hcase y) + refine ⟨fun B => w B + if B = A then a - b else 0, ?_, ?_⟩ + · intro B + apply add_nonneg (hw B) + split_ifs + · exact sub_nonneg.mpr hba.le + · exact le_rfl + · intro x y + rw [heq, hwd] + simp only [add_mul, sum_add_distrib, ite_mul, zero_mul, sum_ite_eq', mem_univ, ite_true] + +theorem scalar_decomposition (f : X → ℝ) : + ∃ w : Finset X → ℝ, (∀ A, 0 ≤ w A) ∧ + ∀ x y, |f x - f y| = ∑ A : Finset X, w A * |cut A x - cut A y| := + scalar_decomposition_aux (univ.image f) f (fun x => mem_image.mpr ⟨x, mem_univ x, rfl⟩) + +end Finite +end EditCuts + +namespace EditCuts +open scoped BigOperators +open Finset + +abbrev RealL1 := lp (fun _ : ℕ => ℝ) 1 + +lemma l1_norm (f : RealL1) : ‖f‖ = ∑' n, |f n| := by + simpa using lp.norm_eq_tsum_rpow (by norm_num : 0 < (1 : ENNReal).toReal) f + +lemma l1_summable (f : RealL1) : Summable (fun n => |f n|) := by + simpa using (lp.memℓp f).summable (by norm_num : 0 < (1 : ENNReal).toReal) + +lemma l1_norm_sub (f g : RealL1) : ‖f - g‖ = ∑' n, |f n - g n| := + l1_norm (f - g) + +section Finite +variable {X : Type*} [Fintype X] [DecidableEq X] + +omit [Fintype X] in +lemma cut_empty (x : X) : cut ∅ x = 0 := by simp [cut] +lemma cut_univ (x : X) : cut univ x = 1 := by simp [cut] + +theorem scalar_decomposition_nontrivial (f : X → ℝ) : + ∃ w : Finset X → ℝ, (∀ A, 0 ≤ w A) ∧ w ∅ = 0 ∧ w univ = 0 ∧ + ∀ x y, |f x - f y| = ∑ A : Finset X, w A * |cut A x - cut A y| := by + classical + obtain ⟨w, hw, hd⟩ := scalar_decomposition f + refine ⟨fun A => if A = ∅ ∨ A = univ then 0 else w A, ?_, by simp, by simp, ?_⟩ + · intro A + dsimp only + split_ifs <;> simp_all + · intro x y + rw [hd] + apply sum_congr rfl + intro A _ + by_cases hac : A = ∅ ∨ A = univ + · rcases hac with rfl | rfl <;> simp [cut_empty, cut_univ] + · simp [hac] + +lemma weight_le_distance (f : X → ℝ) (w : Finset X → ℝ) + (hw : ∀ A, 0 ≤ w A) + (hd : ∀ x y, |f x - f y| = ∑ A : Finset X, w A * |cut A x - cut A y|) + (A : Finset X) (x y : X) (hx : x ∈ A) (hy : y ∉ A) : + w A ≤ |f x - f y| := by + rw [hd] + calc + w A = w A * |cut A x - cut A y| := by simp [cut, hx, hy] + _ ≤ _ := single_le_sum (fun B _ => mul_nonneg (hw B) (abs_nonneg (cut B x - cut B y))) (mem_univ A) + +theorem l1_decomposition (H : X → RealL1) : + ∃ c : Finset X → ℝ, (∀ A, 0 ≤ c A) ∧ c ∅ = 0 ∧ c univ = 0 ∧ + ∀ x y, ‖H x - H y‖ = ∑ A : Finset X, c A * |cut A x - cut A y| := by + classical + choose w hw he hu hd using fun n => scalar_decomposition_nontrivial (fun x => H x n) + have hs (A : Finset X) : Summable (fun n => w n A) := by + by_cases ha : A = ∅ ∨ A = univ + · rcases ha with rfl | rfl <;> simpa only [he, hu] using (summable_zero : Summable (fun _ : ℕ => (0 : ℝ))) + obtain ⟨x, hx⟩ := nonempty_iff_ne_empty.mpr (not_or.mp ha).1 + obtain ⟨y, hy⟩ : ∃ y, y ∉ A := by + by_contra! hn + exact (not_or.mp ha).2 (eq_univ_iff_forall.mpr hn) + exact Summable.of_nonneg_of_le (fun n => hw n A) + (fun n => weight_le_distance _ _ (hw n) (hd n) A x y hx hy) + (l1_summable (H x - H y)) + refine ⟨fun A => ∑' n, w n A, fun A => tsum_nonneg (fun n => hw n A), + by simp [he], by simp [hu], ?_⟩ + intro x y + rw [l1_norm_sub] + simp_rw [hd] + rw [Summable.tsum_finsetSum] + · apply sum_congr rfl + intro A _ + exact (hs A).tsum_mul_right _ + · intro A _ + exact (hs A).mul_right _ + +end Finite +end EditCuts + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/DelimiterAlignment.lean b/lean/OAI/Combinatorics/EditDistance/DelimiterAlignment.lean new file mode 100644 index 0000000000000000000000000000000000000000..57f2e34db2bbc63cbd845b315bf903fae1e5a1db --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/DelimiterAlignment.lean @@ -0,0 +1,147 @@ +import OAI.Combinatorics.EditDistance.Metric + +namespace OAI + +/-! +# Increasing matchings through binary delimiter blocks +-/ + +namespace EditCode +open scoped BigOperators +attribute [local instance] Classical.propDecidable + +section Matching +variable {k w n U V : ℕ} {f g : Fin k → ℕ} + +def BlockSpan (f g : Fin k → ℕ) (w i : ℕ) : Prop := + ∃ t : ℕ, ∀ r : ℕ, r < w → ∃ a : Fin k, f a = w * i + r ∧ g a = t + r + +def Missing (f : Fin k → ℕ) (w i : ℕ) : Prop := + ∃ r : ℕ, r < w ∧ ∀ a : Fin k, f a ≠ w * i + r + +def Gap (f g : Fin k → ℕ) (w i : ℕ) : Prop := + ∃ (r : ℕ) (a b : Fin k), r + 1 < w ∧ f a = w * i + r ∧ + f b = w * i + (r+1) ∧ g a + 1 < g b + +lemma span_of_no_defect (hf : StrictMono f) (hg : StrictMono g) (hw : 0 < w) (i : ℕ) + (hm : ¬ Missing f w i) (hgap : ¬ Gap f g w i) : BlockSpan f g w i := by + have hfull : ∀ r : ℕ, r < w → ∃ a : Fin k, f a = w * i + r := by + intro r hr + by_contra h + exact hm ⟨r,hr,by simpa only [not_exists] using h⟩ + obtain ⟨a₀, ha₀⟩ := hfull 0 hw + refine ⟨g a₀, ?_⟩ + intro r hr + induction r with + | zero => exact ⟨a₀,ha₀,by omega⟩ + | succ r ih => + obtain ⟨a, ha, hga⟩ := ih (by omega) + obtain ⟨b, hb⟩ := hfull (r+1) hr + have hab : a < b := hf.lt_iff_lt.mp (by omega) + have hgab := hg hab + have hn : ¬g a + 1 < g b := fun h => hgap ⟨r,a,b,hr,ha,hb,h⟩ + exact ⟨b,hb,by omega⟩ + +lemma defect_of_not_span (hf : StrictMono f) (hg : StrictMono g) (hw : 0 < w) (i : ℕ) + (h : ¬BlockSpan f g w i) : Missing f w i ∨ Gap f g w i := by + by_contra h' + push Not at h' + exact h (span_of_no_defect hf hg hw i h'.1 h'.2) + +def Charge (f g : Fin k → ℕ) (w i : ℕ) : ℕ ⊕ ℕ → Prop + | Sum.inl x => w * i ≤ x ∧ x < w * i + w ∧ ∀ a : Fin k, f a ≠ x + | Sum.inr x => (∀ a : Fin k, g a ≠ x) ∧ ∃ a b : Fin k, + w * i ≤ f a ∧ f a < w * i + w ∧ w * i ≤ f b ∧ f b < w * i + w ∧ + g a < x ∧ x < g b + +lemma exists_charge (hf : StrictMono f) (hg : StrictMono g) (hw : 0 < w) (i : ℕ) + (h : ¬BlockSpan f g w i) : ∃ x, Charge f g w i x := by + rcases defect_of_not_span hf hg hw i h with hm | hgap + · obtain ⟨r,hr,hm⟩ := hm + exact ⟨Sum.inl (w*i+r), by exact ⟨by omega,by omega,hm⟩⟩ + · obtain ⟨r,a,b,hr,ha,hb,hgap⟩ := hgap + refine ⟨Sum.inr (g a+1), ?_⟩ + constructor + · intro c hc + have hac : a < c := hg.lt_iff_lt.mp (by omega) + have hcb : c < b := hg.lt_iff_lt.mp (by omega) + have hfa := hf hac + have hfb := hf hcb + omega + · exact ⟨a,b,by omega,by omega,by omega,by omega,by omega,hgap⟩ + +lemma charge_distinct (hf : StrictMono f) (hg : StrictMono g) + {i j : ℕ} (hij : i ≠ j) {x : ℕ ⊕ ℕ} + (hi : Charge f g w i x) (hj : Charge f g w j x) : False := by + wlog h : i < j generalizing i j + · exact this hij.symm hj hi (lt_of_le_of_ne (Nat.le_of_not_gt h) hij.symm) + have hwi : w * i + w ≤ w * j := by + have := Nat.mul_le_mul_left w h + nlinarith + cases x with + | inl x => dsimp [Charge] at hi hj; omega + | inr x => + obtain ⟨_,a,b,ha₁,ha₂,hb₁,hb₂,hax,hxb⟩ := hi + obtain ⟨_,c,d,hc₁,hc₂,hd₁,hd₂,hcx,hxd⟩ := hj + have hbc : b < c := hf.lt_iff_lt.mp (by omega) + have := hg hbc + omega + +lemma missing_card {N : ℕ} (hf : Function.Injective f) (hN : ∀ a, f a < N) : + (Finset.range N \ Finset.univ.image f).card = N - k := by + have hs : Finset.univ.image f ⊆ Finset.range N := by + intro x hx + obtain ⟨a,_,rfl⟩ := Finset.mem_image.mp hx + exact Finset.mem_range.mpr (hN a) + rw [Finset.card_sdiff_of_subset hs, Finset.card_range, + Finset.card_image_of_injective _ hf, Finset.card_univ, Fintype.card_fin] + +theorem bad_blocks_le_loss + (hf : StrictMono f) (hg : StrictMono g) (hw : 0 < w) + (hU : ∀ a, f a < U) (hV : ∀ a, g a < V) (hn : w * n ≤ U) : + (Finset.univ.filter (fun i : Fin n => ¬BlockSpan f g w i.val)).card ≤ (U-k) + (V-k) := by + classical + let B := {i : Fin n // ¬BlockSpan f g w i.val} + let X := Finset.range U \ Finset.univ.image f + let Y := Finset.range V \ Finset.univ.image g + have hx (i : B) : ∃ x, Charge f g w i.val.val x := exists_charge hf hg hw i.val i.property + let c (i : B) : ℕ ⊕ ℕ := (hx i).choose + have hc (i : B) : Charge f g w i.val.val (c i) := (hx i).choose_spec + have hcX (i : B) (x : ℕ) (he : c i = Sum.inl x) : x ∈ X := by + have h := hc i + rw [he] at h + rcases h with ⟨h₁,h₂,h₃⟩ + have hwi : w * (i.val.val+1) ≤ w * n := Nat.mul_le_mul_left _ i.val.isLt + simp only [X, Finset.mem_sdiff, Finset.mem_range, Finset.mem_image, Finset.mem_univ, + true_and, not_exists] + exact ⟨by nlinarith,fun a => (h₃ a)⟩ + have hcY (i : B) (x : ℕ) (he : c i = Sum.inr x) : x ∈ Y := by + have h := hc i + rw [he] at h + obtain ⟨hx,a,b,_,_,_,_,_,hxb⟩ := h + simp only [Y, Finset.mem_sdiff, Finset.mem_range, Finset.mem_image, Finset.mem_univ, + true_and, not_exists] + exact ⟨lt_trans hxb (hV b),hx⟩ + let c' (i : B) : X ⊕ Y := match he : c i with + | Sum.inl x => Sum.inl ⟨x,hcX i x he⟩ + | Sum.inr x => Sum.inr ⟨x,hcY i x he⟩ + have hval (i : B) : Sum.map Subtype.val Subtype.val (c' i) = c i := by + dsimp [c'] + split <;> rename_i x he <;> exact he.symm + have hinj : Function.Injective c' := by + intro i j he + have he' : c i = c j := by rw [←hval i,←hval j,he] + by_contra hij + have hvalne : i.val.val ≠ j.val.val := by + intro h + apply hij + exact Subtype.ext (Fin.ext h) + exact charge_distinct hf hg hvalne (hc i) (by rw [he']; exact hc j) + have hcard := Fintype.card_le_of_injective c' hinj + simpa only [B, Fintype.card_subtype, Fintype.card_sum, Fintype.card_coe, X, Y, + missing_card hf.injective hU, missing_card hg.injective hV] using hcard + +end Matching +end EditCode + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/DepthInversion.lean b/lean/OAI/Combinatorics/EditDistance/DepthInversion.lean new file mode 100644 index 0000000000000000000000000000000000000000..995e76ecf291b89c6a16eac575bf01a7f5e048a2 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/DepthInversion.lean @@ -0,0 +1,105 @@ +import OAI.Combinatorics.EditDistance.LowerParameters + +namespace OAI + +/-! +# Inverting recursive depth for all sufficiently large lengths +-/ + +namespace EditDepth +open Filter + +noncomputable def radius (t : ℝ) := Real.sqrt (t / Real.log t) +noncomputable def depth (t : ℝ) : ℕ := ⌊radius t / 100⌋₊ + +lemma radius_nonneg (t : ℝ) : 0 ≤ radius t := Real.sqrt_nonneg _ + +lemma eventually_radius_large (K : ℕ) : + ∀ᶠ t : ℝ in atTop, (100 : ℝ)*(K+2) ≤ radius t := by + let R : ℝ := 100*((K : ℝ)+2) + have hR : 0 < R := by dsimp [R]; positivity + have he : 0 < 1/R^2 := by positivity + have hlog := Real.isLittleO_log_id_atTop.def he + have hl := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1 : ℝ)) + filter_upwards [hlog,hl,eventually_ge_atTop (1 : ℝ)] with t ht hlt htp + have tp : 0 < t := by linarith + have lp : 0 < Real.log t := by linarith + have ht' : Real.log t ≤ t/R^2 := by + simpa only [Function.id_def,Real.norm_eq_abs,abs_of_pos tp,abs_of_pos lp,div_eq_mul_inv,one_mul,mul_comm] using ht + have hs : R^2 ≤ t/Real.log t := by + apply (le_div_iff₀ lp).mpr + have hb := (le_div_iff₀ (sq_pos_of_pos hR)).mp ht' + nlinarith + exact Real.le_sqrt_of_sq_le hs + +lemma depth_lower {t : ℝ} (ht : 200 ≤ radius t) : radius t/200 ≤ (depth t : ℝ) := by + have hf := Nat.lt_floor_add_one (radius t/100) + change radius t/100 < (depth t : ℝ)+1 at hf + linarith + +lemma depth_upper (t : ℝ) : (depth t : ℝ) ≤ radius t/100 := + Nat.floor_le (div_nonneg (radius_nonneg t) (by norm_num)) + +lemma depth_bounds {t : ℝ} (ht : 1 ≤ t) (hlt : 1 ≤ Real.log t) + (hr : 200 ≤ radius t) (hll : Real.log (Real.log t) ≤ Real.log t/6) + (hlarge : 12*Real.log (200 : ℝ) ≤ Real.log t) : + 1000*(depth t : ℝ)^2*Real.log (depth t : ℝ) ≤ t ∧ + Real.sqrt (t*Real.log t)/1200 ≤ (1/2 : ℝ)*(depth t : ℝ)*Real.log (depth t : ℝ) := by + have tp : 0 < t := by linarith + have lp : 0 < Real.log t := by linarith + have rp : 0 < radius t := by linarith + have kp : 0 < (depth t : ℝ) := lt_of_lt_of_le (by positivity) (depth_lower hr) + have hr2 : radius t^2 = t/Real.log t := Real.sq_sqrt (div_nonneg tp.le lp.le) + have hr2' : radius t^2*Real.log t = t := (eq_div_iff lp.ne').mp hr2 + have hrle : radius t ≤ t := by + have hdiv : t/Real.log t ≤ t := (div_le_iff₀ lp).mpr (by nlinarith) + nlinarith [radius_nonneg t] + have hkle : (depth t : ℝ) ≤ t := by + have hh := depth_upper t + nlinarith [radius_nonneg t] + have logupper : Real.log (depth t : ℝ) ≤ Real.log t := Real.log_le_log kp hkle + have loglower : Real.log t/3 ≤ Real.log (depth t : ℝ) := by + have hlog := Real.log_le_log (by positivity : 0 < radius t/200) (depth_lower hr) + have logR : Real.log (radius t) = (Real.log t - Real.log (Real.log t))/2 := by + dsimp [radius] + rw [Real.log_sqrt (div_nonneg tp.le lp.le),Real.log_div tp.ne' lp.ne'] + rw [Real.log_div rp.ne' (by norm_num),logR] at hlog + linarith + have hsq : (depth t : ℝ)^2 ≤ radius t^2/10000 := by + have hh := depth_upper t + nlinarith [sq_nonneg (radius t/100-(depth t : ℝ))] + have hsqrt : Real.sqrt (t*Real.log t) = radius t*Real.log t := by + apply (Real.sqrt_eq_iff_mul_self_eq (by positivity) (by positivity)).mpr + nlinarith [congrArg (fun x : ℝ => x*Real.log t) hr2'] + constructor + · calc + _ ≤ 1000*(depth t : ℝ)^2*Real.log t := mul_le_mul_of_nonneg_left logupper (by positivity) + _ ≤ t := by + have hh := mul_le_mul_of_nonneg_right hsq lp.le + nlinarith + · rw [hsqrt] + have hh : radius t/200*(Real.log t/3) ≤ (depth t : ℝ)*Real.log (depth t : ℝ) := by + gcongr + · exact depth_lower hr + linarith + +theorem eventually_choose_depth (K : ℕ) : ∀ᶠ t : ℝ in atTop, + K ≤ depth t ∧ 1000*(depth t : ℝ)^2*Real.log (depth t : ℝ) ≤ t ∧ + Real.sqrt (t*Real.log t)/1200 ≤ (1/2 : ℝ)*(depth t : ℝ)*Real.log (depth t : ℝ) := by + have hsmall := Real.isLittleO_log_id_atTop.def (by norm_num : (0 : ℝ)<1/6) + have hsmall' := Real.tendsto_log_atTop.eventually hsmall + have hl := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1 : ℝ)) + have hh := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (12*Real.log (200 : ℝ))) + filter_upwards [eventually_radius_large K,hsmall',hl,hh,eventually_ge_atTop (1 : ℝ)] with t hr hs hl hh ht + have hK : (K : ℝ) ≤ radius t/100 := by nlinarith + have hr' : 200 ≤ radius t := by have := Nat.cast_nonneg (α := ℝ) K; nlinarith + have hll : Real.log (Real.log t) ≤ Real.log t/6 := by + have hlog := Real.log_nonneg hl + have hpos : 0 ≤ Real.log t := by linarith + simpa only [Function.id_def,Real.norm_eq_abs,abs_of_nonneg hlog,abs_of_nonneg hpos, + div_eq_mul_inv,one_mul,mul_comm] using hs + exact ⟨Nat.le_floor hK,depth_bounds ht hl hr' hll hh⟩ + +end EditDepth + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/DirectSums.lean b/lean/OAI/Combinatorics/EditDistance/DirectSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1b0288b8e398d7fa1b02b296eba1e8e8f838b8d --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/DirectSums.lean @@ -0,0 +1,145 @@ +import OAI.Combinatorics.EditDistance.PrimeDisplacement + +namespace OAI + +/-! +# Weighted direct sums and normalized slice maps +-/ + +namespace EditL1 +open scoped BigOperators + +abbrev L1 := lp (fun _ : ℕ => ℝ) 1 +abbrev L1On (I : Type*) := lp (fun _ : I => ℝ) 1 + +lemma norm_eq_tsum {I : Type*} (f : L1On I) : ‖f‖ = ∑' i, |f i| := by + simpa using lp.norm_eq_tsum_rpow (by norm_num : 0 < (1 : ENNReal).toReal) f + +lemma summable_abs {I : Type*} (f : L1On I) : Summable (fun i => |f i|) := by + simpa using (lp.memℓp f).summable (by norm_num : 0 < (1 : ENNReal).toReal) + +noncomputable def reindex {I J : Type*} (e : I ≃ J) (f : L1On I) : L1On J := + ⟨fun j => f (e.symm j), memℓp_gen (by + simpa only [ENNReal.toReal_one, Real.rpow_one, Real.norm_eq_abs, Function.comp_def] using! + (e.symm.summable_iff).mpr (summable_abs f))⟩ + +lemma reindex_apply {I J : Type*} (e : I ≃ J) (f : L1On I) (j : J) : + reindex e f j = f (e.symm j) := rfl + +lemma reindex_norm {I J : Type*} (e : I ≃ J) (f : L1On I) : + ‖reindex e f‖ = ‖f‖ := by + simp_rw [norm_eq_tsum, reindex_apply] + exact e.symm.tsum_eq (fun i => |f i|) + +lemma reindex_sub {I J : Type*} (e : I ≃ J) (f g : L1On I) : + reindex e (f - g) = reindex e f - reindex e g := by + ext j + rfl + +section FiniteSum +variable {I : Type*} [Fintype I] + +lemma family_summable (f : I → L1) : Summable (fun a : I × ℕ => |f a.1 a.2|) := + (summable_prod_of_nonneg (fun _ => abs_nonneg _)).mpr + ⟨fun i => summable_abs (f i), (hasSum_fintype _).summable⟩ + +noncomputable def familyLp (f : I → L1) : L1On (I × ℕ) := + ⟨fun a => f a.1 a.2, memℓp_gen (by simpa using family_summable f)⟩ + +lemma familyLp_apply (f : I → L1) (i : I) (n : ℕ) : familyLp f (i, n) = f i n := rfl + +lemma familyLp_norm (f : I → L1) : ‖familyLp f‖ = ∑ i, ‖f i‖ := by + rw [norm_eq_tsum] + change (∑' a : I × ℕ, |f a.1 a.2|) = _ + rw [(family_summable f).tsum_prod, tsum_fintype] + exact Finset.sum_congr rfl (fun i _ => (norm_eq_tsum (f i)).symm) + +lemma familyLp_sub (f g : I → L1) : familyLp (f - g) = familyLp f - familyLp g := by + ext ⟨i, n⟩ + rfl + +variable [Nonempty I] + +noncomputable def indexEquiv : (I × ℕ) ≃ ℕ := Classical.choice inferInstance + +noncomputable def pack (f : I → L1) : L1 := reindex indexEquiv (familyLp f) + +lemma pack_norm (f : I → L1) : ‖pack f‖ = ∑ i, ‖f i‖ := by + rw [pack, reindex_norm, familyLp_norm] + +lemma pack_sub (f g : I → L1) : pack (f - g) = pack f - pack g := by + rw [pack, familyLp_sub, reindex_sub] + rfl + +lemma pack_distance (f g : I → L1) : ‖pack f - pack g‖ = ∑ i, ‖f i - g i‖ := by + rw [← pack_sub, pack_norm] + rfl + +lemma weighted_pack_distance (w : I → ℝ) (hw : ∀ i, 0 ≤ w i) (f g : I → L1) : + ‖pack (fun i => w i • f i) - pack (fun i => w i • g i)‖ = + ∑ i, w i * ‖f i - g i‖ := by + rw [pack_distance] + apply Finset.sum_congr rfl + intro i _ + rw [← smul_sub, norm_smul, Real.norm_eq_abs, abs_of_nonneg (hw i)] + +end FiniteSum +end EditL1 + +namespace EditAverage +lemma avg_prod {X Y : Type*} [Fintype X] [Fintype Y] (f : X → Y → ℝ) : + avg (fun z : X × Y => f z.1 z.2) = avg (fun x => avg (f x)) := by + simp only [avg, Fintype.card_prod, Nat.cast_mul, Fintype.sum_prod_type, ← Finset.sum_div, + div_div] + rw [mul_comm] +end EditAverage + +namespace EditSlices +open scoped BigOperators +open EditAverage EditFourier + +variable {J : Type*} [Fintype J] [DecidableEq J] +variable (G : J → Type*) [∀ j, AddCommGroup (G j)] [∀ j, Fintype (G j)] + +omit [Fintype J] [∀ j, Fintype (G j)] in +lemma split_add_single (i : J) (x u : G i) (y : ∀ j : {j // j ≠ i}, G j) : + (Equiv.piSplitAt i G).symm (x + u, y) = + (Equiv.piSplitAt i G).symm (x, y) + Pi.single i u := by + ext j + by_cases h : j = i + · subst j + simp [Equiv.piSplitAt] + · simp [Equiv.piSplitAt, h] + +noncomputable def slice (H : (∀ j, G j) → EditL1.L1) (i : J) (ω : ℝ) : G i → EditL1.L1 := + fun x => EditL1.pack (fun y : (∀ j : {j // j ≠ i}, G j) => + (1 / (ω * Fintype.card (∀ j : {j // j ≠ i}, G j))) • + H ((Equiv.piSplitAt i G).symm (x,y))) + +lemma variation_slice (H : (∀ j, G j) → EditL1.L1) (i : J) (ω : ℝ) (hω : 0 < ω) + (u : G i) : variation (slice G H i ω) u = variation H (Pi.single i u) / ω := by + let Y := ∀ j : {j // j ≠ i}, G j + let E := Equiv.piSplitAt i G + have hY : 0 < (Fintype.card Y : ℝ) := Nat.cast_pos.mpr Fintype.card_pos + have hweight : 0 ≤ 1 / (ω * (Fintype.card Y : ℝ)) := by positivity + have hd (x : G i) : + ‖slice G H i ω (x + u) - slice G H i ω x‖ = + (1 / ω) * avg (fun y : Y => ‖H (E.symm (x,y) + Pi.single i u) - H (E.symm (x,y))‖) := by + rw [slice, slice, EditL1.weighted_pack_distance (fun _ => _) (fun _ => hweight)] + simp_rw [split_add_single] + rw [← Finset.mul_sum, avg] + dsimp [E, Y] + ring + have he : variation H (Pi.single i u) = + avg (fun x : G i => avg (fun y : Y => + ‖H (E.symm (x,y) + Pi.single i u) - H (E.symm (x,y))‖)) := by + rw [← avg_prod] + exact (avg_equiv E.symm (fun z => ‖H (z + Pi.single i u) - H z‖)).symm + change avg (fun x => ‖slice G H i ω (x + u) - slice G H i ω x‖) = _ + simp_rw [hd] + rw [avg_mul, ← he] + ring + +end EditSlices + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Distortion.lean b/lean/OAI/Combinatorics/EditDistance/Distortion.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fdfc61dc7ff8aa3d78c7fee86dfe9e611a32c76 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Distortion.lean @@ -0,0 +1,92 @@ +import OAI.Combinatorics.EditDistance.DirectSums +import OAI.Combinatorics.EditDistance.Metric + +namespace OAI + +/-! +# Distance-ratio extrema and finite-dimensional embeddings +-/ + +namespace EditDistortion +universe u v + +noncomputable def coordinateEmbedding (X : Type u) [Fintype X] : X ↪ L1 := by + classical + let e : X ↪ ℕ := (Fintype.equivFin X).toEmbedding.trans ⟨Fin.val,Fin.val_injective⟩ + refine ⟨fun x => lp.single 1 (e x) (1 : ℝ), ?_⟩ + intro x y h + by_contra hxy + have hne : e x ≠ e y := fun h => hxy (e.injective h) + have he := congrArg (fun f : L1 => f (e x)) h + simp only [lp.single_apply_self,lp.single_apply_ne (E := fun _ : ℕ => ℝ) 1 (e y) (1 : ℝ) hne] at he + norm_num at he + +lemma ratios_finite {X : Type u} [Finite X] (ρ : X → X → ℝ) (f : X → L1) : + {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ‖f x-f y‖/ρ x y}.Finite := by + refine (Set.finite_range (fun p : X × X => ‖f p.1-f p.2‖/ρ p.1 p.2)).subset ?_ + rintro r ⟨x,y,_,rfl⟩ + exact Set.mem_range.mpr ⟨(x,y),rfl⟩ + +lemma reverse_ratios_finite {X : Type u} [Finite X] (ρ : X → X → ℝ) (f : X → L1) : + {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ρ x y/‖f x-f y‖}.Finite := by + refine (Set.finite_range (fun p : X × X => ρ p.1 p.2/‖f p.1-f p.2‖)).subset ?_ + rintro r ⟨x,y,_,rfl⟩ + exact Set.mem_range.mpr ⟨(x,y),rfl⟩ + +lemma distortion_constants {X : Type u} [Finite X] [Nontrivial X] + (ρ : X → X → ℝ) (hd : ∀ x, ρ x x = 0) + (hp : ∀ x y, x ≠ y → 0 < ρ x y) (f : X ↪ L1) : + ∃ U V : ℝ, 0 < U ∧ 0 < V ∧ distortion ρ f = U*V ∧ + (∀ x y, ‖f x-f y‖ ≤ U*ρ x y) ∧ (∀ x y, ρ x y ≤ V*‖f x-f y‖) := by + let U := sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ‖f x-f y‖/ρ x y} + let V := sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ρ x y/‖f x-f y‖} + have hu (x y : X) (hxy : x ≠ y) : ‖f x-f y‖/ρ x y ≤ U := + le_csSup (ratios_finite ρ f).bddAbove ⟨x,y,hxy,rfl⟩ + have hv (x y : X) (hxy : x ≠ y) : ρ x y/‖f x-f y‖ ≤ V := + le_csSup (reverse_ratios_finite ρ f).bddAbove ⟨x,y,hxy,rfl⟩ + have hn (x y : X) (hxy : x ≠ y) : 0 < ‖f x-f y‖ := + norm_pos_iff.mpr (sub_ne_zero.mpr (fun h => hxy (f.injective h))) + obtain ⟨x,y,hxy⟩ := exists_pair_ne X + refine ⟨U,V,(div_pos (hn x y hxy) (hp x y hxy)).trans_le (hu x y hxy), + (div_pos (hp x y hxy) (hn x y hxy)).trans_le (hv x y hxy),rfl,?_,?_⟩ + · intro x y + by_cases hxy : x = y + · subst y; simp only [sub_self,norm_zero,hd,mul_zero,le_refl] + · exact (div_le_iff₀ (hp x y hxy)).mp (hu x y hxy) + · intro x y + by_cases hxy : x = y + · subst y; simp only [sub_self,norm_zero,hd,mul_zero,le_refl] + · exact (div_le_iff₀ (hn x y hxy)).mp (hv x y hxy) + +lemma distortion_nonneg {X : Type u} [Finite X] [Nontrivial X] + (ρ : X → X → ℝ) (hd : ∀ x, ρ x x = 0) + (hp : ∀ x y, x ≠ y → 0 < ρ x y) (f : X ↪ L1) : 0 ≤ distortion ρ f := by + obtain ⟨U,V,hU,hV,he,_,_⟩ := distortion_constants ρ hd hp f + rw [he] + positivity + +lemma leastDistortion_lower {X : Type u} [Fintype X] (ρ : X → X → ℝ) (B : ℝ) + (h : ∀ f : X ↪ L1, B ≤ distortion ρ f) : B ≤ leastDistortion ρ := by + let : Nonempty (X ↪ L1) := ⟨coordinateEmbedding X⟩ + apply le_csInf (Set.range_nonempty (f := distortion ρ)) + rintro r ⟨f,rfl⟩ + exact h f + +lemma finite_words (Alpha : Type u) [Finite Alpha] (d : ℕ) : Finite (Words Alpha d) := by + let domain := (n : Fin (d+1)) × (Fin n.val → Alpha) + let F : domain → Words Alpha d := fun ⟨n,v⟩ => ⟨List.ofFn v,by simp only [List.length_ofFn]; omega⟩ + apply Finite.of_surjective F + intro x + refine ⟨⟨⟨x.val.length,by have := x.property; omega⟩,x.val.get⟩,?_⟩ + apply Subtype.ext + exact List.ofFn_get x.val + +lemma edit_real_diag {Alpha : Type u} (x : List Alpha) : (edit x x : ℝ) = 0 := by + exact_mod_cast (cost_refl (s := true) x) + +lemma edit_real_pos {Alpha : Type u} (x y : List Alpha) (hxy : x ≠ y) : 0 < (edit x y : ℝ) := by + exact_mod_cast Nat.pos_of_ne_zero (mt (cost_eq_zero_iff (s := true)).mp hxy) + +end EditDistortion + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/DistortionMonotonicity.lean b/lean/OAI/Combinatorics/EditDistance/DistortionMonotonicity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b89dec1d71c7c1b53ffc5ad585af43808ea4a183 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/DistortionMonotonicity.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.EditDistance.Distortion +import OAI.Combinatorics.EditDistance.Metric + +namespace OAI + +/-! +# Restriction and monotonicity of least distortion +-/ + +namespace EditDistortion +universe u v + +lemma leastDistortion_le {X : Type u} [Finite X] [Nontrivial X] + (ρ : X → X → ℝ) (hd : ∀ x, ρ x x = 0) + (hp : ∀ x y, x ≠ y → 0 < ρ x y) (f : X ↪ L1) : leastDistortion ρ ≤ distortion ρ f := by + apply csInf_le (s := Set.range (distortion ρ)) (a := distortion ρ f) ?_ ⟨f,rfl⟩ + refine ⟨0,?_⟩ + rintro r ⟨g,rfl⟩ + exact distortion_nonneg ρ hd hp g + +lemma distortion_le_of_bounds {X : Type u} [Finite X] [Nontrivial X] + (ρ : X → X → ℝ) (hp : ∀ x y, x ≠ y → 0 < ρ x y) + (f : X ↪ L1) {U V : ℝ} (hU : 0 ≤ U) + (hu : ∀ x y, ‖f x-f y‖ ≤ U*ρ x y) + (hv : ∀ x y, ρ x y ≤ V*‖f x-f y‖) : distortion ρ f ≤ U*V := by + have hn (x y : X) (hxy : x ≠ y) : 0 < ‖f x-f y‖ := + norm_pos_iff.mpr (sub_ne_zero.mpr (fun h => hxy (f.injective h))) + obtain ⟨x,y,hxy⟩ := exists_pair_ne X + have hn1 : {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ‖f x-f y‖/ρ x y}.Nonempty := + ⟨_,⟨x,y,hxy,rfl⟩⟩ + have hn2 : {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ρ x y/‖f x-f y‖}.Nonempty := + ⟨_,⟨x,y,hxy,rfl⟩⟩ + have h1 : sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ‖f x-f y‖/ρ x y} ≤ U := by + apply csSup_le hn1 + rintro r ⟨i,j,hij,rfl⟩ + exact (div_le_iff₀ (hp i j hij)).mpr (hu i j) + have h2 : sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ρ x y/‖f x-f y‖} ≤ V := by + apply csSup_le hn2 + rintro r ⟨i,j,hij,rfl⟩ + exact (div_le_iff₀ (hn i j hij)).mpr (hv i j) + have hnon : 0 ≤ sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ρ x y/‖f x-f y‖} := + (div_nonneg (hp x y hxy).le (norm_nonneg _)).trans + (le_csSup (reverse_ratios_finite ρ f).bddAbove ⟨x,y,hxy,rfl⟩) + unfold distortion + exact mul_le_mul h1 h2 hnon hU + +theorem leastDistortion_mono {X : Type u} {Y : Type v} [Fintype X] [Fintype Y] + [Nontrivial X] [Nontrivial Y] (ρX : X → X → ℝ) (ρY : Y → Y → ℝ) + (hdX : ∀ x, ρX x x = 0) (hpX : ∀ x y, x ≠ y → 0 < ρX x y) + (hdY : ∀ x, ρY x x = 0) (hpY : ∀ x y, x ≠ y → 0 < ρY x y) + (e : X ↪ Y) (he : ∀ x y, ρY (e x) (e y) = ρX x y) : + leastDistortion ρX ≤ leastDistortion ρY := by + apply leastDistortion_lower + intro f + obtain ⟨U,V,hU,_,hD,hu,hv⟩ := distortion_constants ρY hdY hpY f + let g : X ↪ L1 := e.trans f + calc + leastDistortion ρX ≤ distortion ρX g := leastDistortion_le ρX hdX hpX g + _ ≤ U*V := distortion_le_of_bounds ρX hpX g hU.le + (fun x y => by simpa only [g,Function.Embedding.trans_apply,he] using hu (e x) (e y)) + (fun x y => by simpa only [g,Function.Embedding.trans_apply,he] using hv (e x) (e y)) + _ = distortion ρY f := hD.symm + +end EditDistortion + +namespace EditDistortion +universe u + +theorem binary_subset_lower (Alpha : Type u) [Fintype Alpha] (hAlpha : 2 ≤ Fintype.card Alpha) + {d n : ℕ} (hn : n ≤ d) (S : Set (List Bool)) (hfin : S.Finite) (hnt : S.Nontrivial) + (hlen : ∀ w ∈ S, w.length = n) : + leastDistortion (fun x y : S => (edit x.val y.val : ℝ)) ≤ E Alpha d := by + classical + let : Fintype S := hfin.fintype + let : Nontrivial S := hnt.coe_sort + let : Finite (Words Alpha d) := finite_words Alpha d + let : Fintype (Words Alpha d) := Fintype.ofFinite _ + let a : Bool ↪ Alpha := Classical.choice (Function.Embedding.nonempty_of_card_le + (by simpa only [Fintype.card_bool] using hAlpha)) + let e : S ↪ Words Alpha d := + ⟨fun x => ⟨x.val.map a,by simpa only [List.length_map,hlen x.val x.property] using hn⟩, + fun x y h => Subtype.ext ((List.map_inj_right a.injective).mp (congrArg Subtype.val h))⟩ + let : Nontrivial (Words Alpha d) := by + obtain ⟨x,y,hxy⟩ := exists_pair_ne S + exact ⟨⟨e x,e y,fun h => hxy (e.injective h)⟩⟩ + apply leastDistortion_mono _ _ + (fun x => edit_real_diag x.val) + (fun x y hxy => edit_real_pos x.val y.val (fun h => hxy (Subtype.ext h))) + (fun x => edit_real_diag x.val) + (fun x y hxy => edit_real_pos x.val y.val (fun h => hxy (Subtype.ext h))) e + intro x y + exact_mod_cast cost_map_eq_of_leftInverse (s := true) a (Function.invFun a) + (Function.leftInverse_invFun a.injective) x.val y.val + +end EditDistortion + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/DyadicScales.lean b/lean/OAI/Combinatorics/EditDistance/DyadicScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..b64224334b1140d46db83be652fe6dc752328c7d --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/DyadicScales.lean @@ -0,0 +1,41 @@ +import Mathlib + +namespace OAI + +/-! +# Dyadic scales for window displacement +-/ + +namespace EditDyadic + +lemma log_mono {a b : ℕ} (hab : a ≤ b) : Nat.log 2 a ≤ Nat.log 2 b := by + exact Nat.log_mono_right hab + +lemma scale {l delta : ℕ} (hl : 0 < l) (hd : 0 < delta) (hdl : delta ≤ 2*l) : + ∃ j : Fin (Nat.log 2 l+1), + let s := 2^j.val + 1 ≤ s ∧ s ≤ l ∧ delta ≤ 16*s ∧ 2*(s-1)+s ≤ delta := by + by_cases hsmall : delta < 4 + · refine ⟨⟨0,by omega⟩,?_⟩ + simp only [pow_zero] + omega + · let m := delta/4 + have hm : 0 < m := by dsimp [m]; omega + have hml : m ≤ l := by dsimp [m]; omega + have hj : Nat.log 2 m < Nat.log 2 l+1 := by have := log_mono hml; omega + refine ⟨⟨Nat.log 2 m,hj⟩,?_⟩ + dsimp only + have hs : 1 ≤ 2^Nat.log 2 m := Nat.one_le_pow _ _ (by omega) + have hsm : 2^Nat.log 2 m ≤ m := Nat.pow_log_le_self 2 (by omega) + have hm2 := Nat.lt_pow_succ_log_self (by omega : 1 < 2) m + rw [pow_succ] at hm2 + dsimp [m] at * + refine ⟨hs,hsm.trans hml,?_,?_⟩ <;> omega + +lemma scale_le {l : ℕ} (hl : 0 < l) (j : Fin (Nat.log 2 l+1)) : 2^j.val ≤ l := by + exact (Nat.pow_le_pow_right (by omega : 0 < 2) (by omega : j.val ≤ Nat.log 2 l)).trans + (Nat.pow_log_le_self 2 (by omega)) + +end EditDyadic + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Families.lean b/lean/OAI/Combinatorics/EditDistance/Families.lean new file mode 100644 index 0000000000000000000000000000000000000000..83e22404f1d0cae4c3271ec12b0d889486a6e62e --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Families.lean @@ -0,0 +1,85 @@ +import OAI.Combinatorics.EditDistance.Metric +import OAI.Combinatorics.EditDistance.PrimeDisplacement + +namespace OAI + +/-! +# Finite word families with averaged displacement control +-/ + +namespace EditFamily +open scoped BigOperators +open EditDistortion EditAverage EditFourier + +structure Family (p n A : ℕ) (α Q : ℝ) where + State : Type + [group : AddCommGroup State] + [finite : Fintype State] + v : State + annihilate : p • v = 0 + word : State → Fin n → Fin A + steps : List (State × ℝ) + positive : ∀ e r, (e,r) ∈ steps → 0 < r + cheap : ∀ e r, (e,r) ∈ steps → ∀ z, + (indel (List.ofFn (word z)) (List.ofFn (word (z + e))) : ℝ) ≤ n * r + far : ∀ z u, 0 < u → u < p → + (n : ℝ) * α ≤ (indel (List.ofFn (word z)) (List.ofFn (word (z + u • v))) : ℝ) + control : ∀ H : State → L1, + (∀ e r, (e,r) ∈ steps → variation H e ≤ r) → + ∀ u, 0 < u → u < p → variation H (u • v) ≤ Q + +attribute [instance] Family.group Family.finite + +lemma indel_singletons_le {A : Type*} (a b : A) : indel [a] [b] ≤ 2 := by + exact cost_le ((Script.to_nil [a]).trans (Script.to_nil [b]).symm) + +noncomputable def base {p A : ℕ} (hp : p.Prime) (hA : p ≤ A) : Family p 1 A 1 2 := by + classical + letI : NeZero p := ⟨hp.ne_zero⟩ + let W : ZMod p → Fin 1 → Fin A := fun z _ => ⟨z.val, lt_of_lt_of_le (ZMod.val_lt z) hA⟩ + let S : List (ZMod p × ℝ) := + ((Finset.univ.filter (fun e : ZMod p => e ≠ 0)).toList).map (fun e => (e,2)) + have memS (e : ZMod p) (r : ℝ) : (e,r) ∈ S ↔ e ≠ 0 ∧ r = 2 := by + simp [S, eq_comm] + have phase (u : ℕ) (hu : 0 < u) (hup : u < p) : u • (1 : ZMod p) ≠ 0 := by + simp only [nsmul_eq_mul, mul_one, Ne, ZMod.natCast_eq_zero_iff] + exact Nat.not_dvd_of_pos_of_lt hu hup + refine { State := ZMod p + group := inferInstance + finite := inferInstance + v := 1 + annihilate := ?_ + word := W + steps := S + positive := ?_ + cheap := ?_ + far := ?_ + control := ?_ } + · simp [nsmul_eq_mul] + · intro e r hr + rw [(memS e r).mp hr |>.2] + norm_num + · intro e r hr z + rw [(memS e r).mp hr |>.2] + simpa [List.ofFn_succ, W] using + (show (indel [W z 0] [W (z+e) 0] : ℝ) ≤ 2 from by exact_mod_cast indel_singletons_le _ _) + · intro z u hu hup + have hne : List.ofFn (W z) ≠ List.ofFn (W (z + u • (1 : ZMod p))) := by + intro he + have hx : W z 0 = W (z + u • (1 : ZMod p)) 0 := by + simpa [List.ofFn_succ] using he + have hz : z = z + u • (1 : ZMod p) := by + apply ZMod.val_injective + exact congrArg Fin.val hx + exact phase u hu hup (add_eq_left.mp hz.symm) + have hpos : 0 < indel (List.ofFn (W z)) (List.ofFn (W (z + u • (1 : ZMod p)))) := + Nat.pos_of_ne_zero (fun hh => hne ((cost_eq_zero_iff (s := false)).mp hh)) + have hlow : (1 : ℝ) ≤ indel (List.ofFn (W z)) (List.ofFn (W (z + u • (1 : ZMod p)))) := by + exact_mod_cast hpos + simpa using hlow + · intro H hH u hu hup + exact hH _ 2 ((memS _ _).mpr ⟨phase u hu hup, rfl⟩) + +end EditFamily + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/FamilyRecursion.lean b/lean/OAI/Combinatorics/EditDistance/FamilyRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..470ec64e5c2bfa5090ec0016ba15320dbe0bc47f --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/FamilyRecursion.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.EditDistance.RecursiveWords + +namespace OAI + +/-! +# Length, alphabet, and distortion recurrences for word families +-/ + +namespace EditFamily +open scoped BigOperators + +def familyLength (b P s : ℕ) : ℕ := (2 * (2 * b - 1) * P ^ (b / 2)) ^ s + +def familyAlphabet (b P : ℕ) : ℕ → ℕ + | 0 => 2 * P + | s+1 => 1 + (2 * b - 1) * familyAlphabet b P s + +noncomputable def familyAlpha (s : ℕ) : ℝ := (24 : ℝ)⁻¹ ^ s + +noncomputable def familyBudget (b P h : ℕ) : ℕ → ℝ + | 0 => 2 + | s+1 => 2 * (2 * (P : ℝ)) ^ (2 * h) / (P ^ (b / 2) : ℕ) + familyBudget b P h s / h + +lemma familyLength_pos {b P : ℕ} (hb : 0 < b) (hP : 0 < P) (s : ℕ) : + 0 < familyLength b P s := by + unfold familyLength + exact pow_pos (Nat.mul_pos (Nat.mul_pos (by omega) (by omega)) (pow_pos hP _)) _ + +lemma familyAlpha_pos (s : ℕ) : 0 < familyAlpha s := by + unfold familyAlpha + positivity + +lemma familyAlpha_le_one (s : ℕ) : familyAlpha s ≤ 1 := by + unfold familyAlpha + exact pow_le_one₀ (by norm_num) (by norm_num) + +lemma familyBudget_nonneg (b P h s : ℕ) : 0 ≤ familyBudget b P h s := by + induction s with + | zero => norm_num [familyBudget] + | succ s ih => + exact add_nonneg (by positivity) (div_nonneg ih (Nat.cast_nonneg _)) + +noncomputable def recursive {J : Type} [Fintype J] [DecidableEq J] + (p : J → ℕ) (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + (P : ℕ) (hP : 1 ≤ P) (hpLow : ∀ j, P ≤ p j) (hpHigh : ∀ j, p j ≤ 2 * P) + (h : ℕ) (hh : 0 < h) : (s : ℕ) → (j : J) → + Family (p j) (familyLength (Fintype.card J) P s) (familyAlphabet (Fintype.card J) P s) + (familyAlpha s) (familyBudget (Fintype.card J) P h s) + | 0, j => base (hp j) (hpHigh j) + | s+1, j => by + let F := recursive p hp hinj P hP hpLow hpHigh h hh s + have hn : familyLength (Fintype.card J) P (s+1) = + 2 * ((2 * Fintype.card J - 1) * familyLength (Fintype.card J) P s) * + P ^ (Fintype.card J / 2) := by + simp only [familyLength, pow_succ] + ring + have ha : familyAlpha (s+1) = familyAlpha s / 24 := by + simp only [familyAlpha, pow_succ, div_eq_mul_inv] + rw [hn, familyAlphabet, ha, familyBudget] + exact successor j F hp hinj P hP hpLow hpHigh + (familyLength_pos (Fintype.card_pos_iff.mpr ⟨j⟩) (by omega) s) + (familyAlpha_pos s).le (familyAlpha_le_one s) + (familyBudget_nonneg _ _ _ _) h hh + +lemma familyAlphabet_pos {b P : ℕ} (hP : 0 < P) (s : ℕ) : 0 < familyAlphabet b P s := by + cases s <;> simp only [familyAlphabet] <;> omega + +lemma familyAlphabet_le {b P : ℕ} (hb : 0 < b) (hP : 0 < P) (s : ℕ) : + familyAlphabet b P s ≤ (2 * P + 1) * (2 * b) ^ s := by + induction s with + | zero => simp [familyAlphabet] + | succ s ih => + have hap := familyAlphabet_pos (b := b) hP s + have hb' : 2 * b - 1 + 1 = 2 * b := by omega + calc + familyAlphabet b P (s+1) = 1 + (2 * b - 1) * familyAlphabet b P s := rfl + _ ≤ 2 * b * familyAlphabet b P s := by + nlinarith [Nat.mul_add (2 * b - 1) 1 (familyAlphabet b P s)] + _ ≤ 2 * b * ((2 * P + 1) * (2 * b) ^ s) := Nat.mul_le_mul_left _ ih + _ = (2 * P + 1) * (2 * b) ^ (s+1) := by rw [pow_succ]; ring + +end EditFamily + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/FiniteLower.lean b/lean/OAI/Combinatorics/EditDistance/FiniteLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..f65c7eddd5dc35613e2271bc2d7eeed3c8e13007 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/FiniteLower.lean @@ -0,0 +1,81 @@ +import OAI.Combinatorics.EditDistance.LowerParameters +import OAI.Combinatorics.EditDistance.LowerDistortion + +namespace OAI + +/-! +# Finite nonempty binary witnesses of a common length +-/ + +namespace EditLower +open EditDistortion EditFamily EditCode EditParameters + +noncomputable def binaryLabels (k : ℕ) : Fin (familyAlphabet (b k) (P k) k) ↪ (Fin (codeBits k) → Bool) := by + simpa only [codeBits,Fintype.card_fin] using labels (Fin (familyAlphabet (b k) (P k) k)) + +theorem family_ratio {k p : ℕ} (hk : 0 < k) (hp : 1 < p) + (F : Family p (familyLength (b k) (P k) k) (familyAlphabet (b k) (P k) k) + (familyAlpha k) (familyBudget (b k) (P k) (h k) k)) + (f : codeSet F (binaryLabels k) ↪ L1) : + lowerRatio k ≤ distortion (fun x y : codeSet F (binaryLabels k) => (edit x.val y.val : ℝ)) f := by + classical + let label := binaryLabels k + let : Fintype (codeSet F label) := (codeSet_finite F label).fintype + have hn := familyLength_pos (by dsimp [b]; omega : 0 < b k) (prime_parameter_pos hk) k + let : Nontrivial (codeSet F label) := codeSet_nontrivial F label hp hn (familyAlpha_pos k) + let D := distortion (fun x y : codeSet F label => (edit x.val y.val : ℝ)) f + have hD : 0 ≤ D := distortion_nonneg _ (fun x => edit_real_diag x.val) + (fun x y hxy => edit_real_pos x.val y.val (fun h => hxy (Subtype.ext h))) f + have hl := family_distortion F label hp hn (familyAlpha_pos k) f + change familyAlpha k ≤ 4*(codeWidth k : ℝ)*familyBudget (b k) (P k) (h k) k*D at hl + have hw : (0 : ℝ) < codeWidth k := by exact_mod_cast EditParameters.width_pos k + have hh : (0 : ℝ) < (h k : ℝ)^k := by dsimp [h]; positivity + have hb : familyAlpha k ≤ (16*(codeWidth k : ℝ)*D)/(h k : ℝ)^k := by + calc + _ ≤ 4*(codeWidth k : ℝ)*(4/(h k : ℝ)^k)*D := by + apply hl.trans + gcongr + exact budget_small hk + _ = _ := by ring + have hmul := (le_div_iff₀ hh).mp hb + have hpow : familyAlpha k*(h k : ℝ)^k = ((h k : ℝ)/24)^k := by + unfold familyAlpha + rw [←mul_pow] + congr 1 + ring + change ((h k : ℝ)/24)^k/(16*(codeWidth k : ℝ)) ≤ D + apply (div_le_iff₀ (by positivity : 0 < 16*(codeWidth k : ℝ))).mpr + rw [hpow] at hmul + nlinarith + +theorem eventually_depth_witness : ∀ᶠ k : ℕ in Filter.atTop, + ∃ S : Set (List Bool), S.Finite ∧ S.Nonempty ∧ S.Nontrivial ∧ + (∀ w ∈ S, w.length = encodedLength k) ∧ + lowerRatio k ≤ leastDistortion (fun x y : S => (edit x.val y.val : ℝ)) := by + classical + obtain ⟨B,hB⟩ := Filter.eventually_atTop.mp EditPrimes.eventually_pool_square + filter_upwards [Filter.eventually_ge_atTop (max 1 B)] with k hk + have hk0 : 0 < k := by omega + have hb0 : 0 < b k := by dsimp [b]; omega + have hpool := hB (b k) (by dsimp [b]; omega) + obtain ⟨p,hinj,hprime,hlow,hhigh⟩ := EditPrimes.primes_of_pool hpool + have hP : 1 ≤ P k := Nat.one_le_iff_ne_zero.mpr (prime_parameter_pos hk0).ne' + let j : Fin (b k) := ⟨0,hb0⟩ + let F : Family (p j) (familyLength (b k) (P k) k) (familyAlphabet (b k) (P k) k) + (familyAlpha k) (familyBudget (b k) (P k) (h k) k) := by + simpa only [Fintype.card_fin] using recursive p hprime hinj (P k) hP hlow hhigh + (h k) (by dsimp [h]; omega) k j + let S := codeSet F (binaryLabels k) + let : Fintype S := (codeSet_finite F (binaryLabels k)).fintype + refine ⟨S,codeSet_finite F (binaryLabels k),codeSet_nonempty F (binaryLabels k),?_,?_,?_⟩ + · exact Set.nontrivial_coe_sort.mp (codeSet_nontrivial F (binaryLabels k) (hprime j).one_lt + (familyLength_pos hb0 (prime_parameter_pos hk0) k) (familyAlpha_pos k)) + · intro w hw + exact codeSet_length F (binaryLabels k) w hw + · apply leastDistortion_lower + intro f + exact family_ratio hk0 (hprime j).one_lt F f + +end EditLower + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/FourierAverages.lean b/lean/OAI/Combinatorics/EditDistance/FourierAverages.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef17b4f37d59157af0ba05377c5bb6dc1996eff7 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/FourierAverages.lean @@ -0,0 +1,173 @@ +import OAI.Combinatorics.EditDistance.PrimeCharacters + +namespace OAI + +/-! +# Uniform averages and quadratic displacement on finite groups +-/ + +namespace EditFourier +open scoped BigOperators +open Finset + +noncomputable def quadraticVariation {R : Type*} [AddCommGroup R] [Fintype R] + (F : R → ℂ) (l : R) : ℝ := + (∑ t, ‖F (t + l) - F t‖ ^ 2) / (Fintype.card R : ℝ) + +section Torus +variable {J : Type*} [Fintype J] [DecidableEq J] +variable (p : J → ℕ) [∀ j, NeZero (p j)] + +lemma torus_variation_single (F : (∀ j, ZMod (p j)) → ℂ) (i : J) (u : ZMod (p i)) : + quadraticVariation F (Pi.single i u) = + ∑ lam, ‖fourier (torusCharacter p) F lam‖ ^ 2 * + ‖ZMod.stdAddChar (lam i * u) - 1‖ ^ 2 := by + rw [quadraticVariation, displacement_normalized _ (torusCharacter_primitive p)] + apply sum_congr rfl + intro lam _ + rw [mul_comm (Pi.single i u) lam] + rw [show torusCharacter p (lam * Pi.single i u) = ZMod.stdAddChar (lam i * u) from + productCharacter_single (fun j => ZMod.stdAddChar (N := p j)) lam i u] + +lemma torus_variation_average (F : (∀ j, ZMod (p j)) → ℂ) (i : J) : + (∑ u : ZMod (p i), quadraticVariation F (Pi.single i u)) / + (Fintype.card (ZMod (p i)) : ℝ) = + ∑ lam, ‖fourier (torusCharacter p) F lam‖ ^ 2 * + (if lam i = 0 then (0 : ℝ) else 2) := by + simp_rw [torus_variation_single p F i] + rw [sum_comm, sum_div] + apply sum_congr rfl + intro lam _ + rw [← mul_sum, mul_div_assoc, average_character_multiplier _ (ZMod.isPrimitive_stdAddChar _)] + +theorem torus_quadratic_comparison + (hcop : Pairwise (fun i j => (p i).Coprime (p j))) + (B : ℝ) (hB : 1 ≤ B) (hpB : ∀ j, (p j : ℝ) ≤ B) + (h : ℕ) (hh : 0 < h) (F : (∀ j, ZMod (p j)) → ℂ) (i : J) (u : ZMod (p i)) : + quadraticVariation F (Pi.single i u) ≤ + B ^ (2 * h) * quadraticVariation F 1 + (2 / (h : ℝ)) * + ∑ j, (∑ a : ZMod (p j), quadraticVariation F (Pi.single j a)) / + (Fintype.card (ZMod (p j)) : ℝ) := by + rw [torus_variation_single p] + calc + _ ≤ ∑ lam, ‖fourier (torusCharacter p) F lam‖ ^ 2 * + (B ^ (2 * h) * ‖torusCharacter p lam - 1‖ ^ 2 + + (2 / (h : ℝ)) * ∑ j, (if lam j = 0 then (0 : ℝ) else 2)) := by + apply sum_le_sum + intro lam _ + exact mul_le_mul_of_nonneg_left + (multiplier_comparison p hcop B hB hpB h hh lam i u) (sq_nonneg _) + _ = _ := by + simp_rw [torus_variation_average p, quadraticVariation, + displacement_normalized _ (torusCharacter_primitive p), one_mul, + mul_add, sum_add_distrib] + congr 1 + · simp_rw [mul_left_comm _ (B ^ (2 * h)), ← mul_sum] + · simp_rw [mul_left_comm _ (2 / (h : ℝ)), ← mul_sum, mul_sum] + rw [sum_comm] + +end Torus +end EditFourier + +namespace EditAverage +open scoped BigOperators +open Finset + +noncomputable def avg {X : Type*} [Fintype X] (f : X → ℝ) : ℝ := + (∑ x, f x) / (Fintype.card X : ℝ) + +lemma avg_nonneg {X : Type*} [Fintype X] {f : X → ℝ} (hf : ∀ x, 0 ≤ f x) : + 0 ≤ avg f := div_nonneg (sum_nonneg (fun x _ => hf x)) (Nat.cast_nonneg _) + +lemma avg_mono {X : Type*} [Fintype X] {f g : X → ℝ} (hf : ∀ x, f x ≤ g x) : + avg f ≤ avg g := div_le_div_of_nonneg_right (sum_le_sum (fun x _ => hf x)) (Nat.cast_nonneg _) + +lemma avg_const {X : Type*} [Fintype X] [Nonempty X] (c : ℝ) : + avg (fun _ : X => c) = c := by + simp [avg, Fintype.card_ne_zero] + +lemma avg_add {X : Type*} [Fintype X] (f g : X → ℝ) : + avg (f + g) = avg f + avg g := by simp only [avg, Pi.add_apply, sum_add_distrib, add_div] + +lemma avg_mul {X : Type*} [Fintype X] (c : ℝ) (f : X → ℝ) : + avg (fun x => c * f x) = c * avg f := by rw [avg, ← mul_sum, mul_div_assoc]; rfl + +lemma avg_sum {X Y : Type*} [Fintype X] [Fintype Y] (f : X → Y → ℝ) : + avg (fun x => ∑ y, f x y) = ∑ y, avg (fun x => f x y) := by + simp only [avg, ← sum_div] + rw [sum_comm] + +lemma avg_comm {X Y : Type*} [Fintype X] [Fintype Y] (f : X → Y → ℝ) : + avg (fun x => avg (f x)) = avg (fun y => avg (fun x => f x y)) := by + simp only [avg, ← sum_div, div_div] + rw [sum_comm, mul_comm] + +lemma avg_equiv {X Y : Type*} [Fintype X] [Fintype Y] (e : X ≃ Y) (f : Y → ℝ) : + avg (fun x => f (e x)) = avg f := by + rw [avg, avg, Fintype.card_congr e, Equiv.sum_comp] + +lemma avg_shift {G : Type*} [AddGroup G] [Fintype G] (f : G → ℝ) (g : G) : + avg (fun z => f (z + g)) = avg f := avg_equiv (Equiv.addRight g) f + +end EditAverage + +namespace EditFourier +open scoped BigOperators +open Finset EditAverage + +section Group +variable {G R : Type*} [AddCommGroup G] [Fintype G] [AddCommGroup R] [Fintype R] + +lemma quadraticVariation_eq_avg (F : G → ℂ) (l : G) : + quadraticVariation F l = avg (fun t => ‖F (t + l) - F t‖ ^ 2) := rfl + +lemma quadraticVariation_pullback_average (φ : R →+ G) (F : G → ℂ) (l : R) : + avg (fun c : G => quadraticVariation (fun t : R => F (c + φ t)) l) = + quadraticVariation F (φ l) := by + simp_rw [quadraticVariation_eq_avg, map_add, ← add_assoc] + rw [avg_comm] + have hshift (t : R) : + avg (fun c : G => ‖F (c + φ t + φ l) - F (c + φ t)‖ ^ 2) = + avg (fun c : G => ‖F (c + φ l) - F c‖ ^ 2) := + avg_shift (fun c : G => ‖F (c + φ l) - F c‖ ^ 2) (φ t) + simp_rw [hshift] + exact avg_const _ + +end Group + +section TorusGroup +variable {J : Type*} [Fintype J] [DecidableEq J] +variable (p : J → ℕ) [∀ j, NeZero (p j)] +variable {G : Type*} [AddCommGroup G] [Fintype G] + +theorem group_quadratic_comparison + (hcop : Pairwise (fun i j => (p i).Coprime (p j))) + (B : ℝ) (hB : 1 ≤ B) (hpB : ∀ j, (p j : ℝ) ≤ B) + (h : ℕ) (hh : 0 < h) (φ : (∀ j, ZMod (p j)) →+ G) + (F : G → ℂ) (i : J) (u : ZMod (p i)) : + quadraticVariation F (φ (Pi.single i u)) ≤ + B ^ (2 * h) * quadraticVariation F (φ 1) + (2 / (h : ℝ)) * + ∑ j, avg (fun a : ZMod (p j) => quadraticVariation F (φ (Pi.single j a))) := by + have hpoint (c : G) := torus_quadratic_comparison p hcop B hB hpB h hh + (fun t => F (c + φ t)) i u + have havg := avg_mono hpoint + change avg (fun c : G => quadraticVariation (fun t => F (c + φ t)) (Pi.single i u)) ≤ + avg (fun c : G => B ^ (2 * h) * quadraticVariation (fun t => F (c + φ t)) 1 + + (2 / (h : ℝ)) * ∑ j, avg (fun a : ZMod (p j) => + quadraticVariation (fun t => F (c + φ t)) (Pi.single j a))) at havg + rw [show (fun c : G => B ^ (2 * h) * quadraticVariation (fun t => F (c + φ t)) 1 + + (2 / (h : ℝ)) * ∑ j, avg (fun a : ZMod (p j) => + quadraticVariation (fun t => F (c + φ t)) (Pi.single j a))) = + (fun c => B ^ (2 * h) * quadraticVariation (fun t => F (c + φ t)) 1) + + (fun c => (2 / (h : ℝ)) * ∑ j, avg (fun a : ZMod (p j) => + quadraticVariation (fun t => F (c + φ t)) (Pi.single j a))) from rfl, + avg_add] at havg + simp_rw [avg_mul, avg_sum, avg_comm (fun c a => + quadraticVariation (fun t => F (c + φ t)) (Pi.single _ a)), + quadraticVariation_pullback_average] at havg + exact havg + +end TorusGroup +end EditFourier + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/FourierCharacters.lean b/lean/OAI/Combinatorics/EditDistance/FourierCharacters.lean new file mode 100644 index 0000000000000000000000000000000000000000..aba9a89004c547634498b37a9dc3f6b34a66d149 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/FourierCharacters.lean @@ -0,0 +1,214 @@ +import Mathlib + +namespace OAI + +/-! +# Finite Fourier inversion, Parseval, and character displacement +-/ + +namespace EditFourier +open scoped BigOperators +open Finset + +section FiniteRing +variable {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + +noncomputable def transform (ψ : AddChar R ℂ) (F : R → ℂ) (k : R) : ℂ := + ∑ t : R, ψ (-(t * k)) * F t + +theorem transform_twice (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (F : R → ℂ) : + transform ψ (transform ψ F) = fun j => (Fintype.card R : ℂ) * F (-j) := by + funext j + simp only [transform, mul_sum, ← mul_assoc, ← AddChar.map_add_eq_mul, ← neg_add, + mul_comm _ j, ← add_mul] + rw [sum_comm] + simp only [← sum_mul, ← neg_mul] + have h1 (t : R) : ∑ i, ψ (t * i) = if t = 0 then (Fintype.card R : ℂ) else 0 := by + simpa only [mul_comm, Nat.cast_ite, Nat.cast_zero] using AddChar.sum_mulShift t hψ + have h2 (x j : R) : -(j + x) = 0 ↔ x = -j := by + rw [neg_add, add_comm, add_eq_zero_iff_neg_eq, neg_neg] + simp only [h1, h2, ite_mul, zero_mul, sum_ite_eq', mem_univ, ite_true] + +omit [DecidableEq R] in +theorem transform_sub (ψ : AddChar R ℂ) (F G : R → ℂ) : + transform ψ (F - G) = transform ψ F - transform ψ G := by + funext k + simp only [transform, Pi.sub_apply, mul_sub, sum_sub_distrib] + +omit [DecidableEq R] in +theorem transform_shift (ψ : AddChar R ℂ) (F : R → ℂ) (l k : R) : + transform ψ (fun t => F (t + l)) k = ψ (l * k) * transform ψ F k := by + classical + calc + _ = ∑ t : R, ψ (-((t - l) * k)) * F t := by + apply Fintype.sum_equiv (Equiv.addRight l) + intro t + simp + _ = ψ (l * k) * transform ψ F k := by + rw [transform, mul_sum] + apply sum_congr rfl + intro t _ + rw [sub_mul, neg_sub, sub_eq_add_neg, AddChar.map_add_eq_mul] + ring + +omit [DecidableEq R] in +theorem transform_pairing (ψ : AddChar R ℂ) (F G : R → ℂ) : + ∑ k, transform ψ F k * G k = ∑ t, F t * transform ψ G t := by + simp only [transform, sum_mul, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro t _ + apply sum_congr rfl + intro k _ + rw [mul_comm k t] + ring + +omit [DecidableEq R] in +theorem transform_conj (ψ : AddChar R ℂ) (F : R → ℂ) (k : R) : + transform ψ (fun t => (starRingEnd ℂ) (F t)) k = + (starRingEnd ℂ) (transform ψ F (-k)) := by + simp only [transform, map_sum, map_mul] + apply sum_congr rfl + intro t _ + rw [← AddChar.map_neg_eq_conj] + congr 2 + ring + +theorem parseval (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (F : R → ℂ) : + ∑ k, ‖transform ψ F k‖ ^ 2 = (Fintype.card R : ℝ) * ∑ t, ‖F t‖ ^ 2 := by + simp only [← Complex.normSq_eq_norm_sq] + apply Complex.ofReal_injective + push_cast + simp only [← Complex.mul_conj] + rw [transform_pairing] + simp only [transform_conj, transform_twice ψ hψ F, neg_neg, map_mul, + map_natCast, Finset.mul_sum] + apply sum_congr rfl + intro t _ + ring + +theorem displacement (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (F : R → ℂ) (l : R) : + (Fintype.card R : ℝ) * ∑ t, ‖F (t + l) - F t‖ ^ 2 = + ∑ k, ‖transform ψ F k‖ ^ 2 * ‖ψ (l * k) - 1‖ ^ 2 := by + rw [← parseval ψ hψ (fun t => F (t + l) - F t)] + have ht : transform ψ (fun t => F (t + l) - F t) = + fun k => (ψ (l * k) - 1) * transform ψ F k := by + rw [show (fun t => F (t + l) - F t) = (fun t => F (t + l)) - F from rfl, + transform_sub] + funext k + simp only [Pi.sub_apply, transform_shift] + ring + rw [ht] + apply sum_congr rfl + intro k _ + rw [norm_mul, mul_pow, mul_comm] + +noncomputable def fourier (ψ : AddChar R ℂ) (F : R → ℂ) (k : R) : ℂ := + transform ψ F k / (Fintype.card R : ℂ) + +theorem displacement_normalized (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) + (F : R → ℂ) (l : R) : + (∑ t, ‖F (t + l) - F t‖ ^ 2) / (Fintype.card R : ℝ) = + ∑ k, ‖fourier ψ F k‖ ^ 2 * ‖ψ (l * k) - 1‖ ^ 2 := by + have hn : (Fintype.card R : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + simp only [fourier, norm_div, Complex.norm_natCast, div_pow, div_mul_eq_mul_div, + ← sum_div] + apply (eq_div_iff (pow_ne_zero 2 hn)).mpr + rw [← displacement ψ hψ F l] + field_simp + +end FiniteRing + +section ProductCharacter +variable {J : Type*} [Fintype J] [DecidableEq J] +variable {A : J → Type*} [∀ j, CommRing (A j)] + +noncomputable def productCharacter (ψ : ∀ j, AddChar (A j) ℂ) : + AddChar (∀ j, A j) ℂ where + toFun x := ∏ j, ψ j (x j) + map_zero_eq_one' := by simp + map_add_eq_mul' x y := by simp [AddChar.map_add_eq_mul, prod_mul_distrib] + +theorem productCharacter_single (ψ : ∀ j, AddChar (A j) ℂ) + (a : ∀ j, A j) (j : J) (x : A j) : + (productCharacter ψ) (a * Pi.single j x) = ψ j (a j * x) := by + change ∏ i, ψ i (a i * Pi.single j x i) = _ + rw [prod_eq_single j] + · simp + · intro i _ hi + simp [Pi.single_eq_of_ne hi] + · simp + +theorem productCharacter_primitive (ψ : ∀ j, AddChar (A j) ℂ) + (hψ : ∀ j, (ψ j).IsPrimitive) : (productCharacter ψ).IsPrimitive := by + intro a ha h + apply ha + funext j + by_contra hj + apply hψ j hj + ext x + have hx := DFunLike.congr_fun h (Pi.single j x) + simpa only [AddChar.mulShift_apply, productCharacter_single, AddChar.one_apply] using hx + +noncomputable def torusCharacter (p : J → ℕ) [∀ j, NeZero (p j)] : + AddChar (∀ j, ZMod (p j)) ℂ := + productCharacter (fun j => ZMod.stdAddChar (N := p j)) + +theorem torusCharacter_primitive (p : J → ℕ) [∀ j, NeZero (p j)] : + (torusCharacter p).IsPrimitive := + productCharacter_primitive _ (fun j => ZMod.isPrimitive_stdAddChar (p j)) + +end ProductCharacter +end EditFourier + +namespace EditFourier +open scoped BigOperators +open Finset + +theorem norm_pow_sub_one_le (z : ℂ) (hz : ‖z‖ = 1) (n : ℕ) : + ‖z ^ n - 1‖ ≤ (n : ℝ) * ‖z - 1‖ := by + induction n with + | zero => simp + | succ n ih => + calc + ‖z ^ (n + 1) - 1‖ = ‖z * (z ^ n - 1) + (z - 1)‖ := by + congr 1 + rw [pow_succ'] + ring + _ ≤ ‖z * (z ^ n - 1)‖ + ‖z - 1‖ := norm_add_le _ _ + _ = ‖z ^ n - 1‖ + ‖z - 1‖ := by rw [norm_mul, hz, one_mul] + _ ≤ (n : ℝ) * ‖z - 1‖ + ‖z - 1‖ := add_le_add ih le_rfl + _ = ((n + 1 : ℕ) : ℝ) * ‖z - 1‖ := by push_cast; ring + +theorem root_separation (z : ℂ) (hz : ‖z‖ = 1) (hne : z ≠ 1) + (q : ℕ) (hq : 0 < q) (hpow : z ^ q = 1) : + 2 ≤ (q : ℝ) * ‖z - 1‖ := by + have hs : ∑ i ∈ range q, z ^ i = 0 := by + apply eq_zero_of_ne_zero_of_mul_left_eq_zero (sub_ne_zero.mpr hne.symm) + rw [mul_neg_geom_sum, hpow, sub_self] + have heq : (q : ℝ) = ‖∑ i ∈ range q, (1 - z ^ i)‖ := by + simp [sum_sub_distrib, hs] + have hbound : (q : ℝ) ≤ (∑ i ∈ range q, (i : ℝ)) * ‖z - 1‖ := by + rw [heq] + calc + _ ≤ ∑ i ∈ range q, ‖1 - z ^ i‖ := norm_sum_le _ _ + _ ≤ ∑ i ∈ range q, (i : ℝ) * ‖z - 1‖ := by + apply sum_le_sum + intro i _ + rw [norm_sub_rev] + exact norm_pow_sub_one_le z hz i + _ = _ := by rw [sum_mul] + have hid : (∑ i ∈ range q, (i : ℝ)) * 2 = (q : ℝ) * ((q : ℝ) - 1) := by + have ht := congrArg (fun a : ℕ => (a : ℝ)) (sum_range_id_mul_two q) + push_cast [Nat.cast_sub (Nat.succ_le_of_lt hq)] at ht + exact ht + have hnn := norm_nonneg (z - 1) + have hm := congrArg (fun x : ℝ => x * ‖z - 1‖) hid + have hp : (0 : ℝ) < q := Nat.cast_pos.mpr hq + have hh : (q : ℝ) * 2 ≤ (q : ℝ) * ((q : ℝ) * ‖z - 1‖) := by + nlinarith + exact (mul_le_mul_iff_right₀ hp).mp hh + +end EditFourier + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/HashCuts.lean b/lean/OAI/Combinatorics/EditDistance/HashCuts.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddf1b532028b63fd2e34248029c06d85367bfbcb --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/HashCuts.lean @@ -0,0 +1,112 @@ +import Mathlib + +namespace OAI + +/-! +# Finite cut hashes and averaged separation +-/ + +namespace EditCutHash +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset + +noncomputable def sep {X : Type*} (x y : X) : ℝ := if x = y then 0 else 1 +lemma sep_nonneg {X : Type*} (x y : X) : 0 ≤ sep x y := by unfold sep; split <;> norm_num +lemma sep_le_one {X : Type*} (x y : X) : sep x y ≤ 1 := by unfold sep; split <;> norm_num +@[simp] lemma sep_self {X : Type*} (x : X) : sep x x = 0 := by simp [sep] +lemma sep_eq_one {X : Type*} {x y : X} (h : x ≠ y) : sep x y = 1 := by simp [sep,h] + +section Hash +variable {I X : Type*} [Fintype I] + +noncomputable def distance (w : I → ℝ) (c : I → X → Bool) (x y : X) : ℝ := + ∑ i, w i * sep (c i x) (c i y) + +lemma distance_nonneg {w : I → ℝ} (hw : ∀ i, 0 ≤ w i) (c : I → X → Bool) (x y : X) : + 0 ≤ distance w c x y := sum_nonneg (fun i _ => mul_nonneg (hw i) (sep_nonneg _ _)) + +noncomputable def coin (w : I → ℝ) (a : ℝ) (i : I) (b : Bool) : ℝ := + if b then 1-Real.exp (-a*w i) else Real.exp (-a*w i) + +noncomputable def probability (w : I → ℝ) (a : ℝ) (h : I → Bool) : ℝ := + ∏ i, coin w a i (h i) + +def key (c : I → X → Bool) (h : I → Bool) (x : X) : I → Bool := + fun i => h i && c i x + +omit [Fintype I] in +lemma coin_sum (w : I → ℝ) (a : ℝ) (i : I) : ∑ b : Bool, coin w a i b = 1 := by + simp [coin] + +lemma probability_nonneg {w : I → ℝ} (hw : ∀ i, 0 ≤ w i) {a : ℝ} (ha : 0 ≤ a) + (h : I → Bool) : 0 ≤ probability w a h := by + apply prod_nonneg + intro i _ + unfold coin + split + · have hb : Real.exp (-a*w i) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [hw i]) + linarith + · exact (Real.exp_pos _).le + +lemma probability_sum (w : I → ℝ) (a : ℝ) : ∑ h : I → Bool, probability w a h = 1 := by + classical + unfold probability + rw [←Fintype.prod_sum] + simp only [coin_sum,prod_const_one] + +lemma collision_indicator (c : I → X → Bool) (h : I → Bool) (x y : X) : + (if key c h x = key c h y then (1 : ℝ) else 0) = + ∏ i, if (h i && c i x) = (h i && c i y) then (1 : ℝ) else 0 := by + classical + by_cases he : key c h x = key c h y + · rw [ite_eq_left he] + have hh (i : I) : (h i && c i x) = (h i && c i y) := congrFun he i + simp only [hh,ite_true,prod_const_one] + · rw [ite_eq_right he] + have hex : ∃ i, (h i && c i x) ≠ (h i && c i y) := by + by_contra hn + push Not at hn + exact he (funext hn) + obtain ⟨i,hi⟩ := hex + symm + exact prod_eq_zero (mem_univ i) (ite_eq_right hi) + +theorem collision_probability (w : I → ℝ) (a : ℝ) (c : I → X → Bool) (x y : X) : + (∑ h : I → Bool, probability w a h * + if key c h x = key c h y then (1 : ℝ) else 0) = Real.exp (-a*distance w c x y) := by + classical + simp_rw [collision_indicator,probability,←prod_mul_distrib] + rw [←Fintype.prod_sum (fun (i : I) (b : Bool) => coin w a i b * + (if (b && c i x) = (b && c i y) then (1 : ℝ) else 0))] + have hf (i : I) : (∑ b : Bool, coin w a i b * + if (b && c i x) = (b && c i y) then (1 : ℝ) else 0) = + Real.exp (-a*(w i*sep (c i x) (c i y))) := by + cases hx : c i x <;> cases hy : c i y <;> simp [coin,sep] + simp_rw [hf] + rw [←Real.exp_sum] + congr 1 + simp only [distance,mul_sum] + +lemma separation_probability (w : I → ℝ) (a : ℝ) (c : I → X → Bool) (x y : X) : + (∑ h : I → Bool, probability w a h * sep (key c h x) (key c h y)) = + 1-Real.exp (-a*distance w c x y) := by + classical + have hs (h : I → Bool) : sep (key c h x) (key c h y) = + 1-(if key c h x = key c h y then (1 : ℝ) else 0) := by + unfold sep + split <;> norm_num + simp_rw [hs,mul_sub,mul_one] + rw [sum_sub_distrib,probability_sum,collision_probability] + +lemma separation_bound (w : I → ℝ) (a : ℝ) (c : I → X → Bool) (x y : X) : + (∑ h : I → Bool, probability w a h * sep (key c h x) (key c h y)) ≤ + a*distance w c x y := by + rw [separation_probability] + have hh := Real.add_one_le_exp (-a*distance w c x y) + linarith + +end Hash +end EditCutHash + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Histograms.lean b/lean/OAI/Combinatorics/EditDistance/Histograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..52a025b2ce4c3df995f99dc009f6ad18e8a15c46 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Histograms.lean @@ -0,0 +1,123 @@ +import OAI.Combinatorics.EditDistance.HashCuts + +namespace OAI + +/-! +# Hash separation and finite histogram inequalities +-/ + +namespace EditCutHash +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset + +section Histogram +variable {J K : Type*} [Fintype J] [Fintype K] + +noncomputable def hit (a b : K) : ℝ := if a = b then 1 else 0 +omit [Fintype K] in +lemma hit_nonneg (a b : K) : 0 ≤ hit a b := by unfold hit; split <;> norm_num +omit [Fintype K] in +lemma hit_le_one (a b : K) : hit a b ≤ 1 := by unfold hit; split <;> norm_num +omit [Fintype K] in +@[simp] lemma hit_self (a : K) : hit a a = 1 := by simp [hit] + +noncomputable def count (f : J → K) (z : K) : ℝ := ∑ j, hit (f j) z +noncomputable def histogramDistance (f g : J → K) : ℝ := ∑ z, |count f z-count g z| + +omit [Fintype K] in +lemma count_nonneg (f : J → K) (z : K) : 0 ≤ count f z := sum_nonneg (fun _ _ => hit_nonneg _ _) +lemma histogramDistance_nonneg (f g : J → K) : 0 ≤ histogramDistance f g := + sum_nonneg (fun _ _ => abs_nonneg _) + +lemma hit_sum (a : K) : ∑ z, hit a z = 1 := by + classical + simp [hit] + +lemma count_sum (f : J → K) : ∑ z, count f z = Fintype.card J := by + unfold count + rw [sum_comm] + simp only [hit_sum,sum_const,card_univ,nsmul_eq_mul,mul_one] + +lemma hit_distance (a b : K) : ∑ z, |hit a z-hit b z| = 2*sep a b := by + classical + by_cases hab : a = b + · subst b + simp [sep] + · have he (z : K) : |hit a z-hit b z| = hit a z+hit b z := by + by_cases haz : a = z + · subst z + simp [hit,Ne.symm hab] + · by_cases hbz : b = z + · subst z + simp [hit,hab] + · simp [hit,haz,hbz] + simp_rw [he] + rw [sum_add_distrib,hit_sum,hit_sum,sep_eq_one hab] + norm_num + +lemma histogramDistance_le (f g : J → K) : histogramDistance f g ≤ 2*∑ j, sep (f j) (g j) := by + unfold histogramDistance count + simp_rw [←sum_sub_distrib] + calc + _ ≤ ∑ z : K, ∑ j : J, |hit (f j) z-hit (g j) z| := + sum_le_sum (fun _ _ => abs_sum_le_sum_abs _ _) + _ = 2*∑ j, sep (f j) (g j) := by + rw [sum_comm] + simp_rw [hit_distance] + rw [mul_sum] + +lemma histogramDistance_disjoint (f g : J → K) (h : ∀ i j, f i ≠ g j) : + histogramDistance f g = 2*(Fintype.card J : ℝ) := by + have hzero (z : K) : count f z = 0 ∨ count g z = 0 := by + by_cases hf : ∃ i, f i = z + · obtain ⟨i,rfl⟩ := hf + right + unfold count + apply sum_eq_zero + intro j _ + exact ite_eq_right (Ne.symm (h i j)) + · left + unfold count + apply sum_eq_zero + intro i _ + exact ite_eq_right (fun he => hf ⟨i,he⟩) + have he (z : K) : |count f z-count g z| = count f z+count g z := by + rcases hzero z with hz|hz + · rw [hz,zero_sub,abs_neg,abs_of_nonneg (count_nonneg g z),zero_add] + · rw [hz,sub_zero,abs_of_nonneg (count_nonneg f z),add_zero] + unfold histogramDistance + simp_rw [he] + rw [sum_add_distrib,count_sum,count_sum] + ring + +lemma histogramDistance_lower (f g : J → K) : + 2*(Fintype.card J : ℝ)*(1-∑ i : J, ∑ j : J, hit (f i) (g j)) ≤ + histogramDistance f g := by + classical + by_cases h : ∀ i j, f i ≠ g j + · rw [histogramDistance_disjoint f g h] + have hz : (∑ i : J, ∑ j : J, hit (f i) (g j)) = 0 := by + apply sum_eq_zero + intro i _ + apply sum_eq_zero + intro j _ + exact ite_eq_right (h i j) + rw [hz] + ring_nf + rfl + · push Not at h + obtain ⟨i,j,hij⟩ := h + have h1 : 1 ≤ ∑ k : J, hit (f i) (g k) := by + have hh := single_le_sum (fun k _ => hit_nonneg (f i) (g k)) (mem_univ j) + simpa only [hij,hit_self] using hh + have h2 : (∑ k : J, hit (f i) (g k)) ≤ ∑ l : J, ∑ k : J, hit (f l) (g k) := + single_le_sum (fun l _ => sum_nonneg (fun k _ => hit_nonneg (f l) (g k))) (mem_univ i) + have hh : 1-∑ l : J, ∑ k : J, hit (f l) (g k) ≤ 0 := by linarith + exact (mul_nonpos_of_nonneg_of_nonpos (by positivity) hh).trans + (histogramDistance_nonneg f g) + +end Histogram +end EditCutHash + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/LowerBound.lean b/lean/OAI/Combinatorics/EditDistance/LowerBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..8abeaabdb0345e7566e4a37fcdfca7d342a18090 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/LowerBound.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.EditDistance.DepthInversion +import OAI.Combinatorics.EditDistance.FiniteLower +import OAI.Combinatorics.EditDistance.DistortionMonotonicity + +namespace OAI + +/-! +# Binary witnesses for every sufficiently large length bound +-/ + +namespace EditLower + +universe u + +open EditDistortion EditParameters Filter + +theorem eventually_length_witness : ∀ᶠ d : ℕ in atTop, + ∃ n : ℕ, n ≤ d ∧ ∃ S : Set (List Bool), S.Finite ∧ S.Nonempty ∧ S.Nontrivial ∧ + (∀ w ∈ S, w.length = n) ∧ + exponentScale (1/1200) d ≤ leastDistortion (fun x y : S => (edit x.val y.val : ℝ)) := by + obtain ⟨K,hK⟩ := eventually_atTop.mp eventually_depth_witness + let J := max (max K (24^4)) 2 + have hlim : Tendsto (fun d : ℕ => Real.log (d : ℝ)) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hchoose := hlim.eventually (EditDepth.eventually_choose_depth J) + filter_upwards [hchoose,eventually_ge_atTop 1] with d hd hd1 + let k := EditDepth.depth (Real.log (d : ℝ)) + have hk : J ≤ k := hd.1 + have hkK : K ≤ k := (le_max_left K (24^4)).trans ((le_max_left _ _).trans hk) + have hk24 : 24^4 ≤ k := (le_max_right K (24^4)).trans ((le_max_left _ _).trans hk) + have hk2 : 2 ≤ k := (le_max_right _ _).trans hk + have hk0 : 0 < k := by omega + obtain ⟨S,hfin,hne,hnt,hlen,hD⟩ := hK k hkK + have hn : encodedLength k ≤ d := by + have hlog : Real.log (encodedLength k : ℝ) ≤ Real.log (d : ℝ) := + (log_length_bound hk2).trans hd.2.1 + have hnp : (0 : ℝ) < encodedLength k := by exact_mod_cast encodedLength_pos hk0 + have hdp : (0 : ℝ) < d := by exact_mod_cast hd1 + exact_mod_cast (Real.log_le_log_iff hnp hdp).mp hlog + refine ⟨encodedLength k,hn,S,hfin,hne,hnt,hlen,?_⟩ + apply le_trans ?_ ((ratio_exponential hk24).trans hD) + apply Real.exp_le_exp.mpr + simpa only [div_eq_mul_inv,mul_comm,one_mul,k] using hd.2.2 + +theorem lower_main : ∃ c : ℝ, 0 < c ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → + (∀ (Alpha : Type u) [Fintype Alpha], 2 ≤ Fintype.card Alpha → + exponentScale c d ≤ E Alpha d) ∧ BinaryWitness c d := by + obtain ⟨d₀,hd₀⟩ := eventually_atTop.mp eventually_length_witness + refine ⟨1/1200,by norm_num,d₀,?_⟩ + intro d hd + obtain ⟨n,hn,S,hfin,hne,hnt,hlen,hD⟩ := hd₀ d hd + constructor + · intro Alpha inst hAlpha + exact hD.trans (binary_subset_lower Alpha hAlpha hn S hfin hnt hlen) + · exact ⟨n,hn,S,hfin,hne,hlen,hD⟩ + +end EditLower + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/LowerDistortion.lean b/lean/OAI/Combinatorics/EditDistance/LowerDistortion.lean new file mode 100644 index 0000000000000000000000000000000000000000..553cf4679888067c99ea3e9e1672c5357cd89646 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/LowerDistortion.lean @@ -0,0 +1,113 @@ +import OAI.Combinatorics.EditDistance.BinaryEmbedding +import OAI.Combinatorics.EditDistance.Distortion +import OAI.Combinatorics.EditDistance.Families + +namespace OAI + +/-! +# Distortion lower bounds from separated finite word families +-/ + +namespace EditLower +open EditDistortion EditFamily EditCode EditAverage EditFourier + +variable {p n A t : ℕ} {α Q : ℝ} (F : Family p n A α Q) + (label : Fin A ↪ (Fin t → Bool)) + +def codeWord (z : F.State) : List Bool := encode label (List.ofFn (F.word z)) +def codeSet : Set (List Bool) := Set.range (codeWord F label) +def codePoint (z : F.State) : codeSet F label := ⟨codeWord F label z,⟨z,rfl⟩⟩ + +lemma codeSet_finite : (codeSet F label).Finite := Set.finite_range _ +lemma codeSet_nonempty : (codeSet F label).Nonempty := ⟨_,⟨0,rfl⟩⟩ +lemma codeSet_length (x : List Bool) (hx : x ∈ codeSet F label) : x.length = width t*n := by + obtain ⟨z,rfl⟩ := hx + simp only [codeWord,encode_length,List.length_ofFn] + +lemma far_after_code (hp : 1 < p) (z : F.State) : + (n : ℝ)*α ≤ 4*(edit (codeWord F label z) (codeWord F label (z+F.v)) : ℝ) := by + have hf := F.far z 1 (by omega) hp + simp only [one_nsmul] at hf + have hc := indel_code_lower label label.injective (List.ofFn (F.word z)) + (List.ofFn (F.word (z+F.v))) 0 0 + simp only [padded,List.replicate_zero,List.append_nil] at hc + have he := indel_le_two_edit (codeWord F label z) (codeWord F label (z+F.v)) + have hcR : (indel (List.ofFn (F.word z)) (List.ofFn (F.word (z+F.v))) : ℝ) ≤ + 2*(indel (codeWord F label z) (codeWord F label (z+F.v)) : ℝ) := by exact_mod_cast hc + have heR : (indel (codeWord F label z) (codeWord F label (z+F.v)) : ℝ) ≤ + 2*(edit (codeWord F label z) (codeWord F label (z+F.v)) : ℝ) := by exact_mod_cast he + linarith + +lemma codeSet_nontrivial (hp : 1 < p) (hn : 0 < n) (ha : 0 < α) : Nontrivial (codeSet F label) := by + have h := far_after_code F label hp 0 + refine ⟨⟨codePoint F label 0,codePoint F label (0+F.v),?_⟩⟩ + intro he + have he' : codeWord F label 0 = codeWord F label (0+F.v) := congrArg Subtype.val he + rw [←he',edit_real_diag] at h + have : (0 : ℝ) < n := by exact_mod_cast hn + nlinarith + +theorem family_distortion (hp : 1 < p) (hn : 0 < n) (ha : 0 < α) + (f : codeSet F label ↪ L1) : + α ≤ 4*(width t : ℝ)*Q*distortion (fun x y : codeSet F label => (edit x.val y.val : ℝ)) f := by + classical + let : Fintype (codeSet F label) := (codeSet_finite F label).fintype + let : Nontrivial (codeSet F label) := codeSet_nontrivial F label hp hn ha + let ρ : codeSet F label → codeSet F label → ℝ := fun x y => (edit x.val y.val : ℝ) + obtain ⟨U,V,hU,hV,hD,hu,hv⟩ := distortion_constants ρ + (fun x => edit_real_diag x.val) + (fun x y hxy => edit_real_pos x.val y.val (fun h => hxy (Subtype.ext h))) f + let C : ℝ := U*(width t : ℝ)*n + have hnR : (0 : ℝ) < n := by exact_mod_cast hn + have hwR : (0 : ℝ) < width t := by exact_mod_cast EditCode.width_pos (t := t) + have hC : 0 < C := by dsimp [C]; positivity + let H : F.State → L1 := fun z => C⁻¹ • f (codePoint F label z) + have hnorm (z e : F.State) : ‖H (z+e)-H z‖ = + ‖f (codePoint F label (z+e))-f (codePoint F label z)‖/C := by + simp only [H,←smul_sub,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hC),div_eq_mul_inv,mul_comm] + have hnorm' (z e : F.State) : ‖f (codePoint F label (z+e))-f (codePoint F label z)‖ = + C*‖H (z+e)-H z‖ := by rw [hnorm]; field_simp + have hcheap (e : F.State) (r : ℝ) (hr : (e,r) ∈ F.steps) : variation H e ≤ r := by + unfold variation + rw [←avg_const (X := F.State) r] + apply avg_mono + intro z + rw [hnorm,div_le_iff₀ hC,norm_sub_rev] + have h1 := hu (codePoint F label z) (codePoint F label (z+e)) + have h2 := edit_le_indel (codeWord F label z) (codeWord F label (z+e)) + have h3 := indel_code_upper label (List.ofFn (F.word z)) (List.ofFn (F.word (z+e))) + have h23 : (edit (codeWord F label z) (codeWord F label (z+e)) : ℝ) ≤ + (width t : ℝ)*(indel (List.ofFn (F.word z)) (List.ofFn (F.word (z+e))) : ℝ) := by + exact_mod_cast h2.trans h3 + have h4 := F.cheap e r hr z + change ‖f (codePoint F label z)-f (codePoint F label (z+e))‖ ≤ + U*(edit (codeWord F label z) (codeWord F label (z+e)) : ℝ) at h1 + calc + _ ≤ U*((width t : ℝ)*((n : ℝ)*r)) := h1.trans (mul_le_mul_of_nonneg_left + (h23.trans (mul_le_mul_of_nonneg_left h4 hwR.le)) hU.le) + _ = r*C := by dsimp [C]; ring + have hbound := F.control H hcheap 1 (by omega) hp + simp only [one_nsmul] at hbound + have hfar (z : F.State) : (n : ℝ)*α ≤ 4*V*C*‖H (z+F.v)-H z‖ := by + have h1 := far_after_code F label hp z + have h2 := hv (codePoint F label z) (codePoint F label (z+F.v)) + change (edit (codeWord F label z) (codeWord F label (z+F.v)) : ℝ) ≤ + V*‖f (codePoint F label z)-f (codePoint F label (z+F.v))‖ at h2 + rw [norm_sub_rev,hnorm'] at h2 + nlinarith + have havg : (n : ℝ)*α ≤ 4*V*C*variation H F.v := by + change (n : ℝ)*α ≤ 4*V*C*avg (fun z => ‖H (z+F.v)-H z‖) + rw [←avg_mul,←avg_const (X := F.State) ((n : ℝ)*α)] + exact avg_mono hfar + have hfinal : (n : ℝ)*α ≤ (n : ℝ)*(4*(width t : ℝ)*Q*(U*V)) := by + calc + _ ≤ 4*V*C*Q := havg.trans (mul_le_mul_of_nonneg_left hbound (by positivity)) + _ = _ := by dsimp [C]; ring + have hcancel := (mul_le_mul_iff_right₀ hnR).mp hfinal + change α ≤ 4*(width t : ℝ)*Q*distortion ρ f + rw [hD] + exact hcancel + +end EditLower + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/LowerParameters.lean b/lean/OAI/Combinatorics/EditDistance/LowerParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cfb0d9cf9924114620862e7db3f1faa0647ed29 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/LowerParameters.lean @@ -0,0 +1,226 @@ +import OAI.Combinatorics.EditDistance.PrimePool +import OAI.Combinatorics.EditDistance.FamilyRecursion + +namespace OAI + +/-! +# Recursive parameter bounds and exponential lower scales +-/ + +namespace EditParameters +open EditFamily + +def b (k : ℕ) := 100*k +def P (k : ℕ) := (b k)^2 +def h (k : ℕ) := 10*k +noncomputable def eta (k : ℕ) : ℝ := 2 * (2 * (P k : ℝ)) ^ (2 * h k) / ((P k) ^ (b k / 2) : ℕ) + +lemma prime_parameter_pos {k : ℕ} (hk : 0 < k) : 0 < P k := by + unfold P b + positivity + +lemma eta_numerator_bound {k : ℕ} (hk : 0 < k) : + 2 * (2 * P k) ^ (2 * h k) * (h k)^k ≤ (P k) ^ (b k / 2) := by + have hp : 4 ≤ P k := by dsimp [P,b]; nlinarith + have hh : h k ≤ P k := by dsimp [h,P,b]; nlinarith + have hpow : (2 * P k)^2 ≤ (P k)^3 := by nlinarith + have he1 : 2*h k = 2*(10*k) := by rfl + have he2 : b k / 2 = 50*k := by dsimp [b]; omega + have htwo : 2 ≤ (P k)^k := le_trans (by omega : 2 ≤ P k) + (Nat.le_self_pow (by omega) _) + calc + 2 * (2*P k)^(2*h k) * (h k)^k ≤ + (P k)^k * ((P k)^3)^(10*k) * (P k)^k := by + rw [he1,pow_mul] + gcongr + _ = (P k)^(32*k) := by rw [←pow_mul,←pow_add,←pow_add]; congr 1; omega + _ ≤ (P k)^(b k / 2) := Nat.pow_le_pow_right (by omega) (by rw [he2]; omega) + +lemma eta_le {k : ℕ} (hk : 0 < k) : eta k ≤ 1 / (h k : ℝ)^k := by + have hp : (0 : ℝ) < ((P k)^(b k/2) : ℕ) := by + exact_mod_cast pow_pos (prime_parameter_pos hk) _ + have hh : (0 : ℝ) < (h k : ℝ)^k := by dsimp [h]; positivity + apply (div_le_div_iff₀ hp hh).mpr + simpa only [one_mul,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat] using + (show (2 : ℝ) * (2*(P k : ℝ))^(2*h k) * (h k : ℝ)^k ≤ ((P k)^(b k/2) : ℕ) by + exact_mod_cast eta_numerator_bound hk) + +lemma budget_bound {k : ℕ} (hk : 0 < k) (s : ℕ) : + familyBudget (b k) (P k) (h k) s ≤ 2/(h k : ℝ)^s + 2*eta k := by + have hp : (0 : ℝ) < h k := by dsimp [h]; positivity + have htwo : (2 : ℝ) ≤ h k := by exact_mod_cast (show 2 ≤ h k by dsimp [h]; omega) + have he : 0 ≤ eta k := by dsimp [eta]; positivity + induction s with + | zero => simp only [familyBudget,pow_zero,div_one]; linarith + | succ s ih => + change eta k + familyBudget (b k) (P k) (h k) s / h k ≤ _ + calc + _ ≤ eta k + (2/(h k : ℝ)^s+2*eta k)/(h k) := by gcongr + _ = 2/(h k : ℝ)^(s+1) + (eta k + 2*eta k/(h k)) := by + rw [pow_succ]; field_simp; ring + _ ≤ 2/(h k : ℝ)^(s+1) + 2*eta k := by + have ht : 2*eta k/(h k) ≤ eta k := (div_le_iff₀ hp).mpr (by nlinarith) + linarith + +theorem budget_small {k : ℕ} (hk : 0 < k) : + familyBudget (b k) (P k) (h k) k ≤ 4/(h k : ℝ)^k := by + have h1 := budget_bound hk k + have h2 := eta_le hk + simp only [div_eq_mul_inv,one_mul] at * + linarith + +def codeBits (k : ℕ) := Nat.clog 2 (familyAlphabet (b k) (P k) k) +def codeWidth (k : ℕ) := 2*codeBits k+3 +def encodedLength (k : ℕ) := codeWidth k * familyLength (b k) (P k) k + +lemma alphabet_power_bound {k : ℕ} (hk : 0 < k) : + familyAlphabet (b k) (P k) k ≤ 2^(30*k^2) := by + have hb : 0 < b k := by dsimp [b]; omega + have hp : 0 < P k := prime_parameter_pos hk + have hkb : k ≤ 2^k := Nat.lt_two_pow_self.le + have hbpow : 2*b k ≤ 2^(k+8) := by + simp only [pow_add] + norm_num only [show 2^8=256 by norm_num] + dsimp [b] + nlinarith + have hppow : 2*P k+1 ≤ 2^(2*k+16) := by + calc + 2*P k+1 ≤ (2*b k)^2 := by dsimp [P]; nlinarith + _ ≤ (2^(k+8))^2 := Nat.pow_le_pow_left hbpow 2 + _ = _ := by rw [←pow_mul]; congr 1; ring + calc + familyAlphabet (b k) (P k) k ≤ (2*P k+1)*(2*b k)^k := familyAlphabet_le hb hp k + _ ≤ 2^(2*k+16)*(2^(k+8))^k := Nat.mul_le_mul hppow (Nat.pow_le_pow_left hbpow k) + _ = 2^(k^2+10*k+16) := by rw [←pow_mul,←pow_add]; congr 1; ring + _ ≤ 2^(30*k^2) := Nat.pow_le_pow_right (by omega) (by nlinarith) + +lemma bits_poly {k : ℕ} (hk : 0 < k) : codeBits k ≤ 30*k^2 := + (Nat.clog_le_iff_le_pow (by norm_num)).mpr (alphabet_power_bound hk) + +lemma width_poly {k : ℕ} (hk : 0 < k) : codeWidth k ≤ 63*k^2 := by + have ht := bits_poly hk + dsimp [codeWidth] + nlinarith + +lemma width_pos (k : ℕ) : 0 < codeWidth k := by dsimp [codeWidth]; omega +lemma encodedLength_pos {k : ℕ} (hk : 0 < k) : 0 < encodedLength k := + Nat.mul_pos (width_pos k) (familyLength_pos (by dsimp [b]; omega) (prime_parameter_pos hk) k) + +lemma length_power_bound (k : ℕ) : familyLength (b k) (P k) k ≤ + (4*(b k)^(100*k+1))^k := by + have he : b k / 2 = 50*k := by dsimp [b]; omega + unfold familyLength + apply Nat.pow_le_pow_left + calc + 2*(2*b k-1)*(P k)^(b k/2) ≤ 4*b k*(P k)^(b k/2) := + Nat.mul_le_mul_right _ (by have := Nat.sub_le (2*b k) 1; omega) + _ = 4*(b k)^(100*k+1) := by + dsimp [P] + rw [he,←pow_mul,pow_succ] + have he' : 2*(50*k)=100*k := by omega + rw [he'] + ring + +theorem log_length_bound {k : ℕ} (hk : 2 ≤ k) : + Real.log (encodedLength k : ℝ) ≤ 1000*(k : ℝ)^2*Real.log (k : ℝ) := by + have hkpos : 0 < k := by omega + have kr : (2 : ℝ) ≤ k := by exact_mod_cast hk + have kp : (0 : ℝ) < k := by positivity + have bp : (0 : ℝ) < b k := by dsimp [b]; positivity + have wp : (0 : ℝ) < codeWidth k := by exact_mod_cast width_pos k + have np : (0 : ℝ) < familyLength (b k) (P k) k := by + exact_mod_cast familyLength_pos (by dsimp [b]; omega) (prime_parameter_pos hkpos) k + have lk : 0 ≤ Real.log (k : ℝ) := Real.log_nonneg (by linarith) + have l2 : Real.log (2 : ℝ) ≤ Real.log (k : ℝ) := Real.log_le_log (by norm_num) kr + have l63 : Real.log (63 : ℝ) ≤ 6*Real.log (2 : ℝ) := by + have ht := Real.log_le_log (by norm_num : (0 : ℝ)<63) (by norm_num : (63 : ℝ) ≤ 2^6) + simpa only [Real.log_pow,Nat.cast_ofNat] using ht + have l100 : Real.log (100 : ℝ) ≤ 7*Real.log (2 : ℝ) := by + have ht := Real.log_le_log (by norm_num : (0 : ℝ)<100) (by norm_num : (100 : ℝ) ≤ 2^7) + simpa only [Real.log_pow,Nat.cast_ofNat] using ht + have l4 : Real.log (4 : ℝ) = 2*Real.log (2 : ℝ) := by + rw [show (4 : ℝ)=2^2 by norm_num,Real.log_pow]; norm_num + have lb : Real.log (b k : ℝ) ≤ 8*Real.log (k : ℝ) := by + simp only [b,Nat.cast_mul,Nat.cast_ofNat,Real.log_mul (by norm_num : (100 : ℝ) ≠ 0) kp.ne'] + linarith + have lw : Real.log (codeWidth k : ℝ) ≤ 8*Real.log (k : ℝ) := by + have hw : (codeWidth k : ℝ) ≤ 63*(k : ℝ)^2 := by exact_mod_cast width_poly hkpos + have hl := Real.log_le_log wp hw + rw [Real.log_mul (by norm_num) (by positivity),Real.log_pow] at hl + norm_num only [Nat.cast_ofNat] at hl + linarith + have ln : Real.log (familyLength (b k) (P k) k : ℝ) ≤ + (k : ℝ)*(Real.log (4 : ℝ)+(100*(k : ℝ)+1)*Real.log (b k : ℝ)) := by + have hn : (familyLength (b k) (P k) k : ℝ) ≤ + (4*(b k : ℝ)^(100*k+1))^k := by exact_mod_cast length_power_bound k + have hl := Real.log_le_log np hn + rw [Real.log_pow,Real.log_mul (by norm_num) (by positivity),Real.log_pow] at hl + push_cast at hl + exact hl + have he : Real.log (encodedLength k : ℝ) = + Real.log (codeWidth k : ℝ)+Real.log (familyLength (b k) (P k) k : ℝ) := by + simp only [encodedLength,Nat.cast_mul,Real.log_mul wp.ne' np.ne'] + rw [he] + calc + _ ≤ 8*Real.log (k : ℝ)+(k : ℝ)*(2*Real.log (k : ℝ)+ + (100*(k : ℝ)+1)*(8*Real.log (k : ℝ))) := by + apply add_le_add lw + apply ln.trans + gcongr + linarith + _ = (800*(k : ℝ)^2+10*(k : ℝ)+8)*Real.log (k : ℝ) := by ring + _ ≤ 1000*(k : ℝ)^2*Real.log (k : ℝ) := by + gcongr + nlinarith + +noncomputable def lowerRatio (k : ℕ) : ℝ := ((h k : ℝ)/24)^k/(16*(codeWidth k : ℝ)) + +lemma log_width_le {k : ℕ} (hk : 0 < k) : + Real.log (codeWidth k : ℝ) ≤ Real.log (63 : ℝ)+2*Real.log (k : ℝ) := by + have hw : (codeWidth k : ℝ) ≤ 63*(k : ℝ)^2 := by exact_mod_cast width_poly hk + have wp : (0 : ℝ) < codeWidth k := by exact_mod_cast width_pos k + have kp : (0 : ℝ) < k := by exact_mod_cast hk + have hh := Real.log_le_log wp hw + rw [Real.log_mul (by norm_num) (by positivity),Real.log_pow] at hh + norm_num only [Nat.cast_ofNat] at hh + exact hh + +theorem ratio_exponential {k : ℕ} (hk : 24^4 ≤ k) : + Real.exp ((1/2 : ℝ)*(k : ℝ)*Real.log (k : ℝ)) ≤ lowerRatio k := by + have hk0 : 0 < k := by norm_num at hk; omega + have kp : (0 : ℝ) < k := by exact_mod_cast hk0 + have k12 : (12 : ℝ) ≤ k := by exact_mod_cast (show 12 ≤ k by norm_num at hk; omega) + have k1008 : (1008 : ℝ) ≤ k := by exact_mod_cast (show 1008 ≤ k by norm_num at hk; omega) + have hn : (0 : ℝ) < h k := by dsimp [h]; positivity + have wp : (0 : ℝ) < codeWidth k := by exact_mod_cast width_pos k + have rp : 0 < lowerRatio k := by dsimp [lowerRatio]; positivity + apply (Real.le_log_iff_exp_le rp).mp + have lkp : 0 ≤ Real.log (k : ℝ) := Real.log_nonneg (by linarith) + have l24 : 4*Real.log (24 : ℝ) ≤ Real.log (k : ℝ) := by + have ht := Real.log_le_log (by norm_num : (0 : ℝ)<24^4) + (show (24 : ℝ)^4 ≤ k by exact_mod_cast hk) + simpa only [Real.log_pow,Nat.cast_ofNat] using ht + have lh : Real.log (k : ℝ) ≤ Real.log (h k : ℝ) := by + apply Real.log_le_log kp + dsimp [h]; push_cast; nlinarith + have lw := log_width_le hk0 + have lconst : Real.log (16 : ℝ)+Real.log (63 : ℝ) ≤ Real.log (k : ℝ) := by + rw [←Real.log_mul (by norm_num) (by norm_num)] + norm_num only [show (16 : ℝ)*63=1008 by norm_num] + exact Real.log_le_log (by norm_num) k1008 + have logeq : Real.log (lowerRatio k) = + (k : ℝ)*(Real.log (h k : ℝ)-Real.log (24 : ℝ))- + (Real.log (16 : ℝ)+Real.log (codeWidth k : ℝ)) := by + dsimp [lowerRatio] + rw [Real.log_div (by positivity) (by positivity),Real.log_pow, + Real.log_div hn.ne' (by norm_num),Real.log_mul (by norm_num) wp.ne'] + rw [logeq] + have h1 := mul_le_mul_of_nonneg_left lh kp.le + have h2 := mul_le_mul_of_nonneg_left l24 kp.le + have h3 : 12*Real.log (k : ℝ) ≤ (k : ℝ)*Real.log (k : ℝ) := + mul_le_mul_of_nonneg_right k12 lkp + nlinarith + +end EditParameters + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Main.lean b/lean/OAI/Combinatorics/EditDistance/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e95ec49d6406e1d96737c1f2111bcc7919cf72b --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Main.lean @@ -0,0 +1,22 @@ +import OAI.Combinatorics.EditDistance.AlphabetLower +import OAI.Combinatorics.EditDistance.AlphabetSupremum +import OAI.Combinatorics.EditDistance.WholeMaps + +namespace OAI + +/-! +# Two-sided exponential bounds for edit-distance distortion +-/ + +universe u + +theorem edit_distance_main : EditDistortion.MainClaim.{u} := by + obtain ⟨c,hc,dL,hL⟩ := EditLower.all_lower_clauses.{u} + obtain ⟨dU,hU⟩ := Filter.eventually_atTop.mp EditUpper.eventual_upper.{u} + refine ⟨c,32,hc,by norm_num,max dL dU,?_⟩ + intro d hd + obtain ⟨hl,hw,hs⟩ := hL d ((le_max_left _ _).trans hd) + obtain ⟨hu,hsu⟩ := hU d ((le_max_right _ _).trans hd) + exact ⟨fun A inst hA => ⟨hl A hA,hu A hA⟩,hw,hs,hsu⟩ + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/MeanHistograms.lean b/lean/OAI/Combinatorics/EditDistance/MeanHistograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..93bdc6ff84704b9d181dd3849dba065ed78c4715 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/MeanHistograms.lean @@ -0,0 +1,154 @@ +import OAI.Combinatorics.EditDistance.Histograms + +namespace OAI + +/-! +# Mean histograms as finite cut distances +-/ + +namespace EditCutHash +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset + +section MeanHistogram +variable {I J X : Type*} [Fintype I] [Fintype J] + +noncomputable def meanHistogram (w : I → ℝ) (a : ℝ) (c : I → X → Bool) (f g : J → X) : ℝ := + ∑ h : I → Bool, probability w a h * histogramDistance (fun j => key c h (f j)) (fun j => key c h (g j)) + +lemma meanHistogram_nonneg {w : I → ℝ} (hw : ∀ i, 0 ≤ w i) {a : ℝ} (ha : 0 ≤ a) + (c : I → X → Bool) (f g : J → X) : 0 ≤ meanHistogram w a c f g := + sum_nonneg (fun h _ => mul_nonneg (probability_nonneg hw ha h) (histogramDistance_nonneg _ _)) + +lemma meanHistogram_upper {w : I → ℝ} (hw : ∀ i, 0 ≤ w i) {a : ℝ} (ha : 0 ≤ a) + (c : I → X → Bool) (f g : J → X) : + meanHistogram w a c f g ≤ 2*a*∑ j, distance w c (f j) (g j) := by + calc + _ ≤ ∑ h : I → Bool, probability w a h * (2*∑ j, sep (key c h (f j)) (key c h (g j))) := + sum_le_sum (fun h _ => mul_le_mul_of_nonneg_left (histogramDistance_le _ _) (probability_nonneg hw ha h)) + _ = 2*∑ j : J, ∑ h : I → Bool, probability w a h * sep (key c h (f j)) (key c h (g j)) := by + simp_rw [mul_left_comm (probability w a _ : ℝ) 2,mul_sum] + rw [sum_comm] + _ ≤ 2*∑ j : J, a*distance w c (f j) (g j) := by + apply mul_le_mul_of_nonneg_left ?_ (by norm_num) + exact sum_le_sum (fun j _ => separation_bound w a c (f j) (g j)) + _ = _ := by rw [←mul_sum]; ring + +lemma mean_cross_collisions (w : I → ℝ) (a : ℝ) (c : I → X → Bool) (f g : J → X) : + (∑ h : I → Bool, probability w a h * + (∑ i : J, ∑ j : J, hit (key c h (f i)) (key c h (g j)))) = + ∑ i : J, ∑ j : J, Real.exp (-a*distance w c (f i) (g j)) := by + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro i _ + rw [sum_comm] + apply sum_congr rfl + intro j _ + apply Eq.trans ?_ (collision_probability w a c (f i) (g j)) + apply sum_congr rfl + intro h _ + congr 1 + by_cases he : key c h (f i) = key c h (g j) <;> simp [hit,he] + +theorem meanHistogram_lower {w : I → ℝ} (hw : ∀ i, 0 ≤ w i) {a : ℝ} (ha : 0 ≤ a) + (c : I → X → Bool) (f g : J → X) {R : ℝ} (hR : ∀ i j, R ≤ distance w c (f i) (g j)) : + 2*(Fintype.card J : ℝ)*(1-(Fintype.card J : ℝ)^2*Real.exp (-a*R)) ≤ + meanHistogram w a c f g := by + have hc : (∑ i : J, ∑ j : J, Real.exp (-a*distance w c (f i) (g j))) ≤ + (Fintype.card J : ℝ)^2*Real.exp (-a*R) := by + calc + _ ≤ ∑ _i : J, ∑ _j : J, Real.exp (-a*R) := by + apply sum_le_sum + intro i _ + apply sum_le_sum + intro j _ + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_left (hR i j) ha] + _ = _ := by simp only [sum_const,card_univ,nsmul_eq_mul]; ring + have hp : (∑ h : I → Bool, probability w a h * + (2*(Fintype.card J : ℝ)*(1-∑ i : J, ∑ j : J, hit (key c h (f i)) (key c h (g j))))) ≤ + meanHistogram w a c f g := + sum_le_sum (fun h _ => mul_le_mul_of_nonneg_left (histogramDistance_lower _ _) (probability_nonneg hw ha h)) + have he : (∑ h : I → Bool, probability w a h * + (2*(Fintype.card J : ℝ)*(1-∑ i : J, ∑ j : J, hit (key c h (f i)) (key c h (g j))))) = + 2*(Fintype.card J : ℝ)*(1-∑ i : J, ∑ j : J, Real.exp (-a*distance w c (f i) (g j))) := by + simp_rw [mul_left_comm (probability w a _) (2*(Fintype.card J : ℝ))] + rw [←mul_sum] + congr 1 + simp_rw [mul_sub,mul_one] + rw [sum_sub_distrib,probability_sum,mean_cross_collisions] + rw [he] at hp + apply le_trans ?_ hp + gcongr + +noncomputable def rate (s : ℕ) : ℝ := Real.log (2*(s : ℝ)^2)/(s : ℝ) + +lemma rate_nonneg {s : ℕ} (hs : 0 < s) : 0 ≤ rate s := by + have hs1 : (1 : ℝ) ≤ s := by exact_mod_cast hs + apply div_nonneg (Real.log_nonneg (by nlinarith)) (by positivity) + +lemma rate_exp {s : ℕ} (hs : 0 < s) : Real.exp (-rate s*(s : ℝ)) = 1/(2*(s : ℝ)^2) := by + have sp : (0 : ℝ) < s := by exact_mod_cast hs + rw [rate,neg_mul,div_mul_cancel₀ _ sp.ne',Real.exp_neg,Real.exp_log (by positivity)] + simp only [one_div] + +lemma meanHistogram_separated {s : ℕ} (hs : 0 < s) {w : I → ℝ} (hw : ∀ i, 0 ≤ w i) + (c : I → X → Bool) (f g : Fin s → X) + (hR : ∀ i j, (s : ℝ) ≤ distance w c (f i) (g j)) : + (s : ℝ) ≤ meanHistogram w (rate s) c f g := by + have hh := meanHistogram_lower hw (rate_nonneg hs) c f g hR + rw [Fintype.card_fin,rate_exp hs] at hh + have sp : (0 : ℝ) < s := by exact_mod_cast hs + have he : 2*(s : ℝ)*(1-(s : ℝ)^2*(1/(2*(s : ℝ)^2))) = (s : ℝ) := by + field_simp + ring + simpa only [he] using hh + +end MeanHistogram +end EditCutHash + +namespace EditCutHash +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset + +lemma histogramDistance_shift {K : Type*} [Fintype K] {s : ℕ} + (f g : Fin (s+1) → K) (h : ∀ i : Fin s, f i.castSucc = g i.succ) : + histogramDistance f g ≤ 2 := by + have hc (z : K) : count f z-count g z = hit (f (Fin.last s)) z-hit (g 0) z := by + unfold count + rw [Fin.sum_univ_castSucc,Fin.sum_univ_succ] + simp_rw [h] + ring + unfold histogramDistance + simp_rw [hc] + rw [hit_distance] + have hh := sep_le_one (f (Fin.last s)) (g 0) + linarith + +lemma meanHistogram_shift {I X : Type*} [Fintype I] {s : ℕ} (hs : 0 < s) + {w : I → ℝ} (hw : ∀ i, 0 ≤ w i) {a : ℝ} (ha : 0 ≤ a) + (c : I → X → Bool) (f g : Fin s → X) + (h : ∀ i : Fin (s-1), f ⟨i.val,by omega⟩ = g ⟨i.val+1,by omega⟩) : + meanHistogram w a c f g ≤ 2 := by + obtain ⟨t,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hs) + have hd (r : I → Bool) : histogramDistance (fun i => key c r (f i)) (fun i => key c r (g i)) ≤ 2 := by + apply histogramDistance_shift + intro i + congr 1 + exact h ⟨i.val,by omega⟩ + calc + _ ≤ ∑ r : I → Bool, probability w a r * 2 := + sum_le_sum (fun r _ => mul_le_mul_of_nonneg_left (hd r) (probability_nonneg hw ha r)) + _ = 2 := by rw [←sum_mul,probability_sum,one_mul] + +@[simp] lemma meanHistogram_self {I J X : Type*} [Fintype I] [Fintype J] + (w : I → ℝ) (a : ℝ) (c : I → X → Bool) (f : J → X) : + meanHistogram w a c f f = 0 := by + simp [meanHistogram,histogramDistance] + +end EditCutHash + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Metric.lean b/lean/OAI/Combinatorics/EditDistance/Metric.lean new file mode 100644 index 0000000000000000000000000000000000000000..23b6783e8f96daef79a9740d39467ff6efa0ab03 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Metric.lean @@ -0,0 +1,300 @@ +import OAI.Combinatorics.EditDistance.Model +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +/-! +# Unrestricted edit scripts, metric inequalities, and common subsequences +-/ + +namespace EditDistortion + +universe u v +noncomputable def indel {Alpha : Type u} (x y : List Alpha) : ℕ := + sInf {n | Script false n x y} + +variable {Alpha : Type u} {Beta : Type v} {s : Bool} + +namespace Step + +theorem symm {x y : List Alpha} (h : Step s x y) : Step s y x := by + cases h with + | insert p q a => exact .delete p q a + | delete p q a => exact .insert p q a + | substitute hs p q a b => exact .substitute hs p q b a + +theorem map (f : Alpha → Beta) {x y : List Alpha} (h : Step s x y) : + Step s (x.map f) (y.map f) := by + cases h with + | insert p q a => simpa using Step.insert (substitutions := s) (p.map f) (q.map f) (f a) + | delete p q a => simpa using Step.delete (substitutions := s) (p.map f) (q.map f) (f a) + | substitute hs p q a b => + simpa using Step.substitute hs (p.map f) (q.map f) (f a) (f b) + +theorem append_left (p : List Alpha) {x y : List Alpha} (h : Step s x y) : + Step s (p ++ x) (p ++ y) := by + cases h with + | insert q r a => simpa only [List.append_assoc] using Step.insert (substitutions := s) (p ++ q) r a + | delete q r a => simpa only [List.append_assoc] using Step.delete (substitutions := s) (p ++ q) r a + | substitute hs q r a b => + simpa only [List.append_assoc] using Step.substitute hs (p ++ q) r a b + +theorem append_right (q : List Alpha) {x y : List Alpha} (h : Step s x y) : + Step s (x ++ q) (y ++ q) := by + cases h with + | insert p r a => + simpa only [List.append_assoc, List.cons_append] using + Step.insert (substitutions := s) p (r ++ q) a + | delete p r a => + simpa only [List.append_assoc, List.cons_append] using + Step.delete (substitutions := s) p (r ++ q) a + | substitute hs p r a b => + simpa only [List.append_assoc, List.cons_append] using Step.substitute hs p (r ++ q) a b + +theorem length_bounds {x y : List Alpha} (h : Step s x y) : + x.length ≤ y.length + 1 ∧ y.length ≤ x.length + 1 := by + cases h <;> simp only [List.length_append, List.length_cons] <;> omega + +theorem allow_substitution {x y : List Alpha} (h : Step false x y) : Step true x y := by + cases h with + | insert p q a => exact .insert p q a + | delete p q a => exact .delete p q a + | substitute hs => cases hs + +end Step + +namespace Script + +theorem trans {m n : ℕ} {x y z : List Alpha} + (h : Script s m x y) (k : Script s n y z) : Script s (m + n) x z := by + induction h with + | nil => simpa using k + | @cons l x w y e h ih => + simpa only [Nat.add_right_comm] using Script.cons e (ih k) + +theorem single {x y : List Alpha} (h : Step s x y) : Script s 1 x y := + .cons h (.nil y) + +theorem symm {n : ℕ} {x y : List Alpha} (h : Script s n x y) : Script s n y x := by + induction h with + | nil x => exact .nil x + | cons e h ih => exact ih.trans (single e.symm) + +theorem map (f : Alpha → Beta) {n : ℕ} {x y : List Alpha} (h : Script s n x y) : + Script s n (x.map f) (y.map f) := by + induction h with + | nil x => exact .nil _ + | cons e h ih => exact .cons (e.map f) ih + +theorem append_left (p : List Alpha) {n : ℕ} {x y : List Alpha} (h : Script s n x y) : + Script s n (p ++ x) (p ++ y) := by + induction h with + | nil x => exact .nil _ + | cons e h ih => exact .cons (e.append_left p) ih + +theorem append_right (q : List Alpha) {n : ℕ} {x y : List Alpha} (h : Script s n x y) : + Script s n (x ++ q) (y ++ q) := by + induction h with + | nil x => exact .nil _ + | cons e h ih => exact .cons (e.append_right q) ih + +theorem to_nil (x : List Alpha) : Script s x.length x [] := by + induction x with + | nil => exact .nil [] + | cons a x ih => exact .cons (.delete [] x a) ih + +theorem exists_script (x y : List Alpha) : ∃ n, Script s n x y := + ⟨x.length + y.length, (to_nil x).trans (to_nil y).symm⟩ + +theorem eq_of_zero {x y : List Alpha} (h : Script s 0 x y) : x = y := by + cases h + rfl + +theorem length_bounds {n : ℕ} {x y : List Alpha} (h : Script s n x y) : + x.length ≤ y.length + n ∧ y.length ≤ x.length + n := by + induction h with + | nil x => omega + | cons e h ih => have := e.length_bounds; omega + +theorem allow_substitution {n : ℕ} {x y : List Alpha} (h : Script false n x y) : + Script true n x y := by + induction h with + | nil x => exact .nil x + | cons e h ih => exact .cons e.allow_substitution ih + +end Script + + + +theorem cost_le {n : ℕ} {x y : List Alpha} (h : Script s n x y) : cost s x y ≤ n := + Nat.sInf_le h + +theorem cost_spec (x y : List Alpha) : Script s (cost s x y) x y := + Nat.sInf_mem (Script.exists_script x y) + +theorem cost_refl (x : List Alpha) : cost s x x = 0 := + Nat.eq_zero_of_le_zero (cost_le (.nil x)) + +theorem cost_eq_zero_iff {x y : List Alpha} : cost s x y = 0 ↔ x = y := by + constructor + · intro h + have hc := cost_spec (s := s) x y + rw [h] at hc + exact hc.eq_of_zero + · rintro rfl + exact cost_refl _ + +theorem cost_symm (x y : List Alpha) : cost s x y = cost s y x := by + apply Nat.le_antisymm + · exact cost_le (cost_spec y x).symm + · exact cost_le (cost_spec x y).symm + +theorem cost_triangle (x y z : List Alpha) : cost s x z ≤ cost s x y + cost s y z := + cost_le ((cost_spec x y).trans (cost_spec y z)) + +theorem cost_map_le (f : Alpha → Beta) (x y : List Alpha) : + cost s (x.map f) (y.map f) ≤ cost s x y := + cost_le ((cost_spec x y).map f) + +theorem cost_length_bounds (x y : List Alpha) : + x.length ≤ y.length + cost s x y ∧ y.length ≤ x.length + cost s x y := + (cost_spec x y).length_bounds + +theorem edit_le_indel (x y : List Alpha) : edit x y ≤ indel x y := + cost_le ((cost_spec (s := false) x y).allow_substitution) + +end EditDistortion + +namespace EditDistortion + +universe u v +variable {Alpha : Type u} {Beta : Type v} {s : Bool} + +theorem Step.indel_simulation {x y : List Alpha} (e : Step true x y) : + ∃ n ≤ 2, Script false n x y := by + cases e with + | insert p q a => exact ⟨1, by omega, Script.single (.insert p q a)⟩ + | delete p q a => exact ⟨1, by omega, Script.single (.delete p q a)⟩ + | substitute _ p q a b => + exact ⟨2, le_rfl, (Script.single (.delete p q a)).trans + (Script.single (.insert p q b))⟩ + +theorem Script.indel_simulation {m : ℕ} {x y : List Alpha} (h : Script true m x y) : + ∃ n ≤ 2 * m, Script false n x y := by + induction h with + | nil x => exact ⟨0, le_rfl, .nil x⟩ + | cons e h ih => + obtain ⟨n, hn, sn⟩ := ih + obtain ⟨k, hk, sk⟩ := e.indel_simulation + exact ⟨k + n, by omega, sk.trans sn⟩ + +theorem indel_le_two_edit (x y : List Alpha) : indel x y ≤ 2 * edit x y := by + obtain ⟨n, hn, hs⟩ := (cost_spec (s := true) x y).indel_simulation + exact (cost_le hs).trans hn + +theorem Script.max_length (x y : List Alpha) : Script true (max x.length y.length) x y := by + induction x generalizing y with + | nil => simpa using (Script.to_nil (s := true) y).symm + | cons a x ih => + cases y with + | nil => simpa using Script.to_nil (s := true) (a :: x) + | cons b y => + have hs := (ih y).append_left [b] + have he := Step.substitute rfl [] x a b + simpa only [List.length_cons, max_add_add_right, List.singleton_append, List.nil_append] using + Script.cons he hs + +theorem edit_le_max_length (x y : List Alpha) : edit x y ≤ max x.length y.length := + cost_le (Script.max_length x y) + +theorem cost_map_eq_of_leftInverse (f : Alpha → Beta) (g : Beta → Alpha) + (h : Function.LeftInverse g f) (x y : List Alpha) : + cost s (x.map f) (y.map f) = cost s x y := by + apply Nat.le_antisymm (cost_map_le f x y) + have H := cost_map_le (s := s) g (x.map f) (y.map f) + simpa only [List.map_map, h.comp_eq_id, List.map_id] using H + +theorem cost_append_le (x y u v : List Alpha) : + cost s (x ++ u) (y ++ v) ≤ cost s x y + cost s u v := + cost_le (((cost_spec x y).append_right u).trans ((cost_spec u v).append_left y)) + +theorem Script.of_sublist {x y : List Alpha} (h : x.Sublist y) : + Script false (y.length - x.length) y x := by + induction h with + | slnil => exact .nil [] + | @cons x y a h ih => + have hl := h.length_le + simpa only [List.length_cons, Nat.succ_sub hl, Nat.succ_eq_add_one, List.nil_append] using + Script.cons (.delete [] y a) ih + | @cons_cons x y a h ih => + simpa only [List.length_cons, Nat.add_sub_add_right, List.singleton_append] using + ih.append_left [a] + +theorem indel_le_matching_loss {x y z : List Alpha} (hx : z.Sublist x) (hy : z.Sublist y) : + indel x y ≤ x.length + y.length - 2 * z.length := by + have hs := (Script.of_sublist hx).trans (Script.of_sublist hy).symm + have hx' := hx.length_le + have hy' := hy.length_le + have heq : x.length - z.length + (y.length - z.length) = + x.length + y.length - 2 * z.length := by omega + rw [heq] at hs + exact cost_le hs + +end EditDistortion + +namespace EditDistortion + +universe u +variable {Alpha : Type u} + +theorem sublist_erase_one {z p q : List Alpha} {a : Alpha} + (h : z.Sublist (p ++ a :: q)) : + ∃ z' : List Alpha, z'.Sublist z ∧ z'.Sublist (p ++ q) ∧ z.length ≤ z'.length + 1 := by + obtain ⟨z₁, z₂, rfl, h₁, h₂⟩ := List.sublist_append_iff.mp h + rcases List.sublist_cons_iff.mp h₂ with h₂ | ⟨r, rfl, hr⟩ + · exact ⟨z₁ ++ z₂, .refl _, h₁.append h₂, by omega⟩ + · refine ⟨z₁ ++ r, (List.Sublist.refl z₁).append ((List.Sublist.refl r).cons a), + h₁.append hr, ?_⟩ + simp only [List.length_append, List.length_cons] + omega + +theorem Script.common_sublist {n : ℕ} {x y : List Alpha} (h : Script false n x y) : + ∃ z : List Alpha, z.Sublist x ∧ z.Sublist y ∧ x.length + y.length ≤ n + 2 * z.length := by + induction h with + | nil x => exact ⟨x, .refl _, .refl _, by omega⟩ + | @cons n x v y e h ih => + obtain ⟨z, hzx, hzy, hz⟩ := ih + cases e with + | insert p q a => + obtain ⟨z', hz'z, hz'x, hz'L⟩ := sublist_erase_one hzx + refine ⟨z', hz'x, hz'z.trans hzy, ?_⟩ + simp only [List.length_append, List.length_cons] at hz ⊢ + omega + | delete p q a => + refine ⟨z, hzx.middle a, hzy, ?_⟩ + simp only [List.length_append, List.length_cons] at hz ⊢ + omega + | substitute hf => cases hf + +theorem indel_matching (x y : List Alpha) : + ∃ z : List Alpha, z.Sublist x ∧ z.Sublist y ∧ + indel x y = x.length + y.length - 2 * z.length := by + obtain ⟨z, hx, hy, hz⟩ := (cost_spec (s := false) x y).common_sublist + refine ⟨z, hx, hy, Nat.le_antisymm (indel_le_matching_loss hx hy) ?_⟩ + change x.length + y.length - 2 * z.length ≤ cost false x y + omega + +theorem le_indel_iff {x y : List Alpha} {r : ℕ} : r ≤ indel x y ↔ + ∀ z : List Alpha, z.Sublist x → z.Sublist y → r ≤ x.length + y.length - 2 * z.length := by + constructor + · intro hr z hx hy + exact hr.trans (indel_le_matching_loss hx hy) + · intro h + obtain ⟨z, hx, hy, hz⟩ := indel_matching x y + rw [hz] + exact h z hx hy + +end EditDistortion + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Model.lean b/lean/OAI/Combinatorics/EditDistance/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..9010c1c4865a14be7c09112f0dba7cfe5d88dcc5 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Model.lean @@ -0,0 +1,59 @@ +import Mathlib +import OAI.Combinatorics.EditApproximation.Definitions + + +namespace OAI + +namespace EditDistortion + +universe u + +/- A single unit-cost insertion, deletion, or (when enabled) substitution. -/ + + +/- An unrestricted script of exactly n unit edits. -/ + + +/-- Minimum script length. Scripts always exist (delete x and insert y). -/ + + +abbrev L1 := lp (fun _ : ℕ => ℝ) 1 + +/-- The product of the two maximal distance ratios. -/ +noncomputable def distortion {X : Type u} (ρ : X → X → ℝ) (f : X ↪ L1) : ℝ := + sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ‖f x - f y‖ / ρ x y} * + sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ r = ρ x y / ‖f x - f y‖} + +/-- The infimum over injective maps to real absolutely summable sequences. -/ +noncomputable def leastDistortion {X : Type u} (ρ : X → X → ℝ) : ℝ := + sInf (Set.range (distortion ρ)) + +abbrev Words (Alpha : Type u) (d : ℕ) := {x : List Alpha // x.length ≤ d} + +noncomputable def E (Alpha : Type u) (d : ℕ) : ℝ := + leastDistortion (fun x y : Words Alpha d => (edit x.val y.val : ℝ)) + +noncomputable def exponentScale (c : ℝ) (d : ℕ) : ℝ := + Real.exp (c * Real.sqrt (Real.log (d : ℝ) * Real.log (Real.log (d : ℝ)))) + +/-- Supremum over finite alphabet cardinalities. -/ +noncomputable def alphabetSup (d : ℕ) : ℝ := + sSup {r : ℝ | ∃ n : ℕ, 2 ≤ n ∧ r = E (Fin n) d} + +/-- A finite nonempty subset of binary words of one common length. -/ +def BinaryWitness (c : ℝ) (d : ℕ) : Prop := + ∃ n : ℕ, n ≤ d ∧ ∃ S : Set (List Bool), S.Finite ∧ S.Nonempty ∧ + (∀ w ∈ S, w.length = n) ∧ + exponentScale c d ≤ leastDistortion (fun x y : S => (edit x.val y.val : ℝ)) + +/-- Uniform two-sided bounds with common positive constants and threshold. -/ +def MainClaim : Prop := + ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → + (∀ (Alpha : Type u) [Fintype Alpha], 2 ≤ Fintype.card Alpha → + exponentScale c d ≤ E Alpha d ∧ E Alpha d ≤ exponentScale C d) ∧ + BinaryWitness c d ∧ + exponentScale c d ≤ alphabetSup d ∧ alphabetSup d ≤ exponentScale C d + +end EditDistortion + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/PrimeCharacters.lean b/lean/OAI/Combinatorics/EditDistance/PrimeCharacters.lean new file mode 100644 index 0000000000000000000000000000000000000000..8132563c785ede198fd7dd243ab6ae7220d1cd47 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/PrimeCharacters.lean @@ -0,0 +1,174 @@ +import OAI.Combinatorics.EditDistance.FourierCharacters + +namespace OAI + +/-! +# Coprime roots and prime-product Fourier multipliers +-/ + +namespace EditFourier +open scoped BigOperators +open Finset + +section CoprimeRoots +variable {J : Type*} [DecidableEq J] + +omit [DecidableEq J] in + +theorem prod_roots_pow (s : Finset J) (p : J → ℕ) (z : J → ℂ) + (hz : ∀ j ∈ s, z j ^ p j = 1) (q : ℕ) (hq : ∀ j ∈ s, p j ∣ q) : + (∏ j ∈ s, z j) ^ q = 1 := by + rw [← prod_pow] + apply prod_eq_one + intro j hj + obtain ⟨m, hm⟩ := hq j hj + rw [hm, pow_mul, hz j hj, one_pow] + +theorem coprime_roots_nontrivial (s : Finset J) (p : J → ℕ) (z : J → ℂ) + (hcop : (s : Set J).Pairwise (fun i j => (p i).Coprime (p j))) + (hz : ∀ j ∈ s, z j ^ p j = 1) (i : J) (hi : i ∈ s) (hne : z i ≠ 1) : + (∏ j ∈ s, z j) ≠ 1 := by + intro h + let q := ∏ j ∈ s.erase i, p j + have hq : ∀ j ∈ s.erase i, p j ∣ q := fun j hj => dvd_prod_of_mem p hj + have hpow := prod_roots_pow (s.erase i) p z + (fun j hj => hz j (mem_of_mem_erase hj)) q hq + have hp : z i ^ q = 1 := by + have hh := congrArg (fun a : ℂ => a ^ q) h + rw [← mul_prod_erase s z hi, mul_pow, hpow, mul_one, one_pow] at hh + exact hh + have hc : (p i).Coprime q := Nat.Coprime.prod_right fun j hj => + hcop hi (mem_of_mem_erase hj) (ne_of_mem_erase hj).symm + exact hne ((pow_eq_one_iff_of_coprime hc).mp ⟨hz i hi, hp⟩) + +theorem coprime_root_separation (s : Finset J) (p : J → ℕ) (z : J → ℂ) + (hpos : ∀ j ∈ s, 0 < p j) + (hcop : (s : Set J).Pairwise (fun i j => (p i).Coprime (p j))) + (hz : ∀ j ∈ s, z j ^ p j = 1) (hnorm : ∀ j ∈ s, ‖z j‖ = 1) + (i : J) (hi : i ∈ s) (hne : z i ≠ 1) : + 2 ≤ ((∏ j ∈ s, p j : ℕ) : ℝ) * ‖(∏ j ∈ s, z j) - 1‖ := by + apply root_separation + · rw [norm_prod] + exact prod_eq_one hnorm + · exact coprime_roots_nontrivial s p z hcop hz i hi hne + · exact prod_pos hpos + · apply prod_roots_pow s p z hz + exact fun j hj => dvd_prod_of_mem p hj + +end CoprimeRoots +end EditFourier + +namespace EditFourier +open scoped BigOperators +open Finset + +lemma norm_sub_one_sq_of_norm_one (z : ℂ) (hz : ‖z‖ = 1) : + ‖z - 1‖ ^ 2 = 2 - 2 * z.re := by + have hh : z.re * z.re + z.im * z.im = 1 := by + have h := congrArg (fun x : ℝ => x ^ 2) hz + rw [← Complex.normSq_eq_norm_sq, Complex.normSq_apply] at h + simpa only [one_pow] using h + simp only [← Complex.normSq_eq_norm_sq, Complex.normSq_apply, + Complex.sub_re, Complex.one_re, Complex.sub_im, Complex.one_im, sub_zero] + nlinarith + +lemma character_multiplier_four {R : Type*} [AddCommGroup R] [Finite R] + (ψ : AddChar R ℂ) (a : R) : ‖ψ a - 1‖ ^ 2 ≤ 4 := by + have hb : ‖ψ a - 1‖ ≤ 2 := by + calc + _ ≤ ‖ψ a‖ + ‖(1 : ℂ)‖ := norm_sub_le _ _ + _ = 2 := by rw [ψ.norm_apply, norm_one]; norm_num + nlinarith [norm_nonneg (ψ a - 1)] + +lemma average_character_multiplier {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (a : R) : + (∑ x : R, ‖ψ (a * x) - 1‖ ^ 2) / (Fintype.card R : ℝ) = + if a = 0 then 0 else 2 := by + by_cases ha : a = 0 + · simp [ha] + have hs : ∑ x : R, ψ (a * x) = 0 := by + simpa only [ha, ite_false, Nat.cast_zero, mul_comm] using AddChar.sum_mulShift a hψ + have hr : ∑ x : R, (ψ (a * x)).re = 0 := by rw [← Complex.re_sum, hs]; rfl + simp_rw [norm_sub_one_sq_of_norm_one _ (ψ.norm_apply _)] + rw [sum_sub_distrib, ← mul_sum, hr, mul_zero, sub_zero] + simp only [sum_const, card_univ, nsmul_eq_mul, ha, ite_false] + field_simp + +lemma std_character_pow (p : ℕ) [NeZero p] (a : ZMod p) : + (ZMod.stdAddChar a) ^ p = 1 := by + rw [← AddChar.map_nsmul_eq_pow, nsmul_eq_mul] + simp + +end EditFourier + +namespace EditFourier +open scoped BigOperators +open Finset + +section PrimeProduct +variable {J : Type*} [Fintype J] [DecidableEq J] +variable (p : J → ℕ) [∀ j, NeZero (p j)] + +theorem multiplier_comparison + (hcop : Pairwise (fun i j => (p i).Coprime (p j))) + (B : ℝ) (hB : 1 ≤ B) (hpB : ∀ j, (p j : ℝ) ≤ B) + (h : ℕ) (hh : 0 < h) (lam : ∀ j, ZMod (p j)) (i : J) (u : ZMod (p i)) : + ‖ZMod.stdAddChar (lam i * u) - 1‖ ^ 2 ≤ + B ^ (2 * h) * ‖torusCharacter p lam - 1‖ ^ 2 + + (2 / (h : ℝ)) * ∑ j, (if lam j = 0 then (0 : ℝ) else 2) := by + have hSim : 0 ≤ B ^ (2 * h) * ‖torusCharacter p lam - 1‖ ^ 2 := by positivity + have hCoord : 0 ≤ (2 / (h : ℝ)) * ∑ j, (if lam j = 0 then (0 : ℝ) else 2) := by + apply mul_nonneg (by positivity) + apply sum_nonneg + intro j _ + split_ifs <;> norm_num + by_cases hi : lam i = 0 + · simpa only [hi, zero_mul, AddChar.map_zero_eq_one, sub_self, norm_zero, zero_pow + (by omega : 2 ≠ 0)] using add_nonneg hSim hCoord + have hleft := character_multiplier_four (ZMod.stdAddChar (N := p i)) (lam i * u) + let s : Finset J := univ.filter (fun j => lam j ≠ 0) + have his : i ∈ s := by simp [s, hi] + by_cases hs : s.card < h + · have hroot := coprime_root_separation s p (fun j => ZMod.stdAddChar (lam j)) + (fun j _ => NeZero.pos (p j)) + (fun _ _ _ _ hij => hcop hij) + (fun j _ => std_character_pow (p j) (lam j)) + (fun j _ => (ZMod.stdAddChar (N := p j)).norm_apply (lam j)) i his + (by + intro heq + apply hi + exact ZMod.injective_stdAddChar (heq.trans (AddChar.map_zero_eq_one _).symm)) + have heq : (∏ j ∈ s, ZMod.stdAddChar (lam j)) = torusCharacter p lam := by + change (∏ j ∈ s, ZMod.stdAddChar (lam j)) = ∏ j, ZMod.stdAddChar (lam j) + apply prod_subset (filter_subset _ _) + intro j _ hj + have hjz : lam j = 0 := by simpa [s] using hj + simp [hjz] + rw [heq] at hroot + have hprod : ((∏ j ∈ s, p j : ℕ) : ℝ) ≤ B ^ h := by + calc + _ = ∏ j ∈ s, (p j : ℝ) := by norm_cast + _ ≤ ∏ _j ∈ s, B := prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun j _ => hpB j) + _ = B ^ s.card := by rw [prod_const] + _ ≤ B ^ h := pow_le_pow_right₀ hB hs.le + have htwo : 2 ≤ B ^ h * ‖torusCharacter p lam - 1‖ := + hroot.trans (mul_le_mul_of_nonneg_right hprod (norm_nonneg _)) + have hfour : 4 ≤ B ^ (2 * h) * ‖torusCharacter p lam - 1‖ ^ 2 := by + have hsq : 4 ≤ (B ^ h * ‖torusCharacter p lam - 1‖) ^ 2 := by nlinarith + simpa only [mul_pow, ← pow_mul, Nat.mul_comm h 2] using hsq + linarith + · have hcard : (h : ℝ) ≤ s.card := by exact_mod_cast Nat.le_of_not_gt hs + have hsum : (∑ j, (if lam j = 0 then (0 : ℝ) else 2)) = (s.card : ℝ) * 2 := by + calc + _ = ∑ _j ∈ s, (2 : ℝ) := by simp only [s, sum_filter, ite_not] + _ = _ := by simp + rw [hsum] + have hfour : 4 ≤ 2 / (h : ℝ) * ((s.card : ℝ) * 2) := by + rw [div_mul_eq_mul_div, le_div_iff₀ (Nat.cast_pos.mpr hh)] + linarith + linarith + +end PrimeProduct +end EditFourier + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/PrimeDisplacement.lean b/lean/OAI/Combinatorics/EditDistance/PrimeDisplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6183239006169a89abcc4d56bf65d7cb907ac46 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/PrimeDisplacement.lean @@ -0,0 +1,149 @@ +import OAI.Combinatorics.EditDistance.FourierAverages +import OAI.Combinatorics.EditDistance.Cuts + +namespace OAI + +/-! +# Prime-product displacement for absolutely summable maps +-/ + +namespace EditFourier +open scoped BigOperators +open Finset EditAverage + +noncomputable def variation {G E : Type*} [AddCommGroup G] [Fintype G] + [NormedAddCommGroup E] (H : G → E) (l : G) : ℝ := + avg (fun z => ‖H (z + l) - H z‖) + +section CutTransport +variable {G : Type*} [AddCommGroup G] [Fintype G] [DecidableEq G] + +lemma quadraticVariation_cut (A : Finset G) (l : G) : + quadraticVariation (fun z => (EditCuts.cut A z : ℂ)) l = + variation (EditCuts.cut A) l := by + unfold quadraticVariation variation avg + congr 1 + apply sum_congr rfl + intro z _ + by_cases hz : z ∈ A <;> by_cases hzl : z + l ∈ A <;> + simp [EditCuts.cut, hz, hzl] + +lemma variation_cut_decomposition (H : G → EditCuts.RealL1) (c : Finset G → ℝ) + (hd : ∀ x y, ‖H x - H y‖ = ∑ A : Finset G, c A * |EditCuts.cut A x - EditCuts.cut A y|) + (l : G) : variation H l = ∑ A : Finset G, c A * variation (EditCuts.cut A) l := by + simp_rw [variation, hd, avg_sum, avg_mul, Real.norm_eq_abs] + +end CutTransport + +section PrimeProductL1 +variable {J : Type*} [Fintype J] [DecidableEq J] +variable (p : J → ℕ) [∀ j, NeZero (p j)] +variable {G : Type*} [AddCommGroup G] [Fintype G] + +theorem prime_product_displacement + (hcop : Pairwise (fun i j => (p i).Coprime (p j))) + (B : ℝ) (hB : 1 ≤ B) (hpB : ∀ j, (p j : ℝ) ≤ B) + (h : ℕ) (hh : 0 < h) (φ : (∀ j, ZMod (p j)) →+ G) + (H : G → EditCuts.RealL1) (i : J) (u : ZMod (p i)) : + variation H (φ (Pi.single i u)) ≤ + B ^ (2 * h) * variation H (φ 1) + (2 / (h : ℝ)) * + ∑ j, avg (fun a : ZMod (p j) => variation H (φ (Pi.single j a))) := by + classical + have hcut (A : Finset G) : + variation (EditCuts.cut A) (φ (Pi.single i u)) ≤ + B ^ (2 * h) * variation (EditCuts.cut A) (φ 1) + (2 / (h : ℝ)) * + ∑ j, avg (fun a : ZMod (p j) => variation (EditCuts.cut A) (φ (Pi.single j a))) := by + simpa only [quadraticVariation_cut] using group_quadratic_comparison p hcop B hB hpB h hh φ + (fun z => (EditCuts.cut A z : ℂ)) i u + obtain ⟨c, hc, _, _, hd⟩ := EditCuts.l1_decomposition H + simp_rw [variation_cut_decomposition H c hd] + calc + _ ≤ ∑ A : Finset G, c A * + (B ^ (2 * h) * variation (EditCuts.cut A) (φ 1) + (2 / (h : ℝ)) * + ∑ j, avg (fun a : ZMod (p j) => variation (EditCuts.cut A) (φ (Pi.single j a)))) := by + apply sum_le_sum + intro A _ + exact mul_le_mul_of_nonneg_left (hcut A) (hc A) + _ = _ := by + simp_rw [mul_add, sum_add_distrib, avg_sum, avg_mul] + congr 1 + · simp_rw [mul_left_comm _ (B ^ (2 * h)), ← mul_sum] + · simp_rw [mul_left_comm _ (2 / (h : ℝ)), ← mul_sum, mul_sum] + rw [sum_comm] + +end PrimeProductL1 +end EditFourier + +namespace EditFourier +open scoped BigOperators +open Finset EditAverage + +def torsionHom {G : Type*} [AddCommGroup G] (p : ℕ) (v : G) (hv : p • v = 0) : + ZMod p →+ G := + ZMod.lift p ⟨{ toFun := fun z : ℤ => z • v + map_zero' := zero_zsmul v + map_add' := fun x y => add_zsmul v x y }, by simpa using hv⟩ + +lemma torsionHom_natCast {G : Type*} [AddCommGroup G] (p : ℕ) (v : G) (hv : p • v = 0) + (a : ℕ) : torsionHom p v hv (a : ZMod p) = a • v := by + simpa [torsionHom] using ZMod.lift_coe p + (⟨{ toFun := fun z : ℤ => z • v + map_zero' := zero_zsmul v + map_add' := fun x y => add_zsmul v x y }, by simpa using hv⟩) (a : ℤ) + +lemma torsionHom_apply {G : Type*} [AddCommGroup G] (p : ℕ) [NeZero p] + (v : G) (hv : p • v = 0) (a : ZMod p) : torsionHom p v hv a = a.val • v := by + rw [← torsionHom_natCast p v hv a.val, ZMod.natCast_zmod_val] + +section Vectors +variable {J G : Type*} [Fintype J] [DecidableEq J] [AddCommGroup G] +variable (p : J → ℕ) (v : J → G) (hv : ∀ j, p j • v j = 0) + +def vectorHom : (∀ j, ZMod (p j)) →+ G where + toFun a := ∑ j, torsionHom (p j) (v j) (hv j) (a j) + map_zero' := by simp + map_add' a b := by simp [map_add, Finset.sum_add_distrib] + +lemma vectorHom_single (i : J) (a : ZMod (p i)) : + vectorHom p v hv (Pi.single i a) = torsionHom (p i) (v i) (hv i) a := by + classical + simp only [vectorHom, AddMonoidHom.coe_mk, ZeroHom.coe_mk] + rw [Finset.sum_eq_single i] + · simp + · intro j _ hj + simp [Pi.single_eq_of_ne hj] + · simp + +omit [DecidableEq J] in +lemma vectorHom_one : vectorHom p v hv 1 = ∑ j, v j := by + change (∑ j, torsionHom (p j) (v j) (hv j) 1) = _ + apply Finset.sum_congr rfl + intro j _ + simpa using torsionHom_natCast (p j) (v j) (hv j) 1 + +variable [Fintype G] [∀ j, NeZero (p j)] + +include hv + +theorem vector_displacement + (hcop : Pairwise (fun i j => (p i).Coprime (p j))) + (B : ℝ) (hB : 1 ≤ B) (hpB : ∀ j, (p j : ℝ) ≤ B) + (h : ℕ) (hh : 0 < h) (H : G → EditCuts.RealL1) (i : J) (u : ZMod (p i)) : + variation H (u.val • v i) ≤ B ^ (2 * h) * variation H (∑ j, v j) + + (2 / (h : ℝ)) * ∑ j, avg (fun a : ZMod (p j) => variation H (a.val • v j)) := by + simpa only [vectorHom_single, vectorHom_one, torsionHom_apply] using + prime_product_displacement p hcop B hB hpB h hh (vectorHom p v hv) H i u + +theorem prime_vector_displacement (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + (P : ℝ) (hP : 1 ≤ 2 * P) (hpP : ∀ j, (p j : ℝ) ≤ 2 * P) + (h : ℕ) (hh : 0 < h) (H : G → EditCuts.RealL1) (i : J) (u : ZMod (p i)) : + variation H (u.val • v i) ≤ (2 * P) ^ (2 * h) * variation H (∑ j, v j) + + (2 / (h : ℝ)) * ∑ j, avg (fun a : ZMod (p j) => variation H (a.val • v j)) := by + apply vector_displacement p v hv (fun i j hij => ?_) (2 * P) hP hpP h hh H i u + exact (hp i).coprime_iff_not_dvd.mpr (fun hd => + hij (hinj ((Nat.dvd_prime (hp j)).mp hd |>.resolve_left (hp i).ne_one))) + +end Vectors +end EditFourier + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/PrimePeriods.lean b/lean/OAI/Combinatorics/EditDistance/PrimePeriods.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c3d8c82339998bdbb76915bba4828af57e6f1ca --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/PrimePeriods.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.EditDistance.PrimeCharacters + +namespace OAI + +/-! +# Prime divisibility and distinct phase periods +-/ + +namespace EditPhase +open scoped BigOperators + +lemma few_divisors {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) (hp : Pairwise (fun i j => (p i).Coprime (p j))) + {P r n : ℕ} (hP : 1 ≤ P) (hpP : ∀ j, P ≤ p j) + (hn : 0 < n) (hnr : n < P ^ r) : + (Finset.univ.filter (fun j => p j ∣ n)).card < r := by + let S := Finset.univ.filter (fun j => p j ∣ n) + have hdiv : (∏ j ∈ S, p j) ∣ n := by + apply Finset.prod_dvd_of_isRelPrime + · intro i hi j hj hij + exact Nat.coprime_iff_isRelPrime.mp (hp hij) + · intro j hj + exact (Finset.mem_filter.mp hj).2 + have hlow : P ^ S.card ≤ ∏ j ∈ S, p j := + Finset.pow_card_le_prod S p P (fun j _ => hpP j) + have hle : P ^ S.card ≤ n := hlow.trans (Nat.le_of_dvd hn hdiv) + by_contra h + have hcard : r ≤ S.card := Nat.le_of_not_gt h + have hpow := pow_le_pow_right' hP hcard + exact (not_lt_of_ge (hpow.trans hle)) hnr + +lemma few_prime_divisors {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + {P r n : ℕ} (hP : 1 ≤ P) (hpP : ∀ j, P ≤ p j) + (hn : 0 < n) (hnr : n < P ^ r) : + (Finset.univ.filter (fun j => p j ∣ n)).card < r := by + apply few_divisors p (fun i j hij => ?_) hP hpP hn hnr + exact (Nat.coprime_primes (hp i) (hp j)).mpr (fun h => hij (hinj h)) + +lemma many_nondivisors_except {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + {P r n : ℕ} (hP : 1 ≤ P) (hpP : ∀ j, P ≤ p j) + (hn : 0 < n) (hnr : n < P ^ r) (i : J) : + Fintype.card J - r ≤ + (Finset.univ.filter (fun j => j ≠ i ∧ ¬p j ∣ n)).card := by + have hbad := few_prime_divisors p hp hinj hP hpP hn hnr + have hsum : (Finset.univ.filter (fun j : J => p j ∣ n)).card + + (Finset.univ.filter (fun j : J => ¬p j ∣ n)).card = Fintype.card J := by + exact Finset.card_filter_add_card_filter_not _ + have hins : (Finset.univ.filter (fun j : J => ¬p j ∣ n)) ⊆ + insert i (Finset.univ.filter (fun j => j ≠ i ∧ ¬p j ∣ n)) := by + intro j hj + by_cases hji : j = i + · simp [hji] + · simp only [Finset.mem_insert, Finset.mem_filter, Finset.mem_univ, true_and] + exact Or.inr ⟨hji, (Finset.mem_filter.mp hj).2⟩ + have hcard := Finset.card_le_card hins + have hle := Finset.card_insert_le i (Finset.univ.filter (fun j => j ≠ i ∧ ¬p j ∣ n)) + omega + +lemma many_nonzero_phases {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + {P r : ℕ} (hP : 1 ≤ P) (hpP : ∀ j, P ≤ p j) + {q : ℤ} (hq : q ≠ 0) (hqr : q.natAbs < P ^ r) (i : J) : + Fintype.card J - r ≤ + (Finset.univ.filter (fun j => j ≠ i ∧ ¬(p j : ℤ) ∣ q)).card := by + simpa only [Int.natCast_dvd] using + many_nondivisors_except p hp hinj hP hpP (Int.natAbs_pos.mpr hq) hqr i + +end EditPhase + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/PrimePool.lean b/lean/OAI/Combinatorics/EditDistance/PrimePool.lean new file mode 100644 index 0000000000000000000000000000000000000000..0240058450d19e1dbb32912de4971e1fde6c5d18 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/PrimePool.lean @@ -0,0 +1,172 @@ +import Mathlib + +namespace OAI + +/-! +# Finite pools of distinct primes from central binomial estimates +-/ + +namespace EditPrimes +open scoped BigOperators +open Nat Finset + +def pool (n : ℕ) : Finset ℕ := (Finset.Ioc n (2*n)).filter Nat.Prime + +lemma centralBinom_le_with_primes (n : ℕ) (hn : 2 < n) : + n.centralBinom ≤ (2*n)^(Nat.sqrt (2*n)) * 4^(2*n/3) * (2*n)^(pool n).card := by + have hpos : 0 < n := by omega + have h2pos : 1 ≤ 2*n := by omega + let f (p : ℕ) := p ^ n.centralBinom.factorization p + let S := (Finset.range (2*n+1)).filter Nat.Prime + let T := (Finset.range (2*n/3+1)).filter Nat.Prime + have heq : n.centralBinom = ∏ p ∈ S, f p := by + rw [← n.prod_pow_factorization_centralBinom] + dsimp [S,f] + symm + apply Finset.prod_filter_of_ne + intro p _ h + contrapose h + rw [Nat.factorization_eq_zero_of_not_prime _ h,pow_zero] + have hlow : ∏ p ∈ S.filter (· ≤ n), f p = ∏ p ∈ T, f p := by + symm + apply Finset.prod_subset + · intro p hp + obtain ⟨hp,hprime⟩ := Finset.mem_filter.mp hp + have hb := Finset.mem_range.mp hp + have hm : 2*n/3 ≤ n := by omega + exact Finset.mem_filter.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (by omega),hprime⟩,by omega⟩ + · intro p hp hpT + obtain ⟨hp,hpn⟩ := Finset.mem_filter.mp hp + obtain ⟨_,hprime⟩ := Finset.mem_filter.mp hp + have hb : 2*n/3 < p := by + by_contra h + apply hpT + exact Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (by omega),hprime⟩ + have hb' : 2*n < 3*p := by omega + dsimp [f] + rw [Nat.factorization_centralBinom_of_two_mul_self_lt_three_mul hn hpn hb',pow_zero] + have hhigh : S.filter (fun p => ¬p ≤ n) = pool n := by + ext p + simp only [S,pool,Finset.mem_filter,Finset.mem_range,Finset.mem_Ioc,Nat.lt_succ_iff,not_le] + tauto + have hT : ∏ p ∈ T, f p ≤ (2*n)^Nat.sqrt (2*n) * 4^(2*n/3) := by + rw [←Finset.prod_filter_mul_prod_filter_not T (· ≤ Nat.sqrt (2*n))] + apply mul_le_mul' + · refine (Finset.prod_le_prod (fun p _ => (show f p ≤ 2*n from + Nat.pow_factorization_choose_le (by omega)))).trans ?_ + rw [Finset.prod_const] + apply Nat.pow_le_pow_right h2pos + have hc : (Finset.Icc 1 (Nat.sqrt (2*n))).card = Nat.sqrt (2*n) := by + rw [Nat.card_Icc,Nat.add_sub_cancel] + apply (Finset.card_le_card ?_).trans hc.le + intro p hp + obtain ⟨hp,hs⟩ := Finset.mem_filter.mp hp + exact Finset.mem_Icc.mpr ⟨(Finset.mem_filter.mp hp).2.one_lt.le,hs⟩ + · refine le_trans ?_ (primorial_le_four_pow (2*n/3)) + refine (Finset.prod_le_prod (fun p hp => (show f p ≤ p from ?_))).trans ?_ + · obtain ⟨hp,hs⟩ := Finset.mem_filter.mp hp + dsimp [f] + refine (Nat.pow_le_pow_right (Finset.mem_filter.mp hp).2.one_lt.le ?_).trans (pow_one p).le + exact Nat.factorization_choose_le_one (Nat.sqrt_lt'.mp (not_le.mp hs)) + · apply Finset.prod_le_prod_of_subset_of_one_le (Finset.filter_subset _ _) + intro p hp _ + exact (Finset.mem_filter.mp hp).2.one_lt.le + rw [heq,←Finset.prod_filter_mul_prod_filter_not S (· ≤ n),hlow,hhigh] + apply Nat.mul_le_mul hT + calc + ∏ p ∈ pool n, f p ≤ ∏ _p ∈ pool n, (2*n) := + Finset.prod_le_prod (fun _ _ => Nat.pow_factorization_choose_le (by omega)) + _ = (2*n)^(pool n).card := Finset.prod_const _ + +end EditPrimes + +namespace EditPrimes +open scoped BigOperators +open Nat Finset Filter + +lemma binomial_log_bound {n : ℕ} (hn : 4 ≤ n) : + (n : ℝ) * Real.log 4 < Real.log (n : ℝ) + + ((Nat.sqrt (2*n) : ℝ) + (pool n).card) * Real.log (2*(n : ℝ)) + + (2*(n : ℝ)/3) * Real.log 4 := by + have hb := Nat.four_pow_lt_mul_centralBinom n (by omega) + have hu := centralBinom_le_with_primes n (by omega) + have hr : (4 : ℝ)^n < (n : ℝ) * + ((2*(n : ℝ))^(Nat.sqrt (2*n)) * 4^(2*n/3) * (2*(n : ℝ))^(pool n).card) := by + exact_mod_cast hb.trans_le (Nat.mul_le_mul_left n hu) + have hnR : 0 < (n : ℝ) := by exact_mod_cast (show 0 (b : ℝ)) Filter.atTop Filter.atTop := + tendsto_natCast_atTop_atTop + filter_upwards [hn.eventually hh,Filter.eventually_ge_atTop (2 : ℕ)] with b hlog hb + apply pool_square_large hb + have hbn : (1 : ℝ) ≤ b := by exact_mod_cast (show 1 ≤ b by omega) + have hlogb : 0 ≤ Real.log (b : ℝ) := Real.log_nonneg hbn + simpa only [Function.id_def,Real.norm_eq_abs,abs_of_nonneg hlogb, + abs_of_nonneg (Nat.cast_nonneg b : (0 : ℝ) ≤ b)] using hlog + +theorem primes_of_pool {b : ℕ} (hb : b ≤ (pool (b^2)).card) : + ∃ p : Fin b → ℕ, Function.Injective p ∧ + (∀ j, (p j).Prime) ∧ (∀ j, b^2 ≤ p j) ∧ (∀ j, p j ≤ 2*b^2) := by + classical + let e : Fin b ↪ (pool (b^2)) := Classical.choice + (Function.Embedding.nonempty_of_card_le (by simpa only [Fintype.card_fin,Fintype.card_coe] using hb)) + refine ⟨fun j => (e j).val, ?_, ?_, ?_, ?_⟩ + · intro i j hij + exact e.injective (Subtype.ext hij) + · intro j + exact (Finset.mem_filter.mp (e j).property).2 + · intro j + exact (Finset.mem_Ioc.mp (Finset.mem_filter.mp (e j).property).1).1.le + · intro j + exact (Finset.mem_Ioc.mp (Finset.mem_filter.mp (e j).property).1).2 + +end EditPrimes + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/RecursiveControl.lean b/lean/OAI/Combinatorics/EditDistance/RecursiveControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..56d42b711c477581825aa2ced9a22bf34b39c149 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/RecursiveControl.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.EditDistance.Families +import OAI.Combinatorics.EditDistance.DirectSums +import OAI.Combinatorics.EditDistance.Slots + +namespace OAI + +/-! +# Averaged displacement control for recursive word families +-/ + +namespace EditFamily +open scoped BigOperators +open EditDistortion EditAverage EditFourier EditSlots + +section InductiveControl +variable {J : Type} [Fintype J] [DecidableEq J] (i : J) + +noncomputable def weight (j : J) : ℝ := (EditSlots.multiplicity i j : ℝ) / (2 * (2 * Fintype.card J - 1)) + +lemma weight_pos (j : J) : 0 < weight i j := by + have hb : 0 < (Fintype.card J : ℝ) := by + exact_mod_cast Fintype.card_pos_iff.mpr ⟨i⟩ + have hb' : (1 : ℝ) ≤ Fintype.card J := by + exact_mod_cast (show 1 ≤ Fintype.card J by exact Fintype.card_pos_iff.mpr ⟨i⟩) + have hc : 0 < (EditSlots.multiplicity i j : ℝ) := by + by_cases hj : j = i <;> simp [EditSlots.multiplicity, hj, hb] + exact div_pos hc (by linarith) + +lemma sum_weight : (∑ j : J, weight i j) = 1 / 2 := by + have hb : (1 : ℝ) ≤ Fintype.card J := by + exact_mod_cast (show 1 ≤ Fintype.card J by exact Fintype.card_pos_iff.mpr ⟨i⟩) + simp only [weight, ← Finset.sum_div, sum_multiplicity] + field_simp [show (2 * (Fintype.card J : ℝ) - 1) ≠ 0 by linarith] + +variable {p : J → ℕ} {m A : ℕ} {α Q : ℝ} +variable (F : ∀ j, Family (p j) m A α Q) + +abbrev ProductState := ∀ j, (F j).State + +def lift (j : J) (e : (F j).State) : ProductState F := Pi.single j e + +def allPhase : ProductState F := fun j => (F j).v + +lemma sum_lift_vectors : (∑ j, lift F j (F j).v) = allPhase F := by + ext j + simp [lift, allPhase] + +omit [Fintype J] in +lemma lift_nsmul (j : J) (u : ℕ) (e : (F j).State) : + lift F j (u • e) = u • lift F j e := by + ext k + by_cases hk : k = j + · subst k; simp [lift] + · simp [lift, hk] + +lemma variation_zero (H : ProductState F → L1) : variation H 0 = 0 := by + simp [variation, avg] + +lemma component_control (hQ : 0 ≤ Q) (H : ProductState F → L1) + (hh : ∀ j e r, (e,r) ∈ (F j).steps → + variation H (lift F j e) ≤ weight i j * r) + (j : J) (a : ℕ) (ha : a < p j) : + variation H (a • lift F j (F j).v) ≤ weight i j * Q := by + by_cases ha0 : a = 0 + · simp only [ha0, zero_nsmul, variation_zero] + exact mul_nonneg (weight_pos i j).le hQ + let T := EditSlices.slice (fun j => (F j).State) H j (weight i j) + have hT : ∀ e r, (e,r) ∈ (F j).steps → variation T e ≤ r := by + intro e r her + rw [EditSlices.variation_slice _ H j _ (weight_pos i j)] + apply (div_le_iff₀ (weight_pos i j)).mpr + simpa only [lift, mul_comm] using hh j e r her + have hC := (F j).control T hT a (Nat.pos_of_ne_zero ha0) ha + rw [EditSlices.variation_slice _ H j _ (weight_pos i j)] at hC + have hC' := (div_le_iff₀ (weight_pos i j)).mp hC + change variation H (lift F j (a • (F j).v)) ≤ Q * weight i j at hC' + rw [lift_nsmul] at hC' + simpa only [mul_comm] using hC' + +theorem successor_control + (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + (P : ℝ) (hP : 1 ≤ 2 * P) (hpP : ∀ j, (p j : ℝ) ≤ 2 * P) + (h : ℕ) (hh : 0 < h) (L : ℕ) (hQ : 0 ≤ Q) + (H : ProductState F → L1) (hτ : variation H (allPhase F) ≤ 2 / L) + (hlift : ∀ j e r, (e,r) ∈ (F j).steps → + variation H (lift F j e) ≤ weight i j * r) + (u : ℕ) (hu : u < p i) : + variation H (u • lift F i (F i).v) ≤ + 2 * (2 * P) ^ (2 * h) / L + Q / h := by + let (j : J) : NeZero (p j) := ⟨(hp j).ne_zero⟩ + have hv (j : J) : p j • lift F j (F j).v = 0 := by + rw [← lift_nsmul, (F j).annihilate] + simp [lift] + have hc := prime_vector_displacement p (fun j => lift F j (F j).v) hv hp hinj + P hP hpP h hh H i (u : ZMod (p i)) + rw [ZMod.val_natCast_of_lt hu, sum_lift_vectors] at hc + have hb (j : J) : avg (fun a : ZMod (p j) => variation H (a.val • lift F j (F j).v)) ≤ + weight i j * Q := by + rw [← avg_const (X := ZMod (p j)) (weight i j * Q)] + exact avg_mono (fun a => component_control i F hQ H hlift j a.val (ZMod.val_lt a)) + calc + _ ≤ (2 * P) ^ (2 * h) * variation H (allPhase F) + + (2 / (h : ℝ)) * ∑ j, avg (fun a : ZMod (p j) => + variation H (a.val • lift F j (F j).v)) := hc + _ ≤ (2 * P) ^ (2 * h) * (2 / (L : ℝ)) + + (2 / (h : ℝ)) * ∑ j, weight i j * Q := by + apply add_le_add + · exact mul_le_mul_of_nonneg_left hτ (pow_nonneg (by linarith) _) + · exact mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun j _ => hb j)) (by positivity) + _ = _ := by rw [← Finset.sum_mul, sum_weight]; ring + +end InductiveControl +end EditFamily + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/RecursiveWords.lean b/lean/OAI/Combinatorics/EditDistance/RecursiveWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1fc8be727a71959c5f0d8e6a4ba2f8e90a96d8e --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/RecursiveWords.lean @@ -0,0 +1,382 @@ +import OAI.Combinatorics.EditDistance.RecursiveControl +import OAI.Combinatorics.EditDistance.RowConstruction +import OAI.Combinatorics.EditDistance.PrimePeriods + +namespace OAI + +/-! +# Recursive payloads, markers, symbol codes, and word separation +-/ + +namespace EditFamily +open scoped BigOperators +open EditDistortion EditAverage EditFourier EditSlots + +lemma torsionHom_intCast {G : Type*} [AddCommGroup G] (p : ℕ) (v : G) (hv : p • v = 0) + (a : ℤ) : torsionHom p v hv (a : ZMod p) = a • v := by + simp [torsionHom] + +lemma Family.far_int {p m A : ℕ} {α Q : ℝ} (F : Family p m A α Q) + (hp : 0 < p) (z : F.State) (a : ℤ) (ha : ¬ (p : ℤ) ∣ a) : + (m : ℝ) * α ≤ (indel (List.ofFn (F.word z)) (List.ofFn (F.word (z + a • F.v))) : ℝ) := by + let : NeZero p := ⟨Nat.ne_of_gt hp⟩ + let x : ZMod p := a + have hx : x ≠ 0 := fun h => ha ((ZMod.intCast_zmod_eq_zero_iff_dvd a p).mp h) + have hv : x.val • F.v = a • F.v := by + rw [← torsionHom_apply p F.v F.annihilate x] + exact torsionHom_intCast p F.v F.annihilate a + rw [← hv] + exact F.far z x.val (Nat.pos_of_ne_zero (fun h => hx ((ZMod.val_eq_zero x).mp h))) (ZMod.val_lt x) + +section Words +variable {J : Type} [Fintype J] [DecidableEq J] (i : J) +variable {p : J → ℕ} {m A : ℕ} {α Q : ℝ} +variable (F : ∀ j, Family (p j) m A α Q) + +noncomputable def payloadList (z : ProductState F) (row : ℕ) : List (Slots i × Fin A) := + tagged (enumeration i) (fun r => List.ofFn ((F (component i r)).word + (z (component i r) + row • (F (component i r)).v))) + +lemma payload_length (z : ProductState F) (row : ℕ) : + (payloadList i F z row).length = (2 * Fintype.card J - 1) * m := by + rw [payloadList, tagged_length, enumeration, List.map_ofFn, List.sum_ofFn] + simp only [Function.comp_apply, List.length_ofFn, Finset.sum_const, Finset.card_univ, + Fintype.card_fin, nsmul_eq_mul, slots_card, Nat.cast_id] + +noncomputable def payloadFn (z : ProductState F) (row : ℕ) : + Fin ((2 * Fintype.card J - 1) * m) → (Slots i × Fin A) := + fixedFn (payloadList i F z row) (payload_length i F z row) + +@[simp] lemma ofFn_payloadFn (z : ProductState F) (row : ℕ) : + List.ofFn (payloadFn i F z row) = payloadList i F z row := ofFn_fixedFn _ _ + +noncomputable def rawWord (L : ℕ) (z : ProductState F) : List (Option (Slots i × Fin A)) := + EditRows.rowWord (fun row : Fin L => payloadFn i F z row.val) + +@[simp] lemma rawWord_length (L : ℕ) (z : ProductState F) : + (rawWord i F L z).length = 2 * ((2 * Fintype.card J - 1) * m) * L := + EditRows.rowWord_length _ + +omit [Fintype J] in +lemma shift_state (z : ProductState F) (u row row' : ℕ) (j : J) : + (z + u • lift F i (F i).v) j + row' • (F j).v = + (z j + row • (F j).v) + + ((row' : ℤ) - (row : ℤ) + if j = i then (u : ℤ) else 0) • (F j).v := by + by_cases hj : j = i + · subst j + simp only [Pi.add_apply, Pi.smul_apply, lift, Pi.single_eq_same] + simp [add_zsmul, sub_zsmul] + abel + · simp only [Pi.add_apply, Pi.smul_apply, lift, Pi.single_eq_of_ne hj, smul_zero, + ite_eq_right hj, add_zero, sub_zsmul, natCast_zsmul] + abel + +noncomputable def componentDistance (z z' : ProductState F) (row row' : ℕ) (j : J) : ℝ := + indel (List.ofFn ((F j).word (z j + row • (F j).v))) + (List.ofFn ((F j).word (z' j + row' • (F j).v))) + +omit [Fintype J] [DecidableEq J] in +lemma componentDistance_nonneg (z z' : ProductState F) (row row' : ℕ) (j : J) : + 0 ≤ componentDistance F z z' row row' j := Nat.cast_nonneg _ + +lemma payload_distance_ge_sum (z z' : ProductState F) (row row' : ℕ) : + (∑ r : Slots i, componentDistance F z z' row row' (component i r)) ≤ + (indel (payloadList i F z row) (payloadList i F z' row') : ℝ) := by + exact sum_indel_le_tagged (enumeration i) (enumeration_nodup i) (enumeration_full i) _ _ + +omit [Fintype J] in +lemma componentDistance_far (hp : ∀ j, (p j).Prime) + (z : ProductState F) (u row row' : ℕ) (j : J) + (ha : ¬ (p j : ℤ) ∣ ((row' : ℤ) - (row : ℤ) + if j = i then (u : ℤ) else 0)) : + (m : ℝ) * α ≤ componentDistance F z (z + u • lift F i (F i).v) row row' j := by + unfold componentDistance + rw [shift_state] + exact (F j).far_int (hp j).pos _ _ ha + +lemma payload_separation + (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + (P : ℕ) (hP : 1 ≤ P) (hpP : ∀ j, P ≤ p j) (hα : 0 ≤ α) + (z : ProductState F) (u : ℕ) (hu0 : 0 < u) (hu : u < p i) + (row row' : ℕ) (hr : row < P ^ (Fintype.card J / 2)) + (hr' : row' < P ^ (Fintype.card J / 2)) : + α * Fintype.card J * m / 3 ≤ + (indel (payloadList i F z row) + (payloadList i F (z + u • lift F i (F i).v) row') : ℝ) := by + let D := componentDistance F z (z + u • lift F i (F i).v) row row' + have hDn (j : J) : 0 ≤ D j := componentDistance_nonneg F _ _ _ _ j + have hsum := payload_distance_ge_sum i F z (z + u • lift F i (F i).v) row row' + rw [sum_slots] at hsum + change (Fintype.card J : ℝ) * D i + ∑ j : {j : J // j ≠ i}, D j ≤ _ at hsum + have hma : 0 ≤ (m : ℝ) * α := mul_nonneg (Nat.cast_nonneg _) hα + have hrest : 0 ≤ ∑ j : {j : J // j ≠ i}, D j := Finset.sum_nonneg (fun j _ => hDn j) + by_cases hphase : ¬(p i : ℤ) ∣ ((row' : ℤ) - row + u) + · have hf : (m : ℝ) * α ≤ D i := by + exact componentDistance_far i F hp z u row row' i (by simpa using hphase) + have hmul := mul_le_mul_of_nonneg_left hf (Nat.cast_nonneg (Fintype.card J) : (0 : ℝ) ≤ _) + have hbma : 0 ≤ (Fintype.card J : ℝ) * ((m : ℝ) * α) := mul_nonneg (Nat.cast_nonneg _) hma + nlinarith + · push Not at hphase + let q : ℤ := (row' : ℤ) - row + have hq : q ≠ 0 := by + intro hq + have hd : (p i : ℤ) ∣ (u : ℤ) := by simpa [q, hq] using hphase + have hd' : p i ∣ u := by exact_mod_cast hd + exact Nat.not_dvd_of_pos_of_lt hu0 hu hd' + have hqr : q.natAbs < P ^ (Fintype.card J / 2) := by + apply Int.ofNat_lt.mp + rw [Int.natCast_natAbs] + apply abs_lt.mpr + dsimp [q] + have hrZ : (row : ℤ) < (P : ℤ) ^ (Fintype.card J / 2) := by exact_mod_cast hr + have hrZ' : (row' : ℤ) < (P : ℤ) ^ (Fintype.card J / 2) := by exact_mod_cast hr' + constructor <;> omega + let S := Finset.univ.filter (fun j => j ≠ i ∧ ¬(p j : ℤ) ∣ q) + have hc : Fintype.card J - Fintype.card J / 2 ≤ S.card := + EditPhase.many_nonzero_phases p hp hinj hP hpP hq hqr i + have hbc : (Fintype.card J : ℝ) / 3 ≤ (S.card : ℝ) := by + have hn : Fintype.card J ≤ 3 * (Fintype.card J - Fintype.card J / 2) := by omega + have hn' : (Fintype.card J : ℝ) ≤ 3 * ((Fintype.card J - Fintype.card J / 2 : ℕ) : ℝ) := by + exact_mod_cast hn + have hc' : ((Fintype.card J - Fintype.card J / 2 : ℕ) : ℝ) ≤ (S.card : ℝ) := by + exact_mod_cast hc + linarith + have hS : (S.card : ℝ) * ((m : ℝ) * α) ≤ ∑ j ∈ S, D j := by + calc + _ = ∑ _j ∈ S, (m : ℝ) * α := by simp + _ ≤ _ := by + apply Finset.sum_le_sum + intro j hj + obtain ⟨hji, hdiv⟩ := (Finset.mem_filter.mp hj).2 + exact componentDistance_far i F hp z u row row' j (by simpa [hji, q] using hdiv) + have hsub : S ⊆ Finset.univ.erase i := by + intro j hj + simp only [Finset.mem_erase, Finset.mem_univ, and_true] + exact (Finset.mem_filter.mp hj).2.1 + have hSrest : ∑ j ∈ S, D j ≤ ∑ j : {j : J // j ≠ i}, D j := by + rw [← Finset.sum_subtype (Finset.univ.erase i) (by simp) D] + exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun j _ _ => hDn j) + have hbound := mul_le_mul_of_nonneg_right hbc hma + have hdi : 0 ≤ (Fintype.card J : ℝ) * D i := mul_nonneg (Nat.cast_nonneg _) (hDn i) + nlinarith + +theorem rawWord_far + (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + (P : ℕ) (hP : 1 ≤ P) (hpP : ∀ j, P ≤ p j) (hm : 0 < m) + (hα0 : 0 ≤ α) (hα1 : α ≤ 1) + (z : ProductState F) (u : ℕ) (hu0 : 0 < u) (hu : u < p i) : + (2 * ((2 * Fintype.card J - 1) * m) * P ^ (Fintype.card J / 2) : ℕ) * (α / 24) ≤ + (indel (rawWord i F (P ^ (Fintype.card J / 2)) z) + (rawWord i F (P ^ (Fintype.card J / 2)) (z + u • lift F i (F i).v)) : ℝ) := by + have hb : 1 ≤ Fintype.card J := Fintype.card_pos_iff.mpr ⟨i⟩ + have hB : 0 < (2 * Fintype.card J - 1) * m := Nat.mul_pos (by omega) hm + have hbR : (1 : ℝ) ≤ Fintype.card J := by exact_mod_cast hb + have hcast : ((2 * Fintype.card J - 1 : ℕ) : ℝ) = 2 * (Fintype.card J : ℝ) - 1 := by + rw [Nat.cast_sub (by omega), Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] + have htB : α * Fintype.card J * m / 6 ≤ (((2 * Fintype.card J - 1) * m : ℕ) : ℝ) := by + rw [Nat.cast_mul, hcast] + have ha := mul_le_mul_of_nonneg_right hα1 (Nat.cast_nonneg (Fintype.card J) : (0 : ℝ) ≤ _) + have ha' := mul_le_mul_of_nonneg_right ha (Nat.cast_nonneg m : (0 : ℝ) ≤ _) + nlinarith [Nat.cast_nonneg m (α := ℝ)] + have h := EditRows.indel_row_separation + (fun r : Fin (P ^ (Fintype.card J / 2)) => payloadFn i F z r.val) + (fun r : Fin (P ^ (Fintype.card J / 2)) => payloadFn i F (z + u • lift F i (F i).v) r.val) + hB htB (by + intro r r' + rw [ofFn_payloadFn, ofFn_payloadFn] + convert payload_separation i F hp hinj P hP hpP hα0 z u hu0 hu r r' r.isLt r'.isLt using 1 + ring) + change (P ^ (Fintype.card J / 2) : ℕ) * (α * Fintype.card J * m / 6) ≤ _ at h + apply le_trans _ h + simp only [Nat.cast_mul, Nat.cast_ofNat, hcast] + have ha : 0 ≤ α * m * (P ^ (Fintype.card J / 2) : ℕ) := by positivity + nlinarith + +lemma payload_distance_le_sum (z z' : ProductState F) (row : ℕ) : + (indel (payloadList i F z row) (payloadList i F z' row) : ℝ) ≤ + ∑ r : Slots i, componentDistance F z z' row row (component i r) := by + have h := cost_tagged_le (enumeration i) + (fun r => List.ofFn ((F (component i r)).word (z (component i r) + row • (F (component i r)).v))) + (fun r => List.ofFn ((F (component i r)).word (z' (component i r) + row • (F (component i r)).v))) false + change indel (payloadList i F z row) (payloadList i F z' row) ≤ _ at h + rw [enumeration, List.map_ofFn, List.sum_ofFn] at h + have h' := Nat.cast_le (α := ℝ).mpr h + rw [Nat.cast_sum] at h' + change (indel (payloadList i F z row) (payloadList i F z' row) : ℝ) ≤ + ∑ x : Fin (Fintype.card (Slots i)), componentDistance F z z' row row + (component i ((Fintype.equivFin (Slots i)).symm x)) at h' + rw [(Fintype.equivFin (Slots i)).symm.sum_comp + (fun r => componentDistance F z z' row row (component i r))] at h' + exact h' + +omit [Fintype J] in +lemma componentDistance_lift (j : J) (e : (F j).State) (r : ℝ) + (her : (e,r) ∈ (F j).steps) (z : ProductState F) (row : ℕ) (k : J) : + componentDistance F z (z + lift F j e) row row k ≤ if k = j then m * r else 0 := by + by_cases hk : k = j + · subst k + have he : (z + lift F j e) j + row • (F j).v = (z j + row • (F j).v) + e := by + simp [lift, add_right_comm] + unfold componentDistance + rw [he, ite_eq_left rfl] + exact (F j).cheap e r her (z j + row • (F j).v) + · have he : (z + lift F j e) k + row • (F k).v = z k + row • (F k).v := by + simp [lift, hk] + simp only [componentDistance, he, ite_eq_right hk] + change (cost false _ _ : ℝ) ≤ 0 + simp only [cost_refl, Nat.cast_zero, le_refl] + +lemma payload_cheap_lift (j : J) (e : (F j).State) (r : ℝ) + (her : (e,r) ∈ (F j).steps) (z : ProductState F) (row : ℕ) : + (indel (payloadList i F z row) (payloadList i F (z + lift F j e) row) : ℝ) ≤ + multiplicity i j * m * r := by + calc + _ ≤ ∑ s : Slots i, componentDistance F z (z + lift F j e) row row (component i s) := + payload_distance_le_sum i F z (z + lift F j e) row + _ ≤ ∑ s : Slots i, if component i s = j then (m : ℝ) * r else 0 := by + apply Finset.sum_le_sum + intro s _ + exact componentDistance_lift F j e r her z row (component i s) + _ = _ := by rw [sum_slots_delta]; ring + +lemma rawWord_cheap_lift (hm : 0 < m) (L : ℕ) + (j : J) (e : (F j).State) (r : ℝ) (her : (e,r) ∈ (F j).steps) (z : ProductState F) : + (indel (rawWord i F L z) (rawWord i F L (z + lift F j e)) : ℝ) ≤ + (2 * ((2 * Fintype.card J - 1) * m) * L : ℕ) * (weight i j * r) := by + have hb : 1 ≤ Fintype.card J := Fintype.card_pos_iff.mpr ⟨i⟩ + have hB : 0 < (2 * Fintype.card J - 1) * m := Nat.mul_pos (by omega) hm + have hbR : (1 : ℝ) ≤ Fintype.card J := by exact_mod_cast hb + have hcast : ((2 * Fintype.card J - 1 : ℕ) : ℝ) = 2 * (Fintype.card J : ℝ) - 1 := by + rw [Nat.cast_sub (by omega), Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] + have h := EditRows.indel_rowWord_le hB + (fun row : Fin L => payloadFn i F z row.val) + (fun row : Fin L => payloadFn i F (z + lift F j e) row.val) + have h' := Nat.cast_le (α := ℝ).mpr h + change (indel (rawWord i F L z) (rawWord i F L (z + lift F j e)) : ℝ) ≤ _ at h' + rw [Nat.cast_sum] at h' + simp only [ofFn_payloadFn] at h' + calc + _ ≤ ∑ row : Fin L, (indel (payloadList i F z row.val) + (payloadList i F (z + lift F j e) row.val) : ℝ) := h' + _ ≤ ∑ _row : Fin L, (multiplicity i j : ℝ) * m * r := + Finset.sum_le_sum (fun row _ => payload_cheap_lift i F j e r her z row.val) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, + weight, Nat.cast_mul, Nat.cast_ofNat, hcast] + field_simp [show (2 * (Fintype.card J : ℝ) - 1) ≠ 0 by linarith] + +lemma payload_allPhase (z : ProductState F) (row : ℕ) : + payloadList i F (z + allPhase F) row = payloadList i F z (row+1) := by + unfold payloadList + congr 1 + funext s + congr 2 + simp only [Pi.add_apply, allPhase, add_nsmul, one_nsmul] + abel + +lemma rawWord_cheap_phase (hm : 0 < m) (L : ℕ) (hL : 0 < L) (z : ProductState F) : + (indel (rawWord i F L z) (rawWord i F L (z + allPhase F)) : ℝ) ≤ + (2 * ((2 * Fintype.card J - 1) * m) * L : ℕ) * (2 / (L : ℝ)) := by + have hb : 1 ≤ Fintype.card J := Fintype.card_pos_iff.mpr ⟨i⟩ + have hB : 0 < (2 * Fintype.card J - 1) * m := Nat.mul_pos (by omega) hm + have h := EditRows.indel_row_shift hL hB + (fun row : Fin L => payloadFn i F z row.val) + (fun row : Fin L => payloadFn i F (z + allPhase F) row.val) (by + intro a b hab + apply List.ofFn_injective + rw [ofFn_payloadFn, ofFn_payloadFn, payload_allPhase, hab]) + have h' := Nat.cast_le (α := ℝ).mpr h + change (indel (rawWord i F L z) (rawWord i F L (z + allPhase F)) : ℝ) ≤ _ at h' + convert h' using 1 + push_cast + field_simp + ring + +noncomputable def symbolCode : Option (Slots i × Fin A) ≃ + Fin (1 + (2 * Fintype.card J - 1) * A) := + (Fintype.equivFin _).trans (finCongr (by + rw [Fintype.card_option, Fintype.card_prod, slots_card, Fintype.card_fin] + omega)) + +noncomputable def nextWord (L : ℕ) (z : ProductState F) : + Fin (2 * ((2 * Fintype.card J - 1) * m) * L) → + Fin (1 + (2 * Fintype.card J - 1) * A) := + fixedFn ((rawWord i F L z).map (symbolCode (A := A) i)) (by simp) + +@[simp] lemma ofFn_nextWord (L : ℕ) (z : ProductState F) : + List.ofFn (nextWord i F L z) = (rawWord i F L z).map (symbolCode (A := A) i) := + ofFn_fixedFn _ _ + +lemma nextWord_distance (L : ℕ) (z z' : ProductState F) : + indel (List.ofFn (nextWord i F L z)) (List.ofFn (nextWord i F L z')) = + indel (rawWord i F L z) (rawWord i F L z') := by + rw [ofFn_nextWord, ofFn_nextWord] + exact cost_map_eq_of_leftInverse (s := false) (symbolCode (A := A) i) + (symbolCode (A := A) i).symm (symbolCode (A := A) i).left_inv _ _ + +noncomputable def nextSteps (L : ℕ) : List (ProductState F × ℝ) := + (allPhase F, 2 / (L : ℝ)) :: (Finset.univ.toList.flatMap (fun j => + (F j).steps.map (fun er => (lift F j er.1, weight i j * er.2)))) + +lemma mem_nextSteps (L : ℕ) (e : ProductState F) (r : ℝ) : + (e,r) ∈ nextSteps i F L ↔ + (e = allPhase F ∧ r = 2 / (L : ℝ)) ∨ + ∃ (j : J) (e' : (F j).State) (r' : ℝ), (e',r') ∈ (F j).steps ∧ + e = lift F j e' ∧ r = weight i j * r' := by + simp only [nextSteps, List.mem_cons, Prod.mk.injEq, List.mem_flatMap, + Finset.mem_toList, Finset.mem_univ, true_and, List.mem_map] + constructor + · rintro (h | ⟨j, ⟨e',r'⟩, hmem, h⟩) + · exact Or.inl h + · exact Or.inr ⟨j,e',r',hmem,h.1.symm,h.2.symm⟩ + · rintro (h | ⟨j,e',r',hmem,he,hr⟩) + · exact Or.inl h + · exact Or.inr ⟨j,(e',r'),hmem,he.symm,hr.symm⟩ + +noncomputable def successor + (hp : ∀ j, (p j).Prime) (hinj : Function.Injective p) + (P : ℕ) (hP : 1 ≤ P) (hpLow : ∀ j, P ≤ p j) (hpHigh : ∀ j, p j ≤ 2 * P) + (hm : 0 < m) (hα0 : 0 ≤ α) (hα1 : α ≤ 1) (hQ : 0 ≤ Q) + (h : ℕ) (hh : 0 < h) : + Family (p i) (2 * ((2 * Fintype.card J - 1) * m) * P ^ (Fintype.card J / 2)) + (1 + (2 * Fintype.card J - 1) * A) (α / 24) + (2 * (2 * (P : ℝ)) ^ (2 * h) / (P ^ (Fintype.card J / 2) : ℕ) + Q / h) := by + classical + let L := P ^ (Fintype.card J / 2) + have hL : 0 < L := pow_pos (by omega) _ + refine { State := ProductState F + group := inferInstance + finite := inferInstance + v := lift F i (F i).v + annihilate := ?_ + word := nextWord i F L + steps := nextSteps i F L + positive := ?_ + cheap := ?_ + far := ?_ + control := ?_ } + · rw [← lift_nsmul, (F i).annihilate] + simp [lift] + · intro e r her + rcases (mem_nextSteps i F L e r).mp her with ⟨rfl,rfl⟩ | ⟨j,e',r',hmem,rfl,rfl⟩ + · exact div_pos (by norm_num) (by exact_mod_cast hL) + · exact mul_pos (weight_pos i j) ((F j).positive e' r' hmem) + · intro e r her z + rw [nextWord_distance] + rcases (mem_nextSteps i F L e r).mp her with ⟨rfl,rfl⟩ | ⟨j,e',r',hmem,rfl,rfl⟩ + · exact rawWord_cheap_phase i F hm L hL z + · exact rawWord_cheap_lift i F hm L j e' r' hmem z + · intro z u hu0 hu + rw [nextWord_distance] + exact rawWord_far i F hp hinj P hP hpLow hm hα0 hα1 z u hu0 hu + · intro H hb u _hu0 hu + apply successor_control i F hp hinj P (by exact_mod_cast (show 1 ≤ 2 * P by omega)) + (fun j => by exact_mod_cast hpHigh j) h hh L hQ H + · exact hb _ _ ((mem_nextSteps i F L _ _).mpr (Or.inl ⟨rfl,rfl⟩)) + · intro j e r hmem + exact hb _ _ ((mem_nextSteps i F L _ _).mpr (Or.inr ⟨j,e,r,hmem,rfl,rfl⟩)) + · exact hu + +end Words +end EditFamily + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/RowAlignment.lean b/lean/OAI/Combinatorics/EditDistance/RowAlignment.lean new file mode 100644 index 0000000000000000000000000000000000000000..f477a4523187e41c3ba54c90235a5a5c5869c7df --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/RowAlignment.lean @@ -0,0 +1,309 @@ +import OAI.Combinatorics.EditDistance.Metric + +namespace OAI + +/-! +# Charging arbitrary alignments across rows and markers +-/ + +namespace EditRows +open scoped BigOperators + +def payload (B i : ℕ) : Finset ℕ := Finset.Ico (2 * B * i) (2 * B * i + B) +def marker (B i : ℕ) : Finset ℕ := Finset.Ico (2 * B * i + B) (2 * B * i + 2 * B) + +lemma mem_payload {B i x : ℕ} : x ∈ payload B i ↔ 2 * B * i ≤ x ∧ x < 2 * B * i + B := by + simp [payload] + +lemma mem_marker {B i x : ℕ} : x ∈ marker B i ↔ + 2 * B * i + B ≤ x ∧ x < 2 * B * i + 2 * B := by + simp [marker] + +lemma card_payload (B i : ℕ) : (payload B i).card = B := by simp [payload] +lemma card_marker (B i : ℕ) : (marker B i).card = B := by simp [marker]; omega + +lemma payload_before {B i j x y : ℕ} (hij : i < j) + (hx : x ∈ payload B i) (hy : y ∈ payload B j) : x < y := by + have hx := mem_payload.mp hx + have hy := mem_payload.mp hy + have h : 2 * B * (i + 1) ≤ 2 * B * j := Nat.mul_le_mul_left _ hij + nlinarith + +lemma marker_disjoint {B i j : ℕ} (h : i ≠ j) : Disjoint (marker B i) (marker B j) := by + apply Finset.disjoint_left.mpr + intro x hx hy + have hx := mem_marker.mp hx + have hy := mem_marker.mp hy + rcases lt_or_gt_of_ne h with h | h + · have h' : 2 * B * (i + 1) ≤ 2 * B * j := Nat.mul_le_mul_left _ h + nlinarith + · have h' : 2 * B * (j + 1) ≤ 2 * B * i := Nat.mul_le_mul_left _ h + nlinarith + +lemma payload_disjoint {B i j : ℕ} (h : i ≠ j) : Disjoint (payload B i) (payload B j) := by + apply Finset.disjoint_left.mpr + intro x hx hy + rcases lt_or_gt_of_ne h with h | h + · exact (Nat.lt_irrefl x) (payload_before h hx hy) + · exact (Nat.lt_irrefl x) (payload_before h hy hx) + +lemma payload_subset_range {B L i : ℕ} (hi : i < L) : + payload B i ⊆ Finset.range (2 * B * L) := by + intro x hx + have hx := mem_payload.mp hx + have h : 2 * B * (i + 1) ≤ 2 * B * L := Nat.mul_le_mul_left _ hi + simp only [Finset.mem_range] + nlinarith + +lemma marker_subset_range {B L i : ℕ} (hi : i < L) : + marker B i ⊆ Finset.range (2 * B * L) := by + intro x hx + have hx := mem_marker.mp hx + have h : 2 * B * (i + 1) ≤ 2 * B * L := Nat.mul_le_mul_left _ hi + simp only [Finset.mem_range] + nlinarith + +lemma payload_index {B : ℕ} (hB : 0 < B) {i x : ℕ} (hx : x ∈ payload B i) : + x / (2 * B) = i := by + have hx := mem_payload.mp hx + apply Nat.div_eq_of_lt_le <;> nlinarith + +lemma payload_of_mod {B x : ℕ} (hx : x % (2 * B) < B) : + x ∈ payload B (x / (2 * B)) := by + rw [mem_payload] + have h := Nat.mod_add_div x (2 * B) + constructor <;> omega + +lemma marker_between {B i a b : ℕ} (ha : a ∈ payload B i) + (hb : i < b / (2 * B)) {x : ℕ} (hx : x ∈ marker B i) : a < x ∧ x < b := by + have ha := mem_payload.mp ha + have hx := mem_marker.mp hx + have h : 2 * B * (i + 1) ≤ 2 * B * (b / (2 * B)) := Nat.mul_le_mul_left _ hb + have hd := Nat.div_mul_le_self b (2 * B) + constructor <;> nlinarith + +lemma marker_not_payload {B i x : ℕ} (hB : 0 < B) (hx : x ∈ marker B i) : + ¬ x % (2 * B) < B := by + intro hp + have h := payload_of_mod hp + have hm := mem_marker.mp hx + have hd : x / (2 * B) = i := by + apply Nat.div_eq_of_lt_le <;> nlinarith + rw [hd] at h + have h := mem_payload.mp h + omega + +section Matching +variable {k B L : ℕ} {f g : Fin k → ℕ} +variable (hf : StrictMono f) (hg : StrictMono g) +include hf hg + +def rowMatches (f : Fin k → ℕ) (B i : ℕ) : Finset (Fin k) := + Finset.univ.filter (fun a => f a ∈ payload B i) + +def Cross (f g : Fin k → ℕ) (B i : ℕ) : Prop := + ∃ a b : Fin k, f a ∈ payload B i ∧ f b ∈ payload B i ∧ + g a / (2 * B) < g b / (2 * B) + +lemma crossing_marker_unmatched (hB : 0 < B) + (hclean : ∀ a : Fin k, ∀ i : ℕ, f a ∈ payload B i → g a % (2 * B) < B) + {i : ℕ} {a b : Fin k} (ha : f a ∈ payload B i) (hb : f b ∈ payload B i) + (hab : g a / (2 * B) < g b / (2 * B)) : + Disjoint (marker B (g a / (2 * B))) (Finset.univ.image g) := by + apply Finset.disjoint_left.mpr + intro x hx hxm + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hxm + obtain ⟨hac, hcb⟩ := marker_between (payload_of_mod (hclean a i ha)) hab hx + have hac' : a < c := hg.lt_iff_lt.mp hac + have hcb' : c < b := hg.lt_iff_lt.mp hcb + have hfa := hf hac' + have hfb := hf hcb' + have hc : f c ∈ payload B i := by + have ha := mem_payload.mp ha + have hb := mem_payload.mp hb + rw [mem_payload] + omega + exact marker_not_payload hB hx (hclean c i hc) + +lemma crossing_marker_distinct {i j : ℕ} (hij : i ≠ j) {a b c d : Fin k} + (ha : f a ∈ payload B i) (hb : f b ∈ payload B i) + (hc : f c ∈ payload B j) (hd : f d ∈ payload B j) + (hab : g a / (2 * B) < g b / (2 * B)) + (hcd : g c / (2 * B) < g d / (2 * B)) : + g a / (2 * B) ≠ g c / (2 * B) := by + intro heq + rcases lt_or_gt_of_ne hij with hij | hji + · have hbc : b < c := hf.lt_iff_lt.mp (payload_before hij hb hc) + have hbc' := hg hbc + have hbc'' : g b / (2 * B) ≤ g c / (2 * B) := Nat.div_le_div_right (Nat.le_of_lt hbc') + omega + · have hda : d < a := hf.lt_iff_lt.mp (payload_before hji hd ha) + have hda' := hg hda + have hda'' : g d / (2 * B) ≤ g a / (2 * B) := Nat.div_le_div_right (Nat.le_of_lt hda') + omega + +end Matching +end EditRows + +namespace EditRows +open scoped BigOperators + +lemma sum_cards_le {I X : Type*} [Fintype I] [DecidableEq X] + (S : I → Finset X) (U : Finset X) + (hdisj : Pairwise (fun i j => Disjoint (S i) (S j))) + (hsub : ∀ i, S i ⊆ U) : ∑ i, (S i).card ≤ U.card := by + classical + have hd : (↑(Finset.univ : Finset I) : Set I).PairwiseDisjoint S := + fun i _ j _ hij => hdisj hij + rw [← Finset.card_biUnion hd] + apply Finset.card_le_card + intro x hx + obtain ⟨i, _, hx⟩ := Finset.mem_biUnion.mp hx + exact hsub i hx + +lemma noncross_loss {k B i t : ℕ} {f g : Fin k → ℕ} + (hclean : ∀ a : Fin k, f a ∈ payload B i → g a % (2 * B) < B) + (hcross : ¬ Cross f g B i) (ht : t ≤ B) + (hlocal : ∀ j : ℕ, + t + ((rowMatches f B i).filter (fun a => g a ∈ payload B j)).card ≤ B) : + t + (rowMatches f B i).card ≤ B := by + classical + by_cases hne : (rowMatches f B i).Nonempty + · obtain ⟨a, ha⟩ := hne + have ha' : f a ∈ payload B i := (Finset.mem_filter.mp ha).2 + have heq : (rowMatches f B i).filter (fun b => g b ∈ payload B (g a / (2 * B))) = + rowMatches f B i := by + apply Finset.filter_eq_self.mpr + intro b hb + have hb' : f b ∈ payload B i := (Finset.mem_filter.mp hb).2 + have hab : g b / (2 * B) = g a / (2 * B) := by + by_contra hn + rcases lt_or_gt_of_ne hn with h | h + · exact hcross ⟨b, a, hb', ha', h⟩ + · exact hcross ⟨a, b, ha', hb', h⟩ + simpa only [hab] using payload_of_mod (hclean b hb') + simpa only [heq] using hlocal (g a / (2 * B)) + · have hnil : rowMatches f B i = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne + simpa only [hnil, Finset.card_empty, Nat.add_zero] using ht + +lemma source_loss_card {k B i : ℕ} {f : Fin k → ℕ} (hf : Function.Injective f) : + (payload B i \ Finset.univ.image f).card = B - (rowMatches f B i).card := by + classical + have himg : (rowMatches f B i).image f = Finset.univ.image f ∩ payload B i := by + ext x + simp only [rowMatches, Finset.mem_image, Finset.mem_filter, Finset.mem_univ, + true_and, Finset.mem_inter] + constructor + · rintro ⟨a, ha, rfl⟩ + exact ⟨⟨a, rfl⟩, ha⟩ + · rintro ⟨⟨a, rfl⟩, ha⟩ + exact ⟨a, ha, rfl⟩ + rw [Finset.card_sdiff, ← himg, card_payload, Finset.card_image_of_injective _ hf] + +lemma unmatched_card {k N : ℕ} {f : Fin k → ℕ} (hf : Function.Injective f) + (hb : ∀ a, f a < N) : + (Finset.range N \ Finset.univ.image f).card = N - k := by + have hsub : Finset.univ.image f ⊆ Finset.range N := by + intro x hx + obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hx + exact Finset.mem_range.mpr (hb a) + rw [Finset.card_sdiff_of_subset hsub, Finset.card_range, + Finset.card_image_of_injective _ hf, Finset.card_univ, Fintype.card_fin] + +theorem matching_loss {k B L t : ℕ} {f g : Fin k → ℕ} + (hf : StrictMono f) (hg : StrictMono g) (hB : 0 < B) + (hfb : ∀ a, f a < 2 * B * L) (hgb : ∀ a, g a < 2 * B * L) + (hclean : ∀ a : Fin k, ∀ i : ℕ, f a ∈ payload B i → g a % (2 * B) < B) + (ht : t ≤ B) + (hlocal : ∀ i : Fin L, ∀ j : ℕ, + t + ((rowMatches f B i).filter (fun a => g a ∈ payload B j)).card ≤ B) : + L * t ≤ 2 * (2 * B * L - k) := by + classical + let C : Finset (Fin L) := Finset.univ.filter (fun i => Cross f g B i) + have hex : ∀ i : C, ∃ a b : Fin k, f a ∈ payload B i.val ∧ + f b ∈ payload B i.val ∧ g a / (2 * B) < g b / (2 * B) := by + intro i + exact (Finset.mem_filter.mp i.property).2 + choose a b ha hb hab using hex + let S (i : Fin L) : Finset ℕ := + if i ∈ C then ∅ else payload B i \ Finset.univ.image f + let T (i : Fin L) : Finset ℕ := + if h : i ∈ C then marker B (g (a ⟨i, h⟩) / (2 * B)) else ∅ + have hsdisj : Pairwise (fun i j => Disjoint (S i) (S j)) := by + intro i j hij + dsimp [S] + split_ifs with hi hj <;> try simp + exact (payload_disjoint (Fin.val_ne_of_ne hij)).mono Finset.sdiff_subset Finset.sdiff_subset + have htdisj : Pairwise (fun i j => Disjoint (T i) (T j)) := by + intro i j hij + dsimp [T] + split_ifs with hi hj <;> try simp + apply marker_disjoint + exact crossing_marker_distinct hf hg (Fin.val_ne_of_ne hij) + (ha ⟨i, hi⟩) (hb ⟨i, hi⟩) (ha ⟨j, hj⟩) (hb ⟨j, hj⟩) + (hab ⟨i, hi⟩) (hab ⟨j, hj⟩) + have hssub : ∀ i, S i ⊆ Finset.range (2 * B * L) \ Finset.univ.image f := by + intro i x hx + dsimp [S] at hx + split_ifs at hx with hi + · simp at hx + · obtain ⟨hp, hn⟩ := Finset.mem_sdiff.mp hx + exact Finset.mem_sdiff.mpr ⟨payload_subset_range i.isLt hp, hn⟩ + have htsub : ∀ i, T i ⊆ Finset.range (2 * B * L) \ Finset.univ.image g := by + intro i x hx + dsimp [T] at hx + split_ifs at hx with hi + · have hd := crossing_marker_unmatched hf hg hB hclean + (ha ⟨i, hi⟩) (hb ⟨i, hi⟩) (hab ⟨i, hi⟩) + have hi' : g (a ⟨i, hi⟩) / (2 * B) < L := + (Nat.div_lt_iff_lt_mul (by omega)).mpr (by simpa [Nat.mul_comm] using hgb (a ⟨i, hi⟩)) + exact Finset.mem_sdiff.mpr ⟨marker_subset_range hi' hx, Finset.disjoint_left.mp hd hx⟩ + · simp at hx + have hsc := sum_cards_le S _ hsdisj hssub + have htc := sum_cards_le T _ htdisj htsub + rw [unmatched_card hf.injective hfb] at hsc + rw [unmatched_card hg.injective hgb] at htc + have heach : ∀ i : Fin L, t ≤ (S i).card + (T i).card := by + intro i + dsimp [S, T] + split_ifs with hi + · simpa only [Finset.card_empty, card_marker, Nat.zero_add] using ht + · simp only [Finset.card_empty, Nat.add_zero, source_loss_card hf.injective] + have hn : ¬ Cross f g B i := by + simpa only [C, Finset.mem_filter, Finset.mem_univ, true_and] using hi + have h := noncross_loss (fun a ha => hclean a i ha) hn ht (hlocal i) + omega + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun i _ => heach i) + simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, + Fintype.card_fin, smul_eq_mul] at hsum + omega + +end EditRows + +namespace EditRows + +theorem matching_loss_real {k B L : ℕ} {t : ℝ} {f g : Fin k → ℕ} + (hf : StrictMono f) (hg : StrictMono g) (hB : 0 < B) + (hfb : ∀ a, f a < 2 * B * L) (hgb : ∀ a, g a < 2 * B * L) + (hclean : ∀ a : Fin k, ∀ i : ℕ, f a ∈ payload B i → g a % (2 * B) < B) + (ht : t ≤ B) + (hlocal : ∀ i : Fin L, ∀ j : ℕ, + t + (((rowMatches f B i).filter (fun a => g a ∈ payload B j)).card : ℝ) ≤ B) : + (L : ℝ) * t ≤ 2 * ((2 * B * L - k : ℕ) : ℝ) := by + classical + by_cases ht0 : 0 ≤ t + · have hceil : ∀ i : Fin L, ∀ j : ℕ, + ⌈t⌉₊ + ((rowMatches f B i).filter (fun a => g a ∈ payload B j)).card ≤ B := by + intro i j + rw [← Nat.ceil_add_natCast ht0] + exact Nat.ceil_le.mpr (hlocal i j) + have h := matching_loss hf hg hB hfb hgb hclean (Nat.ceil_le.mpr ht) hceil + have h' : (L : ℝ) * (⌈t⌉₊ : ℝ) ≤ 2 * ((2 * B * L - k : ℕ) : ℝ) := by + exact_mod_cast h + exact (mul_le_mul_of_nonneg_left (Nat.le_ceil t) (Nat.cast_nonneg L)).trans h' + · exact (mul_nonpos_of_nonneg_of_nonpos (Nat.cast_nonneg L) (le_of_not_ge ht0)).trans + (mul_nonneg (by norm_num) (Nat.cast_nonneg _)) + +end EditRows + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/RowConstruction.lean b/lean/OAI/Combinatorics/EditDistance/RowConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..660ac0cb290e3f79d660a5e570a016c51864a3c2 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/RowConstruction.lean @@ -0,0 +1,126 @@ +import OAI.Combinatorics.EditDistance.RowSeparation + +namespace OAI + +/-! +# Row concatenation and cyclic phase shifts +-/ + +namespace EditRows + +lemma rowValue_offset {A : Type*} {L B : ℕ} (hB : 0 < B) + (P : Fin L → Fin B → A) (i : Fin L) (j : Fin (2 * B)) : + rowValue P ⟨2 * B * i.val + j.val, by nlinarith [i.isLt, j.isLt]⟩ = + if h : j.val < B then some (P i ⟨j.val, h⟩) else none := by + have hdiv : (2 * B * i.val + j.val) / (2 * B) = i.val := by + simp [Nat.mul_add_div (by omega : 0 < 2 * B), Nat.div_eq_of_lt j.isLt] + have hmod : (2 * B * i.val + j.val) % (2 * B) = j.val := by + simp [Nat.add_mod, Nat.mod_eq_of_lt j.isLt] + unfold rowValue + simp only [hmod, hdiv] + +lemma chunk_ofFn {A : Type*} {B : ℕ} (P : Fin B → A) : + (List.ofFn (fun j : Fin (2 * B) => + if h : j.val < B then some (P ⟨j.val, h⟩) else none)) = + (List.ofFn P).map some ++ List.replicate B none := by + rw [show 2 * B = B + B by omega] + rw [List.ofFn_add] + congr 1 + · rw [List.map_ofFn] + apply congrArg List.ofFn + funext i + simp [i.isLt] + · have he : (fun i : Fin B => if h : (Fin.natAdd B i).val < B then + some (P ⟨(Fin.natAdd B i).val, h⟩) else none) = (fun _ => (none : Option A)) := by + funext i + simp + simp only [he, List.ofFn_const] + +lemma rowWord_flatten {A : Type*} {L B : ℕ} (hB : 0 < B) (P : Fin L → Fin B → A) : + rowWord P = (List.ofFn (fun i : Fin L => + (List.ofFn (P i)).map some ++ List.replicate B none)).flatten := by + rw [rowWord, List.ofFn_mul'] + congr 1 + apply congrArg List.ofFn + funext i + simp_rw [rowValue_offset hB] + exact chunk_ofFn (P i) + +lemma indel_flatten_le {A : Type*} (x y : List (List A)) (hlen : x.length = y.length) : + EditDistortion.indel x.flatten y.flatten ≤ + ((x.zip y).map (fun z => EditDistortion.indel z.1 z.2)).sum := by + induction x generalizing y with + | nil => + have hy : y = [] := List.length_eq_zero_iff.mp hlen.symm + subst y + exact le_of_eq (EditDistortion.cost_refl (s := false) []) + | cons a x ih => + cases y with + | nil => simp at hlen + | cons b y => + simp only [List.length_cons, Nat.add_right_cancel_iff] at hlen + have hh := EditDistortion.cost_append_le (s := false) a b x.flatten y.flatten + exact hh.trans (by simpa only [List.zip_cons_cons, List.map_cons, List.sum_cons] using! Nat.add_le_add_left (ih y hlen) (EditDistortion.indel a b)) + +lemma zip_ofFn {A C : Type*} {n : ℕ} (f : Fin n → A) (g : Fin n → C) : + (List.ofFn f).zip (List.ofFn g) = List.ofFn (fun i => (f i, g i)) := by + simp only [List.ofFn_eq_map, List.zip_map'] + +lemma indel_rowWord_le {A : Type*} {L B : ℕ} (hB : 0 < B) + (P Q : Fin L → Fin B → A) : + EditDistortion.indel (rowWord P) (rowWord Q) ≤ + ∑ i, EditDistortion.indel (List.ofFn (P i)) (List.ofFn (Q i)) := by + classical + rw [rowWord_flatten hB P, rowWord_flatten hB Q] + have h := indel_flatten_le + (List.ofFn (fun i : Fin L => (List.ofFn (P i)).map some ++ List.replicate B none)) + (List.ofFn (fun i : Fin L => (List.ofFn (Q i)).map some ++ List.replicate B none)) (by simp) + apply h.trans + rw [zip_ofFn, List.map_ofFn, List.sum_ofFn] + apply Finset.sum_le_sum + intro i _ + have ha := EditDistortion.cost_append_le (s := false) + ((List.ofFn (P i)).map some) ((List.ofFn (Q i)).map some) + (List.replicate B none) (List.replicate B none) + have hb := EditDistortion.cost_map_le (s := false) some (List.ofFn (P i)) (List.ofFn (Q i)) + simpa only [EditDistortion.cost_refl, Nat.add_zero] using! ha.trans (Nat.add_le_add_right hb _) + +end EditRows + +namespace EditRows + +lemma indel_shift_flatten {A : Type*} {n R : ℕ} (P Q : Fin (n+1) → List A) + (hfront : (P 0).length ≤ R) (hback : (Q (Fin.last n)).length ≤ R) + (halign : ∀ i : Fin n, Q i.castSucc = P i.succ) : + EditDistortion.indel (List.ofFn P).flatten (List.ofFn Q).flatten ≤ 2 * R := by + have hp : (List.ofFn P).flatten = P 0 ++ (List.ofFn (fun i : Fin n => P i.succ)).flatten := by + rw [List.ofFn_succ, List.flatten_cons] + have hq : (List.ofFn Q).flatten = + (List.ofFn (fun i : Fin n => Q i.castSucc)).flatten ++ Q (Fin.last n) := by + rw [List.ofFn_succ', List.concat_eq_append, List.flatten_append] + simp + rw [hp, hq] + simp_rw [halign] + let m := (List.ofFn (fun i : Fin n => P i.succ)).flatten + have h₁ : EditDistortion.Script false (P 0).length (P 0 ++ m) m := by + simpa using (EditDistortion.Script.to_nil (s := false) (P 0)).append_right m + have h₂ : EditDistortion.Script false (Q (Fin.last n)).length m (m ++ Q (Fin.last n)) := by + simpa using (EditDistortion.Script.to_nil (s := false) (Q (Fin.last n))).symm.append_left m + exact (EditDistortion.cost_le (h₁.trans h₂)).trans (by omega) + +lemma indel_row_shift {A : Type*} {L B : ℕ} (hL : 0 < L) (hB : 0 < B) + (P Q : Fin L → Fin B → A) + (halign : ∀ (i j : Fin L), j.val = i.val + 1 → Q i = P j) : + EditDistortion.indel (rowWord P) (rowWord Q) ≤ 4 * B := by + obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hL) + rw [rowWord_flatten hB P, rowWord_flatten hB Q] + have h := indel_shift_flatten (R := 2 * B) + (fun i => (List.ofFn (P i)).map some ++ List.replicate B none) + (fun i => (List.ofFn (Q i)).map some ++ List.replicate B none) + (by simp; omega) (by simp; omega) (fun i => by rw [halign i.castSucc i.succ (by simp)]) + convert h using 1 + omega + +end EditRows + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/RowSeparation.lean b/lean/OAI/Combinatorics/EditDistance/RowSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e79ffdaff358aefb5476fbed47fa196521697435 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/RowSeparation.lean @@ -0,0 +1,183 @@ +import OAI.Combinatorics.EditDistance.RowAlignment + +namespace OAI + +/-! +# Payload restrictions and fresh-marker row separation +-/ + +namespace EditDistortion + +lemma sublist_ofFn_comp {A : Type*} {m n : ℕ} (x : Fin n → A) (f : Fin m ↪o Fin n) : + (List.ofFn (fun i => x (f i))).Sublist (List.ofFn x) := by + apply List.sublist_iff_exists_fin_orderEmbedding_get_eq.mpr + refine ⟨((Fin.castOrderIso (List.length_ofFn (f := fun i => x (f i)))).toOrderEmbedding.trans f).trans + (Fin.castOrderIso (List.length_ofFn (f := x)).symm).toOrderEmbedding, ?_⟩ + intro i + simp only [List.get_ofFn] + rfl + +lemma indel_le_of_matching {A : Type*} {m n k : ℕ} (x : Fin m → A) (y : Fin n → A) + (f : Fin k ↪o Fin m) (g : Fin k ↪o Fin n) (heq : ∀ i, x (f i) = y (g i)) : + indel (List.ofFn x) (List.ofFn y) ≤ m + n - 2 * k := by + have hx := sublist_ofFn_comp x f + have hy := sublist_ofFn_comp y g + have hz : (fun i => x (f i)) = (fun i => y (g i)) := funext heq + rw [← hz] at hy + simpa only [List.length_ofFn] using indel_le_matching_loss hx hy + +end EditDistortion + +namespace EditRows + +lemma payload_mod {B i x : ℕ} (hB : 0 < B) (hx : x ∈ payload B i) : + x % (2 * B) < B := by + have hd := payload_index hB hx + have hx := mem_payload.mp hx + have hm := Nat.mod_add_div x (2 * B) + rw [hd] at hm + omega + +def rowValue {A : Type*} {L B : ℕ} (P : Fin L → Fin B → A) + (x : Fin (2 * B * L)) : Option A := + if h : x.val % (2 * B) < B then + some (P ⟨x.val / (2 * B), (Nat.div_lt_iff_lt_mul (by omega)).mpr + (by simpa only [Nat.mul_comm] using x.isLt)⟩ ⟨x.val % (2 * B), h⟩) + else none + +def rowWord {A : Type*} {L B : ℕ} (P : Fin L → Fin B → A) : List (Option A) := + List.ofFn (rowValue P) + +@[simp] lemma rowWord_length {A : Type*} {L B : ℕ} (P : Fin L → Fin B → A) : + (rowWord P).length = 2 * B * L := by simp [rowWord] + +lemma rowValue_ne_none {A : Type*} {L B : ℕ} (P : Fin L → Fin B → A) + (x : Fin (2 * B * L)) : rowValue P x ≠ none ↔ x.val % (2 * B) < B := by + unfold rowValue + split_ifs <;> simp_all + +def payloadOffset {B i x : ℕ} (h : x ∈ payload B i) : Fin B := + ⟨x - 2 * B * i, by have h := mem_payload.mp h; omega⟩ + +lemma rowValue_payload {A : Type*} {L B : ℕ} (hB : 0 < B) (P : Fin L → Fin B → A) + (i : Fin L) (x : Fin (2 * B * L)) (hx : x.val ∈ payload B i) : + rowValue P x = some (P i (payloadOffset hx)) := by + have hd := payload_index hB hx + have hm := payload_mod hB hx + rw [rowValue, dite_eq_left hm] + congr 2 + · exact Fin.ext hd + · apply Fin.ext + change x.val % (2 * B) = x.val - 2 * B * i.val + have hh := Nat.mod_add_div x.val (2 * B) + rw [hd] at hh + omega + +end EditRows + +namespace EditRows + +lemma local_matching_bound {A : Type*} {k L B : ℕ} {t : ℝ} + (P Q : Fin L → Fin B → A) (hB : 0 < B) + (f g : Fin k → Fin (2 * B * L)) + (hf : StrictMono (fun a => (f a).val)) (hg : StrictMono (fun a => (g a).val)) + (heq : ∀ a, rowValue P (f a) = rowValue Q (g a)) + (ht : t ≤ B) + (hsep : ∀ i j : Fin L, 2 * t ≤ + (EditDistortion.indel (List.ofFn (P i)) (List.ofFn (Q j)) : ℝ)) + (i : Fin L) (j : ℕ) : + t + (((rowMatches (fun a => (f a).val) B i).filter + (fun a => (g a).val ∈ payload B j)).card : ℝ) ≤ B := by + classical + let K := (rowMatches (fun a => (f a).val) B i).filter + (fun a => (g a).val ∈ payload B j) + change t + (K.card : ℝ) ≤ B + by_cases hj : j < L + · let e : Fin K.card ↪o Fin k := K.orderEmbOfFin rfl + have hp : ∀ r : Fin K.card, + (f (e r)).val ∈ payload B i ∧ (g (e r)).val ∈ payload B j := by + intro r + have h := K.orderEmbOfFin_mem rfl r + exact ⟨(Finset.mem_filter.mp (Finset.mem_filter.mp h).1).2, + (Finset.mem_filter.mp h).2⟩ + let ff : Fin K.card → Fin B := fun r => payloadOffset (hp r).1 + let gg : Fin K.card → Fin B := fun r => payloadOffset (hp r).2 + have hff : StrictMono ff := by + intro r s hrs + have h := hf (e.strictMono hrs) + change (f (e r)).val < (f (e s)).val at h + have hr := mem_payload.mp (hp r).1 + have hs := mem_payload.mp (hp s).1 + change (f (e r)).val - 2 * B * i.val < (f (e s)).val - 2 * B * i.val + omega + have hgg : StrictMono gg := by + intro r s hrs + have h := hg (e.strictMono hrs) + change (g (e r)).val < (g (e s)).val at h + have hr := mem_payload.mp (hp r).2 + have hs := mem_payload.mp (hp s).2 + change (g (e r)).val - 2 * B * j < (g (e s)).val - 2 * B * j + omega + have he : ∀ r, P i (ff r) = Q ⟨j, hj⟩ (gg r) := by + intro r + have h := heq (e r) + rw [rowValue_payload hB P i (f (e r)) (hp r).1, + rowValue_payload hB Q ⟨j, hj⟩ (g (e r)) (hp r).2] at h + exact Option.some.inj h + have hcost := EditDistortion.indel_le_of_matching (P i) (Q ⟨j, hj⟩) + (OrderEmbedding.ofStrictMono ff hff) (OrderEmbedding.ofStrictMono gg hgg) he + have hk : K.card ≤ B := by + simpa only [Fintype.card_fin] using Fintype.card_le_of_injective ff hff.injective + have hcost' : (EditDistortion.indel (List.ofFn (P i)) (List.ofFn (Q ⟨j, hj⟩)) : ℝ) ≤ + ((B + B - 2 * K.card : ℕ) : ℝ) := by exact_mod_cast hcost + rw [Nat.cast_sub (by omega), Nat.cast_add, Nat.cast_mul] at hcost' + norm_num at hcost' + have hsep' := hsep i ⟨j, hj⟩ + linarith + · have hnil : K = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro a ha + have h := mem_payload.mp (Finset.mem_filter.mp ha).2 + have hg' := (g a).isLt + have hh : 2 * B * L ≤ 2 * B * j := Nat.mul_le_mul_left _ (by omega) + omega + simpa only [hnil, Finset.card_empty, Nat.cast_zero, add_zero] using ht + +theorem indel_row_separation {A : Type*} {L B : ℕ} {t : ℝ} + (P Q : Fin L → Fin B → A) (hB : 0 < B) (ht : t ≤ B) + (hsep : ∀ i j : Fin L, 2 * t ≤ + (EditDistortion.indel (List.ofFn (P i)) (List.ofFn (Q j)) : ℝ)) : + (L : ℝ) * t ≤ (EditDistortion.indel (rowWord P) (rowWord Q) : ℝ) := by + classical + obtain ⟨z, hx, hy, hcost⟩ := EditDistortion.indel_matching (rowWord P) (rowWord Q) + obtain ⟨f₀, hf₀⟩ := List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp hx + obtain ⟨g₀, hg₀⟩ := List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp hy + let f : Fin z.length ↪o Fin (2 * B * L) := + f₀.trans (Fin.castOrderIso (rowWord_length P)).toOrderEmbedding + let g : Fin z.length ↪o Fin (2 * B * L) := + g₀.trans (Fin.castOrderIso (rowWord_length Q)).toOrderEmbedding + have hf : StrictMono (fun a => (f a).val) := fun _ _ h => f.strictMono h + have hg : StrictMono (fun a => (g a).val) := fun _ _ h => g.strictMono h + have heq : ∀ a, rowValue P (f a) = rowValue Q (g a) := by + intro a + have h := (hf₀ a).symm.trans (hg₀ a) + simpa only [rowWord, List.get_ofFn] using! h + have hclean : ∀ a : Fin z.length, ∀ i : ℕ, + (f a).val ∈ payload B i → (g a).val % (2 * B) < B := by + intro a i ha + apply (rowValue_ne_none Q (g a)).mp + rw [← heq a] + exact (rowValue_ne_none P (f a)).mpr (payload_mod hB ha) + have hbound := matching_loss_real hf hg hB (fun a => (f a).isLt) + (fun a => (g a).isLt) hclean ht (local_matching_bound P Q hB f g hf hg heq ht hsep) + have hk : z.length ≤ 2 * B * L := by simpa only [rowWord_length] using hx.length_le + have he : 2 * (2 * B * L - z.length) = + (rowWord P).length + (rowWord Q).length - 2 * z.length := by + rw [rowWord_length, rowWord_length] + omega + rw [hcost, ← he, Nat.cast_mul, Nat.cast_ofNat] + exact hbound + +end EditRows + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Slots.lean b/lean/OAI/Combinatorics/EditDistance/Slots.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3cc1bd37e776a1e03931ea9a391b873fbec90a8 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Slots.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.EditDistance.Metric + +namespace OAI + +/-! +# Position-tagged concatenation and repeated slots +-/ + +namespace EditSlots +open scoped BigOperators + +variable {I A : Type*} [DecidableEq I] + +def project (i : I) (x : I × A) : Option A := if i = x.1 then some x.2 else none + +lemma project_map (i j : I) (x : List A) : + (x.map (Prod.mk j)).filterMap (project i) = if i = j then x else [] := by + by_cases h : i = j <;> simp [List.filterMap_map, project, h, Function.comp_def] + +def tagged (l : List I) (P : I → List A) : List (I × A) := + l.flatMap (fun i => (P i).map (Prod.mk i)) + +lemma project_tagged (l : List I) (hl : l.Nodup) (P : I → List A) (i : I) : + (tagged l P).filterMap (project i) = if i ∈ l then P i else [] := by + induction l with + | nil => simp [tagged] + | cons j l ih => + obtain ⟨hjl, hl⟩ := List.nodup_cons.mp hl + simp only [tagged, List.flatMap_cons, List.filterMap_append, project_map] + change (if i = j then P j else []) ++ (tagged l P).filterMap (project i) = _ + rw [ih hl] + by_cases h : i = j + · subst i + simp [hjl] + · simp [h] + +lemma project_length_partition [Fintype I] (z : List (I × A)) : + ∑ i, (z.filterMap (project i)).length = z.length := by + induction z with + | nil => simp + | cons a z ih => + have hh (i : I) : ((a :: z).filterMap (project i)).length = + (z.filterMap (project i)).length + if i = a.1 then 1 else 0 := by + by_cases h : i = a.1 <;> simp [project, h] + simp_rw [hh] + rw [Finset.sum_add_distrib, ih] + simp + +omit [DecidableEq I] in +lemma tagged_length (l : List I) (P : I → List A) : + (tagged l P).length = (l.map (fun i => (P i).length)).sum := by + induction l with + | nil => simp [tagged] + | cons a l ih => simp_all [tagged] + +theorem sum_indel_le_tagged [Fintype I] (l : List I) (hl : l.Nodup) + (hfull : ∀ i : I, i ∈ l) (P Q : I → List A) : + (∑ i, (EditDistortion.indel (P i) (Q i) : ℝ)) ≤ + (EditDistortion.indel (tagged l P) (tagged l Q) : ℝ) := by + classical + obtain ⟨z, hzP, hzQ, hz⟩ := EditDistortion.indel_matching (tagged l P) (tagged l Q) + have hsubP : ∀ i, (z.filterMap (project i)).Sublist (P i) := by + intro i + simpa only [project_tagged l hl P i, ite_eq_left (hfull i)] using hzP.filterMap (project i) + have hsubQ : ∀ i, (z.filterMap (project i)).Sublist (Q i) := by + intro i + simpa only [project_tagged l hl Q i, ite_eq_left (hfull i)] using hzQ.filterMap (project i) + have hp (i : I) : (EditDistortion.indel (P i) (Q i) : ℝ) ≤ + ((P i).length : ℝ) + (Q i).length - 2 * (z.filterMap (project i)).length := by + have hh := EditDistortion.indel_le_matching_loss (hsubP i) (hsubQ i) + have h₁ := (hsubP i).length_le + have h₂ := (hsubQ i).length_le + have hh' : (EditDistortion.indel (P i) (Q i) : ℝ) ≤ + (((P i).length + (Q i).length - 2 * (z.filterMap (project i)).length : ℕ) : ℝ) := by + exact_mod_cast hh + rw [Nat.cast_sub (by omega), Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] at hh' + exact hh' + have hlen (R : I → List A) : (tagged l R).length = ∑ i, (R i).length := by + have hp := project_length_partition (tagged l R) + simpa only [project_tagged l hl R, ite_eq_left (hfull _)] using hp.symm + have hpart : (∑ i, ((z.filterMap (project i)).length : ℝ)) = z.length := by + exact_mod_cast project_length_partition z + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hp i) + rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, hpart] at hsum + have hz₁ := hzP.length_le + have hz₂ := hzQ.length_le + rw [hz, Nat.cast_sub (by omega), Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, + hlen P, hlen Q, Nat.cast_sum, Nat.cast_sum] + exact hsum + +end EditSlots + +namespace EditSlots +open scoped BigOperators + +lemma cost_tagged_le {I A : Type*} (l : List I) (P Q : I → List A) (s : Bool) : + EditDistortion.cost s (tagged l P) (tagged l Q) ≤ + (l.map (fun i => EditDistortion.cost s (P i) (Q i))).sum := by + induction l with + | nil => exact le_of_eq (EditDistortion.cost_refl []) + | cons i l ih => + have ha := EditDistortion.cost_append_le (s := s) + ((P i).map (Prod.mk i)) ((Q i).map (Prod.mk i)) (tagged l P) (tagged l Q) + have hm := EditDistortion.cost_map_le (s := s) (Prod.mk i) (P i) (Q i) + exact ha.trans (by simpa only [List.map_cons, List.sum_cons] using Nat.add_le_add hm ih) + +def fixedFn {A : Type*} {n : ℕ} (l : List A) (h : l.length = n) : Fin n → A := + fun i => l.get (Fin.cast h.symm i) + +@[simp] lemma ofFn_fixedFn {A : Type*} {n : ℕ} (l : List A) (h : l.length = n) : + List.ofFn (fixedFn l h) = l := by + subst n + exact List.ofFn_get l + +section Repeated +variable {J : Type*} [Fintype J] [DecidableEq J] (i : J) + +abbrev Slots := Fin (Fintype.card J) ⊕ {j : J // j ≠ i} + +def component : Slots i → J + | Sum.inl _ => i + | Sum.inr j => j.val + +lemma slots_card : Fintype.card (Slots i) = 2 * Fintype.card J - 1 := by + have hb : 0 < Fintype.card J := Fintype.card_pos_iff.mpr ⟨i⟩ + simp only [Slots, Fintype.card_sum, Fintype.card_fin, Fintype.card_subtype_compl, + Fintype.card_unique] + omega + +noncomputable def enumeration : List (Slots i) := + List.ofFn (Fintype.equivFin (Slots i)).symm + +lemma enumeration_nodup : (enumeration i).Nodup := + List.nodup_ofFn_ofInjective (Fintype.equivFin (Slots i)).symm.injective + +lemma enumeration_full (r : Slots i) : r ∈ enumeration i := by + simp only [enumeration, List.mem_ofFn] + exact ⟨(Fintype.equivFin (Slots i)) r, (Fintype.equivFin (Slots i)).symm_apply_apply r⟩ + +lemma sum_slots (f : J → ℝ) : + (∑ r : Slots i, f (component i r)) = + (Fintype.card J : ℝ) * f i + ∑ j : {j : J // j ≠ i}, f j := by + simp [Fintype.sum_sum_type, component] + +def multiplicity (j : J) : ℕ := if j = i then Fintype.card J else 1 + +lemma sum_slots_delta (j : J) (a : ℝ) : + (∑ r : Slots i, if component i r = j then a else 0) = multiplicity i j * a := by + rw [sum_slots i (fun k => if k = j then a else 0)] + by_cases h : j = i + · subst j + have hz : (∑ x : {j : J // j ≠ i}, if x.val = i then a else 0) = 0 := by + apply Finset.sum_eq_zero + intro x _ + simp [x.property] + simp [hz, multiplicity] + · have hs : (∑ x : {j : J // j ≠ i}, if x.val = j then a else 0) = a := by + rw [Finset.sum_eq_single ⟨j,h⟩] + · simp + · intro x _ hx + have hx' : x.val ≠ j := fun he => hx (Subtype.ext he) + simp [hx'] + · simp + simp [hs, Ne.symm h, multiplicity, h] + +lemma sum_multiplicity : (∑ j : J, (multiplicity i j : ℝ)) = 2 * Fintype.card J - 1 := by + have he (j : J) : (multiplicity i j : ℝ) = + 1 + if j = i then (Fintype.card J : ℝ) - 1 else 0 := by + by_cases h : j = i <;> simp [multiplicity, h] + simp_rw [he] + simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, + nsmul_eq_mul, mul_one, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + ring + +end Repeated +end EditSlots + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/UpperBase.lean b/lean/OAI/Combinatorics/EditDistance/UpperBase.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff0d5d9a5738d39880974cbc3607b9ea6c3d8594 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/UpperBase.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.EditDistance.WindowRecursion + +namespace OAI + +/-! +# Base finite-cut embedding for short words +-/ + +namespace EditUpper +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset EditDistortion EditWindow EditCutModel +variable {A : Type*} [Fintype A] + +noncomputable def firstKey (x : List A) : Fin (Fintype.card (Option A)) := + Fintype.equivFin (Option A) (x[0]?) + +noncomputable def base : Model (List A) where + Index := Fin (Fintype.card (Option A)) + finiteIndex := inferInstance + weight _ := 1 + nonneg _ := by norm_num + cut i x := decide (firstKey x = i) + +lemma base_distance (x y : List A) : + (base (A := A)).dist x y = 2*EditCutHash.sep (x[0]?) (y[0]?) := by + have hcuts (i : Fin (Fintype.card (Option A))) : + sep (decide (firstKey x = i)) (decide (firstKey y = i)) = + |EditCutHash.hit (firstKey x) i-EditCutHash.hit (firstKey y) i| := by + by_cases hx : firstKey x = i <;> by_cases hy : firstKey y = i <;> + simp [sep,EditCutHash.hit,hx,hy] + change (∑ i, 1*sep (decide (firstKey x = i)) (decide (firstKey y = i))) = _ + simp_rw [one_mul,hcuts] + rw [EditCutHash.hit_distance] + congr 1 + have he : firstKey x = firstKey y ↔ x[0]? = y[0]? := (Fintype.equivFin (Option A)).injective.eq_iff + by_cases hxy : x[0]? = y[0]? <;> simp only [EditCutHash.sep,he,hxy,ite_true,ite_false] + +lemma base_le_two (x y : List A) : (base (A := A)).dist x y ≤ 2 := by + rw [base_distance] + have h := EditCutHash.sep_le_one (x[0]?) (y[0]?) + linarith + +omit [Fintype A] in +lemma first_eq_of_small (x y : List A) (hx : x.length ≤ 1) (hy : y.length ≤ 1) + (he : x[0]? = y[0]?) : x = y := by + cases x with + | nil => cases y <;> simp_all + | cons a x => + have hxn : x = [] := List.eq_nil_iff_length_eq_zero.mpr (by simp only [List.length_cons] at hx; omega) + subst x + cases y with + | nil => simp at he + | cons b y => + have hyn : y = [] := List.eq_nil_iff_length_eq_zero.mpr (by simp only [List.length_cons] at hy; omega) + subst y + simpa using he + +lemma base_lower (x y : List A) (hx : x.length ≤ 1) (hy : y.length ≤ 1) : + (indel x y : ℝ) ≤ (base (A := A)).dist x y := by + by_cases he : x[0]? = y[0]? + · have hxy := first_eq_of_small x y hx hy he + subst y + rw [Model.dist_self] + norm_cast + exact cost_le (.nil _) + · rw [base_distance,EditCutHash.sep_eq_one he,mul_one] + have hlen : indel x y ≤ x.length+y.length := + cost_le ((Script.to_nil (s := false) x).trans (Script.to_nil y).symm) + exact_mod_cast (show indel x y ≤ 2 by omega) + +lemma base_upper (x y : List A) : (base (A := A)).dist x y ≤ 2*(indel x y : ℝ) := + model_indel_lipschitz base (fun p q a => base_le_two (p++q) (p++a::q)) x y + +end EditUpper + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/UpperBound.lean b/lean/OAI/Combinatorics/EditDistance/UpperBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..81f0a22d5793c6f4d6055bce2a4b5f8701e61c04 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/UpperBound.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.EditDistance.UpperRecursion +import OAI.Combinatorics.EditDistance.UpperParameters +import OAI.Combinatorics.EditDistance.CutRealization +import OAI.Combinatorics.EditDistance.DistortionMonotonicity + +namespace OAI + +/-! +# Alphabet-uniform upper bounds for least distortion +-/ + +namespace EditUpper +open EditDistortion EditCutModel +universe u + +lemma model_E_bound (A : Type u) [Fintype A] [Nonempty A] {d : ℕ} (hd : 1 ≤ d) + (M : Model (List A)) {D : ℝ} (hD : 0 ≤ D) + (hlo : ∀ x y : List A, x.length ≤ d → y.length ≤ d → (indel x y : ℝ) ≤ M.dist x y) + (hup : ∀ x y : List A, M.dist x y ≤ D*(indel x y : ℝ)) : E A d ≤ 2*D := by + classical + let : Finite (Words A d) := finite_words A d + let x : Words A d := ⟨[],by simp⟩ + let y : Words A d := ⟨[Classical.arbitrary A],by simpa using hd⟩ + let : Nontrivial (Words A d) := ⟨⟨x,y,by simp [x,y]⟩⟩ + let f : Words A d ↪ L1 := + { toFun := fun z => M.vector z.val + inj' := by + intro v w he + change M.vector v.val = M.vector w.val at he + have hh := hlo v.val w.val v.property w.property + rw [← M.vector_distance,he,sub_self,norm_zero] at hh + have hz : indel v.val w.val = 0 := by exact_mod_cast le_antisymm hh (Nat.cast_nonneg _) + exact Subtype.ext ((cost_eq_zero_iff (s := false)).mp hz) } + apply (leastDistortion_le _ (fun z => edit_real_diag z.val) + (fun v w h => edit_real_pos v.val w.val (fun hh => h (Subtype.ext hh))) f).trans + have hbound : distortion (fun v w : Words A d => (edit v.val w.val : ℝ)) f ≤ (2*D)*1 := by + apply distortion_le_of_bounds _ + (fun v w h => edit_real_pos v.val w.val (fun hh => h (Subtype.ext hh))) f (by positivity) + · intro v w + change ‖M.vector v.val-M.vector w.val‖ ≤ _ + rw [M.vector_distance] + have hi : (indel v.val w.val : ℝ) ≤ 2*(edit v.val w.val : ℝ) := by + exact_mod_cast indel_le_two_edit v.val w.val + calc + _ ≤ D*(indel v.val w.val : ℝ) := hup _ _ + _ ≤ D*(2*(edit v.val w.val : ℝ)) := mul_le_mul_of_nonneg_left hi hD + _ = _ := by ring + · intro v w + change (edit v.val w.val : ℝ) ≤ 1*‖M.vector v.val-M.vector w.val‖ + rw [one_mul,M.vector_distance] + exact (show (edit v.val w.val : ℝ) ≤ indel v.val w.val by + exact_mod_cast edit_le_indel v.val w.val).trans (hlo _ _ v.property w.property) + simpa using hbound + +lemma level_E_bound (b N : ℕ) (hb : 1 ≤ b) (A : Type u) [Fintype A] [Nonempty A] + {d : ℕ} (hd : 1 ≤ d) (hcap : d ≤ b^N) : + E A d ≤ 2*(((b : ℝ)+2)*(growth b N)^N) := by + obtain ⟨M,hlo,hup⟩ := exists_level b N hb N le_rfl A + have hD : 0 ≤ ((b : ℝ)+2)*(growth b N)^N := by + have hh := growth_ge (N := N) hb + positivity + exact model_E_bound A hd M hD + (fun x y hx hy => hlo x y (hx.trans hcap) (hy.trans hcap)) hup + +theorem eventual_upper : ∀ᶠ d : ℕ in Filter.atTop, + (∀ (A : Type u) [Fintype A], 2 ≤ Fintype.card A → E A d ≤ exponentScale 32 d) ∧ + alphabetSup d ≤ exponentScale 32 d := by + filter_upwards [EditUpperParameters.eventual_choice,Filter.eventually_ge_atTop (1 : ℕ)] with d hc hd + rcases hc with ⟨hN,hb,hcap,hbound⟩ + let N := EditUpperParameters.level (Real.log (d : ℝ)) + let b := EditUpperParameters.branching (Real.log (d : ℝ)) + have hnum : 2*(((b : ℝ)+2)*(growth b N)^N) ≤ exponentScale 32 d := by + simpa [growth,exponentScale,b,N,mul_assoc] using hbound + constructor + · intro A inst hA + let : Nonempty A := Fintype.card_pos_iff.mp (by omega) + exact (level_E_bound b N (by omega) A hd hcap).trans hnum + · apply csSup_le (s := {r : ℝ | ∃ n : ℕ, 2 ≤ n ∧ r = E (Fin n) d}) + ⟨E (Fin 2) d,2,by omega,rfl⟩ + rintro r ⟨n,hn,rfl⟩ + let : NeZero n := ⟨by omega⟩ + exact (level_E_bound b N (by omega) (Fin n) hd hcap).trans hnum + +end EditUpper + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/UpperParameters.lean b/lean/OAI/Combinatorics/EditDistance/UpperParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..19990b3f389da79151164ae2a68876e47a6ef70a --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/UpperParameters.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.EditDistance.DepthInversion +import OAI.Combinatorics.EditDistance.UpperRecursion + +namespace OAI + +/-! +# Branching and depth choices at every sufficiently large length +-/ + +namespace EditUpperParameters +open Filter + +noncomputable def peak (t : ℝ) : ℝ := Real.sqrt (t*Real.log t) +noncomputable def level (t : ℝ) : ℕ := ⌊EditDepth.radius t⌋₊ +noncomputable def branching (t : ℝ) : ℕ := ⌈Real.exp (2*peak t)⌉₊ + +lemma radius_peak {t : ℝ} (ht : 1 ≤ t) (hlt : 1 ≤ Real.log t) : + EditDepth.radius t * Real.log t = peak t ∧ EditDepth.radius t * peak t = t ∧ 1 ≤ peak t := by + have tp : 0 < t := by linarith + have lp : 0 < Real.log t := by linarith + have hr : 0 ≤ EditDepth.radius t := EditDepth.radius_nonneg t + have hr2 : EditDepth.radius t^2 = t/Real.log t := Real.sq_sqrt (div_nonneg tp.le lp.le) + have hr2' : EditDepth.radius t^2*Real.log t = t := (eq_div_iff lp.ne').mp hr2 + have hs : peak t = EditDepth.radius t*Real.log t := by + apply (Real.sqrt_eq_iff_mul_self_eq (by positivity) (by positivity)).mpr + nlinarith [congrArg (fun x : ℝ => x*Real.log t) hr2'] + refine ⟨hs.symm,?_,?_⟩ + · rw [hs] + nlinarith [hr2'] + · apply Real.le_sqrt_of_sq_le + nlinarith + +lemma choose_parameters {t : ℝ} (ht : 1 ≤ t) (hlt : 1024 ≤ Real.log t) + (hr : 2 ≤ EditDepth.radius t) : + 1 ≤ level t ∧ 2 ≤ branching t ∧ + Real.exp t ≤ (branching t : ℝ)^(level t) ∧ + 2*((branching t : ℝ)+2)* + (1024*(1+(level t : ℝ)*Real.log (branching t : ℝ))^2)^(level t) ≤ + Real.exp (32*peak t) := by + have hlt1 : 1 ≤ Real.log t := by linarith + obtain ⟨hRS,hRt,hS⟩ := radius_peak ht hlt1 + have hNup : (level t : ℝ) ≤ EditDepth.radius t := Nat.floor_le (EditDepth.radius_nonneg t) + have hNfloor := Nat.lt_floor_add_one (EditDepth.radius t) + change EditDepth.radius t < (level t : ℝ)+1 at hNfloor + have hNlo : EditDepth.radius t/2 ≤ (level t : ℝ) := by linarith + have hNp : 1 ≤ level t := by + have hh : (1 : ℝ) ≤ level t := by linarith + exact_mod_cast hh + have helo : Real.exp (2*peak t) ≤ (branching t : ℝ) := Nat.le_ceil _ + have hehi : (branching t : ℝ) < Real.exp (2*peak t)+1 := Nat.ceil_lt_add_one (Real.exp_pos _).le + have hexp : 3 ≤ Real.exp (2*peak t) := by have := Real.add_one_le_exp (2*peak t); linarith + have hb : 2 ≤ branching t := by + have hh : (2 : ℝ) ≤ branching t := by linarith + exact_mod_cast hh + have hbp : (0 : ℝ) < branching t := by exact_mod_cast (show 0 < branching t by omega) + have hBnon : 0 ≤ Real.log (branching t : ℝ) := Real.log_nonneg (by exact_mod_cast (show 1 ≤ branching t by omega)) + have hBlo : 2*peak t ≤ Real.log (branching t : ℝ) := (Real.le_log_iff_exp_le hbp).mpr helo + have hBup : Real.log (branching t : ℝ) ≤ 3*peak t := by + have hh : (branching t : ℝ) ≤ 2*Real.exp (2*peak t) := by linarith + have hl := Real.log_le_log hbp hh + rw [Real.log_mul (by norm_num) (Real.exp_ne_zero _),Real.log_exp] at hl + have h2 := log_two_bounds + linarith + have hBlog : Real.log ((branching t : ℝ)+2) ≤ 5*peak t := by + have hh : (branching t : ℝ)+2 ≤ 4*Real.exp (2*peak t) := by linarith + have hl := Real.log_le_log (by positivity : 0 < (branching t : ℝ)+2) hh + rw [Real.log_mul (by norm_num) (Real.exp_ne_zero _),Real.log_exp] at hl + have h4 := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ)<4) + linarith + have hNnon : 0 ≤ (level t : ℝ) := Nat.cast_nonneg _ + have hNblo : t ≤ (level t : ℝ)*Real.log (branching t : ℝ) := by + have hh := mul_le_mul hNlo hBlo (by linarith : 0 ≤ 2*peak t) hNnon + nlinarith [hRt] + have hNbup : (level t : ℝ)*Real.log (branching t : ℝ) ≤ 3*t := by + have hh := mul_le_mul hNup hBup hBnon (EditDepth.radius_nonneg t) + nlinarith [hRt] + have hcap : Real.exp t ≤ (branching t : ℝ)^(level t) := by + apply (Real.le_log_iff_exp_le (pow_pos hbp _)).mp + rw [Real.log_pow] + exact hNblo + let T := 1+(level t : ℝ)*Real.log (branching t : ℝ) + let P := 1024*T^2 + have hT : 0 < T := by dsimp [T]; positivity + have hP : 0 < P := by dsimp [P]; positivity + have hTup : T ≤ 4*t := by dsimp [T]; linarith + have hlogT : Real.log T ≤ 3+Real.log t := by + have hh := Real.log_le_log hT hTup + rw [Real.log_mul (by norm_num) (by linarith : t ≠ 0)] at hh + have h4 := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ)<4) + linarith + have hlogP : Real.log P ≤ 4*Real.log t := by + dsimp [P] + rw [Real.log_mul (by norm_num) (pow_ne_zero 2 hT.ne'),Real.log_pow] + have h1024 := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ)<1024) + norm_num only [Nat.cast_ofNat] + linarith + have hNP : (level t : ℝ)*Real.log P ≤ 4*peak t := by + have h1 := mul_le_mul_of_nonneg_left hlogP hNnon + have h2 := mul_le_mul_of_nonneg_right hNup (show 0 ≤ 4*Real.log t by linarith) + nlinarith [hRS] + refine ⟨hNp,hb,hcap,?_⟩ + change 2*((branching t : ℝ)+2)*P^(level t) ≤ _ + apply (Real.log_le_iff_le_exp (by positivity)).mp + rw [Real.log_mul (by positivity) (pow_ne_zero _ hP.ne'), + Real.log_mul (by norm_num) (by positivity : ((branching t : ℝ)+2) ≠ 0),Real.log_pow] + have h2 := log_two_bounds + nlinarith + +theorem eventual_choice : ∀ᶠ d : ℕ in atTop, + 1 ≤ level (Real.log (d : ℝ)) ∧ 2 ≤ branching (Real.log (d : ℝ)) ∧ + d ≤ branching (Real.log (d : ℝ))^level (Real.log (d : ℝ)) ∧ + 2*((branching (Real.log (d : ℝ)) : ℝ)+2)* + (1024*(1+(level (Real.log (d : ℝ)) : ℝ)*Real.log (branching (Real.log (d : ℝ)) : ℝ))^2)^level (Real.log (d : ℝ)) ≤ + Real.exp (32*Real.sqrt (Real.log (d : ℝ)*Real.log (Real.log (d : ℝ)))) := by + have htend : Tendsto (fun d : ℕ => Real.log (d : ℝ)) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have h1 := htend.eventually (eventually_ge_atTop (1 : ℝ)) + have h2 := htend.eventually (Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1024 : ℝ))) + have h3 := htend.eventually (EditDepth.eventually_radius_large 0) + filter_upwards [h1,h2,h3,eventually_ge_atTop (1 : ℕ)] with d ht hl hr hd + have hr' : 2 ≤ EditDepth.radius (Real.log (d : ℝ)) := by norm_num at hr; linarith + obtain ⟨hN,hb,hcap,hbound⟩ := choose_parameters ht hl hr' + refine ⟨hN,hb,?_,hbound⟩ + rw [Real.exp_log (by exact_mod_cast (show 0 < d by omega))] at hcap + exact_mod_cast hcap + +end EditUpperParameters + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/UpperRecursion.lean b/lean/OAI/Combinatorics/EditDistance/UpperRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac8f7fe8256d3ee21316af4dbb02bf67af2fb759 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/UpperRecursion.lean @@ -0,0 +1,137 @@ +import OAI.Combinatorics.EditDistance.UpperBase + +namespace OAI + +/-! +# Uniform finite-cut embeddings at recursive capacities +-/ + +namespace EditUpperParameters +open scoped BigOperators + +lemma log_two_bounds : (1/2 : ℝ) ≤ Real.log 2 ∧ Real.log 2 ≤ 1 := by + constructor + · have hh := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at hh ⊢ + exact hh + · have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at hh ⊢ + exact hh + +lemma scale_count_bound {l : ℕ} (hl : 0 < l) : + ((Nat.log 2 l+1 : ℕ) : ℝ) ≤ 2*(1+Real.log (l : ℝ)) := by + have hpow := Nat.pow_log_le_self 2 (Nat.ne_of_gt hl) + have hpr : (2 : ℝ)^(Nat.log 2 l) ≤ l := by exact_mod_cast hpow + have hh := Real.log_le_log (pow_pos (by norm_num : (0 : ℝ)<2) _) hpr + rw [Real.log_pow] at hh + have hlog : 0 ≤ Real.log (l : ℝ) := Real.log_nonneg (by exact_mod_cast hl) + have hm : 0 ≤ (Nat.log 2 l : ℝ) := Nat.cast_nonneg _ + have h2 := log_two_bounds + push_cast + nlinarith + +lemma log_square_bound {l : ℕ} (hl : 0 < l) : + Real.log (2*(l : ℝ)^2) ≤ 2*(1+Real.log (l : ℝ)) := by + have hp : (0 : ℝ) + refine ⟨base,?_,?_⟩ + · intro x y hx hy + exact base_lower x y (by simpa using hx) (by simpa using hy) + · intro x y + have hh := base_upper x y + have hi := Nat.cast_nonneg (α := ℝ) (indel x y) + simp only [pow_zero,mul_one] + nlinarith [Nat.cast_nonneg (α := ℝ) b] + | succ k ih => + obtain ⟨M,hlo,hup⟩ := ih (by omega) (Option A) + let D := ((b : ℝ)+2)*(growth b N)^k + have hP := growth_ge (N := N) hb + have hD : 0 ≤ D := by dsimp [D]; positivity + have hpow : 1 ≤ (growth b N)^k := one_le_pow₀ hP + have hbD : (b : ℝ) ≤ D := by + dsimp [D] + have hb0 := Nat.cast_nonneg (α := ℝ) b + nlinarith + have hl : 0 < b^k := pow_pos (by omega) _ + have hkN : (k : ℝ) ≤ N := by exact_mod_cast (show k ≤ N by omega) + have hlog : 0 ≤ Real.log (b : ℝ) := Real.log_nonneg (by exact_mod_cast hb) + have hT : 1+Real.log ((b^k : ℕ) : ℝ) ≤ 1+(N : ℝ)*Real.log (b : ℝ) := by + rw [Nat.cast_pow,Real.log_pow] + nlinarith + have hTnn : 0 ≤ 1+Real.log ((b^k : ℕ) : ℝ) := by + have hh : 0 ≤ Real.log ((b^k : ℕ) : ℝ) := Real.log_nonneg (by exact_mod_cast (Nat.one_le_pow k b (by omega))) + linarith + have hconst : 512*(1+Real.log ((b^k : ℕ) : ℝ))^2*((b : ℝ)+D) ≤ + ((b : ℝ)+2)*(growth b N)^(k+1) := by + calc + _ ≤ 512*(1+(N : ℝ)*Real.log (b : ℝ))^2*(2*D) := by + apply mul_le_mul + · gcongr + · linarith + · positivity + · positivity + _ = _ := by dsimp [D,growth]; rw [pow_succ]; ring + refine ⟨lift M b (b^k),?_,?_⟩ + · intro x y hx hy + apply lift_lower M b (b^k) hl hlo x y + · simpa only [pow_succ,Nat.mul_comm] using hx + · simpa only [pow_succ,Nat.mul_comm] using hy + · apply model_indel_lipschitz + intro p q a + exact (lift_insert_raw M hD hup p q a b (b^k) hl).trans + ((EditUpperParameters.step_constant_bound hl hD).trans hconst) + +end EditUpper + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/WholeMaps.lean b/lean/OAI/Combinatorics/EditDistance/WholeMaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..666a869ab64a413180971ec3543df46cd0cee04a --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/WholeMaps.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.EditDistance.UpperBound +import OAI.Combinatorics.EditDistance.AlphabetLower + +namespace OAI + +/-! +# Simultaneous whole-domain maps and fixed-length binary upper bounds +-/ + +namespace EditUpper +open EditDistortion EditCutModel Filter +universe u + +lemma coarse_whole_map (A : Type u) [Fintype A] (d : ℕ) : + ∃ f : Words A d → L1, ∀ x y, + (edit x.val y.val : ℝ) ≤ ‖f x-f y‖ ∧ + ‖f x-f y‖ ≤ (2*(d : ℝ))*(edit x.val y.val : ℝ) := by + classical + let : Finite (Words A d) := finite_words A d + let : Fintype (Words A d) := Fintype.ofFinite _ + let f := fun x : Words A d => (d : ℝ) • coordinateEmbedding (Words A d) x + have hn (x y : Words A d) : ‖f x-f y‖ = (d : ℝ)* + ‖coordinateEmbedding (Words A d) x-coordinateEmbedding (Words A d) y‖ := by + dsimp [f] + rw [← smul_sub,norm_smul,Real.norm_eq_abs,abs_of_nonneg (Nat.cast_nonneg d)] + refine ⟨f,?_⟩ + intro x y + by_cases hxy : x = y + · subst y + simp only [sub_self,norm_zero,edit_real_diag,mul_zero,le_refl,and_self] + · have hlo := coordinate_separation x y hxy + have hu := norm_sub_le (coordinateEmbedding (Words A d) x) (coordinateEmbedding (Words A d) y) + rw [coordinate_norm,coordinate_norm] at hu + have he : (edit x.val y.val : ℝ) ≤ d := by + exact_mod_cast (edit_le_max_length x.val y.val).trans (max_le x.property y.property) + have hep : (1 : ℝ) ≤ edit x.val y.val := by + exact_mod_cast Nat.one_le_iff_ne_zero.mpr + (mt (cost_eq_zero_iff (s := true)).mp (fun hh => hxy (Subtype.ext hh))) + rw [hn] + have hd := Nat.cast_nonneg (α := ℝ) d + constructor <;> nlinarith + +theorem eventual_whole_maps : ∀ᶠ d : ℕ in atTop, + ∀ (A : Type u) [Fintype A], ∃ f : Words A d → L1, ∀ x y, + (edit x.val y.val : ℝ) ≤ ‖f x-f y‖ ∧ + ‖f x-f y‖ ≤ exponentScale 32 d*(edit x.val y.val : ℝ) := by + filter_upwards [EditUpperParameters.eventual_choice] with d hc + rcases hc with ⟨hN,hb,hcap,hbound⟩ + intro A inst + let N := EditUpperParameters.level (Real.log (d : ℝ)) + let b := EditUpperParameters.branching (Real.log (d : ℝ)) + obtain ⟨M,hlo,hup⟩ := exists_level b N (by omega) N le_rfl A + let D := ((b : ℝ)+2)*(growth b N)^N + have hD : 0 ≤ D := by + have hh := growth_ge (N := N) (show 1 ≤ b by omega) + dsimp [D] + positivity + have hnum : 2*D ≤ exponentScale 32 d := by + simpa [D,growth,exponentScale,b,N,mul_assoc] using hbound + refine ⟨fun x => M.vector x.val,?_⟩ + intro x y + rw [M.vector_distance] + constructor + · exact (show (edit x.val y.val : ℝ) ≤ indel x.val y.val by + exact_mod_cast edit_le_indel x.val y.val).trans + (hlo _ _ (x.property.trans hcap) (y.property.trans hcap)) + · have hi : (indel x.val y.val : ℝ) ≤ 2*(edit x.val y.val : ℝ) := by + exact_mod_cast indel_le_two_edit x.val y.val + calc + _ ≤ D*(indel x.val y.val : ℝ) := hup _ _ + _ ≤ D*(2*(edit x.val y.val : ℝ)) := mul_le_mul_of_nonneg_left hi hD + _ = (2*D)*(edit x.val y.val : ℝ) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hnum (Nat.cast_nonneg _) + +theorem whole_maps_all_lengths : ∃ C : ℝ, 0 < C ∧ ∀ d : ℕ, 3 ≤ d → + ∀ (A : Type u) [Fintype A], ∃ f : Words A d → L1, ∀ x y, + (edit x.val y.val : ℝ) ≤ ‖f x-f y‖ ∧ + ‖f x-f y‖ ≤ exponentScale C d*(edit x.val y.val : ℝ) := by + obtain ⟨D,hD⟩ := eventually_atTop.mp eventual_whole_maps.{u} + let S := Real.sqrt (Real.log 3*Real.log (Real.log 3)) + have hl3 : 1 < Real.log 3 := by linarith [Real.log_three_gt_d9] + have hll3 : 0 < Real.log (Real.log 3) := Real.log_pos hl3 + have hS : 0 < S := Real.sqrt_pos.mpr (mul_pos (by linarith) hll3) + let C := 32+2*(D : ℝ)/S + have hDC : 0 ≤ 2*(D : ℝ)/S := by positivity + have hC : 0 < C := by dsimp [C]; linarith + have h32 : 32 ≤ C := by dsimp [C]; linarith + refine ⟨C,hC,?_⟩ + intro d hd A inst + have hm : 0 ≤ Real.sqrt (Real.log (d : ℝ)*Real.log (Real.log (d : ℝ))) := Real.sqrt_nonneg _ + by_cases hDd : D ≤ d + · obtain ⟨f,hf⟩ := hD d hDd A + refine ⟨f,fun x y => ⟨(hf x y).1,?_⟩⟩ + apply (hf x y).2.trans + apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right h32 hm + · obtain ⟨f,hf⟩ := coarse_whole_map A d + have hl : Real.log 3 ≤ Real.log (d : ℝ) := + Real.log_le_log (by norm_num) (by exact_mod_cast hd) + have hll : Real.log (Real.log 3) ≤ Real.log (Real.log (d : ℝ)) := + Real.log_le_log (by linarith) hl + have hST : S ≤ Real.sqrt (Real.log (d : ℝ)*Real.log (Real.log (d : ℝ))) := by + apply Real.sqrt_le_sqrt + exact mul_le_mul hl hll hll3.le (by linarith) + have hCS : 2*(D : ℝ) ≤ C*S := by + have he : (2*(D : ℝ)/S)*S = 2*(D : ℝ) := div_mul_cancel₀ _ hS.ne' + dsimp [C] + nlinarith + have h2 : 2*(d : ℝ) ≤ exponentScale C d := by + have hdD : (d : ℝ) ≤ D := by exact_mod_cast (show d ≤ D by omega) + have hmC := mul_le_mul_of_nonneg_left hST hC.le + have hexp := Real.add_one_le_exp (C*Real.sqrt (Real.log (d : ℝ)*Real.log (Real.log (d : ℝ)))) + unfold exponentScale + linarith + exact ⟨f,fun x y => ⟨(hf x y).1,(hf x y).2.trans + (mul_le_mul_of_nonneg_right h2 (Nat.cast_nonneg _))⟩⟩ + +theorem fixed_length_binary_upper : ∃ C₀ : ℝ, 0 < C₀ ∧ ∀ m : ℕ, 3 ≤ m → + ∃ g : (Fin m → Bool) → L1, ∀ x y : Fin m → Bool, + (edit (List.ofFn x) (List.ofFn y) : ℝ) ≤ ‖g x-g y‖ ∧ + ‖g x-g y‖ ≤ exponentScale C₀ m*(edit (List.ofFn x) (List.ofFn y) : ℝ) := by + obtain ⟨C,hC,h⟩ := whole_maps_all_lengths.{0} + refine ⟨C,hC,?_⟩ + intro m hm + obtain ⟨f,hf⟩ := h m hm Bool + let word : (Fin m → Bool) → Words Bool m := fun x => ⟨List.ofFn x,by simp⟩ + exact ⟨fun x => f (word x),fun x y => hf (word x) (word y)⟩ + +end EditUpper + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/WindowRecursion.lean b/lean/OAI/Combinatorics/EditDistance/WindowRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..3acb3978e08d4fdeada536f1ac8e819ff68b13c2 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/WindowRecursion.lean @@ -0,0 +1,237 @@ +import OAI.Combinatorics.EditDistance.CutModels +import OAI.Combinatorics.EditDistance.DyadicScales +import OAI.Combinatorics.EditDistance.Windows + +namespace OAI + +/-! +# Dyadic-window recursion and insertion bounds +-/ + +namespace EditUpper +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset EditDistortion EditWindow EditCutModel + +variable {A : Type*} + +def samples (x : List A) (start l s : ℕ) : Fin s → List (Option A) := + fun i => window x (start+i.val) (l-s+1) + +noncomputable def piece (M : Model (List (Option A))) (x y : List A) (start l s : ℕ) : ℝ := + EditCutHash.meanHistogram M.weight (EditCutHash.rate s) M.cut + (samples x start l s) (samples y start l s) + +lemma piece_nonneg (M : Model (List (Option A))) (x y : List A) (start l s : ℕ) (hs : 0 < s) : + 0 ≤ piece M x y start l s := + EditCutHash.meanHistogram_nonneg M.nonneg (EditCutHash.rate_nonneg hs) _ _ _ + +noncomputable def lift (M : Model (List (Option A))) (b l : ℕ) : Model (List A) := + (Model.total (fun j : Fin b × Fin (Nat.log 2 l+1) => + (M.histogram (2^j.2.val) (EditCutHash.rate (2^j.2.val)) + (EditCutHash.rate_nonneg (pow_pos (by omega) _))).pullback + (fun x => samples x (j.1.val*l) l (2^j.2.val)))).scale 16 (by norm_num) + +lemma lift_dist (M : Model (List (Option A))) (b l : ℕ) (x y : List A) : + (lift M b l).dist x y = + 16 * ∑ j : Fin b, ∑ r : Fin (Nat.log 2 l+1), piece M x y (j.val*l) l (2^r.val) := by + rw [lift,Model.scale_dist,Model.total_dist,Fintype.sum_prod_type] + congr 1 + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro r _ + rw [Model.pullback_dist,Model.histogram_dist] + rfl + +lemma block_indel_bound (x y : List A) (start l : ℕ) : + indel (window x start l) (window y start l) ≤ 2*l := by + have h : indel (window x start l) (window y start l) ≤ + (window x start l).length+(window y start l).length := by + exact cost_le ((Script.to_nil (s := false) _).trans (Script.to_nil _).symm) + simpa only [window_length,two_mul] using h + +lemma block_lower (M : Model (List (Option A))) (l : ℕ) (hl : 0 < l) + (hM : ∀ u v : List (Option A), u.length ≤ l → v.length ≤ l → + (indel u v : ℝ) ≤ M.dist u v) (x y : List A) (start : ℕ) : + (indel (window x start l) (window y start l) : ℝ) ≤ + 16 * ∑ r : Fin (Nat.log 2 l+1), piece M x y start l (2^r.val) := by + let delta := indel (window x start l) (window y start l) + have hnn (r : Fin (Nat.log 2 l+1)) : 0 ≤ piece M x y start l (2^r.val) := + piece_nonneg _ _ _ _ _ _ (pow_pos (by omega) _) + by_cases hd : delta = 0 + · change (delta : ℝ) ≤ _ + rw [hd,Nat.cast_zero] + exact mul_nonneg (by norm_num) (sum_nonneg (fun r _ => hnn r)) + · obtain ⟨r,hs,hsl,hds,hsd⟩ := EditDyadic.scale hl (Nat.pos_of_ne_zero hd) (block_indel_bound x y start l) + have hcross (i j : Fin (2^r.val)) : ((2^r.val : ℕ) : ℝ) ≤ + EditCutHash.distance M.weight M.cut (samples x start l (2^r.val) i) (samples y start l (2^r.val) j) := by + rw [Model.distance_eq] + have htri := segment_cross (fun k => x[k]?) (fun k => y[k]?) start l (2^r.val) hs hsl i j + change delta ≤ 2*(2^r.val-1)+indel (samples x start l (2^r.val) i) + (samples y start l (2^r.val) j) at htri + have hloss : 2^r.val ≤ indel (samples x start l (2^r.val) i) + (samples y start l (2^r.val) j) := by omega + calc + _ ≤ (indel (samples x start l (2^r.val) i) (samples y start l (2^r.val) j) : ℝ) := by exact_mod_cast hloss + _ ≤ _ := hM _ _ (by simp only [samples,window_length]; omega) (by simp only [samples,window_length]; omega) + have hh := EditCutHash.meanHistogram_separated (by omega : 0 < 2^r.val) M.nonneg M.cut + (samples x start l (2^r.val)) (samples y start l (2^r.val)) hcross + change ((2^r.val : ℕ) : ℝ) ≤ piece M x y start l (2^r.val) at hh + have hsum := single_le_sum (fun j _ => hnn j) (mem_univ r) + have hdsr : (delta : ℝ) ≤ 16*((2^r.val : ℕ) : ℝ) := by exact_mod_cast hds + change (delta : ℝ) ≤ _ + nlinarith + +lemma lift_lower (M : Model (List (Option A))) (b l : ℕ) (hl : 0 < l) + (hM : ∀ u v : List (Option A), u.length ≤ l → v.length ≤ l → + (indel u v : ℝ) ≤ M.dist u v) (x y : List A) + (hx : x.length ≤ b*l) (hy : y.length ≤ b*l) : + (indel x y : ℝ) ≤ (lift M b l).dist x y := by + have h1 := indel_le_window x y (b*l) hx hy + have h2 := indel_segment_blocks (fun k => x[k]?) (fun k => y[k]?) l b + change indel (window x 0 (b*l)) (window y 0 (b*l)) ≤ _ at h2 + have h3 : (indel x y : ℝ) ≤ + ∑ j : Fin b, (indel (window x (j.val*l) l) (window y (j.val*l) l) : ℝ) := by + rw [Fin.sum_univ_eq_sum_range (fun j => (indel (window x (j*l) l) (window y (j*l) l) : ℝ)) b] + exact_mod_cast h1.trans h2 + rw [lift_dist,mul_sum] + apply h3.trans + apply sum_le_sum + intro j _ + exact block_lower M l hl hM x y (j.val*l) + +lemma piece_insert_general (M : Model (List (Option A))) {D : ℝ} (hD : 0 ≤ D) + (hM : ∀ u v, M.dist u v ≤ D*(indel u v : ℝ)) + (p q : List A) (a : A) (start l s : ℕ) (hs : 0 < s) : + piece M (p++q) (p++a::q) start l s ≤ 4*Real.log (2*(s : ℝ)^2)*D := by + have hup := EditCutHash.meanHistogram_upper M.nonneg (EditCutHash.rate_nonneg hs) M.cut + (samples (p++q) start l s) (samples (p++a::q) start l s) + have hsum : (∑ i : Fin s, EditCutHash.distance M.weight M.cut + (samples (p++q) start l s i) (samples (p++a::q) start l s i)) ≤ (s : ℝ)*(2*D) := by + calc + _ ≤ ∑ _i : Fin s, 2*D := by + apply sum_le_sum + intro i _ + rw [Model.distance_eq] + have hcost := window_insert_cost p q a (start+i.val) (l-s+1) + have hcr : (indel (samples (p++q) start l s i) (samples (p++a::q) start l s i) : ℝ) ≤ 2 := by exact_mod_cast hcost + exact (hM _ _).trans (by nlinarith) + _ = _ := by simp only [sum_const,card_univ,Fintype.card_fin,nsmul_eq_mul] + have hr := EditCutHash.rate_nonneg hs + have h := hup.trans (mul_le_mul_of_nonneg_left hsum (by positivity)) + change piece M (p++q) (p++a::q) start l s ≤ _ at h + apply h.trans_eq + unfold EditCutHash.rate + have hs0 : (s : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hs) + field_simp + ring + +lemma piece_before (M : Model (List (Option A))) (p q : List A) (a : A) + (start l s : ℕ) (_hs : 0 < s) (hsl : s ≤ l) (hp : start+l ≤ p.length) : + piece M (p++q) (p++a::q) start l s = 0 := by + have he : samples (p++q) start l s = samples (p++a::q) start l s := by + funext i + exact (window_before p q a (by omega)).symm + unfold piece + rw [←he,EditCutHash.meanHistogram_self] + +lemma piece_after (M : Model (List (Option A))) (p q : List A) (a : A) + (start l s : ℕ) (hs : 0 < s) (hp : p.length ≤ start) : + piece M (p++q) (p++a::q) start l s ≤ 2 := by + apply EditCutHash.meanHistogram_shift hs M.nonneg (EditCutHash.rate_nonneg hs) + intro i + exact (window_after p q a (by omega)).symm + +end EditUpper + +namespace EditUpper +attribute [local instance] Classical.propDecidable +open scoped BigOperators +open Finset EditDistortion EditWindow EditCutModel +variable {A : Type*} + +lemma sum_block_insert (M : Model (List (Option A))) {D : ℝ} (hD : 0 ≤ D) + (hM : ∀ u v, M.dist u v ≤ D*(indel u v : ℝ)) + (p q : List A) (a : A) (b l s : ℕ) (hl : 0 < l) (hs : 0 < s) (hsl : s ≤ l) : + (∑ j : Fin b, piece M (p++q) (p++a::q) (j.val*l) l s) ≤ + 2*(b : ℝ)+4*Real.log (2*(s : ℝ)^2)*D := by + let K := 4*Real.log (2*(s : ℝ)^2)*D + have hK : 0 ≤ K := by + dsimp [K] + have hs1 : (1 : ℝ) ≤ s := by exact_mod_cast hs + exact mul_nonneg (mul_nonneg (by norm_num) (Real.log_nonneg (by nlinarith))) hD + have hj (j : Fin b) : piece M (p++q) (p++a::q) (j.val*l) l s ≤ + 2+(if j.val = p.length/l then K else 0) := by + by_cases he : j.val = p.length/l + · rw [ite_eq_left he] + have hh := piece_insert_general M hD hM p q a (j.val*l) l s hs + change _ ≤ K at hh + linarith + · rw [ite_eq_right he,add_zero] + by_cases hlt : j.val < p.length/l + · have hp : j.val*l+l ≤ p.length := by + have h1 := Nat.mul_le_mul_right l (show j.val+1 ≤ p.length/l by omega) + have h2 := Nat.div_mul_le_self p.length l + nlinarith + rw [piece_before M p q a (j.val*l) l s hs hsl hp] + norm_num + · have hp : p.length ≤ j.val*l := by + have h1 := Nat.mul_le_mul_right l (show p.length/l+1 ≤ j.val by omega) + have h2 := Nat.lt_mul_div_succ p.length hl + nlinarith + exact piece_after M p q a (j.val*l) l s hs hp + have hsum := sum_le_sum (fun j (_ : j ∈ (univ : Finset (Fin b))) => hj j) + rw [sum_add_distrib] at hsum + have hc : (∑ j : Fin b, (if j.val = p.length/l then K else 0)) ≤ K := by + rw [Fin.sum_univ_eq_sum_range (fun j => if j = p.length/l then K else 0) b,sum_ite_eq'] + split <;> linarith + simp only [sum_const,card_univ,Fintype.card_fin,nsmul_eq_mul] at hsum + dsimp [K] at hc hsum + linarith + +lemma lift_insert_raw (M : Model (List (Option A))) {D : ℝ} (hD : 0 ≤ D) + (hM : ∀ u v, M.dist u v ≤ D*(indel u v : ℝ)) + (p q : List A) (a : A) (b l : ℕ) (hl : 0 < l) : + (lift M b l).dist (p++q) (p++a::q) ≤ + 16*(Nat.log 2 l+1 : ℕ)*(2*(b : ℝ)+4*Real.log (2*(l : ℝ)^2)*D) := by + rw [lift_dist,sum_comm] + have hscale (r : Fin (Nat.log 2 l+1)) : (∑ j : Fin b, + piece M (p++q) (p++a::q) (j.val*l) l (2^r.val)) ≤ + 2*(b : ℝ)+4*Real.log (2*(l : ℝ)^2)*D := by + have hr := EditDyadic.scale_le hl r + have hp : 0 < 2^r.val := pow_pos (by omega) _ + have h := sum_block_insert M hD hM p q a b l (2^r.val) hl hp hr + apply h.trans + have hrr : ((2^r.val : ℕ) : ℝ) ≤ l := by exact_mod_cast hr + have hlog : Real.log (2*(((2^r.val : ℕ) : ℝ))^2) ≤ Real.log (2*(l : ℝ)^2) := by + apply Real.log_le_log (by positivity) + gcongr + nlinarith + calc + _ ≤ 16 * ∑ _r : Fin (Nat.log 2 l+1), (2*(b : ℝ)+4*Real.log (2*(l : ℝ)^2)*D) := + mul_le_mul_of_nonneg_left (sum_le_sum (fun r _ => hscale r)) (by norm_num) + _ = _ := by simp only [sum_const,card_univ,Fintype.card_fin,nsmul_eq_mul]; ring + +lemma model_indel_lipschitz (M : Model (List A)) {D : ℝ} + (hstep : ∀ (p q : List A) (a : A), M.dist (p++q) (p++a::q) ≤ D) : + ∀ x y, M.dist x y ≤ D*(indel x y : ℝ) := by + have he {x y : List A} (h : Step false x y) : M.dist x y ≤ D := by + cases h with + | insert p q a => exact hstep p q a + | delete p q a => rw [Model.dist_symm]; exact hstep p q a + | substitute h => contradiction + have hs {n : ℕ} {x y : List A} (h : Script false n x y) : M.dist x y ≤ D*(n : ℝ) := by + induction h with + | nil x => simp + | @cons n x y z e h ih => + have ht := M.dist_triangle x y z + have hh := he e + push_cast + nlinarith + intro x y + exact hs (cost_spec x y) + +end EditUpper + +end OAI diff --git a/lean/OAI/Combinatorics/EditDistance/Windows.lean b/lean/OAI/Combinatorics/EditDistance/Windows.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9cc6b3b7f22a054af8fc9e0653e5827c48cf1e2 --- /dev/null +++ b/lean/OAI/Combinatorics/EditDistance/Windows.lean @@ -0,0 +1,199 @@ +import OAI.Combinatorics.EditDistance.RowSeparation + +namespace OAI + +/-! +# Padded windows and insertion-deletion matching inequalities +-/ + +namespace EditWindow +open EditDistortion + +variable {A : Type*} + +def window (x : List A) (start len : ℕ) : List (Option A) := + List.ofFn (fun i : Fin len => x[start+i.val]?) + +@[simp] lemma window_length (x : List A) (start len : ℕ) : (window x start len).length = len := + List.length_ofFn + +lemma lookup_insert_before (p q : List A) (a : A) {r : ℕ} (hr : r < p.length) : + (p ++ a::q)[r]? = (p ++ q)[r]? := by + rw [List.getElem?_append_left hr,List.getElem?_append_left hr] + +lemma lookup_insert_after (p q : List A) (a : A) {r : ℕ} (hr : p.length ≤ r) : + (p ++ a::q)[r+1]? = (p ++ q)[r]? := by + rw [List.getElem?_append_right (by omega),List.getElem?_append_right hr] + have he : r+1-p.length = (r-p.length)+1 := by omega + simp only [he,List.getElem?_cons_succ] + +lemma window_before (p q : List A) (a : A) {start len : ℕ} (h : start+len ≤ p.length) : + window (p ++ a::q) start len = window (p ++ q) start len := by + unfold window + congr 1 + funext i + exact lookup_insert_before p q a (by omega) + +lemma window_after (p q : List A) (a : A) {start len : ℕ} (h : p.length ≤ start) : + window (p ++ a::q) (start+1) len = window (p ++ q) start len := by + unfold window + congr 1 + funext i + simpa only [Nat.add_assoc,Nat.add_left_comm,Nat.add_comm] using + lookup_insert_after p q a (r := start+i.val) (by omega) + +theorem window_insert_cost (p q : List A) (a : A) (start len : ℕ) : + indel (window (p ++ q) start len) (window (p ++ a::q) start len) ≤ 2 := by + by_cases hl : len = 0 + · subst len + have hh : indel ([] : List (Option A)) [] = 0 := (cost_eq_zero_iff (s := false)).mpr rfl + simpa only [window,List.ofFn_zero,hh] using (by norm_num : (0 : ℕ) ≤ 2) + have hlp : 0 < len := Nat.pos_of_ne_zero hl + let f : Fin (len-1) ↪o Fin len := + (Fin.castLEOrderEmb (by omega : len-1 ≤ len)) + let g₀ (i : Fin (len-1)) : Fin len := + ⟨if start+i.val < p.length then i.val else i.val+1,by split <;> omega⟩ + have hg : StrictMono g₀ := by + intro i j hij + have hij' : i.val < j.val := hij + change (if start+i.val < p.length then i.val else i.val+1) < + (if start+j.val < p.length then j.val else j.val+1) + split <;> split <;> omega + let g : Fin (len-1) ↪o Fin len := OrderEmbedding.ofStrictMono g₀ hg + have he (i : Fin (len-1)) : + (p ++ q)[start+(f i).val]? = (p ++ a::q)[start+(g i).val]? := by + change (p ++ q)[start+i.val]? = + (p ++ a::q)[start+(if start+i.val < p.length then i.val else i.val+1)]? + split + · rename_i hi + exact (lookup_insert_before p q a hi).symm + · rename_i hi + simpa only [Nat.add_assoc] using + (lookup_insert_after p q a (r := start+i.val) (by omega)).symm + have hh := indel_le_of_matching (fun i : Fin len => (p ++ q)[start+i.val]?) + (fun i : Fin len => (p ++ a::q)[start+i.val]?) f g he + exact hh.trans (by omega) + +end EditWindow + +namespace EditDistortion +variable {A B : Type*} + +lemma indel_cost (x y : List A) : indel x y = cost false x y := rfl + +lemma step_indel_filterMap (f : A → Option B) {x y : List A} (h : Step false x y) : + indel (x.filterMap f) (y.filterMap f) ≤ 1 := by + cases h with + | insert p q a => + cases ha : f a with + | none => simp only [List.filterMap_append,List.filterMap_cons,ha,indel_cost,cost_refl]; omega + | some b => + simpa only [List.filterMap_append,List.filterMap_cons,ha,indel_cost] using + cost_le (Script.single (Step.insert (substitutions := false) (p.filterMap f) (q.filterMap f) b)) + | delete p q a => + cases ha : f a with + | none => simp only [List.filterMap_append,List.filterMap_cons,ha,indel_cost,cost_refl]; omega + | some b => + simpa only [List.filterMap_append,List.filterMap_cons,ha,indel_cost] using + cost_le (Script.single (Step.delete (substitutions := false) (p.filterMap f) (q.filterMap f) b)) + | substitute hf => contradiction + +lemma indel_filterMap_le (f : A → Option B) (x y : List A) : + indel (x.filterMap f) (y.filterMap f) ≤ indel x y := by + have hh {n : ℕ} {x y : List A} (h : Script false n x y) : + indel (x.filterMap f) (y.filterMap f) ≤ n := by + induction h with + | nil x => exact cost_le (.nil _) + | @cons n x y z e h ih => + have ht := cost_triangle (s := false) (x.filterMap f) (y.filterMap f) (z.filterMap f) + have he := step_indel_filterMap f e + rw [indel_cost] at he ih ⊢ + omega + exact hh (cost_spec x y) +end EditDistortion + +namespace EditWindow +open EditDistortion +variable {A : Type*} + +def segment (x : ℕ → A) (start len : ℕ) : List A := + List.ofFn (fun i : Fin len => x (start+i.val)) + +@[simp] lemma segment_length (x : ℕ → A) (start len : ℕ) : + (segment x start len).length = len := List.length_ofFn + +lemma segment_sublist (x : ℕ → A) (start l k L : ℕ) (hk : k+L ≤ l) : + (segment x (start+k) L).Sublist (segment x start l) := by + let f : Fin L ↪o Fin l := OrderEmbedding.ofStrictMono + (fun i => (⟨k+i.val,by omega⟩ : Fin l)) (by intro i j hij; change k+i.val < k+j.val; omega) + have hh := sublist_ofFn_comp (fun i : Fin l => x (start+i.val)) f + dsimp [f,OrderEmbedding.ofStrictMono] at hh + simpa only [segment,Nat.add_assoc] using hh + +lemma segment_loss (x : ℕ → A) (start l k L : ℕ) (hk : k+L ≤ l) : + indel (segment x start l) (segment x (start+k) L) ≤ l-L := by + simpa only [segment_length,indel_cost] using cost_le (Script.of_sublist (segment_sublist x start l k L hk)) + +lemma segment_cross (x y : ℕ → A) (start l s : ℕ) (hs : 1 ≤ s) (hsl : s ≤ l) + (i j : Fin s) : + indel (segment x start l) (segment y start l) ≤ + 2*(s-1)+indel (segment x (start+i.val) (l-s+1)) (segment y (start+j.val) (l-s+1)) := by + have hx := segment_loss x start l i.val (l-s+1) (by omega) + have hy := segment_loss y start l j.val (l-s+1) (by omega) + rw [indel_cost,cost_symm] at hy + have h1 := cost_triangle (s := false) (segment x start l) + (segment x (start+i.val) (l-s+1)) (segment y (start+j.val) (l-s+1)) + have h2 := cost_triangle (s := false) (segment x start l) + (segment y (start+j.val) (l-s+1)) (segment y start l) + simp only [indel_cost] at hx hy ⊢ + omega + +lemma segment_append (x : ℕ → A) (start l m : ℕ) : + segment x start (l+m) = segment x start l ++ segment x (start+l) m := by + unfold segment + rw [List.ofFn_add] + congr 1 + congr 1 + funext i + simp only [Fin.val_natAdd,Nat.add_assoc] + +lemma indel_segment_blocks (x y : ℕ → A) (l b : ℕ) : + indel (segment x 0 (b*l)) (segment y 0 (b*l)) ≤ + ∑ j ∈ Finset.range b, indel (segment x (j*l) l) (segment y (j*l) l) := by + induction b with + | zero => simp only [Nat.zero_mul,segment,List.ofFn_zero,Finset.sum_range_zero]; exact cost_le (.nil _) + | succ b ih => + rw [Nat.succ_mul,segment_append,segment_append,Finset.sum_range_succ] + simp only [Nat.zero_add] + exact (cost_append_le (s := false) _ _ _ _).trans (Nat.add_le_add_right ih _) + +lemma window_eq_segment (x : List A) (start len : ℕ) : + window x start len = segment (fun k => x[k]?) start len := rfl + +lemma window_padding (x : List A) (n : ℕ) (hx : x.length ≤ n) : + window x 0 n = (x.map some) ++ List.replicate (n-x.length) none := by + apply List.ext_getElem? + intro i + simp only [window,List.getElem?_ofFn,Nat.zero_add,List.getElem?_append,List.length_map, + List.getElem?_map,List.getElem?_replicate] + by_cases hix : i < x.length + · have hin : i < n := lt_of_lt_of_le hix hx + simp [hix,hin] + · have hxn : x[i]? = none := List.getElem?_eq_none (by omega) + have hi : i-x.length < n-x.length ↔ i < n := by omega + simp only [ite_eq_right hix,hxn,hi] + split <;> rfl + +lemma filterMap_window (x : List A) (n : ℕ) (hx : x.length ≤ n) : + (window x 0 n).filterMap id = x := by + rw [window_padding x n hx] + simp + +lemma indel_le_window (x y : List A) (n : ℕ) (hx : x.length ≤ n) (hy : y.length ≤ n) : + indel x y ≤ indel (window x 0 n) (window y 0 n) := by + have hh := indel_filterMap_le id (window x 0 n) (window y 0 n) + simpa only [filterMap_window x n hx,filterMap_window y n hy] using hh + +end EditWindow + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/AdicLifting.lean b/lean/OAI/Combinatorics/EuclideanRamsey/AdicLifting.lean new file mode 100644 index 0000000000000000000000000000000000000000..edc829eb4b2442f00b4de0077b8546cbe63c08b2 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/AdicLifting.lean @@ -0,0 +1,450 @@ +import OAI.Combinatorics.EuclideanRamsey.StencilConvolution + +namespace OAI + +universe uRing uGroup uSemigroup uModule uModuleTarget uIndex + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology + +open scoped TensorProduct +namespace EuclideanRamsey + +section NilpotentLog +variable {R : Type uRing} [CommRing R] [Algebra ℚ R] +open Finset + +lemma nil_exp_quadratic {a : R} (ha : IsNilpotent a) : + ∃ b : R, IsNilpotent b ∧ IsNilpotent.exp a = 1 + a * (1 + b) := by + obtain ⟨n, hn⟩ := ha + let c : R := ∑ i ∈ range n, ((i + 2).factorial : ℚ)⁻¹ • a ^ i + refine ⟨a * c, ?_, ?_⟩ + · exact ⟨n, by rw [mul_pow, hn, zero_mul]⟩ + · rw [IsNilpotent.exp_eq_sum (pow_eq_zero_of_le (Nat.le_add_right n 2) hn)] + rw [show n + 2 = 2 + n by omega, sum_range_add] + have h2 : (∑ i ∈ range 2, (i.factorial : ℚ)⁻¹ • a ^ i) = 1 + a := by + simp [sum_range_succ] + rw [h2] + have ht : (∑ i ∈ range n, ((2 + i).factorial : ℚ)⁻¹ • a ^ (2 + i)) = a ^ 2 * c := by + simp only [c, mul_sum, pow_add, mul_smul_comm, add_comm 2, mul_comm] + rw [ht] + ring + +lemma nil_exp_eq_one_iff {a : R} (ha : IsNilpotent a) : + IsNilpotent.exp a = 1 ↔ a = 0 := by + obtain ⟨b, hb, he⟩ := nil_exp_quadratic ha + rw [he] + constructor + · intro h + have hmul : a * (1 + b) = 0 := by linear_combination h + exact hb.isUnit_one_add.mul_right_cancel (by simpa using hmul) + · intro h + simp [h] + +lemma nil_exp_sub_one_sub_mem {J : Ideal R} {a : R} (ha : IsNilpotent a) (hJ : a ∈ J) : + IsNilpotent.exp a - 1 - a ∈ J ^ 2 := by + obtain ⟨n, hn⟩ := ha + rw [IsNilpotent.exp_eq_sum (pow_eq_zero_of_le (Nat.le_add_right n 2) hn)] + rw [show n + 2 = 2 + n by omega, sum_range_add] + have h2 : (∑ i ∈ range 2, (i.factorial : ℚ)⁻¹ • a ^ i) = 1 + a := by + simp [sum_range_succ] + rw [h2] + have he : 1 + a + (∑ i ∈ range n, ((2 + i).factorial : ℚ)⁻¹ • a ^ (2 + i)) - 1 - a = + ∑ i ∈ range n, ((2 + i).factorial : ℚ)⁻¹ • a ^ (2 + i) := by ring + rw [he] + apply Submodule.sum_mem + intro i hi + rw [Algebra.smul_def] + apply Ideal.mul_mem_left + rw [pow_add] + exact Ideal.mul_mem_right _ _ (Ideal.pow_mem_pow hJ 2) + +lemma nil_exp_sub_one_mem {J : Ideal R} {a : R} (ha : IsNilpotent a) (hJ : a ∈ J) : + IsNilpotent.exp a - 1 ∈ J := by + have h2 := nil_exp_sub_one_sub_mem ha hJ + have hle : J ^ 2 ≤ J := Ideal.pow_le_self (by omega) + have := J.add_mem (hle h2) hJ + simpa only [sub_add_cancel] using this + +omit [Algebra ℚ R] in +lemma nilpotent_of_mem_nil_ideal {I : Ideal R} {n : ℕ} (hI : I ^ n = ⊥) + {x : R} (hx : x ∈ I) : IsNilpotent x := by + refine ⟨n, ?_⟩ + have := Ideal.pow_mem_pow hx n + simpa only [hI, Ideal.mem_bot] using this + +lemma nil_ideal_exp_surjective {I : Ideal R} {n : ℕ} (hI : I ^ n = ⊥) + {z : R} (hz : z ∈ I) : ∃ x ∈ I, IsNilpotent.exp x = 1 + z := by + have happrox : ∀ k : ℕ, ∃ x ∈ I, IsNilpotent.exp x - (1 + z) ∈ I ^ (k + 1) := by + intro k + induction k with + | zero => + refine ⟨0, I.zero_mem, ?_⟩ + simpa using I.neg_mem hz + | succ k ih => + obtain ⟨x, hx, he⟩ := ih + let e := (1 + z) - IsNilpotent.exp x + have he' : e ∈ I ^ (k + 1) := by simpa only [e, neg_sub] using (I ^ (k + 1)).neg_mem he + have hp : I ^ (k + 1) ≤ I := Ideal.pow_le_self (by omega) + have hei : e ∈ I := hp he' + have hnx := nilpotent_of_mem_nil_ideal hI hx + have hne := nilpotent_of_mem_nil_ideal hI hei + refine ⟨x + e, I.add_mem hx hei, ?_⟩ + rw [IsNilpotent.exp_add_of_commute (Commute.all _ _) hnx hne] + let r := IsNilpotent.exp e - 1 - e + have hr : r ∈ (I ^ (k + 1)) ^ 2 := nil_exp_sub_one_sub_mem hne he' + have hle : (I ^ (k + 1)) ^ 2 ≤ I ^ (k + 2) := by + rw [← pow_mul] + exact Ideal.pow_le_pow_right (by omega) + have hterm1 : (IsNilpotent.exp x - 1) * e ∈ I ^ (k + 2) := by + have hh := Ideal.mul_mem_mul (nil_exp_sub_one_mem hnx hx) he' + simpa only [← pow_succ', Nat.add_assoc] using hh + have hterm2 : IsNilpotent.exp x * r ∈ I ^ (k + 2) := + Ideal.mul_mem_left _ _ (hle hr) + have hh := (I ^ (k + 2)).add_mem hterm1 hterm2 + convert hh using 1 ; dsimp [r, e] ; ring + obtain ⟨x, hx, he⟩ := happrox n + have hp : I ^ (n + 1) = ⊥ := by simp [pow_succ, hI] + rw [hp, Ideal.mem_bot, sub_eq_zero] at he + exact ⟨x, hx, he⟩ + +end NilpotentLog + +section LogCharacter +variable {R : Type uRing} [CommRing R] [Algebra ℚ R] + {I : Ideal R} {n : ℕ} (hI : I ^ n = ⊥) + +include hI in +lemma nil_exp_injective {a b : R} (ha : a ∈ I) (hb : b ∈ I) + (he : IsNilpotent.exp a = IsNilpotent.exp b) : a = b := by + have hna := nilpotent_of_mem_nil_ideal hI ha + have hnb := nilpotent_of_mem_nil_ideal hI hb + have hnd := nilpotent_of_mem_nil_ideal hI (I.sub_mem ha hb) + apply sub_eq_zero.mp + apply (nil_exp_eq_one_iff hnd).mp + rw [sub_eq_add_neg, IsNilpotent.exp_add_of_commute (Commute.all _ _) hna hnb.neg, + he, hnb.exp_mul_exp_neg_self] + +variable {G : Type uGroup} [AddCommGroup G] (χ : Multiplicative G →* R) + (hχ : ∀ γ : G, χ (Multiplicative.ofAdd γ) - 1 ∈ I) + +noncomputable def characterLog (γ : G) : R := + Classical.choose (nil_ideal_exp_surjective hI (hχ γ)) + +lemma characterLog_mem (γ : G) : characterLog hI χ hχ γ ∈ I := + (Classical.choose_spec (nil_ideal_exp_surjective hI (hχ γ))).1 + +lemma characterLog_exp (γ : G) : + IsNilpotent.exp (characterLog hI χ hχ γ) = χ (Multiplicative.ofAdd γ) := by + have := (Classical.choose_spec (nil_ideal_exp_surjective hI (hχ γ))).2 + simpa only [characterLog, add_sub_cancel] using this + +noncomputable def characterLogHom : G →+ R where + toFun := characterLog hI χ hχ + map_zero' := by + apply nil_exp_injective hI (characterLog_mem ..) I.zero_mem + rw [characterLog_exp, IsNilpotent.exp_zero] + exact χ.map_one + map_add' a b := by + apply nil_exp_injective hI (characterLog_mem ..) + (I.add_mem (characterLog_mem ..) (characterLog_mem ..)) + rw [characterLog_exp, IsNilpotent.exp_add_of_commute (Commute.all _ _) + (nilpotent_of_mem_nil_ideal hI (characterLog_mem ..)) + (nilpotent_of_mem_nil_ideal hI (characterLog_mem ..)), characterLog_exp, characterLog_exp] + exact χ.map_mul _ _ + +lemma characterLog_map_zero {S : Type uSemigroup} [CommRing S] [Algebra ℚ S] + (f : R →ₐ[ℚ] S) (γ : G) (h : f (χ (Multiplicative.ofAdd γ)) = 1) : + f (characterLogHom hI χ hχ γ) = 0 := by + have hn := nilpotent_of_mem_nil_ideal hI (characterLog_mem hI χ hχ γ) + apply (nil_exp_eq_one_iff (hn.map f)).mp + rw [← hn.map_exp f, characterLog_exp, h] + +end LogCharacter + +section LatticeLog +variable {k : ℕ} {R : Type uRing} [CommRing R] [Algebra ℚ R] + +def rationalExtension (f : (Fin k → ℤ) →+ R) : (Fin k → ℚ) →ₗ[ℚ] R where + toFun v := ∑ j, v j • f (Pi.single j 1) + map_add' a b := by simp [add_smul, Finset.sum_add_distrib] + map_smul' a b := by simp [mul_smul, Finset.smul_sum] + +lemma rationalExtension_lattice (f : (Fin k → ℤ) →+ R) (γ : Fin k → ℤ) : + rationalExtension f (fun j => (γ j : ℚ)) = f γ := by + dsimp [rationalExtension] + simp_rw [Int.cast_smul_eq_zsmul, ← map_zsmul] + rw [← map_sum] + congr 1 + convert Finset.univ_sum_single γ using 1 + congr 1 + ext j + rw [← Pi.single_smul] + simp + +lemma rationalExtension_mem {I : Ideal R} (f : (Fin k → ℤ) →+ R) + (hf : ∀ γ, f γ ∈ I) (v : Fin k → ℚ) : rationalExtension f v ∈ I := by + change (∑ j, v j • f (Pi.single j 1)) ∈ I + apply I.sum_mem + intro j hj + rw [Algebra.smul_def] + exact I.mul_mem_left _ (hf _) + +end LatticeLog + +section AdicLifting +variable {R : Type uRing} {M : Type uModule} {N : Type uModuleTarget} [CommRing R] [IsNoetherianRing R] + [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] + [Module.Finite R N] + +lemma adic_kernel_lifting (I : Ideal R) (f : M →ₗ[R] N) (q : ℕ) : + ∃ n : ℕ, ∀ x : M, f x ∈ I ^ n • (⊤ : Submodule R N) → + ∃ y : M, f y = 0 ∧ x - y ∈ I ^ q • (⊤ : Submodule R M) := by + obtain ⟨k, hk⟩ := I.exists_pow_inf_eq_pow_smul (LinearMap.range f) + refine ⟨k + q, ?_⟩ + intro x hx + have hfx : f x ∈ I ^ (k + q) • (⊤ : Submodule R N) ⊓ LinearMap.range f := + ⟨hx, ⟨x, rfl⟩⟩ + rw [hk (k + q) (by omega), Nat.add_sub_cancel_left] at hfx + have hle : I ^ q • (I ^ k • (⊤ : Submodule R N) ⊓ LinearMap.range f) ≤ + I ^ q • LinearMap.range f := smul_mono_right _ inf_le_right + have hf' : f x ∈ I ^ q • LinearMap.range f := hle hfx + have hm : I ^ q • LinearMap.range f = Submodule.map f (I ^ q • (⊤ : Submodule R M)) := by + rw [Submodule.map_smul''] + simp + rw [hm] at hf' + obtain ⟨z, hz, he⟩ := hf' + refine ⟨x - z, ?_, ?_⟩ + · rw [map_sub, he, sub_self] + · simpa using hz + +end AdicLifting + +section IntersectionLifting +variable {R : Type uRing} [CommRing R] [IsNoetherianRing R] + {ι : Type uIndex} [Fintype ι] (I : Ideal R) (J : ι → Ideal R) + +lemma adic_intersection_lifting (q : ℕ) : + ∃ n : ℕ, ∀ x : R, (∀ i, x ∈ J i ⊔ I ^ n) → + ∃ y : R, (∀ i, y ∈ J i) ∧ x - y ∈ I ^ q := by + classical + let f : R →ₗ[R] (∀ i, R ⧸ J i) := LinearMap.pi (fun i => Algebra.linearMap R (R ⧸ J i)) + obtain ⟨n, hn⟩ := adic_kernel_lifting I f q + refine ⟨n, fun x hx => ?_⟩ + have hm : f x ∈ I ^ n • (⊤ : Submodule R (∀ i, R ⧸ J i)) := by + have hz : ∀ i, ∃ z ∈ I ^ n, (Ideal.Quotient.mk (J i)) z = (Ideal.Quotient.mk (J i)) x := by + intro i + obtain ⟨y, hy, z, hz, he⟩ := Submodule.mem_sup.mp (hx i) + refine ⟨z, hz, ?_⟩ + rw [← he, map_add, (Ideal.Quotient.eq_zero_iff_mem).mpr hy, zero_add] + choose z hz he using hz + have he' : f x = ∑ i, z i • Pi.single i (1 : R ⧸ J i) := by + simp_rw [← Pi.single_smul, Algebra.smul_def, mul_one, + Ideal.Quotient.algebraMap_eq, he] + exact (Finset.univ_sum_single _).symm + rw [he'] + exact Submodule.sum_mem _ (fun i _ => Submodule.smul_mem_smul (hz i) Submodule.mem_top) + obtain ⟨y, hy, hxy⟩ := hn x hm + refine ⟨y, ?_, ?_⟩ + · intro i + apply Ideal.Quotient.eq_zero_iff_mem.mp + exact congrFun hy i + · simpa only [Ideal.smul_eq_mul, Ideal.mul_top] using hxy + +end IntersectionLifting + +section Construction +variable {k : ℕ} + +@[simp] lemma rationalExtension_single {R : Type uRing} [CommRing R] [Algebra ℚ R] + (f : Lattice k →+ R) (a : Fin k) : + rationalExtension f (Pi.single a 1) = f (Pi.single a 1) := by + classical + simp [rationalExtension, Pi.single_apply] + +lemma tensor_quotient_quadratic {S : Type uSemigroup} [CommRing S] [Algebra ℚ S] + (V : Submodule ℚ (RationalSpace k)) (C : Matrix (Fin k) (Fin k) ℚ) + (f : RationalSpace k →ₗ[ℚ] S) (hf : V ≤ LinearMap.ker f) + (hC : TensorProduct.map V.mkQ V.mkQ (matrixTensor C) = 0) : + (∑ a, ∑ b, C a b • (f (Pi.single a 1) * f (Pi.single b 1))) = 0 := by + let u := V.liftQ f hf + let φ := (Algebra.TensorProduct.lmul' ℚ : S ⊗[ℚ] S →ₐ[ℚ] S).toLinearMap.comp + (TensorProduct.map u u) + have hh := congrArg φ hC + simpa [φ, u, matrixTensor, LinearMap.comp_apply] using hh + +def cosetMap (Λ : AddSubgroup (Lattice k)) : + LatticeRing k →ₐ[ℚ] AddMonoidAlgebra ℚ (Lattice k ⧸ Λ) := + AddMonoidAlgebra.mapDomainAlgHom ℚ ℚ (QuotientAddGroup.mk' Λ) + +def cosetIdeal (Λ : AddSubgroup (Lattice k)) : Ideal (LatticeRing k) := + RingHom.ker (cosetMap Λ) + +lemma mem_cosetIdeal_iff (Λ : AddSubgroup (Lattice k)) (x : LatticeRing k) : + x ∈ cosetIdeal Λ ↔ cosetPushforward Λ x = 0 := by + change cosetMap Λ x = 0 ↔ _ + rw [← AddMonoidAlgebra.coeff_injective.eq_iff, AddMonoidAlgebra.coeff_zero] + rfl + +lemma monomial_sub_one_mem_cosetIdeal (Λ : AddSubgroup (Lattice k)) {γ : Lattice k} + (hγ : γ ∈ Λ) : AddMonoidAlgebra.single γ 1 - 1 ∈ cosetIdeal Λ := by + change cosetMap Λ (AddMonoidAlgebra.single γ 1 - 1) = 0 + rw [map_sub, map_one] + simp only [cosetMap, AddMonoidAlgebra.mapDomainAlgHom_apply, AddMonoidAlgebra.mapDomain_single] + have hh : QuotientAddGroup.mk' Λ γ = 0 := (QuotientAddGroup.eq_zero_iff γ).mpr hγ + rw [hh] + exact sub_self _ + +lemma quotient_nil_augmentation (N : ℕ) : + (Ideal.map (Ideal.Quotient.mk (augmentationIdeal ^ N)) + (augmentationIdeal : Ideal (LatticeRing k))) ^ N = ⊥ := by + rw [← Ideal.map_pow, Ideal.map_quotient_self] + +lemma finite_order_logs (N : ℕ) : + ∃ f : Lattice k →+ (LatticeRing k ⧸ augmentationIdeal ^ N), + (∀ γ, f γ ∈ Ideal.map (Ideal.Quotient.mk (augmentationIdeal ^ N)) augmentationIdeal) ∧ + (∀ γ, IsNilpotent.exp (f γ) = + (Ideal.Quotient.mk (augmentationIdeal ^ N)) (AddMonoidAlgebra.single γ 1)) := by + let q := Ideal.Quotient.mkₐ ℚ ((augmentationIdeal : Ideal (LatticeRing k)) ^ N) + let χ : Multiplicative (Lattice k) →* (LatticeRing k ⧸ augmentationIdeal ^ N) := + q.toMonoidHom.comp (AddMonoidAlgebra.of ℚ (Lattice k)) + have hχ : ∀ γ : Lattice k, χ (Multiplicative.ofAdd γ) - 1 ∈ + Ideal.map (Ideal.Quotient.mk (augmentationIdeal ^ N)) augmentationIdeal := by + intro γ + have h := Ideal.mem_map_of_mem (Ideal.Quotient.mk (augmentationIdeal ^ N)) + (monomial_sub_one_mem γ) + simpa [χ, q, AddMonoidAlgebra.of_apply, map_sub] using h + refine ⟨characterLogHom (quotient_nil_augmentation N) χ hχ, ?_, ?_⟩ + · intro γ + exact characterLog_mem (quotient_nil_augmentation N) χ hχ γ + · intro γ + simpa [χ, q, AddMonoidAlgebra.of_apply, characterLogHom] using + characterLog_exp (quotient_nil_augmentation N) χ hχ γ + +lemma log_quadratic_mod_coset (N : ℕ) (f : Lattice k →+ (LatticeRing k ⧸ augmentationIdeal ^ N)) + (hf : ∀ γ, f γ ∈ Ideal.map (Ideal.Quotient.mk (augmentationIdeal ^ N)) augmentationIdeal) + (hfexp : ∀ γ, IsNilpotent.exp (f γ) = + (Ideal.Quotient.mk (augmentationIdeal ^ N)) (AddMonoidAlgebra.single γ 1)) + (Λ : AddSubgroup (Lattice k)) (C : Matrix (Fin k) (Fin k) ℚ) + (hC : quotientTensor Λ (matrixTensor C) = 0) + (l : Fin k → LatticeRing k) + (hl : ∀ a, (Ideal.Quotient.mk (augmentationIdeal ^ N)) (l a) = f (Pi.single a 1)) : + quadraticStencil C l ∈ cosetIdeal Λ ⊔ augmentationIdeal ^ N := by + let J := cosetIdeal Λ ⊔ (augmentationIdeal : Ideal (LatticeRing k)) ^ N + let ψ := Ideal.Quotient.factorₐ ℚ (show augmentationIdeal ^ N ≤ J from le_sup_right) + let g := ψ.toLinearMap.comp (rationalExtension f) + have hgγ : ∀ γ ∈ Λ, g (rationalize γ) = 0 := by + intro γ hγ + have hn := nilpotent_of_mem_nil_ideal (quotient_nil_augmentation N) (hf γ) + change ψ (rationalExtension f (rationalize γ)) = 0 + rw [show rationalize γ = (fun j => (γ j : ℚ)) from rfl, rationalExtension_lattice] + apply (nil_exp_eq_one_iff (hn.map ψ)).mp + rw [← hn.map_exp ψ, hfexp] + change (Ideal.Quotient.mk J) (AddMonoidAlgebra.single γ 1) = 1 + have hm : AddMonoidAlgebra.single γ (1 : ℚ) - 1 ∈ J := + Ideal.mem_sup_left (monomial_sub_one_mem_cosetIdeal Λ hγ) + have hz : (Ideal.Quotient.mk J) (AddMonoidAlgebra.single γ 1 - 1) = 0 := + Ideal.Quotient.eq_zero_iff_mem.mpr hm + simpa only [map_sub, map_one, sub_eq_zero] using hz + have hg : latticeSpan Λ ≤ LinearMap.ker g := by + apply Submodule.span_le.mpr + rintro _ ⟨γ, hγ, rfl⟩ + exact hgγ γ hγ + have hquad := tensor_quotient_quadratic (latticeSpan Λ) C g hg hC + apply Ideal.Quotient.eq_zero_iff_mem.mp + change (Ideal.Quotient.mkₐ ℚ J) (quadraticStencil C l) = 0 + have hlj : ∀ a, (Ideal.Quotient.mkₐ ℚ J) (l a) = g (Pi.single a 1) := by + intro a + change ψ ((Ideal.Quotient.mk (augmentationIdeal ^ N)) (l a)) = + ψ (rationalExtension f (Pi.single a 1)) + rw [hl, rationalExtension_single] + simp only [quadraticStencil, map_smul, map_sum, map_mul, hlj, hquad, smul_zero] + +lemma finite_order_log_lifts (N : ℕ) (hN : 2 ≤ N) + (f : Lattice k →+ (LatticeRing k ⧸ augmentationIdeal ^ N)) + (hf : ∀ γ, f γ ∈ Ideal.map (Ideal.Quotient.mk (augmentationIdeal ^ N)) augmentationIdeal) + (hfexp : ∀ γ, IsNilpotent.exp (f γ) = + (Ideal.Quotient.mk (augmentationIdeal ^ N)) (AddMonoidAlgebra.single γ 1)) : + ∃ l : Fin k → LatticeRing k, + (∀ a, (Ideal.Quotient.mk (augmentationIdeal ^ N)) (l a) = f (Pi.single a 1)) ∧ + (∀ a, mass (l a) = 0) ∧ + (∀ a b, firstMoment (l a) b = if a = b then 1 else 0) := by + classical + let I : Ideal (LatticeRing k) := augmentationIdeal + let q := Ideal.Quotient.mk (I ^ N) + let M := Ideal.map q I + have hex : ∀ a : Fin k, ∃ x ∈ I, q x = f (Pi.single a 1) := by + intro a + exact (Ideal.mem_map_iff_of_surjective q (Ideal.Quotient.mk_surjective)).mp (hf _) + choose l hlI hl using hex + refine ⟨l, hl, fun a => (mem_augmentationIdeal _).mp (hlI a), ?_⟩ + have hker : RingHom.ker q = I ^ N := by + ext x + exact Ideal.Quotient.eq_zero_iff_mem + have hpre : Ideal.comap q (Ideal.map q (I ^ 2)) = I ^ 2 := by + rw [Ideal.comap_map_of_surjective' q Ideal.Quotient.mk_surjective, hker] + exact sup_eq_left.mpr (Ideal.pow_le_pow_right hN) + intro a b + let z : LatticeRing k := AddMonoidAlgebra.single (Pi.single a 1) 1 - 1 + have hdiff : l a - z ∈ I ^ 2 := by + rw [← hpre] + change q (l a - z) ∈ Ideal.map q (I ^ 2) + rw [Ideal.map_pow] + have hn := nilpotent_of_mem_nil_ideal (quotient_nil_augmentation N) (hf (Pi.single a 1)) + have hr : IsNilpotent.exp (f (Pi.single a 1)) - 1 - f (Pi.single a 1) ∈ M ^ 2 := + nil_exp_sub_one_sub_mem hn (hf _) + have hre : q (l a - z) = -(IsNilpotent.exp (f (Pi.single a 1)) - 1 - f (Pi.single a 1)) := by + rw [hfexp, map_sub, hl] + dsimp [z, q] + rw [map_sub, map_one] + ring + rw [hre] + exact (M ^ 2).neg_mem hr + have hj := augmentation_sq_le_jetOne hdiff + have hjb := hj.2 b + simp only [firstMoment_sub, sub_eq_zero] at hjb + rw [hjb] + simp [z, Pi.single_apply, eq_comm] + +theorem finite_lattice_identity : FiniteLatticeIdentity := by + intro k s hk hs Λ C hCs hC + let I : Ideal (LatticeRing k) := augmentationIdeal + obtain ⟨n, hn⟩ := adic_intersection_lifting I (fun i => cosetIdeal (Λ i)) 3 + let N := n + 3 + obtain ⟨f, hf, hfexp⟩ := finite_order_logs (k := k) N + obtain ⟨l, hl, hm, hfirst⟩ := finite_order_log_lifts N (by omega) f hf hfexp + have hx : ∀ i, quadraticStencil C l ∈ cosetIdeal (Λ i) ⊔ I ^ n := by + intro i + apply (sup_le_sup_left (α := Ideal (LatticeRing k)) + (Ideal.pow_le_pow_right (show n ≤ N by omega)) (cosetIdeal (Λ i))) + exact log_quadratic_mod_coset N f hf hfexp (Λ i) C (hC i) l hl + obtain ⟨y, hy, hxy⟩ := hn (quadraticStencil C l) hx + have he := moments_eq_of_sub_mem_cube hxy + have hM := quadraticStencil_moments C hCs l hm hfirst + refine ⟨y, fun i => (mem_cosetIdeal_iff _ _).mp (hy i), ?_, ?_, ?_⟩ + · exact he.1.symm.trans hM.1 + · intro a + exact (he.2.1 a).symm.trans (hM.2.1 a) + · intro a b + exact (he.2.2 a b).symm.trans (hM.2.2 a b) + +end Construction + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Circle.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Circle.lean new file mode 100644 index 0000000000000000000000000000000000000000..adf383ee19a650c65c419ad47559b23da69d8034 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Circle.lean @@ -0,0 +1,40 @@ +import OAI.Combinatorics.EuclideanRamsey.CircleRows +import OAI.Combinatorics.EuclideanRamsey.CircleSpan +import OAI.Combinatorics.EuclideanRamsey.CircleExtension +import OAI.Combinatorics.EuclideanRamsey.Quadratic + +namespace OAI + +noncomputable section +namespace EuclideanRamsey.CircleConsequence + +/-- Every five-point subset of a circle is Ramsey. -/ +theorem five_circle_points_ramsey (a : Fin 5 → Space 2) + (ha : Function.Injective a) (c : Space 2) (r : ℝ) + (hc : ∀ i, dist (a i) c = r) : Ramsey a := by + exact spherical_quadraticIndependent_ramsey a (by decide) ha + (circle_five_affineSpan a ha c r hc) ⟨c, r, hc⟩ + (circle_five_rows_independent a ha c r hc) + +/-- Every nonempty set of at most five distinct circle points is Ramsey, +including singletons and zero-radius circles. -/ +theorem at_most_five_circle_points_ramsey {s : ℕ} (a : Fin s → Space 2) + (hs : 0 < s) (hs5 : s ≤ 5) (ha : Function.Injective a) + (hsphere : ∃ c : Space 2, ∃ r : ℝ, ∀ i, dist (a i) c = r) : Ramsey a := by + obtain ⟨c, r, hc⟩ := hsphere + have hr : 0 ≤ r := by + rw [← hc ⟨0, hs⟩] + exact dist_nonneg + by_cases hr0 : r = 0 + · exact zero_radius_ramsey a c (by simpa [hr0] using hc) + · have hrpos : 0 < r := lt_of_le_of_ne hr (Ne.symm hr0) + obtain ⟨b, hb, hbc, f, hf⟩ := extend_to_five a hs5 ha c r hrpos hc + have hramsey := ramsey_restrict b f (five_circle_points_ramsey b hb c r hbc) + have he : b ∘ f = a := funext hf + rwa [he] at hramsey + +end EuclideanRamsey.CircleConsequence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/CircleExtension.lean b/lean/OAI/Combinatorics/EuclideanRamsey/CircleExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..b93f79e61aa825da77625e8b761f1de285278fb0 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/CircleExtension.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.EuclideanRamsey.CircleGeometry +import Mathlib.Data.Set.Finite.Basic +import Mathlib.Data.Fintype.EquivFin + +namespace OAI +noncomputable section +namespace EuclideanRamsey.CircleConsequence + +/-- Rational parametrization of a genuine radius-r circle. -/ +def stereographic (c : Space 2) (r t : ℝ) : Space 2 := + c + r • WithLp.toLp 2 ![(1-t^2)/(1+t^2), (2*t)/(1+t^2)] + +theorem stereographic_recover (t : ℝ) : + ((2*t)/(1+t^2)) / (1 + (1-t^2)/(1+t^2)) = t := by + have hd : 1+t^2 ≠ 0 := by positivity + have he : 1 + (1-t^2)/(1+t^2) = 2/(1+t^2) := by field_simp; ring + rw [he, div_div] + field_simp + +theorem stereographic_injective (c : Space 2) (r : ℝ) (hr : 0 < r) : + Function.Injective (stereographic c r) := by + intro t u h + have h₀ := congrArg (fun p : Space 2 => p 0) h + have h₁ := congrArg (fun p : Space 2 => p 1) h + have hx : (1-t^2)/(1+t^2) = (1-u^2)/(1+u^2) := by + apply mul_left_cancel₀ (ne_of_gt hr) + apply add_left_cancel (a := c 0) + simpa only [stereographic, PiLp.add_apply, PiLp.smul_apply, PiLp.toLp_apply, + Matrix.cons_val_zero, smul_eq_mul] using h₀ + have hy : (2*t)/(1+t^2) = (2*u)/(1+u^2) := by + apply mul_left_cancel₀ (ne_of_gt hr) + apply add_left_cancel (a := c 1) + simpa only [stereographic, PiLp.add_apply, PiLp.smul_apply, PiLp.toLp_apply, + Matrix.cons_val_one, Matrix.cons_val_zero, smul_eq_mul] using h₁ + calc + t = ((2*t)/(1+t^2)) / (1 + (1-t^2)/(1+t^2)) := (stereographic_recover t).symm + _ = ((2*u)/(1+u^2)) / (1 + (1-u^2)/(1+u^2)) := by rw [hx, hy] + _ = u := stereographic_recover u + +theorem stereographic_on_circle (c : Space 2) (r t : ℝ) (hr : 0 < r) : + dist (stereographic c r t) c = r := by + have hd : 1+t^2 ≠ 0 := by positivity + have hs : ((1-t^2)/(1+t^2))^2 + ((2*t)/(1+t^2))^2 = 1 := by + field_simp + ring + have he : dist (stereographic c r t) c ^ 2 = r^2 := by + simp only [dist_eq_norm, stereographic, add_sub_cancel_left] + rw [norm_smul, mul_pow] + simp only [Real.norm_eq_abs, sq_abs, EuclideanSpace.norm_sq_eq, + Fin.sum_univ_two, Matrix.cons_val_zero, Matrix.cons_val_one, + Real.norm_eq_abs, sq_abs] + rw [hs, mul_one] + have hn : 0 ≤ dist (stereographic c r t) c := dist_nonneg + nlinarith + +theorem circle_infinite (c : Space 2) (r : ℝ) (hr : 0 < r) : + {p : Space 2 | dist p c = r}.Infinite := by + apply (Set.infinite_range_of_injective (stereographic_injective c r hr)).mono + rintro p ⟨t, rfl⟩ + exact stereographic_on_circle c r t hr + +/-- Extension adds actual distinct points on the same metric circle. -/ +theorem extend_to_five {s : ℕ} (a : Fin s → Space 2) + (hs : s ≤ 5) (ha : Function.Injective a) + (c : Space 2) (r : ℝ) (hr : 0 < r) + (hc : ∀ i, dist (a i) c = r) : + ∃ b : Fin 5 → Space 2, Function.Injective b ∧ + (∀ j, dist (b j) c = r) ∧ ∃ f : Fin s → Fin 5, ∀ i, b (f i) = a i := by + classical + let S : Finset (Space 2) := Finset.univ.image a + have hS : S.card = s := by simp [S, Finset.card_image_of_injective _ ha] + have hSc : ∀ p ∈ S, dist p c = r := by + intro p hp + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hp + exact hc i + obtain ⟨T, hTc, hT⟩ := (circle_infinite c r hr).exists_subset_card_eq 5 + have hST : 5 ≤ (S ∪ T).card := by + rw [← hT] + exact Finset.card_le_card Finset.subset_union_right + obtain ⟨U, hSU, hUst, hU⟩ := Finset.exists_subsuperset_card_eq + (Finset.subset_union_left : S ⊆ S ∪ T) (by omega : S.card ≤ 5) hST + let e : U ≃ Fin 5 := Finset.equivFinOfCardEq hU + let b : Fin 5 → Space 2 := fun j => (e.symm j).val + refine ⟨b, ?_, ?_, ?_⟩ + · intro i j hij + exact e.symm.injective (Subtype.ext hij) + · intro j + have hj : b j ∈ S ∪ T := hUst (e.symm j).property + rcases Finset.mem_union.mp hj with hj | hj + · exact hSc _ hj + · exact hTc hj + · let f : Fin s → Fin 5 := fun i => e ⟨a i, hSU (by simp [S])⟩ + refine ⟨f, ?_⟩ + intro i + simp [b, f] +end EuclideanRamsey.CircleConsequence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/CircleGeometry.lean b/lean/OAI/Combinatorics/EuclideanRamsey/CircleGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fb8afc4d37558653dd693e11138cf3f702d0976 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/CircleGeometry.lean @@ -0,0 +1,109 @@ +import OAI.Combinatorics.EuclideanRamsey.Model + +namespace OAI + +noncomputable section +namespace EuclideanRamsey.CircleConsequence + +/-- Three points on a real circle cannot occupy three distinct parameters +on a secant. No positive-radius assumption is needed. -/ +theorem circle_parameter_eq_zero_or_one + (x₀ x₁ y₀ y₁ c₀ c₁ R t : ℝ) + (hx : (x₀-c₀)^2 + (x₁-c₁)^2 = R) + (hy : (y₀-c₀)^2 + (y₁-c₁)^2 = R) + (hz : (x₀+t*(y₀-x₀)-c₀)^2 + (x₁+t*(y₁-x₁)-c₁)^2 = R) + (hxy : x₀ ≠ y₀ ∨ x₁ ≠ y₁) : t = 0 ∨ t = 1 := by + have hnorm : (y₀-x₀)^2 + (y₁-x₁)^2 ≠ 0 := by + intro h + have h₀ : y₀-x₀ = 0 := by nlinarith [sq_nonneg (y₁-x₁)] + have h₁ : y₁-x₁ = 0 := by nlinarith [sq_nonneg (y₀-x₀)] + rcases hxy with hxy | hxy <;> apply hxy <;> linarith + have hprod : t * (t-1) * ((y₀-x₀)^2 + (y₁-x₁)^2) = 0 := by + linear_combination hz - (1-t)*hx - t*hy + rcases mul_eq_zero.mp ((mul_eq_zero.mp hprod).resolve_right hnorm) with h | h + · exact Or.inl h + · exact Or.inr (sub_eq_zero.mp h) + +/-- The determinant of a secant line is nonzero at a third distinct +point on the same circle. Distinctness excludes radius zero. -/ +theorem secant_nonzero + (x₀ x₁ y₀ y₁ z₀ z₁ c₀ c₁ R : ℝ) + (hx : (x₀-c₀)^2 + (x₁-c₁)^2 = R) + (hy : (y₀-c₀)^2 + (y₁-c₁)^2 = R) + (hz : (z₀-c₀)^2 + (z₁-c₁)^2 = R) + (hxy : x₀ ≠ y₀ ∨ x₁ ≠ y₁) + (hxz : x₀ ≠ z₀ ∨ x₁ ≠ z₁) + (hyz : y₀ ≠ z₀ ∨ y₁ ≠ z₁) : + (y₀-x₀)*(z₁-x₁) - (y₁-x₁)*(z₀-x₀) ≠ 0 := by + intro hdet + by_cases hdx : y₀-x₀ = 0 + · have hdy : y₁-x₁ ≠ 0 := by + intro hdy + rcases hxy with hxy | hxy <;> apply hxy <;> linarith + have hzx : z₀ = x₀ := by + have : (y₁-x₁)*(z₀-x₀) = 0 := by rw [hdx] at hdet; nlinarith + have := (mul_eq_zero.mp this).resolve_left hdy + linarith + let t := (z₁-x₁)/(y₁-x₁) + have ht : x₁+t*(y₁-x₁) = z₁ := by dsimp [t]; field_simp; ring + have htx : x₀+t*(y₀-x₀) = z₀ := by rw [hdx]; simp [hzx] + have he := circle_parameter_eq_zero_or_one x₀ x₁ y₀ y₁ c₀ c₁ R t hx hy + (by rw [ht, htx]; exact hz) hxy + rcases he with he | he + · rcases hxz with h | h <;> apply h <;> simp_all + · rcases hyz with h | h + · apply h + calc + y₀ = x₀ := sub_eq_zero.mp hdx + _ = z₀ := hzx.symm + · apply h + simpa [he] using ht + · let t := (z₀-x₀)/(y₀-x₀) + have ht : x₀+t*(y₀-x₀) = z₀ := by dsimp [t]; field_simp; ring + have hty : x₁+t*(y₁-x₁) = z₁ := by + dsimp [t] + apply (mul_right_cancel₀ hdx) + field_simp + nlinarith [hdet] + have he := circle_parameter_eq_zero_or_one x₀ x₁ y₀ y₁ c₀ c₁ R t hx hy + (by rw [ht, hty]; exact hz) hxy + rcases he with he | he + · rcases hxz with h | h <;> apply h <;> simp_all + · rcases hyz with h | h <;> apply h <;> simp_all + +/-- Restriction of a Ramsey configuration preserves its distances. -/ +theorem ramsey_restrict {s t d : ℕ} (a : Fin t → Space d) + (f : Fin s → Fin t) (ha : Ramsey a) : Ramsey (a ∘ f) := by + intro r hr + obtain ⟨D, hD, h⟩ := ha r hr + refine ⟨D, hD, ?_⟩ + intro c + obtain ⟨b, hb, k, hk⟩ := h c + exact ⟨b ∘ f, fun i j => hb (f i) (f j), k, fun i => hk (f i)⟩ + +/-- A circle of zero radius is a singleton; repeated labels are allowed. -/ +theorem zero_radius_ramsey {s : ℕ} (a : Fin s → Space 2) + (c : Space 2) (h : ∀ i, dist (a i) c = 0) : Ramsey a := by + intro r hr + refine ⟨1, by omega, ?_⟩ + intro coloring + refine ⟨fun _ => 0, ?_, coloring 0, fun _ => rfl⟩ + intro i j + have hi : a i = c := dist_eq_zero.mp (h i) + have hj : a j = c := dist_eq_zero.mp (h j) + simp [hi, hj] + +/-- The metric circle equation implies the scalar coordinate equation. -/ +theorem circle_coordinates {s : ℕ} (a : Fin s → Space 2) + (c : Space 2) (r : ℝ) (hc : ∀ i, dist (a i) c = r) : + ∀ i, (a i 0-c 0)^2 + (a i 1-c 1)^2 = r^2 := by + intro i + have h := congrArg (fun x : ℝ => x^2) (hc i) + simpa [dist_eq_norm, EuclideanSpace.norm_sq_eq, Fin.sum_univ_two, + Real.norm_eq_abs, sq_abs] using h + +end EuclideanRamsey.CircleConsequence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/CircleInterpolation.lean b/lean/OAI/Combinatorics/EuclideanRamsey/CircleInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c9b972ab5a25503a0599e73169b6319e0ac4cd6 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/CircleInterpolation.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.EuclideanRamsey.CircleGeometry + +namespace OAI + +/- The secant equations and quadratic isolators have coefficients in the coordinate field. -/ +noncomputable section +namespace EuclideanRamsey.CircleConsequence + +def secantRow {s : ℕ} (a : Fin s → Space 2) (i j : Fin s) : + Option (Fin 2) → Coeff a + | none => coordinate a i 0 * coordinate a j 1 - coordinate a j 0 * coordinate a i 1 + | some k => if k = 0 then coordinate a i 1 - coordinate a j 1 + else coordinate a j 0 - coordinate a i 0 + +def secantValue {s : ℕ} (a : Fin s → Space 2) (i j k : Fin s) : Coeff a := + (coordinate a j 0-coordinate a i 0)*(coordinate a k 1-coordinate a i 1) - + (coordinate a j 1-coordinate a i 1)*(coordinate a k 0-coordinate a i 0) + +theorem secantRow_eval {s : ℕ} (a : Fin s → Space 2) (i j k : Fin s) : + (∑ α : Option (Fin 2), secantRow a i j α * augmented a k α) = + secantValue a i j k := by + simp [secantRow, secantValue, augmented, Fin.sum_univ_two] + ring + +def pairedSecantMatrix {s : ℕ} (a : Fin s → Space 2) + (i j k l : Fin s) : Matrix (Option (Fin 2)) (Option (Fin 2)) (Coeff a) := + fun α β => secantRow a i j α * secantRow a k l β + +theorem pairedSecantMatrix_eval {s : ℕ} (a : Fin s → Space 2) + (i j k l m : Fin s) : + (∑ α : Option (Fin 2), ∑ β : Option (Fin 2), + pairedSecantMatrix a i j k l α β * augmented a m α * augmented a m β) = + secantValue a i j m * secantValue a k l m := by + rw [← secantRow_eval a i j m, ← secantRow_eval a k l m] + rw [Finset.sum_mul] + simp only [pairedSecantMatrix, Finset.mul_sum] + apply Finset.sum_congr rfl + intro α hα + apply Finset.sum_congr rfl + intro β hβ + ring + +theorem pairedSecantMatrix_vanishes {s : ℕ} (a : Fin s → Space 2) + (i j k l m : Fin s) (hm : m = i ∨ m = j ∨ m = k ∨ m = l) : + (∑ α : Option (Fin 2), ∑ β : Option (Fin 2), + pairedSecantMatrix a i j k l α β * augmented a m α * augmented a m β) = 0 := by + rw [pairedSecantMatrix_eval] + rcases hm with rfl | rfl | rfl | rfl <;> dsimp only [secantValue] <;> ring + +/-- Nonzero evaluation follows from actual planar circle equations. -/ +theorem secantValue_ne_zero {s : ℕ} (a : Fin s → Space 2) + (ha : Function.Injective a) (c : Space 2) (R : ℝ) + (hc : ∀ m, (a m 0-c 0)^2 + (a m 1-c 1)^2 = R) + (i j k : Fin s) (hij : i ≠ j) (hik : i ≠ k) (hjk : j ≠ k) : + secantValue a i j k ≠ 0 := by + have different (u v : Fin s) (huv : u ≠ v) : + a u 0 ≠ a v 0 ∨ a u 1 ≠ a v 1 := by + by_contra h + push Not at h + apply huv + apply ha + ext q + fin_cases q <;> simp_all + have h := secant_nonzero (a i 0) (a i 1) (a j 0) (a j 1) + (a k 0) (a k 1) (c 0) (c 1) R (hc i) (hc j) (hc k) + (different i j hij) (different i k hik) (different j k hjk) + intro hz + apply h + have he := congrArg (fun z : Coeff a => (z : ℝ)) hz + simpa [secantValue, coordinate] using he + +/-- The five-point isolator is a concrete coordinate-field matrix. +The permutation is just a labeling, with e 0 the point being isolated. -/ +theorem five_point_isolator (a : Fin 5 → Space 2) + (ha : Function.Injective a) (c : Space 2) (R : ℝ) + (hc : ∀ m, (a m 0-c 0)^2 + (a m 1-c 1)^2 = R) + (e : Equiv.Perm (Fin 5)) : + ∃ M : Matrix (Option (Fin 2)) (Option (Fin 2)) (Coeff a), + (∀ m, m ≠ e 0 → + (∑ α : Option (Fin 2), ∑ β : Option (Fin 2), + M α β * augmented a m α * augmented a m β) = 0) ∧ + (∑ α : Option (Fin 2), ∑ β : Option (Fin 2), + M α β * augmented a (e 0) α * augmented a (e 0) β) ≠ 0 := by + refine ⟨pairedSecantMatrix a (e 1) (e 2) (e 3) (e 4), ?_, ?_⟩ + · intro m hm + apply pairedSecantMatrix_vanishes + have hem : e (e.symm m) = m := e.apply_symm_apply m + have hn : e.symm m ≠ 0 := by intro h; apply hm; simpa [h] using hem.symm + generalize h : e.symm m = k at hem hn + fin_cases k <;> simp_all + · rw [pairedSecantMatrix_eval] + apply mul_ne_zero + · apply secantValue_ne_zero a ha c R hc <;> exact e.injective.ne (by decide) + · apply secantValue_ne_zero a ha c R hc <;> exact e.injective.ne (by decide) + +end EuclideanRamsey.CircleConsequence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/CircleRows.lean b/lean/OAI/Combinatorics/EuclideanRamsey/CircleRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..8711645ff53e0e4c9316d8e2572cacb88e20584c --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/CircleRows.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.EuclideanRamsey.CircleInterpolation +import Mathlib.LinearAlgebra.LinearIndependent.Defs + +namespace OAI +noncomputable section +namespace EuclideanRamsey.CircleConsequence + +abbrev QIndex := Option (Fin 2) × Option (Fin 2) +def quadraticRow (a : Fin 5 → Space 2) (i : Fin 5) (q : QIndex) : Coeff a := + augmented a i q.1 * augmented a i q.2 + +/-- Normalized coefficients for quadratic interpolation at five circle points. -/ +theorem normalized_isolators (a : Fin 5 → Space 2) (ha : Function.Injective a) + (c : Space 2) (r : ℝ) (hc : ∀ i, dist (a i) c = r) : + ∃ L : Fin 5 → QIndex → Coeff a, + ∀ i j, ∑ q, L i q * quadraticRow a j q = if j = i then 1 else 0 := by + classical + have hcoord := circle_coordinates a c r hc + have hiso (i : Fin 5) : ∃ M : QIndex → Coeff a, + (∀ j, j ≠ i → ∑ q, M q * quadraticRow a j q = 0) ∧ + (∑ q, M q * quadraticRow a i q) ≠ 0 := by + obtain ⟨M, hM, hMi⟩ := five_point_isolator a ha c (r^2) hcoord (Equiv.swap 0 i) + refine ⟨fun q => M q.1 q.2, ?_, ?_⟩ + · intro j hj + simpa [quadraticRow, Fintype.sum_prod_type, mul_assoc] using hM j (by simpa using hj) + · simpa [quadraticRow, Fintype.sum_prod_type, mul_assoc] using hMi + choose M hM hMi using hiso + refine ⟨fun i q => (∑ t, M i t * quadraticRow a i t)⁻¹ * M i q, ?_⟩ + intro i j + simp_rw [mul_assoc, ← Finset.mul_sum] + by_cases hji : j = i + · subst j + simp [hMi] + · simp [hji, hM i j hji] + +/-- A concrete right inverse to quadratic evaluation. -/ +theorem quadratic_evaluation_surjective (a : Fin 5 → Space 2) + (ha : Function.Injective a) (c : Space 2) (r : ℝ) + (hc : ∀ i, dist (a i) c = r) : + ∀ values : Fin 5 → Coeff a, ∃ coeff : QIndex → Coeff a, + ∀ j, ∑ q, coeff q * quadraticRow a j q = values j := by + classical + obtain ⟨L, hL⟩ := normalized_isolators a ha c r hc + intro values + refine ⟨fun q => ∑ i, values i * L i q, ?_⟩ + intro j + simp_rw [Finset.sum_mul] + rw [Finset.sum_comm] + simp_rw [mul_assoc, ← Finset.mul_sum, hL] + simp + +/-- The quadratic evaluation rows are independent because their dual rows isolate them. -/ +theorem circle_five_rows_independent (a : Fin 5 → Space 2) + (ha : Function.Injective a) (c : Space 2) (r : ℝ) + (hc : ∀ i, dist (a i) c = r) : + LinearIndependent (Coeff a) (fun i : Fin 5 => fun q : QIndex => + augmented a i q.1 * augmented a i q.2) := by + classical + obtain ⟨L, hL⟩ := normalized_isolators a ha c r hc + rw [Fintype.linearIndependent_iff] + intro g hg i + have hzero (q : QIndex) : ∑ j, g j * quadraticRow a j q = 0 := by + simpa [quadraticRow] using congrFun hg q + have hpair : ∑ q, L i q * (∑ j, g j * quadraticRow a j q) = 0 := by + simp [hzero] + have hcalc : (∑ q, L i q * (∑ j, g j * quadraticRow a j q)) = g i := by + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + calc + _ = ∑ j, g j * (∑ q, L i q * quadraticRow a j q) := by + apply Finset.sum_congr rfl + intro j hj + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro q hq + ring + _ = g i := by simp [hL] + exact hcalc.symm.trans hpair +end EuclideanRamsey.CircleConsequence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/CircleSpan.lean b/lean/OAI/Combinatorics/EuclideanRamsey/CircleSpan.lean new file mode 100644 index 0000000000000000000000000000000000000000..58547eba81c460f2405c646eae78d218759901bc --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/CircleSpan.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.EuclideanRamsey.CircleInterpolation + +namespace OAI +noncomputable section +namespace EuclideanRamsey.CircleConsequence + +/-- Three actual distinct circle points already affinely span the plane. +The inverse two-by-two determinant is written explicitly. -/ +theorem circle_five_affineSpan (a : Fin 5 → Space 2) + (ha : Function.Injective a) (c : Space 2) (r : ℝ) + (hc : ∀ i, dist (a i) c = r) : affineSpan ℝ (Set.range a) = ⊤ := by + classical + let A := affineSpan ℝ (Set.range a) + have hp (i : Fin 5) : a i ∈ A := mem_affineSpan ℝ (Set.mem_range_self i) + let u := a 1 - a 0 + let v := a 2 - a 0 + let D : ℝ := u 0 * v 1 - v 0 * u 1 + have hfield := secantValue_ne_zero a ha c (r^2) (circle_coordinates a c r hc) + 0 1 2 (by decide) (by decide) (by decide) + have hD : D ≠ 0 := by + intro h + apply hfield + apply Subtype.ext + simpa [D, u, v, secantValue, coordinate, mul_comm] using h + have hu : u ∈ A.direction := by + simpa [u, vsub_eq_sub] using AffineSubspace.vsub_mem_direction (hp 1) (hp 0) + have hv : v ∈ A.direction := by + simpa [v, vsub_eq_sub] using AffineSubspace.vsub_mem_direction (hp 2) (hp 0) + apply top_unique + intro x hx + let w := x - a 0 + let α : ℝ := (w 0 * v 1 - v 0 * w 1) / D + let β : ℝ := (u 0 * w 1 - w 0 * u 1) / D + have hcomb : α • u + β • v = w := by + ext j + fin_cases j <;> + simp only [PiLp.add_apply, PiLp.smul_apply, smul_eq_mul] <;> + dsimp [α, β] <;> + field_simp [hD] <;> + dsimp [D] <;> ring + have hm : α • u + β • v ∈ A.direction := + A.direction.add_mem (A.direction.smul_mem α hu) (A.direction.smul_mem β hv) + have he := AffineSubspace.vadd_mem_of_mem_direction hm (hp 0) + simpa [hcomb, w, vadd_eq_add] using he +end EuclideanRamsey.CircleConsequence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/ColoringCompactness.lean b/lean/OAI/Combinatorics/EuclideanRamsey/ColoringCompactness.lean new file mode 100644 index 0000000000000000000000000000000000000000..1efb84c9d90195ce6f3870fef705127b99fb92ae --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/ColoringCompactness.lean @@ -0,0 +1,190 @@ +import OAI.Combinatorics.EuclideanRamsey.CornerGroup + +namespace OAI + +universe uModule uColor + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace +open Filter +open Set + +namespace EuclideanRamsey +open Filter +open scoped BigOperators +attribute [local instance] Ultrafilter.mul Ultrafilter.semigroup + +lemma exists_ultra_color {M : Type uModule} {κ : Type uColor} [Finite κ] (U : Ultrafilter M) (c : M → κ) : + ∃ k,{x | c x=k}∈U := by + apply Ultrafilter.eventually_exists_iff.mp + exact Filter.Eventually.of_forall (fun x => ⟨c x,rfl⟩) +noncomputable def ultraColor {M : Type uModule} {κ : Type uColor} [Finite κ] (c : M → κ) (U : Ultrafilter M) : κ := + (exists_ultra_color U c).choose +lemma ultraColor_spec {M : Type uModule} {κ : Type uColor} [Finite κ] (c : M → κ) (U : Ultrafilter M) : + {x | c x=ultraColor c U}∈U := (exists_ultra_color U c).choose_spec + +lemma exists_corner_map : ∃ (p : Ultrafilter Strings) (Ψ : LetterGroup →ₙ* Ultrafilter Strings), + ∀ z,Ψ (FreeGroup.of z)=p*(pure (FreeMonoid.of z))*p := by + let := ultrafilterMonoid (M:=Strings) + obtain ⟨p,hp,hi⟩ := exists_group_corner (S:=Ultrafilter Strings) Ultrafilter.continuous_mul_left + let := Corner.group hp hi + let letter (z : FiniteEuclidean) : Corner p := + ⟨p*(pure (FreeMonoid.of z))*p,by + constructor + · simp only [← mul_assoc,hp] + · simp only [mul_assoc,hp]⟩ + let ψ : LetterGroup →* Corner p := FreeGroup.lift letter + let v : Corner p →ₙ* Ultrafilter Strings := { toFun := Subtype.val, map_mul' _ _ := rfl } + refine ⟨p,v.comp ψ.toMulHom,?_⟩ + intro z + change (ψ (FreeGroup.of z)).val=_ + exact congrArg (fun x : Corner p => x.val) (FreeGroup.lift_apply_of (f:=letter) (x:=z)) + +theorem paths_monochromatic {s : ℕ} (a : Fin s → FiniteEuclidean) + (hpaths : ∀ n : ℕ,1 ≤ n → ∃ w lmb μ,Path a w lmb ∧ Path a w μ ∧ + 0 < lmb ∧ μ/lmb < 1/(n:ℝ)) + {κ : Type uColor} [Finite κ] (c : FiniteEuclidean → κ) : + ∃ b : Fin s → FiniteEuclidean,(∀ i j,‖b i-b j‖=‖a i-a j‖) ∧ + ∃ k : κ,∀ i,c (b i)=k := by + classical + let := ultrafilterMonoid (M:=Strings) + obtain ⟨β,hβ,hHJ⟩ := Combinatorics.Line.exists_mono_in_high_dimension (Fin s) κ + let := hβ + obtain ⟨w,lmb,μ,hp,hm,hlmb,hratio⟩ := hpaths (Fintype.card β+1) (by omega) + obtain ⟨W,hW⟩ := synchronize_paths (Fintype.card β+1) (by omega) hp hm hlmb hratio + obtain ⟨p,Ψ,hgen⟩ := exists_corner_map + let coloring : Strings → κ := fun x => c (FiniteEuclidean.flatten x.toList) + let L : List β := Finset.univ.toList + let C : (β → Fin s) → κ := fun x => ultraColor coloring ((L.map (fun j => Ψ (W (x j)))).prod) + obtain ⟨line,k,hline⟩ := hHJ C + let S : Finset β := Finset.univ.filter (fun j => line.idxFun j=none) + let t := S.card + have ht : 1 ≤ t := by + apply Finset.card_pos.mpr + obtain ⟨j,hj⟩ := line.proper + exact ⟨j,by simp [S,hj]⟩ + have htn : t ≤ Fintype.card β+1 := le_trans (Finset.card_le_univ S) (Nat.le_succ _) + obtain ⟨qs,hqs,hqe⟩ := (hW t ht htn).expand Ψ p hgen + let q (j : β) : List (UltraColumn (Fin s) Strings) := + (line.idxFun j).elim qs (fun i => [.common (Ψ (W i))]) + let u (j : β) : ℝ := if line.idxFun j=none then 1/(t:ℝ) else 0 + have hcol : ∀ j∈L,ColumnPath a (q j) (u j) := by + intro j _ + cases he : line.idxFun j with + | none => simpa [q,u,he] using hqs + | some i => simpa [q,u,he] using (ColumnPath.common (a:=a) (Ψ (W i))) + have hprod : ∀ j∈L,∀ i,((q j).map (fun q => q.value i)).prod=Ψ (W (line i j)) := by + intro j _ i + cases he : line.idxFun j with + | none => simpa [q,he,Combinatorics.Line.coe_apply] using hqe i + | some x => simp [q,he,Combinatorics.Line.coe_apply,UltraColumn.value] + have hweight : (L.map u).sum=1 := by + have he : (L.map u).sum=∑ j,u j := by + simp [L] + rw [he] + change (∑ j,if line.idxFun j=none then 1/(t:ℝ) else 0)=1 + rw [← Finset.sum_filter] + change (∑ j∈S,1/(t:ℝ))=1 + simp only [Finset.sum_const,nsmul_eq_mul] + change (t:ℝ)*(1/(t:ℝ))=1 + exact mul_one_div_cancel (Nat.cast_ne_zero.mpr (by omega)) + have hfull : ColumnPath a ((L.map q).flatten) 1 := by + convert ColumnPath.flatten L q u hcol using 1 + exact hweight.symm + have hmem : ∀ i,{x : Strings | coloring x=k}∈ + ((((L.map q).flatten).map (fun q => q.value i)).prod : Ultrafilter Strings) := by + intro i + rw [flattened_ultra_product L q (fun j i => Ψ (W (line i j))) hprod i] + have hk := ultraColor_spec coloring ((L.map (fun j => Ψ (W (line i j)))).prod) + change {x | coloring x=C (line i)}∈_ at hk + rwa [hline i] at hk + obtain ⟨xs,hxs,hxB⟩ := UltraColumn.simultaneously_realize ((L.map q).flatten) + (fun _ => {x : Strings | coloring x=k}) hmem + let b (i : Fin s) := FiniteEuclidean.flatten ((xs.map (fun x => x i)).prod : Strings).toList + refine ⟨b,(hfull.realizes xs hxs).congruent,k,?_⟩ + exact hxB +end EuclideanRamsey +namespace EuclideanRamsey +namespace FiniteEuclidean +open Filter +open scoped BigOperators +noncomputable def truncate (d : ℕ) (x : FiniteEuclidean) : EuclideanSpace ℝ (Fin d) := + WithLp.toLp 2 (fun i => coords x i) + +lemma embed_truncate (x : FiniteEuclidean) (d : ℕ) + (h : ∀ n∈(coords x).support,n hn (h n hm))).symm + +lemma eventually_embed_truncate (x : FiniteEuclidean) : + ∀ᶠ d : ℕ in atTop,embed (d+1) (truncate (d+1) x)=x := by + filter_upwards [eventually_ge_atTop ((coords x).support.sup id)] with d hd + apply embed_truncate + intro n hn + have h := Finset.le_sup (f:=id) hn + dsimp only [id_eq] at h + omega +end FiniteEuclidean + +theorem finite_coloring_compactness {s : ℕ} (a : Fin s → FiniteEuclidean) (r : ℕ) + (h : ∀ c : FiniteEuclidean → Fin r,∃ b : Fin s → FiniteEuclidean, + (∀ i j,‖b i-b j‖=‖a i-a j‖) ∧ ∃ k : Fin r,∀ i,c (b i)=k) : + ∃ D : ℕ,1≤D ∧ ∀ c : EuclideanSpace ℝ (Fin D) → Fin r, + ∃ b : Fin s → EuclideanSpace ℝ (Fin D), + (∀ i j,‖b i-b j‖=‖a i-a j‖) ∧ ∃ k : Fin r,∀ i,c (b i)=k := by + classical + by_contra hbad + have hc : ∀ n : ℕ,∃ c : EuclideanSpace ℝ (Fin (n+1)) → Fin r, + ¬ ∃ b : Fin s → EuclideanSpace ℝ (Fin (n+1)), + (∀ i j,‖b i-b j‖=‖a i-a j‖) ∧ ∃ k : Fin r,∀ i,c (b i)=k := by + intro n + by_contra hh + push Not at hh + exact hbad ⟨n+1,by omega,hh⟩ + choose c hc using hc + let U : Ultrafilter ℕ := Ultrafilter.of Filter.atTop + let C : FiniteEuclidean → Fin r := fun z => ultraColor + (fun n => c n (FiniteEuclidean.truncate (n+1) z)) U + obtain ⟨b,hb,k,hbk⟩ := h C + have hcolor : ∀ᶠ n in (U : Filter ℕ),∀ i,c n (FiniteEuclidean.truncate (n+1) (b i))=k := by + apply Filter.eventually_all.mpr + intro i + have hh := ultraColor_spec (fun n => c n (FiniteEuclidean.truncate (n+1) (b i))) U + change ∀ᶠ n in (U : Filter ℕ),c n (FiniteEuclidean.truncate (n+1) (b i))=C (b i) at hh + rwa [hbk i] at hh + have he : ∀ᶠ n in (U : Filter ℕ),∀ i,FiniteEuclidean.embed (n+1) + (FiniteEuclidean.truncate (n+1) (b i))=b i := by + apply Filter.eventually_all.mpr + intro i + exact (Ultrafilter.of_le Filter.atTop) (FiniteEuclidean.eventually_embed_truncate (b i)) + obtain ⟨n,hn,hcol⟩ := (he.and hcolor).exists + apply hc n + refine ⟨fun i => FiniteEuclidean.truncate (n+1) (b i),?_,k,hcol⟩ + intro i j + rw [← (FiniteEuclidean.embed (n+1)).norm_map, map_sub,hn i,hn j,hb] +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Congruence.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Congruence.lean new file mode 100644 index 0000000000000000000000000000000000000000..93cf5eb8775df1dd3376bc9604be32ce012fd9fe --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Congruence.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.EuclideanRamsey.Model + +namespace OAI + +universe uIndex uDomain uCodomain + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace + +namespace EuclideanRamsey + +theorem singleton_ramsey {d : ℕ} (a : Fin 1 → Space d) : Ramsey a := by + intro r hr + refine ⟨1, by omega, ?_⟩ + intro c + refine ⟨fun _ => 0, ?_, c 0, ?_⟩ + · intro i j + have : i = j := Subsingleton.elim _ _ + simp [this] + · intro i + rfl + +theorem ramsey_congruent_iff {s d D : ℕ} {a : Fin s → Space d} + {b : Fin s → Space D} (h : Congruent a b) : Ramsey a ↔ Ramsey b := by + constructor + · intro ha r hr + obtain ⟨n, hn, hn'⟩ := ha r hr + refine ⟨n, hn, fun c => ?_⟩ + obtain ⟨x, hx, k, hk⟩ := hn' c + exact ⟨x, fun i j => (hx i j).trans (h i j).symm, k, hk⟩ + · intro ha r hr + obtain ⟨n, hn, hn'⟩ := ha r hr + refine ⟨n, hn, fun c => ?_⟩ + obtain ⟨x, hx, k, hk⟩ := hn' c + exact ⟨x, fun i j => (hx i j).trans (h i j), k, hk⟩ + +theorem linearIsometry_of_equal_gram {ι : Type uIndex} {E : Type uDomain} {F : Type uCodomain} [Fintype ι] + [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] + (x : ι → E) (y : ι → F) + (hspan : Submodule.span ℝ (Set.range x) = ⊤) + (hgram : ∀ i j, ⟪y i, y j⟫ = ⟪x i, x j⟫) : + ∃ Q : E →ₗᵢ[ℝ] F, ∀ i, Q (x i) = y i := by + classical + let A := Fintype.linearCombination ℝ x + let B := Fintype.linearCombination ℝ y + have hinner (c e : ι → ℝ) : ⟪B c, B e⟫ = ⟪A c, A e⟫ := by + simp only [A, B, Fintype.linearCombination_apply, sum_inner, inner_sum, + real_inner_smul_left, inner_smul_right, hgram] + have hnorm (c : ι → ℝ) : ‖B c‖ = ‖A c‖ := by + have h := hinner c c + rw [real_inner_self_eq_norm_sq, real_inner_self_eq_norm_sq] at h + nlinarith [norm_nonneg (B c), norm_nonneg (A c)] + have hsurj : LinearMap.range A = ⊤ := by + rw [Fintype.range_linearCombination] + exact hspan + obtain ⟨R, hR⟩ := A.exists_rightInverse_of_surjective hsurj + have hR' (z : E) : A (R z) = z := congrArg (fun L : E →ₗ[ℝ] E => L z) hR + let L : E →ₗ[ℝ] F := B.comp R + have hLnorm (z : E) : ‖L z‖ = ‖z‖ := by + change ‖B (R z)‖ = ‖z‖ + rw [hnorm, hR'] + have hfactor (c : ι → ℝ) : L (A c) = B c := by + have hzero : A (R (A c) - c) = 0 := by rw [map_sub, hR', sub_self] + have : B (R (A c) - c) = 0 := by + apply norm_eq_zero.mp + rw [hnorm, hzero, norm_zero] + simpa only [map_sub, L, LinearMap.comp_apply, sub_eq_zero] using this + refine ⟨⟨L, hLnorm⟩, ?_⟩ + intro i + simpa [A, B] using hfactor (Pi.single i 1) + +theorem congruent_linearIsometry {s d D : ℕ} (a : Fin s → Space d) + (b : Fin s → Space D) (i₀ : Fin s) + (hspan : affineSpan ℝ (Set.range a) = ⊤) (h : Congruent a b) : + ∃ Q : Space d →ₗᵢ[ℝ] Space D, ∃ t : Space D, ∀ i, b i = t + Q (a i) := by + have hv : vectorSpan ℝ (Set.range a) = ⊤ := by + simpa only [direction_affineSpan, AffineSubspace.direction_top] using + congrArg AffineSubspace.direction hspan + have hs : Submodule.span ℝ (Set.range fun i => a i - a i₀) = ⊤ := by + rw [vectorSpan_range_eq_span_range_vsub_right ℝ a i₀] at hv + exact hv + have hg (i j : Fin s) : ⟪b i - b i₀, b j - b i₀⟫ = + ⟪a i - a i₀, a j - a i₀⟫ := by + simp only [real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two, + sub_sub_sub_cancel_right, ← dist_eq_norm] + rw [h i i₀, h j i₀, h i j] + obtain ⟨Q, hQ⟩ := linearIsometry_of_equal_gram + (fun i => a i - a i₀) (fun i => b i - b i₀) hs hg + refine ⟨Q, b i₀ - Q (a i₀), fun i => ?_⟩ + have hi := hQ i + rw [map_sub] at hi + calc + b i = (b i - b i₀) + b i₀ := (sub_add_cancel _ _).symm + _ = (Q (a i) - Q (a i₀)) + b i₀ := by rw [hi] + _ = b i₀ - Q (a i₀) + Q (a i) := by abel + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/CornerGroup.lean b/lean/OAI/Combinatorics/EuclideanRamsey/CornerGroup.lean new file mode 100644 index 0000000000000000000000000000000000000000..12ac12d0262e1718688891f69b3e36033b2bfcd9 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/CornerGroup.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.EuclideanRamsey.PathSynchronization + +namespace OAI + +universe uSemigroup + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace +open Filter + +open Set +namespace EuclideanRamsey + +theorem exists_group_corner {S : Type uSemigroup} [Nonempty S] [Semigroup S] + [TopologicalSpace S] [CompactSpace S] [T2Space S] + (hc : ∀ y : S, Continuous (· * y)) : + ∃ p : S, p*p=p ∧ ∀ y : S, p*y=y → y*p=y → + ∃ v : S, p*v=v ∧ v*p=v ∧ v*y=p := by + let ideals : Set (Set S) := {N | IsClosed N ∧ N.Nonempty ∧ ∀ x y, y∈N → x*y∈N} + have hmin : ∃ N, Minimal (· ∈ ideals) N := by + refine zorn_superset _ fun c hcs hchain => ?_ + refine ⟨⋂₀ c, ⟨isClosed_sInter (fun N hN => (hcs hN).1), ?_, ?_⟩, + fun N hN => Set.sInter_subset_of_mem hN⟩ + · obtain rfl | hcn := c.eq_empty_or_nonempty + · simp + convert! @IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed + _ _ _ hcn.coe_sort ((↑) : c → Set S) ?_ ?_ ?_ ?_ + · exact Set.sInter_eq_iInter + · exact DirectedOn.directed_val (IsChain.directedOn hchain.symm) + · exact fun N => (hcs N.prop).2.1 + · exact fun N => (hcs N.prop).1.isCompact + · exact fun N => (hcs N.prop).1 + · intro x y hy + exact Set.mem_sInter.mpr fun N hN => (hcs hN).2.2 x y (Set.mem_sInter.mp hy N hN) + obtain ⟨N,hN⟩ := hmin + have hprincipal (y : S) (hy : y∈N) : Set.range (·*y) = N := by + apply hN.eq_of_subset + · refine ⟨isCompact_range (hc y) |>.isClosed, ⟨y*y,y,rfl⟩, ?_⟩ + rintro a _ ⟨b,rfl⟩ + exact ⟨a*b,mul_assoc a b y⟩ + · rintro _ ⟨a,rfl⟩ + exact hN.prop.2.2 a y hy + obtain ⟨p,hpN,hp⟩ := exists_idempotent_in_compact_subsemigroup hc N + hN.prop.2.1 hN.prop.1.isCompact (fun x _ y hy => hN.prop.2.2 x y hy) + refine ⟨p,hp,?_⟩ + intro y hpy hyp + have hyN : y∈N := hyp ▸ hN.prop.2.2 y p hpN + have hpr : p ∈ Set.range (·*y) := hprincipal y hyN ▸ hpN + obtain ⟨v,hv⟩ := hpr + change v*y=p at hv + refine ⟨p*v*p,?_,?_,?_⟩ + · simp only [← mul_assoc,hp] + · simp only [mul_assoc,hp] + · calc + (p*v*p)*y = p*v*(p*y) := mul_assoc _ _ _ + _ = p*(v*y) := by rw [hpy,mul_assoc] + _ = p := by rw [hv,hp] + +def Corner {S : Type uSemigroup} [Semigroup S] (p : S) := {x : S // p*x=x ∧ x*p=x} +namespace Corner +variable {S : Type uSemigroup} [Semigroup S] {p : S} +instance : Mul (Corner p) := ⟨fun x y => ⟨x.val*y.val, by + constructor + · rw [← mul_assoc,x.property.1] + · rw [mul_assoc,y.property.2]⟩⟩ +@[simp] lemma val_mul (x y : Corner p) : (x*y).val=x.val*y.val := rfl +instance : Semigroup (Corner p) where + mul_assoc _x _y _z := Subtype.ext (mul_assoc _ _ _) + +@[instance_reducible] def group (hp : p*p=p) + (hi : ∀ y : S, p*y=y → y*p=y → ∃ v : S,p*v=v ∧ v*p=v ∧ v*y=p) : Group (Corner p) := by + letI : One (Corner p) := ⟨⟨p,hp,hp⟩⟩ + letI : Inv (Corner p) := ⟨fun y => + ⟨(hi y.val y.property.1 y.property.2).choose, + (hi y.val y.property.1 y.property.2).choose_spec.1, + (hi y.val y.property.1 y.property.2).choose_spec.2.1⟩⟩ + exact Group.ofLeftAxioms (fun x y z => mul_assoc x y z) + (fun x => Subtype.ext x.property.1) + (fun x => Subtype.ext (hi x.val x.property.1 x.property.2).choose_spec.2.2) + +end Corner +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/CorrectionPaths.lean b/lean/OAI/Combinatorics/EuclideanRamsey/CorrectionPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..178983f978a3746eacae31f9aeb0e82b7dec6510 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/CorrectionPaths.lean @@ -0,0 +1,223 @@ +import OAI.Combinatorics.EuclideanRamsey.OrbitAveraging + +namespace OAI + +universe uGroup uIndex uAction uPoint + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace +open Filter +open Set + +namespace EuclideanRamsey +open scoped BigOperators +variable {G : Type uGroup} {ι : Type uIndex} [Group G] [Fintype ι] [DecidableEq ι] +namespace GradedPaths +variable (P : GradedPaths ι G) (L : Subgroup G) [L.Normal] +variable (hL : ∀ i,L ≤ singleFractions P.monoid P.diagonal i) + +def maxCost (g : G) : ℕ := Finset.univ.sup (fun i => P.singleCost i g) +lemma single_le_maxCost (i : ι) (g : G) : P.singleCost i g ≤ P.maxCost g := + Finset.le_sup (f := fun j => P.singleCost j g) (Finset.mem_univ i) +noncomputable def normalCost : NormalCost L where + cost g := P.maxCost g + nonneg g := Nat.cast_nonneg _ + one := by simp [maxCost,P.singleCost_one] + inv g hg := by + congr 1 + apply Finset.sup_congr rfl + intro i _ + exact P.singleCost_inv i (hL i hg) + conj g hg k := by + congr 1 + apply Finset.sup_congr rfl + intro i _ + exact P.singleCost_conjugate i (hL i hg) k + mul g hg h hh := by + rw [← Nat.cast_add] + apply Nat.cast_le.mpr + apply Finset.sup_le + intro i _ + exact (P.singleCost_mul i (hL i hg) (hL i hh)).trans + (add_le_add (P.single_le_maxCost i g) (P.single_le_maxCost i h)) + +omit [Fintype ι] in +lemma prod_single_eq (l : List ι) (hl : l.Nodup) (g : ι → G) (i : ι) : + ((l.map (fun j => Pi.mulSingle j (g j))).prod) i=if i∈l then g i else 1 := by + induction l with + | nil => simp + | cons j l ih => + obtain ⟨hj,hl⟩ := List.nodup_cons.mp hl + rw [List.map_cons,List.prod_cons,Pi.mul_apply,ih hl] + by_cases h : i=j + · subst j; simp [hj] + · simp [h] + +include hL in +omit [L.Normal] in +lemma bounded_tuple (g : ι → G) (hg : ∀ i,g i∈L) : + P.BoundedFraction g (∑ i,P.singleCost i (g i)) := by + classical + have hb := P.bounded_tuple_list (Finset.univ.toList) g (fun i => P.singleCost i (g i)) + (fun i _ => P.singleCost_bounded i (hL i (hg i))) + have he : ((Finset.univ.toList.map (fun i => Pi.mulSingle i (g i))).prod)=g := by + ext i + simpa using prod_single_eq Finset.univ.toList (Finset.nodup_toList _) g i + rw [he] at hb + simpa using hb + +omit [L.Normal] in +lemma correction_cost (g : ι → G) (hg : ∀ i,g i∈L) (B : ℝ) + (hc : ∀ i,(P.normalCost L hL).cost (g i)≤B) : + ∃ u v m n,P.Holds u m ∧ P.Holds v n ∧ g=u*v⁻¹ ∧ + (m+n:ℕ)≤(Fintype.card ι:ℝ)*B := by + obtain ⟨u,v,m,n,hu,hv,he,hn⟩ := P.bounded_tuple L hL g hg + refine ⟨u,v,m,n,hu,hv,he,?_⟩ + calc + ((m+n:ℕ):ℝ) ≤ ∑ i,(P.singleCost i (g i):ℝ) := by exact_mod_cast hn + _ ≤ ∑ i,B := Finset.sum_le_sum (fun i _ => + (Nat.cast_le.mpr (P.single_le_maxCost i (g i))).trans (hc i)) + _ = _ := by simp +end GradedPaths +end EuclideanRamsey +namespace EuclideanRamsey +open scoped BigOperators +variable {ι : Type uIndex} {H : Type uAction} {X : Type uPoint} [Fintype ι] [DecidableEq ι] +variable [Group H] [MulAction H X] [Fintype H] [Fintype X] + +omit [Fintype ι] [DecidableEq ι] [Fintype H] [Fintype X] in +lemma OrbitWords.path {a : ι → FiniteEuclidean} (z : X → FiniteEuclidean) + (f : ι → X) (q : ℝ) (hq : ∀ h : H,CopyPath a q (fun i => z (h • f i))) + {w : X → LetterGroup} {m : ℕ} (hw : OrbitWords (H:=H) (fun x => FreeGroup.of (z x)) w m) : + Path a (fun i => w (f i)) (q*m) := by + induction hw with + | diag g => simpa using (Path.diag (a:=a) g) + | point h => simpa using (Path.copy (a:=a) _ (hq h)) + | mul _ _ ihu ihv => simpa only [Nat.cast_add,mul_add,Pi.mul_def] using ihu.mul ihv + +theorem averaged_equal_endpoints (a : ι → FiniteEuclidean) (ha : Function.Injective a) + (z : X → FiniteEuclidean) (f g : ι → X) (q δ : ℝ) (hq : 0 < q) (hδ : 0 < δ) + (hf : ∀ h : H,CopyPath a 1 (fun i => z (h • f i))) + (hg : ∀ h : H,CopyPath a q (fun i => z (h • g i))) + (horbit : ∀ i,SameOrbit (H:=H) (f i) (g i)) : + ∃ w lmb μ,Path a w lmb ∧ Path a w μ ∧ 0 < lmb ∧ 0 ≤ μ ∧ + μ/lmb ≤ q+(Fintype.card ι:ℝ)*δ := by + let N := AugKernel FiniteEuclidean + let L := Derived N (Fintype.card ι-2) + let P := unitGraded a + have hL : ∀ i,L ≤ singleFractions P.monoid P.diagonal i := by + apply derived_subset_single N (Fintype.card ι-2) ι P.monoid P.diagonal + (unit_pair_inverse a) (unit_pair_coverage a ha) + omega + let c := P.normalCost L hL + obtain ⟨w,m,hw,hm,hwm⟩ := finite_group_averaging (H:=H) N (Fintype.card ι-2) + c (fun x => FreeGroup.of (z x)) (fun x y => letter_difference_mem (z x) (z y)) δ hδ + let Dp : ι → LetterGroup := fun i => w (f i) + let Dm : ι → LetterGroup := fun i => w (g i) + have hp : Path a Dp (m:ℝ) := by simpa using hw.path z f 1 hf + have hn : Path a Dm (q*m) := hw.path z g q hg + let r : ι → LetterGroup := Dp⁻¹*Dm + have hrc : ∀ i,r i∈L ∧ c.cost (r i) ≤ δ*m := by + intro i + obtain ⟨hmem,hcost⟩ := hwm (f i) (g i) (horbit i) + have he : r i=(w (f i))⁻¹*(w (f i)*(w (g i))⁻¹)⁻¹*((w (f i))⁻¹)⁻¹ := by + dsimp [r,Dp,Dm]; group + rw [he] + refine ⟨(inferInstance : L.Normal).conj_mem _ (L.inv_mem hmem) _,?_⟩ + rw [c.conj _ (L.inv_mem hmem),c.inv _ hmem] + exact hcost + obtain ⟨u,v,b,e,hu,hv,he,hbe⟩ := P.correction_cost L hL r (fun i => (hrc i).1) + (δ*m) (fun i => (hrc i).2) + have heq : Dp*u=Dm*v := by + have ht := congrArg (fun t => Dp*t*v) he + simpa [r,mul_assoc] using ht.symm + have h₁ : Path a (Dp*u) ((m:ℝ)+b) := hp.mul (UnitWords.path hu) + have h₂ : Path a (Dp*u) (q*m+e) := by rw [heq]; exact hn.mul (UnitWords.path hv) + have hm' : (0:ℝ) < m := Nat.cast_pos.mpr hm + have hb : (0:ℝ) ≤ b := Nat.cast_nonneg _ + have he' : (0:ℝ) ≤ e := Nat.cast_nonneg _ + refine ⟨_,_,_,h₁,h₂,by positivity,by positivity,?_⟩ + apply (div_le_iff₀ (by positivity : (0:ℝ) < m+b)).mpr + have hc' : (b:ℝ)+e ≤ (Fintype.card ι:ℝ)*(δ*m) := by simpa only [Nat.cast_add] using hbe + have hcd : 0 ≤ (Fintype.card ι:ℝ)*δ := mul_nonneg (Nat.cast_nonneg _) hδ.le + nlinarith +end EuclideanRamsey +namespace EuclideanRamsey +open scoped BigOperators + +noncomputable def permute {ℓ : ℕ} (σ : Equiv.Perm (Fin ℓ)) : + EuclideanSpace ℝ (Fin ℓ) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin ℓ) := + LinearIsometryEquiv.piLpCongrLeft 2 ℝ ℝ σ +@[simp] lemma permute_apply {ℓ : ℕ} (σ : Equiv.Perm (Fin ℓ)) + (x : EuclideanSpace ℝ (Fin ℓ)) (j : Fin ℓ) : permute σ x j=x (σ.symm j) := rfl +lemma permute_mul {ℓ : ℕ} (σ τ : Equiv.Perm (Fin ℓ)) (x : EuclideanSpace ℝ (Fin ℓ)) : + permute (σ*τ) x=permute σ (permute τ x) := by ext j; rfl +@[simp] lemma permute_one {ℓ : ℕ} (x : EuclideanSpace ℝ (Fin ℓ)) : + permute 1 x=x := by ext j; rfl + +theorem permutation_equal_endpoints {s d ℓ : ℕ} (a : Fin s → EuclideanSpace ℝ (Fin d)) + (ha : Function.Injective a) (f g : Fin s → EuclideanSpace ℝ (Fin ℓ)) + (q δ : ℝ) (hq : 0 < q) (hδ : 0 < δ) + (hf : ∀ i j,‖f i-f j‖^2=‖a i-a j‖^2) + (hg : ∀ i j,‖g i-g j‖^2=q*‖a i-a j‖^2) + (hperm : ∀ i,∃ σ : Equiv.Perm (Fin ℓ),∀ x,g i (σ x)=f i x) : + ∃ w lmb μ,Path (fun i => FiniteEuclidean.embed d (a i)) w lmb ∧ + Path (fun i => FiniteEuclidean.embed d (a i)) w μ ∧ 0 < lmb ∧ 0 ≤ μ ∧ μ/lmb ≤ q+s*δ := by + classical + choose σ hσ using hperm + let H := Equiv.Perm (Fin ℓ) + let X := H×Fin s + let : MulAction H X := + { smul := fun h x => (h*x.1,x.2) + one_smul := by intro x; exact Prod.ext (one_mul _) rfl + mul_smul := by intro h k x; exact Prod.ext (mul_assoc _ _ _) rfl } + let z : X → FiniteEuclidean := fun x => FiniteEuclidean.embed ℓ (permute x.1 (f x.2)) + have hσ' (i : Fin s) : permute (σ i) (f i)=g i := by + ext j + simpa using (hσ i ((σ i).symm j)).symm + have hcopy (h : H) (i : Fin s) : + z (h • ((σ i,i):X))=FiniteEuclidean.embed ℓ (permute h (g i)) := by + change FiniteEuclidean.embed ℓ (permute (h*σ i) (f i))=_ + rw [permute_mul,hσ'] + have ht := averaged_equal_endpoints (H:=H) (X:=X) (fun i => FiniteEuclidean.embed d (a i)) + ((FiniteEuclidean.embed d).injective.comp ha) z (fun i => (1,i)) (fun i => (σ i,i)) + q δ hq hδ + simp only [Fintype.card_fin] at ht + apply ht + · intro h + refine ⟨zero_le_one,?_⟩ + intro i j + change ‖FiniteEuclidean.embed ℓ (permute (h*1) (f i))- + FiniteEuclidean.embed ℓ (permute (h*1) (f j))‖^2=_ + simp only [mul_one,← map_sub,LinearIsometry.norm_map,LinearIsometryEquiv.norm_map,one_mul] + exact hf i j + · intro h + refine ⟨hq.le,?_⟩ + intro i j + dsimp only + rw [hcopy h i,hcopy h j] + simp only [← map_sub,LinearIsometry.norm_map,LinearIsometryEquiv.norm_map] + exact hg i j + · intro i + exact ⟨σ i,by change (σ i*1,i)=(σ i,i); simp⟩ +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/DerivedFractions.lean b/lean/OAI/Combinatorics/EuclideanRamsey/DerivedFractions.lean new file mode 100644 index 0000000000000000000000000000000000000000..30104f2580f5956ad4e2c30d61e30fdba7f241c6 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/DerivedFractions.lean @@ -0,0 +1,213 @@ +import OAI.Combinatorics.EuclideanRamsey.PathFractions + +namespace OAI + +universe uGroup uIndex uColor uPoint + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace + +namespace EuclideanRamsey +open scoped commutatorElement +variable {G : Type uGroup} [Group G] + +def Derived (N : Subgroup G) : ℕ → Subgroup G + | 0 => N + | n+1 => ⁅Derived N n,Derived N n⁆ +instance derived_normal (N : Subgroup G) [N.Normal] (n : ℕ) : (Derived N n).Normal := by + induction n with + | zero => exact inferInstanceAs N.Normal + | succ n ih => exact Subgroup.commutator_normal _ _ +lemma derived_le (N : Subgroup G) [N.Normal] (n : ℕ) : Derived N n ≤ N := by + induction n with + | zero => exact le_rfl + | succ n ih => exact (Subgroup.commutator_le_left _ _).trans ih + +def PairCoverage {ι : Type uIndex} (M : Submonoid (ι → G)) (N : Subgroup G) : Prop := + ∀ i j : ι,i≠j → ∀ a∈N,∀ b∈N,∃ z∈M,z i=a ∧ z j=b + +def restrictionHom {ι : Type uIndex} {κ : Type uColor} (f : κ → ι) : (ι → G) →* (κ → G) where + toFun z := z ∘ f + map_one' := rfl + map_mul' _ _ := rfl + +lemma restrict_diagonal {ι : Type uIndex} {κ : Type uColor} (M : Submonoid (ι → G)) (f : κ → ι) + (h : HasDiagonal M) : HasDiagonal (M.map (restrictionHom f)) := by + intro g + exact ⟨fun _ => g,h g,rfl⟩ +lemma restrict_pairInverse {ι : Type uIndex} {κ : Type uColor} (M : Submonoid (ι → G)) (f : κ → ι) + (hf : Function.Injective f) (h : PairInverse M) : PairInverse (M.map (restrictionHom f)) := by + rintro i j hij v ⟨v,hv,rfl⟩ + obtain ⟨b,hb,hi,hj⟩ := h (f i) (f j) (fun he => hij (hf he)) v hv + exact ⟨restrictionHom f b,⟨b,hb,rfl⟩,hi,hj⟩ +lemma restrict_pairCoverage {ι : Type uIndex} {κ : Type uColor} (M : Submonoid (ι → G)) (N : Subgroup G) + (f : κ → ι) (hf : Function.Injective f) (h : PairCoverage M N) : + PairCoverage (M.map (restrictionHom f)) N := by + intro i j hij a ha b hb + obtain ⟨z,hz,hi,hj⟩ := h (f i) (f j) (fun he => hij (hf he)) a ha b hb + exact ⟨restrictionHom f z,⟨z,hz,rfl⟩,hi,hj⟩ + +lemma lift_restricted_fraction {ι : Type uIndex} {κ : Type uColor} [DecidableEq ι] [DecidableEq κ] + (M : Submonoid (ι → G)) (f : κ → ι) (z : κ → G) + (h : RightFraction (M.map (restrictionHom f)) z) : + ∃ z' : ι → G,RightFraction M z' ∧ ∀ j,z' (f j)=z j := by + obtain ⟨_,⟨u,hu,rfl⟩,_,⟨v,hv,rfl⟩,he⟩ := h + refine ⟨u*v⁻¹,⟨u,hu,v,hv,rfl⟩,?_⟩ + intro j + exact (congrFun he j).symm + +lemma pair_commutator_fraction {ι : Type uIndex} [DecidableEq ι] + (M : Submonoid (ι → G)) (hM : PairInverse M) + (i j k : ι) (hij : i≠j) (hik : i≠k) (hjk : j≠k) + (z t : ι → G) (hz : RightFraction M z) (ht : RightFraction M t) + (hsz : ∀ l,l≠i → l≠j → z l=1) (hst : ∀ l,l≠i → l≠k → t l=1) : + RightFraction M (Pi.mulSingle i ⁅z i,t i⁆) := by + have hzi : ∀ l,l≠i → l≠j → z⁻¹ l=1 := by simpa only [Pi.inv_apply,inv_eq_one] using hsz + have hti : ∀ l,l≠i → l≠k → t⁻¹ l=1 := by simpa only [Pi.inv_apply,inv_eq_one] using hst + have h := ((hz.mul_pair hM ht i k hik hst).mul_pair hM hz.inv i j hij hzi).mul_pair hM ht.inv i k hik hti + have he : z*t*z⁻¹*t⁻¹=Pi.mulSingle i ⁅z i,t i⁆ := by + ext l + by_cases hli : l=i + · subst l; simp [commutatorElement_def] + · by_cases hlj : l=j + · subst l + have hh := hst j hli hjk + simp [hh,Pi.mulSingle_eq_of_ne hli] + · have hh := hsz l hli hlj + simp [hh,Pi.mulSingle_eq_of_ne hli] + rwa [he] at h + +lemma fraction_card_le_two {ι : Type uIndex} [Fintype ι] [DecidableEq ι] + (M : Submonoid (ι → G)) (N : Subgroup G) (hd : HasDiagonal M) + (hc : PairCoverage M N) (hcard : Fintype.card ι ≤ 2) (i : ι) : + N ≤ singleFractions M hd i := by + intro a ha + change RightFraction M (Pi.mulSingle i a) + by_cases h : ∃ j : ι,j≠i + · obtain ⟨j,hji⟩ := h + obtain ⟨z,hz,hzi,hzj⟩ := hc i j (Ne.symm hji) a ha 1 N.one_mem + have he : z=Pi.mulSingle i a := by + ext l + by_cases hli : l=i + · subst l; simpa using hzi + · have hlj : l=j := by + by_contra hlj + have hh : 3 ≤ Fintype.card ι := by + have hs : ({i,j,l} : Finset ι).card ≤ Fintype.card ι := Finset.card_le_univ _ + simpa [hji,Ne.symm hji,hli,Ne.symm hli,hlj,Ne.symm hlj] using hs + omega + subst l + simpa [Pi.mulSingle_eq_of_ne hli] using hzj + exact ⟨z,hz,1,M.one_mem,by simpa using he.symm⟩ + · have he : (fun _ : ι => a)=Pi.mulSingle i a := by + ext l + have hl : l=i := by by_contra hh; exact h ⟨l,hh⟩ + simp [hl] + exact ⟨_,hd a,1,M.one_mem,by simpa using he.symm⟩ + +theorem derived_subset_single (N : Subgroup G) [N.Normal] (n : ℕ) : + ∀ (ι : Type uIndex) [Fintype ι] [DecidableEq ι] (M : Submonoid (ι → G)) + (hd : HasDiagonal M) (_hi : PairInverse M) (_hc : PairCoverage M N), + Fintype.card ι ≤ n+2 → ∀ i,Derived N n ≤ singleFractions M hd i := by + induction n with + | zero => + intro ι _ _ M hd hi hc hcard i + exact fraction_card_le_two M N hd hc hcard i + | succ n ih => + intro ι _ _ M hd hi hc hcard i + by_cases hsmall : Fintype.card ι ≤ 2 + · exact (derived_le N _).trans (fraction_card_le_two M N hd hc hsmall i) + obtain ⟨j,hji⟩ := Fintype.exists_ne_of_one_lt_card (by omega) i + have hek : ∃ k : ι,k≠i ∧ k≠j := by + by_contra hh + have he : (Finset.univ : Finset ι) ⊆ {i,j} := by + intro k _ + by_cases hki : k=i + · simp [hki] + · have hkj : k=j := by by_contra hkj; exact hh ⟨k,hki,hkj⟩ + simp [hkj] + have hh := Finset.card_le_card he + have hh' : Fintype.card ι ≤ 2 := hh.trans (Finset.card_insert_le _ _ |>.trans (by simp)) + exact hsmall hh' + obtain ⟨k,hki,hkj⟩ := hek + change ⁅Derived N n,Derived N n⁆ ≤ _ + apply Subgroup.commutator_le.mpr + intro a ha b hb + have lift (j : ι) (hji : j≠i) (a : G) (ha : a∈Derived N n) : + ∃ z : ι → G,RightFraction M z ∧ z i=a ∧ ∀ l,l≠i → l≠j → z l=1 := by + let κ := {l : ι // l≠j} + let f : κ → ι := Subtype.val + let M' := M.map (restrictionHom f) + let i' : κ := ⟨i,Ne.symm hji⟩ + have hf : Function.Injective f := Subtype.val_injective + have hκ : Fintype.card κ ≤ n+2 := by + have hh := Fintype.card_subtype_lt (p:=fun l : ι => l≠j) (x:=j) (by simp) + change Fintype.card κ < Fintype.card ι at hh + omega + have he := ih κ M' (restrict_diagonal M f hd) (restrict_pairInverse M f hf hi) + (restrict_pairCoverage M N f hf hc) hκ i' ha + obtain ⟨z,hz,he⟩ := lift_restricted_fraction M f (Pi.mulSingle i' a) he + refine ⟨z,hz,?_,?_⟩ + · simpa [i',f] using he i' + · intro l hli hlj + have hh := he ⟨l,hlj⟩ + have hn : (⟨l,hlj⟩ : κ) ≠ i' := by intro he; exact hli (Subtype.mk.inj he) + simpa [f,Pi.mulSingle_eq_of_ne hn] using hh + obtain ⟨z,hz,hzi,hsz⟩ := lift j hji a ha + obtain ⟨t,ht,hti,hst⟩ := lift k hki b hb + have hh := pair_commutator_fraction M hi i j k (Ne.symm hji) (Ne.symm hki) + (Ne.symm hkj) z t hz ht hsz hst + change RightFraction M (Pi.mulSingle i ⁅a,b⁆) + simpa only [hzi,hti] using hh +end EuclideanRamsey + +namespace EuclideanRamsey +variable {X : Type uPoint} {G : Type uGroup} [Group G] +def freeAugmentation (X : Type uPoint) : FreeGroup X →* Multiplicative ℤ := + FreeGroup.lift (fun _ => Multiplicative.ofAdd 1) +def AugKernel (X : Type uPoint) : Subgroup (FreeGroup X) := (freeAugmentation X).ker +instance (X : Type uPoint) : (AugKernel X).Normal := inferInstanceAs (freeAugmentation X).ker.Normal +lemma letter_difference_mem (x y : X) : FreeGroup.of x*(FreeGroup.of y)⁻¹∈AugKernel X := by + change freeAugmentation X _=1 + simp [freeAugmentation] + +lemma augmentation_kernel_le (x₀ : X) (Q : Subgroup (FreeGroup X)) [Q.Normal] + (h : ∀ x y,(QuotientGroup.mk' Q) (FreeGroup.of x)=(QuotientGroup.mk' Q) (FreeGroup.of y)) : + AugKernel X≤Q := by + let q := QuotientGroup.mk' Q + let t := q (FreeGroup.of x₀) + let cy : Multiplicative ℤ →* (FreeGroup X ⧸ Q) := + { toFun := fun n => t^(Multiplicative.toAdd n) + map_one' := by simp + map_mul' := by intro a b; exact zpow_add t _ _ } + have he : q=cy.comp (freeAugmentation X) := by + apply FreeGroup.ext_hom + intro x + simpa [cy,freeAugmentation,t,q] using h x x₀ + intro g hg + apply (QuotientGroup.eq_one_iff _).mp + change q g=1 + rw [he,MonoidHom.comp_apply] + change freeAugmentation X g=1 at hg + rw [hg,map_one] +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/DifferentialSplitting.lean b/lean/OAI/Combinatorics/EuclideanRamsey/DifferentialSplitting.lean new file mode 100644 index 0000000000000000000000000000000000000000..56116fc81fcba8ad52ac6deb62817ab587cf7545 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/DifferentialSplitting.lean @@ -0,0 +1,329 @@ +import OAI.Combinatorics.EuclideanRamsey.Hessian + +namespace OAI + +universe uDomain uAction uVertical uCodomain + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory + +open scoped BigOperators +open Matrix MeasureTheory +namespace EuclideanRamsey + +section Operator +variable {E : Type uDomain} [NormedAddCommGroup E] [NormedSpace ℝ E] {k : ℕ} + +def secondOperator (C : Matrix (Fin k) (Fin k) ℝ) (v : Fin k → E) + (f : E → ℝ) (x : E) : ℝ := + (1/2:ℝ)*∑ j, ∑ l, C j l*hessianB f x (v j) (v l) + +lemma secondOperator_continuous (C : Matrix (Fin k) (Fin k) ℝ) (v : Fin k → E) + {f : E → ℝ} (hf : ContDiff ℝ (⊤ : ℕ∞) f) : Continuous (secondOperator C v f) := by + unfold secondOperator + apply continuous_const.mul + apply continuous_finsetSum + intro j hj + apply continuous_finsetSum + intro l hl + exact continuous_const.mul (hessianB_apply_continuous hf _ _) + +lemma secondOperator_compact (C : Matrix (Fin k) (Fin k) ℝ) (v : Fin k → E) + {f : E → ℝ} (hf : HasCompactSupport f) : HasCompactSupport (secondOperator C v f) := by + apply (hessianB_compact hf).comp_left (g := fun B => (1/2:ℝ)*∑ j, ∑ l, C j l*B (v j) (v l)) + simp + +end Operator + +section Scale +variable (H : Type uAction) (V : Type uVertical) [NormedAddCommGroup H] [NormedSpace ℝ H] + [NormedAddCommGroup V] [NormedSpace ℝ V] [FiniteDimensional ℝ H] [FiniteDimensional ℝ V] + +def scaleVertical (t : ℝ) (ht : t ≠ 0) : (H×V) ≃L[ℝ] H×V := + (show (H×V) ≃ₗ[ℝ] H×V from { + toFun := fun x => (x.1,t • x.2) + invFun := fun x => (x.1,t⁻¹ • x.2) + left_inv := by intro x; simp [smul_smul, ht] + right_inv := by intro x; simp [smul_smul, ht] + map_add' := by intro x y; simp [smul_add] + map_smul' := by intro c x; ext <;> simp [smul_smul, mul_comm] + }).toContinuousLinearEquiv + +@[simp] lemma scaleVertical_apply (t : ℝ) (ht : t ≠ 0) (x : H×V) : + scaleVertical H V t ht x = (x.1,t • x.2) := rfl + +end Scale + +section SplitDifferential +variable {k d : ℕ} {H : Type uAction} {V : Type uVertical} + [NormedAddCommGroup H] [InnerProductSpace ℝ H] [FiniteDimensional ℝ H] + [NormedAddCommGroup V] [NormedSpace ℝ V] [FiniteDimensional ℝ V] + +lemma split_differential + (C : Matrix (Fin k) (Fin k) ℝ) (R : Matrix (Fin k) (Fin d) ℝ) + (Z : Matrix (Fin k) (Fin k) ℝ) + (hsplit : C = R*R.transpose+Z*C*Z.transpose) + (e : (Fin k → ℝ) ≃L[ℝ] H×V) (eh : OrthonormalBasis (Fin d) ℝ H) + (z : Fin k → V) + (hR : ∀ j, e (fun l => R l j) = (eh j,0)) + (hZ : ∀ j, e (fun l => Z l j) = (0,z j)) + (f : H → ℝ) (g : V → ℝ) (hf : ContDiff ℝ (⊤ : ℕ∞) f) + (hg : ContDiff ℝ (⊤ : ℕ∞) g) (t : ℝ) (ht : t ≠ 0) (x : Fin k → ℝ) : + let et := e.trans (scaleVertical H V t ht) + let b := (fun y : H×V => f y.1*g y.2) ∘ et + secondOperator C (fun j => Pi.single j 1) b x = + g (et x).2 * halfLaplacian f (et x).1 + + t^2*f (et x).1*secondOperator C z g (et x).2 := by + dsimp only + let et := e.trans (scaleVertical H V t ht) + let b := (fun y : H×V => f y.1*g y.2) ∘ et + change secondOperator C (fun j => Pi.single j 1) b x = _ + have hfg : ContDiff ℝ (⊤ : ℕ∞) (fun y : H×V => f y.1*g y.2) := + (hf.comp contDiff_fst).mul (hg.comp contDiff_snd) + have hb (v w : Fin k → ℝ) : hessianB b x v w = + hessianB (fun y : H×V => f y.1*g y.2) (et x) (et v) (et w) := + hessianB_linear_comp hfg et.toContinuousLinearMap x v w + have hhr (j : Fin d) : et (fun l => R l j) = (eh j,0) := by simp [et,hR] + have hhz (j : Fin k) : et (fun l => Z l j) = (0,t • z j) := by simp [et,hZ] + have hhor : ∑ j, hessianB b x (fun l => R l j) (fun l => R l j) = + g (et x).2 * ∑ j, hessianB f (et x).1 (eh j) (eh j) := by + simp only [hb, hhr, hessianB_prod_horizontal hf hg, Finset.mul_sum] + have hver : ∑ j, ∑ l, C j l*hessianB b x (fun a => Z a j) (fun a => Z a l) = + t^2*f (et x).1 * ∑ j, ∑ l, C j l*hessianB g (et x).2 (z j) (z l) := by + simp only [hb, hhz, hessianB_prod_vertical hf hg, map_smul, + _root_.smul_apply, smul_eq_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro l hl + ring + unfold secondOperator + have hcon : ∑ j, ∑ l, C j l*hessianB b x (Pi.single j 1) (Pi.single l 1) = + (∑ j, hessianB b x (fun l => R l j) (fun l => R l j)) + + ∑ j, ∑ l, C j l*hessianB b x (fun a => Z a j) (fun a => Z a l) := by + conv_lhs => rw [hsplit] + simp only [Matrix.add_apply, add_mul, Finset.sum_add_distrib] + congr 1 + · have he := bilinear_matrix_pushforward (hessianB b x) R 1 + simpa [Matrix.one_apply] using he + · exact bilinear_matrix_pushforward (hessianB b x) Z C + rw [hcon, hhor, hver] + have htrace := bilinear_orthonormal_trace (hessianB f (et x).1) eh (stdOrthonormalBasis ℝ H) + rw [htrace] + simp only [halfLaplacian, ← hessianB_eq] + ring + +end SplitDifferential +end EuclideanRamsey + +open MeasureTheory +namespace EuclideanRamsey + +lemma haar_linear_change {E : Type uDomain} {F : Type uCodomain} + [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace E] [BorelSpace E] [MeasurableSpace F] [BorelSpace F] + (e : E ≃L[ℝ] F) (μ : Measure E) [μ.IsAddHaarMeasure] + (ν : Measure F) [ν.IsAddHaarMeasure] : + ∃ c : ℝ, 0 < c ∧ ∀ f : F → ℝ, Continuous f → + (∫ x, f (e x) ∂μ) = c * ∫ y, f y ∂ν := by + let : (μ.map e).IsAddHaarMeasure := e.isAddHaarMeasure_map μ + let c := (μ.map e).addHaarScalarFactor ν + have hc : 0 < c := Measure.addHaarScalarFactor_pos_of_isAddHaarMeasure _ _ + refine ⟨c, by exact_mod_cast hc, ?_⟩ + intro f hf + rw [← integral_map e.continuous.measurable.aemeasurable hf.aestronglyMeasurable, + Measure.isAddLeftInvariant_eq_smul (μ.map e) ν] + simp [c, integral_smul_nnreal_measure, NNReal.smul_def, smul_eq_mul] + +lemma compact_prod_mul {E : Type uDomain} {F : Type uCodomain} [TopologicalSpace E] [TopologicalSpace F] + [R1Space E] [R1Space F] {f : E → ℝ} {g : F → ℝ} + (hf : HasCompactSupport f) (hg : HasCompactSupport g) : + HasCompactSupport (fun x : E×F => f x.1*g x.2) := by + apply HasCompactSupport.of_support_subset_isCompact (hf.prod hg) + rintro ⟨x,y⟩ h + have hx : f x ≠ 0 := by intro h0; exact h (by simp [h0]) + have hy : g y ≠ 0 := by intro h0; exact h (by simp [h0]) + exact ⟨subset_closure hx, subset_closure hy⟩ + +lemma negative_product_sum_bound (f g a b t : ℝ) (hf : 0 ≤ f) (hg : 0 ≤ g) + (ht : 0 ≤ t) : + max (-(g*a+t*f*b)) 0 ≤ g*max (-a) 0+t*f*|b| := by + apply max_le + · have ha := le_max_left (-a) 0 + have hb := neg_le_abs b + nlinarith [mul_le_mul_of_nonneg_left ha hg, + mul_le_mul_of_nonneg_left hb (mul_nonneg ht hf)] + · exact add_nonneg (mul_nonneg hg (le_max_right _ _)) + (mul_nonneg (mul_nonneg ht hf) (abs_nonneg _)) + +end EuclideanRamsey + +open MeasureTheory +namespace EuclideanRamsey + +lemma product_negative_integral_bound {E : Type uDomain} {F : Type uCodomain} + [MeasurableSpace E] [MeasurableSpace F] + (μ : Measure E) (ν : Measure F) [SFinite μ] [SFinite ν] + (f a w : E → ℝ) (g b : F → ℝ) (t : ℝ) + (hf : ∀ x, 0 ≤ f x) (hg : ∀ y, 0 ≤ g y) (hw : ∀ x, 0 ≤ w x) + (haI : Integrable (fun x => max (-a x) 0*w x) μ) + (hfI : Integrable (fun x => f x*w x) μ) + (hgI : Integrable g ν) (hbI : Integrable (fun y => |b y|) ν) : + (∫ z : E×F, max (-(g z.2*a z.1+t^2*f z.1*b z.2)) 0*w z.1 ∂μ.prod ν) ≤ + (∫ x, max (-a x) 0*w x ∂μ)*(∫ y, g y ∂ν) + + t^2*(∫ x, f x*w x ∂μ)*(∫ y, |b y| ∂ν) := by + have hI := (haI.mul_prod hgI).add ((hfI.mul_prod hbI).const_mul (t^2)) + have hbound (z : E×F) : + max (-(g z.2*a z.1+t^2*f z.1*b z.2)) 0*w z.1 ≤ + (max (-a z.1) 0*w z.1)*g z.2+t^2*((f z.1*w z.1)*|b z.2|) := by + have h : max (-(g z.2*a z.1+t^2*f z.1*b z.2)) 0 ≤ + g z.2*max (-a z.1) 0+t^2*f z.1*|b z.2| := by + apply max_le + · have ha := le_max_left (-a z.1) 0 + have hb := neg_le_abs (b z.2) + nlinarith [mul_le_mul_of_nonneg_left ha (hg z.2), + mul_le_mul_of_nonneg_left hb (mul_nonneg (sq_nonneg t) (hf z.1))] + · exact add_nonneg (mul_nonneg (hg z.2) (le_max_right _ _)) + (mul_nonneg (mul_nonneg (sq_nonneg t) (hf z.1)) (abs_nonneg _)) + calc + _ ≤ (g z.2*max (-a z.1) 0+t^2*f z.1*|b z.2|)*w z.1 := + mul_le_mul_of_nonneg_right h (hw z.1) + _ = _ := by ring + refine (integral_mono_of_nonneg + (Filter.Eventually.of_forall (fun z => mul_nonneg (le_max_right _ _) (hw z.1))) hI + (Filter.Eventually.of_forall hbound)).trans_eq ?_ + change (∫ z : E×F, (max (-a z.1) 0*w z.1)*g z.2+ + t^2*((f z.1*w z.1)*|b z.2|) ∂μ.prod ν) = _ + rw [integral_add (haI.mul_prod hgI) ((hfI.mul_prod hbI).const_mul (t^2)), + integral_const_mul, integral_prod_mul (fun x => max (-a x) 0*w x) g, + integral_prod_mul (fun x => f x*w x) (fun y => |b y|)] + ring + +end EuclideanRamsey + +namespace EuclideanRamsey +open MeasureTheory Matrix +open scoped BigOperators + +lemma halfLaplacian_continuous {H : Type uAction} [NormedAddCommGroup H] + [InnerProductSpace ℝ H] [FiniteDimensional ℝ H] {f : H → ℝ} + (hf : ContDiff ℝ (⊤ : ℕ∞) f) : Continuous (halfLaplacian f) := by + change Continuous (fun x => halfLaplacian f x) + simp only [halfLaplacian, ← hessianB_eq] + apply continuous_const.mul + exact continuous_finsetSum _ (fun j hj => hessianB_apply_continuous hf _ _) + +lemma halfLaplacian_compact {H : Type uAction} [NormedAddCommGroup H] + [InnerProductSpace ℝ H] [FiniteDimensional ℝ H] {f : H → ℝ} + (hf : HasCompactSupport f) : HasCompactSupport (halfLaplacian f) := by + change HasCompactSupport (fun x => halfLaplacian f x) + simp only [halfLaplacian, ← hessianB_eq] + apply (hessianB_compact hf).comp_left + (g := fun B => (1/2:ℝ)*∑ j, B (stdOrthonormalBasis ℝ H j) (stdOrthonormalBasis ℝ H j)) + simp + + theorem exists_split_smoothing {k d : ℕ} {H : Type uAction} {V : Type uVertical} + [NormedAddCommGroup H] [InnerProductSpace ℝ H] [FiniteDimensional ℝ H] + [NormedAddCommGroup V] [NormedSpace ℝ V] [FiniteDimensional ℝ V] + [MeasurableSpace H] [BorelSpace H] [MeasurableSpace V] [BorelSpace V] + (hn : 1 ≤ Module.finrank ℝ H) + (C : Matrix (Fin k) (Fin k) ℝ) (R : Matrix (Fin k) (Fin d) ℝ) + (Z : Matrix (Fin k) (Fin k) ℝ) + (hsplit : C = R*R.transpose+Z*C*Z.transpose) + (e : (Fin k → ℝ) ≃L[ℝ] H×V) (eh : OrthonormalBasis (Fin d) ℝ H) + (z : Fin k → V) + (hR : ∀ j, e (fun l => R l j) = (eh j,0)) + (hZ : ∀ j, e (fun l => Z l j) = (0,z j)) + {η : ℝ} (hη : 0 < η) : + ∃ b : (Fin k → ℝ) → ℝ, ContDiff ℝ (⊤ : ℕ∞) b ∧ HasCompactSupport b ∧ + (∀ x, 0 ≤ b x) ∧ 0 < ∫ x, b x ∧ + (∫ x, max (-secondOperator C (fun j => Pi.single j 1) b x) 0 * ‖(e x).1‖^2) < + η * ∫ x, b x := by + let μH : Measure H := Measure.addHaar + let μV : Measure V := Measure.addHaar + obtain ⟨f,hfs,hfc,hfp,hfm,hfsmall⟩ := exists_radial_smoothing μH hn (η := η/2) (by positivity) + let g₀ : ContDiffBump (0:V) := ⟨1,2,by norm_num,by norm_num⟩ + let g : V → ℝ := g₀ + have hgs : ContDiff ℝ (⊤ : ℕ∞) g := g₀.contDiff + have hgc : HasCompactSupport g := g₀.hasCompactSupport + have hgp : ∀ y, 0 ≤ g y := g₀.nonneg' + have hgm : 0 < ∫ y, g y ∂μV := g₀.integral_pos + let a := halfLaplacian f + let bV := secondOperator C z g + have hac : Continuous a := halfLaplacian_continuous hfs + have hak : HasCompactSupport a := halfLaplacian_compact hfc + have hbc : Continuous bV := secondOperator_continuous C z hgs + have hbk : HasCompactSupport bV := secondOperator_compact C z hgc + have haI : Integrable (fun x => max (-a x) 0*‖x‖^2) μH := by + have hk : HasCompactSupport (fun x => max (-a x) 0) := + hak.comp_left (g := fun r : ℝ => max (-r) 0) (by simp) + exact ((hac.neg.max continuous_const).mul (continuous_norm.pow 2)).integrable_of_hasCompactSupport hk.mul_right + have hfI : Integrable (fun x => f x*‖x‖^2) μH := + (hfs.continuous.mul (continuous_norm.pow 2)).integrable_of_hasCompactSupport hfc.mul_right + have hgI : Integrable g μV := hgs.continuous.integrable_of_hasCompactSupport hgc + have hbI : Integrable (fun y => |bV y|) μV := + hbc.abs.integrable_of_hasCompactSupport hbk.abs + let K := (∫ x, f x*‖x‖^2 ∂μH)*(∫ y, |bV y| ∂μV) + have hK : 0 ≤ K := mul_nonneg + (integral_nonneg (fun x => mul_nonneg (hfp x) (sq_nonneg _))) + (integral_nonneg (fun y => abs_nonneg _)) + obtain ⟨t₀,ht₀,htsmall⟩ := exists_pos_mul_lt + (mul_pos (mul_pos (show 0 < η/2 by positivity) hfm) hgm) (K+1) + let t := min t₀ 1 + have ht : 0 < t := lt_min ht₀ zero_lt_one + have ht1 : t ≤ 1 := min_le_right _ _ + have htt₀ : t ≤ t₀ := min_le_left _ _ + have hsmall : t^2*K < (η/2)*(∫ x,f x ∂μH)*(∫ y,g y ∂μV) := by + have h : (K+1)*t ≤ (K+1)*t₀ := mul_le_mul_of_nonneg_left htt₀ (by linarith) + have hsq : t^2 ≤ t := by nlinarith + have hsqK := mul_le_mul_of_nonneg_right hsq hK + nlinarith + let et := e.trans (scaleVertical H V t ht.ne') + let b := (fun y : H×V => f y.1*g y.2) ∘ et + have hfgs : ContDiff ℝ (⊤ : ℕ∞) (fun y : H×V => f y.1*g y.2) := + (hfs.comp contDiff_fst).mul (hgs.comp contDiff_snd) + have hbs : ContDiff ℝ (⊤ : ℕ∞) b := hfgs.comp et.contDiff + have hbk' : HasCompactSupport b := (compact_prod_mul hfc hgc).comp_homeomorph et.toHomeomorph + obtain ⟨c,hc,hchange⟩ := haar_linear_change et volume (μH.prod μV) + have hmass : (∫ x,b x) = c*((∫ x,f x ∂μH)*(∫ y,g y ∂μV)) := by + change (∫ x, f (et x).1*g (et x).2) = _ + rw [hchange _ hfgs.continuous, integral_prod_mul] + have hetfst (x : Fin k → ℝ) : (et x).1 = (e x).1 := rfl + have hdiff (x : Fin k → ℝ) : secondOperator C (fun j => Pi.single j 1) b x = + g (et x).2*a (et x).1+t^2*f (et x).1*bV (et x).2 := + split_differential C R Z hsplit e eh z hR hZ f g hfs hgs t ht.ne' x + let φ : H×V → ℝ := fun y => max (-(g y.2*a y.1+t^2*f y.1*bV y.2)) 0*‖y.1‖^2 + have hφ : Continuous φ := by + dsimp [φ] + exact ((((hgs.continuous.comp continuous_snd).mul (hac.comp continuous_fst)).add + ((continuous_const.mul (hfs.continuous.comp continuous_fst)).mul + (hbc.comp continuous_snd))).neg.max continuous_const).mul ((continuous_fst.norm).pow 2) + have hneg : (∫ x, max (-secondOperator C (fun j => Pi.single j 1) b x) 0*‖(e x).1‖^2) = + c*∫ y, φ y ∂μH.prod μV := by + conv_lhs => arg 2; intro x; rw [hdiff, ← hetfst] + exact hchange φ hφ + have hbound := product_negative_integral_bound μH μV f a (fun x => ‖x‖^2) g bV t + hfp hgp (fun x => sq_nonneg _) haI hfI hgI hbI + have hfinal : (∫ y,φ y ∂μH.prod μV) < η*((∫ x,f x ∂μH)*(∫ y,g y ∂μV)) := by + have hh := mul_lt_mul_of_pos_right hfsmall hgm + change _ < η/2 * _ * _ at hh + rw [mul_assoc (t^2)] at hbound + change _ ≤ _ + t^2*K at hbound + change _ < _ at hsmall + dsimp only [φ] at * + nlinarith + refine ⟨b,hbs,hbk',fun x => mul_nonneg (hfp _) (hgp _),?_,?_⟩ + · rw [hmass]; positivity + · rw [hneg,hmass] + nlinarith [mul_lt_mul_of_pos_left hfinal hc] + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Discretization.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Discretization.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcca95c13169f710681f924282f95aba0a152505 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Discretization.lean @@ -0,0 +1,220 @@ +import OAI.Combinatorics.EuclideanRamsey.LatticeMoments + +namespace OAI + +universe uDomain uIndex + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct + +open MeasureTheory +open scoped BigOperators +namespace EuclideanRamsey + +lemma compact_taylor_bound {E : Type uDomain} [NormedAddCommGroup E] [NormedSpace ℝ E] + {f : E → ℝ} (hf : ContDiff ℝ (⊤ : ℕ∞) f) (hfc : HasCompactSupport f) : + ∃ K : ℝ, 0 ≤ K ∧ ∀ x h : E, + |f (x+h)-f x-fderiv ℝ f x h- + (1/2:ℝ)*iteratedFDeriv ℝ 2 f x ![h,h]| ≤ K*‖h‖^3 := by + obtain ⟨K,hK⟩ := (hf.continuous_iteratedFDeriv (m := 3) (by norm_cast)).bounded_above_of_compact_support + (hfc.iteratedFDeriv 3) + have hK0 : 0 ≤ K := (norm_nonneg _).trans (hK 0) + refine ⟨K,hK0,?_⟩ + intro x h + have ht := map_add_eq_sum_add_integral_iteratedFDeriv (n := 2) (f := f) (x := x) (y := h) + (fun t ht => (hf.of_le (by norm_cast)).contDiffAt) + have he : f (x+h)-f x-fderiv ℝ f x h-(1/2:ℝ)*iteratedFDeriv ℝ 2 f x ![h,h] = + (1/2:ℝ)*∫ t in (0:ℝ)..1, (1-t)^2 * iteratedFDeriv ℝ 3 f (x+t • h) (fun _ => h) := by + have hvec : (fun _ : Fin 2 => h) = ![h,h] := by ext i; fin_cases i <;> rfl + simp only [Finset.sum_range_succ,Finset.sum_range_zero,zero_add,Nat.factorial, + Nat.cast_one,Nat.cast_mul,inv_one, + iteratedFDeriv_zero_apply,iteratedFDeriv_one_apply,smul_eq_mul,hvec] at ht + linarith + rw [he,abs_mul,abs_of_nonneg (by norm_num : (0:ℝ) ≤ 1/2)] + have hi : |∫ t in (0:ℝ)..1, (1-t)^2 * iteratedFDeriv ℝ 3 f (x+t • h) (fun _ => h)| ≤ + K*‖h‖^3 := by + have ht (t : ℝ) (ht : t ∈ Set.Icc (0:ℝ) 1) : + ‖(1-t)^2 * iteratedFDeriv ℝ 3 f (x+t • h) (fun _ => h)‖ ≤ K*‖h‖^3 := by + rw [norm_mul, Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + have hm := (iteratedFDeriv ℝ 3 f (x+t • h)).le_opNorm (fun _ => h) + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin] at hm + have hd : ‖iteratedFDeriv ℝ 3 f (x+t • h) (fun _ => h)‖ ≤ K*‖h‖^3 := + hm.trans (mul_le_mul_of_nonneg_right (hK _) (by positivity)) + have ht2 : (1-t)^2 ≤ 1 := by nlinarith [ht.1,ht.2] + calc + _ ≤ 1 * (K*‖h‖^3) := mul_le_mul ht2 hd (norm_nonneg _) (by norm_num) + _ = _ := one_mul _ + have hh := intervalIntegral.norm_integral_le_of_norm_le_const (a := (0:ℝ)) (b := 1) + (C := K*‖h‖^3) (fun t ht' => ht t ⟨(by simpa using ht'.1 : 0 < t).le,by simpa using ht'.2⟩) + simpa using hh + nlinarith [mul_nonneg hK0 (pow_nonneg (norm_nonneg h) 3)] + +end EuclideanRamsey + +open scoped BigOperators +namespace EuclideanRamsey + +lemma linear_moment_contract {ι : Type uIndex} {k : ℕ} + (S : Finset ι) (q : ι → ℝ) (v : ι → (Fin k → ℝ)) + (L : (Fin k → ℝ) →L[ℝ] ℝ) : + ∑ γ ∈ S,q γ*L (v γ) = ∑ j,(∑ γ ∈ S,q γ*v γ j)*L (Pi.single j 1) := by + have hv (γ : ι) : v γ = ∑ j, v γ j • Pi.single j (1:ℝ) := by + ext l + simp [Pi.single_apply] + conv_lhs => arg 2; intro γ; rw [hv γ] + simp only [map_sum,map_smul,smul_eq_mul,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro γ hγ + ring + +lemma bilinear_moment_contract {ι : Type uIndex} {k : ℕ} + (S : Finset ι) (q : ι → ℝ) (v : ι → (Fin k → ℝ)) + (L : (Fin k → ℝ) →L[ℝ] (Fin k → ℝ) →L[ℝ] ℝ) : + ∑ γ ∈ S,q γ*L (v γ) (v γ) = + ∑ j,∑ l,(∑ γ ∈ S,q γ*v γ j*v γ l)*L (Pi.single j 1) (Pi.single l 1) := by + have hv (γ : ι) : v γ = ∑ j, v γ j • Pi.single j (1:ℝ) := by + ext l + simp [Pi.single_apply] + have he (γ : ι) : q γ*L (v γ) (v γ) = + ∑ j,∑ l,q γ*v γ j*v γ l*L (Pi.single j 1) (Pi.single l 1) := by + have hfirst := congrArg (fun a => L a (v γ)) (hv γ) + rw [hfirst] + simp only [map_sum,map_smul,_root_.sum_apply, + _root_.smul_apply,smul_eq_mul,Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + have hsecond := congrArg (fun a => L (Pi.single j 1) a) (hv γ) + rw [hsecond] + simp only [map_sum,map_smul,smul_eq_mul,Finset.mul_sum] + apply Finset.sum_congr rfl + intro l hl + ring + simp only [he,Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + rw [Finset.sum_comm] + +end EuclideanRamsey + +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +namespace EuclideanRamsey + +abbrev realLattice (k : ℕ) := Submodule.span ℤ (Set.range (Pi.basisFun ℝ (Fin k))) +def latticeSample {k : ℕ} (n : ℕ) (γ : Fin k → ℤ) : Fin k → ℝ := fun j => (γ j : ℝ)/n + +lemma latticeSample_injective {k n : ℕ} (hn : n ≠ 0) : + Function.Injective (@latticeSample k n) := by + intro γ δ h + funext j + have he := congr_fun h j + dsimp [latticeSample] at he + exact_mod_cast (div_left_inj' (show (n:ℝ) ≠ 0 by exact_mod_cast hn)).mp he + +lemma latticeSample_mem_grid {k n : ℕ} (hn : n ≠ 0) (γ : Fin k → ℤ) : + latticeSample n γ ∈ (n:ℝ)⁻¹ • (realLattice k : Set (Fin k → ℝ)) := by + let : NeZero n := ⟨hn⟩ + rw [← Submodule.coe_pointwise_smul] + apply BoxIntegral.unitPartition.mem_smul_span_iff.mpr + intro j + refine ⟨γ j,?_⟩ + change (γ j : ℝ) = (n:ℝ)*((γ j : ℝ)/n) + field_simp + +lemma grid_surjective {k n : ℕ} (hn : n ≠ 0) {x : Fin k → ℝ} + (hx : x ∈ (n:ℝ)⁻¹ • (realLattice k : Set (Fin k → ℝ))) : ∃ γ, latticeSample n γ = x := by + let : NeZero n := ⟨hn⟩ + rw [← Submodule.coe_pointwise_smul] at hx + have h := BoxIntegral.unitPartition.mem_smul_span_iff.mp hx + choose γ hγ using h + refine ⟨γ,?_⟩ + funext j + simp only [latticeSample] + have he : (γ j : ℝ) = (n:ℝ)*x j := hγ j + rw [he] + exact mul_div_cancel_left₀ (x j) (by exact_mod_cast hn) + +lemma lattice_tsum_eq_grid {k n : ℕ} (hn : n ≠ 0) (s : Set (Fin k → ℝ)) + (f : (Fin k → ℝ) → ℝ) (hf : Function.support f ⊆ s) : + (∑' γ : Fin k → ℤ, f (latticeSample n γ)) = + ∑' x : ↑(s ∩ (n:ℝ)⁻¹ • realLattice k), f x := by + let e : {γ : Fin k → ℤ // latticeSample n γ ∈ s} ≃ + ↑(s ∩ (n:ℝ)⁻¹ • realLattice k) := Equiv.ofBijective + (fun γ => ⟨latticeSample n γ,γ.property,latticeSample_mem_grid hn γ.val⟩) (by + constructor + · intro x y h + apply Subtype.ext + exact latticeSample_injective hn (congr_arg Subtype.val h) + · intro x + obtain ⟨γ,hγ⟩ := grid_surjective hn x.property.2 + exact ⟨⟨γ,by simpa [hγ] using x.property.1⟩,Subtype.ext hγ⟩) + rw [← tsum_subtype_eq_of_support_subset (s := {γ | latticeSample n γ ∈ s}) + (f := fun γ => f (latticeSample n γ)) (fun γ hγ => hf hγ)] + exact e.tsum_eq (fun x => f x) + +theorem lattice_riemann {k : ℕ} {f : (Fin k → ℝ) → ℝ} + (hf : Continuous f) (hfc : HasCompactSupport f) : + Tendsto (fun n : ℕ => (∑' γ : Fin k → ℤ, f (latticeSample n γ))/(n:ℝ)^k) + atTop (𝓝 (∫ x, f x)) := by + obtain ⟨R,hR,hfR⟩ := hfc.exists_pos_le_norm + let s := Metric.closedBall (0 : Fin k → ℝ) R + have hs : Function.support f ⊆ s := by + intro x hx + rw [show s = Metric.closedBall 0 R from rfl, Metric.mem_closedBall,dist_zero_right] + exact le_of_lt (lt_of_not_ge (fun h => hx (hfR x h))) + have hfront : volume (frontier s) = 0 := + measure_mono_null Metric.frontier_closedBall_subset_sphere + (volume.addHaar_sphere_of_ne_zero 0 hR.ne') + have h := tendsto_tsum_div_pow_atTop_integral s f hf Metric.isBounded_closedBall + measurableSet_closedBall hfront + have hi : (∫ x in s,f x) = ∫ x,f x := by + rw [← integral_indicator measurableSet_closedBall, Set.indicator_eq_self.mpr hs] + simp only [Fintype.card_fin,hi] at h + apply h.congr' + filter_upwards [eventually_ge_atTop 1] with n hn + rw [lattice_tsum_eq_grid (by omega) s f hs] + +lemma latticeSample_finite_support {k n : ℕ} (hn : n ≠ 0) + {f : (Fin k → ℝ) → ℝ} (hf : HasCompactSupport f) : + Function.HasFiniteSupport (fun γ : Fin k → ℤ => f (latticeSample n γ)) := by + let b := Pi.basisFun ℝ (Fin k) + have hb : Bornology.IsBounded ((n:ℝ) • tsupport f) := + (hf.isCompact.image (show Continuous (fun x : Fin k → ℝ => (n:ℝ) • x) by fun_prop)).isBounded + have hfinite := ZSpan.setFinite_inter b hb + let cast : (Fin k → ℤ) → (Fin k → ℝ) := fun γ j => γ j + have hinj : Function.Injective cast := by + intro x y h + ext j + have he : (x j : ℝ) = (y j : ℝ) := congr_fun h j + exact_mod_cast he + apply ((hfinite.preimage hinj.injOn).subset ?_) + intro γ hγ + have hs : latticeSample n γ ∈ tsupport f := subset_closure hγ + constructor + · refine ⟨latticeSample n γ,hs,?_⟩ + ext j + change (n:ℝ)*((γ j : ℝ)/n) = (γ j : ℝ) + field_simp + · change cast γ ∈ Submodule.span ℤ (Set.range b) + rw [b.mem_span_iff_repr_mem ℤ] + intro j + exact ⟨γ j,by simp [b,cast]⟩ + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/FiniteEuclidean.lean b/lean/OAI/Combinatorics/EuclideanRamsey/FiniteEuclidean.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e739f643be51eab5b857050ce60dda0a07c0007 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/FiniteEuclidean.lean @@ -0,0 +1,255 @@ +import OAI.Combinatorics.EuclideanRamsey.GramCompletion + +namespace OAI + +universe uValue + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator + +open scoped BigOperators RealInnerProductSpace +namespace EuclideanRamsey + +def FiniteEuclidean := ℕ →₀ ℝ +namespace FiniteEuclidean +instance : AddCommGroup FiniteEuclidean := inferInstanceAs (AddCommGroup (ℕ →₀ ℝ)) +instance : Module ℝ FiniteEuclidean := inferInstanceAs (Module ℝ (ℕ →₀ ℝ)) +def coords (x : FiniteEuclidean) : ℕ →₀ ℝ := x + +def product (x y : FiniteEuclidean) : ℝ := + (coords x).sum (fun n r => r*coords y n) +lemma product_eq_sum (x y : FiniteEuclidean) {s : Finset ℕ} + (hx : (coords x).support ⊆ s) : product x y=∑ n∈s,coords x n*coords y n := + Finsupp.sum_of_support_subset _ hx _ (by simp) +instance core : InnerProductSpace.Core ℝ FiniteEuclidean where + inner := product + conj_inner_symm x y := by + change product y x=product x y + rw [product_eq_sum y x ((Finset.subset_union_right : (coords y).support ⊆ (coords x).support ∪ (coords y).support)), + product_eq_sum x y ((Finset.subset_union_left : (coords x).support ⊆ (coords x).support ∪ (coords y).support))] + apply Finset.sum_congr rfl + intro n _; ring + re_inner_nonneg x := by + change 0 ≤ (coords x).sum (fun n r => r*coords x n) + exact Finset.sum_nonneg (fun n _ => mul_self_nonneg _) + add_left x y z := by + change ((coords x)+(coords y)).sum _ = _ + exact Finsupp.sum_add_index (by simp) (by intro n _ r t; exact add_mul _ _ _) + smul_left x y r := by + change (r • coords x).sum (fun n t => t*coords y n)=r*product x y + rw [Finsupp.sum_smul_index (by simp)] + simp only [product,Finsupp.mul_sum,mul_assoc] + definite x h := by + change (coords x).sum (fun n r => r*coords x n)=0 at h + have hs : ∀ n∈(coords x).support,coords x n*coords x n=0 := + (Finset.sum_eq_zero_iff_of_nonneg (fun n _ => mul_self_nonneg _)).mp h + apply Finsupp.ext + intro n + by_cases hn : n∈(coords x).support + · exact mul_self_eq_zero.mp (hs n hn) + · exact Finsupp.notMem_support_iff.mp hn +instance : NormedAddCommGroup FiniteEuclidean := InnerProductSpace.Core.toNormedAddCommGroup (𝕜:=ℝ) +instance : InnerProductSpace ℝ FiniteEuclidean := InnerProductSpace.ofCore core.toCore +lemma norm_sq (x : FiniteEuclidean) : ‖x‖^2=(coords x).sum (fun _ r => r^2) := by + rw [← real_inner_self_eq_norm_sq] + change product x x = _ + simp [product,Finsupp.sum,pow_two] +@[simp] lemma coords_add (x y : FiniteEuclidean) : coords (x+y)=coords x+coords y := rfl +@[simp] lemma coords_sub (x y : FiniteEuclidean) : coords (x-y)=coords x-coords y := rfl +@[simp] lemma coords_smul (c : ℝ) (x : FiniteEuclidean) : coords (c • x)=c • coords x := rfl + +def reindex (f : ℕ → ℕ) (hf : Function.Injective f) : FiniteEuclidean →ₗᵢ[ℝ] FiniteEuclidean where + toLinearMap := + { toFun := fun x => (coords x).mapDomain f + map_add' := fun x y => Finsupp.mapDomain_add + map_smul' := fun c x => Finsupp.mapDomain_smul c (coords x) } + norm_map' x := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + rw [norm_sq,norm_sq] + exact Finsupp.sum_mapDomain_index_inj hf + +def block (j : ℕ) : FiniteEuclidean →ₗᵢ[ℝ] FiniteEuclidean := + reindex (Nat.pair j) (fun _m _n h => (Nat.pair_eq_pair.mp h).2) +end FiniteEuclidean +end EuclideanRamsey +namespace EuclideanRamsey +namespace FiniteEuclidean +open scoped BigOperators RealInnerProductSpace + +noncomputable def embed (d : ℕ) : EuclideanSpace ℝ (Fin d) →ₗᵢ[ℝ] FiniteEuclidean where + toLinearMap := + { toFun := fun x => (Finsupp.equivFunOnFinite.symm (fun i => x i)).mapDomain Fin.val + map_add' := by + intro x y + change Finsupp.mapDomain _ _ = _ + _ + rw [← Finsupp.mapDomain_add] + congr 1 + ext i; simp + map_smul' := by + intro r x + change Finsupp.mapDomain _ _ = r • (_ : ℕ →₀ ℝ) + rw [← Finsupp.mapDomain_smul] + congr 1 + ext i; simp } + norm_map' x := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + rw [norm_sq,EuclideanSpace.norm_sq_eq] + change (Finsupp.mapDomain Fin.val _).sum _ = _ + rw [Finsupp.sum_mapDomain_index_inj Fin.val_injective] + rw [Finsupp.sum_fintype] + · simp [Real.norm_eq_abs,sq_abs] + · intro _; simp + +@[simp] lemma embed_apply (d : ℕ) (x : EuclideanSpace ℝ (Fin d)) (i : Fin d) : + coords (embed d x) i.val=x i := by + exact Finsupp.mapDomain_apply_of_injective Fin.val_injective _ i + +lemma embed_outside (d : ℕ) (x : EuclideanSpace ℝ (Fin d)) (n : ℕ) (hn : d≤n) : + coords (embed d x) n=0 := by + apply Finsupp.mapDomain_of_notMem_range + rintro ⟨i,rfl⟩ + exact (not_le_of_gt i.isLt) hn + +lemma extend_pair {s d : ℕ} (a : Fin s → EuclideanSpace ℝ (Fin d)) (i j : Fin s) + (z z' : FiniteEuclidean) (h : ‖z'-z‖=‖a j-a i‖) : + ∃ b : Fin s → FiniteEuclidean,b i=z ∧ b j=z' ∧ + ∀ k l,‖b k-b l‖=‖a k-a l‖ := by + let e := embed d + let v := e (a j-a i) + let w := z'-z + let R := (ℝ ∙ (v-w))ᗮ.reflection + refine ⟨fun k => z+R (e (a k-a i)),by simp,?_,?_⟩ + · have he : R v=w := Submodule.reflection_sub (by rw [show ‖v‖=‖a j-a i‖ from e.norm_map _]; exact h.symm) + simpa [v,w] using congrArg (fun t => z+t) he + · intro k l + simp only [add_sub_add_left_eq_sub,← map_sub,sub_sub_sub_cancel_right, + LinearIsometryEquiv.norm_map,LinearIsometry.norm_map] + +lemma inner_reindex (f : ℕ → ℕ) (hf : Function.Injective f) (x y : FiniteEuclidean) : + ⟪reindex f hf x,reindex f hf y⟫=⟪x,y⟫ := + (reindex f hf).inner_map_map x y + +lemma inner_block_ne (i j : ℕ) (hij : i≠j) (x y : FiniteEuclidean) : + ⟪block i x,block j y⟫=0 := by + change product (block i x) (block j y)=0 + unfold product + change ((coords x).mapDomain (Nat.pair i)).sum + (fun n r => r*((coords y).mapDomain (Nat.pair j)) n)=0 + rw [Finsupp.sum_mapDomain_index_inj (fun _ _ h => (Nat.pair_eq_pair.mp h).2)] + apply Finset.sum_eq_zero + intro n hn + dsimp only + rw [Finsupp.mapDomain_of_notMem_range] + · simp + · rintro ⟨m,hm⟩ + exact hij (Nat.pair_eq_pair.mp hm).1.symm + +noncomputable def flatten (l : List FiniteEuclidean) : FiniteEuclidean := + ∑ i : Fin l.length,block i (l.get i) + +lemma norm_sum_blocks {n : ℕ} (x : Fin n → FiniteEuclidean) : + ‖∑ i : Fin n,block i (x i)‖^2=∑ i,‖x i‖^2 := by + rw [← real_inner_self_eq_norm_sq,inner_sum] + apply Finset.sum_congr rfl + intro i hi + rw [sum_inner] + rw [Finset.sum_eq_single i] + · exact (block i).inner_map_map _ _ |>.trans (real_inner_self_eq_norm_sq _) + · intro j _ hji + exact inner_block_ne j i (fun he => hji (Fin.ext he)) _ _ + · simp + +lemma flatten_distance (l k : List FiniteEuclidean) (h : l.length=k.length) : + ‖flatten l-flatten k‖^2 = ∑ i : Fin l.length,‖l.get i-k.get (i.cast h)‖^2 := by + have he : flatten l-flatten k = ∑ i : Fin l.length,block i (l.get i-k.get (i.cast h)) := by + unfold flatten + have hk : (∑ i : Fin k.length,block i (k.get i))= + ∑ i : Fin l.length,block i (k.get (i.cast h)) := by + exact Fintype.sum_equiv (finCongr h).symm _ _ (by intro i; rfl) + rw [hk,← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i _ + exact (map_sub (block i) _ _).symm + rw [he,norm_sum_blocks] +end FiniteEuclidean +end EuclideanRamsey +namespace EuclideanRamsey +namespace FiniteEuclidean +open scoped BigOperators RealInnerProductSpace + +noncomputable def unit (n : ℕ) : FiniteEuclidean := Finsupp.single n 1 +lemma norm_unit (n : ℕ) : ‖unit n‖=1 := by + apply (sq_eq_sq₀ (norm_nonneg _) zero_le_one).mp + rw [norm_sq] + simp [unit,coords] +lemma inner_unit (x : FiniteEuclidean) (n : ℕ) : ⟪x,unit n⟫=coords x n := by + rw [real_inner_comm] + change product (unit n) x=coords x n + simp [product,unit,coords] + +lemma common_vertex (r : ℝ) (hr : 0 < r) (x y : FiniteEuclidean) (hxy : ‖y-x‖≤2*r) : + ∃ z : FiniteEuclidean,‖z-x‖=r ∧ ‖z-y‖=r := by + classical + let v := y-x + obtain ⟨n,hn⟩ := (coords v).support.exists_notMem + have hz : coords v n=0 := Finsupp.notMem_support_iff.mp hn + let e := unit n + have he : ‖e‖=1 := norm_unit n + have hv : ⟪v,e⟫=0 := by simpa [e] using (inner_unit v n).trans hz + let t := Real.sqrt (r^2-‖v‖^2/4) + have ht0 : 0≤r^2-‖v‖^2/4 := by + have hv0 := norm_nonneg v + change ‖v‖≤2*r at hxy + nlinarith [sq_nonneg (2*r-‖v‖)] + have ht : t^2=r^2-‖v‖^2/4 := Real.sq_sqrt ht0 + refine ⟨x+(1/2:ℝ)•v+t•e,?_,?_⟩ + · apply (sq_eq_sq₀ (norm_nonneg _) hr.le).mp + have heq : x+(1/2:ℝ)•v+t•e-x=(1/2:ℝ)•v+t•e := by abel + rw [heq,norm_add_sq_real] + rw [norm_smul,norm_smul,he,real_inner_smul_left,real_inner_smul_right,hv] + simp only [Real.norm_eq_abs,sq_abs,mul_pow] + nlinarith + · apply (sq_eq_sq₀ (norm_nonneg _) hr.le).mp + have heq : x+(1/2:ℝ)•v+t•e-y=(-(1/2):ℝ)•v+t•e := by + have : y=x+v := by dsimp [v]; abel + rw [this] + module + rw [heq,norm_add_sq_real] + rw [norm_smul,norm_smul,he,real_inner_smul_left,real_inner_smul_right,hv] + simp only [Real.norm_eq_abs,mul_pow,sq_abs] + nlinarith + +lemma unit_distance_constant {Y : Type uValue} (r : ℝ) (hr : 0 < r) + (f : FiniteEuclidean → Y) (hf : ∀ x y,‖x-y‖=r → f x=f y) (x y : FiniteEuclidean) : + f x=f y := by + have hsmall (x y : FiniteEuclidean) (h : ‖y-x‖≤2*r) : f x=f y := by + obtain ⟨z,hz,hz'⟩ := common_vertex r hr x y h + exact (hf z x hz).symm.trans (hf z y hz') + have hl : IsLocallyConstant f := by + apply (IsLocallyConstant.iff_exists_open f).mpr + intro x + refine ⟨Metric.ball x (2*r),Metric.isOpen_ball,Metric.mem_ball_self (by positivity),?_⟩ + intro y hy + exact (hsmall x y (by exact (show ‖y-x‖<2*r by simpa only [Metric.mem_ball,dist_eq_norm] using hy).le)).symm + exact hl.apply_eq_of_isPreconnected isPreconnected_univ (Set.mem_univ x) (Set.mem_univ y) +end FiniteEuclidean +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/GramCompletion.lean b/lean/OAI/Combinatorics/EuclideanRamsey/GramCompletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8adf3dd1f27d342cde93f1b6e8575e2b395a767 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/GramCompletion.lean @@ -0,0 +1,293 @@ +import OAI.Combinatorics.EuclideanRamsey.SignedRows + +namespace OAI + +universe uIndex uRow uColor + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators + +open Matrix +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +namespace EuclideanRamsey +lemma trace_gram_complement {ι : Type uIndex} [Fintype ι] [DecidableEq ι] + (B : Matrix ι ι ℝ) (hB : B.PosSemidef) (η : ℝ) (hη : B.trace ≤ η) : + (η • (1 : Matrix ι ι ℝ)-B).PosSemidef := by + let e := Unitary.conjStarAlgAut ℝ (Matrix ι ι ℝ) hB.1.eigenvectorUnitary + have he (i : ι) : hB.1.eigenvalues i ≤ η := by + apply le_trans _ hη + rw [hB.1.trace_eq_sum_eigenvalues] + simpa using (Finset.single_le_sum (fun j _ => hB.eigenvalues_nonneg j) (Finset.mem_univ i)) + have hD : (diagonal (fun i => η-hB.1.eigenvalues i)).PosSemidef := + posSemidef_diagonal_iff.mpr (fun i => sub_nonneg.mpr (he i)) + have hd : e (diagonal (fun i => η-hB.1.eigenvalues i)) = η • 1-B := by + have hr : diagonal (fun i => η-hB.1.eigenvalues i) = + η • (1 : Matrix ι ι ℝ)-diagonal hB.1.eigenvalues := by + ext i j + by_cases h : i=j <;> simp [h] + rw [hr,map_sub,map_smul,map_one] + congr 1 + exact hB.1.spectral_theorem.symm + rw [← hd] + exact hD.mul_mul_conjTranspose_same _ + +lemma exists_gram_sqrt {ι : Type uIndex} [Fintype ι] [DecidableEq ι] + (P : Matrix ι ι ℝ) (hP : P.PosSemidef) : + ∃ R : Matrix ι ι ℝ,R*R.transpose=P := by + let R := CFC.sqrt P + have hr : R.PosSemidef := Matrix.nonneg_iff_posSemidef.mp (CFC.sqrt_nonneg P) + refine ⟨R,?_⟩ + rw [← Matrix.conjTranspose_eq_transpose_of_trivial,hr.1.eq] + exact CFC.sqrt_mul_sqrt_self P hP.nonneg + +lemma gram_fromCols {ι : Type uIndex} {τ : Type uRow} {κ : Type uColor} [Fintype τ] [Fintype κ] + (U : Matrix ι τ ℝ) (R : Matrix ι κ ℝ) : + (U.fromCols R)*(U.fromCols R).transpose = U*U.transpose+R*R.transpose := by + ext i j + simp [Matrix.mul_apply,Matrix.fromCols,Matrix.transpose_apply,Fintype.sum_sum_type] + +theorem complete_gram_pair {d : ℕ} {τ : Type uRow} [Fintype τ] + (U V : Matrix (Fin d) τ ℝ) (η : ℝ) (hη : 0 < η) + (hdiff : U*U.transpose-V*V.transpose=1) + (htrace : (V*V.transpose).trace < η) : + ∃ R : Matrix (Fin d) (Fin d) ℝ, + let c := (Real.sqrt (1+η))⁻¹ + (c • (U.fromCols R))*(c • (U.fromCols R)).transpose=1 ∧ + (c • (V.fromCols R))*(c • (V.fromCols R)).transpose= + (η/(1+η)) • (1 : Matrix (Fin d) (Fin d) ℝ) := by + have hB : (V*V.transpose).PosSemidef := by + simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using + Matrix.posSemidef_self_mul_conjTranspose V + obtain ⟨R,hR⟩ := exists_gram_sqrt _ (trace_gram_complement _ hB η htrace.le) + refine ⟨R,?_⟩ + dsimp only + have he (A : Matrix (Fin d) τ ℝ) : + ((Real.sqrt (1+η))⁻¹ • A.fromCols R)* + ((Real.sqrt (1+η))⁻¹ • A.fromCols R).transpose = + (1/(1+η)) • (A*A.transpose+R*R.transpose) := by + rw [Matrix.transpose_smul,Matrix.smul_mul,Matrix.mul_smul,smul_smul,gram_fromCols] + congr 1 + rw [← _root_.mul_inv_rev,← sq,Real.sq_sqrt (by linarith)] + simp + rw [he,he,hR] + have hU : U*U.transpose+(η • 1-V*V.transpose)=(1+η) • (1 : Matrix (Fin d) (Fin d) ℝ) := by + rw [add_smul,one_smul,← hdiff] + abel + rw [hU,smul_smul,one_div_mul_cancel (by linarith : 1+η ≠ 0),one_smul] + constructor + · rfl + · have hv : V*V.transpose+(η • 1-V*V.transpose)=η • (1 : Matrix (Fin d) (Fin d) ℝ) := by abel + rw [hv,smul_smul] + congr 1 + ring +end EuclideanRamsey + +namespace EuclideanRamsey +open Matrix +lemma row_gram_distance {d : ℕ} {τ : Type uRow} [Fintype τ] + (v : τ → ℝ) (U : Matrix (Fin d) τ ℝ) (q : ℝ) + (hU : U*U.transpose=q • (1 : Matrix (Fin d) (Fin d) ℝ)) + (a b : Fin d → ℝ) : + (∑ x,((v x+∑ j,a j*U j x)-(v x+∑ j,b j*U j x))^2) = + q*(∑ j,(a j-b j)^2) := by + have he (x : τ) : (v x+∑ j,a j*U j x)-(v x+∑ j,b j*U j x) = + (U.transpose *ᵥ (a-b)) x := by + simp only [Matrix.mulVec,Matrix.transpose_apply,dotProduct,Pi.sub_apply, + mul_sub,Finset.sum_sub_distrib] + simp only [mul_comm] + ring + simp only [he,pow_two] + change (U.transpose *ᵥ (a-b)) ⬝ᵥ (U.transpose *ᵥ (a-b)) = _ + have hquad : (U.transpose *ᵥ (a-b)) ⬝ᵥ (U.transpose *ᵥ (a-b)) = + (a-b) ⬝ᵥ ((U*U.transpose) *ᵥ (a-b)) := by + rw [← Matrix.mulVec_mulVec,Matrix.dotProduct_mulVec (a-b) U] + congr 1 + exact (Matrix.vecMul_transpose U.transpose (a-b)).symm + rw [hquad,hU,Matrix.smul_mulVec,Matrix.one_mulVec,dotProduct_smul] + simp only [smul_eq_mul,dotProduct,Pi.sub_apply] + +theorem two_scale_of_signed_rows {α : Type} [DecidableEq α] {d s : ℕ} + (hd : 0 < d) (hs : 0 < s) (a : Fin s → EuclideanSpace ℝ (Fin d)) + (v : α → ℝ) (g : α → Fin d → ℝ) (f : α →₀ ℚ) + (ζ η : ℝ) (hζ : 0 < ζ) (hη : 0 < η) + (heval : ∀ i,f.mapDomain (fun x => v x+∑ j,a i j*g x j)=0) + (hmom : ∀ j l,f.sum (fun x q => (q:ℝ)*g x j*g x l)=ζ*(if j=l then 1 else 0)) + (hneg : f.sum (fun x q => max (-(q:ℝ)) 0*(∑ j,(g x j)^2)) < η*ζ) : + ∃ (ℓ : ℕ),1 ≤ ℓ ∧ ∃ (f' g' : Fin s → EuclideanSpace ℝ (Fin ℓ)), + (∀ i j,‖f' i-f' j‖^2=‖a i-a j‖^2) ∧ + (∀ i j,‖g' i-g' j‖^2=(η/(1+η))*‖a i-a j‖^2) ∧ + ∀ i,∃ σ : Equiv.Perm (Fin ℓ),∀ x,g' i (σ x)=f' i x := by + classical + obtain ⟨τ,hτ,vp,vn,U,V,hdiff,htrace,hperm⟩ := + normalized_signed_rows hs (fun i j => a i j) v g f ζ η hζ heval hmom hneg + let := hτ + obtain ⟨R,hR1,hR2⟩ := complete_gram_pair U V η hη hdiff htrace + let c := (Real.sqrt (1+η))⁻¹ + let Up := c • U.fromCols R + let Un := c • V.fromCols R + let cp : τ ⊕ Fin d → ℝ := fun x => c*Sum.elim vp (fun _ => 0) x + let cn : τ ⊕ Fin d → ℝ := fun x => c*Sum.elim vn (fun _ => 0) x + let ip (i : Fin s) (x : τ ⊕ Fin d) := cp x+∑ j,a i j*Up j x + let ineg (i : Fin s) (x : τ ⊕ Fin d) := cn x+∑ j,a i j*Un j x + have hperm' (i : Fin s) : ∃ σ : Equiv.Perm (τ ⊕ Fin d),∀ x,ineg i (σ x)=ip i x := by + obtain ⟨σ,hσ⟩ := hperm i + refine ⟨Equiv.sumCongr σ (Equiv.refl _),?_⟩ + intro x + cases x with + | inl x => + have h := congrArg (fun r : ℝ => c*r) (hσ x) + simpa [ineg,ip,cn,cp,Up,Un,Finset.mul_sum,mul_add,mul_assoc,mul_comm,mul_left_comm] using h + | inr x => simp [ineg,ip,cn,cp,Up,Un] + let ℓ := Fintype.card (τ ⊕ Fin d) + let e := Fintype.equivFin (τ ⊕ Fin d) + let fp (i : Fin s) : EuclideanSpace ℝ (Fin ℓ) := WithLp.toLp 2 (fun x => ip i (e.symm x)) + let fn (i : Fin s) : EuclideanSpace ℝ (Fin ℓ) := WithLp.toLp 2 (fun x => ineg i (e.symm x)) + have hd' : Nonempty (τ ⊕ Fin d) := ⟨Sum.inr ⟨0,hd⟩⟩ + refine ⟨ℓ,Fintype.card_pos_iff.mpr hd',fp,fn,?_,?_,?_⟩ + · intro i j + have h := row_gram_distance cp Up 1 (by simpa only [one_smul] using hR1) (a i) (a j) + rw [one_mul] at h + simp only [EuclideanSpace.norm_sq_eq,Real.norm_eq_abs,sq_abs,fp,WithLp.ofLp_sub, + Pi.sub_apply] + rw [e.symm.sum_comp (fun x => (ip i x-ip j x)^2)] + exact h + · intro i j + have h := row_gram_distance cn Un (η/(1+η)) hR2 (a i) (a j) + simp only [EuclideanSpace.norm_sq_eq,Real.norm_eq_abs,sq_abs,fn,WithLp.ofLp_sub, + Pi.sub_apply] + rw [e.symm.sum_comp (fun x => (ineg i x-ineg j x)^2)] + exact h + · intro i + obtain ⟨σ,hσ⟩ := hperm' i + refine ⟨e.symm.trans (σ.trans e),?_⟩ + intro x + simpa [fp,fn,Equiv.trans_apply] using hσ (e.symm x) +end EuclideanRamsey + +namespace EuclideanRamsey +open scoped BigOperators +lemma evaluation_coset_pushforward {k : ℕ} (φ : Lattice k →+ ℝ) + (μ : LatticeRing k) (hμ : cosetPushforward φ.ker μ=0) (n : ℝ) : + μ.coeff.mapDomain (fun x => φ x/n)=0 := by + let f := QuotientAddGroup.lift φ.ker φ le_rfl + have he : (fun x => φ x/n) = (fun y => f y/n) ∘ QuotientAddGroup.mk' φ.ker := by + funext x + rfl + rw [he,Finsupp.mapDomain_comp] + change Finsupp.mapDomain _ (cosetPushforward φ.ker μ) = 0 + rw [hμ,Finsupp.mapDomain_zero] + +lemma lattice_affine_evaluation {k d s : ℕ} (a : Fin s → Space d) + (w : Fin k → AffineVector d) (i : Fin s) (γ : Lattice k) (n : ℝ) : + ((rowEvaluation a i).comp (Fintype.linearCombination ℚ w)) (rationalize γ)/n = + (∑ j,(γ j:ℝ)/n*w j none)+ + ∑ α,a i α*(∑ j,(γ j:ℝ)/n*w j (some α)) := by + simp only [LinearMap.comp_apply,Fintype.linearCombination_apply,map_sum,map_smul, + rationalize,AddMonoidHom.coe_mk,Rat.smul_def,rowEvaluation,LinearMap.coe_mk, + AddHom.coe_mk,Fintype.sum_option,realAugmented,one_mul] + change (∑ j,(γ j:ℝ)*(w j none+∑ α,a i α*w j (some α)))/n = _ + simp only [div_eq_mul_inv,mul_add,add_mul,Finset.sum_add_distrib,Finset.sum_mul,Finset.mul_sum] + congr 1 + · apply Finset.sum_congr rfl + intro j _ + ring + · rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro α _ + apply Finset.sum_congr rfl + intro j _ + ring + +lemma scaled_second_moment {k d : ℕ} (μ : LatticeRing k) (n : ℕ) + (C : Matrix (Fin k) (Fin k) ℚ) (U : Matrix (Fin d) (Fin k) ℝ) + (ζ : ℚ) (hsecond : ∀ j l,secondMoment μ j l/(n:ℚ)^2 = ζ*C j l) + (α β : Fin d) : + μ.coeff.sum (fun γ q => (q:ℝ)*(∑ j,U α j*latticeSample n γ j)* + (∑ l,U β l*latticeSample n γ l)) = + (ζ:ℝ)*(U*(C.map (Rat.cast : ℚ → ℝ))*U.transpose) α β := by + have hm (j l : Fin k) : ∑ γ ∈ μ.coeff.support, + (μ.coeff γ:ℝ)*latticeSample n γ j*latticeSample n γ l = (ζ:ℝ)*(C j l:ℝ) := by + have h := congrArg (Rat.cast : ℚ → ℝ) (hsecond j l) + simp only [Rat.cast_div,Rat.cast_pow,Rat.cast_natCast,Rat.cast_mul,secondMoment, + Finsupp.sum,Rat.cast_sum,Rat.cast_intCast] at h + rw [← h,Finset.sum_div] + apply Finset.sum_congr rfl + intro γ hγ + simp only [latticeSample] + ring + simp only [Finsupp.sum,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] + conv_lhs => arg 2; ext j; rw [Finset.sum_comm] + have hr (j l : Fin k) : (∑ γ ∈ μ.coeff.support, + (μ.coeff γ:ℝ)*(U α j*latticeSample n γ j)*(U β l*latticeSample n γ l)) = + U α j*U β l*((ζ:ℝ)*(C j l:ℝ)) := by + rw [← hm,Finset.mul_sum] + apply Finset.sum_congr rfl + intro γ hγ + ring + simp only [hr] + change _ = (ζ:ℝ)*(∑ l,(∑ j,U α j*(C j l:ℝ))*U β l) + simp only [Finset.mul_sum,Finset.sum_mul] + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro l _ + ring + +theorem realCriterion_two_scale {s d : ℕ} (a : Fin s → Space d) + (hd : 1 ≤ d) (hs : 1 ≤ s) (h : RealCriterion a) (η : ℝ) (hη : 0 < η) : + ∃ (ℓ : ℕ),1 ≤ ℓ ∧ ∃ (f g : Fin s → Space ℓ), + (∀ i j,‖f i-f j‖^2=‖a i-a j‖^2) ∧ + (∀ i j,‖g i-g j‖^2=(η/(1+η))*‖a i-a j‖^2) ∧ + ∀ i,∃ σ : Equiv.Perm (Fin ℓ),∀ x,g i (σ x)=f i x := by + classical + obtain ⟨k,w,C,hk,hC,hU,hquot⟩ := realCriterion_lattice a hd h + let U : Matrix (Fin d) (Fin k) ℝ := fun α j => w j (some α) + let φ (i : Fin s) : Lattice k →+ ℝ := + ((rowEvaluation a i).comp (Fintype.linearCombination ℚ w)).toAddMonoidHom.comp rationalize + let Λ (i : Fin s) := (φ i).ker + obtain ⟨ν,hcos,hzero,hfirst,hsecond⟩ := + finite_lattice_identity k s hk hs Λ C hC hquot + obtain ⟨n,μ,ζ,hn,hζ,hcos,_,_,hmom,hneg⟩ := + rational_smoothing hd Λ ν C U hC hU hcos hzero hfirst hsecond η hη + let v (γ : Lattice k) : ℝ := ∑ j,(γ j:ℝ)/(n:ℝ)*w j none + let g (γ : Lattice k) (α : Fin d) : ℝ := ∑ j,U α j*latticeSample n γ j + have heval (i : Fin s) : μ.coeff.mapDomain (fun γ => v γ+∑ α,a i α*g γ α)=0 := by + have he := evaluation_coset_pushforward (φ i) μ (hcos i) (n:ℝ) + have heq : (fun γ => φ i γ/(n:ℝ)) = (fun γ => v γ+∑ α,a i α*g γ α) := by + funext γ + simpa only [φ,v,g,U,latticeSample,mul_comm,AddMonoidHom.comp_apply,LinearMap.toAddMonoidHom_coe] using lattice_affine_evaluation a w i γ (n:ℝ) + rwa [heq] at he + have hmoment (α β : Fin d) : μ.coeff.sum (fun γ q => (q:ℝ)*g γ α*g γ β) = + (ζ:ℝ)*(if α=β then 1 else 0) := by + have he := scaled_second_moment μ n C U ζ hmom α β + rw [hU] at he + exact he + have hnegative : μ.coeff.sum (fun γ q => max (-(q:ℝ)) 0*(∑ α,(g γ α)^2)) < η*(ζ:ℝ) := by + rw [tsum_eq_sum (s := μ.coeff.support)] at hneg + · exact hneg + · intro γ hγ + have hz := Finsupp.notMem_support_iff.mp hγ + simp [hz] + exact two_scale_of_signed_rows hd hs a v g μ.coeff (ζ:ℝ) η + (by exact_mod_cast hζ) hη heval hmoment hnegative + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Hessian.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Hessian.lean new file mode 100644 index 0000000000000000000000000000000000000000..edc1e798b492618b76bfa396ee9be410fa3c0e35 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Hessian.lean @@ -0,0 +1,233 @@ +import OAI.Combinatorics.EuclideanRamsey.SmoothingKernel + +namespace OAI + +universe uDomain uCodomain uIndex uColor uAction + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial + +open scoped BigOperators +open Matrix MeasureTheory +namespace EuclideanRamsey + +section Hessian +variable {E : Type uDomain} {F : Type uCodomain} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] + +def hessianB (f : E → ℝ) (x : E) : E →L[ℝ] E →L[ℝ] ℝ := + fderiv ℝ (fun y => fderiv ℝ f y) x + +lemma hessianB_eq (f : E → ℝ) (x v w : E) : + hessianB f x v w = iteratedFDeriv ℝ 2 f x ![v,w] := by + rw [iteratedFDeriv_succ_apply_right, iteratedFDeriv_one_apply] + rfl + +lemma hessianB_linear_comp {f : F → ℝ} (hf : ContDiff ℝ (⊤ : ℕ∞) f) + (L : E →L[ℝ] F) (x v w : E) : + hessianB (f ∘ L) x v w = hessianB f (L x) (L v) (L w) := by + have hG : (fun y => fderiv ℝ (f ∘ L) y) = + (fun y => (fderiv ℝ f (L y)).comp L) := by + funext y + exact ((hf.differentiable (by simp) (L y)).hasFDerivAt.comp y L.hasFDerivAt).fderiv + have hd : Differentiable ℝ (fun y => fderiv ℝ f y) := + (hf.fderiv_right (m := (⊤ : ℕ∞)) (by simp)).differentiable (by simp) + have h := (((hd (L x)).hasFDerivAt.comp x L.hasFDerivAt).clm_comp + (hasFDerivAt_const L x)) + dsimp only [Function.comp_def] at h + unfold hessianB + rw [hG, h.fderiv] + simp + +lemma hessianB_mul {f g : E → ℝ} (hf : ContDiff ℝ (⊤ : ℕ∞) f) + (hg : ContDiff ℝ (⊤ : ℕ∞) g) (x v w : E) : + hessianB (fun y => f y*g y) x v w = + f x*hessianB g x v w + g x*hessianB f x v w + + fderiv ℝ f x v*fderiv ℝ g x w + fderiv ℝ g x v*fderiv ℝ f x w := by + have hf' (x : E) := (hf.differentiable (by simp) x).hasFDerivAt + have hg' (x : E) := (hg.differentiable (by simp) x).hasFDerivAt + have hG : (fun y => fderiv ℝ (fun z => f z*g z) y) = + (fun y => f y • fderiv ℝ g y + g y • fderiv ℝ f y) := by + funext y + exact ((hf' y).mul (hg' y)).fderiv + have hfd : Differentiable ℝ (fun y => fderiv ℝ f y) := + (hf.fderiv_right (m := (⊤ : ℕ∞)) (by simp)).differentiable (by simp) + have hgd : Differentiable ℝ (fun y => fderiv ℝ g y) := + (hg.fderiv_right (m := (⊤ : ℕ∞)) (by simp)).differentiable (by simp) + have hd := ((hf' x).smul (hgd x).hasFDerivAt).add + ((hg' x).smul (hfd x).hasFDerivAt) + unfold hessianB + rw [hG] + change ((fderiv ℝ ((f • fun y => fderiv ℝ g y) + g • fun y => fderiv ℝ f y) x) v) w = _ + rw [hd.fderiv] + simp only [_root_.add_apply, _root_.smul_apply, + ContinuousLinearMap.smulRight_apply, smul_eq_mul] + ring + +lemma hessianB_prod_horizontal {f : E → ℝ} {g : F → ℝ} + (hf : ContDiff ℝ (⊤ : ℕ∞) f) (hg : ContDiff ℝ (⊤ : ℕ∞) g) + (x : E × F) (v w : E) : + hessianB (fun x : E × F => f x.1*g x.2) x (v,0) (w,0) = + g x.2*hessianB f x.1 v w := by + have hf1 : ContDiff ℝ (⊤ : ℕ∞) (fun x : E×F => f x.1) := hf.comp contDiff_fst + have hg2 : ContDiff ℝ (⊤ : ℕ∞) (fun x : E×F => g x.2) := hg.comp contDiff_snd + rw [hessianB_mul hf1 hg2] + rw [show (fun x : E×F => f x.1) = f ∘ ContinuousLinearMap.fst ℝ E F from rfl, + show (fun x : E×F => g x.2) = g ∘ ContinuousLinearMap.snd ℝ E F from rfl, + hessianB_linear_comp hf, hessianB_linear_comp hg] + have hfg := ((hg.differentiable (by simp) x.2).hasFDerivAt.comp x + (ContinuousLinearMap.snd ℝ E F).hasFDerivAt).fderiv + change fderiv ℝ (_ ∘ ⇑(ContinuousLinearMap.snd ℝ E F)) x = _ at hfg + rw [hfg] + simp + +lemma hessianB_prod_vertical {f : E → ℝ} {g : F → ℝ} + (hf : ContDiff ℝ (⊤ : ℕ∞) f) (hg : ContDiff ℝ (⊤ : ℕ∞) g) + (x : E × F) (v w : F) : + hessianB (fun x : E × F => f x.1*g x.2) x (0,v) (0,w) = + f x.1*hessianB g x.2 v w := by + have hf1 : ContDiff ℝ (⊤ : ℕ∞) (fun x : E×F => f x.1) := hf.comp contDiff_fst + have hg2 : ContDiff ℝ (⊤ : ℕ∞) (fun x : E×F => g x.2) := hg.comp contDiff_snd + rw [hessianB_mul hf1 hg2] + rw [show (fun x : E×F => f x.1) = f ∘ ContinuousLinearMap.fst ℝ E F from rfl, + show (fun x : E×F => g x.2) = g ∘ ContinuousLinearMap.snd ℝ E F from rfl, + hessianB_linear_comp hf, hessianB_linear_comp hg] + have hfg := ((hf.differentiable (by simp) x.1).hasFDerivAt.comp x + (ContinuousLinearMap.fst ℝ E F).hasFDerivAt).fderiv + change fderiv ℝ (_ ∘ ⇑(ContinuousLinearMap.fst ℝ E F)) x = _ at hfg + rw [hfg] + simp + +lemma hessianB_continuous {f : E → ℝ} (hf : ContDiff ℝ (⊤ : ℕ∞) f) : + Continuous (hessianB f) := + (hf.fderiv_right (m := (⊤ : ℕ∞)) (by simp)).continuous_fderiv (by simp) + +lemma hessianB_compact {f : E → ℝ} (hf : HasCompactSupport f) : + HasCompactSupport (hessianB f) := (hf.fderiv ℝ).fderiv ℝ + +lemma hessianB_apply_continuous {f : E → ℝ} (hf : ContDiff ℝ (⊤ : ℕ∞) f) + (v w : E) : Continuous (fun x => hessianB f x v w) := + ((hessianB_continuous hf).clm_apply continuous_const).clm_apply continuous_const + +lemma hessianB_apply_compact {f : E → ℝ} (hf : HasCompactSupport f) + (v w : E) : HasCompactSupport (fun x => hessianB f x v w) := by + apply (hessianB_compact hf).comp_left (g := fun B => B v w) + simp + +end Hessian + +section Trace +variable {E : Type uDomain} {ι : Type uIndex} {κ : Type uColor} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [Fintype ι] [Fintype κ] + +lemma bilinear_orthonormal_trace (B : E →L[ℝ] E →L[ℝ] ℝ) + (e : OrthonormalBasis ι ℝ E) (f : OrthonormalBasis κ ℝ E) : + ∑ i, B (e i) (e i) = ∑ j, B (f j) (f j) := by + classical + have hex (x y : E) : B x y = ∑ j, ∑ l, + (inner ℝ (f j) x * inner ℝ (f l) y) * B (f j) (f l) := by + conv_lhs => rw [← f.sum_repr x, ← f.sum_repr y] + simp only [map_sum, map_smul, _root_.sum_apply, + _root_.smul_apply, OrthonormalBasis.repr_apply_apply, smul_eq_mul, + Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro l hl + ring + conv_lhs => arg 2; intro i; rw [hex] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + rw [Finset.sum_comm] + simp_rw [← Finset.sum_mul] + have hsum (l : κ) : ∑ i, inner ℝ (f j) (e i) * inner ℝ (f l) (e i) = + if j=l then 1 else 0 := by + simpa only [real_inner_comm (f l), f.inner_eq_ite, eq_comm] using e.sum_inner_mul_inner (f j) (f l) + simp_rw [hsum] + simp + +end Trace + +section MatrixContraction + +lemma pi_basis_expansion {n : ℕ} (v : Fin n → ℝ) : + v = ∑ j, v j • Pi.single j (1:ℝ) := by + simpa only [← Pi.single_smul, smul_eq_mul, mul_one] using (Finset.univ_sum_single v).symm + +lemma bilinear_matrix_pushforward {k n : ℕ} + (B : (Fin k → ℝ) →L[ℝ] (Fin k → ℝ) →L[ℝ] ℝ) + (M : Matrix (Fin k) (Fin n) ℝ) (D : Matrix (Fin n) (Fin n) ℝ) : + ∑ j, ∑ l, (M*D*M.transpose) j l * B (Pi.single j 1) (Pi.single l 1) = + ∑ a, ∑ b, D a b * B (fun j => M j a) (fun j => M j b) := by + have hex (v w : Fin k → ℝ) : B v w = ∑ j, ∑ l, + (v j*w l)*B (Pi.single j 1) (Pi.single l 1) := by + conv_lhs => rw [pi_basis_expansion v, pi_basis_expansion w] + simp only [map_sum, map_smul, _root_.sum_apply, + _root_.smul_apply, smul_eq_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro l hl + ring + conv_rhs => arg 2; intro a; arg 2; intro b; rw [hex] + simp only [Matrix.mul_apply, Matrix.transpose_apply, Finset.sum_mul, Finset.mul_sum] + conv_rhs => rw [Finset.sum_comm]; arg 2; intro b; rw [Finset.sum_comm]; arg 2; intro j; rw [Finset.sum_comm] + conv_rhs => rw [Finset.sum_comm]; arg 2; intro j; rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro l hl + apply Finset.sum_congr rfl + intro b hb + apply Finset.sum_congr rfl + intro a ha + ring + +end MatrixContraction + +section Split +variable {E : Type uDomain} {H : Type uAction} [AddCommGroup E] [Module ℝ E] [AddCommGroup H] [Module ℝ H] + +def rightInverseSplit (U : E →ₗ[ℝ] H) (R : H →ₗ[ℝ] E) + (hUR : U.comp R = LinearMap.id) : E ≃ₗ[ℝ] H × LinearMap.ker U where + toFun x := (U x, ⟨x-R (U x), by + change U (x-R (U x)) = 0 + simp only [map_sub, show U (R (U x)) = U x from LinearMap.congr_fun hUR (U x), sub_self]⟩) + invFun v := R v.1 + v.2 + left_inv x := by simp + right_inv v := by + ext + · simp only [map_add, show U (R v.1) = v.1 from LinearMap.congr_fun hUR v.1, + LinearMap.map_coe_ker, add_zero] + · change R v.1 + (v.2:E) - R (U (R v.1 + v.2)) = v.2 + simp only [map_add, show U (R v.1) = v.1 from LinearMap.congr_fun hUR v.1, + LinearMap.map_coe_ker, add_zero] + abel + map_add' v w := by ext <;> simp [map_add] ; abel + map_smul' c x := by ext <;> simp [map_smul, smul_sub] + +@[simp] lemma rightInverseSplit_fst (U : E →ₗ[ℝ] H) (R : H →ₗ[ℝ] E) + (hUR : U.comp R = LinearMap.id) (x : E) : (rightInverseSplit U R hUR x).1 = U x := rfl + +@[simp] lemma rightInverseSplit_apply_R (U : E →ₗ[ℝ] H) (R : H →ₗ[ℝ] E) + (hUR : U.comp R = LinearMap.id) (y : H) : (rightInverseSplit U R hUR (R y)) = (y,0) := by + have h : U (R y) = y := LinearMap.congr_fun hUR y + apply Prod.ext + · exact h + · apply Subtype.ext + change R y - R (U (R y)) = 0 + rw [h, sub_self] + +end Split + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/IndependentTensor.lean b/lean/OAI/Combinatorics/EuclideanRamsey/IndependentTensor.lean new file mode 100644 index 0000000000000000000000000000000000000000..eeb4b279e9142c1111b63e547ee781e51e2cd870 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/IndependentTensor.lean @@ -0,0 +1,203 @@ +import Mathlib.RingTheory.Localization.BaseChange +import Mathlib.RingTheory.Localization.FractionRing +import Mathlib.RingTheory.TensorProduct.MvPolynomial + +namespace OAI + +noncomputable section +open scoped TensorProduct + +namespace EuclideanRamsey.IndependentTensor + +universe u +variable (ι : Type u) + +abbrev Poly := MvPolynomial ι ℚ +abbrev Rat := FractionRing (Poly ι) +abbrev JointPoly := MvPolynomial (ι ⊕ ι) ℚ +abbrev JointField := FractionRing (JointPoly ι) + +def polyToRat : Poly ι →ₐ[ℚ] Rat ι := + IsScalarTower.toAlgHom ℚ (Poly ι) (Rat ι) + +def jointToField : JointPoly ι →ₐ[ℚ] JointField ι := + IsScalarTower.toAlgHom ℚ (JointPoly ι) (JointField ι) + +def leftPolynomialMap : Poly ι →ₐ[ℚ] JointField ι := + (jointToField ι).comp (MvPolynomial.rename Sum.inl) + +def rightPolynomialMap : Poly ι →ₐ[ℚ] JointField ι := + (jointToField ι).comp (MvPolynomial.rename Sum.inr) + +theorem leftPolynomialMap_injective : + Function.Injective (leftPolynomialMap ι) := + (IsFractionRing.injective (JointPoly ι) (JointField ι)).comp + (MvPolynomial.rename_injective Sum.inl Sum.inl_injective) + +theorem rightPolynomialMap_injective : + Function.Injective (rightPolynomialMap ι) := + (IsFractionRing.injective (JointPoly ι) (JointField ι)).comp + (MvPolynomial.rename_injective Sum.inr Sum.inr_injective) + +/-- The first rational-function copy, in the independent left variables. -/ +def leftMap : Rat ι →ₐ[ℚ] JointField ι := + IsFractionRing.liftAlgHom (K := Rat ι) (leftPolynomialMap_injective ι) + +/-- The second rational-function copy, in the independent right variables. -/ +def rightMap : Rat ι →ₐ[ℚ] JointField ι := + IsFractionRing.liftAlgHom (K := Rat ι) (rightPolynomialMap_injective ι) + +@[simp] theorem leftMap_algebraMap (p : Poly ι) : + leftMap ι (algebraMap (Poly ι) (Rat ι) p) = + algebraMap (JointPoly ι) (JointField ι) (MvPolynomial.rename Sum.inl p) := by + exact IsFractionRing.lift_algebraMap (K := Rat ι) + (g := (leftPolynomialMap ι).toRingHom) (leftPolynomialMap_injective ι) p + +@[simp] theorem rightMap_algebraMap (p : Poly ι) : + rightMap ι (algebraMap (Poly ι) (Rat ι) p) = + algebraMap (JointPoly ι) (JointField ι) (MvPolynomial.rename Sum.inr p) := by + exact IsFractionRing.lift_algebraMap (K := Rat ι) + (g := (rightPolynomialMap ι).toRingHom) (rightPolynomialMap_injective ι) p + +@[simp] theorem leftMap_X (i : ι) : + leftMap ι (algebraMap (Poly ι) (Rat ι) (MvPolynomial.X i)) = + algebraMap (JointPoly ι) (JointField ι) (MvPolynomial.X (Sum.inl i)) := by + simp + +@[simp] theorem rightMap_X (i : ι) : + rightMap ι (algebraMap (Poly ι) (Rat ι) (MvPolynomial.X i)) = + algebraMap (JointPoly ι) (JointField ι) (MvPolynomial.X (Sum.inr i)) := by + simp + +/-- The map to the joint rational-function field. -/ +def tensorEmbedding : Rat ι ⊗[ℚ] Rat ι →ₐ[ℚ] JointField ι := + Algebra.TensorProduct.lift (leftMap ι) (rightMap ι) (fun _ _ => Commute.all _ _) + +@[simp] theorem tensorEmbedding_tmul (x y : Rat ι) : + tensorEmbedding ι (x ⊗ₜ[ℚ] y) = leftMap ι x * rightMap ι y := by + rfl + +@[simp] theorem tensorEmbedding_X_tmul_one (i : ι) : + tensorEmbedding ι + ((algebraMap (Poly ι) (Rat ι) (MvPolynomial.X i)) ⊗ₜ[ℚ] 1) = + algebraMap (JointPoly ι) (JointField ι) (MvPolynomial.X (Sum.inl i)) := by + simp + +@[simp] theorem tensorEmbedding_one_tmul_X (i : ι) : + tensorEmbedding ι + (1 ⊗ₜ[ℚ] (algebraMap (Poly ι) (Rat ι) (MvPolynomial.X i))) = + algebraMap (JointPoly ι) (JointField ι) (MvPolynomial.X (Sum.inr i)) := by + simp + +def localizeLeft : Poly ι ⊗[ℚ] Poly ι →ₐ[ℚ] Rat ι ⊗[ℚ] Poly ι := + Algebra.TensorProduct.map (polyToRat ι) (AlgHom.id ℚ (Poly ι)) + +def localizeRight : Rat ι ⊗[ℚ] Poly ι →ₐ[ℚ] Rat ι ⊗[ℚ] Rat ι := + Algebra.TensorProduct.map (AlgHom.id ℚ (Rat ι)) (polyToRat ι) + +def halfEmbedding : Rat ι ⊗[ℚ] Poly ι →ₐ[ℚ] JointField ι := + (tensorEmbedding ι).comp (localizeRight ι) + +def polynomialEmbedding : Poly ι ⊗[ℚ] Poly ι →ₐ[ℚ] JointField ι := + (jointToField ι).comp (MvPolynomial.tensorEquivSum ℚ ι ι ℚ).toAlgHom + +theorem polynomialEmbedding_injective : + Function.Injective (polynomialEmbedding ι) := + (IsFractionRing.injective (JointPoly ι) (JointField ι)).comp + (MvPolynomial.tensorEquivSum ℚ ι ι ℚ).injective + +/-- On polynomials the joint map is the standard polynomial tensor equivalence, +followed by the injective fraction-ring inclusion. -/ +theorem halfEmbedding_comp_localizeLeft : + (halfEmbedding ι).comp (localizeLeft ι) = polynomialEmbedding ι := by + apply Algebra.TensorProduct.ext + · ext i + simp [halfEmbedding, localizeLeft, localizeRight, polyToRat, + polynomialEmbedding, jointToField, IsScalarTower.toAlgHom_apply] + · ext i + simp [halfEmbedding, localizeLeft, localizeRight, polyToRat, + polynomialEmbedding, jointToField, IsScalarTower.toAlgHom_apply] + +/-- First localization: invert all nonzero polynomials in the left factor. +The target map detects zero on the polynomial base, hence on its localization. -/ +theorem halfEmbedding_injective : Function.Injective (halfEmbedding ι) := by + let : Algebra (Poly ι ⊗[ℚ] Poly ι) (Rat ι ⊗[ℚ] Poly ι) := + (localizeLeft ι).toAlgebra + let : IsScalarTower (Poly ι) (Poly ι ⊗[ℚ] Poly ι) (Rat ι ⊗[ℚ] Poly ι) := + IsScalarTower.of_algebraMap_eq + (R := Poly ι) (S := Poly ι ⊗[ℚ] Poly ι) (A := Rat ι ⊗[ℚ] Poly ι) (by + intro p + change algebraMap (Poly ι) (Rat ι) p ⊗ₜ[ℚ] (1 : Poly ι) = + localizeLeft ι (p ⊗ₜ[ℚ] (1 : Poly ι)) + simp [localizeLeft, polyToRat, IsScalarTower.toAlgHom_apply]) + have hcompat : + (algebraMap (Poly ι ⊗[ℚ] Poly ι) (Rat ι ⊗[ℚ] Poly ι)).comp + Algebra.TensorProduct.includeRight.toRingHom = + Algebra.TensorProduct.includeRight.toRingHom := by + apply RingHom.ext + intro p + change localizeLeft ι ((1 : Poly ι) ⊗ₜ[ℚ] p) = (1 : Rat ι) ⊗ₜ[ℚ] p + simp [localizeLeft, polyToRat, IsScalarTower.toAlgHom_apply] + let : IsLocalization + (Algebra.algebraMapSubmonoid (Poly ι ⊗[ℚ] Poly ι) (nonZeroDivisors (Poly ι))) + (Rat ι ⊗[ℚ] Poly ι) := + IsLocalization.tensorProduct_tensorProduct ℚ (Poly ι) + (nonZeroDivisors (Poly ι)) (Rat ι) hcompat + apply IsLocalization.injective_of_map_algebraMap_zero + (M := Algebra.algebraMapSubmonoid (Poly ι ⊗[ℚ] Poly ι) (nonZeroDivisors (Poly ι))) + (S := Rat ι ⊗[ℚ] Poly ι) + (halfEmbedding ι).toRingHom + intro x hx + have hbase : polynomialEmbedding ι x = 0 := by + have heq := AlgHom.congr_fun (halfEmbedding_comp_localizeLeft ι) x + simpa only [AlgHom.comp_apply, RingHom.algebraMap_toAlgebra] using + heq.symm.trans hx + have hxzero : x = 0 := (polynomialEmbedding_injective ι) + (hbase.trans (map_zero (polynomialEmbedding ι)).symm) + simp [hxzero] + +/-- The two independent rational-function copies embed faithfully. -/ +theorem tensorEmbedding_injective : Function.Injective (tensorEmbedding ι) := by + let : Algebra (Rat ι ⊗[ℚ] Poly ι) (Rat ι ⊗[ℚ] Rat ι) := + (localizeRight ι).toAlgebra + let : IsScalarTower (Rat ι) (Rat ι ⊗[ℚ] Poly ι) (Rat ι ⊗[ℚ] Rat ι) := + IsScalarTower.of_algebraMap_eq + (R := Rat ι) (S := Rat ι ⊗[ℚ] Poly ι) (A := Rat ι ⊗[ℚ] Rat ι) (by + intro x + change x ⊗ₜ[ℚ] (1 : Rat ι) = + localizeRight ι (x ⊗ₜ[ℚ] (1 : Poly ι)) + simp [localizeRight, polyToRat, IsScalarTower.toAlgHom_apply]) + have hcompat : + (algebraMap (Rat ι ⊗[ℚ] Poly ι) (Rat ι ⊗[ℚ] Rat ι)).comp + Algebra.TensorProduct.includeRight.toRingHom = + Algebra.TensorProduct.includeRight.toRingHom.comp + (algebraMap (Poly ι) (Rat ι)) := by + apply RingHom.ext + intro p + change localizeRight ι ((1 : Rat ι) ⊗ₜ[ℚ] p) = + (1 : Rat ι) ⊗ₜ[ℚ] algebraMap (Poly ι) (Rat ι) p + simp [localizeRight, polyToRat, IsScalarTower.toAlgHom_apply] + let : IsLocalization + ((nonZeroDivisors (Poly ι)).map + (Algebra.TensorProduct.includeRight (R := ℚ) (A := Rat ι))) + (Rat ι ⊗[ℚ] Rat ι) := + IsLocalization.tensorProduct_tensorProduct_right ℚ (Rat ι) + (nonZeroDivisors (Poly ι)) (Rat ι) hcompat + apply IsLocalization.injective_of_map_algebraMap_zero + (M := (nonZeroDivisors (Poly ι)).map + (Algebra.TensorProduct.includeRight (R := ℚ) (A := Rat ι))) + (S := Rat ι ⊗[ℚ] Rat ι) + (tensorEmbedding ι).toRingHom + intro x hx + have hhalf : halfEmbedding ι x = 0 := by + change halfEmbedding ι x = 0 at hx + exact hx + have hxzero : x = 0 := (halfEmbedding_injective ι) + (hhalf.trans (map_zero (halfEmbedding ι)).symm) + simp [hxzero] + +end EuclideanRamsey.IndependentTensor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/LatticeMoments.lean b/lean/OAI/Combinatorics/EuclideanRamsey/LatticeMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..1dedd15523660daa8a09f3b490d70013cd41a347 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/LatticeMoments.lean @@ -0,0 +1,269 @@ +import OAI.Combinatorics.EuclideanRamsey.SmoothingMatrix + +namespace OAI + +universe uIndex + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix + +open scoped TensorProduct +namespace EuclideanRamsey + +abbrev Lattice (k : ℕ) := Fin k → ℤ +abbrev RationalSpace (k : ℕ) := Fin k → ℚ +abbrev LatticeRing (k : ℕ) := AddMonoidAlgebra ℚ (Lattice k) + +def rationalize {k : ℕ} : Lattice k →+ RationalSpace k where + toFun γ := fun j => (γ j : ℚ) + map_zero' := by ext; simp + map_add' γ δ := by ext; simp + +def latticeSpan {k : ℕ} (Λ : AddSubgroup (Lattice k)) : Submodule ℚ (RationalSpace k) := + Submodule.span ℚ (rationalize '' (Λ : Set (Lattice k))) + +def matrixTensor {k : ℕ} (C : Matrix (Fin k) (Fin k) ℚ) : + RationalSpace k ⊗[ℚ] RationalSpace k := + ∑ a, ∑ b, C a b • ((Pi.single a (1 : ℚ)) ⊗ₜ[ℚ] (Pi.single b (1 : ℚ))) + +def quotientTensor {k : ℕ} (Λ : AddSubgroup (Lattice k)) := + TensorProduct.map (latticeSpan Λ).mkQ (latticeSpan Λ).mkQ + +def mass {k : ℕ} (ν : LatticeRing k) : ℚ := ν.coeff.sum fun _ q => q + +def firstMoment {k : ℕ} (ν : LatticeRing k) (a : Fin k) : ℚ := + ν.coeff.sum fun γ q => q * γ a + +def secondMoment {k : ℕ} (ν : LatticeRing k) (a b : Fin k) : ℚ := + ν.coeff.sum fun γ q => q * γ a * γ b + +def cosetPushforward {k : ℕ} (Λ : AddSubgroup (Lattice k)) (ν : LatticeRing k) : + (Lattice k ⧸ Λ) →₀ ℚ := Finsupp.mapDomain (QuotientAddGroup.mk' Λ) ν.coeff + +def FiniteLatticeIdentity : Prop := + ∀ (k s : ℕ), 1 ≤ k → 1 ≤ s → + ∀ (Λ : Fin s → AddSubgroup (Lattice k)) (C : Matrix (Fin k) (Fin k) ℚ), + C.IsSymm → (∀ i, quotientTensor (Λ i) (matrixTensor C) = 0) → + ∃ ν : LatticeRing k, + (∀ i, cosetPushforward (Λ i) ν = 0) ∧ mass ν = 0 ∧ + (∀ a, firstMoment ν a = 0) ∧ (∀ a b, secondMoment ν a b = C a b) + +section Algebra +variable {k : ℕ} + +instance latticeNoetherian : IsNoetherianRing (LatticeRing k) := + Algebra.FiniteType.isNoetherianRing ℚ (LatticeRing k) + +def augmentation : LatticeRing k →ₐ[ℚ] ℚ := + AddMonoidAlgebra.lift ℚ ℚ (Lattice k) 1 + +def augmentationIdeal : Ideal (LatticeRing k) := RingHom.ker augmentation + +lemma augmentation_eq_mass (x : LatticeRing k) : augmentation x = mass x := by + simp only [augmentation, AddMonoidAlgebra.lift_apply, MonoidHom.one_apply, smul_eq_mul, mul_one, mass] + +@[simp] lemma augmentation_monomial (γ : Lattice k) : + augmentation (AddMonoidAlgebra.single γ 1) = 1 := by + simp [augmentation] + +lemma monomial_sub_one_mem (γ : Lattice k) : + AddMonoidAlgebra.single γ 1 - 1 ∈ (augmentationIdeal : Ideal (LatticeRing k)) := by + change augmentation _ = 0 + simp + +def coefficientFunctional (g : Lattice k → ℚ) : LatticeRing k →ₗ[ℚ] ℚ := + (Finsupp.linearCombination ℚ g).comp (AddMonoidAlgebra.coeffLinearEquiv ℚ).toLinearMap + +lemma coefficientFunctional_apply (g : Lattice k → ℚ) (x : LatticeRing k) : + coefficientFunctional g x = x.coeff.sum (fun γ q => q * g γ) := rfl + +@[simp] lemma coefficientFunctional_single (g : Lattice k → ℚ) (γ : Lattice k) (q : ℚ) : + coefficientFunctional g (AddMonoidAlgebra.single γ q) = q * g γ := by + simp [coefficientFunctional, Finsupp.linearCombination_apply] + +lemma mass_linear : (mass : LatticeRing k → ℚ) = coefficientFunctional (fun _ => 1) := by + funext x + simp [coefficientFunctional_apply, mass] + +lemma firstMoment_linear (a : Fin k) : + (fun x : LatticeRing k => firstMoment x a) = coefficientFunctional (fun γ => γ a) := rfl + +lemma secondMoment_linear (a b : Fin k) : + (fun x : LatticeRing k => secondMoment x a b) = + coefficientFunctional (fun γ => (γ a : ℚ) * γ b) := by + funext x + simp only [secondMoment, coefficientFunctional_apply, mul_assoc] + +@[simp] lemma mass_add (x y : LatticeRing k) : mass (x+y) = mass x + mass y := by + simp only [mass_linear, map_add] +@[simp] lemma mass_smul (r : ℚ) (x : LatticeRing k) : mass (r • x) = r * mass x := by + simp only [mass_linear, map_smul, smul_eq_mul] +@[simp] lemma mass_zero : mass (0 : LatticeRing k) = 0 := by simp only [mass_linear, map_zero] +@[simp] lemma mass_single (γ : Lattice k) (q : ℚ) : mass (AddMonoidAlgebra.single γ q) = q := by + simp [mass_linear] +@[simp] lemma mass_mul (x y : LatticeRing k) : mass (x*y) = mass x * mass y := by + simp only [← augmentation_eq_mass, map_mul] +@[simp] lemma firstMoment_add (x y : LatticeRing k) (a : Fin k) : + firstMoment (x+y) a = firstMoment x a + firstMoment y a := by + change coefficientFunctional _ (x+y) = _ + _ + exact map_add _ _ _ +@[simp] lemma firstMoment_smul (r : ℚ) (x : LatticeRing k) (a : Fin k) : + firstMoment (r • x) a = r * firstMoment x a := by + change coefficientFunctional _ (r • x) = _ * _ + exact map_smul _ _ _ +@[simp] lemma firstMoment_zero (a : Fin k) : firstMoment (0 : LatticeRing k) a = 0 := by + exact map_zero (coefficientFunctional (k := k) (fun γ => γ a)) +@[simp] lemma firstMoment_single (γ : Lattice k) (q : ℚ) (a : Fin k) : + firstMoment (AddMonoidAlgebra.single γ q) a = q * γ a := coefficientFunctional_single _ _ _ +@[simp] lemma secondMoment_add (x y : LatticeRing k) (a b : Fin k) : + secondMoment (x+y) a b = secondMoment x a b + secondMoment y a b := by + have hh := congrFun (secondMoment_linear a b) + simp only [hh, map_add] +@[simp] lemma secondMoment_smul (r : ℚ) (x : LatticeRing k) (a b : Fin k) : + secondMoment (r • x) a b = r * secondMoment x a b := by + have hh := congrFun (secondMoment_linear a b) + simp only [hh, map_smul, smul_eq_mul] +@[simp] lemma secondMoment_zero (a b : Fin k) : secondMoment (0 : LatticeRing k) a b = 0 := by + have hh := congrFun (secondMoment_linear a b) + simp only [hh, map_zero] +@[simp] lemma secondMoment_single (γ : Lattice k) (q : ℚ) (a b : Fin k) : + secondMoment (AddMonoidAlgebra.single γ q) a b = q * γ a * γ b := by + have hh := congrFun (secondMoment_linear a b) + simp only [hh, coefficientFunctional_single, mul_assoc] + +lemma firstMoment_mul (x y : LatticeRing k) (a : Fin k) : + firstMoment (x*y) a = mass x * firstMoment y a + firstMoment x a * mass y := by + induction x using AddMonoidAlgebra.induction_on with + | «of» γ => + induction y using AddMonoidAlgebra.induction_on with + | «of» δ => simp [AddMonoidAlgebra.of_apply, AddMonoidAlgebra.single_mul_single, mul_add]; ring + | add y z hy hz => simp only [mul_add, firstMoment_add, mass_add, hy, hz]; ring + | smul r y hy => simp only [mul_smul_comm, firstMoment_smul, mass_smul, hy]; ring + | add x z hx hz => simp only [add_mul, firstMoment_add, mass_add, hx, hz]; ring + | smul r x hx => simp only [smul_mul_assoc, firstMoment_smul, mass_smul, hx]; ring + +lemma secondMoment_mul (x y : LatticeRing k) (a b : Fin k) : + secondMoment (x*y) a b = mass x * secondMoment y a b + secondMoment x a b * mass y + + firstMoment x a * firstMoment y b + firstMoment x b * firstMoment y a := by + induction x using AddMonoidAlgebra.induction_on with + | «of» γ => + induction y using AddMonoidAlgebra.induction_on with + | «of» δ => simp [AddMonoidAlgebra.of_apply, AddMonoidAlgebra.single_mul_single, mul_add, add_mul]; ring + | add y z hy hz => simp only [mul_add, firstMoment_add, secondMoment_add, mass_add, hy, hz]; ring + | smul r y hy => simp only [mul_smul_comm, firstMoment_smul, secondMoment_smul, mass_smul, hy]; ring + | add x z hx hz => simp only [add_mul, firstMoment_add, secondMoment_add, mass_add, hx, hz]; ring + | smul r x hx => simp only [smul_mul_assoc, firstMoment_smul, secondMoment_smul, mass_smul, hx]; ring + +@[simp] lemma mass_sub (x y : LatticeRing k) : mass (x-y) = mass x - mass y := by + simp only [mass_linear, map_sub] +@[simp] lemma firstMoment_sub (x y : LatticeRing k) (a : Fin k) : + firstMoment (x-y) a = firstMoment x a - firstMoment y a := by + exact map_sub (coefficientFunctional (k := k) (fun γ => γ a)) x y +@[simp] lemma secondMoment_sub (x y : LatticeRing k) (a b : Fin k) : + secondMoment (x-y) a b = secondMoment x a b - secondMoment y a b := by + have hh := congrFun (secondMoment_linear a b) + simp only [hh, map_sub] +@[simp] lemma mass_one : mass (1 : LatticeRing k) = 1 := by + change mass (AddMonoidAlgebra.single 0 1) = 1 + simp +@[simp] lemma firstMoment_one (a : Fin k) : firstMoment (1 : LatticeRing k) a = 0 := by + change firstMoment (AddMonoidAlgebra.single 0 1) a = 0 + simp +@[simp] lemma secondMoment_one (a b : Fin k) : secondMoment (1 : LatticeRing k) a b = 0 := by + change secondMoment (AddMonoidAlgebra.single 0 1) a b = 0 + simp + +lemma mem_augmentationIdeal (x : LatticeRing k) : + x ∈ augmentationIdeal ↔ mass x = 0 := by + change augmentation x = 0 ↔ _ + rw [augmentation_eq_mass] + +def jetOne : Ideal (LatticeRing k) where + carrier := {x | mass x = 0 ∧ ∀ a, firstMoment x a = 0} + zero_mem' := by simp + add_mem' hx hy := by simp [hx.1, hx.2, hy.1, hy.2] + smul_mem' r x hx := by + change mass (r*x) = 0 ∧ ∀ a, firstMoment (r*x) a = 0 + simp [firstMoment_mul, hx.1, hx.2] + +def jetTwo : Ideal (LatticeRing k) where + carrier := {x | mass x = 0 ∧ (∀ a, firstMoment x a = 0) ∧ ∀ a b, secondMoment x a b = 0} + zero_mem' := by simp + add_mem' hx hy := by simp [hx.1, hx.2.1, hx.2.2, hy.1, hy.2.1, hy.2.2] + smul_mem' r x hx := by + change mass (r*x) = 0 ∧ (∀ a, firstMoment (r*x) a = 0) ∧ ∀ a b, secondMoment (r*x) a b = 0 + simp [firstMoment_mul, secondMoment_mul, hx.1, hx.2.1, hx.2.2] + +lemma augmentation_sq_le_jetOne : (augmentationIdeal : Ideal (LatticeRing k)) ^ 2 ≤ jetOne := by + rw [pow_two] + apply Ideal.mul_le.mpr + intro x hx y hy + have hx0 := (mem_augmentationIdeal x).mp hx + have hy0 := (mem_augmentationIdeal y).mp hy + change mass (x*y) = 0 ∧ ∀ a, firstMoment (x*y) a = 0 + simp [firstMoment_mul, hx0, hy0] + +lemma augmentation_cube_le_jetTwo : (augmentationIdeal : Ideal (LatticeRing k)) ^ 3 ≤ jetTwo := by + rw [show (3 : ℕ) = 2 + 1 from rfl, pow_succ'] + apply Ideal.mul_le.mpr + intro x hx y hy + have hx0 := (mem_augmentationIdeal x).mp hx + have hy0 : mass y = 0 ∧ ∀ a, firstMoment y a = 0 := augmentation_sq_le_jetOne hy + change mass (x*y) = 0 ∧ (∀ a, firstMoment (x*y) a = 0) ∧ ∀ a b, secondMoment (x*y) a b = 0 + simp [firstMoment_mul, secondMoment_mul, hx0, hy0] + +lemma moments_eq_of_sub_mem_cube {x y : LatticeRing k} + (h : x-y ∈ (augmentationIdeal : Ideal (LatticeRing k)) ^ 3) : + mass x = mass y ∧ (∀ a, firstMoment x a = firstMoment y a) ∧ + ∀ a b, secondMoment x a b = secondMoment y a b := by + have hh := augmentation_cube_le_jetTwo h + change mass (x-y) = 0 ∧ (∀ a, firstMoment (x-y) a = 0) ∧ ∀ a b, secondMoment (x-y) a b = 0 at hh + simpa only [mass_sub, firstMoment_sub, secondMoment_sub, sub_eq_zero] using hh + +@[simp] lemma mass_sum {ι : Type uIndex} (t : Finset ι) (x : ι → LatticeRing k) : + mass (∑ i ∈ t, x i) = ∑ i ∈ t, mass (x i) := by + simp only [mass_linear, map_sum] +@[simp] lemma firstMoment_sum {ι : Type uIndex} (t : Finset ι) (x : ι → LatticeRing k) (a : Fin k) : + firstMoment (∑ i ∈ t, x i) a = ∑ i ∈ t, firstMoment (x i) a := by + exact map_sum (coefficientFunctional (k := k) (fun γ => γ a)) x t +@[simp] lemma secondMoment_sum {ι : Type uIndex} (t : Finset ι) (x : ι → LatticeRing k) (a b : Fin k) : + secondMoment (∑ i ∈ t, x i) a b = ∑ i ∈ t, secondMoment (x i) a b := by + have hh := congrFun (secondMoment_linear a b) + simp only [hh, map_sum] + +def quadraticStencil (C : Matrix (Fin k) (Fin k) ℚ) (l : Fin k → LatticeRing k) : LatticeRing k := + (1/2 : ℚ) • ∑ a, ∑ b, C a b • (l a * l b) + +lemma quadraticStencil_moments (C : Matrix (Fin k) (Fin k) ℚ) (hC : C.IsSymm) + (l : Fin k → LatticeRing k) (hm : ∀ a, mass (l a) = 0) + (hf : ∀ a b, firstMoment (l a) b = if a = b then 1 else 0) : + mass (quadraticStencil C l) = 0 ∧ (∀ a, firstMoment (quadraticStencil C l) a = 0) ∧ + (∀ a b, secondMoment (quadraticStencil C l) a b = C a b) := by + classical + refine ⟨?_, ?_, ?_⟩ + · simp [quadraticStencil, hm] + · intro a + simp [quadraticStencil, firstMoment_mul, hm] + · intro a b + simp only [quadraticStencil, secondMoment_smul, secondMoment_sum, secondMoment_mul, hm, + hf, zero_mul, mul_zero, zero_add] + simp only [mul_add, Finset.sum_add_distrib] + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + have hs : C b a = C a b := congrFun (congrFun hC a) b + rw [hs] + ring + +end Algebra +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Main.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..f61dbf1f08e982747098c903896971d7fd4d1524 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Main.lean @@ -0,0 +1,153 @@ +import OAI.Combinatorics.EuclideanRamsey.CorrectionPaths + +namespace OAI + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace +open Filter +open Set + +namespace EuclideanRamsey + +theorem fieldCriterion_ramsey {s d : ℕ} (a : Fin s → Space d) + (hs : 2 ≤ s) (hd : 1 ≤ d) (ha : Function.Injective a) + (h : FieldCriterion a) : Ramsey a := by + have hreal := fieldCriterion_realCriterion a h + have hpaths : ∀ n : ℕ,1 ≤ n → ∃ w lmb μ, + Path (fun i => FiniteEuclidean.embed d (a i)) w lmb ∧ + Path (fun i => FiniteEuclidean.embed d (a i)) w μ ∧ + 0 < lmb ∧ μ/lmb < 1/(n:ℝ) := by + intro n hn + have hn' : (0:ℝ) FiniteEuclidean.embed d (a i)) r + (fun c => paths_monochromatic _ hpaths c) + refine ⟨D,hD,?_⟩ + intro c + obtain ⟨b,hb,k,hk⟩ := hmono c + refine ⟨b,?_,k,hk⟩ + intro i j + rw [dist_eq_norm,dist_eq_norm,hb,← map_sub,LinearIsometry.norm_map] + +theorem classification {s d : ℕ} (a : Fin s → Space d) + (hs : 2 ≤ s) (hd : 1 ≤ d) (ha : Function.Injective a) + (hspan : affineSpan ℝ (Set.range a) = ⊤) : + Ramsey a ↔ FieldCriterion a := + ⟨ramsey_fieldCriterion a (by omega) hspan,fieldCriterion_ramsey a hs hd ha⟩ +end EuclideanRamsey + +namespace EuclideanRamsey + +theorem full_affine_representative {s D : ℕ} (a : Fin s → Space D) + (hs : 2 ≤ s) (ha : Function.Injective a) : + ∃ d : ℕ,1 ≤ d ∧ ∃ b : Fin s → Space d,Function.Injective b ∧ + Congruent a b ∧ affineSpan ℝ (Set.range b)=⊤ := by + classical + let i₀ : Fin s := ⟨0,by omega⟩ + let i₁ : Fin s := ⟨1,by omega⟩ + let V : Submodule ℝ (Space D) := Submodule.span ℝ (Set.range (fun i => a i-a i₀)) + have hx (i : Fin s) : a i-a i₀∈V := Submodule.subset_span (Set.mem_range_self i) + let x (i : Fin s) : V := ⟨a i-a i₀,hx i⟩ + have hxspan : Submodule.span ℝ (Set.range x)=⊤ := + (Submodule.span_range_subtype_eq_top_iff V hx).mpr rfl + have hpos : 0 (z : Space D)) he + change a i₁-a i₀=0 at hv + have hi := ha (sub_eq_zero.mp hv) + have hi' := congrArg Fin.val hi + norm_num [i₀,i₁] at hi' + let E := (stdOrthonormalBasis ℝ V).repr + let b : Fin s → Space (Module.finrank ℝ V) := fun i => E (x i) + have hbspan : Submodule.span ℝ (Set.range b)=⊤ := by + change Submodule.span ℝ (Set.range (E.toLinearEquiv.toLinearMap ∘ x))=⊤ + rw [Set.range_comp,Submodule.span_image,hxspan,Submodule.map_top] + exact LinearMap.range_eq_top.mpr E.surjective + have hb0 : b i₀=0 := by + change E (x i₀)=0 + have hx0 : x i₀=0 := by apply Subtype.ext; exact sub_self _ + rw [hx0,map_zero] + refine ⟨Module.finrank ℝ V,hpos, b,?_,?_,?_⟩ + · intro i j he + have hx' := E.injective he + have hv := congrArg (fun z : V => (z : Space D)) hx' + change a i-a i₀=a j-a i₀ at hv + exact ha (sub_left_injective hv) + · intro i j + change dist (E (x i)) (E (x j))=dist (a i) (a j) + rw [dist_eq_norm,dist_eq_norm,← map_sub,LinearIsometryEquiv.norm_map] + change ‖(a i-a i₀)-(a j-a i₀)‖=‖a i-a j‖ + rw [sub_sub_sub_cancel_right] + · apply (AffineSubspace.direction_eq_top_iff_of_nonempty + ⟨b i₀,subset_affineSpan ℝ (Set.range b) (Set.mem_range_self i₀)⟩).mp + rw [direction_affineSpan,vectorSpan_range_eq_span_range_vsub_right ℝ b i₀] + simpa only [vsub_eq_sub,hb0,sub_zero] using hbspan +end EuclideanRamsey + +namespace EuclideanRamsey + +theorem classification_nonempty {s D : ℕ} (a : Fin s → Space D) + (hs : 0 < s) (ha : Function.Injective a) : + Ramsey a ↔ s = 1 ∨ ∃ d : ℕ, 1 ≤ d ∧ ∃ b : Fin s → Space d, + Function.Injective b ∧ Congruent a b ∧ affineSpan ℝ (Set.range b) = ⊤ ∧ + FieldCriterion b := by + constructor + · intro hr + by_cases hs1 : s = 1 + · exact Or.inl hs1 + · have hs2 : 2 ≤ s := by omega + obtain ⟨d, hd, b, hb, hc, hspan⟩ := full_affine_representative a hs2 ha + exact Or.inr ⟨d, hd, b, hb, hc, hspan, + (classification b hs2 hd hb hspan).mp ((ramsey_congruent_iff hc).mp hr)⟩ + · rintro (hs1 | ⟨d, hd, b, hb, hc, hspan, hcrit⟩) + · subst s + exact singleton_ramsey a + · by_cases hs1 : s = 1 + · subst s + exact singleton_ramsey a + · exact (ramsey_congruent_iff hc).mpr + ((classification b (by omega) hd hb hspan).mpr hcrit) +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Model.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..71ecccecba69d369602cff27eb8ac79b4b16b424 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Model.lean @@ -0,0 +1,46 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped TensorProduct +namespace EuclideanRamsey + +abbrev Space (d : ℕ) := EuclideanSpace ℝ (Fin d) + +def Congruent {s d D : ℕ} (a : Fin s → Space d) (b : Fin s → Space D) : Prop := + ∀ i j, dist (b i) (b j) = dist (a i) (a j) + +def Ramsey {s d : ℕ} (a : Fin s → Space d) : Prop := + ∀ r : ℕ, 2 ≤ r → ∃ D : ℕ, 1 ≤ D ∧ + ∀ c : Space D → Fin r, ∃ b : Fin s → Space D, + Congruent a b ∧ ∃ k : Fin r, ∀ i, c (b i) = k + +def coordinateField {s d : ℕ} (a : Fin s → Space d) : IntermediateField ℚ ℝ := + IntermediateField.adjoin ℚ (Set.range (fun ij : Fin s × Fin d => a ij.1 ij.2)) + +abbrev Coeff {s d : ℕ} (a : Fin s → Space d) := ↥(coordinateField a) +abbrev TensorRing {s d : ℕ} (a : Fin s → Space d) := Coeff a ⊗[ℚ] Coeff a + +def coordinate {s d : ℕ} (a : Fin s → Space d) (i : Fin s) (j : Fin d) : Coeff a := + ⟨a i j, IntermediateField.subset_adjoin ℚ _ (Set.mem_range_self (i, j))⟩ + +def augmented {s d : ℕ} (a : Fin s → Space d) (i : Fin s) : Option (Fin d) → Coeff a + | none => 1 + | some j => coordinate a i j + +def multiply {s d : ℕ} (a : Fin s → Space d) : TensorRing a →ₐ[ℚ] Coeff a := + Algebra.TensorProduct.lmul' ℚ + +def FieldCriterion {s d : ℕ} (a : Fin s → Space d) : Prop := + ∃ P : Matrix (Option (Fin d)) (Option (Fin d)) (TensorRing a), + (∀ i : Fin s, ∑ α, ∑ β, + ((augmented a i α) ⊗ₜ[ℚ] (1 : Coeff a)) * P α β * + ((1 : Coeff a) ⊗ₜ[ℚ] (augmented a i β)) = 0) ∧ + (∀ α β : Fin d, multiply a (P (some α) (some β)) = if α = β then 1 else 0) + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Nine.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Nine.lean new file mode 100644 index 0000000000000000000000000000000000000000..2dc014d3bf4b4187c115bb286414f063251008ad --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Nine.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.EuclideanRamsey.NineGeometry +import OAI.Combinatorics.EuclideanRamsey.NineField +import OAI.Combinatorics.EuclideanRamsey.NineRationalDeterminant +import OAI.Combinatorics.EuclideanRamsey.NineLinearObstruction +import Mathlib.Logic.Equiv.Fin.Basic + +namespace OAI + +/-! Nine algebraically independent circle parameters give a non-Ramsey configuration. -/ + +noncomputable section +namespace EuclideanRamsey.NineMain + +local instance parameterFieldAlgebra : Algebra ℚ NineField.ParameterField := + NineField.parameterFieldAlgebra + +local instance targetFieldAlgebra : Algebra ℚ NineField.TargetField := + NineField.targetFieldAlgebra + +open NineGeometry +open scoped TensorProduct + +def gridToFin9 : NineGrid.Index ≃ Fin 9 := finProdFinEquiv + +def gridToColumn : NineGrid.Index ≃ NineLinearObstruction.Column 2 := + Equiv.prodCongr (finSuccEquiv 2) (finSuccEquiv 2) + +def rowEquiv : NineLinearObstruction.Column 2 ≃ Fin 9 := + gridToColumn.symm.trans gridToFin9 + +/-- Renaming the polynomial variables into the independent-variable field. -/ +def polynomialEmbedding : NineGrid.Poly →+* NineField.TargetField := + (algebraMap NineField.TargetPoly NineField.TargetField).comp + (MvPolynomial.renameEquiv ℚ (Equiv.sumCongr gridToFin9 gridToFin9)).toRingHom + +theorem polynomialEmbedding_injective : Function.Injective polynomialEmbedding := + (IsFractionRing.injective NineField.TargetPoly NineField.TargetField).comp + (MvPolynomial.renameEquiv ℚ (Equiv.sumCongr gridToFin9 gridToFin9)).injective + +@[simp] theorem polynomialEmbedding_T (i : NineGrid.Index) : + polynomialEmbedding (NineGrid.T i) = NineField.T (gridToFin9 i) := by + simp [polynomialEmbedding, NineGrid.T, NineField.T] + +@[simp] theorem polynomialEmbedding_U (i : NineGrid.Index) : + polynomialEmbedding (NineGrid.U i) = NineField.U (gridToFin9 i) := by + simp [polynomialEmbedding, NineGrid.U, NineField.U] + +theorem paramVector_eq_r (z : NineField.TargetField) (a : Option (Fin 2)) : + NineField.paramVector z a = NineRational.r z ((finSuccEquiv 2).symm a) := by + cases a with + | none => simp [NineField.paramVector, NineField.a0, NineRational.r] + | some a => fin_cases a <;> + simp [NineField.paramVector, NineField.a1, NineField.a2, NineRational.r] + +/-- The tensor evaluation matrix is the rational-coordinate matrix after reindexing. -/ +theorem evaluationMatrix_eq (t : Fin 9 → ℝ) (ht : AlgebraicIndependent ℚ t) : + NineLinearObstruction.evaluationMatrix (circleConfig t) + (NineField.coordinateTensorEmbedding t ht) rowEquiv = + Matrix.reindex gridToColumn gridToColumn + (NineRational.genericMatrix polynomialEmbedding) := by + ext i q + simp only [NineLinearObstruction.evaluationMatrix, + NineField.coordinateTensorEmbedding_tmul, map_one, mul_one, one_mul, + NineField.leftCoeff_augmented, NineField.rightCoeff_augmented] + simp only [paramVector_eq_r, Matrix.reindex_apply, Matrix.submatrix_apply, + NineRational.genericMatrix, + polynomialEmbedding_T, polynomialEmbedding_U] + rfl + +theorem evaluationMatrix_det_ne_zero (t : Fin 9 → ℝ) + (ht : AlgebraicIndependent ℚ t) : + (NineLinearObstruction.evaluationMatrix (circleConfig t) + (NineField.coordinateTensorEmbedding t ht) rowEquiv).det ≠ 0 := by + rw [evaluationMatrix_eq, Matrix.det_reindex_self] + exact NineRational.det_genericMatrix_ne_zero polynomialEmbedding + polynomialEmbedding_injective + +/-- Nine algebraically independent real parameters give a non-Ramsey configuration. -/ +theorem nine_circle_not_ramsey (t : Fin 9 → ℝ) + (ht : AlgebraicIndependent ℚ t) : ¬ Ramsey (circleConfig t) := by + exact NineLinearObstruction.not_ramsey_of_det_ne_zero (circleConfig t) + (by decide) (by decide) (circleConfig_affineSpan t ht) + (NineField.coordinateTensorEmbedding t ht) + (NineField.coordinateTensorEmbedding_injective t ht) rowEquiv + (evaluationMatrix_det_ne_zero t ht) + +/-- Nine distinct points on the unit circle form a non-Ramsey configuration. -/ +theorem nine_circle_configuration (t : Fin 9 → ℝ) + (ht : AlgebraicIndependent ℚ t) : + Function.Injective (circleConfig t) ∧ + (∀ i, dist (circleConfig t i) 0 = 1) ∧ ¬ Ramsey (circleConfig t) := + ⟨circleConfig_injective t ht, circleConfig_on_circle t, nine_circle_not_ramsey t ht⟩ + +end EuclideanRamsey.NineMain + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/NineField.lean b/lean/OAI/Combinatorics/EuclideanRamsey/NineField.lean new file mode 100644 index 0000000000000000000000000000000000000000..5464b54e5d52bf179cb272322c6a384f64c754d7 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/NineField.lean @@ -0,0 +1,211 @@ +import OAI.Combinatorics.EuclideanRamsey.NineGeometry +import OAI.Combinatorics.EuclideanRamsey.IndependentTensor +import Mathlib.RingTheory.AlgebraicIndependent.Adjoin + +namespace OAI + +noncomputable section +open scoped TensorProduct + +namespace EuclideanRamsey.NineField + +open NineGeometry + +abbrev ParameterPoly := IndependentTensor.Poly (Fin 9) +abbrev ParameterField := IndependentTensor.Rat (Fin 9) +abbrev TargetPoly := IndependentTensor.JointPoly (Fin 9) +abbrev TargetField := IndependentTensor.JointField (Fin 9) + +/-- The rational scalar structure induced by the fraction-ring construction. -/ +local instance parameterFieldAlgebra : Algebra ℚ ParameterField := + OreLocalization.instAlgebra (R₀ := ℚ) (R := ParameterPoly) + (S := nonZeroDivisors ParameterPoly) + +/-- The rational scalar structure on the joint rational-function field. -/ +local instance targetFieldAlgebra : Algebra ℚ TargetField := + OreLocalization.instAlgebra (R₀ := ℚ) (R := TargetPoly) + (S := nonZeroDivisors TargetPoly) + +theorem parameterFieldAlgebra_eq_canonical : + parameterFieldAlgebra = (DivisionRing.toRatAlgebra : Algebra ℚ ParameterField) := + Subsingleton.elim _ _ + +theorem targetFieldAlgebra_eq_canonical : + targetFieldAlgebra = (DivisionRing.toRatAlgebra : Algebra ℚ TargetField) := + Subsingleton.elim _ _ + +def T (i : Fin 9) : TargetField := + algebraMap TargetPoly TargetField (MvPolynomial.X (Sum.inl i)) + +def U (i : Fin 9) : TargetField := + algebraMap TargetPoly TargetField (MvPolynomial.X (Sum.inr i)) + +/-- The three augmented rational parametrization entries. -/ +def a0 : TargetField := 1 +def a1 (z : TargetField) : TargetField := (1 - z^2) / (1 + z^2) +def a2 (z : TargetField) : TargetField := (2*z) / (1 + z^2) + +def paramVector (z : TargetField) : Option (Fin 2) → TargetField + | none => a0 + | some j => if j = 0 then a1 z else a2 z + +variable (t : Fin 9 → ℝ) + +/-- Each parameter is an element of the actual coordinate field, by the +proved recovery formula and coordinate-field equality. -/ +def parameter (i : Fin 9) : Coeff (circleConfig t) := + ⟨t i, by + rw [circleConfig_coordinateField] + exact IntermediateField.subset_adjoin ℚ _ (Set.mem_range_self i)⟩ + +@[simp] theorem parameter_coe (i : Fin 9) : (parameter t i : ℝ) = t i := rfl + +theorem coordinate_zero (i : Fin 9) : + coordinate (circleConfig t) i 0 = + (1 - (parameter t i)^2) / (1 + (parameter t i)^2) := by + apply Subtype.ext + simp [coordinate, circleConfig, parameter] + +theorem coordinate_one (i : Fin 9) : + coordinate (circleConfig t) i 1 = + (2 * parameter t i) / (1 + (parameter t i)^2) := by + have htwo : ((2 : Coeff (circleConfig t)) : ℝ) = 2 := + map_ofNat (coordinateField (circleConfig t)).val 2 + apply Subtype.ext + simp [coordinate, circleConfig, parameter, htwo] + +variable (ht : AlgebraicIndependent ℚ t) + +/-- The actual coefficient field is identified with the rational function +field using exactly the given algebraic independence of the real parameters. -/ +def coefficientEquiv : Coeff (circleConfig t) ≃ₐ[ℚ] ParameterField := + (IntermediateField.equivOfEq (circleConfig_coordinateField t)).trans + ht.aevalEquivField.symm + +@[simp] theorem coefficientEquiv_parameter (i : Fin 9) : + coefficientEquiv t ht (parameter t i) = + algebraMap ParameterPoly ParameterField (MvPolynomial.X i) := by + apply ht.aevalEquivField.injective + change ht.aevalEquivField + (ht.aevalEquivField.symm + ((IntermediateField.equivOfEq (circleConfig_coordinateField t)) (parameter t i))) = _ + rw [AlgEquiv.apply_symm_apply] + apply Subtype.ext + change t i = + (ht.aevalEquivField + (algebraMap ParameterPoly ParameterField (MvPolynomial.X i)) : ℝ) + rw [AlgebraicIndependent.aevalEquivField_algebraMap_apply_coe] + simp + +def leftCoeff : Coeff (circleConfig t) →ₐ[ℚ] TargetField := + (IndependentTensor.leftMap (Fin 9)).comp (coefficientEquiv t ht).toAlgHom + +def rightCoeff : Coeff (circleConfig t) →ₐ[ℚ] TargetField := + (IndependentTensor.rightMap (Fin 9)).comp (coefficientEquiv t ht).toAlgHom + +@[simp] theorem leftCoeff_parameter (i : Fin 9) : + leftCoeff t ht (parameter t i) = T i := by + simp [leftCoeff, T] + +@[simp] theorem rightCoeff_parameter (i : Fin 9) : + rightCoeff t ht (parameter t i) = U i := by + simp [rightCoeff, U] + +@[simp] theorem leftCoeff_coordinate_zero (i : Fin 9) : + leftCoeff t ht (coordinate (circleConfig t) i 0) = a1 (T i) := by + rw [coordinate_zero] + simp [a1, map_div₀] + +@[simp] theorem leftCoeff_coordinate_one (i : Fin 9) : + leftCoeff t ht (coordinate (circleConfig t) i 1) = a2 (T i) := by + rw [coordinate_one] + simp [a2, map_div₀, map_ofNat] + +@[simp] theorem rightCoeff_coordinate_zero (i : Fin 9) : + rightCoeff t ht (coordinate (circleConfig t) i 0) = a1 (U i) := by + rw [coordinate_zero] + simp [a1, map_div₀] + +@[simp] theorem rightCoeff_coordinate_one (i : Fin 9) : + rightCoeff t ht (coordinate (circleConfig t) i 1) = a2 (U i) := by + rw [coordinate_one] + simp [a2, map_div₀, map_ofNat] + +/-- The tensor equivalence transports both copies of the actual field. -/ +def coefficientTensorEquiv : + TensorRing (circleConfig t) ≃ₐ[ℚ] ParameterField ⊗[ℚ] ParameterField := + Algebra.TensorProduct.congr (coefficientEquiv t ht) (coefficientEquiv t ht) + +/-- The coordinate-field tensor square embeds in the rational function field +on eighteen variables. -/ +def coordinateTensorEmbedding : TensorRing (circleConfig t) →ₐ[ℚ] TargetField := + (IndependentTensor.tensorEmbedding (Fin 9)).comp + (coefficientTensorEquiv t ht).toAlgHom + +theorem coordinateTensorEmbedding_injective : + Function.Injective (coordinateTensorEmbedding t ht) := + (IndependentTensor.tensorEmbedding_injective (Fin 9)).comp + (coefficientTensorEquiv t ht).injective + +@[simp] theorem coordinateTensorEmbedding_tmul + (x y : Coeff (circleConfig t)) : + coordinateTensorEmbedding t ht (x ⊗ₜ[ℚ] y) = + leftCoeff t ht x * rightCoeff t ht y := by + simp [coordinateTensorEmbedding, coefficientTensorEquiv, leftCoeff, rightCoeff] + +/-- Exact images of the constant and two spatial augmented coordinates. -/ +@[simp] theorem coordinateTensorEmbedding_a0_left (i : Fin 9) : + coordinateTensorEmbedding t ht + ((augmented (circleConfig t) i none) ⊗ₜ[ℚ] 1) = a0 := by + simp [augmented, a0] + +@[simp] theorem coordinateTensorEmbedding_a1_left (i : Fin 9) : + coordinateTensorEmbedding t ht + ((augmented (circleConfig t) i (some 0)) ⊗ₜ[ℚ] 1) = a1 (T i) := by + simp [augmented] + +@[simp] theorem coordinateTensorEmbedding_a2_left (i : Fin 9) : + coordinateTensorEmbedding t ht + ((augmented (circleConfig t) i (some 1)) ⊗ₜ[ℚ] 1) = a2 (T i) := by + simp [augmented] + +@[simp] theorem coordinateTensorEmbedding_a0_right (i : Fin 9) : + coordinateTensorEmbedding t ht + (1 ⊗ₜ[ℚ] (augmented (circleConfig t) i none)) = a0 := by + simp [augmented, a0] + +@[simp] theorem coordinateTensorEmbedding_a1_right (i : Fin 9) : + coordinateTensorEmbedding t ht + (1 ⊗ₜ[ℚ] (augmented (circleConfig t) i (some 0))) = a1 (U i) := by + simp [augmented] + +@[simp] theorem coordinateTensorEmbedding_a2_right (i : Fin 9) : + coordinateTensorEmbedding t ht + (1 ⊗ₜ[ℚ] (augmented (circleConfig t) i (some 1))) = a2 (U i) := by + simp [augmented] + +theorem leftCoeff_augmented (i : Fin 9) (j : Option (Fin 2)) : + leftCoeff t ht (augmented (circleConfig t) i j) = paramVector (T i) j := by + cases j with + | none => simp [augmented, paramVector, a0] + | some j => fin_cases j <;> simp [augmented, paramVector] + +theorem rightCoeff_augmented (i : Fin 9) (j : Option (Fin 2)) : + rightCoeff t ht (augmented (circleConfig t) i j) = paramVector (U i) j := by + cases j with + | none => simp [augmented, paramVector, a0] + | some j => fin_cases j <;> simp [augmented, paramVector] + +/-- The augmented-coordinate tensors map to entries of the rational evaluation matrix. -/ +theorem coordinateTensorEmbedding_augmented_tmul (i : Fin 9) + (α β : Option (Fin 2)) : + coordinateTensorEmbedding t ht + ((augmented (circleConfig t) i α) ⊗ₜ[ℚ] (augmented (circleConfig t) i β)) = + paramVector (T i) α * paramVector (U i) β := by + rw [coordinateTensorEmbedding_tmul, leftCoeff_augmented, rightCoeff_augmented] + +end EuclideanRamsey.NineField + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/NineGeometry.lean b/lean/OAI/Combinatorics/EuclideanRamsey/NineGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..09c7571d2b6c1b90f95fb1c4217c76075435adff --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/NineGeometry.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.EuclideanRamsey.CircleExtension +import OAI.Combinatorics.EuclideanRamsey.CircleSpan +import Mathlib.RingTheory.AlgebraicIndependent.Basic + +namespace OAI + +/-! Rational parametrization of the unit circle and its coordinate field. -/ + +noncomputable section +namespace EuclideanRamsey.NineGeometry + +def circlePoint (x : ℝ) : Space 2 := + CircleConsequence.stereographic (0 : Space 2) 1 x + +def circleConfig (t : Fin 9 → ℝ) (i : Fin 9) : Space 2 := circlePoint (t i) + +@[simp] theorem circlePoint_zero (x : ℝ) : + circlePoint x 0 = (1 - x^2) / (1 + x^2) := by + simp [circlePoint, CircleConsequence.stereographic] + +@[simp] theorem circlePoint_one (x : ℝ) : + circlePoint x 1 = (2*x) / (1 + x^2) := by + simp [circlePoint, CircleConsequence.stereographic] + +theorem circlePoint_recover (x : ℝ) : + circlePoint x 1 / (1 + circlePoint x 0) = x := by + simpa only [circlePoint_zero, circlePoint_one] using + CircleConsequence.stereographic_recover x + +theorem circlePoint_on_circle (x : ℝ) : dist (circlePoint x) 0 = 1 := + CircleConsequence.stereographic_on_circle 0 1 x (by norm_num) + +theorem circlePoint_injective : Function.Injective circlePoint := by + intro x y h + have hr := congrArg (fun p : Space 2 => p 1 / (1 + p 0)) h + simpa only [circlePoint_recover] using hr + +theorem circleConfig_on_circle (t : Fin 9 → ℝ) (i : Fin 9) : + dist (circleConfig t i) 0 = 1 := circlePoint_on_circle (t i) + +theorem circleConfig_injective (t : Fin 9 → ℝ) + (ht : AlgebraicIndependent ℚ t) : Function.Injective (circleConfig t) := + circlePoint_injective.comp ht.injective + +/-- Restriction to the first five points. -/ +def firstFive (i : Fin 5) : Fin 9 := ⟨i.val, by omega⟩ + +theorem firstFive_injective : Function.Injective firstFive := by + intro i j h + apply Fin.ext + simpa only [firstFive] using congrArg (fun k : Fin 9 => k.val) h + +theorem circleConfig_affineSpan (t : Fin 9 → ℝ) + (ht : AlgebraicIndependent ℚ t) : + affineSpan ℝ (Set.range (circleConfig t)) = ⊤ := by + have hfive : affineSpan ℝ (Set.range (circleConfig t ∘ firstFive)) = ⊤ := + CircleConsequence.circle_five_affineSpan (circleConfig t ∘ firstFive) + ((circleConfig_injective t ht).comp firstFive_injective) 0 1 + (fun i => circleConfig_on_circle t (firstFive i)) + apply top_unique + rw [← hfive] + apply affineSpan_mono + rintro p ⟨i, rfl⟩ + exact Set.mem_range_self (firstFive i) + +/-- The coordinate field is generated by the circle parameters. -/ +theorem circleConfig_coordinateField (t : Fin 9 → ℝ) : + coordinateField (circleConfig t) = IntermediateField.adjoin ℚ (Set.range t) := by + let F : IntermediateField ℚ ℝ := IntermediateField.adjoin ℚ (Set.range t) + apply le_antisymm + · change IntermediateField.adjoin ℚ + (Set.range (fun ij : Fin 9 × Fin 2 => circleConfig t ij.1 ij.2)) ≤ F + apply IntermediateField.adjoin_le_iff.mpr + rintro x ⟨⟨i, j⟩, rfl⟩ + have ht : t i ∈ F := IntermediateField.subset_adjoin ℚ _ (Set.mem_range_self i) + have ht2 : (t i)^2 ∈ F := F.pow_mem ht 2 + have hden : 1 + (t i)^2 ∈ F := F.add_mem F.one_mem ht2 + fin_cases j + · change circlePoint (t i) 0 ∈ F + rw [circlePoint_zero] + exact F.div_mem (F.sub_mem F.one_mem ht2) hden + · change circlePoint (t i) 1 ∈ F + rw [circlePoint_one] + exact F.div_mem (F.mul_mem (F.natCast_mem 2) ht) hden + · apply IntermediateField.adjoin_le_iff.mpr + rintro x ⟨i, rfl⟩ + let K : IntermediateField ℚ ℝ := coordinateField (circleConfig t) + have hcoord (j : Fin 2) : circleConfig t i j ∈ K := + IntermediateField.subset_adjoin ℚ _ (Set.mem_range_self (i, j)) + have hrecovered : circleConfig t i 1 / (1 + circleConfig t i 0) ∈ K := + K.div_mem (hcoord 1) (K.add_mem K.one_mem (hcoord 0)) + change t i ∈ K + simpa only [circleConfig, circlePoint_recover] using hrecovered + +end EuclideanRamsey.NineGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/NineGridDeterminant.lean b/lean/OAI/Combinatorics/EuclideanRamsey/NineGridDeterminant.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d2cba5a4273878d2801153530dbdda9008ff720 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/NineGridDeterminant.lean @@ -0,0 +1,94 @@ +import Mathlib.Algebra.MvPolynomial.Eval +import Mathlib.Data.Fin.VecNotation +import Mathlib.LinearAlgebra.Matrix.Kronecker +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.NormNum + +namespace OAI + +/-! The denominator-cleared matrix has rows and columns indexed by `Fin 3 × Fin 3`. +At the grid `(0, 1, -1)²`, its polynomial evaluation is a Kronecker square +with nonzero determinant. -/ + +noncomputable section + +namespace EuclideanRamsey.NineGrid + +open scoped Kronecker + +abbrev Index := Fin 3 × Fin 3 +abbrev Vars := Index ⊕ Index +abbrev Poly := MvPolynomial Vars ℚ + +/-- The denominator-cleared rational parametrization coordinates. -/ +def q {R : Type*} [CommRing R] (z : R) : Fin 3 → R := + ![1 + z ^ 2, 1 - z ^ 2, 2 * z] + +def T (i : Index) : Poly := MvPolynomial.X (Sum.inl i) +def U (i : Index) : Poly := MvPolynomial.X (Sum.inr i) + +/-- Polynomial evaluation rows before dividing by (1+T²)(1+U²). -/ +def E : Matrix Index Index Poly := + fun i j => q (T i) j.1 * q (U i) j.2 + +def grid : Fin 3 → ℚ := ![0, 1, -1] + +/-- T_(a,b) is sent to grid a, and U_(a,b) to grid b. -/ +def gridAssignment : Vars → ℚ + | Sum.inl i => grid i.1 + | Sum.inr i => grid i.2 + +def gridEval : Poly →+* ℚ := MvPolynomial.eval gridAssignment + +/-- The evaluated one-parameter matrix C'. -/ +def C : Matrix (Fin 3) (Fin 3) ℚ := fun i j => q (grid i) j + +lemma map_q {R S : Type*} [CommRing R] [CommRing S] + (f : R →+* S) (z : R) (a : Fin 3) : + f (q z a) = q (f z) a := by + fin_cases a <;> simp [q, map_ofNat] + +@[simp] lemma gridEval_T (i : Index) : gridEval (T i) = grid i.1 := by + simp [gridEval, T, gridAssignment] + +@[simp] lemma gridEval_U (i : Index) : gridEval (U i) = grid i.2 := by + simp [gridEval, U, gridAssignment] + +/-- Exact rational entries, with rows indexed in the order 0,1,2. -/ +lemma C_eq : C = ![![1, 1, 0], ![2, 0, 2], ![2, 0, -2]] := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [C, q, grid] + +lemma det_C : Matrix.det C = 8 := by + rw [Matrix.det_fin_three] + norm_num [C, q, grid, Matrix.cons_val_two, Matrix.vecHead, Matrix.vecTail] + +/-- The evaluation is on the polynomial ring alone. -/ +lemma evaluated_E : gridEval.mapMatrix E = C ⊗ₖ C := by + ext i j + rcases i with ⟨r, s⟩ + rcases j with ⟨a, b⟩ + change gridEval (q (T (r, s)) a * q (U (r, s)) b) = C r a * C s b + rw [map_mul, map_q, map_q, gridEval_T, gridEval_U] + rfl + +lemma det_evaluated_E : Matrix.det (gridEval.mapMatrix E) = (8 : ℚ) ^ 6 := by + simp only [evaluated_E, Matrix.det_kronecker, det_C, Fintype.card_fin] + norm_num + +lemma gridEval_det_E : gridEval (Matrix.det E) = (8 : ℚ) ^ 6 := by + rw [RingHom.map_det] + exact det_evaluated_E + +/-- The full denominator-cleared nine-row polynomial determinant is nonzero. -/ +theorem det_E_ne_zero : Matrix.det E ≠ 0 := by + intro hzero + have h := gridEval_det_E + rw [hzero, map_zero] at h + norm_num at h + +end EuclideanRamsey.NineGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/NineLinearObstruction.lean b/lean/OAI/Combinatorics/EuclideanRamsey/NineLinearObstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a9a6d2f7c49c8365e1e3ebb2a4d0f4c2ff01c44 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/NineLinearObstruction.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.EuclideanRamsey.TensorDescent +import Mathlib.LinearAlgebra.Matrix.NonsingularInverse + +namespace OAI + +/-! Nonsingular tensor evaluation matrices obstruct the Euclidean Ramsey property. -/ + +noncomputable section +open scoped TensorProduct BigOperators + +namespace EuclideanRamsey.NineLinearObstruction + +theorem vector_eq_zero_of_det_ne_zero {J K : Type*} [Fintype J] + [DecidableEq J] [Field K] (M : Matrix J J K) (hM : M.det ≠ 0) + (v : J → K) (hv : M.mulVec v = 0) : v = 0 := by + have hu : IsUnit M := M.isUnit_iff_isUnit_det.mpr (isUnit_iff_ne_zero.mpr hM) + apply (Matrix.mulVec_injective_iff_isUnit.mpr hu) + simpa using hv + +abbrev Column (d : ℕ) := Option (Fin d) × Option (Fin d) + +/-- Rows are reindexed by an actual equivalence; entries are the exact +images of the two augmented-coordinate tensor factors in FieldCriterion. -/ +def evaluationMatrix {s d : ℕ} (a : Fin s → Space d) + {K : Type*} [Field K] [Algebra ℚ K] + (f : TensorRing a →ₐ[ℚ] K) (e : Column d ≃ Fin s) : + Matrix (Column d) (Column d) K := fun i q => + f ((augmented a (e i) q.1) ⊗ₜ[ℚ] (1 : Coeff a)) * + f ((1 : Coeff a) ⊗ₜ[ℚ] (augmented a (e i) q.2)) + +theorem not_fieldCriterion_of_det_ne_zero {s d : ℕ} (a : Fin s → Space d) + (hd : 0 < d) {K : Type*} [Field K] [Algebra ℚ K] + (f : TensorRing a →ₐ[ℚ] K) (hf : Function.Injective f) + (e : Column d ≃ Fin s) (hdet : (evaluationMatrix a f e).det ≠ 0) : + ¬ FieldCriterion a := by + classical + rintro ⟨P, hP, hspatial⟩ + let v : Column d → K := fun q => f (P q.1 q.2) + have hv : (evaluationMatrix a f e).mulVec v = 0 := by + funext i + have h := congrArg f (hP (e i)) + simp only [map_sum, map_mul, map_zero] at h + change (∑ q : Column d, evaluationMatrix a f e i q * v q) = 0 + rw [Fintype.sum_prod_type] + convert h using 1 + apply Finset.sum_congr rfl + intro α hα + apply Finset.sum_congr rfl + intro β hβ + dsimp [evaluationMatrix, v] + ring + have hvzero := vector_eq_zero_of_det_ne_zero (evaluationMatrix a f e) hdet v hv + have hPzero (α β : Option (Fin d)) : P α β = 0 := by + apply hf + have h := congrFun hvzero (α, β) + simpa only [v, Pi.zero_apply, map_zero] using h + let j : Fin d := ⟨0, hd⟩ + have hbad := hspatial j j + rw [hPzero, map_zero, ite_eq_left rfl] at hbad + exact zero_ne_one hbad + +/-- Ramsey configurations cannot have a nonsingular tensor evaluation matrix. -/ +theorem not_ramsey_of_det_ne_zero {s d : ℕ} (a : Fin s → Space d) + (hs : 0 < s) (hd : 0 < d) + (hspan : affineSpan ℝ (Set.range a) = ⊤) + {K : Type*} [Field K] [Algebra ℚ K] + (f : TensorRing a →ₐ[ℚ] K) (hf : Function.Injective f) + (e : Column d ≃ Fin s) (hdet : (evaluationMatrix a f e).det ≠ 0) : + ¬ Ramsey a := by + intro hR + exact not_fieldCriterion_of_det_ne_zero a hd f hf e hdet + (ramsey_fieldCriterion a hs hspan hR) + +end EuclideanRamsey.NineLinearObstruction + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/NineRationalDeterminant.lean b/lean/OAI/Combinatorics/EuclideanRamsey/NineRationalDeterminant.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3dd11bc01e474dc0c430b8fca8f0fc1cff12e2f --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/NineRationalDeterminant.lean @@ -0,0 +1,148 @@ +import OAI.Combinatorics.EuclideanRamsey.NineGridDeterminant +import OAI.Combinatorics.EuclideanRamsey.IndependentTensor +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Ring + +namespace OAI + +/-! Clearing denominators transfers the polynomial determinant to a faithful +rational-function realization. Renaming variables transports the result to +any equivalent set of nine row labels. -/ + +noncomputable section + +namespace EuclideanRamsey.NineRational + +abbrev Index := NineGrid.Index +abbrev Poly := NineGrid.Poly +abbrev K := IndependentTensor.JointField Index + +/-- Actual rational-coordinate vector, including its constant first entry. -/ +def r {F : Type*} [Field F] (z : F) : Fin 3 → F := + ![1, (1 - z ^ 2) / (1 + z ^ 2), (2 * z) / (1 + z ^ 2)] + +lemma polynomial_denominator_ne_zero (v : NineGrid.Vars) : + (1 + (MvPolynomial.X v : Poly) ^ 2) ≠ 0 := by + intro hz + have h := congrArg (MvPolynomial.eval (fun _ : NineGrid.Vars => (0 : ℚ))) hz + norm_num at h + +lemma mapped_denominator_ne_zero {F : Type*} [Field F] + (f : Poly →+* F) (hf : Function.Injective f) (v : NineGrid.Vars) : + 1 + f (MvPolynomial.X v) ^ 2 ≠ 0 := by + intro hz + apply polynomial_denominator_ne_zero v + apply hf + simpa only [map_add, map_one, map_pow, map_zero] using hz + +lemma clear_r {F : Type*} [Field F] (z : F) (hz : 1 + z ^ 2 ≠ 0) + (a : Fin 3) : (1 + z ^ 2) * r z a = NineGrid.q z a := by + fin_cases a <;> simp [r, NineGrid.q] <;> field_simp [hz] + +/-- The actual rational-coordinate matrix in any faithful polynomial realization. -/ +def genericMatrix {F : Type*} [Field F] (f : Poly →+* F) : Matrix Index Index F := + fun i j => r (f (NineGrid.T i)) j.1 * r (f (NineGrid.U i)) j.2 + +def rowDenominator {F : Type*} [Field F] (f : Poly →+* F) (i : Index) : F := + (1 + f (NineGrid.T i) ^ 2) * (1 + f (NineGrid.U i) ^ 2) + +/-- Multiplying each row by its denominator gives the polynomial matrix. -/ +lemma cleared_matrix {F : Type*} [Field F] (f : Poly →+* F) + (hf : Function.Injective f) : + f.mapMatrix NineGrid.E = Matrix.diagonal (rowDenominator f) * genericMatrix f := by + ext i j + rw [Matrix.diagonal_mul] + change f (NineGrid.q (NineGrid.T i) j.1 * NineGrid.q (NineGrid.U i) j.2) = + ((1 + f (NineGrid.T i) ^ 2) * (1 + f (NineGrid.U i) ^ 2)) * + (r (f (NineGrid.T i)) j.1 * r (f (NineGrid.U i)) j.2) + rw [map_mul, NineGrid.map_q, NineGrid.map_q] + rw [← clear_r (f (NineGrid.T i)) (mapped_denominator_ne_zero f hf (Sum.inl i)) j.1, + ← clear_r (f (NineGrid.U i)) (mapped_denominator_ne_zero f hf (Sum.inr i)) j.2] + ring + +/-- The rational-coordinate matrix has nonzero determinant in every faithful realization. -/ +theorem det_genericMatrix_ne_zero {F : Type*} [Field F] + (f : Poly →+* F) (hf : Function.Injective f) : + Matrix.det (genericMatrix f) ≠ 0 := by + have hpoly : f (Matrix.det NineGrid.E) ≠ 0 := by + intro hz + apply NineGrid.det_E_ne_zero + apply hf + simpa only [map_zero] using hz + have hcleared : Matrix.det (f.mapMatrix NineGrid.E) ≠ 0 := by + rw [← f.map_det] + exact hpoly + intro hz + apply hcleared + rw [cleared_matrix f hf, Matrix.det_mul, hz, mul_zero] + +/-- The polynomial inclusion into the doubled-variable fraction field. -/ +def polynomialInclusion : Poly →+* K := algebraMap Poly K + +def t (i : Index) : K := polynomialInclusion (NineGrid.T i) +def u (i : Index) : K := polynomialInclusion (NineGrid.U i) + +def M : Matrix Index Index K := fun i j => r (t i) j.1 * r (u i) j.2 + +theorem det_M_ne_zero : Matrix.det M ≠ 0 := + det_genericMatrix_ne_zero polynomialInclusion (IsFractionRing.injective Poly K) + +section Relabel + +variable {ι : Type*} + +/-- Independent rational-function variables with arbitrary row labels. -/ +def tVar (i : ι) : IndependentTensor.JointField ι := + algebraMap (IndependentTensor.JointPoly ι) (IndependentTensor.JointField ι) + (MvPolynomial.X (Sum.inl i)) + +def uVar (i : ι) : IndependentTensor.JointField ι := + algebraMap (IndependentTensor.JointPoly ι) (IndependentTensor.JointField ι) + (MvPolynomial.X (Sum.inr i)) + +/-- Rename the polynomial variables bijectively and include them in the fraction field. -/ +def transportPoly (e : ι ≃ Index) : Poly →+* IndependentTensor.JointField ι := + (algebraMap (IndependentTensor.JointPoly ι) (IndependentTensor.JointField ι)).comp + (MvPolynomial.rename (Equiv.sumCongr e.symm e.symm)).toRingHom + +lemma transportPoly_injective (e : ι ≃ Index) : Function.Injective (transportPoly e) := + (IsFractionRing.injective (IndependentTensor.JointPoly ι) + (IndependentTensor.JointField ι)).comp + (MvPolynomial.rename_injective (Equiv.sumCongr e.symm e.symm) + (Equiv.sumCongr e.symm e.symm).injective) + +/-- Both axes are reindexed by e. Columns encode the two coordinate indices. -/ +def transportedMatrix (e : ι ≃ Index) : Matrix ι ι (IndependentTensor.JointField ι) := + (genericMatrix (transportPoly e)).submatrix e e + +lemma transportedMatrix_apply (e : ι ≃ Index) (i j : ι) : + transportedMatrix e i j = r (tVar i) (e j).1 * r (uVar i) (e j).2 := by + simp [transportedMatrix, genericMatrix, transportPoly, NineGrid.T, NineGrid.U, + tVar, uVar] + +theorem det_transportedMatrix_ne_zero [Fintype ι] [DecidableEq ι] (e : ι ≃ Index) : + Matrix.det (transportedMatrix e) ≠ 0 := by + change Matrix.det ((genericMatrix (transportPoly e)).submatrix e e) ≠ 0 + rw [Matrix.det_submatrix_equiv_self] + exact det_genericMatrix_ne_zero (transportPoly e) (transportPoly_injective e) + +end Relabel + +/-- Concrete row/column enumeration of the nine tensor coordinates. -/ +def fin9Equiv : Fin 9 ≃ Index := (finProdFinEquiv : Index ≃ Fin (3 * 3)).symm + +def fin9Matrix : Matrix (Fin 9) (Fin 9) (IndependentTensor.JointField (Fin 9)) := + transportedMatrix fin9Equiv + +lemma fin9Matrix_apply (i j : Fin 9) : + fin9Matrix i j = r (tVar i) (fin9Equiv j).1 * r (uVar i) (fin9Equiv j).2 := + transportedMatrix_apply fin9Equiv i j + +theorem det_fin9Matrix_ne_zero : Matrix.det fin9Matrix ≠ 0 := + det_transportedMatrix_ne_zero fin9Equiv + +end EuclideanRamsey.NineRational + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/NineStatement.lean b/lean/OAI/Combinatorics/EuclideanRamsey/NineStatement.lean new file mode 100644 index 0000000000000000000000000000000000000000..da584d3c77f07319fb952417a0e10d2f59270907 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/NineStatement.lean @@ -0,0 +1,36 @@ +import OAI.Combinatorics.EuclideanRamsey.Nine + +namespace OAI + +/-! The literal rational parametrization of the nine-point circle configuration. -/ + +noncomputable section +namespace EuclideanRamsey.NineStatement + +/-- The rational parametrization of nine points in the Euclidean plane. -/ +def literalCircleConfig (t : Fin 9 → ℝ) (i : Fin 9) : Space 2 := + WithLp.toLp 2 ![(1 - (t i)^2) / (1 + (t i)^2), + (2 * t i) / (1 + (t i)^2)] + +theorem literalCircleConfig_eq (t : Fin 9 → ℝ) : + literalCircleConfig t = NineGeometry.circleConfig t := by + funext i + ext j + fin_cases j <;> + simp [literalCircleConfig, NineGeometry.circleConfig] + +/-- Nine points on the unit circle form a non-Ramsey configuration when their +parameters are algebraically independent over the rationals. -/ +theorem nine_circle_configuration (t : Fin 9 → ℝ) + (ht : AlgebraicIndependent ℚ t) : + Function.Injective (literalCircleConfig t) ∧ + (∀ i, dist (literalCircleConfig t i) 0 = 1) ∧ + ¬ Ramsey (literalCircleConfig t) := by + rw [literalCircleConfig_eq] + exact NineMain.nine_circle_configuration t ht + +end EuclideanRamsey.NineStatement + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/NormalCost.lean b/lean/OAI/Combinatorics/EuclideanRamsey/NormalCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..0695404a2dc841d23659b67f74558603f0c9ca30 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/NormalCost.lean @@ -0,0 +1,161 @@ +import OAI.Combinatorics.EuclideanRamsey.ColoringCompactness + +namespace OAI + +universe uGroup uAction uPoint uAlpha + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace +open Filter +open Set + +namespace EuclideanRamsey +open scoped BigOperators commutatorElement +variable {G : Type uGroup} {H : Type uAction} {X : Type uPoint} [Group G] [Group H] [MulAction H X] + +def SameOrbit (x y : X) : Prop := ∃ h : H,h • x=y +lemma SameOrbit.refl (x : X) : SameOrbit (H:=H) x x := ⟨1,one_smul _ _⟩ +lemma SameOrbit.symm {x y : X} (h : SameOrbit (H:=H) x y) : SameOrbit (H:=H) y x := by + obtain ⟨h,rfl⟩ := h + exact ⟨h⁻¹,inv_smul_smul h x⟩ +lemma SameOrbit.trans {x y z : X} (h : SameOrbit (H:=H) x y) (h' : SameOrbit (H:=H) y z) : + SameOrbit (H:=H) x z := by + obtain ⟨h,rfl⟩ := h + obtain ⟨g,rfl⟩ := h' + exact ⟨g*h,mul_smul _ _ _⟩ +lemma SameOrbit.smul (x : X) (h : H) : SameOrbit (H:=H) x (h•x) := ⟨h,rfl⟩ + +structure NormalCost (L : Subgroup G) where + cost : G → ℝ + nonneg : ∀ g,0≤cost g + one : cost 1=0 + inv : ∀ g∈L,cost g⁻¹=cost g + conj : ∀ g∈L,∀ k,cost (k*g*k⁻¹)=cost g + mul : ∀ g∈L,∀ h∈L,cost (g*h)≤cost g+cost h +namespace NormalCost +variable {L : Subgroup G} [L.Normal] (c : NormalCost L) +omit [L.Normal] in +lemma list_mem (l : List G) (h : ∀ g∈l,g∈L) : l.prod∈L := L.list_prod_mem h +omit [L.Normal] in +lemma list_bound (l : List G) (h : ∀ g∈l,g∈L) : + c.cost l.prod ≤ (l.map c.cost).sum := by + induction l with + | nil => simp [c.one] + | cons g l ih => + have hg := h g (by simp) + have hl : ∀ x∈l,x∈L := fun x hx => h x (by simp [hx]) + exact (c.mul g hg l.prod (L.list_prod_mem hl)).trans (by simpa using add_le_add_left (ih hl) (c.cost g)) +omit [L.Normal] in +lemma list_bound_const (l : List G) (h : ∀ g∈l,g∈L) (B : ℝ) (hB : ∀ g∈l,c.cost g≤B) : + c.cost l.prod ≤ (l.length:ℝ)*B := by + refine (c.list_bound l h).trans ?_ + induction l with + | nil => simp + | cons g l ih => + have hh := ih (fun x hx => h x (by simp [hx])) (fun x hx => hB x (by simp [hx])) + simpa [Nat.cast_add,Nat.cast_one,add_mul,add_comm] using add_le_add (hB g (by simp)) hh + +lemma product_difference {α : Type uAlpha} (l : List α) (a b : α → G) + (h : ∀ j∈l,a j*(b j)⁻¹∈L) : + (l.map a).prod*((l.map b).prod)⁻¹∈L ∧ + c.cost ((l.map a).prod*((l.map b).prod)⁻¹) ≤ + (l.map (fun j => c.cost (a j*(b j)⁻¹))).sum := by + induction l with + | nil => simp [c.one,L.one_mem] + | cons j l ih => + obtain ⟨hm,hc⟩ := ih (fun k hk => h k (by simp [hk])) + have hj := h j (by simp) + let z := (l.map a).prod*((l.map b).prod)⁻¹ + have he : (a j*(l.map a).prod)*(b j*(l.map b).prod)⁻¹ = + (a j*z*(a j)⁻¹)*(a j*(b j)⁻¹) := by dsimp [z]; group + have hz : a j*z*(a j)⁻¹∈L := (inferInstance : L.Normal).conj_mem _ hm _ + simp only [List.map_cons,List.prod_cons,List.sum_cons] + rw [he] + refine ⟨L.mul_mem hz hj,?_⟩ + exact (c.mul _ hz _ hj).trans (by rw [c.conj z hm]; linarith) +end NormalCost + +lemma product_difference_mem {N : Subgroup G} [N.Normal] {α : Type uAlpha} + (l : List α) (a b : α → G) (h : ∀ j∈l,a j*(b j)⁻¹∈N) : + (l.map a).prod*((l.map b).prod)⁻¹∈N := by + let q := QuotientGroup.mk' N + apply (QuotientGroup.eq_one_iff _).mp + change q ((l.map a).prod*((l.map b).prod)⁻¹)=1 + rw [map_mul,map_inv,mul_inv_eq_one] + simp only [map_list_prod,List.map_map] + congr 1 + apply List.map_congr_left + intro j hj + apply QuotientGroup.eq_iff_div_mem.mpr + simpa only [div_eq_mul_inv] using h j hj + +noncomputable def groupList (H : Type uAction) [Fintype H] : List H := (Finset.univ : Finset H).toList +omit [Group H] in +lemma groupList_mem [Fintype H] (h : H) : h∈groupList H := by + classical + simp [groupList] +omit [Group H] in +lemma groupList_length [Fintype H] : (groupList H).length=Fintype.card H := by + classical + simp [groupList] +lemma groupList_mul_perm [Fintype H] (h : H) : + ((groupList H).map (·*h)).Perm (groupList H) := by + classical + apply (List.perm_ext_iff_of_nodup ((Finset.nodup_toList _).map (mul_left_injective h)) + (Finset.nodup_toList _)).mpr + intro g + simp only [List.mem_map,Finset.mem_toList,Finset.mem_univ,true_and,iff_true] + exact ⟨g*h⁻¹,by group⟩ + +noncomputable def orbitAverage [Fintype H] (w : X → G) (x : X) : G := + ((groupList H).map (fun h => w (h•x))).prod + +lemma orbitAverage_preserves [Fintype H] (N : Subgroup G) [N.Normal] + (w : X → G) (x y : X) + (h : ∀ g : H,w (g•x)*(w (g•y))⁻¹∈N) : + orbitAverage (H:=H) w x*(orbitAverage (H:=H) w y)⁻¹∈N := + product_difference_mem _ _ _ (fun g _ => h g) + +lemma orbitAverage_derived [Fintype H] (N : Subgroup G) [N.Normal] + (w : X → G) (x y : X) (horbit : SameOrbit (H:=H) x y) + (hw : ∀ g : H,w (g•x)∈N) : + orbitAverage (H:=H) w x*(orbitAverage (H:=H) w y)⁻¹∈⁅N,N⁆ := by + obtain ⟨h,rfl⟩ := horbit + let q := QuotientGroup.mk' ⁅N,N⁆ + rw [← div_eq_mul_inv] + apply QuotientGroup.eq_iff_div_mem.mp + change q (orbitAverage (H:=H) w x)=q (orbitAverage (H:=H) w (h•x)) + simp only [orbitAverage,map_list_prod,List.map_map] + have hp := (groupList_mul_perm h).map (fun g => q (w (g•x))) + simp only [List.map_map,Function.comp_def,mul_smul] at hp + symm + apply hp.prod_eq' + apply List.pairwise_map.mpr + apply List.pairwise_of_forall + intro g k + apply commutatorElement_eq_one_iff_commute.mp + rw [← map_commutatorElement] + exact (QuotientGroup.eq_one_iff _).mpr + (Subgroup.commutator_mem_commutator (by simpa only [mul_smul] using hw (g*h)) + (by simpa only [mul_smul] using hw (k*h))) +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/OrbitAveraging.lean b/lean/OAI/Combinatorics/EuclideanRamsey/OrbitAveraging.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e1219f7d51fc6ec5011e6fd9ddf372ed9b6b960 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/OrbitAveraging.lean @@ -0,0 +1,311 @@ +import OAI.Combinatorics.EuclideanRamsey.NormalCost + +namespace OAI + +universe uGroup uAction uPoint + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace +open Filter +open Set + +namespace EuclideanRamsey +open scoped BigOperators +variable {G : Type uGroup} {H : Type uAction} {X : Type uPoint} [Group G] [Group H] [MulAction H X] + +inductive OrbitWords (letter : X → G) : (X → G) → ℕ → Prop + | diag (g : G) : OrbitWords letter (fun _ => g) 0 + | point (h : H) : OrbitWords letter (fun x => letter (h•x)) 1 + | mul {u v m n} : OrbitWords letter u m → OrbitWords letter v n → OrbitWords letter (u*v) (m+n) +namespace OrbitWords +variable {letter : X → G} {w : X → G} {m : ℕ} +lemma reindex (hw : OrbitWords (H:=H) letter w m) (g : H) : + OrbitWords (H:=H) letter (fun x => w (g•x)) m := by + induction hw with + | diag a => exact .diag a + | point h => simpa only [mul_smul] using (point (letter:=letter) (h*g)) + | mul _ _ ihu ihv => exact .mul ihu ihv +lemma normalize (hw : OrbitWords (H:=H) letter w m) (a : G) : + OrbitWords (H:=H) letter (fun x => w x*a) m := by + simpa only [Nat.add_zero,Pi.mul_def] using hw.mul (.diag a) +lemma average [Fintype H] (hw : OrbitWords (H:=H) letter w m) : + OrbitWords (H:=H) letter (orbitAverage (H:=H) w) (Fintype.card H*m) := by + have aux (l : List H) : OrbitWords (H:=H) letter + (fun x => (l.map (fun h => w (h•x))).prod) (l.length*m) := by + induction l with + | nil => simpa using (diag (letter:=letter) (H:=H) 1) + | cons h l ih => simpa [Nat.add_mul,add_comm,Pi.mul_def] using (hw.reindex h).mul ih + change OrbitWords letter (fun x => ((groupList H).map (fun h => w (h•x))).prod) _ + simpa only [groupList_length] using aux (groupList H) +end OrbitWords + +def OrbitIn (N : Subgroup G) (w : X → G) (x : X) : Prop := + ∀ y z,SameOrbit (H:=H) x y → SameOrbit (H:=H) x z → w y*(w z)⁻¹∈N + +def OrbitBound {L : Subgroup G} (c : NormalCost L) (w : X → G) (b : ℝ) (x : X) : Prop := + OrbitIn (H:=H) L w x ∧ ∀ y z,SameOrbit (H:=H) x y → SameOrbit (H:=H) x z → + c.cost (w y*(w z)⁻¹)≤b + +lemma orbitIn_normalize {N : Subgroup G} {w : X → G} {x : X} + (hw : OrbitIn (H:=H) N w x) (a : G) : OrbitIn (H:=H) N (fun y => w y*a) x := by + intro y z hy hz + simpa only [_root_.mul_inv_rev,mul_assoc,mul_inv_cancel_left] using hw y z hy hz + +lemma orbitIn_average [Fintype H] {N : Subgroup G} [N.Normal] {w : X → G} {x : X} + (hw : OrbitIn (H:=H) N w x) : OrbitIn (H:=H) N (orbitAverage (H:=H) w) x := by + intro y z hy hz + apply orbitAverage_preserves + intro g + exact hw _ _ (hy.trans (SameOrbit.smul y g)) (hz.trans (SameOrbit.smul z g)) + +lemma orbitBound_normalize {L : Subgroup G} {c : NormalCost L} {w : X → G} {b : ℝ} {x : X} + (hw : OrbitBound (H:=H) c w b x) (a : G) : + OrbitBound (H:=H) c (fun y => w y*a) b x := by + refine ⟨orbitIn_normalize hw.1 a,?_⟩ + intro y z hy hz + simpa only [_root_.mul_inv_rev,mul_assoc,mul_inv_cancel_left] using hw.2 y z hy hz + +lemma orbitBound_average [Fintype H] {L : Subgroup G} [L.Normal] {c : NormalCost L} + {w : X → G} {b : ℝ} {x : X} (hw : OrbitBound (H:=H) c w b x) : + OrbitBound (H:=H) c (orbitAverage (H:=H) w) (Fintype.card H*b) x := by + refine ⟨orbitIn_average hw.1,?_⟩ + intro y z hy hz + refine (c.product_difference (groupList H) (fun g => w (g•y)) (fun g => w (g•z)) + (fun g _ => hw.1 _ _ (hy.trans (SameOrbit.smul y g)) (hz.trans (SameOrbit.smul z g)))).2.trans ?_ + have hh : ∀ g∈groupList H,c.cost (w (g•y)*(w (g•z))⁻¹)≤b := fun g _ => + hw.2 _ _ (hy.trans (SameOrbit.smul y g)) (hz.trans (SameOrbit.smul z g)) + calc + _ ≤ ((groupList H).map (fun _ => b)).sum := List.sum_le_sum hh + _ = _ := by simp [List.map_const',groupList_length,List.sum_replicate, nsmul_eq_mul] + +lemma orbitIn_raise [Fintype H] (N : Subgroup G) [N.Normal] {w : X → G} {x : X} + (hw : OrbitIn (H:=H) N w x) : + OrbitIn (H:=H) ⁅N,N⁆ (orbitAverage (H:=H) (fun y => w y*(w x)⁻¹)) x := by + intro y z hy hz + apply orbitAverage_derived N + · exact hy.symm.trans hz + · intro g + exact hw _ _ (hy.trans (SameOrbit.smul y g)) (SameOrbit.refl x) + +lemma contraction_bound [Fintype H] {L : Subgroup G} [L.Normal] (c : NormalCost L) + (w : X → G) (x y : X) (hxy : SameOrbit (H:=H) x y) (B : ℝ) + (hm : ∀ z,SameOrbit (H:=H) x z → w z∈L) + (hb : ∀ z,SameOrbit (H:=H) x z → c.cost (w z)≤B) : + orbitAverage (H:=H) w y*(w x)⁻¹∈L ∧ + c.cost (orbitAverage (H:=H) w y*(w x)⁻¹) ≤ (Fintype.card H-1:ℝ)*B := by + obtain ⟨g,hg⟩ := hxy.symm + obtain ⟨p,q,he⟩ := List.mem_iff_append.mp (groupList_mem g) + let a := (p.map (fun h => w (h•y))).prod + let b := (q.map (fun h => w (h•y))).prod + have hmem (h : H) : w (h•y)∈L := hm _ (hxy.trans (SameOrbit.smul y h)) + have hcost (h : H) : c.cost (w (h•y))≤B := hb _ (hxy.trans (SameOrbit.smul y h)) + have ha : a∈L := L.list_prod_mem (by simpa using fun h (_ : h∈p) => hmem h) + have hb' : b∈L := L.list_prod_mem (by simpa using fun h (_ : h∈q) => hmem h) + have hc : w x*b*(w x)⁻¹∈L := (inferInstance : L.Normal).conj_mem _ hb' _ + have hid : orbitAverage (H:=H) w y*(w x)⁻¹=a*(w x*b*(w x)⁻¹) := by + simp [orbitAverage,he,hg,a,b,List.prod_append,mul_assoc] + rw [hid] + refine ⟨L.mul_mem ha hc,?_⟩ + have hca : c.cost a≤(p.length:ℝ)*B := by + simpa only [List.length_map] using c.list_bound_const (p.map (fun h => w (h•y))) + (by simpa using fun h (_ : h∈p) => hmem h) B + (by simpa using fun h (_ : h∈p) => hcost h) + have hcb : c.cost b≤(q.length:ℝ)*B := by + simpa only [List.length_map] using c.list_bound_const (q.map (fun h => w (h•y))) + (by simpa using fun h (_ : h∈q) => hmem h) B + (by simpa using fun h (_ : h∈q) => hcost h) + have hn : (Fintype.card H:ℝ)=(p.length:ℝ)+1+(q.length:ℝ) := by + have := congrArg List.length he + rw [groupList_length] at this + exact_mod_cast (by simpa [List.length_append,add_assoc,add_comm,add_left_comm] using this) + calc + _ ≤ c.cost a+c.cost b := by simpa [c.conj b hb'] using c.mul a ha _ hc + _ ≤ _ := by rw [hn]; nlinarith +end EuclideanRamsey +namespace EuclideanRamsey +open scoped BigOperators +variable {G : Type uGroup} {H : Type uAction} {X : Type uPoint} [Group G] [Group H] [MulAction H X] [Fintype H] + +inductive Evolution : (X → G) → ℕ → (X → G) → ℕ → Prop + | refl (w m) : Evolution w m w m + | normalize {w m v n} : Evolution w m v n → (a : G) → + Evolution w m (fun x => v x*a) n + | average {w m v n} : Evolution w m v n → + Evolution w m (orbitAverage (H:=H) v) (Fintype.card H*n) +namespace Evolution +variable {w v u : X → G} {m n k : ℕ} +lemma trans (h : Evolution (H:=H) w m v n) (h' : Evolution (H:=H) v n u k) : + Evolution (H:=H) w m u k := by + induction h' with + | refl => exact h + | normalize _ a ih => exact ih.normalize a + | average _ ih => exact ih.average +lemma words {letter : X → G} (h : Evolution (H:=H) w m v n) + (hw : OrbitWords (H:=H) letter w m) : OrbitWords (H:=H) letter v n := by + induction h with + | refl => exact hw + | normalize _ a ih => exact ih.normalize a + | average _ ih => exact ih.average +lemma positive (h : Evolution (H:=H) w m v n) (hm : 0 < m) : 0 < n := by + induction h with + | refl => exact hm + | normalize _ _ ih => exact ih + | average _ ih => exact Nat.mul_pos Fintype.card_pos ih +lemma orbitIn (h : Evolution (H:=H) w m v n) {N : Subgroup G} [N.Normal] {x : X} + (hw : OrbitIn (H:=H) N w x) : OrbitIn (H:=H) N v x := by + induction h with + | refl => exact hw + | normalize _ a ih => exact orbitIn_normalize ih a + | average _ ih => exact orbitIn_average ih +lemma orbitBound (h : Evolution (H:=H) w m v n) {L : Subgroup G} [L.Normal] + {c : NormalCost L} {δ : ℝ} {x : X} (hw : OrbitBound (H:=H) c w (δ*m) x) : + OrbitBound (H:=H) c v (δ*n) x := by + induction h with + | refl => exact hw + | normalize _ a ih => exact orbitBound_normalize ih a + | average _ ih => + simpa only [Nat.cast_mul,mul_left_comm] using orbitBound_average ih +end Evolution + +lemma evolve_finite [Fintype X] (w : X → G) (m : ℕ) + (Good : X → (X → G) → ℕ → Prop) + (preserve : ∀ {v n u k},Evolution (H:=H) v n u k → ∀ x,Good x v n → Good x u k) + (improve : ∀ {v n},Evolution (H:=H) w m v n → ∀ x, + ∃ u k,Evolution (H:=H) v n u k ∧ Good x u k) : + ∃ v n,Evolution (H:=H) w m v n ∧ ∀ x,Good x v n := by + classical + have aux (t : Finset X) : ∃ v n,Evolution (H:=H) w m v n ∧ ∀ x∈t,Good x v n := by + induction t using Finset.induction_on with + | empty => exact ⟨w,m,.refl _ _,by simp⟩ + | @insert x t hx ih => + obtain ⟨v,n,hev,hv⟩ := ih + obtain ⟨u,k,heu,hu⟩ := improve hev x + refine ⟨u,k,hev.trans heu,?_⟩ + intro y hy + rcases Finset.mem_insert.mp hy with rfl | hy + · exact hu + · exact preserve heu y (hv y hy) + simpa using aux Finset.univ + +lemma orbit_raise_depth (N : Subgroup G) [N.Normal] (r : ℕ) (w : X → G) (m : ℕ) + (x : X) (hw : OrbitIn (H:=H) N w x) : + ∃ v n,Evolution (H:=H) w m v n ∧ OrbitIn (H:=H) (Derived N r) v x := by + induction r with + | zero => exact ⟨w,m,.refl _ _,hw⟩ + | succ r ih => + obtain ⟨v,n,hev,hv⟩ := ih + exact ⟨_,_,(hev.normalize (v x)⁻¹).average,orbitIn_raise (Derived N r) hv⟩ + +lemma all_orbits_derived [Fintype X] (N : Subgroup G) [N.Normal] (r : ℕ) + (w : X → G) (m : ℕ) (hw : ∀ x,OrbitIn (H:=H) N w x) : + ∃ v n,Evolution (H:=H) w m v n ∧ ∀ x,OrbitIn (H:=H) (Derived N r) v x := by + apply evolve_finite w m (fun x v _ => OrbitIn (H:=H) (Derived N r) v x) + · intro v n u k he x hx + exact he.orbitIn hx + · intro v n he x + exact orbit_raise_depth N r v n x (he.orbitIn (hw x)) + +lemma contraction_iterate {L : Subgroup G} [L.Normal] (c : NormalCost L) + (w : X → G) (m : ℕ) (x : X) (B : ℝ) + (hm : ∀ y,SameOrbit (H:=H) x y → w y∈L) + (hb : ∀ y,SameOrbit (H:=H) x y → c.cost (w y)≤B) (k : ℕ) : + ∃ v,Evolution (H:=H) w m v ((Fintype.card H)^k*m) ∧ + (∀ y,SameOrbit (H:=H) x y → v y∈L) ∧ + ∀ y,SameOrbit (H:=H) x y → c.cost (v y)≤B*(Fintype.card H-1:ℝ)^k := by + induction k with + | zero => exact ⟨w,by simpa using (Evolution.refl (H:=H) w m),hm,by simpa using hb⟩ + | succ k ih => + obtain ⟨v,hev,hm,hb⟩ := ih + refine ⟨fun y => orbitAverage (H:=H) v y*(v x)⁻¹,?_,?_,?_⟩ + · convert hev.average.normalize (v x)⁻¹ using 1 ; simp [pow_succ,mul_left_comm,mul_comm] + · intro y hy + exact (contraction_bound c v x y hy _ hm hb).1 + · intro y hy + convert (contraction_bound c v x y hy _ hm hb).2 using 1 ; ring + +lemma contraction_rate (h m : ℕ) (hh : 0 < h) (hm : 0 < m) (B δ : ℝ) (hB : 0≤B) (hδ : 0 < δ) : + ∃ k : ℕ,2*(B*(h-1:ℝ)^k)≤δ*((h^k*m:ℕ):ℝ) := by + have hh' : (0:ℝ) w y*(w x)⁻¹ + let B : ℝ := ∑ y,c.cost (w₀ y) + have hB : 0≤B := Finset.sum_nonneg (fun y _ => c.nonneg _) + have hmem : ∀ y,SameOrbit (H:=H) x y → w₀ y∈L := + fun y hy => hw y x hy (SameOrbit.refl x) + have hbound : ∀ y,SameOrbit (H:=H) x y → c.cost (w₀ y)≤B := by + intro y _ + exact Finset.single_le_sum (fun z _ => c.nonneg _) (Finset.mem_univ y) + obtain ⟨k,hk⟩ := contraction_rate (Fintype.card H) m Fintype.card_pos hm B δ hB hδ + obtain ⟨v,hev,hvm,hvb⟩ := contraction_iterate c w₀ m x B hmem hbound k + refine ⟨v,(Fintype.card H)^k*m,(Evolution.normalize (.refl w m) (w x)⁻¹).trans hev,?_,?_⟩ + · intro y z hy hz + exact L.mul_mem (hvm y hy) (L.inv_mem (hvm z hz)) + · intro y z hy hz + have hcm := c.mul (v y) (hvm y hy) (v z)⁻¹ (L.inv_mem (hvm z hz)) + rw [c.inv _ (hvm z hz)] at hcm + exact hcm.trans ((add_le_add (hvb y hy) (hvb z hz)).trans (by linarith)) + +theorem finite_group_averaging (N : Subgroup G) [N.Normal] (r : ℕ) + (c : NormalCost (Derived N r)) (letter : X → G) + (hletter : ∀ x y,letter x*(letter y)⁻¹∈N) (δ : ℝ) (hδ : 0 < δ) : + ∃ (w : X → G) (m : ℕ),OrbitWords (H:=H) letter w m ∧ 0 < m ∧ + ∀ x y,SameOrbit (H:=H) x y → + w x*(w y)⁻¹∈Derived N r ∧ c.cost (w x*(w y)⁻¹)≤δ*m := by + have hstart : OrbitWords (H:=H) letter letter 1 := by + simpa only [one_smul] using (OrbitWords.point (letter:=letter) (1:H)) + obtain ⟨v,n,hev,hv⟩ := all_orbits_derived (H:=H) N r letter 1 (fun _ _ _ _ _ => hletter _ _) + have hn : 0 < n := hev.positive Nat.zero_lt_one + obtain ⟨w,m,hew,hw⟩ := evolve_finite v n (fun x w m => OrbitBound (H:=H) c w (δ*m) x) + (by intro _ _ _ _ he x hx; exact he.orbitBound hx) + (by + intro u k he x + exact orbit_make_small c u k (he.positive hn) x (he.orbitIn (hv x)) δ hδ) + refine ⟨w,m,hew.words (hev.words hstart),hew.positive hn,?_⟩ + intro x y hxy + exact ⟨(hw x).1 x y (SameOrbit.refl x) hxy,(hw x).2 x y (SameOrbit.refl x) hxy⟩ +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/PathFractions.lean b/lean/OAI/Combinatorics/EuclideanRamsey/PathFractions.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3a715b20ac12dd70eba9e1a1f041766c3ea2aae --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/PathFractions.lean @@ -0,0 +1,247 @@ +import OAI.Combinatorics.EuclideanRamsey.FiniteEuclidean + +namespace OAI + +universe uGroup uIndex + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace + +open scoped BigOperators +namespace EuclideanRamsey +section Fractions +variable {G : Type uGroup} {ι : Type uIndex} [Group G] [DecidableEq ι] + +def RightFraction (M : Submonoid (ι → G)) (z : ι → G) : Prop := + ∃ u ∈ M,∃ v ∈ M,z=u*v⁻¹ + +def HasDiagonal (M : Submonoid (ι → G)) : Prop := ∀ g : G,(fun _ => g)∈M + +def PairInverse (M : Submonoid (ι → G)) : Prop := + ∀ i j : ι,i≠j → ∀ v∈M,∃ b∈M,v i*b i=1 ∧ v j*b j=1 + +omit [DecidableEq ι] in +lemma RightFraction.one (M : Submonoid (ι → G)) : RightFraction M 1 := + ⟨1,M.one_mem,1,M.one_mem,by simp⟩ +omit [DecidableEq ι] in +lemma RightFraction.inv {M : Submonoid (ι → G)} {z : ι → G} + (h : RightFraction M z) : RightFraction M z⁻¹ := by + obtain ⟨u,hu,v,hv,rfl⟩ := h + exact ⟨v,hv,u,hu,by group⟩ +omit [DecidableEq ι] in +lemma RightFraction.conjugate {M : Submonoid (ι → G)} (hM : HasDiagonal M) + {z : ι → G} (h : RightFraction M z) (g : G) : + RightFraction M (fun i => g*z i*g⁻¹) := by + obtain ⟨u,hu,v,hv,rfl⟩ := h + refine ⟨(fun _ => g)*u,M.mul_mem (hM g) hu,(fun _ => g)*v,M.mul_mem (hM g) hv,?_⟩ + ext i + simp only [Pi.mul_apply,Pi.inv_apply] + group + +lemma conjugate_single (i : ι) (g h : G) : + (fun j => g*(Pi.mulSingle i h : ι → G) j*g⁻¹)=Pi.mulSingle i (g*h*g⁻¹) := by + ext j + by_cases hj : j=i <;> simp [hj] + +lemma RightFraction.mul_single {M : Submonoid (ι → G)} (hM : HasDiagonal M) + {z : ι → G} (hz : RightFraction M z) (i : ι) {g : G} + (hg : RightFraction M (Pi.mulSingle i g)) : RightFraction M (z*Pi.mulSingle i g) := by + obtain ⟨u,hu,v,hv,rfl⟩ := hz + have hh := hg.conjugate hM (v i)⁻¹ + rw [conjugate_single,inv_inv] at hh + obtain ⟨a,ha,b,hb,he⟩ := hh + refine ⟨u*a,M.mul_mem hu ha,v*b,M.mul_mem hv hb,?_⟩ + have ht : v⁻¹*Pi.mulSingle i g = Pi.mulSingle i ((v i)⁻¹*g*v i)*v⁻¹ := by + ext j + by_cases hj : j=i + · subst j; simp + · simp [Pi.mulSingle_eq_of_ne hj] + rw [mul_assoc,ht,he] + group + +def singleFractions (M : Submonoid (ι → G)) (hM : HasDiagonal M) (i : ι) : Subgroup G where + carrier := {g | RightFraction M (Pi.mulSingle i g)} + one_mem' := by simpa using RightFraction.one M + mul_mem' {a b} ha hb := by + change RightFraction M (Pi.mulSingle i (a*b)) + rw [Pi.mulSingle_mul] + exact ha.mul_single hM i hb + inv_mem' {a} ha := by + change RightFraction M (Pi.mulSingle i a⁻¹) + rw [Pi.mulSingle_inv] + exact ha.inv + +instance singleFractions_normal (M : Submonoid (ι → G)) (hM : HasDiagonal M) (i : ι) : + (singleFractions M hM i).Normal where + conj_mem g hg k := by + change RightFraction M (Pi.mulSingle i (k*g*k⁻¹)) + rw [← conjugate_single] + exact hg.conjugate hM k + +lemma RightFraction.mul_pair {M : Submonoid (ι → G)} (hM : PairInverse M) + {z t : ι → G} (hz : RightFraction M z) (ht : RightFraction M t) + (i j : ι) (hij : i≠j) (hs : ∀ l,l≠i → l≠j → t l=1) : + RightFraction M (z*t) := by + obtain ⟨u,hu,v,hv,rfl⟩ := hz + obtain ⟨c,hc,d,hd,rfl⟩ := ht + obtain ⟨b,hb,hi,hj⟩ := hM i j hij v hv + have hcomm : Commute (v*b) (c*d⁻¹) := by + ext l + by_cases hli : l=i + · subst l; simp only [Pi.mul_apply,Pi.inv_apply] at *; rw [hi]; simp + by_cases hlj : l=j + · subst l; simp only [Pi.mul_apply,Pi.inv_apply] at *; rw [hj]; simp + · have hh := hs l hli hlj + change v l*b l*(c l*(d l)⁻¹) = (c l*(d l)⁻¹)*(v l*b l) + change c l*(d l)⁻¹=1 at hh + rw [hh]; simp + refine ⟨u*b*c,M.mul_mem (M.mul_mem hu hb) hc,(v*b)*d,M.mul_mem (M.mul_mem hv hb) hd,?_⟩ + have he : u*v⁻¹ = (u*b)*(v*b)⁻¹ := by group + rw [he,mul_assoc,hcomm.inv_left.eq] + group +end Fractions +end EuclideanRamsey +namespace EuclideanRamsey +open scoped BigOperators +variable {G : Type uGroup} {ι : Type uIndex} [Group G] [DecidableEq ι] + +structure GradedPaths (ι : Type uIndex) (G : Type uGroup) [Group G] where + Holds : (ι → G) → ℕ → Prop + diag : ∀ g,Holds (fun _ => g) 0 + mul : ∀ {u v m n},Holds u m → Holds v n → Holds (u*v) (m+n) +namespace GradedPaths +variable (P : GradedPaths ι G) +def monoid : Submonoid (ι → G) where + carrier := {u | ∃ n,P.Holds u n} + one_mem' := ⟨0,P.diag 1⟩ + mul_mem' := by rintro u v ⟨m,hm⟩ ⟨n,hn⟩; exact ⟨m+n,P.mul hm hn⟩ +omit [DecidableEq ι] in +lemma diagonal : HasDiagonal P.monoid := fun g => ⟨0,P.diag g⟩ + +def BoundedFraction (z : ι → G) (c : ℕ) : Prop := + ∃ (u v : ι → G) (m n : ℕ),P.Holds u m ∧ P.Holds v n ∧ z=u*v⁻¹ ∧ m+n≤c +omit [DecidableEq ι] in +lemma bounded_exists {z : ι → G} (h : RightFraction P.monoid z) : + ∃ c,P.BoundedFraction z c := by + obtain ⟨u,⟨m,hm⟩,v,⟨n,hn⟩,he⟩ := h + exact ⟨m+n,u,v,m,n,hm,hn,he,le_rfl⟩ +omit [DecidableEq ι] in +lemma bounded_fraction {z : ι → G} {c : ℕ} (h : P.BoundedFraction z c) : + RightFraction P.monoid z := by + obtain ⟨u,v,m,n,hm,hn,he,_⟩ := h + exact ⟨u,⟨m,hm⟩,v,⟨n,hn⟩,he⟩ +omit [DecidableEq ι] in +lemma bounded_one : P.BoundedFraction 1 0 := + ⟨1,1,0,0,P.diag 1,P.diag 1,by simp,le_rfl⟩ +omit [DecidableEq ι] in +lemma bounded_mono {z : ι → G} {c d : ℕ} (h : P.BoundedFraction z c) (hc : c≤d) : + P.BoundedFraction z d := by + obtain ⟨u,v,m,n,hm,hn,he,hc'⟩ := h + exact ⟨u,v,m,n,hm,hn,he,hc'.trans hc⟩ +omit [DecidableEq ι] in +lemma bounded_inv {z : ι → G} {c : ℕ} (h : P.BoundedFraction z c) : + P.BoundedFraction z⁻¹ c := by + obtain ⟨u,v,m,n,hm,hn,rfl,hc⟩ := h + exact ⟨v,u,n,m,hn,hm,by group,by omega⟩ +omit [DecidableEq ι] in +lemma bounded_conjugate {z : ι → G} {c : ℕ} (h : P.BoundedFraction z c) (g : G) : + P.BoundedFraction (fun i => g*z i*g⁻¹) c := by + obtain ⟨u,v,m,n,hm,hn,rfl,hc⟩ := h + refine ⟨(fun _ => g)*u,(fun _ => g)*v,m,n,?_,?_,?_,hc⟩ + · simpa using P.mul (P.diag g) hm + · simpa using P.mul (P.diag g) hn + · ext i; simp only [Pi.mul_apply,Pi.inv_apply]; group +lemma bounded_mul_single {z : ι → G} {c d : ℕ} (hz : P.BoundedFraction z c) + (i : ι) {g : G} (hg : P.BoundedFraction (Pi.mulSingle i g) d) : + P.BoundedFraction (z*Pi.mulSingle i g) (c+d) := by + obtain ⟨u,v,m,n,hm,hn,rfl,hc⟩ := hz + have hh := P.bounded_conjugate hg (v i)⁻¹ + rw [conjugate_single,inv_inv] at hh + obtain ⟨a,b,k,l,hk,hl,he,hd⟩ := hh + refine ⟨u*a,v*b,m+k,n+l,P.mul hm hk,P.mul hn hl,?_,by omega⟩ + have ht : v⁻¹*Pi.mulSingle i g = Pi.mulSingle i ((v i)⁻¹*g*v i)*v⁻¹ := by + ext j + by_cases hj : j=i + · subst j; simp + · simp [Pi.mulSingle_eq_of_ne hj] + rw [mul_assoc,ht,he] + group + +def singleCost (i : ι) (g : G) : ℕ := sInf {c | P.BoundedFraction (Pi.mulSingle i g) c} +lemma singleCost_bounded (i : ι) {g : G} (hg : g∈singleFractions P.monoid P.diagonal i) : + P.BoundedFraction (Pi.mulSingle i g) (P.singleCost i g) := + Nat.sInf_mem (P.bounded_exists hg) +lemma singleCost_le (i : ι) {g : G} {c : ℕ} (hc : P.BoundedFraction (Pi.mulSingle i g) c) : + P.singleCost i g ≤ c := Nat.sInf_le hc +lemma singleCost_one (i : ι) : P.singleCost i 1=0 := by + apply Nat.eq_zero_of_le_zero + apply P.singleCost_le + simpa using P.bounded_one +lemma singleCost_inv (i : ι) {g : G} (hg : g∈singleFractions P.monoid P.diagonal i) : + P.singleCost i g⁻¹=P.singleCost i g := by + apply Nat.le_antisymm + · apply P.singleCost_le + rw [Pi.mulSingle_inv] + exact P.bounded_inv (P.singleCost_bounded i hg) + · apply P.singleCost_le + have he := P.bounded_inv (P.singleCost_bounded i ((singleFractions _ _ i).inv_mem hg)) + simpa only [Pi.mulSingle_inv,inv_inv] using he +lemma singleCost_conjugate (i : ι) {g : G} (hg : g∈singleFractions P.monoid P.diagonal i) (k : G) : + P.singleCost i (k*g*k⁻¹)=P.singleCost i g := by + have hle {g : G} (hg : g∈singleFractions P.monoid P.diagonal i) (k : G) : + P.singleCost i (k*g*k⁻¹) ≤ P.singleCost i g := by + apply P.singleCost_le + rw [← conjugate_single] + exact P.bounded_conjugate (P.singleCost_bounded i hg) k + apply Nat.le_antisymm (hle hg k) + have he := hle ((singleFractions_normal P.monoid P.diagonal i).conj_mem g hg k) k⁻¹ + simpa only [inv_inv,inv_mul_cancel_left,mul_assoc,mul_inv_cancel_right,inv_mul_cancel,mul_one] using he +lemma singleCost_mul (i : ι) {g h : G} + (hg : g∈singleFractions P.monoid P.diagonal i) (hh : h∈singleFractions P.monoid P.diagonal i) : + P.singleCost i (g*h)≤P.singleCost i g+P.singleCost i h := by + apply P.singleCost_le + rw [Pi.mulSingle_mul] + exact P.bounded_mul_single (P.singleCost_bounded i hg) i (P.singleCost_bounded i hh) + +lemma bounded_tuple_list (l : List ι) (z : ι → G) (c : ι → ℕ) + (h : ∀ i∈l,P.BoundedFraction (Pi.mulSingle i (z i)) (c i)) : + P.BoundedFraction ((l.map (fun i => Pi.mulSingle i (z i))).prod) ((l.map c).sum) := by + induction l with + | nil => simpa using P.bounded_one + | cons i l ih => + have ht := (P.bounded_mul_single (ih (by intro j hj; exact h j (by simp [hj]))) i (h i (by simp))) + have he : (l.map (fun j => Pi.mulSingle j (z j))).prod*Pi.mulSingle i (z i)= + Pi.mulSingle i (z i)*(l.map (fun j => Pi.mulSingle j (z j))).prod := by + apply Commute.symm + apply Commute.list_prod_right + intro y hy + obtain ⟨j,_,rfl⟩ := List.mem_map.mp hy + by_cases hji : j=i + · subst j; exact Commute.refl _ + · ext k + by_cases hki : k=i + · subst k; simp [Pi.mulSingle_eq_of_ne (Ne.symm hji)] + · simp [Pi.mulSingle_eq_of_ne hki] + simpa [he,Nat.add_comm] using ht +end GradedPaths +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/PathSynchronization.lean b/lean/OAI/Combinatorics/EuclideanRamsey/PathSynchronization.lean new file mode 100644 index 0000000000000000000000000000000000000000..daff285de63b5ac90cc7c1c42965c28cc30b1d9a --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/PathSynchronization.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.EuclideanRamsey.UltrafilterStrings + +namespace OAI + +universe uIndex uAlpha + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace +open Filter + +namespace EuclideanRamsey +open scoped BigOperators +variable {ι : Type uIndex} {a : ι → FiniteEuclidean} + +def scaleGroup (c : ℝ) : LetterGroup →* LetterGroup := FreeGroup.map (fun z => Real.sqrt c • z) +lemma Path.scale {w lmb} (h : Path a w lmb) (c : ℝ) (hc : 0 ≤ c) : + Path a (fun i => scaleGroup c (w i)) (c*lmb) := by + induction h with + | diag g => simpa using (Path.diag (a:=a) (scaleGroup c g)) + | @copy u b hb => + have hcopy : CopyPath a (c*u) (fun i => Real.sqrt c • b i) := by + refine ⟨mul_nonneg hc hb.1,?_⟩ + intro i j + rw [← smul_sub,norm_smul,mul_pow,Real.norm_eq_abs,sq_abs,Real.sq_sqrt hc,hb.2] + ring + simpa only [scaleGroup,FreeGroup.map.of] using Path.copy _ hcopy + | mul _ _ ihu ihv => simpa only [map_mul,Pi.mul_apply,Pi.mul_def,mul_add] using ihu.mul ihv + +lemma Path.list_prod {α : Type uAlpha} (l : List α) (w : α → ι → LetterGroup) (u : α → ℝ) + (h : ∀ j∈l,Path a (w j) (u j)) : + Path a ((l.map w).prod) ((l.map u).sum) := by + induction l with + | nil => simpa only [List.map_nil,List.prod_nil,List.sum_nil,Pi.one_def] using (Path.diag (a:=a) 1) + | cons j l ih => + simpa only [List.map_cons,List.prod_cons,List.sum_cons] using + (h j (by simp)).mul (ih (fun k hk => h k (by simp [hk]))) + +lemma synchronized_chain {w : ι → LetterGroup} {ρ : ℝ} (hp : Path a w 1) + (hm : Path a w ρ) (hρ : ρ < 1) (v : ℕ → ℝ) (n : ℕ) + (hv0 : v 0=1) (hvn : v n=ρ) (hv : ∀ j,j div_nonneg (sub_nonneg.mpr (hv j hj)) (by linarith) + let ww (j : ℕ) : ι → LetterGroup := fun i => scaleGroup (c j) (w i) + refine ⟨((List.range n).map ww).prod,?_⟩ + intro k hk + let u (j : ℕ) := if j scaleGroup lmb⁻¹ (w i)) 1 := by + simpa [inv_mul_cancel₀ hlmb.ne'] using hp.scale lmb⁻¹ (inv_nonneg.mpr hlmb.le) + have hnorm' : Path a (fun i => scaleGroup lmb⁻¹ (w i)) ρ := by + simpa [ρ,div_eq_mul_inv,mul_comm] using hm.scale lmb⁻¹ (inv_nonneg.mpr hlmb.le) + let v (j : ℕ) : ℝ := if j g) 0 + | copy (b : ι → FiniteEuclidean) (h : ∀ i j,‖b i-b j‖=‖a i-a j‖) : + UnitWords a (fun i => FreeGroup.of (b i)) 1 + | mul {u v m n} : UnitWords a u m → UnitWords a v n → UnitWords a (u*v) (m+n) +def unitGraded (a : ι → FiniteEuclidean) : GradedPaths ι LetterGroup where + Holds := UnitWords a + diag := .diag + mul := .mul + +def CopyPath (a : ι → FiniteEuclidean) (u : ℝ) (b : ι → FiniteEuclidean) : Prop := + 0≤u ∧ ∀ i j,‖b i-b j‖^2=u*‖a i-a j‖^2 + +inductive Path (a : ι → FiniteEuclidean) : (ι → LetterGroup) → ℝ → Prop + | diag (g : LetterGroup) : Path a (fun _ => g) 0 + | copy {u : ℝ} (b : ι → FiniteEuclidean) (h : CopyPath a u b) : + Path a (fun i => FreeGroup.of (b i)) u + | mul {u v lmb μ} : Path a u lmb → Path a v μ → Path a (u*v) (lmb+μ) +lemma UnitWords.path {a : ι → FiniteEuclidean} {w n} (h : UnitWords a w n) : Path a w n := by + induction h with + | diag g => simpa only [Nat.cast_zero] using (Path.diag (a:=a) g) + | copy b hb => + simpa only [Nat.cast_one] using (Path.copy (a:=a) (u:=1) b ⟨zero_le_one,by intro i j; simp [hb i j]⟩) + | mul _ _ ihu ihv => simpa only [Nat.cast_add] using ihu.mul ihv +lemma Path.nonneg {a : ι → FiniteEuclidean} {w lmb} (h : Path a w lmb) : 0≤lmb := by + induction h with + | diag => exact le_rfl + | copy _ h => exact h.1 + | mul _ _ ih1 ih2 => exact add_nonneg ih1 ih2 + +lemma extend_pair_E (a : ι → FiniteEuclidean) (i j : ι) (z z' : FiniteEuclidean) + (h : ‖z'-z‖=‖a j-a i‖) : + ∃ b : ι → FiniteEuclidean,b i=z ∧ b j=z' ∧ ∀ k l,‖b k-b l‖=‖a k-a l‖ := by + let v := a j-a i + let w := z'-z + let R := (ℝ ∙ (v-w))ᗮ.reflection + refine ⟨fun k => z+R (a k-a i),by simp,?_,?_⟩ + · have he : R v=w := Submodule.reflection_sub h.symm + simpa [v,w] using congrArg (fun t => z+t) he + · intro k l + simp only [add_sub_add_left_eq_sub,← map_sub,sub_sub_sub_cancel_right, + LinearIsometryEquiv.norm_map] + +lemma unit_pair_inverse (a : ι → FiniteEuclidean) : PairInverse (unitGraded a).monoid := by + intro i j _ u hu + obtain ⟨m,hm⟩ := hu + change UnitWords a u m at hm + suffices ∃ v n,UnitWords a v n ∧ v i=(u i)⁻¹ ∧ v j=(u j)⁻¹ by + obtain ⟨v,n,hv,hi,hj⟩ := this + exact ⟨v,⟨n,hv⟩,by rw [hi]; exact mul_inv_cancel _,by rw [hj]; exact mul_inv_cancel _⟩ + induction hm with + | diag g => exact ⟨_,0,.diag g⁻¹,rfl,rfl⟩ + | copy b hb => + obtain ⟨c,hci,hcj,hc⟩ := extend_pair_E a i j (b j) (b i) (by + rw [hb i j,norm_sub_rev (a i) (a j)]) + let x := FreeGroup.of (b i) + let y := FreeGroup.of (b j) + refine ⟨(fun _ => x⁻¹)*(fun k => FreeGroup.of (c k))*(fun _ => y⁻¹),1,?_,?_,?_⟩ + · simpa using ((UnitWords.diag x⁻¹).mul (.copy c hc)).mul (.diag y⁻¹) + · simp [x,y,hci] + · simp [x,y,hcj] + | @mul u v m n hu hv ihu ihv => + obtain ⟨u',m',hu',hui,huj⟩ := ihu + obtain ⟨v',n',hv',hvi,hvj⟩ := ihv + exact ⟨v'*u',n'+m',hv'.mul hu',by simp [hui,hvi],by simp [huj,hvj]⟩ + +def pairHom (i j : ι) : (ι → LetterGroup) →* LetterGroup×LetterGroup where + toFun u := (u i,u j) + map_one' := rfl + map_mul' _ _ := rfl + +def pairGroup (a : ι → FiniteEuclidean) (i j : ι) (hij : i≠j) : Subgroup (LetterGroup×LetterGroup) where + toSubmonoid := (unitGraded a).monoid.map (pairHom i j) + inv_mem' := by + rintro _ ⟨u,hu,rfl⟩ + obtain ⟨v,hv,hi,hj⟩ := unit_pair_inverse a i j hij u hu + exact ⟨v,hv,Prod.ext (by + change v i=(u i)⁻¹ + apply mul_left_cancel (a:=u i) + simpa using hi) (by + change v j=(u j)⁻¹ + apply mul_left_cancel (a:=u j) + simpa using hj)⟩ +lemma pairGroup_diag (a : ι → FiniteEuclidean) (i j : ι) (hij : i≠j) (g : LetterGroup) : + (g,g)∈pairGroup a i j hij := by + classical + exact ⟨_,(unitGraded a).diagonal g,rfl⟩ + +def pairLeft (a : ι → FiniteEuclidean) (i j : ι) (hij : i≠j) : Subgroup LetterGroup := + (pairGroup a i j hij).comap (MonoidHom.inl LetterGroup LetterGroup) +instance pairLeft_normal (a : ι → FiniteEuclidean) (i j : ι) (hij : i≠j) : + (pairLeft a i j hij).Normal := by + constructor + intro g hg k + change (k*g*k⁻¹,1)∈pairGroup a i j hij + have h := (pairGroup a i j hij).mul_mem + ((pairGroup a i j hij).mul_mem (pairGroup_diag a i j hij k) hg) + (pairGroup_diag a i j hij k⁻¹) + simpa using h + +lemma pairLeft_edge (a : ι → FiniteEuclidean) (i j : ι) (hij : i≠j) + (x y : FiniteEuclidean) (hxy : ‖x-y‖=‖a i-a j‖) : + FreeGroup.of x*(FreeGroup.of y)⁻¹∈pairLeft a i j hij := by + obtain ⟨b,hbi,hbj,hb⟩ := extend_pair_E a i j x y (by + simpa only [norm_sub_rev y x,norm_sub_rev (a j) (a i)] using hxy) + have hcopy : (FreeGroup.of x,FreeGroup.of y)∈pairGroup a i j hij := by + refine ⟨(fun k => FreeGroup.of (b k)),⟨1,UnitWords.copy b hb⟩,?_⟩ + exact Prod.ext (congrArg FreeGroup.of hbi) (congrArg FreeGroup.of hbj) + have h := (pairGroup a i j hij).mul_mem hcopy (pairGroup_diag a i j hij (FreeGroup.of y)⁻¹) + simpa [pairLeft,MonoidHom.inl_apply] using h + +lemma unit_pair_coverage (a : ι → FiniteEuclidean) (ha : Function.Injective a) : + PairCoverage (unitGraded a).monoid (AugKernel FiniteEuclidean) := by + intro i j hij g hg h hh + have hr : 0<‖a i-a j‖ := norm_pos_iff.mpr (sub_ne_zero.mpr (fun he => hij (ha he))) + have hle : AugKernel FiniteEuclidean≤pairLeft a i j hij := by + apply augmentation_kernel_le 0 + intro x y + apply FiniteEuclidean.unit_distance_constant _ hr + (fun z => (QuotientGroup.mk' (pairLeft a i j hij)) (FreeGroup.of z)) + intro x y hxy + apply QuotientGroup.eq_iff_div_mem.mpr + simpa only [div_eq_mul_inv] using pairLeft_edge a i j hij x y hxy + have hleft : (g,1)∈pairGroup a i j hij := hle hg + have hright : (1,h)∈pairGroup a i j hij := by + have h := (pairGroup a i j hij).mul_mem (pairGroup_diag a i j hij h) + (hle ((AugKernel FiniteEuclidean).inv_mem hh)) + simpa using h + have hp := (pairGroup a i j hij).mul_mem hleft hright + have hp' : (g,h)∈(unitGraded a).monoid.map (pairHom i j) := by + change (g,h)∈pairGroup a i j hij + simpa using hp + obtain ⟨v,hv,hv'⟩ := hp' + exact ⟨v,hv,congrArg Prod.fst hv',congrArg Prod.snd hv'⟩ +end EuclideanRamsey +namespace EuclideanRamsey +open scoped BigOperators +abbrev Strings := FreeMonoid FiniteEuclidean + +def stringEnergy : List FiniteEuclidean → List FiniteEuclidean → ℝ + | x::l,y::k => ‖x-y‖^2+stringEnergy l k + | _,_ => 0 +@[simp] lemma stringEnergy_self (l : List FiniteEuclidean) : stringEnergy l l=0 := by + induction l with + | nil => rfl + | cons x l ih => simp [stringEnergy,ih] +lemma stringEnergy_append (l k l' k' : List FiniteEuclidean) (h : l.length=k.length) : + stringEnergy (l++l') (k++k')=stringEnergy l k+stringEnergy l' k' := by + induction l generalizing k with + | nil => have hk : k=[] := List.length_eq_zero_iff.mp h.symm; subst k; simp [stringEnergy] + | cons x l ih => + cases k with + | nil => simp at h + | cons y k => + simp only [List.length_cons,Nat.add_right_cancel_iff] at h + simp only [List.cons_append,stringEnergy,ih k h,add_assoc] + +lemma stringEnergy_eq_sum (l k : List FiniteEuclidean) (h : l.length=k.length) : + stringEnergy l k = ∑ i : Fin l.length,‖l.get i-k.get (i.cast h)‖^2 := by + induction l generalizing k with + | nil => simp [stringEnergy] + | cons x l ih => + cases k with + | nil => simp at h + | cons y k => + have h' : l.length=k.length := Nat.add_right_cancel h + change _ = ∑ i : Fin (l.length+1), ‖(x::l).get i-(y::k).get (i.cast h)‖^2 + rw [Fin.sum_univ_succ] + simpa only [stringEnergy,List.get_eq_getElem,List.getElem_cons_zero,List.getElem_cons_succ, + Fin.val_zero,Fin.val_succ,Fin.val_cast] using congrArg (fun t => ‖x-y‖^2+t) (ih k h') + +lemma flatten_energy (l k : List FiniteEuclidean) (h : l.length=k.length) : + ‖FiniteEuclidean.flatten l-FiniteEuclidean.flatten k‖^2=stringEnergy l k := by + rw [FiniteEuclidean.flatten_distance l k h,stringEnergy_eq_sum l k h] + +variable {ι : Type uIndex} +def StringFamily (a : ι → FiniteEuclidean) (u : ℝ) (x : ι → Strings) : Prop := + (∀ i j,(x i).toList.length=(x j).toList.length) ∧ + ∀ i j,stringEnergy (x i).toList (x j).toList=u*‖a i-a j‖^2 +lemma StringFamily.common (a : ι → FiniteEuclidean) (x : Strings) : + StringFamily a 0 (fun _ => x) := by constructor <;> intros <;> simp [stringEnergy_self] +lemma StringFamily.single {a : ι → FiniteEuclidean} {u : ℝ} {b : ι → FiniteEuclidean} + (h : CopyPath a u b) : StringFamily a u (fun i => FreeMonoid.of (b i)) := by + refine ⟨fun _ _ => rfl,?_⟩ + intro i j + change ‖b i-b j‖^2+0=u*‖a i-a j‖^2 + simpa only [add_zero] using h.2 i j +lemma StringFamily.mul {a : ι → FiniteEuclidean} {u v : ℝ} {x y : ι → Strings} + (hx : StringFamily a u x) (hy : StringFamily a v y) : StringFamily a (u+v) (x*y) := by + refine ⟨?_,?_⟩ + · intro i j + change ((x i).toList++(y i).toList).length=((x j).toList++(y j).toList).length + simp only [List.length_append,hx.1 i j,hy.1 i j] + · intro i j + change stringEnergy ((x i).toList++(y i).toList) ((x j).toList++(y j).toList)=_ + rw [stringEnergy_append _ _ _ _ (hx.1 i j),hx.2,hy.2,add_mul] +lemma StringFamily.congruent {a : ι → FiniteEuclidean} {x : ι → Strings} + (h : StringFamily a 1 x) : + ∀ i j,‖FiniteEuclidean.flatten (x i).toList-FiniteEuclidean.flatten (x j).toList‖=‖a i-a j‖ := by + intro i j + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + rw [flatten_energy _ _ (h.1 i j),h.2,one_mul] +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Quadratic.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Quadratic.lean new file mode 100644 index 0000000000000000000000000000000000000000..de62167121102fb9978a387c3d29678c9e9f6c0c --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Quadratic.lean @@ -0,0 +1,270 @@ +import OAI.Combinatorics.EuclideanRamsey.Main +import Mathlib.LinearAlgebra.Matrix.Adjugate +import Mathlib.LinearAlgebra.Basis.VectorSpace + +namespace OAI + +/-! Quadratic row independence gives a tensor lift and the Ramsey property. -/ + +noncomputable section +open scoped TensorProduct BigOperators RealInnerProductSpace Matrix + +namespace EuclideanRamsey.Quadratic + +theorem field_rightInverse {F ι ν : Type*} [Field F] + [Fintype ι] [Fintype ν] [DecidableEq ι] [DecidableEq ν] + (E : Matrix ι ν F) (hE : LinearIndependent F E.row) : + ∃ S : Matrix ν ι F, E * S = 1 := by + have hinj : Function.Injective E.vecMulLinear := Matrix.vecMul_injective_iff.mpr hE + obtain ⟨g, hg⟩ := E.vecMulLinear.exists_leftInverse_of_injective + (LinearMap.ker_eq_bot.mpr hinj) + let S : Matrix ν ι F := fun q j => g (Pi.single q 1) j + refine ⟨S, ?_⟩ + ext i j + have hrow : E.vecMulLinear (Pi.single i 1) = E i := by + ext q + change (∑ x : ι, (Pi.single i (1 : F) : ι → F) x * E x q) = E i q + rw [Finset.sum_eq_single i] + · simp + · intro x _ hxi + simp [hxi] + · simp + have hgi : g (E i) = Pi.single i 1 := by + have ht := LinearMap.congr_fun hg (Pi.single i 1) + simpa only [LinearMap.comp_apply, LinearMap.id_apply, hrow] using ht + have hsum : (∑ q : ν, E i q • Pi.single q (1 : F)) = E i := by + ext q + simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + rw [Finset.sum_eq_single q] + · simp + · intro x _ hxq + simp [Ne.symm hxq] + · simp + have ht := congrArg (fun x : ν → F => g x j) hsum + simp only [map_sum, map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] at ht + change (∑ q, E i q * g (Pi.single q 1) j) = _ + rw [ht, hgi] + simp [Matrix.one_apply, Pi.single_apply, eq_comm] + +theorem lift_kernel {F B ι ν : Type*} [Field F] [CommRing B] + [Fintype ι] [Fintype ν] [DecidableEq ι] [DecidableEq ν] + (μ : B →+* F) (σ : F →+* B) (hsection : ∀ x, μ (σ x) = x) + (D : Matrix ι ν B) (hrows : LinearIndependent F (D.map μ).row) + (h : ν → F) (hh : D.map μ *ᵥ h = 0) : + ∃ z : ν → B, D *ᵥ z = 0 ∧ (fun q => μ (z q)) = h := by + obtain ⟨S, hS⟩ := field_rightInverse (D.map μ) hrows + let J : Matrix ν ι B := S.map σ + let M : Matrix ι ι B := D * J + let b : ν → B := fun q => σ (h q) + have hJ : J.map μ = S := by + ext q i + exact hsection _ + have hM : M.map μ = 1 := by + calc + M.map μ = D.map μ * J.map μ := by + ext i j + simp [M, Matrix.mul_apply] + _ = 1 := by rw [hJ, hS] + have hdet : μ M.det = 1 := by + rw [μ.map_det] + change (M.map μ).det = 1 + rw [hM, Matrix.det_one] + have hb : (fun q => μ (b q)) = h := by + funext q + exact hsection _ + have hDb : (fun i => μ ((D *ᵥ b) i)) = 0 := by + ext i + rw [μ.map_mulVec] + change (D.map μ *ᵥ (fun q => μ (b q))) i = 0 + rw [hb, hh] + rfl + let z : ν → B := M.det • b - J *ᵥ (M.adjugate *ᵥ (D *ᵥ b)) + refine ⟨z, ?_, ?_⟩ + · change D *ᵥ (M.det • b - J *ᵥ (M.adjugate *ᵥ (D *ᵥ b))) = 0 + rw [Matrix.mulVec_sub, Matrix.mulVec_smul, Matrix.mulVec_mulVec] + change M.det • (D *ᵥ b) - M *ᵥ (M.adjugate *ᵥ (D *ᵥ b)) = 0 + rw [Matrix.mulVec_mulVec, Matrix.mul_adjugate, Matrix.smul_mulVec, + Matrix.one_mulVec, sub_self] + · have hAdj : (fun i => μ ((M.adjugate *ᵥ (D *ᵥ b)) i)) = 0 := by + ext i + rw [μ.map_mulVec] + change (M.adjugate.map μ *ᵥ (fun j => μ ((D *ᵥ b) j))) i = 0 + rw [hDb, Matrix.mulVec_zero] + rfl + have hCorrection : (fun q => μ ((J *ᵥ (M.adjugate *ᵥ (D *ᵥ b))) q)) = 0 := by + ext q + rw [μ.map_mulVec] + change (J.map μ *ᵥ (fun i => μ ((M.adjugate *ᵥ (D *ᵥ b)) i))) q = 0 + rw [hAdj, Matrix.mulVec_zero] + rfl + funext q + change μ (M.det * b q - (J *ᵥ (M.adjugate *ᵥ (D *ᵥ b))) q) = h q + rw [map_sub, map_mul, hdet, one_mul, congrFun hCorrection q] + change μ (b q) - (0 : F) = h q + rw [sub_zero] + exact congrFun hb q + +end EuclideanRamsey.Quadratic + +namespace EuclideanRamsey + +abbrev QuadraticIndex (d : ℕ) := Option (Fin d) × Option (Fin d) + +def augmentedQuadraticRows {s d : ℕ} (a : Fin s → Space d) : + Matrix (Fin s) (QuadraticIndex d) (Coeff a) := + fun i q => augmented a i q.1 * augmented a i q.2 + +theorem sphere_field_quadratic {s d : ℕ} (a : Fin s → Space d) + (hsphere : ∃ c : Space d, ∃ r : ℝ, ∀ i, dist (a i) c = r) : + ∃ h : QuadraticIndex d → Coeff a, + augmentedQuadraticRows a *ᵥ h = 0 ∧ + ∀ j k : Fin d, h (some j, some k) = if j = k then 1 else 0 := by + classical + obtain ⟨c, r, hr⟩ := hsphere + obtain ⟨φ, hφ⟩ := Module.Projective.exists_dual_eq_one (Coeff a) + (one_ne_zero : (1 : ℝ) ≠ 0) + have hfix (x : Coeff a) : φ (x : ℝ) = x := by + have ht := φ.map_smul x (1 : ℝ) + simpa [Algebra.smul_def, hφ] using ht + have hmul (x : Coeff a) (t : ℝ) : φ ((x : ℝ) * t) = x * φ t := by + simpa [Algebra.smul_def] using φ.map_smul x t + let C : ℝ := (∑ j, (c j)^2) - r^2 + let h : QuadraticIndex d → Coeff a := fun q => + match q.1, q.2 with + | none, none => φ C + | none, some j => φ (-2 * c j) + | some _, none => 0 + | some j, some k => if j = k then 1 else 0 + refine ⟨h, ?_, fun _ _ => rfl⟩ + funext i + have hreal : C + (∑ j, a i j * (-2 * c j)) + (∑ j, (a i j)^2) = 0 := by + have hdist : (∑ j, (a i j - c j)^2) = r^2 := by + calc + (∑ j, (a i j - c j)^2) = dist (a i) c ^ 2 := by + simpa only [Real.dist_eq, sq_abs] using + (EuclideanSpace.dist_sq_eq (a i) c).symm + _ = r^2 := congrArg (fun x : ℝ => x^2) (hr i) + have hexpand : (∑ j, (a i j - c j)^2) = + (∑ j, (a i j)^2) + (∑ j, a i j * (-2*c j)) + (∑ j, (c j)^2) := by + rw [← Finset.sum_add_distrib, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro j _ + ring + dsimp [C] + linarith + have hdesc := congrArg φ hreal + simp only [map_add, map_sum, map_zero] at hdesc + have hlinear (j : Fin d) : φ (a i j * (-2*c j)) = + coordinate a i j * φ (-2*c j) := hmul (coordinate a i j) _ + have hsquare (j : Fin d) : φ ((a i j)^2) = (coordinate a i j)^2 := by + change φ (((coordinate a i j)^2 : Coeff a) : ℝ) = (coordinate a i j)^2 + exact hfix _ + simp only [hlinear, hsquare] at hdesc + change (∑ q : QuadraticIndex d, augmentedQuadraticRows a i q * h q) = 0 + simpa [augmentedQuadraticRows, Fintype.sum_prod_type, Fintype.sum_option, + augmented, h, mul_ite, ite_mul, pow_two, mul_comm, mul_left_comm, + mul_assoc] using hdesc + +theorem quadraticIndependent_fieldCriterion {s d : ℕ} (a : Fin s → Space d) + (hrows : LinearIndependent (Coeff a) (augmentedQuadraticRows a).row) + (h : QuadraticIndex d → Coeff a) + (hzero : augmentedQuadraticRows a *ᵥ h = 0) + (hspatial : ∀ j k : Fin d, h (some j, some k) = if j = k then 1 else 0) : + FieldCriterion a := by + classical + let D : Matrix (Fin s) (QuadraticIndex d) (TensorRing a) := + fun i q => augmented a i q.1 ⊗ₜ[ℚ] augmented a i q.2 + let μ : TensorRing a →+* Coeff a := (multiply a).toRingHom + let σ : Coeff a →+* TensorRing a := Algebra.TensorProduct.includeLeftRingHom + have hsection (x : Coeff a) : μ (σ x) = x := by + simp [μ, σ, multiply, Algebra.TensorProduct.includeLeftRingHom] + have hD : D.map μ = augmentedQuadraticRows a := by + funext i q + change Algebra.TensorProduct.lmul' ℚ + (augmented a i q.1 ⊗ₜ[ℚ] augmented a i q.2) = + augmented a i q.1 * augmented a i q.2 + exact Algebra.TensorProduct.lmul'_apply_tmul _ _ + obtain ⟨z, hz, hm⟩ := Quadratic.lift_kernel μ σ hsection D + (by simpa only [hD] using hrows) h (by simpa only [hD] using hzero) + refine ⟨fun α β => z (α, β), ?_, ?_⟩ + · intro i + have ht := congrFun hz i + change (∑ q, D i q * z q) = 0 at ht + have hsand (x y : Coeff a) (T : TensorRing a) : + (x ⊗ₜ[ℚ] (1 : Coeff a)) * T * ((1 : Coeff a) ⊗ₜ[ℚ] y) = + (x ⊗ₜ[ℚ] y) * T := by + have hpair : + ((x ⊗ₜ[ℚ] (1 : Coeff a)) : TensorRing a) * + ((1 : Coeff a) ⊗ₜ[ℚ] y) = x ⊗ₜ[ℚ] y := + (Algebra.TensorProduct.tmul_mul_tmul x (1 : Coeff a) (1 : Coeff a) y).trans + (congrArg₂ (fun u v : Coeff a => u ⊗ₜ[ℚ] v) (mul_one x) (one_mul y)) + exact (mul_right_comm ((x ⊗ₜ[ℚ] (1 : Coeff a)) : TensorRing a) T + (((1 : Coeff a) ⊗ₜ[ℚ] y) : TensorRing a)).trans + (congrArg (fun U : TensorRing a => U * T) hpair) + simp only [hsand] + simpa only [D, Fintype.sum_prod_type] using ht + · intro j k + exact (congrFun hm (some j, some k)).trans (hspatial j k) + +theorem spherical_quadraticIndependent_ramsey_of_dimension {s d : ℕ} + (a : Fin s → Space d) (hs : 2 ≤ s) (hd : 1 ≤ d) + (ha : Function.Injective a) + (hsphere : ∃ c : Space d, ∃ r : ℝ, ∀ i, dist (a i) c = r) + (hrows : LinearIndependent (Coeff a) + (fun i : Fin s => fun q : Option (Fin d) × Option (Fin d) => + augmented a i q.1 * augmented a i q.2)) : Ramsey a := by + obtain ⟨h, hzero, hspatial⟩ := sphere_field_quadratic a hsphere + exact fieldCriterion_ramsey a hs hd ha + (quadraticIndependent_fieldCriterion a hrows h hzero hspatial) + +theorem spherical_quadraticIndependent_ramsey {s d : ℕ} (a : Fin s → Space d) + (hs : 0 < s) (ha : Function.Injective a) + (hspan : affineSpan ℝ (Set.range a) = ⊤) + (hsphere : ∃ c : Space d, ∃ r : ℝ, ∀ i, dist (a i) c = r) + (hrows : LinearIndependent (Coeff a) + (fun i : Fin s => fun q : Option (Fin d) × Option (Fin d) => + augmented a i q.1 * augmented a i q.2)) : Ramsey a := by + classical + by_cases hs1 : s = 1 + · subst s + exact singleton_ramsey a + have hs2 : 2 ≤ s := by omega + have hd : 1 ≤ d := by + by_contra hd + have hd0 : d = 0 := by omega + subst d + have he : a ⟨0, by omega⟩ = a ⟨1, by omega⟩ := Subsingleton.elim _ _ + have hi := congrArg Fin.val (ha he) + norm_num at hi + obtain ⟨h, hzero, hspatial⟩ := sphere_field_quadratic a hsphere + apply (classification a hs2 hd ha hspan).mpr + exact quadraticIndependent_fieldCriterion a hrows h hzero hspatial + +theorem quadratic_empty_ramsey {d : ℕ} (a : Fin 0 → Space d) : Ramsey a := by + intro r hr + refine ⟨1, by omega, ?_⟩ + intro c + refine ⟨fun i => Fin.elim0 i, ?_, ⟨0, by omega⟩, ?_⟩ + · intro i + exact Fin.elim0 i + · intro i + exact Fin.elim0 i + +theorem spherical_quadraticIndependent_ramsey_all {s d : ℕ} + (a : Fin s → Space d) (ha : Function.Injective a) + (hspan : affineSpan ℝ (Set.range a) = ⊤) + (hsphere : ∃ c : Space d, ∃ r : ℝ, ∀ i, dist (a i) c = r) + (hrows : LinearIndependent (Coeff a) + (fun i : Fin s => fun q : Option (Fin d) × Option (Fin d) => + augmented a i q.1 * augmented a i q.2)) : Ramsey a := by + by_cases hs : 0 < s + · exact spherical_quadraticIndependent_ramsey a hs ha hspan hsphere hrows + · have hs0 : s = 0 := by omega + subst s + exact quadratic_empty_ramsey a + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/RationalConvolution.lean b/lean/OAI/Combinatorics/EuclideanRamsey/RationalConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..b59905664b1e32e63acceb82d432f6ee2e984dda --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/RationalConvolution.lean @@ -0,0 +1,226 @@ +import OAI.Combinatorics.EuclideanRamsey.Discretization + +namespace OAI + +universe uGroup uIndex + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter + +namespace EuclideanRamsey +open MeasureTheory Filter +open scoped BigOperators Pointwise Topology + +lemma bounded_grid_finite {k n : ℕ} (hn : n ≠ 0) {s : Set (Fin k → ℝ)} + (hs : Bornology.IsBounded s) : + (s ∩ (n:ℝ)⁻¹ • (realLattice k : Set (Fin k → ℝ))).Finite := by + rw [← Submodule.coe_pointwise_smul, ZSpan.smul _ (inv_ne_zero (by exact_mod_cast hn))] + exact ZSpan.setFinite_inter _ hs + +lemma lattice_sum_perturb_bound {k n : ℕ} (hn : n ≠ 0) {s : Set (Fin k → ℝ)} + (hs : Bornology.IsBounded s) (f g : (Fin k → ℝ) → ℝ) + (hf : Function.support f ⊆ s) (hg : Function.support g ⊆ s) + (ε : ℝ) (hb : ∀ x, |f x-g x| ≤ ε) : + |((∑' γ : Fin k → ℤ, f (latticeSample n γ))/(n:ℝ)^k)- + ((∑' γ : Fin k → ℤ, g (latticeSample n γ))/(n:ℝ)^k)| ≤ + ε * ((Nat.card ↑(s ∩ (n:ℝ)⁻¹ • (realLattice k : Set (Fin k → ℝ))) : ℝ)/(n:ℝ)^k) := by + let G := ↑(s ∩ (n:ℝ)⁻¹ • (realLattice k : Set (Fin k → ℝ))) + let : Fintype G := (bounded_grid_finite hn hs).fintype + rw [lattice_tsum_eq_grid hn s f hf,lattice_tsum_eq_grid hn s g hg, + ← sub_div,abs_div,abs_of_nonneg (by positivity : 0 ≤ (n:ℝ)^k)] + have hsum : |(∑' x : G,f x)-(∑' x : G,g x)| ≤ (Nat.card G : ℝ)*ε := by + rw [tsum_fintype,tsum_fintype,← Finset.sum_sub_distrib] + calc + _ ≤ ∑ x : G, |f x-g x| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _x : G, ε := Finset.sum_le_sum (fun x hx => hb x) + _ = _ := by simp [Nat.card_eq_fintype_card] + calc + _ ≤ ((Nat.card G : ℝ)*ε)/(n:ℝ)^k := div_le_div_of_nonneg_right hsum (by positivity) + _ = _ := by ring + +theorem lattice_riemann_perturb {k : ℕ} (f : (Fin k → ℝ) → ℝ) + (g : ℕ → (Fin k → ℝ) → ℝ) (hf : Continuous f) (hfc : HasCompactSupport f) + {R : ℝ} (hR : 0 < R) + (hfs : Function.support f ⊆ Metric.closedBall 0 R) + (hgs : ∀ n, Function.support (g n) ⊆ Metric.closedBall 0 R) + (ε : ℕ → ℝ) (hε : Tendsto ε atTop (𝓝 0)) + (hbound : ∀ n, 1 ≤ n → ∀ x, |g n x-f x| ≤ ε n) : + Tendsto (fun n : ℕ => (∑' γ : Fin k → ℤ, g n (latticeSample n γ))/(n:ℝ)^k) + atTop (𝓝 (∫ x, f x)) := by + let s := Metric.closedBall (0 : Fin k → ℝ) R + have hfront : volume (frontier s) = 0 := + measure_mono_null Metric.frontier_closedBall_subset_sphere + (volume.addHaar_sphere_of_ne_zero 0 hR.ne') + have hc := tendsto_card_div_pow_atTop_volume s Metric.isBounded_closedBall + measurableSet_closedBall hfront + have hlim := hε.mul hc + rw [zero_mul] at hlim + have hdiff : Tendsto (fun n : ℕ => + (∑' γ : Fin k → ℤ, g n (latticeSample n γ))/(n:ℝ)^k- + (∑' γ : Fin k → ℤ, f (latticeSample n γ))/(n:ℝ)^k) atTop (𝓝 0) := by + apply squeeze_zero_norm' _ hlim + filter_upwards [eventually_ge_atTop 1] with n hn + simpa only [Real.norm_eq_abs,Fintype.card_fin] using + lattice_sum_perturb_bound (by omega : n ≠ 0) Metric.isBounded_closedBall + (g n) f (hgs n) hfs (ε n) (hbound n hn) + convert hdiff.add (lattice_riemann hf hfc) using 1 + · ext n; ring + · simp + +end EuclideanRamsey + +open scoped BigOperators Pointwise +namespace EuclideanRamsey + +lemma convolution_support {G : Type uGroup} [AddCommGroup G] (S : Finset G) (q : G → ℝ) + {d : G → ℝ} (hd : Function.HasFiniteSupport d) : + Function.HasFiniteSupport (fun δ => ∑ γ ∈ S,q γ*d (δ-γ)) := by + classical + apply (S.finite_toSet.add hd).subset + intro δ hδ + obtain ⟨γ,hγ,hn⟩ := Finset.exists_ne_zero_of_sum_ne_zero hδ + have hd' : δ-γ ∈ Function.support d := by + intro hz + exact hn (by rw [hz,mul_zero]) + exact ⟨γ,hγ,δ-γ,hd',(add_comm _ _).trans (sub_add_cancel _ _)⟩ + +lemma rational_convolution_coeff {G : Type uGroup} [AddCommGroup G] [DecidableEq G] + (ν d : AddMonoidAlgebra ℚ G) (δ : G) : + (ν*d).coeff δ = ∑ γ ∈ ν.coeff.support,ν.coeff γ*d.coeff (δ-γ) := by + rw [AddMonoidAlgebra.coeff_mul] + apply Finset.sum_congr rfl + intro γ hγ + change (∑ β ∈ d.coeff.support,if γ+β=δ then ν.coeff γ*d.coeff β else 0) = _ + have he (β : G) : γ+β=δ ↔ β=δ-γ := by + constructor + · intro h; apply eq_sub_iff_add_eq.mpr; simpa [add_comm] using h + · intro h; rw [h]; abel + simp only [he,Finset.sum_ite_eq'] + split_ifs with h + · rfl + · simp [Finsupp.notMem_support_iff.mp h] + +end EuclideanRamsey + +open scoped BigOperators Topology +namespace EuclideanRamsey + +lemma rational_vector_strict {ι : Type uIndex} [Fintype ι] + (ζ N : (ι → ℝ) → ℝ) (hζ : Continuous ζ) (hN : Continuous N) + (η : ℝ) (d : ι → ℝ) (hp : 0 < ζ d) (hn : N d < η*ζ d) : + ∃ q : ι → ℚ, 0 < ζ (fun i => q i) ∧ N (fun i => q i) < η*ζ (fun i => q i) := by + have hDense : DenseRange (fun q : ι → ℚ => fun i => (q i : ℝ)) := by + exact DenseRange.piMap (fun _ => Rat.denseRange_cast) + have hopen : IsOpen {d : ι → ℝ | 0 < ζ d ∧ N d < η*ζ d} := + (isOpen_lt continuous_const hζ).inter (isOpen_lt hN (continuous_const.mul hζ)) + exact hDense.exists_mem_open hopen ⟨d,hp,hn⟩ +end EuclideanRamsey + +namespace EuclideanRamsey +open scoped BigOperators Pointwise + +lemma rationalize_convolution {G : Type uGroup} [AddCommGroup G] [DecidableEq G] + (ν : AddMonoidAlgebra ℚ G) (w : G → ℝ) (t η : ℝ) + {a : G → ℝ} (ha : Function.HasFiniteSupport a) + (hp : 0 < (∑' γ,a γ)/t) + (hn : (∑' δ,max (-(∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ)*a (δ-γ))) 0*w δ) < + η*((∑' γ,a γ)/t)) : + ∃ b : AddMonoidAlgebra ℚ G, + 0 < ((b.coeff.sum fun _ q => q : ℚ):ℝ)/t ∧ + (∑' δ,max (-((ν*b).coeff δ:ℝ)) 0*w δ) < + η*(((b.coeff.sum fun _ q => q : ℚ):ℝ)/t) := by + classical + let E := ha.toFinset + let : Fintype E := inferInstance + let K := ν.coeff.support+E + let ext (d : E → ℝ) (γ : G) := if h : γ ∈ E then d ⟨γ,h⟩ else 0 + let ζ (d : E → ℝ) := (∑ γ : E,d γ)/t + let N (d : E → ℝ) := ∑ δ ∈ K,max (-(∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ)*ext d (δ-γ))) 0*w δ + have hζ : Continuous ζ := by unfold ζ; fun_prop + have hExt (γ : G) : Continuous (fun d : E → ℝ => ext d γ) := by + dsimp [ext] + split_ifs <;> fun_prop + have hN : Continuous N := by unfold N; fun_prop + have hsum (d : E → ℝ) : ∑' γ,ext d γ = ∑ γ : E,d γ := by + rw [tsum_eq_sum (s := E)] + · rw [← Finset.sum_coe_sort] + apply Finset.sum_congr rfl + intro γ hγ + simp only [ext,dite_eq_left γ.property] + · intro γ hγ + simp [ext,hγ] + have hNeg (d : E → ℝ) : (∑' δ,max (-(∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ)*ext d (δ-γ))) 0*w δ) = N d := by + apply tsum_eq_sum + intro δ hδ + have hz : ∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ)*ext d (δ-γ) = 0 := by + apply Finset.sum_eq_zero + intro γ hγ + have hE : δ-γ ∉ E := by + intro h + exact hδ (Finset.mem_add.mpr ⟨γ,hγ,δ-γ,h,by abel⟩) + simp [ext,hE] + simp [hz] + let aE : E → ℝ := fun γ => a γ + have haE : ext aE = a := by + funext γ + dsimp [ext,aE] + split_ifs with h + · rfl + · have hγ : γ ∉ Function.support a := by + intro hh + exact h (ha.mem_toFinset.mpr hh) + exact (not_not.mp hγ).symm + have hpE : 0 < ζ aE := by + change 0 < (∑ γ : E,aE γ)/t + rw [← hsum aE,haE] + exact hp + have hnE : N aE < η*ζ aE := by + rw [← hNeg,haE] + change _ < η*((∑ γ : E,aE γ)/t) + rw [← hsum aE,haE] + exact hn + obtain ⟨q,hq0,hqN⟩ := rational_vector_strict ζ N hζ hN η aE hpE hnE + let b : AddMonoidAlgebra ℚ G := ∑ γ : E,AddMonoidAlgebra.single γ.val (q γ) + have hb (γ : G) : (b.coeff γ : ℝ) = ext (fun i => (q i:ℝ)) γ := by + simp only [b,AddMonoidAlgebra.coeff_sum,Finsupp.finsetSum_apply,Rat.cast_sum] + by_cases h : γ ∈ E + · rw [Finset.sum_eq_single ⟨γ,h⟩] + · simp [ext,h] + · intro β hβ hne + have hne' : β.val ≠ γ := fun he => hne (Subtype.ext he) + simp [hne'] + · simp + · have hz (β : E) : β.val ≠ γ := fun hb => h (hb ▸ β.property) + simp [ext,h,hz] + have hbMass : ((b.coeff.sum fun _ q => q : ℚ):ℝ) = ∑ γ : E,(q γ:ℝ) := by + have ht : ∑' γ,(b.coeff γ:ℝ) = ((b.coeff.sum fun _ q => q : ℚ):ℝ) := by + rw [tsum_eq_sum (s := b.coeff.support)] + · simp [Finsupp.sum] + · intro γ hγ; simp [Finsupp.notMem_support_iff.mp hγ] + rw [← ht] + simp only [hb] + exact hsum (fun i => (q i:ℝ)) + refine ⟨b,?_,?_⟩ + · simpa only [hbMass,ζ] using hq0 + · have hc (δ : G) : ((ν*b).coeff δ:ℝ) = ∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ)*ext (fun i => (q i:ℝ)) (δ-γ) := by + rw [rational_convolution_coeff] + simp only [Rat.cast_sum,Rat.cast_mul,hb] + simp only [hc,hNeg,hbMass] + exact hqN + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/SignedRows.lean b/lean/OAI/Combinatorics/EuclideanRamsey/SignedRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..92a9595784e46a514efbae54d306d6d4ed755112 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/SignedRows.lean @@ -0,0 +1,235 @@ +import OAI.Combinatorics.EuclideanRamsey.TensorPresentation + +namespace OAI + +universe uAlpha uBeta + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators + +open scoped BigOperators +namespace EuclideanRamsey + +lemma integerize_finsupp {α : Type uAlpha} (f : α →₀ ℚ) : + ∃ (M : ℕ) (z : α →₀ ℤ), 0 < M ∧ ∀ a, (z a:ℚ) = M*f a := by + classical + let A : Matrix Unit ↥f.support ℚ := fun _ a => f a + let z := f.mapRange (fun q => Int.floor ((A.den:ℚ)*q)) (by simp) + refine ⟨A.den,z,Nat.pos_of_ne_zero A.den_ne_zero,?_⟩ + intro a + by_cases ha : a∈f.support + · have he := A.num_div_den () ⟨a,ha⟩ + have hd : (A.den:ℚ) ≠ 0 := by exact_mod_cast A.den_ne_zero + have hn : (A.num () ⟨a,ha⟩:ℚ) = (A.den:ℚ)*f a := by + exact ((div_eq_iff hd).mp he).trans (mul_comm _ _) + simp only [z,Finsupp.mapRange_apply,← hn,Int.floor_intCast] + · simp [z,Finsupp.notMem_support_iff.mp ha] + +lemma integerize_finsupp_real {α : Type uAlpha} (f : α →₀ ℚ) : + ∃ (M : ℕ) (z : α →₀ ℤ), 0 < M ∧ ∀ a, (z a:ℝ) = M*(f a:ℝ) := by + obtain ⟨M,z,hM,hz⟩ := integerize_finsupp f + exact ⟨M,z,hM,fun a => by exact_mod_cast hz a⟩ + +def positiveCount {α : Type uAlpha} (z : α →₀ ℤ) : α →₀ ℕ := z.mapRange Int.toNat (by simp) +def negativeCount {α : Type uAlpha} (z : α →₀ ℤ) : α →₀ ℕ := z.mapRange (fun n => (-n).toNat) (by simp) + +lemma positiveCount_cast {α : Type uAlpha} (z : α →₀ ℤ) (a : α) : + (positiveCount z a : ℝ) = max (z a:ℝ) 0 := by + change ((z a).toNat:ℝ) = _ + exact_mod_cast Int.toNat_eq_max (z a) +lemma negativeCount_cast {α : Type uAlpha} (z : α →₀ ℤ) (a : α) : + (negativeCount z a : ℝ) = max (-(z a:ℝ)) 0 := by + change ((-(z a)).toNat:ℝ) = _ + exact_mod_cast Int.toNat_eq_max (-(z a)) + +lemma count_difference {α : Type uAlpha} (z : α →₀ ℤ) (a : α) : + (positiveCount z a : ℝ)-(negativeCount z a:ℝ) = z a := by + rw [positiveCount_cast,negativeCount_cast] + by_cases h : 0 ≤ (z a:ℝ) + · rw [max_eq_left h,max_eq_right (neg_nonpos.mpr h),sub_zero] + · have h := le_of_not_ge h + rw [max_eq_right h,max_eq_left (neg_nonneg.mpr h)] + ring + +lemma sum_multiset_elements {α : Type uAlpha} {β : Type uBeta} [DecidableEq α] [AddCommMonoid β] + (m : Multiset α) (f : α → β) : (∑ x : m, f x) = (m.map f).sum := by + change ((Finset.univ : Finset m).val.map (fun x : m => f x)).sum = _ + rw [Multiset.map_univ] + +lemma sum_count_elements {α : Type uAlpha} [DecidableEq α] (c : α →₀ ℕ) (f : α → ℝ) : + (∑ x : c.toMultiset, f x) = c.sum (fun a n => (n:ℝ)*f a) := by + rw [sum_multiset_elements,Finsupp.toMultiset_map,Finsupp.sum_toMultiset, + Finsupp.sum_mapDomain_index] + · simp only [nsmul_eq_mul] + · intro a; simp + · intro a n m; simp [add_smul] + +lemma multiset_map_equiv {α : Type uAlpha} {β : Type uBeta} [DecidableEq α] [DecidableEq β] + (m n : Multiset α) (f : α → β) (h : m.map f = n.map f) : + ∃ e : m ≃ n, ∀ x : m, f (e x) = f x := by + let e := (m.mapEquiv f).trans ((Multiset.cast h).trans (n.mapEquiv f).symm) + refine ⟨e,?_⟩ + intro x + have ht := (n.mapEquiv f).apply_symm_apply ((Multiset.cast h) (m.mapEquiv f x)) + have hh := congrArg (fun y : n.map f => (y : β)) ht + simp only [Multiset.mapEquiv_apply] at hh + change f (e x) = (m.mapEquiv f x : β) at hh + exact hh.trans (Multiset.mapEquiv_apply m f x) + +lemma count_difference_finsupp {α : Type uAlpha} (f : α →₀ ℚ) (M : ℕ) (z : α →₀ ℤ) + (hz : ∀ a,(z a:ℝ) = M*(f a:ℝ)) : + (positiveCount z).mapRange (Nat.cast : ℕ → ℝ) (by simp) - + (negativeCount z).mapRange (Nat.cast : ℕ → ℝ) (by simp) = + (M:ℝ) • f.mapRange (Rat.cast : ℚ → ℝ) (by simp) := by + ext a + simp only [Finsupp.sub_apply,Finsupp.mapRange_apply,Finsupp.smul_apply,smul_eq_mul] + exact (count_difference z a).trans (hz a) + +lemma equal_count_pushforward {α : Type uAlpha} {β : Type uBeta} (f : α →₀ ℚ) (M : ℕ) (z : α →₀ ℤ) + (hz : ∀ a,(z a:ℝ) = M*(f a:ℝ)) (g : α → β) (hg : f.mapDomain g = 0) : + (positiveCount z).mapDomain g = (negativeCount z).mapDomain g := by + apply Finsupp.mapRange_injective (Nat.cast : ℕ → ℝ) (by simp) Nat.cast_injective + apply sub_eq_zero.mp + rw [← Finsupp.mapDomain_mapRange g _ _ _ (fun x y => Nat.cast_add x y), + ← Finsupp.mapDomain_mapRange g _ _ _ (fun x y => Nat.cast_add x y), + ← Finsupp.mapDomain_sub,count_difference_finsupp f M z hz, + Finsupp.mapDomain_smul,Finsupp.mapDomain_mapRange g _ _ _ (fun x y => Rat.cast_add x y),hg] + simp + +lemma equal_evaluated_multisets {α : Type uAlpha} {β : Type uBeta} (f : α →₀ ℚ) (M : ℕ) (z : α →₀ ℤ) + (hz : ∀ a,(z a:ℝ) = M*(f a:ℝ)) (g : α → β) (hg : f.mapDomain g = 0) : + (positiveCount z).toMultiset.map g = (negativeCount z).toMultiset.map g := by + simp only [Finsupp.toMultiset_map,equal_count_pushforward f M z hz g hg] + +lemma sum_counts_difference {α : Type uAlpha} [DecidableEq α] + (f : α →₀ ℚ) (M : ℕ) (z : α →₀ ℤ) + (hz : ∀ a,(z a:ℝ) = M*(f a:ℝ)) (g : α → ℝ) : + (∑ x : (positiveCount z).toMultiset,g x) - + (∑ x : (negativeCount z).toMultiset,g x) = + M*f.sum (fun a q => (q:ℝ)*g a) := by + rw [sum_count_elements,sum_count_elements] + have hs := congrArg (fun c : α →₀ ℝ => c.sum (fun a q => q*g a)) + (count_difference_finsupp f M z hz) + rw [Finsupp.sum_sub_index (fun a b c => sub_mul b c (g a)), + Finsupp.sum_mapRange_index (by intro a; simp), + Finsupp.sum_mapRange_index (by intro a; simp), + Finsupp.sum_smul_index (by intro a; simp), + Finsupp.sum_mapRange_index (by intro a; simp)] at hs + rw [hs] + simp only [Finsupp.sum,Finset.mul_sum,mul_assoc] + +lemma sum_counts_negative {α : Type uAlpha} [DecidableEq α] + (f : α →₀ ℚ) (M : ℕ) (z : α →₀ ℤ) + (hz : ∀ a,(z a:ℝ) = M*(f a:ℝ)) (g : α → ℝ) : + (∑ x : (negativeCount z).toMultiset,g x) = + M*f.sum (fun a q => max (-(q:ℝ)) 0*g a) := by + have he : (negativeCount z).mapRange (Nat.cast : ℕ → ℝ) (by simp) = + (M:ℝ) • f.mapRange (fun q : ℚ => max (-(q:ℝ)) 0) (by simp) := by + ext a + simp only [Finsupp.mapRange_apply,Finsupp.smul_apply,smul_eq_mul, + negativeCount_cast,hz,← mul_neg, mul_max_of_nonneg _ _ (Nat.cast_nonneg M),mul_zero] + rw [sum_count_elements] + have hs := congrArg (fun c : α →₀ ℝ => c.sum (fun a q => q*g a)) he + rw [Finsupp.sum_mapRange_index (by intro a; simp), + Finsupp.sum_smul_index (by intro a; simp), + Finsupp.sum_mapRange_index (by intro a; simp)] at hs + rw [hs] + simp only [Finsupp.sum,Finset.mul_sum,mul_assoc] + +end EuclideanRamsey + +namespace EuclideanRamsey +open Matrix + +theorem normalized_signed_rows {α : Type} [DecidableEq α] {d s : ℕ} (hs : 0 < s) + (a : Fin s → Fin d → ℝ) (v : α → ℝ) (g : α → Fin d → ℝ) + (f : α →₀ ℚ) (ζ η : ℝ) (hζ : 0 < ζ) + (heval : ∀ i,f.mapDomain (fun x => v x+∑ j,a i j*g x j)=0) + (hmom : ∀ j l,f.sum (fun x q => (q:ℝ)*g x j*g x l)=ζ*(if j=l then 1 else 0)) + (hneg : f.sum (fun x q => max (-(q:ℝ)) 0*(∑ j,(g x j)^2)) < η*ζ) : + ∃ (τ : Type) (_ : Fintype τ) (vp vn : τ → ℝ) (U V : Matrix (Fin d) τ ℝ), + U*U.transpose-V*V.transpose=1 ∧ (V*V.transpose).trace < η ∧ + ∀ i,∃ σ : Equiv.Perm τ,∀ x, + vn (σ x)+∑ j,a i j*V j (σ x) = vp x+∑ j,a i j*U j x := by + classical + obtain ⟨M,z,hM,hz⟩ := integerize_finsupp_real f + let m := (positiveCount z).toMultiset + let n := (negativeCount z).toMultiset + have hh (i : Fin s) : ∃ e : m ≃ n,∀ x : m, + v (e x)+∑ j,a i j*g (e x) j = v x+∑ j,a i j*g x j := + multiset_map_equiv m n _ (equal_evaluated_multisets f M z hz _ (heval i)) + choose e he using hh + let e₀ := e ⟨0,hs⟩ + let c := (Real.sqrt ((M:ℝ)*ζ))⁻¹ + have hMp : (0:ℝ) c*g x j + let V : Matrix (Fin d) m ℝ := fun j x => c*g (e₀ x) j + have hu (j l : Fin d) : (U*U.transpose) j l = c^2*∑ x : m,g x j*g x l := by + change (∑ x : m,(c*g x j)*(c*g x l)) = _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + ring + have hv (j l : Fin d) : (V*V.transpose) j l = c^2*∑ x : n,g x j*g x l := by + change (∑ x : m,(c*g (e₀ x) j)*(c*g (e₀ x) l)) = _ + rw [← e₀.sum_comp (fun x : n => g x j*g x l),Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + ring + refine ⟨m,inferInstance,(fun x => c*v x),(fun x => c*v (e₀ x)),U,V,?_,?_,?_⟩ + · ext j l + simp only [Matrix.sub_apply,hu,hv,← mul_sub] + have hm' := sum_counts_difference f M z hz (fun x => g x j*g x l) + change (∑ x : m,g x j*g x l)-(∑ x : n,g x j*g x l) = _ at hm' + rw [hm'] + have hm := hmom j l + simp only [mul_assoc] at hm + rw [hm] + calc c^2*((M:ℝ)*(ζ*(if j=l then 1 else 0))) = + (c^2*((M:ℝ)*ζ))*(if j=l then 1 else 0) := by ring + _ = _ := by simp [hsq,Matrix.one_apply] + · have ht : (V*V.transpose).trace = c^2*(M:ℝ)* + f.sum (fun x q => max (-(q:ℝ)) 0*(∑ j,(g x j)^2)) := by + change (∑ j,(V*V.transpose) j j) = _ + simp only [hv,← Finset.mul_sum] + rw [Finset.sum_comm] + simp only [← pow_two] + have hn' := sum_counts_negative f M z hz (fun x => ∑ j,(g x j)^2) + change (∑ x : n,∑ j,(g x j)^2) = _ at hn' + rw [hn'] + ring + rw [ht] + have hc' : 0 < c^2*(M:ℝ) := by + have hc0 : c ≠ 0 := by dsimp [c]; positivity + exact mul_pos (sq_pos_of_ne_zero hc0) hMp + calc c^2*(M:ℝ)*_ < c^2*(M:ℝ)*(η*ζ) := mul_lt_mul_of_pos_left hneg hc' + _ = (c^2*((M:ℝ)*ζ))*η := by ring + _ = η := by rw [hsq,one_mul] + · intro i + refine ⟨(e i).trans e₀.symm,?_⟩ + intro x + have he' := congrArg (fun r : ℝ => c*r) (he i x) + simpa [U,V,Equiv.trans_apply,e₀,Finset.mul_sum,mul_add,mul_assoc,mul_comm,mul_left_comm] using he' +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/SmoothingKernel.lean b/lean/OAI/Combinatorics/EuclideanRamsey/SmoothingKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..81bbc14c4f597fc3d9240d6f12db194a4378a345 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/SmoothingKernel.lean @@ -0,0 +1,485 @@ +import OAI.Combinatorics.EuclideanRamsey.TensorDescent + +namespace OAI + +universe uDomain + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace + +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +namespace EuclideanRamsey + +def smoothPositivePart (t : ℝ) : ℝ := t * expNegInvGlue t + +def smoothPositivePart' (t : ℝ) : ℝ := (1 + t⁻¹) * expNegInvGlue t + +def smoothPositivePart'' (t : ℝ) : ℝ := t⁻¹ ^ 3 * expNegInvGlue t + +lemma smoothPositivePart_contDiff : ContDiff ℝ (⊤ : ℕ∞) smoothPositivePart := + contDiff_id.mul expNegInvGlue.contDiff + +lemma smoothPositivePart_hasDerivAt (t : ℝ) : + HasDerivAt smoothPositivePart (smoothPositivePart' t) t := by + have hg : HasDerivAt expNegInvGlue (t⁻¹ ^ 2 * expNegInvGlue t) t := by + simpa using expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul (1 : ℝ[X]) t + have h := (hasDerivAt_id t).mul hg + change HasDerivAt smoothPositivePart _ t at h + convert h using 1 + unfold smoothPositivePart' + by_cases ht : t = 0 + · simp [ht] + · simp only [id_eq] + field_simp + +lemma smoothPositivePart'_hasDerivAt (t : ℝ) : + HasDerivAt smoothPositivePart' (smoothPositivePart'' t) t := by + have h := expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul (1 + X : ℝ[X]) t + simp only [Polynomial.eval_add, Polynomial.eval_one, Polynomial.eval_X] at h + change HasDerivAt smoothPositivePart' _ t at h + apply h.congr_deriv + simp [smoothPositivePart''] + left + ring + +lemma smoothPositivePart_nonneg (t : ℝ) : 0 ≤ smoothPositivePart t := by + by_cases ht : t ≤ 0 + · simp [smoothPositivePart, expNegInvGlue.zero_of_nonpos ht] + · exact mul_nonneg (le_of_not_ge ht) (expNegInvGlue.nonneg t) + +lemma smoothPositivePart_pos {t : ℝ} (ht : 0 < t) : 0 < smoothPositivePart t := + mul_pos ht (expNegInvGlue.pos_of_pos ht) + +lemma smoothPositivePart_zero {t : ℝ} (ht : t ≤ 0) : smoothPositivePart t = 0 := by + simp [smoothPositivePart, expNegInvGlue.zero_of_nonpos ht] + +lemma smoothPositivePart'_bounds (t : ℝ) : + 0 ≤ smoothPositivePart' t ∧ smoothPositivePart' t ≤ 1 := by + by_cases ht : t ≤ 0 + · simp [smoothPositivePart', expNegInvGlue.zero_of_nonpos ht] + have ht0 : 0 < t := lt_of_not_ge ht + constructor + · exact mul_nonneg (by positivity) (expNegInvGlue.nonneg _) + · unfold smoothPositivePart' + rw [expNegInvGlue, ite_eq_right ht, show -t⁻¹ = -1 / t by ring, + show -1 / t = -(t⁻¹) by ring, Real.exp_neg] + rw [← div_eq_mul_inv, div_le_one (Real.exp_pos _)] + simpa [add_comm] using Real.add_one_le_exp (t⁻¹) + +lemma smoothPositivePart''_nonneg (t : ℝ) : 0 ≤ smoothPositivePart'' t := by + by_cases ht : t ≤ 0 + · simp [smoothPositivePart'', expNegInvGlue.zero_of_nonpos ht] + · have ht0 : 0 < t := lt_of_not_ge ht + exact mul_nonneg (by positivity) (expNegInvGlue.nonneg _) + +section Radial +variable {E : Type uDomain} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + +def radialPower (a p : ℝ) (x : E) : ℝ := (a + ‖x‖^2) ^ p + +lemma radialPower_contDiff {a : ℝ} (ha : 0 < a) (p : ℝ) : + ContDiff ℝ (⊤ : ℕ∞) (radialPower (E := E) a p) := by + exact (contDiff_const.add (contDiff_norm_sq ℝ)).rpow_const_of_ne + (fun x => ne_of_gt (add_pos_of_pos_of_nonneg ha (sq_nonneg _))) + +lemma radialPower_hasFDerivAt {a : ℝ} (ha : 0 < a) (p : ℝ) (x : E) : + HasFDerivAt (radialPower a p) + ((2*p*(a+‖x‖^2)^(p-1)) • innerSL ℝ x) x := by + have h := ((hasStrictFDerivAt_norm_sq x).hasFDerivAt.const_add a).rpow_const + (p := p) (Or.inl (ne_of_gt (add_pos_of_pos_of_nonneg ha (sq_nonneg _)))) + change HasFDerivAt (radialPower a p) _ x at h + apply h.congr_fderiv + ext v + simp only [_root_.smul_apply, smul_eq_mul] + ring + +lemma radialPower_hessian {a : ℝ} (ha : 0 < a) (p : ℝ) (x v w : E) : + iteratedFDeriv ℝ 2 (radialPower a p) x ![v,w] = + 4*p*(p-1)*(a+‖x‖^2)^(p-2) * inner ℝ x v * inner ℝ x w + + 2*p*(a+‖x‖^2)^(p-1) * inner ℝ v w := by + have hg : (fun y => fderiv ℝ (radialPower a p) y) = + (fun y => (2*p*radialPower a (p-1) y) • innerSL ℝ y) := + funext fun (y : E) => by simpa only [radialPower] using (radialPower_hasFDerivAt ha p y).fderiv + have hs := (radialPower_hasFDerivAt ha (p-1) x).const_smul (2*p) + have hd := hs.smul (innerSL ℝ (E := E)).hasFDerivAt + change HasFDerivAt (fun y => (2*p*radialPower a (p-1) y) • innerSL ℝ y) _ x at hd + rw [iteratedFDeriv_succ_apply_right, iteratedFDeriv_one_apply] + change ((fderiv ℝ (fun y => fderiv ℝ (radialPower a p) y) x) v) w = _ + rw [hg, hd.fderiv] + simp only [_root_.add_apply, ContinuousLinearMap.smulRight_apply, + _root_.smul_apply, + innerSL_apply_apply, Pi.smul_apply, smul_eq_mul, radialPower, show p-1-1 = p-2 by ring] + change (2*p*(a+‖x‖^2)^(p-1))*inner ℝ v w + + (2*p)*(2*(p-1)*(a+‖x‖^2)^(p-2)*inner ℝ x v)*inner ℝ x w = _ + ring + +lemma scalarComposition_hessian {f : E → ℝ} {g g' g'' : ℝ → ℝ} + (hf : ContDiff ℝ (⊤ : ℕ∞) f) (hg : ∀ t, HasDerivAt g (g' t) t) + (hg' : ∀ t, HasDerivAt g' (g'' t) t) (x v w : E) : + iteratedFDeriv ℝ 2 (g ∘ f) x ![v,w] = + g'' (f x) * (fderiv ℝ f x v) * (fderiv ℝ f x w) + + g' (f x) * iteratedFDeriv ℝ 2 f x ![v,w] := by + have hf' (y : E) := (hf.differentiable (by simp) y).hasFDerivAt + have hG : (fun y => fderiv ℝ (g ∘ f) y) = + (fun y => g' (f y) • fderiv ℝ f y) := by + funext y + exact ((hg (f y)).comp_hasFDerivAt y (hf' y)).fderiv + have hfd : Differentiable ℝ (fun y => fderiv ℝ f y) := + (hf.fderiv_right (m := (⊤ : ℕ∞)) (by simp)).differentiable (by simp) + have hd := ((hg' (f x)).comp_hasFDerivAt x (hf' x)).smul + (hfd x).hasFDerivAt + change HasFDerivAt (fun y => g' (f y) • fderiv ℝ f y) _ x at hd + rw [iteratedFDeriv_succ_apply_right, iteratedFDeriv_one_apply] + change ((fderiv ℝ (fun y => fderiv ℝ (g ∘ f) y) x) v) w = _ + rw [hG, hd.fderiv] + rw [iteratedFDeriv_succ_apply_right, iteratedFDeriv_one_apply] + simp only [_root_.add_apply, ContinuousLinearMap.smulRight_apply, + _root_.smul_apply, smul_eq_mul] + simp only [show Fin.init ![v,w] 0 = v from rfl, show ![v,w] (Fin.last 1) = w from rfl, Function.comp_apply] + ring + +variable [FiniteDimensional ℝ E] + +def halfLaplacian (f : E → ℝ) (x : E) : ℝ := + (1/2 : ℝ) * ∑ i, iteratedFDeriv ℝ 2 f x + ![stdOrthonormalBasis ℝ E i, stdOrthonormalBasis ℝ E i] + +lemma radialPower_halfLaplacian {a : ℝ} (ha : 0 < a) (p : ℝ) (x : E) : + halfLaplacian (radialPower a p) x = + p * (a+‖x‖^2)^(p-2) * + ((Module.finrank ℝ E : ℝ)*a + (Module.finrank ℝ E + 2*p-2)*‖x‖^2) := by + classical + let e := stdOrthonormalBasis ℝ E + have hsum : (∑ i, inner ℝ x (e i) * inner ℝ x (e i)) = ‖x‖^2 := by + simpa only [real_inner_comm (e _), real_inner_self_eq_norm_sq] using + e.sum_inner_mul_inner x x + unfold halfLaplacian + simp_rw [radialPower_hessian ha] + simp only [(stdOrthonormalBasis ℝ E).inner_eq_ite, ite_eq_left, mul_one, Finset.sum_add_distrib] + have hsum' : (∑ i, 4*p*(p-1)*(a+‖x‖^2)^(p-2)*inner ℝ x (e i)*inner ℝ x (e i)) = + 4*p*(p-1)*(a+‖x‖^2)^(p-2)*‖x‖^2 := by + rw [← hsum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + change (1/2 : ℝ) * ((∑ i, 4*p*(p-1)*(a+‖x‖^2)^(p-2)*inner ℝ x (e i)*inner ℝ x (e i)) + + ∑ _ : Fin (Module.finrank ℝ E), 2*p*(a+‖x‖^2)^(p-1)) = _ + rw [hsum'] + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + have hpow : (a+‖x‖^2)^(p-1) = (a+‖x‖^2)^(p-2)*(a+‖x‖^2) := by + rw [show p-1 = (p-2)+1 by ring, Real.rpow_add (by positivity), Real.rpow_one] + rw [hpow] + ring + +def radialBump (a p : ℝ) (x : E) : ℝ := + smoothPositivePart (radialPower a p x - 1) + +omit [FiniteDimensional ℝ E] in +lemma radialBump_contDiff {a : ℝ} (ha : 0 < a) (p : ℝ) : + ContDiff ℝ (⊤ : ℕ∞) (radialBump (E := E) a p) := + smoothPositivePart_contDiff.comp ((radialPower_contDiff ha p).sub contDiff_const) + +omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] in +lemma radialBump_nonneg (a p : ℝ) (x : E) : 0 ≤ radialBump a p x := + smoothPositivePart_nonneg _ + +lemma radialBump_compact {a p : ℝ} (ha : 0 < a) (hp : p < 0) : + HasCompactSupport (radialBump (E := E) a p) := by + refine HasCompactSupport.intro (isCompact_closedBall (0 : E) 1) ?_ + intro x hx + apply smoothPositivePart_zero + have hx1 : 1 < ‖x‖ := by simpa [Metric.mem_closedBall, dist_zero_right] using hx + have hq : 1 ≤ a+‖x‖^2 := by nlinarith + exact sub_nonpos.mpr (Real.rpow_le_one_of_one_le_of_nonpos hq hp.le) + +lemma radialBump_halfLaplacian {a : ℝ} (ha : 0 < a) (p : ℝ) (x : E) : + halfLaplacian (radialBump a p) x = + smoothPositivePart' (radialPower a p x-1) * halfLaplacian (radialPower a p) x + + 2 * smoothPositivePart'' (radialPower a p x-1) * p^2 * + ((a+‖x‖^2)^(p-1))^2 * ‖x‖^2 := by + classical + have hf : ContDiff ℝ (⊤ : ℕ∞) (fun y : E => radialPower a p y - 1) := + (radialPower_contDiff ha p).sub contDiff_const + have he (v w : E) : + iteratedFDeriv ℝ 2 (radialBump a p) x ![v,w] = + smoothPositivePart'' (radialPower a p x-1) * + (2*p*(a+‖x‖^2)^(p-1)*inner ℝ x v) * + (2*p*(a+‖x‖^2)^(p-1)*inner ℝ x w) + + smoothPositivePart' (radialPower a p x-1) * + iteratedFDeriv ℝ 2 (radialPower a p) x ![v,w] := by + change iteratedFDeriv ℝ 2 (smoothPositivePart ∘ fun y => radialPower a p y-1) x _ = _ + rw [scalarComposition_hessian hf smoothPositivePart_hasDerivAt smoothPositivePart'_hasDerivAt] + simp only [fderiv_sub_const, (radialPower_hasFDerivAt ha p x).fderiv, + _root_.smul_apply, innerSL_apply_apply, smul_eq_mul] + congr 1 + congr 1 + rw [iteratedFDeriv_succ_apply_right, iteratedFDeriv_one_apply, + iteratedFDeriv_succ_apply_right, iteratedFDeriv_one_apply] + simp only [fderiv_sub_const] + let e := stdOrthonormalBasis ℝ E + have hsum : (∑ i, inner ℝ x (e i) * inner ℝ x (e i)) = ‖x‖^2 := by + simpa only [real_inner_comm (e _), real_inner_self_eq_norm_sq] using + e.sum_inner_mul_inner x x + unfold halfLaplacian + simp_rw [he, Finset.sum_add_distrib] + rw [← Finset.mul_sum] + have hs : (∑ i, smoothPositivePart'' (radialPower a p x-1) * + (2*p*(a+‖x‖^2)^(p-1)*inner ℝ x (e i)) * + (2*p*(a+‖x‖^2)^(p-1)*inner ℝ x (e i))) = + (4*smoothPositivePart'' (radialPower a p x-1)*p^2*((a+‖x‖^2)^(p-1))^2)*‖x‖^2 := by + rw [← hsum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + change (1/2:ℝ) * ((∑ i, smoothPositivePart'' (radialPower a p x-1) * + (2*p*(a+‖x‖^2)^(p-1)*inner ℝ x (e i)) * + (2*p*(a+‖x‖^2)^(p-1)*inner ℝ x (e i))) + _) = _ + rw [hs] + ring + +lemma smoothPositivePart_monotone : Monotone smoothPositivePart := + monotone_of_hasDerivAt_nonneg smoothPositivePart_hasDerivAt + (fun t => (smoothPositivePart'_bounds t).1) + +omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] in +lemma radialBump_antitone_parameter {a b p : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hp : p ≤ 0) (x : E) : radialBump b p x ≤ radialBump a p x := by + apply smoothPositivePart_monotone + exact sub_le_sub_right (Real.rpow_le_rpow_of_nonpos + (by positivity) (by linarith) hp) 1 + +lemma radialBump_negative_le {a : ℝ} (ha : 0 < a) (p : ℝ) (x : E) : + max (-halfLaplacian (radialBump a p) x) 0 ≤ + max (-halfLaplacian (radialPower a p) x) 0 := by + rw [radialBump_halfLaplacian ha] + have hb := smoothPositivePart'_bounds (radialPower a p x-1) + have hc : 0 ≤ 2 * smoothPositivePart'' (radialPower a p x-1) * p^2 * + ((a+‖x‖^2)^(p-1))^2 * ‖x‖^2 := by + exact mul_nonneg (mul_nonneg (mul_nonneg + (mul_nonneg (by norm_num) (smoothPositivePart''_nonneg _)) (sq_nonneg _)) + (sq_nonneg _)) (sq_nonneg _) + apply max_le + · by_cases h : 0 ≤ halfLaplacian (radialPower a p) x + · exact le_trans (by nlinarith [mul_nonneg hb.1 h]) (le_max_right _ _) + · have : smoothPositivePart' (radialPower a p x-1) * + halfLaplacian (radialPower a p) x ≥ halfLaplacian (radialPower a p) x := + by nlinarith [mul_nonneg (sub_nonneg.mpr hb.2) (neg_nonneg.mpr (le_of_not_ge h))] + exact le_trans (by linarith) (le_max_left _ _) + · exact le_max_right _ _ + +def smoothingExponent (E : Type uDomain) [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] : ℝ := 1/4 - (Module.finrank ℝ E : ℝ)/2 + +lemma smoothingExponent_neg (hn : 1 ≤ Module.finrank ℝ E) : smoothingExponent E < 0 := by + have : (1 : ℝ) ≤ Module.finrank ℝ E := by exact_mod_cast hn + unfold smoothingExponent + linarith + +lemma radialPower_laplacian_lower {a : ℝ} (ha : 0 < a) + (hn : 1 ≤ Module.finrank ℝ E) (x : E) : + smoothingExponent E * (Module.finrank ℝ E : ℝ) * a^(smoothingExponent E-1) ≤ + halfLaplacian (radialPower a (smoothingExponent E)) x := by + let p := smoothingExponent E + let n : ℝ := Module.finrank ℝ E + have hp : p < 0 := smoothingExponent_neg hn + have hn0 : 0 ≤ n := Nat.cast_nonneg _ + have hbracket : n + 2*p-2 = -(3/2:ℝ) := by unfold p n smoothingExponent; ring + rw [radialPower_halfLaplacian ha] + change p*n*a^(p-1) ≤ p*(a+‖x‖^2)^(p-2)*(n*a+(n+2*p-2)*‖x‖^2) + rw [hbracket] + have hpow := Real.rpow_le_rpow_of_nonpos ha + (show a ≤ a+‖x‖^2 by nlinarith [sq_nonneg ‖x‖]) (show p-2 ≤ 0 by linarith) + have hq : 0 ≤ (a+‖x‖^2)^(p-2) := Real.rpow_nonneg (by positivity) _ + have hstep : p*n*a^(p-1) = (p*n*a)*a^(p-2) := by + rw [show p-1 = (p-2)+1 by ring, Real.rpow_add ha, Real.rpow_one] + ring + rw [hstep] + calc + (p*n*a)*a^(p-2) ≤ (p*n*a)*(a+‖x‖^2)^(p-2) := + mul_le_mul_of_nonpos_left hpow (mul_nonpos_of_nonpos_of_nonneg + (mul_nonpos_of_nonpos_of_nonneg hp.le hn0) ha.le) + _ ≤ p*(a+‖x‖^2)^(p-2)*(n*a+ -(3/2:ℝ)*‖x‖^2) := by + have := mul_nonneg (neg_nonneg.mpr hp.le) (mul_nonneg hq (sq_nonneg ‖x‖)) + nlinarith + +lemma radialPower_laplacian_nonneg_outside {ε : ℝ} (hε : 0 < ε) + (hn : 1 ≤ Module.finrank ℝ E) (x : E) + (hx : (Module.finrank ℝ E + 1 : ℝ) * ε ≤ ‖x‖) : + 0 ≤ halfLaplacian (radialPower (ε^2) (smoothingExponent E)) x := by + let p := smoothingExponent E + let n : ℝ := Module.finrank ℝ E + have hp : p < 0 := smoothingExponent_neg hn + have hn0 : 0 ≤ n := Nat.cast_nonneg _ + have hbracket : n + 2*p-2 = -(3/2:ℝ) := by unfold p n smoothingExponent; ring + rw [radialPower_halfLaplacian (sq_pos_of_pos hε)] + change 0 ≤ p*(ε^2+‖x‖^2)^(p-2)*(n*ε^2+(n+2*p-2)*‖x‖^2) + rw [hbracket] + apply mul_nonneg_of_nonpos_of_nonpos + · exact mul_nonpos_of_nonpos_of_nonneg hp.le (Real.rpow_nonneg (by positivity) _) + · have hs : ((n+1)*ε)^2 ≤ ‖x‖^2 := sq_le_sq₀ (by positivity) (norm_nonneg _) |>.mpr hx + have he : 0 ≤ ε^2 := sq_nonneg _ + have hnn : n ≤ (n+1)^2 := by nlinarith [sq_nonneg n] + have hnn' := mul_le_mul_of_nonneg_right hnn he + nlinarith + +lemma radialBump_weighted_negative_bound {ε : ℝ} (hε : 0 < ε) + (hn : 1 ≤ Module.finrank ℝ E) (x : E) : + max (-halfLaplacian (radialBump (ε^2) (smoothingExponent E)) x) 0 * ‖x‖^2 ≤ + (Metric.closedBall (0 : E) ((Module.finrank ℝ E + 1 : ℝ)*ε)).indicator + (fun _ => (-smoothingExponent E)*(Module.finrank ℝ E : ℝ)* + (Module.finrank ℝ E + 1 : ℝ)^2*(ε^2)^(smoothingExponent E)) x := by + classical + let p := smoothingExponent E + let n : ℝ := Module.finrank ℝ E + have hp : p < 0 := smoothingExponent_neg hn + have hn0 : 0 ≤ n := Nat.cast_nonneg _ + have hε2 : 0 < ε^2 := sq_pos_of_pos hε + have hle := radialBump_negative_le hε2 p x + by_cases hx : x ∈ Metric.closedBall (0 : E) ((n+1)*ε) + · rw [Set.indicator_of_mem hx] + have hx' : ‖x‖ ≤ (n+1)*ε := by simpa [Metric.mem_closedBall, dist_zero_right] using hx + have hs : ‖x‖^2 ≤ ((n+1)*ε)^2 := (sq_le_sq₀ (norm_nonneg _) (by positivity)).mpr hx' + have hlower := radialPower_laplacian_lower hε2 hn x + have hK : 0 ≤ (-p)*n*(ε^2)^(p-1) := + mul_nonneg (mul_nonneg (neg_nonneg.mpr hp.le) hn0) (Real.rpow_nonneg hε2.le _) + have hmax : max (-halfLaplacian (radialPower (ε^2) p) x) 0 ≤ + (-p)*n*(ε^2)^(p-1) := max_le (by linarith) hK + calc + _ ≤ ((-p)*n*(ε^2)^(p-1))*((n+1)*ε)^2 := + mul_le_mul (hle.trans hmax) hs (sq_nonneg _) hK + _ = _ := by + have hpow : (ε^2)^(p-1)*(ε^2) = (ε^2)^p := by + calc + _ = (ε^2)^(p-1)*(ε^2)^(1:ℝ) := by rw [Real.rpow_one] + _ = _ := by rw [← Real.rpow_add hε2]; congr 1; ring + change (-p)*n*(ε^2)^(p-1)*((n+1)*ε)^2 = (-p)*n*(n+1)^2*(ε^2)^p + rw [← hpow] + ring + · rw [Set.indicator_of_notMem hx] + have hx' : (n+1)*ε ≤ ‖x‖ := by + have := hx + simp only [Metric.mem_closedBall, dist_zero_right, not_le] at this + exact this.le + have hnonneg := radialPower_laplacian_nonneg_outside hε hn x hx' + have hzero : max (-halfLaplacian (radialPower (ε^2) p) x) 0 = 0 := + max_eq_right (neg_nonpos.mpr hnonneg) + rw [hzero] at hle + exact mul_nonpos_of_nonpos_of_nonneg hle (sq_nonneg _) + +section Integration +variable [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] + +lemma radialBump_integral_pos (hn : 1 ≤ Module.finrank ℝ E) : + 0 < ∫ x, radialBump (1/4) (smoothingExponent E) x ∂μ := by + apply (radialBump_contDiff (E := E) (by norm_num : (0:ℝ)<1/4) + (smoothingExponent E)).continuous.integral_pos_of_hasCompactSupport_nonneg_nonzero + (radialBump_compact (by norm_num) (smoothingExponent_neg hn)) + (radialBump_nonneg _ _) + apply ne_of_gt (smoothPositivePart_pos (t := radialPower (1/4) (smoothingExponent E) (0:E)-1) _) + simp only [radialPower, norm_zero, sq, mul_zero, add_zero] + exact sub_pos.mpr (Real.one_lt_rpow_of_pos_of_lt_one_of_neg + (by norm_num) (by norm_num) (smoothingExponent_neg hn)) + +lemma radialBump_integral_lower {a : ℝ} (ha : 0 < a) (ha' : a ≤ 1/4) + (hn : 1 ≤ Module.finrank ℝ E) : + (∫ x, radialBump (1/4) (smoothingExponent E) x ∂μ) ≤ + ∫ x, radialBump a (smoothingExponent E) x ∂μ := by + apply integral_mono + · exact (radialBump_contDiff (by norm_num) _).continuous.integrable_of_hasCompactSupport + (radialBump_compact (by norm_num) (smoothingExponent_neg hn)) + · exact (radialBump_contDiff ha _).continuous.integrable_of_hasCompactSupport + (radialBump_compact ha (smoothingExponent_neg hn)) + · exact fun x => radialBump_antitone_parameter ha ha' (smoothingExponent_neg hn).le x + +omit [MeasurableSpace E] [BorelSpace E] in +lemma radial_weight_exponent {ε : ℝ} (hε : 0 < ε) : + ε^(Module.finrank ℝ E) * (ε^2)^(smoothingExponent E) = Real.sqrt ε := by + rw [Real.sqrt_eq_rpow, ← Real.rpow_natCast, ← Real.rpow_natCast_mul hε.le 2, + ← Real.rpow_add hε] + congr 1 + unfold smoothingExponent + push_cast + ring + +lemma radialBump_integral_negative_bound {ε : ℝ} (hε : 0 < ε) + (hn : 1 ≤ Module.finrank ℝ E) : + (∫ x, max (-halfLaplacian (radialBump (ε^2) (smoothingExponent E)) x) 0 * ‖x‖^2 ∂μ) ≤ + μ.real (Metric.ball (0:E) 1) * (-smoothingExponent E) * + (Module.finrank ℝ E : ℝ) * (Module.finrank ℝ E + 1 : ℝ)^(Module.finrank ℝ E+2) * + Real.sqrt ε := by + let n : ℝ := Module.finrank ℝ E + let p := smoothingExponent E + let R := (n+1)*ε + let K := (-p)*n*(n+1)^2*(ε^2)^p + have hR : 0 ≤ R := by dsimp [R,n]; positivity + have hI : Integrable ((Metric.closedBall (0:E) R).indicator (fun _ => K)) μ := + (integrableOn_const (measure_closedBall_lt_top.ne)).integrable_indicator measurableSet_closedBall + have hbound := integral_mono_of_nonneg + (Filter.Eventually.of_forall (fun x => mul_nonneg (le_max_right _ _) (sq_nonneg _))) hI + (Filter.Eventually.of_forall (radialBump_weighted_negative_bound hε hn)) + refine hbound.trans_eq ?_ + rw [integral_indicator_const _ measurableSet_closedBall, smul_eq_mul] + rw [Measure.real_def, μ.addHaar_closedBall (0:E) hR, ENNReal.toReal_mul, + ENNReal.toReal_ofReal (pow_nonneg hR _)] + dsimp [R,K,n,p] + rw [mul_pow] + have he := radial_weight_exponent (E := E) hε + have he' : ε^(Module.finrank ℝ E)*(ε^2)^(smoothingExponent E) = Real.sqrt ε := he + change ((Module.finrank ℝ E + 1 : ℝ)^(Module.finrank ℝ E)*ε^(Module.finrank ℝ E)* + μ.real (Metric.ball (0:E) 1)) * + ((-smoothingExponent E)*(Module.finrank ℝ E : ℝ)*(Module.finrank ℝ E + 1 : ℝ)^2* + (ε^2)^(smoothingExponent E)) = _ + rw [pow_add, ← he'] + ring + +theorem exists_radial_smoothing (hn : 1 ≤ Module.finrank ℝ E) {η : ℝ} (hη : 0 < η) : + ∃ b : E → ℝ, ContDiff ℝ (⊤ : ℕ∞) b ∧ HasCompactSupport b ∧ + (∀ x, 0 ≤ b x) ∧ 0 < ∫ x, b x ∂μ ∧ + (∫ x, max (-halfLaplacian b x) 0 * ‖x‖^2 ∂μ) < η * ∫ x, b x ∂μ := by + let p := smoothingExponent E + let m := ∫ x, radialBump (1/4) p x ∂μ + let K := μ.real (Metric.ball (0:E) 1) * (-p) * (Module.finrank ℝ E : ℝ) * + (Module.finrank ℝ E + 1 : ℝ)^(Module.finrank ℝ E+2) + have hm : 0 < m := radialBump_integral_pos μ hn + have hp : p < 0 := smoothingExponent_neg hn + have hK : 0 ≤ K := by + dsimp [K] + exact mul_nonneg (mul_nonneg (mul_nonneg (ENNReal.toReal_nonneg) + (neg_nonneg.mpr hp.le)) (Nat.cast_nonneg _)) (by positivity) + obtain ⟨t,ht,ht'⟩ := exists_pos_mul_lt (mul_pos hη hm) (K+1) + let δ := min t (1/2:ℝ) + have hδ : 0 < δ := lt_min ht (by norm_num) + have hδt : δ ≤ t := min_le_left _ _ + have hδhalf : δ ≤ 1/2 := min_le_right _ _ + have hsmall : K*δ < η*m := by + have := mul_le_mul_of_nonneg_left hδt (show 0 ≤ K+1 by linarith) + nlinarith + let ε := δ^2 + have hε : 0 < ε := sq_pos_of_pos hδ + have hεlimit : ε^2 ≤ 1/4 := by + have hs : δ^2 ≤ 1/4 := by nlinarith + dsimp [ε] + calc + (δ^2)^2 ≤ (1/4:ℝ)^2 := (sq_le_sq₀ (sq_nonneg _) (by norm_num)).mpr hs + _ ≤ 1/4 := by norm_num + refine ⟨radialBump (ε^2) p, radialBump_contDiff (sq_pos_of_pos hε) p, + radialBump_compact (sq_pos_of_pos hε) hp, radialBump_nonneg _ _, ?_, ?_⟩ + · exact hm.trans_le (radialBump_integral_lower μ (sq_pos_of_pos hε) hεlimit hn) + · have hupper := radialBump_integral_negative_bound μ hε hn + have hroot : Real.sqrt ε = δ := by dsimp [ε]; rw [Real.sqrt_sq hδ.le] + change _ ≤ K*Real.sqrt ε at hupper + rw [hroot] at hupper + exact hupper.trans_lt (hsmall.trans_le (mul_le_mul_of_nonneg_left + (radialBump_integral_lower μ (sq_pos_of_pos hε) hεlimit hn) hη.le)) + +end Integration + +end Radial + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/SmoothingMatrix.lean b/lean/OAI/Combinatorics/EuclideanRamsey/SmoothingMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..56ed07173ce143b0bfd1cbcc25212cda3f2abe2c --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/SmoothingMatrix.lean @@ -0,0 +1,240 @@ +import OAI.Combinatorics.EuclideanRamsey.DifferentialSplitting + +namespace OAI + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory + +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +namespace EuclideanRamsey +lemma exists_positive_shift {k : ℕ} (C : Matrix (Fin k) (Fin k) ℝ) (hC : C.IsSymm) : + ∃ L : ℝ, 0 < L ∧ (L • (1 : Matrix (Fin k) (Fin k) ℝ) + C).PosDef := by + by_cases hk : k = 0 + · subst k + exact ⟨1, zero_lt_one, by convert (Matrix.PosDef.one : (1 : Matrix (Fin 0) (Fin 0) ℝ).PosDef) using 1; exact Subsingleton.elim _ _⟩ + let : NeZero k := ⟨hk⟩ + have hh : C.IsHermitian := Matrix.isHermitian_iff_isSymm.mpr hC + have h : -(algebraMap ℝ (Matrix (Fin k) (Fin k) ℝ) ‖C‖) ≤ C := + by + rw [neg_le] + exact le_algebraMap_of_spectrum_le (fun r hr => (Real.le_norm_self r).trans + (by simpa using spectrum.norm_le_norm_of_mem hr)) hh.neg.isSelfAdjoint + have h' : (‖C‖ • (1 : Matrix (Fin k) (Fin k) ℝ) + C).PosSemidef := by + simpa [Matrix.le_iff, Algebra.algebraMap_eq_smul_one, add_comm] using h + refine ⟨1+‖C‖, by positivity, ?_⟩ + convert Matrix.PosDef.one.add_posSemidef h' using 1 ; simp [add_smul, add_assoc] + +lemma covariance_splitting {k d : ℕ} (C : Matrix (Fin k) (Fin k) ℝ) + (U : Matrix (Fin d) (Fin k) ℝ) (hC : C.IsSymm) + (hU : U * C * U.transpose = 1) : + let R := C * U.transpose + let Z := 1 - R * U + U * R = 1 ∧ U * Z = 0 ∧ C = R * R.transpose + Z * C * Z.transpose := by + dsimp only + let R := C * U.transpose + have hR : U * R = 1 := by simpa only [R, ← Matrix.mul_assoc] using hU + have hRt : R.transpose = U * C := by simp only [R, Matrix.transpose_mul, + Matrix.transpose_transpose, hC.eq] + have hRR : R.transpose * U.transpose = 1 := by + rw [← Matrix.transpose_mul, hR, Matrix.transpose_one] + refine ⟨hR, ?_, ?_⟩ + · change U * (1 - R * U) = 0 + rw [Matrix.mul_sub, Matrix.mul_one, ← Matrix.mul_assoc, hR, Matrix.one_mul, sub_self] + · change C = R * R.transpose + (1 - R * U) * C * (1 - R * U).transpose + have ht : (1 - R * U).transpose = 1 - U.transpose * R.transpose := by + rw [Matrix.transpose_sub, Matrix.transpose_one, Matrix.transpose_mul] + have h1 : R * U * C = R * R.transpose := by rw [hRt, Matrix.mul_assoc] + have h2 : C * (U.transpose * R.transpose) = R * R.transpose := by + rw [← Matrix.mul_assoc] + have h3 : R * R.transpose * (U.transpose * R.transpose) = R * R.transpose := by + rw [ Matrix.mul_assoc, ← Matrix.mul_assoc R.transpose, hRR, Matrix.one_mul] + simp only [ht, Matrix.sub_mul, Matrix.mul_sub, Matrix.one_mul, Matrix.mul_one, + h1, h2, h3] + abel + +lemma positive_joint_pushforward {k d : ℕ} (R : Matrix (Fin k) (Fin d) ℝ) + (U : Matrix (Fin d) (Fin k) ℝ) (Z : Matrix (Fin k) (Fin k) ℝ) + (hRU : R * U + Z = 1) (A : Matrix (Fin d) (Fin d) ℝ) + (B : Matrix (Fin k) (Fin k) ℝ) (hA : A.PosDef) (hB : B.PosDef) : + (R * A * R.transpose + Z * B * Z.transpose).PosDef := by + have hs : (R * A * R.transpose + Z * B * Z.transpose).IsHermitian := by + simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using + (isHermitian_mul_mul_conjTranspose R hA.isHermitian).add + (isHermitian_mul_mul_conjTranspose Z hB.isHermitian) + apply Matrix.PosDef.of_dotProduct_mulVec_pos hs + intro x hx + have hj : R.transpose *ᵥ x ≠ 0 ∨ Z.transpose *ᵥ x ≠ 0 := by + by_contra hh + push Not at hh + have he := congrArg (fun M : Matrix (Fin k) (Fin k) ℝ => M.transpose *ᵥ x) hRU + simp only [Matrix.transpose_add, Matrix.transpose_mul, Matrix.transpose_one, + Matrix.add_mulVec, ← Matrix.mulVec_mulVec, Matrix.one_mulVec, hh.1, hh.2, + Matrix.mulVec_zero, add_zero] at he + exact hx he.symm + have ha : 0 ≤ (R.transpose *ᵥ x) ⬝ᵥ (A *ᵥ (R.transpose *ᵥ x)) := by + simpa using hA.posSemidef.dotProduct_mulVec_nonneg (R.transpose *ᵥ x) + have hb : 0 ≤ (Z.transpose *ᵥ x) ⬝ᵥ (B *ᵥ (Z.transpose *ᵥ x)) := by + simpa using hB.posSemidef.dotProduct_mulVec_nonneg (Z.transpose *ᵥ x) + have hpos : 0 < (R.transpose *ᵥ x) ⬝ᵥ (A *ᵥ (R.transpose *ᵥ x)) + + (Z.transpose *ᵥ x) ⬝ᵥ (B *ᵥ (Z.transpose *ᵥ x)) := by + rcases hj with hj | hj + · exact add_pos_of_pos_of_nonneg (by simpa using hA.dotProduct_mulVec_pos hj) hb + · exact add_pos_of_nonneg_of_pos ha (by simpa using hB.dotProduct_mulVec_pos hj) + have heq {n : ℕ} (M : Matrix (Fin k) (Fin n) ℝ) (D : Matrix (Fin n) (Fin n) ℝ) : + x ⬝ᵥ ((M * D * M.transpose) *ᵥ x) = + (M.transpose *ᵥ x) ⬝ᵥ (D *ᵥ (M.transpose *ᵥ x)) := by + rw [← Matrix.mulVec_mulVec, ← Matrix.mulVec_mulVec, + Matrix.dotProduct_mulVec x M] + have ht : x ᵥ* M = M.transpose *ᵥ x := by + simpa using Matrix.vecMul_transpose M.transpose x + rw [ht] + simpa only [star_trivial, Matrix.add_mulVec, dotProduct_add, heq] using hpos + +theorem exists_small_covariance {k d : ℕ} (C : Matrix (Fin k) (Fin k) ℝ) + (U : Matrix (Fin d) (Fin k) ℝ) (hC : C.IsSymm) + (hU : U * C * U.transpose = 1) {η : ℝ} (hη : 0 < η) : + ∃ S : Matrix (Fin k) (Fin k) ℝ, S.PosDef ∧ (S + C).PosDef ∧ + (U * S * U.transpose).trace < η := by + let R := C * U.transpose + let Z := 1 - R * U + obtain ⟨hR, hZ, hsplit⟩ := covariance_splitting C U hC hU + change U * R = 1 at hR + change U * Z = 0 at hZ + change C = R * R.transpose + Z * C * Z.transpose at hsplit + have hj : R * U + Z = 1 := by dsimp [Z]; abel + obtain ⟨L, hL, hLC⟩ := exists_positive_shift C hC + let ε : ℝ := η / (2 * (d + 1)) + have hε : 0 < ε := by dsimp [ε]; positivity + let S := R * (ε • (1 : Matrix (Fin d) (Fin d) ℝ)) * R.transpose + + Z * (L • (1 : Matrix (Fin k) (Fin k) ℝ)) * Z.transpose + refine ⟨S, positive_joint_pushforward R U Z hj _ _ + (Matrix.PosDef.one.smul hε) (Matrix.PosDef.one.smul hL), ?_, ?_⟩ + · have heq : S + C = R * ((ε + 1) • (1 : Matrix (Fin d) (Fin d) ℝ)) * R.transpose + + Z * (L • (1 : Matrix (Fin k) (Fin k) ℝ) + C) * Z.transpose := by + conv_lhs => rw [hsplit] + simp only [S, add_smul, one_smul, Matrix.mul_add, Matrix.add_mul, Matrix.mul_one] + abel + rw [heq] + exact positive_joint_pushforward R U Z hj _ _ + (Matrix.PosDef.one.smul (by linarith)) hLC + · have heq {n : ℕ} (M : Matrix (Fin k) (Fin n) ℝ) + (A : Matrix (Fin n) (Fin n) ℝ) : + U * (M * A * M.transpose) * U.transpose = + (U * M) * A * (U * M).transpose := by + simp only [Matrix.transpose_mul, Matrix.mul_assoc] + have hcov : U * S * U.transpose = ε • (1 : Matrix (Fin d) (Fin d) ℝ) := by + dsimp only [S] + rw [Matrix.mul_add, Matrix.add_mul, heq, heq, hR, hZ] + simp + rw [hcov, Matrix.trace_smul, Matrix.trace_one] + simp only [Fintype.card_fin, smul_eq_mul] + dsimp [ε] + have hd : (0 : ℝ) ≤ d := Nat.cast_nonneg _ + rw [div_mul_eq_mul_div] + apply (div_lt_iff₀ (by positivity : (0 : ℝ) < 2 * (d+1))).mpr + nlinarith + +end EuclideanRamsey + +open scoped BigOperators +open MeasureTheory Matrix +namespace EuclideanRamsey + +def stencilDifferential {k : ℕ} (C : Matrix (Fin k) (Fin k) ℝ) + (b : (Fin k → ℝ) → ℝ) (x : Fin k → ℝ) : ℝ := + (1/2 : ℝ) * ∑ j, ∑ l, C j l * + iteratedFDeriv ℝ 2 b x ![Pi.single j 1, Pi.single l 1] + +def gradientWeight {k d : ℕ} (U : Matrix (Fin d) (Fin k) ℝ) (x : Fin k → ℝ) : ℝ := + ∑ a, (∑ j, U a j * x j)^2 + +lemma gradientWeight_nonneg {k d : ℕ} (U : Matrix (Fin d) (Fin k) ℝ) (x : Fin k → ℝ) : + 0 ≤ gradientWeight U x := Finset.sum_nonneg (fun _ _ => sq_nonneg _) + +def CompactSmoothing : Prop := + ∀ (k d : ℕ), 1 ≤ d → ∀ (C : Matrix (Fin k) (Fin k) ℝ) + (U : Matrix (Fin d) (Fin k) ℝ), C.IsSymm → U * C * U.transpose = 1 → + ∀ η : ℝ, 0 < η → ∃ b : (Fin k → ℝ) → ℝ, + ContDiff ℝ (⊤ : ℕ∞) b ∧ HasCompactSupport b ∧ (∀ x, 0 ≤ b x) ∧ + 0 < ∫ x, b x ∧ + (∫ x, max (-(stencilDifferential C b x)) 0 * gradientWeight U x) < η * ∫ x, b x + +end EuclideanRamsey +namespace EuclideanRamsey +open MeasureTheory Matrix +open scoped BigOperators + +theorem compact_smoothing : CompactSmoothing := by + intro k d hd C U hC hU η hη + let R := C * U.transpose + let Z : Matrix (Fin k) (Fin k) ℝ := 1-R*U + obtain ⟨hUR,hUZ,hsplit⟩ := covariance_splitting C U hC hU + change U*R=1 at hUR + change U*Z=0 at hUZ + change C=R*R.transpose+Z*C*Z.transpose at hsplit + let H := EuclideanSpace ℝ (Fin d) + let eH : H ≃ₗ[ℝ] (Fin d → ℝ) := (EuclideanSpace.equiv (Fin d) ℝ).toLinearEquiv + let u : (Fin k → ℝ) →ₗ[ℝ] H := eH.symm.toLinearMap.comp (Matrix.toLin' U) + let r : H →ₗ[ℝ] (Fin k → ℝ) := (Matrix.toLin' R).comp eH.toLinearMap + have hur : u.comp r = LinearMap.id := by + apply LinearMap.ext + intro y + simp only [u,r,LinearMap.comp_apply,Matrix.toLin'_apply] + rw [Matrix.mulVec_mulVec, hUR, Matrix.one_mulVec] + exact eH.symm_apply_apply y + let V := LinearMap.ker u + let e : (Fin k → ℝ) ≃L[ℝ] H×V := (rightInverseSplit u r hur).toContinuousLinearEquiv + let eh : OrthonormalBasis (Fin d) ℝ H := EuclideanSpace.basisFun (Fin d) ℝ + have hRv (j : Fin d) : r (eh j) = fun l => R l j := by + change R.mulVec (eH (eh j)) = _ + have h : eH (eh j) = Pi.single j 1 := by + change ((EuclideanSpace.basisFun (Fin d) ℝ) j).ofLp = _ + rw [EuclideanSpace.basisFun_apply] + rfl + rw [h, Matrix.mulVec_single] + simp + rfl + have hZv (j : Fin k) : (fun l => Z l j) ∈ LinearMap.ker u := by + rw [LinearMap.mem_ker] + change eH.symm (U.mulVec (fun l => Z l j)) = 0 + have h : U.mulVec (fun l => Z l j) = 0 := by + ext a + change (U*Z) a j = 0 + rw [hUZ]; rfl + rw [h,map_zero] + let z : Fin k → V := fun j => ⟨fun l => Z l j,hZv j⟩ + have hR (j : Fin d) : e (fun l => R l j) = (eh j,0) := by + rw [← hRv] + exact rightInverseSplit_apply_R u r hur (eh j) + have hZ (j : Fin k) : e (fun l => Z l j) = (0,z j) := by + apply Prod.ext + · exact hZv j + · apply Subtype.ext + change (fun l => Z l j) - r (u (fun l => Z l j)) = _ + rw [show u (fun l => Z l j) = 0 from hZv j,map_zero,sub_zero] + let : MeasurableSpace H := borel H + let : BorelSpace H := ⟨rfl⟩ + let : MeasurableSpace V := borel V + let : BorelSpace V := ⟨rfl⟩ + have hn : 1 ≤ Module.finrank ℝ H := by simpa [H] using hd + obtain ⟨b,hbs,hbk,hbp,hbm,hsmall⟩ := exists_split_smoothing hn C R Z hsplit e eh z hR hZ hη + refine ⟨b,hbs,hbk,hbp,hbm,?_⟩ + have hw (x : Fin k → ℝ) : ‖(e x).1‖^2 = gradientWeight U x := by + change ‖eH.symm (U.mulVec x)‖^2 = _ + rw [EuclideanSpace.real_norm_sq_eq] + rfl + have hop (x : Fin k → ℝ) : secondOperator C (fun j => Pi.single j 1) b x = + stencilDifferential C b x := by simp only [secondOperator,stencilDifferential,hessianB_eq] + simpa only [hw,hop] using hsmall + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/SphereTransport.lean b/lean/OAI/Combinatorics/EuclideanRamsey/SphereTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..d53bda84bb578a7080f3c747d90cc93868da2b32 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/SphereTransport.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.EuclideanRamsey.Congruence +import Mathlib.Geometry.Euclidean.Sphere.Basic + +namespace OAI + +noncomputable section + +namespace EuclideanRamsey + +/-- A full-affine-span representative transfers its sphere to any congruent +configuration. The translated linear isometry preserves the radius exactly; +in particular, there is no rescaling of the pairwise distances. No injectivity +or positive-dimension hypothesis is needed for this transport lemma. -/ +theorem cospherical_transport {s D d : ℕ} + (a : Fin s → Space D) (b : Fin s → Space d) + (hspan : affineSpan ℝ (Set.range b) = ⊤) + (hab : Congruent a b) + (hb : EuclideanGeometry.Cospherical (Set.range b)) : + EuclideanGeometry.Cospherical (Set.range a) := by + by_cases hs : s = 0 + · subst s + refine ⟨0, 0, ?_⟩ + rintro _ ⟨i, rfl⟩ + exact Fin.elim0 i + · have hspos : 0 < s := Nat.pos_of_ne_zero hs + have hba : Congruent b a := fun i j => (hab i j).symm + obtain ⟨Q, t, hQ⟩ := + congruent_linearIsometry b a ⟨0, hspos⟩ hspan hba + obtain ⟨center, radius, hcenter⟩ := hb + refine ⟨t + Q center, radius, ?_⟩ + rintro _ ⟨i, rfl⟩ + calc + dist (a i) (t + Q center) = + dist (t + Q (b i)) (t + Q center) := by rw [hQ i] + _ = dist (Q (b i)) (Q center) := by + simp only [dist_eq_norm] + congr 1 + abel + _ = dist (b i) center := Q.dist_map _ _ + _ = radius := hcenter (b i) (Set.mem_range_self i) + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Spherical.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Spherical.lean new file mode 100644 index 0000000000000000000000000000000000000000..19633b1b69b8c9d4eee5ed8404da4b306f8904ae --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Spherical.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.EuclideanRamsey.TensorSphere +import OAI.Combinatorics.EuclideanRamsey.SphereTransport +import OAI.Combinatorics.EuclideanRamsey.Main + +namespace OAI + +noncomputable section + +namespace EuclideanRamsey + +/-- Every injective finite indexed Ramsey configuration is cospherical. +This uses the existing Ramsey predicate, with arbitrary finite colorings and +copies preserving the original pairwise distances. Empty configurations and +singletons are included, and no ambient affine-span assumption is imposed. -/ +theorem ramsey_cospherical {s d : ℕ} (a : Fin s → Space d) + (ha : Function.Injective a) (hR : Ramsey a) : + EuclideanGeometry.Cospherical (Set.range a) := by + by_cases hs0 : s = 0 + · subst s + refine ⟨0, 0, ?_⟩ + rintro _ ⟨i, rfl⟩ + exact Fin.elim0 i + · by_cases hs1 : s = 1 + · subst s + refine ⟨a 0, 0, ?_⟩ + rintro _ ⟨i, rfl⟩ + have hi : i = 0 := Subsingleton.elim _ _ + rw [hi, dist_self] + · have hs2 : 2 ≤ s := by omega + obtain ⟨D, _hD, b, _hb, hab, hspan⟩ := + full_affine_representative a hs2 ha + have hbR : Ramsey b := (ramsey_congruent_iff hab).mp hR + have hbCriterion : RealCriterion b := + ramsey_realCriterion b (by omega) hspan hbR + have hbSphere : EuclideanGeometry.Cospherical (Set.range b) := + realCriterion_cospherical b (by omega) hbCriterion + exact cospherical_transport a b hspan hab hbSphere + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/StencilConvolution.lean b/lean/OAI/Combinatorics/EuclideanRamsey/StencilConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..f59c61c26559f08de903aea8315ef32d41eb4139 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/StencilConvolution.lean @@ -0,0 +1,314 @@ +import OAI.Combinatorics.EuclideanRamsey.RationalConvolution + +namespace OAI + +universe uIndex + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology + +namespace EuclideanRamsey +open scoped BigOperators + +lemma stencil_taylor_uniform {ι : Type uIndex} {k : ℕ} (S : Finset ι) + (q : ι → ℝ) (v : ι → (Fin k → ℝ)) (C : Matrix (Fin k) (Fin k) ℝ) + (hzero : ∑ γ ∈ S,q γ = 0) (hfirst : ∀ j,∑ γ ∈ S,q γ*v γ j = 0) + (hsecond : ∀ j l,∑ γ ∈ S,q γ*v γ j*v γ l = C j l) + {b : (Fin k → ℝ) → ℝ} (hb : ContDiff ℝ (⊤ : ℕ∞) b) + (hbc : HasCompactSupport b) : + ∃ K : ℝ, 0 ≤ K ∧ ∀ (t : ℝ), 0 < t → ∀ x, + |t^2*(∑ γ ∈ S,q γ*b (x+(-t⁻¹) • v γ))-stencilDifferential C b x| ≤ K/t := by + obtain ⟨K,hK,hTaylor⟩ := compact_taylor_bound hb hbc + refine ⟨∑ γ ∈ S, |q γ| *K*‖v γ‖^3,Finset.sum_nonneg (fun _ _ => by positivity),?_⟩ + intro t ht x + have hl := linear_moment_contract S q v (fderiv ℝ b x) + simp only [hfirst,zero_mul,Finset.sum_const_zero] at hl + have hb' := bilinear_moment_contract S q v (hessianB b x) + simp only [hsecond,hessianB_eq] at hb' + let r (γ : ι) := b (x+(-t⁻¹) • v γ)-b x- + fderiv ℝ b x ((-t⁻¹) • v γ)- + (1/2:ℝ)*iteratedFDeriv ℝ 2 b x ![(-t⁻¹) • v γ,(-t⁻¹) • v γ] + have hr (γ : ι) : |r γ| ≤ K*(t⁻¹)^3*‖v γ‖^3 := by + have hh := hTaylor x ((-t⁻¹) • v γ) + simpa only [r,norm_smul,Real.norm_eq_abs,abs_neg,abs_inv,abs_of_pos ht,mul_pow, + mul_assoc] using hh + have hrEq : t^2*(∑ γ ∈ S,q γ*b (x+(-t⁻¹) • v γ))-stencilDifferential C b x = + t^2*∑ γ ∈ S,q γ*r γ := by + have hscale (γ : ι) : iteratedFDeriv ℝ 2 b x ![(-t⁻¹) • v γ,(-t⁻¹) • v γ] = + (t⁻¹)^2*iteratedFDeriv ℝ 2 b x ![v γ,v γ] := by + simp only [← hessianB_eq,map_smul,_root_.smul_apply,smul_eq_mul] + ring + simp only [r,mul_sub,Finset.sum_sub_distrib,map_smul,smul_eq_mul,hscale] + have hz : ∑ γ ∈ S,q γ*b x = 0 := by rw [← Finset.sum_mul,hzero,zero_mul] + have h1 : ∑ γ ∈ S,q γ*(-t⁻¹*fderiv ℝ b x (v γ)) = 0 := by + calc + _ = -t⁻¹*(∑ γ ∈ S,q γ*fderiv ℝ b x (v γ)) := by + rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro γ hγ; ring + _ = 0 := by rw [hl,mul_zero] + have h2 : ∑ γ ∈ S,q γ*((1/2:ℝ)*((t⁻¹)^2*iteratedFDeriv ℝ 2 b x ![v γ,v γ])) = + (t⁻¹)^2*stencilDifferential C b x := by + unfold stencilDifferential + rw [← hb'] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro γ hγ + ring + rw [hz,h1,h2] + field_simp + ring + rw [hrEq,abs_mul,abs_of_nonneg (sq_nonneg t)] + calc + _ ≤ t^2 * ∑ γ ∈ S, |q γ| *|r γ| := by + gcongr + simpa only [abs_mul] using Finset.abs_sum_le_sum_abs (fun γ => q γ*r γ) S + _ ≤ t^2 * ∑ γ ∈ S, |q γ| *(K*(t⁻¹)^3*‖v γ‖^3) := by + gcongr with γ hγ + exact hr γ + _ = (∑ γ ∈ S,|q γ| *K*‖v γ‖^3)/t := by + rw [Finset.mul_sum,Finset.sum_div] + apply Finset.sum_congr rfl + intro γ hγ + field_simp + +end EuclideanRamsey + +namespace EuclideanRamsey +open MeasureTheory Filter +open scoped BigOperators Topology + +lemma stencilDifferential_continuous {k : ℕ} (C : Matrix (Fin k) (Fin k) ℝ) + {b : (Fin k → ℝ) → ℝ} (hb : ContDiff ℝ (⊤ : ℕ∞) b) : + Continuous (stencilDifferential C b) := by + have hh := hb.continuous_iteratedFDeriv (m := 2) (by norm_cast) + unfold stencilDifferential + fun_prop + +lemma stencilDifferential_support {k : ℕ} (C : Matrix (Fin k) (Fin k) ℝ) + (b : (Fin k → ℝ) → ℝ) : Function.support (stencilDifferential C b) ⊆ tsupport b := by + intro x hx + by_contra h + have hi : x ∉ tsupport (iteratedFDeriv ℝ 2 b) := fun hx => h (tsupport_iteratedFDeriv_subset 2 hx) + have hz := image_eq_zero_of_notMem_tsupport hi + exact hx (by simp [stencilDifferential,hz]) + +lemma stencil_weighted_riemann {ι : Type uIndex} {k d : ℕ} (S : Finset ι) + (q : ι → ℝ) (v : ι → (Fin k → ℝ)) (C : Matrix (Fin k) (Fin k) ℝ) + (U : Matrix (Fin d) (Fin k) ℝ) + (hzero : ∑ γ ∈ S,q γ = 0) (hfirst : ∀ j,∑ γ ∈ S,q γ*v γ j = 0) + (hsecond : ∀ j l,∑ γ ∈ S,q γ*v γ j*v γ l = C j l) + {b : (Fin k → ℝ) → ℝ} (hb : ContDiff ℝ (⊤ : ℕ∞) b) + (hbc : HasCompactSupport b) : + Tendsto (fun n : ℕ => (∑' δ : Fin k → ℤ, + max (-((n:ℝ)^2*∑ γ ∈ S,q γ*b (latticeSample n δ+(-(n:ℝ)⁻¹) • v γ))) 0 * + gradientWeight U (latticeSample n δ))/(n:ℝ)^k) atTop + (𝓝 (∫ x,max (-stencilDifferential C b x) 0*gradientWeight U x)) := by + classical + let f := fun x => max (-stencilDifferential C b x) 0*gradientWeight U x + let g := fun (n : ℕ) x => max (-((n:ℝ)^2*∑ γ ∈ S,q γ*b (x+(-(n:ℝ)⁻¹) • v γ))) 0* + gradientWeight U x + have hc : Continuous f := by + have hh := stencilDifferential_continuous C hb + unfold f gradientWeight + fun_prop + have hs : Function.support f ⊆ tsupport b := by + intro x hx + by_contra h + have hd : stencilDifferential C b x = 0 := by + by_contra hh + exact h (stencilDifferential_support C b hh) + exact hx (by simp [f,hd]) + have hfc : HasCompactSupport f := HasCompactSupport.of_support_subset_isCompact hbc hs + obtain ⟨r,hr,hbr⟩ := hbc.exists_pos_le_norm + let V := ∑ γ ∈ S,‖v γ‖ + have hV : 0 ≤ V := Finset.sum_nonneg (fun _ _ => norm_nonneg _) + have hv (γ : ι) (hγ : γ ∈ S) : ‖v γ‖ ≤ V := Finset.single_le_sum (fun _ _ => norm_nonneg _) hγ + let R := r+V+1 + have hR : 0 < R := by dsimp [R]; linarith + have hfr : Function.support f ⊆ Metric.closedBall 0 R := by + intro x hx + rw [Metric.mem_closedBall,dist_zero_right] + by_contra h + have hxr : r < ‖x‖ := by dsimp [R] at h; linarith + have hnb : x ∉ tsupport b := by + apply notMem_tsupport_iff_eventuallyEq.mpr + filter_upwards [(continuous_norm.continuousAt.eventually (eventually_gt_nhds hxr))] with y hy + exact hbr y hy.le + exact hnb (hs hx) + have hgr (n : ℕ) : Function.support (g n) ⊆ Metric.closedBall 0 R := by + intro x hx + rw [Metric.mem_closedBall,dist_zero_right] + by_contra h + have hRx : R < ‖x‖ := lt_of_not_ge h + have hz : g n x = 0 := by + by_cases hn : n = 0 + · simp [g,hn] + have hn1 : (1:ℝ) ≤ n := by exact_mod_cast (Nat.one_le_iff_ne_zero.mpr hn) + have hni : |(n:ℝ)⁻¹| ≤ 1 := by rw [abs_inv,abs_of_nonneg (by positivity)]; exact inv_le_one_of_one_le₀ hn1 + have hsum : ∑ γ ∈ S,q γ*b (x+(-(n:ℝ)⁻¹) • v γ) = 0 := by + apply Finset.sum_eq_zero + intro γ hγ + have hnorm : r ≤ ‖x+(-(n:ℝ)⁻¹) • v γ‖ := by + have hshift : ‖(-(n:ℝ)⁻¹) • v γ‖ ≤ V := by + rw [norm_smul,Real.norm_eq_abs,abs_neg] + exact (mul_le_mul_of_nonneg_right hni (norm_nonneg _)).trans (by simpa using hv γ hγ) + have hx' : ‖x‖ ≤ ‖x+(-(n:ℝ)⁻¹) • v γ‖+‖(-(n:ℝ)⁻¹) • v γ‖ := by + simpa only [add_sub_cancel_left] using norm_le_norm_add_norm_sub (x+(-(n:ℝ)⁻¹) • v γ) x + dsimp [R] at hRx + linarith + rw [hbr _ hnorm,mul_zero] + dsimp only [g] + rw [hsum] + simp + exact hx hz + obtain ⟨W,hW⟩ := (isCompact_closedBall (0 : Fin k → ℝ) R).exists_bound_of_continuousOn + (show Continuous (gradientWeight U) by unfold gradientWeight; fun_prop).continuousOn + obtain ⟨K,hK,hTaylor⟩ := stencil_taylor_uniform S q v C hzero hfirst hsecond hb hbc + have hW0 : 0 ≤ W := (norm_nonneg _).trans (hW 0 (by simp [hR.le])) + apply lattice_riemann_perturb f g hc hfc hR hfr hgr (fun n => K*W/(n:ℝ)) + · exact tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop + · intro n hn x + by_cases hx : x ∈ Metric.closedBall (0 : Fin k → ℝ) R + · have hw : |gradientWeight U x| ≤ W := by simpa [Real.norm_eq_abs] using hW x hx + have hn0 : (0:ℝ) < n := by exact_mod_cast (by omega : 0 < n) + have he := hTaylor n hn0 x + have hm := abs_max_sub_max_le_abs + (-((n:ℝ)^2*∑ γ ∈ S,q γ*b (x+(-(n:ℝ)⁻¹) • v γ))) (-stencilDifferential C b x) 0 + have hm' : |max (-((n:ℝ)^2*∑ γ ∈ S,q γ*b (x+(-(n:ℝ)⁻¹) • v γ))) 0- + max (-stencilDifferential C b x) 0| ≤ K/n := by + apply hm.trans + simpa only [neg_sub_neg,abs_sub_comm] using he + dsimp [g,f] + rw [← sub_mul,abs_mul] + calc + _ ≤ (K/n)*W := mul_le_mul hm' hw (abs_nonneg _) (by positivity) + _ = _ := by ring + · have hf0 : f x = 0 := by by_contra hh; exact hx (hfr hh) + have hg0 : g n x = 0 := by by_contra hh; exact hx (hgr n hh) + rw [hf0,hg0,sub_self,abs_zero] + positivity + +end EuclideanRamsey + +namespace EuclideanRamsey +open Filter MeasureTheory +open scoped BigOperators Topology + +theorem exists_discrete_smoothing {k d : ℕ} (S : Finset (Fin k → ℤ)) + (q : (Fin k → ℤ) → ℝ) (C : Matrix (Fin k) (Fin k) ℝ) (U : Matrix (Fin d) (Fin k) ℝ) + (hzero : ∑ γ ∈ S,q γ = 0) (hfirst : ∀ j,∑ γ ∈ S,q γ*(γ j:ℝ) = 0) + (hsecond : ∀ j l,∑ γ ∈ S,q γ*(γ j:ℝ)*(γ l:ℝ) = C j l) + {b : (Fin k → ℝ) → ℝ} (hb : ContDiff ℝ (⊤ : ℕ∞) b) + (hbc : HasCompactSupport b) (hI : 0 < ∫ x,b x) + {η : ℝ} (hη : (∫ x,max (-stencilDifferential C b x) 0*gradientWeight U x) < η*∫ x,b x) : + ∃ (n : ℕ) (a : (Fin k → ℤ) → ℝ), 1 ≤ n ∧ Function.HasFiniteSupport a ∧ + 0 < (∑' γ,a γ)/(n:ℝ)^2 ∧ + (∑' δ,max (-(∑ γ ∈ S,q γ*a (δ-γ))) 0*gradientWeight U (latticeSample n δ)) < + η*((∑' γ,a γ)/(n:ℝ)^2) := by + have hZ := lattice_riemann hb.continuous hbc + have hN := stencil_weighted_riemann S q (fun γ j => (γ j:ℝ)) C U hzero hfirst hsecond hb hbc + have he := hN.eventually_lt (tendsto_const_nhds.mul hZ) hη + have hp := (tendsto_const_nhds.eventually_lt hZ hI) + obtain ⟨n,hn,hp,he⟩ := (eventually_ge_atTop 1 |>.and (hp.and he)).exists + let a := fun γ : Fin k → ℤ => b (latticeSample n γ) + have hnf : (0:ℝ) < n := by exact_mod_cast (by omega : 0 < n) + have ha : Function.HasFiniteSupport a := latticeSample_finite_support (by omega) hbc + have hshift (δ γ : Fin k → ℤ) : latticeSample n δ+(-(n:ℝ)⁻¹) • (fun j => (γ j:ℝ)) = + latticeSample n (δ-γ) := by + ext j + simp only [latticeSample,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Pi.sub_apply,Int.cast_sub] + ring + simp only [hshift] at he + have hscale (δ : Fin k → ℤ) : + max (-((n:ℝ)^2*∑ γ ∈ S,q γ*a (δ-γ))) 0*gradientWeight U (latticeSample n δ) = + (n:ℝ)^2*(max (-(∑ γ ∈ S,q γ*a (δ-γ))) 0*gradientWeight U (latticeSample n δ)) := by + rw [← mul_neg,← mul_zero ((n:ℝ)^2),← mul_max_of_nonneg _ _ (sq_nonneg (n:ℝ))] + rw [mul_assoc, mul_zero] + change (∑' δ,max (-((n:ℝ)^2*∑ γ ∈ S,q γ*a (δ-γ))) 0* + gradientWeight U (latticeSample n δ))/(n:ℝ)^k < η*((∑' γ,a γ)/(n:ℝ)^k) at he + simp only [hscale,tsum_mul_left] at he + have hp' : 0 < ∑' γ,a γ := (div_pos_iff_of_pos_right (pow_pos hnf k)).mp hp + refine ⟨n,a,hn,ha,div_pos hp' (sq_pos_of_pos hnf),?_⟩ + have hh : (n:ℝ)^2*(∑' δ,max (-(∑ γ ∈ S,q γ*a (δ-γ))) 0* + gradientWeight U (latticeSample n δ)) < η*(∑' γ,a γ) := by + apply (div_lt_div_iff_of_pos_right (pow_pos hnf k)).mp + simpa only [mul_div_assoc] using he + rw [← mul_div_assoc] + apply (lt_div_iff₀ (sq_pos_of_pos hnf)).mpr + simpa only [mul_comm] using hh + +end EuclideanRamsey + +namespace EuclideanRamsey +open scoped BigOperators + +lemma cosetPushforward_mul {k : ℕ} (Λ : AddSubgroup (Lattice k)) (ν b : LatticeRing k) + (hν : cosetPushforward Λ ν = 0) : cosetPushforward Λ (ν*b) = 0 := by + have he : AddMonoidAlgebra.mapDomain (QuotientAddGroup.mk' Λ) ν = 0 := by + apply AddMonoidAlgebra.coeff_injective + exact hν + change (AddMonoidAlgebra.mapDomain (QuotientAddGroup.mk' Λ) (ν*b)).coeff = 0 + rw [AddMonoidAlgebra.mapDomain_mul,he,zero_mul] + rfl + +theorem rational_smoothing {k d s : ℕ} (hd : 1 ≤ d) + (Λ : Fin s → AddSubgroup (Lattice k)) (ν : LatticeRing k) + (C : Matrix (Fin k) (Fin k) ℚ) (U : Matrix (Fin d) (Fin k) ℝ) + (hC : C.IsSymm) (hU : U*(C.map (Rat.cast : ℚ → ℝ))*U.transpose = (1 : Matrix (Fin d) (Fin d) ℝ)) + (hcos : ∀ i,cosetPushforward (Λ i) ν = 0) + (hzero : mass ν = 0) (hfirst : ∀ j,firstMoment ν j = 0) + (hsecond : ∀ j l,secondMoment ν j l = C j l) + (η : ℝ) (hη : 0 < η) : + ∃ (n : ℕ) (μ : LatticeRing k) (ζ : ℚ), 1 ≤ n ∧ 0 < ζ ∧ + (∀ i,cosetPushforward (Λ i) μ = 0) ∧ mass μ = 0 ∧ + (∀ j,firstMoment μ j = 0) ∧ + (∀ j l,secondMoment μ j l/(n:ℚ)^2 = ζ*C j l) ∧ + (∑' δ : Lattice k,max (-(μ.coeff δ:ℝ)) 0*gradientWeight U (latticeSample n δ)) < η*ζ := by + classical + have hC' : (C.map (Rat.cast : ℚ → ℝ)).IsSymm := by + ext j l + change (C l j:ℝ) = (C j l:ℝ) + exact congrArg Rat.cast (congrFun (congrFun hC j) l) + obtain ⟨b,hb,hbc,hb0,hbI,hbη⟩ := compact_smoothing k d hd (C.map (Rat.cast : ℚ → ℝ)) U hC' hU η hη + have hz : ∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ) = 0 := by + exact_mod_cast hzero + have hf (j : Fin k) : ∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ)*(γ j:ℝ) = 0 := by + exact_mod_cast hfirst j + have hs (j l : Fin k) : ∑ γ ∈ ν.coeff.support,(ν.coeff γ:ℝ)*(γ j:ℝ)*(γ l:ℝ) = (C j l:ℝ) := by + exact_mod_cast hsecond j l + obtain ⟨n,a,hn,ha,hap,han⟩ := exists_discrete_smoothing ν.coeff.support + (fun γ => (ν.coeff γ:ℝ)) (C.map (Rat.cast : ℚ → ℝ)) U hz hf hs hb hbc hbI hbη + obtain ⟨p,hp0,hpη⟩ := rationalize_convolution ν (fun δ => gradientWeight U (latticeSample n δ)) + ((n:ℝ)^2) η ha hap han + let ζ : ℚ := mass p/(n:ℚ)^2 + have hζ : (ζ:ℝ) = ((mass p : ℚ):ℝ)/(n:ℝ)^2 := by simp [ζ] + have hζ0 : 0 < ζ := by + have hp' : (0:ℝ) < (ζ:ℝ) := by simpa only [hζ,mass] using hp0 + exact_mod_cast hp' + refine ⟨n,ν*p,ζ,hn,hζ0,fun i => cosetPushforward_mul (Λ i) ν p (hcos i),?_,?_,?_,?_⟩ + · simp [hzero] + · intro j + simp [firstMoment_mul,hzero,hfirst] + · intro j l + simp only [secondMoment_mul,hzero,hfirst,hsecond,zero_mul,zero_add,add_zero] + dsimp [ζ] + ring + · simpa only [hζ,mass] using hpη + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/TensorDescent.lean b/lean/OAI/Combinatorics/EuclideanRamsey/TensorDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd0fda2b32715da45251fb3d0f15cf14308b8775 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/TensorDescent.lean @@ -0,0 +1,162 @@ +import OAI.Combinatorics.EuclideanRamsey.TensorNecessity + +namespace OAI + +universe uIndex + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace + +namespace EuclideanRamsey + +section Descent +variable (F : IntermediateField ℚ ℝ) {ι : Type uIndex} (b : Module.Basis ι F ℝ) + +def tensorCoordinates : (ℝ ⊗[ℚ] ℝ) ≃ₗ[ℚ] (ι × ι →₀ (F ⊗[ℚ] F)) := + (TensorProduct.congr (b.repr.restrictScalars ℚ) (b.repr.restrictScalars ℚ)).trans + (finsuppTensorFinsupp ℚ ℚ F F ι ι) + +lemma tensorCoordinates_tmul (x y : ℝ) (k : ι × ι) : + tensorCoordinates F b (x ⊗ₜ[ℚ] y) k = b.repr x k.1 ⊗ₜ[ℚ] b.repr y k.2 := by + rcases k with ⟨l, m⟩ + simp [tensorCoordinates] + +lemma tensorCoordinates_symm_single_tmul (x y : F) (k : ι × ι) : + (tensorCoordinates F b).symm (Finsupp.single k (x ⊗ₜ[ℚ] y)) = + (x • b k.1) ⊗ₜ[ℚ] (y • b k.2) := by + simp [tensorCoordinates, finsuppTensorFinsupp_symm_single] + +lemma repr_mul (x : F) (u : ℝ) : + b.repr ((x : ℝ) * u) = x • b.repr u := by + simpa only [Algebra.smul_def, IntermediateField.algebraMap_apply] using b.repr.map_smul x u + +lemma tensorCoordinates_sandwich (x y : F) (T : ℝ ⊗[ℚ] ℝ) : + tensorCoordinates F b (((x : ℝ) ⊗ₜ[ℚ] (1 : ℝ)) * T * + ((1 : ℝ) ⊗ₜ[ℚ] (y : ℝ))) = + (x ⊗ₜ[ℚ] y) • tensorCoordinates F b T := by + ext k + induction T using TensorProduct.inductionOn with + | tmul u v => + simp only [Algebra.TensorProduct.tmul_mul_tmul, one_mul, mul_one, + tensorCoordinates_tmul, Finsupp.smul_apply, smul_eq_mul] + rw [repr_mul, mul_comm v (y : ℝ), repr_mul] + simp only [Finsupp.smul_apply, smul_eq_mul] + | add U V hU hV => + simpa only [mul_add, add_mul, map_add, Finsupp.add_apply, smul_add, + Finsupp.smul_apply] using congrArg₂ (· + ·) hU hV + +variable (φ : ℝ →ₗ[F] F) + +local instance tensorRing : CommRing (F ⊗[ℚ] F) := inferInstance + +def coefficientTrace : (ι × ι →₀ (F ⊗[ℚ] F)) →ₗ[(F ⊗[ℚ] F)] (F ⊗[ℚ] F) := + Finsupp.linearCombination (F ⊗[ℚ] F) (fun k => φ (b k.1 * b k.2) ⊗ₜ[ℚ] (1 : F)) + +def tensorDescent : (ℝ ⊗[ℚ] ℝ) →ₗ[ℚ] (F ⊗[ℚ] F) := + ((coefficientTrace F b φ).restrictScalars ℚ).comp (tensorCoordinates F b).toLinearMap + +lemma tensorDescent_sandwich (x y : F) (T : ℝ ⊗[ℚ] ℝ) : + tensorDescent F b φ (((x : ℝ) ⊗ₜ[ℚ] (1 : ℝ)) * T * + ((1 : ℝ) ⊗ₜ[ℚ] (y : ℝ))) = + (x ⊗ₜ[ℚ] (1 : F)) * tensorDescent F b φ T * ((1 : F) ⊗ₜ[ℚ] y) := by + change coefficientTrace F b φ (tensorCoordinates F b _) = _ + rw [tensorCoordinates_sandwich, map_smul] + change (x ⊗ₜ[ℚ] y) * tensorDescent F b φ T = _ + rw [mul_right_comm, Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul] + +lemma coefficientTrace_multiply (z : ι × ι →₀ (F ⊗[ℚ] F)) : + Algebra.TensorProduct.lmul' ℚ (coefficientTrace F b φ z) = + φ (Algebra.TensorProduct.lmul' ℚ ((tensorCoordinates F b).symm z)) := by + induction z using Finsupp.induction_linear with + | zero => simp + | add z w hz hw => simp only [map_add, hz, hw] + | single k z => + induction z using TensorProduct.inductionOn with + | add z w hz hw => simp only [Finsupp.single_add, map_add, hz, hw] + | tmul x y => + simp only [coefficientTrace, Finsupp.linearCombination_single, smul_eq_mul, + map_mul, Algebra.TensorProduct.lmul'_apply_tmul, mul_one, + tensorCoordinates_symm_single_tmul] + have hmul : (x • b k.1) * (y • b k.2) = (x * y) • (b k.1 * b k.2) := by + simp only [Algebra.smul_def, map_mul] + ring + rw [hmul, map_smul, smul_eq_mul] + +lemma tensorDescent_multiply (T : ℝ ⊗[ℚ] ℝ) : + Algebra.TensorProduct.lmul' ℚ (tensorDescent F b φ T) = + φ (Algebra.TensorProduct.lmul' ℚ T) := by + change Algebra.TensorProduct.lmul' ℚ (coefficientTrace F b φ (tensorCoordinates F b T)) = _ + rw [coefficientTrace_multiply, LinearEquiv.symm_apply_apply] + +end Descent + +theorem realCriterion_fieldCriterion {s d : ℕ} (a : Fin s → Space d) + (h : RealCriterion a) : FieldCriterion a := by + classical + let F := coordinateField a + let b := Module.Free.chooseBasis F ℝ + obtain ⟨φ, hφ⟩ := Module.Projective.exists_dual_eq_one F (one_ne_zero : (1 : ℝ) ≠ 0) + let δ := tensorDescent F b φ + obtain ⟨P, he, hm⟩ := h + refine ⟨fun α β => δ (P α β), ?_, ?_⟩ + · intro i + have haug (α : Option (Fin d)) : ((augmented a i α : F) : ℝ) = realAugmented a i α := by + cases α <;> rfl + have hd := congrArg δ (he i) + change δ (∑ α, ∑ β, (realAugmented a i α ⊗ₜ[ℚ] (1 : ℝ)) * P α β * + ((1 : ℝ) ⊗ₜ[ℚ] realAugmented a i β)) = δ 0 at hd + simp only [map_sum, map_zero] at hd + simpa only [δ, ← haug, tensorDescent_sandwich] using hd + · intro α β + change Algebra.TensorProduct.lmul' ℚ (tensorDescent F b φ (P (some α) (some β))) = _ + rw [tensorDescent_multiply] + have hab := congrFun (congrFun hm α) β + change Algebra.TensorProduct.lmul' ℚ (P (some α) (some β)) = _ at hab + rw [hab] + by_cases heq : α = β + · simp only [Matrix.one_apply, heq, ite_true, hφ] + · simp only [Matrix.one_apply, heq, ite_false, map_zero] + +theorem ramsey_fieldCriterion {s d : ℕ} (a : Fin s → Space d) + (hs : 0 < s) (hspan : affineSpan ℝ (Set.range a) = ⊤) + (hR : Ramsey a) : FieldCriterion a := + realCriterion_fieldCriterion a (ramsey_realCriterion a hs hspan hR) + +end EuclideanRamsey + +namespace EuclideanRamsey +open scoped TensorProduct BigOperators + +theorem fieldCriterion_realCriterion {s d : ℕ} (a : Fin s → Space d) + (h : FieldCriterion a) : RealCriterion a := by + classical + obtain ⟨P,hP,hG⟩ := h + let φ : TensorRing a →ₐ[ℚ] RealTensor := + Algebra.TensorProduct.map (coordinateField a).val (coordinateField a).val + have haug (i : Fin s) (α : Option (Fin d)) : + ((augmented a i α : Coeff a) : ℝ) = realAugmented a i α := by + cases α <;> rfl + have hmul (T : TensorRing a) : + Algebra.TensorProduct.lmul' ℚ (φ T) = (multiply a T : ℝ) := by + induction T using TensorProduct.inductionOn with + | tmul x y => rfl + | add x y hx hy => simp [hx,hy] + refine ⟨fun α β => φ (P α β),?_,?_⟩ + · intro i + have hh := congrArg φ (hP i) + have hφ (x y : Coeff a) : φ (x ⊗ₜ[ℚ] y) = (x:ℝ) ⊗ₜ[ℚ] (y:ℝ) := rfl + change (∑ α,∑ β,(realAugmented a i α ⊗ₜ[ℚ] (1:ℝ))*φ (P α β)* + ((1:ℝ) ⊗ₜ[ℚ] realAugmented a i β)) = 0 + simpa only [map_sum,map_mul,map_zero,hφ,haug,OneMemClass.coe_one] using hh + · ext α β + change Algebra.TensorProduct.lmul' ℚ (φ (P (some α) (some β))) = _ + rw [hmul,hG] + simp only [Matrix.one_apply] + split_ifs <;> rfl + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/TensorNecessity.lean b/lean/OAI/Combinatorics/EuclideanRamsey/TensorNecessity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1425f0b6786db629ff80f0ea2763d79f88ee3a45 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/TensorNecessity.lean @@ -0,0 +1,262 @@ +import OAI.Combinatorics.EuclideanRamsey.Congruence + +namespace OAI + +universe uPoint + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace + +namespace EuclideanRamsey + +private theorem sum_floor_bounds {s : ℕ} (hs : 0 < s) (f : Fin s → ℝ) : + (∑ i, f i) - s < ((∑ i, ⌊f i⌋ : ℤ) : ℝ) ∧ + ((∑ i, ⌊f i⌋ : ℤ) : ℝ) ≤ ∑ i, f i := by + have hu : (Finset.univ : Finset (Fin s)).Nonempty := ⟨⟨0, hs⟩, Finset.mem_univ _⟩ + have hlt := Finset.sum_lt_sum_of_nonempty hu (fun i _ => Int.lt_floor_add_one (f i)) + have hle := Finset.sum_le_sum (s := Finset.univ) (fun i _ => Int.floor_le (f i)) + simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + nsmul_eq_mul, mul_one] at hlt + constructor + · push_cast + linarith + · simpa only [Int.cast_sum] using hle + +theorem floor_coloring_obstruction {X : Type uPoint} {s : ℕ} (hs : 0 < s) + (H : Fin s → X → ℝ) (hcancel : ∀ z, ∑ i, H i z = 0) + (b : Fin s → X) + (hmono : ∀ i, (fun j : Fin s => + (⌊((2 * s + 1 : ℕ) : ℝ) / 2 * H j (b i)⌋ : ZMod (2 * s + 1))) = + (fun j : Fin s => + (⌊((2 * s + 1 : ℕ) : ℝ) / 2 * H j (b ⟨0, hs⟩)⌋ : ZMod (2 * s + 1)))) : + ∑ i, H i (b i) ≠ -1 := by + intro hsum + let K : ℕ := 2 * s + 1 + let x : Fin s → ℝ := fun i => (K : ℝ) / 2 * H i (b i) + let y : Fin s → ℝ := fun i => (K : ℝ) / 2 * H i (b ⟨0, hs⟩) + have hx : ∑ i, x i = -(K : ℝ) / 2 := by + simp [x, ← Finset.mul_sum, hsum]; ring + have hy : ∑ i, y i = 0 := by + simp [y, ← Finset.mul_sum, hcancel] + let A : ℤ := ∑ i, ⌊x i⌋ + let B : ℤ := ∑ i, ⌊y i⌋ + have hAB : (A : ZMod K) = (B : ZMod K) := by + simp only [A, B, Int.cast_sum] + apply Finset.sum_congr rfl + intro i _ + exact congrFun (hmono i) i + have hdvd : (K : ℤ) ∣ B - A := (ZMod.intCast_eq_intCast_iff_dvd_sub A B K).mp hAB + obtain ⟨hxlo, hxhi⟩ := sum_floor_bounds hs x + obtain ⟨hylo, hyhi⟩ := sum_floor_bounds hs y + change (∑ i, x i) - s < (A : ℝ) at hxlo + change (A : ℝ) ≤ ∑ i, x i at hxhi + change (∑ i, y i) - s < (B : ℝ) at hylo + change (B : ℝ) ≤ ∑ i, y i at hyhi + rw [hx] at hxlo hxhi + rw [hy] at hylo hyhi + have hK : (K : ℝ) = 2 * (s : ℝ) + 1 := by simp [K] + have hpos : (0 : ℤ) < B - A := by + have : (0 : ℝ) < (B : ℝ) - (A : ℝ) := by linarith + exact_mod_cast this + have hlt : B - A < (K : ℤ) := by + have : (B : ℝ) - (A : ℝ) < (K : ℝ) := by linarith + exact_mod_cast this + exact (not_le_of_gt hlt) (Int.le_of_dvd hpos hdvd) + +abbrev RealTensor := ℝ ⊗[ℚ] ℝ +abbrev RealArray (d : ℕ) := Matrix (Option (Fin d)) (Option (Fin d)) RealTensor +abbrev SeparationSpace (s d : ℕ) := (Fin s → RealTensor) × Matrix (Fin d) (Fin d) ℝ + +def realAugmented {s d : ℕ} (a : Fin s → Space d) (i : Fin s) : Option (Fin d) → ℝ + | none => 1 + | some j => a i j + +def arrayEvaluation {s d : ℕ} (a : Fin s → Space d) (i : Fin s) : + RealArray d →ₗ[ℚ] RealTensor where + toFun P := ∑ α, ∑ β, ((realAugmented a i α) ⊗ₜ[ℚ] (1 : ℝ)) * P α β * + ((1 : ℝ) ⊗ₜ[ℚ] (realAugmented a i β)) + map_add' P Q := by + simp only [Matrix.add_apply, mul_add, add_mul, Finset.sum_add_distrib] + map_smul' q P := by + simp only [Matrix.smul_apply, RingHom.id_apply, mul_smul_comm, smul_mul_assoc, + Finset.smul_sum] + +def spatialMultiply {d : ℕ} : RealArray d →ₗ[ℚ] Matrix (Fin d) (Fin d) ℝ where + toFun P := fun α β => Algebra.TensorProduct.lmul' ℚ (P (some α) (some β)) + map_add' P Q := by + ext α β + exact map_add (Algebra.TensorProduct.lmul' ℚ) _ _ + map_smul' q P := by + ext α β + exact (Algebra.TensorProduct.lmul' ℚ).toLinearMap.map_smul q _ + +def arrayMap {s d : ℕ} (a : Fin s → Space d) : + RealArray d →ₗ[ℚ] SeparationSpace s d := + (LinearMap.pi (arrayEvaluation a)).prod spatialMultiply + +def RealCriterion {s d : ℕ} (a : Fin s → Space d) : Prop := + ∃ P : RealArray d, (∀ i, arrayEvaluation a i P = 0) ∧ spatialMultiply P = 1 + +theorem separate_arrayMap {s d : ℕ} (a : Fin s → Space d) (h : ¬ RealCriterion a) : + ∃ ℓ : SeparationSpace s d →ₗ[ℚ] ℝ, + (∀ P, ℓ (arrayMap a P) = 0) ∧ ℓ (0, 1) = 1 := by + let N := LinearMap.range (arrayMap a) + have hy : (0, 1) ∉ N := by + rintro ⟨P, hP⟩ + apply h + refine ⟨P, ?_, ?_⟩ + · intro i + exact congrFun (congrArg Prod.fst hP) i + · exact congrArg Prod.snd hP + have hq : N.mkQ (0, 1) ≠ 0 := by + intro hz + exact hy ((Submodule.Quotient.mk_eq_zero N).mp hz) + obtain ⟨f, hf⟩ := Module.Projective.exists_dual_eq_one ℚ hq + let ℓ : SeparationSpace s d →ₗ[ℚ] ℝ := + (Algebra.linearMap ℚ ℝ).comp (f.comp N.mkQ) + refine ⟨ℓ, ?_, ?_⟩ + · intro P + have hp : N.mkQ (arrayMap a P) = 0 := by + apply (Submodule.Quotient.mk_eq_zero N).mpr + exact ⟨P, rfl⟩ + simp [ℓ, hp] + · change ((f (N.mkQ (0, 1)) : ℚ) : ℝ) = 1 + rw [hf] + norm_num + +def diagonalArray {d : ℕ} (v : ℝ) (u : Space d) : RealArray d := + let w : Option (Fin d) → ℝ := fun α => α.elim v (u ·) + fun α β => w α ⊗ₜ[ℚ] w β + +def gradientRankOne {d : ℕ} (u : Space d) : Matrix (Fin d) (Fin d) ℝ := + fun α β => u α * u β + +def affineEvaluation {s d : ℕ} (a : Fin s → Space d) (i : Fin s) + (v : ℝ) (u : Space d) : ℝ := v + ∑ j, a i j * u j + +lemma arrayEvaluation_diagonal {s d : ℕ} (a : Fin s → Space d) (i : Fin s) + (v : ℝ) (u : Space d) : + arrayEvaluation a i (diagonalArray v u) = + affineEvaluation a i v u ⊗ₜ[ℚ] affineEvaluation a i v u := by + let w : Option (Fin d) → ℝ := fun α => α.elim v (u ·) + have he : affineEvaluation a i v u = ∑ α, realAugmented a i α * w α := by + simp [affineEvaluation, realAugmented, w, Fintype.sum_option] + rw [he, TensorProduct.sum_tmul] + simp only [TensorProduct.tmul_sum] + change (∑ α, ∑ β, (realAugmented a i α ⊗ₜ[ℚ] (1 : ℝ)) * + (w α ⊗ₜ[ℚ] w β) * ((1 : ℝ) ⊗ₜ[ℚ] realAugmented a i β)) = _ + simp only [Algebra.TensorProduct.tmul_mul_tmul, one_mul, mul_comm] + +lemma spatialMultiply_diagonal {d : ℕ} (v : ℝ) (u : Space d) : + spatialMultiply (diagonalArray v u) = gradientRankOne u := by + ext α β + change (Algebra.TensorProduct.lmul' ℚ) (u α ⊗ₜ[ℚ] u β) = u α * u β + simp + +theorem exists_separated_functions {s d : ℕ} (a : Fin s → Space d) + (h : ¬ RealCriterion a) : + ∃ f : Fin s → ℝ → ℝ, ∃ L : Matrix (Fin d) (Fin d) ℝ →ₗ[ℚ] ℝ, + L 1 = 1 ∧ + (∀ v u, (∑ i, f i (affineEvaluation a i v u)) + L (gradientRankOne u) = 0) ∧ + ∀ x, ∑ i, f i x = 0 := by + classical + obtain ⟨ℓ, hℓ, hℓ₀⟩ := separate_arrayMap a h + let f : Fin s → ℝ → ℝ := fun i x => ℓ (Pi.single i (x ⊗ₜ[ℚ] x), 0) + let L : Matrix (Fin d) (Fin d) ℝ →ₗ[ℚ] ℝ := ℓ.comp (LinearMap.inr ℚ _ _) + have hsplit (x : Fin s → RealTensor) (M : Matrix (Fin d) (Fin d) ℝ) : + ℓ (x, M) = (∑ i, ℓ (Pi.single i (x i), 0)) + L M := by + change ℓ (x, M) = (∑ i, ℓ (Pi.single i (x i), 0)) + ℓ (0, M) + rw [← map_sum, ← map_add] + congr 1 + ext <;> simp [Prod.fst_sum, Prod.snd_sum, Finset.sum_apply] + have heq (v : ℝ) (u : Space d) : + (∑ i, f i (affineEvaluation a i v u)) + L (gradientRankOne u) = 0 := by + have hp := hℓ (diagonalArray v u) + change ℓ ((fun i => arrayEvaluation a i (diagonalArray v u)), + spatialMultiply (diagonalArray v u)) = 0 at hp + simp only [arrayEvaluation_diagonal, spatialMultiply_diagonal] at hp + rw [hsplit] at hp + exact hp + refine ⟨f, L, hℓ₀, heq, ?_⟩ + intro x + have hz : gradientRankOne (0 : Space d) = 0 := by ext; simp [gradientRankOne] + simpa [affineEvaluation, hz] using heq x (0 : Space d) + +def isometryRows {d D : ℕ} (Q : Space d →ₗᵢ[ℝ] Space D) (j : Fin D) : Space d := + WithLp.toLp 2 (fun α => Q (EuclideanSpace.single α 1) j) + +lemma isometryRows_apply {d D : ℕ} (Q : Space d →ₗᵢ[ℝ] Space D) + (x : Space d) (j : Fin D) : + Q x j = ∑ α, x α * isometryRows Q j α := by + have hx := (EuclideanSpace.basisFun (Fin d) ℝ).sum_repr x + have hv := congrArg (fun z : Space d => Q z j) hx + simpa only [map_sum, map_smul, EuclideanSpace.basisFun_repr, + EuclideanSpace.basisFun_apply, WithLp.ofLp_sum, Finset.sum_apply, PiLp.smul_apply, smul_eq_mul, + isometryRows, WithLp.ofLp_toLp] using hv.symm + +lemma isometryRows_gram {d D : ℕ} (Q : Space d →ₗᵢ[ℝ] Space D) + (α β : Fin d) : + ∑ j, isometryRows Q j α * isometryRows Q j β = if α = β then 1 else 0 := by + have h := Q.inner_map_map (EuclideanSpace.single β 1) (EuclideanSpace.single α 1) + rw [EuclideanSpace.inner_single_left] at h + simpa only [PiLp.inner_apply, RCLike.inner_apply, conj_trivial, map_one, one_mul, + PiLp.single_apply, eq_comm, isometryRows, WithLp.ofLp_toLp] using h + +theorem separated_copy_sum {s d D : ℕ} (a : Fin s → Space d) + (f : Fin s → ℝ → ℝ) (L : Matrix (Fin d) (Fin d) ℝ →ₗ[ℚ] ℝ) + (hL : L 1 = 1) + (heq : ∀ v u, (∑ i, f i (affineEvaluation a i v u)) + L (gradientRankOne u) = 0) + (Q : Space d →ₗᵢ[ℝ] Space D) (t : Space D) : + ∑ i, ∑ j, f i ((t + Q (a i)) j) = -1 := by + have hrows : (∑ j, gradientRankOne (isometryRows Q j)) = (1 : Matrix (Fin d) (Fin d) ℝ) := by + ext α β + simp only [Matrix.sum_apply, gradientRankOne, Matrix.one_apply, isometryRows_gram] + have heach (j : Fin D) : + (∑ i, f i ((t + Q (a i)) j)) = -L (gradientRankOne (isometryRows Q j)) := by + have h := heq (t j) (isometryRows Q j) + apply eq_neg_of_add_eq_zero_left + convert h using 2 + apply Finset.sum_congr rfl + intro i _ + congr 1 + simp only [PiLp.add_apply, affineEvaluation, isometryRows_apply] + rw [Finset.sum_comm] + simp only [heach, Finset.sum_neg_distrib, ← map_sum, hrows, hL] + +theorem ramsey_realCriterion {s d : ℕ} (a : Fin s → Space d) + (hs : 0 < s) (hspan : affineSpan ℝ (Set.range a) = ⊤) + (hR : Ramsey a) : RealCriterion a := by + classical + by_contra h + obtain ⟨f, L, hL, heq, hcancel⟩ := exists_separated_functions a h + let K := 2 * s + 1 + let Colors := Fin s → ZMod K + have hK : 1 < K := by dsimp [K]; omega + have hr : 2 ≤ Fintype.card Colors := by + change 2 ≤ Fintype.card (Fin s → ZMod K) + simp only [Fintype.card_fun, ZMod.card, Fintype.card_fin] + exact Nat.one_lt_pow (by omega) hK + obtain ⟨D, hD, hD'⟩ := hR (Fintype.card Colors) hr + let H : Fin s → Space D → ℝ := fun i z => ∑ j, f i (z j) + have hH (z : Space D) : ∑ i, H i z = 0 := by + simp only [H] + rw [Finset.sum_comm] + simp only [hcancel, Finset.sum_const_zero] + let color : Space D → Colors := fun z i => (⌊(K : ℝ) / 2 * H i z⌋ : ZMod K) + obtain ⟨b, hb, k, hk⟩ := hD' (fun z => Fintype.equivFin Colors (color z)) + have hmono : ∀ i, color (b i) = color (b ⟨0, hs⟩) := by + intro i + apply (Fintype.equivFin Colors).injective + exact (hk i).trans (hk ⟨0, hs⟩).symm + have hnot := floor_coloring_obstruction hs H hH b hmono + apply hnot + obtain ⟨Q, t, hQ⟩ := congruent_linearIsometry a b ⟨0, hs⟩ hspan hb + simp only [H, hQ] + exact separated_copy_sum a f L hL heq Q t + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/TensorPresentation.lean b/lean/OAI/Combinatorics/EuclideanRamsey/TensorPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5069d6510bc61666427b0da8ce64b913c901b77 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/TensorPresentation.lean @@ -0,0 +1,261 @@ +import OAI.Combinatorics.EuclideanRamsey.AdicLifting + +namespace OAI + +universe uVector + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology + +open scoped TensorProduct RealInnerProductSpace +namespace EuclideanRamsey + +end EuclideanRamsey +namespace EuclideanRamsey +open scoped TensorProduct BigOperators + +abbrev AffineVector (d : ℕ) := Option (Fin d) → ℝ + +def affineArray {d : ℕ} : + (AffineVector d ⊗[ℚ] AffineVector d) ≃ₗ[ℚ] RealArray d := + (TensorProduct.piLeft ℚ (AffineVector d) (fun _ : Option (Fin d) => ℝ)).trans + (LinearEquiv.piCongrRight (fun _ => TensorProduct.piRight ℚ ℚ ℝ (fun _ : Option (Fin d) => ℝ))) + +@[simp] lemma affineArray_tmul {d : ℕ} (w z : AffineVector d) (α β : Option (Fin d)) : + affineArray (w ⊗ₜ[ℚ] z) α β = w α ⊗ₜ[ℚ] z β := by + rfl + +def rowEvaluation {s d : ℕ} (a : Fin s → Space d) (i : Fin s) : AffineVector d →ₗ[ℚ] ℝ where + toFun w := ∑ α,realAugmented a i α * w α + map_add' x y := by simp [mul_add,Finset.sum_add_distrib] + map_smul' q x := by + simp only [Pi.smul_apply,RingHom.id_apply,Rat.smul_def,mul_left_comm,Finset.mul_sum] + +lemma arrayEvaluation_affineArray {s d : ℕ} (a : Fin s → Space d) (i : Fin s) + (T : AffineVector d ⊗[ℚ] AffineVector d) : + arrayEvaluation a i (affineArray T) = TensorProduct.map (rowEvaluation a i) (rowEvaluation a i) T := by + induction T using TensorProduct.inductionOn with + | tmul w z => + simp only [arrayEvaluation,LinearMap.coe_mk,AddHom.coe_mk,affineArray_tmul, + Algebra.TensorProduct.tmul_mul_tmul,one_mul,mul_one,TensorProduct.map_tmul, + rowEvaluation,TensorProduct.sum_tmul,TensorProduct.tmul_sum] + rw [Finset.sum_comm] + simp only [mul_comm] + | add x y hx hy => simp [hx,hy] + +lemma spatialMultiply_affineArray {d : ℕ} (T : AffineVector d ⊗[ℚ] AffineVector d) (α β : Fin d) : + spatialMultiply (affineArray T) α β = + Algebra.TensorProduct.lmul' ℚ + (TensorProduct.map (LinearMap.proj (some α)) (LinearMap.proj (some β)) T) := by + induction T using TensorProduct.inductionOn with + | tmul w z => + change Algebra.TensorProduct.lmul' ℚ (affineArray (w ⊗ₜ[ℚ] z) (some α) (some β)) = _ + rw [affineArray_tmul] + rfl + | add x y hx hy => simp [hx,hy] + +lemma affineArray_comm {d : ℕ} (T : AffineVector d ⊗[ℚ] AffineVector d) (α β : Option (Fin d)) : + affineArray (TensorProduct.comm ℚ _ _ T) α β = TensorProduct.comm ℚ ℝ ℝ (affineArray T β α) := by + induction T using TensorProduct.inductionOn with + | tmul w z => simp + | add x y hx hy => simp [hx,hy] + +lemma arrayEvaluation_comm {s d : ℕ} (a : Fin s → Space d) (i : Fin s) + (T : AffineVector d ⊗[ℚ] AffineVector d) : + arrayEvaluation a i (affineArray (TensorProduct.comm ℚ _ _ T)) = + TensorProduct.comm ℚ ℝ ℝ (arrayEvaluation a i (affineArray T)) := by + simp only [arrayEvaluation_affineArray] + induction T using TensorProduct.inductionOn with + | tmul w z => simp + | add x y hx hy => simp [hx,hy] + +lemma spatialMultiply_comm {d : ℕ} (T : AffineVector d ⊗[ℚ] AffineVector d) : + spatialMultiply (affineArray (TensorProduct.comm ℚ _ _ T)) = + (spatialMultiply (affineArray T)).transpose := by + ext α β + change Algebra.TensorProduct.lmul' ℚ (affineArray (TensorProduct.comm ℚ _ _ T) (some α) (some β)) = + Algebra.TensorProduct.lmul' ℚ (affineArray T (some β) (some α)) + rw [affineArray_comm] + generalize affineArray T (some β) (some α) = z + induction z using TensorProduct.inductionOn with + | tmul x y => simp [mul_comm] + | add x y hx hy => simp [hx,hy] + +end EuclideanRamsey + +open scoped TensorProduct BigOperators +namespace EuclideanRamsey + +theorem exists_symmetric_tensor_presentation {W : Type uVector} [AddCommGroup W] [Module ℚ W] + (T : W ⊗[ℚ] W) : + ∃ (k : ℕ) (w : Fin k → W) (C : Matrix (Fin k) (Fin k) ℚ), C.IsSymm ∧ + (∑ j,∑ l,C j l • (w j ⊗ₜ[ℚ] w l)) = + (1/2:ℚ) • (T + TensorProduct.comm ℚ W W T) := by + classical + obtain ⟨S,hS⟩ := TensorProduct.exists_finset T + let w : (↥S ⊕ ↥S) → W := Sum.elim (fun z : ↥S => z.val.1) (fun z : ↥S => z.val.2) + let C : (↥S ⊕ ↥S) → (↥S ⊕ ↥S) → ℚ := fun j l => match j,l with + | .inl i,.inr j => if i=j then 1/2 else 0 + | .inr i,.inl j => if i=j then 1/2 else 0 + | _,_ => 0 + have hC : Matrix.IsSymm C := by + ext j l + change C l j = C j l + cases j <;> cases l <;> dsimp only [C] + all_goals simp only [eq_comm] + have hs : (∑ j,∑ l,C j l • (w j ⊗ₜ[ℚ] w l)) = + (1/2:ℚ) • (T + TensorProduct.comm ℚ W W T) := by + simp only [Fintype.sum_sum_type,C,w,zero_smul,Finset.sum_const_zero,zero_add,add_zero, + ite_smul,Sum.elim_inl,Sum.elim_inr,Finset.sum_ite_eq,Finset.mem_univ,ite_true] + rw [hS] + simp only [map_sum,TensorProduct.comm_tmul,smul_add,Finset.smul_sum] + rw [Finset.sum_subtype S (p := fun z => z ∈ S) (F := inferInstance) (fun _ => Iff.rfl) (fun z => (1/2:ℚ) • (z.1 ⊗ₜ[ℚ] z.2)), + Finset.sum_subtype S (p := fun z => z ∈ S) (F := inferInstance) (fun _ => Iff.rfl) (fun z => (1/2:ℚ) • (z.2 ⊗ₜ[ℚ] z.1))] + let e := Fintype.equivFin (↥S ⊕ ↥S) + refine ⟨Fintype.card (↥S ⊕ ↥S), fun j => w (e.symm j), fun j l => C (e.symm j) (e.symm l),?_,?_⟩ + · ext j l + exact congrFun (congrFun hC (e.symm j)) (e.symm l) + · change (∑ j,∑ l,C (e.symm j) (e.symm l) • (w (e.symm j) ⊗ₜ[ℚ] w (e.symm l))) = _ + calc + _ = ∑ j : Fin (Fintype.card (↥S ⊕ ↥S)),∑ l : ↥S ⊕ ↥S, + C (e.symm j) l • (w (e.symm j) ⊗ₜ[ℚ] w l) := by + apply Finset.sum_congr rfl + intro j _ + exact Equiv.sum_comp e.symm (fun l => C (e.symm j) l • (w (e.symm j) ⊗ₜ[ℚ] w l)) + _ = _ := (Equiv.sum_comp e.symm (fun j => ∑ l,C j l • (w j ⊗ₜ[ℚ] w l))).trans hs + +end EuclideanRamsey + +open scoped TensorProduct +namespace EuclideanRamsey + +end EuclideanRamsey +namespace EuclideanRamsey +open scoped TensorProduct + +lemma rational_lattice_kernel {k : ℕ} (f : RationalSpace k →ₗ[ℚ] ℝ) : + latticeSpan (AddMonoidHom.ker (f.toAddMonoidHom.comp rationalize)) = f.ker := by + classical + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨γ,hγ,rfl⟩ + exact hγ + · intro x hx + let A : Matrix Unit (Fin k) ℚ := fun _ j => x j + let γ : Lattice k := fun j => A.num () j + have hden : (A.den:ℚ) ≠ 0 := by exact_mod_cast A.den_ne_zero + have he : (rationalize γ : RationalSpace k) = (A.den:ℚ) • x := by + ext j + have hm := A.num_div_den () j + change (A.num () j:ℚ)/(A.den:ℚ) = x j at hm + change (A.num () j:ℚ) = (A.den:ℚ)*x j + exact ((div_eq_iff hden).mp hm).trans (mul_comm _ _) + have hγ : γ ∈ AddMonoidHom.ker (f.toAddMonoidHom.comp rationalize) := by + change f (rationalize γ) = 0 + rw [he,map_smul] + exact smul_eq_zero_of_right _ hx + have hm : rationalize γ ∈ latticeSpan (AddMonoidHom.ker (f.toAddMonoidHom.comp rationalize)) := + Submodule.subset_span ⟨γ,hγ,rfl⟩ + have := Submodule.smul_mem (latticeSpan (AddMonoidHom.ker (f.toAddMonoidHom.comp rationalize))) + (A.den:ℚ)⁻¹ hm + simpa only [he,smul_smul,inv_mul_cancel₀ hden,one_smul] using this + +lemma quotientTensor_zero_of_evaluation {k : ℕ} (f : RationalSpace k →ₗ[ℚ] ℝ) + (T : RationalSpace k ⊗[ℚ] RationalSpace k) (hT : TensorProduct.map f f T = 0) : + quotientTensor (AddMonoidHom.ker (f.toAddMonoidHom.comp rationalize)) T = 0 := by + classical + change TensorProduct.map _ _ T = 0 + rw [rational_lattice_kernel] + let e := f.quotKerEquivRange + let j : (RationalSpace k ⧸ f.ker) →ₗ[ℚ] ℝ := f.range.subtype.comp e.toLinearMap + have hj : Function.Injective j := f.range.subtype_injective.comp e.injective + obtain ⟨r,hr⟩ := j.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hj) + have hpre : j.comp f.ker.mkQ = f := by + ext x + rfl + have htmp : TensorProduct.map j j (TensorProduct.map f.ker.mkQ f.ker.mkQ T) = 0 := by + rw [← LinearMap.comp_apply,← TensorProduct.map_comp,hpre,hT] + have hback := congrArg (TensorProduct.map r r) htmp + simpa only [map_zero,← LinearMap.comp_apply,← TensorProduct.map_comp,← LinearMap.comp_assoc,hr,LinearMap.id_comp,TensorProduct.map_id, + LinearMap.id_apply] using hback + +end EuclideanRamsey + +namespace EuclideanRamsey +open scoped TensorProduct BigOperators + +lemma matrixTensor_map_family {k : ℕ} {W : Type uVector} [AddCommGroup W] [Module ℚ W] + (w : Fin k → W) (C : Matrix (Fin k) (Fin k) ℚ) : + TensorProduct.map (Fintype.linearCombination ℚ w) (Fintype.linearCombination ℚ w) (matrixTensor C) = + ∑ j,∑ l,C j l • (w j ⊗ₜ[ℚ] w l) := by + simp [matrixTensor,Fintype.linearCombination_apply,TensorProduct.map_tmul] + +lemma spatialMultiply_family {k d : ℕ} (w : Fin k → AffineVector d) + (C : Matrix (Fin k) (Fin k) ℚ) : + spatialMultiply (affineArray (∑ j,∑ l,C j l • (w j ⊗ₜ[ℚ] w l))) = + (show Matrix (Fin d) (Fin k) ℝ from fun α j => w j (some α)) * (C.map (Rat.cast : ℚ → ℝ)) * + (show Matrix (Fin d) (Fin k) ℝ from fun α j => w j (some α)).transpose := by + ext α β + simp only [map_sum,map_smul,Matrix.sum_apply,Matrix.smul_apply,spatialMultiply, + LinearMap.coe_mk] + change (∑ j, ∑ l, (C j l:ℝ)*(w j (some α)*w l (some β))) = _ + change _ = ∑ l, (∑ j, w j (some α) * (C j l : ℝ)) * w l (some β) + simp only [Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro l _ + apply Finset.sum_congr rfl + intro j _ + ring + +theorem realCriterion_lattice {s d : ℕ} (a : Fin s → Space d) (hd : 1 ≤ d) + (h : RealCriterion a) : + ∃ (k : ℕ) (w : Fin k → AffineVector d) (C : Matrix (Fin k) (Fin k) ℚ), + 1 ≤ k ∧ C.IsSymm ∧ + (show Matrix (Fin d) (Fin k) ℝ from fun α j => w j (some α)) * (C.map (Rat.cast : ℚ → ℝ)) * + (show Matrix (Fin d) (Fin k) ℝ from fun α j => w j (some α)).transpose = (1 : Matrix (Fin d) (Fin d) ℝ) ∧ + ∀ i,quotientTensor + (AddMonoidHom.ker (((rowEvaluation a i).comp (Fintype.linearCombination ℚ w)).toAddMonoidHom.comp rationalize)) + (matrixTensor C) = 0 := by + classical + obtain ⟨P,hP,hG⟩ := h + let T : AffineVector d ⊗[ℚ] AffineVector d := affineArray.symm P + have hT : affineArray T = P := affineArray.apply_symm_apply P + obtain ⟨k,w,C,hC,hrep⟩ := exists_symmetric_tensor_presentation T + have hs : spatialMultiply (affineArray (∑ j,∑ l,C j l • (w j ⊗ₜ[ℚ] w l))) = 1 := by + rw [hrep,map_smul,map_add,map_smul,map_add,spatialMultiply_comm,hT,hG] + ext α β + simp only [Matrix.smul_apply,Matrix.add_apply,Matrix.transpose_apply,Matrix.one_apply] + by_cases hh : α = β <;> norm_num [hh,eq_comm,Rat.smul_def] + have hU := (spatialMultiply_family w C).symm.trans hs + have hk : 1 ≤ k := by + by_contra hh + have hk : k = 0 := by omega + subst k + have he := congrFun (congrFun hU ⟨0,by omega⟩) ⟨0,by omega⟩ + simp [Matrix.mul_apply] at he + refine ⟨k,w,C,hk,hC,hU,?_⟩ + intro i + apply quotientTensor_zero_of_evaluation + rw [TensorProduct.map_comp,LinearMap.comp_apply,matrixTensor_map_family] + rw [← arrayEvaluation_affineArray,hrep,map_smul,map_add,map_smul,map_add, + arrayEvaluation_comm,hT,hP,map_zero,add_zero,smul_zero] + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/TensorSphere.lean b/lean/OAI/Combinatorics/EuclideanRamsey/TensorSphere.lean new file mode 100644 index 0000000000000000000000000000000000000000..be96fdc72d4b967cad8148355c6bac49f4bd1eca --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/TensorSphere.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.EuclideanRamsey.TensorNecessity +import Mathlib.Geometry.Euclidean.Sphere.Basic + +namespace OAI + +/-! +The real tensor criterion implies ordinary Euclidean cosphericity. +The two constant/spatial matrix blocks are added to obtain the linear coefficient; +no symmetry of the tensor matrix is assumed. +-/ + +noncomputable section +open scoped TensorProduct RealInnerProductSpace + +namespace EuclideanRamsey + +/-- The real tensor criterion places every point on one ordinary Euclidean sphere. -/ +theorem realCriterion_cospherical {s d : ℕ} (a : Fin s → Space d) + (hs : 0 < s) (h : RealCriterion a) : + EuclideanGeometry.Cospherical (Set.range a) := by + classical + obtain ⟨P, hzero, hidentity⟩ := h + let H : Matrix (Option (Fin d)) (Option (Fin d)) ℝ := + fun α β => Algebra.TensorProduct.lmul' ℚ (P α β) + have hspatial (j k : Fin d) : H (some j) (some k) = if j = k then 1 else 0 := by + have hentry := congrFun (congrFun hidentity j) k + change Algebra.TensorProduct.lmul' ℚ (P (some j) (some k)) = + (1 : Matrix (Fin d) (Fin d) ℝ) j k at hentry + simpa only [H, Matrix.one_apply] using hentry + + -- Applying multiplication ℝ ⊗[ℚ] ℝ → ℝ yields an ordinary quadratic. + have hquad (i : Fin s) : + H none none + + (∑ j, (H none (some j) + H (some j) none) * a i j) + + (∑ j, (a i j) ^ 2) = 0 := by + have htensor : + (∑ α, ∑ β, + ((realAugmented a i α) ⊗ₜ[ℚ] (1 : ℝ)) * P α β * + ((1 : ℝ) ⊗ₜ[ℚ] (realAugmented a i β))) = 0 := + hzero i + have hreal := congrArg (Algebra.TensorProduct.lmul' ℚ (S := ℝ)) htensor + simp only [map_sum, map_mul, Algebra.TensorProduct.lmul'_apply_tmul, + mul_one, one_mul, map_zero] at hreal + change (∑ α, ∑ β, + realAugmented a i α * H α β * realAugmented a i β) = 0 at hreal + simp only [Fintype.sum_option, realAugmented, one_mul, mul_one, + Finset.sum_add_distrib] at hreal + have hdiagonal : + (∑ j : Fin d, ∑ k : Fin d, a i j * H (some j) (some k) * a i k) = + ∑ j : Fin d, (a i j) ^ 2 := by + apply Finset.sum_congr rfl + intro j _ + simp [hspatial, mul_ite, ite_mul, pow_two] + have hlinear : + (∑ j : Fin d, H none (some j) * a i j) + + (∑ j : Fin d, a i j * H (some j) none) = + ∑ j : Fin d, (H none (some j) + H (some j) none) * a i j := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro j _ + ring + rw [hdiagonal] at hreal + linarith [hlinear] + + -- Complete the square coordinatewise. This includes the zero-dimensional case. + let center : Space d := WithLp.toLp 2 + (fun j => -((H none (some j) + H (some j) none) / 2)) + have hdist (i : Fin s) : + dist (a i) center ^ 2 = (∑ j, (center j) ^ 2) - H none none := by + rw [EuclideanSpace.dist_sq_eq] + simp only [Real.dist_eq, sq_abs] + calc + (∑ j, (a i j - center j) ^ 2) = + (∑ j, (a i j) ^ 2) + + (∑ j, (H none (some j) + H (some j) none) * a i j) + + (∑ j, (center j) ^ 2) := by + rw [← Finset.sum_add_distrib, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro j _ + dsimp [center] + ring + _ = (∑ j, (center j) ^ 2) - H none none := by + linarith [hquad i] + + -- Use an actual point's nonnegative distance as radius, avoiding a sqrt witness. + let first : Fin s := ⟨0, hs⟩ + refine ⟨center, dist (a first) center, ?_⟩ + rintro p ⟨i, rfl⟩ + exact (sq_eq_sq₀ dist_nonneg dist_nonneg).mp ((hdist i).trans (hdist first).symm) + +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/Transitive.lean b/lean/OAI/Combinatorics/EuclideanRamsey/Transitive.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a80b7a1ff1e46d936e66e9f807305e898b7e304 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/Transitive.lean @@ -0,0 +1,160 @@ +import OAI.Combinatorics.EuclideanRamsey.Main + +namespace OAI + +/-! Finite transitive Euclidean configurations and their subsets are Ramsey. -/ + +noncomputable section +open scoped TensorProduct BigOperators +namespace EuclideanRamsey +namespace TransitiveConsequence + +def distancePermutationGroup {t D : ℕ} (y : Fin t → Space D) : + Subgroup (Equiv.Perm (Fin t)) where + carrier := {σ | ∀ i j, dist (y (σ i)) (y (σ j)) = dist (y i) (y j)} + one_mem' := by intro i j; rfl + mul_mem' := by + intro σ τ hσ hτ i j + change dist (y (σ (τ i))) (y (σ (τ j))) = dist (y i) (y j) + rw [hσ, hτ] + inv_mem' := by + intro σ hσ i j + have h := hσ (σ.symm i) (σ.symm j) + simpa using h.symm + +noncomputable instance distancePermutationFintype {t D : ℕ} (y : Fin t → Space D) : + Fintype (distancePermutationGroup y) := Fintype.ofFinite _ + +def IsTransitive {t D : ℕ} (y : Fin t → Space D) : Prop := + ∀ i j : Fin t, ∃ σ : distancePermutationGroup y, σ.val i = j + +theorem orbit_sum_eq {t D : ℕ} (y : Fin t → Space D) (hy : IsTransitive y) + {M : Type*} [AddCommMonoid M] (f : Space D → M) (i j : Fin t) : + (∑ σ : distancePermutationGroup y, f (y (σ.val i))) = + ∑ σ : distancePermutationGroup y, f (y (σ.val j)) := by + classical + obtain ⟨τ, hτ⟩ := hy i j + calc + (∑ σ : distancePermutationGroup y, f (y (σ.val i))) = + ∑ σ : distancePermutationGroup y, f (y ((σ * τ).val i)) := + (Equiv.sum_comp (Equiv.mulRight τ) + (fun σ : distancePermutationGroup y => f (y (σ.val i)))).symm + _ = ∑ σ : distancePermutationGroup y, f (y (σ.val j)) := by + apply Finset.sum_congr rfl + intro σ _ + change f (y (σ.val (τ.val i))) = f (y (σ.val j)) + rw [hτ] + +theorem averaged_realCriterion {s d t D : ℕ} + (a : Fin s → Space d) (hs : 0 < s) + (hspan : affineSpan ℝ (Set.range a) = ⊤) + (y : Fin t → Space D) (hy : IsTransitive y) + (e : Fin s → Fin t) (he : Congruent a (fun i => y (e i))) : + RealCriterion a := by + classical + let H := distancePermutationGroup y + let i₀ : Fin s := ⟨0, hs⟩ + have hcopies (σ : H) : + ∃ Q : Space d →ₗᵢ[ℝ] Space D, ∃ z : Space D, + ∀ i, y (σ.val (e i)) = z + Q (a i) := by + apply congruent_linearIsometry a (fun i => y (σ.val (e i))) i₀ hspan + intro i j + exact (σ.property (e i) (e j)).trans (he i j) + choose Q z hz using hcopies + let S : RealArray d := ∑ σ : H, ∑ j : Fin D, + (diagonalArray (z σ j) (isometryRows (Q σ) j) - + diagonalArray (y (σ.val (e i₀)) j) 0) + let q : ℚ := (Fintype.card H : ℚ)⁻¹ + have hcard : (Fintype.card H : ℚ) ≠ 0 := by + exact_mod_cast (Fintype.card_ne_zero : Fintype.card H ≠ 0) + have haff (σ : H) (i : Fin s) (j : Fin D) : + affineEvaluation a i (z σ j) (isometryRows (Q σ) j) = + y (σ.val (e i)) j := by + calc + affineEvaluation a i (z σ j) (isometryRows (Q σ) j) = + z σ j + Q σ (a i) j := by + rw [isometryRows_apply] + rfl + _ = y (σ.val (e i)) j := by + simpa only [PiLp.add_apply] using + (congrArg (fun v : Space D => v j) (hz σ i)).symm + have heval (i : Fin s) : + (∑ σ : H, ∑ j : Fin D, + ((y (σ.val (e i)) j ⊗ₜ[ℚ] y (σ.val (e i)) j) - + (y (σ.val (e i₀)) j ⊗ₜ[ℚ] y (σ.val (e i₀)) j))) = 0 := by + rw [Finset.sum_comm] + apply Finset.sum_eq_zero + intro j _ + rw [Finset.sum_sub_distrib] + apply sub_eq_zero.mpr + exact orbit_sum_eq y hy (fun x => x j ⊗ₜ[ℚ] x j) (e i) (e i₀) + have hS_eval (i : Fin s) : arrayEvaluation a i S = 0 := by + dsimp only [S] + simp only [map_sum, map_sub, arrayEvaluation_diagonal, haff] + simpa [affineEvaluation] using heval i + have hgram (σ : H) : + (∑ j : Fin D, + (gradientRankOne (isometryRows (Q σ) j) - gradientRankOne (0 : Space d))) = + (1 : Matrix (Fin d) (Fin d) ℝ) := by + ext α β + simpa only [Matrix.sum_apply, Matrix.sub_apply, gradientRankOne, PiLp.zero_apply, + zero_mul, sub_zero, Matrix.one_apply] using + isometryRows_gram (Q σ) α β + have hS_spatial : spatialMultiply S = + (Fintype.card H : ℚ) • (1 : Matrix (Fin d) (Fin d) ℝ) := by + dsimp only [S] + simp only [map_sum, map_sub, spatialMultiply_diagonal] + simp_rw [hgram] + ext α β + simp [Matrix.one_apply, Rat.smul_def] + refine ⟨q • S, ?_, ?_⟩ + · intro i + rw [map_smul, hS_eval i, smul_zero] + · rw [map_smul, hS_spatial, smul_smul] + dsimp only [q] + rw [inv_mul_cancel₀ hcard, one_smul] + +theorem isometric_subconfiguration_ramsey {s d t D : ℕ} + (a : Fin s → Space d) (hs : 0 < s) (ha : Function.Injective a) + (y : Fin t → Space D) (hy : IsTransitive y) + (e : Fin s → Fin t) (he : Congruent a (fun i => y (e i))) : Ramsey a := by + classical + by_cases hs1 : s = 1 + · subst s + exact singleton_ramsey a + have hs2 : 2 ≤ s := by omega + obtain ⟨d', hd', b, hb, hab, hspan⟩ := full_affine_representative a hs2 ha + have hbe : Congruent b (fun i => y (e i)) := by + intro i j + exact (he i j).trans (hab i j).symm + have hreal : RealCriterion b := + averaged_realCriterion b hs hspan y hy e hbe + have hrb : Ramsey b := fieldCriterion_ramsey b hs2 hd' hb + (realCriterion_fieldCriterion b hreal) + exact (ramsey_congruent_iff hab).mpr hrb + +theorem subset_of_finite_transitive_ramsey {s t D : ℕ} + (a : Fin s → Space D) (y : Fin t → Space D) + (hs : 0 < s) (ha : Function.Injective a) (_hy : Function.Injective y) + (htrans : ∀ i j : Fin t, ∃ σ : Equiv.Perm (Fin t), + (∀ k l : Fin t, dist (y (σ k)) (y (σ l)) = dist (y k) (y l)) ∧ σ i = j) + (hsub : Set.range a ⊆ Set.range y) : Ramsey a := by + classical + have htrans' : IsTransitive y := by + intro i j + obtain ⟨σ, hσ, hij⟩ := htrans i j + exact ⟨⟨σ, hσ⟩, hij⟩ + have hex (i : Fin s) : ∃ j : Fin t, y j = a i := + hsub (Set.mem_range_self i) + choose e he using hex + apply isometric_subconfiguration_ramsey a hs ha y htrans' e + intro i j + change dist (y (e i)) (y (e j)) = dist (a i) (a j) + rw [he i, he j] + +end TransitiveConsequence +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/EuclideanRamsey/UltrafilterStrings.lean b/lean/OAI/Combinatorics/EuclideanRamsey/UltrafilterStrings.lean new file mode 100644 index 0000000000000000000000000000000000000000..3eba86b74b8b1a120e7f9fdef2ce17d75093f552 --- /dev/null +++ b/lean/OAI/Combinatorics/EuclideanRamsey/UltrafilterStrings.lean @@ -0,0 +1,206 @@ +import OAI.Combinatorics.EuclideanRamsey.PathWords + +namespace OAI + +universe uModule uIndex uAlpha + +noncomputable section + +open scoped TensorProduct RealInnerProductSpace +open scoped BigOperators +open Real Filter Topology MeasureTheory Polynomial +open Matrix MeasureTheory +open MeasureTheory +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +open MeasureTheory Matrix +open scoped TensorProduct +open scoped BigOperators Pointwise Topology +open MeasureTheory Filter +open scoped BigOperators Pointwise +open scoped BigOperators Topology +open scoped TensorProduct BigOperators +open scoped BigOperators MatrixOrder Matrix.Norms.L2Operator +open scoped BigOperators RealInnerProductSpace + +open Filter +namespace EuclideanRamsey +attribute [local instance] Ultrafilter.mul Ultrafilter.semigroup + +section Ultrafilters +variable {M : Type uModule} [Monoid M] +@[simp] lemma pure_mul_ultra (x : M) (V : Ultrafilter M) : + (pure x : Ultrafilter M)*V = V.map (x*·) := by + apply Ultrafilter.coe_inj.mp + apply Filter.ext' + intro p + simp [Ultrafilter.eventually_mul] +@[simp] lemma mul_pure_ultra (U : Ultrafilter M) (y : M) : + U*(pure y : Ultrafilter M) = U.map (·*y) := by + apply Ultrafilter.coe_inj.mp + apply Filter.ext' + intro p + simp [Ultrafilter.eventually_mul] + +@[instance_reducible] def ultrafilterMonoid : Monoid (Ultrafilter M) where + toSemigroup := Ultrafilter.semigroup + one := pure 1 + one_mul U := by + change (pure (1:M) : Ultrafilter M)*U=U + rw [pure_mul_ultra] + simp + mul_one U := by + change U*(pure (1:M) : Ultrafilter M)=U + rw [mul_pure_ultra] + simp + +end Ultrafilters + +inductive UltraColumn (ι : Type uIndex) (M : Type uModule) + | common (U : Ultrafilter M) + | principal (x : ι → M) + +namespace UltraColumn +variable {ι : Type uIndex} {M : Type uModule} +def value : UltraColumn ι M → ι → Ultrafilter M + | .common U,_ => U + | .principal x,i => pure (x i) +def Realizes : UltraColumn ι M → (ι → M) → Prop + | .common _,x => ∃ y,∀ i,x i=y + | .principal y,x => x=y + +lemma choose [Finite ι] (q : UltraColumn ι M) (p : ι → M → Prop) + (h : ∀ i,∀ᶠ x in (q.value i : Filter M),p i x) : + ∃ x : ι → M,q.Realizes x ∧ ∀ i,p i (x i) := by + cases q with + | common U => + have hh : ∀ᶠ x in (U : Filter M),∀ i,p i x := Filter.eventually_all.mpr h + obtain ⟨x,hx⟩ := hh.exists + exact ⟨fun _ => x,⟨x,fun _ => rfl⟩,hx⟩ + | principal x => + refine ⟨x,rfl,?_⟩ + intro i + simpa [value] using h i + +theorem simultaneously_realize [Finite ι] [Monoid M] (qs : List (UltraColumn ι M)) + (B : ι → Set M) + (h : letI := ultrafilterMonoid (M:=M) + ∀ i,B i ∈ ((qs.map (fun q => q.value i)).prod : Ultrafilter M)) : + ∃ xs : List (ι → M), List.Forall₂ Realizes qs xs ∧ + ∀ i, (xs.map (fun x => x i)).prod ∈ B i := by + let := ultrafilterMonoid (M:=M) + induction qs generalizing B with + | nil => + refine ⟨[],.nil,?_⟩ + intro i + have hi := h i + change B i ∈ (pure (1:M) : Ultrafilter M) at hi + simpa using hi + | cons q qs ih => + have hh (i : ι) : ∀ᶠ x in (q.value i : Filter M), + {y | x*y∈B i} ∈ ((qs.map (fun q => q.value i)).prod : Ultrafilter M) := by + have hi := h i + change ∀ᶠ z in ((q.value i)*(qs.map (fun q => q.value i)).prod : Ultrafilter M), z∈B i at hi + exact (Ultrafilter.eventually_mul _ _ _).mp hi + obtain ⟨x,hx,hxB⟩ := q.choose _ hh + obtain ⟨xs,hxs,hB⟩ := ih (fun i => {y | x i*y∈B i}) hxB + refine ⟨x::xs,.cons hx hxs,?_⟩ + intro i + simpa using hB i +end UltraColumn +end EuclideanRamsey +namespace EuclideanRamsey +open Filter +attribute [local instance] Ultrafilter.mul Ultrafilter.semigroup +variable {ι : Type uIndex} + +inductive ColumnPath (a : ι → FiniteEuclidean) : List (UltraColumn ι Strings) → ℝ → Prop + | nil : ColumnPath a [] 0 + | common (U : Ultrafilter Strings) : ColumnPath a [.common U] 0 + | copy {u : ℝ} (b : ι → FiniteEuclidean) (h : CopyPath a u b) : + ColumnPath a [.principal (fun i => FreeMonoid.of (b i))] u + | append {p q u v} : ColumnPath a p u → ColumnPath a q v → ColumnPath a (p++q) (u+v) + +lemma ColumnPath.realizes {a : ι → FiniteEuclidean} {qs u} (h : ColumnPath a qs u) + (xs : List (ι → Strings)) (hx : List.Forall₂ UltraColumn.Realizes qs xs) : + StringFamily a u (fun i => (xs.map (fun x => x i)).prod) := by + induction h generalizing xs with + | nil => + cases hx + simpa using StringFamily.common a 1 + | common U => + cases hx with + | cons hx hn => + cases hn + obtain ⟨x,hx⟩ := hx + simpa [hx] using StringFamily.common a x + | copy b hb => + cases hx with + | cons hx hn => + cases hn + change _ = _ at hx + subst hx + simpa using StringFamily.single hb + | @append p q u v _ _ ihp ihq => + have hp : List.Forall₂ UltraColumn.Realizes p (xs.take p.length) := by + have hh := List.forall₂_take p.length hx + simpa only [List.take_left] using hh + have hq : List.Forall₂ UltraColumn.Realizes q (xs.drop p.length) := by + have hh := List.forall₂_drop p.length hx + simpa only [List.drop_left] using hh + have hmul := (ihp (xs.take p.length) hp).mul (ihq (xs.drop p.length) hq) + have he : (fun i => ((xs.take p.length).map (fun x => x i)).prod) * + (fun i => ((xs.drop p.length).map (fun x => x i)).prod) = + (fun i => (xs.map (fun x => x i)).prod) := by + funext i + simp only [Pi.mul_apply,← List.prod_append,← List.map_append,List.take_append_drop] + rwa [he] at hmul + +lemma Path.expand {a : ι → FiniteEuclidean} {w u} (h : Path a w u) + (Ψ : LetterGroup →ₙ* Ultrafilter Strings) (p : Ultrafilter Strings) + (hgen : ∀ z,Ψ (FreeGroup.of z)=p*(pure (FreeMonoid.of z))*p) : + ∃ qs : List (UltraColumn ι Strings),ColumnPath a qs u ∧ + (letI := ultrafilterMonoid (M:=Strings); ∀ i,(qs.map (fun q => q.value i)).prod=Ψ (w i)) := by + let := ultrafilterMonoid (M:=Strings) + induction h with + | diag g => exact ⟨[.common (Ψ g)],.common _,by intro i; simp [UltraColumn.value]⟩ + | @copy u b hb => + refine ⟨[.common p,.principal (fun i => FreeMonoid.of (b i)),.common p],?_,?_⟩ + · simpa using (ColumnPath.common p).append ((ColumnPath.copy b hb).append (.common p)) + · intro i + simp only [List.map_cons,List.map_nil,List.prod_cons,List.prod_nil,UltraColumn.value,mul_one,hgen,mul_assoc] + | @mul w v u t hu hv ihu ihv => + obtain ⟨qs,hqs,hqe⟩ := ihu + obtain ⟨rs,hrs,hre⟩ := ihv + refine ⟨qs++rs,hqs.append hrs,?_⟩ + intro i + simp only [List.map_append,List.prod_append,hqe,hre,Pi.mul_apply] + exact (Ψ.map_mul _ _).symm + +lemma ColumnPath.flatten {α : Type uAlpha} {a : ι → FiniteEuclidean} (l : List α) + (qs : α → List (UltraColumn ι Strings)) (u : α → ℝ) + (h : ∀ j∈l,ColumnPath a (qs j) (u j)) : + ColumnPath a ((l.map qs).flatten) ((l.map u).sum) := by + induction l with + | nil => simpa using (ColumnPath.nil (a:=a)) + | cons j l ih => + simpa only [List.map_cons,List.flatten_cons,List.sum_cons] using + (h j (by simp)).append (ih (fun k hk => h k (by simp [hk]))) + +lemma flattened_ultra_product {α : Type uAlpha} (l : List α) (qs : α → List (UltraColumn ι Strings)) + (U : α → ι → Ultrafilter Strings) + (h : letI := ultrafilterMonoid (M:=Strings); ∀ j∈l,∀ i,((qs j).map (fun q => q.value i)).prod=U j i) : + letI := ultrafilterMonoid (M:=Strings) + ∀ i,(((l.map qs).flatten).map (fun q => q.value i)).prod=(l.map (fun j => U j i)).prod := by + let := ultrafilterMonoid (M:=Strings) + intro i + induction l with + | nil => simp + | cons j l ih => + simp only [List.map_cons,List.flatten_cons,List.map_append,List.prod_append,List.prod_cons] + rw [h j (by simp) i,ih (fun k hk => h k (by simp [hk]))] +end EuclideanRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/Basic.lean b/lean/OAI/Combinatorics/ExpectationThreshold/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..b918d92b0ff4440c643e7200893cbefb20bc9e33 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/Basic.lean @@ -0,0 +1,218 @@ +import OAI.Combinatorics.ExpectationThreshold.Model + +namespace OAI + +namespace TalagrandThreshold + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable section + +omit [Fintype α] [DecidableEq α] in +@[simp] theorem cost_empty (p : ℝ) : cost p (∅ : Family α) = 0 := by + simp [cost] + +omit [Fintype α] [DecidableEq α] in +@[simp] theorem cost_singleton (p : ℝ) (S : Finset α) : + cost p {S} = p ^ S.card := by simp [cost] + +omit [Fintype α] [DecidableEq α] in +theorem cost_nonneg {p : ℝ} (hp : 0 ≤ p) (G : Family α) : 0 ≤ cost p G := + Finset.sum_nonneg (fun S _ => pow_nonneg hp S.card) + +omit [Fintype α] [DecidableEq α] in +theorem cost_mono {p : ℝ} (hp : 0 ≤ p) {G H : Family α} (h : G ⊆ H) : + cost p G ≤ cost p H := + Finset.sum_le_sum_of_subset_of_nonneg h (fun S _ _ => pow_nonneg hp S.card) + +omit [Fintype α] in +theorem cost_union_le {p : ℝ} (hp : 0 ≤ p) (G H : Family α) : + cost p (G ∪ H) ≤ cost p G + cost p H := by + calc + cost p (G ∪ H) ≤ cost p (G ∪ H) + cost p (G ∩ H) := + le_add_of_nonneg_right (cost_nonneg hp _) + _ = cost p G + cost p H := Finset.sum_union_inter + +omit [Fintype α] in +theorem cost_biUnion_le {ι : Type*} [DecidableEq ι] {p : ℝ} (hp : 0 ≤ p) + (T : Finset ι) (G : ι → Family α) : + cost p (T.biUnion G) ≤ ∑ i ∈ T, cost p (G i) := by + induction T using Finset.induction_on with + | empty => simp + | @insert a T ha ih => + rw [Finset.biUnion_insert, Finset.sum_insert ha] + exact (cost_union_le hp _ _).trans (add_le_add le_rfl ih) + +omit [Fintype α] in +theorem cost_image_le {ι : Type*} [DecidableEq ι] {p : ℝ} (hp : 0 ≤ p) + (T : Finset ι) (G : ι → Finset α) : + cost p (T.image G) ≤ ∑ i ∈ T, p ^ (G i).card := by + exact Finset.sum_image_le_of_nonneg (fun S _ => pow_nonneg hp S.card) + +omit [Fintype α] [DecidableEq α] in +theorem cost_mono_density {p r : ℝ} (hp : 0 ≤ p) (hpr : p ≤ r) (G : Family α) : + cost p G ≤ cost r G := + Finset.sum_le_sum (fun S _ => pow_le_pow_left₀ hp hpr S.card) + +omit [Fintype α] [DecidableEq α] in +theorem covers_self (F : Family α) : Covers F F := + fun H hH => ⟨H, hH, Finset.Subset.refl H⟩ + +omit [Fintype α] [DecidableEq α] in +@[simp] theorem covers_empty (G : Family α) : Covers G ∅ := by + intro H hH + exact False.elim (Finset.notMem_empty H hH) + +omit [Fintype α] [DecidableEq α] in +theorem Covers.mono_target {G F E : Family α} (h : Covers G F) (hEF : E ⊆ F) : + Covers G E := fun H hH => h H (hEF hH) + +omit [Fintype α] [DecidableEq α] in +theorem Covers.mono_cover {G K F : Family α} (h : Covers G F) (hGK : G ⊆ K) : + Covers K F := by + intro H hH + obtain ⟨S, hS, hSH⟩ := h H hH + exact ⟨S, hGK hS, hSH⟩ + +omit [Fintype α] in +theorem Covers.union {G K F E : Family α} (hGF : Covers G F) (hKE : Covers K E) : + Covers (G ∪ K) (F ∪ E) := by + intro H hH + rcases Finset.mem_union.mp hH with hH | hH + · obtain ⟨S, hS, hSH⟩ := hGF H hH + exact ⟨S, Finset.mem_union_left K hS, hSH⟩ + · obtain ⟨S, hS, hSH⟩ := hKE H hH + exact ⟨S, Finset.mem_union_right G hS, hSH⟩ + +omit [Fintype α] [DecidableEq α] in +theorem small_empty (p : ℝ) : Small p (∅ : Family α) := by + refine ⟨∅, covers_empty _, ?_⟩ + simp + +omit [Fintype α] [DecidableEq α] in +theorem Small.mono {F : Family α} {p r : ℝ} (h : Small r F) + (hp : 0 ≤ p) (hpr : p ≤ r) : Small p F := by + obtain ⟨G, hG, hcost⟩ := h + exact ⟨G, hG, (cost_mono_density hp hpr G).trans hcost⟩ + +omit [Fintype α] [DecidableEq α] in +theorem cost_gt_of_not_small {F G : Family α} {p : ℝ} + (h : ¬ Small p F) (hG : Covers G F) : 1 / 2 < cost p G := + lt_of_not_ge (fun hc => h ⟨G, hG, hc⟩) + +omit [Fintype α] [DecidableEq α] in +theorem members_nonempty {F : Family α} (hF : (∅ : Finset α) ∉ F) + {H : Finset α} (hH : H ∈ F) : H.Nonempty := by + apply Finset.nonempty_iff_ne_empty.mpr + intro he + exact hF (he ▸ hH) + +omit [Fintype α] [DecidableEq α] in +theorem cost_zero_of_empty_not_mem (F : Family α) (hF : (∅ : Finset α) ∉ F) : + cost 0 F = 0 := by + apply Finset.sum_eq_zero + intro S hS + exact zero_pow (Nat.ne_of_gt (Finset.card_pos.mpr (members_nonempty hF hS))) + +omit [Fintype α] [DecidableEq α] in +theorem small_zero (F : Family α) (hF : (∅ : Finset α) ∉ F) : Small 0 F := by + refine ⟨F, covers_self F, ?_⟩ + rw [cost_zero_of_empty_not_mem F hF] + exact div_nonneg zero_le_one zero_le_two + +omit [DecidableEq α] in +theorem Increasing.empty_not_mem {F : Family α} (hF : Increasing F) + (hproper : F ≠ Finset.univ) : (∅ : Finset α) ∉ F := by + intro hempty + apply hproper + apply Finset.eq_univ_iff_forall.mpr + intro H + exact hF ∅ hempty H (Finset.empty_subset H) + +def coverIndicator (G : Family α) (S : Finset α) : ℝ := if S ∈ G then 1 else 0 + +omit [Fintype α] in +theorem coverIndicator_nonneg (G : Family α) (S : Finset α) : + 0 ≤ coverIndicator G S := by + unfold coverIndicator + split_ifs <;> simp + +omit [Fintype α] in +theorem coverIndicator_le_one (G : Family α) (S : Finset α) : + coverIndicator G S ≤ 1 := by + unfold coverIndicator + split_ifs <;> simp + +omit [Fintype α] in +theorem Covers.fractionalCover {G F : Family α} (h : Covers G F) : + FractionalCover F (coverIndicator G) := by + constructor + · intro S + exact ⟨coverIndicator_nonneg G S, coverIndicator_le_one G S⟩ + · intro H hH + obtain ⟨S, hSG, hSH⟩ := h H hH + have hs := Finset.single_le_sum (fun T _ => coverIndicator_nonneg G T) + (Finset.mem_powerset.mpr hSH) + simpa only [coverIndicator, ite_eq_left hSG] using hs + +theorem fracCost_coverIndicator (p : ℝ) (G : Family α) : + fracCost p (coverIndicator G) = cost p G := by + classical + unfold fracCost cost + calc + (∑ S : Finset α, coverIndicator G S * p ^ S.card) = + ∑ S : Finset α, if S ∈ G then p ^ S.card else 0 := by + apply Finset.sum_congr rfl + intro S _ + by_cases hS : S ∈ G <;> simp [coverIndicator, hS] + _ = ∑ S ∈ G, p ^ S.card := Finset.sum_ite_mem_eq G (fun S => p ^ S.card) + +theorem Small.fractionalSmall {F : Family α} {p : ℝ} (h : Small p F) : + FractionalSmall p F := by + obtain ⟨G, hG, hcost⟩ := h + exact ⟨coverIndicator G, hG.fractionalCover, (fracCost_coverIndicator p G).trans_le hcost⟩ + +theorem fractionalSmall_zero (F : Family α) (hF : (∅ : Finset α) ∉ F) : + FractionalSmall 0 F := (small_zero F hF).fractionalSmall + +omit [Fintype α] [DecidableEq α] in +theorem FractionalCover.nonneg {F : Family α} {g : Finset α → ℝ} + (h : FractionalCover F g) (S : Finset α) : 0 ≤ g S := (h.1 S).1 + +omit [Fintype α] [DecidableEq α] in +theorem FractionalCover.le_one {F : Family α} {g : Finset α → ℝ} + (h : FractionalCover F g) (S : Finset α) : g S ≤ 1 := (h.1 S).2 + +omit [DecidableEq α] in +theorem fracCost_nonneg {p : ℝ} {g : Finset α → ℝ} + (hp : 0 ≤ p) (hg : ∀ S, 0 ≤ g S) : 0 ≤ fracCost p g := + Finset.sum_nonneg (fun S _ => mul_nonneg (hg S) (pow_nonneg hp S.card)) + +omit [DecidableEq α] in +theorem fracCost_mono_density {p r : ℝ} {g : Finset α → ℝ} + (hg : ∀ S, 0 ≤ g S) (hp : 0 ≤ p) (hpr : p ≤ r) : + fracCost p g ≤ fracCost r g := + Finset.sum_le_sum (fun S _ => + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hp hpr S.card) (hg S)) + +omit [DecidableEq α] in +theorem FractionalSmall.mono {F : Family α} {p r : ℝ} (h : FractionalSmall r F) + (hp : 0 ≤ p) (hpr : p ≤ r) : FractionalSmall p F := by + obtain ⟨g, hg, hcost⟩ := h + exact ⟨g, hg, (fracCost_mono_density hg.nonneg hp hpr).trans hcost⟩ + +omit [DecidableEq α] in +theorem empty_weight_le_fracCost {p : ℝ} {g : Finset α → ℝ} + (hp : 0 ≤ p) (hg : ∀ S, 0 ≤ g S) : g ∅ ≤ fracCost p g := by + have h := Finset.single_le_sum + (fun S (_ : S ∈ (Finset.univ : Finset (Finset α))) => + mul_nonneg (hg S) (pow_nonneg hp S.card)) + (Finset.mem_univ (∅ : Finset α)) + simpa only [fracCost, Finset.card_empty, pow_zero, mul_one] using h + +end +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ColorArithmetic.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ColorArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc2e8bc7806fae290ae7ed256ca4e6e70cb032db --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ColorArithmetic.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.ExpectationThreshold.ProbabilityColors +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Exact normalization of the profile coefficient + +At level `i+1`, the color probability is `256^(i+1)*p`. Its likelihood +factor cancels the density and turns the counting factor `3*4^(i+1)` +into the geometric coefficient `3/64^(i+1)`. +-/ + +namespace TalagrandThreshold + +theorem profile_coefficient_eq {p : ℝ} (hp : 0 < p) (s : ℕ) (i : Fin s) : + ((3 : ℝ) * (4 : ℝ) ^ (i.val + 1)) * (p / colorProb p s i.castSucc) = + 3 / (64 : ℝ) ^ (i.val + 1) := by + rw [colorProb_castSucc] + have hpne : p ≠ 0 := ne_of_gt hp + have hpow : (256 : ℝ) ^ (i.val + 1) = + (4 : ℝ) ^ (i.val + 1) * (64 : ℝ) ^ (i.val + 1) := by + rw [← mul_pow] + norm_num + calc + _ = 3 * ((4 : ℝ) ^ (i.val + 1) / (256 : ℝ) ^ (i.val + 1)) := by + field_simp [hpne] + _ = 3 / (64 : ℝ) ^ (i.val + 1) := by + rw [hpow] + field_simp + +theorem profile_coefficient_pow_eq {p : ℝ} (hp : 0 < p) + (s : ℕ) (i : Fin s) (t : ℕ) : + ((3 : ℝ) * (4 : ℝ) ^ (i.val + 1)) ^ t * + (p / colorProb p s i.castSucc) ^ t = + (3 / (64 : ℝ) ^ (i.val + 1)) ^ t := by + rw [← mul_pow, profile_coefficient_eq hp s i] + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ColorMean.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ColorMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bd5453690c3d0dd7ed51183e7472074b8d8f559 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ColorMean.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.ExpectationThreshold.ScaleBounds +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# The mean of the numerical color variable + +The variable at color `c` is `512^4 / 512^(c.val+1)`. This quotient represents +a possibly negative integral exponent without natural +subtraction. The computation includes the residual last color and also +applies when the selected number of scales is zero. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +private theorem color_mean_row (p : ℝ) (n : ℕ) : + ((256 : ℝ) ^ n * p) * ((512 : ℝ) ^ 4 / (512 : ℝ) ^ n) = + (512 : ℝ) ^ 4 * (p * (1 / 2 : ℝ) ^ n) := by + have hratio : (256 : ℝ) ^ n / (512 : ℝ) ^ n = (1 / 2 : ℝ) ^ n := by + rw [← div_pow] + norm_num + calc + _ = (512 : ℝ) ^ 4 * (p * ((256 : ℝ) ^ n / (512 : ℝ) ^ n)) := by ring + _ = _ := by rw [hratio] + +/-- The exact finite-color mean, including the residual last color. -/ +theorem color_mean_eq (p : ℝ) (s : ℕ) : + (∑ c : Color s, + colorProb p s c * ((512 : ℝ) ^ 4 / (512 : ℝ) ^ (c.val + 1))) = + (512 : ℝ) ^ 4 * + (p * (∑ i : Fin s, (1 / 2 : ℝ) ^ (i.val + 1)) + + (1 - p * scaleSum s) * (1 / (512 : ℝ) ^ (s + 1))) := by + change (∑ c : Fin (s + 1), + colorProb p s c * ((512 : ℝ) ^ 4 / (512 : ℝ) ^ (c.val + 1))) = _ + rw [Fin.sum_univ_castSucc] + simp only [colorProb_castSucc, colorProb_last, Fin.val_castSucc, Fin.val_last] + simp_rw [color_mean_row] + rw [← Finset.mul_sum, ← Finset.mul_sum] + ring + +/-- Maximality of the scale makes the common mean at most `5 * 512^4 * p`. -/ +theorem color_mean_le {p : ℝ} (hp : 0 < p) {s : ℕ} + (_hs : p * scaleSum s ≤ 1 / 2) + (hnext : 1 / 2 < p * scaleSum (s + 1)) : + (∑ c : Color s, + colorProb p s c * ((512 : ℝ) ^ 4 / (512 : ℝ) ^ (c.val + 1))) ≤ + 5 * (512 : ℝ) ^ 4 * p := by + have hres : 1 - p * scaleSum s ≤ 1 := + sub_le_self _ (mul_nonneg hp.le (scaleSum_nonneg s)) + have htail : (1 - p * scaleSum s) * (1 / (512 : ℝ) ^ (s + 1)) ≤ 4 * p := by + calc + _ ≤ 1 * (1 / (512 : ℝ) ^ (s + 1)) := + mul_le_mul_of_nonneg_right hres (by positivity) + _ ≤ 4 * p := by + simpa only [one_mul] using (tail_lt_four_mul_p hp hnext).le + rw [color_mean_eq] + calc + _ ≤ (512 : ℝ) ^ 4 * (p * 1 + 4 * p) := + mul_le_mul_of_nonneg_left + (add_le_add (mul_le_mul_of_nonneg_left (half_geometric_sum_le_one s) hp.le) htail) + (by positivity) + _ = 5 * (512 : ℝ) ^ 4 * p := by ring + +theorem rounding_constant_pos : 0 < (25 : ℝ) * (512 : ℝ) ^ 4 := by positivity + +/-- The leading constant is 25. -/ +theorem five_Bfour_mul_scaled_density (r : ℝ) : + 5 * (512 : ℝ) ^ 4 * (r / ((25 : ℝ) * (512 : ℝ) ^ 4)) = r / 5 := by + field_simp + ring + +/-- The mean bound at the exact density used for rounding. -/ +theorem color_mean_le_r_div_five {r : ℝ} (hr : 0 < r) {s : ℕ} + (hs : (r / ((25 : ℝ) * (512 : ℝ) ^ 4)) * scaleSum s ≤ 1 / 2) + (hnext : 1 / 2 < (r / ((25 : ℝ) * (512 : ℝ) ^ 4)) * scaleSum (s + 1)) : + (∑ c : Color s, + colorProb (r / ((25 : ℝ) * (512 : ℝ) ^ 4)) s c * + ((512 : ℝ) ^ 4 / (512 : ℝ) ^ (c.val + 1))) ≤ r / 5 := by + simpa only [five_Bfour_mul_scaled_density] using + color_mean_le (div_pos hr rounding_constant_pos) hs hnext + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/Main.lean b/lean/OAI/Combinatorics/ExpectationThreshold/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab98e4ee229ca69d4bb3e8fb23bbe2f604d41b2a --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/Main.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.ExpectationThreshold.RoundingMain +import OAI.Combinatorics.ExpectationThreshold.ThresholdAttainment + +namespace OAI + +/-! +# Integral and fractional expectation thresholds + +The fractional threshold is genuinely attained with budget one half. Rounding +that attained cover gives an integral cover at the threshold divided by +`25 * 512^4`, still with budget one half and without a support-size restriction. +-/ + +namespace TalagrandThreshold + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- Talagrand's threshold comparison with the explicit constant `25 * 512^4`. +The coefficient 25 is an integer factor, and both feasible sets use budget +one half. The fractional cover ranges over every subset of the ground set. -/ +theorem talagrand_expectation_threshold_equivalence [Nonempty α] + (F : Family α) (_hF : F.Nonempty) (hproper : F ≠ Finset.univ) + (hIncreasing : Increasing F) : + qf F ≤ ((25 : ℝ) * (512 : ℝ) ^ 4) * q F := by + have hempty : (∅ : Finset α) ∉ F := hIncreasing.empty_not_mem hproper + have hqf0 : 0 ≤ qf F := qf_nonneg F hempty + have hqf1 : qf F ≤ 1 := qf_le_one F hempty + have hsmall : Small (qf F / ((25 : ℝ) * (512 : ℝ) ^ 4)) F := + fractionalSmall_rounding F hqf0 hqf1 (fractionalSmall_qf F hempty) + have hscaled0 : 0 ≤ qf F / ((25 : ℝ) * (512 : ℝ) ^ 4) := + div_nonneg hqf0 rounding_constant_pos.le + have hscaled1 : qf F / ((25 : ℝ) * (512 : ℝ) ^ 4) ≤ 1 := + (div_le_one rounding_constant_pos).mpr + (hqf1.trans (by norm_num : (1 : ℝ) ≤ (25 : ℝ) * (512 : ℝ) ^ 4)) + have hle := le_q_of_small hscaled0 hscaled1 hsmall + calc + qf F ≤ q F * ((25 : ℝ) * (512 : ℝ) ^ 4) := + (div_le_iff₀ rounding_constant_pos).mp hle + _ = ((25 : ℝ) * (512 : ℝ) ^ 4) * q F := mul_comm _ _ + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/Model.lean b/lean/OAI/Combinatorics/ExpectationThreshold/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c62008b75595760ae2b38aa8809e46aeb15f686 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/Model.lean @@ -0,0 +1,72 @@ +import Mathlib.Data.Fintype.Powerset +import Mathlib.Data.Finset.Union +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise + +namespace OAI + +/-! +# Containment covers and expectation thresholds + +Both costs use budget one half. Fractional coefficients are indexed by every +subset of the ground set, without a support-size bound. The empty subset is +included, and ordinary natural powers give `p^0 = 1`, including at zero. +The thresholds are real suprema of feasible densities in the closed unit interval. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +abbrev Family (α : Type*) := Finset (Finset α) + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable section + +def cost (p : ℝ) (G : Family α) : ℝ := ∑ S ∈ G, p ^ S.card + +def Covers (G F : Family α) : Prop := ∀ H ∈ F, ∃ S ∈ G, S ⊆ H + +def Small (p : ℝ) (F : Family α) : Prop := + ∃ G : Family α, Covers G F ∧ cost p G ≤ 1 / 2 + +def fracCost (p : ℝ) (g : Finset α → ℝ) : ℝ := + ∑ S : Finset α, g S * p ^ S.card + +def FractionalCover (F : Family α) (g : Finset α → ℝ) : Prop := + (∀ S, 0 ≤ g S ∧ g S ≤ 1) ∧ + ∀ H ∈ F, 1 ≤ ∑ S ∈ H.powerset, g S + +def FractionalSmall (p : ℝ) (F : Family α) : Prop := + ∃ g : Finset α → ℝ, FractionalCover F g ∧ fracCost p g ≤ 1 / 2 + +def Increasing (F : Family α) : Prop := + ∀ H ∈ F, ∀ K : Finset α, H ⊆ K → K ∈ F + +def integralFeasible (F : Family α) : Set ℝ := + {p | 0 ≤ p ∧ p ≤ 1 ∧ Small p F} + +def fractionalFeasible (F : Family α) : Set ℝ := + {p | 0 ≤ p ∧ p ≤ 1 ∧ FractionalSmall p F} + +/-- The integral expectation threshold. -/ +def q (F : Family α) : ℝ := sSup (integralFeasible F) + +/-- The fractional expectation threshold. -/ +def qf (F : Family α) : ℝ := sSup (fractionalFeasible F) + +omit [Fintype α] [DecidableEq α] in +@[simp] theorem mem_integralFeasible {F : Family α} {p : ℝ} : + p ∈ integralFeasible F ↔ 0 ≤ p ∧ p ≤ 1 ∧ Small p F := Iff.rfl + +omit [DecidableEq α] in +@[simp] theorem mem_fractionalFeasible {F : Family α} {p : ℝ} : + p ∈ fractionalFeasible F ↔ 0 ≤ p ∧ p ≤ 1 ∧ FractionalSmall p F := Iff.rfl + +end +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityColors.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityColors.lean new file mode 100644 index 0000000000000000000000000000000000000000..16864ff20bd3ce70add0559535844817e6761e19 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityColors.lean @@ -0,0 +1,141 @@ +import OAI.Combinatorics.ExpectationThreshold.ProbabilityProduct +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# The actual independent color law + +Colors are indexed from zero; their numerical levels are one larger. The +first `s` colors have masses `256^(i+1) * p`, and the final color carries the +remaining mass. All laws below use these literal weights. +-/ + +open scoped BigOperators +noncomputable section + +namespace TalagrandThreshold + +abbrev Color (s : ℕ) := Fin (s + 1) + +abbrev Coloring (α : Type*) (s : ℕ) := α → Color s + +/-- The geometric sum appearing in the admissibility condition. -/ +def scaleSum (s : ℕ) : ℝ := ∑ i : Fin s, (256 : ℝ) ^ (i.val + 1) + +/-- The literal single-coordinate probabilities from the selector experiment. -/ +def colorProb (p : ℝ) (s : ℕ) (c : Color s) : ℝ := + if c.val < s then (256 : ℝ) ^ (c.val + 1) * p else 1 - p * scaleSum s + +@[simp] theorem scaleSum_zero : scaleSum 0 = 0 := by + simp [scaleSum] + +theorem scaleSum_nonneg (s : ℕ) : 0 ≤ scaleSum s := by + exact Finset.sum_nonneg fun i _ => pow_nonneg (by norm_num) _ + +@[simp] theorem colorProb_castSucc (p : ℝ) (s : ℕ) (i : Fin s) : + colorProb p s i.castSucc = (256 : ℝ) ^ (i.val + 1) * p := by + simp [colorProb, i.isLt] + +@[simp] theorem colorProb_last (p : ℝ) (s : ℕ) : + colorProb p s (Fin.last s) = 1 - p * scaleSum s := by + simp [colorProb] + +/-- Normalization is an algebraic identity, even before assuming positivity. -/ +theorem sum_colorProb (p : ℝ) (s : ℕ) : ∑ c : Color s, colorProb p s c = 1 := by + rw [Fin.sum_univ_castSucc] + simp only [colorProb_castSucc, colorProb_last] + rw [← Finset.sum_mul] + change scaleSum s * p + (1 - p * scaleSum s) = 1 + ring + +theorem colorProb_pos (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (c : Color s) : 0 < colorProb p s c := by + unfold colorProb + split_ifs + · exact mul_pos (pow_pos (by norm_num) _) hp + · linarith + +theorem colorProb_nonneg (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (c : Color s) : 0 ≤ colorProb p s c := + (colorProb_pos p s hp hs c).le + +theorem colorProb_le_one (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (c : Color s) : colorProb p s c ≤ 1 := by + rw [← sum_colorProb p s] + exact Finset.single_le_sum (fun d _ => colorProb_nonneg p s hp hs d) + (Finset.mem_univ c) + +def colorLaw (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) : FiniteLaw (Color s) where + weight := colorProb p s + nonneg := colorProb_nonneg p s hp hs + total := sum_colorProb p s + +@[simp] theorem colorLaw_weight (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (c : Color s) : + (colorLaw p s hp hs).weight c = colorProb p s c := rfl + +theorem colorLaw_isPositive (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) : (colorLaw p s hp hs).IsPositive := + colorProb_pos p s hp hs + +variable {α : Type*} [Fintype α] + +/-- Probability mass of a complete coloring, with one factor per vertex. -/ +def colorMass (p : ℝ) (s : ℕ) (a : Coloring α s) : ℝ := + ∏ x, colorProb p s (a x) + +theorem colorMass_pos (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (a : Coloring α s) : 0 < colorMass p s a := by + exact Finset.prod_pos fun x _ => colorProb_pos p s hp hs (a x) + +theorem colorMass_nonneg (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (a : Coloring α s) : 0 ≤ colorMass p s a := + (colorMass_pos p s hp hs a).le + +variable [DecidableEq α] + +/-- Summing over actual colorings gives total mass one. -/ +theorem sum_colorMass (p : ℝ) (s : ℕ) : + ∑ a : Coloring α s, colorMass p s a = 1 := by + classical + unfold colorMass + rw [← Fintype.prod_sum (fun (_ : α) (c : Color s) => colorProb p s c)] + simp only [sum_colorProb, Finset.prod_const_one] + +/-- The independent product law on exactly the original vertex set. -/ +def coloringLaw (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) : FiniteLaw (Coloring α s) := + FiniteLaw.pi (fun _ : α => colorLaw p s hp hs) + +@[simp] theorem coloringLaw_weight (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (a : Coloring α s) : + (coloringLaw p s hp hs).weight a = colorMass p s a := rfl + +theorem coloringLaw_isPositive (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) : + (coloringLaw (α := α) p s hp hs).IsPositive := + colorMass_pos p s hp hs + +/-- Coordinate observables have the explicitly specified color marginal. -/ +theorem coloringLaw_expectation_coordinate (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (x : α) (f : Color s → ℝ) : + (coloringLaw p s hp hs).expectation (fun a => f (a x)) = + ∑ c : Color s, colorProb p s c * f c := + FiniteLaw.expectation_pi_coordinate (fun _ : α => colorLaw p s hp hs) x f + +/-- Independent coordinate observables factor under the actual coloring law. -/ +theorem coloringLaw_expectation_product (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (f : α → Color s → ℝ) : + (coloringLaw p s hp hs).expectation (fun a => ∏ x, f x (a x)) = + ∏ x, ∑ c : Color s, colorProb p s c * f x c := + FiniteLaw.expectation_pi_product (fun _ : α => colorLaw p s hp hs) f + +end TalagrandThreshold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityFinite.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityFinite.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2e2a0028105c3bee0d5cee9a5f3fa8a2034ad40 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityFinite.lean @@ -0,0 +1,194 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Data.Fintype.Pi +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.SplitIfs + +namespace OAI + +/-! +# Finite probability laws + +Probabilities and expectations are finite real sums. Independent samples, +product laws, and uniform laws satisfy the usual elementary inequalities. +-/ + +open scoped BigOperators +noncomputable section +attribute [local instance] Classical.propDecidable + +namespace TalagrandThreshold + +structure FiniteLaw (Ω : Type*) [Fintype Ω] where + weight : Ω → ℝ + nonneg : ∀ ω, 0 ≤ weight ω + total : ∑ ω, weight ω = 1 + +namespace FiniteLaw + +def expectation {Ω : Type*} [Fintype Ω] (μ : FiniteLaw Ω) (f : Ω → ℝ) : ℝ := + ∑ ω, μ.weight ω * f ω + +def prob {Ω : Type*} [Fintype Ω] (μ : FiniteLaw Ω) (P : Ω → Prop) : ℝ := by + classical + exact ∑ ω, if P ω then μ.weight ω else 0 + +def IsPositive {Ω : Type*} [Fintype Ω] (μ : FiniteLaw Ω) : Prop := + ∀ ω, 0 < μ.weight ω + +variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + +@[simp] theorem expectation_const (μ : FiniteLaw Ω) (c : ℝ) : + μ.expectation (fun _ => c) = c := by + rw [expectation, ← Finset.sum_mul, μ.total, one_mul] + +theorem expectation_add (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.expectation (fun ω => f ω + g ω) = μ.expectation f + μ.expectation g := by + simp [expectation, mul_add, Finset.sum_add_distrib] + +theorem expectation_sub (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.expectation (fun ω => f ω - g ω) = μ.expectation f - μ.expectation g := by + simp [expectation, mul_sub, Finset.sum_sub_distrib] + +theorem expectation_smul (μ : FiniteLaw Ω) (c : ℝ) (f : Ω → ℝ) : + μ.expectation (fun ω => c * f ω) = c * μ.expectation f := by + simp [expectation, Finset.mul_sum, mul_left_comm] + +theorem expectation_sum {ι : Type*} [Fintype ι] (μ : FiniteLaw Ω) (f : ι → Ω → ℝ) : + μ.expectation (fun ω => ∑ i, f i ω) = ∑ i, μ.expectation (f i) := by + simp only [expectation, Finset.mul_sum] + exact Finset.sum_comm + +theorem expectation_nonneg (μ : FiniteLaw Ω) {f : Ω → ℝ} (hf : ∀ ω, 0 ≤ f ω) : + 0 ≤ μ.expectation f := + Finset.sum_nonneg fun ω _ => mul_nonneg (μ.nonneg ω) (hf ω) + +theorem expectation_mono (μ : FiniteLaw Ω) {f g : Ω → ℝ} (hfg : ∀ ω, f ω ≤ g ω) : + μ.expectation f ≤ μ.expectation g := + Finset.sum_le_sum fun ω _ => mul_le_mul_of_nonneg_left (hfg ω) (μ.nonneg ω) + +theorem prob_eq_expectation (μ : FiniteLaw Ω) (P : Ω → Prop) : + μ.prob P = μ.expectation (fun ω => if P ω then 1 else 0) := by + classical + simp [prob, expectation, mul_ite] + +@[simp] theorem prob_true (μ : FiniteLaw Ω) : μ.prob (fun _ => True) = 1 := by + simp [prob, μ.total] + +@[simp] theorem prob_false (μ : FiniteLaw Ω) : μ.prob (fun _ => False) = 0 := by + simp [prob] + +theorem prob_nonneg (μ : FiniteLaw Ω) (P : Ω → Prop) : 0 ≤ μ.prob P := by + classical + exact Finset.sum_nonneg fun ω _ => by split_ifs <;> simp [μ.nonneg] + +theorem prob_mono (μ : FiniteLaw Ω) {P Q : Ω → Prop} (hPQ : ∀ ω, P ω → Q ω) : + μ.prob P ≤ μ.prob Q := by + classical + apply Finset.sum_le_sum + intro ω _ + by_cases hp : P ω + · simp [hp, hPQ ω hp] + · by_cases hq : Q ω <;> simp [hp, hq, μ.nonneg ω] + +theorem prob_le_one (μ : FiniteLaw Ω) (P : Ω → Prop) : μ.prob P ≤ 1 := by + simpa using μ.prob_mono (Q := fun _ => True) (fun _ _ => trivial) + +theorem prob_compl (μ : FiniteLaw Ω) (P : Ω → Prop) : + μ.prob (fun ω => ¬ P ω) = 1 - μ.prob P := by + classical + have h : μ.prob P + μ.prob (fun ω => ¬ P ω) = 1 := by + rw [prob, prob, ← Finset.sum_add_distrib, ← μ.total] + apply Finset.sum_congr rfl + intro ω _ + by_cases hp : P ω <;> simp [hp] + linarith + +theorem prob_union_le (μ : FiniteLaw Ω) (P Q : Ω → Prop) : + μ.prob (fun ω => P ω ∨ Q ω) ≤ μ.prob P + μ.prob Q := by + classical + rw [prob, prob, prob, ← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro ω _ + by_cases hp : P ω <;> by_cases hq : Q ω <;> simp [hp, hq, μ.nonneg] + +theorem prob_le_expectation (μ : FiniteLaw Ω) (P : Ω → Prop) (f : Ω → ℝ) + (hf : ∀ ω, 0 ≤ f ω) (hP : ∀ ω, P ω → 1 ≤ f ω) : μ.prob P ≤ μ.expectation f := by + classical + rw [prob_eq_expectation] + apply μ.expectation_mono + intro ω + by_cases hp : P ω + · simpa [hp] using hP ω hp + · simpa [hp] using hf ω + +theorem prob_ge_le_expectation_div (μ : FiniteLaw Ω) (f : Ω → ℝ) + (hf : ∀ ω, 0 ≤ f ω) {t : ℝ} (ht : 0 < t) : + μ.prob (fun ω => t ≤ f ω) ≤ μ.expectation f / t := by + have h := μ.prob_le_expectation (fun ω => t ≤ f ω) (fun ω => t⁻¹ * f ω) + (fun ω => mul_nonneg (inv_nonneg.mpr ht.le) (hf ω)) + (fun ω hω => by simpa [ht.ne'] using mul_le_mul_of_nonneg_left hω (inv_nonneg.mpr ht.le)) + rw [expectation_smul] at h + simpa [div_eq_mul_inv, mul_comm] using h + +def prod (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) : FiniteLaw (Ω × Γ) where + weight ω := μ.weight ω.1 * ν.weight ω.2 + nonneg ω := mul_nonneg (μ.nonneg _) (ν.nonneg _) + total := by + simp only [Fintype.sum_prod_type, ← Finset.mul_sum, ν.total, mul_one, μ.total] + +@[simp] theorem prod_weight (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) (ω : Ω) (γ : Γ) : + (μ.prod ν).weight (ω, γ) = μ.weight ω * ν.weight γ := rfl + +theorem expectation_prod (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) (f : Ω × Γ → ℝ) : + (μ.prod ν).expectation f = μ.expectation (fun ω => ν.expectation (fun γ => f (ω, γ))) := by + simp [expectation, prod, Fintype.sum_prod_type, Finset.mul_sum, mul_assoc] + +theorem prod_isPositive (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) + (hμ : μ.IsPositive) (hν : ν.IsPositive) : (μ.prod ν).IsPositive := + fun outcome => mul_pos (hμ outcome.1) (hν outcome.2) + +def pi {ι : Type*} [Fintype ι] [DecidableEq ι] {A : ι → Type*} [∀ i, Fintype (A i)] + (μ : ∀ i, FiniteLaw (A i)) : FiniteLaw (∀ i, A i) := by + classical + exact { + weight := fun ω => ∏ i, (μ i).weight (ω i) + nonneg := fun ω => Finset.prod_nonneg fun i _ => (μ i).nonneg (ω i) + total := by + rw [← Fintype.prod_sum (fun i a => (μ i).weight a)] + simp_rw [(μ _).total] + simp } + +@[simp] theorem pi_weight {ι : Type*} [Fintype ι] [DecidableEq ι] {A : ι → Type*} [∀ i, Fintype (A i)] + (μ : ∀ i, FiniteLaw (A i)) (ω : ∀ i, A i) : + (pi μ).weight ω = ∏ i, (μ i).weight (ω i) := rfl + +def iid (μ : FiniteLaw Ω) (n : ℕ) : FiniteLaw (Fin n → Ω) := pi (fun _ : Fin n => μ) + +@[simp] theorem iid_weight (μ : FiniteLaw Ω) (n : ℕ) (ω : Fin n → Ω) : + (iid μ n).weight ω = ∏ i, μ.weight (ω i) := rfl + +def uniform (Ω : Type*) [Fintype Ω] [Nonempty Ω] : FiniteLaw Ω where + weight _ := (Fintype.card Ω : ℝ)⁻¹ + nonneg _ := inv_nonneg.mpr (Nat.cast_nonneg _) + total := by + have hN : (Fintype.card Ω : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + simp [hN] + +theorem uniform_isPositive (Ω : Type*) [Fintype Ω] [Nonempty Ω] : + (uniform Ω).IsPositive := fun _ => inv_pos.mpr (Nat.cast_pos.mpr Fintype.card_pos) + +theorem uniform_prob (Ω : Type*) [Fintype Ω] [Nonempty Ω] (P : Ω → Prop) : + (uniform Ω).prob P = ((Finset.univ.filter P).card : ℝ) / Fintype.card Ω := by + simp [prob, uniform, ← Finset.sum_filter, div_eq_mul_inv] + +end FiniteLaw + +end TalagrandThreshold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityLikelihood.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityLikelihood.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5930a64bfc6174700d5622c7e4723699f2ef6d1 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityLikelihood.lean @@ -0,0 +1,146 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitions +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Algebra.GroupWithZero.Units.Basic +import Mathlib.Basic.Real.Basic + +namespace OAI + +/-! +# Likelihood of an actual move of colors + +The full guarded profile records every changed coordinate exactly once. +Grouping the coordinate likelihood factors by that profile gives the precise +ratio used by the selector estimate. +-/ + +noncomputable section + +open scoped BigOperators + +namespace TalagrandThreshold + +open Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] {s : ℕ} + +omit [DecidableEq α] in +/-- Group a product over changed vertices by the actual full profile. -/ +theorem prod_profile_eq_prod_changes (a z : Coloring α s) + (F : Color s → Color s → ℝ) : + (∏ i : Fin s, ∏ h : Color s, F i.castSucc h ^ profile a z i h) = + ∏ x ∈ changes a z, F (z x) (a x) := by + classical + let n (c h : Color s) : ℕ := + (Finset.univ.filter + (fun x : α => z x = c ∧ a x = h ∧ c.val < h.val)).card + have hfiber (c h : Color s) : + (changes a z).filter (fun x => (z x, a x) = (c, h)) = + Finset.univ.filter + (fun x : α => z x = c ∧ a x = h ∧ c.val < h.val) := by + ext x + simp only [changes, Finset.mem_filter, Finset.mem_univ, true_and, Prod.mk.injEq, + Fin.lt_def] + constructor + · rintro ⟨hx, hz, ha⟩ + exact ⟨hz, ha, by simpa only [hz, ha] using hx⟩ + · rintro ⟨hz, ha, hch⟩ + exact ⟨by simpa only [hz, ha] using hch, hz, ha⟩ + have hgroup : + (∏ c : Color s, ∏ h : Color s, F c h ^ n c h) = + ∏ x ∈ changes a z, F (z x) (a x) := by + calc + _ = ∏ ch : Color s × Color s, + F ch.1 ch.2 ^ + ((changes a z).filter (fun x => (z x, a x) = ch)).card := by + rw [Fintype.prod_prod_type] + apply Finset.prod_congr rfl + intro c _ + apply Finset.prod_congr rfl + intro h _ + rw [hfiber c h] + _ = ∏ x ∈ changes a z, F (z x) (a x) := by + simpa only [Finset.prod_const] using + (Finset.prod_fiberwise' (changes a z) + (fun x => (z x, a x)) + (fun ch : Color s × Color s => F ch.1 ch.2)) + have hlast : (∏ h : Color s, F (Fin.last s) h ^ n (Fin.last s) h) = 1 := by + apply Finset.prod_eq_one + intro h _ + have hnot : ¬ (Fin.last s).val < h.val := + Nat.not_lt_of_ge (Nat.le_of_lt_succ h.isLt) + simp only [n, hnot, and_false, Finset.filter_false, Finset.card_empty, pow_zero] + have hcount (i : Fin s) (h : Color s) : n i.castSucc h = profile a z i h := by + simp only [n, profile, Fin.ext_iff, Fin.val_castSucc] + rw [Fin.prod_univ_castSucc, hlast, mul_one] at hgroup + simpa only [hcount] using hgroup + +omit [DecidableEq α] in +/-- The profile exponent is the product of one p-factor per actual changed vertex. -/ +theorem pow_profileSize_eq_prod_changes (p : ℝ) (a z : Coloring α s) : + p ^ profileSize (profile a z) = ∏ _x ∈ changes a z, p := by + calc + _ = ∏ i : Fin s, ∏ h : Color s, p ^ profile a z i h := by + simp only [Finset.prod_pow_eq_pow_sum, profileSize, rowCount] + _ = ∏ _x ∈ changes a z, p := + prod_profile_eq_prod_changes a z (fun _ _ => p) + +omit [DecidableEq α] in +/-- Exact likelihood regrouping for the original independent color law and an +actual move to earlier colors. Each source row retains all original-color counts. -/ +theorem colorMass_profile_likelihood (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (a z : Coloring α s) (haz : Selector.Earlier a z) : + p ^ Selector.profileSize (Selector.profile a z) * colorMass p s a = + colorMass p s z * ∏ i : Fin s, + ((p / colorProb p s i.castSucc) ^ Selector.rowCount (Selector.profile a z) i * + ∏ h : Color s, (colorProb p s h) ^ Selector.profile a z i h) := by + classical + have hpowers : p ^ profileSize (profile a z) = + ∏ x : α, if z x < a x then p else 1 := by + calc + _ = ∏ _x ∈ changes a z, p := pow_profileSize_eq_prod_changes p a z + _ = ∏ x : α, if z x < a x then p else 1 := + Finset.prod_filter (fun x => z x < a x) (fun _ => p) + have hratios : + (∏ x ∈ changes a z, (p / colorProb p s (z x)) * colorProb p s (a x)) = + ∏ x : α, if z x < a x then + (p / colorProb p s (z x)) * colorProb p s (a x) else 1 := + Finset.prod_filter (fun x => z x < a x) + (fun x => (p / colorProb p s (z x)) * colorProb p s (a x)) + have hpoint (x : α) : + (if z x < a x then p else 1) * colorProb p s (a x) = + colorProb p s (z x) * (if z x < a x then + (p / colorProb p s (z x)) * colorProb p s (a x) else 1) := by + by_cases h : z x < a x + · rw [ite_eq_left h, ite_eq_left h, ← mul_assoc, + mul_div_cancel₀ p (ne_of_gt (colorProb_pos p s hp hs (z x)))] + · have heq : z x = a x := le_antisymm (haz x) (le_of_not_gt h) + simp only [heq, lt_self_iff_false, ite_false, one_mul, mul_one] + calc + _ = ∏ x : α, (if z x < a x then p else 1) * colorProb p s (a x) := by + rw [hpowers, colorMass, Finset.prod_mul_distrib] + _ = ∏ x : α, colorProb p s (z x) * (if z x < a x then + (p / colorProb p s (z x)) * colorProb p s (a x) else 1) := by + apply Finset.prod_congr rfl + intro x _ + exact hpoint x + _ = colorMass p s z * + ∏ x ∈ changes a z, (p / colorProb p s (z x)) * colorProb p s (a x) := by + rw [Finset.prod_mul_distrib, ← hratios, colorMass] + _ = colorMass p s z * + ∏ i : Fin s, ∏ h : Color s, + ((p / colorProb p s i.castSucc) * colorProb p s h) ^ profile a z i h := by + rw [prod_profile_eq_prod_changes a z + (fun c h => (p / colorProb p s c) * colorProb p s h)] + _ = colorMass p s z * ∏ i : Fin s, + ((p / colorProb p s i.castSucc) ^ rowCount (profile a z) i * + ∏ h : Color s, (colorProb p s h) ^ profile a z i h) := by + congr 1 + apply Finset.prod_congr rfl + intro i _ + simp only [mul_pow, Finset.prod_mul_distrib, Finset.prod_pow_eq_pow_sum, rowCount] + +end TalagrandThreshold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityProduct.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..7980a2787acf1929adcc2d202ace10cc94f8bc31 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilityProduct.lean @@ -0,0 +1,143 @@ +import OAI.Combinatorics.ExpectationThreshold.ProbabilityFinite +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Algebra.BigOperators.GroupWithZero.Finset + +namespace OAI + +/-! +# Marginals and pushforwards of finite product laws + +Product moments, one-coordinate marginals, and pushforward identities follow +from the weights of the finite laws. +-/ + +open scoped BigOperators +noncomputable section +attribute [local instance] Classical.propDecidable + +namespace TalagrandThreshold.FiniteLaw + +section ProductCoordinates + +variable {I : Type*} [Fintype I] [DecidableEq I] + {A : I → Type*} [∀ i, Fintype (A i)] + +/-- Product observables factor under the product of the given finite laws. -/ +theorem expectation_pi_product (μ : ∀ i, FiniteLaw (A i)) + (f : ∀ i, A i → ℝ) : + (pi μ).expectation (fun ω => ∏ i, f i (ω i)) = + ∏ i, (μ i).expectation (f i) := by + classical + simp only [expectation, pi_weight] + simp_rw [← Finset.prod_mul_distrib] + exact (Fintype.prod_sum (fun i a => (μ i).weight a * f i a)).symm + +/-- A coordinate of the product law has exactly its prescribed marginal. -/ +theorem expectation_pi_coordinate (μ : ∀ i, FiniteLaw (A i)) + (i : I) (f : A i → ℝ) : + (pi μ).expectation (fun ω => f (ω i)) = (μ i).expectation f := by + classical + let g : ∀ j, A j → ℝ := fun j a => if h : j = i then f (h ▸ a) else 1 + have hg (ω : ∀ j, A j) : (∏ j, g j (ω j)) = f (ω i) := by + dsimp only [g] + simp only [Fintype.prod_dite_eq'] + have he (j : I) : (μ j).expectation (g j) = + if h : j = i then (μ i).expectation f else 1 := by + by_cases h : j = i + · subst j + simp [g] + · simp [g, h, expectation_const] + calc + _ = (pi μ).expectation (fun ω => ∏ j, g j (ω j)) := by + congr 1 + funext ω + exact (hg ω).symm + _ = ∏ j, (μ j).expectation (g j) := expectation_pi_product μ g + _ = _ := by simp_rw [he]; simp + +/-- Events depending on one coordinate have their original probabilities. -/ +theorem prob_pi_coordinate (μ : ∀ i, FiniteLaw (A i)) + (i : I) (P : A i → Prop) : + (pi μ).prob (fun ω => P (ω i)) = (μ i).prob P := by + classical + rw [prob_eq_expectation, prob_eq_expectation] + exact expectation_pi_coordinate μ i (fun a => if P a then 1 else 0) + +/-- A cylinder event has the product of its coordinate probabilities. -/ +theorem prob_pi (μ : ∀ i, FiniteLaw (A i)) (P : ∀ i, A i → Prop) : + (pi μ).prob (fun ω => ∀ i, P i (ω i)) = ∏ i, (μ i).prob (P i) := by + classical + rw [prob_eq_expectation] + calc + _ = (pi μ).expectation (fun ω => ∏ i, if P i (ω i) then 1 else 0) := by + congr 1 + funext ω + symm + by_cases h : ∀ i, P i (ω i) + · simpa only [ite_eq_left h] using + (Fintype.prod_boole (p := fun i => P i (ω i)) (M₀ := ℝ)) + · simpa only [ite_eq_right h] using + (Fintype.prod_boole (p := fun i => P i (ω i)) (M₀ := ℝ)) + _ = ∏ i, (μ i).expectation (fun a => if P i a then 1 else 0) := + expectation_pi_product μ (fun i a => if P i a then 1 else 0) + _ = _ := by simp_rw [prob_eq_expectation] + +end ProductCoordinates + +variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + +/-- Rectangle events factor under the binary product law. -/ +theorem prob_prod (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) + (P : Ω → Prop) (Q : Γ → Prop) : + (μ.prod ν).prob (fun z => P z.1 ∧ Q z.2) = μ.prob P * ν.prob Q := by + classical + simp only [prob, prod, Fintype.sum_prod_type] + calc + _ = ∑ ω, ∑ γ, + (if P ω then μ.weight ω else 0) * (if Q γ then ν.weight γ else 0) := by + apply Finset.sum_congr rfl + intro ω _ + apply Finset.sum_congr rfl + intro γ _ + by_cases hp : P ω <;> by_cases hq : Q γ <;> simp [hp, hq] + _ = _ := by + simp_rw [← Finset.mul_sum] + rw [← Finset.sum_mul] + +/-- Pushforward by summing the source weights in each fiber. -/ +def map (μ : FiniteLaw Ω) (f : Ω → Γ) : FiniteLaw Γ where + weight γ := ∑ ω, if f ω = γ then μ.weight ω else 0 + nonneg γ := Finset.sum_nonneg fun ω _ => by + split_ifs + · exact μ.nonneg ω + · exact le_rfl + total := by + rw [Finset.sum_comm] + simpa using μ.total + +@[simp] theorem map_weight (μ : FiniteLaw Ω) (f : Ω → Γ) (γ : Γ) : + (map μ f).weight γ = ∑ ω, if f ω = γ then μ.weight ω else 0 := rfl + +theorem map_weight_eq_prob (μ : FiniteLaw Ω) (f : Ω → Γ) (γ : Γ) : + (map μ f).weight γ = μ.prob (fun ω => f ω = γ) := rfl + +/-- Observables of a pushed law are evaluated along the defining map. -/ +theorem expectation_map (μ : FiniteLaw Ω) (f : Ω → Γ) (g : Γ → ℝ) : + (map μ f).expectation g = μ.expectation (fun ω => g (f ω)) := by + unfold expectation + simp only [map_weight, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro ω _ + simp [ite_mul] + +/-- The probability of an event under a pushed law is its preimage probability. -/ +theorem prob_map (μ : FiniteLaw Ω) (f : Ω → Γ) (P : Γ → Prop) : + (map μ f).prob P = μ.prob (fun ω => P (f ω)) := by + rw [prob_eq_expectation, expectation_map, prob_eq_expectation] + +end TalagrandThreshold.FiniteLaw + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilitySubsetProduct.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilitySubsetProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..81ade06dc31b32eb64d2259d10c4258d410cf3fe --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ProbabilitySubsetProduct.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.ExpectationThreshold.ProbabilityProduct + +namespace OAI + +/-! +# Moments of products on a subset of coordinates + +Under the actual product law, observables supported on a finite subset +factor into their coordinate expectations. Extending the factors by one +outside the subset reduces this to the full product moment identity. +-/ + +open scoped BigOperators +noncomputable section + +namespace TalagrandThreshold.FiniteLaw + +variable {I : Type*} [Fintype I] [DecidableEq I] + {A : I → Type*} [∀ i, Fintype (A i)] + +/-- A product on a subset has the product of its actual coordinate means. -/ +theorem expectation_pi_subset_product (μ : ∀ i, FiniteLaw (A i)) + (S : Finset I) (f : ∀ i, A i → ℝ) : + (pi μ).expectation (fun ω => ∏ i ∈ S, f i (ω i)) = + ∏ i ∈ S, (μ i).expectation (f i) := by + classical + let g : ∀ i, A i → ℝ := fun i a => if i ∈ S then f i a else 1 + have hg (ω : ∀ i, A i) : (∏ i, g i (ω i)) = ∏ i ∈ S, f i (ω i) := by + simpa only [g] using Fintype.prod_ite_mem S (fun i => f i (ω i)) + have he (i : I) : (μ i).expectation (g i) = + if i ∈ S then (μ i).expectation (f i) else 1 := by + by_cases hi : i ∈ S + · simp only [g, ite_eq_left hi] + · simp only [g, ite_eq_right hi, expectation_const] + calc + _ = (pi μ).expectation (fun ω => ∏ i, g i (ω i)) := by + congr 1 + funext ω + exact (hg ω).symm + _ = ∏ i, (μ i).expectation (g i) := expectation_pi_product μ g + _ = ∏ i ∈ S, (μ i).expectation (f i) := by + simp only [he, Finset.prod_ite_mem_eq] + +/-- Equal coordinate means give the corresponding power of the subset size. -/ +theorem expectation_pi_subset_product_of_mean (μ : ∀ i, FiniteLaw (A i)) + (S : Finset I) (f : ∀ i, A i → ℝ) (a : ℝ) + (hmean : ∀ i ∈ S, (μ i).expectation (f i) = a) : + (pi μ).expectation (fun ω => ∏ i ∈ S, f i (ω i)) = a ^ S.card := by + rw [expectation_pi_subset_product] + calc + (∏ i ∈ S, (μ i).expectation (f i)) = ∏ _i ∈ S, a := + Finset.prod_congr rfl hmean + _ = a ^ S.card := Finset.prod_const a + +/-- Identically distributed coordinates give a power of their common mean. -/ +theorem expectation_pi_subset_product_const {Ω : Type*} [Fintype Ω] + (μ : FiniteLaw Ω) (S : Finset I) (f : Ω → ℝ) : + (pi (fun _ : I => μ)).expectation (fun ω => ∏ i ∈ S, f (ω i)) = + (μ.expectation f) ^ S.card := by + rw [expectation_pi_subset_product, Finset.prod_const] + +end TalagrandThreshold.FiniteLaw + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/RoundingColorProducts.lean b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingColorProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..2226af1639bb3415634e6950c36b83ef97322699 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingColorProducts.lean @@ -0,0 +1,40 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Algebra.Order.Field.Basic +import Mathlib.Tactic.NormNum + +namespace OAI + +/-! +# Products controlled by the total color level + +The numerical color variable is a quotient of powers. This retains its correct +value when a color level exceeds four, without truncated natural subtraction. +Only the total level over the selected finite set enters the product bound. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +variable {α : Type*} + +/-- Separate the fixed numerator from the sum of all color exponents. -/ +theorem colorProduct_eq_pow_div_pow (S : Finset α) (a : α → ℕ) : + (∏ x ∈ S, (512 : ℝ) ^ 4 / (512 : ℝ) ^ a x) = + (512 : ℝ) ^ (4 * S.card) / (512 : ℝ) ^ (∑ x ∈ S, a x) := by + rw [Finset.prod_div_distrib (s := S) + (fun _ : α => (512 : ℝ) ^ 4) (fun x : α => (512 : ℝ) ^ a x)] + rw [Finset.prod_const, Finset.prod_pow_eq_pow_sum S a (512 : ℝ), ← pow_mul] + +/-- Average color at most four forces the numerical product to be at least one. -/ +theorem one_le_colorProduct_of_sum_le (S : Finset α) (a : α → ℕ) + (hsum : (∑ x ∈ S, a x) ≤ 4 * S.card) : + 1 ≤ ∏ x ∈ S, (512 : ℝ) ^ 4 / (512 : ℝ) ^ a x := by + rw [colorProduct_eq_pow_div_pow S a] + apply (one_le_div (pow_pos (by norm_num : (0 : ℝ) < 512) _)).mpr + exact pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 512) hsum + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/RoundingExpectation.lean b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..228b670cdca7a75c2ad418fd3e4ca38f60369223 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingExpectation.lean @@ -0,0 +1,116 @@ +import OAI.Combinatorics.ExpectationThreshold.Basic +import OAI.Combinatorics.ExpectationThreshold.ProbabilitySubsetProduct +import Mathlib.Algebra.Order.GroupWithZero.Basic +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# The upper expectation bound for rounding + +The score sums over nonempty subsets of the original ground set. Its moments +come from the actual coordinate product law. Nonemptiness saves a factor of +one fifth in the fractional-cover cost. +-/ + +open scoped BigOperators + +namespace TalagrandThreshold + +noncomputable section + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- The nonnegative subset-product score used by the rounding argument. -/ +def productScore (g : Finset α → ℝ) (Y : α → ℝ) : ℝ := + ∑ S ∈ (Finset.univ.erase ∅ : Finset (Finset α)), g S * ∏ x ∈ S, Y x + +theorem productScore_nonneg {g : Finset α → ℝ} {Y : α → ℝ} + (hg : ∀ S, 0 ≤ g S) (hY : ∀ x, 0 ≤ Y x) : 0 ≤ productScore g Y := by + exact Finset.sum_nonneg fun S _ => + mul_nonneg (hg S) (Finset.prod_nonneg fun x _ => hY x) + +variable {Ω : Type*} [Fintype Ω] + +/-- Independence of the coordinates gives the full subset-product expectation. -/ +theorem expectation_productScore (ν : FiniteLaw Ω) (g : Finset α → ℝ) (Y : Ω → ℝ) : + (FiniteLaw.pi (fun _ : α => ν)).expectation + (fun ω => productScore g (fun x => Y (ω x))) = + ∑ S ∈ (Finset.univ.erase ∅ : Finset (Finset α)), + g S * (ν.expectation Y) ^ S.card := by + classical + calc + _ = ∑ S ∈ (Finset.univ.erase ∅ : Finset (Finset α)), + (FiniteLaw.pi (fun _ : α => ν)).expectation + (fun ω => g S * ∏ x ∈ S, Y (ω x)) := by + unfold FiniteLaw.expectation productScore + simp only [Finset.mul_sum] + exact Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl + intro S _ + rw [FiniteLaw.expectation_smul, FiniteLaw.expectation_pi_subset_product_const] + +/-- A nonempty product gains at least one factor of one fifth. -/ +theorem one_fifth_pow_le {r : ℝ} (hr : 0 ≤ r) {k : ℕ} (hk : 0 < k) : + (r / 5) ^ k ≤ (1 / 5) * r ^ k := by + have hsmall : (1 / 5 : ℝ) ^ k ≤ 1 / 5 := + pow_le_of_le_one (by norm_num) (by norm_num) (Nat.ne_of_gt hk) + calc + (r / 5) ^ k = (1 / 5 : ℝ) ^ k * r ^ k := by + rw [← mul_pow] + congr 1 + ring + _ ≤ (1 / 5) * r ^ k := mul_le_mul_of_nonneg_right hsmall (pow_nonneg hr k) + +/-- The product score costs at most one fifth of the fractional-cover cost. -/ +theorem expectation_productScore_le (ν : FiniteLaw Ω) (g : Finset α → ℝ) + (Y : Ω → ℝ) {r : ℝ} (hg : ∀ S, 0 ≤ g S) (hY : ∀ ω, 0 ≤ Y ω) + (hr : 0 ≤ r) (hmean : ν.expectation Y ≤ r / 5) : + (FiniteLaw.pi (fun _ : α => ν)).expectation + (fun ω => productScore g (fun x => Y (ω x))) ≤ + (1 / 5) * fracCost r g := by + classical + have hmean0 := ν.expectation_nonneg hY + rw [expectation_productScore] + calc + (∑ S ∈ (Finset.univ.erase ∅ : Finset (Finset α)), + g S * (ν.expectation Y) ^ S.card) ≤ + ∑ S ∈ (Finset.univ.erase ∅ : Finset (Finset α)), + (1 / 5) * (g S * r ^ S.card) := by + apply Finset.sum_le_sum + intro S hS + have hne : S.Nonempty := + Finset.nonempty_iff_ne_empty.mpr (Finset.mem_erase.mp hS).1 + have hpower : (ν.expectation Y) ^ S.card ≤ (1 / 5) * r ^ S.card := + (pow_le_pow_left₀ hmean0 hmean S.card).trans + (one_fifth_pow_le hr (Finset.card_pos.mpr hne)) + calc + g S * (ν.expectation Y) ^ S.card ≤ g S * ((1 / 5) * r ^ S.card) := + mul_le_mul_of_nonneg_left hpower (hg S) + _ = (1 / 5) * (g S * r ^ S.card) := by ring + _ = (1 / 5) * ∑ S ∈ (Finset.univ.erase ∅ : Finset (Finset α)), + g S * r ^ S.card := (Finset.mul_sum _ _ _).symm + _ ≤ (1 / 5) * fracCost r g := by + apply mul_le_mul_of_nonneg_left _ (by norm_num : (0 : ℝ) ≤ 1 / 5) + unfold fracCost + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.erase_subset _ _) + (fun S _ _ => mul_nonneg (hg S) (pow_nonneg hr S.card)) + +/-- The budget one half gives the upper bound one tenth for the same score. -/ +theorem expectation_productScore_le_tenth (ν : FiniteLaw Ω) (g : Finset α → ℝ) + (Y : Ω → ℝ) {r : ℝ} (hg : ∀ S, 0 ≤ g S) (hY : ∀ ω, 0 ≤ Y ω) + (hr : 0 ≤ r) (hmean : ν.expectation Y ≤ r / 5) (hcost : fracCost r g ≤ 1 / 2) : + (FiniteLaw.pi (fun _ : α => ν)).expectation + (fun ω => productScore g (fun x => Y (ω x))) ≤ 1 / 10 := by + calc + _ ≤ (1 / 5) * fracCost r g := expectation_productScore_le ν g Y hg hY hr hmean + _ ≤ (1 / 5 : ℝ) * (1 / 2) := + mul_le_mul_of_nonneg_left hcost (by norm_num : (0 : ℝ) ≤ 1 / 5) + _ = 1 / 10 := by norm_num + +end +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/RoundingLowerBound.lean b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingLowerBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..339df1663a14975a84669b7a974cfdecf78876a6 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingLowerBound.lean @@ -0,0 +1,117 @@ +import OAI.Combinatorics.ExpectationThreshold.RoundingMasses +import OAI.Combinatorics.ExpectationThreshold.RoundingColorProducts +import OAI.Combinatorics.ExpectationThreshold.RoundingExpectation +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum + +namespace OAI + +/-! +# The deterministic lower bound for rounding + +A weighted average at most two places at least half the mass on subsets with +average at most four. On those subsets the quotient-of-powers product is at +least one, yielding the lower bound one quarter for the full product score. +This statement is pointwise in the coloring and needs no independence premise. +-/ + +open scoped BigOperators + +namespace TalagrandThreshold + +/-- Finite weighted Markov inequality in the form used by rounding. -/ +theorem half_mass_of_weighted_average_le {β : Type*} (T : Finset β) + (w v : β → ℝ) (hw : ∀ i ∈ T, 0 ≤ w i) (hv : ∀ i ∈ T, 0 ≤ v i) + (hmean : (∑ i ∈ T, w i * v i) ≤ 2 * (∑ i ∈ T, w i)) : + (∑ i ∈ T, w i) / 2 ≤ ∑ i ∈ T.filter (fun i => v i ≤ 4), w i := by + classical + have hpoint (i : β) (hi : i ∈ T) : + 4 * w i ≤ w i * v i + 4 * (if v i ≤ 4 then w i else 0) := by + by_cases hgood : v i ≤ 4 + · simp only [ite_eq_left hgood] + have hnonneg := mul_nonneg (hw i hi) (hv i hi) + linarith + · simp only [ite_eq_right hgood, mul_zero, add_zero] + calc + 4 * w i = w i * 4 := mul_comm _ _ + _ ≤ w i * v i := + mul_le_mul_of_nonneg_left (le_of_lt (lt_of_not_ge hgood)) (hw i hi) + have hsum : 4 * (∑ i ∈ T, w i) ≤ + (∑ i ∈ T, w i * v i) + 4 * (∑ i ∈ T.filter (fun i => v i ≤ 4), w i) := by + calc + _ = ∑ i ∈ T, 4 * w i := Finset.mul_sum _ _ _ + _ ≤ ∑ i ∈ T, (w i * v i + 4 * (if v i ≤ 4 then w i else 0)) := + Finset.sum_le_sum hpoint + _ = _ := by + simp only [Finset.sum_add_distrib, Finset.mul_sum, Finset.sum_filter, + mul_ite, mul_zero] + linarith + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [Fintype α] [DecidableEq α] in +theorem subsetAverage_nat_nonneg (a : α → ℕ) (S : Finset α) : + 0 ≤ subsetAverage (fun x => (a x : ℝ)) S := by + unfold subsetAverage + exact div_nonneg (Finset.sum_nonneg (fun x _ => Nat.cast_nonneg (a x))) + (Nat.cast_nonneg S.card) + +omit [Fintype α] [DecidableEq α] in +theorem sum_le_four_card_of_subsetAverage_le (a : α → ℕ) {S : Finset α} + (hS : S.Nonempty) (haverage : subsetAverage (fun x => (a x : ℝ)) S ≤ 4) : + (∑ x ∈ S, a x) ≤ 4 * S.card := by + have hcard : (0 : ℝ) < S.card := Nat.cast_pos.mpr (Finset.card_pos.mpr hS) + have hreal : (∑ x ∈ S, (a x : ℝ)) ≤ 4 * (S.card : ℝ) := + (div_le_iff₀ hcard).mp haverage + exact_mod_cast hreal + +/-- The fractional member mass and its mean color force a product-score lower +bound. Natural colors can include zero; the actual selector uses `val + 1`. -/ +theorem productScore_lower_of_mean (g : Finset α → ℝ) (H : Finset α) + (a : α → ℕ) (hg : ∀ S, 0 ≤ g S) (hMH : (1 / 2 : ℝ) ≤ memberMass g H) + (hmean : (∑ x : α, (a x : ℝ) * roundingMass g H x) ≤ 2) : + (1 / 4 : ℝ) ≤ productScore g (fun x => (512 : ℝ) ^ 4 / (512 : ℝ) ^ a x) := by + classical + have hMpos : 0 < memberMass g H := by linarith + have hweighted : + (∑ S ∈ nonemptySubsets H, g S * subsetAverage (fun x => (a x : ℝ)) S) ≤ + 2 * memberMass g H := by + apply (div_le_iff₀ hMpos).mp + rw [← roundingMass_mean g H (fun x => (a x : ℝ))] + exact hmean + let G := (nonemptySubsets H).filter + (fun S => subsetAverage (fun x => (a x : ℝ)) S ≤ 4) + have hgood : memberMass g H / 2 ≤ ∑ S ∈ G, g S := by + simpa only [G, memberMass] using + half_mass_of_weighted_average_le (nonemptySubsets H) g + (fun S => subsetAverage (fun x => (a x : ℝ)) S) + (fun S _ => hg S) (fun S _ => subsetAverage_nat_nonneg a S) hweighted + have hsub : G ⊆ (Finset.univ.erase ∅ : Finset (Finset α)) := by + intro S hS + have hS' : S ∈ nonemptySubsets H := (Finset.mem_filter.mp hS).1 + have hSne : S ≠ ∅ := (mem_nonemptySubsets.mp hS').1 + exact Finset.mem_erase.mpr ⟨hSne, Finset.mem_univ S⟩ + have hproduct (S : Finset α) (hS : S ∈ G) : + 1 ≤ ∏ x ∈ S, (512 : ℝ) ^ 4 / (512 : ℝ) ^ a x := by + have hS' := Finset.mem_filter.mp hS + have hSne : S ≠ ∅ := (mem_nonemptySubsets.mp hS'.1).1 + exact one_le_colorProduct_of_sum_le S a + (sum_le_four_card_of_subsetAverage_le a + (Finset.nonempty_iff_ne_empty.mpr hSne) hS'.2) + have hY (x : α) : 0 ≤ (512 : ℝ) ^ 4 / (512 : ℝ) ^ a x := + div_nonneg (pow_nonneg (by norm_num) _) (pow_nonneg (by norm_num) _) + calc + (1 / 4 : ℝ) ≤ memberMass g H / 2 := by linarith + _ ≤ ∑ S ∈ G, g S := hgood + _ ≤ ∑ S ∈ G, g S * ∏ x ∈ S, (512 : ℝ) ^ 4 / (512 : ℝ) ^ a x := by + apply Finset.sum_le_sum + intro S hS + simpa only [mul_one] using mul_le_mul_of_nonneg_left (hproduct S hS) (hg S) + _ ≤ productScore g (fun x => (512 : ℝ) ^ 4 / (512 : ℝ) ^ a x) := by + unfold productScore + exact Finset.sum_le_sum_of_subset_of_nonneg hsub + (fun S _ _ => mul_nonneg (hg S) (Finset.prod_nonneg (fun x _ => hY x))) + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/RoundingMain.lean b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..a374971befa79d89bfe1ce7297ebea71720aaf6a --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingMain.lean @@ -0,0 +1,110 @@ +import OAI.Combinatorics.ExpectationThreshold.RoundingMasses +import OAI.Combinatorics.ExpectationThreshold.RoundingLowerBound +import OAI.Combinatorics.ExpectationThreshold.RoundingProbabilityContradiction +import OAI.Combinatorics.ExpectationThreshold.ColorMean +import OAI.Combinatorics.ExpectationThreshold.SelectorMain + +namespace OAI + +/-! +# Actual rounding of an unrestricted fractional cover + +The concrete member masses feed the proved multiscale selector. The same +independent color law supplies the lower and upper bounds on the subset-product +score. No selector hypothesis or bound on support sizes appears in the result. +-/ + +open scoped BigOperators + +noncomputable section + +namespace TalagrandThreshold + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [DecidableEq α] in +theorem fractionalCover_empty_not_mem {F : Family α} {g : Finset α → ℝ} {r : ℝ} + (hr : 0 ≤ r) (hcover : FractionalCover F g) (hcost : fracCost r g ≤ 1 / 2) : + (∅ : Finset α) ∉ F := by + intro hempty + have hcoverEmpty : (1 : ℝ) ≤ g ∅ := by + simpa only [Finset.powerset_empty, Finset.sum_singleton] using hcover.2 ∅ hempty + have hweight : g ∅ ≤ (1 / 2 : ℝ) := + (empty_weight_le_fracCost hr hcover.nonneg).trans hcost + exact (by norm_num : ¬ ((1 : ℝ) ≤ 1 / 2)) (hcoverEmpty.trans hweight) + +/-- The actual normalized probability masses attached to family members. -/ +def fractionalMassFamily (F : Family α) (g : Finset α → ℝ) {r : ℝ} + (hr : 0 ≤ r) (hcover : FractionalCover F g) (hcost : fracCost r g ≤ 1 / 2) : + Selector.MassFamily F where + weight H := roundingMass g H.val + nonneg H x := roundingMass_nonneg g H.val hcover.nonneg + (memberMass_pos_of_fractionalCover hcover H.property hr hcost) x + total H := roundingMass_sum g H.val + (memberMass_pos_of_fractionalCover hcover H.property hr hcost) + supported H _ hx := roundingMass_eq_zero_of_not_mem g H.val hx + +/-- Every fractional cover of cost at most one half rounds at the exact +parameter `r / (25 * 512^4)`. Its support may contain subsets of any size. -/ +theorem fractionalCover_rounding (F : Family α) (g : Finset α → ℝ) {r : ℝ} + (hr0 : 0 < r) (hr1 : r ≤ 1) (hcover : FractionalCover F g) + (hcost : fracCost r g ≤ 1 / 2) : + Small (r / ((25 : ℝ) * (512 : ℝ) ^ 4)) F := by + classical + by_cases hF : F.Nonempty + · let p : ℝ := r / ((25 : ℝ) * (512 : ℝ) ^ 4) + have hp0 : 0 < p := div_pos hr0 rounding_constant_pos + have hp1 : p ≤ 1 := (div_le_one rounding_constant_pos).mpr + (hr1.trans (by norm_num : (1 : ℝ) ≤ (25 : ℝ) * (512 : ℝ) ^ 4)) + have hnoempty := fractionalCover_empty_not_mem hr0.le hcover hcost + let mu := fractionalMassFamily F g hr0.le hcover hcost + obtain ⟨s, hs, hnext⟩ := exists_scale hp0 + let μ := coloringLaw (α := α) p s hp0 hs + let Y : Color s → ℝ := fun c => (512 : ℝ) ^ 4 / (512 : ℝ) ^ (c.val + 1) + let Z : Coloring α s → ℝ := fun a => productScore g (fun x => Y (a x)) + let P : Coloring α s → Prop := fun a => ∃ H : ↥F, Selector.meanColor mu H a ≤ 2 + change Small p F + by_contra hnotsmall + have hprob : (9 / 10 : ℝ) ≤ μ.prob P := + Selector.average_color F hF (fun H hH => members_nonempty hnoempty hH) + mu p hp0 hp1 hnotsmall s hs + have hY : ∀ c, 0 ≤ Y c := by + intro c + exact div_nonneg (pow_nonneg (by norm_num) _) (pow_nonneg (by norm_num) _) + have hZ : ∀ a, 0 ≤ Z a := fun a => + productScore_nonneg hcover.nonneg (fun x => hY (a x)) + have hlower : ∀ a, P a → (1 / 4 : ℝ) ≤ Z a := by + intro a ha + obtain ⟨H, hH⟩ := ha + apply productScore_lower_of_mean g H.val (fun x => (a x).val + 1) hcover.nonneg + (memberMass_ge_half hcover H.property hr0.le hcost) + simpa only [Selector.meanColor, mu, fractionalMassFamily, Nat.cast_add, + Nat.cast_one] using hH + have hmean : (colorLaw p s hp0 hs).expectation Y ≤ r / 5 := by + change (∑ c : Color s, + colorProb p s c * ((512 : ℝ) ^ 4 / (512 : ℝ) ^ (c.val + 1))) ≤ r / 5 + exact color_mean_le_r_div_five hr0 hs hnext + have hupper : μ.expectation Z ≤ (1 / 10 : ℝ) := + expectation_productScore_le_tenth (colorLaw p s hp0 hs) g Y + hcover.nonneg hY hr0.le hmean hcost + exact rounding_expectation_contradiction μ P Z hZ hprob hlower hupper + · have hFempty : F = ∅ := Finset.not_nonempty_iff_eq_empty.mp hF + rw [hFempty] + exact small_empty _ + +/-- Parameterwise rounding also includes density zero, with an actual cover. -/ +theorem fractionalSmall_rounding (F : Family α) {r : ℝ} + (hr0 : 0 ≤ r) (hr1 : r ≤ 1) (hF : FractionalSmall r F) : + Small (r / ((25 : ℝ) * (512 : ℝ) ^ 4)) F := by + obtain ⟨g, hcover, hcost⟩ := hF + by_cases hr : r = 0 + · subst r + rw [zero_div] + exact small_zero F (fractionalCover_empty_not_mem le_rfl hcover hcost) + · exact fractionalCover_rounding F g (lt_of_le_of_ne hr0 (Ne.symm hr)) hr1 hcover hcost + +end TalagrandThreshold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/RoundingMasses.lean b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingMasses.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c5f76d3b792cdb3e5d8a2ff9263a5b86d61bbbe --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingMasses.lean @@ -0,0 +1,151 @@ +import OAI.Combinatorics.ExpectationThreshold.Basic +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Concrete rounding masses + +Each nonempty subset's fractional weight is split equally among its members. +Normalizing by the total nonempty-subset weight gives the probability mass used +by the common selector. Both normalization and the mean identity are finite +double-sum calculations. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable section + +def nonemptySubsets (H : Finset α) : Finset (Finset α) := H.powerset.erase ∅ + +def memberMass (g : Finset α → ℝ) (H : Finset α) : ℝ := + ∑ S ∈ nonemptySubsets H, g S + +def subsetAverage (a : α → ℝ) (S : Finset α) : ℝ := + (∑ x ∈ S, a x) / (S.card : ℝ) + +def roundingMass (g : Finset α → ℝ) (H : Finset α) (x : α) : ℝ := + (∑ S ∈ nonemptySubsets H, if x ∈ S then g S / (S.card : ℝ) else 0) / + memberMass g H + +omit [Fintype α] in +@[simp] theorem mem_nonemptySubsets {S H : Finset α} : + S ∈ nonemptySubsets H ↔ S ≠ ∅ ∧ S ⊆ H := by + simp only [nonemptySubsets, Finset.mem_erase, Finset.mem_powerset] + +omit [Fintype α] in +theorem memberMass_add_empty (g : Finset α → ℝ) (H : Finset α) : + memberMass g H + g ∅ = ∑ S ∈ H.powerset, g S := by + exact Finset.sum_erase_add H.powerset g (Finset.empty_mem_powerset H) + +omit [Fintype α] in +theorem memberMass_nonneg {g : Finset α → ℝ} (hg : ∀ S, 0 ≤ g S) + (H : Finset α) : 0 ≤ memberMass g H := + Finset.sum_nonneg (fun S _ => hg S) + +omit [DecidableEq α] in +theorem empty_weight_le_half {r : ℝ} {g : Finset α → ℝ} + (hr : 0 ≤ r) (hg : ∀ S, 0 ≤ g S) (hcost : fracCost r g ≤ 1 / 2) : + g ∅ ≤ 1 / 2 := + (empty_weight_le_fracCost hr hg).trans hcost + +theorem memberMass_ge_half {F : Family α} {g : Finset α → ℝ} + {H : Finset α} {r : ℝ} (hcover : FractionalCover F g) (hH : H ∈ F) + (hr : 0 ≤ r) (hcost : fracCost r g ≤ 1 / 2) : + 1 / 2 ≤ memberMass g H := by + have hcoverage := hcover.2 H hH + have hempty := empty_weight_le_half hr hcover.nonneg hcost + have hsplit := memberMass_add_empty g H + linarith + +theorem memberMass_pos_of_fractionalCover {F : Family α} {g : Finset α → ℝ} + {H : Finset α} {r : ℝ} (hcover : FractionalCover F g) (hH : H ∈ F) + (hr : 0 ≤ r) (hcost : fracCost r g ≤ 1 / 2) : + 0 < memberMass g H := by + have hmass := memberMass_ge_half hcover hH hr hcost + linarith + +omit [Fintype α] [DecidableEq α] in +theorem subsetAverage_nonneg {a : α → ℝ} (ha : ∀ x, 0 ≤ a x) + (S : Finset α) : 0 ≤ subsetAverage a S := + div_nonneg (Finset.sum_nonneg (fun x _ => ha x)) (Nat.cast_nonneg _) + +omit [Fintype α] in +theorem roundingMass_nonneg (g : Finset α → ℝ) (H : Finset α) + (hg : ∀ S, 0 ≤ g S) (hM : 0 < memberMass g H) (x : α) : + 0 ≤ roundingMass g H x := by + apply div_nonneg _ hM.le + apply Finset.sum_nonneg + intro S _ + split_ifs + · exact div_nonneg (hg S) (Nat.cast_nonneg _) + · exact le_rfl + +omit [Fintype α] in +theorem roundingMass_eq_zero_of_not_mem (g : Finset α → ℝ) (H : Finset α) + {x : α} (hx : x ∉ H) : roundingMass g H x = 0 := by + have hsum : + (∑ S ∈ nonemptySubsets H, if x ∈ S then g S / (S.card : ℝ) else 0) = 0 := by + apply Finset.sum_eq_zero + intro S hS + have hxS : x ∉ S := fun h => hx ((mem_nonemptySubsets.mp hS).2 h) + simp only [ite_eq_right hxS] + unfold roundingMass + rw [hsum, zero_div] + +/-- A nonempty set distributes exactly its original weight. -/ +theorem sum_uniform_subset_weight (g : Finset α → ℝ) (S : Finset α) + (hS : S ≠ ∅) : + (∑ x : α, if x ∈ S then g S / (S.card : ℝ) else 0) = g S := by + have hcard : (S.card : ℝ) ≠ 0 := by + exact Nat.cast_ne_zero.mpr + (Finset.card_ne_zero.mpr (Finset.nonempty_iff_ne_empty.mpr hS)) + rw [Finset.sum_ite_mem_eq, Finset.sum_const, nsmul_eq_mul] + exact mul_div_cancel₀ (g S) hcard + +/-- Counting each set's members evaluates the full double sum. -/ +theorem sum_rounding_numerator (g : Finset α → ℝ) (H : Finset α) : + (∑ x : α, ∑ S ∈ nonemptySubsets H, + if x ∈ S then g S / (S.card : ℝ) else 0) = memberMass g H := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + exact sum_uniform_subset_weight g S (mem_nonemptySubsets.mp hS).1 + +theorem roundingMass_sum (g : Finset α → ℝ) (H : Finset α) + (hM : 0 < memberMass g H) : (∑ x : α, roundingMass g H x) = 1 := by + simp only [roundingMass, ← Finset.sum_div] + rw [sum_rounding_numerator, div_self hM.ne'] + +/-- Averaging one set's distributed weight gives its subset average. -/ +theorem sum_weighted_uniform_subset_weight (g : Finset α → ℝ) + (S : Finset α) (a : α → ℝ) : + (∑ x : α, a x * (if x ∈ S then g S / (S.card : ℝ) else 0)) = + g S * subsetAverage a S := by + simp only [mul_ite, mul_zero] + rw [Finset.sum_ite_mem_eq, ← Finset.sum_mul] + unfold subsetAverage + ring + +theorem roundingMass_mean (g : Finset α → ℝ) (H : Finset α) (a : α → ℝ) : + (∑ x : α, a x * roundingMass g H x) = + (∑ S ∈ nonemptySubsets H, g S * subsetAverage a S) / memberMass g H := by + unfold roundingMass + simp only [← mul_div_assoc, ← Finset.sum_div] + congr 1 + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S _ + exact sum_weighted_uniform_subset_weight g S a + +end +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/RoundingProbabilityContradiction.lean b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingProbabilityContradiction.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c40f152040850a194a6f449073de2999f80312a --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/RoundingProbabilityContradiction.lean @@ -0,0 +1,40 @@ +import OAI.Combinatorics.ExpectationThreshold.ProbabilityFinite +import Mathlib.Tactic.NormNum + +namespace OAI + +/-! +# The numerical contradiction used in rounding + +A nonnegative score bounded below by one quarter on an event of probability +at least nine tenths has expectation at least nine fortieths. +-/ + +namespace TalagrandThreshold + +variable {Ω : Type*} [Fintype Ω] + +theorem expectation_ge_nine_fortieths (μ : FiniteLaw Ω) (P : Ω → Prop) + (Z : Ω → ℝ) (hZ : ∀ ω, 0 ≤ Z ω) (hprob : (9 / 10 : ℝ) ≤ μ.prob P) + (hlower : ∀ ω, P ω → (1 / 4 : ℝ) ≤ Z ω) : + (9 / 40 : ℝ) ≤ μ.expectation Z := by + have hinclusion : μ.prob P ≤ μ.prob (fun ω => (1 / 4 : ℝ) ≤ Z ω) := + μ.prob_mono hlower + have hmarkov := μ.prob_ge_le_expectation_div Z hZ + (by norm_num : (0 : ℝ) < 1 / 4) + have hbound : (9 / 10 : ℝ) ≤ μ.expectation Z / (1 / 4 : ℝ) := + hprob.trans (hinclusion.trans hmarkov) + calc + (9 / 40 : ℝ) = (9 / 10 : ℝ) * (1 / 4 : ℝ) := by norm_num + _ ≤ μ.expectation Z := (le_div_iff₀ (by norm_num : (0 : ℝ) < 1 / 4)).mp hbound + +theorem rounding_expectation_contradiction (μ : FiniteLaw Ω) (P : Ω → Prop) + (Z : Ω → ℝ) (hZ : ∀ ω, 0 ≤ Z ω) (hprob : (9 / 10 : ℝ) ≤ μ.prob P) + (hlower : ∀ ω, P ω → (1 / 4 : ℝ) ≤ Z ω) + (hupper : μ.expectation Z ≤ (1 / 10 : ℝ)) : False := by + have h := (expectation_ge_nine_fortieths μ P Z hZ hprob hlower).trans hupper + exact (by norm_num : ¬ ((9 / 40 : ℝ) ≤ 1 / 10)) h + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ScaleBounds.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ScaleBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..4316e685cdb116722b6faac88c963e74a1d98c39 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ScaleBounds.lean @@ -0,0 +1,143 @@ +import OAI.Combinatorics.ExpectationThreshold.ProbabilityColors +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Data.Nat.Find +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Lean.Elab.Tactic.Omega + +namespace OAI + +/-! +# The largest admissible scale + +The cutoff is constructed as the first index whose next scale fails. +Its existence follows from the Archimedean property and the elementary +lower bound `scaleSum s ≥ s`. No finite search bound or computed large +power is used. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +theorem scaleSum_succ (s : ℕ) : + scaleSum (s + 1) = scaleSum s + (256 : ℝ) ^ (s + 1) := by + simp only [scaleSum, Fin.sum_univ_castSucc, Fin.val_castSucc, Fin.val_last] + +theorem scaleSum_monotone : Monotone scaleSum := by + apply monotone_nat_of_le_succ + intro s + rw [scaleSum_succ] + exact le_add_of_nonneg_right (by positivity) + +theorem scaleSum_ge_nat (s : ℕ) : (s : ℝ) ≤ scaleSum s := by + calc + (s : ℝ) = ∑ _i : Fin s, (1 : ℝ) := by simp + _ ≤ scaleSum s := by + unfold scaleSum + exact Finset.sum_le_sum fun _ _ => one_le_pow₀ (by norm_num : (1 : ℝ) ≤ 256) + +/-- The finite geometric sum is at most twice its largest power. -/ +theorem scaleSum_le_two_pow (s : ℕ) : scaleSum s ≤ 2 * (256 : ℝ) ^ s := by + induction s with + | zero => simp [scaleSum_zero] + | succ s ih => + rw [scaleSum_succ, pow_succ (256 : ℝ) s] + have hpow : 0 ≤ (256 : ℝ) ^ s := by positivity + nlinarith + +private theorem half_geometric_sum_identity (s : ℕ) : + (∑ i : Fin s, (1 / 2 : ℝ) ^ (i.val + 1)) + (1 / 2 : ℝ) ^ s = 1 := by + induction s with + | zero => simp + | succ s ih => + simp only [Fin.sum_univ_castSucc, Fin.val_castSucc, Fin.val_last] + rw [pow_succ (1 / 2 : ℝ) s] + nlinarith + +theorem half_geometric_sum_le_one (s : ℕ) : + (∑ i : Fin s, (1 / 2 : ℝ) ^ (i.val + 1)) ≤ 1 := by + have h := half_geometric_sum_identity s + have hpow : 0 ≤ (1 / 2 : ℝ) ^ s := by positivity + linarith + +/-- Some next scale fails whenever the density is positive. -/ +theorem scale_next_fail_exists {p : ℝ} (hp : 0 < p) : + ∃ s : ℕ, 1 / 2 < p * scaleSum (s + 1) := by + obtain ⟨n, hn⟩ := exists_nat_gt ((1 / 2 : ℝ) / p) + refine ⟨n, ?_⟩ + have hnp : (1 / 2 : ℝ) < (n : ℝ) * p := (div_lt_iff₀ hp).mp hn + have hcast : (n : ℝ) ≤ (n + 1 : ℕ) := by + simp only [Nat.cast_add, Nat.cast_one] + linarith + calc + (1 / 2 : ℝ) < p * (n : ℝ) := by simpa only [mul_comm] using hnp + _ ≤ p * scaleSum (n + 1) := + mul_le_mul_of_nonneg_left (hcast.trans (scaleSum_ge_nat (n + 1))) hp.le + +/-- The largest admissible scale; its irrelevant nonpositive-density value is zero. -/ +noncomputable def maxScale (p : ℝ) : ℕ := by + classical + exact if hp : 0 < p then Nat.find (scale_next_fail_exists hp) else 0 + +private theorem maxScale_eq_find {p : ℝ} (hp : 0 < p) : + maxScale p = Nat.find (scale_next_fail_exists hp) := by + classical + simp only [maxScale, dite_eq_left hp] + +theorem maxScale_next_fail {p : ℝ} (hp : 0 < p) : + 1 / 2 < p * scaleSum (maxScale p + 1) := by + classical + rw [maxScale_eq_find hp] + exact Nat.find_spec (scale_next_fail_exists hp) + +theorem maxScale_admissible {p : ℝ} (hp : 0 < p) : + p * scaleSum (maxScale p) ≤ 1 / 2 := by + classical + cases hs : maxScale p with + | zero => simp [scaleSum_zero] + | succ s => + have hslt : s < Nat.find (scale_next_fail_exists hp) := by + rw [← maxScale_eq_find hp, hs] + exact Nat.lt_succ_self s + exact le_of_not_gt (Nat.find_min (scale_next_fail_exists hp) hslt) + +/-- Every admissible integer is at most the constructed cutoff. -/ +theorem maxScale_largest {p : ℝ} (hp : 0 < p) {t : ℕ} + (ht : p * scaleSum t ≤ 1 / 2) : t ≤ maxScale p := by + by_contra h + have hst : maxScale p + 1 ≤ t := by omega + have hle : p * scaleSum (maxScale p + 1) ≤ p * scaleSum t := + mul_le_mul_of_nonneg_left (scaleSum_monotone hst) hp.le + exact (not_le_of_gt (maxScale_next_fail hp)) (hle.trans ht) + +/-- The exact pair of cutoff inequalities used by the rounding argument. -/ +theorem exists_scale {p : ℝ} (hp : 0 < p) : + ∃ s : ℕ, p * scaleSum s ≤ 1 / 2 ∧ 1 / 2 < p * scaleSum (s + 1) := + ⟨maxScale p, maxScale_admissible hp, maxScale_next_fail hp⟩ + +/-- Failure at the next scale controls the residual color contribution. -/ +theorem tail_lt_four_mul_p {p : ℝ} {s : ℕ} (hp : 0 < p) + (hnext : 1 / 2 < p * scaleSum (s + 1)) : + 1 / (512 : ℝ) ^ (s + 1) < 4 * p := by + have hsum : p * scaleSum (s + 1) ≤ p * (2 * (256 : ℝ) ^ (s + 1)) := + mul_le_mul_of_nonneg_left (scaleSum_le_two_pow (s + 1)) hp.le + have hDpos : 0 < (256 : ℝ) ^ (s + 1) := by positivity + have hDB : (256 : ℝ) ^ (s + 1) ≤ (512 : ℝ) ^ (s + 1) := + pow_le_pow_left₀ (by norm_num) (by norm_num) _ + calc + 1 / (512 : ℝ) ^ (s + 1) ≤ 1 / (256 : ℝ) ^ (s + 1) := + one_div_le_one_div_of_le hDpos hDB + _ < 4 * p := by + apply (div_lt_iff₀ hDpos).mpr + nlinarith + +theorem maxScale_tail_lt {p : ℝ} (hp : 0 < p) : + 1 / (512 : ℝ) ^ (maxScale p + 1) < 4 * p := + tail_lt_four_mul_p hp (maxScale_next_fail hp) + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorAverageColor.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorAverageColor.lean new file mode 100644 index 0000000000000000000000000000000000000000..36703a5d368d9f1739505086372966628acf2e4d --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorAverageColor.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitionsLemmas +import OAI.Combinatorics.ExpectationThreshold.ScaleBounds +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Algebra.BigOperators.Ring.Finset + +namespace OAI + +/-! +# Average color from simultaneous capture + +An integer color is one plus the number of preceding prefixes it misses. +Summing this finite identity against the actual probability mass gives the +mean-color identity. A captured coloring has the same family member at +every scale, so the geometric sum of its missed masses is at most one. +-/ + +namespace TalagrandThreshold.Selector + +open scoped BigOperators + +/-- Count the prefixes strictly below a color, including the final color. -/ +theorem sum_color_tail_indicators {s : ℕ} (c : Color s) : + (∑ i : Fin s, if i.val < c.val then (1 : ℝ) else 0) = (c.val : ℝ) := by + have hcs : c.val ≤ s := Nat.le_of_lt_succ c.isLt + have hfilter : (Finset.range s).filter (fun i => i < c.val) = Finset.range c.val := by + ext i + simp only [Finset.mem_filter, Finset.mem_range] + exact ⟨And.right, fun hi => ⟨hi.trans_le hcs, hi⟩⟩ + calc + (∑ i : Fin s, if i.val < c.val then (1 : ℝ) else 0) = + ∑ i ∈ Finset.range s, if i < c.val then (1 : ℝ) else 0 := + Fin.sum_univ_eq_sum_range (fun i => if i < c.val then (1 : ℝ) else 0) s + _ = (((Finset.range s).filter (fun i => i < c.val)).card : ℝ) := + Finset.sum_boole _ _ + _ = (c.val : ℝ) := by rw [hfilter, Finset.card_range] + +/-- The finite integer layer-cake identity for the zero-based color index. -/ +theorem color_level_eq_one_add_tail {s : ℕ} (c : Color s) : + (c.val + 1 : ℝ) = 1 + ∑ i : Fin s, if i.val < c.val then (1 : ℝ) else 0 := by + rw [sum_color_tail_indicators] + ring + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [DecidableEq α] in +/-- The mass of colors above a prefixSet is its complementary mass. -/ +theorem sum_tail_eq_one_sub_prefix {F : Family α} (mu : MassFamily F) {s : ℕ} + (H : ↥F) (a : Coloring α s) (i : Fin s) : + (∑ x, if i.val < (a x).val then mu.weight H x else 0) = + 1 - ∑ x ∈ prefixSet a i, mu.weight H x := by + classical + have hsplit := Finset.sum_filter_add_sum_filter_not Finset.univ + (fun x : α => (a x).val ≤ i.val) (mu.weight H) + rw [mu.total H] at hsplit + have heq : (∑ x ∈ prefixSet a i, mu.weight H x) + + (∑ x, if i.val < (a x).val then mu.weight H x else 0) = 1 := by + simpa only [prefixSet, Finset.sum_filter, not_le] using hsplit + exact eq_sub_iff_add_eq.mpr (by simpa only [add_comm] using heq) + +omit [DecidableEq α] in +/-- The actual mean color is one plus the sum of all missed prefixSet masses. -/ +theorem meanColor_eq_one_add_sum_tail {F : Family α} (mu : MassFamily F) {s : ℕ} + (H : ↥F) (a : Coloring α s) : + meanColor mu H a = 1 + + ∑ i : Fin s, (1 - ∑ x ∈ prefixSet a i, mu.weight H x) := by + classical + unfold meanColor + simp_rw [color_level_eq_one_add_tail, add_mul, one_mul, Finset.sum_mul, + ite_mul, one_mul, zero_mul] + rw [Finset.sum_add_distrib, mu.total H, Finset.sum_comm] + simp_rw [sum_tail_eq_one_sub_prefix mu H a] + +/-- The truncation scales have total mass at most one, also when there are no scales. -/ +theorem sum_dscale_le_one (s : ℕ) : (∑ i : Fin s, dscale i) ≤ 1 := by + simpa only [dscale, one_div, inv_pow] using half_geometric_sum_le_one s + +omit [DecidableEq α] in +/-- A single member capturing every prefixSet has mean color at most two. -/ +theorem meanColor_le_two_of_capture {F : Family α} (mu : MassFamily F) {s : ℕ} + (H : ↥F) (a : Coloring α s) + (hcapture : ∀ i : Fin s, + 1 - dscale i ≤ ∑ x ∈ prefixSet a i, mu.weight H x) : + meanColor mu H a ≤ 2 := by + rw [meanColor_eq_one_add_sum_tail] + calc + 1 + ∑ i : Fin s, (1 - ∑ x ∈ prefixSet a i, mu.weight H x) ≤ + 1 + ∑ i : Fin s, dscale i := by + apply add_le_add le_rfl + apply Finset.sum_le_sum + intro i _ + linarith [hcapture i] + _ ≤ 1 + 1 := add_le_add le_rfl (sum_dscale_le_one s) + _ = 2 := by norm_num + +omit [DecidableEq α] in +/-- The same captured member supplies the average-color witness. -/ +theorem Captured.exists_meanColor_le_two {F : Family α} {mu : MassFamily F} {s : ℕ} + {a : Coloring α s} (h : Captured mu a) : ∃ H : ↥F, meanColor mu H a ≤ 2 := by + obtain ⟨H, hH⟩ := h + exact ⟨H, meanColor_le_two_of_capture mu H a hH⟩ + +end TalagrandThreshold.Selector + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCommonWitness.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCommonWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b5a49237641803a110b3b291b4e86c65457ac61 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCommonWitness.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitionsLemmas +import OAI.Combinatorics.ExpectationThreshold.SelectorProfile +import OAI.Combinatorics.ExpectationThreshold.SelectorReconstruction +import OAI.Combinatorics.ExpectationThreshold.SelectorTruncation + +namespace OAI + +/-! +# One witness for an entire selector profile group + +A nonempty group contains an actual selected move, hence an actual feasible +family member. Its admissibility tests depend on the original coloring only +through the full profile. Maximizing each cutoff for this one member therefore +produces common heavy sets for the entire group. Selected-move minimality puts +every moved row inside its corresponding common heavy set. +-/ + +noncomputable section + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- The same actual family member and cutoffs work for every original coloring +in a fixed final-coloring/profile group. -/ +structure CommonWitness {F : Family α} (mu : MassFamily F) {s : ℕ} + (z : Coloring α s) (n : Profile s) where + member : ↥F + cutoff : Fin s → ℝ + admissible : ∀ a ∈ groupOriginals mu z n, ∀ i : Fin s, + Admissible (mu.weight member) (prefixSet z i) (crossings a z i : ℝ) + (dscale i) (cutoff i) + maximal : ∀ (i : Fin s) (u : ℝ), + Admissible (mu.weight member) (prefixSet z i) (profileCrossings n i : ℝ) + (dscale i) u → u ≤ cutoff i + card_le : ∀ i : Fin s, + (heavySet (mu.weight member) (cutoff i)).card ≤ 2 ^ (i.val + 1) * profileSize n + moved_subset : ∀ a ∈ groupOriginals mu z n, ∀ i : Fin s, + movedRow a z i ⊆ heavySet (mu.weight member) (cutoff i) + +omit [Fintype α] [DecidableEq α] in +private theorem card_le_profile_of_truncation {s : ℕ} + (R : Finset α) (i : Fin s) (n : Profile s) (m : ℕ) + (hcard : (R.card : ℝ) ≤ (m : ℝ) / dscale i) + (hm : m ≤ profileSize n) : + R.card ≤ 2 ^ (i.val + 1) * profileSize n := by + have hreal : (R.card : ℝ) ≤ ((m * 2 ^ (i.val + 1) : ℕ) : ℝ) := by + simpa only [dscale, div_inv_eq_mul, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] + using hcard + have hnat : R.card ≤ m * 2 ^ (i.val + 1) := (Nat.cast_le (α := ℝ)).mp hreal + calc + R.card ≤ m * 2 ^ (i.val + 1) := hnat + _ ≤ profileSize n * 2 ^ (i.val + 1) := Nat.mul_le_mul_right _ hm + _ = 2 ^ (i.val + 1) * profileSize n := Nat.mul_comm _ _ + +/-- The common witness is constructed from the actual nonempty group; no +additional feasibility, reconstruction, or cardinality certificate is assumed. -/ +theorem exists_common_witness {F : Family α} (mu : MassFamily F) {s : ℕ} + (z : Coloring α s) (n : Profile s) + (hne : (groupOriginals mu z n).Nonempty) : Nonempty (CommonWitness mu z n) := by + classical + obtain ⟨a₀, ha₀⟩ := hne + have ha₀' := (mem_groupOriginals mu a₀ z n).mp ha₀ + obtain ⟨H₀, hminimal⟩ := ha₀'.2.1 + obtain ⟨H, hfeasible⟩ := hminimal.1.1.2 + have hcross₀ (i : Fin s) : crossings a₀ z i = profileCrossings n i := by + rw [crossings_eq_profileCrossings, ha₀'.2.2] + have hcutoff (i : Fin s) : ∃ ε : ℝ, + Admissible (mu.weight H) (prefixSet z i) (profileCrossings n i : ℝ) (dscale i) ε ∧ + (∀ u, Admissible (mu.weight H) (prefixSet z i) (profileCrossings n i : ℝ) + (dscale i) u → u ≤ ε) ∧ + ((heavySet (mu.weight H) ε).card : ℝ) ≤ (profileCrossings n i : ℝ) / dscale i := by + apply exists_maximal_truncation_div (mu.weight H) (prefixSet z i) + (profileCrossings n i : ℝ) (dscale i) (mu.nonneg H) (mu.total H) + (Nat.cast_nonneg _) (dscale_pos i) (dscale_lt_one i) + simpa only [hcross₀ i] using hfeasible i + let ε : Fin s → ℝ := fun i => Classical.choose (hcutoff i) + have hε (i : Fin s) : + Admissible (mu.weight H) (prefixSet z i) (profileCrossings n i : ℝ) (dscale i) (ε i) ∧ + (∀ u, Admissible (mu.weight H) (prefixSet z i) (profileCrossings n i : ℝ) + (dscale i) u → u ≤ ε i) ∧ + ((heavySet (mu.weight H) (ε i)).card : ℝ) ≤ + (profileCrossings n i : ℝ) / dscale i := + Classical.choose_spec (hcutoff i) + have hadmissible : ∀ a ∈ groupOriginals mu z n, ∀ i : Fin s, + Admissible (mu.weight H) (prefixSet z i) (crossings a z i : ℝ) (dscale i) (ε i) := by + intro a ha i + have hprofile := ((mem_groupOriginals mu a z n).mp ha).2.2 + rw [crossings_eq_profileCrossings, hprofile] + exact (hε i).1 + refine ⟨{ + member := H + cutoff := ε + admissible := hadmissible + maximal := fun i => (hε i).2.1 + card_le := ?_ + moved_subset := ?_ + }⟩ + · intro i + exact card_le_profile_of_truncation (heavySet (mu.weight H) (ε i)) i n + (profileCrossings n i) (hε i).2.2 (profileCrossings_le_profileSize n i) + · intro a ha i + have hselected := ((mem_groupOriginals mu a z n).mp ha).2.1 + have hfeasible' : FeasibleFor mu a z H := fun j => ⟨ε j, hadmissible a ha j⟩ + exact selected_movedRow_subset_heavySet mu a z hselected H hfeasible' i (ε i) + (hadmissible a ha i) + +/-- The finite sets needed for counting are common to the whole actual group. -/ +theorem exists_common_heavy_sets {F : Family α} (mu : MassFamily F) {s : ℕ} + (z : Coloring α s) (n : Profile s) + (hne : (groupOriginals mu z n).Nonempty) : + ∃ R : Fin s → Finset α, + (∀ i, (R i).card ≤ 2 ^ (i.val + 1) * profileSize n) ∧ + ∀ a ∈ groupOriginals mu z n, ∀ i, movedRow a z i ⊆ R i := by + obtain ⟨w⟩ := exists_common_witness mu z n hne + exact ⟨fun i => heavySet (mu.weight w.member) (w.cutoff i), w.card_le, w.moved_subset⟩ + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncoding.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..277b6d7be2ce53b27c444a98c28fb21cc5966bf4 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncoding.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitions + +namespace OAI + +/-! +# Reconstruction from the actual changed rows + +For an earlier coloring, every point outside the changed rows retains its final +color. Inside a changed row its original color is recorded. Thus the changed +subsets and their original labels determine the entire original coloring. +-/ + +noncomputable section + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] {s : ℕ} + +omit [DecidableEq α] in +/-- An original coloring is reconstructed from its changed rows and the +original labels on those rows. No disjointness of ambient row supersets is used. -/ +theorem coloring_eq_of_movedRows + {a b z : Coloring α s} (ha : Earlier a z) (hb : Earlier b z) + (hrows : ∀ i, movedRow a z i = movedRow b z i) + (hlabels : ∀ i x, x ∈ movedRow a z i → a x = b x) : a = b := by + funext x + by_cases hxa : z x < a x + · let i : Fin s := ⟨(z x).val, + Nat.lt_of_lt_of_le hxa (Nat.le_of_lt_succ (a x).isLt)⟩ + apply hlabels i x + simp only [movedRow, Finset.mem_filter, Finset.mem_univ, true_and] + exact ⟨rfl, hxa⟩ + · have haeq : a x = z x := le_antisymm (le_of_not_gt hxa) (ha x) + have hxb : ¬ z x < b x := by + intro hxb + let i : Fin s := ⟨(z x).val, + Nat.lt_of_lt_of_le hxb (Nat.le_of_lt_succ (b x).isLt)⟩ + have hx : x ∈ movedRow b z i := by + simp only [movedRow, Finset.mem_filter, Finset.mem_univ, true_and] + exact ⟨rfl, hxb⟩ + rw [← hrows i] at hx + exact hxa (Finset.mem_filter.mp hx).2.2 + exact haeq.trans (le_antisymm (le_of_not_gt hxb) (hb x)).symm + +/-- The unrestricted row record consists of its actual support and its labels. -/ +abbrev RawRowEncoding (α : Type*) (s : ℕ) := + Σ U : Finset α, (↥U → Color s) + +def rawRowEncoding (a z : Coloring α s) (i : Fin s) : RawRowEncoding α s := + ⟨movedRow a z i, fun x => a x.1⟩ + +/-- Reading one point avoids any dependence on the chosen subtype proof. -/ +def rawRowLookup (E : RawRowEncoding α s) (x : α) : Option (Color s) := + if hx : x ∈ E.1 then some (E.2 ⟨x, hx⟩) else none + +/-- The literal row encoding is injective on originals moved only earlier. -/ +theorem rawRowEncoding_injective + {a b z : Coloring α s} (ha : Earlier a z) (hb : Earlier b z) + (he : ∀ i, rawRowEncoding a z i = rawRowEncoding b z i) : a = b := by + have hrows : ∀ i, movedRow a z i = movedRow b z i := + fun i => congrArg Sigma.fst (he i) + apply coloring_eq_of_movedRows ha hb hrows + intro i x hx + have hx' : x ∈ movedRow b z i := by rw [← hrows i]; exact hx + have hlookup := congrArg (fun E => rawRowLookup E x) (he i) + dsimp only [rawRowLookup, rawRowEncoding] at hlookup + simp only [dite_eq_left hx, dite_eq_left hx'] at hlookup + exact Option.some.inj hlookup + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncodingBound.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncodingBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..79dcb41dbd88a53f914d002a71ecba47897efb04 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncodingBound.lean @@ -0,0 +1,110 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorCountingEncoding +import OAI.Combinatorics.ExpectationThreshold.SelectorCountingEncodingRows +import OAI.Combinatorics.ExpectationThreshold.SelectorProfile + +namespace OAI + +/-! +# The fixed-profile encoding bound + +Each actual coloring maps to the tuple of its changed row subsets and the +original colors on them. Reconstruction proves this map injective. The row +record permits arbitrary subsets of the fixed ambient sets, so overlap between +those ambient sets can only enlarge the number of records. +-/ + +noncomputable section +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] {s : ℕ} + +omit [Fintype α] [DecidableEq α] in +/-- Restricting a labeling to a finite set counts exactly its fibers there. -/ +theorem wordProfile_restrict_finset {H : Type*} [DecidableEq H] + (U : Finset α) (f : α → H) (h : H) : + wordProfile (fun x : ↥U => f x.val) h = + (U.filter fun x => f x = h).card := by + unfold wordProfile + apply Finset.card_bij (fun x _ => x.val) + · intro x hx + exact Finset.mem_filter.mpr ⟨x.property, (Finset.mem_filter.mp hx).2⟩ + · intro x _ y _ hxy + exact Subtype.ext hxy + · intro x hx + refine ⟨⟨x, (Finset.mem_filter.mp hx).1⟩, ?_, rfl⟩ + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hx).2⟩ + +omit [DecidableEq α] in +/-- The recorded original labels have precisely the actual profile row. -/ +theorem movedRow_wordProfile (a z : Coloring α s) (i : Fin s) : + wordProfile (fun x : ↥(movedRow a z i) => a x.val) = profile a z i := by + funext h + rw [wordProfile_restrict_finset, profile_eq_card_filter_movedRow] + +/-- The literal row record with its proved size and histogram constraints. -/ +def profileRowEncoding (a z : Coloring α s) (n : Profile s) + (R : Fin s → Finset α) (hn : profile a z = n) + (hR : ∀ i, movedRow a z i ⊆ R i) (i : Fin s) : + RowEncoding (R i) (rowCount n i) (n i) := + ⟨⟨movedRow a z i, hR i, by rw [movedRow_card_eq_rowCount, hn]⟩, + ⟨fun x => a x.val, (mem_wordFiber _ _ _).mpr + ((movedRow_wordProfile a z i).trans (congrFun hn i))⟩⟩ + +/-- Forgetting the constraints retains the actual changed subset and labels. -/ +def rowEncodingForget {R : Finset α} {t : ℕ} {n : Color s → ℕ} + (E : RowEncoding R t n) : RawRowEncoding α s := + ⟨E.1.val, E.2.val⟩ + +@[simp] theorem rowEncodingForget_profileRowEncoding + (a z : Coloring α s) (n : Profile s) (R : Fin s → Finset α) + (hn : profile a z = n) (hR : ∀ i, movedRow a z i ⊆ R i) (i : Fin s) : + rowEncodingForget (profileRowEncoding a z n R hn hR i) = + rawRowEncoding a z i := rfl + +/-- Count actual originals of a fixed final coloring and profile. Every +injectivity and histogram condition is proved from the actual row encoding. -/ +theorem card_le_profile_encoding + (G : Finset (Coloring α s)) (z : Coloring α s) (n : Profile s) + (R : Fin s → Finset α) + (hEarlier : ∀ a ∈ G, Earlier a z) + (hprofile : ∀ a ∈ G, profile a z = n) + (hrows : ∀ a ∈ G, ∀ i, movedRow a z i ⊆ R i) : + G.card ≤ ∏ i : Fin s, + Nat.choose (R i).card (rowCount n i) * wordCount (rowCount n i) (n i) := by + classical + let encode : ↥G → ∀ i : Fin s, RowEncoding (R i) (rowCount n i) (n i) := + fun a => profileRowEncoding a.val z n R + (hprofile a.val a.property) (hrows a.val a.property) + have hinj : Function.Injective encode := by + intro a b hab + apply Subtype.ext + apply rawRowEncoding_injective + (hEarlier a.val a.property) (hEarlier b.val b.property) + intro i + have hi := congrArg (fun f => rowEncodingForget (f i)) hab + simpa only [encode, rowEncodingForget_profileRowEncoding] using hi + have hcard := Fintype.card_le_of_injective encode hinj + simpa only [Fintype.card_coe, Fintype.card_pi, card_rowEncoding] using hcard + +/-- Specialization to the actual selected bad originals in one profile group. -/ +theorem groupOriginals_card_le_profile_encoding + {F : Family α} (mu : MassFamily F) (z : Coloring α s) (n : Profile s) + (R : Fin s → Finset α) + (hrows : ∀ a ∈ groupOriginals mu z n, ∀ i, movedRow a z i ⊆ R i) : + (groupOriginals mu z n).card ≤ ∏ i : Fin s, + Nat.choose (R i).card (rowCount n i) * wordCount (rowCount n i) (n i) := by + apply card_le_profile_encoding (groupOriginals mu z n) z n R + · intro a ha + obtain ⟨_, ⟨H₀, hmin⟩, _⟩ := (mem_groupOriginals mu a z n).mp ha + exact hmin.1.1.1 + · intro a ha + exact ((mem_groupOriginals mu a z n).mp ha).2.2 + · exact hrows + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncodingRows.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncodingRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..f25f3dbb3137f0f7fcdb1bf735c064919affecac --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingEncodingRows.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorCountingWordsTransport +import Mathlib.Data.Fintype.Powerset +import Mathlib.Data.Fintype.BigOperators + +namespace OAI + +/-! +# Counting row encodings + +A row encoding chooses a subset of the available positions and labels those +positions with a word of a prescribed profile. The word count depends only on +the number of chosen positions, so the total count factors into a binomial +coefficient and the corresponding word count. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +variable {α H : Type*} [Fintype α] [DecidableEq α] [Fintype H] [DecidableEq H] + +/-- The number of subsets of `R` with exactly `t` elements. -/ +theorem card_fixedSize_subsets (R : Finset α) (t : ℕ) : + Fintype.card {U : Finset α // U ⊆ R ∧ U.card = t} = + Nat.choose R.card t := by + calc + Fintype.card {U : Finset α // U ⊆ R ∧ U.card = t} = + (R.powersetCard t).card := + Fintype.card_of_subtype (R.powersetCard t) + (fun _ => Finset.mem_powersetCard) + _ = Nat.choose R.card t := Finset.card_powersetCard t R + +/-- A chosen set of positions together with labels of the prescribed profile. -/ +def RowEncoding (R : Finset α) (t : ℕ) (n : H → ℕ) : Type _ := + Σ U : {U : Finset α // U ⊆ R ∧ U.card = t}, ↥(wordFiber ↥U.val n) + +noncomputable instance instFintypeRowEncoding (R : Finset α) (t : ℕ) (n : H → ℕ) : + Fintype (RowEncoding R t n) := + inferInstanceAs (Fintype + (Σ U : {U : Finset α // U ⊆ R ∧ U.card = t}, ↥(wordFiber ↥U.val n))) + +/-- Each chosen set admits the same number of words, so the count factors. -/ +theorem card_rowEncoding (R : Finset α) (t : ℕ) (n : H → ℕ) : + Fintype.card (RowEncoding R t n) = Nat.choose R.card t * wordCount t n := by + classical + change Fintype.card + (Σ U : {U : Finset α // U ⊆ R ∧ U.card = t}, ↥(wordFiber ↥U.val n)) = _ + rw [Fintype.card_sigma] + have hFiber (U : {U : Finset α // U ⊆ R ∧ U.card = t}) : + Fintype.card ↥(wordFiber ↥U.val n) = wordCount t n := by + rw [Fintype.card_coe, wordFiber_finset_card, U.property.2] + calc + (∑ U : {U : Finset α // U ⊆ R ∧ U.card = t}, + Fintype.card ↥(wordFiber ↥U.val n)) = + Fintype.card {U : Finset α // U ⊆ R ∧ U.card = t} * wordCount t n := by + simpa only [Finset.card_univ] using + (Finset.sum_const_nat (s := Finset.univ) + (f := fun U : {U : Finset α // U ⊆ R ∧ U.card = t} => + Fintype.card ↥(wordFiber ↥U.val n)) + (m := wordCount t n) (fun U _ => hFiber U)) + _ = Nat.choose R.card t * wordCount t n := by + rw [card_fixedSize_subsets] + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWords.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c5cf1d1c3603c2ac95778a6d49efefccf77cc89 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWords.lean @@ -0,0 +1,121 @@ +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset +import Mathlib.Data.Fintype.Pi +import Mathlib.Basic.Real.Basic + +namespace OAI + +/-! +# Counting finite words by their color profiles + +The coefficient attached to a profile is the actual cardinality of its fiber +among finite words. Regrouping the weighted sum over words proves the finite +multinomial identity without introducing a factorial formula or a counting +hypothesis. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +/-- The number of positions of each color in a word on a finite domain. -/ +def wordProfile {D H : Type*} [Fintype D] [DecidableEq H] (f : D → H) (h : H) : ℕ := + (Finset.univ.filter fun i => f i = h).card + +/-- All words on a fixed finite domain having the specified profile. -/ +def wordFiber (D : Type*) {H : Type*} [Fintype D] [DecidableEq D] + [Fintype H] [DecidableEq H] (n : H → ℕ) : Finset (D → H) := + Finset.univ.filter fun f => wordProfile f = n + +/-- The concrete multinomial coefficient, defined as a finite fiber cardinality. -/ +def wordCount {H : Type*} [Fintype H] [DecidableEq H] (t : ℕ) (n : H → ℕ) : ℕ := + (wordFiber (Fin t) n).card + +/-- The finite set of profiles attained by words of length `t`. -/ +def wordProfiles (H : Type*) [Fintype H] [DecidableEq H] (t : ℕ) : Finset (H → ℕ) := + Finset.univ.image (fun f : Fin t → H => wordProfile f) + +variable {H : Type*} [Fintype H] [DecidableEq H] + +@[simp] theorem mem_wordFiber (D : Type*) [Fintype D] [DecidableEq D] + (n : H → ℕ) (f : D → H) : f ∈ wordFiber D n ↔ wordProfile f = n := by + simp only [wordFiber, Finset.mem_filter, Finset.mem_univ, true_and] + +theorem mem_wordProfiles_iff (t : ℕ) (n : H → ℕ) : + n ∈ wordProfiles H t ↔ ∃ f : Fin t → H, wordProfile f = n := by + simp only [wordProfiles, Finset.mem_image, Finset.mem_univ, true_and] + +theorem sum_wordProfile {D : Type*} [Fintype D] (f : D → H) : + (∑ h, wordProfile f h) = Fintype.card D := by + simpa only [wordProfile, Finset.mem_univ, Finset.filter_true, Finset.card_univ] using + (Finset.sum_card_fiberwise_eq_card_filter (Finset.univ : Finset D) Finset.univ f) + +theorem wordCount_eq_zero_of_not_mem_wordProfiles (t : ℕ) (n : H → ℕ) + (hn : n ∉ wordProfiles H t) : wordCount t n = 0 := by + unfold wordCount wordFiber + apply Finset.card_eq_zero.mpr + apply Finset.filter_eq_empty_iff.mpr + intro f _ hf + exact hn ((mem_wordProfiles_iff t n).mpr ⟨f, hf⟩) + +/-- The weight from a profile equals the product of the individual letter weights. -/ +theorem prod_weight_wordProfile {D : Type*} [Fintype D] + (f : D → H) (π : H → ℝ) : + (∏ h, π h ^ wordProfile f h) = ∏ i, π (f i) := by + simpa only [wordProfile, Finset.prod_const] using + (Finset.prod_fiberwise' (Finset.univ : Finset D) f π) + +/-- The multinomial identity obtained by grouping actual words by their profile. -/ +theorem sum_wordCount_weight (t : ℕ) (π : H → ℝ) : + (∑ n ∈ wordProfiles H t, (wordCount t n : ℝ) * ∏ h, π h ^ n h) = + (∑ h, π h) ^ t := by + have hgroup : (∑ f : Fin t → H, ∏ h, π h ^ wordProfile f h) = + ∑ n ∈ wordProfiles H t, (wordCount t n : ℝ) * ∏ h, π h ^ n h := by + simpa only [wordProfiles, wordCount, wordFiber, nsmul_eq_mul] using + (Finset.sum_comp (s := (Finset.univ : Finset (Fin t → H))) + (fun n : H → ℕ => ∏ h, π h ^ n h) (fun f : Fin t → H => wordProfile f)) + calc + _ = ∑ f : Fin t → H, ∏ h, π h ^ wordProfile f h := hgroup.symm + _ = ∑ f : Fin t → H, ∏ i, π (f i) := by + apply Finset.sum_congr rfl + intro f _ + exact prod_weight_wordProfile f π + _ = (∑ h, π h) ^ t := (Fintype.sum_pow π t).symm + +theorem wordCount_weight_nonneg (t : ℕ) (π : H → ℝ) (hπ : ∀ h, 0 ≤ π h) + (n : H → ℕ) : 0 ≤ (wordCount t n : ℝ) * ∏ h, π h ^ n h := + mul_nonneg (Nat.cast_nonneg _) (Finset.prod_nonneg fun h _ => pow_nonneg (hπ h) _) + +theorem sum_wordCount_weight_le_one (t : ℕ) (π : H → ℝ) (hπ : ∀ h, 0 ≤ π h) + (hπsum : (∑ h, π h) ≤ 1) : + (∑ n ∈ wordProfiles H t, (wordCount t n : ℝ) * ∏ h, π h ^ n h) ≤ 1 := by + rw [sum_wordCount_weight] + exact pow_le_one₀ (Finset.sum_nonneg fun h _ => hπ h) hπsum + +/-- Any finite collection of profiles has total weight at most one, including +profiles not attained by a word: their fiber counts are zero. -/ +theorem sum_wordCount_weight_finset_le_one (t : ℕ) (E : Finset (H → ℕ)) + (π : H → ℝ) (hπ : ∀ h, 0 ≤ π h) (hπsum : (∑ h, π h) ≤ 1) : + (∑ n ∈ E, (wordCount t n : ℝ) * ∏ h, π h ^ n h) ≤ 1 := by + classical + have hrestrict : + (∑ n ∈ E ∩ wordProfiles H t, (wordCount t n : ℝ) * ∏ h, π h ^ n h) = + ∑ n ∈ E, (wordCount t n : ℝ) * ∏ h, π h ^ n h := by + apply Finset.sum_subset Finset.inter_subset_left + intro n hn hnot + have hout : n ∉ wordProfiles H t := by + intro hp + exact hnot (Finset.mem_inter.mpr ⟨hn, hp⟩) + rw [wordCount_eq_zero_of_not_mem_wordProfiles t n hout] + simp only [Nat.cast_zero, zero_mul] + rw [← hrestrict] + calc + _ ≤ ∑ n ∈ wordProfiles H t, (wordCount t n : ℝ) * ∏ h, π h ^ n h := + Finset.sum_le_sum_of_subset_of_nonneg Finset.inter_subset_right + (fun n _ _ => wordCount_weight_nonneg t π hπ n) + _ ≤ 1 := sum_wordCount_weight_le_one t π hπ hπsum + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWordsProducts.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWordsProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..524d01bab27bd96aa98a7586d0157d60e2a47a97 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWordsProducts.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorCountingWords +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset + +namespace OAI + +/-! +# Products of counting-word weights + +An arbitrary finite collection of row profiles has total counting-word weight +at most one when the nonnegative color weights have total mass at most one. +The coefficients are the actual cardinalities of words with each profile. +-/ + +open scoped BigOperators + +namespace TalagrandThreshold + +private theorem sum_prod_le_prod_sum_of_support {I A : Type*} [Fintype I] + (S : I → Finset A) (w : I → A → ℝ) + (hw : ∀ i a, 0 ≤ w i a) + (hz : ∀ i a, a ∉ S i → w i a = 0) (E : Finset (I → A)) : + (∑ n ∈ E, ∏ i, w i (n i)) ≤ ∏ i, ∑ a ∈ S i, w i a := by + classical + let P : Finset (I → A) := Fintype.piFinset S + have hzero (n : I → A) (hn : n ∉ P) : (∏ i, w i (n i)) = 0 := by + have hn' : ¬ ∀ i, n i ∈ S i := by + simpa only [P, Fintype.mem_piFinset] using hn + obtain ⟨i, hi⟩ := not_forall.mp hn' + exact Finset.prod_eq_zero (Finset.mem_univ i) (hz i (n i) hi) + calc + (∑ n ∈ E, ∏ i, w i (n i)) = ∑ n ∈ E ∩ P, ∏ i, w i (n i) := by + symm + apply Finset.sum_subset Finset.inter_subset_left + intro n hn hnot + apply hzero n + intro hnP + exact hnot (Finset.mem_inter.mpr ⟨hn, hnP⟩) + _ ≤ ∑ n ∈ P, ∏ i, w i (n i) := + Finset.sum_le_sum_of_subset_of_nonneg Finset.inter_subset_right + (fun n _ _ => Finset.prod_nonneg fun i _ => hw i (n i)) + _ = ∏ i, ∑ a ∈ S i, w i a := (Finset.prod_univ_sum S w).symm + +/-- Summing the literal counting-word weights over any finite set of row +profiles is bounded by one. Neither the row type nor the color type needs +to be nonempty. -/ +theorem sum_prod_wordCount_weight_le_one {I H : Type*} [Fintype I] + [Fintype H] [DecidableEq H] (t : I → ℕ) (E : Finset (I → H → ℕ)) + (π : H → ℝ) (hπ : ∀ h, 0 ≤ π h) (hπsum : (∑ h, π h) ≤ 1) : + (∑ n ∈ E, ∏ i, ((wordCount (t i) (n i) : ℝ) * ∏ h, π h ^ (n i h))) ≤ 1 := by + classical + have hπsum_nonneg : 0 ≤ ∑ h, π h := Finset.sum_nonneg fun h _ => hπ h + calc + (∑ n ∈ E, ∏ i, ((wordCount (t i) (n i) : ℝ) * ∏ h, π h ^ (n i h))) ≤ + ∏ i, ∑ n ∈ wordProfiles H (t i), + (wordCount (t i) n : ℝ) * ∏ h, π h ^ (n h) := by + refine sum_prod_le_prod_sum_of_support (I := I) (A := H → ℕ) + (fun i => wordProfiles H (t i)) + (fun i (n : H → ℕ) => (wordCount (t i) n : ℝ) * ∏ h, π h ^ n h) ?_ ?_ E + · intro i n + exact mul_nonneg (Nat.cast_nonneg _) + (Finset.prod_nonneg fun h _ => pow_nonneg (hπ h) _) + · intro i n hn + rw [wordCount_eq_zero_of_not_mem_wordProfiles (t i) n hn] + simp + _ = ∏ i, (∑ h, π h) ^ (t i) := by + apply Finset.prod_congr rfl + intro i _ + exact sum_wordCount_weight (t i) π + _ ≤ 1 := Finset.prod_le_one₀ + (fun i _ => pow_nonneg hπsum_nonneg (t i)) + (fun _ _ => pow_le_one₀ hπsum_nonneg hπsum) + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWordsTransport.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWordsTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..2320a931f32dc84912a365253f96a48a32d497dd --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorCountingWordsTransport.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorCountingWords +import Mathlib.Data.Fintype.EquivFin + +namespace OAI + +/-! +# Transport of words with a prescribed profile + +Reindexing the domain of a word preserves every letter count. Consequently, +the number of words with a prescribed profile depends only on the size of +the domain, including when that domain is the subtype of a finite set. +-/ + +namespace TalagrandThreshold + +section Profile + +variable {D E H : Type*} [Fintype D] [Fintype E] [DecidableEq H] + +/-- A domain equivalence preserves the profile of a word. -/ +theorem wordProfile_comp_equiv (e : D ≃ E) (f : E → H) : + wordProfile (f ∘ e) = wordProfile f := by + funext h + change (Finset.univ.filter (fun i : D => f (e i) = h)).card = + (Finset.univ.filter (fun j : E => f j = h)).card + apply Finset.card_equiv e + intro i + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + +end Profile + +section Fiber + +variable {D E H : Type*} [Fintype D] [Fintype E] +variable [DecidableEq D] [DecidableEq E] [Fintype H] [DecidableEq H] + +/-- Reindexing gives an equivalence between words of the same profile. -/ +def wordFiberEquiv (e : D ≃ E) (n : H → ℕ) : + ↥(wordFiber D n) ≃ ↥(wordFiber E n) := by + refine Equiv.subtypeEquiv (Equiv.arrowCongr e (Equiv.refl H)) ?_ + intro f + change f ∈ Finset.univ.filter (fun g : D → H => wordProfile g = n) ↔ + (f ∘ e.symm) ∈ Finset.univ.filter (fun g : E → H => wordProfile g = n) + rw [Finset.mem_filter, Finset.mem_filter] + constructor + · intro hf + exact ⟨Finset.mem_univ _, (wordProfile_comp_equiv e.symm f).trans hf.2⟩ + · intro hf + exact ⟨Finset.mem_univ _, (wordProfile_comp_equiv e.symm f).symm.trans hf.2⟩ + +/-- Equivalent finite domains have equally many words of each profile. -/ +theorem wordFiber_card_eq_of_equiv (e : D ≃ E) (n : H → ℕ) : + (wordFiber D n).card = (wordFiber E n).card := by + simpa only [Fintype.card_coe] using Fintype.card_congr (wordFiberEquiv e n) + +end Fiber + +/-- The word count on any finite domain agrees with the count on `Fin`. -/ +theorem wordFiber_card_eq_wordCount (D : Type*) {H : Type*} + [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H] (n : H → ℕ) : + (wordFiber D n).card = wordCount (Fintype.card D) n := by + change (wordFiber D n).card = (wordFiber (Fin (Fintype.card D)) n).card + exact wordFiber_card_eq_of_equiv (Fintype.equivFin D) n + +/-- Labels on a finite set are counted by the word count for its cardinality. -/ +theorem wordFiber_finset_card {α H : Type*} [DecidableEq α] + [Fintype H] [DecidableEq H] (U : Finset α) (n : H → ℕ) : + (wordFiber ↥U n).card = wordCount U.card n := by + change (wordFiber ↥U n).card = (wordFiber (Fin U.card) n).card + exact wordFiber_card_eq_of_equiv U.equivFin n + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDefinitions.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDefinitions.lean new file mode 100644 index 0000000000000000000000000000000000000000..5dc4d15b2fb4bdbb759660e5803852d20c7f53e2 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDefinitions.lean @@ -0,0 +1,116 @@ +import OAI.Combinatorics.ExpectationThreshold.Basic +import OAI.Combinatorics.ExpectationThreshold.ProbabilityColors +import OAI.Combinatorics.ExpectationThreshold.SelectorTruncationDefinitions +import Mathlib.Data.Fintype.Pi +import Mathlib.Data.Finset.Lattice.Fold + +namespace OAI + +/-! +# Actual moves and profiles for the simultaneous selector + +We retain all colorings of minimum total movement for at least one original +family member. This avoids an arbitrary tie-breaking order; each retained +coloring still has the member-specific minimality used in reconstruction. +-/ + +noncomputable section + +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- A probability mass for each actual member of the family. -/ +structure MassFamily (F : Family α) where + weight : ↥F → α → ℝ + nonneg : ∀ H x, 0 ≤ weight H x + total : ∀ H, ∑ x, weight H x = 1 + supported : ∀ H x, x ∉ H.val → weight H x = 0 + +/-- Colors have zero-based indices; the actual color level is one larger. -/ +def prefixSet {s : ℕ} (z : Coloring α s) (i : Fin s) : Finset α := + Finset.univ.filter fun x => (z x).val ≤ i.val + +def dscale {s : ℕ} (i : Fin s) : ℝ := ((2 : ℝ) ^ (i.val + 1))⁻¹ + +/-- `Earlier a z` means that the move from `a` to `z` only lowers colors. -/ +def Earlier {s : ℕ} (a z : Coloring α s) : Prop := ∀ x, z x ≤ a x + +def changes {s : ℕ} (a z : Coloring α s) : Finset α := + Finset.univ.filter fun x => z x < a x + +def crossings {s : ℕ} (a z : Coloring α s) (i : Fin s) : ℕ := + (prefixSet z i \ prefixSet a i).card + +def movement {s : ℕ} (a z : Coloring α s) : ℕ := + ∑ x, ((a x).val - (z x).val) + +def movedRow {s : ℕ} (a z : Coloring α s) (i : Fin s) : Finset α := + Finset.univ.filter fun x => (z x).val = i.val ∧ (z x).val < (a x).val + +/-- The full profile retains both final and original colors. -/ +abbrev Profile (s : ℕ) := Fin s → Color s → ℕ + +def profile {s : ℕ} (a z : Coloring α s) : Profile s := + fun i h => (Finset.univ.filter fun x => + (z x).val = i.val ∧ a x = h ∧ i.val < h.val).card + +def rowCount {s : ℕ} (n : Profile s) (i : Fin s) : ℕ := ∑ h, n i h + +def profileSize {s : ℕ} (n : Profile s) : ℕ := ∑ i, rowCount n i + +def profileCrossings {s : ℕ} (n : Profile s) (i : Fin s) : ℕ := + ∑ j : Fin s, ∑ h : Color s, + if j.val ≤ i.val ∧ i.val < h.val then n j h else 0 + +def FeasibleFor {F : Family α} (mu : MassFamily F) {s : ℕ} + (a z : Coloring α s) (H : ↥F) : Prop := + ∀ i : Fin s, ∃ ε : ℝ, + Admissible (mu.weight H) (prefixSet z i) (crossings a z i : ℝ) (dscale i) ε + +def Feasible {F : Family α} (mu : MassFamily F) {s : ℕ} + (a z : Coloring α s) : Prop := + Earlier a z ∧ ∃ H : ↥F, FeasibleFor mu a z H + +def BoundedFeasible {F : Family α} (mu : MassFamily F) {s : ℕ} + (a : Coloring α s) (H₀ : ↥F) (z : Coloring α s) : Prop := + Feasible mu a z ∧ changes a z ⊆ H₀.val + +def IsMinimalMove {F : Family α} (mu : MassFamily F) {s : ℕ} + (a : Coloring α s) (H₀ : ↥F) (z : Coloring α s) : Prop := + BoundedFeasible mu a H₀ z ∧ + ∀ w, BoundedFeasible mu a H₀ w → movement a z ≤ movement a w + +def Selected {F : Family α} (mu : MassFamily F) {s : ℕ} + (a z : Coloring α s) : Prop := ∃ H₀ : ↥F, IsMinimalMove mu a H₀ z + +def selectedMoves {F : Family α} (mu : MassFamily F) {s : ℕ} + (a : Coloring α s) : Finset (Coloring α s) := by + classical + exact Finset.univ.filter (Selected mu a) + +/-- An actual bad original coloring, its selected endpoint, and its full profile. -/ +def Captured {F : Family α} (mu : MassFamily F) {s : ℕ} + (a : Coloring α s) : Prop := + ∃ H : ↥F, ∀ i : Fin s, + 1 - dscale i ≤ ∑ x ∈ prefixSet a i, mu.weight H x + +def Bad {F : Family α} (mu : MassFamily F) {s : ℕ} + (a : Coloring α s) : Prop := ¬ Captured mu a + +def groupOriginals {F : Family α} (mu : MassFamily F) {s : ℕ} + (z : Coloring α s) (n : Profile s) : Finset (Coloring α s) := by + classical + exact Finset.univ.filter fun a => Bad mu a ∧ Selected mu a z ∧ profile a z = n + +def meanColor {F : Family α} (mu : MassFamily F) {s : ℕ} + (H : ↥F) (a : Coloring α s) : ℝ := + ∑ x, ((a x).val + 1 : ℝ) * mu.weight H x + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDefinitionsLemmas.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDefinitionsLemmas.lean new file mode 100644 index 0000000000000000000000000000000000000000..f356cf541d4593dc818d7c03e655f3f977231fc1 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDefinitionsLemmas.lean @@ -0,0 +1,21 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitions + +namespace OAI + +/-! Elementary bounds on the literal truncation scales. -/ + +namespace TalagrandThreshold.Selector + +theorem dscale_pos {s : ℕ} (i : Fin s) : 0 < dscale i := by + exact inv_pos.mpr (pow_pos (by norm_num : (0 : ℝ) < 2) _) + +theorem dscale_nonneg {s : ℕ} (i : Fin s) : 0 ≤ dscale i := + (dscale_pos i).le + +theorem dscale_lt_one {s : ℕ} (i : Fin s) : dscale i < 1 := by + exact inv_lt_one_of_one_lt₀ + (one_lt_pow₀ (by norm_num : (1 : ℝ) < 2) (Nat.succ_ne_zero i.val)) + +end TalagrandThreshold.Selector + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDelay.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDelay.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfa9063ad2748f577a1a3dc9f4335bc5fbf77566 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDelay.lean @@ -0,0 +1,146 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitions +import Lean.Elab.Tactic.Omega + +namespace OAI + +/-! +# Delaying one moved coordinate by one color + +When a moved coordinate has final color `i`, replacing it by `i.succ` removes +exactly that coordinate from the prefixSet at cut `i`. Every other cut stays +unchanged, and total movement decreases by one. +-/ + +noncomputable section + +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] {s : ℕ} + +/-- Raise the final color of `x` to the color immediately after cut `i`. -/ +def delayColor (z : Coloring α s) (x : α) (i : Fin s) : Coloring α s := + Function.update z x i.succ + +omit [Fintype α] in +@[simp] theorem delayColor_apply_self (z : Coloring α s) (x : α) (i : Fin s) : + delayColor z x i x = i.succ := by + simp [delayColor] + +omit [Fintype α] in +theorem delayColor_apply_of_ne (z : Coloring α s) (x : α) (i : Fin s) + (y : α) (hy : y ≠ x) : delayColor z x i y = z y := by + simp [delayColor, hy] + +omit [Fintype α] in +theorem earlier_delayColor (a z : Coloring α s) (x : α) (i : Fin s) + (hx : (z x).val = i.val) (hmove : (z x).val < (a x).val) + (hearlier : Earlier a z) : Earlier a (delayColor z x i) := by + intro y + by_cases hy : y = x + · subst y + rw [delayColor_apply_self] + change i.val + 1 ≤ (a x).val + omega + · rw [delayColor_apply_of_ne z x i y hy] + exact hearlier y + +/-- Delaying a coordinate cannot introduce a newly moved vertex. -/ +theorem changes_delayColor_subset (a z : Coloring α s) (x : α) (i : Fin s) + (hx : (z x).val = i.val) : changes a (delayColor z x i) ⊆ changes a z := by + intro y hy + have hlt : delayColor z x i y < a y := (Finset.mem_filter.mp hy).2 + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ y, ?_⟩ + by_cases hyx : y = x + · subst y + rw [delayColor_apply_self] at hlt + change i.val + 1 < (a x).val at hlt + change (z x).val < (a x).val + omega + · rw [delayColor_apply_of_ne z x i y hyx] at hlt + exact hlt + +theorem prefix_delayColor_self (z : Coloring α s) (x : α) (i : Fin s) + (_hx : (z x).val = i.val) : + prefixSet (delayColor z x i) i = (prefixSet z i).erase x := by + ext y + by_cases hy : y = x + · subst y + simp only [prefixSet, Finset.mem_filter, Finset.mem_univ, true_and, + Finset.mem_erase, delayColor_apply_self] + simp + · constructor + · intro hnew + have hle : (delayColor z x i y).val ≤ i.val := + (Finset.mem_filter.mp hnew).2 + rw [delayColor_apply_of_ne z x i y hy] at hle + exact Finset.mem_erase.mpr + ⟨hy, Finset.mem_filter.mpr ⟨Finset.mem_univ y, hle⟩⟩ + · intro hold + have hmem : y ∈ prefixSet z i := (Finset.mem_erase.mp hold).2 + have hle : (z y).val ≤ i.val := (Finset.mem_filter.mp hmem).2 + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ y, ?_⟩ + rw [delayColor_apply_of_ne z x i y hy] + exact hle + +theorem prefix_delayColor_of_ne (z : Coloring α s) (x : α) (i j : Fin s) + (hx : (z x).val = i.val) (hji : j ≠ i) : + prefixSet (delayColor z x i) j = prefixSet z j := by + ext y + by_cases hy : y = x + · subst y + have hvals : j.val ≠ i.val := fun h => hji (Fin.ext h) + simp only [prefixSet, Finset.mem_filter, Finset.mem_univ, true_and, + delayColor_apply_self] + change i.val + 1 ≤ j.val ↔ (z x).val ≤ j.val + omega + · simp only [prefixSet, Finset.mem_filter, Finset.mem_univ, true_and] + rw [delayColor_apply_of_ne z x i y hy] + +/-- Exactly one crossing disappears at the affected cut. -/ +theorem crossings_delayColor_self (a z : Coloring α s) (x : α) (i : Fin s) + (hx : (z x).val = i.val) (hmove : (z x).val < (a x).val) : + crossings a (delayColor z x i) i + 1 = crossings a z i := by + unfold crossings + rw [prefix_delayColor_self z x i hx, Finset.erase_sdiff_comm] + apply Finset.card_erase_add_one + simp only [Finset.mem_sdiff, prefixSet, Finset.mem_filter, Finset.mem_univ, true_and] + constructor <;> omega + +theorem crossings_delayColor_of_ne (a z : Coloring α s) (x : α) (i j : Fin s) + (hx : (z x).val = i.val) (hji : j ≠ i) : + crossings a (delayColor z x i) j = crossings a z j := by + unfold crossings + rw [prefix_delayColor_of_ne z x i j hx hji] + +/-- The delay removes precisely one unit of total movement. -/ +theorem movement_delayColor_add_one (a z : Coloring α s) (x : α) (i : Fin s) + (hx : (z x).val = i.val) (hmove : (z x).val < (a x).val) : + movement a (delayColor z x i) + 1 = movement a z := by + let f : α → ℕ := fun y => (a y).val - (z y).val + let g : α → ℕ := fun y => (a y).val - (delayColor z x i y).val + have hrest : (∑ y ∈ Finset.univ.erase x, g y) = + ∑ y ∈ Finset.univ.erase x, f y := by + apply Finset.sum_congr rfl + intro y hy + have hne : y ≠ x := (Finset.mem_erase.mp hy).1 + dsimp only [g, f] + rw [delayColor_apply_of_ne z x i y hne] + have hpoint : g x + 1 = f x := by + dsimp only [g, f] + rw [delayColor_apply_self] + change (a x).val - (i.val + 1) + 1 = (a x).val - (z x).val + omega + change (∑ y, g y) + 1 = ∑ y, f y + rw [← Finset.sum_erase_add Finset.univ g (Finset.mem_univ x), + ← Finset.sum_erase_add Finset.univ f (Finset.mem_univ x), hrest] + omega + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDelayFeasibility.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDelayFeasibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbe3380d242bde334982bb79652660f84a66fc8c --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorDelayFeasibility.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDelay +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Feasibility after delaying one color + +Removing a point from a tested prefixSet subtracts exactly its truncated weight +from the excess. If that point is not heavy, the heavy-set condition survives; +the crossing count decreases by one, so the same cutoff remains admissible. +The other tests and their cutoffs are unchanged. +-/ + +noncomputable section + +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] + +theorem truncatedExcess_erase (mu : α → ℝ) (A : Finset α) (d u : ℝ) + (x : α) (hx : x ∈ A) : + truncatedExcess mu (A.erase x) d u = + truncatedExcess mu A d u - min (mu x) u := by + classical + unfold truncatedExcess + calc + (∑ y, min (mu y) u * ((if y ∈ A.erase x then 1 else 0) - (1 - d))) = + ∑ y, (min (mu y) u * ((if y ∈ A then 1 else 0) - (1 - d)) - + if y = x then min (mu x) u else 0) := by + apply Finset.sum_congr rfl + intro y hy + by_cases hyx : y = x + · subst y + simp only [Finset.notMem_erase, ite_false, hx, ite_true] + ring + · simp [Finset.mem_erase, hyx] + _ = (∑ y, min (mu y) u * ((if y ∈ A then 1 else 0) - (1 - d))) - + min (mu x) u := by + rw [Finset.sum_sub_distrib] + simp + +/-- The same cutoff works after deleting a non-heavy point and reducing the +crossing parameter by one. No maximality assumption on the cutoff is used. -/ +theorem Admissible.erase_one {mu : α → ℝ} {A : Finset α} {m m' d u : ℝ} + (hu : Admissible mu A m d u) {x : α} (hx : x ∈ A) + (hxu : mu x ≤ u) (hm : m' + 1 = m) : + Admissible mu (A.erase x) m' d u := by + refine ⟨hu.1, hu.2.1, ?_, ?_⟩ + · intro y hy + refine Finset.mem_erase.mpr ⟨?_, hu.2.2.1 y hy⟩ + intro hyx + subst y + exact (not_lt_of_ge hxu) hy + · rw [truncatedExcess_erase mu A d u x hx] + calc + m' * u = m * u - u := by rw [← hm]; ring + _ ≤ truncatedExcess mu A d u - u := sub_le_sub_right hu.2.2.2 u + _ ≤ truncatedExcess mu A d u - min (mu x) u := + sub_le_sub_left (min_le_right (mu x) u) _ + +/-- An actual one-step delay preserves all tests for the same family member. +At the affected scale it uses the supplied cutoff; all other cutoffs are the +ones already supplied by `hfeasible`. -/ +theorem feasibleFor_delayColor {F : Family α} (mu : MassFamily F) {s : ℕ} + (a z : Coloring α s) (H : ↥F) (hfeasible : FeasibleFor mu a z H) + (x : α) (i : Fin s) (hx : (z x).val = i.val) + (hmove : (z x).val < (a x).val) (ε : ℝ) + (hε : Admissible (mu.weight H) (prefixSet z i) + (crossings a z i : ℝ) (dscale i) ε) + (hweight : mu.weight H x ≤ ε) : + FeasibleFor mu a (delayColor z x i) H := by + intro j + by_cases hji : j = i + · subst j + refine ⟨ε, ?_⟩ + rw [prefix_delayColor_self z x i hx] + have hmem : x ∈ prefixSet z i := by simp [prefixSet, hx] + have hcount : (crossings a (delayColor z x i) i : ℝ) + 1 = + (crossings a z i : ℝ) := by + simpa only [Nat.cast_add, Nat.cast_one] using + congrArg (fun k : ℕ => (k : ℝ)) + (crossings_delayColor_self a z x i hx hmove) + exact hε.erase_one hmem hweight hcount + · obtain ⟨u, hu⟩ := hfeasible j + refine ⟨u, ?_⟩ + rw [prefix_delayColor_of_ne z x i j hx hji, + crossings_delayColor_of_ne a z x i j hx hji] + exact hu + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorEntropy.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..93d10ea039f167311f5e31ba40c46e21fd03664d --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorEntropy.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorEntropyDyadic +import Mathlib.Data.Nat.Choose.Bounds +import Mathlib.Analysis.Complex.Exponential +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# The selector's finite entropy estimate + +After scaling row `i` by `4^(i+1)`, its binomial coefficient is bounded by +one term of the exponential series at `T * 2^(-(i+1))`. The sum of these +arguments is at most `T`, so their product is at most `exp T ≤ 3^T`. +This proves the row-count estimate directly, including rows of count zero. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +/-- A finite series and its explicit remainder already give the needed slack. -/ +private theorem selector_exp_one_le_three : Real.exp 1 ≤ 3 := by + have h := Real.exp_bound' (x := (1 : ℝ)) (n := 3) + (by norm_num) (by norm_num) (by norm_num) + exact h.trans (by norm_num [Finset.sum_range_succ]) + +/-- A scaled binomial coefficient is bounded by an exponential-series term. -/ +theorem selector_choose_le_scaled_exp (m t : ℕ) (d y : ℝ) + (hd : 0 ≤ d) (hy : 0 ≤ y) (hm : (m : ℝ) ≤ d * y) : + (m.choose t : ℝ) ≤ d ^ t * Real.exp y := by + calc + (m.choose t : ℝ) ≤ (m : ℝ) ^ t / (t.factorial : ℝ) := + Nat.choose_le_pow_div t m + _ ≤ (d * y) ^ t / (t.factorial : ℝ) := + div_le_div_of_nonneg_right + (pow_le_pow_left₀ (Nat.cast_nonneg m) hm t) (Nat.cast_nonneg _) + _ = d ^ t * (y ^ t / (t.factorial : ℝ)) := by rw [mul_pow]; ring + _ ≤ d ^ t * Real.exp y := + mul_le_mul_of_nonneg_left (Real.pow_div_factorial_le_exp y hy t) + (pow_nonneg hd t) + +/-- The actual finite entropy bound for the selector's row sizes and counts. +The statement also permits total count zero. -/ +theorem selector_entropy_bound (s : ℕ) (m t : Fin s → ℕ) + (hm : ∀ i, m i ≤ 2 ^ (i.val + 1) * (∑ j, t j)) : + (∏ i, ((m i).choose (t i) : ℝ)) ≤ + ∏ i, (3 * 4 ^ (i.val + 1) : ℝ) ^ (t i) := by + let T : ℕ := ∑ i, t i + have hT : (0 : ℝ) ≤ T := Nat.cast_nonneg T + have hrow (i : Fin s) : + ((m i).choose (t i) : ℝ) ≤ + ((4 : ℝ) ^ (i.val + 1)) ^ (t i) * + Real.exp ((T : ℝ) * (1 / 2 : ℝ) ^ (i.val + 1)) := by + have hbound : (m i : ℝ) ≤ (2 : ℝ) ^ (i.val + 1) * (T : ℝ) := by + have hnat : m i ≤ 2 ^ (i.val + 1) * T := hm i + exact_mod_cast hnat + have hscale : (4 : ℝ) ^ (i.val + 1) * + ((T : ℝ) * (1 / 2 : ℝ) ^ (i.val + 1)) = + (2 : ℝ) ^ (i.val + 1) * (T : ℝ) := by + calc + (4 : ℝ) ^ (i.val + 1) * + ((T : ℝ) * (1 / 2 : ℝ) ^ (i.val + 1)) = + ((4 : ℝ) * (1 / 2 : ℝ)) ^ (i.val + 1) * (T : ℝ) := by + rw [mul_pow] + ring + _ = (2 : ℝ) ^ (i.val + 1) * (T : ℝ) := by norm_num + apply selector_choose_le_scaled_exp + (m i) (t i) ((4 : ℝ) ^ (i.val + 1)) + ((T : ℝ) * (1 / 2 : ℝ) ^ (i.val + 1)) + · exact pow_nonneg (by norm_num) _ + · exact mul_nonneg hT (pow_nonneg (by norm_num) _) + · rw [hscale] + exact hbound + have hsum : (∑ i : Fin s, (T : ℝ) * (1 / 2 : ℝ) ^ (i.val + 1)) ≤ + (T : ℝ) := by + rw [← Finset.mul_sum] + exact mul_le_of_le_one_right hT (selector_dyadic_sum_le_one s) + have hexp : Real.exp (T : ℝ) ≤ (3 : ℝ) ^ T := by + calc + Real.exp (T : ℝ) = Real.exp 1 ^ T := by + simpa only [mul_one] using Real.exp_nat_mul 1 T + _ ≤ (3 : ℝ) ^ T := + pow_le_pow_left₀ (Real.exp_pos 1).le selector_exp_one_le_three T + have hprod : (0 : ℝ) ≤ ∏ i : Fin s, ((4 : ℝ) ^ (i.val + 1)) ^ (t i) := + Finset.prod_nonneg (fun i _ => pow_nonneg (pow_nonneg (by norm_num) _) _) + have hfactor : (∏ i, (3 * 4 ^ (i.val + 1) : ℝ) ^ (t i)) = + (∏ i, ((4 : ℝ) ^ (i.val + 1)) ^ (t i)) * (3 : ℝ) ^ T := by + simp only [mul_pow, Finset.prod_mul_distrib, Finset.prod_pow_eq_pow_sum] + exact mul_comm _ _ + calc + (∏ i, ((m i).choose (t i) : ℝ)) ≤ + ∏ i, (((4 : ℝ) ^ (i.val + 1)) ^ (t i) * + Real.exp ((T : ℝ) * (1 / 2 : ℝ) ^ (i.val + 1))) := + Finset.prod_le_prod₀ (fun i _ => Nat.cast_nonneg _) (fun i _ => hrow i) + _ = (∏ i, ((4 : ℝ) ^ (i.val + 1)) ^ (t i)) * + Real.exp (∑ i : Fin s, (T : ℝ) * (1 / 2 : ℝ) ^ (i.val + 1)) := by + rw [Finset.prod_mul_distrib, ← Real.exp_sum] + _ ≤ (∏ i, ((4 : ℝ) ^ (i.val + 1)) ^ (t i)) * Real.exp (T : ℝ) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp_of_le hsum) hprod + _ ≤ (∏ i, ((4 : ℝ) ^ (i.val + 1)) ^ (t i)) * (3 : ℝ) ^ T := + mul_le_mul_of_nonneg_left hexp hprod + _ = ∏ i, (3 * 4 ^ (i.val + 1) : ℝ) ^ (t i) := hfactor.symm + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorEntropyDyadic.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorEntropyDyadic.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c5923f4516a8d5205deec1facb576285263da9c --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorEntropyDyadic.lean @@ -0,0 +1,40 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Finite dyadic mass for the selector entropy estimate + +The positive dyadic levels have total mass at most one, including when there +are no levels. +-/ + +open scoped BigOperators + +namespace TalagrandThreshold + +private lemma selector_dyadic_range_sum (s : ℕ) : + (∑ i ∈ Finset.range s, (1 / 2 : ℝ) ^ (i + 1)) = 1 - (1 / 2 : ℝ) ^ s := by + induction s with + | zero => simp + | succ s ih => + rw [Finset.sum_range_succ, ih] + simp only [pow_succ] + ring + +/-- The dyadic weights of all positive selector levels sum to at most one. -/ +theorem selector_dyadic_sum_le_one (s : ℕ) : + (∑ i : Fin s, (1 / 2 : ℝ) ^ (i.val + 1)) ≤ 1 := by + calc + (∑ i : Fin s, (1 / 2 : ℝ) ^ (i.val + 1)) = + ∑ i ∈ Finset.range s, (1 / 2 : ℝ) ^ (i + 1) := + Fin.sum_univ_eq_sum_range (fun i : ℕ => (1 / 2 : ℝ) ^ (i + 1)) s + _ = 1 - (1 / 2 : ℝ) ^ s := selector_dyadic_range_sum s + _ ≤ 1 := sub_le_self _ (pow_nonneg (by norm_num) s) + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorFeasibility.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorFeasibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..70415e1274c6c62d4f7c727b692d89c9ccd2fa6e --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorFeasibility.lean @@ -0,0 +1,197 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitionsLemmas +import Mathlib.Data.Nat.Find +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Feasible minima and the actual containment cover + +Resetting an original family member to the first color proves existence of +a bounded feasible move. Minimization itself retains the unrestricted +feasibility witness from `Feasible`; the witness need not be that member. +All retained minima contribute their actual changed sets to a cover. +-/ + +noncomputable section + +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {F : Family α} {s : ℕ} + +/-- Reset only the specified member to zero, the first color index. -/ +def reset (a : Coloring α s) (H₀ : ↥F) : Coloring α s := + fun x => if x ∈ H₀.val then 0 else a x + +omit [Fintype α] in +theorem reset_earlier (a : Coloring α s) (H₀ : ↥F) : + Earlier a (reset a H₀) := by + intro x + by_cases hx : x ∈ H₀.val + · simp [reset, hx] + · simp [reset, hx] + +theorem changes_reset_subset (a : Coloring α s) (H₀ : ↥F) : + changes a (reset a H₀) ⊆ H₀.val := by + intro x hx + by_contra hnot + have hlt := (Finset.mem_filter.mp hx).2 + simp [reset, hnot] at hlt + +/-- The reset uses this one member as a witness, with every cutoff zero. -/ +theorem reset_feasibleFor (mu : MassFamily F) (a : Coloring α s) (H₀ : ↥F) : + FeasibleFor mu a (reset a H₀) H₀ := by + classical + intro i + refine ⟨0, le_rfl, zero_le_one, ?_, ?_⟩ + · intro x hpos + have hx : x ∈ H₀.val := by + by_contra hnot + rw [mu.supported H₀ x hnot] at hpos + exact (lt_irrefl (0 : ℝ)) hpos + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ x, ?_⟩ + change (if x ∈ H₀.val then (0 : Color s) else a x).val ≤ i.val + rw [ite_eq_left hx] + exact Nat.zero_le i.val + · have hmin : ∀ x, min (mu.weight H₀ x) (0 : ℝ) = 0 := + fun x => min_eq_right (mu.nonneg H₀ x) + simp only [truncatedExcess, hmin, zero_mul, Finset.sum_const_zero, mul_zero, le_refl] + +theorem reset_boundedFeasible (mu : MassFamily F) (a : Coloring α s) (H₀ : ↥F) : + BoundedFeasible mu a H₀ (reset a H₀) := + ⟨⟨reset_earlier a H₀, H₀, reset_feasibleFor mu a H₀⟩, changes_reset_subset a H₀⟩ + +/-- A minimum exists for every member, without restricting its witness. -/ +theorem exists_isMinimalMove (mu : MassFamily F) (a : Coloring α s) (H₀ : ↥F) : + ∃ z, IsMinimalMove mu a H₀ z := by + classical + let P : ℕ → Prop := fun k => + ∃ z : Coloring α s, BoundedFeasible mu a H₀ z ∧ movement a z = k + have hex : ∃ k, P k := + ⟨movement a (reset a H₀), reset a H₀, reset_boundedFeasible mu a H₀, rfl⟩ + obtain ⟨z, hz, hcost⟩ := Nat.find_spec hex + refine ⟨z, hz, ?_⟩ + intro w hw + rw [hcost] + exact Nat.find_min' hex ⟨w, hw, rfl⟩ + +theorem Selected.feasible {mu : MassFamily F} {a z : Coloring α s} + (hz : Selected mu a z) : Feasible mu a z := by + obtain ⟨H₀, hz⟩ := hz + exact hz.1.1 + +theorem Selected.earlier {mu : MassFamily F} {a z : Coloring α s} + (hz : Selected mu a z) : Earlier a z := hz.feasible.1 + +@[simp] theorem mem_selectedMoves {mu : MassFamily F} {a z : Coloring α s} : + z ∈ selectedMoves mu a ↔ Selected mu a z := by + classical + simp [selectedMoves] + +/-- Remove duplicate changed sets only when forming the containment cover. -/ +def selectedChanges (mu : MassFamily F) (a : Coloring α s) : Family α := by + classical + exact (selectedMoves mu a).image (changes a) + +theorem selectedChanges_covers (mu : MassFamily F) (a : Coloring α s) : + Covers (selectedChanges mu a) F := by + classical + intro H hH + obtain ⟨z, hz⟩ := exists_isMinimalMove mu a ⟨H, hH⟩ + refine ⟨changes a z, ?_, hz.1.2⟩ + exact Finset.mem_image.mpr + ⟨z, mem_selectedMoves.mpr ⟨⟨H, hH⟩, hz⟩, rfl⟩ + +/-- The sum over selected colorings dominates the cost with duplicates removed. -/ +theorem half_lt_selectedMoves_cost (mu : MassFamily F) (a : Coloring α s) + {p : ℝ} (hp : 0 ≤ p) (hF : ¬ Small p F) : + (1 / 2 : ℝ) < ∑ z ∈ selectedMoves mu a, p ^ (changes a z).card := by + classical + exact (cost_gt_of_not_small hF (selectedChanges_covers mu a)).trans_le + (cost_image_le hp (selectedMoves mu a) (changes a)) + +omit [DecidableEq α] in +/-- An earlier move with no changed vertex is the unchanged coloring. -/ +theorem eq_of_changes_eq_empty {a z : Coloring α s} (hz : Earlier a z) + (hempty : changes a z = ∅) : z = a := by + funext x + apply le_antisymm (hz x) + apply le_of_not_gt + intro hlt + have hx : x ∈ changes a z := Finset.mem_filter.mpr ⟨Finset.mem_univ x, hlt⟩ + rw [hempty] at hx + exact Finset.notMem_empty x hx + +/-- Restoring weights increases the excess: only heavy points change, and +their coefficient is the nonnegative value `d`. -/ +theorem truncatedExcess_le_original (w : α → ℝ) (A : Finset α) (d u : ℝ) + (hd : 0 ≤ d) (hheavy : ∀ x, u < w x → x ∈ A) : + truncatedExcess w A d u ≤ + ∑ x, w x * ((if x ∈ A then 1 else 0) - (1 - d)) := by + classical + unfold truncatedExcess + apply Finset.sum_le_sum + intro x _ + by_cases hx : x ∈ A + · have hcoef : ((if x ∈ A then (1 : ℝ) else 0) - (1 - d)) = d := by + rw [ite_eq_left hx] + ring + rw [hcoef] + exact mul_le_mul_of_nonneg_right (min_le_left (w x) u) hd + · have hxu : w x ≤ u := le_of_not_gt (fun h => hx (hheavy x h)) + rw [min_eq_left hxu] + +theorem originalExcess_eq_mass_sub (w : α → ℝ) (A : Finset α) (d : ℝ) + (htotal : ∑ x, w x = 1) : + (∑ x, w x * ((if x ∈ A then 1 else 0) - (1 - d))) = + (∑ x ∈ A, w x) - (1 - d) := by + classical + calc + (∑ x, w x * ((if x ∈ A then 1 else 0) - (1 - d))) = + (∑ x, if x ∈ A then w x else 0) - (∑ x, w x) * (1 - d) := by + rw [Finset.sum_mul, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro x _ + split_ifs <;> ring + _ = (∑ x ∈ A, w x) - (1 - d) := by + rw [Finset.sum_ite_mem_eq, htotal, one_mul] + +/-- The actual feasibility witness is chosen once, before the scale index. -/ +theorem captured_of_feasible_self {mu : MassFamily F} {a : Coloring α s} + (h : Feasible mu a a) : Captured mu a := by + classical + obtain ⟨H, hH⟩ := h.2 + refine ⟨H, ?_⟩ + intro i + obtain ⟨u, hu⟩ := hH i + have htest : 0 ≤ truncatedExcess (mu.weight H) (prefixSet a i) (dscale i) u := by + simpa [crossings] using hu.2.2.2 + have hfull : 0 ≤ (∑ x ∈ prefixSet a i, mu.weight H x) - (1 - dscale i) := by + calc + 0 ≤ truncatedExcess (mu.weight H) (prefixSet a i) (dscale i) u := htest + _ ≤ ∑ x, mu.weight H x * + ((if x ∈ prefixSet a i then 1 else 0) - (1 - dscale i)) := + truncatedExcess_le_original (mu.weight H) (prefixSet a i) (dscale i) u + (dscale_nonneg i) hu.2.2.1 + _ = (∑ x ∈ prefixSet a i, mu.weight H x) - (1 - dscale i) := + originalExcess_eq_mass_sub (mu.weight H) (prefixSet a i) (dscale i) (mu.total H) + exact sub_nonneg.mp hfull + +theorem Selected.changes_nonempty {mu : MassFamily F} {a z : Coloring α s} + (hz : Selected mu a z) (ha : Bad mu a) : (changes a z).Nonempty := by + apply Finset.nonempty_iff_ne_empty.mpr + intro hempty + have hza : z = a := eq_of_changes_eq_empty hz.earlier hempty + have hself : Feasible mu a a := by simpa only [hza] using hz.feasible + exact ha (captured_of_feasible_self hself) + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGlobalCost.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGlobalCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..c71b8365d80e66474e70713bfa0c787682b86698 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGlobalCost.lean @@ -0,0 +1,163 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorGroupCost +import OAI.Combinatorics.ExpectationThreshold.SelectorGlobalCostProfiles +import OAI.Combinatorics.ExpectationThreshold.SelectorFeasibility +import OAI.Combinatorics.ExpectationThreshold.SelectorProfile + +namespace OAI + +/-! +# The global cost of actual selected moves + +Partition selected pairs first by their final coloring and then by their +full profile. The profile estimate removes the profile-dependent heavy +sets before summation. Word-count normalization and the finite geometric +bound then give the strict budget under the actual coloring law. +-/ + +noncomputable section + +open scoped BigOperators Classical + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {F : Family α} {s : ℕ} + +/-- Actual bad original colorings that select one fixed endpoint. -/ +def selectedOriginals (mu : MassFamily F) (z : Coloring α s) : + Finset (Coloring α s) := by + classical + exact Finset.univ.filter fun a => Bad mu a ∧ Selected mu a z + +/-- Only the full profiles that occur for this endpoint. -/ +def selectedProfiles (mu : MassFamily F) (z : Coloring α s) : + Finset (Profile s) := by + classical + exact (selectedOriginals mu z).image fun a => profile a z + +@[simp] theorem mem_selectedOriginals (mu : MassFamily F) + (a z : Coloring α s) : + a ∈ selectedOriginals mu z ↔ Bad mu a ∧ Selected mu a z := by + classical + simp only [selectedOriginals, Finset.mem_filter, Finset.mem_univ, true_and] + +/-- A selected move from a bad coloring has a nonzero tuple of row sizes. -/ +theorem selectedProfiles_rowCount_ne_zero (mu : MassFamily F) + (z : Coloring α s) (n : Profile s) (hn : n ∈ selectedProfiles mu z) : + rowCount n ≠ 0 := by + classical + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hn + obtain ⟨hbad, hselected⟩ := (mem_selectedOriginals mu a z).mp ha + intro hz + have hpos := Finset.card_pos.mpr (hselected.changes_nonempty hbad) + rw [← profileSize_profile a z] at hpos + simp only [profileSize, hz, Pi.zero_apply, Finset.sum_const_zero, + lt_self_iff_false] at hpos + +/-- Grouping by the actual full profile loses no original coloring. -/ +theorem selected_endpoint_cost_grouped (mu : MassFamily F) + (z : Coloring α s) (f : Coloring α s → ℝ) : + (∑ a ∈ selectedOriginals mu z, f a) = + ∑ n ∈ selectedProfiles mu z, ∑ a ∈ groupOriginals mu z n, f a := by + classical + have hgroup (n : Profile s) : + (selectedOriginals mu z).filter (fun a => profile a z = n) = + groupOriginals mu z n := by + ext a + simp [selectedOriginals, groupOriginals, and_assoc] + symm + calc + (∑ n ∈ selectedProfiles mu z, ∑ a ∈ groupOriginals mu z n, f a) = + ∑ n ∈ selectedProfiles mu z, + ∑ a ∈ (selectedOriginals mu z).filter (fun a => profile a z = n), f a := by + simp only [hgroup] + _ = ∑ a ∈ selectedOriginals mu z, f a := + Finset.sum_fiberwise_of_maps_to + (fun a ha => Finset.mem_image.mpr ⟨a, ha, rfl⟩) f + +/-- Swapping the two finite sums groups all actual selected pairs by endpoint. -/ +theorem selected_cost_group_by_endpoint (mu : MassFamily F) + (f : Coloring α s → Coloring α s → ℝ) : + (∑ a ∈ (Finset.univ : Finset (Coloring α s)).filter (Bad mu), + ∑ z ∈ selectedMoves mu a, f a z) = + ∑ z : Coloring α s, ∑ a ∈ selectedOriginals mu z, f a z := by + classical + calc + (∑ a ∈ (Finset.univ : Finset (Coloring α s)).filter (Bad mu), + ∑ z ∈ selectedMoves mu a, f a z) = + ∑ a : Coloring α s, ∑ z : Coloring α s, + if Bad mu a ∧ Selected mu a z then f a z else 0 := by + simp only [selectedMoves, Finset.sum_filter] + apply Finset.sum_congr rfl + intro a _ + by_cases ha : Bad mu a <;> simp [ha] + _ = ∑ z : Coloring α s, ∑ a ∈ selectedOriginals mu z, f a z := by + rw [Finset.sum_comm] + simp only [selectedOriginals, Finset.sum_filter] + +/-- All actual original colorings for one endpoint fit its probability-weighted budget. -/ +theorem selected_endpoint_cost_lt (mu : MassFamily F) + (p : ℝ) (s : ℕ) (hp : 0 < p) (hs : p * scaleSum s ≤ 1 / 2) + (z : Coloring α s) : + (∑ a ∈ selectedOriginals mu z, colorMass p s a * p ^ (changes a z).card) < + colorMass p s z * (1 / 20) := by + classical + calc + (∑ a ∈ selectedOriginals mu z, colorMass p s a * p ^ (changes a z).card) = + ∑ n ∈ selectedProfiles mu z, + ∑ a ∈ groupOriginals mu z n, colorMass p s a * p ^ (changes a z).card := + selected_endpoint_cost_grouped mu z _ + _ ≤ ∑ n ∈ selectedProfiles mu z, + colorMass p s z * + (∏ i : Fin s, (3 / (64 : ℝ) ^ (i.val + 1)) ^ (rowCount n i)) * + (∏ i : Fin s, ((wordCount (rowCount n i) (n i) : ℝ) * + ∏ h : Color s, colorProb p s h ^ (n i h))) := + Finset.sum_le_sum fun n _ => group_cost_le mu p s hp hs z n + _ = colorMass p s z * + (∑ n ∈ selectedProfiles mu z, + (∏ i : Fin s, (3 / (64 : ℝ) ^ (i.val + 1)) ^ (rowCount n i)) * + (∏ i : Fin s, ((wordCount (rowCount n i) (n i) : ℝ) * + ∏ h : Color s, colorProb p s h ^ (n i h)))) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro n _ + exact mul_assoc _ _ _ + _ < colorMass p s z * (1 / 20) := + mul_lt_mul_of_pos_left + (sum_profile_weights_lt_one_twentieth p s hp hs (selectedProfiles mu z) + (selectedProfiles_rowCount_ne_zero mu z)) + (colorMass_pos p s hp hs z) + +/-- The complete selected cost is strictly below one twentieth. All grouping, +counting, reconstruction, entropy, and probability facts are proved above. -/ +theorem selected_total_cost_lt_one_twentieth (mu : MassFamily F) + (p : ℝ) (s : ℕ) (hp : 0 < p) (hs : p * scaleSum s ≤ 1 / 2) : + (∑ a ∈ (Finset.univ : Finset (Coloring α s)).filter (Bad mu), + ∑ z ∈ selectedMoves mu a, colorMass p s a * p ^ (changes a z).card) < 1 / 20 := by + classical + rw [selected_cost_group_by_endpoint] + calc + (∑ z : Coloring α s, + ∑ a ∈ selectedOriginals mu z, colorMass p s a * p ^ (changes a z).card) < + ∑ z : Coloring α s, colorMass p s z * (1 / 20) := by + apply Finset.sum_lt_sum_of_nonempty + ⟨(fun _ => Fin.last s), Finset.mem_univ _⟩ + intro z _ + exact selected_endpoint_cost_lt mu p s hp hs z + _ = 1 / 20 := by + rw [← Finset.sum_mul, sum_colorMass, one_mul] + +/-- The same bound in expectation notation, ready for the bad-event argument. -/ +theorem weighted_bad_selected_cost_le (mu : MassFamily F) + (p : ℝ) (s : ℕ) (hp : 0 < p) (hs : p * scaleSum s ≤ 1 / 2) : + (∑ a : Coloring α s, if Bad mu a then + colorMass p s a * ∑ z ∈ selectedMoves mu a, p ^ (changes a z).card else 0) ≤ 1 / 20 := by + classical + simpa only [Finset.sum_filter, Finset.mul_sum] using + (selected_total_cost_lt_one_twentieth mu p s hp hs).le + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGlobalCostProfiles.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGlobalCostProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..2300554aecf7f39a9051f3ec76b616eba1026c8e --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGlobalCostProfiles.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitions +import OAI.Combinatorics.ExpectationThreshold.SelectorCountingWordsProducts +import OAI.Combinatorics.ExpectationThreshold.TupleGeometric + +namespace OAI + +/-! +# Summing the full-profile weights + +The reconstruction sets may depend on the entire profile. Once their counting +bound has been replaced by the uniform entropy bound, the remaining full +profiles can be grouped by row counts. The literal word-count weights have +total mass at most one within each such group. +-/ + +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +/-- The full-profile sum satisfies the selector budget for any finite family +whose row-count vectors are nonzero. No independence of the rows of the +profile family is required. -/ +theorem sum_profile_weights_lt_one_twentieth (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (N : Finset (Profile s)) + (hN : ∀ n ∈ N, rowCount n ≠ 0) : + (∑ n ∈ N, + (∏ i : Fin s, ((3 : ℝ) / 64 ^ (i.val + 1)) ^ (rowCount n i)) * + (∏ i : Fin s, ((wordCount (rowCount n i) (n i) : ℝ) * + ∏ h : Color s, colorProb p s h ^ (n i h)))) < 1 / 20 := by + classical + let c : (Fin s → ℕ) → ℝ := fun t => + ∏ i : Fin s, ((3 : ℝ) / 64 ^ (i.val + 1)) ^ (t i) + let w : (Fin s → ℕ) → Profile s → ℝ := fun t n => + ∏ i : Fin s, ((wordCount (t i) (n i) : ℝ) * + ∏ h : Color s, colorProb p s h ^ (n i h)) + let T : Finset (Fin s → ℕ) := N.image rowCount + have hc (t : Fin s → ℕ) : 0 ≤ c t := by + exact Finset.prod_nonneg fun i _ => + pow_nonneg (div_nonneg (by norm_num) (pow_nonneg (by norm_num) _)) _ + have hfiber (t : Fin s → ℕ) : + (∑ n ∈ N.filter (fun n => rowCount n = t), + c (rowCount n) * w (rowCount n) n) ≤ c t := by + have hw : (∑ n ∈ N.filter (fun n => rowCount n = t), w t n) ≤ 1 := + sum_prod_wordCount_weight_le_one t (N.filter (fun n => rowCount n = t)) + (colorProb p s) (colorProb_nonneg p s hp hs) (sum_colorProb p s).le + calc + (∑ n ∈ N.filter (fun n => rowCount n = t), + c (rowCount n) * w (rowCount n) n) = + c t * ∑ n ∈ N.filter (fun n => rowCount n = t), w t n := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro n hn + rw [(Finset.mem_filter.mp hn).2] + _ ≤ c t * 1 := mul_le_mul_of_nonneg_left hw (hc t) + _ = c t := mul_one _ + have hT : ∀ t ∈ T, t ≠ 0 := by + intro t ht + obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp ht + exact hN n hn + change (∑ n ∈ N, c (rowCount n) * w (rowCount n) n) < 1 / 20 + calc + (∑ n ∈ N, c (rowCount n) * w (rowCount n) n) = + ∑ t ∈ T, ∑ n ∈ N.filter (fun n => rowCount n = t), + c (rowCount n) * w (rowCount n) n := + (Finset.sum_fiberwise_of_maps_to + (fun n hn => Finset.mem_image_of_mem rowCount hn) + (fun n => c (rowCount n) * w (rowCount n) n)).symm + _ ≤ ∑ t ∈ T, c t := Finset.sum_le_sum fun t _ => hfiber t + _ < 1 / 20 := tuple_geometric_sum_lt_one_twentieth T hT + +end TalagrandThreshold.Selector + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGroupCost.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGroupCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba33e8d23ec2c4d1c34cf0e226ed26e15101c684 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorGroupCost.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorCountingEncodingBound +import OAI.Combinatorics.ExpectationThreshold.SelectorCommonWitness +import OAI.Combinatorics.ExpectationThreshold.SelectorProfile +import OAI.Combinatorics.ExpectationThreshold.SelectorEntropy +import OAI.Combinatorics.ExpectationThreshold.ProbabilityLikelihood +import OAI.Combinatorics.ExpectationThreshold.ColorArithmetic +import Mathlib.Tactic.Positivity + +namespace OAI + +/-! +# The actual contribution of one full selector profile + +The common heavy sets are obtained separately for each occurring profile. +The entropy estimate removes their sizes before profiles are summed, so no +uniform choice of heavy sets across distinct profiles is required. +-/ + +noncomputable section +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- A finite group with a fixed final coloring and full profile has the +claimed weighted contribution whenever its rows fit the actual heavy sets. -/ +theorem profile_group_cost_le (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) + (G : Finset (Coloring α s)) (z : Coloring α s) (n : Profile s) + (R : Fin s → Finset α) + (hEarlier : ∀ a ∈ G, Earlier a z) + (hprofile : ∀ a ∈ G, profile a z = n) + (hrows : ∀ a ∈ G, ∀ i, movedRow a z i ⊆ R i) + (hR : ∀ i, (R i).card ≤ 2 ^ (i.val + 1) * profileSize n) : + (∑ a ∈ G, colorMass p s a * p ^ (changes a z).card) ≤ + colorMass p s z * + (∏ i : Fin s, (3 / (64 : ℝ) ^ (i.val + 1)) ^ (rowCount n i)) * + (∏ i : Fin s, ((wordCount (rowCount n i) (n i) : ℝ) * + ∏ h : Color s, colorProb p s h ^ (n i h))) := by + classical + let C : ℝ := ∏ i : Fin s, ((R i).card.choose (rowCount n i) : ℝ) + let W : ℝ := ∏ i : Fin s, (wordCount (rowCount n i) (n i) : ℝ) + let L : ℝ := ∏ i : Fin s, (p / colorProb p s i.castSucc) ^ (rowCount n i) + let Q : ℝ := ∏ i : Fin s, ∏ h : Color s, colorProb p s h ^ (n i h) + let E : ℝ := ∏ i : Fin s, (3 * 4 ^ (i.val + 1) : ℝ) ^ (rowCount n i) + let K : ℝ := ∏ i : Fin s, (3 / (64 : ℝ) ^ (i.val + 1)) ^ (rowCount n i) + have hW : 0 ≤ W := Finset.prod_nonneg fun i _ => Nat.cast_nonneg _ + have hL : 0 ≤ L := Finset.prod_nonneg fun i _ => + pow_nonneg (div_nonneg hp.le (colorProb_nonneg p s hp hs _)) _ + have hQ : 0 ≤ Q := Finset.prod_nonneg fun i _ => + Finset.prod_nonneg fun h _ => pow_nonneg (colorProb_nonneg p s hp hs h) _ + have hP : 0 ≤ colorMass p s z := colorMass_nonneg p s hp hs z + have hcard : (G.card : ℝ) ≤ C * W := by + have h := card_le_profile_encoding G z n R hEarlier hprofile hrows + have hcast : (G.card : ℝ) ≤ + ∏ i : Fin s, ((R i).card.choose (rowCount n i) : ℝ) * + (wordCount (rowCount n i) (n i) : ℝ) := by + exact_mod_cast h + simpa only [Finset.prod_mul_distrib] using hcast + have hentropy : C ≤ E := + selector_entropy_bound s (fun i => (R i).card) (rowCount n) hR + have hnormalize : E * L = K := by + dsimp [E, L, K] + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + exact profile_coefficient_pow_eq hp s i (rowCount n i) + have hterm (a : Coloring α s) (ha : a ∈ G) : + colorMass p s a * p ^ (changes a z).card = colorMass p s z * L * Q := by + have h := colorMass_profile_likelihood p s hp hs a z (hEarlier a ha) + rw [hprofile a ha] at h + have hsize : (changes a z).card = profileSize n := by + rw [← profileSize_profile, hprofile a ha] + rw [hsize, mul_comm] + simpa only [Finset.prod_mul_distrib, mul_assoc] using h + calc + (∑ a ∈ G, colorMass p s a * p ^ (changes a z).card) = + (G.card : ℝ) * (colorMass p s z * L * Q) := by + simp only [Finset.sum_congr rfl hterm, Finset.sum_const, nsmul_eq_mul] + _ ≤ (C * W) * (colorMass p s z * L * Q) := + mul_le_mul_of_nonneg_right hcard (mul_nonneg (mul_nonneg hP hL) hQ) + _ = C * (W * (colorMass p s z * L * Q)) := by ring + _ ≤ E * (W * (colorMass p s z * L * Q)) := + mul_le_mul_of_nonneg_right hentropy + (mul_nonneg hW (mul_nonneg (mul_nonneg hP hL) hQ)) + _ = colorMass p s z * (E * L) * (W * Q) := by ring + _ = colorMass p s z * K * (W * Q) := by rw [hnormalize] + _ = _ := by + dsimp [K, W, Q] + rw [← Finset.prod_mul_distrib] + +/-- The contribution of an actual selected profile. All reconstruction and +counting premises are discharged by the concrete selector construction. -/ +theorem group_cost_le {F : Family α} (mu : MassFamily F) + (p : ℝ) (s : ℕ) (hp : 0 < p) (hs : p * scaleSum s ≤ 1 / 2) + (z : Coloring α s) (n : Profile s) : + (∑ a ∈ groupOriginals mu z n, colorMass p s a * p ^ (changes a z).card) ≤ + colorMass p s z * + (∏ i : Fin s, (3 / (64 : ℝ) ^ (i.val + 1)) ^ (rowCount n i)) * + (∏ i : Fin s, ((wordCount (rowCount n i) (n i) : ℝ) * + ∏ h : Color s, colorProb p s h ^ (n i h))) := by + classical + by_cases hne : (groupOriginals mu z n).Nonempty + · obtain ⟨R, hR, hrows⟩ := exists_common_heavy_sets mu z n hne + apply profile_group_cost_le p s hp hs (groupOriginals mu z n) z n R + · intro a ha + have h := (Finset.mem_filter.mp ha).2 + obtain ⟨H₀, hmin⟩ := h.2.1 + exact hmin.1.1.1 + · intro a ha + exact (Finset.mem_filter.mp ha).2.2.2 + · exact hrows + · exact hR + · have hempty : groupOriginals mu z n = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne + rw [hempty, Finset.sum_empty] + exact mul_nonneg + (mul_nonneg (colorMass_nonneg p s hp hs z) + (Finset.prod_nonneg fun i _ => pow_nonneg (by positivity) _)) + (Finset.prod_nonneg fun i _ => mul_nonneg (Nat.cast_nonneg _) + (Finset.prod_nonneg fun h _ => pow_nonneg (colorProb_nonneg p s hp hs h) _)) + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorMain.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..2fe8a43db25a9e9aa98ab66e0f0ae80b7d48d5cb --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorMain.lean @@ -0,0 +1,80 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorFeasibility +import OAI.Combinatorics.ExpectationThreshold.SelectorGlobalCost +import OAI.Combinatorics.ExpectationThreshold.SelectorAverageColor +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# The simultaneous multiscale selector + +The actual minimum-move cover bounds the bad probability from below by its +weighted cost. The profile reconstruction and counting theorem bounds that +same cost from above. Both conclusions use the literal independent color law. +-/ + +noncomputable section +open scoped BigOperators Classical + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- The actual selected changed sets give the cover-cost inequality. -/ +theorem half_bad_probability_le_selected_cost {F : Family α} + (mu : MassFamily F) (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (hF : ¬ Small p F) : + (1 / 2 : ℝ) * (coloringLaw (α := α) p s hp hs).prob (Bad mu) ≤ + ∑ a : Coloring α s, if Bad mu a then + colorMass p s a * ∑ z ∈ selectedMoves mu a, p ^ (changes a z).card + else 0 := by + classical + unfold FiniteLaw.prob + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro a _ + by_cases ha : Bad mu a + · simp only [ite_eq_left ha, coloringLaw_weight] + have hcover := (half_lt_selectedMoves_cost mu a hp.le hF).le + have hmass := colorMass_nonneg p s hp hs a + nlinarith + · simp only [ite_eq_right ha, mul_zero, le_refl] + +/-- The actual bad event has probability at most one tenth. -/ +theorem bad_probability_le_one_tenth {F : Family α} + (mu : MassFamily F) (p : ℝ) (s : ℕ) (hp : 0 < p) + (hs : p * scaleSum s ≤ 1 / 2) (hF : ¬ Small p F) : + (coloringLaw (α := α) p s hp hs).prob (Bad mu) ≤ 1 / 10 := by + have hcover := half_bad_probability_le_selected_cost mu p s hp hs hF + have hcount := weighted_bad_selected_cost_le mu p s hp hs + linarith + +/-- One family member is simultaneously captured at every scale. -/ +theorem simultaneous_capture (F : Family α) (_hF : F.Nonempty) + (_hsets : ∀ H ∈ F, H.Nonempty) (mu : MassFamily F) + (p : ℝ) (hp0 : 0 < p) (_hp1 : p ≤ 1) (hnotsmall : ¬ Small p F) + (s : ℕ) (hs : p * scaleSum s ≤ 1 / 2) : + (9 / 10 : ℝ) ≤ + (coloringLaw (α := α) p s hp0 hs).prob (Captured mu) := by + have hbad := bad_probability_le_one_tenth mu p s hp0 hs hnotsmall + have hcompl := (coloringLaw (α := α) p s hp0 hs).prob_compl (Captured mu) + change (coloringLaw (α := α) p s hp0 hs).prob (fun a => ¬ Captured mu a) ≤ + 1 / 10 at hbad + linarith + +/-- With probability at least nine tenths, one member has mean color at most two. -/ +theorem average_color (F : Family α) (hF : F.Nonempty) + (hsets : ∀ H ∈ F, H.Nonempty) (mu : MassFamily F) + (p : ℝ) (hp0 : 0 < p) (hp1 : p ≤ 1) (hnotsmall : ¬ Small p F) + (s : ℕ) (hs : p * scaleSum s ≤ 1 / 2) : + (9 / 10 : ℝ) ≤ (coloringLaw (α := α) p s hp0 hs).prob + (fun a => ∃ H : ↥F, meanColor mu H a ≤ 2) := by + exact (simultaneous_capture F hF hsets mu p hp0 hp1 hnotsmall s hs).trans + ((coloringLaw (α := α) p s hp0 hs).prob_mono + fun _ ha => ha.exists_meanColor_le_two) + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorProfile.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c2622f711b4e19e1c0e7ca61a88daffd2ae0da4 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorProfile.lean @@ -0,0 +1,212 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDefinitions + +namespace OAI + +/-! +# Exact counts in a selector profile + +The full profile records each strict downward move by its final and original +colors. These counting identities hold even without a global `Earlier` +hypothesis: every point counted by a crossing already moves downward. +-/ + +noncomputable section + +open scoped BigOperators + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] {s : ℕ} + +omit [DecidableEq α] in +/-- A profile entry is the original-color fiber within its moved row. -/ +theorem profile_eq_card_filter_movedRow (a z : Coloring α s) + (i : Fin s) (h : Color s) : + profile a z i h = ((movedRow a z i).filter fun x => a x = h).card := by + unfold profile movedRow + congr 1 + ext x + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · rintro ⟨hz, ha, hi⟩ + exact ⟨⟨hz, by simpa only [hz, ha] using hi⟩, ha⟩ + · rintro ⟨⟨hz, hi⟩, ha⟩ + exact ⟨hz, ha, by simpa only [hz, ha] using hi⟩ + +omit [DecidableEq α] in +/-- All original colors partition the moved row. -/ +theorem rowCount_profile (a z : Coloring α s) (i : Fin s) : + rowCount (profile a z) i = (movedRow a z i).card := by + unfold rowCount + simp_rw [profile_eq_card_filter_movedRow] + simpa using Finset.sum_card_fiberwise_eq_card_filter + (movedRow a z i) Finset.univ a + +omit [DecidableEq α] in +theorem movedRow_card_eq_rowCount (a z : Coloring α s) (i : Fin s) : + (movedRow a z i).card = rowCount (profile a z) i := + (rowCount_profile a z i).symm + +omit [DecidableEq α] in +theorem movedRow_subset_changes (a z : Coloring α s) (i : Fin s) : + movedRow a z i ⊆ changes a z := by + intro x hx + have hx' : (z x).val = i.val ∧ (z x).val < (a x).val := by + simpa only [movedRow, Finset.mem_filter, Finset.mem_univ, true_and] using hx + exact Finset.mem_filter.mpr ⟨Finset.mem_univ x, hx'.2⟩ + +omit [DecidableEq α] in +/-- The last color cannot be the final color of a strict downward move. -/ +theorem changes_filter_last (a z : Coloring α s) : + (changes a z).filter (fun x => z x = Fin.last s) = ∅ := by + ext x + simp only [Finset.mem_filter, changes, Finset.mem_univ, true_and, + Finset.notMem_empty, iff_false, not_and] + intro hmove hlast + have hlt : (z x).val < (a x).val := hmove + have hz : (z x).val = s := congrArg Fin.val hlast + have ha := (a x).isLt + omega + +omit [DecidableEq α] in +/-- The nonterminal final-color fibers are exactly the moved rows. -/ +theorem changes_filter_castSucc (a z : Coloring α s) (i : Fin s) : + (changes a z).filter (fun x => z x = i.castSucc) = movedRow a z i := by + ext x + simp only [Finset.mem_filter, changes, movedRow, Finset.mem_univ, true_and] + constructor + · rintro ⟨hmove, hz⟩ + exact ⟨congrArg Fin.val hz, hmove⟩ + · rintro ⟨hz, hmove⟩ + exact ⟨hmove, Fin.ext hz⟩ + +omit [DecidableEq α] in +/-- Every changed point has exactly one nonterminal final color. -/ +theorem profileSize_profile (a z : Coloring α s) : + profileSize (profile a z) = (changes a z).card := by + have hpartition : + (∑ h : Color s, ((changes a z).filter fun x => z x = h).card) = + (changes a z).card := by + simpa using Finset.sum_card_fiberwise_eq_card_filter + (changes a z) Finset.univ z + rw [Fin.sum_univ_castSucc, changes_filter_last, Finset.card_empty, + add_zero] at hpartition + simp_rw [changes_filter_castSucc] at hpartition + simpa only [profileSize, rowCount_profile] using hpartition + +omit [DecidableEq α] in +theorem profileSize_profile_eq_card_changes (a z : Coloring α s) : + profileSize (profile a z) = (changes a z).card := + profileSize_profile a z + +omit [DecidableEq α] in +/-- Entries on or below the diagonal vanish in every actual profile. -/ +theorem profile_eq_zero_of_le (a z : Coloring α s) (i : Fin s) + (h : Color s) (hhi : h.val ≤ i.val) : profile a z i h = 0 := by + simp [profile, Nat.not_lt.mpr hhi] + +/-- The full profile determines every actual crossing count. -/ +theorem crossings_eq_profileCrossings (a z : Coloring α s) (i : Fin s) : + crossings a z i = profileCrossings (profile a z) i := by + classical + let C := prefixSet z i \ prefixSet a i + have hC (x : α) : + x ∈ C ↔ (z x).val ≤ i.val ∧ i.val < (a x).val := by + simp [C, prefixSet, not_le] + have hsplit : + C.card = ∑ j : Color s, ∑ h : Color s, + (C.filter fun x => z x = j ∧ a x = h).card := by + calc + C.card = ∑ j : Color s, (C.filter fun x => z x = j).card := + Finset.card_eq_sum_card_fiberwise + (s := C) (t := (Finset.univ : Finset (Color s))) (f := z) + (fun _ _ => Finset.mem_univ _) + _ = _ := by + apply Finset.sum_congr rfl + intro j _ + simpa only [Finset.filter_filter] using + (Finset.card_eq_sum_card_fiberwise + (s := C.filter fun x => z x = j) + (t := (Finset.univ : Finset (Color s))) (f := a) + (fun _ _ => Finset.mem_univ _)) + have hcell (j h : Color s) : + (C.filter fun x => z x = j ∧ a x = h) = + if j.val ≤ i.val ∧ i.val < h.val then + Finset.univ.filter (fun x => + (z x).val = j.val ∧ a x = h ∧ j.val < h.val) + else ∅ := by + by_cases hc : j.val ≤ i.val ∧ i.val < h.val + · rw [ite_eq_left hc] + ext x + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · rintro ⟨_, hz, ha⟩ + exact ⟨congrArg Fin.val hz, ha, lt_of_le_of_lt hc.1 hc.2⟩ + · rintro ⟨hz, ha, _⟩ + have hz' : z x = j := Fin.ext hz + refine ⟨(hC x).mpr ?_, hz', ha⟩ + simpa only [hz', ha] using hc + · rw [ite_eq_right hc] + apply Finset.filter_eq_empty_iff.mpr + intro x hx hpair + rcases hpair with ⟨hz, ha⟩ + apply hc + simpa only [hz, ha] using (hC x).mp hx + have hlast : + (∑ h : Color s, + (C.filter fun x => z x = Fin.last s ∧ a x = h).card) = 0 := by + apply Finset.sum_eq_zero + intro h _ + rw [hcell] + have hnot : ¬ (Fin.last s).val ≤ i.val := + Nat.not_le.mpr i.isLt + simp only [hnot, false_and, ite_false, Finset.card_empty] + change C.card = _ + rw [hsplit, Fin.sum_univ_castSucc, hlast, add_zero] + unfold profileCrossings + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro h _ + rw [hcell] + by_cases hc : j.val ≤ i.val ∧ i.val < h.val + · simp only [Fin.val_castSucc, ite_eq_left hc, profile] + · simp only [Fin.val_castSucc, ite_eq_right hc, Finset.card_empty] + +theorem crossings_eq_of_profile_eq (a z : Coloring α s) (n : Profile s) + (hn : profile a z = n) (i : Fin s) : + crossings a z i = profileCrossings n i := by + rw [crossings_eq_profileCrossings, hn] + +/-- A row is bounded by the total size of any natural-valued profile. -/ +theorem rowCount_le_profileSize (n : Profile s) (i : Fin s) : + rowCount n i ≤ profileSize n := by + exact Finset.single_le_sum (fun j _ => Nat.zero_le (rowCount n j)) + (Finset.mem_univ i) + +/-- Restricting to entries crossing one level cannot increase total size. -/ +theorem profileCrossings_le_profileSize (n : Profile s) (i : Fin s) : + profileCrossings n i ≤ profileSize n := by + unfold profileCrossings profileSize rowCount + apply Finset.sum_le_sum + intro j _ + apply Finset.sum_le_sum + intro h _ + split_ifs <;> omega + +theorem crossings_le_card_changes (a z : Coloring α s) (i : Fin s) : + crossings a z i ≤ (changes a z).card := by + rw [crossings_eq_profileCrossings, ← profileSize_profile a z] + exact profileCrossings_le_profileSize (profile a z) i + +@[simp] theorem mem_groupOriginals {F : Family α} (mu : MassFamily F) + (a z : Coloring α s) (n : Profile s) : + a ∈ groupOriginals mu z n ↔ Bad mu a ∧ Selected mu a z ∧ profile a z = n := by + classical + simp only [groupOriginals, Finset.mem_filter, Finset.mem_univ, true_and] + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorReconstruction.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..f727257c51187b3770c35310378deae297b8835d --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorReconstruction.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorDelayFeasibility + +namespace OAI + +/-! +# Minimal moves reconstruct inside the heavy sets + +The family member in this theorem is any member witnessing feasibility of the +selected endpoint. It need not be the member restricting the changed set in +the minimization. This permits one witness to be used for an entire profile. +-/ + +noncomputable section + +namespace TalagrandThreshold.Selector + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- Every point moved into row `i` is heavy for every admissible cutoff of any +common feasibility witness. Otherwise its actual color can be delayed by one, +preserving that witness and contradicting minimal total movement. -/ +theorem selected_movedRow_subset_heavySet {F : Family α} (mu : MassFamily F) + {s : ℕ} (a z : Coloring α s) (hselected : Selected mu a z) + (H : ↥F) (hfeasible : FeasibleFor mu a z H) (i : Fin s) (ε : ℝ) + (hε : Admissible (mu.weight H) (prefixSet z i) + (crossings a z i : ℝ) (dscale i) ε) : + movedRow a z i ⊆ heavySet (mu.weight H) ε := by + classical + intro x hxrow + obtain ⟨hx, hmove⟩ := (Finset.mem_filter.mp hxrow).2 + apply mem_heavySet.mpr + by_contra hheavy + have hweight : mu.weight H x ≤ ε := le_of_not_gt hheavy + obtain ⟨H₀, hbounded, hminimal⟩ := hselected + have hbounded' : BoundedFeasible mu a H₀ (delayColor z x i) := by + refine ⟨⟨earlier_delayColor a z x i hx hmove hbounded.1.1, ?_⟩, ?_⟩ + · exact ⟨H, feasibleFor_delayColor mu a z H hfeasible x i hx hmove ε hε hweight⟩ + · intro y hy + exact hbounded.2 (changes_delayColor_subset a z x i hx hy) + have hmin := hminimal (delayColor z x i) hbounded' + have hdec := movement_delayColor_add_one a z x i hx hmove + have hstrict : movement a (delayColor z x i) < movement a z := + lt_of_lt_of_eq (Nat.lt_succ_self _) hdec + exact (not_lt_of_ge hmin) hstrict + +/-- The same reconstruction statement with the heavy set written explicitly. -/ +theorem selected_movedRow_subset_filter {F : Family α} (mu : MassFamily F) + {s : ℕ} (a z : Coloring α s) (hselected : Selected mu a z) + (H : ↥F) (hfeasible : FeasibleFor mu a z H) (i : Fin s) (ε : ℝ) + (hε : Admissible (mu.weight H) (prefixSet z i) + (crossings a z i : ℝ) (dscale i) ε) : + movedRow a z i ⊆ Finset.univ.filter (fun x => ε < mu.weight H x) := by + simpa only [heavySet] using + selected_movedRow_subset_heavySet mu a z hselected H hfeasible i ε hε + +end TalagrandThreshold.Selector + +end + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncation.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..61e55df3b88c66ad0e9bde42b5d79f330c357398 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncation.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorTruncationCompact +import OAI.Combinatorics.ExpectationThreshold.SelectorTruncationSlope + +namespace OAI + +/-! +# Maximal weighted truncation + +This is the maximal truncation lemma used by the multiscale selector. The +cutoff is obtained from the actual compact admissible set. Its heavy-set +bound follows from the exact affine increase on the next interval between +weights, rather than an assumed slope or regularity certificate. +-/ + +namespace TalagrandThreshold.Selector + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- A nonempty admissible set has a greatest cutoff, whose heavy set satisfies +the multiplied cardinality bound. -/ +theorem exists_maximal_truncation (w : α → ℝ) (A : Finset α) (m d : ℝ) + (hw : ∀ x, 0 ≤ w x) (hsum : ∑ x, w x = 1) + (hm : 0 ≤ m) (hd0 : 0 < d) (hd1 : d < 1) + (hne : ∃ u, Admissible w A m d u) : + ∃ ε, Admissible w A m d ε ∧ + (∀ u, Admissible w A m d u → u ≤ ε) ∧ + d * ((heavySet w ε).card : ℝ) ≤ m := by + obtain ⟨ε, hε, hmax⟩ := exists_greatest_admissible w A m d hne + exact ⟨ε, hε, hmax, + maximal_admissible_card_bound w A m d ε hw hsum hm hd0 hd1 hε hmax⟩ + +/-- The division form of the maximal truncation lemma. -/ +theorem exists_maximal_truncation_div (w : α → ℝ) (A : Finset α) (m d : ℝ) + (hw : ∀ x, 0 ≤ w x) (hsum : ∑ x, w x = 1) + (hm : 0 ≤ m) (hd0 : 0 < d) (hd1 : d < 1) + (hne : ∃ u, Admissible w A m d u) : + ∃ ε, Admissible w A m d ε ∧ + (∀ u, Admissible w A m d u → u ≤ ε) ∧ + ((heavySet w ε).card : ℝ) ≤ m / d := by + obtain ⟨ε, hε, hmax, hcard⟩ := + exists_maximal_truncation w A m d hw hsum hm hd0 hd1 hne + refine ⟨ε, hε, hmax, (le_div_iff₀ hd0).2 ?_⟩ + simpa only [mul_comm] using hcard + +end TalagrandThreshold.Selector + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationCompact.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationCompact.lean new file mode 100644 index 0000000000000000000000000000000000000000..de0df91f3fe65b90a0f62fd217c786480f2b9b55 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationCompact.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorTruncationDefinitions +import Mathlib.Topology.Algebra.Ring.Real +import Mathlib.Topology.Order.Compact + +namespace OAI + +/-! +# Existence of the maximal admissible truncation + +The condition that every heavy point belongs to `A` is a family of closed +lower bounds on the cutoff, one for each point outside `A`. The excess is a +continuous finite sum. Thus the admissible cutoffs form a closed subset of +`[0, 1]`, and a nonempty such set has a greatest element. + +This existence argument does not use positivity or normalization of the +weights, or sign assumptions on the parameters `m` and `d`. +-/ + +namespace TalagrandThreshold.Selector + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- Finite truncation gives a continuous excess as the cutoff varies. -/ +theorem continuous_truncatedExcess (w : α → ℝ) (A : Finset α) (d : ℝ) : + Continuous (fun u => truncatedExcess w A d u) := by + unfold truncatedExcess + apply continuous_finsetSum + intro x _ + exact (continuous_const.min continuous_id).mul continuous_const + +/-- The heavy-point inclusion and the excess test are closed conditions. -/ +theorem isClosed_admissible (w : α → ℝ) (A : Finset α) (m d : ℝ) : + IsClosed {u : ℝ | Admissible w A m d u} := by + have hlarge : IsClosed {u : ℝ | ∀ x, x ∉ A → w x ≤ u} := by + simp only [Set.ofPred_forall] + exact isClosed_iInter fun x => isClosed_iInter fun _ => + isClosed_le continuous_const continuous_id + have hexcess : IsClosed {u : ℝ | m * u ≤ truncatedExcess w A d u} := + isClosed_le (continuous_const.mul continuous_id) + (continuous_truncatedExcess w A d) + have hrepr : {u : ℝ | Admissible w A m d u} = + (Set.Icc 0 1 ∩ {u : ℝ | ∀ x, x ∉ A → w x ≤ u}) ∩ + {u : ℝ | m * u ≤ truncatedExcess w A d u} := by + ext u + constructor + · intro hu + exact ⟨⟨⟨hu.1, hu.2.1⟩, fun _ hx => hu.outside_le hx⟩, hu.2.2.2⟩ + · intro hu + refine ⟨hu.1.1.1, hu.1.1.2, ?_, hu.2⟩ + intro x hux + by_contra hx + exact (not_lt_of_ge (hu.1.2 x hx)) hux + rw [hrepr] + exact (isClosed_Icc.inter hlarge).inter hexcess + +/-- Admissible cutoffs are compact because they are closed and lie in `[0, 1]`. -/ +theorem isCompact_admissible (w : α → ℝ) (A : Finset α) (m d : ℝ) : + IsCompact {u : ℝ | Admissible w A m d u} := by + apply (isCompact_Icc : IsCompact (Set.Icc (0 : ℝ) 1)).of_isClosed_subset + (isClosed_admissible w A m d) + intro u hu + exact ⟨hu.1, hu.2.1⟩ + +/-- Every nonempty admissible set has an actual greatest cutoff. -/ +theorem exists_greatest_admissible (w : α → ℝ) (A : Finset α) (m d : ℝ) + (hne : ∃ u, Admissible w A m d u) : + ∃ ε, Admissible w A m d ε ∧ ∀ u, Admissible w A m d u → u ≤ ε := by + obtain ⟨ε, hε⟩ := (isCompact_admissible w A m d).exists_isGreatest hne + exact ⟨ε, hε.1, fun _ hu => hε.2 hu⟩ + +end TalagrandThreshold.Selector + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationDefinitions.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationDefinitions.lean new file mode 100644 index 0000000000000000000000000000000000000000..98d808298ce72db6ac6a03bc9ca782550a874abc --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationDefinitions.lean @@ -0,0 +1,53 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Data.Fintype.Basic +import Mathlib.Algebra.BigOperators.Ring.Finset + +namespace OAI + +/-! +# Finite weighted truncation + +The heavy set uses a strict cutoff. Weights equal to the cutoff are already +saturated when the cutoff increases, as required by the maximal truncation +argument. +-/ + +namespace TalagrandThreshold.Selector + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- The points whose weight is strictly above the cutoff. -/ +noncomputable def heavySet (w : α → ℝ) (u : ℝ) : Finset α := by + classical + exact Finset.univ.filter (fun x => u < w x) + +/-- The excess mass after every coordinate is truncated at the same cutoff. -/ +noncomputable def truncatedExcess (w : α → ℝ) (A : Finset α) (d u : ℝ) : ℝ := + ∑ x, min (w x) u * ((if x ∈ A then 1 else 0) - (1 - d)) + +/-- An admissible cutoff includes all heavy points and meets the truncated +weighted-excess test. -/ +def Admissible (w : α → ℝ) (A : Finset α) (m d u : ℝ) : Prop := + 0 ≤ u ∧ u ≤ 1 ∧ (∀ x, u < w x → x ∈ A) ∧ + m * u ≤ truncatedExcess w A d u + +omit [DecidableEq α] in +@[simp] theorem mem_heavySet {w : α → ℝ} {u : ℝ} {x : α} : + x ∈ heavySet w u ↔ u < w x := by + classical + simp [heavySet] + +theorem Admissible.heavy_subset {w : α → ℝ} {A : Finset α} {m d u : ℝ} + (hu : Admissible w A m d u) : heavySet w u ⊆ A := by + intro x hx + exact hu.2.2.1 x (mem_heavySet.mp hx) + +theorem Admissible.outside_le {w : α → ℝ} {A : Finset α} {m d u : ℝ} + (hu : Admissible w A m d u) {x : α} (hx : x ∉ A) : w x ≤ u := by + exact le_of_not_gt (fun h => hx (hu.2.2.1 x h)) + +end TalagrandThreshold.Selector + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationSlope.lean b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationSlope.lean new file mode 100644 index 0000000000000000000000000000000000000000..f37aaa003d97a6d2f7764fb501bf7a87e8bc7359 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/SelectorTruncationSlope.lean @@ -0,0 +1,114 @@ +import OAI.Combinatorics.ExpectationThreshold.SelectorTruncationDefinitions +import Mathlib.Data.Finset.Max +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# The right-hand slope at a maximal admissible cutoff + +A finite minimum provides an actual larger cutoff below every currently +heavy weight. Between these cutoffs the truncated excess has the exact +affine increment contributed by the heavy coordinates. Weights equal to +the original cutoff remain saturated, including when the cutoff is zero. +-/ + +namespace TalagrandThreshold.Selector + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [DecidableEq α] in +/-- There is a strictly larger cutoff, at most one, that does not pass any +weight strictly above the current cutoff. -/ +theorem exists_short_right_cutoff (w : α → ℝ) {ε : ℝ} (hε : ε < 1) : + ∃ u : ℝ, ε < u ∧ u ≤ 1 ∧ ∀ x, ε < w x → u ≤ w x := by + classical + let S : Finset ℝ := insert 1 ((heavySet w ε).image w) + have hS : S.Nonempty := ⟨1, Finset.mem_insert_self _ _⟩ + refine ⟨S.min' hS, ?_, S.min'_le 1 (Finset.mem_insert_self _ _), ?_⟩ + · apply (Finset.lt_min'_iff S hS).2 + intro y hy + rcases Finset.mem_insert.mp hy with rfl | hy + · exact hε + · obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hy + exact mem_heavySet.mp hx + · intro x hx + apply S.min'_le (w x) + exact Finset.mem_insert_of_mem + (Finset.mem_image.mpr ⟨x, mem_heavySet.mpr hx, rfl⟩) + +/-- On the first interval to the right of a cutoff, precisely the strictly +heavy coordinates vary. The inclusion in `A` makes their coefficient `d`. -/ +theorem truncatedExcess_sub_eq_heavy_increment (w : α → ℝ) (A : Finset α) + (d ε u : ℝ) (hεu : ε ≤ u) + (hupper : ∀ x, ε < w x → u ≤ w x) + (hheavy : ∀ x, ε < w x → x ∈ A) : + truncatedExcess w A d u - truncatedExcess w A d ε = + (u - ε) * d * ((heavySet w ε).card : ℝ) := by + classical + calc + truncatedExcess w A d u - truncatedExcess w A d ε = + ∑ x, if ε < w x then (u - ε) * d else 0 := by + unfold truncatedExcess + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro x _ + by_cases hx : ε < w x + · simp only [min_eq_right (hupper x hx), min_eq_right hx.le, + ite_eq_left hx, ite_eq_left (hheavy x hx)] + ring + · have hxε : w x ≤ ε := le_of_not_gt hx + simp only [min_eq_left (hxε.trans hεu), min_eq_left hxε, + ite_eq_right hx, sub_self] + _ = ∑ x ∈ heavySet w ε, (u - ε) * d := by + rw [← Finset.sum_filter] + rfl + _ = (u - ε) * d * ((heavySet w ε).card : ℝ) := by + simp only [Finset.sum_const, nsmul_eq_mul] + ring + +/-- The cardinality conclusion of maximal truncation. Existence of a +maximal admissible cutoff is supplied separately by compactness. -/ +theorem maximal_admissible_card_bound (w : α → ℝ) (A : Finset α) (m d ε : ℝ) + (hwnonneg : ∀ x, 0 ≤ w x) (hwsum : ∑ x, w x = 1) + (hm0 : 0 ≤ m) (_hd0 : 0 < d) (_hd1 : d < 1) + (hε : Admissible w A m d ε) + (hmax : ∀ u : ℝ, Admissible w A m d u → u ≤ ε) : + d * ((heavySet w ε).card : ℝ) ≤ m := by + classical + have hwle (x : α) : w x ≤ 1 := by + calc + w x ≤ ∑ y, w y := + Finset.single_le_sum (fun y _ => hwnonneg y) (Finset.mem_univ x) + _ = 1 := hwsum + by_cases hεone : ε = 1 + · have hempty : heavySet w ε = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro x hx + have hlt := mem_heavySet.mp hx + rw [hεone] at hlt + exact (not_lt_of_ge (hwle x)) hlt + simpa only [hempty, Finset.card_empty, Nat.cast_zero, mul_zero] using hm0 + · have hεlt : ε < 1 := lt_of_le_of_ne hε.2.1 hεone + obtain ⟨u, hεu, hu1, hupper⟩ := exists_short_right_cutoff w hεlt + by_contra hbound + have hgap : m < d * ((heavySet w ε).card : ℝ) := lt_of_not_ge hbound + have haffine := truncatedExcess_sub_eq_heavy_increment w A d ε u + hεu.le hupper hε.2.2.1 + have hslope : 0 ≤ (u - ε) * (d * ((heavySet w ε).card : ℝ) - m) := + mul_nonneg (sub_nonneg.mpr hεu.le) (sub_nonneg.mpr hgap.le) + have htest : m * u ≤ truncatedExcess w A d u := by + have htestε := hε.2.2.2 + nlinarith + have hu : Admissible w A m d u := + ⟨hε.1.trans hεu.le, hu1, + fun x hx => hε.2.2.1 x (hεu.trans hx), htest⟩ + exact (not_lt_of_ge (hmax u hu)) hεu + +end TalagrandThreshold.Selector + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdAttainment.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdAttainment.lean new file mode 100644 index 0000000000000000000000000000000000000000..75d9d8b8e1d9f100f826a230b9a61f6d24ace65e --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdAttainment.lean @@ -0,0 +1,76 @@ +import OAI.Combinatorics.ExpectationThreshold.ThresholdCompactness +import OAI.Combinatorics.ExpectationThreshold.ThresholdBounds + +namespace OAI + +/-! +# Attainment of the integral and fractional thresholds + +There are finitely many integral covers, so integral feasibility is closed +in the density interval. Fractional feasibility is a compact projection. +The actual suprema therefore belong to their respective feasible sets as +soon as those sets contain density zero. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [Fintype α] [DecidableEq α] in +theorem continuous_cost (G : Family α) : Continuous (fun p : ℝ => cost p G) := by + unfold cost + exact continuous_finsetSum G (fun S _ => continuous_pow S.card) + +omit [DecidableEq α] in +/-- Smallness is a finite union of closed conditions, one per actual cover. -/ +theorem isClosed_small (F : Family α) : IsClosed {p : ℝ | Small p F} := by + classical + have hset : {p : ℝ | Small p F} = + ⋃ G : Family α, {p : ℝ | Covers G F ∧ cost p G ≤ 1 / 2} := by + ext p + simp only [Set.mem_ofPred_eq, Set.mem_iUnion, Small] + rw [hset] + apply isClosed_iUnion_of_finite + intro G + by_cases hG : Covers G F + · simpa only [hG, true_and] using + (isClosed_le (continuous_cost G) (continuous_const : + Continuous (fun _ : ℝ => (1 / 2 : ℝ)))) + · simpa only [hG, false_and, Set.ofPred_false] using + (isClosed_empty : IsClosed (∅ : Set ℝ)) + +omit [DecidableEq α] in +theorem isCompact_integralFeasible (F : Family α) : IsCompact (integralFeasible F) := by + have hset : integralFeasible F = Set.Icc (0 : ℝ) 1 ∩ {p : ℝ | Small p F} := by + ext p + constructor + · intro hp + exact ⟨⟨hp.1, hp.2.1⟩, hp.2.2⟩ + · intro hp + exact ⟨hp.1.1, hp.1.2, hp.2⟩ + rw [hset] + exact (isCompact_Icc : IsCompact (Set.Icc (0 : ℝ) 1)).inter_right (isClosed_small F) + +omit [DecidableEq α] in +/-- The integral supremum is an actual feasible density. -/ +theorem q_mem_integralFeasible (F : Family α) (hF : ∅ ∉ F) : + q F ∈ integralFeasible F := by + exact (isCompact_integralFeasible F).sSup_mem (integralFeasible_nonempty F hF) + +/-- The fractional supremum is an actual feasible density. -/ +theorem qf_mem_fractionalFeasible (F : Family α) (hF : ∅ ∉ F) : + qf F ∈ fractionalFeasible F := by + exact (isCompact_fractionalFeasible F).sSup_mem (fractionalFeasible_nonempty F hF) + +omit [DecidableEq α] in +theorem small_q (F : Family α) (hF : ∅ ∉ F) : Small (q F) F := + (mem_integralFeasible.mp (q_mem_integralFeasible F hF)).2.2 + +theorem fractionalSmall_qf (F : Family α) (hF : ∅ ∉ F) : FractionalSmall (qf F) F := + (mem_fractionalFeasible.mp (qf_mem_fractionalFeasible F hF)).2.2 + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdBounds.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..34a95d2e138de97395c9b8ec5adca31b596845b4 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdBounds.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.ExpectationThreshold.Basic +import Mathlib.Order.ConditionallyCompleteLattice.Basic + +namespace OAI + +/-! +# Elementary bounds for the actual expectation thresholds + +When the empty set is absent from the family, zero is feasible for both +thresholds. Their feasible sets are bounded by one, and indicator covers +give the integral-to-fractional comparison. +-/ + +namespace TalagrandThreshold + +noncomputable section + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [Fintype α] [DecidableEq α] in +theorem integralFeasible_subset_Icc (F : Family α) : + integralFeasible F ⊆ Set.Icc (0 : ℝ) 1 := + fun _ hp => ⟨hp.1, hp.2.1⟩ + +omit [DecidableEq α] in +theorem fractionalFeasible_subset_Icc (F : Family α) : + fractionalFeasible F ⊆ Set.Icc (0 : ℝ) 1 := + fun _ hp => ⟨hp.1, hp.2.1⟩ + +omit [Fintype α] [DecidableEq α] in +theorem integralFeasible_bddAbove (F : Family α) : BddAbove (integralFeasible F) := + ⟨1, fun _ hp => hp.2.1⟩ + +omit [DecidableEq α] in +theorem fractionalFeasible_bddAbove (F : Family α) : BddAbove (fractionalFeasible F) := + ⟨1, fun _ hp => hp.2.1⟩ + +omit [Fintype α] [DecidableEq α] in +theorem zero_mem_integralFeasible (F : Family α) (hF : (∅ : Finset α) ∉ F) : + (0 : ℝ) ∈ integralFeasible F := + ⟨le_rfl, zero_le_one, small_zero F hF⟩ + +theorem zero_mem_fractionalFeasible (F : Family α) (hF : (∅ : Finset α) ∉ F) : + (0 : ℝ) ∈ fractionalFeasible F := + ⟨le_rfl, zero_le_one, fractionalSmall_zero F hF⟩ + +omit [Fintype α] [DecidableEq α] in +theorem integralFeasible_nonempty (F : Family α) (hF : (∅ : Finset α) ∉ F) : + (integralFeasible F).Nonempty := + ⟨0, zero_mem_integralFeasible F hF⟩ + +theorem fractionalFeasible_nonempty (F : Family α) (hF : (∅ : Finset α) ∉ F) : + (fractionalFeasible F).Nonempty := + ⟨0, zero_mem_fractionalFeasible F hF⟩ + +omit [Fintype α] [DecidableEq α] in +/-- Integral feasibility is preserved by lowering the nonnegative density. -/ +theorem integralFeasible_mono {F : Family α} {p r : ℝ} + (hr : r ∈ integralFeasible F) (hp : 0 ≤ p) (hpr : p ≤ r) : + p ∈ integralFeasible F := + ⟨hp, hpr.trans hr.2.1, hr.2.2.mono hp hpr⟩ + +omit [DecidableEq α] in +/-- Fractional feasibility is preserved by lowering the nonnegative density. -/ +theorem fractionalFeasible_mono {F : Family α} {p r : ℝ} + (hr : r ∈ fractionalFeasible F) (hp : 0 ≤ p) (hpr : p ≤ r) : + p ∈ fractionalFeasible F := + ⟨hp, hpr.trans hr.2.1, hr.2.2.mono hp hpr⟩ + +theorem integralFeasible_subset_fractionalFeasible (F : Family α) : + integralFeasible F ⊆ fractionalFeasible F := + fun _ hp => ⟨hp.1, hp.2.1, hp.2.2.fractionalSmall⟩ + +omit [Fintype α] [DecidableEq α] in +theorem le_q_of_mem {F : Family α} {p : ℝ} (hp : p ∈ integralFeasible F) : + p ≤ q F := + le_csSup (integralFeasible_bddAbove F) hp + +omit [DecidableEq α] in +theorem le_qf_of_mem {F : Family α} {p : ℝ} (hp : p ∈ fractionalFeasible F) : + p ≤ qf F := + le_csSup (fractionalFeasible_bddAbove F) hp + +omit [Fintype α] [DecidableEq α] in +theorem le_q_of_small {F : Family α} {p : ℝ} + (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (hp : Small p F) : p ≤ q F := + le_q_of_mem ⟨hp0, hp1, hp⟩ + +omit [DecidableEq α] in +theorem le_qf_of_fractionalSmall {F : Family α} {p : ℝ} + (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (hp : FractionalSmall p F) : p ≤ qf F := + le_qf_of_mem ⟨hp0, hp1, hp⟩ + +omit [Fintype α] [DecidableEq α] in +theorem q_nonneg (F : Family α) (hF : (∅ : Finset α) ∉ F) : 0 ≤ q F := + le_q_of_mem (zero_mem_integralFeasible F hF) + +theorem qf_nonneg (F : Family α) (hF : (∅ : Finset α) ∉ F) : 0 ≤ qf F := + le_qf_of_mem (zero_mem_fractionalFeasible F hF) + +omit [Fintype α] [DecidableEq α] in +theorem q_le_one (F : Family α) (hF : (∅ : Finset α) ∉ F) : q F ≤ 1 := + csSup_le (integralFeasible_nonempty F hF) (fun _ hp => hp.2.1) + +theorem qf_le_one (F : Family α) (hF : (∅ : Finset α) ∉ F) : qf F ≤ 1 := + csSup_le (fractionalFeasible_nonempty F hF) (fun _ hp => hp.2.1) + +theorem q_le_qf (F : Family α) (hF : (∅ : Finset α) ∉ F) : q F ≤ qf F := + csSup_le_csSup (fractionalFeasible_bddAbove F) (integralFeasible_nonempty F hF) + (integralFeasible_subset_fractionalFeasible F) + +end +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdCompactness.lean b/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdCompactness.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b6c99a86ed894428a44d6ecbdeb8208bdfe4bb2 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/ThresholdCompactness.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.ExpectationThreshold.Basic +import Mathlib.Topology.Algebra.Ring.Real +import Mathlib.Topology.Order.Compact + +namespace OAI + +/-! +# Compactness of the fractional feasible densities + +The cover coefficients and the density range over closed unit intervals. +The coverage inequalities and the polynomial cost bound cut out a closed +subset of their compact product. Its projection is exactly the set of +fractionally feasible densities, including when that set is empty. +-/ + +namespace TalagrandThreshold + +noncomputable section + +open scoped BigOperators + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [DecidableEq α] in +/-- The fractional cost is jointly continuous in the density and coefficients. -/ +theorem continuous_fracCost : + Continuous (fun z : ℝ × (Finset α → ℝ) => fracCost z.1 z.2) := by + unfold fracCost + exact continuous_finsetSum Finset.univ fun S _ => + ((continuous_apply S).comp continuous_snd).mul (continuous_fst.pow S.card) + +omit [DecidableEq α] in +/-- Fractional feasibility is the projection of the actual compact set of covers. -/ +theorem isCompact_fractionalFeasible (F : Family α) : + IsCompact (fractionalFeasible F) := by + let B : Set (ℝ × (Finset α → ℝ)) := + Set.Icc (0 : ℝ) 1 ×ˢ {g | ∀ S, 0 ≤ g S ∧ g S ≤ 1} + let C : Set (ℝ × (Finset α → ℝ)) := + {z | (∀ H ∈ F, 1 ≤ ∑ S ∈ H.powerset, z.2 S) ∧ fracCost z.1 z.2 ≤ 1 / 2} + have hbox : IsCompact B := + (isCompact_Icc : IsCompact (Set.Icc (0 : ℝ) 1)).prod + (isCompact_pi_infinite fun _ : Finset α => + (isCompact_Icc : IsCompact (Set.Icc (0 : ℝ) 1))) + have hcoverage : IsClosed + {z : ℝ × (Finset α → ℝ) | ∀ H ∈ F, 1 ≤ ∑ S ∈ H.powerset, z.2 S} := by + simp only [Set.ofPred_forall] + refine isClosed_iInter fun H => isClosed_iInter fun _ => ?_ + exact isClosed_le continuous_const + (continuous_finsetSum H.powerset fun S _ => + (continuous_apply S).comp continuous_snd) + have hcost : IsClosed + {z : ℝ × (Finset α → ℝ) | fracCost z.1 z.2 ≤ 1 / 2} := + isClosed_le continuous_fracCost continuous_const + have hclosed : IsClosed C := hcoverage.inter hcost + have himage : Prod.fst '' (B ∩ C) = fractionalFeasible F := by + ext p + constructor + · rintro ⟨⟨q, g⟩, ⟨hB, hC⟩, hp⟩ + change (0 ≤ q ∧ q ≤ 1) ∧ (∀ S, 0 ≤ g S ∧ g S ≤ 1) at hB + change (∀ H ∈ F, 1 ≤ ∑ S ∈ H.powerset, g S) ∧ fracCost q g ≤ 1 / 2 at hC + change q = p at hp + subst p + exact ⟨hB.1.1, hB.1.2, g, ⟨hB.2, hC.1⟩, hC.2⟩ + · rintro ⟨hp0, hp1, g, hcover, hcost⟩ + exact ⟨(p, g), ⟨⟨⟨hp0, hp1⟩, hcover.1⟩, ⟨hcover.2, hcost⟩⟩, rfl⟩ + rw [← himage] + exact (hbox.inter_right hclosed).image continuous_fst + +end +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/TupleCoefficients.lean b/lean/OAI/Combinatorics/ExpectationThreshold/TupleCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdd6971996ea8fbfb6b58e8133541932bf866bc2 --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/TupleCoefficients.lean @@ -0,0 +1,97 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Coefficients for the finite tuple estimate + +Replacing `e` by `3` gives the coefficients `3 / 64^(i+1)`. Their finite +sum has an explicit positive remainder below `1 / 21`. A finite product +inequality then bounds the product of their complements from below. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +/-- The convenient rational upper bound on the selector's coefficient. -/ +noncomputable def tupleCoefficient (i : ℕ) : ℝ := + 3 / 64 ^ (i + 1) + +theorem tupleCoefficient_eq (i : ℕ) : + tupleCoefficient i = (3 / 64 : ℝ) * (1 / 64 : ℝ) ^ i := by + simp only [tupleCoefficient, pow_succ, div_eq_mul_inv, mul_inv_rev, one_mul, + inv_pow] + ring + +theorem tupleCoefficient_pos (i : ℕ) : 0 < tupleCoefficient i := by + unfold tupleCoefficient + positivity + +theorem tupleCoefficient_nonneg (i : ℕ) : 0 ≤ tupleCoefficient i := + (tupleCoefficient_pos i).le + +theorem tupleCoefficient_le_first (i : ℕ) : tupleCoefficient i ≤ 3 / 64 := by + rw [tupleCoefficient_eq] + have hpow : (1 / 64 : ℝ) ^ i ≤ 1 := + pow_le_one₀ (by norm_num) (by norm_num) + nlinarith + +theorem tupleCoefficient_lt_one (i : ℕ) : tupleCoefficient i < 1 := + lt_of_le_of_lt (tupleCoefficient_le_first i) (by norm_num) + +/-- The exact finite geometric identity, including the empty sum. -/ +theorem sum_tupleCoefficient_add_remainder (s : ℕ) : + (∑ i : Fin s, tupleCoefficient i.val) + + (1 / 21 : ℝ) * (1 / 64 : ℝ) ^ s = 1 / 21 := by + induction s with + | zero => norm_num + | succ s ih => + rw [Fin.sum_univ_castSucc] + simp only [Fin.val_castSucc, Fin.val_last] + rw [tupleCoefficient_eq s, pow_succ] + nlinarith [ih] + +theorem sum_tupleCoefficient_lt (s : ℕ) : + (∑ i : Fin s, tupleCoefficient i.val) < 1 / 21 := by + have hrem : 0 < (1 / 21 : ℝ) * (1 / 64 : ℝ) ^ s := by positivity + linarith [sum_tupleCoefficient_add_remainder s] + +theorem sum_tupleCoefficient_le (s : ℕ) : + (∑ i : Fin s, tupleCoefficient i.val) ≤ 1 / 21 := + (sum_tupleCoefficient_lt s).le + +/-- A finite product loses at most the sum of its factors' deficits. -/ +theorem one_sub_sum_le_prod_one_sub {ι : Type*} [Fintype ι] + (c : ι → ℝ) (h0 : ∀ i, 0 ≤ c i) (h1 : ∀ i, c i ≤ 1) : + 1 - ∑ i, c i ≤ ∏ i, (1 - c i) := by + classical + suffices h : ∀ s : Finset ι, + 1 - ∑ i ∈ s, c i ≤ ∏ i ∈ s, (1 - c i) by + exact h Finset.univ + intro s + induction s using Finset.induction_on with + | empty => simp + | @insert a s ha ih => + rw [Finset.sum_insert ha, Finset.prod_insert ha] + have hs : 0 ≤ ∑ i ∈ s, c i := + Finset.sum_nonneg (fun i _ => h0 i) + have hm := mul_le_mul_of_nonneg_left ih (sub_nonneg.mpr (h1 a)) + nlinarith [mul_nonneg (h0 a) hs] + +theorem prod_one_sub_tupleCoefficient_gt (s : ℕ) : + (20 / 21 : ℝ) < ∏ i : Fin s, (1 - tupleCoefficient i.val) := by + have hprod := one_sub_sum_le_prod_one_sub (fun i : Fin s => tupleCoefficient i.val) + (fun i => tupleCoefficient_nonneg i.val) (fun i => (tupleCoefficient_lt_one i.val).le) + have hsum := sum_tupleCoefficient_lt s + linarith + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/ExpectationThreshold/TupleGeometric.lean b/lean/OAI/Combinatorics/ExpectationThreshold/TupleGeometric.lean new file mode 100644 index 0000000000000000000000000000000000000000..aae2cf332a9cf53f5ed1e9ab0ecd2c6dd6db07ab --- /dev/null +++ b/lean/OAI/Combinatorics/ExpectationThreshold/TupleGeometric.lean @@ -0,0 +1,124 @@ +import OAI.Combinatorics.ExpectationThreshold.TupleCoefficients +import Mathlib.Data.Fintype.Pi +import Mathlib.Data.Finset.Lattice.Fold +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum + +namespace OAI + +/-! +# A finite geometric bound for nonzero tuples + +Every finite family of tuples lies in a finite coordinate box. Factoring +the sum over this box reduces the estimate to ordinary finite geometric +sums. Adding the zero tuple contributes exactly one, so removing it gives +the selector's budget of strictly less than `1 / 20`. +-/ + +namespace TalagrandThreshold + +open scoped BigOperators + +private theorem finite_geom_sum_mul_one_sub (c : ℝ) (n : ℕ) : + (∑ k ∈ Finset.range n, c ^ k) * (1 - c) = 1 - c ^ n := by + induction n with + | zero => simp + | succ n ih => + rw [Finset.sum_range_succ, pow_succ] + nlinarith [ih] + +private theorem finite_geom_sum_le_inverse {c : ℝ} + (hc0 : 0 ≤ c) (hc1 : c < 1) (n : ℕ) : + (∑ k ∈ Finset.range n, c ^ k) ≤ (1 - c)⁻¹ := by + rw [← one_div] + apply (le_div_iff₀ (sub_pos.mpr hc1)).mpr + rw [finite_geom_sum_mul_one_sub] + exact sub_le_self 1 (pow_nonneg hc0 n) + +/-- A finite tuple family is bounded by the product of geometric bounds. -/ +theorem finite_tuple_sum_le_inverse_product {ι : Type*} [Fintype ι] + (T : Finset (ι → ℕ)) (c : ι → ℝ) + (hc0 : ∀ i, 0 ≤ c i) (hc1 : ∀ i, c i < 1) : + (∑ t ∈ T, ∏ i, (c i) ^ (t i)) ≤ ∏ i, (1 - c i)⁻¹ := by + classical + let m : ι → ℕ := fun i => T.sup (fun t => t i) + 1 + let B : Finset (ι → ℕ) := Fintype.piFinset (fun i => Finset.range (m i)) + have hTB : T ⊆ B := by + intro t ht + apply Fintype.mem_piFinset.mpr + intro i + apply Finset.mem_range.mpr + exact Nat.lt_succ_of_le (Finset.le_sup (f := fun u => u i) ht) + calc + (∑ t ∈ T, ∏ i, (c i) ^ (t i)) ≤ + ∑ t ∈ B, ∏ i, (c i) ^ (t i) := + Finset.sum_le_sum_of_subset_of_nonneg hTB + (fun t _ _ => Finset.prod_nonneg fun i _ => pow_nonneg (hc0 i) (t i)) + _ = ∏ i, ∑ k ∈ Finset.range (m i), (c i) ^ k := + (Finset.prod_univ_sum (fun i => Finset.range (m i)) + (fun i k => (c i) ^ k)).symm + _ ≤ ∏ i, (1 - c i)⁻¹ := by + apply Finset.prod_le_prod₀ + · intro i _ + exact Finset.sum_nonneg fun k _ => pow_nonneg (hc0 i) k + · intro i _ + exact finite_geom_sum_le_inverse (hc0 i) (hc1 i) (m i) + +/-- The sum of coefficients controls every finite tuple family. -/ +theorem finite_tuple_sum_le_inverse_one_sub_sum {ι : Type*} [Fintype ι] + (T : Finset (ι → ℕ)) (c : ι → ℝ) + (hc0 : ∀ i, 0 ≤ c i) (hc1 : ∀ i, c i < 1) + (hsum : (∑ i, c i) < 1) : + (∑ t ∈ T, ∏ i, (c i) ^ (t i)) ≤ (1 - ∑ i, c i)⁻¹ := by + calc + (∑ t ∈ T, ∏ i, (c i) ^ (t i)) ≤ ∏ i, (1 - c i)⁻¹ := + finite_tuple_sum_le_inverse_product T c hc0 hc1 + _ = (∏ i, (1 - c i))⁻¹ := Finset.prod_inv_distrib _ + _ ≤ (1 - ∑ i, c i)⁻¹ := + inv_anti₀ (sub_pos.mpr hsum) + (one_sub_sum_le_prod_one_sub c hc0 (fun i => (hc1 i).le)) + +/-- The actual selector coefficients give a strict budget for every finite +family of nonzero tuples, without an infinite-series argument. -/ +theorem tuple_geometric_sum_lt_one_twentieth {s : ℕ} + (T : Finset (Fin s → ℕ)) (hT : ∀ t ∈ T, t ≠ 0) : + (∑ t ∈ T, ∏ i : Fin s, ((3 : ℝ) / 64 ^ (i.val + 1)) ^ (t i)) < 1 / 20 := by + classical + let c : Fin s → ℝ := fun i => tupleCoefficient i.val + have hc0 : ∀ i, 0 ≤ c i := fun i => tupleCoefficient_nonneg i.val + have hc1 : ∀ i, c i < 1 := fun i => tupleCoefficient_lt_one i.val + have hrho : (∑ i, c i) < (1 / 21 : ℝ) := sum_tupleCoefficient_lt s + have hsum : (∑ i, c i) < 1 := hrho.trans (by norm_num) + have hz : (0 : Fin s → ℕ) ∉ T := fun hz => hT 0 hz rfl + have hall := finite_tuple_sum_le_inverse_one_sub_sum (insert 0 T) c hc0 hc1 hsum + have htotal : 1 + (∑ t ∈ T, ∏ i, (c i) ^ (t i)) ≤ (1 - ∑ i, c i)⁻¹ := by + simpa only [Finset.sum_insert hz, Pi.zero_apply, pow_zero, Finset.prod_const_one] + using hall + have hden : (20 / 21 : ℝ) < 1 - ∑ i, c i := by linarith + have hinv : (1 - ∑ i, c i)⁻¹ < (21 / 20 : ℝ) := by + have h := (inv_lt_inv₀ (sub_pos.mpr hsum) + (by norm_num : (0 : ℝ) < 20 / 21)).mpr hden + norm_num at h + exact h + change (∑ t ∈ T, ∏ i, (c i) ^ (t i)) < 1 / 20 + linarith + +theorem tuple_geometric_sum_le_one_twentieth {s : ℕ} + (T : Finset (Fin s → ℕ)) (hT : ∀ t ∈ T, t ≠ 0) : + (∑ t ∈ T, ∏ i : Fin s, ((3 : ℝ) / 64 ^ (i.val + 1)) ^ (t i)) ≤ 1 / 20 := + (tuple_geometric_sum_lt_one_twentieth T hT).le + +/-- A positive total degree is the form supplied by a nonempty changed set. -/ +theorem tuple_geometric_sum_lt_one_twentieth_of_pos_total {s : ℕ} + (T : Finset (Fin s → ℕ)) (hT : ∀ t ∈ T, 0 < ∑ i, t i) : + (∑ t ∈ T, ∏ i : Fin s, ((3 : ℝ) / 64 ^ (i.val + 1)) ^ (t i)) < 1 / 20 := by + apply tuple_geometric_sum_lt_one_twentieth T + intro t ht hz + have hpos := hT t ht + simp [hz] at hpos + +end TalagrandThreshold + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/AnchorRecovery.lean b/lean/OAI/Combinatorics/FiniteCircle/AnchorRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d7d5a2be7c83e05d36ea2f4a0fecceb4fbf2de8 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/AnchorRecovery.lean @@ -0,0 +1,301 @@ +import OAI.Combinatorics.FiniteCircle.BlockMatching + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem zip_ofFn {α β : Type*} {n : ℕ} (f : Fin n → α) (g : Fin n → β) : + (List.ofFn f).zip (List.ofFn g) = List.ofFn (fun i => (f i, g i)) := by + apply List.ext_getElem + · simp + · intro i hi hj + simp only [List.getElem_zip, List.getElem_ofFn] + +namespace WordMatching +variable {α : Type*} {x y : List α} {w q : ℕ} {c : α → Fin w → Bool} + +theorem localIndices_letters (hw : 0 < w) (A : WordMatching (encode c x) (encode c y) q) + {i : Fin x.length} {j : Fin y.length} {S : Finset (Fin q)} + (hS : S ⊆ A.blockPair w i j) : + ∀ z ∈ (A.localIndices hw S).zip (A.symm.localIndices hw S), + c (x.get i) z.1 = c (y.get j) z.2 := by + intro z hz + rw [localIndices, localIndices, zip_ofFn] at hz + obtain ⟨k, rfl⟩ := List.mem_ofFn.mp hz + let p := S.orderEmbOfFin rfl k + have hp := hS (S.orderEmbOfFin_mem rfl k) + obtain ⟨hl, hr⟩ := Finset.mem_inter.mp hp + have hi := (A.mem_sourceBlock w i p).mp hl + have hj := (A.symm.mem_sourceBlock w j p).mp hr + have he := A.letters p + rw [get_encode hw, get_encode hw] at he + convert he using 1 <;> congr 2 + · apply Fin.ext + exact hi.symm + · apply Fin.ext + exact hj.symm + +theorem anchor_on_blockPair (hw : 0 < w) {ε : ℝ} (hlocal : AnchorLocal ε c) + (A : WordMatching (encode c x) (encode c y) q) + (i : Fin x.length) (j : Fin y.length) + (hcard : w ≤ 4*(A.blockPair w i j).card) + (hU : (A.sourceLoss w i : ℝ) ≤ ε*w) + (hV : (A.spanLoss w i : ℝ) ≤ ε*w) : + x.get i = y.get j ∧ ∃ k ∈ A.blockPair w i j, (A.left k).val%w = (A.right k).val%w := by + let S := A.blockPair w i j + have hS : S ⊆ A.sourceBlock w i := Finset.inter_subset_left + have hT : S ⊆ A.symm.sourceBlock w j := Finset.inter_subset_right + have hconv : ConvexIndices S := A.blockPair_convex w i j + have hbound : (w : ℝ)/4 ≤ (A.localIndices hw S).length := by + rw [localIndices_length] + have hc : (w : ℝ) ≤ 4*(S.card : ℝ) := by exact_mod_cast hcard + linarith + have hleft : ((indexSpan (A.localIndices hw S) - (A.localIndices hw S).length : ℕ) : ℝ) ≤ ε*w := by + rw [A.localIndices_span hw hS, localIndices_length] + have hh : (((A.symm.rightSpan S).card - S.card : ℕ) : ℝ) ≤ A.sourceLoss w i := by + exact_mod_cast A.left_span_holes_le_sourceLoss hw hconv hS + exact hh.trans hU + have hright : ((indexSpan (A.symm.localIndices hw S) - (A.symm.localIndices hw S).length : ℕ) : ℝ) ≤ ε*w := by + rw [A.symm.localIndices_span hw hT, localIndices_length] + have hh : (((A.rightSpan S).card - S.card : ℕ) : ℝ) ≤ A.spanLoss w i := by + exact_mod_cast A.right_span_holes_le_spanLoss hconv hS + exact hh.trans hV + obtain ⟨hlabels, k, hk⟩ := hlocal (x.get i) (y.get j) _ _ + (A.localIndices_sorted hw hS) (A.symm.localIndices_sorted hw hT) (by simp) + hbound hleft hright (A.localIndices_letters hw (by rfl)) + refine ⟨hlabels, ?_⟩ + rw [localIndices, localIndices, zip_ofFn] at hk + obtain ⟨p, hp⟩ := List.mem_ofFn.mp hk + refine ⟨S.orderEmbOfFin rfl p, S.orderEmbOfFin_mem rfl p, ?_⟩ + have hl := congrArg (fun z : Fin w × Fin w => z.1.val) hp + have hr := congrArg (fun z : Fin w × Fin w => z.2.val) hp + exact hl.trans hr.symm + +theorem good_block_anchor (hw : 0 < w) {ε : ℝ} (hε : ε ≤ 1/10) + (hlocal : AnchorLocal ε c) (A : WordMatching (encode c x) (encode c y) q) + (i : Fin x.length) (hU : (A.sourceLoss w i : ℝ) ≤ ε*w) + (hV : (A.spanLoss w i : ℝ) ≤ ε*w) : + ∃ j : Fin y.length, x.get i = y.get j ∧ + ∃ k ∈ A.blockPair w i j, (A.left k).val%w = (A.right k).val%w := by + have hc := A.sourceBlock_card_le hw i + have hs := A.card_le_rightSpan (A.sourceBlock w i) + have hcardU : A.sourceLoss w i + (A.sourceBlock w i).card = w := Nat.sub_add_cancel hc + have hcardV : A.spanLoss w i + (A.sourceBlock w i).card = (A.rightSpan (A.sourceBlock w i)).card := + Nat.sub_add_cancel hs + have hU' : (A.sourceLoss w i : ℝ) ≤ (w : ℝ)/10 := by nlinarith + have hV' : (A.spanLoss w i : ℝ) ≤ (w : ℝ)/10 := by nlinarith + have hsmall : (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w := by + apply Nat.cast_le (α := ℝ) |>.mp + have h1 : (A.spanLoss w i : ℝ) + (A.sourceBlock w i).card = (A.rightSpan (A.sourceBlock w i)).card := by exact_mod_cast hcardV + have h2 : ((A.sourceBlock w i).card : ℝ) ≤ w := by exact_mod_cast hc + push_cast + linarith + have hlarge : 3*w < 4*(A.sourceBlock w i).card := by + apply Nat.cast_lt (α := ℝ) |>.mp + have h1 : (A.sourceLoss w i : ℝ) + (A.sourceBlock w i).card = w := by exact_mod_cast hcardU + have hp : (0 : ℝ) < w := by exact_mod_cast hw + push_cast + linarith + obtain ⟨j, hj, hcard⟩ := A.exists_large_blockPair hw hsmall hlarge + have hjlt : j < y.length := by + obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp hj + apply (Nat.div_lt_iff_lt_mul hw).mpr + simpa only [length_encode, Nat.mul_comm] using (A.right k).isLt + exact ⟨⟨j, hjlt⟩, A.anchor_on_blockPair hw hlocal i ⟨j, hjlt⟩ hcard hU hV⟩ + +end WordMatching + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +theorem mod_injectiveOn (A : WordMatching x y q) {w i : ℕ} : + Set.InjOn (fun k : Fin q => (A.left k).val%w) (↑(A.sourceBlock w i) : Set (Fin q)) := by + intro k hk l hl he + change (A.left k).val%w = (A.left l).val%w at he + apply A.left.injective + apply Fin.ext + have h1 := Nat.mod_add_div (A.left k).val w + have h2 := Nat.mod_add_div (A.left l).val w + rw [(A.mem_sourceBlock w i k).mp hk, he] at h1 + rw [(A.mem_sourceBlock w i l).mp hl] at h2 + omega + +theorem block_before_card_le (A : WordMatching x y q) {w i : ℕ} + {k : Fin q} (hk : k ∈ A.sourceBlock w i) : + ((A.sourceBlock w i).filter (fun l => l < k)).card ≤ (A.left k).val%w := by + let T := (A.sourceBlock w i).filter (fun l => l < k) + let f := fun l : Fin q => (A.left l).val%w + have hinj : Set.InjOn f (↑T : Set (Fin q)) := A.mod_injectiveOn.mono (by + intro l hl; exact (Finset.mem_filter.mp hl).1) + have hsub : T.image f ⊆ Finset.Iio ((A.left k).val%w) := by + intro j hj + obtain ⟨l, hl, rfl⟩ := Finset.mem_image.mp hj + obtain ⟨hl, hlt⟩ := Finset.mem_filter.mp hl + exact Finset.mem_Iio.mpr (A.mod_strictMono_on_block hl hk hlt) + rw [← Finset.card_image_of_injOn hinj] + simpa only [Nat.card_Iio] using Finset.card_le_card hsub + +theorem block_after_card_le (A : WordMatching x y q) {w i : ℕ} (hw : 0 < w) + {k : Fin q} (hk : k ∈ A.sourceBlock w i) : + ((A.sourceBlock w i).filter (fun l => k < l)).card ≤ w - (A.left k).val%w - 1 := by + let T := (A.sourceBlock w i).filter (fun l => k < l) + let f := fun l : Fin q => (A.left l).val%w + have hinj : Set.InjOn f (↑T : Set (Fin q)) := A.mod_injectiveOn.mono (by + intro l hl; exact (Finset.mem_filter.mp hl).1) + have hsub : T.image f ⊆ Finset.Ioo ((A.left k).val%w) w := by + intro j hj + obtain ⟨l, hl, rfl⟩ := Finset.mem_image.mp hj + obtain ⟨hl, hlt⟩ := Finset.mem_filter.mp hl + exact Finset.mem_Ioo.mpr ⟨A.mod_strictMono_on_block hk hl hlt, Nat.mod_lt _ hw⟩ + rw [← Finset.card_image_of_injOn hinj] + simpa only [Nat.card_Ioo] using Finset.card_le_card hsub + +theorem two_anchors_source_loss (A : WordMatching x y q) {w i j t : ℕ} (hw : 0 < w) + (hij : i < j) {k l : Fin q} (hk : k ∈ A.blockPair w i t) (hl : l ∈ A.blockPair w j t) + (hkmod : (A.left k).val%w = (A.right k).val%w) + (hlmod : (A.left l).val%w = (A.right l).val%w) : + w ≤ A.sourceLoss w i + A.sourceLoss w j := by + obtain ⟨hki, hkt⟩ := Finset.mem_inter.mp hk + obtain ⟨hlj, hlt⟩ := Finset.mem_inter.mp hl + let T := (A.sourceBlock w i).filter (fun v => k ≤ v) + let U := (A.sourceBlock w j).filter (fun v => v ≤ l) + have hdis : Disjoint T U := by + apply Finset.disjoint_left.mpr + intro v hv hu + exact (lt_irrefl v) (A.sourceBlock_order hij (Finset.mem_filter.mp hv).1 (Finset.mem_filter.mp hu).1) + have hmaps : Set.MapsTo A.right (↑(T ∪ U) : Set (Fin q)) + (↑(Finset.Icc (A.right k) (A.right l)) : Set (Fin y.length)) := by + intro v hv + change A.right v ∈ Finset.Icc (A.right k) (A.right l) + rcases Finset.mem_union.mp hv with hv | hv + · obtain ⟨hv, hkv⟩ := Finset.mem_filter.mp hv + exact Finset.mem_Icc.mpr ⟨A.right.monotone hkv, + A.right.monotone (A.sourceBlock_order hij hv hlj).le⟩ + · obtain ⟨hv, hvl⟩ := Finset.mem_filter.mp hv + exact Finset.mem_Icc.mpr ⟨A.right.monotone (A.sourceBlock_order hij hki hv).le, + A.right.monotone hvl⟩ + have hc := Finset.card_le_card_of_injOn A.right hmaps A.right.injective.injOn + rw [Finset.card_union_of_disjoint hdis, Fin.card_Icc] at hc + have hb := A.block_before_card_le hki + have ha := A.block_after_card_le hw hlj + have hTi : T.card + ((A.sourceBlock w i).filter (fun v => v < k)).card = (A.sourceBlock w i).card := by + simpa only [not_le] using Finset.card_filter_add_card_filter_not (s := A.sourceBlock w i) (p := fun v => k ≤ v) + have hUj : U.card + ((A.sourceBlock w j).filter (fun v => l < v)).card = (A.sourceBlock w j).card := by + simpa only [not_le] using Finset.card_filter_add_card_filter_not (s := A.sourceBlock w j) (p := fun v => v ≤ l) + have hXi : A.sourceLoss w i + (A.sourceBlock w i).card = w := Nat.sub_add_cancel (A.sourceBlock_card_le hw i) + have hXj : A.sourceLoss w j + (A.sourceBlock w j).card = w := Nat.sub_add_cancel (A.sourceBlock_card_le hw j) + have hrk := Nat.mod_add_div (A.right k).val w + have hrl := Nat.mod_add_div (A.right l).val w + have hkt' : (A.right k).val/w = t := (A.symm.mem_sourceBlock w t k).mp hkt + have hlt' : (A.right l).val/w = t := (A.symm.mem_sourceBlock w t l).mp hlt + rw [hkt', ← hkmod] at hrk + rw [hlt', ← hlmod] at hrl + have hklt := Nat.mod_lt (A.left k).val hw + have hllt := Nat.mod_lt (A.left l).val hw + have hkl : (A.right k).val ≤ (A.right l).val := A.right.monotone (A.sourceBlock_order hij hki hlj).le + omega + +end WordMatching + +namespace WordMatching +variable {α : Type*} {x y : List α} {w q : ℕ} {c : α → Fin w → Bool} + +theorem anchors_strict_order (hw : 0 < w) {ε : ℝ} (hε : ε ≤ 1/10) + (A : WordMatching (encode c x) (encode c y) q) + {i j : Fin x.length} {s t : Fin y.length} (hij : i < j) + {k l : Fin q} (hk : k ∈ A.blockPair w i s) (hl : l ∈ A.blockPair w j t) + (hkmod : (A.left k).val%w = (A.right k).val%w) + (hlmod : (A.left l).val%w = (A.right l).val%w) + (hUi : (A.sourceLoss w i : ℝ) ≤ ε*w) (hUj : (A.sourceLoss w j : ℝ) ≤ ε*w) : s < t := by + have hkl : k < l := A.sourceBlock_order hij (Finset.mem_inter.mp hk).1 (Finset.mem_inter.mp hl).1 + have hks : (A.right k).val/w = s.val := (A.symm.mem_sourceBlock w s k).mp (Finset.mem_inter.mp hk).2 + have hlt : (A.right l).val/w = t.val := (A.symm.mem_sourceBlock w t l).mp (Finset.mem_inter.mp hl).2 + have hquot := Nat.div_le_div_right (c := w) (show (A.right k).val ≤ (A.right l).val from (A.right.strictMono hkl).le) + rw [hks, hlt] at hquot + have hne : s ≠ t := by + intro he + have hl' : l ∈ A.blockPair w j s := by simpa only [he] using hl + have hc := A.two_anchors_source_loss hw hij hk hl' hkmod hlmod + have hc' : (w : ℝ) ≤ A.sourceLoss w i + A.sourceLoss w j := by exact_mod_cast hc + have hp : (0 : ℝ) < w := by exact_mod_cast hw + nlinarith + exact lt_of_le_of_ne hquot hne + +theorem good_blocks_le_lcs (hw : 0 < w) {ε : ℝ} (hε : ε ≤ 1/10) + (hlocal : AnchorLocal ε c) (A : WordMatching (encode c x) (encode c y) q) : + (Finset.univ.filter (fun i : Fin x.length => + (A.sourceLoss w i : ℝ) ≤ ε*w ∧ (A.spanLoss w i : ℝ) ≤ ε*w)).card ≤ lcs x y := by + classical + let G := Finset.univ.filter (fun i : Fin x.length => + (A.sourceLoss w i : ℝ) ≤ ε*w ∧ (A.spanLoss w i : ℝ) ≤ ε*w) + let e := G.orderEmbOfFin rfl + have hgood (k : Fin G.card) : (A.sourceLoss w (e k) : ℝ) ≤ ε*w ∧ (A.spanLoss w (e k) : ℝ) ≤ ε*w := + (Finset.mem_filter.mp (G.orderEmbOfFin_mem rfl k)).2 + have hex (k : Fin G.card) : ∃ j : Fin y.length, x.get (e k) = y.get j ∧ + ∃ p ∈ A.blockPair w (e k) j, (A.left p).val%w = (A.right p).val%w := + A.good_block_anchor hw hε hlocal (e k) (hgood k).1 (hgood k).2 + choose f hlabels p hp hmod using hex + have hmono : StrictMono f := by + intro k l hkl + exact A.anchors_strict_order hw hε (e.strictMono hkl) (hp k) (hp l) + (hmod k) (hmod l) (hgood k).1 (hgood l).1 + let B : WordMatching x y G.card := + { left := e + right := OrderEmbedding.ofStrictMono f hmono + letters := hlabels } + exact B.le_lcs + +end WordMatching + +theorem anchor_deficit_lower {α : Type*} {w : ℕ} (hw : 0 < w) {ε : ℝ} + (hε0 : 0 ≤ ε) (hε : ε ≤ 1/10) {c : α → Fin w → Bool} (hlocal : AnchorLocal ε c) + (x y : List α) (hlen : x.length = y.length) : + (ε/2) * w * deficit x y ≤ (deficit (encode c x) (encode c y) : ℝ) := by + classical + obtain ⟨A⟩ := exists_lcs_matching (encode c x) (encode c y) + let U : Fin x.length → ℝ := fun i => A.sourceLoss w i + let V : Fin x.length → ℝ := fun i => A.spanLoss w i + let G := Finset.univ.filter (fun i : Fin x.length => U i ≤ ε*w ∧ V i ≤ ε*w) + let B := Gᶜ + have hG : G.card ≤ lcs x y := A.good_blocks_le_lcs hw hε hlocal + have hB : deficit x y ≤ B.card := by + have hc := Finset.card_compl G + simp only [Fintype.card_fin] at hc + dsimp only [B, deficit] + omega + have hbad (i : Fin x.length) (hi : i ∈ B) : ε*w ≤ U i + V i := by + have hn : ¬(U i ≤ ε*w ∧ V i ≤ ε*w) := by + simpa only [B, G, Finset.mem_compl, Finset.mem_filter, Finset.mem_univ, true_and] using hi + have hu : 0 ≤ U i := Nat.cast_nonneg _ + have hv : 0 ≤ V i := Nat.cast_nonneg _ + push Not at hn + by_cases hh : U i ≤ ε*w + · have := hn hh + linarith + · push Not at hh + linarith + have hsumU : ∑ i, U i = (deficit (encode c x) (encode c y) : ℝ) := by + have h := A.sum_sourceLoss hw (length_encode c x) + simp only [U, deficit, length_encode] + exact_mod_cast h + have hsumV : ∑ i, V i ≤ (deficit (encode c x) (encode c y) : ℝ) := by + have h := A.sum_spanLoss_le hw (length_encode c x) (by rw [length_encode, hlen]) + simp only [V, deficit, length_encode] + exact_mod_cast h + have hcost : ε*w*(B.card : ℝ) ≤ ∑ i, (U i + V i) := calc + _ = ∑ _i ∈ B, ε*w := by simp [mul_comm] + _ ≤ ∑ i ∈ B, (U i + V i) := Finset.sum_le_sum hbad + _ ≤ ∑ i, (U i + V i) := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun i _ _ => add_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + rw [Finset.sum_add_distrib, hsumU] at hcost + have hmul := mul_le_mul_of_nonneg_left (show (deficit x y : ℝ) ≤ B.card by exact_mod_cast hB) + (mul_nonneg hε0 (Nat.cast_nonneg w)) + nlinarith + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/BinaryDistortion.lean b/lean/OAI/Combinatorics/FiniteCircle/BinaryDistortion.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cd1820afc00034f899507ecdfbe54e4b4aad756 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/BinaryDistortion.lean @@ -0,0 +1,187 @@ +import OAI.Combinatorics.FiniteCircle.Parameters + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem coded_range_lower {I α : Type*} [Fintype I] [DecidableEq I] [Fintype α] + {n k M : ℕ} [NeZero M] (hn : 1000000≤n) (hk : n^4=4*k) + (hJ : Nat.log 2 M+1≤n^13) + (H : AddSubgroup (I → ZMod M)) [Fintype H] (θ : I → ZMod M) + (hb : ∀ χ : AddChar (I → ZMod M) ℂ, χ.compAddMonoidHom H.subtype=0 → χ θ≠1 → + (((n^4:ℕ):ℝ)/2)^(n^4) ≤ ∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ)) + (W : (I → ZMod M) → List α) (L copies : ℕ) (hL : 0 encode c (W v)) => x.val) := by + classical + have hn0 : 0 encode c (W v)) (n^4) ((n^4)^(2*n^4):ℕ) L copies w + ((1/268435456)*w/(n:ℝ)^(3*n^4)) ((n:ℝ)^k) (by positivity) (by have := hc.1; positivity) + (by exact_mod_cast hcL) + · intro v z + apply (le_div_iff₀ hR).mpr + have he := hc.2.2.2 (W v) (W (v+z)) + have ht := Nat.mul_le_mul_left ((n^4)^(2*n^4)) he + have hh := Nat.mul_le_mul_left w (hcheap v z) + have hn : editDistance (encode c (W v)) (encode c (W (v+z)))*((n^4)^(2*n^4)) ≤ w*2*n^4*L := by + nlinarith + exact_mod_cast hn + · intro v i j + have he := (hc.2.2.2 (W v) (W (v+Pi.single i ((2^j.val:ℕ):ZMod M)))).trans + (Nat.mul_le_mul_left w (hsingle v i j)) + have hn : editDistance (encode c (W v)) (encode c (W (v+Pi.single i ((2^j.val:ℕ):ZMod M)))) ≤ + w*2*copies*2^j.val := by nlinarith + exact_mod_cast hn + · intro v + have hd := (hc.2.2.1 L (W v) (W (v+θ)) (hLen v) (hLen (v+θ))).1 + have he := deficit_le_editDistance (x:=encode c (W v)) (y:=encode c (W (v+θ))) (by simp only [length_encode,hLen]) + calc + _ = (1/268435456)*w*((L:ℝ)/(n:ℝ)^(3*n^4)) := by ring + _ ≤ (1/268435456)*w*(deficit (W v) (W (v+θ)):ℝ) := + mul_le_mul_of_nonneg_left (hlong v) (by positivity) + _ ≤ (deficit (encode c (W v)) (encode c (W (v+θ))):ℝ) := hd + _ ≤ _ := by exact_mod_cast he + · intro t _ ht + apply lower_numeric hn hk hJ hc.1 t + simpa only [Nat.cast_pow] using ht + + theorem flatMaskState_surjective (h : ℕ) (p : ℕ → ℕ → ℕ) (M l : ℕ) : + Function.Surjective (flatMaskState h p M l) := by + classical + induction l with + | zero => intro v; exact ⟨fun _ => v,rfl⟩ + | succ l ih => + intro v + choose f hf using fun j => ih (v j) + refine ⟨fun i => f i.1 i.2, ?_⟩ + funext j + exact hf j + + theorem flatExcludedState_surjective (h M l : ℕ) : + Function.Surjective (flatExcludedState h M l) := by + classical + induction l with + | zero => intro v; exact ⟨fun _ => v,rfl⟩ + | succ l ih => + intro v + choose f hf using fun j => ih (v j) + refine ⟨fun i => f i.1 i.2, ?_⟩ + funext j + exact hf j + + theorem range_comp_surjective {X Y Z : Type*} (f : X → Y) (g : Y → Z) (hf : Function.Surjective f) : + Set.range (fun x => g (f x)) = Set.range g := by + ext z + constructor + · rintro ⟨x,rfl⟩; exact ⟨f x,rfl⟩ + · rintro ⟨y,rfl⟩; obtain ⟨x,rfl⟩ := hf y; exact ⟨x,rfl⟩ + + theorem mask_length_factor (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) : + maskLength h p R M l = M*Fintype.card (TreeLeaf (MaskChildren h p) l)*treeCopies R (period h p) l := by + apply tree_length_eq (MaskChildren h p) M R (period h p) (maskLength h p R M) rfl + intro l + simp only [maskLength, length_maskTags] + congr 2 + simp only [MaskChildren, Fintype.card_sigma, Fintype.card_fin] + + theorem excluded_length_factor (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) : + excludedLength h p R M l = M*Fintype.card (TreeLeaf (fun _ => Fin h) l)*treeCopies R (period h p) l := by + apply tree_length_eq (fun _ => Fin h) M R (period h p) (excludedLength h p R M) rfl + intro l + simp only [excludedLength,length_excludedTags,Fintype.card_fin] + + theorem mask_binary_distortion {n k : ℕ} (hn : 1000000≤n) (hk : n^4=4*k) + {p : ℕ → ℕ → ℕ} (hp : StandingPrimes (n^4) p) {w : ℕ} + (c : MaskAlphabet (n^4) p (n^4) → Fin w → Bool) + (hc : SubstitutionBounds (1/268435456) 67108928 c) : + (n:ℝ)^k ≤ setDistortion (Set.range fun v : MaskState (n^4) p (circleSize (n^4) p) (n^4) => + encode c (maskWord (n^4) p ((n^4)^(2*n^4)) (circleSize (n^4) p) (n^4) v)) := by + classical + let h := n^4 + let M := circleSize h p + let R := h^(2*h) + let : NeZero M := ⟨hp.circle_pos.ne'⟩ + have hh : 2≤h := (show 2≤n by omega).trans (le_self_pow₀ (by omega) (by norm_num)) + have hR : 0 ((M/2:ℕ):ZMod M))≠1) : + ((h:ℝ)/2)^h ≤ ∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ) := by + apply mask_character_branching hh hp.divides_circle hp.positive + (fun l k hl hlh => (hp.atLevel l hl hlh k).1) + hp.level_injective (fun l k hl hlh => (hp.atLevel l hl hlh k).2.1.le) χ ha _ hw + have hlong (v : TreeLeaf (MaskChildren h p) h → ZMod M) : + (maskLength h p R M h:ℝ)/(n:ℝ)^(3*n^4) ≤ + (deficit (flatMaskWord h p R M h v) (flatMaskWord h p R M h (v+(fun _ => ((M/2:ℕ):ZMod M)))):ℝ) := by + have he : n^4=2*(n^4/2) := by omega + have ht := mask_long_deficit hn he hp hR (flatMaskState h p M h v) + have hf := flatMaskState_shift h p M h v ((M/2:ℕ):ZMod M) + change flatMaskState h p M h (v+(fun _ => ((M/2:ℕ):ZMod M))) = _ at hf + simpa only [flatMaskWord,hf] using ht + have ht := coded_range_lower hn hk (hp.log_circle_fourth hn) H (fun _ => ((M/2:ℕ):ZMod M)) hhb + (flatMaskWord h p R M h) (maskLength h p R M h) (treeCopies R (period h p) h) + (hp.mask_length_pos (by omega) hR h) (mask_length_factor h p R M h) + (fun v => length_maskWord h p R M h (flatMaskState h p M h v)) + (fun v z => mask_cheap_ed hR hp.divides_circle hp.positive hp.coprime h v z z.property) + (fun v i j => mask_single_ed (StandingPrimes.circle_even (h:=h) (p:=p)) h v i (2^j.val)) hlong c hc + have he := range_comp_surjective (flatMaskState h p M h) + (fun v => encode c (maskWord h p R M h v)) (flatMaskState_surjective h p M h) + unfold flatMaskWord at ht + rw [he] at ht + exact ht + theorem excluded_binary_distortion {n k : ℕ} (hn : 1000000≤n) (hk : n^4=4*k) + {p : ℕ → ℕ → ℕ} (hp : StandingPrimes (n^4) p) {w : ℕ} + (c : ExcludedAlphabet (n^4) (circleSize (n^4) p) (n^4) → Fin w → Bool) + (hc : SubstitutionBounds (1/268435456) 67108928 c) : + (n:ℝ)^k ≤ setDistortion (Set.range fun v : ExcludedState (n^4) (circleSize (n^4) p) (n^4) => + encode c (excludedWord (n^4) p ((n^4)^(2*n^4)) (circleSize (n^4) p) (n^4) v)) := by + classical + let h := n^4 + let M := circleSize h p + let R := h^(2*h) + let : NeZero M := ⟨hp.circle_pos.ne'⟩ + have hh : 2≤h := (show 2≤n by omega).trans (le_self_pow₀ (by omega) (by norm_num)) + have hR : 0 Fin h) h → ZMod M) ℂ) + (ha : χ.compAddMonoidHom H.subtype=0) (hw : χ (fun _ => ((M/2:ℕ):ZMod M))≠1) : + ((h:ℝ)/2)^h ≤ ∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ) := by + apply excluded_character_branching hh hp.divides_circle hp.positive + (fun l k hl hlh => (hp.atLevel l hl hlh k).1) + hp.level_injective (fun l k hl hlh => (hp.atLevel l hl hlh k).2.1.le) χ ha _ hw + have hlong (v : TreeLeaf (fun _ => Fin h) h → ZMod M) : + (excludedLength h p R M h:ℝ)/(n:ℝ)^(3*n^4) ≤ + (deficit (flatExcludedWord h p R M h v) (flatExcludedWord h p R M h (v+(fun _ => ((M/2:ℕ):ZMod M)))):ℝ) := by + have he : n^4=2*(n^4/2) := by omega + have ht := excluded_long_deficit hn he hp hR (flatExcludedState h M h v) + have hf := flatExcludedState_shift h M h v ((M/2:ℕ):ZMod M) + change flatExcludedState h M h (v+(fun _ => ((M/2:ℕ):ZMod M))) = _ at hf + simpa only [flatExcludedWord,hf] using ht + have ht := coded_range_lower hn hk (hp.log_circle_fourth hn) H (fun _ => ((M/2:ℕ):ZMod M)) hhb + (flatExcludedWord h p R M h) (excludedLength h p R M h) (treeCopies R (period h p) h) + (hp.excluded_length_pos (by omega) hR h) (excluded_length_factor h p R M h) + (fun v => length_excludedWord h p R M h (flatExcludedState h M h v)) + (fun v z => excluded_cheap_ed hR hp.divides_circle hp.positive hp.coprime h v z z.property) + (fun v i j => excluded_single_ed (StandingPrimes.circle_even (h:=h) (p:=p)) h v i (2^j.val)) hlong c hc + have he := range_comp_surjective (flatExcludedState h M h) + (fun v => encode c (excludedWord h p R M h v)) (flatExcludedState_surjective h M h) + unfold flatExcludedWord at ht + rw [he] at ht + exact ht + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/BitCounting.lean b/lean/OAI/Combinatorics/FiniteCircle/BitCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..fce98776a3469c066d1c7fe7538bd71b568dc158 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/BitCounting.lean @@ -0,0 +1,155 @@ +import OAI.Combinatorics.FiniteCircle.OffsetRecovery + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem exists_disjoint_pair_subfamily {ι J : Type*} [DecidableEq ι] [DecidableEq J] + (f g : ι → J) (hf : Function.Injective f) (hg : Function.Injective g) + (I : Finset ι) (hne : ∀ i ∈ I, f i ≠ g i) : + ∃ S ⊆ I, I.card ≤ 3*S.card ∧ ∀ i ∈ S, ∀ j ∈ S, f i ≠ g j := by + induction I using Finset.strongInductionOn + rename_i I ih + by_cases he : I.Nonempty + · obtain ⟨k, hk⟩ := he + let N := I.filter (fun i => i = k ∨ f i = g k ∨ g i = f k) + let T := I \ N + have hkN : k ∈ N := Finset.mem_filter.mpr ⟨hk, Or.inl rfl⟩ + have hN : N ⊆ I := Finset.filter_subset _ _ + have hT : T ⊂ I := Finset.ssubset_iff_subset_ne.mpr ⟨Finset.sdiff_subset, by + intro heq + have hmem : k ∈ T := heq.symm ▸ hk + exact (Finset.mem_sdiff.mp hmem).2 hkN⟩ + have hca : (I.filter (fun i => f i = g k)).card ≤ 1 := by + apply Finset.card_le_one.mpr + intro i hi j hj + exact hf ((Finset.mem_filter.mp hi).2.trans (Finset.mem_filter.mp hj).2.symm) + have hcb : (I.filter (fun i => g i = f k)).card ≤ 1 := by + apply Finset.card_le_one.mpr + intro i hi j hj + exact hg ((Finset.mem_filter.mp hi).2.trans (Finset.mem_filter.mp hj).2.symm) + have hsub : N ⊆ {k} ∪ I.filter (fun i => f i = g k) ∪ I.filter (fun i => g i = f k) := by + intro i hi + obtain ⟨hi, hn⟩ := Finset.mem_filter.mp hi + rcases hn with rfl | ha | hb + · simp + · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨hi, ha⟩)) + · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨hi, hb⟩) + have hNc : N.card ≤ 3 := by + have h1 := Finset.card_le_card hsub + have h2 := Finset.card_union_le ({k} ∪ I.filter (fun i => f i = g k)) (I.filter (fun i => g i = f k)) + have h3 := Finset.card_union_le ({k} : Finset ι) (I.filter (fun i => f i = g k)) + simp only [Finset.card_singleton] at h3 + omega + obtain ⟨S, hST, hc, hcross⟩ := ih T hT (fun i hi => hne i (Finset.sdiff_subset hi)) + have hkS : k ∉ S := fun hks => (Finset.mem_sdiff.mp (hST hks)).2 hkN + refine ⟨insert k S, Finset.insert_subset_iff.mpr ⟨hk, hST.trans Finset.sdiff_subset⟩, ?_, ?_⟩ + · rw [Finset.card_insert_of_notMem hkS] + have hIc : T.card = I.card - N.card := Finset.card_sdiff_of_subset hN + have hNi := Finset.card_le_card hN + omega + · intro i hi j hj + rcases Finset.mem_insert.mp hi with hi | hi + · subst i + rcases Finset.mem_insert.mp hj with hj | hj + · subst j + exact hne k hk + · intro hh + have hjI := (Finset.mem_sdiff.mp (hST hj)).1 + have hjN := (Finset.mem_sdiff.mp (hST hj)).2 + exact hjN (Finset.mem_filter.mpr ⟨hjI, Or.inr (Or.inr hh.symm)⟩) + · rcases Finset.mem_insert.mp hj with hj | hj + · subst j + intro hh + have hiI := (Finset.mem_sdiff.mp (hST hi)).1 + have hiN := (Finset.mem_sdiff.mp (hST hi)).2 + exact hiN (Finset.mem_filter.mpr ⟨hiI, Or.inr (Or.inl hh)⟩) + · exact hcross i hi j hj + · refine ⟨∅, Finset.empty_subset _, ?_, by simp⟩ + simp [Finset.not_nonempty_iff_eq_empty.mp he] + +theorem card_bit_equalities_le {ι J : Type*} [Fintype J] [DecidableEq J] [DecidableEq ι] + (I : Finset ι) (f g : ι → J) (hg : Function.Injective g) + (hcross : ∀ i ∈ I, ∀ j ∈ I, f i ≠ g j) : + (Finset.univ.filter (fun ω : J → Bool => ∀ i ∈ I, ω (f i) = ω (g i))).card ≤ + 2 ^ (Fintype.card J - I.card) := by + classical + let T := I.image g + let π : (J → Bool) → (↥(Tᶜ : Finset J) → Bool) := fun ω j => ω j.val + have hinj : Set.InjOn π (↑(Finset.univ.filter (fun ω : J → Bool => ∀ i ∈ I, ω (f i) = ω (g i))) : Set (J → Bool)) := by + intro ω hω η hη he + have hω := (Finset.mem_filter.mp hω).2 + have hη := (Finset.mem_filter.mp hη).2 + funext j + by_cases hj : j ∈ T + · obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hj + have hf : f i ∈ Tᶜ := by + apply Finset.mem_compl.mpr + intro hh + obtain ⟨k, hk, heq⟩ := Finset.mem_image.mp hh + exact hcross i hi k hk heq.symm + have heq : ω (f i) = η (f i) := congrFun he ⟨f i, hf⟩ + exact (hω i hi).symm.trans (heq.trans (hη i hi)) + · exact congrFun he ⟨j, Finset.mem_compl.mpr hj⟩ + have hc := Finset.card_le_card_of_injOn π (fun _ _ => Finset.mem_univ _) hinj + simpa only [Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_coe, + Finset.card_compl, Finset.card_image_of_injective I hg, T] using hc + +theorem card_matching_equalities_le {ι J : Type*} [Fintype J] [DecidableEq J] [DecidableEq ι] + (I : Finset ι) (f g : ι → J) (hf : Function.Injective f) (hg : Function.Injective g) + (hne : ∀ i ∈ I, f i ≠ g i) (w : ℕ) (hw : w ≤ 16*I.card) : + (Finset.univ.filter (fun ω : J → Bool => ∀ i ∈ I, ω (f i) = ω (g i))).card ≤ + 2 ^ (Fintype.card J - w/64) := by + classical + obtain ⟨S, hSI, hcard, hcross⟩ := exists_disjoint_pair_subfamily f g hf hg I hne + have hsub : (Finset.univ.filter (fun ω : J → Bool => ∀ i ∈ I, ω (f i) = ω (g i))) ⊆ + Finset.univ.filter (fun ω : J → Bool => ∀ i ∈ S, ω (f i) = ω (g i)) := by + intro ω hω + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i hi => (Finset.mem_filter.mp hω).2 i (hSI hi)⟩ + have hh : w/64 ≤ S.card := by omega + exact (Finset.card_le_card hsub).trans ((card_bit_equalities_le S f g hg hcross).trans + (Nat.pow_le_pow_right (by omega) (Nat.sub_le_sub_left hh _))) + +theorem card_small_subsets_le (w : ℕ) : + ((Finset.univ.filter (fun S : Finset (Fin w) => (S.card : ℝ) ≤ (w : ℝ)/1048576)).card : ℝ) ≤ + Real.exp ((w : ℝ)/512) := by + classical + let K := Finset.univ.filter (fun S : Finset (Fin w) => (S.card : ℝ) ≤ (w : ℝ)/1048576) + let z : ℝ := 1/1024 + have hz : 0 < z := by norm_num [z] + have hlog : -1024 ≤ Real.log z := by + have h := Real.log_le_sub_one_of_pos (x := 1024) (by norm_num) + simp only [z, one_div, Real.log_inv] + linarith + have hlow (S : Finset (Fin w)) (hS : S ∈ K) : Real.exp (-(w : ℝ)/1024) ≤ z^S.card := by + have hs := (Finset.mem_filter.mp hS).2 + have hmul := mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg S.card) + have he : -(w : ℝ)/1024 ≤ (S.card : ℝ)*Real.log z := by nlinarith + have h := Real.exp_le_exp.mpr he + simpa only [Real.exp_nat_mul, Real.exp_log hz] using h + have htotal : ∑ S : Finset (Fin w), z^S.card = (z+1)^w := by + simpa using Finset.sum_pow_mul_eq_add_pow z (1 : ℝ) (Finset.univ : Finset (Fin w)) + have hsum : (K.card : ℝ) * Real.exp (-(w : ℝ)/1024) ≤ (z+1)^w := calc + _ = ∑ _S ∈ K, Real.exp (-(w : ℝ)/1024) := by simp + _ ≤ ∑ S ∈ K, z^S.card := Finset.sum_le_sum hlow + _ ≤ ∑ S : Finset (Fin w), z^S.card := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ _) (fun _ _ _ => pow_nonneg hz.le _) + _ = _ := htotal + have hupper : (z+1)^w ≤ Real.exp ((w : ℝ)/1024) := by + have hl := Real.log_le_sub_one_of_pos (x := z+1) (by positivity) + have hm := mul_le_mul_of_nonneg_left hl (Nat.cast_nonneg w) + have hh : (w : ℝ)*Real.log (z+1) ≤ (w : ℝ)/1024 := by dsimp [z] at *; nlinarith + have hh := Real.exp_le_exp.mpr hh + simpa only [Real.exp_nat_mul, Real.exp_log (show 0 < z+1 by positivity)] using hh + calc + (K.card : ℝ) ≤ (z+1)^w / Real.exp (-(w : ℝ)/1024) := (le_div_iff₀ (Real.exp_pos _)).mpr hsum + _ ≤ Real.exp ((w : ℝ)/1024) / Real.exp (-(w : ℝ)/1024) := div_le_div_of_nonneg_right hupper (Real.exp_pos _).le + _ = Real.exp ((w : ℝ)/512) := by rw [← Real.exp_sub]; congr 1; ring + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/BlockMatching.lean b/lean/OAI/Combinatorics/FiniteCircle/BlockMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..947e070ae5524e7f5eeeb37e204b51d367d0af3f --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/BlockMatching.lean @@ -0,0 +1,183 @@ +import OAI.Combinatorics.FiniteCircle.BinaryDistortion + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem get_encode_block {α : Type*} {w : ℕ} (c : α → Fin w → Bool) + (x : List α) (i : Fin x.length) (r : Fin w) : + (encode c x).get ⟨i.val * w + r.val, by + rw [length_encode] + nlinarith [i.isLt, r.isLt]⟩ = c (x.get i) r := by + induction x with + | nil => exact Fin.elim0 i + | cons a x ih => + refine Fin.cases ?_ (fun j => ?_) i + · simp only [Fin.val_zero, Nat.zero_mul, Nat.zero_add, encode_cons, List.get_eq_getElem, + List.getElem_cons_zero] + rw [List.getElem_append_left (by simp only [List.length_ofFn]; exact r.isLt), List.getElem_ofFn] + · have hit : (j.val+1)*w+r.val < (List.ofFn (c a) ++ encode c x).length := by + simp only [List.length_append, List.length_ofFn, length_encode] + nlinarith [j.isLt, r.isLt] + change (List.ofFn (c a) ++ encode c x)[(j.val+1)*w+r.val] = c (x.get j) r + rw [List.getElem_append_right (by simp only [List.length_ofFn]; nlinarith)] + convert ih j using 1 + simp only [List.length_ofFn, List.get_eq_getElem] + congr 1 + simp [Nat.add_mul, Nat.add_comm, Nat.add_left_comm] + +theorem get_encode {α : Type*} {w : ℕ} (hw : 0 < w) (c : α → Fin w → Bool) + (x : List α) (k : Fin (encode c x).length) : + (encode c x).get k = c (x.get ⟨k.val/w, by + apply (Nat.div_lt_iff_lt_mul hw).mpr + simpa only [length_encode, Nat.mul_comm] using k.isLt⟩) + ⟨k.val%w, Nat.mod_lt _ hw⟩ := by + have h := get_encode_block c x ⟨k.val/w, by + apply (Nat.div_lt_iff_lt_mul hw).mpr + simpa only [length_encode, Nat.mul_comm] using k.isLt⟩ ⟨k.val%w, Nat.mod_lt _ hw⟩ + convert h using 1 + congr 1 + apply Fin.ext + simpa only [Nat.mul_comm] using (Nat.div_add_mod k.val w).symm + +theorem indexSpan_ofFn {w n : ℕ} (f : Fin n → Fin w) (hn : 0 < n) : + indexSpan (List.ofFn f) = (f ⟨n-1, by omega⟩).val + 1 - (f ⟨0, hn⟩).val := by + cases n with + | zero => omega + | succ n => + have he : List.ofFn f ≠ [] := by simp + have hl := List.getLast_ofFn (f := f) he + simp only [List.ofFn_succ, List.getLast_eq_getLastD] at hl + simp only [List.ofFn_succ, indexSpan] + rw [hl] + rfl + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +def localIndices (A : WordMatching x y q) {w : ℕ} (hw : 0 < w) + (S : Finset (Fin q)) : List (Fin w) := + List.ofFn (fun k : Fin S.card => + ⟨(A.left (S.orderEmbOfFin rfl k)).val % w, Nat.mod_lt _ hw⟩) + +@[simp] theorem localIndices_length (A : WordMatching x y q) {w : ℕ} (hw : 0 < w) + (S : Finset (Fin q)) : (A.localIndices hw S).length = S.card := List.length_ofFn + +theorem mod_strictMono_on_block (A : WordMatching x y q) {w i : ℕ} + {k l : Fin q} (hk : k ∈ A.sourceBlock w i) (hl : l ∈ A.sourceBlock w i) + (hkl : k < l) : (A.left k).val % w < (A.left l).val % w := by + have hm : (A.left k).val < (A.left l).val := A.left.strictMono hkl + have h1 := Nat.mod_add_div (A.left k).val w + have h2 := Nat.mod_add_div (A.left l).val w + rw [(A.mem_sourceBlock w i k).mp hk] at h1 + rw [(A.mem_sourceBlock w i l).mp hl] at h2 + omega + +theorem localIndices_sorted (A : WordMatching x y q) {w i : ℕ} (hw : 0 < w) + {S : Finset (Fin q)} (hS : S ⊆ A.sourceBlock w i) : + (A.localIndices hw S).Pairwise (fun i j => i.val < j.val) := by + apply List.pairwise_ofFn.mpr + intro k l hkl + exact A.mod_strictMono_on_block (hS (S.orderEmbOfFin_mem rfl k)) + (hS (S.orderEmbOfFin_mem rfl l)) ((S.orderEmbOfFin rfl).strictMono hkl) + +theorem localIndices_span (A : WordMatching x y q) {w i : ℕ} (hw : 0 < w) + {S : Finset (Fin q)} (hS : S ⊆ A.sourceBlock w i) : + indexSpan (A.localIndices hw S) = (A.symm.rightSpan S).card := by + by_cases h : S.Nonempty + · have hc : 0 < S.card := Finset.card_pos.mpr h + rw [localIndices, indexSpan_ofFn _ hc, A.symm.rightSpan_eq_Icc h, Fin.card_Icc] + dsimp only + rw [Finset.orderEmbOfFin_last rfl hc, Finset.orderEmbOfFin_zero rfl hc] + simp only [symm] + have h1 := Nat.mod_add_div (A.left (S.min' h)).val w + have h2 := Nat.mod_add_div (A.left (S.max' h)).val w + rw [(A.mem_sourceBlock w i _).mp (hS (S.min'_mem h))] at h1 + rw [(A.mem_sourceBlock w i _).mp (hS (S.max'_mem h))] at h2 + omega + · have he : S = ∅ := Finset.not_nonempty_iff_eq_empty.mp h + have hl : A.localIndices hw S = [] := List.length_eq_zero_iff.mp (by simp [he]) + rw [hl] + simp [indexSpan, he, rightSpan] + +def blockPair (A : WordMatching x y q) (w i j : ℕ) : Finset (Fin q) := + A.sourceBlock w i ∩ A.symm.sourceBlock w j + +theorem blockPair_convex (A : WordMatching x y q) (w i j : ℕ) : + ConvexIndices (A.blockPair w i j) := by + intro k hk l hl v hkv hvl + exact Finset.mem_inter.mpr + ⟨A.sourceBlock_convex w i k (Finset.mem_inter.mp hk).1 l (Finset.mem_inter.mp hl).1 v hkv hvl, + A.symm.sourceBlock_convex w j k (Finset.mem_inter.mp hk).2 l (Finset.mem_inter.mp hl).2 v hkv hvl⟩ + +def targetBlocks (A : WordMatching x y q) (w : ℕ) (S : Finset (Fin q)) : Finset ℕ := + S.image (fun k => (A.right k).val / w) + +theorem targetBlocks_card_le_three (A : WordMatching x y q) {w : ℕ} (hw : 0 < w) + {S : Finset (Fin q)} (hspan : (A.rightSpan S).card ≤ 2*w) : + (A.targetBlocks w S).card ≤ 3 := by + by_cases h : S.Nonempty + · let lo := (A.right (S.min' h)).val + let hi := (A.right (S.max' h)).val + have hle : lo ≤ hi := A.right.monotone (S.min'_le _ (S.max'_mem h)) + have hspan' : hi + 1 - lo ≤ 2*w := by + simpa only [A.rightSpan_eq_Icc h, Fin.card_Icc] using hspan + have hdiv : hi/w ≤ lo/w+2 := by + have hlo := Nat.mod_add_div lo w + have hhi := Nat.mod_add_div hi w + have hm := Nat.mod_lt lo hw + by_contra hh + have hh : lo/w+3 ≤ hi/w := by omega + have hh' := Nat.mul_le_mul_left w hh + have hs : hi+1 ≤ lo+2*w := by omega + have hh2 : w*(lo/w)+3*w ≤ hi := calc + _ = w*(lo/w+3) := by ring + _ ≤ w*(hi/w) := hh' + _ ≤ hi := Nat.mul_div_le hi w + have hlo2 : lo < w*(lo/w)+w := by omega + omega + have hs : A.targetBlocks w S ⊆ Finset.Icc (lo/w) (lo/w+2) := by + intro j hj + obtain ⟨k, hk, rfl⟩ := Finset.mem_image.mp hj + have hklo : lo ≤ (A.right k).val := A.right.monotone (S.min'_le _ hk) + have hkhi : (A.right k).val ≤ hi := A.right.monotone (S.le_max' _ hk) + exact Finset.mem_Icc.mpr ⟨Nat.div_le_div_right hklo, (Nat.div_le_div_right hkhi).trans hdiv⟩ + have hc := Finset.card_le_card hs + rw [Nat.card_Icc] at hc + omega + · simp [targetBlocks, Finset.not_nonempty_iff_eq_empty.mp h] + +theorem sum_blockPair_card (A : WordMatching x y q) (w i : ℕ) : + ∑ j ∈ A.targetBlocks w (A.sourceBlock w i), (A.blockPair w i j).card = + (A.sourceBlock w i).card := by + have hpair (j : ℕ) : A.blockPair w i j = (A.sourceBlock w i).filter (fun k => (A.right k).val / w = j) := by + ext k + simp [blockPair, mem_sourceBlock, symm] + simp_rw [hpair] + rw [Finset.sum_card_fiberwise_eq_card_filter] + congr 1 + apply Finset.filter_true_of_mem + intro k hk + exact Finset.mem_image_of_mem _ hk + +theorem exists_large_blockPair (A : WordMatching x y q) {w i : ℕ} (hw : 0 < w) + (hspan : (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w) + (hcard : 3*w < 4*(A.sourceBlock w i).card) : + ∃ j ∈ A.targetBlocks w (A.sourceBlock w i), w ≤ 4*(A.blockPair w i j).card := by + by_contra hh + push Not at hh + have hs := Finset.sum_le_sum (fun j hj => (hh j hj).le) + rw [← Finset.mul_sum, A.sum_blockPair_card, Finset.sum_const, smul_eq_mul] at hs + have ht := A.targetBlocks_card_le_three hw hspan + have hmul := Nat.mul_le_mul_right w ht + omega + +end WordMatching + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/CircleWords.lean b/lean/OAI/Combinatorics/FiniteCircle/CircleWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..b08d5ff41babe5a568acf290bf9b405b4ed759b1 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/CircleWords.lean @@ -0,0 +1,501 @@ +import OAI.Combinatorics.FiniteCircle.PhaseCost + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +@[simp] theorem mem_maskTags (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) (j : MaskTag h p l) : + j ∈ maskTags h p l := by + rcases j with ⟨k,b⟩ + simp only [maskTags, List.mem_flatten, List.mem_ofFn] + exact ⟨_, ⟨k, rfl⟩, List.mem_ofFn.mpr ⟨b,rfl⟩⟩ + +@[simp] theorem length_maskTags (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) : + (maskTags h p l).length = ∑ k : Fin h, p l k := by + simp [maskTags, List.length_flatten, List.map_ofFn, List.sum_ofFn] + +theorem nodup_maskTags (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) : + (maskTags h p l).Nodup := by + classical + unfold maskTags + have he : (List.ofFn (fun k : Fin h => List.ofFn (fun b : Fin (p l k) => (Sigma.mk k b : MaskTag h p l)))) = + (List.ofFn (fun k : Fin h => k)).map (fun k : Fin h => List.ofFn (fun b : Fin (p l k) => (Sigma.mk k b : MaskTag h p l))) := by simp only [List.map_ofFn]; rfl + rw [he, ← List.flatMap_def] + change ((List.ofFn (fun k : Fin h => k)).flatMap + (fun k : Fin h => List.ofFn (fun b : Fin (p l k) => (Sigma.mk k b : MaskTag h p l)))).Nodup + apply List.nodup_flatMap.mpr + constructor + · intro k _ + apply List.nodup_ofFn.mpr + intro a b hab + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using hab + · apply List.pairwise_ofFn.mpr + intro i j hij + apply List.disjoint_left.mpr + intro a ha hb + obtain ⟨u,hu⟩ := List.mem_ofFn.mp ha + obtain ⟨v,hv⟩ := List.mem_ofFn.mp hb + have he : i = j := congrArg Sigma.fst (hu.trans hv.symm) + exact (Fin.ne_of_lt hij) he + +noncomputable def maskLength (h : ℕ) (p : ℕ → ℕ → ℕ) (R M : ℕ) : ℕ → ℕ + | 0 => M + | l+1 => (R*period h p (l+1))*((maskTags h p (l+1)).length*maskLength h p R M l) + +@[simp] theorem length_maskWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : MaskState h p M l) : (maskWord h p R M l v).length = maskLength h p R M l := by + induction l with + | zero => + have he := maskWord.eq_1 h p R M v + dsimp only [MaskState] at v + dsimp only [MaskAlphabet] at he + have hh := congrArg (@List.length Bool) he + simp only [List.length_map, List.bind_eq_flatMap, List.pure_def, ← List.map_eq_flatMap, + List.length_range] at hh + exact hh + | succ l ih => + change ((List.range (R*period h p (l+1))).flatMap (fun a => + taggedRow (maskTags h p (l+1)) (fun j => maskWord h p R M l + (shiftMaskState h p M l (v j) (maskGamma h p M (l+1) a j))))).length = _ + rw [length_flatMap_uniform _ _ ((maskTags h p (l+1)).length*maskLength h p R M l)] + · simp [maskLength] + · intro a _ + apply length_flatMap_uniform + intro j _ + simp [ih] + +@[simp] theorem shiftMaskState_zero (h : ℕ) (p : ℕ → ℕ → ℕ) (M l : ℕ) + (v : MaskState h p M l) : shiftMaskState h p M l v 0 = v := by + induction l with + | zero => change ZMod M at v; exact add_zero v + | succ l ih => funext j; exact ih (v j) + +theorem shiftMaskState_add (h : ℕ) (p : ℕ → ℕ → ℕ) (M l : ℕ) + (v : MaskState h p M l) (a b : ZMod M) : + shiftMaskState h p M l (shiftMaskState h p M l v a) b = + shiftMaskState h p M l v (a+b) := by + induction l with + | zero => change ZMod M at v; exact add_assoc v a b + | succ l ih => funext j; exact ih (v j) + +theorem shiftMaskState_change_base (h : ℕ) (p : ℕ → ℕ → ℕ) (M l : ℕ) + (v : MaskState h p M l) (θ a b : ZMod M) : + shiftMaskState h p M l (shiftMaskState h p M l v θ) b = + shiftMaskState h p M l (shiftMaskState h p M l v a) (θ+b-a) := by + rw [shiftMaskState_add, shiftMaskState_add] + congr 1 + abel + +def maskRow (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : MaskState h p M (l+1)) (a : ℕ) : List (MaskAlphabet h p (l+1)) := + taggedRow (maskTags h p (l+1)) (fun j => maskWord h p R M l + (shiftMaskState h p M l (v j) (maskGamma h p M (l+1) a j))) + +@[simp] theorem length_maskRow (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : MaskState h p M (l+1)) (a : ℕ) : + (maskRow h p R M l v a).length = (maskTags h p (l+1)).length*maskLength h p R M l := by + change (MaskTag h p (l+1) → MaskState h p M l) at v + change (taggedRow (maskTags h p (l+1)) (fun j => maskWord h p R M l + (shiftMaskState h p M l (v j) (maskGamma h p M (l+1) a j)))).length = _ + unfold taggedRow + apply length_flatMap_uniform + intro j _ + rw [List.length_map, length_maskWord] + +theorem segment_maskWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : MaskState h p M (l+1)) (a : Fin (R*period h p (l+1))) : + segment (maskWord h p R M (l+1) v) + (a.val*((maskTags h p (l+1)).length*maskLength h p R M l)) + ((maskTags h p (l+1)).length*maskLength h p R M l) = maskRow h p R M l v a := by + have he := segment_flatMap_uniform (List.range (R*period h p (l+1))) + (maskRow h p R M l v) _ (fun a _ => length_maskRow h p R M l v a) + ⟨a.val, by simp⟩ + change segment ((List.range (R*period h p (l+1))).flatMap (maskRow h p R M l v)) _ _ = _ + simpa only [List.get_eq_getElem, List.getElem_range] using he + +theorem tag_get_maskWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : MaskState h p M (l+1)) (hL : 0 < maskLength h p R M l) + (ht : 0 < (maskTags h p (l+1)).length) + (k : Fin (maskWord h p R M (l+1) v).length) : + (maskTags h p (l+1)).idxOf ((maskWord h p R M (l+1) v).get k).1 = + (k.val/maskLength h p R M l)%(maskTags h p (l+1)).length := by + classical + exact tag_get_rows _ (nodup_maskTags h p (l+1)) _ hL ht + (fun _ _ _ _ => length_maskWord ..) k + + theorem fin_orderEmbedding_lower {q n : ℕ} (e : Fin q ↪o Fin n) (i : Fin q) : + i.val ≤ (e i).val := by + cases q with + | zero => exact Fin.elim0 i + | succ q => + induction i using Fin.induction with + | zero => exact Nat.zero_le _ + | succ i ih => + have he := e.strictMono (Fin.castSucc_lt_succ (i := i)) + change (e i.castSucc).val < (e i.succ).val at he + simpa only [Fin.val_succ, Fin.val_castSucc, Nat.succ_eq_add_one] using (Nat.succ_le_of_lt (ih.trans_lt he)) + + theorem fin_orderEmbedding_upper {q n : ℕ} (e : Fin q ↪o Fin n) (i : Fin q) : + (e i).val ≤ i.val+(n-q) := by + let r : Fin q ↪o Fin n := OrderEmbedding.ofStrictMono (fun j => (e j.rev).rev) (by + intro a b hab + exact Fin.rev_lt_rev.mpr (e.strictMono (Fin.rev_lt_rev.mpr hab))) + have h := fin_orderEmbedding_lower r i.rev + change i.rev.val ≤ n-((e i.rev.rev).val+1) at h + simp only [Fin.rev_rev, Fin.val_rev] at h + have hqn : q ≤ n := by simpa using Fintype.card_le_of_injective e e.injective + have hi := i.isLt + have hei := (e i).isLt + omega + + theorem threshold_neighborhood_card {n : ℕ} (t E : ℕ) : + (Finset.univ.filter (fun i : Fin n => t ≤ i.val+E ∧ i.val < t+E)).card ≤ 2*E := by + classical + have hc : (Finset.univ.filter (fun i : Fin n => t ≤ i.val+E ∧ i.val < t+E)).card ≤ + (Finset.Ico (t-E) (t+E)).card := by + apply Finset.card_le_card_of_injOn Fin.val + · intro i hi + have hi := (Finset.mem_filter.mp hi).2 + exact Finset.mem_Ico.mpr ⟨by omega, hi.2⟩ + · intro i _ j _ hij + exact Fin.ext hij + rw [Nat.card_Ico] at hc + omega + +theorem hamming_le_five_deficit {n : ℕ} (f g : Fin n → Bool) (t u : ℕ) + (hg : ∀ i j : Fin n, g i ≠ g j → + (i.val < t ∧ t ≤ j.val) ∨ (j.val < t ∧ t ≤ i.val) ∨ + (i.val < u ∧ u ≤ j.val) ∨ (j.val < u ∧ u ≤ i.val)) : + (Finset.univ.filter (fun i => f i ≠ g i)).card ≤ + 5*deficit (List.ofFn f) (List.ofFn g) := by + classical + obtain ⟨A⟩ := exists_lcs_matching (List.ofFn f) (List.ofFn g) + let q := lcs (List.ofFn f) (List.ofFn g) + let E := n-q + let L : Fin q ↪o Fin n := A.left.trans (Fin.castOrderIso (List.length_ofFn)).toOrderEmbedding + let R : Fin q ↪o Fin n := A.right.trans (Fin.castOrderIso (List.length_ofFn)).toOrderEmbedding + have hletters (i : Fin q) : f (L i) = g (R i) := by + change f (Fin.cast (List.length_ofFn) (A.left i)) = g (Fin.cast (List.length_ofFn) (A.right i)) + simpa only [List.get_ofFn] using A.letters i + have hdisp (i : Fin q) : (L i).val ≤ (R i).val+E ∧ (R i).val ≤ (L i).val+E := by + have hl := fin_orderEmbedding_lower L i + have hu := fin_orderEmbedding_upper L i + have hl' := fin_orderEmbedding_lower R i + have hu' := fin_orderEmbedding_upper R i + exact ⟨by omega, by omega⟩ + let U := Finset.univ \ (Finset.univ.image L) + let B (a : ℕ) := Finset.univ.filter (fun i : Fin n => a ≤ i.val+E ∧ i.val < a+E) + have hUC : U.card = E := by + dsimp [U, E] + rw [Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_image_of_injective _ L.injective] + simp + have hsub : Finset.univ.filter (fun i => f i ≠ g i) ⊆ U ∪ (B t ∪ B u) := by + intro i hi + have hd := (Finset.mem_filter.mp hi).2 + by_cases hu : i ∈ U + · exact Finset.mem_union_left _ hu + · have him : i ∈ Finset.univ.image L := by simpa [U] using hu + obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp him + have hg' : g (L k) ≠ g (R k) := by rw [← hletters]; exact Ne.symm hd + have hc := hg (L k) (R k) hg' + have hm := hdisp k + apply Finset.mem_union_right + rcases hc with hc | hc | hc | hc + · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, by omega⟩) + · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, by omega⟩) + · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, by omega⟩) + · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, by omega⟩) + have hc := (Finset.card_le_card hsub).trans (Finset.card_union_le U (B t ∪ B u)) + have hb := Finset.card_union_le (B t) (B u) + have ht := threshold_neighborhood_card (n := n) t E + have hu := threshold_neighborhood_card (n := n) u E + change (B t).card ≤ 2*E at ht + change (B u).card ≤ 2*E at hu + have hde : deficit (List.ofFn f) (List.ofFn g) = E := by simp [deficit, E, q] + rw [hde] + omega + +def halfBit {M : ℕ} (v b : ZMod M) : Bool := decide ((b-v).val < M/2) + + theorem zmod_val_sub_cases {M : ℕ} [NeZero M] (b v : ZMod M) : + (b-v).val = if v.val ≤ b.val then b.val-v.val else M+b.val-v.val := by + split_ifs with h + · exact ZMod.val_sub h + · have hlt : b.val < v.val := by omega + have hv : v ≠ 0 := by intro he; simp [he] at h + rw [sub_eq_add_neg, ZMod.val_add, ZMod.neg_val, ite_eq_right hv] + have hb := b.val_lt + have hv' := v.val_lt + rw [Nat.mod_eq_of_lt (by omega)] + omega + + theorem halfBit_interval {M : ℕ} [NeZero M] (he : M = 2*(M/2)) (v b : ZMod M) : + halfBit v b = if v.val ≤ M/2 then + decide (v.val ≤ b.val ∧ b.val < v.val+M/2) + else decide (b.val < v.val-M/2 ∨ v.val ≤ b.val) := by + unfold halfBit + rw [zmod_val_sub_cases] + split_ifs with h h' <;> apply Bool.eq_iff_iff.mpr <;> simp only [decide_eq_true_eq] <;> + have hv := v.val_lt <;> have hb := b.val_lt <;> omega + + theorem halfBit_thresholds {M : ℕ} [NeZero M] (he : M = 2*(M/2)) (v : ZMod M) : + ∀ i j : Fin M, halfBit v (i.val : ZMod M) ≠ halfBit v (j.val : ZMod M) → + (i.val < v.val ∧ v.val ≤ j.val) ∨ (j.val < v.val ∧ v.val ≤ i.val) ∨ + (i.val < (v.val+M/2)%M ∧ (v.val+M/2)%M ≤ j.val) ∨ + (j.val < (v.val+M/2)%M ∧ (v.val+M/2)%M ≤ i.val) := by + intro i j hij + rw [halfBit_interval he, halfBit_interval he] at hij + simp only [ZMod.val_natCast, Nat.mod_eq_of_lt i.isLt, Nat.mod_eq_of_lt j.isLt] at hij + by_cases hv : v.val < M/2 + · rw [ite_eq_left (by omega), ite_eq_left (by omega)] at hij + rw [Nat.mod_eq_of_lt (by omega : v.val+M/2 < M)] + have hh : ¬ ((v.val ≤ i.val ∧ i.val < v.val+M/2) ↔ + (v.val ≤ j.val ∧ j.val < v.val+M/2)) := by simpa only [ne_eq, decide_eq_decide] using hij + omega + · have hmod : (v.val+M/2)%M = v.val-M/2 := by + have hval := v.val_lt + have hh : v.val+M/2 = (v.val-M/2)+M := by omega + rw [hh, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] + rw [hmod] + by_cases hv' : v.val = M/2 + · rw [ite_eq_left (by omega), ite_eq_left (by omega), hv'] at hij + have hi := i.isLt; have hj := j.isLt + have hh : ¬ ((M/2 ≤ i.val ∧ i.val < M/2+M/2) ↔ + (M/2 ≤ j.val ∧ j.val < M/2+M/2)) := by simpa only [ne_eq, decide_eq_decide] using hij + omega + · rw [ite_eq_right (by omega), ite_eq_right (by omega)] at hij + have hh : ¬ ((i.val < v.val-M/2 ∨ v.val ≤ i.val) ↔ + (j.val < v.val-M/2 ∨ v.val ≤ j.val)) := by simpa only [ne_eq, decide_eq_decide] using hij + omega + +noncomputable def halfHamming {M : ℕ} [NeZero M] (v w : ZMod M) : ℕ := + (Finset.univ.filter (fun b : ZMod M => halfBit v b ≠ halfBit w b)).card + + theorem halfHamming_symm {M : ℕ} [NeZero M] (v w : ZMod M) : + halfHamming v w = halfHamming w v := by + unfold halfHamming + congr 1 + ext b + simp only [Finset.mem_filter, Finset.mem_univ, true_and, ne_comm] + + theorem halfHamming_translate {M : ℕ} [NeZero M] (v w a : ZMod M) : + halfHamming (v+a) (w+a) = halfHamming v w := by + classical + unfold halfHamming + apply Finset.card_bij (fun b _ => b-a) + · intro b hb + have hb := (Finset.mem_filter.mp hb).2 + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _, ?_⟩ + simpa only [halfBit, sub_add_eq_sub_sub, sub_right_comm] using hb + · intro b _ c _ hbc + exact sub_left_injective hbc + · intro b hb + refine ⟨b+a, ?_, by simp⟩ + have hb := (Finset.mem_filter.mp hb).2 + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _, ?_⟩ + simpa only [halfBit, add_sub_add_right_eq_sub] using hb + + theorem halfHamming_zero_neg {M : ℕ} [NeZero M] (v : ZMod M) : + halfHamming 0 (-v) = halfHamming 0 v := by + have h := halfHamming_translate (0 : ZMod M) (-v) v + simp only [zero_add, neg_add_cancel] at h + exact h.symm.trans (halfHamming_symm _ _) + + theorem halfHamming_zero_small {M : ℕ} [NeZero M] (he : M = 2*(M/2)) + (v : ZMod M) (hv : v.val ≤ M/2) : halfHamming 0 v = 2*v.val := by + classical + let D := Finset.univ.filter (fun b : ZMod M => halfBit 0 b ≠ halfBit v b) + have hmem (b : ZMod M) : b ∈ D ↔ b.val < v.val ∨ (M/2 ≤ b.val ∧ b.val < M/2+v.val) := by + simp only [D, Finset.mem_filter, Finset.mem_univ, true_and] + rw [halfBit_interval he, halfBit_interval he, ite_eq_left hv] + simp only [ZMod.val_zero, Nat.zero_le, ite_true, zero_add, true_and] + have hb := b.val_lt + simp only [ne_eq, decide_eq_decide] + omega + let f : Bool × Fin v.val → ZMod M := fun a => ((if a.1 then M/2 else 0)+a.2.val : ℕ) + have hfval (a : Bool × Fin v.val) : (f a).val = (if a.1 then M/2 else 0)+a.2.val := by + change (((if a.1 then M/2 else 0)+a.2.val : ℕ) : ZMod M).val = _ + rw [ZMod.val_natCast, Nat.mod_eq_of_lt] + cases a with | mk t b => cases t <;> simp only [Bool.false_eq_true, ↓reduceIte, zero_add] <;> omega + have hcard : (Finset.univ : Finset (Bool × Fin v.val)).card = D.card := by + apply Finset.card_bij (fun a _ => f a) + · intro a _ + rw [hmem, hfval] + cases a with | mk t b => cases t <;> simp only [Bool.false_eq_true, ↓reduceIte, zero_add] <;> omega + · intro a _ b _ hab + have hab' := congrArg ZMod.val hab + rw [hfval, hfval] at hab' + rcases a with ⟨ta,ia⟩ + rcases b with ⟨tb,ib⟩ + have hi := ia.isLt + have hj := ib.isLt + cases ta <;> cases tb <;> simp only [Bool.false_eq_true, ↓reduceIte, zero_add] at hab' + · exact Prod.ext rfl (Fin.ext hab') + · omega + · omega + · exact Prod.ext rfl (Fin.ext (Nat.add_left_cancel hab')) + · intro b hb + rw [hmem] at hb + rcases hb with hb | hb + · refine ⟨(false,⟨b.val,hb⟩), Finset.mem_univ _, ?_⟩ + apply ZMod.val_injective + rw [hfval] + simp + · refine ⟨(true,⟨b.val-M/2, by omega⟩), Finset.mem_univ _, ?_⟩ + apply ZMod.val_injective + rw [hfval] + simp only [↓reduceIte] + omega + simpa [halfHamming, D] using hcard.symm + + theorem halfHamming_eq {M : ℕ} [NeZero M] (he : M = 2*(M/2)) + (v w : ZMod M) : halfHamming v w = 2*(w-v).valMinAbs.natAbs := by + have ht : halfHamming v w = halfHamming 0 (w-v) := by + have hh := halfHamming_translate v w (-v) + simpa only [add_neg_cancel, ← sub_eq_add_neg] using hh.symm + rw [ht] + by_cases h : (w-v).val ≤ M/2 + · rw [halfHamming_zero_small he _ h, ZMod.valMinAbs_def_pos, ite_eq_left h, Int.natAbs_natCast] + · have hh : (-(w-v)).val ≤ M/2 := by + rw [ZMod.neg_val, ite_eq_right] + · have hv := (w-v).val_lt + omega + · intro hz + simp [hz] at h + rw [← halfHamming_zero_neg (w-v), halfHamming_zero_small he _ hh] + have ha : (-(w-v)).valMinAbs.natAbs = (-(w-v)).val := by + rw [ZMod.valMinAbs_def_pos, ite_eq_left hh, Int.natAbs_natCast] + rw [← ha, ZMod.natAbs_valMinAbs_neg] + + theorem halfHamming_fin {M : ℕ} [NeZero M] (v w : ZMod M) : + (Finset.univ.filter (fun i : Fin M => halfBit v (i.val : ZMod M) ≠ + halfBit w (i.val : ZMod M))).card = halfHamming v w := by + classical + unfold halfHamming + apply Finset.card_bij (fun b _ => (b.val : ZMod M)) + · intro b hb + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hb).2⟩ + · intro b _ c _ hbc + have hh := congrArg ZMod.val hbc + simp only [ZMod.val_natCast, Nat.mod_eq_of_lt b.isLt, Nat.mod_eq_of_lt c.isLt] at hh + exact Fin.ext hh + · intro b hb + refine ⟨⟨b.val,b.val_lt⟩, ?_, ZMod.natCast_zmod_val b⟩ + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hb ⊢ + simpa only [ZMod.natCast_zmod_val] using hb + + theorem maskWord_zero_eq {h M R : ℕ} {p : ℕ → ℕ → ℕ} (v : ZMod M) : + maskWord h p R M 0 v = List.ofFn (fun i : Fin M => halfBit v (i.val : ZMod M)) := by + have he := maskWord.eq_1 h p R M v + dsimp only [MaskState, MaskAlphabet] at he + refine he.trans ?_ + simp only [List.bind_eq_flatMap, List.pure_def, ← List.map_eq_flatMap, List.map_map] + apply List.ext_getElem + · simp + · intro i hi hj + simp [Function.comp_def, halfBit] + + theorem halfCircle_separation {M : ℕ} [NeZero M] (he : M = 2*(M/2)) + (v θ : ZMod M) : + (M:ℝ)*circleCost θ/4 ≤ + (deficit (List.ofFn (fun i : Fin M => halfBit v (i.val : ZMod M))) + (List.ofFn (fun i : Fin M => halfBit (v+θ) (i.val : ZMod M))) : ℝ) := by + have hh := hamming_le_five_deficit + (fun i : Fin M => halfBit v (i.val : ZMod M)) + (fun i : Fin M => halfBit (v+θ) (i.val : ZMod M)) + (v+θ).val (((v+θ).val+M/2)%M) (halfBit_thresholds he (v+θ)) + rw [halfHamming_fin, halfHamming_eq he, add_sub_cancel_left] at hh + have hr : 2*(θ.valMinAbs.natAbs : ℝ) ≤ 5* + (deficit (List.ofFn (fun i : Fin M => halfBit v (i.val : ZMod M))) + (List.ofFn (fun i : Fin M => halfBit (v+θ) (i.val : ZMod M))) : ℝ) := by exact_mod_cast hh + have hM : (M:ℝ) ≠ 0 := by exact_mod_cast NeZero.ne M + rw [circleCost, mul_div_cancel₀ _ hM] + nlinarith [Nat.cast_nonneg (α := ℝ) θ.valMinAbs.natAbs] + +noncomputable def subcircle {M p : ℕ} (hp : p ∣ M) : ZMod p →+ ZMod M := + ZMod.lift p ⟨(AddMonoidHom.mulRight (M/p : ZMod M)).comp (Int.castAddHom _), by + change ((p : ℤ) : ZMod M) * ((M/p : ℕ) : ZMod M) = 0 + rw [Int.cast_natCast, ← Nat.cast_mul, Nat.mul_div_cancel' hp] + simp⟩ + +@[simp] theorem subcircle_natCast {M p : ℕ} (hp : p ∣ M) (a : ℕ) : + subcircle hp (a : ZMod p) = (M/p : ZMod M)*(a : ZMod M) := by + have he := ZMod.lift_coe p + ⟨(AddMonoidHom.mulRight (M/p : ZMod M)).comp (Int.castAddHom _), by + change ((p : ℤ) : ZMod M) * ((M/p : ℕ) : ZMod M) = 0 + rw [Int.cast_natCast, ← Nat.cast_mul, Nat.mul_div_cancel' hp] + simp⟩ (a : ℤ) + simpa [subcircle, Int.castAddHom, mul_comm] using he + +@[simp] theorem subcircle_val {M p : ℕ} [NeZero p] (hp : p ∣ M) (a : ZMod p) : + subcircle hp a = ((M/p*a.val : ℕ) : ZMod M) := by + conv_lhs => rw [← ZMod.natCast_zmod_val a] + rw [subcircle_natCast] + simp + + theorem subcircle_injective {M p : ℕ} [NeZero M] [NeZero p] (hp : p ∣ M) : + Function.Injective (subcircle hp) := by + apply (injective_iff_map_eq_zero (subcircle hp)).mpr + intro a ha + rw [subcircle_val] at ha + have hd := (ZMod.natCast_eq_zero_iff (M/p*a.val) M).mp ha + have hM : M/p*p = M := Nat.div_mul_cancel hp + have hpos : 0 < M/p := Nat.div_pos (Nat.le_of_dvd (NeZero.pos M) hp) (NeZero.pos p) + have hd' : p ∣ a.val := by + exact (Nat.mul_dvd_mul_iff_left hpos).mp (show M/p*p ∣ M/p*a.val by simpa only [hM] using hd) + have haz := Nat.eq_zero_of_dvd_of_lt hd' a.val_lt + exact (ZMod.val_eq_zero a).mp haz + +theorem add_ne_zero_of_coprime_orders {G : Type*} [AddCommGroup G] {x y : G} + {q r : ℕ} (hc : q.Coprime r) (hx : x ≠ 0) (hq : q • x = 0) (hr : r • y = 0) : + x+y ≠ 0 := by + intro h + have he : y = -x := eq_neg_of_add_eq_zero_left (by simpa only [add_comm] using h) + rw [he, smul_neg, neg_eq_zero] at hr + have hq' := addOrderOf_dvd_of_nsmul_eq_zero hq + have hr' := addOrderOf_dvd_of_nsmul_eq_zero hr + have ho : addOrderOf x = 1 := Nat.dvd_one.mp (hc ▸ Nat.dvd_gcd hq' hr') + exact hx (AddMonoid.addOrderOf_eq_one_iff.mp ho) + +namespace PhaseCost +variable {G : Type*} [AddCommGroup G] + +theorem sub_le (f : PhaseCost G) (x y : G) : f (x-y) ≤ f x+f y := by + simpa only [sub_eq_add_neg, f.neg] using f.add_le x (-y) + +theorem le_pair (f : PhaseCost G) (x d : G) : f d ≤ f x+f (x+d) := by + have h := f.sub_le (x+d) x + simpa only [add_sub_cancel_left, add_comm] using h + +theorem grid_pair_bound (f : PhaseCost G) {p : ℕ} [NeZero p] + (φ : ZMod p →+ G) (x : G) : + (p : ℝ)*f (φ 1) ≤ 2*∑ b : ZMod p, f (x+φ b) := by + have hpairs := Finset.sum_le_sum (s := Finset.univ) + (fun (b : ZMod p) _ => f.le_pair (x+φ b) (φ 1)) + have hs : ∑ b : ZMod p, f (x+φ b+φ 1) = ∑ b : ZMod p, f (x+φ b) := by + simpa only [Equiv.coe_addRight, map_add, add_assoc] using + Equiv.sum_comp (Equiv.addRight (1 : ZMod p)) (fun b => f (x+φ b)) + simpa only [Finset.sum_const, Finset.card_univ, ZMod.card, nsmul_eq_mul, + Finset.sum_add_distrib, hs, two_mul] using hpairs + +theorem prime_grid_bound (f : PhaseCost G) {p : ℕ} [NeZero p] (hp : p.Prime) + (φ : ZMod p →+ G) (x : G) (z : ZMod p) (hz : z ≠ 0) : + (p : ℝ)*f (φ 1) ≤ 2*∑ b : ZMod p, f (x+b.val • φ z) := by + let : Fact p.Prime := ⟨hp⟩ + have hs : ∑ b : ZMod p, f (x+b.val • φ z) = ∑ b : ZMod p, f (x+φ b) := by + have he (b : ZMod p) : b.val • φ z = φ (b*z) := by + rw [← map_nsmul, nsmul_eq_mul, ZMod.natCast_zmod_val] + simp_rw [he] + exact Equiv.sum_comp (Equiv.mulRight₀ z hz) (fun b => f (x+φ b)) + rw [hs] + exact f.grid_pair_bound φ x + +end PhaseCost + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Codes.lean b/lean/OAI/Combinatorics/FiniteCircle/Codes.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ae1b8aeeab764d128ae2511a305fa840cab8981 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Codes.lean @@ -0,0 +1,176 @@ +import OAI.Combinatorics.FiniteCircle.RandomCodes + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +theorem StrongLocal.anchorLocal {α : Type*} {w : ℕ} {c : α → Fin w → Bool} + (hc : StrongLocal c) : AnchorLocal (1/1048576) c := by + intro a b is js his hjs hlen hsize hli hlj hbits + apply hc a b is js his hjs hlen + · have hh : (w : ℝ) ≤ 16*is.length := by nlinarith + exact_mod_cast hh + · convert hli using 1; ring + · convert hlj using 1; ring + · exact hbits + +@[simp] theorem length_interval {α : Type*} {w : ℕ} (c : α → Fin w → Bool) + (a : α) {s u : ℕ} (hs : s+u ≤ w) : (interval c a s u).length = u := by + simp only [interval, List.length_take, List.length_drop, List.length_ofFn] + omega + +theorem get_interval {α : Type*} {w : ℕ} (c : α → Fin w → Bool) + (a : α) {s u : ℕ} (hs : s+u ≤ w) (i : Fin (interval c a s u).length) : + (interval c a s u).get i = c a ⟨s+i.val, by + have hi := i.isLt + simp only [length_interval c a hs] at hi + omega⟩ := by + change (((List.ofFn (c a)).drop s).take u)[i.val] = _ + simp only [List.getElem_take, List.getElem_drop, List.getElem_ofFn] + +theorem indexSpan_ofFn_le {w q s u : ℕ} (f : Fin q → Fin w) + (hb : ∀ i, s ≤ (f i).val ∧ (f i).val < s+u) : indexSpan (List.ofFn f) ≤ u := by + by_cases hq : 0 < q + · rw [indexSpan_ofFn f hq] + obtain ⟨hl, _⟩ := hb ⟨0, hq⟩ + obtain ⟨_, hh⟩ := hb ⟨q-1, by omega⟩ + omega + · have he : q = 0 := by omega + subst q + simp [indexSpan] + +theorem StrongLocal.offsetLocal {α : Type*} {w : ℕ} {c : α → Fin w → Bool} + (hc : StrongLocal c) (hw : 0 < w) (hd : 8 ∣ w) : OffsetLocal (1/1048576) c := by + intro a b hab s t hs ht + let u := w/8 + let q := lcs (interval c a s u) (interval c b t u) + have hsu : s+u ≤ w := hs + have htu : t+u ≤ w := ht + have hqu : q ≤ u := by simpa only [length_interval c a hsu] using lcs_le_length_left (interval c a s u) (interval c b t u) + have huw : u*8 = w := Nat.div_mul_cancel hd + by_contra hn + have hn : (1-(1:ℝ)/1048576)*(u : ℝ) < q := lt_of_not_ge hn + have hqpos : 0 < q := by + have hu : (0 : ℝ) < u := by exact_mod_cast (by omega : 0 < u) + have hqr : (0 : ℝ) < q := by nlinarith + exact_mod_cast hqr + obtain ⟨M⟩ := exists_lcs_matching (interval c a s u) (interval c b t u) + let f : Fin q → Fin w := fun i => ⟨s+(M.left i).val, by + have hh := (M.left i).isLt + simp only [length_interval c a hsu] at hh + omega⟩ + let g : Fin q → Fin w := fun i => ⟨t+(M.right i).val, by + have hh := (M.right i).isLt + simp only [length_interval c b htu] at hh + omega⟩ + have hf : StrictMono f := by + intro i j hij + have hh := M.left.strictMono hij + change s+(M.left i).val < s+(M.left j).val + exact Nat.add_lt_add_left hh s + have hg : StrictMono g := by + intro i j hij + have hh := M.right.strictMono hij + change t+(M.right i).val < t+(M.right j).val + exact Nat.add_lt_add_left hh t + have his : (List.ofFn f).Pairwise (fun i j => i.val < j.val) := by + apply List.pairwise_iff_get.mpr + intro i j hij + simpa only [List.get_ofFn, Fin.lt_def] using hf (show (Fin.cast List.length_ofFn i) < Fin.cast List.length_ofFn j from hij) + have hjs : (List.ofFn g).Pairwise (fun i j => i.val < j.val) := by + apply List.pairwise_iff_get.mpr + intro i j hij + simpa only [List.get_ofFn, Fin.lt_def] using hg (show (Fin.cast List.length_ofFn i) < Fin.cast List.length_ofFn j from hij) + have hsize : w ≤ 16*(List.ofFn f).length := by + rw [List.length_ofFn] + have hur : (u : ℝ)*8 = w := by exact_mod_cast huw + have hqr : (w : ℝ) ≤ 16*q := by nlinarith + exact_mod_cast hqr + have hdef : ((u-q : ℕ) : ℝ) ≤ (w : ℝ)/1048576 := by + rw [Nat.cast_sub hqu] + have hur : (u : ℝ)*8 = w := by exact_mod_cast huw + nlinarith + have hli : ((indexSpan (List.ofFn f) - (List.ofFn f).length : ℕ) : ℝ) ≤ (w : ℝ)/1048576 := by + have hh : indexSpan (List.ofFn f) ≤ u := indexSpan_ofFn_le (s := s) (u := u) f (fun i => by + dsimp only [f] + have hi := (M.left i).isLt + simp only [length_interval c a hsu] at hi + omega) + rw [List.length_ofFn] + exact (Nat.cast_le.mpr (Nat.sub_le_sub_right hh q)).trans hdef + have hlj : ((indexSpan (List.ofFn g) - (List.ofFn g).length : ℕ) : ℝ) ≤ (w : ℝ)/1048576 := by + have hh : indexSpan (List.ofFn g) ≤ u := indexSpan_ofFn_le (s := t) (u := u) g (fun i => by + dsimp only [g] + have hi := (M.right i).isLt + simp only [length_interval c b htu] at hi + omega) + rw [List.length_ofFn] + exact (Nat.cast_le.mpr (Nat.sub_le_sub_right hh q)).trans hdef + have hbits : ∀ ij ∈ (List.ofFn f).zip (List.ofFn g), c a ij.1 = c b ij.2 := by + intro ij hij + rw [zip_ofFn] at hij + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp hij + have hh := M.letters i + rw [get_interval c a hsu, get_interval c b htu] at hh + exact hh + exact hab (hc a b (List.ofFn f) (List.ofFn g) his hjs (by simp) hsize hli hlj hbits).1 + +theorem strongLocal_substitutionBounds {α : Type*} [Fintype α] {w : ℕ} + {c : α → Fin w → Bool} (hw : 0 < w) + (hwidth : (w : ℝ) ≤ 67108928*Real.log (2*Fintype.card α)) (hc : StrongLocal c) : + SubstitutionBounds (1/2097152) 67108928 c := by + refine ⟨hw, hwidth, ?_, editDistance_encode_le c⟩ + intro L x y hx hy + refine ⟨?_, deficit_encode_le c x y⟩ + have hh := anchor_deficit_lower hw (by norm_num : (0 : ℝ) ≤ 1/1048576) + (by norm_num : (1 : ℝ)/1048576 ≤ 1/10) hc.anchorLocal x y (hx.trans hy.symm) + convert hh using 1; norm_num + +theorem SubstitutionBounds.weaken {α : Type*} [Fintype α] {w : ℕ} + {c : α → Fin w → Bool} {a b C : ℝ} (hc : SubstitutionBounds a C c) + (hba : b ≤ a) : SubstitutionBounds b C c := by + refine ⟨hc.1,hc.2.1,?_,hc.2.2.2⟩ + intro L x y hx hy + obtain ⟨hl,hu⟩ := hc.2.2.1 L x y hx hy + refine ⟨?_,hu⟩ + exact (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hba + (Nat.cast_nonneg w)) (Nat.cast_nonneg (deficit x y))).trans hl + +theorem offsetLocal_substitutionBounds {α : Type*} [Fintype α] {w : ℕ} + {c : α → Fin w → Bool} (hw : 12 ≤ w) (hd : 8 ∣ w) + (hwidth : (w : ℝ) ≤ 67108928 * Real.log (2*Fintype.card α)) + (hc : OffsetLocal (1/1048576) c) : SubstitutionBounds (1/268435456) 67108928 c := by + refine ⟨by omega,hwidth,?_,editDistance_encode_le c⟩ + intro L x y hx hy + refine ⟨?_,deficit_encode_le c x y⟩ + have he : (8 : ℝ)*(w/8 : ℕ) = w := by exact_mod_cast (Nat.mul_div_cancel' hd) + have hw0 : (0 : ℝ) < w := by exact_mod_cast (show 0 hp.positive l k) + + theorem StandingPrimes.half_fresh {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2 ≤ h) (l : ℕ) (hl : l ≤ h) : LowerFresh h p l {2} := by + intro j hj hjl k hk + have ht := (hp.atLevel j hj (hjl.trans hl) k).2.1 + have hh3 := Nat.pow_le_pow_left hh 3 + simp only [Finset.mem_singleton] at hk + omega + + theorem mask_long_deficit {n : ℕ} (hn : 1000000 ≤ n) (he : n^4=2*(n^4/2)) + {p : ℕ → ℕ → ℕ} (hp : StandingPrimes (n^4) p) {R : ℕ} (hR : 0 (hp.atLevel j hj hjh k).1) + (fun j hj hjh k => (hp.atLevel j hj hjh k).2.1.le) + (fun j hj hjh k => (hp.atLevel j hj hjh k).2.2) hp.level_distinct + h (le_refl _) {2} ((M/2:ℕ) : ZMod M) (by simp; omega) + (by intro q hq; simp only [Finset.mem_singleton] at hq; subst q + exact ⟨Nat.prime_two, (show 2≤h by omega).trans (le_self_pow₀ (by omega) (by norm_num))⟩) + (hp.half_fresh (by omega) h (le_refl _)) + (halfturn_ne_zero (StandingPrimes.circle_even (h:=h) (p:=p))) + (halfturn_supported (StandingPrimes.circle_even (h:=h) (p:=p))) + simp only [Finset.card_singleton] at hbound + have hsep := mask_separation (StandingPrimes.circle_even (h:=h) (p:=p)) (by omega : 0 (hp.atLevel j hj hjh k).1) + (fun j hj hjh k => by + have ht := ((hp.excludedPrimes (by omega)).2.2 ⟨j-1,by omega⟩ k).2 + simpa only [show j-1+1=j by omega] using ht) hp.level_injective hp.level_distinct + h (le_refl _) {2} ((M/2:ℕ) : ZMod M) (by simp; omega) + (by intro q hq; simp only [Finset.mem_singleton] at hq; subst q + exact ⟨Nat.prime_two, (show 2≤h by omega).trans (le_self_pow₀ (by omega) (by norm_num))⟩) + (hp.half_fresh (by omega) h (le_refl _)) + (halfturn_ne_zero (StandingPrimes.circle_even (h:=h) (p:=p))) + (halfturn_supported (StandingPrimes.circle_even (h:=h) (p:=p))) + simp only [Finset.card_singleton] at hbound + have hsep := excluded_separation (StandingPrimes.circle_even (h:=h) (p:=p)) (by omega : 0 by simp; omega) h v ((M/2:ℕ) : ZMod M) + have hnum := excluded_descent_numeric hn he + have hL : (0:ℝ) ≤ excludedLength h p R M h := by positivity + have hc : (0:ℝ) ≤ 1/((2:ℝ)^h*4) := by positivity + calc + _ = (excludedLength h p R M h:ℝ)*(1/(n:ℝ)^(3*h)) := by dsimp [h,M]; ring + _ ≤ (excludedLength h p R M h:ℝ)*((1/((2:ℝ)^h*4))*pairDescentBound h (h/100) (n^3) n 1 h) := + mul_le_mul_of_nonneg_left hnum hL + _ ≤ (1/((2:ℝ)^h*4))*(excludedLength h p R M h)*excludedCost h p M hp.divides_circle hp.positive h ((M/2:ℕ) : ZMod M) := by + nlinarith [mul_le_mul_of_nonneg_left hbound (mul_nonneg hL hc)] + _ ≤ _ := hsep + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Distortion.lean b/lean/OAI/Combinatorics/FiniteCircle/Distortion.lean new file mode 100644 index 0000000000000000000000000000000000000000..90933f1770e7822d2fc1c080359b7272e2c28777 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Distortion.lean @@ -0,0 +1,271 @@ +import OAI.Combinatorics.FiniteCircle.Translations + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +noncomputable def upperRates {α X : Type*} (word : X → List α) (f : X → RealL1) : Set ℝ := + {r | ∃ x y : X, x ≠ y ∧ r = ‖f x-f y‖/(editDistance (word x) (word y):ℝ)} +noncomputable def lowerRates {α X : Type*} (word : X → List α) (f : X → RealL1) : Set ℝ := + {r | ∃ x y : X, x ≠ y ∧ r = (editDistance (word x) (word y):ℝ)/‖f x-f y‖} + + theorem upperRates_finite {α X : Type*} [Finite X] (word : X → List α) (f : X → RealL1) : + (upperRates word f).Finite := by + apply (Set.finite_range (fun z : X×X => ‖f z.1-f z.2‖/(editDistance (word z.1) (word z.2):ℝ))).subset + rintro r ⟨x,y,_,rfl⟩ + exact ⟨(x,y),rfl⟩ + + theorem lowerRates_finite {α X : Type*} [Finite X] (word : X → List α) (f : X → RealL1) : + (lowerRates word f).Finite := by + apply (Set.finite_range (fun z : X×X => (editDistance (word z.1) (word z.2):ℝ)/‖f z.1-f z.2‖)).subset + rintro r ⟨x,y,_,rfl⟩ + exact ⟨(x,y),rfl⟩ + + theorem distortion_nonneg {α X : Type*} (word : X → List α) (f : X → RealL1) : + 0 ≤ distortion word f := by + apply mul_nonneg + · apply Real.sSup_nonneg + rintro r ⟨x,y,_,rfl⟩ + positivity + · apply Real.sSup_nonneg + rintro r ⟨x,y,_,rfl⟩ + positivity + + theorem finite_l1_embedding (X : Type*) [Fintype X] : ∃ f : X → RealL1, Function.Injective f := by + classical + let e : X → ℕ := fun x => (Fintype.equivFin X x).val + have he : Function.Injective e := fun x y h => (Fintype.equivFin X).injective (Fin.ext h) + refine ⟨fun x => lp.single 1 (e x) (1:ℝ), ?_⟩ + intro x y h + by_contra hxy + have hne : e x ≠ e y := fun h => hxy (he h) + have ht := congrArg (fun f : RealL1 => f (e x)) h + simp only [lp.single_apply_self, lp.single_apply, Pi.single_eq_of_ne hne] at ht + norm_num at ht + + theorem optimalDistortion_nonneg {α X : Type*} (word : X → List α) : 0 ≤ optimalDistortion word := by + apply Real.sInf_nonneg + rintro D ⟨f,_,rfl⟩ + exact distortion_nonneg word f + + theorem optimalDistortion_lower {α X : Type*} [Fintype X] (word : X → List α) (D : ℝ) + (hD : ∀ f : X → RealL1, Function.Injective f → D ≤ distortion word f) : + D ≤ optimalDistortion word := by + apply le_csInf + · obtain ⟨f,hf⟩ := finite_l1_embedding X + exact ⟨distortion word f,f,hf,rfl⟩ + · rintro b ⟨f,hf,rfl⟩ + exact hD f hf + + theorem optimalDistortion_le {α X : Type*} (word : X → List α) + (f : X → RealL1) (hf : Function.Injective f) : + optimalDistortion word ≤ distortion word f := by + apply csInf_le + · refine ⟨0,?_⟩ + rintro b ⟨g,_,rfl⟩ + exact distortion_nonneg word g + · exact ⟨f,hf,rfl⟩ + + theorem distortion_control {α X : Type*} [Finite X] [Nontrivial X] + (word : X → List α) (hw : Function.Injective word) + (f : X → RealL1) (hf : Function.Injective f) : + ∃ A B : ℝ, 0 hxy (hw (editDistance_eq_zero.mp he))) + have hn (x y : X) (hxy : x ≠ y) : 0<‖f x-f y‖ := norm_pos_iff.mpr (sub_ne_zero.mpr (fun he => hxy (hf he))) + obtain ⟨x,y,hxy⟩ := exists_pair_ne X + have ha : ‖f x-f y‖/(editDistance (word x) (word y):ℝ) ≤ A := + le_csSup (upperRates_finite word f).bddAbove ⟨x,y,hxy,rfl⟩ + have hb : (editDistance (word x) (word y):ℝ)/‖f x-f y‖ ≤ B := + le_csSup (lowerRates_finite word f).bddAbove ⟨x,y,hxy,rfl⟩ + refine ⟨A,B,(div_pos (hn x y hxy) (hED x y hxy)).trans_le ha, + (div_pos (hED x y hxy) (hn x y hxy)).trans_le hb,rfl,?_,?_⟩ + · intro x y + by_cases hxy : x=y + · subst y; simp + · exact (div_le_iff₀ (hED x y hxy)).mp (le_csSup (upperRates_finite word f).bddAbove ⟨x,y,hxy,rfl⟩) + · intro x y + by_cases hxy : x=y + · subst y; simp + · exact (div_le_iff₀ (hn x y hxy)).mp (le_csSup (lowerRates_finite word f).bddAbove ⟨x,y,hxy,rfl⟩) + + theorem distortion_upper {α X : Type*} [Nontrivial X] + (word : X → List α) (hw : Function.Injective word) + (f : X → RealL1) (A B : ℝ) (hA : 0≤A) + (hu : ∀ x y, ‖f x-f y‖ ≤ A*(editDistance (word x) (word y):ℝ)) + (hl : ∀ x y, (editDistance (word x) (word y):ℝ) ≤ B*‖f x-f y‖) : + Function.Injective f ∧ distortion word f ≤ A*B := by + have hf : Function.Injective f := by + intro x y he + have hwxy := hl x y + rw [he,sub_self,norm_zero,mul_zero] at hwxy + have ht : editDistance (word x) (word y)=0 := by exact_mod_cast (le_antisymm hwxy (by positivity)) + exact hw (editDistance_eq_zero.mp ht) + refine ⟨hf,?_⟩ + obtain ⟨x,y,hxy⟩ := exists_pair_ne X + have hune : (upperRates word f).Nonempty := ⟨_,x,y,hxy,rfl⟩ + have hlne : (lowerRates word f).Nonempty := ⟨_,x,y,hxy,rfl⟩ + have hU : sSup (upperRates word f) ≤ A := by + apply csSup_le hune + rintro r ⟨x,y,hxy,rfl⟩ + have hed : (0:ℝ) hxy (hw (editDistance_eq_zero.mp he))) + exact (div_le_iff₀ hed).mpr (hu x y) + have hL : sSup (lowerRates word f) ≤ B := by + apply csSup_le hlne + rintro r ⟨x,y,hxy,rfl⟩ + have hn : 0<‖f x-f y‖ := norm_pos_iff.mpr (sub_ne_zero.mpr (fun he => hxy (hf he))) + exact (div_le_iff₀ hn).mpr (hl x y) + apply mul_le_mul hU hL + · apply Real.sSup_nonneg + rintro r ⟨x,y,_,rfl⟩ + positivity + · exact hA + +noncomputable def finiteL1 (M : ℕ) (v : Fin M → ℝ) : RealL1 := + ∑ i, lp.single 1 i.val (v i) + + theorem finiteL1_sub (M : ℕ) (v w : Fin M → ℝ) : + finiteL1 M v-finiteL1 M w=finiteL1 M (v-w) := by + unfold finiteL1 + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i _ + exact (lp.single_sub (E:=fun _ : ℕ=>ℝ) 1 i.val (v i) (w i)).symm + + theorem finiteL1_norm (M : ℕ) (v : Fin M → ℝ) : ‖finiteL1 M v‖=∑ i, |v i| := by + classical + let g : ℕ → ℝ := fun i => if hi : iℝ) (p:=1) (by norm_num) g (Finset.range M) + simpa [g,← Fin.sum_univ_eq_sum_range] using ht + + theorem finiteL1_norm_sub (M : ℕ) (v w : Fin M → ℝ) : + ‖finiteL1 M v-finiteL1 M w‖=∑ i, |v i-w i| := by + rw [finiteL1_sub,finiteL1_norm] + rfl + + theorem dyadic_expected_budget {I : Type*} [Fintype I] [DecidableEq I] + {M : ℕ} [NeZero M] (f : (I → ZMod M) → RealL1) + (A u L copies : ℝ) (hcL : L=(M:ℝ)*Fintype.card I*copies) + (hrsingle : ∀ (i : I) (j : Fin (Nat.log 2 M+1)), + (𝔼 v, ‖f (v+Pi.single i ((2^j.val:ℕ):ZMod M))-f v‖) ≤ A*(u*2*copies*(2:ℝ)^j.val)) + : (∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + (𝔼 v, ‖f (v+Pi.single i ((2^j.val:ℕ):ZMod M))-f v‖)) ≤ + A*u*2*L*(Nat.log 2 M+1:ℕ) := by + classical + calc + _ ≤ ∑ i : I, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val*(A*(u*2*copies*(2:ℝ)^j.val)) := by + apply Finset.sum_le_sum + intro i _ + apply Finset.sum_le_sum + intro j _ + exact mul_le_mul_of_nonneg_left (hrsingle i j) (by positivity) + _ = ∑ _i : I, ∑ _j : Fin (Nat.log 2 M+1), (M:ℝ)*A*u*2*copies := by + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + field_simp + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]; rw [hcL]; ring + + theorem fourier_edit_distortion {I α : Type*} [Fintype I] [DecidableEq I] + {M : ℕ} [NeZero M] (H : AddSubgroup (I → ZMod M)) [Fintype H] + (w : I → ZMod M) (B : ℝ) (hB : 0 x.val) := by + classical + let X := Set.range W + let : Fintype X := (Set.finite_range W).fintype + have hw0 : W 0 ≠ W w := by + intro he + have ht := hlong 0 + simp only [zero_add, ← he,editDistance_self,Nat.cast_zero] at ht + exact (mul_pos hδ hL).not_ge ht + let : Nontrivial X := ⟨⟨⟨W 0,⟨0,rfl⟩⟩,⟨W w,⟨w,rfl⟩⟩,fun he => hw0 (congrArg Subtype.val he)⟩⟩ + apply optimalDistortion_lower + intro f hf + obtain ⟨A,A',hA,hA',hD,hu,hl⟩ := distortion_control (fun x : X => x.val) Subtype.val_injective f hf + let F := fun v => f (⟨W v,⟨v,rfl⟩⟩ : X) + have hcontrolu (v z : I → ZMod M) : ‖F (v+z)-F v‖ ≤ A*(editDistance (W v) (W (v+z)):ℝ) := by + rw [norm_sub_rev] + exact hu ⟨W v,⟨v,rfl⟩⟩ ⟨W (v+z),⟨v+z,rfl⟩⟩ + have hcontroll (v z : I → ZMod M) : (editDistance (W v) (W (v+z)):ℝ) ≤ A'*‖F (v+z)-F v‖ := by + rw [norm_sub_rev] + exact hl ⟨W v,⟨v,rfl⟩⟩ ⟨W (v+z),⟨v+z,rfl⟩⟩ + have ht := fourier_edit_distortion H w B hB hb W h R L copies u δ hL hcL hcheap hsingle hlong + F A A' hA.le hA'.le hcontrolu hcontroll + rw [hD] + exact hnum (A*A') (mul_nonneg hA.le hA'.le) ht + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/DyadicShifts.lean b/lean/OAI/Combinatorics/FiniteCircle/DyadicShifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a8a1af7cd9c62d4408b5ed144d250c570d9a643 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/DyadicShifts.lean @@ -0,0 +1,243 @@ +import OAI.Combinatorics.FiniteCircle.Fourier + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem character_multiplier (G : Type*) [AddCommGroup G] [Fintype G] + (χ : AddChar G ℂ) (x : G) : Complex.normSq (1-χ x) = 2-2*(χ x).re := by + rw [Complex.normSq_sub, Complex.normSq_eq_norm_sq (χ x), χ.norm_apply] + norm_num + + theorem character_multiplier_le_four {G : Type*} [AddCommGroup G] [Fintype G] + (χ : AddChar G ℂ) (x : G) : Complex.normSq (1-χ x) ≤ 4 := by + rw [character_multiplier] + have h := ((abs_le.mp (Complex.abs_re_le_norm (χ x))).1) + rw [χ.norm_apply] at h + linarith + + theorem character_subgroup_mean {G : Type*} [AddCommGroup G] [Fintype G] + (H : AddSubgroup G) [Fintype H] (χ : AddChar G ℂ) + (hn : χ.compAddMonoidHom H.subtype ≠ 0) : + (𝔼 x : H, Complex.normSq (1-χ x)) = 2 := by + classical + have hz := (AddChar.expect_eq_zero_iff_ne_zero (ψ := χ.compAddMonoidHom H.subtype)).mpr hn + have hr : (𝔼 x : H, (χ x).re) = 0 := by + have := congrArg Complex.re hz + simpa only [Fintype.expect_eq_sum_div_card, Complex.div_ofReal_re, + Complex.re_sum, Complex.zero_re, AddChar.compAddMonoidHom_apply, + AddSubgroup.subtype_apply, ← Complex.ofReal_natCast] using this + simp_rw [character_multiplier] + rw [Finset.expect_sub_distrib, ← Finset.mul_expect, hr] + simp + + theorem zmod_character_int {M : ℕ} [NeZero M] (a b : ℤ) : + (AddChar.zmodAddEquiv (a : ZMod M)) (b : ZMod M) = + Complex.exp ((2*Real.pi*((a:ℝ)*b/M):ℝ)*Complex.I) := by + change ((AddChar.zmod M (a : ZMod M) (b : ZMod M) : Circle) : ℂ) = _ + rw [AddChar.zmod_intCast, Circle.coe_exp] + + theorem zmod_character_mul {M : ℕ} [NeZero M] (x y : ZMod M) : + AddChar.zmodAddEquiv x y = AddChar.zmodAddEquiv (x*y) 1 := by + change ((AddChar.zmod M x y : Circle) : ℂ) = ((AddChar.zmod M (x*y) 1 : Circle) : ℂ) + simp only [AddChar.zmod, AddChar.compAddMonoidHom_apply, AddMonoidHom.comp_apply, + AddMonoidHom.coe_mulLeft, mul_one] + + theorem zmod_character_one_injective {M : ℕ} [NeZero M] : + Function.Injective (fun x : ZMod M => AddChar.zmodAddEquiv x 1) := by + intro x y h + dsimp only at h + apply AddChar.zmodAddEquiv.injective + apply AddChar.ext + intro a + obtain ⟨b,rfl⟩ := ZMod.natCast_zmod_surjective a + have hx (z : ZMod M) : AddChar.zmodAddEquiv z (b : ZMod M) = + (AddChar.zmodAddEquiv z 1)^b := by + rw [← nsmul_one (n := b), AddChar.map_nsmul_eq_pow] + rw [hx, hx, h] + + theorem zmod_character_eq_one {M : ℕ} [NeZero M] (x y : ZMod M) : + AddChar.zmodAddEquiv x y = 1 ↔ x*y = 0 := by + rw [zmod_character_mul] + have hz : AddChar.zmodAddEquiv (0 : ZMod M) 1 = 1 := by + rw [map_zero]; rfl + rw [← hz] + exact zmod_character_one_injective.eq_iff + + theorem circle_character_re {M : ℕ} [NeZero M] (x : ZMod M) (a : ℕ) : + (AddChar.zmodAddEquiv x (a : ZMod M)).re = + Real.cos (2*Real.pi*((x.valMinAbs.natAbs:ℝ)*a/M)) := by + have he := zmod_character_int (M := M) x.valMinAbs (a:ℤ) + simp only [ZMod.coe_valMinAbs, Int.cast_natCast] at he + rw [he, Complex.exp_re] + simp only [Complex.mul_re, Complex.ofReal_re, Complex.I_re, mul_zero, + Complex.ofReal_im, Complex.I_im, sub_self, Real.exp_zero, + Complex.mul_im, mul_one, add_zero, one_mul] + have habs : (x.valMinAbs.natAbs:ℝ) = |(x.valMinAbs:ℝ)| := by + rw [Nat.cast_natAbs, Int.cast_abs] + by_cases hx : 0 ≤ x.valMinAbs + · rw [habs, abs_of_nonneg (by exact_mod_cast hx)] + · have hx' : (x.valMinAbs:ℝ) ≤ 0 := by exact_mod_cast (le_of_lt (lt_of_not_ge hx)) + rw [habs, abs_of_nonpos hx'] + rw [show 2*Real.pi*(-(x.valMinAbs:ℝ)*a/M) = -(2*Real.pi*((x.valMinAbs:ℝ)*a/M)) by ring, + Real.cos_neg] + +theorem dyadic_detect {M : ℕ} [NeZero M] (x : ZMod M) (hx : x ≠ 0) : + ∃ j < Nat.log 2 M+1, + 4*(x.valMinAbs.natAbs:ℝ) ≤ + (M:ℝ)/(2:ℝ)^j * Complex.normSq (1-AddChar.zmodAddEquiv x ((2^j : ℕ):ZMod M)) := by + have hM : (0:ℝ) < M := by exact_mod_cast NeZero.pos M + have hn : 0 < x.valMinAbs.natAbs := by + apply Nat.pos_of_ne_zero + simpa [ZMod.valMinAbs_eq_zero] using hx + have hnR : (0:ℝ) < x.valMinAbs.natAbs := by exact_mod_cast hn + have hle : 2*x.valMinAbs.natAbs ≤ M := by have := ZMod.natAbs_valMinAbs_le x; omega + have hleR : 2*(x.valMinAbs.natAbs:ℝ) ≤ M := by exact_mod_cast hle + obtain ⟨j,hj,hj'⟩ := exists_nat_pow_near + ((le_div_iff₀ (by positivity : (0:ℝ)<2*x.valMinAbs.natAbs)).mpr (by simpa using hleR)) + (show (1:ℝ)<2 by norm_num) + have hp : (0:ℝ) < (2:ℝ)^j := by positivity + have hn1 : (1:ℝ) ≤ x.valMinAbs.natAbs := by exact_mod_cast hn + have hpow : (2:ℝ)^j ≤ M := by + have := (le_div_iff₀ (by positivity : (0:ℝ)<2*x.valMinAbs.natAbs)).mp hj + nlinarith + have hjlog : j < Nat.log 2 M+1 := by + have hpN : 2^j ≤ M := by exact_mod_cast hpow + have := Nat.le_log_of_pow_le (by norm_num : 1<2) hpN + omega + refine ⟨j,hjlog,?_⟩ + have ha : 1/4 < (x.valMinAbs.natAbs:ℝ)*(2:ℝ)^j/M := by + rw [div_lt_iff₀ (by positivity : (0:ℝ)<2*x.valMinAbs.natAbs), pow_succ] at hj' + rw [lt_div_iff₀ hM] + nlinarith + have hb : (x.valMinAbs.natAbs:ℝ)*(2:ℝ)^j/M ≤ 1/2 := by + have := (le_div_iff₀ (by positivity : (0:ℝ)<2*x.valMinAbs.natAbs)).mp hj + rw [div_le_iff₀ hM] + nlinarith + have hcos : Real.cos (2*Real.pi*((x.valMinAbs.natAbs:ℝ)*(2:ℝ)^j/M)) ≤ 0 := + Real.cos_nonpos_of_pi_div_two_le_of_le (by nlinarith [Real.pi_pos]) + (by nlinarith [Real.pi_pos]) + have hc : 2 ≤ Complex.normSq (1-AddChar.zmodAddEquiv x ((2^j : ℕ):ZMod M)) := by + rw [character_multiplier, circle_character_re] + push_cast + linarith + have hq : 2*(x.valMinAbs.natAbs:ℝ) ≤ (M:ℝ)/(2:ℝ)^j := by + rw [le_div_iff₀ hp] + have := (le_div_iff₀ (by positivity : (0:ℝ)<2*x.valMinAbs.natAbs)).mp hj + nlinarith + nlinarith [div_nonneg hM.le hp.le] + +noncomputable def coordinateChar {I : Type*} [DecidableEq I] {M : ℕ} + (χ : AddChar (I → ZMod M) ℂ) (i : I) : AddChar (ZMod M) ℂ := + χ.compAddMonoidHom (AddMonoidHom.single (fun _ : I => ZMod M) i) + +noncomputable def coordinateFrequency {I : Type*} [DecidableEq I] {M : ℕ} [NeZero M] + (χ : AddChar (I → ZMod M) ℂ) (i : I) : ZMod M := + AddChar.zmodAddEquiv.symm (coordinateChar χ i) + + theorem character_single {I : Type*} [DecidableEq I] {M : ℕ} [NeZero M] + (χ : AddChar (I → ZMod M) ℂ) (i : I) (a : ZMod M) : + χ (Pi.single i a) = AddChar.zmodAddEquiv (coordinateFrequency χ i) a := by + rw [coordinateFrequency, AddEquiv.apply_symm_apply] + rfl + +theorem coordinate_dyadic_sum {I : Type*} [Fintype I] [DecidableEq I] {M : ℕ} [NeZero M] + (χ : AddChar (I → ZMod M) ℂ) : + 4*(∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ)) ≤ + ∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + Complex.normSq (1-χ (Pi.single i ((2^j.val : ℕ):ZMod M))) := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + by_cases hx : coordinateFrequency χ i = 0 + · simp only [hx, ZMod.valMinAbs_zero, Int.natAbs_zero, Nat.cast_zero, mul_zero] + exact Finset.sum_nonneg (fun j _ => mul_nonneg (by positivity) (Complex.normSq_nonneg _)) + · obtain ⟨j,hj,hd⟩ := dyadic_detect (coordinateFrequency χ i) hx + rw [← character_single] at hd + apply hd.trans + exact Finset.single_le_sum (f := fun j : Fin (Nat.log 2 M+1) => + (M:ℝ)/(2:ℝ)^j.val * Complex.normSq (1-χ (Pi.single i ((2^j.val:ℕ):ZMod M)))) + (fun j _ => mul_nonneg (by positivity) (Complex.normSq_nonneg _)) + (Finset.mem_univ (⟨j,hj⟩ : Fin (Nat.log 2 M+1))) + +theorem weighted_character_inequality {I : Type*} [Fintype I] [DecidableEq I] + {M : ℕ} [NeZero M] (H : AddSubgroup (I → ZMod M)) [Fintype H] + (w : I → ZMod M) (B : ℝ) (hB : 0 < B) + (hb : ∀ χ : AddChar (I → ZMod M) ℂ, + χ.compAddMonoidHom H.subtype = 0 → χ w ≠ 1 → + B ≤ ∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ)) + (χ : AddChar (I → ZMod M) ℂ) : + Complex.normSq (1-χ w) ≤ + 2*(𝔼 c : H, Complex.normSq (1-χ c)) + (1/B)* + ∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + Complex.normSq (1-χ (Pi.single i ((2^j.val : ℕ):ZMod M))) := by + have hs : 0 ≤ ∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + Complex.normSq (1-χ (Pi.single i ((2^j.val : ℕ):ZMod M))) := by + exact Finset.sum_nonneg (fun i _ => Finset.sum_nonneg (fun j _ => + mul_nonneg (by positivity) (Complex.normSq_nonneg _))) + have hc : 0 ≤ (𝔼 c : H, Complex.normSq (1-χ c)) := + Finset.expect_nonneg (fun c _ => Complex.normSq_nonneg _) + by_cases ht : χ.compAddMonoidHom H.subtype = 0 + · by_cases hw : χ w = 1 + · simp only [hw, sub_self, map_zero] + positivity + · have hm := coordinate_dyadic_sum χ + have hmass := hb χ ht hw + have hm' : 4*B ≤ ∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + Complex.normSq (1-χ (Pi.single i ((2^j.val : ℕ):ZMod M))) := by linarith + have hdiv : 4 ≤ (1/B)*∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + Complex.normSq (1-χ (Pi.single i ((2^j.val : ℕ):ZMod M))) := by + rw [one_div_mul_eq_div, le_div_iff₀ hB] + exact hm' + have hfour := character_multiplier_le_four χ w + linarith + · rw [character_subgroup_mean H χ ht] + have hfour := character_multiplier_le_four χ w + have hnn := mul_nonneg (le_of_lt (one_div_pos.mpr hB)) hs + linarith + + theorem weighted_l1_inequality {I : Type*} [Fintype I] [DecidableEq I] + {M : ℕ} [NeZero M] (H : AddSubgroup (I → ZMod M)) [Fintype H] + (w : I → ZMod M) (B : ℝ) (hB : 0 < B) + (hb : ∀ χ : AddChar (I → ZMod M) ℂ, + χ.compAddMonoidHom H.subtype = 0 → χ w ≠ 1 → + B ≤ ∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ)) + (f : (I → ZMod M) → RealL1) : + (𝔼 v, ‖f (v+w)-f v‖) ≤ + 2*(𝔼 c : H, 𝔼 v, ‖f (v+c)-f v‖) + (1/B)* + ∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + (𝔼 v, ‖f (v+Pi.single i ((2^j.val : ℕ):ZMod M))-f v‖) := by + classical + let a : H ⊕ (I × Fin (Nat.log 2 M+1)) → (I → ZMod M) := + Sum.elim (fun c => c) (fun ij => Pi.single ij.1 ((2^ij.2.val : ℕ):ZMod M)) + let q : H ⊕ (I × Fin (Nat.log 2 M+1)) → ℝ := + Sum.elim (fun _ => 2/(Fintype.card H)) (fun ij => (1/B)*((M:ℝ)/(2:ℝ)^ij.2.val)) + have he (D : (I → ZMod M) → ℝ) : (∑ t, q t * D (a t)) = + 2*(𝔼 c : H, D c) + (1/B)* + ∑ i, ∑ j : Fin (Nat.log 2 M+1), (M:ℝ)/(2:ℝ)^j.val * + D (Pi.single i ((2^j.val : ℕ):ZMod M)) := by + simp only [Fintype.sum_sum_type, q, a, Sum.elim_inl, Sum.elim_inr, + Fintype.sum_prod_type, Fintype.expect_eq_sum_div_card] + rw [← Finset.mul_sum] + congr 1 + · ring + · simp_rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + have hs (χ : AddChar (I → ZMod M) ℂ) : Complex.normSq (1-χ w) ≤ + ∑ t, q t * Complex.normSq (1-χ (a t)) := by + rw [he (fun x => Complex.normSq (1-χ x))] + exact weighted_character_inequality H w B hB hb χ + have h := spectral_l1_inequality w a q hs f + rwa [he (fun t => 𝔼 v, ‖f (v+t)-f v‖)] at h + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Edit.lean b/lean/OAI/Combinatorics/FiniteCircle/Edit.lean new file mode 100644 index 0000000000000000000000000000000000000000..985712bdb6aff974985a202c187e019d69adf5e3 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Edit.lean @@ -0,0 +1,524 @@ +import OAI.Combinatorics.FiniteCircle.Model + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +namespace EditStep +variable {α β : Type*} {x y : List α} + +theorem symm (h : EditStep x y) : EditStep y x := by + cases h with + | insert u v a => exact .delete u v a + | delete u v a => exact .insert u v a + | substitute u v a b => exact .substitute u v b a + +theorem append_left (h : EditStep x y) (u : List α) : EditStep (u ++ x) (u ++ y) := by + cases h with + | insert p q a => simpa only [List.append_assoc] using EditStep.insert (u ++ p) q a + | delete p q a => simpa only [List.append_assoc] using EditStep.delete (u ++ p) q a + | substitute p q a b => + simpa only [List.append_assoc] using EditStep.substitute (u ++ p) q a b + +theorem append_right (h : EditStep x y) (v : List α) : EditStep (x ++ v) (y ++ v) := by + cases h with + | insert p q a => simpa only [List.append_assoc, List.cons_append] using EditStep.insert p (q ++ v) a + | delete p q a => simpa only [List.append_assoc, List.cons_append] using EditStep.delete p (q ++ v) a + | substitute p q a b => + simpa only [List.append_assoc, List.cons_append] using EditStep.substitute p (q ++ v) a b + +theorem map (h : EditStep x y) (f : α → β) : EditStep (x.map f) (y.map f) := by + cases h with + | insert u v a => simpa using EditStep.insert (u.map f) (v.map f) (f a) + | delete u v a => simpa using EditStep.delete (u.map f) (v.map f) (f a) + | substitute u v a b => simpa using EditStep.substitute (u.map f) (v.map f) (f a) (f b) +end EditStep + +namespace EditScript +variable {α β : Type*} {n m : ℕ} {x y z : List α} + +theorem one (h : EditStep x y) : EditScript 1 x y := .cons h (.nil y) + +theorem trans (h : EditScript n x y) (g : EditScript m y z) : EditScript (n + m) x z := by + induction h with + | nil => simpa using g + | cons h _ ih => simpa only [Nat.add_right_comm] using EditScript.cons h (ih g) + +theorem symm (h : EditScript n x y) : EditScript n y x := by + induction h with + | nil x => exact .nil x + | cons h _ ih => exact ih.trans (one h.symm) + +theorem append_left (h : EditScript n x y) (u : List α) : EditScript n (u ++ x) (u ++ y) := by + induction h with + | nil => exact .nil _ + | cons h _ ih => exact .cons (h.append_left u) ih + +theorem append_right (h : EditScript n x y) (v : List α) : EditScript n (x ++ v) (y ++ v) := by + induction h with + | nil => exact .nil _ + | cons h _ ih => exact .cons (h.append_right v) ih + +theorem map (h : EditScript n x y) (f : α → β) : EditScript n (x.map f) (y.map f) := by + induction h with + | nil => exact .nil _ + | cons h _ ih => exact .cons (h.map f) ih + +theorem deleteAll (x : List α) : EditScript x.length x [] := by + induction x with + | nil => exact .nil [] + | cons a x ih => exact .cons (.delete [] x a) ih + +theorem insertAll (x : List α) : EditScript x.length [] x := (deleteAll x).symm + +theorem exists_script (x y : List α) : ∃ n, EditScript n x y := + ⟨x.length + y.length, (deleteAll x).trans (insertAll y)⟩ + +theorem of_sublist {z x : List α} (h : z <+ x) : EditScript (x.length - z.length) x z := by + induction h with + | slnil => exact .nil [] + | @cons l₁ l₂ a h ih => + have hl := h.length_le + simpa only [List.nil_append, List.length_cons, show l₂.length + 1 - l₁.length = l₂.length - l₁.length + 1 by omega] + using EditScript.cons (EditStep.delete [] l₂ a) ih + | cons_cons a h ih => + simpa using ih.append_left [a] + +theorem of_length_eq {x y : List α} (h : x.length = y.length) : EditScript x.length x y := by + induction x generalizing y with + | nil => + have : y = [] := List.length_eq_zero_iff.mp h.symm + subst y + exact .nil [] + | cons a x ih => + cases y with + | nil => simp at h + | cons b y => + have ht : x.length = y.length := by simpa using h + exact .cons (.substitute [] x a b) ((ih ht).append_left [b]) +end EditScript + +theorem editDistance_spec {α : Type*} (x y : List α) : EditScript (editDistance x y) x y := by + exact csInf_mem (EditScript.exists_script x y) + +theorem editDistance_le_of_script {α : Type*} {x y : List α} {n : ℕ} (h : EditScript n x y) : + editDistance x y ≤ n := csInf_le (OrderBot.bddBelow _) h + +@[simp] theorem editDistance_self {α : Type*} (x : List α) : editDistance x x = 0 := + Nat.eq_zero_of_le_zero (editDistance_le_of_script (.nil x)) + +@[simp] theorem editDistance_eq_zero {α : Type*} {x y : List α} : editDistance x y = 0 ↔ x = y := by + constructor + · intro h + have hs := editDistance_spec x y + rw [h] at hs + cases hs + rfl + · rintro rfl + exact editDistance_self x + +theorem editDistance_symm {α : Type*} (x y : List α) : editDistance x y = editDistance y x := by + apply Nat.le_antisymm + · exact editDistance_le_of_script (editDistance_spec y x).symm + · exact editDistance_le_of_script (editDistance_spec x y).symm + +theorem editDistance_triangle {α : Type*} (x y z : List α) : + editDistance x z ≤ editDistance x y + editDistance y z := + editDistance_le_of_script ((editDistance_spec x y).trans (editDistance_spec y z)) + +theorem editDistance_map_le {α β : Type*} (f : α → β) (x y : List α) : + editDistance (x.map f) (y.map f) ≤ editDistance x y := + editDistance_le_of_script ((editDistance_spec x y).map f) + +theorem editDistance_map_eq {α β : Type*} (f : α → β) (g : β → α) (hg : Function.LeftInverse g f) + (x y : List α) : editDistance (x.map f) (y.map f) = editDistance x y := by + apply Nat.le_antisymm (editDistance_map_le f x y) + have hgf : ∀ a, g (f a) = a := hg + simpa [List.map_map, Function.comp_def, hgf] using + editDistance_map_le g (x.map f) (y.map f) + +@[simp] theorem encode_nil {α : Type*} {w : ℕ} (c : α → Fin w → Bool) : encode c [] = [] := rfl +@[simp] theorem encode_cons {α : Type*} {w : ℕ} (c : α → Fin w → Bool) (a : α) (x : List α) : + encode c (a :: x) = List.ofFn (c a) ++ encode c x := rfl +@[simp] theorem encode_append {α : Type*} {w : ℕ} (c : α → Fin w → Bool) (x y : List α) : + encode c (x ++ y) = encode c x ++ encode c y := List.flatMap_append +@[simp] theorem length_encode {α : Type*} {w : ℕ} (c : α → Fin w → Bool) (x : List α) : + (encode c x).length = w * x.length := by + induction x with + | nil => simp + | cons a x ih => simp [ih, Nat.mul_add, Nat.add_comm] + +theorem EditStep.encode_script {α : Type*} {w : ℕ} (c : α → Fin w → Bool) {x y : List α} + (h : EditStep x y) : EditScript w (encode c x) (encode c y) := by + cases h with + | insert u v a => + simpa only [encode_append, encode_cons, List.length_ofFn, List.nil_append, List.append_assoc] using + ((EditScript.insertAll (List.ofFn (c a))).append_right (encode c v)).append_left (encode c u) + | delete u v a => + simpa only [encode_append, encode_cons, List.length_ofFn, List.nil_append, List.append_assoc] using + ((EditScript.deleteAll (List.ofFn (c a))).append_right (encode c v)).append_left (encode c u) + | substitute u v a b => + simpa only [encode_append, encode_cons, List.length_ofFn, List.append_assoc] using + ((EditScript.of_length_eq (x := List.ofFn (c a)) (y := List.ofFn (c b)) (by simp)).append_right + (encode c v)).append_left (encode c u) + +theorem EditScript.encode_script {α : Type*} {w n : ℕ} (c : α → Fin w → Bool) {x y : List α} + (h : EditScript n x y) : EditScript (w * n) (encode c x) (encode c y) := by + induction h with + | nil => simp only [Nat.mul_zero]; exact .nil _ + | @cons n x y z h _ ih => + simpa only [Nat.mul_add, Nat.mul_one, Nat.add_comm] using (h.encode_script c).trans ih + +theorem editDistance_encode_le {α : Type*} {w : ℕ} (c : α → Fin w → Bool) (x y : List α) : + editDistance (encode c x) (encode c y) ≤ w * editDistance x y := + editDistance_le_of_script ((editDistance_spec x y).encode_script c) + +theorem lcs_exists {α : Type*} (x y : List α) : + ∃ z : List α, z <+ x ∧ z <+ y ∧ z.length = lcs x y := by + let s := {n : ℕ | ∃ z : List α, z <+ x ∧ z <+ y ∧ z.length = n} + have hs : s.Nonempty := ⟨0, [], List.nil_sublist _, List.nil_sublist _, rfl⟩ + have hf : s.Finite := (Set.finite_Iic x.length).subset (by + rintro n ⟨z, hx, _, rfl⟩ + exact hx.length_le) + exact hs.csSup_mem hf + +theorem le_lcs {α : Type*} {x y z : List α} (hx : z <+ x) (hy : z <+ y) : + z.length ≤ lcs x y := by + apply le_csSup + · refine ⟨x.length, ?_⟩ + rintro n ⟨u, hu, _, rfl⟩ + exact hu.length_le + · exact ⟨z, hx, hy, rfl⟩ + +theorem lcs_le_length_left {α : Type*} (x y : List α) : lcs x y ≤ x.length := by + obtain ⟨z, hx, _, hz⟩ := lcs_exists x y + rw [← hz] + exact hx.length_le + +theorem lcs_le_length_right {α : Type*} (x y : List α) : lcs x y ≤ y.length := by + obtain ⟨z, _, hy, hz⟩ := lcs_exists x y + rw [← hz] + exact hy.length_le + +theorem lcs_symm {α : Type*} (x y : List α) : lcs x y = lcs y x := by + apply Nat.le_antisymm + · obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + rw [← hz] + exact le_lcs hy hx + · obtain ⟨z, hy, hx, hz⟩ := lcs_exists y x + rw [← hz] + exact le_lcs hx hy + +@[simp] theorem lcs_self {α : Type*} (x : List α) : lcs x x = x.length := + Nat.le_antisymm (lcs_le_length_left _ _) (le_lcs (List.Sublist.refl _) (List.Sublist.refl _)) + +@[simp] theorem lcs_nil_left {α : Type*} (x : List α) : lcs [] x = 0 := + Nat.eq_zero_of_le_zero (lcs_le_length_left _ _) + +@[simp] theorem lcs_nil_right {α : Type*} (x : List α) : lcs x [] = 0 := + Nat.eq_zero_of_le_zero (lcs_le_length_right _ _) + +theorem lcs_mono {α : Type*} {x y x' y' : List α} (hx : x <+ x') (hy : y <+ y') : + lcs x y ≤ lcs x' y' := by + obtain ⟨z, hz, hw, heq⟩ := lcs_exists x y + rw [← heq] + exact le_lcs (hz.trans hx) (hw.trans hy) + +theorem lcs_encode_ge {α : Type*} {w : ℕ} (c : α → Fin w → Bool) (x y : List α) : + w * lcs x y ≤ lcs (encode c x) (encode c y) := by + obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + rw [← hz] + have he := + le_lcs (hx.flatMap (fun a => List.ofFn (c a))) (hy.flatMap (fun a => List.ofFn (c a))) + change (encode c z).length ≤ lcs (encode c x) (encode c y) at he + simpa only [length_encode] using he + +theorem deficit_encode_le {α : Type*} {w : ℕ} (c : α → Fin w → Bool) (x y : List α) : + deficit (encode c x) (encode c y) ≤ w * deficit x y := by + simp only [deficit, length_encode] + calc + w * x.length - lcs (encode c x) (encode c y) ≤ w * x.length - w * lcs x y := + Nat.sub_le_sub_left (lcs_encode_ge c x y) _ + _ = w * (x.length - lcs x y) := (Nat.mul_sub _ _ _).symm + +theorem sublist_common_large {α : Type*} {x y z : List α} (hx : x <+ z) (hy : y <+ z) : + ∃ u : List α, u <+ x ∧ u <+ y ∧ x.length + y.length ≤ u.length + z.length := by + induction z generalizing x y with + | nil => + have : x = [] := List.sublist_nil.mp hx + have : y = [] := List.sublist_nil.mp hy + subst x; subst y + exact ⟨[], .slnil, .slnil, le_rfl⟩ + | cons a z ih => + cases hx with + | cons _ hx => + cases hy with + | cons _ hy => + obtain ⟨u, hux, huy, hlen⟩ := ih hx hy + exact ⟨u, hux, huy, by simp only [List.length_cons]; omega⟩ + | cons_cons _ hy => + obtain ⟨u, hux, huy, hlen⟩ := ih hx hy + exact ⟨u, hux, huy.cons a, by simp only [List.length_cons]; omega⟩ + | cons_cons _ hx => + cases hy with + | cons _ hy => + obtain ⟨u, hux, huy, hlen⟩ := ih hx hy + exact ⟨u, hux.cons a, huy, by simp only [List.length_cons]; omega⟩ + | cons_cons _ hy => + obtain ⟨u, hux, huy, hlen⟩ := ih hx hy + exact ⟨a :: u, hux.cons_cons a, huy.cons_cons a, by simp only [List.length_cons]; omega⟩ + +theorem lcs_triangle {α : Type*} (x y z : List α) : lcs x y + lcs y z ≤ y.length + lcs x z := by + obtain ⟨a, hax, hay, ha⟩ := lcs_exists x y + obtain ⟨b, hby, hbz, hb⟩ := lcs_exists y z + obtain ⟨u, hua, hub, hlen⟩ := sublist_common_large hay hby + have hle := le_lcs (hua.trans hax) (hub.trans hbz) + omega + +theorem unequalDeficit_triangle {α : Type*} (x y z : List α) : + unequalDeficit x z ≤ unequalDeficit x y + unequalDeficit y z := by + have hxy := lcs_le_length_left x y + have hyx := lcs_le_length_right x y + have hyz := lcs_le_length_left y z + have hzy := lcs_le_length_right y z + have hxz := lcs_le_length_left x z + have hzx := lcs_le_length_right x z + have ht := lcs_triangle x y z + simp only [unequalDeficit] + omega + +@[simp] theorem unequalDeficit_self {α : Type*} (x : List α) : unequalDeficit x x = 0 := by + simp [unequalDeficit] + +theorem EditStep.unequalDeficit_le {α : Type*} {x y : List α} (h : EditStep x y) : + unequalDeficit x y ≤ 1 := by + cases h with + | insert u v a => + have hs : u ++ v <+ u ++ a :: v := (List.Sublist.refl v).cons a |>.append_left u + have hl := le_lcs (List.Sublist.refl (u ++ v)) hs + simp only [unequalDeficit, List.length_append, List.length_cons] + simp only [List.length_append] at hl + omega + | delete u v a => + have hs : u ++ v <+ u ++ a :: v := (List.Sublist.refl v).cons a |>.append_left u + have hl := le_lcs hs (List.Sublist.refl (u ++ v)) + simp only [unequalDeficit, List.length_append, List.length_cons] + simp only [List.length_append] at hl + omega + | substitute u v a b => + have ha : u ++ v <+ u ++ a :: v := (List.Sublist.refl v).cons a |>.append_left u + have hb : u ++ v <+ u ++ b :: v := (List.Sublist.refl v).cons b |>.append_left u + have hl := le_lcs ha hb + simp only [unequalDeficit, List.length_append, List.length_cons] + simp only [List.length_append] at hl + omega + +theorem EditScript.unequalDeficit_le {α : Type*} {n : ℕ} {x y : List α} (h : EditScript n x y) : + unequalDeficit x y ≤ n := by + induction h with + | nil => simp + | cons h hs ih => + exact (unequalDeficit_triangle _ _ _).trans ((Nat.add_le_add h.unequalDeficit_le ih).trans_eq (Nat.add_comm _ _)) + +theorem unequalDeficit_le_editDistance {α : Type*} (x y : List α) : + unequalDeficit x y ≤ editDistance x y := (editDistance_spec x y).unequalDeficit_le + +theorem editDistance_le_two_unequalDeficit {α : Type*} (x y : List α) : + editDistance x y ≤ 2 * unequalDeficit x y := by + obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + have hscript := (EditScript.of_sublist hx).trans (EditScript.of_sublist hy).symm + have hlenx := hx.length_le + have hleny := hy.length_le + exact (editDistance_le_of_script hscript).trans (by simp only [unequalDeficit]; omega) + +theorem deficit_eq_unequalDeficit {α : Type*} {x y : List α} (h : x.length = y.length) : + deficit x y = unequalDeficit x y := by simp [deficit, unequalDeficit, h] + +theorem deficit_le_editDistance {α : Type*} {x y : List α} (h : x.length = y.length) : + deficit x y ≤ editDistance x y := by + rw [deficit_eq_unequalDeficit h] + exact unequalDeficit_le_editDistance x y + +theorem editDistance_le_two_deficit {α : Type*} {x y : List α} (h : x.length = y.length) : + editDistance x y ≤ 2 * deficit x y := by + rw [deficit_eq_unequalDeficit h] + exact editDistance_le_two_unequalDeficit x y + +theorem lcs_cons_right_le {α : Type*} (x y : List α) (a : α) : + lcs x (a :: y) ≤ lcs x y + 1 := by + obtain ⟨z, hx, hy, hz⟩ := lcs_exists x (a :: y) + cases hy with + | cons _ hy => have h := le_lcs hx hy; omega + | cons_cons _ hy => + have h := le_lcs ((List.Sublist.refl _).cons _ |>.trans hx) hy + simp only [List.length_cons] at hz + omega + +@[simp] theorem lcs_cons_cons {α : Type*} (x y : List α) (a : α) : + lcs (a :: x) (a :: y) = lcs x y + 1 := by + apply Nat.le_antisymm + · obtain ⟨z, hx, hy, hz⟩ := lcs_exists (a :: x) (a :: y) + cases hx with + | cons _ hx => + have h := (le_lcs hx hy).trans (lcs_cons_right_le x y a) + omega + | cons_cons _ hx => + cases hy with + | cons _ hy => + have h := le_lcs hx ((List.Sublist.refl _).cons _ |>.trans hy) + simp only [List.length_cons] at hz + omega + | cons_cons _ hy => + have h := le_lcs hx hy + simp only [List.length_cons] at hz + omega + · obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + have h := le_lcs (hx.cons_cons a) (hy.cons_cons a) + simp only [List.length_cons, hz] at h + exact h + +theorem lcs_reverse {α : Type*} (x y : List α) : lcs x.reverse y.reverse = lcs x y := by + apply Nat.le_antisymm + · obtain ⟨z, hx, hy, hz⟩ := lcs_exists x.reverse y.reverse + have h := le_lcs hx.reverse hy.reverse + simpa only [List.reverse_reverse, List.length_reverse, hz] using h + · obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + have h := le_lcs hx.reverse hy.reverse + simpa only [List.length_reverse, hz] using h + +theorem lcs_append_common_left {α : Type*} (z x y : List α) : + lcs (z ++ x) (z ++ y) = z.length + lcs x y := by + induction z with + | nil => simp + | cons a z ih => simp only [List.cons_append, lcs_cons_cons, List.length_cons, ih]; omega + +theorem lcs_append_common_right {α : Type*} (x y z : List α) : + lcs (x ++ z) (y ++ z) = lcs x y + z.length := by + rw [← lcs_reverse (x ++ z) (y ++ z)] + simp only [List.reverse_append, lcs_append_common_left, lcs_reverse, List.length_reverse] + omega + +theorem deficit_append_common_right {α : Type*} (x y z : List α) : + deficit (x ++ z) (y ++ z) = deficit x y := by + simp only [deficit, List.length_append, lcs_append_common_right] + omega + +theorem lcs_map_ge {α β : Type*} (f : α → β) (x y : List α) : + lcs x y ≤ lcs (x.map f) (y.map f) := by + obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + have h := le_lcs (hx.map f) (hy.map f) + simpa only [List.length_map, hz] using h + +theorem lcs_map_eq {α β : Type*} (f : α → β) (hf : Function.Injective f) (x y : List α) : + lcs (x.map f) (y.map f) = lcs x y := by + apply Nat.le_antisymm _ (lcs_map_ge f x y) + obtain ⟨z, hx, hy, hz⟩ := lcs_exists (x.map f) (y.map f) + obtain ⟨u, hux, hu⟩ := List.sublist_map_iff.mp hx + obtain ⟨v, hvy, hv⟩ := List.sublist_map_iff.mp hy + have huv : u = v := List.map_injective_iff.mpr hf (hu.symm.trans hv) + subst v + have h := le_lcs hux hvy + rw [← hz, hu, List.length_map] + exact h + +theorem lcs_append_replicate {α : Type*} [DecidableEq α] (x y : List α) (b : α) + (hx : b ∉ x) (hy : b ∉ y) (n m : ℕ) : + lcs (x ++ List.replicate n b) (y ++ List.replicate m b) = lcs x y + min n m := by + let p : α → Bool := fun a => decide (a ≠ b) + have hp (l : List α) (h : b ∉ l) : l.filter p = l := by + apply List.filter_eq_self.mpr + intro a ha + exact decide_eq_true (by rintro rfl; exact h ha) + have hnp (l : List α) (h : b ∉ l) : l.filter (fun a => !p a) = [] := by + apply List.filter_eq_nil_iff.mpr + intro a ha + have hab : a ≠ b := by rintro rfl; exact h ha + simp [p, hab] + have hpb : p b = false := by simp [p] + have hnpb : (!p b) = true := by simp [hpb] + apply Nat.le_antisymm + · obtain ⟨z, hzx, hzy, hz⟩ := lcs_exists (x ++ List.replicate n b) (y ++ List.replicate m b) + have hxt : z.filter p <+ x := by + simpa only [List.filter_append, hp x hx, List.filter_replicate, hpb, Bool.false_eq_true, ↓reduceIte, List.append_nil] using hzx.filter p + have hyt : z.filter p <+ y := by + simpa only [List.filter_append, hp y hy, List.filter_replicate, hpb, Bool.false_eq_true, ↓reduceIte, List.append_nil] using hzy.filter p + have hxn : (z.filter (fun a => !p a)).length ≤ n := by + have h := (hzx.filter (fun a => !p a)).length_le + simpa only [List.filter_append, hnp x hx, List.filter_replicate, hnpb, ↓reduceIte, List.nil_append, List.length_replicate] using h + have hyn : (z.filter (fun a => !p a)).length ≤ m := by + have h := (hzy.filter (fun a => !p a)).length_le + simpa only [List.filter_append, hnp y hy, List.filter_replicate, hnpb, ↓reduceIte, List.nil_append, List.length_replicate] using h + have hl := le_lcs hxt hyt + have hs := List.length_eq_length_filter_add (l := z) p + omega + · obtain ⟨z, hzx, hzy, hz⟩ := lcs_exists x y + have hn : List.replicate (min n m) b <+ List.replicate n b := + (List.replicate_sublist_replicate b).mpr (min_le_left _ _) + have hm : List.replicate (min n m) b <+ List.replicate m b := + (List.replicate_sublist_replicate b).mpr (min_le_right _ _) + have h := le_lcs (hzx.append hn) (hzy.append hm) + simpa only [List.length_append, List.length_replicate, hz] using h + +def freshPad {α : Type*} (n : ℕ) (x : List α) : List (Option α) := + x.map some ++ List.replicate (n - x.length) none + +@[simp] theorem length_freshPad {α : Type*} {n : ℕ} {x : List α} (hx : x.length ≤ n) : + (freshPad n x).length = n := by simp [freshPad]; omega + +theorem lcs_freshPad {α : Type*} (n : ℕ) (x y : List α) : + lcs (freshPad n x) (freshPad n y) = lcs x y + (n - max x.length y.length) := by + classical + unfold freshPad + rw [lcs_append_replicate _ _ none (by simp) (by simp)] + rw [lcs_map_eq some (Option.some_injective _)] + congr 1 + omega + +theorem deficit_freshPad {α : Type*} {n : ℕ} {x y : List α} + (hx : x.length ≤ n) (hy : y.length ≤ n) : + deficit (freshPad n x) (freshPad n y) = unequalDeficit x y := by + have hl := lcs_le_length_left x y + have hr := lcs_le_length_right x y + simp only [deficit, length_freshPad hx, lcs_freshPad, unequalDeficit] + omega + +theorem sublist_take_with_loss {α : Type*} {x y : List α} (h : x <+ y) (k : ℕ) : + x.take (k - (y.length - x.length)) <+ y.take k := by + induction h generalizing k with + | slnil => simp + | @cons x y a h ih => + have hl := h.length_le + cases k with + | zero => simp + | succ k => + simpa only [List.length_cons, List.take_succ_cons, + show k + 1 - (y.length + 1 - x.length) = k - (y.length - x.length) by omega] + using (ih k).cons a + | @cons_cons x y a h ih => + have hl := h.length_le + cases k with + | zero => simp + | succ k => + by_cases hk : k + 1 ≤ y.length - x.length + · have he : k + 1 - ((a :: y).length - (a :: x).length) = 0 := by + simp only [List.length_cons]; omega + rw [he] + simp + · have he : k + 1 - ((a :: y).length - (a :: x).length) = + (k - (y.length - x.length)) + 1 := by simp only [List.length_cons]; omega + simpa only [he, List.take_succ_cons] using (ih k).cons_cons a + +theorem unequalDeficit_take_sublist_le {α : Type*} {x y : List α} (h : x <+ y) (k : ℕ) : + unequalDeficit (x.take k) (y.take k) ≤ y.length - x.length := by + have hs : x.take (k - (y.length - x.length)) <+ x.take k := + List.take_sublist_take_left (Nat.sub_le _ _) + have hc := le_lcs hs (sublist_take_with_loss h k) + have hl := h.length_le + simp only [unequalDeficit, List.length_take] at * + omega + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/ExcludedDescent.lean b/lean/OAI/Combinatorics/FiniteCircle/ExcludedDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..71442c16ec2c8d5fbd66d4e7c1f358b68a2908c7 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/ExcludedDescent.lean @@ -0,0 +1,316 @@ +import OAI.Combinatorics.FiniteCircle.MaskDescent + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +theorem PhaseSupported.neg {G : Type*} [AddCommGroup G] {S : Finset ℕ} + {x : G} (hx : PhaseSupported S x) : PhaseSupported S (-x) := by + change _ • (-x) = 0 + rw [smul_neg, hx, neg_zero] + + theorem circleCost_support_lower_pow {M h K e : ℕ} [NeZero M] (hh : 1 ≤ h) + {S : Finset ℕ} (hS : ∀ q ∈ S, q.Prime ∧ q ≤ h^e) (hcard : S.card ≤ K) + {x : ZMod M} (hx : x ≠ 0) (hs : PhaseSupported S x) : + 1 / ((h:ℝ)^(e*K)) ≤ circleCost x := by + let Q := ∏ q ∈ S, q + have hQ : 0 < Q := Finset.prod_pos (fun q hq => (hS q hq).1.pos) + have hQu : Q ≤ h^(e*K) := by + calc + Q ≤ ∏ _q ∈ S, h^e := Finset.prod_le_prod (fun q hq => (hS q hq).2) + _ = h^(e*S.card) := by simp only [Finset.prod_const]; rw [← pow_mul] + _ ≤ _ := Nat.pow_le_pow_right hh (Nat.mul_le_mul_left e hcard) + have he := circleCost_order_lower hQ hx hs + have hp : (0:ℝ) < h := by exact_mod_cast (show 0 < h by omega) + rw [div_le_iff₀ (pow_pos hp _)] + have hc := circleCost_nonneg x + have hQu' : (Q:ℝ) ≤ (h:ℝ)^(e*K) := by exact_mod_cast hQu + nlinarith + +def pairResetBudget (K T n l : ℕ) : ℕ := (n+l*T+K-3)/(K-2) + + theorem pairResetBudget_mono {K T n m l r : ℕ} (h : n+l*T ≤ m+r*T) : + pairResetBudget K T n l ≤ pairResetBudget K T m r := by + unfold pairResetBudget + exact Nat.div_le_div_right (by omega) + + theorem pairResetBudget_overflow {K T n s l : ℕ} (hK : 3 ≤ K) + (hs : s < T) (hover : K < n+s) : + pairResetBudget K T 2 l+1 ≤ pairResetBudget K T n (l+1) := by + have hstep : 2+l*T+K-3+(K-2) ≤ n+(l+1)*T+K-3 := by + rw [Nat.add_mul]; omega + have hdiv := Nat.div_le_div_right (c := K-2) hstep + rw [Nat.add_div_right _ (by omega : 0 < K-2)] at hdiv + exact hdiv + +noncomputable def pairDescentBound (m K T B n l : ℕ) : ℝ := + 1/((4:ℝ)^l*(B:ℝ)^(l+3*pairResetBudget K T n l)*(m:ℝ)^(5*K)) + + theorem pairDescentBound_pos {m K T B n l : ℕ} (hm : 0 < m) (hB : 0 < B) : + 0 < pairDescentBound m K T B n l := by + unfold pairDescentBound; positivity + + theorem pairDescentBound_step {m K T B n s l e : ℕ} (hm : 0 < m) (hB : 1 ≤ B) + (he : l+3*pairResetBudget K T s l+e ≤ l+1+3*pairResetBudget K T n (l+1)) : + pairDescentBound m K T B n (l+1) ≤ + (1/(4*(B:ℝ)^e))*pairDescentBound m K T B s l := by + have hb : (1:ℝ) ≤ B := by exact_mod_cast hB + have hp : (0:ℝ) < m := by exact_mod_cast hm + have hlu := pow_le_pow_right₀ hb he + unfold pairDescentBound + rw [one_div_mul_one_div] + apply one_div_le_one_div_of_le + · positivity + · calc + 4*(B:ℝ)^e*((4:ℝ)^l*(B:ℝ)^(l+3*pairResetBudget K T s l)*(m:ℝ)^(5*K)) = + (4:ℝ)^(l+1)*(B:ℝ)^(l+3*pairResetBudget K T s l+e)*(m:ℝ)^(5*K) := by + rw [pow_succ, pow_add]; ring + _ ≤ _ := by gcongr + + theorem pairDescentBound_base {m K T B n : ℕ} (hm : 0 < m) (hB : 1 ≤ B) : + pairDescentBound m K T B n 0 ≤ 1/(m:ℝ)^(5*K) := by + have hb : (1:ℝ) ≤ B := by exact_mod_cast hB + have hp : (0:ℝ) < m := by exact_mod_cast hm + unfold pairDescentBound + simp only [pow_zero, one_mul, zero_add] + apply one_div_le_one_div_of_le (by positivity) + exact le_mul_of_one_le_left (by positivity) (one_le_pow₀ hb) + +theorem excluded_denominator_descent {m H M K T B : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hT : 2 ≤ T) (hB : 1 ≤ B) (hmB : m ≤ B^4) (hmTB : m ≤ T*B) + (hsmall : 2*T ≤ m) (hK : 3 ≤ K) + (hd : ∀ l (k : Fin m), p l k ∣ M) (hn : ∀ l (k : Fin m), 0 < p l k) + (hp : ∀ l, 1 ≤ l → l ≤ H → ∀ k : Fin m, (p l k).Prime) + (hin : ∀ l, 1 ≤ l → l ≤ H → ∀ k : Fin m, p l k ≤ m^5) + (hinj : ∀ l, 1 ≤ l → l ≤ H → Function.Injective (fun k : Fin m => p l k)) + (hlevel : ∀ l r, 1 ≤ l → l ≤ H → 1 ≤ r → r ≤ H → l ≠ r → + ∀ i j : Fin m, p l i ≠ p r j) : + ∀ l, l ≤ H → ∀ (S : Finset ℕ) (x : ZMod M), S.card ≤ K → + (∀ q ∈ S, q.Prime ∧ q ≤ m^5) → LowerFresh m p l S → x ≠ 0 → + PhaseSupported S x → pairDescentBound m K T B S.card l ≤ excludedCost m p M hd hn l x := by + classical + have hm : 0 < m := by omega + have hBp : 0 < B := by omega + intro l + induction l with + | zero => + intro _ S x hcard hS _ hx hs + exact (pairDescentBound_base hm hB).trans (circleCost_support_lower_pow (by omega) hS hcard hx hs) + | succ l ih => + intro hlH S x hcard hS hfresh hx hs + let : ∀ k : Fin m, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + let f := excludedCost m p M hd hn l + obtain ⟨z,hact,hinact⟩ := excluded_minimizer_options (by omega) (hd (l+1)) (hn (l+1)) f x + let A := Finset.univ.filter (fun k : Fin m => z k ≠ 0) + let P := A.image (fun k : Fin m => p (l+1) k) + have hpP (q : ℕ) (hq : q ∈ P) : q.Prime ∧ q ≤ m^5 := by + obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp hq + exact ⟨hp (l+1) (by omega) hlH k, hin (l+1) (by omega) hlH k⟩ + have hfreshP : LowerFresh m p l P := by + intro j hj hjl k hk + obtain ⟨t, _, ht⟩ := Finset.mem_image.mp hk + exact hlevel j (l+1) hj (by omega) (by omega) hlH (by omega) k t ht.symm + have hdis : Disjoint S P := by + apply Finset.disjoint_left.mpr + intro q hq hqP + obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp hqP + exact hfresh (l+1) (by omega) (by omega) k hq + have hchild (i j : Fin m) (hi : z i ≠ 0) (hij : i ≠ j) : + pairDescentBound m K T B 2 l ≤ f (subcircle (hd (l+1) i) (z i)-subcircle (hd (l+1) j) (z j)) := by + have hne : p (l+1) i ≠ p (l+1) j := (hinj (l+1) (by omega) hlH).ne hij + let Q : Finset ℕ := {p (l+1) i,p (l+1) j} + have hQ : Q.card = 2 := by simp [Q,hne] + have hfr : LowerFresh m p l Q := by + intro r hr hrl k hk + simp only [Q, Finset.mem_insert, Finset.mem_singleton] at hk + rcases hk with hk | hk + · exact hlevel r (l+1) hr (by omega) (by omega) hlH (by omega) k i hk + · exact hlevel r (l+1) hr (by omega) (by omega) hlH (by omega) k j hk + have hpi := hp (l+1) (by omega) hlH i + have hpj := hp (l+1) (by omega) hlH j + have hsupp : PhaseSupported Q (subcircle (hd (l+1) i) (z i)-subcircle (hd (l+1) j) (z j)) := by + simpa only [Finset.singleton_union, sub_eq_add_neg] using + (support_subcircle (hd (l+1) i) (z i)).add (support_subcircle (hd (l+1) j) (z j)).neg + have hnon : subcircle (hd (l+1) i) (z i)-subcircle (hd (l+1) j) (z j) ≠ 0 := by + rw [sub_eq_add_neg] + apply phase_add_supported_ne_zero (support_subcircle (hd (l+1) i) (z i)) + (support_subcircle (hd (l+1) j) (z j)).neg + · simpa using hpi + · simpa using hpj + · simpa using hne + · simpa only [map_zero] using (subcircle_injective (hd (l+1) i)).ne hi + have hQP (q : ℕ) (hq : q ∈ Q) : q.Prime ∧ q ≤ m^5 := by + simp only [Q, Finset.mem_insert, Finset.mem_singleton] at hq + rcases hq with rfl | rfl + · exact ⟨hpi,hin (l+1) (by omega) hlH i⟩ + · exact ⟨hpj,hin (l+1) (by omega) hlH j⟩ + simpa only [hQ] using ih (by omega) Q _ (by omega) hQP hfr hnon hsupp + have hreset : (A.card:ℝ)/(4*m)*pairDescentBound m K T B 2 l ≤ excludedCost m p M hd hn (l+1) x := + hact _ (pairDescentBound_pos hm hBp).le hchild + have hspos : 0 < S.card := support_card_pos hx hs + have hmreal : (0:ℝ) < m := by exact_mod_cast hm + have hBreal : (0:ℝ) < B := by exact_mod_cast hBp + by_cases hlarge : T ≤ A.card + · have hbudget : pairResetBudget K T 2 l ≤ pairResetBudget K T S.card (l+1) := by + apply pairResetBudget_mono + rw [Nat.add_mul]; omega + have hstep := pairDescentBound_step (K := K) (T := T) (n := S.card) (s := 2) (l := l) (e := 1) hm hB (by omega) + have hfac : 1/(4*(B:ℝ)^1) ≤ (A.card:ℝ)/(4*m) := by + rw [div_le_div_iff₀ (by positivity) (by positivity)] + simp only [pow_one] + have hmTB' : (m:ℝ) ≤ T*B := by exact_mod_cast hmTB + have ha : (T:ℝ) ≤ A.card := by exact_mod_cast hlarge + nlinarith + exact hstep.trans ((mul_le_mul_of_nonneg_right hfac (pairDescentBound_pos hm hBp).le).trans hreset) + · have hsm : A.card < T := by omega + by_cases hover : K < S.card+A.card + · have hapos : 0 < A.card := by omega + have hbudget := pairResetBudget_overflow (l := l) hK hsm hover + have hstep := pairDescentBound_step (K := K) (T := T) (n := S.card) (s := 2) (l := l) (e := 4) hm hB (by omega) + have hfac : 1/(4*(B:ℝ)^4) ≤ (A.card:ℝ)/(4*m) := by + rw [div_le_div_iff₀ (by positivity) (by positivity)] + have ha : (1:ℝ) ≤ A.card := by exact_mod_cast hapos + have hmB' : (m:ℝ) ≤ (B:ℝ)^4 := by exact_mod_cast hmB + nlinarith [pow_nonneg (Nat.cast_nonneg B : (0:ℝ) ≤ B) 4] + exact hstep.trans ((mul_le_mul_of_nonneg_right hfac (pairDescentBound_pos hm hBp).le).trans hreset) + · have hPC : P.card ≤ A.card := Finset.card_image_le + have hunion : (S ∪ P).card ≤ S.card+A.card := (Finset.card_union_le S P).trans (by omega) + have hnew := hs.add (support_mask_sum (hd (l+1)) z) + have hnz : (x+∑ k,subcircle (hd (l+1) k) (z k)) ≠ 0 := + phase_add_supported_ne_zero hs (support_mask_sum (hd (l+1)) z) + (fun q hq => (hS q hq).1) (fun q hq => (hpP q hq).1) hdis hx + have hfr : LowerFresh m p l (S ∪ P) := by + intro j hj hjl k hk + rcases Finset.mem_union.mp hk with hk | hk + · exact hfresh j hj (by omega) k hk + · exact hfreshP j hj hjl k hk + have hSUP (q : ℕ) (hq : q ∈ S ∪ P) : q.Prime ∧ q ≤ m^5 := by + rcases Finset.mem_union.mp hq with hq | hq + · exact hS q hq + · exact hpP q hq + have hlower := ih (by omega) (S ∪ P) _ (by omega) hSUP hfr hnz hnew + have hbudget : pairResetBudget K T (S∪P).card l ≤ pairResetBudget K T S.card (l+1) := by + apply pairResetBudget_mono + rw [Nat.add_mul]; omega + have hstep := pairDescentBound_step (K := K) (T := T) (n := S.card) (s := (S∪P).card) (l := l) (e := 0) hm hB (by omega) + simp only [pow_zero,mul_one] at hstep + exact hstep.trans ((mul_le_mul_of_nonneg_left hlower (by norm_num : (0:ℝ) ≤ 1/4)).trans + (hinact (by change 2*A.card ≤ m; omega))) + + theorem resetBudget_bound {h T : ℕ} (hh : 1000000 ≤ h) (hT : 1 ≤ T) : + resetBudget (h/100) T 1 h ≤ 200*T := by + let K := h/100 + have hKh : h ≤ 198*(K-1) := by dsimp [K]; omega + have hK : K ≤ 2*(K-1) := by dsimp [K]; omega + have hmul := Nat.mul_le_mul_right T hKh + have hmulK := Nat.mul_le_mul_left (2*(K-1)) hT + unfold resetBudget + apply Nat.div_le_of_le_mul + change 1+h*T+K-2 ≤ (K-1)*(200*T) + calc + _ ≤ h*T+K := by omega + _ ≤ 198*(K-1)*T+2*(K-1)*T := Nat.add_le_add hmul (hK.trans (by simpa using hmulK)) + _ = _ := by ring + + theorem pairResetBudget_bound {h T : ℕ} (hh : 1000000 ≤ h) (hT : 1 ≤ T) : + pairResetBudget (h/100) T 1 h ≤ 200*T := by + let K := h/100 + have hKh : h ≤ 198*(K-2) := by dsimp [K]; omega + have hK : K ≤ 2*(K-2) := by dsimp [K]; omega + have hmul := Nat.mul_le_mul_right T hKh + have hmulK := Nat.mul_le_mul_left (2*(K-2)) hT + unfold pairResetBudget + apply Nat.div_le_of_le_mul + change 1+h*T+K-3 ≤ (K-2)*(200*T) + calc + _ ≤ h*T+K := by omega + _ ≤ 198*(K-2)*T+2*(K-2)*T := Nat.add_le_add hmul (hK.trans (by simpa using hmulK)) + _ = _ := by ring + + theorem mask_budget_exponent {n : ℕ} (hn : 1000000 ≤ n) : + 2*resetBudget (n^4/100) (n^2) 1 (n^4)+16*(n^4/100) ≤ n^4/2 := by + have hn2 : 2000 ≤ n^2 := by nlinarith + have hn4 : 1000000 ≤ n^4 := by nlinarith [sq_nonneg (n^2:ℤ)] + have hb := resetBudget_bound hn4 (show 1 ≤ n^2 by omega) + have hk := Nat.mul_div_le (n^4) 100 + have hp : 40000*n^2 ≤ 34*n^4 := by nlinarith + omega + + theorem excluded_budget_exponent {n : ℕ} (hn : 1000000 ≤ n) : + 3*pairResetBudget (n^4/100) (n^3) 1 (n^4)+20*(n^4/100) ≤ n^4 := by + have hn3 : 1 ≤ n^3 := Nat.one_le_pow _ _ (by omega) + have hn4 : 1000000 ≤ n^4 := by nlinarith [Nat.pow_le_pow_left (show 2 ≤ n by omega) 4] + have hb := pairResetBudget_bound hn4 hn3 + have hk := Nat.mul_div_le (n^4) 100 + have hp := Nat.mul_le_mul_right (n^3) (show 1000 ≤ n by omega) + have he : n*n^3=n^4 := by ring + rw [he] at hp + omega + + theorem four_eight_pow_le {n h : ℕ} (hn : 256 ≤ n) (hh : 2 ≤ h) (he : h=2*(h/2)) : + 4*(8:ℝ)^h ≤ (n:ℝ)^(h/2) := by + have hfour : (4:ℝ) ≤ 2^h := by + calc + (4:ℝ) = 2^2 := by norm_num + _ ≤ _ := pow_le_pow_right₀ (by norm_num) hh + calc + 4*(8:ℝ)^h ≤ (2:ℝ)^h*8^h := mul_le_mul_of_nonneg_right hfour (by positivity) + _ = (16:ℝ)^h := by rw [← mul_pow]; norm_num + _ = (256:ℝ)^(h/2) := by conv_lhs => rw [he, pow_mul]; norm_num + _ ≤ _ := pow_le_pow_left₀ (by norm_num) (by exact_mod_cast hn) _ + + theorem mask_descent_numeric {n : ℕ} (hn : 1000000 ≤ n) (he : n^4=2*(n^4/2)) : + 1/(n:ℝ)^(3*n^4) ≤ (1/((2:ℝ)^(n^4)*4)) * descentBound (n^4) (n^4/100) (n^2) 1 (n^4) := by + have hnp : (0:ℝ) (a : ZMod (p l k))) = + excludedTranslation m p M l a := by + ext i + change (∑ j ∈ Finset.univ.erase i, subcircle (hd j) (a : ZMod (p l j))) = _ + unfold excludedTranslation + apply Finset.sum_congr rfl + intro j _ + let : NeZero (p l j) := ⟨(hn j).ne'⟩ + rw [subcircle_val, ZMod.val_natCast] + +noncomputable def excludedCost (m : ℕ) (p : ℕ → ℕ → ℕ) (M : ℕ) + (hd : ∀ l (k : Fin m), p l k ∣ M) (hn : ∀ l (k : Fin m), 0 < p l k) : + ℕ → PhaseCost (ZMod M) + | 0 => circlePhaseCost M + | l+1 => by + let : ∀ k : Fin m, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + exact (excludedCost m p M hd hn l).step (excludedPhaseHom m p M (l+1) (hd _)) + + theorem excludedCost_le_half {m M : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hm : 0 < m) (hd : ∀ l (k : Fin m), p l k ∣ M) (hn : ∀ l (k : Fin m), 0 < p l k) + (l : ℕ) (x : ZMod M) : excludedCost m p M hd hn l x ≤ 1/2 := by + induction l with + | zero => exact circleCost_le_half x + | succ l ih => + let : ∀ k : Fin m, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + let : Nonempty (Fin m) := ⟨⟨0,hm⟩⟩ + exact ((excludedCost m p M hd hn l).infAverage_le_self _ x).trans ih + +theorem excluded_active_average_lower {m M l : ℕ} {p : ℕ → ℕ → ℕ} + (hm : 2 ≤ m) (hd : ∀ k : Fin m, p l k ∣ M) + (f : PhaseCost (ZMod M)) (x : ZMod M) (z : MaskResidues m p l) + (Q : ℝ) (hQ : 0 ≤ Q) + (hq : ∀ i j : Fin m, z i ≠ 0 → i ≠ j → + Q ≤ f (subcircle (hd i) (z i)-subcircle (hd j) (z j))) : + (((Finset.univ.filter (fun k : Fin m => z k ≠ 0)).card : ℝ)/(4*m))*Q ≤ + f.average (excludedPhaseHom m p M l hd) x z := by + classical + let A := Finset.univ.filter (fun k : Fin m => z k ≠ 0) + let y (i : Fin m) := x+excludedPhaseHom m p M l hd z i + let B := ∑ i : Fin m, f (y i) + have hB : 0 ≤ B := Finset.sum_nonneg (fun _ _ => f.nonneg _) + have hpair (i j : Fin m) (hi : i ∈ A) (hij : i ≠ j) : Q ≤ f (y i)+f (y j) := by + have he : subcircle (hd i) (z i)-subcircle (hd j) (z j) = y j-y i := by + dsimp only [y] + rw [excludedPhaseHom_apply, excludedPhaseHom_apply] + abel + exact (hq i j ((Finset.mem_filter.mp hi).2) hij).trans (by rw [he]; simpa [add_comm] using f.sub_le (y j) (y i)) + have hper (i : Fin m) (hi : i ∈ A) : ((m : ℝ) - 1)*Q ≤ (m:ℝ)*f (y i)+B := by + have hh := Finset.sum_le_sum (s := Finset.univ.erase i) (fun j hj => + hpair i j hi (Ne.symm (Finset.mem_erase.mp hj).1)) + have hsum : (∑ j ∈ Finset.univ.erase i, (f (y i)+f (y j))) ≤ + ∑ j : Fin m, (f (y i)+f (y j)) := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.erase_subset _ _) (fun j _ _ => add_nonneg (f.nonneg _) (f.nonneg _)) + have hcard : (Finset.univ.erase i).card = m-1 := by simp + rw [Finset.sum_const, hcard, nsmul_eq_mul, Nat.cast_sub (by omega : 1 ≤ m), Nat.cast_one] at hh + simpa only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, + Fintype.card_fin, nsmul_eq_mul] using hh.trans hsum + have hs : A.card ≤ m := by simpa using Finset.card_le_card (Finset.subset_univ A) + have hsum := Finset.sum_le_sum (s := A) hper + simp only [Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul, ← Finset.mul_sum] at hsum + have hpart : (∑ i ∈ A, f (y i)) ≤ B := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ _) (fun _ _ _ => f.nonneg _) + have hsreal : (A.card : ℝ) ≤ m := by exact_mod_cast hs + have hmreal : (2:ℝ) ≤ m := by exact_mod_cast hm + have ha0 : (0:ℝ) ≤ A.card := by positivity + have hsq : (A.card : ℝ)*Q ≤ 4*B := by + have hupper : (m:ℝ)*(∑ i ∈ A, f (y i))+(A.card:ℝ)*B ≤ 2*m*B := by + nlinarith [mul_le_mul_of_nonneg_left hpart (show (0 : ℝ) ≤ m by positivity), + mul_le_mul_of_nonneg_right hsreal hB] + have hbase : (A.card:ℝ)*((m : ℝ) - 1)*Q ≤ 2*m*B := by nlinarith + have hnon : 0 ≤ (A.card:ℝ)*Q := mul_nonneg ha0 hQ + nlinarith [mul_nonneg hnon (show (0:ℝ)≤(m : ℝ) - 2 by linarith)] + change (A.card:ℝ)/(4*m)*Q ≤ B / Fintype.card (Fin m) + rw [Fintype.card_fin] + rw [le_div_iff₀ (by positivity : (0 : ℝ) < m)] + calc + _ = (A.card:ℝ)*Q/4 := by field_simp + _ ≤ _ := by linarith + + theorem excluded_inactive_average_lower {m M l : ℕ} {p : ℕ → ℕ → ℕ} + (hm : 0 < m) (hd : ∀ k : Fin m, p l k ∣ M) + (f : PhaseCost (ZMod M)) (x : ZMod M) (z : MaskResidues m p l) + (hs : 2*(Finset.univ.filter (fun k : Fin m => z k ≠ 0)).card ≤ m) : + (1/4:ℝ)*f (x+∑ k,subcircle (hd k) (z k)) ≤ + f.average (excludedPhaseHom m p M l hd) x z := by + classical + let A := Finset.univ.filter (fun k : Fin m => z k ≠ 0) + let N := Finset.univ.filter (fun k : Fin m => z k = 0) + let Q := f (x+∑ k,subcircle (hd k) (z k)) + have hQ : 0 ≤ Q := f.nonneg _ + have hsum : (N.card:ℝ)*Q ≤ ∑ k : Fin m, f (x+excludedPhaseHom m p M l hd z k) := by + calc + _ = ∑ _k ∈ N, Q := by simp only [Finset.sum_const, nsmul_eq_mul] + _ = ∑ k ∈ N, f (x+excludedPhaseHom m p M l hd z k) := by + apply Finset.sum_congr rfl + intro k hk + rw [excludedPhaseHom_apply, (Finset.mem_filter.mp hk).2, map_zero, sub_zero] + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun _ _ _ => f.nonneg _) + have hcard : A.card+N.card = m := by + simpa only [Finset.card_univ, Fintype.card_fin, not_not] using + Finset.card_filter_add_card_filter_not (s := Finset.univ) (p := fun k : Fin m => z k ≠ 0) + change 2*A.card ≤ m at hs + have hN : (m:ℝ) ≤ 2*N.card := by exact_mod_cast (show m ≤ 2*N.card by omega) + rw [PhaseCost.average, Fintype.card_fin, le_div_iff₀ (by exact_mod_cast hm : (0 : ℝ) < m)] + change (1/4:ℝ)*Q*m ≤ _ + have hh := mul_le_mul_of_nonneg_right hN hQ + nlinarith + + theorem excluded_minimizer_options {m M l : ℕ} {p : ℕ → ℕ → ℕ} + [∀ k : Fin m, NeZero (p l k)] + (hm : 2 ≤ m) (hd : ∀ k : Fin m, p l k ∣ M) (hn : ∀ k : Fin m, 0 < p l k) + (f : PhaseCost (ZMod M)) (x : ZMod M) : + ∃ z : MaskResidues m p l, + (∀ Q : ℝ, 0 ≤ Q → (∀ i j : Fin m, z i ≠ 0 → i ≠ j → + Q ≤ f (subcircle (hd i) (z i)-subcircle (hd j) (z j))) → + (((Finset.univ.filter (fun k : Fin m => z k ≠ 0)).card : ℝ)/(4*m))*Q ≤ + (f.step (excludedPhaseHom m p M l hd)) x) ∧ + (2*(Finset.univ.filter (fun k : Fin m => z k ≠ 0)).card ≤ m → + (1/4:ℝ)*f (x+∑ k,subcircle (hd k) (z k)) ≤ + (f.step (excludedPhaseHom m p M l hd)) x) := by + let : ∀ k : Fin m, NeZero (p l k) := fun k => ⟨(hn k).ne'⟩ + obtain ⟨z,hz⟩ := f.exists_average_eq (excludedPhaseHom m p M l hd) x + refine ⟨z,?_,?_⟩ + · intro Q hQ hq + change _ ≤ f.infAverage _ _ + rw [hz] + exact excluded_active_average_lower hm hd f x z Q hQ hq + · intro hs + change _ ≤ f.infAverage _ _ + rw [hz] + exact excluded_inactive_average_lower (by omega) hd f x z hs + + def excludedTags (m _l : ℕ) : List (Fin m) := List.ofFn id + +@[simp] theorem length_excludedTags (m l : ℕ) : (excludedTags m l).length = m := by + simp [excludedTags] + + theorem mem_excludedTags (m l : ℕ) (j : Fin m) : j ∈ excludedTags m l := by + simp [excludedTags] + + theorem nodup_excludedTags (m l : ℕ) : (excludedTags m l).Nodup := by + apply List.nodup_ofFn.mpr + exact Function.injective_id + + theorem excludedWord_succ (m : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : ExcludedState m M (l+1)) : + excludedWord m p R M (l+1) v = (List.range (R*period m p (l+1))).flatMap (fun a => + taggedRow (excludedTags m (l+1)) (fun j => excludedWord m p R M l + (shiftExcludedState m M l (v j) (excludedTranslation m p M (l+1) a j)))) := by + have he := excludedWord.eq_2 m p R M l v + dsimp only [ExcludedAlphabet, ExcludedState] at he + refine he.trans ?_ + unfold taggedRow excludedTags + simp only [List.flatMap_def, List.map_ofFn, Function.comp_id] +noncomputable def excludedLength (h : ℕ) (p : ℕ → ℕ → ℕ) (R M : ℕ) : ℕ → ℕ + | 0 => M + | l+1 => (R*period h p (l+1))*((excludedTags h (l+1)).length*excludedLength h p R M l) + +@[simp] theorem length_excludedWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : ExcludedState h M l) : (excludedWord h p R M l v).length = excludedLength h p R M l := by + induction l with + | zero => + have he := excludedWord.eq_1 h p R M v + dsimp only [ExcludedAlphabet, ExcludedState] at he + exact (congrArg List.length he).trans (List.length_ofFn) + | succ l ih => + rw [excludedWord_succ] + change ((List.range (R*period h p (l+1))).flatMap (fun a => + taggedRow (excludedTags h (l+1)) (fun j => excludedWord h p R M l + (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j))))).length = _ + rw [length_flatMap_uniform _ _ ((excludedTags h (l+1)).length*excludedLength h p R M l)] + · simp [excludedLength] + · intro a _ + apply length_flatMap_uniform + intro j _ + simp [ih] + +@[simp] theorem shiftExcludedState_zero (h : ℕ) (M l : ℕ) + (v : ExcludedState h M l) : shiftExcludedState h M l v 0 = v := by + induction l with + | zero => change ZMod M at v; exact add_zero v + | succ l ih => funext j; exact ih (v j) + +theorem shiftExcludedState_add (h : ℕ) (M l : ℕ) + (v : ExcludedState h M l) (a b : ZMod M) : + shiftExcludedState h M l (shiftExcludedState h M l v a) b = + shiftExcludedState h M l v (a+b) := by + induction l with + | zero => change ZMod M at v; exact add_assoc v a b + | succ l ih => funext j; exact ih (v j) + +theorem shiftExcludedState_change_base (h : ℕ) (M l : ℕ) + (v : ExcludedState h M l) (θ a b : ZMod M) : + shiftExcludedState h M l (shiftExcludedState h M l v θ) b = + shiftExcludedState h M l (shiftExcludedState h M l v a) (θ+b-a) := by + rw [shiftExcludedState_add, shiftExcludedState_add] + congr 1 + abel + +def excludedRow (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : ExcludedState h M (l+1)) (a : ℕ) : List (ExcludedAlphabet h M (l+1)) := + taggedRow (excludedTags h (l+1)) (fun j => excludedWord h p R M l + (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j))) + +@[simp] theorem length_excludedRow (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : ExcludedState h M (l+1)) (a : ℕ) : + (excludedRow h p R M l v a).length = (excludedTags h (l+1)).length*excludedLength h p R M l := by + change (Fin h → ExcludedState h M l) at v + change (taggedRow (excludedTags h (l+1)) (fun j => excludedWord h p R M l + (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j)))).length = _ + unfold taggedRow + apply length_flatMap_uniform + intro j _ + rw [List.length_map, length_excludedWord] + +theorem segment_excludedWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : ExcludedState h M (l+1)) (a : Fin (R*period h p (l+1))) : + segment (excludedWord h p R M (l+1) v) + (a.val*((excludedTags h (l+1)).length*excludedLength h p R M l)) + ((excludedTags h (l+1)).length*excludedLength h p R M l) = excludedRow h p R M l v a := by + have he := segment_flatMap_uniform (List.range (R*period h p (l+1))) + (excludedRow h p R M l v) _ (fun a _ => length_excludedRow h p R M l v a) + ⟨a.val, by simp⟩ + rw [excludedWord_succ] + change segment ((List.range (R*period h p (l+1))).flatMap (excludedRow h p R M l v)) _ _ = _ + simpa only [List.get_eq_getElem, List.getElem_range] using he + +theorem tag_get_excludedWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : ExcludedState h M (l+1)) (hL : 0 < excludedLength h p R M l) + (ht : 0 < (excludedTags h (l+1)).length) + (k : Fin (excludedWord h p R M (l+1) v).length) : + (excludedTags h (l+1)).idxOf ((excludedWord h p R M (l+1) v).get k).1 = + (k.val/excludedLength h p R M l)%(excludedTags h (l+1)).length := by + classical + have hl := congrArg List.length (excludedWord_succ h p R M l v) + let k' := Fin.cast hl k + have he := tag_get_rows (excludedTags h (l+1)) (nodup_excludedTags h (l+1)) + (fun a j => excludedWord h p R M l + (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j))) + (N := R*period h p (l+1)) hL ht + (fun _ _ _ _ => length_excludedWord ..) k' + have hg : ((excludedWord h p R M (l+1) v).get k) = + (((List.range (R*period h p (l+1))).flatMap (fun a => + taggedRow (excludedTags h (l+1)) (fun j => excludedWord h p R M l + (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j))))).get k') := by + exact List.get_of_eq (excludedWord_succ h p R M l v) k + rw [hg] + exact he + + theorem excludedLength_pos {h M R : ℕ} {p : ℕ → ℕ → ℕ} + (hh : 0 < h) (hM : 0 < M) (hR : 0 < R) (hn : ∀ l (k : Fin h), 0 < p l k) + (l : ℕ) : 0 < excludedLength h p R M l := by + induction l with + | zero => exact hM + | succ l ih => + unfold excludedLength + apply Nat.mul_pos (Nat.mul_pos hR (Finset.prod_pos (fun k _ => hn _ k))) + apply Nat.mul_pos _ ih + simpa using hh + +theorem excluded_separation {h M R : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (he : M = 2*(M/2)) (hh : 0 < h) (hR : 0 < R) + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (ht : ∀ l, 4 ≤ (excludedTags h l).length) + (l : ℕ) (v : ExcludedState h M l) (θ : ZMod M) : + (1/((2:ℝ)^l*4))*(excludedLength h p R M l)*excludedCost h p M hd hn l θ ≤ + (deficit (excludedWord h p R M l v) + (excludedWord h p R M l (shiftExcludedState h M l v θ)) : ℝ) := by + classical + induction l generalizing θ with + | zero => + change ZMod M at v + change (1/((2:ℝ)^0*4))*M*circleCost θ ≤ + (deficit (excludedWord h p R M 0 v) (excludedWord h p R M 0 (v+θ)) : ℝ) + have hbase (u : ZMod M) : (excludedWord h p R M 0 u).map Prod.snd = + List.ofFn (fun i : Fin M => halfBit u (i.val : ZMod M)) := by + change (List.ofFn (fun b : Fin M => (b,halfBit u (b.val : ZMod M)))).map Prod.snd = _ + rw [List.map_ofFn] + rfl + have hlcs := lcs_map_ge Prod.snd (excludedWord h p R M 0 v) (excludedWord h p R M 0 (v+θ)) + rw [hbase, hbase] at hlcs + have hdef : deficit (List.ofFn (fun i : Fin M => halfBit v (i.val : ZMod M))) + (List.ofFn (fun i : Fin M => halfBit (v+θ) (i.val : ZMod M))) ≤ + deficit (excludedWord h p R M 0 v) (excludedWord h p R M 0 (v+θ)) := by + have hlen := length_excludedWord h p R M 0 v + change (excludedWord h p R M 0 v).length = M at hlen + rw [deficit, List.length_ofFn, deficit, hlen] + exact Nat.sub_le_sub_left hlcs M + calc + _ = (M:ℝ)*circleCost θ/4 := by norm_num; ring + _ ≤ _ := (halfCircle_separation he v θ).trans (by exact_mod_cast hdef) + | succ l ih => + let : ∀ k : Fin h, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + let L := excludedLength h p R M l + let t := (excludedTags h (l+1)).length + let N := R*period h p (l+1) + let f := excludedCost h p M hd hn l + let σ := excludedPhaseHom h p M (l+1) (hd _) + let ρ := (1/((2:ℝ)^l*4))*excludedCost h p M hd hn (l+1) θ + have hL : 0 < L := excludedLength_pos hh (NeZero.pos M) hR hn l + have hp2 : 1 ≤ (2:ℝ)^l := one_le_pow₀ (by norm_num) + have hρ : ρ ≤ 1/2 := by + have hc := excludedCost_le_half hh hd hn (l+1) θ + have hc0 := (excludedCost h p M hd hn (l+1)).nonneg θ + dsimp [ρ] + have hi : 1/((2:ℝ)^l*4) ≤ 1 := (div_le_one (by positivity)).mpr (by nlinarith) + calc + _ ≤ 1*excludedCost h p M hd hn (l+1) θ := mul_le_mul_of_nonneg_right hi hc0 + _ ≤ _ := by simpa using hc + have hx : (excludedWord h p R M (l+1) v).length = (t*L)*N := by + rw [length_excludedWord h p R M (l+1) v] + change N*(t*L) = (t*L)*N + exact Nat.mul_comm _ _ + have hy : (excludedWord h p R M (l+1) (shiftExcludedState h M (l+1) v θ)).length = (t*L)*N := by + rw [length_excludedWord] + change N*(t*L) = (t*L)*N + exact Nat.mul_comm _ _ + have hr := row_separation hL (ht (l+1)) hx hy + (fun x => (excludedTags h (l+1)).idxOf x.1) + (tag_get_excludedWord h p R M l v hL (by have := ht (l+1); omega)) + (tag_get_excludedWord h p R M l _ hL (by have := ht (l+1); omega)) ρ hρ + have hrows : ∀ i j : Fin N, ρ*(t*L) ≤ + (deficit (segment (excludedWord h p R M (l+1) v) (i.val*(t*L)) (t*L)) + (segment (excludedWord h p R M (l+1) (shiftExcludedState h M (l+1) v θ)) + (j.val*(t*L)) (t*L)) : ℝ) := by + intro a b + rw [segment_excludedWord h p R M l v a, segment_excludedWord h p R M l _ b] + let z : MaskResidues h p (l+1) := fun k => (b.val : ZMod (p (l+1) k)) - (a.val : ZMod (p (l+1) k)) + have hz (j : Fin h) : σ z j = + excludedTranslation h p M (l+1) b j - excludedTranslation h p M (l+1) a j := by + change σ ((fun k : Fin h => (b.val : ZMod (p (l+1) k))) - (fun k : Fin h => (a.val : ZMod (p (l+1) k)))) j = _ + rw [map_sub, Pi.sub_apply] + exact congrArg₂ (·-·) (congrFun (excludedPhaseHom_natCast h p M (l+1) b (hd _) (hn _)) j) + (congrFun (excludedPhaseHom_natCast h p M (l+1) a (hd _) (hn _)) j) + have hind (j : Fin h) := ih + (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j)) (θ+σ z j) + have hstate (j : Fin h) : + shiftExcludedState h M l (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j)) (θ+σ z j) = + shiftExcludedState h M l (shiftExcludedState h M l (v j) θ) (excludedTranslation h p M (l+1) b j) := by + rw [shiftExcludedState_add, shiftExcludedState_add, hz] + congr 1 + abel + simp_rw [hstate] at hind + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun j _ => hind j) + have hdef := deficit_taggedRow_lower (excludedTags h (l+1)) (nodup_excludedTags ..) + (mem_excludedTags h (l+1)) + (fun j => excludedWord h p R M l (shiftExcludedState h M l (v j) (excludedTranslation h p M (l+1) a j))) + (fun j => excludedWord h p R M l (shiftExcludedState h M l (shiftExcludedState h M l (v j) θ) (excludedTranslation h p M (l+1) b j))) + apply le_trans _ (hsum.trans hdef) + rw [← Finset.mul_sum] + have hcost : excludedCost h p M hd hn (l+1) θ ≤ f.average σ θ z := f.infAverage_le σ θ z + have htpos : (0:ℝ) < t := by exact_mod_cast (show 0 < t by have := ht (l+1); omega) + have hcard : (Fintype.card (Fin h) : ℝ) = t := by simp [t] + rw [PhaseCost.average, hcard, le_div_iff₀ htpos] at hcost + dsimp only [ρ] + calc + _ = ((1/((2:ℝ)^l*4))*(L:ℝ)) * ((excludedCost h p M hd hn (l+1) θ)*t) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hcost (by positivity) + have hfinal := hr hrows + rw [length_excludedWord h p R M (l+1) v] at hfinal + dsimp only [ρ] at hfinal + calc + _ = ((1/((2:ℝ)^l*4))*excludedCost h p M hd hn (l+1) θ)/2 * excludedLength h p R M (l+1) := by rw [pow_succ]; ring + _ ≤ _ := hfinal + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Fourier.lean b/lean/OAI/Combinatorics/FiniteCircle/Fourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..90ad86699e3b473e18d8fdd070ae935d09689931 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Fourier.lean @@ -0,0 +1,292 @@ +import OAI.Combinatorics.FiniteCircle.DeficitLower + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +open scoped BigOperators ComplexConjugate +open RCLike Module + +noncomputable def characterBasis (G : Type*) [AddCommGroup G] [Fintype G] : + Basis (AddChar G ℂ) ℂ (G → ℂ) := + basisOfLinearIndependentOfCardEqFinrank' ((⇑) : AddChar G ℂ → G → ℂ) + (AddChar.linearIndependent G ℂ) (by simp) + +@[simp] theorem characterBasis_apply {G : Type*} [AddCommGroup G] [Fintype G] + (χ : AddChar G ℂ) : characterBasis G χ = (χ : G → ℂ) := by + simp [characterBasis, coe_basisOfLinearIndependentOfCardEqFinrank'] + +noncomputable def characterCoeff {G : Type*} [AddCommGroup G] [Fintype G] + (f : G → ℂ) (χ : AddChar G ℂ) : ℂ := (characterBasis G).repr f χ + +theorem character_expansion {G : Type*} [AddCommGroup G] [Fintype G] (f : G → ℂ) : + ∑ χ : AddChar G ℂ, characterCoeff f χ • (χ : G → ℂ) = f := by + simpa only [characterCoeff, characterBasis_apply] using (characterBasis G).sum_repr f + +theorem wInner_sum_left {ι κ : Type*} [Fintype ι] (s : Finset κ) (w : ι → ℝ) + (f : κ → ι → ℂ) (g : ι → ℂ) : + wInner (𝕜 := ℂ) w (∑ k ∈ s, f k) g = ∑ k ∈ s, wInner (𝕜 := ℂ) w (f k) g := by + induction s using Finset.cons_induction with + | empty => simp + | cons a s ha ih => simp [Finset.sum_cons, wInner_add_left, ih] + +theorem wInner_sum_right {ι κ : Type*} [Fintype ι] (s : Finset κ) (w : ι → ℝ) + (f : ι → ℂ) (g : κ → ι → ℂ) : + wInner (𝕜 := ℂ) w f (∑ k ∈ s, g k) = ∑ k ∈ s, wInner (𝕜 := ℂ) w f (g k) := by + induction s using Finset.cons_induction with + | empty => simp + | cons a s ha ih => simp [Finset.sum_cons, wInner_add_right, ih] + +theorem characterCoeff_eq_wInner {G : Type*} [AddCommGroup G] [Fintype G] + (f : G → ℂ) (χ : AddChar G ℂ) : characterCoeff f χ = ⟪(χ : G → ℂ), f⟫ₙ_[ℂ] := by + classical + conv_rhs => rw [← character_expansion f] + rw [wInner_sum_right] + simp only [wInner_smul_right, smul_eq_mul, AddChar.wInner_cWeight_eq_boole] + simp + +theorem character_parseval_complex {G : Type*} [AddCommGroup G] [Fintype G] (f : G → ℂ) : + (𝔼 x, star (f x) * f x) = ∑ χ : AddChar G ℂ, star (characterCoeff f χ) * characterCoeff f χ := by + have heq : ⟪f, f⟫ₙ_[ℂ] = ∑ χ : AddChar G ℂ, star (characterCoeff f χ) * characterCoeff f χ := by + conv_lhs => arg 2; rw [← character_expansion f] + rw [wInner_sum_left] + simp only [wInner_smul_left, smul_eq_mul, ← characterCoeff_eq_wInner] + simpa only [wInner_cWeight_eq_expect, RCLike.inner_apply, starRingEnd_apply, mul_comm] using heq + +theorem character_parseval {G : Type*} [AddCommGroup G] [Fintype G] (f : G → ℂ) : + (𝔼 x, Complex.normSq (f x)) = ∑ χ : AddChar G ℂ, Complex.normSq (characterCoeff f χ) := by + have h := character_parseval_complex f + apply Complex.ofReal_injective + simpa only [Complex.ofReal_sum, Complex.ofReal_natCast, Complex.ofReal_inv, Complex.ofReal_mul, + Complex.normSq_eq_conj_mul_self, starRingEnd_apply, Fintype.expect_eq_sum_div_card, + Complex.ofReal_div] using h + +theorem characterCoeff_translate {G : Type*} [AddCommGroup G] [Fintype G] + (f : G → ℂ) (a : G) (χ : AddChar G ℂ) : + characterCoeff (fun x => f (x + a)) χ = χ a * characterCoeff f χ := by + classical + have hexp : (fun x => f (x + a)) = + ∑ ψ : AddChar G ℂ, (ψ a * characterCoeff f ψ) • (ψ : G → ℂ) := by + funext x + have h := congrFun (character_expansion f) (x + a) + simpa only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul, AddChar.map_add_eq_mul, + mul_comm, mul_left_comm, mul_assoc] using h.symm + rw [hexp, characterCoeff, map_sum] + simp only [Finsupp.finsetSum_apply, map_smul, Finsupp.smul_apply, smul_eq_mul] + simp only [← characterBasis_apply, Basis.repr_self, Finsupp.single_apply] + simp + +theorem characterCoeff_sub {G : Type*} [AddCommGroup G] [Fintype G] + (f g : G → ℂ) (χ : AddChar G ℂ) : + characterCoeff (f - g) χ = characterCoeff f χ - characterCoeff g χ := by + exact congrArg (fun v => v χ) ((characterBasis G).repr.map_sub f g) + +theorem character_displacement {G : Type*} [AddCommGroup G] [Fintype G] + (f : G → ℂ) (a : G) : + (𝔼 x, Complex.normSq (f (x + a) - f x)) = + ∑ χ : AddChar G ℂ, Complex.normSq (characterCoeff f χ) * Complex.normSq (1 - χ a) := by + have hp := character_parseval ((fun x => f (x + a)) - f) + simp only [Pi.sub_apply, characterCoeff_sub, characterCoeff_translate] at hp + rw [hp] + apply Finset.sum_congr rfl + intro χ _ + have hc : χ a * characterCoeff f χ - characterCoeff f χ = + -(characterCoeff f χ * (1 - χ a)) := by ring + rw [hc, Complex.normSq_neg, Complex.normSq_mul] + +open scoped BigOperators + +def cutDistance {X : Type*} (c : X → Bool) (x y : X) : ℝ := + if c x = c y then 0 else 1 + +@[simp] theorem cutDistance_self {X : Type*} (c : X → Bool) (x : X) : + cutDistance c x x = 0 := by simp [cutDistance] + +theorem cutDistance_nonneg {X : Type*} (c : X → Bool) (x y : X) : + 0 ≤ cutDistance c x y := by unfold cutDistance; split <;> norm_num + +theorem cutDistance_le_one {X : Type*} (c : X → Bool) (x y : X) : + cutDistance c x y ≤ 1 := by unfold cutDistance; split <;> norm_num + +theorem cutDistance_symm {X : Type*} (c : X → Bool) (x y : X) : + cutDistance c x y = cutDistance c y x := by simp [cutDistance, eq_comm] + +def HasCutRepresentation {X : Type*} [Fintype X] (ρ : X → X → ℝ) : Prop := by + classical + exact ∃ a : (X → Bool) → ℝ, (∀ c, 0 ≤ a c) ∧ + ∀ x y, ρ x y = ∑ c : X → Bool, a c * cutDistance c x y + +namespace HasCutRepresentation +variable {X : Type*} [Fintype X] + +theorem zero : HasCutRepresentation (fun _ _ : X => 0) := by + classical + exact ⟨fun _ => 0, fun _ => le_rfl, by simp⟩ + +theorem congr {ρ σ : X → X → ℝ} (h : HasCutRepresentation ρ) + (he : ∀ x y, σ x y = ρ x y) : HasCutRepresentation σ := by + obtain ⟨a, ha, hρ⟩ := h + exact ⟨a, ha, fun x y => (he x y).trans (hρ x y)⟩ + +theorem add {ρ σ : X → X → ℝ} (hρ : HasCutRepresentation ρ) + (hσ : HasCutRepresentation σ) : HasCutRepresentation (fun x y => ρ x y + σ x y) := by + obtain ⟨a, ha, hρ⟩ := hρ + obtain ⟨b, hb, hσ⟩ := hσ + refine ⟨fun c => a c + b c, fun c => add_nonneg (ha c) (hb c), ?_⟩ + intro x y + simp only [add_mul, Finset.sum_add_distrib, ← hρ, ← hσ] + +theorem mul {ρ : X → X → ℝ} (h : HasCutRepresentation ρ) {r : ℝ} (hr : 0 ≤ r) : + HasCutRepresentation (fun x y => r * ρ x y) := by + obtain ⟨a, ha, hρ⟩ := h + refine ⟨fun c => r * a c, fun c => mul_nonneg hr (ha c), ?_⟩ + intro x y + simp only [mul_assoc, ← Finset.mul_sum, ← hρ] + +theorem cut (c : X → Bool) : HasCutRepresentation (cutDistance c) := by + classical + refine ⟨fun d => if d = c then 1 else 0, ?_, ?_⟩ + · intro d; dsimp; split <;> norm_num + · intro x y; simp + +theorem sum {ι : Type*} (s : Finset ι) (ρ : ι → X → X → ℝ) + (h : ∀ i ∈ s, HasCutRepresentation (ρ i)) : + HasCutRepresentation (fun x y => ∑ i ∈ s, ρ i x y) := by + classical + induction s using Finset.cons_induction with + | empty => simpa using (zero (X := X)) + | cons i s hi ih => + have ht := (h i (by simp)).add (ih (fun j hj => h j (by simp [hj]))) + simpa only [Finset.sum_cons] using ht +end HasCutRepresentation + +theorem finite_scalar_cuts {X : Type*} [Fintype X] (s : Finset ℝ) : + ∀ f : X → ℝ, (∀ x, f x ∈ s) → + HasCutRepresentation (fun x y => |f x - f y|) := by + classical + induction s using Finset.induction_on_max with + | empty => + intro f hf + exact HasCutRepresentation.zero.congr (fun x _ => (Finset.notMem_empty _ (hf x)).elim) + | insert a s ha ih => + intro f hf + by_cases hs : s.Nonempty + · let b := s.max' hs + have hb : b ∈ s := Finset.max'_mem s hs + have hba : b < a := ha b hb + let g : X → ℝ := fun x => if f x = a then b else f x + have hg : ∀ x, g x ∈ s := by + intro x + dsimp [g] + split_ifs with h + · exact hb + · exact (Finset.mem_insert.mp (hf x)).resolve_left h + have hle : ∀ x, f x ≠ a → f x ≤ b := by + intro x hx + exact Finset.le_max' s _ ((Finset.mem_insert.mp (hf x)).resolve_left hx) + let c : X → Bool := fun x => decide (f x = a) + have he : ∀ x y, |f x - f y| = |g x - g y| + (a - b) * cutDistance c x y := by + intro x y + by_cases hx : f x = a <;> by_cases hy : f y = a + · simp [g, c, cutDistance, hx, hy] + · have hya := (hle y hy).trans hba.le + simp [g, c, cutDistance, hx, hy, abs_of_nonneg (sub_nonneg.mpr hya), + abs_of_nonneg (sub_nonneg.mpr (hle y hy))] + · have hxa := (hle x hx).trans hba.le + simp [g, c, cutDistance, hx, hy, abs_of_nonpos (sub_nonpos.mpr hxa), + abs_of_nonpos (sub_nonpos.mpr (hle x hx))] + · simp [g, c, cutDistance, hx, hy] + exact ((ih g hg).add ((HasCutRepresentation.cut c).mul (sub_nonneg.mpr hba.le))).congr he + · have hs0 : s = ∅ := Finset.not_nonempty_iff_eq_empty.mp hs + have hfa : ∀ x, f x = a := by simpa [hs0] using hf + exact HasCutRepresentation.zero.congr (by intro x y; simp [hfa]) + +theorem scalar_cuts {X : Type*} [Fintype X] (f : X → ℝ) : + HasCutRepresentation (fun x y => |f x - f y|) := by + classical + exact finite_scalar_cuts (Finset.univ.image f) f (by intro x; simp) + +theorem finite_l1_cuts {X ι : Type*} [Fintype X] [Fintype ι] (f : X → ι → ℝ) : + HasCutRepresentation (fun x y => ∑ i, |f x i - f y i|) := by + exact HasCutRepresentation.sum Finset.univ _ (fun i _ => scalar_cuts (fun x => f x i)) + +theorem spectral_square_inequality {G T : Type*} [AddCommGroup G] [Fintype G] [Fintype T] + (w : G) (a : T → G) (q : T → ℝ) + (hs : ∀ χ : AddChar G ℂ, Complex.normSq (1-χ w) ≤ + ∑ t, q t * Complex.normSq (1-χ (a t))) (f : G → ℂ) : + (𝔼 x, Complex.normSq (f (x+w)-f x)) ≤ + ∑ t, q t * (𝔼 x, Complex.normSq (f (x+a t)-f x)) := by + classical + simp_rw [character_displacement] + calc + _ ≤ ∑ χ : AddChar G ℂ, Complex.normSq (characterCoeff f χ) * + ∑ t, q t * Complex.normSq (1-χ (a t)) := + Finset.sum_le_sum (fun χ _ => mul_le_mul_of_nonneg_left (hs χ) (Complex.normSq_nonneg _)) + _ = _ := by simp_rw [Finset.mul_sum]; rw [Finset.sum_comm]; congr 1; funext t; apply Finset.sum_congr rfl; intro χ _; ring + +theorem spectral_cut_inequality {G T : Type*} [AddCommGroup G] [Fintype G] [Fintype T] + (w : G) (a : T → G) (q : T → ℝ) + (hs : ∀ χ : AddChar G ℂ, Complex.normSq (1-χ w) ≤ + ∑ t, q t * Complex.normSq (1-χ (a t))) (c : G → Bool) : + (𝔼 x, cutDistance c (x+w) x) ≤ ∑ t, q t * (𝔼 x, cutDistance c (x+a t) x) := by + let f : G → ℂ := fun x => if c x then 1 else 0 + have he (x y : G) : Complex.normSq (f x-f y) = cutDistance c x y := by + simp only [f, cutDistance] + cases c x <;> cases c y <;> norm_num + simpa only [he] using spectral_square_inequality w a q hs f + +theorem cut_representation_inequality {G T : Type*} [AddCommGroup G] [Fintype G] [Fintype T] + (w : G) (a : T → G) (q : T → ℝ) (ρ : G → G → ℝ) + (hr : HasCutRepresentation ρ) + (hs : ∀ c : G → Bool, (𝔼 x, cutDistance c (x+w) x) ≤ + ∑ t, q t * (𝔼 x, cutDistance c (x+a t) x)) : + (𝔼 x, ρ (x+w) x) ≤ ∑ t, q t * (𝔼 x, ρ (x+a t) x) := by + classical + obtain ⟨b,hb,hρ⟩ := hr + have he (u : G) : (𝔼 x, ρ (x+u) x) = + ∑ c, b c * (𝔼 x, cutDistance c (x+u) x) := by + simp_rw [hρ, Fintype.expect_eq_sum_div_card, Finset.sum_div, Finset.mul_sum, mul_div_assoc] + exact Finset.sum_comm + simp_rw [he] + calc + _ ≤ ∑ c, b c * ∑ t, q t * (𝔼 x, cutDistance c (x+a t) x) := + Finset.sum_le_sum (fun c _ => mul_le_mul_of_nonneg_left (hs c) (hb c)) + _ = _ := by simp_rw [Finset.mul_sum]; rw [Finset.sum_comm]; congr 1; funext t; apply Finset.sum_congr rfl; intro χ _; ring + + theorem lp_one_norm (f : RealL1) : ‖f‖ = ∑' i, |f i| := by + simpa using lp.norm_eq_tsum_rpow (E := fun _ : ℕ => ℝ) (p := 1) (by norm_num) f + + theorem lp_one_summable (f : RealL1) : Summable (fun i => |f i|) := by + simpa using (lp.memℓp f).summable (show (0:ℝ) < (1:ENNReal).toReal by norm_num) + +theorem spectral_l1_inequality {G T : Type*} [AddCommGroup G] [Fintype G] [Fintype T] + (w : G) (a : T → G) (q : T → ℝ) + (hs : ∀ χ : AddChar G ℂ, Complex.normSq (1-χ w) ≤ + ∑ t, q t * Complex.normSq (1-χ (a t))) (f : G → RealL1) : + (𝔼 x, ‖f (x+w)-f x‖) ≤ ∑ t, q t * (𝔼 x, ‖f (x+a t)-f x‖) := by + classical + let D (u : G) (i : ℕ) := 𝔼 x, |f (x+u) i-f x i| + have hm (u : G) : Summable (D u) := by + dsimp [D] + simp only [Fintype.expect_eq_sum_div_card] + simpa only [lp.coeFn_sub, Pi.sub_apply] using + (summable_sum (fun x (_ : x ∈ (Finset.univ : Finset G)) => lp_one_summable (f (x+u)-f x))).div_const (Fintype.card G : ℝ) + have he (u : G) : (𝔼 x, ‖f (x+u)-f x‖) = ∑' i, D u i := by + simp_rw [lp_one_norm, Fintype.expect_eq_sum_div_card] + rw [← Summable.tsum_finsetSum (fun x _ => lp_one_summable (f (x+u)-f x))] + rw [← tsum_div_const] + simp only [D, Fintype.expect_eq_sum_div_card, lp.coeFn_sub, Pi.sub_apply] + have hi (i : ℕ) : D w i ≤ ∑ t, q t * D (a t) i := + cut_representation_inequality w a q (fun x y => |f x i-f y i|) + (scalar_cuts (fun x => f x i)) (spectral_cut_inequality w a q hs) + rw [he] + apply (Summable.tsum_le_tsum hi (hm w) + (summable_sum (fun t _ => (hm (a t)).mul_left (q t)))).trans_eq + rw [Summable.tsum_finsetSum (fun t _ => (hm (a t)).mul_left (q t))] + simp_rw [tsum_mul_left, ← he] + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/HistogramEmbedding.lean b/lean/OAI/Combinatorics/FiniteCircle/HistogramEmbedding.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ae5bd3385837023fadbdd53d71a83e3d40422c1 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/HistogramEmbedding.lean @@ -0,0 +1,117 @@ +import OAI.Combinatorics.FiniteCircle.Separation + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +theorem histogram_embedding_step {α : Type*} [Fintype α] (a : α) {m M : ℕ} + (hm : 0 < m) (b : ℕ) (F : List.Vector α m → Fin M → ℝ) (Λ : ℝ) (hΛ : 0 ≤ Λ) + (hFlo : ∀ u v, (deficit u.val v.val : ℝ) ≤ coordDist F u v) + (hFhi : ∀ u v, coordDist F u v ≤ Λ * deficit u.val v.val) : + ∃ M' : ℕ, ∃ F' : List.Vector α (b*m) → Fin M' → ℝ, + ∀ x y, (deficit x.val y.val : ℝ) ≤ coordDist F' x y ∧ + coordDist F' x y ≤ (16 * (Nat.log 2 m + 1) * + (b + 16 * Real.log ((m:ℝ)+1) * Λ)) * deficit x.val y.val := by + classical + let X := List.Vector α m + let : DecidableEq X := Classical.decEq X + let Ω := PartitionSpace X + let K := Nat.log 2 m + 1 + have hav (k : Fin K) : 1 ≤ 2^k.val ∧ 2^k.val ≤ m := by + refine ⟨?_, Nat.pow_le_of_le_log hm.ne' (by have := k.isLt; dsimp [K] at *; omega)⟩ + have hp : 0 < 2^k.val := pow_pos (by norm_num) _ + omega + have hp (k : Fin K) := finite_partition (finite_l1_cuts F) (partitionRate (2^k.val)) + (partitionRate_nonneg (2^k.val)) + choose μ label he using hp + let I := (Fin b × Fin K) × (Ω × Ω) + let Φ : List α → I → ℝ := fun x i => + 4 * histMap (μ i.1.2) (label i.1.2) (windowWords a x (i.1.1*m) m (2^i.1.2.val)) i.2 + have hΦ (x y : List α) : coordDist Φ x y = + 4 * ∑ j : Fin b, ∑ k : Fin K, (μ k).expect (fun ω => histDist (label k ω) + (windowWords a x (j*m) m (2^k.val)) (windowWords a y (j*m) m (2^k.val))) := by + unfold coordDist + rw [Fintype.sum_prod_type] + simp only [Φ, ← mul_sub, abs_mul, show |(4:ℝ)| = 4 by norm_num] + simp_rw [← Finset.mul_sum, histMap_distance] + rw [Fintype.sum_prod_type] + have hnonneg (x y : List α) (j : Fin b) (k : Fin K) : + 0 ≤ (μ k).expect (fun ω => histDist (label k ω) + (windowWords a x (j*m) m (2^k.val)) (windowWords a y (j*m) m (2^k.val))) := + (μ k).expect_nonneg (fun _ => histDist_nonneg _ _ _) + have hlo (x y : List.Vector α (b*m)) : (deficit x.val y.val : ℝ) ≤ coordDist Φ x.val y.val := by + have hx (j : Fin b) : (segment x.val (j*m) m).length = m := by + apply length_segment + rw [x.property] + have h := Nat.mul_le_mul_right m (Nat.succ_le_of_lt j.isLt) + simpa only [Nat.succ_mul] using h + have hy (j : Fin b) : (segment y.val (j*m) m).length = m := by + apply length_segment + rw [y.property] + have h := Nat.mul_le_mul_right m (Nat.succ_le_of_lt j.isLt) + simpa only [Nat.succ_mul] using h + have hblock (j : Fin b) : (deficit (segment x.val (j*m) m) (segment y.val (j*m) m) : ℝ) ≤ + 4 * ∑ k : Fin K, (μ k).expect (fun ω => histDist (label k ω) + (windowWords a x.val (j*m) m (2^k.val)) (windowWords a y.val (j*m) m (2^k.val))) := by + let q := deficit (segment x.val (j*m) m) (segment y.val (j*m) m) + by_cases hq : q = 0 + · change (q:ℝ) ≤ _ + rw [hq, Nat.cast_zero] + exact mul_nonneg (by norm_num) (Finset.sum_nonneg (fun k _ => hnonneg x.val y.val j k)) + · have hqm : q ≤ m := by dsimp [q, deficit]; rw [hx]; omega + obtain ⟨k, hs, hsm, hqs, hsq⟩ := exists_separating_scale (Nat.pos_of_ne_zero hq) hqm + have hsep := block_histogram_lower a F hFlo (μ k) (label k) (he k) + (hx j) (hy j) hs hsm hsq + rw [windowWords_segment a x.val hs hsm, windowWords_segment a y.val hs hsm] at hsep + calc + _ = (q:ℝ) := rfl + _ ≤ 4 * (2^k.val : ℕ) := by exact_mod_cast hqs + _ ≤ 4 * (μ k).expect (fun ω => histDist (label k ω) + (windowWords a x.val (j*m) m (2^k.val)) (windowWords a y.val (j*m) m (2^k.val))) := by linarith + _ ≤ _ := mul_le_mul_of_nonneg_left + (Finset.single_le_sum (fun k _ => hnonneg x.val y.val j k) (Finset.mem_univ _)) (by norm_num) + calc + _ ≤ ∑ j : Fin b, (deficit (segment x.val (j*m) m) (segment y.val (j*m) m) : ℝ) := by + exact_mod_cast deficit_le_sum_blocks x.property y.property + _ ≤ ∑ j : Fin b, 4 * ∑ k : Fin K, (μ k).expect (fun ω => histDist (label k ω) + (windowWords a x.val (j*m) m (2^k.val)) (windowWords a y.val (j*m) m (2^k.val))) := + Finset.sum_le_sum (fun j _ => hblock j) + _ = _ := by rw [hΦ, Finset.mul_sum] + have hmove (x y : List α) (hxy : Slide x y) : coordDist Φ x y ≤ + 4*K * (2*b + 32 * Real.log ((m:ℝ)+1) * Λ) := by + rw [hΦ, Finset.sum_comm] + calc + _ ≤ 4 * ∑ k : Fin K, (2*b + 32 * Real.log ((m:ℝ)+1) * Λ) := by + apply mul_le_mul_of_nonneg_left _ (by norm_num) + apply Finset.sum_le_sum + intro k _ + refine (histogram_slide_bound a F Λ hΛ hFhi (μ k) (label k) (he k) hxy b + (hav k).1 (hav k).2).trans ?_ + have hlog : Real.log (((2^k.val : ℕ):ℝ)+1) ≤ Real.log ((m:ℝ)+1) := + Real.log_le_log (by positivity) (by exact_mod_cast Nat.add_le_add_right (hav k).2 1) + gcongr + _ = _ := by simp; ring + let e := Fintype.equivFin I + let F' : List.Vector α (b*m) → Fin (Fintype.card I) → ℝ := fun x i => Φ x.val (e.symm i) + have hdist (x y : List.Vector α (b*m)) : coordDist F' x y = coordDist Φ x.val y.val := + e.symm.sum_comp (fun i => |Φ x.val i - Φ y.val i|) + refine ⟨Fintype.card I, F', fun x y => ⟨?_, ?_⟩⟩ + · rw [hdist] + exact hlo x y + · rw [hdist] + have hp := (exists_slidePath a (x.property.trans y.property.symm)).coordDist_le Φ + (4*K * (2*b + 32 * Real.log ((m:ℝ)+1) * Λ)) hmove + refine hp.trans_eq ?_ + push_cast + dsimp [K] + push_cast + ring + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Histograms.lean b/lean/OAI/Combinatorics/FiniteCircle/Histograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..53ee340f08d45df6ed81a345c809f279126cd6ff --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Histograms.lean @@ -0,0 +1,234 @@ +import OAI.Combinatorics.FiniteCircle.Partitions + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +noncomputable def histogram {X Y : Type*} (label : X → Y) (xs : List X) (y : Y) : ℝ := by + classical + exact (xs.map (fun x => if label x = y then (1 : ℝ) else 0)).sum + +@[simp] theorem histogram_nil {X Y : Type*} (label : X → Y) (y : Y) : + histogram label [] y = 0 := by simp [histogram] + +@[simp] theorem histogram_cons {X Y : Type*} [DecidableEq Y] (label : X → Y) (x : X) (xs : List X) (y : Y) : + histogram label (x :: xs) y = (if label x = y then 1 else 0) + histogram label xs y := by + classical + simp [histogram] + +@[simp] theorem histogram_append {X Y : Type*} (label : X → Y) (xs ys : List X) (y : Y) : + histogram label (xs ++ ys) y = histogram label xs y + histogram label ys y := by + simp [histogram] + +theorem histogram_nonneg {X Y : Type*} (label : X → Y) (xs : List X) (y : Y) : + 0 ≤ histogram label xs y := by + classical + induction xs with + | nil => simp + | cons x xs ih => + rw [histogram_cons] + split <;> linarith + +theorem histogram_mass {X Y : Type*} [Fintype Y] (label : X → Y) (xs : List X) : + ∑ y, histogram label xs y = xs.length := by + classical + induction xs with + | nil => simp + | cons x xs ih => simp [histogram_cons, Finset.sum_add_distrib, ih, Nat.cast_add, add_comm] + +theorem histogram_eq_zero {X Y : Type*} (label : X → Y) (xs : List X) (y : Y) + (h : ∀ x ∈ xs, label x ≠ y) : histogram label xs y = 0 := by + classical + induction xs with + | nil => simp + | cons x xs ih => + simp only [histogram_cons, ite_eq_right (h x (by simp)), zero_add] + exact ih (fun z hz => h z (by simp [hz])) + +noncomputable def histDist {X Y : Type*} [Fintype Y] (label : X → Y) (xs ys : List X) : ℝ := + ∑ y, |histogram label xs y - histogram label ys y| + +@[simp] theorem histDist_self {X Y : Type*} [Fintype Y] (label : X → Y) (xs : List X) : + histDist label xs xs = 0 := by simp [histDist] + +theorem histDist_nonneg {X Y : Type*} [Fintype Y] (label : X → Y) (xs ys : List X) : + 0 ≤ histDist label xs ys := Finset.sum_nonneg (fun _ _ => abs_nonneg _) + +theorem histDist_symm {X Y : Type*} [Fintype Y] (label : X → Y) (xs ys : List X) : + histDist label xs ys = histDist label ys xs := by + unfold histDist + simp only [abs_sub_comm] + +theorem histDist_triangle {X Y : Type*} [Fintype Y] (label : X → Y) (xs ys zs : List X) : + histDist label xs zs ≤ histDist label xs ys + histDist label ys zs := by + unfold histDist + rw [← Finset.sum_add_distrib] + exact Finset.sum_le_sum (fun _ _ => abs_sub_le _ _ _) + +theorem histDist_le_mass {X Y : Type*} [Fintype Y] (label : X → Y) (xs ys : List X) : + histDist label xs ys ≤ xs.length + ys.length := by + calc + _ ≤ ∑ y, (histogram label xs y + histogram label ys y) := by + apply Finset.sum_le_sum + intro y _ + exact abs_sub_le_iff.mpr ⟨by linarith [histogram_nonneg label ys y], + by linarith [histogram_nonneg label xs y]⟩ + _ = _ := by rw [Finset.sum_add_distrib, histogram_mass, histogram_mass] + +theorem histDist_disjoint {X Y : Type*} [Fintype Y] (label : X → Y) (xs ys : List X) + (h : ∀ x ∈ xs, ∀ y ∈ ys, label x ≠ label y) : + histDist label xs ys = xs.length + ys.length := by + classical + calc + _ = ∑ y, (histogram label xs y + histogram label ys y) := by + apply Finset.sum_congr rfl + intro y _ + by_cases he : ∃ x ∈ xs, label x = y + · obtain ⟨x, hx, rfl⟩ := he + rw [histogram_eq_zero label ys _ (fun z hz => Ne.symm (h x hx z hz))] + simp [abs_of_nonneg (histogram_nonneg label xs (label x))] + · rw [histogram_eq_zero label xs _ (fun x hx heq => he ⟨x, hx, heq⟩)] + simp [abs_of_nonneg (histogram_nonneg label ys y)] + _ = _ := by rw [Finset.sum_add_distrib, histogram_mass, histogram_mass] + +theorem histDist_append_le {X Y : Type*} [Fintype Y] (label : X → Y) + (xs ys us vs : List X) : + histDist label (xs ++ us) (ys ++ vs) ≤ histDist label xs ys + histDist label us vs := by + unfold histDist + rw [← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro y _ + simp only [histogram_append] + convert abs_add_le (histogram label xs y - histogram label ys y) + (histogram label us y - histogram label vs y) using 1 + congr 1 + ring + +@[simp] theorem histDist_singleton {X Y : Type*} [Fintype Y] [DecidableEq Y] (label : X → Y) (x y : X) : + histDist label [x] [y] = if label x = label y then 0 else 2 := by + classical + by_cases h : label x = label y + · rw [ite_eq_left h] + unfold histDist + apply Finset.sum_eq_zero + intro z _ + by_cases hz : label y = z <;> simp [histogram, h, hz] + · rw [ite_eq_right h, histDist_disjoint label [x] [y] (by simpa using h)] + norm_num + +theorem histDist_cons_le {X Y : Type*} [Fintype Y] [DecidableEq Y] (label : X → Y) (x y : X) (xs ys : List X) : + histDist label (x :: xs) (y :: ys) ≤ + (if label x = label y then 0 else 2) + histDist label xs ys := by + classical + simpa only [List.singleton_append, histDist_singleton] using histDist_append_le label [x] [y] xs ys + +theorem histogram_mono {X Y : Type*} (label : X → Y) {xs ys : List X} (h : xs <+ ys) (y : Y) : + histogram label xs y ≤ histogram label ys y := by + classical + induction h with + | slnil => exact le_rfl + | cons a h ih => + rw [histogram_cons] + split <;> linarith + | cons_cons a h ih => + rw [histogram_cons, histogram_cons] + by_cases ha : label a = y <;> simp only [ha, ite_true, ite_false] <;> linarith + +theorem histDist_sublist {X Y : Type*} [Fintype Y] (label : X → Y) + {xs ys : List X} (h : xs <+ ys) : histDist label xs ys = ys.length - xs.length := by + unfold histDist + simp only [abs_of_nonpos (sub_nonpos.mpr (histogram_mono label h _))] + simp only [neg_sub, Finset.sum_sub_distrib, histogram_mass] + +theorem histDist_common_sublist_le {X Y : Type*} [Fintype Y] (label : X → Y) + {xs ys zs : List X} (hx : zs <+ xs) (hy : zs <+ ys) : + histDist label xs ys ≤ xs.length + ys.length - 2 * zs.length := by + calc + _ ≤ histDist label xs zs + histDist label zs ys := histDist_triangle _ _ _ _ + _ = _ := by rw [histDist_symm label xs, histDist_sublist label hx, histDist_sublist label hy]; ring + +theorem histDist_ofFn_le {X Y : Type*} [Fintype Y] [DecidableEq Y] + (label : X → Y) {s : ℕ} (f g : Fin s → X) : + histDist label (List.ofFn f) (List.ofFn g) ≤ + 2 * ∑ i, (if label (f i) = label (g i) then (0 : ℝ) else 1) := by + induction s with + | zero => simp [histDist] + | succ s ih => + rw [List.ofFn_succ, List.ofFn_succ, Fin.sum_univ_succ, mul_add] + refine (histDist_cons_le _ _ _ _ _).trans (add_le_add ?_ (ih _ _)) + split <;> norm_num + +noncomputable def histMap {X Ω Y : Type*} [Fintype Ω] (μ : FiniteLaw Ω) + (label : Ω → X → Y) (xs : List X) (i : Ω × Y) : ℝ := + μ.weight i.1 * histogram (label i.1) xs i.2 + +theorem histMap_distance {X Ω Y : Type*} [Fintype Ω] [Fintype Y] + (μ : FiniteLaw Ω) (label : Ω → X → Y) (xs ys : List X) : + ∑ i, |histMap μ label xs i - histMap μ label ys i| = + μ.expect (fun ω => histDist (label ω) xs ys) := by + simp only [histMap, ← mul_sub, abs_mul, abs_of_nonneg (μ.nonneg _), + Fintype.sum_prod_type, FiniteLaw.expect, histDist, Finset.mul_sum] + +theorem expect_histDist_ofFn_le {X Ω Y : Type*} [Fintype Ω] [Fintype Y] + (μ : FiniteLaw Ω) (label : Ω → X → Y) {s : ℕ} (f g : Fin s → X) + (p : ℝ) (hp : ∀ i, μ.event (fun ω => label ω (f i) ≠ label ω (g i)) ≤ p) : + μ.expect (fun ω => histDist (label ω) (List.ofFn f) (List.ofFn g)) ≤ 2 * s * p := by + classical + calc + _ ≤ μ.expect (fun ω => 2 * ∑ i, if label ω (f i) = label ω (g i) then 0 else 1) := + μ.expect_mono (fun _ => histDist_ofFn_le _ _ _) + _ = 2 * ∑ i, μ.event (fun ω => label ω (f i) ≠ label ω (g i)) := by + rw [μ.expect_smul, μ.expect_sum] + congr 1 + apply Finset.sum_congr rfl + intro i _ + rw [FiniteLaw.event_eq_expect] + congr 1 + funext ω + split <;> simp_all + _ ≤ 2 * ∑ _i : Fin s, p := mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => hp i)) (by norm_num) + _ = _ := by simp; ring + +theorem expect_histDist_ofFn_ge {X Ω Y : Type*} [Fintype Ω] [Fintype Y] + (μ : FiniteLaw Ω) (label : Ω → X → Y) {s : ℕ} (f g : Fin s → X) + (p : ℝ) (hp : ∀ i j, μ.event (fun ω => label ω (f i) = label ω (g j)) ≤ p) + (hsp : (s : ℝ)^2 * p ≤ 1 / 2) : + (s : ℝ) ≤ μ.expect (fun ω => histDist (label ω) (List.ofFn f) (List.ofFn g)) := by + classical + let Collision := fun ω => ∃ ij : Fin s × Fin s, label ω (f ij.1) = label ω (g ij.2) + have hc : μ.event Collision ≤ 1 / 2 := by + calc + _ ≤ ∑ ij : Fin s × Fin s, μ.event (fun ω => label ω (f ij.1) = label ω (g ij.2)) := + μ.event_exists_le_sum _ + _ ≤ ∑ _ij : Fin s × Fin s, p := Finset.sum_le_sum (fun ij _ => hp ij.1 ij.2) + _ = (s : ℝ)^2 * p := by simp [sq, mul_assoc] + _ ≤ _ := hsp + have hn : 1 / 2 ≤ μ.event (fun ω => ¬Collision ω) := by rw [μ.event_compl]; linarith + have hd : 2 * s * μ.event (fun ω => ¬Collision ω) ≤ + μ.expect (fun ω => histDist (label ω) (List.ofFn f) (List.ofFn g)) := by + rw [FiniteLaw.event_eq_expect, ← μ.expect_smul] + apply μ.expect_mono + intro ω + by_cases h : Collision ω + · simp only [ite_eq_right (not_not_intro h), mul_zero] + exact histDist_nonneg _ _ _ + · rw [ite_eq_left h, mul_one] + have hdis : ∀ x ∈ List.ofFn f, ∀ y ∈ List.ofFn g, label ω x ≠ label ω y := by + intro x hx y hy heq + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp hx + obtain ⟨j, rfl⟩ := List.mem_ofFn.mp hy + exact h ⟨(i,j), heq⟩ + rw [histDist_disjoint _ _ _ hdis] + simp only [List.length_ofFn] + linarith + have hs : (0 : ℝ) ≤ s := Nat.cast_nonneg s + nlinarith + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Lower.lean b/lean/OAI/Combinatorics/FiniteCircle/Lower.lean new file mode 100644 index 0000000000000000000000000000000000000000..2526fd9c14a638a0f689b26d5adad8280f526a04 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Lower.lean @@ -0,0 +1,168 @@ +import OAI.Combinatorics.FiniteCircle.Codes + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +def lowerCap (n : ℕ) : ℕ := (n^4)^(32*(n^4)^2) + + theorem lowerCap_ge (n : ℕ) : n≤lowerCap n := by + by_cases hn : n=0 + · subst n; exact Nat.zero_le _ + have hn1 : 1≤n := by omega + exact (le_self_pow₀ hn1 (by norm_num) : n≤n^4).trans + (le_self_pow₀ (one_le_pow₀ hn1) (by simp [hn]) : n^4≤(n^4)^(32*(n^4)^2)) + + theorem lower_parameter (d : ℕ) (hd : lowerCap 1000000≤d) : + ∃ q : ℕ, 500000≤q ∧ lowerCap (2*q)≤d ∧ d lowerCap (2*q)≤d + let q := Nat.findGreatest P d + have h0 : 500000≤d := by have := lowerCap_ge 1000000; omega + have hp : P 500000 := hd + have hq : 500000≤q := by + by_contra hn + have ht := Nat.findGreatest_is_greatest (P:=P) (show q<500000 by omega) h0 + exact ht hp + refine ⟨q,hq,Nat.findGreatest_spec h0 hp,?_⟩ + by_contra hn + have hnext : P (q+1) := by dsimp [P]; omega + have hb : q+1≤d := by have := lowerCap_ge (2*(q+1)); dsimp [P] at hnext; omega + exact Nat.findGreatest_is_greatest (P:=P) (show q hxy (hg h),by simp only [Function.comp_apply,he]⟩ + have hl : sSup (lowerRates wordX (f ∘ g)) ≤ sSup (lowerRates wordY f) := by + apply Real.sSup_le _ (lowerRates_sup_nonneg wordY f) + rintro r ⟨x,y,hxy,rfl⟩ + apply le_csSup (lowerRates_finite wordY f).bddAbove + exact ⟨g x,g y,fun h => hxy (hg h),by simp only [Function.comp_apply,he]⟩ + exact mul_le_mul hu hl (lowerRates_sup_nonneg wordX (f ∘ g)) (upperRates_sup_nonneg wordY f) + + theorem optimalDistortion_isometry_mono {α β X Y : Type*} [Fintype Y] + (wordX : X → List α) (wordY : Y → List β) (g : X → Y) (hg : Function.Injective g) + (he : ∀ x y, editDistance (wordY (g x)) (wordY (g y)) = editDistance (wordX x) (wordX y)) : + optimalDistortion wordX ≤ optimalDistortion wordY := by + apply optimalDistortion_lower + intro f hf + exact (optimalDistortion_le wordX (f ∘ g) (hf.comp hg)).trans + (distortion_isometry_restrict wordX wordY g hg he f) + +instance wordsFinite (α : Type*) [Finite α] (d : ℕ) : Finite (Words α d) := + (List.finite_length_le α d).to_subtype + + theorem words_nontrivial (α : Type*) [Nonempty α] {d : ℕ} (hd : 1≤d) : Nontrivial (Words α d) := by + classical + let a : α := Classical.ofNonempty + refine ⟨⟨⟨[],by simp⟩,⟨[a],by simpa using hd⟩,?_⟩⟩ + intro he + have ht := congrArg (fun x : Words α d => x.val.length) he + simp at ht + + theorem binary_alphabet_embedding (α : Type*) [Fintype α] (hα : 2≤Fintype.card α) : + ∃ (f : Bool → α) (g : α → Bool), Function.LeftInverse g f := by + classical + let : Nontrivial α := Fintype.one_lt_card_iff_nontrivial.mp hα + obtain ⟨a,b,hab⟩ := exists_pair_ne α + refine ⟨fun t => cond t b a,fun x => decide (x=b),?_⟩ + intro t + cases t <;> simp [hab] + + theorem setDistortion_le_E (α : Type*) [Fintype α] (hα : 2≤Fintype.card α) + {S : Set (List Bool)} {d : ℕ} (hS : ∀ x∈S, x.length≤d) : setDistortion S≤E α d := by + classical + let : Fintype (Words α d) := Fintype.ofFinite _ + obtain ⟨f,g,hgf⟩ := binary_alphabet_embedding α hα + let e : S → Words α d := fun x => ⟨x.val.map f,by simpa using hS x.val x.property⟩ + have he : Function.Injective e := by + intro x y hxy + exact Subtype.ext (hgf.injective.list_map (congrArg Subtype.val hxy)) + apply optimalDistortion_isometry_mono (fun x : S => x.val) (fun x : Words α d => x.val) e he + intro x y + exact editDistance_map_eq f g hgf x.val y.val + + theorem maskWitness_lower_E {a C δ c : ℝ} {d : ℕ} (hw : MaskWitness a C δ c d) + (α : Type*) [Fintype α] (hα : 2≤Fintype.card α) : Real.exp (c*exponentScale d)≤E α d := by + rcases hw with ⟨h,_,p,_,w,code,_,_,n,_,hnd,hlen,hD⟩ + apply hD.trans (setDistortion_le_E α hα _) + rintro x ⟨v,rfl⟩ + exact (hlen v).le.trans hnd + + theorem uniformUpper_E {C : ℝ} {d₀ : ℕ} (hu : UniformUpper C d₀) + (α : Type) [Fintype α] (hα : 2≤Fintype.card α) {d : ℕ} (hd : d₀≤d) (hd1 : 1≤d) : + E α d≤Real.exp (C*exponentScale d) := by + classical + let : Nontrivial α := Fintype.one_lt_card_iff_nontrivial.mp hα + let : Nontrivial (Words α d) := words_nontrivial α hd1 + obtain ⟨M,F,hF⟩ := hu α hα d hd + let f : Words α d → RealL1 := fun x => finiteL1 M (F x) + have hb := distortion_upper (fun x : Words α d => x.val) Subtype.val_injective + f (Real.exp (C*exponentScale d)) 1 (Real.exp_pos _).le + (fun x y => by simpa only [f,finiteL1_norm_sub] using (hF x y).2) + (fun x y => by simpa only [f,one_mul,finiteL1_norm_sub] using (hF x y).1) + exact (optimalDistortion_le (fun x : Words α d => x.val) f hb.1).trans (by simpa only [mul_one] using hb.2) + + theorem alphabetSupremum_bounds {d : ℕ} {lo hi : ℝ} + (hb : ∀ A : ℕ, 2≤A → lo≤E (Fin A) d ∧ E (Fin A) d≤hi) : + lo≤alphabetSupremum d ∧ alphabetSupremum d≤hi := by + have hne : {r : ℝ | ∃ A : ℕ, 2≤A ∧ r=E (Fin A) d}.Nonempty := ⟨_,2,by norm_num,rfl⟩ + have hub : BddAbove {r : ℝ | ∃ A : ℕ, 2≤A ∧ r=E (Fin A) d} := by + refine ⟨hi,?_⟩ + rintro r ⟨A,hA,rfl⟩ + exact (hb A hA).2 + refine ⟨(hb 2 (by norm_num)).1.trans (le_csSup hub ⟨2,by norm_num,rfl⟩),?_⟩ + apply csSup_le hne + rintro r ⟨A,hA,rfl⟩ + exact (hb A hA).2 + +theorem full_main : FullMain := by + obtain ⟨u,hu⟩ := uniform_upper + let d₀ := max u (lowerCap 1000000) + have hlow {d : ℕ} (hd : d₀≤d) : lowerCap 1000000≤d := (le_max_right _ _).trans hd + have hu' : UniformUpper 32 d₀ := by + intro α _ hα d hd + exact hu α hα d ((le_max_left _ _).trans hd) + have hb : ∀ (α : Type) [Fintype α], 2≤Fintype.card α → ∀ d : ℕ, d₀≤d → + Real.exp ((1/8192)*exponentScale d)≤E α d ∧ E α d≤Real.exp (32*exponentScale d) := by + intro α _ hα d hd + have hd1 : 1≤d := by have := lowerCap_ge 1000000; have := hlow hd; omega + exact ⟨maskWitness_lower_E (both_witnesses (hlow hd)).1 α hα, + uniformUpper_E hu' α hα hd hd1⟩ + refine ⟨1/8192,32,1/268435456,67108928,1/1048576,1/1048576,d₀, + by norm_num,by norm_num,by norm_num,by norm_num,by norm_num,by norm_num, + two_codes,hu',hb,?_⟩ + intro d hd + have hw := both_witnesses (hlow hd) + refine ⟨hw.1,hw.2,?_⟩ + exact alphabetSupremum_bounds (fun A hA => hb (Fin A) (by simpa using hA) d hd) + +end FiniteCircle + +theorem finiteCircle_fullMain : FiniteCircle.FullMain := FiniteCircle.full_main + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/MaskBranching.lean b/lean/OAI/Combinatorics/FiniteCircle/MaskBranching.lean new file mode 100644 index 0000000000000000000000000000000000000000..b38c8cdcbfb3686c0f4e47780c3eb6a15156cef6 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/MaskBranching.lean @@ -0,0 +1,171 @@ +import OAI.Combinatorics.FiniteCircle.DyadicShifts + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem few_large_prime_divisors {h : ℕ} (hh : 2 ≤ h) + {ι : Type*} [Fintype ι] [DecidableEq ι] (p : ι → ℕ) + (hp : ∀ i, Nat.Prime (p i)) (hinj : Function.Injective p) + (hlarge : ∀ i, h ^ 3 ≤ p i) {β : ℤ} (hβ : β ≠ 0) + (hsmall : β.natAbs < h ^ h) : + 3 * ((Finset.univ.filter fun i => (p i : ℤ) ∣ β).card) < h := by + let s := Finset.univ.filter fun i => (p i : ℤ) ∣ β + have hdvd : (∏ i ∈ s, p i) ∣ β.natAbs := by + have heq : (∏ q ∈ s.image p, q) = ∏ i ∈ s, p i := + Finset.prod_image (fun _ _ _ _ hij => hinj hij) + rw [← heq] + apply Finset.prod_primes_dvd + · intro q hq + obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hq + exact (hp i).prime + · intro q hq + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hq + exact Int.natCast_dvd.mp (Finset.mem_filter.mp hi).2 + have hprod : h ^ (3 * s.card) ≤ β.natAbs := by + calc + h ^ (3 * s.card) = ∏ i ∈ s, h ^ 3 := by simp [pow_mul] + _ ≤ ∏ i ∈ s, p i := Finset.prod_le_prod (fun i _ => hlarge i) + _ ≤ β.natAbs := Nat.le_of_dvd (Int.natAbs_pos.mpr hβ) hdvd + by_contra hn + have hge : h ≤ 3 * s.card := Nat.le_of_not_gt hn + have : h ^ h ≤ h ^ (3 * s.card) := Nat.pow_le_pow_right (by omega) hge + omega + +theorem many_mask_children {h : ℕ} (hh : 2 ≤ h) (p : Fin h → ℕ) + (hp : ∀ i, Nat.Prime (p i)) (hinj : Function.Injective p) + (hlarge : ∀ i, h ^ 3 ≤ p i) (f : (Σ k : Fin h, Fin (p k)) → ℤ) + {β : ℤ} (hβ : β ≠ 0) (hsmall : β.natAbs < h ^ h) + (hc : ∀ k, (p k : ℤ) ∣ β + ∑ b : Fin (p k), (b.val : ℤ) * f ⟨k, b⟩) : + h ≤ 2 * (Finset.univ.filter fun j => f j ≠ 0).card := by + classical + let s := Finset.univ.filter fun j => f j ≠ 0 + let t := Finset.univ.filter fun k => ¬ (p k : ℤ) ∣ β + let q := Finset.univ.filter fun k => (p k : ℤ) ∣ β + have hq : 3 * q.card < h := few_large_prime_divisors hh p hp hinj hlarge hβ hsmall + have ht : t ⊆ s.image Sigma.fst := by + intro k hk + have hk' : ¬ (p k : ℤ) ∣ β := (Finset.mem_filter.mp hk).2 + have hex : ∃ b : Fin (p k), f ⟨k, b⟩ ≠ 0 := by + by_contra hn + push Not at hn + have hc' := hc k + simp only [hn, mul_zero, Finset.sum_const_zero, add_zero] at hc' + exact hk' hc' + obtain ⟨b, hb⟩ := hex + exact Finset.mem_image.mpr ⟨⟨k, b⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hb⟩, rfl⟩ + have hcard : t.card ≤ s.card := + (Finset.card_le_card ht).trans (Finset.card_image_le) + have hcount : q.card + t.card = h := by + simpa [q, t] using (Finset.card_filter_add_card_filter_not + (s := (Finset.univ : Finset (Fin h))) (fun k => (p k : ℤ) ∣ β)) + change h ≤ 2 * s.card + omega + +def FrequencyTree (J : ℕ → Type) : ℕ → Type _ + | 0 => ℤ + | l + 1 => J (l + 1) → FrequencyTree J l + +noncomputable def frequencySum (J : ℕ → Type) [∀ l, Fintype (J l)] : + (l : ℕ) → FrequencyTree J l → ℤ + | 0, t => t + | l + 1, t => ∑ j, frequencySum J l (t j) + +noncomputable def frequencyMass (J : ℕ → Type) [∀ l, Fintype (J l)] : + (l : ℕ) → FrequencyTree J l → ℕ + | 0, t => (show ℤ from t).natAbs + | l + 1, t => ∑ j, frequencyMass J l (t j) + +theorem frequencySum_natAbs_le_mass (J : ℕ → Type) [∀ l, Fintype (J l)] + (l : ℕ) (t : FrequencyTree J l) : + (frequencySum J l t).natAbs ≤ frequencyMass J l t := by + induction l with + | zero => exact le_rfl + | succ l ih => + exact (Int.natAbs_sum_le _ _).trans (Finset.sum_le_sum fun j _ => ih (t j)) + +def MaskChildren (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) := Σ k : Fin h, Fin (p l k) + +instance maskChildrenFintype (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) : + Fintype (MaskChildren h p l) := inferInstanceAs (Fintype (Σ k : Fin h, Fin (p l k))) + +noncomputable def MaskCongruences (h : ℕ) (p : ℕ → ℕ → ℕ) : + (l : ℕ) → FrequencyTree (MaskChildren h p) l → Prop + | 0, _ => True + | l + 1, t => + (∀ k : Fin h, (p (l + 1) k : ℤ) ∣ frequencySum (MaskChildren h p) (l + 1) t + + ∑ b : Fin (p (l + 1) k), (b.val : ℤ) * frequencySum (MaskChildren h p) l (t ⟨k, b⟩)) ∧ + ∀ j, MaskCongruences h p l (t j) + +theorem mask_branching_induction {h : ℕ} (hh : 2 ≤ h) (p : ℕ → ℕ → ℕ) + (hp : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → Nat.Prime (p l k)) + (hinj : ∀ l, 1 ≤ l → l ≤ h → Function.Injective (fun k : Fin h => p l k)) + (hlarge : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → h ^ 3 ≤ p l k) + (l : ℕ) (hl : l ≤ h) (t : FrequencyTree (MaskChildren h p) l) + (hc : MaskCongruences h p l t) + (hroot : frequencySum (MaskChildren h p) l t ≠ 0) + (hsmall : frequencyMass (MaskChildren h p) l t < h ^ h) : + ((h : ℝ) / 2) ^ l ≤ (frequencyMass (MaskChildren h p) l t : ℝ) := by + classical + induction l with + | zero => + have : 1 ≤ frequencyMass (MaskChildren h p) 0 t := + (Int.natAbs_pos.mpr hroot).trans_le (frequencySum_natAbs_le_mass _ _ _) + simpa using (show (1 : ℝ) ≤ frequencyMass (MaskChildren h p) 0 t by exact_mod_cast this) + | succ l ih => + let f : MaskChildren h p (l + 1) → ℤ := fun j => frequencySum (MaskChildren h p) l (t j) + let s := Finset.univ.filter fun j => f j ≠ 0 + have hsumSmall : (frequencySum (MaskChildren h p) (l + 1) t).natAbs < h ^ h := + (frequencySum_natAbs_le_mass _ _ _).trans_lt hsmall + have hcard : h ≤ 2 * s.card := + many_mask_children hh (fun k => p (l + 1) k) + (fun k => hp _ k (by omega) hl) (hinj _ (by omega) hl) + (fun k => hlarge _ k (by omega) hl) f hroot hsumSmall hc.1 + have hchild : ∀ j, frequencyMass (MaskChildren h p) l (t j) < h ^ h := by + intro j + apply lt_of_le_of_lt _ hsmall + change frequencyMass (MaskChildren h p) l (t j) ≤ ∑ j, frequencyMass (MaskChildren h p) l (t j) + exact Finset.single_le_sum (f := fun j => frequencyMass (MaskChildren h p) l (t j)) + (fun _ _ => Nat.zero_le _) (Finset.mem_univ j) + have hm : ∀ j ∈ s, ((h : ℝ) / 2) ^ l ≤ frequencyMass (MaskChildren h p) l (t j) := by + intro j hj + exact ih (by omega) (t j) (hc.2 j) (Finset.mem_filter.mp hj).2 (hchild j) + have hcardR : (h : ℝ) / 2 ≤ s.card := by + have : (h : ℝ) ≤ 2 * (s.card : ℝ) := by exact_mod_cast hcard + linarith + calc + ((h : ℝ) / 2) ^ (l + 1) = ((h : ℝ) / 2) * ((h : ℝ) / 2) ^ l := by ring + _ ≤ s.card * ((h : ℝ) / 2) ^ l := mul_le_mul_of_nonneg_right hcardR (by positivity) + _ = ∑ j ∈ s, ((h : ℝ) / 2) ^ l := by simp + _ ≤ ∑ j ∈ s, (frequencyMass (MaskChildren h p) l (t j) : ℝ) := Finset.sum_le_sum hm + _ ≤ ∑ j, (frequencyMass (MaskChildren h p) l (t j) : ℝ) := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) (fun _ _ _ => by positivity) + _ = (frequencyMass (MaskChildren h p) (l + 1) t : ℝ) := by + simp only [frequencyMass, Nat.cast_sum] + +theorem mask_frequency_branching {h : ℕ} (hh : 2 ≤ h) (p : ℕ → ℕ → ℕ) + (hp : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → Nat.Prime (p l k)) + (hinj : ∀ l, 1 ≤ l → l ≤ h → Function.Injective (fun k : Fin h => p l k)) + (hlarge : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → h ^ 3 ≤ p l k) + (t : FrequencyTree (MaskChildren h p) h) (hc : MaskCongruences h p h t) + (hroot : frequencySum (MaskChildren h p) h t ≠ 0) : + ((h : ℝ) / 2) ^ h ≤ (frequencyMass (MaskChildren h p) h t : ℝ) := by + by_contra hn + have hlt := lt_of_not_ge hn + have hcap : ((h : ℝ) / 2) ^ h ≤ (h : ℝ) ^ h := by + apply pow_le_pow_left₀ (by positivity) + have : (0 : ℝ) ≤ h := Nat.cast_nonneg h + linarith + have hsmall : frequencyMass (MaskChildren h p) h t < h ^ h := by + exact_mod_cast hlt.trans_le hcap + exact (not_lt_of_ge (mask_branching_induction hh p hp hinj hlarge h le_rfl t hc hroot hsmall)) hlt + +attribute [reducible] MaskChildren + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/MaskDescent.lean b/lean/OAI/Combinatorics/FiniteCircle/MaskDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..1036251bc722b9bd3784fbfafdaf1fcec47fc5e8 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/MaskDescent.lean @@ -0,0 +1,270 @@ +import OAI.Combinatorics.FiniteCircle.ExcludedSeparation + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +def PhaseSupported {G : Type*} [AddCommGroup G] (S : Finset ℕ) (x : G) : Prop := + (∏ q ∈ S, q) • x = 0 + + theorem primes_coprime_prod {S A : Finset ℕ} + (hS : ∀ q ∈ S, q.Prime) (hA : ∀ q ∈ A, q.Prime) (hdis : Disjoint S A) : + (∏ q ∈ S, q).Coprime (∏ q ∈ A, q) := by + apply Nat.Coprime.prod_left + intro q hq + apply Nat.Coprime.prod_right + intro r hr + apply (hS q hq).coprime_iff_not_dvd.mpr + intro hd + have he : q = r := (Nat.prime_dvd_prime_iff_eq (hS q hq) (hA r hr)).mp hd + exact Finset.disjoint_left.mp hdis hq (he.symm ▸ hr) + + theorem nsmul_zero_of_dvd {G : Type*} [AddCommGroup G] {n m : ℕ} {x : G} + (h : n ∣ m) (hx : n • x = 0) : m • x = 0 := by + obtain ⟨a,rfl⟩ := h + rw [mul_nsmul, hx, nsmul_zero] + + theorem PhaseSupported.mono {G : Type*} [AddCommGroup G] {S A : Finset ℕ} + {x : G} (hx : PhaseSupported S x) (h : S ⊆ A) : PhaseSupported A x := + nsmul_zero_of_dvd (Finset.prod_dvd_prod_of_subset S A id h) hx + + theorem PhaseSupported.add {G : Type*} [AddCommGroup G] {S A : Finset ℕ} + {x y : G} (hx : PhaseSupported S x) (hy : PhaseSupported A y) : + PhaseSupported (S ∪ A) (x+y) := by + have hx' := hx.mono (show S ⊆ S ∪ A from Finset.subset_union_left) + have hy' := hy.mono (show A ⊆ S ∪ A from Finset.subset_union_right) + change _ • (x+y) = 0 + rw [nsmul_add, hx', hy', add_zero] + + theorem phase_add_supported_ne_zero {G : Type*} [AddCommGroup G] {S A : Finset ℕ} + {x y : G} (hx : PhaseSupported S x) (hy : PhaseSupported A y) + (hS : ∀ q ∈ S, q.Prime) (hA : ∀ q ∈ A, q.Prime) (hdis : Disjoint S A) + (hne : x ≠ 0) : x+y ≠ 0 := + add_ne_zero_of_coprime_orders (primes_coprime_prod hS hA hdis) hne hx hy + + theorem support_subcircle {M p : ℕ} (hp : p ∣ M) (z : ZMod p) : + PhaseSupported {p} (subcircle hp z) := by + simp only [PhaseSupported, Finset.prod_singleton, ← map_nsmul] + rw [nsmul_eq_mul] + simp + + theorem support_mask_sum {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ k : Fin h, p l k ∣ M) (z : MaskResidues h p l) : + PhaseSupported ((Finset.univ.filter (fun k : Fin h => z k ≠ 0)).image (fun k : Fin h => p l k)) + (∑ k, subcircle (hd k) (z k)) := by + classical + unfold PhaseSupported + rw [Finset.smul_sum] + apply Finset.sum_eq_zero + intro k _ + by_cases hz : z k = 0 + · simp [hz] + · apply nsmul_zero_of_dvd + · exact Finset.dvd_prod_of_mem _ (Finset.mem_image.mpr ⟨k, by simp [hz], rfl⟩) + · simpa only [PhaseSupported, Finset.prod_singleton] using support_subcircle (hd k) (z k) + + theorem circleCost_support_lower {M h K : ℕ} [NeZero M] (hh : 1 ≤ h) + {S : Finset ℕ} (hS : ∀ q ∈ S, q.Prime ∧ q ≤ h^4) (hcard : S.card ≤ K) + {x : ZMod M} (hx : x ≠ 0) (hs : PhaseSupported S x) : + 1 / ((h:ℝ)^(4*K)) ≤ circleCost x := by + let Q := ∏ q ∈ S, q + have hQ : 0 < Q := Finset.prod_pos (fun q hq => (hS q hq).1.pos) + have hQu : Q ≤ h^(4*K) := by + calc + Q ≤ ∏ _q ∈ S, h^4 := Finset.prod_le_prod (fun q hq => (hS q hq).2) + _ = h^(4*S.card) := by simp only [Finset.prod_const]; rw [← pow_mul] + _ ≤ _ := Nat.pow_le_pow_right hh (by omega) + have he := circleCost_order_lower hQ hx hs + have hp : (0:ℝ) < h := by exact_mod_cast (show 0 < h by omega) + rw [div_le_iff₀ (pow_pos hp _)] + have hc := circleCost_nonneg x + have hQu' : (Q:ℝ) ≤ (h:ℝ)^(4*K) := by exact_mod_cast hQu + nlinarith + +def resetBudget (K T n l : ℕ) : ℕ := (n + l*T + K - 2) / (K-1) + + theorem resetBudget_mono {K T n m l r : ℕ} (h : n+l*T ≤ m+r*T) : + resetBudget K T n l ≤ resetBudget K T m r := by + unfold resetBudget + exact Nat.div_le_div_right (by omega) + + theorem resetBudget_overflow {K T n s l : ℕ} (hK : 2 ≤ K) + (hs : s < T) (hover : K < n+s) : + resetBudget K T 1 l + 1 ≤ resetBudget K T n (l+1) := by + have hstep : 1+l*T+K-2+(K-1) ≤ n+(l+1)*T+K-2 := by + rw [Nat.add_mul] + omega + have hdiv := Nat.div_le_div_right (c := K-1) hstep + rw [Nat.add_div_right _ (by omega : 0 < K-1)] at hdiv + exact hdiv + +noncomputable def descentBound (h K T n l : ℕ) : ℝ := + 1 / ((4:ℝ)^l * (T:ℝ)^(l+resetBudget K T n l) * (h:ℝ)^(4*K)) + + theorem descentBound_pos {h K T n l : ℕ} (hh : 0 < h) (hT : 0 < T) : + 0 < descentBound h K T n l := by + unfold descentBound + positivity + + theorem descentBound_step {h K T n m l e : ℕ} (hh : 0 < h) (hT : 1 ≤ T) + (he : l + resetBudget K T m l + e ≤ l+1 + resetBudget K T n (l+1)) : + descentBound h K T n (l+1) ≤ + (1/(4*(T:ℝ)^e))*descentBound h K T m l := by + have ht : (1:ℝ) ≤ T := by exact_mod_cast hT + have hp : (0:ℝ) < h := by exact_mod_cast hh + have hlu : (T:ℝ)^(l + resetBudget K T m l + e) ≤ + (T:ℝ)^(l+1 + resetBudget K T n (l+1)) := pow_le_pow_right₀ ht he + unfold descentBound + rw [one_div_mul_one_div] + apply one_div_le_one_div_of_le + · positivity + · calc + 4*(T:ℝ)^e*((4:ℝ)^l*(T:ℝ)^(l+resetBudget K T m l)*(h:ℝ)^(4*K)) = + (4:ℝ)^(l+1)*(T:ℝ)^(l+resetBudget K T m l+e)*(h:ℝ)^(4*K) := by + rw [pow_succ, pow_add]; ring + _ ≤ _ := by gcongr + + theorem support_card_pos {G : Type*} [AddCommGroup G] {S : Finset ℕ} + {x : G} (hx : x ≠ 0) (hs : PhaseSupported S x) : 0 < S.card := by + by_contra h + have he : S = ∅ := Finset.card_eq_zero.mp (by omega) + subst S + exact hx (by simpa [PhaseSupported] using hs) + +def LowerFresh (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) (S : Finset ℕ) : Prop := + ∀ j : ℕ, 1 ≤ j → j ≤ l → ∀ k : Fin h, p j k ∉ S + + theorem descentBound_base {h K T n : ℕ} (hh : 0 < h) (hT : 1 ≤ T) : + descentBound h K T n 0 ≤ 1/(h:ℝ)^(4*K) := by + have ht : (1:ℝ) ≤ T := by exact_mod_cast hT + have hp : (0:ℝ) < h := by exact_mod_cast hh + unfold descentBound + simp only [pow_zero, one_mul, zero_add] + apply one_div_le_one_div_of_le (by positivity) + exact le_mul_of_one_le_left (by positivity) (one_le_pow₀ ht) + +theorem mask_denominator_descent {h H M K T : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hT : 2 ≤ T) (hhT : h ≤ T^2) (hTh : 2*T ≤ h) (hK : 2 ≤ K) + (hd : ∀ j (k : Fin h), p j k ∣ M) (hn : ∀ j (k : Fin h), 0 < p j k) + (hp : ∀ j, 1 ≤ j → j ≤ H → ∀ k : Fin h, (p j k).Prime) + (hlo : ∀ j, 1 ≤ j → j ≤ H → ∀ k : Fin h, h^3 ≤ p j k) + (hhi : ∀ j, 1 ≤ j → j ≤ H → ∀ k : Fin h, p j k ≤ 2*h^3) + (hlevel : ∀ j r, 1 ≤ j → j ≤ H → 1 ≤ r → r ≤ H → j ≠ r → + ∀ k t : Fin h, p j k ≠ p r t) : + ∀ l, l ≤ H → ∀ (S : Finset ℕ) (x : ZMod M), + S.card ≤ K → (∀ q ∈ S, q.Prime ∧ q ≤ h^4) → LowerFresh h p l S → + x ≠ 0 → PhaseSupported S x → + descentBound h K T S.card l ≤ maskCost h p M hd hn l x := by + classical + have hh : 0 < h := by omega + have hh2 : 2 ≤ h := by omega + have hTp : 0 < T := by omega + have hin (j : ℕ) (hj : 1 ≤ j) (hjH : j ≤ H) (k : Fin h) : p j k ≤ h^4 := by + calc + p j k ≤ 2*h^3 := hhi j hj hjH k + _ ≤ h*h^3 := Nat.mul_le_mul_right _ hh2 + _ = h^4 := by ring + intro l + induction l with + | zero => + intro _ S x hcard hS _ hx hs + exact (descentBound_base hh (by omega)).trans + (circleCost_support_lower (by omega) hS hcard hx hs) + | succ l ih => + intro hlH S x hcard hS hfresh hx hs + let : ∀ k : Fin h, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + let f := maskCost h p M hd hn l + obtain ⟨z, hact, hinact⟩ := mask_minimizer_options hh (hd (l+1)) + (hp (l+1) (by omega) hlH) (hlo (l+1) (by omega) hlH) + (hhi (l+1) (by omega) hlH) f x + let A := Finset.univ.filter (fun k : Fin h => z k ≠ 0) + let P := A.image (fun k : Fin h => p (l+1) k) + have hpP (q : ℕ) (hq : q ∈ P) : q.Prime ∧ q ≤ h^4 := by + obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp hq + exact ⟨hp (l+1) (by omega) hlH k, hin (l+1) (by omega) hlH k⟩ + have hfreshP : LowerFresh h p l P := by + intro j hj hjl k hk + obtain ⟨t, _, ht⟩ := Finset.mem_image.mp hk + exact hlevel j (l+1) hj (by omega) (by omega) hlH (by omega) k t ht.symm + have hdis : Disjoint S P := by + apply Finset.disjoint_left.mpr + intro q hq hqP + obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp hqP + exact hfresh (l+1) (by omega) (by omega) k hq + have hchild (k : Fin h) : descentBound h K T 1 l ≤ f (subcircle (hd (l+1) k) 1) := by + let : Fact (p (l+1) k).Prime := ⟨hp (l+1) (by omega) hlH k⟩ + have hne : subcircle (hd (l+1) k) 1 ≠ 0 := by + simpa only [map_zero] using (subcircle_injective (hd (l+1) k)).ne (one_ne_zero : (1:ZMod (p (l+1) k)) ≠ 0) + have hfr : LowerFresh h p l {p (l+1) k} := by + intro j hj hjl t ht + have he : p j t = p (l+1) k := Finset.mem_singleton.mp ht + exact hlevel j (l+1) hj (by omega) (by omega) hlH (by omega) t k he + simpa only [Finset.card_singleton] using ih (by omega) {p (l+1) k} + (subcircle (hd (l+1) k) 1) (by simp; omega) + (by intro q hq; simpa only [Finset.mem_singleton.mp hq] using + (show (p (l+1) k).Prime ∧ p (l+1) k ≤ h^4 from + ⟨hp (l+1) (by omega) hlH k, hin (l+1) (by omega) hlH k⟩)) + hfr hne (support_subcircle (hd (l+1) k) 1) + have hreset : (A.card : ℝ)/(4*h)*descentBound h K T 1 l ≤ maskCost h p M hd hn (l+1) x := + hact _ (descentBound_pos hh hTp).le (fun k _ => hchild k) + have hspos : 0 < S.card := support_card_pos hx hs + have hhreal : (0:ℝ) < h := by exact_mod_cast hh + have hTreal : (0:ℝ) < T := by exact_mod_cast hTp + have hhTreal : (h:ℝ) ≤ (T:ℝ)^2 := by exact_mod_cast hhT + by_cases hlarge : T ≤ A.card + · have hbudget : resetBudget K T 1 l ≤ resetBudget K T S.card (l+1) := by + apply resetBudget_mono + rw [Nat.add_mul] + omega + have hstep := descentBound_step (K := K) (n := S.card) (m := 1) (l := l) (e := 1) + hh (by omega : 1 ≤ T) (by omega) + have hfac : (1/(4*(T:ℝ)^1)) ≤ (A.card : ℝ)/(4*h) := by + rw [div_le_div_iff₀ (by positivity) (by positivity)] + simp only [pow_one] + have hlarge' : (T:ℝ) ≤ A.card := by exact_mod_cast hlarge + nlinarith + exact hstep.trans ((mul_le_mul_of_nonneg_right hfac (descentBound_pos hh hTp).le).trans hreset) + · have hsmall : A.card < T := by omega + by_cases hover : K < S.card+A.card + · have hapos : 0 < A.card := by omega + have hbudget := resetBudget_overflow (l := l) hK hsmall hover + have hstep := descentBound_step (K := K) (n := S.card) (m := 1) (l := l) (e := 2) + hh (by omega : 1 ≤ T) (by omega) + have hfac : (1/(4*(T:ℝ)^2)) ≤ (A.card : ℝ)/(4*h) := by + rw [div_le_div_iff₀ (by positivity) (by positivity)] + have ha : (1:ℝ) ≤ A.card := by exact_mod_cast hapos + nlinarith [sq_nonneg (T:ℝ)] + exact hstep.trans ((mul_le_mul_of_nonneg_right hfac (descentBound_pos hh hTp).le).trans hreset) + · have hPC : P.card ≤ A.card := Finset.card_image_le + have hunion : (S ∪ P).card ≤ S.card+A.card := (Finset.card_union_le S P).trans (by omega) + have hnew : PhaseSupported (S ∪ P) (x+∑ k,subcircle (hd (l+1) k) (z k)) := + hs.add (support_mask_sum (hd (l+1)) z) + have hnz : (x+∑ k,subcircle (hd (l+1) k) (z k)) ≠ 0 := + phase_add_supported_ne_zero hs (support_mask_sum (hd (l+1)) z) + (fun q hq => (hS q hq).1) (fun q hq => (hpP q hq).1) hdis hx + have hfr : LowerFresh h p l (S ∪ P) := by + intro j hj hjl k hk + rcases Finset.mem_union.mp hk with hk | hk + · exact hfresh j hj (by omega) k hk + · exact hfreshP j hj hjl k hk + have hSUP (q : ℕ) (hq : q ∈ S ∪ P) : q.Prime ∧ q ≤ h^4 := by + rcases Finset.mem_union.mp hq with hq | hq + · exact hS q hq + · exact hpP q hq + have hlower := ih (by omega) (S ∪ P) (x+∑ k,subcircle (hd (l+1) k) (z k)) + (by omega) hSUP hfr hnz hnew + have hbudget : resetBudget K T (S∪P).card l ≤ resetBudget K T S.card (l+1) := by + apply resetBudget_mono + rw [Nat.add_mul] + omega + have hstep := descentBound_step (K := K) (n := S.card) (m := (S∪P).card) (l := l) (e := 0) + hh (by omega : 1 ≤ T) (by omega) + simp only [pow_zero, mul_one] at hstep + exact hstep.trans ((mul_le_mul_of_nonneg_left hlower (by norm_num : (0:ℝ)≤1/4)).trans + (hinact (by change 2*A.card ≤ h; omega))) + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/MaskSeparation.lean b/lean/OAI/Combinatorics/FiniteCircle/MaskSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..30971e1f60f307aa5d4bf14fb4529268b02fc002 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/MaskSeparation.lean @@ -0,0 +1,334 @@ +import OAI.Combinatorics.FiniteCircle.CircleWords + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +abbrev MaskResidues (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) := (k : Fin h) → ZMod (p l k) + +noncomputable def maskPhaseHom (h : ℕ) (p : ℕ → ℕ → ℕ) (M l : ℕ) + (hd : ∀ k : Fin h, p l k ∣ M) : MaskResidues h p l →+ (MaskTag h p l → ZMod M) where + toFun z j := (∑ k, subcircle (hd k) (z k)) + j.2.val • subcircle (hd j.1) (z j.1) + map_zero' := by funext j; simp + map_add' z u := by + funext j + simp only [Pi.add_apply, map_add, Finset.sum_add_distrib, nsmul_add] + abel + + theorem maskPhaseHom_natCast (h : ℕ) (p : ℕ → ℕ → ℕ) (M l a : ℕ) + (hd : ∀ k : Fin h, p l k ∣ M) (hn : ∀ k : Fin h, 0 < p l k) : + maskPhaseHom h p M l hd (fun k => (a : ZMod (p l k))) = maskGamma h p M l a := by + funext j + change (∑ k, subcircle (hd k) (a : ZMod (p l k))) + + j.2.val • subcircle (hd j.1) (a : ZMod (p l j.1)) = _ + have he (k : Fin h) : subcircle (hd k) (a : ZMod (p l k)) = + ((M/p l k*(a%p l k) : ℕ) : ZMod M) := by + let : NeZero (p l k) := ⟨(hn k).ne'⟩ + rw [subcircle_val, ZMod.val_natCast] + simp_rw [he] + simp only [maskGamma, nsmul_eq_mul, Nat.cast_mul] + ring + + theorem sum_fin_zmod {p : ℕ} [NeZero p] (g : ZMod p → ℝ) : + ∑ b : Fin p, g (b.val : ZMod p) = ∑ b : ZMod p, g b := by + refine Fintype.sum_equiv (ZMod.finEquiv p).toEquiv _ _ ?_ + intro b + congr 1 + cases p with + | zero => exact Fin.elim0 b + | succ p => + change (b.val : ZMod (p+1)) = b + exact ZMod.natCast_zmod_val (show ZMod (p+1) from b) + +noncomputable def maskCost (h : ℕ) (p : ℕ → ℕ → ℕ) (M : ℕ) + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) : + ℕ → PhaseCost (ZMod M) + | 0 => circlePhaseCost M + | l+1 => by + let : ∀ k : Fin h, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + exact (maskCost h p M hd hn l).step (maskPhaseHom h p M (l+1) (hd _)) + + theorem maskCost_le_half {h M : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hh : 0 < h) (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (l : ℕ) (x : ZMod M) : maskCost h p M hd hn l x ≤ 1/2 := by + induction l with + | zero => exact circleCost_le_half x + | succ l ih => + let : ∀ k : Fin h, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + let : Nonempty (MaskTag h p (l+1)) := ⟨⟨⟨0,hh⟩,⟨0,hn _ ⟨0,hh⟩⟩⟩⟩ + exact ((maskCost h p M hd hn l).infAverage_le_self _ x).trans ih + + theorem card_maskTag (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) : + Fintype.card (MaskTag h p l) = ∑ k : Fin h, p l k := by + simp only [MaskTag, Fintype.card_sigma, Fintype.card_fin] + + theorem mask_average_formula {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ k : Fin h, p l k ∣ M) (hn : ∀ k : Fin h, 0 < p l k) + (f : PhaseCost (ZMod M)) (x : ZMod M) (z : MaskResidues h p l) : + f.average (maskPhaseHom h p M l hd) x z = + (∑ k : Fin h, ∑ b : Fin (p l k), + f (x+(∑ k,subcircle (hd k) (z k))+b.val • subcircle (hd k) (z k))) / + (∑ k : Fin h, (p l k : ℝ)) := by + let : ∀ k : Fin h, NeZero (p l k) := fun k => ⟨(hn k).ne'⟩ + simp only [PhaseCost.average, card_maskTag, Nat.cast_sum, Fintype.sum_sigma] + congr 1 + apply Finset.sum_congr rfl + intro k _ + apply Finset.sum_congr rfl + intro b _ + congr 1 + change x+((∑ k,subcircle (hd k) (z k))+b.val • subcircle (hd k) (z k)) = _ + abel + +theorem mask_active_average_lower {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hh : 0 < h) (hd : ∀ k : Fin h, p l k ∣ M) + (hp : ∀ k : Fin h, (p l k).Prime) + (hlo : ∀ k : Fin h, h^3 ≤ p l k) (hhi : ∀ k : Fin h, p l k ≤ 2*h^3) + (f : PhaseCost (ZMod M)) (x : ZMod M) (z : MaskResidues h p l) + (Q : ℝ) (hQ : 0 ≤ Q) + (hq : ∀ k : Fin h, z k ≠ 0 → Q ≤ f (subcircle (hd k) 1)) : + (((Finset.univ.filter (fun k : Fin h => z k ≠ 0)).card : ℝ)/(4*h))*Q ≤ + f.average (maskPhaseHom h p M l hd) x z := by + classical + let : ∀ k : Fin h, NeZero (p l k) := fun k => ⟨(hp k).ne_zero⟩ + let S := Finset.univ.filter (fun k : Fin h => z k ≠ 0) + let T : ℝ := ∑ k : Fin h, (p l k : ℝ) + let B (k : Fin h) : ℝ := ∑ b : Fin (p l k), + f (x+(∑ j,subcircle (hd j) (z j))+b.val • subcircle (hd k) (z k)) + have hB (k : Fin h) : 0 ≤ B k := Finset.sum_nonneg (fun _ _ => f.nonneg _) + have hT : 0 < T := by + apply Finset.sum_pos + · intro k _; exact_mod_cast (hp k).pos + · exact Finset.univ_nonempty_iff.mpr ⟨⟨0,hh⟩⟩ + have hTu : T ≤ 2*(h:ℝ)^4 := by + calc + T ≤ ∑ _k : Fin h, (2:ℝ)*h^3 := Finset.sum_le_sum (fun k _ => by exact_mod_cast hhi k) + _ = _ := by simp; ring + have hkb (k : Fin h) (hk : k ∈ S) : (h:ℝ)^3*Q ≤ 2*B k := by + have ha := f.prime_grid_bound (hp k) (subcircle (hd k)) + (x+∑ j,subcircle (hd j) (z j)) (z k) ((Finset.mem_filter.mp hk).2) + have he : B k = ∑ b : ZMod (p l k), + f (x+(∑ j,subcircle (hd j) (z j))+b.val • subcircle (hd k) (z k)) := by + symm + rw [← sum_fin_zmod] + apply Finset.sum_congr rfl + intro b _ + rw [ZMod.val_natCast, Nat.mod_eq_of_lt b.isLt] + rw [← he] at ha + calc + (h:ℝ)^3*Q ≤ (p l k : ℝ)*Q := mul_le_mul_of_nonneg_right (by exact_mod_cast hlo k) hQ + _ ≤ (p l k : ℝ)*f (subcircle (hd k) 1) := mul_le_mul_of_nonneg_left (hq k ((Finset.mem_filter.mp hk).2)) (by positivity) + _ ≤ _ := ha + have hsum : (S.card : ℝ)*(h:ℝ)^3*Q ≤ 2*∑ k : Fin h, B k := by + calc + _ = ∑ _k ∈ S, (h:ℝ)^3*Q := by simp; ring + _ ≤ ∑ k ∈ S, 2*B k := Finset.sum_le_sum hkb + _ ≤ ∑ k : Fin h, 2*B k := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ _) (fun k _ _ => mul_nonneg (by norm_num) (hB k)) + _ = _ := (Finset.mul_sum ..).symm + rw [mask_average_formula hd (fun k => (hp k).pos)] + change (S.card : ℝ)/(4*h)*Q ≤ (∑ k : Fin h, B k)/T + rw [le_div_iff₀ hT] + have hh' : (0:ℝ) < h := by exact_mod_cast hh + have hb : 0 ≤ (S.card : ℝ)/(4*h)*Q := by positivity + calc + _ ≤ ((S.card : ℝ)/(4*h)*Q)*(2*(h:ℝ)^4) := mul_le_mul_of_nonneg_left hTu hb + _ = ((S.card : ℝ)*(h:ℝ)^3*Q)/2 := by field_simp; ring + _ ≤ _ := by linarith + +theorem mask_inactive_average_lower {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hh : 0 < h) (hd : ∀ k : Fin h, p l k ∣ M) + (hp : ∀ k : Fin h, (p l k).Prime) + (hlo : ∀ k : Fin h, h^3 ≤ p l k) (hhi : ∀ k : Fin h, p l k ≤ 2*h^3) + (f : PhaseCost (ZMod M)) (x : ZMod M) (z : MaskResidues h p l) + (hs : 2*(Finset.univ.filter (fun k : Fin h => z k ≠ 0)).card ≤ h) : + (1/4:ℝ)*f (x+∑ k,subcircle (hd k) (z k)) ≤ + f.average (maskPhaseHom h p M l hd) x z := by + classical + let N := Finset.univ.filter (fun k : Fin h => z k = 0) + let T : ℝ := ∑ k : Fin h, (p l k : ℝ) + let B (k : Fin h) : ℝ := ∑ b : Fin (p l k), + f (x+(∑ j,subcircle (hd j) (z j))+b.val • subcircle (hd k) (z k)) + let Q := f (x+∑ k,subcircle (hd k) (z k)) + have hQ : 0 ≤ Q := f.nonneg _ + have hB (k : Fin h) : 0 ≤ B k := Finset.sum_nonneg (fun _ _ => f.nonneg _) + have hT : 0 < T := by + apply Finset.sum_pos + · intro k _; exact_mod_cast (hp k).pos + · exact Finset.univ_nonempty_iff.mpr ⟨⟨0,hh⟩⟩ + have hTu : T ≤ 2*(h:ℝ)^4 := by + calc + T ≤ ∑ _k : Fin h, (2:ℝ)*h^3 := Finset.sum_le_sum (fun k _ => by exact_mod_cast hhi k) + _ = _ := by simp; ring + have hN : (h:ℝ) ≤ 2*N.card := by + have hc := Finset.card_filter_add_card_filter_not (s := Finset.univ) (fun k : Fin h => z k = 0) + simp only [Finset.card_univ, Fintype.card_fin] at hc + change N.card + (Finset.univ.filter (fun k : Fin h => z k ≠ 0)).card = h at hc + exact_mod_cast (show h ≤ 2*N.card by omega) + have hkb (k : Fin h) (hk : k ∈ N) : (h:ℝ)^3*Q ≤ B k := by + have hz := (Finset.mem_filter.mp hk).2 + have he : B k = (p l k : ℝ)*Q := by + simp [B, Q, hz] + rw [he] + exact mul_le_mul_of_nonneg_right (by exact_mod_cast hlo k) hQ + have hsum : (N.card : ℝ)*(h:ℝ)^3*Q ≤ ∑ k : Fin h, B k := by + calc + _ = ∑ _k ∈ N, (h:ℝ)^3*Q := by simp; ring + _ ≤ ∑ k ∈ N, B k := Finset.sum_le_sum hkb + _ ≤ ∑ k : Fin h, B k := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ _) (fun k _ _ => hB k) + rw [mask_average_formula hd (fun k => (hp k).pos)] + change (1/4:ℝ)*Q ≤ (∑ k : Fin h, B k)/T + rw [le_div_iff₀ hT] + calc + _ ≤ ((1/4:ℝ)*Q)*(2*(h:ℝ)^4) := mul_le_mul_of_nonneg_left hTu (by positivity) + _ = ((h:ℝ)/2)*h^3*Q := by ring + _ ≤ (N.card : ℝ)*h^3*Q := by gcongr; linarith + _ ≤ _ := hsum + +theorem mask_minimizer_options {h M l : ℕ} {p : ℕ → ℕ → ℕ} + [∀ k : Fin h, NeZero (p l k)] + (hh : 0 < h) (hd : ∀ k : Fin h, p l k ∣ M) + (hp : ∀ k : Fin h, (p l k).Prime) + (hlo : ∀ k : Fin h, h^3 ≤ p l k) (hhi : ∀ k : Fin h, p l k ≤ 2*h^3) + (f : PhaseCost (ZMod M)) (x : ZMod M) : + ∃ z : MaskResidues h p l, + (let S := Finset.univ.filter (fun k : Fin h => z k ≠ 0) + (∀ Q : ℝ, 0 ≤ Q → (∀ k ∈ S, Q ≤ f (subcircle (hd k) 1)) → + (S.card : ℝ)/(4*h)*Q ≤ f.infAverage (maskPhaseHom h p M l hd) x) ∧ + (2*S.card ≤ h → (1/4:ℝ)*f (x+∑ k,subcircle (hd k) (z k)) ≤ + f.infAverage (maskPhaseHom h p M l hd) x)) := by + classical + let : ∀ k : Fin h, NeZero (p l k) := fun k => ⟨(hp k).ne_zero⟩ + obtain ⟨z,hz⟩ := f.exists_average_eq (maskPhaseHom h p M l hd) x + refine ⟨z, ?_⟩ + dsimp only + rw [hz] + constructor + · intro Q hQ hq + exact mask_active_average_lower hh hd hp hlo hhi f x z Q hQ + (fun k hk => hq k (by simp [hk])) + · exact mask_inactive_average_lower hh hd hp hlo hhi f x z + + theorem deficit_cast {β : Type*} (x y : List β) : (deficit x y : ℝ) = (x.length:ℝ) - lcs x y := by + exact Nat.cast_sub (lcs_le_length_left x y) + + theorem deficit_taggedRow_lower {J β : Type*} [Fintype J] [DecidableEq J] + (js : List J) (hn : js.Nodup) (hall : ∀ j, j ∈ js) (W U : J → List β) : + (∑ j : J, (deficit (W j) (U j) : ℝ)) ≤ + deficit (taggedRow js W) (taggedRow js U) := by + have hc := lcs_taggedRow_le js hn hall W U + have hcr : (lcs (taggedRow js W) (taggedRow js U) : ℝ) ≤ ∑ j : J, (lcs (W j) (U j) : ℝ) := by exact_mod_cast hc + simp_rw [deficit_cast] + rw [Finset.sum_sub_distrib, length_taggedRow js hn hall W, Nat.cast_sum] + linarith + + theorem maskLength_pos {h M R : ℕ} {p : ℕ → ℕ → ℕ} + (hh : 0 < h) (hM : 0 < M) (hR : 0 < R) (hn : ∀ l (k : Fin h), 0 < p l k) + (l : ℕ) : 0 < maskLength h p R M l := by + induction l with + | zero => exact hM + | succ l ih => + unfold maskLength + apply Nat.mul_pos (Nat.mul_pos hR (Finset.prod_pos (fun k _ => hn _ k))) + apply Nat.mul_pos _ ih + rw [length_maskTags] + exact Finset.sum_pos (fun k _ => hn _ k) (Finset.univ_nonempty_iff.mpr ⟨⟨0,hh⟩⟩) + +theorem mask_separation {h M R : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (he : M = 2*(M/2)) (hh : 0 < h) (hR : 0 < R) + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (ht : ∀ l, 4 ≤ (maskTags h p l).length) + (l : ℕ) (v : MaskState h p M l) (θ : ZMod M) : + (1/((2:ℝ)^l*4))*(maskLength h p R M l)*maskCost h p M hd hn l θ ≤ + (deficit (maskWord h p R M l v) + (maskWord h p R M l (shiftMaskState h p M l v θ)) : ℝ) := by + classical + induction l generalizing θ with + | zero => + change ZMod M at v + change (1/((2:ℝ)^0*4))*M*circleCost θ ≤ + (deficit (maskWord h p R M 0 v) (maskWord h p R M 0 (v+θ)) : ℝ) + rw [maskWord_zero_eq, maskWord_zero_eq] + calc + _ = (M:ℝ)*circleCost θ/4 := by norm_num; ring + _ ≤ _ := halfCircle_separation he v θ + | succ l ih => + let : ∀ k : Fin h, NeZero (p (l+1) k) := fun k => ⟨(hn _ k).ne'⟩ + let L := maskLength h p R M l + let t := (maskTags h p (l+1)).length + let N := R*period h p (l+1) + let f := maskCost h p M hd hn l + let σ := maskPhaseHom h p M (l+1) (hd _) + let ρ := (1/((2:ℝ)^l*4))*maskCost h p M hd hn (l+1) θ + have hL : 0 < L := maskLength_pos hh (NeZero.pos M) hR hn l + have hp2 : 1 ≤ (2:ℝ)^l := one_le_pow₀ (by norm_num) + have hρ : ρ ≤ 1/2 := by + have hc := maskCost_le_half hh hd hn (l+1) θ + have hc0 := (maskCost h p M hd hn (l+1)).nonneg θ + dsimp [ρ] + have hi : 1/((2:ℝ)^l*4) ≤ 1 := (div_le_one (by positivity)).mpr (by nlinarith) + calc + _ ≤ 1*maskCost h p M hd hn (l+1) θ := mul_le_mul_of_nonneg_right hi hc0 + _ ≤ _ := by simpa using hc + have hx : (maskWord h p R M (l+1) v).length = (t*L)*N := by + rw [length_maskWord] + change N*(t*L) = (t*L)*N + exact Nat.mul_comm _ _ + have hy : (maskWord h p R M (l+1) (shiftMaskState h p M (l+1) v θ)).length = (t*L)*N := by + rw [length_maskWord] + change N*(t*L) = (t*L)*N + exact Nat.mul_comm _ _ + have hr := row_separation hL (ht (l+1)) hx hy + (fun x => (maskTags h p (l+1)).idxOf x.1) + (tag_get_maskWord h p R M l v hL (by have := ht (l+1); omega)) + (tag_get_maskWord h p R M l _ hL (by have := ht (l+1); omega)) ρ hρ + have hrows : ∀ i j : Fin N, ρ*(t*L) ≤ + (deficit (segment (maskWord h p R M (l+1) v) (i.val*(t*L)) (t*L)) + (segment (maskWord h p R M (l+1) (shiftMaskState h p M (l+1) v θ)) + (j.val*(t*L)) (t*L)) : ℝ) := by + intro a b + rw [segment_maskWord, segment_maskWord] + let z : MaskResidues h p (l+1) := fun k => (b.val : ZMod (p (l+1) k)) - (a.val : ZMod (p (l+1) k)) + have hz (j : MaskTag h p (l+1)) : σ z j = + maskGamma h p M (l+1) b j - maskGamma h p M (l+1) a j := by + change σ ((fun k : Fin h => (b.val : ZMod (p (l+1) k))) - (fun k : Fin h => (a.val : ZMod (p (l+1) k)))) j = _ + rw [map_sub, Pi.sub_apply] + exact congrArg₂ (·-·) (congrFun (maskPhaseHom_natCast h p M (l+1) b (hd _) (hn _)) j) + (congrFun (maskPhaseHom_natCast h p M (l+1) a (hd _) (hn _)) j) + have hind (j : MaskTag h p (l+1)) := ih + (shiftMaskState h p M l (v j) (maskGamma h p M (l+1) a j)) (θ+σ z j) + have hstate (j : MaskTag h p (l+1)) : + shiftMaskState h p M l (shiftMaskState h p M l (v j) (maskGamma h p M (l+1) a j)) (θ+σ z j) = + shiftMaskState h p M l (shiftMaskState h p M l (v j) θ) (maskGamma h p M (l+1) b j) := by + rw [shiftMaskState_add, shiftMaskState_add, hz] + congr 1 + abel + simp_rw [hstate] at hind + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun j _ => hind j) + have hdef := deficit_taggedRow_lower (maskTags h p (l+1)) (nodup_maskTags ..) + (mem_maskTags h p (l+1)) + (fun j => maskWord h p R M l (shiftMaskState h p M l (v j) (maskGamma h p M (l+1) a j))) + (fun j => maskWord h p R M l (shiftMaskState h p M l (shiftMaskState h p M l (v j) θ) (maskGamma h p M (l+1) b j))) + apply le_trans _ (hsum.trans hdef) + rw [← Finset.mul_sum] + have hcost : maskCost h p M hd hn (l+1) θ ≤ f.average σ θ z := f.infAverage_le σ θ z + have htpos : (0:ℝ) < t := by exact_mod_cast (show 0 < t by have := ht (l+1); omega) + have hcard : (Fintype.card (MaskTag h p (l+1)) : ℝ) = t := by rw [card_maskTag]; exact_mod_cast (length_maskTags h p (l+1)).symm + rw [PhaseCost.average, hcard, le_div_iff₀ htpos] at hcost + dsimp only [ρ] + calc + _ = ((1/((2:ℝ)^l*4))*(L:ℝ)) * ((maskCost h p M hd hn (l+1) θ)*t) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hcost (by positivity) + have hfinal := hr hrows + rw [length_maskWord] at hfinal + dsimp only [ρ] at hfinal + calc + _ = ((1/((2:ℝ)^l*4))*maskCost h p M hd hn (l+1) θ)/2 * maskLength h p R M (l+1) := by rw [pow_succ]; ring + _ ≤ _ := hfinal + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Matching.lean b/lean/OAI/Combinatorics/FiniteCircle/Matching.lean new file mode 100644 index 0000000000000000000000000000000000000000..792d2f8db669356eae10337dbbd04460f971c21d --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Matching.lean @@ -0,0 +1,410 @@ +import OAI.Combinatorics.FiniteCircle.Edit + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +def segment {α : Type*} (x : List α) (start size : ℕ) : List α := (x.drop start).take size + +theorem segment_sublist {α : Type*} (x : List α) (start size : ℕ) : + segment x start size <+ x := (List.take_sublist _ _).trans (List.drop_sublist _ _) + +theorem length_segment {α : Type*} {x : List α} {start size : ℕ} + (h : start + size ≤ x.length) : (segment x start size).length = size := by + simp only [segment, List.length_take, List.length_drop] + omega + +theorem unequalDeficit_segment_sublist_le {α : Type*} {x y : List α} (h : x <+ y) + (start size : ℕ) : + unequalDeficit (segment x start size) (segment y start size) ≤ y.length - x.length := by + have hl := h.length_le + exact (unequalDeficit_take_sublist_le (h.drop start) size).trans (by + simp only [List.length_drop] + omega) + +theorem unequalDeficit_symm {α : Type*} (x y : List α) : + unequalDeficit x y = unequalDeficit y x := by + simp [unequalDeficit, lcs_symm x y, max_comm] + +inductive Slide {α : Type*} : List α → List α → Prop + | forward (u v t : List α) (a b : α) : + Slide (u ++ a :: (v ++ t)) (u ++ v ++ b :: t) + | backward (u v t : List α) (a b : α) : + Slide (u ++ v ++ b :: t) (u ++ a :: (v ++ t)) + +namespace Slide +variable {α : Type*} {x y : List α} + +theorem symm (h : Slide x y) : Slide y x := by + cases h with + | forward u v t a b => exact .backward u v t a b + | backward u v t a b => exact .forward u v t a b + +theorem length_eq (h : Slide x y) : x.length = y.length := by + cases h <;> simp <;> omega + +theorem append_left (h : Slide x y) (l : List α) : Slide (l ++ x) (l ++ y) := by + cases h with + | forward u v t a b => simpa only [List.append_assoc] using Slide.forward (l ++ u) v t a b + | backward u v t a b => simpa only [List.append_assoc] using Slide.backward (l ++ u) v t a b + +theorem append_right (h : Slide x y) (l : List α) : Slide (x ++ l) (y ++ l) := by + cases h with + | forward u v t a b => + simpa only [List.append_assoc, List.cons_append] using Slide.forward u v (t ++ l) a b + | backward u v t a b => + simpa only [List.append_assoc, List.cons_append] using Slide.backward u v (t ++ l) a b + +theorem common_delete (h : Slide x y) : + ∃ z : List α, z <+ x ∧ z <+ y ∧ z.length + 1 = x.length ∧ z.length + 1 = y.length := by + cases h with + | forward u v t a b => + exact ⟨u ++ v ++ t, + by simpa only [List.append_assoc] using ((List.Sublist.refl (v ++ t)).cons a).append_left u, + ((List.Sublist.refl t).cons b).append_left (u ++ v), by simp; omega, by simp; omega⟩ + | backward u v t a b => + exact ⟨u ++ v ++ t, + ((List.Sublist.refl t).cons b).append_left (u ++ v), + by simpa only [List.append_assoc] using ((List.Sublist.refl (v ++ t)).cons a).append_left u, + by simp; omega, by simp; omega⟩ + +theorem segment_deficit_le_two (h : Slide x y) (start size : ℕ) : + unequalDeficit (segment x start size) (segment y start size) ≤ 2 := by + obtain ⟨z, hx, hy, hzx, hzy⟩ := h.common_delete + have hleft := unequalDeficit_segment_sublist_le hx start size + have hright := unequalDeficit_segment_sublist_le hy start size + rw [unequalDeficit_symm] at hleft + exact (unequalDeficit_triangle _ (segment z start size) _).trans (by omega) +end Slide + +inductive SlidePath {α : Type*} : ℕ → List α → List α → Prop + | nil (x : List α) : SlidePath 0 x x + | cons {n : ℕ} {x y z : List α} : Slide x y → SlidePath n y z → SlidePath (n + 1) x z + +namespace SlidePath +variable {α : Type*} {x y z : List α} {n m : ℕ} + +theorem trans (h : SlidePath n x y) (g : SlidePath m y z) : SlidePath (n + m) x z := by + induction h with + | nil => simpa using g + | cons h hs ih => simpa only [Nat.add_right_comm] using SlidePath.cons h (ih g) + +theorem symm (h : SlidePath n x y) : SlidePath n y x := by + induction h with + | nil x => exact .nil x + | cons h hs ih => exact ih.trans (.cons h.symm (.nil _)) + +theorem append_left (h : SlidePath n x y) (l : List α) : SlidePath n (l ++ x) (l ++ y) := by + induction h with + | nil => exact .nil _ + | cons h hs ih => exact .cons (h.append_left l) ih + +theorem append_right (h : SlidePath n x y) (l : List α) : SlidePath n (x ++ l) (y ++ l) := by + induction h with + | nil => exact .nil _ + | cons h hs ih => exact .cons (h.append_right l) ih + +theorem length_eq (h : SlidePath n x y) : x.length = y.length := by + induction h with + | nil => rfl + | cons h hs ih => exact h.length_eq.trans ih + +theorem to_padded_sublist (h : z <+ x) (a : α) : + SlidePath (x.length - z.length) x (z ++ List.replicate (x.length - z.length) a) := by + induction h with + | slnil => simpa using SlidePath.nil ([] : List α) + | @cons z x b h ih => + have hl := h.length_le + have hfirst : Slide (b :: x) (x ++ [a]) := by + simpa using Slide.forward ([] : List α) x [] b a + have ht := SlidePath.cons hfirst (ih.append_right [a]) + simpa only [List.length_cons, + show x.length + 1 - z.length = (x.length - z.length) + 1 by omega, + List.append_assoc, List.replicate_succ', List.concat_eq_append] using ht + | cons_cons b h ih => + simpa using ih.append_left [b] +end SlidePath + +theorem exists_slidePath {α : Type*} (a : α) {x y : List α} (h : x.length = y.length) : + SlidePath (2 * deficit x y) x y := by + obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + have h1 := SlidePath.to_padded_sublist hx a + have h2 := SlidePath.to_padded_sublist hy a + rw [← h] at h2 + have ht := h1.trans h2.symm + simpa only [deficit, hz, two_mul] using ht + +structure WordMatching {α : Type*} (x y : List α) (q : ℕ) where + left : Fin q ↪o Fin x.length + right : Fin q ↪o Fin y.length + letters : ∀ i, x.get (left i) = y.get (right i) + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +theorem le_lcs (A : WordMatching x y q) : q ≤ lcs x y := by + let z := List.ofFn (fun i : Fin q => x.get (A.left i)) + have hx : z <+ x := by + apply List.sublist_iff_exists_fin_orderEmbedding_get_eq.mpr + have he : z.length = q := List.length_ofFn + refine ⟨(Fin.castOrderIso he).toOrderEmbedding.trans A.left, ?_⟩ + intro i + change (List.ofFn (fun j : Fin q => x.get (A.left j))).get i = x.get (A.left (Fin.cast he i)) + rw [List.get_ofFn] + have hy : z <+ y := by + apply List.sublist_iff_exists_fin_orderEmbedding_get_eq.mpr + have he : z.length = q := List.length_ofFn + refine ⟨(Fin.castOrderIso he).toOrderEmbedding.trans A.right, ?_⟩ + intro i + change (List.ofFn (fun j : Fin q => x.get (A.left j))).get i = y.get (A.right (Fin.cast he i)) + rw [List.get_ofFn] + convert A.letters (Fin.cast he i) using 1 + simpa [z] using FiniteCircle.le_lcs hx hy + +def restrict (A : WordMatching x y q) {r : ℕ} (e : Fin r ↪o Fin q) : WordMatching x y r where + left := e.trans A.left + right := e.trans A.right + letters i := A.letters (e i) + +def symm (A : WordMatching x y q) : WordMatching y x q where + left := A.right + right := A.left + letters i := (A.letters i).symm + +def rightSpan (A : WordMatching x y q) (S : Finset (Fin q)) : Finset (Fin y.length) := + Finset.univ.filter (fun j => ∃ i ∈ S, ∃ k ∈ S, A.right i ≤ j ∧ j ≤ A.right k) + +theorem rightSpan_matched_iff (A : WordMatching x y q) (S : Finset (Fin q)) + (hS : ∀ i ∈ S, ∀ k ∈ S, ∀ j, i ≤ j → j ≤ k → j ∈ S) (j : Fin q) : + A.right j ∈ A.rightSpan S ↔ j ∈ S := by + simp only [rightSpan, Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · rintro ⟨i, hi, k, hk, hij, hjk⟩ + exact hS i hi k hk j (A.right.le_iff_le.mp hij) (A.right.le_iff_le.mp hjk) + · intro hj + exact ⟨j, hj, j, hj, le_rfl, le_rfl⟩ + +theorem rightSpan_disjoint (A : WordMatching x y q) {S T : Finset (Fin q)} + (h : ∀ i ∈ S, ∀ j ∈ T, i < j) : Disjoint (A.rightSpan S) (A.rightSpan T) := by + apply Finset.disjoint_left.mpr + intro z hz hw + obtain ⟨_, i, hi, k, hk, hiz, hzk⟩ := Finset.mem_filter.mp hz + obtain ⟨_, j, hj, l, hl, hjz, hzl⟩ := Finset.mem_filter.mp hw + have hkj : A.right k < A.right j := A.right.strictMono (h k hk j hj) + exact (not_lt_of_ge (hjz.trans hzk)) hkj + +theorem sum_span_card_le {ι : Type*} [Fintype ι] [LinearOrder ι] + (A : WordMatching x y q) (S : ι → Finset (Fin q)) + (h : ∀ i j, i < j → ∀ u ∈ S i, ∀ v ∈ S j, u < v) : + ∑ i, (A.rightSpan (S i)).card ≤ y.length := by + classical + have hdis : (↑(Finset.univ : Finset ι) : Set ι).PairwiseDisjoint (fun i => A.rightSpan (S i)) := by + intro i _ j _ hij + rcases lt_or_gt_of_ne hij with hij | hij + · exact A.rightSpan_disjoint (h i j hij) + · exact (A.rightSpan_disjoint (h j i hij)).symm + rw [← Finset.card_biUnion hdis] + exact (Finset.card_le_card (Finset.subset_univ _)).trans_eq (Fintype.card_fin _) + +end WordMatching + +theorem exists_lcs_matching {α : Type*} (x y : List α) : + Nonempty (WordMatching x y (lcs x y)) := by + obtain ⟨z, hx, hy, hz⟩ := lcs_exists x y + obtain ⟨f, hf⟩ := List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp hx + obtain ⟨g, hg⟩ := List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp hy + let e := (Fin.castOrderIso hz.symm).toOrderEmbedding + exact ⟨⟨e.trans f, e.trans g, fun i => (hf (e i)).symm.trans (hg (e i))⟩⟩ + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +def sourceBlock (A : WordMatching x y q) (w i : ℕ) : Finset (Fin q) := + Finset.univ.filter (fun k => (A.left k).val / w = i) + +@[simp] theorem mem_sourceBlock (A : WordMatching x y q) (w i : ℕ) (k : Fin q) : + k ∈ A.sourceBlock w i ↔ (A.left k).val / w = i := by simp [sourceBlock] + +theorem sourceBlock_card_le (A : WordMatching x y q) {w : ℕ} (hw : 0 < w) (i : ℕ) : + (A.sourceBlock w i).card ≤ w := by + let f : Fin q → Fin w := fun k => ⟨(A.left k).val % w, Nat.mod_lt _ hw⟩ + have h : Set.InjOn f (↑(A.sourceBlock w i) : Set (Fin q)) := by + intro j hj k hk he + apply A.left.injective + apply Fin.ext + have hj := (A.mem_sourceBlock w i j).mp hj + have hk := (A.mem_sourceBlock w i k).mp hk + have hf : (A.left j).val % w = (A.left k).val % w := congrArg Fin.val he + have h1 := Nat.mod_add_div (A.left j).val w + have h2 := Nat.mod_add_div (A.left k).val w + rw [hj, hf] at h1 + rw [hk] at h2 + omega + have hc := Finset.card_le_card_of_injOn f (fun _ _ => Finset.mem_univ _) h + simpa using hc + +theorem sum_sourceBlock_card (A : WordMatching x y q) {w L : ℕ} (hw : 0 < w) + (hx : x.length = w*L) : ∑ i : Fin L, (A.sourceBlock w i).card = q := by + let f : Fin q → Fin L := fun k => ⟨(A.left k).val / w, by + apply (Nat.div_lt_iff_lt_mul hw).mpr + simpa only [hx, Nat.mul_comm] using (A.left k).isLt⟩ + have hh (i : Fin L) : A.sourceBlock w i = Finset.univ.filter (fun k => f k = i) := by + ext k + simp only [mem_sourceBlock, Finset.mem_filter, Finset.mem_univ, true_and, Fin.ext_iff, f] + simp_rw [hh] + simpa using Finset.sum_card_fiberwise_eq_card_filter (Finset.univ : Finset (Fin q)) + (Finset.univ : Finset (Fin L)) f + +theorem sourceBlock_order (A : WordMatching x y q) {w i j : ℕ} (hij : i < j) + {k l : Fin q} (hk : k ∈ A.sourceBlock w i) (hl : l ∈ A.sourceBlock w j) : k < l := by + by_contra h + have hkl := A.left.monotone (not_lt.mp h) + have hd := Nat.div_le_div_right (c := w) (show (A.left l).val ≤ (A.left k).val from hkl) + rw [← (A.mem_sourceBlock w i k).mp hk, ← (A.mem_sourceBlock w j l).mp hl] at hij + omega + +theorem sourceBlock_convex (A : WordMatching x y q) (w i : ℕ) : + ∀ k ∈ A.sourceBlock w i, ∀ l ∈ A.sourceBlock w i, ∀ j, k ≤ j → j ≤ l → + j ∈ A.sourceBlock w i := by + intro k hk l hl j hkj hjl + rw [mem_sourceBlock] at * + have h1 := Nat.div_le_div_right (c := w) (show (A.left k).val ≤ (A.left j).val from A.left.monotone hkj) + have h2 := Nat.div_le_div_right (c := w) (show (A.left j).val ≤ (A.left l).val from A.left.monotone hjl) + omega + +theorem card_le_rightSpan (A : WordMatching x y q) (S : Finset (Fin q)) : + S.card ≤ (A.rightSpan S).card := by + have hmaps : Set.MapsTo A.right (↑S : Set (Fin q)) (↑(A.rightSpan S) : Set (Fin y.length)) := by + intro k hk + change A.right k ∈ A.rightSpan S + simp only [rightSpan, Finset.mem_filter, Finset.mem_univ, true_and] + exact ⟨k, hk, k, hk, le_rfl, le_rfl⟩ + exact Finset.card_le_card_of_injOn A.right hmaps A.right.injective.injOn + +def sourceLoss (A : WordMatching x y q) (w i : ℕ) : ℕ := w - (A.sourceBlock w i).card + +def spanLoss (A : WordMatching x y q) (w i : ℕ) : ℕ := + (A.rightSpan (A.sourceBlock w i)).card - (A.sourceBlock w i).card + +theorem sum_sourceLoss (A : WordMatching x y q) {w L : ℕ} (hw : 0 < w) + (hx : x.length = w*L) : ∑ i : Fin L, A.sourceLoss w i = w*L-q := by + have he : (∑ i : Fin L, A.sourceLoss w i) + q = w*L := by + conv_lhs => rhs; rw [← A.sum_sourceBlock_card hw hx] + rw [← Finset.sum_add_distrib] + simp only [sourceLoss, Nat.sub_add_cancel (A.sourceBlock_card_le hw _), + Finset.sum_const, Finset.card_univ, Fintype.card_fin, smul_eq_mul, Nat.mul_comm] + omega + +theorem sum_spanLoss_le (A : WordMatching x y q) {w L : ℕ} (hw : 0 < w) + (hx : x.length = w*L) (hy : y.length = w*L) : ∑ i : Fin L, A.spanLoss w i ≤ w*L-q := by + have he : (∑ i : Fin L, A.spanLoss w i) + q = + ∑ i : Fin L, (A.rightSpan (A.sourceBlock w i)).card := by + conv_lhs => rhs; rw [← A.sum_sourceBlock_card hw hx] + rw [← Finset.sum_add_distrib] + simp only [spanLoss, Nat.sub_add_cancel (A.card_le_rightSpan _)] + have hle := A.sum_span_card_le (fun i : Fin L => A.sourceBlock w i) + (fun _ _ hij _ hk _ hl => A.sourceBlock_order hij hk hl) + have hle' := hle.trans_eq hy + omega + +end WordMatching + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +def ConvexIndices (S : Finset (Fin q)) : Prop := + ∀ i ∈ S, ∀ k ∈ S, ∀ j, i ≤ j → j ≤ k → j ∈ S + +theorem rightSpan_mono (A : WordMatching x y q) {S T : Finset (Fin q)} (h : S ⊆ T) : + A.rightSpan S ⊆ A.rightSpan T := by + intro j hj + obtain ⟨_, i, hi, k, hk, hij, hjk⟩ := Finset.mem_filter.mp hj + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, i, h hi, k, h hk, hij, hjk⟩ + +theorem rightSpan_eq_Icc (A : WordMatching x y q) {S : Finset (Fin q)} (h : S.Nonempty) : + A.rightSpan S = Finset.Icc (A.right (S.min' h)) (A.right (S.max' h)) := by + ext j + simp only [rightSpan, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_Icc] + constructor + · rintro ⟨i, hi, k, hk, hij, hjk⟩ + exact ⟨(A.right.monotone (S.min'_le _ hi)).trans hij, + hjk.trans (A.right.monotone (S.le_max' _ hk))⟩ + · rintro ⟨hlo, hhi⟩ + exact ⟨_, S.min'_mem h, _, S.max'_mem h, hlo, hhi⟩ + +theorem convex_eq_Icc {S : Finset (Fin q)} (hS : ConvexIndices S) (h : S.Nonempty) : + S = Finset.Icc (S.min' h) (S.max' h) := by + ext j + constructor + · intro hj + exact Finset.mem_Icc.mpr ⟨S.min'_le _ hj, S.le_max' _ hj⟩ + · intro hj + obtain ⟨hlo, hhi⟩ := Finset.mem_Icc.mp hj + exact hS _ (S.min'_mem h) _ (S.max'_mem h) j hlo hhi + +theorem card_span_unmatched (A : WordMatching x y q) {S : Finset (Fin q)} + (hS : ConvexIndices S) : + (A.rightSpan S \ (Finset.univ.image A.right)).card = (A.rightSpan S).card - S.card := by + have he : A.rightSpan S \ (Finset.univ.image A.right) = A.rightSpan S \ (S.image A.right) := by + ext j + simp only [Finset.mem_sdiff, Finset.mem_image, Finset.mem_univ, true_and] + constructor + · rintro ⟨hj, hn⟩ + exact ⟨hj, fun ⟨k, _, hk⟩ => hn ⟨k, hk⟩⟩ + · rintro ⟨hj, hn⟩ + refine ⟨hj, ?_⟩ + rintro ⟨k, rfl⟩ + exact hn ⟨k, (A.rightSpan_matched_iff S hS k).mp hj, rfl⟩ + have hs : S.image A.right ⊆ A.rightSpan S := by + intro j hj + obtain ⟨k, hk, rfl⟩ := Finset.mem_image.mp hj + exact (A.rightSpan_matched_iff S hS k).mpr hk + rw [he, Finset.card_sdiff_of_subset hs, Finset.card_image_of_injective S A.right.injective] + +theorem span_holes_mono (A : WordMatching x y q) {S T : Finset (Fin q)} + (hS : ConvexIndices S) (hT : ConvexIndices T) (h : S ⊆ T) : + (A.rightSpan S).card - S.card ≤ (A.rightSpan T).card - T.card := by + rw [← A.card_span_unmatched hS, ← A.card_span_unmatched hT] + exact Finset.card_le_card (Finset.sdiff_subset_sdiff (A.rightSpan_mono h) le_rfl) + +theorem leftSpan_sourceBlock_card_le (A : WordMatching x y q) {w : ℕ} (hw : 0 < w) (i : ℕ) : + (A.symm.rightSpan (A.sourceBlock w i)).card ≤ w := by + let f : Fin x.length → Fin w := fun j => ⟨j.val % w, Nat.mod_lt _ hw⟩ + have hquot (j : Fin x.length) (hj : j ∈ A.symm.rightSpan (A.sourceBlock w i)) : j.val/w = i := by + obtain ⟨_, k, hk, l, hl, hkj, hjl⟩ := Finset.mem_filter.mp hj + have hk := (A.mem_sourceBlock w i k).mp hk + have hl := (A.mem_sourceBlock w i l).mp hl + have h1 := Nat.div_le_div_right (c := w) (show (A.left k).val ≤ j.val from hkj) + have h2 := Nat.div_le_div_right (c := w) (show j.val ≤ (A.left l).val from hjl) + omega + have hinj : Set.InjOn f (↑(A.symm.rightSpan (A.sourceBlock w i)) : Set (Fin x.length)) := by + intro j hj k hk he + have hj := hquot j hj + have hk := hquot k hk + have hf : j.val % w = k.val % w := congrArg Fin.val he + have h1 := Nat.mod_add_div j.val w + have h2 := Nat.mod_add_div k.val w + rw [hj, hf] at h1 + rw [hk] at h2 + apply Fin.ext + omega + simpa using Finset.card_le_card_of_injOn f (fun _ _ => Finset.mem_univ _) hinj + +theorem left_span_holes_le_sourceLoss (A : WordMatching x y q) {w : ℕ} (hw : 0 < w) + {i : ℕ} {S : Finset (Fin q)} (hS : ConvexIndices S) (h : S ⊆ A.sourceBlock w i) : + (A.symm.rightSpan S).card - S.card ≤ A.sourceLoss w i := by + exact (A.symm.span_holes_mono hS (A.sourceBlock_convex w i) h).trans + (Nat.sub_le_sub_right (A.leftSpan_sourceBlock_card_le hw i) _) + +theorem right_span_holes_le_spanLoss (A : WordMatching x y q) {w i : ℕ} + {S : Finset (Fin q)} (hS : ConvexIndices S) (h : S ⊆ A.sourceBlock w i) : + (A.rightSpan S).card - S.card ≤ A.spanLoss w i := + A.span_holes_mono hS (A.sourceBlock_convex w i) h + +end WordMatching + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Model.lean b/lean/OAI/Combinatorics/FiniteCircle/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..a82c9a159028b2236f25b227e623c5ab0b33e1b2 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Model.lean @@ -0,0 +1,228 @@ +import Mathlib + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +universe u v + +inductive EditStep {α : Type u} : List α → List α → Prop + | insert (u v : List α) (a : α) : EditStep (u ++ v) (u ++ a :: v) + | delete (u v : List α) (a : α) : EditStep (u ++ a :: v) (u ++ v) + | substitute (u v : List α) (a b : α) : EditStep (u ++ a :: v) (u ++ b :: v) + +inductive EditScript {α : Type u} : ℕ → List α → List α → Prop + | nil (x : List α) : EditScript 0 x x + | cons {n : ℕ} {x y z : List α} : + EditStep x y → EditScript n y z → EditScript (n + 1) x z + +noncomputable def editDistance {α : Type u} (x y : List α) : ℕ := + sInf {n : ℕ | EditScript n x y} + +noncomputable def lcs {α : Type u} (x y : List α) : ℕ := + sSup {n : ℕ | ∃ z : List α, z <+ x ∧ z <+ y ∧ z.length = n} + +noncomputable def deficit {α : Type u} (x y : List α) : ℕ := x.length - lcs x y + +abbrev Words (α : Type u) (d : ℕ) := {x : List α // x.length ≤ d} +abbrev RealL1 := lp (fun _ : ℕ => ℝ) 1 + +noncomputable def distortion {α : Type u} {X : Type v} (word : X → List α) + (f : X → RealL1) : ℝ := + (sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ + r = ‖f x - f y‖ / (editDistance (word x) (word y) : ℝ)}) * + (sSup {r : ℝ | ∃ x y : X, x ≠ y ∧ + r = (editDistance (word x) (word y) : ℝ) / ‖f x - f y‖}) + +noncomputable def optimalDistortion {α : Type u} {X : Type v} + (word : X → List α) : ℝ := + sInf {D | ∃ f : X → RealL1, Function.Injective f ∧ D = distortion word f} + +noncomputable def E (α : Type u) (d : ℕ) : ℝ := + optimalDistortion (fun x : Words α d => x.val) + +noncomputable def setDistortion (S : Set (List Bool)) : ℝ := + optimalDistortion (fun x : S => x.val) + +noncomputable def alphabetSupremum (d : ℕ) : ℝ := + sSup {r | ∃ A : ℕ, 2 ≤ A ∧ r = E (Fin A) d} + +noncomputable def exponentScale (d : ℕ) : ℝ := + Real.sqrt (Real.log d * Real.log (Real.log d)) + +def encode {α : Type u} {w : ℕ} (c : α → Fin w → Bool) (x : List α) : List Bool := + x.flatMap (fun a => List.ofFn (c a)) + +def interval {α : Type u} {w : ℕ} (c : α → Fin w → Bool) + (a : α) (s len : ℕ) : List Bool := + ((List.ofFn (c a)).drop s).take len + +def OffsetLocal {α : Type u} {w : ℕ} (δ : ℝ) (c : α → Fin w → Bool) : Prop := + ∀ a b : α, a ≠ b → ∀ s t : ℕ, + s + w / 8 ≤ w → t + w / 8 ≤ w → + (lcs (interval c a s (w / 8)) (interval c b t (w / 8)) : ℝ) ≤ + (1 - δ) * (w / 8 : ℕ) + +def indexSpan {w : ℕ} (is : List (Fin w)) : ℕ := + match is with + | [] => 0 + | i :: js => (js.getLastD i).val + 1 - i.val + +def AnchorLocal {α : Type u} {w : ℕ} (ε : ℝ) (c : α → Fin w → Bool) : Prop := + ∀ a b : α, ∀ is js : List (Fin w), + is.Pairwise (fun i j => i.val < j.val) → + js.Pairwise (fun i j => i.val < j.val) → + is.length = js.length → (w : ℝ) / 4 ≤ is.length → + (indexSpan is - is.length : ℕ) ≤ ε * w → + (indexSpan js - js.length : ℕ) ≤ ε * w → + (∀ ij ∈ is.zip js, c a ij.1 = c b ij.2) → + a = b ∧ ∃ i : Fin w, (i, i) ∈ is.zip js + +def SubstitutionBounds {α : Type u} [Fintype α] {w : ℕ} + (a C : ℝ) (c : α → Fin w → Bool) : Prop := + 0 < w ∧ (w : ℝ) ≤ C * Real.log (2 * Fintype.card α) ∧ + (∀ L : ℕ, ∀ x y : List α, x.length = L → y.length = L → + a * w * deficit x y ≤ (deficit (encode c x) (encode c y) : ℝ) ∧ + deficit (encode c x) (encode c y) ≤ w * deficit x y) ∧ + (∀ x y : List α, editDistance (encode c x) (encode c y) ≤ w * editDistance x y) + +def TwoCodes (a C δ ε : ℝ) : Prop := + ∀ (α : Type) [Fintype α], 2 ≤ Fintype.card α → + (∃ (w : ℕ) (c : α → Fin w → Bool), + SubstitutionBounds a C c ∧ OffsetLocal δ c) ∧ + (∃ (w : ℕ) (c : α → Fin w → Bool), + SubstitutionBounds a C c ∧ AnchorLocal ε c) + +def period (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) : ℕ := ∏ k : Fin h, p l k + +def circleSize (h : ℕ) (p : ℕ → ℕ → ℕ) : ℕ := + 2 * ∏ l : Fin h, period h p (l.val + 1) + +def MaskPrimes (h : ℕ) (p : ℕ → ℕ → ℕ) : Prop := + (∀ l k : Fin h, Nat.Prime (p (l.val + 1) k)) ∧ + Function.Injective (fun lk : Fin h × Fin h => p (lk.1.val + 1) lk.2) ∧ + ∀ l k : Fin h, h ^ 3 ≤ p (l.val + 1) k ∧ p (l.val + 1) k ≤ 2 * h ^ 3 + +def ExcludedPrimes (m : ℕ) (p : ℕ → ℕ → ℕ) : Prop := + (∀ l k : Fin m, Nat.Prime (p (l.val + 1) k)) ∧ + Function.Injective (fun lk : Fin m × Fin m => p (lk.1.val + 1) lk.2) ∧ + ∀ l k : Fin m, m ^ 3 < p (l.val + 1) k ∧ p (l.val + 1) k ≤ m ^ 5 + +abbrev MaskTag (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) := Σ k : Fin h, Fin (p l k) + +def maskTags (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) : List (MaskTag h p l) := + (List.ofFn fun k : Fin h => List.ofFn fun b : Fin (p l k) => Sigma.mk k b).flatten + +def MaskAlphabet (h : ℕ) (p : ℕ → ℕ → ℕ) : ℕ → Type + | 0 => Bool + | l + 1 => MaskTag h p (l + 1) × MaskAlphabet h p l + +instance maskAlphabetFintype (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) : + Fintype (MaskAlphabet h p l) := by + induction l with + | zero => exact inferInstanceAs (Fintype Bool) + | succ l ih => exact @instFintypeProd _ _ inferInstance ih + +def MaskState (h : ℕ) (p : ℕ → ℕ → ℕ) (M : ℕ) : ℕ → Type + | 0 => ZMod M + | l + 1 => MaskTag h p (l + 1) → MaskState h p M l + +def shiftMaskState (h : ℕ) (p : ℕ → ℕ → ℕ) (M : ℕ) : + (l : ℕ) → MaskState h p M l → ZMod M → MaskState h p M l + | 0, v, θ => (show ZMod M from v) + θ + | l + 1, v, θ => fun j => shiftMaskState h p M l (v j) θ + +def maskGamma (h : ℕ) (p : ℕ → ℕ → ℕ) (M l a : ℕ) + (j : MaskTag h p l) : ZMod M := + (∑ k : Fin h, ((M / p l k * (a % p l k) : ℕ) : ZMod M)) + + ((j.2.val * (M / p l j.1) * (a % p l j.1) : ℕ) : ZMod M) + +def maskWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M : ℕ) : + (l : ℕ) → MaskState h p M l → List (MaskAlphabet h p l) + | 0, v => (List.range M).map (fun b => decide (((b : ZMod M) - (show ZMod M from v)).val < M / 2)) + | l + 1, v => (List.range (R * period h p (l + 1))).flatMap fun a => + (maskTags h p (l + 1)).flatMap fun j => + (maskWord h p R M l + (shiftMaskState h p M l (v j) (maskGamma h p M (l + 1) a j))).map + (fun x => (j, x)) + +def ExcludedAlphabet (m L : ℕ) : ℕ → Type + | 0 => Fin L × Bool + | l + 1 => Fin m × ExcludedAlphabet m L l + +instance excludedAlphabetFintype (m L l : ℕ) : Fintype (ExcludedAlphabet m L l) := by + induction l with + | zero => exact inferInstanceAs (Fintype (Fin L × Bool)) + | succ l ih => exact @instFintypeProd _ _ inferInstance ih + +def ExcludedState (m L : ℕ) : ℕ → Type + | 0 => ZMod L + | l + 1 => Fin m → ExcludedState m L l + +def shiftExcludedState (m L : ℕ) : + (l : ℕ) → ExcludedState m L l → ZMod L → ExcludedState m L l + | 0, v, θ => (show ZMod L from v) + θ + | l + 1, v, θ => fun i => shiftExcludedState m L l (v i) θ + +def excludedTranslation (m : ℕ) (p : ℕ → ℕ → ℕ) (L l s : ℕ) (i : Fin m) : + ZMod L := ∑ j ∈ Finset.univ.erase i, ((L / p l j * (s % p l j) : ℕ) : ZMod L) + +def excludedWord (m : ℕ) (p : ℕ → ℕ → ℕ) (R L : ℕ) : + (l : ℕ) → ExcludedState m L l → List (ExcludedAlphabet m L l) + | 0, v => List.ofFn fun b : Fin L => + (b, decide (((b.val : ZMod L) - (show ZMod L from v)).val < L / 2)) + | l + 1, v => (List.range (R * period m p (l + 1))).flatMap fun s => + (List.ofFn fun i : Fin m => + (excludedWord m p R L l + (shiftExcludedState m L l (v i) (excludedTranslation m p L (l + 1) s i))).map + (fun x => (i, x))).flatten + +def MaskWitness (a C δ lower : ℝ) (d : ℕ) : Prop := + ∃ h : ℕ, 2 ≤ h ∧ ∃ p : ℕ → ℕ → ℕ, MaskPrimes h p ∧ + ∃ (w : ℕ) (c : MaskAlphabet h p h → Fin w → Bool), + SubstitutionBounds a C c ∧ OffsetLocal δ c ∧ + ∃ n : ℕ, 0 < n ∧ n ≤ d ∧ + (∀ v : MaskState h p (circleSize h p) h, + (encode c (maskWord h p (h ^ (2 * h)) (circleSize h p) h v)).length = n) ∧ + Real.exp (lower * exponentScale d) ≤ setDistortion + (Set.range fun v : MaskState h p (circleSize h p) h => + encode c (maskWord h p (h ^ (2 * h)) (circleSize h p) h v)) + +def ExcludedWitness (a C ε lower : ℝ) (d : ℕ) : Prop := + ∃ m : ℕ, 2 ≤ m ∧ ∃ p : ℕ → ℕ → ℕ, ExcludedPrimes m p ∧ + ∃ (w : ℕ) (c : ExcludedAlphabet m (circleSize m p) m → Fin w → Bool), + SubstitutionBounds a C c ∧ AnchorLocal ε c ∧ + ∃ n : ℕ, 0 < n ∧ n ≤ d ∧ + (∀ v : ExcludedState m (circleSize m p) m, + (encode c (excludedWord m p (m ^ (2 * m)) (circleSize m p) m v)).length = n) ∧ + Real.exp (lower * exponentScale d) ≤ setDistortion + (Set.range fun v : ExcludedState m (circleSize m p) m => + encode c (excludedWord m p (m ^ (2 * m)) (circleSize m p) m v)) + +def UniformUpper (C : ℝ) (d₀ : ℕ) : Prop := + ∀ (α : Type) [Fintype α], 2 ≤ Fintype.card α → ∀ d : ℕ, d₀ ≤ d → + ∃ (M : ℕ) (F : Words α d → Fin M → ℝ), ∀ x y : Words α d, + (editDistance x.val y.val : ℝ) ≤ ∑ i, |F x i - F y i| ∧ + (∑ i, |F x i - F y i|) ≤ + Real.exp (C * exponentScale d) * editDistance x.val y.val + +def FullMain : Prop := + ∃ c C a Ccode δ ε : ℝ, ∃ d₀ : ℕ, + 0 < c ∧ 0 < C ∧ 0 < a ∧ 0 < Ccode ∧ 0 < δ ∧ 0 < ε ∧ + TwoCodes a Ccode δ ε ∧ UniformUpper C d₀ ∧ + (∀ (α : Type) [Fintype α], 2 ≤ Fintype.card α → ∀ d : ℕ, d₀ ≤ d → + Real.exp (c * exponentScale d) ≤ E α d ∧ + E α d ≤ Real.exp (C * exponentScale d)) ∧ + (∀ d : ℕ, d₀ ≤ d → + MaskWitness a Ccode δ c d ∧ ExcludedWitness a Ccode ε c d ∧ + Real.exp (c * exponentScale d) ≤ alphabetSupremum d ∧ + alphabetSupremum d ≤ Real.exp (C * exponentScale d)) + +noncomputable def unequalDeficit {α : Type u} (x y : List α) : ℕ := + max x.length y.length - lcs x y + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/OffsetRecovery.lean b/lean/OAI/Combinatorics/FiniteCircle/OffsetRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b626c8021f696e0b437f0c4849e86e4046b4b0e --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/OffsetRecovery.lean @@ -0,0 +1,443 @@ +import OAI.Combinatorics.FiniteCircle.WindowMatching + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +theorem common_offset_duplicate_loss (A : WordMatching x y q) {w i j t : ℕ} (hw : 0 < w) + (hij : i < j) {k l : Fin q} (hk : k ∈ A.blockPair w i t) (hl : l ∈ A.blockPair w j t) + (hmod : (A.left k).val%w = (A.left l).val%w) : + (A.right k).val%w < A.sourceLoss w i + A.sourceLoss w j := by + obtain ⟨hki, hkt⟩ := Finset.mem_inter.mp hk + obtain ⟨hlj, hlt⟩ := Finset.mem_inter.mp hl + let T := (A.sourceBlock w i).filter (fun v => k ≤ v) + let U := (A.sourceBlock w j).filter (fun v => v ≤ l) + have hdis : Disjoint T U := by + apply Finset.disjoint_left.mpr + intro v hv hu + exact (lt_irrefl v) (A.sourceBlock_order hij (Finset.mem_filter.mp hv).1 (Finset.mem_filter.mp hu).1) + have hmaps : Set.MapsTo A.right (↑(T ∪ U) : Set (Fin q)) + (↑(Finset.Icc (A.right k) (A.right l)) : Set (Fin y.length)) := by + intro v hv + change A.right v ∈ Finset.Icc (A.right k) (A.right l) + rcases Finset.mem_union.mp hv with hv | hv + · obtain ⟨hv, hkv⟩ := Finset.mem_filter.mp hv + exact Finset.mem_Icc.mpr ⟨A.right.monotone hkv, + A.right.monotone (A.sourceBlock_order hij hv hlj).le⟩ + · obtain ⟨hv, hvl⟩ := Finset.mem_filter.mp hv + exact Finset.mem_Icc.mpr ⟨A.right.monotone (A.sourceBlock_order hij hki hv).le, + A.right.monotone hvl⟩ + have hc := Finset.card_le_card_of_injOn A.right hmaps A.right.injective.injOn + rw [Finset.card_union_of_disjoint hdis, Fin.card_Icc] at hc + have hb := A.block_before_card_le hki + have ha := A.block_after_card_le hw hlj + have hTi : T.card + ((A.sourceBlock w i).filter (fun v => v < k)).card = (A.sourceBlock w i).card := by + simpa only [not_le] using Finset.card_filter_add_card_filter_not (s := A.sourceBlock w i) (p := fun v => k ≤ v) + have hUj : U.card + ((A.sourceBlock w j).filter (fun v => l < v)).card = (A.sourceBlock w j).card := by + simpa only [not_le] using Finset.card_filter_add_card_filter_not (s := A.sourceBlock w j) (p := fun v => v ≤ l) + have hXi : A.sourceLoss w i + (A.sourceBlock w i).card = w := Nat.sub_add_cancel (A.sourceBlock_card_le hw i) + have hXj : A.sourceLoss w j + (A.sourceBlock w j).card = w := Nat.sub_add_cancel (A.sourceBlock_card_le hw j) + have hrk := Nat.mod_add_div (A.right k).val w + have hrl := Nat.mod_add_div (A.right l).val w + have hkt' : (A.right k).val/w = t := (A.symm.mem_sourceBlock w t k).mp hkt + have hlt' : (A.right l).val/w = t := (A.symm.mem_sourceBlock w t l).mp hlt + rw [hkt'] at hrk + rw [hlt'] at hrl + have hklt := Nat.mod_lt (A.left k).val hw + have hllt := Nat.mod_lt (A.left l).val hw + have hrl_lt := Nat.mod_lt (A.right l).val hw + have hkl : (A.right k).val ≤ (A.right l).val := A.right.monotone (A.sourceBlock_order hij hki hlj).le + omega + +theorem common_offset_duplicates_card (A : WordMatching x y q) {w i : ℕ} + (hw : 0 < w) (hspan : (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w) : + ((A.sourceBlock w i).filter (fun k => ∃ l ∈ A.sourceBlock w (i+1), + (A.left k).val%w = (A.left l).val%w ∧ + (A.right k).val/w = (A.right l).val/w)).card ≤ + 3*(A.sourceLoss w i + A.sourceLoss w (i+1)) := by + classical + let S := (A.sourceBlock w i).filter (fun k => ∃ l ∈ A.sourceBlock w (i+1), + (A.left k).val%w = (A.left l).val%w ∧ + (A.right k).val/w = (A.right l).val/w) + let d := A.sourceLoss w i + A.sourceLoss w (i+1) + let f : Fin q → ℕ × ℕ := fun k => ((A.right k).val/w,(A.right k).val%w) + have hf : Function.Injective f := by + intro k l h + have h1 := congrArg Prod.fst h + have h2 := congrArg Prod.snd h + have hk := Nat.mod_add_div (A.right k).val w + have hl := Nat.mod_add_div (A.right l).val w + dsimp [f] at h1 h2 + rw [h1,h2] at hk + exact A.right.injective (Fin.ext (by omega)) + have hmaps : S.image f ⊆ A.targetBlocks w (A.sourceBlock w i) ×ˢ Finset.range d := by + intro v hv + obtain ⟨k,hk,rfl⟩ := Finset.mem_image.mp hv + obtain ⟨hki,l,hli,hmod,hdiv⟩ := Finset.mem_filter.mp hk + apply Finset.mem_product.mpr + refine ⟨Finset.mem_image.mpr ⟨k,hki,rfl⟩,Finset.mem_range.mpr ?_⟩ + have hkt : k ∈ A.blockPair w i ((A.right k).val/w) := Finset.mem_inter.mpr + ⟨hki,(A.symm.mem_sourceBlock _ _ _).mpr rfl⟩ + have hlt : l ∈ A.blockPair w (i+1) ((A.right k).val/w) := Finset.mem_inter.mpr + ⟨hli,(A.symm.mem_sourceBlock _ _ _).mpr hdiv.symm⟩ + exact A.common_offset_duplicate_loss hw (by omega) hkt hlt hmod + have hh := Finset.card_le_card hmaps + rw [Finset.card_image_of_injective S hf,Finset.card_product,Finset.card_range] at hh + exact hh.trans (Nat.mul_le_mul_right d (A.targetBlocks_card_le_three hw hspan)) + +end WordMatching + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +def matchedAt (A : WordMatching x y q) (w i p : ℕ) : Prop := + ∃ k : Fin q, (A.left k).val = i*w+p + +instance matchedAtDecidable (A : WordMatching x y q) (w i p : ℕ) : + Decidable (A.matchedAt w i p) := inferInstanceAs (Decidable (∃ k : Fin q, (A.left k).val = i*w+p)) + +noncomputable def partnerAt (A : WordMatching x y q) (w i p : ℕ) : ℕ := + if h : A.matchedAt w i p then (A.right (Classical.choose h)).val/w else 0 + +theorem partnerAt_eq (A : WordMatching x y q) {w i p : ℕ} {k : Fin q} + (hk : (A.left k).val = i*w+p) : A.partnerAt w i p = (A.right k).val/w := by + have hh : A.matchedAt w i p := ⟨k,hk⟩ + rw [partnerAt,dite_eq_left hh] + have he : Classical.choose hh = k := A.left.injective + (Fin.ext ((Classical.choose_spec hh).trans hk.symm)) + rw [he] + +theorem matchedAt_block (A : WordMatching x y q) {w i p : ℕ} {k : Fin q} + (hp : p < w) (hk : (A.left k).val = i*w+p) : + k ∈ A.sourceBlock w i ∧ (A.left k).val%w = p := by + have hd : (A.left k).val/w = i := + Nat.div_eq_of_lt_le (by omega) (by rw [hk,Nat.add_mul,one_mul]; omega) + refine ⟨(A.mem_sourceBlock w i k).mpr hd,?_⟩ + have hh := Nat.mod_add_div (A.left k).val w + rw [hd,Nat.mul_comm w i] at hh + omega + +theorem unmatched_offsets_card_le (A : WordMatching x y q) {w i : ℕ} + (hw : 0 < w) (I : Finset ℕ) (hI : I ⊆ Finset.range w) : + (I.filter (fun p => ¬ A.matchedAt w i p)).card ≤ A.sourceLoss w i := by + classical + let T := (A.sourceBlock w i).image (fun k => (A.left k).val%w) + have hT : T ⊆ Finset.range w := by + intro p hp + obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp hp + exact Finset.mem_range.mpr (Nat.mod_lt _ hw) + have hTc : T.card = (A.sourceBlock w i).card := + Finset.card_image_of_injOn A.mod_injectiveOn + have hs : I.filter (fun p => ¬ A.matchedAt w i p) ⊆ Finset.range w \ T := by + intro p hp + obtain ⟨hp,hn⟩ := Finset.mem_filter.mp hp + refine Finset.mem_sdiff.mpr ⟨hI hp,?_⟩ + intro ht + obtain ⟨k,hki,hkp⟩ := Finset.mem_image.mp ht + apply hn + refine ⟨k,?_⟩ + have hh := Nat.mod_add_div (A.left k).val w + rw [(A.mem_sourceBlock w i k).mp hki,hkp,Nat.mul_comm w i] at hh + omega + have hh := Finset.card_le_card hs + rwa [Finset.card_sdiff_of_subset hT,Finset.card_range,hTc] at hh + +def duplicateAt (A : WordMatching x y q) (w i p : ℕ) : Prop := + ∃ k l : Fin q, (A.left k).val = i*w+p ∧ (A.left l).val = (i+1)*w+p ∧ + (A.right k).val/w = (A.right l).val/w + +instance duplicateAtDecidable (A : WordMatching x y q) (w i p : ℕ) : + Decidable (A.duplicateAt w i p) := inferInstanceAs (Decidable (∃ k l : Fin q, + (A.left k).val = i*w+p ∧ (A.left l).val = (i+1)*w+p ∧ + (A.right k).val/w = (A.right l).val/w)) + +theorem duplicate_offsets_card_le (A : WordMatching x y q) {w i : ℕ} + (hw : 0 < w) (I : Finset ℕ) (hI : I ⊆ Finset.range w) + (hspan : (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w) : + (I.filter (A.duplicateAt w i)).card ≤ 3*(A.sourceLoss w i+A.sourceLoss w (i+1)) := by + classical + let T := (A.sourceBlock w i).filter (fun k => ∃ l ∈ A.sourceBlock w (i+1), + (A.left k).val%w = (A.left l).val%w ∧ + (A.right k).val/w = (A.right l).val/w) + have hs : I.filter (A.duplicateAt w i) ⊆ T.image (fun k => (A.left k).val%w) := by + intro p hp + obtain ⟨hp,k,l,hk,hl,hkl⟩ := Finset.mem_filter.mp hp + have hpw := Finset.mem_range.mp (hI hp) + obtain ⟨hki,hkp⟩ := A.matchedAt_block hpw hk + obtain ⟨hli,hlp⟩ := A.matchedAt_block hpw hl + exact Finset.mem_image.mpr ⟨k,Finset.mem_filter.mpr ⟨hki,l,hli,hkp.trans hlp.symm,hkl⟩,hkp⟩ + exact (Finset.card_le_card hs).trans ((Finset.card_image_le).trans + (A.common_offset_duplicates_card hw hspan)) + +end WordMatching + +theorem sum_card_filters_swap {α β : Type*} (S : Finset α) (T : Finset β) + (R : α → β → Prop) [DecidableRel R] : + ∑ a ∈ S, (T.filter (R a)).card = ∑ b ∈ T, (S.filter (fun a => R a b)).card := by + simp only [Finset.card_eq_sum_ones,Finset.sum_filter] + exact Finset.sum_comm + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +theorem sum_omitted_offsets_le (A : WordMatching x y q) {w L : ℕ} + (hw : 0 < w) (I G : Finset ℕ) (hI : I ⊆ Finset.range w) (hG : G ⊆ Finset.range L) : + (∑ p ∈ I, (L-(G.filter (fun i => A.matchedAt w i p)).card)) ≤ + I.card*(L-G.card) + ∑ i ∈ Finset.range L, A.sourceLoss w i := by + classical + have he (p : ℕ) : L-(G.filter (fun i => A.matchedAt w i p)).card = + L-G.card + (G.filter (fun i => ¬ A.matchedAt w i p)).card := by + have hh := Finset.card_filter_add_card_filter_not (s:=G) (p:=fun i => A.matchedAt w i p) + have hg := Finset.card_le_card hG + rw [Finset.card_range] at hg + omega + simp_rw [he] + rw [Finset.sum_add_distrib] + simp only [Finset.sum_const,smul_eq_mul] + rw [sum_card_filters_swap] + apply Nat.add_le_add_left + exact (Finset.sum_le_sum (fun i _ => A.unmatched_offsets_card_le hw I hI)).trans + (Finset.sum_le_sum_of_subset_of_nonneg hG (fun _ _ _ => Nat.zero_le _)) + +theorem sum_duplicate_offsets_le (A : WordMatching x y q) {w L : ℕ} + (hw : 0 < w) (I G : Finset ℕ) (hI : I ⊆ Finset.range w) (hG : G ⊆ Finset.range L) + (hspan : ∀ i ∈ G, (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w) : + (∑ p ∈ I, ((G.filter (fun i => i+1 < L)).filter (fun i => A.duplicateAt w i p)).card) ≤ + 6 * ∑ i ∈ Finset.range L, A.sourceLoss w i := by + classical + let H := G.filter (fun i => i+1 < L) + have hH : H ⊆ Finset.range L := (Finset.filter_subset _ _).trans hG + have hsucc : H.image (fun i => i+1) ⊆ Finset.range L := by + intro j hj + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hj + exact Finset.mem_range.mpr (Finset.mem_filter.mp hi).2 + have h1 : (∑ i ∈ H, A.sourceLoss w i) ≤ ∑ i ∈ Finset.range L, A.sourceLoss w i := + Finset.sum_le_sum_of_subset_of_nonneg hH (fun _ _ _ => Nat.zero_le _) + have h2 : (∑ i ∈ H, A.sourceLoss w (i+1)) ≤ ∑ i ∈ Finset.range L, A.sourceLoss w i := by + rw [← Finset.sum_image (g:=fun i => i+1) (by intro i _ j _ h; dsimp only at h; omega)] + exact Finset.sum_le_sum_of_subset_of_nonneg hsucc (fun _ _ _ => Nat.zero_le _) + rw [sum_card_filters_swap] + have hh : (∑ i ∈ H, (I.filter (fun p => A.duplicateAt w i p)).card) ≤ + ∑ i ∈ H, 3*(A.sourceLoss w i+A.sourceLoss w (i+1)) := by + apply Finset.sum_le_sum + intro i hi + exact A.duplicate_offsets_card_le hw I hI (hspan i (Finset.mem_filter.mp hi).1) + change (∑ i ∈ H, _) ≤ _ + refine hh.trans ?_ + rw [← Finset.mul_sum,Finset.sum_add_distrib] + omega + +end WordMatching + +namespace WordMatching +variable {α : Type*} {x y : List α} {w q : ℕ} {c : α → Fin w → Bool} + +theorem offset_deficit_le (A : WordMatching (encode c x) (encode c y) q) + (hw : 0 < w) (p : ℕ) (G : Finset ℕ) (hG : G ⊆ Finset.range x.length) + (hlabels : ∀ i ∈ G, ∀ k : Fin q, (A.left k).val=i*w+p → + x[i]? = y[(A.right k).val/w]?) : + deficit x y ≤ 2*(x.length-(G.filter (fun i => A.matchedAt w i p)).card) + + ((G.filter (fun i => i+1 < x.length)).filter (fun i => A.duplicateAt w i p)).card := by + classical + let S := G.filter (fun i => A.matchedAt w i p) + let f := fun i => A.partnerAt w i p + have hS : S ⊆ Finset.range x.length := (Finset.filter_subset _ _).trans hG + have hf : ∀ i ∈ S, f i < y.length := by + intro i hi + obtain ⟨k,hk⟩ := (Finset.mem_filter.mp hi).2 + rw [show f i = (A.right k).val/w from A.partnerAt_eq hk] + apply (Nat.div_lt_iff_lt_mul hw).mpr + simpa only [length_encode,Nat.mul_comm] using (A.right k).isLt + have hm : ∀ i ∈ S, ∀ j ∈ S, i ≤ j → f i ≤ f j := by + intro i hi j hj hij + obtain ⟨k,hk⟩ := (Finset.mem_filter.mp hi).2 + obtain ⟨l,hl⟩ := (Finset.mem_filter.mp hj).2 + rw [show f i = (A.right k).val/w from A.partnerAt_eq hk, + show f j = (A.right l).val/w from A.partnerAt_eq hl] + apply Nat.div_le_div_right + apply A.right.monotone + apply A.left.le_iff_le.mp + change (A.left k).val ≤ (A.left l).val + rw [hk,hl] + exact Nat.add_le_add_right (Nat.mul_le_mul_right w hij) p + have hl : ∀ i (hi : i ∈ S), x[i]'(Finset.mem_range.mp (hS hi)) = y[f i]'(hf i hi) := by + intro i hi + obtain ⟨k,hk⟩ := (Finset.mem_filter.mp hi).2 + have hh := hlabels i (Finset.mem_filter.mp hi).1 k hk + rw [← A.partnerAt_eq hk] at hh + change x[i]? = y[f i]? at hh + simpa only [List.getElem?_eq_getElem (Finset.mem_range.mp (hS hi)), + List.getElem?_eq_getElem (hf i hi),Option.some.injEq] using hh + have hh := monotone_assignment_deficit S hS f hf hm hl + have hs : S.filter (fun i => i+1 ∈ S ∧ f i=f (i+1)) ⊆ + (G.filter (fun i => i+1 < x.length)).filter (fun i => A.duplicateAt w i p) := by + intro i hi + obtain ⟨hi,hj,hfij⟩ := Finset.mem_filter.mp hi + obtain ⟨k,hk⟩ := (Finset.mem_filter.mp hi).2 + obtain ⟨l,hl⟩ := (Finset.mem_filter.mp hj).2 + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hi).1, + Finset.mem_range.mp (hS hj)⟩, k,l,hk,hl,?_⟩ + simpa only [f,A.partnerAt_eq hk,A.partnerAt_eq hl] using hfij + exact hh.trans (Nat.add_le_add_left (Finset.card_le_card hs) _) + +theorem averaged_offset_recovery (A : WordMatching (encode c x) (encode c y) q) + (hw : 0 < w) (I G : Finset ℕ) (hI : I ⊆ Finset.range w) (hG : G ⊆ Finset.range x.length) + (hspan : ∀ i ∈ G, (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w) + (hlabels : ∀ p ∈ I, ∀ i ∈ G, ∀ k : Fin q, (A.left k).val=i*w+p → + x[i]? = y[(A.right k).val/w]?) : + I.card * deficit x y ≤ 2*I.card*(x.length-G.card) + + 8*(w*x.length-q) := by + have hsum : (∑ i ∈ Finset.range x.length, A.sourceLoss w i) = w*x.length-q := by + have hh := A.sum_sourceLoss hw (length_encode c x) + simpa only [Fin.sum_univ_eq_sum_range] using hh + have hh := Finset.sum_le_sum (fun p (hp : p ∈ I) => A.offset_deficit_le hw p G hG (hlabels p hp)) + rw [Finset.sum_add_distrib,← Finset.mul_sum] at hh + simp only [Finset.sum_const,smul_eq_mul] at hh + have h1 := A.sum_omitted_offsets_le hw I G hI hG + have h2 := A.sum_duplicate_offsets_le hw I G hI hG hspan + rw [hsum] at h1 h2 + rw [Nat.mul_assoc] + omega + +end WordMatching + +namespace WordMatching +variable {α : Type*} {x y : List α} {w q : ℕ} {c : α → Fin w → Bool} + +noncomputable def offsetGood (A : WordMatching (encode c x) (encode c y) q) (w : ℕ) (η : ℝ) : Finset ℕ := + (Finset.range x.length).filter (fun i => + (A.sourceLoss w i : ℝ) ≤ η*w ∧ (A.spanLoss w i : ℝ) ≤ η*w) + +theorem offsetGood_subset (A : WordMatching (encode c x) (encode c y) q) (w : ℕ) (η : ℝ) : + A.offsetGood w η ⊆ Finset.range x.length := Finset.filter_subset _ _ + +theorem offsetGood_span (A : WordMatching (encode c x) (encode c y) q) + (hw : 0 < w) {η : ℝ} (hη : η ≤ 1) {i : ℕ} (hi : i ∈ A.offsetGood w η) : + (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w := by + have hv := (Finset.mem_filter.mp hi).2.2 + have hv' : (A.spanLoss w i : ℝ) ≤ w := hv.trans (by nlinarith only [hη,(show (0 : ℝ) ≤ w from Nat.cast_nonneg w)]) + have hvn : A.spanLoss w i ≤ w := by exact_mod_cast hv' + have h1 := A.card_le_rightSpan (A.sourceBlock w i) + have h2 := A.sourceBlock_card_le hw i + dsimp only [spanLoss] at hvn + omega + +theorem offsetGood_bad_cost (A : WordMatching (encode c x) (encode c y) q) + (hw : 0 < w) (hlen : x.length=y.length) (η : ℝ) : + η*w*(x.length-(A.offsetGood w η).card : ℕ) ≤ 2*(w*x.length-q : ℕ) := by + classical + let G := A.offsetGood w η + let B := Finset.range x.length \ G + have hG : G ⊆ Finset.range x.length := A.offsetGood_subset w η + have hBc : B.card=x.length-G.card := by rw [Finset.card_sdiff_of_subset hG,Finset.card_range] + have hbad (i : ℕ) (hi : i ∈ B) : η*w ≤ (A.sourceLoss w i : ℝ)+A.spanLoss w i := by + obtain ⟨hi,hn⟩ := Finset.mem_sdiff.mp hi + have hn' : ¬ ((A.sourceLoss w i : ℝ) ≤ η*w ∧ (A.spanLoss w i : ℝ) ≤ η*w) := by + intro hh + exact hn (Finset.mem_filter.mpr ⟨hi,hh⟩) + have hU : (0 : ℝ) ≤ A.sourceLoss w i := Nat.cast_nonneg _ + have hV : (0 : ℝ) ≤ A.spanLoss w i := Nat.cast_nonneg _ + push Not at hn' + by_cases hh : (A.sourceLoss w i : ℝ) ≤ η*w + · have hv := hn' hh + linarith + · push Not at hh + linarith + have hsumU : (∑ i ∈ Finset.range x.length, (A.sourceLoss w i : ℝ)) = (w*x.length-q : ℕ) := by + have hh := A.sum_sourceLoss hw (length_encode c x) + rw [Fin.sum_univ_eq_sum_range] at hh + exact_mod_cast hh + have hsumV : (∑ i ∈ Finset.range x.length, (A.spanLoss w i : ℝ)) ≤ (w*x.length-q : ℕ) := by + have hh := A.sum_spanLoss_le hw (length_encode c x) (by rw [length_encode,hlen]) + rw [Fin.sum_univ_eq_sum_range] at hh + exact_mod_cast hh + have hcost : η*w*(B.card : ℝ) ≤ ∑ i ∈ Finset.range x.length, + ((A.sourceLoss w i : ℝ)+A.spanLoss w i) := calc + _ = ∑ _i ∈ B, η*w := by simp [mul_comm] + _ ≤ ∑ i ∈ B, ((A.sourceLoss w i : ℝ)+A.spanLoss w i) := Finset.sum_le_sum hbad + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg Finset.sdiff_subset + (fun _ _ _ => add_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + rw [Finset.sum_add_distrib,hsumU,hBc] at hcost + change η*w*(x.length-G.card : ℕ) ≤ _ + linarith only [hcost,hsumV] + +end WordMatching + +theorem offset_deficit_lower {α : Type*} {w : ℕ} (hw : 12 ≤ w) {δ η : ℝ} + (hδ : δ ≤ 1) (hη0 : 0 ≤ η) (hη : η ≤ 1) + (hfit : 2*η*w < δ*(w/8 : ℕ)) {c : α → Fin w → Bool} (hc : OffsetLocal δ c) + (x y : List α) (hlen : x.length=y.length) : + (η/(4+32*η))*w*deficit x y ≤ (deficit (encode c x) (encode c y) : ℝ) := by + classical + have hwp : 0 < w := by omega + obtain ⟨A⟩ := exists_lcs_matching (encode c x) (encode c y) + let G := A.offsetGood w η + let I := Finset.Icc ((w+2)/3) (2*w/3) + let E := deficit (encode c x) (encode c y) + have hG : G ⊆ Finset.range x.length := A.offsetGood_subset w η + have hI : I ⊆ Finset.range w := by + intro p hp + obtain ⟨h1,h2⟩ := Finset.mem_Icc.mp hp + apply Finset.mem_range.mpr + omega + have hIp (p : ℕ) (hp : p ∈ I) : w/8 ≤ p ∧ p+w/8 ≤ w := by + obtain ⟨h1,h2⟩ := Finset.mem_Icc.mp hp + omega + have hIc : w ≤ 4*I.card := by + simp only [I,Nat.card_Icc] + omega + have hspan : ∀ i ∈ G, (A.rightSpan (A.sourceBlock w i)).card ≤ 2*w := + fun _ hi => A.offsetGood_span hwp hη hi + have hlabels : ∀ p ∈ I, ∀ i ∈ G, ∀ k : Fin _, (A.left k).val=i*w+p → + x[i]? = y[(A.right k).val/w]? := by + intro p hp i hi k hk + have hil := Finset.mem_range.mp (hG hi) + have hjl : (A.right k).val/w < y.length := by + apply (Nat.div_lt_iff_lt_mul hwp).mpr + simpa only [length_encode,Nat.mul_comm] using (A.right k).isLt + obtain ⟨hki,hkp⟩ := A.matchedAt_block (Finset.mem_range.mp (hI hp)) hk + have hgood := (Finset.mem_filter.mp hi).2 + have hloss : (A.sourceLoss w i+A.spanLoss w i : ℕ) < δ*(w/8 : ℕ) := by + push_cast + linarith only [hgood.1,hgood.2,hfit] + have hh := A.offset_interior_labels hwp hδ hc k ⟨i,hil⟩ ⟨(A.right k).val/w,hjl⟩ + ((A.mem_sourceBlock w i k).mp hki) rfl (by rw [hkp]; exact (hIp p hp).1) + (by rw [hkp]; exact (hIp p hp).2) hloss + simpa only [List.getElem?_eq_getElem hil,List.getElem?_eq_getElem hjl, + List.get_eq_getElem,Option.some.injEq] using hh + have hav := A.averaged_offset_recovery hwp I G hI hG hspan hlabels + have he : w*x.length-lcs (encode c x) (encode c y) = E := by simp only [E,deficit,length_encode] + rw [he] at hav + have havr : (I.card : ℝ)*deficit x y ≤ 2*(I.card : ℝ)*(x.length-G.card : ℕ)+8*E := by exact_mod_cast hav + have hbad := A.offsetGood_bad_cost hwp hlen η + rw [he] at hbad + have hbad' : η*w*(x.length-G.card : ℕ) ≤ 2*E := hbad + have hicr : (w : ℝ) ≤ 4*I.card := by exact_mod_cast hIc + have hip : (0 : ℝ) < I.card := by exact_mod_cast (show 0 < I.card by omega) + have hmain : η*w*(deficit x y : ℝ) ≤ (4+32*η)*E := by + apply (mul_le_mul_iff_right₀ hip).mp + calc + _ = η*w*((I.card : ℝ)*deficit x y) := by ring + _ ≤ η*w*(2*(I.card : ℝ)*(x.length-G.card : ℕ)+8*E) := + mul_le_mul_of_nonneg_left havr (mul_nonneg hη0 (Nat.cast_nonneg w)) + _ = 2*(I.card : ℝ)*(η*w*(x.length-G.card : ℕ))+8*η*w*E := by ring + _ ≤ 2*(I.card : ℝ)*(2*E)+8*η*(4*I.card)*E := add_le_add + (mul_le_mul_of_nonneg_left hbad' (by positivity)) + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hicr (by positivity)) (Nat.cast_nonneg E)) + _ = (I.card : ℝ)*((4+32*η)*E) := by ring + have hden : 0 < 4+32*η := by linarith + calc + _ = (η*w*(deficit x y : ℝ))/(4+32*η) := by ring + _ ≤ E := (div_le_iff₀ hden).mpr (by simpa only [mul_comm] using hmain) + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Parameters.lean b/lean/OAI/Combinatorics/FiniteCircle/Parameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..7177e2f431c741385d334cd99777110a6f412d18 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Parameters.lean @@ -0,0 +1,294 @@ +import OAI.Combinatorics.FiniteCircle.Distortion + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem StandingPrimes.small_prime {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2 ≤ h) (l : ℕ) (hl : 1≤l) (hlh : l≤h) (k : Fin h) : + p l k ≤ h^4 := by + apply (hp.atLevel l hl hlh k).2.2.trans + calc + 2*h^3 ≤ h*h^3 := Nat.mul_le_mul_right _ hh + _ = h^4 := by ring + + theorem StandingPrimes.period_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2 ≤ h) (l : ℕ) (hl : 1≤l) (hlh : l≤h) : + period h p l ≤ h^(4*h) := by + calc + _ ≤ ∏ _k : Fin h, h^4 := Finset.prod_le_prod (fun k _ => hp.small_prime hh l hl hlh k) + _ = _ := by simp [← pow_mul] + + theorem StandingPrimes.circle_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2 ≤ h) : circleSize h p ≤ h^(5*h^2) := by + calc + _ ≤ h*(∏ _l : Fin h, h^(4*h)) := Nat.mul_le_mul hh + (Finset.prod_le_prod (fun l _ => hp.period_bound hh (l.val+1) (by omega) (by omega))) + _ = h^(4*h^2+1) := by simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin, ← pow_mul]; ring + _ ≤ _ := Nat.pow_le_pow_right (by omega) (by nlinarith) + + theorem StandingPrimes.log_circle_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2 ≤ h) : Nat.log 2 (circleSize h p)+1 ≤ 6*h^3 := by + have ht : h ≤ 2^h := (Nat.lt_two_pow_self (n:=h)).le + have hm : circleSize h p ≤ 2^(5*h^3) := by + calc + _ ≤ h^(5*h^2) := hp.circle_bound hh + _ ≤ (2^h)^(5*h^2) := Nat.pow_le_pow_left ht _ + _ = _ := by rw [← pow_mul]; congr 1; ring + have hn := Nat.log_mono_right hm (b:=2) + rw [Nat.log_pow (by norm_num : 1<2)] at hn + have hp3 : 0 hp.small_prime hh l hl hlh k) + _ = _ := by simp; ring + + theorem StandingPrimes.tag_card_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2 ≤ h) (l : ℕ) (hl : 1≤l) (hlh : l≤h) : + Fintype.card (MaskTag h p l) ≤ h^5 := by + simpa [Fintype.card_sigma, MaskTag, length_maskTags] using hp.tags_bound hh l hl hlh + + theorem recursive_length_bound (h M : ℕ) (P T L : ℕ → ℕ) (hh : 3≤h) + (h0 : L 0=M) (hs : ∀ l, L (l+1)=(h^(2*h)*P (l+1))*(T (l+1)*L l)) + (hP : ∀ l, 1≤l → l≤h → P l≤h^(4*h)) + (hT : ∀ l, 1≤l → l≤h → T l≤h^5) : + ∀ l, l≤h → L l ≤ M*h^(8*h*l) := by + intro l + induction l with + | zero => intro _; simp [h0] + | succ l ih => + intro hl + rw [hs] + calc + _ ≤ (h^(2*h)*h^(4*h))*(h^5*(M*h^(8*h*l))) := + Nat.mul_le_mul (Nat.mul_le_mul_left _ (hP _ (by omega) hl)) + (Nat.mul_le_mul (hT _ (by omega) hl) (ih (by omega))) + _ = M*h^(2*h+4*h+5+8*h*l) := by ring + _ ≤ _ := Nat.mul_le_mul_left _ (Nat.pow_le_pow_right (by omega) (by nlinarith)) + + theorem StandingPrimes.mask_length_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 3≤h) : + maskLength h p (h^(2*h)) (circleSize h p) h ≤ h^(13*h^2) := by + have ht := recursive_length_bound h (circleSize h p) (period h p) + (fun l => (maskTags h p l).length) (maskLength h p (h^(2*h)) (circleSize h p)) hh rfl + (fun _ => rfl) (hp.period_bound (by omega)) (hp.tags_bound (by omega)) h (le_refl _) + calc + _ ≤ circleSize h p*h^(8*h*h) := ht + _ ≤ h^(5*h^2)*h^(8*h*h) := Nat.mul_le_mul_right _ (hp.circle_bound (by omega)) + _ = _ := by ring + + theorem StandingPrimes.excluded_length_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 3≤h) : + excludedLength h p (h^(2*h)) (circleSize h p) h ≤ h^(13*h^2) := by + have ht := recursive_length_bound h (circleSize h p) (period h p) + (fun _ => h) (excludedLength h p (h^(2*h)) (circleSize h p)) hh rfl + (fun l => by simp only [excludedLength,length_excludedTags]) (hp.period_bound (by omega)) + (fun _ _ _ => le_self_pow₀ (by omega) (by norm_num)) h (le_refl _) + calc + _ ≤ circleSize h p*h^(8*h*h) := ht + _ ≤ h^(5*h^2)*h^(8*h*h) := Nat.mul_le_mul_right _ (hp.circle_bound (by omega)) + _ = _ := by ring + + theorem StandingPrimes.mask_alphabet_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2≤h) : + Fintype.card (MaskAlphabet h p h) ≤ h^(6*h^2) := by + have hc : ∀ l, l≤h → Fintype.card (MaskAlphabet h p l) ≤ 2*h^(5*l) := by + intro l + induction l with + | zero => intro _; change Fintype.card Bool ≤ 2*h^(5*0); norm_num + | succ l ih => + intro hl + calc + _ = Fintype.card (MaskTag h p (l+1))*Fintype.card (MaskAlphabet h p l) := Fintype.card_prod _ _ + _ ≤ h^5*(2*h^(5*l)) := Nat.mul_le_mul (hp.tag_card_bound hh _ (by omega) hl) (ih (by omega)) + _ = _ := by ring + calc + _ ≤ 2*h^(5*h) := hc h (le_refl _) + _ ≤ h*h^(5*h) := Nat.mul_le_mul_right _ hh + _ = h^(5*h+1) := by ring + _ ≤ _ := Nat.pow_le_pow_right (by omega) (by nlinarith) + + theorem StandingPrimes.excluded_alphabet_bound {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 2≤h) : + Fintype.card (ExcludedAlphabet h (circleSize h p) h) ≤ h^(6*h^2) := by + have hc : ∀ l, Fintype.card (ExcludedAlphabet h (circleSize h p) l) = h^l*(circleSize h p*2) := by + intro l + induction l with + | zero => change Fintype.card (Fin (circleSize h p) × Bool) = 1*(circleSize h p*2); simp + | succ l ih => change Fintype.card (Fin h × ExcludedAlphabet h (circleSize h p) l) = _ + rw [Fintype.card_prod,Fintype.card_fin,ih]; ring + rw [hc] + calc + _ ≤ h^h*(h^(5*h^2)*h) := Nat.mul_le_mul_left _ (Nat.mul_le_mul (hp.circle_bound hh) hh) + _ = h^(5*h^2+h+1) := by ring + _ ≤ _ := Nat.pow_le_pow_right (by omega) (by nlinarith) + + theorem StandingPrimes.mask_alphabet_ge {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 1≤h) (l : ℕ) : 2≤Fintype.card (MaskAlphabet h p l) := by + have hT (l : ℕ) : 1≤Fintype.card (MaskTag h p l) := by + have ht : h≤∑ k : Fin h, p l k := by + calc + _ = ∑ _k : Fin h, 1 := by simp + _ ≤ _ := Finset.sum_le_sum (fun k _ => hp.positive l k) + simpa only [MaskTag,Fintype.card_sigma,Fintype.card_fin] using hh.trans ht + induction l with + | zero => change 2≤Fintype.card Bool; norm_num + | succ l ih => + change 2≤Fintype.card (MaskTag h p (l+1) × MaskAlphabet h p l) + rw [Fintype.card_prod] + nlinarith [hT (l+1)] + + theorem StandingPrimes.excluded_alphabet_ge {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 1≤h) (l : ℕ) : + 2≤Fintype.card (ExcludedAlphabet h (circleSize h p) l) := by + induction l with + | zero => + change 2≤Fintype.card (Fin (circleSize h p) × Bool) + rw [Fintype.card_prod,Fintype.card_fin,Fintype.card_bool] + have ht := hp.circle_pos + omega + | succ l ih => + change 2≤Fintype.card (Fin h × ExcludedAlphabet h (circleSize h p) l) + rw [Fintype.card_prod,Fintype.card_fin] + nlinarith + + theorem StandingPrimes.mask_length_pos {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 1≤h) {R : ℕ} (hR : 0 exact hp.circle_pos + | succ l ih => + have hT : h≤(maskTags h p (l+1)).length := by + rw [length_maskTags] + calc + _ = ∑ _k : Fin h, 1 := by simp + _ ≤ _ := Finset.sum_le_sum (fun k _ => hp.positive _ k) + exact Nat.mul_pos (Nat.mul_pos hR (hp.period_pos _)) (Nat.mul_pos (by omega) ih) + + theorem StandingPrimes.excluded_length_pos {h : ℕ} {p : ℕ → ℕ → ℕ} + (hp : StandingPrimes h p) (hh : 1≤h) {R : ℕ} (hR : 0 exact hp.circle_pos + | succ l ih => + simp only [excludedLength,length_excludedTags] + exact Nat.mul_pos (Nat.mul_pos hR (hp.period_pos _)) (Nat.mul_pos (by omega) ih) + + theorem logarithmic_width_bound {h A w : ℕ} (hh : 100000000≤h) (hA : 0 if P ω then 1 else 0) := by + classical + unfold event expect + apply Finset.sum_congr rfl + intro ω _ + by_cases h : P ω <;> simp [h] + +theorem expect_nonneg (μ : FiniteLaw Ω) {f : Ω → ℝ} (hf : ∀ ω, 0 ≤ f ω) : + 0 ≤ μ.expect f := Finset.sum_nonneg (fun ω _ => mul_nonneg (μ.nonneg ω) (hf ω)) + +theorem expect_mono (μ : FiniteLaw Ω) {f g : Ω → ℝ} (h : ∀ ω, f ω ≤ g ω) : + μ.expect f ≤ μ.expect g := + Finset.sum_le_sum (fun ω _ => mul_le_mul_of_nonneg_left (h ω) (μ.nonneg ω)) + +@[simp] theorem expect_const (μ : FiniteLaw Ω) (a : ℝ) : μ.expect (fun _ => a) = a := by + simp only [expect, ← Finset.sum_mul, μ.total, one_mul] + +theorem expect_add (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.expect (fun ω => f ω + g ω) = μ.expect f + μ.expect g := by + simp only [expect, mul_add, Finset.sum_add_distrib] + +theorem expect_sub (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.expect (fun ω => f ω - g ω) = μ.expect f - μ.expect g := by + simp only [expect, mul_sub, Finset.sum_sub_distrib] + +theorem expect_smul (μ : FiniteLaw Ω) (a : ℝ) (f : Ω → ℝ) : + μ.expect (fun ω => a * f ω) = a * μ.expect f := by + simp only [expect, mul_left_comm _ a, Finset.mul_sum] + +theorem expect_sum {ι : Type*} (μ : FiniteLaw Ω) (s : Finset ι) (f : ι → Ω → ℝ) : + μ.expect (fun ω => ∑ i ∈ s, f i ω) = ∑ i ∈ s, μ.expect (f i) := by + simp only [expect, Finset.mul_sum] + exact Finset.sum_comm + +theorem event_nonneg (μ : FiniteLaw Ω) (P : Ω → Prop) : 0 ≤ μ.event P := by + classical + apply Finset.sum_nonneg + intro ω _ + split <;> first | exact μ.nonneg ω | exact le_rfl + +theorem event_mono (μ : FiniteLaw Ω) {P Q : Ω → Prop} (h : ∀ ω, P ω → Q ω) : + μ.event P ≤ μ.event Q := by + classical + apply Finset.sum_le_sum + intro ω _ + by_cases hp : P ω <;> by_cases hq : Q ω <;> simp [hp, hq] + · exact (hq (h ω hp)).elim + · exact μ.nonneg ω + +@[simp] theorem event_true (μ : FiniteLaw Ω) : μ.event (fun _ => True) = 1 := by + simp [event, μ.total] + +@[simp] theorem event_false (μ : FiniteLaw Ω) : μ.event (fun _ => False) = 0 := by simp [event] + +theorem event_le_one (μ : FiniteLaw Ω) (P : Ω → Prop) : μ.event P ≤ 1 := by + simpa only [event_true] using μ.event_mono (P := P) (Q := fun _ => True) (fun _ _ => trivial) + +theorem event_compl (μ : FiniteLaw Ω) (P : Ω → Prop) : + μ.event (fun ω => ¬P ω) = 1 - μ.event P := by + classical + rw [← μ.total] + unfold event + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro ω _ + by_cases h : P ω <;> simp [h] + +theorem event_exists_le_sum {ι : Type*} [Fintype ι] (μ : FiniteLaw Ω) (P : ι → Ω → Prop) : + μ.event (fun ω => ∃ i, P i ω) ≤ ∑ i, μ.event (P i) := by + classical + simp only [event_eq_expect] + rw [← μ.expect_sum] + apply μ.expect_mono + intro ω + by_cases h : ∃ i, P i ω + · obtain ⟨i, hi⟩ := h + rw [ite_eq_left ⟨i, hi⟩] + exact (by simpa only [ite_eq_left hi] using + (Finset.single_le_sum (f := fun j : ι => if P j ω then (1 : ℝ) else 0) + (fun j _ => by split <;> norm_num) (Finset.mem_univ i))) + · simp [show ∀ i, ¬ P i ω from fun i hi => h ⟨i, hi⟩] +end FiniteLaw + +noncomputable def selectionWeight {I : Type*} [Fintype I] (q : I → ℝ) (s : I → Bool) : ℝ := + ∏ i, if s i then 1 - q i else q i + +def selectionLabel {I X : Type*} (c : I → X → Bool) (s : I → Bool) (x : X) : I → Bool := + fun i => s i && c i x + +theorem selectionWeight_nonneg {I : Type*} [Fintype I] (q : I → ℝ) + (hq : ∀ i, 0 ≤ q i ∧ q i ≤ 1) (s : I → Bool) : 0 ≤ selectionWeight q s := by + apply Finset.prod_nonneg + intro i _ + split + · exact sub_nonneg.mpr (hq i).2 + · exact (hq i).1 + +theorem selectionWeight_total {I : Type*} [Fintype I] [DecidableEq I] (q : I → ℝ) : + ∑ s : I → Bool, selectionWeight q s = 1 := by + unfold selectionWeight + rw [← Fintype.prod_sum (fun i (b : Bool) => if b then 1 - q i else q i)] + simp + +theorem selection_collision {I X : Type*} [Fintype I] [DecidableEq I] + (q : I → ℝ) (c : I → X → Bool) (x y : X) : + (∑ s : I → Bool, if selectionLabel c s x = selectionLabel c s y then selectionWeight q s else 0) = + ∏ i, if c i x = c i y then 1 else q i := by + classical + have hterm (s : I → Bool) : + (if selectionLabel c s x = selectionLabel c s y then selectionWeight q s else 0) = + ∏ i, if (s i && c i x) = (s i && c i y) then + (if s i then 1 - q i else q i) else 0 := by + rw [Fintype.prod_ite_zero] + simp only [selectionLabel, selectionWeight, funext_iff] + simp_rw [hterm] + rw [← Fintype.prod_sum (fun i (b : Bool) => + if (b && c i x) = (b && c i y) then (if b then 1 - q i else q i) else 0)] + apply Finset.prod_congr rfl + intro i _ + simp only [Fintype.sum_bool] + cases hcx : c i x <;> cases hcy : c i y <;> simp + +abbrev PartitionSpace (X : Type*) := (X → Bool) → Bool + +theorem finite_partition {X : Type*} [Fintype X] {ρ : X → X → ℝ} + (hρ : HasCutRepresentation ρ) (α : ℝ) (hα : 0 ≤ α) : by + classical + exact ∃ (μ : FiniteLaw (PartitionSpace X)) (label : PartitionSpace X → X → PartitionSpace X), + ∀ x y, μ.event (fun ω => label ω x = label ω y) = Real.exp (-α * ρ x y) := by + classical + obtain ⟨a, ha, hrep⟩ := hρ + let q : (X → Bool) → ℝ := fun c => Real.exp (-α * a c) + have hq (c : X → Bool) : 0 ≤ q c ∧ q c ≤ 1 := by + constructor + · exact (Real.exp_pos _).le + · apply Real.exp_le_one_iff.mpr + exact mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hα) (ha c) + let μ : FiniteLaw (PartitionSpace X) := + ⟨selectionWeight q, selectionWeight_nonneg q hq, selectionWeight_total q⟩ + refine ⟨μ, selectionLabel (fun c => c), ?_⟩ + intro x y + dsimp only [FiniteLaw.event, μ] + trans ∏ c : X → Bool, if c x = c y then (1 : ℝ) else q c + · convert selection_collision q (fun c : X → Bool => c) x y using 1 + apply Finset.sum_congr rfl + intro ω _ + by_cases h : selectionLabel (fun c : X → Bool => c) ω x = selectionLabel (fun c => c) ω y <;> simp [h] + have he (c : X → Bool) : (if c x = c y then (1 : ℝ) else q c) = + Real.exp (-α * (a c * cutDistance c x y)) := by + by_cases h : c x = c y <;> simp [h, cutDistance, q] + simp_rw [he] + rw [← Real.exp_sum, ← Finset.mul_sum] + congr 2 + exact (hrep x y).symm + +theorem partition_separation_le {X Ω Y : Type*} [Fintype Ω] + (μ : FiniteLaw Ω) (label : Ω → X → Y) (ρ : X → X → ℝ) (α : ℝ) + (he : ∀ x y, μ.event (fun ω => label ω x = label ω y) = Real.exp (-α * ρ x y)) + (x y : X) : μ.event (fun ω => label ω x ≠ label ω y) ≤ α * ρ x y := by + rw [μ.event_compl, he] + have h := Real.add_one_le_exp (-α * ρ x y) + linarith + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/PhaseCost.lean b/lean/OAI/Combinatorics/FiniteCircle/PhaseCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..f48654b4631273e0790f8ce5da94a217f0375361 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/PhaseCost.lean @@ -0,0 +1,165 @@ +import OAI.Combinatorics.FiniteCircle.TaggedRows + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +noncomputable def circleCost {M : ℕ} (x : ZMod M) : ℝ := x.valMinAbs.natAbs / (M : ℝ) + +@[simp] theorem circleCost_zero (M : ℕ) : circleCost (0 : ZMod M) = 0 := by + simp [circleCost] + +theorem circleCost_nonneg {M : ℕ} (x : ZMod M) : 0 ≤ circleCost x := by + unfold circleCost + positivity + +@[simp] theorem circleCost_neg {M : ℕ} (x : ZMod M) : circleCost (-x) = circleCost x := by + simp [circleCost, ZMod.natAbs_valMinAbs_neg] + +theorem circleCost_add_le {M : ℕ} (x y : ZMod M) : + circleCost (x+y) ≤ circleCost x + circleCost y := by + have h := (ZMod.natAbs_valMinAbs_add_le x y).trans (Int.natAbs_add_le _ _) + unfold circleCost + rw [← add_div] + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast h + +theorem circleCost_le_half {M : ℕ} [NeZero M] (x : ZMod M) : circleCost x ≤ 1/2 := by + have hM : 0 < M := NeZero.pos M + have h := ZMod.natAbs_valMinAbs_le x + have h' : 2*x.valMinAbs.natAbs ≤ M := by omega + unfold circleCost + rw [div_le_iff₀ (by exact_mod_cast hM)] + have hh : 2*(x.valMinAbs.natAbs : ℝ) ≤ M := by exact_mod_cast h' + linarith + +theorem circleCost_pos {M : ℕ} [NeZero M] {x : ZMod M} (hx : x ≠ 0) : 0 < circleCost x := by + have hn : x.valMinAbs.natAbs ≠ 0 := by + intro he + exact hx ((ZMod.valMinAbs_eq_zero x).mp (Int.natAbs_eq_zero.mp he)) + unfold circleCost + exact div_pos (by exact_mod_cast Nat.pos_of_ne_zero hn) (by exact_mod_cast NeZero.pos M) + +theorem circleCost_order_lower {M q : ℕ} [NeZero M] {x : ZMod M} + (hq : 0 < q) (hx : x ≠ 0) (hqx : q • x = 0) : 1 ≤ (q : ℝ)*circleCost x := by + have he : (((q : ℤ)*x.valMinAbs : ℤ) : ZMod M) = 0 := by + simpa [nsmul_eq_mul] using hqx + have hd := (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mp he + have hd' : M ∣ q*x.valMinAbs.natAbs := by + have hh := Int.natAbs_dvd_natAbs.mpr hd + simpa only [Int.natAbs_mul, Int.natAbs_natCast] using hh + have ha : 0 < x.valMinAbs.natAbs := by + apply Nat.pos_of_ne_zero + intro he + exact hx ((ZMod.valMinAbs_eq_zero x).mp (Int.natAbs_eq_zero.mp he)) + have hm := Nat.le_of_dvd (Nat.mul_pos hq ha) hd' + unfold circleCost + rw [← mul_div_assoc, le_div_iff₀ (by exact_mod_cast NeZero.pos M)] + simp only [one_mul] + exact_mod_cast hm + +structure PhaseCost (G : Type*) [AddCommGroup G] where + toFun : G → ℝ + nonneg : ∀ x, 0 ≤ toFun x + zero : toFun 0 = 0 + neg : ∀ x, toFun (-x) = toFun x + add_le : ∀ x y, toFun (x+y) ≤ toFun x + toFun y + +instance {G : Type*} [AddCommGroup G] : CoeFun (PhaseCost G) (fun _ => G → ℝ) := ⟨PhaseCost.toFun⟩ + +noncomputable def circlePhaseCost (M : ℕ) : PhaseCost (ZMod M) := + ⟨circleCost, circleCost_nonneg, circleCost_zero M, circleCost_neg, circleCost_add_le⟩ + +namespace PhaseCost +variable {G H J : Type*} [AddCommGroup G] [AddCommGroup H] [Fintype H] [Fintype J] + +noncomputable def average (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) (s : H) : ℝ := + (∑ j, f (x + σ s j)) / Fintype.card J + +noncomputable def infAverage (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) : ℝ := + Finset.univ.inf' Finset.univ_nonempty (f.average σ x) + +theorem infAverage_le (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) (s : H) : + f.infAverage σ x ≤ f.average σ x s := + Finset.inf'_le _ (Finset.mem_univ s) + +theorem exists_average_eq (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) : + ∃ s : H, f.infAverage σ x = f.average σ x s := by + obtain ⟨s,_,hs⟩ := Finset.exists_mem_eq_inf' Finset.univ_nonempty (f.average σ x) + exact ⟨s,hs⟩ + +theorem infAverage_nonneg (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) : + 0 ≤ f.infAverage σ x := by + apply Finset.le_inf' + intro s _ + exact div_nonneg (Finset.sum_nonneg (fun _ _ => f.nonneg _)) (by positivity) + +omit [Fintype H] in +@[simp] theorem average_zero_mask [Nonempty J] (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) : + f.average σ x 0 = f x := by + simp only [average, map_zero, Pi.zero_apply, add_zero, Finset.sum_const, + Finset.card_univ, nsmul_eq_mul] + exact mul_div_cancel_left₀ _ (by exact_mod_cast (Fintype.card_pos : 0 < Fintype.card J).ne') + +theorem infAverage_le_self [Nonempty J] (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) : + f.infAverage σ x ≤ f x := by + simpa using f.infAverage_le σ x 0 + +@[simp] theorem infAverage_zero (f : PhaseCost G) (σ : H →+ (J → G)) : + f.infAverage σ 0 = 0 := by + apply le_antisymm + · refine (f.infAverage_le σ 0 0).trans_eq ?_ + simp only [average, map_zero, Pi.zero_apply, add_zero, f.zero, + Finset.sum_const_zero, zero_div] + · exact f.infAverage_nonneg σ 0 + +omit [Fintype H] in +@[simp] theorem average_neg (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) (s : H) : + f.average σ (-x) (-s) = f.average σ x s := by + unfold average + congr 1 + apply Finset.sum_congr rfl + intro j _ + have he : -x+σ (-s) j = -(x+σ s j) := by simp [add_comm] + rw [he, f.neg] + +@[simp] theorem infAverage_neg (f : PhaseCost G) (σ : H →+ (J → G)) (x : G) : + f.infAverage σ (-x) = f.infAverage σ x := by + have aux (x : G) : f.infAverage σ (-x) ≤ f.infAverage σ x := by + obtain ⟨s,hs⟩ := f.exists_average_eq σ x + rw [hs] + simpa using f.infAverage_le σ (-x) (-s) + exact le_antisymm (aux x) (by simpa using aux (-x)) + +omit [Fintype H] in +theorem average_add_le (f : PhaseCost G) (σ : H →+ (J → G)) (x y : G) (s t : H) : + f.average σ (x+y) (s+t) ≤ f.average σ x s + f.average σ y t := by + unfold average + rw [← add_div, ← Finset.sum_add_distrib] + apply div_le_div_of_nonneg_right _ (by positivity) + apply Finset.sum_le_sum + intro j _ + have he : x+y+σ (s+t) j = (x+σ s j)+(y+σ t j) := by + simp only [map_add, Pi.add_apply] + abel + rw [he] + exact f.add_le _ _ + +theorem infAverage_add_le (f : PhaseCost G) (σ : H →+ (J → G)) (x y : G) : + f.infAverage σ (x+y) ≤ f.infAverage σ x + f.infAverage σ y := by + obtain ⟨s,hs⟩ := f.exists_average_eq σ x + obtain ⟨t,ht⟩ := f.exists_average_eq σ y + rw [hs,ht] + exact (f.infAverage_le σ (x+y) (s+t)).trans (f.average_add_le σ x y s t) + +noncomputable def step (f : PhaseCost G) (σ : H →+ (J → G)) : PhaseCost G := + ⟨f.infAverage σ, f.infAverage_nonneg σ, f.infAverage_zero σ, + f.infAverage_neg σ, f.infAverage_add_le σ⟩ + +end PhaseCost + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Primes.lean b/lean/OAI/Combinatorics/FiniteCircle/Primes.lean new file mode 100644 index 0000000000000000000000000000000000000000..c35dc1c5b508d2016947edfe0be6774b9764b097 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Primes.lean @@ -0,0 +1,274 @@ +import OAI.Combinatorics.FiniteCircle.ExcludedDescent + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +def primeInterval (n : ℕ) : Finset ℕ := (Finset.Ioc n (2*n)).filter Nat.Prime + +theorem centralBinom_le_interval (n : ℕ) (hn : 2 < n) : + n.centralBinom ≤ (2*n)^Nat.sqrt (2*n) * 4^(2*n/3) * ∏ p ∈ primeInterval n, p := by + classical + let f : ℕ → ℕ := fun p => p^n.centralBinom.factorization p + have hsmall : (∏ p ∈ Finset.range (2*n/3+1), f p) ≤ (2*n)^Nat.sqrt (2*n)*4^(2*n/3) := by + let S := (Finset.range (2*n/3+1)).filter Nat.Prime + have he : (∏ p ∈ S, f p) = ∏ p ∈ Finset.range (2*n/3+1), f p := by + apply Finset.prod_filter_of_ne + intro p _ hp + contrapose hp + simp only [f, Nat.factorization_eq_zero_of_not_prime n.centralBinom hp, pow_zero] + rw [← he, ← Finset.prod_filter_mul_prod_filter_not S (fun p => p ≤ Nat.sqrt (2*n))] + apply Nat.mul_le_mul + · calc + _ ≤ ∏ _p ∈ S.filter (fun p => p ≤ Nat.sqrt (2*n)), 2*n := + Finset.prod_le_prod (fun p _ => Nat.pow_factorization_choose_le (by omega : 0<2*n)) + _ = (2*n)^(S.filter (fun p => p ≤ Nat.sqrt (2*n))).card := by simp + _ ≤ _ := by + apply Nat.pow_le_pow_right (by omega) + have hs : S.filter (fun p => p ≤ Nat.sqrt (2*n)) ⊆ Finset.Icc 1 (Nat.sqrt (2*n)) := by + intro p hp + obtain ⟨hp,hq⟩ := Finset.mem_filter.mp hp + exact Finset.mem_Icc.mpr ⟨(Finset.mem_filter.mp hp).2.one_lt.le,hq⟩ + have hh := Finset.card_le_card hs + simpa using hh + · calc + _ ≤ ∏ p ∈ S.filter (fun p => ¬p ≤ Nat.sqrt (2*n)), p := by + apply Finset.prod_le_prod + intro p hp + obtain ⟨hp,hq⟩ := Finset.mem_filter.mp hp + dsimp [f] + have hfac : n.centralBinom.factorization p ≤ 1 := + Nat.factorization_choose_le_one (Nat.sqrt_lt'.mp (lt_of_not_ge hq)) + exact (Nat.pow_le_pow_right (Finset.mem_filter.mp hp).2.one_lt.le hfac).trans_eq (pow_one p) + _ ≤ primorial (2*n/3) := by + apply Finset.prod_le_prod_of_subset_of_one_le (Finset.filter_subset _ _) + intro p hp _ + exact (Finset.mem_filter.mp hp).2.one_lt.le + _ ≤ _ := primorial_le_four_pow _ + have htail : (∏ p ∈ Finset.Ico (2*n/3+1) (2*n+1), f p) ≤ ∏ p ∈ primeInterval n, p := by + have hs : primeInterval n ⊆ Finset.Ico (2*n/3+1) (2*n+1) := by + intro p hp + have h := Finset.mem_Ioc.mp (Finset.mem_filter.mp hp).1 + have hdiv : 2*n/3 ≤ n := (Nat.div_le_iff_le_mul_add_pred (by decide : 0<3)).mpr (by omega) + exact Finset.mem_Ico.mpr ⟨by omega,by omega⟩ + have he : (∏ p ∈ primeInterval n, f p) = ∏ p ∈ Finset.Ico (2*n/3+1) (2*n+1), f p := by + apply Finset.prod_subset hs + intro p hp hnot + dsimp [f] + by_cases hprime : p.Prime + · have hp' := Finset.mem_Ico.mp hp + have hpn : p ≤ n := by + by_contra h + exact hnot (Finset.mem_filter.mpr ⟨Finset.mem_Ioc.mpr ⟨by omega,by omega⟩,hprime⟩) + rw [Nat.factorization_centralBinom_of_two_mul_self_lt_three_mul hn hpn (by omega), pow_zero] + · rw [Nat.factorization_eq_zero_of_not_prime _ hprime, pow_zero] + rw [← he] + apply Finset.prod_le_prod + intro p hp + obtain ⟨hpi,hp⟩ := Finset.mem_filter.mp hp + have hpn := (Finset.mem_Ioc.mp hpi).1 + have hfac : n.centralBinom.factorization p ≤ 1 := Nat.factorization_choose_le_one (by nlinarith) + exact (Nat.pow_le_pow_right hp.one_lt.le hfac).trans_eq (pow_one p) + calc + _ = (∏ p ∈ Finset.range (2*n/3+1), f p) * ∏ p ∈ Finset.Ico (2*n/3+1) (2*n+1), f p := by + rw [Finset.prod_range_mul_prod_Ico _ (by omega)] + exact (Nat.prod_pow_factorization_centralBinom n).symm + _ ≤ _ := Nat.mul_le_mul hsmall htail + + theorem centralBinom_le_interval_card (n : ℕ) (hn : 2 < n) : + n.centralBinom ≤ (2*n)^Nat.sqrt (2*n) * 4^(2*n/3) * (2*n)^(primeInterval n).card := by + refine (centralBinom_le_interval n hn).trans (Nat.mul_le_mul_left _ ?_) + calc + _ ≤ ∏ _p ∈ primeInterval n, 2*n := Finset.prod_le_prod (fun p hp => + (Finset.mem_Ioc.mp (Finset.mem_filter.mp hp).1).2) + _ = _ := by simp + +theorem log_le_linear_million {x : ℝ} (hx : 1000000 ≤ x) : + Real.log x ≤ x / 500 := by + have hp : 0 < x := by linarith + have hs : Real.sqrt x ≤ x/1000 := by + apply Real.sqrt_le_iff.mpr + constructor + · positivity + · have h := mul_nonneg (show 0 ≤ x-1000000 by linarith) hp.le + nlinarith + have hl := Real.log_le_sub_one_of_pos (Real.sqrt_pos.mpr hp) + rw [Real.log_sqrt hp.le] at hl + linarith + +theorem primeInterval_card_cubic (h : ℕ) (hh : 1000000 ≤ h) : + h^2 ≤ (primeInterval (h^3)).card := by + have htwo : 2 ≤ h := by omega + have hN : 4 ≤ h^3 := by nlinarith [Nat.pow_le_pow_left htwo 3] + have hH : (1000000:ℝ) ≤ h := by exact_mod_cast hh + have hp : (0:ℝ) < h := by positivity + have hhlog := log_le_linear_million hH + have hlog0 : 0 ≤ Real.log (h:ℝ) := Real.log_nonneg (by exact_mod_cast (show 1 ≤ h by omega)) + have hlog4 : (3:ℝ)/4 ≤ Real.log 4 := by + have hl := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<(4:ℝ)⁻¹) + rw [Real.log_inv] at hl + norm_num at hl ⊢ + linarith + have hsqrt : Nat.sqrt (2*h^3) ≤ 2*h^2 := by + have he : 2*h^3 ≤ (2*h^2)^2 := by nlinarith [sq_nonneg (h:ℤ), Nat.pow_le_pow_left htwo 2] + exact (Nat.sqrt_le_sqrt he).trans_eq (Nat.sqrt_eq' _) + by_contra hn + have hc : (primeInterval (h^3)).card ≤ h^2 := by omega + have hbin := centralBinom_le_interval_card (h^3) (by omega) + have hpow : 4^(h^3) < h^3 * ((2*h^3)^(3*h^2) * 4^(2*h^3/3)) := by + apply (Nat.four_pow_lt_mul_centralBinom (h^3) hN).trans_le + apply Nat.mul_le_mul_left + apply hbin.trans + calc + _ = (2*h^3)^(Nat.sqrt (2*h^3)+(primeInterval (h^3)).card)*4^(2*h^3/3) := by + rw [pow_add] + ring + _ ≤ _ := Nat.mul_le_mul_right _ (Nat.pow_le_pow_right (by omega) (by omega)) + have hpowR : (4:ℝ)^(h^3) < (h:ℝ)^3 *((2*(h:ℝ)^3)^(3*h^2)*4^(2*h^3/3)) := by + exact_mod_cast hpow + have hlog := (Real.log_lt_log (by positivity) hpowR) + rw [Real.log_mul (by positivity) (by positivity), Real.log_mul (by positivity) (by positivity)] at hlog + simp only [Real.log_pow] at hlog + have hlog2 : Real.log (2*(h:ℝ)^3) ≤ 4*Real.log (h:ℝ) := by + have ht : 2*(h:ℝ)^3 ≤ (h:ℝ)^4 := by + have hh2 : (2:ℝ) ≤ h := by exact_mod_cast htwo + nlinarith [mul_nonneg (show 0 ≤ (h:ℝ)-2 by linarith) (show 0 ≤ (h:ℝ)^3 by positivity)] + simpa only [Real.log_pow, Nat.cast_ofNat] using Real.log_le_log (by positivity) ht + have hdiv : ((2*h^3/3:ℕ):ℝ) ≤ 2*(h:ℝ)^3/3 := by + exact_mod_cast (Nat.cast_div_le (α := ℝ) (m := 2*h^3) (n := 3)) + have hmul := mul_le_mul_of_nonneg_right hdiv (show 0 ≤ Real.log 4 by linarith) + have hmul2 := mul_le_mul_of_nonneg_left hlog2 (show (0:ℝ) ≤ (3*h^2:ℕ) by positivity) + have hbound : (h:ℝ)^3*Real.log 4/3 < (3+12*(h:ℝ)^2)*Real.log h := by + push_cast at hlog hmul2 + nlinarith + have hlarge : (3+12*(h:ℝ)^2)*Real.log h ≤ 13*(h:ℝ)^2*((h:ℝ)/500) := by + have hh2 : (2:ℝ) ≤ h := by exact_mod_cast htwo + have ha : 3+12*(h:ℝ)^2 ≤ 13*(h:ℝ)^2 := by nlinarith + exact mul_le_mul ha hhlog hlog0 (by positivity) + have hlower := mul_le_mul_of_nonneg_left hlog4 (show 0 ≤ (h:ℝ)^3/3 by positivity) + have hcube : 0 < (h:ℝ)^3 := by positivity + nlinarith + +theorem prime_array (h : ℕ) (hh : 1000000 ≤ h) : + ∃ p : ℕ → ℕ → ℕ, + (∀ l k : Fin h, Nat.Prime (p (l.val+1) k) ∧ h^3 < p (l.val+1) k ∧ p (l.val+1) k ≤ 2*h^3) ∧ + Function.Injective (fun lk : Fin h × Fin h => p (lk.1.val+1) lk.2) ∧ + (∀ l k, ¬(1 ≤ l ∧ l ≤ h ∧ k < h) → p l k = 1) := by + classical + obtain ⟨s,hs,hcard⟩ := Finset.exists_subset_card_eq (primeInterval_card_cubic h hh) + let e : (Fin h × Fin h) ≃ s := Fintype.equivOfCardEq (by simp [hcard, pow_two]) + let p : ℕ → ℕ → ℕ := fun l k => if hl : 1 ≤ l ∧ l ≤ h then + if hk : k < h then (e (⟨l-1,by omega⟩,⟨k,hk⟩)).val else 1 else 1 + have hep (l k : Fin h) : p (l.val+1) k = (e (l,k)).val := by + simp only [p, show 1 ≤ l.val+1 ∧ l.val+1 ≤ h by omega, dite_true, k.isLt] + rfl + refine ⟨p, ?_, ?_, ?_⟩ + · intro l k + rw [hep] + have he := hs (e (l,k)).property + obtain ⟨he,hprime⟩ := Finset.mem_filter.mp he + have hv := Finset.mem_Ioc.mp he + exact ⟨hprime,hv.1,hv.2⟩ + · intro x y he + simp only [hep] at he + exact e.injective (Subtype.ext he) + · intro l k hn + dsimp [p] + split_ifs with hl hk + · exact False.elim (hn ⟨hl.1,hl.2,hk⟩) + · rfl + · rfl + +structure StandingPrimes (h : ℕ) (p : ℕ → ℕ → ℕ) : Prop where + inside : ∀ l k : Fin h, Nat.Prime (p (l.val+1) k) ∧ h^3 < p (l.val+1) k ∧ p (l.val+1) k ≤ 2*h^3 + inj : Function.Injective (fun lk : Fin h × Fin h => p (lk.1.val+1) lk.2) + outside : ∀ l k, ¬(1 ≤ l ∧ l ≤ h ∧ k < h) → p l k = 1 + + theorem standingPrimes_exists (h : ℕ) (hh : 1000000 ≤ h) : + ∃ p, StandingPrimes h p := by + obtain ⟨p,hp,hi,ho⟩ := prime_array h hh + exact ⟨p,⟨hp,hi,ho⟩⟩ + +namespace StandingPrimes +variable {h : ℕ} {p : ℕ → ℕ → ℕ} (hp : StandingPrimes h p) +include hp + + theorem atLevel (l : ℕ) (hl : 1 ≤ l) (hlh : l ≤ h) (k : Fin h) : + Nat.Prime (p l k) ∧ h^3 < p l k ∧ p l k ≤ 2*h^3 := by + have ht := hp.inside ⟨l-1,by omega⟩ k + simpa only [show l-1+1=l by omega] using ht + + theorem positive (l : ℕ) (k : Fin h) : 0 < p l k := by + by_cases hl : 1 ≤ l ∧ l ≤ h + · exact (hp.atLevel l hl.1 hl.2 k).1.pos + · rw [hp.outside l k (by omega)] + norm_num + + theorem level_injective (l : ℕ) (hl : 1 ≤ l) (hlh : l ≤ h) : + Function.Injective (fun k : Fin h => p l k) := by + intro i j he + have hi := hp.inj (a₁ := (⟨l-1,by omega⟩,i)) (a₂ := (⟨l-1,by omega⟩,j)) + (by simpa only [show l-1+1=l by omega] using he) + exact congrArg Prod.snd hi + + theorem level_distinct (l r : ℕ) (hl : 1 ≤ l) (hlh : l ≤ h) + (hr : 1 ≤ r) (hrh : r ≤ h) (hlr : l ≠ r) (i j : Fin h) : p l i ≠ p r j := by + intro he + have hi := hp.inj (a₁ := (⟨l-1,by omega⟩,i)) (a₂ := (⟨r-1,by omega⟩,j)) + (by simpa only [show l-1+1=l by omega, show r-1+1=r by omega] using he) + have hh := congrArg (fun z : Fin h × Fin h => z.1.val) hi + apply hlr + dsimp only at hh + omega + + theorem coprime (l : ℕ) : Pairwise (fun i j : Fin h => Nat.Coprime (p l i) (p l j)) := by + intro i j hij + by_cases hl : 1 ≤ l ∧ l ≤ h + · exact ((hp.atLevel l hl.1 hl.2 i).1.coprime_iff_not_dvd).mpr (by + intro hd + have he := ((hp.atLevel l hl.1 hl.2 j).1.dvd_iff_eq (hp.atLevel l hl.1 hl.2 i).1.ne_one).mp hd + exact hij (hp.level_injective l hl.1 hl.2 he.symm)) + · rw [hp.outside l i (by omega), hp.outside l j (by omega)] + exact Nat.coprime_one_left _ + + theorem period_pos (l : ℕ) : 0 < period h p l := + Finset.prod_pos (fun k _ => hp.positive l k) + + theorem circle_pos : 0 < circleSize h p := by + apply Nat.mul_pos (by norm_num) + exact Finset.prod_pos (fun l _ => hp.period_pos (l.val+1)) + + omit hp in + theorem circle_even : circleSize h p = 2*(circleSize h p/2) := by + unfold circleSize + omega + + theorem divides_circle (l : ℕ) (k : Fin h) : p l k ∣ circleSize h p := by + by_cases hl : 1 ≤ l ∧ l ≤ h + · have hk : p l k ∣ period h p l := Finset.dvd_prod_of_mem _ (Finset.mem_univ k) + have hd : period h p l ∣ ∏ r : Fin h, period h p (r.val+1) := by + have hh := Finset.dvd_prod_of_mem (fun r : Fin h => period h p (r.val+1)) + (Finset.mem_univ (⟨l-1,by omega⟩ : Fin h)) + simpa only [show l-1+1=l by omega] using hh + exact hk.trans (hd.trans (dvd_mul_left _ _)) + · rw [hp.outside l k (by omega)] + exact one_dvd _ + + theorem maskPrimes : MaskPrimes h p := by + exact ⟨fun l k => (hp.inside l k).1, hp.inj, fun l k => ⟨(hp.inside l k).2.1.le,(hp.inside l k).2.2⟩⟩ + + theorem excludedPrimes (hh : 2 ≤ h) : ExcludedPrimes h p := by + refine ⟨fun l k => (hp.inside l k).1, hp.inj, fun l k => ⟨(hp.inside l k).2.1, ?_⟩⟩ + apply (hp.inside l k).2.2.trans + have hh2 : 2 ≤ h^2 := by nlinarith + calc + 2*h^3 ≤ h^2*h^3 := Nat.mul_le_mul_right _ hh2 + _ = h^5 := by ring + +end StandingPrimes + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/RandomCodes.lean b/lean/OAI/Combinatorics/FiniteCircle/RandomCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..1996972e2ae740b51c1e1c24da221e7b949b8b79 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/RandomCodes.lean @@ -0,0 +1,245 @@ +import OAI.Combinatorics.FiniteCircle.BitCounting + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +open Classical + +abbrev SmallHoles (w : ℕ) := {S : Finset (Fin w) // (S.card : ℝ) ≤ (w : ℝ)/1048576} +abbrev DenseParameters (w : ℕ) := Fin w × Fin w × SmallHoles w + +noncomputable instance (w : ℕ) : Fintype (SmallHoles w) := Fintype.ofFinite _ + +def denseList {w : ℕ} (P : DenseParameters w) : List (Fin w) := + (Finset.Icc P.1 P.2.1 \ P.2.2.val).sort (· ≤ ·) + +theorem denseList_sorted {w : ℕ} (P : DenseParameters w) : + (denseList P).Pairwise (fun i j => i.val < j.val) := + (Finset.sortedLT_sort (Finset.Icc P.1 P.2.1 \ P.2.2.val)).pairwise + +theorem exists_denseParameters {w : ℕ} (is : List (Fin w)) + (hs : is.Pairwise (fun i j => i.val < j.val)) (hn : 0 < is.length) + (hloss : (indexSpan is - is.length : ℕ) ≤ (w : ℝ)/1048576) : + ∃ P : DenseParameters w, denseList P = is := by + classical + let lo := is.get ⟨0, hn⟩ + let hi := is.get ⟨is.length-1, by omega⟩ + let S := is.toFinset + have hm : StrictMono is.get := List.pairwise_iff_get.mp hs + have hsub : S ⊆ Finset.Icc lo hi := by + intro i hiS + obtain ⟨k, hk⟩ := List.mem_iff_get.mp (List.mem_toFinset.mp hiS) + subst i + exact Finset.mem_Icc.mpr ⟨hm.monotone (by exact Nat.zero_le _), hm.monotone (by + change k.val ≤ is.length-1; omega)⟩ + have hcard : S.card = is.length := List.toFinset_card_of_nodup hs.nodup + have hspan : (Finset.Icc lo hi).card = indexSpan is := by + rw [Fin.card_Icc] + have hh := indexSpan_ofFn is.get hn + simpa only [List.ofFn_get] using hh.symm + let H := Finset.Icc lo hi \ S + have hH : (H.card : ℝ) ≤ (w : ℝ)/1048576 := by + simpa only [H, Finset.card_sdiff_of_subset hsub, hcard, hspan] using hloss + refine ⟨(lo, hi, ⟨H, hH⟩), ?_⟩ + dsimp only [denseList] + rw [show Finset.Icc lo hi \ H = S from Finset.sdiff_sdiff_eq_self hsub] + exact (List.toFinset_sort (· ≤ ·) hs.nodup).mpr (hs.imp (fun h => h.le)) + +def StrongLocal {α : Type*} {w : ℕ} (c : α → Fin w → Bool) : Prop := + ∀ a b : α, ∀ is js : List (Fin w), + is.Pairwise (fun i j => i.val < j.val) → + js.Pairwise (fun i j => i.val < j.val) → + is.length = js.length → w ≤ 16*is.length → + (indexSpan is - is.length : ℕ) ≤ (w : ℝ)/1048576 → + (indexSpan js - js.length : ℕ) ≤ (w : ℝ)/1048576 → + (∀ ij ∈ is.zip js, c a ij.1 = c b ij.2) → + a = b ∧ ∃ i : Fin w, (i, i) ∈ is.zip js + +abbrev DenseWitness (α : Type*) (w : ℕ) := (α × DenseParameters w) × (α × DenseParameters w) + +def badDenseWitness {α : Type*} {w : ℕ} (W : DenseWitness α w) (ω : α × Fin w → Bool) : Prop := + let is := denseList W.1.2 + let js := denseList W.2.2 + is.length = js.length ∧ w ≤ 16*is.length ∧ + (W.1.1 ≠ W.2.1 ∨ ∀ i : Fin w, (i,i) ∉ is.zip js) ∧ + ∀ ij ∈ is.zip js, ω (W.1.1, ij.1) = ω (W.2.1, ij.2) + +theorem card_badDenseWitness_le {α : Type*} [Fintype α] {w : ℕ} + (W : DenseWitness α w) : + (Finset.univ.filter (badDenseWitness W)).card ≤ + 2^(Fintype.card α*w-w/64) := by + classical + let is := denseList W.1.2 + let js := denseList W.2.2 + by_cases hc : is.length = js.length ∧ w ≤ 16*is.length ∧ + (W.1.1 ≠ W.2.1 ∨ ∀ i : Fin w, (i,i) ∉ is.zip js) + · obtain ⟨hlen, hw, hne⟩ := hc + let f : Fin is.length → α × Fin w := fun k => (W.1.1, is.get k) + let g : Fin is.length → α × Fin w := fun k => (W.2.1, js.get (Fin.cast hlen k)) + have his : StrictMono is.get := List.pairwise_iff_get.mp (denseList_sorted _) + have hjs : StrictMono js.get := List.pairwise_iff_get.mp (denseList_sorted _) + have hf : Function.Injective f := fun i j h => his.injective (congrArg Prod.snd h) + have hg : Function.Injective g := by + intro i j h + have hh := hjs.injective (congrArg Prod.snd h) + exact Fin.ext (show i.val = j.val from congrArg (fun k : Fin js.length => k.val) hh) + have hpair (i : Fin is.length) : (is.get i, js.get (Fin.cast hlen i)) ∈ is.zip js := by + apply List.mem_iff_get.mpr + refine ⟨⟨i.val, by simp only [List.length_zip]; omega⟩, ?_⟩ + simp only [List.get_eq_getElem, List.getElem_zip, Fin.val_cast] + have hn : ∀ i ∈ (Finset.univ : Finset (Fin is.length)), f i ≠ g i := by + intro i _ he + rcases hne with hne | hne + · exact hne (show W.1.1 = W.2.1 from congrArg (fun x : α × Fin w => x.1) he) + · have hh : is.get i = js.get (Fin.cast hlen i) := congrArg (fun x : α × Fin w => x.2) he + exact hne (is.get i) (hh.symm ▸ hpair i) + have hsub : Finset.univ.filter (badDenseWitness W) ⊆ + Finset.univ.filter (fun ω : α × Fin w → Bool => ∀ i ∈ (Finset.univ : Finset (Fin is.length)), ω (f i) = ω (g i)) := by + intro ω hω + have hω := (Finset.mem_filter.mp hω).2 + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i _ => hω.2.2.2 _ (hpair i)⟩ + have hh := card_matching_equalities_le (Finset.univ : Finset (Fin is.length)) f g hf hg hn w (by simpa using hw) + exact (Finset.card_le_card hsub).trans (by simpa [Fintype.card_prod, Fintype.card_fin] using hh) + · have he : Finset.univ.filter (badDenseWitness W) = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro ω hω + have hω := (Finset.mem_filter.mp hω).2 + exact hc ⟨hω.1, hω.2.1, hω.2.2.1⟩ + rw [he, Finset.card_empty] + exact Nat.zero_le _ + +theorem card_denseWitness_le {α : Type*} [Fintype α] (w : ℕ) : + (Fintype.card (DenseWitness α w) : ℝ) ≤ + (Fintype.card α : ℝ)^2 * (w : ℝ)^4 * Real.exp ((w : ℝ)/256) := by + classical + have hk : (Fintype.card (SmallHoles w) : ℝ) ≤ Real.exp ((w : ℝ)/512) := by + simpa only [SmallHoles, Fintype.card_subtype] using card_small_subsets_le w + have he : Real.exp ((w : ℝ)/256) = Real.exp ((w : ℝ)/512)^2 := by + rw [← Real.exp_nat_mul] + congr 1 + ring + have hc : (Fintype.card (DenseWitness α w) : ℝ) = + (Fintype.card α : ℝ)^2 * (w : ℝ)^4 * (Fintype.card (SmallHoles w) : ℝ)^2 := by + simp only [DenseWitness, DenseParameters, Fintype.card_prod, Fintype.card_fin, Nat.cast_mul] + ring + rw [hc, he] + exact mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by positivity) hk 2) (by positivity) + +theorem dense_union_numerics {A w : ℕ} (hA : 2 ≤ A) (hw : 67108864 ≤ w) + (hlog : 2048*Real.log (A : ℝ) ≤ w) (hd : 64 ∣ w) : + (A : ℝ)^2 * (w : ℝ)^4 * Real.exp ((w : ℝ)/256) < (2 : ℝ)^(w/64) := by + have hAp : (0 : ℝ) < A := by positivity + have hwp : (0 : ℝ) < w := by exact_mod_cast (by omega : 0 < w) + have hsqrt : 8192 ≤ Real.sqrt (w : ℝ) := by + apply (Real.le_sqrt (by norm_num) (by positivity)).mpr + exact_mod_cast hw + have hlogw : Real.log (w : ℝ) ≤ 2*Real.sqrt (w : ℝ) := by + have hh := Real.log_le_sub_one_of_pos (Real.sqrt_pos.2 hwp) + rw [Real.log_sqrt hwp.le] at hh + linarith + have hsquare : (Real.sqrt (w : ℝ))^2 = w := Real.sq_sqrt hwp.le + have hlogw' : 4096 * Real.log (w : ℝ) ≤ w := by + nlinarith + have hdiv : ((w/64 : ℕ) : ℝ)*64 = w := by + exact_mod_cast Nat.div_mul_cancel hd + have hlog2 : (1 : ℝ)/2 < Real.log 2 := by linarith [Real.log_two_gt_d9] + have hexpl : (A : ℝ)^2 * (w : ℝ)^4 * Real.exp ((w : ℝ)/256) = + Real.exp (2*Real.log (A : ℝ) + 4*Real.log (w : ℝ) + (w : ℝ)/256) := by + rw [Real.exp_add, Real.exp_add] + have h2 := Real.exp_nat_mul (Real.log (A : ℝ)) 2 + have h4 := Real.exp_nat_mul (Real.log (w : ℝ)) 4 + norm_num only [Nat.cast_ofNat, Real.exp_log hAp, Real.exp_log hwp] at h2 h4 + rw [h2, h4] + have hexpr : (2 : ℝ)^(w/64) = Real.exp (((w/64 : ℕ) : ℝ)*Real.log 2) := by + rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + rw [hexpl, hexpr] + apply Real.exp_lt_exp.mpr + have hpos : (0 : ℝ) < (w/64 : ℕ) := by nlinarith + have hm := mul_lt_mul_of_pos_left hlog2 hpos + linarith + +theorem exists_coding_width (A : ℕ) (hA : 2 ≤ A) : + ∃ w : ℕ, 67108864 ≤ w ∧ 64 ∣ w ∧ + 2048*Real.log (A : ℝ) ≤ w ∧ + (w : ℝ) ≤ 67108928 * Real.log (2*A) := by + let t := Real.log (2*(A : ℝ)) + have hAp : (0 : ℝ) < A := by positivity + have ht : 1 ≤ t := by + have hh : (4 : ℝ) ≤ 2*A := by exact_mod_cast (by omega : 4 ≤ 2*A) + have hm := Real.log_le_log (by norm_num : (0 : ℝ) < 4) hh + have h4 : Real.log (4 : ℝ) = 2*Real.log 2 := by + rw [show (4 : ℝ) = 2^2 by norm_num, Real.log_pow]; norm_num + dsimp only [t] + linarith [Real.log_two_gt_d9] + have hAt : Real.log (A : ℝ) ≤ t := Real.log_le_log hAp (by nlinarith) + let n := ⌈1048576*t⌉₊ + have hn : 1048576*t ≤ (n : ℝ) := Nat.le_ceil _ + have hn' : (n : ℝ) < 1048576*t+1 := Nat.ceil_lt_add_one (by positivity) + refine ⟨64*n, ?_, dvd_mul_right _ _, ?_, ?_⟩ + · have hh : (67108864 : ℝ) ≤ 64*n := by nlinarith + exact_mod_cast hh + · push_cast + nlinarith + · push_cast + change 64*(n : ℝ) ≤ 67108928*t + nlinarith + +theorem exists_strongLocal (α : Type*) [Fintype α] (hA : 2 ≤ Fintype.card α) : + ∃ (w : ℕ) (c : α → Fin w → Bool), 67108864 ≤ w ∧ 64 ∣ w ∧ + (w : ℝ) ≤ 67108928 * Real.log (2*Fintype.card α) ∧ StrongLocal c := by + classical + obtain ⟨w, hw, hd, hlog, hwidth⟩ := exists_coding_width (Fintype.card α) hA + let Ω := α × Fin w → Bool + let B : Finset Ω := Finset.univ.biUnion (fun W : DenseWitness α w => + Finset.univ.filter (badDenseWitness W)) + have hcard : B.card ≤ Fintype.card (DenseWitness α w) * 2^(Fintype.card α*w-w/64) := by + apply Finset.card_biUnion_le.trans + calc + _ ≤ ∑ _W : DenseWitness α w, 2^(Fintype.card α*w-w/64) := + Finset.sum_le_sum (fun W _ => card_badDenseWitness_le W) + _ = _ := by simp + have hexp : (Fintype.card (DenseWitness α w) : ℝ) < (2 : ℝ)^(w/64) := + (card_denseWitness_le w).trans_lt (dense_union_numerics hA hw hlog hd) + have hkn : w/64 ≤ Fintype.card α*w := by + have hh : w ≤ Fintype.card α*w := by nlinarith + exact (Nat.div_le_self _ _).trans hh + have hstrict : (B.card : ℝ) < (2 : ℝ)^(Fintype.card α*w) := by + have hc : (B.card : ℝ) ≤ (Fintype.card (DenseWitness α w) : ℝ) * (2 : ℝ)^(Fintype.card α*w-w/64) := by + exact_mod_cast hcard + calc + _ ≤ _ := hc + _ < (2 : ℝ)^(w/64) * (2 : ℝ)^(Fintype.card α*w-w/64) := + mul_lt_mul_of_pos_right hexp (by positivity) + _ = _ := by rw [← pow_add, Nat.add_sub_of_le hkn] + have hB : B.card < (Finset.univ : Finset Ω).card := by + have he : (Finset.univ : Finset Ω).card = 2^(Fintype.card α*w) := by + simp [Ω, Fintype.card_prod] + rw [he] + exact_mod_cast hstrict + obtain ⟨ω, _, hω⟩ := Finset.exists_mem_notMem_of_card_lt_card hB + have hω' (W : DenseWitness α w) : ¬badDenseWitness W ω := by + intro hh + apply hω + exact Finset.mem_biUnion.mpr ⟨W, Finset.mem_univ _, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hh⟩⟩ + refine ⟨w, fun a i => ω (a,i), hw, hd, hwidth, ?_⟩ + intro a b is js his hjs hlen hsize hli hlj hbits + have hn : 0 < is.length := by omega + obtain ⟨P, hP⟩ := exists_denseParameters is his hn hli + obtain ⟨Q, hQ⟩ := exists_denseParameters js hjs (by omega) hlj + by_contra hh + apply hω' ((a,P),(b,Q)) + dsimp only [badDenseWitness] + rw [hP, hQ] + refine ⟨hlen, hsize, ?_, hbits⟩ + by_cases hab : a = b + · exact Or.inr (fun i hi => hh ⟨hab, i, hi⟩) + · exact Or.inl hab + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Separation.lean b/lean/OAI/Combinatorics/FiniteCircle/Separation.lean new file mode 100644 index 0000000000000000000000000000000000000000..df404b4c7ca4f592b7ff94c0f7490f7422f08079 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Separation.lean @@ -0,0 +1,284 @@ +import OAI.Combinatorics.FiniteCircle.Histograms + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +noncomputable def coordDist {X ι : Type*} [Fintype ι] (F : X → ι → ℝ) (x y : X) : ℝ := + ∑ i, |F x i - F y i| + +theorem coordDist_nonneg {X ι : Type*} [Fintype ι] (F : X → ι → ℝ) (x y : X) : + 0 ≤ coordDist F x y := Finset.sum_nonneg (fun _ _ => abs_nonneg _) + +theorem coordDist_symm {X ι : Type*} [Fintype ι] (F : X → ι → ℝ) (x y : X) : + coordDist F x y = coordDist F y x := by simp only [coordDist, abs_sub_comm] + +theorem coordDist_triangle {X ι : Type*} [Fintype ι] (F : X → ι → ℝ) (x y z : X) : + coordDist F x z ≤ coordDist F x y + coordDist F y z := by + unfold coordDist + rw [← Finset.sum_add_distrib] + exact Finset.sum_le_sum (fun _ _ => abs_sub_le _ _ _) + +def normalizeWord {α : Type*} (a : α) (m : ℕ) (x : List α) : List.Vector α m := + ⟨x.take m ++ List.replicate (m - x.length) a, by simp; omega⟩ + +theorem normalizeWord_val {α : Type*} (a : α) {m : ℕ} {x : List α} (h : x.length ≤ m) : + (normalizeWord a m x).val = x ++ List.replicate (m-x.length) a := by + simp only [normalizeWord, List.take_of_length_le h] + +theorem normalizeWord_deficit {α : Type*} (a : α) {m : ℕ} {x y : List α} + (hx : x.length ≤ m) (hy : x.length = y.length) : + deficit (normalizeWord a m x).val (normalizeWord a m y).val = deficit x y := by + rw [normalizeWord_val a hx, normalizeWord_val a (by omega), ← hy] + simp only [deficit, List.length_append, List.length_replicate, lcs_append_common_right] + omega + +def windowWords {α : Type*} (a : α) (x : List α) (start m s : ℕ) : List (List.Vector α m) := + (windows x start m s).map (normalizeWord a m) + +@[simp] theorem length_windowWords {α : Type*} (a : α) (x : List α) (start m s : ℕ) : + (windowWords a x start m s).length = s := by simp [windowWords] + +theorem windowWords_ofFn {α : Type*} (a : α) (x : List α) (start m s : ℕ) : + windowWords a x start m s = + List.ofFn (fun r : Fin s => normalizeWord a m (segment x (start+r) (m-s+1))) := by + simp [windowWords, windows, List.map_ofFn, Function.comp_def] + +theorem windows_segment {α : Type*} (x : List α) {start m s : ℕ} + (_hs : 1 ≤ s) (hsm : s ≤ m) : + windows (segment x start m) 0 m s = windows x start m s := by + unfold windows + congr 1 + funext r + simp only [Nat.zero_add] + exact segment_segment x start m r (m-s+1) (by have := r.isLt; omega) + +theorem windowWords_segment {α : Type*} (a : α) (x : List α) {start m s : ℕ} + (hs : 1 ≤ s) (hsm : s ≤ m) : + windowWords a (segment x start m) 0 m s = windowWords a x start m s := by + simp only [windowWords, windows_segment x hs hsm] + +theorem cross_window_deficit {α : Type*} (a : α) {x y : List α} {m s : ℕ} + (hx : x.length = m) (hy : y.length = m) (hs : 1 ≤ s) (hsm : s ≤ m) + (hq : 2*s ≤ deficit x y + 1) (i j : Fin s) : + s ≤ deficit (normalizeWord a m (segment x i (m-s+1))).val + (normalizeWord a m (segment y j (m-s+1))).val := by + have hxi : (segment x i (m-s+1)).length = m-s+1 := + length_segment (by have := i.isLt; omega) + have hyj : (segment y j (m-s+1)).length = m-s+1 := + length_segment (by have := j.isLt; omega) + rw [normalizeWord_deficit a (by omega) (by omega)] + have hmono := lcs_mono (segment_sublist x i (m-s+1)) (segment_sublist y j (m-s+1)) + have hb := lcs_le_length_left x y + simp only [deficit, hxi] at * + omega + +theorem exists_separating_scale {m q : ℕ} (hq : 0 < q) (hqm : q ≤ m) : + ∃ k : Fin (Nat.log 2 m + 1), 1 ≤ 2^k.val ∧ 2^k.val ≤ m ∧ + q ≤ 4 * 2^k.val ∧ 2 * 2^k.val ≤ q+1 := by + let n := (q+1)/2 + have hn : 0 < n := by dsimp [n]; omega + have hnm : n ≤ m := by dsimp [n]; omega + let k := Nat.log 2 n + have hk : k ≤ Nat.log 2 m := Nat.log_mono_right hnm + have hpow : 2^k ≤ n := Nat.pow_le_of_le_log hn.ne' le_rfl + have hlt : n < 2^(k+1) := Nat.lt_pow_succ_log_self (by norm_num) n + refine ⟨⟨k, by omega⟩, ?_, hpow.trans hnm, ?_, ?_⟩ + · change 1 ≤ 2^k + have hp : 0 < 2^k := pow_pos (by norm_num) _ + omega + · change q ≤ 4 * 2^k + simp only [pow_succ] at hlt + dsimp [n] at * + omega + · change 2 * 2^k ≤ q+1 + dsimp [n] at hpow + omega + +noncomputable def partitionRate (s : ℕ) : ℝ := 4 * Real.log (s+1) / s + +theorem partitionRate_nonneg (s : ℕ) : 0 ≤ partitionRate s := by + unfold partitionRate + exact div_nonneg (mul_nonneg (by norm_num) (Real.log_nonneg (by norm_num))) (Nat.cast_nonneg _) + +theorem partition_collision_bound {s : ℕ} (hs : 1 ≤ s) {ρ : ℝ} (hρ : s ≤ ρ) : + Real.exp (-partitionRate s * ρ) ≤ ((s : ℝ)+1)⁻¹ ^ 4 := by + have hspos : (0 : ℝ) < s := by exact_mod_cast hs + calc + _ ≤ Real.exp (-partitionRate s * s) := Real.exp_le_exp.mpr + (mul_le_mul_of_nonpos_left hρ (neg_nonpos.mpr (partitionRate_nonneg s))) + _ = _ := by + rw [show -partitionRate s * s = -(4 * Real.log ((s:ℝ)+1)) by + unfold partitionRate; field_simp] + rw [Real.exp_neg, show 4 * Real.log ((s:ℝ)+1) = (4:ℕ) * Real.log ((s:ℝ)+1) by norm_num, + Real.exp_nat_mul, Real.exp_log (by positivity), inv_pow] + +theorem scale_collision_union {s : ℕ} : (s : ℝ)^2 * (((s:ℝ)+1)⁻¹ ^ 4) ≤ 1/2 := by + have hs : (0 : ℝ) ≤ s := Nat.cast_nonneg s + rw [inv_pow, mul_inv_le_iff₀ (by positivity)] + nlinarith [sq_nonneg ((s:ℝ)^2), sq_nonneg ((s:ℝ)-1)] + +theorem block_histogram_lower {α Ω Y ι : Type*} [Fintype Ω] [Fintype Y] [Fintype ι] + (a : α) {m s : ℕ} (F : List.Vector α m → ι → ℝ) + (hF : ∀ u v, (deficit u.val v.val : ℝ) ≤ coordDist F u v) + (μ : FiniteLaw Ω) (label : Ω → List.Vector α m → Y) + (he : ∀ u v, μ.event (fun ω => label ω u = label ω v) = + Real.exp (-partitionRate s * coordDist F u v)) + {x y : List α} (hx : x.length = m) (hy : y.length = m) + (hs : 1 ≤ s) (hsm : s ≤ m) (hq : 2*s ≤ deficit x y + 1) : + (s:ℝ) ≤ μ.expect (fun ω => histDist (label ω) (windowWords a x 0 m s) (windowWords a y 0 m s)) := by + rw [windowWords_ofFn, windowWords_ofFn] + simp only [Nat.zero_add] + apply expect_histDist_ofFn_ge μ label _ _ (((s:ℝ)+1)⁻¹^4) _ scale_collision_union + intro i j + rw [he] + apply partition_collision_bound hs + exact (Nat.cast_le.mpr (cross_window_deficit a hx hy hs hsm hq i j)).trans (hF _ _) + +theorem normalized_slide_segment {α : Type*} (a : α) {x y : List α} (h : Slide x y) + {m len start : ℕ} (hlen : len ≤ m) : + deficit (normalizeWord a m (segment x start len)).val + (normalizeWord a m (segment y start len)).val ≤ 2 := by + have hx : (segment x start len).length ≤ m := by + simp only [segment, List.length_take, List.length_drop] + exact (min_le_left _ _).trans hlen + have hy : (segment x start len).length = (segment y start len).length := by + simp only [segment, List.length_take, List.length_drop, h.length_eq] + rw [normalizeWord_deficit a hx hy, deficit_eq_unequalDeficit hy] + exact h.segment_deficit_le_two _ _ + +theorem block_histogram_pairing {α Ω Y ι : Type*} [Fintype Ω] [Fintype Y] [Fintype ι] + (a : α) {m s : ℕ} (F : List.Vector α m → ι → ℝ) (Λ : ℝ) (hΛ : 0 ≤ Λ) + (hF : ∀ u v, coordDist F u v ≤ Λ * deficit u.val v.val) + (μ : FiniteLaw Ω) (label : Ω → List.Vector α m → Y) + (he : ∀ u v, μ.event (fun ω => label ω u = label ω v) = + Real.exp (-partitionRate s * coordDist F u v)) + {x y : List α} (hxy : Slide x y) (start : ℕ) (hs : 1 ≤ s) (hsm : s ≤ m) : + μ.expect (fun ω => histDist (label ω) (windowWords a x start m s) (windowWords a y start m s)) ≤ + 16 * Real.log ((s:ℝ)+1) * Λ := by + rw [windowWords_ofFn, windowWords_ofFn] + calc + _ ≤ 2 * s * (2 * partitionRate s * Λ) := by + apply expect_histDist_ofFn_le + intro i + have hr := partition_separation_le μ label (coordDist F) (partitionRate s) he + (normalizeWord a m (segment x (start+i) (m-s+1))) + (normalizeWord a m (segment y (start+i) (m-s+1))) + refine hr.trans ?_ + calc + _ ≤ partitionRate s * (Λ * 2) := by + apply mul_le_mul_of_nonneg_left _ (partitionRate_nonneg s) + refine (hF _ _).trans ?_ + apply mul_le_mul_of_nonneg_left _ hΛ + exact_mod_cast normalized_slide_segment a hxy (by omega : m-s+1 ≤ m) + _ = _ := by ring + _ = _ := by + have hs0 : (s:ℝ) ≠ 0 := by exact_mod_cast (by omega : s ≠ 0) + unfold partitionRate + field_simp + ring + +theorem fin_index_indicator_sum (b p : ℕ) : + (∑ j : Fin b, if j.val = p then (1:ℝ) else 0) ≤ 1 := by + classical + by_cases hp : p < b + · have he (j : Fin b) : j.val = p ↔ j = ⟨p,hp⟩ := by simp only [Fin.ext_iff] + simp only [he] + simp + · have hn (j : Fin b) : j.val ≠ p := by have := j.isLt; omega + simp [hn] + +theorem histogram_forward_bound {α Ω Y ι : Type*} [Fintype Ω] [Fintype Y] [Fintype ι] + (a : α) {m s : ℕ} (F : List.Vector α m → ι → ℝ) (Λ : ℝ) (hΛ : 0 ≤ Λ) + (hF : ∀ u v, coordDist F u v ≤ Λ * deficit u.val v.val) + (μ : FiniteLaw Ω) (label : Ω → List.Vector α m → Y) + (he : ∀ u v, μ.event (fun ω => label ω u = label ω v) = + Real.exp (-partitionRate s * coordDist F u v)) + (u v t : List α) (c d : α) (b : ℕ) (hs : 1 ≤ s) (hsm : s ≤ m) : + (∑ j : Fin b, μ.expect (fun ω => histDist (label ω) + (windowWords a (u ++ c :: (v ++ t)) (j*m) m s) + (windowWords a (u ++ v ++ d :: t) (j*m) m s))) ≤ + 2*b + 32 * Real.log ((s:ℝ)+1) * Λ := by + classical + let B := 16 * Real.log ((s:ℝ)+1) * Λ + have hB : 0 ≤ B := mul_nonneg (mul_nonneg (by norm_num) (Real.log_nonneg (by have := Nat.cast_nonneg (α := ℝ) s; linarith))) hΛ + let p := u.length / m + let q := (u.length + v.length) / m + have hb (j : Fin b) : μ.expect (fun ω => histDist (label ω) + (windowWords a (u ++ c :: (v ++ t)) (j*m) m s) + (windowWords a (u ++ v ++ d :: t) (j*m) m s)) ≤ + 2 + B * ((if j.val = p then 1 else 0) + (if j.val = q then 1 else 0)) := by + have hexc : μ.expect (fun ω => histDist (label ω) + (windowWords a (u ++ c :: (v ++ t)) (j*m) m s) + (windowWords a (u ++ v ++ d :: t) (j*m) m s)) ≤ B := + block_histogram_pairing a F Λ hΛ hF μ label he (.forward u v t c d) (j*m) hs hsm + by_cases hp : j.val = p + · refine hexc.trans ?_ + rw [ite_eq_left hp] + split_ifs <;> linarith + · by_cases hq : j.val = q + · refine hexc.trans ?_ + rw [ite_eq_right hp, ite_eq_left hq] + linarith + · rw [ite_eq_right hp, ite_eq_right hq] + simp only [add_zero, mul_zero] + obtain ⟨zs, hz, hx, hy⟩ := windows_nonexceptional u v t c d hs hsm hp hq + have hbω (ω : Ω) : histDist (label ω) + (windowWords a (u ++ c :: (v ++ t)) (j*m) m s) + (windowWords a (u ++ v ++ d :: t) (j*m) m s) ≤ 2 := by + have h := histDist_common_sublist_le (label ω) (hx.map (normalizeWord a m)) + (hy.map (normalizeWord a m)) + simp only [List.length_map, length_windows] at h + have hr : (2:ℝ) * s ≤ 2 * zs.length + 2 := by + exact_mod_cast (by omega : 2*s ≤ 2*zs.length+2) + exact h.trans (by linarith) + simpa using μ.expect_mono hbω + calc + _ ≤ ∑ j : Fin b, (2 + B * ((if j.val = p then 1 else 0) + (if j.val = q then 1 else 0))) := + Finset.sum_le_sum (fun j _ => hb j) + _ = 2*b + B * ((∑ j : Fin b, if j.val=p then (1:ℝ) else 0) + + (∑ j : Fin b, if j.val=q then (1:ℝ) else 0)) := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_add_distrib] + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + ring + _ ≤ 2*b + B * (1+1) := by + exact add_le_add le_rfl (mul_le_mul_of_nonneg_left + (add_le_add (fin_index_indicator_sum b p) (fin_index_indicator_sum b q)) hB) + _ = _ := by dsimp [B]; ring + +theorem histogram_slide_bound {α Ω Y ι : Type*} [Fintype Ω] [Fintype Y] [Fintype ι] + (a : α) {m s : ℕ} (F : List.Vector α m → ι → ℝ) (Λ : ℝ) (hΛ : 0 ≤ Λ) + (hF : ∀ u v, coordDist F u v ≤ Λ * deficit u.val v.val) + (μ : FiniteLaw Ω) (label : Ω → List.Vector α m → Y) + (he : ∀ u v, μ.event (fun ω => label ω u = label ω v) = + Real.exp (-partitionRate s * coordDist F u v)) + {x y : List α} (hxy : Slide x y) (b : ℕ) (hs : 1 ≤ s) (hsm : s ≤ m) : + (∑ j : Fin b, μ.expect (fun ω => histDist (label ω) + (windowWords a x (j*m) m s) (windowWords a y (j*m) m s))) ≤ + 2*b + 32 * Real.log ((s:ℝ)+1) * Λ := by + cases hxy with + | forward u v t c d => exact histogram_forward_bound a F Λ hΛ hF μ label he u v t c d b hs hsm + | backward u v t c d => + simp only [histDist_symm (label _) + (windowWords a (u ++ v ++ d :: t) _ _ _)] + exact histogram_forward_bound a F Λ hΛ hF μ label he u v t c d b hs hsm + +theorem SlidePath.coordDist_le {α ι : Type*} [Fintype ι] {x y : List α} {n : ℕ} + (h : SlidePath n x y) (F : List α → ι → ℝ) (K : ℝ) + (hF : ∀ u v, Slide u v → coordDist F u v ≤ K) : coordDist F x y ≤ n*K := by + induction h with + | nil => simp [coordDist] + | @cons n x y z h hs ih => + calc + _ ≤ coordDist F x y + coordDist F y z := coordDist_triangle F x y z + _ ≤ K + n*K := add_le_add (hF x y h) ih + _ = _ := by push_cast; ring + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/TaggedRows.lean b/lean/OAI/Combinatorics/FiniteCircle/TaggedRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..0de2cebff33cc37d38f8bfb8beec5420999fcf46 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/TaggedRows.lean @@ -0,0 +1,380 @@ +import OAI.Combinatorics.FiniteCircle.Matching + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List + +def taggedRow {J β : Type*} (js : List J) (W : J → List β) : List (J × β) := + js.flatMap (fun j => (W j).map (fun b => (j,b))) + +@[simp] theorem taggedRow_nil {J β : Type*} (W : J → List β) : taggedRow [] W = [] := rfl +@[simp] theorem taggedRow_cons {J β : Type*} (j : J) (js : List J) (W : J → List β) : + taggedRow (j::js) W = (W j).map (fun b => (j,b)) ++ taggedRow js W := rfl + +theorem filter_map_tag {J β : Type*} [DecidableEq J] (j k : J) (x : List β) : + ((x.map (fun b => (k,b))).filter (fun z => decide (z.1 = j))) = + if k = j then x.map (fun b => (j,b)) else [] := by + by_cases h : k = j + · subst k + simp [List.filter_map, Function.comp_def] + · simp [List.filter_map, Function.comp_def, h] + +theorem filter_taggedRow {J β : Type*} [DecidableEq J] (js : List J) + (hn : js.Nodup) (W : J → List β) (j : J) : + ((taggedRow js W).filter (fun z => decide (z.1 = j))) = + if j ∈ js then (W j).map (fun b => (j,b)) else [] := by + induction js with + | nil => simp + | cons k js ih => + have hn' := List.nodup_cons.mp hn + rw [taggedRow_cons, List.filter_append, filter_map_tag, ih hn'.2] + by_cases h : k = j + · subst k + simp [hn'.1] + · by_cases hj : j ∈ js <;> simp [h, hj, Ne.symm h] + +theorem sum_filter_tag_length {J β : Type*} [Fintype J] [DecidableEq J] + (x : List (J × β)) : + ∑ j : J, (x.filter (fun z => decide (z.1 = j))).length = x.length := by + induction x with + | nil => simp + | cons a x ih => + have he (j : J) : ((a::x).filter (fun z => decide (z.1 = j))).length = + (if a.1 = j then 1 else 0) + (x.filter (fun z => decide (z.1 = j))).length := by + by_cases h : a.1 = j <;> simp [h, Nat.add_comm] + simp_rw [he] + rw [Finset.sum_add_distrib, ih] + simp [Nat.add_comm] + +theorem length_taggedRow {J β : Type*} [Fintype J] [DecidableEq J] + (js : List J) (hn : js.Nodup) (hall : ∀ j, j ∈ js) (W : J → List β) : + (taggedRow js W).length = ∑ j : J, (W j).length := by + rw [← sum_filter_tag_length (taggedRow js W)] + congr 1 + funext j + rw [filter_taggedRow js hn W j, ite_eq_left (hall j), List.length_map] + +theorem lcs_taggedRow_le {J β : Type*} [Fintype J] [DecidableEq J] + (js : List J) (hn : js.Nodup) (hall : ∀ j, j ∈ js) (W U : J → List β) : + lcs (taggedRow js W) (taggedRow js U) ≤ ∑ j : J, lcs (W j) (U j) := by + obtain ⟨z, hx, hy, hz⟩ := lcs_exists (taggedRow js W) (taggedRow js U) + rw [← hz, ← sum_filter_tag_length z] + apply Finset.sum_le_sum + intro j _ + have hx' := hx.filter (fun z => decide (z.1 = j)) + have hy' := hy.filter (fun z => decide (z.1 = j)) + rw [filter_taggedRow js hn W j, ite_eq_left (hall j)] at hx' + rw [filter_taggedRow js hn U j, ite_eq_left (hall j)] at hy' + have hh := le_lcs hx' hy' + rw [lcs_map_eq (fun b : β => (j,b)) (fun _ _ h => congrArg Prod.snd h)] at hh + exact hh + +theorem get_segment {β : Type*} (x : List β) {s n : ℕ} (hs : s+n ≤ x.length) + (i : Fin (segment x s n).length) : + (segment x s n).get i = x.get ⟨s+i.val, by + have hi := i.isLt + simp only [length_segment hs] at hi + omega⟩ := by + change ((x.drop s).take n)[i.val] = _ + simp only [List.getElem_take, List.getElem_drop, List.get_eq_getElem] + +namespace WordMatching +variable {β : Type*} {x y : List β} {q : ℕ} + +def onSegments (A : WordMatching x y q) (S : Finset (Fin q)) + {s n t m : ℕ} (hs : s+n ≤ x.length) (ht : t+m ≤ y.length) + (hleft : ∀ i ∈ S, s ≤ (A.left i).val ∧ (A.left i).val < s+n) + (hright : ∀ i ∈ S, t ≤ (A.right i).val ∧ (A.right i).val < t+m) : + WordMatching (segment x s n) (segment y t m) S.card := by + let f : Fin S.card → Fin (segment x s n).length := fun i => + ⟨(A.left (S.orderEmbOfFin rfl i)).val-s, by + rw [length_segment hs] + have hh := hleft _ (S.orderEmbOfFin_mem rfl i) + omega⟩ + let g : Fin S.card → Fin (segment y t m).length := fun i => + ⟨(A.right (S.orderEmbOfFin rfl i)).val-t, by + rw [length_segment ht] + have hh := hright _ (S.orderEmbOfFin_mem rfl i) + omega⟩ + have hf : StrictMono f := by + intro i j hij + have hh : (A.left (S.orderEmbOfFin rfl i)).val < (A.left (S.orderEmbOfFin rfl j)).val := + A.left.strictMono ((S.orderEmbOfFin rfl).strictMono hij) + have hi := hleft _ (S.orderEmbOfFin_mem rfl i) + change (A.left (S.orderEmbOfFin rfl i)).val-s < (A.left (S.orderEmbOfFin rfl j)).val-s + omega + have hg : StrictMono g := by + intro i j hij + have hh : (A.right (S.orderEmbOfFin rfl i)).val < (A.right (S.orderEmbOfFin rfl j)).val := + A.right.strictMono ((S.orderEmbOfFin rfl).strictMono hij) + have hi := hright _ (S.orderEmbOfFin_mem rfl i) + change (A.right (S.orderEmbOfFin rfl i)).val-t < (A.right (S.orderEmbOfFin rfl j)).val-t + omega + refine ⟨OrderEmbedding.ofStrictMono f hf, OrderEmbedding.ofStrictMono g hg, ?_⟩ + intro i + change (segment x s n).get (f i) = (segment y t m).get (g i) + rw [get_segment x hs, get_segment y ht] + have hi := hleft _ (S.orderEmbOfFin_mem rfl i) + have hj := hright _ (S.orderEmbOfFin_mem rfl i) + convert A.letters (S.orderEmbOfFin rfl i) using 1 + · congr 1 + apply Fin.ext + change s+((A.left (S.orderEmbOfFin rfl i)).val-s) = _ + omega + · congr 1 + apply Fin.ext + change t+((A.right (S.orderEmbOfFin rfl i)).val-t) = _ + omega + +theorem card_onSegments_le (A : WordMatching x y q) (S : Finset (Fin q)) + {s n t m : ℕ} (hs : s+n ≤ x.length) (ht : t+m ≤ y.length) + (hleft : ∀ i ∈ S, s ≤ (A.left i).val ∧ (A.left i).val < s+n) + (hright : ∀ i ∈ S, t ≤ (A.right i).val ∧ (A.right i).val < t+m) : + S.card ≤ lcs (segment x s n) (segment y t m) := + (A.onSegments S hs ht hleft hright).le_lcs + +end WordMatching + +theorem position_decomposition (x t L : ℕ) : + x = (x/(t*L))*(t*L) + ((x/L)%t)*L + x%L := by + have h1 := Nat.mod_add_div (x/L) t + have h2 := Nat.mod_add_div x L + rw [Nat.div_div_eq_div_mul, Nat.mul_comm L t] at h1 + nlinarith + +theorem split_positions_gap {t L i x₁ x₂ y₁ y₂ : ℕ} (ht : 2 ≤ t) (hL : 0 < L) + (hx₁ : x₁/(t*L) = i) (hx₂ : x₂/(t*L) = i) + (hy : y₁/(t*L) < y₂/(t*L)) (hx : x₁ ≤ x₂) + (hxy : y₁ ≤ y₂) + (htag₁ : (x₁/L)%t = (y₁/L)%t) (htag₂ : (x₂/L)%t = (y₂/L)%t) : + (t-2)*L + (x₂+1-x₁) ≤ y₂+1-y₁ := by + have ex₁ := position_decomposition x₁ t L + have ex₂ := position_decomposition x₂ t L + have ey₁ := position_decomposition y₁ t L + have ey₂ := position_decomposition y₂ t L + rw [hx₁, htag₁] at ex₁ + rw [hx₂, htag₂] at ex₂ + have hb := Nat.mul_le_mul_right (t*L) (show y₁/(t*L)+1 ≤ y₂/(t*L) by omega) + have hrx₂ := Nat.mod_lt x₂ hL + have hry₁ := Nat.mod_lt y₁ hL + have hT : (t-2)*L+2*L = t*L := by + rw [← Nat.add_mul] + congr 1 + omega + have hgap : (t-2)*L+x₂+y₁ ≤ y₂+x₁ := by nlinarith [Nat.zero_le (x₁%L), Nat.zero_le (y₂%L)] + omega + +namespace WordMatching +variable {β : Type*} {x y : List β} {q : ℕ} + +def singleTargetRow (A : WordMatching x y q) (W i : ℕ) : Prop := + ∃ j : ℕ, ∀ k ∈ A.sourceBlock W i, (A.right k).val/W = j + +theorem spanLoss_of_split (A : WordMatching x y q) {t L i : ℕ} + (ht : 2 ≤ t) (hL : 0 < L) (tag : β → ℕ) + (hx : ∀ k : Fin x.length, tag (x.get k) = (k.val/L)%t) + (hy : ∀ k : Fin y.length, tag (y.get k) = (k.val/L)%t) + (hsplit : ¬A.singleTargetRow (t*L) i) : + (t-2)*L ≤ A.spanLoss (t*L) i := by + classical + let S := A.sourceBlock (t*L) i + have hS : S.Nonempty := by + by_contra he + have he : S = ∅ := Finset.not_nonempty_iff_eq_empty.mp he + apply hsplit + exact ⟨0, fun k hk => False.elim (by change k ∈ S at hk; simp [he] at hk)⟩ + let a := S.min' hS + let b := S.max' hS + have ha : a ∈ S := S.min'_mem hS + have hb : b ∈ S := S.max'_mem hS + have hab : a ≤ b := S.min'_le b hb + have hleft : (A.left a).val ≤ (A.left b).val := A.left.monotone hab + have hright : (A.right a).val ≤ (A.right b).val := A.right.monotone hab + have hrow : (A.right a).val/(t*L) < (A.right b).val/(t*L) := by + by_contra hn + have he : (A.right a).val/(t*L) = (A.right b).val/(t*L) := by + have hh := Nat.div_le_div_right (c := t*L) hright + omega + apply hsplit + refine ⟨(A.right a).val/(t*L), fun k hk => ?_⟩ + have hlo := Nat.div_le_div_right (c := t*L) (show (A.right a).val ≤ (A.right k).val from + A.right.monotone (S.min'_le k hk)) + have hhi := Nat.div_le_div_right (c := t*L) (show (A.right k).val ≤ (A.right b).val from + A.right.monotone (S.le_max' k hk)) + omega + have htag (k : Fin q) : ((A.left k).val/L)%t = ((A.right k).val/L)%t := by + rw [← hx, ← hy, A.letters] + have hgap := split_positions_gap ht hL ((A.mem_sourceBlock (t*L) i a).mp ha) + ((A.mem_sourceBlock (t*L) i b).mp hb) hrow hleft hright (htag a) (htag b) + have hcard := A.symm.card_le_rightSpan S + have hsx := A.symm.rightSpan_eq_Icc hS + have hsy := A.rightSpan_eq_Icc hS + rw [hsx, Fin.card_Icc] at hcard + change (t-2)*L ≤ (A.rightSpan S).card - S.card + rw [hsy, Fin.card_Icc] + change S.card ≤ (A.left b).val+1-(A.left a).val at hcard + change (t-2)*L ≤ (A.right b).val+1-(A.right a).val-S.card + omega + +theorem sourceLoss_of_single (A : WordMatching x y q) {W N i : ℕ} + (hW : 0 < W) (hx : x.length = W*N) (hy : y.length = W*N) (hi : i < N) + (hS : (A.sourceBlock W i).Nonempty) (hsingle : A.singleTargetRow W i) : + ∃ j : Fin N, deficit (segment x (i*W) W) (segment y (j.val*W) W) ≤ A.sourceLoss W i := by + obtain ⟨j, hj⟩ := hsingle + obtain ⟨k, hk⟩ := hS + have hjN : j < N := by + have hkj := hj k hk + have hkp := (A.right k).isLt + simp only [hy] at hkp + rw [← hkj] + exact (Nat.div_lt_iff_lt_mul hW).mpr (by nlinarith) + have hxi : i*W+W ≤ x.length := by rw [hx]; nlinarith + have hyj : j*W+W ≤ y.length := by rw [hy]; nlinarith + have hc := A.card_onSegments_le (A.sourceBlock W i) hxi hyj + (fun k hk => by + have hh := (A.mem_sourceBlock W i k).mp hk + have h1 := Nat.mod_add_div (A.left k).val W + have h2 := Nat.mod_lt (A.left k).val hW + rw [hh] at h1 + constructor <;> nlinarith [Nat.zero_le ((A.left k).val%W)]) + (fun k hk => by + have hh := hj k hk + have h1 := Nat.mod_add_div (A.right k).val W + have h2 := Nat.mod_lt (A.right k).val hW + rw [hh] at h1 + constructor <;> nlinarith [Nat.zero_le ((A.right k).val%W)]) + refine ⟨⟨j, hjN⟩, ?_⟩ + simpa only [deficit, length_segment hxi, sourceLoss] using Nat.sub_le_sub_left hc W + +end WordMatching + +theorem row_separation {β : Type*} {x y : List β} {N t L : ℕ} (hL : 0 < L) (ht : 4 ≤ t) + (hx : x.length = (t*L)*N) (hy : y.length = (t*L)*N) + (tag : β → ℕ) + (htagx : ∀ k : Fin x.length, tag (x.get k) = (k.val/L)%t) + (htagy : ∀ k : Fin y.length, tag (y.get k) = (k.val/L)%t) + (ρ : ℝ) (hρ : ρ ≤ 1/2) + (hrows : ∀ i j : Fin N, ρ*(t*L) ≤ + (deficit (segment x (i.val*(t*L)) (t*L)) (segment y (j.val*(t*L)) (t*L)) : ℝ)) : + ρ/2 * x.length ≤ (deficit x y : ℝ) := by + classical + have hW : 0 < t*L := by positivity + obtain ⟨A⟩ := exists_lcs_matching x y + have hper (i : Fin N) : ρ*(t*L) ≤ (A.sourceLoss (t*L) i : ℝ)+(A.spanLoss (t*L) i : ℝ) := by + by_cases hS : (A.sourceBlock (t*L) i).Nonempty + · by_cases hsingle : A.singleTargetRow (t*L) i + · obtain ⟨j, hj⟩ := A.sourceLoss_of_single hW hx hy i.isLt hS hsingle + have hh : (deficit (segment x (i.val*(t*L)) (t*L)) (segment y (j.val*(t*L)) (t*L)) : ℝ) ≤ A.sourceLoss (t*L) i := by exact_mod_cast hj + exact (hrows i j).trans (hh.trans (le_add_of_nonneg_right (by positivity))) + · have hh := A.spanLoss_of_split (by omega) hL tag htagx htagy hsingle + have hh' : ((t-2 : ℕ) : ℝ)*L ≤ A.spanLoss (t*L) i := by exact_mod_cast hh + have ht' : (4 : ℝ) ≤ t := by exact_mod_cast ht + rw [Nat.cast_sub (by omega : 2 ≤ t), Nat.cast_ofNat] at hh' + have hlt : (0 : ℝ) ≤ t*L := by positivity + have hρ' := mul_le_mul_of_nonneg_right hρ hlt + nlinarith [Nat.cast_nonneg (α := ℝ) (A.sourceLoss (t*L) i)] + · have he : A.sourceBlock (t*L) i = ∅ := Finset.not_nonempty_iff_eq_empty.mp hS + have hu : A.sourceLoss (t*L) i = t*L := by simp [WordMatching.sourceLoss, he] + rw [hu, Nat.cast_mul] + have hh := mul_le_mul_of_nonneg_right hρ (show (0 : ℝ) ≤ t*L by positivity) + nlinarith [Nat.cast_nonneg (α := ℝ) (A.spanLoss (t*L) i)] + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hper i) + rw [Finset.sum_add_distrib] at hsum + have hU := A.sum_sourceLoss hW hx + have hV := A.sum_spanLoss_le hW hx hy + have hUr : (∑ i : Fin N, (A.sourceLoss (t*L) i : ℝ)) = deficit x y := by + exact_mod_cast (show (∑ i : Fin N, A.sourceLoss (t*L) i) = deficit x y by simpa only [deficit, hx] using hU) + have hVr : (∑ i : Fin N, (A.spanLoss (t*L) i : ℝ)) ≤ deficit x y := by + exact_mod_cast (show (∑ i : Fin N, A.spanLoss (t*L) i) ≤ deficit x y by simpa only [deficit, hx] using hV) + rw [hUr] at hsum + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at hsum + rw [hx, Nat.cast_mul, Nat.cast_mul] + nlinarith + +theorem length_flatMap_uniform {α β : Type*} (xs : List α) (f : α → List β) (L : ℕ) + (hl : ∀ a ∈ xs, (f a).length = L) : (xs.flatMap f).length = xs.length*L := by + induction xs with + | nil => simp + | cons a xs ih => + simp only [List.flatMap_cons, List.length_append, List.length_cons] + rw [hl a (by simp), ih (fun a ha => hl a (by simp [ha]))] + nlinarith + +theorem segment_flatMap_uniform {α β : Type*} (xs : List α) (f : α → List β) (L : ℕ) + (hl : ∀ a ∈ xs, (f a).length = L) (i : Fin xs.length) : + segment (xs.flatMap f) (i.val*L) L = f (xs.get i) := by + have he : xs = xs.take i.val ++ xs[i.val] :: xs.drop (i.val+1) := by + conv_lhs => rw [← List.take_append_drop i.val xs, List.drop_eq_getElem_cons i.isLt] + have hp : ((xs.take i.val).flatMap f).length = i.val*L := by + rw [length_flatMap_uniform _ f L (fun a ha => hl a (List.mem_of_mem_take ha)), + List.length_take_of_le i.isLt.le] + have hi := hl (xs.get i) (xs.get_mem i) + have hf := congrArg (fun ys => ys.flatMap f) he + rw [List.flatMap_append, List.flatMap_cons] at hf + rw [hf] + unfold segment + rw [← hp, List.drop_left, List.take_append_of_le_length (by simpa only [List.get_eq_getElem] using hi.ge)] + simpa only [List.get_eq_getElem] using List.take_of_length_le (by simpa only [List.get_eq_getElem] using hi.le) + +theorem get_flatMap_uniform {α β : Type*} (xs : List α) (f : α → List β) {L : ℕ} + (hL : 0 < L) (hl : ∀ a ∈ xs, (f a).length = L) + (k : Fin (xs.flatMap f).length) : + ∃ (i : Fin xs.length) (b : Fin (f (xs.get i)).length), + i.val = k.val/L ∧ b.val = k.val%L ∧ (xs.flatMap f).get k = (f (xs.get i)).get b := by + have hk : k.val < xs.length*L := by simpa only [length_flatMap_uniform xs f L hl] using k.isLt + let i : Fin xs.length := ⟨k.val/L, (Nat.div_lt_iff_lt_mul hL).mpr hk⟩ + have hi := hl (xs.get i) (xs.get_mem i) + let b : Fin (f (xs.get i)).length := ⟨k.val%L, by rw [hi]; exact Nat.mod_lt _ hL⟩ + refine ⟨i, b, rfl, rfl, ?_⟩ + have hs : i.val*L+L ≤ (xs.flatMap f).length := by + rw [length_flatMap_uniform xs f L hl] + have h := Nat.mul_le_mul_right L i.isLt + nlinarith + have he := segment_flatMap_uniform xs f L hl i + let b' : Fin (segment (xs.flatMap f) (i.val*L) L).length := + ⟨b.val, by rw [he]; exact b.isLt⟩ + have hg := get_segment (xs.flatMap f) hs b' + have hpos : i.val*L+b'.val = k.val := by + change k.val/L*L+k.val%L = k.val + simpa only [Nat.mul_comm] using Nat.div_add_mod k.val L + have hg' : (segment (xs.flatMap f) (i.val*L) L).get b' = (xs.flatMap f).get k := by + convert hg using 1 + congr 1 + exact Fin.ext hpos.symm + rw [← hg'] + simp only [List.get_eq_getElem] + simp only [he] + rfl + +theorem tag_get_taggedRow {J β : Type*} [DecidableEq J] (js : List J) (hn : js.Nodup) + (W : J → List β) {L : ℕ} (hL : 0 < L) (hl : ∀ j ∈ js, (W j).length = L) + (k : Fin (taggedRow js W).length) : + js.idxOf ((taggedRow js W).get k).1 = k.val/L := by + obtain ⟨i,b,hi,_,he⟩ := get_flatMap_uniform js (fun j => (W j).map (fun z => (j,z))) hL + (fun j hj => by simp [hl j hj]) k + change (taggedRow js W).get k = _ at he + rw [he] + simp only [List.get_eq_getElem, List.getElem_map] + rw [hn.idxOf_getElem] + exact hi + +theorem tag_get_rows {J β : Type*} [DecidableEq J] (js : List J) (hn : js.Nodup) + (W : ℕ → J → List β) {L N : ℕ} (hL : 0 < L) (ht : 0 < js.length) + (hl : ∀ a < N, ∀ j ∈ js, (W a j).length = L) + (k : Fin ((List.range N).flatMap (fun a => taggedRow js (W a))).length) : + js.idxOf (((List.range N).flatMap (fun a => taggedRow js (W a))).get k).1 = + (k.val/L)%js.length := by + have hr (a : ℕ) (ha : a ∈ List.range N) : (taggedRow js (W a)).length = js.length*L := by + apply length_flatMap_uniform + intro j hj + simp [hl a (List.mem_range.mp ha) j hj] + obtain ⟨i,b,_,hb,he⟩ := get_flatMap_uniform (List.range N) (fun a => taggedRow js (W a)) + (Nat.mul_pos ht hL) hr k + rw [he, tag_get_taggedRow js hn _ hL (hl _ (by simpa using i.isLt)), hb] + rw [Nat.mul_comm js.length L, Nat.mod_mul_right_div_self] + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Translations.lean b/lean/OAI/Combinatorics/FiniteCircle/Translations.lean new file mode 100644 index 0000000000000000000000000000000000000000..b768996d5cf1d8ebad75d1035379b99d46083a8b --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Translations.lean @@ -0,0 +1,421 @@ +import OAI.Combinatorics.FiniteCircle.TreeBranching + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem editDistance_append_le {α : Type*} (x y x' y' : List α) : + editDistance (x++y) (x'++y') ≤ editDistance x x' + editDistance y y' := by + apply editDistance_le_of_script + exact ((editDistance_spec x x').append_right y).trans ((editDistance_spec y y').append_left x') + + theorem editDistance_flatMap_le {α β : Type*} (xs : List α) (f g : α → List β) : + editDistance (xs.flatMap f) (xs.flatMap g) ≤ (xs.map (fun a => editDistance (f a) (g a))).sum := by + induction xs with + | nil => simp + | cons a xs ih => + simpa only [List.flatMap_cons, List.map_cons, List.sum_cons] using + (editDistance_append_le (f a) (xs.flatMap f) (g a) (xs.flatMap g)).trans (Nat.add_le_add_left ih _) + + theorem editDistance_flatMap_uniform {α β : Type*} (xs : List α) (f g : α → List β) + (k : ℕ) (hk : ∀ a ∈ xs, editDistance (f a) (g a) ≤ k) : + editDistance (xs.flatMap f) (xs.flatMap g) ≤ xs.length*k := by + apply (editDistance_flatMap_le xs f g).trans + induction xs with + | nil => simp + | cons a xs ih => + simp only [List.map_cons, List.sum_cons, List.length_cons] + have ha := hk a (by simp) + have hs := ih (fun a ha => hk a (by simp [ha])) + nlinarith + + theorem editDistance_ofFn_le_hamming {α : Type*} [DecidableEq α] {N : ℕ} (f g : Fin N → α) : + editDistance (List.ofFn f) (List.ofFn g) ≤ + (Finset.univ.filter fun i => f i ≠ g i).card := by + classical + induction N with + | zero => simp + | succ N ih => + have he : ∀ a b : α, editDistance [a] [b] ≤ if a=b then 0 else 1 := by + intro a b + split_ifs with h + · subst b + simp + · apply editDistance_le_of_script + exact EditScript.one (.substitute [] [] a b) + rw [List.ofFn_succ, List.ofFn_succ] + have ht := editDistance_append_le [f 0] (List.ofFn (fun i => f i.succ)) + [g 0] (List.ofFn (fun i => g i.succ)) + have hi := ih (fun i => f i.succ) (fun i => g i.succ) + have hcard : (Finset.univ.filter fun i : Fin (N+1) => f i ≠ g i).card = + (if f 0 = g 0 then 0 else 1) + + (Finset.univ.filter fun i : Fin N => f i.succ ≠ g i.succ).card := by + simp only [Finset.card_filter, Fin.sum_univ_succ] + split_ifs <;> simp_all + rw [hcard] + exact ht.trans (Nat.add_le_add (he _ _) hi) + + theorem ed_halfBit_le {M : ℕ} [NeZero M] (he : M = 2*(M/2)) (v w : ZMod M) : + editDistance (List.ofFn (fun b : Fin M => halfBit v b.val)) + (List.ofFn (fun b : Fin M => halfBit w b.val)) ≤ 2*(w-v).valMinAbs.natAbs := by + exact (editDistance_ofFn_le_hamming _ _).trans_eq ((halfHamming_fin v w).trans (halfHamming_eq he v w)) + + theorem ed_tagged_halfBit_le {M : ℕ} [NeZero M] (he : M = 2*(M/2)) (v w : ZMod M) : + editDistance (List.ofFn (fun b : Fin M => (b,halfBit v b.val))) + (List.ofFn (fun b : Fin M => (b,halfBit w b.val))) ≤ 2*(w-v).valMinAbs.natAbs := by + apply (editDistance_ofFn_le_hamming _ _).trans + have heq : (Finset.univ.filter fun i : Fin M => (i,halfBit v i.val) ≠ (i,halfBit w i.val)) = + (Finset.univ.filter fun i : Fin M => halfBit v i.val ≠ halfBit w i.val) := by + ext i + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + apply not_congr + constructor + · exact congrArg Prod.snd + · intro hh + rw [hh] + rw [heq] + exact le_of_eq ((halfHamming_fin v w).trans (halfHamming_eq he v w)) + +theorem editDistance_shifted_rows {α : Type*} (f : ℕ → List α) (N q b : ℕ) + (hq : q ≤ N) (hf : ∀ a, (f a).length = b) : + editDistance ((List.range N).flatMap f) + ((List.range N).flatMap (fun a => f (q+a))) ≤ 2*q*b := by + let z := (List.range (N-q)).flatMap (fun a => f (q+a)) + have hx : z <+ (List.range N).flatMap f := by + have he : N = q+(N-q) := by omega + conv_rhs => rw [he, List.range_add, List.flatMap_append, List.flatMap_map] + exact List.sublist_append_right _ _ + have hy : z <+ (List.range N).flatMap (fun a => f (q+a)) := by + have he : N = (N-q)+q := by omega + conv_rhs => rw [he, List.range_add, List.flatMap_append] + exact List.sublist_append_left _ _ + have hlen : ∀ a, ((List.range N).flatMap (fun i => f (a+i))).length = N*b := by + intro a + simpa only [List.length_range] using length_flatMap_uniform (List.range N) (fun i => f (a+i)) b (fun i _ => hf _) + have hlx : ((List.range N).flatMap f).length = N*b := by simpa using hlen 0 + have hlz : z.length = (N-q)*b := by + simpa only [List.length_range] using length_flatMap_uniform (List.range (N-q)) (fun i => f (q+i)) b (fun i _ => hf _) + have hd := editDistance_le_of_script ((EditScript.of_sublist hx).trans (EditScript.of_sublist hy).symm) + rw [hlx, hlen, hlz] at hd + have hab : (N-q)*b+q*b = N*b := by rw [← Nat.add_mul]; congr; omega + have hh : N*b-(N-q)*b = q*b := by omega + rw [hh] at hd + simpa only [two_mul, add_mul] using hd + + theorem editDistance_flatMap_scaled {α β : Type*} (xs : List α) (f g : α → List β) + (R k : ℕ) (hk : ∀ a ∈ xs, R*editDistance (f a) (g a) ≤ k) : + R*editDistance (xs.flatMap f) (xs.flatMap g) ≤ xs.length*k := by + induction xs with + | nil => simp + | cons a xs ih => + have ht := Nat.mul_le_mul_left R (editDistance_append_le (f a) (xs.flatMap f) (g a) (xs.flatMap g)) + have ha := hk a (by simp) + have hs := ih (fun a ha => hk a (by simp [ha])) + simp only [List.flatMap_cons, List.length_cons] + rw [Nat.mul_add] at ht + nlinarith + +theorem tree_cheap_ed (J Z A : ℕ → Type) [∀ l, AddCommGroup (Z l)] + {M R : ℕ} (hR : 0 < R) (P L : ℕ → ℕ) + (tags : ∀ l, List (J (l+1))) + (tag : ∀ l, J (l+1) → A l → A (l+1)) + (σ : ∀ l, Z l →+ (J l → ZMod M)) + (γ : ∀ l, ℕ → J (l+1) → ZMod M) + (W : ∀ l, (TreeLeaf J l → ZMod M) → List (A l)) + (hlen : ∀ l v, (W l v).length = L l) + (hL : ∀ l, L (l+1) = (R*P (l+1))*((tags l).length*L l)) + (hrec : ∀ l v, W (l+1) v = (List.range (R*P (l+1))).flatMap + (fun a => (tags l).flatMap (fun j => (W l (fun i => v (j,i)+γ l a j)).map (tag l j)))) + (hCRT : ∀ l z, ∃ q : ℕ, q < P (l+1) ∧ ∀ a j, γ l (q+a) j = σ (l+1) z j+γ l a j) + (l : ℕ) (v c : TreeLeaf J l → ZMod M) (hc : c ∈ treeCheap J Z σ l) : + R*editDistance (W l v) (W l (v+c)) ≤ 2*l*L l := by + classical + induction l with + | zero => + have hz : c=0 := hc + simp [hz] + | succ l ih => + obtain ⟨cc,hcc,z,hz⟩ := hc + let u : TreeLeaf J (l+1) → ZMod M := fun i => v i+cc i.1 i.2 + have hu : R*editDistance (W (l+1) v) (W (l+1) u) ≤ 2*l*L (l+1) := by + rw [hrec, hrec] + have hh := editDistance_flatMap_scaled (List.range (R*P (l+1))) + (fun a => (tags l).flatMap (fun j => (W l (fun i => v (j,i)+γ l a j)).map (tag l j))) + (fun a => (tags l).flatMap (fun j => (W l (fun i => u (j,i)+γ l a j)).map (tag l j))) + R ((tags l).length*(2*l*L l)) (by + intro a _ + apply editDistance_flatMap_scaled + intro j _ + have he : (fun i => u (j,i)+γ l a j) = (fun i => v (j,i)+γ l a j)+cc j := by + funext i + dsimp [u] + abel + rw [he] + exact (Nat.mul_le_mul_left R (editDistance_map_le _ _ _)).trans + (ih (fun i => v (j,i)+γ l a j) (cc j) (hcc j))) + simpa only [List.length_range, hL, Nat.mul_assoc, Nat.mul_left_comm, Nat.mul_comm] using hh + obtain ⟨q,hq,hqγ⟩ := hCRT l z + let row (a : ℕ) := (tags l).flatMap (fun j => (W l (fun i => u (j,i)+γ l a j)).map (tag l j)) + have hrow : ∀ a, (row a).length = (tags l).length*L l := by + intro a + apply length_flatMap_uniform + intro j _ + simp only [List.length_map, hlen] + have hshift : W (l+1) (v+c) = (List.range (R*P (l+1))).flatMap (fun a => row (q+a)) := by + rw [hrec] + apply List.flatMap_congr + intro a _ + apply List.flatMap_congr + intro j _ + congr 2 + funext i + change v (j,i)+c (j,i)+γ l a j = u (j,i)+γ l (q+a) j + rw [hz, hqγ] + dsimp [u] + abel + have hqN : q ≤ R*P (l+1) := by + exact hq.le.trans (Nat.le_mul_of_pos_left _ hR) + have hs := editDistance_shifted_rows row (R*P (l+1)) q ((tags l).length*L l) hqN hrow + change editDistance ((List.range (R*P (l+1))).flatMap row) _ ≤ _ at hs + have hurow : W (l+1) u = (List.range (R*P (l+1))).flatMap row := hrec l u + rw [← hurow, ← hshift] at hs + have hs' : R*editDistance (W (l+1) u) (W (l+1) (v+c)) ≤ 2*L (l+1) := by + apply (Nat.mul_le_mul_left R hs).trans + rw [hL] + have hqp := Nat.mul_le_mul_right (R*((tags l).length*L l)) hq.le + nlinarith + have ht := Nat.mul_le_mul_left R (editDistance_triangle (W (l+1) v) (W (l+1) u) (W (l+1) (v+c))) + rw [Nat.mul_add] at ht + nlinarith + +noncomputable def treeCopies (R : ℕ) (P : ℕ → ℕ) : ℕ → ℕ + | 0 => 1 + | l+1 => (R*P (l+1))*treeCopies R P l + + theorem tree_coordinate_ed (J A : ℕ → Type) [∀ l, Fintype (J l)] + {M R : ℕ} (P : ℕ → ℕ) (tags : ∀ l, List (J (l+1))) + (hsum : ∀ l (f : J (l+1) → ℕ), ((tags l).map f).sum = ∑ j, f j) + (tag : ∀ l, J (l+1) → A l → A (l+1)) + (γ : ∀ l, ℕ → J (l+1) → ZMod M) + (W : ∀ l, (TreeLeaf J l → ZMod M) → List (A l)) + (hbase : ∀ v w, editDistance (W 0 v) (W 0 w) ≤ 2*(w PUnit.unit-v PUnit.unit).valMinAbs.natAbs) + (hrec : ∀ l v, W (l+1) v = (List.range (R*P (l+1))).flatMap + (fun a => (tags l).flatMap (fun j => (W l (fun i => v (j,i)+γ l a j)).map (tag l j)))) + (l : ℕ) (v w : TreeLeaf J l → ZMod M) : + editDistance (W l v) (W l w) ≤ 2*treeCopies R P l * ∑ i, (w i-v i).valMinAbs.natAbs := by + classical + induction l with + | zero => simpa only [treeCopies, mul_one, Fintype.sum_unique] using hbase v w + | succ l ih => + rw [hrec, hrec] + have hr : ∀ a, editDistance + ((tags l).flatMap (fun j => (W l (fun i => v (j,i)+γ l a j)).map (tag l j))) + ((tags l).flatMap (fun j => (W l (fun i => w (j,i)+γ l a j)).map (tag l j))) ≤ + 2*treeCopies R P l * ∑ i, (w i-v i).valMinAbs.natAbs := by + intro a + apply (editDistance_flatMap_le _ _ _).trans + rw [hsum] + change (∑ j, editDistance _ _) ≤ 2*treeCopies R P l * + ∑ i : J (l+1) × TreeLeaf J l, (w i-v i).valMinAbs.natAbs + rw [Fintype.sum_prod_type, Finset.mul_sum] + apply Finset.sum_le_sum + intro j _ + apply (editDistance_map_le _ _ _).trans + have hh := ih (fun i => v (j,i)+γ l a j) (fun i => w (j,i)+γ l a j) + simpa only [add_sub_add_right_eq_sub] using hh + have hh := editDistance_flatMap_uniform (List.range (R*P (l+1))) _ _ + (2*treeCopies R P l * ∑ i, (w i-v i).valMinAbs.natAbs) (fun a _ => hr a) + simpa only [List.length_range, treeCopies, Nat.mul_assoc, Nat.mul_left_comm, Nat.mul_comm] using hh + + theorem tree_single_ed (J A : ℕ → Type) [∀ l, Fintype (J l)] + {M R : ℕ} [NeZero M] (P : ℕ → ℕ) (tags : ∀ l, List (J (l+1))) + (hsum : ∀ l (f : J (l+1) → ℕ), ((tags l).map f).sum = ∑ j, f j) + (tag : ∀ l, J (l+1) → A l → A (l+1)) + (γ : ∀ l, ℕ → J (l+1) → ZMod M) + (W : ∀ l, (TreeLeaf J l → ZMod M) → List (A l)) + (hbase : ∀ v w, editDistance (W 0 v) (W 0 w) ≤ 2*(w PUnit.unit-v PUnit.unit).valMinAbs.natAbs) + (hrec : ∀ l v, W (l+1) v = (List.range (R*P (l+1))).flatMap + (fun a => (tags l).flatMap (fun j => (W l (fun i => v (j,i)+γ l a j)).map (tag l j)))) + (l : ℕ) (v : TreeLeaf J l → ZMod M) (i : TreeLeaf J l) (q : ℕ) : + editDistance (W l v) (W l (v+Pi.single i (q : ZMod M))) ≤ 2*treeCopies R P l*q := by + classical + have hh := tree_coordinate_ed J A P tags hsum tag γ W hbase hrec l v (v+Pi.single i (q : ZMod M)) + have hs : (∑ k, ((v+Pi.single i (q : ZMod M) : TreeLeaf J l → ZMod M) k-v k).valMinAbs.natAbs) = (q : ZMod M).valMinAbs.natAbs := by + simp only [Pi.add_apply, add_sub_cancel_left, Pi.single_apply] + simp only [apply_ite, ZMod.valMinAbs_zero, Int.natAbs_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + rw [hs] at hh + apply hh.trans + apply Nat.mul_le_mul_left + rw [ZMod.valMinAbs_natAbs_eq_min] + exact (min_le_left _ _).trans ((ZMod.val_natCast M q).trans_le (Nat.mod_le _ _)) + + theorem tree_length_eq (J : ℕ → Type) [∀ l, Fintype (J l)] (M R : ℕ) (P L : ℕ → ℕ) + (h0 : L 0=M) (hL : ∀ l, L (l+1)=(R*P (l+1))*(Fintype.card (J (l+1))*L l)) (l : ℕ) : + L l = M*Fintype.card (TreeLeaf J l)*treeCopies R P l := by + induction l with + | zero => simp only [TreeLeaf, Fintype.card_punit, treeCopies, mul_one, h0] + | succ l ih => + change L (l+1) = M*Fintype.card (J (l+1) × TreeLeaf J l)*treeCopies R P (l+1) + rw [hL, ih, Fintype.card_prod, treeCopies] + ring + + theorem residue_representative {h : ℕ} (p : Fin h → ℕ) + (hn : ∀ k, 0 < p k) (hp : Pairwise (fun i j => Nat.Coprime (p i) (p j))) + (z : ∀ k, ZMod (p k)) : ∃ q : ℕ, q < ∏ k, p k ∧ ∀ k, (q : ZMod (p k)) = z k := by + classical + let a := fun k => (z k).val + have hs : ∀ k ∈ (Finset.univ : Finset (Fin h)), p k ≠ 0 := fun k _ => (hn k).ne' + have hpp : Set.Pairwise (Finset.univ : Finset (Fin h)) (fun i j => Nat.Coprime (p i) (p j)) := + fun i _ j _ hij => hp hij + let q := Nat.chineseRemainderOfFinset a p Finset.univ hs hpp + refine ⟨q.val, Nat.chineseRemainderOfFinset_lt_prod a p hs hpp, ?_⟩ + intro k + let : NeZero (p k) := ⟨(hn k).ne'⟩ + have ht := q.property k (Finset.mem_univ k) + have he := (ZMod.natCast_eq_natCast_iff q.val (a k) (p k)).mpr ht + exact he.trans (ZMod.natCast_zmod_val (z k)) + + theorem mask_CRT_shift {h M : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (hp : ∀ l, Pairwise (fun i j : Fin h => Nat.Coprime (p l i) (p l j))) + (l : ℕ) (z : MaskResidues h p (l+1)) : + ∃ q, q < period h p (l+1) ∧ ∀ a j, + maskGamma h p M (l+1) (q+a) j = + maskPhaseHom h p M (l+1) (hd (l+1)) z j + maskGamma h p M (l+1) a j := by + obtain ⟨q,hq,hz⟩ := residue_representative (fun k : Fin h => p (l+1) k) (hn _) (hp _) z + refine ⟨q,hq,?_⟩ + intro a j + rw [← maskPhaseHom_natCast h p M (l+1) (q+a) (hd _) (hn _), + ← maskPhaseHom_natCast h p M (l+1) a (hd _) (hn _)] + have he : (fun k : Fin h => ((q+a : ℕ) : ZMod (p (l+1) k))) = z+(fun k : Fin h => (a : ZMod (p (l+1) k))) := by + funext k + simp only [Nat.cast_add, hz, Pi.add_apply] + rw [he, map_add, Pi.add_apply] + + theorem excluded_CRT_shift {h M : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (hp : ∀ l, Pairwise (fun i j : Fin h => Nat.Coprime (p l i) (p l j))) + (l : ℕ) (z : MaskResidues h p (l+1)) : + ∃ q, q < period h p (l+1) ∧ ∀ a j, + excludedTranslation h p M (l+1) (q+a) j = + excludedPhaseHom h p M (l+1) (hd (l+1)) z j + excludedTranslation h p M (l+1) a j := by + obtain ⟨q,hq,hz⟩ := residue_representative (fun k : Fin h => p (l+1) k) (hn _) (hp _) z + refine ⟨q,hq,?_⟩ + intro a j + rw [← excludedPhaseHom_natCast h p M (l+1) (q+a) (hd _) (hn _), + ← excludedPhaseHom_natCast h p M (l+1) a (hd _) (hn _)] + have he : (fun k : Fin h => ((q+a : ℕ) : ZMod (p (l+1) k))) = z+(fun k : Fin h => (a : ZMod (p (l+1) k))) := by + funext k + simp only [Nat.cast_add, hz, Pi.add_apply] + rw [he, map_add, Pi.add_apply] + +noncomputable def flatMaskWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : TreeLeaf (MaskChildren h p) l → ZMod M) : List (MaskAlphabet h p l) := + maskWord h p R M l (flatMaskState h p M l v) + +noncomputable def flatExcludedWord (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : TreeLeaf (fun _ => Fin h) l → ZMod M) : List (ExcludedAlphabet h M l) := + excludedWord h p R M l (flatExcludedState h M l v) + + theorem flatMaskWord_succ (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : TreeLeaf (MaskChildren h p) (l+1) → ZMod M) : + flatMaskWord h p R M (l+1) v = (List.range (R*period h p (l+1))).flatMap + (fun a => (maskTags h p (l+1)).flatMap (fun j => + (flatMaskWord h p R M l (fun i => v (j,i)+maskGamma h p M (l+1) a j)).map (Prod.mk j))) := by + change (List.range _).flatMap _ = _ + apply List.flatMap_congr + intro a _ + apply List.flatMap_congr + intro j _ + congr 2 + exact (flatMaskState_shift h p M l (fun i => v (j,i)) _).symm + + theorem flatExcludedWord_succ (h : ℕ) (p : ℕ → ℕ → ℕ) (R M l : ℕ) + (v : TreeLeaf (fun _ => Fin h) (l+1) → ZMod M) : + flatExcludedWord h p R M (l+1) v = (List.range (R*period h p (l+1))).flatMap + (fun a => (excludedTags h (l+1)).flatMap (fun j => + (flatExcludedWord h p R M l (fun i => v (j,i)+excludedTranslation h p M (l+1) a j)).map (Prod.mk j))) := by + unfold flatExcludedWord + rw [excludedWord_succ] + apply List.flatMap_congr + intro a _ + unfold taggedRow + apply List.flatMap_congr + intro j _ + congr 2 + change excludedWord h p R M l (shiftExcludedState h M l (flatExcludedState h M l (fun i => v (j,i))) _) = _ + rw [flatExcludedState_shift] + + theorem mask_cheap_ed {h M R : ℕ} {p : ℕ → ℕ → ℕ} (hR : 0 < R) + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (hp : ∀ l, Pairwise (fun i j : Fin h => Nat.Coprime (p l i) (p l j))) + (l : ℕ) (v c : TreeLeaf (MaskChildren h p) l → ZMod M) + (hc : c ∈ treeCheap (MaskChildren h p) (MaskResidues h p) (fun l => maskPhaseHom h p M l (hd l)) l) : + R*editDistance (flatMaskWord h p R M l v) (flatMaskWord h p R M l (v+c)) ≤ 2*l*maskLength h p R M l := by + apply tree_cheap_ed (MaskChildren h p) (MaskResidues h p) (MaskAlphabet h p) hR + (period h p) (maskLength h p R M) (fun l => maskTags h p (l+1)) (fun _ => Prod.mk) + (fun l => maskPhaseHom h p M l (hd l)) (fun l => maskGamma h p M (l+1)) + (flatMaskWord h p R M) (fun l v => length_maskWord h p R M l (flatMaskState h p M l v)) + (fun _ => rfl) (flatMaskWord_succ h p R M) (mask_CRT_shift hd hn hp) l v c hc + + theorem excluded_cheap_ed {h M R : ℕ} {p : ℕ → ℕ → ℕ} (hR : 0 < R) + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (hp : ∀ l, Pairwise (fun i j : Fin h => Nat.Coprime (p l i) (p l j))) + (l : ℕ) (v c : TreeLeaf (fun _ => Fin h) l → ZMod M) + (hc : c ∈ treeCheap (fun _ => Fin h) (MaskResidues h p) (fun l => excludedPhaseHom h p M l (hd l)) l) : + R*editDistance (flatExcludedWord h p R M l v) (flatExcludedWord h p R M l (v+c)) ≤ 2*l*excludedLength h p R M l := by + apply tree_cheap_ed (fun _ => Fin h) (MaskResidues h p) (ExcludedAlphabet h M) hR + (period h p) (excludedLength h p R M) (fun l => excludedTags h (l+1)) (fun _ => Prod.mk) + (fun l => excludedPhaseHom h p M l (hd l)) (fun l => excludedTranslation h p M (l+1)) + (flatExcludedWord h p R M) (fun l v => length_excludedWord h p R M l (flatExcludedState h M l v)) + (fun _ => rfl) (flatExcludedWord_succ h p R M) (excluded_CRT_shift hd hn hp) l v c hc + + theorem sum_map_maskTags (h : ℕ) (p : ℕ → ℕ → ℕ) (l : ℕ) (f : MaskTag h p l → ℕ) : + ((maskTags h p l).map f).sum = ∑ j, f j := by + simp only [maskTags, List.map_flatten, List.map_ofFn, List.sum_flatten, List.sum_ofFn, + Fintype.sum_sigma] + simp only [Function.comp_def, List.map_ofFn, List.sum_ofFn] + + theorem sum_map_excludedTags (h l : ℕ) (f : Fin h → ℕ) : + ((excludedTags h l).map f).sum = ∑ j, f j := by + simp only [excludedTags, List.map_ofFn, Function.comp_id, List.sum_ofFn] + + theorem flatMaskWord_base (h : ℕ) (p : ℕ → ℕ → ℕ) (R M : ℕ) + (v : TreeLeaf (MaskChildren h p) 0 → ZMod M) : + flatMaskWord h p R M 0 v = List.ofFn (fun b : Fin M => halfBit (v PUnit.unit) b.val) := by + exact maskWord_zero_eq _ + + theorem flatExcludedWord_base (h : ℕ) (p : ℕ → ℕ → ℕ) (R M : ℕ) + (v : TreeLeaf (fun _ => Fin h) 0 → ZMod M) : + flatExcludedWord h p R M 0 v = List.ofFn (fun b : Fin M => (b,halfBit (v PUnit.unit) b.val)) := by + rfl + + theorem mask_single_ed {h M R : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] (he : M=2*(M/2)) + (l : ℕ) (v : TreeLeaf (MaskChildren h p) l → ZMod M) (i : TreeLeaf (MaskChildren h p) l) (q : ℕ) : + editDistance (flatMaskWord h p R M l v) (flatMaskWord h p R M l (v+Pi.single i (q : ZMod M))) ≤ + 2*treeCopies R (period h p) l*q := by + apply tree_single_ed (MaskChildren h p) (MaskAlphabet h p) (period h p) (fun l => maskTags h p (l+1)) + (fun l => sum_map_maskTags h p (l+1)) (fun _ => Prod.mk) (fun l => maskGamma h p M (l+1)) + (flatMaskWord h p R M) _ (flatMaskWord_succ h p R M) l v i q + intro v w + rw [flatMaskWord_base, flatMaskWord_base] + exact ed_halfBit_le he _ _ + + theorem excluded_single_ed {h M R : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] (he : M=2*(M/2)) + (l : ℕ) (v : TreeLeaf (fun _ => Fin h) l → ZMod M) (i : TreeLeaf (fun _ => Fin h) l) (q : ℕ) : + editDistance (flatExcludedWord h p R M l v) (flatExcludedWord h p R M l (v+Pi.single i (q : ZMod M))) ≤ + 2*treeCopies R (period h p) l*q := by + apply tree_single_ed (fun _ => Fin h) (ExcludedAlphabet h M) (period h p) (fun l => excludedTags h (l+1)) + (fun l => sum_map_excludedTags h (l+1)) (fun _ => Prod.mk) (fun l => excludedTranslation h p M (l+1)) + (flatExcludedWord h p R M) _ (flatExcludedWord_succ h p R M) l v i q + intro v w + rw [flatExcludedWord_base, flatExcludedWord_base] + exact ed_tagged_halfBit_le he _ _ + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/TreeBranching.lean b/lean/OAI/Combinatorics/FiniteCircle/TreeBranching.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f778cf71b2b79075e8a219871aa91330c1f5d4a --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/TreeBranching.lean @@ -0,0 +1,507 @@ +import OAI.Combinatorics.FiniteCircle.MaskBranching + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +@[reducible] def TreeLeaf (J : ℕ → Type) : ℕ → Type + | 0 => PUnit + | l+1 => J (l+1) × TreeLeaf J l + +instance treeLeafFintype (J : ℕ → Type) [∀ l, Fintype (J l)] (l : ℕ) : + Fintype (TreeLeaf J l) := by + induction l with + | zero => exact inferInstanceAs (Fintype PUnit) + | succ l ih => exact @instFintypeProd _ _ inferInstance ih + +noncomputable instance treeLeafDecidableEq (J : ℕ → Type) (l : ℕ) : + DecidableEq (TreeLeaf J l) := Classical.decEq _ + +noncomputable def treeCheap (J Z : ℕ → Type) [∀ l, AddCommGroup (Z l)] {M : ℕ} + (σ : ∀ l, Z l →+ (J l → ZMod M)) : (l : ℕ) → AddSubgroup (TreeLeaf J l → ZMod M) + | 0 => ⊥ + | l+1 => { + carrier := {v | ∃ c : J (l+1) → TreeLeaf J l → ZMod M, + (∀ j, c j ∈ treeCheap J Z σ l) ∧ ∃ z : Z (l+1), ∀ j i, v (j,i) = c j i + σ (l+1) z j} + zero_mem' := by + refine ⟨0, fun j => (treeCheap J Z σ l).zero_mem, 0, ?_⟩ + intro j i + change (0:ZMod M) = 0 + σ (l+1) 0 j + simp + add_mem' := by + rintro v w ⟨c,hc,z,hz⟩ ⟨d,hd,u,hu⟩ + refine ⟨c+d, fun j => (treeCheap J Z σ l).add_mem (hc j) (hd j), z+u, ?_⟩ + intro j i + change v (j,i)+w (j,i) = c j i+d j i+σ (l+1) (z+u) j + simp only [hz, hu, map_add, Pi.add_apply] + abel + neg_mem' := by + rintro v ⟨c,hc,z,hz⟩ + refine ⟨-c, fun j => (treeCheap J Z σ l).neg_mem (hc j), -z, ?_⟩ + intro j i + change -v (j,i) = -c j i+σ (l+1) (-z) j + simp only [hz, map_neg, Pi.neg_apply] + abel } + + theorem treeCheap_generator (J Z : ℕ → Type) [∀ l, AddCommGroup (Z l)] {M : ℕ} + (σ : ∀ l, Z l →+ (J l → ZMod M)) (l : ℕ) (z : Z (l+1)) : + (fun i : TreeLeaf J (l+1) => σ (l+1) z i.1) ∈ treeCheap J Z σ (l+1) := by + exact ⟨0, fun _ => (treeCheap J Z σ l).zero_mem, z, fun _ _ => (zero_add _).symm⟩ + + theorem treeCheap_child (J Z : ℕ → Type) [∀ l, AddCommGroup (Z l)] {M : ℕ} + (σ : ∀ l, Z l →+ (J l → ZMod M)) (l : ℕ) [DecidableEq (J (l+1))] (j : J (l+1)) + (c : TreeLeaf J l → ZMod M) (hc : c ∈ treeCheap J Z σ l) : + (fun i : TreeLeaf J (l+1) => if i.1 = j then c i.2 else 0) ∈ treeCheap J Z σ (l+1) := by + classical + refine ⟨fun k => if k = j then c else 0, ?_, 0, ?_⟩ + · intro k + dsimp only + split_ifs + · exact hc + · exact (treeCheap J Z σ l).zero_mem + · intro k i + simp only [map_zero, Pi.zero_apply, add_zero] + split_ifs <;> rfl + +noncomputable def treeFrequency (J : ℕ → Type) : + (l : ℕ) → (TreeLeaf J l → ℤ) → FrequencyTree J l + | 0, ξ => ξ PUnit.unit + | l+1, ξ => fun j => treeFrequency J l (fun i => ξ (j,i)) + + theorem treeFrequency_sum (J : ℕ → Type) [∀ l, Fintype (J l)] (l : ℕ) + (ξ : TreeLeaf J l → ℤ) : frequencySum J l (treeFrequency J l ξ) = ∑ i, ξ i := by + induction l with + | zero => + change ξ PUnit.unit = ∑ i : PUnit, ξ i + exact (Fintype.sum_unique (fun i : PUnit => ξ i)).symm + | succ l ih => + change (∑ j, frequencySum J l (treeFrequency J l (fun i => ξ (j,i)))) = + ∑ i : J (l+1) × TreeLeaf J l, ξ i + simp only [ih] + exact (Fintype.sum_prod_type (fun i : J (l+1) × TreeLeaf J l => ξ i)).symm + + theorem treeFrequency_mass (J : ℕ → Type) [∀ l, Fintype (J l)] (l : ℕ) + (ξ : TreeLeaf J l → ℤ) : frequencyMass J l (treeFrequency J l ξ) = ∑ i, (ξ i).natAbs := by + induction l with + | zero => + change (ξ PUnit.unit).natAbs = ∑ i : PUnit, (ξ i).natAbs + exact (Fintype.sum_unique (fun i : PUnit => (ξ i).natAbs)).symm + | succ l ih => + change (∑ j, frequencyMass J l (treeFrequency J l (fun i => ξ (j,i)))) = + ∑ i : J (l+1) × TreeLeaf J l, (ξ i).natAbs + simp only [ih] + exact (Fintype.sum_prod_type (fun i : J (l+1) × TreeLeaf J l => (ξ i).natAbs)).symm + +noncomputable def flatMaskState (h : ℕ) (p : ℕ → ℕ → ℕ) (M : ℕ) : + (l : ℕ) → (TreeLeaf (MaskChildren h p) l → ZMod M) → MaskState h p M l + | 0, v => v PUnit.unit + | l+1, v => fun j => flatMaskState h p M l (fun i => v (j,i)) + + theorem flatMaskState_shift (h : ℕ) (p : ℕ → ℕ → ℕ) (M l : ℕ) + (v : TreeLeaf (MaskChildren h p) l → ZMod M) (θ : ZMod M) : + flatMaskState h p M l (fun i => v i+θ) = shiftMaskState h p M l (flatMaskState h p M l v) θ := by + induction l with + | zero => rfl + | succ l ih => + funext j + exact ih (fun i => v (j,i)) + +noncomputable def flatExcludedState (m M : ℕ) : + (l : ℕ) → (TreeLeaf (fun _ => Fin m) l → ZMod M) → ExcludedState m M l + | 0, v => v PUnit.unit + | l+1, v => fun j => flatExcludedState m M l (fun i => v (j,i)) + + theorem flatExcludedState_shift (m M l : ℕ) + (v : TreeLeaf (fun _ => Fin m) l → ZMod M) (θ : ZMod M) : + flatExcludedState m M l (fun i => v i+θ) = shiftExcludedState m M l (flatExcludedState m M l v) θ := by + induction l with + | zero => rfl + | succ l ih => + funext j + exact ih (fun i => v (j,i)) + + theorem char_sum {G : Type*} [AddCommMonoid G] {I : Type*} (χ : AddChar G ℂ) + (s : Finset I) (f : I → G) : χ (∑ i ∈ s, f i) = ∏ i ∈ s, χ (f i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => simp only [Finset.sum_insert hi, Finset.prod_insert hi, + AddChar.map_add_eq_mul, ih] + + theorem character_dot {I : Type*} [Fintype I] [DecidableEq I] {M : ℕ} [NeZero M] + (χ : AddChar (I → ZMod M) ℂ) (v : I → ZMod M) : + χ v = AddChar.zmodAddEquiv (∑ i, coordinateFrequency χ i * v i) 1 := by + classical + have hv : v = ∑ i, Pi.single i (v i) := by + ext j + simp [Pi.single_apply] + conv_lhs => rw [hv] + rw [char_sum] + rw [map_sum, AddChar.sum_apply] + apply Finset.prod_congr rfl + intro i _ + rw [character_single, zmod_character_mul] + + theorem character_dot_eq_one {I : Type*} [Fintype I] [DecidableEq I] {M : ℕ} [NeZero M] + (χ : AddChar (I → ZMod M) ℂ) (v : I → ZMod M) : + χ v = 1 ↔ ∑ i, coordinateFrequency χ i * v i = 0 := by + rw [character_dot, zmod_character_eq_one, mul_one] + + theorem dot_restrict_child (J Z : ℕ → Type) [∀ l, Fintype (J l)] + [∀ l, AddCommGroup (Z l)] {M : ℕ} (σ : ∀ l, Z l →+ (J l → ZMod M)) + (l : ℕ) (ξ : TreeLeaf J (l+1) → ℤ) + (ha : ∀ c ∈ treeCheap J Z σ (l+1), ∑ i, (ξ i : ZMod M)*c i = 0) + (j : J (l+1)) (c : TreeLeaf J l → ZMod M) (hc : c ∈ treeCheap J Z σ l) : + ∑ i, (ξ (j,i):ZMod M)*c i = 0 := by + classical + have ht := ha _ (treeCheap_child J Z σ l j c hc) + change (∑ k : J (l+1) × TreeLeaf J l, (ξ k : ZMod M)*(if k.1=j then c k.2 else 0)) = 0 at ht + simpa only [Fintype.sum_prod_type, mul_ite, mul_zero, Finset.sum_ite_irrel, + Finset.sum_const_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true] using ht + +@[simp] theorem subcircle_intCast {M p : ℕ} (hp : p ∣ M) (a : ℤ) : + subcircle hp (a : ZMod p) = (M/p : ZMod M)*(a : ZMod M) := by + have h := map_zsmul (subcircle hp) a (1 : ZMod p) + have hc : subcircle hp 1 = (M/p : ZMod M) := by + simpa only [Nat.cast_one, mul_one] using subcircle_natCast hp 1 + rw [zsmul_eq_mul, mul_one, hc, zsmul_eq_mul] at h + simpa only [mul_comm] using h + + theorem mask_generator_apply {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ k : Fin h, p l k ∣ M) (k : Fin h) (j : MaskTag h p l) : + maskPhaseHom h p M l hd (Pi.single k 1) j = + subcircle (hd k) 1 + if j.1 = k then j.2.val • subcircle (hd k) 1 else 0 := by + classical + have hs : (∑ a : Fin h, subcircle (hd a) ((Pi.single k 1 : MaskResidues h p l) a)) = + subcircle (hd k) 1 := by + rw [Finset.sum_eq_single k] + · simp + · intro a _ ha + simp [Pi.single_eq_of_ne ha] + · simp + change (∑ a : Fin h, subcircle (hd a) ((Pi.single k 1 : MaskResidues h p l) a)) + + j.2.val • subcircle (hd j.1) ((Pi.single k 1 : MaskResidues h p l) j.1) = _ + rw [hs] + congr 1 + by_cases he : j.1 = k + · subst k + simp + · simp [he] + +noncomputable def maskCheap (h : ℕ) (p : ℕ → ℕ → ℕ) (M : ℕ) + (hd : ∀ l (k : Fin h), p l k ∣ M) (l : ℕ) : + AddSubgroup (TreeLeaf (MaskChildren h p) l → ZMod M) := + treeCheap (MaskChildren h p) (MaskResidues h p) (fun l => maskPhaseHom h p M l (hd l)) l + + theorem mask_dot_generator {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ k : Fin h, p (l+1) k ∣ M) (k : Fin h) + (ξ : TreeLeaf (MaskChildren h p) (l+1) → ℤ) : + (∑ i, (ξ i:ZMod M)*maskPhaseHom h p M (l+1) hd (Pi.single k 1) i.1) = + subcircle (hd k) (((∑ i, ξ i) + ∑ b : Fin (p (l+1) k), (b.val:ℤ)* + ∑ i : TreeLeaf (MaskChildren h p) l, ξ (⟨k,b⟩,i) : ℤ) : ZMod (p (l+1) k)) := by + classical + rw [subcircle_intCast] + let q : ZMod M := subcircle (hd k) 1 + have hq : q = (M/p (l+1) k : ZMod M) := by + simpa only [Nat.cast_one, mul_one] using subcircle_natCast (hd k) 1 + simp_rw [mask_generator_apply] + change (∑ i : MaskTag h p (l+1) × TreeLeaf (MaskChildren h p) l, + (ξ i:ZMod M)*(q+if i.1.1=k then i.1.2.val • q else 0)) = _ + simp_rw [mul_add, Finset.sum_add_distrib] + rw [← Finset.sum_mul] + have hs : (∑ i : MaskTag h p (l+1) × TreeLeaf (MaskChildren h p) l, + (ξ i:ZMod M)*(if i.1.1=k then i.1.2.val • q else 0)) = + (∑ b : Fin (p (l+1) k), (b.val:ZMod M)*∑ i : TreeLeaf (MaskChildren h p) l, + (ξ (⟨k,b⟩,i):ZMod M))*q := by + rw [Fintype.sum_prod_type, Fintype.sum_sigma] + simp only [mul_ite, mul_zero, Finset.sum_ite_irrel, Finset.sum_const_zero] + rw [Finset.sum_ite_eq', ite_eq_left (Finset.mem_univ k)] + simp_rw [nsmul_eq_mul, ← Finset.sum_mul] + conv_rhs => rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro b _ + ring + rw [hs, hq] + push_cast + ring + +theorem mask_annihilator_congruences {h M : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (l : ℕ) (ξ : TreeLeaf (MaskChildren h p) l → ℤ) + (ha : ∀ c ∈ maskCheap h p M hd l, ∑ i, (ξ i:ZMod M)*c i = 0) : + MaskCongruences h p l (treeFrequency (MaskChildren h p) l ξ) := by + classical + induction l with + | zero => trivial + | succ l ih => + change (∀ k : Fin h, (p (l+1) k:ℤ) ∣ _ ) ∧ _ + constructor + · intro k + let : NeZero (p (l+1) k) := ⟨(hn _ k).ne'⟩ + have hg := treeCheap_generator (MaskChildren h p) (MaskResidues h p) + (fun l => maskPhaseHom h p M l (hd _)) l (Pi.single k 1) + have hz := ha _ hg + rw [mask_dot_generator (hd (l+1)) k ξ] at hz + have he : (((∑ i, ξ i) + ∑ b : Fin (p (l+1) k), (b.val:ℤ)* + ∑ i : TreeLeaf (MaskChildren h p) l, ξ (⟨k,b⟩,i) : ℤ) : ZMod (p (l+1) k)) = 0 := + subcircle_injective (hd _ k) (hz.trans (map_zero _).symm) + have he' := (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mp he + simp only [treeFrequency, frequencySum, treeFrequency_sum] + convert he' using 1 + congr 1 + exact (Fintype.sum_prod_type (fun i : MaskChildren h p (l+1) × TreeLeaf (MaskChildren h p) l => ξ i)).symm + · intro j + apply ih + intro c hc + exact dot_restrict_child (MaskChildren h p) (MaskResidues h p) + (fun l => maskPhaseHom h p M l (hd _)) l ξ ha j c hc + +theorem mask_character_branching {h M : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hh : 2 ≤ h) (hd : ∀ l (k : Fin h), p l k ∣ M) + (hn : ∀ l (k : Fin h), 0 < p l k) + (hp : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → Nat.Prime (p l k)) + (hinj : ∀ l, 1 ≤ l → l ≤ h → Function.Injective (fun k : Fin h => p l k)) + (hlarge : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → h ^ 3 ≤ p l k) + (χ : AddChar (TreeLeaf (MaskChildren h p) h → ZMod M) ℂ) + (ha : χ.compAddMonoidHom (maskCheap h p M hd h).subtype = 0) + (θ : ZMod M) (hw : χ (fun _ => θ) ≠ 1) : + ((h:ℝ)/2)^h ≤ ∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ) := by + classical + let ξ := fun i => (coordinateFrequency χ i).valMinAbs + have hc := mask_annihilator_congruences hd hn h ξ (fun c hc => by + have hv := congrArg (fun ψ : AddChar (maskCheap h p M hd h) ℂ => ψ ⟨c,hc⟩) ha + have he : χ c = 1 := hv + have hz := (character_dot_eq_one χ c).mp he + simpa only [ξ, ZMod.coe_valMinAbs] using hz) + have hroot : frequencySum (MaskChildren h p) h (treeFrequency (MaskChildren h p) h ξ) ≠ 0 := by + rw [treeFrequency_sum] + intro he + apply hw + rw [character_dot_eq_one, ← Finset.sum_mul] + have hz : ∑ i, coordinateFrequency χ i = 0 := by + have ht := congrArg (fun n : ℤ => (n : ZMod M)) he + simpa only [Int.cast_sum, ξ, ZMod.coe_valMinAbs, Int.cast_zero] using ht + rw [hz, zero_mul] + have hb := mask_frequency_branching hh p hp hinj hlarge _ hc hroot + rw [treeFrequency_mass] at hb + simp only [Nat.cast_sum, ξ] at hb + convert hb using 1 + congr 1 + +noncomputable def ExcludedCongruences (h : ℕ) (p : ℕ → ℕ → ℕ) : + (l : ℕ) → FrequencyTree (fun _ => Fin h) l → Prop + | 0, _ => True + | l+1, t => + (∀ k : Fin h, (p (l+1) k:ℤ) ∣ frequencySum (fun _ => Fin h) (l+1) t - + frequencySum (fun _ => Fin h) l (t k)) ∧ + ∀ j, ExcludedCongruences h p l (t j) + + theorem many_excluded_children {h : ℕ} (hh : 2 ≤ h) (p : Fin h → ℕ) + (hp : ∀ i, Nat.Prime (p i)) (hinj : Function.Injective p) + (hlarge : ∀ i, h ^ 3 ≤ p i) (f : Fin h → ℤ) + {β : ℤ} (hβ : β ≠ 0) (hsmall : β.natAbs < h ^ h) + (hc : ∀ k, (p k : ℤ) ∣ β - f k) : + h ≤ 2 * (Finset.univ.filter fun j => f j ≠ 0).card := by + classical + let s := Finset.univ.filter fun j => f j ≠ 0 + let t := Finset.univ.filter fun k => ¬ (p k : ℤ) ∣ β + let q := Finset.univ.filter fun k => (p k : ℤ) ∣ β + have hq : 3 * q.card < h := few_large_prime_divisors hh p hp hinj hlarge hβ hsmall + have ht : t ⊆ s := by + intro k hk + refine Finset.mem_filter.mpr ⟨Finset.mem_univ k, ?_⟩ + intro he + have hc' := hc k + rw [he, sub_zero] at hc' + exact (Finset.mem_filter.mp hk).2 hc' + have hcard : t.card ≤ s.card := Finset.card_le_card ht + have hcount : q.card + t.card = h := by + simpa [q, t] using (Finset.card_filter_add_card_filter_not + (s := (Finset.univ : Finset (Fin h))) (fun k => (p k : ℤ) ∣ β)) + change h ≤ 2 * s.card + omega + +theorem excluded_branching_induction {h : ℕ} (hh : 2 ≤ h) (p : ℕ → ℕ → ℕ) + (hp : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → Nat.Prime (p l k)) + (hinj : ∀ l, 1 ≤ l → l ≤ h → Function.Injective (fun k : Fin h => p l k)) + (hlarge : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → h ^ 3 ≤ p l k) + (l : ℕ) (hl : l ≤ h) (t : FrequencyTree (fun _ => Fin h) l) + (hc : ExcludedCongruences h p l t) + (hroot : frequencySum (fun _ => Fin h) l t ≠ 0) + (hsmall : frequencyMass (fun _ => Fin h) l t < h ^ h) : + ((h : ℝ) / 2) ^ l ≤ (frequencyMass (fun _ => Fin h) l t : ℝ) := by + classical + induction l with + | zero => + have : 1 ≤ frequencyMass (fun _ => Fin h) 0 t := + (Int.natAbs_pos.mpr hroot).trans_le (frequencySum_natAbs_le_mass _ _ _) + simpa using (show (1 : ℝ) ≤ frequencyMass (fun _ => Fin h) 0 t by exact_mod_cast this) + | succ l ih => + let f : Fin h → ℤ := fun j => frequencySum (fun _ => Fin h) l (t j) + let s := Finset.univ.filter fun j => f j ≠ 0 + have hsumSmall : (frequencySum (fun _ => Fin h) (l + 1) t).natAbs < h ^ h := + (frequencySum_natAbs_le_mass _ _ _).trans_lt hsmall + have hcard : h ≤ 2 * s.card := + many_excluded_children hh (fun k => p (l + 1) k) + (fun k => hp _ k (by omega) hl) (hinj _ (by omega) hl) + (fun k => hlarge _ k (by omega) hl) f hroot hsumSmall hc.1 + have hchild : ∀ j, frequencyMass (fun _ => Fin h) l (t j) < h ^ h := by + intro j + apply lt_of_le_of_lt _ hsmall + change frequencyMass (fun _ => Fin h) l (t j) ≤ ∑ j, frequencyMass (fun _ => Fin h) l (t j) + exact Finset.single_le_sum (f := fun j => frequencyMass (fun _ => Fin h) l (t j)) + (fun _ _ => Nat.zero_le _) (Finset.mem_univ j) + have hm : ∀ j ∈ s, ((h : ℝ) / 2) ^ l ≤ frequencyMass (fun _ => Fin h) l (t j) := by + intro j hj + exact ih (by omega) (t j) (hc.2 j) (Finset.mem_filter.mp hj).2 (hchild j) + have hcardR : (h : ℝ) / 2 ≤ s.card := by + have : (h : ℝ) ≤ 2 * (s.card : ℝ) := by exact_mod_cast hcard + linarith + calc + ((h : ℝ) / 2) ^ (l + 1) = ((h : ℝ) / 2) * ((h : ℝ) / 2) ^ l := by ring + _ ≤ s.card * ((h : ℝ) / 2) ^ l := mul_le_mul_of_nonneg_right hcardR (by positivity) + _ = ∑ j ∈ s, ((h : ℝ) / 2) ^ l := by simp + _ ≤ ∑ j ∈ s, (frequencyMass (fun _ => Fin h) l (t j) : ℝ) := Finset.sum_le_sum hm + _ ≤ ∑ j, (frequencyMass (fun _ => Fin h) l (t j) : ℝ) := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) (fun _ _ _ => by positivity) + _ = (frequencyMass (fun _ => Fin h) (l + 1) t : ℝ) := by + simp only [frequencyMass, Nat.cast_sum] + +theorem excluded_frequency_branching {h : ℕ} (hh : 2 ≤ h) (p : ℕ → ℕ → ℕ) + (hp : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → Nat.Prime (p l k)) + (hinj : ∀ l, 1 ≤ l → l ≤ h → Function.Injective (fun k : Fin h => p l k)) + (hlarge : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → h ^ 3 ≤ p l k) + (t : FrequencyTree (fun _ => Fin h) h) (hc : ExcludedCongruences h p h t) + (hroot : frequencySum (fun _ => Fin h) h t ≠ 0) : + ((h : ℝ) / 2) ^ h ≤ (frequencyMass (fun _ => Fin h) h t : ℝ) := by + by_contra hn + have hlt := lt_of_not_ge hn + have hcap : ((h : ℝ) / 2) ^ h ≤ (h : ℝ) ^ h := by + apply pow_le_pow_left₀ (by positivity) + have : (0 : ℝ) ≤ h := Nat.cast_nonneg h + linarith + have hsmall : frequencyMass (fun _ => Fin h) h t < h ^ h := by + exact_mod_cast hlt.trans_le hcap + exact (not_lt_of_ge (excluded_branching_induction hh p hp hinj hlarge h le_rfl t hc hroot hsmall)) hlt + + theorem excluded_generator_apply {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ k : Fin h, p l k ∣ M) (k j : Fin h) : + excludedPhaseHom h p M l hd (Pi.single k 1) j = + subcircle (hd k) 1 - if j = k then subcircle (hd k) 1 else 0 := by + classical + rw [excludedPhaseHom_apply] + have hs : (∑ a : Fin h, subcircle (hd a) ((Pi.single k 1 : MaskResidues h p l) a)) = + subcircle (hd k) 1 := by + rw [Finset.sum_eq_single k] + · simp + · intro a _ ha + simp [Pi.single_eq_of_ne ha] + · simp + rw [hs] + congr 1 + by_cases he : j = k + · subst j + simp + · simp [he] + +noncomputable def excludedCheap (h : ℕ) (p : ℕ → ℕ → ℕ) (M : ℕ) + (hd : ∀ l (k : Fin h), p l k ∣ M) (l : ℕ) : + AddSubgroup (TreeLeaf (fun _ => Fin h) l → ZMod M) := + treeCheap (fun _ => Fin h) (MaskResidues h p) (fun l => excludedPhaseHom h p M l (hd l)) l + + theorem excluded_dot_generator {h M l : ℕ} {p : ℕ → ℕ → ℕ} + (hd : ∀ k : Fin h, p (l+1) k ∣ M) (k : Fin h) + (ξ : TreeLeaf (fun _ => Fin h) (l+1) → ℤ) : + (∑ i, (ξ i:ZMod M)*excludedPhaseHom h p M (l+1) hd (Pi.single k 1) i.1) = + subcircle (hd k) (((∑ i, ξ i) - + ∑ i : TreeLeaf (fun _ => Fin h) l, ξ (k,i) : ℤ) : ZMod (p (l+1) k)) := by + classical + rw [subcircle_intCast] + let q : ZMod M := subcircle (hd k) 1 + have hq : q = (M/p (l+1) k : ZMod M) := by + simpa only [Nat.cast_one, mul_one] using subcircle_natCast (hd k) 1 + simp_rw [excluded_generator_apply] + change (∑ i : Fin h × TreeLeaf (fun _ => Fin h) l, + (ξ i:ZMod M)*(q-if i.1=k then q else 0)) = _ + simp_rw [mul_sub, Finset.sum_sub_distrib] + rw [← Finset.sum_mul] + have hs : (∑ i : Fin h × TreeLeaf (fun _ => Fin h) l, + (ξ i:ZMod M)*(if i.1=k then q else 0)) = + (∑ i : TreeLeaf (fun _ => Fin h) l, (ξ (k,i):ZMod M))*q := by + simp only [Fintype.sum_prod_type, mul_ite, mul_zero] + rw [Finset.sum_comm] + simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true] + rw [← Finset.sum_mul] + rw [hs, hq] + push_cast + ring + + theorem excluded_annihilator_congruences {h M : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hd : ∀ l (k : Fin h), p l k ∣ M) (hn : ∀ l (k : Fin h), 0 < p l k) + (l : ℕ) (ξ : TreeLeaf (fun _ => Fin h) l → ℤ) + (ha : ∀ c ∈ excludedCheap h p M hd l, ∑ i, (ξ i:ZMod M)*c i = 0) : + ExcludedCongruences h p l (treeFrequency (fun _ => Fin h) l ξ) := by + classical + induction l with + | zero => trivial + | succ l ih => + change (∀ k : Fin h, (p (l+1) k:ℤ) ∣ _ ) ∧ _ + constructor + · intro k + let : NeZero (p (l+1) k) := ⟨(hn _ k).ne'⟩ + have hg := treeCheap_generator (fun _ => Fin h) (MaskResidues h p) + (fun l => excludedPhaseHom h p M l (hd _)) l (Pi.single k 1) + have hz := ha _ hg + rw [excluded_dot_generator (hd (l+1)) k ξ] at hz + have he : (((∑ i, ξ i) - + ∑ i : TreeLeaf (fun _ => Fin h) l, ξ (k,i) : ℤ) : ZMod (p (l+1) k)) = 0 := + subcircle_injective (hd _ k) (hz.trans (map_zero _).symm) + have he' := (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mp he + simp only [treeFrequency, frequencySum, treeFrequency_sum] + convert he' using 1 + congr 1 + exact (Fintype.sum_prod_type (fun i : Fin h × TreeLeaf (fun _ => Fin h) l => ξ i)).symm + · intro j + apply ih + intro c hc + exact dot_restrict_child (fun _ => Fin h) (MaskResidues h p) + (fun l => excludedPhaseHom h p M l (hd _)) l ξ ha j c hc + + theorem excluded_character_branching {h M : ℕ} {p : ℕ → ℕ → ℕ} [NeZero M] + (hh : 2 ≤ h) (hd : ∀ l (k : Fin h), p l k ∣ M) + (hn : ∀ l (k : Fin h), 0 < p l k) + (hp : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → Nat.Prime (p l k)) + (hinj : ∀ l, 1 ≤ l → l ≤ h → Function.Injective (fun k : Fin h => p l k)) + (hlarge : ∀ l (k : Fin h), 1 ≤ l → l ≤ h → h ^ 3 ≤ p l k) + (χ : AddChar (TreeLeaf (fun _ => Fin h) h → ZMod M) ℂ) + (ha : χ.compAddMonoidHom (excludedCheap h p M hd h).subtype = 0) + (θ : ZMod M) (hw : χ (fun _ => θ) ≠ 1) : + ((h:ℝ)/2)^h ≤ ∑ i, ((coordinateFrequency χ i).valMinAbs.natAbs:ℝ) := by + classical + let ξ := fun i => (coordinateFrequency χ i).valMinAbs + have hc := excluded_annihilator_congruences hd hn h ξ (fun c hc => by + have hv := congrArg (fun ψ : AddChar (excludedCheap h p M hd h) ℂ => ψ ⟨c,hc⟩) ha + have he : χ c = 1 := hv + have hz := (character_dot_eq_one χ c).mp he + simpa only [ξ, ZMod.coe_valMinAbs] using hz) + have hroot : frequencySum (fun _ => Fin h) h (treeFrequency (fun _ => Fin h) h ξ) ≠ 0 := by + rw [treeFrequency_sum] + intro he + apply hw + rw [character_dot_eq_one, ← Finset.sum_mul] + have hz : ∑ i, coordinateFrequency χ i = 0 := by + have ht := congrArg (fun n : ℤ => (n : ZMod M)) he + simpa only [Int.cast_sum, ξ, ZMod.coe_valMinAbs, Int.cast_zero] using ht + rw [hz, zero_mul] + have hb := excluded_frequency_branching hh p hp hinj hlarge _ hc hroot + rw [treeFrequency_mass] at hb + simp only [Nat.cast_sum, ξ] at hb + simpa only [Nat.cast_sum, ξ] using hb + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Upper.lean b/lean/OAI/Combinatorics/FiniteCircle/Upper.lean new file mode 100644 index 0000000000000000000000000000000000000000..63e2e64ea386a77c8fdd4e60eaa5fc854d50c2f7 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Upper.lean @@ -0,0 +1,162 @@ +import OAI.Combinatorics.FiniteCircle.UpperParameters + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +theorem one_letter_embedding {α : Type*} [Fintype α] : + ∃ M : ℕ, ∃ F : List.Vector α 1 → Fin M → ℝ, ∀ x y, + (deficit x.val y.val : ℝ) ≤ coordDist F x y ∧ + coordDist F x y ≤ 2 * deficit x.val y.val := by + classical + let X := List.Vector α 1 + let : DecidableEq X := Classical.decEq X + let e := Fintype.equivFin X + let F : X → Fin (Fintype.card X) → ℝ := fun x i => if e.symm i = x then 1 else 0 + have he (x y : X) : coordDist F x y = if x = y then 0 else 2 := by + unfold coordDist + rw [← e.sum_comp (fun i => |F x i - F y i|)] + simp only [F, Equiv.symm_apply_apply] + by_cases h : x = y + · simp [h] + · rw [ite_eq_right h] + have hh (i : X) : |(if i = x then (1:ℝ) else 0) - (if i = y then 1 else 0)| = + (if i = x then 1 else 0) + (if i = y then 1 else 0) := by + split_ifs <;> simp_all + simp_rw [hh] + rw [Finset.sum_add_distrib] + simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true] + norm_num + have hd (x y : X) : deficit x.val y.val = if x = y then 0 else 1 := by + by_cases h : x = y + · simp [h, deficit] + · rw [ite_eq_right h] + have hx : x.val.length = 1 := x.property + have hy : y.val.length = 1 := y.property + have hu := lcs_le_length_left x.val y.val + have h0 : lcs x.val y.val = 0 := by + by_contra hc + have hl : lcs x.val y.val = 1 := by omega + obtain ⟨z, hz, hw, heq⟩ := lcs_exists x.val y.val + have hzx : z = x.val := hz.eq_of_length (by omega) + have hzy : z = y.val := hw.eq_of_length (by omega) + exact h (Subtype.ext (hzx.symm.trans hzy)) + simp [deficit, hx, h0] + refine ⟨Fintype.card X, F, fun x y => ?_⟩ + rw [he, hd] + split_ifs <;> norm_num + +theorem histogram_factor_le {b m n : ℕ} (hmn : m ≤ n) {Λ : ℝ} (hΛ : 0 ≤ Λ) : + 16 * ((Nat.log 2 m : ℝ)+1) * ((b:ℝ) + 16 * Real.log ((m:ℝ)+1) * Λ) ≤ + 512 * ((Nat.log 2 n : ℝ)+1)^2 * ((b:ℝ)+Λ) := by + let K : ℝ := (Nat.log 2 n : ℝ)+1 + have hK : 1 ≤ K := by dsimp [K]; linarith [Nat.cast_nonneg (α := ℝ) (Nat.log 2 n)] + have hK0 : 0 ≤ K := by linarith + have hl : Real.log ((m:ℝ)+1) ≤ K := + (log_add_one_le_dyadic_count m).trans (by + dsimp [K] + exact_mod_cast Nat.add_le_add_right (Nat.log_mono_right hmn) 1) + have hmK : (Nat.log 2 m : ℝ)+1 ≤ K := by + dsimp [K] + exact_mod_cast Nat.add_le_add_right (Nat.log_mono_right hmn) 1 + have hn : (0:ℝ) ≤ b := Nat.cast_nonneg b + have hl0 : 0 ≤ Real.log ((m:ℝ)+1) := Real.log_nonneg (by linarith [Nat.cast_nonneg (α := ℝ) m]) + calc + _ ≤ 16*K*((b:ℝ)+16*K*Λ) := by gcongr + _ ≤ 512*K^2*((b:ℝ)+Λ) := by + have hKb : K*(b:ℝ) ≤ K^2*b := mul_le_mul_of_nonneg_right (by nlinarith only [hK] : K ≤ K^2) hn + have hKΛ : 0 ≤ K^2*Λ := mul_nonneg (sq_nonneg K) hΛ + nlinarith only [hKb, hKΛ, mul_nonneg (sq_nonneg K) hn] + +theorem power_length_embedding {α : Type*} [Fintype α] (a : α) {b H : ℕ} (hb : 2 ≤ b) : + ∃ M : ℕ, ∃ F : List.Vector α (b^H) → Fin M → ℝ, ∀ x y, + (deficit x.val y.val : ℝ) ≤ coordDist F x y ∧ + coordDist F x y ≤ (b * (1024 * ((Nat.log 2 (b^H) : ℝ)+1)^2)^H) * deficit x.val y.val := by + let n := b^H + let B : ℝ := 1024 * ((Nat.log 2 n : ℝ)+1)^2 + have hb0 : 0 < b := by omega + have hbR : (2:ℝ) ≤ b := by exact_mod_cast hb + have hB : 1 ≤ B := by + have h : (1:ℝ) ≤ (Nat.log 2 n : ℝ)+1 := by linarith [Nat.cast_nonneg (α := ℝ) (Nat.log 2 n)] + dsimp [B] + nlinarith + have hB0 : 0 ≤ B := by linarith + have all (k : ℕ) (hk : k ≤ H) : + ∃ M : ℕ, ∃ F : List.Vector α (b^k) → Fin M → ℝ, ∀ x y, + (deficit x.val y.val : ℝ) ≤ coordDist F x y ∧ + coordDist F x y ≤ ((b:ℝ)*B^k) * deficit x.val y.val := by + induction k with + | zero => + obtain ⟨M, F, hF⟩ := one_letter_embedding (α := α) + refine ⟨M, F, fun x y => ⟨(hF x y).1, ?_⟩⟩ + simpa using (hF x y).2.trans (mul_le_mul_of_nonneg_right hbR (Nat.cast_nonneg _)) + | succ k ih => + obtain ⟨M, F, hF⟩ := ih (by omega) + have hΛ : (0:ℝ) ≤ (b:ℝ)*B^k := by positivity + obtain ⟨M', F', hF'⟩ := histogram_embedding_step a (pow_pos hb0 k) b F ((b:ℝ)*B^k) + hΛ (fun x y => (hF x y).1) (fun x y => (hF x y).2) + have hmn : b^k ≤ n := Nat.pow_le_pow_right hb0 (by omega) + have hfactor := histogram_factor_le (b := b) hmn hΛ + have hΛb : (b:ℝ) ≤ (b:ℝ)*B^k := by + exact le_mul_of_one_le_right (Nat.cast_nonneg b) (one_le_pow₀ hB) + have hfac : 16 * ((Nat.log 2 (b^k) : ℝ)+1) * + ((b:ℝ)+16*Real.log (((b^k : ℕ):ℝ)+1)*((b:ℝ)*B^k)) ≤ (b:ℝ)*B^(k+1) := by + calc + _ ≤ 512*((Nat.log 2 n : ℝ)+1)^2*((b:ℝ)+(b:ℝ)*B^k) := hfactor + _ ≤ 512*((Nat.log 2 n : ℝ)+1)^2*(2*((b:ℝ)*B^k)) := by gcongr; linarith + _ = _ := by dsimp [B]; rw [pow_succ]; ring + rw [pow_succ'] + refine ⟨M', F', fun x y => ⟨(hF' x y).1, ?_⟩⟩ + exact (hF' x y).2.trans (mul_le_mul_of_nonneg_right hfac (Nat.cast_nonneg _)) + exact all H le_rfl + +theorem uniform_upper_of_log_large {α : Type*} [Fintype α] {d : ℕ} + (hd : 16 ≤ Real.log d) : + ∃ M : ℕ, ∃ F : Words α d → Fin M → ℝ, ∀ x y, + (editDistance x.val y.val : ℝ) ≤ coordDist F x y ∧ + coordDist F x y ≤ Real.exp (32 * exponentScale d) * editDistance x.val y.val := by + obtain ⟨b, H, hb, _, hdn, hbound⟩ := exists_power_parameters hd + obtain ⟨M, G, hG⟩ := power_length_embedding (α := Option α) none (H := H) hb + let pad : Words α d → List.Vector (Option α) (b^H) := fun x => + ⟨freshPad (b^H) x.val, length_freshPad (x.property.trans hdn)⟩ + let F : Words α d → Fin M → ℝ := fun x i => 2 * G (pad x) i + have he (x y : Words α d) : coordDist F x y = 2*coordDist G (pad x) (pad y) := by + simp only [coordDist, F, ← mul_sub, abs_mul, show |(2:ℝ)| = 2 by norm_num, Finset.mul_sum] + have hpad (x y : Words α d) : deficit (pad x).val (pad y).val = unequalDeficit x.val y.val := + deficit_freshPad (x.property.trans hdn) (y.property.trans hdn) + refine ⟨M, F, fun x y => ⟨?_, ?_⟩⟩ + · rw [he] + have h := (hG (pad x) (pad y)).1 + rw [hpad] at h + have he := editDistance_le_two_unequalDeficit x.val y.val + exact (by exact_mod_cast he : (editDistance x.val y.val : ℝ) ≤ 2*(unequalDeficit x.val y.val:ℝ)).trans (by linarith) + · rw [he] + have h := (hG (pad x) (pad y)).2 + rw [hpad] at h + have hq : (unequalDeficit x.val y.val:ℝ) ≤ editDistance x.val y.val := + by exact_mod_cast unequalDeficit_le_editDistance x.val y.val + have hB : 0 ≤ (b:ℝ)*(1024*((Nat.log 2 (b^H):ℝ)+1)^2)^H := by positivity + calc + _ ≤ 2*((b:ℝ)*(1024*((Nat.log 2 (b^H):ℝ)+1)^2)^H) * unequalDeficit x.val y.val := by linarith + _ ≤ 2*((b:ℝ)*(1024*((Nat.log 2 (b^H):ℝ)+1)^2)^H) * editDistance x.val y.val := by gcongr + _ ≤ Real.exp (32*exponentScale d) * editDistance x.val y.val := by + gcongr + dsimp [exponentScale] + nlinarith only [hbound, hB] + +theorem uniform_upper : ∃ d₀ : ℕ, UniformUpper 32 d₀ := by + refine ⟨⌈Real.exp 16⌉₊, fun α _ _ d hd => ?_⟩ + have hdexp : Real.exp 16 ≤ (d:ℝ) := (Nat.le_ceil _).trans (by exact_mod_cast hd) + have hlog : 16 ≤ Real.log d := by + have h := Real.log_le_log (Real.exp_pos 16) hdexp + simpa only [Real.log_exp] using h + exact uniform_upper_of_log_large hlog + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/UpperParameters.lean b/lean/OAI/Combinatorics/FiniteCircle/UpperParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0dbc1e933fabbd81d880141e1c5768c755051fd --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/UpperParameters.lean @@ -0,0 +1,170 @@ +import OAI.Combinatorics.FiniteCircle.HistogramEmbedding + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +theorem log_add_one_le_dyadic_count (n : ℕ) : + Real.log ((n:ℝ)+1) ≤ Nat.log 2 n + 1 := by + have hpow : n+1 ≤ 2^(Nat.log 2 n + 1) := + Nat.succ_le_of_lt (Nat.lt_pow_succ_log_self (by norm_num) n) + have hlog := Real.log_le_log (by positivity : (0:ℝ) < (n:ℝ)+1) + (show (n:ℝ)+1 ≤ (2:ℝ)^(Nat.log 2 n+1) by exact_mod_cast hpow) + rw [Real.log_pow] at hlog + have hl2 : Real.log 2 ≤ 1 := by linarith [Real.log_two_lt_d9] + have hc : (0:ℝ) ≤ Nat.log 2 n + 1 := by positivity + push_cast at hlog + nlinarith + +theorem log_large_aux {t : ℝ} (ht : 16 ≤ t) : + 1 ≤ Real.log t ∧ 4 * Real.log t ≤ t := by + have ht0 : 0 < t := by linarith + have hl16 : Real.log 16 = 4 * Real.log 2 := by + rw [show (16:ℝ) = 2^4 by norm_num, Real.log_pow] + norm_num + have hl2lo : (1:ℝ)/2 ≤ Real.log 2 := by linarith [Real.log_two_gt_d9] + have hl2hi : Real.log 2 ≤ 1 := by linarith [Real.log_two_lt_d9] + have hlo := Real.log_le_log (by norm_num : (0:ℝ) < 16) ht + rw [hl16] at hlo + refine ⟨by linarith, ?_⟩ + have hr := Real.log_le_sub_one_of_pos (div_pos ht0 (by norm_num) : 0 < t/16) + rw [Real.log_div ht0.ne' (by norm_num), hl16] at hr + linarith + +theorem natLog_le_twice_log (n : ℕ) : (Nat.log 2 n : ℝ) ≤ 2 * Real.log n := by + have h := Real.natLog_le_logb n 2 + simp only [Real.logb, Nat.cast_ofNat] at h + have hl : (1:ℝ)/2 ≤ Real.log 2 := by linarith [Real.log_two_gt_d9] + have hl0 : 0 < Real.log 2 := by linarith + have hn := Real.log_natCast_nonneg n + refine h.trans ((div_le_iff₀ hl0).mpr ?_) + nlinarith + +theorem exists_power_parameters {d : ℕ} (hd : 16 ≤ Real.log d) : + ∃ b H : ℕ, 2 ≤ b ∧ 1 ≤ H ∧ d ≤ b^H ∧ + (4 * (b:ℝ) * (1024 * ((Nat.log 2 (b^H) : ℝ)+1)^2)^H) ≤ + Real.exp (32 * Real.sqrt (Real.log d * Real.log (Real.log d))) := by + let t := Real.log d + let l := Real.log t + have ht : 16 ≤ t := hd + obtain ⟨hl, hlt⟩ := log_large_aux ht + change 1 ≤ l at hl + change 4*l ≤ t at hlt + have ht0 : 0 < t := by linarith + have hl0 : 0 < l := by linarith + let r := Real.sqrt (t/l) + let s := Real.sqrt (t*l) + have hr0 : 0 ≤ r := Real.sqrt_nonneg _ + have hs0 : 0 ≤ s := Real.sqrt_nonneg _ + have hr2 : r^2 = t/l := Real.sq_sqrt (div_nonneg ht0.le hl0.le) + have hs2 : s^2 = t*l := Real.sq_sqrt (mul_nonneg ht0.le hl0.le) + have hrl : r^2*l = t := by rw [hr2]; field_simp + have hrlo : 2 ≤ r := by + have h : (4:ℝ) ≤ t/l := (le_div_iff₀ hl0).mpr (by linarith) + nlinarith only [h, hr2, hr0] + have hrhi : r ≤ t := by + have h : t/l ≤ t := div_le_self ht0.le hl + nlinarith only [h, hr2, hr0, ht] + have hrs : r*l = s := by + have hsq : (r*l)^2 = s^2 := by + calc + _ = (r^2*l)*l := by ring + _ = t*l := by rw [hrl] + _ = _ := hs2.symm + have hp : 0 ≤ r*l := mul_nonneg hr0 hl0.le + nlinarith only [hsq, hp, hs0] + have htr : t = r*s := by rw [← hrs, ← hrl]; ring + have hslo : 1 ≤ s := by nlinarith only [hs2, hs0, ht, hl] + let H := ⌊r⌋₊ + have hHhi : (H:ℝ) ≤ r := Nat.floor_le hr0 + have hHlow : r < (H:ℝ)+1 := Nat.lt_floor_add_one r + have hHhalf : r/2 ≤ (H:ℝ) := by linarith + have hHpos : 0 < (H:ℝ) := by linarith + have hHnat : 1 ≤ H := by exact_mod_cast (show (1:ℝ) ≤ H by linarith only [hrlo, hHhalf]) + let b := ⌈Real.exp (t/H)⌉₊ + have hbexp : Real.exp (t/H) ≤ (b:ℝ) := Nat.le_ceil _ + have hbupper : (b:ℝ) ≤ 2 * Real.exp (t/H) := by + have hc : (b:ℝ) < Real.exp (t/H)+1 := Nat.ceil_lt_add_one (Real.exp_pos _).le + have he : 1 ≤ Real.exp (t/H) := Real.one_le_exp_iff.mpr (div_nonneg ht0.le hHpos.le) + linarith + have hb2 : 2 ≤ b := by + have he : 1 < Real.exp (t/H) := Real.one_lt_exp_iff.mpr (div_pos ht0 hHpos) + have hb1 : (1:ℝ) < b := he.trans_le hbexp + exact_mod_cast hb1 + have hb0 : (0:ℝ) < b := by exact_mod_cast (by omega : 0 < b) + have hlblo : t/H ≤ Real.log b := by + have h := Real.log_le_log (Real.exp_pos _) hbexp + simpa only [Real.log_exp] using h + have hlbhi : Real.log b ≤ 1 + t/H := by + have h := Real.log_le_log hb0 hbupper + rw [Real.log_mul (by norm_num) (Real.exp_pos _).ne', Real.log_exp] at h + linarith [Real.log_two_lt_d9] + let n := b^H + have hn0 : (0:ℝ) < n := by dsimp [n]; positivity + have hlogn : Real.log n = (H:ℝ)*Real.log b := by simp [n, Real.log_pow] + have htn : t ≤ Real.log n := by + rw [hlogn] + calc + _ = (H:ℝ)*(t/H) := by field_simp + _ ≤ _ := mul_le_mul_of_nonneg_left hlblo hHpos.le + have hnt : Real.log n ≤ 2*t := by + rw [hlogn] + have h := mul_le_mul_of_nonneg_left hlbhi hHpos.le + have he : (H:ℝ)*(1+t/H) = H+t := by field_simp + rw [he] at h + linarith + have hd0 : (0:ℝ) < d := by + by_contra h + have hd0 : d = 0 := by exact_mod_cast (le_antisymm (not_lt.mp h) (Nat.cast_nonneg d)) + norm_num [hd0] at hd + have hdn : d ≤ n := by + exact_mod_cast (Real.log_le_log_iff hd0 hn0).mp htn + let K : ℝ := (Nat.log 2 n : ℝ)+1 + have hKpos : 0 < K := by dsimp [K]; positivity + have hKbound : K ≤ 5*t := by + have h := natLog_le_twice_log n + dsimp [K] + linarith + have hlogK : Real.log K ≤ 4+l := by + have h := Real.log_le_log hKpos hKbound + rw [Real.log_mul (by norm_num) ht0.ne'] at h + have h5 := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ) < 5) + dsimp [l] + linarith + let B : ℝ := 1024*K^2 + have hBpos : 0 < B := by dsimp [B]; positivity + have hlogB : Real.log B ≤ 20*l := by + have h1024 : Real.log 1024 = 10 * Real.log 2 := by + rw [show (1024:ℝ)=2^10 by norm_num, Real.log_pow] + norm_num + dsimp [B] + rw [Real.log_mul (by norm_num) (pow_pos hKpos 2).ne', Real.log_pow, h1024] + norm_num + linarith only [hlogK, hl, Real.log_two_lt_d9] + have hdiv : t/(H:ℝ) ≤ 2*s := by + apply (div_le_iff₀ hHpos).mpr + rw [htr] + nlinarith only [hHhalf, hs0] + have hHl : (H:ℝ)*l ≤ s := by rw [← hrs]; exact mul_le_mul_of_nonneg_right hHhi hl0.le + have hprodpos : 0 < 4*(b:ℝ)*B^H := by positivity + have hlogprod : Real.log (4*(b:ℝ)*B^H) ≤ 32*s := by + rw [Real.log_mul (by positivity) (pow_pos hBpos H).ne', + Real.log_mul (by norm_num) hb0.ne', Real.log_pow] + have h4 : Real.log 4 ≤ 2 := by + rw [show (4:ℝ)=2^2 by norm_num, Real.log_pow] + norm_num only [Nat.cast_ofNat] + nlinarith only [Real.log_two_lt_d9] + have h := mul_le_mul_of_nonneg_left hlogB hHpos.le + nlinarith only [h4, hlbhi, hdiv, h, hHl, hslo] + refine ⟨b, H, hb2, hHnat, hdn, ?_⟩ + change 4*(b:ℝ)*B^H ≤ Real.exp (32*s) + exact (Real.log_le_iff_le_exp hprodpos).mp hlogprod + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/WindowMatching.lean b/lean/OAI/Combinatorics/FiniteCircle/WindowMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..e90303b604d158b2911cd8b6b3d98da11165e204 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/WindowMatching.lean @@ -0,0 +1,332 @@ +import OAI.Combinatorics.FiniteCircle.AnchorRecovery + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module + +theorem matching_segments_card {α : Type*} {x y : List α} {q : ℕ} + (A : WordMatching x y q) (a b n : ℕ) (ha : a+n ≤ x.length) (hb : b+n ≤ y.length) : + (Finset.univ.filter (fun k : Fin q => + a ≤ (A.left k).val ∧ (A.left k).val < a+n ∧ + b ≤ (A.right k).val ∧ (A.right k).val < b+n)).card ≤ + lcs (segment x a n) (segment y b n) := by + classical + let S := Finset.univ.filter (fun k : Fin q => + a ≤ (A.left k).val ∧ (A.left k).val < a+n ∧ + b ≤ (A.right k).val ∧ (A.right k).val < b+n) + let e := S.orderEmbOfFin rfl + have hmem (k : Fin S.card) : a ≤ (A.left (e k)).val ∧ (A.left (e k)).val < a+n ∧ + b ≤ (A.right (e k)).val ∧ (A.right (e k)).val < b+n := + (Finset.mem_filter.mp (S.orderEmbOfFin_mem rfl k)).2 + let f : Fin S.card → Fin (segment x a n).length := fun k => + ⟨(A.left (e k)).val-a, by rw [length_segment ha]; have := hmem k; omega⟩ + let g : Fin S.card → Fin (segment y b n).length := fun k => + ⟨(A.right (e k)).val-b, by rw [length_segment hb]; have := hmem k; omega⟩ + have hf : StrictMono f := by + intro i j hij + have hh := A.left.strictMono (e.strictMono hij) + have hi := hmem i + change (A.left (e i)).val-a < (A.left (e j)).val-a + omega + have hg : StrictMono g := by + intro i j hij + have hh := A.right.strictMono (e.strictMono hij) + have hi := hmem i + change (A.right (e i)).val-b < (A.right (e j)).val-b + omega + apply WordMatching.le_lcs (q:=S.card) + refine ⟨OrderEmbedding.ofStrictMono f hf,OrderEmbedding.ofStrictMono g hg,?_⟩ + intro k + have hka : a+((A.left (e k)).val-a)=(A.left (e k)).val := by have := hmem k; omega + have hkb : b+((A.right (e k)).val-b)=(A.right (e k)).val := by have := hmem k; omega + change (segment x a n).get (f k) = (segment y b n).get (g k) + simpa only [f,g,List.get_eq_getElem, segment, + List.getElem_take,List.getElem_drop,hka,hkb] using A.letters (e k) + +theorem WordMatching.interval_card_loss {α : Type*} {x y : List α} {q w i a t : ℕ} + (A : WordMatching x y q) (hw : 0 < w) (ha : i*w ≤ a) (ht : a+t ≤ (i+1)*w) : + t ≤ (Finset.univ.filter (fun k : Fin q => a ≤ (A.left k).val ∧ (A.left k).val < a+t)).card + + A.sourceLoss w i := by + classical + let S := A.sourceBlock w i + let B := Finset.Ico (i*w) ((i+1)*w) + let T := S.image (fun k => (A.left k).val) + let K := Finset.univ.filter (fun k : Fin q => a ≤ (A.left k).val ∧ (A.left k).val < a+t) + let I := Finset.Ico a (a+t) + have hinj : Function.Injective (fun k : Fin q => (A.left k).val) := + fun k l h => A.left.injective (Fin.ext h) + have hT : T⊆B := by + intro j hj + obtain ⟨k,hk,rfl⟩ := Finset.mem_image.mp hj + have hd := (A.mem_sourceBlock w i k).mp hk + have hl := Nat.mod_lt (A.left k).val hw + have he := Nat.mod_add_div (A.left k).val w + rw [hd, Nat.mul_comm w i] at he + apply Finset.mem_Ico.mpr + constructor + · omega + · rw [Nat.add_mul, one_mul]; omega + have hBcard : B.card=w := by simp [B,Nat.add_mul] + have hTcard : T.card=S.card := Finset.card_image_of_injective S hinj + have hI : I ⊆ B := by + intro j hj + obtain ⟨h1,h2⟩ := Finset.mem_Ico.mp hj + exact Finset.mem_Ico.mpr ⟨ha.trans h1,h2.trans_le ht⟩ + have hsub : I ⊆ K.image (fun k => (A.left k).val) ∪ (B\T) := by + intro j hj + by_cases hjT : j∈T + · obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp hjT + exact Finset.mem_union_left _ (Finset.mem_image.mpr + ⟨k,Finset.mem_filter.mpr ⟨Finset.mem_univ _,Finset.mem_Ico.mp hj⟩,rfl⟩) + · exact Finset.mem_union_right _ (Finset.mem_sdiff.mpr ⟨hI hj,hjT⟩) + have hc := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) + rw [Finset.card_image_of_injective K hinj,Finset.card_sdiff_of_subset hT,hBcard,hTcard] at hc + simpa only [I,Nat.card_Ico,Nat.add_sub_cancel_left,WordMatching.sourceLoss,S,K] using hc + +namespace WordMatching +variable {α : Type*} {x y : List α} {q : ℕ} + +theorem gap_right_le {w i : ℕ} (A : WordMatching x y q) + {k l : Fin q} (hk : k∈A.sourceBlock w i) (hl : l∈A.sourceBlock w i) (hkl : k ≤ l) : + (A.right l).val + (A.left k).val ≤ + (A.right k).val + (A.left l).val + A.spanLoss w i := by + let S := Finset.Icc k l + have hS : S.Nonempty := ⟨k,Finset.mem_Icc.mpr ⟨le_rfl,hkl⟩⟩ + have hconv : ConvexIndices S := by + intro a ha b hb c hac hcb + exact Finset.mem_Icc.mpr ⟨(Finset.mem_Icc.mp ha).1.trans hac,hcb.trans (Finset.mem_Icc.mp hb).2⟩ + have hsub : S ⊆ A.sourceBlock w i := by + intro j hj + exact A.sourceBlock_convex w i k hk l hl j (Finset.mem_Icc.mp hj).1 (Finset.mem_Icc.mp hj).2 + have he : A.rightSpan S=Finset.Icc (A.right k) (A.right l) := by + ext j + simp only [rightSpan,Finset.mem_filter,Finset.mem_univ,true_and,S,Finset.mem_Icc] + constructor + · rintro ⟨a,ha,b,hb,haj,hjb⟩ + exact ⟨(A.right.monotone ha.1).trans haj,hjb.trans (A.right.monotone hb.2)⟩ + · intro hj + exact ⟨k,⟨le_rfl,hkl⟩,l,⟨hkl,le_rfl⟩,hj.1,hj.2⟩ + have hv := A.right_span_holes_le_spanLoss hconv hsub + rw [he,Fin.card_Icc,Fin.card_Icc] at hv + have hleft := A.symm.card_le_rightSpan S + have heleft : A.symm.rightSpan S=Finset.Icc (A.left k) (A.left l) := by + ext j + simp only [rightSpan, Finset.mem_filter, Finset.mem_univ, true_and, S, Finset.mem_Icc] + change (∃ a, (k ≤ a ∧ a ≤ l) ∧ ∃ b, (k ≤ b ∧ b ≤ l) ∧ A.left a ≤ j ∧ j ≤ A.left b) ↔ _ + constructor + · rintro ⟨a,ha,b,hb,haj,hjb⟩ + exact ⟨(A.left.monotone ha.1).trans haj,hjb.trans (A.left.monotone hb.2)⟩ + · intro hj + exact ⟨k,⟨le_rfl,hkl⟩,l,⟨hkl,le_rfl⟩,hj.1,hj.2⟩ + rw [heleft,Fin.card_Icc,Fin.card_Icc] at hleft + have h1 := A.left.monotone hkl + have h2 := A.right.monotone hkl + omega + +end WordMatching + +theorem segment_encode_block {α : Type*} {w : ℕ} (c : α → Fin w → Bool) + (x : List α) (i : Fin x.length) (s n : ℕ) (hs : s+n ≤ w) : + segment (encode c x) (i.val*w+s) n = interval c (x.get i) s n := by + have ha : i.val*w+s+n ≤ (encode c x).length := by rw [length_encode]; nlinarith [i.isLt] + apply List.ext_getElem + · rw [length_segment ha] + simp only [interval,List.length_take,List.length_drop,List.length_ofFn] + omega + · intro j hj hk + have hjn : j < n := by simpa only [length_segment ha] using hj + have hjw : s+j < w := by omega + have hh := get_encode_block c x i ⟨s+j,hjw⟩ + simpa only [segment,interval,List.getElem_take,List.getElem_drop,List.getElem_ofFn, + List.get_eq_getElem,Nat.add_assoc] using hh + +namespace WordMatching +variable {α : Type*} {x y : List α} {w q : ℕ} {c : α → Fin w → Bool} + +theorem offset_interior_labels (hw : 0 < w) {δ : ℝ} (hδ : δ ≤ 1) + (hc : OffsetLocal δ c) (A : WordMatching (encode c x) (encode c y) q) + (k : Fin q) (i : Fin x.length) (j : Fin y.length) + (hi : (A.left k).val/w=i.val) (hj : (A.right k).val/w=j.val) + (hp : w/8 ≤ (A.left k).val%w) (hp' : (A.left k).val%w+w/8 ≤ w) + (hloss : (A.sourceLoss w i+A.spanLoss w i : ℕ) < δ*(w/8 : ℕ)) : + x.get i=y.get j := by + classical + let u := w/8 + let p := (A.left k).val%w + let r := (A.right k).val%w + let U := A.sourceLoss w i + let V := A.spanLoss w i + have hloss' : ((U+V : ℕ) : ℝ) < δ*u := hloss + have hUV : U+V < u := by + have hnon : (0 : ℝ) ≤ u := by positivity + have hh : (U+V : ℝ) < u := by push_cast at hloss'; nlinarith + exact_mod_cast hh + have hV : V < u := by omega + have hup : u ≤ p := hp + have hpu : p+u ≤ w := hp' + have hpl : p < w := Nat.mod_lt _ hw + have hrl : r < w := Nat.mod_lt _ hw + have hleft : (A.left k).val=i.val*w+p := by + have hh := Nat.mod_add_div (A.left k).val w + rw [hi] at hh + dsimp [p] + nlinarith + have hright : (A.right k).val=j.val*w+r := by + have hh := Nat.mod_add_div (A.right k).val w + rw [hj] at hh + dsimp [r] + nlinarith + have hk : k∈A.sourceBlock w i := (A.mem_sourceBlock w i k).mpr hi + have bound {a b t : ℕ} (hat : a+t ≤ w) (hbt : b+t ≤ w) : + (Finset.univ.filter (fun z : Fin q => + i.val*w+a ≤ (A.left z).val ∧ (A.left z).val < i.val*w+a+t ∧ + j.val*w+b ≤ (A.right z).val ∧ (A.right z).val < j.val*w+b+t)).card ≤ + lcs (interval c (x.get i) a t) (interval c (y.get j) b t) := by + have hai : i.val*w+a+t ≤ (encode c x).length := by rw [length_encode]; nlinarith [i.isLt] + have hbj : j.val*w+b+t ≤ (encode c y).length := by rw [length_encode]; nlinarith [j.isLt] + simpa only [segment_encode_block c x i a t hat,segment_encode_block c y j b t hbt] using + matching_segments_card A (i.val*w+a) (j.val*w+b) t hai hbj + by_contra hne + by_cases hf : r+u ≤ w + · let a := i.val*w+p + let b := j.val*w+r + let t := u-V + let K := Finset.univ.filter (fun z : Fin q => a ≤ (A.left z).val ∧ (A.left z).val < a+t) + have ha : i.val*w ≤ a := by dsimp [a]; omega + have hat : a+t ≤ (i.val+1)*w := by dsimp [a,t]; nlinarith [Nat.sub_le u V] + have hcard : t ≤ K.card+U := A.interval_card_loss hw ha hat + have hsub : K ⊆ Finset.univ.filter (fun z : Fin q => + i.val*w+p ≤ (A.left z).val ∧ (A.left z).val < i.val*w+p+u ∧ + j.val*w+r ≤ (A.right z).val ∧ (A.right z).val < j.val*w+r+u) := by + intro z hz + have hpos : a ≤ (A.left z).val ∧ (A.left z).val < a+t := (Finset.mem_filter.mp hz).2 + have hzi : (A.left z).val/w=i.val := + Nat.div_eq_of_lt_le (ha.trans hpos.1) (hpos.2.trans_le hat) + have hkz : k ≤ z := A.left.le_iff_le.mp (by change (A.left k).val ≤ (A.left z).val; simpa only [hleft] using hpos.1) + have hg := A.gap_right_le hk ((A.mem_sourceBlock w i z).mpr hzi) hkz + have hmono := A.right.monotone hkz + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _,?_,?_,?_,?_⟩ <;> dsimp [a,b,t] at * <;> omega + have hb := (Finset.card_le_card hsub).trans (bound hpu hf) + have hlocal := hc (x.get i) (y.get j) hne p r hpu hf + have hs : (u : ℝ) ≤ (lcs (interval c (x.get i) p u) (interval c (y.get j) r u):ℝ)+U+V := by + have hc' : u ≤ lcs (interval c (x.get i) p u) (interval c (y.get j) r u)+U+V := by dsimp [t] at hcard; omega + exact_mod_cast hc' + change _ ≤ (1-δ)*(u : ℝ) at hlocal + push_cast at hloss' + nlinarith only [hs,hlocal,hloss'] + · let a := i.val*w+(p+1-(u-V)) + let t := u-V + have hrfit : u ≤ r+1 := by dsimp [u] at *; omega + have hpfit : u ≤ p+1 := by omega + have hps : p+1-u+u ≤ w := by omega + have hrs : r+1-u+u ≤ w := by omega + let K := Finset.univ.filter (fun z : Fin q => a ≤ (A.left z).val ∧ (A.left z).val < a+t) + have ha : i.val*w ≤ a := by dsimp [a]; omega + have hat : a+t ≤ (i.val+1)*w := by + dsimp [a,t] + rw [Nat.add_mul, one_mul] + omega + have hcard : t ≤ K.card+U := A.interval_card_loss hw ha hat + have hsub : K ⊆ Finset.univ.filter (fun z : Fin q => + i.val*w+(p+1-u) ≤ (A.left z).val ∧ (A.left z).val < i.val*w+(p+1-u)+u ∧ + j.val*w+(r+1-u) ≤ (A.right z).val ∧ (A.right z).val < j.val*w+(r+1-u)+u) := by + intro z hz + have hpos : a ≤ (A.left z).val ∧ (A.left z).val < a+t := (Finset.mem_filter.mp hz).2 + have hzi : (A.left z).val/w=i.val := + Nat.div_eq_of_lt_le (ha.trans hpos.1) (hpos.2.trans_le hat) + have hzk : z ≤ k := A.left.le_iff_le.mp (by change (A.left z).val ≤ (A.left k).val; dsimp [a,t] at hpos; omega) + have hg := A.gap_right_le ((A.mem_sourceBlock w i z).mpr hzi) hk hzk + have hmono := A.right.monotone hzk + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _,?_,?_,?_,?_⟩ <;> dsimp [a,t] at * <;> omega + have hb := (Finset.card_le_card hsub).trans (bound hps hrs) + have hlocal := hc (x.get i) (y.get j) hne (p+1-u) (r+1-u) hps hrs + have hs : (u : ℝ) ≤ (lcs (interval c (x.get i) (p+1-u) u) (interval c (y.get j) (r+1-u) u):ℝ)+U+V := by + have hc' : u ≤ lcs (interval c (x.get i) (p+1-u) u) (interval c (y.get j) (r+1-u) u)+U+V := by dsimp [t] at hcard; omega + exact_mod_cast hc' + change _ ≤ (1-δ)*(u : ℝ) at hlocal + push_cast at hloss' + nlinarith only [hs,hlocal,hloss'] + +end WordMatching + +theorem monotone_assignment_deficit {α : Type*} {x y : List α} + (S : Finset ℕ) (hS : S ⊆ Finset.range x.length) (f : ℕ → ℕ) + (hf : ∀ i ∈ S, f i < y.length) + (hm : ∀ i ∈ S, ∀ j ∈ S, i ≤ j → f i ≤ f j) + (hl : ∀ i (hi : i ∈ S), x[i]'(Finset.mem_range.mp (hS hi)) = y[f i]'(hf i hi)) : + deficit x y ≤ 2 * (x.length - S.card) + + (S.filter (fun i => i+1 ∈ S ∧ f i = f (i+1))).card := by + classical + let D := S.filter (fun i => ∃ j ∈ S, j < i ∧ f j = f i) + let T := S \ D + let B := Finset.range x.length \ S + let J := S.filter (fun i => i+1 ∈ S ∧ f i = f (i+1)) + have hD : D ⊆ S := Finset.filter_subset _ _ + have hT : T ⊆ S := Finset.sdiff_subset + have hdpos : ∀ i ∈ D, 0 < i := by + intro i hi + obtain ⟨j,_,hj,_⟩ := (Finset.mem_filter.mp hi).2 + omega + have hpred : D.image (fun i => i-1) ⊆ B ∪ J := by + intro v hv + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hv + have hip := hdpos i hi + have hil := Finset.mem_range.mp (hS (hD hi)) + by_cases hh : i-1 ∈ S + · apply Finset.mem_union_right + apply Finset.mem_filter.mpr + refine ⟨hh,?_,?_⟩ + · simpa only [Nat.sub_add_cancel (by omega : 1 ≤ i)] using hD hi + · obtain ⟨j,hj,hji,hfj⟩ := (Finset.mem_filter.mp hi).2 + have h1 := hm j hj (i-1) hh (by omega) + have h2 := hm (i-1) hh i (hD hi) (by omega) + simpa only [Nat.sub_add_cancel (by omega : 1 ≤ i)] using + (show f (i-1) = f i by omega) + · exact Finset.mem_union_left _ (Finset.mem_sdiff.mpr + ⟨Finset.mem_range.mpr (by omega),hh⟩) + have hdinj : Set.InjOn (fun i : ℕ => i-1) D := by + intro i hi j hj hij + have := hdpos i hi + have := hdpos j hj + dsimp only at hij + omega + have hdc : D.card ≤ B.card + J.card := by + have hh := (Finset.card_le_card hpred).trans (Finset.card_union_le B J) + rwa [Finset.card_image_of_injOn hdinj] at hh + have htmat : T.card ≤ lcs x y := by + let e := T.orderEmbOfFin rfl + have he (k : Fin T.card) : e k ∈ T := T.orderEmbOfFin_mem rfl k + let g : Fin T.card → Fin x.length := fun k => + ⟨e k,Finset.mem_range.mp (hS (hT (he k)))⟩ + let h : Fin T.card → Fin y.length := fun k => ⟨f (e k),hf _ (hT (he k))⟩ + have hg : StrictMono g := fun i j hij => e.strictMono hij + have hh : StrictMono h := by + intro i j hij + have heij := e.strictMono hij + have hm' := hm (e i) (hT (he i)) (e j) (hT (he j)) heij.le + have hneq : f (e i) ≠ f (e j) := by + intro heq + have hn := (Finset.mem_sdiff.mp (he j)).2 + exact hn (Finset.mem_filter.mpr ⟨hT (he j),e i,hT (he i),heij,heq⟩) + change f (e i) < f (e j) + exact lt_of_le_of_ne hm' hneq + let A : WordMatching x y T.card := + { left := OrderEmbedding.ofStrictMono g hg + right := OrderEmbedding.ofStrictMono h hh + letters := fun k => hl (e k) (hT (he k)) } + exact A.le_lcs + have htc : T.card = S.card - D.card := Finset.card_sdiff_of_subset hD + have hbc : B.card = x.length - S.card := by rw [Finset.card_sdiff_of_subset hS,Finset.card_range] + dsimp only [deficit] + dsimp only [J] at hdc + omega + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/FiniteCircle/Windows.lean b/lean/OAI/Combinatorics/FiniteCircle/Windows.lean new file mode 100644 index 0000000000000000000000000000000000000000..01210258c65224451a4e2b163c609d356dc55293 --- /dev/null +++ b/lean/OAI/Combinatorics/FiniteCircle/Windows.lean @@ -0,0 +1,183 @@ +import OAI.Combinatorics.FiniteCircle.Lower + +namespace OAI + +namespace FiniteCircle + +open scoped BigOperators List +open scoped ComplexConjugate +open RCLike Module +open Classical + +theorem segment_segment {α : Type*} (x : List α) (start size r len : ℕ) + (h : r + len ≤ size) : segment (segment x start size) r len = segment x (start + r) len := by + unfold segment + rw [List.drop_take, List.take_take, List.drop_drop, Nat.min_eq_left (by omega)] + +theorem segment_append_left {α : Type*} (u v : List α) {start size : ℕ} + (h : start + size ≤ u.length) : segment (u ++ v) start size = segment u start size := by + unfold segment + rw [List.drop_append_of_le_length (by omega), List.take_append_of_le_length (by simp; omega)] + +theorem segment_append_right {α : Type*} (u v : List α) {start size : ℕ} + (h : u.length ≤ start) : segment (u ++ v) start size = segment v (start - u.length) size := by + unfold segment + rw [List.drop_append, List.drop_eq_nil_of_le h, List.nil_append] + +theorem slide_segment_before {α : Type*} (u v t : List α) (a b : α) {start size : ℕ} + (h : start + size ≤ u.length) : + segment (u ++ a :: (v ++ t)) start size = segment (u ++ v ++ b :: t) start size := by + rw [segment_append_left _ _ h, List.append_assoc, segment_append_left _ _ h] + +theorem slide_segment_after {α : Type*} (u v t : List α) (a b : α) {start size : ℕ} + (h : u.length + v.length + 1 ≤ start) : + segment (u ++ a :: (v ++ t)) start size = segment (u ++ v ++ b :: t) start size := by + have h₁ : (u ++ a :: v).length ≤ start := by simp; omega + have h₂ : (u ++ v ++ [b]).length ≤ start := by simp; omega + rw [show u ++ a :: (v ++ t) = (u ++ a :: v) ++ t by simp, + show u ++ v ++ b :: t = (u ++ v ++ [b]) ++ t by simp, + segment_append_right _ _ h₁, segment_append_right _ _ h₂] + congr 2 + simp + +theorem slide_segment_shift {α : Type*} (u v t : List α) (a b : α) {start size : ℕ} + (h₁ : u.length + 1 ≤ start) (h₂ : start + size ≤ u.length + v.length + 1) : + segment (u ++ a :: (v ++ t)) start size = + segment (u ++ v ++ b :: t) (start - 1) size := by + rw [show u ++ a :: (v ++ t) = (u ++ [a]) ++ (v ++ t) by simp, + segment_append_right (u ++ [a]) _ (by simp; omega), + show u ++ v ++ b :: t = u ++ (v ++ b :: t) by simp, + segment_append_right u _ (by omega), + segment_append_left v t (by simp; omega), + segment_append_left v (b :: t) (by omega)] + congr 1 + simp only [List.length_append, List.length_singleton] + omega + +def windows {α : Type*} (x : List α) (start m s : ℕ) : List (List α) := + List.ofFn (fun r : Fin s => segment x (start + r) (m - s + 1)) + +@[simp] theorem length_windows {α : Type*} (x : List α) (start m s : ℕ) : + (windows x start m s).length = s := List.length_ofFn + +theorem windows_before {α : Type*} (u v t : List α) (a b : α) + {start m s : ℕ} (_hs : 1 ≤ s) (hsm : s ≤ m) (hbef : start + m ≤ u.length) : + windows (u ++ a :: (v ++ t)) start m s = windows (u ++ v ++ b :: t) start m s := by + unfold windows + congr 1 + funext r + exact slide_segment_before _ _ _ _ _ (by have := r.isLt; omega) + +theorem windows_after {α : Type*} (u v t : List α) (a b : α) + {start m s : ℕ} (haft : u.length + v.length + 1 ≤ start) : + windows (u ++ a :: (v ++ t)) start m s = windows (u ++ v ++ b :: t) start m s := by + unfold windows + congr 1 + funext r + exact slide_segment_after _ _ _ _ _ (by omega) + +theorem windows_shift {α : Type*} (u v t : List α) (a b : α) + {start m s : ℕ} (hs : 1 ≤ s) (hsm : s ≤ m) + (h₁ : u.length + 1 ≤ start) (h₂ : start + m ≤ u.length + v.length) : + ∃ zs : List (List α), zs.length = s - 1 ∧ + zs <+ windows (u ++ a :: (v ++ t)) start m s ∧ + zs <+ windows (u ++ v ++ b :: t) start m s := by + obtain ⟨r, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : s ≠ 0) + let zs := List.ofFn (fun i : Fin r => segment (u ++ a :: (v ++ t)) (start + i.val + 1) (m - (r+1) + 1)) + refine ⟨zs, by simp [zs], ?_, ?_⟩ + · unfold windows + rw [List.ofFn_succ] + have he : zs = List.ofFn (fun i : Fin r => segment (u ++ a :: (v ++ t)) + (start + (i.succ : Fin (r+1))) (m - (r+1) + 1)) := by simp [zs, Nat.add_assoc] + rw [he] + exact List.Sublist.cons _ (List.Sublist.refl _) + · unfold windows + rw [List.ofFn_succ'] + have he : zs = List.ofFn (fun i : Fin r => segment (u ++ v ++ b :: t) + (start + (i.castSucc : Fin (r+1))) (m - (r+1) + 1)) := by + unfold zs + congr 1 + funext i + have hh := slide_segment_shift u v t a b (start := start + i.val + 1) + (size := m - (r+1) + 1) (by omega) (by have := i.isLt; omega) + simpa using hh + rw [he] + rw [List.concat_eq_append] + exact List.sublist_append_left _ _ + +theorem block_location (p q m j : ℕ) (hm : 0 < m) (_hpq : p ≤ q) + (hp : j ≠ p / m) (hq : j ≠ q / m) : + (j * m + m ≤ p) ∨ (p + 1 ≤ j * m ∧ j * m + m ≤ q) ∨ (q + 1 ≤ j * m) := by + by_cases hjp : j < p / m + · left + have h := (Nat.le_div_iff_mul_le hm).mp (by omega : j+1 ≤ p/m) + nlinarith + · have hstart : p + 1 ≤ j*m := by + have h := (Nat.div_lt_iff_lt_mul hm).mp (by omega : p/m < j) + omega + by_cases hjq : j < q / m + · right; left + refine ⟨hstart, ?_⟩ + have h := (Nat.le_div_iff_mul_le hm).mp (by omega : j+1 ≤ q/m) + nlinarith + · right; right + have h := (Nat.div_lt_iff_lt_mul hm).mp (by omega : q/m < j) + omega + +theorem windows_nonexceptional {α : Type*} (u v t : List α) (a b : α) + {m s j : ℕ} (hs : 1 ≤ s) (hsm : s ≤ m) + (hp : j ≠ u.length / m) (hq : j ≠ (u.length + v.length) / m) : + ∃ zs : List (List α), s - 1 ≤ zs.length ∧ + zs <+ windows (u ++ a :: (v ++ t)) (j*m) m s ∧ + zs <+ windows (u ++ v ++ b :: t) (j*m) m s := by + rcases block_location u.length (u.length+v.length) m j (by omega) (by omega) hp hq with h | h | h + · have he := windows_before u v t a b hs hsm h + exact ⟨_, by simp, .refl _, he ▸ List.Sublist.refl _⟩ + · obtain ⟨zs, hz, hx, hy⟩ := windows_shift u v t a b hs hsm h.1 h.2 + exact ⟨zs, hz.ge, hx, hy⟩ + · have he := windows_after u v t a b (m := m) (s := s) h + exact ⟨_, by simp, .refl _, he ▸ List.Sublist.refl _⟩ + +theorem lcs_append_ge {α : Type*} (x y u v : List α) : + lcs x y + lcs u v ≤ lcs (x ++ u) (y ++ v) := by + obtain ⟨z, hzx, hzy, hz⟩ := lcs_exists x y + obtain ⟨t, htu, htv, ht⟩ := lcs_exists u v + simpa [List.length_append, hz, ht] using le_lcs (hzx.append htu) (hzy.append htv) + +theorem deficit_append_le {α : Type*} (x y u v : List α) : + deficit (x ++ u) (y ++ v) ≤ deficit x y + deficit u v := by + have h := lcs_append_ge x y u v + have hx := lcs_le_length_left x y + have hu := lcs_le_length_left u v + simp only [deficit, List.length_append] + omega + +theorem deficit_le_sum_blocks {α : Type*} {x y : List α} {b m : ℕ} + (hx : x.length = b*m) (hy : y.length = b*m) : + deficit x y ≤ ∑ j : Fin b, deficit (segment x (j*m) m) (segment y (j*m) m) := by + induction b generalizing x y with + | zero => + have hx0 : x = [] := List.length_eq_zero_iff.mp (by simpa using hx) + have hy0 : y = [] := List.length_eq_zero_iff.mp (by simpa using hy) + simp [hx0, hy0, deficit] + | succ b ih => + have hxt : (x.drop m).length = b*m := by simp only [List.length_drop]; rw [hx, Nat.succ_mul]; omega + have hyt : (y.drop m).length = b*m := by simp only [List.length_drop]; rw [hy, Nat.succ_mul]; omega + have hd := deficit_append_le (x.take m) (y.take m) (x.drop m) (y.drop m) + simp only [List.take_append_drop] at hd + refine hd.trans ?_ + rw [Fin.sum_univ_succ] + simp only [Fin.val_zero, Nat.zero_mul, segment, List.drop_zero] + apply Nat.add_le_add_left + convert ih hxt hyt using 1 + apply Finset.sum_congr rfl + intro j _ + simp [segment, List.drop_drop, Fin.val_succ, Nat.add_mul, Nat.add_comm] + +open scoped BigOperators List + +open scoped BigOperators + +end FiniteCircle + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/BinomialMoments.lean b/lean/OAI/Combinatorics/GotsmanLinial/BinomialMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..d473ed04c121a977cc58c54673579a6d20ae5cbd --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/BinomialMoments.lean @@ -0,0 +1,181 @@ +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Data.Fin.Rev +import Mathlib.Data.Nat.Choose.Sum +import Mathlib.Analysis.Real.Sqrt +import Mathlib.Tactic.FieldSimp + +namespace OAI + +/-! +Exact finite moments of the symmetric binomial weights. These identities provide +the grading multiplicities and the variance used in the finite coupling estimate. +No probabilistic assumptions or measures enter the statements. +-/ + +namespace LeanBlast.GotsmanLinial + +open scoped BigOperators + +/-- The normalizing denominator is positive, also when `n = 0`. -/ +theorem binomialDenominator_pos (n : ℕ) : 0 < (2 : ℝ) ^ n := + pow_pos (by norm_num) n + +theorem binomialDenominator_ne_zero (n : ℕ) : (2 : ℝ) ^ n ≠ 0 := + ne_of_gt (binomialDenominator_pos n) + +/-- The real sum of one row of Pascal's triangle. -/ +theorem sum_choose_range (n : ℕ) : + (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ)) = (2 : ℝ) ^ n := by + exact_mod_cast Nat.sum_range_choose n + +/-- Pascal recursion for an arbitrary real function of the binomial index. -/ +theorem sum_choose_succ (n : ℕ) (f : ℕ → ℝ) : + (∑ k ∈ Finset.range (n + 2), ((n + 1).choose k : ℝ) * f k) = + (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * f k) + + ∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * f (k + 1) := + Finset.sum_choose_succ_mul (fun k _ => f k) n + +/-- The first raw binomial moment, with a formula valid at `n = 0`. -/ +theorem sum_choose_mul_index_range (n : ℕ) : + (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * (k : ℝ)) = + (n : ℝ) * (2 : ℝ) ^ n / 2 := by + induction n with + | zero => simp + | succ n ih => + rw [sum_choose_succ] + simp_rw [Nat.cast_add, Nat.cast_one, mul_add, mul_one] + rw [Finset.sum_add_distrib, ih, sum_choose_range] + simp only [pow_succ] + ring + +/-- The second raw binomial moment, with a formula valid at `n = 0`. -/ +theorem sum_choose_mul_index_sq_range (n : ℕ) : + (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * (k : ℝ) ^ 2) = + (n : ℝ) * ((n : ℝ) + 1) * (2 : ℝ) ^ n / 4 := by + induction n with + | zero => simp + | succ n ih => + rw [sum_choose_succ] + have hshift : + (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * ((k + 1 : ℕ) : ℝ) ^ 2) = + (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * (k : ℝ) ^ 2) + + 2 * (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * (k : ℝ)) + + ∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) := by + rw [Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro k _ + push_cast + ring + rw [hshift, ih, sum_choose_mul_index_range, sum_choose_range] + simp only [pow_succ, Nat.cast_add, Nat.cast_one] + ring + +/-- Exact centered second moment before dividing by `2^n`. -/ +theorem sum_choose_centered_sq_range (n : ℕ) : + (∑ k ∈ Finset.range (n + 1), + (n.choose k : ℝ) * ((k : ℝ) - (n : ℝ) / 2) ^ 2) = + (n : ℝ) * (2 : ℝ) ^ n / 4 := by + calc + _ = (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * (k : ℝ) ^ 2) - + (n : ℝ) * (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ) * (k : ℝ)) + + ((n : ℝ) ^ 2 / 4) * (∑ k ∈ Finset.range (n + 1), (n.choose k : ℝ)) := by + rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_sub_distrib, + ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro k _ + ring + _ = _ := by + rw [sum_choose_mul_index_sq_range, sum_choose_mul_index_range, sum_choose_range] + ring + +/-- The same total mass on the grading-index type. -/ +theorem sum_choose (n : ℕ) : + (∑ k : Fin (n + 1), (n.choose k.val : ℝ)) = (2 : ℝ) ^ n := by + rw [Fin.sum_univ_eq_sum_range (fun k => (n.choose k : ℝ))] + exact sum_choose_range n + +theorem sum_choose_mul_index (n : ℕ) : + (∑ k : Fin (n + 1), (n.choose k.val : ℝ) * (k.val : ℝ)) = + (n : ℝ) * (2 : ℝ) ^ n / 2 := by + rw [Fin.sum_univ_eq_sum_range (fun k => (n.choose k : ℝ) * (k : ℝ))] + exact sum_choose_mul_index_range n + +theorem sum_choose_mul_index_sq (n : ℕ) : + (∑ k : Fin (n + 1), (n.choose k.val : ℝ) * (k.val : ℝ) ^ 2) = + (n : ℝ) * ((n : ℝ) + 1) * (2 : ℝ) ^ n / 4 := by + rw [Fin.sum_univ_eq_sum_range (fun k => (n.choose k : ℝ) * (k : ℝ) ^ 2)] + exact sum_choose_mul_index_sq_range n + +theorem sum_choose_centered_sq (n : ℕ) : + (∑ k : Fin (n + 1), + (n.choose k.val : ℝ) * ((k.val : ℝ) - (n : ℝ) / 2) ^ 2) = + (n : ℝ) * (2 : ℝ) ^ n / 4 := by + rw [Fin.sum_univ_eq_sum_range + (fun k => (n.choose k : ℝ) * ((k : ℝ) - (n : ℝ) / 2) ^ 2)] + exact sum_choose_centered_sq_range n + +/-- The symmetric binomial probability weights, presented as a finite real function. -/ +noncomputable def binomialWeight (n : ℕ) (k : Fin (n + 1)) : ℝ := + (n.choose k.val : ℝ) / (2 : ℝ) ^ n + +theorem binomialWeight_nonneg (n : ℕ) (k : Fin (n + 1)) : + 0 ≤ binomialWeight n k := + div_nonneg (Nat.cast_nonneg _) (le_of_lt (binomialDenominator_pos n)) + +theorem sum_binomialWeight (n : ℕ) : (∑ k : Fin (n + 1), binomialWeight n k) = 1 := by + unfold binomialWeight + rw [← Finset.sum_div, sum_choose, div_self (binomialDenominator_ne_zero n)] + +theorem binomialWeight_mean (n : ℕ) : + (∑ k : Fin (n + 1), binomialWeight n k * (k.val : ℝ)) = (n : ℝ) / 2 := by + unfold binomialWeight + simp_rw [div_mul_eq_mul_div] + rw [← Finset.sum_div, sum_choose_mul_index] + field_simp [binomialDenominator_ne_zero n] + +theorem binomialWeight_variance (n : ℕ) : + (∑ k : Fin (n + 1), binomialWeight n k * ((k.val : ℝ) - (n : ℝ) / 2) ^ 2) = + (n : ℝ) / 4 := by + unfold binomialWeight + simp_rw [div_mul_eq_mul_div] + rw [← Finset.sum_div, sum_choose_centered_sq] + field_simp [binomialDenominator_ne_zero n] + +/-- The binomial coefficients are invariant under reflection about `n/2`. -/ +theorem choose_reflect (n : ℕ) (k : Fin (n + 1)) : + n.choose (n - k.val) = n.choose k.val := + Nat.choose_symm (Nat.le_of_lt_succ k.isLt) + +theorem choose_rev (n : ℕ) (k : Fin (n + 1)) : + n.choose k.rev.val = n.choose k.val := by + simpa only [Fin.val_rev, Nat.add_sub_add_right] using choose_reflect n k + +theorem binomialWeight_rev (n : ℕ) (k : Fin (n + 1)) : + binomialWeight n k.rev = binomialWeight n k := by + simp only [binomialWeight, choose_rev] + +theorem index_rev_real (n : ℕ) (k : Fin (n + 1)) : + (k.rev.val : ℝ) = (n : ℝ) - (k.val : ℝ) := by + rw [Fin.val_rev, Nat.add_sub_add_right, Nat.cast_sub (Nat.le_of_lt_succ k.isLt)] + +/-- Reflecting a binomial index preserves every real finite expectation. -/ +theorem binomialWeight_reflect (n : ℕ) (φ : ℝ → ℝ) : + (∑ k : Fin (n + 1), binomialWeight n k * φ ((n : ℝ) - (k.val : ℝ))) = + ∑ k : Fin (n + 1), binomialWeight n k * φ (k.val : ℝ) := by + have h := Equiv.sum_comp (Fin.revPerm (n := n + 1)) + (fun k : Fin (n + 1) => binomialWeight n k * φ (k.val : ℝ)) + change (∑ k : Fin (n + 1), binomialWeight n k.rev * φ (k.rev.val : ℝ)) = _ at h + simpa only [binomialWeight_rev, index_rev_real] using h + +/-- Standard deviation corresponding to the preceding finite variance identity. -/ +theorem binomialSigma_sq (n : ℕ) : (Real.sqrt (n : ℝ) / 2) ^ 2 = (n : ℝ) / 4 := by + rw [div_pow, Real.sq_sqrt (Nat.cast_nonneg n)] + norm_num + +theorem binomialSigma_nonneg (n : ℕ) : 0 ≤ Real.sqrt (n : ℝ) / 2 := + div_nonneg (Real.sqrt_nonneg _) (by norm_num) + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/BlockCoupling.lean b/lean/OAI/Combinatorics/GotsmanLinial/BlockCoupling.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d166ccfadbb9af94859b50ecafc5f9847ed01be --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/BlockCoupling.lean @@ -0,0 +1,236 @@ +import OAI.Combinatorics.GotsmanLinial.BinomialMoments +import OAI.Combinatorics.GotsmanLinial.FiniteCoupling +import OAI.Combinatorics.GotsmanLinial.ProjectionBlocks +import Mathlib.Data.Fintype.BigOperators + +namespace OAI + +/-! +# The finite block coupling + +Normalize a nonnegative matrix of block masses, identify its two binomial +marginals, and reflect its first index. The low-degree block vanishing gives +the one-sided displacement bound required by the finite coupling lemma. +-/ + +open scoped BigOperators + +namespace LeanBlast.GotsmanLinial + +/-- Normalize finite two-index masses by their total mass. -/ +noncomputable def normalizedPairWeight {α β : Type*} + (B : α → β → ℝ) (Z : ℝ) (t : α × β) : ℝ := + B t.1 t.2 / Z + +theorem normalizedPairWeight_nonneg {α β : Type*} + (B : α → β → ℝ) (Z : ℝ) (hB : ∀ r s, 0 ≤ B r s) (hZ : 0 ≤ Z) + (t : α × β) : 0 ≤ normalizedPairWeight B Z t := + div_nonneg (hB t.1 t.2) hZ + +theorem normalizedPairWeight_row {α β : Type*} [Fintype β] + (B : α → β → ℝ) (Z : ℝ) (r : α) : + (∑ s : β, normalizedPairWeight B Z (r, s)) = (∑ s : β, B r s) / Z := by + simp only [normalizedPairWeight, ← Finset.sum_div] + +theorem normalizedPairWeight_column {α β : Type*} [Fintype α] + (B : α → β → ℝ) (Z : ℝ) (s : β) : + (∑ r : α, normalizedPairWeight B Z (r, s)) = (∑ r : α, B r s) / Z := by + simp only [normalizedPairWeight, ← Finset.sum_div] + +/-- First-coordinate expectations are computed from the row sums. -/ +theorem normalizedPairWeight_expect_fst {α β : Type*} [Fintype α] [Fintype β] + (B : α → β → ℝ) (Z : ℝ) (φ : α → ℝ) : + (∑ t : α × β, normalizedPairWeight B Z t * φ t.1) = + ∑ r : α, ((∑ s : β, B r s) / Z) * φ r := by + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro r _ + simp only [normalizedPairWeight] + rw [← Finset.sum_mul, ← Finset.sum_div] + +/-- Second-coordinate expectations are computed from the column sums. -/ +theorem normalizedPairWeight_expect_snd {α β : Type*} [Fintype α] [Fintype β] + (B : α → β → ℝ) (Z : ℝ) (φ : β → ℝ) : + (∑ t : α × β, normalizedPairWeight B Z t * φ t.2) = + ∑ s : β, ((∑ r : α, B r s) / Z) * φ s := by + rw [Fintype.sum_prod_type_right] + apply Finset.sum_congr rfl + intro s _ + simp only [normalizedPairWeight] + rw [← Finset.sum_mul, ← Finset.sum_div] + +/-- Finite masses with binomial row and column sums, supported above the +anti-diagonal `r+s=n-d`, have the required centered quadratic bound. -/ +theorem binomial_block_coupling_bound + (n d : ℕ) (B : Fin (n + 1) → Fin (n + 1) → ℝ) + (hB : ∀ r s, 0 ≤ B r s) + (hrow : ∀ r, (∑ s : Fin (n + 1), B r s) = (n.choose r.val : ℝ)) + (hcol : ∀ s, (∑ r : Fin (n + 1), B r s) = (n.choose s.val : ℝ)) + (hvanish : ∀ r s, r.val + s.val < n - d → B r s = 0) : + (∑ r : Fin (n + 1), ∑ s : Fin (n + 1), + ((s.val : ℝ) + (r.val : ℝ) - (n : ℝ)) ^ 2 * B r s) ≤ + 4 * (d : ℝ) * Real.sqrt (n : ℝ) * (2 : ℝ) ^ n := by + let w : Fin (n + 1) × Fin (n + 1) → ℝ := + normalizedPairWeight B ((2 : ℝ) ^ n) + let U : Fin (n + 1) × Fin (n + 1) → ℝ := fun t => (t.2.val : ℝ) + let V : Fin (n + 1) × Fin (n + 1) → ℝ := + fun t => (n : ℝ) - (t.1.val : ℝ) + have hU (φ : ℝ → ℝ) : + (∑ t : Fin (n + 1) × Fin (n + 1), w t * φ (U t)) = + ∑ s : Fin (n + 1), binomialWeight n s * φ (s.val : ℝ) := by + simpa only [w, U, hcol, binomialWeight] using + normalizedPairWeight_expect_snd B ((2 : ℝ) ^ n) + (fun s => φ (s.val : ℝ)) + have hV (φ : ℝ → ℝ) : + (∑ t : Fin (n + 1) × Fin (n + 1), w t * φ (V t)) = + ∑ r : Fin (n + 1), + binomialWeight n r * φ ((n : ℝ) - (r.val : ℝ)) := by + simpa only [w, V, hrow, binomialWeight] using + normalizedPairWeight_expect_fst B ((2 : ℝ) ^ n) + (fun r => φ ((n : ℝ) - (r.val : ℝ))) + have hw : ∀ t, 0 ≤ w t := + normalizedPairWeight_nonneg B _ hB (binomialDenominator_pos n).le + have hprob : (∑ t, w t) = 1 := by + have h := hU (fun _ => 1) + simpa only [mul_one, sum_binomialWeight] using h + have hsame : ∀ φ : ℝ → ℝ, + (∑ t, w t * φ (U t)) = ∑ t, w t * φ (V t) := by + intro φ + rw [hU, hV, binomialWeight_reflect] + have hvariance : + (∑ t, w t * (U t - (n : ℝ) / 2) ^ 2) = + (Real.sqrt (n : ℝ) / 2) ^ 2 := by + rw [hU (fun z => (z - (n : ℝ) / 2) ^ 2)] + rw [binomialWeight_variance, binomialSigma_sq] + have hstep : ∀ t, w t ≠ 0 → V t - U t ≤ (d : ℝ) := by + rintro ⟨r, s⟩ ht + have hnonzero : B r s ≠ 0 := by + intro hz + exact ht (by simp only [w, normalizedPairWeight, hz, zero_div]) + have hnat : n - d ≤ r.val + s.val := + Nat.le_of_not_gt (fun hlt => hnonzero (hvanish r s hlt)) + have hnat' : n ≤ r.val + s.val + d := by omega + have hreal : (n : ℝ) ≤ (r.val : ℝ) + (s.val : ℝ) + (d : ℝ) := by + exact_mod_cast hnat' + dsimp only [U, V] + linarith + have hbound := finite_one_sided_coupling_bound w U V + ((n : ℝ) / 2) (Real.sqrt (n : ℝ) / 2) (d : ℝ) + hw hprob hsame (binomialSigma_nonneg n) (Nat.cast_nonneg d) hvariance hstep + calc + _ = (2 : ℝ) ^ n * (∑ t, w t * (U t - V t) ^ 2) := by + rw [Fintype.sum_prod_type, Finset.mul_sum] + apply Finset.sum_congr rfl + intro r _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro s _ + dsimp only [w, U, V, normalizedPairWeight] + field_simp [binomialDenominator_ne_zero n] + ring + _ ≤ (2 : ℝ) ^ n * (8 * (d : ℝ) * (Real.sqrt (n : ℝ) / 2)) := + mul_le_mul_of_nonneg_left hbound (binomialDenominator_pos n).le + _ = 4 * (d : ℝ) * Real.sqrt (n : ℝ) * (2 : ℝ) ^ n := by ring + +/-- The actual finite probability weights supplied by the Hilbert--Schmidt +blocks of an operator in a binomial orthogonal grading. -/ +noncomputable def blockCouplingWeight {n : ℕ} {ι : Type*} [Fintype ι] + (P : Fin (n + 1) → Matrix ι ι ℂ) (H : Matrix ι ι ℂ) + (t : Fin (n + 1) × Fin (n + 1)) : ℝ := + normalizedPairWeight (fun r s => hsNormSq (P s * H * P r)) ((2 : ℝ) ^ n) t + +theorem blockCouplingWeight_nonneg {n : ℕ} {ι : Type*} [Fintype ι] + (P : Fin (n + 1) → Matrix ι ι ℂ) (H : Matrix ι ι ℂ) + (t : Fin (n + 1) × Fin (n + 1)) : 0 ≤ blockCouplingWeight P H t := + normalizedPairWeight_nonneg _ _ (fun _ _ => hsNormSq_nonneg _) + (binomialDenominator_pos n).le t + +/-- The first block index has the binomial distribution. -/ +theorem blockCouplingWeight_fst_marginal {n : ℕ} {ι : Type*} + [Fintype ι] [DecidableEq ι] + {P : Fin (n + 1) → Matrix ι ι ℂ} (hP : OrthogonalProjectionFamily P) + (H : Matrix ι ι ℂ) (hH : H.conjTranspose * H = 1) + (hmult : ∀ k, hsNormSq (P k) = (n.choose k.val : ℝ)) + (r : Fin (n + 1)) : + (∑ s : Fin (n + 1), blockCouplingWeight P H (r, s)) = binomialWeight n r := by + unfold blockCouplingWeight + rw [normalizedPairWeight_row, sum_hsNormSq_blocks_column hP H r hH, hmult] + rfl + +/-- The second block index has the same binomial distribution. -/ +theorem blockCouplingWeight_snd_marginal {n : ℕ} {ι : Type*} + [Fintype ι] [DecidableEq ι] + {P : Fin (n + 1) → Matrix ι ι ℂ} (hP : OrthogonalProjectionFamily P) + (H : Matrix ι ι ℂ) (hH : H * H.conjTranspose = 1) + (hmult : ∀ k, hsNormSq (P k) = (n.choose k.val : ℝ)) + (s : Fin (n + 1)) : + (∑ r : Fin (n + 1), blockCouplingWeight P H (r, s)) = binomialWeight n s := by + unfold blockCouplingWeight + rw [normalizedPairWeight_column, sum_hsNormSq_blocks_row hP H s hH, hmult] + rfl + +/-- Unitarity and the grading multiplicities make the block weights a +probability distribution without any additional normalization assumption. -/ +theorem sum_blockCouplingWeight {n : ℕ} {ι : Type*} + [Fintype ι] [DecidableEq ι] + {P : Fin (n + 1) → Matrix ι ι ℂ} (hP : OrthogonalProjectionFamily P) + (H : Matrix ι ι ℂ) (hH : H.conjTranspose * H = 1) + (hmult : ∀ k, hsNormSq (P k) = (n.choose k.val : ℝ)) : + (∑ t : Fin (n + 1) × Fin (n + 1), blockCouplingWeight P H t) = 1 := by + rw [Fintype.sum_prod_type] + simp_rw [blockCouplingWeight_fst_marginal hP H hH hmult] + exact sum_binomialWeight n + +/-- A nonzero block probability lies on or above the required anti-diagonal. -/ +theorem blockCouplingWeight_support {n d : ℕ} {ι : Type*} [Fintype ι] + (P : Fin (n + 1) → Matrix ι ι ℂ) (H : Matrix ι ι ℂ) + (hvanish : ∀ r s, r.val + s.val < n - d → P s * H * P r = 0) + (r s : Fin (n + 1)) (ht : blockCouplingWeight P H (r, s) ≠ 0) : + n - d ≤ r.val + s.val := by + apply Nat.le_of_not_gt + intro hlt + apply ht + simp only [blockCouplingWeight, normalizedPairWeight, hvanish r s hlt, + hsNormSq_zero, zero_div] + +/-- The spectral block coupling bounds the actual centered grading +anticommutator. Its hypotheses are the orthogonal grading, its binomial +multiplicities, unitarity, and the separately proved low-degree vanishing. -/ +theorem hsNormSq_centeredGrading_anticommutator_le {ι : Type*} + [Fintype ι] [DecidableEq ι] + (n d : ℕ) (P : Fin (n + 1) → Matrix ι ι ℂ) + (hP : OrthogonalProjectionFamily P) (H : Matrix ι ι ℂ) + (hleft : H.conjTranspose * H = 1) (hright : H * H.conjTranspose = 1) + (hmult : ∀ k, hsNormSq (P k) = (n.choose k.val : ℝ)) + (hvanish : ∀ r s, r.val + s.val < n - d → P s * H * P r = 0) : + hsNormSq (centeredGrading P * H + H * centeredGrading P) ≤ + 4 * (d : ℝ) * Real.sqrt (n : ℝ) * (2 : ℝ) ^ n := by + rw [hsNormSq_centered_anticommutator hP H] + apply binomial_block_coupling_bound n d (fun r s => hsNormSq (P s * H * P r)) + · intro r s + exact hsNormSq_nonneg _ + · intro r + rw [sum_hsNormSq_blocks_column hP H r hleft, hmult] + · intro s + rw [sum_hsNormSq_blocks_row hP H s hright, hmult] + · intro r s hrs + rw [hvanish r s hrs, hsNormSq_zero] + +/-- Trace-multiplicity form, for direct use with finite-dimensional orthogonal +projections whose ranks have already been computed. -/ +theorem hsNormSq_centeredGrading_anticommutator_le_of_trace {ι : Type*} + [Fintype ι] [DecidableEq ι] + (n d : ℕ) (P : Fin (n + 1) → Matrix ι ι ℂ) + (hP : OrthogonalProjectionFamily P) (H : Matrix ι ι ℂ) + (hleft : H.conjTranspose * H = 1) (hright : H * H.conjTranspose = 1) + (htrace : ∀ k, (Matrix.trace (P k)).re = (n.choose k.val : ℝ)) + (hvanish : ∀ r s, r.val + s.val < n - d → P s * H * P r = 0) : + hsNormSq (centeredGrading P * H + H * centeredGrading P) ≤ + 4 * (d : ℝ) * Real.sqrt (n : ℝ) * (2 : ℝ) ^ n := by + apply hsNormSq_centeredGrading_anticommutator_le n d P hP H hleft hright _ hvanish + intro k + rw [hsNormSq_projection (P k) (hP.conjTranspose_eq k) (hP.idempotent k), htrace] + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/BlockVanishing.lean b/lean/OAI/Combinatorics/GotsmanLinial/BlockVanishing.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbb9ea61a5adc8bf3b220247034caaafef23a7eb --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/BlockVanishing.lean @@ -0,0 +1,249 @@ +import OAI.Combinatorics.GotsmanLinial.Statement +import OAI.Combinatorics.GotsmanLinial.PolynomialDegree +import OAI.Combinatorics.GotsmanLinial.CoordinateMultipliers +import OAI.Combinatorics.GotsmanLinial.SignParity +import OAI.Combinatorics.GotsmanLinial.WeightedGrading +import OAI.Combinatorics.GotsmanLinial.ProjectionBlocks +import Mathlib.Analysis.InnerProductSpace.Projection.FiniteDimensional +import Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Vanishing of low antidiagonal blocks + +The geometric step is reduced to an explicit finite sum: multiplication on +both sides by the square root of a positive weight turns the weighted pairing +into a Fourier pairing against the signed weight. +-/ + +noncomputable section + +open scoped BigOperators ComplexConjugate + +namespace LeanBlast.GotsmanLinial + +/-- The threshold convention at zero is compatible with the signed absolute +value identity used to build the weighted grading. -/ +theorem abs_mul_thresholdSign (t : ℝ) : |t| * thresholdSign t = t := by + by_cases ht : 0 ≤ t + · simp [thresholdSign, ht, abs_of_nonneg ht] + · simp [thresholdSign, ht, abs_of_neg (lt_of_not_ge ht)] + +/-- If the image of one subspace under an operator is orthogonal to a second +subspace, the corresponding projection block vanishes. -/ +theorem projectionBlock_eq_zero_of_pairing + {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] + (U V : Submodule 𝕜 E) [U.HasOrthogonalProjection] [V.HasOrthogonalProjection] + (H : E →L[𝕜] E) + (hpair : ∀ u ∈ U, ∀ v ∈ V, inner 𝕜 v (H u) = 0) : + V.starProjection * H * U.starProjection = 0 := by + ext x + change V.starProjection (H (U.starProjection x)) = 0 + apply (Submodule.starProjection_apply_eq_zero_iff V).mpr + intro v hv + exact hpair _ (U.starProjection_apply_mem x) v hv + +/-- Lift an orthogonality calculation on preimages through a common linear map +to a zero block between subspaces of its images. -/ +theorem projectionBlock_eq_zero_of_map_pairing + {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] + (A B U V : Submodule 𝕜 E) [U.HasOrthogonalProjection] [V.HasOrthogonalProjection] + (D : E →ₗ[𝕜] E) (H : E →L[𝕜] E) + (hU : U ≤ A.map D) (hV : V ≤ B.map D) + (hpair : ∀ a ∈ A, ∀ b ∈ B, inner 𝕜 (D b) (H (D a)) = 0) : + V.starProjection * H * U.starProjection = 0 := by + apply projectionBlock_eq_zero_of_pairing U V H + intro u hu v hv + obtain ⟨a, ha, rfl⟩ := hU hu + obtain ⟨b, hb, rfl⟩ := hV hv + exact hpair a ha b hb + +/-- The finite pairing identity underlying the low antidiagonal cutoff. +The norm and inner product are the counting Euclidean ones. -/ +theorem sqrtWeight_inner_eq_sum + {Ω : Type*} [Fintype Ω] + (w h : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) + (D : EuclideanSpace ℂ Ω →ₗ[ℂ] EuclideanSpace ℂ Ω) + (hD : ∀ a x, D a x = (Real.sqrt (w x) : ℂ) * a x) + (H : EuclideanSpace ℂ Ω →L[ℂ] EuclideanSpace ℂ Ω) + (hH : ∀ a x, H a x = (h x : ℂ) * a x) + (a b : EuclideanSpace ℂ Ω) : + inner ℂ (D b) (H (D a)) = + ∑ x, star (b x) * a x * ((w x : ℂ) * (h x : ℂ)) := by + rw [PiLp.inner_apply] + apply Finset.sum_congr rfl + intro x _ + rw [RCLike.inner_apply', hH, hD, hD] + calc + star ((Real.sqrt (w x) : ℂ) * b x) * + ((h x : ℂ) * ((Real.sqrt (w x) : ℂ) * a x)) = + star (b x) * a x * + (((Real.sqrt (w x) : ℂ) * (Real.sqrt (w x) : ℂ)) * (h x : ℂ)) := by + simp only [star_mul, Complex.star_def, Complex.conj_ofReal] + ring + _ = star (b x) * a x * ((w x : ℂ) * (h x : ℂ)) := by + rw [← Complex.ofReal_mul, Real.mul_self_sqrt (hw x)] + +/-- Replace the weight times the diagonal sign by the actual signed weight. -/ +theorem sqrtWeight_inner_eq_sum_signedWeight + {Ω : Type*} [Fintype Ω] + (w h : Ω → ℝ) (q : Ω → ℂ) (hw : ∀ x, 0 ≤ w x) + (hwq : ∀ x, (w x : ℂ) * (h x : ℂ) = q x) + (D : EuclideanSpace ℂ Ω →ₗ[ℂ] EuclideanSpace ℂ Ω) + (hD : ∀ a x, D a x = (Real.sqrt (w x) : ℂ) * a x) + (H : EuclideanSpace ℂ Ω →L[ℂ] EuclideanSpace ℂ Ω) + (hH : ∀ a x, H a x = (h x : ℂ) * a x) + (a b : EuclideanSpace ℂ Ω) : + inner ℂ (D b) (H (D a)) = ∑ x, star (b x) * a x * q x := by + rw [sqrtWeight_inner_eq_sum w h hw D hD H hH] + simp only [hwq] + +/-- High Fourier support of the signed weight kills every pairing whose two +unweighted degrees have smaller total degree. -/ +theorem sqrtWeight_pairing_eq_zero_of_fourier_separation + {n r s k : ℕ} (w h : Cube n → ℝ) (q : Cube n → ℂ) + (hw : ∀ x, 0 ≤ w x) (hwq : ∀ x, (w x : ℂ) * (h x : ℂ) = q x) + (D : EuclideanSpace ℂ (Cube n) →ₗ[ℂ] EuclideanSpace ℂ (Cube n)) + (hD : ∀ a x, D a x = (Real.sqrt (w x) : ℂ) * a x) + (H : EuclideanSpace ℂ (Cube n) →L[ℂ] EuclideanSpace ℂ (Cube n)) + (hH : ∀ a x, H a x = (h x : ℂ) * a x) + (a b : EuclideanSpace ℂ (Cube n)) + (ha : WithLp.ofLp a ∈ fourierSpace n r) + (hb : WithLp.ofLp b ∈ fourierSpace n s) + (hq : q ∈ fourierSpaceFrom n k) (hrs : r + s < k) : + inner ℂ (D b) (H (D a)) = 0 := by + rw [sqrtWeight_inner_eq_sum_signedWeight w h q hw hwq D hD H hH] + exact sum_mul_eq_zero_of_fourier_separated (fourierSpace_conj_mul ha hb) hq hrs + +/-- The choices `w = |p|` and `h = parity * sign(p)` multiply to the +high-degree signed polynomial, including at a zero of the polynomial. -/ +theorem polynomial_signedWeight {n : ℕ} (p : MvPolynomial (Fin n) ℝ) (x : Cube n) : + ((|polynomialValue p x| : ℝ) : ℂ) * + ((fullParity x * thresholdSign (polynomialValue p x) : ℝ) : ℂ) = + walshChar Finset.univ x * (polynomialValue p x : ℂ) := by + rw [Complex.ofReal_mul] + calc + ((|polynomialValue p x| : ℝ) : ℂ) * + ((fullParity x : ℂ) * (thresholdSign (polynomialValue p x) : ℂ)) = + (fullParity x : ℂ) * + (((|polynomialValue p x| : ℝ) : ℂ) * + (thresholdSign (polynomialValue p x) : ℂ)) := by ring + _ = walshChar Finset.univ x * (polynomialValue p x : ℂ) := by + rw [← Complex.ofReal_mul, abs_mul_thresholdSign] + simp only [fullParity, walshChar, Complex.ofReal_prod] + +/-- The weighted pairing vanishes for the polynomial, weight, +and parity-modified threshold sign. No Fourier-support assumption remains. -/ +theorem polynomial_sqrtWeight_pairing_eq_zero + {n d r s : ℕ} (p : MvPolynomial (Fin n) ℝ) + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) + (hnz : ∀ x, polynomialValue p x ≠ 0) + (a b : EuclideanSpace ℂ (Cube n)) + (ha : WithLp.ofLp a ∈ fourierSpace n r) + (hb : WithLp.ofLp b ∈ fourierSpace n s) (hrs : r + s < n - d) : + let D := sqrtWeightEquiv (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x)) + inner ℂ (D b) + (signMultiplier (fun x => fullParity x * thresholdSign (polynomialValue p x)) (D a)) + = 0 := by + dsimp only + apply sqrtWeight_pairing_eq_zero_of_fourier_separation + (fun x => |polynomialValue p x|) + (fun x => fullParity x * thresholdSign (polynomialValue p x)) + (fun x => walshChar Finset.univ x * (polynomialValue p x : ℂ)) + (fun x => abs_nonneg (polynomialValue p x)) (polynomial_signedWeight p) + _ (fun a x => sqrtWeightEquiv_apply _ _ a x) + _ (fun a x => signMultiplier_apply _ a x) a b ha hb + (parity_polynomialValue_mem_fourierSpaceFrom hp hd) hrs + +/-- The operator between two subspaces of weighted low-degree spaces is zero +below the polynomial's degree cutoff. -/ +theorem polynomial_projectionBlock_eq_zero + {n d r s : ℕ} (p : MvPolynomial (Fin n) ℝ) + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) + (hnz : ∀ x, polynomialValue p x ≠ 0) + (U V : Submodule ℂ (EuclideanSpace ℂ (Cube n))) + (hU : U ≤ weightedFourierSpace (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x)) r) + (hV : V ≤ weightedFourierSpace (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x)) s) + (hrs : r + s < n - d) : + V.starProjection * + signMultiplier (fun x => fullParity x * thresholdSign (polynomialValue p x)) * + U.starProjection = 0 := by + apply projectionBlock_eq_zero_of_map_pairing + (fourierEuclideanSpace n r) (fourierEuclideanSpace n s) U V + (sqrtWeightEquiv (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x))).toLinearMap _ hU hV + intro a ha b hb + apply polynomial_sqrtWeight_pairing_eq_zero (r := r) (s := s) p hp hd hnz a b + · simpa only [mem_fourierEuclideanSpace] using ha + · simpa only [mem_fourierEuclideanSpace] using hb + · exact hrs + +/-- Low antidiagonal vanishing for the actual weighted grading constructed +from the polynomial. All geometric hypotheses are discharged. -/ +theorem weightedFlag_block_eq_zero_of_polynomial_degree + {n d r s : ℕ} (p : MvPolynomial (Fin n) ℝ) + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) + (hnz : ∀ x, polynomialValue p x ≠ 0) (hrs : r + s < n - d) : + let K := weightedFourierFlag (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x)) + flagProjection K s * + signMultiplier (fun x => fullParity x * thresholdSign (polynomialValue p x)) * + flagProjection K r = 0 := by + dsimp only + apply polynomial_projectionBlock_eq_zero (r := r) (s := s) p hp hd hnz + · simpa only [weightedFourierFlag_succ] using + flagLayer_le_next + (weightedFourierFlag (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x))) r + · simpa only [weightedFourierFlag_succ] using + flagLayer_le_next + (weightedFourierFlag (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x))) s + · exact hrs + +/-- The same vanishing statement in any orthonormal matrix coordinates, ready +for the Hilbert-Schmidt block coupling. -/ +theorem weightedFlag_matrixBlock_eq_zero_of_polynomial_degree + {n d r s : ℕ} (p : MvPolynomial (Fin n) ℝ) + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) + (hnz : ∀ x, polynomialValue p x ≠ 0) (hrs : r + s < n - d) + {ι : Type*} [Fintype ι] [DecidableEq ι] + (b : OrthonormalBasis ι ℂ (EuclideanSpace ℂ (Cube n))) : + let K := weightedFourierFlag (fun x => |polynomialValue p x|) + (fun x => abs_pos.mpr (hnz x)) + operatorMatrix b (flagProjection K s) * + operatorMatrix b + (signMultiplier (fun x => fullParity x * thresholdSign (polynomialValue p x))) * + operatorMatrix b (flagProjection K r) = 0 := by + have h := congrArg (operatorMatrix b) + (weightedFlag_block_eq_zero_of_polynomial_degree p hp hd hnz hrs) + simpa only [operatorMatrix_mul, operatorMatrix_zero] using h + +/-- The concrete cutoff used by the finite block coupling: actual weighted +projection matrices, actual diagonal parity-modified polynomial threshold, +and no unproved construction assumptions. -/ +theorem weightedProjectionMatrix_block_eq_zero_of_polynomial_degree + {n d : ℕ} (p : MvPolynomial (Fin n) ℝ) + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) + (hnz : ∀ x, polynomialValue p x ≠ 0) + (r s : Fin (n + 1)) (hrs : r.val + s.val < n - d) : + let w := fun x => |polynomialValue p x| + let hw : ∀ x, 0 < w x := fun x => abs_pos.mpr (hnz x) + weightedProjectionMatrix w hw s * + signMatrix (fun x => fullParity x * polynomialThreshold p x) * + weightedProjectionMatrix w hw r = 0 := by + have h := weightedFlag_matrixBlock_eq_zero_of_polynomial_degree + (r := r.val) (s := s.val) p hp hd hnz hrs (EuclideanSpace.basisFun (Cube n) ℂ) + simpa only [weightedProjectionMatrix, flagProjectionMatrix, signMultiplier, + operatorMatrix_toEuclideanCLM, polynomialThreshold] using h + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/Commutator.lean b/lean/OAI/Combinatorics/GotsmanLinial/Commutator.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bd1478b410526788dfa89b67f7b726b2493ff57 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/Commutator.lean @@ -0,0 +1,271 @@ +import OAI.Combinatorics.GotsmanLinial.ProjectionBlocks +import Mathlib.LinearAlgebra.UnitaryGroup +import Mathlib.Tactic + +namespace OAI + +/-! +# Entry bounds for a tridiagonal grading commutator + +All norms here are norms of individual complex entries. No default +norm on a matrix is used. A complete orthogonal family defines a phase +unitary with eigenvalues `I^k`. For a tridiagonal operator the commutator is +the difference of two unitary conjugates divided by `2 I`. +-/ + +noncomputable section + +open scoped BigOperators Matrix + +namespace LeanBlast.GotsmanLinial + +section SpectralMultiplier + +variable {κ ι : Type*} [Fintype κ] [DecidableEq κ] [Fintype ι] [DecidableEq ι] + +/-- A complex spectral multiplier for a finite family of projections. -/ +def spectralMultiplier (P : κ → Matrix ι ι ℂ) (a : κ → ℂ) : Matrix ι ι ℂ := + ∑ k, a k • P k + +variable (P : κ → Matrix ι ι ℂ) +variable (hmul : ∀ r s, P r * P s = if r = s then P r else 0) +include hmul + +theorem spectralMultiplier_mul_projection (a : κ → ℂ) (r : κ) : + spectralMultiplier P a * P r = a r • P r := by + classical + simp [spectralMultiplier, Finset.sum_mul, hmul] + +theorem projection_mul_spectralMultiplier (a : κ → ℂ) (r : κ) : + P r * spectralMultiplier P a = a r • P r := by + classical + simp [spectralMultiplier, Finset.mul_sum, hmul] + +theorem spectralMultiplier_mul (a b : κ → ℂ) : + spectralMultiplier P a * spectralMultiplier P b = + spectralMultiplier P (fun k => a k * b k) := by + change spectralMultiplier P a * (∑ k, b k • P k) = _ + rw [Finset.mul_sum] + simp only [mul_smul_comm, spectralMultiplier_mul_projection P hmul, smul_smul] + simp only [spectralMultiplier, mul_comm] + +omit hmul [DecidableEq κ] [Fintype ι] [DecidableEq ι] in +theorem star_spectralMultiplier (hstar : ∀ k, star (P k) = P k) (a : κ → ℂ) : + star (spectralMultiplier P a) = spectralMultiplier P (fun k => star (a k)) := by + simp only [spectralMultiplier, star_sum, star_smul, hstar] + +theorem spectralMultiplier_unitary + (hstar : ∀ k, star (P k) = P k) (hsum : ∑ k, P k = 1) + (a : κ → ℂ) (ha : ∀ k, a k * star (a k) = 1) : + spectralMultiplier P a ∈ Matrix.unitaryGroup ι ℂ := by + rw [Matrix.mem_unitaryGroup_iff, star_spectralMultiplier P hstar, + spectralMultiplier_mul P hmul] + simpa only [spectralMultiplier, ha, one_smul] using hsum + +theorem spectralMultiplier_sandwich_block (a b : κ → ℂ) + (Z : Matrix ι ι ℂ) (r s : κ) : + P s * (spectralMultiplier P a * Z * spectralMultiplier P b) * P r = + (a s * b r) • (P s * Z * P r) := by + calc + _ = ((P s * spectralMultiplier P a) * Z) * + (spectralMultiplier P b * P r) := by simp only [mul_assoc] + _ = ((a s • P s) * Z) * (b r • P r) := by + rw [projection_mul_spectralMultiplier P hmul, + spectralMultiplier_mul_projection P hmul] + _ = _ := by simp only [smul_mul_assoc, mul_smul_comm, smul_smul, mul_comm] + +theorem spectralMultiplier_commutator_block (a : κ → ℂ) + (Z : Matrix ι ι ℂ) (r s : κ) : + P s * (spectralMultiplier P a * Z - Z * spectralMultiplier P a) * P r = + (a s - a r) • (P s * Z * P r) := by + have hleft : P s * (spectralMultiplier P a * Z) * P r = + a s • (P s * Z * P r) := by + rw [← mul_assoc (P s) (spectralMultiplier P a) Z, + projection_mul_spectralMultiplier P hmul] + simp only [smul_mul_assoc] + have hright : P s * (Z * spectralMultiplier P a) * P r = + a r • (P s * Z * P r) := by + calc + _ = (P s * Z) * (spectralMultiplier P a * P r) := by simp only [mul_assoc] + _ = _ := by rw [spectralMultiplier_mul_projection P hmul, mul_smul_comm] + rw [mul_sub, sub_mul, hleft, hright, sub_smul] + +omit hmul [DecidableEq κ] in +theorem spectral_blocks_reconstruct (hsum : ∑ k, P k = 1) (B : Matrix ι ι ℂ) : + (∑ s, ∑ r, P s * B * P r) = B := by + simp only [← Finset.mul_sum, hsum, mul_one, ← Finset.sum_mul, one_mul] + +omit hmul [DecidableEq κ] in +theorem spectral_blocks_ext (hsum : ∑ k, P k = 1) (A B : Matrix ι ι ℂ) + (h : ∀ r s, P s * A * P r = P s * B * P r) : A = B := by + rw [← spectral_blocks_reconstruct P hsum A, ← spectral_blocks_reconstruct P hsum B] + exact Finset.sum_congr rfl fun s _ => Finset.sum_congr rfl fun r _ => h r s + +end SpectralMultiplier + +theorem I_pow_mul_star (k : ℕ) : Complex.I ^ k * star (Complex.I ^ k) = 1 := by + rw [Complex.star_def, Complex.mul_conj'] + simp + +theorem phase_coeff_adjacent (r s : ℕ) (h₁ : s ≤ r + 1) (h₂ : r ≤ s + 1) : + Complex.I ^ s * star (Complex.I ^ r) - star (Complex.I ^ s) * Complex.I ^ r = + (2 * Complex.I) * ((s : ℂ) - (r : ℂ)) := by + have hcases : s = r ∨ s = r + 1 ∨ r = s + 1 := by omega + rcases hcases with h | h | h + · subst s + simp [mul_comm] + · subst s + simp only [pow_succ, star_mul, Complex.star_def, Complex.conj_I, Nat.cast_add, + Nat.cast_one] + calc + _ = (2 * Complex.I) * (Complex.I ^ r * star (Complex.I ^ r)) := by + simp only [Complex.star_def] + ring + _ = _ := by rw [I_pow_mul_star]; ring + · subst r + simp only [pow_succ, star_mul, Complex.star_def, Complex.conj_I, Nat.cast_add, + Nat.cast_one] + calc + _ = -(2 * Complex.I) * (Complex.I ^ s * star (Complex.I ^ s)) := by + simp only [Complex.star_def] + ring + _ = _ := by rw [I_pow_mul_star]; ring + +/-- The difference of two unitary matrices, divided by `2 I`, has entries +of modulus at most one. -/ +theorem entry_norm_le_one_of_two_unitaries + {ι : Type*} [Fintype ι] [DecidableEq ι] + (C U V : Matrix ι ι ℂ) + (hU : U ∈ Matrix.unitaryGroup ι ℂ) (hV : V ∈ Matrix.unitaryGroup ι ℂ) + (h : (2 * Complex.I) • C = U - V) (x y : ι) : ‖C x y‖ ≤ 1 := by + have heq := congrArg (fun A : Matrix ι ι ℂ => A x y) h + have hn : (2 : ℝ) * ‖C x y‖ = ‖U x y - V x y‖ := by + simpa [norm_mul] using congrArg norm heq + have htri := norm_sub_le (U x y) (V x y) + have hu₂ := sq_norm_entry_le_one_of_unitary U hU.1 x y + have hv₂ := sq_norm_entry_le_one_of_unitary V hV.1 x y + have hu : ‖U x y‖ ≤ 1 := by nlinarith [norm_nonneg (U x y)] + have hv : ‖V x y‖ ≤ 1 := by nlinarith [norm_nonneg (V x y)] + linarith + +section GradingCommutator + +variable {n : ℕ} {ι : Type*} [Fintype ι] [DecidableEq ι] +variable {P : Fin (n + 1) → Matrix ι ι ℂ} + +/-- The spectral phase `I^k` of the degree grading. -/ +def gradingPhase (P : Fin (n + 1) → Matrix ι ι ℂ) : Matrix ι ι ℂ := + spectralMultiplier P fun k => Complex.I ^ k.val + +theorem gradingPhase_unitary (hP : OrthogonalProjectionFamily P) : + gradingPhase P ∈ Matrix.unitaryGroup ι ℂ := by + exact spectralMultiplier_unitary P hP.mul_eq_ite (fun k => (hP.selfAdjoint k).star_eq) + hP.sum_eq_one _ (fun k => I_pow_mul_star k.val) + +/-- Tridiagonality means that blocks at grading distance greater than one vanish. -/ +def BlockTridiagonal (P : Fin (n + 1) → Matrix ι ι ℂ) (Z : Matrix ι ι ℂ) : Prop := + ∀ r s : Fin (n + 1), (r.val + 1 < s.val ∨ s.val + 1 < r.val) → + P s * Z * P r = 0 + +/-- Two opposite phase conjugations differ by `2 I` times the grading commutator. -/ +theorem grading_commutator_phase_identity (hP : OrthogonalProjectionFamily P) + (Z : Matrix ι ι ℂ) (htri : BlockTridiagonal P Z) : + (2 * Complex.I) • (degreeGrading P * Z - Z * degreeGrading P) = + gradingPhase P * Z * star (gradingPhase P) - + star (gradingPhase P) * Z * gradingPhase P := by + apply projection_block_ext hP + intro r s + rw [Matrix.mul_smul, Matrix.smul_mul, degreeGrading, projection_commutator hP, + Matrix.mul_sub, Matrix.sub_mul] + simp only [gradingPhase, + star_spectralMultiplier P (fun k => (hP.selfAdjoint k).star_eq)] + rw [spectralMultiplier_sandwich_block P hP.mul_eq_ite, + spectralMultiplier_sandwich_block P hP.mul_eq_ite] + by_cases hfar : r.val + 1 < s.val ∨ s.val + 1 < r.val + · simp only [htri r s hfar, smul_zero, sub_self] + · have hsr : s.val ≤ r.val + 1 := by omega + have hrs : r.val ≤ s.val + 1 := by omega + rw [← sub_smul, smul_smul, phase_coeff_adjacent r.val s.val hsr hrs] + simp + +/-- Every entry of the tridiagonal degree commutator has modulus at most one. -/ +theorem norm_degreeGrading_commutator_entry_le_one + (hP : OrthogonalProjectionFamily P) (Z : Matrix ι ι ℂ) + (htri : BlockTridiagonal P Z) (hZ : Z ∈ Matrix.unitaryGroup ι ℂ) + (x y : ι) : ‖(degreeGrading P * Z - Z * degreeGrading P) x y‖ ≤ 1 := by + have hW := gradingPhase_unitary hP + have hWstar := Unitary.star_mem hW + have hU : gradingPhase P * Z * star (gradingPhase P) ∈ Matrix.unitaryGroup ι ℂ := + (Matrix.unitaryGroup ι ℂ).mul_mem ((Matrix.unitaryGroup ι ℂ).mul_mem hW hZ) hWstar + have hV : star (gradingPhase P) * Z * gradingPhase P ∈ Matrix.unitaryGroup ι ℂ := + (Matrix.unitaryGroup ι ℂ).mul_mem ((Matrix.unitaryGroup ι ℂ).mul_mem hWstar hZ) hW + exact entry_norm_le_one_of_two_unitaries _ _ _ hU hV + (grading_commutator_phase_identity hP Z htri) x y + +/-- The Hilbert--Schmidt commutator bound is a consequence of block Parseval +and the fact that each nonzero block has grading distance at most one. -/ +theorem hsNormSq_degreeGrading_commutator_le + (hP : OrthogonalProjectionFamily P) (Z : Matrix ι ι ℂ) + (htri : BlockTridiagonal P Z) : + hsNormSq (degreeGrading P * Z - Z * degreeGrading P) ≤ hsNormSq Z := by + rw [degreeGrading, hsNormSq_commutator hP, hsNormSq_block_parseval hP Z] + apply Finset.sum_le_sum + intro r _ + apply Finset.sum_le_sum + intro s _ + by_cases hfar : r.val + 1 < s.val ∨ s.val + 1 < r.val + · simp only [htri r s hfar, hsNormSq_zero, mul_zero, le_refl] + · have hsr : (s.val : ℝ) ≤ (r.val : ℝ) + 1 := by + exact_mod_cast (show s.val ≤ r.val + 1 by omega) + have hrs : (r.val : ℝ) ≤ (s.val : ℝ) + 1 := by + exact_mod_cast (show r.val ≤ s.val + 1 by omega) + have hsq : ((s.val : ℝ) - (r.val : ℝ)) ^ 2 ≤ 1 := by + rw [sq_le_one_iff_abs_le_one, abs_le] + constructor <;> linarith + exact (mul_le_mul_of_nonneg_right hsq (hsNormSq_nonneg _)).trans_eq (one_mul _) + +theorem hsNormSq_degreeGrading_commutator_le_card + (hP : OrthogonalProjectionFamily P) (Z : Matrix ι ι ℂ) + (htri : BlockTridiagonal P Z) (hZ : Z ∈ Matrix.unitaryGroup ι ℂ) : + hsNormSq (degreeGrading P * Z - Z * degreeGrading P) ≤ Fintype.card ι := by + calc + _ ≤ hsNormSq Z := hsNormSq_degreeGrading_commutator_le hP Z htri + _ = _ := hsNormSq_of_unitary Z hZ.1 + +/-- Centering the grading does not change its commutator. -/ +theorem centeredGrading_commutator_eq (hP : OrthogonalProjectionFamily P) + (Z : Matrix ι ι ℂ) : + centeredGrading P * Z - Z * centeredGrading P = + degreeGrading P * Z - Z * degreeGrading P := by + rw [centeredGrading_eq hP] + simp only [sub_mul, mul_sub, smul_mul_assoc, mul_smul_comm, one_mul, mul_one] + abel + +theorem norm_centeredGrading_commutator_entry_le_one + (hP : OrthogonalProjectionFamily P) (Z : Matrix ι ι ℂ) + (htri : BlockTridiagonal P Z) (hZ : Z ∈ Matrix.unitaryGroup ι ℂ) + (x y : ι) : ‖(centeredGrading P * Z - Z * centeredGrading P) x y‖ ≤ 1 := by + rw [centeredGrading_commutator_eq hP] + exact norm_degreeGrading_commutator_entry_le_one hP Z htri hZ x y + +theorem sq_norm_centeredGrading_commutator_entry_le_one + (hP : OrthogonalProjectionFamily P) (Z : Matrix ι ι ℂ) + (htri : BlockTridiagonal P Z) (hZ : Z ∈ Matrix.unitaryGroup ι ℂ) + (x y : ι) : ‖(centeredGrading P * Z - Z * centeredGrading P) x y‖ ^ 2 ≤ 1 := by + rw [sq_le_one_iff₀ (norm_nonneg _)] + exact norm_centeredGrading_commutator_entry_le_one hP Z htri hZ x y + +theorem hsNormSq_centeredGrading_commutator_le_card + (hP : OrthogonalProjectionFamily P) (Z : Matrix ι ι ℂ) + (htri : BlockTridiagonal P Z) (hZ : Z ∈ Matrix.unitaryGroup ι ℂ) : + hsNormSq (centeredGrading P * Z - Z * centeredGrading P) ≤ Fintype.card ι := by + rw [centeredGrading_commutator_eq hP] + exact hsNormSq_degreeGrading_commutator_le_card hP Z htri hZ + +end GradingCommutator + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/CoordinateDegree.lean b/lean/OAI/Combinatorics/GotsmanLinial/CoordinateDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..68292ca213694825df56172b4e2b339e24a72a72 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/CoordinateDegree.lean @@ -0,0 +1,61 @@ +import OAI.Combinatorics.GotsmanLinial.PolynomialDegree +import OAI.Combinatorics.GotsmanLinial.CoordinateMultipliers +import OAI.Combinatorics.GotsmanLinial.Walsh + +namespace OAI + +/-! +# Coordinate multiplication raises the Fourier degree by at most one + +The unweighted polynomial degree bound is transported to the actual diagonal matrices and continuous linear operators +on the counting-inner-product Euclidean space, including the shifted flag used +by the weighted grading construction. +-/ + +noncomputable section + +open scoped Matrix + +namespace LeanBlast.GotsmanLinial + +variable {n k : ℕ} + +/-- The actual coordinate-sign matrix raises the unweighted degree by at most one. -/ +theorem coordinateSignMatrix_mem_fourierSpace (i : Fin n) {a : Cube n → ℂ} + (ha : a ∈ fourierSpace n k) : + coordinateSignMatrix i *ᵥ a ∈ fourierSpace n (k + 1) := by + change (fun x => (coordinateSignMatrix i *ᵥ a) x) ∈ fourierSpace n (k + 1) + simpa only [coordinateSignMatrix_mulVec] using cubeCoord_mul_mem_fourierSpace ha i + +/-- The continuous coordinate multiplier has the same degree shift in Euclidean space. -/ +theorem coordinateMultiplier_mem_fourierEuclideanSpace (i : Fin n) + {a : EuclideanSpace ℂ (Cube n)} (ha : a ∈ fourierEuclideanSpace n k) : + coordinateMultiplier i a ∈ fourierEuclideanSpace n (k + 1) := by + apply (mem_fourierEuclideanSpace _).2 + simpa only [coordinateMultiplier_apply] using + cubeCoord_mul_mem_fourierSpace ((mem_fourierEuclideanSpace _).1 ha) i + +/-- Submodule-map form of the Euclidean coordinate-degree shift. -/ +theorem coordinateMultiplier_map_fourierEuclideanSpace_le (i : Fin n) : + (fourierEuclideanSpace n k).map (coordinateMultiplier i).toLinearMap ≤ + fourierEuclideanSpace n (k + 1) := by + rintro a ⟨b, hb, rfl⟩ + exact coordinateMultiplier_mem_fourierEuclideanSpace i hb + +/-- The shifted flag also has a one-step coordinate shift, including its bottom term. -/ +theorem coordinateMultiplier_fourierFlag_shift (i : Fin n) : + ∀ k (a : EuclideanSpace ℂ (Cube n)), a ∈ fourierFlag n k → + coordinateMultiplier i a ∈ fourierFlag n (k + 1) := by + intro k a ha + cases k with + | zero => + have ha0 : a = 0 := by simpa using ha + simp [ha0] + | succ k => + exact coordinateMultiplier_mem_fourierEuclideanSpace i ha + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/CoordinateMultipliers.lean b/lean/OAI/Combinatorics/GotsmanLinial/CoordinateMultipliers.lean new file mode 100644 index 0000000000000000000000000000000000000000..e889109b96c3b6f2b06875b2734a94075ae03dc9 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/CoordinateMultipliers.lean @@ -0,0 +1,218 @@ +import OAI.Combinatorics.GotsmanLinial.Statement +import OAI.Combinatorics.GotsmanLinial.HilbertSchmidt +import Mathlib.Analysis.CStarAlgebra.Matrix +import Mathlib.LinearAlgebra.Matrix.Hermitian + +namespace OAI + +/-! +# Actual diagonal sign and coordinate operators on the cube + +The matrices here act on the cube with its counting inner product. Their +continuous linear maps act on `EuclideanSpace`, so all operator-norm statements +refer to the intended Euclidean norm. The Hilbert--Schmidt statements use the +explicit squared-entry sum `hsNormSq`. +-/ + +noncomputable section + +open scoped BigOperators Matrix + +namespace LeanBlast.GotsmanLinial + +variable {n : ℕ} + +/-- Multiplication by a real function on the cube, represented in the point-mass basis. -/ +def signMatrix (h : Cube n → ℝ) : Matrix (Cube n) (Cube n) ℂ := + Matrix.diagonal (fun x => (h x : ℂ)) + +/-- The actual cube coordinate-sign matrix `Z_i`. -/ +def coordinateSignMatrix (i : Fin n) : Matrix (Cube n) (Cube n) ℂ := + signMatrix (fun x => cubeCoord x i) + +@[simp] theorem signMatrix_apply (h : Cube n → ℝ) (x y : Cube n) : + signMatrix h x y = if x = y then (h x : ℂ) else 0 := by + simp [signMatrix, Matrix.diagonal_apply] + +@[simp] theorem signMatrix_apply_self (h : Cube n → ℝ) (x : Cube n) : + signMatrix h x x = (h x : ℂ) := by simp + +@[simp] theorem coordinateSignMatrix_apply (i : Fin n) (x y : Cube n) : + coordinateSignMatrix i x y = if x = y then (cubeCoord x i : ℂ) else 0 := + signMatrix_apply _ x y + +@[simp] theorem signMatrix_conjTranspose (h : Cube n → ℝ) : + (signMatrix h).conjTranspose = signMatrix h := by + simp [signMatrix, Matrix.diagonal_conjTranspose] + +@[simp] theorem signMatrix_star (h : Cube n → ℝ) : + star (signMatrix h) = signMatrix h := + signMatrix_conjTranspose h + +theorem signMatrix_isHermitian (h : Cube n → ℝ) : (signMatrix h).IsHermitian := + signMatrix_conjTranspose h + +/-- A sign-valued real diagonal is an involution. -/ +theorem signMatrix_mul_self (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) : signMatrix h * signMatrix h = 1 := by + classical + rw [signMatrix, Matrix.diagonal_mul_diagonal] + have hs : (fun x => (h x : ℂ) * (h x : ℂ)) = fun _ : Cube n => (1 : ℂ) := by + funext x + rcases hh x with hx | hx <;> simp [hx] + rw [hs, Matrix.diagonal_one] + +theorem signMatrix_conjTranspose_mul (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) : + (signMatrix h).conjTranspose * signMatrix h = 1 := by + rw [signMatrix_conjTranspose, signMatrix_mul_self h hh] + +theorem signMatrix_mul_conjTranspose (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) : + signMatrix h * (signMatrix h).conjTranspose = 1 := by + rw [signMatrix_conjTranspose, signMatrix_mul_self h hh] + +theorem signMatrix_unitary (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) : + signMatrix h ∈ Matrix.unitaryGroup (Cube n) ℂ := by + rw [Matrix.mem_unitaryGroup_iff, signMatrix_star] + exact signMatrix_mul_self h hh + +/-- A real sign diagonal commutes with every complex diagonal weight. -/ +theorem signMatrix_commute_diagonal (h : Cube n → ℝ) (d : Cube n → ℂ) : + Commute (signMatrix h) (Matrix.diagonal d) := by + change signMatrix h * Matrix.diagonal d = Matrix.diagonal d * signMatrix h + simp only [signMatrix, Matrix.diagonal_mul_diagonal] + congr 1 + funext x + exact mul_comm _ _ + +theorem signMatrix_mul_diagonal_comm (h : Cube n → ℝ) (d : Cube n → ℂ) : + signMatrix h * Matrix.diagonal d = Matrix.diagonal d * signMatrix h := + (signMatrix_commute_diagonal h d).eq + +@[simp] theorem signMatrix_mulVec (h : Cube n → ℝ) (v : Cube n → ℂ) (x : Cube n) : + (signMatrix h *ᵥ v) x = (h x : ℂ) * v x := by + simp [signMatrix, Matrix.mulVec_diagonal] + +theorem hsNormSq_signMatrix (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) : hsNormSq (signMatrix h) = (2 : ℝ) ^ n := by + rw [hsNormSq_of_unitary _ (signMatrix_conjTranspose_mul h hh), card_cube] + simp + +@[simp] theorem coordinateSignMatrix_conjTranspose (i : Fin n) : + (coordinateSignMatrix i).conjTranspose = coordinateSignMatrix i := + signMatrix_conjTranspose _ + +@[simp] theorem coordinateSignMatrix_star (i : Fin n) : + star (coordinateSignMatrix i) = coordinateSignMatrix i := + signMatrix_star _ + +theorem coordinateSignMatrix_isHermitian (i : Fin n) : + (coordinateSignMatrix i).IsHermitian := signMatrix_isHermitian _ + +@[simp] theorem coordinateSignMatrix_mul_self (i : Fin n) : + coordinateSignMatrix i * coordinateSignMatrix i = 1 := + signMatrix_mul_self _ (fun x => cubeCoord_cases x i) + +@[simp] theorem coordinateSignMatrix_conjTranspose_mul (i : Fin n) : + (coordinateSignMatrix i).conjTranspose * coordinateSignMatrix i = 1 := by simp + +@[simp] theorem coordinateSignMatrix_mul_conjTranspose (i : Fin n) : + coordinateSignMatrix i * (coordinateSignMatrix i).conjTranspose = 1 := by simp + +theorem coordinateSignMatrix_unitary (i : Fin n) : + coordinateSignMatrix i ∈ Matrix.unitaryGroup (Cube n) ℂ := + signMatrix_unitary _ (fun x => cubeCoord_cases x i) + +theorem coordinateSignMatrix_commute_diagonal (i : Fin n) (d : Cube n → ℂ) : + Commute (coordinateSignMatrix i) (Matrix.diagonal d) := + signMatrix_commute_diagonal _ d + +theorem coordinateSignMatrix_mul_diagonal_comm (i : Fin n) (d : Cube n → ℂ) : + coordinateSignMatrix i * Matrix.diagonal d = + Matrix.diagonal d * coordinateSignMatrix i := + (coordinateSignMatrix_commute_diagonal i d).eq + +@[simp] theorem coordinateSignMatrix_mulVec (i : Fin n) (v : Cube n → ℂ) (x : Cube n) : + (coordinateSignMatrix i *ᵥ v) x = (cubeCoord x i : ℂ) * v x := + signMatrix_mulVec _ v x + +@[simp] theorem hsNormSq_coordinateSignMatrix (i : Fin n) : + hsNormSq (coordinateSignMatrix i) = (2 : ℝ) ^ n := + hsNormSq_signMatrix _ (fun x => cubeCoord_cases x i) + +/-- The same diagonal action on the counting-inner-product Euclidean space. -/ +def signMultiplier (h : Cube n → ℝ) : + EuclideanSpace ℂ (Cube n) →L[ℂ] EuclideanSpace ℂ (Cube n) := + Matrix.toEuclideanCLM (n := Cube n) (𝕜 := ℂ) (signMatrix h) + +/-- The actual coordinate multiplier on Euclidean space. -/ +def coordinateMultiplier (i : Fin n) : + EuclideanSpace ℂ (Cube n) →L[ℂ] EuclideanSpace ℂ (Cube n) := + signMultiplier (fun x => cubeCoord x i) + +@[simp] theorem toEuclideanCLM_signMatrix (h : Cube n → ℝ) : + Matrix.toEuclideanCLM (n := Cube n) (𝕜 := ℂ) (signMatrix h) = signMultiplier h := rfl + +@[simp] theorem toEuclideanCLM_coordinateSignMatrix (i : Fin n) : + Matrix.toEuclideanCLM (n := Cube n) (𝕜 := ℂ) (coordinateSignMatrix i) = + coordinateMultiplier i := rfl + +@[simp] theorem signMultiplier_apply (h : Cube n → ℝ) + (v : EuclideanSpace ℂ (Cube n)) (x : Cube n) : + signMultiplier h v x = (h x : ℂ) * v x := by + change (signMatrix h *ᵥ fun y => v y) x = _ + exact signMatrix_mulVec h _ x + +@[simp] theorem coordinateMultiplier_apply (i : Fin n) + (v : EuclideanSpace ℂ (Cube n)) (x : Cube n) : + coordinateMultiplier i v x = (cubeCoord x i : ℂ) * v x := + signMultiplier_apply _ v x + +theorem signMultiplier_isSelfAdjoint (h : Cube n → ℝ) : + IsSelfAdjoint (signMultiplier h) := by + change star (Matrix.toEuclideanCLM (n := Cube n) (𝕜 := ℂ) (signMatrix h)) = + Matrix.toEuclideanCLM (n := Cube n) (𝕜 := ℂ) (signMatrix h) + rw [← map_star, signMatrix_star] + +theorem coordinateMultiplier_isSelfAdjoint (i : Fin n) : + IsSelfAdjoint (coordinateMultiplier i) := signMultiplier_isSelfAdjoint _ + +theorem signMultiplier_mul_self (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) : signMultiplier h * signMultiplier h = 1 := by + change Matrix.toEuclideanCLM (n := Cube n) (𝕜 := ℂ) (signMatrix h) * + Matrix.toEuclideanCLM (n := Cube n) (𝕜 := ℂ) (signMatrix h) = 1 + rw [← map_mul, signMatrix_mul_self h hh, map_one] + +@[simp] theorem coordinateMultiplier_mul_self (i : Fin n) : + coordinateMultiplier i * coordinateMultiplier i = 1 := + signMultiplier_mul_self _ (fun x => cubeCoord_cases x i) + +theorem norm_signMultiplier_apply (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) (v : EuclideanSpace ℂ (Cube n)) : + ‖signMultiplier h v‖ = ‖v‖ := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + simp only [EuclideanSpace.norm_sq_eq] + apply Finset.sum_congr rfl + intro x _ + rcases hh x with hx | hx <;> simp [signMultiplier_apply, hx] + +@[simp] theorem norm_coordinateMultiplier_apply (i : Fin n) + (v : EuclideanSpace ℂ (Cube n)) : ‖coordinateMultiplier i v‖ = ‖v‖ := + norm_signMultiplier_apply _ (fun x => cubeCoord_cases x i) v + +theorem norm_signMultiplier_le_one (h : Cube n → ℝ) + (hh : ∀ x, h x = 1 ∨ h x = -1) : ‖signMultiplier h‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ zero_le_one + intro v + simp [norm_signMultiplier_apply h hh] + +theorem norm_coordinateMultiplier_le_one (i : Fin n) : ‖coordinateMultiplier i‖ ≤ 1 := + norm_signMultiplier_le_one _ (fun x => cubeCoord_cases x i) + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/CubeOperators.lean b/lean/OAI/Combinatorics/GotsmanLinial/CubeOperators.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f590af3bec414952f35005819eddbc896e5bb65 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/CubeOperators.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.GotsmanLinial.CoordinateMultipliers +import OAI.Combinatorics.GotsmanLinial.HilbertSchmidt +import Mathlib.InformationTheory.Hamming +import Mathlib.Tactic + +namespace OAI + +/-! +# Coordinate commutators and Hamming-distance energy + +The coordinate sign matrices are the actual diagonal operators of the Boolean +cube. The identities here turn their Hilbert--Schmidt and entry estimates into +the energy estimates used by the edge-recovery argument. +-/ + +open scoped BigOperators + +namespace LeanBlast.GotsmanLinial + +variable {n : ℕ} + +/-- In the point basis, a coordinate commutator records the difference of the +two endpoint signs. -/ +theorem coordinate_commutator_apply + (M : Matrix (Cube n) (Cube n) ℂ) (i : Fin n) (x y : Cube n) : + (M * coordinateSignMatrix i - coordinateSignMatrix i * M) x y = + (((cubeCoord y i - cubeCoord x i : ℝ) : ℂ)) * M x y := by + simp only [coordinateSignMatrix, signMatrix, Matrix.sub_apply, + Matrix.mul_diagonal, Matrix.diagonal_mul, Complex.ofReal_sub] + ring + +/-- Squaring a coordinate difference gives four exactly on the coordinates +where the Boolean endpoints differ. -/ +theorem coordinate_commutator_sq_norm + (M : Matrix (Cube n) (Cube n) ℂ) (i : Fin n) (x y : Cube n) : + ‖(M * coordinateSignMatrix i - coordinateSignMatrix i * M) x y‖ ^ 2 = + (if x i ≠ y i then (4 : ℝ) else 0) * ‖M x y‖ ^ 2 := by + rw [coordinate_commutator_apply, norm_mul, mul_pow] + congr 1 + cases hx : x i <;> cases hy : y i <;> norm_num [cubeCoord, hx, hy] + +/-- Summing the squared entries over coordinates counts Hamming distance. -/ +theorem sum_coordinate_commutator_sq_norm + (M : Matrix (Cube n) (Cube n) ℂ) (x y : Cube n) : + (∑ i : Fin n, + ‖(M * coordinateSignMatrix i - coordinateSignMatrix i * M) x y‖ ^ 2) = + 4 * (hammingDist x y : ℝ) * ‖M x y‖ ^ 2 := by + classical + simp_rw [coordinate_commutator_sq_norm, ite_mul, zero_mul] + calc + (∑ i : Fin n, if x i ≠ y i then 4 * ‖M x y‖ ^ 2 else 0) = + ∑ i ∈ Finset.univ.filter (fun i => x i ≠ y i), 4 * ‖M x y‖ ^ 2 := by + rw [Finset.sum_filter] + _ = (hammingDist x y : ℝ) * (4 * ‖M x y‖ ^ 2) := by + simp [hammingDist, nsmul_eq_mul] + _ = 4 * (hammingDist x y : ℝ) * ‖M x y‖ ^ 2 := by ring + +/-- The total coordinate-commutator energy is four times the distance-weighted +entry energy. -/ +theorem sum_hsNormSq_coordinate_commutator + (M : Matrix (Cube n) (Cube n) ℂ) : + (∑ i : Fin n, hsNormSq (M * coordinateSignMatrix i - coordinateSignMatrix i * M)) = + 4 * ∑ x : Cube n, ∑ y : Cube n, (hammingDist x y : ℝ) * ‖M x y‖ ^ 2 := by + classical + simp only [hsNormSq] + calc + (∑ i : Fin n, ∑ x : Cube n, ∑ y : Cube n, + ‖(M * coordinateSignMatrix i - coordinateSignMatrix i * M) x y‖ ^ 2) = + ∑ x : Cube n, ∑ y : Cube n, ∑ i : Fin n, + ‖(M * coordinateSignMatrix i - coordinateSignMatrix i * M) x y‖ ^ 2 := by + rw [Finset.sum_comm] + exact Finset.sum_congr rfl fun _ _ => Finset.sum_comm + _ = ∑ x : Cube n, ∑ y : Cube n, + 4 * (hammingDist x y : ℝ) * ‖M x y‖ ^ 2 := by + simp_rw [sum_coordinate_commutator_sq_norm] + _ = 4 * ∑ x : Cube n, ∑ y : Cube n, + (hammingDist x y : ℝ) * ‖M x y‖ ^ 2 := by + simp only [Finset.mul_sum, mul_assoc] + +/-- A uniform coordinate-commutator Hilbert--Schmidt bound gives the distance +energy inequality for the actual cube matrix. -/ +theorem distance_energy_le_of_coordinate_commutator_bound + (M : Matrix (Cube n) (Cube n) ℂ) + (hbound : ∀ i : Fin n, + hsNormSq (M * coordinateSignMatrix i - coordinateSignMatrix i * M) ≤ (2 : ℝ) ^ n) : + (∑ x : Cube n, ∑ y : Cube n, (hammingDist x y : ℝ) * ‖M x y‖ ^ 2) ≤ + (n : ℝ) * (2 : ℝ) ^ n / 4 := by + have h := Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset (Fin n))) => hbound i) + rw [sum_hsNormSq_coordinate_commutator] at h + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at h + linarith + +/-- A coordinate at which distinct endpoints differ turns an entrywise +commutator estimate into the edge-entry cap `1/4`. -/ +theorem off_diagonal_sq_norm_le_quarter_of_commutator_bound + (M : Matrix (Cube n) (Cube n) ℂ) + (hbound : ∀ (i : Fin n) (x y : Cube n), + ‖(M * coordinateSignMatrix i - coordinateSignMatrix i * M) x y‖ ^ 2 ≤ 1) + (x y : Cube n) (hxy : x ≠ y) : ‖M x y‖ ^ 2 ≤ (1 : ℝ) / 4 := by + classical + obtain ⟨i, hi⟩ : ∃ i : Fin n, x i ≠ y i := by + by_contra h + apply hxy + funext i + exact not_not.mp (not_exists.mp h i) + have h := hbound i x y + rw [coordinate_commutator_sq_norm, ite_eq_left hi] at h + linarith + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/EdgeRecovery.lean b/lean/OAI/Combinatorics/GotsmanLinial/EdgeRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..0920e9bdcf0041ce0b3d3c40e27e59832cbba9c5 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/EdgeRecovery.lean @@ -0,0 +1,201 @@ +import OAI.Combinatorics.GotsmanLinial.HilbertSchmidt +import OAI.Combinatorics.GotsmanLinial.SignParity +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Recovering constant-sign edges from grading energy + +The counting argument is separated from construction of the grading matrix. +Its hypotheses are explicit entrywise, total-energy, and distance-energy facts. +No edge-count or anticommutator conclusion is assumed. +-/ + +open scoped BigOperators + +namespace LeanBlast.GotsmanLinial + +variable {α ι : Type*} [Fintype α] [Fintype ι] + +/-- A finite distance layer, also useful for weights indexed by ordered pairs. -/ +def distanceShell (d : α → ℕ) (k : ℕ) : Finset α := + Finset.univ.filter fun a => d a = k + +@[simp] theorem mem_distanceShell (d : α → ℕ) (k : ℕ) (a : α) : + a ∈ distanceShell d k ↔ d a = k := by + simp [distanceShell] + +/-- Pointwise distance counting: distance-zero entries are the only possible +source of a deficit between total mass and distance-weighted mass. -/ +theorem twice_mass_sub_neighbor_le_distance (d : α → ℕ) (w : α → ℝ) + (hw : ∀ a, 0 ≤ w a) : + 2 * (∑ a, w a) - (∑ a ∈ distanceShell d 1, w a) ≤ + 2 * (∑ a ∈ distanceShell d 0, w a) + ∑ a, (d a : ℝ) * w a := by + have hpoint : ∀ a, + 2 * w a - (if d a = 1 then w a else 0) ≤ + 2 * (if d a = 0 then w a else 0) + (d a : ℝ) * w a := by + intro a + by_cases h0 : d a = 0 + · simp [h0] + by_cases h1 : d a = 1 + · rw [ite_eq_left h1, ite_eq_right h0, h1] + norm_num + linarith + have h2 : 2 ≤ d a := by omega + have h2R : (2 : ℝ) ≤ (d a : ℝ) := by exact_mod_cast h2 + simpa only [ite_eq_right h0, ite_eq_right h1, sub_zero, mul_zero, zero_add] using + mul_le_mul_of_nonneg_right h2R (hw a) + have hsum := Finset.sum_le_sum (s := Finset.univ) fun a _ => hpoint a + simpa only [distanceShell, Finset.sum_filter, Finset.sum_sub_distrib, + Finset.sum_add_distrib, Finset.mul_sum] using hsum + +/-- The sum of the nonnegative neighbor deficits is controlled by twice the +distance-zero energy. Equivalently, `A₀ + F ≤ 2 A₀`. -/ +theorem neighbor_deficit_le_twice_zero_mass (d : α → ℕ) (w : α → ℝ) + (hw : ∀ a, 0 ≤ w a) + (htotal : (∑ a, w a) = ((distanceShell d 1).card : ℝ) / 4) + (henergy : (∑ a, (d a : ℝ) * w a) ≤ ∑ a, w a) : + (∑ a ∈ distanceShell d 1, ((1 / 4 : ℝ) - w a)) ≤ + 2 * (∑ a ∈ distanceShell d 0, w a) := by + have hpoint := twice_mass_sub_neighbor_le_distance d w hw + rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] + linarith + +/-- Restricting the nonnegative deficits to any chosen neighbor subset gives +the counting bound needed before applying the anticommutator identity. -/ +theorem selected_neighbor_card_le_eight_mass (d : α → ℕ) (w : α → ℝ) + (s : Finset α) (hs : s ⊆ distanceShell d 1) + (hw : ∀ a, 0 ≤ w a) + (hcap : ∀ a ∈ distanceShell d 1, w a ≤ (1 / 4 : ℝ)) + (htotal : (∑ a, w a) = ((distanceShell d 1).card : ℝ) / 4) + (henergy : (∑ a, (d a : ℝ) * w a) ≤ ∑ a, w a) : + (s.card : ℝ) ≤ 8 * ((∑ a ∈ distanceShell d 0, w a) + ∑ a ∈ s, w a) := by + have hrestrict := Finset.sum_le_sum_of_subset_of_nonneg hs + (fun a ha _ => sub_nonneg.mpr (hcap a ha)) + have hdeficit := neighbor_deficit_le_twice_zero_mass d w hw htotal henergy + have hmass : 0 ≤ ∑ a ∈ s, w a := Finset.sum_nonneg fun a _ => hw a + have hselected : (∑ a ∈ s, ((1 / 4 : ℝ) - w a)) = + (s.card : ℝ) / 4 - ∑ a ∈ s, w a := by + rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] + ring + rw [hselected] at hrestrict + linarith + +/-- On an equal-sign pair the anticommutator has four times the squared entry +mass. The diagonal is included as an equal-sign pair. -/ +theorem anticommutator_entry_sq_of_same_sign [DecidableEq ι] + (M : Matrix ι ι ℂ) (h : ι → ℝ) (hh : ∀ i, h i = 1 ∨ h i = -1) + (i j : ι) (hij : h i = h j) : + ‖(M * Matrix.diagonal (fun i => (h i : ℂ)) + + Matrix.diagonal (fun i => (h i : ℂ)) * M) i j‖ ^ 2 = + 4 * ‖M i j‖ ^ 2 := by + simp only [Matrix.add_apply, Matrix.mul_diagonal, Matrix.diagonal_mul] + rw [← hij] + have hfactor : M i j * (h i : ℂ) + (h i : ℂ) * M i j = + (2 : ℂ) * (h i : ℂ) * M i j := by ring + rw [hfactor] + have hnorm : ‖(h i : ℂ)‖ = 1 := by + rcases hh i with hi | hi <;> simp [hi] + rw [norm_mul, norm_mul, hnorm] + norm_num [mul_pow] + +/-- The diagonal and a disjoint set of equal-sign neighbor entries contribute +four times their mass to the Hilbert--Schmidt squared norm. -/ +theorem anticommutator_energy_ge_selected [DecidableEq ι] + (ρ : ι → ι → ℕ) (hzero : ∀ i j, ρ i j = 0 → i = j) + (M : Matrix ι ι ℂ) (h : ι → ℝ) (hh : ∀ i, h i = 1 ∨ h i = -1) + (s : Finset (ι × ι)) + (hs : s ⊆ distanceShell (fun p : ι × ι => ρ p.1 p.2) 1) + (hsign : ∀ p ∈ s, h p.1 = h p.2) : + 4 * ((∑ p ∈ distanceShell (fun p : ι × ι => ρ p.1 p.2) 0, + ‖M p.1 p.2‖ ^ 2) + ∑ p ∈ s, ‖M p.1 p.2‖ ^ 2) ≤ + hsNormSq (M * Matrix.diagonal (fun i => (h i : ℂ)) + + Matrix.diagonal (fun i => (h i : ℂ)) * M) := by + classical + let D := distanceShell (fun p : ι × ι => ρ p.1 p.2) 0 + let T := M * Matrix.diagonal (fun i => (h i : ℂ)) + + Matrix.diagonal (fun i => (h i : ℂ)) * M + have hdisj : Disjoint D s := by + apply Finset.disjoint_left.mpr + intro p hpD hps + have h0 : ρ p.1 p.2 = 0 := by simpa only [D, mem_distanceShell] using hpD + have h1 : ρ p.1 p.2 = 1 := by simpa only [mem_distanceShell] using hs hps + omega + have hsame : ∀ p ∈ D ∪ s, h p.1 = h p.2 := by + intro p hp + rcases Finset.mem_union.mp hp with hpD | hps + · have h0 : ρ p.1 p.2 = 0 := by simpa only [D, mem_distanceShell] using hpD + rw [hzero _ _ h0] + · exact hsign p hps + have hentries : (∑ p ∈ D ∪ s, 4 * ‖M p.1 p.2‖ ^ 2) = + ∑ p ∈ D ∪ s, ‖T p.1 p.2‖ ^ 2 := by + apply Finset.sum_congr rfl + intro p hp + exact (anticommutator_entry_sq_of_same_sign M h hh p.1 p.2 (hsame p hp)).symm + have hsubset : (∑ p ∈ D ∪ s, ‖T p.1 p.2‖ ^ 2) ≤ + ∑ p : ι × ι, ‖T p.1 p.2‖ ^ 2 := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun p _ _ => sq_nonneg ‖T p.1 p.2‖) + have hsplit : (∑ p ∈ D ∪ s, 4 * ‖M p.1 p.2‖ ^ 2) = + 4 * ((∑ p ∈ D, ‖M p.1 p.2‖ ^ 2) + ∑ p ∈ s, ‖M p.1 p.2‖ ^ 2) := by + rw [Finset.sum_union hdisj, ← Finset.mul_sum, ← Finset.mul_sum, mul_add] + rw [← hentries, hsplit] at hsubset + simpa only [D, T, hsNormSq, Fintype.sum_prod_type] using hsubset + +/-- Abstract edge recovery from the exact finite matrix energy hypotheses. +The chosen set may be any subset of constant-sign distance-one pairs. -/ +theorem edge_recovery_for_subset [DecidableEq ι] + (ρ : ι → ι → ℕ) (hzero : ∀ i j, ρ i j = 0 → i = j) + (M : Matrix ι ι ℂ) (h : ι → ℝ) (hh : ∀ i, h i = 1 ∨ h i = -1) + (s : Finset (ι × ι)) + (hs : s ⊆ distanceShell (fun p : ι × ι => ρ p.1 p.2) 1) + (hsign : ∀ p ∈ s, h p.1 = h p.2) + (hcap : ∀ i j, ρ i j = 1 → ‖M i j‖ ^ 2 ≤ (1 / 4 : ℝ)) + (htotal : hsNormSq M = + ((distanceShell (fun p : ι × ι => ρ p.1 p.2) 1).card : ℝ) / 4) + (henergy : (∑ i, ∑ j, (ρ i j : ℝ) * ‖M i j‖ ^ 2) ≤ hsNormSq M) : + (s.card : ℝ) ≤ 2 * hsNormSq + (M * Matrix.diagonal (fun i => (h i : ℂ)) + + Matrix.diagonal (fun i => (h i : ℂ)) * M) := by + have hcount := selected_neighbor_card_le_eight_mass + (fun p : ι × ι => ρ p.1 p.2) (fun p => ‖M p.1 p.2‖ ^ 2) s hs + (fun p => sq_nonneg _) (fun p hp => hcap p.1 p.2 (by simpa only [mem_distanceShell] using hp)) + (by simpa only [hsNormSq, Fintype.sum_prod_type] using htotal) + (by simpa only [hsNormSq, Fintype.sum_prod_type] using henergy) + have hanti := anticommutator_energy_ge_selected ρ hzero M h hh s hs hsign + linarith + +/-- The edge-recovery inequality on the Boolean cube, from the three +matrix facts established by the grading and commutator constructions. -/ +theorem edge_recovery {n : ℕ} (M : Matrix (Cube n) (Cube n) ℂ) + (h : Cube n → ℝ) (hh : ∀ x, h x = 1 ∨ h x = -1) + (htotal : hsNormSq M = (n : ℝ) * (2 : ℝ) ^ n / 4) + (hdistance : (∑ x, ∑ y, (hammingDist x y : ℝ) * ‖M x y‖ ^ 2) ≤ hsNormSq M) + (hcap : ∀ x y, x ≠ y → ‖M x y‖ ^ 2 ≤ (1 / 4 : ℝ)) : + ((orderedConstantEdges h).card : ℝ) ≤ + 2 * hsNormSq (M * Matrix.diagonal (fun x => (h x : ℂ)) + + Matrix.diagonal (fun x => (h x : ℂ)) * M) := by + classical + apply edge_recovery_for_subset (fun x y : Cube n => hammingDist x y) + (fun _ _ hxy => hammingDist_eq_zero.mp hxy) M h hh (orderedConstantEdges h) + · exact Finset.filter_subset _ _ + · intro p hp + exact (Finset.mem_filter.mp hp).2 + · intro x y hxy + apply hcap x y + intro heq + subst y + simp only [hammingDist_self, Nat.zero_ne_one] at hxy + · change hsNormSq M = ((orderedNeighborPairs n).card : ℝ) / 4 + rw [card_orderedNeighborPairs] + simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] using htotal + · exact hdistance + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/FiniteCoupling.lean b/lean/OAI/Combinatorics/GotsmanLinial/FiniteCoupling.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3ef40735d0551b3d680d9c4e67e0e8f120fabd8 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/FiniteCoupling.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.GotsmanLinial.ScalarIncrements +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# A finite one-sided coupling estimate + +This is a finite weighted probabilistic estimate. Equal +marginals are expressed as equality of the weighted expectations of every +real function. The increment bound is required only on the support of the +nonnegative probability weights. +-/ + +open scoped BigOperators + +namespace LeanBlast.GotsmanLinial + +variable {Ω : Type*} [Fintype Ω] + +/-- Weighted Cauchy--Schwarz bounds the first absolute moment by a bound on +the second moment. Zero weights are allowed. -/ +theorem weighted_abs_le_of_second_moment (w f : Ω → ℝ) (σ : ℝ) + (hw : ∀ i, 0 ≤ w i) (hprob : ∑ i, w i = 1) (hσ : 0 ≤ σ) + (hsecond : ∑ i, w i * (f i) ^ 2 ≤ σ ^ 2) : + ∑ i, w i * |f i| ≤ σ := by + have hcs : (∑ i, w i * |f i|) ^ 2 ≤ + (∑ i, w i) * ∑ i, w i * (f i) ^ 2 := by + apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul + · intro i _ + exact hw i + · intro i _ + exact mul_nonneg (hw i) (sq_nonneg (f i)) + · intro i _ + apply le_of_eq + rw [mul_pow, sq_abs] + ring + rw [hprob, one_mul] at hcs + have hnonneg : 0 ≤ ∑ i, w i * |f i| := + Finset.sum_nonneg (fun i _ => mul_nonneg (hw i) (abs_nonneg (f i))) + nlinarith + +/-- A weighted mean-zero variable has absolute first moment twice the first +moment of its positive part. This identity does not need positivity of the weights. -/ +theorem weighted_abs_eq_twice_positive_part (w z : Ω → ℝ) + (hzero : ∑ i, w i * z i = 0) : + ∑ i, w i * |z i| = 2 * ∑ i, w i * max (z i) 0 := by + calc + ∑ i, w i * |z i| = + (∑ i, w i * |z i|) + ∑ i, w i * z i := by rw [hzero, add_zero] + _ = ∑ i, (w i * |z i| + w i * z i) := by rw [Finset.sum_add_distrib] + _ = ∑ i, 2 * (w i * max (z i) 0) := by + apply Finset.sum_congr rfl + intro i _ + by_cases hi : 0 ≤ z i + · rw [abs_of_nonneg hi, max_eq_left hi] + ring + · have hi' : z i ≤ 0 := (lt_of_not_ge hi).le + rw [abs_of_nonpos hi', max_eq_right hi'] + ring + _ = 2 * ∑ i, w i * max (z i) 0 := by rw [Finset.mul_sum] + +/-- The finite one-sided coupling lemma: identical marginals and an upper +bound `a` on `V - U` bound the mean square displacement by `8 * a * σ`. + +The center `m` may be arbitrary. Taking it to be the common mean recovers the +variance bound with variance `σ²`; only the displayed second moment is used. -/ +theorem finite_one_sided_coupling_bound (w U V : Ω → ℝ) (m σ a : ℝ) + (hw : ∀ i, 0 ≤ w i) (hprob : ∑ i, w i = 1) + (hsame : ∀ φ : ℝ → ℝ, ∑ i, w i * φ (U i) = ∑ i, w i * φ (V i)) + (hσ : 0 ≤ σ) (ha : 0 ≤ a) + (hvariance : ∑ i, w i * (U i - m) ^ 2 = σ ^ 2) + (hstep : ∀ i, w i ≠ 0 → V i - U i ≤ a) : + ∑ i, w i * (U i - V i) ^ 2 ≤ 8 * a * σ := by + let z : Ω → ℝ := fun i => couplingPotential m (V i) - couplingPotential m (U i) + have hz : ∑ i, w i * z i = 0 := by + simp only [z, mul_sub, Finset.sum_sub_distrib] + rw [hsame (couplingPotential m), sub_self] + have habs := weighted_abs_eq_twice_positive_part w z hz + have hU : ∑ i, w i * |U i - m| ≤ σ := + weighted_abs_le_of_second_moment w (fun i => U i - m) σ hw hprob hσ hvariance.le + have hV : ∑ i, w i * |V i - m| ≤ σ := by + rw [← hsame (fun t => |t - m|)] + exact hU + have hpositive : ∑ i, w i * max (z i) 0 ≤ a * σ := by + calc + ∑ i, w i * max (z i) 0 ≤ + ∑ i, w i * (a / 2 * (|U i - m| + |V i - m|)) := by + apply Finset.sum_le_sum + intro i _ + by_cases hi : w i = 0 + · simp only [hi, zero_mul, le_refl] + · exact mul_le_mul_of_nonneg_left + (max_couplingPotential_increment_le m a (U i) (V i) ha (hstep i hi)) + (hw i) + _ = a / 2 * ((∑ i, w i * |U i - m|) + ∑ i, w i * |V i - m|) := by + rw [← Finset.sum_add_distrib, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + _ ≤ a / 2 * (σ + σ) := + mul_le_mul_of_nonneg_left (add_le_add hU hV) (div_nonneg ha (by norm_num)) + _ = a * σ := by ring + have hsquare : ∑ i, w i * (U i - V i) ^ 2 ≤ 4 * ∑ i, w i * |z i| := by + calc + ∑ i, w i * (U i - V i) ^ 2 ≤ ∑ i, w i * (4 * |z i|) := by + apply Finset.sum_le_sum + intro i _ + apply mul_le_mul_of_nonneg_left _ (hw i) + dsimp only [z] + rw [abs_sub_comm] + exact sq_sub_le_four_mul_abs_potential_sub m (U i) (V i) + _ = 4 * ∑ i, w i * |z i| := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + calc + ∑ i, w i * (U i - V i) ^ 2 ≤ 4 * ∑ i, w i * |z i| := hsquare + _ = 8 * ∑ i, w i * max (z i) 0 := by rw [habs]; ring + _ ≤ 8 * (a * σ) := mul_le_mul_of_nonneg_left hpositive (by norm_num) + _ = 8 * a * σ := by ring + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/GradingShift.lean b/lean/OAI/Combinatorics/GotsmanLinial/GradingShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b2199c9a04b9374758d26005400ff1028f97f7d --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/GradingShift.lean @@ -0,0 +1,159 @@ +import OAI.Combinatorics.GotsmanLinial.WeightedGrading +import OAI.Combinatorics.GotsmanLinial.ProjectionBlocks +import OAI.Combinatorics.GotsmanLinial.CoordinateDegree + +namespace OAI + +/-! +# A degree shift is tridiagonal in the associated orthogonal grading + +These lemmas retain the degree-shift premise explicitly. The cube application +discharges it using coordinate multiplication and the weighted Fourier flag. +-/ + +noncomputable section + +namespace LeanBlast.GotsmanLinial + +section FiniteFlag + +variable {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] + [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] + +local instance : CompleteSpace E := FiniteDimensional.complete 𝕜 E + +/-- An operator that raises the flag index by at most one has no blocks +strictly above the first off-diagonal. -/ +theorem flagProjection_mul_shift_eq_zero + (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) (Z : E →L[𝕜] E) + (hshift : ∀ k x, x ∈ K k → Z x ∈ K (k + 1)) + {r s : ℕ} (hrs : r + 1 < s) : + flagProjection K s * Z * flagProjection K r = 0 := by + ext x + change flagProjection K s (Z (flagProjection K r x)) = 0 + apply flagProjection_apply_eq_zero_of_mem_prev + exact hK (by omega : r + 1 + 1 ≤ s) + (hshift (r + 1) (flagProjection K r x) (flagProjection_apply_mem_next K r x)) + +/-- Self-adjointness gives the other half of the band by taking adjoints. -/ +theorem flagProjection_tridiagonal + (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) (Z : E →L[𝕜] E) + (hZ : IsSelfAdjoint Z) + (hshift : ∀ k x, x ∈ K k → Z x ∈ K (k + 1)) + {r s : ℕ} (hrs : r + 1 < s ∨ s + 1 < r) : + flagProjection K s * Z * flagProjection K r = 0 := by + rcases hrs with hrs | hsr + · exact flagProjection_mul_shift_eq_zero K hK Z hshift hrs + · have h := congrArg star (flagProjection_mul_shift_eq_zero K hK Z hshift hsr) + simpa only [star_mul, star_zero, (flagProjection_isSelfAdjoint K r).star_eq, + (flagProjection_isSelfAdjoint K s).star_eq, hZ.star_eq, mul_assoc] using h + +/-- The band property is preserved by taking matrices or any other ring +representation of the operator algebra. -/ +theorem map_flagProjection_tridiagonal + {A : Type*} [Ring A] (F : (E →L[𝕜] E) →+* A) + (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) (Z : E →L[𝕜] E) + (hZ : IsSelfAdjoint Z) + (hshift : ∀ k x, x ∈ K k → Z x ∈ K (k + 1)) + {r s : ℕ} (hrs : r + 1 < s ∨ s + 1 < r) : + F (flagProjection K s) * F Z * F (flagProjection K r) = 0 := by + rw [← map_mul, ← map_mul, flagProjection_tridiagonal K hK Z hZ hshift hrs, map_zero] + +omit [FiniteDimensional 𝕜 E] in +/-- Commutation transports a degree-shift statement through a weight map. -/ +theorem shift_mem_map_of_commute + (V : ℕ → Submodule 𝕜 E) (D Z : E →ₗ[𝕜] E) + (hcommute : ∀ x, Z (D x) = D (Z x)) + (hshift : ∀ k x, x ∈ V k → Z x ∈ V (k + 1)) + (k : ℕ) {x : E} (hx : x ∈ (V k).map D) : + Z x ∈ (V (k + 1)).map D := by + rcases hx with ⟨y, hy, rfl⟩ + exact ⟨Z y, hshift k y hy, (hcommute y).symm⟩ + +end FiniteFlag + +section MatrixFlag + +variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [FiniteDimensional ℂ E] [Fintype ι] [DecidableEq ι] + +local instance : CompleteSpace E := FiniteDimensional.complete ℂ E + +/-- The concrete matrix form consumed by the commutator estimate. -/ +theorem operatorMatrix_flagProjection_tridiagonal + (b : OrthonormalBasis ι ℂ E) + (K : ℕ → Submodule ℂ E) (hK : Monotone K) (Z : E →L[ℂ] E) + (hZ : IsSelfAdjoint Z) + (hshift : ∀ k x, x ∈ K k → Z x ∈ K (k + 1)) + (n : ℕ) (r s : Fin (n + 1)) + (hrs : r.val + 1 < s.val ∨ s.val + 1 < r.val) : + operatorMatrix b (flagProjection K s.val) * operatorMatrix b Z * + operatorMatrix b (flagProjection K r.val) = 0 := by + exact map_flagProjection_tridiagonal (operatorMatrixEquiv b).toRingHom + K hK Z hZ hshift hrs + +end MatrixFlag + +section WeightedCube + +variable {n : ℕ} + +/-- Coordinate signs commute with the actual positive square-root weight. -/ +theorem coordinateMultiplier_sqrtWeight_commute + (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) (i : Fin n) + (a : EuclideanSpace ℂ (Cube n)) : + coordinateMultiplier i (sqrtWeightEquiv w hw a) = + sqrtWeightEquiv w hw (coordinateMultiplier i a) := by + ext x + simp only [coordinateMultiplier_apply, sqrtWeightEquiv_apply] + exact mul_left_comm _ _ _ + +/-- The actual weighted Fourier flag retains the one-step coordinate shift. -/ +theorem coordinateMultiplier_weightedFlag_shift + (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) (i : Fin n) : + ∀ k (a : EuclideanSpace ℂ (Cube n)), + a ∈ transportFlag (sqrtWeightEquiv w hw) (fourierFlag n) k → + coordinateMultiplier i a ∈ + transportFlag (sqrtWeightEquiv w hw) (fourierFlag n) (k + 1) := by + intro k a ha + exact shift_mem_map_of_commute (fourierFlag n) (sqrtWeightEquiv w hw).toLinearMap + (coordinateMultiplier i).toLinearMap + (coordinateMultiplier_sqrtWeight_commute w hw i) + (coordinateMultiplier_fourierFlag_shift i) k ha + +/-- Tridiagonality for the actually constructed weighted Fourier projections, +expressed in an arbitrary orthonormal coordinate system. -/ +theorem weightedFlag_operatorMatrix_tridiagonal + (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (b : OrthonormalBasis (Cube n) ℂ (EuclideanSpace ℂ (Cube n))) + (i : Fin n) (r s : Fin (n + 1)) + (hrs : r.val + 1 < s.val ∨ s.val + 1 < r.val) : + flagProjectionMatrix b (transportFlag (sqrtWeightEquiv w hw) (fourierFlag n)) s.val * + operatorMatrix b (coordinateMultiplier i) * + flagProjectionMatrix b (transportFlag (sqrtWeightEquiv w hw) (fourierFlag n)) r.val = 0 := by + exact operatorMatrix_flagProjection_tridiagonal b + (transportFlag (sqrtWeightEquiv w hw) (fourierFlag n)) + (transportFlag_monotone _ _ (fourierFlag_mono n)) + (coordinateMultiplier i) (coordinateMultiplier_isSelfAdjoint i) + (coordinateMultiplier_weightedFlag_shift w hw i) n r s hrs + +/-- The raw coordinate-sign matrices are tridiagonal for the actual weighted +Fourier projection family. There is no remaining degree-shift hypothesis. -/ +theorem weightedProjectionMatrix_tridiagonal + (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (i : Fin n) (r s : Fin (n + 1)) + (hrs : r.val + 1 < s.val ∨ s.val + 1 < r.val) : + weightedProjectionMatrix w hw s * coordinateSignMatrix i * + weightedProjectionMatrix w hw r = 0 := by + simpa only [weightedProjectionMatrix, weightedFourierFlag, coordinateMultiplier, + signMultiplier, operatorMatrix_toEuclideanCLM, coordinateSignMatrix] using + weightedFlag_operatorMatrix_tridiagonal w hw + (EuclideanSpace.basisFun (Cube n) ℂ) i r s hrs + +end WeightedCube + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/HilbertSchmidt.lean b/lean/OAI/Combinatorics/GotsmanLinial/HilbertSchmidt.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca6522116e8283cded331a615b009a427d9fbe19 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/HilbertSchmidt.lean @@ -0,0 +1,128 @@ +import Mathlib.Analysis.Complex.Basic +import Mathlib.LinearAlgebra.Matrix.Trace + +namespace OAI + +open scoped BigOperators ComplexConjugate + +namespace LeanBlast.GotsmanLinial + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +/-- The Hilbert--Schmidt norm squared for the counting inner product. +This explicit entry sum does not use any norm instance on matrices. -/ +noncomputable def hsNormSq (A : Matrix ι κ ℂ) : ℝ := + ∑ i, ∑ j, ‖A i j‖ ^ 2 + +theorem hsNormSq_nonneg (A : Matrix ι κ ℂ) : 0 ≤ hsNormSq A := by + exact Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => sq_nonneg _ + +@[simp] theorem hsNormSq_zero : hsNormSq (0 : Matrix ι κ ℂ) = 0 := by + simp [hsNormSq] + +theorem hsNormSq_smul (c : ℂ) (A : Matrix ι κ ℂ) : + hsNormSq (c • A) = ‖c‖ ^ 2 * hsNormSq A := by + simp [hsNormSq, mul_pow, Finset.mul_sum] + +theorem hsNormSq_real_smul (c : ℝ) (A : Matrix ι κ ℂ) : + hsNormSq ((c : ℂ) • A) = c ^ 2 * hsNormSq A := by + rw [hsNormSq_smul] + simp + +@[simp] theorem hsNormSq_conjTranspose (A : Matrix ι κ ℂ) : + hsNormSq A.conjTranspose = hsNormSq A := by + simp only [hsNormSq, Matrix.conjTranspose_apply, norm_star] + exact Finset.sum_comm + +theorem ofReal_sq_norm (z : ℂ) : (↑(‖z‖ ^ 2) : ℂ) = star z * z := by + rw [← Complex.normSq_eq_norm_sq, Complex.normSq_eq_conj_mul_self, Complex.star_def] + +private theorem ofReal_fintype_sum (f : ι → ℝ) : + (↑(∑ i, f i) : ℂ) = ∑ i, (f i : ℂ) := + map_sum Complex.ofRealHom f Finset.univ + +omit [Fintype κ] in +theorem ofReal_sum_sq_norm_column (A : Matrix ι κ ℂ) (j : κ) : + (↑(∑ i, ‖A i j‖ ^ 2) : ℂ) = (A.conjTranspose * A) j j := by + rw [ofReal_fintype_sum] + simp only [Matrix.mul_apply, Matrix.conjTranspose_apply] + exact Finset.sum_congr rfl fun i _ => ofReal_sq_norm _ + +theorem ofReal_hsNormSq (A : Matrix ι κ ℂ) : + (hsNormSq A : ℂ) = Matrix.trace (A.conjTranspose * A) := by + rw [hsNormSq, Finset.sum_comm] + rw [ofReal_fintype_sum] + simp only [Matrix.trace, Matrix.diag_apply] + exact Finset.sum_congr rfl fun j _ => ofReal_sum_sq_norm_column A j + +theorem hsNormSq_eq_re_trace (A : Matrix ι κ ℂ) : + hsNormSq A = (Matrix.trace (A.conjTranspose * A)).re := by + exact congrArg Complex.re (ofReal_hsNormSq A) + +theorem hsNormSq_eq_sum_columns (A : Matrix ι κ ℂ) : + hsNormSq A = ∑ j, ∑ i, ‖A i j‖ ^ 2 := by + exact Finset.sum_comm + +omit [Fintype κ] in +theorem sum_sq_norm_column_eq_re (A : Matrix ι κ ℂ) (j : κ) : + ∑ i, ‖A i j‖ ^ 2 = ((A.conjTranspose * A) j j).re := by + exact congrArg Complex.re (ofReal_sum_sq_norm_column A j) + +theorem hsNormSq_mul_left_of_unitary [DecidableEq ι] + (U : Matrix ι ι ℂ) (A : Matrix ι κ ℂ) (hU : U.conjTranspose * U = 1) : + hsNormSq (U * A) = hsNormSq A := by + rw [hsNormSq_eq_re_trace, hsNormSq_eq_re_trace] + congr 2 + calc + (U * A).conjTranspose * (U * A) = A.conjTranspose * + (U.conjTranspose * U) * A := by + simp only [Matrix.conjTranspose_mul, Matrix.mul_assoc] + _ = A.conjTranspose * A := by rw [hU, Matrix.mul_one] + +theorem hsNormSq_mul_right_of_unitary [DecidableEq κ] + (A : Matrix ι κ ℂ) (U : Matrix κ κ ℂ) (hU : U * U.conjTranspose = 1) : + hsNormSq (A * U) = hsNormSq A := by + rw [← hsNormSq_conjTranspose (A * U), Matrix.conjTranspose_mul] + rw [hsNormSq_mul_left_of_unitary U.conjTranspose A.conjTranspose] + · exact hsNormSq_conjTranspose A + · simpa using hU + +@[simp] theorem hsNormSq_diagonal [DecidableEq ι] (d : ι → ℂ) : + hsNormSq (Matrix.diagonal d) = ∑ i, ‖d i‖ ^ 2 := by + simp [hsNormSq, Matrix.diagonal_apply, apply_ite] + +@[simp] theorem hsNormSq_one [DecidableEq ι] : + hsNormSq (1 : Matrix ι ι ℂ) = Fintype.card ι := by + rw [hsNormSq_eq_re_trace] + simp + +theorem hsNormSq_of_unitary [DecidableEq ι] (U : Matrix ι ι ℂ) + (hU : U.conjTranspose * U = 1) : hsNormSq U = Fintype.card ι := by + rw [hsNormSq_eq_re_trace, hU] + simp + +theorem hsNormSq_diagonal_of_norm_one [DecidableEq ι] (d : ι → ℂ) + (hd : ∀ i, ‖d i‖ = 1) : + hsNormSq (Matrix.diagonal d) = Fintype.card ι := by + simp [hsNormSq_diagonal, hd] + +theorem hsNormSq_projection (P : Matrix ι ι ℂ) + (hself : P.conjTranspose = P) (hidem : P * P = P) : + hsNormSq P = (Matrix.trace P).re := by + rw [hsNormSq_eq_re_trace, hself, hidem] + +theorem sum_sq_norm_column_of_unitary [DecidableEq ι] + (U : Matrix ι ι ℂ) (hU : U.conjTranspose * U = 1) (j : ι) : + ∑ i, ‖U i j‖ ^ 2 = 1 := by + rw [sum_sq_norm_column_eq_re, hU] + simp + +theorem sq_norm_entry_le_one_of_unitary [DecidableEq ι] + (U : Matrix ι ι ℂ) (hU : U.conjTranspose * U = 1) (i j : ι) : + ‖U i j‖ ^ 2 ≤ 1 := by + rw [← sum_sq_norm_column_of_unitary U hU j] + exact Finset.single_le_sum (fun k _ => sq_nonneg ‖U k j‖) (Finset.mem_univ i) + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/Main.lean b/lean/OAI/Combinatorics/GotsmanLinial/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ab67c81020533ebca1b16d94a863c8d176e31ba --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/Main.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.GotsmanLinial.Statement +import OAI.Combinatorics.GotsmanLinial.BlockCoupling +import OAI.Combinatorics.GotsmanLinial.Commutator +import OAI.Combinatorics.GotsmanLinial.CubeOperators +import OAI.Combinatorics.GotsmanLinial.EdgeRecovery +import OAI.Combinatorics.GotsmanLinial.GradingShift +import OAI.Combinatorics.GotsmanLinial.BlockVanishing +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Assembly of the Gotsman--Linial average-sensitivity bound + +The first lemmas are explicitly conditional assembly bridges. The final +theorems discharge their matrix and counting hypotheses using the concrete +weighted Boolean-cube grading and a sign-preserving constant perturbation. +-/ + +namespace LeanBlast.GotsmanLinial + +open scoped BigOperators + +/-- The two analytic constants combine to the constant `8` after +normalizing by the number of cube vertices. This is only a scalar bridge. -/ +theorem normalized_edge_bound {N C T a : ℝ} (hN : 0 < N) + (hedge : C ≤ 2 * T) (henergy : T ≤ 4 * a * N) : + C / N ≤ 8 * a := by + apply (div_le_iff₀ hN).mpr + calc + C ≤ 2 * T := hedge + _ ≤ 2 * (4 * a * N) := mul_le_mul_of_nonneg_left henergy (by norm_num) + _ = 8 * a * N := by ring + +/-- Convert a counted-edge identity, edge recovery, and an anticommutator +energy estimate into the desired sensitivity inequality. The counting and energy premises are explicit. -/ +theorem sensitivity_bound_of_counting_energy {n d : ℕ} + (f : Cube n → ℝ) (C T : ℝ) + (hcount : averageSensitivity f = C / (2 : ℝ) ^ n) + (hedge : C ≤ 2 * T) + (henergy : T ≤ 4 * ((d : ℝ) * Real.sqrt (n : ℝ)) * (2 : ℝ) ^ n) : + averageSensitivity f ≤ 8 * (d : ℝ) * Real.sqrt (n : ℝ) := by + rw [hcount] + simpa only [mul_assoc] using + normalized_edge_bound (pow_pos (by norm_num : (0 : ℝ) < 2) n) hedge henergy + +/-- The finite-matrix bound assuming an orthogonal projection family with +binomial multiplicities, coordinate tridiagonality, and low-block vanishing. -/ +theorem sensitivity_bound_of_cube_grading {n d : ℕ} + (f : Cube n → ℝ) (hf : ∀ x, f x = 1 ∨ f x = -1) + (P : Fin (n + 1) → Matrix (Cube n) (Cube n) ℂ) + (hP : OrthogonalProjectionFamily P) + (htrace : ∀ k, (Matrix.trace (P k)).re = (n.choose k.val : ℝ)) + (htri : ∀ i : Fin n, BlockTridiagonal P (coordinateSignMatrix i)) + (hvanish : ∀ r s : Fin (n + 1), r.val + s.val < n - d → + P s * signMatrix (fun x => fullParity x * f x) * P r = 0) : + averageSensitivity f ≤ 8 * (d : ℝ) * Real.sqrt (n : ℝ) := by + classical + let h : Cube n → ℝ := fun x => fullParity x * f x + let H : Matrix (Cube n) (Cube n) ℂ := signMatrix h + let M : Matrix (Cube n) (Cube n) ℂ := centeredGrading P + have hh (x : Cube n) : h x = 1 ∨ h x = -1 := parity_twist_cases hf x + have htotal : hsNormSq M = (n : ℝ) * (2 : ℝ) ^ n / 4 := by + change hsNormSq (centeredGrading P) = _ + rw [hsNormSq_centeredGrading_trace hP] + simp_rw [htrace] + simpa only [mul_comm] using sum_choose_centered_sq n + have hcoordinate (i : Fin n) : + hsNormSq (M * coordinateSignMatrix i - coordinateSignMatrix i * M) ≤ (2 : ℝ) ^ n := by + simpa only [M, card_cube, Nat.cast_pow, Nat.cast_ofNat] using + hsNormSq_centeredGrading_commutator_le_card hP (coordinateSignMatrix i) + (htri i) (coordinateSignMatrix_unitary i) + have hdistance : + (∑ x : Cube n, ∑ y : Cube n, (hammingDist x y : ℝ) * ‖M x y‖ ^ 2) ≤ hsNormSq M := by + rw [htotal] + exact distance_energy_le_of_coordinate_commutator_bound M hcoordinate + have hcap (x y : Cube n) (hxy : x ≠ y) : ‖M x y‖ ^ 2 ≤ (1 : ℝ) / 4 := by + apply off_diagonal_sq_norm_le_quarter_of_commutator_bound M _ x y hxy + intro i a b + exact sq_norm_centeredGrading_commutator_entry_le_one hP (coordinateSignMatrix i) + (htri i) (coordinateSignMatrix_unitary i) a b + have hedge : ((orderedConstantEdges h).card : ℝ) ≤ + 2 * hsNormSq (M * H + H * M) := edge_recovery M h hh htotal hdistance hcap + have henergy : hsNormSq (M * H + H * M) ≤ + 4 * (d : ℝ) * Real.sqrt (n : ℝ) * (2 : ℝ) ^ n := + hsNormSq_centeredGrading_anticommutator_le_of_trace n d P hP H + (signMatrix_conjTranspose_mul h hh) (signMatrix_mul_conjTranspose h hh) htrace hvanish + apply sensitivity_bound_of_counting_energy f ((orderedConstantEdges h).card : ℝ) + (hsNormSq (M * H + H * M)) (averageSensitivity_eq_parity_edges hf) hedge + simpa only [mul_assoc] using henergy + +/-- The bound for a polynomial without cube zeros. The projection +family and both block-vanishing properties are constructed from its absolute +value, rather than retained as hypotheses. -/ +theorem polynomialThreshold_averageSensitivity_le_of_nonzero {n d : ℕ} + (p : MvPolynomial (Fin n) ℝ) (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) + (hnz : ∀ x : Cube n, polynomialValue p x ≠ 0) : + averageSensitivity (polynomialThreshold p) ≤ 8 * (d : ℝ) * Real.sqrt (n : ℝ) := by + let w : Cube n → ℝ := fun x => |polynomialValue p x| + have hw (x : Cube n) : 0 < w x := abs_pos.mpr (hnz x) + apply sensitivity_bound_of_cube_grading (polynomialThreshold p) + (fun x => thresholdSign_cases (polynomialValue p x)) + (weightedProjectionMatrix w hw) + (weightedProjectionMatrix_family w hw) + (weightedProjectionMatrix_trace_re w hw) + · intro i + exact weightedProjectionMatrix_tridiagonal w hw i + · intro r s hrs + exact weightedProjectionMatrix_block_eq_zero_of_polynomial_degree p hp hd hnz r s hrs + +/-- Every real multilinear polynomial of degree at most `d` has average +sensitivity at most `8*d*sqrt(n)`, including cube zeros under `sign(0)=1`. +The argument in fact covers all natural `n` and `d`. -/ +theorem polynomialThreshold_averageSensitivity_le {n d : ℕ} + (p : MvPolynomial (Fin n) ℝ) (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) : + averageSensitivity (polynomialThreshold p) ≤ 8 * (d : ℝ) * Real.sqrt (n : ℝ) := by + obtain ⟨q, hq, hqd, hqnz, hqf⟩ := exists_nonzero_polynomial_same_threshold hp hd + rw [← hqf] + exact polynomialThreshold_averageSensitivity_le_of_nonzero q hq hqd hqnz + +/-- The average-sensitivity bound for `1 ≤ d ≤ n`, without auxiliary +construction hypotheses. -/ +theorem gotsmanLinialStatement : GotsmanLinialStatement := by + intro n d _ _ _ p hp hd + exact polynomialThreshold_averageSensitivity_le p hp hd + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/Model.lean b/lean/OAI/Combinatorics/GotsmanLinial/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe42ea84d4bf21bee7da1491674254a125f46c5b --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/Model.lean @@ -0,0 +1,76 @@ +import Mathlib.Algebra.MvPolynomial.Degrees +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Analysis.Real.Sqrt +import Mathlib.Tactic.NormNum + +namespace OAI + +/-! +# Polynomial thresholds and average sensitivity + +The Boolean cube encodes the sign cube `{−1,1}^n`: +`false` represents `−1` and `true` represents `1`. The public statement +quantifies directly over real multilinear polynomials and uses uniform counting +probability, the convention `sign(0) = 1`, and the exact constant `8`. + +`GotsmanLinialStatement` is a proposition definition, not a proof of the bound. +-/ + +open scoped BigOperators + +namespace LeanBlast.GotsmanLinial + +/-- The sign cube `{−1,1}^n`, with Boolean coordinates encoding the signs. -/ +abbrev Cube (n : ℕ) := Fin n → Bool + +/-- Interpret a Boolean cube coordinate as the corresponding real sign. -/ +def cubeCoord {n : ℕ} (x : Cube n) (i : Fin n) : ℝ := + if x i then 1 else -1 + +/-- Reverse one coordinate of a cube vertex. -/ +def flip {n : ℕ} (i : Fin n) (x : Cube n) : Cube n := + Function.update x i (!(x i)) + +/-- The threshold convention assigns `1` at zero. -/ +noncomputable def thresholdSign (t : ℝ) : ℝ := + if 0 ≤ t then 1 else -1 + +/-- Vertices at which reversing coordinate `i` changes the function. -/ +noncomputable def sensitiveVertices {n : ℕ} (f : Cube n → ℝ) (i : Fin n) : + Finset (Cube n) := by + classical + exact Finset.univ.filter fun x => f x ≠ f (flip i x) + +/-- Number of ordered sensitive edges, indexed by their initial vertex and direction. -/ +noncomputable def sensitiveEdgeCount {n : ℕ} (f : Cube n → ℝ) : ℕ := + ∑ i : Fin n, (sensitiveVertices f i).card + +/-- Sum of the uniform probabilities that a coordinate flip changes `f`. -/ +noncomputable def averageSensitivity {n : ℕ} (f : Cube n → ℝ) : ℝ := + ∑ i : Fin n, ((sensitiveVertices f i).card : ℝ) / (2 : ℝ) ^ n + +/-- Every exponent in every supported monomial is at most one. -/ +def IsMultilinear {n : ℕ} (p : MvPolynomial (Fin n) ℝ) : Prop := + ∀ m ∈ p.support, ∀ i : Fin n, m i ≤ 1 + +/-- Evaluate a real polynomial at the signs represented by a cube vertex. -/ +noncomputable def polynomialValue {n : ℕ} (p : MvPolynomial (Fin n) ℝ) + (x : Cube n) : ℝ := + MvPolynomial.eval (cubeCoord x) p + +/-- The polynomial threshold function with the nonnegative-at-zero convention. -/ +noncomputable def polynomialThreshold {n : ℕ} (p : MvPolynomial (Fin n) ℝ) : + Cube n → ℝ := + fun x => thresholdSign (polynomialValue p x) + +/-- The average-sensitivity bound for positive dimension and degree at most the dimension. -/ +def GotsmanLinialStatement : Prop := + ∀ (n d : ℕ), 1 ≤ n → 1 ≤ d → d ≤ n → + ∀ p : MvPolynomial (Fin n) ℝ, + IsMultilinear p → p.totalDegree ≤ d → + averageSensitivity (polynomialThreshold p) ≤ 8 * (d : ℝ) * Real.sqrt (n : ℝ) + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/PolynomialDegree.lean b/lean/OAI/Combinatorics/GotsmanLinial/PolynomialDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7a007dbc813b47d1b5f4b658b60bc8075870ce9 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/PolynomialDegree.lean @@ -0,0 +1,251 @@ +import OAI.Combinatorics.GotsmanLinial.Walsh +import Mathlib.Basic.Complex.BigOperators + +namespace OAI + +/-! +# Polynomial degree and the Walsh filtration + +The polynomial lemmas concern real multilinear +`MvPolynomial`s. Restriction to the cube is justified by an explicit monomial +expansion rather than assumed as an alternate polynomial representation. +-/ + +open scoped BigOperators symmDiff + +namespace LeanBlast.GotsmanLinial + +noncomputable section + +variable {n d : ℕ} + +/-- Adding a constant preserves the multilinearity condition. -/ +theorem IsMultilinear.add_C {p : MvPolynomial (Fin n) ℝ} + (hp : IsMultilinear p) (c : ℝ) : IsMultilinear (p + MvPolynomial.C c) := by + classical + intro m hm i + rcases Finset.mem_union.mp (MvPolynomial.support_add hm) with hm | hm + · exact hp m hm i + · have hm0 : m = 0 := by + by_cases hc : c = 0 + · simp [hc] at hm + · simpa [MvPolynomial.support_C, hc] using hm + simp [hm0] + +/-- Adding a constant cannot violate an existing total-degree upper bound. -/ +theorem totalDegree_add_C_le {p : MvPolynomial (Fin n) ℝ} + (hd : p.totalDegree ≤ d) (c : ℝ) : + (p + MvPolynomial.C c).totalDegree ≤ d := by + exact (MvPolynomial.totalDegree_add _ _).trans (max_le hd (by simp)) + +/-- Every exponent occurring in a supported multilinear monomial is one. -/ +theorem IsMultilinear.exponent_eq_one {p : MvPolynomial (Fin n) ℝ} + (hp : IsMultilinear p) {m : Fin n →₀ ℕ} (hm : m ∈ p.support) + {i : Fin n} (hi : i ∈ m.support) : m i = 1 := by + exact Nat.le_antisymm (hp m hm i) + (Nat.one_le_iff_ne_zero.mpr (Finsupp.mem_support_iff.mp hi)) + +/-- A supported monomial has no more variables than the polynomial's total +degree. This estimate does not require multilinearity. -/ +theorem monomial_support_card_le_totalDegree {p : MvPolynomial (Fin n) ℝ} + {m : Fin n →₀ ℕ} (hm : m ∈ p.support) : m.support.card ≤ p.totalDegree := by + calc + m.support.card = ∑ _i ∈ m.support, 1 := Finset.card_eq_sum_ones _ + _ ≤ ∑ i ∈ m.support, m i := by + apply Finset.sum_le_sum + intro i hi + exact Nat.one_le_iff_ne_zero.mpr (Finsupp.mem_support_iff.mp hi) + _ ≤ p.totalDegree := MvPolynomial.le_totalDegree hm + +/-- Faithful evaluation of a multilinear polynomial as products over +the supports of its monomials. -/ +theorem polynomialValue_eq_multilinear_expansion {p : MvPolynomial (Fin n) ℝ} + (hp : IsMultilinear p) (x : Cube n) : + polynomialValue p x = + ∑ m ∈ p.support, p.coeff m * ∏ i ∈ m.support, cubeCoord x i := by + classical + unfold polynomialValue + rw [MvPolynomial.eval_eq] + apply Finset.sum_congr rfl + intro m hm + congr 1 + apply Finset.prod_congr rfl + intro i hi + rw [hp.exponent_eq_one hm hi, pow_one] + +/-- The same faithful expansion, with values regarded as complex numbers. -/ +theorem polynomialValue_walsh_expansion {p : MvPolynomial (Fin n) ℝ} + (hp : IsMultilinear p) (x : Cube n) : + (polynomialValue p x : ℂ) = + ∑ m ∈ p.support, ((p.coeff m : ℝ) : ℂ) * walshChar m.support x := by + rw [polynomialValue_eq_multilinear_expansion hp] + simp only [Complex.ofReal_sum, Complex.ofReal_mul, Complex.ofReal_prod, walshChar] + +/-- A character of degree at most `d` belongs to the corresponding filtration. -/ +theorem walshChar_mem_fourierSpace {S : Finset (Fin n)} (hS : S.card ≤ d) : + walshChar S ∈ fourierSpace n d := + Submodule.subset_span ⟨S, hS, rfl⟩ + +/-- The exact polynomial bridge into the complex Walsh filtration. -/ +theorem polynomialValue_mem_fourierSpace {p : MvPolynomial (Fin n) ℝ} + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) : + (fun x => (polynomialValue p x : ℂ)) ∈ fourierSpace n d := by + classical + have hsum : (∑ m ∈ p.support, ((p.coeff m : ℝ) : ℂ) • walshChar m.support) ∈ + fourierSpace n d := by + apply Submodule.sum_mem + intro m hm + exact Submodule.smul_mem _ _ + (walshChar_mem_fourierSpace ((monomial_support_card_le_totalDegree hm).trans hd)) + convert hsum using 1 + ext x + simpa only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul] using + polynomialValue_walsh_expansion hp x + +/-- Complex conjugation preserves Fourier degree, since each character is real. -/ +theorem fourierSpace_star {a : Cube n → ℂ} (ha : a ∈ fourierSpace n d) : + star a ∈ fourierSpace n d := by + induction ha using Submodule.span_induction with + | mem a ha => + obtain ⟨S, hS, rfl⟩ := ha + have hstar : star (walshChar S) = walshChar S := by + ext x + exact star_walshChar S x + rw [hstar] + exact walshChar_mem_fourierSpace hS + | zero => simpa only [star_zero] using (fourierSpace n d).zero_mem + | add a b _ _ ha hb => + simpa only [star_add] using (fourierSpace n d).add_mem ha hb + | smul c a _ ha => + simpa only [star_smul] using (fourierSpace n d).smul_mem (star c) ha + +/-- The filtration is multiplicative. The symmetric difference of two index +sets has cardinality at most the sum of their cardinalities. -/ +theorem fourierSpace_mul {r s : ℕ} {a b : Cube n → ℂ} + (ha : a ∈ fourierSpace n r) (hb : b ∈ fourierSpace n s) : + a * b ∈ fourierSpace n (r + s) := by + classical + induction ha, hb using Submodule.span_induction₂ with + | mem_mem a b ha hb => + obtain ⟨S, hS, rfl⟩ := ha + obtain ⟨T, hT, rfl⟩ := hb + have hST : (S ∆ T).card ≤ r + s := + (Finset.card_le_card Finset.symmDiff_subset_union).trans + ((Finset.card_union_le S T).trans (Nat.add_le_add hS hT)) + convert walshChar_mem_fourierSpace hST using 1 + ext x + exact walshChar_mul S T x + | zero_left b hb => simp + | zero_right a ha => simp + | add_left a b c _ _ _ ha hb => + simpa only [add_mul] using (fourierSpace n (r + s)).add_mem ha hb + | add_right a b c _ _ _ ha hb => + simpa only [mul_add] using (fourierSpace n (r + s)).add_mem ha hb + | smul_left c a b _ _ hab => + simpa only [smul_mul_assoc] using (fourierSpace n (r + s)).smul_mem c hab + | smul_right c a b _ _ hab => + simpa only [mul_smul_comm] using (fourierSpace n (r + s)).smul_mem c hab + +/-- The precise multiplication-conjugation rule used in the weighted pairing. -/ +theorem fourierSpace_conj_mul {r s : ℕ} {a b : Cube n → ℂ} + (ha : a ∈ fourierSpace n r) (hb : b ∈ fourierSpace n s) : + (fun x => star (b x) * a x) ∈ fourierSpace n (r + s) := by + simpa only [Nat.add_comm, Pi.mul_def, Pi.star_def] using + fourierSpace_mul (fourierSpace_star hb) ha + +/-- Multiplication by one cube coordinate raises the degree by at most one. -/ +theorem cubeCoord_mul_mem_fourierSpace {r : ℕ} {a : Cube n → ℂ} + (ha : a ∈ fourierSpace n r) (i : Fin n) : + (fun x => (cubeCoord x i : ℂ) * a x) ∈ fourierSpace n (r + 1) := by + have hi : walshChar {i} ∈ fourierSpace n 1 := + walshChar_mem_fourierSpace (by simp) + have h := fourierSpace_mul hi ha + rw [Nat.add_comm] at h + convert h using 1 + ext x + simp only [Pi.mul_apply, walshChar_singleton] + +/-- Functions whose Walsh support starts in degree `k`. -/ +def fourierSpaceFrom (n k : ℕ) : Submodule ℂ (Cube n → ℂ) := + Submodule.span ℂ (walshChar '' {S : Finset (Fin n) | k ≤ S.card}) + +theorem walshChar_mem_fourierSpaceFrom {S : Finset (Fin n)} (hS : d ≤ S.card) : + walshChar S ∈ fourierSpaceFrom n d := + Submodule.subset_span ⟨S, hS, rfl⟩ + +/-- Full parity complements character index sets, taking low degree `d` to +Fourier support in degrees at least `n - d`. -/ +theorem parity_mul_mem_fourierSpaceFrom {a : Cube n → ℂ} + (ha : a ∈ fourierSpace n d) : + (fun x => walshChar Finset.univ x * a x) ∈ fourierSpaceFrom n (n - d) := by + classical + change walshChar Finset.univ * a ∈ fourierSpaceFrom n (n - d) + induction ha using Submodule.span_induction with + | mem a ha => + obtain ⟨S, hS, rfl⟩ := ha + have hSc : n - d ≤ (Finset.univ \ S).card := by + rw [Finset.card_sdiff_of_subset (Finset.subset_univ S)] + simpa using Nat.sub_le_sub_left hS n + convert walshChar_mem_fourierSpaceFrom hSc using 1 + ext x + exact walshChar_univ_mul S x + | zero => simp + | add a b _ _ ha hb => + simpa only [mul_add] using (fourierSpaceFrom n (n - d)).add_mem ha hb + | smul c a _ ha => + simpa only [mul_smul_comm] using (fourierSpaceFrom n (n - d)).smul_mem c ha + +/-- Low and high Fourier support with a strict gap have zero counting pairing. +There is no conjugation in this formulation because Walsh characters are real; +it applies directly to the product appearing in the weighted proof. -/ +theorem sum_mul_eq_zero_of_fourier_separated {r s : ℕ} {a b : Cube n → ℂ} + (ha : a ∈ fourierSpace n r) (hb : b ∈ fourierSpaceFrom n s) (hrs : r < s) : + (∑ x : Cube n, a x * b x) = 0 := by + classical + induction ha, hb using Submodule.span_induction₂ with + | mem_mem a b ha hb => + obtain ⟨S, hS, rfl⟩ := ha + obtain ⟨T, hT, rfl⟩ := hb + have hne : S ≠ T := by + intro h + subst T + exact (not_lt_of_ge (hT.trans hS)) hrs + simpa only [star_walshChar, ite_eq_right hne] using walshChar_orthogonality S T + | zero_left b hb => simp + | zero_right a ha => simp + | add_left a b c _ _ _ ha hb => + simp only [Pi.add_apply, add_mul, Finset.sum_add_distrib, ha, hb, add_zero] + | add_right a b c _ _ _ ha hb => + simp only [Pi.add_apply, mul_add, Finset.sum_add_distrib, ha, hb, add_zero] + | smul_left c a b _ _ hab => + simpa only [Pi.smul_apply, smul_eq_mul, mul_assoc, ← Finset.mul_sum, mul_zero] using + congrArg (fun z : ℂ => c * z) hab + | smul_right c a b _ _ hab => + simpa only [Pi.smul_apply, smul_eq_mul, mul_left_comm, ← Finset.mul_sum, mul_zero] using + congrArg (fun z : ℂ => c * z) hab + +/-- The polynomial has high Fourier support after multiplication by +full parity, with no alternate polynomial-class assumption. -/ +theorem parity_polynomialValue_mem_fourierSpaceFrom {p : MvPolynomial (Fin n) ℝ} + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) : + (fun x => walshChar Finset.univ x * (polynomialValue p x : ℂ)) ∈ + fourierSpaceFrom n (n - d) := + parity_mul_mem_fourierSpaceFrom (polynomialValue_mem_fourierSpace hp hd) + +/-- Every Fourier coefficient below `n - d` of the parity-transformed +polynomial vanishes. -/ +theorem parity_polynomialValue_low_coefficient_eq_zero {p : MvPolynomial (Fin n) ℝ} + (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) {S : Finset (Fin n)} + (hS : S.card < n - d) : + walshCoefficientLinear S + (fun x => walshChar Finset.univ x * (polynomialValue p x : ℂ)) = 0 := by + have h := sum_mul_eq_zero_of_fourier_separated + (walshChar_mem_fourierSpace (Nat.le_refl S.card)) + (parity_polynomialValue_mem_fourierSpaceFrom hp hd) hS + simpa only [walshCoefficientLinear, LinearMap.coe_mk, AddHom.coe_mk, star_walshChar] using h + +end + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/ProjectionBlocks.lean b/lean/OAI/Combinatorics/GotsmanLinial/ProjectionBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..524ac7ad932b8e05ad9847b05285b5e107e76875 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/ProjectionBlocks.lean @@ -0,0 +1,358 @@ +import OAI.Combinatorics.GotsmanLinial.HilbertSchmidt +import Mathlib.Analysis.CStarAlgebra.Matrix +import Mathlib.Analysis.InnerProductSpace.Adjoint +import Mathlib.LinearAlgebra.Trace +import Mathlib.Tactic + +namespace OAI + +/-! +# Matrix blocks of a finite orthogonal projection family + +The Hilbert--Schmidt quantity below is the explicit sum of squared entry norms +rather than an ambient matrix norm instance. +-/ + +open scoped BigOperators ComplexConjugate +open Module + +noncomputable section + +namespace LeanBlast.GotsmanLinial + +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] + +/-- A finite orthogonal decomposition of the identity by Hermitian projections. -/ +structure OrthogonalProjectionFamily (P : κ → Matrix ι ι ℂ) : Prop where + selfAdjoint : ∀ k, IsSelfAdjoint (P k) + idempotent : ∀ k, P k * P k = P k + orthogonal : ∀ r s, r ≠ s → P r * P s = 0 + sum_eq_one : ∑ k, P k = 1 + +namespace OrthogonalProjectionFamily + +variable {P : κ → Matrix ι ι ℂ} (hP : OrthogonalProjectionFamily P) + +include hP + +theorem conjTranspose_eq (k : κ) : (P k).conjTranspose = P k := by + simpa only [IsSelfAdjoint, Matrix.star_eq_conjTranspose] using hP.selfAdjoint k + +theorem mul_eq_ite [DecidableEq κ] (r s : κ) : + P r * P s = if r = s then P r else 0 := by + by_cases hrs : r = s + · subst s + simp [hP.idempotent] + · simp [hrs, hP.orthogonal r s hrs] + +end OrthogonalProjectionFamily + +variable {P : κ → Matrix ι ι ℂ} + +theorem sum_projection_blocks (hP : OrthogonalProjectionFamily P) (B : Matrix ι ι ℂ) : + (∑ r, ∑ s, P s * B * P r) = B := by + simp_rw [← Matrix.sum_mul, hP.sum_eq_one, Matrix.one_mul] + rw [← Matrix.mul_sum, hP.sum_eq_one, Matrix.mul_one] + +theorem projection_block_ext (hP : OrthogonalProjectionFamily P) + {A B : Matrix ι ι ℂ} (h : ∀ r s, P s * A * P r = P s * B * P r) : A = B := by + rw [← sum_projection_blocks hP A, ← sum_projection_blocks hP B] + exact Finset.sum_congr rfl fun r _ => Finset.sum_congr rfl fun s _ => h r s + +/-- The real-valued spectral multiplier defined by the projection family. -/ +def matrixGrading (P : κ → Matrix ι ι ℂ) (weight : κ → ℝ) : Matrix ι ι ℂ := + ∑ k, (weight k : ℂ) • P k + +theorem projection_mul_matrixGrading (hP : OrthogonalProjectionFamily P) + (weight : κ → ℝ) (s : κ) : P s * matrixGrading P weight = (weight s : ℂ) • P s := by + classical + simp only [matrixGrading, Matrix.mul_sum, Matrix.mul_smul, hP.mul_eq_ite] + simp + +theorem matrixGrading_mul_projection (hP : OrthogonalProjectionFamily P) + (weight : κ → ℝ) (r : κ) : matrixGrading P weight * P r = (weight r : ℂ) • P r := by + classical + simp only [matrixGrading, Matrix.sum_mul, Matrix.smul_mul, hP.mul_eq_ite] + simp + +theorem projection_commutator (hP : OrthogonalProjectionFamily P) + (weight : κ → ℝ) (B : Matrix ι ι ℂ) (r s : κ) : + P s * (matrixGrading P weight * B - B * matrixGrading P weight) * P r = + ((weight s - weight r : ℝ) : ℂ) • (P s * B * P r) := by + rw [Matrix.mul_sub, Matrix.sub_mul] + calc + P s * (matrixGrading P weight * B) * P r - + P s * (B * matrixGrading P weight) * P r = + (P s * matrixGrading P weight) * B * P r - + P s * B * (matrixGrading P weight * P r) := by simp only [Matrix.mul_assoc] + _ = ((weight s : ℂ) • P s) * B * P r - + P s * B * ((weight r : ℂ) • P r) := by + rw [projection_mul_matrixGrading hP, matrixGrading_mul_projection hP] + _ = ((weight s - weight r : ℝ) : ℂ) • (P s * B * P r) := by + simp only [Matrix.smul_mul, Matrix.mul_smul, Complex.ofReal_sub, sub_smul] + +theorem projection_anticommutator (hP : OrthogonalProjectionFamily P) + (weight : κ → ℝ) (B : Matrix ι ι ℂ) (r s : κ) : + P s * (matrixGrading P weight * B + B * matrixGrading P weight) * P r = + ((weight s + weight r : ℝ) : ℂ) • (P s * B * P r) := by + rw [Matrix.mul_add, Matrix.add_mul] + calc + P s * (matrixGrading P weight * B) * P r + + P s * (B * matrixGrading P weight) * P r = + (P s * matrixGrading P weight) * B * P r + + P s * B * (matrixGrading P weight * P r) := by simp only [Matrix.mul_assoc] + _ = ((weight s : ℂ) • P s) * B * P r + + P s * B * ((weight r : ℂ) • P r) := by + rw [projection_mul_matrixGrading hP, matrixGrading_mul_projection hP] + _ = ((weight s + weight r : ℝ) : ℂ) • (P s * B * P r) := by + simp only [Matrix.smul_mul, Matrix.mul_smul, Complex.ofReal_add, add_smul] + +omit [DecidableEq ι] in +theorem trace_projection_sandwich (Q A : Matrix ι ι ℂ) (hQ : Q * Q = Q) : + Matrix.trace (Q * A * Q) = Matrix.trace (Q * A) := by + rw [Matrix.trace_mul_cycle, hQ] + +theorem hsNormSq_projection_mul (hP : OrthogonalProjectionFamily P) + (s : κ) (B : Matrix ι ι ℂ) : + hsNormSq (P s * B) = (Matrix.trace (B.conjTranspose * P s * B)).re := by + rw [hsNormSq_eq_re_trace, Matrix.conjTranspose_mul, hP.conjTranspose_eq] + congr 2 + calc + (B.conjTranspose * P s) * (P s * B) = + B.conjTranspose * (P s * P s) * B := by simp only [Matrix.mul_assoc] + _ = B.conjTranspose * P s * B := by rw [hP.idempotent] + +theorem hsNormSq_mul_projection (hP : OrthogonalProjectionFamily P) + (r : κ) (B : Matrix ι ι ℂ) : + hsNormSq (B * P r) = (Matrix.trace (P r * (B.conjTranspose * B))).re := by + rw [hsNormSq_eq_re_trace, Matrix.conjTranspose_mul, hP.conjTranspose_eq] + have heq : (P r * B.conjTranspose) * (B * P r) = + P r * (B.conjTranspose * B) * P r := by simp only [Matrix.mul_assoc] + rw [heq, trace_projection_sandwich _ _ (hP.idempotent r)] + +theorem hsNormSq_left_projection_decomposition (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) : hsNormSq B = ∑ s, hsNormSq (P s * B) := by + simp_rw [hsNormSq_projection_mul hP] + rw [← Complex.re_sum, ← Matrix.trace_sum] + simp_rw [← Matrix.sum_mul] + rw [← Matrix.mul_sum, hP.sum_eq_one, Matrix.mul_one, hsNormSq_eq_re_trace] + +theorem hsNormSq_right_projection_decomposition (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) : hsNormSq B = ∑ r, hsNormSq (B * P r) := by + simp_rw [hsNormSq_mul_projection hP] + rw [← Complex.re_sum, ← Matrix.trace_sum, ← Matrix.sum_mul, + hP.sum_eq_one, Matrix.one_mul, hsNormSq_eq_re_trace] + +theorem hsNormSq_block_parseval (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) : + hsNormSq B = ∑ r, ∑ s, hsNormSq (P s * B * P r) := by + rw [hsNormSq_right_projection_decomposition hP B] + apply Finset.sum_congr rfl + intro r _ + simpa only [Matrix.mul_assoc] using hsNormSq_left_projection_decomposition hP (B * P r) + +theorem hsNormSq_matrixGrading (hP : OrthogonalProjectionFamily P) (weight : κ → ℝ) : + hsNormSq (matrixGrading P weight) = ∑ r, weight r ^ 2 * hsNormSq (P r) := by + classical + rw [hsNormSq_block_parseval hP] + apply Finset.sum_congr rfl + intro r _ + rw [Finset.sum_eq_single r] + · rw [projection_mul_matrixGrading hP, Matrix.smul_mul, hP.idempotent, + hsNormSq_real_smul] + · intro s _ hsr + rw [projection_mul_matrixGrading hP, Matrix.smul_mul, + hP.orthogonal s r hsr, smul_zero, hsNormSq_zero] + · simp + +theorem hsNormSq_matrixGrading_trace (hP : OrthogonalProjectionFamily P) + (weight : κ → ℝ) : + hsNormSq (matrixGrading P weight) = ∑ r, weight r ^ 2 * (Matrix.trace (P r)).re := by + rw [hsNormSq_matrixGrading hP] + apply Finset.sum_congr rfl + intro r _ + rw [hsNormSq_projection (P r) (hP.conjTranspose_eq r) (hP.idempotent r)] + +theorem sum_hsNormSq_blocks_column (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) (r : κ) (hB : B.conjTranspose * B = 1) : + (∑ s, hsNormSq (P s * B * P r)) = hsNormSq (P r) := by + calc + (∑ s, hsNormSq (P s * B * P r)) = hsNormSq (B * P r) := by + simpa only [Matrix.mul_assoc] using + (hsNormSq_left_projection_decomposition hP (B * P r)).symm + _ = hsNormSq (P r) := hsNormSq_mul_left_of_unitary B (P r) hB + +theorem sum_hsNormSq_blocks_row (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) (s : κ) (hB : B * B.conjTranspose = 1) : + (∑ r, hsNormSq (P s * B * P r)) = hsNormSq (P s) := by + rw [← hsNormSq_right_projection_decomposition hP (P s * B)] + exact hsNormSq_mul_right_of_unitary (P s) B hB + +theorem sum_hsNormSq_blocks_column_trace (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) (r : κ) (hB : B.conjTranspose * B = 1) : + (∑ s, hsNormSq (P s * B * P r)) = (Matrix.trace (P r)).re := by + rw [sum_hsNormSq_blocks_column hP B r hB] + exact hsNormSq_projection (P r) (hP.conjTranspose_eq r) (hP.idempotent r) + +theorem sum_hsNormSq_blocks_row_trace (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) (s : κ) (hB : B * B.conjTranspose = 1) : + (∑ r, hsNormSq (P s * B * P r)) = (Matrix.trace (P s)).re := by + rw [sum_hsNormSq_blocks_row hP B s hB] + exact hsNormSq_projection (P s) (hP.conjTranspose_eq s) (hP.idempotent s) + +theorem hsNormSq_commutator (hP : OrthogonalProjectionFamily P) + (weight : κ → ℝ) (B : Matrix ι ι ℂ) : + hsNormSq (matrixGrading P weight * B - B * matrixGrading P weight) = + ∑ r, ∑ s, (weight s - weight r) ^ 2 * hsNormSq (P s * B * P r) := by + rw [hsNormSq_block_parseval hP] + simp_rw [projection_commutator hP, hsNormSq_real_smul] + +theorem hsNormSq_anticommutator (hP : OrthogonalProjectionFamily P) + (weight : κ → ℝ) (B : Matrix ι ι ℂ) : + hsNormSq (matrixGrading P weight * B + B * matrixGrading P weight) = + ∑ r, ∑ s, (weight s + weight r) ^ 2 * hsNormSq (P s * B * P r) := by + rw [hsNormSq_block_parseval hP] + simp_rw [projection_anticommutator hP, hsNormSq_real_smul] + +/-- The degree grading associated to projections indexed from zero to `n`. -/ +def degreeGrading {n : ℕ} (P : Fin (n + 1) → Matrix ι ι ℂ) : Matrix ι ι ℂ := + matrixGrading P fun k => (k.val : ℝ) + +/-- The degree grading centered at `n / 2`. -/ +def centeredGrading {n : ℕ} (P : Fin (n + 1) → Matrix ι ι ℂ) : Matrix ι ι ℂ := + matrixGrading P fun k => (k.val : ℝ) - (n : ℝ) / 2 + +theorem hsNormSq_centeredGrading {n : ℕ} {P : Fin (n + 1) → Matrix ι ι ℂ} + (hP : OrthogonalProjectionFamily P) : + hsNormSq (centeredGrading P) = + ∑ k, ((k.val : ℝ) - (n : ℝ) / 2) ^ 2 * hsNormSq (P k) := + hsNormSq_matrixGrading hP _ + +theorem hsNormSq_centeredGrading_trace {n : ℕ} {P : Fin (n + 1) → Matrix ι ι ℂ} + (hP : OrthogonalProjectionFamily P) : + hsNormSq (centeredGrading P) = + ∑ k, ((k.val : ℝ) - (n : ℝ) / 2) ^ 2 * (Matrix.trace (P k)).re := + hsNormSq_matrixGrading_trace hP _ + +theorem centeredGrading_eq {n : ℕ} {P : Fin (n + 1) → Matrix ι ι ℂ} + (hP : OrthogonalProjectionFamily P) : + centeredGrading P = degreeGrading P - (((n : ℝ) / 2 : ℝ) : ℂ) • (1 : Matrix ι ι ℂ) := by + simp only [centeredGrading, degreeGrading, matrixGrading, Complex.ofReal_sub, sub_smul, + Finset.sum_sub_distrib] + rw [← Finset.smul_sum, hP.sum_eq_one] + +theorem projection_centered_anticommutator {n : ℕ} + {P : Fin (n + 1) → Matrix ι ι ℂ} (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) (r s : Fin (n + 1)) : + P s * (centeredGrading P * B + B * centeredGrading P) * P r = + (((s.val : ℝ) + (r.val : ℝ) - n : ℝ) : ℂ) • (P s * B * P r) := by + rw [centeredGrading, projection_anticommutator hP] + congr 2 + ring + +theorem hsNormSq_centered_anticommutator {n : ℕ} + {P : Fin (n + 1) → Matrix ι ι ℂ} (hP : OrthogonalProjectionFamily P) + (B : Matrix ι ι ℂ) : + hsNormSq (centeredGrading P * B + B * centeredGrading P) = + ∑ r, ∑ s, ((s.val : ℝ) + (r.val : ℝ) - n) ^ 2 * + hsNormSq (P s * B * P r) := by + rw [hsNormSq_block_parseval hP] + simp_rw [projection_centered_anticommutator hP, hsNormSq_real_smul] + +section OperatorTransport + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [FiniteDimensional ℂ E] + +local instance : CompleteSpace E := FiniteDimensional.complete ℂ E + +/-- Matrix representation of a continuous operator in an orthonormal basis, +bundled with its algebraic compatibility. -/ +def operatorMatrixEquiv (b : OrthonormalBasis ι ℂ E) : + (E →L[ℂ] E) ≃ₐ[ℂ] Matrix ι ι ℂ := + (Module.End.toContinuousLinearMap (𝕜 := ℂ) E).symm.trans + (LinearMap.toMatrixOrthonormal b).toAlgEquiv + +/-- Matrix entries for the counting orthonormal basis or any chosen +orthonormal basis. -/ +def operatorMatrix (b : OrthonormalBasis ι ℂ E) (T : E →L[ℂ] E) : Matrix ι ι ℂ := + operatorMatrixEquiv b T + +theorem operatorMatrix_eq_toMatrix (b : OrthonormalBasis ι ℂ E) (T : E →L[ℂ] E) : + operatorMatrix b T = LinearMap.toMatrixOrthonormal b T.toLinearMap := rfl + +theorem operatorMatrix_apply (b : OrthonormalBasis ι ℂ E) (T : E →L[ℂ] E) (i j : ι) : + operatorMatrix b T i j = inner ℂ (b i) (T (b j)) := + LinearMap.toMatrixOrthonormal_apply_apply b T.toLinearMap i j + +theorem operatorMatrix_injective (b : OrthonormalBasis ι ℂ E) : + Function.Injective (operatorMatrix b) := (operatorMatrixEquiv b).injective + +@[simp] +theorem operatorMatrix_zero (b : OrthonormalBasis ι ℂ E) : + operatorMatrix b (0 : E →L[ℂ] E) = 0 := map_zero (operatorMatrixEquiv b) + +@[simp] +theorem operatorMatrix_one (b : OrthonormalBasis ι ℂ E) : + operatorMatrix b (1 : E →L[ℂ] E) = 1 := map_one (operatorMatrixEquiv b) + +@[simp] +theorem operatorMatrix_add (b : OrthonormalBasis ι ℂ E) (A B : E →L[ℂ] E) : + operatorMatrix b (A + B) = operatorMatrix b A + operatorMatrix b B := + map_add (operatorMatrixEquiv b) A B + +@[simp] +theorem operatorMatrix_sub (b : OrthonormalBasis ι ℂ E) (A B : E →L[ℂ] E) : + operatorMatrix b (A - B) = operatorMatrix b A - operatorMatrix b B := + map_sub (operatorMatrixEquiv b) A B + +@[simp] +theorem operatorMatrix_mul (b : OrthonormalBasis ι ℂ E) (A B : E →L[ℂ] E) : + operatorMatrix b (A * B) = operatorMatrix b A * operatorMatrix b B := + map_mul (operatorMatrixEquiv b) A B + +@[simp] +theorem operatorMatrix_smul (b : OrthonormalBasis ι ℂ E) (z : ℂ) (T : E →L[ℂ] E) : + operatorMatrix b (z • T) = z • operatorMatrix b T := + (operatorMatrixEquiv b).toLinearEquiv.map_smul z T + +@[simp] +theorem operatorMatrix_sum (b : OrthonormalBasis ι ℂ E) (T : κ → E →L[ℂ] E) : + operatorMatrix b (∑ k, T k) = ∑ k, operatorMatrix b (T k) := + map_sum (operatorMatrixEquiv b) T Finset.univ + +theorem operatorMatrix_isSelfAdjoint (b : OrthonormalBasis ι ℂ E) + (T : E →L[ℂ] E) (hT : IsSelfAdjoint T) : IsSelfAdjoint (operatorMatrix b T) := by + have hlin : IsSelfAdjoint T.toLinearMap := + (ContinuousLinearMap.isSelfAdjoint_toLinearMap_iff T).mpr hT + exact hlin.map (LinearMap.toMatrixOrthonormal b) + +/-- Transfer an actually constructed orthogonal family of Hilbert-space +projections to the matrix interface used by the block estimates. -/ +theorem orthogonalProjectionFamily_operatorMatrix (b : OrthonormalBasis ι ℂ E) + (T : κ → E →L[ℂ] E) + (hself : ∀ k, IsSelfAdjoint (T k)) + (hidem : ∀ k, T k * T k = T k) + (horth : ∀ r s, r ≠ s → T r * T s = 0) + (hsum : ∑ k, T k = 1) : + OrthogonalProjectionFamily (fun k => operatorMatrix b (T k)) where + selfAdjoint k := operatorMatrix_isSelfAdjoint b (T k) (hself k) + idempotent k := by rw [← operatorMatrix_mul, hidem k] + orthogonal r s hrs := by rw [← operatorMatrix_mul, horth r s hrs, operatorMatrix_zero] + sum_eq_one := by rw [← operatorMatrix_sum, hsum, operatorMatrix_one] + +end OperatorTransport + +/-- The standard-basis matrix representation is inverse to the standard +Euclidean continuous linear operator associated to a matrix. -/ +@[simp] +theorem operatorMatrix_toEuclideanCLM (A : Matrix ι ι ℂ) : + operatorMatrix (EuclideanSpace.basisFun ι ℂ) + (Matrix.toEuclideanCLM (n := ι) (𝕜 := ℂ) A) = A := + (LinearMap.toMatrixOrthonormal (EuclideanSpace.basisFun ι ℂ)).apply_symm_apply A + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/ProjectionTrace.lean b/lean/OAI/Combinatorics/GotsmanLinial/ProjectionTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..d01cec1c44712d988d434a427048725771e0a307 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/ProjectionTrace.lean @@ -0,0 +1,73 @@ +import Mathlib.Analysis.InnerProductSpace.Projection.FiniteDimensional +import Mathlib.Analysis.InnerProductSpace.Adjoint +import Mathlib.LinearAlgebra.Trace + +namespace OAI + +/-! +# Traces of actual orthogonal projections + +The trace calculation uses the algebraic theorem for a projection onto a +submodule. In particular, no spectral decomposition or matrix norm instance +is needed. Matrix transport is valid in every basis, and hence in the +orthonormal basis used for the weighted grading. +-/ + +noncomputable section + +namespace LeanBlast.GotsmanLinial + +section General + +variable {𝕜 E ι : Type*} [RCLike 𝕜] [NormedAddCommGroup E] + [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] + +/-- The actual orthogonal projection is algebraically a projection onto its +specified submodule. -/ +theorem starProjection_isProj (K : Submodule 𝕜 E) : + LinearMap.IsProj K K.starProjection.toLinearMap where + map_mem := K.starProjection_apply_mem + map_id := fun _ hx => Submodule.starProjection_eq_self_iff.mpr hx + +/-- The trace of the actual orthogonal projection is the dimension of its range. -/ +theorem trace_starProjection (K : Submodule 𝕜 E) : + LinearMap.trace 𝕜 E K.starProjection.toLinearMap = (Module.finrank 𝕜 K : 𝕜) := + (starProjection_isProj K).trace + +variable [Fintype ι] [DecidableEq ι] + +/-- The matrix trace of an orthogonal projection is independent of the chosen basis. -/ +theorem trace_toMatrix_starProjection (b : Module.Basis ι 𝕜 E) (K : Submodule 𝕜 E) : + Matrix.trace (LinearMap.toMatrix b b K.starProjection.toLinearMap) = + (Module.finrank 𝕜 K : 𝕜) := by + rw [← LinearMap.trace_eq_matrix_trace 𝕜 b, trace_starProjection] + +/-- The orthonormal matrix representation used by the grading has the correct trace. -/ +theorem trace_toMatrixOrthonormal_starProjection (b : OrthonormalBasis ι 𝕜 E) + (K : Submodule 𝕜 E) : + Matrix.trace (LinearMap.toMatrixOrthonormal b K.starProjection.toLinearMap) = + (Module.finrank 𝕜 K : 𝕜) := + trace_toMatrix_starProjection b.toBasis K + +end General + +section Complex + +variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [FiniteDimensional ℂ E] [Fintype ι] [DecidableEq ι] + +/-- The real trace required by Hilbert--Schmidt block-mass computations. -/ +theorem re_trace_toMatrixOrthonormal_starProjection (b : OrthonormalBasis ι ℂ E) + (K : Submodule ℂ E) : + (Matrix.trace (LinearMap.toMatrixOrthonormal b K.starProjection.toLinearMap)).re = + (Module.finrank ℂ K : ℝ) := by + rw [trace_toMatrixOrthonormal_starProjection] + simp + +end Complex + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/ScalarIncrements.lean b/lean/OAI/Combinatorics/GotsmanLinial/ScalarIncrements.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c3c75d269d0fd76576d9c7e40d84ded87993627 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/ScalarIncrements.lean @@ -0,0 +1,127 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Scalar inequalities for the one-sided coupling estimate + +The increasing function `couplingPotential m t = (t-m)|t-m|/2` controls +squared distances from below and has a trapezoidal increment bound from above. +All arguments here are algebraic, by splitting according to the positions of +the endpoints relative to the center `m`. +-/ + +namespace LeanBlast.GotsmanLinial + +/-- The scalar potential used in the one-sided coupling argument. -/ +noncomputable def couplingPotential (m t : ℝ) : ℝ := + (1 / 2 : ℝ) * (t - m) * |t - m| + +@[simp] theorem couplingPotential_self (m : ℝ) : couplingPotential m m = 0 := by + simp [couplingPotential] + +/-- Both increment inequalities hold even when the endpoints coincide. -/ +theorem couplingPotential_increment_bounds (m : ℝ) {u v : ℝ} (huv : u ≤ v) : + (v - u) ^ 2 / 4 ≤ couplingPotential m v - couplingPotential m u ∧ + couplingPotential m v - couplingPotential m u ≤ + (v - u) / 2 * (|u - m| + |v - m|) := by + by_cases hum : u ≤ m + · by_cases hvm : v ≤ m + · simp only [couplingPotential, abs_of_nonpos (sub_nonpos.mpr hum), + abs_of_nonpos (sub_nonpos.mpr hvm)] + constructor + · nlinarith [sq_nonneg (v - u), + mul_nonneg (sub_nonneg.mpr huv) (sub_nonneg.mpr hvm)] + · nlinarith + · have hmv : m ≤ v := (not_le.mp hvm).le + simp only [couplingPotential, abs_of_nonpos (sub_nonpos.mpr hum), + abs_of_nonneg (sub_nonneg.mpr hmv)] + constructor + · nlinarith [sq_nonneg (u + v - 2 * m)] + · nlinarith [mul_nonneg (sub_nonneg.mpr hum) (sub_nonneg.mpr hmv)] + · have hmu : m ≤ u := (not_le.mp hum).le + have hmv : m ≤ v := hmu.trans huv + simp only [couplingPotential, abs_of_nonneg (sub_nonneg.mpr hmu), + abs_of_nonneg (sub_nonneg.mpr hmv)] + constructor + · nlinarith [sq_nonneg (v - u), + mul_nonneg (sub_nonneg.mpr huv) (sub_nonneg.mpr hmu)] + · nlinarith + +theorem couplingPotential_increment_lower (m : ℝ) {u v : ℝ} (huv : u ≤ v) : + (v - u) ^ 2 / 4 ≤ couplingPotential m v - couplingPotential m u := + (couplingPotential_increment_bounds m huv).1 + +theorem couplingPotential_increment_upper (m : ℝ) {u v : ℝ} (huv : u ≤ v) : + couplingPotential m v - couplingPotential m u ≤ + (v - u) / 2 * (|u - m| + |v - m|) := + (couplingPotential_increment_bounds m huv).2 + +theorem monotone_couplingPotential (m : ℝ) : Monotone (couplingPotential m) := by + intro u v huv + have h := couplingPotential_increment_lower m huv + nlinarith [sq_nonneg (v - u)] + +theorem strictMono_couplingPotential (m : ℝ) : StrictMono (couplingPotential m) := by + intro u v huv + have h := couplingPotential_increment_lower m huv.le + have hs := mul_pos (sub_pos.mpr huv) (sub_pos.mpr huv) + nlinarith + +@[simp] theorem couplingPotential_le_iff (m u v : ℝ) : + couplingPotential m u ≤ couplingPotential m v ↔ u ≤ v := + (strictMono_couplingPotential m).le_iff_le + +@[simp] theorem couplingPotential_lt_iff (m u v : ℝ) : + couplingPotential m u < couplingPotential m v ↔ u < v := + (strictMono_couplingPotential m).lt_iff_lt + +@[simp] theorem couplingPotential_eq_iff (m u v : ℝ) : + couplingPotential m u = couplingPotential m v ↔ u = v := + (strictMono_couplingPotential m).injective.eq_iff + +theorem couplingPotential_sub_nonneg_iff (m u v : ℝ) : + 0 ≤ couplingPotential m v - couplingPotential m u ↔ u ≤ v := by + rw [sub_nonneg, couplingPotential_le_iff] + +theorem couplingPotential_sub_pos_iff (m u v : ℝ) : + 0 < couplingPotential m v - couplingPotential m u ↔ u < v := by + rw [sub_pos, couplingPotential_lt_iff] + +theorem abs_couplingPotential_sub_of_le (m : ℝ) {u v : ℝ} (huv : u ≤ v) : + |couplingPotential m v - couplingPotential m u| = + couplingPotential m v - couplingPotential m u := + abs_of_nonneg ((couplingPotential_sub_nonneg_iff m u v).mpr huv) + +/-- The pointwise lower bound in the coupling argument, without ordering the +two real variables. -/ +theorem sq_sub_le_four_mul_abs_potential_sub (m u v : ℝ) : + (u - v) ^ 2 ≤ 4 * |couplingPotential m u - couplingPotential m v| := by + rcases le_total u v with huv | hvu + · rw [abs_sub_comm, abs_couplingPotential_sub_of_le m huv] + have h := couplingPotential_increment_lower m huv + nlinarith + · rw [abs_couplingPotential_sub_of_le m hvu] + have h := couplingPotential_increment_lower m hvu + nlinarith + +/-- An upper bound for the positive part of a potential increment under a +one-sided bound on the original increment. -/ +theorem max_couplingPotential_increment_le (m a u v : ℝ) + (ha : 0 ≤ a) (hstep : v - u ≤ a) : + max (couplingPotential m v - couplingPotential m u) 0 ≤ + a / 2 * (|u - m| + |v - m|) := by + have hs : 0 ≤ |u - m| + |v - m| := add_nonneg (abs_nonneg _) (abs_nonneg _) + by_cases huv : u ≤ v + · rw [max_eq_left ((couplingPotential_sub_nonneg_iff m u v).mpr huv)] + have h := couplingPotential_increment_upper m huv + have hp := mul_nonneg (sub_nonneg.mpr hstep) hs + nlinarith + · have hvu : v ≤ u := (not_le.mp huv).le + rw [max_eq_right (sub_nonpos.mpr ((monotone_couplingPotential m) hvu))] + nlinarith [mul_nonneg ha hs] + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/SignParity.lean b/lean/OAI/Combinatorics/GotsmanLinial/SignParity.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cb9b569e1618b48f07a24be746be54742aa6676 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/SignParity.lean @@ -0,0 +1,258 @@ +import OAI.Combinatorics.GotsmanLinial.Statement +import OAI.Combinatorics.GotsmanLinial.PolynomialDegree +import Mathlib.InformationTheory.Hamming +import Mathlib.Tactic + +namespace OAI + +/-! +# Removing threshold zeros and turning sensitive edges into constant-sign edges + +All graph pairs are ordered. The cube coordinates are the real +signs encoded by `Bool` in the public statement. +-/ + +open scoped BigOperators + +namespace LeanBlast.GotsmanLinial + +/-- Full parity, with values in the reals. -/ +noncomputable def fullParity {n : ℕ} (x : Cube n) : ℝ := + ∏ i : Fin n, cubeCoord x i + +/-- Two cube vertices differ by a single coordinate flip. -/ +def CubeAdjacent {n : ℕ} (x y : Cube n) : Prop := + ∃ i : Fin n, flip i x = y + +/-- All ordered pairs of neighboring vertices. -/ +noncomputable def orderedNeighborPairs (n : ℕ) : Finset (Cube n × Cube n) := by + classical + exact Finset.univ.filter fun e => hammingDist e.1 e.2 = 1 + +/-- Ordered neighboring pairs at which a real function has equal values. -/ +noncomputable def orderedConstantEdges {n : ℕ} (h : Cube n → ℝ) : + Finset (Cube n × Cube n) := by + classical + exact (orderedNeighborPairs n).filter fun e => h e.1 = h e.2 + +private theorem exists_pos_lt_finset {α : Type*} (s : Finset α) (a : α → ℝ) + (ha : ∀ x ∈ s, 0 < a x) : ∃ ε : ℝ, 0 < ε ∧ ∀ x ∈ s, ε < a x := by + classical + revert ha + induction s using Finset.induction_on with + | empty => + intro _ + exact ⟨1, by norm_num, by simp⟩ + | @insert x s hx ih => + intro ha + obtain ⟨ε, hε, hεa⟩ := ih (fun y hy => ha y (Finset.mem_insert_of_mem hy)) + have hax : 0 < a x := ha x (Finset.mem_insert_self x s) + refine ⟨min ε (a x / 2), lt_min hε (by linarith), ?_⟩ + intro y hy + rcases Finset.mem_insert.mp hy with rfl | hy + · exact lt_of_le_of_lt (min_le_right _ _) (by linarith) + · exact lt_of_le_of_lt (min_le_left _ _) (hεa y hy) + +/-- A positive constant removes all zeros of a real function on a finite set +without changing its threshold signs, including the convention `sign(0)=1`. -/ +theorem exists_pos_shift_nonzero_preserves_sign {α : Type*} [Fintype α] + (v : α → ℝ) : ∃ ε : ℝ, 0 < ε ∧ (∀ x, v x + ε ≠ 0) ∧ + (∀ x, thresholdSign (v x + ε) = thresholdSign (v x)) := by + classical + let a : α → ℝ := fun x => if v x < 0 then -v x else 1 + have ha : ∀ x ∈ (Finset.univ : Finset α), 0 < a x := by + intro x _ + by_cases hx : v x < 0 + · simp [a, hx, neg_pos.mpr hx] + · simp [a, hx] + obtain ⟨ε, hε, hεa⟩ := exists_pos_lt_finset Finset.univ a ha + have hneg : ∀ x, v x < 0 → v x + ε < 0 := by + intro x hx + have he : ε < -v x := by simpa [a, hx] using hεa x (Finset.mem_univ x) + linarith + refine ⟨ε, hε, ?_, ?_⟩ + · intro x + by_cases hx : v x < 0 + · exact ne_of_lt (hneg x hx) + · exact ne_of_gt (add_pos_of_nonneg_of_pos (le_of_not_gt hx) hε) + · intro x + by_cases hx : v x < 0 + · simp [thresholdSign, not_le.mpr hx, not_le.mpr (hneg x hx)] + · have hv : 0 ≤ v x := le_of_not_gt hx + simp [thresholdSign, hv, add_nonneg hv hε.le] + +@[simp] theorem fullParity_sq {n : ℕ} (x : Cube n) : fullParity x ^ 2 = 1 := by + rw [fullParity, ← Finset.prod_pow] + simp + +theorem fullParity_cases {n : ℕ} (x : Cube n) : + fullParity x = 1 ∨ fullParity x = -1 := + sq_eq_one_iff.mp (fullParity_sq x) + +/-- Reversing one coordinate reverses full parity. -/ +@[simp] theorem fullParity_flip {n : ℕ} (i : Fin n) (x : Cube n) : + fullParity (flip i x) = -fullParity x := by + classical + have hc : cubeCoord (flip i x) = Function.update (cubeCoord x) i (-cubeCoord x i) := by + funext j + by_cases hj : j = i + · subst j + simp + · simp [cubeCoord_flip_ne x i j hj, Function.update_of_ne hj] + unfold fullParity + rw [hc, Finset.prod_update_of_mem (Finset.mem_univ i), Finset.sdiff_singleton_eq_erase, neg_mul, + Finset.mul_prod_erase Finset.univ (cubeCoord x) (Finset.mem_univ i)] + +@[simp] theorem hammingDist_flip {n : ℕ} (i : Fin n) (x : Cube n) : + hammingDist x (flip i x) = 1 := by + classical + have hset : (Finset.univ.filter fun j => x j ≠ flip i x j) = {i} := by + ext j + by_cases hj : j = i + · subst j + cases hx : x i <;> simp [flip, hx] + · simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] + simp [flip, hj] + simp only [hammingDist, hset, Finset.card_singleton] + +/-- The flip definition of adjacency agrees with Hamming distance one. -/ +theorem adjacent_iff_hammingDist_eq_one {n : ℕ} (x y : Cube n) : + CubeAdjacent x y ↔ hammingDist x y = 1 := by + classical + constructor + · rintro ⟨i, rfl⟩ + exact hammingDist_flip i x + · intro hxy + obtain ⟨i, hi⟩ := Finset.card_eq_one.mp hxy + refine ⟨i, ?_⟩ + funext j + by_cases hj : j = i + · subst j + have hmem : i ∈ Finset.univ.filter (fun j => x j ≠ y j) := by rw [hi]; simp + have hneq : x i ≠ y i := (Finset.mem_filter.mp hmem).2 + rw [flip_apply_same] + cases hx : x i <;> cases hy : y i <;> simp_all + · have heq : x j = y j := by + by_contra hneq + have hmem : j ∈ Finset.univ.filter (fun j => x j ≠ y j) := + Finset.mem_filter.mpr ⟨Finset.mem_univ j, hneq⟩ + rw [hi] at hmem + exact hj (Finset.mem_singleton.mp hmem) + rw [flip_apply_ne i x j hj, heq] + +/-- A vertex and a direction identify a unique ordered cube edge. -/ +def directedEdgeEmbedding (n : ℕ) : (Fin n × Cube n) ↪ (Cube n × Cube n) where + toFun e := (e.2, flip e.1 e.2) + inj' := by + rintro ⟨i, x⟩ ⟨j, y⟩ heq + have hxy : x = y := congrArg Prod.fst heq + subst y + have hij : i = j := flip_injective_direction x (congrArg Prod.snd heq) + subst j + rfl + +theorem orderedNeighborPairs_eq_map {n : ℕ} : + orderedNeighborPairs n = Finset.univ.map (directedEdgeEmbedding n) := by + classical + ext e + constructor + · intro he + have hd : hammingDist e.1 e.2 = 1 := (Finset.mem_filter.mp he).2 + obtain ⟨i, hi⟩ := (adjacent_iff_hammingDist_eq_one e.1 e.2).mpr hd + exact Finset.mem_map.mpr ⟨(i, e.1), Finset.mem_univ _, Prod.ext rfl hi⟩ + · intro he + obtain ⟨⟨i, x⟩, _, rfl⟩ := Finset.mem_map.mp he + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hammingDist_flip i x⟩ + +/-- The `n * 2^n` count includes both orientations of every cube edge. -/ +theorem card_orderedNeighborPairs (n : ℕ) : + (orderedNeighborPairs n).card = n * 2 ^ n := by + rw [orderedNeighborPairs_eq_map] + simp + +theorem card_orderedConstantEdges {n : ℕ} (h : Cube n → ℝ) : + (orderedConstantEdges h).card = + ∑ i : Fin n, (Finset.univ.filter fun x => h x = h (flip i x)).card := by + classical + unfold orderedConstantEdges + rw [orderedNeighborPairs_eq_map, Finset.filter_map, Finset.card_map] + change (Finset.univ.filter fun e : Fin n × Cube n => h e.2 = h (flip e.1 e.2)).card = _ + simp only [Finset.card_eq_sum_ones, Finset.sum_filter] + exact Fintype.sum_prod_type _ + +/-- Twisting a sign-valued function by parity changes sensitivity into +equality across a coordinate flip. -/ +theorem parity_twist_eq_iff {n : ℕ} {f : Cube n → ℝ} + (hf : ∀ x, f x = 1 ∨ f x = -1) (i : Fin n) (x : Cube n) : + fullParity x * f x = fullParity (flip i x) * f (flip i x) ↔ + f x ≠ f (flip i x) := by + rw [fullParity_flip] + rcases fullParity_cases x with hp | hp <;> + rcases hf x with hx | hx <;> + rcases hf (flip i x) with hy | hy <;> norm_num [hp, hx, hy] + +theorem parity_twist_cases {n : ℕ} {f : Cube n → ℝ} + (hf : ∀ x, f x = 1 ∨ f x = -1) (x : Cube n) : + fullParity x * f x = 1 ∨ fullParity x * f x = -1 := by + rcases fullParity_cases x with hp | hp <;> + rcases hf x with hx | hx <;> simp [hp, hx] + +theorem card_orderedConstantEdges_parity {n : ℕ} {f : Cube n → ℝ} + (hf : ∀ x, f x = 1 ∨ f x = -1) : + (orderedConstantEdges (fun x => fullParity x * f x)).card = sensitiveEdgeCount f := by + classical + rw [card_orderedConstantEdges] + unfold sensitiveEdgeCount + apply Finset.sum_congr rfl + intro i _ + unfold sensitiveVertices + apply congrArg Finset.card + apply Finset.filter_congr + intro x _ + exact parity_twist_eq_iff hf i x + +/-- Exact uniform normalization: both sides count each sensitive undirected +edge twice, once in each direction. -/ +theorem averageSensitivity_eq_parity_edges {n : ℕ} {f : Cube n → ℝ} + (hf : ∀ x, f x = 1 ∨ f x = -1) : + averageSensitivity f = + ((orderedConstantEdges (fun x => fullParity x * f x)).card : ℝ) / (2 : ℝ) ^ n := by + rw [averageSensitivity_eq_count, card_orderedConstantEdges_parity hf] + +theorem polynomialThreshold_sensitivity_eq_parity_edges {n : ℕ} + (p : MvPolynomial (Fin n) ℝ) : + averageSensitivity (polynomialThreshold p) = + ((orderedConstantEdges (fun x => fullParity x * polynomialThreshold p x)).card : ℝ) / + (2 : ℝ) ^ n := + averageSensitivity_eq_parity_edges (fun x => thresholdSign_cases (polynomialValue p x)) + +/-- The real parity used for threshold signs is exactly the full complex +Walsh character under the standard real embedding. -/ +@[simp] theorem ofReal_fullParity {n : ℕ} (x : Cube n) : + (fullParity x : ℂ) = walshChar Finset.univ x := by + simp only [fullParity, Complex.ofReal_prod, walshChar] + +@[simp] theorem polynomialValue_add_C {n : ℕ} + (p : MvPolynomial (Fin n) ℝ) (ε : ℝ) (x : Cube n) : + polynomialValue (p + MvPolynomial.C ε) x = polynomialValue p x + ε := by + simp [polynomialValue] + +/-- The zero-removal reduction preserves multilinearity, the degree bound, +and the entire threshold function. -/ +theorem exists_nonzero_polynomial_same_threshold {n d : ℕ} + {p : MvPolynomial (Fin n) ℝ} (hp : IsMultilinear p) (hd : p.totalDegree ≤ d) : + ∃ q : MvPolynomial (Fin n) ℝ, + IsMultilinear q ∧ q.totalDegree ≤ d ∧ + (∀ x : Cube n, polynomialValue q x ≠ 0) ∧ + polynomialThreshold q = polynomialThreshold p := by + obtain ⟨ε, _hε, hnonzero, hsign⟩ := + exists_pos_shift_nonzero_preserves_sign (polynomialValue p) + refine ⟨p + MvPolynomial.C ε, hp.add_C ε, totalDegree_add_C_le hd ε, ?_, ?_⟩ + · intro x + simpa only [polynomialValue_add_C] using hnonzero x + · funext x + simpa only [polynomialThreshold, polynomialValue_add_C] using hsign x + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/Statement.lean b/lean/OAI/Combinatorics/GotsmanLinial/Statement.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb6048ffb58bc2aa3ddc479d69be2514f47a9605 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/Statement.lean @@ -0,0 +1,111 @@ +import OAI.Combinatorics.GotsmanLinial.Model + +namespace OAI + +open scoped BigOperators + +namespace LeanBlast.GotsmanLinial + +@[simp] theorem flip_apply_same {n : ℕ} (i : Fin n) (x : Cube n) : + flip i x i = !(x i) := by + simp [flip] + +theorem flip_apply_ne {n : ℕ} (i : Fin n) (x : Cube n) (j : Fin n) (h : j ≠ i) : + flip i x j = x j := by + simp [flip, h] + +@[simp] theorem flip_flip {n : ℕ} (i : Fin n) (x : Cube n) : + flip i (flip i x) = x := by + funext j + by_cases h : j = i + · subst j + simp [flip] + · simp [flip, h] + +theorem flip_ne_self {n : ℕ} (i : Fin n) (x : Cube n) : flip i x ≠ x := by + intro h + have hi := congrFun h i + cases hxi : x i <;> simp [flip, hxi] at hi + +theorem flip_injective_direction {n : ℕ} (x : Cube n) : + Function.Injective (fun i : Fin n => flip i x) := by + intro i j h + by_contra hij + have hi := congrFun h i + cases hxi : x i <;> simp [flip, hij, hxi] at hi + +theorem flip_involutive {n : ℕ} (i : Fin n) : Function.Involutive (flip i) := + flip_flip i + +theorem flip_bijective {n : ℕ} (i : Fin n) : Function.Bijective (flip i) := + (flip_involutive i).bijective + +@[simp] theorem cubeCoord_flip_same {n : ℕ} (x : Cube n) (i : Fin n) : + cubeCoord (flip i x) i = -cubeCoord x i := by + cases hxi : x i <;> simp [cubeCoord, flip, hxi] + +theorem cubeCoord_flip_ne {n : ℕ} (x : Cube n) (i j : Fin n) (h : j ≠ i) : + cubeCoord (flip i x) j = cubeCoord x j := by + simp [cubeCoord, flip, h] + +theorem cubeCoord_cases {n : ℕ} (x : Cube n) (i : Fin n) : + cubeCoord x i = 1 ∨ cubeCoord x i = -1 := by + cases hxi : x i <;> simp [cubeCoord, hxi] + +@[simp] theorem cubeCoord_sq {n : ℕ} (x : Cube n) (i : Fin n) : + (cubeCoord x i) ^ 2 = 1 := by + cases hxi : x i <;> simp [cubeCoord, hxi] + +@[simp] theorem thresholdSign_zero : thresholdSign 0 = 1 := by + simp [thresholdSign] + +theorem thresholdSign_eq_one_iff (t : ℝ) : thresholdSign t = 1 ↔ 0 ≤ t := by + by_cases h : 0 ≤ t + · simp [thresholdSign, h] + · simp [thresholdSign, h, show (-1 : ℝ) ≠ 1 by norm_num] + +theorem thresholdSign_eq_neg_one_iff (t : ℝ) : thresholdSign t = -1 ↔ t < 0 := by + by_cases h : 0 ≤ t + · simp [thresholdSign, h, not_lt.mpr h, show (1 : ℝ) ≠ -1 by norm_num] + · simp [thresholdSign, h, lt_of_not_ge h] + +theorem thresholdSign_cases (t : ℝ) : thresholdSign t = 1 ∨ thresholdSign t = -1 := by + unfold thresholdSign + split <;> simp + +@[simp] theorem thresholdSign_sq (t : ℝ) : thresholdSign t ^ 2 = 1 := by + rcases thresholdSign_cases t with h | h <;> simp [h] + +@[simp] theorem card_cube (n : ℕ) : Fintype.card (Cube n) = 2 ^ n := by + simp [Cube] + +/-- The Boolean encoding represents every sign vector exactly once. -/ +noncomputable def cubeEquivSignVectors (n : ℕ) : + Cube n ≃ {x : Fin n → ℝ // ∀ i, x i = 1 ∨ x i = -1} := by + classical + exact + { toFun := fun x => ⟨cubeCoord x, cubeCoord_cases x⟩ + invFun := fun x i => decide (x.1 i = 1) + left_inv := by + intro x + funext i + cases hxi : x i <;> simp [cubeCoord, hxi, show (-1 : ℝ) ≠ 1 by norm_num] + right_inv := by + intro x + apply Subtype.ext + funext i + rcases x.2 i with hxi | hxi <;> + simp [cubeCoord, hxi, show (-1 : ℝ) ≠ 1 by norm_num] } + +theorem averageSensitivity_eq_count {n : ℕ} (f : Cube n → ℝ) : + averageSensitivity f = (sensitiveEdgeCount f : ℝ) / (2 : ℝ) ^ n := by + simp [averageSensitivity, sensitiveEdgeCount, Finset.sum_div] + +theorem averageSensitivity_eq_uniform {n : ℕ} (f : Cube n → ℝ) : + averageSensitivity f = + ∑ i : Fin n, ((sensitiveVertices f i).card : ℝ) / (Fintype.card (Cube n) : ℝ) := by + simp [averageSensitivity] + +end LeanBlast.GotsmanLinial + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/Walsh.lean b/lean/OAI/Combinatorics/GotsmanLinial/Walsh.lean new file mode 100644 index 0000000000000000000000000000000000000000..a01636410331941c96b622339d3a10f7c95f5728 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/Walsh.lean @@ -0,0 +1,191 @@ +import OAI.Combinatorics.GotsmanLinial.Statement +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Data.Finset.SymmDiff +import Mathlib.Data.Fintype.Powerset +import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas + +namespace OAI + +/-! +# Walsh characters of the Boolean cube + +The characters are the real sign monomials, regarded as complex-valued +functions. Counting orthogonality proves linear independence; the cardinality +comparison then gives a basis. The degree filtration and its dimensions are +constructed from this concrete basis. +-/ + +noncomputable section + +open scoped BigOperators symmDiff +open Finset Submodule Module + +namespace LeanBlast.GotsmanLinial + +/-- The complex-valued Walsh character associated to a subset of coordinates. -/ +def walshChar {n : ℕ} (S : Finset (Fin n)) (x : Cube n) : ℂ := + ∏ i ∈ S, (cubeCoord x i : ℂ) + +@[simp] theorem walshChar_empty {n : ℕ} (x : Cube n) : + walshChar ∅ x = 1 := by simp [walshChar] + +@[simp] theorem walshChar_singleton {n : ℕ} (i : Fin n) (x : Cube n) : + walshChar {i} x = (cubeCoord x i : ℂ) := by simp [walshChar] + +theorem walshChar_eq_prod_univ {n : ℕ} (S : Finset (Fin n)) (x : Cube n) : + walshChar S x = ∏ i : Fin n, if i ∈ S then (cubeCoord x i : ℂ) else 1 := by + exact (Fintype.prod_ite_mem S (fun i => (cubeCoord x i : ℂ))).symm + +@[simp] theorem star_walshChar {n : ℕ} (S : Finset (Fin n)) (x : Cube n) : + star (walshChar S x) = walshChar S x := by + simp [walshChar] + +theorem walshChar_mul {n : ℕ} (S T : Finset (Fin n)) (x : Cube n) : + walshChar S x * walshChar T x = walshChar (S ∆ T) x := by + classical + simp only [walshChar_eq_prod_univ, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i hi + by_cases hS : i ∈ S <;> by_cases hT : i ∈ T <;> + cases hx : x i <;> simp [Finset.mem_symmDiff, hS, hT, cubeCoord, hx] + +@[simp] theorem walshChar_mul_self {n : ℕ} (S : Finset (Fin n)) (x : Cube n) : + walshChar S x * walshChar S x = 1 := by + simpa using walshChar_mul S S x + +theorem walshChar_univ_mul {n : ℕ} (S : Finset (Fin n)) (x : Cube n) : + walshChar Finset.univ x * walshChar S x = walshChar (Finset.univ \ S) x := by + rw [walshChar_mul] + congr 1 + ext i + simp [Finset.mem_symmDiff] + +theorem sum_walshChar {n : ℕ} (S : Finset (Fin n)) : + (∑ x : Cube n, walshChar S x) = if S = ∅ then (2 : ℂ) ^ n else 0 := by + classical + have hc (b : Bool) : ((if b then (1 : ℝ) else -1 : ℝ) : ℂ) = + (if b then (1 : ℂ) else -1) := by cases b <;> simp + simp_rw [walshChar_eq_prod_univ, cubeCoord, hc] + rw [← Fintype.prod_sum (fun (i : Fin n) (b : Bool) => + if i ∈ S then (if b then (1 : ℂ) else -1) else 1)] + by_cases hS : S = ∅ + · subst S + simp + · rw [ite_eq_right hS] + obtain ⟨i, hi⟩ := Finset.nonempty_iff_ne_empty.mpr hS + apply Finset.prod_eq_zero (Finset.mem_univ i) + simp [hi] + +/-- Orthogonality for the unnormalized counting inner product. -/ +theorem walshChar_orthogonality {n : ℕ} (S T : Finset (Fin n)) : + (∑ x : Cube n, star (walshChar S x) * walshChar T x) = + if S = T then (2 : ℂ) ^ n else 0 := by + simp_rw [star_walshChar, walshChar_mul] + rw [sum_walshChar] + simp + +/-- Unnormalized Fourier coefficient as a linear functional. -/ +def walshCoefficientLinear {n : ℕ} (S : Finset (Fin n)) : + (Cube n → ℂ) →ₗ[ℂ] ℂ where + toFun f := ∑ x, star (walshChar S x) * f x + map_add' f g := by simp [mul_add, Finset.sum_add_distrib] + map_smul' c f := by simp [Finset.mul_sum, mul_left_comm] + +@[simp] theorem walshCoefficientLinear_char {n : ℕ} (S T : Finset (Fin n)) : + walshCoefficientLinear S (walshChar T) = if S = T then (2 : ℂ) ^ n else 0 := + walshChar_orthogonality S T + +theorem walshChar_linearIndependent (n : ℕ) : + LinearIndependent ℂ (walshChar (n := n)) := by + classical + rw [Fintype.linearIndependent_iff] + intro c hc S + have h := congrArg (walshCoefficientLinear S) hc + have h' : c S * (2 : ℂ) ^ n = 0 := by + simpa only [map_sum, map_smul, walshCoefficientLinear_char, map_zero, + smul_eq_mul, mul_ite, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] using h + exact (mul_eq_zero.mp h').resolve_right (pow_ne_zero _ (by norm_num)) + +theorem walsh_index_card (n : ℕ) : + Fintype.card (Finset (Fin n)) = Module.finrank ℂ (Cube n → ℂ) := by + simp [Module.finrank_fintype_fun_eq_card, Fintype.card_finset, Cube] + +/-- The concrete Walsh basis, indexed by coordinate subsets. -/ +def walshBasis (n : ℕ) : Basis (Finset (Fin n)) ℂ (Cube n → ℂ) := + basisOfLinearIndependentOfCardEqFinrank (walshChar_linearIndependent n) (walsh_index_card n) + +@[simp] theorem walshBasis_apply {n : ℕ} (S : Finset (Fin n)) : + walshBasis n S = walshChar S := by + simp [walshBasis] + +/-- Functions of Fourier degree at most `k`. -/ +def fourierSpace (n k : ℕ) : Submodule ℂ (Cube n → ℂ) := + Submodule.span ℂ (walshChar '' {S : Finset (Fin n) | S.card ≤ k}) + +theorem fourierSpace_mono (n : ℕ) : Monotone (fourierSpace n) := by + intro k l hkl + apply Submodule.span_mono + rintro f ⟨S, hS, rfl⟩ + exact ⟨S, hS.trans hkl, rfl⟩ + +theorem fourierSpace_eq_top {n k : ℕ} (hk : n ≤ k) : fourierSpace n k = ⊤ := by + apply top_unique + rw [← (walshChar_linearIndependent n).span_eq_top_of_card_eq_finrank (walsh_index_card n)] + apply Submodule.span_mono + rintro f ⟨S, rfl⟩ + have hS : S.card ≤ n := by simpa using S.card_le_univ + exact ⟨S, hS.trans hk, rfl⟩ + +/-- Fourier degree filtration in the Hilbert space with counting inner product. -/ +def fourierEuclideanSpace (n k : ℕ) : Submodule ℂ (EuclideanSpace ℂ (Cube n)) := + (fourierSpace n k).map + (WithLp.linearEquiv 2 ℂ (Cube n → ℂ)).symm.toLinearMap + +@[simp] theorem mem_fourierEuclideanSpace {n k : ℕ} + (f : EuclideanSpace ℂ (Cube n)) : + f ∈ fourierEuclideanSpace n k ↔ (fun x => f x) ∈ fourierSpace n k := by + change f ∈ (fourierSpace n k).map + (WithLp.linearEquiv 2 ℂ (Cube n → ℂ)).symm.toLinearMap ↔ _ + rw [Submodule.mem_map_equiv] + rfl + +theorem fourierEuclideanSpace_mono (n : ℕ) : Monotone (fourierEuclideanSpace n) := by + intro k l hkl + exact Submodule.map_mono (fourierSpace_mono n hkl) + +theorem fourierEuclideanSpace_eq_top {n k : ℕ} (hk : n ≤ k) : + fourierEuclideanSpace n k = ⊤ := by + unfold fourierEuclideanSpace + rw [fourierSpace_eq_top hk, Submodule.map_top] + exact LinearMap.range_eq_top.mpr + (WithLp.linearEquiv 2 ℂ (Cube n → ℂ)).symm.surjective + +/-- Shift the degree filtration so that its zeroth member is bottom. -/ +def fourierFlag (n : ℕ) : ℕ → Submodule ℂ (EuclideanSpace ℂ (Cube n)) + | 0 => ⊥ + | k + 1 => fourierEuclideanSpace n k + +@[simp] theorem fourierFlag_zero (n : ℕ) : fourierFlag n 0 = ⊥ := rfl + +@[simp] theorem fourierFlag_succ (n k : ℕ) : + fourierFlag n (k + 1) = fourierEuclideanSpace n k := rfl + +theorem fourierFlag_mono (n : ℕ) : Monotone (fourierFlag n) := by + intro k l hkl + cases k with + | zero => exact bot_le + | succ k => + cases l with + | zero => omega + | succ l => exact fourierEuclideanSpace_mono n (Nat.le_of_succ_le_succ hkl) + +@[simp] theorem fourierFlag_top (n : ℕ) : fourierFlag n (n + 1) = ⊤ := + fourierEuclideanSpace_eq_top (le_refl n) + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/WalshDimensions.lean b/lean/OAI/Combinatorics/GotsmanLinial/WalshDimensions.lean new file mode 100644 index 0000000000000000000000000000000000000000..7efda552c0c9dfaef84557ab426baa6bec3aaaac --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/WalshDimensions.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.GotsmanLinial.Walsh +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Data.Fintype.Powerset +import Mathlib.LinearAlgebra.Dimension.Constructions + +namespace OAI + +/-! +Dimensions of the Walsh degree filtration, derived from the +linear independence of the concrete characters. +-/ + +noncomputable section + +open scoped BigOperators +open Module + +namespace LeanBlast.GotsmanLinial + +/-- Count low-degree character indices by partitioning them according to cardinality. -/ +theorem card_finset_card_le (n k : ℕ) : + Fintype.card {S : Finset (Fin n) // S.card ≤ k} = + ∑ j ∈ Finset.range (k + 1), n.choose j := by + classical + let e : {S : Finset (Fin n) // S.card ≤ k} ≃ + (Σ j : Fin (k + 1), {S : Finset (Fin n) // S.card = j.val}) := { + toFun := fun S => ⟨⟨S.val.card, Nat.lt_succ_of_le S.property⟩, ⟨S.val, rfl⟩⟩ + invFun := fun a => ⟨a.2.val, by + rw [a.2.property] + exact Nat.le_of_lt_succ a.1.isLt⟩ + left_inv := fun S => by rfl + right_inv := fun a => by + rcases a with ⟨⟨j, hj⟩, ⟨S, hS⟩⟩ + dsimp at hS + subst j + rfl + } + rw [Fintype.card_congr e, Fintype.card_sigma] + simp only [Fintype.card_finset_len, Fintype.card_fin] + exact Fin.sum_univ_eq_sum_range _ _ + +/-- The dimension of the degree-`k` Fourier subspace is the number of indices of +cardinality at most `k`. This formula remains valid beyond the saturated stage. -/ +theorem fourierSpace_finrank (n k : ℕ) : + finrank ℂ (fourierSpace n k) = ∑ j ∈ Finset.range (k + 1), n.choose j := by + classical + rw [fourierSpace, Set.image_eq_range] + calc + _ = Fintype.card {S : Finset (Fin n) // S.card ≤ k} := by + exact finrank_span_eq_card ((walshChar_linearIndependent n).comp + (Subtype.val : {S : Finset (Fin n) // S.card ≤ k} → Finset (Fin n)) + Subtype.val_injective) + _ = _ := card_finset_card_le n k + +/-- Each new degree contributes exactly the next binomial multiplicity. -/ +theorem fourierSpace_finrank_add (n k : ℕ) : + finrank ℂ (fourierSpace n k) + n.choose (k + 1) = + finrank ℂ (fourierSpace n (k + 1)) := by + simp only [fourierSpace_finrank] + exact (Finset.sum_range_succ (fun j => n.choose j) (k + 1)).symm + +theorem fourierSpace_finrank_sub (n k : ℕ) : + finrank ℂ (fourierSpace n (k + 1)) - finrank ℂ (fourierSpace n k) = + n.choose (k + 1) := by + rw [← fourierSpace_finrank_add] + exact Nat.add_sub_cancel_left _ _ + +@[simp] theorem fourierSpace_zero_finrank (n : ℕ) : + finrank ℂ (fourierSpace n 0) = 1 := by + simp [fourierSpace_finrank] + +/-- At or above degree `n`, the Fourier space has the full cube dimension. -/ +theorem fourierSpace_finrank_of_le {n k : ℕ} (hnk : n ≤ k) : + finrank ℂ (fourierSpace n k) = 2 ^ n := by + rw [fourierSpace_eq_top hnk, finrank_top] + simp [Module.finrank_fintype_fun_eq_card] + +/-- Arbitrary invertible linear changes of coordinates preserve every Fourier dimension. -/ +theorem map_fourierSpace_finrank {E : Type*} [AddCommGroup E] [Module ℂ E] + (n k : ℕ) (D : (Cube n → ℂ) ≃ₗ[ℂ] E) : + finrank ℂ ((fourierSpace n k).map D.toLinearMap) = + ∑ j ∈ Finset.range (k + 1), n.choose j := by + rw [D.finrank_map_eq, fourierSpace_finrank] + +/-- Passing to the counting Euclidean Hilbert space changes no dimensions. -/ +theorem fourierEuclideanSpace_finrank (n k : ℕ) : + finrank ℂ (fourierEuclideanSpace n k) = + ∑ j ∈ Finset.range (k + 1), n.choose j := by + exact map_fourierSpace_finrank n k (WithLp.linearEquiv 2 ℂ (Cube n → ℂ)).symm + +/-- With the bottom stage inserted, stage `k` contains exactly degrees below `k`. -/ +theorem fourierFlag_finrank (n k : ℕ) : + finrank ℂ (fourierFlag n k) = ∑ j ∈ Finset.range k, n.choose j := by + cases k with + | zero => + rw [fourierFlag_zero, finrank_bot] + simp + | succ k => exact fourierEuclideanSpace_finrank n k + +/-- The degree-`k` layer has the prescribed binomial dimension increment. -/ +theorem fourierFlag_finrank_add (n k : ℕ) : + finrank ℂ (fourierFlag n k) + n.choose k = + finrank ℂ (fourierFlag n (k + 1)) := by + simp only [fourierFlag_finrank] + exact (Finset.sum_range_succ (fun j => n.choose j) k).symm + +theorem fourierFlag_finrank_sub (n k : ℕ) : + finrank ℂ (fourierFlag n (k + 1)) - finrank ℂ (fourierFlag n k) = + n.choose k := by + rw [← fourierFlag_finrank_add] + exact Nat.add_sub_cancel_left _ _ + +/-- Any invertible weight preserves the dimensions of all stages of the Euclidean flag. -/ +theorem map_fourierFlag_finrank (n k : ℕ) + (D : EuclideanSpace ℂ (Cube n) ≃ₗ[ℂ] EuclideanSpace ℂ (Cube n)) : + finrank ℂ ((fourierFlag n k).map D.toLinearMap) = + ∑ j ∈ Finset.range k, n.choose j := by + rw [D.finrank_map_eq, fourierFlag_finrank] + +/-- In particular, an invertible weight preserves each binomial dimension increment. -/ +theorem map_fourierFlag_finrank_add (n k : ℕ) + (D : EuclideanSpace ℂ (Cube n) ≃ₗ[ℂ] EuclideanSpace ℂ (Cube n)) : + finrank ℂ ((fourierFlag n k).map D.toLinearMap) + n.choose k = + finrank ℂ ((fourierFlag n (k + 1)).map D.toLinearMap) := by + rw [D.finrank_map_eq, D.finrank_map_eq] + exact fourierFlag_finrank_add n k + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GotsmanLinial/WeightedGrading.lean b/lean/OAI/Combinatorics/GotsmanLinial/WeightedGrading.lean new file mode 100644 index 0000000000000000000000000000000000000000..4aab6981eabd6ff967e49a5f0c07f83af34e31c3 --- /dev/null +++ b/lean/OAI/Combinatorics/GotsmanLinial/WeightedGrading.lean @@ -0,0 +1,373 @@ +import Mathlib.Analysis.InnerProductSpace.Projection.FiniteDimensional +import Mathlib.Analysis.InnerProductSpace.Adjoint +import Mathlib.Analysis.InnerProductSpace.PiL2 +import OAI.Combinatorics.GotsmanLinial.ProjectionBlocks +import OAI.Combinatorics.GotsmanLinial.ProjectionTrace +import OAI.Combinatorics.GotsmanLinial.WalshDimensions +import OAI.Combinatorics.GotsmanLinial.CoordinateMultipliers + +namespace OAI + +/-! +# The actual weighted orthogonal grading of the cube + +The construction first orthogonalizes an arbitrary finite flag of subspaces. +It then transports the concrete Walsh flag by the invertible square-root +weight and takes the orthogonal projections in the counting Hilbert space. +The resulting matrices are proved to form an orthogonal decomposition of +the identity with the prescribed binomial multiplicities. +-/ + +noncomputable section + +open scoped BigOperators +open Module + +namespace LeanBlast.GotsmanLinial + +section FiniteFlag + +variable {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] + [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] + +local instance : CompleteSpace E := FiniteDimensional.complete 𝕜 E + +/-- The new orthogonal layer appearing between two consecutive stages of a flag. -/ +def flagLayer (K : ℕ → Submodule 𝕜 E) (k : ℕ) : Submodule 𝕜 E := + K (k + 1) ⊓ (K k)ᗮ + +/-- The actual orthogonal projection onto a layer of a finite-dimensional flag. -/ +def flagProjection (K : ℕ → Submodule 𝕜 E) (k : ℕ) : E →L[𝕜] E := + (flagLayer K k).starProjection + +omit [FiniteDimensional 𝕜 E] in +theorem flagLayer_le_next (K : ℕ → Submodule 𝕜 E) (k : ℕ) : + flagLayer K k ≤ K (k + 1) := inf_le_left + +omit [FiniteDimensional 𝕜 E] in +theorem flagLayer_le_prev_orthogonal (K : ℕ → Submodule 𝕜 E) (k : ℕ) : + flagLayer K k ≤ (K k)ᗮ := inf_le_right + +theorem flagLayer_sup_prev (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) (k : ℕ) : + K k ⊔ flagLayer K k = K (k + 1) := by + simpa only [flagLayer, inf_comm] using + Submodule.sup_orthogonal_inf_of_hasOrthogonalProjection (hK (Nat.le_succ k)) + +theorem flagLayer_finrank_add (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) (k : ℕ) : + finrank 𝕜 (K k) + finrank 𝕜 (flagLayer K k) = finrank 𝕜 (K (k + 1)) := by + change finrank 𝕜 (K k) + finrank 𝕜 (K (k + 1) ⊓ (K k)ᗮ : Submodule 𝕜 E) = _ + rw [inf_comm] + exact Submodule.finrank_add_inf_finrank_orthogonal (hK (Nat.le_succ k)) + +theorem flagLayer_finrank (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) (k : ℕ) : + finrank 𝕜 (flagLayer K k) = finrank 𝕜 (K (k + 1)) - finrank 𝕜 (K k) := by + have h := flagLayer_finrank_add K hK k + omega + +omit [FiniteDimensional 𝕜 E] in +theorem flagLayer_isOrtho_of_lt (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) + {r s : ℕ} (hrs : r < s) : flagLayer K r ⟂ flagLayer K s := by + apply Submodule.IsOrtho.symm + exact (flagLayer_le_prev_orthogonal K s).trans + (Submodule.orthogonal_le ((flagLayer_le_next K r).trans (hK hrs))) + +omit [FiniteDimensional 𝕜 E] in +theorem flagLayer_isOrtho (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) + {r s : ℕ} (hrs : r ≠ s) : flagLayer K r ⟂ flagLayer K s := by + rcases lt_or_gt_of_ne hrs with h | h + · exact flagLayer_isOrtho_of_lt K hK h + · exact (flagLayer_isOrtho_of_lt K hK h).symm + +theorem flagLayer_iSup_eq_top (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) + (hzero : K 0 = ⊥) (n : ℕ) (htop : K (n + 1) = ⊤) : + (⨆ k : Fin (n + 1), flagLayer K k.val) = ⊤ := by + let S := ⨆ k : Fin (n + 1), flagLayer K k.val + have hle : ∀ m, m ≤ n + 1 → K m ≤ S := by + intro m + induction m with + | zero => simp [hzero] + | succ m ih => + intro hm + rw [← flagLayer_sup_prev K hK m] + exact sup_le (ih (by omega)) + (le_iSup (fun k : Fin (n + 1) => flagLayer K k.val) ⟨m, by omega⟩) + apply top_unique + rw [← htop] + exact hle (n + 1) le_rfl + +omit [FiniteDimensional 𝕜 E] in +theorem flagLayer_orthogonalFamily (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) + (n : ℕ) : + OrthogonalFamily 𝕜 (fun k : Fin (n + 1) => flagLayer K k.val) + (fun k => (flagLayer K k.val).subtypeₗᵢ) := by + apply OrthogonalFamily.of_pairwise + intro r s hrs + exact flagLayer_isOrtho K hK (fun h => hrs (Fin.ext h)) + +theorem flagProjection_isSelfAdjoint (K : ℕ → Submodule 𝕜 E) (k : ℕ) : + IsSelfAdjoint (flagProjection K k) := + isSelfAdjoint_starProjection (flagLayer K k) + +theorem flagProjection_idempotent (K : ℕ → Submodule 𝕜 E) (k : ℕ) : + flagProjection K k * flagProjection K k = flagProjection K k := + (flagLayer K k).isIdempotentElem_starProjection.eq + +theorem flagProjection_mul_eq_zero (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) + {r s : ℕ} (hrs : r ≠ s) : flagProjection K r * flagProjection K s = 0 := + (flagLayer_isOrtho K hK hrs).starProjection_comp_starProjection + +theorem sum_flagProjection (K : ℕ → Submodule 𝕜 E) (hK : Monotone K) + (hzero : K 0 = ⊥) (n : ℕ) (htop : K (n + 1) = ⊤) : + (∑ k : Fin (n + 1), flagProjection K k.val) = 1 := by + ext x + change (∑ k : Fin (n + 1), (flagLayer K k.val).starProjection) x = x + rw [sum_apply] + apply (flagLayer_orthogonalFamily K hK n).sum_projection_of_mem_iSup + rw [flagLayer_iSup_eq_top K hK hzero n htop] + trivial + +@[simp] +theorem range_flagProjection (K : ℕ → Submodule 𝕜 E) (k : ℕ) : + (flagProjection K k).range = flagLayer K k := + Submodule.range_starProjection (flagLayer K k) + +theorem flagProjection_apply_mem_next (K : ℕ → Submodule 𝕜 E) (k : ℕ) (x : E) : + flagProjection K k x ∈ K (k + 1) := + (flagLayer K k).starProjection_apply_mem x |>.1 + +theorem flagProjection_apply_eq_zero_of_mem_prev (K : ℕ → Submodule 𝕜 E) + (k : ℕ) {x : E} (hx : x ∈ K k) : flagProjection K k x = 0 := by + have ho : x ∈ (flagLayer K k)ᗮ := + Submodule.orthogonal_le (flagLayer_le_prev_orthogonal K k) + ((K k).le_orthogonal_orthogonal hx) + exact congrArg Subtype.val + (Submodule.orthogonalProjectionOnto_eq_zero_iff.mpr ho) + +end FiniteFlag + +section InvertibleWeights + +variable {Ω : Type*} [Fintype Ω] + +/-- Multiplication by pointwise nonzero coefficients is a linear equivalence. -/ +def coordinateMulEquiv (a : Ω → ℂ) (ha : ∀ x, a x ≠ 0) : + (Ω → ℂ) ≃ₗ[ℂ] (Ω → ℂ) where + toFun f x := a x * f x + invFun f x := (a x)⁻¹ * f x + left_inv f := by + funext x + simp only [← mul_assoc, inv_mul_cancel₀ (ha x), one_mul] + right_inv f := by + funext x + simp only [← mul_assoc, mul_inv_cancel₀ (ha x), one_mul] + map_add' f g := by + funext x + exact mul_add _ _ _ + map_smul' c f := by + funext x + exact mul_left_comm _ _ _ + +/-- Multiplication by the square root of a strictly positive weight, in the +counting Euclidean Hilbert space. -/ +def sqrtWeightEquiv (w : Ω → ℝ) (hw : ∀ x, 0 < w x) : + EuclideanSpace ℂ Ω ≃ₗ[ℂ] EuclideanSpace ℂ Ω := + ((WithLp.linearEquiv 2 ℂ (Ω → ℂ)).trans + (coordinateMulEquiv (fun x => (Real.sqrt (w x) : ℂ)) + (fun x => Complex.ofReal_ne_zero.mpr (ne_of_gt (Real.sqrt_pos.2 (hw x)))))).trans + (WithLp.linearEquiv 2 ℂ (Ω → ℂ)).symm + +omit [Fintype Ω] in +@[simp] +theorem sqrtWeightEquiv_apply (w : Ω → ℝ) (hw : ∀ x, 0 < w x) + (f : EuclideanSpace ℂ Ω) (x : Ω) : + sqrtWeightEquiv w hw f x = (Real.sqrt (w x) : ℂ) * f x := rfl + +omit [Fintype Ω] in +@[simp] +theorem sqrtWeightEquiv_symm_apply (w : Ω → ℝ) (hw : ∀ x, 0 < w x) + (f : EuclideanSpace ℂ Ω) (x : Ω) : + (sqrtWeightEquiv w hw).symm f x = (Real.sqrt (w x) : ℂ)⁻¹ * f x := rfl + +end InvertibleWeights + +section Transport + +variable {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] + [InnerProductSpace 𝕜 E] + +/-- Transport a degree flag through an invertible linear weight operator. -/ +def transportFlag (D : E ≃ₗ[𝕜] E) (F : ℕ → Submodule 𝕜 E) (k : ℕ) : + Submodule 𝕜 E := (F k).map D.toLinearMap + +theorem transportFlag_monotone (D : E ≃ₗ[𝕜] E) (F : ℕ → Submodule 𝕜 E) + (hF : Monotone F) : Monotone (transportFlag D F) := by + intro i j hij + exact Submodule.map_mono (hF hij) + +theorem transportFlag_zero (D : E ≃ₗ[𝕜] E) (F : ℕ → Submodule 𝕜 E) + (hF : F 0 = ⊥) : transportFlag D F 0 = ⊥ := by + simp [transportFlag, hF] + +theorem transportFlag_top (D : E ≃ₗ[𝕜] E) (F : ℕ → Submodule 𝕜 E) + (k : ℕ) (hF : F k = ⊤) : transportFlag D F k = ⊤ := by + simp [transportFlag, hF] + +theorem transportFlag_finrank (D : E ≃ₗ[𝕜] E) (F : ℕ → Submodule 𝕜 E) (k : ℕ) : + finrank 𝕜 (transportFlag D F k) = finrank 𝕜 (F k) := + D.finrank_map_eq (F k) + +/-- The weighted construction preserves every prescribed dimension increment. -/ +theorem transportFlag_layer_finrank [FiniteDimensional 𝕜 E] (D : E ≃ₗ[𝕜] E) + (F : ℕ → Submodule 𝕜 E) (hF : Monotone F) (k d : ℕ) + (hd : finrank 𝕜 (F k) + d = finrank 𝕜 (F (k + 1))) : + finrank 𝕜 (flagLayer (transportFlag D F) k) = d := by + have h := flagLayer_finrank_add (transportFlag D F) (transportFlag_monotone D F hF) k + rw [transportFlag_finrank, transportFlag_finrank] at h + omega + +end Transport + +section MatrixTransport + +variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + [FiniteDimensional ℂ E] [Fintype ι] [DecidableEq ι] + +local instance : CompleteSpace E := FiniteDimensional.complete ℂ E + +/-- Matrix of an actual flag-layer projection in an orthonormal basis. -/ +def flagProjectionMatrix (b : OrthonormalBasis ι ℂ E) + (K : ℕ → Submodule ℂ E) (k : ℕ) : Matrix ι ι ℂ := + operatorMatrix b (flagProjection K k) + +/-- The matrix projection-family laws follow from the constructed Hilbert-space +projections, without any additional grading hypothesis. -/ +theorem flagProjectionMatrix_family (b : OrthonormalBasis ι ℂ E) + (K : ℕ → Submodule ℂ E) (hK : Monotone K) (hzero : K 0 = ⊥) + (n : ℕ) (htop : K (n + 1) = ⊤) : + OrthogonalProjectionFamily (fun k : Fin (n + 1) => flagProjectionMatrix b K k.val) := + orthogonalProjectionFamily_operatorMatrix b + (fun k : Fin (n + 1) => flagProjection K k.val) + (fun k => flagProjection_isSelfAdjoint K k.val) + (fun k => flagProjection_idempotent K k.val) + (fun _ _ hrs => flagProjection_mul_eq_zero K hK (fun h => hrs (Fin.ext h))) + (sum_flagProjection K hK hzero n htop) + +theorem trace_flagProjectionMatrix (b : OrthonormalBasis ι ℂ E) + (K : ℕ → Submodule ℂ E) (k : ℕ) : + Matrix.trace (flagProjectionMatrix b K k) = (finrank ℂ (flagLayer K k) : ℂ) := + trace_toMatrixOrthonormal_starProjection b (flagLayer K k) + +theorem re_trace_flagProjectionMatrix (b : OrthonormalBasis ι ℂ E) + (K : ℕ → Submodule ℂ E) (k : ℕ) : + (Matrix.trace (flagProjectionMatrix b K k)).re = (finrank ℂ (flagLayer K k) : ℝ) := + re_trace_toMatrixOrthonormal_starProjection b (flagLayer K k) + +end MatrixTransport + +section WeightedCube + +variable {n : ℕ} + +/-- The weighted degree-`k` subspace of the counting Hilbert space. -/ +def weightedFourierSpace (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) (k : ℕ) : + Submodule ℂ (EuclideanSpace ℂ (Cube n)) := + (fourierEuclideanSpace n k).map (sqrtWeightEquiv w hw).toLinearMap + +/-- The weighted Fourier flag, shifted by one so that stage zero is bottom. -/ +def weightedFourierFlag (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) : + ℕ → Submodule ℂ (EuclideanSpace ℂ (Cube n)) := + transportFlag (sqrtWeightEquiv w hw) (fourierFlag n) + +@[simp] +theorem weightedFourierFlag_zero (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) : + weightedFourierFlag w hw 0 = ⊥ := + transportFlag_zero _ _ (fourierFlag_zero n) + +@[simp] +theorem weightedFourierFlag_succ (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) (k : ℕ) : + weightedFourierFlag w hw (k + 1) = weightedFourierSpace w hw k := rfl + +theorem weightedFourierFlag_mono (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) : + Monotone (weightedFourierFlag w hw) := + transportFlag_monotone _ _ (fourierFlag_mono n) + +@[simp] +theorem weightedFourierFlag_top (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) : + weightedFourierFlag w hw (n + 1) = ⊤ := + transportFlag_top _ _ _ (fourierFlag_top n) + +/-- Weighting preserves the exact binomial dimensions of the orthogonal layers. -/ +theorem weightedFourierFlag_layer_finrank (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (k : ℕ) : + finrank ℂ (flagLayer (weightedFourierFlag w hw) k) = n.choose k := + transportFlag_layer_finrank (sqrtWeightEquiv w hw) (fourierFlag n) + (fourierFlag_mono n) k (n.choose k) (fourierFlag_finrank_add n k) + +/-- Actual orthogonal projection onto weighted Fourier layer `k`. -/ +def weightedProjection (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) (k : Fin (n + 1)) : + EuclideanSpace ℂ (Cube n) →L[ℂ] EuclideanSpace ℂ (Cube n) := + flagProjection (weightedFourierFlag w hw) k.val + +/-- The projection represented in the point-mass orthonormal basis. -/ +def weightedProjectionMatrix (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (k : Fin (n + 1)) : Matrix (Cube n) (Cube n) ℂ := + flagProjectionMatrix (EuclideanSpace.basisFun (Cube n) ℂ) + (weightedFourierFlag w hw) k.val + +theorem weightedProjection_apply_mem (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (k : Fin (n + 1)) (f : EuclideanSpace ℂ (Cube n)) : + weightedProjection w hw k f ∈ weightedFourierSpace w hw k.val := + flagProjection_apply_mem_next (weightedFourierFlag w hw) k.val f + +theorem weightedProjection_annihilate_prev (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (k : Fin (n + 1)) {f : EuclideanSpace ℂ (Cube n)} + (hf : f ∈ weightedFourierFlag w hw k.val) : weightedProjection w hw k f = 0 := + flagProjection_apply_eq_zero_of_mem_prev (weightedFourierFlag w hw) k.val hf + +theorem weightedProjectionMatrix_family (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) : + OrthogonalProjectionFamily (weightedProjectionMatrix w hw) := + flagProjectionMatrix_family (EuclideanSpace.basisFun (Cube n) ℂ) + (weightedFourierFlag w hw) (weightedFourierFlag_mono w hw) + (weightedFourierFlag_zero w hw) n (weightedFourierFlag_top w hw) + +theorem weightedProjectionMatrix_trace (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (k : Fin (n + 1)) : + Matrix.trace (weightedProjectionMatrix w hw k) = (n.choose k.val : ℂ) := by + rw [weightedProjectionMatrix, trace_flagProjectionMatrix, weightedFourierFlag_layer_finrank] + +theorem weightedProjectionMatrix_trace_re (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (k : Fin (n + 1)) : + (Matrix.trace (weightedProjectionMatrix w hw k)).re = (n.choose k.val : ℝ) := by + rw [weightedProjectionMatrix_trace] + simp + +theorem weightedProjectionMatrix_hsNormSq (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) + (k : Fin (n + 1)) : hsNormSq (weightedProjectionMatrix w hw k) = (n.choose k.val : ℝ) := by + rw [hsNormSq_projection _ ((weightedProjectionMatrix_family w hw).conjTranspose_eq k) + ((weightedProjectionMatrix_family w hw).idempotent k)] + exact weightedProjectionMatrix_trace_re w hw k + +/-- Every real diagonal multiplier commutes with the positive square-root weight. -/ +theorem sqrtWeightEquiv_commute_signMultiplier + (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) (h : Cube n → ℝ) + (f : EuclideanSpace ℂ (Cube n)) : + signMultiplier h (sqrtWeightEquiv w hw f) = + sqrtWeightEquiv w hw (signMultiplier h f) := by + ext x + simp only [signMultiplier_apply, sqrtWeightEquiv_apply] + exact mul_left_comm _ _ _ + +theorem sqrtWeightEquiv_commute_coordinateMultiplier + (w : Cube n → ℝ) (hw : ∀ x, 0 < w x) (i : Fin n) + (f : EuclideanSpace ℂ (Cube n)) : + coordinateMultiplier i (sqrtWeightEquiv w hw f) = + sqrtWeightEquiv w hw (coordinateMultiplier i f) := + sqrtWeightEquiv_commute_signMultiplier w hw (fun x => cubeCoord x i) f + +end WeightedCube + +end LeanBlast.GotsmanLinial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphSpectrum/SampledChromatic.lean b/lean/OAI/Combinatorics/GraphSpectrum/SampledChromatic.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1ab9cd7e9b749b3c5236bcf3388d45e1f4ab3ca --- /dev/null +++ b/lean/OAI/Combinatorics/GraphSpectrum/SampledChromatic.lean @@ -0,0 +1,476 @@ +import Mathlib + +namespace OAI + +/-! Colin de Verdiere matrix definitions and chromatic bounds for graphs sampled from a binary hole relation. -/ + +namespace CdV + +open Matrix + +variable {V : Type*} [Fintype V] [DecidableEq V] + +def WellSigned (G : SimpleGraph V) (M : Matrix V V ℝ) : Prop := + M.IsSymm ∧ ∀ i j, i ≠ j → + (G.Adj i j → M i j < 0) ∧ (¬G.Adj i j → M i j = 0) + +def OneNegativeEigenvalue (M : Matrix V V ℝ) : Prop := by + classical + exact ∃ hM : M.IsHermitian, + Fintype.card {i : V // hM.eigenvalues i < 0} = 1 + +def StrongArnold (G : SimpleGraph V) (M : Matrix V V ℝ) : Prop := + ∀ X : Matrix V V ℝ, X.IsSymm → M * X = 0 → + (∀ i, X i i = 0) → (∀ i j, G.Adj i j → X i j = 0) → X = 0 + +noncomputable def nullity (M : Matrix V V ℝ) : ℕ := + Module.finrank ℝ (LinearMap.ker M.mulVecLin) + +def Admissible (G : SimpleGraph V) (M : Matrix V V ℝ) : Prop := + WellSigned G M ∧ OneNegativeEigenvalue M ∧ StrongArnold G M + +def admissibleNullities (G : SimpleGraph V) : Set ℕ := + {k | ∃ M : Matrix V V ℝ, Admissible G M ∧ nullity M = k} + +noncomputable def mu (G : SimpleGraph V) : ℕ := sSup (admissibleNullities G) + +noncomputable def chi (G : SimpleGraph V) : ℕ := G.chromaticNumber.toNat + +def ChromaticConjecture : Prop := + ∀ n : ℕ, 0 < n → ∀ G : SimpleGraph (Fin n), chi G ≤ mu G + 1 + +omit [DecidableEq V] in +lemma rank_add_nullity (M : Matrix V V ℝ) : + M.rank + nullity M = Fintype.card V := by + simpa [Matrix.rank, nullity] using M.mulVecLin.finrank_range_add_finrank_ker + +omit [DecidableEq V] in +lemma nullity_le_card (M : Matrix V V ℝ) : nullity M ≤ Fintype.card V := by + have := rank_add_nullity M + omega + +lemma admissibleNullities_bddAbove (G : SimpleGraph V) : + BddAbove (admissibleNullities G) := by + refine ⟨Fintype.card V, ?_⟩ + rintro k ⟨M, _, rfl⟩ + exact nullity_le_card M + +lemma nullity_le_mu {G : SimpleGraph V} {M : Matrix V V ℝ} + (hM : Admissible G M) : nullity M ≤ mu G := by + exact le_csSup (admissibleNullities_bddAbove G) ⟨M, hM, rfl⟩ + +lemma mu_le_card (G : SimpleGraph V) : mu G ≤ Fintype.card V := by + apply csSup_le' + rintro k ⟨M, _, rfl⟩ + exact nullity_le_card M + +lemma exists_nullity_eq_mu {G : SimpleGraph V} + (hG : ∃ M, Admissible G M) : + ∃ M, Admissible G M ∧ nullity M = mu G := by + apply Nat.sSup_mem _ (admissibleNullities_bddAbove G) + obtain ⟨M, hM⟩ := hG + exact ⟨nullity M, M, hM, rfl⟩ + +lemma strongArnold_of_isUnit {G : SimpleGraph V} {M : Matrix V V ℝ} + (hM : IsUnit M) : StrongArnold G M := by + intro X _ hMX _ _ + obtain ⟨U, rfl⟩ := hM + have h := congrArg (fun A : Matrix V V ℝ => (↑U⁻¹ : Matrix V V ℝ) * A) hMX + simpa [← mul_assoc] using h + +omit [DecidableEq V] in + +private lemma neg_card_of_trace (f : V → ℝ) (c R : ℝ) + (hc : 0 < c) (hmargin : (Fintype.card V : ℝ) * R < 2 * c) + (hnear : ∀ i, |f i - (if f i < 0 then -c else c)| ≤ R) + (hsum : ∑ i, f i = (Fintype.card V : ℝ) * c - 2 * c) : + Fintype.card {i : V // f i < 0} = 1 := by + classical + let S : Finset V := Finset.univ.filter (fun i => f i < 0) + have hcenter : (∑ i, if f i < 0 then -c else c) = + (Fintype.card V : ℝ) * c - 2 * (S.card : ℝ) * c := by + calc + _ = ∑ i, (c - if f i < 0 then 2 * c else 0) := by + apply Finset.sum_congr rfl + intro i _ + split_ifs <;> ring + _ = _ := by + rw [Finset.sum_sub_distrib] + simp [S, Finset.sum_ite] + ring + have herr : |2 * ((S.card : ℝ) - 1) * c| < 2 * c := by + calc + _ = |∑ i, (f i - (if f i < 0 then -c else c))| := by + rw [Finset.sum_sub_distrib, hsum, hcenter] + congr 1 + ring + _ ≤ ∑ i, |f i - (if f i < 0 then -c else c)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : V, R := Finset.sum_le_sum fun i _ => hnear i + _ = (Fintype.card V : ℝ) * R := by simp + _ < 2 * c := hmargin + have hb := abs_lt.mp herr + have hlo : 0 < (S.card : ℝ) := by nlinarith + have hhi : (S.card : ℝ) < 2 := by nlinarith + have hpos : 0 < S.card := by exact_mod_cast hlo + have hlt : S.card < 2 := by exact_mod_cast hhi + have hcard : S.card = 1 := by omega + simpa [S, Fintype.card_subtype] using hcard + +noncomputable def seedMatrix (G : SimpleGraph V) (v : V) (c : ℝ) : Matrix V V ℝ := by + classical + exact Matrix.diagonal (fun i => if i = v then -c else c) - G.adjMatrix ℝ + +omit [Fintype V] in +lemma seedMatrix_isSymm (G : SimpleGraph V) (v : V) (c : ℝ) : + (seedMatrix G v c).IsSymm := by + classical + exact (Matrix.isSymm_diagonal _).sub (G.isSymm_adjMatrix) + +omit [Fintype V] in +lemma seedMatrix_diag (G : SimpleGraph V) (v i : V) (c : ℝ) : + seedMatrix G v c i i = if i = v then -c else c := by + classical + simp [seedMatrix, SimpleGraph.adjMatrix_apply] + +open scoped Classical in +omit [Fintype V] in +lemma seedMatrix_offDiag (G : SimpleGraph V) (v i j : V) (c : ℝ) (hij : i ≠ j) : + seedMatrix G v c i j = if G.Adj i j then -1 else 0 := by + classical + simp only [seedMatrix, Matrix.sub_apply, Matrix.diagonal_apply_ne _ hij, + SimpleGraph.adjMatrix_apply, zero_sub] + split_ifs <;> norm_num + +lemma seedMatrix_offDiag_norm_sum (G : SimpleGraph V) (v i : V) (c : ℝ) : + (∑ j ∈ Finset.univ.erase i, ‖seedMatrix G v c i j‖) ≤ Fintype.card V := by + classical + calc + _ ≤ ∑ _j ∈ Finset.univ.erase i, (1 : ℝ) := by + apply Finset.sum_le_sum + intro j hj + rw [seedMatrix_offDiag G v i j c (Finset.ne_of_mem_erase hj).symm] + split_ifs <;> norm_num + _ = ((Finset.univ.erase i).card : ℝ) := by simp + _ ≤ (Fintype.card V : ℝ) := by exact_mod_cast Finset.card_le_card (Finset.erase_subset i Finset.univ) + +lemma seedMatrix_trace (G : SimpleGraph V) (v : V) (c : ℝ) : + Matrix.trace (seedMatrix G v c) = (Fintype.card V : ℝ) * c - 2 * c := by + classical + calc + _ = ∑ i, (c - if i = v then 2 * c else 0) := by + unfold Matrix.trace Matrix.diag + apply Finset.sum_congr rfl + intro i _ + rw [seedMatrix_diag] + split_ifs <;> ring + _ = _ := by rw [Finset.sum_sub_distrib]; simp + +lemma seedMatrix_neg_eigenvalues (G : SimpleGraph V) (v : V) {c : ℝ} + (hc : (Fintype.card V : ℝ) < c) + (hmargin : (Fintype.card V : ℝ) ^ 2 < 2 * c) : + let hM : (seedMatrix G v c).IsHermitian := + Matrix.isHermitian_iff_isSymm.mpr (seedMatrix_isSymm G v c) + Fintype.card {i : V // hM.eigenvalues i < 0} = 1 := by + classical + intro hM + apply neg_card_of_trace hM.eigenvalues c (Fintype.card V) + · exact lt_of_le_of_lt (Nat.cast_nonneg _) hc + · nlinarith + · intro i + have heig : Module.End.HasEigenvalue (Matrix.toLin' (seedMatrix G v c)) (hM.eigenvalues i) := by + apply Module.End.HasEigenvalue.of_mem_spectrum + rw [Matrix.spectrum_toLin'] + exact hM.eigenvalues_mem_spectrum_real i + obtain ⟨k, hk⟩ := eigenvalue_mem_ball heig + have hk' : |hM.eigenvalues i - (if k = v then -c else c)| ≤ Fintype.card V := by + have h := hk.trans (seedMatrix_offDiag_norm_sum G v k c) + simpa only [Metric.mem_closedBall, Real.dist_eq, seedMatrix_diag] using h + by_cases hkv : k = v + · simp only [hkv, ite_true] at hk' + have hneg : hM.eigenvalues i < 0 := by + have := (abs_le.mp hk').2 + linarith + simpa only [hneg, ite_true] using hk' + · simp only [hkv, ite_false] at hk' + have hpos : ¬ hM.eigenvalues i < 0 := by + have := (abs_le.mp hk').1 + linarith + simpa only [hpos, ite_false] using hk' + · have ht : Matrix.trace (seedMatrix G v c) = ∑ i, hM.eigenvalues i := by + simpa using hM.trace_eq_sum_eigenvalues + rw [← ht] + exact seedMatrix_trace G v c + +lemma seedMatrix_isUnit (G : SimpleGraph V) (v : V) {c : ℝ} + (hc : (Fintype.card V : ℝ) < c) : IsUnit (seedMatrix G v c) := by + classical + apply (Matrix.isUnit_iff_isUnit_det _).mpr + apply isUnit_iff_ne_zero.mpr + apply det_ne_zero_of_sum_row_lt_diag + intro i + apply lt_of_le_of_lt (seedMatrix_offDiag_norm_sum G v i c) + rw [seedMatrix_diag] + split_ifs <;> simpa [abs_of_pos (lt_of_le_of_lt (Nat.cast_nonneg _) hc)] using hc + +lemma exists_admissible [Nonempty V] (G : SimpleGraph V) : + ∃ M : Matrix V V ℝ, Admissible G M := by + classical + let v : V := Classical.arbitrary V + let c : ℝ := (Fintype.card V : ℝ) ^ 2 + 1 + have hc : (Fintype.card V : ℝ) < c := by + dsimp [c] + nlinarith [sq_nonneg ((Fintype.card V : ℝ) - 1 / 2)] + have hmargin : (Fintype.card V : ℝ) ^ 2 < 2 * c := by + dsimp [c] + nlinarith [sq_nonneg (Fintype.card V : ℝ)] + refine ⟨seedMatrix G v c, ?_, ?_, ?_⟩ + · refine ⟨seedMatrix_isSymm G v c, ?_⟩ + intro i j hij + rw [seedMatrix_offDiag G v i j c hij] + constructor + · intro h; simp [h] + · intro h; simp [h] + · refine ⟨Matrix.isHermitian_iff_isSymm.mpr (seedMatrix_isSymm G v c), ?_⟩ + exact seedMatrix_neg_eigenvalues G v hc hmargin + · exact strongArnold_of_isUnit (seedMatrix_isUnit G v hc) + +lemma admissibleNullities_nonempty [Nonempty V] (G : SimpleGraph V) : + (admissibleNullities G).Nonempty := by + obtain ⟨M, hM⟩ := exists_admissible G + exact ⟨nullity M, M, hM, rfl⟩ + +lemma exists_maximizing_admissible [Nonempty V] (G : SimpleGraph V) : + ∃ M, Admissible G M ∧ nullity M = mu G := + exists_nullity_eq_mu (exists_admissible G) + +def RankObstruction (G : SimpleGraph V) : Prop := + ∀ M : Matrix V V ℝ, WellSigned G M → OneNegativeEigenvalue M → + (Fintype.card V : ℝ) / 2 + 1 < (M.rank : ℝ) + +lemma mu_gap_of_rankObstruction [Nonempty V] {G : SimpleGraph V} + (hrank : RankObstruction G) : + (mu G : ℝ) + 1 < (Fintype.card V : ℝ) / 2 := by + obtain ⟨M, hM, hnull⟩ := exists_maximizing_admissible G + have hR := hrank M hM.1 hM.2.1 + have hdim : (M.rank : ℝ) + (nullity M : ℝ) = (Fintype.card V : ℝ) := by + exact_mod_cast rank_add_nullity M + rw [hnull] at hdim + linarith + +omit [DecidableEq V] in +lemma chi_colorable (G : SimpleGraph V) : G.Colorable (chi G) := + G.colorable_chromaticNumber_of_fintype + +omit [DecidableEq V] in + +lemma card_le_indepNum_mul_chi (G : SimpleGraph V) : + Fintype.card V ≤ G.indepNum * chi G := by + classical + obtain ⟨C⟩ := chi_colorable G + have hfiber (c : Fin (chi G)) : + Fintype.card {v : V // C v = c} ≤ G.indepNum := by + have hind : G.IsIndepSet ((Finset.univ.filter (fun v : V => C v = c)) : Set V) := by + intro v hv w hw _ + exact C.not_adj_of_mem_colorClass (Finset.mem_filter.mp hv).2 + (Finset.mem_filter.mp hw).2 + simpa [Fintype.card_subtype] using hind.card_le_indepNum + calc + Fintype.card V = Fintype.card (Σ c : Fin (chi G), {v : V // C v = c}) := + Fintype.card_congr (Equiv.sigmaFiberEquiv C).symm + _ = ∑ c : Fin (chi G), Fintype.card {v : V // C v = c} := Fintype.card_sigma + _ ≤ ∑ _c : Fin (chi G), G.indepNum := Finset.sum_le_sum fun c _ => hfiber c + _ = G.indepNum * chi G := by simp [Nat.mul_comm] + +omit [DecidableEq V] in +lemma half_order_le_chi {G : SimpleGraph V} (hα : G.indepNum ≤ 2) : + (Fintype.card V : ℝ) / 2 ≤ (chi G : ℝ) := by + have h : Fintype.card V ≤ 2 * chi G := + (card_le_indepNum_mul_chi G).trans (Nat.mul_le_mul_right _ hα) + have hR : (Fintype.card V : ℝ) ≤ 2 * (chi G : ℝ) := by exact_mod_cast h + linarith + +omit [Fintype V] [DecidableEq V] in +lemma indepNum_le_two_of_no_independent_triple (G : SimpleGraph V) + (hG : ∀ a b c : V, a ≠ b → a ≠ c → b ≠ c → + ¬ G.Adj a b → ¬ G.Adj a c → ¬ G.Adj b c → False) : + G.indepNum ≤ 2 := by + obtain ⟨S, hS⟩ := G.exists_isNIndepSet_indepNum + rw [← hS.card_eq] + by_contra h + obtain ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩ := + Finset.two_lt_card_iff.mp (Nat.lt_of_not_ge h) + exact hG a b c hab hac hbc (hS.isIndepSet ha hb hab) + (hS.isIndepSet ha hc hac) (hS.isIndepSet hb hc hbc) + +lemma inequalities_of_rankObstruction [Nonempty V] {G : SimpleGraph V} + (hα : G.indepNum ≤ 2) (hrank : RankObstruction G) : + (mu G : ℝ) + 1 < (Fintype.card V : ℝ) / 2 ∧ + (Fintype.card V : ℝ) / 2 ≤ (chi G : ℝ) := + ⟨mu_gap_of_rankObstruction hrank, half_order_le_chi hα⟩ + +lemma not_chromaticConjecture_of_gap {n : ℕ} (hn : 0 < n) + (G : SimpleGraph (Fin n)) + (hμ : (mu G : ℝ) + 1 < (n : ℝ) / 2) + (hχ : (n : ℝ) / 2 ≤ (chi G : ℝ)) : + ¬ ChromaticConjecture := by + intro hconj + have h : (chi G : ℝ) ≤ (mu G : ℝ) + 1 := by + exact_mod_cast hconj n hn G + linarith + +def cliqueBlowup (H : SimpleGraph V) (s : ℕ) : SimpleGraph (V × Fin s) where + Adj p q := p ≠ q ∧ (p.1 = q.1 ∨ H.Adj p.1 q.1) + symm := ⟨by + intro p q hpq + exact ⟨hpq.1.symm, hpq.2.elim (fun h => Or.inl h.symm) + (fun h => Or.inr h.symm)⟩⟩ + loopless := ⟨by intro p hp; exact hp.1 rfl⟩ + +lemma indepNum_cliqueBlowup_le (H : SimpleGraph V) (s : ℕ) : + (cliqueBlowup H s).indepNum ≤ H.indepNum := by + classical + obtain ⟨S, hS⟩ := (cliqueBlowup H s).exists_isNIndepSet_indepNum + have hinj : Set.InjOn Prod.fst (S : Set (V × Fin s)) := by + intro p hp q hq heq + by_contra hne + exact hS.isIndepSet hp hq hne ⟨hne, Or.inl heq⟩ + have hproj : H.IsIndepSet (S.image Prod.fst : Set V) := by + intro v hv w hw hvw hvwAdj + obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hv + obtain ⟨q, hq, rfl⟩ := Finset.mem_image.mp hw + have hpq : p ≠ q := fun h => hvw (congrArg Prod.fst h) + exact hS.isIndepSet hp hq hpq ⟨hpq, Or.inr hvwAdj⟩ + calc + (cliqueBlowup H s).indepNum = S.card := hS.card_eq.symm + _ = (S.image Prod.fst).card := (Finset.card_image_of_injOn hinj).symm + _ ≤ H.indepNum := hproj.card_le_indepNum + +lemma indepNum_cliqueBlowup (H : SimpleGraph V) {s : ℕ} (hs : 0 < s) : + (cliqueBlowup H s).indepNum = H.indepNum := by + classical + apply le_antisymm (indepNum_cliqueBlowup_le H s) + obtain ⟨S, hS⟩ := H.exists_isNIndepSet_indepNum + let f : V → V × Fin s := fun v => (v, ⟨0, hs⟩) + have hf : Function.Injective f := fun v w h => congrArg Prod.fst h + have hind : (cliqueBlowup H s).IsIndepSet (S.image f : Set (V × Fin s)) := by + intro p hp q hq hpq hadj + obtain ⟨v, hv, rfl⟩ := Finset.mem_image.mp hp + obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hq + have hvw : v ≠ w := fun h => hpq (congrArg f h) + rcases hadj.2 with heq | hedge + · exact hvw heq + · exact hS.isIndepSet hv hw hvw hedge + calc + H.indepNum = S.card := hS.card_eq.symm + _ = (S.image f).card := (Finset.card_image_of_injective S hf).symm + _ ≤ (cliqueBlowup H s).indepNum := hind.card_le_indepNum + +lemma cliqueBlowup_independence_and_colouring (H : SimpleGraph V) + (hH : H.indepNum ≤ 2) (s : ℕ) : + (cliqueBlowup H s).indepNum ≤ 2 ∧ + (Fintype.card V * s : ℝ) / 2 ≤ (chi (cliqueBlowup H s) : ℝ) := by + have hα := (indepNum_cliqueBlowup_le H s).trans hH + refine ⟨hα, ?_⟩ + simpa using half_order_le_chi hα + +namespace Geometry + +abbrev F := ZMod 2 + +variable {X A Ω : Type*} [AddCommGroup X] [Module F X] + [AddCommGroup A] [Module F A] + +def Hole (U : Ω → X →ₗ[F] A) (u : Ω → A →ₗ[F] F) + (a : X →ₗ[F] F) (T : X →ₗ[F] X →ₗ[F] F) (i j : Ω) : Prop := + ∃ x y : X, U i x = U j y ∧ + (u j).comp (U i) = a + T x ∧ + (u i).comp (U j) = a + T y ∧ + a x + a y = 1 + +variable {U : Ω → X →ₗ[F] A} {u : Ω → A →ₗ[F] F} + {a : X →ₗ[F] F} {T : X →ₗ[F] X →ₗ[F] F} + +lemma hole_symm {i j : Ω} (h : Hole U u a T i j) : Hole U u a T j i := by + obtain ⟨x, y, hxy, hi, hj, hpar⟩ := h + exact ⟨y, x, hxy.symm, hj, hi, by simpa [add_comm] using hpar⟩ + +lemma hole_irrefl (hU : ∀ i, Function.Injective (U i)) (i : Ω) : + ¬ Hole U u a T i i := by + rintro ⟨x, y, hxy, _, _, hpar⟩ + have h := hU i hxy + rw [h, CharTwo.add_self_eq_zero] at hpar + exact zero_ne_one hpar + +lemma hole_triangle_free (hT : ∀ x y : X, T x y = T y x) + (i j k : Ω) (hij : Hole U u a T i j) + (hik : Hole U u a T i k) (hjk : Hole U u a T j k) : False := by + obtain ⟨xij, xji, sij, gij, gji, pij⟩ := hij + obtain ⟨xik, xki, sik, gik, gki, pik⟩ := hik + obtain ⟨xjk, xkj, sjk, gjk, gkj, pjk⟩ := hjk + have eval {v w : Ω} {x : X} (h : (u w).comp (U v) = a + T x) (y : X) : + u w (U v y) = a y + T x y := DFunLike.congr_fun h y + have e1 : a xik + T xij xik = a xki + T xki xkj := by + calc + _ = u j (U i xik) := (eval gij xik).symm + _ = u j (U k xki) := congrArg (u j) sik + _ = a xki + T xkj xki := eval gkj xki + _ = _ := by rw [hT xkj xki] + have e2 : a xij + T xij xik = a xji + T xji xjk := by + calc + _ = a xij + T xik xij := by rw [hT xik xij] + _ = u k (U i xij) := (eval gik xij).symm + _ = u k (U j xji) := congrArg (u k) sij + _ = a xji + T xjk xji := eval gjk xji + _ = _ := by rw [hT xjk xji] + have e3 : a xjk + T xji xjk = a xkj + T xki xkj := by + calc + _ = u i (U j xjk) := (eval gji xjk).symm + _ = u i (U k xkj) := congrArg (u i) sjk + _ = _ := eval gki xkj + have hbad : (0 : F) = 1 := by + linear_combination (norm := ring_nf) e1 + e2 + e3 + pij + pik + pjk + simp [CharTwo.two_eq_zero] + exact zero_ne_one hbad + +def sampledGraph {I : Type*} (U : Ω → X →ₗ[F] A) (u : Ω → A →ₗ[F] F) + (a : X →ₗ[F] F) (T : X →ₗ[F] X →ₗ[F] F) (sample : I → Ω) : SimpleGraph I where + Adj i j := i ≠ j ∧ ¬ Hole U u a T (sample i) (sample j) + symm := ⟨by + intro i j h + exact ⟨h.1.symm, fun h' => h.2 (hole_symm h')⟩⟩ + loopless := ⟨by intro i h; exact h.1 rfl⟩ + +lemma sampledGraph_adj_of_same_type {I : Type*} (sample : I → Ω) + (hU : ∀ i, Function.Injective (U i)) {i j : I} + (hij : i ≠ j) (hsame : sample i = sample j) : + (sampledGraph U u a T sample).Adj i j := by + refine ⟨hij, ?_⟩ + rw [hsame] + exact hole_irrefl hU _ + +lemma sampledGraph_indepNum_le_two {I : Type*} (sample : I → Ω) + (hT : ∀ x y : X, T x y = T y x) : + (sampledGraph U u a T sample).indepNum ≤ 2 := by + classical + apply indepNum_le_two_of_no_independent_triple + intro i j k hij hik hjk hneij hneik hnejk + have hij' : Hole U u a T (sample i) (sample j) := by + by_contra h + exact hneij ⟨hij, h⟩ + have hik' : Hole U u a T (sample i) (sample k) := by + by_contra h + exact hneik ⟨hik, h⟩ + have hjk' : Hole U u a T (sample j) (sample k) := by + by_contra h + exact hnejk ⟨hjk, h⟩ + exact hole_triangle_free hT _ _ _ hij' hik' hjk' + +lemma sampledGraph_half_order_le_chi {I : Type*} [Fintype I] (sample : I → Ω) + (hT : ∀ x y : X, T x y = T y x) : + (Fintype.card I : ℝ) / 2 ≤ (chi (sampledGraph U u a T sample) : ℝ) := + half_order_le_chi (sampledGraph_indepNum_le_two sample hT) + +end Geometry +end CdV + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/AdaptiveTrials.lean b/lean/OAI/Combinatorics/GraphThreshold/AdaptiveTrials.lean new file mode 100644 index 0000000000000000000000000000000000000000..7181c9fc9924351e77fe5f59be6e955a0aef7a4f --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/AdaptiveTrials.lean @@ -0,0 +1,257 @@ +import OAI.Combinatorics.GraphThreshold.FiniteProbability +import Mathlib.Tactic + +namespace OAI + +/-! +# Finite adaptive trials + +The draws are independent, but whether an attempt succeeds may depend on the +entire current state. The head-tail identity below performs the conditioning +explicitly. No independence assumption is made about success indicators. +-/ + +noncomputable section +open scoped BigOperators + +universe u v + +namespace LeanBlast.SecondKahnKalai + +variable {State : Type u} {Ω : Type v} + +/-- Split a finite draw sequence into its first draw and remaining sequence. -/ +def trialSplitEquiv (Ω : Type v) (n : ℕ) : Ω × (Fin n → Ω) ≃ (Fin (n + 1) → Ω) where + toFun p := Fin.cases p.1 p.2 + invFun draws := (draws 0, fun i => draws i.succ) + left_inv p := by cases p; rfl + right_inv draws := by + funext i + refine Fin.cases ?_ (fun j => ?_) i <;> rfl + +namespace FiniteLaw + +variable [Fintype Ω] + +@[simp] theorem iid_weight_cons (μ : FiniteLaw Ω) (n : ℕ) (head : Ω) (tail : Fin n → Ω) : + (μ.iid (n + 1)).weight (Fin.cases head tail) = μ.weight head * (μ.iid n).weight tail := by + simp [iid_weight, Fin.prod_univ_succ] + +/-- Exact finite conditional-expectation identity for a fresh independent draw. -/ +theorem iid_expectation_succ (μ : FiniteLaw Ω) (n : ℕ) + (f : (Fin (n + 1) → Ω) → ℝ) : + (μ.iid (n + 1)).expectation f = + μ.expectation (fun head => (μ.iid n).expectation (fun tail => f (Fin.cases head tail))) := by + unfold expectation + rw [← (trialSplitEquiv Ω n).sum_comp + (fun draws => (μ.iid (n + 1)).weight draws * f draws)] + simp only [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro head _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro tail _ + change (μ.iid (n + 1)).weight (Fin.cases head tail) * f (Fin.cases head tail) = _ + rw [iid_weight_cons] + ring + +end FiniteLaw + +/-- A deterministic adaptive update iterated over a finite sequence of draws. -/ +def adaptiveRun (step : State → Ω → State) : + (n : ℕ) → State → (Fin n → Ω) → State + | 0, state, _ => state + | n + 1, state, draws => adaptiveRun step n (step state (draws 0)) (fun i => draws i.succ) + +/-- Number of failed attempts along the actual adaptive state trajectory. -/ +def adaptiveFailureCount (step : State → Ω → State) (bad : State → Ω → Bool) : + (n : ℕ) → State → (Fin n → Ω) → ℕ + | 0, _, _ => 0 + | n + 1, state, draws => + (if bad state (draws 0) then 1 else 0) + + adaptiveFailureCount step bad n (step state (draws 0)) (fun i => draws i.succ) + +/-- A uniform state-dependent failure bound controls expected total failures. +This proof conditions at every step on the actual preceding draw and state. -/ +theorem adaptiveFailureCount_expectation_le [Fintype Ω] + (μ : FiniteLaw Ω) (step : State → Ω → State) (bad : State → Ω → Bool) + (q : ℝ) (hbad : ∀ state, μ.prob (fun draw => bad state draw = true) ≤ q) + (n : ℕ) (initial : State) : + (μ.iid n).expectation (fun draws => (adaptiveFailureCount step bad n initial draws : ℝ)) ≤ + (n : ℝ) * q := by + induction n generalizing initial with + | zero => simp [adaptiveFailureCount] + | succ n ih => + rw [FiniteLaw.iid_expectation_succ] + have hstep : ∀ head, + (μ.iid n).expectation (fun tail => + (adaptiveFailureCount step bad (n + 1) initial (Fin.cases head tail) : ℝ)) ≤ + (if bad initial head then (1 : ℝ) else 0) + (n : ℝ) * q := by + intro head + by_cases hbad : bad initial head = true + · simpa only [adaptiveFailureCount, Fin.cases_zero, Fin.cases_succ, hbad, + ite_true, Nat.cast_add, Nat.cast_one, FiniteLaw.expectation_add, + FiniteLaw.expectation_const] using add_le_add_right (ih (step initial head)) 1 + · simpa only [adaptiveFailureCount, Fin.cases_zero, Fin.cases_succ, hbad, + Bool.false_eq_true, ite_false, Nat.zero_add, zero_add] using ih (step initial head) + have h := (μ.expectation_mono hstep).trans_eq + (μ.expectation_add (fun head => if bad initial head then (1 : ℝ) else 0) + (fun _ => (n : ℝ) * q)) + have hindicator : μ.expectation (fun head => if bad initial head then (1 : ℝ) else 0) = + μ.prob (fun draw => bad initial draw = true) := by + classical + unfold FiniteLaw.expectation FiniteLaw.prob + apply Finset.sum_congr rfl + intro draw _ + cases hdraw : bad initial draw <;> simp [hdraw] + rw [FiniteLaw.expectation_const, hindicator] at h + have hlocal := hbad initial + push_cast + linarith + +/-- Once the rank is zero, later draws are declared successful for the purpose +of counting failures. Before then, success means a strict rank decrease. -/ +def rankFailure (rank : State → ℕ) (step : State → Ω → State) + (state : State) (draw : Ω) : Bool := + decide (rank state ≠ 0 ∧ ¬ rank (step state draw) < rank state) + +theorem adaptiveRun_rank_le (rank : State → ℕ) (step : State → Ω → State) + (hstep : ∀ state draw, rank (step state draw) ≤ rank state) + (n : ℕ) (initial : State) (draws : Fin n → Ω) : + rank (adaptiveRun step n initial draws) ≤ rank initial := by + induction n generalizing initial with + | zero => exact le_rfl + | succ n ih => + exact (ih (step initial (draws 0)) (fun i => draws i.succ)).trans (hstep _ _) + +/-- On a trajectory that is still incomplete, every nonfailed attempt consumes +at least one unit of rank. The conclusion includes the final positive rank. -/ +theorem adaptiveRun_rank_failure_bound (rank : State → ℕ) (step : State → Ω → State) + (hstep : ∀ state draw, rank (step state draw) ≤ rank state) + (n : ℕ) (initial : State) (draws : Fin n → Ω) + (hincomplete : rank (adaptiveRun step n initial draws) ≠ 0) : + n + rank (adaptiveRun step n initial draws) ≤ + rank initial + adaptiveFailureCount step (rankFailure rank step) n initial draws := by + induction n generalizing initial with + | zero => simp [adaptiveRun, adaptiveFailureCount] + | succ n ih => + have htail := ih (step initial (draws 0)) (fun i => draws i.succ) hincomplete + have hdecrease := hstep initial (draws 0) + have hinit : rank initial ≠ 0 := by + have hbound := adaptiveRun_rank_le rank step hstep (n + 1) initial draws + omega + change (n + 1) + rank (adaptiveRun step n (step initial (draws 0)) + (fun i => draws i.succ)) ≤ + rank initial + ((if rankFailure rank step initial (draws 0) then 1 else 0) + + adaptiveFailureCount step (rankFailure rank step) n (step initial (draws 0)) + (fun i => draws i.succ)) + by_cases hprogress : rank (step initial (draws 0)) < rank initial + · have hbad : rankFailure rank step initial (draws 0) = false := by + simp [rankFailure, hprogress] + simp [hbad] + omega + · have hbad : rankFailure rank step initial (draws 0) = true := by + simp [rankFailure, hinit, hprogress] + simp [hbad] + omega + +theorem rankFailure_probability_le [Fintype Ω] (μ : FiniteLaw Ω) + (rank : State → ℕ) (step : State → Ω → State) + (hprogress : ∀ state, rank state ≠ 0 → + (3 / 4 : ℝ) ≤ μ.prob (fun draw => rank (step state draw) < rank state)) + (state : State) : + μ.prob (fun draw => rankFailure rank step state draw = true) ≤ (1 / 4 : ℝ) := by + by_cases hz : rank state = 0 + · simp [rankFailure, hz, FiniteLaw.prob] + · have heq : μ.prob (fun draw => rankFailure rank step state draw = true) = + 1 - μ.prob (fun draw => rank (step state draw) < rank state) := by + simpa [rankFailure, hz] using + μ.prob_compl (fun draw => rank (step state draw) < rank state) + rw [heq] + linarith [hprogress state hz] + +/-- Noncompletion by time `4*s` forces at least `3*s+1` failed attempts. -/ +theorem adaptive_incomplete_many_failures (rank : State → ℕ) (step : State → Ω → State) + (hstep : ∀ state draw, rank (step state draw) ≤ rank state) + (s : ℕ) (initial : State) (hinitial : rank initial ≤ s) + (draws : Fin (4 * s) → Ω) + (hincomplete : rank (adaptiveRun step (4 * s) initial draws) ≠ 0) : + 3 * s + 1 ≤ adaptiveFailureCount step (rankFailure rank step) (4 * s) initial draws := by + have h := adaptiveRun_rank_failure_bound rank step hstep (4 * s) initial draws hincomplete + omega + +/-- Adaptive finite completion bound. Only fresh draws are independent. +The chance of progress can depend arbitrarily on the current state. +The case `s=0` is included. -/ +theorem adaptive_rank_completion [Fintype Ω] (μ : FiniteLaw Ω) + (rank : State → ℕ) (step : State → Ω → State) + (hstep : ∀ state draw, rank (step state draw) ≤ rank state) + (hprogress : ∀ state, rank state ≠ 0 → + (3 / 4 : ℝ) ≤ μ.prob (fun draw => rank (step state draw) < rank state)) + (s : ℕ) (initial : State) (hinitial : rank initial ≤ s) : + (2 / 3 : ℝ) ≤ (μ.iid (4 * s)).prob + (fun draws => rank (adaptiveRun step (4 * s) initial draws) = 0) := by + let ν := μ.iid (4 * s) + let F : (Fin (4 * s) → Ω) → ℝ := fun draws => + adaptiveFailureCount step (rankFailure rank step) (4 * s) initial draws + have hF : ∀ draws, 0 ≤ F draws := fun _ => Nat.cast_nonneg _ + have hexpected := adaptiveFailureCount_expectation_le μ step (rankFailure rank step) + (1 / 4) (rankFailure_probability_le μ rank step hprogress) (4 * s) initial + have hE : ν.expectation F ≤ (s : ℝ) := by + convert hexpected using 1 + push_cast + ring + have ht : 0 < 3 * (s : ℝ) + 1 := by positivity + have hsubset : ν.prob (fun draws => rank (adaptiveRun step (4 * s) initial draws) ≠ 0) ≤ + ν.prob (fun draws => 3 * (s : ℝ) + 1 ≤ F draws) := by + apply ν.prob_mono + intro draws hinc + have h := adaptive_incomplete_many_failures rank step hstep s initial hinitial draws hinc + dsimp [F] + exact_mod_cast h + have hMarkov := ν.prob_ge_le_expectation_div F hF ht + have hbad : ν.prob (fun draws => rank (adaptiveRun step (4 * s) initial draws) ≠ 0) ≤ + (s : ℝ) / (3 * (s : ℝ) + 1) := + (hsubset.trans hMarkov).trans (div_le_div_of_nonneg_right hE ht.le) + have hratio : (s : ℝ) / (3 * (s : ℝ) + 1) ≤ (1 / 3 : ℝ) := by + apply (div_le_iff₀ ht).mpr + linarith + have hbad' := hbad.trans hratio + have hcomplement := ν.prob_compl + (fun draws => rank (adaptiveRun step (4 * s) initial draws) = 0) + change (2 / 3 : ℝ) ≤ ν.prob (fun draws => rank (adaptiveRun step (4 * s) initial draws) = 0) + linarith + +/-- Counter form for the tree reduction: counters never decrease, and while +fewer than `s` successful rounds have occurred the chance of an increase is +at least three quarters. No finite-state assumption is needed. -/ +theorem adaptive_counter_completion [Fintype Ω] (μ : FiniteLaw Ω) + (counter : State → ℕ) (step : State → Ω → State) + (hstep : ∀ state draw, counter state ≤ counter (step state draw)) + (s : ℕ) + (hprogress : ∀ state, counter state < s → + (3 / 4 : ℝ) ≤ μ.prob (fun draw => counter state < counter (step state draw))) + (initial : State) : + (2 / 3 : ℝ) ≤ (μ.iid (4 * s)).prob + (fun draws => s ≤ counter (adaptiveRun step (4 * s) initial draws)) := by + let rank : State → ℕ := fun state => s - counter state + have hrank : ∀ state draw, rank (step state draw) ≤ rank state := by + intro state draw + exact Nat.sub_le_sub_left (hstep state draw) s + have hprob : ∀ state, rank state ≠ 0 → + (3 / 4 : ℝ) ≤ μ.prob (fun draw => rank (step state draw) < rank state) := by + intro state hne + have hlt : counter state < s := by dsimp [rank] at hne; omega + apply (hprogress state hlt).trans + apply μ.prob_mono + intro draw hdraw + dsimp [rank] + omega + have h := adaptive_rank_completion μ rank step hrank hprob s initial (Nat.sub_le _ _) + simpa only [rank, Nat.sub_eq_zero_iff_le] using h + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/Basic.lean b/lean/OAI/Combinatorics/GraphThreshold/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..40e5d241a8b9a45d1ee37fe22a48828cb39eaf2c --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/Basic.lean @@ -0,0 +1,36 @@ +import OAI.Combinatorics.GraphThreshold.Model + +namespace OAI + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +structure FiniteLaw (Ω : Type*) [Fintype Ω] where + weight : Ω → ℝ + nonneg : ∀ ω, 0 ≤ weight ω + total : ∑ ω, weight ω = 1 + +namespace FiniteLaw + +def expectation {Ω : Type*} [Fintype Ω] (μ : FiniteLaw Ω) (f : Ω → ℝ) : ℝ := + ∑ ω, μ.weight ω * f ω + +def prob {Ω : Type*} [Fintype Ω] (μ : FiniteLaw Ω) (P : Ω → Prop) : ℝ := by + classical + exact ∑ ω, if P ω then μ.weight ω else 0 + +def IsPositive {Ω : Type*} [Fintype Ω] (μ : FiniteLaw Ω) : Prop := + ∀ ω, 0 < μ.weight ω + +end FiniteLaw + +def IsSpread {X B : Type*} [DecidableEq X] [Fintype B] + (μ : FiniteLaw B) (A : B → Finset X) (a : ℝ) : Prop := + ∀ J : Finset X, J.Nonempty → μ.prob (fun b => J ⊆ A b) ≤ a ^ J.card + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/BernoulliCoupling.lean b/lean/OAI/Combinatorics/GraphThreshold/BernoulliCoupling.lean new file mode 100644 index 0000000000000000000000000000000000000000..12cfa703edcffa7175fce4959623c10e982f2f8d --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/BernoulliCoupling.lean @@ -0,0 +1,133 @@ +import OAI.Combinatorics.GraphThreshold.FiniteProbability +import Mathlib.Algebra.BigOperators.Group.Finset.Powerset +import Mathlib.Tactic.FieldSimp + +namespace OAI + +open scoped BigOperators +noncomputable section +attribute [local instance] Classical.propDecidable + +namespace LeanBlast.SecondKahnKalai + +variable {X : Type*} [Fintype X] [DecidableEq X] + +theorem bernoulliExpectation_congr (p : ℝ) {f g : Finset X → ℝ} + (h : ∀ W, f W = g W) : bernoulliExpectation p f = bernoulliExpectation p g := by + exact Finset.sum_congr rfl fun W _ => congrArg (fun z => bernoulliWeight p W * z) (h W) + +@[simp] theorem bernoulliExpectation_const (p c : ℝ) : + bernoulliExpectation p (fun _ : Finset X => c) = c := by + rw [bernoulliExpectation, ← Finset.sum_mul, bernoulliWeight_sum, one_mul] + +theorem bernoulliExpectation_add (p : ℝ) (f g : Finset X → ℝ) : + bernoulliExpectation p (fun W => f W + g W) = + bernoulliExpectation p f + bernoulliExpectation p g := by + simp [bernoulliExpectation, mul_add, Finset.sum_add_distrib] + +theorem bernoulliExpectation_smul (p c : ℝ) (f : Finset X → ℝ) : + bernoulliExpectation p (fun W => c * f W) = c * bernoulliExpectation p f := by + simp [bernoulliExpectation, Finset.mul_sum, mul_left_comm] + +theorem bernoulliExpectation_sum {ι : Type*} [Fintype ι] (p : ℝ) + (f : ι → Finset X → ℝ) : + bernoulliExpectation p (fun W => ∑ i, f i W) = ∑ i, bernoulliExpectation p (f i) := by + simp only [bernoulliExpectation, Finset.mul_sum] + exact Finset.sum_comm + +theorem bernoulliExpectation_nonneg {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + {f : Finset X → ℝ} (hf : ∀ W, 0 ≤ f W) : 0 ≤ bernoulliExpectation p f := + (bernoulliLaw p hp0 hp1).expectation_nonneg hf + +theorem bernoulliExpectation_mono {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + {f g : Finset X → ℝ} (hfg : ∀ W, f W ≤ g W) : + bernoulliExpectation p f ≤ bernoulliExpectation p g := + (bernoulliLaw p hp0 hp1).expectation_mono hfg + +theorem finset_eq_indicator_product (U V : Finset X) : + (if U = V then (1 : ℝ) else 0) = + ∏ x, if (x ∈ U ↔ x ∈ V) then (1 : ℝ) else 0 := by + rw [Fintype.prod_boole] + have h : (∀ x : X, x ∈ U ↔ x ∈ V) ↔ U = V := + ⟨Finset.ext, fun h => by subst V; simp⟩ + simp only [h] + +theorem bernoulliExpectation_pushforward (p : ℝ) (T : Finset X → Finset X) + (F : Finset X → ℝ) : + bernoulliExpectation p (fun W => F (T W)) = + ∑ Y : Finset X, bernoulliExpectation p (fun W => if T W = Y then 1 else 0) * F Y := by + unfold bernoulliExpectation + calc + (∑ W : Finset X, bernoulliWeight p W * F (T W)) = + ∑ W : Finset X, ∑ Y : Finset X, + (bernoulliWeight p W * (if T W = Y then 1 else 0)) * F Y := by + apply Finset.sum_congr rfl + intro W _ + simp [mul_ite, ite_mul] + _ = ∑ Y : Finset X, ∑ W : Finset X, + (bernoulliWeight p W * (if T W = Y then 1 else 0)) * F Y := Finset.sum_comm + _ = _ := by simp only [Finset.sum_mul] + +theorem bernoulli_union_fixed_mass (p : ℝ) (A Y : Finset X) : + bernoulliExpectation p (fun W => if W ∪ A = Y then 1 else 0) = + ∏ x, if x ∈ A then (if x ∈ Y then (1 : ℝ) else 0) + else (if x ∈ Y then p else 1 - p) := by + let f : X → Bool → ℝ := fun x b => + if (b = true ∨ x ∈ A) ↔ x ∈ Y then 1 else 0 + have hf : (fun W : Finset X => if W ∪ A = Y then (1 : ℝ) else 0) = + (fun W => ∏ x, f x (decide (x ∈ W))) := by + funext W + simpa [f] using finset_eq_indicator_product (W ∪ A) Y + rw [hf, bernoulliExpectation_product] + apply Finset.prod_congr rfl + intro x _ + by_cases ha : x ∈ A <;> by_cases hy : x ∈ Y <;> simp [f, ha, hy] + +theorem bernoulli_union_fixed_mass_mul (p : ℝ) (A Y : Finset X) : + p ^ A.card * bernoulliExpectation p (fun W => if W ∪ A = Y then 1 else 0) = + if A ⊆ Y then bernoulliWeight p Y else 0 := by + rw [bernoulli_union_fixed_mass] + by_cases hAY : A ⊆ Y + · rw [ite_eq_left hAY] + have hp : p ^ A.card = ∏ x : X, if x ∈ A then p else 1 := by + rw [Fintype.prod_ite_mem] + simp + rw [hp, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro x _ + by_cases ha : x ∈ A + · simp [ha, hAY ha] + · simp [ha] + · rw [ite_eq_right hAY] + obtain ⟨x, hxa, hxy⟩ := Finset.not_subset.mp hAY + have hz : (∏ x, if x ∈ A then (if x ∈ Y then (1 : ℝ) else 0) + else (if x ∈ Y then p else 1 - p)) = 0 := by + apply Finset.prod_eq_zero (Finset.mem_univ x) + simp [hxa, hxy] + rw [hz, mul_zero] + +theorem bernoulli_union_fixed_mass_div (p : ℝ) (hp : p ≠ 0) (A Y : Finset X) : + bernoulliExpectation p (fun W => if W ∪ A = Y then 1 else 0) = + (if A ⊆ Y then bernoulliWeight p Y else 0) / p ^ A.card := by + apply (eq_div_iff (pow_ne_zero _ hp)).2 + simpa only [mul_comm] using bernoulli_union_fixed_mass_mul p A Y + +/-- Forcing all coordinates of `A` to be present gives the literal Bernoulli +law conditioned on containing `A`. -/ +theorem bernoulliExpectation_union_fixed (p : ℝ) (hp : p ≠ 0) + (A : Finset X) (F : Finset X → ℝ) : + bernoulliExpectation p (fun W => F (W ∪ A)) = + bernoulliExpectation p (fun Y => if A ⊆ Y then F Y / p ^ A.card else 0) := by + rw [bernoulliExpectation_pushforward] + unfold bernoulliExpectation + apply Finset.sum_congr rfl + intro Y _ + rw [← bernoulliExpectation, bernoulli_union_fixed_mass_div p hp A Y] + by_cases hAY : A ⊆ Y <;> simp [hAY] + ring + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/BernoulliMonotonicity.lean b/lean/OAI/Combinatorics/GraphThreshold/BernoulliMonotonicity.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfb01ca53f46155687afc311b4287c37824d8e58 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/BernoulliMonotonicity.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.GraphThreshold.BernoulliUnion + +namespace OAI + +/-! +# Monotonicity of finite Bernoulli probabilities + +For `p ≤ q`, adjoin an independent Bernoulli set to a Bernoulli-`p` set. +The resulting union has parameter `q` and contains the first set. This gives +expectation and event monotonicity, including both endpoints of `[0, 1]`. +-/ + +noncomputable section +attribute [local instance] Classical.propDecidable + +namespace LeanBlast.SecondKahnKalai + +variable {X : Type*} [Fintype X] [DecidableEq X] + +/-- A Bernoulli set with a larger parameter has larger expectation for every +function monotone under inclusion. The function need not be nonnegative. -/ +theorem bernoulliExpectation_mono_parameter {p q : ℝ} + (hp0 : 0 ≤ p) (hpq : p ≤ q) (hq1 : q ≤ 1) (F : Finset X → ℝ) + (hF : ∀ U V, U ⊆ V → F U ≤ F V) : + bernoulliExpectation p F ≤ bernoulliExpectation q F := by + have hp1 : p ≤ 1 := hpq.trans hq1 + by_cases hp : p = 1 + · have hq : q = 1 := by linarith + simp [hp, hq] + have hp_lt : p < 1 := by + rcases lt_or_eq_of_le hp1 with hlt | heq + · exact hlt + · exact (hp heq).elim + have hd : 0 < 1 - p := sub_pos.mpr hp_lt + let r := (q - p) / (1 - p) + have hr0 : 0 ≤ r := div_nonneg (sub_nonneg.mpr hpq) hd.le + have hr1 : r ≤ 1 := (div_le_one hd).2 (by linarith) + have hparam : p + r - p * r = q := by + dsimp [r] + field_simp [hd.ne'] + ring + calc + bernoulliExpectation p F = + bernoulliExpectation p (fun U => bernoulliExpectation r (fun _ => F U)) := by + simp + _ ≤ bernoulliExpectation p (fun U => bernoulliExpectation r (fun V => F (U ∪ V))) := + bernoulliExpectation_mono hp0 hp1 fun U => + bernoulliExpectation_mono hr0 hr1 fun V => hF U (U ∪ V) Finset.subset_union_left + _ = bernoulliExpectation q F := by + rw [bernoulliExpectation_union, hparam] + +/-- Inclusion-monotone events become more likely as the Bernoulli parameter +increases. The proof couples actual independent finite Bernoulli sets. -/ +theorem bernoulliProbability_mono_parameter {p q : ℝ} + (hp0 : 0 ≤ p) (hpq : p ≤ q) (hq1 : q ≤ 1) (P : Finset X → Prop) + (hP : ∀ U V, U ⊆ V → P U → P V) : + bernoulliProbability p P ≤ bernoulliProbability q P := by + rw [bernoulliProbability_eq_expectation, bernoulliProbability_eq_expectation] + apply bernoulliExpectation_mono_parameter hp0 hpq hq1 + intro U V hUV + by_cases hu : P U + · simp [hu, hP U V hUV hu] + · by_cases hv : P V <;> simp [hu, hv] + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/BernoulliUnion.lean b/lean/OAI/Combinatorics/GraphThreshold/BernoulliUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..35b2e5207647b50a911bbef751567932c234ce15 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/BernoulliUnion.lean @@ -0,0 +1,146 @@ +import OAI.Combinatorics.GraphThreshold.BernoulliCoupling +import OAI.Combinatorics.GraphThreshold.AdaptiveTrials +import OAI.Combinatorics.GraphThreshold.GraphProbability + +namespace OAI + +open scoped BigOperators +noncomputable section +attribute [local instance] Classical.propDecidable + +namespace LeanBlast.SecondKahnKalai + +variable {X : Type*} [Fintype X] [DecidableEq X] + +theorem bernoulli_union_product (p q : ℝ) (f : X → Bool → ℝ) : + bernoulliExpectation p (fun U => bernoulliExpectation q + (fun V => ∏ x, f x (decide (x ∈ U ∪ V)))) = + ∏ x, ((p + q - p * q) * f x true + (1 - (p + q - p * q)) * f x false) := by + have hi (U : Finset X) : + bernoulliExpectation q (fun V => ∏ x, f x (decide (x ∈ U ∪ V))) = + ∏ x, (q * f x true + (1 - q) * f x (decide (x ∈ U))) := by + have hfun : (fun V : Finset X => ∏ x, f x (decide (x ∈ U ∪ V))) = + (fun V => ∏ x, f x (decide (x ∈ U) || decide (x ∈ V))) := by + funext V + apply Finset.prod_congr rfl + intro x _ + by_cases hu : x ∈ U <;> by_cases hv : x ∈ V <;> simp [Finset.mem_union, hu, hv] + rw [hfun] + simpa using + bernoulliExpectation_product q (fun x b => f x (decide (x ∈ U) || b)) + calc + _ = bernoulliExpectation p (fun U => + ∏ x, (q * f x true + (1 - q) * f x (decide (x ∈ U)))) := + bernoulliExpectation_congr p hi + _ = _ := by + rw [bernoulliExpectation_product p (fun x b => q * f x true + (1 - q) * f x b)] + apply Finset.prod_congr rfl + intro x _ + ring + +theorem bernoulli_union_mass (p q : ℝ) (Y : Finset X) : + bernoulliExpectation p (fun U => bernoulliExpectation q + (fun V => if U ∪ V = Y then 1 else 0)) = bernoulliWeight (p + q - p * q) Y := by + let f : X → Bool → ℝ := fun x b => if (b = true ↔ x ∈ Y) then 1 else 0 + have hi (U V : Finset X) : + (if U ∪ V = Y then (1 : ℝ) else 0) = ∏ x, f x (decide (x ∈ U ∪ V)) := by + simpa [f] using finset_eq_indicator_product (U ∪ V) Y + calc + _ = bernoulliExpectation p (fun U => bernoulliExpectation q + (fun V => ∏ x, f x (decide (x ∈ U ∪ V)))) := + bernoulliExpectation_congr p fun U => bernoulliExpectation_congr q (hi U) + _ = _ := by + rw [bernoulli_union_product] + apply Finset.prod_congr rfl + intro x _ + by_cases hy : x ∈ Y <;> simp [f, hy] + +/-- The union of two independent Bernoulli subsets has the stated Bernoulli law. -/ +theorem bernoulliExpectation_union (p q : ℝ) (F : Finset X → ℝ) : + bernoulliExpectation p (fun U => bernoulliExpectation q (fun V => F (U ∪ V))) = + bernoulliExpectation (p + q - p * q) F := by + calc + _ = bernoulliExpectation p (fun U => ∑ Y : Finset X, + bernoulliExpectation q (fun V => if U ∪ V = Y then 1 else 0) * F Y) := + bernoulliExpectation_congr p fun U => + bernoulliExpectation_pushforward q (fun V => U ∪ V) F + _ = ∑ Y : Finset X, bernoulliExpectation p (fun U => + bernoulliExpectation q (fun V => if U ∪ V = Y then 1 else 0) * F Y) := + bernoulliExpectation_sum p _ + _ = ∑ Y : Finset X, bernoulliWeight (p + q - p * q) Y * F Y := by + apply Finset.sum_congr rfl + intro Y _ + have hfactor : bernoulliExpectation p (fun U => + bernoulliExpectation q (fun V => if U ∪ V = Y then 1 else 0) * F Y) = + bernoulliExpectation p (fun U => + bernoulliExpectation q (fun V => if U ∪ V = Y then 1 else 0)) * F Y := by + simp only [bernoulliExpectation, Finset.sum_mul, mul_assoc] + rw [hfactor, bernoulli_union_mass] + _ = _ := rfl + +omit [Fintype X] in +theorem biUnion_fin_cons {n : ℕ} (A : Finset X) (draws : Fin n → Finset X) : + Finset.univ.biUnion (Fin.cases A draws) = A ∪ Finset.univ.biUnion draws := by + ext x + simp only [Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_union] + constructor + · rintro ⟨i, hi⟩ + revert hi + refine Fin.cases ?_ (fun j => ?_) i + · intro hi + exact Or.inl hi + · intro hi + exact Or.inr ⟨j, hi⟩ + · rintro (hx | ⟨j, hj⟩) + · exact ⟨0, hx⟩ + · exact ⟨j.succ, hj⟩ + +/-- Exact law of the union of a finite history of independent draws. -/ +theorem iid_bernoulli_union_expectation (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (n : ℕ) (F : Finset X → ℝ) : + ((bernoulliLaw p hp0 hp1).iid n).expectation (fun draws => F (Finset.univ.biUnion draws)) = + bernoulliExpectation (1 - (1 - p) ^ n) F := by + induction n generalizing F with + | zero => simp + | succ n ih => + rw [FiniteLaw.iid_expectation_succ] + simp_rw [biUnion_fin_cons] + have hi (A : Finset X) := ih (fun W => F (A ∪ W)) + have hrewrite : (fun A => ((bernoulliLaw p hp0 hp1).iid n).expectation + (fun draws => F (A ∪ Finset.univ.biUnion draws))) = + (fun A => bernoulliExpectation (1 - (1 - p) ^ n) (fun W => F (A ∪ W))) := by + funext A + exact hi A + rw [hrewrite, bernoulliLaw_expectation, bernoulliExpectation_union] + congr 1 + rw [pow_succ] + ring + +theorem iid_bernoulli_union_probability (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (n : ℕ) (P : Finset X → Prop) : + ((bernoulliLaw p hp0 hp1).iid n).prob (fun draws => P (Finset.univ.biUnion draws)) = + bernoulliProbability (1 - (1 - p) ^ n) P := by + rw [FiniteLaw.prob_eq_expectation, bernoulliProbability_eq_expectation] + exact iid_bernoulli_union_expectation p hp0 hp1 n (fun W => if P W then 1 else 0) + +theorem bernoulli_union_parameter_mem {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (n : ℕ) : + 0 ≤ 1 - (1 - p) ^ n ∧ 1 - (1 - p) ^ n ≤ 1 := by + have hpow0 : 0 ≤ (1 - p) ^ n := pow_nonneg (sub_nonneg.mpr hp1) _ + have hpow1 : (1 - p) ^ n ≤ 1 := pow_le_one₀ (sub_nonneg.mpr hp1) (by linarith) + constructor <;> linarith + +theorem bernoulli_union_parameter_le {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (n : ℕ) : + 1 - (1 - p) ^ n ≤ (n : ℝ) * p := by + induction n with + | zero => simp + | succ n ih => + have hpow1 : (1 - p) ^ n ≤ 1 := pow_le_one₀ (sub_nonneg.mpr hp1) (by linarith) + have hmul := mul_le_mul_of_nonneg_left hpow1 hp0 + rw [pow_succ, Nat.cast_succ] + nlinarith + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/CapacityIteration.lean b/lean/OAI/Combinatorics/GraphThreshold/CapacityIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab194c7b43308de8e3d4a5833284f2c8d3ff394b --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/CapacityIteration.lean @@ -0,0 +1,418 @@ +import Mathlib.Analysis.SpecialFunctions.Log.Base +import Mathlib.Algebra.Order.Field.GeomSum +import Mathlib.Algebra.Order.Floor.Semifield +import Mathlib.Order.Interval.Set.Monotone +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Capacities and finite inflation products + +The capacity after `t` successful reductions is natural-number division by +`2^t`. All product estimates below are finite; no infinite product is used. +-/ + +noncomputable section + +open Finset Set + +namespace LeanBlast.SecondKahnKalai + +def reducedCapacity (l t : ℕ) : ℕ := l / 2 ^ t + +def successesNeeded (l : ℕ) : ℕ := Nat.log2 l + 1 + +@[simp] theorem reducedCapacity_zero (l : ℕ) : reducedCapacity l 0 = l := by + simp [reducedCapacity] + +theorem reducedCapacity_succ (l t : ℕ) : + reducedCapacity l (t + 1) = reducedCapacity l t / 2 := by + simp only [reducedCapacity, pow_succ, Nat.div_div_eq_div_mul] + +theorem reducedCapacity_add (l t u : ℕ) : + reducedCapacity l (t + u) = reducedCapacity (reducedCapacity l t) u := by + simp only [reducedCapacity, pow_add, Nat.div_div_eq_div_mul] + +theorem reducedCapacity_eq_floor (l t : ℕ) : + reducedCapacity l t = ⌊(l : ℝ) / (2 : ℝ) ^ t⌋₊ := by + simpa only [reducedCapacity, Nat.cast_pow, Nat.cast_ofNat] using + (Nat.floor_div_eq_div (K := ℝ) l (2 ^ t)).symm + +theorem antitone_reducedCapacity (l : ℕ) : Antitone (reducedCapacity l) := by + apply antitone_nat_of_succ_le + intro t + rw [reducedCapacity_succ] + exact Nat.div_le_self _ _ + +theorem monotone_reducedCapacity_left (t : ℕ) : Monotone (fun l => reducedCapacity l t) := by + intro a b hab + exact Nat.div_le_div_right hab + +theorem reducedCapacity_zero_prefix {a b t : ℕ} (hab : a ≤ b) + (hb : reducedCapacity b t = 0) : reducedCapacity a t = 0 := by + have h := monotone_reducedCapacity_left t hab + change reducedCapacity a t ≤ reducedCapacity b t at h + rw [hb] at h + exact Nat.eq_zero_of_le_zero h + +theorem reducedCapacity_growth {a b : ℕ} (hab : 16 * a ≤ b) (t : ℕ) : + 16 * reducedCapacity a t ≤ reducedCapacity b t := by + unfold reducedCapacity + apply (Nat.le_div_iff_mul_le (by positivity : 0 < 2 ^ t)).mpr + calc + 16 * (a / 2 ^ t) * 2 ^ t = 16 * (a / 2 ^ t * 2 ^ t) := by ring + _ ≤ 16 * a := Nat.mul_le_mul_left 16 (Nat.div_mul_le_self a (2 ^ t)) + _ ≤ b := hab + +theorem strictAntiOn_reducedCapacity {l t : ℕ} (hpos : 0 < reducedCapacity l t) : + StrictAntiOn (reducedCapacity l) (Set.Iic t) := by + apply strictAntiOn_Iic_of_succ_lt + intro u hu + change reducedCapacity l (u + 1) < reducedCapacity l u + rw [reducedCapacity_succ] + exact Nat.div_lt_self (lt_of_lt_of_le hpos (antitone_reducedCapacity l hu.le)) (by decide) + +theorem reducedCapacity_successesNeeded (l : ℕ) : + reducedCapacity l (successesNeeded l) = 0 := by + exact Nat.div_eq_of_lt Nat.lt_log2_self + +theorem reducedCapacity_eq_zero_of_le {a l : ℕ} (hal : a ≤ l) : + reducedCapacity a (successesNeeded l) = 0 := by + exact Nat.div_eq_of_lt (lt_of_le_of_lt hal Nat.lt_log2_self) + +theorem successesNeeded_pos (l : ℕ) : 0 < successesNeeded l := by + exact Nat.succ_pos _ + +theorem monotone_successesNeeded : Monotone successesNeeded := by + intro a b hab + simp only [successesNeeded, Nat.log2_eq_log_two, Nat.add_le_add_iff_right] + exact Nat.log_mono_right hab + +theorem successesNeeded_half_lt {m : ℕ} (hhalf : 0 < m / 2) : + successesNeeded (m / 2) < successesNeeded m := by + have hm : 2 ≤ m := by omega + have hl : Nat.log2 m = Nat.log2 (m / 2) + 1 := by + rw [Nat.log2_def m, ite_eq_left hm] + simp only [successesNeeded] + omega + +theorem successesNeeded_eq_floor_logb (l : ℕ) : + successesNeeded l = ⌊Real.logb 2 (l : ℝ)⌋₊ + 1 := by + simpa only [successesNeeded, Nat.log2_eq_log_two, Nat.cast_ofNat] using + congrArg (fun n : ℕ => n + 1) (Real.natFloor_logb_natCast 2 l).symm + +theorem successesNeeded_le_logb (l : ℕ) : + (successesNeeded l : ℝ) ≤ 1 + Real.logb 2 (l : ℝ) := by + have h := Real.log2_le_logb l + simp only [successesNeeded, Nat.cast_add, Nat.cast_one] + linarith + +theorem capacity_logb_nonneg {l : ℕ} (hl : 1 ≤ l) : + 0 ≤ Real.logb 2 (l : ℝ) := + Real.logb_nonneg (by norm_num) (by exact_mod_cast hl) + +theorem label_empty_after_successes {X : Type*} (A : Finset X) {l L : ℕ} + (hl : l ≤ L) (hA : A.card ≤ reducedCapacity l (successesNeeded L)) : A = ∅ := by + rw [reducedCapacity_eq_zero_of_le hl] at hA + exact Finset.card_eq_zero.mp (Nat.eq_zero_of_le_zero hA) + +/-- Geometric growth bounds every earlier prefix by one fifteenth of the +current capacity. The natural form avoids premature division. -/ +theorem capacity_prefix_sum_le (m : ℕ → ℕ) (k : ℕ) + (hgrowth : ∀ j, j + 1 < k → 16 * m j ≤ m (j + 1)) : + ∀ j, j < k → 15 * (∑ h ∈ range j, m h) ≤ m j := by + intro j + induction j with + | zero => simp + | succ j ih => + intro hj + have hp := ih (by omega) + have hn := hgrowth j hj + rw [sum_range_succ] + omega + +theorem capacity_prefix_sum_real_le (m : ℕ → ℕ) (k : ℕ) + (hgrowth : ∀ j, j + 1 < k → 16 * m j ≤ m (j + 1)) + {j : ℕ} (hj : j < k) : + (∑ h ∈ range j, (m h : ℝ)) ≤ (m j : ℝ) / 15 := by + have h : (15 : ℝ) * (∑ h ∈ range j, (m h : ℝ)) ≤ (m j : ℝ) := by + exact_mod_cast capacity_prefix_sum_le m k hgrowth j hj + linarith + +theorem strictMonoOn_capacities (m : ℕ → ℕ) (k : ℕ) + (hpos : ∀ j, j < k → 1 ≤ m j) + (hgrowth : ∀ j, j + 1 < k → 16 * m j ≤ m (j + 1)) : + StrictMonoOn m (Set.Iio k) := by + intro i hi j hj hij + change i < k at hi + change j < k at hj + have hmono : StrictMonoOn m (Set.Iic j) := by + apply strictMonoOn_Iic_of_lt_succ + intro a ha + have hp := hpos a (by omega) + have hg := hgrowth a (by omega) + change m a < m (a + 1) + omega + exact hmono (show i ≤ j from hij.le) (show j ≤ j from Nat.le_refl j) hij + +/-- Index monotonicity also holds before an initial zero-capacity segment is +removed. No positivity assumption is needed here. -/ +theorem monotoneOn_capacities (m : ℕ → ℕ) (k : ℕ) + (hgrowth : ∀ j, j + 1 < k → 16 * m j ≤ m (j + 1)) : + MonotoneOn m (Set.Iio k) := by + apply monotoneOn_of_le_succ Set.ordConnected_Iio + intro j _ _ hj + have hg := hgrowth j hj + change m j ≤ m (j + 1) + omega + +/-- A finite sum of distinct positive geometric powers. -/ +theorem sum_positive_geometric_le (s : Finset ℕ) {q : ℝ} + (hq : 0 ≤ q) (hq1 : q < 1) (hpos : ∀ m ∈ s, 1 ≤ m) : + (∑ m ∈ s, q ^ m) ≤ q / (1 - q) := by + obtain ⟨N, hN⟩ := s.exists_nat_subset_range + calc + (∑ m ∈ s, q ^ m) ≤ ∑ m ∈ Finset.Ico 1 N, q ^ m := by + apply sum_le_sum_of_subset_of_nonneg + · intro m hm + exact Finset.mem_Ico.mpr ⟨hpos m hm, mem_range.mp (hN hm)⟩ + · intro m _ _ + exact pow_nonneg hq _ + _ ≤ q / (1 - q) := by + simpa only [pow_one] using geom_sum_Ico_le_of_lt_one (m := 1) (n := N) hq hq1 + +/-- Elementary finite product bound, applied below to the retention factors. -/ +theorem one_sub_sum_le_prod_one_sub {ι : Type*} (s : Finset ι) (f : ι → ℝ) + (h0 : ∀ i ∈ s, 0 ≤ f i) (h1 : ∀ i ∈ s, f i ≤ 1) : + 1 - (∑ i ∈ s, f i) ≤ ∏ i ∈ s, (1 - f i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + have h0i := h0 i (mem_insert_self _ _) + have h1i := h1 i (mem_insert_self _ _) + have h0s : ∀ j ∈ s, 0 ≤ f j := fun j hj => h0 j (mem_insert_of_mem hj) + have h1s : ∀ j ∈ s, f j ≤ 1 := fun j hj => h1 j (mem_insert_of_mem hj) + have hp := mul_le_mul_of_nonneg_left (ih h0s h1s) (sub_nonneg.mpr h1i) + have hs := sum_nonneg h0s + rw [sum_insert hi, prod_insert hi] + nlinarith [mul_nonneg h0i hs] + +theorem exp_neg_one_le_two_fifths : Real.exp (-1) ≤ (2 / 5 : ℝ) := by + have he : (5 / 2 : ℝ) ≤ Real.exp 1 := by + have h := Real.quadratic_le_exp_of_nonneg (show (0 : ℝ) ≤ 1 by norm_num) + norm_num at h + exact h + rw [Real.exp_neg] + apply (inv_le_iff_one_le_mul₀ (Real.exp_pos 1)).mpr + nlinarith + +theorem sum_exp_neg_capacities_le_two_thirds (s : Finset ℕ) + (hpos : ∀ m ∈ s, 1 ≤ m) : + (∑ m ∈ s, Real.exp (-(m : ℝ))) ≤ (2 / 3 : ℝ) := by + have hq0 := (Real.exp_pos (-1)).le + have hq1 : Real.exp (-1) < 1 := lt_of_le_of_lt exp_neg_one_le_two_fifths (by norm_num) + have heq (m : ℕ) : Real.exp (-(m : ℝ)) = Real.exp (-1) ^ m := by + simpa only [mul_neg_one] using Real.exp_nat_mul (-1) m + simp_rw [heq] + apply (sum_positive_geometric_le s hq0 hq1 hpos).trans + apply (div_le_iff₀ (sub_pos.mpr hq1)).mpr + nlinarith [exp_neg_one_le_two_fifths] + +theorem finite_retentionProduct_ge_one_third (s : Finset ℕ) + (hpos : ∀ m ∈ s, 1 ≤ m) : + (1 / 3 : ℝ) ≤ ∏ m ∈ s, (1 - Real.exp (-(m : ℝ))) := by + have h0 (m : ℕ) (_ : m ∈ s) : 0 ≤ Real.exp (-(m : ℝ)) := (Real.exp_pos _).le + have h1 (m : ℕ) (_ : m ∈ s) : Real.exp (-(m : ℝ)) ≤ 1 := by + rw [Real.exp_le_one_iff] + exact neg_nonpos.mpr (Nat.cast_nonneg m) + have hb := one_sub_sum_le_prod_one_sub s (fun m => Real.exp (-(m : ℝ))) h0 h1 + have hs := sum_exp_neg_capacities_le_two_thirds s hpos + linarith + +theorem finite_spreadInflation_lt_four (s : Finset ℕ) + (hpos : ∀ m ∈ s, 1 ≤ m) : + (∏ m ∈ s, (1 - Real.exp (-(m : ℝ)))⁻¹) < 4 := by + have hp := finite_retentionProduct_ge_one_third s hpos + have hp0 : 0 < ∏ m ∈ s, (1 - Real.exp (-(m : ℝ))) := lt_of_lt_of_le (by norm_num) hp + rw [Finset.prod_inv_distrib] + apply (inv_lt_iff_one_lt_mul₀ hp0).mpr + nlinarith + +theorem spreadInflation_lt_four {ι : Type*} [DecidableEq ι] + (s : Finset ι) (m : ι → ℕ) (hpos : ∀ i ∈ s, 1 ≤ m i) + (hinj : Set.InjOn m (↑s : Set ι)) : + (∏ i ∈ s, (1 - Real.exp (-(m i : ℝ)))⁻¹) < 4 := by + have heq : (∏ i ∈ s, (1 - Real.exp (-(m i : ℝ)))⁻¹) = + ∏ n ∈ s.image m, (1 - Real.exp (-(n : ℝ)))⁻¹ := by + symm + exact Finset.prod_image hinj + rw [heq] + apply finite_spreadInflation_lt_four + intro n hn + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hn + exact hpos i hi + +def iteratedSpread (σ : ℝ) (l t : ℕ) : ℝ := + σ * ∏ u ∈ range t, (1 - Real.exp (-(reducedCapacity l u : ℝ)))⁻¹ + +@[simp] theorem iteratedSpread_zero (σ : ℝ) (l : ℕ) : iteratedSpread σ l 0 = σ := by + simp [iteratedSpread] + +theorem iteratedSpread_succ (σ : ℝ) (l t : ℕ) : + iteratedSpread σ l (t + 1) = + iteratedSpread σ l t / (1 - Real.exp (-(reducedCapacity l t : ℝ))) := by + simp only [iteratedSpread, prod_range_succ, div_eq_mul_inv, mul_assoc] + +theorem halving_spreadInflation_lt_four {l t : ℕ} (hpos : 0 < reducedCapacity l t) : + (∏ u ∈ range t, (1 - Real.exp (-(reducedCapacity l u : ℝ)))⁻¹) < 4 := by + apply spreadInflation_lt_four (range t) (reducedCapacity l) + · intro u hu + exact le_trans hpos (antitone_reducedCapacity l (le_of_lt (mem_range.mp hu))) + · intro u hu v hv huv + exact (strictAntiOn_reducedCapacity hpos).injOn + (le_of_lt (mem_range.mp hu)) (le_of_lt (mem_range.mp hv)) huv + +theorem iteratedSpread_pos {σ : ℝ} (hσ : 0 < σ) {l t : ℕ} + (hpos : 0 < reducedCapacity l t) : 0 < iteratedSpread σ l t := by + apply mul_pos hσ + apply Finset.prod_pos + intro u hu + apply inv_pos.mpr + apply sub_pos.mpr + rw [Real.exp_lt_one_iff] + have hp : 0 < reducedCapacity l u := + lt_of_lt_of_le hpos (antitone_reducedCapacity l (mem_range.mp hu).le) + exact neg_neg_of_pos (by exact_mod_cast hp) + +theorem iteratedSpread_le_four_mul {σ : ℝ} (hσ : 0 < σ) {l t : ℕ} + (hpos : 0 < reducedCapacity l t) : iteratedSpread σ l t ≤ 4 * σ := by + have h := mul_lt_mul_of_pos_left (halving_spreadInflation_lt_four hpos) hσ + simpa only [iteratedSpread, mul_comm σ 4] using h.le + +theorem exp_neg_seven_le_one_eighth : Real.exp (-7) ≤ (1 / 8 : ℝ) := by + have he : (8 : ℝ) ≤ Real.exp 7 := by + have h := Real.add_one_le_exp (7 : ℝ) + norm_num at h + exact h + rw [Real.exp_neg] + apply (inv_le_iff_one_le_mul₀ (Real.exp_pos 7)).mpr + nlinarith + +theorem sum_exp_neg_seven_capacities_lt_one_quarter (s : Finset ℕ) + (hpos : ∀ m ∈ s, 1 ≤ m) : + (∑ m ∈ s, Real.exp (-7 * (m : ℝ))) < (1 / 4 : ℝ) := by + have hq0 := (Real.exp_pos (-7)).le + have hq1 : Real.exp (-7) < 1 := lt_of_le_of_lt exp_neg_seven_le_one_eighth (by norm_num) + have heq (m : ℕ) : Real.exp (-7 * (m : ℝ)) = Real.exp (-7) ^ m := by + simpa only [mul_comm] using Real.exp_nat_mul (-7) m + simp_rw [heq] + have hsum := sum_positive_geometric_le s hq0 hq1 hpos + have hfrac : Real.exp (-7) / (1 - Real.exp (-7)) ≤ (1 / 7 : ℝ) := by + apply (div_le_iff₀ (sub_pos.mpr hq1)).mpr + nlinarith [exp_neg_seven_le_one_eighth] + exact lt_of_le_of_lt (hsum.trans hfrac) (by norm_num) + +theorem capacity_failure_sum_lt_one_quarter (m : ℕ → ℕ) (k : ℕ) + (hpos : ∀ j, j < k → 1 ≤ m j) + (hgrowth : ∀ j, j + 1 < k → 16 * m j ≤ m (j + 1)) : + (∑ j ∈ range k, + Real.exp (12 * (∑ h ∈ range j, (m h : ℝ)) - 8 * (m j : ℝ))) < (1 / 4 : ℝ) := by + have hmono := strictMonoOn_capacities m k hpos hgrowth + have hinj : Set.InjOn m (↑(range k) : Set ℕ) := by + intro i hi j hj hij + exact hmono.injOn (mem_range.mp hi) (mem_range.mp hj) hij + calc + (∑ j ∈ range k, + Real.exp (12 * (∑ h ∈ range j, (m h : ℝ)) - 8 * (m j : ℝ))) + ≤ ∑ j ∈ range k, Real.exp (-7 * (m j : ℝ)) := by + apply Finset.sum_le_sum + intro j hj + apply Real.exp_le_exp.mpr + have hs := capacity_prefix_sum_real_le m k hgrowth (mem_range.mp hj) + have hm : 0 ≤ (m j : ℝ) := Nat.cast_nonneg _ + nlinarith + _ = ∑ n ∈ (range k).image m, Real.exp (-7 * (n : ℝ)) := by + symm + exact Finset.sum_image hinj + _ < 1 / 4 := by + apply sum_exp_neg_seven_capacities_lt_one_quarter + intro n hn + obtain ⟨j, hj, rfl⟩ := mem_image.mp hn + exact hpos j (mem_range.mp hj) + +/-- A history-free allowance for the spread parameter at capacity `m`. -/ +def capacityReserve (σ : ℝ) (m : ℕ) : ℝ := + 4 * σ * ∏ j ∈ Finset.Icc 1 m, (1 - Real.exp (-(j : ℝ))) + +theorem retentionFactor_pos {m : ℕ} (hm : 0 < m) : + 0 < 1 - Real.exp (-(m : ℝ)) := by + apply sub_pos.mpr + rw [Real.exp_lt_one_iff] + exact neg_neg_of_pos (by exact_mod_cast hm) + +theorem retentionFactor_le_one (m : ℕ) : + 1 - Real.exp (-(m : ℝ)) ≤ 1 := sub_le_self _ (Real.exp_pos _).le + +@[simp] theorem capacityReserve_zero (σ : ℝ) : capacityReserve σ 0 = 4 * σ := by + simp [capacityReserve] + +theorem capacityReserve_pos {σ : ℝ} (hσ : 0 < σ) (m : ℕ) : + 0 < capacityReserve σ m := by + apply mul_pos (mul_pos (by norm_num) hσ) + apply Finset.prod_pos + intro j hj + exact retentionFactor_pos (Finset.mem_Icc.mp hj).1 + +theorem capacityReserve_lower {σ : ℝ} (hσ : 0 ≤ σ) (m : ℕ) : + σ ≤ capacityReserve σ m := by + have hp := finite_retentionProduct_ge_one_third (Finset.Icc 1 m) + (fun j hj => (Finset.mem_Icc.mp hj).1) + have hm := mul_le_mul_of_nonneg_left hp (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) hσ) + unfold capacityReserve + nlinarith + +theorem capacityReserve_upper {σ : ℝ} (hσ : 0 ≤ σ) (m : ℕ) : + capacityReserve σ m ≤ 4 * σ := by + have hp : (∏ j ∈ Finset.Icc 1 m, (1 - Real.exp (-(j : ℝ)))) ≤ 1 := by + apply Finset.prod_le_one₀ + · intro j hj + exact (retentionFactor_pos (Finset.mem_Icc.mp hj).1).le + · intro j _ + exact retentionFactor_le_one j + have hm := mul_le_mul_of_nonneg_left hp (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) hσ) + simpa only [capacityReserve, mul_one] using hm + +theorem antitone_capacityReserve {σ : ℝ} (hσ : 0 ≤ σ) : + Antitone (capacityReserve σ) := by + intro a b hab + apply mul_le_mul_of_nonneg_left _ (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) hσ) + apply Finset.prod_le_prod_of_subset_of_le_one₀ + · intro j hj + obtain ⟨hj1, hja⟩ := Finset.mem_Icc.mp hj + exact Finset.mem_Icc.mpr ⟨hj1, hja.trans hab⟩ + · intro j hj + exact (retentionFactor_pos (Finset.mem_Icc.mp hj).1).le + · intro j _ _ + exact retentionFactor_le_one j + +theorem capacityReserve_succ (σ : ℝ) (m : ℕ) : + capacityReserve σ (m + 1) = capacityReserve σ m * + (1 - Real.exp (-((m + 1 : ℕ) : ℝ))) := by + simp only [capacityReserve, Finset.prod_Icc_succ_top (show 1 ≤ m + 1 by omega), mul_assoc] + +theorem capacityReserve_div_le_half {σ : ℝ} (hσ : 0 ≤ σ) {m : ℕ} (hm : 0 < m) : + capacityReserve σ m / (1 - Real.exp (-(m : ℝ))) ≤ capacityReserve σ (m / 2) := by + obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hm) + rw [capacityReserve_succ, mul_div_cancel_right₀ _ (retentionFactor_pos (Nat.succ_pos m)).ne'] + exact antitone_capacityReserve hσ (show (m + 1) / 2 ≤ m by omega) + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/CopyOrbits.lean b/lean/OAI/Combinatorics/GraphThreshold/CopyOrbits.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd50ecbc8596d494a34aabf9159eed96fce9c9f5 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/CopyOrbits.lean @@ -0,0 +1,391 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import OAI.Combinatorics.GraphThreshold.FiniteProbability +import Mathlib.Algebra.Group.Action.Pointwise.Finset +import Mathlib.Data.Finset.Powerset +import Mathlib.Tactic + +namespace OAI + +/-! +# Distinct subset copies under a finite group action + +Copies are distinct orbit elements, not group elements or labeled embeddings. +All counting and probability statements therefore retain the stabilizer +multiplicities correctly, including for the empty subset. +-/ + +noncomputable section + +open scoped BigOperators Pointwise + +namespace LeanBlast.SecondKahnKalai + +universe u v + +variable (G : Type u) [Group G] [Fintype G] +variable {X : Type v} [DecidableEq X] [MulAction G X] + +/-- The distinct copies of a finite subset under the given action. -/ +def copyOrbit (F : Finset X) : Finset (Finset X) := + Finset.univ.image (fun g : G => g • F) + +/-- An actual distinct copy, with no labeling multiplicity. -/ +abbrev OrbitCopy (F : Finset X) := {J : Finset X // J ∈ copyOrbit G F} + +/-- The total number of distinct copies. -/ +def orbitCount (F : Finset X) : ℕ := (copyOrbit G F).card + +/-- Copies of `F` whose elements all lie in the fixed set `I`. -/ +def internalCopyCount (I F : Finset X) : ℕ := + ((copyOrbit G F).filter (fun J => J ⊆ I)).card + +/-- Copies of `I` containing the fixed observed set `U`. -/ +def containingCopyCount (I U : Finset X) : ℕ := + ((copyOrbit G I).filter (fun J => U ⊆ J)).card + +@[simp] theorem mem_copyOrbit_iff {F J : Finset X} : + J ∈ copyOrbit G F ↔ ∃ g : G, g • F = J := by + simp only [copyOrbit, Finset.mem_image, Finset.mem_univ, true_and] + +theorem self_mem_copyOrbit (F : Finset X) : F ∈ copyOrbit G F := by + exact (mem_copyOrbit_iff G).mpr ⟨1, one_smul _ _⟩ + +theorem copyOrbit_nonempty (F : Finset X) : (copyOrbit G F).Nonempty := + ⟨F, self_mem_copyOrbit G F⟩ + +theorem orbitCount_pos (F : Finset X) : 0 < orbitCount G F := + Finset.card_pos.mpr (copyOrbit_nonempty G F) + +instance orbitCopy_nonempty (F : Finset X) : Nonempty (OrbitCopy G F) := + ⟨⟨F, self_mem_copyOrbit G F⟩⟩ + +@[simp] theorem card_OrbitCopy (F : Finset X) : + Fintype.card (OrbitCopy G F) = orbitCount G F := Fintype.card_coe _ + +theorem smul_mem_copyOrbit (g : G) {F J : Finset X} (hJ : J ∈ copyOrbit G F) : + g • J ∈ copyOrbit G F := by + obtain ⟨h, rfl⟩ := (mem_copyOrbit_iff G).mp hJ + exact (mem_copyOrbit_iff G).mpr ⟨g * h, mul_smul _ _ _⟩ + +@[simp] theorem smul_mem_copyOrbit_iff (g : G) {F J : Finset X} : + g • J ∈ copyOrbit G F ↔ J ∈ copyOrbit G F := by + refine ⟨fun h => ?_, smul_mem_copyOrbit G g⟩ + simpa only [inv_smul_smul] using smul_mem_copyOrbit G g⁻¹ h + +@[simp] theorem copyOrbit_smul (g : G) (F : Finset X) : + copyOrbit G (g • F) = copyOrbit G F := by + ext J + constructor + · intro hJ + obtain ⟨h, rfl⟩ := (mem_copyOrbit_iff G).mp hJ + exact (mem_copyOrbit_iff G).mpr ⟨h * g, mul_smul _ _ _⟩ + · intro hJ + obtain ⟨h, rfl⟩ := (mem_copyOrbit_iff G).mp hJ + apply (mem_copyOrbit_iff G).mpr + refine ⟨h * g⁻¹, ?_⟩ + simp only [mul_smul, inv_smul_smul] + +theorem copyOrbit_eq_of_mem_copyOrbit {F J : Finset X} (hJ : J ∈ copyOrbit G F) : + copyOrbit G J = copyOrbit G F := by + obtain ⟨g, rfl⟩ := (mem_copyOrbit_iff G).mp hJ + exact copyOrbit_smul G g F + +theorem card_eq_of_mem_copyOrbit {F J : Finset X} (hJ : J ∈ copyOrbit G F) : + J.card = F.card := by + obtain ⟨g, rfl⟩ := (mem_copyOrbit_iff G).mp hJ + exact Finset.card_smul_finset _ _ + +/-- The group acts bijectively on the set of actual orbit copies. -/ +def orbitCopyEquiv (g : G) (F : Finset X) : OrbitCopy G F ≃ OrbitCopy G F where + toFun J := ⟨g • J.val, smul_mem_copyOrbit G g J.property⟩ + invFun J := ⟨g⁻¹ • J.val, smul_mem_copyOrbit G g⁻¹ J.property⟩ + left_inv _ := Subtype.ext (inv_smul_smul _ _) + right_inv _ := Subtype.ext (smul_inv_smul _ _) + +@[simp] theorem orbitCopyEquiv_val (g : G) (F : Finset X) (J : OrbitCopy G F) : + (orbitCopyEquiv G g F J).val = g • J.val := rfl + +/-- There are no more internal copies than subsets of the correct size. -/ +theorem internalCopyCount_le_choose (I F : Finset X) : + internalCopyCount G I F ≤ Nat.choose I.card F.card := by + rw [← Finset.card_powersetCard F.card I] + apply Finset.card_le_card + intro J hJ + obtain ⟨hcopy, hsub⟩ := Finset.mem_filter.mp hJ + exact Finset.mem_powersetCard.mpr ⟨hsub, card_eq_of_mem_copyOrbit G hcopy⟩ + +@[simp] theorem copyOrbit_empty : copyOrbit G (∅ : Finset X) = {∅} := by + ext J + simp only [mem_copyOrbit_iff, Finset.smul_finset_empty, Finset.mem_singleton] + constructor + · rintro ⟨_, h⟩ + exact h.symm + · intro h + exact ⟨1, h.symm⟩ + +@[simp] theorem orbitCount_empty : orbitCount G (∅ : Finset X) = 1 := by + simp [orbitCount] + +@[simp] theorem internalCopyCount_empty (I : Finset X) : + internalCopyCount G I ∅ = 1 := by + simp [internalCopyCount, Finset.filter_singleton, Finset.empty_subset] + +/-- Acting permutes the distinct orbit elements with no multiplicity. -/ +theorem sum_copyOrbit_smul (g : G) (F : Finset X) (f : Finset X → ℕ) : + (∑ J ∈ copyOrbit G F, f (g • J)) = ∑ J ∈ copyOrbit G F, f J := by + calc + _ = ∑ J : OrbitCopy G F, f (g • J.val) := + (Finset.sum_coe_sort (copyOrbit G F) (fun J => f (g • J))).symm + _ = ∑ J : OrbitCopy G F, f J.val := + (orbitCopyEquiv G g F).sum_comp (fun J : OrbitCopy G F => f J.val) + _ = _ := Finset.sum_coe_sort (copyOrbit G F) f + +theorem internalCopyCount_smul (g : G) (I F : Finset X) : + internalCopyCount G (g • I) F = internalCopyCount G I F := by + have h := sum_copyOrbit_smul G g F (fun J => if J ⊆ g • I then 1 else 0) + simpa only [Finset.smul_finset_subset_smul_finset_iff, Finset.sum_boole, + Nat.cast_id, internalCopyCount] using h.symm + +theorem containingCopyCount_smul (g : G) (I U : Finset X) : + containingCopyCount G I (g • U) = containingCopyCount G I U := by + have h := sum_copyOrbit_smul G g I (fun J => if g • U ⊆ J then 1 else 0) + simpa only [Finset.smul_finset_subset_smul_finset_iff, Finset.sum_boole, + Nat.cast_id, containingCopyCount] using h.symm + +theorem internalCopyCount_eq_of_mem_copyOrbit {I I₀ F : Finset X} + (hI : I₀ ∈ copyOrbit G I) : internalCopyCount G I₀ F = internalCopyCount G I F := by + obtain ⟨g, rfl⟩ := (mem_copyOrbit_iff G).mp hI + exact internalCopyCount_smul G g I F + +theorem containingCopyCount_eq_of_mem_copyOrbit {I F F₀ : Finset X} + (hF : F₀ ∈ copyOrbit G F) : + containingCopyCount G I F₀ = containingCopyCount G I F := by + obtain ⟨g, rfl⟩ := (mem_copyOrbit_iff G).mp hF + exact containingCopyCount_smul G g I F + +/-- Double-count containment pairs of distinct orbit copies. -/ +theorem copy_incidence_identity (I F : Finset X) : + orbitCount G F * containingCopyCount G I F = + orbitCount G I * internalCopyCount G I F := by + have h : (∑ U ∈ copyOrbit G F, ∑ J ∈ copyOrbit G I, if U ⊆ J then (1 : ℕ) else 0) = + ∑ J ∈ copyOrbit G I, ∑ U ∈ copyOrbit G F, if U ⊆ J then (1 : ℕ) else 0 := + Finset.sum_comm + simp only [Finset.sum_boole] at h + change (∑ U ∈ copyOrbit G F, containingCopyCount G I U) = + ∑ J ∈ copyOrbit G I, internalCopyCount G J F at h + have hleft : (∑ U ∈ copyOrbit G F, containingCopyCount G I U) = + orbitCount G F * containingCopyCount G I F := by + calc + _ = ∑ _U ∈ copyOrbit G F, containingCopyCount G I F := + Finset.sum_congr rfl (fun _ hU => containingCopyCount_eq_of_mem_copyOrbit G hU) + _ = _ := by simp [orbitCount] + have hright : (∑ J ∈ copyOrbit G I, internalCopyCount G J F) = + orbitCount G I * internalCopyCount G I F := by + calc + _ = ∑ _J ∈ copyOrbit G I, internalCopyCount G I F := + Finset.sum_congr rfl (fun _ hJ => internalCopyCount_eq_of_mem_copyOrbit G hJ) + _ = _ := by simp [orbitCount] + rwa [hleft, hright] at h + +theorem containingCopyCount_pos_iff (I U : Finset X) : + 0 < containingCopyCount G I U ↔ ∃ g : G, U ⊆ g • I := by + rw [containingCopyCount, Finset.card_pos] + constructor + · rintro ⟨J, hJ⟩ + obtain ⟨hcopy, hsub⟩ := Finset.mem_filter.mp hJ + obtain ⟨g, rfl⟩ := (mem_copyOrbit_iff G).mp hcopy + exact ⟨g, hsub⟩ + · rintro ⟨g, hg⟩ + refine ⟨g • I, Finset.mem_filter.mpr ⟨?_, hg⟩⟩ + exact (mem_copyOrbit_iff G).mpr ⟨g, rfl⟩ + +/-- Positive containment can be pulled back to an actual subset of `I`. -/ +theorem exists_pullback_of_containingCopyCount_pos {I U : Finset X} + (hpos : 0 < containingCopyCount G I U) : + ∃ V : Finset X, V ⊆ I ∧ U ∈ copyOrbit G V ∧ V.card = U.card := by + obtain ⟨g, hg⟩ := (containingCopyCount_pos_iff G I U).mp hpos + refine ⟨g⁻¹ • U, (Finset.subset_smul_finset_iff.mp hg), ?_, + Finset.card_smul_finset _ _⟩ + exact (mem_copyOrbit_iff G).mpr ⟨g, smul_inv_smul _ _⟩ + +/-- The uniform law on distinct copies, rather than on labeled embeddings. -/ +def copyLaw (I : Finset X) : FiniteLaw (OrbitCopy G I) := + FiniteLaw.uniform (OrbitCopy G I) + +theorem copyLaw_isPositive (I : Finset X) : (copyLaw G I).IsPositive := + FiniteLaw.uniform_isPositive _ + +/-- Probability that a uniform actual copy contains an observed finite set. -/ +def containmentProb (I U : Finset X) : ℝ := + (copyLaw G I).prob (fun J => U ⊆ J.val) + +/-- Expose the generic uniform formula with the caller's decidable predicate. +The finite sets are equal extensionally even when the generic probability +definition uses its own classical decision procedure. -/ +private theorem uniform_prob_count (Ω : Type*) [Fintype Ω] [Nonempty Ω] + (P : Ω → Prop) [DecidablePred P] : + (FiniteLaw.uniform Ω).prob P = ((Finset.univ.filter P).card : ℝ) / Fintype.card Ω := by + have hfilter : @Finset.filter Ω P (fun ω => Classical.propDecidable (P ω)) Finset.univ = + Finset.univ.filter P := by + ext ω + simp only [Finset.mem_filter] + rw [FiniteLaw.uniform_prob, hfilter] + +theorem card_filter_OrbitCopy (I : Finset X) (P : Finset X → Prop) [DecidablePred P] : + ((Finset.univ : Finset (OrbitCopy G I)).filter (fun J => P J.val)).card = + ((copyOrbit G I).filter P).card := by + have h : (∑ J : OrbitCopy G I, if P J.val then (1 : ℕ) else 0) = + ∑ J ∈ copyOrbit G I, if P J then 1 else 0 := + Finset.sum_coe_sort (copyOrbit G I) (fun J => if P J then (1 : ℕ) else 0) + simpa only [Finset.sum_boole, Nat.cast_id] using h + +theorem containmentProb_eq_count (I U : Finset X) : + containmentProb G I U = (containingCopyCount G I U : ℝ) / orbitCount G I := by + rw [containmentProb, copyLaw, uniform_prob_count, card_OrbitCopy] + exact congrArg (fun k : ℕ => (k : ℝ) / (orbitCount G I : ℝ)) + (card_filter_OrbitCopy G I (fun J => U ⊆ J)) + +theorem containmentProb_nonneg (I U : Finset X) : 0 ≤ containmentProb G I U := + (copyLaw G I).prob_nonneg _ + +theorem containmentProb_le_one (I U : Finset X) : containmentProb G I U ≤ 1 := + (copyLaw G I).prob_le_one _ + +@[simp] theorem containmentProb_empty (I : Finset X) : containmentProb G I ∅ = 1 := by + simp [containmentProb] + +theorem containmentProb_smul (g : G) (I U : Finset X) : + containmentProb G I (g • U) = containmentProb G I U := by + rw [containmentProb_eq_count, containmentProb_eq_count, containingCopyCount_smul] + +theorem containmentProb_smul_left (g : G) (I U : Finset X) : + containmentProb G (g • I) U = containmentProb G I U := by + simp only [containmentProb_eq_count, containingCopyCount, orbitCount, copyOrbit_smul] + +theorem containmentProb_smul_both (g : G) (I U : Finset X) : + containmentProb G (g • I) (g • U) = containmentProb G I U := by + rw [containmentProb_smul_left, containmentProb_smul] + +theorem containmentProb_eq_of_mem_copyOrbit {I F F₀ : Finset X} + (hF : F₀ ∈ copyOrbit G F) : containmentProb G I F₀ = containmentProb G I F := by + obtain ⟨g, rfl⟩ := (mem_copyOrbit_iff G).mp hF + exact containmentProb_smul G g I F + +/-- The exact permutation-symmetry incidence identity, including the empty set. -/ +theorem containmentProb_eq_internalCopyCount (I F : Finset X) : + containmentProb G I F = (internalCopyCount G I F : ℝ) / orbitCount G F := by + rw [containmentProb_eq_count] + have hI : (orbitCount G I : ℝ) ≠ 0 := ne_of_gt (Nat.cast_pos.mpr (orbitCount_pos G I)) + have hF : (orbitCount G F : ℝ) ≠ 0 := ne_of_gt (Nat.cast_pos.mpr (orbitCount_pos G F)) + have hcount : (orbitCount G F : ℝ) * containingCopyCount G I F = + (orbitCount G I : ℝ) * internalCopyCount G I F := by + exact_mod_cast copy_incidence_identity G I F + apply (div_eq_div_iff hI hF).mpr + nlinarith [hcount] + +theorem containmentProb_copy_eq_internalCopyCount {I F F₀ : Finset X} + (hF : F₀ ∈ copyOrbit G F) : + containmentProb G I F₀ = (internalCopyCount G I F : ℝ) / orbitCount G F := by + rw [containmentProb_eq_of_mem_copyOrbit G hF, containmentProb_eq_internalCopyCount] + +theorem containmentProb_pos_iff (I U : Finset X) : + 0 < containmentProb G I U ↔ ∃ g : G, U ⊆ g • I := by + rw [containmentProb_eq_count, + div_pos_iff_of_pos_right (Nat.cast_pos.mpr (orbitCount_pos G I)), Nat.cast_pos] + exact containingCopyCount_pos_iff G I U + +theorem exists_pullback_of_containmentProb_pos {I U : Finset X} + (hpos : 0 < containmentProb G I U) : + ∃ V : Finset X, V ⊆ I ∧ U ∈ copyOrbit G V ∧ V.card = U.card := by + apply exists_pullback_of_containingCopyCount_pos G + exact (containingCopyCount_pos_iff G I U).mpr ((containmentProb_pos_iff G I U).mp hpos) + +/-- Every copy of a subset extends to at least one copy of its ambient set. -/ +theorem containmentProb_pos_of_copy_subset {S I S₀ : Finset X} + (hSI : S ⊆ I) (hS₀ : S₀ ∈ copyOrbit G S) : 0 < containmentProb G I S₀ := by + obtain ⟨g, rfl⟩ := (mem_copyOrbit_iff G).mp hS₀ + exact (containmentProb_pos_iff G I (g • S)).mpr + ⟨g, Finset.smul_finset_subset_smul_finset_iff.mpr hSI⟩ + +/-- Actual distinct extensions of the observed predecessor. Histories in a +tree may index this same family separately; this type never merges histories. -/ +abbrev ExtensionCopy (I S : Finset X) := {J : OrbitCopy G I // S ⊆ J.val} + +theorem extensionCopy_nonempty {I S : Finset X} + (hpos : 0 < containmentProb G I S) : Nonempty (ExtensionCopy G I S) := by + obtain ⟨g, hg⟩ := (containmentProb_pos_iff G I S).mp hpos + exact ⟨⟨⟨g • I, (mem_copyOrbit_iff G).mpr ⟨g, rfl⟩⟩, hg⟩⟩ + +@[simp] theorem card_ExtensionCopy (I S : Finset X) : + Fintype.card (ExtensionCopy G I S) = containingCopyCount G I S := by + rw [Fintype.card_subtype, card_filter_OrbitCopy] + rfl + +/-- The uniform law on actual copies extending `S`, with positivity justified +by the actual containment event. -/ +def extensionLaw (I S : Finset X) (hpos : 0 < containmentProb G I S) : + FiniteLaw (ExtensionCopy G I S) := by + let : Nonempty (ExtensionCopy G I S) := extensionCopy_nonempty G hpos + exact FiniteLaw.uniform (ExtensionCopy G I S) + +theorem extensionLaw_isPositive (I S : Finset X) (hpos : 0 < containmentProb G I S) : + (extensionLaw G I S hpos).IsPositive := by + let : Nonempty (ExtensionCopy G I S) := extensionCopy_nonempty G hpos + exact FiniteLaw.uniform_isPositive _ + +def extensionIntersectionEquiv (I S J : Finset X) : + {C : ExtensionCopy G I S // J ⊆ C.val.val} ≃ ExtensionCopy G I (S ∪ J) where + toFun C := ⟨C.val.val, Finset.union_subset_iff.mpr ⟨C.val.property, C.property⟩⟩ + invFun C := ⟨⟨C.val, (Finset.union_subset_iff.mp C.property).1⟩, + (Finset.union_subset_iff.mp C.property).2⟩ + left_inv C := by apply Subtype.ext; apply Subtype.ext; rfl + right_inv C := by apply Subtype.ext; rfl + +theorem card_extension_filter (I S J : Finset X) : + ((Finset.univ : Finset (ExtensionCopy G I S)).filter + (fun C => J ⊆ C.val.val)).card = containingCopyCount G I (S ∪ J) := by + calc + _ = Fintype.card {C : ExtensionCopy G I S // J ⊆ C.val.val} := + (Fintype.card_subtype _).symm + _ = Fintype.card (ExtensionCopy G I (S ∪ J)) := + Fintype.card_congr (extensionIntersectionEquiv G I S J) + _ = _ := card_ExtensionCopy G I (S ∪ J) + +theorem extensionLaw_prob (I S J : Finset X) (hpos : 0 < containmentProb G I S) : + (extensionLaw G I S hpos).prob (fun C => J ⊆ C.val.val) = + containmentProb G I (S ∪ J) / containmentProb G I S := by + let : Nonempty (ExtensionCopy G I S) := extensionCopy_nonempty G hpos + change (FiniteLaw.uniform (ExtensionCopy G I S)).prob _ = _ + rw [uniform_prob_count] + calc + _ = (containingCopyCount G I (S ∪ J) : ℝ) / containingCopyCount G I S := + congrArg₂ (fun a b : ℕ => (a : ℝ) / (b : ℝ)) + (card_extension_filter G I S J) (card_ExtensionCopy G I S) + _ = _ := by + rw [containmentProb_eq_count, containmentProb_eq_count] + have hI : (orbitCount G I : ℝ) ≠ 0 := ne_of_gt (Nat.cast_pos.mpr (orbitCount_pos G I)) + have hS : (containingCopyCount G I S : ℝ) ≠ 0 := by + apply ne_of_gt + apply Nat.cast_pos.mpr + exact (containingCopyCount_pos_iff G I S).mpr ((containmentProb_pos_iff G I S).mp hpos) + field_simp [hI, hS] + +/-- For a set disjoint from the predecessor, containment in the added label +is exactly the usual conditional containment event. -/ +theorem extensionLaw_added_prob (I S J : Finset X) (hpos : 0 < containmentProb G I S) + (hdis : Disjoint J S) : + (extensionLaw G I S hpos).prob (fun C => J ⊆ C.val.val \ S) = + containmentProb G I (S ∪ J) / containmentProb G I S := by + simpa only [Finset.subset_sdiff, hdis, and_true] using extensionLaw_prob G I S J hpos + +/-- A set meeting the predecessor cannot lie in any added label. -/ +theorem extensionLaw_added_prob_eq_zero (I S J : Finset X) + (hpos : 0 < containmentProb G I S) (hdis : ¬ Disjoint J S) : + (extensionLaw G I S hpos).prob (fun C => J ⊆ C.val.val \ S) = 0 := by + simp [FiniteLaw.prob, Finset.subset_sdiff, hdis] + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/EmbeddingExtension.lean b/lean/OAI/Combinatorics/GraphThreshold/EmbeddingExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3b14e41e2a514f46dc3dbe6c58c45cce4b7c4dc --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/EmbeddingExtension.lean @@ -0,0 +1,25 @@ +import Mathlib.Logic.Equiv.Fintype + +namespace OAI + +/-! Two placements of the same finite graph differ by an ambient permutation. +The statement is about arbitrary embeddings and therefore preserves isolated +vertices as well as vertices incident to edges. -/ + +namespace LeanBlast.SecondKahnKalai + +theorem exists_perm_comp_embedding {α β : Type*} [Finite β] + (f g : α ↪ β) : ∃ σ : Equiv.Perm β, ∀ a, σ (f a) = g a := by + classical + let : Finite α := Finite.of_injective f f.injective + let : Fintype α := Fintype.ofFinite α + let e : Set.range f ≃ Set.range g := f.toEquivRange.symm.trans g.toEquivRange + refine ⟨e.extendSubtype, ?_⟩ + intro a + rw [e.extendSubtype_apply_of_mem (f a) ⟨a, rfl⟩] + change (e (f.toEquivRange a) : β) = g a + simp [e] + +end LeanBlast.SecondKahnKalai + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/FiniteProbability.lean b/lean/OAI/Combinatorics/GraphThreshold/FiniteProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..968d950c7aa1422b5f7ada613d078c6a09805516 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/FiniteProbability.lean @@ -0,0 +1,273 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Algebra.BigOperators.GroupWithZero.Finset +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Data.Fintype.Pi +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring + +namespace OAI + +open scoped BigOperators +noncomputable section +attribute [local instance] Classical.propDecidable + +namespace LeanBlast.SecondKahnKalai + +namespace FiniteLaw + +variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + +@[simp] theorem expectation_const (μ : FiniteLaw Ω) (c : ℝ) : + μ.expectation (fun _ => c) = c := by + rw [expectation, ← Finset.sum_mul, μ.total, one_mul] + +theorem expectation_add (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.expectation (fun ω => f ω + g ω) = μ.expectation f + μ.expectation g := by + simp [expectation, mul_add, Finset.sum_add_distrib] + +theorem expectation_sub (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.expectation (fun ω => f ω - g ω) = μ.expectation f - μ.expectation g := by + simp [expectation, mul_sub, Finset.sum_sub_distrib] + +theorem expectation_smul (μ : FiniteLaw Ω) (c : ℝ) (f : Ω → ℝ) : + μ.expectation (fun ω => c * f ω) = c * μ.expectation f := by + simp [expectation, Finset.mul_sum, mul_left_comm] + +theorem expectation_sum {ι : Type*} [Fintype ι] (μ : FiniteLaw Ω) (f : ι → Ω → ℝ) : + μ.expectation (fun ω => ∑ i, f i ω) = ∑ i, μ.expectation (f i) := by + simp only [expectation, Finset.mul_sum] + exact Finset.sum_comm + +theorem expectation_nonneg (μ : FiniteLaw Ω) {f : Ω → ℝ} (hf : ∀ ω, 0 ≤ f ω) : + 0 ≤ μ.expectation f := + Finset.sum_nonneg fun ω _ => mul_nonneg (μ.nonneg ω) (hf ω) + +theorem expectation_mono (μ : FiniteLaw Ω) {f g : Ω → ℝ} (hfg : ∀ ω, f ω ≤ g ω) : + μ.expectation f ≤ μ.expectation g := + Finset.sum_le_sum fun ω _ => mul_le_mul_of_nonneg_left (hfg ω) (μ.nonneg ω) + +theorem prob_eq_expectation (μ : FiniteLaw Ω) (P : Ω → Prop) : + μ.prob P = μ.expectation (fun ω => if P ω then 1 else 0) := by + classical + simp [prob, expectation, mul_ite] + +@[simp] theorem prob_true (μ : FiniteLaw Ω) : μ.prob (fun _ => True) = 1 := by + simp [prob, μ.total] + +@[simp] theorem prob_false (μ : FiniteLaw Ω) : μ.prob (fun _ => False) = 0 := by + simp [prob] + +theorem prob_nonneg (μ : FiniteLaw Ω) (P : Ω → Prop) : 0 ≤ μ.prob P := by + classical + exact Finset.sum_nonneg fun ω _ => by split_ifs <;> simp [μ.nonneg] + +theorem prob_mono (μ : FiniteLaw Ω) {P Q : Ω → Prop} (hPQ : ∀ ω, P ω → Q ω) : + μ.prob P ≤ μ.prob Q := by + classical + apply Finset.sum_le_sum + intro ω _ + by_cases hp : P ω + · simp [hp, hPQ ω hp] + · by_cases hq : Q ω <;> simp [hp, hq, μ.nonneg ω] + +theorem prob_le_one (μ : FiniteLaw Ω) (P : Ω → Prop) : μ.prob P ≤ 1 := by + simpa using μ.prob_mono (Q := fun _ => True) (fun _ _ => trivial) + +theorem prob_compl (μ : FiniteLaw Ω) (P : Ω → Prop) : + μ.prob (fun ω => ¬ P ω) = 1 - μ.prob P := by + classical + have h : μ.prob P + μ.prob (fun ω => ¬ P ω) = 1 := by + rw [prob, prob, ← Finset.sum_add_distrib, ← μ.total] + apply Finset.sum_congr rfl + intro ω _ + by_cases hp : P ω <;> simp [hp] + linarith + +theorem prob_union_le (μ : FiniteLaw Ω) (P Q : Ω → Prop) : + μ.prob (fun ω => P ω ∨ Q ω) ≤ μ.prob P + μ.prob Q := by + classical + rw [prob, prob, prob, ← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro ω _ + by_cases hp : P ω <;> by_cases hq : Q ω <;> simp [hp, hq, μ.nonneg] + +theorem prob_le_expectation (μ : FiniteLaw Ω) (P : Ω → Prop) (f : Ω → ℝ) + (hf : ∀ ω, 0 ≤ f ω) (hP : ∀ ω, P ω → 1 ≤ f ω) : μ.prob P ≤ μ.expectation f := by + classical + rw [prob_eq_expectation] + apply μ.expectation_mono + intro ω + by_cases hp : P ω + · simpa [hp] using hP ω hp + · simpa [hp] using hf ω + +theorem prob_ge_le_expectation_div (μ : FiniteLaw Ω) (f : Ω → ℝ) + (hf : ∀ ω, 0 ≤ f ω) {t : ℝ} (ht : 0 < t) : + μ.prob (fun ω => t ≤ f ω) ≤ μ.expectation f / t := by + have h := μ.prob_le_expectation (fun ω => t ≤ f ω) (fun ω => t⁻¹ * f ω) + (fun ω => mul_nonneg (inv_nonneg.mpr ht.le) (hf ω)) + (fun ω hω => by simpa [ht.ne'] using mul_le_mul_of_nonneg_left hω (inv_nonneg.mpr ht.le)) + rw [expectation_smul] at h + simpa [div_eq_mul_inv, mul_comm] using h + +def prod (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) : FiniteLaw (Ω × Γ) where + weight ω := μ.weight ω.1 * ν.weight ω.2 + nonneg ω := mul_nonneg (μ.nonneg _) (ν.nonneg _) + total := by + simp only [Fintype.sum_prod_type, ← Finset.mul_sum, ν.total, mul_one, μ.total] + +@[simp] theorem prod_weight (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) (ω : Ω) (γ : Γ) : + (μ.prod ν).weight (ω, γ) = μ.weight ω * ν.weight γ := rfl + +theorem expectation_prod (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) (f : Ω × Γ → ℝ) : + (μ.prod ν).expectation f = μ.expectation (fun ω => ν.expectation (fun γ => f (ω, γ))) := by + simp [expectation, prod, Fintype.sum_prod_type, Finset.mul_sum, mul_assoc] + +theorem prod_isPositive (μ : FiniteLaw Ω) (ν : FiniteLaw Γ) + (hμ : μ.IsPositive) (hν : ν.IsPositive) : (μ.prod ν).IsPositive := + fun ω => mul_pos (hμ ω.1) (hν ω.2) + +def pi {ι : Type*} [Fintype ι] [DecidableEq ι] {A : ι → Type*} [∀ i, Fintype (A i)] + (μ : ∀ i, FiniteLaw (A i)) : FiniteLaw (∀ i, A i) := by + classical + exact { + weight := fun ω => ∏ i, (μ i).weight (ω i) + nonneg := fun ω => Finset.prod_nonneg fun i _ => (μ i).nonneg (ω i) + total := by + rw [← Fintype.prod_sum (fun i a => (μ i).weight a)] + simp_rw [(μ _).total] + simp } + +@[simp] theorem pi_weight {ι : Type*} [Fintype ι] [DecidableEq ι] {A : ι → Type*} [∀ i, Fintype (A i)] + (μ : ∀ i, FiniteLaw (A i)) (ω : ∀ i, A i) : + (pi μ).weight ω = ∏ i, (μ i).weight (ω i) := rfl + +def iid (μ : FiniteLaw Ω) (n : ℕ) : FiniteLaw (Fin n → Ω) := pi (fun _ : Fin n => μ) + +@[simp] theorem iid_weight (μ : FiniteLaw Ω) (n : ℕ) (ω : Fin n → Ω) : + (iid μ n).weight ω = ∏ i, μ.weight (ω i) := rfl + +def uniform (Ω : Type*) [Fintype Ω] [Nonempty Ω] : FiniteLaw Ω where + weight _ := (Fintype.card Ω : ℝ)⁻¹ + nonneg _ := inv_nonneg.mpr (Nat.cast_nonneg _) + total := by + have hN : (Fintype.card Ω : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + simp [hN] + +theorem uniform_isPositive (Ω : Type*) [Fintype Ω] [Nonempty Ω] : + (uniform Ω).IsPositive := fun _ => inv_pos.mpr (Nat.cast_pos.mpr Fintype.card_pos) + +theorem uniform_prob (Ω : Type*) [Fintype Ω] [Nonempty Ω] (P : Ω → Prop) : + (uniform Ω).prob P = ((Finset.univ.filter P).card : ℝ) / Fintype.card Ω := by + simp [prob, uniform, ← Finset.sum_filter, div_eq_mul_inv] + +end FiniteLaw + +variable {X : Type*} [Fintype X] [DecidableEq X] + +def finsetBoolEquiv : Finset X ≃ (X → Bool) where + toFun W x := decide (x ∈ W) + invFun b := Finset.univ.filter fun x => b x = true + left_inv W := by ext x; simp + right_inv b := by + funext x + cases hb : b x <;> simp [hb] + +theorem sum_finset_product (f : X → Bool → ℝ) : + (∑ W : Finset X, ∏ x, f x (decide (x ∈ W))) = + ∏ x, (f x true + f x false) := by + calc + (∑ W : Finset X, ∏ x, f x (decide (x ∈ W))) = + ∑ b : X → Bool, ∏ x, f x (b x) := + (finsetBoolEquiv (X := X)).sum_comp (fun b => ∏ x, f x (b x)) + _ = _ := by rw [← Fintype.prod_sum f]; simp only [Fintype.sum_bool] + +theorem bernoulliExpectation_product (p : ℝ) (f : X → Bool → ℝ) : + bernoulliExpectation p (fun W => ∏ x, f x (decide (x ∈ W))) = + ∏ x, (p * f x true + (1 - p) * f x false) := by + unfold bernoulliExpectation bernoulliWeight + simp_rw [← Finset.prod_mul_distrib] + simpa using sum_finset_product (fun x b => (if b then p else 1 - p) * f x b) + +theorem bernoulliWeight_nonneg {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (W : Finset X) : + 0 ≤ bernoulliWeight p W := by + apply Finset.prod_nonneg + intro x _ + split_ifs <;> linarith + +theorem bernoulliWeight_pos {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) (W : Finset X) : + 0 < bernoulliWeight p W := by + apply Finset.prod_pos + intro x _ + split_ifs <;> linarith + +theorem bernoulliWeight_sum (p : ℝ) : ∑ W : Finset X, bernoulliWeight p W = 1 := by + have hp : p + (1 - p) = 1 := by ring + simpa [bernoulliExpectation, hp] using + bernoulliExpectation_product p (fun (_ : X) (_ : Bool) => 1) + +def bernoulliLaw (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : FiniteLaw (Finset X) where + weight := bernoulliWeight p + nonneg := bernoulliWeight_nonneg hp0 hp1 + total := bernoulliWeight_sum p + +@[simp] theorem bernoulliLaw_weight (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (W : Finset X) : + (bernoulliLaw p hp0 hp1).weight W = bernoulliWeight p W := rfl + +@[simp] theorem bernoulliLaw_expectation (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (f : Finset X → ℝ) : + (bernoulliLaw p hp0 hp1).expectation f = bernoulliExpectation p f := rfl + +@[simp] theorem bernoulliLaw_prob (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (P : Finset X → Prop) : (bernoulliLaw p hp0 hp1).prob P = bernoulliProbability p P := rfl + +theorem bernoulliProbability_eq_expectation (p : ℝ) (P : Finset X → Prop) : + bernoulliProbability p P = bernoulliExpectation p (fun W => if P W then 1 else 0) := by + classical + simp [bernoulliProbability, bernoulliExpectation, mul_ite] + +theorem subset_indicator_product (A W : Finset X) : + (if A ⊆ W then (1 : ℝ) else 0) = + ∏ x, (if x ∈ A then (if x ∈ W then (1 : ℝ) else 0) else 1) := by + rw [Fintype.prod_ite_mem, Finset.prod_boole] + rfl + +theorem bernoulliProbability_subset (p : ℝ) (A : Finset X) : + bernoulliProbability p (fun W => A ⊆ W) = p ^ A.card := by + trans bernoulliExpectation p (fun W => + ∏ x, (if x ∈ A then (if x ∈ W then (1 : ℝ) else 0) else 1)) + · unfold bernoulliProbability bernoulliExpectation + apply Finset.sum_congr rfl + intro W _ + dsimp only + by_cases hs : A ⊆ W + · have hh := (subset_indicator_product A W).symm + simp only [ite_eq_left hs] at hh + rw [hh] + simp [hs] + · have hh := (subset_indicator_product A W).symm + simp only [ite_eq_right hs] at hh + rw [hh] + simp [hs] + calc + bernoulliExpectation p (fun W => + ∏ x, (if x ∈ A then (if x ∈ W then (1 : ℝ) else 0) else 1)) = + ∏ x, (p * (if x ∈ A then (1 : ℝ) else 1) + + (1 - p) * (if x ∈ A then (0 : ℝ) else 1)) := by + simpa only [decide_eq_true_eq, Bool.true_eq, ite_true, Bool.false_eq_true, ite_false] using + bernoulliExpectation_product p + (fun x b => if x ∈ A then (if b then (1 : ℝ) else 0) else 1) + _ = ∏ x, (if x ∈ A then p else 1) := by + apply Finset.prod_congr rfl + intro x _ + by_cases hx : x ∈ A <;> simp [hx] + _ = p ^ A.card := by rw [Fintype.prod_ite_mem]; simp + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/GraphContainment.lean b/lean/OAI/Combinatorics/GraphThreshold/GraphContainment.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4ce6c346c19b09566c06a3ad648aef0131e1b09 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/GraphContainment.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.GraphThreshold.GraphEncoding +import OAI.Combinatorics.GraphThreshold.EmbeddingExtension + +namespace OAI + +noncomputable section + +open scoped Pointwise + +namespace LeanBlast.SecondKahnKalai + +variable {n : ℕ} {V : Type*} + +theorem card_mappedGraphEdges [Fintype V] (f : V ↪ Fin n) (H : SimpleGraph V) : + (graphEdges (H.map f)).card = edgeCount H := by + classical + rw [card_graphEdges, edgeCount_eq_card_edgeFinset, edgeCount_eq_card_edgeFinset] + exact SimpleGraph.card_edgeFinset_map f H + +theorem mapped_copy_le {U W : Type*} {H : SimpleGraph U} {G : SimpleGraph W} + (c : H.Copy G) : H.map c.toEmbedding ≤ G := by + intro a b hab + obtain ⟨v, w, hvw, rfl, rfl⟩ := (SimpleGraph.map_adj c.toEmbedding H a b).mp hab + exact c.toHom.map_adj hvw + +/-- Containment of a graph is equivalent to containing a permuted copy of its +edges. The embedding carries *all* vertices, so isolated vertices are retained. -/ +theorem isContained_iff_exists_smul_subset (f : V ↪ Fin n) (H : SimpleGraph V) + (W : Finset (Edge n)) : + H.IsContained (graphOfEdges W) ↔ + ∃ σ : Equiv.Perm (Fin n), σ • graphEdges (H.map f) ⊆ W := by + constructor + · rintro ⟨c⟩ + obtain ⟨σ, hσ⟩ := exists_perm_comp_embedding f c.toEmbedding + refine ⟨σ, graphOfEdges_le_iff.mp ?_⟩ + rw [graphOfEdges_smul, graphOfEdges_graphEdges, SimpleGraph.map_map] + have heq : (fun v => σ.toEmbedding (f v)) = c.toEmbedding := by + funext v + exact hσ v + change H.map (fun v => σ.toEmbedding (f v)) ≤ graphOfEdges W + rw [heq] + exact mapped_copy_le c + · rintro ⟨σ, hσ⟩ + have hf : H.IsContained (H.map f) := + ⟨(SimpleGraph.Embedding.map f H).toCopy⟩ + have hperm : (H.map f).IsContained (graphOfEdges (σ • graphEdges (H.map f))) := by + rw [graphOfEdges_smul, graphOfEdges_graphEdges] + exact ⟨(SimpleGraph.Iso.map σ _).toCopy⟩ + exact hf.trans (hperm.trans (SimpleGraph.IsContained.of_le (graphOfEdges_mono hσ))) + +theorem copyCount_pos_iff_exists_smul_subset (f : V ↪ Fin n) (H : SimpleGraph V) + (W : Finset (Edge n)) : + 0 < (graphOfEdges W).copyCount H ↔ + ∃ σ : Equiv.Perm (Fin n), σ • graphEdges (H.map f) ⊆ W := + SimpleGraph.copyCount_pos.trans (isContained_iff_exists_smul_subset f H W) + +theorem exists_graphRepresentation [Fintype V] (n : ℕ) (H : SimpleGraph V) + (hcard : Fintype.card V ≤ n) : + ∃ E : Finset (Edge n), E.card = edgeCount H ∧ + ∀ W : Finset (Edge n), + (0 < (graphOfEdges W).copyCount H ↔ + ∃ σ : Equiv.Perm (Fin n), σ • E ⊆ W) := by + obtain ⟨f⟩ := Function.Embedding.nonempty_of_card_le + (show Fintype.card V ≤ Fintype.card (Fin n) by simpa using hcard) + exact ⟨graphEdges (H.map f), card_mappedGraphEdges f H, + copyCount_pos_iff_exists_smul_subset f H⟩ + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/GraphCopies.lean b/lean/OAI/Combinatorics/GraphThreshold/GraphCopies.lean new file mode 100644 index 0000000000000000000000000000000000000000..74d99ecaead4f28cd5d453ef8dbed38906436fab --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/GraphCopies.lean @@ -0,0 +1,109 @@ +import OAI.Combinatorics.GraphThreshold.GraphSupport +import OAI.Combinatorics.GraphThreshold.GraphProbability +import OAI.Combinatorics.GraphThreshold.CopyOrbits +import OAI.Combinatorics.GraphThreshold.GraphExpectedCopies + +namespace OAI + +noncomputable section + +open scoped Pointwise + +namespace LeanBlast.SecondKahnKalai + +variable {n : ℕ} + +theorem mem_copyOrbit_iff_edgeSupportGraph_iso {S T : Finset (Edge n)} : + T ∈ copyOrbit (Equiv.Perm (Fin n)) S ↔ + Nonempty (edgeSupportGraph S ≃g edgeSupportGraph T) := by + rw [mem_copyOrbit_iff] + constructor + · rintro ⟨σ, rfl⟩ + exact ⟨edgeSupportGraph_smulIso σ S⟩ + · rintro ⟨e⟩ + exact exists_smul_eq_of_edgeSupportGraph_iso e + +/-- Distinct edge orbits correspond bijectively to actual unlabelled subgraphs. +The target has no isolated vertices, so its image subgraph is uniquely determined +by its edges. This also covers the empty graph, with its empty vertex set. -/ +def orbitSubgraphEquiv (S : Finset (Edge n)) : + OrbitCopy (Equiv.Perm (Fin n)) S ≃ + {K : (⊤ : SimpleGraph (Fin n)).Subgraph // + Nonempty (edgeSupportGraph S ≃g K.coe)} where + toFun T := ⟨edgeSubgraph T.val, mem_copyOrbit_iff_edgeSupportGraph_iso.mp T.property⟩ + invFun K := ⟨graphEdges K.val.spanningCoe, by + apply mem_copyOrbit_iff_edgeSupportGraph_iso.mpr + obtain ⟨e⟩ := K.property + have hK := subgraph_eq_edgeSubgraph_of_iso K.val e + change Nonempty (edgeSupportGraph S ≃g (edgeSubgraph _).coe) + rw [← hK] + exact ⟨e⟩⟩ + left_inv T := by + apply Subtype.ext + exact graphEdges_graphOfEdges T.val + right_inv K := by + apply Subtype.ext + exact (subgraph_eq_edgeSubgraph_of_iso K.val K.property.some).symm + +theorem orbitCount_eq_copyCount (S : Finset (Edge n)) : + orbitCount (Equiv.Perm (Fin n)) S = + (⊤ : SimpleGraph (Fin n)).copyCount (edgeSupportGraph S) := by + classical + calc + orbitCount (Equiv.Perm (Fin n)) S = + Fintype.card (OrbitCopy (Equiv.Perm (Fin n)) S) := (card_OrbitCopy _ _).symm + _ = Fintype.card {K : (⊤ : SimpleGraph (Fin n)).Subgraph // + Nonempty (edgeSupportGraph S ≃g K.coe)} := Fintype.card_congr (orbitSubgraphEquiv S) + _ = _ := by + rw [SimpleGraph.copyCount, Fintype.card_subtype] + apply congrArg Finset.card + ext K + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + +theorem expectedCopies_edgeSupportGraph (p : ℝ) (S : Finset (Edge n)) : + expectedCopies n p (edgeSupportGraph S) = + (orbitCount (Equiv.Perm (Fin n)) S : ℝ) * p ^ S.card := by + rw [expectedCopies_formula, edgeCount_edgeSupportGraph, orbitCount_eq_copyCount] + +/-- The internal orbit constraint follows from an actual subgraph constraint +of the public expectation threshold, with no multiplicity factor. -/ +theorem orbit_expectation_constraint {V : Type*} (f : V ↪ Fin n) + (H : SimpleGraph V) (q : ℝ) + (hq : ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n q F.coe) + (S : Finset (Edge n)) (hS : S ⊆ graphEdges (H.map f)) : + (1 / 2 : ℝ) ≤ (orbitCount (Equiv.Perm (Fin n)) S : ℝ) * q ^ S.card := by + obtain ⟨F, ⟨e⟩⟩ := exists_subgraph_iso_edgeSupportGraph f H S hS + rw [← expectedCopies_edgeSupportGraph, expectedCopies_iso n q e] + exact hq F + +theorem copyCount_pos_iff_orbit_subset {V : Type*} (f : V ↪ Fin n) + (H : SimpleGraph V) (W : Finset (Edge n)) : + 0 < (graphOfEdges W).copyCount H ↔ + ∃ E ∈ copyOrbit (Equiv.Perm (Fin n)) (graphEdges (H.map f)), E ⊆ W := by + rw [copyCount_pos_iff_exists_smul_subset f H W] + constructor + · rintro ⟨σ, hσ⟩ + exact ⟨_, (mem_copyOrbit_iff _).mpr ⟨σ, rfl⟩, hσ⟩ + · rintro ⟨E, hE, hEW⟩ + obtain ⟨σ, rfl⟩ := (mem_copyOrbit_iff _).mp hE + exact ⟨σ, hEW⟩ + +theorem exists_graphRepresentationWithConstraints {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) (q : ℝ) + (hq : ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n q F.coe) : + ∃ E : Finset (Edge n), E.card = edgeCount H ∧ + (∀ W : Finset (Edge n), + (0 < (graphOfEdges W).copyCount H ↔ + ∃ T ∈ copyOrbit (Equiv.Perm (Fin n)) E, T ⊆ W)) ∧ + (∀ S : Finset (Edge n), S ⊆ E → + (1 / 2 : ℝ) ≤ (orbitCount (Equiv.Perm (Fin n)) S : ℝ) * q ^ S.card) := by + obtain ⟨f⟩ := Function.Embedding.nonempty_of_card_le + (show Fintype.card V ≤ Fintype.card (Fin n) by simpa using hcard) + exact ⟨graphEdges (H.map f), card_mappedGraphEdges f H, + copyCount_pos_iff_orbit_subset f H, orbit_expectation_constraint f H q hq⟩ + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/GraphEncoding.lean b/lean/OAI/Combinatorics/GraphThreshold/GraphEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..75fe816e4f1d3f02ee858a6c4b8496731dcf8c50 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/GraphEncoding.lean @@ -0,0 +1,174 @@ +import OAI.Combinatorics.GraphThreshold.Statement +import Mathlib.Algebra.Group.Action.Pointwise.Finset + +namespace OAI + +noncomputable section + +open scoped Pointwise + +namespace LeanBlast.SecondKahnKalai + +/-- The non-loop edge set of an ordinary graph on `Fin n`. -/ +def graphEdges {n : ℕ} (G : SimpleGraph (Fin n)) : Finset (Edge n) := by + classical + exact Finset.univ.filter (fun e => e.val ∈ G.edgeSet) + +variable {n : ℕ} + +/-- Vertex permutations act on unordered non-loop edges. -/ +instance edgeMulAction : MulAction (Equiv.Perm (Fin n)) (Edge n) where + smul σ e := ⟨Sym2.map σ e.val, fun h => + e.property ((Sym2.isDiag_map σ.injective).mp h)⟩ + one_smul e := by + apply Subtype.ext + change Sym2.map (1 : Equiv.Perm (Fin n)) e.val = e.val + simp + mul_smul σ τ e := by + apply Subtype.ext + change Sym2.map (σ * τ) e.val = Sym2.map σ (Sym2.map τ e.val) + rw [Sym2.map_map] + rfl + +@[simp] +theorem edge_smul_val (σ : Equiv.Perm (Fin n)) (e : Edge n) : + (σ • e).val = Sym2.map σ e.val := rfl + +@[simp] +theorem mem_graphEdges (G : SimpleGraph (Fin n)) (e : Edge n) : + e ∈ graphEdges G ↔ e.val ∈ G.edgeSet := by + classical + simp [graphEdges] + +theorem edgeSet_graphOfEdges (W : Finset (Edge n)) : + (graphOfEdges W).edgeSet = Subtype.val '' (W : Set (Edge n)) := by + rw [graphOfEdges, SimpleGraph.edgeSet_fromEdgeSet] + ext e + constructor + · exact And.left + · rintro ⟨a, ha, rfl⟩ + exact ⟨⟨a, ha, rfl⟩, a.property⟩ + +@[simp] +theorem mem_edgeSet_graphOfEdges (W : Finset (Edge n)) (e : Edge n) : + e.val ∈ (graphOfEdges W).edgeSet ↔ e ∈ W := by + classical + simp [graphOfEdges, e.property, Subtype.val_injective.eq_iff] + +@[simp] +theorem graphEdges_graphOfEdges (W : Finset (Edge n)) : + graphEdges (graphOfEdges W) = W := by + classical + ext e + simp + +@[simp] +theorem graphOfEdges_graphEdges (G : SimpleGraph (Fin n)) : + graphOfEdges (graphEdges G) = G := by + apply SimpleGraph.edgeSet_injective + ext e + by_cases he : e.IsDiag + · simp [SimpleGraph.not_mem_edgeSet_of_isDiag, he] + · exact (mem_edgeSet_graphOfEdges (graphEdges G) ⟨e, he⟩).trans + (mem_graphEdges G ⟨e, he⟩) + +/-- No graphs or edge sets are omitted or multiply represented. -/ +def graphEdgeEquiv (n : ℕ) : Finset (Edge n) ≃ SimpleGraph (Fin n) where + toFun := graphOfEdges + invFun := graphEdges + left_inv := graphEdges_graphOfEdges + right_inv := graphOfEdges_graphEdges + +theorem graphOfEdges_smul (σ : Equiv.Perm (Fin n)) (W : Finset (Edge n)) : + graphOfEdges (σ • W) = (graphOfEdges W).map σ.toEmbedding := by + apply SimpleGraph.edgeSet_injective + rw [edgeSet_graphOfEdges, SimpleGraph.edgeSet_map, edgeSet_graphOfEdges, + Finset.smul_finset_def, Finset.coe_image, Set.image_image, Set.image_image] + rfl + +theorem graphEdges_map (σ : Equiv.Perm (Fin n)) (G : SimpleGraph (Fin n)) : + graphEdges (G.map σ.toEmbedding) = σ • graphEdges G := by + apply (graphEdgeEquiv n).injective + change graphOfEdges _ = graphOfEdges _ + rw [graphOfEdges_graphEdges, graphOfEdges_smul, graphOfEdges_graphEdges] + +@[simp] +theorem graphOfEdges_empty : graphOfEdges (∅ : Finset (Edge n)) = ⊥ := by + simp [graphOfEdges] + +@[simp] +theorem graphEdges_bot : graphEdges (⊥ : SimpleGraph (Fin n)) = ∅ := by + classical + ext e + simp + +@[simp] +theorem graphEdges_top : graphEdges (⊤ : SimpleGraph (Fin n)) = Finset.univ := by + classical + ext e + simp [e.property] + +@[simp] +theorem graphOfEdges_univ : graphOfEdges (Finset.univ : Finset (Edge n)) = ⊤ := by + rw [← graphEdges_top, graphOfEdges_graphEdges] + +theorem graphEdges_mono {G H : SimpleGraph (Fin n)} (h : G ≤ H) : + graphEdges G ⊆ graphEdges H := by + intro e he + exact (mem_graphEdges H e).mpr (SimpleGraph.edgeSet_mono h + ((mem_graphEdges G e).mp he)) + +theorem graphOfEdges_mono {S T : Finset (Edge n)} (h : S ⊆ T) : + graphOfEdges S ≤ graphOfEdges T := by + apply SimpleGraph.fromEdgeSet_mono + exact Set.image_mono h + +@[simp] +theorem graphOfEdges_le_iff {S T : Finset (Edge n)} : + graphOfEdges S ≤ graphOfEdges T ↔ S ⊆ T := by + constructor + · intro h + simpa using graphEdges_mono h + · exact graphOfEdges_mono + +/-- Edge-set encoding preserves the ordinary unlabelled edge count. -/ +def graphEdgesEquiv (G : SimpleGraph (Fin n)) : ↥(graphEdges G) ≃ G.edgeSet where + toFun e := ⟨e.val.val, (mem_graphEdges G e.val).mp e.property⟩ + invFun e := ⟨⟨e.val, G.not_isDiag_of_mem_edgeSet e.property⟩, + (mem_graphEdges G _).mpr e.property⟩ + left_inv _ := rfl + right_inv _ := rfl + +@[simp] +theorem card_graphEdges (G : SimpleGraph (Fin n)) : + (graphEdges G).card = edgeCount G := by + classical + rw [edgeCount, Nat.card_eq_fintype_card, ← Fintype.card_coe] + exact Fintype.card_congr (graphEdgesEquiv G) + +@[simp] +theorem edgeCount_graphOfEdges (W : Finset (Edge n)) : + edgeCount (graphOfEdges W) = W.card := by + rw [← card_graphEdges, graphEdges_graphOfEdges] + +theorem edgeCount_eq_card_edgeFinset {V : Type*} [Fintype V] (G : SimpleGraph V) + [Fintype G.edgeSet] : + edgeCount G = G.edgeFinset.card := by + classical + rw [edgeCount, Nat.card_eq_fintype_card, SimpleGraph.edgeFinset_card] + +theorem edgeCount_eq_zero_iff {V : Type*} [Fintype V] (G : SimpleGraph V) : + edgeCount G = 0 ↔ G = ⊥ := by + classical + rw [edgeCount_eq_card_edgeFinset, Finset.card_eq_zero] + exact G.edgeFinset_eq_empty + +theorem positive_copies_iff {V : Type*} (W : Finset (Edge n)) (H : SimpleGraph V) : + 0 < (graphOfEdges W).copyCount H ↔ H.IsContained (graphOfEdges W) := + SimpleGraph.copyCount_pos + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/GraphExpectedCopies.lean b/lean/OAI/Combinatorics/GraphThreshold/GraphExpectedCopies.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8cde73457285062d0c4777279b36a97c0952d89 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/GraphExpectedCopies.lean @@ -0,0 +1,143 @@ +import OAI.Combinatorics.GraphThreshold.GraphEncoding +import OAI.Combinatorics.GraphThreshold.FiniteProbability + +namespace OAI + +noncomputable section + +attribute [local instance] Classical.propDecidable + +namespace LeanBlast.SecondKahnKalai + +universe u + +variable {n : ℕ} {V : Type u} + +/-- Regard an actual subgraph as a subgraph of the complete graph. Its vertex set, +including all isolated vertices, is unchanged. -/ +def subgraphToComplete {G : SimpleGraph (Fin n)} (K : G.Subgraph) : + (⊤ : SimpleGraph (Fin n)).Subgraph where + verts := K.verts + Adj := K.Adj + adj_sub h := h.ne + edge_vert := K.edge_vert + symm := K.symm + +/-- A complete-graph subgraph whose edges occur in G is the same actual subgraph of G. -/ +def subgraphFromComplete (G : SimpleGraph (Fin n)) + (K : (⊤ : SimpleGraph (Fin n)).Subgraph) (hK : K.spanningCoe ≤ G) : + G.Subgraph where + verts := K.verts + Adj := K.Adj + adj_sub h := hK h + edge_vert := K.edge_vert + symm := K.symm + +/-- Copies are put in bijection without choosing or counting graph embeddings. -/ +def completeCopyEquiv (G : SimpleGraph (Fin n)) (F : SimpleGraph V) : + {K : G.Subgraph // Nonempty (F ≃g K.coe)} ≃ + {K : (⊤ : SimpleGraph (Fin n)).Subgraph // + Nonempty (F ≃g K.coe) ∧ K.spanningCoe ≤ G} where + toFun K := ⟨subgraphToComplete K.val, K.property, fun _ _ h => K.val.adj_sub h⟩ + invFun K := ⟨subgraphFromComplete G K.val K.property.2, K.property.1⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem copyCount_eq_complete_card (G : SimpleGraph (Fin n)) (F : SimpleGraph V) : + G.copyCount F = Nat.card + {K : (⊤ : SimpleGraph (Fin n)).Subgraph // + Nonempty (F ≃g K.coe) ∧ K.spanningCoe ≤ G} := by + classical + calc + G.copyCount F = Fintype.card {K : G.Subgraph // Nonempty (F ≃g K.coe)} := by + rw [SimpleGraph.copyCount, Fintype.card_subtype] + apply congrArg Finset.card + ext K + simp + _ = Fintype.card {K : (⊤ : SimpleGraph (Fin n)).Subgraph // + Nonempty (F ≃g K.coe) ∧ K.spanningCoe ≤ G} := + Fintype.card_congr (completeCopyEquiv G F) + _ = _ := Nat.card_eq_fintype_card.symm + +theorem copyCount_eq_sum_complete (G : SimpleGraph (Fin n)) (F : SimpleGraph V) : + (G.copyCount F : ℝ) = + ∑ K : (⊤ : SimpleGraph (Fin n)).Subgraph, + if Nonempty (F ≃g K.coe) then (if K.spanningCoe ≤ G then (1 : ℝ) else 0) + else 0 := by + classical + rw [copyCount_eq_complete_card, Nat.card_eq_fintype_card, Fintype.card_subtype] + rw [Finset.card_eq_sum_ones] + simp only [Nat.cast_sum, Finset.sum_filter] + apply Finset.sum_congr rfl + intro K _ + by_cases hF : Nonempty (F ≃g K.coe) <;> simp [hF] + +/-- Adding ambient isolated vertices does not change the edge count. -/ +theorem edgeCount_spanningCoe {G : SimpleGraph (Fin n)} (K : G.Subgraph) : + edgeCount K.spanningCoe = edgeCount K.coe := by + unfold edgeCount + rw [SimpleGraph.Subgraph.edgeSet_spanningCoe, ← K.image_coe_edgeSet_coe] + exact Nat.card_congr + (Equiv.Set.image (Sym2.map (Subtype.val : K.verts → Fin n)) K.coe.edgeSet + (Sym2.map.injective Subtype.val_injective)).symm + +theorem card_graphEdges_of_copy (F : SimpleGraph V) + (K : (⊤ : SimpleGraph (Fin n)).Subgraph) (hK : Nonempty (F ≃g K.coe)) : + (graphEdges K.spanningCoe).card = edgeCount F := by + obtain ⟨f⟩ := hK + rw [card_graphEdges, edgeCount_spanningCoe] + exact (Nat.card_congr f.mapEdgeSet).symm + +theorem subgraph_survival_probability (p : ℝ) + (K : (⊤ : SimpleGraph (Fin n)).Subgraph) : + bernoulliProbability p (fun W : Finset (Edge n) => + K.spanningCoe ≤ graphOfEdges W) = p ^ edgeCount K.coe := by + have h : ∀ W : Finset (Edge n), + K.spanningCoe ≤ graphOfEdges W ↔ graphEdges K.spanningCoe ⊆ W := by + intro W + calc + K.spanningCoe ≤ graphOfEdges W ↔ + graphOfEdges (graphEdges K.spanningCoe) ≤ graphOfEdges W := by + rw [graphOfEdges_graphEdges] + _ ↔ graphEdges K.spanningCoe ⊆ W := graphOfEdges_le_iff + simp_rw [h] + rw [bernoulliProbability_subset, card_graphEdges, edgeCount_spanningCoe] + +/-- The exact expected number of unlabelled, non-induced copies. The counted +objects include their vertex sets, so the identity retains isolated vertices. -/ +theorem expectedCopies_formula (n : ℕ) (p : ℝ) (F : SimpleGraph V) : + expectedCopies n p F = + ((⊤ : SimpleGraph (Fin n)).copyCount F : ℝ) * p ^ edgeCount F := by + classical + calc + expectedCopies n p F = + ∑ K : (⊤ : SimpleGraph (Fin n)).Subgraph, + if Nonempty (F ≃g K.coe) then p ^ edgeCount F else 0 := by + unfold expectedCopies bernoulliExpectation + simp_rw [copyCount_eq_sum_complete, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro K _ + by_cases hK : Nonempty (F ≃g K.coe) + · simp only [hK, ite_true] + have hsurv := subgraph_survival_probability p K + have hedge : edgeCount K.coe = edgeCount F := + (Nat.card_congr hK.some.mapEdgeSet).symm + rw [hedge] at hsurv + rw [← hsurv] + unfold bernoulliProbability + apply Finset.sum_congr rfl + intro W _ + by_cases hW : K.spanningCoe ≤ graphOfEdges W <;> simp [hW] + · simp [hK] + _ = ((⊤ : SimpleGraph (Fin n)).copyCount F : ℝ) * p ^ edgeCount F := by + rw [copyCount_eq_sum_complete, Finset.sum_mul] + apply Finset.sum_congr rfl + intro K _ + by_cases hK : Nonempty (F ≃g K.coe) <;> simp [hK] + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/GraphHierarchy.lean b/lean/OAI/Combinatorics/GraphThreshold/GraphHierarchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..f74de5086a40ab637c143b1df82cf58c52d400a3 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/GraphHierarchy.lean @@ -0,0 +1,330 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import OAI.Combinatorics.GraphThreshold.ProbabilityTree +import OAI.Combinatorics.GraphThreshold.CopyOrbits +import OAI.Combinatorics.GraphThreshold.Predecessor +import Mathlib.Data.Finset.Card +import Mathlib.Tactic + +namespace OAI + +/-! The finite hierarchy and the actual tree of extensions used in the graph +application. Histories are represented by the probability tree's dependent +paths; equal set labels do not identify distinct histories. -/ + +noncomputable section + +open Finset + +namespace LeanBlast.SecondKahnKalai + +/-- A reversed predecessor chain, with its first term empty and last term the +given set. The relation records the actual rule used to select predecessors. -/ +structure SetHierarchy {X : Type*} [DecidableEq X] + (R : Finset X → Finset X → Prop) (H : Finset X) where + depth : ℕ + stage : ℕ → Finset X + first : stage 0 = ∅ + last : stage depth = H + nested : ∀ i, i < depth → stage i ⊆ stage (i + 1) + sparse : ∀ i, i < depth → 17 * (stage i).card < (stage (i + 1)).card + selected : ∀ i, i < depth → R (stage i) (stage (i + 1)) + +namespace SetHierarchy + +variable {X : Type*} [DecidableEq X] +variable {R : Finset X → Finset X → Prop} {H : Finset X} + +theorem stage_subset_stage (h : SetHierarchy R H) {i j : ℕ} + (hij : i ≤ j) (hj : j ≤ h.depth) : h.stage i ⊆ h.stage j := by + induction j, hij using Nat.le_induction with + | base => exact Subset.rfl + | succ j hij ih => + exact (ih (by omega)).trans (h.nested j (by omega)) + +theorem stage_subset (h : SetHierarchy R H) {i : ℕ} (hi : i ≤ h.depth) : + h.stage i ⊆ H := by + simpa only [h.last] using h.stage_subset_stage hi (le_refl h.depth) + +theorem depth_pos (h : SetHierarchy R H) (hH : H.Nonempty) : 0 < h.depth := by + by_contra hn + have hd : h.depth = 0 := by omega + have : H = ∅ := by rw [← h.last, hd, h.first] + simp [this] at hH + +/-- The number of new elements on a level of the hierarchy. -/ +def capacity (h : SetHierarchy R H) (i : ℕ) : ℕ := + (h.stage (i + 1)).card - (h.stage i).card + +theorem capacity_pos (h : SetHierarchy R H) {i : ℕ} (hi : i < h.depth) : + 0 < h.capacity i := by + have hs := h.sparse i hi + unfold capacity + omega + +theorem capacity_growth (h : SetHierarchy R H) {i : ℕ} (hi : i + 1 < h.depth) : + 16 * h.capacity i ≤ h.capacity (i + 1) := by + have hs := h.sparse (i + 1) hi + unfold capacity + omega + +theorem capacity_le (h : SetHierarchy R H) {i : ℕ} (hi : i < h.depth) : + h.capacity i ≤ H.card := by + exact (Nat.sub_le _ _).trans (Finset.card_le_card (h.stage_subset (by omega))) + +end SetHierarchy + +/-- Strict cardinal descent constructs a finite hierarchy; no chain or tree is +assumed as an input. The predecessor hypotheses are needed only inside `H`. -/ +theorem exists_setHierarchy {X : Type*} [DecidableEq X] + (R : Finset X → Finset X → Prop) (H : Finset X) + (hpred : ∀ I, I ⊆ H → I.Nonempty → + ∃ S, S ⊆ I ∧ 17 * S.card < I.card ∧ R S I) : + Nonempty (SetHierarchy R H) := by + have aux : ∀ m : ℕ, ∀ I : Finset X, I.card = m → I ⊆ H → + Nonempty (SetHierarchy R I) := by + intro m + induction m using Nat.strong_induction_on with + | h m ih => + intro I hcard hIH + by_cases hI : I = ∅ + · subst I + exact ⟨{ + depth := 0 + stage := fun _ => ∅ + first := rfl + last := rfl + nested := by omega + sparse := by omega + selected := by omega }⟩ + · obtain ⟨S, hSI, hsmall, hRSI⟩ := hpred I hIH (Finset.nonempty_iff_ne_empty.mpr hI) + have hlt : S.card < m := by omega + obtain ⟨a⟩ := ih S.card hlt S rfl (hSI.trans hIH) + refine ⟨{ + depth := a.depth + 1 + stage := fun i => if i ≤ a.depth then a.stage i else I + first := by simpa using a.first + last := by simp + nested := ?_ + sparse := ?_ + selected := ?_ }⟩ + · intro i hi + by_cases hik : i < a.depth + · simpa only [ite_eq_left (show i ≤ a.depth by omega), + ite_eq_left (show i + 1 ≤ a.depth by omega)] using a.nested i hik + · have hik' : i = a.depth := by omega + subst i + simpa only [ite_eq_left (le_refl a.depth), + ite_eq_right (show ¬a.depth + 1 ≤ a.depth by omega), a.last] using hSI + · intro i hi + by_cases hik : i < a.depth + · simpa only [ite_eq_left (show i ≤ a.depth by omega), + ite_eq_left (show i + 1 ≤ a.depth by omega)] using a.sparse i hik + · have hik' : i = a.depth := by omega + subst i + simpa only [ite_eq_left (le_refl a.depth), + ite_eq_right (show ¬a.depth + 1 ≤ a.depth by omega), a.last] using hsmall + · intro i hi + by_cases hik : i < a.depth + · simpa only [ite_eq_left (show i ≤ a.depth by omega), + ite_eq_left (show i + 1 ≤ a.depth by omega)] using a.selected i hik + · have hik' : i = a.depth := by omega + subst i + simpa only [ite_eq_left (le_refl a.depth), + ite_eq_right (show ¬a.depth + 1 ≤ a.depth by omega), a.last] using hRSI + exact aux H.card H rfl Subset.rfl + +section OrbitTrees + +variable (G : Type*) [Group G] [Fintype G] +variable {X : Type} [DecidableEq X] [MulAction G X] + +/-- A conditional containment-ratio estimate is exactly spreadness of the +added set. Requests intersecting the existing set have probability zero. -/ +theorem extensionLaw_isSpread_of_ratio (I S : Finset X) + (hp : 0 < containmentProb G I S) (σ : ℝ) (hσ : 0 ≤ σ) + (hratio : ∀ J : Finset X, J.Nonempty → Disjoint S J → + containmentProb G I (S ∪ J) / containmentProb G I S ≤ σ ^ J.card) : + IsSpread (extensionLaw G I S hp) (fun b => b.val.val \ S) σ := by + intro J hJ + by_cases hd : Disjoint J S + · rw [extensionLaw_added_prob G I S J hp hd] + exact hratio J hJ hd.symm + · rw [extensionLaw_added_prob_eq_zero G I S J hp hd] + exact pow_nonneg hσ _ + +/-- The actual extension tree. At each node its children are all distinct +copies of the next set containing the current copy, with their uniform law. +The dependent path type retains the entire sequence of choices. -/ +def orbitExtensionTree : (d : ℕ) → (A : ℕ → Finset X) → + (∀ i, i < d → A i ⊆ A (i + 1)) → + (S0 : Finset X) → S0 ∈ copyOrbit G (A 0) → ProbabilityTree X d + | 0, _, _, _, _ => .leaf + | d + 1, A, hnested, S0, hS0 => + let hp := containmentProb_pos_of_copy_subset G (hnested 0 (by omega)) hS0 + .node (ExtensionCopy G (A 1) S0) + (extensionLaw G (A 1) S0 hp) + (extensionLaw_isPositive G (A 1) S0 hp) + (fun b => b.val.val \ S0) + (fun b => orbitExtensionTree d (fun i => A (i + 1)) + (fun i hi => hnested (i + 1) (by omega)) b.val.val b.val.property) + +/-- No element already present at a node occurs anywhere below it. -/ +theorem orbitExtensionTree_support_disjoint (d : ℕ) (A : ℕ → Finset X) + (hnested : ∀ i, i < d → A i ⊆ A (i + 1)) + (S0 : Finset X) (hS0 : S0 ∈ copyOrbit G (A 0)) : + Disjoint S0 (orbitExtensionTree G d A hnested S0 hS0).support := by + induction d generalizing A S0 with + | zero => simp [orbitExtensionTree, ProbabilityTree.support] + | succ d ih => + simp only [orbitExtensionTree, ProbabilityTree.support, + Finset.disjoint_biUnion_right, Finset.mem_univ, forall_true_left, + Finset.disjoint_union_right] + intro b + constructor + · exact Finset.disjoint_left.mpr (fun x hx hxs => (Finset.mem_sdiff.mp hxs).2 hx) + · exact (ih (fun i => A (i + 1)) + (fun i hi => hnested (i + 1) (by omega)) b.val.val b.val.property).mono_left + b.property + +/-- Every constructed tree has the strong recursive disjointness property. -/ +theorem orbitExtensionTree_isDisjoint (d : ℕ) (A : ℕ → Finset X) + (hnested : ∀ i, i < d → A i ⊆ A (i + 1)) + (S0 : Finset X) (hS0 : S0 ∈ copyOrbit G (A 0)) : + (orbitExtensionTree G d A hnested S0 hS0).IsDisjoint := by + induction d generalizing A S0 with + | zero => trivial + | succ d ih => + simp only [orbitExtensionTree, ProbabilityTree.IsDisjoint] + constructor + · intro b + exact (orbitExtensionTree_support_disjoint G d (fun i => A (i + 1)) + (fun i hi => hnested (i + 1) (by omega)) b.val.val b.val.property).mono_left + Finset.sdiff_subset + · intro b + exact ih (fun i => A (i + 1)) + (fun i hi => hnested (i + 1) (by omega)) b.val.val b.val.property + +/-- Adding a path's labels to its starting copy recovers an actual terminal +copy. In particular an empty root gives an actual copy as its path union. -/ +theorem orbitExtensionTree_pathUnion (d : ℕ) (A : ℕ → Finset X) + (hnested : ∀ i, i < d → A i ⊆ A (i + 1)) + (S0 : Finset X) (hS0 : S0 ∈ copyOrbit G (A 0)) + (p : (orbitExtensionTree G d A hnested S0 hS0).Path) : + S0 ∪ (orbitExtensionTree G d A hnested S0 hS0).pathUnion p ∈ + copyOrbit G (A d) := by + induction d generalizing A S0 with + | zero => simpa only [orbitExtensionTree, ProbabilityTree.pathUnion, Finset.union_empty] using hS0 + | succ d ih => + rcases p with ⟨b, p⟩ + have hp := ih (fun i => A (i + 1)) + (fun i hi => hnested (i + 1) (by omega)) b.val.val b.val.property p + simpa only [orbitExtensionTree, ProbabilityTree.pathUnion, ← Finset.union_assoc, + Finset.union_sdiff_of_subset b.property] using hp + +/-- Every arc has exactly the cardinal difference of its two abstract stages, +so these differences are valid capacities at every node of the tree. -/ +theorem orbitExtensionTree_hasCapacities (d : ℕ) (A : ℕ → Finset X) + (hnested : ∀ i, i < d → A i ⊆ A (i + 1)) + (S0 : Finset X) (hS0 : S0 ∈ copyOrbit G (A 0)) : + (orbitExtensionTree G d A hnested S0 hS0).HasCapacities + (fun i => (A (i + 1)).card - (A i).card) := by + induction d generalizing A S0 with + | zero => trivial + | succ d ih => + simp only [orbitExtensionTree, ProbabilityTree.HasCapacities] + constructor + · intro b + rw [Finset.card_sdiff_of_subset b.property, + card_eq_of_mem_copyOrbit G b.val.property, card_eq_of_mem_copyOrbit G hS0] + · intro b + exact ih (fun i => A (i + 1)) + (fun i hi => hnested (i + 1) (by omega)) b.val.val b.val.property + +/-- Local conditional containment ratios give spread at every node, including +nodes reached through different histories with the same current copy. -/ +theorem orbitExtensionTree_hasSpread (σ : ℝ) (hσ : 0 ≤ σ) + (d : ℕ) (A : ℕ → Finset X) + (hnested : ∀ i, i < d → A i ⊆ A (i + 1)) + (hratio : ∀ i, i < d → ∀ S0 ∈ copyOrbit G (A i), + ∀ J : Finset X, J.Nonempty → Disjoint S0 J → + containmentProb G (A (i + 1)) (S0 ∪ J) / + containmentProb G (A (i + 1)) S0 ≤ σ ^ J.card) + (S0 : Finset X) (hS0 : S0 ∈ copyOrbit G (A 0)) : + (orbitExtensionTree G d A hnested S0 hS0).HasSpread (fun _ => σ) := by + induction d generalizing A S0 with + | zero => trivial + | succ d ih => + simp only [orbitExtensionTree, ProbabilityTree.HasSpread] + constructor + · exact extensionLaw_isSpread_of_ratio G (A 1) S0 _ σ hσ + (hratio 0 (by omega) S0 hS0) + · intro b + exact ih (fun i => A (i + 1)) + (fun i hi => hnested (i + 1) (by omega)) + (fun i hi => hratio (i + 1) (by omega)) b.val.val b.val.property + +/-- The constructive assembly from a strict predecessor rule. In particular, +the tree and its chain are outputs, not hypotheses. The concrete maximizing +rule below discharges the two local predecessor requirements. -/ +theorem exists_spread_orbit_tree_of_predecessors + (H : Finset X) (hH : H.Nonempty) (σ : ℝ) (hσ : 0 ≤ σ) + (R : Finset X → Finset X → Prop) + (hpred : ∀ I, I ⊆ H → I.Nonempty → + ∃ S, S ⊆ I ∧ 17 * S.card < I.card ∧ R S I) + (hratio : ∀ I, I ⊆ H → ∀ S, R S I → + ∀ S0 ∈ copyOrbit G S, ∀ J : Finset X, J.Nonempty → Disjoint S0 J → + containmentProb G I (S0 ∪ J) / containmentProb G I S0 ≤ σ ^ J.card) : + ∃ k : ℕ, ∃ m : ℕ → ℕ, ∃ T : ProbabilityTree X k, + 0 < k ∧ T.IsDisjoint ∧ T.HasCapacities m ∧ T.HasSpread (fun _ => σ) ∧ + (∀ i, i < k → 0 < m i) ∧ + (∀ i, i + 1 < k → 16 * m i ≤ m (i + 1)) ∧ + m (k - 1) ≤ H.card ∧ + ∀ p : T.Path, T.pathUnion p ∈ copyOrbit G H := by + obtain ⟨a⟩ := exists_setHierarchy R H hpred + have hk : 0 < a.depth := a.depth_pos hH + have hroot : (∅ : Finset X) ∈ copyOrbit G (a.stage 0) := by + rw [a.first] + exact self_mem_copyOrbit G ∅ + let T := orbitExtensionTree G a.depth a.stage a.nested ∅ hroot + refine ⟨a.depth, a.capacity, T, hk, + orbitExtensionTree_isDisjoint G _ _ _ _ _, + orbitExtensionTree_hasCapacities G _ _ _ _ _, ?_, + (fun i hi => a.capacity_pos hi), (fun i hi => a.capacity_growth hi), + a.capacity_le (by omega), ?_⟩ + · apply orbitExtensionTree_hasSpread G σ hσ + intro i hi S0 hS0 J hJ hd + exact hratio (a.stage (i + 1)) (a.stage_subset (by omega)) + (a.stage i) (a.selected i hi) S0 hS0 J hJ hd + · intro p + simpa only [Finset.empty_union, a.last] using + orbitExtensionTree_pathUnion G a.depth a.stage a.nested ∅ hroot p + +theorem exists_spread_orbit_tree (H : Finset X) (q : ℝ) (hq : 0 < q) + (hH : H.Nonempty) + (hE : ∀ U : Finset X, U ⊆ H → U.Nonempty → + (1 / 2 : ℝ) ≤ (orbitCount G U : ℝ) * q ^ U.card) : + ∃ k : ℕ, ∃ m : ℕ → ℕ, ∃ T : ProbabilityTree X k, + 0 < k ∧ T.IsDisjoint ∧ T.HasCapacities m ∧ + T.HasSpread (fun _ => 128 * q) ∧ + (∀ i, i < k → 0 < m i) ∧ + (∀ i, i + 1 < k → 16 * m i ≤ m (i + 1)) ∧ + m (k - 1) ≤ H.card ∧ + ∀ p : T.Path, T.pathUnion p ∈ copyOrbit G H := by + apply exists_spread_orbit_tree_of_predecessors G H hH (128 * q) (by positivity) + (fun S I => S = maximizingPredecessor G I (128 * q)) + · intro I hIH hI + refine ⟨maximizingPredecessor G I (128 * q), + maximizingPredecessor_subset G I (128 * q), ?_, rfl⟩ + exact maximizingPredecessor_small G I hI hq + (fun U hUI hU => hE U (hUI.trans hIH) hU) + · intro I _ S hS S0 hS0 J _ hd + subst S + exact predecessor_conditional_ratio_le G I (by positivity) hS0 hd + +end OrbitTrees + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/GraphProbability.lean b/lean/OAI/Combinatorics/GraphThreshold/GraphProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8a1af60bf357ef48e3ae53b279bf3102a7d4e29 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/GraphProbability.lean @@ -0,0 +1,149 @@ +import OAI.Combinatorics.GraphThreshold.GraphEncoding +import Mathlib.Tactic + +namespace OAI + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +section BernoulliEndpoints + +variable {X : Type*} [Fintype X] [DecidableEq X] + +theorem bernoulliWeight_zero (W : Finset X) : + bernoulliWeight 0 W = if W = ∅ then 1 else 0 := by + by_cases hW : W = ∅ + · subst W + simp [bernoulliWeight] + · rw [ite_eq_right hW] + obtain ⟨x, hx⟩ := Finset.nonempty_iff_ne_empty.mpr hW + exact Finset.prod_eq_zero (Finset.mem_univ x) (by simp [hx]) + +theorem bernoulliWeight_one (W : Finset X) : + bernoulliWeight 1 W = if W = Finset.univ then 1 else 0 := by + by_cases hW : W = Finset.univ + · subst W + simp [bernoulliWeight] + · rw [ite_eq_right hW] + obtain ⟨x, hx⟩ : ∃ x : X, x ∉ W := by + simpa [Finset.eq_univ_iff_forall] using hW + exact Finset.prod_eq_zero (Finset.mem_univ x) (by simp [hx]) + +@[simp] +theorem bernoulliExpectation_zero (f : Finset X → ℝ) : + bernoulliExpectation 0 f = f ∅ := by + simp [bernoulliExpectation, bernoulliWeight_zero] + +@[simp] +theorem bernoulliExpectation_one (f : Finset X → ℝ) : + bernoulliExpectation 1 f = f Finset.univ := by + simp [bernoulliExpectation, bernoulliWeight_one] + +@[simp] +theorem bernoulliProbability_zero (P : Finset X → Prop) [DecidablePred P] : + bernoulliProbability 0 P = if P ∅ then 1 else 0 := by + classical + unfold bernoulliProbability + rw [Finset.sum_eq_single ∅] + · simp [bernoulliWeight_zero] + · intro W _ hW + simp [bernoulliWeight_zero, hW] + · simp + +@[simp] +theorem bernoulliProbability_one (P : Finset X → Prop) [DecidablePred P] : + bernoulliProbability 1 P = if P Finset.univ then 1 else 0 := by + classical + unfold bernoulliProbability + rw [Finset.sum_eq_single Finset.univ] + · simp [bernoulliWeight_one] + · intro W _ hW + simp [bernoulliWeight_one, hW] + · simp + +end BernoulliEndpoints + +theorem copyCount_iso_target {V W U : Type*} [Fintype V] + (G : SimpleGraph V) {H : SimpleGraph W} {F : SimpleGraph U} + (e : H ≃g F) : G.copyCount H = G.copyCount F := by + classical + unfold SimpleGraph.copyCount + congr 1 + apply Finset.filter_congr + intro J _ + constructor + · rintro ⟨g⟩ + exact ⟨g.comp e.symm⟩ + · rintro ⟨g⟩ + exact ⟨g.comp e⟩ + +theorem expectedCopies_iso {V W : Type*} (n : ℕ) (p : ℝ) + {H : SimpleGraph V} {F : SimpleGraph W} (e : H ≃g F) : + expectedCopies n p H = expectedCopies n p F := by + unfold expectedCopies bernoulliExpectation + simp_rw [copyCount_iso_target _ e] + +theorem containmentProbability_iso {V W : Type*} (n : ℕ) (p : ℝ) + {H : SimpleGraph V} {F : SimpleGraph W} (e : H ≃g F) : + containmentProbability n p H = containmentProbability n p F := by + unfold containmentProbability + congr 1 + funext K + rw [copyCount_iso_target _ e] + +theorem isContained_top_of_card_le {V : Type*} [Fintype V] (n : ℕ) + (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + H.IsContained (⊤ : SimpleGraph (Fin n)) := by + obtain ⟨f⟩ := Function.Embedding.nonempty_of_card_le + (show Fintype.card V ≤ Fintype.card (Fin n) by simpa using hcard) + refine ⟨{ toHom := ⟨f, ?_⟩, injective' := f.injective }⟩ + intro a b hab + exact f.injective.ne hab.ne + +theorem expectedCopies_one_ge_one {V : Type*} [Fintype V] (n : ℕ) + (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + 1 ≤ expectedCopies n 1 H := by + have hp : 0 < (⊤ : SimpleGraph (Fin n)).copyCount H := + SimpleGraph.copyCount_pos.mpr (isContained_top_of_card_le n H hcard) + simpa only [expectedCopies, bernoulliExpectation_one, graphOfEdges_univ, + Nat.one_le_cast] using Nat.succ_le_of_lt hp + +theorem containmentProbability_one {V : Type*} [Fintype V] (n : ℕ) + (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + containmentProbability n 1 H = 1 := by + classical + have hp : 0 < (⊤ : SimpleGraph (Fin n)).copyCount H := + SimpleGraph.copyCount_pos.mpr (isContained_top_of_card_le n H hcard) + simp only [containmentProbability, bernoulliProbability_one, graphOfEdges_univ, hp, + ite_true] + +theorem copyCount_bot_of_edge {V W : Type*} [Fintype V] [Fintype W] + (H : SimpleGraph V) (he : 1 ≤ edgeCount H) : + (⊥ : SimpleGraph W).copyCount H = 0 := by + apply SimpleGraph.copyCount_eq_zero.mpr + rintro ⟨f⟩ + have hbot : H = ⊥ := by + apply SimpleGraph.eq_bot_iff_forall_not_adj.mpr + intro a b hab + exact f.toHom.map_adj hab + have hz := (edgeCount_eq_zero_iff H).mpr hbot + omega + +theorem expectedCopies_zero {V : Type*} [Fintype V] (n : ℕ) + (H : SimpleGraph V) (he : 1 ≤ edgeCount H) : + expectedCopies n 0 H = 0 := by + simp [expectedCopies, copyCount_bot_of_edge H he] + +theorem containmentProbability_zero {V : Type*} [Fintype V] (n : ℕ) + (H : SimpleGraph V) (he : 1 ≤ edgeCount H) : + containmentProbability n 0 H = 0 := by + classical + simp only [containmentProbability, bernoulliProbability_zero, graphOfEdges_empty, + copyCount_bot_of_edge H he, lt_self_iff_false, ite_false] + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/GraphSupport.lean b/lean/OAI/Combinatorics/GraphThreshold/GraphSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..c545a254b55c09f5cc8b4e8793059978c2b8cfa6 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/GraphSupport.lean @@ -0,0 +1,167 @@ +import OAI.Combinatorics.GraphThreshold.GraphContainment + +namespace OAI + +noncomputable section + +open scoped Pointwise + +namespace LeanBlast.SecondKahnKalai + +variable {n : ℕ} + +/-- The subgraph containing exactly the given edges and their incident vertices. +For the empty edge set this has no vertices, as required for internal copies. -/ +def edgeSubgraph (S : Finset (Edge n)) : (⊤ : SimpleGraph (Fin n)).Subgraph where + verts := (graphOfEdges S).support + Adj := (graphOfEdges S).Adj + adj_sub h := h.ne + edge_vert h := ⟨_, h⟩ + symm := (graphOfEdges S).symm + +def edgeSupportGraph (S : Finset (Edge n)) : + SimpleGraph (graphOfEdges S).support := (edgeSubgraph S).coe + +@[simp] +theorem edgeSubgraph_spanningCoe (S : Finset (Edge n)) : + (edgeSubgraph S).spanningCoe = graphOfEdges S := rfl + +@[simp] +theorem edgeSupportGraph_map (S : Finset (Edge n)) : + (edgeSupportGraph S).map (Function.Embedding.subtype + (fun v => v ∈ (graphOfEdges S).support)) = graphOfEdges S := by + exact SimpleGraph.Subgraph.spanningCoe_coe (edgeSubgraph S) + +theorem edgeSupportGraph_noIsolates (S : Finset (Edge n)) + (v : (graphOfEdges S).support) : + ∃ w, (edgeSupportGraph S).Adj v w := by + obtain ⟨w, hw⟩ := v.property + have hvw : (graphOfEdges S).Adj v w := hw + exact ⟨⟨w, ⟨v, hvw.symm⟩⟩, hvw⟩ + +/-- Restriction of a graph isomorphism to its incident vertices. -/ +def supportIso {V W : Type*} {G : SimpleGraph V} {H : SimpleGraph W} + (e : G ≃g H) : G.induce G.support ≃g H.induce H.support where + toFun v := ⟨e v, by + obtain ⟨w, hw⟩ := v.property + exact ⟨e w, e.toHom.map_adj hw⟩⟩ + invFun v := ⟨e.symm v, by + obtain ⟨w, hw⟩ := v.property + exact ⟨e.symm w, e.symm.toHom.map_adj hw⟩⟩ + left_inv v := Subtype.ext (e.symm_apply_apply v) + right_inv v := Subtype.ext (e.apply_symm_apply v) + map_rel_iff' := e.map_rel_iff + +def edgeSupportGraph_smulIso (σ : Equiv.Perm (Fin n)) (S : Finset (Edge n)) : + edgeSupportGraph S ≃g edgeSupportGraph (σ • S) := by + have e : graphOfEdges S ≃g graphOfEdges (σ • S) := by + rw [graphOfEdges_smul] + exact SimpleGraph.Iso.map σ _ + exact supportIso e + +theorem map_eq_of_iso {V W : Type*} {G : SimpleGraph V} {H : SimpleGraph W} + (e : G ≃g H) : G.map e.toEquiv.toEmbedding = H := by + ext a b + rw [SimpleGraph.map_adj] + constructor + · rintro ⟨v, w, hvw, rfl, rfl⟩ + exact e.toHom.map_adj hvw + · intro hab + exact ⟨e.symm a, e.symm b, e.symm.toHom.map_adj hab, + e.apply_symm_apply a, e.apply_symm_apply b⟩ + +/-- An isomorphism of incident-vertex graphs extends to a permutation of the +full ambient vertex set, hence to equality of the corresponding edge copies. -/ +theorem exists_smul_eq_of_edgeSupportGraph_iso {S T : Finset (Edge n)} + (e : edgeSupportGraph S ≃g edgeSupportGraph T) : + ∃ σ : Equiv.Perm (Fin n), σ • S = T := by + let f : (graphOfEdges S).support ↪ Fin n := Function.Embedding.subtype _ + let j : (graphOfEdges T).support ↪ Fin n := Function.Embedding.subtype _ + let g : (graphOfEdges S).support ↪ Fin n := e.toEquiv.toEmbedding.trans j + obtain ⟨σ, hσ⟩ := exists_perm_comp_embedding f g + have hfun : (fun v => σ (f v)) = (fun v => j (e v)) := funext hσ + have hm : ((edgeSupportGraph S).map f).map σ.toEmbedding = + (edgeSupportGraph T).map j := by + rw [SimpleGraph.map_map] + change (edgeSupportGraph S).map (fun v => σ (f v)) = _ + rw [hfun] + change (edgeSupportGraph S).map (j ∘ e.toEquiv.toEmbedding) = _ + rw [← SimpleGraph.map_map, map_eq_of_iso] + refine ⟨σ, (graphEdgeEquiv n).injective ?_⟩ + change graphOfEdges (σ • S) = graphOfEdges T + rw [graphOfEdges_smul] + simpa only [f, j, edgeSupportGraph_map] using hm + +theorem subgraph_eq_edgeSubgraph + (K : (⊤ : SimpleGraph (Fin n)).Subgraph) + (hK : ∀ v : K.verts, ∃ w, K.coe.Adj v w) : + K = edgeSubgraph (graphEdges K.spanningCoe) := by + apply SimpleGraph.Subgraph.ext + · change K.verts = (graphOfEdges (graphEdges K.spanningCoe)).support + rw [graphOfEdges_graphEdges] + ext v + constructor + · intro hv + obtain ⟨w, hw⟩ := hK ⟨v, hv⟩ + exact ⟨w, hw⟩ + · rintro ⟨w, hw⟩ + exact K.edge_vert hw + · change K.Adj = (graphOfEdges (graphEdges K.spanningCoe)).Adj + rw [graphOfEdges_graphEdges] + rfl + +theorem subgraph_eq_edgeSubgraph_of_iso {S : Finset (Edge n)} + (K : (⊤ : SimpleGraph (Fin n)).Subgraph) + (e : edgeSupportGraph S ≃g K.coe) : + K = edgeSubgraph (graphEdges K.spanningCoe) := by + apply subgraph_eq_edgeSubgraph K + intro v + obtain ⟨w, hw⟩ := edgeSupportGraph_noIsolates S (e.symm v) + refine ⟨e w, ?_⟩ + have hh : K.coe.Adj (e (e.symm v)) (e w) := e.toHom.map_adj hw + simpa only [e.apply_symm_apply] using hh + +theorem edgeCount_edgeSupportGraph (S : Finset (Edge n)) : + edgeCount (edgeSupportGraph S) = S.card := by + classical + have h := card_mappedGraphEdges + (Function.Embedding.subtype (fun v => v ∈ (graphOfEdges S).support)) + (edgeSupportGraph S) + simpa only [edgeSupportGraph_map, graphEdges_graphOfEdges] using h.symm + +/-- A selected edge subset of an embedded graph pulls back to an actual copy +inside the original graph, using only incident vertices of the selection. -/ +def edgeSupportGraph_copy_of_subset {V : Type*} (f : V ↪ Fin n) + (H : SimpleGraph V) (S : Finset (Edge n)) + (hS : S ⊆ graphEdges (H.map f)) : (edgeSupportGraph S).Copy H := by + have hle : graphOfEdges S ≤ H.map f := by + simpa only [graphOfEdges_graphEdges] using graphOfEdges_mono hS + have hrange (v : (graphOfEdges S).support) : ∃ a : V, f a = v.val := by + obtain ⟨w, hw⟩ := v.property + obtain ⟨a, b, hab, ha, hb⟩ := (SimpleGraph.map_adj f H v w).mp (hle hw) + exact ⟨a, ha⟩ + let g : (graphOfEdges S).support → V := fun v => Classical.choose (hrange v) + have hg (v : (graphOfEdges S).support) : f (g v) = v.val := + Classical.choose_spec (hrange v) + refine { toHom := ⟨g, ?_⟩, injective' := ?_ } + · intro v w hvw + apply (SimpleGraph.map_adj_apply (f := f)).mp + rw [hg v, hg w] + exact hle hvw + · intro v w hvw + change g v = g w at hvw + apply Subtype.ext + rw [← hg v, ← hg w, hvw] + +theorem exists_subgraph_iso_edgeSupportGraph {V : Type*} (f : V ↪ Fin n) + (H : SimpleGraph V) (S : Finset (Edge n)) + (hS : S ⊆ graphEdges (H.map f)) : + ∃ F : H.Subgraph, Nonempty (edgeSupportGraph S ≃g F.coe) := + SimpleGraph.isContained_iff_exists_iso_subgraph.mp + ⟨edgeSupportGraph_copy_of_subset f H S hS⟩ + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/LocalFailure.lean b/lean/OAI/Combinatorics/GraphThreshold/LocalFailure.lean new file mode 100644 index 0000000000000000000000000000000000000000..2239979db54b344f6b5e965ebd6c07d1fc8d1db2 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/LocalFailure.lean @@ -0,0 +1,338 @@ +import OAI.Combinatorics.GraphThreshold.LocalFailureNumerics +import OAI.Combinatorics.GraphThreshold.ResamplingEvents +import OAI.Combinatorics.GraphThreshold.SpreadCounting +import OAI.Combinatorics.GraphThreshold.FiniteProbability +import OAI.Combinatorics.GraphThreshold.ResamplingDensity + +namespace OAI + +/-! # Local failure of the actual resampling experiment -/ + +noncomputable section + +open Finset + +namespace LeanBlast.SecondKahnKalai + +variable {X B : Type*} [Fintype X] [DecidableEq X] [Fintype B] + +omit [Fintype X] [Fintype B] in +private theorem target_subset_iff_required_subset (A : B → Finset X) + (W : Finset X) (c b : B) : + A b ⊆ resamplingY A W c ↔ A b \ A c ⊆ W := by + constructor + · intro h x hx + rcases Finset.mem_union.mp (h (Finset.mem_sdiff.mp hx).1) with hW | hc + · exact hW + · exact ((Finset.mem_sdiff.mp hx).2 hc).elim + · intro h x hx + by_cases hc : x ∈ A c + · exact Finset.mem_union.mpr (Or.inr hc) + · exact Finset.mem_union.mpr (Or.inl (h (Finset.mem_sdiff.mpr ⟨hx, hc⟩))) + +omit [Fintype X] [Fintype B] in +private theorem fragment_subset_inter_of_target_subset (A : B → Finset X) + (W : Finset X) (c b : B) (h : A b ⊆ resamplingY A W c) : + A b \ W ⊆ A c ∩ A b := by + intro x hx + obtain ⟨hb, hW⟩ := Finset.mem_sdiff.mp hx + rcases Finset.mem_union.mp (h hb) with hxW | hc + · exact (hW hxW).elim + · exact Finset.mem_inter.mpr ⟨hc, hb⟩ + +omit [Fintype X] [Fintype B] in +private theorem inverse_power_card_cancel (A : B → Finset X) {ρ : ℝ} + (hρ : 0 < ρ) (c b : B) : + (ρ⁻¹) ^ (A b).card * ρ ^ (A b \ A c).card = + (ρ⁻¹) ^ (A c ∩ A b).card := by + have hc : (A b).card = (A b \ A c).card + (A c ∩ A b).card := by + simpa only [Finset.inter_comm] using (Finset.card_sdiff_add_card_inter (A b) (A c)).symm + rw [hc, pow_add] + calc + ((ρ⁻¹) ^ (A b \ A c).card * (ρ⁻¹) ^ (A c ∩ A b).card) * + ρ ^ (A b \ A c).card = + ((ρ⁻¹) ^ (A b \ A c).card * ρ ^ (A b \ A c).card) * + (ρ⁻¹) ^ (A c ∩ A b).card := by ring + _ = (ρ⁻¹) ^ (A c ∩ A b).card := by simp [inv_pow, hρ.ne'] + +omit [Fintype X] in +/-- At a large denominator, the actual large-fragment weight is bounded by +an intersection-tail indicator and the required-coordinate indicator. -/ +theorem resampling_large_fragment_term_le (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 < ρ) (m : ℕ) (W : Finset X) (c b : B) : + (if Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A ρ (resamplingY A W c) ∧ + m / 2 < (A b \ W).card then resamplingWeight ν A ρ W (c, b) else 0) ≤ + if m < 2 * (A c ∩ A b).card ∧ A b \ A c ⊆ W then + Real.exp (10 * (m : ℝ)) * ν.weight c * ν.weight b * (ρ⁻¹) ^ (A b).card + else 0 := by + classical + have hrhs : 0 ≤ + if m < 2 * (A c ∩ A b).card ∧ A b \ A c ⊆ W then + Real.exp (10 * (m : ℝ)) * ν.weight c * ν.weight b * (ρ⁻¹) ^ (A b).card + else 0 := by + split_ifs + · exact mul_nonneg (mul_nonneg (mul_nonneg (Real.exp_pos _).le (ν.nonneg c)) + (ν.nonneg b)) (pow_nonneg (inv_nonneg.mpr hρ.le) _) + · exact le_rfl + by_cases he : Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A ρ (resamplingY A W c) ∧ + m / 2 < (A b \ W).card + · rw [ite_eq_left he] + by_cases hs : A b ⊆ resamplingY A W c + · have hfrag := Finset.card_le_card (fragment_subset_inter_of_target_subset A W c b hs) + have hlarge : m < 2 * (A c ∩ A b).card := by omega + have hreq := (target_subset_iff_required_subset A W c b).mp hs + rw [ite_eq_left ⟨hlarge, hreq⟩] + have hZpos : 0 < resamplingZ ν A ρ (resamplingY A W c) := + (Real.exp_pos _).trans_le he.1 + have hscale : 1 ≤ Real.exp (10 * (m : ℝ)) * + resamplingZ ν A ρ (resamplingY A W c) := by + calc + 1 = Real.exp (10 * (m : ℝ)) * Real.exp (-10 * (m : ℝ)) := by + rw [← Real.exp_add]; simp + _ ≤ _ := mul_le_mul_of_nonneg_left he.1 (Real.exp_pos _).le + have hnum : 0 ≤ ν.weight b * (ρ⁻¹) ^ (A b).card := + mul_nonneg (ν.nonneg b) (pow_nonneg (inv_nonneg.mpr hρ.le) _) + have hdiv : (ν.weight b * (ρ⁻¹) ^ (A b).card) / + resamplingZ ν A ρ (resamplingY A W c) ≤ + Real.exp (10 * (m : ℝ)) * (ν.weight b * (ρ⁻¹) ^ (A b).card) := by + apply (div_le_iff₀ hZpos).mpr + nlinarith [mul_le_mul_of_nonneg_left hscale hnum] + unfold resamplingWeight resamplingTargetWeight + rw [resamplingNumerator, ite_eq_left hs] + calc + ν.weight c * ((ν.weight b * (ρ⁻¹) ^ (A b).card) / + resamplingZ ν A ρ (resamplingY A W c)) ≤ + ν.weight c * (Real.exp (10 * (m : ℝ)) * + (ν.weight b * (ρ⁻¹) ^ (A b).card)) := + mul_le_mul_of_nonneg_left hdiv (ν.nonneg c) + _ = _ := by ring + · rw [resamplingWeight_eq_zero_of_not_subset ν A ρ W c b hs] + exact hrhs + · rw [ite_eq_right he] + exact hrhs + +private theorem local_bernoulliExpectation_sum {ι : Type*} [Fintype ι] + (ρ : ℝ) (f : ι → Finset X → ℝ) : + bernoulliExpectation ρ (fun W => ∑ i, f i W) = + ∑ i, bernoulliExpectation ρ (f i) := by + simp only [bernoulliExpectation, Finset.mul_sum] + exact Finset.sum_comm + +theorem resampling_large_fragment_pair_bound (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 < ρ) (hρ1 : ρ < 1) (m : ℕ) (c b : B) : + bernoulliExpectation ρ (fun W => + if Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A ρ (resamplingY A W c) ∧ + m / 2 < (A b \ W).card then resamplingWeight ν A ρ W (c, b) else 0) ≤ + if m < 2 * (A c ∩ A b).card then + Real.exp (10 * (m : ℝ)) * ν.weight c * ν.weight b * (ρ⁻¹) ^ (A c ∩ A b).card + else 0 := by + classical + let μ : FiniteLaw (Finset X) := bernoulliLaw ρ hρ.le hρ1.le + by_cases hlarge : m < 2 * (A c ∩ A b).card + · rw [ite_eq_left hlarge] + calc + _ ≤ μ.expectation (fun W => + (Real.exp (10 * (m : ℝ)) * ν.weight c * ν.weight b * (ρ⁻¹) ^ (A b).card) * + (if A b \ A c ⊆ W then 1 else 0)) := by + apply μ.expectation_mono + intro W + simpa only [hlarge, true_and, mul_ite, mul_one, mul_zero] using + resampling_large_fragment_term_le ν A hρ m W c b + _ = (Real.exp (10 * (m : ℝ)) * ν.weight c * ν.weight b * (ρ⁻¹) ^ (A b).card) * + ρ ^ (A b \ A c).card := by + rw [FiniteLaw.expectation_smul] + congr 1 + change bernoulliExpectation ρ (fun W => if A b \ A c ⊆ W then 1 else 0) = _ + rw [← bernoulliProbability_subset ρ (A b \ A c)] + simp only [bernoulliExpectation, bernoulliProbability, mul_ite, mul_one, mul_zero] + apply Finset.sum_congr rfl + intro W _ + by_cases hW : A b \ A c ⊆ W <;> simp [hW] + _ = Real.exp (10 * (m : ℝ)) * ν.weight c * ν.weight b * + ((ρ⁻¹) ^ (A b).card * ρ ^ (A b \ A c).card) := by ring + _ = _ := by rw [inverse_power_card_cancel A hρ c b] + · rw [ite_eq_right hlarge] + calc + _ ≤ μ.expectation (fun _ => 0) := by + apply μ.expectation_mono + intro W + simpa only [hlarge, false_and, ite_false] using + resampling_large_fragment_term_le ν A hρ m W c b + _ = 0 := μ.expectation_const 0 + +theorem resampling_large_fragment_bound (ν : FiniteLaw B) (A : B → Finset X) + {ρ a : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ < 1) + (m : ℕ) (hsize : ∀ b, (A b).card ≤ m) (hspread : IsSpread ν A a) + (ha : 0 ≤ a) (hratio : a / ρ ≤ Real.exp (-50)) : + bernoulliExpectation ρ (fun W => (resamplingLaw ν A ρ W hν hρ).prob + (fun cb => Real.exp (-10 * (m : ℝ)) ≤ + resamplingZ ν A ρ (resamplingY A W cb.1) ∧ + m / 2 < (A cb.2 \ W).card)) ≤ + Real.exp (10 * (m : ℝ)) * (2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ)) := by + classical + have hpair (b : B) : + (∑ c, bernoulliExpectation ρ (fun W => + if Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A ρ (resamplingY A W c) ∧ + m / 2 < (A b \ W).card then resamplingWeight ν A ρ W (c, b) else 0)) ≤ + (Real.exp (10 * (m : ℝ)) * ν.weight b) * largeIntersectionTail m (a / ρ) := by + calc + _ ≤ ∑ c, if m < 2 * (A c ∩ A b).card then + Real.exp (10 * (m : ℝ)) * ν.weight c * ν.weight b * + (ρ⁻¹) ^ (A c ∩ A b).card else 0 := by + apply Finset.sum_le_sum + intro c _ + exact resampling_large_fragment_pair_bound ν A hρ hρ1 m c b + _ = (Real.exp (10 * (m : ℝ)) * ν.weight b) * + ∑ c, if m < 2 * (A c ∩ A b).card then + ν.weight c * (ρ⁻¹) ^ (A c ∩ A b).card else 0 := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro c _ + split_ifs <;> ring + _ ≤ _ := mul_le_mul_of_nonneg_left + (intersection_inverse_truncated_sum_le hspread ha (hsize b) hρ + (fun r => m < 2 * r)) + (mul_nonneg (Real.exp_pos _).le (ν.nonneg b)) + calc + _ = ∑ b, ∑ c, bernoulliExpectation ρ (fun W => + if Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A ρ (resamplingY A W c) ∧ + m / 2 < (A b \ W).card then resamplingWeight ν A ρ W (c, b) else 0) := by + simp only [FiniteLaw.prob, resamplingLaw_weight, Fintype.sum_prod_type] + conv_lhs => arg 2; ext W; rw [Finset.sum_comm] + rw [local_bernoulliExpectation_sum] + simp_rw [local_bernoulliExpectation_sum] + apply Finset.sum_congr rfl + intro target _ + apply Finset.sum_congr rfl + intro source _ + congr 1 + funext drawn + split_ifs <;> rfl + _ ≤ ∑ b, (Real.exp (10 * (m : ℝ)) * ν.weight b) * largeIntersectionTail m (a / ρ) := + Finset.sum_le_sum (fun b _ => hpair b) + _ = Real.exp (10 * (m : ℝ)) * largeIntersectionTail m (a / ρ) := by + calc + _ = (Real.exp (10 * (m : ℝ)) * largeIntersectionTail m (a / ρ)) * + ∑ b, ν.weight b := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro b _ + ring + _ = _ := by rw [ν.total, mul_one] + _ ≤ Real.exp (10 * (m : ℝ)) * ((2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ))) := + mul_le_mul_of_nonneg_left (largeIntersectionTail_le (div_nonneg ha hρ.le) hratio) + (Real.exp_pos _).le + _ = _ := by ring + +/-- The density identity bounds the probability of a small denominator by +the cutoff itself. -/ +theorem resampling_small_density_bound (ν : FiniteLaw B) (A : B → Finset X) + {ρ τ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ < 1) (hτ : 0 ≤ τ) : + bernoulliExpectation ρ (fun W => (resamplingLaw ν A ρ W hν hρ).prob + (fun cb => resamplingZ ν A ρ (resamplingY A W cb.1) < τ)) ≤ τ := by + classical + rw [resampling_density_prob ν A hν hρ (fun Y => resamplingZ ν A ρ Y < τ)] + let μ : FiniteLaw (Finset X) := bernoulliLaw ρ hρ.le hρ1.le + change μ.expectation _ ≤ τ + calc + _ ≤ μ.expectation (fun _ => τ) := by + apply μ.expectation_mono + intro Y + split_ifs with hY + · exact hY.le + · exact hτ + _ = τ := μ.expectation_const τ + +theorem local_failure_bound (ν : FiniteLaw B) (A : B → Finset X) + {ρ a : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ < 1) + (m : ℕ) (hm : 1 ≤ m) (hsize : ∀ b, (A b).card ≤ m) + (hspread : IsSpread ν A a) (ha : 0 ≤ a) (hratio : a / ρ ≤ Real.exp (-50)) : + bernoulliExpectation ρ (fun W => (resamplingLaw ν A ρ W hν hρ).prob + (fun cb => LocalFailure ν A ρ m W cb.1 cb.2)) ≤ Real.exp (-9 * (m : ℝ)) := by + classical + let μ : FiniteLaw (Finset X) := bernoulliLaw ρ hρ.le hρ1.le + let low (W : Finset X) (cb : B × B) : Prop := + resamplingZ ν A ρ (resamplingY A W cb.1) < Real.exp (-10 * (m : ℝ)) + let big (W : Finset X) (cb : B × B) : Prop := + Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A ρ (resamplingY A W cb.1) ∧ + m / 2 < (A cb.2 \ W).card + have hpoint (W : Finset X) : + (resamplingLaw ν A ρ W hν hρ).prob (fun cb => LocalFailure ν A ρ m W cb.1 cb.2) ≤ + (resamplingLaw ν A ρ W hν hρ).prob (low W) + + (resamplingLaw ν A ρ W hν hρ).prob (big W) := by + apply le_trans ((resamplingLaw ν A ρ W hν hρ).prob_mono (Q := fun cb => low W cb ∨ big W cb) ?_) + ((resamplingLaw ν A ρ W hν hρ).prob_union_le (low W) (big W)) + intro cb hcb + rcases (localFailure_iff ν A ρ m W cb.1 cb.2).mp hcb with hlow | hfrag + · exact Or.inl hlow + · by_cases hl : low W cb + · exact Or.inl hl + · exact Or.inr ⟨le_of_not_gt hl, hfrag⟩ + calc + _ ≤ μ.expectation (fun W => (resamplingLaw ν A ρ W hν hρ).prob (low W) + + (resamplingLaw ν A ρ W hν hρ).prob (big W)) := μ.expectation_mono hpoint + _ = μ.expectation (fun W => (resamplingLaw ν A ρ W hν hρ).prob (low W)) + + μ.expectation (fun W => (resamplingLaw ν A ρ W hν hρ).prob (big W)) := + μ.expectation_add _ _ + _ ≤ Real.exp (-10 * (m : ℝ)) + + Real.exp (10 * (m : ℝ)) * (2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ)) := + add_le_add (resampling_small_density_bound ν A hν hρ hρ1 (Real.exp_pos _).le) + (resampling_large_fragment_bound ν A hν hρ hρ1 m hsize hspread ha hratio) + _ ≤ Real.exp (-9 * (m : ℝ)) := local_failure_exponential_combine hm + +theorem local_failure_probability_bound (ν : FiniteLaw B) (A : B → Finset X) + {ρ a : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ < 1) + (m : ℕ) (hm : 1 ≤ m) (hsize : ∀ b, (A b).card ≤ m) + (hspread : IsSpread ν A a) (ha : 0 ≤ a) (hratio : a / ρ ≤ Real.exp (-50)) : + (resamplingExperimentLaw ν A ρ hν hρ hρ1.le).prob + (fun ω => LocalFailure ν A ρ m ω.1 ω.2.1 ω.2.2) ≤ Real.exp (-9 * (m : ℝ)) := by + classical + have heq : (resamplingExperimentLaw ν A ρ hν hρ hρ1.le).prob + (fun ω => LocalFailure ν A ρ m ω.1 ω.2.1 ω.2.2) = + bernoulliExpectation ρ (fun W => (resamplingLaw ν A ρ W hν hρ).prob + (fun cb => LocalFailure ν A ρ m W cb.1 cb.2)) := by + simp only [FiniteLaw.prob, resamplingExperimentLaw, Fintype.sum_prod_type, + bernoulliExpectation, resamplingLaw_weight, Finset.mul_sum] + apply Finset.sum_congr rfl + intro W _ + apply Finset.sum_congr rfl + intro c _ + apply Finset.sum_congr rfl + intro b _ + by_cases h : LocalFailure ν A ρ m W c b <;> simp [h] + rw [heq] + exact local_failure_bound ν A hν hρ hρ1 m hm hsize hspread ha hratio + +omit [Fintype X] in + +theorem localFailure_iff_real (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (m : ℕ) (W : Finset X) (c b : B) : + LocalFailure ν A ρ m W c b ↔ + resamplingZ ν A ρ (resamplingY A W c) < Real.exp (-10 * (m : ℝ)) ∨ + (m : ℝ) / 2 < ((A b \ W).card : ℝ) := by + rw [localFailure_iff_twice] + apply or_congr Iff.rfl + constructor + · intro h + have h' : (m : ℝ) < 2 * ((A b \ W).card : ℝ) := by exact_mod_cast h + linarith + · intro h + have h' : (m : ℝ) < 2 * ((A b \ W).card : ℝ) := by linarith + exact_mod_cast h' + +theorem local_failure_source_form (ν : FiniteLaw B) (A : B → Finset X) + {ρ a : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ < 1) + (m : ℕ) (hm : 1 ≤ m) (hsize : ∀ b, (A b).card ≤ m) + (hspread : IsSpread ν A a) (ha : 0 ≤ a) (hratio : a / ρ ≤ Real.exp (-50)) : + (resamplingExperimentLaw ν A ρ hν hρ hρ1.le).prob + (fun ω => resamplingZ ν A ρ (resamplingY A ω.1 ω.2.1) < + Real.exp (-10 * (m : ℝ)) ∨ + (m : ℝ) / 2 < ((A ω.2.2 \ ω.1).card : ℝ)) ≤ Real.exp (-9 * (m : ℝ)) := by + simpa only [localFailure_iff_real] using + local_failure_probability_bound ν A hν hρ hρ1 m hm hsize hspread ha hratio + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/LocalFailureNumerics.lean b/lean/OAI/Combinatorics/GraphThreshold/LocalFailureNumerics.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcaa233a2446cf407ef7f1a76284693fb76773f4 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/LocalFailureNumerics.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import Mathlib.Analysis.Complex.ExponentialBounds +import Mathlib.Data.Nat.Choose.Sum +import Mathlib.Tactic + +namespace OAI + +noncomputable section + +open Finset + +namespace LeanBlast.SecondKahnKalai + +theorem two_lt_exp_one : (2 : ℝ) < Real.exp 1 := Real.exp_one_gt_two + +theorem exp_one_lt_three : Real.exp 1 < (3 : ℝ) := Real.exp_one_lt_three + +/-- The strict numerical estimate used to rule out large maximizing +predecessors in the graph hierarchy. -/ +theorem predecessor_power_lt_one {r : ℕ} (hr : 1 ≤ r) : + 2 * (17 * Real.exp 1 / 128) ^ r < 1 := by + have hbase0 : 0 ≤ 17 * Real.exp 1 / 128 := by positivity + have hbase : 17 * Real.exp 1 / 128 < (1 / 2 : ℝ) := by + nlinarith [exp_one_lt_three] + have hp : (17 * Real.exp 1 / 128) ^ r ≤ 17 * Real.exp 1 / 128 := + pow_le_of_le_one hbase0 (by linarith) (by omega) + linarith + +theorem exp_neg_fifty_lt_one : Real.exp (-50) < 1 := by + exact Real.exp_lt_one_iff.mpr (by norm_num) + +theorem one_add_le_exp_one_of_le_exp_neg_fifty {q : ℝ} + (hq : q ≤ Real.exp (-50)) : 1 + q ≤ Real.exp 1 := by + linarith [exp_neg_fifty_lt_one, two_lt_exp_one] + +theorem one_add_pow_le_exp_nat {q : ℝ} (hq0 : 0 ≤ q) + (hq : q ≤ Real.exp (-50)) (m : ℕ) : + (1 + q) ^ m ≤ Real.exp (m : ℝ) := by + calc + (1 + q) ^ m ≤ Real.exp 1 ^ m := + pow_le_pow_left₀ (by positivity) (one_add_le_exp_one_of_le_exp_neg_fifty hq) m + _ = Real.exp (m : ℝ) := by rw [← Real.exp_nat_mul]; simp + +theorem two_pow_le_exp_nat (m : ℕ) : (2 : ℝ) ^ m ≤ Real.exp (m : ℝ) := by + calc + (2 : ℝ) ^ m ≤ Real.exp 1 ^ m := pow_le_pow_left₀ (by norm_num) two_lt_exp_one.le m + _ = Real.exp (m : ℝ) := by rw [← Real.exp_nat_mul]; simp + +/-- A term beyond half the capacity has the required exponential decay. -/ +theorem large_intersection_power_le {m r : ℕ} {q : ℝ} + (hq0 : 0 ≤ q) (hq : q ≤ Real.exp (-50)) (hr : m < 2 * r) : + q ^ r ≤ Real.exp (-25 * (m : ℝ)) := by + have hr' : (m : ℝ) < 2 * (r : ℝ) := by exact_mod_cast hr + calc + q ^ r ≤ Real.exp (-50) ^ r := pow_le_pow_left₀ hq0 hq r + _ = Real.exp ((r : ℝ) * (-50)) := (Real.exp_nat_mul _ _).symm + _ ≤ Real.exp (-25 * (m : ℝ)) := Real.exp_le_exp.mpr (by linarith) + +/-- The finite binomial upper tail used by the resampling argument. -/ +def largeIntersectionTail (m : ℕ) (q : ℝ) : ℝ := + ∑ r ∈ range (m + 1), if m < 2 * r then (m.choose r : ℝ) * q ^ r else 0 + +theorem largeIntersectionTail_le {m : ℕ} {q : ℝ} + (hq0 : 0 ≤ q) (hq : q ≤ Real.exp (-50)) : + largeIntersectionTail m q ≤ (2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ)) := by + have hsum : (∑ r ∈ range (m + 1), (m.choose r : ℝ)) = (2 : ℝ) ^ m := by + exact_mod_cast Nat.sum_range_choose m + unfold largeIntersectionTail + calc + (∑ r ∈ range (m + 1), if m < 2 * r then (m.choose r : ℝ) * q ^ r else 0) ≤ + ∑ r ∈ range (m + 1), (m.choose r : ℝ) * Real.exp (-25 * (m : ℝ)) := by + apply sum_le_sum + intro r hr + split_ifs with h + · exact mul_le_mul_of_nonneg_left (large_intersection_power_le hq0 hq h) (by positivity) + · positivity + _ = (2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ)) := by rw [← sum_mul, hsum] + +theorem local_failure_exponential_combine {m : ℕ} (hm : 1 ≤ m) : + Real.exp (-10 * (m : ℝ)) + + Real.exp (10 * (m : ℝ)) * (2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ)) ≤ + Real.exp (-9 * (m : ℝ)) := by + have hm0 : 0 ≤ (m : ℝ) := Nat.cast_nonneg m + have hm1 : 1 ≤ (m : ℝ) := by exact_mod_cast hm + have hterm : Real.exp (10 * (m : ℝ)) * (2 : ℝ) ^ m * + Real.exp (-25 * (m : ℝ)) ≤ Real.exp (-10 * (m : ℝ)) := by + calc + Real.exp (10 * (m : ℝ)) * (2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ)) ≤ + Real.exp (10 * (m : ℝ)) * Real.exp (m : ℝ) * Real.exp (-25 * (m : ℝ)) := by + gcongr + exact two_pow_le_exp_nat m + _ = Real.exp (-14 * (m : ℝ)) := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + _ ≤ Real.exp (-10 * (m : ℝ)) := Real.exp_le_exp.mpr (by linarith) + have htwo : (2 : ℝ) ≤ Real.exp (m : ℝ) := + two_lt_exp_one.le.trans (Real.exp_le_exp.mpr hm1) + calc + Real.exp (-10 * (m : ℝ)) + + Real.exp (10 * (m : ℝ)) * (2 : ℝ) ^ m * Real.exp (-25 * (m : ℝ)) ≤ + 2 * Real.exp (-10 * (m : ℝ)) := by linarith + _ ≤ Real.exp (m : ℝ) * Real.exp (-10 * (m : ℝ)) := by gcongr + _ = Real.exp (-9 * (m : ℝ)) := by rw [← Real.exp_add]; congr 1; ring + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/Main.lean b/lean/OAI/Combinatorics/GraphThreshold/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..26bf6dd13ddb7dc4a51df75d547d027c11cffefb --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/Main.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.GraphThreshold.ThresholdBounds +import OAI.Combinatorics.GraphThreshold.GraphCopies +import OAI.Combinatorics.GraphThreshold.GraphHierarchy +import OAI.Combinatorics.GraphThreshold.BernoulliMonotonicity +import OAI.Combinatorics.GraphThreshold.TreeCovering + +namespace OAI + +/-! +# The second Kahn–Kalai graph-threshold bounds + +The graph-to-orbit bridge counts actual unlabelled subgraphs. The hierarchy is +constructed from the constraints at the attained expectation threshold, and +covering one of its paths yields a copy of the original graph. +-/ + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +universe u + +def FullStatement : Prop := SecondKahnKalaiStatement.{u} + +theorem secondKahnKalaiBounds (n : ℕ) (V : Type u) [Fintype V] + (H : SimpleGraph V) (hn : 2 ≤ n) (hcard : Fintype.card V ≤ n) + (hedge : 1 ≤ edgeCount H) : SecondKahnKalaiBounds n H := by + classical + let q := expectationThreshold n H + have hq : 0 < q := expectationThreshold_pos n H hcard hedge + obtain ⟨E, hEcard, hEevent, hEconstraint⟩ := + exists_graphRepresentationWithConstraints n H hcard q + (expectationThreshold_attained n H hcard).2 + have hEnonempty : E.Nonempty := Finset.card_pos.mp (by omega) + obtain ⟨k, m, T, hk, hdisjoint, hcapacity, hspread, hpositive, hgrowth, hlast, hpath⟩ := + exists_spread_orbit_tree (Equiv.Perm (Fin n)) E q hq hEnonempty + (fun S hS _ => hEconstraint S hS) + have hm : 0 < m (k - 1) := hpositive (k - 1) (by omega) + have hmh : m (k - 1) ≤ edgeCount H := by omega + let p := min 1 (2048 * Real.exp 50 * q * (1 + logTwo (edgeCount H : ℝ))) + let pTree := min 1 (16 * Real.exp 50 * (128 * q) * + (1 + Real.logb 2 (m (k - 1) : ℝ))) + have hp : p ∈ Set.Icc 0 1 := graphThresholdParameter_mem_unitInterval q _ hq.le hedge + have hpTree : pTree ∈ Set.Icc 0 1 := treeSamplingParameter_mem_unitInterval q _ hq.le hm + have hpTree_le : pTree ≤ p := + treeSamplingParameter_le_graphParameter q _ _ hq.le hm hmh + have hcovered : (2 / 3 : ℝ) ≤ bernoulliProbability pTree T.CoveredBy := + tree_covering T hk hdisjoint m hcapacity hpositive hgrowth (128 * q) + (by positivity) hspread + have hincrease : bernoulliProbability pTree T.CoveredBy ≤ + bernoulliProbability p T.CoveredBy := by + apply bernoulliProbability_mono_parameter hpTree.1 hpTree_le hp.2 T.CoveredBy + rintro W W' hWW' ⟨path, hpathW⟩ + exact ⟨path, hpathW.trans hWW'⟩ + have hevent : bernoulliProbability p T.CoveredBy ≤ containmentProbability n p H := by + change (bernoulliLaw p hp.1 hp.2).prob T.CoveredBy ≤ + (bernoulliLaw p hp.1 hp.2).prob (fun W => 0 < (graphOfEdges W).copyCount H) + apply FiniteLaw.prob_mono + rintro W ⟨path, hpathW⟩ + exact (hEevent W).mpr ⟨T.pathUnion path, hpath path, hpathW⟩ + have hpc : criticalThreshold n H ≤ p := by + apply criticalThreshold_le_of_probability n H hp + exact (by norm_num : (1 / 2 : ℝ) ≤ 2 / 3).trans + (hcovered.trans (hincrease.trans hevent)) + exact ⟨hpc, hpc.trans (graphThresholdParameter_le_vertexBound n H q hn hcard hedge hq.le)⟩ + +theorem secondKahnKalai : FullStatement.{u} := by + intro n V inst H hn hcard hedge + exact secondKahnKalaiBounds n V H hn hcard hedge + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/Model.lean b/lean/OAI/Combinatorics/GraphThreshold/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..45af91bda56e423d36a0940356c870f6895cd970 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/Model.lean @@ -0,0 +1,69 @@ +import Mathlib.Data.Fintype.Powerset +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Combinatorics.SimpleGraph.Copy +import Mathlib.Analysis.SpecialFunctions.Log.Basic + +namespace OAI + +noncomputable section + +universe u + +namespace LeanBlast.SecondKahnKalai + +def bernoulliWeight {X : Type u} [Fintype X] [DecidableEq X] + (p : ℝ) (W : Finset X) : ℝ := + ∏ x, if x ∈ W then p else 1 - p + +def bernoulliExpectation {X : Type u} [Fintype X] [DecidableEq X] + (p : ℝ) (f : Finset X → ℝ) : ℝ := + ∑ W, bernoulliWeight p W * f W + +def bernoulliProbability {X : Type u} [Fintype X] [DecidableEq X] + (p : ℝ) (P : Finset X → Prop) : ℝ := by + classical + exact ∑ W, if P W then bernoulliWeight p W else 0 + +/-- The unordered non-loop edges of the complete graph on `n` vertices. -/ +abbrev Edge (n : ℕ) := {e : Sym2 (Fin n) // ¬e.IsDiag} + +/-- A set of edges, interpreted as an ordinary graph on all `n` vertices. -/ +def graphOfEdges {n : ℕ} (W : Finset (Edge n)) : SimpleGraph (Fin n) := + SimpleGraph.fromEdgeSet (Subtype.val '' (W : Set (Edge n))) + +/-- The number of unordered edges, each counted once. -/ +def edgeCount {V : Type u} (H : SimpleGraph V) : ℕ := Nat.card H.edgeSet + +/-- Expected number of actual unlabelled non-induced copies in `G(n,p)`. -/ +def expectedCopies {V : Type u} (n : ℕ) (p : ℝ) (H : SimpleGraph V) : ℝ := + bernoulliExpectation p (fun W : Finset (Edge n) => + ((graphOfEdges W).copyCount H : ℝ)) + +/-- Probability that `G(n,p)` contains at least one non-induced copy. -/ +def containmentProbability {V : Type u} (n : ℕ) (p : ℝ) + (H : SimpleGraph V) : ℝ := + bernoulliProbability p (fun W : Finset (Edge n) => + 0 < (graphOfEdges W).copyCount H) + +def criticalThreshold {V : Type u} (n : ℕ) (H : SimpleGraph V) : ℝ := + sInf {p : ℝ | p ∈ Set.Icc 0 1 ∧ (1 / 2 : ℝ) ≤ containmentProbability n p H} + +def expectationThreshold {V : Type u} (n : ℕ) (H : SimpleGraph V) : ℝ := + sInf {p : ℝ | p ∈ Set.Icc 0 1 ∧ + ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n p F.coe} + +def logTwo (x : ℝ) : ℝ := Real.log x / Real.log 2 + +def SecondKahnKalaiBounds {V : Type u} (n : ℕ) (H : SimpleGraph V) : Prop := + criticalThreshold n H ≤ + min 1 (2048 * Real.exp 50 * expectationThreshold n H * + (1 + logTwo (edgeCount H : ℝ))) ∧ + criticalThreshold n H ≤ + 6144 * Real.exp 50 * expectationThreshold n H * logTwo (n : ℝ) + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/OutsideChangeOfMeasure.lean b/lean/OAI/Combinatorics/GraphThreshold/OutsideChangeOfMeasure.lean new file mode 100644 index 0000000000000000000000000000000000000000..99e7cfaecd274608a1ec1b0d4160b2365790a90d --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/OutsideChangeOfMeasure.lean @@ -0,0 +1,282 @@ +import OAI.Combinatorics.GraphThreshold.BernoulliCoupling +import OAI.Combinatorics.GraphThreshold.Resampling +import OAI.Combinatorics.GraphThreshold.ProbabilityTree +import OAI.Combinatorics.GraphThreshold.SpreadCounting +import OAI.Combinatorics.GraphThreshold.LocalFailureNumerics +import Mathlib.Tactic + +namespace OAI + +/-! +# Outside-coordinate change of measure for the actual resampling transition + +The observable may depend on the same Bernoulli set used at every other tree +node. The only locality required here is that it ignores the fixed target's +incoming label. No independence between different tree nodes is assumed. +-/ + +noncomputable section + +open scoped BigOperators +attribute [local instance] Classical.propDecidable + +namespace LeanBlast.SecondKahnKalai + +variable {X B : Type*} [DecidableEq X] [Fintype B] + +/-- Actual target marginal restricted to the event that the density is at least `δ`. -/ +def cutoffTargetMass (ν : FiniteLaw B) (A : B → Finset X) (p δ : ℝ) + (W : Finset X) (b : B) : ℝ := + ∑ c, if δ ≤ resamplingZ ν A p (resamplingY A W c) + then resamplingWeight ν A p W (c, b) else 0 + +theorem cutoffTargetMass_nonneg (ν : FiniteLaw B) (A : B → Finset X) + {p : ℝ} (hp : 0 ≤ p) (δ : ℝ) (W : Finset X) (b : B) : + 0 ≤ cutoffTargetMass ν A p δ W b := by + unfold cutoffTargetMass + apply Finset.sum_nonneg + intro c _ + split_ifs + · exact resamplingWeight_nonneg ν A hp W (c, b) + · exact le_rfl + +/-- This marginal is the literal conditional expectation of the target-and-density event. -/ +theorem cutoffTargetMass_mul_eq_expectation (ν : FiniteLaw B) (A : B → Finset X) + {p : ℝ} (hν : ν.IsPositive) (hp : 0 < p) (δ : ℝ) + (W : Finset X) (b : B) (f : Finset X → ℝ) : + cutoffTargetMass ν A p δ W b * f W = + (resamplingLaw ν A p W hν hp).expectation + (fun cb => if cb.2 = b ∧ δ ≤ resamplingZ ν A p (resamplingY A W cb.1) + then f W else 0) := by + classical + simp only [cutoffTargetMass, FiniteLaw.expectation, resamplingLaw_weight, + Fintype.sum_prod_type, Finset.sum_mul] + apply Finset.sum_congr rfl + intro c _ + by_cases hc : δ ≤ resamplingZ ν A p (resamplingY A W c) + · simp [hc, mul_ite] + · simp [hc] + +theorem subset_union_iff_sdiff_subset (S T W : Finset X) : + S ⊆ W ∪ T ↔ S \ T ⊆ W := by + constructor + · intro h x hx + obtain ⟨hxS, hxT⟩ := Finset.mem_sdiff.mp hx + exact (Finset.mem_union.mp (h hxS)).resolve_right hxT + · intro h x hxS + by_cases hxT : x ∈ T + · exact Finset.mem_union.mpr (Or.inr hxT) + · exact Finset.mem_union.mpr (Or.inl (h (Finset.mem_sdiff.mpr ⟨hxS, hxT⟩))) + +/-- Modifying only coordinates inside the ignored label leaves the observable unchanged. -/ +theorem dependsOutside_union {β : Type*} (A S : Finset X) (f : Finset X → β) + (hf : DependsOutside A f) (hSA : S ⊆ A) (W : Finset X) : + f (W ∪ S) = f W := by + apply hf + ext x + simp only [Finset.mem_sdiff, Finset.mem_union] + constructor + · rintro ⟨hx | hx, hn⟩ + · exact ⟨hx, hn⟩ + · exact (hn (hSA hx)).elim + · rintro ⟨hx, hn⟩ + exact ⟨Or.inl hx, hn⟩ + +theorem inv_pow_card_mul_pow_sdiff (p : ℝ) (hp : p ≠ 0) (S T : Finset X) : + (p⁻¹) ^ S.card * p ^ (S \ T).card = (p⁻¹) ^ (T ∩ S).card := by + have hc : (S \ T).card + (T ∩ S).card = S.card := by + simpa only [Finset.inter_comm] using Finset.card_sdiff_add_card_inter S T + rw [← hc, pow_add] + calc + (p⁻¹) ^ (S \ T).card * (p⁻¹) ^ (T ∩ S).card * p ^ (S \ T).card = + ((p⁻¹) ^ (S \ T).card * p ^ (S \ T).card) * (p⁻¹) ^ (T ∩ S).card := by ring + _ = (p⁻¹) ^ (T ∩ S).card := by rw [← mul_pow, inv_mul_cancel₀ hp, one_pow, one_mul] + +/-- The only pointwise change of density is the reciprocal cutoff. +The remaining event uses coordinates inside the fixed target label. -/ +theorem cutoff_source_weight_le (ν : FiniteLaw B) (A : B → Finset X) + {p δ : ℝ} (hp : 0 ≤ p) (hδ : 0 < δ) (W : Finset X) (c b : B) : + (if δ ≤ resamplingZ ν A p (resamplingY A W c) + then resamplingWeight ν A p W (c, b) else 0) ≤ + if A b \ A c ⊆ W then δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A b).card + else 0 := by + have hnum : 0 ≤ ν.weight b * (p⁻¹) ^ (A b).card := + mul_nonneg (ν.nonneg b) (pow_nonneg (inv_nonneg.mpr hp) _) + by_cases he : A b \ A c ⊆ W + · have he' : A b ⊆ resamplingY A W c := + (subset_union_iff_sdiff_subset (A b) (A c) W).mpr he + rw [ite_eq_left he] + by_cases hz : δ ≤ resamplingZ ν A p (resamplingY A W c) + · rw [ite_eq_left hz] + simp only [resamplingWeight, resamplingTargetWeight, resamplingNumerator, ite_eq_left he'] + calc + ν.weight c * (ν.weight b * (p⁻¹) ^ (A b).card / + resamplingZ ν A p (resamplingY A W c)) ≤ + ν.weight c * (ν.weight b * (p⁻¹) ^ (A b).card / δ) := + mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_left hnum hδ hz) (ν.nonneg c) + _ = _ := by ring + · rw [ite_eq_right hz] + exact mul_nonneg (mul_nonneg (mul_nonneg (inv_nonneg.mpr hδ.le) (ν.nonneg c)) + (ν.nonneg b)) (pow_nonneg (inv_nonneg.mpr hp) _) + · have he' : ¬ A b ⊆ resamplingY A W c := + fun h => he ((subset_union_iff_sdiff_subset (A b) (A c) W).mp h) + simp [he, resamplingWeight, resamplingTargetWeight, resamplingNumerator, he'] + +variable [Fintype X] + +/-- A containment event on ignored coordinates is independent of the observable. +This is derived from the fixed-union formula for the actual Bernoulli product weights. -/ +theorem bernoulli_subset_expectation_of_dependsOutside + {p : ℝ} (hp : p ≠ 0) (A S : Finset X) (f : Finset X → ℝ) + (hf : DependsOutside A f) (hSA : S ⊆ A) : + bernoulliExpectation p (fun W => if S ⊆ W then f W else 0) = + p ^ S.card * bernoulliExpectation p f := by + have hu : bernoulliExpectation p (fun W => f (W ∪ S)) = + bernoulliExpectation p f := by + congr 1 + funext W + exact dependsOutside_union A S f hf hSA W + have hd : bernoulliExpectation p (fun W => if S ⊆ W then f W / p ^ S.card else 0) = + bernoulliExpectation p (fun W => if S ⊆ W then f W else 0) / p ^ S.card := by + unfold bernoulliExpectation + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro W _ + by_cases hW : S ⊆ W <;> simp [hW, mul_div_assoc] + have h := bernoulliExpectation_union_fixed (p := p) hp S f + rw [hu, hd] at h + have he := (eq_div_iff (pow_ne_zero _ hp)).mp h + simpa only [mul_comm] using he.symm + +/-- Change of measure before applying spread: the exact loss is the intersection moment. -/ +theorem outside_change_of_measure_moment (ν : FiniteLaw B) (A : B → Finset X) + {p δ : ℝ} (hp : 0 < p) (hp1 : p ≤ 1) (hδ : 0 < δ) + (b : B) (f : Finset X → ℝ) (hf : ∀ W, 0 ≤ f W) + (hloc : DependsOutside (A b) f) : + bernoulliExpectation p (fun W => cutoffTargetMass ν A p δ W b * f W) ≤ + δ⁻¹ * ν.weight b * bernoulliExpectation p f * + ν.expectation (fun c => (p⁻¹) ^ (A c ∩ A b).card) := by + let μ := bernoulliLaw (X := X) p hp.le hp1 + change μ.expectation (fun W => cutoffTargetMass ν A p δ W b * f W) ≤ + δ⁻¹ * ν.weight b * μ.expectation f * + ν.expectation (fun c => (p⁻¹) ^ (A c ∩ A b).card) + calc + μ.expectation (fun W => cutoffTargetMass ν A p δ W b * f W) ≤ + μ.expectation (fun W => ∑ c, + (if A b \ A c ⊆ W then δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A b).card + else 0) * f W) := by + apply μ.expectation_mono + intro W + unfold cutoffTargetMass + rw [Finset.sum_mul] + exact Finset.sum_le_sum fun c _ => + mul_le_mul_of_nonneg_right (cutoff_source_weight_le ν A hp.le hδ W c b) (hf W) + _ = ∑ c, μ.expectation (fun W => + (if A b \ A c ⊆ W then δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A b).card + else 0) * f W) := μ.expectation_sum _ + _ = ∑ c, δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A c ∩ A b).card * + μ.expectation f := by + apply Finset.sum_congr rfl + intro c _ + have hi : μ.expectation (fun W => if A b \ A c ⊆ W then f W else 0) = + p ^ (A b \ A c).card * μ.expectation f := + bernoulli_subset_expectation_of_dependsOutside hp.ne' (A b) (A b \ A c) f + hloc Finset.sdiff_subset + have he : μ.expectation (fun W => + (if A b \ A c ⊆ W then δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A b).card + else 0) * f W) = + (δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A b).card) * + μ.expectation (fun W => if A b \ A c ⊆ W then f W else 0) := by + rw [← μ.expectation_smul] + congr 1 + funext W + split_ifs <;> simp + rw [he, hi] + calc + δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A b).card * + (p ^ (A b \ A c).card * μ.expectation f) = + δ⁻¹ * ν.weight c * ν.weight b * + ((p⁻¹) ^ (A b).card * p ^ (A b \ A c).card) * μ.expectation f := by ring + _ = _ := by rw [inv_pow_card_mul_pow_sdiff p hp.ne'] + _ = δ⁻¹ * ν.weight b * μ.expectation f * + ν.expectation (fun c => (p⁻¹) ^ (A c ∩ A b).card) := by + change (∑ c, δ⁻¹ * ν.weight c * ν.weight b * (p⁻¹) ^ (A c ∩ A b).card * + μ.expectation f) = + (δ⁻¹ * ν.weight b * μ.expectation f) * + (∑ c, ν.weight c * (p⁻¹) ^ (A c ∩ A b).card) + conv_rhs => rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro c _ + ring + +theorem outside_change_of_measure (ν : FiniteLaw B) (A : B → Finset X) + {p a : ℝ} (hp : 0 < p) (hp1 : p ≤ 1) (ha : 0 ≤ a) + (hs : IsSpread ν A a) (m : ℕ) (b : B) (hAb : (A b).card ≤ m) + (hsmall : a / p ≤ Real.exp (-50)) + (f : Finset X → ℝ) (hf : ∀ W, 0 ≤ f W) (hloc : DependsOutside (A b) f) : + bernoulliExpectation p (fun W => + cutoffTargetMass ν A p (Real.exp (-10 * (m : ℝ))) W b * f W) ≤ + Real.exp (11 * (m : ℝ)) * ν.weight b * bernoulliExpectation p f := by + have hEf : 0 ≤ bernoulliExpectation p f := + (bernoulliLaw (X := X) p hp.le hp1).expectation_nonneg hf + have hmoment : ν.expectation (fun c => (p⁻¹) ^ (A c ∩ A b).card) ≤ + Real.exp (m : ℝ) := + (intersection_inverse_moment_le hs ha hAb hp).trans + (one_add_pow_le_exp_nat (div_nonneg ha hp.le) hsmall m) + have hcoef : 0 ≤ (Real.exp (-10 * (m : ℝ)))⁻¹ * ν.weight b * + bernoulliExpectation p f := + mul_nonneg (mul_nonneg (inv_nonneg.mpr (Real.exp_pos _).le) (ν.nonneg b)) hEf + have he : (Real.exp (-10 * (m : ℝ)))⁻¹ * Real.exp (m : ℝ) = + Real.exp (11 * (m : ℝ)) := by + rw [← Real.exp_neg, ← Real.exp_add] + congr 1 + ring + calc + bernoulliExpectation p (fun W => + cutoffTargetMass ν A p (Real.exp (-10 * (m : ℝ))) W b * f W) ≤ + (Real.exp (-10 * (m : ℝ)))⁻¹ * ν.weight b * bernoulliExpectation p f * + ν.expectation (fun c => (p⁻¹) ^ (A c ∩ A b).card) := + outside_change_of_measure_moment ν A hp hp1 (Real.exp_pos _) b f hf hloc + _ ≤ (Real.exp (-10 * (m : ℝ)))⁻¹ * ν.weight b * bernoulliExpectation p f * + Real.exp (m : ℝ) := mul_le_mul_of_nonneg_left hmoment hcoef + _ = ((Real.exp (-10 * (m : ℝ)))⁻¹ * Real.exp (m : ℝ)) * ν.weight b * + bernoulliExpectation p f := by ring + _ = _ := by rw [he] + +/-- Any smaller target mass, including local non-failure, obeys the same bound. -/ +theorem outside_change_of_measure_of_le (ν : FiniteLaw B) (A : B → Finset X) + {p a : ℝ} (hp : 0 < p) (hp1 : p ≤ 1) (ha : 0 ≤ a) + (hs : IsSpread ν A a) (m : ℕ) (b : B) (hAb : (A b).card ≤ m) + (hsmall : a / p ≤ Real.exp (-50)) + (f : Finset X → ℝ) (hf : ∀ W, 0 ≤ f W) (hloc : DependsOutside (A b) f) + (t : Finset X → ℝ) + (ht : ∀ W, t W ≤ cutoffTargetMass ν A p (Real.exp (-10 * (m : ℝ))) W b) : + bernoulliExpectation p (fun W => t W * f W) ≤ + Real.exp (11 * (m : ℝ)) * ν.weight b * bernoulliExpectation p f := by + have hm : bernoulliExpectation p (fun W => t W * f W) ≤ + bernoulliExpectation p (fun W => + cutoffTargetMass ν A p (Real.exp (-10 * (m : ℝ))) W b * f W) := + (bernoulliLaw (X := X) p hp.le hp1).expectation_mono + (fun W => mul_le_mul_of_nonneg_right (ht W) (hf W)) + exact hm.trans (outside_change_of_measure ν A hp hp1 ha hs m b hAb hsmall f hf hloc) + +/-- The same inequality stated as the expectation of the actual transition event. -/ +theorem outside_change_of_measure_law (ν : FiniteLaw B) (A : B → Finset X) + (hν : ν.IsPositive) {p a : ℝ} (hp : 0 < p) (hp1 : p ≤ 1) (ha : 0 ≤ a) + (hs : IsSpread ν A a) (m : ℕ) (b : B) (hAb : (A b).card ≤ m) + (hsmall : a / p ≤ Real.exp (-50)) + (f : Finset X → ℝ) (hf : ∀ W, 0 ≤ f W) (hloc : DependsOutside (A b) f) : + bernoulliExpectation p (fun W => + (resamplingLaw ν A p W hν hp).expectation + (fun cb => if cb.2 = b ∧ Real.exp (-10 * (m : ℝ)) ≤ + resamplingZ ν A p (resamplingY A W cb.1) then f W else 0)) ≤ + Real.exp (11 * (m : ℝ)) * ν.weight b * bernoulliExpectation p f := by + classical + simp_rw [← cutoffTargetMass_mul_eq_expectation ν A hν hp _ _ b f] + exact outside_change_of_measure ν A hp hp1 ha hs m b hAb hsmall f hf hloc + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/Predecessor.lean b/lean/OAI/Combinatorics/GraphThreshold/Predecessor.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f61c955acb44aafeef6450d7ab39ff9a42c6f81 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/Predecessor.lean @@ -0,0 +1,218 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import OAI.Combinatorics.GraphThreshold.LocalFailureNumerics +import OAI.Combinatorics.GraphThreshold.CopyOrbits +import Mathlib.Data.Nat.Choose.Bounds +import Mathlib.Data.Finset.Max +import Mathlib.Analysis.Complex.ExponentialBounds +import Mathlib.Tactic + +namespace OAI + +/-! +# Maximizing predecessors + +The predecessor is chosen by maximization over the actual finite powerset, +including its empty member. The graph application uses distinct group-orbit +copies and the actual containment probability, not labeled embeddings. +-/ + +noncomputable section + +open scoped BigOperators + +namespace LeanBlast.SecondKahnKalai + +/-- The standard real binomial upper bound, derived directly from the +exponential series and the factorial upper bound on `choose`. -/ +theorem choose_le_exp_div_pow (h r : ℕ) (hr : 0 < r) : + (h.choose r : ℝ) ≤ (Real.exp 1 * (h : ℝ) / (r : ℝ)) ^ r := by + have hr0 : 0 < (r : ℝ) := by exact_mod_cast hr + have hrne : (r : ℝ) ≠ 0 := ne_of_gt hr0 + have hfac : (r.factorial : ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero r + have hexp : (r : ℝ) ^ r / (r.factorial : ℝ) ≤ Real.exp 1 ^ r := by + simpa only [← Real.exp_nat_mul, mul_one] using + Real.pow_div_factorial_le_exp (r : ℝ) (show 0 ≤ (r : ℝ) by positivity) r + calc + (h.choose r : ℝ) ≤ (h : ℝ) ^ r / (r.factorial : ℝ) := Nat.choose_le_pow_div r h + _ = ((h : ℝ) / (r : ℝ)) ^ r * ((r : ℝ) ^ r / (r.factorial : ℝ)) := by + rw [div_pow] + field_simp + _ ≤ ((h : ℝ) / (r : ℝ)) ^ r * Real.exp 1 ^ r := + mul_le_mul_of_nonneg_left hexp (by positivity) + _ = (Real.exp 1 * (h : ℝ) / (r : ℝ)) ^ r := by + rw [← mul_pow] + congr 1 + ring + +theorem two_choose_div_le_predecessor_power (h r : ℕ) (hr : 0 < r) + (hhr : h ≤ 17 * r) : + 2 * (h.choose r : ℝ) / (128 : ℝ) ^ r ≤ + 2 * (17 * Real.exp 1 / 128) ^ r := by + have hr0 : 0 < (r : ℝ) := by exact_mod_cast hr + have hhr' : (h : ℝ) ≤ 17 * (r : ℝ) := by exact_mod_cast hhr + have hbase : Real.exp 1 * (h : ℝ) / (r : ℝ) ≤ 17 * Real.exp 1 := by + apply (div_le_iff₀ hr0).mpr + calc + Real.exp 1 * (h : ℝ) ≤ Real.exp 1 * (17 * (r : ℝ)) := + mul_le_mul_of_nonneg_left hhr' (Real.exp_pos 1).le + _ = _ := by ring + have hchoose : (h.choose r : ℝ) ≤ (17 * Real.exp 1) ^ r := + (choose_le_exp_div_pow h r hr).trans (pow_le_pow_left₀ (by positivity) hbase r) + calc + 2 * (h.choose r : ℝ) / (128 : ℝ) ^ r ≤ + 2 * (17 * Real.exp 1) ^ r / (128 : ℝ) ^ r := + div_le_div_of_nonneg_right (by nlinarith) (by positivity) + _ = _ := by rw [div_pow]; ring + +theorem two_choose_div_lt_one (h r : ℕ) (hr : 0 < r) (hhr : h ≤ 17 * r) : + 2 * (h.choose r : ℝ) / (128 : ℝ) ^ r < 1 := + (two_choose_div_le_predecessor_power h r hr hhr).trans_lt + (predecessor_power_lt_one hr) + +/-- Arithmetic form of the expectation constraint and internal-copy count bound. -/ +theorem normalized_count_score_bound {a m h r : ℕ} {q : ℝ} + (hq : 0 < q) (hm : 0 < m) (ha : a ≤ h.choose r) + (he : (1 / 2 : ℝ) ≤ (m : ℝ) * q ^ r) : + ((a : ℝ) / (m : ℝ)) / (128 * q) ^ r ≤ + 2 * (h.choose r : ℝ) / (128 : ℝ) ^ r := by + apply (div_le_iff₀ (pow_pos (by positivity : 0 < 128 * q) r)).mpr + have hscale : (2 * (h.choose r : ℝ) / (128 : ℝ) ^ r) * (128 * q) ^ r = + 2 * (h.choose r : ℝ) * q ^ r := by + rw [mul_pow] + field_simp + rw [hscale] + apply (div_le_iff₀ (show 0 < (m : ℝ) by exact_mod_cast hm)).mpr + have ha' : (a : ℝ) ≤ (h.choose r : ℝ) := by exact_mod_cast ha + have hprod := mul_le_mul_of_nonneg_left he + (show 0 ≤ 2 * (h.choose r : ℝ) by positivity) + nlinarith + +section FiniteMaximum + +variable {X : Type*} + +private theorem exists_powerset_max (I : Finset X) (score : Finset X → ℝ) : + ∃ S ∈ I.powerset, ∀ U ∈ I.powerset, score U ≤ score S := + Finset.exists_max_image I.powerset score ⟨∅, by simp⟩ + +/-- A deterministic classical choice of a maximizer over all subsets of `I`. +The empty set is included, so this definition also applies to empty `I`. -/ +def maximizingSubset (I : Finset X) (score : Finset X → ℝ) : Finset X := + (exists_powerset_max I score).choose + +theorem maximizingSubset_subset (I : Finset X) (score : Finset X → ℝ) : + maximizingSubset I score ⊆ I := + Finset.mem_powerset.mp (exists_powerset_max I score).choose_spec.1 + +theorem le_maximizingSubset (I : Finset X) (score : Finset X → ℝ) + {U : Finset X} (hU : U ⊆ I) : score U ≤ score (maximizingSubset I score) := + (exists_powerset_max I score).choose_spec.2 U (Finset.mem_powerset.mpr hU) + +end FiniteMaximum + +section OrbitPredecessor + +variable (G : Type*) [Group G] [Fintype G] +variable {X : Type*} [DecidableEq X] [MulAction G X] + +def predecessorScore (I : Finset X) (σ : ℝ) (S : Finset X) : ℝ := + containmentProb G I S / σ ^ S.card + +/-- The actual maximizing predecessor; the finite choice includes the empty set. -/ +def maximizingPredecessor (I : Finset X) (σ : ℝ) : Finset X := + maximizingSubset I (predecessorScore G I σ) + +theorem maximizingPredecessor_subset (I : Finset X) (σ : ℝ) : + maximizingPredecessor G I σ ⊆ I := + maximizingSubset_subset I _ + +theorem predecessorScore_le_max (I : Finset X) (σ : ℝ) + {S : Finset X} (hS : S ⊆ I) : + predecessorScore G I σ S ≤ predecessorScore G I σ (maximizingPredecessor G I σ) := + le_maximizingSubset I _ hS + +@[simp] +theorem predecessorScore_empty (I : Finset X) (σ : ℝ) : + predecessorScore G I σ ∅ = 1 := by + simp [predecessorScore] + +theorem one_le_predecessorScore_max (I : Finset X) (σ : ℝ) : + 1 ≤ predecessorScore G I σ (maximizingPredecessor G I σ) := by + simpa using predecessorScore_le_max G I σ (Finset.empty_subset I) + +theorem predecessorScore_eq_of_mem_copyOrbit (σ : ℝ) {I S S₀ : Finset X} + (hS₀ : S₀ ∈ copyOrbit G S) : + predecessorScore G I σ S₀ = predecessorScore G I σ S := by + rw [predecessorScore, predecessorScore, + containmentProb_eq_of_mem_copyOrbit G hS₀, card_eq_of_mem_copyOrbit G hS₀] + +/-- A positive observation pulls back to an actual subset of `I`; zero-probability +observations cannot exceed the empty set's score. Thus the chosen finite +maximum controls every observed set, not only subsets of the original copy. -/ +theorem predecessorScore_le_max_all (I U : Finset X) (σ : ℝ) : + predecessorScore G I σ U ≤ predecessorScore G I σ (maximizingPredecessor G I σ) := by + by_cases hzero : containmentProb G I U = 0 + · rw [predecessorScore, hzero, zero_div] + exact zero_le_one.trans (one_le_predecessorScore_max G I σ) + · have hpos : 0 < containmentProb G I U := + lt_of_le_of_ne (containmentProb_nonneg G I U) (Ne.symm hzero) + obtain ⟨V, hVI, hcopy, _⟩ := exists_pullback_of_containmentProb_pos G hpos + rw [predecessorScore_eq_of_mem_copyOrbit G σ hcopy] + exact predecessorScore_le_max G I σ hVI + +theorem predecessorScore_le_two_choose {I S : Finset X} {q : ℝ} + (hq : 0 < q) + (hE : (1 / 2 : ℝ) ≤ (orbitCount G S : ℝ) * q ^ S.card) : + predecessorScore G I (128 * q) S ≤ + 2 * (I.card.choose S.card : ℝ) / (128 : ℝ) ^ S.card := by + rw [predecessorScore, containmentProb_eq_internalCopyCount] + exact normalized_count_score_bound hq (orbitCount_pos G S) + (internalCopyCount_le_choose G I S) hE + +/-- The maximizing predecessor is less than one seventeenth of the current set. +The only probabilistic input is the actual expectation constraint for its +nonempty edge subsets. -/ +theorem maximizingPredecessor_small (I : Finset X) (hI : I.Nonempty) + {q : ℝ} (hq : 0 < q) + (hE : ∀ S : Finset X, S ⊆ I → S.Nonempty → + (1 / 2 : ℝ) ≤ (orbitCount G S : ℝ) * q ^ S.card) : + 17 * (maximizingPredecessor G I (128 * q)).card < I.card := by + by_contra hsmall + have hcardI : 0 < I.card := Finset.card_pos.mpr hI + have hlarge : I.card ≤ 17 * (maximizingPredecessor G I (128 * q)).card := by omega + have hcardS : 0 < (maximizingPredecessor G I (128 * q)).card := by omega + have hbound := predecessorScore_le_two_choose G (I := I) hq + (hE _ (maximizingPredecessor_subset G I _) (Finset.card_pos.mp hcardS)) + have hlt := hbound.trans_lt (two_choose_div_lt_one I.card _ hcardS hlarge) + have hge := one_le_predecessorScore_max G I (128 * q) + linarith + +theorem predecessor_copy_prob_pos (I : Finset X) (σ : ℝ) {S₀ : Finset X} + (hS₀ : S₀ ∈ copyOrbit G (maximizingPredecessor G I σ)) : + 0 < containmentProb G I S₀ := + containmentProb_pos_of_copy_subset G (maximizingPredecessor_subset G I σ) hS₀ + +theorem predecessor_conditional_ratio_le (I : Finset X) {σ : ℝ} (hσ : 0 < σ) + {S₀ J : Finset X} + (hS₀ : S₀ ∈ copyOrbit G (maximizingPredecessor G I σ)) + (hdisj : Disjoint S₀ J) : + containmentProb G I (S₀ ∪ J) / containmentProb G I S₀ ≤ σ ^ J.card := by + have hscore := predecessorScore_le_max_all G I (S₀ ∪ J) σ + rw [← predecessorScore_eq_of_mem_copyOrbit G σ hS₀] at hscore + simp only [predecessorScore, Finset.card_union_of_disjoint hdisj, pow_add] at hscore + have hpowS : 0 < σ ^ S₀.card := pow_pos hσ _ + have hpowJ : 0 < σ ^ J.card := pow_pos hσ _ + have hclear := (div_le_div_iff₀ (mul_pos hpowS hpowJ) hpowS).mp hscore + have hnum : containmentProb G I (S₀ ∪ J) ≤ + σ ^ J.card * containmentProb G I S₀ := by + apply (mul_le_mul_iff_right₀ hpowS).mp + simpa only [mul_assoc, mul_comm, mul_left_comm] using hclear + exact (div_le_iff₀ (predecessor_copy_prob_pos G I σ hS₀)).mpr hnum + +end OrbitPredecessor + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTree.lean b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1dd22aa45a8adf3b1083ad8081269d22c7dbdba --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTree.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import Mathlib.Data.List.Pairwise +import Mathlib.Data.Fintype.Sigma + +namespace OAI + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +/-- Equal-depth trees carrying an actual strictly positive child law at every branch. -/ +inductive ProbabilityTree (X : Type) : ℕ → Type 1 + | leaf : ProbabilityTree X 0 + | node {d : ℕ} (B : Type) [Fintype B] (law : FiniteLaw B) + (positive : law.IsPositive) (label : B → Finset X) + (child : B → ProbabilityTree X d) : ProbabilityTree X (d + 1) + +/-- A function inspects only the indicated coordinates of its input subset. -/ +def DependsOnlyOn {X β : Type*} [DecidableEq X] (S : Finset X) + (f : Finset X → β) : Prop := + ∀ W V, W ∩ S = V ∩ S → f W = f V + +/-- A function is unchanged by modifications inside the indicated coordinates. -/ +def DependsOutside {X β : Type*} [DecidableEq X] (A : Finset X) + (f : Finset X → β) : Prop := + ∀ W V, W \ A = V \ A → f W = f V + +namespace ProbabilityTree + +variable {X : Type} + +/-- Full root-to-leaf paths, retaining distinct child-index histories. -/ +def Path : {d : ℕ} → ProbabilityTree X d → Type + | _, .leaf => PUnit + | _, @node _ _ B _ _ _ _ child => Σ b : B, Path (child b) + +/-- The list of arc labels along a full path, in root-to-leaf order. -/ +def pathLabels : {d : ℕ} → (T : ProbabilityTree X d) → T.Path → List (Finset X) + | _, .leaf => fun _ => [] + | _, @node _ _ _B _ _ _ label child => fun p => + label p.1 :: pathLabels (child p.1) p.2 + +/-- Every path family is finite; no quotient by labels is taken. -/ +instance pathFintype : {d : ℕ} → (T : ProbabilityTree X d) → Fintype T.Path + | _, .leaf => inferInstanceAs (Fintype PUnit) + | _, @node _ _ B _ _ _ _ child => by + letI : ∀ b : B, Fintype (Path (child b)) := fun b => pathFintype (child b) + exact inferInstanceAs (Fintype (Σ b : B, Path (child b))) + +section Labels + +variable [DecidableEq X] + +/-- Union of all arc labels along a specified full path. -/ +def pathUnion : {d : ℕ} → (T : ProbabilityTree X d) → T.Path → Finset X + | _, .leaf => fun _ => ∅ + | _, @node _ _ _B _ _ _ label child => fun p => + label p.1 ∪ pathUnion (child p.1) p.2 + +/-- All coordinates used by any arc anywhere in the tree. -/ +def support : {d : ℕ} → ProbabilityTree X d → Finset X + | _, .leaf => ∅ + | _, @node _ _ B inst _ _ label child => + (@Finset.univ B inst).biUnion fun b => label b ∪ support (child b) + +/-- A recursive form of disjointness, equivalent to pairwise disjoint labels on every full path. -/ +def IsDisjoint : {d : ℕ} → ProbabilityTree X d → Prop + | _, .leaf => True + | _, @node _ _ _ _ _ _ label child => + (∀ b, Disjoint (label b) (support (child b))) ∧ ∀ b, IsDisjoint (child b) + +/-- Literal pairwise disjointness along every full root-to-leaf path. -/ +def PathDisjoint {d : ℕ} (T : ProbabilityTree X d) : Prop := + ∀ p : T.Path, (T.pathLabels p).Pairwise Disjoint + +/-- Per-level spread conditions, starting with index zero at the root. -/ +def HasSpread : {d : ℕ} → ProbabilityTree X d → (ℕ → ℝ) → Prop + | _, .leaf, _ => True + | _, @node _ _ _ _ law _ label child, a => + IsSpread law label (a 0) ∧ ∀ b, HasSpread (child b) (fun j => a (j + 1)) + +/-- The event that some full path is covered by a given set. -/ +def CoveredBy {d : ℕ} (T : ProbabilityTree X d) (W : Finset X) : Prop := + ∃ p : T.Path, T.pathUnion p ⊆ W + +end Labels + +/-- Per-level cardinality capacities, starting with index zero at the root. -/ +def HasCapacities : {d : ℕ} → ProbabilityTree X d → (ℕ → ℕ) → Prop + | _, .leaf, _ => True + | _, @node _ _ _ _ _ _ label child, m => + (∀ b, (label b).card ≤ m 0) ∧ ∀ b, HasCapacities (child b) (fun j => m (j + 1)) + +end ProbabilityTree + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreeFacts.lean b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreeFacts.lean new file mode 100644 index 0000000000000000000000000000000000000000..702a6b9fbf7ee120e9cd185455f3bf7e9a5340d6 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreeFacts.lean @@ -0,0 +1,137 @@ +import OAI.Combinatorics.GraphThreshold.ProbabilityTree +import Mathlib.Tactic + +namespace OAI + +/-! Path and locality facts for the stable finite probability-tree representation. -/ + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +section Locality + +variable {X β : Type*} [DecidableEq X] {S T A : Finset X} {f : Finset X → β} + +theorem DependsOnlyOn.mono (hf : DependsOnlyOn S f) (hST : S ⊆ T) : + DependsOnlyOn T f := by + intro W V hWV + apply hf W V + apply Finset.ext + intro x + by_cases hx : x ∈ S + · have hxT := hST hx + have he := Finset.ext_iff.mp hWV x + simpa [hx, hxT] using he + · simp [hx] + +theorem DependsOnlyOn.dependsOutside (hf : DependsOnlyOn S f) (hAS : Disjoint A S) : + DependsOutside A f := by + intro W V hWV + apply hf W V + apply Finset.ext + intro x + by_cases hx : x ∈ S + · have hxA : x ∉ A := fun hxA => Finset.disjoint_left.mp hAS hxA hx + have he := Finset.ext_iff.mp hWV x + simpa [hx, hxA] using he + · simp [hx] + +theorem DependsOutside.sdiff_eq (hf : DependsOutside A f) (W : Finset X) : + f (W \ A) = f W := by + apply hf + ext x + simp + +theorem dependsOutside_iff_sdiff : + DependsOutside A f ↔ ∀ W, f (W \ A) = f W := by + constructor + · exact fun hf => hf.sdiff_eq + · intro hf W V hWV + rw [← hf W, ← hf V, hWV] + +theorem DependsOutside.union_eq (hf : DependsOutside A f) (W U : Finset X) (hU : U ⊆ A) : + f (W ∪ U) = f W := by + apply hf + ext x + by_cases hx : x ∈ A + · simp [hx] + · have hxU : x ∉ U := fun hxU => hx (hU hxU) + simp [hx, hxU] + +end Locality + +namespace ProbabilityTree + +variable {X : Type} + +/-- A finite law of total mass one has a nonempty underlying type. -/ +theorem branch_nonempty {B : Type} [Fintype B] (law : FiniteLaw B) : Nonempty B := by + classical + by_contra h + let : IsEmpty B := not_nonempty_iff.mp h + have ht := law.total + simp at ht + +/-- Every equal-depth probability tree has at least one full path. -/ +instance pathNonempty {d : ℕ} (T : ProbabilityTree X d) : Nonempty T.Path := by + induction T with + | leaf => exact ⟨PUnit.unit⟩ + | @node d B inst law positive label child ih => + let b : B := Classical.choice (branch_nonempty law) + exact ⟨⟨b, Classical.choice (ih b)⟩⟩ + +/-- A fixed deterministic full path, used only to resolve finite choices. -/ +def choosePath {d : ℕ} (T : ProbabilityTree X d) : T.Path := Classical.choice (pathNonempty T) + +@[simp] theorem pathLabels_length {d : ℕ} (T : ProbabilityTree X d) (p : T.Path) : + (T.pathLabels p).length = d := by + induction T with + | leaf => rfl + | @node d B inst law positive label child ih => + rcases p with ⟨b, p⟩ + simpa [pathLabels] using congrArg Nat.succ (ih b p) + +section Labels + +variable [DecidableEq X] + +theorem label_subset_support {d : ℕ} {B : Type} [Fintype B] + (law : FiniteLaw B) (positive : law.IsPositive) (label : B → Finset X) + (child : B → ProbabilityTree X d) (b : B) : + label b ⊆ (node B law positive label child).support := by + intro x hx + exact Finset.mem_biUnion.mpr ⟨b, Finset.mem_univ b, Finset.mem_union_left _ hx⟩ + +theorem child_support_subset {d : ℕ} {B : Type} [Fintype B] + (law : FiniteLaw B) (positive : law.IsPositive) (label : B → Finset X) + (child : B → ProbabilityTree X d) (b : B) : + (child b).support ⊆ (node B law positive label child).support := by + intro x hx + exact Finset.mem_biUnion.mpr ⟨b, Finset.mem_univ b, Finset.mem_union_right _ hx⟩ + +theorem labels_support_subset {d : ℕ} {B : Type} [Fintype B] + (law : FiniteLaw B) (positive : law.IsPositive) (label : B → Finset X) + (child : B → ProbabilityTree X d) : + (Finset.univ.biUnion label) ⊆ (node B law positive label child).support := by + intro x hx + obtain ⟨b, _, hxb⟩ := Finset.mem_biUnion.mp hx + exact label_subset_support law positive label child b hxb + +theorem child_dependsOutside {d : ℕ} {B : Type} [Fintype B] + {law : FiniteLaw B} {positive : law.IsPositive} {label : B → Finset X} + {child : B → ProbabilityTree X d} + (hT : (node B law positive label child).IsDisjoint) (b : B) + {β : Type*} {f : Finset X → β} (hf : DependsOnlyOn (child b).support f) : + DependsOutside (label b) f := + hf.dependsOutside (hT.1 b) + +end Labels + +end ProbabilityTree + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreePaths.lean b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreePaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b370f753ce39e7e3237c16c2a6dd95513484f10 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreePaths.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.GraphThreshold.ProbabilityTreeFacts + +namespace OAI + +/-! Full-path interpretation of supports and structural disjointness. -/ + +noncomputable section + +namespace LeanBlast.SecondKahnKalai.ProbabilityTree + +variable {X : Type} [DecidableEq X] + +theorem pathUnion_subset_support {d : ℕ} (T : ProbabilityTree X d) (p : T.Path) : + T.pathUnion p ⊆ T.support := by + induction T with + | leaf => exact Finset.empty_subset _ + | @node d B inst law positive label child ih => + rcases p with ⟨b, p⟩ + exact Finset.union_subset (label_subset_support law positive label child b) + ((ih b p).trans (child_support_subset law positive label child b)) + +theorem mem_pathUnion_iff {d : ℕ} (T : ProbabilityTree X d) (p : T.Path) (x : X) : + x ∈ T.pathUnion p ↔ ∃ S ∈ T.pathLabels p, x ∈ S := by + induction T with + | leaf => simp [pathUnion, pathLabels] + | @node d B inst law positive label child ih => + rcases p with ⟨b, p⟩ + simp [pathUnion, pathLabels, ih b p] + +theorem pathLabel_subset_pathUnion {d : ℕ} (T : ProbabilityTree X d) + (p : T.Path) {S : Finset X} (hS : S ∈ T.pathLabels p) : S ⊆ T.pathUnion p := by + intro x hx + exact (mem_pathUnion_iff T p x).2 ⟨S, hS, hx⟩ + +theorem pathLabel_subset_support {d : ℕ} (T : ProbabilityTree X d) + (p : T.Path) {S : Finset X} (hS : S ∈ T.pathLabels p) : S ⊆ T.support := + (pathLabel_subset_pathUnion T p hS).trans (pathUnion_subset_support T p) + +/-- Every arc coordinate occurs on an actual full path, since all branches continue. -/ +theorem mem_support_iff_exists_path {d : ℕ} (T : ProbabilityTree X d) (x : X) : + x ∈ T.support ↔ ∃ p : T.Path, x ∈ T.pathUnion p := by + induction T with + | leaf => simp [support, pathUnion] + | @node d B inst law positive label child ih => + constructor + · intro hx + obtain ⟨b, _, hxb⟩ := Finset.mem_biUnion.mp hx + rcases Finset.mem_union.mp hxb with hlabel | hchild + · exact ⟨⟨b, choosePath (child b)⟩, Finset.mem_union_left _ hlabel⟩ + · obtain ⟨p, hp⟩ := (ih b).1 hchild + exact ⟨⟨b, p⟩, Finset.mem_union_right _ hp⟩ + · rintro ⟨⟨b, p⟩, hx⟩ + apply Finset.mem_biUnion.mpr + refine ⟨b, Finset.mem_univ _, ?_⟩ + rcases Finset.mem_union.mp hx with hlabel | hchild + · exact Finset.mem_union_left _ hlabel + · exact Finset.mem_union_right _ ((ih b).2 ⟨p, hchild⟩) + +theorem support_eq_pathUnion_biUnion {d : ℕ} (T : ProbabilityTree X d) : + T.support = Finset.univ.biUnion T.pathUnion := by + ext x + simpa only [Finset.mem_biUnion, Finset.mem_univ, true_and] using + mem_support_iff_exists_path T x + +theorem isDisjoint_iff_pathDisjoint {d : ℕ} (T : ProbabilityTree X d) : + T.IsDisjoint ↔ T.PathDisjoint := by + induction T with + | leaf => simp [IsDisjoint, PathDisjoint, pathLabels] + | @node d B inst law positive label child ih => + constructor + · intro hT p + rcases p with ⟨b, p⟩ + apply List.pairwise_cons.mpr + constructor + · intro S hS + exact (hT.1 b).mono_right (pathLabel_subset_support (child b) p hS) + · exact (ih b).1 (hT.2 b) p + · intro hT + constructor + · intro b + apply Finset.disjoint_left.mpr + intro x hxLabel hxSupport + obtain ⟨p, hp⟩ := (mem_support_iff_exists_path (child b) x).1 hxSupport + obtain ⟨S, hS, hxS⟩ := (mem_pathUnion_iff (child b) p x).1 hp + have hpw := hT ⟨b, p⟩ + have hdis := (List.pairwise_cons.mp hpw).1 S hS + exact Finset.disjoint_left.mp hdis hxLabel hxS + · intro b + apply (ih b).2 + intro p + exact (List.pairwise_cons.mp (hT ⟨b, p⟩)).2 + +theorem incoming_disjoint_subtree_of_pathDisjoint {d : ℕ} {B : Type} [Fintype B] + {law : FiniteLaw B} {positive : law.IsPositive} {label : B → Finset X} + {child : B → ProbabilityTree X d} + (hT : (node B law positive label child).PathDisjoint) (b : B) : + Disjoint (label b) (child b).support := + ((isDisjoint_iff_pathDisjoint _).2 hT).1 b + +/-- The locality assertion applies even when disjointness is given in the literal path form. -/ +theorem child_dependsOutside_of_pathDisjoint {d : ℕ} {B : Type} [Fintype B] + {law : FiniteLaw B} {positive : law.IsPositive} {label : B → Finset X} + {child : B → ProbabilityTree X d} + (hT : (node B law positive label child).PathDisjoint) (b : B) + {β : Type*} {f : Finset X → β} (hf : DependsOnlyOn (child b).support f) : + DependsOutside (label b) f := + hf.dependsOutside (incoming_disjoint_subtree_of_pathDisjoint hT b) + +theorem coveredBy_mono {d : ℕ} {T : ProbabilityTree X d} {W V : Finset X} + (h : T.CoveredBy W) (hWV : W ⊆ V) : T.CoveredBy V := by + obtain ⟨p, hp⟩ := h + exact ⟨p, hp.trans hWV⟩ + +theorem coveredBy_univ [Fintype X] {d : ℕ} (T : ProbabilityTree X d) : + T.CoveredBy Finset.univ := + ⟨choosePath T, Finset.subset_univ _⟩ + +end LeanBlast.SecondKahnKalai.ProbabilityTree + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreeTrim.lean b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreeTrim.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9b38f2f1d44cb976b01969555cf4a32636f63d6 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/ProbabilityTreeTrim.lean @@ -0,0 +1,222 @@ +import OAI.Combinatorics.GraphThreshold.ProbabilityTreePaths + +namespace OAI + +/-! Deterministic removal of initial zero-capacity levels. -/ + +noncomputable section + +namespace LeanBlast.SecondKahnKalai.ProbabilityTree + +variable {X : Type} + +/-- Choose one child deterministically from the actual nonempty child law. -/ +def firstChild : {d : ℕ} → ProbabilityTree X (d + 1) → ProbabilityTree X d + | _, @node _ _ _ _ law _ _ child => child (Classical.choice (branch_nonempty law)) + +def firstLabel : {d : ℕ} → ProbabilityTree X (d + 1) → Finset X + | _, @node _ _ _ _ law _ label _ => label (Classical.choice (branch_nonempty law)) + +/-- Prepend the chosen incoming arc to a path of the chosen child. -/ +def prependChosen : {d : ℕ} → (T : ProbabilityTree X (d + 1)) → + (firstChild T).Path → T.Path + | _, @node _ _ _ _ law _ _ _, p => ⟨Classical.choice (branch_nonempty law), p⟩ + +/-- Remove `k` initial levels. The additive depth form avoids subtraction casts. -/ +def drop : (k : ℕ) → {d : ℕ} → ProbabilityTree X (d + k) → ProbabilityTree X d + | 0, _, T => T + | k + 1, _, T => drop k (firstChild T) + +/-- Lift a retained path through the fixed choices on the removed prefix. -/ +def liftDropPath : (k : ℕ) → {d : ℕ} → (T : ProbabilityTree X (d + k)) → + (drop k T).Path → T.Path + | 0, _, _, p => p + | k + 1, _, T, p => prependChosen T (liftDropPath k (firstChild T) p) + +/-- Reindex a tree along equality of depths, without changing its data. -/ +def castDepth {d e : ℕ} (h : d = e) (T : ProbabilityTree X d) : ProbabilityTree X e := h ▸ T + +def castPath {d e : ℕ} (h : d = e) (T : ProbabilityTree X d) : + T.Path ≃ (castDepth h T).Path := by + cases h + exact Equiv.refl _ + +/-- Subtraction-indexed convenience wrapper for removing an initial prefix. -/ +def dropPrefix {d : ℕ} (T : ProbabilityTree X d) (k : ℕ) (hk : k ≤ d) : + ProbabilityTree X (d - k) := + drop k (castDepth (Nat.sub_add_cancel hk).symm T) + +def liftDropPrefixPath {d : ℕ} (T : ProbabilityTree X d) (k : ℕ) (hk : k ≤ d) + (p : (dropPrefix T k hk).Path) : T.Path := + (castPath (Nat.sub_add_cancel hk).symm T).symm + (liftDropPath k (castDepth (Nat.sub_add_cancel hk).symm T) p) + +section Properties + +variable [DecidableEq X] + +theorem pathUnion_prependChosen {d : ℕ} (T : ProbabilityTree X (d + 1)) + (p : (firstChild T).Path) : + T.pathUnion (prependChosen T p) = firstLabel T ∪ (firstChild T).pathUnion p := by + cases T + rfl + +theorem firstChild_support_subset {d : ℕ} (T : ProbabilityTree X (d + 1)) : + (firstChild T).support ⊆ T.support := by + cases T with + | node B law positive label child => + exact child_support_subset law positive label child _ + +theorem firstChild_isDisjoint {d : ℕ} {T : ProbabilityTree X (d + 1)} + (hT : T.IsDisjoint) : (firstChild T).IsDisjoint := by + cases T + exact hT.2 _ + +omit [DecidableEq X] in +theorem firstChild_hasCapacities {d : ℕ} {T : ProbabilityTree X (d + 1)} {m : ℕ → ℕ} + (hT : T.HasCapacities m) : (firstChild T).HasCapacities (fun i => m (i + 1)) := by + cases T + exact hT.2 _ + +theorem firstChild_hasSpread {d : ℕ} {T : ProbabilityTree X (d + 1)} {a : ℕ → ℝ} + (hT : T.HasSpread a) : (firstChild T).HasSpread (fun i => a (i + 1)) := by + cases T + exact hT.2 _ + +omit [DecidableEq X] in +theorem firstLabel_card_le {d : ℕ} {T : ProbabilityTree X (d + 1)} {m : ℕ → ℕ} + (hT : T.HasCapacities m) : (firstLabel T).card ≤ m 0 := by + cases T + exact hT.1 _ + +omit [DecidableEq X] in +theorem firstLabel_eq_empty {d : ℕ} {T : ProbabilityTree X (d + 1)} {m : ℕ → ℕ} + (hT : T.HasCapacities m) (hm : m 0 = 0) : firstLabel T = ∅ := by + apply Finset.card_eq_zero.mp + have h := firstLabel_card_le hT + omega + +/-- Labels committed by the deterministic choices on the removed prefix. -/ +def prefixUnion : (k : ℕ) → {d : ℕ} → ProbabilityTree X (d + k) → Finset X + | 0, _, _ => ∅ + | k + 1, _, T => firstLabel T ∪ prefixUnion k (firstChild T) + +theorem pathUnion_liftDropPath (k : ℕ) {d : ℕ} (T : ProbabilityTree X (d + k)) + (p : (drop k T).Path) : + T.pathUnion (liftDropPath k T p) = prefixUnion k T ∪ (drop k T).pathUnion p := by + induction k generalizing d with + | zero => simp [liftDropPath, prefixUnion, drop] + | succ k ih => + change T.pathUnion (prependChosen T (liftDropPath k T.firstChild p)) = + (T.firstLabel ∪ prefixUnion k T.firstChild) ∪ (drop k T.firstChild).pathUnion p + rw [pathUnion_prependChosen, ih T.firstChild p, Finset.union_assoc] + +theorem drop_support_subset (k : ℕ) {d : ℕ} (T : ProbabilityTree X (d + k)) : + (drop k T).support ⊆ T.support := by + induction k generalizing d with + | zero => exact Finset.Subset.refl _ + | succ k ih => exact (ih (firstChild T)).trans (firstChild_support_subset T) + +theorem drop_isDisjoint (k : ℕ) {d : ℕ} {T : ProbabilityTree X (d + k)} + (hT : T.IsDisjoint) : (drop k T).IsDisjoint := by + induction k generalizing d with + | zero => exact hT + | succ k ih => exact ih (firstChild_isDisjoint hT) + +omit [DecidableEq X] in +theorem drop_hasCapacities (k : ℕ) {d : ℕ} {T : ProbabilityTree X (d + k)} + {m : ℕ → ℕ} (hT : T.HasCapacities m) : + (drop k T).HasCapacities (fun i => m (i + k)) := by + induction k generalizing d m with + | zero => simpa [drop] using hT + | succ k ih => + simpa [drop, Nat.add_assoc] using ih (firstChild_hasCapacities hT) + +theorem drop_hasSpread (k : ℕ) {d : ℕ} {T : ProbabilityTree X (d + k)} + {a : ℕ → ℝ} (hT : T.HasSpread a) : + (drop k T).HasSpread (fun i => a (i + k)) := by + induction k generalizing d a with + | zero => simpa [drop] using hT + | succ k ih => + simpa [drop, Nat.add_assoc] using ih (firstChild_hasSpread hT) + +theorem prefixUnion_eq_empty_of_capacities (k : ℕ) {d : ℕ} + {T : ProbabilityTree X (d + k)} {m : ℕ → ℕ} (hT : T.HasCapacities m) + (hm : ∀ i, i < k → m i = 0) : prefixUnion k T = ∅ := by + induction k generalizing d m with + | zero => rfl + | succ k ih => + rw [prefixUnion, firstLabel_eq_empty hT (hm 0 (by omega)), Finset.empty_union] + exact ih (firstChild_hasCapacities hT) (fun i hi => hm (i + 1) (by omega)) + +/-- Removing zero-capacity levels preserves every retained full path union exactly. -/ +theorem pathUnion_liftDropPath_eq (k : ℕ) {d : ℕ} {T : ProbabilityTree X (d + k)} + {m : ℕ → ℕ} (hT : T.HasCapacities m) (hm : ∀ i, i < k → m i = 0) + (p : (drop k T).Path) : T.pathUnion (liftDropPath k T p) = (drop k T).pathUnion p := by + rw [pathUnion_liftDropPath, prefixUnion_eq_empty_of_capacities k hT hm, Finset.empty_union] + +@[simp] theorem support_castDepth {d e : ℕ} (h : d = e) (T : ProbabilityTree X d) : + (castDepth h T).support = T.support := by cases h; rfl + +@[simp] theorem isDisjoint_castDepth {d e : ℕ} (h : d = e) (T : ProbabilityTree X d) : + (castDepth h T).IsDisjoint ↔ T.IsDisjoint := by cases h; rfl + +omit [DecidableEq X] in +@[simp] theorem hasCapacities_castDepth {d e : ℕ} (h : d = e) (T : ProbabilityTree X d) + (m : ℕ → ℕ) : (castDepth h T).HasCapacities m ↔ T.HasCapacities m := by cases h; rfl + +@[simp] theorem hasSpread_castDepth {d e : ℕ} (h : d = e) (T : ProbabilityTree X d) + (a : ℕ → ℝ) : (castDepth h T).HasSpread a ↔ T.HasSpread a := by cases h; rfl + +theorem pathUnion_castPath_symm {d e : ℕ} (h : d = e) (T : ProbabilityTree X d) + (p : (castDepth h T).Path) : + T.pathUnion ((castPath h T).symm p) = (castDepth h T).pathUnion p := by cases h; rfl + +theorem dropPrefix_support_subset {d : ℕ} (T : ProbabilityTree X d) (k : ℕ) (hk : k ≤ d) : + (dropPrefix T k hk).support ⊆ T.support := by + simpa only [dropPrefix, support_castDepth] using + drop_support_subset k (castDepth (Nat.sub_add_cancel hk).symm T) + +theorem dropPrefix_isDisjoint {d : ℕ} {T : ProbabilityTree X d} (hT : T.IsDisjoint) + (k : ℕ) (hk : k ≤ d) : (dropPrefix T k hk).IsDisjoint := by + apply drop_isDisjoint + simpa using hT + +omit [DecidableEq X] in +theorem dropPrefix_hasCapacities {d : ℕ} {T : ProbabilityTree X d} {m : ℕ → ℕ} + (hT : T.HasCapacities m) (k : ℕ) (hk : k ≤ d) : + (dropPrefix T k hk).HasCapacities (fun i => m (i + k)) := by + apply drop_hasCapacities + simpa using hT + +theorem dropPrefix_hasSpread {d : ℕ} {T : ProbabilityTree X d} {a : ℕ → ℝ} + (hT : T.HasSpread a) (k : ℕ) (hk : k ≤ d) : + (dropPrefix T k hk).HasSpread (fun i => a (i + k)) := by + apply drop_hasSpread + simpa using hT + +/-- Every path after zero-prefix trimming is an original full path with exactly the same union. -/ +theorem pathUnion_liftDropPrefixPath_eq {d : ℕ} {T : ProbabilityTree X d} {m : ℕ → ℕ} + (hT : T.HasCapacities m) (k : ℕ) (hk : k ≤ d) + (hm : ∀ i, i < k → m i = 0) (p : (dropPrefix T k hk).Path) : + T.pathUnion (liftDropPrefixPath T k hk p) = (dropPrefix T k hk).pathUnion p := by + unfold liftDropPrefixPath + rw [pathUnion_castPath_symm] + apply pathUnion_liftDropPath_eq k _ hm + simpa using hT + +theorem coveredBy_of_dropPrefix {d : ℕ} {T : ProbabilityTree X d} {m : ℕ → ℕ} + (hT : T.HasCapacities m) (k : ℕ) (hk : k ≤ d) + (hm : ∀ i, i < k → m i = 0) {W : Finset X} + (hW : (dropPrefix T k hk).CoveredBy W) : T.CoveredBy W := by + obtain ⟨p, hp⟩ := hW + refine ⟨liftDropPrefixPath T k hk p, ?_⟩ + rwa [pathUnion_liftDropPrefixPath_eq hT k hk hm p] + +end Properties + +end LeanBlast.SecondKahnKalai.ProbabilityTree + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/Resampling.lean b/lean/OAI/Combinatorics/GraphThreshold/Resampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..4176fa634d3bc1aa1e160ac7e60e4e769b0eb897 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/Resampling.lean @@ -0,0 +1,202 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Data.Fintype.BigOperators + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace LeanBlast.SecondKahnKalai + +variable {X B : Type*} [DecidableEq X] [Fintype B] + +def resamplingY (A : B → Finset X) (W : Finset X) (c : B) : Finset X := W ∪ A c + +def resamplingNumerator (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (Y : Finset X) (b : B) : ℝ := + if A b ⊆ Y then ν.weight b * (ρ⁻¹) ^ (A b).card else 0 + +/-- The actual normalizing density `Z(Y)`. -/ +def resamplingZ (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (Y : Finset X) : ℝ := + ∑ b, resamplingNumerator ν A ρ Y b + +def resamplingTargetWeight (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (W : Finset X) (c b : B) : ℝ := + resamplingNumerator ν A ρ (resamplingY A W c) b / + resamplingZ ν A ρ (resamplingY A W c) + +def resamplingWeight (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (W : Finset X) (cb : B × B) : ℝ := + ν.weight cb.1 * resamplingTargetWeight ν A ρ W cb.1 cb.2 + +/-- The retained target fragment; no quotienting of the label indices occurs. -/ +def resamplingFragment (A : B → Finset X) (W : Finset X) (b : B) : Finset X := + A b \ W + +theorem resamplingNumerator_nonneg (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 ≤ ρ) (Y : Finset X) (b : B) : + 0 ≤ resamplingNumerator ν A ρ Y b := by + unfold resamplingNumerator + split_ifs + · exact mul_nonneg (ν.nonneg b) (pow_nonneg (inv_nonneg.mpr hρ) _) + · exact le_rfl + +theorem resamplingZ_nonneg (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 ≤ ρ) (Y : Finset X) : 0 ≤ resamplingZ ν A ρ Y := by + exact Finset.sum_nonneg fun b _ => resamplingNumerator_nonneg ν A hρ Y b + +theorem resamplingZ_pos (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (W : Finset X) (c : B) : + 0 < resamplingZ ν A ρ (resamplingY A W c) := by + classical + have hc : 0 < resamplingNumerator ν A ρ (resamplingY A W c) c := by + rw [resamplingNumerator, resamplingY, ite_eq_left Finset.subset_union_right] + exact mul_pos (hν c) (pow_pos (inv_pos.mpr hρ) _) + exact lt_of_lt_of_le hc (Finset.single_le_sum + (fun b _ => resamplingNumerator_nonneg ν A hρ.le (resamplingY A W c) b) + (Finset.mem_univ c)) + +theorem resamplingTargetWeight_nonneg (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 ≤ ρ) (W : Finset X) (c b : B) : + 0 ≤ resamplingTargetWeight ν A ρ W c b := + div_nonneg (resamplingNumerator_nonneg ν A hρ _ _) + (resamplingZ_nonneg ν A hρ _) + +theorem resamplingWeight_nonneg (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 ≤ ρ) (W : Finset X) (cb : B × B) : + 0 ≤ resamplingWeight ν A ρ W cb := + mul_nonneg (ν.nonneg _) (resamplingTargetWeight_nonneg ν A hρ W _ _) + +theorem resamplingTargetWeight_total (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (W : Finset X) (c : B) : + (∑ b, resamplingTargetWeight ν A ρ W c b) = 1 := by + simp only [resamplingTargetWeight, ← Finset.sum_div] + exact div_self (resamplingZ_pos ν A hν hρ W c).ne' + +theorem resampling_source_marginal (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (W : Finset X) (c : B) : + (∑ b, resamplingWeight ν A ρ W (c, b)) = ν.weight c := by + simp only [resamplingWeight, ← Finset.mul_sum, + resamplingTargetWeight_total ν A hν hρ W c, mul_one] + +theorem resamplingWeight_total (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (W : Finset X) : + (∑ cb : B × B, resamplingWeight ν A ρ W cb) = 1 := by + rw [Fintype.sum_prod_type] + simp only [resampling_source_marginal ν A hν hρ W] + exact ν.total + +def resamplingTargetLaw (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (W : Finset X) (c : B) (hν : ν.IsPositive) (hρ : 0 < ρ) : FiniteLaw B where + weight := resamplingTargetWeight ν A ρ W c + nonneg := resamplingTargetWeight_nonneg ν A hρ.le W c + total := resamplingTargetWeight_total ν A hν hρ W c + +def resamplingLaw (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (W : Finset X) (hν : ν.IsPositive) (hρ : 0 < ρ) : FiniteLaw (B × B) where + weight := resamplingWeight ν A ρ W + nonneg := resamplingWeight_nonneg ν A hρ.le W + total := resamplingWeight_total ν A hν hρ W + +@[simp] theorem resamplingLaw_weight (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (W : Finset X) (hν : ν.IsPositive) (hρ : 0 < ρ) (cb : B × B) : + (resamplingLaw ν A ρ W hν hρ).weight cb = resamplingWeight ν A ρ W cb := rfl + +theorem resampling_expectation_source (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (W : Finset X) (f : B → ℝ) : + (resamplingLaw ν A ρ W hν hρ).expectation (fun cb => f cb.1) = ν.expectation f := by + simp only [FiniteLaw.expectation, resamplingLaw_weight, Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro c _ + rw [← Finset.sum_mul, resampling_source_marginal ν A hν hρ W c] + +theorem resampling_prob_source (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (W : Finset X) (P : B → Prop) : + (resamplingLaw ν A ρ W hν hρ).prob (fun cb => P cb.1) = ν.prob P := by + classical + simp only [FiniteLaw.prob, Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro c _ + by_cases hc : P c + · simp only [ite_eq_left hc, resamplingLaw_weight, resampling_source_marginal ν A hν hρ W c] + · simp only [ite_eq_right hc, Finset.sum_const_zero] + +theorem resamplingWeight_eq_zero_of_not_subset (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (W : Finset X) (c b : B) (hb : ¬A b ⊆ resamplingY A W c) : + resamplingWeight ν A ρ W (c, b) = 0 := by + simp [resamplingWeight, resamplingTargetWeight, resamplingNumerator, hb] + +theorem resampling_target_subset_of_pos (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (W : Finset X) (c b : B) + (hcb : 0 < resamplingWeight ν A ρ W (c, b)) : A b ⊆ resamplingY A W c := by + by_contra hb + rw [resamplingWeight_eq_zero_of_not_subset ν A ρ W c b hb] at hcb + exact (lt_irrefl 0) hcb + +omit [Fintype B] in +theorem resamplingFragment_subset_target (A : B → Finset X) (W : Finset X) (b : B) : + resamplingFragment A W b ⊆ A b := Finset.sdiff_subset + +theorem resamplingFragment_subset_source (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (W : Finset X) (c b : B) + (hcb : 0 < resamplingWeight ν A ρ W (c, b)) : + resamplingFragment A W b ⊆ A c := by + intro x hx + have hx' := Finset.mem_sdiff.mp hx + rcases Finset.mem_union.mp (resampling_target_subset_of_pos ν A ρ W c b hcb hx'.1) with hW | hc + · exact (hx'.2 hW).elim + · exact hc + +theorem resamplingFragment_subset_inter (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (W : Finset X) (c b : B) + (hcb : 0 < resamplingWeight ν A ρ W (c, b)) : + resamplingFragment A W b ⊆ A c ∩ A b := + Finset.subset_inter (resamplingFragment_subset_source ν A ρ W c b hcb) + (resamplingFragment_subset_target A W b) + +omit [Fintype B] in +/-- Every target label is recovered by adjoining its retained fragment to W. -/ +theorem resamplingFragment_recovery (A : B → Finset X) (W : Finset X) (b : B) : + A b ⊆ W ∪ resamplingFragment A W b := by + intro x hx + by_cases hW : x ∈ W + · exact Finset.mem_union.mpr (Or.inl hW) + · exact Finset.mem_union.mpr (Or.inr (Finset.mem_sdiff.mpr ⟨hx, hW⟩)) + +omit [Fintype B] in +theorem resampling_target_subset_iff_fragment (A : B → Finset X) + (W : Finset X) (c b : B) : + A b ⊆ resamplingY A W c ↔ resamplingFragment A W b ⊆ A c := by + constructor + · intro h x hx + have hx' := Finset.mem_sdiff.mp hx + rcases Finset.mem_union.mp (h hx'.1) with hW | hc + · exact (hx'.2 hW).elim + · exact hc + · intro h x hx + by_cases hW : x ∈ W + · exact Finset.mem_union.mpr (Or.inl hW) + · exact Finset.mem_union.mpr (Or.inr (h (Finset.mem_sdiff.mpr ⟨hx, hW⟩))) + +/-- The transition depends on W only through its intersections with the +labels, expressed equivalently by their retained fragments. -/ +theorem resamplingWeight_congr_fragments (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) {W W' : Finset X} + (hW : ∀ b, resamplingFragment A W b = resamplingFragment A W' b) (cb : B × B) : + resamplingWeight ν A ρ W cb = resamplingWeight ν A ρ W' cb := by + have hsub (c b : B) : A b ⊆ resamplingY A W c ↔ A b ⊆ resamplingY A W' c := by + rw [resampling_target_subset_iff_fragment, resampling_target_subset_iff_fragment, hW] + have hn (c b : B) : + resamplingNumerator ν A ρ (resamplingY A W c) b = + resamplingNumerator ν A ρ (resamplingY A W' c) b := by + simp only [resamplingNumerator, hsub] + simp only [resamplingWeight, resamplingTargetWeight, resamplingZ, hn] + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/ResamplingDensity.lean b/lean/OAI/Combinatorics/GraphThreshold/ResamplingDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..43a0806baa95028761e2e8e823306412a059c8dc --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/ResamplingDensity.lean @@ -0,0 +1,141 @@ +import OAI.Combinatorics.GraphThreshold.Resampling +import OAI.Combinatorics.GraphThreshold.FiniteProbability +import OAI.Combinatorics.GraphThreshold.BernoulliCoupling + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace LeanBlast.SecondKahnKalai + +attribute [local instance] Classical.propDecidable + +variable {X B : Type*} [Fintype X] [DecidableEq X] [Fintype B] + +def resamplingExperimentLaw (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) + (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) : + FiniteLaw (Finset X × (B × B)) where + weight ω := bernoulliWeight ρ ω.1 * resamplingWeight ν A ρ ω.1 ω.2 + nonneg ω := mul_nonneg (bernoulliWeight_nonneg hρ.le hρ1 ω.1) + (resamplingWeight_nonneg ν A hρ.le ω.1 ω.2) + total := by + rw [Fintype.sum_prod_type] + simp only [← Finset.mul_sum, resamplingWeight_total ν A hν hρ, mul_one] + exact bernoulliWeight_sum ρ + +theorem resamplingExperiment_expectation (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (F : Finset X → B × B → ℝ) : + (resamplingExperimentLaw ν A ρ hν hρ hρ1).expectation (fun ω => F ω.1 ω.2) = + bernoulliExpectation ρ (fun W => (resamplingLaw ν A ρ W hν hρ).expectation (F W)) := by + simp only [FiniteLaw.expectation, resamplingExperimentLaw, Fintype.sum_prod_type, + bernoulliExpectation, resamplingLaw_weight, Finset.mul_sum] + apply Finset.sum_congr rfl + intro W _ + apply Finset.sum_congr rfl + intro cb _ + ring_nf + +/-- Mixture expansion before using the Bernoulli union identity. -/ +theorem bernoulliExpectation_resampling_source (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (F : Finset X → ℝ) : + bernoulliExpectation ρ (fun W => ν.expectation (fun c => F (resamplingY A W c))) = + ∑ c, ν.weight c * bernoulliExpectation ρ (fun W => F (W ∪ A c)) := by + simp only [bernoulliExpectation, FiniteLaw.expectation, resamplingY, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro c _ + apply Finset.sum_congr rfl + intro W _ + ring_nf + +/-- Expand the proposed density into the finite mixture of conditional +Bernoulli densities. This is an algebraic identity, not a normalization premise. -/ +theorem bernoulliExpectation_resamplingZ (ν : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (F : Finset X → ℝ) : + bernoulliExpectation ρ (fun Y => resamplingZ ν A ρ Y * F Y) = + ∑ c, ν.weight c * bernoulliExpectation ρ + (fun Y => if A c ⊆ Y then F Y / ρ ^ (A c).card else 0) := by + classical + simp only [bernoulliExpectation, resamplingZ, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro c _ + apply Finset.sum_congr rfl + intro Y _ + by_cases hY : A c ⊆ Y + · simp only [resamplingNumerator, ite_eq_left hY, div_eq_mul_inv, inv_pow] + ring_nf + · simp only [resamplingNumerator, ite_eq_right hY, zero_mul, mul_zero] + +theorem resampling_source_density (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : ρ ≠ 0) (F : Finset X → ℝ) : + bernoulliExpectation ρ (fun W => ν.expectation (fun c => F (resamplingY A W c))) = + bernoulliExpectation ρ (fun Y => resamplingZ ν A ρ Y * F Y) := by + rw [bernoulliExpectation_resampling_source, bernoulliExpectation_resamplingZ] + apply Finset.sum_congr rfl + intro c _ + rw [bernoulliExpectation_union_fixed ρ hρ] + +theorem resampling_density (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (F : Finset X → ℝ) : + bernoulliExpectation ρ (fun W => (resamplingLaw ν A ρ W hν hρ).expectation + (fun cb => F (resamplingY A W cb.1))) = + bernoulliExpectation ρ (fun Y => resamplingZ ν A ρ Y * F Y) := by + calc + _ = bernoulliExpectation ρ (fun W => ν.expectation + (fun c => F (resamplingY A W c))) := by + unfold bernoulliExpectation + apply Finset.sum_congr rfl + intro W _ + exact congrArg (fun x => bernoulliWeight ρ W * x) + (resampling_expectation_source ν A hν hρ W (fun c => F (resamplingY A W c))) + _ = _ := resampling_source_density ν A hρ.ne' F + +/-- Event form of the observed-set density formula, used for small-`Z` +failure events in the actual resampling procedure. -/ +theorem resampling_density_prob (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (P : Finset X → Prop) : + bernoulliExpectation ρ (fun W => (resamplingLaw ν A ρ W hν hρ).prob + (fun cb => P (resamplingY A W cb.1))) = + bernoulliExpectation ρ (fun Y => if P Y then resamplingZ ν A ρ Y else 0) := by + classical + simpa only [FiniteLaw.prob_eq_expectation, mul_ite, mul_one, mul_zero] using + resampling_density ν A hν hρ (fun Y => if P Y then 1 else 0) + +theorem resamplingExperiment_density (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (F : Finset X → ℝ) : + (resamplingExperimentLaw ν A ρ hν hρ hρ1).expectation + (fun ω => F (resamplingY A ω.1 ω.2.1)) = + bernoulliExpectation ρ (fun Y => resamplingZ ν A ρ Y * F Y) := by + exact (resamplingExperiment_expectation ν A hν hρ hρ1 + (fun W cb => F (resamplingY A W cb.1))).trans (resampling_density ν A hν hρ F) + +theorem resamplingExperiment_density_prob (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (P : Finset X → Prop) : + (resamplingExperimentLaw ν A ρ hν hρ hρ1).prob + (fun ω => P (resamplingY A ω.1 ω.2.1)) = + bernoulliExpectation ρ (fun Y => if P Y then resamplingZ ν A ρ Y else 0) := by + classical + simpa only [FiniteLaw.prob_eq_expectation, mul_ite, mul_one, mul_zero] using + resamplingExperiment_density ν A hν hρ hρ1 (fun Y => if P Y then 1 else 0) + +/-- Every atom of the observed-set law is exactly the Bernoulli atom times +the explicit finite density `Z`. -/ +theorem resamplingExperiment_observed_mass (ν : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hν : ν.IsPositive) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (Y : Finset X) : + (resamplingExperimentLaw ν A ρ hν hρ hρ1).prob + (fun ω => resamplingY A ω.1 ω.2.1 = Y) = + bernoulliWeight ρ Y * resamplingZ ν A ρ Y := by + classical + simpa [bernoulliExpectation, mul_ite] using + resamplingExperiment_density_prob ν A hν hρ hρ1 (fun Y' => Y' = Y) + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/ResamplingEvents.lean b/lean/OAI/Combinatorics/GraphThreshold/ResamplingEvents.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e16a71e4339ef2510ff57218affc46c90df4f06 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/ResamplingEvents.lean @@ -0,0 +1,47 @@ +import OAI.Combinatorics.GraphThreshold.Resampling +import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Tactic + +namespace OAI + +/-! # Success and failure of a local resampling transition -/ + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +variable {X B : Type*} [DecidableEq X] [Fintype B] + +/-- The denominator is large enough and the retained fragment fits in the +halved integral capacity. -/ +def LocalSuccess (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) (m : ℕ) + (W : Finset X) (c b : B) : Prop := + Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A ρ (W ∪ A c) ∧ + (A b \ W).card ≤ m / 2 + +/-- A local failure is the complement of the actual local success event. -/ +def LocalFailure (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) (m : ℕ) + (W : Finset X) (c b : B) : Prop := + ¬ LocalSuccess ν A ρ m W c b + +theorem localFailure_iff (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) (m : ℕ) + (W : Finset X) (c b : B) : + LocalFailure ν A ρ m W c b ↔ + resamplingZ ν A ρ (W ∪ A c) < Real.exp (-10 * (m : ℝ)) ∨ + m / 2 < (A b \ W).card := by + simp only [LocalFailure, LocalSuccess, not_and_or, not_le] + +theorem localFailure_iff_twice (ν : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) (m : ℕ) + (W : Finset X) (c b : B) : + LocalFailure ν A ρ m W c b ↔ + resamplingZ ν A ρ (W ∪ A c) < Real.exp (-10 * (m : ℝ)) ∨ + m < 2 * (A b \ W).card := by + rw [localFailure_iff] + apply or_congr Iff.rfl + omega + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/SpreadCounting.lean b/lean/OAI/Combinatorics/GraphThreshold/SpreadCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..b53551e3fece7490d610fbaa7319406b55d370b7 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/SpreadCounting.lean @@ -0,0 +1,212 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Data.Nat.Choose.Sum +import Mathlib.Tactic + +namespace OAI + +/-! Exact intersection counting for a finite, weighted spread family. + +No injectivity of the label map and no strict positivity of individual weights +is required. The fixed target is an arbitrary finite set, and may be empty. +-/ + +noncomputable section + +open scoped BigOperators + +namespace LeanBlast.SecondKahnKalai + +variable {X B : Type*} [DecidableEq X] [Fintype B] + +/-- The spread bound also holds for the empty test set, by normalization. -/ +theorem IsSpread.containment_le {μ : FiniteLaw B} {A : B → Finset X} {a : ℝ} + (hs : IsSpread μ A a) (J : Finset X) : + μ.prob (fun c => J ⊆ A c) ≤ a ^ J.card := by + classical + by_cases hJ : J.Nonempty + · exact hs J hJ + · have hJ' : J = ∅ := Finset.not_nonempty_iff_eq_empty.mp hJ + simp [hJ', FiniteLaw.prob, μ.total] + +/-- If the intersection has at least `r` points, it contains an `r`-set +from the target. This is the weighted finite union bound. -/ +theorem intersection_card_ge_le_subsets (μ : FiniteLaw B) (A : B → Finset X) + (T : Finset X) (r : ℕ) : + μ.prob (fun c => r ≤ (A c ∩ T).card) ≤ + ∑ J ∈ T.powersetCard r, μ.prob (fun c => J ⊆ A c) := by + classical + unfold FiniteLaw.prob + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro c hc + by_cases hcr : r ≤ (A c ∩ T).card + · rw [ite_eq_left hcr] + obtain ⟨J, hJ, hJr⟩ := Finset.exists_subset_card_eq hcr + have hJA : J ⊆ A c := hJ.trans Finset.inter_subset_left + have hJT : J ⊆ T := hJ.trans Finset.inter_subset_right + have hm : J ∈ T.powersetCard r := Finset.mem_powersetCard.mpr ⟨hJT, hJr⟩ + have hsingle := Finset.single_le_sum + (f := fun J : Finset X => if J ⊆ A c then μ.weight c else 0) + (fun J _ => by split_ifs <;> + first | exact μ.nonneg c | exact le_rfl) hm + have hsingle' : μ.weight c ≤ + ∑ J ∈ T.powersetCard r, if J ⊆ A c then μ.weight c else 0 := by + simpa only [ite_eq_left hJA] using hsingle + refine hsingle'.trans_eq ?_ + apply Finset.sum_congr rfl + intro L hL + by_cases hLA : L ⊆ A c <;> simp [hLA] + · rw [ite_eq_right hcr] + exact Finset.sum_nonneg fun J _ => by + split_ifs <;> first | exact μ.nonneg c | exact le_rfl + +/-- Exact binomial count of potential witnesses bounds the intersection tail. -/ +theorem intersection_card_ge_le_target {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (T : Finset X) (r : ℕ) : + μ.prob (fun c => r ≤ (A c ∩ T).card) ≤ + (T.card.choose r : ℝ) * a ^ r := by + classical + calc + μ.prob (fun c => r ≤ (A c ∩ T).card) ≤ + ∑ J ∈ T.powersetCard r, μ.prob (fun c => J ⊆ A c) := + intersection_card_ge_le_subsets μ A T r + _ ≤ ∑ J ∈ T.powersetCard r, a ^ r := by + apply Finset.sum_le_sum + intro J hJ + simpa [(Finset.mem_powersetCard.mp hJ).2] using hs.containment_le J + _ = (T.card.choose r : ℝ) * a ^ r := by simp + +/-- Uniform capacity version, including `r = 0` and empty target sets. -/ +theorem intersection_card_ge_le {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) (r : ℕ) : + μ.prob (fun c => r ≤ (A c ∩ T).card) ≤ + (m.choose r : ℝ) * a ^ r := by + apply (intersection_card_ge_le_target hs T r).trans + apply mul_le_mul_of_nonneg_right _ (pow_nonneg ha r) + exact_mod_cast Nat.choose_le_choose r hT + +/-- The exact intersection histogram is bounded by the same binomial count. -/ +theorem intersection_card_eq_le {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) (r : ℕ) : + μ.prob (fun c => (A c ∩ T).card = r) ≤ + (m.choose r : ℝ) * a ^ r := by + classical + apply le_trans _ (intersection_card_ge_le hs ha hT r) + unfold FiniteLaw.prob + apply Finset.sum_le_sum + intro c hc + by_cases hcr : (A c ∩ T).card = r + · simp [hcr] + · simp only [ite_eq_right hcr] + split_ifs <;> first | exact μ.nonneg c | exact le_rfl + +/-- Reindex any function of the intersection by the exact finite histogram. -/ +theorem expectation_intersection_eq_sum (μ : FiniteLaw B) (A : B → Finset X) + {m : ℕ} {T : Finset X} (hT : T.card ≤ m) (g : ℕ → ℝ) : + μ.expectation (fun c => g (A c ∩ T).card) = + ∑ r ∈ Finset.range (m + 1), + μ.prob (fun c => (A c ∩ T).card = r) * g r := by + classical + unfold FiniteLaw.expectation FiniteLaw.prob + simp_rw [Finset.sum_mul, ite_mul, zero_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro c hc + have hcm : (A c ∩ T).card ∈ Finset.range (m + 1) := by + apply Finset.mem_range.mpr + have hct := Finset.card_le_card (Finset.inter_subset_right (s₁ := A c) (s₂ := T)) + omega + simp [hcm] + +/-- Any nonnegative function of the intersection admits a binomial majorant. -/ +theorem expectation_intersection_le_binomial {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) (g : ℕ → ℝ) (hg : ∀ r, 0 ≤ g r) : + μ.expectation (fun c => g (A c ∩ T).card) ≤ + ∑ r ∈ Finset.range (m + 1), (m.choose r : ℝ) * a ^ r * g r := by + rw [expectation_intersection_eq_sum μ A hT g] + exact Finset.sum_le_sum fun r _ => + mul_le_mul_of_nonneg_right (intersection_card_eq_le hs ha hT r) (hg r) + +/-- A predicate can truncate the intersection generating function arbitrarily. -/ +theorem intersection_truncated_moment_le {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) {t : ℝ} (ht : 0 ≤ t) + (Q : ℕ → Prop) [DecidablePred Q] : + μ.expectation (fun c => if Q (A c ∩ T).card then t ^ (A c ∩ T).card else 0) ≤ + ∑ r ∈ Finset.range (m + 1), + if Q r then (m.choose r : ℝ) * (a * t) ^ r else 0 := by + calc + _ ≤ ∑ r ∈ Finset.range (m + 1), + (m.choose r : ℝ) * a ^ r * (if Q r then t ^ r else 0) := by + apply expectation_intersection_le_binomial hs ha hT + (fun r => if Q r then t ^ r else 0) + intro r + split_ifs <;> first | exact pow_nonneg ht r | exact le_rfl + _ = _ := by + apply Finset.sum_congr rfl + intro r hr + by_cases hQ : Q r <;> simp [hQ, mul_pow, mul_assoc] + +/-- Raw-sum form of the truncated moment estimate. -/ +theorem intersection_truncated_sum_le {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) {t : ℝ} (ht : 0 ≤ t) + (Q : ℕ → Prop) [DecidablePred Q] : + (∑ c, if Q (A c ∩ T).card then μ.weight c * t ^ (A c ∩ T).card else 0) ≤ + ∑ r ∈ Finset.range (m + 1), + if Q r then (m.choose r : ℝ) * (a * t) ^ r else 0 := by + simpa only [FiniteLaw.expectation, mul_ite, mul_zero] using + intersection_truncated_moment_le hs ha hT ht Q + +/-- The full generating-function bound needs only a nonnegative argument. -/ +theorem intersection_moment_le {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) {t : ℝ} (ht : 0 ≤ t) : + μ.expectation (fun c => t ^ (A c ∩ T).card) ≤ (1 + a * t) ^ m := by + calc + _ ≤ ∑ r ∈ Finset.range (m + 1), (m.choose r : ℝ) * a ^ r * t ^ r := + expectation_intersection_le_binomial hs ha hT _ (fun r => pow_nonneg ht r) + _ = (1 + a * t) ^ m := by + rw [add_comm 1 (a * t), add_pow] + apply Finset.sum_congr rfl + intro r hr + simp only [one_pow, mul_one, mul_pow] + ring + +/-- Inverse-parameter moment used by the resampling density estimate. -/ +theorem intersection_inverse_moment_le {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) {ρ : ℝ} (hρ : 0 < ρ) : + μ.expectation (fun c => (ρ⁻¹) ^ (A c ∩ T).card) ≤ (1 + a / ρ) ^ m := by + simpa only [div_eq_mul_inv] using + intersection_moment_le hs ha hT (inv_nonneg.mpr hρ.le) + +/-- Raw-sum form of the inverse-parameter moment. -/ +theorem intersection_inverse_sum_le {μ : FiniteLaw B} {A : B → Finset X} + {a : ℝ} (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) {ρ : ℝ} (hρ : 0 < ρ) : + (∑ c, μ.weight c * (ρ⁻¹) ^ (A c ∩ T).card) ≤ (1 + a / ρ) ^ m := + intersection_inverse_moment_le hs ha hT hρ + +/-- Inverse-parameter truncated moment, retaining an arbitrary tail predicate. -/ +theorem intersection_inverse_truncated_sum_le + {μ : FiniteLaw B} {A : B → Finset X} {a : ℝ} + (hs : IsSpread μ A a) (ha : 0 ≤ a) {m : ℕ} + {T : Finset X} (hT : T.card ≤ m) {ρ : ℝ} (hρ : 0 < ρ) + (Q : ℕ → Prop) [DecidablePred Q] : + (∑ c, if Q (A c ∩ T).card then μ.weight c * (ρ⁻¹) ^ (A c ∩ T).card else 0) ≤ + ∑ r ∈ Finset.range (m + 1), + if Q r then (m.choose r : ℝ) * (a / ρ) ^ r else 0 := by + simpa only [div_eq_mul_inv] using + intersection_truncated_sum_le hs ha hT (inv_nonneg.mpr hρ.le) Q + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/Statement.lean b/lean/OAI/Combinatorics/GraphThreshold/Statement.lean new file mode 100644 index 0000000000000000000000000000000000000000..c75f83ef8f823be66d7be0a2f60015c411a52771 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/Statement.lean @@ -0,0 +1,20 @@ +import OAI.Combinatorics.GraphThreshold.Model + +namespace OAI + +noncomputable section + +universe u + +namespace LeanBlast.SecondKahnKalai + +def SecondKahnKalaiStatement : Prop := + ∀ (n : ℕ) (V : Type u) [Fintype V] (H : SimpleGraph V), + 2 ≤ n → Fintype.card V ≤ n → 1 ≤ edgeCount H → + SecondKahnKalaiBounds n H + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/ThresholdBounds.lean b/lean/OAI/Combinatorics/GraphThreshold/ThresholdBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..85f705e37098a7c9805321c2bbc0d230e198d2b9 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/ThresholdBounds.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.GraphThreshold.Thresholds +import Mathlib.Data.Nat.Choose.Bounds +import Mathlib.Analysis.SpecialFunctions.Log.Base + +namespace OAI + +/-! +# Explicit constants in the threshold conclusion + +The tree argument first gives a logarithm of an edge capacity. These elementary +bounds turn that quantity into the two constants stated for graphs. +-/ + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +theorem logTwo_eq_logb (x : ℝ) : logTwo x = Real.logb 2 x := rfl + +theorem logTwo_nonneg {x : ℝ} (hx : 1 ≤ x) : 0 ≤ logTwo x := by + unfold logTwo + exact div_nonneg (Real.log_nonneg hx) (Real.log_pos (by norm_num)).le + +theorem logTwo_mono {x y : ℝ} (hx : 0 < x) (hxy : x ≤ y) : + logTwo x ≤ logTwo y := by + unfold logTwo + exact div_le_div_of_nonneg_right (Real.log_le_log hx hxy) + (Real.log_pos (by norm_num)).le + +theorem edgeCount_le_sq {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + edgeCount H ≤ n ^ 2 := by + classical + rw [edgeCount_eq_card_edgeFinset] + calc + H.edgeFinset.card ≤ (Fintype.card V).choose 2 := + SimpleGraph.card_edgeFinset_le_card_choose_two + _ ≤ (Fintype.card V) ^ 2 := Nat.choose_le_pow _ _ + _ ≤ n ^ 2 := Nat.pow_le_pow_left hcard 2 + +theorem one_add_logTwo_le_three_logTwo (n h : ℕ) + (hn : 2 ≤ n) (hh : 1 ≤ h) (hhn : h ≤ n ^ 2) : + 1 + logTwo (h : ℝ) ≤ 3 * logTwo (n : ℝ) := by + have hn' : (2 : ℝ) ≤ n := by exact_mod_cast hn + have hh' : (1 : ℝ) ≤ h := by exact_mod_cast hh + have hhn' : (h : ℝ) ≤ (n : ℝ) ^ 2 := by exact_mod_cast hhn + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hlogn : Real.log 2 ≤ Real.log (n : ℝ) := + Real.log_le_log (by norm_num) hn' + have hone : 1 ≤ logTwo (n : ℝ) := by + unfold logTwo + exact (le_div_iff₀ hlog2).mpr (by simpa using hlogn) + have hlogh : Real.log (h : ℝ) ≤ 2 * Real.log (n : ℝ) := by + calc + Real.log (h : ℝ) ≤ Real.log ((n : ℝ) ^ 2) := + Real.log_le_log (by linarith) hhn' + _ = 2 * Real.log (n : ℝ) := by rw [Real.log_pow]; norm_num + have htwo : logTwo (h : ℝ) ≤ 2 * logTwo (n : ℝ) := by + unfold logTwo + simpa only [mul_div_assoc] using + div_le_div_of_nonneg_right hlogh hlog2.le + linarith + +theorem graph_one_add_logTwo_le_three_logTwo {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hn : 2 ≤ n) + (hcard : Fintype.card V ≤ n) (hedge : 1 ≤ edgeCount H) : + 1 + logTwo (edgeCount H : ℝ) ≤ 3 * logTwo (n : ℝ) := + one_add_logTwo_le_three_logTwo n (edgeCount H) hn hedge + (edgeCount_le_sq n H hcard) + +theorem graphThresholdParameter_mem_unitInterval (q : ℝ) (h : ℕ) + (hq : 0 ≤ q) (hh : 1 ≤ h) : + min 1 (2048 * Real.exp 50 * q * (1 + logTwo (h : ℝ))) ∈ Set.Icc 0 1 := by + have hlog : 0 ≤ logTwo (h : ℝ) := logTwo_nonneg (by exact_mod_cast hh) + constructor + · exact le_min (by norm_num) (mul_nonneg + (mul_nonneg (mul_nonneg (by norm_num) (Real.exp_pos 50).le) hq) (by linarith)) + · exact min_le_left _ _ + +theorem treeSamplingParameter_mem_unitInterval (q : ℝ) (m : ℕ) + (hq : 0 ≤ q) (hm : 0 < m) : + min 1 (16 * Real.exp 50 * (128 * q) * + (1 + Real.logb 2 (m : ℝ))) ∈ Set.Icc 0 1 := by + have hfactor : 16 * Real.exp 50 * (128 * q) = 2048 * Real.exp 50 * q := by ring + rw [hfactor, ← logTwo_eq_logb] + exact graphThresholdParameter_mem_unitInterval q m hq hm + +theorem treeSamplingParameter_le_graphParameter (q : ℝ) (m h : ℕ) + (hq : 0 ≤ q) (hm : 0 < m) (hmh : m ≤ h) : + min 1 (16 * Real.exp 50 * (128 * q) * (1 + Real.logb 2 (m : ℝ))) ≤ + min 1 (2048 * Real.exp 50 * q * (1 + logTwo (h : ℝ))) := by + apply min_le_min_left + have hlog : logTwo (m : ℝ) ≤ logTwo (h : ℝ) := + logTwo_mono (by exact_mod_cast hm) (by exact_mod_cast hmh) + calc + 16 * Real.exp 50 * (128 * q) * (1 + Real.logb 2 (m : ℝ)) = + 2048 * Real.exp 50 * q * (1 + logTwo (m : ℝ)) := by + rw [logTwo_eq_logb] + ring + _ ≤ 2048 * Real.exp 50 * q * (1 + logTwo (h : ℝ)) := + mul_le_mul_of_nonneg_left (by linarith) + (mul_nonneg (mul_nonneg (by norm_num) (Real.exp_pos 50).le) hq) + +theorem graphThresholdParameter_le_vertexBound {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (q : ℝ) (hn : 2 ≤ n) + (hcard : Fintype.card V ≤ n) (hedge : 1 ≤ edgeCount H) (hq : 0 ≤ q) : + min 1 (2048 * Real.exp 50 * q * (1 + logTwo (edgeCount H : ℝ))) ≤ + 6144 * Real.exp 50 * q * logTwo (n : ℝ) := by + calc + min 1 (2048 * Real.exp 50 * q * (1 + logTwo (edgeCount H : ℝ))) ≤ + 2048 * Real.exp 50 * q * (1 + logTwo (edgeCount H : ℝ)) := min_le_right _ _ + _ ≤ 2048 * Real.exp 50 * q * (3 * logTwo (n : ℝ)) := by + exact mul_le_mul_of_nonneg_left + (graph_one_add_logTwo_le_three_logTwo n H hn hcard hedge) + (mul_nonneg (mul_nonneg (by norm_num) (Real.exp_pos 50).le) hq) + _ = 6144 * Real.exp 50 * q * logTwo (n : ℝ) := by ring + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/Thresholds.lean b/lean/OAI/Combinatorics/GraphThreshold/Thresholds.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ea98e1817a9dbbc0d123ffa1d48eb3062ce9204 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/Thresholds.lean @@ -0,0 +1,200 @@ +import OAI.Combinatorics.GraphThreshold.Statement +import OAI.Combinatorics.GraphThreshold.GraphProbability +import Mathlib.Topology.Order.Monotone +import Mathlib.Tactic + +namespace OAI + +/-! +# Continuity and attainment of the graph thresholds + +Every probability is a literal finite sum of Bernoulli products. The +admissible parameter sets are closed subsets of `[0,1]`; endpoint feasibility +therefore makes their infima admissible. No minimizer is postulated. +-/ + +noncomputable section + +open scoped BigOperators + +namespace LeanBlast.SecondKahnKalai + +theorem continuous_bernoulliWeight {X : Type*} [Fintype X] [DecidableEq X] + (W : Finset X) : Continuous (fun p : ℝ => bernoulliWeight p W) := by + unfold bernoulliWeight + apply continuous_finsetProd + intro x _ + split_ifs <;> fun_prop + +theorem continuous_bernoulliExpectation {X : Type*} [Fintype X] [DecidableEq X] + (f : Finset X → ℝ) : Continuous (fun p : ℝ => bernoulliExpectation p f) := by + unfold bernoulliExpectation + apply continuous_finsetSum + intro W _ + exact (continuous_bernoulliWeight W).mul continuous_const + +theorem continuous_bernoulliProbability {X : Type*} [Fintype X] [DecidableEq X] + (P : Finset X → Prop) : Continuous (fun p : ℝ => bernoulliProbability p P) := by + classical + unfold bernoulliProbability + apply continuous_finsetSum + intro W _ + split_ifs + · exact continuous_bernoulliWeight W + · exact continuous_const + +theorem continuous_expectedCopies {V : Type*} (n : ℕ) (H : SimpleGraph V) : + Continuous (fun p : ℝ => expectedCopies n p H) := by + classical + exact continuous_bernoulliExpectation _ + +theorem continuous_containmentProbability {V : Type*} (n : ℕ) (H : SimpleGraph V) : + Continuous (fun p : ℝ => containmentProbability n p H) := by + classical + exact continuous_bernoulliProbability _ + +theorem isClosed_criticalFeasible {V : Type*} (n : ℕ) (H : SimpleGraph V) : + IsClosed {p : ℝ | p ∈ Set.Icc 0 1 ∧ + (1 / 2 : ℝ) ≤ containmentProbability n p H} := + isClosed_Icc.inter (isClosed_le continuous_const (continuous_containmentProbability n H)) + +theorem isClosed_expectationFeasible {V : Type*} (n : ℕ) (H : SimpleGraph V) : + IsClosed {p : ℝ | p ∈ Set.Icc 0 1 ∧ + ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n p F.coe} := by + have hc : IsClosed (⋂ F : H.Subgraph, + {p : ℝ | (1 / 2 : ℝ) ≤ expectedCopies n p F.coe}) := + isClosed_iInter (fun F : H.Subgraph => + isClosed_le continuous_const (continuous_expectedCopies n F.coe)) + convert (isClosed_Icc : IsClosed (Set.Icc (0 : ℝ) 1)).inter hc using 1 + ext p + simp + +/-- Endpoint feasibility is enough to ensure that the containment infimum +is attained; its probability need not be assumed monotone for this step. -/ +theorem criticalThreshold_attained_of_one {V : Type*} (n : ℕ) (H : SimpleGraph V) + (hone : (1 / 2 : ℝ) ≤ containmentProbability n 1 H) : + criticalThreshold n H ∈ Set.Icc 0 1 ∧ + (1 / 2 : ℝ) ≤ containmentProbability n (criticalThreshold n H) H := by + have hb : BddBelow {p : ℝ | p ∈ Set.Icc 0 1 ∧ + (1 / 2 : ℝ) ≤ containmentProbability n p H} := by + refine ⟨0, ?_⟩ + intro p hp + exact hp.1.1 + have hn : Set.Nonempty {p : ℝ | p ∈ Set.Icc 0 1 ∧ + (1 / 2 : ℝ) ≤ containmentProbability n p H} := + ⟨1, ⟨by norm_num, hone⟩⟩ + exact (isClosed_criticalFeasible n H).csInf_mem hn hb + +/-- All subgraph constraints hold at the expectation infimum. Arbitrary +intersections of closed constraints suffice, so no enumeration is assumed. -/ +theorem expectationThreshold_attained_of_one {V : Type*} (n : ℕ) (H : SimpleGraph V) + (hone : ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n 1 F.coe) : + expectationThreshold n H ∈ Set.Icc 0 1 ∧ + ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ + expectedCopies n (expectationThreshold n H) F.coe := by + have hb : BddBelow {p : ℝ | p ∈ Set.Icc 0 1 ∧ + ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n p F.coe} := by + refine ⟨0, ?_⟩ + intro p hp + exact hp.1.1 + have hn : Set.Nonempty {p : ℝ | p ∈ Set.Icc 0 1 ∧ + ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n p F.coe} := + ⟨1, ⟨by norm_num, hone⟩⟩ + exact (isClosed_expectationFeasible n H).csInf_mem hn hb + +/-- Any admissible parameter gives an upper bound on the actual critical +threshold. -/ +theorem criticalThreshold_le_of_probability {V : Type*} (n : ℕ) (H : SimpleGraph V) + {p : ℝ} (hp : p ∈ Set.Icc 0 1) + (hprob : (1 / 2 : ℝ) ≤ containmentProbability n p H) : + criticalThreshold n H ≤ p := by + unfold criticalThreshold + apply csInf_le + · refine ⟨0, ?_⟩ + intro q hq + exact hq.1.1 + · exact ⟨hp, hprob⟩ + +/-- A subgraph whose expectation vanishes at zero forces strict positivity +of the attained expectation threshold. -/ +theorem expectationThreshold_pos_of_zero_constraint {V : Type*} + (n : ℕ) (H : SimpleGraph V) + (hone : ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ expectedCopies n 1 F.coe) + (F : H.Subgraph) (hzero : expectedCopies n 0 F.coe = 0) : + 0 < expectationThreshold n H := by + have hatt := expectationThreshold_attained_of_one n H hone + have hne : expectationThreshold n H ≠ 0 := by + intro hz + have h := hatt.2 F + rw [hz, hzero] at h + norm_num at h + exact lt_of_le_of_ne hatt.1.1 (Ne.symm hne) + +theorem expectationFeasible_one {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) + (F : H.Subgraph) : (1 / 2 : ℝ) ≤ expectedCopies n 1 F.coe := by + classical + have hFcard : Fintype.card F.verts ≤ n := + (Fintype.card_le_of_injective (fun v : F.verts => (v : V)) Subtype.val_injective).trans hcard + exact (by norm_num : (1 / 2 : ℝ) ≤ 1).trans (expectedCopies_one_ge_one n F.coe hFcard) + +theorem criticalThreshold_attained {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + criticalThreshold n H ∈ Set.Icc 0 1 ∧ + (1 / 2 : ℝ) ≤ containmentProbability n (criticalThreshold n H) H := by + apply criticalThreshold_attained_of_one + rw [containmentProbability_one n H hcard] + norm_num + +/-- Every actual subgraph expectation constraint holds at `p_E`. -/ +theorem expectationThreshold_attained {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + expectationThreshold n H ∈ Set.Icc 0 1 ∧ + ∀ F : H.Subgraph, (1 / 2 : ℝ) ≤ + expectedCopies n (expectationThreshold n H) F.coe := + expectationThreshold_attained_of_one n H (expectationFeasible_one n H hcard) + +theorem criticalThreshold_mem_unitInterval {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + criticalThreshold n H ∈ Set.Icc 0 1 := + (criticalThreshold_attained n H hcard).1 + +theorem expectationThreshold_mem_unitInterval {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + expectationThreshold n H ∈ Set.Icc 0 1 := + (expectationThreshold_attained n H hcard).1 + +/-- Strict positivity follows from the constraint for an actual one-edge +subgraph, whose expected number of copies at parameter zero vanishes. -/ +theorem expectationThreshold_pos {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) + (hedge : 1 ≤ edgeCount H) : 0 < expectationThreshold n H := by + classical + have hne : H ≠ ⊥ := by + intro hz + have hzero := (edgeCount_eq_zero_iff H).mpr hz + omega + obtain ⟨v, w, hvw⟩ := SimpleGraph.ne_bot_iff_exists_adj.mp hne + let F : H.Subgraph := H.subgraphOfAdj hvw + let a : F.verts := ⟨v, by simp [F]⟩ + let b : F.verts := ⟨w, by simp [F]⟩ + have hab : F.coe.Adj a b := by + change s(v, w) = s(v, w) + rfl + have hFedge : 1 ≤ edgeCount F.coe := by + let : Nonempty F.coe.edgeSet := ⟨⟨s(a, b), hab⟩⟩ + exact Nat.card_pos + exact expectationThreshold_pos_of_zero_constraint n H + (expectationFeasible_one n H hcard) F (expectedCopies_zero n F.coe hFedge) + +theorem expectationThreshold_constraint_self {V : Type*} [Fintype V] + (n : ℕ) (H : SimpleGraph V) (hcard : Fintype.card V ≤ n) : + (1 / 2 : ℝ) ≤ expectedCopies n (expectationThreshold n H) H := by + have h := (expectationThreshold_attained n H hcard).2 (⊤ : H.Subgraph) + rwa [expectedCopies_iso n _ (SimpleGraph.Subgraph.topIso (G := H))] at h + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/TreeCovering.lean b/lean/OAI/Combinatorics/GraphThreshold/TreeCovering.lean new file mode 100644 index 0000000000000000000000000000000000000000..151c4c47ad00fb50693ab787ce66c139860f22c0 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/TreeCovering.lean @@ -0,0 +1,432 @@ +import OAI.Combinatorics.GraphThreshold.ProbabilityTreeTrim +import OAI.Combinatorics.GraphThreshold.CapacityIteration +import OAI.Combinatorics.GraphThreshold.AdaptiveTrials +import OAI.Combinatorics.GraphThreshold.TreeReduction +import OAI.Combinatorics.GraphThreshold.BernoulliMonotonicity +import OAI.Combinatorics.GraphThreshold.TreePotential +import Mathlib.Tactic + +namespace OAI + +/-! +# Covering a probability tree by iterative reductions + +Recovery keeps the original and retained path histories distinct, even when +their labels agree. All draws are retained in the accumulating union. +-/ + +noncomputable section +open Classical + +namespace LeanBlast.SecondKahnKalai + +/-- A nondecreasing finite list of capacities has a zero prefix followed by +strictly positive capacities. The empty positive suffix is permitted. -/ +theorem exists_zero_prefix_positive_suffix (m : ℕ → ℕ) (d : ℕ) + (hmono : MonotoneOn m (Set.Iio d)) : + ∃ k, k ≤ d ∧ (∀ i, i < k → m i = 0) ∧ + (∀ i, i < d - k → 0 < m (i + k)) := by + classical + by_cases h : ∃ k, k < d ∧ 0 < m k + · let k := Nat.find h + have hk : k < d ∧ 0 < m k := Nat.find_spec h + refine ⟨k, hk.1.le, ?_, ?_⟩ + · intro i hi + by_contra hzero + have hip : 0 < m i := Nat.pos_of_ne_zero hzero + have hki : k ≤ i := Nat.find_min' h ⟨lt_trans hi hk.1, hip⟩ + omega + · intro i hi + have hik : i + k < d := by omega + exact lt_of_lt_of_le hk.2 (hmono hk.1 hik (by omega)) + · refine ⟨d, le_rfl, ?_, ?_⟩ + · intro i hi + by_contra hzero + exact h ⟨i, hi, Nat.pos_of_ne_zero hzero⟩ + · intro i hi + omega + +theorem capacityReserve_div_sampling_le {σ : ℝ} (hσ : 0 < σ) (m : ℕ) : + capacityReserve σ m / (Real.exp 50 * (4 * σ)) ≤ Real.exp (-50) := by + have hp : 0 < Real.exp 50 * (4 * σ) := by positivity + calc + _ ≤ (4 * σ) / (Real.exp 50 * (4 * σ)) := + div_le_div_of_nonneg_right (capacityReserve_upper hσ.le m) hp.le + _ = Real.exp (-50) := by + rw [Real.exp_neg] + field_simp + +theorem sampling_budget_le {σ : ℝ} (hσ : 0 ≤ σ) (L : ℕ) : + ((4 * successesNeeded L : ℕ) : ℝ) * (Real.exp 50 * (4 * σ)) ≤ + 16 * Real.exp 50 * σ * (1 + Real.logb 2 (L : ℝ)) := by + calc + _ = (16 * Real.exp 50 * σ) * (successesNeeded L : ℝ) := by push_cast; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (successesNeeded_le_logb L) (by positivity) + +namespace ProbabilityTree + +variable {X : Type} [DecidableEq X] + +/-- Each path of a retained tree recovers a path of the original tree after +the already collected coordinates are added. -/ +def Recovers {d e : ℕ} (T : ProbabilityTree X d) (S : ProbabilityTree X e) + (W : Finset X) : Prop := + ∀ q : S.Path, ∃ p : T.Path, T.pathUnion p ⊆ W ∪ S.pathUnion q + +theorem Recovers.refl {d : ℕ} (T : ProbabilityTree X d) : Recovers T T ∅ := by + intro p + exact ⟨p, by simp⟩ + +theorem Recovers.mono {d e : ℕ} {T : ProbabilityTree X d} {S : ProbabilityTree X e} + {W V : Finset X} (h : Recovers T S W) (hWV : W ⊆ V) : Recovers T S V := by + intro q + obtain ⟨p, hp⟩ := h q + exact ⟨p, hp.trans (Finset.union_subset_union hWV (Finset.Subset.refl _))⟩ + +/-- Recovery composes through the union of the independent draws. -/ +theorem Recovers.trans {d e f : ℕ} + {T : ProbabilityTree X d} {S : ProbabilityTree X e} {U : ProbabilityTree X f} + {W V : Finset X} (hTS : Recovers T S W) (hSU : Recovers S U V) : + Recovers T U (W ∪ V) := by + intro r + obtain ⟨q, hq⟩ := hSU r + obtain ⟨p, hp⟩ := hTS q + refine ⟨p, ?_⟩ + simpa only [Finset.union_assoc] using + hp.trans (Finset.union_subset_union (Finset.Subset.refl W) hq) + +/-- A covered retained path yields a covered original path. -/ +theorem Recovers.coveredBy {d e : ℕ} {T : ProbabilityTree X d} {S : ProbabilityTree X e} + {W V : Finset X} (h : Recovers T S W) (hS : S.CoveredBy V) : + T.CoveredBy (W ∪ V) := by + obtain ⟨q, hq⟩ := hS + obtain ⟨p, hp⟩ := h q + exact ⟨p, hp.trans (Finset.union_subset_union (Finset.Subset.refl W) hq)⟩ + +/-- When no levels remain, recovery is already a covering certificate. -/ +theorem Recovers.coveredBy_of_depth_zero {d : ℕ} {T : ProbabilityTree X d} + {S : ProbabilityTree X 0} {W : Finset X} (h : Recovers T S W) : T.CoveredBy W := by + cases S + obtain ⟨p, hp⟩ := h PUnit.unit + exact ⟨p, by simpa only [pathUnion, Finset.union_empty] using hp⟩ + +theorem Recovers.coveredBy_of_depth_eq_zero {d e : ℕ} {T : ProbabilityTree X d} + {S : ProbabilityTree X e} {W : Finset X} (h : Recovers T S W) (he : e = 0) : + T.CoveredBy W := by + subst e + exact h.coveredBy_of_depth_zero + +/-- Removing empty initial labels preserves recovery without adding any +coordinates. The path lifting premise is supplied by deterministic prefix +removal. -/ +theorem Recovers.of_pathUnion_eq {d e : ℕ} + {T : ProbabilityTree X d} {S : ProbabilityTree X e} + (h : ∀ q : S.Path, ∃ p : T.Path, T.pathUnion p = S.pathUnion q) : + Recovers T S ∅ := by + intro q + obtain ⟨p, hp⟩ := h q + exact ⟨p, by simp [hp]⟩ + +/-- Increasing each nonnegative level spread parameter preserves spread. -/ +theorem HasSpread.mono {d : ℕ} {T : ProbabilityTree X d} {a b : ℕ → ℝ} + (hT : T.HasSpread a) (ha : ∀ i, i < d → 0 ≤ a i) + (hab : ∀ i, i < d → a i ≤ b i) : T.HasSpread b := by + induction T generalizing a b with + | leaf => trivial + | @node d B inst law positive label child ih => + constructor + · intro J hJ + exact (hT.1 J hJ).trans (pow_le_pow_left₀ (ha 0 (by omega)) (hab 0 (by omega)) _) + · intro c + exact ih c (hT.2 c) (fun i hi => ha (i + 1) (by omega)) + (fun i hi => hab (i + 1) (by omega)) + +theorem coveredBy_probability_one [Fintype X] {d : ℕ} (T : ProbabilityTree X d) : + bernoulliProbability 1 T.CoveredBy = 1 := by + apply le_antisymm + · exact (bernoulliLaw 1 (by norm_num) le_rfl).prob_le_one T.CoveredBy + · have h := (bernoulliLaw (X := X) 1 (by norm_num) le_rfl).prob_mono + (P := fun W => Finset.univ ⊆ W) (Q := T.CoveredBy) + (fun _ hW => coveredBy_mono (coveredBy_univ T) hW) + change bernoulliProbability 1 (fun W => Finset.univ ⊆ W) ≤ + bernoulliProbability 1 T.CoveredBy at h + simpa only [bernoulliProbability_subset, one_pow] using h + +/-- The actual retained tree, its spread budget, and recovery to the fixed +original tree. Only positive-capacity levels are stored. -/ +structure CoverState {k : ℕ} (original : ProbabilityTree X k) (σ : ℝ) where + depth : ℕ + tree : ProbabilityTree X depth + capacity : ℕ → ℕ + disjoint : tree.IsDisjoint + capacities : tree.HasCapacities capacity + spread : tree.HasSpread (fun i => capacityReserve σ (capacity i)) + positive : ∀ i, i < depth → 0 < capacity i + growth : ∀ i, i + 1 < depth → 16 * capacity i ≤ capacity (i + 1) + seen : Finset X + recovery : Recovers original tree seen + +namespace CoverState + +variable {k : ℕ} {original : ProbabilityTree X k} {σ : ℝ} + +def initial (original : ProbabilityTree X k) (σ : ℝ) (m : ℕ → ℕ) + (hσ : 0 < σ) (hdisjoint : original.IsDisjoint) + (hcapacity : original.HasCapacities m) + (hspread : original.HasSpread (fun _ => σ)) + (hpositive : ∀ i, i < k → 0 < m i) + (hgrowth : ∀ i, i + 1 < k → 16 * m i ≤ m (i + 1)) : CoverState original σ := + { depth := k + tree := original + capacity := m + disjoint := hdisjoint + capacities := hcapacity + spread := hspread.mono (fun _ _ => hσ.le) (fun i _ => capacityReserve_lower hσ.le (m i)) + positive := hpositive + growth := hgrowth + seen := ∅ + recovery := Recovers.refl original } + +def rank (state : CoverState original σ) : ℕ := + if state.depth = 0 then 0 else successesNeeded (state.capacity (state.depth - 1)) + +@[simp] theorem rank_eq_zero_iff (state : CoverState original σ) : + state.rank = 0 ↔ state.depth = 0 := by + unfold rank + split_ifs with h + · simp [h] + · simp [h, ne_of_gt (successesNeeded_pos _)] + +theorem coveredBy_of_rank_zero (state : CoverState original σ) (h : state.rank = 0) : + original.CoveredBy state.seen := + state.recovery.coveredBy_of_depth_eq_zero ((rank_eq_zero_iff state).mp h) + +/-- Every draw is retained even when the reduction attempt fails. -/ +def accumulate (state : CoverState original σ) (W : Finset X) : CoverState original σ := + { state with + seen := state.seen ∪ W + recovery := state.recovery.mono Finset.subset_union_left } + +@[simp] theorem accumulate_rank (state : CoverState original σ) (W : Finset X) : + (state.accumulate W).rank = state.rank := rfl + +def Advances (state : CoverState original σ) (W : Finset X) + (next : CoverState original σ) : Prop := + next.rank < state.rank ∧ next.seen = state.seen ∪ W + +/-- Choose a strict improvement when one exists; otherwise keep the tree. +Existence of improvements will be supplied by the actual good-tree reduction. -/ +def step (state : CoverState original σ) (W : Finset X) : CoverState original σ := + if h : ∃ next, state.Advances W next then Classical.choose h else state.accumulate W + +theorem step_seen (state : CoverState original σ) (W : Finset X) : + (state.step W).seen = state.seen ∪ W := by + unfold step + split_ifs with h + · exact (Classical.choose_spec h).2 + · rfl + +theorem step_rank_le (state : CoverState original σ) (W : Finset X) : + (state.step W).rank ≤ state.rank := by + unfold step + split_ifs with h + · exact (Classical.choose_spec h).1.le + · exact le_rfl + +theorem step_rank_lt_of_exists (state : CoverState original σ) (W : Finset X) + (h : ∃ next, state.Advances W next) : (state.step W).rank < state.rank := by + unfold step + rw [dite_eq_left h] + exact (Classical.choose_spec h).1 + +theorem biUnion_fin_succ {n : ℕ} (draws : Fin (n + 1) → Finset X) : + Finset.univ.biUnion draws = draws 0 ∪ Finset.univ.biUnion (fun i : Fin n => draws i.succ) := by + ext x + simp only [Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_union] + constructor + · rintro ⟨i, hi⟩ + refine Fin.cases (fun hx => Or.inl hx) (fun j hx => Or.inr ⟨j, hx⟩) i hi + · rintro (h | ⟨i, hi⟩) + · exact ⟨0, h⟩ + · exact ⟨i.succ, hi⟩ + +/-- The recorded set is exactly the union of all draws, including failures. -/ +theorem run_seen (n : ℕ) (state : CoverState original σ) (draws : Fin n → Finset X) : + (adaptiveRun step n state draws).seen = state.seen ∪ Finset.univ.biUnion draws := by + induction n generalizing state with + | zero => simp [adaptiveRun] + | succ n ih => + rw [adaptiveRun, ih, step_seen, biUnion_fin_succ, Finset.union_assoc] + +/-- The finite adaptive theorem transfers actual strict advances to covering. +The good-tree probability estimate supplies the premise in the final theorem. -/ +theorem prob_covered_of_advance_probability [Fintype X] (μ : FiniteLaw (Finset X)) + (hprogress : ∀ state : CoverState original σ, state.rank ≠ 0 → + (3 / 4 : ℝ) ≤ μ.prob (fun W => ∃ next, state.Advances W next)) + (s : ℕ) (state : CoverState original σ) (hrank : state.rank ≤ s) : + (2 / 3 : ℝ) ≤ (μ.iid (4 * s)).prob + (fun draws => original.CoveredBy (state.seen ∪ Finset.univ.biUnion draws)) := by + have hp : ∀ st : CoverState original σ, st.rank ≠ 0 → + (3 / 4 : ℝ) ≤ μ.prob (fun W => (st.step W).rank < st.rank) := by + intro st hst + exact (hprogress st hst).trans (μ.prob_mono fun W hW => st.step_rank_lt_of_exists W hW) + have hcomplete := adaptive_rank_completion μ rank step step_rank_le hp s state hrank + apply hcomplete.trans + apply (μ.iid (4 * s)).prob_mono + intro draws hdraws + have hcover := (adaptiveRun step (4 * s) state draws).coveredBy_of_rank_zero hdraws + rwa [run_seen] at hcover + +/-- A halved tree, after its zero prefix is removed, is a strict improvement +of the current positive-capacity tree. -/ +theorem exists_advance_of_halved (state : CoverState original σ) (W : Finset X) + (hdepth : state.depth ≠ 0) (U : ProbabilityTree X state.depth) + (hdisjoint : U.IsDisjoint) + (hcapacity : U.HasCapacities (fun i => state.capacity i / 2)) + (hspread : U.HasSpread (fun i => capacityReserve σ (state.capacity i / 2))) + (hrecovery : Recovers state.tree U W) : + ∃ next, state.Advances W next := by + let m : ℕ → ℕ := fun i => state.capacity i / 2 + have hgrowth : ∀ i, i + 1 < state.depth → 16 * m i ≤ m (i + 1) := by + intro i hi + simpa [m, reducedCapacity] using reducedCapacity_growth (state.growth i hi) 1 + obtain ⟨j, hj, hzero, hpositive⟩ := exists_zero_prefix_positive_suffix m state.depth + (monotoneOn_capacities m state.depth hgrowth) + let V := U.dropPrefix j hj + have htrim : Recovers U V ∅ := by + apply Recovers.of_pathUnion_eq + intro q + exact ⟨liftDropPrefixPath U j hj q, + pathUnion_liftDropPrefixPath_eq hcapacity j hj hzero q⟩ + let next : CoverState original σ := + { depth := state.depth - j + tree := V + capacity := fun i => m (i + j) + disjoint := dropPrefix_isDisjoint hdisjoint j hj + capacities := dropPrefix_hasCapacities hcapacity j hj + spread := dropPrefix_hasSpread hspread j hj + positive := hpositive + growth := by + intro i hi + simpa only [Nat.add_assoc, Nat.add_comm 1 j] using hgrowth (i + j) (by omega) + seen := state.seen ∪ W + recovery := by + simpa only [Finset.union_empty] using (state.recovery.trans hrecovery).trans htrim } + refine ⟨next, ?_, rfl⟩ + change (if state.depth - j = 0 then 0 else + successesNeeded (m (state.depth - j - 1 + j))) < state.rank + by_cases hempty : state.depth - j = 0 + · rw [ite_eq_left hempty] + exact Nat.pos_of_ne_zero (fun h => hdepth ((rank_eq_zero_iff state).mp h)) + · rw [ite_eq_right hempty] + have hindex : state.depth - j - 1 + j = state.depth - 1 := by omega + rw [hindex] + unfold rank + rw [ite_eq_right hdepth] + apply successesNeeded_half_lt + have hp := hpositive (state.depth - j - 1) (by omega) + simpa only [hindex] using hp + +/-- A good draw produces an actual strict advance: construct the pruned tree, +preserve the reserve budget, and delete exactly its zero-capacity prefix. -/ +theorem exists_advance_of_good (state : CoverState original σ) (W : Finset X) + (hσ : 0 < σ) {ρ : ℝ} (hρ : 0 < ρ) (hrank : state.rank ≠ 0) + (hgood : Good ρ state.capacity W state.tree) : + ∃ next, state.Advances W next := by + let U := reduceTree ρ state.capacity W state.tree hρ state.positive hgood + have ha : ∀ i, i < state.depth → 0 ≤ capacityReserve σ (state.capacity i) := + fun i _ => (capacityReserve_pos hσ (state.capacity i)).le + have hspread := reduceTree_hasSpread ρ state.capacity W state.tree hρ state.positive + hgood (fun i => capacityReserve σ (state.capacity i)) ha state.spread + refine state.exists_advance_of_halved W + (fun hd => hrank ((rank_eq_zero_iff state).mpr hd)) U + (reduceTree_isDisjoint ρ state.capacity W state.tree hρ state.positive hgood state.disjoint) + (reduceTree_hasCapacities ρ state.capacity W state.tree hρ state.positive hgood) ?_ + (reduceTree_path_recovery ρ state.capacity W state.tree hρ state.positive hgood) + exact hspread.mono + (fun i hi => div_nonneg (ha i hi) (retentionFactor_pos (state.positive i hi)).le) + (fun i hi => capacityReserve_div_le_half hσ.le (state.positive i hi)) + +end CoverState + +end ProbabilityTree + +/-- The finite random experiment and final parameter comparison. The next +theorem supplies this private lemma's progress estimate from actual reduction. -/ +private theorem tree_covering_of_progress {X : Type} [Fintype X] [DecidableEq X] + {k : ℕ} (T : ProbabilityTree X k) (hk : 0 < k) (hdis : T.IsDisjoint) + (m : ℕ → ℕ) (hcap : T.HasCapacities m) (hpos : ∀ i, i < k → 0 < m i) + (hgrowth : ∀ i, i + 1 < k → 16 * m i ≤ m (i + 1)) + (σ : ℝ) (hσ : 0 < σ) (hspread : T.HasSpread (fun _ => σ)) + (hprogress : Real.exp 50 * (4 * σ) < 1 → + ∀ state : ProbabilityTree.CoverState T σ, state.rank ≠ 0 → + (3 / 4 : ℝ) ≤ bernoulliProbability (Real.exp 50 * (4 * σ)) + (fun W => ∃ next, state.Advances W next)) : + (2 / 3 : ℝ) ≤ bernoulliProbability + (min 1 (16 * Real.exp 50 * σ * (1 + Real.logb 2 (m (k - 1) : ℝ)))) T.CoveredBy := by + let B := 16 * Real.exp 50 * σ * (1 + Real.logb 2 (m (k - 1) : ℝ)) + change (2 / 3 : ℝ) ≤ bernoulliProbability (min 1 B) T.CoveredBy + by_cases hB : 1 ≤ B + · rw [min_eq_left hB, ProbabilityTree.coveredBy_probability_one] + norm_num + have hB1 : B < 1 := lt_of_not_ge hB + let p := Real.exp 50 * (4 * σ) + have hp : 0 < p := by dsimp [p]; positivity + have hlog : 0 ≤ Real.logb 2 (m (k - 1) : ℝ) := + capacity_logb_nonneg (hpos (k - 1) (by omega)) + have hBp : 4 * p ≤ B := by + calc + 4 * p = (16 * Real.exp 50 * σ) * 1 := by dsimp [p]; ring + _ ≤ B := mul_le_mul_of_nonneg_left (by linarith : (1 : ℝ) ≤ + 1 + Real.logb 2 (m (k - 1) : ℝ)) (by positivity) + have hp1 : p < 1 := by linarith + let μ := bernoulliLaw (X := X) p hp.le hp1.le + let state := ProbabilityTree.CoverState.initial T σ m hσ hdis hcap hspread hpos hgrowth + let s := successesNeeded (m (k - 1)) + have hrank : state.rank ≤ s := by + change (if k = 0 then 0 else successesNeeded (m (k - 1))) ≤ s + rw [ite_eq_right (Nat.ne_of_gt hk)] + have hprog : ∀ st : ProbabilityTree.CoverState T σ, st.rank ≠ 0 → + (3 / 4 : ℝ) ≤ μ.prob (fun W => ∃ next, st.Advances W next) := + fun st hst => hprogress hp1 st hst + have hc := ProbabilityTree.CoverState.prob_covered_of_advance_probability μ hprog s state hrank + have hseen : state.seen = ∅ := rfl + simp only [hseen, Finset.empty_union] at hc + change (2 / 3 : ℝ) ≤ ((bernoulliLaw p hp.le hp1.le).iid (4 * s)).prob + (fun draws => T.CoveredBy (Finset.univ.biUnion draws)) at hc + rw [iid_bernoulli_union_probability] at hc + have hq0 := (bernoulli_union_parameter_mem hp.le hp1.le (4 * s)).1 + have hqB : 1 - (1 - p) ^ (4 * s) ≤ B := + (bernoulli_union_parameter_le hp.le hp1.le (4 * s)).trans + (sampling_budget_le hσ.le (m (k - 1))) + have hmono := bernoulliProbability_mono_parameter hq0 hqB hB1.le T.CoveredBy + (fun _ _ hUV hU => ProbabilityTree.coveredBy_mono hU hUV) + rw [min_eq_right hB1.le] + exact hc.trans hmono + +theorem tree_covering {X : Type} [Fintype X] [DecidableEq X] {k : ℕ} + (T : ProbabilityTree X k) (hk : 0 < k) (hdis : T.IsDisjoint) + (m : ℕ → ℕ) (hcap : T.HasCapacities m) (hpos : ∀ i, i < k → 0 < m i) + (hgrowth : ∀ i, i + 1 < k → 16 * m i ≤ m (i + 1)) + (σ : ℝ) (hσ : 0 < σ) (hspread : T.HasSpread (fun _ => σ)) : + (2 / 3 : ℝ) ≤ bernoulliProbability + (min 1 (16 * Real.exp 50 * σ * (1 + Real.logb 2 (m (k - 1) : ℝ)))) T.CoveredBy := by + apply tree_covering_of_progress T hk hdis m hcap hpos hgrowth σ hσ hspread + intro hp1 state hrank + have hp : 0 < Real.exp 50 * (4 * σ) := by positivity + have hgood := reduction_good_probability_ge hp hp1 state.capacity + (fun i => capacityReserve σ (state.capacity i)) state.tree + state.disjoint state.capacities state.spread state.positive + (fun i _ => (capacityReserve_pos hσ (state.capacity i)).le) + (fun i _ => capacityReserve_div_sampling_le hσ (state.capacity i)) state.growth + have hmono := (bernoulliLaw (X := X) (Real.exp 50 * (4 * σ)) hp.le hp1.le).prob_mono + (P := fun W => Good (Real.exp 50 * (4 * σ)) state.capacity W state.tree) + (Q := fun W => ∃ next, state.Advances W next) + (fun W hW => state.exists_advance_of_good W hσ hp hrank hW) + exact hgood.trans hmono + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/TreePotential.lean b/lean/OAI/Combinatorics/GraphThreshold/TreePotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a04b4b78d74849612992effe7b025b856e24af9 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/TreePotential.lean @@ -0,0 +1,345 @@ +import OAI.Combinatorics.GraphThreshold.Basic +import OAI.Combinatorics.GraphThreshold.FiniteProbability +import OAI.Combinatorics.GraphThreshold.ProbabilityTreeFacts +import OAI.Combinatorics.GraphThreshold.TreeReductionData +import OAI.Combinatorics.GraphThreshold.OutsideChangeOfMeasure +import OAI.Combinatorics.GraphThreshold.LocalFailure +import OAI.Combinatorics.GraphThreshold.CapacityIteration +import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Tactic + +namespace OAI + +/-! +# The bad-node potential for simultaneous tree reduction + +All nodes in a reduction use the same random set. The expectation argument +uses an outside-coordinate change of measure, rather than independence of +node outcomes. +-/ + +noncomputable section + +open scoped BigOperators +open Classical + +namespace LeanBlast.SecondKahnKalai + +/-- One step of the actual recursive bad-node potential. -/ +def nodePotential {B : Type*} [Fintype B] (m : ℕ) (failure : ℝ) + (target childPotential : B → ℝ) : ℝ := + (failure + ∑ b, target b * childPotential b) / Real.exp (-(m : ℝ)) + +theorem nodePotential_nonneg {B : Type*} [Fintype B] (m : ℕ) (failure : ℝ) + (target childPotential : B → ℝ) (hf : 0 ≤ failure) + (ht : ∀ b, 0 ≤ target b) (hc : ∀ b, 0 ≤ childPotential b) : + 0 ≤ nodePotential m failure target childPotential := by + exact div_nonneg (add_nonneg hf (Finset.sum_nonneg (fun b _ => mul_nonneg (ht b) (hc b)))) + (Real.exp_pos _).le + +/-- A failed good-mass threshold forces the recursively defined potential +above one. Children with zero target mass require no special treatment. -/ +theorem one_lt_nodePotential_of_bad {B : Type*} [Fintype B] + (m : ℕ) (failure : ℝ) (target childPotential : B → ℝ) (good : B → Prop) + (ht : ∀ b, 0 ≤ target b) (hc : ∀ b, 0 ≤ childPotential b) + (hmass : failure + ∑ b, target b = 1) + (hchild : ∀ b, ¬good b → 1 < childPotential b) + (hbad : (∑ b, if good b then target b else 0) < 1 - Real.exp (-(m : ℝ))) : + 1 < nodePotential m failure target childPotential := by + classical + have hsplit : (∑ b, if good b then target b else 0) + + (∑ b, if good b then 0 else target b) = ∑ b, target b := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro b _ + by_cases hb : good b <;> simp [hb] + have hsum : (∑ b, if good b then 0 else target b) ≤ + ∑ b, target b * childPotential b := by + apply Finset.sum_le_sum + intro b _ + by_cases hb : good b + · simpa only [ite_eq_left hb] using mul_nonneg (ht b) (hc b) + · simpa only [ite_eq_right hb, mul_one] using + mul_le_mul_of_nonneg_left (hchild b hb).le (ht b) + unfold nodePotential + apply (lt_div_iff₀ (Real.exp_pos _)).mpr + nlinarith + +theorem bernoulliExpectation_nodePotential {X B : Type*} [Fintype X] [DecidableEq X] + [Fintype B] (p : ℝ) (m : ℕ) (failure : Finset X → ℝ) + (target childPotential : B → Finset X → ℝ) : + bernoulliExpectation p (fun W => nodePotential m (failure W) + (fun b => target b W) (fun b => childPotential b W)) = + (bernoulliExpectation p failure + + ∑ b, bernoulliExpectation p (fun W => target b W * childPotential b W)) / + Real.exp (-(m : ℝ)) := by + unfold bernoulliExpectation nodePotential + dsimp only + rw [Finset.sum_comm, ← Finset.sum_add_distrib, Finset.sum_div] + apply Finset.sum_congr rfl + intro W _ + rw [← mul_div_assoc, mul_add, Finset.mul_sum] + +/-- The expectation recursion uses one change-of-measure estimate per child; +it does not factor a product of dependent random variables. -/ +theorem bernoulliExpectation_nodePotential_le {X B : Type*} [Fintype X] [DecidableEq X] + [Fintype B] (p : ℝ) (m : ℕ) (ν : FiniteLaw B) (failure : Finset X → ℝ) + (target childPotential : B → Finset X → ℝ) + (hfailure : bernoulliExpectation p failure ≤ Real.exp (-9 * (m : ℝ))) + (hchild : ∀ b, + bernoulliExpectation p (fun W => target b W * childPotential b W) ≤ + Real.exp (11 * (m : ℝ)) * ν.weight b * bernoulliExpectation p (childPotential b)) : + bernoulliExpectation p (fun W => nodePotential m (failure W) + (fun b => target b W) (fun b => childPotential b W)) ≤ + Real.exp (-8 * (m : ℝ)) + Real.exp (12 * (m : ℝ)) * + ν.expectation (fun b => bernoulliExpectation p (childPotential b)) := by + rw [bernoulliExpectation_nodePotential] + have hs := Finset.sum_le_sum (fun b (_ : b ∈ Finset.univ) => hchild b) + have hsum : (∑ b, Real.exp (11 * (m : ℝ)) * ν.weight b * + bernoulliExpectation p (childPotential b)) = + Real.exp (11 * (m : ℝ)) * ν.expectation + (fun b => bernoulliExpectation p (childPotential b)) := by + unfold FiniteLaw.expectation + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro b _ + ring + have hbound := div_le_div_of_nonneg_right (add_le_add hfailure hs) (Real.exp_pos (-(m : ℝ))).le + rw [hsum] at hbound + refine hbound.trans_eq ?_ + have hfirst : Real.exp (-9 * (m : ℝ)) / Real.exp (-(m : ℝ)) = + Real.exp (-8 * (m : ℝ)) := by + rw [← Real.exp_sub] + congr 1 + ring + have hsecond : Real.exp (11 * (m : ℝ)) / Real.exp (-(m : ℝ)) = + Real.exp (12 * (m : ℝ)) := by + rw [← Real.exp_sub] + congr 1 + ring + rw [add_div, hfirst, mul_div_right_comm, hsecond] + +/-- Deterministic envelope obtained by iterating the expectation recursion. -/ +def potentialEnvelope : ℕ → (ℕ → ℕ) → ℝ + | 0, _ => 0 + | d + 1, m => Real.exp (-8 * (m 0 : ℝ)) + Real.exp (12 * (m 0 : ℝ)) * + potentialEnvelope d (fun j => m (j + 1)) + +theorem potentialEnvelope_eq_sum (d : ℕ) (m : ℕ → ℕ) : + potentialEnvelope d m = + ∑ j ∈ Finset.range d, + Real.exp (12 * (∑ h ∈ Finset.range j, (m h : ℝ)) - 8 * (m j : ℝ)) := by + induction d generalizing m with + | zero => simp [potentialEnvelope] + | succ d ih => + rw [potentialEnvelope, ih, Finset.sum_range_succ'] + simp only [Finset.range_zero, Finset.sum_empty, mul_zero, zero_sub, neg_mul] + rw [Finset.mul_sum] + rw [add_comm] + congr 1 + apply Finset.sum_congr rfl + intro j _ + rw [← Real.exp_add, Finset.sum_range_succ'] + congr 1 + ring + +section Trees + +variable {X : Type} [Fintype X] [DecidableEq X] + +def treePotential (p : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} + (T : ProbabilityTree X d) : ℝ := + match T with + | .leaf => 0 + | @ProbabilityTree.node _ _ B inst ν hν A child => + nodePotential (m 0) (localFailureMass ν A p (m 0) W) + (successfulTargetMass ν A p (m 0) W) + (fun b => treePotential p (fun j => m (j + 1)) W (child b)) +termination_by d + +omit [Fintype X] in +theorem treePotential_nonneg {p : ℝ} (hp : 0 ≤ p) (m : ℕ → ℕ) (W : Finset X) + {d : ℕ} (T : ProbabilityTree X d) : 0 ≤ treePotential p m W T := by + induction T generalizing m with + | leaf => simp only [treePotential, le_refl] + | @node d B inst ν hν A child ih => + simp only [treePotential] + exact nodePotential_nonneg (m 0) _ _ _ (localFailureMass_nonneg ν A hp (m 0) W) + (fun b => successfulTargetMass_nonneg ν A hp (m 0) W b) + (fun b => ih b (fun j => m (j + 1))) + +omit [Fintype X] in +theorem one_lt_treePotential_of_not_good {p : ℝ} (hp : 0 < p) (m : ℕ → ℕ) + (W : Finset X) {d : ℕ} (T : ProbabilityTree X d) (hbad : ¬Good p m W T) : + 1 < treePotential p m W T := by + induction T generalizing m with + | leaf => simp only [Good, not_true_eq_false] at hbad + | @node d B inst ν hν A child ih => + simp only [treePotential] + simp only [Good] at hbad + apply one_lt_nodePotential_of_bad (m 0) _ _ _ + (fun b => Good p (fun j => m (j + 1)) W (child b)) + · exact fun b => successfulTargetMass_nonneg ν A hp.le _ W b + · exact fun b => treePotential_nonneg hp.le _ W (child b) + · exact localFailureMass_add_successfulTargetMass ν A hν hp (m 0) W + · exact fun b hb => ih b _ hb + · exact lt_of_not_ge hbad + +omit [Fintype X] in +/-- The potential only inspects the labels belonging to the fixed subtree. -/ +theorem treePotential_dependsOnlyOn (p : ℝ) (m : ℕ → ℕ) {d : ℕ} + (T : ProbabilityTree X d) : DependsOnlyOn T.support (fun W => treePotential p m W T) := by + induction T generalizing m with + | leaf => intro W V _; simp only [treePotential] + | @node d B inst ν hν A child ih => + intro W V hWV + have hd := ((localFailureMass_dependsOnlyOn ν A p (m 0)).mono + (ProbabilityTree.labels_support_subset ν hν A child)) W V hWV + have ht (b : B) := ((successfulTargetMass_dependsOnlyOn ν A p (m 0) b).mono + (ProbabilityTree.labels_support_subset ν hν A child)) W V hWV + have hc (b : B) := ((ih b (fun j => m (j + 1))).mono + (ProbabilityTree.child_support_subset ν hν A child b)) W V hWV + dsimp only at hd ht hc + simp only [treePotential, nodePotential] + rw [hd] + congr 2 + apply Finset.sum_congr rfl + intro b _ + rw [ht b, hc b] + +omit [Fintype X] in +/-- Path disjointness makes a descendant potential insensitive to its +incoming label; this is the locality needed by the change of measure. -/ +theorem child_treePotential_dependsOutside {d : ℕ} {B : Type} [Fintype B] + (ν : FiniteLaw B) (hν : ν.IsPositive) (A : B → Finset X) + (child : B → ProbabilityTree X d) + (hdis : (ProbabilityTree.node B ν hν A child).IsDisjoint) + (p : ℝ) (m : ℕ → ℕ) (b : B) : + DependsOutside (A b) (fun W => treePotential p m W (child b)) := + ProbabilityTree.child_dependsOutside hdis b (treePotential_dependsOnlyOn p m (child b)) + +theorem bad_probability_le_expected_treePotential {p : ℝ} (hp : 0 < p) (hp1 : p ≤ 1) + (m : ℕ → ℕ) {d : ℕ} (T : ProbabilityTree X d) : + bernoulliProbability p (fun W => ¬Good p m W T) ≤ + bernoulliExpectation p (fun W => treePotential p m W T) := by + exact (bernoulliLaw p hp.le hp1).prob_le_expectation (fun W => ¬Good p m W T) + (fun W => treePotential p m W T) (fun W => treePotential_nonneg hp.le m W T) + (fun W hW => (one_lt_treePotential_of_not_good hp m W T hW).le) + +omit [Fintype X] in +private theorem localFailureMass_eq_probability {B : Type} [Fintype B] + (ν : FiniteLaw B) (hν : ν.IsPositive) (A : B → Finset X) + {p : ℝ} (hp : 0 < p) (m : ℕ) (W : Finset X) : + localFailureMass ν A p m W = + (resamplingLaw ν A p W hν hp).prob (fun cb => LocalFailure ν A p m W cb.1 cb.2) := by + simp only [localFailureMass, FiniteLaw.prob, resamplingLaw_weight, Fintype.sum_prod_type] + exact Finset.sum_comm + +omit [Fintype X] in +theorem successfulTargetMass_le_cutoff {B : Type} [Fintype B] + (ν : FiniteLaw B) (A : B → Finset X) {p : ℝ} (hp : 0 ≤ p) + (m : ℕ) (W : Finset X) (b : B) : + successfulTargetMass ν A p m W b ≤ + cutoffTargetMass ν A p (Real.exp (-10 * (m : ℝ))) W b := by + unfold successfulTargetMass cutoffTargetMass + apply Finset.sum_le_sum + intro c _ + by_cases hsuccess : LocalSuccess ν A p m W c b + · have hcut : Real.exp (-10 * (m : ℝ)) ≤ resamplingZ ν A p (resamplingY A W c) := + hsuccess.1 + simp only [ite_eq_left hsuccess, ite_eq_left hcut, le_refl] + · simp only [ite_eq_right hsuccess] + split_ifs + · exact resamplingWeight_nonneg ν A hp W (c, b) + · exact le_rfl + +theorem treePotential_expectation_node_le {d : ℕ} {B : Type} [Fintype B] + (ν : FiniteLaw B) (hν : ν.IsPositive) (A : B → Finset X) + (child : B → ProbabilityTree X d) (m : ℕ → ℕ) + {p a : ℝ} (hp : 0 < p) (hp1 : p < 1) (ha : 0 ≤ a) + (hspread : IsSpread ν A a) (hm : 1 ≤ m 0) + (hsize : ∀ b, (A b).card ≤ m 0) (hsmall : a / p ≤ Real.exp (-50)) + (hdis : (ProbabilityTree.node B ν hν A child).IsDisjoint) : + bernoulliExpectation p (fun W => treePotential p m W (ProbabilityTree.node B ν hν A child)) ≤ + Real.exp (-8 * (m 0 : ℝ)) + Real.exp (12 * (m 0 : ℝ)) * + ν.expectation (fun b => bernoulliExpectation p + (fun W => treePotential p (fun j => m (j + 1)) W (child b))) := by + simp only [treePotential] + apply bernoulliExpectation_nodePotential_le p (m 0) ν + · have h := local_failure_bound ν A hν hp hp1 (m 0) hm hsize hspread ha hsmall + simpa only [← localFailureMass_eq_probability ν hν A hp (m 0)] using h + · intro b + exact outside_change_of_measure_of_le ν A hp hp1.le ha hspread (m 0) b (hsize b) hsmall + (fun W => treePotential p (fun j => m (j + 1)) W (child b)) + (fun W => treePotential_nonneg hp.le _ W (child b)) + (child_treePotential_dependsOutside ν hν A child hdis p _ b) + (fun W => successfulTargetMass ν A p (m 0) W b) + (fun W => successfulTargetMass_le_cutoff ν A hp.le (m 0) W b) + +theorem treePotential_expectation_le {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (m : ℕ → ℕ) (a : ℕ → ℝ) {d : ℕ} (T : ProbabilityTree X d) + (hdis : T.IsDisjoint) (hcap : T.HasCapacities m) (hspread : T.HasSpread a) + (hm : ∀ j, j < d → 1 ≤ m j) (ha : ∀ j, j < d → 0 ≤ a j) + (hsmall : ∀ j, j < d → a j / p ≤ Real.exp (-50)) : + bernoulliExpectation p (fun W => treePotential p m W T) ≤ potentialEnvelope d m := by + induction T generalizing m a with + | leaf => simp [treePotential, potentialEnvelope, bernoulliExpectation] + | @node d B inst ν hν A child ih => + have hnode := treePotential_expectation_node_le ν hν A child m hp hp1 + (ha 0 (by omega)) hspread.1 (hm 0 (by omega)) hcap.1 (hsmall 0 (by omega)) hdis + have hchild (b : B) : bernoulliExpectation p + (fun W => treePotential p (fun j => m (j + 1)) W (child b)) ≤ + potentialEnvelope d (fun j => m (j + 1)) := by + apply ih b (fun j => m (j + 1)) (fun j => a (j + 1)) (hdis.2 b) (hcap.2 b) (hspread.2 b) + · intro j hj + exact hm (j + 1) (by omega) + · intro j hj + exact ha (j + 1) (by omega) + · intro j hj + exact hsmall (j + 1) (by omega) + have havg : ν.expectation (fun b => bernoulliExpectation p + (fun W => treePotential p (fun j => m (j + 1)) W (child b))) ≤ + potentialEnvelope d (fun j => m (j + 1)) := by + unfold FiniteLaw.expectation + calc + _ ≤ ∑ b, ν.weight b * potentialEnvelope d (fun j => m (j + 1)) := + Finset.sum_le_sum (fun b _ => mul_le_mul_of_nonneg_left (hchild b) (ν.nonneg b)) + _ = _ := by rw [← Finset.sum_mul, ν.total, one_mul] + exact hnode.trans (add_le_add le_rfl + (mul_le_mul_of_nonneg_left havg (Real.exp_pos _).le)) + +/-- One simultaneous reduction fails with probability strictly below one +quarter under the geometric level-capacity assumptions. -/ +theorem root_bad_probability_lt_one_quarter {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (m : ℕ → ℕ) (a : ℕ → ℝ) {d : ℕ} (T : ProbabilityTree X d) + (hdis : T.IsDisjoint) (hcap : T.HasCapacities m) (hspread : T.HasSpread a) + (hm : ∀ j, j < d → 1 ≤ m j) (ha : ∀ j, j < d → 0 ≤ a j) + (hsmall : ∀ j, j < d → a j / p ≤ Real.exp (-50)) + (hgrowth : ∀ j, j + 1 < d → 16 * m j ≤ m (j + 1)) : + bernoulliProbability p (fun W => ¬Good p m W T) < 1 / 4 := by + have hbound := (bad_probability_le_expected_treePotential hp hp1.le m T).trans + (treePotential_expectation_le hp hp1 m a T hdis hcap hspread hm ha hsmall) + rw [potentialEnvelope_eq_sum] at hbound + exact hbound.trans_lt (capacity_failure_sum_lt_one_quarter m d hm hgrowth) + +theorem reduction_good_probability_ge {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (m : ℕ → ℕ) (a : ℕ → ℝ) {d : ℕ} (T : ProbabilityTree X d) + (hdis : T.IsDisjoint) (hcap : T.HasCapacities m) (hspread : T.HasSpread a) + (hm : ∀ j, j < d → 1 ≤ m j) (ha : ∀ j, j < d → 0 ≤ a j) + (hsmall : ∀ j, j < d → a j / p ≤ Real.exp (-50)) + (hgrowth : ∀ j, j + 1 < d → 16 * m j ≤ m (j + 1)) : + 3 / 4 ≤ bernoulliProbability p (fun W => Good p m W T) := by + have hbad := root_bad_probability_lt_one_quarter hp hp1 m a T + hdis hcap hspread hm ha hsmall hgrowth + have hcompl := (bernoulliLaw (X := X) p hp.le hp1.le).prob_compl (fun W => Good p m W T) + change bernoulliProbability p (fun W => ¬Good p m W T) = + 1 - bernoulliProbability p (fun W => Good p m W T) at hcompl + linarith + +end Trees + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/TreeReduction.lean b/lean/OAI/Combinatorics/GraphThreshold/TreeReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3a1363c2044d64b463d52672d47dd64a5a72d41 --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/TreeReduction.lean @@ -0,0 +1,289 @@ +import OAI.Combinatorics.GraphThreshold.TreeReductionData +import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Tactic + +namespace OAI + +open scoped BigOperators +open Classical + +noncomputable section + +namespace LeanBlast.SecondKahnKalai + +section RetainedLaw + +variable {B X : Type*} [Fintype B] [DecidableEq X] + +def retainedMass (w : B → ℝ) (G : B → Prop) : ℝ := + ∑ b, if G b then w b else 0 + +abbrev RetainedIndex (w : B → ℝ) (G : B → Prop) := {b : B // G b ∧ 0 < w b} + +theorem sum_retained (w : B → ℝ) (G : B → Prop) (hw : ∀ b, 0 ≤ w b) (f : B → ℝ) : + (∑ b : RetainedIndex w G, w b * f b) = ∑ b, if G b then w b * f b else 0 := by + symm + apply Finset.sum_congr_set {b | G b ∧ 0 < w b} + · intro b hb + simp only [Set.mem_ofPred_eq] at hb + simp [hb.1] + · intro b hb + by_cases hg : G b + · have hnot : ¬ 0 < w b := fun hpos => hb ⟨hg, hpos⟩ + have hz : w b = 0 := le_antisymm (le_of_not_gt hnot) (hw b) + simp [hg, hz] + · simp [hg] + +theorem sum_retained_weights (w : B → ℝ) (G : B → Prop) (hw : ∀ b, 0 ≤ w b) : + (∑ b : RetainedIndex w G, w b) = retainedMass w G := by + simpa only [mul_one, retainedMass] using sum_retained w G hw (fun _ => 1) + +theorem sum_retained_indicator (w : B → ℝ) (G Q : B → Prop) (hw : ∀ b, 0 ≤ w b) : + (∑ b : RetainedIndex w G, if Q b then w b else 0) = + ∑ b, if G b ∧ Q b then w b else 0 := by + simpa only [mul_ite, mul_one, mul_zero, ite_and] using + sum_retained w G hw (fun b => if Q b then 1 else 0) + +/-- The actual normalized child law, after removing all zero-mass targets. -/ +def retainedLaw (w : B → ℝ) (G : B → Prop) (hw : ∀ b, 0 ≤ w b) + (hpos : 0 < retainedMass w G) : FiniteLaw (RetainedIndex w G) where + weight b := w b / retainedMass w G + nonneg b := div_nonneg (hw b) hpos.le + total := by + rw [← Finset.sum_div, sum_retained_weights w G hw] + exact div_self hpos.ne' + +theorem retainedLaw_positive (w : B → ℝ) (G : B → Prop) (hw : ∀ b, 0 ≤ w b) + (hpos : 0 < retainedMass w G) : (retainedLaw w G hw hpos).IsPositive := by + intro b + exact div_pos b.property.2 hpos + +theorem retainedLaw_prob (w : B → ℝ) (G Q : B → Prop) (hw : ∀ b, 0 ≤ w b) + (hpos : 0 < retainedMass w G) : + (retainedLaw w G hw hpos).prob (fun b => Q b) = + (∑ b, if G b ∧ Q b then w b else 0) / retainedMass w G := by + rw [← sum_retained_indicator w G Q hw, Finset.sum_div] + unfold FiniteLaw.prob + apply Finset.sum_congr rfl + intro b _ + by_cases hq : Q b <;> simp [retainedLaw, hq] + +theorem retainedLaw_isSpread (w : B → ℝ) (G : B → Prop) (hw : ∀ b, 0 ≤ w b) + (hpos : 0 < retainedMass w G) (F : B → Finset X) {a q : ℝ} + (ha : 0 ≤ a) (hq : 0 < q) (hq1 : q ≤ 1) (hretain : q ≤ retainedMass w G) + (hnum : ∀ J : Finset X, J.Nonempty → + (∑ b, if G b ∧ J ⊆ F b then w b else 0) ≤ a ^ J.card) : + IsSpread (retainedLaw w G hw hpos) (fun b => F b) (a / q) := by + classical + intro J hJ + change (retainedLaw w G hw hpos).prob (fun b => J ⊆ F b.val) ≤ (a / q) ^ J.card + rw [retainedLaw_prob w G (fun b => J ⊆ F b) hw hpos] + have hpower : q ^ J.card ≤ q := + pow_le_of_le_one hq.le hq1 (Nat.ne_of_gt hJ.card_pos) + calc + _ ≤ a ^ J.card / retainedMass w G := by + apply div_le_div_of_nonneg_right _ hpos.le + convert hnum J hJ using 1 + apply Finset.sum_congr rfl + intro b _ + by_cases hb : G b ∧ J ⊆ F b <;> simp [hb] + _ ≤ a ^ J.card / q := div_le_div_of_nonneg_left (pow_nonneg ha _) hq hretain + _ ≤ a ^ J.card / q ^ J.card := + div_le_div_of_nonneg_left (pow_nonneg ha _) (pow_pos hq _) hpower + _ = (a / q) ^ J.card := (div_pow a q J.card).symm + +theorem target_fragment_mass_le_source + (μ : FiniteLaw B) (A F : B → Finset X) (joint : B × B → ℝ) + (event : B → B → Prop) (G : B → Prop) + (hjoint : ∀ c b, 0 ≤ joint (c, b)) + (hsource : ∀ c, ∑ b, joint (c, b) = μ.weight c) + (hfragment : ∀ c b, 0 < joint (c, b) → F b ⊆ A c) (J : Finset X) : + (∑ b, if G b ∧ J ⊆ F b then ∑ c, if event c b then joint (c, b) else 0 else 0) ≤ + μ.prob (fun c => J ⊆ A c) := by + calc + _ = ∑ b, ∑ c, + if G b ∧ J ⊆ F b then if event c b then joint (c, b) else 0 else 0 := by + apply Finset.sum_congr rfl + intro b _ + by_cases hb : G b ∧ J ⊆ F b <;> simp [hb] + _ = ∑ c, ∑ b, + if G b ∧ J ⊆ F b then if event c b then joint (c, b) else 0 else 0 := + Finset.sum_comm + _ ≤ ∑ c, ∑ b, if J ⊆ A c then joint (c, b) else 0 := by + apply Finset.sum_le_sum + intro c _ + apply Finset.sum_le_sum + intro b _ + by_cases hb : G b ∧ J ⊆ F b + · by_cases he : event c b + · by_cases hj : 0 < joint (c, b) + · have hJA : J ⊆ A c := hb.2.trans (hfragment c b hj) + simp [hb, he, hJA] + · have hz : joint (c, b) = 0 := + le_antisymm (le_of_not_gt hj) (hjoint c b) + simp [hb, he, hz] + · simp only [ite_eq_left hb, ite_eq_right he] + split_ifs <;> linarith [hjoint c b] + · simp only [ite_eq_right hb] + split_ifs <;> linarith [hjoint c b] + _ = μ.prob (fun c => J ⊆ A c) := by + unfold FiniteLaw.prob + apply Finset.sum_congr rfl + intro c _ + by_cases hc : J ⊆ A c <;> simp [hc, hsource] + +end RetainedLaw + +section Construction + +variable {X : Type} [DecidableEq X] + +theorem one_sub_exp_neg_nat_pos {m : ℕ} (hm : 0 < m) : + 0 < 1 - Real.exp (-(m : ℝ)) := by + have hm' : 0 < (m : ℝ) := by exact_mod_cast hm + exact sub_pos.mpr (Real.exp_lt_one_iff.mpr (neg_neg_of_pos hm')) + +theorem good_retainedMass_pos {d : ℕ} {B : Type} [Fintype B] + (μ : FiniteLaw B) (hμ : μ.IsPositive) (A : B → Finset X) + (child : B → ProbabilityTree X d) (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) + (hm : 0 < m 0) (hg : Good ρ m W (.node B μ hμ A child)) : + 0 < retainedMass (successfulTargetMass μ A ρ (m 0) W) + (fun b => Good ρ (fun j => m (j + 1)) W (child b)) := by + apply lt_of_lt_of_le (one_sub_exp_neg_nat_pos hm) + simpa only [Good, retainedMass] using hg + +/-- Explicit good-node pruning and normalization. The depth is preserved in the +result type. Every retained label is the actual fragment of its original label. -/ +def reduceTree (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} + (T : ProbabilityTree X d) (hρ : 0 < ρ) (hm : ∀ j < d, 0 < m j) + (hg : Good ρ m W T) : ProbabilityTree X d := + match T with + | .leaf => .leaf + | @ProbabilityTree.node _ n _B _inst μ hμ A child => + let w := successfulTargetMass μ A ρ (m 0) W + let G := fun b => Good ρ (fun j => m (j + 1)) W (child b) + have hw : ∀ b, 0 ≤ w b := successfulTargetMass_nonneg μ A hρ.le (m 0) W + have hp : 0 < retainedMass w G := + good_retainedMass_pos μ hμ A child ρ m W (hm 0 (Nat.succ_pos _)) hg + .node (RetainedIndex w G) (retainedLaw w G hw hp) + (retainedLaw_positive w G hw hp) (fun b => A b.val \ W) + (fun b => reduceTree ρ (fun j => m (j + 1)) W (child b.val) hρ + (fun j hj => hm (j + 1) (Nat.succ_lt_succ hj)) b.property.1) +termination_by structural T + +theorem reduceTree_support_subset (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} + (T : ProbabilityTree X d) (hρ : 0 < ρ) (hm : ∀ j < d, 0 < m j) + (hg : Good ρ m W T) : (reduceTree ρ m W T hρ hm hg).support ⊆ T.support := by + induction T generalizing m with + | leaf => simp [reduceTree, ProbabilityTree.support] + | @node n B inst μ hμ A child ih => + simp only [reduceTree, ProbabilityTree.support] + intro x hx + obtain ⟨b, _, hb⟩ := Finset.mem_biUnion.mp hx + refine Finset.mem_biUnion.mpr ⟨b.val, Finset.mem_univ _, ?_⟩ + rcases Finset.mem_union.mp hb with hb | hb + · exact Finset.mem_union_left _ (Finset.mem_sdiff.mp hb).1 + · exact Finset.mem_union_right _ + (ih b.val (fun j => m (j + 1)) + (fun j hj => hm (j + 1) (Nat.succ_lt_succ hj)) b.property.1 hb) + +theorem reduceTree_hasCapacities (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} + (T : ProbabilityTree X d) (hρ : 0 < ρ) (hm : ∀ j < d, 0 < m j) + (hg : Good ρ m W T) : + (reduceTree ρ m W T hρ hm hg).HasCapacities (fun j => m j / 2) := by + induction T generalizing m with + | leaf => simp only [reduceTree, ProbabilityTree.HasCapacities] + | @node n B inst μ hμ A child ih => + simp only [reduceTree, ProbabilityTree.HasCapacities] + constructor + · intro b + exact successfulTargetMass_pos_capacity μ A ρ (m 0) W b.val b.property.2 + · intro b + exact ih b.val (fun j => m (j + 1)) + (fun j hj => hm (j + 1) (Nat.succ_lt_succ hj)) b.property.1 + +theorem reduceTree_isDisjoint (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} + (T : ProbabilityTree X d) (hρ : 0 < ρ) (hm : ∀ j < d, 0 < m j) + (hg : Good ρ m W T) (hT : T.IsDisjoint) : + (reduceTree ρ m W T hρ hm hg).IsDisjoint := by + induction T generalizing m with + | leaf => simp only [reduceTree, ProbabilityTree.IsDisjoint] + | @node n B inst μ hμ A child ih => + simp only [reduceTree, ProbabilityTree.IsDisjoint] + constructor + · intro b + exact (hT.1 b.val).mono Finset.sdiff_subset + (reduceTree_support_subset ρ (fun j => m (j + 1)) W (child b.val) hρ + (fun j hj => hm (j + 1) (Nat.succ_lt_succ hj)) b.property.1) + · intro b + exact ih b.val (fun j => m (j + 1)) + (fun j hj => hm (j + 1) (Nat.succ_lt_succ hj)) b.property.1 (hT.2 b.val) + +theorem reduceTree_path_recovery (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} + (T : ProbabilityTree X d) (hρ : 0 < ρ) (hm : ∀ j < d, 0 < m j) + (hg : Good ρ m W T) : + ∀ q : (reduceTree ρ m W T hρ hm hg).Path, + ∃ p : T.Path, T.pathUnion p ⊆ W ∪ (reduceTree ρ m W T hρ hm hg).pathUnion q := by + induction T generalizing m with + | leaf => + intro q + exact ⟨PUnit.unit, Finset.empty_subset _⟩ + | @node n B inst μ hμ A child ih => + rw [reduceTree] + simp only [ProbabilityTree.Path, ProbabilityTree.pathUnion] + intro q + rcases q with ⟨b, q⟩ + obtain ⟨p, hp⟩ := ih b.val (fun j => m (j + 1)) + (fun j hj => hm (j + 1) (Nat.succ_lt_succ hj)) b.property.1 q + refine ⟨⟨b.val, p⟩, ?_⟩ + intro x hx + rcases Finset.mem_union.mp hx with ha | hc + · by_cases hw : x ∈ W + · exact Finset.mem_union_left _ hw + · exact Finset.mem_union_right _ + (Finset.mem_union_left _ (Finset.mem_sdiff.mpr ⟨ha, hw⟩)) + · rcases Finset.mem_union.mp (hp hc) with hw | hq + · exact Finset.mem_union_left _ hw + · exact Finset.mem_union_right _ (Finset.mem_union_right _ hq) + +theorem reduceTree_hasSpread (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} + (T : ProbabilityTree X d) (hρ : 0 < ρ) (hm : ∀ j < d, 0 < m j) + (hg : Good ρ m W T) (a : ℕ → ℝ) (ha : ∀ j < d, 0 ≤ a j) + (hT : T.HasSpread a) : + (reduceTree ρ m W T hρ hm hg).HasSpread + (fun j => a j / (1 - Real.exp (-(m j : ℝ)))) := by + induction T generalizing m a with + | leaf => simp only [reduceTree, ProbabilityTree.HasSpread] + | @node n B inst μ hμ A child ih => + simp only [reduceTree, ProbabilityTree.HasSpread] + constructor + · refine retainedLaw_isSpread (successfulTargetMass μ A ρ (m 0) W) + (fun b => Good ρ (fun j => m (j + 1)) W (child b)) + (successfulTargetMass_nonneg μ A hρ.le (m 0) W) + (good_retainedMass_pos μ hμ A child ρ m W (hm 0 (Nat.succ_pos _)) hg) + (fun b => A b \ W) + (ha 0 (Nat.succ_pos _)) + (one_sub_exp_neg_nat_pos (hm 0 (Nat.succ_pos _))) ?_ ?_ ?_ + · linarith [Real.exp_pos (-(m 0 : ℝ))] + · simpa only [retainedMass, Good] using hg + · intro J hJ + exact (target_fragment_mass_le_source μ A (fun b => A b \ W) + (resamplingWeight μ A ρ W) (LocalSuccess μ A ρ (m 0) W) + (fun b => Good ρ (fun j => m (j + 1)) W (child b)) + (fun c b => resamplingWeight_nonneg μ A hρ.le W (c, b)) + (resampling_source_marginal μ A hμ hρ W) + (fun c b hp => resamplingFragment_subset_source μ A ρ W c b hp) J).trans + (hT.1 J hJ) + · intro b + exact ih b.val (fun j => m (j + 1)) + (fun j hj => hm (j + 1) (Nat.succ_lt_succ hj)) b.property.1 + (fun j => a (j + 1)) (fun j hj => ha (j + 1) (Nat.succ_lt_succ hj)) + (hT.2 b.val) + +end Construction + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/GraphThreshold/TreeReductionData.lean b/lean/OAI/Combinatorics/GraphThreshold/TreeReductionData.lean new file mode 100644 index 0000000000000000000000000000000000000000..99dfd25e126e6fddb70560d6b04e1e8c1a92099f --- /dev/null +++ b/lean/OAI/Combinatorics/GraphThreshold/TreeReductionData.lean @@ -0,0 +1,181 @@ +import OAI.Combinatorics.GraphThreshold.ProbabilityTree +import OAI.Combinatorics.GraphThreshold.ResamplingEvents + +namespace OAI + +/-! Fixed-input local masses and the deterministic good-node predicate. -/ + +noncomputable section +open scoped BigOperators +open Classical + +namespace LeanBlast.SecondKahnKalai + +section LocalMasses + +variable {X B : Type*} [DecidableEq X] [Fintype B] + +def successfulTargetMass (μ : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) (m : ℕ) + (W : Finset X) (b : B) : ℝ := + ∑ c, if LocalSuccess μ A ρ m W c b then resamplingWeight μ A ρ W (c, b) else 0 + +def localFailureMass (μ : FiniteLaw B) (A : B → Finset X) (ρ : ℝ) (m : ℕ) + (W : Finset X) : ℝ := + ∑ b, ∑ c, if LocalFailure μ A ρ m W c b then resamplingWeight μ A ρ W (c, b) else 0 + +theorem successfulTargetMass_nonneg (μ : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 ≤ ρ) (m : ℕ) (W : Finset X) (b : B) : + 0 ≤ successfulTargetMass μ A ρ m W b := by + apply Finset.sum_nonneg + intro c _ + split_ifs + · exact resamplingWeight_nonneg μ A hρ W (c, b) + · exact le_rfl + +theorem localFailureMass_nonneg (μ : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hρ : 0 ≤ ρ) (m : ℕ) (W : Finset X) : + 0 ≤ localFailureMass μ A ρ m W := by + apply Finset.sum_nonneg + intro b _ + apply Finset.sum_nonneg + intro c _ + split_ifs + · exact resamplingWeight_nonneg μ A hρ W (c, b) + · exact le_rfl + +theorem localFailureMass_add_successfulTargetMass (μ : FiniteLaw B) + (A : B → Finset X) {ρ : ℝ} (hμ : μ.IsPositive) (hρ : 0 < ρ) + (m : ℕ) (W : Finset X) : + localFailureMass μ A ρ m W + ∑ b, successfulTargetMass μ A ρ m W b = 1 := by + classical + calc + _ = ∑ b, ∑ c, resamplingWeight μ A ρ W (c, b) := by + unfold localFailureMass successfulTargetMass LocalFailure + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro b _ + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro c _ + by_cases h : LocalSuccess μ A ρ m W c b <;> simp [h] + _ = ∑ c, ∑ b, resamplingWeight μ A ρ W (c, b) := Finset.sum_comm + _ = 1 := by + simp_rw [resampling_source_marginal μ A hμ hρ W] + exact μ.total + +theorem localFailureMass_eq_prob (μ : FiniteLaw B) (A : B → Finset X) + {ρ : ℝ} (hμ : μ.IsPositive) (hρ : 0 < ρ) (m : ℕ) (W : Finset X) : + localFailureMass μ A ρ m W = + (resamplingLaw μ A ρ W hμ hρ).prob (fun cb => LocalFailure μ A ρ m W cb.1 cb.2) := by + classical + unfold localFailureMass FiniteLaw.prob + rw [Fintype.sum_prod_type] + rw [Finset.sum_comm] + rfl + +theorem successfulTargetMass_pos_capacity (μ : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (m : ℕ) (W : Finset X) (b : B) + (hb : 0 < successfulTargetMass μ A ρ m W b) : (A b \ W).card ≤ m / 2 := by + by_contra hcap + have hfail (c : B) : ¬LocalSuccess μ A ρ m W c b := fun h => hcap h.2 + simp [successfulTargetMass, hfail] at hb + +theorem resamplingZ_congr_fragments (μ : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) {W V : Finset X} + (hWV : ∀ b, resamplingFragment A W b = resamplingFragment A V b) (c : B) : + resamplingZ μ A ρ (W ∪ A c) = resamplingZ μ A ρ (V ∪ A c) := by + unfold resamplingZ + apply Finset.sum_congr rfl + intro b _ + have hsub : A b ⊆ resamplingY A W c ↔ A b ⊆ resamplingY A V c := by + rw [resampling_target_subset_iff_fragment, resampling_target_subset_iff_fragment, hWV] + unfold resamplingNumerator + exact if_congr hsub rfl rfl + +theorem localSuccess_congr_fragments (μ : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (m : ℕ) {W V : Finset X} + (hWV : ∀ b, resamplingFragment A W b = resamplingFragment A V b) (c b : B) : + LocalSuccess μ A ρ m W c b ↔ LocalSuccess μ A ρ m V c b := by + unfold LocalSuccess + rw [resamplingZ_congr_fragments μ A ρ hWV c] + change (_ ∧ (resamplingFragment A W b).card ≤ m / 2) ↔ + (_ ∧ (resamplingFragment A V b).card ≤ m / 2) + rw [hWV b] + +theorem successfulTargetMass_congr_fragments (μ : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (m : ℕ) {W V : Finset X} + (hWV : ∀ b, resamplingFragment A W b = resamplingFragment A V b) (b : B) : + successfulTargetMass μ A ρ m W b = successfulTargetMass μ A ρ m V b := by + unfold successfulTargetMass + apply Finset.sum_congr rfl + intro c _ + by_cases h : LocalSuccess μ A ρ m W c b + · have hv := (localSuccess_congr_fragments μ A ρ m hWV c b).mp h + simp [h, hv, resamplingWeight_congr_fragments μ A ρ hWV] + · have hv : ¬LocalSuccess μ A ρ m V c b := + fun hv => h ((localSuccess_congr_fragments μ A ρ m hWV c b).mpr hv) + simp [h, hv] + +theorem localFailureMass_congr_fragments (μ : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (m : ℕ) {W V : Finset X} + (hWV : ∀ b, resamplingFragment A W b = resamplingFragment A V b) : + localFailureMass μ A ρ m W = localFailureMass μ A ρ m V := by + unfold localFailureMass LocalFailure + apply Finset.sum_congr rfl + intro b _ + apply Finset.sum_congr rfl + intro c _ + by_cases h : LocalSuccess μ A ρ m W c b + · have hv := (localSuccess_congr_fragments μ A ρ m hWV c b).mp h + simp [h, hv] + · have hv : ¬LocalSuccess μ A ρ m V c b := + fun hv => h ((localSuccess_congr_fragments μ A ρ m hWV c b).mpr hv) + simp [h, hv, resamplingWeight_congr_fragments μ A ρ hWV] + +theorem fragments_eq_of_inter_label_union_eq (A : B → Finset X) {W V : Finset X} + (hWV : W ∩ Finset.univ.biUnion A = V ∩ Finset.univ.biUnion A) (b : B) : + resamplingFragment A W b = resamplingFragment A V b := by + apply Finset.ext + intro x + by_cases hx : x ∈ A b + · have hxU : x ∈ Finset.univ.biUnion A := + Finset.mem_biUnion.mpr ⟨b, Finset.mem_univ b, hx⟩ + have hmem : x ∈ W ↔ x ∈ V := by + simpa only [Finset.mem_inter, hxU, and_true] using Finset.ext_iff.mp hWV x + simp [resamplingFragment, hx, hmem] + · simp [resamplingFragment, hx] + +theorem successfulTargetMass_dependsOnlyOn (μ : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (m : ℕ) (b : B) : + DependsOnlyOn (Finset.univ.biUnion A) (fun W => successfulTargetMass μ A ρ m W b) := by + intro W V hWV + exact successfulTargetMass_congr_fragments μ A ρ m + (fragments_eq_of_inter_label_union_eq A hWV) b + +theorem localFailureMass_dependsOnlyOn (μ : FiniteLaw B) (A : B → Finset X) + (ρ : ℝ) (m : ℕ) : + DependsOnlyOn (Finset.univ.biUnion A) (fun W => localFailureMass μ A ρ m W) := by + intro W V hWV + exact localFailureMass_congr_fragments μ A ρ m + (fragments_eq_of_inter_label_union_eq A hWV) + +end LocalMasses + +variable {X : Type} [DecidableEq X] + +/-- Goodness is evaluated on the fixed input tree, using local nonfailure +target masses before any pruning or reweighting. -/ +def Good (ρ : ℝ) (m : ℕ → ℕ) (W : Finset X) {d : ℕ} (T : ProbabilityTree X d) : Prop := + match T with + | .leaf => True + | @ProbabilityTree.node _ _ B inst μ _hμ A child => + 1 - Real.exp (-(m 0 : ℝ)) ≤ + ∑ b, if Good ρ (fun j => m (j + 1)) W (child b) then + successfulTargetMass μ A ρ (m 0) W b else 0 +termination_by d + +end LeanBlast.SecondKahnKalai + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Graphs/Coverage.lean b/lean/OAI/Combinatorics/Graphs/Coverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..400f1a836647ae43630b44003a55d629675d8240 --- /dev/null +++ b/lean/OAI/Combinatorics/Graphs/Coverage.lean @@ -0,0 +1,723 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator ComplexOrder +attribute [local instance] Classical.propDecidable +noncomputable section +open scoped BigOperators +attribute [local instance] Classical.propDecidable + +namespace CoordinateSweeps.Coverage +variable {I H : Type*} [Fintype I] [DecidableEq I] + +/- Oriented edges crossing a two-color cut. -/ +def cutEdges (R : I → I → Prop) (c : I → Bool) : Finset (I × I) := + Finset.univ.filter (fun p => R p.1 p.2 ∧ c p.1 ≠ c p.2) + +omit [DecidableEq I] in +@[simp] theorem mem_cutEdges (R : I → I → Prop) (c : I → Bool) (i j : I) : + (i,j) ∈ cutEdges R c ↔ R i j ∧ c i ≠ c j := by simp [cutEdges] + +/- A maximum cut has an opposite-color neighbor at every nonisolated vertex. +Only symmetry and absence of loops are used. -/ +theorem exists_crossing_cut (R : I → I → Prop) + (hsym : ∀ ⦃left right⦄, R left right → R right left) (hirr : ∀ vertex, ¬ R vertex vertex) : + ∃ c : I → Bool, ∀ i, (∃ j, R i j) → ∃ j, R i j ∧ c i ≠ c j := by + obtain ⟨c, _, hc⟩ := Finset.exists_max_image + (Finset.univ : Finset (I → Bool)) (fun c => (cutEdges R c).card) Finset.univ_nonempty + refine ⟨c, ?_⟩ + intro i hi + by_contra hh + have hn : ∀ j, R i j → c i = c j := by + intro j hij + by_contra hne + exact hh ⟨j,hij,hne⟩ + let c' := Function.update c i (!(c i)) + have hsub : cutEdges R c ⊆ cutEdges R c' := by + intro p hp + obtain ⟨hpR,hpne⟩ := (mem_cutEdges R c p.1 p.2).mp hp + have hpi : p.1 ≠ i := by + intro he; subst he + exact hpne (hn _ hpR) + have hpj : p.2 ≠ i := by + intro he + have heq := hn p.1 (hsym (he ▸ hpR)) + exact hpne (he ▸ heq.symm) + apply (mem_cutEdges R c' p.1 p.2).mpr + exact ⟨hpR, by simpa [c', Function.update_of_ne hpi, Function.update_of_ne hpj] using hpne⟩ + obtain ⟨j,hij⟩ := hi + have hji : j ≠ i := by intro he; subst j; exact hirr i hij + have hnew : (i,j) ∈ cutEdges R c' := by + rw [mem_cutEdges] + refine ⟨hij, ?_⟩ + simp only [c', Function.update_self, Function.update_of_ne hji] + rw [← hn j hij] + cases c i <;> decide + have hold : (i,j) ∉ cutEdges R c := by simp [hn j hij] + have hlt : (cutEdges R c).card < (cutEdges R c').card := + Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr ⟨hsub, by + intro he; rw [he] at hold; exact hold hnew⟩) + exact (not_lt_of_ge (hc c' (Finset.mem_univ _))) hlt + +/- Particles incident to a particle-sharing edge or a fixed hole. -/ +def covered (R : I → I → Prop) (T : I → H → Prop) : Finset I := + Finset.univ.filter (fun i => (∃ j, R i j) ∨ (∃ l, T i l)) + +omit [DecidableEq I] in +@[simp] theorem mem_covered (R : I → I → Prop) (T : I → H → Prop) (i : I) : + i ∈ covered R T ↔ (∃ j, R i j) ∨ (∃ l, T i l) := by simp [covered] + +/- A star forest supplies at least half as many distinct particle tails as +there are covered particles, with all parents outside the chosen tails. -/ +theorem exists_star_forest (R : I → I → Prop) (T : I → H → Prop) + (hsym : ∀ ⦃left right⦄, R left right → R right left) (hirr : ∀ vertex, ¬ R vertex vertex) : + ∃ A : Finset I, A ⊆ covered R T ∧ (covered R T).card ≤ 2*A.card ∧ + ∀ i ∈ A, (∃ j, j ∉ A ∧ R i j) ∨ (∃ l, T i l) := by + obtain ⟨c,hc⟩ := exists_crossing_cut R hsym hirr + let A := (covered R T).filter (fun i => c i = false) + let B := (covered R T).filter (fun i => c i = true) + have hAB : (covered R T).card = A.card + B.card := by + have hpart := Finset.card_filter_add_card_filter_not (s := covered R T) + (p := fun i => c i = false) + have he : B = (covered R T).filter (fun i => ¬ c i = false) := by + ext i + simp only [B, Finset.mem_filter] + cases c i <;> simp + rw [he] + exact hpart.symm + have hA : ∀ i ∈ A, (∃ j, j ∉ A ∧ R i j) ∨ (∃ l, T i l) := by + intro i hi + obtain ⟨hcov,hci⟩ := Finset.mem_filter.mp hi + rcases (mem_covered R T i).mp hcov with h | h + · obtain ⟨j,hij,hne⟩ := hc i h + left + refine ⟨j,?_,hij⟩ + intro hj + have hcj := (Finset.mem_filter.mp hj).2 + exact hne (hci.trans hcj.symm) + · exact Or.inr h + have hB : ∀ i ∈ B, (∃ j, j ∉ B ∧ R i j) ∨ (∃ l, T i l) := by + intro i hi + obtain ⟨hcov,hci⟩ := Finset.mem_filter.mp hi + rcases (mem_covered R T i).mp hcov with h | h + · obtain ⟨j,hij,hne⟩ := hc i h + left + refine ⟨j,?_,hij⟩ + intro hj + have hcj := (Finset.mem_filter.mp hj).2 + exact hne (hci.trans hcj.symm) + · exact Or.inr h + by_cases hle : A.card ≤ B.card + · exact ⟨B, Finset.filter_subset _ _, by omega, hB⟩ + · exact ⟨A, Finset.filter_subset _ _, by omega, hA⟩ + +end CoordinateSweeps.Coverage + +namespace CoordinateSweeps.Coverage +variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] + +/- Product mass of independent particle data. -/ +def productMass (w : X → ℝ) (x : I → X) : ℝ := ∏ i, w (x i) + +/- Finite event probability, with the product law on the full endpoint array. -/ +def probability (w : X → ℝ) (P : (I → X) → Prop) : ℝ := + ∑ x : I → X, if P x then productMass w x else 0 + +def glue (A : Finset I) (x : A → X) (y : {i : I // i ∉ A} → X) : I → X := + (Equiv.piEquivPiSubtypeProd (fun i => i ∈ A) (fun _ => X)).symm (x,y) + +omit [Fintype I] [Fintype X] in +@[simp] theorem glue_mem (A : Finset I) (x : A → X) (y : {i : I // i ∉ A} → X) + (i : A) : glue A x y i = x i := by + simp [glue, Equiv.piEquivPiSubtypeProd_symm_apply, i.property] + +omit [Fintype I] [Fintype X] in +@[simp] theorem glue_not_mem (A : Finset I) (x : A → X) (y : {i : I // i ∉ A} → X) + (i : {i : I // i ∉ A}) : glue A x y i = y i := by + simp [glue, Equiv.piEquivPiSubtypeProd_symm_apply, i.property] + +omit [Fintype X] in +theorem productMass_glue (A : Finset I) (w : X → ℝ) + (x : A → X) (y : {i : I // i ∉ A} → X) : + productMass w (glue A x y) = (∏ i, w (x i)) * ∏ j, w (y j) := by + unfold productMass + rw [← Fintype.prod_subtype_mul_prod_subtype (fun i => i ∈ A)] + simp only [glue_mem, glue_not_mem] + congr! + +/- Reused elementary finite independence identity, inline. -/ +theorem sum_prod_ite_all {J : Type*} [Fintype J] [DecidableEq J] + {Y : J → Type*} [∀ j, Fintype (Y j)] + (w : ∀ j, Y j → ℝ) (P : ∀ j, Y j → Prop) : + (∑ x : ∀ j, Y j, if ∀ j, P j (x j) then ∏ j, w j (x j) else 0) = + ∏ j, ∑ y, if P j y then w j y else 0 := by + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro x _ + by_cases hx : ∀ j, P j (x j) + · simp [hx] + · obtain ⟨j,hj⟩ := not_forall.mp hx + rw [ite_eq_right hx] + symm + apply Finset.prod_eq_zero (Finset.mem_univ j) + simp [hj] + +/- Conditional on all roots, different star tails involve independent data. +This is a factorization of the actual finite sum, not an independence axiom. -/ +theorem probability_star_factorization (A : Finset I) (w : X → ℝ) + (P : ({i : I // i ∉ A} → X) → A → X → Prop) : + probability w (fun x : I → X => ∀ i : A, P (fun j => x j) i (x i)) = + ∑ y : {i : I // i ∉ A} → X, + (∏ j, w (y j)) * ∏ i : A, ∑ t : X, if P y i t then w t else 0 := by + unfold probability + let e := Equiv.piEquivPiSubtypeProd (fun i => i ∈ A) (fun _ => X) + rw [← Equiv.sum_comp e.symm, Fintype.sum_prod_type, Finset.sum_comm] + apply Finset.sum_congr rfl + intro y _ + have hg : ∀ x : A → X, + (if ∀ i : A, P (fun j => e.symm (x,y) j) i (e.symm (x,y) i) + then productMass w (e.symm (x,y)) else 0) = + (∏ j, w (y j)) * (if ∀ i : A, P y i (x i) then ∏ i, w (x i) else 0) := by + intro x + change (if ∀ i : A, P (fun j => glue A x y j) i (glue A x y i) + then productMass w (glue A x y) else 0) = _ + simp only [glue_mem, glue_not_mem, productMass_glue] + split_ifs <;> ring + calc + _ = ∑ x : A → X, (∏ j, w (y j)) * + (if ∀ i : A, P y i (x i) then ∏ i, w (x i) else 0) := by + apply Finset.sum_congr rfl + intro x _ + convert hg x using 1 + congr! + _ = (∏ j, w (y j)) * (∑ x : A → X, + if ∀ i : A, P y i (x i) then ∏ i, w (x i) else 0) := by rw [Finset.mul_sum] + _ = _ := by + congr 1 + exact sum_prod_ite_all (fun (_ : A) t => w t) (P y) + +/- The source's leaf elimination bound for the star witnesses selected above. -/ +theorem probability_star_le (A : Finset I) (w : X → ℝ) + (hw : ∀ x, 0 ≤ w x) (hs : ∑ x, w x = 1) (ω : ℝ) (hω : 0 ≤ ω) + (P : ({i : I // i ∉ A} → X) → A → X → Prop) + (hP : ∀ y i, (∑ t : X, if P y i t then w t else 0) ≤ ω) : + probability w (fun x : I → X => ∀ i : A, P (fun j => x j) i (x i)) ≤ ω^A.card := by + rw [probability_star_factorization] + have hprod : ∀ y : {i : I // i ∉ A} → X, + (∏ i : A, ∑ t : X, if P y i t then w t else 0) ≤ ω^A.card := by + intro y + calc + _ ≤ ∏ _i : A, ω := by + apply Finset.prod_le_prod₀ + · intro i _; exact Finset.sum_nonneg (fun t _ => by split_ifs; exact hw t; exact le_rfl) + · intro i _; exact hP y i + _ = _ := by simp + calc + _ ≤ ∑ y : {i : I // i ∉ A} → X, (∏ j, w (y j)) * ω^A.card := by + apply Finset.sum_le_sum + intro y _ + exact mul_le_mul_of_nonneg_left (hprod y) (Finset.prod_nonneg (fun j _ => hw _)) + _ ≤ 1 * ω^A.card := by + rw [← Finset.sum_mul] + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hω _) + rw [← Fintype.prod_sum] + simp [hs] + _ = ω^A.card := one_mul _ + +end CoordinateSweeps.Coverage + +namespace CoordinateSweeps.Coverage +variable {I H : Type*} [Fintype I] [DecidableEq I] + +/- A finite directed star system. Distinct tails are indexed by the subtype A; +the parent lies outside A or is a hole. -/ +def starSystem (R : I → I → Prop) (T : I → H → Prop) + (A : Finset I) (p : A → I ⊕ H) : Prop := + ∀ i : A, match p i with + | .inl j => j ∉ A ∧ R i j + | .inr l => T i l + +/- The witness can be trimmed to any requested number of tails up to half +(rounded up) of the number of covered particles. -/ +theorem exists_star_system (R : I → I → Prop) (T : I → H → Prop) + (hsym : ∀ ⦃left right⦄, R left right → R right left) (hirr : ∀ vertex, ¬ R vertex vertex) (j : ℕ) + (hj : j ≤ ((covered R T).card + 1)/2) : + ∃ A : Finset I, A.card = j ∧ ∃ p : A → I ⊕ H, starSystem R T A p := by + obtain ⟨B,_,hB,hpar⟩ := exists_star_forest R T hsym hirr + have hjB : j ≤ B.card := by omega + obtain ⟨A,hAB,hAc⟩ := Finset.exists_subset_card_eq hjB + have hp : ∀ i : A, ∃ r : I ⊕ H, match r with + | .inl l => l ∉ A ∧ R i l + | .inr l => T i l := by + intro i + rcases hpar i (hAB i.property) with ⟨l,hl,hR⟩ | ⟨l,hT⟩ + · exact ⟨.inl l, fun hm => hl (hAB hm), hR⟩ + · exact ⟨.inr l, hT⟩ + choose p hp using hp + exact ⟨A,hAc,p,hp⟩ + +variable {X : Type*} [Fintype X] + +/- The sharing event of one directed system under the full independent data. +Forbidden parent choices simply give an empty event. -/ +def starEvent (S : X → X → Prop) (holes : H → X) + (A : Finset I) (p : A → I ⊕ H) (x : I → X) : Prop := + starSystem (fun i j => S (x i) (x j)) (fun i l => S (x i) (holes l)) A p + +/- A tail predicate with the values at all its possible roots fixed. -/ +def rootPredicate (S : X → X → Prop) (holes : H → X) + (A : Finset I) (p : A → I ⊕ H) + (y : {i : I // i ∉ A} → X) (i : A) (t : X) : Prop := + match p i with + | .inl j => if hj : j ∉ A then S t (y ⟨j,hj⟩) else False + | .inr l => S t (holes l) + +omit [Fintype I] [Fintype X] in +theorem starEvent_iff_root (S : X → X → Prop) (holes : H → X) + (A : Finset I) (p : A → I ⊕ H) (x : I → X) : + starEvent S holes A p x ↔ + ∀ i : A, rootPredicate S holes A p (fun j => x j) i (x i) := by + unfold starEvent starSystem rootPredicate + apply forall_congr' + intro i + cases p i with + | inl j => by_cases hj : j ∉ A <;> simp [hj] + | inr l => rfl + +/- For every particular system of j distinct tails toward non-tail parents, +the sharing probability is at most ω^j, with no layer independence premise. -/ +theorem probability_starEvent_le (S : X → X → Prop) (holes : H → X) + (A : Finset I) (p : A → I ⊕ H) (w : X → ℝ) + (hw : ∀ x, 0 ≤ w x) (hs : ∑ x, w x = 1) (ω : ℝ) (hω : 0 ≤ ω) + (hS : ∀ y, (∑ t : X, if S t y then w t else 0) ≤ ω) : + probability w (starEvent S holes A p) ≤ ω^A.card := by + have he : starEvent S holes A p = + (fun x : I → X => ∀ i : A, rootPredicate S holes A p (fun j => x j) i (x i)) := by + funext x + exact propext (starEvent_iff_root S holes A p x) + rw [he] + apply probability_star_le A w hw hs ω hω + intro y i + unfold rootPredicate + cases hp : p i with + | inl j => + by_cases hj : j ∉ A + · simpa only [dite_eq_left hj] using hS (y ⟨j,hj⟩) + · simpa [hj] using hω + | inr l => exact hS (holes l) + +end CoordinateSweeps.Coverage + +namespace CoordinateSweeps.Coverage +variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] + +omit [DecidableEq I] [Fintype X] in +theorem productMass_nonneg (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) (x : I → X) : + 0 ≤ productMass w x := Finset.prod_nonneg (fun i _ => hw (x i)) + +theorem probability_mono (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + {P Q : (I → X) → Prop} (hPQ : ∀ x, P x → Q x) : + probability w P ≤ probability w Q := by + apply Finset.sum_le_sum + intro x _ + by_cases hp : P x + · simp only [ite_eq_left hp, ite_eq_left (hPQ x hp)] + exact le_rfl + · simp only [ite_eq_right hp] + split_ifs + · exact productMass_nonneg w hw x + · exact le_rfl + +theorem probability_exists_le {J : Type*} [Fintype J] + (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) (P : J → (I → X) → Prop) : + probability w (fun x => ∃ j, P j x) ≤ ∑ j, probability w (P j) := by + unfold probability + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro x _ + have hpj : ∀ j, 0 ≤ (if P j x then productMass w x else 0) := by + intro j; split_ifs; exact productMass_nonneg w hw x; exact le_rfl + by_cases he : ∃ j, P j x + · obtain ⟨j,hj⟩ := he + rw [ite_eq_left ⟨j,hj⟩] + have hh := Finset.single_le_sum (fun j _ => hpj j) (Finset.mem_univ j) + simpa only [ite_eq_left hj] using hh + · rw [ite_eq_right he] + exact Finset.sum_nonneg (fun j _ => hpj j) + +end CoordinateSweeps.Coverage + +namespace CoordinateSweeps.Coverage +variable {I H : Type*} [Fintype I] [DecidableEq I] [Fintype H] + +/- Data encoding exactly j distinct tails and one arbitrary parent per tail. +The sub-event enforces the star/root restrictions. -/ +abbrev Witness (I H : Type*) [Fintype I] (j : ℕ) := + Σ A : {A : Finset I // A.card = j}, (A.val → I ⊕ H) + +theorem card_witness_le (j : ℕ) : + Fintype.card (Witness I H j) ≤ + 2^Fintype.card I * (Fintype.card I + Fintype.card H)^j := by + have hc : ∀ A : {A : Finset I // A.card = j}, + Fintype.card (A.val → I ⊕ H) = (Fintype.card I + Fintype.card H)^j := by + intro A + simp [A.property] + have hA : Fintype.card {A : Finset I // A.card = j} ≤ 2^Fintype.card I := by + simpa using Fintype.card_le_of_injective + (fun A : {A : Finset I // A.card = j} => A.val) Subtype.val_injective + calc + _ = Fintype.card {A : Finset I // A.card = j} * + (Fintype.card I + Fintype.card H)^j := by + rw [Fintype.card_sigma] + simp only [hc, Finset.sum_const, Finset.card_univ, smul_eq_mul] + _ ≤ _ := Nat.mul_le_mul_right _ hA + +variable {X : Type*} [Fintype X] + +/- Covered particles for the actual symmetric sharing relation on path data. -/ +def sharingCoverage (S : X → X → Prop) (holes : H → X) (x : I → X) : Finset I := + covered (fun i j => i ≠ j ∧ S (x i) (x j)) (fun i l => S (x i) (holes l)) + +omit [Fintype H] [Fintype X] in +theorem sharingCoverage_witness (S : X → X → Prop) + (hSsym : ∀ ⦃left right⦄, S left right → S right left) + (holes : H → X) (x : I → X) (n : ℕ) + (hn : n ≤ (sharingCoverage S holes x).card) : + ∃ W : Witness I H ((n+1)/2), starEvent S holes W.1.val W.2 x := by + let R : I → I → Prop := fun i j => i ≠ j ∧ S (x i) (x j) + let T : I → H → Prop := fun i l => S (x i) (holes l) + have hsym : ∀ ⦃left right⦄, R left right → R right left := fun i j h => ⟨h.1.symm, hSsym h.2⟩ + have hirr : ∀ vertex, ¬ R vertex vertex := fun i h => h.1 rfl + have hc : n ≤ (covered R T).card := hn + obtain ⟨A,hAc,p,hp⟩ := exists_star_system R T hsym hirr ((n+1)/2) (by omega) + refine ⟨⟨⟨A,hAc⟩,p⟩,?_⟩ + intro i + have hi := hp i + cases hpi : p i with + | inl j => + simp only [hpi] at hi ⊢ + exact ⟨hi.1,hi.2.2⟩ + | inr l => + simpa only [hpi] using hi + +/- Source coverage bound with the slightly stronger integer exponent ceil(n/2). +There is no independence assumption between different path layers. -/ +theorem probability_coverage_le_nat (S : X → X → Prop) + (hSsym : ∀ ⦃left right⦄, S left right → S right left) + (holes : H → X) (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) (hs : ∑ x, w x = 1) + (ω : ℝ) (hω : 0 ≤ ω) + (hS : ∀ y, (∑ t : X, if S t y then w t else 0) ≤ ω) (n : ℕ) : + probability w (fun x : I → X => n ≤ (sharingCoverage S holes x).card) ≤ + (2 : ℝ)^Fintype.card I * + (((Fintype.card I + Fintype.card H : ℕ) : ℝ) * ω)^((n+1)/2) := by + let j := (n+1)/2 + let P : Witness I H j → (I → X) → Prop := + fun W => starEvent S holes W.1.val W.2 + calc + _ ≤ probability w (fun x : I → X => ∃ W : Witness I H j, P W x) := + probability_mono w hw (fun x hx => sharingCoverage_witness S hSsym holes x n hx) + _ ≤ ∑ W : Witness I H j, probability w (P W) := probability_exists_le w hw P + _ ≤ ∑ _W : Witness I H j, ω^j := by + apply Finset.sum_le_sum + intro W _ + simpa only [W.1.property] using + probability_starEvent_le S holes W.1.val W.2 w hw hs ω hω hS + _ = (Fintype.card (Witness I H j) : ℝ) * ω^j := by simp + _ ≤ (2 : ℝ)^Fintype.card I * + (((Fintype.card I + Fintype.card H : ℕ) : ℝ)^j) * ω^j := by + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hω _) + exact_mod_cast (card_witness_le (I := I) (H := H) j) + _ = _ := by rw [mul_assoc, ← mul_pow] + +end CoordinateSweeps.Coverage + +namespace CoordinateSweeps.Coverage +variable {I H X : Type*} [Fintype I] [DecidableEq I] [Fintype H] [Fintype X] + +/- The literal source's coverage estimate (04:eq9), including zero sharing +rate and zero requested coverage, with the real exponent n/2. -/ +theorem probability_coverage_le (S : X → X → Prop) + (hSsym : ∀ ⦃left right⦄, S left right → S right left) + (holes : H → X) (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) (hs : ∑ x, w x = 1) + (ω : ℝ) (hω : 0 ≤ ω) + (hS : ∀ y, (∑ t : X, if S t y then w t else 0) ≤ ω) + (hsmall : ((Fintype.card I + Fintype.card H : ℕ) : ℝ) * ω ≤ 1) (n : ℕ) : + probability w (fun x : I → X => n ≤ (sharingCoverage S holes x).card) ≤ + (2 : ℝ)^Fintype.card I * + ((((Fintype.card I + Fintype.card H : ℕ) : ℝ) * ω) ^ ((n : ℝ)/2)) := by + have hn : n ≤ 2*((n+1)/2) := by omega + have hn' : (n : ℝ) ≤ 2 * (((n+1)/2 : ℕ) : ℝ) := by exact_mod_cast hn + have hr : + ((((Fintype.card I + Fintype.card H : ℕ) : ℝ) * ω) ^ ((n+1)/2 : ℕ)) ≤ + ((((Fintype.card I + Fintype.card H : ℕ) : ℝ) * ω) ^ ((n : ℝ)/2)) := by + rw [← Real.rpow_natCast] + exact Real.rpow_le_rpow_of_exponent_ge' (by positivity) hsmall (by positivity) (by linarith) + exact (probability_coverage_le_nat S hSsym holes w hw hs ω hω hS n).trans + (mul_le_mul_of_nonneg_left hr (by positivity)) + +end CoordinateSweeps.Coverage +end +end +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator ComplexOrder +attribute [local instance] Classical.propDecidable +noncomputable section +open scoped BigOperators +attribute [local instance] Classical.propDecidable +noncomputable section +open scoped BigOperators +open MvPolynomial +noncomputable section +open MeasureTheory ProbabilityTheory Real Set Filter +open scoped ENNReal NNReal BigOperators +noncomputable section +open scoped BigOperators +namespace CoordinateSweeps.Coverage +variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] + +/- Independent occupancy of a fixed measurable subset. The set is fixed +BEFORE taking probability, exactly as required in source04:eq12. -/ +theorem probability_many_hits_le (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (hs : ∑ x, w x = 1) (P : X → Prop) (p : ℝ) (hp : 0 ≤ p) + (hP : (∑ x, if P x then w x else 0) ≤ p) (n : ℕ) : + probability w (fun x : I → X => n ≤ (Finset.univ.filter (fun i => P (x i))).card) ≤ + (2 : ℝ)^Fintype.card I * p^n := by + let W := {A : Finset I // A.card = n} + have hcover (x : I → X) (hx : n ≤ (Finset.univ.filter (fun i => P (x i))).card) : + ∃ A : W, ∀ i : A.val, P (x i) := by + obtain ⟨A,hA,hAc⟩ := Finset.exists_subset_card_eq hx + exact ⟨⟨A,hAc⟩, fun i => (Finset.mem_filter.mp (hA i.property)).2⟩ + have hprob (A : W) : probability w (fun x : I → X => ∀ i : A.val, P (x i)) ≤ p^n := by + simpa only [A.property] using probability_star_le A.val w hw hs p hp + (fun _ _ x => P x) (fun _ _ => hP) + calc + _ ≤ probability w (fun x : I → X => ∃ A : W, ∀ i : A.val, P (x i)) := + probability_mono w hw hcover + _ ≤ ∑ A : W, probability w (fun x : I → X => ∀ i : A.val, P (x i)) := + probability_exists_le w hw _ + _ ≤ ∑ _A : W, p^n := Finset.sum_le_sum (fun A _ => hprob A) + _ = (Fintype.card W : ℝ)*p^n := by simp + _ ≤ _ := by + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hp _) + exact_mod_cast (Fintype.card_subtype_le (fun A : Finset I => A.card = n)).trans_eq + (Fintype.card_finset (α := I)) + +theorem probability_many_hits_le_rpow (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (hs : ∑ x, w x = 1) (P : X → Prop) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hP : (∑ x, if P x then w x else 0) ≤ p) (u : ℝ) (hu : 0 ≤ u) : + probability w (fun x : I → X => u ≤ ((Finset.univ.filter (fun i => P (x i))).card : ℝ)) ≤ + (2 : ℝ)^Fintype.card I * p^u := by + have he := probability_many_hits_le (I := I) w hw hs P p hp hP ⌈u⌉₊ + have hconv : (fun x : I → X => u ≤ ((Finset.univ.filter (fun i => P (x i))).card : ℝ)) = + (fun x => ⌈u⌉₊ ≤ (Finset.univ.filter (fun i => P (x i))).card) := by + funext x + exact propext Nat.ceil_le.symm + rw [hconv] + apply he.trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + rw [← Real.rpow_natCast] + exact Real.rpow_le_rpow_of_exponent_ge' hp hp1 hu (Nat.le_ceil u) + +/- Canonical padded enumeration encodes a subset of size at most r in r +optional entries. This supplies the source's (number-of-lines+1)^r union count. -/ +def encodeSmallSet {L : Type*} [Fintype L] [DecidableEq L] (r : ℕ) + (S : {S : Finset L // S.card ≤ r}) : Fin r → Option L := fun i => + if hi : i.val < S.val.card then + some (((Fintype.equivFinOfCardEq (Fintype.card_coe S.val)).symm ⟨i.val,hi⟩).val) + else none + +theorem mem_iff_encodeSmallSet {L : Type*} [Fintype L] [DecidableEq L] (r : ℕ) + (S : {S : Finset L // S.card ≤ r}) (a : L) : + a ∈ S.val ↔ ∃ i, encodeSmallSet r S i = some a := by + constructor + · intro ha + let e := Fintype.equivFinOfCardEq (Fintype.card_coe S.val) + let j := e ⟨a,ha⟩ + let i : Fin r := ⟨j.val, lt_of_lt_of_le j.isLt S.property⟩ + refine ⟨i, ?_⟩ + simp only [encodeSmallSet, i, dite_eq_left j.isLt] + change some ((e.symm j).val) = some a + simp [j] + · rintro ⟨i,hi⟩ + unfold encodeSmallSet at hi + split_ifs at hi with hlt + · have he := Option.some.inj hi + rw [← he] + exact ((Fintype.equivFinOfCardEq (Fintype.card_coe S.val)).symm ⟨i.val,hlt⟩).property + +theorem encodeSmallSet_injective {L : Type*} [Fintype L] [DecidableEq L] (r : ℕ) : + Function.Injective (encodeSmallSet (L := L) r) := by + intro S T he + apply Subtype.ext + ext a + rw [mem_iff_encodeSmallSet, mem_iff_encodeSmallSet] + simp only [he] + +theorem card_smallSets_le {L : Type*} [Fintype L] [DecidableEq L] (r : ℕ) : + Fintype.card {S : Finset L // S.card ≤ r} ≤ (Fintype.card L+1)^r := by + have he := Fintype.card_le_of_injective _ (encodeSmallSet_injective (L := L) r) + simpa using he + +/- Uniform union bound over small sets of lines, without conditioning on a +set chosen from the particle array. -/ +theorem probability_smallSet_hits_le {L : Type*} [Fintype L] [DecidableEq L] + (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) (hs : ∑ x, w x = 1) (line : X → L) + (r : ℕ) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hprob : ∀ S : Finset L, S.card ≤ r → (∑ x, if line x ∈ S then w x else 0) ≤ p) + (u : ℝ) (hu : 0 ≤ u) : + probability w (fun x : I → X => ∃ S : Finset L, S.card ≤ r ∧ + u ≤ ((Finset.univ.filter (fun i => line (x i) ∈ S)).card : ℝ)) ≤ + ((Fintype.card L+1 : ℕ) : ℝ)^r * (2 : ℝ)^Fintype.card I * p^u := by + let W := {S : Finset L // S.card ≤ r} + have he (x : I → X) : + (∃ S : Finset L, S.card ≤ r ∧ u ≤ ((Finset.univ.filter (fun i => line (x i) ∈ S)).card : ℝ)) ↔ + ∃ S : W, u ≤ ((Finset.univ.filter (fun i => line (x i) ∈ S.val)).card : ℝ) := by + constructor + · rintro ⟨S,hS,hc⟩; exact ⟨⟨S,hS⟩,hc⟩ + · rintro ⟨S,hc⟩; exact ⟨S.val,S.property,hc⟩ + simp only [he] + calc + _ ≤ ∑ S : W, probability w (fun x : I → X => + u ≤ ((Finset.univ.filter (fun i => line (x i) ∈ S.val)).card : ℝ)) := + probability_exists_le w hw _ + _ ≤ ∑ _S : W, (2 : ℝ)^Fintype.card I*p^u := by + apply Finset.sum_le_sum + intro S _ + convert probability_many_hits_le_rpow (I := I) w hw hs (fun x => line x ∈ S.val) p hp hp1 + (by convert hprob S.val S.property using 1; congr!) u hu using 1 + congr! + _ = (Fintype.card W : ℝ)*((2 : ℝ)^Fintype.card I*p^u) := by simp + _ ≤ _ := by + rw [mul_assoc] + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact_mod_cast card_smallSets_le (L := L) r + +end CoordinateSweeps.Coverage + +namespace CoordinateSweeps.Coverage +variable {I X L : Type*} [Fintype I] [DecidableEq I] [Fintype X] [Fintype L] [DecidableEq L] + +omit [Fintype L] in +theorem sum_lineSet (w : X → ℝ) (line : X → L) (S : Finset L) : + (∑ x, if line x ∈ S then w x else 0) = + ∑ l ∈ S, ∑ x, if line x = l then w x else 0 := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + simp + +omit [Fintype L] in +theorem probability_lineSet_le (w : X → ℝ) (line : X → L) (S : Finset L) + (δ : ℝ) (hδ : ∀ l, (∑ x, if line x = l then w x else 0) ≤ δ) : + (∑ x, if line x ∈ S then w x else 0) ≤ (S.card : ℝ)*δ := by + rw [sum_lineSet] + calc + _ ≤ ∑ _l ∈ S, δ := Finset.sum_le_sum (fun l _ => hδ l) + _ = _ := by simp + +def heavySet (t : L → ℕ) (v : ℝ) : Finset L := Finset.univ.filter (fun l => v < t l) + +omit [DecidableEq L] in +theorem heavySet_card_mul_le (t : L → ℕ) (v : ℝ) : + ((heavySet t v).card : ℝ)*v ≤ ∑ l, (t l : ℝ) := by + calc + _ = ∑ _l ∈ heavySet t v, v := by simp + _ ≤ ∑ l ∈ heavySet t v, (t l : ℝ) := by + apply Finset.sum_le_sum + intro l hl + exact (Finset.mem_filter.mp hl).2.le + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun _ _ _ => Nat.cast_nonneg _) + +omit [DecidableEq L] in +theorem heavySet_card_le_floor (t : L → ℕ) {v : ℝ} (hv : 0 < v) : + (heavySet t v).card ≤ ⌊(∑ l, (t l : ℝ))/v⌋₊ := by + apply Nat.le_floor + apply (le_div_iff₀ hv).mpr + exact heavySet_card_mul_le t v + +def occupancy (line : X → L) (x : I → X) (l : L) : ℕ := + (Finset.univ.filter (fun i => line (x i) = l)).card + +omit [DecidableEq I] [Fintype X] in +theorem sum_occupancy (line : X → L) (x : I → X) : + ∑ l, occupancy line x l = Fintype.card I := by + unfold occupancy + simp only [Finset.card_eq_sum_ones, Finset.sum_filter] + rw [Finset.sum_comm] + simp + +/- Heavy line sets are small by deterministic occupancy counting. -/ +omit [DecidableEq I] [Fintype X] in +theorem heavy_occupancy_card_le (line : X → L) (x : I → X) {v : ℝ} (hv : 0 < v) : + (heavySet (occupancy line x) v).card ≤ ⌊(Fintype.card I : ℝ)/v⌋₊ := by + have hh := heavySet_card_le_floor (occupancy line x) hv + simpa only [← Nat.cast_sum, sum_occupancy] using hh + +/- Probability of many particles in particle-heavy lines. The random line +set is controlled by a union over ALL small deterministic sets. -/ +theorem probability_heavy_occupancy_le (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (hs : ∑ x, w x = 1) (line : X → L) {v : ℝ} (hv : 0 < v) + (p δ : ℝ) (hδ : 0 ≤ δ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hline : ∀ l, (∑ x, if line x = l then w x else 0) ≤ δ) + (hrp : (⌊(Fintype.card I : ℝ)/v⌋₊ : ℝ)*δ ≤ p) + (u : ℝ) (hu : 0 ≤ u) : + probability w (fun x : I → X => + u ≤ ((Finset.univ.filter (fun i => line (x i) ∈ heavySet (occupancy line x) v)).card : ℝ)) ≤ + ((Fintype.card L+1 : ℕ) : ℝ)^⌊(Fintype.card I : ℝ)/v⌋₊ * + (2 : ℝ)^Fintype.card I * p^u := by + apply le_trans (probability_mono w hw (Q := fun x : I → X => + ∃ S : Finset L, S.card ≤ ⌊(Fintype.card I : ℝ)/v⌋₊ ∧ + u ≤ ((Finset.univ.filter (fun i => line (x i) ∈ S)).card : ℝ)) (fun x hx => + ⟨heavySet (occupancy line x) v, heavy_occupancy_card_le line x hv, hx⟩)) + apply probability_smallSet_hits_le w hw hs line _ p hp hp1 _ u hu + intro S hS + have hle := probability_lineSet_le w line S δ hline + apply hle.trans + apply le_trans _ hrp + exact mul_le_mul_of_nonneg_right (by exact_mod_cast hS) hδ + +end CoordinateSweeps.Coverage + +namespace CoordinateSweeps.Coverage +variable {I H X : Type*} [Fintype I] [DecidableEq I] [Fintype H] [Fintype X] + +theorem probability_or_le (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) (P Q : (I → X) → Prop) : + probability w (fun x => P x ∨ Q x) ≤ probability w P + probability w Q := by + simp only [probability, ← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro x _ + have hx := productMass_nonneg w hw x + split_ifs <;> simp_all + +theorem probability_coverage_le_real (S : X → X → Prop) + (hSsym : ∀ ⦃left right⦄, S left right → S right left) + (holes : H → X) (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) (hs : ∑ x, w x = 1) + (ω : ℝ) (hω : 0 ≤ ω) + (hS : ∀ y, (∑ t : X, if S t y then w t else 0) ≤ ω) + (hsmall : ((Fintype.card I + Fintype.card H : ℕ) : ℝ) * ω ≤ 1) + (u : ℝ) (hu : 0 ≤ u) : + probability w (fun x : I → X => u ≤ ((sharingCoverage S holes x).card : ℝ)) ≤ + (2 : ℝ)^Fintype.card I * + ((((Fintype.card I + Fintype.card H : ℕ) : ℝ)*ω)^(u/2)) := by + have hc : (fun x : I → X => u ≤ ((sharingCoverage S holes x).card : ℝ)) = + (fun x => ⌈u⌉₊ ≤ (sharingCoverage S holes x).card) := by + funext x + exact propext Nat.ceil_le.symm + rw [hc] + apply (probability_coverage_le S hSsym holes w hw hs ω hω hS hsmall ⌈u⌉₊).trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact Real.rpow_le_rpow_of_exponent_ge' (by positivity) hsmall (by positivity) + (div_le_div_of_nonneg_right (Nat.le_ceil u) (by norm_num)) +end CoordinateSweeps.Coverage + +end +end +end +end +end +open scoped Matrix.Norms.L2Operator + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/BasicMatching.lean b/lean/OAI/Combinatorics/HadwigerMatching/BasicMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..36e160bd1ea68ac80ecfadd7d13b29eda07053fd --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/BasicMatching.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.HadwigerMatching.Definitions +import Mathlib.Algebra.BigOperators.Group.Finset.Basic + +namespace OAI + +namespace HadwigerMatching + +open scoped BigOperators + +universe u +variable {V : Type u} {G : SimpleGraph V} + +/-- The empty family is a touching matching. -/ +theorem isTouchingMatching_empty (G : SimpleGraph V) : + IsTouchingMatching G ∅ := by + simp [IsTouchingMatching] + +/-- Every member contributes exactly two vertices. -/ +theorem IsTouchingMatching.sum_card_eq {M : Finset (Finset V)} + (hM : IsTouchingMatching G M) : + (∑ e ∈ M, e.card) = 2 * M.card := by + rw [Finset.sum_const_nat (fun e he => (hM.1 e he).1)] + exact Nat.mul_comm M.card 2 + +/-- Disjointness bounds twice the number of matching edges by the graph order. -/ +theorem IsTouchingMatching.two_mul_card_le [Fintype V] + {M : Finset (Finset V)} (hM : IsTouchingMatching G M) : + 2 * M.card ≤ Fintype.card V := by + classical + have hd : (M : Set (Finset V)).PairwiseDisjoint (fun e => e) := by + intro e he f hf hne + exact hM.2.1 e he f hf hne + have hc : (M.biUnion (fun e => e)).card = 2 * M.card := by + rw [Finset.card_biUnion hd] + exact hM.sum_card_eq + rw [← hc] + exact Finset.card_le_univ _ + +/-- Touching matching cardinalities are bounded on a finite vertex type. -/ +theorem connectedMatchingNumber_bddAbove [Fintype V] (G : SimpleGraph V) : + BddAbove {n : ℕ | ∃ M : Finset (Finset V), + IsTouchingMatching G M ∧ M.card = n} := by + refine ⟨Fintype.card V, ?_⟩ + rintro n ⟨M, hM, rfl⟩ + have h : M.card + M.card ≤ Fintype.card V := by + simpa only [two_mul] using hM.two_mul_card_le + exact (Nat.le_add_right M.card M.card).trans h + +/-- Every touching matching is bounded by the connected matching number. -/ +theorem matching_card_le_number [Fintype V] {M : Finset (Finset V)} + (hM : IsTouchingMatching G M) : M.card ≤ connectedMatchingNumber G := by + exact le_csSup (connectedMatchingNumber_bddAbove G) ⟨M, hM, rfl⟩ + +/-- The connected matching number is realized by a touching matching. -/ +theorem exists_matching_card_eq_number [Fintype V] (G : SimpleGraph V) : + ∃ M : Finset (Finset V), IsTouchingMatching G M ∧ + M.card = connectedMatchingNumber G := by + have hne : Set.Nonempty {n : ℕ | ∃ M : Finset (Finset V), + IsTouchingMatching G M ∧ M.card = n} := + ⟨0, ∅, isTouchingMatching_empty G, rfl⟩ + exact Nat.sSup_mem hne (connectedMatchingNumber_bddAbove G) + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/BranchCounting.lean b/lean/OAI/Combinatorics/HadwigerMatching/BranchCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7789373ac5e86943de373162803edb82b0db8ad --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/BranchCounting.lean @@ -0,0 +1,63 @@ +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Data.Fintype.Card +import Mathlib.Tactic.SplitIfs +import Lean.Elab.Tactic.Omega + +namespace OAI + +/-! Cardinal bounds for pairwise disjoint nonempty branch sets. -/ +namespace HadwigerMatching +open scoped BigOperators + +variable {V : Type*} {t : ℕ} + +/-- The number of one-vertex branches. -/ +def singletonBranchCount (B : Fin t → Finset V) : ℕ := + (Finset.univ.filter fun i => (B i).card = 1).card + +/-- The number of two-vertex branches. -/ +def doubletonBranchCount (B : Fin t → Finset V) : ℕ := + (Finset.univ.filter fun i => (B i).card = 2).card + +theorem sum_singleton_indicator (B : Fin t → Finset V) : + (∑ i, if (B i).card = 1 then 1 else 0) = singletonBranchCount B := by + simp [singletonBranchCount] + +theorem sum_doubleton_indicator (B : Fin t → Finset V) : + (∑ i, if (B i).card = 2 then 1 else 0) = doubletonBranchCount B := by + simp [doubletonBranchCount] + +/-- Disjoint branch sets occupy at most the ambient finite ground set. -/ +theorem branch_card_sum_le [Fintype V] [DecidableEq V] + (B : Fin t → Finset V) (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) : + (∑ i, (B i).card) ≤ Fintype.card V := by + have hd : (↑(Finset.univ : Finset (Fin t)) : Set (Fin t)).PairwiseDisjoint B := + fun i _ j _ hij => hdisj hij + rw [← Finset.card_biUnion hd] + exact Finset.card_le_univ _ + +/-- Every nonempty branch costs at least three, except for the exact deficits +of two for a singleton and one for a doubleton. -/ +theorem branch_counting [Fintype V] [DecidableEq V] + (B : Fin t → Finset V) + (hne : ∀ i, (B i).Nonempty) + (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) : + 3 * t ≤ Fintype.card V + 2 * singletonBranchCount B + doubletonBranchCount B := by + have hpoint (i : Fin t) : + 3 ≤ (B i).card + 2 * (if (B i).card = 1 then 1 else 0) + + (if (B i).card = 2 then 1 else 0) := by + have hp : 0 < (B i).card := Finset.card_pos.mpr (hne i) + split_ifs <;> omega + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hpoint i) + have hsum' : 3 * t ≤ (∑ i, (B i).card) + + 2 * singletonBranchCount B + doubletonBranchCount B := by + simpa only [Finset.sum_add_distrib, ← Finset.mul_sum, + sum_singleton_indicator, sum_doubleton_indicator, Finset.sum_const, + Finset.card_univ, Fintype.card_fin, Nat.nsmul_eq_mul, mul_comm t 3] using hsum + exact hsum'.trans (Nat.add_le_add_right + (Nat.add_le_add_right (branch_card_sum_le B hdisj) _) _) + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/BranchGeometry.lean b/lean/OAI/Combinatorics/HadwigerMatching/BranchGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcf6ae2018f8bc7576da25640bef7522181aeb83 --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/BranchGeometry.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.ListHadwiger.Basic + +namespace OAI + +/-! Clique geometry of singleton and doubleton branches and finite clique-minor models. -/ +namespace HadwigerMatching + +variable {V : Type} {G : SimpleGraph V} + +/-- A connected induced graph on precisely two vertices contains their edge. -/ +theorem connected_card_two_isClique [DecidableEq V] (S : Finset V) + (hS : S.card = 2) (hc : (G.induce (S : Set V)).Connected) : + G.IsClique (S : Set V) := by + obtain ⟨a, b, hab, rfl⟩ := Finset.card_eq_two.mp hS + have hedge : G.Adj a b := by + let a' : ({a, b} : Finset V) := ⟨a, by simp⟩ + let b' : ({a, b} : Finset V) := ⟨b, by simp⟩ + have hne : a' ≠ b' := by + intro h + exact hab (congrArg Subtype.val h) + obtain ⟨p⟩ := hc.preconnected a' b' + have hadj := p.adj_snd (p.not_nil_of_ne hne) + have hsnd : (p.snd : V) = a ∨ (p.snd : V) = b := by + simpa using p.snd.property + rcases hsnd with hsnd | hsnd + · change G.Adj a (p.snd : V) at hadj + rw [hsnd] at hadj + exact (G.irrefl hadj).elim + · simpa [a', hsnd] using hadj + intro x hx y hy hxy + have hx' : x = a ∨ x = b := by simpa using hx + have hy' : y = a ∨ y = b := by simpa using hy + rcases hx' with rfl | rfl <;> rcases hy' with rfl | rfl + · exact (hxy rfl).elim + · exact hedge + · exact hedge.symm + · exact (hxy rfl).elim + +/-- The vertices of singleton branches form a clique in `G`. -/ +theorem singleton_vertices_isClique {ι : Type*} (B : ι → Set V) + (htouch : ∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w) : + G.IsClique {v | ∃ i, B i = {v}} := by + rintro x ⟨i, hi⟩ y ⟨j, hj⟩ hxy + have hij : i ≠ j := by + intro h + subst j + have : x ∈ ({y} : Set V) := by rw [← hj, hi]; simp + exact hxy (Set.mem_singleton_iff.mp this) + obtain ⟨v, hv, w, hw, hvw⟩ := htouch i j hij + have hvx : v = x := by simpa [hi] using hv + have hwy : w = y := by simpa [hj] using hw + simpa [hvx, hwy] using hvw + +/-- On a finite vertex type, clique-minor branches can be represented by finite sets. -/ +theorem finite_branch_model [Fintype V] {t : ℕ} + (h : LinearListHadwiger.HasCliqueMinor G t) : + ∃ B : Fin t → Finset V, + (∀ i, (G.induce (B i : Set V)).Connected) ∧ + (∀ i, (B i).Nonempty) ∧ + Pairwise (fun i j => Disjoint (B i) (B j)) ∧ + (∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w) := by + classical + obtain ⟨A, hconn, hdisj, htouch⟩ := h + let B : Fin t → Finset V := fun i => (A i).toFinset + have hcoe (i : Fin t) : (B i : Set V) = A i := by simp [B] + refine ⟨B, ?_, ?_, ?_, ?_⟩ + · intro i + rw [hcoe] + exact hconn i + · intro i + obtain ⟨v⟩ := (hconn i).nonempty + exact ⟨v.val, Set.mem_toFinset.mpr v.property⟩ + · intro i j hij + apply Finset.disjoint_left.mpr + intro v hvi hvj + exact Set.disjoint_left.mp (hdisj i j hij) + (by simpa [B] using hvi) (by simpa [B] using hvj) + · intro i j hij + obtain ⟨v, hv, w, hw, hvw⟩ := htouch i j hij + exact ⟨v, by simpa [B] using hv, w, by simpa [B] using hw, hvw⟩ + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/ChromaticBound.lean b/lean/OAI/Combinatorics/HadwigerMatching/ChromaticBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..b03683341bc908d1eb534cb60f435f9ff3e55ee1 --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/ChromaticBound.lean @@ -0,0 +1,59 @@ +import Mathlib.Combinatorics.SimpleGraph.Coloring.Vertex +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset + +namespace OAI + +/-! A chromatic lower bound for finite graphs with independence number at most two. -/ + +namespace HadwigerMatching + +open scoped BigOperators + +variable {V : Type*} [Fintype V] (G : SimpleGraph V) + +/-- Every color fiber is an independent vertex set, so a coloring by `k` +colors can cover at most `2*k` vertices under the stated independence bound. -/ +theorem card_le_twice_of_coloring {k : ℕ} (C : G.Coloring (Fin k)) + (hα : ∀ S : Finset V, G.IsIndepSet (S : Set V) → S.card ≤ 2) : + Fintype.card V ≤ 2 * k := by + classical + let fiber : Fin k → Finset V := fun c => Finset.univ.filter (fun v => C v = c) + have hfiber (c : Fin k) : (fiber c).card ≤ 2 := by + apply hα + intro v hv w hw _ hadj + exact C.valid hadj ((Finset.mem_filter.mp hv).2.trans + (Finset.mem_filter.mp hw).2.symm) + have hcount : ∑ c : Fin k, (fiber c).card = Fintype.card V := by + simp only [fiber, Finset.card_eq_sum_ones, Finset.sum_filter] + rw [Finset.sum_comm] + simp + calc + Fintype.card V = ∑ c : Fin k, (fiber c).card := hcount.symm + _ ≤ ∑ _c : Fin k, 2 := Finset.sum_le_sum (fun c _ => hfiber c) + _ = 2 * k := by simp [Nat.mul_comm] + +/-- A finite graph has finite chromatic number; an optimal coloring +then proves the lower bound, including the empty vertex type. -/ +theorem card_le_twice_chromaticNumber + (hα : ∀ S : Finset V, G.IsIndepSet (S : Set V) → S.card ≤ 2) : + Fintype.card V ≤ 2 * G.chromaticNumber.toNat := by + have hfinite : G.chromaticNumber ≠ ⊤ := by + intro htop + have h := G.chromaticNumber_le_card + rw [htop] at h + simp at h + obtain ⟨C⟩ := G.colorable_of_chromaticNumber_ne_top hfinite + exact card_le_twice_of_coloring G C hα + +/-- A graph with independence number at most two needs at least half as many +colors as vertices. -/ +theorem card_le_twice_chromaticNumber_of_indepNum (hα : G.indepNum ≤ 2) : + Fintype.card V ≤ 2 * G.chromaticNumber.toNat := by + apply card_le_twice_chromaticNumber G + intro S hS + exact hS.card_le_indepNum.trans hα + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/Definitions.lean b/lean/OAI/Combinatorics/HadwigerMatching/Definitions.lean new file mode 100644 index 0000000000000000000000000000000000000000..844de0ed720be7398910108c6d6d9184630fc16e --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/Definitions.lean @@ -0,0 +1,25 @@ +import Mathlib.Combinatorics.SimpleGraph.Clique + +namespace OAI + +namespace HadwigerMatching + +universe u +variable {V : Type u} + +/-- A finite matching whose edges are pairwise touching: each member is a +two-vertex clique, and distinct members are disjoint and joined by an edge. -/ +def IsTouchingMatching (G : SimpleGraph V) (M : Finset (Finset V)) : Prop := + (∀ e ∈ M, e.card = 2 ∧ G.IsClique (e : Set V)) ∧ + (∀ e ∈ M, ∀ f ∈ M, e ≠ f → Disjoint e f) ∧ + (∀ e ∈ M, ∀ f ∈ M, e ≠ f → + ∃ v ∈ e, ∃ w ∈ f, G.Adj v w) + +/-- The supremum of the cardinalities of pairwise touching matchings. +For finite vertex types, this supremum is attained. -/ +noncomputable def connectedMatchingNumber (G : SimpleGraph V) : ℕ := + sSup {n : ℕ | ∃ M : Finset (Finset V), IsTouchingMatching G M ∧ M.card = n} + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/FinitePairing.lean b/lean/OAI/Combinatorics/HadwigerMatching/FinitePairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..17ef437bd4b6259cd4f6b1ff609bc2b7a1ab9b6c --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/FinitePairing.lean @@ -0,0 +1,80 @@ +import Mathlib.Data.Finset.Card +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace HadwigerMatching + +/-- A finite set admits pairwise disjoint two-element subsets covering all but at most +one of its elements, without requiring the ambient type to be finite. -/ +theorem exists_finite_pairing {V : Type*} (S : Finset V) : + ∃ P : Finset (Finset V), + (∀ A ∈ P, A.card = 2 ∧ A ⊆ S) ∧ + (∀ A ∈ P, ∀ B ∈ P, A ≠ B → Disjoint A B) ∧ + 2 * P.card ≤ S.card ∧ S.card ≤ 2 * P.card + 1 := by + classical + induction S using Finset.strongInductionOn with + | _ S ih => + by_cases hsmall : S.card ≤ 1 + · exact ⟨∅, by simp, by simp, by simp, by simpa using hsmall⟩ + have hpos : 0 < S.card := by omega + obtain ⟨a, ha⟩ := Finset.card_pos.mp hpos + have hca := Finset.card_erase_add_one ha + have hpos' : 0 < (S.erase a).card := by omega + obtain ⟨b, hb⟩ := Finset.card_pos.mp hpos' + have hba : b ≠ a := (Finset.mem_erase.mp hb).1 + have hbS : b ∈ S := (Finset.mem_erase.mp hb).2 + let R := (S.erase a).erase b + have hR : R ⊂ S := + Finset.ssubset_of_subset_of_ssubset (Finset.erase_subset _ _) (Finset.erase_ssubset ha) + obtain ⟨P, hP, hdisj, hlo, hhi⟩ := ih R hR + have hcr : R.card + 2 = S.card := by + have hcb := Finset.card_erase_add_one hb + dsimp [R] + omega + have hRsub : R ⊆ S := fun x hx => + Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hx) + have haR : a ∉ R := by simp [R] + have hbR : b ∉ R := by simp [R] + have hpair : ({a, b} : Finset V).card = 2 := by simp [Ne.symm hba] + have hpairsub : ({a, b} : Finset V) ⊆ S := by + intro x hx + rcases Finset.mem_insert.mp hx with rfl | hx + · exact ha + · have hxb := Finset.mem_singleton.mp hx + subst x + exact hbS + have hnew : ({a, b} : Finset V) ∉ P := by + intro hp + exact haR ((hP _ hp).2 (by simp)) + have hpairdisj : ∀ A ∈ P, Disjoint ({a, b} : Finset V) A := by + intro A hA + apply Finset.disjoint_left.mpr + intro x hx hxA + have hxR := (hP A hA).2 hxA + rcases Finset.mem_insert.mp hx with rfl | hx + · exact haR hxR + · have hxb := Finset.mem_singleton.mp hx + subst x + exact hbR hxR + refine ⟨insert {a, b} P, ?_, ?_, ?_, ?_⟩ + · intro A hA + rcases Finset.mem_insert.mp hA with rfl | hA + · exact ⟨hpair, hpairsub⟩ + · exact ⟨(hP A hA).1, fun x hx => hRsub ((hP A hA).2 hx)⟩ + · intro A hA B hB hne + rcases Finset.mem_insert.mp hA with rfl | hA + · rcases Finset.mem_insert.mp hB with rfl | hB + · exact (hne rfl).elim + · exact hpairdisj B hB + · rcases Finset.mem_insert.mp hB with rfl | hB + · exact (hpairdisj A hA).symm + · exact hdisj A hA B hB hne + · rw [Finset.card_insert_of_notMem hnew] + omega + · rw [Finset.card_insert_of_notMem hnew] + omega + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/Main.lean b/lean/OAI/Combinatorics/HadwigerMatching/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..74271efa4ad2e3d6e231c54dd7f08ce80e6c5b78 --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/Main.lean @@ -0,0 +1,39 @@ +import OAI.Combinatorics.HadwigerMatching.MinorBound +import OAI.Combinatorics.HadwigerMatching.ChromaticBound +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum + +namespace OAI + +namespace HadwigerMatching + +/-- The matching–minor proposition: the Hadwiger bound and its chromatic +consequence when the independence and touching-matching numbers are small. -/ +theorem full_matching_minor_proposition + (V : Type) [Fintype V] [Nonempty V] (G : SimpleGraph V) : + let m : ℕ := Fintype.card V + let h : ℕ := LinearListHadwiger.hadwigerNumber G + let c : ℕ := HadwigerMatching.connectedMatchingNumber G + (h : ℚ) ≤ ((m : ℚ) + 4 * (c : ℚ) + 2) / 3 ∧ + (G.indepNum ≤ 2 → + (c : ℚ) < (m : ℚ) / 100 → + 5 ≤ m → + (h : ℚ) < 26 * (m : ℚ) / 75 + 2 / 3 ∧ + 26 * (m : ℚ) / 75 + 2 / 3 < (m : ℚ) / 2 ∧ + (m : ℚ) / 2 ≤ (G.chromaticNumber.toNat : ℚ)) := by + dsimp only + have hn := hadwiger_matching_bound G + have hq : 3 * (LinearListHadwiger.hadwigerNumber G : ℚ) ≤ + (Fintype.card V : ℚ) + 4 * (connectedMatchingNumber G : ℚ) + 2 := by + exact_mod_cast hn + refine ⟨by linarith, ?_⟩ + intro hα hc hm + have hm' : (5 : ℚ) ≤ (Fintype.card V : ℚ) := by exact_mod_cast hm + have hnχ := card_le_twice_chromaticNumber_of_indepNum G hα + have hχ : (Fintype.card V : ℚ) ≤ 2 * (G.chromaticNumber.toNat : ℚ) := by + exact_mod_cast hnχ + refine ⟨?_, ?_, ?_⟩ <;> linarith + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/MinorBound.lean b/lean/OAI/Combinatorics/HadwigerMatching/MinorBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d143ddefd4146254b4be1604642eb214ec2e3a2 --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/MinorBound.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.HadwigerMatching.SmallBranches +import OAI.Combinatorics.HadwigerMatching.BranchGeometry +import OAI.Combinatorics.HadwigerMatching.PairingExtension +import OAI.Combinatorics.HadwigerMatching.BasicMatching + +namespace OAI + +/-! The integral Hadwiger bound from pairwise touching matchings. + +The small-branch counting argument is Proposition `matching-minor` of +*A counterexample to Hadwiger's conjecture*, following the connected-matching +approach of Cambie. +-/ + +namespace HadwigerMatching + +variable {V : Type} [Fintype V] {G : SimpleGraph V} + +/-- The singleton and doubleton deficits of an actual clique-minor model are +controlled by a touching matching constructed from those very branches. -/ +theorem small_branch_deficit_le {t : ℕ} (B : Fin t → Finset V) + (hconn : ∀ i, (G.induce (B i : Set V)).Connected) + (hne : ∀ i, (B i).Nonempty) + (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) + (htouch : ∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w) : + 2 * singletonBranchCount B + doubletonBranchCount B ≤ + 4 * connectedMatchingNumber G + 2 := by + classical + have hE := twoVertexBranches_isTouchingMatching G B hdisj htouch + (fun i hi => connected_card_two_isClique (B i) hi (hconn i)) + obtain ⟨P, hP, hcard, hcover⟩ := extend_matching_by_clique_pairs G + (twoVertexBranches B) (singletonVertices B) hE + (singletonVertices_isClique G B htouch) + (fun _ he => twoVertexBranches_disjoint_singletonVertices B hdisj he) + (fun _ hv _ he => singletonVertices_touch_twoVertexBranches G B htouch hv he) + have hbound := matching_card_le_number hP + rw [hcard, card_twoVertexBranches B hne hdisj] at hbound + rw [card_singletonVertices B hdisj] at hcover + omega + +/-- Every clique minor satisfies the integral matching bound. -/ +theorem clique_minor_matching_bound {t : ℕ} + (h : LinearListHadwiger.HasCliqueMinor G t) : + 3 * t ≤ Fintype.card V + 4 * connectedMatchingNumber G + 2 := by + classical + obtain ⟨B, hconn, hne, hdisj, htouch⟩ := finite_branch_model h + have hcount := branch_counting B hne hdisj + have hsmall := small_branch_deficit_le B hconn hne hdisj htouch + omega + +/-- The maximum is attained by an actual clique-minor branch model. This proves +the bound for the literal Hadwiger number, including the empty graph. -/ +theorem hadwiger_matching_bound (G : SimpleGraph V) : + 3 * LinearListHadwiger.hadwigerNumber G ≤ + Fintype.card V + 4 * connectedMatchingNumber G + 2 := + clique_minor_matching_bound (LinearListHadwiger.hasCliqueMinor_hadwigerNumber G) + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/PairingExtension.lean b/lean/OAI/Combinatorics/HadwigerMatching/PairingExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f9f21ad397916e5c55e9f449ca7e43f3e44cd06 --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/PairingExtension.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.HadwigerMatching.Definitions +import OAI.Combinatorics.HadwigerMatching.FinitePairing + +namespace OAI + +namespace HadwigerMatching + +/-- Disjoint pairs from a clique extend a touching matching when every clique vertex +is adjacent to a vertex in each existing matching edge. -/ +theorem extend_matching_by_clique_pairs {V : Type*} [DecidableEq V] + (G : SimpleGraph V) (E : Finset (Finset V)) (S : Finset V) + (hE : IsTouchingMatching G E) (hS : G.IsClique (S : Set V)) + (hdisj : ∀ e ∈ E, Disjoint e S) + (htouch : ∀ v ∈ S, ∀ e ∈ E, ∃ w ∈ e, G.Adj v w) : + ∃ P : Finset (Finset V), IsTouchingMatching G (E ∪ P) ∧ + (E ∪ P).card = E.card + P.card ∧ S.card ≤ 2 * P.card + 1 := by + classical + obtain ⟨P, hP, hPP, _hlo, hhi⟩ := exists_finite_pairing S + have hnonempty : ∀ p ∈ P, p.Nonempty := by + intro p hp + exact Finset.card_pos.mp (by rw [(hP p hp).1]; decide) + have hEP : ∀ e ∈ E, ∀ p ∈ P, Disjoint e p := by + intro e he p hp + apply Finset.disjoint_left.mpr + intro x hxe hxp + exact Finset.disjoint_left.mp (hdisj e he) hxe ((hP p hp).2 hxp) + have hfamily : Disjoint E P := by + apply Finset.disjoint_left.mpr + intro e he hp + obtain ⟨v, hv⟩ := hnonempty e hp + exact Finset.disjoint_left.mp (hEP e he e hp) hv hv + have hclique : ∀ p ∈ P, G.IsClique (p : Set V) := by + intro p hp v hv w hw hne + exact hS ((hP p hp).2 hv) ((hP p hp).2 hw) hne + have hPT : ∀ p ∈ P, ∀ q ∈ P, p ≠ q → + ∃ v ∈ p, ∃ w ∈ q, G.Adj v w := by + intro p hp q hq hne + obtain ⟨v, hv⟩ := hnonempty p hp + obtain ⟨w, hw⟩ := hnonempty q hq + have hvw : v ≠ w := by + intro heq + subst w + exact Finset.disjoint_left.mp (hPP p hp q hq hne) hv hw + exact ⟨v, hv, w, hw, hS ((hP p hp).2 hv) ((hP q hq).2 hw) hvw⟩ + have hPEtouch : ∀ p ∈ P, ∀ e ∈ E, + ∃ v ∈ p, ∃ w ∈ e, G.Adj v w := by + intro p hp e he + obtain ⟨v, hv⟩ := hnonempty p hp + obtain ⟨w, hw, hvw⟩ := htouch v ((hP p hp).2 hv) e he + exact ⟨v, hv, w, hw, hvw⟩ + refine ⟨P, ?_, Finset.card_union_of_disjoint hfamily, hhi⟩ + refine ⟨?_, ?_, ?_⟩ + · intro e he + rcases Finset.mem_union.mp he with he | he + · exact hE.1 e he + · exact ⟨(hP e he).1, hclique e he⟩ + · intro e he f hf hne + rcases Finset.mem_union.mp he with he | he <;> + rcases Finset.mem_union.mp hf with hf | hf + · exact hE.2.1 e he f hf hne + · exact hEP e he f hf + · exact (hEP f hf e he).symm + · exact hPP e he f hf hne + · intro e he f hf hne + rcases Finset.mem_union.mp he with he | he <;> + rcases Finset.mem_union.mp hf with hf | hf + · exact hE.2.2 e he f hf hne + · obtain ⟨v, hv, w, hw, hvw⟩ := hPEtouch f hf e he + exact ⟨w, hw, v, hv, hvw.symm⟩ + · exact hPEtouch e he f hf + · exact hPT e he f hf hne + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HadwigerMatching/SmallBranches.lean b/lean/OAI/Combinatorics/HadwigerMatching/SmallBranches.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ee8c8dd2144f4c4e899e60d352fe2177c293d93 --- /dev/null +++ b/lean/OAI/Combinatorics/HadwigerMatching/SmallBranches.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.HadwigerMatching.Definitions +import OAI.Combinatorics.HadwigerMatching.BranchCounting + +namespace OAI + +/-! Cliques and touching matchings formed by singleton and doubleton branches. -/ +namespace HadwigerMatching +open scoped BigOperators +variable {V : Type*} [DecidableEq V] {t : ℕ} + +def singletonVertices (B : Fin t → Finset V) : Finset V := + (Finset.univ.filter fun i => (B i).card = 1).biUnion B + +def twoVertexBranches (B : Fin t → Finset V) : Finset (Finset V) := + (Finset.univ.filter fun i => (B i).card = 2).image B + +theorem mem_singletonVertices (B : Fin t → Finset V) (v : V) : + v ∈ singletonVertices B ↔ ∃ i, (B i).card = 1 ∧ v ∈ B i := by + simp [singletonVertices] + +theorem mem_twoVertexBranches (B : Fin t → Finset V) (e : Finset V) : + e ∈ twoVertexBranches B ↔ ∃ i, (B i).card = 2 ∧ B i = e := by + simp [twoVertexBranches] + +omit [DecidableEq V] in +/-- Nonemptiness is essential: distinct empty branches would not be injective. -/ +theorem branches_injective (B : Fin t → Finset V) + (hne : ∀ i, (B i).Nonempty) + (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) : + Function.Injective B := by + intro i j he + by_contra hij + obtain ⟨v, hv⟩ := hne i + exact Finset.disjoint_left.mp (hdisj hij) hv (he ▸ hv) + +theorem card_singletonVertices (B : Fin t → Finset V) + (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) : + (singletonVertices B).card = singletonBranchCount B := by + unfold singletonVertices singletonBranchCount + rw [Finset.card_biUnion (fun i _ j _ hij => hdisj hij)] + calc + (∑ i ∈ Finset.univ.filter (fun i => (B i).card = 1), (B i).card) = + ∑ i ∈ Finset.univ.filter (fun i => (B i).card = 1), 1 := by + apply Finset.sum_congr rfl + intro i hi + exact (Finset.mem_filter.mp hi).2 + _ = _ := by simp + +theorem card_twoVertexBranches (B : Fin t → Finset V) + (hne : ∀ i, (B i).Nonempty) + (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) : + (twoVertexBranches B).card = doubletonBranchCount B := by + unfold twoVertexBranches doubletonBranchCount + exact Finset.card_image_of_injective _ (branches_injective B hne hdisj) + +omit [DecidableEq V] in +theorem singleton_branch_eq (B : Fin t → Finset V) {i : Fin t} {v : V} + (hi : (B i).card = 1) (hv : v ∈ B i) : B i = {v} := by + obtain ⟨w, hw⟩ := Finset.card_eq_one.mp hi + have hvw : v = w := by simpa [hw] using hv + simpa [hvw] using hw + +theorem singletonVertices_isClique (G : SimpleGraph V) (B : Fin t → Finset V) + (htouch : ∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w) : + G.IsClique (singletonVertices B : Set V) := by + intro v hv w hw hvw + obtain ⟨i, hi, hvi⟩ := (mem_singletonVertices B v).mp hv + obtain ⟨j, hj, hwj⟩ := (mem_singletonVertices B w).mp hw + have hBi := singleton_branch_eq B hi hvi + have hBj := singleton_branch_eq B hj hwj + have hij : i ≠ j := by + intro he + have hmem : v ∈ B j := he ▸ hvi + have hvw' : v = w := by simpa [hBj] using hmem + exact hvw hvw' + obtain ⟨x, hx, y, hy, hxy⟩ := htouch i j hij + have hxv : x = v := by simpa [hBi] using hx + have hyw : y = w := by simpa [hBj] using hy + simpa [hxv, hyw] using hxy + +theorem twoVertexBranches_isTouchingMatching (G : SimpleGraph V) + (B : Fin t → Finset V) + (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) + (htouch : ∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w) + (hclique : ∀ i, (B i).card = 2 → G.IsClique (B i : Set V)) : + IsTouchingMatching G (twoVertexBranches B) := by + refine ⟨?_, ?_, ?_⟩ + · intro e he + obtain ⟨i, hi, rfl⟩ := (mem_twoVertexBranches B e).mp he + exact ⟨hi, hclique i hi⟩ + · intro e he f hf hef + obtain ⟨i, _, rfl⟩ := (mem_twoVertexBranches B e).mp he + obtain ⟨j, _, rfl⟩ := (mem_twoVertexBranches B f).mp hf + exact hdisj (fun hij => hef (congrArg B hij)) + · intro e he f hf hef + obtain ⟨i, _, rfl⟩ := (mem_twoVertexBranches B e).mp he + obtain ⟨j, _, rfl⟩ := (mem_twoVertexBranches B f).mp hf + exact htouch i j (fun hij => hef (congrArg B hij)) + +theorem twoVertexBranches_disjoint_singletonVertices (B : Fin t → Finset V) + (hdisj : Pairwise (fun i j => Disjoint (B i) (B j))) + {e : Finset V} (he : e ∈ twoVertexBranches B) : + Disjoint e (singletonVertices B) := by + obtain ⟨i, hi, rfl⟩ := (mem_twoVertexBranches B e).mp he + apply Finset.disjoint_left.mpr + intro v hvi hv + obtain ⟨j, hj, hvj⟩ := (mem_singletonVertices B v).mp hv + have hij : i ≠ j := by + intro heq + have : (2 : ℕ) = 1 := hi.symm.trans ((congrArg (fun k => (B k).card) heq).trans hj) + exact (by decide : (2 : ℕ) ≠ 1) this + exact Finset.disjoint_left.mp (hdisj hij) hvi hvj + +theorem singletonVertices_touch_twoVertexBranches (G : SimpleGraph V) + (B : Fin t → Finset V) + (htouch : ∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w) + {v : V} (hv : v ∈ singletonVertices B) + {e : Finset V} (he : e ∈ twoVertexBranches B) : + ∃ w ∈ e, G.Adj v w := by + obtain ⟨i, hi, hvi⟩ := (mem_singletonVertices B v).mp hv + obtain ⟨j, hj, rfl⟩ := (mem_twoVertexBranches B e).mp he + have hij : i ≠ j := by + intro heq + have : (1 : ℕ) = 2 := hi.symm.trans ((congrArg (fun k => (B k).card) heq).trans hj) + exact (by decide : (1 : ℕ) ≠ 2) this + obtain ⟨x, hx, w, hw, hxw⟩ := htouch i j hij + have hxv : x = v := by simpa [singleton_branch_eq B hi hvi] using hx + exact ⟨w, hw, hxv ▸ hxw⟩ + +end HadwigerMatching + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Activity.lean b/lean/OAI/Combinatorics/HalvingLines/Activity.lean new file mode 100644 index 0000000000000000000000000000000000000000..41c93281647ae37ac5c4f3c7ed62058074a28f5e --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Activity.lean @@ -0,0 +1,325 @@ +import OAI.Combinatorics.HalvingLines.Basic + +namespace OAI + +namespace PlanarHalving + +namespace Sweep + +noncomputable def projection (s : ℝ) (p : Point) : ℝ := p.2 - s * p.1 + +def Separates {n : ℕ} (P : Fin n → Point) (s : ℝ) (M : Finset (Fin n)) : Prop := + ∀ i ∈ M, ∀ j ∉ M, projection s (P i) < projection s (P j) + +lemma comparison_persists (p q : Point) {s₀ s t : ℝ} (h₀ : s₀ ≤ s) (ht : s ≤ t) + (hbefore : projection s₀ q < projection s₀ p) + (hafter : projection s p < projection s q) : + p.1 > q.1 ∧ projection t p < projection t q := by + unfold projection at * + have hm : 0 < (s - s₀) * (p.1 - q.1) := by nlinarith only [hbefore, hafter] + have hx : 0 < p.1 - q.1 := by + rcases mul_pos_iff.mp hm with hh | hh + · exact hh.2 + · exact False.elim ((not_lt_of_ge (sub_nonneg.mpr h₀)) hh.1) + have hprod := mul_nonneg (sub_nonneg.mpr ht) hx.le + constructor + · exact sub_pos.mp hx + · nlinarith only [hafter, hprod] + +lemma exchange_rightward {n : ℕ} {P : Fin n → Point} {s t : ℝ} + {M M' : Finset (Fin n)} (hst : s ≤ t) + (hM : Separates P s M) (hM' : Separates P t M') + {i j : Fin n} (hi : i ∈ M \ M') (hj : j ∈ M' \ M) : (P i).1 < (P j).1 := by + exact (comparison_persists (P j) (P i) hst le_rfl + (hM i (Finset.mem_sdiff.mp hi).1 j (Finset.mem_sdiff.mp hj).2) + (hM' j (Finset.mem_sdiff.mp hj).1 i (Finset.mem_sdiff.mp hi).2)).1 + +theorem distance_of_outside_visitors {n k c : ℕ} (P : Fin n → Point) + (s₀ t : ℝ) (E E' U : Finset (Fin n)) + (hE : E.card = k + c) (hE' : E'.card = k + c) + (hsep : Separates P s₀ E) (hsep' : Separates P t E') + (hU : c ≤ U.card) + (hvisit : ∀ u ∈ U, u ∉ E ∧ ∃ (s : ℝ) (M : Finset (Fin n)), + s₀ ≤ s ∧ s ≤ t ∧ M.card = k ∧ Separates P s M ∧ u ∈ M) : + c ≤ (E \ E').card := by + classical + by_cases hh : ∃ u ∈ U, u ∉ E' + · obtain ⟨u, hu, hu'⟩ := hh + obtain ⟨huE, s, M, h₀, ht, hcard, hM, huM⟩ := hvisit u hu + have hsub : E \ M ⊆ E \ E' := by + intro v hv + obtain ⟨hvE, hvM⟩ := Finset.mem_sdiff.mp hv + refine Finset.mem_sdiff.mpr ⟨hvE, ?_⟩ + intro hv' + have hvt := (comparison_persists (P u) (P v) h₀ ht + (hsep v hvE u huE) (hM u huM v hvM)).2 + exact (not_lt_of_gt hvt) (hsep' v hv' u hu') + have hcount := Finset.card_sdiff_add_card_inter E M + have hinter : (E ∩ M).card ≤ M.card := Finset.card_le_card Finset.inter_subset_right + have hc : c ≤ (E \ M).card := by omega + exact hc.trans (Finset.card_le_card hsub) + · have hsub : U ⊆ E' \ E := by + intro u hu + refine Finset.mem_sdiff.mpr ⟨?_, (hvisit u hu).1⟩ + by_contra hnot + exact hh ⟨u, hu, hnot⟩ + have hc := hU.trans (Finset.card_le_card hsub) + have hc₁ := Finset.card_sdiff_add_card_inter E E' + have hc₂ := Finset.card_sdiff_add_card_inter E' E + rw [Finset.inter_comm E' E] at hc₂ + omega + +private structure ProjectionIndex (n : ℕ) where + down : Fin n + +private def projectionIndexEquiv (n : ℕ) : ProjectionIndex n ≃ Fin n where + toFun := ProjectionIndex.down + invFun := ProjectionIndex.mk + left_inv _ := rfl + right_inv _ := rfl + +theorem exists_state {n k : ℕ} (P : Fin n → Point) (s : ℝ) (hk : k ≤ n) + (hinj : Function.Injective (fun i => projection s (P i))) : + ∃ M : Finset (Fin n), M.card = k ∧ Separates P s M := by + classical + let ind := projectionIndexEquiv n + let : Fintype (ProjectionIndex n) := Fintype.ofEquiv (Fin n) ind.symm + let : LinearOrder (ProjectionIndex n) := + LinearOrder.lift' (fun i => projection s (P (ind i))) (hinj.comp ind.injective) + let e := Fintype.orderIsoFinOfCardEq (ProjectionIndex n) + ((Fintype.card_congr ind).trans (Fintype.card_fin n)) + let f : Fin k ↪ Fin n := (Fin.castLEEmb hk).trans + (e.toEmbedding.trans ind.toEmbedding) + let M := Finset.univ.map f + have hmem (z : Fin n) : z ∈ M ↔ (e.symm (ind.symm z)).val < k := by + constructor + · intro hz + obtain ⟨a, _, rfl⟩ := Finset.mem_map.mp hz + change (e.symm (ind.symm (ind (e (Fin.castLE hk a))))).val < k + rw [ind.symm_apply_apply, e.symm_apply_apply] + exact a.isLt + · intro hz + let a : Fin k := ⟨(e.symm (ind.symm z)).val, hz⟩ + apply Finset.mem_map.mpr + refine ⟨a, Finset.mem_univ _, ?_⟩ + change ind (e (Fin.castLE hk a)) = z + apply ind.symm.injective + rw [ind.symm_apply_apply] + apply e.symm.injective + rw [e.symm_apply_apply] + apply Fin.ext + rfl + refine ⟨M, by simp only [M, Finset.card_map, Finset.card_univ, Fintype.card_fin], ?_⟩ + intro i hi j hj + have hi' := (hmem i).mp hi + have hj' : k ≤ (e.symm (ind.symm j)).val := Nat.le_of_not_gt (fun h => hj ((hmem j).mpr h)) + have hlt : e.symm (ind.symm i) < e.symm (ind.symm j) := by + change (e.symm (ind.symm i)).val < (e.symm (ind.symm j)).val + exact lt_of_lt_of_le hi' hj' + have he := e.strictMono hlt + rw [e.apply_symm_apply, e.apply_symm_apply] at he + change projection s (P (ind (ind.symm i))) < projection s (P (ind (ind.symm j))) at he + simpa only [ind.apply_symm_apply] using he + +lemma states_nested {n : ℕ} {P : Fin n → Point} {s : ℝ} {M E : Finset (Fin n)} + (hM : Separates P s M) (hE : Separates P s E) (hcard : M.card ≤ E.card) : M ⊆ E := by + classical + intro i hi + by_contra hiE + have hsub : E ⊆ M := by + intro j hj + by_contra hjM + exact (not_lt_of_gt (hM i hi j hjM)) (hE j hj i hiE) + have heq := Finset.eq_of_subset_of_card_le hsub hcard + exact hiE (heq.symm ▸ hi) + +theorem outside_class_distance {n k c : ℕ} (P : Fin n → Point) + (s₀ t : ℝ) (M₀ E E' V : Finset (Fin n)) + (hM₀ : M₀.card = k) (hE : E.card = k + c) (hE' : E'.card = k + c) + (hsep₀ : Separates P s₀ M₀) (hsep : Separates P s₀ E) + (hsep' : Separates P t E') (hV : 2 * c ≤ V.card) + (hvisit : ∀ u ∈ V, u ∉ M₀ ∧ ∃ (s : ℝ) (M : Finset (Fin n)), + s₀ ≤ s ∧ s ≤ t ∧ M.card = k ∧ Separates P s M ∧ u ∈ M) : + c ≤ (E \ E').card := by + classical + have hsubset : M₀ ⊆ E := states_nested hsep₀ hsep (by omega) + have hdiff : (E \ M₀).card = c := by + have hh := Finset.card_sdiff_add_card_inter E M₀ + rw [Finset.inter_eq_right.mpr hsubset, hM₀, hE] at hh + omega + have hinter : V ∩ E ⊆ E \ M₀ := by + intro u hu + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_inter.mp hu).2, + (hvisit u (Finset.mem_inter.mp hu).1).1⟩ + have hU : c ≤ (V \ E).card := by + have hh := Finset.card_sdiff_add_card_inter V E + have hle := Finset.card_le_card hinter + omega + apply distance_of_outside_visitors P s₀ t E E' (V \ E) hE hE' hsep hsep' hU + intro u hu + exact ⟨(Finset.mem_sdiff.mp hu).2, (hvisit u (Finset.mem_sdiff.mp hu).1).2⟩ + +end Sweep + +namespace Sweep + +lemma separates_neg_compl {n : ℕ} {P : Fin n → Point} {s : ℝ} + {M : Finset (Fin n)} (hM : Separates P s M) : + Separates (fun i => -P i) s Mᶜ := by + classical + intro i hi j hj + have hi' : i ∉ M := Finset.mem_compl.mp hi + have hj' : j ∈ M := by simpa using hj + have h := hM j hj' i hi' + simp only [projection, Prod.fst_neg, Prod.snd_neg] at * + linarith + +noncomputable def activity {n : ℕ} {ι : Type*} [Fintype ι] + (M : ι → Finset (Fin n)) (i₀ : ι) : Finset (Fin n) := + Finset.univ.filter fun u => ∃ i, (u ∈ M i ∧ u ∉ M i₀) ∨ + (u ∉ M i ∧ u ∈ M i₀) + +lemma mem_activity {n : ℕ} {ι : Type*} [Fintype ι] + {M : ι → Finset (Fin n)} {i₀ : ι} {u : Fin n} : + u ∈ activity M i₀ ↔ ∃ i, (u ∈ M i ∧ u ∉ M i₀) ∨ + (u ∉ M i ∧ u ∈ M i₀) := by + classical + simp [activity] + +theorem activity_distance {n k c : ℕ} {ι : Type*} [Fintype ι] + (P : Fin n → Point) (s : ι → ℝ) (M : ι → Finset (Fin n)) (i₀ i₁ : ι) + (hsize : ∀ i, (M i).card = k) (hsep : ∀ i, Separates P (s i) (M i)) + (hlo : ∀ i, s i₀ ≤ s i) (hhi : ∀ i, s i ≤ s i₁) + (hinj₀ : Function.Injective (fun u => projection (s i₀) (P u))) + (hinj₁ : Function.Injective (fun u => projection (s i₁) (P u))) + (hc : 4 * c ≤ (activity M i₀).card) : + (k + c ≤ n ∧ ∃ E E' : Finset (Fin n), + E.card = k + c ∧ E'.card = k + c ∧ + Separates P (s i₀) E ∧ Separates P (s i₁) E' ∧ c ≤ (E \ E').card) ∨ + (c ≤ k ∧ ∃ E E' : Finset (Fin n), + E.card = k - c ∧ E'.card = k - c ∧ + Separates P (s i₀) E ∧ Separates P (s i₁) E' ∧ c ≤ (E \ E').card) := by + classical + let A := activity M i₀ + let V := A \ M i₀ + let W := A ∩ M i₀ + have hpart : V.card + W.card = A.card := Finset.card_sdiff_add_card_inter A (M i₀) + have hk : k ≤ n := by + simpa only [hsize i₀, Fintype.card_fin] using (M i₀).card_le_univ + by_cases hV : 2 * c ≤ V.card + · have hVsub : V ⊆ (M i₀)ᶜ := by + intro u hu + exact Finset.mem_compl.mpr (Finset.mem_sdiff.mp hu).2 + have hfeas : k + c ≤ n := by + have hle := Finset.card_le_card hVsub + simp only [Finset.card_compl, Fintype.card_fin, hsize] at hle + omega + obtain ⟨E, hE, hsepE⟩ := exists_state P (s i₀) hfeas hinj₀ + obtain ⟨E', hE', hsepE'⟩ := exists_state P (s i₁) hfeas hinj₁ + refine Or.inl ⟨hfeas, E, E', hE, hE', hsepE, hsepE', ?_⟩ + apply outside_class_distance P (s i₀) (s i₁) (M i₀) E E' V + (hsize i₀) hE hE' (hsep i₀) hsepE hsepE' hV + intro u hu + obtain ⟨huA, huM⟩ := Finset.mem_sdiff.mp hu + obtain ⟨i, hi | hi⟩ := mem_activity.mp huA + · exact ⟨huM, s i, M i, hlo i, hhi i, hsize i, hsep i, hi.1⟩ + · exact False.elim (huM hi.2) + · have hW : 2 * c ≤ W.card := by change 4 * c ≤ A.card at hc; omega + have hfeas : c ≤ k := by + have hle : W.card ≤ (M i₀).card := Finset.card_le_card Finset.inter_subset_right + rw [hsize] at hle + omega + obtain ⟨E, hE, hsepE⟩ := exists_state P (s i₀) (show k-c ≤ n by omega) hinj₀ + obtain ⟨E', hE', hsepE'⟩ := exists_state P (s i₁) (show k-c ≤ n by omega) hinj₁ + refine Or.inr ⟨hfeas, E, E', hE, hE', hsepE, hsepE', ?_⟩ + have hbound : c ≤ (Eᶜ \ E'ᶜ).card := by + apply outside_class_distance (fun u => -P u) (s i₀) (s i₁) (M i₀)ᶜ Eᶜ E'ᶜ W + (k := n-k) (c := c) + · simp only [Finset.card_compl, Fintype.card_fin, hsize] + · simp only [Finset.card_compl, Fintype.card_fin, hE] + omega + · simp only [Finset.card_compl, Fintype.card_fin, hE'] + omega + · exact separates_neg_compl (hsep i₀) + · exact separates_neg_compl hsepE + · exact separates_neg_compl hsepE' + · exact hW + · intro u hu + obtain ⟨huA, huM⟩ := Finset.mem_inter.mp hu + obtain ⟨i, hi | hi⟩ := mem_activity.mp huA + · exact False.elim (hi.2 huM) + · refine ⟨by simpa using huM, s i, (M i)ᶜ, hlo i, hhi i, ?_, + separates_neg_compl (hsep i), Finset.mem_compl.mpr hi.1⟩ + simp only [Finset.card_compl, Fintype.card_fin, hsize] + have heq : Eᶜ \ E'ᶜ = E' \ E := by ext u; simp; tauto + rw [heq] at hbound + have he := Finset.card_sdiff_add_card_inter E E' + have he' := Finset.card_sdiff_add_card_inter E' E + rw [Finset.inter_comm E' E] at he' + omega + +lemma projection_lt_between (p q : Point) {s₀ s₁ t : ℝ} + (h₀ : s₀ ≤ t) (h₁ : t ≤ s₁) + (hp₀ : projection s₀ p < projection s₀ q) + (hp₁ : projection s₁ p < projection s₁ q) : projection t p < projection t q := by + unfold projection at * + by_cases hx : p.1 ≤ q.1 + · have hprod := mul_nonneg (sub_nonneg.mpr h₁) (sub_nonneg.mpr hx) + nlinarith only [hp₁, hprod] + · have hprod := mul_nonneg (sub_nonneg.mpr h₀) (sub_nonneg.mpr (le_of_not_ge hx)) + nlinarith only [hp₀, hprod] + +lemma separates_between {n : ℕ} {P : Fin n → Point} {s₀ s₁ t : ℝ} + {M : Finset (Fin n)} (h₀ : s₀ ≤ t) (h₁ : t ≤ s₁) + (hM₀ : Separates P s₀ M) (hM₁ : Separates P s₁ M) : Separates P t M := by + intro u hu v hv + exact projection_lt_between (P u) (P v) h₀ h₁ (hM₀ u hu v hv) (hM₁ u hu v hv) + +lemma states_unique {n : ℕ} {P : Fin n → Point} {s : ℝ} {M E : Finset (Fin n)} + (hM : Separates P s M) (hE : Separates P s E) (hcard : M.card = E.card) : M = E := + Finset.eq_of_subset_of_card_le (states_nested hM hE hcard.le) hcard.ge + +theorem activity_pos_distance {n k : ℕ} {ι : Type*} [Fintype ι] + (P : Fin n → Point) (s : ι → ℝ) (M : ι → Finset (Fin n)) (i₀ i₁ : ι) + (hsize : ∀ i, (M i).card = k) (hsep : ∀ i, Separates P (s i) (M i)) + (hlo : ∀ i, s i₀ ≤ s i) (hhi : ∀ i, s i ≤ s i₁) + (hactivity : 0 < (activity M i₀).card) : 1 ≤ (M i₀ \ M i₁).card := by + classical + by_contra hn + have hempty : M i₀ \ M i₁ = ∅ := Finset.card_eq_zero.mp (by omega) + have hsub : M i₀ ⊆ M i₁ := Finset.sdiff_eq_empty_iff_subset.mp hempty + have heq : M i₀ = M i₁ := Finset.eq_of_subset_of_card_le hsub (by rw [hsize, hsize]) + have hconstant (i : ι) : M i = M i₀ := by + apply states_unique (hsep i) + (separates_between (hlo i) (hhi i) (hsep i₀) (by rw [heq]; exact hsep i₁)) + rw [hsize, hsize] + obtain ⟨u, hu⟩ := Finset.card_pos.mp hactivity + obtain ⟨i, hi | hi⟩ := mem_activity.mp hu + · rw [hconstant i] at hi + exact hi.2 hi.1 + · rw [hconstant i] at hi + exact hi.1 hi.2 + +lemma exchange_slope_between {n : ℕ} {P : Fin n → Point} {s t : ℝ} + {M M' : Finset (Fin n)} (hst : s ≤ t) + (hM : Separates P s M) (hM' : Separates P t M') + {i j : Fin n} (hi : i ∈ M \ M') (hj : j ∈ M' \ M) : + s < slope (P i) (P j) ∧ slope (P i) (P j) < t := by + have hx := exchange_rightward hst hM hM' hi hj + have h₀ := hM i (Finset.mem_sdiff.mp hi).1 j (Finset.mem_sdiff.mp hj).2 + have h₁ := hM' j (Finset.mem_sdiff.mp hj).1 i (Finset.mem_sdiff.mp hi).2 + have hdx : 0 < (P j).1 - (P i).1 := sub_pos.mpr hx + unfold slope + constructor + · apply (lt_div_iff₀ hdx).mpr + unfold projection at h₀ + nlinarith only [h₀] + · apply (div_lt_iff₀ hdx).mpr + unfold projection at h₁ + nlinarith only [h₁] + +end Sweep + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/ActivityRetention.lean b/lean/OAI/Combinatorics/HalvingLines/ActivityRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9a3eacac640a939bfec09503a3191baee71fcf5 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/ActivityRetention.lean @@ -0,0 +1,402 @@ +import OAI.Combinatorics.HalvingLines.ThinStrips + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Boundary +open Set Filter MeasureTheory Batches TimeWindows RankLimits Enhancement Spatial +open scoped Topology unitInterval NNReal ENNReal Classical + +lemma finite_window_params (F : Configuration) (K : Window) (E : Point ≃L[ℝ] Point) + {A B l u : ℝ} (hA : 0 < A) (hB : 0 < B) (hlu : l < u) + (h1 : E (1,0)=A • (1,l)) (h2 : E (0,1)=B • (1,u)) + (hspan : ∀ i, (F.system.timeWindow K).slope i ∈ Icc l u) + (o : Point) {r : ℝ} (hr : 0 < r) : + ∃ p : Subwindow K → CompactParams, + (∀ J, (vertices F (physical E o r) J.val + (Prod.snd ⁻¹' (encode '' awayStrips (p J).2.1.val (p J).2.2.1.val + (fun i => ((p J).2.2.2 i).val))):ℝ) ≤ 2*(p J).1.val) ∧ + (∀ D : Finset (Subwindow K), Set.PairwiseDisjoint (↑D : Set (Subwindow K)) (fun J => carrier J.val) → + (∑ J∈D, (p J).1.val) ≤ 4 ∧ (∑ J∈D, (p J).2.2.1.val) ≤ 1) := by + classical + let S := F.system.timeWindow K + let pnt := fun v => physical E o r (F.point v) + let j : Fin F.a := ⟨0,F.a_pos⟩ + let w : Fin (length F.R K) → ℝ := fun i => S.boundaryCount pnt j i + let t : Fin (length F.R K+1) → ℝ := fun i => frameParameter A B l u (S.slope i) + let s : Subwindow K → ℕ := fun J => start F.R J.val-start F.R K + let m : Subwindow K → ℕ := fun J => length F.R J.val + have hsm (J : Subwindow K) : s J+m J ≤ length F.R K := relative_end_le F.R J.property + let b : Subwindow K → ℝ := fun J => (∑ i∈batchRange _ (s J) (m J), w i)/F.n + let ti : Subwindow K → ℝ := fun J => t ⟨s J,by have := hsm J; omega⟩ + let theta : Subwindow K → ℝ := fun J => t ⟨s J+m J,by have := hsm J; omega⟩-ti J + have hw (i) : 0 ≤ w i := Nat.cast_nonneg _ + have ht : Monotone t := by + intro i i' hii' + apply frameParameter_monotone hA hB hlu (hspan _) (hspan _) + exact S.increasing.monotone hii' + have htI (i) : t i ∈ Icc (0:ℝ) 1 := frameParameter_mem hA hB hlu (hspan _) + have hcost : (∑ i, w i) ≤ 4*(F.n:ℝ) := by + have hh := S.boundary_budget pnt j + (fun v => (actual_tokens_monotone S E hA hB hlu h1 h2 hspan o hr j v).1) + (fun v => (actual_tokens_monotone S E hA hB hlu h1 h2 hspan o hr j v).2) + dsimp only [w] + exact_mod_cast hh + have hpos : 0 < (F.n:ℝ) := Nat.cast_pos.mpr F.n_pos + have hb (J) : b J ∈ Icc (0:ℝ) 4 := by + constructor + · exact div_nonneg (Finset.sum_nonneg (fun i _ => hw i)) hpos.le + · apply (div_le_iff₀ hpos).mpr + exact (Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun i _ _ => hw i)).trans hcost + have hti (J) : ti J ∈ Icc (0:ℝ) 1 := htI _ + have htheta (J) : theta J ∈ Icc (0:ℝ) 1 := by + constructor + · exact sub_nonneg.mpr (ht (by simp [Fin.le_def])) + · have hh := (htI (⟨s J+m J,by have := hsm J; omega⟩)).2 + have hh' := (hti J).1 + dsimp [theta]; linarith + obtain ⟨c,hc,hfinite⟩ : ∃ c : Subwindow K → Fin 3 → ℝ, + (∀ J h, c J h ∈ Icc (-4:ℝ) 4) ∧ + ∀ J, (((S.window (s J) (m J) (hsm J)).vertices.filter fun v => + pnt v∈awayStrips (ti J) (theta J) (c J)).card) ≤ + 2*∑ i : Fin (m J), S.boundaryCount pnt j ⟨s J+i.val,by have := hsm J; omega⟩ := by + choose c hc hb using fun J => S.window_boundary E hA hB hlu h1 h2 hspan o hr j (s J) (m J) (hsm J) + refine ⟨c,hc,fun J => ?_⟩ + convert hb J using 1 + congr 1 + apply Finset.filter_congr + intro v _ + rfl + let p : Subwindow K → CompactParams := fun J => + (⟨b J,hb J⟩,⟨ti J,hti J⟩,⟨theta J,htheta J⟩,fun i => ⟨c J i,hc J i⟩) + refine ⟨p,?_,?_⟩ + · intro J + change (vertices F (physical E o r) J.val (Prod.snd ⁻¹' (encode '' awayStrips (ti J) (theta J) (c J))):ℝ) ≤ 2*b J + rw [vertices,System.vertexMeasure_apply _ _ ((isOpenMap_encode _ (isOpen_awayStrips _ _ _)).measurableSet.preimage measurable_snd)] + have he : ((F.system.timeWindow J.val).vertices.filter fun v => + label F (physical E o r) (F.point v)∈Prod.snd ⁻¹' (encode '' awayStrips (ti J) (theta J) (c J))) = + ((S.window (s J) (m J) (hsm J)).vertices.filter fun v => pnt v∈awayStrips (ti J) (theta J) (c J)) := by + rw [show (S.window (s J) (m J) (hsm J)).vertices=(F.system.timeWindow J.val).vertices from + F.system.relative_vertices J.property] + apply Finset.filter_congr + intro v _ + exact encode_injective.mem_set_image + rw [he] + apply (div_le_iff₀ hpos).mpr + have hh : (((S.window (s J) (m J) (hsm J)).vertices.filter fun v => pnt v∈awayStrips (ti J) (theta J) (c J)).card:ℝ) ≤ + 2*∑ i∈batchRange _ (s J) (m J), w i := by + rw [sum_batchRange (hsm J)] + dsimp only [w] + exact_mod_cast hfinite J + calc + _ ≤ 2*∑ i∈batchRange _ (s J) (m J), w i := hh + _ = 2*b J*(F.n:ℝ) := by + dsimp [b] + field_simp + · intro D hD + have hd : Set.PairwiseDisjoint (↑D : Set (Subwindow K)) (fun J => batchRange (length F.R K) (s J) (m J)) := by + intro J hJ H hH hJH + exact relative_range_disjoint F.R J H (hD hJ hH hJH) + constructor + · change (∑ J∈D, b J) ≤ 4 + simp only [b,← Finset.sum_div] + apply (div_le_iff₀ hpos).mpr + exact (sum_disjoint_ranges D s m hd w hw).trans hcost + · change (∑ J∈D, theta J) ≤ 1 + have he (J : Subwindow K) : theta J=∑ i∈batchRange _ (s J) (m J), (t i.succ-t i.castSucc) := + (parameter_range_sum (hsm J) t).symm + simp_rw [he] + exact parameter_budget D s m hd t ht htI + +end PlanarHalving.Boundary + +namespace PlanarHalving.RankLimits +open Set TimeWindows Boundary +open scoped Classical + +lemma localPartition_subset {K J : Window} {m : ℕ} (h : J∈localPartition K m) : carrier J⊆carrier K := + (Finset.mem_filter.mp h).2 + +noncomputable def subPartition (K : Window) (m : ℕ) : Finset (Subwindow K) := + (localPartition K m).attach.image (fun J => (⟨J.val,localPartition_subset J.property⟩ : Subwindow K)) + +lemma mem_subPartition {K : Window} {m : ℕ} {J : Subwindow K} : + J∈subPartition K m ↔ J.val∈localPartition K m := by + unfold subPartition + constructor + · intro h + obtain ⟨j,_,rfl⟩ := Finset.mem_image.mp h + exact j.property + · intro h + exact Finset.mem_image.mpr ⟨⟨J.val,h⟩,Finset.mem_attach _ _,Subtype.ext rfl⟩ + +lemma subPartition_map_val (K : Window) (m : ℕ) : + (subPartition K m).image Subtype.val=localPartition K m := by + ext J + constructor + · intro h + obtain ⟨j,hj,rfl⟩ := Finset.mem_image.mp h + exact mem_subPartition.mp hj + · intro h + exact Finset.mem_image.mpr ⟨⟨J,localPartition_subset h⟩,mem_subPartition.mpr h,rfl⟩ + +lemma subPartition_sum {M : Type*} [AddCommMonoid M] (K : Window) (m : ℕ) (f : Window → M) : + ∑ J∈subPartition K m, f J.val=∑ J∈localPartition K m, f J := by + rw [← subPartition_map_val K m] + rw [Finset.sum_image (fun _ _ _ _ h => Subtype.ext h)] + +lemma subPartition_disjoint (K : Window) (m : ℕ) : + Set.PairwiseDisjoint (↑(subPartition K m):Set (Subwindow K)) (fun J => carrier J.val) := by + intro J hJ H hH hJH + exact localPartition_disjoint K m (mem_subPartition.mp hJ) (mem_subPartition.mp hH) + (fun he => hJH (Subtype.ext he)) + +lemma subPartition_card (K : Window) (m : ℕ) : (subPartition K m).card ≤ 2^(K.1+m) := by + have he : (subPartition K m).card=(localPartition K m).card := by + rw [← subPartition_map_val K m,Finset.card_image_of_injective _ Subtype.val_injective] + rw [he] + apply (Finset.card_le_card (Finset.filter_subset _ _)).trans + exact (Finset.card_image_le).trans (by simp) + +lemma subPartition_tail {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) (K : Window) (m : ℕ) {u : ℝ} (hu : 0 < u) : + (((subPartition K m).filter fun J => u < ((L.vertices J.val).mass:ℝ)).card:ℝ) ≤ + 10000*u^(-(4:ℝ)/3) := by + have hh := h.activity_tail E (K.1+m) hu + rw [← filter_timePartition (K.1+m) (fun J => u < ((L.vertices J).mass:ℝ))] at hh + apply hh.trans' + apply Nat.cast_le.mpr + apply Finset.card_le_card_of_injOn Subtype.val + · intro J hJ + obtain ⟨hJ,hJu⟩ := Finset.mem_filter.mp hJ + exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp (mem_subPartition.mp hJ)).1,hJu⟩ + · exact Subtype.val_injective.injOn + +end PlanarHalving.RankLimits + +namespace PlanarHalving.Enhancement +open Set Filter MeasureTheory Batches TimeWindows RankLimits Limits Spatial +open scoped Topology unitInterval NNReal ENNReal Classical + +lemma limit_vertices_le {F : ℕ → Configuration} {ψ : ℕ → Point → Point} + {M : Index → FiniteMeasure Space} + (hM : ∀ i, Tendsto (fun n => measures (F n) (ψ n) i) atTop (𝓝 (M i))) (J : Window) : + (M (.vertex J) : Measure Space) ≤ (M .point : Measure Space) := + measure_le_of_weak_limits (hM (.vertex J)) (hM .point) (fun n => vertices_le_points (F n) (ψ n) J) + +lemma limit_edge_ac {F : ℕ → Configuration} {ψ : ℕ → Point → Point} + {M : Index → FiniteMeasure Space} + (hM : ∀ i, Tendsto (fun n => measures (F n) (ψ n) i) atTop (𝓝 (M i))) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a:ℝ)^2*(F n).n^4 / (((F n).R:ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n:ℝ)^3 / (((F n).R:ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (J : Window) : (M (.edge J) : Measure Space) ≪ (M .point : Measure Space) := by + apply Measure.AbsolutelyContinuous.trans (μ₂ := (M (.vertex J) : Measure Space)) + _ (Measure.absolutelyContinuous_of_le (limit_vertices_le hM J)) + intro U hU + let V := toMeasurable (M (.vertex J) : Measure Space) U + have hc := local_cubic hM hC hcoeff herror J (measurableSet_toMeasurable (M (.vertex J) : Measure Space) U) + have hV : M (.vertex J) V=0 := by + apply ENNReal.coe_eq_zero.mp + rw [FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,measure_toMeasurable] + exact hU + change (M (.edge J) V:ℝ)^3 ≤ C*((M (.vertex J)).mass:ℝ)^3*(M (.vertex J) V:ℝ) at hc + rw [hV,NNReal.coe_zero,mul_zero] at hc + have hz : M (.edge J) V=0 := by + apply NNReal.coe_injective + exact (pow_eq_zero_iff (by norm_num : (3:ℕ)≠0)).mp + (le_antisymm hc (pow_nonneg (NNReal.coe_nonneg _) _)) + apply measure_mono_null (subset_toMeasurable _ _) + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,hz,ENNReal.coe_zero] + +lemma lifted_mass (μ ν : FiniteMeasure Space) (ρ : FiniteMeasure Labels) + (hac : (ν : Measure Space) ≪ (μ : Measure Space)) (hmap : ν.map Prod.fst=ρ) + {G : Set Labels} (hG : MeasurableSet G) : + (ν (Prod.fst ⁻¹' G ∩ (μ : Measure Space).support):ℝ)=(ρ G:ℝ) := by + have hr := congrArg (fun m : Measure Space => m univ) + (support_lift_restrict (μ:Measure Space) (ν:Measure Space) hac (Prod.fst ⁻¹' G)) + simp only [Measure.restrict_apply_univ] at hr + have he := congrArg (fun m : FiniteMeasure Labels => (m:Measure Labels) G) hmap + rw [FiniteMeasure.toMeasure_map,Measure.map_apply measurable_fst hG] at he + change ((ν:Measure Space) _).toReal=((ρ:Measure Labels) G).toReal + rw [hr,he] + +lemma projected_mass (ν : FiniteMeasure Space) (ρ : FiniteMeasure Labels) + (hmap : ν.map Prod.fst=ρ) : ν.mass=ρ.mass := by + rw [← hmap] + change ν univ=(ν.map Prod.fst) univ + rw [FiniteMeasure.map_apply _ measurable_fst MeasurableSet.univ,preimage_univ] + +end PlanarHalving.Enhancement + +namespace PlanarHalving.Boundary +open Set Filter Metric MeasureTheory Batches TimeWindows RankLimits Enhancement Spatial +open scoped Topology unitInterval NNReal ENNReal Classical + +lemma enhanced_boundary_zero {F : ℕ → Configuration} {L : Data} (hF : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (emb : ∀ n, (F n).SweepEmbedding) + {C : ℝ} (hC : 0≤C) + (hcoeff : ∀ n, 4608*((F n).a:ℝ)^2*(F n).n^4 / (((F n).R:ℝ)*(F n).a^2)^3≤C) + (herror : Tendsto (fun n => 13824*((F n).n:ℝ)^3 / (((F n).R:ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (K : Window) (E : ℕ → Point ≃L[ℝ] Point) (o : ℕ → Point) (r : ℕ → ℝ) + (hr : ∀ n, 0 measures (F n) (physical (E n) (o n) (r n)) i) atTop (𝓝 (M i))) + (hprojection : ∀ i, (M i).map Prod.fst=old L i) + (G : Set Labels) (hG : MeasurableSet G) + (hpos : ∀ z∈Prod.fst ⁻¹' G ∩ (M .point : Measure Space).support, + ‖decode z.2‖≤1 ∧ encode (decode z.2)=z.2) + {D : ℝ} (hD : 0≤D) + (hdisk : ∀ x : Point, ∀ t : ℝ, 0 finite_window_params (F n) K (E n) + (ha n) (hb n) (hlu n) (h1 n) (h2 n) (hspan n) (o n) (hr n) + choose p hp hbudget using hparams + obtain ⟨φ,b,t,θ,c,hφ,hbounds,hb,ht,hθ,hc⟩ := params_subsequence p + have haway (J : Subwindow K) : + (M (.vertex J.val) (Prod.snd ⁻¹' (encode '' awayStrips (t J) (θ J) (c J))):ℝ)≤2*b J := by + apply moving_strips_limit ((hM (.vertex J.val)).comp hφ.tendsto_atTop) + (ht J) (hθ J) (hc J) (hb J) + exact Filter.Eventually.of_forall (fun n => hp (φ n) J) + have hactivity (J : Subwindow K) : (M (.vertex J.val) H:ℝ)≤ + 2*b J+3*(13*D*(1+3^((32:ℝ)/17))*36^((32:ℝ)/17-1))*θ J^((32:ℝ)/17-1) := by + exact limiting_activity_bound (M .point) (M (.vertex J.val)) H hH + (limit_vertices_le hM J.val) hpos hD (by norm_num) (hbounds J).2.2.1.1 + (hbounds J).1.1 (c J) hdisk (haway J) + have hbudgets (m : ℕ) : (∑ J∈subPartition K m, b J)≤4 ∧ (∑ J∈subPartition K m, θ J)≤1 := by + constructor + · exact finite_budget_limit (subPartition K m) _ b hb + (Filter.Eventually.of_forall (fun n => (hbudget (φ n) (subPartition K m) (subPartition_disjoint K m)).1)) + · exact finite_budget_limit (subPartition K m) _ θ hθ + (Filter.Eventually.of_forall (fun n => (hbudget (φ n) (subPartition K m) (subPartition_disjoint K m)).2)) + have hlam (J : Window) : (M (.edge J) H:ℝ)=(L.edgeWindow J G:ℝ) := + lifted_mass (M .point) (M (.edge J)) (L.edgeWindow J) + (limit_edge_ac hM hC hcoeff herror J) (hprojection (.edge J)) hG + have hvertex (J : Window) : (M (.vertex J)).mass=(L.vertices J).mass := + projected_mass _ _ (hprojection (.vertex J)) + let q : ℕ → ℝ := fun m => (2:ℝ)^(K.1+m) + have hq : ∀ m, 0 by positivity + have hqtop : Tendsto q atTop atTop := + (tendsto_pow_atTop_atTop_of_one_lt (by norm_num : (1:ℝ)<2)).comp (tendsto_atTop_mono (fun n => Nat.le_add_left n K.1) tendsto_id) + apply mass_eq_zero (subPartition K) (fun _ J => (M (.edge J.val) H:ℝ)) + (fun _ J => (M (.vertex J.val) H:ℝ)) (fun _ J => ((L.vertices J.val).mass:ℝ)) + (fun _ J => b J) (fun _ J => θ J) q (A:=C) + (H:=10000) (B:=3*(13*D*(1+3^((32:ℝ)/17))*36^((32:ℝ)/17-1))) (B₀:=4) (T:=1) + (α:=(32:ℝ)/17-1) (NNReal.coe_nonneg _) hC (by positivity) (by norm_num) + (by norm_num) (by norm_num) hq hqtop + · intro m + simpa only [q,Nat.cast_pow,Nat.cast_ofNat] using + (Nat.cast_le (α:=ℝ).mpr (subPartition_card K m)) + · intro m J _ + exact NNReal.coe_nonneg _ + · intro m J hJ + rw [hlam] + have hd := mem_timePartition.mp (Finset.mem_filter.mp (mem_subPartition.mp hJ)).1 + apply (NNReal.coe_le_coe.mpr ((L.edgeWindow J.val).apply_le_mass G)).trans_eq + rw [hF.edgeWindow_mass hR,hd] + simp only [q,Nat.cast_pow,Nat.cast_ofNat] + · intro m J _; exact NNReal.coe_nonneg _ + · intro m J _; exact NNReal.coe_nonneg _ + · intro m J _; exact (hbounds J).2.2.1.1 + · intro m J _ + have hh := Enhancement.local_cubic hM hC hcoeff herror J.val hH + rwa [hvertex] at hh + · intro m J _; exact hactivity J + · intro m; exact (hbudgets m).1 + · intro m; exact (hbudgets m).2 + · intro m u hu; exact subPartition_tail hF emb K m hu + · intro m + simp_rw [hlam] + rw [subPartition_sum K m (fun J => (L.edgeWindow J G:ℝ)),hF.localPartition_sum hR K m hG] + +end PlanarHalving.Boundary + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Batches TimeWindows Limits +open scoped Topology unitInterval ENNReal + +lemma Converges.window_le_edge {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) : + (L.edgeWindow J : Measure Labels)≤(L.edge : Measure Labels) := by + rw [Data.edgeWindow,Data.edge,FiniteMeasure.toMeasure_map,FiniteMeasure.toMeasure_map, + h.restriction_eq hR] + exact Measure.map_mono Measure.restrict_le_self measurable_fst + +noncomputable def commonSet (L : Data) {K : Window} (q : CommonChoice K) : Set Labels := + {z | L.conditional z (carrier q.val.1)≠0 ∧ L.conditional z (carrier q.val.2.1)≠0 ∧ + L.conditional z (carrier q.val.2.2)≠0} + +lemma commonSet_measurable (L : Data) {K : Window} (q : CommonChoice K) : + MeasurableSet (commonSet L q) := by + have hm (J : Window) : MeasurableSet {z | L.conditional z (carrier J)≠0} := + ((L.conditional.measurable_coe (measurable_carrier J)) (measurableSet_singleton 0)).compl + exact (hm q.val.1).inter ((hm q.val.2.1).inter (hm q.val.2.2)) + +lemma Converges.common_positive {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (K : Window) + (hna : ∀ᵐ z ∂(L.edge : Measure Labels), NullSingletonClass (L.conditional z)) + {T : Set Labels} (hT : MeasurableSet T) (hTp : (L.edge : Measure Labels) T≠0) + (hK : ∀ z∈T, L.conditional z (carrier K)≠0) : + ∃ (q : CommonChoice K) (E : Set Labels), MeasurableSet E ∧ E⊆T ∧ + (∀ z∈E, z∈commonSet L q) ∧ (L.edgeWindow q.val.2.2 : Measure Labels) E≠0 ∧ + (L.edgeWindow q.val.2.2 : Measure Labels).restrict E ≤ (L.edge : Measure Labels).restrict T := by + have hcover : ∀ᵐ z ∂(L.edge : Measure Labels).restrict T, ∃ q : CommonChoice K, z∈commonSet L q := by + filter_upwards [ae_restrict_of_ae hna,ae_restrict_mem hT] with z hz hzt + let := hz + exact exists_commonChoice (L.conditional z) K (hK z hzt) + obtain ⟨q,hq⟩ := positive_countable_selection (L.edge : Measure Labels) T hT hTp (commonSet L) hcover + let E := T∩commonSet L q + have hE : MeasurableSet E := hT.inter (commonSet_measurable L q) + have hac : (L.edge : Measure Labels).restrict E ≪ (L.edgeWindow q.val.2.2 : Measure Labels) := by + rw [h.window_withDensity hR] + exact restrict_ac_withDensity _ _ (L.conditional.measurable_coe (measurable_carrier _)) hE + (fun z hz => hz.2.2.2) + refine ⟨q,E,hE,inter_subset_left,fun _ hz => hz.2,?_,?_⟩ + · intro he + have hzero := hac he + rw [Measure.restrict_apply hE,inter_self] at hzero + exact hq hzero + · exact Measure.restrict_mono inter_subset_left (h.window_le_edge hR _) + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Batches TimeWindows +open scoped Topology unitInterval ENNReal + +lemma coordinate_lines_null (x : ℝ) : + (volume : Measure Point) {p | p.1=x}=0 ∧ (volume : Measure Point) {p | p.2=x}=0 := by + have h1 : {p : Point | p.1=x}=({x}:Set ℝ)×ˢuniv := by ext p; simp + have h2 : {p : Point | p.2=x}=(univ:Set ℝ)×ˢ{x} := by ext p; simp + rw [h1,h2,Measure.volume_eq_prod,Measure.prod_prod,Measure.prod_prod] + simp + +lemma pairCoordinates_interior_ae {ν : Measure Labels} {A B : Window} + (hproj : ν.map (pairCoordinates true A B) ≪ volume) : + ∀ᵐ z ∂ν, pairCoordinates true A B z∈Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0 := by + have hq : Measure.QuasiMeasurePreserving (pairCoordinates true A B) ν volume := + ⟨(continuous_pairCoordinates true A B).measurable,hproj⟩ + have ha (x : ℝ) : ∀ᵐ p ∂(volume : Measure Point), p.1≠x := by + simpa only [ae_iff,not_not] using (coordinate_lines_null x).1 + have hb (x : ℝ) : ∀ᵐ p ∂(volume : Measure Point), p.2≠x := by + simpa only [ae_iff,not_not] using (coordinate_lines_null x).2 + filter_upwards [hq.ae (ha 0),hq.ae (ha 1),hq.ae (hb (-1)),hq.ae (hb 0)] with z h1 h2 h3 h4 + dsimp [pairCoordinates,signedPair] at h1 h2 h3 h4 ⊢ + have hzA := (z A).property + have hzB := (z B).property + exact ⟨⟨lt_of_le_of_ne hzA.1 (Ne.symm h1),lt_of_le_of_ne hzA.2 h2⟩, + ⟨lt_of_le_of_ne (by linarith [hzB.2]) (Ne.symm h3),lt_of_le_of_ne (by linarith [hzB.1]) h4⟩⟩ + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/AtomicBounds.lean b/lean/OAI/Combinatorics/HalvingLines/AtomicBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea8ad98ef78aed33af7f6b0698ad5a032725c58c --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/AtomicBounds.lean @@ -0,0 +1,504 @@ +import OAI.Combinatorics.HalvingLines.Tokens + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.EdgeTrace.match_eq (S : @System n R k a P) [NeZero a] + {e : Fin n × Fin n} (t : S.EdgeTrace e) : + S.match t.number t.batch ⟨e.1,t.loss⟩ = ⟨e.2,t.gain⟩ := by + apply Subtype.ext + have hn : (S.tokenState t.number t.batch.castSucc t.token : Fin n) ∉ S.marks t.batch.succ := by + rw [t.source] + exact (Finset.mem_sdiff.mp t.loss).2 + have ht := t.target + rw [S.tokenState_succ] at ht + change (transport _ _ (S.match t.number t.batch) _ : Fin n) = e.2 at ht + rw [transport_of_not_mem (S.match t.number t.batch) _ hn] at ht + convert ht using 1 + apply congrArg (fun v : ↥(S.loss t.batch) => (S.match t.number t.batch v : Fin n)) + exact Subtype.ext t.source.symm + +lemma System.EdgeTrace.same_path (S : @System n R k a P) [NeZero a] + {e : Fin n × Fin n} (t t' : S.EdgeTrace e) : + t.number = t'.number ∧ t.token = t'.token := by + have hm₀ := t.match_eq S + have hm₁ := t'.match_eq S + rcases t with ⟨b,j,v,hs,ht,hl,hg⟩ + rcases t' with ⟨b',j',v',hs',ht',hl',hg'⟩ + have hb : b = b' := S.batch_unique ⟨hl,hg⟩ ⟨hl',hg'⟩ + subst b' + have hj : j = j' := (matching_unique (S.lossIndex b) (S.gainIndex b) + ⟨e.1,hl⟩ ⟨e.2,hg⟩).unique hm₀ hm₁ + refine ⟨hj,?_⟩ + apply (S.tokenState j b.castSucc).injective + apply Subtype.ext + rw [hs,hj,hs'] + +lemma System.convexOwner_of_trace (S : @System n R k a P) [NeZero n] [NeZero a] + {e : Fin n × Fin n} (t : S.EdgeTrace e) : + S.convexOwner e = (t.number,t.token.val) := by + have he : e ∈ S.edges := (S.mem_edges e).mpr ⟨t.batch,t.loss,t.gain⟩ + rw [S.convexOwner_eq he] + obtain ⟨hj,ht⟩ := (S.trace he).same_path S t + rw [hj,ht] + +lemma System.tokenPath_bounds (S : @System n R k a P) [NeZero a] + (j : Fin a) (v : ↥(S.marks 0)) (b : Fin R) + (hb : (S.tokenPath j v).point b.castSucc ≠ (S.tokenPath j v).point b.succ) : + S.slope 0 < PlanarHalving.slope ((S.tokenPath j v).point b.castSucc) ((S.tokenPath j v).point b.succ) ∧ + PlanarHalving.slope ((S.tokenPath j v).point b.castSucc) ((S.tokenPath j v).point b.succ) < S.slope (Fin.last R) := by + have hstep := (S.token_step j v b).resolve_left (fun h => hb (congrArg P h)) + have h := S.edge_slope b hstep.1 hstep.2 + exact ⟨(S.increasing.monotone (Fin.zero_le _)).trans_lt h.1, + h.2.trans_le (S.increasing.monotone (Fin.le_last _))⟩ + +lemma System.tokenPath_segment_owner (S : @System n R k a P) [NeZero n] [NeZero a] + (j : Fin a) (v : ↥(S.marks 0)) (b : Fin R) + (hb : (S.tokenPath j v).point b.castSucc ≠ (S.tokenPath j v).point b.succ) + {z : Point} (hz : z ∈ segment ℝ ((S.tokenPath j v).point b.castSucc) ((S.tokenPath j v).point b.succ)) : + ∃ e ∈ S.edges, S.convexOwner e = (j,v.val) ∧ z ∈ segment ℝ (P e.1) (P e.2) := by + have hstep := (S.token_step j v b).resolve_left (fun h => hb (congrArg P h)) + let e : Fin n × Fin n := ((S.tokenState j b.castSucc v).val,(S.tokenState j b.succ v).val) + let t : S.EdgeTrace e := ⟨b,j,v,rfl,rfl,hstep.1,hstep.2⟩ + exact ⟨e,(S.mem_edges e).mpr ⟨b,hstep⟩,S.convexOwner_of_trace t,hz⟩ + +lemma System.exists_graph (S : @System n R k a P) [NeZero n] [NeZero a] + (hR : 0 < R) (F : Finset Point) (hF : ∀ v, P v ∉ F) (i : Fin a × Fin n) : + ∃ (l u : ℝ) (g : ℝ → ℝ), S.slope 0 < l ∧ l ≤ u ∧ u < S.slope (Fin.last R) ∧ + Continuous g ∧ ConvexOn ℝ univ g ∧ + (∀ x y, x ≤ y → l*(y-x) ≤ g y-g x ∧ g y-g x ≤ u*(y-x)) ∧ + (∀ e ∈ S.edges, S.convexOwner e = i → ∀ z ∈ segment ℝ (P e.1) (P e.2), g z.1 = z.2) ∧ + (∀ z ∈ F, g z.1 = z.2 → ∃ e ∈ S.edges, S.convexOwner e = i ∧ z ∈ segment ℝ (P e.1) (P e.2)) := by + classical + have hspan : S.slope 0 < S.slope (Fin.last R) := S.increasing (by simpa only [Fin.lt_def, Fin.val_zero, Fin.val_last] using hR) + by_cases hi : i.2 ∈ S.marks 0 + · let v : ↥(S.marks 0) := ⟨i.2,hi⟩ + let C := S.tokenPath i.1 v + have h₀ : C.point 0 ∉ F := hF _ + have h₁ : C.point (Fin.last R) ∉ F := hF _ + obtain ⟨l,u,hl,hlu,hu,hs,hclean⟩ := C.exists_clean_extension F hspan h₀ h₁ (S.tokenPath_bounds i.1 v) + refine ⟨l,u,C.extension l u,hl,hlu,hu, + continuous_envelope _ _,convexOn_envelope _ _,?_,?_,?_⟩ + · intro x y hxy + exact envelope_slopes _ _ (C.extension_slopes hlu hs) hxy + · intro e he heowner z hz + have howner := S.convexOwner_eq he + rw [heowner] at howner + have hj : (S.trace he).number = i.1 := congrArg Prod.fst howner.symm + have hv : (S.trace he).token = v := Subtype.ext (congrArg Prod.snd howner.symm) + have hsrc : C.point (S.trace he).batch.castSucc = P e.1 := by + simpa only [C,System.tokenPath,hj,hv] using congrArg P (S.trace he).source + have htgt : C.point (S.trace he).batch.succ = P e.2 := by + simpa only [C,System.tokenPath,hj,hv] using congrArg P (S.trace he).target + have hne : C.point (S.trace he).batch.castSucc ≠ C.point (S.trace he).batch.succ := by + rw [hsrc,htgt] + exact fun heq => (S.drawing.right e he).ne (congrArg Prod.fst heq) + exact C.extension_edge hs _ hne (by rwa [hsrc,htgt]) + · intro z hz hg + obtain ⟨b,hb,hz'⟩ := hclean z hz hg + exact S.tokenPath_segment_owner i.1 v b hb hz' + · obtain ⟨l,hl,hu⟩ := exists_between hspan + obtain ⟨c,hc⟩ := exists_affine_avoiding F l + refine ⟨l,l,fun x => l*x+c,hl,le_rfl,hu,by fun_prop,?_,?_,?_,?_⟩ + · refine ⟨convex_univ, ?_⟩ + intro x _ y _ p q _ _ hpq + simp only [smul_eq_mul] + nlinarith [congrArg (fun t : ℝ => c*t) hpq] + · intro x y _ + constructor <;> ring_nf <;> exact le_rfl + · intro e he howner + have ho := S.convexOwner_eq he + rw [howner] at ho + have hv := congrArg Prod.snd ho + exact (hi (hv ▸ (S.trace he).token.property)).elim + · intro z hz hg + exact (hc z hz hg).elim + +end PlanarHalving.Batches + +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates +variable {n R k a : ℕ} {P : Fin n → Point} + +structure System.FullGraphs (S : @System n R k a P) [NeZero n] [NeZero a] (F : Finset Point) where + lower : ℝ + upper : ℝ + lower_lt : S.slope 0 < lower + lower_le_upper : lower ≤ upper + upper_lt : upper < S.slope (Fin.last R) + graph : Fin (a*n) → ℝ → ℝ + continuous : ∀ i, Continuous (graph i) + convex : ∀ i, ConvexOn ℝ univ (graph i) + slopes : ∀ i x y, x ≤ y → lower*(y-x) ≤ graph i y-graph i x ∧ + graph i y-graph i x ≤ upper*(y-x) + edge : ∀ e ∈ S.edges, ∀ z ∈ segment ℝ (P e.1) (P e.2), + graph (finProdFinEquiv (S.convexOwner e)) z.1 = z.2 + clean : ∀ i z, z ∈ F → graph i z.1 = z.2 → ∃ e ∈ S.edges, + finProdFinEquiv (S.convexOwner e) = i ∧ z ∈ segment ℝ (P e.1) (P e.2) + +lemma System.fullGraphs_nonempty (S : @System n R k a P) [NeZero n] [NeZero a] + (hR : 0 < R) (F : Finset Point) (hF : ∀ v, P v ∉ F) : + Nonempty (S.FullGraphs F) := by + classical + choose l u g hl hlu hu hc hv hs he hclean using S.exists_graph hR F hF + let ι := Fin a × Fin n + let ls : Finset ℝ := Finset.univ.image l + let us : Finset ℝ := Finset.univ.image u + have hls : ls.Nonempty := ⟨l (0,0),Finset.mem_image.mpr ⟨(0,0),Finset.mem_univ _,rfl⟩⟩ + have hus : us.Nonempty := ⟨u (0,0),Finset.mem_image.mpr ⟨(0,0),Finset.mem_univ _,rfl⟩⟩ + let L := ls.min' hls + let U := us.max' hus + have hL i : L ≤ l i := Finset.min'_le ls _ (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩) + have hU i : u i ≤ U := Finset.le_max' us _ (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩) + have hL' : S.slope 0 < L := by + obtain ⟨i,_,hi⟩ := Finset.mem_image.mp (Finset.min'_mem ls hls) + change S.slope 0 < ls.min' hls + rw [← hi] + exact hl i + have hU' : U < S.slope (Fin.last R) := by + obtain ⟨i,_,hi⟩ := Finset.mem_image.mp (Finset.max'_mem us hus) + change us.max' hus < S.slope (Fin.last R) + rw [← hi] + exact hu i + refine ⟨⟨L,U,hL',(hL (0,0)).trans ((hlu (0,0)).trans (hU (0,0))),hU', + fun i => g (finProdFinEquiv.symm i),fun i => hc _,fun i => hv _,?_,?_,?_⟩⟩ + · intro i x y hxy + exact ⟨(mul_le_mul_of_nonneg_right (hL _) (sub_nonneg.mpr hxy)).trans (hs _ x y hxy).1, + (hs _ x y hxy).2.trans (mul_le_mul_of_nonneg_right (hU _) (sub_nonneg.mpr hxy))⟩ + · intro e hh z hz + simpa only [Equiv.symm_apply_apply] using he (S.convexOwner e) e hh rfl z hz + · intro i z hz hgz + obtain ⟨e,hh,ho,hz'⟩ := hclean _ z hz hgz + exact ⟨e,hh,by rw [ho,Equiv.apply_symm_apply],hz'⟩ + +noncomputable def System.fullGraphs (S : @System n R k a P) [NeZero n] [NeZero a] + (hR : 0 < R) (F : Finset Point) (hF : ∀ v, P v ∉ F) : S.FullGraphs F := + Classical.choice (S.fullGraphs_nonempty hR F hF) + +lemma System.FullGraphs.unique_incidence (S : @System n R k a P) [NeZero n] [NeZero a] + {F : Finset Point} (G : S.FullGraphs F) + (hF : ∀ z ∈ F, ∀ e ∈ S.edges, ∀ f ∈ S.edges, + z ∈ segment ℝ (P e.1) (P e.2) → z ∈ segment ℝ (P f.1) (P f.2) → e = f) + {z : Point} (hz : z ∈ F) {i j : Fin (a*n)} + (hi : G.graph i z.1 = z.2) (hj : G.graph j z.1 = z.2) : i = j := by + obtain ⟨e,he,hei,hze⟩ := G.clean i z hz hi + obtain ⟨f,hf,hfj,hzf⟩ := G.clean j z hz hj + have h := hF z hz e he f hf hze hzf + rw [← hei,← hfj,h] + +end PlanarHalving.Batches + +namespace PlanarHalving.RankCoordinates +open Filter Set +open scoped Topology +lemma sigmoid_scale_limit {x : ℝ} (hx : x ≠ 0) : + Tendsto (fun t : ℝ => Real.sigmoid (x*t)) atTop (𝓝 (if 0 < x then 1 else 0)) := by + split_ifs with h + · exact Real.tendsto_sigmoid_atTop.comp ((tendsto_const_mul_atTop_of_pos h).mpr tendsto_id) + · exact Real.tendsto_sigmoid_atBot.comp + ((tendsto_const_mul_atBot_of_neg (lt_of_le_of_ne (le_of_not_gt h) hx)).mpr tendsto_id) + +lemma smoothed_scale_limit {m : ℕ} (g : Fin m → ℝ → ℝ) {p : Point} (j : Fin m) + (hj : g j p.1 = p.2) (hunique : ∀ i, g i p.1 = p.2 → i = j) : + Tendsto (fun t : ℝ => smoothed g (1/t) p) atTop + (𝓝 (((slot g p : ℝ) + 1/2)/m)) := by + classical + have hlim (i : Fin m) : Tendsto (fun t : ℝ => Real.sigmoid ((p.2-g i p.1)*t)) atTop + (𝓝 ((if g i p.1 < p.2 then (1:ℝ) else 0) + if i = j then 1/2 else 0)) := by + by_cases hi : i = j + · subst i + simp only [hj,lt_self_iff_false,ite_false,ite_true,sub_self,zero_mul,Real.sigmoid_zero,zero_add] + simpa only [one_div] using (tendsto_const_nhds : Tendsto (fun _ : ℝ => (2:ℝ)⁻¹) atTop (𝓝 (2:ℝ)⁻¹)) + · have hn : p.2-g i p.1 ≠ 0 := fun h => hi (hunique i (sub_eq_zero.mp h).symm) + simpa only [sub_pos,hi,ite_false,add_zero] using sigmoid_scale_limit hn + have ht := (tendsto_finsetSum Finset.univ (fun i _ => hlim i)).div_const (m : ℝ) + have hs : (∑ i : Fin m, ((if g i p.1 < p.2 then (1:ℝ) else 0) + if i = j then 1/2 else 0)) = + (slot g p : ℝ) + 1/2 := by + rw [Finset.sum_add_distrib] + simp [slot] + rw [hs] at ht + simpa only [smoothed,one_div,div_inv_eq_mul] using ht + +theorem exists_smoothing_slot_error {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + (F : Finset Point) (hF : ∀ p ∈ F, ∃! j, g j p.1 = p.2) : + ∃ ε : ℝ, 0 < ε ∧ ∀ p ∈ F, |smoothed g ε p - (slot g p : ℝ)/m| ≤ 2/m := by + classical + have hmR : (0:ℝ) < m := Nat.cast_pos.mpr hm + have hev : ∀ᶠ t : ℝ in atTop, ∀ p ∈ F, + |smoothed g (1/t) p - (slot g p : ℝ)/m| ≤ 2/m := by + rw [Filter.eventually_all_finset] + intro p hp + obtain ⟨j,hj,hju⟩ := hF p hp + have ht := ((smoothed_scale_limit g j hj hju).sub_const ((slot g p : ℝ)/m)).abs + have hb : |((slot g p : ℝ)+1/2)/m-(slot g p : ℝ)/m| < 2/m := by + rw [add_div,add_sub_cancel_left,abs_of_pos (div_pos (by norm_num) hmR)] + exact div_lt_div_of_pos_right (by norm_num) hmR + exact (ht.eventually_lt_const hb).mono (fun _ h => h.le) + obtain ⟨t,ht,hp⟩ := ( (eventually_gt_atTop (0:ℝ)).and hev).exists + exact ⟨1/t,div_pos zero_lt_one ht,hp⟩ +end PlanarHalving.RankCoordinates + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology NNReal +variable {X : Type*} [MetricSpace X] [Nonempty X] [MeasurableSpace X] [BorelSpace X] + +lemma finiteMeasure_tendsto_apply {μ : FiniteMeasure X} {μs : ℕ → FiniteMeasure X} + (h : Tendsto μs atTop (𝓝 μ)) {E : Set X} (hE : (μ : Measure X) (frontier E) = 0) : + Tendsto (fun n => μs n E) atTop (𝓝 (μ E)) := by + by_cases hμ : μ = 0 + · subst μ + have hmass := h.mass + have hb (n : ℕ) : μs n E ≤ (μs n).mass := (μs n).apply_mono (subset_univ E) + simpa using + tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds hmass (fun _ => zero_le) hb + · have hn := FiniteMeasure.tendsto_normalize_of_tendsto h hμ + have hE' : (μ.normalize : Measure X) (frontier E) = 0 := by + rw [μ.toMeasure_normalize_eq_of_nonzero hμ,Measure.smul_apply,hE] + simp + have ht := ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto hn (by simpa only [← ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure, ENNReal.coe_eq_zero] using hE') + have hh := h.mass.mul ht + simpa only [← FiniteMeasure.self_eq_mass_mul_normalize] using hh + +omit [Nonempty X] in +lemma finiteMeasure_tendsto_thickening (μ : FiniteMeasure X) {F : Set X} (hF : IsClosed F) + {r : ℕ → ℝ} (hr : Tendsto r atTop (𝓝 0)) (hp : ∀ n, 0 < r n) : + Tendsto (fun n => μ (Metric.thickening (r n) F)) atTop (𝓝 (μ F)) := by + have ht := tendsto_measure_thickening_of_isClosed (μ := (μ : Measure X)) ⟨1,by norm_num,measure_ne_top _ _⟩ hF + have hr' : Tendsto r atTop (𝓝[>] 0) := tendsto_nhdsWithin_iff.mpr ⟨hr,Filter.Eventually.of_forall hp⟩ + have hh := (ENNReal.tendsto_toNNReal (measure_ne_top (μ : Measure X) F)).comp (ht.comp hr') + exact hh + +lemma cubed_bound_limit_closed + {μ lam : FiniteMeasure X} {μs lams : ℕ → FiniteMeasure X} + (hμ : Tendsto μs atTop (𝓝 μ)) (hlam : Tendsto lams atTop (𝓝 lam)) + {c d : ℕ → ℝ} {C : ℝ} (hc : Tendsto c atTop (𝓝 C)) (hd : Tendsto d atTop (𝓝 0)) + (hbound : ∀ n U, MeasurableSet U → (lams n U : ℝ)^3 ≤ c n*(μs n U : ℝ)+d n) + {F : Set X} (hF : IsClosed F) : (lam F : ℝ)^3 ≤ C*(μ F : ℝ) := by + obtain ⟨r,hr,hnull⟩ := exists_null_frontiers_thickening ((μ : Measure X)+(lam : Measure X)) F + have hb (j : ℕ) : (lam (Metric.thickening (r j) F) : ℝ)^3 ≤ C*(μ (Metric.thickening (r j) F) : ℝ) := by + have hh := (hnull j).2 + rw [Measure.add_apply] at hh + have hμ' := finiteMeasure_tendsto_apply hμ (add_eq_zero.mp hh).1 + have hlam' := finiteMeasure_tendsto_apply hlam (add_eq_zero.mp hh).2 + have hμR := NNReal.continuous_coe.tendsto _ |>.comp hμ' + have hlamR := NNReal.continuous_coe.tendsto _ |>.comp hlam' + have ht := le_of_tendsto_of_tendsto (hlamR.pow 3) ((hc.mul hμR).add hd) + (Filter.Eventually.of_forall (fun n => hbound n _ Metric.isOpen_thickening.measurableSet)) + simpa only [add_zero] using ht + have hp : ∀ j, 0 < r j := fun j => (hnull j).1 + have hμR := NNReal.continuous_coe.tendsto _ |>.comp (finiteMeasure_tendsto_thickening μ hF hr hp) + have hlamR := NNReal.continuous_coe.tendsto _ |>.comp (finiteMeasure_tendsto_thickening lam hF hr hp) + exact le_of_tendsto_of_tendsto (hlamR.pow 3) (hμR.const_mul C) (Filter.Eventually.of_forall hb) + +omit [Nonempty X] in +lemma cubed_bound_of_compact [CompactSpace X] + (μ lam : FiniteMeasure X) {C : ℝ} (hC : 0 ≤ C) + (hbound : ∀ K : Set X, IsCompact K → (lam K : ℝ)^3 ≤ C*(μ K : ℝ)) + {F : Set X} (hF : MeasurableSet F) : (lam F : ℝ)^3 ≤ C*(μ F : ℝ) := by + have hh (t : ℝ) (ht : t < (lam F : ℝ)) : t^3 ≤ C*(μ F : ℝ) := by + by_cases ht0 : t < 0 + · exact (show t^3 ≤ 0 by have h := mul_nonpos_of_nonneg_of_nonpos (sq_nonneg t) ht0.le; nlinarith).trans (mul_nonneg hC (NNReal.coe_nonneg _)) + · have ht0' : 0 ≤ t := le_of_not_gt ht0 + have ht' : ENNReal.ofReal t < (lam : Measure X) F := by + rw [ENNReal.ofReal_lt_iff_lt_toReal ht0' (measure_ne_top (lam : Measure X) F)] + exact ht + obtain ⟨K,hKF,hK,htK⟩ := hF.exists_lt_isCompact ht' + have htK' : t < (lam K : ℝ) := by + rwa [ENNReal.ofReal_lt_iff_lt_toReal ht0' (measure_ne_top (lam : Measure X) K)] at htK + exact (pow_le_pow_left₀ ht0' htK'.le 3).trans ((hbound K hK).trans + (mul_le_mul_of_nonneg_left (show (μ K : ℝ) ≤ μ F from (NNReal.coe_le_coe.mpr (μ.apply_mono hKF))) hC)) + have ht : Tendsto (fun t : ℝ => t^3) (𝓝[<] (lam F : ℝ)) (𝓝 ((lam F : ℝ)^3)) := + ((continuous_pow 3).tendsto _).mono_left inf_le_left + exact le_of_tendsto ht (Filter.mem_of_superset self_mem_nhdsWithin (fun t ht => hh t ht)) + +lemma cubed_bound_limit [CompactSpace X] + {μ lam : FiniteMeasure X} {μs lams : ℕ → FiniteMeasure X} + (hμ : Tendsto μs atTop (𝓝 μ)) (hlam : Tendsto lams atTop (𝓝 lam)) + {c d : ℕ → ℝ} {C : ℝ} (hC : 0 ≤ C) + (hc : Tendsto c atTop (𝓝 C)) (hd : Tendsto d atTop (𝓝 0)) + (hbound : ∀ n U, MeasurableSet U → (lams n U : ℝ)^3 ≤ c n*(μs n U : ℝ)+d n) + {F : Set X} (hF : MeasurableSet F) : (lam F : ℝ)^3 ≤ C*(μ F : ℝ) := + cubed_bound_of_compact μ lam hC (fun _ hK => cubed_bound_limit_closed hμ hlam hc hd hbound hK.isClosed) hF + +end PlanarHalving.Limits + +namespace PlanarHalving.Batches +open Set PlaneGraph +variable {n R k a : ℕ} {P : Fin n → Point} + +def System.window (S : @System n R k a P) (start len : ℕ) (h : start+len ≤ R) : + @System n len k a P where + slope b := S.slope ⟨start+b.val,by omega⟩ + increasing := by + intro b c hbc + apply S.increasing + simpa only [Fin.lt_def] using Nat.add_lt_add_left hbc start + marks b := S.marks ⟨start+b.val,by omega⟩ + card_marks _ := S.card_marks _ + separates _ := S.separates _ + distance b := S.distance ⟨start+b.val,by omega⟩ + +lemma System.window_edges (S : @System n R k a P) (start len : ℕ) (h : start+len ≤ R) : + (S.window start len h).edges ⊆ S.edges := by + intro e he + obtain ⟨b,hb,hc⟩ := ((S.window start len h).mem_edges e).mp he + exact (S.mem_edges e).mpr ⟨⟨start+b.val,by omega⟩,hb,hc⟩ + +lemma System.window_vertices (S : @System n R k a P) (start len : ℕ) (h : start+len ≤ R) : + (S.window start len h).vertices ⊆ S.vertices := + Finset.union_subset_union (Finset.image_subset_image (S.window_edges start len h)) + (Finset.image_subset_image (S.window_edges start len h)) + +lemma System.windows_disjoint (S : @System n R k a P) + {s l t m : ℕ} (h₁ : s+l ≤ R) (h₂ : t+m ≤ R) (h : s+l ≤ t) : + Disjoint (S.window s l h₁).edges (S.window t m h₂).edges := by + apply Finset.disjoint_left.mpr + intro e he hf + obtain ⟨b,hb,hc⟩ := ((S.window s l h₁).mem_edges e).mp he + obtain ⟨c,hd,he⟩ := ((S.window t m h₂).mem_edges e).mp hf + have hh := S.batch_unique (b := ⟨s+b.val,by omega⟩) (c := ⟨t+c.val,by omega⟩) ⟨hb,hc⟩ ⟨hd,he⟩ + have hv : s+b.val = t+c.val := congrArg Fin.val hh + have := b.isLt + omega + +lemma System.windows_slopes (S : @System n R k a P) + {s l t m : ℕ} (h₁ : s+l ≤ R) (h₂ : t+m ≤ R) (h : s+l ≤ t) : + (S.window s l h₁).slope (Fin.last l) ≤ (S.window t m h₂).slope 0 := by + apply S.increasing.monotone + simpa [Fin.le_def] using h + +lemma System.FullGraphs.disjoint_bands (S : @System n R k a P) [NeZero n] [NeZero a] + {s l t m : ℕ} (h₁ : s+l ≤ R) (h₂ : t+m ≤ R) (h : s+l ≤ t) + {F G : Finset Point} (A : (S.window s l h₁).FullGraphs F) + (B : (S.window t m h₂).FullGraphs G) : A.upper < B.lower := + A.upper_lt.trans_le (S.windows_slopes h₁ h₂ h) |>.trans B.lower_lt + +end PlanarHalving.Batches + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology + +theorem persistent_mass_zero {ι : Type*} (S : ℕ → Finset ι) + (lam μ s : ℕ → ι → ℝ) (q : ℕ → ℝ) {L A H U : ℝ} + (hL : 0 ≤ L) (hA : 0 ≤ A) + (hq : ∀ n, 0 < q n) (hqtop : Tendsto q atTop atTop) + (hcard : ∀ n, ((S n).card : ℝ) ≤ q n) + (hlam0 : ∀ n i, i ∈ S n → 0 ≤ lam n i) + (hlam1 : ∀ n i, i ∈ S n → lam n i ≤ (q n)⁻¹) + (hμ0 : ∀ n i, i ∈ S n → 0 ≤ μ n i) + (hs0 : ∀ n i, i ∈ S n → 0 ≤ s n i) + (hmass : ∀ n i, i ∈ S n → (lam n i)^3 ≤ A*(s n i)^3*μ n i) + (hμsum : ∀ n, ∑ i ∈ S n, μ n i ≤ U) + (htail : ∀ n u, 0 < u → ((S n |>.filter fun i => u < s n i).card : ℝ) ≤ + H*u^(-(4:ℝ)/3)) + (hpartition : ∀ n, L ≤ ∑ i ∈ S n, lam n i) : L = 0 := by + apply Boundary.mass_eq_zero S lam μ s (fun n i => μ n i/2) (fun _ _ => 0) q + (L := L) (A := A) (H := H) (B := 0) (B₀ := U/2) (T := 0) (α := 1) + hL hA (by norm_num) (by norm_num) (by norm_num) (by norm_num) + hq hqtop hcard hlam0 hlam1 hμ0 hs0 (by intros; norm_num) hmass + (by intros; linarith) ?_ (by intros; simp) htail hpartition + intro n + rw [← Finset.sum_div] + exact div_le_div_of_nonneg_right (hμsum n) (by norm_num) + +end PlanarHalving.Limits + +namespace PlanarHalving.PlaneGraph +open Set +variable {n : ℕ} {P : Fin n → Point} + +lemma Generic.not_vertex_on_openSegment (hP : Generic P) {i j : Fin n} + (hij : (P i).1 < (P j).1) (v : Fin n) : + P v ∉ openSegment ℝ (P i) (P j) := by + intro hv + have hbounds := openSegment_horizontal_bounds hij hv + have hheight := (height_of_mem_openSegment hij.ne hv).2 + have hzero : orient (P i) (P j) (P v) = 0 := by + rw [orient_eq_proj_diff _ _ _ hij.ne.symm] + have hh : (P v).2 - slope (P i) (P j) * (P v).1 - + ((P i).2 - slope (P i) (P j) * (P i).1) = 0 := by + unfold height at hheight + nlinarith only [hheight] + rw [hh,mul_zero] + have hne : i ≠ j := by intro h; subst j; exact lt_irrefl _ hij + rcases (orient_zero_iff hP.1 hne v).mp hzero with rfl | rfl + · exact lt_irrefl _ hbounds.1 + · exact lt_irrefl _ hbounds.2 + +noncomputable def Drawing.exteriorCrossings (D : Drawing P) (E : Finset (Fin n × Fin n)) : + Finset Point := by + classical + exact (Finset.univ.filter (fun w : ↥D.crossings => + (w.val.1 ∈ E ∧ w.val.2 ∉ E) ∨ (w.val.2 ∈ E ∧ w.val.1 ∉ E))).image D.crossingPoint + +lemma Drawing.exteriorCrossings_not_vertex (D : Drawing P) (hP : Generic P) + (E : Finset (Fin n × Fin n)) (v : Fin n) : P v ∉ D.exteriorCrossings E := by + classical + intro hv + obtain ⟨w,_,hw⟩ := Finset.mem_image.mp hv + have hz := (D.crossingPoint_mem w).1 + rw [hw] at hz + exact Generic.not_vertex_on_openSegment hP (D.right _ (D.crossing_props w).1) v hz + +lemma Drawing.exteriorCrossings_unique (D : Drawing P) (hD : D.NoMultiple) + {E : Finset (Fin n × Fin n)} (hE : E ⊆ D.edges) {z : Point} + (hz : z ∈ D.exteriorCrossings E) : + ∃! e, e ∈ E ∧ z ∈ segment ℝ (P e.1) (P e.2) := by + classical + obtain ⟨w,hw,rfl⟩ := Finset.mem_image.mp hz + have hw' := (Finset.mem_filter.mp hw).2 + have hp := D.crossing_props w + have hm := D.crossingPoint_mem w + have hne : w.val.1 ≠ w.val.2 := fun h => hp.2.2.1.ne (congrArg edgeIndex h) + have hloc (g : Fin n × Fin n) (hg : g ∈ E) + (hm : D.crossingPoint w ∈ segment ℝ (P g.1) (P g.2)) : + g = w.val.1 ∨ g = w.val.2 := by + by_contra hh + push Not at hh + exact hD _ hp.1 _ hp.2.1 hne _ (hE hg) hh.1 hh.2 _ + (D.crossingPoint_mem w).1 (D.crossingPoint_mem w).2 hm + rcases hw' with hw' | hw' + · refine ⟨w.val.1,⟨hw'.1,openSegment_subset_segment ℝ _ _ hm.1⟩,?_⟩ + intro g hg + exact (hloc g hg.1 hg.2).resolve_right (fun h => hw'.2 (h ▸ hg.1)) + · refine ⟨w.val.2,⟨hw'.1,openSegment_subset_segment ℝ _ _ hm.2⟩,?_⟩ + intro g hg + exact (hloc g hg.1 hg.2).resolve_left (fun h => hw'.2 (h ▸ hg.1)) + +end PlanarHalving.PlaneGraph + +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates +variable {n R k a : ℕ} {P : Fin n → Point} + +theorem System.window_coordinate (S : @System n R k a P) [NeZero n] [NeZero a] + (hP : Generic P) (s l : ℕ) (h : s+l ≤ R) (hl : 0 < l) : + ∃ (G : (S.window s l h).FullGraphs (S.drawing.exteriorCrossings (S.window s l h).edges)) + (ε : ℝ), 0 < ε ∧ + ∀ z ∈ S.drawing.exteriorCrossings (S.window s l h).edges, + |smoothed G.graph ε z-(slot G.graph z : ℝ)/(a*n)| ≤ 2/(a*n) := by + let T := S.window s l h + let F := S.drawing.exteriorCrossings T.edges + let G := T.fullGraphs hl F (S.drawing.exteriorCrossings_not_vertex hP T.edges) + have hf (z : Point) (hz : z ∈ F) : ∃! j, G.graph j z.1 = z.2 := by + obtain ⟨e,he,_⟩ := S.drawing.exteriorCrossings_unique (S.drawing.noMultiple_of_generic hP) + (S.window_edges s l h) hz + refine ⟨finProdFinEquiv (T.convexOwner e),G.edge e he.1 z he.2,?_⟩ + intro j hj + apply G.unique_incidence T (fun q hq e he f hf hqe hqf => ?_) hz hj (G.edge e he.1 z he.2) + obtain ⟨b,_,hb⟩ := S.drawing.exteriorCrossings_unique (S.drawing.noMultiple_of_generic hP) + (S.window_edges s l h) hq + exact (hb e ⟨he,hqe⟩).trans (hb f ⟨hf,hqf⟩).symm + obtain ⟨ε,hε,herr⟩ := exists_smoothing_slot_error (Nat.mul_pos (NeZero.pos a) (NeZero.pos n)) G.graph F hf + exact ⟨G,ε,hε,by simpa only [Nat.cast_mul] using herr⟩ + +end PlanarHalving.Batches + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Basic.lean b/lean/OAI/Combinatorics/HalvingLines/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..120b2a1c9dbd892c2faeffba7b46a6e09a9bf678 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Basic.lean @@ -0,0 +1,142 @@ +import OAI.Combinatorics.HalvingLines.Model + +namespace OAI + +namespace PlanarHalving + +theorem critical_image_null (f : Point → Point) : + MeasureTheory.volume (f '' {p | DifferentiableAt ℝ f p ∧ + (fderiv ℝ f p).det = 0}) = 0 := by + apply MeasureTheory.addHaar_image_eq_zero_of_det_fderivWithin_eq_zero + MeasureTheory.volume + · intro p hp + exact hp.1.hasFDerivAt.hasFDerivWithinAt + · intro p hp + exact hp.2 + +theorem orient_swap (p q r : Point) : orient q p r = -orient p q r := by + unfold orient + ring + +@[simp] theorem orient_left (p q : Point) : orient p q p = 0 := by + simp [orient] + +@[simp] theorem orient_right (p q : Point) : orient p q q = 0 := by + unfold orient + ring + +@[simp] theorem switchCount_zero {n : ℕ} (P : Fin n → Point) : + switchCount P 0 = 0 := by + simp [switchCount] + +@[simp] theorem switchCount_top {n : ℕ} (P : Fin n → Point) : + switchCount P n = 0 := by + simp [switchCount] + +theorem orient_eq_proj_diff (p q r : Point) (hx : q.1 ≠ p.1) : + orient p q r = (q.1 - p.1) * + ((r.2 - slope p q * r.1) - (p.2 - slope p q * p.1)) := by + unfold orient slope + field_simp + ring + +lemma orient_zero_iff {n : ℕ} {P : Fin n → Point} (hP : GeneralPosition P) + {i j : Fin n} (hij : i ≠ j) (l : Fin n) : + orient (P i) (P j) (P l) = 0 ↔ l = i ∨ l = j := by + constructor + · intro hl + by_contra! hh + exact hP.2 i j l hij hh.2.symm hh.1.symm hl + · rintro (rfl | rfl) <;> simp + +lemma sideCount_add_reverse {n : ℕ} {P : Fin n → Point} (hP : GeneralPosition P) + {i j : Fin n} (hij : i ≠ j) : sideCount P i j + sideCount P j i = n - 2 := by + classical + let A := Finset.univ.filter (fun l => 0 < orient (P i) (P j) (P l)) + let B := Finset.univ.filter (fun l => 0 < orient (P j) (P i) (P l)) + have hd : Disjoint A B := by + apply Finset.disjoint_left.mpr + intro l hlA hlB + have ha : 0 < orient (P i) (P j) (P l) := (Finset.mem_filter.mp hlA).2 + have hb : 0 < orient (P j) (P i) (P l) := (Finset.mem_filter.mp hlB).2 + rw [orient_swap] at hb + linarith only [ha, hb] + have hu : A ∪ B = (Finset.univ.erase i).erase j := by + ext l + simp only [A, B, Finset.mem_union, Finset.mem_filter, Finset.mem_univ, + true_and, Finset.mem_erase] + rw [orient_swap (P i) (P j) (P l)] + have hz := orient_zero_iff hP hij l + constructor + · intro hl + have hn : orient (P i) (P j) (P l) ≠ 0 := by + rcases hl with hl | hl <;> linarith only [hl] + have hn' : ¬ (l = i ∨ l = j) := fun he => hn (hz.mpr he) + exact ⟨fun h => hn' (Or.inr h), fun h => hn' (Or.inl h), trivial⟩ + · rintro ⟨hlj, hli, _⟩ + have hn : orient (P i) (P j) (P l) ≠ 0 := by + intro hh + rcases hz.mp hh with hh | hh + · exact hli hh + · exact hlj hh + rcases lt_or_gt_of_ne hn with hl | hl + · right; linarith only [hl] + · exact Or.inl hl + change A.card + B.card = n - 2 + rw [← Finset.card_union_of_disjoint hd, hu, + Finset.card_erase_of_mem (by simp [hij.symm]), + Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, Fintype.card_fin] + omega + +lemma belowCount_eq_sideCount_of_x_lt {n : ℕ} (P : Fin n → Point) (i j : Fin n) + (hx : (P i).1 < (P j).1) : belowCount P i j = sideCount P j i := by + classical + unfold belowCount sideCount + dsimp only + apply congrArg Finset.card + apply Finset.filter_congr + intro l _ + rw [orient_swap, orient_eq_proj_diff _ _ _ hx.ne'] + have hx' : 0 < (P j).1 - (P i).1 := sub_pos.mpr hx + rw [neg_pos] + simp only [mul_neg_iff, hx', hx'.not_gt, true_and, false_and, + or_false, sub_neg] + +lemma belowCount_eq_sideCount_of_x_gt {n : ℕ} (P : Fin n → Point) (i j : Fin n) + (hx : (P j).1 < (P i).1) : belowCount P i j = sideCount P i j := by + classical + unfold belowCount sideCount + dsimp only + apply congrArg Finset.card + apply Finset.filter_congr + intro l _ + rw [orient_eq_proj_diff _ _ _ hx.ne] + have hx' : (P j).1 - (P i).1 < 0 := sub_neg.mpr hx + simp only [mul_pos_iff, hx', hx'.not_gt, true_and, false_and, + false_or, sub_neg] + +theorem halvingCount_eq_middle_switchCount {m : ℕ} (hm : 0 < m) + (P : Fin (2 * m) → Point) (hP : Generic P) : + halvingCount P = switchCount P m := by + classical + unfold halvingCount switchCount + congr 1 + apply Finset.filter_congr + intro ij _ + have hm' : m < 2 * m := by omega + simp only [hm, hm', true_and] + by_cases hij : ij.1 < ij.2 + · simp only [hij, true_and] + have hs := sideCount_add_reverse hP.1 hij.ne + have hdiv : (2 * m - 2) / 2 = m - 1 := by omega + rw [hdiv] + rcases lt_or_gt_of_ne (hP.2.1 ij.1 ij.2 hij.ne) with hx | hx + · rw [belowCount_eq_sideCount_of_x_lt P _ _ hx] + omega + · rw [belowCount_eq_sideCount_of_x_gt P _ _ hx] + omega + · simp only [hij, false_and] + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Batches.lean b/lean/OAI/Combinatorics/HalvingLines/Batches.lean new file mode 100644 index 0000000000000000000000000000000000000000..24f6a2fc111b851a47c8f5e0f34ede21c9bb08b9 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Batches.lean @@ -0,0 +1,260 @@ +import OAI.Combinatorics.HalvingLines.CrossingEstimate + +namespace OAI + +open Filter Topology + +namespace PlanarHalving +namespace Batches + +variable {α : Type*} [DecidableEq α] + +noncomputable def transport (M M' : Finset α) (e : ↥(M \ M') ≃ ↥(M' \ M)) : + ↥M ≃ ↥M' where + toFun u := if h : (u : α) ∈ M' then ⟨u, h⟩ + else let v := e ⟨u, Finset.mem_sdiff.mpr ⟨u.property, h⟩⟩ + ⟨v.val, (Finset.mem_sdiff.mp v.property).1⟩ + invFun v := if h : (v : α) ∈ M then ⟨v, h⟩ + else let u := e.symm ⟨v, Finset.mem_sdiff.mpr ⟨v.property, h⟩⟩ + ⟨u.val, (Finset.mem_sdiff.mp u.property).1⟩ + left_inv := by + intro u + by_cases h : (u : α) ∈ M' + · simp only [h, u.property, ↓reduceDIte] + · have hn := (Finset.mem_sdiff.mp (e ⟨u.val, + Finset.mem_sdiff.mpr ⟨u.property, h⟩⟩).property).2 + simp only [h, hn, ↓reduceDIte] + exact congrArg (fun w : ↥(M \ M') => (⟨w.val, + (Finset.mem_sdiff.mp w.property).1⟩ : ↥M)) (e.symm_apply_apply _) + right_inv := by + intro v + by_cases h : (v : α) ∈ M + · simp only [h, v.property, ↓reduceDIte] + · have hn := (Finset.mem_sdiff.mp (e.symm ⟨v.val, + Finset.mem_sdiff.mpr ⟨v.property, h⟩⟩).property).2 + simp only [h, hn, ↓reduceDIte] + exact congrArg (fun w : ↥(M' \ M) => (⟨w.val, + (Finset.mem_sdiff.mp w.property).1⟩ : ↥M')) (e.apply_symm_apply _) + +lemma transport_of_mem {M M' : Finset α} (e : ↥(M \ M') ≃ ↥(M' \ M)) + (u : ↥M) (hu : (u : α) ∈ M') : (transport M M' e u : α) = u := by + simp [transport, hu] + +lemma transport_of_not_mem {M M' : Finset α} (e : ↥(M \ M') ≃ ↥(M' \ M)) + (u : ↥M) (hu : (u : α) ∉ M') : + (transport M M' e u : α) = (e ⟨u.val, Finset.mem_sdiff.mpr ⟨u.property, hu⟩⟩ : α) := by + simp [transport, hu] + +noncomputable def matching {a : ℕ} [NeZero a] {L G : Type*} + (l : L ≃ Fin a) (g : G ≃ Fin a) (j : Fin a) : L ≃ G := + l.trans ((Equiv.addRight j).trans g.symm) + +lemma matching_unique {a : ℕ} [NeZero a] {L G : Type*} + (l : L ≃ Fin a) (g : G ≃ Fin a) (u : L) (v : G) : + ∃! j, matching l g j u = v := by + refine ⟨g v - l u, ?_, ?_⟩ + · apply g.injective + simp [matching] + · intro j hj + have h : l u + j = g v := by + simpa [matching] using congrArg g hj + exact eq_sub_of_add_eq' h + +structure System {n R k a : ℕ} (P : Fin n → Point) where + slope : Fin (R + 1) → ℝ + increasing : StrictMono slope + marks : Fin (R + 1) → Finset (Fin n) + card_marks : ∀ b, (marks b).card = k + separates : ∀ b, Sweep.Separates P (slope b) (marks b) + distance : ∀ b : Fin R, (marks b.castSucc \ marks b.succ).card = a + +variable {n R k a : ℕ} {P : Fin n → Point} + +noncomputable def System.loss (S : @System n R k a P) (b : Fin R) : Finset (Fin n) := + S.marks b.castSucc \ S.marks b.succ +noncomputable def System.gain (S : @System n R k a P) (b : Fin R) : Finset (Fin n) := + S.marks b.succ \ S.marks b.castSucc + +lemma System.card_loss (S : @System n R k a P) (b : Fin R) : (S.loss b).card = a := + S.distance b +lemma System.card_gain (S : @System n R k a P) (b : Fin R) : (S.gain b).card = a := by + rw [System.gain, Finset.card_sdiff_comm (by rw [S.card_marks, S.card_marks])] + exact S.card_loss b + +noncomputable def System.lossIndex (S : @System n R k a P) (b : Fin R) : ↥(S.loss b) ≃ Fin a := + Fintype.equivFinOfCardEq (by simpa using S.card_loss b) +noncomputable def System.gainIndex (S : @System n R k a P) (b : Fin R) : ↥(S.gain b) ≃ Fin a := + Fintype.equivFinOfCardEq (by simpa using S.card_gain b) + +noncomputable def System.match (S : @System n R k a P) [NeZero a] (j : Fin a) (b : Fin R) : + ↥(S.loss b) ≃ ↥(S.gain b) := matching (S.lossIndex b) (S.gainIndex b) j + +noncomputable def System.transition (S : @System n R k a P) [NeZero a] + (j : Fin a) (b : Fin R) : ↥(S.marks b.castSucc) ≃ ↥(S.marks b.succ) := + transport _ _ (S.match j b) + +noncomputable def System.tokenState (S : @System n R k a P) [NeZero a] + (j : Fin a) (b : Fin (R + 1)) : ↥(S.marks 0) ≃ ↥(S.marks b) := + Fin.induction (Equiv.refl _) (fun b e => e.trans (S.transition j b)) b + +@[simp] lemma System.tokenState_zero (S : @System n R k a P) [NeZero a] + (j : Fin a) : S.tokenState j 0 = Equiv.refl _ := by simp [System.tokenState] + +lemma System.tokenState_succ (S : @System n R k a P) [NeZero a] + (j : Fin a) (b : Fin R) (u : ↥(S.marks 0)) : + S.tokenState j b.succ u = S.transition j b (S.tokenState j b.castSucc u) := by + simp [System.tokenState, Fin.induction_succ] + +lemma System.edge_right (S : @System n R k a P) (b : Fin R) + {u v : Fin n} (hu : u ∈ S.loss b) (hv : v ∈ S.gain b) : (P u).1 < (P v).1 := by + exact Sweep.exchange_rightward (S.increasing (Fin.castSucc_lt_succ (i := b))).le + (S.separates b.castSucc) (S.separates b.succ) hu hv + +lemma System.edge_slope (S : @System n R k a P) (b : Fin R) + {u v : Fin n} (hu : u ∈ S.loss b) (hv : v ∈ S.gain b) : + S.slope b.castSucc < PlanarHalving.slope (P u) (P v) ∧ + PlanarHalving.slope (P u) (P v) < S.slope b.succ := + Sweep.exchange_slope_between (S.increasing (Fin.castSucc_lt_succ (i := b))).le + (S.separates b.castSucc) (S.separates b.succ) hu hv + +end Batches +end PlanarHalving + +namespace PlanarHalving.Batches +open PlaneGraph + +lemma fin_between_le {R : ℕ} {f : Fin (R + 1) → ℝ} (i j : Fin (R + 1)) + (hij : i ≤ j) + (hstep : ∀ r : Fin R, i ≤ r.castSucc → r.succ ≤ j → f r.castSucc ≤ f r.succ) : + f i ≤ f j := by + induction j using Fin.induction with + | zero => + have hi : i = 0 := Fin.ext (by simpa using hij) + subst i + exact le_rfl + | succ r ih => + by_cases hi : i ≤ r.castSucc + · exact (ih hi (fun s hs ht => hstep s hs (ht.trans (Fin.castSucc_le_succ r)))).trans + (hstep r hi le_rfl) + · have he : i = r.succ := Fin.ext (by simp only [Fin.le_def, Fin.val_succ, Fin.val_castSucc] at *; omega) + subst i + exact le_rfl + +structure ConvexPath (R : ℕ) where + point : Fin (R + 1) → Point + right : ∀ r : Fin R, point r.castSucc = point r.succ ∨ + (point r.castSucc).1 < (point r.succ).1 + slopes : ∀ r s : Fin R, r < s → point r.castSucc ≠ point r.succ → + point s.castSucc ≠ point s.succ → + slope (point r.castSucc) (point r.succ) ≤ slope (point s.castSucc) (point s.succ) + +lemma projection_step (p q : Point) {t : ℝ} (hx : p.1 ≠ q.1) : + Sweep.projection t q - Sweep.projection t p = + (q.1 - p.1) * (slope p q - t) := by + unfold Sweep.projection slope + field_simp + ring + +variable {R : ℕ} + +lemma ConvexPath.x_mono (C : ConvexPath R) : Monotone (fun r => (C.point r).1) := by + apply Fin.monotone_iff_le_succ.mpr + intro r + rcases C.right r with h | h + · exact le_of_eq (congrArg Prod.fst h) + · exact h.le + +lemma ConvexPath.support_vertex (C : ConvexPath R) (b : Fin R) + (hb : C.point b.castSucc ≠ C.point b.succ) (c : Fin (R + 1)) : + height (C.point b.castSucc) (C.point b.succ) (C.point c).1 ≤ (C.point c).2 := by + let t := slope (C.point b.castSucc) (C.point b.succ) + have hb' := (C.right b).resolve_left hb + have hroot : Sweep.projection t (C.point b.castSucc) = + Sweep.projection t (C.point b.succ) := by + have hh := projection_step (C.point b.castSucc) (C.point b.succ) (t := t) hb'.ne + simp only [t, sub_self, mul_zero] at hh + linarith + have hmin : Sweep.projection t (C.point b.castSucc) ≤ Sweep.projection t (C.point c) := by + by_cases hc : c ≤ b.castSucc + · have hh := fin_between_le (f := fun r => -Sweep.projection t (C.point r)) c b.castSucc hc + apply neg_le_neg_iff.mp + apply hh + intro r _ hr + rcases C.right r with he | hx + · rw [he] + · have hne : C.point r.castSucc ≠ C.point r.succ := fun he => hx.ne (congrArg Prod.fst he) + have hlt : r < b := by simp only [Fin.le_def, Fin.lt_def, Fin.val_succ, Fin.val_castSucc] at *; omega + have hs := C.slopes r b hlt hne hb + have hd := projection_step (C.point r.castSucc) (C.point r.succ) (t := t) hx.ne + have hn := mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hx.le) (sub_nonpos.mpr hs) + dsimp only [t] at hd ⊢ + linarith only [hd, hn] + · have hc' : b.succ ≤ c := by simp only [Fin.le_def, Fin.val_succ, Fin.val_castSucc] at *; omega + rw [hroot] + apply fin_between_le (f := fun r => Sweep.projection t (C.point r)) b.succ c hc' + intro r hr _ + rcases C.right r with he | hx + · rw [he] + · have hne : C.point r.castSucc ≠ C.point r.succ := fun he => hx.ne (congrArg Prod.fst he) + have hlt : b < r := by simp only [Fin.le_def, Fin.lt_def, Fin.val_succ, Fin.val_castSucc] at *; omega + have hs := C.slopes b r hlt hb hne + have hd := projection_step (C.point r.castSucc) (C.point r.succ) (t := t) hx.ne + have hn := mul_nonneg (sub_nonneg.mpr hx.le) (sub_nonneg.mpr hs) + change Sweep.projection t (C.point r.castSucc) ≤ Sweep.projection t (C.point r.succ) + dsimp only [t] at hd ⊢ + linarith only [hd, hn] + unfold Sweep.projection at hmin + unfold height + dsimp only [t] at hmin + linarith only [hmin] + +lemma ConvexPath.support_segment (C : ConvexPath R) (b : Fin R) + (hb : C.point b.castSucc ≠ C.point b.succ) (c : Fin R) {z : Point} + (hz : z ∈ segment ℝ (C.point c.castSucc) (C.point c.succ)) : + height (C.point b.castSucc) (C.point b.succ) z.1 ≤ z.2 := by + rw [segment_eq_image] at hz + obtain ⟨u, hu, rfl⟩ := hz + have h₀ := C.support_vertex b hb c.castSucc + have h₁ := C.support_vertex b hb c.succ + have hw₀ := mul_nonneg (sub_nonneg.mpr hu.2) (sub_nonneg.mpr h₀) + have hw₁ := mul_nonneg hu.1 (sub_nonneg.mpr h₁) + simp only [Prod.fst_add, Prod.snd_add, Prod.smul_fst, Prod.smul_snd, smul_eq_mul, height] at * + nlinarith only [hw₀, hw₁] + +variable {n k a : ℕ} {P : Fin n → Point} + +lemma System.token_step (S : @System n R k a P) [NeZero a] + (j : Fin a) (u : ↥(S.marks 0)) (b : Fin R) : + (S.tokenState j b.castSucc u : Fin n) = (S.tokenState j b.succ u : Fin n) ∨ + (S.tokenState j b.castSucc u : Fin n) ∈ S.loss b ∧ + (S.tokenState j b.succ u : Fin n) ∈ S.gain b := by + rw [S.tokenState_succ] + by_cases h : (S.tokenState j b.castSucc u : Fin n) ∈ S.marks b.succ + · left + exact (transport_of_mem (S.match j b) _ h).symm + · right + refine ⟨Finset.mem_sdiff.mpr ⟨(S.tokenState j b.castSucc u).property, h⟩, ?_⟩ + change (transport _ _ (S.match j b) _ : Fin n) ∈ _ + rw [transport_of_not_mem (S.match j b) _ h] + exact (S.match j b ⟨_, Finset.mem_sdiff.mpr ⟨(S.tokenState j b.castSucc u).property, h⟩⟩).property + +noncomputable def System.tokenPath (S : @System n R k a P) [NeZero a] + (j : Fin a) (u : ↥(S.marks 0)) : ConvexPath R where + point b := P (S.tokenState j b u) + right b := by + rcases S.token_step j u b with h | ⟨h₀,h₁⟩ + · exact Or.inl (congrArg P h) + · exact Or.inr (S.edge_right b h₀ h₁) + slopes b c hbc hb hc := by + have hb' := (S.token_step j u b).resolve_left (fun h => hb (congrArg P h)) + have hc' := (S.token_step j u c).resolve_left (fun h => hc (congrArg P h)) + have hs₁ := S.edge_slope b hb'.1 hb'.2 + have hs₂ := S.edge_slope c hc'.1 hc'.2 + have horder : b.succ ≤ c.castSucc := by + simp only [Fin.le_def, Fin.lt_def, Fin.val_succ, Fin.val_castSucc] at * + omega + exact (hs₁.2.trans_le (S.increasing.monotone horder)).trans hs₂.1 |>.le + +end PlanarHalving.Batches + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Boundary.lean b/lean/OAI/Combinatorics/HalvingLines/Boundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..91ec4fdbaaed811dd03302af4c0c222340fd9407 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Boundary.lean @@ -0,0 +1,345 @@ +import OAI.Combinatorics.HalvingLines.Activity + +namespace OAI + +namespace PlanarHalving + +namespace Boundary + +lemma outside_strip {t c ρ : ℝ} (h : ¬ |t - c| ≤ 3 * ρ) : + t < c - 3 * ρ ∨ c + 3 * ρ < t := by + have h' : 3 * ρ < |t - c| := lt_of_not_ge h + rcases lt_abs.mp h' with h' | h' + · right + linarith + · left + linarith + +lemma initially_marked_loss {t c₀ cmin ρ : ℝ} + (hρ : 0 ≤ ρ) (hmark : t < c₀) + (hactive : cmin - ρ ≤ t) + (hstrip₀ : ¬ |t - c₀| ≤ 3 * ρ) + (hstripmin : ¬ |t - cmin| ≤ 3 * ρ) : + cmin + 3 * ρ < t ∧ t < c₀ - 3 * ρ ∧ cmin + 6 * ρ < c₀ := by + rcases outside_strip hstrip₀ with h₀ | h₀ + · rcases outside_strip hstripmin with hm | hm + · linarith + · exact ⟨hm, h₀, by linarith⟩ + · linarith + +lemma initially_unmarked_gain {t c₀ cmax ρ : ℝ} + (hρ : 0 ≤ ρ) (hunmark : c₀ ≤ t) + (hactive : t ≤ cmax + ρ) + (hstrip₀ : ¬ |t - c₀| ≤ 3 * ρ) + (hstripmax : ¬ |t - cmax| ≤ 3 * ρ) : + c₀ + 3 * ρ < t ∧ t < cmax - 3 * ρ ∧ c₀ + 6 * ρ < cmax := by + rcases outside_strip hstrip₀ with h₀ | h₀ + · linarith + · rcases outside_strip hstripmax with hm | hm + · exact ⟨h₀, hm, by linarith⟩ + · linarith + +theorem three_strips_core {α ι : Type*} [DecidableEq α] + (M : ι → Finset α) (A B : Finset α) (t : α → ℝ) + (c : ι → ℝ) (e : ι → α → ℝ) (i₀ imin imax : ι) (ρ : ℝ) (C : ℕ) + (hρ : 0 ≤ ρ) + (hmin : ∀ i, c imin ≤ c i) (hmax : ∀ i, c i ≤ c imax) + (herr : ∀ i x, x ∈ B → |e i x| ≤ ρ) + (hzero : ∀ x ∈ B, e i₀ x = 0) + (hcut : ∀ i x, x ∈ B → (x ∈ M i ↔ t x + e i x < c i)) + (hactive : ∀ x ∈ A, + (x ∈ M i₀ → ∃ i, x ∉ M i) ∧ (x ∉ M i₀ → ∃ i, x ∈ M i)) + (hbudget : ∀ i, + (M i₀ ∩ B).card ≤ (M i ∩ B).card + C ∧ + (M i ∩ B).card ≤ (M i₀ ∩ B).card + C) : + ((A ∩ B).filter fun x => + ¬ (|t x - c i₀| ≤ 3 * ρ ∨ |t x - c imin| ≤ 3 * ρ ∨ + |t x - c imax| ≤ 3 * ρ)).card ≤ 2 * C := by + classical + let H := (A ∩ B).filter fun x => + ¬ (|t x - c i₀| ≤ 3 * ρ ∨ |t x - c imin| ≤ 3 * ρ ∨ + |t x - c imax| ≤ 3 * ρ) + let L := H.filter fun x => x ∈ M i₀ + let G := H.filter fun x => x ∉ M i₀ + have hH (x : α) (hx : x ∈ H) : + x ∈ A ∧ x ∈ B ∧ ¬ |t x - c i₀| ≤ 3 * ρ ∧ + ¬ |t x - c imin| ≤ 3 * ρ ∧ ¬ |t x - c imax| ≤ 3 * ρ := by + simpa only [H, Finset.mem_filter, Finset.mem_inter, not_or, and_assoc] using hx + have hL (x : α) (hx : x ∈ L) : + c imin + 3 * ρ < t x ∧ t x < c i₀ - 3 * ρ ∧ c imin + 6 * ρ < c i₀ := by + obtain ⟨hxH, hxM⟩ := Finset.mem_filter.mp hx + obtain ⟨hxA, hxB, hx₀, hxm, _⟩ := hH x hxH + have hmarked : t x < c i₀ := by + simpa only [hzero x hxB, add_zero] using (hcut i₀ x hxB).mp hxM + obtain ⟨i, hi⟩ := (hactive x hxA).1 hxM + have hi' : c i ≤ t x + e i x := not_lt.mp fun h => hi ((hcut i x hxB).mpr h) + have he := (abs_le.mp (herr i x hxB)).2 + have ht : c imin - ρ ≤ t x := by linarith [hmin i] + exact initially_marked_loss hρ hmarked ht hx₀ hxm + have hG (x : α) (hx : x ∈ G) : + c i₀ + 3 * ρ < t x ∧ t x < c imax - 3 * ρ ∧ c i₀ + 6 * ρ < c imax := by + obtain ⟨hxH, hxM⟩ := Finset.mem_filter.mp hx + obtain ⟨hxA, hxB, hx₀, _, hxmax⟩ := hH x hxH + have hunmarked : c i₀ ≤ t x := by + apply not_lt.mp + intro h + exact hxM ((hcut i₀ x hxB).mpr (by simpa only [hzero x hxB, add_zero] using h)) + obtain ⟨i, hi⟩ := (hactive x hxA).2 hxM + have hi' := (hcut i x hxB).mp hi + have he := (abs_le.mp (herr i x hxB)).1 + have ht : t x ≤ c imax + ρ := by linarith [hmax i] + exact initially_unmarked_gain hρ hunmarked ht hx₀ hxmax + have hLcard : L.card ≤ C := by + by_cases hn : L.Nonempty + · obtain ⟨x, hx⟩ := hn + have hgap := (hL x hx).2.2 + have hsub : M imin ∩ B ⊆ M i₀ ∩ B := by + intro y hy + obtain ⟨hyM, hyB⟩ := Finset.mem_inter.mp hy + refine Finset.mem_inter.mpr ⟨?_, hyB⟩ + by_contra hnM + have hy₀ : c i₀ ≤ t y := by + apply not_lt.mp + intro h + exact hnM ((hcut i₀ y hyB).mpr (by simpa only [hzero y hyB, add_zero] using h)) + have hymin := (hcut imin y hyB).mp hyM + have he := (abs_le.mp (herr imin y hyB)).1 + linarith + have hsubL : L ⊆ (M i₀ ∩ B) \ (M imin ∩ B) := by + intro y hy + obtain ⟨hyH, hyM⟩ := Finset.mem_filter.mp hy + have hyB := (hH y hyH).2.1 + refine Finset.mem_sdiff.mpr ⟨Finset.mem_inter.mpr ⟨hyM, hyB⟩, ?_⟩ + intro hymin + have hc := (hcut imin y hyB).mp (Finset.mem_inter.mp hymin).1 + have he := (abs_le.mp (herr imin y hyB)).1 + have ht := (hL y hy).1 + linarith + have hcount := Finset.card_sdiff_add_card_eq_card hsub + have hle := Finset.card_le_card hsubL + have hb := (hbudget imin).1 + omega + · simp only [Finset.not_nonempty_iff_eq_empty.mp hn, Finset.card_empty, Nat.zero_le] + have hGcard : G.card ≤ C := by + by_cases hn : G.Nonempty + · obtain ⟨x, hx⟩ := hn + have hgap := (hG x hx).2.2 + have hsub : M i₀ ∩ B ⊆ M imax ∩ B := by + intro y hy + obtain ⟨hyM, hyB⟩ := Finset.mem_inter.mp hy + refine Finset.mem_inter.mpr ⟨(hcut imax y hyB).mpr ?_, hyB⟩ + have hy₀ : t y < c i₀ := by + simpa only [hzero y hyB, add_zero] using (hcut i₀ y hyB).mp hyM + have he := (abs_le.mp (herr imax y hyB)).2 + linarith + have hsubG : G ⊆ (M imax ∩ B) \ (M i₀ ∩ B) := by + intro y hy + obtain ⟨hyH, hyM⟩ := Finset.mem_filter.mp hy + have hyB := (hH y hyH).2.1 + refine Finset.mem_sdiff.mpr ⟨Finset.mem_inter.mpr ⟨?_, hyB⟩, ?_⟩ + · apply (hcut imax y hyB).mpr + have he := (abs_le.mp (herr imax y hyB)).2 + have ht := (hG y hy).2.1 + linarith + · exact fun hi => hyM (Finset.mem_inter.mp hi).1 + have hcount := Finset.card_sdiff_add_card_eq_card hsub + have hle := Finset.card_le_card hsubG + have hb := (hbudget imax).2 + omega + · simp only [Finset.not_nonempty_iff_eq_empty.mp hn, Finset.card_empty, Nat.zero_le] + have hsplit : L.card + G.card = H.card := Finset.card_filter_add_card_filter_not (s := H) (fun x => x ∈ M i₀) + change H.card ≤ 2 * C + omega + +lemma token_population {α τ : Type*} [DecidableEq α] [Fintype τ] + (f : τ → α) (hf : Function.Injective f) (B : Finset α) : + ((Finset.univ.image f) ∩ B).card = + (Finset.univ.filter fun u => f u ∈ B).card := by + classical + rw [← Finset.filter_mem_eq_inter, Finset.filter_image, + Finset.card_image_of_injective _ hf] + +lemma filter_population_change {τ : Type*} [Fintype τ] + (p q : τ → Prop) [DecidablePred p] [DecidablePred q] : + (Finset.univ.filter p).card ≤ (Finset.univ.filter q).card + + (Finset.univ.filter fun u => ¬ (p u ↔ q u)).card ∧ + (Finset.univ.filter q).card ≤ (Finset.univ.filter p).card + + (Finset.univ.filter fun u => ¬ (p u ↔ q u)).card := by + classical + have h₁ : Finset.univ.filter p ⊆ + (Finset.univ.filter q) ∪ (Finset.univ.filter fun u => ¬ (p u ↔ q u)) := by + intro u hu + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hu + simp only [Finset.mem_union, Finset.mem_filter, Finset.mem_univ, true_and] + by_cases hq : q u + · exact Or.inl hq + · exact Or.inr fun h => hq (h.mp hu) + have h₂ : Finset.univ.filter q ⊆ + (Finset.univ.filter p) ∪ (Finset.univ.filter fun u => ¬ (p u ↔ q u)) := by + intro u hu + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hu + simp only [Finset.mem_union, Finset.mem_filter, Finset.mem_univ, true_and] + by_cases hp : p u + · exact Or.inl hp + · exact Or.inr fun h => hp (h.mpr hu) + exact ⟨(Finset.card_le_card h₁).trans (Finset.card_union_le _ _), + (Finset.card_le_card h₂).trans (Finset.card_union_le _ _)⟩ + +theorem token_population_budget {τ : Type*} [Fintype τ] + (inside : ℕ → τ → Prop) [∀ i, DecidablePred (inside i)] (m i : ℕ) (hi : i ≤ m) : + let pop := fun j => (Finset.univ.filter (inside j)).card + let cost := fun j => (Finset.univ.filter fun u => + ¬ (inside j u ↔ inside (j + 1) u)).card + pop 0 ≤ pop i + ∑ j ∈ Finset.range m, cost j ∧ + pop i ≤ pop 0 + ∑ j ∈ Finset.range m, cost j := by + classical + dsimp only + let pop := fun j => (Finset.univ.filter (inside j)).card + let cost := fun j => (Finset.univ.filter fun u => + ¬ (inside j u ↔ inside (j + 1) u)).card + change pop 0 ≤ pop i + ∑ j ∈ Finset.range m, cost j ∧ + pop i ≤ pop 0 + ∑ j ∈ Finset.range m, cost j + have hpref (i : ℕ) : + pop 0 ≤ pop i + ∑ j ∈ Finset.range i, cost j ∧ + pop i ≤ pop 0 + ∑ j ∈ Finset.range i, cost j := by + induction i with + | zero => simp + | succ i ih => + have hstep := filter_population_change (inside i) (inside (i + 1)) + change pop i ≤ pop (i+1) + cost i ∧ pop (i+1) ≤ pop i + cost i at hstep + rw [Finset.sum_range_succ] + omega + have hsum : ∑ j ∈ Finset.range i, cost j ≤ ∑ j ∈ Finset.range m, cost j := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono hi) (by intros; omega) + have hp := hpref i + omega + +theorem three_strips_tokens {α τ : Type*} [DecidableEq α] [Fintype τ] + (m : ℕ) (f : ℕ → τ → α) (hf : ∀ i ≤ m, Function.Injective (f i)) + (A B : Finset α) (t : α → ℝ) (c : Fin (m + 1) → ℝ) + (e : Fin (m + 1) → α → ℝ) (imin imax : Fin (m + 1)) (ρ : ℝ) + (hρ : 0 ≤ ρ) + (hmin : ∀ i, c imin ≤ c i) (hmax : ∀ i, c i ≤ c imax) + (herr : ∀ i x, x ∈ B → |e i x| ≤ ρ) + (hzero : ∀ x ∈ B, e 0 x = 0) + (hcut : ∀ (i : Fin (m + 1)) (x : α), x ∈ B → + (x ∈ Finset.univ.image (f i) ↔ t x + e i x < c i)) + (hactive : ∀ x ∈ A, + (x ∈ Finset.univ.image (f 0) → ∃ i : Fin (m + 1), + x ∉ Finset.univ.image (f i)) ∧ + (x ∉ Finset.univ.image (f 0) → ∃ i : Fin (m + 1), + x ∈ Finset.univ.image (f i))) : + ((A ∩ B).filter fun x => + ¬ (|t x - c 0| ≤ 3 * ρ ∨ |t x - c imin| ≤ 3 * ρ ∨ + |t x - c imax| ≤ 3 * ρ)).card ≤ + 2 * ∑ j ∈ Finset.range m, (Finset.univ.filter fun u => + ¬ (f j u ∈ B ↔ f (j + 1) u ∈ B)).card := by + classical + apply three_strips_core (fun i : Fin (m + 1) => Finset.univ.image (f i)) + A B t c e 0 imin imax ρ _ hρ hmin hmax herr hzero hcut hactive + intro i + simp only [Fin.val_zero] + rw [token_population _ (hf 0 (Nat.zero_le _)), + token_population _ (hf i (by omega))] + exact token_population_budget (fun j u => f j u ∈ B) m i (by omega) + +lemma changes_initial {ι : Type*} (p : ι → Prop) (i₀ : ι) + (hp : ∃ i j, ¬ (p i ↔ p j)) : + (p i₀ → ∃ i, ¬ p i) ∧ (¬ p i₀ → ∃ i, p i) := by + classical + obtain ⟨i, j, h⟩ := hp + constructor + · intro _ + by_cases hi : p i + · exact ⟨j, fun hj => h ⟨fun _ => hj, fun _ => hi⟩⟩ + · exact ⟨i, hi⟩ + · intro _ + by_cases hi : p i + · exact ⟨i, hi⟩ + · refine ⟨j, ?_⟩ + by_contra hj + exact h ⟨fun hpi => (hi hpi).elim, fun hpj => (hj hpj).elim⟩ + +def dot (u v : Point) : ℝ := u.1 * v.1 + u.2 * v.2 + +def sqNorm (u : Point) : ℝ := u.1 ^ 2 + u.2 ^ 2 + +lemma dot_sq_le (u v : Point) : dot u v ^ 2 ≤ sqNorm u * sqNorm v := by + unfold dot sqNorm + nlinarith [sq_nonneg (u.1 * v.2 - u.2 * v.1)] + +lemma abs_dot_le {u v : Point} {D θ : ℝ} (hD : 0 ≤ D) (hθ : 0 ≤ θ) + (hu : sqNorm u ≤ θ ^ 2) (hv : sqNorm v ≤ D ^ 2) : + |dot u v| ≤ D * θ := by + have hs : 0 ≤ sqNorm v := by unfold sqNorm; positivity + have hsq := (dot_sq_le u v).trans (mul_le_mul hu hv hs (sq_nonneg θ)) + apply (sq_le_sq₀ (abs_nonneg _) (mul_nonneg hD hθ)).mp + rw [sq_abs] + nlinarith + +theorem three_strips_geometric {τ : Type*} [Fintype τ] + (m : ℕ) (f : ℕ → τ → Point) (hf : ∀ i ≤ m, Function.Injective (f i)) + (A B : Finset Point) (ν : Fin (m + 1) → Point) (c : Fin (m + 1) → ℝ) + (imin imax : Fin (m + 1)) (D θ : ℝ) + (hD : 0 ≤ D) (hθ : 0 ≤ θ) + (hmin : ∀ i, c imin ≤ c i) (hmax : ∀ i, c i ≤ c imax) + (hnormal : ∀ i, sqNorm (ν i - ν 0) ≤ θ ^ 2) + (hbounded : ∀ x ∈ B, sqNorm x ≤ D ^ 2) + (hcut : ∀ (i : Fin (m + 1)) (x : Point), x ∈ B → + (x ∈ Finset.univ.image (f i) ↔ dot (ν i) x < c i)) + (hactive : ∀ x ∈ A, ∃ i j : Fin (m + 1), + ¬ (x ∈ Finset.univ.image (f i) ↔ x ∈ Finset.univ.image (f j))) : + ((A ∩ B).filter fun x => + ¬ (|dot (ν 0) x - c 0| ≤ 3 * (D * θ) ∨ + |dot (ν 0) x - c imin| ≤ 3 * (D * θ) ∨ + |dot (ν 0) x - c imax| ≤ 3 * (D * θ))).card ≤ + 2 * ∑ j ∈ Finset.range m, (Finset.univ.filter fun u => + ¬ (f j u ∈ B ↔ f (j + 1) u ∈ B)).card := by + classical + apply three_strips_tokens m f hf A B (dot (ν 0)) c + (fun i x => dot (ν i - ν 0) x) imin imax (D * θ) + (mul_nonneg hD hθ) hmin hmax + · intro i x hx + exact abs_dot_le hD hθ (hnormal i) (hbounded x hx) + · intro x _ + simp [dot] + · intro i x hx + have hid : dot (ν 0) x + dot (ν i - ν 0) x = dot (ν i) x := by + simp only [dot, Prod.fst_sub, Prod.snd_sub] + ring + rw [hid] + exact hcut i x hx + · intro x hx + simpa only [Fin.val_zero] using + changes_initial (fun i : Fin (m + 1) => x ∈ Finset.univ.image (f i)) 0 + (hactive x hx) + +lemma active_le_outside_add_strips {α : Type*} [DecidableEq α] + (A B : Finset α) (p q r : α → Prop) + [DecidablePred p] [DecidablePred q] [DecidablePred r] : + (A ∩ B).card ≤ + ((A ∩ B).filter fun x => ¬ (p x ∨ q x ∨ r x)).card + + (B.filter p).card + (B.filter q).card + (B.filter r).card := by + classical + have hsub : A ∩ B ⊆ + (((A ∩ B).filter fun x => ¬ (p x ∨ q x ∨ r x)) ∪ B.filter p ∪ + B.filter q) ∪ B.filter r := by + intro x hx + obtain ⟨ha, hb⟩ := Finset.mem_inter.mp hx + simp only [Finset.mem_union, Finset.mem_filter, Finset.mem_inter] + tauto + have h₀ := Finset.card_le_card hsub + have h₁ := Finset.card_union_le + (((A ∩ B).filter fun x => ¬ (p x ∨ q x ∨ r x)) ∪ B.filter p ∪ + B.filter q) (B.filter r) + have h₂ := Finset.card_union_le + (((A ∩ B).filter fun x => ¬ (p x ∨ q x ∨ r x)) ∪ B.filter p) (B.filter q) + have h₃ := Finset.card_union_le + ((A ∩ B).filter fun x => ¬ (p x ∨ q x ∨ r x)) (B.filter p) + omega + +end Boundary + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/BoundaryTokens.lean b/lean/OAI/Combinatorics/HalvingLines/BoundaryTokens.lean new file mode 100644 index 0000000000000000000000000000000000000000..873bf903ba9bf20faf02b56329232ac6c3c6c0b8 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/BoundaryTokens.lean @@ -0,0 +1,485 @@ +import OAI.Combinatorics.HalvingLines.Enhancement + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Boundary +open Set +open scoped Classical + +lemma monotone_pred_changes {m : ℕ} (p : Fin (m+1) → Prop) + (hp : ∀ i j, i≤j → p i → p j) : + (Finset.univ.filter fun i : Fin m => ¬ (p i.castSucc ↔ p i.succ)).card≤1 := by + classical + have hstep {i : Fin m} (hi : ¬ (p i.castSucc ↔ p i.succ)) : ¬p i.castSucc ∧ p i.succ := by + have hf := hp i.castSucc i.succ (by simp [Fin.le_def]) + tauto + apply Finset.card_le_one.mpr + intro i hi j hj + have hi' := hstep (Finset.mem_filter.mp hi).2 + have hj' := hstep (Finset.mem_filter.mp hj).2 + by_contra hne + rcases lt_or_gt_of_ne hne with hij | hji + · exact hj'.1 (hp i.succ j.castSucc (by simp only [Fin.le_def,Fin.lt_def,Fin.val_succ,Fin.val_castSucc] at *; omega) hi'.2) + · exact hi'.1 (hp j.succ i.castSucc (by simp only [Fin.le_def,Fin.lt_def,Fin.val_succ,Fin.val_castSucc] at *; omega) hj'.2) + +def InSquare (a b : ℝ) (x : Point) : Prop := a (f i).1)) (h2 : Monotone (fun i => (f i).2)) + (a b : ℝ) : + (Finset.univ.filter fun i : Fin m => ¬ (InSquare a b (f i.castSucc) ↔ InSquare a b (f i.succ))).card≤4 := by + classical + let A := Finset.univ.filter fun i : Fin m => ¬ (a<(f i.castSucc).1 ↔ a<(f i.succ).1) + let B := Finset.univ.filter fun i : Fin m => ¬ (b≤(f i.castSucc).1 ↔ b≤(f i.succ).1) + let C := Finset.univ.filter fun i : Fin m => ¬ (a<(f i.castSucc).2 ↔ a<(f i.succ).2) + let D := Finset.univ.filter fun i : Fin m => ¬ (b≤(f i.castSucc).2 ↔ b≤(f i.succ).2) + have hA : A.card≤1 := monotone_pred_changes (fun i => a<(f i).1) (fun i j hij ha => ha.trans_le (h1 hij)) + have hB : B.card≤1 := monotone_pred_changes (fun i => b≤(f i).1) (fun i j hij ha => ha.trans (h1 hij)) + have hC : C.card≤1 := monotone_pred_changes (fun i => a<(f i).2) (fun i j hij ha => ha.trans_le (h2 hij)) + have hD : D.card≤1 := monotone_pred_changes (fun i => b≤(f i).2) (fun i j hij ha => ha.trans (h2 hij)) + have hs : (Finset.univ.filter fun i : Fin m => + ¬ (InSquare a b (f i.castSucc) ↔ InSquare a b (f i.succ)))⊆ A∪B∪C∪D := by + intro i hi + have hi' := (Finset.mem_filter.mp hi).2 + simp only [A,B,C,D,Finset.mem_union,Finset.mem_filter,Finset.mem_univ,true_and] + dsimp only [InSquare] at hi' + simp only [lt_iff_not_ge] at * + tauto + have ht := Finset.card_le_card hs + have h4 := Finset.card_union_le (A∪B∪C) D + have h3 := Finset.card_union_le (A∪B) C + have h2 := Finset.card_union_le A B + omega + +lemma square_token_budget {τ : Type*} [Fintype τ] {m : ℕ} + (f : Fin (m+1) → τ → Point) + (h1 : ∀ u, Monotone (fun i => (f i u).1)) + (h2 : ∀ u, Monotone (fun i => (f i u).2)) (a b : ℝ) : + (∑ i : Fin m, (Finset.univ.filter fun u : τ => + ¬ (InSquare a b (f i.castSucc u) ↔ InSquare a b (f i.succ u))).card)≤4*Fintype.card τ := by + classical + have he : (∑ i : Fin m, (Finset.univ.filter fun u : τ => + ¬ (InSquare a b (f i.castSucc u) ↔ InSquare a b (f i.succ u))).card)= + ∑ u : τ, (Finset.univ.filter fun i : Fin m => + ¬ (InSquare a b (f i.castSucc u) ↔ InSquare a b (f i.succ u))).card := by + simp only [Finset.card_filter] + exact Finset.sum_comm + rw [he] + calc + _ ≤ ∑ _u : τ, 4 := Finset.sum_le_sum (fun u _ => monotone_square_changes (fun i => f i u) (h1 u) (h2 u) a b) + _ = _ := by simp [Nat.mul_comm] + +end PlanarHalving.Boundary + +namespace PlanarHalving.Boundary +open Set +open scoped Classical + +noncomputable def rawNormal (t : ℝ) : Point := (-t,1-t) +noncomputable def frameWeight (a b l u s : ℝ) : ℝ := a*(s-l)+b*(u-s) +noncomputable def frameParameter (a b l u s : ℝ) : ℝ := a*(s-l)/frameWeight a b l u s + +lemma frameWeight_pos {a b l u s : ℝ} (ha : 0 simp + conv_lhs => rw [hx,map_add,map_smul,map_smul,h1,h2] + ext <;> dsimp <;> ring + +lemma frame_projection (E : Point ≃L[ℝ] Point) {a b l u s : ℝ} + (h1 : E (1,0)=a • (1,l)) (h2 : E (0,1)=b • (1,u)) + (hd : frameWeight a b l u s≠0) (x : Point) : + Sweep.projection s (E x)=frameWeight a b l u s * dot (rawNormal (frameParameter a b l u s)) x := by + rw [frame_apply E h1 h2] + dsimp [Sweep.projection,dot,rawNormal,frameParameter] + field_simp + dsimp [frameWeight] + ring + +lemma frame_inverse_nonneg (E : Point ≃L[ℝ] Point) {a b l u : ℝ} + (ha : 0 ⟨fun hv => (hmax v hv).trans_lt hc,fun hv => ?_⟩⟩ + by_contra hvM + exact (not_lt_of_ge ((hmin v (Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,hvM⟩)).trans' hd.le)) hv + · refine ⟨f i+1,fun v => ⟨fun hv => by linarith [hmax v hv],fun _ => ?_⟩⟩ + by_contra hv + exact hN ⟨v,Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,hv⟩⟩ + · have he : M=∅ := Finset.not_nonempty_iff_eq_empty.mp hM + subst M + by_cases hn : Nonempty V + · let := hn + obtain ⟨j,hj,hmin⟩ := Finset.exists_min_image Finset.univ f Finset.univ_nonempty + refine ⟨f j-1,fun v => ?_⟩ + simp only [Finset.notMem_empty,false_iff,not_lt] + linarith [hmin v (Finset.mem_univ _)] + · exact ⟨0,fun v => (hn ⟨v⟩).elim⟩ + +end PlanarHalving.Boundary + +namespace PlanarHalving.Boundary +open Set +open scoped Classical + +noncomputable def physical (E : Point ≃L[ℝ] Point) (o : Point) (r : ℝ) (p : Point) : Point := + r • E.symm (p-o) + +lemma physical_sub (E : Point ≃L[ℝ] Point) (o : Point) (r : ℝ) (p q : Point) : + physical E o r q - physical E o r p=r • E.symm (q-p) := by + rw [physical,physical,← smul_sub,← map_sub] + congr 2 + abel + +lemma physical_injective (E : Point ≃L[ℝ] Point) (o : Point) {r : ℝ} (hr : r≠0) : + Function.Injective (physical E o r) := by + intro p q h + have he := (smul_right_injective Point hr) h + simpa only [sub_add_cancel] using congrArg (fun x : Point => x+o) (E.symm.injective he) + +lemma projection_physical (E : Point ≃L[ℝ] Point) {a b l u s : ℝ} + (h1 : E (1,0)=a • (1,l)) (h2 : E (0,1)=b • (1,u)) + (hd : frameWeight a b l u s≠0) (o : Point) (r : ℝ) (p : Point) : + dot (rawNormal (frameParameter a b l u s)) (physical E o r p)= + r/frameWeight a b l u s*(Sweep.projection s p-Sweep.projection s o) := by + have he := frame_projection E h1 h2 hd (E.symm (p-o)) + rw [E.apply_symm_apply] at he + calc + _ = r*dot (rawNormal (frameParameter a b l u s)) (E.symm (p-o)) := by dsimp [physical,dot]; ring + _ = r/frameWeight a b l u s*(frameWeight a b l u s*dot (rawNormal (frameParameter a b l u s)) (E.symm (p-o))) := by field_simp + _ = _ := by rw [← he]; dsimp [Sweep.projection]; congr 1; ring + +lemma actual_transformed_cuts {n R k a₀ : ℕ} {P : Fin n → Point} + (S : @Batches.System n R k a₀ P) (E : Point ≃L[ℝ] Point) + {a b l u : ℝ} (ha : 0 separating_threshold + (fun v => dot (rawNormal (frameParameter a b l u (S.slope i))) (physical E o r (P v))) + (S.marks i) (by + intro v hv w hw + rw [projection_physical E h1 h2 (frameWeight_pos ha hb hlu (hspan i)).ne' o r, + projection_physical E h1 h2 (frameWeight_pos ha hb hlu (hspan i)).ne' o r] + exact mul_lt_mul_of_pos_left (sub_lt_sub_right (S.separates i v hv w hw) _) + (div_pos hr (frameWeight_pos ha hb hlu (hspan i)))) + exact ⟨c,hc⟩ + +lemma actual_tokens_monotone {n R k a₀ : ℕ} {P : Fin n → Point} [NeZero a₀] + (S : @Batches.System n R k a₀ P) (E : Point ≃L[ℝ] Point) + {a b l u : ℝ} (ha : 0 (physical E o r (P (S.tokenState j i v))).1) ∧ + Monotone (fun i => (physical E o r (P (S.tokenState j i v))).2) := by + have hstep (i : Fin R) : + 0 ≤ (physical E o r (P (S.tokenState j i.succ v))- + physical E o r (P (S.tokenState j i.castSucc v))).1 ∧ + 0 ≤ (physical E o r (P (S.tokenState j i.succ v))- + physical E o r (P (S.tokenState j i.castSucc v))).2 := by + rcases S.token_step j v i with he | ⟨hl,hg⟩ + · rw [he,sub_self]; exact ⟨le_rfl,le_rfl⟩ + · have hx := sub_pos.mpr (S.edge_right i hl hg) + have hs := S.edge_slope i hl hg + have hlo : l*(P (S.tokenState j i.succ v)-P (S.tokenState j i.castSucc v)).1 ≤ + (P (S.tokenState j i.succ v)-P (S.tokenState j i.castSucc v)).2 := + (le_div_iff₀ hx).mp ((hspan i.castSucc).1.trans hs.1.le) + have hhi : (P (S.tokenState j i.succ v)-P (S.tokenState j i.castSucc v)).2 ≤ + u*(P (S.tokenState j i.succ v)-P (S.tokenState j i.castSucc v)).1 := + (div_le_iff₀ hx).mp (hs.2.le.trans (hspan i.succ).2) + have hh := frame_inverse_nonneg E ha hb hlu h1 h2 _ hlo hhi + rw [physical_sub] + exact ⟨mul_nonneg hr.le hh.1,mul_nonneg hr.le hh.2⟩ + constructor + · apply Fin.monotone_iff_le_succ.mpr + intro i + exact sub_nonneg.mp (hstep i).1 + · apply Fin.monotone_iff_le_succ.mpr + intro i + exact sub_nonneg.mp (hstep i).2 + +end PlanarHalving.Boundary + +namespace PlanarHalving.Boundary +open Set +open scoped Classical + +noncomputable def clipCut (c : ℝ) : ℝ := max (-4) (min 4 c) +lemma clipCut_mem (c : ℝ) : clipCut c∈Icc (-4:ℝ) 4 := by + exact ⟨le_max_left _ _,max_le (by norm_num) (min_le_left _ _)⟩ +lemma clipCut_distance {t : ℝ} (ht : t∈Icc (-4:ℝ) 4) (c : ℝ) : + |t-clipCut c|≤|t-c| := by + obtain ⟨htlo,hthi⟩ := ht + by_cases hc : c≤-4 + · rw [clipCut,min_eq_right (hc.trans (by norm_num)),max_eq_left hc, + abs_of_nonneg (by linarith : 0≤t-(-4)),abs_of_nonneg (by linarith : 0≤t-c)] + linarith + · by_cases hd : 4≤c + · rw [clipCut,min_eq_left hd,max_eq_right (by norm_num : (-4:ℝ)≤4), + abs_of_nonpos (by linarith : t-4≤0),abs_of_nonpos (by linarith : t-c≤0)] + linarith + · rw [clipCut,min_eq_right (le_of_not_ge hd),max_eq_right (le_of_not_ge hc)] + +lemma rawNormal_dot_bound {t : ℝ} (ht : t∈Icc (0:ℝ) 1) {x : Point} + (hx : InSquare (-2) 2 x) : |dot (rawNormal t) x|≤2 := by + have htlo := ht.1 + have hthi := ht.2 + have h1 : |x.1|≤2 := abs_le.mpr ⟨hx.1.le,hx.2.1.le⟩ + have h2 : |x.2|≤2 := abs_le.mpr ⟨hx.2.2.1.le,hx.2.2.2.le⟩ + calc + _ ≤ |(-t)*x.1|+|(1-t)*x.2| := abs_add_le _ _ + _ = t*|x.1|+(1-t)*|x.2| := by rw [abs_mul,abs_mul,abs_neg,abs_of_nonneg ht.1,abs_of_nonneg (by linarith : 0≤1-t)] + _ ≤ t*2+(1-t)*2 := add_le_add (mul_le_mul_of_nonneg_left h1 ht.1) (mul_le_mul_of_nonneg_left h2 (by linarith)) + _ = 2 := by ring + +lemma finite_raw_bound {V τ : Type*} [Fintype V] [Fintype τ] + {m : ℕ} (p : V → Point) (f : Fin (m+1) → τ → V) + (hf : ∀ i, Function.Injective (f i)) (A : Finset V) + (t c : Fin (m+1) → ℝ) (ht : Monotone t) (htI : ∀ i, t i∈Icc (0:ℝ) 1) + (hcut : ∀ i v, v∈Finset.univ.image (f i) ↔ dot (rawNormal (t i)) (p v) InSquare (-2) 2 (p v) ∧ + ∀ j, 18*(t (Fin.last m)-t 0)< |dot (rawNormal (t 0)) (p v)-d j|).card≤ + 2*∑ i : Fin m, (Finset.univ.filter fun u : τ => + ¬(InSquare (-2) 2 (p (f i.castSucc u)) ↔ InSquare (-2) 2 (p (f i.succ u)))).card := by + classical + obtain ⟨imin,hmin⟩ := Finite.exists_min c + obtain ⟨imax,hmax⟩ := Finite.exists_max c + let d : Fin 3 → ℝ := ![clipCut (c 0),clipCut (c imin),clipCut (c imax)] + refine ⟨d,fun j => by fin_cases j <;> exact clipCut_mem _,?_⟩ + let B := Finset.univ.filter fun v => InSquare (-2) 2 (p v) + let θ := t (Fin.last m)-t 0 + have hθ : 0≤θ := sub_nonneg.mpr (ht (Fin.zero_le _)) + let g : ℕ → τ → V := fun i => f ⟨min i m,by omega⟩ + have hg (i : Fin (m+1)) : g i=f i := by + have he : (⟨min i.val m,by omega⟩ : Fin (m+1))=i := Fin.ext (min_eq_left (by omega)) + exact congrArg f he + have hgzero : g 0=f 0 := hg 0 + have hnormal (i : Fin (m+1)) : sqNorm (rawNormal (t i)-rawNormal (t 0))≤(2*θ)^2 := by + rw [rawNormal_difference] + have h0 := ht (Fin.zero_le i) + have h1 := ht (Fin.le_last i) + have hh : (t i-t 0)^2≤θ^2 := pow_le_pow_left₀ (sub_nonneg.mpr h0) (by dsimp [θ]; linarith) 2 + nlinarith [sq_nonneg θ] + have herr (i : Fin (m+1)) (v : V) (hv : v∈B) : + |dot (rawNormal (t i)-rawNormal (t 0)) (p v)|≤3*(2*θ) := by + apply abs_dot_le (by norm_num) (by positivity) (hnormal i) + have hv' := (Finset.mem_filter.mp hv).2 + have h1 : |(p v).1|≤2 := abs_le.mpr ⟨hv'.1.le,hv'.2.1.le⟩ + have h2 : |(p v).2|≤2 := abs_le.mpr ⟨hv'.2.2.1.le,hv'.2.2.2.le⟩ + have h1' := (sq_le_sq₀ (abs_nonneg _) (by norm_num : (0:ℝ)≤2)).mpr h1 + have h2' := (sq_le_sq₀ (abs_nonneg _) (by norm_num : (0:ℝ)≤2)).mpr h2 + simp only [sq_abs] at h1' h2' + dsimp [sqNorm]; nlinarith + have hmain := three_strips_tokens m g (fun i hi => hf _) A B + (fun v => dot (rawNormal (t 0)) (p v)) c + (fun i v => dot (rawNormal (t i)-rawNormal (t 0)) (p v)) imin imax (3*(2*θ)) + (by positivity) hmin hmax herr (fun v _ => by simp [dot]) + (by + intro i v _ + rw [hg] + have he : dot (rawNormal (t 0)) (p v)+dot (rawNormal (t i)-rawNormal (t 0)) (p v)=dot (rawNormal (t i)) (p v) := by dsimp [dot]; ring + rw [he] + exact hcut i v) + (by + intro v hv + have hh := changes_initial (fun i : Fin (m+1) => v∈Finset.univ.image (f i)) 0 (hactive v hv) + simpa only [hgzero,hg] using hh) + have hs : (A.filter fun v => InSquare (-2) 2 (p v) ∧ + ∀ j,18*θ< |dot (rawNormal (t 0)) (p v)-d j|)⊆ + ((A∩B).filter fun v => ¬(|dot (rawNormal (t 0)) (p v)-c 0|≤3*(3*(2*θ)) ∨ + |dot (rawNormal (t 0)) (p v)-c imin|≤3*(3*(2*θ)) ∨ + |dot (rawNormal (t 0)) (p v)-c imax|≤3*(3*(2*θ)))) := by + intro v hv + obtain ⟨hvA,hvB,hvD⟩ := Finset.mem_filter.mp hv + refine Finset.mem_filter.mpr ⟨Finset.mem_inter.mpr ⟨hvA,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hvB⟩⟩,?_⟩ + have hvdot := abs_le.mp (rawNormal_dot_bound (htI 0) hvB) + have hd (c : ℝ) := clipCut_distance (show dot (rawNormal (t 0)) (p v)∈Icc (-4:ℝ) 4 by constructor <;> linarith) c + have h0 := (hvD 0).trans_le (hd (c 0)) + have h1 := (hvD 1).trans_le (hd (c imin)) + have h2 := (hvD 2).trans_le (hd (c imax)) + change 18*θ< |dot (rawNormal (t 0)) (p v)-c 0| at h0 + change 18*θ< |dot (rawNormal (t 0)) (p v)-c imin| at h1 + change 18*θ< |dot (rawNormal (t 0)) (p v)-c imax| at h2 + rintro (hh|hh|hh) <;> linarith + apply (Finset.card_le_card hs).trans + convert hmain using 1 + congr 1 + rw [← Fin.sum_univ_eq_sum_range] + apply Finset.sum_congr rfl + intro i _ + congr 1 + ext u + have hgi := hg i.castSucc + have hgj := hg i.succ + simp only [Fin.val_castSucc,Fin.val_succ] at hgi hgj + simp only [Finset.mem_filter,Finset.mem_univ,true_and,hgi,hgj,B] + +end PlanarHalving.Boundary + +namespace PlanarHalving.Spatial +open Set Metric MeasureTheory Boundary +open scoped ENNReal + +lemma strip_bound_of_disk_nonneg (μ : Measure Point) {C d : ℝ} (hC : 0 ≤ C) (hd : 1 < d) + (hbound : ∀ x : Point, ∀ r : ℝ, 0 < r → μ (closedBall x r) ≤ ENNReal.ofReal (C*r^d)) + (ν : Point) (hν : sqNorm ν=1) (c : ℝ) {r : ℝ} (hr : 0 ≤ r) : + μ (closedBall (0:Point) 1 ∩ {x | |dot ν x-c| ≤ r}) ≤ + ENNReal.ofReal (13*C*(1+3^d)*r^(d-1)) := by + rcases hr.eq_or_lt with he | hr + · subst r + have hz := line_null_of_disk μ hC hd hbound ν hν c + have heq : {x : Point | |dot ν x-c| ≤ 0}={x | dot ν x=c} := by ext x; simp [sub_eq_zero] + rw [heq,hz] + exact zero_le + · by_cases h1 : r ≤ 1 + · apply (strip_bound_of_disk μ hC hbound ν hν c hr h1).trans + apply ENNReal.ofReal_le_ofReal + gcongr + linarith + · have h1' : 1 ≤ r := (not_le.mp h1).le + have hp : 1 ≤ r^(d-1) := Real.one_le_rpow h1' (by linarith) + calc + _ ≤ μ (closedBall (0:Point) 1) := measure_mono inter_subset_left + _ ≤ ENNReal.ofReal C := by simpa using hbound 0 1 (by norm_num) + _ ≤ _ := by + apply ENNReal.ofReal_le_ofReal + have h3 : 0 ≤ (3:ℝ)^d := Real.rpow_nonneg (by norm_num) _ + have hh : C ≤ 13*C*(1+3^d) := by nlinarith + exact hh.trans (le_mul_of_one_le_right (by positivity) hp) + +lemma normalize_sqNorm (ν : Point) (hν : 0 < sqNorm ν) : + sqNorm ((Real.sqrt (sqNorm ν))⁻¹ • ν)=1 := by + have hs := Real.sq_sqrt hν.le + have hn := (Real.sqrt_pos.mpr hν).ne' + dsimp [sqNorm] at * + field_simp + nlinarith only [hs] + +lemma raw_strip_bound (μ : Measure Point) {C d : ℝ} (hC : 0 ≤ C) (hd : 1 < d) + (hbound : ∀ x : Point, ∀ r : ℝ, 0 < r → μ (closedBall x r) ≤ ENNReal.ofReal (C*r^d)) + (t c : ℝ) {θ : ℝ} (hθ : 0 ≤ θ) : + μ (closedBall (0:Point) 1 ∩ {x | |dot (Boundary.rawNormal t) x-c| ≤ 18*θ}) ≤ + ENNReal.ofReal (13*C*(1+3^d)*36^(d-1)*θ^(d-1)) := by + let ν := Boundary.rawNormal t + let a := Real.sqrt (sqNorm ν) + have ha : 0 < a := Real.sqrt_pos.mpr (lt_of_lt_of_le (by norm_num : (0:ℝ) < 1/2) (Boundary.rawNormal_bounds t)) + have ha2 : (1:ℝ)/2 ≤ a := by + have hs := Real.sq_sqrt (show 0 ≤ sqNorm ν from (by norm_num : (0:ℝ) ≤ 1/2).trans (Boundary.rawNormal_bounds t)) + change a^2=sqNorm ν at hs + have hb := Boundary.rawNormal_bounds t + change 1/2 ≤ sqNorm ν at hb + nlinarith + have hn : sqNorm (a⁻¹ • ν)=1 := normalize_sqNorm ν (by have := Boundary.rawNormal_bounds t; change 1/2 ≤ sqNorm ν at this; linarith) + have hs : {x : Point | |dot ν x-c| ≤ 18*θ}⊆{x | |dot (a⁻¹ • ν) x-c/a| ≤ 36*θ} := by + intro x hx + have he : dot (a⁻¹ • ν) x-c/a=(dot ν x-c)/a := by dsimp [dot]; ring + change |dot (a⁻¹ • ν) x-c/a| ≤ 36*θ + rw [he,abs_div,abs_of_pos ha] + apply (div_le_iff₀ ha).mpr + change |dot ν x-c| ≤ 18*θ at hx + have hh := mul_le_mul_of_nonneg_left ha2 (show 0 ≤ 36*θ by positivity) + nlinarith only [hx,hh] + apply (measure_mono (inter_subset_inter_right _ hs)).trans + have hh := strip_bound_of_disk_nonneg μ hC hd hbound (a⁻¹ • ν) hn (c/a) (show 0 ≤ 36*θ by positivity) + rw [Real.mul_rpow (by norm_num : (0:ℝ) ≤ 36) hθ] at hh + simpa only [mul_assoc] using hh + +end PlanarHalving.Spatial + +namespace PlanarHalving.Limits +open Set Filter MeasureTheory +open scoped Topology +variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + +lemma eventually_gt_open {μ : FiniteMeasure X} {μs : ℕ → FiniteMeasure X} + (h : Tendsto μs atTop (𝓝 μ)) {O : Set X} (hO : IsOpen O) + {q : ℝ} (hq : q < (μ O : ℝ)) : ∀ᶠ n in atTop, q < (μs n O : ℝ) := by + let ε := ((μ O:ℝ)-q)/3 + have hε : 0<ε := by dsimp [ε]; linarith + have hadd (ν : FiniteMeasure X) : (ν O:ℝ)+(ν Oᶜ:ℝ)=(ν.mass:ℝ) := + measureReal_add_measureReal_compl (μ:=(ν:Measure X)) hO.measurableSet + have hcomp := eventually_lt_closed h hO.isClosed_compl + (show (μ Oᶜ:ℝ)<(μ Oᶜ:ℝ)+ε by linarith) + have hmass := (NNReal.continuous_coe.tendsto _ |>.comp h.mass).eventually + (eventually_gt_nhds (show (μ.mass:ℝ)-ε<(μ.mass:ℝ) by linarith)) + filter_upwards [hcomp,hmass] with n hn hm + have hsum := hadd (μs n) + have hsum' := hadd μ + dsimp [ε] at hn hm + linarith + +lemma open_le_of_eventually_le {μ : FiniteMeasure X} {μs : ℕ → FiniteMeasure X} + (h : Tendsto μs atTop (𝓝 μ)) {O : Set X} (hO : IsOpen O) + {b : ℕ → ℝ} {B : ℝ} (hb : Tendsto b atTop (𝓝 B)) + (hbound : ∀ᶠ n in atTop, (μs n O:ℝ) ≤ b n) : (μ O:ℝ) ≤ B := by + by_contra hh + obtain ⟨q,hqB,hqμ⟩ := exists_between (lt_of_not_ge hh) + obtain ⟨n,hn,hn',hn''⟩ := ((eventually_gt_open h hO hqμ).and + ((hb.eventually (eventually_lt_nhds hqB)).and hbound)).exists + exact (not_lt_of_ge hn'') (hn'.trans hn) + +end PlanarHalving.Limits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Calculus.lean b/lean/OAI/Combinatorics/HalvingLines/Calculus.lean new file mode 100644 index 0000000000000000000000000000000000000000..a528d7bd4347a6fa886cc303b5494447e7252467 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Calculus.lean @@ -0,0 +1,320 @@ +import OAI.Combinatorics.HalvingLines.Zoom + +namespace OAI + +namespace PlanarHalving + +namespace Calculus + +open Filter MeasureTheory Set Metric Asymptotics +open scoped Topology ENNReal NNReal + +theorem ae_near_set (S : Set Point) (hS : MeasurableSet S) : + ∀ᵐ x ∂(volume : Measure Point), x ∈ S → + ∀ ε : ℝ, 0 < ε → ∀ᶠ y in 𝓝 x, + ∃ z ∈ S, dist z y ≤ ε * dist y x := by + have hd : ∀ᵐ x ∂(volume : Measure Point).restrict S, ∀ n : ℕ, + ∀ {ι : Type} {l : Filter ι} (w : ι → Point) (δ : ι → ℝ), + Tendsto δ l (𝓝[>] 0) → + (∀ᶠ j in l, x ∈ closedBall (w j) ((n + 1 : ℝ) * δ j)) → + Tendsto (fun j => volume (S ∩ closedBall (w j) (δ j)) / + volume (closedBall (w j) (δ j))) l (𝓝 (1 : ℝ≥0∞)) := by + rw [ae_all_iff] + intro n + exact IsUnifLocDoublingMeasure.ae_tendsto_measure_inter_div volume S (n + 1) + rw [ae_restrict_iff' hS] at hd + filter_upwards [hd] with x hx hxs + intro ε hε + obtain ⟨n, hn⟩ := exists_nat_gt (ε⁻¹) + have hn0 : (0 : ℝ) < n + 1 := by positivity + have hnε : (n + 1 : ℝ)⁻¹ ≤ ε := by + apply (inv_le_iff_one_le_mul₀ hn0).mpr + have hh := (inv_lt_iff_one_lt_mul₀ hε).mp hn + nlinarith + have hδ : Tendsto (fun y : Point => (n + 1 : ℝ)⁻¹ * dist y x) + (𝓝[≠] x) (𝓝[>] (0 : ℝ)) := by + rw [tendsto_nhdsWithin_iff] + refine ⟨?_, ?_⟩ + · have hh : Tendsto (fun y : Point => (n + 1 : ℝ)⁻¹ * dist y x) + (𝓝 x) (𝓝 ((n + 1 : ℝ)⁻¹ * dist x x)) := + (continuousAt_id.dist continuousAt_const).const_mul _ + simpa using hh.mono_left (nhdsWithin_le_nhds (s := {x}ᶜ)) + · filter_upwards [self_mem_nhdsWithin] with y hy + exact mul_pos (inv_pos.mpr hn0) (dist_pos.mpr hy) + have hcover : ∀ᶠ y : Point in 𝓝[≠] x, + x ∈ closedBall y ((n + 1 : ℝ) * ((n + 1 : ℝ)⁻¹ * dist y x)) := by + filter_upwards with y + simp [Metric.mem_closedBall, mul_inv_cancel_left₀ hn0.ne', dist_comm] + have hlim := hx hxs n (fun y : Point => y) + (fun y => (n + 1 : ℝ)⁻¹ * dist y x) hδ hcover + have he : ∀ᶠ y : Point in 𝓝[≠] x, + ∃ z ∈ S, dist z y ≤ ε * dist y x := by + have hh := hlim.eventually (Ioi_mem_nhds (show (0 : ℝ≥0∞) < 1 by simp)) + filter_upwards [hh] with y hy + have hne : volume (S ∩ closedBall y ((n + 1 : ℝ)⁻¹ * dist y x)) ≠ 0 := by + intro hz + simp [hz] at hy + obtain ⟨z, hzS, hzB⟩ := nonempty_of_measure_ne_zero hne + exact ⟨z, hzS, (Metric.mem_closedBall.mp hzB).trans + (mul_le_mul_of_nonneg_right hnε dist_nonneg)⟩ + rw [← nhdsNE_sup_pure x, Filter.eventually_sup] + exact ⟨he, by simp only [Filter.eventually_pure]; exact ⟨x, hxs, by simp⟩⟩ + +theorem hasFDerivAt_of_within_near_set {f : Point → ℝ} {S : Set Point} + {x : Point} {f' : Point →L[ℝ] ℝ} {C : ℝ} (hC : 0 ≤ C) + (hLip : ∀ z ∈ S, ∀ y, ‖f y - f z‖ ≤ C * ‖y - z‖) + (hnear : ∀ ε : ℝ, 0 < ε → ∀ᶠ y in 𝓝 x, + ∃ z ∈ S, dist z y ≤ ε * dist y x) + (hf : HasFDerivWithinAt f f' S x) : HasFDerivAt f f' x := by + rw [hasFDerivAt_iff_isLittleO] + apply IsLittleO.of_bound + intro ε hε + let η := min 1 (ε / (2 * (C + ‖f'‖ + 1))) + have hden : 0 < 2 * (C + ‖f'‖ + 1) := by positivity + have hη : 0 < η := lt_min zero_lt_one (div_pos hε hden) + have hη1 : η ≤ 1 := min_le_left _ _ + have hsmall : (C + ‖f'‖) * η ≤ ε / 2 := by + have hh := (le_div_iff₀ hden).mp (min_le_right 1 (ε / (2 * (C + ‖f'‖ + 1)))) + nlinarith only [hh, hη] + have hlin := hf.isLittleO.def (show 0 < ε / 4 by positivity) + obtain ⟨r, hr, hrlin⟩ := Metric.mem_nhdsWithin_iff.mp hlin + filter_upwards [hnear η hη, Metric.ball_mem_nhds x (show 0 < r / 2 by positivity)] with y hy hyr + obtain ⟨z, hzS, hzy⟩ := hy + have hyz : ‖y - z‖ ≤ η * ‖y - x‖ := by + simpa only [dist_eq_norm, norm_sub_rev] using hzy + have hzx : ‖z - x‖ ≤ 2 * ‖y - x‖ := by + have hh := dist_triangle z y x + simp only [dist_eq_norm] at hh + have hzy' : ‖z - y‖ ≤ ‖y - x‖ := by + have hzyη : ‖z - y‖ ≤ η * ‖y - x‖ := by + rw [norm_sub_rev] + exact hyz + exact hzyη.trans (mul_le_of_le_one_left (norm_nonneg _) hη1) + linarith only [hh, hzy'] + have hzr : dist z x < r := by + rw [Metric.mem_ball, dist_eq_norm] at hyr + rw [dist_eq_norm] + linarith only [hzx, hyr] + have hzlin := hrlin ⟨hzr, hzS⟩ + have hdecomp : f y - f x - f' (y - x) = + (f y - f z - f' (y - z)) + (f z - f x - f' (z - x)) := by + rw [show y - x = (y - z) + (z - x) by abel, map_add] + ring + calc + ‖f y - f x - f' (y - x)‖ ≤ + ‖f y - f z‖ + ‖f' (y - z)‖ + ‖f z - f x - f' (z - x)‖ := by + rw [hdecomp] + exact (norm_add_le _ _).trans (add_le_add_left (norm_sub_le _ _) _) + _ ≤ C * ‖y - z‖ + ‖f'‖ * ‖y - z‖ + (ε / 4) * ‖z - x‖ := by + gcongr + · exact hLip z hzS y + · exact f'.le_opNorm _ + · exact hzlin + _ ≤ (C + ‖f'‖) * (η * ‖y - x‖) + (ε / 4) * (2 * ‖y - x‖) := by + rw [← add_mul] + gcongr + _ ≤ ε * ‖y - x‖ := by + nlinarith only [mul_le_mul_of_nonneg_right hsmall (norm_nonneg (y - x))] + +theorem ae_differentiable_of_pointwise_lipschitz_pieces {f : Point → ℝ} + (S : ℕ → Set Point) (hS : ∀ n, MeasurableSet (S n)) + (hLip : ∀ n, ∀ z ∈ S n, ∀ y, ‖f y - f z‖ ≤ (n : ℝ) * ‖y - z‖) + (hcover : ∀ᵐ x ∂(volume : Measure Point), ∃ n, x ∈ S n) : + ∀ᵐ x ∂(volume : Measure Point), DifferentiableAt ℝ f x := by + have hd : ∀ n, ∀ᵐ x ∂(volume : Measure Point), x ∈ S n → DifferentiableAt ℝ f x := by + intro n + have hl : LipschitzOnWith (n : ℝ≥0) f (S n) := by + apply LipschitzOnWith.of_dist_le_mul + intro x hx y hy + simpa only [dist_eq_norm, NNReal.coe_natCast] using hLip n y hy x + filter_upwards [hl.ae_differentiableWithinAt_of_mem, ae_near_set (S n) (hS n)] with x hx hn hxs + obtain ⟨f', hf'⟩ := hx hxs + exact (hasFDerivAt_of_within_near_set (by positivity) (hLip n) (hn hxs) hf').differentiableAt + filter_upwards [ae_all_iff.mpr hd, hcover] with x hx hc + obtain ⟨n, hn⟩ := hc + exact hx n hn + +def slopePiece (f : Point → ℝ) (m : ℕ) : Set Point := + {x | ∀ q : ℚ, 0 < q → + f (x + ((q : ℝ), (q : ℝ))) - f (x - ((q : ℝ), (q : ℝ))) ≤ m * (q : ℝ)} + +theorem measurableSet_slopePiece {f : Point → ℝ} (hf : Measurable f) (m : ℕ) : + MeasurableSet (slopePiece f m) := by + simp only [slopePiece, ofPred_forall] + apply MeasurableSet.iInter + intro q + apply MeasurableSet.iInter + intro _ + exact measurableSet_le ((hf.comp (measurable_id.add_const _)).sub + (hf.comp (measurable_id.sub_const _))) measurable_const + +theorem monotone_chord_bound {f : Point → ℝ} (hf : Monotone f) + (x y : Point) (q : ℝ) (hq : ‖y - x‖ ≤ q) : + ‖f y - f x‖ ≤ f (x + (q, q)) - f (x - (q, q)) := by + have hq0 : 0 ≤ q := (norm_nonneg _).trans hq + have hxy := norm_prod_le_iff.mp hq + change |y.1 - x.1| ≤ q ∧ |y.2 - x.2| ≤ q at hxy + rw [abs_le, abs_le] at hxy + have hlow : x - (q, q) ≤ y := by + constructor <;> dsimp <;> linarith only [hxy.1.1, hxy.2.1] + have hup : y ≤ x + (q, q) := by + constructor <;> dsimp <;> linarith only [hxy.1.2, hxy.2.2] + have hlowx : x - (q, q) ≤ x := by constructor <;> dsimp <;> linarith + have hupx : x ≤ x + (q, q) := by constructor <;> dsimp <;> linarith + rw [Real.norm_eq_abs, abs_le] + constructor <;> linarith only [hf hlow, hf hup, hf hlowx, hf hupx] + +theorem slopePiece_bound {f : Point → ℝ} (hf : Monotone f) (m : ℕ) + {x : Point} (hx : x ∈ slopePiece f m) (y : Point) : + ‖f y - f x‖ ≤ (m : ℝ) * ‖y - x‖ := by + apply le_of_forall_pos_le_add + intro ε hε + have hm : 0 < (m : ℝ) + 1 := by positivity + obtain ⟨q, hq, hq'⟩ := exists_rat_btwn + (show ‖y - x‖ < ‖y - x‖ + ε / (m + 1 : ℝ) by linarith only [div_pos hε hm]) + have hq0 : 0 < q := by exact_mod_cast (lt_of_le_of_lt (norm_nonneg _) hq) + have hh := (monotone_chord_bound hf x y q hq.le).trans (hx q hq0) + have hq'' : (q : ℝ) - ‖y - x‖ < ε / (m + 1 : ℝ) := by linarith only [hq'] + have hmul := (lt_div_iff₀ hm).mp hq'' + nlinarith only [hh, hmul, hq] + +theorem mem_slopePiece_of_diagonal_differentiable {f : Point → ℝ} {B : ℝ} + (hb : ∀ x, ‖f x‖ ≤ B) {x : Point} + (hd : DifferentiableAt ℝ (fun t : ℝ => f (x + (t, t))) 0) : + ∃ m, x ∈ slopePiece f m := by + obtain ⟨C, hC, hc⟩ := hd.hasFDerivAt.isBigO_sub.exists_pos + obtain ⟨δ, hδ, hδC⟩ := Metric.eventually_nhds_iff.mp hc.bound + obtain ⟨m, hm⟩ := exists_nat_ge (max (2 * C) (2 * B / δ)) + have hmC := (le_max_left (2 * C) (2 * B / δ)).trans hm + have hmB := (le_max_right (2 * C) (2 * B / δ)).trans hm + refine ⟨m, ?_⟩ + intro q hq + have hq0 : 0 < (q : ℝ) := by exact_mod_cast hq + by_cases hqd : (q : ℝ) < δ + · have hp := hδC (y := (q : ℝ)) (by simpa only [dist_zero_right, Real.norm_eq_abs, abs_neg, abs_of_pos hq0] using hqd) + have hn := hδC (y := -(q : ℝ)) (by simpa only [dist_zero_right, Real.norm_eq_abs, abs_neg, abs_of_pos hq0] using hqd) + simp only [sub_zero, Real.norm_eq_abs, abs_of_pos hq0, abs_neg] at hp hn + have he : x + (-(q : ℝ), -(q : ℝ)) = x - ((q : ℝ), (q : ℝ)) := by ext <;> simp [sub_eq_add_neg] + rw [he] at hn + have hpu := (abs_le.mp hp).2 + have hnl := (abs_le.mp hn).1 + nlinarith only [hpu, hnl, mul_le_mul_of_nonneg_right hmC hq0.le] + · have hb1 := (abs_le.mp (show |f (x + ((q : ℝ), (q : ℝ)))| ≤ B by simpa using hb _)).2 + have hb2 := (abs_le.mp (show |f (x - ((q : ℝ), (q : ℝ)))| ≤ B by simpa using hb _)).1 + have hB := (div_le_iff₀ hδ).mp hmB + have hmul := mul_le_mul_of_nonneg_left (le_of_not_gt hqd) (show 0 ≤ (m : ℝ) by positivity) + nlinarith only [hb1, hb2, hB, hmul] + +theorem bounded_monotone_ae_differentiable {f : Point → ℝ} (hf : Monotone f) + (hfmeas : Measurable f) {B : ℝ} (hb : ∀ x, ‖f x‖ ≤ B) : + ∀ᵐ x ∂(volume : Measure Point), DifferentiableAt ℝ f x := by + apply ae_differentiable_of_pointwise_lipschitz_pieces (slopePiece f) + (measurableSet_slopePiece hfmeas) (fun n z hz y => slopePiece_bound hf n hz y) + let L : ℝ →ₗ[ℝ] Point := (LinearMap.id : ℝ →ₗ[ℝ] ℝ).prod LinearMap.id + have hS : MeasurableSet {x | ∃ n, x ∈ slopePiece f n} := by + simpa only [ofPred_exists, Set.ofPred_mem_eq] using + MeasurableSet.iUnion (measurableSet_slopePiece hfmeas) + apply ae_mem_of_ae_add_linearMap_mem L volume volume hS + intro p + have hg : Monotone (fun t : ℝ => f (p + (t, t))) := by + intro s t hst + apply hf + constructor <;> dsimp <;> linarith only [hst] + filter_upwards [hg.ae_differentiableAt] with s hs + apply mem_slopePiece_of_diagonal_differentiable hb + have hs' : DifferentiableAt ℝ (fun t => f (p + (t, t))) (s + (0 : ℝ)) := by simpa using hs + have hh := hs'.comp 0 ((differentiableAt_id : DifferentiableAt ℝ (fun t : ℝ => t) 0).const_add s) + have he : (fun t : ℝ => f (p + L s + (t, t))) = + (fun t : ℝ => f (p + (t, t))) ∘ (fun t : ℝ => s + t) := by + funext t + congr 1 + ext <;> simp [L] <;> ring + rw [he] + exact hh + +def clampPoint (a b x : Point) : Point := + (max a.1 (min b.1 x.1), max a.2 (min b.2 x.2)) + +lemma clampPoint_mem {a b : Point} (hab : a ≤ b) (x : Point) : + clampPoint a b x ∈ Icc a b := by + constructor + · exact ⟨le_max_left _ _, le_max_left _ _⟩ + · exact ⟨max_le hab.1 (min_le_left _ _), max_le hab.2 (min_le_left _ _)⟩ + +lemma clampPoint_eq {a b x : Point} (hx : x ∈ Icc a b) : clampPoint a b x = x := by + ext <;> simp only [clampPoint, min_eq_right, hx.2.1, hx.2.2, + max_eq_right, hx.1.1, hx.1.2] + +lemma clampPoint_monotone (a b : Point) : Monotone (clampPoint a b) := by + intro x y hxy + exact ⟨max_le_max le_rfl (min_le_min le_rfl hxy.1), + max_le_max le_rfl (min_le_min le_rfl hxy.2)⟩ + +lemma clampPoint_continuous (a b : Point) : Continuous (clampPoint a b) := by + exact (continuous_const.max (continuous_const.min continuous_fst)).prodMk + (continuous_const.max (continuous_const.min continuous_snd)) + +theorem bounded_monotoneOn_Icc_ae_differentiable {f : Point → ℝ} {a b : Point} + (hab : a ≤ b) (hf : MonotoneOn f (Icc a b)) (hfmeas : Measurable f) + {B : ℝ} (hb : ∀ x ∈ Icc a b, ‖f x‖ ≤ B) : + ∀ᵐ x ∂(volume : Measure Point), x ∈ interior (Icc a b) → DifferentiableAt ℝ f x := by + let g := fun x => f (clampPoint a b x) + have hg : Monotone g := fun x y hxy => hf (clampPoint_mem hab x) + (clampPoint_mem hab y) (clampPoint_monotone a b hxy) + have hgm : Measurable g := hfmeas.comp (clampPoint_continuous a b).measurable + filter_upwards [bounded_monotone_ae_differentiable hg hgm + (fun x => hb _ (clampPoint_mem hab x))] with x hx hxi + apply hx.congr_of_eventuallyEq + filter_upwards [mem_interior_iff_mem_nhds.mp hxi] with y hy + exact congrArg f (clampPoint_eq hy).symm + +theorem bounded_monotoneOn_rectangle_ae_differentiable {f : Point → ℝ} {a b : Point} + (hf : MonotoneOn f (Ioo a.1 b.1 ×ˢ Ioo a.2 b.2)) (hfmeas : Measurable f) + {B : ℝ} (hb : ∀ x ∈ Ioo a.1 b.1 ×ˢ Ioo a.2 b.2, ‖f x‖ ≤ B) : + ∀ᵐ x ∂(volume : Measure Point), + x ∈ Ioo a.1 b.1 ×ˢ Ioo a.2 b.2 → DifferentiableAt ℝ f x := by + let castPoint : ℚ × ℚ → Point := fun q => ((q.1 : ℝ), (q.2 : ℝ)) + have hall : ∀ q r : ℚ × ℚ, ∀ᵐ x ∂(volume : Measure Point), + Icc (castPoint q) (castPoint r) ⊆ Ioo a.1 b.1 ×ˢ Ioo a.2 b.2 → + x ∈ interior (Icc (castPoint q) (castPoint r)) → DifferentiableAt ℝ f x := by + intro q r + by_cases hqr : castPoint q ≤ castPoint r + · by_cases hsub : Icc (castPoint q) (castPoint r) ⊆ Ioo a.1 b.1 ×ˢ Ioo a.2 b.2 + · filter_upwards [bounded_monotoneOn_Icc_ae_differentiable hqr (hf.mono hsub) + hfmeas (fun x hx => hb x (hsub hx))] with x hx _ hi + exact hx hi + · exact Filter.Eventually.of_forall (fun _ h => (hsub h).elim) + · have hempty : Icc (castPoint q) (castPoint r) = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro x hx + exact hqr (hx.1.trans hx.2) + simp only [hempty, interior_empty, mem_empty_iff_false, IsEmpty.forall_iff, + implies_true, Filter.eventually_true] + filter_upwards [ae_all_iff.mpr (fun q => ae_all_iff.mpr (hall q))] with x hx hxi + obtain ⟨q₁, haq₁, hq₁x⟩ := exists_rat_btwn hxi.1.1 + obtain ⟨r₁, hxr₁, hr₁b⟩ := exists_rat_btwn hxi.1.2 + obtain ⟨q₂, haq₂, hq₂x⟩ := exists_rat_btwn hxi.2.1 + obtain ⟨r₂, hxr₂, hr₂b⟩ := exists_rat_btwn hxi.2.2 + apply hx (q₁, q₂) (r₁, r₂) + · intro y hy + exact ⟨⟨haq₁.trans_le hy.1.1, hy.2.1.trans_lt hr₁b⟩, + ⟨haq₂.trans_le hy.1.2, hy.2.2.trans_lt hr₂b⟩⟩ + · rw [Icc_prod_eq, interior_prod_eq, interior_Icc, interior_Icc] + exact ⟨⟨hq₁x, hxr₁⟩, ⟨hq₂x, hxr₂⟩⟩ + +theorem ae_differentiable_linear_change (A : Point ≃L[ℝ] Point) (f : Point → ℝ) + (U : Set Point) + (hd : ∀ᵐ x ∂(volume : Measure Point), x ∈ U → DifferentiableAt ℝ (f ∘ A) x) : + ∀ᵐ y ∂(volume : Measure Point), A.symm y ∈ U → DifferentiableAt ℝ f y := by + have hA : Measure.QuasiMeasurePreserving A.symm volume volume := + Measure.LinearMap.quasiMeasurePreserving volume A.symm.toLinearEquiv.toLinearMap + A.symm.toLinearEquiv.isUnit_det'.ne_zero + filter_upwards [hA.ae hd] with y hy hyU + have hh := (hy hyU).comp y (A.symm.differentiable y) + simpa only [Function.comp_def, A.apply_symm_apply] using hh + +end Calculus + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/ChainDrawing.lean b/lean/OAI/Combinatorics/HalvingLines/ChainDrawing.lean new file mode 100644 index 0000000000000000000000000000000000000000..37f7c2b4a4018387abdb5626d9d8d02ed4a428ff --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/ChainDrawing.lean @@ -0,0 +1,426 @@ +import OAI.Combinatorics.HalvingLines.Chains + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Batches +open PlaneGraph +variable {n R k a : ℕ} {P : Fin n → Point} + +noncomputable def System.flip (S : @System n R k a P) : + @System n R (n-k) a (fun v => -P v) where + slope := S.slope + increasing := S.increasing + marks b := (S.marks b)ᶜ + card_marks b := by + classical + rw [Finset.card_compl, S.card_marks, Fintype.card_fin] + separates b := by + classical + intro i hi j hj + have hi' := Finset.mem_compl.mp hi + have hj' : j ∈ S.marks b := by simpa using hj + have h := S.separates b j hj' i hi' + simp only [Sweep.projection, Prod.fst_neg, Prod.snd_neg] at * + linarith + distance b := by + classical + have he : (S.marks b.castSucc)ᶜ \ (S.marks b.succ)ᶜ = S.gain b := by + ext u + simp [System.gain, and_comm] + rw [he, S.card_gain] + +@[simp] lemma System.flip_loss (S : @System n R k a P) (b : Fin R) : + S.flip.loss b = S.gain b := by + classical + ext u + simp [System.loss, System.gain, System.flip, and_comm] +@[simp] lemma System.flip_gain (S : @System n R k a P) (b : Fin R) : + S.flip.gain b = S.loss b := by + classical + ext u + simp [System.loss, System.gain, System.flip, and_comm] + +lemma System.flip_edge (S : @System n R k a P) (e : Fin n × Fin n) : + e.swap ∈ S.flip.edges ↔ e ∈ S.edges := by + rw [S.flip.mem_edges, S.mem_edges] + simp only [Prod.fst_swap, Prod.snd_swap, System.flip_loss, System.flip_gain, and_comm] + +lemma System.flip_vertices (S : @System n R k a P) : S.flip.vertices = S.vertices := by + classical + ext u + simp only [System.vertices, Finset.mem_union, Finset.mem_image] + constructor + · rintro (⟨e,he,hu⟩ | ⟨e,he,hu⟩) + · exact Or.inr ⟨e.swap, (S.flip_edge e.swap).mp (by simpa using he), hu⟩ + · exact Or.inl ⟨e.swap, (S.flip_edge e.swap).mp (by simpa using he), hu⟩ + · rintro (⟨e,he,hu⟩ | ⟨e,he,hu⟩) + · exact Or.inr ⟨e.swap, (S.flip_edge e).mpr he, hu⟩ + · exact Or.inl ⟨e.swap, (S.flip_edge e).mpr he, hu⟩ + +noncomputable def System.concaveCover (S : @System n R k a P) [NeZero n] [NeZero a] : + ConcaveCover S.drawing (Fin a × Fin n) where + owner e := S.flip.convexOwner e.swap + support e he f hf ho z hz := by + have he' : e.swap ∈ S.flip.drawing.edges := (S.flip_edge e).mpr he + have hf' : f.swap ∈ S.flip.drawing.edges := (S.flip_edge f).mpr hf + have hz' : -z ∈ segment ℝ (-P f.2) (-P f.1) := by + rw [segment_eq_image] at hz ⊢ + obtain ⟨u,hu,hz⟩ := hz + refine ⟨1-u, ⟨by linarith only [hu.2], by linarith only [hu.1]⟩, ?_⟩ + rw [← hz] + module + have h := S.flip.convexCover.support e.swap he' f.swap hf' ho (-z) hz' + change height (-P e.2) (-P e.1) (-z.1) ≤ -z.2 at h + rw [height_neg_reverse _ _ (S.drawing.right e he).ne] at h + exact neg_le_neg_iff.mp h + +lemma System.concaveOwner_mem (S : @System n R k a P) [NeZero n] [NeZero a] + {e : Fin n × Fin n} (he : e ∈ S.edges) : + S.concaveCover.owner e ∈ Finset.univ ×ˢ S.vertices := by + have h := S.flip.convexOwner_mem ((S.flip_edge e).mpr he) + rwa [S.flip_vertices] at h + +theorem System.crossing_cap (S : @System n R k a P) [NeZero n] [NeZero a] + (hP : Position P) (hx : Function.Injective (fun v => (P v).1)) + (hD : S.drawing.NoMultiple) : + S.drawing.crossings.card ≤ 2 * a^2 * S.vertices.card^2 := by + have h := S.convexCover.crossing_bound_finset S.concaveCover hP hx hD + (Finset.univ ×ˢ S.vertices) (Finset.univ ×ˢ S.vertices) + (fun _ he => S.convexOwner_mem he) (fun _ he => S.concaveOwner_mem he) + simpa [Finset.card_product, pow_two, mul_assoc, mul_left_comm, mul_comm] using h + +end PlanarHalving.Batches + +namespace PlanarHalving.PlaneGraph +variable {n : ℕ} {P : Fin n → Point} + +def sortEdge (e : Fin n × Fin n) : Fin n × Fin n := + if e.1 < e.2 then e else e.swap + +lemma sortEdge_order (e : Fin n × Fin n) (he : e.1 ≠ e.2) : + (sortEdge e).1 < (sortEdge e).2 := by + unfold sortEdge + split_ifs with h + · exact h + · exact lt_of_le_of_ne (le_of_not_gt h) he.symm + +lemma sortEdge_cases (e : Fin n × Fin n) : sortEdge e = e ∨ sortEdge e = e.swap := by + unfold sortEdge + split_ifs <;> simp + +lemma sortEdge_coincide {e f : Fin n × Fin n} (he : sortEdge e = sortEdge f) : + e = f ∨ e = f.swap := by + rcases sortEdge_cases e with hh | hh <;> rcases sortEdge_cases f with hg | hg <;> rw [hh,hg] at he + · exact Or.inl he + · exact Or.inr he + · exact Or.inr (by simpa using congrArg Prod.swap he) + · exact Or.inl (Prod.swap_injective he) + +lemma Drawing.sortEdge_injective (D : Drawing P) : + (↑D.edges : Set (Fin n × Fin n)).InjOn (@sortEdge n) := by + intro e he f hf h + rcases sortEdge_coincide h with h | h + · exact h + · have hx := D.right e he + have hy := D.right f hf + rw [h] at hx + exact False.elim (lt_asymm hx hy) + +lemma openSegment_sortEdge (e : Fin n × Fin n) : + openSegment ℝ (P (sortEdge e).1) (P (sortEdge e).2) = + openSegment ℝ (P e.1) (P e.2) := by + rcases sortEdge_cases e with h | h + · rw [h] + · rw [h] + exact openSegment_symm ℝ _ _ + +lemma segment_sortEdge (e : Fin n × Fin n) : + segment ℝ (P (sortEdge e).1) (P (sortEdge e).2) = + segment ℝ (P e.1) (P e.2) := by + rcases sortEdge_cases e with h | h + · rw [h] + · rw [h] + exact segment_symm ℝ _ _ + +lemma Drawing.noMultiple_of_generic (D : Drawing P) (hP : Generic P) : D.NoMultiple := by + intro e he f hf hef g hg hge hgf z hze hzf hzg + have ho (i : Fin n × Fin n) (hi : i ∈ D.edges) : (sortEdge i).1 < (sortEdge i).2 := + sortEdge_order i (fun h => (D.right i hi).ne (congrArg (fun v => (P v).1) h)) + have hne {i j : Fin n × Fin n} (hi : i ∈ D.edges) (hj : j ∈ D.edges) (hn : i ≠ j) : + sortEdge i ≠ sortEdge j := fun h => hn (D.sortEdge_injective hi hj h) + apply hP.2.2.2 _ _ _ _ _ _ (ho e he) (ho f hf) (ho g hg) + (hne he hf hef) (hne hg he hge) (hne hg hf hgf) z + · rwa [openSegment_sortEdge] + · rwa [openSegment_sortEdge] + · rwa [segment_sortEdge] + +lemma Generic.position (hP : Generic P) : Position P := hP.1 +lemma Generic.x_injective (hP : Generic P) : Function.Injective (fun v => (P v).1) := by + intro i j hij + by_contra hn + exact hP.2.1 i j hn hij + +end PlanarHalving.PlaneGraph + +namespace PlanarHalving.PlaneGraph +variable {V : Type*} [Fintype V] {P : V → Point} + +noncomputable def Drawing.restrictEdges (D : Drawing P) (E : Finset (V × V)) : Drawing P := by + classical + exact { + vertices := D.vertices + edges := D.edges ∩ E + right := fun e he => D.right e (Finset.mem_inter.mp he).1 + ends := fun e he => D.ends e (Finset.mem_inter.mp he).1 } + +lemma Drawing.restrict_crossings (D : Drawing P) (E : Finset (V × V)) : + (D.restrictEdges E).crossings ⊆ D.crossings := by + classical + intro w hw + simp only [Drawing.crossings, Drawing.restrictEdges, Finset.mem_filter, + Finset.mem_product, Finset.mem_inter] at hw ⊢ + exact ⟨⟨hw.1.1.1,hw.1.2.1⟩,hw.2⟩ + +end PlanarHalving.PlaneGraph + +namespace PlanarHalving.Batches +open PlaneGraph +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.vertices_le (S : @System n R k a P) : S.vertices.card ≤ n := by + exact (Finset.card_le_univ _).trans_eq (Fintype.card_fin n) + +theorem System.localized_crossing (S : @System n R k a P) [NeZero n] [NeZero a] + (hP : Generic P) (F : Finset (Fin n)) (hF : F ⊆ S.vertices) : + ((S.edges.filter fun e => e.1 ∈ F).card : ℝ)^3 ≤ + 4608 * (a : ℝ)^2 * F.card * (S.vertices.card : ℝ)^3 + + 13824 * (S.vertices.card : ℝ)^3 := by + classical + let D := S.drawing.restrictEdges (S.edges.filter fun e => e.1 ∈ F) + have hv : D.vertices = S.vertices := rfl + have he : D.edges = S.edges.filter (fun e => e.1 ∈ F) := by + ext e + simp [D, Drawing.restrictEdges, System.drawing] + have hc := D.designated_crossing hP.1 (PlaneGraph.Generic.x_injective hP) F hF (by + intro e he' + rw [he] at he' + exact Or.inl (Finset.mem_filter.mp he').2) + rw [he,hv] at hc + have hcr : (D.crossings.card : ℝ) ≤ 2 * (a : ℝ)^2 * (S.vertices.card : ℝ)^2 := by + exact_mod_cast (Finset.card_le_card (S.drawing.restrict_crossings _)).trans + (S.crossing_cap hP.1 (PlaneGraph.Generic.x_injective hP) (S.drawing.noMultiple_of_generic hP)) + apply hc.trans + calc 2304 * (F.card : ℝ) * S.vertices.card * D.crossings.card + + 13824 * (S.vertices.card : ℝ)^3 ≤ + 2304 * (F.card : ℝ) * S.vertices.card * (2 * (a : ℝ)^2 * (S.vertices.card : ℝ)^2) + + 13824 * (S.vertices.card : ℝ)^3 := by gcongr + _ = _ := by ring + +theorem System.cubed_bound (S : @System n R k a P) [NeZero n] [NeZero a] + (hP : Generic P) : + (R : ℝ)^3 * (a : ℝ)^4 ≤ 18432 * (n : ℝ)^4 := by + classical + have hc := S.localized_crossing hP S.vertices (by rfl) + have he : S.edges.filter (fun e => e.1 ∈ S.vertices) = S.edges := by + exact Finset.filter_eq_self.mpr (fun e he => (S.edge_ends he).1) + rw [he, S.card_edges] at hc + push_cast at hc + have hs : (S.vertices.card : ℝ) ≤ n := by exact_mod_cast S.vertices_le + have ha : (1 : ℝ) ≤ a := by exact_mod_cast (NeZero.one_le : 1 ≤ a) + have hn : (1 : ℝ) ≤ n := by exact_mod_cast (NeZero.one_le : 1 ≤ n) + have hs₁ : 4608 * (a : ℝ)^2 * S.vertices.card * (S.vertices.card : ℝ)^3 ≤ + 4608 * (a : ℝ)^2 * (n : ℝ)^4 := by + calc _ ≤ 4608 * (a : ℝ)^2 * n * (n : ℝ)^3 := by gcongr + _ = _ := by ring + have hs₂ : 13824 * (S.vertices.card : ℝ)^3 ≤ 13824 * (a : ℝ)^2 * (n : ℝ)^4 := by + calc _ ≤ 13824 * (n : ℝ)^3 := by gcongr + _ = 13824 * (1 : ℝ)^2 * (1 * (n : ℝ)^3) := by ring + _ ≤ 13824 * (a : ℝ)^2 * (n * (n : ℝ)^3) := by gcongr + _ = _ := by ring + have hh : (a : ℝ)^2 * ((R : ℝ)^3 * (a : ℝ)^4) ≤ + (a : ℝ)^2 * (18432 * (n : ℝ)^4) := by + nlinarith only [hc, hs₁, hs₂] + exact (mul_le_mul_iff_right₀ (by positivity : 0 < (a : ℝ)^2)).mp hh + +end PlanarHalving.Batches +namespace PlanarHalving.PlaneGraph +lemma height_of_mem_segment {p q z : Point} (hx : p.1 ≠ q.1) + (hz : z ∈ segment ℝ p q) : z.2 = height p q z.1 := by + rw [segment_eq_image] at hz + obtain ⟨t,_,rfl⟩ := hz + simp only [Prod.fst_add, Prod.snd_add, Prod.smul_fst, Prod.smul_snd, smul_eq_mul] + unfold height slope + field_simp + ring +end PlanarHalving.PlaneGraph + +namespace PlanarHalving.RankCoordinates +open Set + +noncomputable def envelope {ι : Type*} [Fintype ι] [Nonempty ι] + (m c : ι → ℝ) (x : ℝ) : ℝ := + Finset.univ.sup' Finset.univ_nonempty (fun i => m i*x+c i) + +lemma le_envelope {ι : Type*} [Fintype ι] [Nonempty ι] + (m c : ι → ℝ) (i : ι) (x : ℝ) : m i*x+c i ≤ envelope m c x := + Finset.le_sup' (fun j => m j*x+c j) (Finset.mem_univ i) + +lemma envelope_le {ι : Type*} [Fintype ι] [Nonempty ι] + (m c : ι → ℝ) (x y : ℝ) (h : ∀ i, m i*x+c i ≤ y) : envelope m c x ≤ y := + Finset.sup'_le Finset.univ_nonempty _ (fun i _ => h i) + +lemma envelope_attains {ι : Type*} [Fintype ι] [Nonempty ι] + (m c : ι → ℝ) (x : ℝ) : ∃ i, envelope m c x = m i*x+c i := by + obtain ⟨i,_,hi⟩ := Finset.exists_max_image Finset.univ (fun i => m i*x+c i) Finset.univ_nonempty + exact ⟨i, le_antisymm (envelope_le m c x _ (fun j => hi j (Finset.mem_univ j))) (le_envelope m c i x)⟩ + +lemma continuous_envelope {ι : Type*} [Fintype ι] [Nonempty ι] + (m c : ι → ℝ) : Continuous (envelope m c) := by + have hh : Continuous (Finset.univ.sup' Finset.univ_nonempty (fun i => fun x : ℝ => m i*x+c i)) := + Continuous.finset_sup' Finset.univ_nonempty (fun _ _ => by fun_prop) + convert hh using 1 + funext x + simp only [envelope, Finset.sup'_apply] + +lemma convexOn_envelope {ι : Type*} [Fintype ι] [Nonempty ι] + (m c : ι → ℝ) : ConvexOn ℝ Set.univ (envelope m c) := by + refine ⟨convex_univ, ?_⟩ + intro x _ y _ a b ha hb hab + simp only [smul_eq_mul] + apply envelope_le + intro i + have h₁ := mul_le_mul_of_nonneg_left (le_envelope m c i x) ha + have h₂ := mul_le_mul_of_nonneg_left (le_envelope m c i y) hb + calc + m i * (a*x+b*y)+c i = a*(m i*x+c i)+b*(m i*y+c i) := by + have hh := congrArg (fun t => t * c i) hab + nlinarith only [hh] + _ ≤ _ := add_le_add h₁ h₂ + +lemma envelope_slopes {ι : Type*} [Fintype ι] [Nonempty ι] + (m c : ι → ℝ) {l u : ℝ} (hm : ∀ i, l ≤ m i ∧ m i ≤ u) + {x y : ℝ} (hxy : x ≤ y) : + l*(y-x) ≤ envelope m c y - envelope m c x ∧ + envelope m c y - envelope m c x ≤ u*(y-x) := by + obtain ⟨i,hi⟩ := envelope_attains m c x + obtain ⟨j,hj⟩ := envelope_attains m c y + have h₁ := le_envelope m c i y + have h₂ := le_envelope m c j x + have h₃ := mul_le_mul_of_nonneg_right (hm i).1 (sub_nonneg.mpr hxy) + have h₄ := mul_le_mul_of_nonneg_right (hm j).2 (sub_nonneg.mpr hxy) + constructor + · rw [hi] + linarith only [h₁,h₃] + · rw [hj] + linarith only [h₂,h₄] + +end PlanarHalving.RankCoordinates + +namespace PlanarHalving.Batches +open PlaneGraph RankCoordinates +variable {R : ℕ} + +lemma ConvexPath.lower_ray (C : ConvexPath R) {l : ℝ} + (hl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → l ≤ slope (C.point b.castSucc) (C.point b.succ)) + (c : Fin (R+1)) : + (C.point 0).2 + ( (C.point c).1 - (C.point 0).1)*l ≤ (C.point c).2 := by + have h := fin_between_le (f := fun r => Sweep.projection l (C.point r)) 0 c (Fin.zero_le c) (by + intro b _ _ + rcases C.right b with he | he + · rw [he] + · have hn : C.point b.castSucc ≠ C.point b.succ := fun h => he.ne (congrArg Prod.fst h) + have hp := projection_step (C.point b.castSucc) (C.point b.succ) (t := l) he.ne + have hprod := mul_nonneg (sub_nonneg.mpr he.le) (sub_nonneg.mpr (hl b hn)) + linarith only [hp,hprod]) + unfold Sweep.projection at h + linarith only [h] + +lemma ConvexPath.upper_ray (C : ConvexPath R) {u : ℝ} + (hu : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → slope (C.point b.castSucc) (C.point b.succ) ≤ u) + (c : Fin (R+1)) : + (C.point (Fin.last R)).2 + ((C.point c).1 - (C.point (Fin.last R)).1)*u ≤ (C.point c).2 := by + have h := fin_between_le (f := fun r => -Sweep.projection u (C.point r)) c (Fin.last R) (Fin.le_last c) (by + intro b _ _ + rcases C.right b with he | he + · rw [he] + · have hn : C.point b.castSucc ≠ C.point b.succ := fun h => he.ne (congrArg Prod.fst h) + have hp := projection_step (C.point b.castSucc) (C.point b.succ) (t := u) he.ne + have hprod := mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr he.le) (sub_nonpos.mpr (hu b hn)) + linarith only [hp,hprod]) + unfold Sweep.projection at h + linarith only [h] + +noncomputable def ConvexPath.extensionSlopes (C : ConvexPath R) (l u : ℝ) : Fin R ⊕ Bool → ℝ + | .inl b => if C.point b.castSucc = C.point b.succ then l else slope (C.point b.castSucc) (C.point b.succ) + | .inr false => l + | .inr true => u + +noncomputable def ConvexPath.extensionIntercepts (C : ConvexPath R) (l u : ℝ) : Fin R ⊕ Bool → ℝ + | .inl b => if C.point b.castSucc = C.point b.succ then (C.point 0).2 - l*(C.point 0).1 + else (C.point b.castSucc).2 - slope (C.point b.castSucc) (C.point b.succ)*(C.point b.castSucc).1 + | .inr false => (C.point 0).2 - l*(C.point 0).1 + | .inr true => (C.point (Fin.last R)).2 - u*(C.point (Fin.last R)).1 + +noncomputable def ConvexPath.extension (C : ConvexPath R) (l u : ℝ) : ℝ → ℝ := + envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) + +lemma ConvexPath.extension_slopes (C : ConvexPath R) {l u : ℝ} (hlu : l ≤ u) + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) : + ∀ i, l ≤ C.extensionSlopes l u i ∧ C.extensionSlopes l u i ≤ u := by + intro i + cases i with + | inl b => + by_cases hb : C.point b.castSucc = C.point b.succ + · simp only [ConvexPath.extensionSlopes, ite_eq_left hb] + exact ⟨le_rfl,hlu⟩ + · simpa only [ConvexPath.extensionSlopes, ite_eq_right hb] using hsl b hb + | inr b => cases b <;> simp only [ConvexPath.extensionSlopes] <;> exact ⟨by order, by order⟩ + +lemma ConvexPath.extension_below_vertex (C : ConvexPath R) {l u : ℝ} + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) + (c : Fin (R+1)) : C.extension l u (C.point c).1 ≤ (C.point c).2 := by + apply envelope_le + intro i + have hl := C.lower_ray (fun b hb => (hsl b hb).1) c + have hu := C.upper_ray (fun b hb => (hsl b hb).2) c + cases i with + | inl b => + by_cases hb : C.point b.castSucc = C.point b.succ + · simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts, ite_eq_left hb] + linarith only [hl] + · simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts, ite_eq_right hb] + have hh := C.support_vertex b hb c + unfold height at hh + linarith only [hh] + | inr b => cases b <;> simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts] <;> linarith only [hl,hu] + +lemma ConvexPath.extension_edge (C : ConvexPath R) {l u : ℝ} + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) + (b : Fin R) (hb : C.point b.castSucc ≠ C.point b.succ) {z : Point} + (hz : z ∈ segment ℝ (C.point b.castSucc) (C.point b.succ)) : + C.extension l u z.1 = z.2 := by + apply le_antisymm + · rw [segment_eq_image] at hz + obtain ⟨t,ht,rfl⟩ := hz + have hc := convexOn_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) + have hh := hc.2 (Set.mem_univ (C.point b.castSucc).1) (Set.mem_univ (C.point b.succ).1) + (sub_nonneg.mpr ht.2) ht.1 (by ring : (1-t)+t=1) + have h₀ := mul_le_mul_of_nonneg_left (C.extension_below_vertex hsl b.castSucc) (sub_nonneg.mpr ht.2) + have h₁ := mul_le_mul_of_nonneg_left (C.extension_below_vertex hsl b.succ) ht.1 + simp only [Prod.fst_add, Prod.snd_add, Prod.smul_fst, Prod.smul_snd, smul_eq_mul] at * + exact hh.trans (add_le_add h₀ h₁) + · have hh := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (.inl b) z.1 + simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts, ite_eq_right hb] at hh + have hz' := height_of_mem_segment (C.right b |>.resolve_left hb).ne hz + unfold height at hz' + change z.2 ≤ envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) z.1 + linarith only [hh,hz'] + +end PlanarHalving.Batches + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Chains.lean b/lean/OAI/Combinatorics/HalvingLines/Chains.lean new file mode 100644 index 0000000000000000000000000000000000000000..59e48ad48ba7663fd79fb6ef61765125561713ce --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Chains.lean @@ -0,0 +1,352 @@ +import OAI.Combinatorics.HalvingLines.Batches + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.PlaneGraph + +variable {V : Type*} [Fintype V] {P : V → Point} + +def Drawing.NoMultiple (D : Drawing P) : Prop := + ∀ e ∈ D.edges, ∀ f ∈ D.edges, e ≠ f → ∀ g ∈ D.edges, + g ≠ e → g ≠ f → ∀ z : Point, + z ∈ openSegment ℝ (P e.1) (P e.2) → + z ∈ openSegment ℝ (P f.1) (P f.2) → + z ∉ segment ℝ (P g.1) (P g.2) + +lemma Drawing.crossing_props (D : Drawing P) (w : ↥D.crossings) : + w.val.1 ∈ D.edges ∧ w.val.2 ∈ D.edges ∧ + edgeIndex w.val.1 < edgeIndex w.val.2 ∧ Crosses P w.val.1 w.val.2 := by + classical + have h := Finset.mem_filter.mp w.property + exact ⟨(Finset.mem_product.mp h.1).1, (Finset.mem_product.mp h.1).2, h.2⟩ + +noncomputable def Drawing.crossingPoint (D : Drawing P) (w : ↥D.crossings) : Point := + (Set.not_disjoint_iff.mp (D.crossing_props w).2.2.2).choose + +lemma Drawing.crossingPoint_mem (D : Drawing P) (w : ↥D.crossings) : + D.crossingPoint w ∈ openSegment ℝ (P w.val.1.1) (P w.val.1.2) ∧ + D.crossingPoint w ∈ openSegment ℝ (P w.val.2.1) (P w.val.2.2) := + (Set.not_disjoint_iff.mp (D.crossing_props w).2.2.2).choose_spec + +lemma Drawing.crossingPoint_injective (D : Drawing P) (hD : D.NoMultiple) : + Function.Injective D.crossingPoint := by + intro w v hpoint + have hw := D.crossing_props w + have hv := D.crossing_props v + have hwm := D.crossingPoint_mem w + have hvm := D.crossingPoint_mem v + have hne : w.val.1 ≠ w.val.2 := fun h => hw.2.2.1.ne (congrArg edgeIndex h) + have he (g : V × V) (hg : g ∈ D.edges) + (hgm : D.crossingPoint w ∈ segment ℝ (P g.1) (P g.2)) : + g = w.val.1 ∨ g = w.val.2 := by + by_contra hh + push Not at hh + exact hD _ hw.1 _ hw.2.1 hne _ hg hh.1 hh.2 _ hwm.1 hwm.2 hgm + have h₁ := he v.val.1 hv.1 (by rw [hpoint]; exact openSegment_subset_segment ℝ _ _ hvm.1) + have h₂ := he v.val.2 hv.2.1 (by rw [hpoint]; exact openSegment_subset_segment ℝ _ _ hvm.2) + apply Subtype.ext + rcases h₁ with h₁ | h₁ <;> rcases h₂ with h₂ | h₂ + · have := hv.2.2.1 + rw [h₁, h₂] at this + exact False.elim (lt_irrefl _ this) + · exact Prod.ext h₁.symm h₂.symm + · have := hv.2.2.1 + rw [h₁, h₂] at this + exact False.elim (lt_asymm hw.2.2.1 this) + · have := hv.2.2.1 + rw [h₁, h₂] at this + exact False.elim (lt_irrefl _ this) + +lemma Drawing.crossing_slopes_ne (D : Drawing P) (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (w : ↥D.crossings) : + slope (P w.val.1.1) (P w.val.1.2) ≠ slope (P w.val.2.1) (P w.val.2.2) := by + have hw := D.crossing_props w + have he := D.crossing_endpoints hP hx hw.1 hw.2.1 + (fun h => hw.2.2.1.ne (congrArg edgeIndex h)) hw.2.2.2 + have hm := D.crossingPoint_mem w + have h₁ := (height_of_mem_openSegment (D.right _ hw.1).ne hm.1).2 + have h₂ := (height_of_mem_openSegment (D.right _ hw.2.1).ne hm.2).2 + intro hs + have h₃ := height_right (P w.val.1.1) (P w.val.1.2) (D.right _ hw.1).ne + apply hP.2 w.val.1.1 w.val.1.2 w.val.2.1 he.1 he.2.2.2.2.1 he.2.2.1 + unfold height at h₁ h₂ h₃ + rw [← hs] at h₂ + unfold orient + have ha : (P w.val.1.2).2 - (P w.val.1.1).2 = + ((P w.val.1.2).1 - (P w.val.1.1).1) * slope (P w.val.1.1) (P w.val.1.2) := by linarith only [h₃] + have hb : (P w.val.2.1).2 - (P w.val.1.1).2 = + ((P w.val.2.1).1 - (P w.val.1.1).1) * slope (P w.val.1.1) (P w.val.1.2) := by linarith only [h₁, h₂] + rw [ha, hb] + ring + +structure ConvexCover (D : Drawing P) (I : Type*) where + owner : V × V → I + support : ∀ e ∈ D.edges, ∀ f ∈ D.edges, owner e = owner f → + ∀ z ∈ segment ℝ (P f.1) (P f.2), height (P e.1) (P e.2) z.1 ≤ z.2 + +structure ConcaveCover (D : Drawing P) (I : Type*) where + owner : V × V → I + support : ∀ e ∈ D.edges, ∀ f ∈ D.edges, owner e = owner f → + ∀ z ∈ segment ℝ (P f.1) (P f.2), z.2 ≤ height (P e.1) (P e.2) z.1 + +variable {I J : Type*} {D : Drawing P} + +lemma height_difference (p q r s : Point) (x y : ℝ) : + height p q x - height r s x = height p q y - height r s y + + (x-y) * (slope p q - slope r s) := by unfold height; ring + +lemma ConvexCover.crossing_support (C : ConvexCover D I) (A : ConcaveCover D J) + (w v : ↥D.crossings) (hc : C.owner w.val.1 = C.owner v.val.1) + (ha : A.owner w.val.2 = A.owner v.val.2) : + ((D.crossingPoint v).1 - (D.crossingPoint w).1) * + (slope (P w.val.1.1) (P w.val.1.2) - slope (P w.val.2.1) (P w.val.2.2)) ≤ 0 := by + have hw := D.crossing_props w + have hv := D.crossing_props v + have hvm := D.crossingPoint_mem v + have hwm := D.crossingPoint_mem w + have h₀ := C.support _ hw.1 _ hv.1 hc _ (openSegment_subset_segment ℝ _ _ hvm.1) + have h₁ := A.support _ hw.2.1 _ hv.2.1 ha _ (openSegment_subset_segment ℝ _ _ hvm.2) + have h₂ := (height_of_mem_openSegment (D.right _ hw.1).ne hwm.1).2 + have h₃ := (height_of_mem_openSegment (D.right _ hw.2.1).ne hwm.2).2 + have h₄ := height_difference (P w.val.1.1) (P w.val.1.2) (P w.val.2.1) (P w.val.2.2) + (D.crossingPoint v).1 (D.crossingPoint w).1 + linarith only [h₀, h₁, h₂, h₃, h₄] + +lemma ConvexCover.crossing_eq_of_x (C : ConvexCover D I) (hD : D.NoMultiple) + (w v : ↥D.crossings) (hc : C.owner w.val.1 = C.owner v.val.1) + (h : (D.crossingPoint w).1 = (D.crossingPoint v).1) : w = v := by + have hw := D.crossing_props w + have hv := D.crossing_props v + have hvm := D.crossingPoint_mem v + have hwm := D.crossingPoint_mem w + have h₀ := C.support _ hw.1 _ hv.1 hc _ (openSegment_subset_segment ℝ _ _ hvm.1) + have h₁ := C.support _ hv.1 _ hw.1 hc.symm _ (openSegment_subset_segment ℝ _ _ hwm.1) + have h₂ := (height_of_mem_openSegment (D.right _ hw.1).ne hwm.1).2 + have h₃ := (height_of_mem_openSegment (D.right _ hv.1).ne hvm.1).2 + apply D.crossingPoint_injective hD + apply Prod.ext h + rw [h] at h₁ h₂ + linarith only [h₀, h₁, h₂, h₃] + +lemma ConvexCover.crossing_sign_injective (C : ConvexCover D I) (A : ConcaveCover D J) + (hP : Position P) (hx : Function.Injective (fun v => (P v).1)) (hD : D.NoMultiple) : + Function.Injective (fun w : ↥D.crossings => + (C.owner w.val.1, A.owner w.val.2, + decide (slope (P w.val.1.1) (P w.val.1.2) < slope (P w.val.2.1) (P w.val.2.2)))) := by + intro w v hh + have hc := congrArg Prod.fst hh + have ha := congrArg (fun p => p.2.1) hh + have hs : (slope (P w.val.1.1) (P w.val.1.2) < slope (P w.val.2.1) (P w.val.2.2)) ↔ + (slope (P v.val.1.1) (P v.val.1.2) < slope (P v.val.2.1) (P v.val.2.2)) := + by simpa only [decide_eq_decide] using (congrArg (fun p => p.2.2) hh) + have hw := C.crossing_support A w v hc ha + have hv := C.crossing_support A v w hc.symm ha.symm + apply C.crossing_eq_of_x hD w v hc + have hnw := D.crossing_slopes_ne hP hx w + have hnv := D.crossing_slopes_ne hP hx v + by_cases h : slope (P w.val.1.1) (P w.val.1.2) < slope (P w.val.2.1) (P w.val.2.2) + · have h' := hs.mp h + have hxw : (D.crossingPoint w).1 ≤ (D.crossingPoint v).1 := by nlinarith only [hw, h] + have hxv : (D.crossingPoint v).1 ≤ (D.crossingPoint w).1 := by nlinarith only [hv, h'] + exact le_antisymm hxw hxv + · have h' := mt hs.mpr h + have hnw' := lt_of_le_of_ne (le_of_not_gt h) hnw.symm + have hnv' := lt_of_le_of_ne (le_of_not_gt h') hnv.symm + have hxw : (D.crossingPoint w).1 ≤ (D.crossingPoint v).1 := by nlinarith only [hv, hnv'] + have hxv : (D.crossingPoint v).1 ≤ (D.crossingPoint w).1 := by nlinarith only [hw, hnw'] + exact le_antisymm hxw hxv + +theorem ConvexCover.crossing_bound [Fintype I] [Fintype J] + (C : ConvexCover D I) (A : ConcaveCover D J) (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (hD : D.NoMultiple) : + D.crossings.card ≤ 2 * Fintype.card I * Fintype.card J := by + classical + have h := Fintype.card_le_of_injective _ (C.crossing_sign_injective A hP hx hD) + simpa [Fintype.card_prod, Fintype.card_bool, mul_comm, mul_left_comm, mul_assoc] using h + +end PlanarHalving.PlaneGraph + +namespace PlanarHalving.Batches +open PlaneGraph + +variable {n R k a : ℕ} {P : Fin n → Point} + +noncomputable def System.edges (S : @System n R k a P) : Finset (Fin n × Fin n) := + Finset.univ.biUnion (fun b => S.loss b ×ˢ S.gain b) + +lemma System.mem_edges (S : @System n R k a P) (e : Fin n × Fin n) : + e ∈ S.edges ↔ ∃ b : Fin R, e.1 ∈ S.loss b ∧ e.2 ∈ S.gain b := by + simp only [System.edges, Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_product] + +lemma System.batch_unique (S : @System n R k a P) {e : Fin n × Fin n} + {b c : Fin R} (hb : e.1 ∈ S.loss b ∧ e.2 ∈ S.gain b) + (hc : e.1 ∈ S.loss c ∧ e.2 ∈ S.gain c) : b = c := by + have h₁ := S.edge_slope b hb.1 hb.2 + have h₂ := S.edge_slope c hc.1 hc.2 + by_contra h + rcases lt_or_gt_of_ne h with hbc | hcb + · have ht : b.succ ≤ c.castSucc := by + simp only [Fin.le_def, Fin.lt_def, Fin.val_succ, Fin.val_castSucc] at * + omega + have := S.increasing.monotone ht + linarith only [h₁.2, h₂.1, this] + · have ht : c.succ ≤ b.castSucc := by + simp only [Fin.le_def, Fin.lt_def, Fin.val_succ, Fin.val_castSucc] at * + omega + have := S.increasing.monotone ht + linarith only [h₂.2, h₁.1, this] + +lemma System.card_edges (S : @System n R k a P) : S.edges.card = R * a ^ 2 := by + classical + rw [System.edges, Finset.card_biUnion] + · simp [Finset.card_product, S.card_loss, S.card_gain, pow_two] + · intro b _ c _ hbc + apply Finset.disjoint_left.mpr + intro e he hf + exact hbc (S.batch_unique (Finset.mem_product.mp he) (Finset.mem_product.mp hf)) + +noncomputable def System.vertices (S : @System n R k a P) : Finset (Fin n) := + S.edges.image Prod.fst ∪ S.edges.image Prod.snd + +lemma System.edge_ends (S : @System n R k a P) {e : Fin n × Fin n} (he : e ∈ S.edges) : + e.1 ∈ S.vertices ∧ e.2 ∈ S.vertices := by + exact ⟨Finset.mem_union_left _ (Finset.mem_image.mpr ⟨e,he,rfl⟩), + Finset.mem_union_right _ (Finset.mem_image.mpr ⟨e,he,rfl⟩)⟩ + +noncomputable def System.drawing (S : @System n R k a P) : Drawing P where + vertices := S.vertices + edges := S.edges + right e he := by obtain ⟨b,hb,hc⟩ := (S.mem_edges e).mp he; exact S.edge_right b hb hc + ends _ he := S.edge_ends he + +structure System.EdgeTrace (S : @System n R k a P) [NeZero a] (e : Fin n × Fin n) where + batch : Fin R + number : Fin a + token : ↥(S.marks 0) + source : (S.tokenState number batch.castSucc token : Fin n) = e.1 + target : (S.tokenState number batch.succ token : Fin n) = e.2 + loss : e.1 ∈ S.loss batch + gain : e.2 ∈ S.gain batch + +lemma System.trace_exists (S : @System n R k a P) [NeZero a] + {e : Fin n × Fin n} (he : e ∈ S.edges) : Nonempty (S.EdgeTrace e) := by + obtain ⟨b,hl,hg⟩ := (S.mem_edges e).mp he + obtain ⟨j,hj,_⟩ := matching_unique (S.lossIndex b) (S.gainIndex b) ⟨e.1,hl⟩ ⟨e.2,hg⟩ + let u : ↥(S.marks b.castSucc) := ⟨e.1, (Finset.mem_sdiff.mp hl).1⟩ + let t := (S.tokenState j b.castSucc).symm u + have hsrc : S.tokenState j b.castSucc t = u := Equiv.apply_symm_apply _ _ + refine ⟨⟨b,j,t,congrArg Subtype.val hsrc, ?_, hl,hg⟩⟩ + rw [S.tokenState_succ, hsrc] + have hn : (u : Fin n) ∉ S.marks b.succ := (Finset.mem_sdiff.mp hl).2 + change (transport _ _ (S.match j b) u : Fin n) = e.2 + rw [transport_of_not_mem (S.match j b) _ hn] + exact congrArg Subtype.val hj + +noncomputable def System.trace (S : @System n R k a P) [NeZero a] + {e : Fin n × Fin n} (he : e ∈ S.edges) : S.EdgeTrace e := + Classical.choice (S.trace_exists he) + +lemma System.token_fixed_of_outside (S : @System n R k a P) [NeZero a] + (j : Fin a) (u : ↥(S.marks 0)) (hu : u.val ∉ S.vertices) (b : Fin (R + 1)) : + (S.tokenState j b u : Fin n) = u.val := by + induction b using Fin.induction with + | zero => simp + | succ b ih => + rcases S.token_step j u b with h | ⟨hl,hg⟩ + · exact h.symm.trans ih + · have he : ((S.tokenState j b.castSucc u : Fin n), (S.tokenState j b.succ u : Fin n)) ∈ S.edges := + (S.mem_edges _).mpr ⟨b,hl,hg⟩ + have hv := (S.edge_ends he).1 + rw [ih] at hv + exact False.elim (hu hv) + +lemma System.trace_token_mem (S : @System n R k a P) [NeZero a] + {e : Fin n × Fin n} (he : e ∈ S.edges) : (S.trace he).token.val ∈ S.vertices := by + by_contra hn + have hh := S.token_fixed_of_outside (S.trace he).number (S.trace he).token hn (S.trace he).batch.castSucc + rw [(S.trace he).source] at hh + exact hn (hh ▸ (S.edge_ends he).1) + +noncomputable def System.convexOwner (S : @System n R k a P) [NeZero n] [NeZero a] + (e : Fin n × Fin n) : Fin a × Fin n := + if h : e ∈ S.edges then ((S.trace h).number, (S.trace h).token.val) else (0,0) + +lemma System.convexOwner_eq (S : @System n R k a P) [NeZero n] [NeZero a] + {e : Fin n × Fin n} (he : e ∈ S.edges) : + S.convexOwner e = ((S.trace he).number, (S.trace he).token.val) := by + simp only [System.convexOwner, dite_eq_left he] + +lemma System.convexOwner_mem (S : @System n R k a P) [NeZero n] [NeZero a] + {e : Fin n × Fin n} (he : e ∈ S.edges) : + S.convexOwner e ∈ Finset.univ ×ˢ S.vertices := by + rw [S.convexOwner_eq he] + exact Finset.mem_product.mpr ⟨Finset.mem_univ _, S.trace_token_mem he⟩ + +noncomputable def System.convexCover (S : @System n R k a P) [NeZero n] [NeZero a] : + ConvexCover S.drawing (Fin a × Fin n) where + owner := S.convexOwner + support e he f hf howner z hz := by + have he' : e ∈ S.edges := he + have hf' : f ∈ S.edges := hf + rw [S.convexOwner_eq he', S.convexOwner_eq hf'] at howner + have hj : (S.trace he').number = (S.trace hf').number := congrArg Prod.fst howner + have hu : (S.trace he').token = (S.trace hf').token := Subtype.ext (congrArg Prod.snd howner) + let C := S.tokenPath (S.trace he').number (S.trace he').token + have h₀ : C.point (S.trace he').batch.castSucc = P e.1 := congrArg P (S.trace he').source + have h₁ : C.point (S.trace he').batch.succ = P e.2 := congrArg P (S.trace he').target + have h₂ : C.point (S.trace hf').batch.castSucc = P f.1 := by + simp only [C, System.tokenPath, hj, hu, (S.trace hf').source] + have h₃ : C.point (S.trace hf').batch.succ = P f.2 := by + simp only [C, System.tokenPath, hj, hu, (S.trace hf').target] + have hne : C.point (S.trace he').batch.castSucc ≠ C.point (S.trace he').batch.succ := by + rw [h₀,h₁] + exact fun h => (S.drawing.right _ he).ne (congrArg Prod.fst h) + have hzs : z ∈ segment ℝ (C.point (S.trace hf').batch.castSucc) (C.point (S.trace hf').batch.succ) := by + rwa [h₂,h₃] + have h := C.support_segment (S.trace he').batch hne (S.trace hf').batch hzs + rwa [h₀,h₁] at h + +end PlanarHalving.Batches + +namespace PlanarHalving.PlaneGraph +variable {V : Type*} [Fintype V] {P : V → Point} {I J : Type*} {D : Drawing P} + +theorem ConvexCover.crossing_bound_finset [DecidableEq I] [DecidableEq J] + (C : ConvexCover D I) (A : ConcaveCover D J) (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (hD : D.NoMultiple) + (ci : Finset I) (cj : Finset J) + (hci : ∀ e ∈ D.edges, C.owner e ∈ ci) (hcj : ∀ e ∈ D.edges, A.owner e ∈ cj) : + D.crossings.card ≤ 2 * ci.card * cj.card := by + classical + let f := fun w : (V × V) × (V × V) => + (C.owner w.1, A.owner w.2, + decide (slope (P w.1.1) (P w.1.2) < slope (P w.2.1) (P w.2.2))) + have hm : Set.MapsTo f (D.crossings : Set _) (↑(ci ×ˢ (cj ×ˢ (Finset.univ : Finset Bool))) : Set _) := by + intro w hw + have hp := D.crossing_props ⟨w,hw⟩ + exact Finset.mem_product.mpr ⟨hci _ hp.1, + Finset.mem_product.mpr ⟨hcj _ hp.2.1, Finset.mem_univ _⟩⟩ + have hi : (D.crossings : Set _).InjOn f := by + intro w hw v hv hh + exact congrArg Subtype.val (C.crossing_sign_injective A hP hx hD (a₁ := ⟨w,hw⟩) (a₂ := ⟨v,hv⟩) hh) + have hc := Finset.card_le_card_of_injOn f hm hi + simpa only [Finset.card_product, Finset.card_univ, Fintype.card_bool, + mul_comm, mul_left_comm, mul_assoc] using hc + +lemma slope_neg_reverse (p q : Point) : slope (-q) (-p) = slope p q := by + simp only [slope, Prod.fst_neg, Prod.snd_neg] + congr 1 <;> ring + +lemma height_neg_reverse (p q : Point) (hx : p.1 ≠ q.1) (x : ℝ) : + height (-q) (-p) (-x) = -height p q x := by + have hy := height_right p q hx + rw [height, slope_neg_reverse] + simp only [Prod.fst_neg, Prod.snd_neg] + unfold height at hy ⊢ + linarith only [hy] + +end PlanarHalving.PlaneGraph + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Compactness.lean b/lean/OAI/Combinatorics/HalvingLines/Compactness.lean new file mode 100644 index 0000000000000000000000000000000000000000..334e4d2561485f341eb8c10af14b848fe04ab05f --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Compactness.lean @@ -0,0 +1,154 @@ +import OAI.Combinatorics.HalvingLines.Calculus + +namespace OAI + +namespace PlanarHalving + +namespace RankLimit + +open Filter MeasureTheory Set Metric +open scoped Topology + +abbrev RatPoint := ℚ × ℚ + +def ratPoint (q : RatPoint) : Point := ((q.1 : ℝ), (q.2 : ℝ)) + +noncomputable def lowerGrid (g : RatPoint → unitInterval) (x : Point) : unitInterval := + ⨆ q : RatPoint, if (q.1 : ℝ) < x.1 ∧ (q.2 : ℝ) < x.2 then g q else ⊥ + +lemma lowerGrid_monotone (g : RatPoint → unitInterval) : Monotone (lowerGrid g) := by + intro x y hxy + apply iSup_le + intro q + by_cases hq : (q.1 : ℝ) < x.1 ∧ (q.2 : ℝ) < x.2 + · have hqy : (q.1 : ℝ) < y.1 ∧ (q.2 : ℝ) < y.2 := + ⟨hq.1.trans_le hxy.1, hq.2.trans_le hxy.2⟩ + simpa only [lowerGrid, ite_eq_left hq, ite_eq_left hqy] using + (le_iSup (fun r : RatPoint => + if (r.1 : ℝ) < y.1 ∧ (r.2 : ℝ) < y.2 then g r else ⊥) q) + · simp only [ite_eq_right hq, bot_le] + +lemma lowerGrid_measurable (g : RatPoint → unitInterval) : Measurable (lowerGrid g) := by + apply Measurable.iSup + intro q + exact Measurable.ite + ((isOpen_lt continuous_const continuous_fst).inter + (isOpen_lt continuous_const continuous_snd)).measurableSet + measurable_const measurable_const + +lemma grid_le_lowerGrid {g : RatPoint → unitInterval} {q : RatPoint} {x : Point} + (hq : (q.1 : ℝ) < x.1 ∧ (q.2 : ℝ) < x.2) : g q ≤ lowerGrid g x := by + simpa only [lowerGrid, ite_eq_left hq] using + (le_iSup (fun r : RatPoint => + if (r.1 : ℝ) < x.1 ∧ (r.2 : ℝ) < x.2 then g r else ⊥) q) + +theorem moving_tendsto_of_grid {f : ℕ → Point → unitInterval} + (hf : ∀ n, Monotone (f n)) {g : RatPoint → unitInterval} + (hg : ∀ q, Tendsto (fun n => f n (ratPoint q)) atTop (𝓝 (g q))) + {x : Point} (hc : ContinuousAt (lowerGrid g) x) {y : ℕ → Point} + (hy : Tendsto y atTop (𝓝 x)) : + Tendsto (fun n => f n (y n)) atTop (𝓝 (lowerGrid g x)) := by + rw [tendsto_order] + constructor + · intro a ha + obtain ⟨q, hq⟩ := lt_iSup_iff.mp ha + by_cases hqx : (q.1 : ℝ) < x.1 ∧ (q.2 : ℝ) < x.2 + · simp only [ite_eq_left hqx] at hq + filter_upwards [(tendsto_order.mp (hg q)).1 a hq, + (tendsto_order.mp ((continuous_fst.tendsto x).comp hy)).1 _ hqx.1, + (tendsto_order.mp ((continuous_snd.tendsto x).comp hy)).1 _ hqx.2] with n hn hn₁ hn₂ + exact hn.trans_le (hf n ⟨hn₁.le, hn₂.le⟩) + · simp only [ite_eq_right hqx, not_lt_bot] at hq + · intro a ha + have hn := hc.preimage_mem_nhds (isOpen_Iio.mem_nhds ha) + obtain ⟨δ, hδ, hδU⟩ := Metric.mem_nhds_iff.mp hn + let b : Point := x + (δ / 2, δ / 2) + have hb : b ∈ ball x δ := by + rw [Metric.mem_ball, dist_eq_norm] + simp only [b, add_sub_cancel_left, Prod.norm_def, Real.norm_eq_abs, + abs_of_pos (half_pos hδ), max_self] + linarith only [hδ] + have hba : lowerGrid g b < a := hδU hb + obtain ⟨r₁, hxr₁, hr₁b⟩ := exists_rat_btwn + (show x.1 < b.1 by dsimp [b]; linarith only [hδ]) + obtain ⟨r₂, hxr₂, hr₂b⟩ := exists_rat_btwn + (show x.2 < b.2 by dsimp [b]; linarith only [hδ]) + let r : RatPoint := (r₁, r₂) + have hra : g r < a := (grid_le_lowerGrid ⟨hr₁b, hr₂b⟩).trans_lt hba + filter_upwards [(tendsto_order.mp (hg r)).2 a hra, + (tendsto_order.mp ((continuous_fst.tendsto x).comp hy)).2 _ hxr₁, + (tendsto_order.mp ((continuous_snd.tendsto x).comp hy)).2 _ hxr₂] with n hn hn₁ hn₂ + exact (hf n ⟨hn₁.le, hn₂.le⟩).trans_lt hn + +theorem monotone_grid_subsequence {ι : Type*} [Countable ι] + (f : ℕ → ι → Point → unitInterval) (hf : ∀ n i, Monotone (f n i)) : + ∃ (φ : ℕ → ℕ) (F : ι → Point → unitInterval), StrictMono φ ∧ + (∀ i, Monotone (F i) ∧ Measurable (F i)) ∧ + (∀ i x, ContinuousAt (F i) x → ∀ y : ℕ → Point, + Tendsto y atTop (𝓝 x) → + Tendsto (fun n => f (φ n) i (y n)) atTop (𝓝 (F i x))) := by + obtain ⟨g, φ, hφ, hg⟩ := CompactSpace.tendsto_subseq + (fun n i q => f n i (ratPoint q)) + refine ⟨φ, fun i => lowerGrid (g i), hφ, + fun i => ⟨lowerGrid_monotone _, lowerGrid_measurable _⟩, ?_⟩ + intro i x hx y hy + apply moving_tendsto_of_grid (fun n => hf (φ n) i) _ hx hy + intro q + exact ((tendsto_pi_nhds.mp hg) i).apply_nhds q + +end RankLimit + +namespace Transversality + +open MeasureTheory Set +open scoped MeasureTheory ENNReal + +theorem critical_projection_null {Z : Type*} [MeasurableSpace Z] + (σ : Measure Z) (coordinate : Z → Point) (hcoordinate : Measurable coordinate) + (hdom : σ.map coordinate ≪ volume) (p : Z → Point) (F : Point → Point) + (S : Set Z) (hidentity : ∀ z ∈ S, coordinate z = F (p z)) + (hdiff : ∀ z ∈ S, DifferentiableAt ℝ F (p z)) + (hsing : ∀ z ∈ S, (fderiv ℝ F (p z)).det = 0) : σ S = 0 := by + obtain ⟨N, hsub, hN, hnull⟩ := exists_measurable_superset_of_null (critical_image_null F) + apply measure_mono_null (t := coordinate ⁻¹' N) + · intro z hz + change coordinate z ∈ N + rw [hidentity z hz] + exact hsub ⟨p z, ⟨hdiff z hz, hsing z hz⟩, rfl⟩ + · rw [← Measure.map_apply hcoordinate hN] + exact hdom hnull + +theorem independent_gradients_ae {Z ι : Type*} [MeasurableSpace Z] [Countable ι] + (ν : Measure Z) (h : Z → ℝ≥0∞) (hh : Measurable h) + (σ : ι → Measure Z) (hν : ν.withDensity h ≪ Measure.sum σ) + (coordinate : ι → Z → Point) (hcoordinate : ∀ i, Measurable (coordinate i)) + (hdom : ∀ i, (σ i).map (coordinate i) ≪ volume) + (p : Z → Point) (F : ι → Point → Point) (S : Set Z) + (hidentity : ∀ i z, z ∈ S → coordinate i z = F i (p z)) + (hdiff : ∀ i z, z ∈ S → DifferentiableAt ℝ (F i) (p z)) : + ∀ᵐ z ∂ν, z ∈ S → h z ≠ 0 → ∃ i, (fderiv ℝ (F i) (p z)).det ≠ 0 := by + have hbad : (ν.withDensity h) {z | z ∈ S ∧ ∀ i, (fderiv ℝ (F i) (p z)).det = 0} = 0 := by + apply hν + rw [Measure.sum_apply_eq_zero] + intro i + apply critical_projection_null (σ i) (coordinate i) (hcoordinate i) (hdom i) p + (F i) _ + · intro z hz + exact hidentity i z hz.1 + · intro z hz + exact hdiff i z hz.1 + · intro z hz + exact hz.2 i + have hgood : ∀ᵐ z ∂ν.withDensity h, + z ∈ S → ∃ i, (fderiv ℝ (F i) (p z)).det ≠ 0 := by + apply ae_iff.mpr + simpa only [Classical.not_imp, not_exists, not_not] using hbad + have hg := (ae_withDensity_iff hh).mp hgood + filter_upwards [hg] with z hz hzS hzh + exact hz hzh hzS + +end Transversality + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Continuity.lean b/lean/OAI/Combinatorics/HalvingLines/Continuity.lean new file mode 100644 index 0000000000000000000000000000000000000000..d221a0990f77fcb9f7473ecb58f3c0279dcf9191 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Continuity.lean @@ -0,0 +1,424 @@ +import OAI.Combinatorics.HalvingLines.Derivatives + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.TimeWindows +open Set Filter MeasureTheory +open scoped unitInterval Topology + +noncomputable def lower (J : Window) : I := UniformPartition.boundary (2^J.1) J.2.castSucc +noncomputable def upper (J : Window) : I := UniformPartition.boundary (2^J.1) J.2.succ + +lemma lower_lt_upper (J : Window) : lower J < upper J := by + change (J.2 : ℝ)/(2^J.1 : ℕ) < ((J.2.val+1 : ℕ) : ℝ)/(2^J.1 : ℕ) + apply div_lt_div_of_pos_right _ (by positivity) + simp + +lemma upper_sub_lower (J : Window) : (upper J : ℝ) - (lower J : ℝ) = 1/(2:ℝ)^J.1 := by + simp only [upper, lower, UniformPartition.boundary, Fin.val_succ, Fin.val_castSucc, + Nat.cast_add, Nat.cast_one, Nat.cast_pow, Nat.cast_ofNat] + ring + +lemma Ioo_subset_carrier (J : Window) : Ioo (lower J) (upper J) ⊆ carrier J := by + intro t ht + unfold carrier UniformPartition.cell + split_ifs + · exact ⟨ht.1.le, ht.2.le⟩ + · exact ⟨ht.1.le, ht.2⟩ + +lemma carrier_subset_Icc (J : Window) : carrier J ⊆ Icc (lower J) (upper J) := by + intro t ht + unfold carrier UniformPartition.cell at ht + split_ifs at ht + · exact ht + · exact ⟨ht.1, ht.2.le⟩ + +lemma closure_carrier (J : Window) : closure (carrier J) = Icc (lower J) (upper J) := by + unfold carrier UniformPartition.cell + split_ifs + · exact isClosed_Icc.closure_eq + · exact closure_Ico (lower_lt_upper J).ne + +lemma endpoints_of_subset {J K : Window} (h : carrier J ⊆ carrier K) : + lower K ≤ lower J ∧ upper J ≤ upper K := by + have hh := closure_mono h + rw [closure_carrier, closure_carrier] at hh + exact ⟨(hh ⟨le_rfl,(lower_lt_upper J).le⟩).1, + (hh ⟨(lower_lt_upper J).le,le_rfl⟩).2⟩ + +lemma before_or_before {A B : Window} (h : Disjoint (carrier A) (carrier B)) : + Before A B ∨ Before B A := by + by_contra hn + have hn' : upper B > lower A ∧ upper A > lower B := by + simpa only [Before, lower, upper, not_or, not_le, and_comm] using hn + have hlt : max (lower A) (lower B) < min (upper A) (upper B) := by + exact max_lt_iff.mpr ⟨lt_min (lower_lt_upper A) hn'.1, + lt_min hn'.2 (lower_lt_upper B)⟩ + obtain ⟨t,ht1,ht2⟩ := exists_between hlt + exact Set.disjoint_left.mp h (Ioo_subset_carrier A ⟨(le_max_left _ _).trans_lt ht1, + ht2.trans_le (min_le_left _ _)⟩) + (Ioo_subset_carrier B ⟨(le_max_right _ _).trans_lt ht1,ht2.trans_le (min_le_right _ _)⟩) + +lemma before_of_separated {K H C A : Window} (hKH : upper K < lower H) + (hC : carrier C ⊆ carrier K) (hA : carrier A ⊆ carrier H) : Before C A := by + exact ((endpoints_of_subset hC).2.trans hKH.le).trans (endpoints_of_subset hA).1 + +lemma ae_avoid_boundaries (μ : Measure I) [NullSingletonClass μ] : + ∀ᵐ t ∂μ, ∀ m (i : Fin (2^m+1)), t ≠ UniformPartition.boundary (2^m) i := by + rw [ae_all_iff] + intro m + rw [ae_all_iff] + intro i + exact μ.ae_ne _ + +lemma exists_separated_positive (μ : Measure I) [IsProbabilityMeasure μ] + [NullSingletonClass μ] : + ∃ K H : Window, (0 : ℝ) < lower K ∧ upper K < lower H ∧ (upper H : ℝ) < 1 ∧ + μ (carrier K) ≠ 0 ∧ μ (carrier H) ≠ 0 := by + have he0 : ∀ᵐ t ∂μ, t ≠ (0 : I) := μ.ae_ne _ + have he1 : ∀ᵐ t ∂μ, t ≠ (1 : I) := μ.ae_ne _ + have hes : ∀ᵐ t ∂μ, t ∈ μ.support := μ.support_mem_ae + obtain ⟨x,hxs,hxb,hx0,hx1⟩ := + (hes.and ((ae_avoid_boundaries μ).and (he0.and he1))).exists + have hne : ∀ᵐ t ∂μ, t ≠ x := μ.ae_ne _ + obtain ⟨y,hys,hyb,hy0,hy1,hyx⟩ := + (hes.and ((ae_avoid_boundaries μ).and (he0.and (he1.and hne)))).exists + have base (x y : I) (hxs : x ∈ μ.support) (hys : y ∈ μ.support) + (hxb : ∀ m (i : Fin (2^m+1)), x ≠ UniformPartition.boundary (2^m) i) + (hyb : ∀ m (i : Fin (2^m+1)), y ≠ UniformPartition.boundary (2^m) i) + (hx0 : x ≠ 0) (hy1 : y ≠ 1) (hxy : x < y) : + ∃ K H : Window, (0 : ℝ) < lower K ∧ upper K < lower H ∧ (upper H : ℝ) < 1 ∧ + μ (carrier K) ≠ 0 ∧ μ (carrier H) ≠ 0 := by + have hxpos : 0 < (x : ℝ) := lt_of_le_of_ne x.property.1 (by + intro hh; exact hx0 (Subtype.ext hh.symm)) + have hylt : (y : ℝ) < 1 := lt_of_le_of_ne y.property.2 (by + intro hh; exact hy1 (Subtype.ext hh)) + have hxy' : (x : ℝ) < (y : ℝ) := hxy + have hmesh : Tendsto (fun m : ℕ => 1/(2:ℝ)^m) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop (tendsto_pow_atTop_atTop_of_one_lt (by norm_num)) + have he := hmesh.eventually (gt_mem_nhds (show 0 < min (x : ℝ) (min (1-(y:ℝ)) (((y:ℝ)-x)/2)) by positivity)) + obtain ⟨m,hm⟩ := he.exists + have hm1 := (lt_min_iff.mp hm).1 + have hm2 := (lt_min_iff.mp (lt_min_iff.mp hm).2).1 + have hm3 := (lt_min_iff.mp (lt_min_iff.mp hm).2).2 + obtain ⟨i,hi⟩ := UniformPartition.mem_some_cell (2^m) x + obtain ⟨j,hj⟩ := UniformPartition.mem_some_cell (2^m) y + let K : Window := ⟨m,i⟩ + let H : Window := ⟨m,j⟩ + have hk := carrier_subset_Icc K hi + have hh := carrier_subset_Icc H hj + have hki : x ∈ Ioo (lower K) (upper K) := + ⟨lt_of_le_of_ne hk.1 (Ne.symm (hxb m i.castSucc)), lt_of_le_of_ne hk.2 (hxb m i.succ)⟩ + have hhi : y ∈ Ioo (lower H) (upper H) := + ⟨lt_of_le_of_ne hh.1 (Ne.symm (hyb m j.castSucc)), lt_of_le_of_ne hh.2 (hyb m j.succ)⟩ + have kw := upper_sub_lower K + have hw := upper_sub_lower H + have hk1 : (lower K : ℝ) ≤ x := hk.1 + have hk2 : (x : ℝ) ≤ upper K := hk.2 + have hh1 : (lower H : ℝ) ≤ y := hh.1 + have hh2 : (y : ℝ) ≤ upper H := hh.2 + refine ⟨K,H,?_,?_,?_,?_,?_⟩ + · dsimp [K] at kw + linarith + · change (upper K : ℝ) < lower H + dsimp [K] at kw + dsimp [H] at hw + linarith + · dsimp [H] at hw + linarith + · exact ne_of_gt ((measure_mono (Ioo_subset_carrier K)).trans_lt' ((Measure.mem_support_iff_forall x).mp hxs _ (Ioo_mem_nhds hki.1 hki.2))) + · exact ne_of_gt ((measure_mono (Ioo_subset_carrier H)).trans_lt' ((Measure.mem_support_iff_forall y).mp hys _ (Ioo_mem_nhds hhi.1 hhi.2))) + rcases lt_or_gt_of_ne hyx with h | h + · exact base y x hys hxs hyb hxb hy0 hx1 h + · exact base x y hxs hys hxb hyb hx0 hy1 h + +end PlanarHalving.TimeWindows +namespace PlanarHalving.Batches +open Set MeasureTheory TimeWindows Limits +variable {n R k a : ℕ} {P : Fin n → Point} +lemma System.windowCrossings_comm (S : @System n R k a P) [NeZero R] (A B : Window) : + S.windowCrossings A B = S.windowCrossings B A := by + classical + unfold System.windowCrossings + congr 1 + funext w + apply propext + tauto + +lemma System.windowCrossMeasure_comm (S : @System n R k a P) [NeZero R] + (A B : Window) {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] + (z : Point → X) : S.windowCrossMeasure A B z = S.windowCrossMeasure B A z := by + apply FiniteMeasure.eq_of_forall_apply_eq + intro U hU + apply NNReal.coe_injective + rw [S.windowCrossMeasure_apply A B z hU,S.windowCrossMeasure_apply B A z hU] + rw [System.crossingsIn,System.crossingsIn,S.windowCrossings_comm A B] +end PlanarHalving.Batches + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Batches TimeWindows Limits +open scoped unitInterval Topology + +lemma Converges.crossings_comm {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (A B : Window) : L.crossings A B = L.crossings B A := by + apply tendsto_nhds_unique (h.crossings A B) + convert h.crossings B A using 1 + funext n + exact (F n).system.windowCrossMeasure_comm A B _ + +lemma unitPair_quasiMeasurePreserving : + Measure.QuasiMeasurePreserving (fun p : I × I => ((p.1 : ℝ),(p.2 : ℝ))) volume volume := by + have hi : Measure.QuasiMeasurePreserving ((↑) : I → ℝ) volume volume := + unitInterval.measurePreserving_coe.quasiMeasurePreserving.mono_right (Measure.absolutelyContinuous_of_le (Measure.restrict_le_self)) + exact QuasiMeasurePreserving.prodMap hi hi + +lemma signedPair_measurePreserving (b : Bool) : MeasurePreserving (signedPair b) volume volume := by + cases b + · exact (Measure.measurePreserving_neg (volume : Measure ℝ)).prod (MeasurePreserving.id _) + · exact (MeasurePreserving.id _).prod (Measure.measurePreserving_neg (volume : Measure ℝ)) + +lemma Converges.crossing_real_projection {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + (hM : Tendsto (fun n => (F n).a*(F n).n) atTop atTop) + {A B : Window} (hAB : Before A B) : + (L.crossings A B : Measure Labels).map (fun z => ((z A : ℝ),(z B : ℝ))) ≪ volume := by + have hp : Measure.QuasiMeasurePreserving (fun z : Labels => (z A,z B)) + (L.crossings A B : Measure Labels) volume := + ⟨(continuous_apply A |>.prodMk (continuous_apply B)).measurable, + Measure.absolutelyContinuous_of_le (h.crossing_projection hR hM hAB)⟩ + exact (unitPair_quasiMeasurePreserving.comp hp).absolutelyContinuous + +lemma Converges.crossing_signed_projection {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + (hM : Tendsto (fun n => (F n).a*(F n).n) atTop atTop) + (b : Bool) {A B : Window} (hAB : Before A B) : + (L.crossings A B : Measure Labels).map (pairCoordinates b A B) ≪ volume := by + have hp : Measure.QuasiMeasurePreserving (fun z : Labels => ((z A : ℝ),(z B : ℝ))) + (L.crossings A B : Measure Labels) volume := + ⟨by fun_prop,h.crossing_real_projection hR hM hAB⟩ + exact ((signedPair_measurePreserving b).quasiMeasurePreserving.comp hp).absolutelyContinuous + +lemma Converges.window_withDensity {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) : + (L.edgeWindow J : Measure Labels) = (L.edge : Measure Labels).withDensity + (fun z => L.conditional z (carrier J)) := by + ext U hU + rw [withDensity_apply _ hU, Data.edge_toMeasure, Data.conditional, + Measure.setLIntegral_condKernel_eq_measure_prod hU (measurable_carrier J)] + rw [Data.edgeWindow,FiniteMeasure.toMeasure_map,Measure.map_apply measurable_fst hU, + h.restriction_eq hR,Measure.restrict_apply (hU.preimage measurable_fst)] + rfl + +lemma Converges.edge_probability {F : ℕ → Configuration} {L : Data} (h : Converges F L) : + IsProbabilityMeasure (L.edge : Measure Labels) := by + constructor + rw [Data.edge,FiniteMeasure.toMeasure_map,Measure.map_apply measurable_fst MeasurableSet.univ, + preimage_univ,← FiniteMeasure.ennreal_mass,h.edgeTime_mass] + rfl + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimit +open Filter Set Metric MeasureTheory +open scoped Topology + +lemma dense_strict_brackets {S : Set Point} (hS : Dense S) {p : Point} {U : Set Point} + (hU : U ∈ 𝓝 p) : + (∃ l ∈ S ∩ U, l.1 < p.1 ∧ l.2 < p.2) ∧ + (∃ u ∈ S ∩ U, p.1 < u.1 ∧ p.2 < u.2) := by + obtain ⟨r,hr,hrU⟩ := Metric.mem_nhds_iff.mp hU + have hb : ‖(r/2,r/2)‖ < r := by + simp only [Prod.norm_def,Real.norm_eq_abs,abs_of_pos (half_pos hr),max_self] + linarith only [hr] + constructor + · obtain ⟨l,hlS,hl⟩ := hS.exists_mem_open + ((isOpen_ball.inter (isOpen_lt continuous_fst continuous_const)).inter + (isOpen_lt continuous_snd continuous_const)) + (show ((ball p r ∩ {x : Point | x.1 < p.1}) ∩ {x : Point | x.2 < p.2}).Nonempty from + ⟨p-(r/2,r/2),⟨⟨by simpa [Metric.mem_ball,dist_eq_norm] using hb,by dsimp; linarith⟩,by dsimp; linarith⟩⟩) + exact ⟨l,⟨hlS,hrU hl.1.1⟩,hl.1.2,hl.2⟩ + · obtain ⟨u,huS,hu⟩ := hS.exists_mem_open + ((isOpen_ball.inter (isOpen_lt continuous_const continuous_fst)).inter + (isOpen_lt continuous_const continuous_snd)) + (show ((ball p r ∩ {x : Point | p.1 < x.1}) ∩ {x : Point | p.2 < x.2}).Nonempty from + ⟨p+(r/2,r/2),⟨⟨by simpa [Metric.mem_ball,dist_eq_norm] using hb,by dsimp; linarith⟩,by dsimp; linarith⟩⟩) + exact ⟨u,⟨huS,hrU hu.1.1⟩,hu.1.2,hu.2⟩ + +lemma monotone_eventually_uniform_approx {f : ℕ → Point → ℝ} {G g : Point → ℝ} + (hf : ∀ n, Monotone (f n)) {S : Set Point} (hS : Dense S) + (hlim : ∀ x ∈ S, Tendsto (fun n => f n x) atTop (𝓝 (G x))) + (hg : Continuous g) {K U : Set Point} (hK : IsCompact K) (hU : IsOpen U) + (hKU : K ⊆ U) {ε : ℝ} (hε : 0 < ε) + (happrox : ∀ x ∈ U, dist (G x) (g x) < ε/4) : + ∀ᶠ n in atTop, ∀ x ∈ K, dist (f n x) (g x) < ε := by + have he : ∀ᶠ q : ℕ × Point in atTop ×ˢ 𝓝ˢ K, dist (f q.1 q.2) (g q.2) < ε := by + apply hK.mem_prod_nhdsSet_of_forall + intro p hp + let V := U ∩ {x | dist (g x) (g p) < ε/4} + have hV : V ∈ 𝓝 p := inter_mem (hU.mem_nhds (hKU hp)) + ((hg.tendsto p).eventually (Metric.ball_mem_nhds _ (by positivity))) + obtain ⟨⟨l,hl,hlp⟩,⟨u,hu,hpu⟩⟩ := dense_strict_brackets hS hV + have hll := (hlim l hl.1).eventually (Metric.ball_mem_nhds _ (show 0 < ε/4 by positivity)) + have hlu := (hlim u hu.1).eventually (Metric.ball_mem_nhds _ (show 0 < ε/4 by positivity)) + have hne : ∀ᶠ x in 𝓝 p, l.1 < x.1 ∧ l.2 < x.2 ∧ x.1 < u.1 ∧ x.2 < u.2 ∧ + dist (g x) (g p) < ε/4 := by + filter_upwards [(continuous_fst.tendsto p).eventually (Ioi_mem_nhds hlp.1), + (continuous_snd.tendsto p).eventually (Ioi_mem_nhds hlp.2), + (continuous_fst.tendsto p).eventually (Iio_mem_nhds hpu.1), + (continuous_snd.tendsto p).eventually (Iio_mem_nhds hpu.2), + (hg.tendsto p).eventually (Metric.ball_mem_nhds _ (show 0 < ε/4 by positivity))] + with x hx1 hx2 hx3 hx4 hx5 + exact ⟨hx1,hx2,hx3,hx4,hx5⟩ + filter_upwards [(hll.and hlu).prod_mk hne] with q hq + rcases hq with ⟨⟨hnl,hnu⟩,hx1,hx2,hx3,hx4,hxg⟩ + have hlo := hf q.1 (show l ≤ q.2 from ⟨hx1.le,hx2.le⟩) + have hup := hf q.1 (show q.2 ≤ u from ⟨hx3.le,hx4.le⟩) + have hdl := happrox l hl.2.1 + have hdu := happrox u hu.2.1 + have hlg : dist (g l) (g p) < ε/4 := hl.2.2 + have hug : dist (g u) (g p) < ε/4 := hu.2.2 + rw [Real.dist_eq,abs_lt] at hnl hnu + rw [Real.dist_eq,abs_lt] at hdl hdu hlg hug hxg + change dist (f q.1 q.2) (g q.2) < ε + rw [Real.dist_eq,abs_lt] + constructor <;> linarith + have hen := he.curry + exact hen.mono fun _ hn => hn.self_of_nhdsSet + +lemma firstOrder_eventually_uniform {f : ℕ → Point → ℝ} {G : Point → ℝ} + (hf : ∀ n, Monotone (f n)) {S : Set Point} (hS : Dense S) + (hlim : ∀ x ∈ S, Tendsto (fun n => f n x) atTop (𝓝 (G x))) + {p : Point} {D : Point →L[ℝ] ℝ} (hd : HasFDerivAt G D p) + {R ε : ℝ} (hR : 0 ≤ R) (hε : 0 < ε) : + ∃ δ : ℝ, 0 < δ ∧ ∀ h : ℝ, 0 < h → h < δ → + ∀ᶠ n in atTop, ∀ x ∈ closedBall p (R*h), + dist (f n x) (G p + D (x-p)) < ε*h := by + let η := ε/(8*(R+1)) + have hη : 0 < η := div_pos hε (by positivity) + have he := hd.isLittleO.def hη + obtain ⟨r,hr,hrb⟩ := Metric.mem_nhds_iff.mp he + refine ⟨r/(R+1),div_pos hr (by positivity),?_⟩ + intro h hh hhr + have hhr' : (R+1)*h < r := by + have ht := (lt_div_iff₀ (show 0 < R+1 by positivity)).mp hhr + nlinarith only [ht] + apply monotone_eventually_uniform_approx hf hS hlim + (continuous_const.add (D.continuous.comp (continuous_id.sub continuous_const))) + (isCompact_closedBall p (R*h)) isOpen_ball (U:=ball p ((R+1)*h)) + (ε:=ε*h) + · intro x hx + exact (Metric.mem_closedBall.mp hx).trans_lt (by nlinarith only [hh]) + · exact mul_pos hε hh + · intro x hx + have hxnorm : ‖x-p‖ < (R+1)*h := by + simpa only [Metric.mem_ball,dist_eq_norm] using hx + have hxb : x ∈ ball p r := by + simpa only [Metric.mem_ball,dist_eq_norm] using hxnorm.trans hhr' + have hxlin := hrb hxb + calc + dist (G x) (G p + D (x-p)) = ‖G x-G p-D (x-p)‖ := by + rw [dist_eq_norm, sub_add_eq_sub_sub] + _ ≤ η*‖x-p‖ := hxlin + _ < η*((R+1)*h) := mul_lt_mul_of_pos_left hxnorm hη + _ = ε*h/8 := by + dsimp [η] + field_simp + _ < ε*h/4 := by nlinarith [mul_pos hε hh] + +lemma firstOrder_of_joint {f : ℕ → Point → ℝ} {G : Point → ℝ} + (hf : ∀ n, Monotone (f n)) + (hlim : ∀ p, ContinuousAt G p → Tendsto (fun q : ℕ × Point => f q.1 q.2) + (atTop ×ˢ 𝓝 p) (𝓝 (G p))) + (hdiff : ∀ᵐ p ∂(volume : Measure Point), DifferentiableAt ℝ G p) + {p : Point} {D : Point →L[ℝ] ℝ} (hd : HasFDerivAt G D p) + {R ε : ℝ} (hR : 0 ≤ R) (hε : 0 < ε) : + ∃ δ : ℝ, 0 < δ ∧ ∀ h : ℝ, 0 < h → h < δ → + ∀ᶠ n in atTop, ∀ x ∈ closedBall p (R*h), + dist (f n x) (G p + D (x-p)) < ε*h := by + apply firstOrder_eventually_uniform hf + (Measure.dense_of_ae (μ := volume) (hdiff.mono fun _ hx => hx.continuousAt)) + _ hd hR hε + intro x hx + exact (hlim x hx).comp (tendsto_id.prodMk tendsto_const_nhds) + +end PlanarHalving.RankLimit + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Batches TimeWindows Limits +open scoped Topology unitInterval ENNReal + +def SeparatedBefore (K H : Window) : Prop := + (0 : ℝ) < lower K ∧ upper K < lower H ∧ (upper H : ℝ) < 1 + +lemma Data.exists_positive_windows (L : Data) [IsProbabilityMeasure (L.edge : Measure Labels)] + (hna : ∀ᵐ z ∂(L.edge : Measure Labels), NullSingletonClass (L.conditional z)) : + ∃ K H : Window, SeparatedBefore K H ∧ + (L.edge : Measure Labels) {z | L.conditional z (carrier K) ≠ 0 ∧ + L.conditional z (carrier H) ≠ 0} ≠ 0 := by + by_contra hn + have hz : ∀ K H : Window, SeparatedBefore K H → + (L.edge : Measure Labels) {z | L.conditional z (carrier K) ≠ 0 ∧ + L.conditional z (carrier H) ≠ 0} = 0 := by + simpa only [not_exists, not_and, not_not] using hn + have he : ∀ᵐ z ∂(L.edge : Measure Labels), ∀ K H : Window, SeparatedBefore K H → + ¬(L.conditional z (carrier K) ≠ 0 ∧ L.conditional z (carrier H) ≠ 0) := by + rw [ae_all_iff] + intro K + rw [ae_all_iff] + intro H + by_cases hs : SeparatedBefore K H + · exact (ae_iff.mpr (by simpa only [not_not] using hz K H hs)).mono fun _ hh _ => hh + · exact Filter.Eventually.of_forall fun _ hh => (hs hh).elim + obtain ⟨z,hz,hzna⟩ := (he.and hna).exists + let := hzna + obtain ⟨K,H,hK,hKH,hH,hk,hh⟩ := exists_separated_positive (L.conditional z) + exact hz K H ⟨hK,hKH,hH⟩ ⟨hk,hh⟩ + +theorem Converges.positive_part {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) (hR : Tendsto (fun n => (F n).R) atTop atTop) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4/(((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3/(((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) : + ∃ (K H A B : Window) (T : Set Labels), SeparatedBefore K H ∧ + carrier A ⊆ carrier H ∧ carrier B ⊆ carrier H ∧ Before A B ∧ + MeasurableSet T ∧ (L.edge : Measure Labels) T ≠ 0 ∧ + (∀ z ∈ T, L.conditional z (carrier K) ≠ 0 ∧ L.conditional z (carrier H) ≠ 0) ∧ + (L.edge : Measure Labels).restrict T ≪ (L.crossings A B : Measure Labels) ∧ + (L.edge : Measure Labels).restrict T ≪ (L.points : Measure Labels) := by + let := h.edge_probability + obtain ⟨K,H,hsep,hpos⟩ := L.exists_positive_windows (h.conditional_nullSingleton E hR hC hcoeff herror) + let U : Set Labels := {z | L.conditional z (carrier K) ≠ 0 ∧ L.conditional z (carrier H) ≠ 0} + have hU : MeasurableSet U := + ((L.conditional.measurable_coe (measurable_carrier K)) (measurableSet_singleton 0)).compl.inter + ((L.conditional.measurable_coe (measurable_carrier H)) (measurableSet_singleton 0)).compl + have hac (J : Window) (hJ : ∀ z ∈ U, L.conditional z (carrier J) ≠ 0) : + (L.edge : Measure Labels).restrict U ≪ (L.edgeWindow J : Measure Labels) := by + rw [h.window_withDensity hR J] + exact restrict_ac_withDensity _ _ (L.conditional.measurable_coe (measurable_carrier J)) hU hJ + have hacH := (hac H (fun _ hz => hz.2)).trans (h.edge_crossing_ac E hR hC hcoeff herror hshort H) + obtain ⟨AB,V,hV,hVp,hVac⟩ := positive_single_component + ((L.edge : Measure Labels).restrict U) + (fun JH : CrossingPairs H => (L.crossings JH.val.1 JH.val.2 : Measure Labels)) hacH + (by simpa only [Measure.restrict_apply_univ] using hpos) + let T := V ∩ U + have hTeq : ((L.edge : Measure Labels).restrict U).restrict V = + (L.edge : Measure Labels).restrict T := Measure.restrict_restrict hV + have hTpos : (L.edge : Measure Labels) T ≠ 0 := by + simpa only [Measure.restrict_apply hV] using hVp + have hTpts : (L.edge : Measure Labels).restrict T ≪ (L.points : Measure Labels) := by + exact (Measure.absolutelyContinuous_of_le (Measure.restrict_mono_set _ inter_subset_right)).trans + ((hac K (fun _ hz => hz.1)).trans (h.window_absolutelyContinuous hC hcoeff herror K)) + rw [hTeq] at hVac + rcases before_or_before AB.property.2.2 with hAB | hBA + · exact ⟨K,H,AB.val.1,AB.val.2,T,hsep,AB.property.1,AB.property.2.1,hAB, + hV.inter hU,hTpos,fun _ hz => hz.2,hVac,hTpts⟩ + · rw [h.crossings_comm] at hVac + exact ⟨K,H,AB.val.2,AB.val.1,T,hsep,AB.property.2.1,AB.property.1,hBA, + hV.inter hU,hTpos,fun _ hz => hz.2,hVac,hTpts⟩ + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/CrossingEstimate.lean b/lean/OAI/Combinatorics/HalvingLines/CrossingEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0ad9dfe788b55839e0e4df8057ee50375829d0e --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/CrossingEstimate.lean @@ -0,0 +1,489 @@ +import OAI.Combinatorics.HalvingLines.PlaneGraph + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.FiniteSampling +open scoped BigOperators + +variable {V : Type*} [Fintype V] + +noncomputable def weight (p : V → ℝ) (ω : V → Bool) : ℝ := + ∏ v, if ω v then p v else 1 - p v + +noncomputable def expect (p : V → ℝ) (f : (V → Bool) → ℝ) : ℝ := + by classical exact ∑ ω, weight p ω * f ω + +lemma weight_nonneg {p : V → ℝ} (hp : ∀ v, p v ∈ Set.Icc (0 : ℝ) 1) (ω : V → Bool) : + 0 ≤ weight p ω := by + classical + apply Finset.prod_nonneg + intro v _ + split_ifs + · exact (hp v).1 + · exact sub_nonneg.mpr (hp v).2 + +lemma expect_prod (p : V → ℝ) (f : V → Bool → ℝ) : + expect p (fun ω => ∏ v, f v (ω v)) = + ∏ v, ((1 - p v) * f v false + p v * f v true) := by + classical + unfold expect weight + simp_rw [← Finset.prod_mul_distrib] + rw [← Fintype.prod_sum (fun v (b : Bool) => (if b then p v else 1 - p v) * f v b)] + congr 1 + funext v + simp [add_comm] + +@[simp] lemma expect_const (p : V → ℝ) (c : ℝ) : expect p (fun _ => c) = c := by + classical + have h := expect_prod p (fun _ _ => 1) + simp only [Finset.prod_const_one, mul_one, sub_add_cancel, expect] at h + unfold expect + rw [← Finset.sum_mul, h, one_mul] + +lemma expect_mono {p : V → ℝ} (hp : ∀ v, p v ∈ Set.Icc (0 : ℝ) 1) + {f g : (V → Bool) → ℝ} (hfg : ∀ ω, f ω ≤ g ω) : expect p f ≤ expect p g := + by + classical + exact Finset.sum_le_sum fun ω _ => mul_le_mul_of_nonneg_left (hfg ω) (weight_nonneg hp ω) + +lemma expect_sum {A : Type*} (p : V → ℝ) (s : Finset A) (f : A → (V → Bool) → ℝ) : + expect p (fun ω => ∑ a ∈ s, f a ω) = ∑ a ∈ s, expect p (f a) := by + classical + unfold expect + simp_rw [Finset.mul_sum] + exact Finset.sum_comm + +lemma expect_add (p : V → ℝ) (f g : (V → Bool) → ℝ) : + expect p (fun ω => f ω + g ω) = expect p f + expect p g := by + classical + simp only [expect, mul_add, Finset.sum_add_distrib] + +lemma expect_sub (p : V → ℝ) (f g : (V → Bool) → ℝ) : + expect p (fun ω => f ω - g ω) = expect p f - expect p g := by + classical + simp only [expect, mul_sub, Finset.sum_sub_distrib] + +lemma expect_mul_const (p : V → ℝ) (f : (V → Bool) → ℝ) (c : ℝ) : + expect p (fun ω => f ω * c) = expect p f * c := by + classical + simp only [expect, ← mul_assoc, Finset.sum_mul] + +lemma expect_const_mul (p : V → ℝ) (f : (V → Bool) → ℝ) (c : ℝ) : + expect p (fun ω => c * f ω) = c * expect p f := by + classical + simp_rw [mul_comm c] + exact expect_mul_const _ _ _ + +noncomputable def keep (s : Finset V) (ω : V → Bool) : ℝ := + if ∀ v ∈ s, ω v = true then 1 else 0 + +lemma keep_prod (s : Finset V) (ω : V → Bool) : + keep s ω = ∏ v ∈ s, if ω v then (1 : ℝ) else 0 := by + classical + by_cases h : ∀ v ∈ s, ω v = true + · rw [keep, ite_eq_left h] + symm + exact Finset.prod_eq_one fun v hv => by simp [h v hv] + · rw [keep, ite_eq_right h] + push Not at h + obtain ⟨v, hv, hw⟩ := h + symm + exact Finset.prod_eq_zero hv (by simp [hw]) + +lemma expect_keep (p : V → ℝ) (s : Finset V) : + expect p (keep s) = ∏ v ∈ s, p v := by + classical + have he (ω : V → Bool) : keep s ω = + ∏ v, if v ∈ s then (if ω v then (1 : ℝ) else 0) else 1 := by + rw [keep_prod] + simp only [Finset.prod_ite_mem_eq] + rw [show keep s = (fun ω => ∏ v, if v ∈ s then (if ω v then (1 : ℝ) else 0) else 1) from funext he] + rw [expect_prod p (fun v b => if v ∈ s then (if b then (1 : ℝ) else 0) else 1)] + simp only [Bool.false_eq_true, ↓reduceIte] + have h (v : V) : (1 - p v) * (if v ∈ s then 0 else 1) + + p v * (if v ∈ s then 1 else 1) = if v ∈ s then p v else 1 := by + split_ifs <;> ring + simp_rw [h] + simp + +lemma exists_ge_expect {p : V → ℝ} (hp : ∀ v, p v ∈ Set.Icc (0 : ℝ) 1) + (f : (V → Bool) → ℝ) : ∃ ω, expect p f ≤ f ω := by + classical + obtain ⟨ω, _, hω⟩ := Finset.univ.exists_max_image f Finset.univ_nonempty + refine ⟨ω, ?_⟩ + calc expect p f ≤ expect p (fun _ => f ω) := expect_mono hp fun τ => hω τ (Finset.mem_univ _) + _ = f ω := expect_const _ _ + +lemma expect_single (p : V → ℝ) (v : V) : + expect p (fun ω => if ω v then (1 : ℝ) else 0) = p v := by + classical + rw [show (fun ω : V → Bool => if ω v then (1 : ℝ) else 0) = keep {v} from by + funext ω; simp [keep]] + simpa using expect_keep p {v} + +lemma expect_pair (p : V → ℝ) {u v : V} (hne : u ≠ v) : + expect p (fun ω => if ω u = true ∧ ω v = true then (1 : ℝ) else 0) = p u * p v := by + classical + rw [show (fun ω : V → Bool => if ω u = true ∧ ω v = true then (1 : ℝ) else 0) = keep {u,v} from by + funext ω; simp [keep]] + simpa [hne] using expect_keep p {u,v} + +lemma expect_xor (p : V → ℝ) {u v : V} (hne : u ≠ v) : + expect p (fun ω => if ω u ≠ ω v then (1 : ℝ) else 0) = p u + p v - 2 * (p u * p v) := by + classical + have he : (fun ω : V → Bool => if ω u ≠ ω v then (1 : ℝ) else 0) = + (fun ω => (if ω u then (1 : ℝ) else 0) + (if ω v then (1 : ℝ) else 0) - + 2 * (if ω u = true ∧ ω v = true then (1 : ℝ) else 0)) := by + funext ω + cases ω u <;> cases ω v <;> norm_num + rw [he, expect_sub, expect_add, expect_const_mul, expect_single, expect_single, expect_pair p hne] + +noncomputable def bit (F : Finset V) (ω : ↥F → Bool) (v : V) : Bool := by + classical + exact if hv : v ∈ F then ω ⟨v,hv⟩ else false + +omit [Fintype V] in +lemma expect_cut (F : Finset V) {u v : V} (hne : u ≠ v) (hF : u ∈ F ∨ v ∈ F) : + expect (fun _ : ↥F => (1 : ℝ) / 2) (fun ω => if bit F ω u ≠ bit F ω v then (1 : ℝ) else 0) = 1 / 2 := by + classical + by_cases hu : u ∈ F + · by_cases hv : v ∈ F + · simp only [bit, dite_eq_left hu, dite_eq_left hv] + rw [expect_xor _ (show (⟨u,hu⟩ : ↥F) ≠ ⟨v,hv⟩ from fun h => hne (congrArg Subtype.val h))] + norm_num + · simp only [bit, dite_eq_left hu, dite_eq_right hv, Bool.not_eq_false] + exact expect_single (fun _ : ↥F => (1 : ℝ) / 2) (⟨u,hu⟩ : ↥F) + · have hv := hF.resolve_left hu + have hb (b : Bool) : (false ≠ b) ↔ b = true := by cases b <;> decide + simp only [bit, dite_eq_right hu, dite_eq_left hv, hb] + exact expect_single (fun _ : ↥F => (1 : ℝ) / 2) (⟨v,hv⟩ : ↥F) + +end PlanarHalving.FiniteSampling + +namespace PlanarHalving.PlaneGraph +open scoped BigOperators +open FiniteSampling +variable {V : Type*} [Fintype V] {P : V → Point} + +noncomputable def Drawing.sample (D : Drawing P) (ω : V → Bool) : Drawing P := by + classical + exact ⟨D.vertices.filter (fun v => ω v = true), + D.edges.filter (fun e => ω e.1 = true ∧ ω e.2 = true), + fun e he => D.right e (Finset.mem_filter.mp he).1, + fun e he => ⟨Finset.mem_filter.mpr ⟨(D.ends _ (Finset.mem_filter.mp he).1).1, + (Finset.mem_filter.mp he).2.1⟩, + Finset.mem_filter.mpr ⟨(D.ends _ (Finset.mem_filter.mp he).1).2, + (Finset.mem_filter.mp he).2.2⟩⟩⟩ + +lemma Drawing.sample_crossings (D : Drawing P) (ω : V → Bool) : + (D.sample ω).crossings = D.crossings.filter (fun ef => + ω ef.1.1 = true ∧ ω ef.1.2 = true ∧ ω ef.2.1 = true ∧ ω ef.2.2 = true) := by + classical + ext ef + simp only [Drawing.crossings, Drawing.sample, Finset.mem_filter, Finset.mem_product] + tauto + +lemma Drawing.expect_vertices (D : Drawing P) (p : V → ℝ) : + expect p (fun ω => ((D.sample ω).vertices.card : ℝ)) = ∑ v ∈ D.vertices, p v := by + classical + have h (ω : V → Bool) : ((D.sample ω).vertices.card : ℝ) = + ∑ v ∈ D.vertices, keep {v} ω := by + simp [Drawing.sample, keep] + simp_rw [h] + rw [expect_sum] + simp [expect_keep] + +lemma Drawing.expect_edges (D : Drawing P) (p : V → ℝ) : + expect p (fun ω => ((D.sample ω).edges.card : ℝ)) = + ∑ e ∈ D.edges, p e.1 * p e.2 := by + classical + have h (ω : V → Bool) : ((D.sample ω).edges.card : ℝ) = + ∑ e ∈ D.edges, keep {e.1, e.2} ω := by + simp [Drawing.sample, keep] + simp_rw [h] + rw [expect_sum] + apply Finset.sum_congr rfl + intro e he + have hne : e.1 ≠ e.2 := by + intro h + have hr := D.right e he + rw [h] at hr + exact lt_irrefl _ hr + simp [expect_keep, hne] + +lemma Drawing.expect_crossings (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) (p : V → ℝ) : + expect p (fun ω => ((D.sample ω).crossings.card : ℝ)) = + ∑ ef ∈ D.crossings, p ef.1.1 * p ef.1.2 * p ef.2.1 * p ef.2.2 := by + classical + have h (ω : V → Bool) : ((D.sample ω).crossings.card : ℝ) = + ∑ ef ∈ D.crossings, keep {ef.1.1, ef.1.2, ef.2.1, ef.2.2} ω := by + simp [D.sample_crossings, keep] + simp_rw [h] + rw [expect_sum] + apply Finset.sum_congr rfl + intro ef hef + have he := (Finset.mem_filter.mp hef) + have ends := D.crossing_endpoints hP hx (Finset.mem_product.mp he.1).1 + (Finset.mem_product.mp he.1).2 (fun h => (ne_of_lt he.2.1) (congrArg edgeIndex h)) he.2.2 + rcases ends with ⟨h12, h34, h13, h14, h23, h24⟩ + simp [expect_keep, h12, h34, h13, h14, h23, h24, mul_assoc] + +theorem Drawing.sample_crossing_bound (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) + (p : V → ℝ) (hp : ∀ v, p v ∈ Set.Icc (0 : ℝ) 1) : + (∑ e ∈ D.edges, p e.1 * p e.2) ≤ 3 * (∑ v ∈ D.vertices, p v) + + ∑ ef ∈ D.crossings, p ef.1.1 * p ef.1.2 * p ef.2.1 * p ef.2.2 := by + have h := expect_mono hp (fun ω => + (show ((D.sample ω).edges.card : ℝ) ≤ + 3 * ((D.sample ω).vertices.card : ℝ) + ((D.sample ω).crossings.card : ℝ) from + by exact_mod_cast (D.sample ω).linear_crossing_bound hP hx)) + rw [expect_add, expect_const_mul, D.expect_edges, D.expect_vertices, + D.expect_crossings hP hx] at h + exact h + +def Drawing.Bipartite (D : Drawing P) (A : Finset V) : Prop := + ∀ e ∈ D.edges, (e.1 ∈ A ∧ e.2 ∉ A) ∨ (e.1 ∉ A ∧ e.2 ∈ A) + +noncomputable def twoProb (A : Finset V) (p q : ℝ) (v : V) : ℝ := + by classical exact if v ∈ A then p else q + +omit [Fintype V] in +lemma Drawing.twoProb_edge {D : Drawing P} {A : Finset V} (hA : D.Bipartite A) + (p q : ℝ) {e : V × V} (he : e ∈ D.edges) : + twoProb A p q e.1 * twoProb A p q e.2 = p * q := by + classical + rcases hA e he with h | h <;> simp [twoProb, h.1, h.2, mul_comm] + +omit [Fintype V] in +lemma Drawing.twoProb_vertices (D : Drawing P) (A : Finset V) (p q : ℝ) + (hp : 0 ≤ p) (hq : 0 ≤ q) : + (∑ v ∈ D.vertices, twoProb A p q v) ≤ p * A.card + q * D.vertices.card := by + classical + have h := Finset.sum_le_sum (s := D.vertices) (fun v _ => + show twoProb A p q v ≤ (if v ∈ A then p else 0) + q from by + unfold twoProb + split_ifs <;> linarith) + rw [Finset.sum_add_distrib] at h + have hc : ((D.vertices.filter (fun v => v ∈ A)).card : ℝ) ≤ A.card := by + exact_mod_cast Finset.card_le_card (show D.vertices.filter (fun v => v ∈ A) ⊆ A from + fun v hv => (Finset.mem_filter.mp hv).2) + calc (∑ v ∈ D.vertices, twoProb A p q v) ≤ + ∑ v ∈ D.vertices, (if v ∈ A then p else 0) + ∑ _v ∈ D.vertices, q := h + _ = p * (D.vertices.filter (fun v => v ∈ A)).card + q * D.vertices.card := by + simp [Finset.filter_mem_eq_inter, mul_comm] + _ ≤ p * A.card + q * D.vertices.card := add_le_add (mul_le_mul_of_nonneg_left hc hp) le_rfl + +lemma Drawing.bipartite_sample_bound (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) + (A : Finset V) (hA : D.Bipartite A) (p q : ℝ) + (hp : p ∈ Set.Icc (0 : ℝ) 1) (hq : q ∈ Set.Icc (0 : ℝ) 1) : + p * q * D.edges.card ≤ 3 * (p * A.card + q * D.vertices.card) + + p ^ 2 * q ^ 2 * D.crossings.card := by + classical + have hh : ∀ v, twoProb A p q v ∈ Set.Icc (0 : ℝ) 1 := by + intro v + unfold twoProb + split_ifs <;> assumption + have h := D.sample_crossing_bound hP hx (twoProb A p q) hh + have he : (∑ e ∈ D.edges, twoProb A p q e.1 * twoProb A p q e.2) = p * q * D.edges.card := by + rw [Finset.sum_congr rfl (fun e he => D.twoProb_edge hA p q he)] + simp [mul_comm] + have hc : (∑ ef ∈ D.crossings, twoProb A p q ef.1.1 * twoProb A p q ef.1.2 * + twoProb A p q ef.2.1 * twoProb A p q ef.2.2) = p ^ 2 * q ^ 2 * D.crossings.card := by + have ht (ef) (hef : ef ∈ D.crossings) : twoProb A p q ef.1.1 * twoProb A p q ef.1.2 * + twoProb A p q ef.2.1 * twoProb A p q ef.2.2 = p ^ 2 * q ^ 2 := by + have hh := Finset.mem_product.mp (Finset.mem_filter.mp hef).1 + rw [mul_assoc (twoProb A p q ef.1.1 * twoProb A p q ef.1.2), + D.twoProb_edge hA p q hh.1, D.twoProb_edge hA p q hh.2] + ring + rw [Finset.sum_congr rfl ht] + simp [mul_comm] + rw [he, hc] at h + exact h.trans (add_le_add (mul_le_mul_of_nonneg_left (D.twoProb_vertices A p q hp.1 hq.1) + (by norm_num : (0 : ℝ) ≤ 3)) le_rfl) + +end PlanarHalving.PlaneGraph + +namespace PlanarHalving.PlaneGraph + +theorem crossing_sampling_algebra {m v e c : ℝ} (hm : 0 < m) (hv : 0 < v) (he : 0 < e) + (h : (12 * v / e) * (12 * m / e) * e ≤ + 3 * ((12 * v / e) * m + (12 * m / e) * v) + + (12 * v / e) ^ 2 * (12 * m / e) ^ 2 * c) : + e ^ 3 ≤ 288 * m * v * c := by + have hK : 0 < 72 * m * v / e ^ 4 := by positivity + have hh : (72 * m * v / e ^ 4) * e ^ 3 ≤ + (72 * m * v / e ^ 4) * (288 * m * v * c) := by + calc (72 * m * v / e ^ 4) * e ^ 3 = + (12 * v / e) * (12 * m / e) * e - + 3 * ((12 * v / e) * m + (12 * m / e) * v) := by field_simp; ring + _ ≤ (12 * v / e) ^ 2 * (12 * m / e) ^ 2 * c := by linarith only [h] + _ = (72 * m * v / e ^ 4) * (288 * m * v * c) := by ring + exact (mul_le_mul_iff_right₀ hK).mp hh + +end PlanarHalving.PlaneGraph + +namespace PlanarHalving.PlaneGraph +open scoped BigOperators +open FiniteSampling +variable {V : Type*} [Fintype V] {P : V → Point} + +theorem Drawing.bipartite_dense (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) + (A : Finset V) (hA : D.Bipartite A) (hAv : A ⊆ D.vertices) + (hd : 12 * (D.vertices.card : ℝ) ≤ D.edges.card) : + (D.edges.card : ℝ) ^ 3 ≤ 288 * A.card * D.vertices.card * D.crossings.card := by + classical + by_cases hempty : D.edges = ∅ + · simp only [hempty, Finset.card_empty, Nat.cast_zero, zero_pow (by omega : 3 ≠ 0)] + positivity + have hen : D.edges.Nonempty := Finset.nonempty_iff_ne_empty.mpr hempty + obtain ⟨e, he⟩ := hen + have hvn : D.vertices.Nonempty := ⟨e.1, (D.ends _ he).1⟩ + have hAn : A.Nonempty := by + rcases hA e he with h | h + · exact ⟨e.1, h.1⟩ + · exact ⟨e.2, h.2⟩ + have hepos : 0 < (D.edges.card : ℝ) := by exact_mod_cast (Finset.card_pos.mpr ⟨e,he⟩) + have hvpos : 0 < (D.vertices.card : ℝ) := by exact_mod_cast (Finset.card_pos.mpr hvn) + have hApos : 0 < (A.card : ℝ) := by exact_mod_cast (Finset.card_pos.mpr hAn) + have hAle : (A.card : ℝ) ≤ D.vertices.card := by exact_mod_cast Finset.card_le_card hAv + have hp : 12 * (D.vertices.card : ℝ) / D.edges.card ∈ Set.Icc (0 : ℝ) 1 := + ⟨by positivity, (div_le_one hepos).mpr hd⟩ + have hq : 12 * (A.card : ℝ) / D.edges.card ∈ Set.Icc (0 : ℝ) 1 := + ⟨by positivity, (div_le_one hepos).mpr (by linarith)⟩ + exact crossing_sampling_algebra hApos hvpos hepos (D.bipartite_sample_bound hP hx A hA _ _ hp hq) + +noncomputable def Drawing.cut (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : Drawing P := by + classical + exact ⟨D.vertices, D.edges.filter (fun e => bit F ω e.1 ≠ bit F ω e.2), + fun e he => D.right e (Finset.mem_filter.mp he).1, + fun e he => D.ends e (Finset.mem_filter.mp he).1⟩ + +noncomputable def Drawing.cutSide (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : Finset V := by + classical + exact D.vertices.filter (fun v => bit F ω v = true) + +omit [Fintype V] in +lemma Drawing.cutSide_vertices (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : + D.cutSide F ω ⊆ D.vertices := by + classical + exact Finset.filter_subset _ _ + +omit [Fintype V] in +lemma Drawing.cutSide_designated (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : + D.cutSide F ω ⊆ F := by + classical + intro v hv + have hh := (Finset.mem_filter.mp hv).2 + by_contra hn + simp [bit, hn] at hh + +omit [Fintype V] in +lemma Drawing.cut_bipartite (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : + (D.cut F ω).Bipartite (D.cutSide F ω) := by + classical + intro e he + have hh := Finset.mem_filter.mp he + have hv := D.ends _ hh.1 + cases h₁ : bit F ω e.1 <;> cases h₂ : bit F ω e.2 <;> + simp_all [Drawing.cutSide] + +lemma Drawing.cut_crossings_le (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : + (D.cut F ω).crossings.card ≤ D.crossings.card := by + classical + apply Finset.card_le_card + intro ef he + have hh := Finset.mem_filter.mp he + have hedges := Finset.mem_product.mp hh.1 + exact Finset.mem_filter.mpr ⟨Finset.mem_product.mpr + ⟨(Finset.mem_filter.mp hedges.1).1, (Finset.mem_filter.mp hedges.2).1⟩, hh.2⟩ + +omit [Fintype V] in +lemma Drawing.cut_edges (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : + (D.cut F ω).edges = D.edges.filter (fun e => bit F ω e.1 ≠ bit F ω e.2) := rfl + +omit [Fintype V] in +lemma Drawing.cut_card (D : Drawing P) (F : Finset V) (ω : ↥F → Bool) : + ((D.cut F ω).edges.card : ℝ) = + ∑ e ∈ D.edges, if bit F ω e.1 ≠ bit F ω e.2 then (1 : ℝ) else 0 := by + classical + rw [D.cut_edges F ω] + simp only [Finset.sum_boole] + +omit [Fintype V] in +lemma Drawing.expect_cut_card (D : Drawing P) (F : Finset V) + (hF : ∀ e ∈ D.edges, e.1 ∈ F ∨ e.2 ∈ F) : + expect (fun _ : ↥F => (1 : ℝ) / 2) + (fun ω => ((D.cut F ω).edges.card : ℝ)) = (D.edges.card : ℝ) / 2 := by + classical + simp_rw [D.cut_card] + rw [expect_sum] + have hc (e) (he : e ∈ D.edges) : + expect (fun _ : ↥F => (1 : ℝ) / 2) + (fun ω => if bit F ω e.1 ≠ bit F ω e.2 then (1 : ℝ) else 0) = 1 / 2 := by + apply expect_cut F _ (hF e he) + intro h + have hr := D.right e he + rw [h] at hr + exact lt_irrefl _ hr + rw [Finset.sum_congr rfl hc] + simp [div_eq_mul_inv] + +omit [Fintype V] in +lemma Drawing.exists_large_cut (D : Drawing P) (F : Finset V) + (hF : ∀ e ∈ D.edges, e.1 ∈ F ∨ e.2 ∈ F) : + ∃ ω : ↥F → Bool, (D.edges.card : ℝ) / 2 ≤ (D.cut F ω).edges.card := by + classical + have hp : ∀ v : ↥F, (1 : ℝ) / 2 ∈ Set.Icc (0 : ℝ) 1 := by intro v; norm_num + have hh := exists_ge_expect hp (fun ω => ((D.cut F ω).edges.card : ℝ)) + rw [D.expect_cut_card F hF] at hh + exact hh + +theorem Drawing.designated_dense (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) + (F : Finset V) (hFv : F ⊆ D.vertices) + (hF : ∀ e ∈ D.edges, e.1 ∈ F ∨ e.2 ∈ F) + (hd : 24 * (D.vertices.card : ℝ) ≤ D.edges.card) : + (D.edges.card : ℝ) ^ 3 ≤ 2304 * F.card * D.vertices.card * D.crossings.card := by + classical + obtain ⟨ω, hω⟩ := D.exists_large_cut F hF + have hv : (D.cut F ω).vertices = D.vertices := rfl + have hside := (D.cutSide_designated F ω).trans hFv + have hden : 12 * ((D.cut F ω).vertices.card : ℝ) ≤ (D.cut F ω).edges.card := by + rw [hv] + linarith + have hc := (D.cut F ω).bipartite_dense hP hx (D.cutSide F ω) (D.cut_bipartite F ω) + (by simpa only [hv] using hside) hden + rw [hv] at hc + have hm : ((D.cutSide F ω).card : ℝ) ≤ F.card := by + exact_mod_cast Finset.card_le_card (D.cutSide_designated F ω) + have hcr : ((D.cut F ω).crossings.card : ℝ) ≤ D.crossings.card := by + exact_mod_cast D.cut_crossings_le F ω + have hbound : ((D.cut F ω).edges.card : ℝ) ^ 3 ≤ + 288 * F.card * D.vertices.card * D.crossings.card := hc.trans (by gcongr) + calc (D.edges.card : ℝ) ^ 3 ≤ (2 * ((D.cut F ω).edges.card : ℝ)) ^ 3 := by gcongr; linarith + _ = 8 * ((D.cut F ω).edges.card : ℝ) ^ 3 := by ring + _ ≤ 8 * (288 * F.card * D.vertices.card * D.crossings.card) := by gcongr + _ = 2304 * F.card * D.vertices.card * D.crossings.card := by ring + +theorem Drawing.designated_crossing (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) + (F : Finset V) (hFv : F ⊆ D.vertices) + (hF : ∀ e ∈ D.edges, e.1 ∈ F ∨ e.2 ∈ F) : + (D.edges.card : ℝ) ^ 3 ≤ 2304 * F.card * D.vertices.card * D.crossings.card + + 13824 * (D.vertices.card : ℝ) ^ 3 := by + by_cases hd : 24 * (D.vertices.card : ℝ) ≤ D.edges.card + · exact (D.designated_dense hP hx F hFv hF hd).trans (le_add_of_nonneg_right (by positivity)) + · have he : (D.edges.card : ℝ) ≤ 24 * (D.vertices.card : ℝ) := (not_le.mp hd).le + calc (D.edges.card : ℝ) ^ 3 ≤ (24 * (D.vertices.card : ℝ)) ^ 3 := by gcongr + _ = 13824 * (D.vertices.card : ℝ) ^ 3 := by ring + _ ≤ 2304 * F.card * D.vertices.card * D.crossings.card + 13824 * (D.vertices.card : ℝ) ^ 3 := + le_add_of_nonneg_left (by positivity) + +end PlanarHalving.PlaneGraph + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Curves.lean b/lean/OAI/Combinatorics/HalvingLines/Curves.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6f5da777cc22880d1de392fd04b575221970e1b --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Curves.lean @@ -0,0 +1,328 @@ +import OAI.Combinatorics.HalvingLines.Boundary + +namespace OAI + +namespace PlanarHalving + +namespace Zoom + +open scoped NNReal Topology +open Filter + +lemma path_stays_inside {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] + (f : E → F) (γ : ℝ → E) (x : E) (h r : ℝ) + (hpos : 0 < h) (hγ : ContinuousOn γ (Set.Icc 0 1)) + (hγ₀ : γ 0 = 0) (hγ₁ : γ 1 = x) + (hsmall : ∀ t ∈ Set.Icc (0 : ℝ) 1, ‖f (γ t)‖ < r) + (hsphere : ∀ z : E, ‖z‖ = h → r ≤ ‖f z‖) : ‖x‖ < h := by + by_contra hn + have hx : h ≤ ‖x‖ := not_lt.mp hn + have hmem : h ∈ Set.Icc ‖γ 0‖ ‖γ 1‖ := by + simp only [hγ₀, hγ₁, norm_zero, Set.mem_Icc] + exact ⟨hpos.le, hx⟩ + obtain ⟨t, ht, hnorm⟩ := intermediate_value_Icc (by norm_num : (0 : ℝ) ≤ 1) hγ.norm hmem + exact (not_lt_of_ge (hsphere (γ t) hnorm)) (hsmall t ht) + +lemma inverse_bound {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : OpenPartialHomeomorph E E) (hrange : f.source = Set.univ) + (hz : f 0 = 0) (R r ε : ℝ) (hR : 0 ≤ R) (hε : 0 ≤ ε) + (hgap : R + ε < r) + (htarget : Metric.closedBall (0 : E) R ⊆ f.target) + (hnear : ∀ x : E, ‖x‖ = r → ‖f x - x‖ ≤ ε) + (y : E) (hy : ‖y‖ ≤ R) : ‖f.symm y‖ < r := by + have hinv₀ : f.symm 0 = 0 := by + calc + f.symm 0 = f.symm (f 0) := congrArg f.symm hz.symm + _ = 0 := f.left_inv (by rw [hrange]; trivial) + have hsmul (t : ℝ) (ht : t ∈ Set.Icc (0 : ℝ) 1) : ‖t • y‖ ≤ R := by + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht.1] + exact (mul_le_of_le_one_left (norm_nonneg y) ht.2).trans hy + have hpath : Set.MapsTo (fun t : ℝ => t • y) (Set.Icc 0 1) f.target := by + intro t ht + exact htarget (by simpa only [Metric.mem_closedBall, dist_zero_right] using hsmul t ht) + apply path_stays_inside f (fun t : ℝ => f.symm (t • y)) (f.symm y) r (r - ε) + (by linarith) + (f.continuousOn_symm.comp (continuous_id.smul continuous_const).continuousOn hpath) + · simpa only [zero_smul] using hinv₀ + · simp only [one_smul] + · intro t ht + rw [f.right_inv (hpath ht)] + have hb := hsmul t ht + linarith + · intro x hx + have he := hnear x hx + have hb : ‖x‖ ≤ ‖f x - x‖ + ‖f x‖ := by + calc + ‖x‖ = ‖(x - f x) + f x‖ := by rw [sub_add_cancel] + _ ≤ ‖x - f x‖ + ‖f x‖ := norm_add_le _ _ + _ = ‖f x - x‖ + ‖f x‖ := by rw [norm_sub_rev] + linarith + +lemma inverse_near_id {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : OpenPartialHomeomorph E E) (hrange : f.source = Set.univ) + (hz : f 0 = 0) (R r ε : ℝ) (hR : 0 ≤ R) (hε : 0 ≤ ε) + (hgap : R + ε < r) + (htarget : Metric.closedBall (0 : E) R ⊆ f.target) + (hnear : ∀ x : E, ‖x‖ ≤ r → ‖f x - x‖ ≤ ε) + (y : E) (hy : ‖y‖ ≤ R) : ‖f.symm y - y‖ ≤ ε := by + have hyT : y ∈ f.target := htarget (by + simpa only [Metric.mem_closedBall, dist_zero_right] using hy) + have hb := inverse_bound f hrange hz R r ε hR hε hgap htarget + (fun x hx => hnear x hx.le) y hy + have he := hnear (f.symm y) hb.le + rw [f.right_inv hyT, norm_sub_rev] at he + exact he + +lemma ray_image_leaves_ball {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (f : OpenPartialHomeomorph E E) (hrange : f.source = Set.univ) + (x v : E) (hv : v ≠ 0) (R : ℝ) + (htarget : Metric.closedBall (f x) R ⊆ f.target) : + ∃ t : ℝ, 0 ≤ t ∧ R < dist (f (x + t • v)) (f x) := by + have hc : IsCompact (f.symm '' Metric.closedBall (f x) R) := + (isCompact_closedBall (f x) R).image_of_continuousOn + (f.continuousOn_symm.mono htarget) + obtain ⟨C, hC, hbound⟩ := hc.isBounded.exists_pos_norm_le + have hvpos : 0 < ‖v‖ := norm_pos_iff.mpr hv + let t : ℝ := (C + ‖x‖ + 1) / ‖v‖ + have ht : 0 ≤ t := div_nonneg (by positivity) hvpos.le + refine ⟨t, ht, ?_⟩ + by_contra hn + have hmem : f (x + t • v) ∈ Metric.closedBall (f x) R := + not_lt.mp hn + have hxmem : x + t • v ∈ f.symm '' Metric.closedBall (f x) R := by + refine ⟨f (x + t • v), hmem, ?_⟩ + apply f.left_inv + rw [hrange] + trivial + have hnorm := hbound (x + t • v) hxmem + have htri : ‖t • v‖ ≤ ‖x + t • v‖ + ‖x‖ := by + calc + ‖t • v‖ = ‖(x + t • v) - x‖ := by congr 1; abel + _ ≤ ‖x + t • v‖ + ‖x‖ := norm_sub_le _ _ + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht, + show t * ‖v‖ = C + ‖x‖ + 1 from div_mul_cancel₀ _ (ne_of_gt hvpos)] at htri + linarith + +lemma line_parameter_levels {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (f : OpenPartialHomeomorph E E) (hrange : f.source = Set.univ) + (x v : E) (hv : v ≠ 0) (ℓ : E →L[ℝ] ℝ) (M R : ℝ) + (hM : 0 < M) + (hmono : StrictMono (fun t : ℝ => ℓ (f (x + t • v) - f x))) + (hcone : ∀ t : ℝ, + ‖f (x + t • v) - f x‖ ≤ M * |ℓ (f (x + t • v) - f x)|) + (htarget : Metric.closedBall (f x) (M * R) ⊆ f.target) + (s : ℝ) (hs : s ∈ Set.Icc (-R) R) : + ∃ t : ℝ, ℓ (f (x + t • v) - f x) = s := by + let φ : ℝ → ℝ := fun t => ℓ (f (x + t • v) - f x) + have hφ : Continuous φ := by + have hf : Continuous f := continuousOn_univ.mp + (by simpa only [← hrange] using f.continuousOn) + exact ℓ.continuous.comp + ((hf.comp (continuous_const.add (continuous_id.smul continuous_const))).sub + continuous_const) + obtain ⟨a, ha, hexit_pos⟩ := ray_image_leaves_ball f hrange x v hv (M * R) htarget + obtain ⟨b, hb, hexit_neg⟩ := ray_image_leaves_ball f hrange x (-v) (neg_ne_zero.mpr hv) + (M * R) htarget + have hpos : 0 ≤ φ a := by simpa [φ] using hmono.monotone ha + have hneg : φ (-b) ≤ 0 := by + simpa [φ] using hmono.monotone (neg_nonpos.mpr hb) + have haR : R < φ a := by + rw [dist_eq_norm] at hexit_pos + have hc := hcone a + change ‖f (x + a • v) - f x‖ ≤ M * |φ a| at hc + rw [abs_of_nonneg hpos] at hc + nlinarith + have hbR : φ (-b) < -R := by + rw [dist_eq_norm, smul_neg, ← neg_smul] at hexit_neg + have hc := hcone (-b) + change ‖f (x + (-b) • v) - f x‖ ≤ M * |φ (-b)| at hc + rw [abs_of_nonpos hneg] at hc + nlinarith + obtain ⟨t, _, ht⟩ := intermediate_value_Icc + (show -b ≤ a by linarith) hφ.continuousOn + (show s ∈ Set.Icc (φ (-b)) (φ a) from ⟨hbR.le.trans hs.1, hs.2.trans haR.le⟩) + exact ⟨t, ht⟩ + +lemma line_parameter_curve {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (f : OpenPartialHomeomorph E E) (hrange : f.source = Set.univ) + (x v : E) (hv : v ≠ 0) (ℓ : E →L[ℝ] ℝ) (M : ℝ≥0) (R : ℝ) + (hM : 0 < M) (hR : 0 ≤ R) + (hmono : StrictMono (fun t : ℝ => ℓ (f (x + t • v) - f x))) + (hcone : ∀ t u : ℝ, + ‖f (x + t • v) - f (x + u • v)‖ ≤ + M * |ℓ (f (x + t • v) - f (x + u • v))|) + (htarget : Metric.closedBall (f x) (M * R) ⊆ f.target) : + ∃ γ : Set.Icc (-R) R → E, LipschitzWith M γ ∧ + (∀ s, ∃ t : ℝ, γ s = f (x + t • v)) ∧ + (∀ s, ℓ (γ s - f x) = s) ∧ + γ ⟨0, ⟨neg_nonpos.mpr hR, hR⟩⟩ = f x := by + have hlevels (s : Set.Icc (-R) R) : + ∃ t : ℝ, ℓ (f (x + t • v) - f x) = (s : ℝ) := + line_parameter_levels f hrange x v hv ℓ M R hM hmono + (fun t => by simpa only [zero_smul, add_zero] using hcone t 0) htarget s s.property + choose t ht using hlevels + let γ : Set.Icc (-R) R → E := fun s => f (x + t s • v) + have hγ : LipschitzWith M γ := by + apply LipschitzWith.of_dist_le_mul + intro s u + have he : ℓ (γ s - γ u) = (s : ℝ) - u := by + calc + ℓ (γ s - γ u) = ℓ (γ s - f x) - ℓ (γ u - f x) := by + simp only [map_sub] + ring + _ = (s : ℝ) - u := by rw [ht s, ht u] + rw [dist_eq_norm, Subtype.dist_eq, Real.dist_eq, ← he] + exact hcone (t s) (t u) + refine ⟨γ, hγ, fun s => ⟨t s, rfl⟩, ht, ?_⟩ + let z : Set.Icc (-R) R := ⟨0, ⟨neg_nonpos.mpr hR, hR⟩⟩ + have hzero := hcone (t z) 0 + simp only [zero_smul, add_zero] at hzero + rw [ht z, show (z : ℝ) = 0 from rfl, abs_zero, mul_zero] at hzero + exact sub_eq_zero.mp (norm_eq_zero.mp (le_antisymm hzero (norm_nonneg _))) + +lemma intersects_level_graph {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] (ℓ ψ : E →L[ℝ] ℝ) + (hjoint : Function.Injective (fun x : E => (ℓ x, ψ x))) + (g β : ℝ → E) (a b c d : ℝ) (hcd : c ≤ d) + (hg : ContinuousOn g (Set.Icc a b)) + (hβ : ContinuousOn β (Set.Icc c d)) + (hlevel : ∀ s ∈ Set.Icc a b, ℓ (g s) = s) + (hinside : ∀ t ∈ Set.Icc c d, ℓ (β t) ∈ Set.Icc a b) + (hlower : ψ (β c) ≤ ψ (g (ℓ (β c)))) + (hupper : ψ (g (ℓ (β d))) ≤ ψ (β d)) : + ∃ t ∈ Set.Icc c d, ∃ s ∈ Set.Icc a b, β t = g s := by + let H : ℝ → ℝ := fun t => ψ (β t) - ψ (g (ℓ (β t))) + have hH : ContinuousOn H (Set.Icc c d) := + (ψ.continuous.comp_continuousOn hβ).sub + (ψ.continuous.comp_continuousOn + (hg.comp (ℓ.continuous.comp_continuousOn hβ) hinside)) + have hmem : (0 : ℝ) ∈ Set.Icc (H c) (H d) := + ⟨sub_nonpos.mpr hlower, sub_nonneg.mpr hupper⟩ + obtain ⟨t, ht, hzero⟩ := intermediate_value_Icc hcd hH hmem + refine ⟨t, ht, ℓ (β t), hinside t ht, hjoint ?_⟩ + apply Prod.ext + · exact (hlevel _ (hinside t ht)).symm + · exact sub_eq_zero.mp hzero + +lemma bounded_parameter_tendsto {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (a b : ℕ → E) (a₀ v : E) (ℓ : E →L[ℝ] ℝ) (s B : ℝ) + (ha : Tendsto a atTop (𝓝 a₀)) + (hbound : ∀ᶠ n in atTop, ‖b n - a n‖ ≤ B) + (hlevel : ∀ᶠ n in atTop, ℓ (b n - a n) = s) (hv : ℓ v ≠ 0) + (hdirection : ∀ (ρ : ℕ → ℕ), StrictMono ρ → ∀ b₀ : E, + Tendsto (b ∘ ρ) atTop (𝓝 b₀) → ∃ r : ℝ, b₀ - a₀ = r • v) : + Tendsto b atTop (𝓝 (a₀ + (s / ℓ v) • v)) := by + obtain ⟨C, _, hC⟩ := (Metric.isBounded_range_of_tendsto a ha).exists_pos_norm_le + have hb : ∀ᶠ n in atTop, b n ∈ Metric.closedBall (0 : E) (B + C) := by + filter_upwards [hbound] with n hn + rw [Metric.mem_closedBall, dist_zero_right] + calc + ‖b n‖ = ‖(b n - a n) + a n‖ := by rw [sub_add_cancel] + _ ≤ ‖b n - a n‖ + ‖a n‖ := norm_add_le _ _ + _ ≤ B + C := add_le_add hn (hC _ (Set.mem_range_self n)) + apply (isCompact_closedBall (0 : E) (B + C)).tendsto_nhds_of_unique_mapClusterPt hb + intro b₀ _ hcluster + obtain ⟨ρ, hρ, hlim⟩ := hcluster.tendsto_subseq + obtain ⟨r, hr⟩ := hdirection ρ hρ b₀ hlim + have he : ℓ (b₀ - a₀) = s := by + have hh : Tendsto (fun _ : ℕ => s) atTop (𝓝 (ℓ (b₀ - a₀))) := by + have hm := (ℓ.continuous.tendsto (b₀ - a₀)).comp + (hlim.sub (ha.comp hρ.tendsto_atTop)) + change Tendsto (fun n => ℓ (b (ρ n) - a (ρ n))) atTop + (𝓝 (ℓ (b₀ - a₀))) at hm + exact hm.congr' (hρ.tendsto_atTop.eventually hlevel) + exact tendsto_nhds_unique hh tendsto_const_nhds + have hcoef : r = s / ℓ v := by + apply (eq_div_iff hv).mpr + simpa only [hr, map_smul, smul_eq_mul] using he + rw [sub_eq_iff_eq_add] at hr + simpa only [hcoef, add_comm] using hr + +lemma parameter_curves_tendsto {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (R : ℝ) (hR : 0 ≤ R) (γ : ℕ → Set.Icc (-R) R → E) + (a : ℕ → E) (a₀ v : E) (ℓ : E →L[ℝ] ℝ) (M : ℝ≥0) + (ha : Tendsto a atTop (𝓝 a₀)) (hγ : ∀ n, LipschitzWith M (γ n)) + (hzero : ∀ n, γ n ⟨0, ⟨neg_nonpos.mpr hR, hR⟩⟩ = a n) + (hlevel : ∀ᶠ n in atTop, ∀ s, ℓ (γ n s - a n) = s) (hv : ℓ v ≠ 0) + (hdirection : ∀ s, ∀ (ρ : ℕ → ℕ), StrictMono ρ → ∀ b₀ : E, + Tendsto (fun n => γ (ρ n) s) atTop (𝓝 b₀) → ∃ r : ℝ, b₀ - a₀ = r • v) : + TendstoUniformly γ (fun s => a₀ + ((s : ℝ) / ℓ v) • v) atTop := by + have hp : ∀ s : Set.Icc (-R) R, + Tendsto (fun n => γ n s) atTop (𝓝 (a₀ + ((s : ℝ) / ℓ v) • v)) := by + intro s + apply bounded_parameter_tendsto a (fun n => γ n s) a₀ v ℓ s (M * |(s : ℝ)|) + ha ?_ (hlevel.mono fun _ hn => hn s) hv (hdirection s) + apply Filter.Eventually.of_forall + intro n + have hb := (hγ n).dist_le_mul s ⟨0, ⟨neg_nonpos.mpr hR, hR⟩⟩ + simpa only [hzero, dist_eq_norm, Subtype.dist_eq, Real.dist_eq, sub_zero, + Real.norm_eq_abs] using hb + have heq : Equicontinuous γ := (LipschitzWith.uniformEquicontinuous γ M hγ).equicontinuous + exact UniformFun.tendsto_iff_tendstoUniformly.mp + ((heq.tendsto_uniformFun_iff_pi atTop _).mpr (tendsto_pi_nhds.mpr hp)) + +noncomputable def coneLevel (Q : Point ≃L[ℝ] Point) : Point →L[ℝ] ℝ := + ((ContinuousLinearMap.fst ℝ ℝ ℝ) + (ContinuousLinearMap.snd ℝ ℝ ℝ)).comp + Q.toContinuousLinearMap + +lemma coneLevel_apply (Q : Point ≃L[ℝ] Point) (x : Point) : + coneLevel Q x = (Q x).1 + (Q x).2 := rfl + +lemma norm_le_coneLevel (Q : Point ≃L[ℝ] Point) (q : Point) + (hq₁ : 0 ≤ (Q q).1) (hq₂ : 0 ≤ (Q q).2) : + ‖q‖ ≤ ‖Q.symm.toContinuousLinearMap‖ * coneLevel Q q := by + have hn : ‖Q q‖ ≤ coneLevel Q q := by + rw [Prod.norm_def, Real.norm_eq_abs, Real.norm_eq_abs, + abs_of_nonneg hq₁, abs_of_nonneg hq₂, coneLevel_apply] + exact max_le (le_add_of_nonneg_right hq₂) (le_add_of_nonneg_left hq₁) + calc + ‖q‖ = ‖Q.symm (Q q)‖ := by rw [Q.symm_apply_apply] + _ ≤ ‖Q.symm.toContinuousLinearMap‖ * ‖Q q‖ := + Q.symm.toContinuousLinearMap.le_opNorm _ + _ ≤ ‖Q.symm.toContinuousLinearMap‖ * coneLevel Q q := + mul_le_mul_of_nonneg_left hn (norm_nonneg _) + +lemma coneLevel_strictMono (Q : Point ≃L[ℝ] Point) (g : ℝ → Point) + (hg : Function.Injective g) + (h₁ : Monotone (fun t => (Q (g t)).1)) + (h₂ : Monotone (fun t => (Q (g t)).2)) : + StrictMono (fun t => coneLevel Q (g t)) := by + intro t u htu + have ha := h₁ htu.le + have hb := h₂ htu.le + simp only [coneLevel_apply] + apply lt_of_le_of_ne (add_le_add ha hb) + intro he + have hpair : Q (g t) = Q (g u) := Prod.ext (by linarith) (by linarith) + exact htu.ne (hg (Q.injective hpair)) + +lemma coneLevel_chord (Q : Point ≃L[ℝ] Point) (g : ℝ → Point) + (h₁ : Monotone (fun t => (Q (g t)).1)) + (h₂ : Monotone (fun t => (Q (g t)).2)) (t u : ℝ) : + ‖g t - g u‖ ≤ ‖Q.symm.toContinuousLinearMap‖ * + |coneLevel Q (g t - g u)| := by + have forward (a b : ℝ) (hab : a ≤ b) : + ‖g b - g a‖ ≤ ‖Q.symm.toContinuousLinearMap‖ * + coneLevel Q (g b - g a) := by + apply norm_le_coneLevel + · rw [map_sub] + exact sub_nonneg.mpr (h₁ hab) + · rw [map_sub] + exact sub_nonneg.mpr (h₂ hab) + rcases le_total u t with hut | htu + · exact (forward u t hut).trans + (mul_le_mul_of_nonneg_left (le_abs_self _) (norm_nonneg _)) + · rw [norm_sub_rev, ← abs_neg, ← map_neg, neg_sub] + exact (forward t u htu).trans + (mul_le_mul_of_nonneg_left (le_abs_self _) (norm_nonneg _)) + +end Zoom + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Decomposition.lean b/lean/OAI/Combinatorics/HalvingLines/Decomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a872362aaf75935561f11771e5d4dfd78c7e086 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Decomposition.lean @@ -0,0 +1,467 @@ +import OAI.Combinatorics.HalvingLines.Greedy + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Sweep +open Set + +lemma state_eq_insert_below {n k : ℕ} {P : Fin n → Point} (hP : GeneralPosition P) + {s : ℝ} {M : Finset (Fin n)} (hM : Separates P s M) (hcard : M.card=k) + {a b : Fin n} (hab : a≠b) (hx : (P a).1≠(P b).1) + (hR : Refines P (slope (P a) (P b)) s) + (hs : projection s (P a) ne_of_lt hx (congrArg (fun x => (P x).1) he) + have he := state_eq_insert_below hP.1 (S.separates i.castSucc) (S.card_marks i.castSucc) + hab' hx.ne hR ho.1 hkpos hb + intro hsame + have ha : a∈S.marks i.succ := by rw [← hsame,he];exact Finset.mem_insert_self _ _ + have hb' : b∉S.marks i.succ := by + rw [← hsame,he,Finset.mem_insert] + simp only [mem_belowSet,tied_projection (P a) (P b) hx.ne,lt_self_iff_false,or_false] + exact hab'.symm + exact not_lt_of_gt ho.2 (S.separates i.succ a ha b hb') + rcases lt_or_gt_of_ne (hP.2.1 a b hab) with hx | hx + · exact aux a b hx hc hbelow + · apply aux b a hx + · simpa only [slope_symm (P b) (P a)] using hc + · simpa only [belowCount_symm (hP.2.1 a b hab)] using hbelow + +noncomputable def switchPairs {n : ℕ} (P : Fin n → Point) (k : ℕ) : Finset (Fin n × Fin n) := + Finset.univ.filter (fun ij => ij.1 < ij.2 ∧ 0 S.marks i.castSucc≠S.marks i.succ) + +lemma States.mem_changeSteps {n T k : ℕ} {P : Fin n → Point} (S : @States n T k P) (i : Fin T) : + i∈S.changeSteps ↔ S.marks i.castSucc≠S.marks i.succ := by + classical + simp only [States.changeSteps,Finset.mem_filter,Finset.mem_univ,true_and] + +lemma switchCount_le_changes {n k : ℕ} {P : Fin n → Point} (hP : Generic P) (hk : k≤n) : + switchCount P k≤(states P hP hk).changeSteps.card := by + classical + let T := traversal (criticalSlopes P) + let S := states P hP hk + have hex (p : ↥(switchPairs P k)) : ∃ i : Fin T.size, i∈S.changeSteps ∧ + T.cut i.succ.castSucc=slope (P p.val.1) (P p.val.2) := by + have hp := (mem_switchPairs P k p.val).mp p.property + obtain ⟨i,hi⟩ := (T.critical _).mp (mem_criticalSlopes P hp.1.ne) + exact ⟨i,(S.mem_changeSteps i).mpr (states_change_of_pair hP hk i hp.1.ne hi hp.2.1 hp.2.2.2),hi⟩ + choose f hf hs using hex + let g : ↥(switchPairs P k) → ↥S.changeSteps := fun p => ⟨f p,hf p⟩ + have hg : Function.Injective g := by + intro p q h + have he : f p=f q := congrArg Subtype.val h + have heq := (hs p).symm.trans ((congrArg (fun j => T.cut j.succ.castSucc) he).trans (hs q)) + have hp := (mem_switchPairs P k p.val).mp p.property + have hq := (mem_switchPairs P k q.val).mp q.property + obtain ⟨h1,h2⟩ := hP.2.2.1 _ _ _ _ hp.1 hq.1 heq + exact Subtype.ext (Prod.ext h1 h2) + change (switchPairs P k).card≤S.changeSteps.card + simpa only [Fintype.card_coe] using Fintype.card_le_of_injective g hg + +lemma local_change_event {n k : ℕ} {P : Fin n → Point} (hP : Generic P) + {s t c : ℝ} {M N : Finset (Fin n)} + (hM : Separates P s M) (hN : Separates P t N) (hcardM : M.card=k) (hcardN : N.card=k) + (hRs : Refines P c s) (hRt : Refines P c t) (hne : M≠N) : + ∃ p∈switchPairs P k, slope (P p.1) (P p.2)=c := by + classical + have hneM : (M\N).Nonempty := by + by_contra hh + have hsub : M⊆N := Finset.sdiff_eq_empty_iff_subset.mp (Finset.not_nonempty_iff_eq_empty.mp hh) + exact hne (Finset.eq_of_subset_of_card_le hsub (hcardN.trans hcardM.symm).le) + obtain ⟨a,ha⟩ := hneM + have hneN : (N\M).Nonempty := by + rw [← Finset.card_pos,← Finset.card_sdiff_comm (hcardM.trans hcardN.symm)] + exact Finset.card_pos.mpr ⟨a,ha⟩ + obtain ⟨b,hb⟩ := hneN + have haM := (Finset.mem_sdiff.mp ha).1 + have haN := (Finset.mem_sdiff.mp ha).2 + have hbN := (Finset.mem_sdiff.mp hb).1 + have hbM := (Finset.mem_sdiff.mp hb).2 + have hab : a≠b := fun he => hbM (he ▸ haM) + have hc : projection c (P a)=projection c (P b) := by + apply le_antisymm + · by_contra h + exact not_lt_of_gt (hM a haM b hbM) (hRs b a (lt_of_not_ge h)) + · by_contra h + exact not_lt_of_gt (hN b hbN a haN) (hRt a b (lt_of_not_ge h)) + have hsc : c=slope (P a) (P b) := (projection_eq_iff_slope (hP.2.1 a b hab)).mp hc + have hbelow : belowCount P a b=k-1 := by + rw [← card_belowSet,belowSet_eq_erase hP.1 hM haM hbM (hP.2.1 a b hab) (hsc ▸ hRs), + Finset.card_erase_of_mem haM,hcardM] + have hkpos : 0 (A.orderIsoOfFin rfl i : Fin n) + +lemma subsetIndex_strictMono {n : ℕ} (A : Finset (Fin n)) : StrictMono (subsetIndex A) := + fun _ _ h => (A.orderIsoOfFin rfl).strictMono h + +lemma subsetIndex_mem {n : ℕ} (A : Finset (Fin n)) (i : Fin A.card) : subsetIndex A i∈A := + (A.orderIsoOfFin rfl i).property + +lemma subsetIndex_surj {n : ℕ} (A : Finset (Fin n)) {x : Fin n} (hx : x∈A) : + ∃ i, subsetIndex A i=x := by + exact ⟨(A.orderIsoOfFin rfl).symm ⟨x,hx⟩,congrArg Subtype.val ((A.orderIsoOfFin rfl).apply_symm_apply ⟨x,hx⟩)⟩ + +noncomputable def subsetPoints {n : ℕ} (P : Fin n → Point) (A : Finset (Fin n)) : Fin A.card → Point := + P∘subsetIndex A + +lemma subsetPoints_generic {n : ℕ} {P : Fin n → Point} (hP : Generic P) (A : Finset (Fin n)) : + Generic (subsetPoints P A) := hP.comp_strictMono (subsetIndex_strictMono A) + +noncomputable def restrictMarks {n : ℕ} (A M : Finset (Fin n)) : Finset (Fin A.card) := + Finset.univ.filter (fun i => subsetIndex A i∈M) + +lemma mem_restrictMarks {n : ℕ} (A M : Finset (Fin n)) (i : Fin A.card) : + i∈restrictMarks A M ↔ subsetIndex A i∈M := by + classical + simp only [restrictMarks,Finset.mem_filter,Finset.mem_univ,true_and] + +lemma card_restrictMarks {n : ℕ} (A M : Finset (Fin n)) : + (restrictMarks A M).card=(M∩A).card := by + classical + have he : (restrictMarks A M).image (subsetIndex A)=M∩A := by + ext x + constructor + · intro hx + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hx + exact Finset.mem_inter.mpr ⟨(mem_restrictMarks A M i).mp hi,subsetIndex_mem A i⟩ + · intro hx + obtain ⟨i,rfl⟩ := subsetIndex_surj A (Finset.mem_inter.mp hx).2 + exact Finset.mem_image.mpr ⟨i,(mem_restrictMarks A M i).mpr (Finset.mem_inter.mp hx).1,rfl⟩ + rw [← he,Finset.card_image_of_injective _ (subsetIndex_strictMono A).injective] + +lemma restrictMarks_separates {n : ℕ} {P : Fin n → Point} {s : ℝ} {M : Finset (Fin n)} + (hM : Separates P s M) (A : Finset (Fin n)) : + Separates (subsetPoints P A) s (restrictMarks A M) := by + intro i hi j hj + exact hM _ ((mem_restrictMarks A M i).mp hi) _ (fun h => hj ((mem_restrictMarks A M j).mpr h)) + +lemma Refines.subset {n : ℕ} {P : Fin n → Point} {c s : ℝ} (hR : Refines P c s) + (A : Finset (Fin n)) : Refines (subsetPoints P A) c s := fun _ _ h => hR _ _ h + +variable {n T k : ℕ} {P : Fin n → Point} + +lemma States.restrict_activity_card (S : @States n T k P) + {u v : Fin (T+1)} (huv : u ≤ v) {i : Fin (T+1)} (hui : u ≤ i) (hiv : i ≤ v) : + (restrictMarks (S.intervalActivity u v huv) (S.marks i)).card= + ((S.marks u)∩S.intervalActivity u v huv).card := by + classical + let A := S.intervalActivity u v huv + have he : S.marks i\A=S.marks u\A := by + ext x + simp only [Finset.mem_sdiff] + by_cases hx : x∈A + · simp [hx] + · rw [S.outside_activity_constant huv hx hui hiv] + have h1 := Finset.card_inter_add_card_sdiff (S.marks i) A + have h2 := Finset.card_inter_add_card_sdiff (S.marks u) A + rw [S.card_marks] at h1 h2 + rw [he] at h1 + rw [card_restrictMarks] + change (S.marks i∩A).card=(S.marks u∩A).card + omega + +lemma States.restrict_activity_change (S : @States n T k P) + {u v : Fin (T+1)} (huv : u ≤ v) {i j : Fin (T+1)} + (hui : u ≤ i) (hiv : i ≤ v) (huj : u ≤ j) (hjv : j ≤ v) + (hne : S.marks i≠S.marks j) : + restrictMarks (S.intervalActivity u v huv) (S.marks i)≠ + restrictMarks (S.intervalActivity u v huv) (S.marks j) := by + classical + intro he + apply hne + ext x + by_cases hx : x∈S.intervalActivity u v huv + · obtain ⟨a,rfl⟩ := subsetIndex_surj _ hx + exact (mem_restrictMarks _ _ a).symm.trans ((congrArg (fun M => a∈M) he).to_iff.trans (mem_restrictMarks _ _ a)) + · exact (S.outside_activity_constant huv hx hui hiv).trans (S.outside_activity_constant huv hx huj hjv).symm + +noncomputable def States.blockSteps (S : @States n T k P) (u v : Fin (T+1)) : Finset (Fin T) := + S.changeSteps.filter (fun i => u ≤ i.castSucc ∧ i.succ ≤ v) + +lemma States.mem_blockSteps (S : @States n T k P) (u v : Fin (T+1)) (i : Fin T) : + i∈S.blockSteps u v ↔ i∈S.changeSteps ∧ u ≤ i.castSucc ∧ i.succ ≤ v := by + classical + simp only [States.blockSteps,Finset.mem_filter] + +lemma card_le_of_injective_labels {α β γ : Type*} [DecidableEq α] [DecidableEq β] + (A : Finset α) (B : Finset β) (f : α → γ) (g : β → γ) + (hf : Set.InjOn f A) (hex : ∀ a∈A, ∃ b∈B, g b=f a) : A.card≤B.card := by + classical + choose h hh he using (fun a : ↥A => hex a a.property) + let F : ↥A → ↥B := fun a => ⟨h a,hh a⟩ + have hF : Function.Injective F := by + intro a b hab + have hh' : h a=h b := congrArg Subtype.val hab + exact Subtype.ext (hf a.property b.property ((he a).symm.trans ((congrArg g hh').trans (he b)))) + simpa only [Fintype.card_coe] using Fintype.card_le_of_injective F hF + +lemma block_step_event {n k : ℕ} {P : Fin n → Point} (hP : Generic P) (hk : k≤n) + {u v : Fin ((traversal (criticalSlopes P)).size+1)} (huv : u ≤ v) + {i : Fin (traversal (criticalSlopes P)).size} (hi : i∈(states P hP hk).blockSteps u v) : + let A := (states P hP hk).intervalActivity u v huv + let r := ((states P hP hk).marks u∩A).card + ∃ p∈switchPairs (subsetPoints P A) r, + slope (subsetPoints P A p.1) (subsetPoints P A p.2)=(traversal (criticalSlopes P)).cut i.succ.castSucc := by + let T := traversal (criticalSlopes P) + let S := states P hP hk + let A := S.intervalActivity u v huv + have hi' := (S.mem_blockSteps u v i).mp hi + have hs := T.sample_refines hP i + exact local_change_event (subsetPoints_generic hP A) + (restrictMarks_separates (S.separates i.castSucc) A) + (restrictMarks_separates (S.separates i.succ) A) + (S.restrict_activity_card huv hi'.2.1 ((Fin.castSucc_le_succ _).trans hi'.2.2)) + (S.restrict_activity_card huv (hi'.2.1.trans (Fin.castSucc_le_succ _)) hi'.2.2) + (hs.1.subset A) (hs.2.subset A) + (S.restrict_activity_change huv hi'.2.1 ((Fin.castSucc_le_succ _).trans hi'.2.2) + (hi'.2.1.trans (Fin.castSucc_le_succ _)) hi'.2.2 ((S.mem_changeSteps _).mp hi'.1)) + +lemma block_count_le {n k : ℕ} {P : Fin n → Point} (hP : Generic P) (hk : k≤n) + {u v : Fin ((traversal (criticalSlopes P)).size+1)} (huv : u ≤ v) : + ∃ r : ℕ, r≤((states P hP hk).intervalActivity u v huv).card ∧ + ((states P hP hk).blockSteps u v).card≤ + switchCount (subsetPoints P ((states P hP hk).intervalActivity u v huv)) r := by + classical + let T := traversal (criticalSlopes P) + let S := states P hP hk + let A := S.intervalActivity u v huv + let r := (S.marks u∩A).card + refine ⟨r,(Finset.card_le_card (Finset.inter_subset_right)),?_⟩ + change (S.blockSteps u v).card≤(switchPairs (subsetPoints P A) r).card + apply card_le_of_injective_labels _ _ (fun i => T.cut i.succ.castSucc) + (fun p => slope (subsetPoints P A p.1) (subsetPoints P A p.2)) + · intro i _ j _ he + exact Fin.succ_inj.mp (Fin.castSucc_inj.mp (T.increasing.injective he)) + · exact fun i hi => block_step_event hP hk huv hi + +end PlanarHalving.Sweep + +namespace PlanarHalving.Sweep +open Set +variable {n T k : ℕ} {P : Fin n → Point} + +lemma States.blockSteps_self (S : @States n T k P) (u : Fin (T+1)) : S.blockSteps u u=∅ := by + classical + apply Finset.eq_empty_iff_forall_notMem.mpr + intro i hi + have h := (S.mem_blockSteps u u i).mp hi + exact not_lt_of_ge (h.2.2.trans h.2.1) (Fin.castSucc_lt_succ (i:=i)) + +lemma States.blockSteps_all (S : @States n T k P) : S.blockSteps 0 (Fin.last T)=S.changeSteps := by + classical + ext i + simp only [S.mem_blockSteps,Fin.zero_le,Fin.le_last,and_true] + +lemma States.blockSteps_card_add (S : @States n T k P) {u v w : Fin (T+1)} + (huv : u ≤ v) (hvw : v ≤ w) : + (S.blockSteps u v).card+(S.blockSteps v w).card=(S.blockSteps u w).card := by + classical + have hdis : Disjoint (S.blockSteps u v) (S.blockSteps v w) := by + apply Finset.disjoint_left.mpr + intro i hi hj + have hi' := (S.mem_blockSteps u v i).mp hi + have hj' := (S.mem_blockSteps v w i).mp hj + exact not_lt_of_ge (hi'.2.2.trans hj'.2.1) (Fin.castSucc_lt_succ (i:=i)) + have he : S.blockSteps u v ∪ S.blockSteps v w=S.blockSteps u w := by + ext i + simp only [Finset.mem_union,S.mem_blockSteps] + constructor + · rintro (⟨hi,hu,hv⟩ | ⟨hi,hv,hw⟩) + · exact ⟨hi,hu,hv.trans hvw⟩ + · exact ⟨hi,huv.trans hv,hw⟩ + · rintro ⟨hi,hu,hw⟩ + by_cases h : i.succ ≤ v + · exact Or.inl ⟨hi,hu,h⟩ + · exact Or.inr ⟨hi,(by change v.val ≤ i.val;change ¬i.val+1 ≤ v.val at h;omega),hw⟩ + rw [← he,Finset.card_union_of_disjoint hdis] + +lemma States.sum_blockSteps (S : @States n T k P) (m : ℕ) + (f : Fin (m+1) → Fin (T+1)) (hf : Monotone f) : + ∑ j : Fin m, (S.blockSteps (f j.castSucc) (f j.succ)).card= + (S.blockSteps (f 0) (f (Fin.last m))).card := by + induction m with + | zero => simp [S.blockSteps_self] + | succ m ih => + rw [Fin.sum_univ_castSucc] + have hh := ih (fun j : Fin (m+1) => f j.castSucc) (fun _ _ h => hf (Fin.castSucc_le_castSucc_iff.mpr h)) + simp only [Fin.castSucc_succ] at hh + rw [hh] + exact S.blockSteps_card_add (hf (Fin.zero_le _)) (hf (Fin.castSucc_le_succ _)) + +noncomputable def States.ActivityGreedy.fullIndex (S : @States n T k P) {s : Fin (T+1)} {b : ℕ} + (G : S.ActivityGreedy s b) : Fin (G.count+2) → Fin (T+1) := + Fin.snoc G.index (Fin.last T) + +lemma States.ActivityGreedy.fullIndex_mono (S : @States n T k P) {s : Fin (T+1)} {b : ℕ} + (G : S.ActivityGreedy s b) : Monotone (G.fullIndex S) := by + intro i j hij + revert hij + refine Fin.lastCases ?_ (fun j => ?_) j + · intro _ + simpa only [States.ActivityGreedy.fullIndex,Fin.snoc_last] using (Fin.le_last (G.fullIndex S i)) + · refine Fin.lastCases ?_ (fun i => ?_) i + · intro hij + exact False.elim (not_le_of_gt (Fin.castSucc_lt_last j) hij) + · intro hij + simpa only [States.ActivityGreedy.fullIndex,Fin.snoc_castSucc] using G.increasing.monotone (Fin.castSucc_le_castSucc_iff.mp hij) + +lemma States.ActivityGreedy.fullIndex_first (S : @States n T k P) {s : Fin (T+1)} {b : ℕ} + (G : S.ActivityGreedy s b) : G.fullIndex S 0=s := by + simpa only [States.ActivityGreedy.fullIndex,←Fin.castSucc_zero,Fin.snoc_castSucc] using G.first + +lemma States.ActivityGreedy.fullIndex_last (S : @States n T k P) {s : Fin (T+1)} {b : ℕ} + (G : S.ActivityGreedy s b) : G.fullIndex S (Fin.last (G.count+1))=Fin.last T := Fin.snoc_last _ _ + +lemma States.ActivityGreedy.fullIndex_activity (S : @States n T k P) {s : Fin (T+1)} {b : ℕ} + (G : S.ActivityGreedy s b) (j : Fin (G.count+1)) : + S.activitySize (G.fullIndex S j.castSucc) (G.fullIndex S j.succ)≤b+1 := by + refine Fin.lastCases ?_ (fun i => ?_) j + · simpa only [States.ActivityGreedy.fullIndex,Fin.snoc_castSucc,Fin.succ_last,Fin.snoc_last] using G.tail.le.trans (Nat.le_succ b) + · simpa only [States.ActivityGreedy.fullIndex,←Fin.castSucc_succ,Fin.snoc_castSucc] using G.upper i + +lemma activity_decomposition {n k : ℕ} {P : Fin n → Point} (hP : Generic P) (hk : k≤n) + {b : ℕ} (hb : 0 hcount j) + +end PlanarHalving.Sweep + +namespace PlanarHalving.Sweep + +lemma division_scale {n q : ℕ} (hq : 4≤q) (hn : 4*q≤n) : + let b := n/q-1 + 0 (F n).R) atTop atTop) + (hM : Tendsto (fun n => (F n).a*(F n).n) atTop atTop) + {A B : Window} (hAB : Disjoint (carrier A) (carrier B)) : + (L.crossings A B : Measure Labels).map (fun z => ((z A : ℝ),(z B : ℝ))) ≪ volume := by + rcases before_or_before hAB with hab | hba + · exact h.crossing_real_projection hR hM hab + · have hp : Measure.QuasiMeasurePreserving (fun z : Labels => ((z B : ℝ),(z A : ℝ))) + (L.crossings B A : Measure Labels) volume := + ⟨by fun_prop,h.crossing_real_projection hR hM hba⟩ + have hswap : Measure.QuasiMeasurePreserving (Prod.swap : Point → Point) volume volume := + (Measure.measurePreserving_swap (μ := (volume : Measure ℝ)) (ν := (volume : Measure ℝ))).quasiMeasurePreserving + have hh := (hswap.comp hp).absolutelyContinuous + simpa only [Function.comp_def, Prod.swap_prod_mk, ← h.crossings_comm A B] using hh + +lemma Converges.rank_regular_ae {F : ℕ → Configuration} {L : Data} (_h : Converges F L) + {K A B : Window} (ν : Measure Labels) (hp : ν ≪ (L.points : Measure Labels)) + (hproj : ν.map (pairCoordinates true A B) ≪ volume) + (G : Subwindows K → Point → I) + (hd : ∀ i, ∀ᵐ p ∂(volume : Measure Point), DifferentiableAt ℝ (fun x => (G i x : ℝ)) p) + (hid : ∀ i z, z ∈ (L.points : Measure Labels).support → + ContinuousAt (G i) (pairCoordinates true A B z) → + z i.val = G i (pairCoordinates true A B z)) : + ∀ᵐ z ∂ν, ∀ i, DifferentiableAt ℝ (fun x => (G i x : ℝ)) (pairCoordinates true A B z) ∧ + z i.val = G i (pairCoordinates true A B z) := by + have hq : Measure.QuasiMeasurePreserving (pairCoordinates true A B) ν volume := + ⟨(continuous_pairCoordinates true A B).measurable,hproj⟩ + have hda := hq.ae ((ae_all_iff).mpr hd) + have hs : ∀ᵐ z ∂ν, z ∈ (L.points : Measure Labels).support := hp.ae_le Measure.support_mem_ae + filter_upwards [hda,hs] with z hz hzs i + refine ⟨hz i,hid i z hzs ?_⟩ + exact ((hz i).continuousAt).codRestrict (fun x => (G i x).property) + +lemma Converges.rank_independent_ae {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + (hM : Tendsto (fun n => (F n).a*(F n).n) atTop atTop) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4/(((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3/(((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + {K A B : Window} (G : Subwindows K → Point → I) : + ∀ᵐ z ∂(L.edge : Measure Labels), + (∀ i, DifferentiableAt ℝ (fun x => (G i x : ℝ)) (pairCoordinates true A B z) ∧ + z i.val = G i (pairCoordinates true A B z)) → + ∀ J : Subwindows K, L.conditional z (carrier J.val) ≠ 0 → + ∃ i j : Subwindows K, carrier i.val ⊆ carrier J.val ∧ + carrier j.val ⊆ carrier J.val ∧ Disjoint (carrier i.val) (carrier j.val) ∧ + Function.Injective (fun v : Point => + ((fderiv ℝ (fun x => (G i x : ℝ)) (pairCoordinates true A B z)) v, + (fderiv ℝ (fun x => (G j x : ℝ)) (pairCoordinates true A B z)) v)) := by + let p := pairCoordinates true A B + let S : Set Labels := {z | ∀ i, DifferentiableAt ℝ (fun x => (G i x : ℝ)) (p z) ∧ + z i.val = G i (p z)} + have he : ∀ J : Subwindows K, ∀ᵐ z ∂(L.edge : Measure Labels), z ∈ S → + L.conditional z (carrier J.val) ≠ 0 → + ∃ q : CrossingPairs J.val, + (fderiv ℝ (fun x => ((G ⟨q.val.1,q.property.1.trans J.property⟩ x : ℝ), + (G ⟨q.val.2,q.property.2.1.trans J.property⟩ x : ℝ))) (p z)).det ≠ 0 := by + intro J + apply Transversality.independent_gradients_ae (L.edge : Measure Labels) + (fun z => L.conditional z (carrier J.val)) (L.conditional.measurable_coe (measurable_carrier J.val)) + (fun q : CrossingPairs J.val => (L.crossings q.val.1 q.val.2 : Measure Labels)) + (by rw [← h.window_withDensity hR]; exact h.edge_crossing_ac E hR hC hcoeff herror hshort J.val) + (fun q z => ((z q.val.1 : ℝ),(z q.val.2 : ℝ))) + (fun _ => by fun_prop) + (fun q => h.crossing_real_projection_disjoint hR hM q.property.2.2) p + (fun q x => ((G ⟨q.val.1,q.property.1.trans J.property⟩ x : ℝ), + (G ⟨q.val.2,q.property.2.1.trans J.property⟩ x : ℝ))) S + · intro q z hz + exact Prod.ext (congrArg Subtype.val (hz ⟨q.val.1,q.property.1.trans J.property⟩).2) + (congrArg Subtype.val (hz ⟨q.val.2,q.property.2.1.trans J.property⟩).2) + · intro q z hz + exact ((hz _).1).prodMk ((hz _).1) + filter_upwards [(ae_all_iff).mpr he] with z hz hreg J hJ + obtain ⟨q,hq⟩ := hz J hreg hJ + let i : Subwindows K := ⟨q.val.1,q.property.1.trans J.property⟩ + let j : Subwindows K := ⟨q.val.2,q.property.2.1.trans J.property⟩ + refine ⟨i,j,q.property.1,q.property.2.1,q.property.2.2,?_⟩ + have hder : fderiv ℝ (fun x => ((G i x : ℝ),(G j x : ℝ))) (p z) = + (fderiv ℝ (fun x => (G i x : ℝ)) (p z)).prod (fderiv ℝ (fun x => (G j x : ℝ)) (p z)) := + ((hreg i).1.hasFDerivAt.prodMk (hreg j).1.hasFDerivAt).fderiv + rw [hder] at hq + let D := (fderiv ℝ (fun x => (G i x : ℝ)) (p z)).prod + (fderiv ℝ (fun x => (G j x : ℝ)) (p z)) + change Function.Injective D + apply (LinearMap.ker_eq_bot (f := D.toLinearMap)).mp + by_contra hn + exact hq (LinearMap.det_eq_zero_iff_ker_ne_bot.mpr hn) + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates +open scoped Topology unitInterval + +noncomputable def reflectSecond : Point ≃L[ℝ] Point := + (ContinuousLinearEquiv.refl ℝ ℝ).prodCongr (ContinuousLinearEquiv.neg ℝ) + +@[simp] lemma reflectSecond_apply (p : Point) : reflectSecond p = (p.1,-p.2) := rfl + +lemma reflectSecond_signed (p : Point) : reflectSecond p = signedPair true p := rfl + +noncomputable def Configuration.rankChart (F : Configuration) {A B : Window} + (hAB : Before A B) (hA : 0 < length F.R A) (hB : 0 < length F.R B) : + OpenPartialHomeomorph Point Point := + let e := F.system.rankHomeomorph F.generic hAB hA hB + let g : UnitOpen × UnitOpen → Point := Prod.map Subtype.val Subtype.val + let hg : Topology.IsOpenEmbedding g := + isOpen_Ioo.isOpenEmbedding_subtypeVal.prodMap isOpen_Ioo.isOpenEmbedding_subtypeVal + ((reflectSecond.toHomeomorph.isOpenEmbedding.comp hg).comp e.isOpenEmbedding).toOpenPartialHomeomorph _ + +lemma Configuration.rankChart_apply (F : Configuration) {A B : Window} + (hAB : Before A B) (hA : 0 < length F.R A) (hB : 0 < length F.R B) (p : Point) : + F.rankChart hAB hA hB p = pairCoordinates true A B (F.system.labels F.generic p) := by + change reflectSecond (((F.system.rankHomeomorph F.generic hAB hA hB) p).1, + ((F.system.rankHomeomorph F.generic hAB hA hB) p).2) = _ + obtain ⟨he1,he2⟩ := F.system.rankHomeomorph_coordinates F.generic hAB hA hB p + rw [he1,he2] + rfl + +lemma Configuration.rankChart_source (F : Configuration) {A B : Window} + (hAB : Before A B) (hA : 0 < length F.R A) (hB : 0 < length F.R B) : + (F.rankChart hAB hA hB).source = univ := rfl + +lemma Configuration.rankChart_target (F : Configuration) {A B : Window} + (hAB : Before A B) (hA : 0 < length F.R A) (hB : 0 < length F.R B) : + (F.rankChart hAB hA hB).target = Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0 := by + unfold Configuration.rankChart + rw [Topology.IsOpenEmbedding.toOpenPartialHomeomorph_target] + change Set.range (fun x : Point => reflectSecond + (((F.system.rankHomeomorph F.generic hAB hA hB) x).1, + ((F.system.rankHomeomorph F.generic hAB hA hB) x).2)) = _ + ext p + constructor + · rintro ⟨x,rfl⟩ + exact ⟨((F.system.rankHomeomorph F.generic hAB hA hB) x).1.property, + by dsimp; constructor <;> linarith [((F.system.rankHomeomorph F.generic hAB hA hB) x).2.property.1, + ((F.system.rankHomeomorph F.generic hAB hA hB) x).2.property.2]⟩ + · intro hp + let q : UnitOpen × UnitOpen := (⟨p.1,hp.1⟩,⟨-p.2,by constructor <;> linarith [hp.2.1,hp.2.2]⟩) + refine ⟨(F.system.rankHomeomorph F.generic hAB hA hB).symm q,?_⟩ + dsimp only + rw [Homeomorph.apply_symm_apply] + simp [q] + +noncomputable def Configuration.timeSlope (F : Configuration) (t : I) : ℝ := + F.system.slope ⟨cut (time F.R) t,Nat.lt_succ_of_le (cut_le _ _)⟩ + +lemma Configuration.timeSlope_before (F : Configuration) {J : Window} {t : I} + (h : t ≤ lower J) : F.timeSlope t ≤ (F.system.timeWindow J).slope 0 := by + apply F.system.increasing.monotone + change cut (time F.R) t ≤ start F.R J+0 + simpa only [Nat.add_zero, start, TimeWindows.lower] using cut_mono (time F.R) h + +lemma Configuration.timeSlope_after (F : Configuration) {J : Window} {t : I} + (h : upper J ≤ t) : (F.system.timeWindow J).slope (Fin.last (length F.R J)) ≤ F.timeSlope t := by + apply F.system.increasing.monotone + change start F.R J+length F.R J ≤ cut (time F.R) t + rw [start_add_length] + exact cut_mono (time F.R) h + +lemma coordinate_forward_before {l u s : ℝ} (C : Coordinate l u) (hs : s ≤ l) + (x : Point) : Antitone (fun t : ℝ => C.value (x+t • (1,s))) := by + intro a b hab + have ht := C.translate_lower (x.1+a) (x.2+a*s) (b-a) (sub_nonneg.mpr hab) + have hv := (C.strict_vertical (x.1+b)).monotone + (show x.2+b*s ≤ x.2+a*s+l*(b-a) by nlinarith) + have he : x.1+a+(b-a)=x.1+b := by ring + rw [he] at ht + change C.value (x.1+b*1,x.2+b*s) ≤ C.value (x.1+a*1,x.2+a*s) + simpa only [mul_one] using hv.trans ht + +lemma coordinate_forward_after {l u s : ℝ} (C : Coordinate l u) (hs : u ≤ s) + (x : Point) : Monotone (fun t : ℝ => C.value (x+t • (1,s))) := by + intro a b hab + have ht := C.translate_upper (x.1+a) (x.2+a*s) (b-a) (sub_nonneg.mpr hab) + have hv := (C.strict_vertical (x.1+b)).monotone + (show x.2+a*s+u*(b-a) ≤ x.2+b*s by nlinarith) + have he : x.1+a+(b-a)=x.1+b := by ring + rw [he] at ht + change C.value (x.1+a*1,x.2+a*s) ≤ C.value (x.1+b*1,x.2+b*s) + simpa only [mul_one] using ht.trans hv + +lemma Configuration.rank_forward_before (F : Configuration) {J : Window} (hJ : 0 < length F.R J) + {t : I} (ht : t ≤ lower J) (x : Point) : + Antitone (fun r : ℝ => (F.system.labels F.generic (x+r • (1,F.timeSlope t)) J : ℝ)) := by + have hlt := (F.timeSlope_before ht).trans (F.system.rankGraphs F.generic J hJ).lower_lt.le + have h := coordinate_forward_before (F.system.rankCoordinate F.generic J hJ) hlt x + simpa only [F.system.rankCoordinate_value] using h + +lemma Configuration.rank_forward_after (F : Configuration) {J : Window} (hJ : 0 < length F.R J) + {t : I} (ht : upper J ≤ t) (x : Point) : + Monotone (fun r : ℝ => (F.system.labels F.generic (x+r • (1,F.timeSlope t)) J : ℝ)) := by + have hlt := (F.system.rankGraphs F.generic J hJ).upper_lt.le.trans (F.timeSlope_after ht) + have h := coordinate_forward_after (F.system.rankCoordinate F.generic J hJ) hlt x + simpa only [F.system.rankCoordinate_value] using h + +end PlanarHalving.RankLimits +namespace PlanarHalving.Directions +open Set Filter Metric +open scoped Topology + +lemma allowed_nonempty_of_approx {ι : Type*} (Q : Plane ≃L[ℝ] Plane) + (g : ι → Plane →L[ℝ] ℝ) (lo hi : ι → ℝ) (t : ℝ) + (happrox : ∀ S : Finset ι, ∀ ε : ℝ, 0 < ε → ∃ x ∈ Icc (0:ℝ) 1, + ∀ i ∈ S, (hi i < t → -ε ≤ g i (Q (simplex x))) ∧ + (t < lo i → g i (Q (simplex x)) ≤ ε)) : + (allowed Q g lo hi t).Nonempty := by + classical + let T (i : ι) : Set ℝ := {x | (hi i < t → 0 ≤ g i (Q (simplex x))) ∧ + (t < lo i → g i (Q (simplex x)) ≤ 0)} + have hc (i : ι) : Continuous (fun x : ℝ => g i (Q (simplex x))) := by + exact (g i).continuous.comp (Q.continuous.comp (continuous_id.prodMk (continuous_const.sub continuous_id))) + have hcl (i : ι) : IsClosed (T i) := by + change IsClosed ({x | hi i < t → 0 ≤ g i (Q (simplex x))} ∩ + {x | t < lo i → g i (Q (simplex x)) ≤ 0}) + apply IsClosed.inter + · by_cases h : hi i < t + · simpa only [h, true_implies] using isClosed_le continuous_const (hc i) + · simpa only [h, false_implies, ofPred_true] using (isClosed_univ : IsClosed (univ : Set ℝ)) + · by_cases h : t < lo i + · simpa only [h, true_implies] using isClosed_le (hc i) continuous_const + · simpa only [h, false_implies, ofPred_true] using (isClosed_univ : IsClosed (univ : Set ℝ)) + have hfin (S : Finset ι) : ((Icc (0:ℝ) 1) ∩ ⋂ i ∈ S, T i).Nonempty := by + have ha (n : ℕ) := happrox S ((n+1:ℝ)⁻¹) (by positivity) + choose x hx hxi using ha + obtain ⟨a,ha,φ,hφ,hxa⟩ := isCompact_Icc.tendsto_subseq hx + refine ⟨a,ha,?_⟩ + simp only [mem_iInter] + intro i hiS + have he : Tendsto (fun n : ℕ => ((φ n+1:ℝ)⁻¹)) atTop (𝓝 0) := + by + have he' : Tendsto (fun n : ℕ => 1 / (n+1:ℝ)) atTop (𝓝 0) := + tendsto_one_div_add_atTop_nhds_zero_nat + simpa only [one_div, Function.comp_def] using he'.comp hφ.tendsto_atTop + constructor + · intro hit + exact le_of_tendsto_of_tendsto (by simpa only [neg_zero] using he.neg) ((hc i).tendsto a |>.comp hxa) + (Eventually.of_forall fun n => (hxi (φ n) i hiS).1 hit) + · intro hti + exact le_of_tendsto_of_tendsto ((hc i).tendsto a |>.comp hxa) he + (Eventually.of_forall fun n => (hxi (φ n) i hiS).2 hti) + obtain ⟨x,hx,hxt⟩ := isCompact_Icc.inter_iInter_nonempty T hcl hfin + exact ⟨x,hx,fun i => mem_iInter.mp hxt i⟩ + +lemma ray_exit_at_radius (f : OpenPartialHomeomorph Plane Plane) (hs : f.source=univ) + {p v : Plane} (hp : p ∈ f.target) (hv : v ≠ 0) {h : ℝ} (hh : 0 < h) + (hball : closedBall p h ⊆ f.target) : + ∃ r : ℝ, 0 ≤ r ∧ dist (f (f.symm p+r • v)) p = h := by + have hfp := f.right_inv hp + obtain ⟨T,hT,hfar⟩ := Zoom.ray_image_leaves_ball f hs (f.symm p) v hv h + (by simpa only [hfp] using hball) + rw [hfp] at hfar + have hf : Continuous f := continuousOn_univ.mp (by simpa only [← hs] using f.continuousOn) + have hc : Continuous (fun r : ℝ => dist (f (f.symm p+r • v)) p) := + (hf.comp (continuous_const.add (continuous_id.smul continuous_const))).dist continuous_const + obtain ⟨r,hr,he⟩ := intermediate_value_Icc hT hc.continuousOn + (show h ∈ Icc (dist (f (f.symm p+0 • v)) p) (dist (f (f.symm p+T • v)) p) from + ⟨by simpa [hfp] using hh.le,hfar.le⟩) + exact ⟨r,hr.1,he⟩ + +lemma chord_firstOrder {f : Plane → ℝ} {D : Plane →L[ℝ] ℝ} {c ε h : ℝ} + {p x y : Plane} (hx : dist (f x) (c+D (x-p)) < ε*h) + (hy : dist (f y) (c+D (y-p)) < ε*h) : + |(f y-f x)-D (y-x)| < 2*ε*h := by + have he : D (y-x)=D (y-p)-D (x-p) := by rw [← map_sub]; congr 1; abel + rw [he] + rw [Real.dist_eq,abs_lt] at hx hy + rw [abs_lt] + constructor <;> linarith + +end PlanarHalving.Directions +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates +open scoped Topology unitInterval + +noncomputable def reflectFirst : Point ≃L[ℝ] Point := + (ContinuousLinearEquiv.neg ℝ).prodCongr (ContinuousLinearEquiv.refl ℝ ℝ) + +@[simp] lemma reflectFirst_apply (p : Point) : reflectFirst p = (-p.1,p.2) := rfl + +lemma rank_firstOrder_filter (F : ℕ → Configuration) (A B C : Window) (G : Point → I) + (hjoint : ∀ p, ContinuousAt G p → Tendsto + (fun q : ℕ × Point => (F q.1).extendedRank true A B C q.2) + (atTop ×ˢ 𝓝 p) (𝓝 (G p))) + (hGaed : ∀ᵐ p ∂(volume : Measure Point), DifferentiableAt ℝ (fun x => (G x : ℝ)) p) + {p : Point} (hd : DifferentiableAt ℝ (fun x => (G x : ℝ)) p) + {R ε : ℝ} (hR : 0 ≤ R) (hε : 0 < ε) : + ∀ᶠ h in 𝓝[>] (0:ℝ), ∀ᶠ n in atTop, ∀ x ∈ closedBall p (R*h), + dist ((F n).extendedRank true A B C x : ℝ) + ((G p : ℝ) + (fderiv ℝ (fun x => (G x : ℝ)) p) (x-p)) < ε*h := by + obtain ⟨δ,hδ,hbound⟩ := RankLimit.firstOrder_of_joint + (fun n => fun x y hxy => (F n).extendedRank_monotone true A B C hxy) + (fun x hx => (continuous_subtype_val.tendsto _).comp + (hjoint x (hx.codRestrict (fun x => (G x).property)))) hGaed hd.hasFDerivAt hR hε + filter_upwards [self_mem_nhdsWithin, + (nhdsWithin_le_nhds (Iio_mem_nhds hδ) : ∀ᶠ h in 𝓝[>] (0:ℝ), h < δ)] with h hh hhd + exact hbound h hh hhd + +theorem actual_allowed_nonempty {ι : Type*} (F : ℕ → Configuration) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + {A B : Window} (hAB : Before A B) (C : ι → Window) + (hC : ∀ i, Before (C i) A ∧ Before (C i) B) + (G : ι → Point → I) + (hjoint : ∀ i p, ContinuousAt (G i) p → Tendsto + (fun q : ℕ × Point => (F q.1).extendedRank true A B (C i) q.2) + (atTop ×ˢ 𝓝 p) (𝓝 (G i p))) + (hGaed : ∀ i, ∀ᵐ p ∂(volume : Measure Point), DifferentiableAt ℝ (fun x => (G i x : ℝ)) p) + {p : Point} (hp : p ∈ Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (hd : ∀ i, DifferentiableAt ℝ (fun x => (G i x : ℝ)) p) + (t : I) (htA : t ≤ lower A) (htB : t ≤ lower B) : + (Directions.allowed reflectFirst (fun i => fderiv ℝ (fun x => (G i x : ℝ)) p) + (fun i => (lower (C i) : ℝ)) (fun i => (upper (C i) : ℝ)) t).Nonempty := by + classical + apply Directions.allowed_nonempty_of_approx + intro S ε hε + obtain ⟨r,hr,hrsub⟩ := Metric.mem_nhds_iff.mp ((isOpen_Ioo.prod isOpen_Ioo).mem_nhds hp) + have hfirst : ∀ᶠ h in 𝓝[>] (0:ℝ), ∀ i ∈ S, ∀ᶠ n in atTop, + ∀ x ∈ closedBall p h, dist ((F n).extendedRank true A B (C i) x : ℝ) + ((G i p : ℝ)+(fderiv ℝ (fun x => (G i x : ℝ)) p) (x-p)) < (ε/2)*h := by + apply (Filter.eventually_all_finset S).mpr + intro i _ + simpa only [one_mul] using rank_firstOrder_filter F A B (C i) (G i) + (hjoint i) (hGaed i) (hd i) (R:=1) (by norm_num) (half_pos hε) + have hall : ∀ᶠ h in 𝓝[>] (0:ℝ), 0 < h ∧ h < r ∧ + ∀ i ∈ S, ∀ᶠ n in atTop, ∀ x ∈ closedBall p h, + dist ((F n).extendedRank true A B (C i) x : ℝ) + ((G i p : ℝ)+(fderiv ℝ (fun x => (G i x : ℝ)) p) (x-p)) < (ε/2)*h := by + filter_upwards [self_mem_nhdsWithin, nhdsWithin_le_nhds (Iio_mem_nhds hr), hfirst] + with h hh hhr hhn + exact ⟨hh,hhr,hhn⟩ + obtain ⟨h,hh,hhr,hhn⟩ := hall.exists + have hn : ∀ᶠ n in atTop, 0 < length (F n).R A ∧ 0 < length (F n).R B ∧ + ∀ i ∈ S, 0 < length (F n).R (C i) ∧ + ∀ x ∈ closedBall p h, dist ((F n).extendedRank true A B (C i) x : ℝ) + ((G i p : ℝ)+(fderiv ℝ (fun x => (G i x : ℝ)) p) (x-p)) < (ε/2)*h := by + filter_upwards [eventually_length_pos _ hR A,eventually_length_pos _ hR B, + (Filter.eventually_all_finset S).mpr (fun i hi => + (eventually_length_pos _ hR (C i)).and (hhn i hi))] with n hA hB hS + exact ⟨hA,hB,hS⟩ + obtain ⟨n,hA,hB,hS⟩ := hn.exists + let f := (F n).rankChart hAB hA hB + have htarget : f.target=Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0 := (F n).rankChart_target hAB hA hB + have hp' : p ∈ f.target := by rwa [htarget] + have hball : closedBall p h ⊆ f.target := by + rw [htarget] + exact fun x hx => hrsub ((Metric.mem_closedBall.mp hx).trans_lt hhr) + have hv : (1,(F n).timeSlope t) ≠ (0:Point) := by intro he; have := congrArg Prod.fst he; norm_num at this + obtain ⟨s,hs,hexit⟩ := Directions.ray_exit_at_radius f ((F n).rankChart_source hAB hA hB) hp' hv hh hball + let x := f.symm p + let y := x+s • (1,(F n).timeSlope t) + let d := f y-p + have hfx : f x=p := f.right_inv hp' + have hd1 : d.1 ≤ 0 := by + have hm := (F n).rank_forward_before hA htA x hs + have he (q : Point) : (f q).1 = (F n).system.labels (F n).generic q A := by + rw [(F n).rankChart_apply]; rfl + change (f y).1-p.1 ≤ 0 + rw [← hfx,he,he] + exact sub_nonpos.mpr (by simpa only [zero_smul,add_zero] using hm) + have hd2 : 0 ≤ d.2 := by + have hm := (F n).rank_forward_before hB htB x hs + have he (q : Point) : (f q).2 = -(F n).system.labels (F n).generic q B := by + rw [(F n).rankChart_apply]; rfl + have hd' : d.2= -(F n).system.labels (F n).generic y B + + (F n).system.labels (F n).generic x B := by + change (f y).2-p.2=_ + rw [← hfx,he,he] + ring + rw [hd'] + simpa only [zero_smul,add_zero,zero_add, sub_eq_add_neg,add_comm,y] using sub_nonneg.mpr hm + have hnorm : ‖d‖=h := by simpa only [d,y,x,dist_eq_norm] using hexit + let a : ℝ := -d.1+d.2 + have hha : h ≤ a := by + rw [← hnorm,Prod.norm_def,Real.norm_eq_abs,Real.norm_eq_abs, + abs_of_nonpos hd1,abs_of_nonneg hd2] + exact max_le (by dsimp [a]; linarith) (by dsimp [a]; linarith) + have ha : 0 < a := hh.trans_le hha + let z : ℝ := -d.1/a + have hz0 : 0 ≤ z := div_nonneg (neg_nonneg.mpr hd1) ha.le + have hz1 : z ≤ 1 := (div_le_one ha).mpr (by dsimp [a]; linarith) + have hdz : d = a • reflectFirst (Directions.simplex z) := by + ext <;> dsimp [reflectFirst,Directions.simplex,z] + · field_simp [ha.ne']; + · field_simp [ha.ne']; dsimp [a]; ring + refine ⟨z,⟨hz0,hz1⟩,?_⟩ + intro i hi + let D := fderiv ℝ (fun x => (G i x : ℝ)) p + have hCi := (hS i hi).1 + have heq (q : Point) : (F n).extendedRank true A B (C i) (f q) = + (F n).system.labels (F n).generic q (C i) := by + rw [(F n).rankChart_apply] + exact (F n).extendedRank_eq true hAB (hC i) hA hB hCi q + have hchord := Directions.chord_firstOrder + (f := fun q => ((F n).extendedRank true A B (C i) q : ℝ)) (D := D) + (c := (G i p : ℝ)) (p := p) (ε := ε/2) (h := h) (x := f x) (y := f y) + ((hS i hi).2 (f x) (by rw [hfx]; exact mem_closedBall_self hh.le)) + ((hS i hi).2 (f y) hexit.le) + rw [heq x,heq y,hfx] at hchord + change |((F n).system.labels (F n).generic y (C i) : ℝ)- + ((F n).system.labels (F n).generic x (C i) : ℝ)-D d| < 2*(ε/2)*h at hchord + have hchord' := abs_lt.mp hchord + have hDd : D d=a*D (reflectFirst (Directions.simplex z)) := by rw [hdz,map_smul]; rfl + constructor + · intro hit + have hm := (F n).rank_forward_after hCi (show upper (C i) ≤ t from hit.le) x hs + simp only [zero_smul,add_zero] at hm + have hb : -ε*h ≤ D d := by linarith + rw [hDd] at hb + change -ε ≤ D (reflectFirst (Directions.simplex z)) + by_contra hnz + have hz' := lt_of_not_ge hnz + have hm' := mul_lt_mul_of_pos_left hz' ha + nlinarith [mul_le_mul_of_nonneg_left hha hε.le] + · intro hti + have hm := (F n).rank_forward_before hCi (show t ≤ lower (C i) from hti.le) x hs + simp only [zero_smul,add_zero] at hm + have hb : D d ≤ ε*h := by linarith + rw [hDd] at hb + change D (reflectFirst (Directions.simplex z)) ≤ ε + by_contra hnz + have hz' := lt_of_not_ge hnz + have hm' := mul_lt_mul_of_pos_left hz' ha + nlinarith [mul_le_mul_of_nonneg_left hha hε.le] + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Derivatives.lean b/lean/OAI/Combinatorics/HalvingLines/Derivatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..62426a678f1732b47b62e71c91bf1608613554d3 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Derivatives.lean @@ -0,0 +1,487 @@ +import OAI.Combinatorics.HalvingLines.MeasureBounds + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +lemma inv_cube_rpow {q : ℝ} (hq : 0 < q) : (1/q^3)^(-(4:ℝ)/3)=q^4 := by + have he : 1/q^3=q^(-(3:ℝ)) := by rw [Real.rpow_neg hq.le]; norm_num [one_div] + rw [he,← Real.rpow_mul hq.le] + norm_num + +noncomputable def goodPartition (L : Data) (K : Window) (m : ℕ) : Finset Window := + (localPartition K (5*m)).filter (fun J => ((L.vertices J).mass : ℝ) ≤ 1/((2:ℝ)^m)^3) + +lemma goodPartition_subset (L : Data) (K : Window) (m : ℕ) : + goodPartition L K m ⊆ localPartition K (5*m) := Finset.filter_subset _ _ + +lemma goodPartition_disjoint (L : Data) (K : Window) (m : ℕ) : + ∀ J∈goodPartition L K m, ∀ H∈goodPartition L K m, J≠H → Disjoint (carrier J) (carrier H) := by + intro J hJ H hH hJH + exact localPartition_disjoint K (5*m) (goodPartition_subset L K m hJ) (goodPartition_subset L K m hH) hJH + +lemma pow_depth (K m : ℕ) : (2:ℝ)^(K+5*m)=(2:ℝ)^K*((2:ℝ)^m)^5 := by + rw [pow_add,Nat.mul_comm 5 m,pow_mul] + +lemma Converges.goodPartition_loss {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) (hR : Tendsto (fun n => (F n).R) atTop atTop) + (K : Window) (m : ℕ) {A : Set Labels} (hA : MeasurableSet A) : + (L.edgeWindow K A : ℝ)-10000/(2:ℝ)^m ≤ ∑ J∈goodPartition L K m, (L.edgeWindow J A : ℝ) := by + classical + let W := localPartition K (5*m) + let u : ℝ := 1/((2:ℝ)^m)^3 + let B := W.filter (fun J => ¬ ((L.vertices J).mass : ℝ) ≤ u) + have hu : 0 < u := by dsimp [u]; positivity + have hcard : (B.card : ℝ) ≤ 10000*((2:ℝ)^m)^4 := by + have hb : B ⊆ (timePartition (K.1+5*m)).filter (fun J => u < ((L.vertices J).mass : ℝ)) := by + intro J hJ + obtain ⟨hJ,hb⟩ := Finset.mem_filter.mp hJ + exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hJ).1,lt_of_not_ge hb⟩ + have ht := h.activity_tail E (K.1+5*m) hu + rw [← filter_timePartition (K.1+5*m) (fun J => u < ((L.vertices J).mass : ℝ))] at ht + have hi := (Nat.cast_le.mpr (Finset.card_le_card hb) : (B.card : ℝ) ≤ _) + exact hi.trans (by simpa only [u,inv_cube_rpow (by positivity : (0:ℝ) < (2:ℝ)^m)] using ht) + have hmass (J : Window) (hJ : J∈B) : (L.edgeWindow J A : ℝ) ≤ 1/((2:ℝ)^m)^5 := by + have hd : J.1=K.1+5*m := mem_timePartition.mp (Finset.mem_filter.mp (Finset.mem_filter.mp hJ).1).1 + have hh := NNReal.coe_le_coe.mpr ((L.edgeWindow J).apply_le_mass A) + rw [h.edgeWindow_mass hR,Nat.cast_pow,Nat.cast_ofNat,hd,pow_depth] at hh + have he : (1:ℝ) ≤ (2:ℝ)^K.1 := one_le_pow₀ (by norm_num) + have hp : ((2:ℝ)^m)^5 ≤ (2:ℝ)^K.1*((2:ℝ)^m)^5 := + le_mul_of_one_le_left (by positivity) he + exact hh.trans (by simpa only [one_div] using + one_div_le_one_div_of_le (by positivity : (0:ℝ) < ((2:ℝ)^m)^5) hp) + have hloss : ∑ J∈B, (L.edgeWindow J A : ℝ) ≤ 10000/(2:ℝ)^m := by + apply (Finset.sum_le_sum hmass).trans + simp only [Finset.sum_const,nsmul_eq_mul] + apply (mul_le_mul_of_nonneg_right hcard (by positivity)).trans + have hn : ((2:ℝ)^m)≠0 := by positivity + exact le_of_eq (by field_simp) + have he : (∑ J∈goodPartition L K m, (L.edgeWindow J A : ℝ))+ + (∑ J∈B, (L.edgeWindow J A : ℝ))=(L.edgeWindow K A : ℝ) := by + rw [← h.localPartition_sum hR K (5*m) hA] + exact Finset.sum_filter_add_sum_filter_not W _ _ + linarith + +lemma Data.goodPartition_diagonal (L : Data) (K : Window) (m : ℕ) : + ∑ J∈goodPartition L K m, 2*((L.vertices J).mass : ℝ)^2 ≤ 2*(2:ℝ)^K.1/(2:ℝ)^m := by + classical + let W := goodPartition L K m + have hs : W ⊆ timePartition (K.1+5*m) := fun J hJ => + (Finset.mem_filter.mp (goodPartition_subset L K m hJ)).1 + have hc : (W.card : ℝ) ≤ (2:ℝ)^(K.1+5*m) := by + exact_mod_cast (Finset.card_le_card hs).trans_eq (timePartition_card _) + have hsum : ∑ J∈W, 2*((L.vertices J).mass : ℝ)^2 ≤ (W.card : ℝ)*(2*(1/((2:ℝ)^m)^3)^2) := by + have hh := Finset.sum_le_sum (s:=W) (fun J hJ => mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (by positivity) (Finset.mem_filter.mp hJ).2 2) (by norm_num : (0:ℝ)≤2)) + simpa only [Finset.sum_const,nsmul_eq_mul] using hh + apply hsum.trans + apply (mul_le_mul_of_nonneg_right hc (by positivity)).trans + rw [pow_depth] + have hn : ((2:ℝ)^m)≠0 := by positivity + exact le_of_eq (by field_simp) + +lemma Data.goodPartition_crossings (L : Data) (K : Window) (m : ℕ) {A : Set Labels} + (hnull : ∀ J H : Window, carrier J⊆carrier K → carrier H⊆carrier K → + Disjoint (carrier J) (carrier H) → L.crossings J H A=0) : + (∑ J∈goodPartition L K m, ∑ H∈goodPartition L K m, + if J=H then 2*((L.vertices J).mass : ℝ)^2 else (L.crossings J H A : ℝ)) ≤ + 2*(2:ℝ)^K.1/(2:ℝ)^m := by + classical + apply le_trans _ (L.goodPartition_diagonal K m) + apply Finset.sum_le_sum + intro J hJ + have he : (∑ H∈goodPartition L K m, + if J=H then 2*((L.vertices J).mass : ℝ)^2 else (L.crossings J H A : ℝ))= + 2*((L.vertices J).mass : ℝ)^2 := by + rw [Finset.sum_eq_single J] + · simp + · intro H hH hHJ + rw [ite_eq_right (Ne.symm hHJ),hnull J H + (Finset.mem_filter.mp (goodPartition_subset L K m hJ)).2 + (Finset.mem_filter.mp (goodPartition_subset L K m hH)).2 + (goodPartition_disjoint L K m J hJ H hH (Ne.symm hHJ))] + rfl + · exact fun hn => (hn hJ).elim + exact he.le + +end PlanarHalving.RankLimits +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +lemma Converges.edge_crossing_null_closed {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) (hR : Tendsto (fun n => (F n).R) atTop atTop) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4/(((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3/(((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + (K : Window) {A : Set Labels} (hA : IsClosed A) + (hnull : ∀ J H : Window, carrier J⊆carrier K → carrier H⊆carrier K → + Disjoint (carrier J) (carrier H) → L.crossings J H A=0) : L.edgeWindow K A=0 := by + have ht : Tendsto (fun m : ℕ => ((2:ℝ)^m)⁻¹) atTop (𝓝 0) := + tendsto_inv_atTop_zero.comp (tendsto_pow_atTop_atTop_of_one_lt (by norm_num)) + have hlo : Tendsto (fun m : ℕ => 10000/(2:ℝ)^m) atTop (𝓝 0) := by + simpa [div_eq_mul_inv] using ht.const_mul (10000:ℝ) + have hup : Tendsto (fun m : ℕ => 2*(2:ℝ)^K.1/(2:ℝ)^m) atTop (𝓝 0) := by + simpa [div_eq_mul_inv] using ht.const_mul (2*(2:ℝ)^K.1) + have hcub : (L.edgeWindow K A : ℝ)^3 ≤ C*0 := by + apply Limits.cubic_of_eventual_bounds (x:=fun m => ∑ J∈goodPartition L K m, (L.edgeWindow J A : ℝ)) + (b:=fun m => 2*(2:ℝ)^K.1/(2:ℝ)^m) (e:=fun _ => 0) (by positivity) hC + · intro m; positivity + · intro m + simpa only [add_zero] using + (h.partition_cubic_closed hC hcoeff herror hshort _ (goodPartition_disjoint L K m) hA).trans + (mul_le_mul_of_nonneg_left (L.goodPartition_crossings K m hnull) hC) + · intro ε hε + filter_upwards [(tendsto_order.mp hlo).2 ε hε] with m hm + have hh := h.goodPartition_loss E hR K m hA.measurableSet + linarith + · intro ε hε + exact ((tendsto_order.mp hup).2 ε hε).mono (fun _ hh => by simpa only [zero_add] using hh.le) + · exact tendsto_const_nhds + apply NNReal.coe_injective + change (L.edgeWindow K A : ℝ)=0 + have hp : 0 ≤ (L.edgeWindow K A : ℝ) := by positivity + have he : (L.edgeWindow K A : ℝ)^3=0 := + le_antisymm (by simpa only [mul_zero] using hcub) (pow_nonneg hp _) + exact (pow_eq_zero_iff (by decide : (3:ℕ)≠0)).mp he + +lemma Converges.edge_crossing_null {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) (hR : Tendsto (fun n => (F n).R) atTop atTop) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4/(((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3/(((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + (K : Window) {A : Set Labels} (hA : MeasurableSet A) + (hnull : ∀ J H : Window, carrier J⊆carrier K → carrier H⊆carrier K → + Disjoint (carrier J) (carrier H) → L.crossings J H A=0) : L.edgeWindow K A=0 := by + by_contra hn + have hp : 0 < (L.edgeWindow K : Measure Labels) A := by + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] + exact ENNReal.coe_pos.mpr (pos_iff_ne_zero.mpr hn) + obtain ⟨T,hTA,hT,hpos⟩ := hA.exists_lt_isCompact hp + have hz := h.edge_crossing_null_closed E hR hC hcoeff herror hshort K hT.isClosed + (fun J H hJ hH hd => le_antisymm (((L.crossings J H).apply_mono hTA).trans_eq (hnull J H hJ hH hd)) (by positivity)) + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,hz,ENNReal.coe_zero] at hpos + exact lt_irrefl _ hpos + +def CrossingPairs (K : Window) := {JH : Window×Window // + carrier JH.1⊆carrier K ∧ carrier JH.2⊆carrier K ∧ Disjoint (carrier JH.1) (carrier JH.2)} + +instance crossingPairsCountable (K : Window) : Countable (CrossingPairs K) := by + unfold CrossingPairs + infer_instance + +lemma Converges.edge_crossing_ac {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) (hR : Tendsto (fun n => (F n).R) atTop atTop) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4/(((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3/(((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + (K : Window) : (L.edgeWindow K : Measure Labels) ≪ + Measure.sum (fun JH : CrossingPairs K => (L.crossings JH.val.1 JH.val.2 : Measure Labels)) := by + apply Measure.AbsolutelyContinuous.mk + intro A hA hn + have hz (J H : Window) (hJ : carrier J⊆carrier K) (hH : carrier H⊆carrier K) + (hd : Disjoint (carrier J) (carrier H)) : L.crossings J H A=0 := by + have hh := Measure.sum_apply_eq_zero.mp hn (⟨(J,H),hJ,hH,hd⟩ : CrossingPairs K) + simpa only [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,ENNReal.coe_eq_zero] using hh + have hh := h.edge_crossing_null E hR hC hcoeff herror hshort K hA hz + simpa only [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,ENNReal.coe_eq_zero] using hh + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimit +open Filter Set MeasureTheory Metric +open scoped Topology unitInterval + +noncomputable def extendRank {X : Type*} (p : X → Point) (c : X → I) (x : Point) : I := + ⨆ a : X, if p a ≤ x then c a else ⊥ + +lemma extendRank_monotone {X : Type*} (p : X → Point) (c : X → I) : + Monotone (extendRank p c) := by + intro x y hxy + apply iSup_le + intro a + by_cases ha : p a ≤ x + · simpa only [extendRank, ite_eq_left ha, ite_eq_left (ha.trans hxy)] using + (le_iSup (fun b : X => if p b ≤ y then c b else ⊥) a) + · simp only [ite_eq_right ha, bot_le] + +lemma extendRank_eq {X : Type*} (p : X → Point) (c : X → I) + (hc : ∀ a b, p a ≤ p b → c a ≤ c b) (a : X) : extendRank p c (p a) = c a := by + apply le_antisymm + · apply iSup_le + intro b + split_ifs with hb + · exact hc b a hb + · exact bot_le + · simpa only [extendRank, ite_eq_left le_rfl] using + (le_iSup (fun b : X => if p b ≤ p a then c b else ⊥) a) + +theorem joint_tendsto_of_grid {f : ℕ → Point → I} + (hf : ∀ n, Monotone (f n)) {g : RatPoint → I} + (hg : ∀ q, Tendsto (fun n => f n (ratPoint q)) atTop (𝓝 (g q))) + {x : Point} (hc : ContinuousAt (lowerGrid g) x) : + Tendsto (fun q : ℕ × Point => f q.1 q.2) (atTop ×ˢ 𝓝 x) (𝓝 (lowerGrid g x)) := by + rw [tendsto_order] + constructor + · intro a ha + obtain ⟨q, hq⟩ := lt_iSup_iff.mp ha + by_cases hqx : (q.1 : ℝ) < x.1 ∧ (q.2 : ℝ) < x.2 + · simp only [ite_eq_left hqx] at hq + filter_upwards [(tendsto_order.mp ((hg q).comp tendsto_fst)).1 a hq, + (tendsto_order.mp ((continuous_fst.tendsto x).comp tendsto_snd)).1 _ hqx.1, + (tendsto_order.mp ((continuous_snd.tendsto x).comp tendsto_snd)).1 _ hqx.2] + with n hn hn₁ hn₂ + exact hn.trans_le (hf n.1 ⟨hn₁.le, hn₂.le⟩) + · simp only [ite_eq_right hqx, not_lt_bot] at hq + · intro a ha + have hn := hc.preimage_mem_nhds (isOpen_Iio.mem_nhds ha) + obtain ⟨δ, hδ, hδU⟩ := Metric.mem_nhds_iff.mp hn + let b : Point := x + (δ / 2, δ / 2) + have hb : b ∈ ball x δ := by + rw [Metric.mem_ball, dist_eq_norm] + simp only [b, add_sub_cancel_left, Prod.norm_def, Real.norm_eq_abs, + abs_of_pos (half_pos hδ), max_self] + linarith only [hδ] + have hba : lowerGrid g b < a := hδU hb + obtain ⟨r₁, hxr₁, hr₁b⟩ := exists_rat_btwn + (show x.1 < b.1 by dsimp [b]; linarith only [hδ]) + obtain ⟨r₂, hxr₂, hr₂b⟩ := exists_rat_btwn + (show x.2 < b.2 by dsimp [b]; linarith only [hδ]) + let r : RatPoint := (r₁, r₂) + have hra : g r < a := (grid_le_lowerGrid ⟨hr₁b, hr₂b⟩).trans_lt hba + filter_upwards [(tendsto_order.mp ((hg r).comp tendsto_fst)).2 a hra, + (tendsto_order.mp ((continuous_fst.tendsto x).comp tendsto_snd)).2 _ hxr₁, + (tendsto_order.mp ((continuous_snd.tendsto x).comp tendsto_snd)).2 _ hxr₂] + with n hn hn₁ hn₂ + exact (hf n.1 ⟨hn₁.le, hn₂.le⟩).trans_lt hn + +theorem monotone_joint_subsequence {ι : Type*} [Countable ι] + (f : ℕ → ι → Point → I) (hf : ∀ n i, Monotone (f n i)) : + ∃ (φ : ℕ → ℕ) (F : ι → Point → I), StrictMono φ ∧ + (∀ i, Monotone (F i) ∧ Measurable (F i)) ∧ + (∀ i x, ContinuousAt (F i) x → + Tendsto (fun q : ℕ × Point => f (φ q.1) i q.2) + (atTop ×ˢ 𝓝 x) (𝓝 (F i x))) := by + obtain ⟨g, φ, hφ, hg⟩ := CompactSpace.tendsto_subseq + (fun n i q => f n i (ratPoint q)) + refine ⟨φ, fun i => lowerGrid (g i), hφ, + fun i => ⟨lowerGrid_monotone _, lowerGrid_measurable _⟩, ?_⟩ + intro i x hx + apply joint_tendsto_of_grid (fun n => hf (φ n) i) _ hx + intro q + exact ((tendsto_pi_nhds.mp hg) i).apply_nhds q + +end PlanarHalving.RankLimit + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows +open scoped Topology unitInterval + +def signedPair (before : Bool) (p : Point) : Point := + if before then (p.1, -p.2) else (-p.1, p.2) + +lemma continuous_signedPair (b : Bool) : Continuous (signedPair b) := by + cases b + · exact continuous_fst.neg.prodMk continuous_snd + · exact continuous_fst.prodMk continuous_snd.neg + +lemma signedPair_involutive (b : Bool) : Function.Involutive (signedPair b) := by + intro p + cases b <;> simp [signedPair] + +noncomputable def pairCoordinates (b : Bool) (A B : Window) (z : Labels) : Point := + signedPair b (z A, z B) + +lemma continuous_pairCoordinates (b : Bool) (A B : Window) : + Continuous (pairCoordinates b A B) := + (continuous_signedPair b).comp ((continuous_subtype_val.comp (continuous_apply A)).prodMk + (continuous_subtype_val.comp (continuous_apply B))) + +noncomputable def Configuration.extendedRank (F : Configuration) (b : Bool) (A B C : Window) : + Point → I := RankLimit.extendRank (fun p => pairCoordinates b A B (F.system.labels F.generic p)) + (fun p => F.system.labels F.generic p C) + +lemma Configuration.extendedRank_monotone (F : Configuration) (b : Bool) (A B C : Window) : + Monotone (F.extendedRank b A B C) := RankLimit.extendRank_monotone _ _ + +lemma Configuration.extendedRank_eq (F : Configuration) (b : Bool) {A B C : Window} + (hAB : Before A B) + (hC : if b then Before C A ∧ Before C B else Before A C ∧ Before B C) + (hA : 0 < length F.R A) (hB : 0 < length F.R B) (hCl : 0 < length F.R C) + (p : Point) : + F.extendedRank b A B C (pairCoordinates b A B (F.system.labels F.generic p)) = + F.system.labels F.generic p C := by + apply RankLimit.extendRank_eq + intro x y hxy + let H := F.system.rankHomeomorph F.generic hAB hA hB + have hx := F.system.rankHomeomorph_coordinates F.generic hAB hA hB x + have hy := F.system.rankHomeomorph_coordinates F.generic hAB hA hB y + change ((F.system.labels F.generic x C : I) : ℝ) ≤ (F.system.labels F.generic y C : ℝ) + have he (q : Point) : F.system.rankInCoordinates F.generic hAB hA hB C (H q) = + (F.system.labels F.generic q C : ℝ) := by + simp only [Batches.System.rankInCoordinates, H, Homeomorph.symm_apply_apply] + rw [← he x, ← he y] + cases b + · simp only [Bool.false_eq_true, ite_false] at hC + have hm := F.system.rankInCoordinates_after F.generic hAB hC.1 hC.2 hA hB hCl + have hh : (H y).1 ≤ (H x).1 ∧ (H x).2 ≤ (H y).2 := by + change ((H y).1 : ℝ) ≤ ((H x).1 : ℝ) ∧ ((H x).2 : ℝ) ≤ ((H y).2 : ℝ) + rw [hy.1,hx.1,hx.2,hy.2] + simpa only [pairCoordinates, signedPair, Bool.false_eq_true, ite_false, Prod.mk_le_mk, + neg_le_neg_iff] using hxy + exact ((hm.1 (H x).2) hh.1).trans ((hm.2 (H y).1) hh.2) + · simp only [ite_true] at hC + have hm := F.system.rankInCoordinates_before F.generic hAB hC.1 hC.2 hA hB hCl + have hh : (H x).1 ≤ (H y).1 ∧ (H y).2 ≤ (H x).2 := by + change ((H x).1 : ℝ) ≤ ((H y).1 : ℝ) ∧ ((H y).2 : ℝ) ≤ ((H x).2 : ℝ) + rw [hx.1,hy.1,hy.2,hx.2] + simpa only [pairCoordinates, signedPair, ite_true, Prod.mk_le_mk,neg_le_neg_iff] using hxy + exact ((hm.1 (H x).2) hh.1).trans ((hm.2 (H y).1) hh.2) + +end PlanarHalving.RankLimits + +namespace PlanarHalving.Limits +open Set Filter MeasureTheory Metric +open scoped Topology + +lemma support_coordinate_identity {X Y T : Type*} [MetricSpace X] [MeasurableSpace X] + [BorelSpace X] [TopologicalSpace Y] [MetricSpace T] + {μs : ℕ → FiniteMeasure X} {μ : FiniteMeasure X} + (hμ : Tendsto μs atTop (𝓝 μ)) (p : X → Y) (hp : Continuous p) + (c : X → T) (hc : Continuous c) (f : ℕ → Y → T) + (hid : ∀ᶠ n in atTop, ∀ᵐ z ∂(μs n : Measure X), c z = f n (p z)) + {z : X} (hz : z ∈ (μ : Measure X).support) {v : T} + (hf : Tendsto (fun q : ℕ × Y => f q.1 q.2) (atTop ×ˢ 𝓝 (p z)) (𝓝 v)) : + c z = v := by + by_contra hne + have hd : 0 < dist (c z) v := dist_pos.mpr hne + have hp' : Tendsto (fun q : ℕ × X => (q.1,p q.2)) (atTop ×ˢ 𝓝 z) + (atTop ×ˢ 𝓝 (p z)) := tendsto_fst.prodMk ((hp.tendsto z).comp tendsto_snd) + have hdlim := ((hc.tendsto z).comp tendsto_snd).dist (hf.comp hp') + have he := (tendsto_order.mp hdlim).1 0 hd + obtain ⟨pa,hpa,pb,hpb,hbad⟩ := Filter.eventually_prod_iff.mp he + obtain ⟨r,hr,hball⟩ := Metric.mem_nhds_iff.mp hpb + let : Nonempty X := ⟨z⟩ + have hpos : 0 < (μ (ball z (r/2)) : ℝ) := by + have hh := (Measure.mem_support_iff_forall z).mp hz _ (ball_mem_nhds _ (half_pos hr)) + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] at hh + exact_mod_cast hh + have helow := eventually_thickening_lower hμ (ball z (r/2)) (half_pos hr) hpos + obtain ⟨n,hn,hni,hnlow⟩ := (hpa.and (hid.and helow)).exists + have hzero : (μs n : Measure X) (ball z r) = 0 := by + apply measure_mono_null (t := {w | c w ≠ f n (p w)}) + · intro w hw + exact dist_pos.mp (hbad hn (hball hw)) + · exact ae_iff.mp hni + have hsub : thickening (r/2) (ball z (r/2)) ⊆ ball z r := by + simpa only [add_halves] using thickening_ball z (r/2) (r/2) + have hzero' := measure_mono_null hsub hzero + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure, ENNReal.coe_eq_zero] at hzero' + rw [hzero'] at hnlow + exact (lt_irrefl (0 : ℝ)) hnlow + +end PlanarHalving.Limits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows Limits +open scoped Topology unitInterval + +lemma Configuration.points_ae (F : Configuration) (H : Labels → Prop) + (hH : ∀ p, H (F.label p)) : ∀ᵐ z ∂(F.points : Measure Labels), H z := by + apply Measure.ae_smul_measure + rw [ae_finsetSum_measure_iff] + intro i _ + simpa only [ae_dirac_eq,Filter.eventually_pure,Function.comp_apply] using hH (F.point i) + +lemma Converges.subseq {F : ℕ → Configuration} {L : Data} (h : Converges F L) + {φ : ℕ → ℕ} (hφ : StrictMono φ) : Converges (F ∘ φ) L := + ⟨h.points.comp hφ.tendsto_atTop,fun J => (h.vertices J).comp hφ.tendsto_atTop, + h.edgeTime.comp hφ.tendsto_atTop,fun J => (h.timeRestrict J).comp hφ.tendsto_atTop, + fun A B => (h.crossings A B).comp hφ.tendsto_atTop⟩ + +theorem Converges.rank_analytic {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + (b : Bool) {A B : Window} (hAB : Before A B) + {ι : Type*} [Countable ι] (C : ι → Window) + (hC : ∀ i, if b then Before (C i) A ∧ Before (C i) B else Before A (C i) ∧ Before B (C i)) : + ∃ (φ : ℕ → ℕ) (G : ι → Point → I), StrictMono φ ∧ + (∀ i, Monotone (G i) ∧ Measurable (G i)) ∧ + (∀ i, ∀ᵐ p ∂(volume : Measure Point), DifferentiableAt ℝ (fun x => (G i x : ℝ)) p) ∧ + (∀ i z, z ∈ (L.points : Measure Labels).support → + ContinuousAt (G i) (pairCoordinates b A B z) → + z (C i) = G i (pairCoordinates b A B z)) ∧ + (∀ i p, ContinuousAt (G i) p → + Tendsto (fun q : ℕ × Point => (F (φ q.1)).extendedRank b A B (C i) q.2) + (atTop ×ˢ 𝓝 p) (𝓝 (G i p))) := by + obtain ⟨φ,G,hφ,hG,hlim⟩ := RankLimit.monotone_joint_subsequence + (fun n i => (F n).extendedRank b A B (C i)) (fun n i => (F n).extendedRank_monotone b A B (C i)) + refine ⟨φ,G,hφ,hG,?_,?_,hlim⟩ + · intro i + apply Calculus.bounded_monotone_ae_differentiable (fun x y hxy => (hG i).1 hxy) + (measurable_subtype_coe.comp (hG i).2) (B:=1) + intro x + simpa only [Real.norm_eq_abs,abs_of_nonneg (G i x).property.1] using (G i x).property.2 + · intro i z hz hcont + apply support_coordinate_identity (h.subseq hφ).points (pairCoordinates b A B) + (continuous_pairCoordinates b A B) (fun z => z (C i)) (continuous_apply (C i)) + (fun n => (F (φ n)).extendedRank b A B (C i)) _ hz (hlim i _ hcont) + have hR' : Tendsto (fun n => (F (φ n)).R) atTop atTop := hR.comp hφ.tendsto_atTop + filter_upwards [eventually_length_pos _ hR' A,eventually_length_pos _ hR' B, + eventually_length_pos _ hR' (C i)] with n hnA hnB hnC + apply Configuration.points_ae + intro p + exact ((F (φ n)).extendedRank_eq b hAB (hC i) hnA hnB hnC p).symm + +end PlanarHalving.RankLimits + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology ENNReal + +lemma positive_single_component {X ι : Type*} [MeasurableSpace X] [Countable ι] + (μ : Measure X) [IsFiniteMeasure μ] (ν : ι → Measure X) [∀ i, IsFiniteMeasure (ν i)] + (hμ : μ ≪ Measure.sum ν) (hpos : μ univ ≠ 0) : + ∃ (i : ι) (A : Set X), MeasurableSet A ∧ μ A ≠ 0 ∧ μ.restrict A ≪ ν i := by + classical + choose A hA hsing hν using fun i => Measure.mutuallySingular_singularPart μ (ν i) + have hac (i : ι) : μ.restrict (A i) ≪ ν i := by + apply Measure.AbsolutelyContinuous.mk + intro B hB hzero + rw [Measure.restrict_apply hB,μ.haveLebesgueDecomposition_add (ν i),Measure.add_apply] + rw [measure_mono_null inter_subset_right (hsing i),zero_add] + exact withDensity_absolutelyContinuous (ν i) _ + (measure_mono_null inter_subset_left hzero) + have hnull : μ (⋃ i, A i)ᶜ = 0 := by + apply hμ + rw [Measure.sum_apply_eq_zero] + intro i + exact measure_mono_null (compl_subset_compl.mpr (subset_iUnion A i)) (hν i) + obtain ⟨i,hi⟩ : ∃ i, μ (A i) ≠ 0 := by + by_contra hh + push Not at hh + have hU : μ (⋃ i, A i) = 0 := measure_iUnion_null hh + exact hpos (by simpa only [union_compl_self] using measure_union_null hU hnull) + exact ⟨i,A i,hA i,hi,hac i⟩ + +lemma restrict_ac_withDensity {X : Type*} [MeasurableSpace X] (μ : Measure X) + (f : X → ℝ≥0∞) (hf : Measurable f) {A : Set X} (_hA : MeasurableSet A) + (hpos : ∀ x ∈ A, f x ≠ 0) : μ.restrict A ≪ μ.withDensity f := by + apply Measure.AbsolutelyContinuous.mk + intro B hB hzero + rw [Measure.restrict_apply hB] + have hh := (withDensity_apply_eq_zero hf).mp hzero + apply measure_mono_null (t := {x | f x ≠ 0} ∩ B) + · intro x hx + exact ⟨hpos x hx.2,hx.1⟩ + · exact hh + +end PlanarHalving.Limits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Directions.lean b/lean/OAI/Combinatorics/HalvingLines/Directions.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5c27293da42b0c495ff52e6130009e65a2db492 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Directions.lean @@ -0,0 +1,439 @@ +import OAI.Combinatorics.HalvingLines.Windows + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Directions +open MeasureTheory Set + +abbrev Plane := ℝ × ℝ + +def simplex (x : ℝ) : Plane := (x,1-x) + +lemma simplex_ne_zero (x : ℝ) : simplex x ≠ 0 := by + intro h + have h₁ := congrArg Prod.fst h + have h₂ := congrArg Prod.snd h + dsimp [simplex] at h₁ h₂ + linarith + +lemma simplex_affine (x y a b : ℝ) (hab : a+b=1) : + simplex (a*x+b*y) = a • simplex x+b • simplex y := by + ext <;> dsimp [simplex] + nlinarith + +def allowed {ι : Type*} (Q : Plane ≃L[ℝ] Plane) (g : ι → Plane →L[ℝ] ℝ) + (lo hi : ι → ℝ) (t : ℝ) : Set ℝ := + {x | x∈Icc 0 1 ∧ ∀ i, (hi i add_nonneg (mul_nonneg ha ((hx.2 i).1 h)) + (mul_nonneg hb ((hy.2 i).1 h)),fun h => add_nonpos + (mul_nonpos_of_nonneg_of_nonpos ha ((hx.2 i).2 h)) + (mul_nonpos_of_nonneg_of_nonpos hb ((hy.2 i).2 h))⟩ + +lemma allowed_disjoint {ι : Type*} (Q : Plane ≃L[ℝ] Plane) (g : ι → Plane →L[ℝ] ℝ) + (lo hi : ι → ℝ) {s t : ℝ} (i j : ι) + (hsi : s (g i v,g j v))) : + Disjoint (allowed Q g lo hi s) (allowed Q g lo hi t) := by + apply Set.disjoint_left.mpr + intro x hs ht + have hi₀ : g i (Q (simplex x))=0 := le_antisymm ((hs.2 i).2 hsi) ((ht.2 i).1 hit) + have hj₀ : g j (Q (simplex x))=0 := le_antisymm ((hs.2 j).2 hsj) ((ht.2 j).1 hjt) + have hv : Q (simplex x)=0 := hij (by simp only [hi₀,hj₀,map_zero]) + exact simplex_ne_zero x (Q.injective (by simpa only [map_zero] using hv)) + +theorem three_allowed_directions {ι : Type*} (μ : Measure ℝ) [NullSingletonClass μ] + (K : Set ℝ) (hK : Bornology.IsBounded K) (hpos : 0<μ K) + (Q : Plane ≃L[ℝ] Plane) (g : ι → Plane →L[ℝ] ℝ) (lo hi : ι → ℝ) + (hne : ∀ t∈K, (allowed Q g lo hi t).Nonempty) + (hgap : ∀ s∈K, ∀ t∈K, s (g i v,g j v))) : + ∃ t₁ t₂ t₃ d₁ d₂ d₃ : ℝ, + t₁∈K ∧ t₂∈K ∧ t₃∈K ∧ t₁ allowed_convex Q g lo hi t) + intro s hs t ht hst hp + obtain ⟨i,j,hsi,hit,hsj,hjt,hij⟩ := hgap s hs t ht hst hp + exact allowed_disjoint Q g lo hi i j hsi hit hsj hjt hij + +end PlanarHalving.Directions + +namespace PlanarHalving.TimeWindows +open MeasureTheory Set Filter UniformPartition Limits +open scoped Topology unitInterval NNReal + +lemma time_mem_cell (m : ℕ) [NeZero m] (i : Fin m) : time m i∈cell m i := by + have hm : (0 : ℝ) < m := Nat.cast_pos.mpr (NeZero.pos m) + have h₁ : (i : ℝ)/(m : ℝ)≤((i : ℝ)+1/2)/(m : ℝ) := by gcongr; norm_num + have h₂ : ((i : ℝ)+1/2)/(m : ℝ)<((i : ℝ)+1)/(m : ℝ) := by gcongr; norm_num + unfold cell + split_ifs + · constructor + · exact h₁ + · change ((i : ℝ)+1/2)/(m : ℝ)≤((i.val+1 : ℕ):ℝ)/(m : ℝ) + simpa only [Nat.cast_add,Nat.cast_one] using h₂.le + · constructor + · exact h₁ + · change ((i : ℝ)+1/2)/(m : ℝ)<((i.val+1 : ℕ):ℝ)/(m : ℝ) + simpa only [Nat.cast_add,Nat.cast_one] using h₂ + +noncomputable def midpointGrid (m : ℕ) [NeZero m] (t : I) : I := time m (index m t) + +lemma midpointGrid_measurable (m : ℕ) [NeZero m] : Measurable (midpointGrid m) := + (measurable_of_finite (time m)).comp (index_measurable m) + +lemma midpointGrid_dist (m : ℕ) [NeZero m] (t : I) : dist (midpointGrid m t) t≤1/(m : ℝ) := + cell_diameter_bound m (index m t) (time_mem_cell m _) (mem_cell_index m t) + +lemma midpointGrid_tendsto (m : ℕ → ℕ) [∀ n, NeZero (m n)] + (hm : Tendsto m atTop atTop) (t : I) : + Tendsto (fun n => midpointGrid (m n) t) atTop (𝓝 t) := by + apply tendsto_iff_dist_tendsto_zero.mpr + apply squeeze_zero (fun _ => dist_nonneg) (fun n => midpointGrid_dist (m n) t) + have hnat : Tendsto (fun n => (m n : ℝ)) atTop atTop := tendsto_natCast_atTop_atTop.comp hm + simpa only [one_div,Function.comp_def] using tendsto_inv_atTop_zero.comp hnat + +lemma integral_midpointGrid (m : ℕ) [NeZero m] (f : I → ℝ) : + ∫ t, f (midpointGrid m t) = (∑ i : Fin m, f (time m i))/(m : ℝ) := by + change ∫ t, (fun i : Fin m => f (time m i)) (index m t) = _ + rw [integral_partition volume (cell m) (cell_measurable m) (index m) (index_eq m) (fun i : Fin m => f (time m i))] + simp only [measureReal_def,cell_volume,ENNReal.toReal_ofReal (by positivity : 0≤1/(m : ℝ))] + rw [← Finset.mul_sum] + ring + +lemma midpoint_riemann_tendsto (m : ℕ → ℕ) [∀ n, NeZero (m n)] (hm : Tendsto m atTop atTop) + (f : BoundedContinuousFunction I ℝ) : + Tendsto (fun n => (∑ i : Fin (m n), f (time (m n) i))/(m n : ℝ)) atTop + (𝓝 (∫ t : I, f t)) := by + simp_rw [← integral_midpointGrid] + apply tendsto_integral_of_dominated_convergence (fun _ : I => ‖f‖) + · intro n + exact (f.continuous.measurable.comp (midpointGrid_measurable (m n))).aestronglyMeasurable + · exact integrable_const _ + · intro n + exact Eventually.of_forall (fun _ => f.norm_coe_le_norm _) + · exact Eventually.of_forall (fun t => (f.continuous.tendsto t).comp (midpointGrid_tendsto m hm t)) + +lemma timeMeasure_tendsto (m : ℕ → ℕ) [∀ n, NeZero (m n)] (hm : Tendsto m atTop atTop) : + Tendsto (fun n => weightedAtoms (m n : ℝ≥0)⁻¹ (time (m n))) atTop + (𝓝 (⟨volume,inferInstance⟩ : FiniteMeasure I)) := by + apply FiniteMeasure.tendsto_iff_forall_integral_tendsto.mpr + intro f + change Tendsto (fun n => ∫ x, f x ∂(weightedAtoms (m n : ℝ≥0)⁻¹ (time (m n)) : Measure I)) + atTop (𝓝 (∫ t : I, f t)) + simpa only [integral_weightedAtoms,NNReal.coe_inv,NNReal.coe_natCast, + ← div_eq_inv_mul] using midpoint_riemann_tendsto m hm f + +end PlanarHalving.TimeWindows + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology NNReal ENNReal +variable {X : Type*} [MetricSpace X] [Nonempty X] [MeasurableSpace X] [BorelSpace X] + +lemma restriction_limit_eq {μ lam : FiniteMeasure X} {μs lams : ℕ → FiniteMeasure X} + (hμ : Tendsto μs atTop (𝓝 μ)) (hlam : Tendsto lams atTop (𝓝 lam)) + {S : Set X} (_hS : MeasurableSet S) (hbd : (μ : Measure X) (frontier S)=0) + (he : ∀ n, (lams n : Measure X)=(μs n : Measure X).restrict S) : + (lam : Measure X)=(μ : Measure X).restrict S := by + let ν : FiniteMeasure X := ⟨(μ : Measure X).restrict S,inferInstance⟩ + have hclosed (F : Set X) (hF : IsClosed F) : lam F=ν F := by + obtain ⟨r,hr,hnull⟩ := exists_null_frontiers_thickening ((μ : Measure X)+(lam : Measure X)) F + have hval (j : ℕ) : lam (Metric.thickening (r j) F)=ν (Metric.thickening (r j) F) := by + let U := Metric.thickening (r j) F + have hU : MeasurableSet U := Metric.isOpen_thickening.measurableSet + have hnullμ : (μ : Measure X) (frontier U)=0 := by + have hh := (hnull j).2 + rw [Measure.add_apply] at hh + exact (add_eq_zero.mp hh).1 + have hnullLam : (lam : Measure X) (frontier U)=0 := by + have hh := (hnull j).2 + rw [Measure.add_apply] at hh + exact (add_eq_zero.mp hh).2 + have hnullUS : (μ : Measure X) (frontier (U∩S))=0 := + measure_mono_null ((frontier_inter_subset U S).trans + (union_subset_union inter_subset_left inter_subset_right)) (measure_union_null hnullμ hbd) + have h₁ := finiteMeasure_tendsto_apply hlam hnullLam + have h₂ := finiteMeasure_tendsto_apply hμ hnullUS + have h₂' : Tendsto (fun n => lams n U) atTop (𝓝 (ν U)) := by + convert h₂ using 1 + · funext n + change ((lams n : Measure X) U).toNNReal = _ + rw [he n,Measure.restrict_apply hU] + rfl + · change 𝓝 (((μ : Measure X).restrict S U).toNNReal) = _ + rw [Measure.restrict_apply hU] + rfl + exact tendsto_nhds_unique h₁ h₂' + have h₁ := finiteMeasure_tendsto_thickening lam hF hr (fun j => (hnull j).1) + have h₂ := finiteMeasure_tendsto_thickening ν hF hr (fun j => (hnull j).1) + exact tendsto_nhds_unique (h₁.congr (fun j => hval j)) h₂ + have heF (F : Set X) (hF : IsClosed F) : (lam : Measure X) F=(ν : Measure X) F := by + simpa only [FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] using congrArg (fun x : ℝ≥0 => (x : ℝ≥0∞)) (hclosed F hF) + change (lam : Measure X)=(ν : Measure X) + apply Measure.OuterRegular.ext_isOpen + intro U hU + rw [← compl_compl U,measure_compl hU.isClosed_compl.measurableSet (measure_ne_top _ _), + measure_compl hU.isClosed_compl.measurableSet (measure_ne_top _ _), + heF univ isClosed_univ,heF Uᶜ hU.isClosed_compl] + +end PlanarHalving.Limits +namespace PlanarHalving.RankCoordinates +open Set +open scoped ENNReal + +lemma smoothed_eVariation {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + (hg : ∀ j, ConvexOn ℝ univ (g j)) {f : ℝ → ℝ} (hf : ConcaveOn ℝ univ f) + {ε : ℝ} (hε : 0 < ε) : + eVariationOn (fun x => smoothed g ε (x,f x)) univ ≤ 2 := by + unfold eVariationOn + apply iSup_le + rintro ⟨n,x,hx,_⟩ + have h := smoothed_variation hm g hg hf hε x hx n + simpa only [edist_dist,Real.dist_eq,ENNReal.ofReal_sum_of_nonneg (fun i _ => abs_nonneg _), + ENNReal.ofReal_ofNat] using ENNReal.ofReal_le_ofReal h + +lemma sum_interval_eVariation {N : ℕ} {f : ℝ → ℝ} + (x : Fin (N+1) → ℝ) (hx : Monotone x) : + ∑ i : Fin N, eVariationOn f (Icc (x i.castSucc) (x i.succ)) ≤ eVariationOn f univ := by + let y : ℕ → ℝ := fun n => x ⟨min n N,by omega⟩ + have hy : Monotone y := fun i j hij => hx (by + show min i N ≤ min j N + exact min_le_min_right N hij) + have he : ∑ i : Fin N, eVariationOn f (Icc (x i.castSucc) (x i.succ)) = + ∑ i ∈ Finset.range N, eVariationOn f (Icc (y i) (y (i+1))) := by + rw [← Fin.sum_univ_eq_sum_range] + apply Finset.sum_congr rfl + intro i _ + have hi := i.isLt + congr 3 <;> apply Fin.ext <;> dsimp [y] <;> omega + rw [he,eVariationOn.sum' f hy] + exact eVariationOn.mono f (subset_univ _) + +end PlanarHalving.RankCoordinates +namespace PlanarHalving.Limits +open MeasureTheory +open scoped NNReal + +lemma map_weightedAtoms {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + [MeasurableSingletonClass X] [MeasurableSingletonClass Y] + {α : Type*} [Fintype α] (w : ℝ≥0) (x : α → X) {f : X → Y} (hf : Measurable f) : + (weightedAtoms w x).map f=weightedAtoms w (f∘x) := by + classical + apply FiniteMeasure.toMeasure_injective + change Measure.map f (w • (∑ i, Measure.dirac (x i) : Measure X))= + w • (∑ i, Measure.dirac (f (x i)) : Measure Y) + rw [Measure.map_smul _ hf.aemeasurable,Measure.map_finset_sum hf.aemeasurable] + simp only [Measure.map_dirac] + +end PlanarHalving.Limits +namespace PlanarHalving.Batches +open MeasureTheory Set Filter Limits TimeWindows +open scoped Topology NNReal ENNReal unitInterval +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.sum_edgeTime (S : @System n R k a P) [NeZero R] [NeZero a] (f : I → ℝ) : + ∑ e : ↥S.edges, f (S.edgeTime e) = (a : ℝ)^2 * ∑ b : Fin R, f (time R b) := by + classical + change ∑ e : ↥S.edges, f (time R (S.trace e.property).batch)=_ + rw [← Finset.sum_fiberwise' Finset.univ (fun e : ↥S.edges => (S.trace e.property).batch) + (fun b => f (time R b))] + simp only [Finset.sum_const,S.edgeTime_distribution,nsmul_eq_mul,Nat.cast_pow] + exact (Finset.mul_sum ..).symm + +lemma System.edgeTime_atoms (S : @System n R k a P) [NeZero R] [NeZero a] : + weightedAtoms ((R : ℝ≥0)*(a : ℝ≥0)^2)⁻¹ S.edgeTime= + weightedAtoms (R : ℝ≥0)⁻¹ (time R) := by + apply FiniteMeasure.ext_of_forall_integral_eq + intro f + simp only [integral_weightedAtoms,S.sum_edgeTime,NNReal.coe_inv,NNReal.coe_mul, + NNReal.coe_pow,NNReal.coe_natCast] + have hR : (R : ℝ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne R) + have ha : (a : ℝ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne a) + field_simp + +noncomputable def System.labelTimeMeasure (S : @System n R k a P) [NeZero R] [NeZero a] + {X : Type*} [MeasurableSpace X] (z : Fin n → X) : FiniteMeasure (X×I) := + weightedAtoms ((R : ℝ≥0)*(a : ℝ≥0)^2)⁻¹ (fun e : ↥S.edges => (z e.val.1,S.edgeTime e)) + +lemma System.labelTimeMeasure_time (S : @System n R k a P) [NeZero R] [NeZero a] + {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] (z : Fin n → X) : + (S.labelTimeMeasure z).map Prod.snd=weightedAtoms (R : ℝ≥0)⁻¹ (time R) := by + rw [System.labelTimeMeasure,map_weightedAtoms _ _ measurable_snd] + exact S.edgeTime_atoms + +lemma System.labelTimeMeasure_space (S : @System n R k a P) [NeZero R] [NeZero a] + {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] (z : Fin n → X) : + (S.labelTimeMeasure z).map Prod.fst=S.endpointMeasure z ((R : ℝ≥0)*(a : ℝ≥0)^2) := by + rw [System.labelTimeMeasure,map_weightedAtoms _ _ measurable_fst] + rfl + +lemma System.labelTimeMeasure_mass (S : @System n R k a P) [NeZero R] [NeZero a] + {X : Type*} [MeasurableSpace X] (z : Fin n → X) : + (S.labelTimeMeasure z).mass=1 := by + rw [System.labelTimeMeasure,mass_weightedAtoms] + simp only [Fintype.card_coe,S.card_edges,Nat.cast_mul,Nat.cast_pow] + exact inv_mul_cancel₀ (mul_ne_zero (Nat.cast_ne_zero.mpr (NeZero.ne R)) + (pow_ne_zero _ (Nat.cast_ne_zero.mpr (NeZero.ne a)))) + +end PlanarHalving.Batches +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates +open scoped ENNReal +variable {R n k a : ℕ} {P : Fin n → Point} + +lemma ConvexPath.x_monotone (C : ConvexPath R) : Monotone (fun i => (C.point i).1) := by + intro i j hij + apply fin_between_le i j hij + intro b _ _ + rcases C.right b with he | he + · exact le_of_eq (congrArg Prod.fst he) + · exact he.le + +lemma segment_fst_mem {p q z : Point} (hpq : p.1 ≤ q.1) + (hz : z∈segment ℝ p q) : z.1∈Icc p.1 q.1 := by + rw [segment_eq_image] at hz + obtain ⟨t,ht,rfl⟩ := hz + simp only [Prod.fst_add,Prod.smul_fst,smul_eq_mul,mem_Icc] + constructor <;> nlinarith [mul_nonneg (sub_nonneg.mpr hpq) ht.1, + mul_nonneg (sub_nonneg.mpr hpq) (sub_nonneg.mpr ht.2)] + +lemma ConvexPath.sum_rank_oscillation (C : ConvexPath R) {l u : ℝ} + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ + slope (C.point b.castSucc) (C.point b.succ) ≤ u) + {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + (hg : ∀ j, ConvexOn ℝ univ (g j)) {ε : ℝ} (hε : 0 < ε) : + ∑ b : Fin R, Metric.ediam ((fun z => smoothed g ε (-z)) '' + segment ℝ (C.point b.castSucc) (C.point b.succ)) ≤ 2 := by + let f := C.extension l u + let g' : Fin m → ℝ → ℝ := fun j x => g j (-x) + let F : ℝ → ℝ := fun x => smoothed g' ε (x,-f x) + have hg' (j : Fin m) : ConvexOn ℝ univ (g' j) := by + simpa only [Set.preimage_univ,Function.comp_def,LinearMap.neg_apply,LinearMap.id_apply] + using (hg j).comp_linearMap (-LinearMap.id : ℝ →ₗ[ℝ] ℝ) + have hf : ConcaveOn ℝ univ (fun x => -f x) := + (convexOn_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u)).neg + have hF : eVariationOn F univ ≤ 2 := smoothed_eVariation hm g' hg' hf hε + have hpiece (b : Fin R) : + Metric.ediam ((fun z => smoothed g ε (-z)) '' + segment ℝ (C.point b.castSucc) (C.point b.succ)) ≤ + eVariationOn F (Icc (C.point b.castSucc).1 (C.point b.succ).1) := by + by_cases hb : C.point b.castSucc=C.point b.succ + · simp only [hb,segment_same,image_singleton,Metric.ediam_singleton] + exact zero_le + · apply Metric.ediam_image_le_iff.mpr + intro z hz w hw + have hz' := C.extension_edge hsl b hb hz + have hw' := C.extension_edge hsl b hb hw + have hze : smoothed g ε (-z)=F z.1 := by + dsimp [F,f,g',smoothed] + rw [hz'] + have hwe : smoothed g ε (-w)=F w.1 := by + dsimp [F,f,g',smoothed] + rw [hw'] + rw [hze,hwe] + exact eVariationOn.edist_le F (segment_fst_mem (C.x_monotone (Fin.castSucc_le_succ b)) hz) + (segment_fst_mem (C.x_monotone (Fin.castSucc_le_succ b)) hw) + exact (Finset.sum_le_sum (fun b _ => hpiece b)).trans + ((sum_interval_eVariation (fun i => (C.point i).1) C.x_monotone).trans hF) + +lemma System.sum_edges_le_paths (S : @System n R k a P) [NeZero a] + (W : Point → Point → ℝ≥0∞) (hpath : ∀ j : Fin a, ∀ u : ↥(S.marks 0), + ∑ b : Fin R, W ((S.tokenPath j u).point b.castSucc) + ((S.tokenPath j u).point b.succ) ≤ 2) : + ∑ e : ↥S.edges, W (P e.val.1) (P e.val.2) ≤ 2*a*n := by + classical + let ι := Fin a × (↥(S.marks 0) × Fin R) + let T (e : ↥S.edges) := S.trace e.property + let tag : ↥S.edges → ι := fun e => ((T e).number,((T e).token,(T e).batch)) + let w : ι → ℝ≥0∞ := fun i => W ((S.tokenPath i.1 i.2.1).point i.2.2.castSucc) + ((S.tokenPath i.1 i.2.1).point i.2.2.succ) + have ht : Function.Injective tag := by + intro e f h + have hn := congrArg Prod.fst h + have hu := congrArg (fun i : ι => i.2.1) h + have hb := congrArg (fun i : ι => i.2.2) h + dsimp only [tag] at hn hu hb + apply Subtype.ext + apply Prod.ext + · rw [← (T e).source,←(T f).source] + rw [hn,hu,hb] + · rw [← (T e).target,←(T f).target] + rw [hn,hu,hb] + have hw (e : ↥S.edges) : W (P e.val.1) (P e.val.2)=w (tag e) := by + dsimp [w,tag,System.tokenPath] + rw [(T e).source,(T e).target] + calc + _ = ∑ e : ↥S.edges, w (tag e) := Fintype.sum_congr _ _ hw + _ = ∑ i ∈ Finset.univ.image tag, w i := (Finset.sum_image (fun _ _ _ _ h => ht h)).symm + _ ≤ ∑ i : ι, w i := Finset.sum_le_sum_of_subset (Finset.subset_univ _) + _ = ∑ j : Fin a, ∑ u : ↥(S.marks 0), ∑ b : Fin R, + W ((S.tokenPath j u).point b.castSucc) ((S.tokenPath j u).point b.succ) := by + dsimp only [ι] + simp only [Fintype.sum_prod_type,w] + _ ≤ ∑ _j : Fin a, ∑ _u : ↥(S.marks 0), (2 : ℝ≥0∞) := by + gcongr with j u + exact hpath j u + _ = 2*a*(S.marks 0).card := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,Fintype.card_coe,nsmul_eq_mul] + ring + _ ≤ 2*a*n := by + have hc : (S.marks 0).card ≤ n := (S.marks 0).card_le_univ.trans (by simp) + gcongr + +theorem System.rank_oscillation (S : @System n R k a P) [NeZero a] + {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + (hg : ∀ j, ConvexOn ℝ univ (g j)) {ε : ℝ} (hε : 0 < ε) : + ∑ e : ↥S.edges, Metric.ediam (smoothed g ε '' segment ℝ (P e.val.1) (P e.val.2)) ≤ 2*a*n := by + classical + let W : Point → Point → ℝ≥0∞ := fun p q => + Metric.ediam ((fun z => smoothed g ε (-z)) '' segment ℝ p q) + have hp (j : Fin a) (v : ↥(S.flip.marks 0)) : + ∑ b : Fin R, W ((S.flip.tokenPath j v).point b.castSucc) + ((S.flip.tokenPath j v).point b.succ) ≤ 2 := by + apply (S.flip.tokenPath j v).sum_rank_oscillation + (l := S.slope 0) (u := S.slope (Fin.last R)) _ hm g hg hε + intro b hb + exact ⟨(S.flip.tokenPath_bounds j v b hb).1.le,(S.flip.tokenPath_bounds j v b hb).2.le⟩ + have hb := S.flip.sum_edges_le_paths W hp + let e : ↥S.edges ≃ ↥S.flip.edges := + { toFun := fun e => ⟨e.val.swap,(S.flip_edge _).mpr e.property⟩ + invFun := fun e => ⟨e.val.swap,(S.flip_edge _).mp (by simp only [Prod.swap_swap]; exact e.property)⟩ + left_inv := by intro x; apply Subtype.ext; exact Prod.swap_swap _ + right_inv := by intro x; apply Subtype.ext; exact Prod.swap_swap _ } + have hsum : (∑ v : ↥S.edges, Metric.ediam (smoothed g ε '' segment ℝ (P v.val.1) (P v.val.2))) = + ∑ v : ↥S.flip.edges, W (-P v.val.1) (-P v.val.2) := by + apply Fintype.sum_equiv e + intro v + change Metric.ediam (smoothed g ε '' segment ℝ (P v.val.1) (P v.val.2)) = + Metric.ediam ((fun z => smoothed g ε (-z)) '' segment ℝ (-P v.val.2) (-P v.val.1)) + have hseg : (fun z : Point => -z) '' segment ℝ (-P v.val.2) (-P v.val.1) = + segment ℝ (P v.val.2) (P v.val.1) := by + simpa using image_segment ℝ ((-LinearMap.id : Point →ₗ[ℝ] Point).toAffineMap) + (-P v.val.2) (-P v.val.1) + congr 1 + calc + _ = smoothed g ε '' ((fun z : Point => -z) '' segment ℝ (-P v.val.2) (-P v.val.1)) := by + rw [hseg,segment_symm] + _ = _ := Set.image_image _ _ _ + rw [hsum] + exact hb + +end PlanarHalving.Batches + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Enhancement.lean b/lean/OAI/Combinatorics/HalvingLines/Enhancement.lean new file mode 100644 index 0000000000000000000000000000000000000000..55ccd59dcced060cab6b2723e9e836991b154d46 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Enhancement.lean @@ -0,0 +1,377 @@ +import OAI.Combinatorics.HalvingLines.MassEstimates + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Enhancement +open RankLimits Batches TimeWindows Limits Spatial MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +abbrev Space := Labels × Cube +noncomputable def label (F : Configuration) (ψ : Point → Point) (p : Point) : Space := + (F.label p,encode (ψ p)) +noncomputable def points (F : Configuration) (ψ : Point → Point) : FiniteMeasure Space := + weightedAtoms (F.n:ℝ≥0)⁻¹ (fun v => label F ψ (F.point v)) +noncomputable def vertices (F : Configuration) (ψ : Point → Point) (J : Window) : FiniteMeasure Space := + (F.system.timeWindow J).vertexMeasure (fun v => label F ψ (F.point v)) +noncomputable def edges (F : Configuration) (ψ : Point → Point) (J : Window) : FiniteMeasure Space := + (F.system.timeWindow J).endpointMeasure (fun v => label F ψ (F.point v)) ((F.R:ℝ≥0)*F.a^2) + +lemma points_map (F : Configuration) (ψ : Point → Point) : (points F ψ).map Prod.fst=F.points := by + rw [points,map_weightedAtoms _ _ measurable_fst] + rfl +lemma vertices_map (F : Configuration) (ψ : Point → Point) (J : Window) : + (vertices F ψ J).map Prod.fst=F.vertices J := by + rw [vertices,System.vertexMeasure,map_weightedAtoms _ _ measurable_fst] + rfl +lemma edges_map (F : Configuration) (ψ : Point → Point) (J : Window) : + (edges F ψ J).map Prod.fst=F.edgeWindow J := by + rw [F.edgeWindow_eq,edges,System.endpointMeasure,map_weightedAtoms _ _ measurable_fst] + rfl + +lemma points_mass (F : Configuration) (ψ : Point → Point) : (points F ψ).mass=1 := by + rw [points,mass_weightedAtoms,Fintype.card_fin] + exact inv_mul_cancel₀ (Nat.cast_ne_zero.mpr (NeZero.ne F.n)) +lemma vertices_mass (F : Configuration) (ψ : Point → Point) (J : Window) : + (vertices F ψ J).mass=(F.vertices J).mass := by + simp only [vertices,Configuration.vertices,System.vertexMeasure,mass_weightedAtoms] +lemma edges_mass (F : Configuration) (ψ : Point → Point) (J : Window) : + (edges F ψ J).mass=(F.edgeWindow J).mass := by + rw [F.edgeWindow_eq,edges] + simp only [System.endpointMeasure,mass_weightedAtoms] + +inductive Index where + | point + | vertex (J : Window) + | edge (J : Window) + deriving Countable + +noncomputable def measures (F : Configuration) (ψ : Point → Point) : Index → FiniteMeasure Space + | .point => points F ψ + | .vertex J => vertices F ψ J + | .edge J => edges F ψ J +noncomputable def old (L : Data) : Index → FiniteMeasure Labels + | .point => L.points + | .vertex J => L.vertices J + | .edge J => L.edgeWindow J + +lemma measures_mass_le (F : Configuration) (ψ : Point → Point) (i : Index) : + (measures F ψ i).mass≤1 := by + cases i with + | point => exact (points_mass F ψ).le + | vertex J => exact (vertices_mass F ψ J).le.trans (F.vertices_mass_le J) + | edge J => + change (edges F ψ J).mass≤1 + rw [edges_mass] + exact (FiniteMeasure.mass_map_le (μ := F.timeRestrict J) + measurable_fst.aemeasurable).trans (F.timeRestrict_mass_le J) + +theorem subsequence {F : ℕ → Configuration} {L : Data} (hF : Converges F L) + (ψ : ℕ → Point → Point) : + ∃ (φ : ℕ → ℕ) (M : Index → FiniteMeasure Space), StrictMono φ ∧ + (∀ i, Tendsto (fun n => measures (F (φ n)) (ψ (φ n)) i) atTop (𝓝 (M i))) ∧ + ∀ i, (M i).map Prod.fst=old L i := by + obtain ⟨φ,M,hφ,hM⟩ := finiteMeasure_subsequence_dependent (X:=fun _ : Index => Space) + (fun n i => measures (F n) (ψ n) i) (fun _ => 1) (fun n i => measures_mass_le (F n) (ψ n) i) + refine ⟨φ,M,hφ,hM,?_⟩ + intro i + have hm := (FiniteMeasure.continuous_map continuous_fst).tendsto (M i) |>.comp (hM i) + apply tendsto_nhds_unique hm + cases i with + | point => + change Tendsto (fun n => (points (F (φ n)) (ψ (φ n))).map Prod.fst) atTop (𝓝 L.points) + simp_rw [points_map] + exact hF.points.comp hφ.tendsto_atTop + | vertex J => + change Tendsto (fun n => (vertices (F (φ n)) (ψ (φ n)) J).map Prod.fst) atTop (𝓝 (L.vertices J)) + simp_rw [vertices_map] + exact (hF.vertices J).comp hφ.tendsto_atTop + | edge J => + change Tendsto (fun n => (edges (F (φ n)) (ψ (φ n)) J).map Prod.fst) atTop (𝓝 (L.edgeWindow J)) + simp_rw [edges_map] + exact (hF.edgeWindow J).comp hφ.tendsto_atTop + +lemma vertices_le_points (F : Configuration) (ψ : Point → Point) (J : Window) : + (vertices F ψ J : Measure Space)≤(points F ψ : Measure Space) := by + apply Measure.le_iff.mpr + intro U hU + have he : (vertices F ψ J U:ℝ)≤(points F ψ U:ℝ) := by + rw [vertices,System.vertexMeasure_apply _ _ hU,points,weightedAtoms_apply_finset _ _ hU] + simp only [NNReal.coe_inv,NNReal.coe_natCast,div_eq_inv_mul] + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact_mod_cast Finset.card_le_card (Finset.filter_subset_filter _ (Finset.subset_univ _)) + simpa only [FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] using + (ENNReal.coe_le_coe.mpr (NNReal.coe_le_coe.mp he)) + +lemma local_cubic {F : ℕ → Configuration} {ψ : ℕ → Point → Point} + {M : Index → FiniteMeasure Space} + (hM : ∀ i, Tendsto (fun n => measures (F n) (ψ n) i) atTop (𝓝 (M i))) + {C : ℝ} (hC : 0≤C) + (hcoeff : ∀ n, 4608*((F n).a:ℝ)^2*(F n).n^4 / + (((F n).R:ℝ)*(F n).a^2)^3≤C) + (herror : Tendsto (fun n => 13824*((F n).n:ℝ)^3 / + (((F n).R:ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (J : Window) {U : Set Space} (hU : MeasurableSet U) : + (M (.edge J) U:ℝ)^3≤C*((M (.vertex J)).mass:ℝ)^3*(M (.vertex J) U:ℝ) := by + have hm := NNReal.continuous_coe.tendsto _ |>.comp + (FiniteMeasure.continuous_mass.tendsto _ |>.comp (hM (.vertex J))) + apply cubed_bound_limit (hM (.vertex J)) (hM (.edge J)) + (mul_nonneg hC (pow_nonneg (NNReal.coe_nonneg _) _)) ((hm.pow 3).const_mul C) herror + · intro n V hV + have hR : 0<((F n).R:ℝ≥0) := Nat.cast_pos.mpr (F n).R_pos + have ha : 0<((F n).a:ℝ≥0) := Nat.cast_pos.mpr (F n).a_pos + have hh := ((F n).system.timeWindow J).atomic_cubed_bound (F n).generic + (fun v => label (F n) (ψ n) ((F n).point v)) (show 0<((F n).R:ℝ≥0)*(F n).a^2 by positivity) hV + change (edges (F n) (ψ n) J V:ℝ)^3≤_ + apply hh.trans + apply add_le_add + · dsimp only [Function.comp_apply] + push_cast + rw [show ((measures (F n) (ψ n) (.vertex J)).mass:ℝ)= + (((F n).system.timeWindow J).vertices.card:ℝ)/(F n).n from by + change ((vertices (F n) (ψ n) J).mass:ℝ)=_ + rw [vertices_mass,(F n).vertices_mass_ratio]] + apply mul_le_mul_of_nonneg_right _ (NNReal.coe_nonneg _) + exact mul_le_mul_of_nonneg_right (hcoeff n) (pow_nonneg (by positivity) _) + · apply div_le_div_of_nonneg_right _ (by positivity) + apply mul_le_mul_of_nonneg_left _ (by norm_num) + apply pow_le_pow_left₀ (Nat.cast_nonneg _) _ 3 + exact_mod_cast (show ((F n).system.timeWindow J).vertices.card≤(F n).n by + simpa only [Fintype.card_fin] using ((F n).system.timeWindow J).vertices.card_le_univ) + · exact hU + +end PlanarHalving.Enhancement + +namespace PlanarHalving.Spatial +open Set Filter Metric MeasureTheory +open scoped Topology ENNReal + +lemma support_lift_restrict {X : Type*} [TopologicalSpace X] [MeasurableSpace X] + [OpensMeasurableSpace X] [HereditarilyLindelofSpace X] + (μ ρ : Measure X) (hac : ρ ≪ μ) (A : Set X) : + ρ.restrict (A∩μ.support)=ρ.restrict A := by + apply Measure.restrict_congr_set + filter_upwards [hac.ae_le μ.support_mem_ae] with x hx + exact propext ⟨fun h => h.1,fun ha => ⟨ha,hx⟩⟩ + +lemma support_lift_disk {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + (μ : Measure (X × Cube)) (G : Set X) (hG : MeasurableSet G) + (π : X → Point) (hπ : Measurable π) (l : (π '' G) → Point) + {m : ℕ} {c : ℝ} (hc : 0 by rw [hg z hz]; exact hl _, + (m:ℝ)*(4*(2/c)^((32:ℝ)/17)),by positivity,?_⟩ + intro x r hr + have hh := disk_bound_of_inverse_holder μ H hH (π∘Prod.fst) (decode∘Prod.snd) + (hπ.comp measurable_fst) (measurable_decode.comp measurable_snd) + hc (by norm_num : (0:ℝ)<17/16) hd (by + intro z hz w hw + simpa only [Function.comp_apply,hg z hz,hg w hw] using + hsep ⟨π z.1,mem_image_of_mem π hz.1⟩ ⟨π w.1,mem_image_of_mem π hw.1⟩) x hr + convert hh using 1 + norm_num only [show (2:ℝ)/(17/16)=32/17 by norm_num, + ENNReal.ofReal_mul (Nat.cast_nonneg m),ENNReal.ofReal_natCast, + ENNReal.ofReal_mul (by positivity : 0≤(4:ℝ)*(2/c)^((32:ℝ)/17)),mul_assoc] + rw [← ENNReal.ofReal_mul (by positivity)] + congr 2 + ring + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Metric Boundary + +lemma unit_sqNorm_coordinate_bounds {v : Point} (hv : sqNorm v=1) : + |v.1|≤1 ∧ |v.2|≤1 := by + dsimp [sqNorm] at hv + constructor + · apply (sq_le_sq₀ (abs_nonneg _) zero_le_one).mp + rw [sq_abs]; nlinarith [sq_nonneg v.2] + · apply (sq_le_sq₀ (abs_nonneg _) zero_le_one).mp + rw [sq_abs]; nlinarith [sq_nonneg v.1] + +lemma unit_sqNorm_norm {v : Point} (hv : sqNorm v=1) : ‖v‖≤1 := by + rw [Prod.norm_def] + exact max_le (unit_sqNorm_coordinate_bounds hv).1 (unit_sqNorm_coordinate_bounds hv).2 + +lemma transverse_decomposition {ν : Point} (hν : sqNorm ν=1) (w : Point) : + w=(dot (-ν.2,ν.1) w) • (-ν.2,ν.1)+(dot ν w) • ν := by + dsimp [sqNorm] at hν + ext <;> dsimp [dot] <;> nlinarith [congrArg (fun t : ℝ => t*w.1) hν, + congrArg (fun t : ℝ => t*w.2) hν] + +lemma bounded_strip_cover (ν : Point) (hν : sqNorm ν=1) (c : ℝ) + {r : ℝ} (hr : 0 0,by simp; positivity,?_⟩ + intro x hx + exact (hA ⟨x,hx⟩).elim + obtain ⟨a,ha⟩ := hA + let v : Point := (-ν.2,ν.1) + have hv : sqNorm v=1 := by dsimp [v,sqNorm]; simpa only [sqNorm,neg_sq,add_comm] using hν + have hnν := unit_sqNorm_norm hν + have hnv := unit_sqNorm_norm hv + let k : ℤ := ⌈4/r⌉+1 + let S : Finset ℤ := Finset.Icc (-k) k + have hkpos : 0≤k := by + have hh := Int.le_ceil (4/r) + have : (0:ℝ)≤(k:ℝ) := by dsimp [k]; push_cast; linarith [div_pos (by norm_num : (0:ℝ)<4) hr] + exact_mod_cast this + have hkbound : (k:ℝ)≤4/r+2 := by + have hh := Int.ceil_lt_add_one (4/r) + dsimp [k]; push_cast; linarith + have hcard : (S.card:ℝ)=2*(k:ℝ)+1 := by + dsimp [S] + rw [Int.card_Icc] + rw [show ((k+1- -k).toNat:ℝ)=((k+1- -k):ℝ) by + exact_mod_cast (Int.toNat_of_nonneg (by omega : 0≤k+1- -k))] + ring + refine ⟨S,fun j => a+(r*(j:ℝ)) • v,?_,?_⟩ + · rw [hcard] + apply (le_div_iff₀ hr).mpr + have hh := mul_le_mul_of_nonneg_right hkbound hr.le + rw [add_mul,div_mul_cancel₀ _ hr.ne'] at hh + nlinarith + · intro x hx + have hdiff : ‖x-a‖≤2 := by + have hx' : ‖x‖≤1 := by simpa only [mem_closedBall,dist_zero_right] using hx.1 + have ha' : ‖a‖≤1 := by simpa only [mem_closedBall,dist_zero_right] using ha.1 + exact (norm_sub_le _ _).trans (by linarith) + let t : ℝ := dot v (x-a) + let δ : ℝ := dot ν (x-a) + have hδ : |δ|≤2*r := by + have he : δ=(dot ν x-c)-(dot ν a-c) := by dsimp [δ,dot]; ring + rw [he] + have hx2 : |dot ν x-c|≤r := hx.2 + have ha2 : |dot ν a-c|≤r := ha.2 + exact (abs_sub _ _).trans (by linarith) + have ht : |t|≤4 := by + have h1 : |(x-a).1|≤2 := (le_max_left _ _).trans hdiff + have h2 : |(x-a).2|≤2 := (le_max_right _ _).trans hdiff + have hv' := unit_sqNorm_coordinate_bounds hv + dsimp [t,dot] + apply (abs_add_le _ _).trans + rw [abs_mul,abs_mul] + have hh1 := mul_le_mul hv'.1 h1 (abs_nonneg _) zero_le_one + have hh2 := mul_le_mul hv'.2 h2 (abs_nonneg _) zero_le_one + dsimp only [Prod.fst_sub,Prod.snd_sub] at hh1 hh2 + linarith + let j : ℤ := ⌊t/r⌋ + have hjlo : (j:ℝ)≤t/r := Int.floor_le _ + have hjhi : t/r<(j:ℝ)+1 := Int.lt_floor_add_one _ + have hceil : 4/r≤(⌈4/r⌉:ℤ) := Int.le_ceil _ + have htlo : -(4/r)≤t/r := by + apply (le_div_iff₀ hr).mpr + have ht' := (abs_le.mp ht).1 + rw [neg_mul,div_mul_cancel₀ _ hr.ne'] + exact ht' + have hthi : t/r≤4/r := (div_le_div_iff_of_pos_right hr).mpr (abs_le.mp ht).2 + have hjmem : j∈S := by + apply Finset.mem_Icc.mpr + constructor + · have : -(k:ℝ)≤(j:ℝ) := by dsimp [k]; push_cast; linarith + exact_mod_cast this + · have : (j:ℝ)≤(k:ℝ) := by dsimp [k]; push_cast; linarith + exact_mod_cast this + refine mem_iUnion.mpr ⟨j,mem_iUnion.mpr ⟨hjmem,?_⟩⟩ + have he : x-(a+(r*(j:ℝ)) • v)=(t-r*(j:ℝ)) • v+δ • ν := by + have hw := transverse_decomposition hν (x-a) + change x-a=t • v+δ • ν at hw + calc + x-(a+(r*(j:ℝ)) • v) = (x-a)-(r*(j:ℝ)) • v := by abel + _ = _ := by rw [hw]; module + rw [mem_closedBall,dist_eq_norm,he] + have htr0 : 0≤t-r*(j:ℝ) := by + have hh := (le_div_iff₀ hr).mp hjlo + nlinarith + have htr1 : t-r*(j:ℝ)≤r := by + have hh := (div_lt_iff₀ hr).mp hjhi + nlinarith + apply (norm_add_le _ _).trans + rw [norm_smul,norm_smul,Real.norm_eq_abs,Real.norm_eq_abs,abs_of_nonneg htr0] + have hh1 := mul_le_mul htr1 hnv (norm_nonneg _) hr.le + have hh2 := mul_le_mul hδ hnν (norm_nonneg _) (by positivity : 0≤2*r) + linarith + +open MeasureTheory Filter +open scoped ENNReal Topology +lemma strip_bound_of_disk (μ : Measure Point) {C d : ℝ} (_hC : 0≤C) + (hbound : ∀ x : Point, ∀ r : ℝ, 0 hbound (a j) (3*r) (by positivity)) + _ = (S.card:ℝ≥0∞)*ENNReal.ofReal (C*(3*r)^d) := by simp + _ ≤ ENNReal.ofReal (13/r)*ENNReal.ofReal (C*(3*r)^d) := mul_le_mul' hcast le_rfl + _ = _ := by + rw [← ENNReal.ofReal_mul (by positivity)] + congr 1 + rw [Real.mul_rpow (by norm_num : (0:ℝ)≤3) hr.le,Real.rpow_sub hr] + simp only [Real.rpow_one] + ring + +lemma line_null_of_disk (μ : Measure Point) {C d : ℝ} (hC : 0≤C) (hd : 1] (0:ℝ), a≤ENNReal.ofReal (13*C*3^d*r^(d-1)) := by + have hu : ∀ᶠ r in 𝓝[>] (0:ℝ), r<1 := (eventually_lt_nhds (by norm_num : (0:ℝ)<1)).filter_mono inf_le_left + filter_upwards [self_mem_nhdsWithin,hu] with r hr hr1 + have hr : (0:ℝ) ENNReal.ofReal (13*C*3^d*r^(d-1))) (𝓝[>] 0) (𝓝 0) := by + have hh : Tendsto (fun r : ℝ => r^(d-1)) (𝓝 (0:ℝ)) (𝓝 (0:ℝ)) := by + convert (Real.continuous_rpow_const (sub_nonneg.mpr hd.le)).tendsto (0:ℝ) using 1 + exact (Real.zero_rpow (sub_ne_zero.mpr hd.ne')).symm ▸ rfl + have hh' : Tendsto (fun r : ℝ => r^(d-1)) (𝓝[>] (0:ℝ)) (𝓝 (0:ℝ)) := + hh.mono_left nhdsWithin_le_nhds + have hc : Tendsto (fun r : ℝ => 13*C*3^d*r^(d-1)) (𝓝[>] (0:ℝ)) (𝓝 (0:ℝ)) := by + simpa only [mul_zero] using hh'.const_mul (13*C*3^d) + convert (ENNReal.continuous_ofReal.tendsto (0:ℝ)).comp hc using 1 + · rfl + · rw [ENNReal.ofReal_zero] + exact le_antisymm (ge_of_tendsto ht hb) zero_le + +end PlanarHalving.Spatial + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Foliations.lean b/lean/OAI/Combinatorics/HalvingLines/Foliations.lean new file mode 100644 index 0000000000000000000000000000000000000000..403e7d0175466398439a766c7bcceb68d3155ca4 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Foliations.lean @@ -0,0 +1,405 @@ +import OAI.Combinatorics.HalvingLines.ZoomControl + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +lemma equiv_opNorm_pos (A : Point ≃L[ℝ] Point) : 0<‖A.toContinuousLinearMap‖ := by + apply norm_pos_iff.mpr + intro he + have ht : A (1,0)=0 := by + have hh := congrArg (fun f : Point →L[ℝ] Point => f (1,0)) he + exact hh + have hz : ((1,0):Point)=0 := A.injective (ht.trans (map_zero A).symm) + have h1 := congrArg Prod.fst hz + norm_num at h1 + +noncomputable def normalizedLinear (A : Point ≃L[ℝ] Point) : Point →L[ℝ] Point := + ‖A.toContinuousLinearMap‖⁻¹ • A.toContinuousLinearMap + +lemma normalizedLinear_norm (A : Point ≃L[ℝ] Point) : ‖normalizedLinear A‖=1 := by + exact norm_smul_inv_norm (norm_pos_iff.mp (equiv_opNorm_pos A)) + +lemma unit_conorm_all (A : Point →L[ℝ] Point) (ε : ℝ) + (h : ∀ x : Point, ‖x‖=1 → ε ≤ ‖A x‖) : ∀ x : Point, ε*‖x‖ ≤ ‖A x‖ := by + intro x + by_cases hx : x=0 + · simp [hx] + · have hn : 0<‖x‖ := norm_pos_iff.mpr hx + have he := h (‖x‖⁻¹ • x) (norm_smul_inv_norm hx) + rw [map_smul,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hn)] at he + have ht := mul_le_mul_of_nonneg_left he hn.le + calc + ε*‖x‖ = ‖x‖*ε := mul_comm _ _ + _ ≤ ‖x‖*(‖x‖⁻¹*‖A x‖) := ht + _ = ‖A x‖ := by rw [← mul_assoc,mul_inv_cancel₀ hn.ne',one_mul] + +lemma normalizedLinear_subsequence (A : ℕ → Point ≃L[ℝ] Point) (ε : ℝ) + (hε : 0<ε) + (hbound : ∀ᶠ n in atTop, ∀ x : Point, ‖x‖=1 → ε ≤ ‖normalizedLinear (A n) x‖) : + ∃ ρ : ℕ → ℕ, StrictMono ρ ∧ ∃ L : Point →L[ℝ] Point, + Tendsto (fun n => normalizedLinear (A (ρ n))) atTop (𝓝 L) ∧ + ‖L‖=1 ∧ Function.Injective L ∧ ∀ x : Point, ε*‖x‖ ≤ ‖L x‖ := by + have hb (n : ℕ) : normalizedLinear (A n)∈closedBall (0:Point →L[ℝ] Point) 1 := by + simp [normalizedLinear_norm] + obtain ⟨L,_,ρ,hρ,hlim⟩ := (isCompact_closedBall (0:Point →L[ℝ] Point) 1).tendsto_subseq hb + have hL : ‖L‖=1 := tendsto_nhds_unique hlim.norm + (by simp only [Function.comp_def,normalizedLinear_norm]; exact tendsto_const_nhds) + have hlower : ∀ x : Point, ε*‖x‖ ≤ ‖L x‖ := by + apply unit_conorm_all + intro x hx + have ht : Tendsto (fun n => ‖normalizedLinear (A (ρ n)) x‖) atTop (𝓝 ‖L x‖) := + (((continuous_id.clm_apply (continuous_const : Continuous (fun _ : Point →L[ℝ] Point => x))).tendsto L).comp hlim).norm + exact ge_of_tendsto ht ((hρ.tendsto_atTop.eventually hbound).mono fun _ hn => hn x hx) + have hinj : Function.Injective L := by + intro x y hxy + have hb := hlower (x-y) + rw [map_sub,hxy,sub_self,norm_zero] at hb + have hn : ‖x-y‖=0 := by nlinarith [norm_nonneg (x-y)] + exact sub_eq_zero.mp (norm_eq_zero.mp hn) + exact ⟨ρ,hρ,L,hlim,hL,hinj,hlower⟩ + +lemma uniform_apply_linear_limit {X : Type*} (K : Set X) + (f : ℕ → X → Point) (g : X → Point) (A : ℕ → Point →L[ℝ] Point) + (L : Point →L[ℝ] Point) (hA : Tendsto A atTop (𝓝 L)) + (hnorm : ∀ n, ‖A n‖=1) (M : ℝ) (hM : 0≤M) (hg : ∀ x∈K, ‖g x‖≤M) + (hf : TendstoUniformlyOn f g atTop K) : + TendstoUniformlyOn (fun n x => A n (f n x)) (fun x => L (g x)) atTop K := by + rw [Metric.tendstoUniformlyOn_iff] + intro ε hε + have hδ : 0<ε/(2*(M+1)) := by positivity + filter_upwards [Metric.tendstoUniformlyOn_iff.mp hf (ε/2) (by positivity), + (Metric.tendsto_nhds.mp hA) _ hδ] with n hn hAn x hx + have he : A n (f n x)-L (g x)=A n (f n x-g x)+(A n-L) (g x) := by + simp only [map_sub,sub_apply]; abel + have hdiff : ‖f n x-g x‖<ε/2 := by simpa only [dist_eq_norm,norm_sub_rev] using hn x hx + have hAdiff : ‖A n-L‖<ε/(2*(M+1)) := by simpa only [dist_eq_norm] using hAn + have hb := norm_add_le (A n (f n x-g x)) ((A n-L) (g x)) + have hfirst := (A n).le_opNorm (f n x-g x) + rw [hnorm n,one_mul] at hfirst + have hsecond := (A n-L).le_opNorm (g x) + have hsmall : ‖A n-L‖*‖g x‖<ε/2 := by + have hprod := mul_le_mul_of_nonneg_left (hg x hx) (norm_nonneg (A n-L)) + have hprod' : ‖A n-L‖*M < ε/2 := by + have ht := (lt_div_iff₀ (by positivity : 0<2*(M+1))).mp hAdiff + nlinarith [norm_nonneg (A n-L)] + exact hprod.trans_lt hprod' + rw [dist_eq_norm,norm_sub_rev,he] + linarith + +end PlanarHalving.Zoom + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +@[simp] lemma affineZoom_symm_apply (f : OpenPartialHomeomorph Point Point) + (E B : Point ≃L[ℝ] Point) (p x₀ : Point) (q h : ℝ) (hq : q≠0) (hh : h≠0) (y : Point) : + (affineZoom f E B p x₀ q h hq hh).symm y= + E.symm (q⁻¹ • (f.symm (p+h • B.symm y)-x₀)) := rfl + +lemma common_inverse_identity (f : OpenPartialHomeomorph Point Point) + (E B G : Point ≃L[ℝ] Point) (p : Point) (q h : ℝ) (hq : q≠0) (hh : h≠0) (w : Point) : + (q*‖(E.trans G).toContinuousLinearMap‖)⁻¹ • + (G (f.symm (p+h • w))-G (f.symm p))= + normalizedLinear (E.trans G) + ((affineZoom f E B p (f.symm p) q h hq hh).symm (B w)) := by + rw [affineZoom_symm_apply,B.symm_apply_apply] + simp only [normalizedLinear,smul_apply,ContinuousLinearEquiv.coe_coe, + ContinuousLinearEquiv.trans_apply,E.apply_symm_apply,map_smul,map_sub,mul_inv_rev,smul_sub,smul_smul] + congr 1 <;> congr 1 <;> ring + +lemma uniform_common_inverse_limit (f : ℕ → OpenPartialHomeomorph Point Point) + (E G : ℕ → Point ≃L[ℝ] Point) (B : Point ≃L[ℝ] Point) (p : Point) + (q h : ℕ → ℝ) (hq : ∀ n, q n≠0) (hh : ∀ n, h n≠0) (sgn : ℝ) + (L : Point →L[ℝ] Point) + (hL : Tendsto (fun n => normalizedLinear ((E n).trans (G n))) atTop (𝓝 L)) + (hinv : ∀ K : Set Point, IsCompact K → TendstoUniformlyOn + (fun n => (affineZoom (f n) (E n) B p ((f n).symm p) (q n) (h n) (hq n) (hh n)).symm) + (fun x => sgn • x) atTop K) : + ∀ K : Set Point, IsCompact K → TendstoUniformlyOn + (fun n w => (q n*‖((E n).trans (G n)).toContinuousLinearMap‖)⁻¹ • + (G n ((f n).symm (p+h n • w))-G n ((f n).symm p))) + (fun w => L (sgn • B w)) atTop K := by + intro K hK + let g : Point → Point := fun w => sgn • B w + have hg : Continuous g := by + dsimp [g] + exact (continuous_const : Continuous (fun _ : Point => sgn)).smul B.continuous + obtain ⟨R,hR⟩ := (Metric.isBounded_iff_subset_closedBall (0:Point)).mp (hK.image hg).isBounded + have hgb (x : Point) (hx : x∈K) : ‖g x‖ ≤ max R 0 := by + apply le_trans _ (le_max_left _ _) + simpa only [mem_closedBall,dist_zero_right] using hR (mem_image_of_mem g hx) + have hf : TendstoUniformlyOn + (fun n w => (affineZoom (f n) (E n) B p ((f n).symm p) (q n) (h n) (hq n) (hh n)).symm (B w)) + g atTop K := by + exact ((hinv (B '' K) (hK.image B.continuous)).comp B).mono + (by intro x hx; exact mem_image_of_mem B hx) + have ht := uniform_apply_linear_limit K _ g + (fun n => normalizedLinear ((E n).trans (G n))) L hL + (fun n => normalizedLinear_norm _) (max R 0) (le_max_right _ _) hgb hf + simpa only [← common_inverse_identity] using ht + +end PlanarHalving.Zoom + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +lemma common_frame_condition (B : Point ≃L[ℝ] Point) + (S : Fin 3 → Set ℝ) (hS : ∀ i, IsClosed (S i)) + (hSb : ∀ i, S i ⊆ Icc (0:ℝ) 1) (hdis : ∀ i j, i≠j → Disjoint (S i) (S j)) + (v : Fin 3 → Point) (hv : ∀ i j, i≠j → detPair (v i) (v j) ≠ 0) : + ∃ ε : ℝ, 0<ε ∧ ∀ (A : ℕ → Point ≃L[ℝ] Point) (u : ℕ → Fin 3 → Point), + (∀ n i, ‖u n i‖=1) → + (∀ ρ : ℕ → ℕ, StrictMono ρ → ∀ x : Fin 3 → Point, + Tendsto (u ∘ ρ) atTop (𝓝 x) → + ∀ i, ∃ z∈S i, detPair (x i) (B (RankLimits.reflectFirst (Directions.simplex z)))=0) → + (∀ n i, detPair (A n (u n i)) (v i)=0) → + ∀ᶠ n in atTop, ∀ x : Point, ‖x‖=1 → ε ≤ ‖normalizedLinear (A n) x‖ := by + obtain ⟨δ,hδ,hsep⟩ := eventually_separated_of_allowed_clusters B S hS hSb hdis + obtain ⟨ε,hε,hcond⟩ := three_lines_uniform_conorm v hv δ hδ + refine ⟨ε,hε,?_⟩ + intro A u hu hcluster hline + filter_upwards [hsep u hu hcluster] with n hn + apply hcond (normalizedLinear (A n)) (normalizedLinear_norm _) (u n) (hu n) hn + intro i + change detPair (‖(A n).toContinuousLinearMap‖⁻¹ • A n (u n i)) (v i)=0 + have he : detPair (‖(A n).toContinuousLinearMap‖⁻¹ • A n (u n i)) (v i)= + ‖(A n).toContinuousLinearMap‖⁻¹*detPair (A n (u n i)) (v i) := by dsimp [detPair]; ring + rw [he,hline,mul_zero] + +end PlanarHalving.Zoom + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +def RadialCompare (f : Point → Point) (p : Point) (h C T : ℝ) : Prop := + (∀ u v : Point, ‖u-p‖=h/T → ‖v-p‖=h → + ‖f v-f p‖ ≤ C*T*‖f u-f p‖) ∧ + (∀ u v : Point, ‖u-p‖=h/T → ‖v-p‖=h → + T*‖f u-f p‖ ≤ C*‖f v-f p‖) + +lemma uniform_radial_compare (f : ℕ → Point → Point) (L : Point →L[ℝ] Point) + (l u C T : ℝ) (hl : 0 g i (Q (simplex x))) := + (g i).continuous.comp (Q.continuous.comp (continuous_id.prodMk (continuous_const.sub continuous_id))) + have he : allowed Q g lo hi t = Icc (0:ℝ) 1 ∩ + ⋂ i, {x : ℝ | (hi i ?_) + change IsClosed ({x : ℝ | hi i norm_num + have hn (x : Point) : ‖sgn • B x‖=‖B x‖ := by rw [norm_smul,Real.norm_eq_abs,habs,one_mul] + constructor + · intro x + have hb := B.symm.toContinuousLinearMap.le_opNorm (B x) + simp only [ContinuousLinearEquiv.coe_coe,B.symm_apply_apply] at hb + have he := hlower (sgn • B x) + rw [hn] at he + change _ ≤ ‖L (sgn • B x)‖ + have hp := equiv_opNorm_pos B.symm + have hd : ‖x‖/‖B.symm.toContinuousLinearMap‖ ≤ ‖B x‖ := (div_le_iff₀ hp).mpr (by nlinarith) + have hm := mul_le_mul_of_nonneg_left hd hε.le + have hid : ε*(‖x‖/‖B.symm.toContinuousLinearMap‖)= + ε/‖B.symm.toContinuousLinearMap‖*‖x‖ := by ring + rw [hid] at hm + exact hm.trans he + · intro x + have he := L.le_opNorm (sgn • B x) + rw [hL,one_mul,hn] at he + exact he.trans (B.toContinuousLinearMap.le_opNorm x) + +end PlanarHalving.Zoom + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +lemma actual_common_inverse_limit {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hCB : ∀ i, Before (C i) A ∧ Before (C i) B) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (hp : p ∈ Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (h q : ℕ → ℝ) (hh : ∀ n, 0 Directions.allowed reflectFirst D (fun i => (lower (C i):ℝ)) + (fun i => (upper (C i):ℝ)) (t j)) v ε) + (hG : ∀ n i, detPair (G n (1,(F n).timeSlope (t i))) (v i)=0) + (sgn : ℝ) (hsgn : sgn=1 ∨ sgn=-1) + (hj : ∀ i R, 0 ≤ R → TendstoUniformlyOn + (fun n u => (((F n).extendedRank true A B (C i) (p+h n • u) : ℝ)-c i)/h n) + (D i) atTop (closedBall 0 R)) + (hunif : ∀ K : Set Point, IsCompact K → TendstoUniformlyOn + (fun n => affineZoom ((F n).rankChart hAB (hA n) (hB n)) (E n) B' p + (((F n).rankChart hAB (hA n) (hB n)).symm p) (q n) (h n) (hq n).ne' (hh n).ne') + (fun x => sgn • x) atTop K) + (hinv : ∀ K : Set Point, IsCompact K → TendstoUniformlyOn + (fun n => (affineZoom ((F n).rankChart hAB (hA n) (hB n)) (E n) B' p + (((F n).rankChart hAB (hA n) (hB n)).symm p) (q n) (h n) (hq n).ne' (hh n).ne').symm) + (fun x => sgn • x) atTop K) : + ∃ ρ : ℕ → ℕ, StrictMono ρ ∧ ∃ r : ℕ → ℝ, (∀ n, 0 r n • (G (ρ n) (((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))).symm + (p+h (ρ n) • w))-G (ρ n) (((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))).symm p))) + M atTop K := by + let u := fun n i => forwardUnit (F n) (E n) (t i) + let A' := fun n => (E n).trans (G n) + have hbound : ∀ᶠ n in atTop, ∀ x : Point, ‖x‖=1 → ε ≤ ‖normalizedLinear (A' n) x‖ := by + apply hcond A' u (fun n i => forwardUnit_norm _ _ _) + · intro ρ hρ x hx i + exact actual_forwardUnit_clusters F hAB hA hB C hCB hC D c p hp h q hh hq E B' + (t i) (htA i) (htB i) sgn hsgn hj (hunif _ (isCompact_closedBall _ _)) + ρ hρ (x i) (tendsto_pi_nhds.mp hx i) + · intro n i + change detPair (G n (E n (forwardUnit (F n) (E n) (t i)))) (v i)=0 + rw [forwardUnit_map,map_smul] + have he : detPair (‖(E n).symm (1,(F n).timeSlope (t i))‖⁻¹ • G n (1,(F n).timeSlope (t i))) (v i)= + ‖(E n).symm (1,(F n).timeSlope (t i))‖⁻¹*detPair (G n (1,(F n).timeSlope (t i))) (v i) := by + dsimp [detPair]; ring + rw [he,hG,mul_zero] + obtain ⟨ρ,hρ,L,hL,hLn,_,hLl⟩ := normalizedLinear_subsequence A' ε hε hbound + let M := L.comp (sgn • B'.toContinuousLinearMap) + let r := fun n => (q (ρ n)*‖(A' (ρ n)).toContinuousLinearMap‖)⁻¹ + have hr (n : ℕ) : 0 (F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))) + (E ∘ ρ) (G ∘ ρ) B' p (q ∘ ρ) (h ∘ ρ) + (fun n => (hq _).ne') (fun n => (hh _).ne') sgn L hL + (fun K hK => (hinv K hK).seq_tendstoUniformlyOn ρ hρ.tendsto_atTop) K hK + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Greedy.lean b/lean/OAI/Combinatorics/HalvingLines/Greedy.lean new file mode 100644 index 0000000000000000000000000000000000000000..d54712f0aaa7e685c7818df91a60487a47a50fa4 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Greedy.lean @@ -0,0 +1,370 @@ +import OAI.Combinatorics.HalvingLines.Packing + +namespace OAI + +open Filter Topology + +namespace PlanarHalving +open Set + +lemma Generic.comp_strictMono {n m : ℕ} {P : Fin n → Point} (hP : Generic P) + {f : Fin m → Fin n} (hf : StrictMono f) : Generic (P∘f) := by + refine ⟨⟨hP.1.1.comp hf.injective,?_⟩,?_,?_,?_⟩ + · intro i j l hij hjl hil + exact hP.1.2 _ _ _ (hf.injective.ne hij) (hf.injective.ne hjl) (hf.injective.ne hil) + · intro i j hij + exact hP.2.1 _ _ (hf.injective.ne hij) + · intro i j a b hij hab he + obtain ⟨hi,hj⟩ := hP.2.2.1 _ _ _ _ (hf hij) (hf hab) he + exact ⟨hf.injective hi,hf.injective hj⟩ + · intro i j a b c d hij hab hcd hne hci hca z hzij hzab hzcd + have hinj : Function.Injective (Prod.map f f) := hf.injective.prodMap hf.injective + exact hP.2.2.2 _ _ _ _ _ _ (hf hij) (hf hab) (hf hcd) + (hinj.ne hne) (hinj.ne hci) (hinj.ne hca) z hzij hzab hzcd + +namespace Sweep +variable {n T k : ℕ} {P : Fin n → Point} + +lemma States.outside_activity_constant (S : @States n T k P) + {u v : Fin (T+1)} (huv : u ≤ v) {x : Fin n} (hx : x ∉ S.intervalActivity u v huv) + {i : Fin (T+1)} (hui : u ≤ i) (hiv : i ≤ v) : x ∈ S.marks i ↔ x ∈ S.marks u := by + by_contra H + apply hx + rw [S.mem_intervalActivity huv] + exact ⟨i,hui,hiv,by tauto⟩ + +lemma States.intervalActivity_self (S : @States n T k P) (u : Fin (T+1)) : + S.intervalActivity u u le_rfl=∅ := by + classical + ext x + simp only [Finset.notMem_empty,iff_false,S.mem_intervalActivity] + rintro ⟨i,hi,hj,h⟩ + have he : i=u := le_antisymm hj hi + subst i + tauto + +lemma States.intervalActivity_mono (S : @States n T k P) + {u v w : Fin (T+1)} (huv : u ≤ v) (hvw : v ≤ w) : + S.intervalActivity u v huv⊆S.intervalActivity u w (huv.trans hvw) := by + intro x hx + obtain ⟨i,hui,hiv,hi⟩ := (S.mem_intervalActivity huv).mp hx + exact (S.mem_intervalActivity (huv.trans hvw)).mpr ⟨i,hui,hiv.trans hvw,hi⟩ + +lemma States.intervalActivity_step_subset (S : @States n T k P) + {u : Fin (T+1)} (j : Fin T) (hu : u ≤ j.castSucc) : + S.intervalActivity u j.succ (hu.trans (Fin.castSucc_le_succ j))⊆ + S.intervalActivity u j.castSucc hu ∪ ((S.marks j.castSucc\S.marks j.succ)∪ + (S.marks j.succ\S.marks j.castSucc)) := by + classical + intro x hx + obtain ⟨i,hui,hij,hi⟩ := (S.mem_intervalActivity _).mp hx + by_cases hprev : i ≤ j.castSucc + · exact Finset.mem_union_left _ ((S.mem_intervalActivity hu).mpr ⟨i,hui,hprev,hi⟩) + · have he : i=j.succ := Fin.ext (by change i.val=j.val+1;change i.val ≤ j.val+1 at hij;change ¬i.val ≤ j.val at hprev;omega) + subst i + by_cases hbefore : x ∈ S.intervalActivity u j.castSucc hu + · exact Finset.mem_union_left _ hbefore + · have hb := S.outside_activity_constant hu hbefore hu le_rfl + apply Finset.mem_union_right + simp only [Finset.mem_union,Finset.mem_sdiff] + tauto + +lemma States.intervalActivity_step_card (S : @States n T k P) + {u : Fin (T+1)} (j : Fin T) (hu : u ≤ j.castSucc) : + (S.intervalActivity u j.succ (hu.trans (Fin.castSucc_le_succ j))).card ≤ + (S.intervalActivity u j.castSucc hu).card+2 := by + have h := Finset.card_le_card (S.intervalActivity_step_subset j hu) + have h1 := Finset.card_union_le (S.intervalActivity u j.castSucc hu) + ((S.marks j.castSucc\S.marks j.succ)∪(S.marks j.succ\S.marks j.castSucc)) + have h2 := Finset.card_union_le (S.marks j.castSucc\S.marks j.succ) (S.marks j.succ\S.marks j.castSucc) + have h3 := S.step j + have h4 := Finset.card_sdiff_comm ((S.card_marks j.castSucc).trans (S.card_marks j.succ).symm) + change (S.marks j.castSucc\S.marks j.succ).card ≤ 1 at h3 + omega + +end Sweep +end PlanarHalving +namespace PlanarHalving.Sweep +open Set +variable {n T k : ℕ} {P : Fin n → Point} + +noncomputable def States.activitySize (S : @States n T k P) (u v : Fin (T+1)) : ℕ := + if h : u ≤ v then (S.intervalActivity u v h).card else 0 + +lemma States.activitySize_eq (S : @States n T k P) {u v : Fin (T+1)} (h : u ≤ v) : + S.activitySize u v=(S.intervalActivity u v h).card := dite_eq_left h + +lemma States.activitySize_self (S : @States n T k P) (u : Fin (T+1)) : S.activitySize u u=0 := by + rw [S.activitySize_eq le_rfl,S.intervalActivity_self,Finset.card_empty] + +noncomputable def States.activityEligible (S : @States n T k P) (s : Fin (T+1)) (b : ℕ) : Finset (Fin (T+1)) := + Finset.univ.filter (fun t => s ?_) j + · simpa only [Fin.castSucc_zero,Fin.cons_zero,Fin.cons_succ,Q.first] using (S.activityNext_spec s b h).2 + · simpa only [Fin.castSucc_succ,Fin.cons_succ] using Q.lower j + · intro j + refine Fin.cases ?_ (fun j => ?_) j + · simpa only [Fin.castSucc_zero,Fin.cons_zero,Fin.cons_succ,Q.first] using S.activityNext_bound s hb h + · simpa only [Fin.castSucc_succ,Fin.cons_succ] using Q.upper j + · simpa only [Fin.cons_last] using Q.tail + · refine ⟨0,fun _ => s,rfl,?_,(fun j => Fin.elim0 j),(fun j => Fin.elim0 j),?_⟩ + · intro i j hij + exact False.elim (by have:=i.isLt;have:=j.isLt;change i.val (Q.index j.castSucc,Q.index j.succ)) + +lemma States.ActivityGreedy.intervals_card (S : @States n T k P) {s : Fin (T+1)} {b : ℕ} + (Q : S.ActivityGreedy s b) : (Q.intervals S).card=Q.count := by + classical + rw [States.ActivityGreedy.intervals,Finset.card_image_of_injective,Finset.card_univ,Fintype.card_fin] + intro i j he + exact Fin.castSucc_inj.mp (Q.increasing.injective (congrArg Prod.fst he)) + +lemma States.ActivityGreedy.intervals_data (S : @States n T k P) {s : Fin (T+1)} {b : ℕ} + (Q : S.ActivityGreedy s b) : StepDisjoint (Q.intervals S) ∧ + ∀ p ∈ Q.intervals S, p.1 ≤ p.2 ∧ b ≤ S.activitySize p.1 p.2 := by + constructor + · intro p hp q hq hne + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hp + obtain ⟨j,_,rfl⟩ := Finset.mem_image.mp hq + have hij : i≠j := by intro h;subst j;exact hne rfl + rcases lt_or_gt_of_ne hij with h | h + · have he : Q.index i.succ ≤ Q.index j.castSucc := Q.increasing.monotone (by change i.val+1 ≤ j.val;omega) + exact Set.disjoint_left.mpr (fun _ hi hj => not_lt_of_ge (hi.2.trans he) hj.1) + · have he : Q.index j.succ ≤ Q.index i.castSucc := Q.increasing.monotone (by change j.val+1 ≤ i.val;omega) + exact Set.disjoint_left.mpr (fun _ hi hj => not_lt_of_ge (hj.2.trans he) hi.1) + · intro p hp + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hp + exact ⟨Q.increasing.monotone (Fin.castSucc_le_succ i),Q.lower i⟩ + +end PlanarHalving.Sweep + +namespace PlanarHalving.Sweep +open Set + +lemma continuous_lt_iff_of_no_eq {f g : ℝ → ℝ} (hf : Continuous f) (hg : Continuous g) + {s t : ℝ} (hst : s≤t) (hne : ∀ u∈Icc s t, f u≠g u) : f s intro h <;> linarith + +lemma tied_projection (p q : Point) (hx : p.1≠q.1) : + projection (slope p q) p=projection (slope p q) q := + (projection_eq_iff_slope hx).mpr rfl + +variable {n : ℕ} {P : Fin n → Point} + +lemma Traversal.cut_bounds (T : Traversal (criticalSlopes P)) (i : Fin T.size) : + T.sample i.castSucc hne (by rw [h]) + intro u hu he + have hs := (projection_eq_iff_slope (hP.2.1 a b hab)).mp he + have hmem : u∈criticalSlopes P := hs ▸ mem_criticalSlopes P hab + have hl : T.sample i.castSucc T.sample_not_mem _ (h ▸ hmem)) + have hr : u T.sample_not_mem _ (h ▸ hmem)) + have hc := T.unique_critical i hmem hl hr + exact hne (hc ▸ he) + +lemma Traversal.comparison_cut (T : Traversal (criticalSlopes P)) (hP : Generic P) + (i : Fin T.size) {a b : Fin n} + (hne : projection (T.cut i.succ.castSucc) (P a)≠projection (T.cut i.succ.castSucc) (P b)) : + (projection (T.sample i.castSucc) (P a) projection s (P a)) := by unfold projection;fun_prop + have hb : Continuous (fun s => projection s (P b)) := by unfold projection;fun_prop + have hc := T.cut_bounds i + have hn := T.projection_ne_between hP i hne + exact ⟨continuous_lt_iff_of_no_eq ha hb hc.1.le + (fun u hu => hn u ⟨hu.1,hu.2.trans hc.2.le⟩), + (continuous_lt_iff_of_no_eq ha hb hc.2.le + (fun u hu => hn u ⟨hc.1.le.trans hu.1,hu.2⟩)).symm⟩ + +lemma projection_ne_at_pair (hP : GeneralPosition P) {a b l : Fin n} + (hab : a≠b) (hla : l≠a) (hlb : l≠b) (hxa : (P a).1≠(P b).1) : + projection (slope (P a) (P b)) (P l)≠projection (slope (P a) (P b)) (P a) := by + intro h + apply hP.2 a b l hab hlb.symm hla.symm + have he := (div_mul_cancel₀ ((P b).2-(P a).2) (sub_ne_zero.mpr hxa.symm)) + change slope (P a) (P b)*((P b).1-(P a).1)=(P b).2-(P a).2 at he + unfold projection at h + have hl : (P l).2-(P a).2=slope (P a) (P b)*((P l).1-(P a).1) := by linarith + unfold orient + rw [hl,← he] + ring + +end PlanarHalving.Sweep + +namespace PlanarHalving.Sweep +open Set + +def Refines {n : ℕ} (P : Fin n → Point) (c s : ℝ) : Prop := + ∀ i j, projection c (P i) intro a b hab + · exact (T.comparison_cut hP i (ne_of_lt hab)).1.mpr hab + · exact (T.comparison_cut hP i (ne_of_lt hab)).2.mpr hab + +noncomputable def belowSet {n : ℕ} (P : Fin n → Point) (a b : Fin n) : Finset (Fin n) := + Finset.univ.filter (fun l => projection (slope (P a) (P b)) (P l) hb (h ▸ ha) + have ht := tied_projection (P a) (P b) hx + ext l + rw [mem_belowSet,Finset.mem_erase] + constructor + · intro hl + have hla : l≠a := by intro he;subst l;exact lt_irrefl _ hl + refine ⟨hla,?_⟩ + by_contra hn + exact not_lt_of_gt (hM a ha l hn) (hR l a hl) + · rintro ⟨hla,hl⟩ + have hlb : l≠b := fun he => hb (he ▸ hl) + have hne := projection_ne_at_pair hP hab hla hlb hx + by_contra hn + have hgt := lt_of_le_of_ne (le_of_not_gt hn) hne.symm + rw [ht] at hgt + exact not_lt_of_gt (hM l hl b hb) (hR b l hgt) + +lemma below_insert_separates {n : ℕ} {P : Fin n → Point} (hP : GeneralPosition P) + {s : ℝ} {a b : Fin n} (hab : a≠b) (hx : (P a).1≠(P b).1) + (hR : Refines P (slope (P a) (P b)) s) + (hs : projection s (P a) hm (Finset.mem_insert_of_mem hh) + have hcm : projection (slope (P a) (P b)) (P a)≤projection (slope (P a) (P b)) (P m) := + le_of_not_gt (fun hh => hmB ((mem_belowSet P a b m).mpr hh)) + rcases Finset.mem_insert.mp hl with he | hl + · subst l + by_cases hmb : m=b + · simpa only [hmb] using hs + · exact hR a m (lt_of_le_of_ne hcm (projection_ne_at_pair hP hab hma hmb hx).symm) + · exact hR l m (((mem_belowSet P a b l).mp hl).trans_le hcm) + +lemma projection_order_at_slope {p q : Point} (hx : p.1 nlinarith + +lemma belowSet_symm {n : ℕ} {P : Fin n → Point} {a b : Fin n} (hx : (P a).1≠(P b).1) : + belowSet P b a=belowSet P a b := by + classical + ext l + simp only [mem_belowSet,slope_symm (P b) (P a),tied_projection (P a) (P b) hx] + +lemma belowCount_symm {n : ℕ} {P : Fin n → Point} {a b : Fin n} (hx : (P a).1≠(P b).1) : + belowCount P b a=belowCount P a b := congrArg Finset.card (belowSet_symm hx) + +end PlanarHalving.Sweep + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Intersections.lean b/lean/OAI/Combinatorics/HalvingLines/Intersections.lean new file mode 100644 index 0000000000000000000000000000000000000000..abb8567fb3472cdb2ec9359296057f2fdd74fc75 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Intersections.lean @@ -0,0 +1,363 @@ +import OAI.Combinatorics.HalvingLines.Curves + +namespace OAI + +namespace PlanarHalving + +namespace Zoom + +open scoped NNReal Topology +open Filter + +lemma intersects_parameter_graph {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] (ℓ ψ : E →L[ℝ] ℝ) + (hjoint : Function.Injective (fun x : E => (ℓ x, ψ x))) + (a : E) (R c d : ℝ) (hcd : c ≤ d) + (γ : Set.Icc (-R) R → E) (β : Set.Icc c d → E) + (hγ : Continuous γ) (hβ : Continuous β) + (hlevel : ∀ s, ℓ (γ s - a) = s) + (hinside : ∀ t, ℓ (β t - a) ∈ Set.Icc (-R) R) + (hlower : ψ (β ⟨c, ⟨le_rfl, hcd⟩⟩) ≤ + ψ (γ ⟨ℓ (β ⟨c, ⟨le_rfl, hcd⟩⟩ - a), hinside _⟩)) + (hupper : ψ (γ ⟨ℓ (β ⟨d, ⟨hcd, le_rfl⟩⟩ - a), hinside _⟩) ≤ + ψ (β ⟨d, ⟨hcd, le_rfl⟩⟩)) : + ∃ t s, β t = γ s := by + let p (t : Set.Icc c d) : Set.Icc (-R) R := ⟨ℓ (β t - a), hinside t⟩ + have hp : Continuous p := + (ℓ.continuous.comp (hβ.sub continuous_const)).subtype_mk _ + let H (t : Set.Icc c d) : ℝ := ψ (β t) - ψ (γ (p t)) + have hH : Continuous H := + (ψ.continuous.comp hβ).sub (ψ.continuous.comp (hγ.comp hp)) + let c' : Set.Icc c d := ⟨c, ⟨le_rfl, hcd⟩⟩ + let d' : Set.Icc c d := ⟨d, ⟨hcd, le_rfl⟩⟩ + have hmem : (0 : ℝ) ∈ Set.Icc (H c') (H d') := + ⟨sub_nonpos.mpr hlower, sub_nonneg.mpr hupper⟩ + let : PreconnectedSpace (Set.Icc c d) := + isPreconnected_iff_preconnectedSpace.mp isPreconnected_Icc + obtain ⟨t, ht⟩ := intermediate_value_univ c' d' hH hmem + refine ⟨t, p t, hjoint (Prod.ext ?_ (sub_eq_zero.mp ht))⟩ + have he := hlevel (p t) + change ℓ (γ (p t) - a) = ℓ (β t - a) at he + simpa only [map_sub, sub_left_inj] using he.symm + +lemma eventual_arc_intersection {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] (ℓ ψ : E →L[ℝ] ℝ) + (hjoint : Function.Injective (fun x : E => (ℓ x, ψ x))) + (a : ℕ → E) (a₀ c v w : E) (R D r : ℝ) + (hD : 0 < D) (hr : 0 < r) + (γ : ℕ → Set.Icc (-R) R → E) (β : ℕ → Set.Icc (-D) D → E) + (ha : Tendsto a atTop (𝓝 a₀)) + (hγ : TendstoUniformly γ (fun s => a₀ + (s : ℝ) • v) atTop) + (hβ : TendstoUniformly β (fun t => c + (t : ℝ) • w) atTop) + (hcγ : ∀ n, Continuous (γ n)) (hcβ : ∀ n, Continuous (β n)) + (hlevel : ∀ᶠ n in atTop, ∀ s, ℓ (γ n s - a n) = s) + (hinside : ∀ t : Set.Icc (-D) D, |ℓ (c + (t : ℝ) • w - a₀)| ≤ R - r) + (hψv : ψ v = 0) (hψc : ψ c = ψ a₀) (hψw : 0 < ψ w) : + ∀ᶠ n in atTop, ∃ t s, β n t = γ n s := by + have hℓβ := ℓ.uniformContinuous.comp_tendstoUniformly hβ + have hψβ := ψ.uniformContinuous.comp_tendstoUniformly hβ + have hψγ := ψ.uniformContinuous.comp_tendstoUniformly hγ + have ha' : ∀ᶠ n in atTop, |ℓ (a n) - ℓ a₀| < r / 2 := by + have hh := ((ℓ.continuous.tendsto a₀).comp ha).eventually + (Metric.ball_mem_nhds (ℓ a₀) (half_pos hr)) + simpa only [Metric.mem_ball, Real.dist_eq, Function.comp_apply] using hh + have hℓβ' := Metric.tendstoUniformly_iff.mp hℓβ (r / 2) (half_pos hr) + let e : ℝ := D * ψ w / 3 + have he : 0 < e := div_pos (mul_pos hD hψw) (by norm_num) + have hψβ' := Metric.tendstoUniformly_iff.mp hψβ e he + have hψγ' := Metric.tendstoUniformly_iff.mp hψγ e he + filter_upwards [ha', hℓβ', hψβ', hψγ', hlevel] with n han hℓn hβn hγn hleveln + have hi (t : Set.Icc (-D) D) : ℓ (β n t - a n) ∈ Set.Icc (-R) R := by + have h₁ : -(r / 2) < ℓ (c + (t : ℝ) • w) - ℓ (β n t) ∧ + ℓ (c + (t : ℝ) • w) - ℓ (β n t) < r / 2 := abs_lt.mp (hℓn t) + have h₂ := abs_lt.mp han + have h₃ := abs_le.mp (hinside t) + simp only [map_sub] at h₃ ⊢ + constructor <;> linarith + let lo : Set.Icc (-D) D := ⟨-D, ⟨le_rfl, by linarith⟩⟩ + let up : Set.Icc (-D) D := ⟨D, ⟨by linarith, le_rfl⟩⟩ + have hl : ψ (β n lo) ≤ ψ (γ n ⟨ℓ (β n lo - a n), hi lo⟩) := by + have hb := hβn lo + have hg := hγn ⟨ℓ (β n lo - a n), hi lo⟩ + simp only [Function.comp_apply, Real.dist_eq, map_add, map_smul, + hψv, hψc, smul_eq_mul, mul_zero, add_zero] at hb hg + change |ψ a₀ + (-D) * ψ w - ψ (β n lo)| < e at hb + have hb' := abs_lt.mp hb + have hg' := abs_lt.mp hg + dsimp [e] at hb' hg' + nlinarith + have hu : ψ (γ n ⟨ℓ (β n up - a n), hi up⟩) ≤ ψ (β n up) := by + have hb := hβn up + have hg := hγn ⟨ℓ (β n up - a n), hi up⟩ + simp only [Function.comp_apply, Real.dist_eq, map_add, map_smul, + hψv, hψc, smul_eq_mul, mul_zero, add_zero] at hb hg + change |ψ a₀ + D * ψ w - ψ (β n up)| < e at hb + have hb' := abs_lt.mp hb + have hg' := abs_lt.mp hg + dsimp [e] at hb' hg' + nlinarith + exact intersects_parameter_graph ℓ ψ hjoint (a n) R (-D) D (by linarith) + (γ n) (β n) (hcγ n) (hcβ n) hleveln hi hl hu + +lemma level_forces_nonzero {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (a b : ℕ → E) (a₀ v : E) (ℓ : E →L[ℝ] ℝ) (B : ℝ) + (ha : Tendsto a atTop (𝓝 a₀)) + (hbound : ∀ᶠ n in atTop, ‖b n - a n‖ ≤ B) + (hlevel : ∀ᶠ n in atTop, ℓ (b n - a n) = 1) + (hdirection : ∀ (ρ : ℕ → ℕ), StrictMono ρ → ∀ b₀ : E, + Tendsto (b ∘ ρ) atTop (𝓝 b₀) → ∃ r : ℝ, b₀ - a₀ = r • v) : + ℓ v ≠ 0 := by + obtain ⟨C, _, hC⟩ := (Metric.isBounded_range_of_tendsto a ha).exists_pos_norm_le + have hb : ∀ᶠ n in atTop, b n ∈ Metric.closedBall (0 : E) (B + C) := by + filter_upwards [hbound] with n hn + rw [Metric.mem_closedBall, dist_zero_right] + calc + ‖b n‖ = ‖(b n - a n) + a n‖ := by rw [sub_add_cancel] + _ ≤ ‖b n - a n‖ + ‖a n‖ := norm_add_le _ _ + _ ≤ B + C := add_le_add hn (hC _ (Set.mem_range_self n)) + obtain ⟨b₀, _, ρ, hρ, hlim⟩ := + (isCompact_closedBall (0 : E) (B + C)).isSeqCompact.subseq_of_frequently_in hb.frequently + obtain ⟨r, hr⟩ := hdirection ρ hρ b₀ hlim + have hm := (ℓ.continuous.tendsto (b₀ - a₀)).comp + (hlim.sub (ha.comp hρ.tendsto_atTop)) + change Tendsto (fun n => ℓ (b (ρ n) - a (ρ n))) atTop + (𝓝 (ℓ (b₀ - a₀))) at hm + have he : ℓ (b₀ - a₀) = 1 := + tendsto_nhds_unique (hm.congr' (hρ.tendsto_atTop.eventually hlevel)) tendsto_const_nhds + intro hv + simp only [hr, map_smul, hv, smul_zero] at he + exact zero_ne_one he + +def DirectionalLimit {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : ℕ → E → E) (v w : E) : Prop := + ∀ (ρ : ℕ → ℕ), StrictMono ρ → ∀ (x y : ℕ → E), + (∀ n, ∃ t : ℝ, y n = x n + t • v) → ∀ a b : E, + Tendsto (fun n => f (ρ n) (x n)) atTop (𝓝 a) → + Tendsto (fun n => f (ρ n) (y n)) atTop (𝓝 b) → + ∃ r : ℝ, b - a = r • w + +lemma controlled_line_arcs {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (f : ℕ → OpenPartialHomeomorph E E) (hsource : ∀ n, (f n).source = Set.univ) + (hexhaust : ∀ K : Set E, IsCompact K → ∀ᶠ n in atTop, K ⊆ (f n).target) + (x : ℕ → E) (a₀ v : E) (hv : v ≠ 0) (ℓ : E →L[ℝ] ℝ) + (M : ℝ≥0) (hM : 0 < M) (R : ℝ) (hR : 0 ≤ R) + (ha : Tendsto (fun n => f n (x n)) atTop (𝓝 a₀)) + (hmono : ∀ n, StrictMono (fun t : ℝ => ℓ (f n (x n + t • v) - f n (x n)))) + (hcone : ∀ n (t u : ℝ), ‖f n (x n + t • v) - f n (x n + u • v)‖ ≤ + M * |ℓ (f n (x n + t • v) - f n (x n + u • v))|) : + ∃ γ : ℕ → Set.Icc (-R) R → E, + (∀ n, LipschitzWith M (γ n)) ∧ + (∀ n s, ∃ t : ℝ, γ n s = f n (x n + t • v)) ∧ + (∀ᶠ n in atTop, ∀ s, ℓ (γ n s - f n (x n)) = s) ∧ + (∀ n, γ n ⟨0, ⟨neg_nonpos.mpr hR, hR⟩⟩ = f n (x n)) := by + classical + obtain ⟨C, _, hC⟩ := (Metric.isBounded_range_of_tendsto _ ha).exists_pos_norm_le + have ht : ∀ᶠ n in atTop, Metric.closedBall (f n (x n)) (M * R) ⊆ (f n).target := by + filter_upwards [hexhaust (Metric.closedBall (0 : E) (C + M * R)) + (isCompact_closedBall _ _)] with n hn + intro y hy + apply hn + rw [Metric.mem_closedBall, dist_zero_right] + calc + ‖y‖ = ‖f n (x n) + (y - f n (x n))‖ := by rw [add_sub_cancel] + _ ≤ ‖f n (x n)‖ + ‖y - f n (x n)‖ := norm_add_le _ _ + _ ≤ C + M * R := add_le_add (hC _ (Set.mem_range_self n)) + (by simpa only [Metric.mem_closedBall, dist_eq_norm] using hy) + have hc (n : ℕ) : ∃ g : Set.Icc (-R) R → E, + LipschitzWith M g ∧ (∀ s, ∃ t : ℝ, g s = f n (x n + t • v)) ∧ + (Metric.closedBall (f n (x n)) (M * R) ⊆ (f n).target → + ∀ s, ℓ (g s - f n (x n)) = s) ∧ + g ⟨0, ⟨neg_nonpos.mpr hR, hR⟩⟩ = f n (x n) := by + by_cases hi : Metric.closedBall (f n (x n)) (M * R) ⊆ (f n).target + · obtain ⟨g, hg, hmem, hlevel, hz⟩ := line_parameter_curve (f n) (hsource n) + (x n) v hv ℓ M R hM hR (hmono n) (hcone n) hi + exact ⟨g, hg, hmem, fun _ => hlevel, hz⟩ + · refine ⟨fun _ => f n (x n), LipschitzWith.const' _, ?_, + fun h => (hi h).elim, rfl⟩ + intro s + exact ⟨0, by rw [zero_smul, add_zero]⟩ + choose γ hγ hmem hlevel hz using hc + exact ⟨γ, hγ, hmem, ht.mono (fun n hn => hlevel n hn), hz⟩ + +lemma moving_line_arcs_tendsto {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [ProperSpace E] + (f : ℕ → OpenPartialHomeomorph E E) (hsource : ∀ n, (f n).source = Set.univ) + (hexhaust : ∀ K : Set E, IsCompact K → ∀ᶠ n in atTop, K ⊆ (f n).target) + (x : ℕ → E) (a₀ v w : E) (hv : v ≠ 0) (ℓ : E →L[ℝ] ℝ) + (M : ℝ≥0) (hM : 0 < M) + (ha : Tendsto (fun n => f n (x n)) atTop (𝓝 a₀)) + (hmono : ∀ n, StrictMono (fun t : ℝ => ℓ (f n (x n + t • v) - f n (x n)))) + (hcone : ∀ n (t u : ℝ), ‖f n (x n + t • v) - f n (x n + u • v)‖ ≤ + M * |ℓ (f n (x n + t • v) - f n (x n + u • v))|) + (hdir : DirectionalLimit (fun n => f n) v w) : + ℓ w ≠ 0 ∧ ∀ R : ℝ, ∀ _hR : 0 ≤ R, + ∃ γ : ℕ → Set.Icc (-R) R → E, + (∀ n, LipschitzWith M (γ n)) ∧ + (∀ n s, ∃ t : ℝ, γ n s = f n (x n + t • v)) ∧ + (∀ᶠ n in atTop, ∀ s, ℓ (γ n s - f n (x n)) = s) ∧ + TendstoUniformly γ (fun s => a₀ + ((s : ℝ) / ℓ w) • w) atTop := by + have hdirs (R : ℝ) (γ : ℕ → Set.Icc (-R) R → E) + (hmem : ∀ n s, ∃ t : ℝ, γ n s = f n (x n + t • v)) + (s : Set.Icc (-R) R) (ρ : ℕ → ℕ) (hρ : StrictMono ρ) (b₀ : E) + (hb : Tendsto (fun n => γ (ρ n) s) atTop (𝓝 b₀)) : + ∃ r : ℝ, b₀ - a₀ = r • w := by + choose t ht using fun n => hmem (ρ n) s + apply hdir ρ hρ (fun n => x (ρ n)) (fun n => x (ρ n) + t n • v) + (fun n => ⟨t n, rfl⟩) a₀ b₀ (ha.comp hρ.tendsto_atTop) + simpa only [← ht] using hb + obtain ⟨γ₁, hLip₁, hmem₁, hlevel₁, hz₁⟩ := controlled_line_arcs f hsource hexhaust + x a₀ v hv ℓ M hM 1 (by norm_num) ha hmono hcone + let one : Set.Icc (-1 : ℝ) 1 := ⟨1, ⟨by norm_num, le_rfl⟩⟩ + have hw : ℓ w ≠ 0 := by + apply level_forces_nonzero (fun n => f n (x n)) (fun n => γ₁ n one) + a₀ w ℓ M ha ?_ (hlevel₁.mono fun _ hn => hn one) (hdirs 1 γ₁ hmem₁ one) + apply Filter.Eventually.of_forall + intro n + have hh := (hLip₁ n).dist_le_mul one ⟨0, by norm_num, by norm_num⟩ + simpa only [hz₁, Subtype.dist_eq, dist_eq_norm, Real.norm_eq_abs, + one, sub_zero, abs_one, mul_one] using hh + refine ⟨hw, ?_⟩ + intro R hR + obtain ⟨γ, hLip, hmem, hlevel, hz⟩ := controlled_line_arcs f hsource hexhaust + x a₀ v hv ℓ M hM R hR ha hmono hcone + exact ⟨γ, hLip, hmem, hlevel, + parameter_curves_tendsto R hR γ (fun n => f n (x n)) a₀ w ℓ M ha hLip hz + hlevel hw (hdirs R γ hmem)⟩ + +lemma line_intersection_tendsto {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] (ℓ ψ : E →L[ℝ] ℝ) + (hjoint : Function.Injective (fun x : E => (ℓ x, ψ x))) + (A B : ℕ → Set E) (z a : ℕ → E) (a₀ b₀ c v w : E) (q : ℝ) + (ha : Tendsto a atTop (𝓝 a₀)) + (hc : c = b₀ + q • w) (hψv : ψ v = 0) (hψc : ψ c = ψ a₀) + (hψw : 0 < ψ w) + (hunique : ∀ n y, y ∈ A n → y ∈ B n → y = z n) + (hA : ∀ R : ℝ, 0 ≤ R → ∃ γ : ℕ → Set.Icc (-R) R → E, + (∀ n, Continuous (γ n)) ∧ (∀ n s, γ n s ∈ A n) ∧ + (∀ᶠ n in atTop, ∀ s, ℓ (γ n s - a n) = s) ∧ + TendstoUniformly γ (fun s => a₀ + (s : ℝ) • v) atTop) + (hB : ∀ R : ℝ, 0 ≤ R → ∃ δ : ℕ → Set.Icc (-R) R → E, + (∀ n, Continuous (δ n)) ∧ (∀ n s, δ n s ∈ B n) ∧ + TendstoUniformly δ (fun s => b₀ + (s : ℝ) • w) atTop) : + Tendsto z atTop (𝓝 c) := by + rw [Metric.tendsto_atTop] + intro ε hε + let d : ℝ := min ε 1 / (4 * (‖w‖ + |ℓ w| + 1)) + have hden : 0 < 4 * (‖w‖ + |ℓ w| + 1) := by positivity + have hd : 0 < d := div_pos (lt_min hε zero_lt_one) hden + have hdw : d * ‖w‖ < ε / 2 := by + have hmul : d * (4 * (‖w‖ + |ℓ w| + 1)) = min ε 1 := + div_mul_cancel₀ _ (ne_of_gt hden) + have hmin := min_le_left ε 1 + have ha := abs_nonneg (ℓ w) + have hn := norm_nonneg w + nlinarith only [hmul, hmin, ha, hn, hd] + have hdl : d * |ℓ w| ≤ 1 / 2 := by + have hmul : d * (4 * (‖w‖ + |ℓ w| + 1)) = min ε 1 := + div_mul_cancel₀ _ (ne_of_gt hden) + have hmin := min_le_right ε 1 + have hn := norm_nonneg w + have ha := abs_nonneg (ℓ w) + nlinarith only [hmul, hmin, ha, hn, hd] + let R : ℝ := |ℓ (c - a₀)| + 1 + obtain ⟨γ, hcγ, hmemγ, hlevel, hγ⟩ := hA R (by dsimp [R]; positivity) + obtain ⟨δ, hcδ, hmemδ, hδ⟩ := hB (|q| + d) (by positivity) + let p (t : Set.Icc (-d) d) : Set.Icc (-(|q| + d)) (|q| + d) := + ⟨q + t, by + constructor + · linarith only [t.property.1, neg_abs_le q] + · linarith only [t.property.2, le_abs_self q]⟩ + have hp : Continuous p := + (continuous_const.add continuous_subtype_val).subtype_mk _ + let β (n : ℕ) (t : Set.Icc (-d) d) : E := δ n (p t) + have hβ : TendstoUniformly β (fun t => c + (t : ℝ) • w) atTop := by + have hh := hδ.comp p + change TendstoUniformly β (fun t => b₀ + (q + (t : ℝ)) • w) atTop at hh + simpa only [hc, add_smul, add_assoc] using hh + have hi (t : Set.Icc (-d) d) : |ℓ (c + (t : ℝ) • w - a₀)| ≤ R - 1 / 2 := by + have ht : |(t : ℝ)| ≤ d := abs_le.mpr t.property + calc + |ℓ (c + (t : ℝ) • w - a₀)| = |ℓ (c - a₀) + (t : ℝ) * ℓ w| := by + congr 1 + rw [add_sub_right_comm, map_add, map_smul, smul_eq_mul] + _ ≤ |ℓ (c - a₀)| + |(t : ℝ) * ℓ w| := abs_add_le _ _ + _ ≤ |ℓ (c - a₀)| + d * |ℓ w| := by + rw [abs_mul] + exact add_le_add le_rfl (mul_le_mul_of_nonneg_right ht (abs_nonneg _)) + _ ≤ R - 1 / 2 := by dsimp [R]; linarith + have hinter := eventual_arc_intersection ℓ ψ hjoint a a₀ c v w R d (1 / 2) + hd (by norm_num) γ β ha hγ hβ hcγ (fun n => (hcδ n).comp hp) + hlevel hi hψv hψc hψw + have hclose := Metric.tendstoUniformly_iff.mp hβ (ε / 2) (half_pos hε) + obtain ⟨N, hN⟩ := eventually_atTop.mp (hinter.and hclose) + refine ⟨N, ?_⟩ + intro n hn + obtain ⟨⟨t, s, hts⟩, hclose⟩ := hN n hn + have he : β n t = z n := hunique n (β n t) (hts ▸ hmemγ n s) (hmemδ n (p t)) + calc + dist (z n) c = dist (β n t) c := by rw [he] + _ ≤ dist (β n t) (c + (t : ℝ) • w) + dist (c + (t : ℝ) • w) c := dist_triangle _ _ _ + _ < ε / 2 + ε / 2 := by + apply add_lt_add + · exact (dist_comm _ _).trans_lt (hclose t) + · rw [dist_eq_norm, add_sub_cancel_left, norm_smul, Real.norm_eq_abs] + exact lt_of_le_of_lt (mul_le_mul_of_nonneg_right + (abs_le.mpr t.property) (norm_nonneg w)) hdw + _ = ε := by ring + +def detPair (u v : Point) : ℝ := u.1 * v.2 - u.2 * v.1 + +lemma plane_span (u v : Point) (hdet : detPair u v ≠ 0) (x : Point) : + ∃ r s : ℝ, x = r • u + s • v := by + refine ⟨(x.1 * v.2 - x.2 * v.1) / detPair u v, + (u.1 * x.2 - u.2 * x.1) / detPair u v, ?_⟩ + apply Prod.ext <;> dsimp + · field_simp + simp only [detPair] + ring + · field_simp + simp only [detPair] + ring + +lemma transverse_covector (ℓ : Point →L[ℝ] ℝ) (u v : Point) + (hℓu : ℓ u ≠ 0) (hdet : detPair u v ≠ 0) : + ∃ ψ : Point →L[ℝ] ℝ, + Function.Injective (fun x : Point => (ℓ x, ψ x)) ∧ ψ u = 0 ∧ ψ v = 1 := by + let φ : Point →L[ℝ] ℝ := + u.1 • ContinuousLinearMap.snd ℝ ℝ ℝ - u.2 • ContinuousLinearMap.fst ℝ ℝ ℝ + have hφu : φ u = 0 := by change u.1 * u.2 - u.2 * u.1 = 0; ring + have hφv : φ v = detPair u v := rfl + let ψ : Point →L[ℝ] ℝ := (detPair u v)⁻¹ • φ + have hψu : ψ u = 0 := by simp [ψ, hφu] + have hψv : ψ v = 1 := by simp [ψ, hφv, hdet] + refine ⟨ψ, ?_, hψu, hψv⟩ + intro x y hxy + obtain ⟨r, s, hrs⟩ := plane_span u v hdet (x - y) + have h₁ : ℓ (x - y) = 0 := by + rw [map_sub] + exact sub_eq_zero.mpr (congrArg Prod.fst hxy) + have h₂ : ψ (x - y) = 0 := by + rw [map_sub] + exact sub_eq_zero.mpr (congrArg Prod.snd hxy) + have hs : s = 0 := by + simpa only [hrs, map_add, map_smul, hψu, hψv, smul_zero, zero_add, + smul_eq_mul, mul_one, mul_zero, zero_add] using h₂ + have hr : r = 0 := by + have hh : r * ℓ u = 0 := by simpa only [hrs, hs, zero_smul, add_zero, + map_smul, smul_eq_mul] using h₁ + exact (mul_eq_zero.mp hh).resolve_right hℓu + apply sub_eq_zero.mp + simpa only [hr, hs, zero_smul, add_zero] using hrs + +lemma detPair_smul_right (u v : Point) (r : ℝ) : + detPair u (r • v) = r * detPair u v := by + dsimp [detPair] + ring + +end Zoom + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Labels.lean b/lean/OAI/Combinatorics/HalvingLines/Labels.lean new file mode 100644 index 0000000000000000000000000000000000000000..11c972343841404c6a68b24b0f6df1def9ddb5c2 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Labels.lean @@ -0,0 +1,380 @@ +import OAI.Combinatorics.HalvingLines.Directions + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.RankCoordinates +open Set +open scoped unitInterval + +structure Family (m : ℕ) where + graph : Fin m → ℝ → ℝ + continuous : ∀ j, Continuous (graph j) + convex : ∀ j, ConvexOn ℝ univ (graph j) + scale : ℝ + scale_pos : 0 < scale + +noncomputable def Family.value {m : ℕ} [NeZero m] (F : Family m) (p : Point) : I := + ⟨smoothed F.graph F.scale p, (smoothed_mem (NeZero.pos m) F.graph F.scale p).1.le, + (smoothed_mem (NeZero.pos m) F.graph F.scale p).2.le⟩ + +lemma Family.continuous_value {m : ℕ} [NeZero m] (F : Family m) : Continuous F.value := + (continuous_smoothed F.graph F.scale F.continuous).subtype_mk _ + +noncomputable def Family.flat (m : ℕ) : Family m where + graph := fun _ _ => 0 + continuous := fun _ => continuous_const + convex := fun _ => convexOn_const _ (convex_univ) + scale := 1 + scale_pos := zero_lt_one + +end PlanarHalving.RankCoordinates +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates TimeWindows +open scoped unitInterval +variable {n R k a : ℕ} {P : Fin n → Point} + +noncomputable def System.rankFamily (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (J : Window) : Family (a*n) := by + classical + by_cases hJ : 0 < length R J + · let h := S.window_coordinate hP (start R J) (length R J) + (by rw [start_add_length]; exact stop_le R J) hJ + let G := h.choose + exact ⟨G.graph,G.continuous,G.convex,h.choose_spec.choose,h.choose_spec.choose_spec.1⟩ + · exact Family.flat _ + +lemma System.rankFamily_spec (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (J : Window) (hJ : 0 < length R J) : + ∃ G : (S.timeWindow J).FullGraphs (S.drawing.exteriorCrossings (S.timeWindow J).edges), + (S.rankFamily hP J).graph=G.graph ∧ + ∀ z ∈ S.drawing.exteriorCrossings (S.timeWindow J).edges, + |(S.rankFamily hP J).value z-(slot G.graph z : ℝ)/(a*n)| ≤ 2/(a*n) := by + classical + unfold System.rankFamily + rw [dite_eq_left hJ] + exact ⟨_,rfl,(S.window_coordinate hP _ _ _ hJ).choose_spec.choose_spec.2⟩ + +abbrev Labels := Window → I + +noncomputable instance labelsMetric : MetricSpace Labels := PiCountable.metricSpace + +noncomputable def System.labels (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (p : Point) : Labels := fun J => (S.rankFamily hP J).value p + +lemma System.continuous_labels (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) : Continuous (S.labels hP) := + continuous_pi (fun J => (S.rankFamily hP J).continuous_value) + +lemma System.coordinate_oscillation (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (J : Window) : + ∑ e : ↥S.edges, Metric.ediam ((fun p => S.labels hP p J) '' segment ℝ (P e.val.1) (P e.val.2)) + ≤ 2*a*n := by + have hh := S.rank_oscillation (Nat.mul_pos (NeZero.pos a) (NeZero.pos n)) + (S.rankFamily hP J).graph (S.rankFamily hP J).convex (S.rankFamily hP J).scale_pos + convert hh using 1 + apply Finset.sum_congr rfl + intro e _ + exact (Isometry.ediam_image (isometry_subtype_coe : Isometry (Subtype.val : I → ℝ)) _).symm.trans + (by rw [Set.image_image]; rfl) + +end PlanarHalving.Batches +namespace PlanarHalving.CompactLabels +open Set Filter MeasureTheory +open scoped Topology ENNReal NNReal PiCountable unitInterval +variable {ι : Type*} [Encodable ι] + +lemma ediam_le_finite {X : Type*} (z : X → (ι → I)) (A : Set X) (K : Finset ι) : + Metric.ediam (z '' A) ≤ (∑ i ∈ K, Metric.ediam ((fun x => z x i) '' A))+ + ∑' i : {j // j ∉ K}, (2 : ℝ≥0∞)⁻¹ ^ Encodable.encode (i : ι) := by + apply Metric.ediam_le + rintro _ ⟨x,hx,rfl⟩ _ ⟨y,hy,rfl⟩ + calc + edist (z x) (z y) = ∑' i : ι, min ((2 : ℝ≥0∞)⁻¹ ^ Encodable.encode i) (edist (z x i) (z y i)) := rfl + _ = (∑ i ∈ K, min ((2 : ℝ≥0∞)⁻¹ ^ Encodable.encode i) (edist (z x i) (z y i)))+ + ∑' i : {j // j ∉ K}, min ((2 : ℝ≥0∞)⁻¹ ^ Encodable.encode (i : ι)) (edist (z x i) (z y i)) := + (ENNReal.sum_add_tsum_compl ..).symm + _ ≤ _ := by + gcongr + · exact (min_le_right ..).trans (Metric.edist_le_ediam_of_mem ⟨x,hx,rfl⟩ ⟨y,hy,rfl⟩) + · exact min_le_left .. + +lemma finite_tail {ρ : ℝ≥0∞} (hρ : 0 < ρ) : + ∃ K : Finset ι, ∑' i : {j // j ∉ K}, (2 : ℝ≥0∞)⁻¹ ^ Encodable.encode (i : ι) < ρ/2 := by + exact ((tendsto_order.1 <| ENNReal.tendsto_tsum_compl_atTop_zero + (tsum_geometric_encode_lt_top ENNReal.one_half_lt_one).ne).2 _ + <| by simpa using hρ.ne').exists + +lemma long_count_bound {X α : Type*} [Fintype α] (z : X → (ι → I)) (A : α → Set X) + {ρ : ℝ≥0∞} (_hρ : 0 < ρ) (K : Finset ι) + (hK : ∑' i : {j // j ∉ K}, (2 : ℝ≥0∞)⁻¹ ^ Encodable.encode (i : ι) < ρ/2) + {B : ℝ≥0∞} (hB : ∀ i, ∑ e : α, Metric.ediam ((fun x => z x i) '' A e) ≤ B) : + (ρ/2) * ((Finset.univ.filter (fun e : α => ρ ≤ Metric.ediam (z '' A e))).card : ℝ≥0∞) + ≤ K.card*B := by + classical + let E := Finset.univ.filter (fun e : α => ρ ≤ Metric.ediam (z '' A e)) + have he (e : α) (he : e ∈ E) : ρ/2 ≤ ∑ i ∈ K, Metric.ediam ((fun x => z x i) '' A e) := by + by_contra hh + have hh' := lt_of_not_ge hh + have hlt := ENNReal.add_lt_add hh' hK + rw [ENNReal.add_halves] at hlt + exact not_lt_of_ge (Finset.mem_filter.mp he).2 + ((ediam_le_finite z (A e) K).trans_lt hlt) + calc + _ = ∑ _e ∈ E, ρ/2 := by simp only [Finset.sum_const,nsmul_eq_mul]; rw [mul_comm] + _ ≤ ∑ e ∈ E, ∑ i ∈ K, Metric.ediam ((fun x => z x i) '' A e) := Finset.sum_le_sum he + _ ≤ ∑ e : α, ∑ i ∈ K, Metric.ediam ((fun x => z x i) '' A e) := + Finset.sum_le_sum_of_subset (Finset.filter_subset ..) + _ = ∑ i ∈ K, ∑ e : α, Metric.ediam ((fun x => z x i) '' A e) := Finset.sum_comm + _ ≤ ∑ _i ∈ K, B := Finset.sum_le_sum (fun i _ => hB i) + _ = K.card*B := by simp + +end PlanarHalving.CompactLabels +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology NNReal + +theorem finiteMeasure_subsequence_dependent + {ι : Type*} [Countable ι] {X : ι → Type*} + [∀ i, MetricSpace (X i)] [∀ i, CompactSpace (X i)] [∀ i, Nonempty (X i)] + [∀ i, MeasurableSpace (X i)] [∀ i, BorelSpace (X i)] + (μ : ℕ → ∀ i, FiniteMeasure (X i)) (C : ι → ℝ≥0) + (hbound : ∀ n i, (μ n i).mass ≤ C i) : + ∃ (φ : ℕ → ℕ) (ν : ∀ i, FiniteMeasure (X i)), StrictMono φ ∧ + ∀ i, Tendsto (fun n => μ (φ n) i) atTop (𝓝 (ν i)) := by + let F : ℕ → ∀ i : ι, (Icc (0 : ℝ≥0) (C i)) × ProbabilityMeasure (X i) := + fun n i => (⟨(μ n i).mass,zero_le,hbound n i⟩,(μ n i).normalize) + obtain ⟨g,φ,hφ,hg⟩ := CompactSpace.tendsto_subseq F + refine ⟨φ,fun i => (g i).1.val • (g i).2.toFiniteMeasure,hφ,?_⟩ + intro i + have hi := (tendsto_pi_nhds.mp hg) i + have hm := continuous_subtype_val.tendsto _ |>.comp ((continuous_fst.tendsto (g i)).comp hi) + have hn := (ProbabilityMeasure.toFiniteMeasure_isEmbedding (X i)).continuous.tendsto _ |>.comp + ((continuous_snd.tendsto (g i)).comp hi) + have ht := hm.smul hn + convert ht using 1 + funext n + exact (μ (φ n) i).self_eq_mass_smul_normalize + +end PlanarHalving.Limits +namespace PlanarHalving.TimeWindows +open Set +open scoped unitInterval + +def Before (A B : Window) : Prop := + UniformPartition.boundary (2^A.1) A.2.succ ≤ UniformPartition.boundary (2^B.1) B.2.castSucc + +lemma stop_le_start (R : ℕ) [NeZero R] {A B : Window} (hAB : Before A B) : + stop R A ≤ start R B := cut_mono _ hAB + +end PlanarHalving.TimeWindows +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates TimeWindows MeasureTheory Limits +open scoped unitInterval NNReal ENNReal +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.timeWindow_disjoint (S : @System n R k a P) [NeZero R] [NeZero a] + {A B : Window} (hAB : Before A B) : + Disjoint (S.timeWindow A).edges (S.timeWindow B).edges := by + classical + apply Finset.disjoint_left.mpr + intro e heA heB + let v : ↥S.edges := ⟨e,S.timeWindow_edges A heA⟩ + have hA := (mem_carrier_iff R A (S.trace v.property).batch).mp ((S.timeWindow_mem A v).mp heA) + have hB := (mem_carrier_iff R B (S.trace v.property).batch).mp ((S.timeWindow_mem B v).mp heB) + have hh := stop_le_start R hAB + omega + +lemma System.timeWindow_graph_gap (S : @System n R k a P) [NeZero R] [NeZero n] [NeZero a] + {A B : Window} (hAB : Before A B) {F H : Finset Point} + (G : (S.timeWindow A).FullGraphs F) (G' : (S.timeWindow B).FullGraphs H) : + G.upper < G'.lower := by + apply G.upper_lt.trans_le + apply le_trans _ G'.lower_lt.le + change S.slope ⟨start R A+length R A, _⟩ ≤ S.slope ⟨start R B+0,_⟩ + apply S.increasing.monotone + change start R A+length R A ≤ start R B+0 + rw [start_add_length,Nat.add_zero] + exact stop_le_start R hAB + +noncomputable def System.windowCrossings (S : @System n R k a P) [NeZero R] (A B : Window) : + Finset ((Fin n × Fin n) × (Fin n × Fin n)) := by + classical + exact S.drawing.crossings.filter (fun w => + (w.1 ∈ (S.timeWindow A).edges ∧ w.2 ∈ (S.timeWindow B).edges) ∨ + (w.2 ∈ (S.timeWindow A).edges ∧ w.1 ∈ (S.timeWindow B).edges)) + +lemma System.windowCrossings_sub (S : @System n R k a P) [NeZero R] (A B : Window) : + S.windowCrossings A B ⊆ S.drawing.crossings := Finset.filter_subset .. + +noncomputable def System.windowCrossPoint (S : @System n R k a P) [NeZero R] (A B : Window) + (w : ↥(S.windowCrossings A B)) : Point := + S.drawing.crossingPoint ⟨w.val,S.windowCrossings_sub A B w.property⟩ + +lemma System.windowCrossPoint_injective (S : @System n R k a P) [NeZero R] + (hP : Generic P) (A B : Window) : Function.Injective (S.windowCrossPoint A B) := by + intro w v h + apply Subtype.ext + exact congrArg (fun v : ↥S.drawing.crossings => v.val) + (S.drawing.crossingPoint_injective (S.drawing.noMultiple_of_generic hP) h) + +lemma System.windowCrossPoint_exterior (S : @System n R k a P) [NeZero R] [NeZero a] + {A B : Window} (hAB : Before A B) (w : ↥(S.windowCrossings A B)) : + S.windowCrossPoint A B w ∈ S.drawing.exteriorCrossings (S.timeWindow A).edges ∧ + S.windowCrossPoint A B w ∈ S.drawing.exteriorCrossings (S.timeWindow B).edges := by + classical + let v : ↥S.drawing.crossings := ⟨w.val,S.windowCrossings_sub A B w.property⟩ + have hw := (Finset.mem_filter.mp w.property).2 + have hd := Finset.disjoint_left.mp (S.timeWindow_disjoint hAB) + have hA : (v.val.1 ∈ (S.timeWindow A).edges ∧ v.val.2 ∉ (S.timeWindow A).edges) ∨ + (v.val.2 ∈ (S.timeWindow A).edges ∧ v.val.1 ∉ (S.timeWindow A).edges) := by + rcases hw with hw | hw + · exact Or.inl ⟨hw.1,fun hh => hd hh hw.2⟩ + · exact Or.inr ⟨hw.1,fun hh => hd hh hw.2⟩ + have hB : (v.val.1 ∈ (S.timeWindow B).edges ∧ v.val.2 ∉ (S.timeWindow B).edges) ∨ + (v.val.2 ∈ (S.timeWindow B).edges ∧ v.val.1 ∉ (S.timeWindow B).edges) := by + rcases hw with hw | hw + · exact Or.inr ⟨hw.2,hd hw.1⟩ + · exact Or.inl ⟨hw.2,hd hw.1⟩ + exact ⟨Finset.mem_image.mpr ⟨v,by simp only [Finset.mem_filter,Finset.mem_univ,true_and]; exact hA,rfl⟩, + Finset.mem_image.mpr ⟨v,by simp only [Finset.mem_filter,Finset.mem_univ,true_and]; exact hB,rfl⟩⟩ + +lemma System.windowCrossPoint_graph (S : @System n R k a P) [NeZero R] [NeZero n] [NeZero a] + {A B : Window} (w : ↥(S.windowCrossings A B)) + {F H : Finset Point} (G : (S.timeWindow A).FullGraphs F) (G' : (S.timeWindow B).FullGraphs H) : + (∃ i, G.graph i (S.windowCrossPoint A B w).1 = (S.windowCrossPoint A B w).2) ∧ + ∃ j, G'.graph j (S.windowCrossPoint A B w).1 = (S.windowCrossPoint A B w).2 := by + classical + let v : ↥S.drawing.crossings := ⟨w.val,S.windowCrossings_sub A B w.property⟩ + have hm := S.drawing.crossingPoint_mem v + have hw := (Finset.mem_filter.mp w.property).2 + rcases hw with hw | hw + · exact ⟨⟨_,G.edge _ hw.1 _ (openSegment_subset_segment ℝ _ _ hm.1)⟩, + ⟨_,G'.edge _ hw.2 _ (openSegment_subset_segment ℝ _ _ hm.2)⟩⟩ + · exact ⟨⟨_,G.edge _ hw.1 _ (openSegment_subset_segment ℝ _ _ hm.2)⟩, + ⟨_,G'.edge _ hw.2 _ (openSegment_subset_segment ℝ _ _ hm.1)⟩⟩ + +theorem System.window_crossing_slots (S : @System n R k a P) [NeZero R] [NeZero n] [NeZero a] + (hP : Generic P) {A B : Window} (hAB : Before A B) + (hA : 0 < length R A) (hB : 0 < length R B) : + ∃ slots : ↥(S.windowCrossings A B) → Fin (a*n) × Fin (a*n), + Function.Injective slots ∧ ∀ w, + dist (S.labels hP (S.windowCrossPoint A B w) A,S.labels hP (S.windowCrossPoint A B w) B) + (UniformPartition.gridPoint (a*n) (slots w)) ≤ 2/(a*n : ℕ) := by + classical + obtain ⟨G,hG,hGE⟩ := S.rankFamily_spec hP A hA + obtain ⟨H,hH,hHE⟩ := S.rankFamily_spec hP B hB + let pt := S.windowCrossPoint A B + have hinc (w : ↥(S.windowCrossings A B)) := S.windowCrossPoint_graph w G H + let slots : ↥(S.windowCrossings A B) → Fin (a*n) × Fin (a*n) := fun w => + (⟨slot G.graph (pt w),by simpa using slot_lt_card G.graph (hinc w).1⟩, + ⟨slot H.graph (pt w),by simpa using slot_lt_card H.graph (hinc w).2⟩) + refine ⟨slots,?_,?_⟩ + · intro u v huv + apply S.windowCrossPoint_injective hP A B + apply pair_slots_injOn G.graph H.graph G.slopes H.slopes (S.timeWindow_graph_gap hAB G H) + (range pt) (by rintro _ ⟨w,rfl⟩; exact hinc w) (mem_range_self u) (mem_range_self v) + exact congrArg (fun p : Fin (a*n) × Fin (a*n) => (p.1.val,p.2.val)) huv + · intro w + rw [Prod.dist_eq,max_le_iff] + have hext := S.windowCrossPoint_exterior hAB w + constructor + · change |(S.rankFamily hP A).value (pt w)-(slot G.graph (pt w) : ℝ)/(a*n : ℕ)| ≤ _ + simpa only [Nat.cast_mul] using hGE _ hext.1 + · change |(S.rankFamily hP B).value (pt w)-(slot H.graph (pt w) : ℝ)/(a*n : ℕ)| ≤ _ + simpa only [Nat.cast_mul] using hHE _ hext.2 + +end PlanarHalving.Batches +namespace PlanarHalving.Batches +open MeasureTheory Set Limits TimeWindows PlaneGraph +open scoped NNReal ENNReal unitInterval +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.vertexMeasure_mass_le (S : @System n R k a P) [NeZero n] + {X : Type*} [MeasurableSpace X] (z : Fin n → X) : (S.vertexMeasure z).mass ≤ 1 := by + rw [System.vertexMeasure,mass_weightedAtoms] + have hcard : Fintype.card ↥S.vertices ≤ n := by simpa using S.vertices.card_le_univ + calc + _ ≤ (n : ℝ≥0)⁻¹ * n := mul_le_mul_of_nonneg_left (by exact_mod_cast hcard) zero_le + _ = 1 := inv_mul_cancel₀ (Nat.cast_ne_zero.mpr (NeZero.ne n)) + +noncomputable def System.windowCrossMeasure (S : @System n R k a P) [NeZero R] + (A B : Window) {X : Type*} [MeasurableSpace X] (z : Point → X) : FiniteMeasure X := + weightedAtoms (((a*n : ℕ) : ℝ≥0)^2)⁻¹ (fun w => z (S.windowCrossPoint A B w)) + +lemma System.windowCrossMeasure_mass_le (S : @System n R k a P) [NeZero R] [NeZero n] [NeZero a] + (hP : Generic P) (A B : Window) {X : Type*} [MeasurableSpace X] (z : Point → X) : + (S.windowCrossMeasure A B z).mass ≤ 2 := by + rw [System.windowCrossMeasure,mass_weightedAtoms,Fintype.card_coe] + have hc : (S.windowCrossings A B).card ≤ 2*(a*n)^2 := by + calc + _ ≤ S.drawing.crossings.card := Finset.card_le_card (S.windowCrossings_sub A B) + _ ≤ 2*a^2*S.vertices.card^2 := S.crossing_cap hP.1 (Generic.x_injective hP) + (S.drawing.noMultiple_of_generic hP) + _ ≤ 2*a^2*n^2 := by gcongr; exact S.vertices.card_le_univ.trans (by simp) + _ = 2*(a*n)^2 := by ring + have hM : (((a*n : ℕ) : ℝ≥0)^2) ≠ 0 := + pow_ne_zero _ (Nat.cast_ne_zero.mpr (Nat.mul_ne_zero (NeZero.ne a) (NeZero.ne n))) + calc + _ ≤ (((a*n : ℕ) : ℝ≥0)^2)⁻¹ * (2*((a*n : ℕ) : ℝ≥0)^2) := by + gcongr + exact_mod_cast hc + _ = 2 := by rw [mul_left_comm,inv_mul_cancel₀ hM,mul_one] + +end PlanarHalving.Batches +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable + +structure Configuration where + n : ℕ + R : ℕ + k : ℕ + a : ℕ + n_pos : 0 < n + R_pos : 0 < R + a_pos : 0 < a + point : Fin n → Point + generic : Generic point + system : @System n R k a point + +instance (F : Configuration) : NeZero F.n := ⟨ne_of_gt F.n_pos⟩ +instance (F : Configuration) : NeZero F.R := ⟨ne_of_gt F.R_pos⟩ +instance (F : Configuration) : NeZero F.a := ⟨ne_of_gt F.a_pos⟩ + +noncomputable def Configuration.label (F : Configuration) : Point → Labels := F.system.labels F.generic + +lemma Configuration.continuous_label (F : Configuration) : Continuous F.label := + F.system.continuous_labels F.generic + +noncomputable def Configuration.points (F : Configuration) : FiniteMeasure Labels := + weightedAtoms (F.n : ℝ≥0)⁻¹ (F.label ∘ F.point) +noncomputable def Configuration.vertices (F : Configuration) (J : Window) : FiniteMeasure Labels := + (F.system.timeWindow J).vertexMeasure (F.label ∘ F.point) +noncomputable def Configuration.edgeTime (F : Configuration) : FiniteMeasure (Labels×I) := + F.system.labelTimeMeasure (F.label ∘ F.point) +noncomputable def Configuration.crossings (F : Configuration) (A B : Window) : FiniteMeasure Labels := + F.system.windowCrossMeasure A B F.label +noncomputable def Configuration.timeRestrict (F : Configuration) (J : Window) : FiniteMeasure (Labels×I) := + ⟨(F.edgeTime : Measure (Labels×I)).restrict (Prod.snd ⁻¹' carrier J),inferInstance⟩ + +lemma Configuration.points_mass (F : Configuration) : F.points.mass=1 := by + rw [Configuration.points,mass_weightedAtoms,Fintype.card_fin] + exact inv_mul_cancel₀ (Nat.cast_ne_zero.mpr (NeZero.ne F.n)) +lemma Configuration.vertices_mass_le (F : Configuration) (J : Window) : (F.vertices J).mass ≤ 1 := + (F.system.timeWindow J).vertexMeasure_mass_le _ +lemma Configuration.edgeTime_mass (F : Configuration) : F.edgeTime.mass=1 := F.system.labelTimeMeasure_mass _ +lemma Configuration.crossings_mass_le (F : Configuration) (A B : Window) : (F.crossings A B).mass ≤ 2 := + F.system.windowCrossMeasure_mass_le F.generic A B _ +lemma Configuration.timeRestrict_mass_le (F : Configuration) (J : Window) : (F.timeRestrict J).mass ≤ 1 := by + rw [← F.edgeTime_mass] + apply ENNReal.coe_le_coe.mp + simp only [FiniteMeasure.ennreal_mass] + change (F.edgeTime : Measure (Labels×I)).restrict (Prod.snd ⁻¹' carrier J) univ ≤ + (F.edgeTime : Measure (Labels×I)) univ + exact Measure.restrict_le_self _ + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/LocalZoom.lean b/lean/OAI/Combinatorics/HalvingLines/LocalZoom.lean new file mode 100644 index 0000000000000000000000000000000000000000..47e1db2f46976b9439e5989db8991830797b232f --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/LocalZoom.lean @@ -0,0 +1,391 @@ +import OAI.Combinatorics.HalvingLines.SeparatedWindows + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Zoom +open Set + +noncomputable def columnMap (u v : Point) : Point →L[ℝ] Point := + (ContinuousLinearMap.fst ℝ ℝ ℝ).smulRight u + (ContinuousLinearMap.snd ℝ ℝ ℝ).smulRight v + +@[simp] lemma columnMap_apply (u v x : Point) : columnMap u v x=x.1 • u+x.2 • v := rfl + +noncomputable def columnEquiv (u v : Point) (h : detPair u v ≠ 0) : Point ≃L[ℝ] Point := + ContinuousLinearEquiv.ofBijective (columnMap u v) + (LinearMap.ker_eq_bot.mpr (by + intro x y hxy + have he : (x.1-y.1) • u=(y.2-x.2) • v := by + dsimp [columnMap] at hxy + rw [sub_smul,sub_smul] + linear_combination hxy + have hz := parallel_scalars_zero u v h _ _ he + exact Prod.ext (sub_eq_zero.mp hz.1) (sub_eq_zero.mp hz.2).symm)) + (LinearMap.range_eq_top.mpr (by + intro x + obtain ⟨a,b,hab⟩ := plane_span u v h x + exact ⟨(a,b),hab.symm⟩)) + +@[simp] lemma columnEquiv_apply (u v : Point) (h : detPair u v ≠ 0) (x : Point) : + columnEquiv u v h x=x.1 • u+x.2 • v := rfl + +lemma detPair_smul (u v : Point) (a b : ℝ) : + detPair (a • u) (b • v)=a*b*detPair u v := by + dsimp [detPair]; ring + +lemma three_frame (u v w : Point) (huv : detPair u v ≠ 0) + (huw : detPair u w ≠ 0) (hwv : detPair w v ≠ 0) : + ∃ (E : Point ≃L[ℝ] Point) (a b : ℝ), a≠0 ∧ b≠0 ∧ + E (1,0)=a • u ∧ E (0,1)=b • v ∧ E (1,1)=w := by + obtain ⟨a,b,he⟩ := plane_span u v huv w + have ha : a≠0 := by + intro ha + rw [ha,zero_smul,zero_add] at he + apply hwv + rw [he] + dsimp [detPair]; ring + have hb : b≠0 := by + intro hb + rw [hb,zero_smul,add_zero] at he + apply huw + rw [he] + dsimp [detPair]; ring + have hab : detPair (a • u) (b • v) ≠ 0 := by + rw [detPair_smul]; exact mul_ne_zero (mul_ne_zero ha hb) huv + refine ⟨columnEquiv (a • u) (b • v) hab,a,b,ha,hb,?_,?_,?_⟩ + · simp + · simp + · simpa using he.symm + +lemma slope_frame {s₁ s₂ s₃ : ℝ} (h12 : s₁ dsimp [a,b] <;> field_simp [hden.ne'] <;> ring + have hdet : detPair (a • (1,s₁)) (b • (1,s₃)) ≠ 0 := by + rw [detPair_smul] + exact mul_ne_zero (mul_ne_zero ha.ne' hb.ne') (by simpa [detPair] using hden.ne') + refine ⟨columnEquiv _ _ hdet,a,b,ha,hb,?_,?_,?_⟩ + · simp + · simp + · simpa using he + +end PlanarHalving.Zoom + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +noncomputable def affineHomeomorph (p : Point) (q : ℝ) (hq : q≠0) + (E : Point ≃L[ℝ] Point) : Point ≃ₜ Point where + toFun x := p+q • E x + invFun y := E.symm (q⁻¹ • (y-p)) + left_inv x := by simp only [add_sub_cancel_left,smul_smul,inv_mul_cancel₀ hq,one_smul,E.symm_apply_apply] + right_inv y := by + dsimp only + rw [E.apply_symm_apply,smul_smul,mul_inv_cancel₀ hq,one_smul] + abel + continuous_toFun := by fun_prop + continuous_invFun := by fun_prop + +@[simp] lemma affineHomeomorph_apply (p : Point) (q : ℝ) (hq : q≠0) + (E : Point ≃L[ℝ] Point) (x : Point) : affineHomeomorph p q hq E x=p+q • E x := rfl + +@[simp] lemma affineHomeomorph_symm_apply (p : Point) (q : ℝ) (hq : q≠0) + (E : Point ≃L[ℝ] Point) (y : Point) : (affineHomeomorph p q hq E).symm y=E.symm (q⁻¹ • (y-p)) := rfl + +noncomputable def affineZoom (f : OpenPartialHomeomorph Point Point) + (E B : Point ≃L[ℝ] Point) (p x₀ : Point) (q h : ℝ) (hq : q≠0) (hh : h≠0) : + OpenPartialHomeomorph Point Point := + ((affineHomeomorph x₀ q hq E).transOpenPartialHomeomorph f).transHomeomorph + (affineHomeomorph p h hh B.symm).symm + +@[simp] lemma affineZoom_apply (f : OpenPartialHomeomorph Point Point) + (E B : Point ≃L[ℝ] Point) (p x₀ : Point) (q h : ℝ) (hq : q≠0) (hh : h≠0) (x : Point) : + affineZoom f E B p x₀ q h hq hh x=B (h⁻¹ • (f (x₀+q • E x)-p)) := rfl + +lemma affineZoom_source (f : OpenPartialHomeomorph Point Point) (hs : f.source=univ) + (E B : Point ≃L[ℝ] Point) (p x₀ : Point) (q h : ℝ) (hq : q≠0) (hh : h≠0) : + (affineZoom f E B p x₀ q h hq hh).source=univ := by + ext x + change (x₀+q • E x∈f.source) ↔ x∈univ + rw [hs]; simp + +@[simp] lemma affineZoom_target (f : OpenPartialHomeomorph Point Point) + (E B : Point ≃L[ℝ] Point) (p x₀ : Point) (q h : ℝ) (hq : q≠0) (hh : h≠0) : + (affineZoom f E B p x₀ q h hq hh).target={w | p+h • B.symm w∈f.target} := rfl + +lemma affineZoom_zero (f : OpenPartialHomeomorph Point Point) + (E B : Point ≃L[ℝ] Point) {p : Point} (hp : p∈f.target) + (q h : ℝ) (hq : q≠0) (hh : h≠0) : + affineZoom f E B p (f.symm p) q h hq hh 0=0 := by + simp [f.right_inv hp] + +lemma affineZoom_exhaust (f : ℕ → OpenPartialHomeomorph Point Point) + (E : ℕ → Point ≃L[ℝ] Point) (B : Point ≃L[ℝ] Point) (p : Point) + (x₀ : ℕ → Point) (q h : ℕ → ℝ) (hq : ∀ n, q n≠0) (hh : ∀ n, h n≠0) + (U : Set Point) (hU : IsOpen U) (hp : p∈U) (hUt : ∀ n, U ⊆ (f n).target) + (hlim : Tendsto h atTop (𝓝 0)) (K : Set Point) (hK : IsCompact K) : + ∀ᶠ n in atTop, K ⊆ (affineZoom (f n) (E n) B p (x₀ n) (q n) (h n) (hq n) (hh n)).target := by + obtain ⟨r,hr,hrsub⟩ := Metric.mem_nhds_iff.mp (hU.mem_nhds hp) + obtain ⟨R,hR⟩ := (Metric.isBounded_iff_subset_closedBall (0 : Point)).mp + ((hK.image B.symm.continuous).isBounded) + have ht : Tendsto (fun n => |h n| * max R 0) atTop (𝓝 0) := by + simpa using hlim.abs.mul_const (max R 0) + filter_upwards [ht.eventually (gt_mem_nhds hr)] with n hn w hw + change p+h n • B.symm w ∈ (f n).target + apply hUt n + apply hrsub + rw [mem_ball,dist_eq_norm,add_sub_cancel_left,norm_smul,Real.norm_eq_abs] + have hw' : ‖B.symm w‖ ≤ max R 0 := by + apply le_trans _ (le_max_left _ _) + simpa using hR (mem_image_of_mem _ hw) + exact (mul_le_mul_of_nonneg_left hw' (abs_nonneg _)).trans_lt hn + +lemma affineZoom_normalizing_scale (f : OpenPartialHomeomorph Point Point) (hs : f.source=univ) + (E B : Point ≃L[ℝ] Point) {p : Point} (hp : p∈f.target) + (h : ℝ) (hh : h≠0) + (hball : closedBall (0:Point) 1 ⊆ {w | p+h • B.symm w∈f.target}) : + ∃ q : ℝ, ∃ hq : 0 + ((B'.symm.trans reflectFirst) (affineZoom (F.rankChart hAB hA hB) E B' p x₀ q h hq.ne' hh.ne' (x+r • v))).1) ∧ + Monotone (fun r : ℝ => + ((B'.symm.trans reflectFirst) (affineZoom (F.rankChart hAB hA hB) E B' p x₀ q h hq.ne' hh.ne' (x+r • v))).2) := by + have harg (r : ℝ) : x₀+q • E (x+r • v)=(x₀+q • E x)+(q*r*s) • (1,F.timeSlope t) := by + rw [map_add,map_smul,hE,smul_add,smul_smul,smul_smul] + simp only [mul_assoc,add_assoc] + have h₁ := F.rank_forward_before hA htA (x₀+q • E x) + have h₂ := F.rank_forward_before hB htB (x₀+q • E x) + have hsc : Monotone (fun r : ℝ => q*r*s) := fun a b hab => + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hab hq.le) hs + constructor + · intro a b hab + simp only [affineZoom_apply,ContinuousLinearEquiv.trans_apply,B'.symm_apply_apply, + reflectFirst_apply,F.rankChart_apply] + change -(h⁻¹*((F.system.labels F.generic (x₀+q • E (x+a • v)) A : ℝ)-p.1)) ≤ + -(h⁻¹*((F.system.labels F.generic (x₀+q • E (x+b • v)) A : ℝ)-p.1)) + rw [harg,harg] + exact neg_le_neg (mul_le_mul_of_nonneg_left (sub_le_sub_right (h₁ (hsc hab)) _) (inv_nonneg.mpr hh.le)) + · intro a b hab + simp only [affineZoom_apply,ContinuousLinearEquiv.trans_apply,B'.symm_apply_apply, + reflectFirst_apply,F.rankChart_apply] + change h⁻¹*(-(F.system.labels F.generic (x₀+q • E (x+a • v)) B : ℝ)-p.2) ≤ + h⁻¹*(-(F.system.labels F.generic (x₀+q • E (x+b • v)) B : ℝ)-p.2) + rw [harg,harg] + exact mul_le_mul_of_nonneg_left (sub_le_sub_right (neg_le_neg (h₂ (hsc hab))) _) (inv_nonneg.mpr hh.le) + +lemma affine_rank_direction {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hCB : ∀ i, Before (C i) A ∧ Before (C i) B) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (h q : ℕ → ℝ) (hh : ∀ n, 0 (lower (C i) : ℝ)) (fun i => (upper (C i) : ℝ)) t = {z}) + (v w : Point) (s : ℕ → ℝ) (d : ℝ) + (hE : ∀ n, E n v=s n • (1,(F n).timeSlope t)) + (hB' : B' (reflectFirst (Directions.simplex z))=d • w) + (hj : ∀ i R, 0 ≤ R → TendstoUniformlyOn + (fun n u => (((F n).extendedRank true A B (C i) (p+h n • u) : ℝ)-c i)/h n) + (D i) atTop (closedBall 0 R)) : + DirectionalLimit (fun n => affineZoom ((F n).rankChart hAB (hA n) (hB n)) + (E n) B' p (x₀ n) (q n) (h n) (hq n).ne' (hh n).ne') v w := by + intro ρ hρ x y hxy a b ha hb + choose r hr using hxy + let X := fun n => x₀ (ρ n)+q (ρ n) • E (ρ n) (x n) + let Y := fun n => x₀ (ρ n)+q (ρ n) • E (ρ n) (y n) + have hXY (n : ℕ) : Y n=X n+(q (ρ n)*r n*s (ρ n)) • (1,(F (ρ n)).timeSlope t) := by + dsimp only [X,Y] + rw [hr,map_add,map_smul,hE,smul_add,smul_smul,smul_smul] + simp only [mul_assoc,add_assoc] + have hxa : Tendsto (fun n => (h (ρ n))⁻¹ • + ((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n)) (X n)-p)) atTop (𝓝 (B'.symm a)) := by + have hv := (B'.symm.continuous.tendsto a).comp ha + simpa only [Function.comp_def,affineZoom_apply,B'.symm_apply_apply,X,Y] using hv + have hyb : Tendsto (fun n => (h (ρ n))⁻¹ • + ((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n)) (Y n)-p)) atTop (𝓝 (B'.symm b)) := by + have hv := (B'.symm.continuous.tendsto b).comp hb + simpa only [Function.comp_def,affineZoom_apply,B'.symm_apply_apply,X,Y] using hv + have hj' (i : ι) (R : ℝ) (hR : 0 ≤ R) : TendstoUniformlyOn + (fun n u => (((F (ρ n)).extendedRank true A B (C i) (p+h (ρ n) • u) : ℝ)-c i)/h (ρ n)) + (D i) atTop (closedBall 0 R) := (hj i R hR).seq_tendstoUniformlyOn ρ hρ.tendsto_atTop + obtain ⟨e,he⟩ := actual_unoriented_limit (F ∘ ρ) hAB (fun n => hA (ρ n)) (fun n => hB (ρ n)) C + (fun i => hρ.tendsto_atTop.eventually (hC i)) D c p (h ∘ ρ) (fun n => hh (ρ n)) + t htA htB z hz X Y (fun n => q (ρ n)*r n*s (ρ n)) hXY (B'.symm a) (B'.symm b) hxa hyb + (fun i => jet_at_physical (F ∘ ρ) hAB (hCB i) (fun n => hA (ρ n)) (fun n => hB (ρ n)) + (hρ.tendsto_atTop.eventually (hC i)) (D i) (c i) p (h ∘ ρ) (fun n => hh (ρ n)) (hj' i) X (B'.symm a) hxa) + (fun i => jet_at_physical (F ∘ ρ) hAB (hCB i) (fun n => hA (ρ n)) (fun n => hB (ρ n)) + (hρ.tendsto_atTop.eventually (hC i)) (D i) (c i) p (h ∘ ρ) (fun n => hh (ρ n)) (hj' i) Y (B'.symm b) hyb) + have he' := congrArg B' he + simp only [map_sub,map_smul,B'.apply_symm_apply,hB',smul_smul] at he' + exact ⟨e*d,he'⟩ + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +lemma actual_zoom_compactness {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hCB : ∀ i, Before (C i) A ∧ Before (C i) B) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (hp : p ∈ Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (h q : ℕ → ℝ) (hh : ∀ n, 0 (lower (C i) : ℝ)) (fun i => (upper (C i) : ℝ)) (t j) = {z j}) + (s : ℕ → Foliation → ℝ) (hs : ∀ n i, 0 ≤ s n i) (d : Foliation → ℝ) + (hE : ∀ n i, E n i.direction=s n i • (1,(F n).timeSlope (t i))) + (hB' : ∀ i, B' (reflectFirst (Directions.simplex (z i)))=d i • i.direction) + (hj : ∀ i R, 0 ≤ R → TendstoUniformlyOn + (fun n u => (((F n).extendedRank true A B (C i) (p+h n • u) : ℝ)-c i)/h n) + (D i) atTop (closedBall 0 R)) + (hone : ∀ n, ‖affineZoom ((F n).rankChart hAB (hA n) (hB n)) (E n) B' p + (((F n).rankChart hAB (hA n) (hB n)).symm p) (q n) (h n) (hq n).ne' (hh n).ne' (1,0)‖=1) : + ∃ (ρ : ℕ → ℕ), StrictMono ρ ∧ ∃ sgn : ℝ, (sgn = 1 ∨ sgn = -1) ∧ + (∀ K : Set Point, IsCompact K → TendstoUniformlyOn + (fun n => affineZoom ((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))) (E (ρ n)) B' p + (((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))).symm p) + (q (ρ n)) (h (ρ n)) (hq (ρ n)).ne' (hh (ρ n)).ne') + (fun x => sgn • x) atTop K) ∧ + (∀ K : Set Point, IsCompact K → TendstoUniformlyOn + (fun n => (affineZoom ((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))) (E (ρ n)) B' p + (((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))).symm p) + (q (ρ n)) (h (ρ n)) (hq (ρ n)).ne' (hh (ρ n)).ne').symm) + (fun x => sgn • x) atTop K) := by + let f := fun n => (F n).rankChart hAB (hA n) (hB n) + let x₀ := fun n => (f n).symm p + let Z := fun n => affineZoom (f n) (E n) B' p (x₀ n) (q n) (h n) (hq n).ne' (hh n).ne' + have hsrc (n : ℕ) : (Z n).source=univ := + affineZoom_source (f n) ((F n).rankChart_source hAB (hA n) (hB n)) _ _ _ _ _ _ _ _ + have hpt (n : ℕ) : p∈(f n).target := by + rw [(F n).rankChart_target]; exact hp + let S : FoliatedSequence := { + map := Z + source := hsrc + exhaust := affineZoom_exhaust f E B' p x₀ q h (fun n => (hq n).ne') (fun n => (hh n).ne') + (Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) (isOpen_Ioo.prod isOpen_Ioo) hp + (fun n => by rw [(F n).rankChart_target]) hlim + control i := LineControl.of_monotone Z hsrc i.direction i.direction_ne_zero (B'.symm.trans reflectFirst) + (fun n x => (affine_rank_monotone (F n) hAB (hA n) (hB n) (E n) B' p (x₀ n) + (q n) (h n) (hq n) (hh n) i.direction (t i) (htA i) (htB i) (s n i) (hs n i) (hE n i) x).1) + (fun n x => (affine_rank_monotone (F n) hAB (hA n) (hB n) (E n) B' p (x₀ n) + (q n) (h n) (hq n) (hh n) i.direction (t i) (htA i) (htB i) (s n i) (hs n i) (hE n i) x).2) + direction i := affine_rank_direction F hAB hA hB C hCB hC D c p h q hh hq E B' x₀ + (t i) (htA i) (htB i) (z i) (hz i) i.direction i.direction (fun n => s n i) (d i) + (fun n => hE n i) (hB' i) hj } + exact S.normalized_compactness (fun n => affineZoom_zero (f n) (E n) B' (hpt n) _ _ _ _) hone + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +lemma timeSlope_eventually_lt (F : ℕ → Configuration) + (hR : Tendsto (fun n => (F n).R) atTop atTop) {s t : I} (hst : s ((F n).R:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop.comp hR + filter_upwards [htR.eventually_gt_atTop (2/((t:ℝ)-s))] with n hn + apply (F n).system.increasing + have hs := (abs_le.mp (cut_time_error (F n).R s)).2 + have ht := (abs_le.mp (cut_time_error (F n).R t)).1 + have hp := (div_lt_iff₀ hst').mp hn + have hc : (cut (time (F n).R) s : ℝ)<(cut (time (F n).R) t : ℝ) := by nlinarith + exact_mod_cast hc + +def foliationTriple {α : Type*} (a b c : α) : Foliation → α + | .horizontal => a + | .vertical => c + | .diagonal => b + +lemma positive_slope_frames (F : ℕ → Configuration) (t₁ t₂ t₃ : I) + (h12 : ∀ n, (F n).timeSlope t₁ < (F n).timeSlope t₂) + (h23 : ∀ n, (F n).timeSlope t₂ < (F n).timeSlope t₃) : + ∃ (E : ℕ → Point ≃L[ℝ] Point) (s : ℕ → Foliation → ℝ), + (∀ n i, 0 slope_frame (h12 n) (h23 n) + refine ⟨E,fun n => foliationTriple (a n) 1 (b n),?_,?_⟩ + · intro n i; cases i <;> simp only [foliationTriple] <;> first | exact ha n | exact hb n | norm_num + · intro n i; cases i + · exact hE1 n + · exact hE2 n + · simpa only [one_smul,foliationTriple,Foliation.direction] using hE3 n + +lemma singleton_target_frame (z₁ z₂ z₃ : ℝ) + (h12 : z₁≠z₂) (h23 : z₂≠z₃) (h13 : z₁≠z₃) : + ∃ (B : Point ≃L[ℝ] Point) (d : Foliation → ℝ), + (∀ i, d i≠0) ∧ ∀ i, + B (reflectFirst (Directions.simplex (foliationTriple z₁ z₂ z₃ i)))=d i • i.direction := by + let u := fun z => reflectFirst (Directions.simplex z) + have hd (a b : ℝ) : detPair (u a) (u b)=b-a := by + dsimp [u,detPair,Directions.simplex]; ring + obtain ⟨E,a,b,ha,hb,hE1,hE2,hE3⟩ := three_frame (u z₁) (u z₃) (u z₂) + (by rw [hd]; exact sub_ne_zero.mpr h13.symm) + (by rw [hd]; exact sub_ne_zero.mpr h12.symm) + (by rw [hd]; exact sub_ne_zero.mpr h23.symm) + refine ⟨E.symm,foliationTriple a⁻¹ 1 b⁻¹,?_,?_⟩ + · intro i; cases i <;> simp only [foliationTriple] <;> first | exact inv_ne_zero ha | exact inv_ne_zero hb | norm_num + · intro i + cases i + · change E.symm (u z₁)=a⁻¹ • (1,0) + apply E.injective + rw [E.apply_symm_apply,map_smul,hE1,smul_smul,inv_mul_cancel₀ ha,one_smul] + · change E.symm (u z₃)=b⁻¹ • (0,1) + apply E.injective + rw [E.apply_symm_apply,map_smul,hE2,smul_smul,inv_mul_cancel₀ hb,one_smul] + · change E.symm (u z₂)=1 • (1,1) + rw [one_smul] + apply E.injective + rw [E.apply_symm_apply,hE3] + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Main.lean b/lean/OAI/Combinatorics/HalvingLines/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbbf778c94e396cb3f8b7c103511cbea24b0ac1c --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Main.lean @@ -0,0 +1,38 @@ +import OAI.Combinatorics.HalvingLines.Perturbation + +namespace OAI + +open Filter Topology + +namespace PlanarHalving + +theorem halving_power : + ∃ ε : ℝ, 0 < ε ∧ ∃ C : ℝ, ∃ n₀ : ℕ, + ∀ n : ℕ, Even n → n₀ ≤ n → ∀ P : Fin n → Point, + GeneralPosition P → (halvingCount P : ℝ) ≤ C * (n : ℝ) ^ ((4 : ℝ) / 3 - ε) := by + obtain ⟨ε,hε,C,hbound⟩ := all_ranks_power + refine ⟨ε,hε,C,2,?_⟩ + intro n heven hn P hP + obtain ⟨m,hm⟩ := heven + have hn' : n=2*m := by omega + clear hm + subst n + obtain ⟨Q,hQ,hcount⟩ := Perturbation.generic_same_halvingCount hP + rw [hcount,halvingCount_eq_middle_switchCount (by omega : 0 < m) Q hQ] + exact hbound (2*m) (by omega) Q hQ m (by omega) +end PlanarHalving + +namespace PlanarHalving + +theorem power_bounds : + (∃ ε : ℝ, 0 < ε ∧ ∃ C : ℝ, ∃ n₀ : ℕ, + ∀ n : ℕ, Even n → n₀ ≤ n → ∀ P : Fin n → Point, + GeneralPosition P → (halvingCount P : ℝ) ≤ C * (n : ℝ) ^ ((4 : ℝ) / 3 - ε)) ∧ + (∃ ε : ℝ, 0 < ε ∧ ∃ C : ℝ, + ∀ n : ℕ, 1 ≤ n → ∀ P : Fin n → Point, Generic P → + ∀ k : ℕ, k ≤ n → (switchCount P k : ℝ) ≤ C * (n : ℝ) ^ ((4 : ℝ) / 3 - ε)) := + ⟨halving_power, all_ranks_power⟩ + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/MassEstimates.lean b/lean/OAI/Combinatorics/HalvingLines/MassEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..25b68d2cef5be8188677a6e5ca6e6c94dc16fa10 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/MassEstimates.lean @@ -0,0 +1,491 @@ +import OAI.Combinatorics.HalvingLines.SpatialMass + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Spatial +open Set Filter Metric Zoom +open scoped Topology + +lemma radial_extrema_scale {f g : Point → Point} {p : Point} {h c : ℝ} + (hh : 0 (f n).symm) h q α β) : + p∈ScaleGood (fun n => (normalizeChart (f n) p₀ (U n) (hU n).ne').symm) h q α β := by + refine ⟨hp.1,fun j => ?_⟩ + have hb (n j : ℕ) : closedBall p (h*q^j) ⊆ (f n).target := by + rw [ht n] + exact (closedBall_subset_closedBall (mul_le_of_le_one_right hh.le (pow_le_one₀ hq.le hq1))).trans + (rankCore_ball hh hp.1) + filter_upwards [hp.2 j] with n hn + have he := normalizeChart_radial (f n) p₀ (hU n) (mul_pos hh (pow_pos hq j)) (hb n j) + have he' := normalizeChart_radial (f n) p₀ (hU n) (mul_pos hh (pow_pos hq (j+1))) (hb n (j+1)) + rw [he.1,he.2,he'.1,he'.2] + constructor + · calc + _ = (U n)⁻¹*(α*radialU (f n).symm p (h*q^j)) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hn.1 (inv_nonneg.mpr (hU n).le) + · calc + _ ≤ (U n)⁻¹*(β*radialV (f n).symm p (h*q^j)) := + mul_le_mul_of_nonneg_left hn.2 (inv_nonneg.mpr (hU n).le) + _ = _ := by ring + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter Metric +open scoped Topology + +lemma normalized_spatial_limit (f : ℕ → OpenPartialHomeomorph Point Point) + (hs : ∀ n, (f n).source=univ) + (ht : ∀ n, (f n).target=Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (G : Set Point) (p₀ : Point) (hp₀ : p₀∈G) + {h q s β : ℝ} (hh : 0 (f n).symm) h q (q^s) β) + (hlocal : ∀ p∈G, dist p p₀ (f (φ n)).symm (u n)) atTop (𝓝 (l p))) ∧ + ∀ p p' : G, (q^s*(q/h)^s)*dist (p:Point) p'^s ≤ dist (l p) (l p') := by + have hq1 : q<1 := by linarith + have hiter := fun p hp => scaleGood_iteration f hs ht hh hq hq2 + (Real.rpow_nonneg hq.le s) hβ (hgood hp₀) (hgood hp) (hlocal p hp) hz hU + have hball (n : ℕ) (p : Point) (hp : p∈G) (j : ℕ) : + closedBall p (h*q^j) ⊆ (f n).target := by + rw [ht n] + exact (closedBall_subset_closedBall (mul_le_of_le_one_right hh.le (pow_le_one₀ hq.le hq1.le))).trans + (rankCore_ball hh (hgood hp).1) + have hcont : ∀ p∈G, ∀ ε>0, ∃ r>0, ∀ᶠ n in atTop, ∀ x, + dist x p (f n).symm) G + (fun j => h*q^(j+1)) (fun j => 2*β^j) + (fun j => mul_pos hh (pow_pos hq _)) + · simpa only [mul_zero] using (tendsto_pow_atTop_nhds_zero_of_lt_one hβ hβ1).const_mul 2 + · intro p hp j + filter_upwards [(hiter p hp).2 j] with n hn x hx + have hc := (f n).continuousOn_symm.mono (hball n p hp (j+1)) + have he := radial_extrema_bounds (mul_pos hh (pow_pos hq (j+1))) hc + apply le_trans (b:=radialU (f n).symm p (h*q^(j+1))) ?_ hn.2 + exact radial_upper_enclosure (f n) (hs n) (he.1.trans he.2.1) (hball n p hp (j+1)) + (fun x hx => (he.2.2 x hx).2) x hx.le + obtain ⟨φ,l,hφ,hl,hmoving⟩ := subsequence_of_asymptotic_continuity + (fun n => (f n).symm) G ⟨p₀,hp₀⟩ (closedBall (0:Point) 1) (isCompact_closedBall _ _) + (fun n p hp => by simpa only [mem_closedBall,dist_zero_right] using (hiter p hp).1 n) hcont + refine ⟨φ,l,hφ,fun p => by simpa only [mem_closedBall,dist_zero_right] using hl p,hmoving,?_⟩ + apply inverse_holder_of_radial_limits (fun n => (f n).symm) φ hφ G l + (fun p => hmoving p (fun _ => p) tendsto_const_nhds) hq hq1 hh hspos + · intro p p' + have hd := dist_triangle (p:Point) p₀ (p':Point) + rw [dist_comm p₀ (p':Point)] at hd + have h1 := hlocal p p.property + have h2 := hlocal p' p'.property + linarith + · intro p j hj + cases j with + | zero => omega + | succ j => + filter_upwards [(hiter p p.property).2 j] with n hn p' hdist + have hc := (f n).continuousOn_symm.mono (hball n p p.property (j+1)) + apply hn.1.trans + rw [dist_comm ((f n).symm p) ((f n).symm p')] + apply radial_lower_exterior (f n) (hs n) + (hball n p p.property 0 (by simpa only [pow_zero,mul_one] using mem_closedBall_self hh.le)) + (mul_nonneg hh.le (pow_nonneg hq.le _)) + (fun x hx => ((radial_extrema_bounds (mul_pos hh (pow_pos hq _)) hc).2.2 x hx).1) + p' (hball n p' p'.property 0 (by simpa only [pow_zero,mul_one] using mem_closedBall_self hh.le)) + simpa only [dist_comm] using hdist.le + +end PlanarHalving.Spatial + +namespace PlanarHalving.Limits +open Set Filter MeasureTheory +open scoped ENNReal + +lemma exists_bounded_density_piece {X : Type*} [MeasurableSpace X] + (ν β γ : Measure X) [IsFiniteMeasure ν] [IsFiniteMeasure γ] [SigmaFinite β] + (hac : γ ≪ β) (hpos : γ univ≠0) : + ∃ (m : ℕ) (A : Set X), MeasurableSet A ∧ γ A≠0 ∧ ν.restrict A≤(m:ℝ≥0∞) • β := by + obtain ⟨S,hS,hνS,hβS⟩ := Measure.mutuallySingular_singularPart ν β + let A : ℕ → Set X := fun m => S∩{x | ν.rnDeriv β x≤(m:ℝ≥0∞)} + have hA (m : ℕ) : MeasurableSet (A m) := hS.inter + (measurableSet_le (Measure.measurable_rnDeriv ν β) measurable_const) + have hSae : ∀ᵐ x ∂β, x∈S := by exact hβS + have hcover : ∀ᵐ x ∂γ, ∃ m : ℕ, x∈A m := by + filter_upwards [hac.ae_le hSae,hac.ae_le (Measure.rnDeriv_lt_top ν β)] with x hx hf + obtain ⟨m,hm⟩ := exists_nat_gt (ν.rnDeriv β x).toReal + refine ⟨m,hx,?_⟩ + apply (ENNReal.toReal_le_toReal hf.ne (by simp)).mp + simpa only [ENNReal.toReal_natCast] using hm.le + obtain ⟨m,hm⟩ := positive_countable_selection γ univ MeasurableSet.univ hpos A + (by simpa only [Measure.restrict_univ] using hcover) + have hm' : γ (A m)≠0 := by simpa only [univ_inter] using hm + refine ⟨m,A m,hA m,hm',?_⟩ + have hsing : (ν.singularPart β).restrict (A m)=0 := by + apply Measure.restrict_eq_zero.mpr + exact measure_mono_null inter_subset_left hνS + rw [ν.haveLebesgueDecomposition_add β,Measure.restrict_add,hsing,zero_add, + restrict_withDensity (hA m)] + have hd : (ν.rnDeriv β)≤ᵐ[β.restrict (A m)] fun _ => (m:ℝ≥0∞) := by + filter_upwards [ae_restrict_mem (hA m)] with x hx + exact hx.2 + exact (withDensity_mono hd).trans (by + rw [withDensity_const] + apply Measure.le_iff.mpr + intro B hB + simp only [Measure.smul_apply,smul_eq_mul] + exact mul_le_mul' le_rfl (Measure.restrict_le_self B)) + +lemma positive_bounded_projection {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + (μ θ : Measure X) [IsFiniteMeasure μ] [IsFiniteMeasure θ] + (β : Measure Y) [SigmaFinite β] (π : X → Y) (hπ : Measurable π) + (E : Set X) (hE : MeasurableSet E) (hpos : θ E≠0) + (hac : (θ.restrict E).map π ≪ β) : + ∃ (m : ℕ) (G : Set X), MeasurableSet G ∧ G⊆E ∧ θ G≠0 ∧ + (μ.restrict G).map π≤(m:ℝ≥0∞) • β := by + obtain ⟨m,A,hA,hm,hb⟩ := exists_bounded_density_piece (μ.map π) β ((θ.restrict E).map π) hac (by + simpa only [Measure.map_apply hπ MeasurableSet.univ,preimage_univ,Measure.restrict_apply_univ] using hpos) + let G := π ⁻¹' A ∩ E + have hG : MeasurableSet G := (hA.preimage hπ).inter hE + refine ⟨m,G,hG,inter_subset_right,?_,?_⟩ + · simpa only [Measure.map_apply hπ hA,Measure.restrict_apply (hA.preimage hπ)] using hm + · apply le_trans (b:= (μ.map π).restrict A) ?_ hb + apply Measure.le_iff.mpr + intro B hB + rw [Measure.map_apply hπ hB,Measure.restrict_apply (hB.preimage hπ), + Measure.restrict_apply hB,Measure.map_apply hπ (hB.inter hA)] + apply measure_mono + intro x hx + exact ⟨hx.1,hx.2.1⟩ + +end PlanarHalving.Limits + +namespace PlanarHalving.Spatial +open Set Filter Metric +open scoped Topology + +lemma joint_of_asymptotic_continuity {X Y : Type*} [MetricSpace X] [MetricSpace Y] + (f : ℕ → X → Y) {p : X} {v : Y} + (hl : Tendsto (fun n => f n p) atTop (𝓝 v)) + (hc : ∀ ε>0, ∃ r>0, ∀ᶠ n in atTop, ∀ x, dist x p f q.1 q.2) (atTop ×ˢ 𝓝 p) (𝓝 v) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + obtain ⟨r,hr,hrc⟩ := hc (ε/2) (half_pos hε) + have hl' := (Metric.tendsto_nhds.mp hl) (ε/2) (half_pos hε) + have hp : ∀ᶠ x in 𝓝 p, dist x p (f n).symm) h q α β) + (hp : p∈ScaleGood (fun n => (f n).symm) h q α β) (hd : dist p p₀ (f (φ n)).symm p) atTop (𝓝 v)) : + Tendsto (fun z : ℕ × Point => (f (φ z.1)).symm z.2) (atTop ×ˢ 𝓝 p) (𝓝 v) := by + apply joint_of_asymptotic_continuity _ hl + have hi := scaleGood_iteration f hs ht hh hq hq2 hα hβ h₀ hp hd hz hU + have hb (n j : ℕ) : closedBall p (h*q^j) ⊆ (f n).target := by + rw [ht n] + exact (closedBall_subset_closedBall (mul_le_of_le_one_right hh.le + (pow_le_one₀ hq.le (by linarith)))).trans (rankCore_ball hh hp.1) + intro ε hε + have he : Tendsto (fun j : ℕ => 2*β^j) atTop (𝓝 0) := by + simpa only [mul_zero] using (tendsto_pow_atTop_nhds_zero_of_lt_one hβ hβ1).const_mul 2 + obtain ⟨j,hj⟩ := ((tendsto_order.mp he).2 ε hε).exists + refine ⟨h*q^(j+1),mul_pos hh (pow_pos hq _),?_⟩ + filter_upwards [hφ.tendsto_atTop.eventually (hi.2 j)] with n hn x hx + have hdisk := radial_upper_enclosure (f (φ n)) (hs (φ n)) + (by positivity : 0≤2*β^j) (hb (φ n) (j+1)) (fun y hy => + ((radial_extrema_bounds (mul_pos hh (pow_pos hq _)) + ((f (φ n)).continuousOn_symm.mono (hb (φ n) (j+1)))).2.2 y hy).2.trans hn.2) + exact (hdisk x hx.le).trans hj.le + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter Metric MeasureTheory +open scoped Topology ENNReal + +lemma positive_localization {X : Type*} [MeasurableSpace X] + (μ : Measure X) (E : Set X) (hE : MeasurableSet E) (hpos : μ E≠0) + (π : X → Point) (hπ : Measurable π) {r : ℝ} (hr : 0 π ⁻¹' ball (a j) (r/2) + obtain ⟨j,hj⟩ := Limits.positive_countable_selection μ E hE hpos A (by + apply Eventually.of_forall + intro x + obtain ⟨j,hj⟩ := ha.exists_dist_lt (π x) (half_pos hr) + exact ⟨j,by simpa only [A,mem_preimage,mem_ball,dist_comm] using hj⟩) + let G := E∩A j + obtain ⟨x₀,hx₀⟩ := nonempty_of_measure_ne_zero hj + refine ⟨G,x₀,hE.inter (measurableSet_ball.preimage hπ),inter_subset_left,hj,hx₀,?_⟩ + intro x hx + have h1 : dist (π x) (a j)] (0:ℝ), + ∀ᶠ n in atTop, Zoom.RadialCompare (f n).symm (π x) h C T) : + ∃ (G : Set X), MeasurableSet G ∧ G⊆E ∧ θ G≠0 ∧ + ∃ (m : ℕ), (μ.restrict G).map π≤(m:ℝ≥0∞) • volume ∧ + ∃ (p₀ : Point) (U : ℕ → ℝ) (hU : ∀ n, 0 + (normalizeChart (f (φ z.1)) p₀ (U (φ z.1)) (hU (φ z.1)).ne').symm z.2) + (atTop ×ˢ 𝓝 (p:Point)) (𝓝 (l p))) ∧ + ∀ p p' : (π '' G), c*dist (p:Point) p'^((17:ℝ)/16)≤dist (l p) (l p') := by + have hcont (n : ℕ) : ContinuousOn (f n).symm (Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) := by + rw [← ht n]; exact (f n).continuousOn_symm + obtain ⟨M,k,hM,hAmeas,hApos⟩ := positive_scaleGood θ E hE hpos π hπ + (fun n => (f n).symm) hcont hc + obtain ⟨hq,hq2,hβ,hβ1,hα⟩ := integer_scale_parameters hM + let q : ℝ := 1/(M:ℝ)^16 + let h : ℝ := q^k + let β : ℝ := (M:ℝ)/(M:ℝ)^16 + have hh : 0 (f n).symm) h q (q^((17:ℝ)/16)) β + have hAm : MeasurableSet A := by simpa only [A,h,q,β,hα] using hAmeas + have hAp : θ A≠0 := by simpa only [A,h,q,β,hα] using hApos + have hAE : A⊆E := inter_subset_left + have hacA : (θ.restrict A).map π ≪ volume := by + exact (Measure.absolutelyContinuous_of_le (Measure.map_mono (Measure.restrict_mono_set θ hAE) hπ)).trans hac + obtain ⟨m,B,hBm,hBA,hBp,hBd⟩ := Limits.positive_bounded_projection μ θ volume π hπ A hAm hAp hacA + obtain ⟨G,x₀,hGm,hGB,hGp,hx₀,hloc⟩ := positive_localization θ B hBm hBp π hπ (by positivity : 0 (f n).symm) h q (q^((17:ℝ)/16)) β := by + rintro p ⟨x,hx,rfl⟩; exact (hGA hx).2 + let p₀ := π x₀ + have hp₀ : p₀∈π '' G := mem_image_of_mem π hx₀ + have hb₀ (n : ℕ) : closedBall p₀ h ⊆ (f n).target := by + rw [ht n]; exact rankCore_ball hh (hgood hp₀).1 + let U : ℕ → ℝ := fun n => radialU (f n).symm p₀ h + have hU (n : ℕ) : 0 normalizeChart (f n) p₀ (U n) (hU n).ne' + have hgs (n : ℕ) : (g n).source=univ := normalizeChart_source _ (hs n) _ _ _ + have hgt (n : ℕ) : (g n).target=Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0 := ht n + have hg : π '' G ⊆ ScaleGood (fun n => (g n).symm) h q (q^((17:ℝ)/16)) β := by + intro p hp + exact normalizeChart_scaleGood f ht p₀ U hU hh hq (by linarith) (hgood hp) + have hz (n : ℕ) : (g n).symm p₀=0 := by simp [g] + have hgU (n : ℕ) : radialU (g n).symm p₀ h=1 := by + rw [(normalizeChart_radial (f n) p₀ (hU n) hh (hb₀ n)).1] + exact inv_mul_cancel₀ (hU n).ne' + obtain ⟨φ,l,hφ,hl,hmov,hsep⟩ := normalized_spatial_limit g hgs hgt (π '' G) p₀ hp₀ + hh hq hq2 (by norm_num : (0:ℝ)<17/16) hβ hβ1 hg + (by rintro p ⟨x,hx,rfl⟩; exact hloc x hx) hz hgU + refine ⟨G,hGm,hGA.trans hAE,hGp,m,?_,p₀,U,hU,φ,l,q^((17:ℝ)/16)*(q/h)^((17:ℝ)/16), + by positivity,hφ,hl,?_,hsep⟩ + · exact (Measure.map_mono (Measure.restrict_mono_set μ hGB) hπ).trans hBd + · intro p + apply scaleGood_joint g hgs hgt hh hq hq2 (by positivity) hβ hβ1 + (hg hp₀) (hg p.property) _ hz hgU φ hφ (l p) + · exact hmov p (fun _ => (p:Point)) tendsto_const_nhds + · obtain ⟨x,hx,he⟩ := p.property + rw [← he]; exact hloc x hx + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter Metric MeasureTheory +open scoped Topology ENNReal unitInterval + +abbrev Cube := I × I +noncomputable def encode (p : Point) : Cube := (unitInterval.sigmoid p.1,unitInterval.sigmoid p.2) +noncomputable def decode (p : Cube) : Point := + (-Real.log ((p.1:ℝ)⁻¹-1),-Real.log ((p.2:ℝ)⁻¹-1)) + +lemma continuous_encode : Continuous encode := by + exact (unitInterval.continuous_sigmoid.comp continuous_fst).prodMk + (unitInterval.continuous_sigmoid.comp continuous_snd) + +lemma measurable_decode : Measurable decode := by + exact ((Real.measurable_log.comp ((measurable_subtype_coe.comp measurable_fst).inv.sub measurable_const)).neg).prodMk + ((Real.measurable_log.comp ((measurable_subtype_coe.comp measurable_snd).inv.sub measurable_const)).neg) + +@[simp] lemma decode_encode (p : Point) : decode (encode p)=p := by + have hn (t : ℝ) : -Real.log ((unitInterval.sigmoid t:ℝ)⁻¹-1)=t := by + change -Real.log (((1+Real.exp (-t))⁻¹)⁻¹-1)=t + simp + exact Prod.ext (hn p.1) (hn p.2) + +lemma encode_injective : Function.Injective encode := by + intro p q he + simpa only [decode_encode] using congrArg decode he + +lemma support_spatial_graph {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + {μs : ℕ → FiniteMeasure (X × Cube)} {μ : FiniteMeasure (X × Cube)} + (hμ : Tendsto μs atTop (𝓝 μ)) (π : X → Point) (hπ : Continuous π) + (f : ℕ → Point → Point) + (hid : ∀ᶠ n in atTop, ∀ᵐ z ∂(μs n : Measure (X × Cube)), z.2=encode (f n (π z.1))) + (G : Set X) (l : (π '' G) → Point) + (hjoint : ∀ p : (π '' G), Tendsto (fun q : ℕ × Point => f q.1 q.2) + (atTop ×ˢ 𝓝 (p:Point)) (𝓝 (l p))) + {z : X × Cube} (hz : z∈(μ : Measure (X × Cube)).support) (hG : z.1∈G) : + z.2=encode (l ⟨π z.1,mem_image_of_mem π hG⟩) := by + exact Limits.support_coordinate_identity hμ (fun z => π z.1) (hπ.comp continuous_fst) + Prod.snd continuous_snd (fun n p => encode (f n p)) hid hz + ((continuous_encode.tendsto _).comp (hjoint ⟨π z.1,mem_image_of_mem π hG⟩)) + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter Metric MeasureTheory +open scoped ENNReal + +lemma volume_closedBall_point (p : Point) {r : ℝ} (hr : 0≤r) : + volume (closedBall p r)=ENNReal.ofReal (4*r^2) := by + rw [← closedBall_prod_same] + change (volume.prod volume) (closedBall p.1 r ×ˢ closedBall p.2 r)=_ + rw [Measure.prod_prod,Real.volume_closedBall,Real.volume_closedBall,← ENNReal.ofReal_mul (by positivity)] + congr 1 + ring + +lemma disk_bound_of_inverse_holder {X : Type*} [MeasurableSpace X] + (μ : Measure X) (G : Set X) (hG : MeasurableSet G) + (π ψ : X → Point) (hπ : Measurable π) (hψ : Measurable ψ) + {M : ℝ≥0∞} {c s : ℝ} (hc : 0 p x.val)).card = (s.filter p).card := by + classical + rw [← Finset.card_image_of_injective _ Subtype.val_injective] + congr 1 + ext x + simp [and_comm] +end PlanarHalving +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +noncomputable def Configuration.longEdges (F : Configuration) (ρ : ℝ) : Finset (Fin F.n×Fin F.n) := + F.system.edges.filter (fun e => ENNReal.ofReal ρ ≤ Metric.ediam + (F.label '' segment ℝ (F.point e.1) (F.point e.2))) + +lemma Configuration.longEdges_bound {ρ : ℝ} (hρ : 0<ρ) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ F : Configuration, ((F.longEdges ρ).card : ℝ) ≤ C*(F.a : ℝ)*F.n := by + classical + obtain ⟨K,hK⟩ := CompactLabels.finite_tail (ι:=Window) (ENNReal.ofReal_pos.mpr hρ) + refine ⟨4*K.card/ρ,by positivity,fun F => ?_⟩ + have hh := CompactLabels.long_count_bound F.label + (fun e : ↥F.system.edges => segment ℝ (F.point e.val.1) (F.point e.val.2)) + (ENNReal.ofReal_pos.mpr hρ) K hK (fun J => F.system.coordinate_oscillation F.generic J) + have hh' := ENNReal.toReal_mono (by finiteness) hh + simp only [ENNReal.toReal_mul,ENNReal.toReal_div,ENNReal.toReal_ofReal hρ.le, + ENNReal.toReal_ofNat,ENNReal.toReal_natCast] at hh' + have hc : (Finset.univ.filter (fun e : ↥F.system.edges => ENNReal.ofReal ρ ≤ Metric.ediam + (F.label '' segment ℝ (F.point e.val.1) (F.point e.val.2)))).card=(F.longEdges ρ).card := + by + simpa only [Configuration.longEdges] using (card_filter_attached F.system.edges + (fun e => ENNReal.ofReal ρ ≤ Metric.ediam (F.label '' segment ℝ (F.point e.1) (F.point e.2)))) + rw [hc] at hh' + change ρ/2*((F.longEdges ρ).card : ℝ) ≤ (K.card : ℝ)*(2*(F.a : ℝ)*F.n) at hh' + calc + _ ≤ 4*(K.card : ℝ)*F.a*F.n/ρ := (le_div_iff₀ hρ).mpr (by nlinarith [hh']) + _ = _ := by ring + +lemma longEdges_ratio_zero {F : ℕ → Configuration} + (hratio : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + {ρ : ℝ} (hρ : 0<ρ) : + Tendsto (fun n => (((F n).longEdges ρ).card : ℝ)/((F n).R*(F n).a^2)) atTop (𝓝 0) := by + obtain ⟨C,hC,hbound⟩ := Configuration.longEdges_bound hρ + have ht := hratio.const_mul C + simp only [mul_zero] at ht + apply squeeze_zero (fun _ => by positivity) _ ht + intro n + have ha : (0:ℝ)<(F n).a := Nat.cast_pos.mpr (F n).a_pos + have hR : (0:ℝ)<(F n).R := Nat.cast_pos.mpr (F n).R_pos + apply (div_le_iff₀ (mul_pos hR (pow_pos ha 2))).mpr + have hh := hbound (F n) + calc + _ ≤ C*(F n).a*(F n).n := hh + _ = _ := by field_simp + +lemma Configuration.short_edge_label {F : Configuration} {ρ : ℝ} + {e : Fin F.n×Fin F.n} (he : e∈F.system.edges) (hshort : e∉F.longEdges ρ) + {p : Point} (hp : p∈segment ℝ (F.point e.1) (F.point e.2)) : + dist (F.label p) (F.label (F.point e.1))<ρ := by + classical + have hdiam : Metric.ediam (F.label '' segment ℝ (F.point e.1) (F.point e.2)).comp + (finiteMeasure_tendsto_apply h (hnull j).2) + have hb : q<(μ (Metric.thickening (s j) F) : ℝ) := + hq.trans_le (NNReal.coe_le_coe.mpr (μ.apply_mono (Metric.self_subset_thickening (hnull j).1 _))) + filter_upwards [(tendsto_order.mp hlim).1 q hb] with n hn + exact hn.trans_le (NNReal.coe_le_coe.mpr (μs n |>.apply_mono (Metric.thickening_mono hj.le _))) + +end PlanarHalving.Limits +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter PlaneGraph +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +lemma Configuration.edgeWindow_apply (F : Configuration) (J : Window) + {U : Set Labels} (hU : MeasurableSet U) : + (F.edgeWindow J U : ℝ)= + (((F.system.timeWindow J).edges.filter (fun e : Fin F.n×Fin F.n => F.label (F.point e.1)∈U)).card : ℝ)/ + ((F.R : ℝ)*F.a^2) := by + classical + rw [F.edgeWindow_eq,System.endpointMeasure,weightedAtoms_apply_finset _ _ hU] + simp only [Function.comp_apply] + rw [card_filter_attached _ (fun e : Fin F.n×Fin F.n => F.label (F.point e.1)∈U)] + simp only [NNReal.coe_inv,NNReal.coe_mul,NNReal.coe_pow,NNReal.coe_natCast, + div_eq_inv_mul] + +lemma Configuration.windows_edges_disjoint (F : Configuration) {A B : Window} + (hAB : Disjoint (carrier A) (carrier B)) : + Disjoint (F.system.timeWindow A).edges (F.system.timeWindow B).edges := by + classical + apply Finset.disjoint_left.mpr + intro e heA heB + let v : ↥F.system.edges := ⟨e,F.system.timeWindow_edges A heA⟩ + exact Set.disjoint_left.mp hAB ((F.system.timeWindow_mem A v).mp heA) + ((F.system.timeWindow_mem B v).mp heB) + +noncomputable def Configuration.selectedEdges (F : Configuration) (W : Finset Window) + (U : Set Labels) : Finset (Fin F.n×Fin F.n) := by + classical + exact W.biUnion (fun J => (F.system.timeWindow J).edges.filter (fun e : Fin F.n×Fin F.n => F.label (F.point e.1)∈U)) + +lemma Configuration.selectedEdges_mass (F : Configuration) (W : Finset Window) + (hW : ∀ J∈W, ∀ K∈W, J≠K → Disjoint (carrier J) (carrier K)) + {U : Set Labels} (hU : MeasurableSet U) : + ∑ J∈W, (F.edgeWindow J U : ℝ) = + ((F.selectedEdges W U).card : ℝ)/((F.R : ℝ)*F.a^2) := by + classical + simp_rw [F.edgeWindow_apply _ hU] + rw [← Finset.sum_div,Configuration.selectedEdges,Finset.card_biUnion] + · push_cast; rfl + · intro J hJ K hK hJK + exact (F.windows_edges_disjoint (hW J hJ K hK hJK)).mono + (Finset.filter_subset ..) (Finset.filter_subset ..) + +lemma Configuration.selectedEdges_subset (F : Configuration) (W : Finset Window) + (U : Set Labels) : F.selectedEdges W U⊆F.system.edges := by + classical + intro e he + obtain ⟨J,_hJ,heJ⟩ := Finset.mem_biUnion.mp he + exact F.system.timeWindow_edges J (Finset.mem_filter.mp heJ).1 + +lemma Configuration.retained_near (F : Configuration) (W : Finset Window) + (A : Set Labels) {ρ : ℝ} (e : Fin F.n×Fin F.n) + (he : e∈F.selectedEdges W (Metric.thickening ρ A) \ F.longEdges ρ) + (p : Point) (hp : p∈segment ℝ (F.point e.1) (F.point e.2)) : + F.label p∈Metric.cthickening (2*ρ) A := by + classical + obtain ⟨hes,hel⟩ := Finset.mem_sdiff.mp he + obtain ⟨J,_hJ,heJ⟩ := Finset.mem_biUnion.mp hes + obtain ⟨z,hz,hd⟩ := Metric.mem_thickening_iff.mp (Finset.mem_filter.mp heJ).2 + have hp' := F.short_edge_label (F.selectedEdges_subset W _ hes) hel hp + exact Metric.mem_cthickening_of_dist_le _ z _ A hz + (le_of_lt ((dist_triangle _ _ _).trans_lt (by linarith))) + +lemma Configuration.retained_mass_lower (F : Configuration) (W : Finset Window) + (hW : ∀ J∈W, ∀ K∈W, J≠K → Disjoint (carrier J) (carrier K)) + {U : Set Labels} (hU : MeasurableSet U) (ρ : ℝ) : + (∑ J∈W, (F.edgeWindow J U : ℝ)) - + ((F.longEdges ρ).card : ℝ)/((F.R : ℝ)*F.a^2) ≤ + ((F.selectedEdges W U \ F.longEdges ρ).card : ℝ)/((F.R : ℝ)*F.a^2) := by + classical + rw [F.selectedEdges_mass W hW hU,← sub_div] + apply div_le_div_of_nonneg_right _ (by positivity) + have hh := Finset.card_le_card (show F.selectedEdges W U⊆ + (F.selectedEdges W U \ F.longEdges ρ)∪F.longEdges ρ from by + intro e he; by_cases h : e∈F.longEdges ρ <;> simp [he,h]) + have hh' := hh.trans (Finset.card_union_le _ _) + have hh'' : ((F.selectedEdges W U).card : ℝ) ≤ + ((F.selectedEdges W U \ F.longEdges ρ).card : ℝ)+(F.longEdges ρ).card := by + exact_mod_cast hh' + linarith + +end PlanarHalving.RankLimits +namespace PlanarHalving.Limits +open Filter +open scoped Topology + +lemma eventually_sum_lower {ι : Type*} (W : Finset ι) {f : ℕ → ι → ℝ} {a : ι → ℝ} + (h : ∀ i∈W, ∀ ε : ℝ, 0<ε → ∀ᶠ n in atTop, a i-ε ≤ f n i) + {ε : ℝ} (hε : 0<ε) : ∀ᶠ n in atTop, (∑ i∈W, a i)-ε ≤ ∑ i∈W, f n i := by + classical + induction W using Finset.induction_on generalizing ε with + | empty => exact Eventually.of_forall (fun _ => by simpa using hε.le) + | @insert i W hi ih => + have h₁ := h i (Finset.mem_insert_self _ _) (ε/2) (by positivity) + have h₂ := ih (fun j hj => h j (Finset.mem_insert_of_mem hj)) (ε := ε/2) (half_pos hε) + filter_upwards [h₁,h₂] with n hn hn' + simp only [Finset.sum_insert hi] + linarith + +lemma eventually_sum_upper {ι : Type*} (W : Finset ι) {f : ℕ → ι → ℝ} {a : ι → ℝ} + (h : ∀ i∈W, ∀ ε : ℝ, 0<ε → ∀ᶠ n in atTop, f n i ≤ a i+ε) + {ε : ℝ} (hε : 0<ε) : ∀ᶠ n in atTop, (∑ i∈W, f n i) ≤ (∑ i∈W, a i)+ε := by + have hh := eventually_sum_lower W (f:=fun n i => -f n i) (a:=fun i => -a i) + (fun i hi δ hδ => (h i hi δ hδ).mono (fun n hn => by linarith)) hε + filter_upwards [hh] with n hn + simp only [Finset.sum_neg_distrib] at hn + linarith + +lemma cubic_of_eventual_bounds {x b e : ℕ → ℝ} {s B C : ℝ} + (hs : 0 ≤ s) (hC : 0 ≤ C) (hx : ∀ n, 0 ≤ x n) + (hb : ∀ n, (x n)^3 ≤ C*b n+e n) + (hlower : ∀ ε : ℝ, 0<ε → ∀ᶠ n in atTop, s-ε ≤ x n) + (hupper : ∀ ε : ℝ, 0<ε → ∀ᶠ n in atTop, b n ≤ B+ε) + (he : Tendsto e atTop (𝓝 0)) : s^3 ≤ C*B := by + have hineq (ε : ℝ) (hε : 0<ε) : (max (s-ε) 0)^3 ≤ C*(B+ε)+ε := by + have hev := ((tendsto_order.mp he).2 ε hε).mono (fun n hn => hn.le) + obtain ⟨n,hn,hn',hen⟩ := ((hlower ε hε).and ((hupper ε hε).and hev)).exists + have hl : max (s-ε) 0 ≤ x n := max_le hn (hx n) + exact (pow_le_pow_left₀ (le_max_right _ _) hl 3).trans + ((hb n).trans (add_le_add (mul_le_mul_of_nonneg_left hn' hC) hen)) + have hlim₁ : Tendsto (fun ε : ℝ => (max (s-ε) 0)^3) (𝓝[>] 0) (𝓝 (s^3)) := by + have hc : Continuous (fun ε : ℝ => (max (s-ε) 0)^3) := by fun_prop + simpa only [sub_zero,max_eq_left hs] using (hc.continuousWithinAt (s:=Set.Ioi (0:ℝ)) (x:=0)).tendsto + have hlim₂ : Tendsto (fun ε : ℝ => C*(B+ε)+ε) (𝓝[>] 0) (𝓝 (C*B)) := by + have hc : Continuous (fun ε : ℝ => C*(B+ε)+ε) := by fun_prop + simpa only [add_zero] using (hc.continuousWithinAt (s:=Set.Ioi (0:ℝ)) (x:=0)).tendsto + exact le_of_tendsto_of_tendsto hlim₁ hlim₂ + (Filter.mem_of_superset self_mem_nhdsWithin (fun ε hε => hineq ε hε)) + +end PlanarHalving.Limits +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter PlaneGraph +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +lemma Configuration.retained_cubic (F : Configuration) {C : ℝ} + (hcoeff : 4608*(F.a : ℝ)^2*F.n^4/((F.R : ℝ)*F.a^2)^3 ≤ C) + (W : Finset Window) (E : Finset (Fin F.n×Fin F.n)) (hE : E⊆F.system.edges) + (hcover : ∀ e∈E, ∃ J∈W, e∈(F.system.timeWindow J).edges) + {U : Set Labels} (hU : MeasurableSet U) + (hnear : ∀ e∈E, ∀ p∈segment ℝ (F.point e.1) (F.point e.2), F.label p∈U) : + ((E.card : ℝ)/((F.R : ℝ)*F.a^2))^3 ≤ + C*(∑ J∈W, ∑ K∈W, if J=K then 2*((F.vertices J).mass : ℝ)^2 + else (F.crossings J K U : ℝ))+ + 13824*(F.n : ℝ)^3/((F.R : ℝ)*F.a^2)^3 := by + classical + let cr : ℝ := ((F.system.drawing.restrictEdges E).crossings.card : ℝ) + let coeff : ℝ := 4608*(F.a : ℝ)^2*F.n^4/((F.R : ℝ)*F.a^2)^3 + have hc := F.system.restricted_crossing F.generic E hE + have hc' : (E.card : ℝ)^3 ≤ 4608*(F.n : ℝ)^2*cr+13824*(F.n : ℝ)^3 := by + dsimp [cr]; nlinarith [mul_nonneg (sq_nonneg (F.n : ℝ)) + (show (0:ℝ) ≤ ((F.system.drawing.restrictEdges E).crossings.card : ℝ) by positivity)] + have hn : (F.n : ℝ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne F.n) + have ha : (F.a : ℝ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne F.a) + have hR : (F.R : ℝ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne F.R) + have heq : (4608*(F.n : ℝ)^2*cr+13824*(F.n : ℝ)^3)/((F.R : ℝ)*F.a^2)^3 = + coeff*(cr/((F.a : ℝ)*F.n)^2)+13824*(F.n : ℝ)^3/((F.R : ℝ)*F.a^2)^3 := by + dsimp [coeff]; field_simp + have hb := F.system.retained_crossing_bound F.generic F.label hU W E hE hcover hnear + have hb' : cr/((F.a : ℝ)*F.n)^2 ≤ + ∑ J∈W, ∑ K∈W, if J=K then 2*((F.vertices J).mass : ℝ)^2 else (F.crossings J K U : ℝ) := by + simpa only [F.vertices_mass_ratio,div_pow,mul_div_assoc,Configuration.crossings,Nat.cast_mul] using hb + rw [div_pow] + apply (div_le_div_of_nonneg_right hc' (by positivity)).trans + rw [heq] + apply add_le_add _ le_rfl + exact (mul_le_mul_of_nonneg_right hcoeff (by dsimp [cr]; positivity)).trans + (mul_le_mul_of_nonneg_left hb' ((show (0:ℝ) ≤ coeff by dsimp [coeff]; positivity).trans hcoeff)) + +lemma Converges.partition_cubic_thickening {F : ℕ → Configuration} {L : Data} (h : Converges F L) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4/(((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3/(((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + (W : Finset Window) (hW : ∀ J∈W, ∀ K∈W, J≠K → Disjoint (carrier J) (carrier K)) + (A : Set Labels) {ρ : ℝ} (hρ : 0<ρ) : + (∑ J∈W, (L.edgeWindow J A : ℝ))^3 ≤ + C*(∑ J∈W, ∑ K∈W, if J=K then 2*((L.vertices J).mass : ℝ)^2 + else (L.crossings J K (Metric.cthickening (2*ρ) A) : ℝ)) := by + classical + let U := Metric.thickening ρ A + let V := Metric.cthickening (2*ρ) A + let E (n : ℕ) := (F n).selectedEdges W U \ (F n).longEdges ρ + apply cubic_of_eventual_bounds (x:=fun n => ((E n).card : ℝ)/((F n).R*(F n).a^2)) + (b:=fun n => ∑ J∈W, ∑ K∈W, if J=K then 2*(((F n).vertices J).mass : ℝ)^2 + else ((F n).crossings J K V : ℝ)) + (by positivity) hC (fun n => by positivity) + · intro n + apply (F n).retained_cubic (hcoeff n) W (E n) + ((Finset.sdiff_subset).trans ((F n).selectedEdges_subset W U)) + · intro e he + obtain ⟨J,hJ,heJ⟩ := Finset.mem_biUnion.mp (Finset.mem_sdiff.mp he).1 + exact ⟨J,hJ,(Finset.mem_filter.mp heJ).1⟩ + · exact Metric.isClosed_cthickening.measurableSet + · exact fun e he p hp => (F n).retained_near W A e he p hp + · intro ε hε + have h₁ := eventually_sum_lower W (fun J _ δ hδ => + (eventually_thickening_lower (h.edgeWindow J) A hρ (by linarith : (L.edgeWindow J A : ℝ)-δ<_)).mono + (fun _ hn => hn.le)) (half_pos hε) + have h₂ := (tendsto_order.mp (longEdges_ratio_zero hshort hρ)).2 (ε/2) (half_pos hε) + filter_upwards [h₁,h₂] with n hn hn' + have hb := (F n).retained_mass_lower W hW (U:=U) Metric.isOpen_thickening.measurableSet ρ + dsimp only [E,U] at * + linarith + · intro ε hε + apply eventually_sum_upper W _ hε + intro J _ δ hδ + apply eventually_sum_upper W _ hδ + intro K _ τ hτ + by_cases hJK : J=K + · simp only [ite_eq_left hJK] + have ht := NNReal.continuous_coe.tendsto _ |>.comp (FiniteMeasure.continuous_mass.tendsto _ |>.comp (h.vertices J)) + exact ((tendsto_order.mp (ht.pow 2 |>.const_mul 2)).2 _ (lt_add_of_pos_right _ hτ)).mono (fun _ hn => hn.le) + · simp only [ite_eq_right hJK] + exact (eventually_lt_closed (h.crossings J K) Metric.isClosed_cthickening + (lt_add_of_pos_right _ hτ)).mono (fun _ hn => hn.le) + · exact herror + +end PlanarHalving.RankLimits +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology NNReal ENNReal +variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + +lemma finiteMeasure_tendsto_cthickening (μ : FiniteMeasure X) {A : Set X} (hA : IsClosed A) + {r : ℕ → ℝ} (hr : Tendsto r atTop (𝓝 0)) : + Tendsto (fun n => (μ (Metric.cthickening (r n) A) : ℝ)) atTop (𝓝 (μ A : ℝ)) := by + have ht := tendsto_measure_cthickening_of_isClosed (μ:=(μ : Measure X)) + ⟨1,by norm_num,measure_ne_top _ _⟩ hA + exact ENNReal.tendsto_toReal (measure_ne_top (μ : Measure X) A) |>.comp (ht.comp hr) + +end PlanarHalving.Limits +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter PlaneGraph +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +lemma Data.partitionQuantity_tendsto (L : Data) (W : Finset Window) + {A : Set Labels} (hA : IsClosed A) {r : ℕ → ℝ} (hr : Tendsto r atTop (𝓝 0)) : + Tendsto (fun n : ℕ => + ∑ J∈W, ∑ K∈W, if J=K then 2*((L.vertices J).mass : ℝ)^2 + else (L.crossings J K (Metric.cthickening (r n) A) : ℝ)) atTop + (𝓝 (∑ J∈W, ∑ K∈W, if J=K then 2*((L.vertices J).mass : ℝ)^2 else (L.crossings J K A : ℝ))) := by + classical + apply tendsto_finsetSum + intro J hJ + apply tendsto_finsetSum + intro K hK + by_cases hJK : J=K + · simp only [ite_eq_left hJK]; exact tendsto_const_nhds + · simp only [ite_eq_right hJK]; exact finiteMeasure_tendsto_cthickening _ hA hr + +lemma Converges.partition_cubic_closed {F : ℕ → Configuration} {L : Data} (h : Converges F L) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4/(((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3/(((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + (W : Finset Window) (hW : ∀ J∈W, ∀ K∈W, J≠K → Disjoint (carrier J) (carrier K)) + {A : Set Labels} (hA : IsClosed A) : + (∑ J∈W, (L.edgeWindow J A : ℝ))^3 ≤ + C*(∑ J∈W, ∑ K∈W, if J=K then 2*((L.vertices J).mass : ℝ)^2 else (L.crossings J K A : ℝ)) := by + classical + have hr : Tendsto (fun n : ℕ => 2*(1/((n:ℝ)+1))) atTop (𝓝 0) := by + simpa using tendsto_one_div_add_atTop_nhds_zero_nat.const_mul (2:ℝ) + have hlim := L.partitionQuantity_tendsto W hA hr |>.const_mul C + apply ge_of_tendsto hlim + exact Eventually.of_forall (fun n => + h.partition_cubic_thickening hC hcoeff herror hshort W hW A (by positivity : 0 < (1/((n:ℝ)+1)))) + +end PlanarHalving.RankLimits +namespace PlanarHalving.UniformPartition +open Set +open scoped unitInterval + +lemma cell_refinement (m d : ℕ) [NeZero m] [NeZero d] (i : Fin (m*d)) : + cell (m*d) i ⊆ cell m ⟨i.val/d,(Nat.div_lt_iff_lt_mul (NeZero.pos d)).mpr i.isLt⟩ := by + intro t ht + let j : Fin m := ⟨i.val/d,(Nat.div_lt_iff_lt_mul (NeZero.pos d)).mpr i.isLt⟩ + have hm : (0:ℝ) < m := Nat.cast_pos.mpr (NeZero.pos m) + have hd : (0:ℝ) < d := Nat.cast_pos.mpr (NeZero.pos d) + have hlo : (j:ℝ)*d ≤ (i:ℝ) := by + exact_mod_cast Nat.div_mul_le_self i.val d + have hhi : (i:ℝ)+1 ≤ ((j:ℝ)+1)*d := by + have hr := Nat.mod_lt i.val (NeZero.pos d) + have he := Nat.mod_add_div i.val d + have hh : i.val+1 ≤ (i.val/d+1)*d := by nlinarith + exact_mod_cast hh + have hlow : (j:ℝ)/(m:ℝ) ≤ (t:ℝ) := by + apply le_trans _ (cell_lower (m*d) i ht) + rw [Nat.cast_mul] + apply (div_le_div_iff₀ hm (mul_pos hm hd)).mpr + nlinarith + have hup : ((i:ℝ)+1)/((m*d:ℕ):ℝ) ≤ ((j:ℝ)+1)/(m:ℝ) := by + rw [Nat.cast_mul] + apply (div_le_div_iff₀ (mul_pos hm hd) hm).mpr + nlinarith + change t∈cell m j + unfold cell + split_ifs with hj + · refine ⟨hlow,?_⟩ + change (t:ℝ) ≤ _ + simpa only [boundary,Fin.val_succ,Nat.cast_add,Nat.cast_one] using (cell_upper (m*d) i ht).trans hup + · have hi : i.val+1≠m*d := by + intro hi + have hsur : i.val+1 ≤ (j.val+1)*d := by exact_mod_cast hhi + have hjlt : j.val+1 < m := by omega + have hh := Nat.mul_lt_mul_of_pos_right hjlt (NeZero.pos d) + omega + refine ⟨hlow,?_⟩ + change (t:ℝ) < _ + simpa only [boundary,Fin.val_succ,Nat.cast_add,Nat.cast_one] using (cell_upper_lt (m*d) i hi ht).trans_le hup + +lemma exists_cell_refinement (m d N : ℕ) [NeZero m] [NeZero d] [NeZero N] + (hN : N=m*d) (i : Fin N) : ∃ j : Fin m, cell N i⊆cell m j := by + subst N + exact ⟨_,cell_refinement m d i⟩ + +end PlanarHalving.UniformPartition +namespace PlanarHalving.TimeWindows +open Set +open scoped unitInterval + +lemma carrier_refinement (d m : ℕ) (i : Fin (2^(d+m))) : + ∃ j : Fin (2^d), carrier ⟨d+m,i⟩⊆carrier ⟨d,j⟩ := by + exact UniformPartition.exists_cell_refinement (2^d) (2^m) (2^(d+m)) (pow_add 2 d m) i + +lemma same_depth_disjoint {d : ℕ} {i j : Fin (2^d)} (hij : i≠j) : + Disjoint (carrier ⟨d,i⟩) (carrier ⟨d,j⟩) := UniformPartition.cells_disjoint _ hij + +lemma refining_cell_subset {K J : Window} {m : ℕ} (hdepth : J.1=K.1+m) + {t : I} (htK : t∈carrier K) (htJ : t∈carrier J) : carrier J⊆carrier K := by + obtain ⟨d,i⟩ := K + obtain ⟨e,j⟩ := J + dsimp only at hdepth + subst e + obtain ⟨k,hk⟩ := carrier_refinement d m j + by_cases hki : k=i + · simpa only [hki] using hk + · exact False.elim (Set.disjoint_left.mp (same_depth_disjoint hki) (hk htJ) htK) + +end PlanarHalving.TimeWindows +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +noncomputable def localPartition (K : Window) (m : ℕ) : Finset Window := + (timePartition (K.1+m)).filter (fun J => carrier J⊆carrier K) + +lemma mem_timePartition {J : Window} {m : ℕ} : J∈timePartition m ↔ J.1=m := by + obtain ⟨d,i⟩ := J + constructor + · intro h + obtain ⟨j,_,he⟩ := Finset.mem_image.mp h + exact (congrArg Sigma.fst he).symm + · intro h + dsimp only at h + subst d + exact Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩ + +lemma timePartition_disjoint (m : ℕ) {J K : Window} (hJ : J∈timePartition m) (hK : K∈timePartition m) + (hJK : J≠K) : Disjoint (carrier J) (carrier K) := by + obtain ⟨d,i⟩ := J + obtain ⟨e,j⟩ := K + have hd := mem_timePartition.mp hJ + have he := mem_timePartition.mp hK + dsimp only at hd he + subst d; subst e + exact same_depth_disjoint (fun hij => hJK (congrArg (Sigma.mk m) hij)) + +lemma localPartition_cover (K : Window) (m : ℕ) {t : I} (ht : t∈carrier K) : + ∃ J∈localPartition K m, t∈carrier J := by + obtain ⟨J,hJ,htJ⟩ := timePartition_cover (K.1+m) t + exact ⟨J,Finset.mem_filter.mpr ⟨hJ,refining_cell_subset (mem_timePartition.mp hJ) ht htJ⟩,htJ⟩ + +lemma localPartition_disjoint (K : Window) (m : ℕ) {J H : Window} + (hJ : J∈localPartition K m) (hH : H∈localPartition K m) (hJH : J≠H) : + Disjoint (carrier J) (carrier H) := + timePartition_disjoint _ (Finset.mem_filter.mp hJ).1 (Finset.mem_filter.mp hH).1 hJH + +end PlanarHalving.RankLimits +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable Classical + +lemma Converges.edgeWindow_apply {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) + {U : Set Labels} (hU : MeasurableSet U) : + (L.edgeWindow J U : ℝ)=(L.edgeTime : Measure (Labels×I)).real (U×ˢcarrier J) := by + change ((L.edgeWindow J : Measure Labels) U).toReal= _ + rw [Data.edgeWindow,FiniteMeasure.toMeasure_map,Measure.map_apply measurable_fst hU, + h.restriction_eq hR,Measure.restrict_apply (hU.preimage measurable_fst)] + rfl + +lemma Converges.localPartition_sum {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (K : Window) (m : ℕ) + {U : Set Labels} (hU : MeasurableSet U) : + ∑ J∈localPartition K m, (L.edgeWindow J U : ℝ)=(L.edgeWindow K U : ℝ) := by + simp_rw [h.edgeWindow_apply hR _ hU] + have hd : Set.PairwiseDisjoint (↑(localPartition K m) : Set Window) (fun J => U×ˢcarrier J) := by + intro J hJ H hH hJH + exact Set.disjoint_left.mpr (fun t htJ htH => + Set.disjoint_left.mp (localPartition_disjoint K m hJ hH hJH) htJ.2 htH.2) + rw [← measureReal_biUnion_finset hd (fun J _ => hU.prod (measurable_carrier J))] + congr 1 + ext t + constructor + · intro ht + obtain ⟨J,hJ,htJ⟩ := mem_iUnion₂.mp ht + exact ⟨htJ.1,(Finset.mem_filter.mp hJ).2 htJ.2⟩ + · intro ht + obtain ⟨J,hJ,htJ⟩ := localPartition_cover K m ht.2 + exact mem_iUnion₂.mpr ⟨J,hJ,ht.1,htJ⟩ + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Model.lean b/lean/OAI/Combinatorics/HalvingLines/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..297f0bfeb62ce11ceabca3a65ab2e978985d7db1 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Model.lean @@ -0,0 +1,47 @@ +import Mathlib + +namespace OAI + +namespace PlanarHalving + +abbrev Point := ℝ × ℝ + +def orient (p q r : Point) : ℝ := + (q.1 - p.1) * (r.2 - p.2) - (q.2 - p.2) * (r.1 - p.1) + +def GeneralPosition {n : ℕ} (P : Fin n → Point) : Prop := + Function.Injective P ∧ ∀ i j l, i ≠ j → j ≠ l → i ≠ l → + orient (P i) (P j) (P l) ≠ 0 + +noncomputable def sideCount {n : ℕ} (P : Fin n → Point) (i j : Fin n) : ℕ := + (Finset.univ.filter fun l => 0 < orient (P i) (P j) (P l)).card + +noncomputable def halvingCount {n : ℕ} (P : Fin n → Point) : ℕ := + (Finset.univ.filter fun ij : Fin n × Fin n => + ij.1 < ij.2 ∧ sideCount P ij.1 ij.2 = (n - 2) / 2 ∧ + sideCount P ij.2 ij.1 = (n - 2) / 2).card + +noncomputable def slope (p q : Point) : ℝ := (q.2 - p.2) / (q.1 - p.1) + +def Generic {n : ℕ} (P : Fin n → Point) : Prop := + GeneralPosition P ∧ + (∀ i j, i ≠ j → (P i).1 ≠ (P j).1) ∧ + (∀ i j a b, i < j → a < b → slope (P i) (P j) = slope (P a) (P b) → + i = a ∧ j = b) ∧ + (∀ i j a b c d, i < j → a < b → c < d → + (i, j) ≠ (a, b) → (c, d) ≠ (i, j) → (c, d) ≠ (a, b) → + ∀ z : Point, z ∈ openSegment ℝ (P i) (P j) → + z ∈ openSegment ℝ (P a) (P b) → z ∉ segment ℝ (P c) (P d)) + +noncomputable def belowCount {n : ℕ} (P : Fin n → Point) (i j : Fin n) : ℕ := + let s := slope (P i) (P j) + (Finset.univ.filter fun l => (P l).2 - s * (P l).1 < + (P i).2 - s * (P i).1).card + +noncomputable def switchCount {n : ℕ} (P : Fin n → Point) (k : ℕ) : ℕ := + (Finset.univ.filter fun ij : Fin n × Fin n => + ij.1 < ij.2 ∧ 0 < k ∧ k < n ∧ belowCount P ij.1 ij.2 = k - 1).card + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Noncollapse.lean b/lean/OAI/Combinatorics/HalvingLines/Noncollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..4763f05dee5a2fc47b32db1b406760a794b62d3b --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Noncollapse.lean @@ -0,0 +1,451 @@ +import OAI.Combinatorics.HalvingLines.Foliations + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +lemma diagonal_common_limit {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hCB : ∀ i, Before (C i) A ∧ Before (C i) B) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (hp : p ∈ Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (h : ℕ → ℝ) (hh : ∀ n, 0 (((F n).extendedRank true A B (C i) (p+h n • u) : ℝ)-c i)/h n) + (D i) atTop (closedBall 0 R)) + (τ₁ τ₂ τ₃ : I) (hτA : ∀ i, foliationTriple τ₁ τ₂ τ₃ i ≤ lower A) + (hτB : ∀ i, foliationTriple τ₁ τ₂ τ₃ i ≤ lower B) + (h12 : ∀ n, (F n).timeSlope τ₁ < (F n).timeSlope τ₂) + (h23 : ∀ n, (F n).timeSlope τ₂ < (F n).timeSlope τ₃) + (z : Foliation → ℝ) + (hz : ∀ j, Directions.allowed reflectFirst D (fun i => (lower (C i):ℝ)) + (fun i => (upper (C i):ℝ)) ((foliationTriple τ₁ τ₂ τ₃ j : I) : ℝ)={z j}) + (B' : Point ≃L[ℝ] Point) (d : Foliation → ℝ) + (hB' : ∀ i, B' (reflectFirst (Directions.simplex (z i)))=d i • i.direction) + (hball : ∀ n, closedBall (0:Point) 1 ⊆ {w | p+h n • B'.symm w∈Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0}) + (G : ℕ → Point ≃L[ℝ] Point) (t : Fin 3 → I) + (htA : ∀ i, t i ≤ lower A) (htB : ∀ i, t i ≤ lower B) + (v : Fin 3 → Point) (ε : ℝ) (hε : 0<ε) + (hcond : FrameCondition B' + (fun j => Directions.allowed reflectFirst D (fun i => (lower (C i):ℝ)) + (fun i => (upper (C i):ℝ)) (t j)) v ε) + (hG : ∀ n i, detPair (G n (1,(F n).timeSlope (t i))) (v i)=0) : + ∃ ρ : ℕ → ℕ, StrictMono ρ ∧ ∃ r : ℕ → ℝ, (∀ n, 0 r n • (G (ρ n) (((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))).symm + (p+h (ρ n) • w))-G (ρ n) (((F (ρ n)).rankChart hAB (hA (ρ n)) (hB (ρ n))).symm p))) + M atTop K := by + obtain ⟨E,s,hs,hE⟩ := positive_slope_frames F τ₁ τ₂ τ₃ h12 h23 + have hex (n : ℕ) : ∃ q : ℝ, ∃ hq : 0 (hs n i).le) d hE hB' hj hone + obtain ⟨ψ,hψ,r,hr,M,hMl,hMu,hM⟩ := actual_common_inverse_limit (F ∘ ρ) hAB + (fun n => hA (ρ n)) (fun n => hB (ρ n)) C hCB + (fun i => hρ.tendsto_atTop.eventually (hC i)) D c p hp (h ∘ ρ) (q ∘ ρ) + (fun n => hh (ρ n)) (fun n => hq (ρ n)) (E ∘ ρ) (G ∘ ρ) B' t htA htB v ε hε hcond + (fun n i => hG (ρ n) i) sgn hsgn + (fun i R hR => (hj i R hR).seq_tendstoUniformlyOn ρ hρ.tendsto_atTop) hu hi + exact ⟨ρ ∘ ψ,hρ.comp hψ,r,hr,M,hMl,hMu,hM⟩ + +end PlanarHalving.RankLimits + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +lemma compact_scaling_eventually (U : Set Point) (hU : IsOpen U) {p : Point} (hp : p∈U) + (B : Point ≃L[ℝ] Point) (h : ℕ → ℝ) (hlim : Tendsto h atTop (𝓝 0)) + (K : Set Point) (hK : IsCompact K) : + ∀ᶠ n in atTop, ∀ w∈K, p+h n • B w∈U := by + obtain ⟨r,hr,hrsub⟩ := Metric.mem_nhds_iff.mp (hU.mem_nhds hp) + obtain ⟨R,hR⟩ := (Metric.isBounded_iff_subset_closedBall (0:Point)).mp (hK.image B.continuous).isBounded + have ht : Tendsto (fun n => |h n| *max R 0) atTop (𝓝 0) := by simpa using hlim.abs.mul_const (max R 0) + filter_upwards [ht.eventually (gt_mem_nhds hr)] with n hn w hw + apply hrsub + rw [mem_ball,dist_eq_norm,add_sub_cancel_left,norm_smul,Real.norm_eq_abs] + have hw' : ‖B w‖ ≤ max R 0 := by + apply le_trans _ (le_max_left _ _) + simpa only [mem_closedBall,dist_zero_right] using hR (mem_image_of_mem B hw) + exact (mul_le_mul_of_nonneg_left hw' (abs_nonneg _)).trans_lt hn + +lemma radial_of_jet_diagonals {ι : Type*} [Nonempty ι] [Countable ι] + (f : ℕ → ι → Point → ℝ) (c : ι → ℝ) (D : ι → Point →L[ℝ] ℝ) + (L : ℕ → Point → Point) (p : Point) (l u C : ℝ) + (hl : 0 0, ∀ᶠ h in 𝓝[>] (0:ℝ), ∀ᶠ n in atTop, + ∀ x ∈ closedBall p (R*h), dist (f n i x) (c i+D i (x-p)) < ε*h) + (hdiag : ∀ (h : ℕ → ℝ) (N : ℕ → ℕ), (∀ m, 0 (f (N m) i (p+h m • w)-c i)/h m) (D i) atTop (closedBall 0 R)) → + ∃ ρ : ℕ → ℕ, StrictMono ρ ∧ ∃ r : ℕ → ℝ, (∀ n, 0 r n • (L (N (ρ n)) (p+h (ρ n) • w)-L (N (ρ n)) p)) + M atTop (closedBall 0 1)) : + ∀ T : ℝ, 1≤T → ∀ᶠ h in 𝓝[>] (0:ℝ), ∀ᶠ n in atTop, + RadialCompare (L n) p h C T := by + intro T hT + by_contra hbad + have hf : ∃ᶠ h in 𝓝[>] (0:ℝ), ∃ᶠ n in atTop, ¬RadialCompare (L n) p h C T := by + simpa only [Filter.Frequently,not_not] using hbad + obtain ⟨h,N,hh,hlim,hN,hbad,hj⟩ := RankLimit.jet_diagonal f c D p hfirst + (fun h n => ¬RadialCompare (L n) p h C T) hf + obtain ⟨ρ,hρ,r,hr,M,hMl,hMu,hconv⟩ := hdiag h N hh hlim hN hj + have hc := uniform_radial_compare _ M l u C T hl hu hT hC hMl hMu hconv + obtain ⟨n,hn⟩ := hc.exists + exact hbad (ρ n) (radial_compare_of_zoom (L (N (ρ n))) p (h (ρ n)) (r n) C T + (hh _) (hr _) hn) + +end PlanarHalving.Zoom + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +lemma actual_radial_comparison {ι : Type*} [Nonempty ι] [Countable ι] + (F : ℕ → Configuration) (hR : Tendsto (fun n => (F n).R) atTop atTop) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hCB : ∀ i, Before (C i) A ∧ Before (C i) B) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (hp : p ∈ Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (hfirst : ∀ i R, 0 ≤ R → ∀ ε > 0, ∀ᶠ h in 𝓝[>] (0:ℝ), ∀ᶠ n in atTop, + ∀ x ∈ closedBall p (R*h), + dist (((F n).extendedRank true A B (C i) x : ℝ)) (c i+D i (x-p)) < ε*h) + (τ₁ τ₂ τ₃ : I) (hτ12 : τ₁<τ₂) (hτ23 : τ₂<τ₃) + (hτA : ∀ i, foliationTriple τ₁ τ₂ τ₃ i ≤ lower A) + (hτB : ∀ i, foliationTriple τ₁ τ₂ τ₃ i ≤ lower B) + (z : Foliation → ℝ) + (hz : ∀ j, Directions.allowed reflectFirst D (fun i => (lower (C i):ℝ)) + (fun i => (upper (C i):ℝ)) ((foliationTriple τ₁ τ₂ τ₃ j : I) : ℝ)={z j}) + (B' : Point ≃L[ℝ] Point) (d : Foliation → ℝ) + (hB' : ∀ i, B' (reflectFirst (Directions.simplex (z i)))=d i • i.direction) + (G : ℕ → Point ≃L[ℝ] Point) (t : Fin 3 → I) + (htA : ∀ i, t i ≤ lower A) (htB : ∀ i, t i ≤ lower B) + (v : Fin 3 → Point) (ε : ℝ) (hε : 0<ε) + (hcond : FrameCondition B' + (fun j => Directions.allowed reflectFirst D (fun i => (lower (C i):ℝ)) + (fun i => (upper (C i):ℝ)) (t j)) v ε) + (hG : ∀ n i, detPair (G n (1,(F n).timeSlope (t i))) (v i)=0) + (C₀ : ℝ) (hC₀ : ‖B'.toContinuousLinearMap‖ < C₀*(ε/‖B'.symm.toContinuousLinearMap‖)) : + ∀ T : ℝ, 1≤T → ∀ᶠ h in 𝓝[>] (0:ℝ), ∀ᶠ n in atTop, + RadialCompare (fun x => G n (((F n).rankChart hAB (hA n) (hB n)).symm x)) p h C₀ T := by + apply radial_of_jet_diagonals + (fun n i x => ((F n).extendedRank true A B (C i) x : ℝ)) c D + (fun n x => G n (((F n).rankChart hAB (hA n) (hB n)).symm x)) p + (ε/‖B'.symm.toContinuousLinearMap‖) ‖B'.toContinuousLinearMap‖ C₀ + (div_pos hε (equiv_opNorm_pos _)) (norm_nonneg _) hC₀ hfirst + intro h N hh hlim hN hj + have h12 := timeSlope_eventually_lt (F ∘ N) (hR.comp hN) hτ12 + have h23 := timeSlope_eventually_lt (F ∘ N) (hR.comp hN) hτ23 + have hball := compact_scaling_eventually _ (isOpen_Ioo.prod isOpen_Ioo) hp B'.symm h hlim + (closedBall 0 1) (isCompact_closedBall _ _) + obtain ⟨n₀,hn₀⟩ := eventually_atTop.mp (h12.and (h23.and hball)) + let η : ℕ → ℕ := fun n => n+n₀ + have hη : StrictMono η := by intro a b hab; dsimp [η]; omega + have hgood (n : ℕ) := hn₀ (η n) (by dsimp [η]; omega) + obtain ⟨ρ,hρ,r,hr,M,hMl,hMu,hconv⟩ := diagonal_common_limit (F ∘ N ∘ η) hAB + (fun n => hA (N (η n))) (fun n => hB (N (η n))) C hCB + (fun i => (hN.comp hη.tendsto_atTop).eventually (hC i)) D c p hp (h ∘ η) + (fun n => hh (η n)) (hlim.comp hη.tendsto_atTop) + (fun i R hR => (hj i R hR).seq_tendstoUniformlyOn η hη.tendsto_atTop) + τ₁ τ₂ τ₃ hτA hτB (fun n => (hgood n).1) (fun n => (hgood n).2.1) + z hz B' d hB' (fun n => (hgood n).2.2) (G ∘ N ∘ η) t htA htB v ε hε hcond + (fun n i => hG (N (η n)) i) + exact ⟨η ∘ ρ,hη.comp hρ,r,hr,M,hMl,hMu,hconv _ (isCompact_closedBall _ _)⟩ + +end PlanarHalving.RankLimits + +namespace PlanarHalving.Spatial +open Set Filter Metric +open scoped Topology + +lemma ray_image_leaves_compact (f : OpenPartialHomeomorph Point Point) + (hs : f.source=univ) (K : Set Point) (hK : IsCompact K) (hKt : K ⊆ f.target) + (x v : Point) (hv : v≠0) : ∃ t : ℝ, 0≤t ∧ f (x+t • v) ∉ K := by + have hc := hK.image_of_continuousOn (f.continuousOn_symm.mono hKt) + obtain ⟨C,hC,hbound⟩ := hc.isBounded.exists_pos_norm_le + have hvp := norm_pos_iff.mpr hv + let t : ℝ := (C+‖x‖+1)/‖v‖ + have ht : 0≤t := by dsimp [t]; positivity + refine ⟨t,ht,?_⟩ + intro hmem + have hx : x+t • v ∈ f.symm '' K := ⟨f (x+t • v),hmem,f.left_inv (by rw [hs]; trivial)⟩ + have hb := hbound _ hx + have hh : ‖t • v‖ ≤ ‖x+t • v‖+‖x‖ := by + calc + _ = ‖(x+t • v)-x‖ := by congr 1; abel + _ ≤ _ := norm_sub_le _ _ + rw [norm_smul,Real.norm_eq_abs,abs_of_nonneg ht] at hh + have he : t*‖v‖=C+‖x‖+1 := div_mul_cancel₀ _ hvp.ne' + rw [he] at hh + linarith + +lemma radial_upper_enclosure (f : OpenPartialHomeomorph Point Point) + (hs : f.source=univ) {p : Point} {h U : ℝ} (hU : 0≤U) + (hball : closedBall p h ⊆ f.target) + (hb : ∀ x ∈ sphere p h, dist (f.symm x) (f.symm p) ≤ U) : + ∀ x ∈ closedBall p h, dist (f.symm x) (f.symm p) ≤ U := by + intro x hx + by_cases he : f.symm x=f.symm p + · simpa only [he,dist_self] using hU + let v := f.symm x-f.symm p + have hv : v≠0 := sub_ne_zero.mpr he + obtain ⟨t,ht,hexit⟩ := ray_image_leaves_compact f hs (closedBall p h) + (isCompact_closedBall _ _) hball (f.symm x) v hv + have hf : Continuous f := continuousOn_univ.mp (by simpa only [hs] using f.continuousOn) + have hcont : Continuous (fun s : ℝ => dist (f (f.symm x+s • v)) p) := + (hf.comp + (continuous_const.add (continuous_id.smul continuous_const))).dist continuous_const + have h0 : dist (f (f.symm x+(0:ℝ) • v)) p ≤ h := by + simpa only [zero_smul,add_zero,f.right_inv (hball hx)] using (Metric.mem_closedBall.mp hx) + have h1 : h ≤ dist (f (f.symm x+t • v)) p := (not_le.mp hexit).le + obtain ⟨s,hs',heq⟩ := intermediate_value_Icc ht hcont.continuousOn ⟨h0,h1⟩ + have hh := hb (f (f.symm x+s • v)) heq + rw [f.left_inv (by rw [hs]; trivial)] at hh + have hn : dist (f.symm x+s • v) (f.symm p)=(1+s)*dist (f.symm x) (f.symm p) := by + rw [dist_eq_norm,show f.symm x+s • v-f.symm p=(1+s) • v by dsimp [v]; module] + rw [norm_smul,Real.norm_eq_abs,abs_of_nonneg (by linarith [hs'.1])] + rfl + rw [hn] at hh + nlinarith [dist_nonneg (x:=f.symm x) (y:=f.symm p),hs'.1] + +lemma radial_lower_exterior (f : OpenPartialHomeomorph Point Point) + (hs : f.source=univ) {p : Point} (hp : p∈f.target) {h V : ℝ} (hh : 0≤h) + (hb : ∀ x ∈ sphere p h, V ≤ dist (f.symm x) (f.symm p)) : + ∀ x ∈ f.target, h ≤ dist x p → V ≤ dist (f.symm x) (f.symm p) := by + intro x hx hxp + let v := f.symm x-f.symm p + have hf : Continuous f := continuousOn_univ.mp (by simpa only [hs] using f.continuousOn) + have hcont : Continuous (fun s : ℝ => dist (f (f.symm p+s • v)) p) := + (hf.comp + (continuous_const.add (continuous_id.smul continuous_const))).dist continuous_const + have h0 : dist (f (f.symm p+(0:ℝ) • v)) p ≤ h := by simpa [f.right_inv hp] using hh + have h1 : h ≤ dist (f (f.symm p+(1:ℝ) • v)) p := by simpa [v,f.right_inv hx] using hxp + obtain ⟨s,hs',heq⟩ := intermediate_value_Icc (show (0:ℝ)≤1 by norm_num) hcont.continuousOn ⟨h0,h1⟩ + have hb' := hb (f (f.symm p+s • v)) heq + rw [f.left_inv (by rw [hs]; trivial),dist_eq_norm,add_sub_cancel_left, + norm_smul,Real.norm_eq_abs,abs_of_nonneg hs'.1] at hb' + change V ≤ dist (f.symm x) (f.symm p) + rw [dist_eq_norm] + exact hb'.trans (mul_le_of_le_one_left (norm_nonneg v) hs'.2) + +lemma radial_inner_enclosure (f : OpenPartialHomeomorph Point Point) + (hs : f.source=univ) {p : Point} (hp : p∈f.target) {h V : ℝ} (hh : 0≤h) + (hb : ∀ x ∈ sphere p h, V ≤ dist (f.symm x) (f.symm p)) : + ball (f.symm p) V ⊆ f.symm '' ball p h := by + intro y hy + have hyt : f y∈f.target := f.map_source (by rw [hs]; trivial) + have he : f.symm (f y)=y := f.left_inv (by rw [hs]; trivial) + refine ⟨f y,?_,he⟩ + by_contra hn + have hd := radial_lower_exterior f hs hp hh hb (f y) hyt (not_lt.mp hn) + rw [he] at hd + exact (not_lt_of_ge hd) hy + +end PlanarHalving.Spatial + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +lemma allowed_disjoint_in_gap (μ : Measure I) [NullSingletonClass μ] + (K : Window) (Q : Point ≃L[ℝ] Point) (g : Subwindows K → Point →L[ℝ] ℝ) + (hind : ∀ J : Subwindows K, μ (carrier J.val) ≠ 0 → + ∃ i j : Subwindows K, carrier i.val ⊆ carrier J.val ∧ + carrier j.val ⊆ carrier J.val ∧ + Function.Injective (fun v : Point => (g i v,g j v))) + {s t : I} (hs : s∈Ioo (lower K) (upper K)) (ht : t∈Ioo (lower K) (upper K)) + (hgap : μ (Ioo s t) ≠ 0) : + Disjoint (Directions.allowed Q g (fun i => (lower i.val:ℝ)) (fun i => (upper i.val:ℝ)) s) + (Directions.allowed Q g (fun i => (lower i.val:ℝ)) (fun i => (upper i.val:ℝ)) t) := by + obtain ⟨J,hsJ,hJt,hJ⟩ := exists_positive_inside μ hgap + have hJK := carrier_subset_of_inside (hs.1.trans hsJ) (hJt.trans ht.2) + obtain ⟨i,j,hi,hj,hij⟩ := hind ⟨J,hJK⟩ hJ + exact Directions.allowed_disjoint Q g _ _ i j + (hsJ.trans_le (endpoints_of_subset hi).1) ((endpoints_of_subset hi).2.trans_lt hJt) + (hsJ.trans_le (endpoints_of_subset hj).1) ((endpoints_of_subset hj).2.trans_lt hJt) hij + +lemma pointwise_radial (F : ℕ → Configuration) (hR : Tendsto (fun n => (F n).R) atTop atTop) + {K A B : Window} (hAB : Before A B) (hKA : Before K A) (hKB : Before K B) + (hA : ∀ n, 0 < length (F n).R A) (hB : ∀ n, 0 < length (F n).R B) + (G : Subwindows K → Point → I) + (hjoint : ∀ i p, ContinuousAt (G i) p → Tendsto + (fun q : ℕ × Point => (F q.1).extendedRank true A B i.val q.2) + (atTop ×ˢ 𝓝 p) (𝓝 (G i p))) + (hGaed : ∀ i, ∀ᵐ p ∂(volume : Measure Point), DifferentiableAt ℝ (fun x => (G i x : ℝ)) p) + {p : Point} (hp : p∈Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (hd : ∀ i, DifferentiableAt ℝ (fun x => (G i x : ℝ)) p) + (μ : Measure I) [NullSingletonClass μ] (hpos : μ (carrier K)≠0) + (hind : ∀ J : Subwindows K, μ (carrier J.val) ≠ 0 → + ∃ i j : Subwindows K, carrier i.val ⊆ carrier J.val ∧ + carrier j.val ⊆ carrier J.val ∧ + Function.Injective (fun v : Point => + ((fderiv ℝ (fun x => (G i x : ℝ)) p) v,(fderiv ℝ (fun x => (G j x : ℝ)) p) v))) + (t : Fin 3 → I) (ht : ∀ i, t i∈Ioo (lower K) (upper K)) + (htgap : ∀ i j, i] (0:ℝ), ∀ᶠ n in atTop, + RadialCompare (fun x => L n (((F n).rankChart hAB (hA n) (hB n)).symm x)) p h C₀ T := by + let : Nonempty (Subwindows K) := ⟨⟨K,Subset.rfl⟩⟩ + let D := fun i : Subwindows K => fderiv ℝ (fun x => (G i x : ℝ)) p + have hC (i : Subwindows K) : Before i.val A ∧ Before i.val B := + ⟨(endpoints_of_subset i.property).2.trans hKA,(endpoints_of_subset i.property).2.trans hKB⟩ + have hne (t : I) (ht : t∈Ioo (lower K) (upper K)) := + actual_allowed_nonempty F hR hAB (fun i : Subwindows K => i.val) hC G hjoint hGaed hp hd + t (ht.2.le.trans hKA) (ht.2.le.trans hKB) + obtain ⟨τ₁,τ₂,τ₃,z₁,z₂,z₃,hτ₁,hτ₂,hτ₃,h12,h23,hz₁,hz₂,hz₃,hd12,hd23,hd13⟩ := + three_directions_of_independent μ K hpos reflectFirst D hne hind + obtain ⟨B',d,_,hB'⟩ := singleton_target_frame z₁ z₂ z₃ hd12 hd23 hd13 + let S := fun j => Directions.allowed reflectFirst D (fun i => (lower i.val:ℝ)) + (fun i => (upper i.val:ℝ)) (t j) + have hdis (i j : Fin 3) (hij : i≠j) : Disjoint (S i) (S j) := by + rcases lt_or_gt_of_ne hij with h | h + · exact allowed_disjoint_in_gap μ K reflectFirst D hind (ht i) (ht j) (htgap i j h) + · exact (allowed_disjoint_in_gap μ K reflectFirst D hind (ht j) (ht i) (htgap j i h)).symm + obtain ⟨ε,hε,hcond⟩ := exists_frameCondition B' S + (fun j => Directions.allowed_closed _ _ _ _ _) (fun _ _ hx => hx.1) hdis v hv + let C₀ : ℝ := (‖B'.toContinuousLinearMap‖+1)/(ε/‖B'.symm.toContinuousLinearMap‖) + have hl : 0<ε/‖B'.symm.toContinuousLinearMap‖ := div_pos hε (equiv_opNorm_pos _) + have hC₀ : 0 i.val) hC + (fun i => eventually_length_pos _ hR i.val) D (fun i => (G i p:ℝ)) p hp + (fun i R hR ε hε => rank_firstOrder_filter F A B i.val (G i) (hjoint i) (hGaed i) (hd i) hR hε) + τ₁ τ₂ τ₃ h12 h23 + (fun i => ?_) (fun i => ?_) (foliationTriple z₁ z₂ z₃) (fun i => ?_) B' d hB' L t + (fun i => (ht i).2.le.trans hKA) (fun i => (ht i).2.le.trans hKB) v ε hε hcond hL C₀ + · dsimp [C₀]; rw [div_mul_cancel₀ _ hl.ne']; linarith + · cases i <;> first | exact hτ₁.2.le.trans hKA | exact hτ₂.2.le.trans hKA | exact hτ₃.2.le.trans hKA + · cases i <;> first | exact hτ₁.2.le.trans hKB | exact hτ₂.2.le.trans hKB | exact hτ₃.2.le.trans hKB + · cases i <;> first | exact hz₁ | exact hz₂ | exact hz₃ + +end PlanarHalving.RankLimits + +namespace PlanarHalving.TimeWindows +open Set Filter MeasureTheory +open scoped Topology unitInterval + +lemma exists_two_positive_inside (μ : Measure I) [NullSingletonClass μ] + (K : Window) (hpos : μ (carrier K)≠0) : + ∃ J H : Window, lower K dsimp [CommonChoice.time] + · exact ⟨h.1,(lower_lt_upper q.val.1).trans (h.2.1.trans ((lower_lt_upper q.val.2.1).trans h.2.2.1))⟩ + · exact ⟨h.1.trans (lower_lt_upper q.val.1),h.2.1.trans ((lower_lt_upper q.val.2.1).trans h.2.2.1)⟩ + · exact ⟨h.1.trans ((lower_lt_upper q.val.1).trans (h.2.1.trans (lower_lt_upper q.val.2.1))),h.2.2.1⟩ + +lemma CommonChoice.time_strictMono {K : Window} (q : CommonChoice K) : StrictMono q.time := by + apply Fin.strictMono_iff_lt_succ.mpr + intro i + fin_cases i <;> dsimp [CommonChoice.time] + · exact lower_lt_upper q.val.1 + · exact q.property.2.1.trans (lower_lt_upper q.val.2.1) + +lemma CommonChoice.positive_gaps {K : Window} (q : CommonChoice K) + (μ : Measure I) [NullSingletonClass μ] + (hJ : μ (carrier q.val.1)≠0) (hH : μ (carrier q.val.2.1)≠0) : + ∀ i j, i fin_cases j + all_goals try (norm_num at hij) + all_goals dsimp [CommonChoice.time] + · exact hj + · apply ne_of_gt (lt_of_lt_of_le (pos_iff_ne_zero.mpr hj) (measure_mono ?_)) + exact Ioo_subset_Ioo_right ((q.property.2.1.trans (lower_lt_upper q.val.2.1)).le) + · apply ne_of_gt (lt_of_lt_of_le (pos_iff_ne_zero.mpr hh) (measure_mono ?_)) + exact Ioo_subset_Ioo_left q.property.2.1.le + +lemma exists_commonChoice (μ : Measure I) [NullSingletonClass μ] + (K : Window) (hpos : μ (carrier K)≠0) : + ∃ q : CommonChoice K, μ (carrier q.val.1)≠0 ∧ + μ (carrier q.val.2.1)≠0 ∧ μ (carrier q.val.2.2)≠0 := by + obtain ⟨J,H,hJ1,hJH,hH2,hJ,hH⟩ := exists_two_positive_inside μ K hpos + have hJi : μ (Ioo (lower J) (upper J))≠0 := by rwa [measure_interior_eq] + obtain ⟨K₀,hK1,hK2,hK⟩ := exists_positive_inside μ hJi + exact ⟨⟨(J,H,K₀),hJ1,hJH,hH2,hK1,hK2⟩,hJ,hH,hK⟩ + +end PlanarHalving.TimeWindows + +namespace PlanarHalving.Limits +open Set MeasureTheory + +lemma positive_countable_selection {X ι : Type*} [MeasurableSpace X] [Countable ι] + (μ : Measure X) (T : Set X) (hTm : MeasurableSet T) (hT : μ T≠0) (E : ι → Set X) + (hcover : ∀ᵐ x ∂μ.restrict T, ∃ i, x∈E i) : + ∃ i, μ (T∩E i)≠0 := by + by_contra hn + have hn' : ∀ i, μ (T∩E i)=0 := by simpa only [not_exists,not_not] using hn + have hzero : μ (⋃ i, T∩E i)=0 := measure_iUnion_null hn' + have hnull : ∀ᵐ x ∂μ.restrict T, x∉⋃ i, E i := by + apply (ae_restrict_iff' hTm).mpr + rw [ae_iff] + convert hzero using 1 + congr 1 + ext x + simp only [mem_ofPred_eq,Classical.not_imp,not_not,mem_iUnion,mem_inter_iff] + aesop + have he : ∀ᵐ x ∂μ.restrict T, False := by + filter_upwards [hcover,hnull] with x hx hn + exact hn (mem_iUnion.mpr hx) + have hh : μ.restrict T univ=0 := by simpa only [ae_iff,not_false_eq_true,ofPred_true] using he + exact hT (by simpa only [Measure.restrict_apply_univ] using hh) + +end PlanarHalving.Limits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Packing.lean b/lean/OAI/Combinatorics/HalvingLines/Packing.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab11bd8d209153549c6c13d5038f76bf163b7f17 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Packing.lean @@ -0,0 +1,475 @@ +import OAI.Combinatorics.HalvingLines.ActivityRetention + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows Zoom +open scoped Topology unitInterval + +noncomputable def commonDirection : Fin 3 → Point := ![(1,0),(1,1),(0,1)] + +lemma commonDirection_independent (i j : Fin 3) (h : i≠j) : + detPair (commonDirection i) (commonDirection j)≠0 := by + fin_cases i <;> fin_cases j <;> norm_num [commonDirection,detPair] at * + +lemma common_frame (F : ℕ → Configuration) {K : Window} (q : CommonChoice K) + (h12 : ∀ n, (F n).timeSlope (q.time 0)<(F n).timeSlope (q.time 1)) + (h23 : ∀ n, (F n).timeSlope (q.time 1)<(F n).timeSlope (q.time 2)) : + ∃ E : ℕ → Point ≃L[ℝ] Point, + (∀ n i, detPair ((E n).symm (1,(F n).timeSlope (q.time i))) (commonDirection i)=0) ∧ + ∀ n, ∃ a b l u : ℝ, 0 slope_frame (h12 n) (h23 n) + refine ⟨E,?_,?_⟩ + · intro n i + have h1' : (E n).symm (1,(F n).timeSlope (q.time 0))=(a n)⁻¹ • (1,0) := by + apply (E n).injective + rw [(E n).apply_symm_apply,map_smul,h1,smul_smul,inv_mul_cancel₀ (ha n).ne',one_smul] + have h2' : (E n).symm (1,(F n).timeSlope (q.time 2))=(b n)⁻¹ • (0,1) := by + apply (E n).injective + rw [(E n).apply_symm_apply,map_smul,h2,smul_smul,inv_mul_cancel₀ (hb n).ne',one_smul] + have h3' : (E n).symm (1,(F n).timeSlope (q.time 1))=(1,1) := by + rw [←h3,(E n).symm_apply_apply] + fin_cases i + · change detPair ((E n).symm (1,(F n).timeSlope (q.time 0))) (1,0)=0 + rw [h1']; simp [detPair] + · change detPair ((E n).symm (1,(F n).timeSlope (q.time 1))) (1,1)=0 + rw [h3']; simp [detPair] + · change detPair ((E n).symm (1,(F n).timeSlope (q.time 2))) (0,1)=0 + rw [h2']; simp [detPair] + · intro n + refine ⟨a n,b n,_,_,ha n,hb n,(h12 n).trans (h23 n),h1 n,h2 n,?_⟩ + intro i + constructor + · exact ((F n).timeSlope_before (J:=q.val.2.2) q.property.2.2.2.1.le).trans + (((F n).system.timeWindow q.val.2.2).increasing.monotone (Fin.zero_le i)) + · apply (((F n).system.timeWindow q.val.2.2).increasing.monotone (Fin.le_last i)).trans + exact (F n).timeSlope_after (J:=q.val.2.2) + (q.property.2.2.2.2.trans (q.property.2.1.trans (lower_lt_upper q.val.2.1))).le + +noncomputable def commonChart (F : Configuration) {A B : Window} (hAB : Before A B) + (hA : 0 (F n).R) atTop atTop) + (hM : Tendsto (fun n => (F n).a*(F n).n) atTop atTop) + {C : ℝ} (hC : 0≤C) + (hcoeff : ∀ n, 4608*((F n).a:ℝ)^2*(F n).n^4 / (((F n).R:ℝ)*(F n).a^2)^3≤C) + (herror : Tendsto (fun n => 13824*((F n).n:ℝ)^3 / (((F n).R:ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n:ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) + {K A B : Window} (hAB : Before A B) (hKA : Before K A) (hKB : Before K B) + (hA : ∀ n, 0 (F q.1).extendedRank true A B i.val q.2) + (atTop ×ˢ 𝓝 p) (𝓝 (G i p))) + (hGaed : ∀ i, ∀ᵐ p ∂(volume : Measure Point), DifferentiableAt ℝ (fun x => (G i x:ℝ)) p) + (hid : ∀ i z, z∈(L.points:Measure Labels).support → + ContinuousAt (G i) (pairCoordinates true A B z) → z i.val=G i (pairCoordinates true A B z)) + (ν : Measure Labels) (he : ν≪(L.edge:Measure Labels)) (hp : ν≪(L.points:Measure Labels)) + (hproj : ν.map (pairCoordinates true A B)≪volume) + (q : CommonChoice K) + (hpos : ∀ᵐ z ∂ν, L.conditional z (carrier K)≠0 ∧ z∈commonSet L q) + (E : ℕ → Point ≃L[ℝ] Point) + (hE : ∀ n i, detPair ((E n).symm (1,(F n).timeSlope (q.time i))) (commonDirection i)=0) : + ∀ᵐ z ∂ν, pairCoordinates true A B z∈Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0 ∧ + ∃ C₀ : ℝ, 0] (0:ℝ), ∀ᶠ n in atTop, + RadialCompare (commonChart (F n) hAB (hA n) (hB n) (E n)).symm + (pairCoordinates true A B z) r C₀ T := by + have hreg := h.rank_regular_ae ν hp hproj G hGaed hid + have hind := he.ae_le (h.rank_independent_ae (A:=A) (B:=B) emb hR hM hC hcoeff herror hshort G) + have hna := he.ae_le (h.conditional_nullSingleton emb hR hC hcoeff herror) + filter_upwards [hreg,hind,hna,hpos,pairCoordinates_interior_ae hproj] with z hz hi hn hpos hzp + let := hn + refine ⟨hzp,?_⟩ + have h := pointwise_radial F hR hAB hKA hKB hA hB G hjoint hGaed hzp + (fun i => (hz i).1) (L.conditional z) hpos.1 (fun J hJ => by + obtain ⟨i,j,hi,hj,_,hij⟩ := hi hz J hJ + exact ⟨i,j,hi,hj,hij⟩) q.time q.time_mem + (q.positive_gaps (L.conditional z) hpos.2.1 hpos.2.2.1) + (fun n => (E n).symm) commonDirection commonDirection_independent hE + exact h + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows Zoom Spatial Enhancement Boundary +open scoped Topology unitInterval + +lemma normalized_commonChart (F : Configuration) {A B : Window} (hAB : Before A B) + (hA : 0 f q.1 q.2) + (atTop ×ˢ 𝓝 (p:Point)) (𝓝 (l p))) : + ∀ z∈(μ:Measure (X×Cube)).support, ∀ hz : z.1∈G, + z.2=encode (l ⟨π z.1,mem_image_of_mem π hz⟩) := by + intro z hz hG + apply support_spatial_graph hμ π hπ (f∘τ) + (Filter.Eventually.of_forall (fun n => hid (τ n))) G l _ hz hG + intro p + exact (hjoint p).comp (hτ.tendsto_atTop.prodMap tendsto_id) + +lemma Converges.spatial_impossible {F : ℕ → Configuration} {L : Data} (hF : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (emb : ∀ n, (F n).SweepEmbedding) + {C : ℝ} (hC : 0≤C) + (hcoeff : ∀ n, 4608*((F n).a:ℝ)^2*(F n).n^4 / (((F n).R:ℝ)*(F n).a^2)^3≤C) + (herror : Tendsto (fun n => 13824*((F n).n:ℝ)^3 / (((F n).R:ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (J : Window) {A B : Window} (hAB : Before A B) + (hA : ∀ n, 0] (0:ℝ), ∀ᶠ n in atTop, + RadialCompare (commonChart (F n) hAB (hA n) (hB n) (E n)).symm + (pairCoordinates true A B z) r C₀ Q) : False := by + let π := pairCoordinates true A B + let f := fun n => commonChart (F n) hAB (hA n) (hB n) (E n) + obtain ⟨G,hG,hGT,hGp,m,hdensity,p₀,U,hU,φ,l,c,hc,hφ,hl,hjoint,hsep⟩ := + positive_spatial_witness (L.points:Measure Labels) (L.edgeWindow J:Measure Labels) + T hT hTp π (continuous_pairCoordinates true A B).measurable hac f + (fun n => commonChart_source _ _ _ _ _) (fun n => commonChart_target _ _ _ _ _) hrad + let o := fun n => ((F n).rankChart hAB (hA n) (hB n)).symm p₀ + let ψ := fun n => physical (E n) (o n) (U n)⁻¹ + obtain ⟨ρ,M,hρ,hM,hprojection⟩ := Enhancement.subsequence (hF.subseq hφ) (fun n => ψ (φ n)) + have hgraph : ∀ z∈(M .point:Measure Space).support, ∀ hz : z.1∈G, + z.2=encode (l ⟨π z.1,mem_image_of_mem π hz⟩) := + support_graph_subseq (μs:=fun n => Enhancement.points (F (φ n)) (ψ (φ n))) hρ + (hM .point) π (continuous_pairCoordinates true A B) + (fun n => (normalizeChart (f (φ n)) p₀ (U (φ n)) (hU (φ n)).ne').symm) + (fun n => normalized_points_graph (F (φ n)) hAB (hA _) (hB _) (E _) p₀ (hU _).ne') + G l hjoint + have hmap : (M .point:Measure Space).map Prod.fst=(L.points:Measure Labels) := by + rw [← FiniteMeasure.toMeasure_map] + exact congrArg FiniteMeasure.toMeasure (hprojection .point) + obtain ⟨hH,hbounded,D,hD,hdisk⟩ := support_lift_disk (M .point:Measure Space) G hG π + (continuous_pairCoordinates true A B).measurable l hc (by rwa [hmap]) hgraph hl hsep + have hz := enhanced_boundary_zero ((hF.subseq hφ).subseq hρ) + ((hR.comp hφ.tendsto_atTop).comp hρ.tendsto_atTop) (fun n => emb (φ (ρ n))) + hC (fun n => hcoeff (φ (ρ n))) ((herror.comp hφ.tendsto_atTop).comp hρ.tendsto_atTop) + J (fun n => E (φ (ρ n))) (fun n => o (φ (ρ n))) (fun n => (U (φ (ρ n)))⁻¹) + (fun n => inv_pos.mpr (hU _)) (fun n => hframe (φ (ρ n))) hM hprojection G hG + (fun z hz => ⟨hbounded z hz,by rw [hgraph z hz.2 hz.1,decode_encode]⟩) hD hdisk + have hz' : L.edgeWindow J G=0 := NNReal.coe_injective hz + apply hGp + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,hz',ENNReal.coe_zero] + +end PlanarHalving.RankLimits +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows Zoom Spatial Enhancement Boundary +open scoped Topology unitInterval + +lemma common_finite_eventually (F : ℕ → Configuration) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + (A B : Window) {K : Window} (q : CommonChoice K) : + ∀ᶠ n in atTop, 0 f z.1 z.2) (atTop ×ˢ 𝓝 p) (𝓝 y)) (N : ℕ) : + Tendsto (fun z : ℕ × X => f (z.1+N) z.2) (atTop ×ˢ 𝓝 p) (𝓝 y) := + h.comp ((tendsto_add_atTop_nat N).prodMap tendsto_id) + +lemma Converges.analytic_ready {F : ℕ → Configuration} {L : Data} (hF : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + {K A B : Window} (hAB : Before A B) (hKA : Before K A) (hKB : Before K B) + (q : CommonChoice K) : + ∃ (φ : ℕ → ℕ) (G : Subwindows K → Point → I), StrictMono φ ∧ + (∀ n, 0 (G i x:ℝ)) p) ∧ + (∀ i z, z∈(L.points:Measure Labels).support → + ContinuousAt (G i) (pairCoordinates true A B z) → z i.val=G i (pairCoordinates true A B z)) ∧ + ∀ i p, ContinuousAt (G i) p → Tendsto + (fun z : ℕ × Point => (F (φ z.1)).extendedRank true A B i.val z.2) + (atTop ×ˢ 𝓝 p) (𝓝 (G i p)) := by + have hC (i : Subwindows K) : Before i.val A ∧ Before i.val B := + ⟨(endpoints_of_subset i.property).2.trans hKA,(endpoints_of_subset i.property).2.trans hKB⟩ + obtain ⟨φ,G,hφ,_,hGaed,hid,hjoint⟩ := hF.rank_analytic hR true hAB + (fun i : Subwindows K => i.val) (fun i => hC i) + have hR' : Tendsto (fun n => (F (φ n)).R) atTop atTop := hR.comp hφ.tendsto_atTop + have he := common_finite_eventually (F∘φ) hR' A B q + obtain ⟨N,hN⟩ := eventually_atTop.mp he + refine ⟨fun n => φ (n+N),G,(fun _ _ h => hφ (Nat.add_lt_add_right h N)), + (fun n => hN (n+N) (Nat.le_add_left N n)),hGaed,hid,?_⟩ + intro i p hp + exact joint_shift (fun n => (F (φ n)).extendedRank true A B i.val) (hjoint i p hp) N + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows Zoom Spatial Enhancement Boundary +open scoped Topology unitInterval + +lemma Converges.impossible {F : ℕ → Configuration} {L : Data} (hF : Converges F L) + (emb : ∀ n, (F n).SweepEmbedding) (hR : Tendsto (fun n => (F n).R) atTop atTop) + (hM : Tendsto (fun n => (F n).a*(F n).n) atTop atTop) + {C : ℝ} (hC : 0≤C) + (hcoeff : ∀ n, 4608*((F n).a:ℝ)^2*(F n).n^4 / (((F n).R:ℝ)*(F n).a^2)^3≤C) + (herror : Tendsto (fun n => 13824*((F n).n:ℝ)^3 / (((F n).R:ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (hshort : Tendsto (fun n => ((F n).n:ℝ)/((F n).R*(F n).a)) atTop (𝓝 0)) : False := by + obtain ⟨K,H,A,B,T,hKH,hAH,hBH,hAB,hT,hTp,hpos,hcross,hpts⟩ := + hF.positive_part emb hR hC hcoeff herror hshort + obtain ⟨q,V,hV,hVT,hcommon,hVp,hVle⟩ := hF.common_positive hR K + (hF.conditional_nullSingleton emb hR hC hcoeff herror) hT hTp (fun z hz => (hpos z hz).1) + let ν := (L.edgeWindow q.val.2.2:Measure Labels).restrict V + have he : ν≪(L.edge:Measure Labels) := + Measure.absolutelyContinuous_of_le (hVle.trans Measure.restrict_le_self) + have hp : ν≪(L.points:Measure Labels) := (Measure.absolutelyContinuous_of_le hVle).trans hpts + have hproj : ν.map (pairCoordinates true A B)≪volume := + (((Measure.absolutelyContinuous_of_le hVle).trans hcross).map + (continuous_pairCoordinates true A B).measurable).trans (hF.crossing_signed_projection hR hM true hAB) + have hgood : ∀ᵐ z ∂ν, L.conditional z (carrier K)≠0 ∧ z∈commonSet L q := by + filter_upwards [ae_restrict_mem hV] with z hz + exact ⟨(hpos z (hVT hz)).1,hcommon z hz⟩ + have hKA : Before K A := hKH.2.1.le.trans (endpoints_of_subset hAH).1 + have hKB : Before K B := hKH.2.1.le.trans (endpoints_of_subset hBH).1 + obtain ⟨φ,G,hφ,hfinite,hGaed,hid,hjoint⟩ := hF.analytic_ready hR hAB hKA hKB q + have hF' : Converges (F∘φ) L := hF.subseq hφ + have hR' : Tendsto (fun n => (F (φ n)).R) atTop atTop := hR.comp hφ.tendsto_atTop + obtain ⟨E,hE,hframe⟩ := common_frame (F∘φ) q + (fun n => (hfinite n).2.2.1) (fun n => (hfinite n).2.2.2) + exact hF'.spatial_impossible hR' (fun n => emb (φ n)) hC (fun n => hcoeff (φ n)) + (herror.comp hφ.tendsto_atTop) q.val.2.2 hAB (fun n => (hfinite n).1) + (fun n => (hfinite n).2.1) E hframe V hV hVp hproj + (hF'.radial_ae (fun n => emb (φ n)) hR' (hM.comp hφ.tendsto_atTop) hC + (fun n => hcoeff (φ n)) (herror.comp hφ.tendsto_atTop) (hshort.comp hφ.tendsto_atTop) + hAB hKA hKB (fun n => (hfinite n).1) (fun n => (hfinite n).2.1) + G hjoint hGaed hid ν he hp hproj q hgood E hE) + +end PlanarHalving.RankLimits +namespace PlanarHalving.RankLimits +open Filter +open scoped Topology + +lemma normalized_sequence_impossible (F : ℕ → Configuration) + (emb : ∀ n, (F n).SweepEmbedding) {c : ℝ} (hc : 0 ((F n).n:ℝ)/(F n).a) atTop atTop) : False := by + obtain ⟨φ,L,hφ,hF⟩ := subsequence F + have hnear' : ∀ n, c*((F (φ n)).n:ℝ)^4≤((F (φ n)).R:ℝ)^3*((F (φ n)).a:ℝ)^4 := + fun n => hnear (φ n) + have hq' := hq.comp hφ.tendsto_atTop + have hs := normalization_sizes_atTop hc hnear' hq' + exact hF.impossible (fun n => emb (φ n)) hs.2.2 hs.2.1 (by positivity : 0≤4608/c) + (fun n => (F (φ n)).normalization_coefficient hc (hnear' n)) + (sparse_error_tendsto_zero hc hnear' hq') (short_ratio_tendsto_zero hc hnear' hq') + +theorem uniform_batch_saving {c : ℝ} (hc : 0 ((F m).n:ℝ)/(F m).a) atTop atTop := by + apply tendsto_atTop_mono hq + exact tendsto_atTop_add_const_right _ 1 tendsto_natCast_atTop_atTop + exact normalized_sequence_impossible F (fun n => (he n).some) hc hn hlim + +end PlanarHalving.RankLimits +namespace PlanarHalving.Sweep +open Set RankLimits + +noncomputable def greedyConfiguration {n k : ℕ} {P : Fin n → Point} + (hP : Generic P) (hk : k≤n) (a : ℕ) (ha : 0 rfl + +lemma distance_saving {c : ℝ} (hc : 0 ∃ hk' : k+c≤n, c≤(states P hP hk').distance p.1 p.2) + let B := C\A + have hA : A⊆C := Finset.filter_subset _ _ + have hB : B⊆C := Finset.sdiff_subset + have hbound (D : Finset _) (hD : D⊆C) (r : ℕ) + (hd : ∀ p∈D, ∃ hr : r≤n, c≤(states P hP hr).distance p.1 p.2) : + (D.card : ℝ)^3*(c : ℝ)^4≤16*δ*(n : ℝ)^4 := by + by_cases hne : D.Nonempty + · obtain ⟨p,hp⟩ := hne + obtain ⟨hr,_⟩ := hd p hp + apply hdist P hP hr hc (hq.trans (div_le_div_of_nonneg_left (by positivity) (by exact_mod_cast hc) (by exact_mod_cast (show c≤b by dsimp [c];omega)))) D + · exact fun p hp q hq hpq => hC p (hD hp) q (hD hq) hpq + · exact fun p hp => horder p (hD hp) + · intro p hp + obtain ⟨hr',hh⟩ := hd p hp + exact hh + · simp only [Finset.not_nonempty_iff_eq_empty.mp hne,Finset.card_empty,Nat.cast_zero,zero_pow (by omega : (3:ℕ)≠0),zero_mul] + positivity + have hAb := hbound A hA (k+c) (fun p hp => (Finset.mem_filter.mp hp).2) + have hBb := hbound B hB (k-c) (fun p hp => by + have hpC := hB hp + have hh := states_intervalActivity_distance P hP hk (horder p hpC) + ((show 4*c≤b from Nat.mul_div_le b 4).trans (hactivity p hpC)) + rcases hh with hh | ⟨hr,_,hh⟩ + · exact False.elim ((Finset.mem_sdiff.mp hp).2 (Finset.mem_filter.mpr ⟨hpC,hh⟩)) + · exact ⟨hr,hh⟩) + have hcard : (C.card : ℝ)=(A.card : ℝ)+(B.card : ℝ) := by + exact_mod_cast (by simpa only [B,Nat.add_comm] using (Finset.card_sdiff_add_card_eq_card hA).symm : C.card=A.card+B.card) + have hsum := mul_le_mul_of_nonneg_right (cube_add_le (show (0:ℝ)≤A.card by positivity) (show (0:ℝ)≤B.card by positivity)) (show (0:ℝ)≤(c : ℝ)^4 by positivity) + rw [← hcard] at hsum + have hcub : (C.card : ℝ)^3*(c : ℝ)^4≤128*δ*(n : ℝ)^4 := by nlinarith [hAb,hBb] + calc + _ ≤ (C.card : ℝ)^3*(8*(c : ℝ))^4 := by gcongr + _ = 4096*((C.card : ℝ)^3*(c : ℝ)^4) := by ring + _ ≤ 4096*(128*δ*(n : ℝ)^4) := mul_le_mul_of_nonneg_left hcub (by norm_num) + _ ≤ _ := by nlinarith [mul_nonneg hδ.le (sq_nonneg ((n : ℝ)^2))] + · have hd := hdist P hP hk (by omega : 0<1) (by simpa using hq.trans (div_le_self (by positivity) (by exact_mod_cast hb))) C hC horder + (fun p hp => S.intervalActivity_pos_distance (horder p hp) (lt_of_lt_of_le hb (hactivity p hp))) + norm_num at hd + have hbLe : (b : ℝ)≤3 := by exact_mod_cast (by omega : b≤3) + calc + _ ≤ (C.card : ℝ)^3*3^4 := by gcongr + _ ≤ 16*δ*(n : ℝ)^4*3^4 := mul_le_mul_of_nonneg_right hd (by norm_num) + _ ≤ _ := by nlinarith [mul_nonneg hδ.le (sq_nonneg ((n : ℝ)^2))] + +end PlanarHalving.Sweep + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Partition.lean b/lean/OAI/Combinatorics/HalvingLines/Partition.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9d09c3984a5df2a96c5687037616ff29087e2cb --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Partition.lean @@ -0,0 +1,545 @@ +import OAI.Combinatorics.HalvingLines.AtomicBounds + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology +variable {X ι : Type*} [MeasurableSpace X] + +lemma probability_overlap_bound (μ : FiniteMeasure X) (S : Finset ι) (p : ι → X → ℝ) + (hp : ∀ i ∈ S, Measurable (p i)) (hp0 : ∀ i ∈ S, ∀ z, 0 ≤ p i z) + (hsum : ∀ z, ∑ i ∈ S, p i z ≤ 1) {β : ℝ} (hβ : 0 < β) : + ∑ i ∈ S, (μ {z | β < p i z} : ℝ) ≤ (μ.mass : ℝ)/β := by + classical + let A : ι → Set X := fun i => {z | β < p i z} + have hm i (hi : i ∈ S) : MeasurableSet (A i) := measurableSet_lt measurable_const (hp i hi) + have hInt i (hi : i ∈ S) : Integrable ((A i).indicator (fun _ : X => (1 : ℝ))) (μ : Measure X) := + (integrable_const 1).indicator (hm i hi) + have he i (hi : i ∈ S) : ∫ z, (A i).indicator (fun _ : X => (1 : ℝ)) z ∂(μ : Measure X) = + (μ (A i) : ℝ) := by + rw [integral_indicator_const 1 (hm i hi)] + simp + have hbound (z : X) : (∑ i ∈ S, (A i).indicator (fun _ : X => (1 : ℝ)) z) ≤ 1/β := by + have hh : β*(∑ i ∈ S, (A i).indicator (fun _ : X => (1 : ℝ)) z) ≤ 1 := by + calc + _ = ∑ i ∈ S, β*(A i).indicator (fun _ : X => (1 : ℝ)) z := Finset.mul_sum .. + _ ≤ ∑ i ∈ S, p i z := by + apply Finset.sum_le_sum + intro i hi + by_cases hz : z ∈ A i + · simpa only [Set.indicator_of_mem hz,mul_one] using (show β < p i z from hz).le + · simpa only [Set.indicator_of_notMem hz,mul_zero] using hp0 i hi z + _ ≤ 1 := hsum z + exact (le_div_iff₀ hβ).mpr (by simpa only [mul_comm] using hh) + have hh := integral_mono (integrable_finsetSum S hInt) (integrable_const (1/β)) hbound + rw [integral_finsetSum S hInt] at hh + rw [Finset.sum_congr rfl he] at hh + simpa [integral_const,div_eq_mul_inv,FiniteMeasure.mass] using hh + +lemma finite_bad_cover_mass (μ : FiniteMeasure X) (S : Finset ι) (p : ι → X → ℝ) + (hp : ∀ i ∈ S, Measurable (p i)) (hp0 : ∀ i ∈ S, ∀ z, 0 ≤ p i z) + (hp1 : ∀ i ∈ S, ∀ z, p i z ≤ 1) {β : ℝ} + {B : Set X} (hB : MeasurableSet B) + (hcover : ∀ z ∈ B, ∃ i ∈ S, β < p i z) : + β*(μ B : ℝ) ≤ ∑ i ∈ S, ∫ z in {z | β < p i z}, p i z ∂(μ : Measure X) := by + classical + let A : ι → Set X := fun i => {z | β < p i z} + have hm i (hi : i ∈ S) : MeasurableSet (A i) := measurableSet_lt measurable_const (hp i hi) + have hInt i (hi : i ∈ S) : Integrable (p i) (μ : Measure X) := + (integrable_const (1 : ℝ)).mono' (hp i hi).aestronglyMeasurable + (Filter.Eventually.of_forall (fun z => by simpa only [Real.norm_eq_abs,abs_of_nonneg (hp0 i hi z)] using hp1 i hi z)) + have hInd i (hi : i ∈ S) := (hInt i hi).indicator (hm i hi) + have hpoint (z : X) : B.indicator (fun _ : X => β) z ≤ ∑ i ∈ S, (A i).indicator (p i) z := by + have hnn i (hi : i ∈ S) : 0 ≤ (A i).indicator (p i) z := by + exact Set.indicator_nonneg (fun x _ => hp0 i hi x) z + by_cases hz : z ∈ B + · obtain ⟨i,hi,hip⟩ := hcover z hz + rw [Set.indicator_of_mem hz] + calc + β ≤ (A i).indicator (p i) z := by rw [Set.indicator_of_mem (show z ∈ A i from hip)]; exact hip.le + _ ≤ ∑ i ∈ S, (A i).indicator (p i) z := Finset.single_le_sum hnn hi + · rw [Set.indicator_of_notMem hz] + exact Finset.sum_nonneg hnn + have hh := integral_mono ((integrable_const β).indicator hB) (integrable_finsetSum S hInd) hpoint + rw [integral_indicator_const β hB,integral_finsetSum S hInd] at hh + rw [Finset.sum_congr rfl (fun i hi => integral_indicator (hm i hi))] at hh + simpa [mul_comm] using hh + +end PlanarHalving.Limits + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology + +theorem ae_exists_partition_small {X ι : Type*} [MeasurableSpace X] + (lam μ : FiniteMeasure X) (S : ℕ → Finset ι) (p : ℕ → ι → X → ℝ) + (mu nu : ℕ → ι → FiniteMeasure X) (s : ℕ → ι → ℝ) (q : ℕ → ℝ) + {A H : ℝ} (hA : 0 ≤ A) + (hq : ∀ n, 0 < q n) (hqtop : Tendsto q atTop atTop) + (hcard : ∀ n, ((S n).card : ℝ) ≤ q n) + (hp : ∀ n i, i ∈ S n → Measurable (p n i)) + (hp0 : ∀ n i, i ∈ S n → ∀ z, 0 ≤ p n i z) + (hp1 : ∀ n i, i ∈ S n → ∀ z, p n i z ≤ 1) + (hsum : ∀ n z, ∑ i ∈ S n, p n i z ≤ 1) + (hs0 : ∀ n i, i ∈ S n → 0 ≤ s n i) + (hmu : ∀ n i, i ∈ S n → ∀ B, mu n i B ≤ μ B) + (hnu : ∀ n i, i ∈ S n → ∀ B, MeasurableSet B → + (nu n i B : ℝ) = ∫ z in B, p n i z ∂(lam : Measure X)) + (hnuMass : ∀ n i, i ∈ S n → ((nu n i).mass : ℝ) ≤ (q n)⁻¹) + (hmass : ∀ n i, i ∈ S n → ∀ B, MeasurableSet B → + (nu n i B : ℝ)^3 ≤ A*(s n i)^3*(mu n i B : ℝ)) + (htail : ∀ n u, 0 < u → ((S n |>.filter fun i => u < s n i).card : ℝ) ≤ + H*u^(-(4:ℝ)/3)) {β : ℝ} (hβ : 0 < β) : + ∀ᵐ z ∂(lam : Measure X), ∃ n, ∀ i ∈ S n, p n i z ≤ β := by + classical + let B : Set X := ⋂ n, ⋃ i ∈ S n, {z | β < p n i z} + have hm n i (hi : i ∈ S n) : MeasurableSet {z | β < p n i z} := + measurableSet_lt measurable_const (hp n i hi) + have hB : MeasurableSet B := by + apply MeasurableSet.iInter + intro n + exact (S n).finite_toSet.measurableSet_biUnion (fun i hi => hm n i hi) + have hcover n z (hz : z ∈ B) : ∃ i ∈ S n, β < p n i z := by + have hz' := mem_iInter.mp hz n + simpa only [mem_iUnion,mem_ofPred_eq,exists_prop] using hz' + have hz := persistent_mass_zero S + (fun n i => (nu n i {z | β < p n i z} : ℝ)) + (fun n i => (mu n i {z | β < p n i z} : ℝ)) s q + (L := β*(lam B : ℝ)) (A := A) (H := H) (U := (μ.mass : ℝ)/β) + (mul_nonneg hβ.le (NNReal.coe_nonneg _)) hA hq hqtop hcard + (fun _ _ _ => NNReal.coe_nonneg _) ?_ + (fun _ _ _ => NNReal.coe_nonneg _) hs0 ?_ ?_ htail ?_ + · have hzero : (lam B : ℝ) = 0 := (mul_eq_zero.mp hz).resolve_left hβ.ne' + have hzero' : (lam : Measure X) B = 0 := by + apply (measureReal_eq_zero_iff (measure_ne_top _ _)).mp + simpa using hzero + rw [ae_iff] + have he : {z | ¬ ∃ n, ∀ i ∈ S n, p n i z ≤ β} = B := by + ext z + simp only [mem_ofPred_eq,not_exists,not_forall,not_le,B,mem_iInter,mem_iUnion, + exists_prop] + rw [he] + exact hzero' + · intro n i hi + exact (show (nu n i {z | β < p n i z} : ℝ) ≤ ((nu n i).mass : ℝ) from + NNReal.coe_le_coe.mpr ((nu n i).apply_le_mass _)).trans (hnuMass n i hi) + · intro n i hi + exact hmass n i hi _ (hm n i hi) + · intro n + exact (Finset.sum_le_sum (fun i hi => NNReal.coe_le_coe.mpr (hmu n i hi _))).trans + (probability_overlap_bound μ (S n) (p n) (hp n) (hp0 n) (hsum n) hβ) + · intro n + have hc := finite_bad_cover_mass lam (S n) (p n) (hp n) (hp0 n) (hp1 n) hB (hcover n) + simpa only [Finset.sum_congr rfl (fun i hi => hnu n i hi _ (hm n i hi))] using hc + +end PlanarHalving.Limits + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter ProbabilityTheory + +lemma kernel_nullSingleton_of_cells {X T ι : Type*} [MeasurableSpace X] + [MeasurableSpace T] (lam : Measure X) (h : Kernel X T) [IsMarkovKernel h] + (S : ℕ → Finset ι) (cell : ℕ → ι → Set T) + (hcover : ∀ n t, ∃ i ∈ S n, t ∈ cell n i) + (hsmall : ∀ m : ℕ, ∀ᵐ z ∂lam, ∃ n, ∀ i ∈ S n, + (h z).real (cell n i) ≤ 1/((m : ℝ)+1)) : + ∀ᵐ z ∂lam, NullSingletonClass (h z) := by + have hh := (ae_all_iff.mpr hsmall) + filter_upwards [hh] with z hz + constructor + intro t + apply (measureReal_eq_zero_iff (measure_ne_top _ _)).mp + by_contra hpos + have htpos : 0 < (h z).real {t} := lt_of_le_of_ne (measureReal_nonneg) (Ne.symm hpos) + obtain ⟨m, hm⟩ := exists_nat_one_div_lt htpos + obtain ⟨n, hn⟩ := hz m + obtain ⟨i, hi, hit⟩ := hcover n t + have hh : (h z).real {t} ≤ (h z).real (cell n i) := + measureReal_mono (singleton_subset_iff.mpr hit) + linarith [hn i hi] + +end PlanarHalving.Limits +namespace PlanarHalving.UniformPartition +open MeasureTheory Set +open scoped unitInterval + +noncomputable def boundary (m : ℕ) [NeZero m] (i : Fin (m+1)) : I := + ⟨(i : ℝ)/(m : ℝ), by + have hm : (0 : ℝ) < m := Nat.cast_pos.mpr (NeZero.pos m) + constructor + · positivity + · apply (div_le_one hm).mpr + exact_mod_cast (Nat.le_of_lt_succ i.isLt)⟩ + +noncomputable def cell (m : ℕ) [NeZero m] (i : Fin m) : Set I := + if i.val+1=m then Icc (boundary m i.castSucc) (boundary m i.succ) + else Ico (boundary m i.castSucc) (boundary m i.succ) + +lemma cell_measurable (m : ℕ) [NeZero m] (i : Fin m) : MeasurableSet (cell m i) := by + unfold cell + split_ifs <;> measurability + +lemma cell_lower (m : ℕ) [NeZero m] (i : Fin m) {t : I} (ht : t ∈ cell m i) : + (i : ℝ)/(m : ℝ) ≤ (t : ℝ) := by + unfold cell at ht + split_ifs at ht <;> exact ht.1 + +lemma cell_upper (m : ℕ) [NeZero m] (i : Fin m) {t : I} (ht : t ∈ cell m i) : + (t : ℝ) ≤ ((i : ℝ)+1)/(m : ℝ) := by + unfold cell at ht + split_ifs at ht + · simpa [boundary] using (show (t : ℝ) ≤ (boundary m i.succ : ℝ) from ht.2) + · simpa [boundary] using (show (t : ℝ) ≤ (boundary m i.succ : ℝ) from ht.2.le) + +lemma cell_upper_lt (m : ℕ) [NeZero m] (i : Fin m) (hi : i.val+1≠m) + {t : I} (ht : t ∈ cell m i) : (t : ℝ) < ((i : ℝ)+1)/(m : ℝ) := by + rw [cell,ite_eq_right hi] at ht + simpa [boundary] using (show (t : ℝ) < (boundary m i.succ : ℝ) from ht.2) + +lemma cells_disjoint (m : ℕ) [NeZero m] : Pairwise (fun i j : Fin m => Disjoint (cell m i) (cell m j)) := by + have hh (i j : Fin m) (hlt : i.val < j.val) : Disjoint (cell m i) (cell m j) := by + apply Set.disjoint_left.mpr + intro t hti htj + have hm : (0 : ℝ) < m := Nat.cast_pos.mpr (NeZero.pos m) + have hu := cell_upper_lt m i (by omega) hti + have hl := cell_lower m j htj + have hij' : (i : ℝ)+1 ≤ (j : ℝ) := by exact_mod_cast hlt + have hc := div_le_div_of_nonneg_right hij' hm.le + linarith + intro i j hij + have hne : i.val ≠ j.val := fun h => hij (Fin.ext h) + rcases lt_or_gt_of_ne hne with h | h + · exact hh i j h + · exact (hh j i h).symm + +lemma mem_some_cell (m : ℕ) [NeZero m] (t : I) : ∃ i : Fin m, t ∈ cell m i := by + have hm : 0 < m := NeZero.pos m + have hm' : (0 : ℝ) < m := Nat.cast_pos.mpr hm + by_cases ht : (t : ℝ)=1 + · let i : Fin m := ⟨m-1, by omega⟩ + refine ⟨i, ?_⟩ + have hi : i.val+1=m := by dsimp [i]; omega + rw [cell,ite_eq_left hi] + constructor + · change (i : ℝ)/(m : ℝ) ≤ (t : ℝ) + rw [ht] + apply (div_le_one hm').mpr + exact_mod_cast i.isLt.le + · change (t : ℝ) ≤ ((i.val+1 : ℕ) : ℝ)/(m : ℝ) + rw [Nat.cast_add,Nat.cast_one,ht] + have he : (i : ℝ)+1=(m : ℝ) := by exact_mod_cast hi + rw [he,div_self hm'.ne'] + · have ht' : (t : ℝ)<1 := lt_of_le_of_ne t.property.2 ht + have hx : 0 ≤ (m : ℝ)*(t : ℝ) := mul_nonneg hm'.le t.property.1 + have hi : ⌊(m : ℝ)*(t : ℝ)⌋₊ < m := by + apply (Nat.floor_lt hx).mpr + nlinarith + let i : Fin m := ⟨⌊(m : ℝ)*(t : ℝ)⌋₊, hi⟩ + have hlo : (i : ℝ)/(m : ℝ) ≤ (t : ℝ) := by + apply (div_le_iff₀ hm').mpr + simpa [i,mul_comm] using Nat.floor_le hx + have hup : (t : ℝ) < ((i : ℝ)+1)/(m : ℝ) := by + apply (lt_div_iff₀ hm').mpr + simpa [i,mul_comm] using Nat.lt_floor_add_one ((m : ℝ)*(t : ℝ)) + refine ⟨i, ?_⟩ + unfold cell + split_ifs + · refine ⟨hlo, ?_⟩ + change (t : ℝ) ≤ ((i.val+1 : ℕ) : ℝ)/(m : ℝ) + simpa only [Nat.cast_add,Nat.cast_one] using hup.le + · refine ⟨hlo, ?_⟩ + change (t : ℝ) < ((i.val+1 : ℕ) : ℝ)/(m : ℝ) + simpa only [Nat.cast_add,Nat.cast_one] using hup + +lemma cells_cover (m : ℕ) [NeZero m] : (⋃ i : Fin m, cell m i) = univ := by + ext t + simp only [mem_iUnion,mem_univ,iff_true] + exact mem_some_cell m t + +lemma cell_volume (m : ℕ) [NeZero m] (i : Fin m) : + volume (cell m i) = ENNReal.ofReal (1/(m : ℝ)) := by + have he : ((boundary m i.succ : I) : ℝ) - ((boundary m i.castSucc : I) : ℝ) = + 1/(m : ℝ) := by simp [boundary]; ring + unfold cell + split_ifs + · rw [unitInterval.volume_Icc,he] + · rw [unitInterval.volume_Ico,he] + +lemma cell_diameter_bound (m : ℕ) [NeZero m] (i : Fin m) {s t : I} + (hs : s ∈ cell m i) (ht : t ∈ cell m i) : dist s t ≤ 1/(m : ℝ) := by + rw [Subtype.dist_eq,Real.dist_eq] + apply abs_le.mpr + have hs0 := cell_lower m i hs + have hs1 := cell_upper m i hs + have ht0 := cell_lower m i ht + have ht1 := cell_upper m i ht + have he : ((i : ℝ)+1)/(m : ℝ) = (i : ℝ)/(m : ℝ)+1/(m : ℝ) := by ring + rw [he] at hs1 ht1 + constructor <;> linarith + +end PlanarHalving.UniformPartition + +namespace PlanarHalving.UniformPartition +open MeasureTheory Set Filter +open scoped unitInterval Topology + +noncomputable def index (m : ℕ) [NeZero m] (t : I) : Fin m := + (mem_some_cell m t).choose + +lemma mem_cell_index (m : ℕ) [NeZero m] (t : I) : t ∈ cell m (index m t) := + (mem_some_cell m t).choose_spec + +lemma index_eq (m : ℕ) [NeZero m] (t : I) (i : Fin m) : index m t = i ↔ t ∈ cell m i := by + constructor + · intro h; rw [← h]; exact mem_cell_index m t + · intro ht + by_contra hne + exact Set.disjoint_left.mp (cells_disjoint m hne) (mem_cell_index m t) ht + +lemma index_measurable (m : ℕ) [NeZero m] : Measurable (index m) := by + apply measurable_to_countable' + intro i + have he : (index m) ⁻¹' {i} = cell m i := by ext t; exact index_eq m t i + rw [he] + exact cell_measurable m i + +noncomputable def grid (m : ℕ) [NeZero m] (t : I) : I := boundary m (index m t).castSucc + +lemma grid_measurable (m : ℕ) [NeZero m] : Measurable (grid m) := + (measurable_of_finite (fun i : Fin m => boundary m i.castSucc)).comp (index_measurable m) + +lemma dist_grid (m : ℕ) [NeZero m] (t : I) : dist (grid m t) t ≤ 1/(m : ℝ) := by + have ht := mem_cell_index m t + have hl := cell_lower m (index m t) ht + have hu := cell_upper m (index m t) ht + rw [Subtype.dist_eq,Real.dist_eq,abs_sub_comm] + change |(t : ℝ)-(index m t : ℝ)/(m : ℝ)| ≤ _ + rw [abs_of_nonneg (sub_nonneg.mpr hl)] + change (t : ℝ)-(index m t : ℝ)/(m : ℝ) ≤ 1/(m : ℝ) + have he : ((index m t : ℝ)+1)/(m : ℝ) = (index m t : ℝ)/(m : ℝ)+1/(m : ℝ) := by ring + rw [he] at hu + linarith + +lemma grid_tendsto (t : I) : Tendsto (fun n : ℕ => grid (n+1) t) atTop (𝓝 t) := by + apply tendsto_iff_dist_tendsto_zero.mpr + apply squeeze_zero (fun _ => dist_nonneg) (fun n => dist_grid (n+1) t) + simpa only [Nat.cast_add,Nat.cast_one] using tendsto_one_div_add_atTop_nhds_zero_nat + +lemma grid_pair_tendsto (t : I × I) : + Tendsto (fun n : ℕ => (grid (n+1) t.1,grid (n+1) t.2)) atTop (𝓝 t) := + (grid_tendsto t.1).prodMk_nhds (grid_tendsto t.2) + +lemma integral_partition {X ι : Type*} [MeasurableSpace X] [Fintype ι] + (μ : Measure X) [IsFiniteMeasure μ] (C : ι → Set X) + (hC : ∀ i, MeasurableSet (C i)) + (idx : X → ι) (hi : ∀ x i, idx x = i ↔ x ∈ C i) (v : ι → ℝ) : + ∫ x, v (idx x) ∂μ = ∑ i, μ.real (C i)*v i := by + classical + have he : (fun x => v (idx x)) = fun x => ∑ i, (C i).indicator (fun _ => v i) x := by + funext x + symm + rw [Finset.sum_eq_single (idx x)] + · exact Set.indicator_of_mem ((hi x (idx x)).mp rfl) _ + · intro j _ hj + rw [Set.indicator_of_notMem] + intro hx + exact hj ((hi x j).mpr hx).symm + · simp + rw [he,integral_finsetSum] + · apply Finset.sum_congr rfl + intro i _ + rw [integral_indicator_const _ (hC i)] + simp only [smul_eq_mul] + · intro i _ + exact (integrable_const (v i)).indicator (hC i) + +lemma integral_grid (m : ℕ) [NeZero m] (f : I → ℝ) : + ∫ t, f (grid m t) = (∑ i : Fin m, f (boundary m i.castSucc))/(m : ℝ) := by + rw [show (fun t => f (grid m t)) = fun t => + (fun i : Fin m => f (boundary m i.castSucc)) (index m t) from rfl] + rw [integral_partition volume (cell m) (cell_measurable m) + (index m) (index_eq m) (fun i : Fin m => f (boundary m i.castSucc))] + simp only [measureReal_def,cell_volume,ENNReal.toReal_ofReal (by positivity : 0 ≤ 1/(m : ℝ))] + rw [← Finset.mul_sum] + ring + +lemma integral_grid_pair (m : ℕ) [NeZero m] (f : I × I → ℝ) : + ∫ t : I × I, f (grid m t.1,grid m t.2) = + (∑ i : Fin m × Fin m, f (boundary m i.1.castSucc,boundary m i.2.castSucc))/(m : ℝ)^2 := by + let C : Fin m × Fin m → Set (I × I) := fun i => cell m i.1 ×ˢ cell m i.2 + have hC i : MeasurableSet (C i) := (cell_measurable m i.1).prod (cell_measurable m i.2) + let idx : I × I → Fin m × Fin m := fun t => (index m t.1,index m t.2) + have hi t i : idx t = i ↔ t ∈ C i := by + rcases i with ⟨i,j⟩ + simp only [idx,C,Prod.mk.injEq,index_eq,mem_prod] + change ∫ t, (fun i : Fin m × Fin m => f (boundary m i.1.castSucc,boundary m i.2.castSucc)) (idx t) = _ + rw [integral_partition volume C hC idx hi (fun i => f (boundary m i.1.castSucc,boundary m i.2.castSucc))] + have hv i : volume.real (C i) = 1/(m : ℝ)^2 := by + rw [measureReal_def] + change ((volume.prod volume) (cell m i.1 ×ˢ cell m i.2)).toReal = _ + rw [Measure.prod_prod,cell_volume,cell_volume,ENNReal.toReal_mul, + ENNReal.toReal_ofReal (by positivity : 0 ≤ 1/(m : ℝ))] + ring + simp_rw [hv] + rw [← Finset.mul_sum] + ring + +end PlanarHalving.UniformPartition + +namespace PlanarHalving.UniformPartition +open MeasureTheory Set Filter BoundedContinuousFunction +open scoped unitInterval Topology + +lemma grid_tendsto_seq (m : ℕ → ℕ) [∀ n, NeZero (m n)] (hm : Tendsto m atTop atTop) (t : I) : + Tendsto (fun n => grid (m n) t) atTop (𝓝 t) := by + apply tendsto_iff_dist_tendsto_zero.mpr + apply squeeze_zero (fun _ => dist_nonneg) (fun n => dist_grid (m n) t) + have hnat : Tendsto (fun n => (m n : ℝ)) atTop atTop := tendsto_natCast_atTop_atTop.comp hm + simpa only [one_div, Function.comp_def] using tendsto_inv_atTop_zero.comp hnat + +lemma riemann_tendsto (m : ℕ → ℕ) [∀ n, NeZero (m n)] (hm : Tendsto m atTop atTop) + (f : BoundedContinuousFunction (I × I) ℝ) : + Tendsto (fun n => (∑ i : Fin (m n) × Fin (m n), + f (boundary (m n) i.1.castSucc,boundary (m n) i.2.castSucc))/(m n : ℝ)^2) + atTop (𝓝 (∫ t : I × I, f t)) := by + simp_rw [← integral_grid_pair] + apply tendsto_integral_of_dominated_convergence (fun _ : I × I => ‖f‖) + · intro n + exact (f.continuous.measurable.comp + (((grid_measurable (m n)).comp measurable_fst).prodMk + ((grid_measurable (m n)).comp measurable_snd))).aestronglyMeasurable + · exact integrable_const _ + · intro n + exact Filter.Eventually.of_forall (fun _ => f.norm_coe_le_norm _) + · exact Filter.Eventually.of_forall (fun t => (f.continuous.tendsto t).comp + ((grid_tendsto_seq m hm t.1).prodMk_nhds (grid_tendsto_seq m hm t.2))) + +end PlanarHalving.UniformPartition + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter BoundedContinuousFunction +open scoped Topology + +lemma measure_le_of_test {X : Type*} [MetricSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] (μ ν : FiniteMeasure X) + (h : ∀ f : BoundedContinuousFunction X ℝ, (∀ x, 0 ≤ f x) → ∫ x, f x ∂(μ : Measure X) ≤ ∫ x, f x ∂(ν : Measure X)) : + (μ : Measure X) ≤ (ν : Measure X) := by + have hn (f : BoundedContinuousFunction X NNReal) : ∫⁻ x, f x ∂(μ : Measure X) ≤ ∫⁻ x, f x ∂(ν : Measure X) := by + let g : BoundedContinuousFunction X ℝ := ⟨⟨fun x => (f x : ℝ), continuous_subtype_val.comp f.continuous⟩,f.map_bounded'⟩ + apply (ENNReal.toReal_le_toReal (f.lintegral_lt_top_of_nnreal _).ne + (f.lintegral_lt_top_of_nnreal _).ne).mp + rw [toReal_lintegral_coe_eq_integral f μ,toReal_lintegral_coe_eq_integral f ν] + exact h g (fun x => NNReal.coe_nonneg _) + have hclosed (F : Set X) (hF : IsClosed F) : (μ : Measure X) F ≤ (ν : Measure X) F := by + exact le_of_tendsto_of_tendsto (HasOuterApproxClosed.tendsto_lintegral_apprSeq hF (μ : Measure X)) + (HasOuterApproxClosed.tendsto_lintegral_apprSeq hF (ν : Measure X)) (Filter.Eventually.of_forall (fun n => hn (hF.apprSeq n))) + apply Measure.le_iff.mpr + intro F hF + rw [hF.measure_eq_iSup_isCompact (μ : Measure X)] + exact iSup_le (fun K => iSup_le (fun hKF => iSup_le (fun hK => + (hclosed K hK.isClosed).trans (measure_mono hKF)))) + +end PlanarHalving.Limits + +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology unitInterval NNReal ENNReal + +noncomputable def weightedAtoms {X : Type*} [MeasurableSpace X] {α : Type*} [Fintype α] + (w : ℝ≥0) (x : α → X) : FiniteMeasure X := + ⟨w • (∑ i, Measure.dirac (x i) : Measure X), inferInstance⟩ + +lemma integral_weightedAtoms {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] + {α : Type*} [Fintype α] (w : ℝ≥0) (x : α → X) (f : X → ℝ) : + ∫ t, f t ∂(weightedAtoms w x : Measure X) = (w : ℝ) * ∑ i, f (x i) := by + classical + change ∫ t, f t ∂((w : ℝ≥0∞) • ∑ i, Measure.dirac (x i)) = _ + rw [integral_smul_measure,integral_finsetSum_measure] + · simp only [integral_dirac,ENNReal.coe_toReal,smul_eq_mul] + · intro i _ + exact integrable_dirac (by simp) + +lemma mass_weightedAtoms {X : Type*} [MeasurableSpace X] {α : Type*} [Fintype α] + (w : ℝ≥0) (x : α → X) : + (weightedAtoms w x).mass = w * Fintype.card α := by + classical + simp [weightedAtoms,FiniteMeasure.mass,FiniteMeasure.mk_apply,Measure.smul_apply, + Measure.finsetSum_apply] + +end PlanarHalving.Limits + +namespace PlanarHalving.UniformPartition +open MeasureTheory Set Filter PlanarHalving.Limits +open scoped Topology unitInterval NNReal ENNReal + +noncomputable def gridPoint (m : ℕ) [NeZero m] (i : Fin m × Fin m) : I × I := + (boundary m i.1.castSucc,boundary m i.2.castSucc) + +lemma grid_sum_le {m c : ℕ} [NeZero m] (slots : Fin c → Fin m × Fin m) + (hs : Function.Injective slots) (f : I × I → ℝ) (hf : ∀ t, 0 ≤ f t) : + (∑ i, f (gridPoint m (slots i))) ≤ ∑ j, f (gridPoint m j) := by + classical + rw [← Finset.sum_image (f := fun j => f (gridPoint m j)) hs.injOn] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun i _ _ => hf _) + +lemma normalized_perturbed_sum_le {m c : ℕ} [NeZero m] + (slots : Fin c → Fin m × Fin m) (hs : Function.Injective slots) + (x : Fin c → I × I) (f : I × I → ℝ) (hf : ∀ t, 0 ≤ f t) + {ε : ℝ} (hε : 0 ≤ ε) (hclose : ∀ i, f (x i) ≤ f (gridPoint m (slots i)) + ε) : + (∑ i, f (x i))/(m : ℝ)^2 ≤ + (∑ j : Fin m × Fin m, f (gridPoint m j))/(m : ℝ)^2 + ε := by + have hm : 0 < (m : ℝ) := by exact_mod_cast NeZero.pos m + have hc : (c : ℝ) ≤ (m : ℝ)^2 := by + have h := Fintype.card_le_of_injective slots hs + simp only [Fintype.card_fin,Fintype.card_prod] at h + simpa only [pow_two] using (show (c : ℝ) ≤ (m : ℝ)*(m : ℝ) by exact_mod_cast h) + have hsum : (∑ i, f (x i)) ≤ (∑ j : Fin m × Fin m, f (gridPoint m j)) + (c : ℝ)*ε := by + calc + _ ≤ ∑ i, (f (gridPoint m (slots i)) + ε) := Finset.sum_le_sum (fun i _ => hclose i) + _ = (∑ i, f (gridPoint m (slots i))) + (c : ℝ)*ε := by simp [Finset.sum_add_distrib] + _ ≤ _ := add_le_add (grid_sum_le slots hs f hf) le_rfl + have hεc : (c : ℝ)*ε ≤ (m : ℝ)^2*ε := mul_le_mul_of_nonneg_right hc hε + apply (div_le_iff₀ (sq_pos_of_pos hm)).mpr + nlinarith [div_mul_cancel₀ (∑ j : Fin m × Fin m, f (gridPoint m j)) (ne_of_gt (sq_pos_of_pos hm))] + +lemma perturbed_grid_limit_le_volume (m c : ℕ → ℕ) [∀ n, NeZero (m n)] + (hm : Tendsto m atTop atTop) (x : ∀ n, Fin (c n) → I × I) + (slots : ∀ n, Fin (c n) → Fin (m n) × Fin (m n)) + (hs : ∀ n, Function.Injective (slots n)) + (d : ℕ → ℝ) (hd : Tendsto d atTop (𝓝 0)) + (hclose : ∀ n i, dist (x n i) (gridPoint (m n) (slots n i)) ≤ d n) + (μ : FiniteMeasure (I × I)) + (hμ : Tendsto (fun n => weightedAtoms ((m n : ℝ≥0)^2)⁻¹ (x n)) atTop (𝓝 μ)) : + (μ : Measure (I × I)) ≤ volume := by + let ν : FiniteMeasure (I × I) := ⟨volume,inferInstance⟩ + apply measure_le_of_test μ ν + intro f hf + apply le_of_forall_pos_le_add + intro ε hε + obtain ⟨δ,hδ,hfδ⟩ := Metric.uniformContinuous_iff.mp + (CompactSpace.uniformContinuous_of_continuous f.continuous) ε hε + have hdδ : ∀ᶠ n in atTop, d n < δ := (tendsto_order.mp hd).2 δ hδ + have hineq : ∀ᶠ n in atTop, + ∫ t, f t ∂(weightedAtoms ((m n : ℝ≥0)^2)⁻¹ (x n) : Measure (I × I)) ≤ + (∑ j : Fin (m n) × Fin (m n), f (gridPoint (m n) j))/(m n : ℝ)^2 + ε := by + filter_upwards [hdδ] with n hn + rw [integral_weightedAtoms] + simp only [NNReal.coe_inv,NNReal.coe_pow,NNReal.coe_natCast] + rw [← div_eq_inv_mul] + apply normalized_perturbed_sum_le (slots n) (hs n) (x n) f hf hε.le + intro i + have h := hfδ ((hclose n i).trans_lt hn) + rw [Real.dist_eq,abs_lt] at h + linarith [h.2] + have hlim := (FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp hμ) f + have hgrid := (riemann_tendsto m hm f).add_const ε + apply le_of_tendsto_of_tendsto hlim hgrid + filter_upwards [hineq] with n hn + exact hn + +end PlanarHalving.UniformPartition + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/PathLimits.lean b/lean/OAI/Combinatorics/HalvingLines/PathLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2a149f986abe82cf19c79e351eeb5522ce45eae --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/PathLimits.lean @@ -0,0 +1,388 @@ +import OAI.Combinatorics.HalvingLines.ChainDrawing + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Batches +open PlaneGraph RankCoordinates +variable {R : ℕ} + +lemma ConvexPath.extension_vertex (C : ConvexPath R) {l u : ℝ} + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) + (c : Fin (R+1)) : C.extension l u (C.point c).1 = (C.point c).2 := by + induction c using Fin.induction with + | zero => + apply le_antisymm (C.extension_below_vertex hsl 0) + have hh := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (.inr false) (C.point 0).1 + simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts] at hh + change _ ≤ envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (C.point 0).1 + linarith only [hh] + | succ b ih => + by_cases hb : C.point b.castSucc = C.point b.succ + · rw [← hb] + exact ih + · exact C.extension_edge hsl b hb (right_mem_segment ℝ _ _) + +lemma ConvexPath.extension_left (C : ConvexPath R) {l u : ℝ} (hlu : l ≤ u) + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) + {x : ℝ} (hx : x ≤ (C.point 0).1) : + C.extension l u x = (C.point 0).2 + l*(x-(C.point 0).1) := by + apply le_antisymm + · apply envelope_le + intro i + have hi := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) i (C.point 0).1 + change _ ≤ C.extension l u (C.point 0).1 at hi + rw [C.extension_vertex hsl] at hi + have hm := mul_nonpos_of_nonneg_of_nonpos + (sub_nonneg.mpr (C.extension_slopes hlu hsl i).1) (sub_nonpos.mpr hx) + nlinarith only [hi,hm] + · have hh := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (.inr false) x + simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts] at hh + change _ ≤ envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) x + linarith only [hh] + +lemma ConvexPath.extension_right (C : ConvexPath R) {l u : ℝ} (hlu : l ≤ u) + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) + {x : ℝ} (hx : (C.point (Fin.last R)).1 ≤ x) : + C.extension l u x = (C.point (Fin.last R)).2 + u*(x-(C.point (Fin.last R)).1) := by + apply le_antisymm + · apply envelope_le + intro i + have hi := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) i (C.point (Fin.last R)).1 + change _ ≤ C.extension l u (C.point (Fin.last R)).1 at hi + rw [C.extension_vertex hsl] at hi + have hm := mul_nonpos_of_nonpos_of_nonneg + (sub_nonpos.mpr (C.extension_slopes hlu hsl i).2) (sub_nonneg.mpr hx) + nlinarith only [hi,hm] + · have hh := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (.inr true) x + simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts] at hh + change _ ≤ envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) x + linarith only [hh] + +lemma finite_intermediate {R : ℕ} (f : Fin (R+1) → ℝ) {x : ℝ} + (h₀ : f 0 ≤ x) (h₁ : x < f (Fin.last R)) : + ∃ b : Fin R, f b.castSucc ≤ x ∧ x < f b.succ := by + have haux : ∀ c : Fin (R+1), x < f c → ∃ b : Fin R, f b.castSucc ≤ x ∧ x < f b.succ := by + intro c + induction c using Fin.induction with + | zero => exact fun h => (not_lt_of_ge h₀ h).elim + | succ b ih => + intro h + by_cases hb : f b.castSucc ≤ x + · exact ⟨b,hb,h⟩ + · exact ih (lt_of_not_ge hb) + exact haux (Fin.last R) h₁ + +lemma ConvexPath.extension_middle (C : ConvexPath R) {l u : ℝ} + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) + {x : ℝ} (h₀ : (C.point 0).1 ≤ x) (h₁ : x < (C.point (Fin.last R)).1) : + ∃ b : Fin R, C.point b.castSucc ≠ C.point b.succ ∧ + (x,C.extension l u x) ∈ segment ℝ (C.point b.castSucc) (C.point b.succ) := by + obtain ⟨b,hb₀,hb₁⟩ := finite_intermediate (fun c => (C.point c).1) h₀ h₁ + have hbx : (C.point b.castSucc).1 < (C.point b.succ).1 := hb₀.trans_lt hb₁ + have hb : C.point b.castSucc ≠ C.point b.succ := fun h => hbx.ne (congrArg Prod.fst h) + let t := (x-(C.point b.castSucc).1)/((C.point b.succ).1-(C.point b.castSucc).1) + have ht : t ∈ Set.Icc (0:ℝ) 1 := by + refine ⟨div_nonneg (sub_nonneg.mpr hb₀) (sub_nonneg.mpr hbx.le), ?_⟩ + exact (div_le_one (sub_pos.mpr hbx)).mpr (by linarith only [hb₁]) + let z : Point := (1-t) • C.point b.castSucc + t • C.point b.succ + have hz : z ∈ segment ℝ (C.point b.castSucc) (C.point b.succ) := by + rw [segment_eq_image] + exact ⟨t,ht,rfl⟩ + have hzx : z.1 = x := by + dsimp [z,t] + field_simp [ne_of_gt (sub_pos.mpr hbx)] + ring + have hzy := C.extension_edge hsl b hb hz + rw [hzx] at hzy + have he : (x,C.extension l u x) = z := Prod.ext hzx.symm hzy + exact ⟨b,hb,he ▸ hz⟩ + +lemma ConvexPath.extension_cases (C : ConvexPath R) {l u : ℝ} (hlu : l ≤ u) + (hsl : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≤ u) + {z : Point} (hz : C.extension l u z.1 = z.2) : + (z.1 ≤ (C.point 0).1 ∧ z.2 = (C.point 0).2 + l*(z.1-(C.point 0).1)) ∨ + ((C.point (Fin.last R)).1 ≤ z.1 ∧ z.2 = (C.point (Fin.last R)).2 + u*(z.1-(C.point (Fin.last R)).1)) ∨ + (∃ b : Fin R, C.point b.castSucc ≠ C.point b.succ ∧ z ∈ segment ℝ (C.point b.castSucc) (C.point b.succ)) := by + by_cases hl : z.1 ≤ (C.point 0).1 + · exact Or.inl ⟨hl, hz.symm.trans (C.extension_left hlu hsl hl)⟩ + by_cases hu : (C.point (Fin.last R)).1 ≤ z.1 + · exact Or.inr (Or.inl ⟨hu,hz.symm.trans (C.extension_right hlu hsl hu)⟩) + obtain ⟨b,hb,hz'⟩ := C.extension_middle hsl (le_of_not_ge hl) (lt_of_not_ge hu) + rw [hz] at hz' + exact Or.inr (Or.inr ⟨b,hb,hz'⟩) + +end PlanarHalving.Batches +namespace PlanarHalving.Spatial +open Set Filter Metric +open scoped Topology + +theorem subsequence_of_asymptotic_continuity + {X Y : Type*} [MetricSpace X] [SecondCountableTopology X] + [MetricSpace Y] [CompleteSpace Y] + (f : ℕ → X → Y) (G : Set X) (hG : G.Nonempty) (K : Set Y) (hK : IsCompact K) + (hbounded : ∀ n p, p ∈ G → f n p ∈ K) + (hcont : ∀ p ∈ G, ∀ ε > 0, ∃ r > 0, + ∀ᶠ n in atTop, ∀ q, dist q p < r → dist (f n q) (f n p) ≤ ε) : + ∃ (φ : ℕ → ℕ) (l : G → Y), StrictMono φ ∧ + (∀ p, l p ∈ K) ∧ + (∀ p : G, ∀ u : ℕ → X, Tendsto u atTop (𝓝 (p : X)) → + Tendsto (fun n => f (φ n) (u n)) atTop (𝓝 (l p))) := by + classical + let : Nonempty G := hG.to_subtype + let : CompactSpace K := isCompact_iff_compactSpace.mp hK + obtain ⟨q,hq⟩ := TopologicalSpace.exists_dense_seq G + let F : ℕ → ℕ → K := fun n j => ⟨f n (q j), hbounded n (q j) (q j).property⟩ + obtain ⟨g,φ,hφ,hg⟩ := CompactSpace.tendsto_subseq F + have hgrid (j : ℕ) : Tendsto (fun n => f (φ n) (q j)) atTop (𝓝 (g j : Y)) := + continuous_subtype_val.tendsto _ |>.comp ((tendsto_pi_nhds.mp hg) j) + have hcauchy (p : G) : CauchySeq (fun n => f (φ n) p) := by + rw [Metric.cauchySeq_iff] + intro ε hε + obtain ⟨r,hr,hrf⟩ := hcont p p.property (ε/4) (by positivity) + obtain ⟨j,hj⟩ := hq.exists_dist_lt p hr + have hj' : dist (q j : X) p < r := by simpa only [Subtype.dist_eq, dist_comm] using hj + obtain ⟨N,hN⟩ := eventually_atTop.mp (hφ.tendsto_atTop.eventually hrf) + obtain ⟨N',hN'⟩ := Metric.cauchySeq_iff.mp (hgrid j).cauchySeq (ε/4) (by positivity) + refine ⟨max N N',fun m hm n hn => ?_⟩ + have hm' := hN m (le_trans (le_max_left _ _) hm) (q j) hj' + have hn' := hN n (le_trans (le_max_left _ _) hn) (q j) hj' + have hmn := hN' m (le_trans (le_max_right _ _) hm) n (le_trans (le_max_right _ _) hn) + have htri := dist_triangle4 (f (φ m) p) (f (φ m) (q j)) (f (φ n) (q j)) (f (φ n) p) + rw [dist_comm (f (φ m) p) (f (φ m) (q j))] at htri + linarith only [htri,hm',hn',hmn,hε] + choose l hl using fun p => cauchySeq_tendsto_of_complete (hcauchy p) + refine ⟨φ,l,hφ,?_,?_⟩ + · intro p + exact hK.isClosed.mem_of_tendsto (hl p) (Eventually.of_forall (fun n => hbounded (φ n) p p.property)) + · intro p u hu + apply Metric.tendsto_atTop.mpr + intro ε hε + obtain ⟨r,hr,hrf⟩ := hcont p p.property (ε/3) (by positivity) + have hu' : ∀ᶠ n in atTop, dist (u n) (p : X) < r := (Metric.tendsto_nhds.mp hu) r hr + have hl' : ∀ᶠ n in atTop, dist (f (φ n) p) (l p) < ε/3 := + (Metric.tendsto_nhds.mp (hl p)) (ε/3) (by positivity) + apply eventually_atTop.mp + filter_upwards [hφ.tendsto_atTop.eventually hrf,hu',hl'] with n hn hnu hnl + have hh := hn (u n) hnu + have ht := dist_triangle (f (φ n) (u n)) (f (φ n) p) (l p) + linarith only [hh,ht,hnl,hε] + +lemma asymptotic_continuity_of_radial + {X Y : Type*} [MetricSpace X] [MetricSpace Y] + (f : ℕ → X → Y) (G : Set X) (r e : ℕ → ℝ) + (hr : ∀ j, 0 < r j) (he : Tendsto e atTop (𝓝 0)) + (hb : ∀ p ∈ G, ∀ j, ∀ᶠ n in atTop, + ∀ q, dist q p < r j → dist (f n q) (f n p) ≤ e j) : + ∀ p ∈ G, ∀ ε > 0, ∃ δ > 0, + ∀ᶠ n in atTop, ∀ q, dist q p < δ → dist (f n q) (f n p) ≤ ε := by + intro p hp ε hε + obtain ⟨j,hj⟩ := ((tendsto_order.mp he).2 ε hε).exists + refine ⟨r j,hr j,?_⟩ + filter_upwards [hb p hp j] with n hn q hq + exact (hn q hq).trans hj.le + +lemma lower_distance_of_limit + {X Y : Type*} [MetricSpace X] [MetricSpace Y] + (f : ℕ → X → Y) (φ : ℕ → ℕ) (hφ : StrictMono φ) + {p q : X} {x y : Y} (hp : Tendsto (fun n => f (φ n) p) atTop (𝓝 x)) + (hq : Tendsto (fun n => f (φ n) q) atTop (𝓝 y)) + {a : ℝ} (ha : ∀ᶠ n in atTop, a ≤ dist (f n p) (f n q)) : a ≤ dist x y := by + exact ge_of_tendsto (hp.dist hq) (hφ.tendsto_atTop.eventually ha) + +end PlanarHalving.Spatial +namespace PlanarHalving.Spatial +open Set Filter Metric +open scoped Topology + +lemma geometric_scale {q h d : ℝ} (hq : 0 < q) (hq1 : q < 1) + (_hh : 0 < h) (hd : 0 < d) (hdh : d ≤ h) : + ∃ j : ℕ, 1 ≤ j ∧ h*q^j < d ∧ q*d ≤ h*q^j := by + have ht : Tendsto (fun j : ℕ => h*q^j) atTop (𝓝 0) := by + simpa using (tendsto_pow_atTop_nhds_zero_of_lt_one hq.le hq1).const_mul h + have hex : ∃ j : ℕ, h*q^j < d := ((tendsto_order.mp ht).2 d hd).exists + let j := Nat.find hex + have hj : h*q^j < d := Nat.find_spec hex + have hj0 : j ≠ 0 := by + intro h + simp only [h,pow_zero,mul_one] at hj + exact (not_lt_of_ge hdh) hj + have hj1 : 1 ≤ j := Nat.one_le_iff_ne_zero.mpr hj0 + have hprev : d ≤ h*q^(j-1) := by + exact le_of_not_gt (Nat.find_min hex (show j-1 < j by omega)) + refine ⟨j,hj1,hj,?_⟩ + have hp : q^j = q^(j-1)*q := by + rw [← pow_succ] + congr 1 + omega + rw [hp] + nlinarith only [mul_le_mul_of_nonneg_left hprev hq.le] + +lemma geometric_lower_power {q h d s : ℝ} (hq : 0 < q) (hq1 : q < 1) + (hh : 0 < h) (hd : 0 < d) (hdh : d ≤ h) (hs : 0 ≤ s) : + ∃ j : ℕ, 1 ≤ j ∧ h*q^j < d ∧ + q^s * (q/h)^s * d^s ≤ (q^s)^(j+1) := by + obtain ⟨j,hj,hjd,hdj⟩ := geometric_scale hq hq1 hh hd hdh + refine ⟨j,hj,hjd,?_⟩ + have hdiv : q/h*d ≤ q^j := by + have hv : q*d/h ≤ q^j := (div_le_iff₀ hh).mpr (by nlinarith only [hdj]) + convert hv using 1 + ring + have hp := Real.rpow_le_rpow (by positivity : 0 ≤ q/h*d) hdiv hs + rw [Real.mul_rpow (by positivity) hd.le] at hp + rw [pow_succ, Real.rpow_pow_comm hq.le] + have ht := mul_le_mul_of_nonneg_left hp (Real.rpow_nonneg hq.le s) + nlinarith only [ht] + +lemma inverse_holder_of_radial_limits + {X Y : Type*} [MetricSpace X] [MetricSpace Y] + (f : ℕ → X → Y) (φ : ℕ → ℕ) (hφ : StrictMono φ) + (G : Set X) (l : G → Y) + (hl : ∀ p : G, Tendsto (fun n => f (φ n) p) atTop (𝓝 (l p))) + {q h s : ℝ} (hq : 0 < q) (hq1 : q < 1) (hh : 0 < h) (hs : 0 < s) + (hdiam : ∀ p p' : G, dist (p : X) p' ≤ h) + (hlower : ∀ p : G, ∀ j : ℕ, 1 ≤ j → ∀ᶠ n in atTop, + ∀ p' : G, h*q^j < dist (p : X) p' → (q^s)^(j+1) ≤ dist (f n p) (f n p')) : + ∀ p p' : G, (q^s * (q/h)^s) * dist (p : X) p' ^ s ≤ dist (l p) (l p') := by + intro p p' + by_cases hpp : p = p' + · subst p' + simp [Real.zero_rpow hs.ne'] + · have hd : 0 < dist (p : X) p' := dist_pos.mpr (Subtype.coe_ne_coe.mpr hpp) + obtain ⟨j,hj,hjd,hdj⟩ := geometric_lower_power hq hq1 hh hd (hdiam p p') hs.le + apply hdj.trans + apply lower_distance_of_limit f φ hφ (hl p) (hl p') + filter_upwards [hlower p j hj] with n hn + exact hn p' hjd + +end PlanarHalving.Spatial +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology NNReal + +theorem finiteMeasure_subsequence + {X : Type*} [MetricSpace X] [CompactSpace X] [Nonempty X] + [MeasurableSpace X] [BorelSpace X] + (μ : ℕ → ℕ → FiniteMeasure X) (C : ℕ → ℝ≥0) + (hbound : ∀ n j, (μ n j).mass ≤ C j) : + ∃ (φ : ℕ → ℕ) (ν : ℕ → FiniteMeasure X), StrictMono φ ∧ + ∀ j, Tendsto (fun n => μ (φ n) j) atTop (𝓝 (ν j)) := by + let F : ℕ → ∀ j : ℕ, (Icc (0 : ℝ≥0) (C j)) × ProbabilityMeasure X := + fun n j => (⟨(μ n j).mass,zero_le,hbound n j⟩,(μ n j).normalize) + obtain ⟨g,φ,hφ,hg⟩ := CompactSpace.tendsto_subseq F + refine ⟨φ,fun j => (g j).1.val • (g j).2.toFiniteMeasure,hφ,?_⟩ + intro j + have hj := (tendsto_pi_nhds.mp hg) j + have hm := continuous_subtype_val.tendsto _ |>.comp ((continuous_fst.tendsto (g j)).comp hj) + have hn := (ProbabilityMeasure.toFiniteMeasure_isEmbedding X).continuous.tendsto _ |>.comp + ((continuous_snd.tendsto (g j)).comp hj) + have ht := hm.smul hn + convert ht using 1 + funext n + exact (μ (φ n) j).self_eq_mass_smul_normalize + +end PlanarHalving.Limits + +namespace PlanarHalving.RankCoordinates +open Set + +lemma variation_le_two {f : ℕ → ℝ} {n : ℕ} + (hf : ∀ i ≤ n, 0 ≤ f i ∧ f i ≤ 1) + (hqc : ∀ i j k, i ≤ j → j ≤ k → k ≤ n → min (f i) (f k) ≤ f j) : + ∑ i ∈ Finset.range n, |f (i+1)-f i| ≤ 2 := by + classical + obtain ⟨k,hk,hmax⟩ := (Finset.range (n+1)).exists_max_image f (by simp) + have hkn : k ≤ n := by simpa only [Finset.mem_range,Nat.lt_succ_iff] using hk + have hleft : ∑ i ∈ Finset.range k, |f (i+1)-f i| = f k-f 0 := by + rw [← Finset.sum_range_sub f k] + apply Finset.sum_congr rfl + intro i hi + have hik : i < k := Finset.mem_range.mp hi + apply abs_of_nonneg + apply sub_nonneg.mpr + have hq := hqc i (i+1) k (by omega) (by omega) hkn + rw [min_eq_left (hmax i (by simp; omega))] at hq + exact hq + have hright : ∑ i ∈ Finset.Ico k n, |f (i+1)-f i| = f k-f n := by + calc + _ = - ∑ i ∈ Finset.Ico k n, (f (i+1)-f i) := by + rw [← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro i hi + obtain ⟨hki,hin⟩ := Finset.mem_Ico.mp hi + apply abs_of_nonpos + apply sub_nonpos.mpr + have hq := hqc k i (i+1) hki (by omega) (by omega) + rw [min_eq_right (hmax (i+1) (by simp; omega))] at hq + exact hq + _ = _ := by rw [Finset.sum_Ico_sub f hkn]; ring + rw [← Finset.sum_range_add_sum_Ico (fun i => |f (i+1)-f i|) hkn,hleft,hright] + have h0 := (hf 0 (Nat.zero_le n)).1 + have hn := (hf n le_rfl).1 + have hk1 := (hf k hkn).2 + linarith only [h0,hn,hk1] + +lemma min_le_of_quasiconcave {f : ℝ → ℝ} (hf : QuasiconcaveOn ℝ univ f) + {x y z : ℝ} (hxy : x ≤ y) (hyz : y ≤ z) : min (f x) (f z) ≤ f y := by + have hc := (hf (min (f x) (f z))).ordConnected + have hx : x ∈ univ ∩ {u | min (f x) (f z) ≤ f u} := by + refine ⟨mem_univ _,?_⟩ + change min (f x) (f z) ≤ f x + exact min_le_left _ _ + have hz : z ∈ univ ∩ {u | min (f x) (f z) ≤ f u} := by + refine ⟨mem_univ _,?_⟩ + change min (f x) (f z) ≤ f z + exact min_le_right _ _ + exact (hc.out hx hz ⟨hxy,hyz⟩).2 + +lemma concave_cdf_variation {f F : ℝ → ℝ} (hf : ConcaveOn ℝ univ f) + (hF : Monotone F) (hFrange : ∀ x, F x ∈ Icc 0 1) + (x : ℕ → ℝ) (hx : Monotone x) (n : ℕ) : + ∑ i ∈ Finset.range n, |F (f (x (i+1)))-F (f (x i))| ≤ 2 := by + apply variation_le_two (fun i _ => hFrange (f (x i))) + intro i j k hij hjk _ + rw [← hF.map_min] + exact hF (min_le_of_quasiconcave hf.quasiconcaveOn (hx hij) (hx hjk)) + +lemma sigmoid_variation {f : ℝ → ℝ} (hf : ConcaveOn ℝ univ f) + {ε : ℝ} (hε : 0 < ε) (x : ℕ → ℝ) (hx : Monotone x) (n : ℕ) : + ∑ i ∈ Finset.range n, + |Real.sigmoid (f (x (i+1))/ε)-Real.sigmoid (f (x i)/ε)| ≤ 2 := by + apply concave_cdf_variation hf + (fun _ _ h => Real.sigmoid_strictMono.monotone (div_le_div_of_nonneg_right h hε.le)) + (fun _ => ⟨(Real.sigmoid_pos _).le,(Real.sigmoid_lt_one _).le⟩) x hx n + +lemma smoothed_variation {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + (hg : ∀ j, ConvexOn ℝ univ (g j)) {f : ℝ → ℝ} (hf : ConcaveOn ℝ univ f) + {ε : ℝ} (hε : 0 < ε) (x : ℕ → ℝ) (hx : Monotone x) (n : ℕ) : + ∑ i ∈ Finset.range n, + |smoothed g ε (x (i+1),f (x (i+1)))-smoothed g ε (x i,f (x i))| ≤ 2 := by + have hmR : (0 : ℝ) < m := Nat.cast_pos.mpr hm + have hterm (i : ℕ) : + |smoothed g ε (x (i+1),f (x (i+1)))-smoothed g ε (x i,f (x i))| ≤ + (∑ j, |Real.sigmoid ((f (x (i+1))-g j (x (i+1)))/ε) - + Real.sigmoid ((f (x i)-g j (x i))/ε)|) / m := by + unfold smoothed + rw [← sub_div,abs_div,abs_of_pos hmR,← Finset.sum_sub_distrib] + exact div_le_div_of_nonneg_right (Finset.abs_sum_le_sum_abs _ _) hmR.le + calc + _ ≤ ∑ i ∈ Finset.range n, (∑ j, |Real.sigmoid ((f (x (i+1))-g j (x (i+1)))/ε) - + Real.sigmoid ((f (x i)-g j (x i))/ε)|) / m := Finset.sum_le_sum (fun i _ => hterm i) + _ = (∑ j : Fin m, ∑ i ∈ Finset.range n, + |Real.sigmoid ((f (x (i+1))-g j (x (i+1)))/ε) - + Real.sigmoid ((f (x i)-g j (x i))/ε)|) / m := by + rw [← Finset.sum_div,Finset.sum_comm] + _ ≤ (∑ _j : Fin m, (2 : ℝ))/m := by + apply div_le_div_of_nonneg_right _ hmR.le + exact Finset.sum_le_sum (fun j _ => sigmoid_variation (hf.sub (hg j)) hε x hx n) + _ = 2 := by simp; field_simp + +end PlanarHalving.RankCoordinates + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Perturbation.lean b/lean/OAI/Combinatorics/HalvingLines/Perturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c8f8809fc7f2dc564ae47bfeb2c44628a9ac9ef --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Perturbation.lean @@ -0,0 +1,416 @@ +import OAI.Combinatorics.HalvingLines.Recurrence + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Perturbation +open Set + +lemma orient_cycle (p q r : Point) : orient q r p=orient p q r := by unfold orient;ring + +lemma orient_segment {p q z : Point} (hz : z∈segment ℝ p q) : orient p q z=0 := by + rw [segment_eq_image] at hz + obtain ⟨t,_,rfl⟩ := hz + simp only [orient,Prod.fst_add,Prod.snd_add,Prod.smul_fst,Prod.smul_snd,smul_eq_mul] + ring + +lemma no_vertex_openSegment {n : ℕ} {P : Fin n → Point} (hP : GeneralPosition P) + {i j : Fin n} (hij : i≠j) (v : Fin n) : P v∉openSegment ℝ (P i) (P j) := by + intro hv + have ho := orient_segment (openSegment_subset_segment ℝ _ _ hv) + rcases (orient_zero_iff hP hij v).mp ho with rfl | rfl + · exact hij (hP.1 (left_mem_openSegment_iff.mp hv)) + · exact hij (hP.1 (right_mem_openSegment_iff.mp hv)) + +lemma two_lines_intersection {p q r z : Point} (hd : orient p q r≠0) + (hq : orient p q z=0) (hr : orient p r z=0) : z=p := by + have hx : orient p q r*(z.1-p.1)=0 := by + unfold orient at * + linear_combination (r.1-p.1)*hq-(q.1-p.1)*hr + have hy : orient p q r*(z.2-p.2)=0 := by + unfold orient at * + linear_combination (r.2-p.2)*hq-(q.2-p.2)*hr + exact Prod.ext (sub_eq_zero.mp ((mul_eq_zero.mp hx).resolve_left hd)) + (sub_eq_zero.mp ((mul_eq_zero.mp hy).resolve_left hd)) + +lemma slope_eq_orient_zero {p q r : Point} (hxq : p.1≠q.1) (hxr : p.1≠r.1) + (hs : slope p q=slope p r) : orient p q r=0 := by + rw [orient_eq_proj_diff _ _ _ hxq.symm] + have he := Sweep.tied_projection p r hxr + rw [← hs] at he + change _*(Sweep.projection (slope p q) r-Sweep.projection (slope p q) p)=0 + rw [← he,sub_self,mul_zero] + +noncomputable def intercept (p q : Point) : ℝ := p.2-slope p q*p.1 +noncomputable def intersectionPoint (p q r s : Point) : Point := + let x := (intercept r s-intercept p q)/(slope p q-slope r s) + (x,slope p q*x+intercept p q) + +lemma orient_line_eq {p q z : Point} (hx : p.1≠q.1) (hz : orient p q z=0) : + z.2=slope p q*z.1+intercept p q := by + rw [orient_eq_proj_diff _ _ _ hx.symm] at hz + have hh := (mul_eq_zero.mp hz).resolve_left (sub_ne_zero.mpr hx.symm) + dsimp [intercept] + linarith + +lemma intersectionPoint_eq {p q r s z : Point} (hpq : p.1≠q.1) (hrs : r.1≠s.1) + (hs : slope p q≠slope r s) (hzp : orient p q z=0) (hzr : orient r s z=0) : + z=intersectionPoint p q r s := by + have hp := orient_line_eq hpq hzp + have hr := orient_line_eq hrs hzr + have hx : z.1=(intercept r s-intercept p q)/(slope p q-slope r s) := by + apply (eq_div_iff (sub_ne_zero.mpr hs)).mpr + nlinarith only [hp,hr] + apply Prod.ext + · exact hx + · change z.2=slope p q*((intercept r s-intercept p q)/(slope p q-slope r s))+intercept p q + rw [← hx] + exact hp + +abbrev Edge (n : ℕ) := {e : Fin n × Fin n // e.1 < e.2} + +noncomputable def edgeSlope {n : ℕ} (P : Fin n → Point) (e : Edge n) := slope (P e.val.1) (P e.val.2) +def onLine {n : ℕ} (P : Fin n → Point) (e : Edge n) (z : Point) := orient (P e.val.1) (P e.val.2) z=0 + +structure Regular {n : ℕ} (P : Fin n → Point) : Prop where + general : GeneralPosition P + xdistinct : ∀ i j, i≠j → (P i).1≠(P j).1 + slopes : Function.Injective (edgeSlope P) + concurrent : ∀ e f g : Edge n, e≠f → g≠e → g≠f → ∀ z : Point, + onLine P e z → onLine P f z → onLine P g z → ∃ v, P v=z + +lemma Regular.generic {n : ℕ} {P : Fin n → Point} (hP : Regular P) : Generic P := by + refine ⟨hP.general,hP.xdistinct,?_,?_⟩ + · intro i j a b hij hab hs + have he : (⟨(i,j),hij⟩ : Edge n)=⟨(a,b),hab⟩ := hP.slopes hs + exact Prod.mk.inj (congrArg Subtype.val he) + · intro i j a b c d hij hab hcd hef hge hgf z hz₁ hz₂ hz₃ + obtain ⟨v,hv⟩ := hP.concurrent ⟨(i,j),hij⟩ ⟨(a,b),hab⟩ ⟨(c,d),hcd⟩ + (fun h => hef (congrArg Subtype.val h)) (fun h => hge (congrArg Subtype.val h)) + (fun h => hgf (congrArg Subtype.val h)) z + (orient_segment (openSegment_subset_segment ℝ _ _ hz₁)) + (orient_segment (openSegment_subset_segment ℝ _ _ hz₂)) (orient_segment hz₃) + rw [← hv] at hz₁ + exact no_vertex_openSegment hP.general hij.ne v hz₁ + +def newEdge {n : ℕ} (i : Fin n) : Edge (n+1) := ⟨(0,i.succ),Fin.succ_pos i⟩ +def oldEdge {n : ℕ} (e : Edge n) : Edge (n+1) := ⟨(e.val.1.succ,e.val.2.succ),Fin.succ_lt_succ_iff.mpr e.property⟩ + +lemma newEdge_injective (n : ℕ) : Function.Injective (@newEdge n) := by + intro i j he + exact Fin.succ_inj.mp (congrArg (fun e => e.val.2) he) +lemma oldEdge_injective (n : ℕ) : Function.Injective (@oldEdge n) := by + intro i j he + apply Subtype.ext + exact Prod.ext (Fin.succ_inj.mp (congrArg (fun e => e.val.1) he)) + (Fin.succ_inj.mp (congrArg (fun e => e.val.2) he)) +lemma newEdge_ne_oldEdge {n : ℕ} (i : Fin n) (e : Edge n) : newEdge i≠oldEdge e := by + intro he + exact Fin.succ_ne_zero e.val.1 (congrArg (fun e => e.val.1) he).symm + +lemma edge_cases {n : ℕ} (e : Edge (n+1)) : + (∃ i, e=newEdge i) ∨ ∃ f, e=oldEdge f := by + rcases e with ⟨⟨i,j⟩,hij⟩ + have hj : j≠0 := by intro h;subst j;exact (Fin.not_lt_zero i) hij + obtain ⟨j,rfl⟩ := Fin.exists_succ_eq.mpr hj + rcases Fin.eq_zero_or_eq_succ i with rfl | ⟨i,rfl⟩ + · exact Or.inl ⟨j,rfl⟩ + · exact Or.inr ⟨⟨(i,j),Fin.succ_lt_succ_iff.mp hij⟩,rfl⟩ + +@[simp] lemma edgeSlope_new {n : ℕ} (P : Fin n → Point) (p : Point) (i : Fin n) : + edgeSlope (Fin.cons p P) (newEdge i)=slope p (P i) := by simp [edgeSlope,newEdge] +@[simp] lemma edgeSlope_old {n : ℕ} (P : Fin n → Point) (p : Point) (e : Edge n) : + edgeSlope (Fin.cons p P) (oldEdge e)=edgeSlope P e := by simp [edgeSlope,oldEdge] +@[simp] lemma onLine_new {n : ℕ} (P : Fin n → Point) (p z : Point) (i : Fin n) : + onLine (Fin.cons p P) (newEdge i) z ↔ orient p (P i) z=0 := by simp [onLine,newEdge] +@[simp] lemma onLine_old {n : ℕ} (P : Fin n → Point) (p z : Point) (e : Edge n) : + onLine (Fin.cons p P) (oldEdge e) z ↔ onLine P e z := by simp [onLine,oldEdge] + +end PlanarHalving.Perturbation +namespace PlanarHalving.Perturbation +open Set + +lemma open_dense_affine (a b c : ℝ) (hab : a≠0 ∨ b≠0) : + IsOpen {p : Point | a*p.1+b*p.2≠c} ∧ Dense {p : Point | a*p.1+b*p.2≠c} := by + let L : Point →L[ℝ] ℝ := a • ContinuousLinearMap.fst ℝ ℝ ℝ+b • ContinuousLinearMap.snd ℝ ℝ ℝ + have hL : L≠0 := by + intro h + have ha := congrArg (fun f : Point →L[ℝ] ℝ => f (1,0)) h + have hb := congrArg (fun f : Point →L[ℝ] ℝ => f (0,1)) h + change a*1+b*0=0 at ha + change a*0+b*1=0 at hb + norm_num at ha hb + exact hab.elim (fun h => h ha) (fun h => h hb) + have hd := (dense_compl_singleton c).preimage (L.isOpenMap_of_ne_zero hL) + refine ⟨?_,?_⟩ + · exact isOpen_ne.preimage (by fun_prop : Continuous (fun p : Point => a*p.1+b*p.2)) + · change Dense {p : Point | a*p.1+b*p.2≠c} at hd + exact hd + +lemma open_dense_orient {p q : Point} (hpq : p≠q) : + IsOpen {z : Point | orient p q z≠0} ∧ Dense {z : Point | orient p q z≠0} := by + have hab : -(q.2-p.2)≠0 ∨ q.1-p.1≠0 := by + by_contra! h + apply hpq + apply Prod.ext <;> linarith + have he : {z : Point | orient p q z≠0}= + {z : Point | -(q.2-p.2)*z.1+(q.1-p.1)*z.2≠(q.1-p.1)*p.2-(q.2-p.2)*p.1} := by + ext z + simp only [Set.mem_ofPred_eq,orient] + constructor <;> intro hn he <;> apply hn <;> nlinarith only [he] + rw [he] + exact open_dense_affine _ _ _ hab + +lemma open_dense_forall {ι : Sort*} [Finite ι] (p : ι → Point → Prop) + (hU : ∀ i, IsOpen {x | p i x} ∧ Dense {x | p i x}) : + IsOpen {x : Point | ∀ i, p i x} ∧ Dense {x : Point | ∀ i, p i x} := by + simpa only [Set.ofPred_forall] using + (show IsOpen (⋂ i, {x | p i x}) ∧ Dense (⋂ i, {x | p i x}) from + ⟨isOpen_iInter_of_finite (fun i => (hU i).1),dense_iInter_of_isOpen (fun i => (hU i).1) (fun i => (hU i).2)⟩) + +lemma open_dense_and {p q : Point → Prop} + (hp : IsOpen {x | p x} ∧ Dense {x | p x}) (hq : IsOpen {x | q x} ∧ Dense {x | q x}) : + IsOpen {x | p x ∧ q x} ∧ Dense {x | p x ∧ q x} := + ⟨hp.1.inter hq.1,hp.2.inter_of_isOpen_left hq.2 hp.1⟩ + +noncomputable def edgeMeet {n : ℕ} (P : Fin n → Point) (e f : Edge n) : Point := + intersectionPoint (P e.val.1) (P e.val.2) (P f.val.1) (P f.val.2) + +def Fresh {n : ℕ} (P : Fin n → Point) (p : Point) : Prop := + (∀ i, p.1≠(P i).1) ∧ + (∀ i j, i≠j → orient (P i) (P j) p≠0) ∧ + (∀ i e, Sweep.projection (edgeSlope P e) p≠Sweep.projection (edgeSlope P e) (P i)) ∧ + (∀ i e f, edgeMeet P e f≠P i → orient (P i) (edgeMeet P e f) p≠0) + +lemma fresh_open_dense {n : ℕ} {P : Fin n → Point} (hP : GeneralPosition P) : + IsOpen {p | Fresh P p} ∧ Dense {p | Fresh P p} := by + unfold Fresh + apply open_dense_and + · apply open_dense_forall + intro i + simpa only [one_mul,zero_mul,add_zero] using open_dense_affine 1 0 (P i).1 (Or.inl one_ne_zero) + · apply open_dense_and + · apply open_dense_forall + intro i + apply open_dense_forall + intro j + apply open_dense_forall + intro hij + exact open_dense_orient (fun h => hij (hP.1 h)) + · apply open_dense_and + · apply open_dense_forall + intro i + apply open_dense_forall + intro e + simpa only [Sweep.projection,one_mul,sub_eq_add_neg,neg_mul,add_comm] using + open_dense_affine (-(edgeSlope P e)) 1 ((P i).2-edgeSlope P e*(P i).1) (Or.inr one_ne_zero) + · apply open_dense_forall + intro i + apply open_dense_forall + intro e + apply open_dense_forall + intro f + apply open_dense_forall + intro hi + exact open_dense_orient hi.symm + +end PlanarHalving.Perturbation +namespace PlanarHalving.Perturbation +open Set +variable {n : ℕ} {P : Fin n → Point} {p : Point} + +lemma Fresh.xdistinct (hP : Regular P) (hp : Fresh P p) : + ∀ i j : Fin (n+1), i≠j → (Fin.cons (α := fun _ => Point) p P i).1≠(Fin.cons (α := fun _ => Point) p P j).1 := by + intro i j hij + rcases Fin.eq_zero_or_eq_succ i with rfl | ⟨i,rfl⟩ <;> + rcases Fin.eq_zero_or_eq_succ j with rfl | ⟨j,rfl⟩ + · exact False.elim (hij rfl) + · simpa only [Fin.cons_zero,Fin.cons_succ] using hp.1 j + · simpa only [Fin.cons_zero,Fin.cons_succ] using (hp.1 i).symm + · simpa only [Fin.cons_succ] using hP.xdistinct i j (fun h => hij (congrArg Fin.succ h)) + +lemma Fresh.general (hP : Regular P) (hp : Fresh P p) : GeneralPosition (Fin.cons (α := fun _ => Point) p P) := by + refine ⟨?_,?_⟩ + · intro i j he + by_contra hn + exact hp.xdistinct hP i j hn (congrArg Prod.fst he) + · intro i j l hij hjl hil + rcases Fin.eq_zero_or_eq_succ i with rfl | ⟨i,rfl⟩ + · rcases Fin.eq_zero_or_eq_succ j with rfl | ⟨j,rfl⟩ + · exact False.elim (hij rfl) + · rcases Fin.eq_zero_or_eq_succ l with rfl | ⟨l,rfl⟩ + · exact False.elim (hil rfl) + · simp only [Fin.cons_zero,Fin.cons_succ] + rw [← orient_cycle p (P j) (P l)] + exact hp.2.1 j l (fun h => hjl (congrArg Fin.succ h)) + · rcases Fin.eq_zero_or_eq_succ j with rfl | ⟨j,rfl⟩ + · rcases Fin.eq_zero_or_eq_succ l with rfl | ⟨l,rfl⟩ + · exact False.elim (hjl rfl) + · simp only [Fin.cons_zero,Fin.cons_succ] + have he : orient (P i) p (P l)=-orient (P i) (P l) p := by unfold orient;ring + rw [he] + exact neg_ne_zero.mpr (hp.2.1 i l (fun h => hil (congrArg Fin.succ h))) + · rcases Fin.eq_zero_or_eq_succ l with rfl | ⟨l,rfl⟩ + · simpa only [Fin.cons_zero,Fin.cons_succ] using hp.2.1 i j (fun h => hij (congrArg Fin.succ h)) + · simpa only [Fin.cons_succ] using hP.general.2 i j l + (fun h => hij (congrArg Fin.succ h)) (fun h => hjl (congrArg Fin.succ h)) + (fun h => hil (congrArg Fin.succ h)) + +lemma Fresh.slopes (hP : Regular P) (hp : Fresh P p) : + Function.Injective (edgeSlope (Fin.cons (α := fun _ => Point) p P)) := by + intro e f hs + rcases edge_cases e with ⟨i,rfl⟩ | ⟨e,rfl⟩ <;> + rcases edge_cases f with ⟨j,rfl⟩ | ⟨f,rfl⟩ + · simp only [edgeSlope_new] at hs + apply congrArg newEdge + by_contra hij + have ho : orient p (P i) (P j)≠0 := by + rw [← orient_cycle p (P i) (P j)] + exact hp.2.1 i j hij + exact ho (slope_eq_orient_zero (hp.1 i) (hp.1 j) hs) + · simp only [edgeSlope_new,edgeSlope_old] at hs + have ht := Sweep.tied_projection p (P i) (hp.1 i) + rw [hs] at ht + exact False.elim (hp.2.2.1 i f ht) + · simp only [edgeSlope_new,edgeSlope_old] at hs + have ht := Sweep.tied_projection p (P j) (hp.1 j) + rw [← hs] at ht + exact False.elim (hp.2.2.1 j e ht) + · simp only [edgeSlope_old] at hs + exact congrArg oldEdge (hP.slopes hs) + +lemma Fresh.two_new {i j : Fin n} (hp : Fresh P p) (hij : i≠j) {z : Point} + (hi : orient p (P i) z=0) (hj : orient p (P j) z=0) : + ∃ v : Fin (n+1), Fin.cons (α := fun _ => Point) p P v=z := by + have ho : orient p (P i) (P j)≠0 := by + rw [← orient_cycle p (P i) (P j)] + exact hp.2.1 i j hij + exact ⟨0,(two_lines_intersection ho hi hj).symm⟩ + +lemma Fresh.one_new (hP : Regular P) (hp : Fresh P p) (i : Fin n) {e f : Edge n} + (hef : e≠f) {z : Point} (hi : orient p (P i) z=0) (he : onLine P e z) (hf : onLine P f z) : + ∃ v : Fin (n+1), Fin.cons (α := fun _ => Point) p P v=z := by + have hz : z=edgeMeet P e f := intersectionPoint_eq + (hP.xdistinct _ _ e.property.ne) (hP.xdistinct _ _ f.property.ne) + (fun h => hef (hP.slopes h)) he hf + by_cases hzi : z=P i + · exact ⟨i.succ,hzi.symm⟩ + · have hn := hp.2.2.2 i e f (by rw [← hz];exact hzi) + rw [← hz,orient_cycle p (P i) z] at hn + exact False.elim (hn hi) + +lemma Fresh.regular (hP : Regular P) (hp : Fresh P p) : Regular (Fin.cons (α := fun _ => Point) p P) := by + refine ⟨hp.general hP,hp.xdistinct hP,hp.slopes hP,?_⟩ + intro e f g hef hge hgf z he hf hg + rcases edge_cases e with ⟨i,rfl⟩ | ⟨e,rfl⟩ + · rcases edge_cases f with ⟨j,rfl⟩ | ⟨f,rfl⟩ + · exact hp.two_new (fun h => hef (congrArg newEdge h)) ((onLine_new P p z i).mp he) ((onLine_new P p z j).mp hf) + · rcases edge_cases g with ⟨l,rfl⟩ | ⟨g,rfl⟩ + · exact hp.two_new (fun h => hge (congrArg newEdge h.symm)) ((onLine_new P p z i).mp he) ((onLine_new P p z l).mp hg) + · exact hp.one_new hP i (fun h => hgf (congrArg oldEdge h.symm)) + ((onLine_new P p z i).mp he) ((onLine_old P p z f).mp hf) ((onLine_old P p z g).mp hg) + · rcases edge_cases f with ⟨j,rfl⟩ | ⟨f,rfl⟩ + · rcases edge_cases g with ⟨l,rfl⟩ | ⟨g,rfl⟩ + · exact hp.two_new (fun h => hgf (congrArg newEdge h.symm)) ((onLine_new P p z j).mp hf) ((onLine_new P p z l).mp hg) + · exact hp.one_new hP j (fun h => hge (congrArg oldEdge h.symm)) + ((onLine_new P p z j).mp hf) ((onLine_old P p z e).mp he) ((onLine_old P p z g).mp hg) + · rcases edge_cases g with ⟨l,rfl⟩ | ⟨g,rfl⟩ + · exact hp.one_new hP l (fun h => hef (congrArg oldEdge h)) + ((onLine_new P p z l).mp hg) ((onLine_old P p z e).mp he) ((onLine_old P p z f).mp hf) + · obtain ⟨v,hv⟩ := hP.concurrent e f g (fun h => hef (congrArg oldEdge h)) + (fun h => hge (congrArg oldEdge h)) (fun h => hgf (congrArg oldEdge h)) z + ((onLine_old P p z e).mp he) ((onLine_old P p z f).mp hf) ((onLine_old P p z g).mp hg) + exact ⟨v.succ,hv⟩ + +end PlanarHalving.Perturbation +namespace PlanarHalving.Perturbation +open Set + +lemma regular_empty (P : Fin 0 → Point) : Regular P := by + constructor + · constructor + · intro i;exact Fin.elim0 i + · intro i;exact Fin.elim0 i + · intro i;exact Fin.elim0 i + · intro e;exact Fin.elim0 e.val.1 + · intro e;exact Fin.elim0 e.val.1 + +lemma regular_approx (n : ℕ) {ε : ℝ} (hε : 0<ε) : ∀ P : Fin n → Point, + ∃ Q : Fin n → Point, Regular Q ∧ ∀ i, dist (Q i) (P i)<ε := by + induction n with + | zero => + intro P + exact ⟨P,regular_empty P,fun i => Fin.elim0 i⟩ + | succ n ih => + intro P + obtain ⟨Q,hQ,hclose⟩ := ih (fun i => P i.succ) + obtain ⟨p,hp,hpclose⟩ := (fresh_open_dense hQ.general).2.exists_mem_open Metric.isOpen_ball + (show (Metric.ball (P 0) ε).Nonempty from ⟨P 0,Metric.mem_ball_self hε⟩) + refine ⟨Fin.cons p Q,hp.regular hQ,?_⟩ + intro i + refine Fin.cases ?_ (fun j => ?_) i + · exact hpclose + · exact hclose j + +lemma dense_regular (n : ℕ) : Dense {P : Fin n → Point | Regular P} := by + apply Metric.dense_iff.mpr + intro P ε hε + obtain ⟨Q,hQ,hclose⟩ := regular_approx n hε P + exact ⟨Q,(dist_pi_lt_iff hε).mpr hclose,hQ⟩ + +lemma dense_generic (n : ℕ) : Dense {P : Fin n → Point | Generic P} := + (dense_regular n).mono (fun _ hp => hp.generic) + +lemma generic_same_sides {n : ℕ} {P : Fin n → Point} (hP : GeneralPosition P) : + ∃ Q : Fin n → Point, Generic Q ∧ ∀ i j l, + (0 hsides i j l) + refine ⟨Q,hQ,?_⟩ + unfold halvingCount + apply congrArg Finset.card + apply Finset.filter_congr + intro ij _ + rw [hcount,hcount] + +end PlanarHalving.Perturbation + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/PlaneGraph.lean b/lean/OAI/Combinatorics/HalvingLines/PlaneGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..b76ee88372983c0ca970ba27dd09f8a05b5f089c --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/PlaneGraph.lean @@ -0,0 +1,462 @@ +import OAI.Combinatorics.HalvingLines.RankCoordinates + +namespace OAI + +open Filter Topology + +namespace PlanarHalving +namespace PlaneGraph + +noncomputable def height (p q : Point) (x : ℝ) : ℝ := + p.2 + (x - p.1) * PlanarHalving.slope p q + +@[simp] lemma height_left (p q : Point) : height p q p.1 = p.2 := by simp [height] +@[simp] lemma height_right (p q : Point) (hx : p.1 ≠ q.1) : height p q q.1 = q.2 := by + unfold height PlanarHalving.slope + have h : q.1 - p.1 ≠ 0 := sub_ne_zero.mpr hx.symm + field_simp + ring + +lemma height_point_openSegment (p q : Point) {x : ℝ} (hl : p.1 < x) (hr : x < q.1) : + (x, height p q x) ∈ openSegment ℝ p q := by + rw [openSegment_eq_image] + have hd : 0 < q.1 - p.1 := sub_pos.mpr (hl.trans hr) + refine ⟨(x - p.1) / (q.1 - p.1), ⟨div_pos (sub_pos.mpr hl) hd, ?_⟩, ?_⟩ + · apply (div_lt_one hd).mpr + linarith + · ext <;> simp only [Prod.fst_add, Prod.snd_add, Prod.smul_fst, Prod.smul_snd, + smul_eq_mul, height, PlanarHalving.slope] + all_goals field_simp; ring + +lemma height_continuous (p q : Point) : Continuous (height p q) := by + unfold height + fun_prop + +lemma height_order {p q r s : Point} + (hd : Disjoint (openSegment ℝ p q) (openSegment ℝ r s)) + {x y : ℝ} (hxy : x < y) (hp : p.1 ≤ x) (hr : r.1 ≤ x) + (hq : y ≤ q.1) (hs : y ≤ s.1) + (hstart : height p q x < height r s x) : + height p q y ≤ height r s y := by + by_contra h + have hend : height r s y < height p q y := lt_of_not_ge h + let f : ℝ → ℝ := fun z => height p q z - height r s z + have hc : Continuous f := (height_continuous p q).sub (height_continuous r s) + have hfx : f x < 0 := sub_neg.mpr hstart + have hfy : 0 < f y := sub_pos.mpr hend + obtain ⟨z, hz, he⟩ := intermediate_value_Icc hxy.le hc.continuousOn ⟨hfx.le, hfy.le⟩ + have hxz : x < z := lt_of_le_of_ne hz.1 (by intro heq; subst z; exact ne_of_lt hfx he) + have hzy : z < y := lt_of_le_of_ne hz.2 (by intro heq; subst z; exact ne_of_gt hfy he) + have h₁ := height_point_openSegment p q (hp.trans_lt hxz) (hzy.trans_le hq) + have h₂ := height_point_openSegment r s (hr.trans_lt hxz) (hzy.trans_le hs) + have hv : height p q z = height r s z := sub_eq_zero.mp he + rw [← hv] at h₂ + exact Set.disjoint_left.mp hd h₁ h₂ + +def Position {V : Type*} (P : V → Point) : Prop := + Function.Injective P ∧ ∀ i j l, i ≠ j → j ≠ l → i ≠ l → + orient (P i) (P j) (P l) ≠ 0 + +variable {V : Type*} [Fintype V] {P : V → Point} + +structure Drawing (P : V → Point) where + vertices : Finset V + edges : Finset (V × V) + right : ∀ e ∈ edges, (P e.1).1 < (P e.2).1 + ends : ∀ e ∈ edges, e.1 ∈ vertices ∧ e.2 ∈ vertices + +def Drawing.NonCrossing (D : Drawing P) : Prop := + ∀ e ∈ D.edges, ∀ f ∈ D.edges, e ≠ f → + Disjoint (openSegment ℝ (P e.1) (P e.2)) (openSegment ℝ (P f.1) (P f.2)) + +omit [Fintype V] in +lemma slope_eq_implies_eq (hP : Position P) {v u w : V} + (hu : (P v).1 < (P u).1) (hw : (P v).1 < (P w).1) + (hs : PlanarHalving.slope (P v) (P u) = PlanarHalving.slope (P v) (P w)) : u = w := by + by_contra hn + have hvu : v ≠ u := by intro h; subst u; exact (lt_irrefl _ hu) + have hvw : v ≠ w := by intro h; subst w; exact (lt_irrefl _ hw) + have hyu := height_right (P v) (P u) hu.ne + have hyw := height_right (P v) (P w) hw.ne + rw [height, hs] at hyu + rw [height] at hyw + apply hP.2 v u w hvu hn hvw + unfold orient + have hu' : (P u).2 - (P v).2 = ((P u).1 - (P v).1) * PlanarHalving.slope (P v) (P w) := by linarith + have hw' : (P w).2 - (P v).2 = ((P w).1 - (P v).1) * PlanarHalving.slope (P v) (P w) := by linarith + rw [hu', hw'] + ring + +def IsGap (D : Drawing P) (g : V × V × V) : Prop := + (g.1, g.2.1) ∈ D.edges ∧ (g.1, g.2.2) ∈ D.edges ∧ + PlanarHalving.slope (P g.1) (P g.2.1) < PlanarHalving.slope (P g.1) (P g.2.2) ∧ + ∀ w, (g.1, w) ∈ D.edges → + PlanarHalving.slope (P g.1) (P g.2.1) < PlanarHalving.slope (P g.1) (P w) → + PlanarHalving.slope (P g.1) (P g.2.2) ≤ PlanarHalving.slope (P g.1) (P w) + +noncomputable def Drawing.gaps (D : Drawing P) : Finset (V × V × V) := + by classical exact Finset.univ.filter (IsGap D) + +lemma height_lt_height_iff (p u v : Point) {x : ℝ} (hx : p.1 < x) : + height p u x < height p v x ↔ PlanarHalving.slope p u < PlanarHalving.slope p v := by + simp only [height, add_lt_add_iff_left, mul_lt_mul_iff_right₀ (sub_pos.mpr hx)] + +lemma height_le_height_iff (p u v : Point) {x : ℝ} (hx : p.1 < x) : + height p u x ≤ height p v x ↔ PlanarHalving.slope p u ≤ PlanarHalving.slope p v := by + simp only [height, add_le_add_iff_left, mul_le_mul_iff_right₀ (sub_pos.mpr hx)] + +def InWedge (P : V → Point) (g : V × V × V) (q : V) : Prop := + (P g.1).1 < (P q).1 ∧ (P q).1 ≤ (P g.2.1).1 ∧ (P q).1 ≤ (P g.2.2).1 ∧ + height (P g.1) (P g.2.1) (P q).1 ≤ (P q).2 ∧ + (P q).2 ≤ height (P g.1) (P g.2.2) (P q).1 + +def FirstVertex (P : V → Point) (s : Finset V) (g : V × V × V) (q : V) : Prop := + InWedge P g q ∧ ∀ r ∈ s, InWedge P g r → (P q).1 ≤ (P r).1 + +omit [Fintype V] in +lemma IsGap.width_pos {D : Drawing P} {g : V × V × V} (hg : IsGap D g) + {x : ℝ} (hx : (P g.1).1 < x) : height (P g.1) (P g.2.1) x < height (P g.1) (P g.2.2) x := + (height_lt_height_iff _ _ _ hx).mpr hg.2.2.1 + +omit [Fintype V] in +lemma IsGap.exists_inWedge {D : Drawing P} {g : V × V × V} (hg : IsGap D g) : + ∃ q ∈ D.vertices, InWedge P g q := by + have hl := D.right _ hg.1 + have hu := D.right _ hg.2.1 + by_cases h : (P g.2.1).1 ≤ (P g.2.2).1 + · refine ⟨g.2.1, (D.ends _ hg.1).2, hl, le_rfl, h, ?_, ?_⟩ + · rw [height_right _ _ hl.ne] + · simpa only [height_right _ _ hl.ne] using (hg.width_pos hl).le + · refine ⟨g.2.2, (D.ends _ hg.2.1).2, hu, (not_le.mp h).le, le_rfl, ?_, ?_⟩ + · simpa only [height_right _ _ hu.ne] using (hg.width_pos hu).le + · rw [height_right _ _ hu.ne] + +omit [Fintype V] in +lemma IsGap.exists_firstVertex {D : Drawing P} {g : V × V × V} (hg : IsGap D g) : + ∃ q : ↥D.vertices, FirstVertex P D.vertices g q := by + classical + let W := D.vertices.filter (InWedge P g) + have he : W.Nonempty := by + obtain ⟨q, hqv, hq⟩ := hg.exists_inWedge + exact ⟨q, Finset.mem_filter.mpr ⟨hqv, hq⟩⟩ + obtain ⟨q, hq, hmin⟩ := W.exists_min_image (fun r => (P r).1) he + refine ⟨⟨q, (Finset.mem_filter.mp hq).1⟩, (Finset.mem_filter.mp hq).2, ?_⟩ + intro r hrv hr + exact hmin r (Finset.mem_filter.mpr ⟨hrv, hr⟩) + +omit [Fintype V] in +lemma IsGap.separated_of_same_source (hP : Position P) {D : Drawing P} + {g h : V × V × V} (hg : IsGap D g) (hh : IsGap D h) + (hsrc : g.1 = h.1) (hne : g ≠ h) {x : ℝ} (hx : (P g.1).1 < x) : + height (P g.1) (P g.2.2) x ≤ height (P h.1) (P h.2.1) x ∨ + height (P h.1) (P h.2.2) x ≤ height (P g.1) (P g.2.1) x := by + have hhl : (h.1, h.2.1) ∈ D.edges := hh.1 + have hhu : (h.1, h.2.2) ∈ D.edges := hh.2.1 + have hgl : (g.1, g.2.1) ∈ D.edges := hg.1 + have hgu : (g.1, g.2.2) ∈ D.edges := hg.2.1 + rcases lt_trichotomy (PlanarHalving.slope (P g.1) (P g.2.1)) + (PlanarHalving.slope (P h.1) (P h.2.1)) with hl | he | hl + · left + rw [← hsrc] at hhl hl ⊢ + exact (height_le_height_iff _ _ _ hx).mpr (hg.2.2.2 _ hhl hl) + · have hlower : g.2.1 = h.2.1 := by + rw [← hsrc] at hhl he + exact slope_eq_implies_eq hP (D.right _ hgl) (D.right _ hhl) he + have hupper : g.2.2 = h.2.2 := by + have hab := hh.2.2.1 + have hba := hg.2.2.1 + rw [← hsrc] at hab hhu + rw [← hlower] at hab + have hb := hg.2.2.2 _ hhu hab + rw [hsrc] at hba hgu + rw [hlower] at hba + have ha := hh.2.2.2 _ hgu hba + rw [← hsrc] at ha + exact slope_eq_implies_eq hP (v := g.1) + (D.right (g.1, g.2.2) hg.2.1) (D.right (g.1, h.2.2) hhu) (le_antisymm hb ha) + exact (hne (Prod.ext hsrc (Prod.ext hlower hupper))).elim + · right + rw [hsrc] at hgl hl hx ⊢ + exact (height_le_height_iff _ _ _ hx).mpr (hh.2.2.2 _ hgl hl) + +omit [Fintype V] in +lemma firstVertex_separated_of_source_lt {D : Drawing P} (hD : D.NonCrossing) + {g h : V × V × V} (hg : IsGap D g) (hh : IsGap D h) + {q : V} (hqg : FirstVertex P D.vertices g q) (hqh : FirstVertex P D.vertices h q) + (hsrc : (P g.1).1 < (P h.1).1) : + height (P g.1) (P g.2.2) (P q).1 ≤ height (P h.1) (P h.2.1) (P q).1 ∨ + height (P h.1) (P h.2.2) (P q).1 ≤ height (P g.1) (P g.2.1) (P q).1 := by + have hnot : ¬ (height (P g.1) (P g.2.1) (P h.1).1 ≤ (P h.1).2 ∧ + (P h.1).2 ≤ height (P g.1) (P g.2.2) (P h.1).1) := by + intro hi + have hw : InWedge P g h.1 := ⟨hsrc, hqh.1.1.le.trans hqg.1.2.1, + hqh.1.1.le.trans hqg.1.2.2.1, hi⟩ + exact (not_le_of_gt hqh.1.1) (hqg.2 _ (D.ends _ hh.1).1 hw) + have hneq : g.1 ≠ h.1 := by intro h; rw [h] at hsrc; exact lt_irrefl _ hsrc + rcases not_and_or.mp hnot with hlo | hup + · right + apply height_order (hD _ hh.2.1 _ hg.1 (by intro h; exact hneq (Prod.mk.inj h).1.symm)) + hqh.1.1 le_rfl hsrc.le hqh.1.2.2.1 hqg.1.2.1 + simpa only [height_left] using lt_of_not_ge hlo + · left + apply height_order (hD _ hg.2.1 _ hh.1 (by intro h; exact hneq (Prod.mk.inj h).1)) + hqh.1.1 hsrc.le le_rfl hqg.1.2.2.1 hqh.1.2.1 + simpa only [height_left] using lt_of_not_ge hup + +omit [Fintype V] in +lemma FirstVertex.separated (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) {D : Drawing P} (hD : D.NonCrossing) + {g h : V × V × V} (hg : IsGap D g) (hh : IsGap D h) + {q : V} (hqg : FirstVertex P D.vertices g q) (hqh : FirstVertex P D.vertices h q) (hne : g ≠ h) : + height (P g.1) (P g.2.2) (P q).1 ≤ height (P h.1) (P h.2.1) (P q).1 ∨ + height (P h.1) (P h.2.2) (P q).1 ≤ height (P g.1) (P g.2.1) (P q).1 := by + rcases lt_trichotomy (P g.1).1 (P h.1).1 with hl | he | hl + · exact firstVertex_separated_of_source_lt hD hg hh hqg hqh hl + · exact hg.separated_of_same_source hP hh (hx he) hne hqg.1.1 + · exact (firstVertex_separated_of_source_lt hD hh hg hqh hqg hl).symm + +noncomputable def Drawing.first (D : Drawing P) (g : ↥D.gaps) : ↥D.vertices := + by classical exact Classical.choose ((Finset.mem_filter.mp g.property).2.exists_firstVertex) + +lemma Drawing.first_spec (D : Drawing P) (g : ↥D.gaps) : FirstVertex P D.vertices g.val (D.first g) := + by classical exact Classical.choose_spec ((Finset.mem_filter.mp g.property).2.exists_firstVertex) + +noncomputable def Drawing.gapCharge (D : Drawing P) (g : ↥D.gaps) : ↥D.vertices × Bool := + by classical exact (D.first g, decide + (height (P g.val.1) (P g.val.2.1) (P (D.first g)).1 < (P (D.first g)).2)) + +lemma Drawing.gapCharge_injective (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) (hD : D.NonCrossing) : + Function.Injective D.gapCharge := by + classical + intro g h he + apply Subtype.ext + by_contra hne + have hq : D.first g = D.first h := congrArg Prod.fst he + have hb := congrArg Prod.snd he + change decide (height (P g.val.1) (P g.val.2.1) (P (D.first g)).1 < (P (D.first g)).2) = + decide (height (P h.val.1) (P h.val.2.1) (P (D.first h)).1 < (P (D.first h)).2) at hb + rw [← hq] at hb + have hg : IsGap D g.val := (Finset.mem_filter.mp g.property).2 + have hh : IsGap D h.val := (Finset.mem_filter.mp h.property).2 + have hfg := D.first_spec g + have hfh := D.first_spec h + rw [← hq] at hfh + have hgwidth := hg.width_pos hfg.1.1 + have hhwidth := hh.width_pos hfh.1.1 + rcases FirstVertex.separated hP hx hD hg hh hfg hfh hne with hsep | hsep + · have htrue : height (P g.val.1) (P g.val.2.1) (P (D.first g)).1 < (P (D.first g)).2 := + hgwidth.trans_le (hsep.trans hfh.1.2.2.2.1) + have hfalse : ¬ height (P h.val.1) (P h.val.2.1) (P (D.first g)).1 < (P (D.first g)).2 := by + linarith only [hsep, hfg.1.2.2.2.2] + simp [htrue, hfalse] at hb + · have htrue : height (P h.val.1) (P h.val.2.1) (P (D.first g)).1 < (P (D.first g)).2 := + hhwidth.trans_le (hsep.trans hfg.1.2.2.2.1) + have hfalse : ¬ height (P g.val.1) (P g.val.2.1) (P (D.first g)).1 < (P (D.first g)).2 := by + linarith only [hsep, hfh.1.2.2.2.2] + simp [htrue, hfalse] at hb + +lemma Drawing.card_gaps_le (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) (hD : D.NonCrossing) : + D.gaps.card ≤ 2 * D.vertices.card := by + have h := Fintype.card_le_of_injective D.gapCharge (D.gapCharge_injective hP hx hD) + simpa only [Fintype.card_coe, Fintype.card_prod, Fintype.card_bool, + Nat.mul_comm] using h + +lemma Drawing.exists_next_gap (D : Drawing P) {v u : V} (he : (v,u) ∈ D.edges) + (hh : ∃ w, (v,w) ∈ D.edges ∧ PlanarHalving.slope (P v) (P u) < PlanarHalving.slope (P v) (P w)) : + ∃ w, IsGap D (v,u,w) := by + classical + let W := Finset.univ.filter (fun w => (v,w) ∈ D.edges ∧ + PlanarHalving.slope (P v) (P u) < PlanarHalving.slope (P v) (P w)) + have hw : W.Nonempty := by obtain ⟨w, hw⟩ := hh; exact ⟨w, by simpa [W] using hw⟩ + obtain ⟨w, hw, hmin⟩ := W.exists_min_image (fun w => PlanarHalving.slope (P v) (P w)) hw + have hp := (Finset.mem_filter.mp hw).2 + refine ⟨w, he, hp.1, hp.2, ?_⟩ + intro r hr hs + exact hmin r (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hr, hs⟩) + +noncomputable def Drawing.edgeCharge (D : Drawing P) (e : ↥D.edges) : ↥D.vertices ⊕ ↥D.gaps := by + classical + exact if h : ∃ w, IsGap D (e.val.1, e.val.2, w) then + Sum.inr ⟨(e.val.1, e.val.2, Classical.choose h), Finset.mem_filter.mpr + ⟨Finset.mem_univ _, Classical.choose_spec h⟩⟩ + else Sum.inl ⟨e.val.1, (D.ends _ e.property).1⟩ + +lemma Drawing.edgeCharge_injective (hP : Position P) (D : Drawing P) : + Function.Injective D.edgeCharge := by + classical + intro e f he + dsimp only [Drawing.edgeCharge] at he + split_ifs at he with hg hh + · have heq := congrArg Subtype.val (Sum.inr.inj he) + apply Subtype.ext + exact Prod.ext (Prod.mk.inj heq).1 (Prod.mk.inj (Prod.mk.inj heq).2).1 + · rename_i hh + have hsrc : e.val.1 = f.val.1 := congrArg Subtype.val (Sum.inl.inj he) + have hemax : ¬ ∃ w, (e.val.1, w) ∈ D.edges ∧ + PlanarHalving.slope (P e.val.1) (P e.val.2) < PlanarHalving.slope (P e.val.1) (P w) := + fun h => hg (D.exists_next_gap e.property h) + have hfmax : ¬ ∃ w, (f.val.1, w) ∈ D.edges ∧ + PlanarHalving.slope (P f.val.1) (P f.val.2) < PlanarHalving.slope (P f.val.1) (P w) := + fun h => hh (D.exists_next_gap f.property h) + have hef : PlanarHalving.slope (P e.val.1) (P e.val.2) ≤ + PlanarHalving.slope (P f.val.1) (P f.val.2) := by + by_contra h + apply hfmax + refine ⟨e.val.2, ?_, ?_⟩ + · simpa only [← hsrc, Prod.mk.eta] using e.property + · simpa only [← hsrc] using lt_of_not_ge h + have hfe : PlanarHalving.slope (P f.val.1) (P f.val.2) ≤ + PlanarHalving.slope (P e.val.1) (P e.val.2) := by + by_contra h + apply hemax + refine ⟨f.val.2, ?_, ?_⟩ + · simpa only [hsrc, Prod.mk.eta] using f.property + · simpa only [hsrc] using lt_of_not_ge h + have hright := D.right f.val f.property + have heq := le_antisymm hef hfe + rw [← hsrc] at hright heq + have htarget := slope_eq_implies_eq hP (D.right e.val e.property) hright heq + exact Subtype.ext (Prod.ext hsrc htarget) + +theorem Drawing.planar_bound (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) (hD : D.NonCrossing) : + D.edges.card ≤ 3 * D.vertices.card := by + have hc := Fintype.card_le_of_injective D.edgeCharge (D.edgeCharge_injective hP) + have hcard : D.edges.card ≤ D.vertices.card + D.gaps.card := by + simpa only [Fintype.card_coe, Fintype.card_sum] using hc + have hg := D.card_gaps_le hP hx hD + omega + +omit [Fintype V] in +lemma slope_eq_implies_eq_ne (hP : Position P) {v u w : V} + (hu : (P v).1 ≠ (P u).1) (hw : (P v).1 ≠ (P w).1) + (hs : PlanarHalving.slope (P v) (P u) = PlanarHalving.slope (P v) (P w)) : u = w := by + by_contra hn + have hvu : v ≠ u := fun h => hu (congrArg (fun i => (P i).1) h) + have hvw : v ≠ w := fun h => hw (congrArg (fun i => (P i).1) h) + have hyu := height_right (P v) (P u) hu + have hyw := height_right (P v) (P w) hw + rw [height, hs] at hyu + rw [height] at hyw + apply hP.2 v u w hvu hn hvw + unfold orient + have hu' : (P u).2 - (P v).2 = ((P u).1 - (P v).1) * PlanarHalving.slope (P v) (P w) := by linarith + have hw' : (P w).2 - (P v).2 = ((P w).1 - (P v).1) * PlanarHalving.slope (P v) (P w) := by linarith + rw [hu', hw'] + ring + +lemma height_of_mem_openSegment {p q z : Point} (hx : p.1 ≠ q.1) + (hz : z ∈ openSegment ℝ p q) : z.1 ≠ p.1 ∧ z.2 = height p q z.1 := by + rw [openSegment_eq_image] at hz + obtain ⟨t, ht, rfl⟩ := hz + have hd : q.1 - p.1 ≠ 0 := sub_ne_zero.mpr hx.symm + simp only [Prod.fst_add, Prod.snd_add, Prod.smul_fst, Prod.smul_snd, smul_eq_mul] + constructor + · have hmul : t * (q.1 - p.1) ≠ 0 := mul_ne_zero ht.1.ne' hd + intro he + apply hmul + linarith + · unfold height PlanarHalving.slope + field_simp + ring + +lemma openSegment_horizontal_bounds {p q z : Point} (hx : p.1 < q.1) + (hz : z ∈ openSegment ℝ p q) : p.1 < z.1 ∧ z.1 < q.1 := by + rw [openSegment_eq_image] at hz + obtain ⟨t, ht, rfl⟩ := hz + simp only [Prod.fst_add, Prod.smul_fst, smul_eq_mul] + constructor <;> nlinarith [mul_pos ht.1 (sub_pos.mpr hx), + mul_pos (sub_pos.mpr ht.2) (sub_pos.mpr hx)] + +omit [Fintype V] in +lemma incident_disjoint (hP : Position P) (hx : Function.Injective (fun v => (P v).1)) + {v u w : V} (hvu : v ≠ u) (hvw : v ≠ w) (huw : u ≠ w) : + Disjoint (openSegment ℝ (P v) (P u)) (openSegment ℝ (P v) (P w)) := by + apply Set.disjoint_left.mpr + intro z hzu hzw + have hu := height_of_mem_openSegment (fun h => hvu (hx h)) hzu + have hw := height_of_mem_openSegment (fun h => hvw (hx h)) hzw + have he : PlanarHalving.slope (P v) (P u) = PlanarHalving.slope (P v) (P w) := by + apply mul_left_cancel₀ (sub_ne_zero.mpr hu.1) + dsimp only [height] at hu hw + linarith only [hu.2, hw.2] + exact huw (slope_eq_implies_eq_ne hP (fun h => hvu (hx h)) (fun h => hvw (hx h)) he) + +def Crosses (P : V → Point) (e f : V × V) : Prop := + ¬ Disjoint (openSegment ℝ (P e.1) (P e.2)) (openSegment ℝ (P f.1) (P f.2)) + +omit [Fintype V] in +lemma Drawing.crossing_endpoints (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) + {e f : V × V} (he : e ∈ D.edges) (hf : f ∈ D.edges) (hne : e ≠ f) + (hc : Crosses P e f) : + e.1 ≠ e.2 ∧ f.1 ≠ f.2 ∧ e.1 ≠ f.1 ∧ e.1 ≠ f.2 ∧ e.2 ≠ f.1 ∧ e.2 ≠ f.2 := by + have hev : e.1 ≠ e.2 := by intro h; have := D.right _ he; rw [h] at this; exact lt_irrefl _ this + have hfv : f.1 ≠ f.2 := by intro h; have := D.right _ hf; rw [h] at this; exact lt_irrefl _ this + have h11 : e.1 ≠ f.1 := by + intro h + apply hc + rw [h] + exact incident_disjoint hP hx (by simpa only [← h] using hev) hfv + (fun h' => hne (Prod.ext h h')) + have h22 : e.2 ≠ f.2 := by + intro h + apply hc + rw [openSegment_symm ℝ (P e.1), openSegment_symm ℝ (P f.1), h] + exact incident_disjoint hP hx (by simpa only [← h] using hev.symm) hfv.symm + (fun h' => hne (Prod.ext h' h)) + obtain ⟨z, hze, hzf⟩ := Set.not_disjoint_iff.mp hc + have hxe := openSegment_horizontal_bounds (D.right _ he) hze + have hxf := openSegment_horizontal_bounds (D.right _ hf) hzf + refine ⟨hev, hfv, h11, ?_, ?_, h22⟩ + · intro h + rw [h] at hxe + exact lt_irrefl _ (hxe.1.trans hxf.2) + · intro h + rw [h] at hxe + exact lt_irrefl _ (hxf.1.trans hxe.2) + +noncomputable def edgeIndex : (V × V) ≃ Fin (Fintype.card (V × V)) := Fintype.equivFin _ + +noncomputable def Drawing.crossings (D : Drawing P) : Finset ((V × V) × (V × V)) := by + classical + exact (D.edges ×ˢ D.edges).filter (fun ef => edgeIndex ef.1 < edgeIndex ef.2 ∧ Crosses P ef.1 ef.2) + +noncomputable def Drawing.uncross (D : Drawing P) : Drawing P := by + classical + exact ⟨D.vertices, D.edges \ D.crossings.image Prod.fst, + fun e he => D.right e (Finset.mem_sdiff.mp he).1, + fun e he => D.ends e (Finset.mem_sdiff.mp he).1⟩ + +lemma Drawing.uncross_nonCrossing (D : Drawing P) : D.uncross.NonCrossing := by + classical + intro e he f hf hne + by_contra hc + have he' := Finset.mem_sdiff.mp he + have hf' := Finset.mem_sdiff.mp hf + have hi : edgeIndex e ≠ edgeIndex f := fun h => hne (edgeIndex.injective h) + rcases hi.lt_or_gt with hlt | hlt + · apply he'.2 + exact Finset.mem_image.mpr ⟨(e,f), Finset.mem_filter.mpr + ⟨Finset.mem_product.mpr ⟨he'.1, hf'.1⟩, hlt, hc⟩, rfl⟩ + · apply hf'.2 + exact Finset.mem_image.mpr ⟨(f,e), Finset.mem_filter.mpr + ⟨Finset.mem_product.mpr ⟨hf'.1, he'.1⟩, hlt, fun h => hc h.symm⟩, rfl⟩ + +theorem Drawing.linear_crossing_bound (hP : Position P) + (hx : Function.Injective (fun v => (P v).1)) (D : Drawing P) : + D.edges.card ≤ 3 * D.vertices.card + D.crossings.card := by + classical + have hp := D.uncross.planar_bound hP hx D.uncross_nonCrossing + change (D.edges \ D.crossings.image Prod.fst).card ≤ 3 * D.vertices.card at hp + have hi : (D.edges ∩ D.crossings.image Prod.fst).card ≤ D.crossings.card := + (Finset.card_le_card Finset.inter_subset_right).trans (Finset.card_image_le) + have he := Finset.card_sdiff_add_card_inter D.edges (D.crossings.image Prod.fst) + omega + +end PlaneGraph +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/RankCoordinates.lean b/lean/OAI/Combinatorics/HalvingLines/RankCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..45da76f11575de917ca395a64328d40848a317e4 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/RankCoordinates.lean @@ -0,0 +1,398 @@ +import OAI.Combinatorics.HalvingLines.Compactness + +namespace OAI + +open Filter Topology +namespace PlanarHalving.RankCoordinates + +abbrev UnitOpen := Set.Ioo (0 : ℝ) 1 + +structure Coordinate (l u : ℝ) where + value : ℝ × ℝ → ℝ + continuous_value : Continuous value + mem : ∀ p, value p ∈ Set.Ioo 0 1 + strict_vertical : ∀ x, StrictMono (fun y => value (x,y)) + onto_vertical : ∀ x (v : UnitOpen), ∃ y, value (x,y) = v + translate_lower : ∀ x y h, 0 ≤ h → value (x+h,y+l*h) ≤ value (x,y) + translate_upper : ∀ x y h, 0 ≤ h → value (x,y) ≤ value (x+h,y+u*h) + +namespace Coordinate +variable {l u : ℝ} (R : Coordinate l u) + +noncomputable def level (x : ℝ) (v : UnitOpen) : ℝ := + Classical.choose (R.onto_vertical x v) + +lemma value_level (x : ℝ) (v : UnitOpen) : R.value (x,R.level x v) = v := + Classical.choose_spec (R.onto_vertical x v) + +lemma level_value (x y : ℝ) : R.level x ⟨R.value (x,y), R.mem (x,y)⟩ = y := + (R.strict_vertical x).injective (R.value_level x _) + +lemma lt_level_iff (x y : ℝ) (v : UnitOpen) : y < R.level x v ↔ R.value (x,y) < v := by + rw [← R.value_level x v] + exact (R.strict_vertical x).lt_iff_lt.symm + +lemma level_lt_iff (x y : ℝ) (v : UnitOpen) : R.level x v < y ↔ (v : ℝ) < R.value (x,y) := by + rw [← R.value_level x v] + exact (R.strict_vertical x).lt_iff_lt.symm + +lemma le_level_iff (x y : ℝ) (v : UnitOpen) : y ≤ R.level x v ↔ R.value (x,y) ≤ v := by + rw [← R.value_level x v] + exact (R.strict_vertical x).le_iff_le.symm + +lemma level_le_iff (x y : ℝ) (v : UnitOpen) : R.level x v ≤ y ↔ (v : ℝ) ≤ R.value (x,y) := by + rw [← R.value_level x v] + exact (R.strict_vertical x).le_iff_le.symm + +lemma continuous_level : Continuous (fun p : ℝ × UnitOpen => R.level p.1 p.2) := by + refine continuous_iff_continuousAt.mpr fun p => tendsto_order.mpr ⟨?_, ?_⟩ + · intro a ha + have h := (R.lt_level_iff p.1 a p.2).mp ha + have hr : Continuous (fun q : ℝ × UnitOpen => R.value (q.1,a)) := + R.continuous_value.comp (continuous_fst.prodMk continuous_const) + have hv : Continuous (fun q : ℝ × UnitOpen => (q.2 : ℝ)) := + continuous_subtype_val.comp continuous_snd + filter_upwards [hr.continuousAt.eventually_lt hv.continuousAt h] with q hq + exact (R.lt_level_iff q.1 a q.2).mpr hq + · intro a ha + have h := (R.level_lt_iff p.1 a p.2).mp ha + have hr : Continuous (fun q : ℝ × UnitOpen => R.value (q.1,a)) := + R.continuous_value.comp (continuous_fst.prodMk continuous_const) + have hv : Continuous (fun q : ℝ × UnitOpen => (q.2 : ℝ)) := + continuous_subtype_val.comp continuous_snd + filter_upwards [hv.continuousAt.eventually_lt hr.continuousAt h] with q hq + exact (R.level_lt_iff q.1 a q.2).mpr hq + +lemma level_slope {x x' : ℝ} (h : x ≤ x') (v : UnitOpen) : + l*(x'-x) ≤ R.level x' v - R.level x v ∧ + R.level x' v - R.level x v ≤ u*(x'-x) := by + have h₁ := R.translate_lower x (R.level x v) (x'-x) (sub_nonneg.mpr h) + have h₂ := R.translate_upper x (R.level x v) (x'-x) (sub_nonneg.mpr h) + rw [R.value_level] at h₁ h₂ + have he : x + (x'-x) = x' := by ring + rw [he] at h₁ h₂ + have hl := (R.le_level_iff x' (R.level x v + l*(x'-x)) v).mpr h₁ + have hu := (R.level_le_iff x' (R.level x v + u*(x'-x)) v).mpr h₂ + constructor <;> linarith + +end Coordinate + +lemma exists_zero_of_strongAnti {f : ℝ → ℝ} (hf : Continuous f) {d : ℝ} + (hd : 0 < d) (hs : ∀ x x', x ≤ x' → f x' - f x ≤ -d*(x'-x)) : + ∃ x, f x = 0 := by + let t := (|f 0|+1)/d + have ht : 0 < t := div_pos (by positivity) hd + have htprod : d*t = |f 0|+1 := by dsimp [t]; field_simp + have hleft := hs (-t) 0 (by linarith) + have hright := hs 0 t ht.le + have hzero : (0:ℝ) ∈ Set.Icc (f t) (f (-t)) := by + constructor + · have h := le_abs_self (f 0); nlinarith + · have h := neg_abs_le (f 0); nlinarith + exact intermediate_value_univ t (-t) hf hzero + +variable {lA uA lB uB : ℝ} (A : Coordinate lA uA) (B : Coordinate lB uB) + +noncomputable def levelDiff (v : UnitOpen × UnitOpen) (x : ℝ) : ℝ := + A.level x v.1 - B.level x v.2 + +lemma continuous_levelDiff : Continuous (fun p : (UnitOpen × UnitOpen) × ℝ => + levelDiff A B p.1 p.2) := by + exact (A.continuous_level.comp (continuous_snd.prodMk continuous_fst.fst)).sub + (B.continuous_level.comp (continuous_snd.prodMk continuous_fst.snd)) + +lemma levelDiff_decay (v : UnitOpen × UnitOpen) {x x' : ℝ} (h : x ≤ x') : + levelDiff A B v x' - levelDiff A B v x ≤ -(lB-uA)*(x'-x) := by + have ha := (A.level_slope h v.1).2 + have hb := (B.level_slope h v.2).1 + dsimp [levelDiff] + nlinarith only [ha, hb] + +lemma levelDiff_strictAnti (hgap : uA < lB) (v : UnitOpen × UnitOpen) : + StrictAnti (levelDiff A B v) := by + intro x x' h + have hh := levelDiff_decay A B v h.le + have hp : 0 < (lB-uA)*(x'-x) := mul_pos (sub_pos.mpr hgap) (sub_pos.mpr h) + linarith + +lemma exists_intersection (hgap : uA < lB) (v : UnitOpen × UnitOpen) : + ∃ x, levelDiff A B v x = 0 := by + exact exists_zero_of_strongAnti + ((continuous_levelDiff A B).comp (continuous_const.prodMk continuous_id)) + (sub_pos.mpr hgap) (fun _ _ h => levelDiff_decay A B v h) + +noncomputable def intersectionX (hgap : uA < lB) (v : UnitOpen × UnitOpen) : ℝ := + Classical.choose (exists_intersection A B hgap v) + +lemma levelDiff_intersectionX (hgap : uA < lB) (v : UnitOpen × UnitOpen) : + levelDiff A B v (intersectionX A B hgap v) = 0 := + Classical.choose_spec (exists_intersection A B hgap v) + +lemma lt_intersectionX_iff (hgap : uA < lB) (v : UnitOpen × UnitOpen) (x : ℝ) : + x < intersectionX A B hgap v ↔ 0 < levelDiff A B v x := by + rw [← levelDiff_intersectionX A B hgap v] + exact (levelDiff_strictAnti A B hgap v).lt_iff_gt.symm + +lemma intersectionX_lt_iff (hgap : uA < lB) (v : UnitOpen × UnitOpen) (x : ℝ) : + intersectionX A B hgap v < x ↔ levelDiff A B v x < 0 := by + rw [← levelDiff_intersectionX A B hgap v] + exact (levelDiff_strictAnti A B hgap v).lt_iff_gt.symm + +lemma continuous_intersectionX (hgap : uA < lB) : Continuous (intersectionX A B hgap) := by + refine continuous_iff_continuousAt.mpr fun v => tendsto_order.mpr ⟨?_, ?_⟩ + · intro a ha + have h := (lt_intersectionX_iff A B hgap v a).mp ha + have hc := (continuous_levelDiff A B).comp (continuous_id.prodMk (continuous_const : Continuous fun _ : UnitOpen × UnitOpen => a)) + filter_upwards [continuousAt_const.eventually_lt hc.continuousAt h] with w hw + exact (lt_intersectionX_iff A B hgap w a).mpr hw + · intro a ha + have h := (intersectionX_lt_iff A B hgap v a).mp ha + have hc := (continuous_levelDiff A B).comp (continuous_id.prodMk (continuous_const : Continuous fun _ : UnitOpen × UnitOpen => a)) + filter_upwards [hc.continuousAt.eventually_lt continuousAt_const h] with w hw + exact (intersectionX_lt_iff A B hgap w a).mpr hw + +noncomputable def pairHomeomorph (hgap : uA < lB) : + (ℝ × ℝ) ≃ₜ (UnitOpen × UnitOpen) where + toFun p := (⟨A.value p,A.mem p⟩, ⟨B.value p,B.mem p⟩) + invFun v := (intersectionX A B hgap v, A.level (intersectionX A B hgap v) v.1) + left_inv p := by + let v : UnitOpen × UnitOpen := (⟨A.value p,A.mem p⟩, ⟨B.value p,B.mem p⟩) + have hz : levelDiff A B v p.1 = 0 := by + dsimp [levelDiff,v] + rw [A.level_value, B.level_value] + ring + have he : intersectionX A B hgap v = p.1 := + (levelDiff_strictAnti A B hgap v).injective + ((levelDiff_intersectionX A B hgap v).trans hz.symm) + change (intersectionX A B hgap v, A.level (intersectionX A B hgap v) v.1) = p + rw [he] + dsimp [v] + rw [A.level_value] + right_inv v := by + have he : A.level (intersectionX A B hgap v) v.1 = + B.level (intersectionX A B hgap v) v.2 := + sub_eq_zero.mp (levelDiff_intersectionX A B hgap v) + apply Prod.ext <;> apply Subtype.ext + · exact A.value_level _ _ + · change B.value (_, A.level _ v.1) = _ + rw [he, B.value_level] + continuous_toFun := (A.continuous_value.subtype_mk _).prodMk (B.continuous_value.subtype_mk _) + continuous_invFun := (continuous_intersectionX A B hgap).prodMk + (A.continuous_level.comp ((continuous_intersectionX A B hgap).prodMk continuous_fst)) + +noncomputable def smoothed {m : ℕ} (g : Fin m → ℝ → ℝ) (ε : ℝ) (p : ℝ × ℝ) : ℝ := + (∑ i, Real.sigmoid ((p.2 - g i p.1)/ε)) / m + +lemma continuous_smoothed {m : ℕ} (g : Fin m → ℝ → ℝ) (ε : ℝ) + (hg : ∀ i, Continuous (g i)) : Continuous (smoothed g ε) := by + unfold smoothed + fun_prop + +lemma smoothed_mem {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) (ε : ℝ) (p : ℝ × ℝ) : + smoothed g ε p ∈ Set.Ioo 0 1 := by + have hmR : (0:ℝ) < m := Nat.cast_pos.mpr hm + have hn : (Finset.univ : Finset (Fin m)).Nonempty := ⟨⟨0,hm⟩, Finset.mem_univ _⟩ + constructor + · exact div_pos (Finset.sum_pos (fun i _ => Real.sigmoid_pos _) hn) hmR + · apply (div_lt_iff₀ hmR).mpr + have hs := Finset.sum_lt_sum (s := (Finset.univ : Finset (Fin m))) + (f := fun i => Real.sigmoid ((p.2 - g i p.1)/ε)) (g := fun _ => (1:ℝ)) + (fun i _ => (Real.sigmoid_lt_one _).le) + ⟨⟨0,hm⟩, Finset.mem_univ _, Real.sigmoid_lt_one _⟩ + simpa using hs + +lemma strict_vertical_smoothed {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + {ε : ℝ} (hε : 0 < ε) (x : ℝ) : StrictMono (fun y => smoothed g ε (x,y)) := by + intro y y' h + apply div_lt_div_of_pos_right _ (Nat.cast_pos.mpr hm) + apply Finset.sum_lt_sum + · intro i _ + exact (Real.sigmoid_strictMono (div_lt_div_of_pos_right (sub_lt_sub_right h _) hε)).le + · exact ⟨⟨0,hm⟩, Finset.mem_univ _, + Real.sigmoid_strictMono (div_lt_div_of_pos_right (sub_lt_sub_right h _) hε)⟩ + +lemma onto_vertical_smoothed {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + {ε : ℝ} (hε : 0 < ε) (x : ℝ) (v : UnitOpen) : + ∃ y, smoothed g ε (x,y) = v := by + obtain ⟨t, ht⟩ : (v : ℝ) ∈ Set.range Real.sigmoid := by + rw [Real.range_sigmoid] + exact v.property + let T : ℝ := ∑ i, |g i x + ε*t| + have hT (i : Fin m) : |g i x+ε*t| ≤ T := + Finset.single_le_sum (fun j _ => abs_nonneg (g j x+ε*t)) (Finset.mem_univ i) + have hlo (i : Fin m) : (-T - g i x)/ε ≤ t := by + apply (div_le_iff₀ hε).mpr + have h := (neg_abs_le (g i x+ε*t)).trans' (neg_le_neg (hT i)) + linarith + have hhi (i : Fin m) : t ≤ (T - g i x)/ε := by + apply (le_div_iff₀ hε).mpr + have h := (le_abs_self (g i x+ε*t)).trans (hT i) + linarith + have hleft : smoothed g ε (x,-T) ≤ v := by + apply (div_le_iff₀ (Nat.cast_pos.mpr hm)).mpr + have h := Finset.sum_le_sum (s := (Finset.univ : Finset (Fin m))) + (fun i _ => Real.sigmoid_monotone (hlo i)) + simpa only [ht, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_comm] using h + have hright : (v : ℝ) ≤ smoothed g ε (x,T) := by + apply (le_div_iff₀ (Nat.cast_pos.mpr hm)).mpr + have h := Finset.sum_le_sum (s := (Finset.univ : Finset (Fin m))) + (fun i _ => Real.sigmoid_monotone (hhi i)) + simpa only [ht, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_comm] using h + have hc : Continuous (fun y => smoothed g ε (x,y)) := by + simp only [smoothed] + fun_prop + exact intermediate_value_univ (-T) T hc ⟨hleft,hright⟩ + +noncomputable def smoothedCoordinate {m : ℕ} (hm : 0 < m) (g : Fin m → ℝ → ℝ) + {ε l u : ℝ} (hε : 0 < ε) (hg : ∀ i, Continuous (g i)) + (hs : ∀ i x x', x ≤ x' → l*(x'-x) ≤ g i x'-g i x ∧ g i x'-g i x ≤ u*(x'-x)) : + Coordinate l u where + value := smoothed g ε + continuous_value := continuous_smoothed g ε hg + mem := smoothed_mem hm g ε + strict_vertical := strict_vertical_smoothed hm g hε + onto_vertical := onto_vertical_smoothed hm g hε + translate_lower x y h hh := by + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg m) + apply Finset.sum_le_sum + intro i _ + apply Real.sigmoid_monotone + apply (div_le_div_iff_of_pos_right hε).mpr + have he := (hs i x (x+h) (by linarith)).1 + dsimp + linarith + translate_upper x y h hh := by + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg m) + apply Finset.sum_le_sum + intro i _ + apply Real.sigmoid_monotone + apply (div_le_div_iff_of_pos_right hε).mpr + have he := (hs i x (x+h) (by linarith)).2 + dsimp + linarith + +namespace Coordinate +variable {lR uR lS uS : ℝ} (R : Coordinate lR uR) (S : Coordinate lS uS) + +lemma strictMono_along_level (hgap : uR < lS) (v : UnitOpen) : + StrictMono (fun x => R.value (x,S.level x v)) := by + intro x x' h + have hh := R.translate_upper x (S.level x v) (x'-x) (sub_nonneg.mpr h.le) + rw [show x+(x'-x) = x' by ring] at hh + have hprod : uR*(x'-x) < lS*(x'-x) := mul_lt_mul_of_pos_right hgap (sub_pos.mpr h) + have hs := (S.level_slope h.le v).1 + exact hh.trans_lt (R.strict_vertical x' (by linarith : + S.level x v+uR*(x'-x) < S.level x' v)) + +lemma strictAnti_along_level (hgap : uS < lR) (v : UnitOpen) : + StrictAnti (fun x => R.value (x,S.level x v)) := by + intro x x' h + have hh := R.translate_lower x (S.level x v) (x'-x) (sub_nonneg.mpr h.le) + rw [show x+(x'-x) = x' by ring] at hh + have hprod : uS*(x'-x) < lR*(x'-x) := mul_lt_mul_of_pos_right hgap (sub_pos.mpr h) + have hs := (S.level_slope h.le v).2 + exact (R.strict_vertical x' (by linarith : + S.level x' v < S.level x v+lR*(x'-x))).trans_le hh + +end Coordinate + +lemma value_pair_inverse_fst (hgap : uA < lB) (v : UnitOpen × UnitOpen) : + A.value ((pairHomeomorph A B hgap).symm v) = v.1 := + congrArg (fun w : UnitOpen × UnitOpen => (w.1:ℝ)) ((pairHomeomorph A B hgap).apply_symm_apply v) + +lemma value_pair_inverse_snd (hgap : uA < lB) (v : UnitOpen × UnitOpen) : + B.value ((pairHomeomorph A B hgap).symm v) = v.2 := + congrArg (fun w : UnitOpen × UnitOpen => (w.2:ℝ)) ((pairHomeomorph A B hgap).apply_symm_apply v) + +lemma pair_inverse_snd_levelA (hgap : uA < lB) (v : UnitOpen × UnitOpen) : + ((pairHomeomorph A B hgap).symm v).2 = A.level ((pairHomeomorph A B hgap).symm v).1 v.1 := rfl + +lemma pair_inverse_snd_levelB (hgap : uA < lB) (v : UnitOpen × UnitOpen) : + ((pairHomeomorph A B hgap).symm v).2 = B.level ((pairHomeomorph A B hgap).symm v).1 v.2 := by + apply (B.strict_vertical ((pairHomeomorph A B hgap).symm v).1).injective + dsimp only + rw [B.value_level] + exact value_pair_inverse_snd A B hgap v + +lemma inverseX_mono_left (hgap : uA < lB) (v : UnitOpen) : + Monotone (fun u : UnitOpen => ((pairHomeomorph A B hgap).symm (u,v)).1) := by + intro u u' huu + apply (A.strictMono_along_level B hgap v).le_iff_le.mp + have h₁ := value_pair_inverse_fst A B hgap (u,v) + have h₂ := value_pair_inverse_fst A B hgap (u',v) + conv_lhs at h₁ => rw [← Prod.eta ((pairHomeomorph A B hgap).symm (u,v))] + conv_lhs at h₂ => rw [← Prod.eta ((pairHomeomorph A B hgap).symm (u',v))] + rw [pair_inverse_snd_levelB] at h₁ h₂ + change A.value (_, B.level _ v) = (u:ℝ) at h₁ + change A.value (_, B.level _ v) = (u':ℝ) at h₂ + rw [h₁,h₂] + exact huu + +lemma inverseX_anti_right (hgap : uA < lB) (u : UnitOpen) : + Antitone (fun v : UnitOpen => ((pairHomeomorph A B hgap).symm (u,v)).1) := by + intro v v' hvv + apply (B.strictAnti_along_level A hgap u).le_iff_ge.mp + have h₁ := value_pair_inverse_snd A B hgap (u,v) + have h₂ := value_pair_inverse_snd A B hgap (u,v') + conv_lhs at h₁ => rw [← Prod.eta ((pairHomeomorph A B hgap).symm (u,v))] + conv_lhs at h₂ => rw [← Prod.eta ((pairHomeomorph A B hgap).symm (u,v'))] + rw [pair_inverse_snd_levelA] at h₁ h₂ + change B.value (_, A.level _ u) = (v:ℝ) at h₁ + change B.value (_, A.level _ u) = (v':ℝ) at h₂ + rw [h₁,h₂] + exact hvv + +noncomputable def inCoordinates {lC uC : ℝ} (hgap : uA < lB) + (C : Coordinate lC uC) (v : UnitOpen × UnitOpen) : ℝ := + C.value ((pairHomeomorph A B hgap).symm v) + +lemma inCoordinates_eq_levelA {lC uC : ℝ} (hgap : uA < lB) + (C : Coordinate lC uC) (v : UnitOpen × UnitOpen) : + inCoordinates A B hgap C v = C.value + (((pairHomeomorph A B hgap).symm v).1, + A.level ((pairHomeomorph A B hgap).symm v).1 v.1) := rfl + +lemma inCoordinates_eq_levelB {lC uC : ℝ} (hgap : uA < lB) + (C : Coordinate lC uC) (v : UnitOpen × UnitOpen) : + inCoordinates A B hgap C v = C.value + (((pairHomeomorph A B hgap).symm v).1, + B.level ((pairHomeomorph A B hgap).symm v).1 v.2) := by + unfold inCoordinates + conv_lhs => rw [← Prod.eta ((pairHomeomorph A B hgap).symm v)] + rw [pair_inverse_snd_levelB] + +lemma inCoordinates_monotone_left {lC uC : ℝ} (hgap : uA < lB) + (C : Coordinate lC uC) (hCB : uC < lB) (v : UnitOpen) : + Monotone (fun u : UnitOpen => inCoordinates A B hgap C (u,v)) := by + intro u u' h + dsimp only + rw [inCoordinates_eq_levelB, inCoordinates_eq_levelB] + exact (C.strictMono_along_level B hCB v).monotone (inverseX_mono_left A B hgap v h) + +lemma inCoordinates_antitone_left {lC uC : ℝ} (hgap : uA < lB) + (C : Coordinate lC uC) (hBC : uB < lC) (v : UnitOpen) : + Antitone (fun u : UnitOpen => inCoordinates A B hgap C (u,v)) := by + intro u u' h + dsimp only + rw [inCoordinates_eq_levelB, inCoordinates_eq_levelB] + exact (C.strictAnti_along_level B hBC v).antitone (inverseX_mono_left A B hgap v h) + +lemma inCoordinates_antitone_right {lC uC : ℝ} (hgap : uA < lB) + (C : Coordinate lC uC) (hCA : uC < lA) (u : UnitOpen) : + Antitone (fun v : UnitOpen => inCoordinates A B hgap C (u,v)) := by + intro v v' h + dsimp only + rw [inCoordinates_eq_levelA, inCoordinates_eq_levelA] + exact (C.strictMono_along_level A hCA u).monotone (inverseX_anti_right A B hgap u h) + +lemma inCoordinates_monotone_right {lC uC : ℝ} (hgap : uA < lB) + (C : Coordinate lC uC) (hAC : uA < lC) (u : UnitOpen) : + Monotone (fun v : UnitOpen => inCoordinates A B hgap C (u,v)) := by + intro v v' h + dsimp only + rw [inCoordinates_eq_levelA, inCoordinates_eq_levelA] + exact (C.strictAnti_along_level A hAC u).antitone (inverseX_anti_right A B hgap u h) + +end PlanarHalving.RankCoordinates + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/RankMeasures.lean b/lean/OAI/Combinatorics/HalvingLines/RankMeasures.lean new file mode 100644 index 0000000000000000000000000000000000000000..c66ae88b53aa8ead6cd0ca74abddafc1477aac6a --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/RankMeasures.lean @@ -0,0 +1,584 @@ +import OAI.Combinatorics.HalvingLines.Labels + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable + +inductive MeasureIndex where + | point + | vertices (J : Window) + | time + | restrict (J : Window) + | cross (A B : Window) + deriving Countable + +abbrev LimitSpace : MeasureIndex → Type + | .point => Labels + | .vertices _ => Labels + | .time => Labels × I + | .restrict _ => Labels × I + | .cross _ _ => Labels + +noncomputable instance (i : MeasureIndex) : MetricSpace (LimitSpace i) := by + cases i <;> dsimp only [LimitSpace] <;> exact inferInstanceAs (MetricSpace _) +instance (i : MeasureIndex) : CompactSpace (LimitSpace i) := by + cases i <;> dsimp only [LimitSpace] <;> exact inferInstanceAs (CompactSpace _) +instance (i : MeasureIndex) : Nonempty (LimitSpace i) := by + cases i <;> dsimp only [LimitSpace] <;> exact inferInstanceAs (Nonempty _) +noncomputable instance (i : MeasureIndex) : MeasurableSpace (LimitSpace i) := by + cases i <;> dsimp only [LimitSpace] <;> exact inferInstanceAs (MeasurableSpace _) +instance (i : MeasureIndex) : BorelSpace (LimitSpace i) := by + cases i <;> dsimp only [LimitSpace] <;> exact inferInstanceAs (BorelSpace _) + +noncomputable def Configuration.measures (F : Configuration) : ∀ i, FiniteMeasure (LimitSpace i) + | .point => F.points + | .vertices J => F.vertices J + | .time => F.edgeTime + | .restrict J => F.timeRestrict J + | .cross A B => F.crossings A B + +lemma Configuration.measures_mass_le (F : Configuration) (i : MeasureIndex) : + (F.measures i).mass ≤ 2 := by + cases i with + | point => exact F.points_mass.le.trans (by norm_num) + | vertices J => exact (F.vertices_mass_le J).trans (by norm_num) + | time => exact F.edgeTime_mass.le.trans (by norm_num) + | restrict J => exact (F.timeRestrict_mass_le J).trans (by norm_num) + | cross A B => exact F.crossings_mass_le A B + +structure Data where + points : FiniteMeasure Labels + vertices : Window → FiniteMeasure Labels + edgeTime : FiniteMeasure (Labels × I) + timeRestrict : Window → FiniteMeasure (Labels × I) + crossings : Window → Window → FiniteMeasure Labels + +noncomputable def Data.ofFamily (f : ∀ i, FiniteMeasure (LimitSpace i)) : Data where + points := f .point + vertices := fun J => f (.vertices J) + edgeTime := f .time + timeRestrict := fun J => f (.restrict J) + crossings := fun A B => f (.cross A B) + +structure Converges (F : ℕ → Configuration) (L : Data) : Prop where + points : Tendsto (fun n => (F n).points) atTop (𝓝 L.points) + vertices : ∀ J, Tendsto (fun n => (F n).vertices J) atTop (𝓝 (L.vertices J)) + edgeTime : Tendsto (fun n => (F n).edgeTime) atTop (𝓝 L.edgeTime) + timeRestrict : ∀ J, Tendsto (fun n => (F n).timeRestrict J) atTop (𝓝 (L.timeRestrict J)) + crossings : ∀ A B, Tendsto (fun n => (F n).crossings A B) atTop (𝓝 (L.crossings A B)) + +theorem subsequence (F : ℕ → Configuration) : + ∃ (φ : ℕ → ℕ) (L : Data), StrictMono φ ∧ Converges (F ∘ φ) L := by + obtain ⟨φ,f,hφ,hf⟩ := finiteMeasure_subsequence_dependent + (fun n => (F n).measures) (fun _ => 2) (fun n i => (F n).measures_mass_le i) + exact ⟨φ,Data.ofFamily f,hφ,⟨hf .point,fun J => hf (.vertices J),hf .time, + fun J => hf (.restrict J),fun A B => hf (.cross A B)⟩⟩ + +lemma Converges.points_mass {F : ℕ → Configuration} {L : Data} (h : Converges F L) : + L.points.mass=1 := by + have hh := FiniteMeasure.continuous_mass.tendsto L.points |>.comp h.points + exact tendsto_nhds_unique hh (by simpa only [Function.comp_def,Configuration.points_mass] using + (tendsto_const_nhds : Tendsto (fun _ : ℕ => (1 : ℝ≥0)) atTop (𝓝 1))) +lemma Converges.edgeTime_mass {F : ℕ → Configuration} {L : Data} (h : Converges F L) : + L.edgeTime.mass=1 := by + have hh := FiniteMeasure.continuous_mass.tendsto L.edgeTime |>.comp h.edgeTime + exact tendsto_nhds_unique hh (by simpa only [Function.comp_def,Configuration.edgeTime_mass] using + (tendsto_const_nhds : Tendsto (fun _ : ℕ => (1 : ℝ≥0)) atTop (𝓝 1))) + +lemma Converges.time_marginal {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) : + L.edgeTime.map Prod.snd=⟨volume,inferInstance⟩ := by + have hm := (FiniteMeasure.continuous_map continuous_snd).tendsto L.edgeTime |>.comp h.edgeTime + have ht := timeMeasure_tendsto (fun n => (F n).R) hR + apply tendsto_nhds_unique hm + convert ht using 1 + funext n + exact (F n).system.labelTimeMeasure_time _ + +end PlanarHalving.RankLimits +namespace PlanarHalving.UniformPartition +open MeasureTheory Set Filter Limits +open scoped Topology NNReal ENNReal unitInterval + +lemma normalized_perturbed_fintype_sum_le {m : ℕ} [NeZero m] {α : Type*} [Fintype α] + (slots : α → Fin m × Fin m) (hs : Function.Injective slots) + (x : α → I × I) (f : I × I → ℝ) (hf : ∀ t, 0 ≤ f t) + {ε : ℝ} (hε : 0 ≤ ε) (hclose : ∀ i, f (x i) ≤ f (gridPoint m (slots i)) + ε) : + (∑ i, f (x i))/(m : ℝ)^2 ≤ + (∑ j : Fin m × Fin m, f (gridPoint m j))/(m : ℝ)^2 + ε := by + let e := (Fintype.equivFin α).symm + have hh := normalized_perturbed_sum_le (slots ∘ e) (hs.comp e.injective) + (x ∘ e) f hf hε (fun i => hclose (e i)) + have he : (∑ i, f (x (e i)))=∑ i, f (x i) := Equiv.sum_comp e (fun i => f (x i)) + simpa only [Function.comp_apply,he] using hh + +lemma perturbed_fintype_grid_limit (m : ℕ → ℕ) [∀ n, NeZero (m n)] + (hm : Tendsto m atTop atTop) {α : ℕ → Type*} [∀ n, Fintype (α n)] + (x : ∀ n, α n → I × I) (d : ℕ → ℝ) (hd : Tendsto d atTop (𝓝 0)) + (hslots : ∀ᶠ n in atTop, ∃ slots : α n → Fin (m n) × Fin (m n), + Function.Injective slots ∧ ∀ i, dist (x n i) (gridPoint (m n) (slots i)) ≤ d n) + (μ : FiniteMeasure (I × I)) + (hμ : Tendsto (fun n => weightedAtoms ((m n : ℝ≥0)^2)⁻¹ (x n)) atTop (𝓝 μ)) : + (μ : Measure (I × I)) ≤ volume := by + let ν : FiniteMeasure (I × I) := ⟨volume,inferInstance⟩ + apply measure_le_of_test μ ν + intro f hf + apply le_of_forall_pos_le_add + intro ε hε + obtain ⟨δ,hδ,hfδ⟩ := Metric.uniformContinuous_iff.mp + (CompactSpace.uniformContinuous_of_continuous f.continuous) ε hε + have hdδ : ∀ᶠ n in atTop, d n < δ := (tendsto_order.mp hd).2 δ hδ + have hineq : ∀ᶠ n in atTop, + ∫ t, f t ∂(weightedAtoms ((m n : ℝ≥0)^2)⁻¹ (x n) : Measure (I × I)) ≤ + (∑ j : Fin (m n) × Fin (m n), f (gridPoint (m n) j))/(m n : ℝ)^2 + ε := by + filter_upwards [hdδ,hslots] with n hn hs + obtain ⟨slots,hs,hclose⟩ := hs + rw [integral_weightedAtoms] + simp only [NNReal.coe_inv,NNReal.coe_pow,NNReal.coe_natCast] + rw [← div_eq_inv_mul] + apply normalized_perturbed_fintype_sum_le slots hs (x n) f hf hε.le + intro i + have h := hfδ ((hclose i).trans_lt hn) + rw [Real.dist_eq,abs_lt] at h + linarith [h.2] + have hlim := (FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp hμ) f + have hgrid := (riemann_tendsto m hm f).add_const ε + exact le_of_tendsto_of_tendsto hlim hgrid hineq + +end PlanarHalving.UniformPartition +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable + +lemma Converges.crossing_projection {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + (hM : Tendsto (fun n => (F n).a*(F n).n) atTop atTop) + {A B : Window} (hAB : Before A B) : + ((L.crossings A B).map (fun z => (z A,z B)) : Measure (I × I)) ≤ volume := by + let m := fun n => (F n).a*(F n).n + let x := fun n w => ((F n).label ((F n).system.windowCrossPoint A B w) A, + (F n).label ((F n).system.windowCrossPoint A B w) B) + have hd : Tendsto (fun n => 2/(m n : ℝ)) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop.comp hM) + have hs : ∀ᶠ n in atTop, ∃ slots : _ → Fin (m n) × Fin (m n), + Function.Injective slots ∧ ∀ w, dist (x n w) (UniformPartition.gridPoint (m n) (slots w)) ≤ 2/(m n : ℝ) := by + filter_upwards [eventually_length_pos _ hR A,eventually_length_pos _ hR B] with n hA hB + exact (F n).system.window_crossing_slots (F n).generic hAB hA hB + apply UniformPartition.perturbed_fintype_grid_limit m hM x _ hd hs + have hc : Continuous (fun z : Labels => (z A,z B)) := + (continuous_apply A).prodMk (continuous_apply B) + have hh := (FiniteMeasure.continuous_map hc).tendsto (L.crossings A B) |>.comp (h.crossings A B) + convert hh using 1 + funext n + exact (map_weightedAtoms _ _ hc.measurable).symm + +end PlanarHalving.RankLimits +namespace PlanarHalving.UniformPartition +open MeasureTheory Set +open scoped unitInterval + +lemma volume_frontier_cell (m : ℕ) [NeZero m] (i : Fin m) : + volume (frontier (cell m i))=0 := by + let a := boundary m i.castSucc + let b := boundary m i.succ + have hab : (a : ℝ)<(b : ℝ) := by + apply div_lt_div_of_pos_right _ (Nat.cast_pos.mpr (NeZero.pos m)) + simp only [Fin.val_castSucc,Fin.val_succ,Nat.cast_add,Nat.cast_one] + linarith + have hpair : (Subtype.val : I → ℝ) ⁻¹' {(a : ℝ),(b : ℝ)}={a,b} := by + ext t + simp only [mem_preimage,mem_insert_iff,mem_singleton_iff,Subtype.coe_inj] + unfold cell + split_ifs + · change volume (frontier ((Subtype.val : I → ℝ) ⁻¹' Icc (a : ℝ) (b : ℝ)))=0 + apply measure_mono_null (continuous_subtype_val.frontier_preimage_subset _) + rw [frontier_Icc hab.le,hpair] + exact Set.Finite.measure_zero ((Set.finite_singleton b).insert a) _ + · change volume (frontier ((Subtype.val : I → ℝ) ⁻¹' Ico (a : ℝ) (b : ℝ)))=0 + apply measure_mono_null (continuous_subtype_val.frontier_preimage_subset _) + rw [frontier_Ico hab,hpair] + exact Set.Finite.measure_zero ((Set.finite_singleton b).insert a) _ + +end PlanarHalving.UniformPartition +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable + +lemma Converges.null_time_boundary {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) : + (L.edgeTime : Measure (Labels×I)) (frontier (Prod.snd ⁻¹' carrier J))=0 := by + apply measure_mono_null (continuous_snd.frontier_preimage_subset _) + rw [← Measure.map_apply measurable_snd isClosed_frontier.measurableSet] + have he : (Measure.map Prod.snd (L.edgeTime : Measure (Labels×I)))=volume := + congrArg (fun m : FiniteMeasure I => (m : Measure I)) (h.time_marginal hR) + rw [he] + exact UniformPartition.volume_frontier_cell _ _ + +lemma Converges.restriction_eq {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) : + (L.timeRestrict J : Measure (Labels×I))=(L.edgeTime : Measure (Labels×I)).restrict (Prod.snd ⁻¹' carrier J) := + restriction_limit_eq h.edgeTime (h.timeRestrict J) + ((measurable_carrier J).preimage measurable_snd) (h.null_time_boundary hR J) (fun _ => rfl) + +noncomputable def Data.edge (L : Data) : FiniteMeasure Labels := L.edgeTime.map Prod.fst +noncomputable def Data.edgeWindow (L : Data) (J : Window) : FiniteMeasure Labels := + (L.timeRestrict J).map Prod.fst + +lemma Converges.restriction_mass {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) : + ((L.timeRestrict J).mass : ℝ≥0∞)=(2^J.1 : ℝ≥0∞)⁻¹ := by + rw [FiniteMeasure.ennreal_mass,h.restriction_eq hR,Measure.restrict_apply MeasurableSet.univ,univ_inter] + rw [← Measure.map_apply measurable_snd (measurable_carrier J)] + have he : (Measure.map Prod.snd (L.edgeTime : Measure (Labels×I)))=volume := + congrArg (fun m : FiniteMeasure I => (m : Measure I)) (h.time_marginal hR) + rw [he] + rw [TimeWindows.carrier,UniformPartition.cell_volume] + rw [ENNReal.ofReal_div_of_pos (by positivity), ENNReal.ofReal_one, + ENNReal.ofReal_natCast,one_div] + norm_cast + +end PlanarHalving.RankLimits +namespace PlanarHalving.Batches +open MeasureTheory Set Limits TimeWindows +open scoped NNReal ENNReal unitInterval +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.window_endpoint_eq (S : @System n R k a P) [NeZero R] [NeZero a] + {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] + (z : Fin n → X) (J : Window) : + ((S.labelTimeMeasure z).restrict (Prod.snd ⁻¹' carrier J)).map Prod.fst= + (S.timeWindow J).endpointMeasure z ((R : ℝ≥0)*(a : ℝ≥0)^2) := by + classical + apply FiniteMeasure.eq_of_forall_toMeasure_apply_eq + intro U hU + have he : ((((S.labelTimeMeasure z).restrict (Prod.snd ⁻¹' carrier J)).map Prod.fst) U : ℝ)= + ((S.timeWindow J).endpointMeasure z ((R : ℝ≥0)*(a : ℝ≥0)^2) U : ℝ) := by + rw [FiniteMeasure.map_apply _ measurable_fst hU, + FiniteMeasure.restrict_apply _ _ (hU.preimage measurable_fst), + System.labelTimeMeasure,weightedAtoms_apply_finset _ _ + ((hU.preimage measurable_fst).inter ((measurable_carrier J).preimage measurable_snd)), + System.endpointMeasure,weightedAtoms_apply_finset _ _ hU] + congr 2 + apply Finset.card_bij (fun e he => + (⟨e.val,(S.timeWindow_mem J e).mpr (by + simp only [Finset.mem_filter, Finset.mem_univ, true_and, + Set.mem_inter_iff,Set.mem_preimage] at he + exact he.2)⟩ : ↥(S.timeWindow J).edges)) + · intro e he + simp only [Finset.mem_filter,Finset.mem_univ,true_and, + Set.mem_inter_iff,Set.mem_preimage] at he ⊢ + exact he.1 + · intro e _ f _ hef + exact Subtype.ext (congrArg (fun x : ↥(S.timeWindow J).edges => x.val) hef) + · intro e he + let f : ↥S.edges := ⟨e.val,S.timeWindow_edges J e.property⟩ + refine ⟨f,?_,rfl⟩ + simp only [Finset.mem_filter,Finset.mem_univ,true_and, + Set.mem_inter_iff,Set.mem_preimage] at he ⊢ + exact ⟨he,(S.timeWindow_mem J f).mp e.property⟩ + have he' := NNReal.coe_injective he + simpa only [FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] using + congrArg (fun x : ℝ≥0 => (x : ℝ≥0∞)) he' + +lemma System.vertexMass_ratio (S : @System n R k a P) (z : Fin n → Point) : + ((S.vertexMeasure z).mass : ℝ)=(S.vertices.card : ℝ)/(n : ℝ) := by + rw [System.vertexMeasure,mass_weightedAtoms,Fintype.card_coe] + simp only [NNReal.coe_mul,NNReal.coe_inv,NNReal.coe_natCast,div_eq_inv_mul] + +end PlanarHalving.Batches +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable + +noncomputable def Configuration.edgeWindow (F : Configuration) (J : Window) : FiniteMeasure Labels := + (F.timeRestrict J).map Prod.fst + +lemma Configuration.edgeWindow_eq (F : Configuration) (J : Window) : + F.edgeWindow J=(F.system.timeWindow J).endpointMeasure (F.label ∘ F.point) + ((F.R : ℝ≥0)*(F.a : ℝ≥0)^2) := F.system.window_endpoint_eq _ J + +lemma Configuration.vertices_mass_ratio (F : Configuration) (J : Window) : + ((F.vertices J).mass : ℝ)=((F.system.timeWindow J).vertices.card : ℝ)/(F.n : ℝ) := by + rw [Configuration.vertices,System.vertexMeasure,mass_weightedAtoms,Fintype.card_coe] + simp only [NNReal.coe_mul,NNReal.coe_inv,NNReal.coe_natCast,div_eq_inv_mul] + +lemma Configuration.window_cubed_bound (F : Configuration) (J : Window) + {U : Set Labels} (hU : MeasurableSet U) : + (F.edgeWindow J U : ℝ)^3 ≤ + (4608 * (F.a : ℝ)^2 * F.n^4 / ((F.R : ℝ)*F.a^2)^3) * + ((F.vertices J).mass : ℝ)^3 * (F.vertices J U : ℝ) + + 13824 * ((F.system.timeWindow J).vertices.card : ℝ)^3 / ((F.R : ℝ)*F.a^2)^3 := by + rw [F.edgeWindow_eq,F.vertices_mass_ratio] + have hR : 0 < (F.R : ℝ≥0) := Nat.cast_pos.mpr F.R_pos + have ha : 0 < (F.a : ℝ≥0) := Nat.cast_pos.mpr F.a_pos + exact (F.system.timeWindow J).atomic_cubed_bound F.generic _ (by positivity) hU + +end PlanarHalving.RankLimits +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates TimeWindows +open scoped unitInterval +variable {n R k a : ℕ} {P : Fin n → Point} + +noncomputable def System.rankGraphs (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (J : Window) (hJ : 0 < length R J) : + (S.timeWindow J).FullGraphs (S.drawing.exteriorCrossings (S.timeWindow J).edges) := + (S.rankFamily_spec hP J hJ).choose + +lemma System.rankGraphs_eq (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (J : Window) (hJ : 0 < length R J) : + (S.rankGraphs hP J hJ).graph=(S.rankFamily hP J).graph := + (S.rankFamily_spec hP J hJ).choose_spec.1.symm + +noncomputable def System.rankCoordinate (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (J : Window) (hJ : 0 < length R J) : + Coordinate (S.rankGraphs hP J hJ).lower (S.rankGraphs hP J hJ).upper := + smoothedCoordinate (Nat.mul_pos (NeZero.pos a) (NeZero.pos n)) + (S.rankGraphs hP J hJ).graph (S.rankFamily hP J).scale_pos + (S.rankGraphs hP J hJ).continuous (S.rankGraphs hP J hJ).slopes + +lemma System.rankCoordinate_value (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) (J : Window) (hJ : 0 < length R J) (p : Point) : + (S.rankCoordinate hP J hJ).value p=(S.labels hP p J : ℝ) := by + change smoothed (S.rankGraphs hP J hJ).graph _ p=smoothed (S.rankFamily hP J).graph _ p + rw [S.rankGraphs_eq] + +noncomputable def System.rankHomeomorph (S : @System n R k a P) [NeZero n] [NeZero a] [NeZero R] + (hP : Generic P) {A B : Window} (hAB : Before A B) + (hA : 0 < length R A) (hB : 0 < length R B) : Point ≃ₜ (UnitOpen × UnitOpen) := + pairHomeomorph (S.rankCoordinate hP A hA) (S.rankCoordinate hP B hB) + (S.timeWindow_graph_gap hAB _ _) + +lemma System.rankHomeomorph_coordinates (S : @System n R k a P) + [NeZero n] [NeZero a] [NeZero R] (hP : Generic P) {A B : Window} (hAB : Before A B) + (hA : 0 < length R A) (hB : 0 < length R B) (p : Point) : + (((S.rankHomeomorph hP hAB hA hB) p).1 : ℝ)=(S.labels hP p A : ℝ) ∧ + (((S.rankHomeomorph hP hAB hA hB) p).2 : ℝ)=(S.labels hP p B : ℝ) := + ⟨S.rankCoordinate_value hP A hA p,S.rankCoordinate_value hP B hB p⟩ + +noncomputable def System.rankInCoordinates (S : @System n R k a P) + [NeZero n] [NeZero a] [NeZero R] (hP : Generic P) {A B : Window} (hAB : Before A B) + (hA : 0 < length R A) (hB : 0 < length R B) (C : Window) : UnitOpen × UnitOpen → ℝ := + fun p => (S.labels hP ((S.rankHomeomorph hP hAB hA hB).symm p) C : ℝ) + +lemma System.rankInCoordinates_eq (S : @System n R k a P) + [NeZero n] [NeZero a] [NeZero R] (hP : Generic P) {A B : Window} (hAB : Before A B) + (hA : 0 < length R A) (hB : 0 < length R B) (C : Window) (hC : 0 < length R C) : + S.rankInCoordinates hP hAB hA hB C= + inCoordinates (S.rankCoordinate hP A hA) (S.rankCoordinate hP B hB) + (S.timeWindow_graph_gap hAB _ _) (S.rankCoordinate hP C hC) := by + funext p + exact (S.rankCoordinate_value hP C hC _).symm + +lemma System.rankInCoordinates_before (S : @System n R k a P) + [NeZero n] [NeZero a] [NeZero R] (hP : Generic P) {A B C : Window} + (hAB : Before A B) (hCA : Before C A) (hCB : Before C B) + (hA : 0 < length R A) (hB : 0 < length R B) (hC : 0 < length R C) : + (∀ v, Monotone (fun u => S.rankInCoordinates hP hAB hA hB C (u,v))) ∧ + (∀ u, Antitone (fun v => S.rankInCoordinates hP hAB hA hB C (u,v))) := by + rw [S.rankInCoordinates_eq hP hAB hA hB C hC] + exact ⟨fun v => inCoordinates_monotone_left _ _ _ _ (S.timeWindow_graph_gap hCB _ _) v, + fun u => inCoordinates_antitone_right _ _ _ _ (S.timeWindow_graph_gap hCA _ _) u⟩ + +lemma System.rankInCoordinates_between (S : @System n R k a P) + [NeZero n] [NeZero a] [NeZero R] (hP : Generic P) {A B C : Window} + (hAB : Before A B) (hAC : Before A C) (hCB : Before C B) + (hA : 0 < length R A) (hB : 0 < length R B) (hC : 0 < length R C) : + (∀ v, Monotone (fun u => S.rankInCoordinates hP hAB hA hB C (u,v))) ∧ + (∀ u, Monotone (fun v => S.rankInCoordinates hP hAB hA hB C (u,v))) := by + rw [S.rankInCoordinates_eq hP hAB hA hB C hC] + exact ⟨fun v => inCoordinates_monotone_left _ _ _ _ (S.timeWindow_graph_gap hCB _ _) v, + fun u => inCoordinates_monotone_right _ _ _ _ (S.timeWindow_graph_gap hAC _ _) u⟩ + +lemma System.rankInCoordinates_after (S : @System n R k a P) + [NeZero n] [NeZero a] [NeZero R] (hP : Generic P) {A B C : Window} + (hAB : Before A B) (hAC : Before A C) (hBC : Before B C) + (hA : 0 < length R A) (hB : 0 < length R B) (hC : 0 < length R C) : + (∀ v, Antitone (fun u => S.rankInCoordinates hP hAB hA hB C (u,v))) ∧ + (∀ u, Monotone (fun v => S.rankInCoordinates hP hAB hA hB C (u,v))) := by + rw [S.rankInCoordinates_eq hP hAB hA hB C hC] + exact ⟨fun v => inCoordinates_antitone_left _ _ _ _ (S.timeWindow_graph_gap hBC _ _) v, + fun u => inCoordinates_monotone_right _ _ _ _ (S.timeWindow_graph_gap hAC _ _) u⟩ + +end PlanarHalving.Batches +namespace PlanarHalving.Limits +open MeasureTheory Set Filter +open scoped Topology + +lemma measure_le_of_weak_limits {X : Type*} [MetricSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] + {μ ν : FiniteMeasure X} {μs νs : ℕ → FiniteMeasure X} + (hμ : Tendsto μs atTop (𝓝 μ)) (hν : Tendsto νs atTop (𝓝 ν)) + (h : ∀ n, (μs n : Measure X) ≤ (νs n : Measure X)) : + (μ : Measure X) ≤ (ν : Measure X) := by + apply measure_le_of_test + intro f hf + exact le_of_tendsto_of_tendsto + (FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp hμ f) + (FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp hν f) + (Eventually.of_forall (fun n => integral_mono_measure (h n) + (Eventually.of_forall hf) (BoundedContinuousFunction.integrable (νs n : Measure X) f))) + +end PlanarHalving.Limits +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter +open scoped Topology NNReal ENNReal unitInterval PiCountable + +lemma Configuration.vertices_le_points (F : Configuration) (J : Window) : + (F.vertices J : Measure Labels) ≤ (F.points : Measure Labels) := by + classical + apply Measure.le_iff.mpr + intro U hU + have he : (F.vertices J U : ℝ) ≤ (F.points U : ℝ) := by + rw [Configuration.vertices,System.vertexMeasure_apply _ _ hU, + Configuration.points,weightedAtoms_apply_finset _ _ hU] + simp only [NNReal.coe_inv,NNReal.coe_natCast,div_eq_inv_mul] + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact_mod_cast Finset.card_le_card (Finset.filter_subset_filter _ (Finset.subset_univ _)) + simpa only [FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] using + (ENNReal.coe_le_coe.mpr (NNReal.coe_le_coe.mp he)) + +lemma Converges.vertices_le_points {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (J : Window) : (L.vertices J : Measure Labels) ≤ (L.points : Measure Labels) := + measure_le_of_weak_limits (h.vertices J) h.points (fun n => (F n).vertices_le_points J) + +lemma Converges.edgeWindow {F : ℕ → Configuration} {L : Data} (h : Converges F L) (J : Window) : + Tendsto (fun n => (F n).edgeWindow J) atTop (𝓝 (L.edgeWindow J)) := + (FiniteMeasure.continuous_map continuous_fst).tendsto _ |>.comp (h.timeRestrict J) + +lemma Converges.local_cubic {F : ℕ → Configuration} {L : Data} (h : Converges F L) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4 / + (((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3 / + (((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) + (J : Window) {U : Set Labels} (hU : MeasurableSet U) : + (L.edgeWindow J U : ℝ)^3 ≤ C*((L.vertices J).mass : ℝ)^3*(L.vertices J U : ℝ) := by + have hm : Tendsto (fun n => ((F n).vertices J).mass) atTop (𝓝 ((L.vertices J).mass)) := + FiniteMeasure.continuous_mass.tendsto _ |>.comp (h.vertices J) + have hmR := NNReal.continuous_coe.tendsto _ |>.comp hm + apply cubed_bound_limit (h.vertices J) (h.edgeWindow J) + (mul_nonneg hC (pow_nonneg (NNReal.coe_nonneg _) _)) + ((hmR.pow 3).const_mul C) herror + intro n V hV + apply ((F n).window_cubed_bound J hV).trans + apply add_le_add + · exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (hcoeff n) (pow_nonneg (NNReal.coe_nonneg _) _)) + (NNReal.coe_nonneg _) + · apply div_le_div_of_nonneg_right _ (by positivity) + apply mul_le_mul_of_nonneg_left _ (by norm_num) + apply pow_le_pow_left₀ (Nat.cast_nonneg _) _ 3 + exact_mod_cast (show ((F n).system.timeWindow J).vertices.card ≤ (F n).n by + simpa only [Fintype.card_fin] using ((F n).system.timeWindow J).vertices.card_le_univ) + exact hU + +lemma Converges.window_absolutelyContinuous {F : ℕ → Configuration} {L : Data} (h : Converges F L) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4 / + (((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3 / + (((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) (J : Window) : + (L.edgeWindow J : Measure Labels) ≪ (L.points : Measure Labels) := by + refine (show (L.edgeWindow J : Measure Labels) ≪ (L.vertices J : Measure Labels) from ?_).trans + (Measure.absolutelyContinuous_of_le (h.vertices_le_points J)) + intro U hU + have hc := h.local_cubic hC hcoeff herror J (measurableSet_toMeasurable (L.vertices J : Measure Labels) U) + have hV : ((L.vertices J : Measure Labels) (toMeasurable (L.vertices J : Measure Labels) U))=0 := by + rwa [measure_toMeasurable] + have hV' : L.vertices J (toMeasurable (L.vertices J : Measure Labels) U)=0 := by + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] at hV + exact ENNReal.coe_eq_zero.mp hV + rw [hV',NNReal.coe_zero,mul_zero] at hc + have hz : L.edgeWindow J (toMeasurable (L.vertices J : Measure Labels) U)=0 := by + apply NNReal.coe_injective + change (L.edgeWindow J (toMeasurable (L.vertices J : Measure Labels) U) : ℝ)=0 + exact (pow_eq_zero_iff (by omega : (3:ℕ)≠0)).mp + (le_antisymm hc (pow_nonneg (NNReal.coe_nonneg _) _)) + apply measure_mono_null (subset_toMeasurable _ _) + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,hz,ENNReal.coe_zero] + +end PlanarHalving.RankLimits +namespace PlanarHalving.RankLimits +open Batches Filter +open scoped Topology + +lemma Configuration.normalization_coefficient (F : Configuration) {c : ℝ} (hc : 0 ((F n).n : ℝ)/(F n).a) atTop atTop) : + Tendsto (fun n => ((F n).n : ℝ)/((F n).R*(F n).a)) atTop (𝓝 0) := by + have hi : Tendsto (fun n => 1/(c*(((F n).n : ℝ)/(F n).a))) atTop (𝓝 0) := by + simpa only [one_div,Function.comp_def] using tendsto_inv_atTop_zero.comp (hq.const_mul_atTop hc) + apply Metric.tendsto_atTop.mpr + intro ε hε + obtain ⟨N,hN⟩ := Metric.tendsto_atTop.mp hi (ε^3) (pow_pos hε _) + refine ⟨N,fun n hn => ?_⟩ + have hb := (F n).short_ratio_cube hc (hnear n) + have hp : (0:ℝ)≤((F n).n : ℝ)/((F n).R*(F n).a) := by positivity + have hv := hN n hn + rw [Real.dist_eq,sub_zero,abs_of_nonneg (by positivity)] at hv + rw [Real.dist_eq,sub_zero,abs_of_nonneg hp] + exact (pow_lt_pow_iff_left₀ hp hε.le (by omega : (3:ℕ)≠0)).mp (hb.trans_lt hv) + +lemma sparse_error_tendsto_zero {F : ℕ → Configuration} {c : ℝ} (hc : 0 ((F n).n : ℝ)/(F n).a) atTop atTop) : + Tendsto (fun n => 13824*((F n).n : ℝ)^3/((F n).R*(F n).a^2)^3) atTop (𝓝 0) := by + have hsmall := (short_ratio_tendsto_zero hc hnear hq).pow 3 |>.const_mul 13824 + simp only [zero_pow (by omega : (3:ℕ)≠0),mul_zero] at hsmall + apply squeeze_zero (fun n => by positivity) (fun n => ?_) hsmall + have ha : (1:ℝ)≤(F n).a := by exact_mod_cast (F n).a_pos + have hR : (0:ℝ)<(F n).R := Nat.cast_pos.mpr (F n).R_pos + rw [div_pow,mul_div_assoc] + apply mul_le_mul_of_nonneg_left _ (by norm_num) + apply div_le_div_of_nonneg_left (by positivity) (by positivity) + gcongr + nlinarith + +lemma normalization_sizes_atTop {F : ℕ → Configuration} {c : ℝ} (hc : 0 ((F n).n : ℝ)/(F n).a) atTop atTop) : + Tendsto (fun n => (F n).n) atTop atTop ∧ + Tendsto (fun n => (F n).a*(F n).n) atTop atTop ∧ + Tendsto (fun n => (F n).R) atTop atTop := by + have hn : Tendsto (fun n => ((F n).n : ℝ)) atTop atTop := by + apply tendsto_atTop_mono (fun n => ?_) hq + exact div_le_self (by positivity) (by exact_mod_cast (F n).a_pos) + have hn' : Tendsto (fun n => (F n).n) atTop atTop := tendsto_natCast_atTop_iff.mp hn + refine ⟨hn',tendsto_atTop_mono (fun n => Nat.le_mul_of_pos_left _ (F n).a_pos) hn',?_⟩ + apply (tendsto_natCast_atTop_iff (R:=ℝ)).mp + apply tendsto_atTop_mono' atTop ?_ hq + have hs := (short_ratio_tendsto_zero hc hnear hq).eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1)) + filter_upwards [hs] with n hn + have ha : (0:ℝ)<(F n).a := Nat.cast_pos.mpr (F n).a_pos + have hR : (0:ℝ)<(F n).R := Nat.cast_pos.mpr (F n).R_pos + apply (div_le_iff₀ ha).mpr + have := (div_lt_iff₀ (mul_pos hR ha)).mp hn + linarith + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Recurrence.lean b/lean/OAI/Combinatorics/HalvingLines/Recurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..ace7d65dab4fbe10a1492f4e62a629afd5d4b36d --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Recurrence.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.HalvingLines.Decomposition + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Sweep + +lemma switchCount_le_sq {n : ℕ} (P : Fin n → Point) (k : ℕ) : switchCount P k≤n*n := by + classical + simpa only [switchCount,Finset.card_univ,Fintype.card_prod,Fintype.card_fin] using + (Finset.card_le_card (Finset.filter_subset (fun ij : Fin n × Fin n => + ij.1 < ij.2 ∧ 0 (hdata.2 p hp).1) (fun p hp => by + rw [← S.activitySize_eq] + exact (hdata.2 p hp).2) + rw [G.intervals_card S] at hh + apply greedy_count_bound hq4 hb hscale.2.2.2.1 + norm_num at hh + nlinarith + +lemma count_bound_induction {q : ℕ} (hq : 4≤q) {β : ℝ} (hβ : 0<β) + (hpacking : ∀ {n k : ℕ} (P : Fin n → Point) (hP : Generic P) (hk : k≤n) + (_hn : 4*q≤n), let b := n/q-1 + ∀ hb : 0 + intro P hP k hk + by_cases hn : 4*q≤n + · let b := n/q-1 + have hscale := division_scale hq hn + change 0 hind j) + _ ≤ ∑ _j : Fin (G.count+1), C*((n:ℝ)/q)^β := Finset.sum_le_sum (fun j _ => + mul_le_mul_of_nonneg_left (Real.rpow_le_rpow (by positivity) (hAreal j) hβ.le) hC) + _ = C*((n:ℝ)/q)^β*((G.count:ℝ)+1) := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,Nat.cast_add,Nat.cast_one];ring + _ ≤ C*((n:ℝ)/q)^β*(q:ℝ)^β := mul_le_mul_of_nonneg_left hg (mul_nonneg hC (Real.rpow_nonneg (by positivity) _)) + _ = C*(n:ℝ)^β := by rw [Real.div_rpow (by positivity) hq0.le];field_simp + · have hs : (switchCount P k:ℝ)≤(n:ℝ)^2 := by exact_mod_cast (by simpa only [pow_two] using switchCount_le_sq P k : switchCount P k≤n^2) + by_cases hz : n=0 + · subst n + simpa only [Nat.cast_zero,zero_pow (by decide : (2:ℕ)≠0),Real.zero_rpow hβ.ne',mul_zero] using hs + · have hn1 : (1:ℝ)≤n := by exact_mod_cast (show 1≤n by omega) + have hnr : (n:ℝ)≤4*(q:ℝ) := by exact_mod_cast (le_of_lt (lt_of_not_ge hn)) + have hpow : 1≤(n:ℝ)^β := by + simpa only [Real.one_rpow] using Real.rpow_le_rpow (by norm_num : (0:ℝ)≤1) hn1 hβ.le + exact (hs.trans (pow_le_pow_left₀ (by positivity) hnr 2)).trans (le_mul_of_one_le_right hC hpow) + +end PlanarHalving.Sweep + +namespace PlanarHalving + +theorem all_ranks_power : + ∃ ε : ℝ, 0 < ε ∧ ∃ C : ℝ, + ∀ n : ℕ, 1 ≤ n → ∀ P : Fin n → Point, Generic P → + ∀ k : ℕ, k ≤ n → (switchCount P k : ℝ) ≤ C * (n : ℝ) ^ ((4 : ℝ) / 3 - ε) := by + obtain ⟨q,hq,hpack⟩ := Sweep.packing_scale + obtain ⟨ε,he,hβ,hpow⟩ := Sweep.recurrence_exponent hq + refine ⟨ε,he,(4*(q:ℝ))^2,?_⟩ + intro n _ P hP k hk + apply Sweep.count_bound_induction hq hβ _ n P hP k hk + intro n k P hP hk hn b hb + exact (hpack P hP hk hn hb).trans hpow +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Rigidity.lean b/lean/OAI/Combinatorics/HalvingLines/Rigidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..de5da9f5714c5f6cc82b0d91584f3588d4bd0a86 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Rigidity.lean @@ -0,0 +1,258 @@ +import OAI.Combinatorics.HalvingLines.Intersections + +namespace OAI + +namespace PlanarHalving + +namespace Zoom + +open scoped NNReal Topology +open Filter + +structure LineControl {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : ℕ → E → E) (v : E) where + level : E →L[ℝ] ℝ + constant : ℝ≥0 + positive : 0 < constant + strict : ∀ n x, StrictMono (fun t : ℝ => level (f n (x + t • v) - f n x)) + chord : ∀ n x (t u : ℝ), ‖f n (x + t • v) - f n (x + u • v)‖ ≤ + constant * |level (f n (x + t • v) - f n (x + u • v))| + +lemma moving_intersection_tendsto + (f : ℕ → OpenPartialHomeomorph Point Point) + (hsource : ∀ n, (f n).source = Set.univ) + (hexhaust : ∀ K : Set Point, IsCompact K → ∀ᶠ n in atTop, K ⊆ (f n).target) + (x y z : ℕ → Point) (u v U V a b c : Point) (r s : ℝ) + (hu : u ≠ 0) (hv : v ≠ 0) + (C₁ : LineControl (fun n => f n) u) (C₂ : LineControl (fun n => f n) v) + (hdir₁ : DirectionalLimit (fun n => f n) u U) + (hdir₂ : DirectionalLimit (fun n => f n) v V) + (ha : Tendsto (fun n => f n (x n)) atTop (𝓝 a)) + (hb : Tendsto (fun n => f n (y n)) atTop (𝓝 b)) + (hdet : detPair U V ≠ 0) (hc₁ : c = a + r • U) (hc₂ : c = b + s • V) + (hunique : ∀ n (t q : ℝ), x n + t • u = y n + q • v → x n + t • u = z n) : + Tendsto (fun n => f n (z n)) atTop (𝓝 c) := by + obtain ⟨hU, hA⟩ := moving_line_arcs_tendsto f hsource hexhaust x a u U hu + C₁.level C₁.constant C₁.positive ha (fun n => C₁.strict n (x n)) + (fun n => C₁.chord n (x n)) hdir₁ + obtain ⟨hV, hB⟩ := moving_line_arcs_tendsto f hsource hexhaust y b v V hv + C₂.level C₂.constant C₂.positive hb (fun n => C₂.strict n (y n)) + (fun n => C₂.chord n (y n)) hdir₂ + let V' : Point := (C₂.level V)⁻¹ • V + have hUV' : detPair U V' ≠ 0 := by + change detPair U ((C₂.level V)⁻¹ • V) ≠ 0 + rw [detPair_smul_right] + exact mul_ne_zero (inv_ne_zero hV) hdet + obtain ⟨ψ, hjoint, hψU, hψV⟩ := transverse_covector C₁.level U V' hU hUV' + let A (n : ℕ) : Set Point := {p | ∃ t : ℝ, p = f n (x n + t • u)} + let B (n : ℕ) : Set Point := {p | ∃ t : ℝ, p = f n (y n + t • v)} + refine line_intersection_tendsto C₁.level ψ hjoint A B (fun n => f n (z n)) + (fun n => f n (x n)) a b c ((C₁.level U)⁻¹ • U) V' + (s * C₂.level V) ha ?_ ?_ ?_ (by rw [hψV]; norm_num) ?_ ?_ ?_ + · rw [hc₂] + congr 1 + dsimp [V'] + rw [smul_smul, mul_inv_cancel_right₀ hV] + · simp only [map_smul, hψU, smul_zero] + · simp only [hc₁, map_add, map_smul, hψU, smul_zero, add_zero] + · intro n p hpA hpB + obtain ⟨t, ht⟩ := hpA + obtain ⟨q, hq⟩ := hpB + have hxy : x n + t • u = y n + q • v := + (f n).injOn (by rw [hsource]; trivial) (by rw [hsource]; trivial) (ht.symm.trans hq) + rw [ht, hunique n t q hxy] + · intro R hR + obtain ⟨γ, hLip, hmem, hlevel, hlim⟩ := hA R hR + refine ⟨γ, fun n => (hLip n).continuous, hmem, hlevel, ?_⟩ + simpa only [div_eq_mul_inv, mul_smul] using hlim + · intro R hR + obtain ⟨γ, hLip, hmem, _, hlim⟩ := hB R hR + refine ⟨γ, fun n => (hLip n).continuous, hmem, ?_⟩ + simpa only [V', div_eq_mul_inv, mul_smul] using hlim + +noncomputable def LineControl.of_monotone + (f : ℕ → OpenPartialHomeomorph Point Point) + (hsource : ∀ n, (f n).source = Set.univ) + (v : Point) (hv : v ≠ 0) (Q : Point ≃L[ℝ] Point) + (h₁ : ∀ n x, Monotone (fun t : ℝ => (Q (f n (x + t • v))).1)) + (h₂ : ∀ n x, Monotone (fun t : ℝ => (Q (f n (x + t • v))).2)) : + LineControl (fun n => f n) v where + level := coneLevel Q + constant := ‖Q.symm.toContinuousLinearMap‖₊ + 1 + positive := by positivity + strict n x := by + have hginj : Function.Injective (fun t : ℝ => f n (x + t • v)) := by + intro t u he + apply smul_left_injective ℝ hv + exact add_left_cancel ((f n).injOn (by rw [hsource]; trivial) + (by rw [hsource]; trivial) he) + have hh := coneLevel_strictMono Q _ hginj (h₁ n x) (h₂ n x) + intro t u htu + simp only [map_sub] + exact sub_lt_sub_right (hh htu) _ + chord n x t u := by + have hh := coneLevel_chord Q (fun t => f n (x + t • v)) (h₁ n x) (h₂ n x) t u + exact hh.trans (mul_le_mul_of_nonneg_right (by simp) (abs_nonneg _)) + +lemma parallel_scalars_zero (u v : Point) (hdet : detPair u v ≠ 0) + (r s : ℝ) (he : r • u = s • v) : r = 0 ∧ s = 0 := by + have h₁ : r * u.1 = s * v.1 := congrArg Prod.fst he + have h₂ : r * u.2 = s * v.2 := congrArg Prod.snd he + have hr : r * detPair u v = 0 := by + dsimp [detPair] + linear_combination v.2 * h₁ - v.1 * h₂ + have hs : s * detPair u v = 0 := by + dsimp [detPair] + linear_combination u.2 * h₁ - u.1 * h₂ + exact ⟨(mul_eq_zero.mp hr).resolve_right hdet, (mul_eq_zero.mp hs).resolve_right hdet⟩ + +lemma line_intersection_unique (x y z u v : Point) (hdet : detPair u v ≠ 0) + (r s : ℝ) (hz₁ : z = x + r • u) (hz₂ : z = y + s • v) + (t q : ℝ) (he : x + t • u = y + q • v) : x + t • u = z := by + have hp : (t - r) • u = (q - s) • v := by + calc + (t - r) • u = (x + t • u) - (x + r • u) := by rw [sub_smul]; abel + _ = (y + q • v) - (y + s • v) := by rw [he, ← hz₁, hz₂] + _ = (q - s) • v := by rw [sub_smul]; abel + have ht : t = r := sub_eq_zero.mp (parallel_scalars_zero u v hdet _ _ hp).1 + rw [ht, ← hz₁] + +inductive Foliation where + | horizontal + | vertical + | diagonal + deriving DecidableEq + +def Foliation.direction : Foliation → Point + | .horizontal => (1, 0) + | .vertical => (0, 1) + | .diagonal => (1, 1) + +lemma Foliation.direction_ne_zero (i : Foliation) : i.direction ≠ 0 := by + cases i <;> norm_num [Foliation.direction] + +lemma Foliation.transverse (i j : Foliation) (hij : i ≠ j) : + detPair i.direction j.direction ≠ 0 := by + cases i <;> cases j <;> simp_all [Foliation.direction, detPair] + +structure FoliatedSequence where + map : ℕ → OpenPartialHomeomorph Point Point + source : ∀ n, (map n).source = Set.univ + exhaust : ∀ K : Set Point, IsCompact K → ∀ᶠ n in atTop, K ⊆ (map n).target + control : ∀ i : Foliation, LineControl (fun n => map n) i.direction + direction : ∀ i : Foliation, DirectionalLimit (fun n => map n) i.direction i.direction + +def FoliatedSequence.subseq (F : FoliatedSequence) (ρ : ℕ → ℕ) (hρ : StrictMono ρ) : + FoliatedSequence where + map n := F.map (ρ n) + source n := F.source (ρ n) + exhaust K hK := hρ.tendsto_atTop.eventually (F.exhaust K hK) + control i := { + level := (F.control i).level + constant := (F.control i).constant + positive := (F.control i).positive + strict n x := (F.control i).strict (ρ n) x + chord n x t u := (F.control i).chord (ρ n) x t u } + direction i σ hσ x y hxy a b ha hb := + F.direction i (ρ ∘ σ) (hρ.comp hσ) x y hxy a b ha hb + +def FoliatedSequence.Good (F : FoliatedSequence) (σ : ℝ) (x : Point) : Prop := + Tendsto (fun n => F.map n x) atTop (𝓝 (σ • x)) + +lemma FoliatedSequence.Good.subseq {F : FoliatedSequence} {σ : ℝ} {x : Point} + (h : F.Good σ x) (ρ : ℕ → ℕ) (hρ : StrictMono ρ) : (F.subseq ρ hρ).Good σ x := + h.comp hρ.tendsto_atTop + +lemma FoliatedSequence.good_intersection (F : FoliatedSequence) (σ : ℝ) + (i j : Foliation) (hij : i ≠ j) (x y z : Point) (r s : ℝ) + (hx : F.Good σ x) (hy : F.Good σ y) + (hz₁ : z = x + r • i.direction) (hz₂ : z = y + s • j.direction) : + F.Good σ z := by + exact moving_intersection_tendsto F.map F.source F.exhaust (fun _ => x) (fun _ => y) + (fun _ => z) i.direction j.direction i.direction j.direction (σ • x) (σ • y) + (σ • z) (σ * r) (σ * s) i.direction_ne_zero j.direction_ne_zero + (F.control i) (F.control j) (F.direction i) (F.direction j) hx hy + (i.transverse j hij) + (by rw [hz₁, smul_add, smul_smul]) + (by rw [hz₂, smul_add, smul_smul]) + (fun _ => line_intersection_unique x y z i.direction j.direction + (i.transverse j hij) r s hz₁ hz₂) + +lemma FoliatedSequence.good_rect (F : FoliatedSequence) (σ : ℝ) + (x y : Point) (hx : F.Good σ x) (hy : F.Good σ y) : + F.Good σ (y.1, x.2) := by + apply F.good_intersection σ .horizontal .vertical (by decide) x y (y.1, x.2) + (y.1 - x.1) (x.2 - y.2) hx hy + · ext <;> dsimp [Foliation.direction] <;> ring + · ext <;> dsimp [Foliation.direction] <;> ring + +lemma FoliatedSequence.good_diagonal_vertical (F : FoliatedSequence) (σ : ℝ) + (x y : Point) (hx : F.Good σ x) (hy : F.Good σ y) : + F.Good σ (y.1, x.2 + y.1 - x.1) := by + apply F.good_intersection σ .diagonal .vertical (by decide) x y + (y.1, x.2 + y.1 - x.1) (y.1 - x.1) (x.2 + y.1 - x.1 - y.2) hx hy + · ext <;> dsimp [Foliation.direction] <;> ring + · ext <;> dsimp [Foliation.direction] <;> ring + +lemma FoliatedSequence.good_diagonal_horizontal (F : FoliatedSequence) (σ : ℝ) + (x y : Point) (hx : F.Good σ x) (hy : F.Good σ y) : + F.Good σ (x.1 + y.2 - x.2, y.2) := by + apply F.good_intersection σ .diagonal .horizontal (by decide) x y + (x.1 + y.2 - x.2, y.2) (y.2 - x.2) (x.1 + y.2 - x.2 - y.1) hx hy + · ext <;> dsimp [Foliation.direction] <;> ring + · ext <;> dsimp [Foliation.direction] <;> ring + +lemma FoliatedSequence.good_axis_swap (F : FoliatedSequence) (σ a : ℝ) + (hzero : F.Good σ 0) (ha : F.Good σ (a, 0)) : F.Good σ (0, a) := by + have hh := F.good_diagonal_vertical σ 0 (a, 0) hzero ha + have hv := F.good_rect σ (a, a) 0 (by simpa using hh) hzero + simpa using hv + +lemma FoliatedSequence.good_axis_add (F : FoliatedSequence) (σ a b : ℝ) + (hzero : F.Good σ 0) (ha : F.Good σ (a, 0)) (hb : F.Good σ (b, 0)) : + F.Good σ (a + b, 0) := by + have hb' := F.good_axis_swap σ b hzero hb + have hh := F.good_diagonal_horizontal σ (a, 0) (0, b) ha hb' + have hv := F.good_rect σ 0 (a + b, b) hzero (by simpa using hh) + simpa using hv + +lemma FoliatedSequence.good_axis_neg (F : FoliatedSequence) (σ a : ℝ) + (hzero : F.Good σ 0) (ha : F.Good σ (a, 0)) : F.Good σ (-a, 0) := by + have hh := F.good_diagonal_vertical σ (a, 0) 0 ha hzero + have hd := F.good_diagonal_horizontal σ 0 (0, -a) hzero (by simpa using hh) + have hv := F.good_rect σ 0 (-a, -a) hzero (by simpa using hd) + simpa using hv + +lemma FoliatedSequence.good_nat_axis (F : FoliatedSequence) (σ a : ℝ) + (hzero : F.Good σ 0) (ha : F.Good σ (a, 0)) (m : ℕ) : + F.Good σ ((m : ℝ) * a, 0) := by + induction m with + | zero => simpa only [Nat.cast_zero, zero_mul] using (show F.Good σ (0, 0) from hzero) + | succ m ih => + convert F.good_axis_add σ ((m : ℝ) * a) a hzero ih ha using 1 + push_cast + ring_nf + +lemma FoliatedSequence.good_int_axis (F : FoliatedSequence) (σ a : ℝ) + (hzero : F.Good σ 0) (ha : F.Good σ (a, 0)) (m : ℤ) : + F.Good σ ((m : ℝ) * a, 0) := by + cases m with + | ofNat n => simpa using F.good_nat_axis σ a hzero ha n + | negSucc n => + convert F.good_axis_neg σ (((n + 1 : ℕ) : ℝ) * a) hzero + (F.good_nat_axis σ a hzero ha (n + 1)) using 1 + push_cast + ring_nf + +lemma FoliatedSequence.good_lattice (F : FoliatedSequence) (σ a : ℝ) + (hzero : F.Good σ 0) (ha : F.Good σ (a, 0)) (m n : ℤ) : + F.Good σ ((m : ℝ) * a, (n : ℝ) * a) := by + exact F.good_rect σ (0, (n : ℝ) * a) ((m : ℝ) * a, 0) + (F.good_axis_swap σ ((n : ℝ) * a) hzero (F.good_int_axis σ a hzero ha n)) + (F.good_int_axis σ a hzero ha m) + +end Zoom + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/SeparatedWindows.lean b/lean/OAI/Combinatorics/HalvingLines/SeparatedWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..82b812402ca5c5c315eca3b528b3f13c4d3104ec --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/SeparatedWindows.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.HalvingLines.Densities + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.TimeWindows +open MeasureTheory Set Filter +open scoped Topology unitInterval + +lemma exists_positive_inside (μ : Measure I) [NullSingletonClass μ] + {s t : I} (hpos : μ (Ioo s t) ≠ 0) : + ∃ J : Window, s < lower J ∧ upper J < t ∧ μ (carrier J) ≠ 0 := by + have hsupp : ∀ᵐ x ∂μ, x ∈ μ.support := μ.support_mem_ae + obtain ⟨x,hx,hxs,hxb⟩ := Measure.exists_mem_of_measure_ne_zero_of_ae hpos + ((hsupp.and (ae_avoid_boundaries μ)).filter_mono ae_restrict_le) + have hmesh : Tendsto (fun m : ℕ => 1/(2:ℝ)^m) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop (tendsto_pow_atTop_atTop_of_one_lt (by norm_num)) + have hsx : (s : ℝ) < x := hx.1 + have hxt : (x : ℝ) < t := hx.2 + obtain ⟨m,hm⟩ := (hmesh.eventually (gt_mem_nhds + (show 0 < min ((x:ℝ)-s) ((t:ℝ)-x) by positivity))).exists + obtain ⟨i,hi⟩ := UniformPartition.mem_some_cell (2^m) x + let J : Window := ⟨m,i⟩ + have hJ := carrier_subset_Icc J hi + have hxi : x ∈ Ioo (lower J) (upper J) := + ⟨lt_of_le_of_ne hJ.1 (Ne.symm (hxb m i.castSucc)), + lt_of_le_of_ne hJ.2 (hxb m i.succ)⟩ + have hw := upper_sub_lower J + have hj1 : (lower J : ℝ) ≤ x := hJ.1 + have hj2 : (x : ℝ) ≤ upper J := hJ.2 + have hm1 := (lt_min_iff.mp hm).1 + have hm2 := (lt_min_iff.mp hm).2 + dsimp [J] at hw + refine ⟨J,?_,?_,?_⟩ + · change (s : ℝ) < lower J + linarith + · change (upper J : ℝ) < t + linarith + · exact ne_of_gt ((measure_mono (Ioo_subset_carrier J)).trans_lt' + ((Measure.mem_support_iff_forall x).mp hxs _ (Ioo_mem_nhds hxi.1 hxi.2))) + +lemma carrier_subset_of_inside {J K : Window} + (hlo : lower K < lower J) (hhi : upper J < upper K) : carrier J ⊆ carrier K := by + intro x hx + have h := carrier_subset_Icc J hx + exact Ioo_subset_carrier K ⟨hlo.trans_le h.1,h.2.trans_lt hhi⟩ + +end PlanarHalving.TimeWindows +namespace PlanarHalving.TimeWindows +open MeasureTheory Set Filter +open scoped Topology unitInterval + +lemma nullSingleton_map_coe (μ : Measure I) [NullSingletonClass μ] : + NullSingletonClass (μ.map (Subtype.val : I → ℝ)) := by + constructor + intro x + rw [Measure.map_apply measurable_subtype_coe (measurableSet_singleton x)] + apply Set.Subsingleton.measure_zero + intro a ha b hb + apply Subtype.ext + exact (mem_singleton_iff.mp ha).trans (mem_singleton_iff.mp hb).symm + +lemma measure_interior_eq (μ : Measure I) [NullSingletonClass μ] (K : Window) : + μ (Ioo (lower K) (upper K)) = μ (carrier K) := by + apply le_antisymm (measure_mono (Ioo_subset_carrier K)) + calc + μ (carrier K) ≤ μ (Icc (lower K) (upper K)) := measure_mono (carrier_subset_Icc K) + _ = μ (Ioo (lower K) (upper K)) := measure_congr Ioo_ae_eq_Icc.symm + +end PlanarHalving.TimeWindows + +namespace PlanarHalving.RankLimits +open MeasureTheory Set Filter TimeWindows +open scoped Topology unitInterval + +lemma three_directions_of_independent (μ : Measure I) [NullSingletonClass μ] + (K : Window) (hpos : μ (carrier K) ≠ 0) + (Q : Point ≃L[ℝ] Point) (g : Subwindows K → Point →L[ℝ] ℝ) + (hne : ∀ t : I, t ∈ Ioo (lower K) (upper K) → + (Directions.allowed Q g (fun i => (lower i.val : ℝ)) + (fun i => (upper i.val : ℝ)) t).Nonempty) + (hind : ∀ J : Subwindows K, μ (carrier J.val) ≠ 0 → + ∃ i j : Subwindows K, carrier i.val ⊆ carrier J.val ∧ + carrier j.val ⊆ carrier J.val ∧ + Function.Injective (fun v : Point => (g i v,g j v))) : + ∃ t₁ t₂ t₃ : I, ∃ d₁ d₂ d₃ : ℝ, + t₁∈Ioo (lower K) (upper K) ∧ t₂∈Ioo (lower K) (upper K) ∧ + t₃∈Ioo (lower K) (upper K) ∧ t₁ (lower i.val : ℝ)) (fun i => (upper i.val : ℝ)) t₁={d₁} ∧ + Directions.allowed Q g (fun i => (lower i.val : ℝ)) (fun i => (upper i.val : ℝ)) t₂={d₂} ∧ + Directions.allowed Q g (fun i => (lower i.val : ℝ)) (fun i => (upper i.val : ℝ)) t₃={d₃} ∧ + d₁≠d₂ ∧ d₂≠d₃ ∧ d₁≠d₃ := by + let ν := μ.map (Subtype.val : I → ℝ) + let : NullSingletonClass ν := nullSingleton_map_coe μ + let U : Set ℝ := Ioo (lower K : ℝ) (upper K : ℝ) + have hU : 0 < ν U := by + rw [show ν U=μ (Ioo (lower K) (upper K)) by + rw [Measure.map_apply measurable_subtype_coe measurableSet_Ioo]; rfl, + measure_interior_eq μ K] + exact pos_iff_ne_zero.mpr hpos + have hmem {t : ℝ} (ht : t ∈ U) : t ∈ Icc (0:ℝ) 1 := + ⟨(lower K).property.1.trans ht.1.le,ht.2.le.trans (upper K).property.2⟩ + obtain ⟨t₁,t₂,t₃,d₁,d₂,d₃,ht₁,ht₂,ht₃,h12,h23,he1,he2,he3,hd12,hd23,hd13⟩ := + Directions.three_allowed_directions ν U (Metric.isBounded_Ioo _ _) hU Q g + (fun i => (lower i.val : ℝ)) (fun i => (upper i.val : ℝ)) + (fun t ht => hne ⟨t,hmem ht⟩ ht) (by + intro s hs t ht hst hp + let s' : I := ⟨s,hmem hs⟩ + let t' : I := ⟨t,hmem ht⟩ + have hμ : μ (Ioo s' t') ≠ 0 := by + apply ne_of_gt + rw [show ν (Ioo s t)=μ (Ioo s' t') by + rw [Measure.map_apply measurable_subtype_coe measurableSet_Ioo]; rfl] at hp + exact hp + obtain ⟨J,hsJ,hJt,hJ⟩ := exists_positive_inside μ hμ + have hJK : carrier J ⊆ carrier K := carrier_subset_of_inside + (lt_trans hs.1 hsJ) (lt_trans hJt ht.2) + obtain ⟨i,j,hi,hj,hij⟩ := hind ⟨J,hJK⟩ hJ + refine ⟨i,j,?_,?_,?_,?_,hij⟩ + · exact hsJ.trans_le (endpoints_of_subset hi).1 + · exact ((endpoints_of_subset hi).2).trans_lt hJt + · exact hsJ.trans_le (endpoints_of_subset hj).1 + · exact ((endpoints_of_subset hj).2).trans_lt hJt) + exact ⟨⟨t₁,hmem ht₁⟩,⟨t₂,hmem ht₂⟩,⟨t₃,hmem ht₃⟩,d₁,d₂,d₃, + ht₁,ht₂,ht₃,h12,h23,he1,he2,he3,hd12,hd23,hd13⟩ + +end PlanarHalving.RankLimits + +namespace PlanarHalving.Directions +open Set Filter +open scoped Topology + +lemma quadrant_allowed {ι : Type*} (Q : Plane ≃L[ℝ] Plane) + (g : ι → Plane →L[ℝ] ℝ) (lo hi : ι → ℝ) (t : ℝ) {d : Plane} + (h₁ : 0 ≤ (Q.symm d).1) (h₂ : 0 ≤ (Q.symm d).2) (hd : d ≠ 0) + (hineq : ∀ i, (hi i < t → 0 ≤ g i d) ∧ (t < lo i → g i d ≤ 0)) : + ∃ r : ℝ, 0 < r ∧ ∃ z ∈ allowed Q g lo hi t, d = r • Q (simplex z) := by + let a := Q.symm d + have ha : a ≠ 0 := by + intro he + apply hd + simpa only [a,Q.apply_symm_apply,map_zero] using congrArg Q he + have hp : 0 < a.1+a.2 := by + by_contra hn + have he : a.1=0 ∧ a.2=0 := by constructor <;> linarith + exact ha (Prod.ext he.1 he.2) + let r := a.1+a.2 + let z := a.1/r + have hz : z ∈ Icc (0:ℝ) 1 := ⟨div_nonneg h₁ hp.le, + (div_le_one hp).mpr (by change a.1 ≤ a.1+a.2; linarith [h₂])⟩ + have hr : r ≠ 0 := hp.ne' + have hd' : d = r • Q (simplex z) := by + apply Q.symm.injective + rw [map_smul,Q.symm_apply_apply] + change a = r • simplex z + ext <;> dsimp [simplex,z] + · field_simp [hr] + · field_simp [hr]; dsimp [r]; ring + refine ⟨r,hp,z,⟨hz,?_⟩,hd'⟩ + intro i + have hgd : g i d = r * g i (Q (simplex z)) := by rw [hd',map_smul]; rfl + constructor + · intro hit + have h := (hineq i).1 hit + rw [hgd] at h + exact nonneg_of_mul_nonneg_right h hp + · intro hti + have h := (hineq i).2 hti + rw [hgd] at h + exact nonpos_of_mul_nonpos_right h hp + +end PlanarHalving.Directions + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates +open scoped Topology unitInterval + +lemma actual_forward_limit {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (h : ℕ → ℝ) (hh : ∀ n, 0 < h n) + (t : I) (htA : t ≤ lower A) (htB : t ≤ lower B) + (x y : ℕ → Point) (s : ℕ → ℝ) (hs : ∀ n, 0 ≤ s n) + (hxy : ∀ n, y n = x n+s n • (1,(F n).timeSlope t)) + (a b : Point) + (hxa : Tendsto (fun n => (h n)⁻¹ • ((F n).rankChart hAB (hA n) (hB n) (x n)-p)) atTop (𝓝 a)) + (hyb : Tendsto (fun n => (h n)⁻¹ • ((F n).rankChart hAB (hA n) (hB n) (y n)-p)) atTop (𝓝 b)) + (hjx : ∀ i, Tendsto (fun n => + (((F n).system.labels (F n).generic (x n) (C i) : ℝ)-c i)/h n) atTop (𝓝 (D i a))) + (hjy : ∀ i, Tendsto (fun n => + (((F n).system.labels (F n).generic (y n) (C i) : ℝ)-c i)/h n) atTop (𝓝 (D i b))) + (hab : b-a ≠ 0) : + ∃ r : ℝ, 0 < r ∧ ∃ z ∈ Directions.allowed reflectFirst D + (fun i => (lower (C i) : ℝ)) (fun i => (upper (C i) : ℝ)) t, + b-a = r • reflectFirst (Directions.simplex z) := by + have hF (n : ℕ) (q : Point) : + (F n).rankChart hAB (hA n) (hB n) q = + (((F n).system.labels (F n).generic q A : ℝ),-((F n).system.labels (F n).generic q B : ℝ)) := by + rw [(F n).rankChart_apply]; rfl + have h₁ : b.1 ≤ a.1 := by + apply le_of_tendsto_of_tendsto ((continuous_fst.tendsto b).comp hyb) ((continuous_fst.tendsto a).comp hxa) + apply Eventually.of_forall + intro n + dsimp only [Function.comp_def] + rw [hF,hF] + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (hh n).le) + apply sub_le_sub_right + rw [hxy] + simpa only [zero_smul,add_zero] using (F n).rank_forward_before (hA n) htA (x n) (hs n) + have h₂ : a.2 ≤ b.2 := by + apply le_of_tendsto_of_tendsto ((continuous_snd.tendsto a).comp hxa) ((continuous_snd.tendsto b).comp hyb) + apply Eventually.of_forall + intro n + dsimp only [Function.comp_def] + rw [hF,hF] + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (hh n).le) + apply sub_le_sub_right + apply neg_le_neg + rw [hxy] + simpa only [zero_smul,add_zero] using (F n).rank_forward_before (hB n) htB (x n) (hs n) + apply Directions.quadrant_allowed reflectFirst D _ _ t (d:=b-a) _ _ hab + · intro i + constructor + · intro hit + have hle : D i a ≤ D i b := by + apply le_of_tendsto_of_tendsto (hjx i) (hjy i) + filter_upwards [hC i] with n hn + apply div_le_div_of_nonneg_right _ (hh n).le + apply sub_le_sub_right + rw [hxy] + simpa only [zero_smul,add_zero] using + (F n).rank_forward_after hn hit.le (x n) (hs n) + simpa only [map_sub] using sub_nonneg.mpr hle + · intro hti + have hle : D i b ≤ D i a := by + apply le_of_tendsto_of_tendsto (hjy i) (hjx i) + filter_upwards [hC i] with n hn + apply div_le_div_of_nonneg_right _ (hh n).le + apply sub_le_sub_right + rw [hxy] + simpa only [zero_smul,add_zero] using + (F n).rank_forward_before hn hti.le (x n) (hs n) + simpa only [map_sub] using sub_nonpos.mpr hle + · change 0 ≤ -(b.1-a.1) + linarith + · change 0 ≤ b.2-a.2 + linarith + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates +open scoped Topology unitInterval + +lemma actual_unoriented_limit {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (h : ℕ → ℝ) (hh : ∀ n, 0 < h n) + (t : I) (htA : t ≤ lower A) (htB : t ≤ lower B) (z : ℝ) + (hz : Directions.allowed reflectFirst D + (fun i => (lower (C i) : ℝ)) (fun i => (upper (C i) : ℝ)) t = {z}) + (x y : ℕ → Point) (s : ℕ → ℝ) + (hxy : ∀ n, y n = x n+s n • (1,(F n).timeSlope t)) + (a b : Point) + (hxa : Tendsto (fun n => (h n)⁻¹ • ((F n).rankChart hAB (hA n) (hB n) (x n)-p)) atTop (𝓝 a)) + (hyb : Tendsto (fun n => (h n)⁻¹ • ((F n).rankChart hAB (hA n) (hB n) (y n)-p)) atTop (𝓝 b)) + (hjx : ∀ i, Tendsto (fun n => + (((F n).system.labels (F n).generic (x n) (C i) : ℝ)-c i)/h n) atTop (𝓝 (D i a))) + (hjy : ∀ i, Tendsto (fun n => + (((F n).system.labels (F n).generic (y n) (C i) : ℝ)-c i)/h n) atTop (𝓝 (D i b))) : + ∃ r : ℝ, b-a = r • reflectFirst (Directions.simplex z) := by + by_cases hab : b-a=0 + · exact ⟨0,by simpa only [zero_smul] using hab⟩ + by_cases hs : ∃ᶠ n in atTop, 0 ≤ s n + · obtain ⟨ρ,hρ,hρs⟩ := extraction_of_frequently_atTop hs + obtain ⟨r,_,u,hu,hbu⟩ := actual_forward_limit (F ∘ ρ) hAB + (fun n => hA (ρ n)) (fun n => hB (ρ n)) C + (fun i => hρ.tendsto_atTop.eventually (hC i)) D c p (h ∘ ρ) (fun n => hh (ρ n)) + t htA htB (x ∘ ρ) (y ∘ ρ) (s ∘ ρ) hρs (fun n => hxy (ρ n)) a b + (hxa.comp hρ.tendsto_atTop) (hyb.comp hρ.tendsto_atTop) + (fun i => (hjx i).comp hρ.tendsto_atTop) (fun i => (hjy i).comp hρ.tendsto_atTop) hab + rw [hz,mem_singleton_iff] at hu + exact ⟨r,hu ▸ hbu⟩ + · have hs' : ∃ᶠ n in atTop, s n ≤ 0 := + ((not_frequently.mp hs).mono fun _ hn => (lt_of_not_ge hn).le).frequently + obtain ⟨ρ,hρ,hρs⟩ := extraction_of_frequently_atTop hs' + have hxy' (n : ℕ) : x (ρ n)=y (ρ n)+(-s (ρ n)) • (1,(F (ρ n)).timeSlope t) := by + rw [hxy (ρ n),neg_smul]; abel + have hab' : a-b ≠ 0 := by + intro he + exact hab (sub_eq_zero.mpr (sub_eq_zero.mp he).symm) + obtain ⟨r,_,u,hu,hbu⟩ := actual_forward_limit (F ∘ ρ) hAB + (fun n => hA (ρ n)) (fun n => hB (ρ n)) C + (fun i => hρ.tendsto_atTop.eventually (hC i)) D c p (h ∘ ρ) (fun n => hh (ρ n)) + t htA htB (y ∘ ρ) (x ∘ ρ) (fun n => -s (ρ n)) + (fun n => neg_nonneg.mpr (hρs n)) hxy' b a + (hyb.comp hρ.tendsto_atTop) (hxa.comp hρ.tendsto_atTop) + (fun i => (hjy i).comp hρ.tendsto_atTop) (fun i => (hjx i).comp hρ.tendsto_atTop) hab' + rw [hz,mem_singleton_iff] at hu + refine ⟨-r,?_⟩ + have hbu' : a-b = r • reflectFirst (Directions.simplex z) := hu ▸ hbu + rw [neg_smul,← hbu',neg_sub] + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimit +open Set Filter Metric +open scoped Topology + +theorem jet_diagonal {ι : Type*} [Nonempty ι] [Countable ι] + (f : ℕ → ι → PlanarHalving.Point → ℝ) (c : ι → ℝ) + (D : ι → PlanarHalving.Point →L[ℝ] ℝ) (p : PlanarHalving.Point) + (hfirst : ∀ i R, 0 ≤ R → ∀ ε > 0, ∀ᶠ h in 𝓝[>] (0:ℝ), ∀ᶠ n in atTop, + ∀ x ∈ closedBall p (R*h), dist (f n i x) (c i+D i (x-p)) < ε*h) + (B : ℝ → ℕ → Prop) (hbad : ∃ᶠ h in 𝓝[>] (0:ℝ), ∃ᶠ n in atTop, B h n) : + ∃ h : ℕ → ℝ, ∃ N : ℕ → ℕ, (∀ m, 0 < h m) ∧ Tendsto h atTop (𝓝 0) ∧ + Tendsto N atTop atTop ∧ (∀ m, B (h m) (N m)) ∧ + ∀ i R, 0 ≤ R → TendstoUniformlyOn + (fun m w => (f (N m) i (p+h m • w)-c i)/h m) (D i) atTop (closedBall 0 R) := by + classical + obtain ⟨e,he⟩ := exists_surjective_nat ι + let ε (m : ℕ) : ℝ := 1/(m+1) + have hε (m : ℕ) : 0 < ε m := by dsimp [ε]; positivity + have hex (m : ℕ) : ∃ h : ℝ, ∃ n : ℕ, 0] (0:ℝ), ∀ k ∈ Finset.range (m+1), ∀ᶠ n in atTop, + ∀ x ∈ closedBall p ((m+1)*h), dist (f n (e k) x) + (c (e k)+D (e k) (x-p)) < ε m*h := by + apply (eventually_all_finset _).mpr + intro k _ + exact hfirst (e k) (m+1) (by positivity) (ε m) (hε m) + have hh : ∀ᶠ h in 𝓝[>] (0:ℝ), 0 (hh m).le) + (fun m => (hhε m).le) hεlim + have hNlim : Tendsto N atTop atTop := tendsto_atTop_mono hN tendsto_id + refine ⟨h,N,hh,hhlim,hNlim,hB,?_⟩ + intro i R hR + obtain ⟨k,rfl⟩ := he i + rw [Metric.tendstoUniformlyOn_iff] + intro δ hδ + have hmlim : Tendsto (fun m : ℕ => (m:ℝ)+1) atTop atTop := + tendsto_atTop_add_const_right _ 1 tendsto_natCast_atTop_atTop + filter_upwards [eventually_ge_atTop k,hmlim.eventually (eventually_ge_atTop R), + hεlim.eventually (gt_mem_nhds hδ)] with m hkm hRm hεδ w hw + have hx : p+h m • w ∈ closedBall p ((m+1)*h m) := by + rw [mem_closedBall,dist_eq_norm,add_sub_cancel_left,norm_smul,Real.norm_eq_abs,abs_of_pos (hh m)] + have hw' : ‖w‖ ≤ R := by simpa only [mem_closedBall,dist_zero_right] using hw + nlinarith [mul_le_mul_of_nonneg_left (hw'.trans hRm) (hh m).le] + have hjm := hj m k (Finset.mem_range.mpr (by omega)) _ hx + let v : ℝ := (f (N m) (e k) (p+h m • w)-c (e k))/h m-D (e k) w + have hv : f (N m) (e k) (p+h m • w)-(c (e k)+D (e k) (p+h m • w-p))=h m*v := by + rw [add_sub_cancel_left,map_smul] + dsimp [v] + field_simp [(hh m).ne'] + ring + rw [Real.dist_eq,hv,abs_mul,abs_of_pos (hh m)] at hjm + have hvbound : |v| < ε m := by nlinarith [hh m] + rw [Real.dist_eq,abs_sub_comm] + exact hvbound.trans hεδ + +end PlanarHalving.RankLimit + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates +open scoped Topology unitInterval + +lemma jet_at_physical (F : ℕ → Configuration) {A B C : Window} + (hAB : Before A B) (hC : Before C A ∧ Before C B) + (hA : ∀ n, 0 < length (F n).R A) (hB : ∀ n, 0 < length (F n).R B) + (hCl : ∀ᶠ n in atTop, 0 < length (F n).R C) + (D : Point →L[ℝ] ℝ) (c : ℝ) (p : Point) (h : ℕ → ℝ) (hh : ∀ n, 0 (((F n).extendedRank true A B C (p+h n • w) : ℝ)-c)/h n) + D atTop (closedBall 0 R)) + (x : ℕ → Point) (a : Point) + (hxa : Tendsto (fun n => (h n)⁻¹ • ((F n).rankChart hAB (hA n) (hB n) (x n)-p)) atTop (𝓝 a)) : + Tendsto (fun n => (((F n).system.labels (F n).generic (x n) C : ℝ)-c)/h n) atTop (𝓝 (D a)) := by + let w := fun n => (h n)⁻¹ • ((F n).rankChart hAB (hA n) (hB n) (x n)-p) + have hw : ∀ᶠ n in atTop, w n∈closedBall 0 (‖a‖+1) := by + filter_upwards [hxa.norm.eventually (gt_mem_nhds (show ‖a‖<‖a‖+1 by linarith))] with n hn + exact mem_closedBall_zero_iff.mpr hn.le + have hlim := (hj (‖a‖+1) (by positivity)).tendsto_comp D.continuous.continuousWithinAt + (tendsto_nhdsWithin_iff.mpr ⟨hxa,hw⟩) + apply hlim.congr' + filter_upwards [hCl] with n hn + have he : p+h n • w n=(F n).rankChart hAB (hA n) (hB n) (x n) := by + dsimp [w] + rw [smul_smul,mul_inv_cancel₀ (hh n).ne',one_smul] + abel + rw [he,(F n).rankChart_apply,(F n).extendedRank_eq true hAB (by simpa using hC) (hA n) (hB n) hn] + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/SpatialMass.lean b/lean/OAI/Combinatorics/HalvingLines/SpatialMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..323862902cb10659136e64dd7b1f6087145281c8 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/SpatialMass.lean @@ -0,0 +1,425 @@ +import OAI.Combinatorics.HalvingLines.Noncollapse + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Spatial +open Set Filter Metric +open scoped Topology + +abbrev UnitSphere := {u : Point // ‖u‖=1} +instance : Nonempty UnitSphere := ⟨⟨(1,0),by simp [Prod.norm_def]⟩⟩ +instance : CompactSpace UnitSphere := by + have hc : IsCompact (sphere (0:Point) 1) := isCompact_sphere _ _ + have he : sphere (0:Point) 1 = {u | ‖u‖=1} := by ext x; simp + rw [he] at hc + exact isCompact_iff_compactSpace.mp hc + +noncomputable def radialU (f : Point → Point) (p : Point) (h : ℝ) : ℝ := + sSup (range fun u : UnitSphere => dist (f (p+h • (u:Point))) (f p)) +noncomputable def radialV (f : Point → Point) (p : Point) (h : ℝ) : ℝ := + sInf (range fun u : UnitSphere => dist (f (p+h • (u:Point))) (f p)) + +lemma unitSphere_param {p : Point} {h : ℝ} (hh : 0≤h) (u : UnitSphere) : + p+h • (u:Point)∈sphere p h := by + simp only [mem_sphere,dist_eq_norm,add_sub_cancel_left,norm_smul,Real.norm_eq_abs, + abs_of_nonneg hh,u.property,mul_one] + +lemma sphere_representation {p x : Point} {h : ℝ} (hh : 0 dist (f (p+h • (u:Point))) (f p)) := by + have hc : Continuous (fun u : UnitSphere => p+h • (u:Point)) := by fun_prop + exact (hf.comp_continuous hc + (fun u => sphere_subset_closedBall (unitSphere_param (p:=p) hh u))).dist continuous_const + +lemma radialU_attained {f : Point → Point} {p : Point} {h : ℝ} (hh : 0 ⟨hlo z hz,hup z hz⟩⟩ + rw [← he']; exact hlo y hy + +lemma radialV_pos {f : Point → Point} {p : Point} {h : ℝ} (hh : 0 radialU f p h) P := by + rw [continuousOn_iff_continuous_domRestrict] + let a : P × UnitSphere → Point := fun q => (q.1:Point)+h • (q.2:Point) + have ha : Continuous a := by dsimp [a]; fun_prop + have hfa : Continuous (f ∘ a) := hf.comp_continuous ha + (fun q => hP q.1 q.1.property (sphere_subset_closedBall (unitSphere_param hh q.2))) + have hfb : Continuous (fun q : P × UnitSphere => f q.1) := hf.comp_continuous + (continuous_subtype_val.comp continuous_fst) (fun q => hP q.1 q.1.property (mem_closedBall_self hh)) + have ht := isCompact_univ.continuous_sSup + (f:=fun p : P => fun u : UnitSphere => dist (f ((p:Point)+h • (u:Point))) (f p)) (hfa.dist hfb) + change Continuous (fun p : P => sSup (range fun u : UnitSphere => dist (f ((p:Point)+h • (u:Point))) (f p))) + simpa only [image_univ] using ht + +lemma continuousOn_radialV {f : Point → Point} {D P : Set Point} {h : ℝ} (hh : 0≤h) + (hf : ContinuousOn f D) (hP : ∀ p∈P, closedBall p h ⊆ D) : + ContinuousOn (fun p => radialV f p h) P := by + rw [continuousOn_iff_continuous_domRestrict] + let a : P × UnitSphere → Point := fun q => (q.1:Point)+h • (q.2:Point) + have ha : Continuous a := by dsimp [a]; fun_prop + have hfa : Continuous (f ∘ a) := hf.comp_continuous ha + (fun q => hP q.1 q.1.property (sphere_subset_closedBall (unitSphere_param hh q.2))) + have hfb : Continuous (fun q : P × UnitSphere => f q.1) := hf.comp_continuous + (continuous_subtype_val.comp continuous_fst) (fun q => hP q.1 q.1.property (mem_closedBall_self hh)) + have ht := isCompact_univ.continuous_sInf + (f:=fun p : P => fun u : UnitSphere => dist (f ((p:Point)+h • (u:Point))) (f p)) (hfa.dist hfb) + change Continuous (fun p : P => sInf (range fun u : UnitSphere => dist (f ((p:Point)+h • (u:Point))) (f p))) + simpa only [image_univ] using ht + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter MeasureTheory Metric Zoom +open scoped Topology + +noncomputable def rankCore (h : ℝ) : Set Point := + Icc (2*h) (1-2*h) ×ˢ Icc (-1+2*h) (-2*h) + +lemma rankCore_closed (h : ℝ) : IsClosed (rankCore h) := isClosed_Icc.prod isClosed_Icc + +lemma rankCore_ball {h : ℝ} (hh : 00, ∀ h, h≤δ → p∈rankCore h := by + let d := min p.1 (min (1-p.1) (min (p.2+1) (-p.2))) + have hd : 0 ?_⟩ + exact ⟨⟨by linarith,by linarith⟩,⟨by linarith,by linarith⟩⟩ + +lemma radialCompare_extrema {f : Point → Point} {p : Point} {h C M T : ℝ} + (hh : 0 radialU (f n) p (h*q^j)) := by + have hc : ContinuousOn (fun p => radialU (f n) p (h*q^j)) P := by + apply continuousOn_radialU (by positivity) (hf n) + intro p hp + exact (closedBall_subset_closedBall (mul_le_of_le_one_right hh.le (pow_le_one₀ hq hq1))).trans + (rankCore_ball hh hp) + exact hc.domRestrict + have hcV (n j : ℕ) : Continuous (fun p : P => radialV (f n) p (h*q^j)) := by + have hc : ContinuousOn (fun p => radialV (f n) p (h*q^j)) P := by + apply continuousOn_radialV (by positivity) (hf n) + intro p hp + exact (closedBall_subset_closedBall (mul_le_of_le_one_right hh.le (pow_le_one₀ hq hq1))).trans + (rankCore_ball hh hp) + exact hc.domRestrict + have hm : MeasurableSet {p : P | ∀ j : ℕ, ∀ᶠ n in atTop, + α*radialU (f n) p (h*q^j)≤radialV (f n) p (h*q^(j+1)) ∧ + radialU (f n) p (h*q^(j+1))≤β*radialV (f n) p (h*q^j)} := by + simp only [eventually_atTop] + rw [ofPred_forall] + apply MeasurableSet.iInter + intro j + rw [ofPred_exists] + apply MeasurableSet.iUnion + intro N + rw [ofPred_forall] + apply MeasurableSet.iInter + intro n + by_cases hn : N≤n + · simp only [hn,true_implies] + exact (measurableSet_le ((hcU n j).measurable.const_mul α) (hcV n (j+1)).measurable).inter + (measurableSet_le (hcU n (j+1)).measurable ((hcV n j).measurable.const_mul β)) + · simp only [hn,false_implies,ofPred_true]; exact MeasurableSet.univ + have hi := (MeasurableEmbedding.subtype_coe (rankCore_closed h).measurableSet).measurableSet_image.mpr hm + convert hi using 1 + ext p + simp only [ScaleGood,mem_ofPred_eq,mem_image,Subtype.exists] + aesop + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter MeasureTheory Metric Zoom +open scoped Topology + +lemma exists_scaleGood (f : ℕ → Point → Point) {p : Point} + (hp : p∈Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (hf : ∀ n, ContinuousOn (f n) (Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0)) + {C M T : ℝ} (hCM : C≤M) (hM : 0] (0:ℝ), ∀ᶠ n in atTop, RadialCompare (f n) p h C T) : + ∃ m : ℕ, p∈ScaleGood f ((1/T)^m) (1/T) (1/(M*T)) (M/T) := by + obtain ⟨δ,hδ,hδc⟩ := mem_nhdsGT_iff_exists_Ioo_subset.mp hc + obtain ⟨d,hd,hcore⟩ := rankCore_small hp + have hTp : 0 ?_⟩ + have hr : 0<(1/T)^m*(1/T)^j := mul_pos (pow_pos hq _) (pow_pos hq _) + have hrm : (1/T)^m*(1/T)^j≤(1/T)^m := mul_le_of_le_one_right + (pow_nonneg hq.le _) (pow_le_one₀ hq.le hq1.le) + have hrc := hδc ⟨hr,hrm.trans_lt hmδ⟩ + filter_upwards [hrc] with n hn + have hball := (closedBall_subset_closedBall hrm (x:=p)).trans + (rankCore_ball (pow_pos hq _) hmc) + have hb := radialCompare_extrema hr hT.le hM hCM ((hf n).mono hball) hn + have he : (1/T)^m*(1/T)^j/T=(1/T)^m*(1/T)^(j+1) := by rw [pow_succ]; ring + rwa [he] at hb + +lemma exists_dyadicExponent_scaleGood (f : ℕ → Point → Point) {p : Point} + (hp : p∈Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (hf : ∀ n, ContinuousOn (f n) (Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0)) + (hc : ∃ C : ℝ, 0] (0:ℝ), + ∀ᶠ n in atTop, RadialCompare (f n) p h C T) : + ∃ M m : ℕ, 2≤M ∧ p∈ScaleGood f ((1/(M:ℝ)^16)^m) (1/(M:ℝ)^16) + (1/((M:ℝ)*(M:ℝ)^16)) ((M:ℝ)/(M:ℝ)^16) := by + obtain ⟨C,_,hC⟩ := hc + obtain ⟨N,hN⟩ := exists_nat_gt C + let M := max N 2 + have hM2 : 2≤M := le_max_right _ _ + have hMp : 0<(M:ℝ) := by exact_mod_cast (lt_of_lt_of_le (by decide : 0<2) hM2) + have hM1 : 1<(M:ℝ) := by exact_mod_cast (lt_of_lt_of_le (by decide : 1<2) hM2) + have hCM : C≤(M:ℝ) := hN.le.trans (by exact_mod_cast le_max_left N 2) + have hT : 1<(M:ℝ)^16 := one_lt_pow₀ hM1 (by decide) + obtain ⟨m,hm⟩ := exists_scaleGood f hp hf hCM hMp hT (hC _ hT.le) + exact ⟨M,m,hM2,hm⟩ + +lemma positive_scaleGood {X : Type*} [MeasurableSpace X] + (μ : Measure X) (E : Set X) (hE : MeasurableSet E) (hpos : μ E≠0) + (π : X → Point) (hπ : Measurable π) (f : ℕ → Point → Point) + (hf : ∀ n, ContinuousOn (f n) (Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0)) + (hc : ∀ᵐ x ∂μ.restrict E, π x∈Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0 ∧ + ∃ C : ℝ, 0] (0:ℝ), + ∀ᶠ n in atTop, RadialCompare (f n) (π x) h C T) : + ∃ M m : ℕ, 2≤M ∧ MeasurableSet (E∩π ⁻¹' ScaleGood f ((1/(M:ℝ)^16)^m) + (1/(M:ℝ)^16) (1/((M:ℝ)*(M:ℝ)^16)) ((M:ℝ)/(M:ℝ)^16)) ∧ + μ (E∩π ⁻¹' ScaleGood f ((1/(M:ℝ)^16)^m) + (1/(M:ℝ)^16) (1/((M:ℝ)*(M:ℝ)^16)) ((M:ℝ)/(M:ℝ)^16))≠0 := by + let A := fun q : ℕ×ℕ => {x | 2≤q.1 ∧ π x∈ScaleGood f ((1/(q.1:ℝ)^16)^q.2) + (1/(q.1:ℝ)^16) (1/((q.1:ℝ)*(q.1:ℝ)^16)) ((q.1:ℝ)/(q.1:ℝ)^16)} + obtain ⟨q,hq⟩ := Limits.positive_countable_selection μ E hE hpos A (by + filter_upwards [hc] with x hx + obtain ⟨M,m,hM,hm⟩ := exists_dyadicExponent_scaleGood f hx.1 hf hx.2 + exact ⟨(M,m),hM,hm⟩) + obtain ⟨x,_,hM,_⟩ := nonempty_of_measure_ne_zero hq + have hM2 : 2≤q.1 := hM + have hMp : 0<(q.1:ℝ) := by exact_mod_cast (lt_of_lt_of_le (by decide : 0<2) hM2) + have hM1 : 1≤(q.1:ℝ) := by exact_mod_cast (le_trans (by decide : 1≤2) hM2) + have hT : 1≤(q.1:ℝ)^16 := one_le_pow₀ hM1 + have hTp : 0<(q.1:ℝ)^16 := pow_pos hMp _ + have hm := scaleGood_measurable f (h:=(1/(q.1:ℝ)^16)^q.2) + (α:=1/((q.1:ℝ)*(q.1:ℝ)^16)) (β:=(q.1:ℝ)/(q.1:ℝ)^16) + (pow_pos (div_pos zero_lt_one hTp) q.2) + (div_nonneg zero_le_one hTp.le) ((div_le_one hTp).mpr hT) hf + refine ⟨q.1,q.2,hM2,hE.inter (hm.preimage hπ),?_⟩ + exact ne_of_gt ((pos_iff_ne_zero.mpr hq).trans_le (measure_mono (by + intro x hx + exact ⟨hx.1,hx.2.2⟩))) + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter Metric +open scoped Topology + +lemma radius_le_of_ball_subset_closedBall {a b : Point} {r R : ℝ} + (hr : 0≤r) (hR : 0≤R) (hb : ball a r ⊆ closedBall b R) : r≤R := by + have hh := diam_mono hb isBounded_closedBall + rw [diam_ball_eq a hr,diam_closedBall_eq b hR] at hh + linarith + +lemma normalized_local_bounds (f : OpenPartialHomeomorph Point Point) + (hs : f.source=univ) {p₀ p : Point} {h q : ℝ} + (hh : 0 by + have hhx := (radial_extrema_bounds hh hcont₀).2.2 x hx + simpa only [hU] using hhx.2) + simpa only [hz,dist_zero_right] using hr + have hnp : ‖f.symm p‖≤1 := hupper p (by change dist p p₀≤h; linarith) + refine ⟨hnp,?_,?_⟩ + · obtain ⟨x,hx,he,_⟩ := radialU_attained hqhp hcont₁ + have hnx := hupper x (hby (sphere_subset_closedBall hx)) + rw [← he] + rw [dist_eq_norm] + exact (norm_sub_le _ _).trans (by linarith) + · intro α hα hαV + have hinner := radial_inner_enclosure f hs (hb₀ (mem_closedBall_self hh.le)) + hqhp.le (fun x hx => hαV.trans ((radial_extrema_bounds hqhp hcont₀₁).2.2 x hx).1) + rw [hz] at hinner + have hu0 := (radial_extrema_bounds hh hcont).1.trans (radial_extrema_bounds hh hcont).2.1 + apply radius_le_of_ball_subset_closedBall hα hu0 + intro y hy + obtain ⟨x,hx,rfl⟩ := hinner hy + exact radial_upper_enclosure f hs hu0 hb + (fun x hx => ((radial_extrema_bounds hh hcont).2.2 x hx).2) x (hby' hx) + +lemma scaleGood_iteration (f : ℕ → OpenPartialHomeomorph Point Point) + (hs : ∀ n, (f n).source=univ) + (ht : ∀ n, (f n).target=Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + {p₀ p : Point} {h q α β : ℝ} (hh : 0 (f n).symm) h q α β) + (hp : p∈ScaleGood (fun n => (f n).symm) h q α β) (hd : dist p p₀ normalized_local_bounds (f n) (hs n) hh hq hq2 (hb₀ n) (hb n) hd (hz n) (hU n) + refine ⟨fun n => (hlocal n).1,?_⟩ + have hlow : ∀ᶠ n in atTop, α≤radialU (f n).symm p h := by + filter_upwards [h₀.2 0] with n hn + apply (hlocal n).2.2 α hα + simpa only [Nat.zero_add,pow_zero,pow_one,mul_one,hU n] using hn.1 + intro j + induction j with + | zero => + filter_upwards [hlow,hp.2 0] with n hn hn' + constructor + · have hh' := mul_le_mul_of_nonneg_left hn hα + simp only [Nat.zero_add,pow_zero,pow_one,mul_one] at hn' + simpa only [Nat.zero_add,pow_one,pow_two] using hh'.trans hn'.1 + · simpa only [Nat.zero_add,pow_zero,pow_one,mul_one] using (hlocal n).2.1 + | succ j ih => + filter_upwards [ih,hp.2 (j+1)] with n hn hn' + have hjh : h*q^(j+1)≤h := mul_le_of_le_one_right hh.le (pow_le_one₀ hq.le (by linarith)) + have hc := (f n).continuousOn_symm.mono ((closedBall_subset_closedBall hjh).trans (hb n)) + have hvu := (radial_extrema_bounds (mul_pos hh (pow_pos hq _)) hc).2.1 + constructor + · have he := (mul_le_mul_of_nonneg_left (hn.1.trans hvu) hα).trans hn'.1 + calc + α^(j.succ+2) = α*α^(j+2) := by + rw [show j.succ+2=j+2+1 by omega,pow_succ,mul_comm] + _ ≤ _ := he + · have he := hn'.2.trans (mul_le_mul_of_nonneg_left (hvu.trans hn.2) hβ) + calc + _ ≤ β*(2*β^j) := he + _ = 2*β^j.succ := by rw [pow_succ]; ring + +end PlanarHalving.Spatial + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Sweep.lean b/lean/OAI/Combinatorics/HalvingLines/Sweep.lean new file mode 100644 index 0000000000000000000000000000000000000000..db528c0f09eb134a82342f6321d9b714b54e4485 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Sweep.lean @@ -0,0 +1,483 @@ +import OAI.Combinatorics.HalvingLines.RankMeasures + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Sweep +open Set + +noncomputable def setDistance {n : ℕ} (M N : Finset (Fin n)) : ℕ := (M\N).card + +lemma setDistance_self {n : ℕ} (M : Finset (Fin n)) : setDistance M M=0 := by + simp [setDistance] + +lemma setDistance_comm {n : ℕ} {M N : Finset (Fin n)} (hc : M.card=N.card) : + setDistance M N=setDistance N M := Finset.card_sdiff_comm hc + +lemma setDistance_triangle {n : ℕ} (M N K : Finset (Fin n)) : + setDistance M K ≤ setDistance M N+setDistance N K := by + classical + apply (Finset.card_le_card (show M\K ⊆ (M\N)∪(N\K) from ?_)).trans + (Finset.card_union_le _ _) + intro x hx + by_cases hxN : x∈N + · exact Finset.mem_union_right _ (Finset.mem_sdiff.mpr ⟨hxN,(Finset.mem_sdiff.mp hx).2⟩) + · exact Finset.mem_union_left _ (Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hx).1,hxN⟩) + +structure States {n T k : ℕ} (P : Fin n → Point) where + slope : Fin (T+1) → ℝ + increasing : StrictMono slope + marks : Fin (T+1) → Finset (Fin n) + card_marks : ∀ i, (marks i).card=k + separates : ∀ i, Separates P (slope i) (marks i) + step : ∀ i : Fin T, setDistance (marks i.castSucc) (marks i.succ) ≤ 1 + +variable {n T k a : ℕ} {P : Fin n → Point} + +noncomputable def States.distance (S : @States n T k P) (s t : Fin (T+1)) : ℕ := + setDistance (S.marks s) (S.marks t) + +lemma States.distance_self (S : @States n T k P) (s : Fin (T+1)) : S.distance s s=0 := + setDistance_self _ + +lemma States.distance_comm (S : @States n T k P) (s t : Fin (T+1)) : S.distance s t=S.distance t s := + setDistance_comm (by rw [S.card_marks,S.card_marks]) + +lemma States.distance_triangle (S : @States n T k P) (s t u : Fin (T+1)) : + S.distance s u ≤ S.distance s t+S.distance t u := setDistance_triangle _ _ _ + +noncomputable def States.eligible (S : @States n T k P) (s : Fin (T+1)) (a : ℕ) : Finset (Fin (T+1)) := + Finset.univ.filter (fun t => s ?_) j + · simpa only [Fin.castSucc_zero,Fin.cons_zero,Fin.cons_succ,Q.first] using S.next_distance s ha h + · simpa only [Fin.castSucc_succ,Fin.cons_succ] using Q.distance j + · intro u v hsu huv hd + by_cases htu : t≤u + · obtain ⟨j,hj⟩ := Q.hit u v htu huv hd + refine ⟨j.succ,?_⟩ + simpa only [Fin.cons_succ] using hj + · have hut : u s,rfl,?_,?_,?_⟩ + · intro i j hij + exact False.elim (by have hi:=i.isLt; have hj:=j.isLt; change i.val S.slope ((S.greedy 0 a ha).index j) + increasing := S.increasing.comp (S.greedy 0 a ha).increasing + marks := fun j => S.marks ((S.greedy 0 a ha).index j) + card_marks := fun _j => S.card_marks _ + separates := fun _j => S.separates _ + distance := (S.greedy 0 a ha).distance + +end PlanarHalving.Sweep +namespace PlanarHalving.Sweep +open Set + +lemma slope_symm (p q : Point) : slope p q=slope q p := by + unfold slope + rw [← neg_sub q.2 p.2,← neg_sub q.1 p.1,neg_div_neg_eq] + +noncomputable def criticalSlopes {n : ℕ} (P : Fin n → Point) : Finset ℝ := + (Finset.univ.filter (fun ij : Fin n × Fin n => ij.1≠ij.2)).image + (fun ij => slope (P ij.1) (P ij.2)) + +lemma mem_criticalSlopes {n : ℕ} (P : Fin n → Point) {i j : Fin n} (hij : i≠j) : + slope (P i) (P j)∈criticalSlopes P := by + classical + exact Finset.mem_image.mpr ⟨(i,j),Finset.mem_filter.mpr ⟨Finset.mem_univ _,hij⟩,rfl⟩ + +lemma projection_injective {n : ℕ} {P : Fin n → Point} (hx : Function.Injective (fun i => (P i).1)) + {s : ℝ} (hs : s∉criticalSlopes P) : Function.Injective (fun i => projection s (P i)) := by + intro i j hij + by_contra hn + apply hs + have hd : (P j).1-(P i).1≠0 := sub_ne_zero.mpr (fun h => hn (hx h.symm)) + have he : s=slope (P i) (P j) := by + apply (eq_div_iff hd).mpr + unfold projection at hij + linarith + rw [he] + exact mem_criticalSlopes P hn + +structure Traversal (C : Finset ℝ) where + size : ℕ + cut : Fin (size+2) → ℝ + increasing : StrictMono cut + critical : ∀ c, c∈C ↔ ∃ j : Fin size, cut j.succ.castSucc=c + +lemma strictMono_snoc {m : ℕ} {f : Fin m → ℝ} {b : ℝ} + (hf : StrictMono f) (hb : ∀ j, f j < b) : StrictMono (Fin.snoc f b) := by + intro i j hij + revert hij + refine Fin.lastCases ?_ (fun j => ?_) j + · intro hij + have hi : i≠Fin.last m := ne_of_lt hij + obtain ⟨i,rfl⟩ := Fin.exists_castSucc_eq.mpr hi + simpa only [Fin.snoc_castSucc,Fin.snoc_last] using hb i + · refine Fin.lastCases ?_ (fun i => ?_) i + · intro hij + exact False.elim (not_lt_of_ge (Fin.le_last _) hij) + · intro hij + simpa only [Fin.snoc_castSucc] using hf (Fin.castSucc_lt_castSucc_iff.mp hij) + +noncomputable def traversal (C : Finset ℝ) : Traversal C := by + classical + let m := C.card + let e := C.orderIsoOfFin rfl + let lo := Classical.choose (C.finite_toSet.bddBelow.exists_le 0) + have hlo := (Classical.choose_spec (C.finite_toSet.bddBelow.exists_le 0)).2 + let hi := Classical.choose (C.finite_toSet.bddAbove.exists_ge 0) + have hhi := (Classical.choose_spec (C.finite_toSet.bddAbove.exists_ge 0)).2 + let upper := max lo hi + have hup : ∀ c∈C, c≤upper := fun _ hc => (hhi _ hc).trans (le_max_right _ _) + let f : Fin m → ℝ := fun j => (e j : ℝ) + have hf : StrictMono f := fun i j hij => e.strictMono hij + refine ⟨m,Fin.cons (lo-1) (Fin.snoc f (upper+1)),?_,?_⟩ + · apply Fin.strictMono_cons.mpr + refine ⟨?_,strictMono_snoc hf ?_⟩ + · intro j + refine Fin.lastCases ?_ (fun i => ?_) j + · simp only [Fin.snoc_last] + have hle : lo≤upper := le_max_left _ _ + linarith + · simpa only [Fin.snoc_castSucc] using lt_of_lt_of_le (sub_lt_self lo (by norm_num : (0:ℝ) < 1)) (hlo _ (e i).property) + · intro i + exact lt_of_le_of_lt (hup _ (e i).property) (lt_add_one upper) + · intro c + constructor + · intro hc + refine ⟨e.symm ⟨c,hc⟩,?_⟩ + simpa only [Fin.castSucc_succ,Fin.cons_succ,Fin.snoc_castSucc,f] using + congrArg Subtype.val (e.apply_symm_apply ⟨c,hc⟩) + · rintro ⟨j,rfl⟩ + simpa only [Fin.castSucc_succ,Fin.cons_succ,Fin.snoc_castSucc,f] using (e j).property + +variable {C : Finset ℝ} + +noncomputable def Traversal.sample (T : Traversal C) (i : Fin (T.size+1)) : ℝ := + (T.cut i.castSucc+T.cut i.succ)/2 + +lemma Traversal.sample_bounds (T : Traversal C) (i : Fin (T.size+1)) : + T.cut i.castSucc < T.sample i ∧ T.sample i < T.cut i.succ := by + have h := T.increasing (show i.castSucc < i.succ from Fin.castSucc_lt_succ) + dsimp [Traversal.sample] + constructor <;> linarith + +lemma Traversal.sample_increasing (T : Traversal C) : StrictMono T.sample := by + intro i j hij + have hc : i.succ≤j.castSucc := by change i.val+1≤j.val; exact Nat.succ_le_of_lt hij + exact (T.sample_bounds i).2.trans_le (T.increasing.monotone hc) |>.trans (T.sample_bounds j).1 + +lemma Traversal.sample_not_mem (T : Traversal C) (i : Fin (T.size+1)) : T.sample i∉C := by + intro h + obtain ⟨j,hj⟩ := (T.critical _).mp h + have hl := (T.sample_bounds i).1 + have hu := (T.sample_bounds i).2 + rw [← hj] at hl hu + have hl' := T.increasing.lt_iff_lt.mp hl + have hu' := T.increasing.lt_iff_lt.mp hu + change i.val < j.val+1 at hl' + change j.val+1 < i.val+1 at hu' + omega + +lemma Traversal.unique_critical (T : Traversal C) (i : Fin T.size) {c : ℝ} (hc : c∈C) + (hl : T.sample i.castSucc < c) (hu : c < T.sample i.succ) : c=T.cut i.succ.castSucc := by + obtain ⟨j,hj⟩ := (T.critical _).mp hc + have hl' := (T.sample_bounds i.castSucc).1.trans hl + have hu' := hu.trans (T.sample_bounds i.succ).2 + rw [← hj] at hl' hu' + have hl'' := T.increasing.lt_iff_lt.mp hl' + have hu'' := T.increasing.lt_iff_lt.mp hu' + have he : j=i := by + apply Fin.ext + change i.val < j.val+1 at hl'' + change j.val+1 < i.val+1+1 at hu'' + omega + simpa only [he] using hj.symm + +lemma separates_step_distance {n k : ℕ} {P : Fin n → Point} (hP : Generic P) + {s t : ℝ} (hst : s≤t) {M N : Finset (Fin n)} (hM : M.card=k) (hN : N.card=k) + (hs : Separates P s M) (ht : Separates P t N) + (hone : ∀ c∈criticalSlopes P, ∀ d∈criticalSlopes P, + s < c → c < t → s < d → d < t → c=d) : setDistance M N≤1 := by + classical + rw [setDistance,Finset.card_le_one] + intro i hi u hu + have hne : (N\M).Nonempty := by + have he := Finset.card_sdiff_comm (hM.trans hN.symm) + have hp := Finset.card_pos.mpr (⟨i,hi⟩ : (M\N).Nonempty) + rw [he] at hp + exact Finset.card_pos.mp hp + obtain ⟨j,hj⟩ := hne + have hiJ : i≠j := by intro he; subst j; exact (Finset.mem_sdiff.mp hj).2 (Finset.mem_sdiff.mp hi).1 + have huJ : u≠j := by intro he; subst j; exact (Finset.mem_sdiff.mp hj).2 (Finset.mem_sdiff.mp hu).1 + have hsi := exchange_slope_between hst hs ht hi hj + have hsu := exchange_slope_between hst hs ht hu hj + have he := hone _ (mem_criticalSlopes P hiJ) _ (mem_criticalSlopes P huJ) hsi.1 hsi.2 hsu.1 hsu.2 + rw [slope_symm (P i) (P j),slope_symm (P u) (P j)] at he + exact PlaneGraph.slope_eq_implies_eq_ne hP.1 + (hP.2.1 j i hiJ.symm) (hP.2.1 j u huJ.symm) he + +noncomputable def states {n k : ℕ} (P : Fin n → Point) (hP : Generic P) (hk : k≤n) : + @States n (traversal (criticalSlopes P)).size k P := by + let T := traversal (criticalSlopes P) + have hex (i : Fin (T.size+1)) := exists_state P (T.sample i) hk + (projection_injective (PlaneGraph.Generic.x_injective hP) (T.sample_not_mem i)) + choose M hM hsep using hex + refine ⟨T.sample,T.sample_increasing,M,hM,hsep,?_⟩ + intro i + apply separates_step_distance hP (T.sample_increasing.monotone (Fin.castSucc_le_succ i)) (hM _) (hM _) (hsep _) (hsep _) + intro c hc d hd hcs hct hds hdt + exact (T.unique_critical i hc hcs hct).trans (T.unique_critical i hd hds hdt).symm + +end PlanarHalving.Sweep +namespace PlanarHalving.Sweep +open Set +variable {n T k : ℕ} {P : Fin n → Point} + +def StepDisjoint (C : Finset (Fin (T+1) × Fin (T+1))) : Prop := + ∀ p∈C, ∀ q∈C, p≠q → Disjoint (Ioc p.1 p.2) (Ioc q.1 q.2) + +lemma States.Greedy.packing (S : @States n T k P) {a : ℕ} + (Q : S.Greedy 0 a) (C : Finset (Fin (T+1) × Fin (T+1))) + (hC : StepDisjoint C) (horder : ∀ p∈C, p.1≤p.2) + (hd : ∀ p∈C, 2*a-1≤S.distance p.1 p.2) : C.card≤Q.count := by + classical + have hex (p : ↥C) : ∃ j : Fin Q.count, p.val.1 < Q.index j.succ ∧ Q.index j.succ≤p.val.2 := + Q.hit _ _ (Fin.zero_le _) (horder _ p.property) (hd _ p.property) + choose f hf using hex + have hinj : Function.Injective f := by + intro p q he + by_contra hpq + have hdis := hC _ p.property _ q.property (fun h => hpq (Subtype.ext h)) + exact Set.disjoint_left.mp hdis (hf p) (by simpa only [Set.mem_Ioc,he] using hf q) + simpa only [Fintype.card_coe,Fintype.card_fin] using Fintype.card_le_of_injective f hinj + +lemma States.greedy_packing (S : @States n T k P) {d : ℕ} (hd : 0 < d) + (C : Finset (Fin (T+1) × Fin (T+1))) (hC : StepDisjoint C) + (horder : ∀ p∈C, p.1≤p.2) (hdist : ∀ p∈C, d≤S.distance p.1 p.2) : + C.card≤(S.greedy 0 ((d+1)/2) (by omega)).count := by + apply (S.greedy 0 ((d+1)/2) (by omega)).packing S C hC horder + intro p hp + exact (show 2*((d+1)/2)-1≤d by omega).trans (hdist p hp) + +lemma States.distance_packing_cubic (S : @States n T k P) (hP : Generic P) [NeZero n] + {d : ℕ} (hd : 0 < d) (C : Finset (Fin (T+1) × Fin (T+1))) + (hC : StepDisjoint C) (horder : ∀ p∈C, p.1≤p.2) + (hdist : ∀ p∈C, d≤S.distance p.1 p.2) : + (C.card : ℝ)^3*(d : ℝ)^4≤294912*(n : ℝ)^4 := by + let a := (d+1)/2 + have ha : 0 < a := by dsimp [a]; omega + let : NeZero a := ⟨ne_of_gt ha⟩ + let Q := S.greedy 0 a ha + have hcount : C.card≤Q.count := S.greedy_packing hd C hC horder hdist + have hbound := (S.greedySystem a ha).cubed_bound hP + have hda : (d : ℝ)≤2*(a : ℝ) := by exact_mod_cast (show d≤2*a by dsimp [a]; omega) + calc + _ ≤ (Q.count : ℝ)^3*(2*(a : ℝ))^4 := by gcongr + _ = 16*((Q.count : ℝ)^3*(a : ℝ)^4) := by ring + _ ≤ 16*(18432*(n : ℝ)^4) := mul_le_mul_of_nonneg_left hbound (by norm_num) + _ = _ := by ring + +end PlanarHalving.Sweep +namespace PlanarHalving.Sweep +open Set +variable {n T k : ℕ} {P : Fin n → Point} + +noncomputable def States.intervalActivity (S : @States n T k P) + (u v : Fin (T+1)) (h : u≤v) : Finset (Fin n) := + activity (fun i : ↥(Finset.Icc u v) => S.marks i) ⟨u,Finset.mem_Icc.mpr ⟨le_rfl,h⟩⟩ + +lemma States.mem_intervalActivity (S : @States n T k P) + {u v : Fin (T+1)} (h : u≤v) {x : Fin n} : x∈S.intervalActivity u v h ↔ + ∃ i, u ≤ i ∧ i ≤ v ∧ ((x∈S.marks i ∧ x∉S.marks u) ∨ (x∉S.marks i ∧ x∈S.marks u)) := by + classical + rw [States.intervalActivity,mem_activity] + constructor + · rintro ⟨i,hi⟩ + exact ⟨i,(Finset.mem_Icc.mp i.property).1,(Finset.mem_Icc.mp i.property).2,hi⟩ + · rintro ⟨i,hu,hv,hi⟩ + exact ⟨⟨i,Finset.mem_Icc.mpr ⟨hu,hv⟩⟩,hi⟩ + +lemma States.intervalActivity_pos_distance (S : @States n T k P) + {u v : Fin (T+1)} (h : u≤v) (ha : 0<(S.intervalActivity u v h).card) : + 1≤S.distance u v := by + exact activity_pos_distance P (fun i : ↥(Finset.Icc u v) => S.slope i) + (fun i => S.marks i) ⟨u,Finset.mem_Icc.mpr ⟨le_rfl,h⟩⟩ + ⟨v,Finset.mem_Icc.mpr ⟨h,le_rfl⟩⟩ (fun i => S.card_marks i) + (fun i => S.separates i) (fun i => S.increasing.monotone (Finset.mem_Icc.mp i.property).1) + (fun i => S.increasing.monotone (Finset.mem_Icc.mp i.property).2) ha + +lemma states_intervalActivity_distance {n k : ℕ} (P : Fin n → Point) (hP : Generic P) (hk : k≤n) + {c : ℕ} {u v : Fin ((traversal (criticalSlopes P)).size+1)} (huv : u≤v) + (hc : 4*c≤((states P hP hk).intervalActivity u v huv).card) : + (∃ hk' : k+c≤n, c≤(states P hP hk').distance u v) ∨ + (∃ hk' : k-c≤n, c≤k ∧ c≤(states P hP hk').distance u v) := by + let S := states P hP hk + have hi (i) : Function.Injective (fun x => projection (S.slope i) (P x)) := + projection_injective (PlaneGraph.Generic.x_injective hP) ((traversal _).sample_not_mem i) + have hd := activity_distance P (fun i : ↥(Finset.Icc u v) => S.slope i) + (fun i => S.marks i) ⟨u,Finset.mem_Icc.mpr ⟨le_rfl,huv⟩⟩ + ⟨v,Finset.mem_Icc.mpr ⟨huv,le_rfl⟩⟩ (fun i => S.card_marks i) + (fun i => S.separates i) (fun i => S.increasing.monotone (Finset.mem_Icc.mp i.property).1) + (fun i => S.increasing.monotone (Finset.mem_Icc.mp i.property).2) (hi u) (hi v) hc + rcases hd with ⟨hk',E,E',hE,hE',hs,hs',hd⟩ | ⟨hck,E,E',hE,hE',hs,hs',hd⟩ + · left + refine ⟨hk',?_⟩ + have he : E=(states P hP hk').marks u := states_unique hs (states P hP hk' |>.separates u) (hE.trans (states P hP hk' |>.card_marks u).symm) + have he' : E'=(states P hP hk').marks v := states_unique hs' (states P hP hk' |>.separates v) (hE'.trans (states P hP hk' |>.card_marks v).symm) + simpa only [he,he',States.distance,setDistance] using hd + · right + have hk' : k-c≤n := (Nat.sub_le _ _).trans hk + refine ⟨hk',hck,?_⟩ + have he : E=(states P hP hk').marks u := states_unique hs (states P hP hk' |>.separates u) (hE.trans (states P hP hk' |>.card_marks u).symm) + have he' : E'=(states P hP hk').marks v := states_unique hs' (states P hP hk' |>.separates v) (hE'.trans (states P hP hk' |>.card_marks v).symm) + simpa only [he,he',States.distance,setDistance] using hd + +lemma cube_add_le {x y : ℝ} (hx : 0≤x) (hy : 0≤y) : (x+y)^3≤4*(x^3+y^3) := by + nlinarith [mul_nonneg (sq_nonneg (x-y)) (add_nonneg hx hy)] + +lemma activity_packing_cubic {n k : ℕ} (P : Fin n → Point) (hP : Generic P) + [NeZero n] (hk : k≤n) {b : ℕ} (hb : 0 ∃ hk' : k+c≤n, c≤(states P hP hk').distance p.1 p.2) + let B := C\A + have hA : A⊆C := Finset.filter_subset _ _ + have hB : B⊆C := Finset.sdiff_subset + have hbound (D : Finset _) (hD : D⊆C) (r : ℕ) + (hd : ∀ p∈D, ∃ hr : r≤n, c≤(states P hP hr).distance p.1 p.2) : + (D.card : ℝ)^3*(c : ℝ)^4≤294912*(n : ℝ)^4 := by + by_cases hne : D.Nonempty + · obtain ⟨p,hp⟩ := hne + obtain ⟨hr,_⟩ := hd p hp + apply (states P hP hr).distance_packing_cubic hP hc D + · exact fun p hp q hq hpq => hC p (hD hp) q (hD hq) hpq + · exact fun p hp => horder p (hD hp) + · intro p hp + obtain ⟨hr',hh⟩ := hd p hp + exact hh + · simp only [Finset.not_nonempty_iff_eq_empty.mp hne,Finset.card_empty,Nat.cast_zero,zero_pow (by omega : (3:ℕ)≠0),zero_mul] + positivity + have hAb := hbound A hA (k+c) (fun p hp => (Finset.mem_filter.mp hp).2) + have hBb := hbound B hB (k-c) (fun p hp => by + have hpC := hB hp + have hh := states_intervalActivity_distance P hP hk (horder p hpC) + ((show 4*c≤b from Nat.mul_div_le b 4).trans (hactivity p hpC)) + rcases hh with hh | ⟨hr,_,hh⟩ + · exact False.elim ((Finset.mem_sdiff.mp hp).2 (Finset.mem_filter.mpr ⟨hpC,hh⟩)) + · exact ⟨hr,hh⟩) + have hcard : (C.card : ℝ)=(A.card : ℝ)+(B.card : ℝ) := by + exact_mod_cast (by simpa only [B,Nat.add_comm] using (Finset.card_sdiff_add_card_eq_card hA).symm : C.card=A.card+B.card) + have hsum := mul_le_mul_of_nonneg_right (cube_add_le (show (0:ℝ)≤A.card by positivity) (show (0:ℝ)≤B.card by positivity)) (show (0:ℝ)≤(c : ℝ)^4 by positivity) + rw [← hcard] at hsum + have hcub : (C.card : ℝ)^3*(c : ℝ)^4≤2359296*(n : ℝ)^4 := by nlinarith [hAb,hBb] + calc + _ ≤ (C.card : ℝ)^3*(8*(c : ℝ))^4 := by gcongr + _ = 4096*((C.card : ℝ)^3*(c : ℝ)^4) := by ring + _ ≤ 4096*(2359296*(n : ℝ)^4) := mul_le_mul_of_nonneg_left hcub (by norm_num) + _ ≤ _ := by nlinarith [sq_nonneg ((n : ℝ)^2)] + · have hd := S.distance_packing_cubic hP (by omega : 0<1) C hC horder + (fun p hp => S.intervalActivity_pos_distance (horder p hp) (lt_of_lt_of_le hb (hactivity p hp))) + norm_num at hd + have hbLe : (b : ℝ)≤3 := by exact_mod_cast (by omega : b≤3) + calc + _ ≤ (C.card : ℝ)^3*3^4 := by gcongr + _ ≤ 294912*(n : ℝ)^4*3^4 := mul_le_mul_of_nonneg_right hd (by norm_num) + _ ≤ _ := by nlinarith [sq_nonneg ((n : ℝ)^2)] + +end PlanarHalving.Sweep + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/ThinStrips.lean b/lean/OAI/Combinatorics/HalvingLines/ThinStrips.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3afb59cc00e40d0d1ba609daad4d21b2850e42c --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/ThinStrips.lean @@ -0,0 +1,484 @@ +import OAI.Combinatorics.HalvingLines.BoundaryTokens + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Spatial +open Set Filter MeasureTheory Boundary +open scoped Topology unitInterval + +lemma isOpenMap_encode : IsOpenMap encode := by + have h : IsOpenMap unitInterval.sigmoid := + Topology.isEmbedding_sigmoid.isInducing.isOpenMap (by rw [unitInterval.range_sigmoid]; exact isOpen_Ioo) + exact h.prodMap h + +lemma isOpen_square (a b : ℝ) : IsOpen {x : Point | InSquare a b x} := by + exact (isOpen_lt continuous_const continuous_fst).inter + ((isOpen_lt continuous_fst continuous_const).inter + ((isOpen_lt continuous_const continuous_snd).inter (isOpen_lt continuous_snd continuous_const))) + +lemma continuous_dot (ν : Point) : Continuous (dot ν) := by + exact (continuous_const.mul continuous_fst).add (continuous_const.mul continuous_snd) + +noncomputable def awayStrips (t θ : ℝ) (c : Fin 3 → ℝ) : Set Point := + {x | InSquare (-2) 2 x ∧ ∀ j, 18*θ < |dot (rawNormal t) x-c j|} + +lemma isOpen_awayStrips (t θ : ℝ) (c : Fin 3 → ℝ) : IsOpen (awayStrips t θ c) := by + have he : awayStrips t θ c={x : Point | InSquare (-2) 2 x} ∩ ⋂ j : Fin 3, {x | 18*θ < |dot (rawNormal t) x-c j|} := by + ext x; simp [awayStrips] + rw [he] + apply (isOpen_square (-2) 2).inter + exact isOpen_iInter_of_finite (fun j : Fin 3 => isOpen_lt continuous_const ((continuous_dot _).sub continuous_const).abs) + +lemma awayStrips_stable {ts θs : ℕ → ℝ} {cs : ℕ → Fin 3 → ℝ} + {t θ : ℝ} {c : Fin 3 → ℝ} + (ht : Tendsto ts atTop (𝓝 t)) (hθ : Tendsto θs atTop (𝓝 θ)) + (hc : Tendsto cs atTop (𝓝 c)) {ε : ℝ} (hε : 0<ε) : + ∀ᶠ n in atTop, awayStrips t (θ+ε) c ⊆ awayStrips (ts n) (θs n) (cs n) := by + have ht' := (tendsto_order.mp ((tendsto_sub_nhds_zero_iff.mpr ht).abs)).2 ε (by simpa using hε) + have hθ' := (tendsto_order.mp ((tendsto_sub_nhds_zero_iff.mpr hθ).abs)).2 (ε/2) (by simpa using half_pos hε) + have hc' : ∀ᶠ n in atTop, ∀ j, |cs n j-c j|<ε := by + apply Filter.eventually_all.mpr + intro j + exact (tendsto_order.mp ((tendsto_sub_nhds_zero_iff.mpr (tendsto_pi_nhds.mp hc j)).abs)).2 ε (by simpa using hε) + filter_upwards [ht',hθ',hc'] with n hn hnθ hnc x hx + refine ⟨hx.1,fun j => ?_⟩ + have h1 : |x.1|≤2 := abs_le.mpr ⟨hx.1.1.le,hx.1.2.1.le⟩ + have h2 : |x.2|≤2 := abs_le.mpr ⟨hx.1.2.2.1.le,hx.1.2.2.2.le⟩ + have hdiff : |dot (rawNormal (ts n)) x-dot (rawNormal t) x|≤4*|ts n-t| := by + have he : dot (rawNormal (ts n)) x-dot (rawNormal t) x=-(ts n-t)*(x.1+x.2) := by dsimp [dot,rawNormal]; ring + rw [he,abs_mul,abs_neg] + have hh : |x.1+x.2|≤4 := (abs_add_le _ _).trans (by linarith) + nlinarith [mul_le_mul_of_nonneg_left hh (abs_nonneg (ts n-t))] + have htotal : |(dot (rawNormal (ts n)) x-cs n j)-(dot (rawNormal t) x-c j)|<5*ε := by + have he : (dot (rawNormal (ts n)) x-cs n j)-(dot (rawNormal t) x-c j)= + (dot (rawNormal (ts n)) x-dot (rawNormal t) x)-(cs n j-c j) := by ring + rw [he] + have hh := abs_sub (dot (rawNormal (ts n)) x-dot (rawNormal t) x) (cs n j-c j) + have hncj := hnc j + linarith + have hh := abs_abs_sub_abs_le_abs_sub (dot (rawNormal (ts n)) x-cs n j) (dot (rawNormal t) x-c j) + have hh' := (abs_le.mp hh).1 + have hlow := hx.2 j + have hup := (abs_lt.mp hnθ).2 + linarith + +end PlanarHalving.Spatial + +namespace PlanarHalving.Spatial +open Set Filter MeasureTheory Boundary Limits +open scoped Topology unitInterval ENNReal + +lemma awayStrips_antitone (t : ℝ) (c : Fin 3 → ℝ) : Antitone (fun θ => awayStrips t θ c) := by + intro θ θ' hθ x hx + exact ⟨hx.1,fun j => (mul_le_mul_of_nonneg_left hθ (by norm_num)).trans_lt (hx.2 j)⟩ + +lemma awayStrips_iUnion (t θ : ℝ) (c : Fin 3 → ℝ) : + (⋃ m : ℕ, awayStrips t (θ+1/((m:ℝ)+1)) c)=awayStrips t θ c := by + apply subset_antisymm + · intro x hx + obtain ⟨m,hm⟩ := mem_iUnion.mp hx + exact awayStrips_antitone t c (le_add_of_nonneg_right (by positivity)) hm + · intro x hx + have hh : ∀ᶠ m : ℕ in atTop, ∀ j, 18*(θ+1/((m:ℝ)+1)) < |dot (rawNormal t) x-c j| := by + apply Filter.eventually_all.mpr + intro j + have hl : Tendsto (fun m : ℕ => 18*(θ+1/((m:ℝ)+1))) atTop (𝓝 (18*θ)) := by + simpa using (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜:=ℝ)).const_add θ |>.const_mul 18 + exact hl.eventually (eventually_lt_nhds (hx.2 j)) + obtain ⟨m,hm⟩ := hh.exists + exact mem_iUnion.mpr ⟨m,hx.1,hm⟩ + +lemma moving_strips_limit {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + {μs : ℕ → FiniteMeasure (X × Cube)} {μ : FiniteMeasure (X × Cube)} + (hμ : Tendsto μs atTop (𝓝 μ)) + {ts θs bs : ℕ → ℝ} {cs : ℕ → Fin 3 → ℝ} {t θ b : ℝ} {c : Fin 3 → ℝ} + (ht : Tendsto ts atTop (𝓝 t)) (hθ : Tendsto θs atTop (𝓝 θ)) + (hc : Tendsto cs atTop (𝓝 c)) (hb : Tendsto bs atTop (𝓝 b)) + (hfinite : ∀ᶠ n in atTop, + (μs n (Prod.snd ⁻¹' (encode '' awayStrips (ts n) (θs n) (cs n))):ℝ) ≤ 2*bs n) : + (μ (Prod.snd ⁻¹' (encode '' awayStrips t θ c)):ℝ) ≤ 2*b := by + let O (m : ℕ) : Set (X × Cube) := Prod.snd ⁻¹' (encode '' awayStrips t (θ+1/((m:ℝ)+1)) c) + have hO (m : ℕ) : IsOpen (O m) := + (isOpenMap_encode _ (isOpen_awayStrips ..)).preimage continuous_snd + have hbound (m : ℕ) : (μ (O m):ℝ) ≤ 2*b := by + apply open_le_of_eventually_le hμ (hO m) (hb.const_mul 2) + have he := awayStrips_stable ht hθ hc (show 0<1/((m:ℝ)+1) by positivity) + filter_upwards [he,hfinite] with n hn hnf + exact (show (μs n (O m):ℝ) ≤ μs n (Prod.snd ⁻¹' (encode '' awayStrips (ts n) (θs n) (cs n))) from + NNReal.coe_le_coe.mpr ((μs n).apply_mono (preimage_mono (image_mono hn)))).trans hnf + have hmono : Monotone O := by + intro m n hmn + apply preimage_mono + apply image_mono + apply awayStrips_antitone + have hm : (0:ℝ) < m+1 := by positivity + have hn : (0:ℝ) < n+1 := by positivity + have hmn' : (m:ℝ)+1 ≤ n+1 := by exact_mod_cast Nat.add_le_add_right hmn 1 + exact add_le_add_right ((one_div_le_one_div hn hm).mpr hmn') θ + have hunion : (⋃ m, O m)=Prod.snd ⁻¹' (encode '' awayStrips t θ c) := by + rw [← awayStrips_iUnion t θ c,image_iUnion,preimage_iUnion] + have hbound' (m : ℕ) : (μ : Measure (X × Cube)) (O m) ≤ ENNReal.ofReal (2*b) := by + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,← ENNReal.ofReal_coe_nnreal] + exact ENNReal.ofReal_le_ofReal (hbound m) + have he : (μ : Measure (X × Cube)) (Prod.snd ⁻¹' (encode '' awayStrips t θ c)) ≤ ENNReal.ofReal (2*b) := by + rw [← hunion,hmono.measure_iUnion] + exact iSup_le hbound' + have hb0 : 0≤2*b := (NNReal.coe_nonneg (μ (O 0))).trans (hbound 0) + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,← ENNReal.ofReal_coe_nnreal] at he + exact (ENNReal.ofReal_le_ofReal_iff hb0).mp he + +end PlanarHalving.Spatial +namespace PlanarHalving.Spatial +open Set Filter Metric MeasureTheory Boundary Limits +open scoped Topology unitInterval ENNReal + +lemma limiting_activity_bound {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] + (μ ν : FiniteMeasure (X × Cube)) (H : Set (X × Cube)) (_hH : MeasurableSet H) + (hν : (ν : Measure (X × Cube))≤μ) + (hpos : ∀ z∈H, ‖decode z.2‖≤1 ∧ encode (decode z.2)=z.2) + {C d t θ b : ℝ} (hC : 0≤C) (hd : 1 closedBall (0:Point) 1 ∩ {x | |dot (rawNormal t) x-c j|≤18*θ} + let A : Fin 3 → Set (X × Cube) := fun j => ψ ⁻¹' D j ∩ H + let O : Set (X × Cube) := Prod.snd ⁻¹' (encode '' awayStrips t θ c) + have hD (j : Fin 3) : MeasurableSet (D j) := measurableSet_closedBall.inter + (isClosed_le (((continuous_dot _).sub continuous_const).abs) continuous_const).measurableSet + have hψ : Measurable ψ := measurable_decode.comp measurable_snd + have hsub : H ⊆ O ∪ ⋃ j : Fin 3, A j := by + intro z hz + have hp := hpos z hz + by_cases hstrip : ∃ j, |dot (rawNormal t) (ψ z)-c j|≤18*θ + · obtain ⟨j,hj⟩ := hstrip + refine Or.inr (mem_iUnion.mpr ⟨j,⟨?_,hj⟩,hz⟩) + simpa only [mem_closedBall,dist_zero_right,ψ,Function.comp_apply] using hp.1 + · apply Or.inl + refine ⟨ψ z,⟨?_,fun j => lt_of_not_ge (fun hj => hstrip ⟨j,hj⟩)⟩,hp.2⟩ + have hx := (norm_fst_le (ψ z)).trans hp.1 + have hy := (norm_snd_le (ψ z)).trans hp.1 + rw [Real.norm_eq_abs] at hx hy + have hx' := abs_le.mp hx + have hy' := abs_le.mp hy + change -2<(ψ z).1 ∧ (ψ z).1<2 ∧ -2<(ψ z).2 ∧ (ψ z).2<2 + constructor + · linarith + constructor + · linarith + constructor <;> linarith + have hA (j : Fin 3) : (μ : Measure (X × Cube)) (A j)=β (D j) := by + rw [Measure.map_apply hψ (hD j),Measure.restrict_apply ((hD j).preimage hψ)] + have hstrip (j : Fin 3) : (ν : Measure (X × Cube)) (A j)≤ + ENNReal.ofReal (13*C*(1+3^d)*36^(d-1)*θ^(d-1)) := by + exact (hν (A j)).trans ((hA j) ▸ raw_strip_bound β hC hd hbound t (c j) hθ) + have haway' : (ν : Measure (X × Cube)) O≤ENNReal.ofReal (2*b) := by + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,← ENNReal.ofReal_coe_nnreal] + exact ENNReal.ofReal_le_ofReal haway + have htotal : (ν : Measure (X × Cube)) H≤ + ENNReal.ofReal (2*b+3*(13*C*(1+3^d)*36^(d-1))*θ^(d-1)) := by + calc + _ ≤ (ν : Measure (X × Cube)) (O ∪ ⋃ j : Fin 3, A j) := measure_mono hsub + _ ≤ (ν : Measure (X × Cube)) O + (ν : Measure (X × Cube)) (⋃ j : Fin 3, A j) := measure_union_le _ _ + _ ≤ ENNReal.ofReal (2*b)+∑ j : Fin 3, ENNReal.ofReal (13*C*(1+3^d)*36^(d-1)*θ^(d-1)) := by + apply add_le_add haway' + exact (measure_iUnion_fintype_le _ _).trans (Finset.sum_le_sum (fun j _ => hstrip j)) + _ = _ := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + rw [← ENNReal.ofReal_natCast 3,← ENNReal.ofReal_mul (by positivity),← ENNReal.ofReal_add (by positivity) (by positivity)] + congr 1 + ring + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,← ENNReal.ofReal_coe_nnreal] at htotal + exact (ENNReal.ofReal_le_ofReal_iff (by positivity)).mp htotal + +end PlanarHalving.Spatial + +namespace PlanarHalving.Boundary +open Set +open scoped Classical + +noncomputable def batchRange (R s m : ℕ) : Finset (Fin R) := + Finset.univ.filter fun i => s ≤ i.val ∧ i.val < s+m + +lemma sum_batchRange {M : Type*} [AddCommMonoid M] {R s m : ℕ} (h : s+m≤R) (w : Fin R → M) : + ∑ i∈batchRange R s m, w i=∑ i : Fin m, w ⟨s+i.val,by omega⟩ := by + classical + symm + apply Finset.sum_bij (fun i _ => (⟨s+i.val,by omega⟩ : Fin R)) + · intro i _ + simp only [batchRange,Finset.mem_filter,Finset.mem_univ,true_and] + constructor <;> omega + · intro i _ j _ hij + have hh := congrArg Fin.val hij + apply Fin.ext + simpa using hh + · intro i hi + obtain ⟨hil,hir⟩ := (Finset.mem_filter.mp hi).2 + refine ⟨⟨i.val-s,by omega⟩,Finset.mem_univ _,?_⟩ + apply Fin.ext + simp only + omega + · intro i _; rfl + +lemma sum_disjoint_ranges {ι : Type*} (F : Finset ι) {R : ℕ} (s m : ι → ℕ) + (hd : Set.PairwiseDisjoint (↑F:Set ι) (fun j => batchRange R (s j) (m j))) + (w : Fin R → ℝ) (hw : ∀ i, 0≤w i) : + ∑ j∈F, ∑ i∈batchRange R (s j) (m j), w i ≤ ∑ i : Fin R, w i := by + classical + rw [← Finset.sum_biUnion hd] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun i _ _ => hw i) + +lemma parameter_telescope {R : ℕ} (t : Fin (R+1) → ℝ) : + ∑ i : Fin R, (t i.succ-t i.castSucc)=t (Fin.last R)-t 0 := by + rw [Finset.sum_sub_distrib] + have h₁ := Fin.sum_univ_succ t + have h₂ := Fin.sum_univ_castSucc t + linarith + +lemma parameter_range_sum {R s m : ℕ} (h : s+m≤R) (t : Fin (R+1) → ℝ) : + ∑ i∈batchRange R s m, (t i.succ-t i.castSucc)= + t ⟨s+m,by omega⟩-t ⟨s,by omega⟩ := by + rw [sum_batchRange h] + convert parameter_telescope (fun i : Fin (m+1) => t ⟨s+i.val,by omega⟩) using 1 <;> simp [Nat.add_assoc] + +lemma parameter_budget {ι : Type*} (F : Finset ι) {R : ℕ} (s m : ι → ℕ) + (hd : Set.PairwiseDisjoint (↑F:Set ι) (fun j => batchRange R (s j) (m j))) + (t : Fin (R+1) → ℝ) (ht : Monotone t) (htI : ∀ i,t i∈Icc (0:ℝ) 1) : + ∑ j∈F, ∑ i∈batchRange R (s j) (m j), (t i.succ-t i.castSucc) ≤ 1 := by + have hh := sum_disjoint_ranges F s m hd (fun i => t i.succ-t i.castSucc) + (fun i => sub_nonneg.mpr (ht (by simp [Fin.le_def]))) + rw [parameter_telescope] at hh + have hlo := (htI 0).1 + have hhi := (htI (Fin.last R)).2 + linarith + +end PlanarHalving.Boundary + +namespace PlanarHalving.TimeWindows +open Set + +lemma cuts_of_subset (R : ℕ) [NeZero R] {J K : Window} (h : carrier J⊆carrier K) : + start R K ≤ start R J ∧ stop R J ≤ stop R K := by + obtain ⟨hl,hu⟩ := endpoints_of_subset h + exact ⟨cut_mono _ hl,cut_mono _ hu⟩ + +lemma relative_end_le (R : ℕ) [NeZero R] {J K : Window} (h : carrier J⊆carrier K) : + start R J-start R K+length R J≤length R K := by + have hcut := cuts_of_subset R h + have hJ := start_add_length R J + have hK := start_add_length R K + omega + +end PlanarHalving.TimeWindows +namespace PlanarHalving.Batches +open Set TimeWindows +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.vertices_eq_of_marks (S T : @System n R k a P) (h : S.marks=T.marks) : + S.vertices=T.vertices := by + classical + unfold System.vertices System.edges System.loss System.gain + rw [h] + +lemma System.relative_vertices (S : @System n R k a P) [NeZero R] + {K J : Window} (h : carrier J⊆carrier K) : + ((S.timeWindow K).window (start R J-start R K) (length R J) (relative_end_le R h)).vertices= + (S.timeWindow J).vertices := by + apply System.vertices_eq_of_marks + funext i + dsimp [System.timeWindow,System.window] + congr 1 + apply Fin.ext + simp only + have hc := (cuts_of_subset R h).1 + omega + +end PlanarHalving.Batches + +namespace PlanarHalving.Boundary +open Set Filter +open scoped Topology unitInterval PiCountable + +abbrev CompactParams := Icc (0:ℝ) 4 × I × I × (Fin 3 → Icc (-4:ℝ) 4) + +lemma params_subsequence {J : Type*} [Countable J] (p : ℕ → J → CompactParams) : + ∃ (φ : ℕ → ℕ) (b t θ : J → ℝ) (c : J → Fin 3 → ℝ), StrictMono φ ∧ + (∀ j, b j∈Icc (0:ℝ) 4 ∧ t j∈Icc (0:ℝ) 1 ∧ θ j∈Icc (0:ℝ) 1 ∧ + ∀ i, c j i∈Icc (-4:ℝ) 4) ∧ + (∀ j, Tendsto (fun n => (p (φ n) j).1.val) atTop (𝓝 (b j))) ∧ + (∀ j, Tendsto (fun n => (p (φ n) j).2.1.val) atTop (𝓝 (t j))) ∧ + (∀ j, Tendsto (fun n => (p (φ n) j).2.2.1.val) atTop (𝓝 (θ j))) ∧ + (∀ j, Tendsto (fun n i => ((p (φ n) j).2.2.2 i).val) atTop (𝓝 (c j))) := by + obtain ⟨q,φ,hφ,hq⟩ := CompactSpace.tendsto_subseq p + refine ⟨φ,fun j => (q j).1.val,fun j => (q j).2.1.val,fun j => (q j).2.2.1.val, + fun j i => ((q j).2.2.2 i).val,hφ,?_,?_,?_,?_,?_⟩ + · intro j + exact ⟨(q j).1.property,(q j).2.1.property,(q j).2.2.1.property, + fun i => ((q j).2.2.2 i).property⟩ + · intro j + exact continuous_subtype_val.tendsto _ |>.comp (tendsto_pi_nhds.mp hq j).fst_nhds + · intro j + exact continuous_subtype_val.tendsto _ |>.comp (tendsto_pi_nhds.mp hq j).snd_nhds.fst_nhds + · intro j + exact continuous_subtype_val.tendsto _ |>.comp (tendsto_pi_nhds.mp hq j).snd_nhds.snd_nhds.fst_nhds + · intro j + apply tendsto_pi_nhds.mpr + intro i + exact continuous_subtype_val.tendsto _ |>.comp (tendsto_pi_nhds.mp (tendsto_pi_nhds.mp hq j).snd_nhds.snd_nhds.snd_nhds i) + +lemma finite_budget_limit {J : Type*} (F : Finset J) (f : ℕ → J → ℝ) (g : J → ℝ) {B : ℝ} + (h : ∀ j, Tendsto (fun n => f n j) atTop (𝓝 (g j))) + (hf : ∀ᶠ n in atTop, ∑ j∈F, f n j ≤ B) : ∑ j∈F, g j≤B := by + apply le_of_tendsto (tendsto_finsetSum F (fun j _ => h j)) hf + +end PlanarHalving.Boundary + +namespace PlanarHalving.Batches +open Set Boundary +open scoped Classical +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.vertices_changes (S : @System n R k a P) {v : Fin n} (hv : v∈S.vertices) : + ∃ i j : Fin (R+1), ¬(v∈S.marks i ↔ v∈S.marks j) := by + classical + rcases Finset.mem_union.mp hv with hv | hv + · obtain ⟨e,he,rfl⟩ := Finset.mem_image.mp hv + obtain ⟨b,hb,_⟩ := (S.mem_edges e).mp he + obtain ⟨hl,hr⟩ := Finset.mem_sdiff.mp hb + exact ⟨b.castSucc,b.succ,fun h => hr (h.mp hl)⟩ + · obtain ⟨e,he,rfl⟩ := Finset.mem_image.mp hv + obtain ⟨b,_,hb⟩ := (S.mem_edges e).mp he + obtain ⟨hl,hr⟩ := Finset.mem_sdiff.mp hb + exact ⟨b.castSucc,b.succ,fun h => hr (h.mpr hl)⟩ + +lemma System.tokenState_image (S : @System n R k a P) [NeZero a] + (j : Fin a) (i : Fin (R+1)) : + Finset.univ.image (fun u : ↥(S.marks 0) => (S.tokenState j i u : Fin n))=S.marks i := by + classical + ext v + constructor + · rintro hv + obtain ⟨u,_,rfl⟩ := Finset.mem_image.mp hv + exact (S.tokenState j i u).property + · intro hv + exact Finset.mem_image.mpr ⟨(S.tokenState j i).symm ⟨v,hv⟩,Finset.mem_univ _, + congrArg Subtype.val ((S.tokenState j i).apply_symm_apply _)⟩ + +noncomputable def System.boundaryCount (S : @System n R k a P) [NeZero a] + (p : Fin n → Point) (j : Fin a) (i : Fin R) : ℕ := + (Finset.univ.filter fun u : ↥(S.marks 0) => + ¬(InSquare (-2) 2 (p (S.tokenState j i.castSucc u)) ↔ + InSquare (-2) 2 (p (S.tokenState j i.succ u)))).card + +lemma System.boundary_budget (S : @System n R k a P) [NeZero a] + (p : Fin n → Point) (j : Fin a) + (h1 : ∀ u, Monotone (fun i => (p (S.tokenState j i u)).1)) + (h2 : ∀ u, Monotone (fun i => (p (S.tokenState j i u)).2)) : + ∑ i : Fin R, S.boundaryCount p j i ≤ 4*n := by + have hh := square_token_budget (fun i u => p (S.tokenState j i u)) h1 h2 (-2) 2 + apply hh.trans + rw [Fintype.card_coe] + exact Nat.mul_le_mul_left _ (by simpa using Finset.card_le_univ (S.marks 0)) + +lemma System.window_boundary (S : @System n R k a P) [NeZero a] + (E : Point ≃L[ℝ] Point) {A B l u : ℝ} (hA : 0 frameParameter A B l u (S.slope i) + let i₀ : Fin (R+1) := ⟨s,by omega⟩ + let i₁ : Fin (R+1) := ⟨s+m,by omega⟩ + ∃ c : Fin 3 → ℝ, (∀ h, c h∈Icc (-4:ℝ) 4) ∧ + (((S.window s m hsm).vertices.filter fun v => + InSquare (-2) 2 (physical E o r (P v)) ∧ + ∀ h, 18*(T i₁-T i₀) < |dot (rawNormal (T i₀)) (physical E o r (P v))-c h|).card) ≤ + 2*∑ i : Fin m, S.boundaryCount (fun v => physical E o r (P v)) j ⟨s+i.val,by omega⟩ := by + classical + dsimp only + obtain ⟨c,hc⟩ := actual_transformed_cuts S E hA hB hlu h1 h2 hspan o hr + let idx : Fin (m+1) → Fin (R+1) := fun i => ⟨s+i.val,by omega⟩ + let f : Fin (m+1) → ↥(S.marks 0) → Fin n := fun i t => S.tokenState j (idx i) t + have hf : ∀ i, Function.Injective (f i) := fun i => Subtype.val_injective.comp (S.tokenState j (idx i)).injective + have himg (i : Fin (m+1)) (v : Fin n) : v∈Finset.univ.image (f i) ↔ v∈S.marks (idx i) := by + constructor + · intro hv + obtain ⟨u,_,rfl⟩ := Finset.mem_image.mp hv + exact (S.tokenState j (idx i) u).property + · intro hv + exact Finset.mem_image.mpr ⟨(S.tokenState j (idx i)).symm ⟨v,hv⟩,Finset.mem_univ _, + congrArg Subtype.val ((S.tokenState j (idx i)).apply_symm_apply _)⟩ + have ht : Monotone (fun i : Fin (m+1) => frameParameter A B l u (S.slope (idx i))) := by + intro v w hvw + apply frameParameter_monotone hA hB hlu (hspan _) (hspan _) + apply S.increasing.monotone + simp only [idx,Fin.le_def] + exact Nat.add_le_add_left hvw s + have htI (i : Fin (m+1)) : frameParameter A B l u (S.slope (idx i))∈Icc (0:ℝ) 1 := + frameParameter_mem hA hB hlu (hspan _) + have hh := finite_raw_bound (fun v => physical E o r (P v)) f hf + (S.window s m hsm).vertices (fun i => frameParameter A B l u (S.slope (idx i))) (fun i => c (idx i)) ht htI + (by + intro i v + simpa only [Finset.mem_image,Finset.mem_univ,true_and] using (himg i v).trans (hc (idx i) v)) + (by + intro v hv + obtain ⟨i,j,hij⟩ := (S.window s m hsm).vertices_changes hv + refine ⟨i,j,?_⟩ + intro he + apply hij + have hi := himg i v + have hj := himg j v + simp only [Finset.mem_image,Finset.mem_univ,true_and] at he hi hj + exact hi.symm.trans (he.trans hj)) + obtain ⟨d,hd,hbound⟩ := hh + refine ⟨d,hd,?_⟩ + have hsum : (∑ i : Fin m, (Finset.univ.filter fun u : ↥(S.marks 0) => + ¬(InSquare (-2) 2 (physical E o r (P (f i.castSucc u))) ↔ + InSquare (-2) 2 (physical E o r (P (f i.succ u))))).card)= + ∑ i : Fin m, S.boundaryCount (fun v => physical E o r (P v)) j ⟨s+i.val,by omega⟩ := by + apply Finset.sum_congr rfl + intro i _ + congr 1 + rw [hsum] at hbound + convert hbound using 1; congr 1 + +end PlanarHalving.Batches + +namespace PlanarHalving.TimeWindows +open Set Boundary +open scoped Classical +abbrev Subwindow (K : Window) := {J : Window // carrier J ⊆ carrier K} + +lemma relative_range_disjoint (R : ℕ) [NeZero R] {K : Window} (J H : Subwindow K) + (h : Disjoint (carrier J.val) (carrier H.val)) : + Disjoint (batchRange (length R K) (start R J.val-start R K) (length R J.val)) + (batchRange (length R K) (start R H.val-start R K) (length R H.val)) := by + apply Finset.disjoint_left.mpr + intro i hi hj + have hi' := (Finset.mem_filter.mp hi).2 + have hj' := (Finset.mem_filter.mp hj).2 + have hJ := (cuts_of_subset R J.property).1 + have hH := (cuts_of_subset R H.property).1 + have hK := start_add_length R K + have hK' := stop_le R K + have heJ := start_add_length R J.val + have heH := start_add_length R H.val + let b : Fin R := ⟨start R K+i.val,by omega⟩ + have hbJ : time R b∈carrier J.val := by + apply (mem_carrier_iff R J.val b).mpr + dsimp [b] + constructor <;> omega + have hbH : time R b∈carrier H.val := by + apply (mem_carrier_iff R H.val b).mpr + dsimp [b] + constructor <;> omega + exact Set.disjoint_left.mp h hbJ hbH + +end PlanarHalving.TimeWindows + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Tokens.lean b/lean/OAI/Combinatorics/HalvingLines/Tokens.lean new file mode 100644 index 0000000000000000000000000000000000000000..6be1513ddb899a95a666aa6ab4124b6b2dbc58d3 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Tokens.lean @@ -0,0 +1,391 @@ +import OAI.Combinatorics.HalvingLines.PathLimits + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Boundary +open Set Filter +open scoped Topology + +lemma sum_cube_le {ι : Type*} (s : Finset ι) (f : ι → ℝ) + (hf : ∀ i ∈ s, 0 ≤ f i) : + (∑ i ∈ s, f i)^3 ≤ (s.card : ℝ)^2 * ∑ i ∈ s, (f i)^3 := by + have hh := Real.rpow_sum_le_const_mul_sum_rpow_of_nonneg s (f := f) (p := 3) (by norm_num) hf + norm_num only [show (3 : ℝ)-1=2 by norm_num, Real.rpow_ofNat] at hh + exact hh + +lemma sum_angular_power_le {ι : Type*} (s : Finset ι) (θ : ι → ℝ) + (hθ : ∀ i ∈ s, 0 ≤ θ i) {α : ℝ} (hα : 0 < α) (hα1 : α ≤ 1) : + (∑ i ∈ s, θ i ^ α) ≤ (s.card : ℝ)^(1-α) * (∑ i ∈ s, θ i)^α := by + by_cases hs : s.Nonempty + · have hc : 0 < (s.card : ℝ) := Nat.cast_pos.mpr hs.card_pos + have hh := Real.rpow_sum_le_const_mul_sum_rpow_of_nonneg s + (f := fun i => θ i^α) (p := α⁻¹) ((one_le_inv₀ hα).mpr hα1) + (fun i hi => Real.rpow_nonneg (hθ i hi) α) + have hsum : 0 ≤ ∑ i ∈ s, θ i^α := Finset.sum_nonneg (fun i hi => Real.rpow_nonneg (hθ i hi) α) + have hsum' : 0 ≤ ∑ i ∈ s, θ i := Finset.sum_nonneg hθ + have hev (i : ι) (hi : i ∈ s) : (θ i^α)^α⁻¹ = θ i := Real.rpow_rpow_inv (hθ i hi) hα.ne' + simp_rw [Finset.sum_congr rfl hev] at hh + have hp := Real.rpow_le_rpow (Real.rpow_nonneg hsum _) hh hα.le + rw [← Real.rpow_mul hsum,inv_mul_cancel₀ hα.ne',Real.rpow_one, + Real.mul_rpow (Real.rpow_nonneg hc.le _) hsum',← Real.rpow_mul hc.le] at hp + have he : (α⁻¹-1)*α = 1-α := by + calc + (α⁻¹-1)*α = α⁻¹*α - α := by ring + _ = 1-α := by rw [inv_mul_cancel₀ hα.ne'] + rwa [he] at hp + · have he : s = ∅ := Finset.not_nonempty_iff_eq_empty.mp hs + simp only [he,Finset.sum_empty,Finset.card_empty,Nat.cast_zero] + rw [Real.zero_rpow hα.ne',mul_zero] + +end PlanarHalving.Boundary + +namespace PlanarHalving.Boundary +open Set Filter +open scoped Topology + +lemma high_mass_bound {ι : Type*} (S : Finset ι) (lam s : ι → ℝ) + {q M H : ℝ} (hq : 0 < q) (hM : 0 < M) + (hlam : ∀ i ∈ S, lam i ≤ q⁻¹) + (htail : ∀ u > 0, ((S.filter fun i => u < s i).card : ℝ) ≤ H * u^(-(4:ℝ)/3)) : + ∑ i ∈ S with M*q^(-(3:ℝ)/4) < s i, lam i ≤ H*M^(-(4:ℝ)/3) := by + classical + let t := M*q^(-(3:ℝ)/4) + have ht : 0 < t := mul_pos hM (Real.rpow_pos_of_pos hq _) + have hpow : t^(-(4:ℝ)/3) = M^(-(4:ℝ)/3)*q := by + dsimp [t] + rw [Real.mul_rpow hM.le (Real.rpow_nonneg hq.le _),← Real.rpow_mul hq.le] + norm_num + have hp := mul_le_mul_of_nonneg_right (htail t ht) (inv_nonneg.mpr hq.le) + rw [hpow] at hp + have hbound := Finset.sum_le_sum (s := S.filter (fun i => t < s i)) + (f := lam) (g := fun _ => q⁻¹) (fun i hi => hlam i (Finset.mem_filter.mp hi).1) + simp only [Finset.sum_const, nsmul_eq_mul] at hbound + apply hbound.trans + convert hp using 1; field_simp + +lemma activity_sum_bound {ι : Type*} (S : Finset ι) (μ b θ : ι → ℝ) + {q B B₀ T α : ℝ} (hq : 0 ≤ q) (hB : 0 ≤ B) (_hT : 0 ≤ T) + (hα : 0 < α) (hα1 : α ≤ 1) + (hcard : (S.card : ℝ) ≤ q) (hb : ∑ i ∈ S, b i ≤ B₀) + (hθ : ∀ i ∈ S, 0 ≤ θ i) (hθsum : ∑ i ∈ S, θ i ≤ T) + (hμ : ∀ i ∈ S, μ i ≤ 2*b i+B*θ i^α) : + ∑ i ∈ S, μ i ≤ 2*B₀+B*q^(1-α)*T^α := by + have hsum0 : 0 ≤ ∑ i ∈ S, θ i := Finset.sum_nonneg hθ + have hc := Real.rpow_le_rpow (Nat.cast_nonneg S.card) hcard (sub_nonneg.mpr hα1) + have hθp := Real.rpow_le_rpow hsum0 hθsum hα.le + have hpow := (sum_angular_power_le S θ hθ hα hα1).trans + (mul_le_mul hc hθp (Real.rpow_nonneg hsum0 _) (Real.rpow_nonneg hq _)) + have hsum := Finset.sum_le_sum hμ + simp only [Finset.sum_add_distrib, ← Finset.mul_sum] at hsum + have hm := mul_le_mul_of_nonneg_left hpow hB + nlinarith only [hsum,hb,hm] + +lemma low_cube_bound {ι : Type*} (S : Finset ι) (lam μ s : ι → ℝ) + {q M A U : ℝ} (hq : 0 < q) (hM : 0 < M) (hA : 0 ≤ A) + (hcard : (S.card : ℝ) ≤ q) + (hlam : ∀ i ∈ S, 0 ≤ lam i) (hμ : ∀ i ∈ S, 0 ≤ μ i) (hs : ∀ i ∈ S, 0 ≤ s i) + (hmass : ∀ i ∈ S, (lam i)^3 ≤ A*(s i)^3*μ i) + (hμsum : ∑ i ∈ S, μ i ≤ U) : + (∑ i ∈ S with s i ≤ M*q^(-(3:ℝ)/4), lam i)^3 ≤ + A*M^3*q^(-(1:ℝ)/4)*U := by + classical + let t := M*q^(-(3:ℝ)/4) + let L := S.filter (fun i => s i ≤ t) + have ht : 0 < t := mul_pos hM (Real.rpow_pos_of_pos hq _) + have hL (i : ι) (hi : i ∈ L) : i ∈ S ∧ s i ≤ t := Finset.mem_filter.mp hi + have hμsumL : ∑ i ∈ L, μ i ≤ U := + (Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset ..) (fun i hi _ => hμ i hi)).trans hμsum + have hmassL : ∑ i ∈ L, (lam i)^3 ≤ A*t^3*U := by + calc + _ ≤ ∑ i ∈ L, A*t^3*μ i := by + apply Finset.sum_le_sum + intro i hi + apply (hmass i (hL i hi).1).trans + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (hs i (hL i hi).1) (hL i hi).2 3) hA) + (hμ i (hL i hi).1) + _ = A*t^3 * ∑ i ∈ L, μ i := by rw [Finset.mul_sum] + _ ≤ A*t^3*U := mul_le_mul_of_nonneg_left hμsumL (by positivity) + have hc : (L.card : ℝ) ≤ q := (Nat.cast_le.mpr (Finset.card_filter_le ..)).trans hcard + have hcube := sum_cube_le L lam (fun i hi => hlam i (hL i hi).1) + have hsumlam : 0 ≤ ∑ i ∈ L, (lam i)^3 := by + exact Finset.sum_nonneg (fun i hi => pow_nonneg (hlam i (hL i hi).1) _) + have hc2 : (L.card : ℝ)^2 ≤ q^2 := by nlinarith [show (0:ℝ) ≤ L.card from Nat.cast_nonneg _] + have hbound := hcube.trans ((mul_le_mul_of_nonneg_right hc2 hsumlam).trans + (mul_le_mul_of_nonneg_left hmassL (sq_nonneg q))) + have he : q^2*t^3 = M^3*q^(-(1:ℝ)/4) := by + dsimp [t] + rw [mul_pow,← Real.rpow_mul_natCast hq.le] + simp only [Nat.cast_ofNat] + rw [← Real.rpow_ofNat q 2] + calc + q^(2:ℝ) * (M^3 * q^((-(3:ℝ)/4)*3)) = + M^3*(q^(2:ℝ)*q^((-(3:ℝ)/4)*3)) := by ring + _ = M^3*q^(-(1:ℝ)/4) := by rw [← Real.rpow_add hq]; congr 2; norm_num + change (∑ i ∈ L, lam i)^3 ≤ _ + calc + _ ≤ q^2*(A*t^3*U) := hbound + _ = A*(q^2*t^3)*U := by ring + _ = A*(M^3*q^(-(1:ℝ)/4))*U := by rw [he] + _ = A*M^3*q^(-(1:ℝ)/4)*U := by ring + +end PlanarHalving.Boundary + +namespace PlanarHalving.Boundary +open Set Filter +open scoped Topology + +lemma low_bound_tendsto_zero {q : ℕ → ℝ} (hq : ∀ n, 0 < q n) + (hqtop : Tendsto q atTop atTop) {α : ℝ} (hα : (3:ℝ)/4 < α) + (A M B₀ B T : ℝ) : + Tendsto (fun n => A*M^3*(q n)^(-(1:ℝ)/4)* + (2*B₀+B*(q n)^(1-α)*T^α)) atTop (𝓝 0) := by + have h1 : Tendsto (fun n => (q n)^(-(1:ℝ)/4)) atTop (𝓝 0) := by + have hh := (tendsto_rpow_neg_atTop (show (0:ℝ)<1/4 by norm_num)).comp hqtop + convert hh using 1 + funext n + rw [Function.comp_apply,neg_div] + have h2 : Tendsto (fun n => (q n)^((3:ℝ)/4-α)) atTop (𝓝 0) := by + have hh := (tendsto_rpow_neg_atTop (sub_pos.mpr hα)).comp hqtop + convert hh using 1 + funext n + rw [Function.comp_apply,neg_sub] + have ht := (h1.const_mul (A*M^3*(2*B₀))).add + (h2.const_mul (A*M^3*B*T^α)) + simp only [mul_zero,add_zero] at ht + apply ht.congr + intro n + have he : (q n)^(-(1:ℝ)/4)*(q n)^(1-α) = (q n)^((3:ℝ)/4-α) := by + rw [← Real.rpow_add (hq n)] + congr 1 + ring + calc + _ = A*M^3*(2*B₀)*(q n)^(-(1:ℝ)/4) + + A*M^3*B*T^α*((q n)^(-(1:ℝ)/4)*(q n)^(1-α)) := by rw [he] + _ = _ := by ring + +theorem mass_eq_zero {ι : Type*} (S : ℕ → Finset ι) + (lam μ s b θ : ℕ → ι → ℝ) (q : ℕ → ℝ) + {L A H B B₀ T α : ℝ} + (hL : 0 ≤ L) (hA : 0 ≤ A) (hB : 0 ≤ B) (hT : 0 ≤ T) + (hα : (3:ℝ)/4 < α) (hα1 : α ≤ 1) + (hq : ∀ n, 0 < q n) (hqtop : Tendsto q atTop atTop) + (hcard : ∀ n, ((S n).card : ℝ) ≤ q n) + (hlam0 : ∀ n i, i ∈ S n → 0 ≤ lam n i) + (hlam1 : ∀ n i, i ∈ S n → lam n i ≤ (q n)⁻¹) + (hμ0 : ∀ n i, i ∈ S n → 0 ≤ μ n i) + (hs0 : ∀ n i, i ∈ S n → 0 ≤ s n i) + (hθ0 : ∀ n i, i ∈ S n → 0 ≤ θ n i) + (hmass : ∀ n i, i ∈ S n → (lam n i)^3 ≤ A*(s n i)^3*μ n i) + (hactivity : ∀ n i, i ∈ S n → μ n i ≤ 2*b n i+B*(θ n i)^α) + (hbsum : ∀ n, ∑ i ∈ S n, b n i ≤ B₀) + (hθsum : ∀ n, ∑ i ∈ S n, θ n i ≤ T) + (htail : ∀ n u, 0 < u → ((S n |>.filter fun i => u < s n i).card : ℝ) ≤ + H*u^(-(4:ℝ)/3)) + (hpartition : ∀ n, L ≤ ∑ i ∈ S n, lam n i) : L = 0 := by + classical + by_contra hne + have hLp : 0 < L := lt_of_le_of_ne hL (Ne.symm hne) + have hdecay : Tendsto (fun M : ℝ => H*M^(-(4:ℝ)/3)) atTop (𝓝 0) := by + simpa only [neg_div,mul_zero] using + (tendsto_rpow_neg_atTop (show (0:ℝ)<4/3 by norm_num)).const_mul H + obtain ⟨M,hM,hMH⟩ : ∃ M : ℝ, 0 < M ∧ H*M^(-(4:ℝ)/3) < L/2 := by + have hev := (hdecay.eventually (eventually_lt_nhds (half_pos hLp))).and + (eventually_gt_atTop (0:ℝ)) + obtain ⟨M,h1,h2⟩ := hev.exists + exact ⟨M,h2,h1⟩ + have hμsum (n : ℕ) : ∑ i ∈ S n, μ n i ≤ + 2*B₀+B*(q n)^(1-α)*T^α := + activity_sum_bound (S n) (μ n) (b n) (θ n) (hq n).le hB hT + (by linarith) hα1 (hcard n) (hbsum n) (hθ0 n) (hθsum n) (hactivity n) + have hdecay2 := low_bound_tendsto_zero hq hqtop hα A M B₀ B T + have hthr : 0 < (L/2)^3 := pow_pos (half_pos hLp) _ + obtain ⟨n,hn⟩ := (hdecay2.eventually (eventually_lt_nhds hthr)).exists + have hhigh := high_mass_bound (S n) (lam n) (s n) (hq n) hM (hlam1 n) (htail n) + have hlow := low_cube_bound (S n) (lam n) (μ n) (s n) (hq n) hM hA + (hcard n) (hlam0 n) (hμ0 n) (hs0 n) (hmass n) (hμsum n) + have hlow' : (∑ i ∈ S n with s n i ≤ M*(q n)^(-(3:ℝ)/4), lam n i) < L/2 := by + by_contra hnot + have hlole : L/2 ≤ ∑ i ∈ S n with s n i ≤ M*(q n)^(-(3:ℝ)/4), lam n i := le_of_not_gt hnot + have hp := pow_le_pow_left₀ (half_pos hLp).le hlole 3 + exact (not_lt_of_ge (hp.trans hlow)) hn + have hsplit := Finset.sum_filter_add_sum_filter_not (S n) + (fun i => s n i ≤ M*(q n)^(-(3:ℝ)/4)) (lam n) + simp only [not_le] at hsplit + have htotal := hpartition n + linarith only [hhigh,hMH,hlow',hsplit,htotal] + +end PlanarHalving.Boundary + +namespace PlanarHalving.RankCoordinates +open Set + +lemma exists_slope_avoiding (p : Point) (F : Finset Point) {l u : ℝ} + (hlu : l < u) (hp : p ∉ F) : + ∃ s ∈ Ioo l u, ∀ z ∈ F, z.2 ≠ p.2+s*(z.1-p.1) := by + classical + obtain ⟨s,hs,havoid⟩ := (Ioo_infinite hlu).exists_notMem_finset + (F.image (fun z => (z.2-p.2)/(z.1-p.1))) + refine ⟨s,hs,?_⟩ + intro z hz he + by_cases hx : z.1 = p.1 + · have heq : z = p := Prod.ext hx (by rw [hx,sub_self,mul_zero,add_zero] at he; exact he) + exact hp (heq ▸ hz) + · apply havoid + apply Finset.mem_image.mpr + refine ⟨z,hz,?_⟩ + apply (div_eq_iff (sub_ne_zero.mpr hx)).mpr + linarith only [he] + +lemma exists_affine_avoiding (F : Finset Point) (s : ℝ) : + ∃ c : ℝ, ∀ z ∈ F, s*z.1+c ≠ z.2 := by + classical + obtain ⟨c,_,hc⟩ := (Set.infinite_univ : (Set.univ : Set ℝ).Infinite).exists_notMem_finset + (F.image (fun z => z.2-s*z.1)) + refine ⟨c,?_⟩ + intro z hz he + apply hc + exact Finset.mem_image.mpr ⟨z,hz,by linarith only [he]⟩ + +end PlanarHalving.RankCoordinates + +namespace PlanarHalving.Batches +open Set PlaneGraph RankCoordinates +variable {R : ℕ} + +lemma ConvexPath.interior_slopes (C : ConvexPath R) {L U : ℝ} + (hLU : L < U) + (hedge : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + L < slope (C.point b.castSucc) (C.point b.succ) ∧ + slope (C.point b.castSucc) (C.point b.succ) < U) : + ∃ l u : ℝ, L < l ∧ l ≤ u ∧ u < U ∧ + ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l < slope (C.point b.castSucc) (C.point b.succ) ∧ + slope (C.point b.castSucc) (C.point b.succ) < u := by + classical + let E := Finset.univ.filter (fun b : Fin R => C.point b.castSucc ≠ C.point b.succ) + by_cases he : E.Nonempty + · obtain ⟨b,hb,hbmin⟩ := Finset.exists_min_image E + (fun b => slope (C.point b.castSucc) (C.point b.succ)) he + obtain ⟨c,hc,hcmax⟩ := Finset.exists_max_image E + (fun b => slope (C.point b.castSucc) (C.point b.succ)) he + have hb' := (Finset.mem_filter.mp hb).2 + have hc' := (Finset.mem_filter.mp hc).2 + obtain ⟨l,hlL,hl⟩ := exists_between (hedge b hb').1 + obtain ⟨u,hu,huU⟩ := exists_between (hedge c hc').2 + refine ⟨l,u,hlL,((hl.trans_le (hbmin c hc)).trans hu).le,huU,?_⟩ + intro i hi + have hi' : i ∈ E := Finset.mem_filter.mpr ⟨Finset.mem_univ i,hi⟩ + exact ⟨hl.trans_le (hbmin i hi'),(hcmax i hi').trans_lt hu⟩ + · obtain ⟨l,hlL,hlU⟩ := exists_between hLU + refine ⟨l,l,hlL,le_rfl,hlU,?_⟩ + intro b hb + exact (he ⟨b,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hb⟩⟩).elim + +lemma ConvexPath.exists_clean_extension (C : ConvexPath R) (F : Finset Point) + {L U : ℝ} (hLU : L < U) + (hp₀ : C.point 0 ∉ F) (hp₁ : C.point (Fin.last R) ∉ F) + (hedge : ∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + L < slope (C.point b.castSucc) (C.point b.succ) ∧ + slope (C.point b.castSucc) (C.point b.succ) < U) : + ∃ l u : ℝ, L < l ∧ l ≤ u ∧ u < U ∧ + (∀ b : Fin R, C.point b.castSucc ≠ C.point b.succ → + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ + slope (C.point b.castSucc) (C.point b.succ) ≤ u) ∧ + ∀ z ∈ F, C.extension l u z.1 = z.2 → + ∃ b : Fin R, C.point b.castSucc ≠ C.point b.succ ∧ + z ∈ segment ℝ (C.point b.castSucc) (C.point b.succ) := by + obtain ⟨l₀,u₀,hl₀,hlu₀,hu₀,hs₀⟩ := C.interior_slopes hLU hedge + obtain ⟨l,hl,hlavoid⟩ := exists_slope_avoiding (C.point 0) F hl₀ hp₀ + obtain ⟨u,hu,huavoid⟩ := exists_slope_avoiding (C.point (Fin.last R)) F hu₀ hp₁ + have hlu : l ≤ u := ((hl.2.trans_le hlu₀).trans hu.1).le + have hs (b : Fin R) (hb : C.point b.castSucc ≠ C.point b.succ) : + l ≤ slope (C.point b.castSucc) (C.point b.succ) ∧ + slope (C.point b.castSucc) (C.point b.succ) ≤ u := + ⟨(hl.2.trans (hs₀ b hb).1).le,((hs₀ b hb).2.trans hu.1).le⟩ + refine ⟨l,u,hl.1,hlu,hu.2,hs,?_⟩ + intro z hz hgraph + rcases C.extension_cases hlu hs hgraph with hleft | hright | hmiddle + · exact (hlavoid z hz hleft.2).elim + · exact (huavoid z hz hright.2).elim + · exact hmiddle + +end PlanarHalving.Batches + +namespace PlanarHalving.RankCoordinates +open Set + +noncomputable def slot {ι : Type*} [Fintype ι] (g : ι → ℝ → ℝ) (p : Point) : ℕ := + (Finset.univ.filter (fun i => g i p.1 < p.2)).card + +lemma slot_lt_of_le_imp_lt {ι : Type*} [Fintype ι] (g : ι → ℝ → ℝ) + {p q : Point} (h : ∀ i, g i p.1 ≤ p.2 → g i q.1 < q.2) + (hp : ∃ i, g i p.1 = p.2) : slot g p < slot g q := by + classical + apply Finset.card_lt_card + apply Finset.ssubset_iff_subset_ne.mpr + refine ⟨?_,?_⟩ + · intro i hi + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,h i (Finset.mem_filter.mp hi).2.le⟩ + · obtain ⟨i,hi⟩ := hp + intro he + have hiq : i ∈ Finset.univ.filter (fun i => g i q.1 < q.2) := + Finset.mem_filter.mpr ⟨Finset.mem_univ _,h i hi.le⟩ + rw [← he] at hiq + exact (lt_irrefl (p.2)) (hi ▸ (Finset.mem_filter.mp hiq).2) + +lemma slot_chord_bounds {ι : Type*} [Fintype ι] (g : ι → ℝ → ℝ) + {l u : ℝ} + (hs : ∀ i x y, x ≤ y → l*(y-x) ≤ g i y-g i x ∧ g i y-g i x ≤ u*(y-x)) + {p q : Point} (hx : p.1 ≤ q.1) (hp : ∃ i, g i p.1 = p.2) + (hq : ∃ i, g i q.1 = q.2) (he : slot g p = slot g q) : + l*(q.1-p.1) ≤ q.2-p.2 ∧ q.2-p.2 ≤ u*(q.1-p.1) := by + constructor + · by_contra hn + have ht := slot_lt_of_le_imp_lt g (p := q) (q := p) (fun i hi => by + have hh := (hs i p.1 q.1 hx).1 + linarith only [hh,hi,lt_of_not_ge hn]) hq + exact (ne_of_lt ht) he.symm + · by_contra hn + have ht := slot_lt_of_le_imp_lt g (p := p) (q := q) (fun i hi => by + have hh := (hs i p.1 q.1 hx).2 + linarith only [hh,hi,lt_of_not_ge hn]) hp + exact (ne_of_lt ht) he + +theorem pair_slots_injOn {ι κ : Type*} [Fintype ι] [Fintype κ] + (g : ι → ℝ → ℝ) (h : κ → ℝ → ℝ) {l u l' u' : ℝ} + (hg : ∀ i x y, x ≤ y → l*(y-x) ≤ g i y-g i x ∧ g i y-g i x ≤ u*(y-x)) + (hh : ∀ i x y, x ≤ y → l'*(y-x) ≤ h i y-h i x ∧ h i y-h i x ≤ u'*(y-x)) + (hgap : u < l') (S : Set Point) + (hS : ∀ p ∈ S, (∃ i, g i p.1 = p.2) ∧ ∃ j, h j p.1 = p.2) : + Set.InjOn (fun p => (slot g p,slot h p)) S := by + have horder {p q : Point} (hp : p ∈ S) (hq : q ∈ S) + (he : (slot g p,slot h p) = (slot g q,slot h q)) : ¬ p.1 < q.1 := by + intro hx + have hg' := (slot_chord_bounds g hg hx.le (hS p hp).1 (hS q hq).1 (congrArg Prod.fst he)).2 + have hh' := (slot_chord_bounds h hh hx.le (hS p hp).2 (hS q hq).2 (congrArg Prod.snd he)).1 + have hstrict := mul_lt_mul_of_pos_right hgap (sub_pos.mpr hx) + linarith only [hg',hh',hstrict] + intro p hp q hq he + have hx : p.1 = q.1 := le_antisymm (le_of_not_gt (horder hq hp he.symm)) (le_of_not_gt (horder hp hq he)) + have hy := slot_chord_bounds g hg hx.le (hS p hp).1 (hS q hq).1 (congrArg Prod.fst he) + rw [hx,sub_self,mul_zero,mul_zero] at hy + exact Prod.ext hx (by linarith only [hy.1,hy.2]) + +lemma slot_lt_card {ι : Type*} [Fintype ι] (g : ι → ℝ → ℝ) {p : Point} + (hp : ∃ i, g i p.1 = p.2) : slot g p < Fintype.card ι := by + classical + apply lt_of_lt_of_eq (Finset.card_lt_card ?_) (Finset.card_univ : _ = Fintype.card ι) + apply Finset.ssubset_iff_subset_ne.mpr + refine ⟨Finset.filter_subset ..,?_⟩ + obtain ⟨i,hi⟩ := hp + intro he + have hmem := Finset.mem_univ i + rw [← he] at hmem + exact (lt_irrefl (p.2)) (hi ▸ (Finset.mem_filter.mp hmem).2) + +end PlanarHalving.RankCoordinates + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/WindowMeasures.lean b/lean/OAI/Combinatorics/HalvingLines/WindowMeasures.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee77e1aab7712423a23500fbbcfc27e23470dbae --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/WindowMeasures.lean @@ -0,0 +1,463 @@ +import OAI.Combinatorics.HalvingLines.Sweep + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter ProbabilityTheory +open scoped Topology NNReal ENNReal unitInterval PiCountable + +noncomputable def Data.conditional (L : Data) : Kernel Labels I := + (L.edgeTime : Measure (Labels×I)).condKernel +instance (L : Data) : IsMarkovKernel L.conditional := by + unfold Data.conditional + infer_instance + +lemma Data.edge_toMeasure (L : Data) : (L.edge : Measure Labels)=(L.edgeTime : Measure (Labels×I)).fst := by + rw [Data.edge,FiniteMeasure.toMeasure_map] + rfl + +lemma Data.conditional_measurable (L : Data) (J : Window) : + Measurable (fun z => (L.conditional z).real (carrier J)) := + (L.conditional.measurable_coe (measurable_carrier J)).ennreal_toReal + +lemma Converges.conditional_integral {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) + {U : Set Labels} (hU : MeasurableSet U) : + (L.edgeWindow J U : ℝ)=∫ z in U, (L.conditional z).real (carrier J) ∂(L.edge : Measure Labels) := by + have hi := Measure.setIntegral_condKernel (ρ:=(L.edgeTime : Measure (Labels×I))) + (f:=fun _ => (1:ℝ)) hU (measurable_carrier J) (integrable_const 1) + simp only [integral_const,measureReal_restrict_apply_univ,smul_eq_mul,mul_one] at hi + rw [L.edge_toMeasure] + change (L.edgeWindow J U : ℝ)=∫ z in U, ((L.edgeTime : Measure (Labels×I)).condKernel z).real (carrier J) + ∂(L.edgeTime : Measure (Labels×I)).fst + rw [hi] + change ((L.edgeWindow J : Measure Labels) U).toReal= _ + rw [Data.edgeWindow,FiniteMeasure.toMeasure_map,Measure.map_apply measurable_fst hU, + h.restriction_eq hR,Measure.restrict_apply (hU.preimage measurable_fst)] + rfl + +lemma Converges.edgeWindow_mass {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (hR : Tendsto (fun n => (F n).R) atTop atTop) (J : Window) : + ((L.edgeWindow J).mass : ℝ)=((2^J.1 : ℕ) : ℝ)⁻¹ := by + have he := h.restriction_mass hR J + have hm : (L.edgeWindow J).mass=(L.timeRestrict J).mass := by + change (L.timeRestrict J).map Prod.fst univ=(L.timeRestrict J) univ + rw [FiniteMeasure.map_apply _ measurable_fst MeasurableSet.univ,preimage_univ] + rw [hm] + have hh := congrArg ENNReal.toReal he + simpa only [ENNReal.coe_toReal,ENNReal.toReal_inv,ENNReal.toReal_pow,ENNReal.toReal_ofNat, + Nat.cast_pow,Nat.cast_ofNat] using hh + +lemma Data.conditional_le_one (L : Data) (J : Window) (z : Labels) : + (L.conditional z).real (carrier J)≤1 := by + exact (measureReal_mono (subset_univ _)).trans_eq (by simp) + +lemma Data.conditional_sum (L : Data) (m : ℕ) (z : Labels) : + ∑ i : Fin (2^m), (L.conditional z).real (carrier ⟨m,i⟩)=1 := by + have he : (⋃ i : Fin (2^m),carrier ⟨m,i⟩)=univ := UniformPartition.cells_cover (2^m) + have hd : Pairwise (fun (i j : Fin (2^m)) => Disjoint (carrier ⟨m,i⟩) (carrier ⟨m,j⟩)) := + UniformPartition.cells_disjoint (2^m) + rw [← measureReal_iUnion_fintype hd (fun i => measurable_carrier ⟨m,i⟩),he] + simp + +end PlanarHalving.RankLimits + +namespace PlanarHalving.Sweep +open Set + +lemma activity_family_cubic {n k : ℕ} (P : Fin n → Point) (hP : Generic P) + [NeZero n] (hk : k≤n) {b : ℕ} (hb : 0 (u i,v i) + have hlt (i) (hi : i∈D) : u i hpq (congrArg f he)) + · intro p hp + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hp + exact huv i hi + · intro p hp + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hp + exact hactivity i hi + +lemma cubic_to_tail {x u : ℝ} (hx : 0≤x) (hu : 0 E.index ⟨TimeWindows.start F.R J+j.val,by have:=start_add_length F.R J;have:=stop_le F.R J;have:=j.isLt;omega⟩ + have hmono : Monotone index := by + intro i j hij + apply E.increasing.monotone + exact Nat.add_le_add_left hij _ + have he := (F.system.timeWindow J).vertices_subset_activity + (states F.point F.generic E.rank_le) index hmono (fun j => E.marks _) + have hstart : index 0=E.start J := by congr 1 + have hstop : index (Fin.last (length F.R J))=E.stop J := by + apply congrArg E.index + apply Fin.ext + exact start_add_length F.R J + simpa only [hstart,hstop] using he + +lemma before_of_same_depth {m : ℕ} {i j : Fin (2^m)} (hij : i not_lt_of_ge (hi.2.trans (E.stop_le_start (before_of_same_depth hh))) hj.1) + · exact Set.disjoint_left.mpr (fun _ hi hj => not_lt_of_ge (hj.2.trans (E.stop_le_start (before_of_same_depth hh))) hi.1) + +lemma Configuration.SweepEmbedding.activity_tail {F : Configuration} (E : F.SweepEmbedding) + (m : ℕ) {u : ℝ} (hu : 0 u<((F.vertices ⟨m,i⟩).mass : ℝ)).card : ℝ))≤ + 10000*u^(-(4:ℝ)/3) := by + classical + let D := Finset.univ.filter fun i : Fin (2^m) => u<((F.vertices ⟨m,i⟩).mass : ℝ) + let b := ⌊u*(F.n : ℝ)⌋₊+1 + have hb : 0 E.start ⟨m,i⟩) (fun i => E.stop ⟨m,i⟩) + (fun i _hi => E.start_le_stop ⟨m,i⟩) + (fun _i _hi _j _hj hij => E.windows_disjoint hij) + (fun i hi => (hcard i hi).trans (Finset.card_le_card (E.vertices_subset ⟨m,i⟩))) + have hb' : u*(F.n : ℝ)≤(b : ℝ) := by + dsimp [b] + rw [Nat.cast_add,Nat.cast_one] + exact (Nat.lt_floor_add_one _).le + have hh' : (D.card : ℝ)^3*(u*(F.n : ℝ))^4≤10000000000*(F.n : ℝ)^4 := by + exact (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (mul_nonneg hu.le hn.le) hb' 4) (by positivity)).trans hh + have hcub : (D.card : ℝ)^3*u^4≤10000000000 := by + apply (mul_le_mul_iff_left₀ (pow_pos hn 4)).mp + nlinarith [hh'] + exact cubic_to_tail (by positivity) hu hcub + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Batches TimeWindows Limits MeasureTheory Set Filter ProbabilityTheory +open scoped Topology NNReal ENNReal unitInterval PiCountable + +lemma Converges.activity_tail {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) (m : ℕ) {u : ℝ} (hu : 0 u<((L.vertices ⟨m,i⟩).mass : ℝ)).card : ℝ))≤ + 10000*u^(-(4:ℝ)/3) := by + classical + have hh : ∀ᶠ j in atTop, ∀ i : Fin (2^m), u<((L.vertices ⟨m,i⟩).mass : ℝ) → + u<(((F j).vertices ⟨m,i⟩).mass : ℝ) := by + apply eventually_all.mpr + intro i + by_cases hi : u<((L.vertices ⟨m,i⟩).mass : ℝ) + · have hm := NNReal.continuous_coe.tendsto _ |>.comp + (FiniteMeasure.continuous_mass.tendsto _ |>.comp (h.vertices ⟨m,i⟩)) + exact ((tendsto_order.mp hm).1 u hi).mono (fun j hj _ => hj) + · exact Eventually.of_forall (fun _ => fun hh => (hi hh).elim) + obtain ⟨j,hj⟩ := hh.exists + apply le_trans _ ((E j).activity_tail m hu) + have hs : (Finset.univ.filter fun i : Fin (2^m) => u<((L.vertices ⟨m,i⟩).mass : ℝ)) ⊆ + (Finset.univ.filter fun i : Fin (2^m) => u<(((F j).vertices ⟨m,i⟩).mass : ℝ)) := by + intro i hi + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hj i (Finset.mem_filter.mp hi).2⟩ + exact Nat.cast_le.mpr (Finset.card_le_card hs) + +noncomputable def timePartition (m : ℕ) : Finset Window := + Finset.univ.image (fun i : Fin (2^m) => (⟨m,i⟩ : Window)) + +lemma timePartition_card (m : ℕ) : (timePartition m).card=2^m := by + classical + rw [timePartition,Finset.card_image_of_injective _ (fun _ _ he => eq_of_heq (Sigma.mk.inj he).2),Finset.card_univ,Fintype.card_fin] + +lemma timePartition_cover (m : ℕ) (t : I) : ∃ J∈timePartition m, t∈carrier J := by + have ht : t∈⋃ i : Fin (2^m),carrier ⟨m,i⟩ := by + change t∈⋃ i : Fin (2^m), UniformPartition.cell (2^m) i + rw [UniformPartition.cells_cover];trivial + obtain ⟨i,hi⟩ := mem_iUnion.mp ht + exact ⟨⟨m,i⟩,Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩,hi⟩ + +lemma sum_timePartition {M : Type*} [AddCommMonoid M] (m : ℕ) (f : Window → M) : + ∑ J∈timePartition m, f J = ∑ i : Fin (2^m), f ⟨m,i⟩ := by + classical + exact Finset.sum_image (fun _ _ _ _ he => eq_of_heq (Sigma.mk.inj he).2) + +lemma filter_timePartition (m : ℕ) (p : Window → Prop) [DecidablePred p] : + (timePartition m |>.filter p).card = (Finset.univ.filter fun i : Fin (2^m) => p ⟨m,i⟩).card := by + classical + rw [timePartition,Finset.filter_image,Finset.card_image_of_injective _ (fun _ _ he => eq_of_heq (Sigma.mk.inj he).2)] + +lemma Converges.conditional_nullSingleton {F : ℕ → Configuration} {L : Data} (h : Converges F L) + (E : ∀ n, (F n).SweepEmbedding) + (hR : Tendsto (fun n => (F n).R) atTop atTop) + {C : ℝ} (hC : 0 ≤ C) + (hcoeff : ∀ n, 4608*((F n).a : ℝ)^2*(F n).n^4 / + (((F n).R : ℝ)*(F n).a^2)^3 ≤ C) + (herror : Tendsto (fun n => 13824*((F n).n : ℝ)^3 / + (((F n).R : ℝ)*(F n).a^2)^3) atTop (𝓝 0)) : + ∀ᵐ z ∂(L.edge : Measure Labels), NullSingletonClass (L.conditional z) := by + classical + apply kernel_nullSingleton_of_cells (L.edge : Measure Labels) L.conditional timePartition + (fun _ J => carrier J) timePartition_cover + intro b + apply ae_exists_partition_small L.edge L.points timePartition + (fun _ J z => (L.conditional z).real (carrier J)) (fun _ => L.vertices) (fun _ => L.edgeWindow) + (fun _ J => ((L.vertices J).mass : ℝ)) (fun m => (2:ℝ)^m) hC + (fun _ => by positivity) (tendsto_pow_atTop_atTop_of_one_lt (by norm_num)) + · intro m + rw [timePartition_card,Nat.cast_pow,Nat.cast_ofNat] + · exact fun _ J _ => L.conditional_measurable J + · exact fun _ _ _ _ => measureReal_nonneg + · exact fun _ J _ => L.conditional_le_one J + · intro m z + rw [sum_timePartition,L.conditional_sum] + · exact fun _ _ _ => NNReal.coe_nonneg _ + · intro _ J _ U + have hh := (h.vertices_le_points J) U + rw [← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure,← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure] at hh + exact ENNReal.coe_le_coe.mp hh + · exact fun _ J _ U hU => h.conditional_integral hR J hU + · intro m J hJ + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hJ + rw [h.edgeWindow_mass hR,Nat.cast_pow,Nat.cast_ofNat] + · exact fun _ J _ U hU => h.local_cubic hC hcoeff herror J hU + · intro m u hu + rw [filter_timePartition] + exact h.activity_tail E m hu + · positivity + +end PlanarHalving.RankLimits +namespace PlanarHalving.PlaneGraph +open Set +variable {V : Type*} [Fintype V] {P : V → Point} + +noncomputable def Drawing.pointOfPair (D : Drawing P) (w : (V×V)×(V×V)) : Point := by + classical + exact if h : w∈D.crossings then D.crossingPoint ⟨w,h⟩ else 0 + +lemma Drawing.pointOfPair_eq (D : Drawing P) (w : ↥D.crossings) : + D.pointOfPair w.val=D.crossingPoint w := by + classical + simp only [Drawing.pointOfPair,dite_eq_left w.property] + +end PlanarHalving.PlaneGraph +namespace PlanarHalving.Batches +open Set PlaneGraph TimeWindows MeasureTheory Limits +open scoped NNReal ENNReal unitInterval +variable {n R k a : ℕ} {P : Fin n → Point} + +lemma System.restricted_crossing (S : @System n R k a P) (hP : Generic P) + (E : Finset (Fin n×Fin n)) (hE : E⊆S.edges) : + (E.card : ℝ)^3 ≤ 2304*(n : ℝ)^2*((S.drawing.restrictEdges E).crossings.card : ℝ)+13824*(n : ℝ)^3 := by + classical + let D := S.drawing.restrictEdges E + have he : D.edges=E := by + ext e + simp only [D, Drawing.restrictEdges, Finset.mem_inter] + exact ⟨And.right, fun h => ⟨hE h, h⟩⟩ + have hc := D.designated_crossing hP.1 (Generic.x_injective hP) D.vertices (by rfl) + (fun e he => Or.inl (D.ends e he).1) + have hv : (D.vertices.card : ℝ) ≤ n := Nat.cast_le.mpr S.vertices_le + rw [he] at hc + apply hc.trans + nlinarith [mul_le_mul_of_nonneg_right (sq_le_sq₀ (by positivity) (by positivity) |>.mpr hv) + (by positivity : (0:ℝ) ≤ 2304*((D.crossings.card : ℝ))), + pow_le_pow_left₀ (by positivity) hv 3] + +noncomputable def System.crossingsIn (S : @System n R k a P) [NeZero R] + (A B : Window) {X : Type*} (z : Point → X) (U : Set X) := by + classical + exact (S.windowCrossings A B).filter (fun w => z (S.drawing.pointOfPair w)∈U) + +lemma System.windowCrossMeasure_apply (S : @System n R k a P) [NeZero R] + (A B : Window) {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] + (z : Point → X) {U : Set X} (hU : MeasurableSet U) : + (S.windowCrossMeasure A B z U : ℝ)=(S.crossingsIn A B z U).card/((a*n : ℕ) : ℝ)^2 := by + classical + rw [System.windowCrossMeasure,weightedAtoms_apply_finset _ _ hU] + have he : (Finset.univ.filter (fun w : ↥(S.windowCrossings A B) => z (S.windowCrossPoint A B w)∈U)).card= + (S.crossingsIn A B z U).card := by + rw [← Finset.card_image_of_injective _ Subtype.val_injective] + congr 1 + ext w + simp only [Finset.mem_image,Finset.mem_filter,Finset.mem_univ,true_and,System.crossingsIn] + constructor + · rintro ⟨v,hv,rfl⟩ + refine ⟨v.property,?_⟩ + simpa only [System.windowCrossPoint,Drawing.pointOfPair, + dite_eq_left (S.windowCrossings_sub A B v.property)] using hv + · rintro ⟨hw,hz⟩ + refine ⟨⟨w,hw⟩,?_,rfl⟩ + simpa only [System.windowCrossPoint,Drawing.pointOfPair, + dite_eq_left (S.windowCrossings_sub A B hw)] using hz + rw [he] + simp only [NNReal.coe_inv,NNReal.coe_pow,NNReal.coe_natCast,div_eq_inv_mul] + +lemma System.retained_crossing_cover (S : @System n R k a P) [NeZero R] + {X : Type*} (z : Point → X) (U : Set X) (W : Finset Window) + (E : Finset (Fin n×Fin n)) (_hE : E⊆S.edges) + (hcover : ∀ e∈E, ∃ J∈W, e∈(S.timeWindow J).edges) + (hnear : ∀ e∈E, ∀ p∈segment ℝ (P e.1) (P e.2), z p∈U) : + (S.drawing.restrictEdges E).crossings ⊆ (W×ˢ W).biUnion + (fun ij => if ij.1=ij.2 then (S.timeWindow ij.1).drawing.crossings + else S.crossingsIn ij.1 ij.2 z U) := by + classical + intro w hw + have hp := (S.drawing.restrictEdges E).crossing_props ⟨w,hw⟩ + have hep := hp + simp only [Drawing.restrictEdges, Finset.mem_inter] at hep + have he₁ := hep.1.2 + have he₂ := hep.2.1.2 + obtain ⟨J,hJ,heJ⟩ := hcover w.1 he₁ + obtain ⟨K,hK,heK⟩ := hcover w.2 he₂ + apply Finset.mem_biUnion.mpr + refine ⟨(J,K),Finset.mem_product.mpr ⟨hJ,hK⟩,?_⟩ + dsimp only + by_cases hJK : J=K + · rw [ite_eq_left hJK] + rw [← hJK] at heK + exact Finset.mem_filter.mpr ⟨Finset.mem_product.mpr ⟨heJ,heK⟩,hp.2.2⟩ + · rw [ite_eq_right hJK] + have hc : w∈S.drawing.crossings := S.drawing.restrict_crossings E hw + have hz : z (S.drawing.pointOfPair w)∈U := by + rw [show S.drawing.pointOfPair w=S.drawing.crossingPoint ⟨w,hc⟩ from S.drawing.pointOfPair_eq ⟨w,hc⟩] + exact hnear _ he₁ _ ((openSegment_subset_segment ℝ _ _) (S.drawing.crossingPoint_mem ⟨w,hc⟩).1) + exact Finset.mem_filter.mpr ⟨Finset.mem_filter.mpr ⟨hc,Or.inl ⟨heJ,heK⟩⟩,hz⟩ + +lemma System.retained_crossing_bound (S : @System n R k a P) [NeZero R] [NeZero n] [NeZero a] + (hP : Generic P) {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] + (z : Point → X) {U : Set X} (hU : MeasurableSet U) (W : Finset Window) + (E : Finset (Fin n×Fin n)) (hE : E⊆S.edges) + (hcover : ∀ e∈E, ∃ J∈W, e∈(S.timeWindow J).edges) + (hnear : ∀ e∈E, ∀ p∈segment ℝ (P e.1) (P e.2), z p∈U) : + (((S.drawing.restrictEdges E).crossings.card : ℝ)/((a*n : ℕ) : ℝ)^2) ≤ + ∑ J∈W, ∑ K∈W, if J=K then 2*((S.timeWindow J).vertices.card : ℝ)^2/(n : ℝ)^2 + else (S.windowCrossMeasure J K z U : ℝ) := by + classical + have hc := (Finset.card_le_card (S.retained_crossing_cover z U W E hE hcover hnear)).trans + (Finset.card_biUnion_le) + have hh : ((S.drawing.restrictEdges E).crossings.card : ℝ) ≤ + ∑ ij∈W×ˢ W, if ij.1=ij.2 then 2*(a : ℝ)^2*((S.timeWindow ij.1).vertices.card : ℝ)^2 + else ((S.crossingsIn ij.1 ij.2 z U).card : ℝ) := by + apply (Nat.cast_le.mpr hc).trans + push_cast + apply Finset.sum_le_sum + intro ij _hij + split_ifs with he + · exact_mod_cast (S.timeWindow ij.1).crossing_cap hP.1 (Generic.x_injective hP) + ((S.timeWindow ij.1).drawing.noMultiple_of_generic hP) + · rfl + apply (div_le_div_of_nonneg_right hh (sq_nonneg _)).trans_eq + rw [Finset.sum_div,Finset.sum_product] + apply Finset.sum_congr rfl + intro J _hJ + apply Finset.sum_congr rfl + intro K _hK + split_ifs + · have ha : (a : ℝ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne a) + push_cast + field_simp + · exact (S.windowCrossMeasure_apply J K z hU).symm + +end PlanarHalving.Batches + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Windows.lean b/lean/OAI/Combinatorics/HalvingLines/Windows.lean new file mode 100644 index 0000000000000000000000000000000000000000..754f8caf43252180e7eb05d8f280fdc46936bfb8 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Windows.lean @@ -0,0 +1,472 @@ +import OAI.Combinatorics.HalvingLines.Partition + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.TimeWindows +open Set +open scoped unitInterval Classical + +abbrev Window := Σ d : ℕ, Fin (2^d) + +noncomputable def carrier (J : Window) : Set I := UniformPartition.cell (2^J.1) J.2 + +lemma measurable_carrier (J : Window) : MeasurableSet (carrier J) := + UniformPartition.cell_measurable _ _ + +noncomputable def time (R : ℕ) [NeZero R] (b : Fin R) : I := + ⟨((b : ℝ)+1/2)/(R : ℝ),by + have hR : (0 : ℝ) t b t c t c time R b ∈ carrier J).card := by + have he : (Finset.univ.filter fun b : Fin R => time R b ∈ carrier J) = + (Finset.univ.filter fun b : Fin R => b.val < stop R J) \ + (Finset.univ.filter fun b : Fin R => b.val < start R J) := by + ext b + simp only [Finset.mem_filter,Finset.mem_univ,true_and,Finset.mem_sdiff,not_lt, + mem_carrier_iff,and_comm] + rw [he,Finset.card_sdiff_of_subset] + · have hcard (c : ℕ) (hc : c ≤ R) : (Finset.univ.filter fun b : Fin R => b.val x i ∈ U).card : ℝ) := by + classical + have h := integral_weightedAtoms w x (U.indicator (fun _ => (1 : ℝ))) + rw [integral_indicator_const 1 hU] at h + simpa only [smul_eq_mul,mul_one,measureReal_def,← FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure, + ENNReal.coe_toReal,Set.indicator_apply,Finset.sum_boole] using h + +end PlanarHalving.Limits + +namespace PlanarHalving.Batches +open MeasureTheory Set Limits +open scoped NNReal ENNReal Classical +variable {n R k a : ℕ} {P : Fin n → Point} + +noncomputable def System.vertexMeasure (S : @System n R k a P) + {X : Type*} [MeasurableSpace X] (z : Fin n → X) : FiniteMeasure X := + weightedAtoms (n : ℝ≥0)⁻¹ (fun v : ↥S.vertices => z v.val) + +noncomputable def System.endpointMeasure (S : @System n R k a P) + {X : Type*} [MeasurableSpace X] (z : Fin n → X) (E : ℝ≥0) : FiniteMeasure X := + weightedAtoms E⁻¹ (fun e : ↥S.edges => z e.val.1) + +lemma System.vertexMeasure_apply (S : @System n R k a P) + {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] (z : Fin n → X) + {U : Set X} (hU : MeasurableSet U) : + (S.vertexMeasure z U : ℝ) = ((S.vertices.filter fun v => z v ∈ U).card : ℝ)/(n : ℝ) := by + classical + rw [System.vertexMeasure,weightedAtoms_apply_finset _ _ hU] + have he : (Finset.univ.filter fun v : ↥S.vertices => z v.val ∈ U).card = + (S.vertices.filter fun v => z v ∈ U).card := by + apply Finset.card_bij (fun v _ => v.val) + · intro v hv + exact Finset.mem_filter.mpr ⟨v.property,(Finset.mem_filter.mp hv).2⟩ + · intro v _ w _ h; exact Subtype.ext h + · intro v hv + exact ⟨⟨v,(Finset.mem_filter.mp hv).1⟩,by simpa using (Finset.mem_filter.mp hv).2,rfl⟩ + rw [he] + simp only [NNReal.coe_inv,NNReal.coe_natCast,div_eq_inv_mul] + +lemma System.endpointMeasure_apply (S : @System n R k a P) + {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] (z : Fin n → X) + (E : ℝ≥0) {U : Set X} (hU : MeasurableSet U) : + (S.endpointMeasure z E U : ℝ) = ((S.edges.filter fun e => z e.1 ∈ U).card : ℝ)/(E : ℝ) := by + classical + rw [System.endpointMeasure,weightedAtoms_apply_finset _ _ hU] + have he : (Finset.univ.filter fun e : ↥S.edges => z e.val.1 ∈ U).card = + (S.edges.filter fun e => z e.1 ∈ U).card := by + apply Finset.card_bij (fun e _ => e.val) + · intro e he + exact Finset.mem_filter.mpr ⟨e.property,(Finset.mem_filter.mp he).2⟩ + · intro e _ f _ h; exact Subtype.ext h + · intro e he + exact ⟨⟨e,(Finset.mem_filter.mp he).1⟩,by simpa using (Finset.mem_filter.mp he).2,rfl⟩ + rw [he] + simp only [NNReal.coe_inv,div_eq_inv_mul] + +theorem System.atomic_cubed_bound (S : @System n R k a P) [NeZero n] [NeZero a] + (hP : Generic P) {X : Type*} [MeasurableSpace X] [MeasurableSingletonClass X] + (z : Fin n → X) {E : ℝ≥0} (hE : 0 < E) {U : Set X} (hU : MeasurableSet U) : + (S.endpointMeasure z E U : ℝ)^3 ≤ + (4608 * (a : ℝ)^2 * n^4 / (E : ℝ)^3) * + ((S.vertices.card : ℝ)/(n : ℝ))^3 * (S.vertexMeasure z U : ℝ) + + 13824 * (S.vertices.card : ℝ)^3 / (E : ℝ)^3 := by + classical + let F := S.vertices.filter fun v => z v ∈ U + have hF : F ⊆ S.vertices := Finset.filter_subset _ _ + have hc := S.localized_crossing hP F hF + have he : S.edges.filter (fun e => e.1 ∈ F) = S.edges.filter (fun e => z e.1 ∈ U) := by + ext e + simp only [Finset.mem_filter,F] + exact ⟨fun h => ⟨h.1,h.2.2⟩,fun h => ⟨h.1,(S.edge_ends h.1).1,h.2⟩⟩ + rw [he] at hc + rw [S.endpointMeasure_apply z E hU,S.vertexMeasure_apply z hU] + have hn : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne n) + have hER : 0 < (E : ℝ) := hE + have hc' := div_le_div_of_nonneg_right hc (le_of_lt (pow_pos hER 3)) + convert hc' using 1 + all_goals + try dsimp only [F] + try field_simp [hn,ne_of_gt hER] + try ring + try rfl + +end PlanarHalving.Batches + +namespace PlanarHalving.TimeWindows +open Set Filter +open scoped unitInterval Topology + +lemma cut_time_error (R : ℕ) [NeZero R] (x : I) : + |(cut (time R) x : ℝ)-(R : ℝ)*(x : ℝ)| ≤ 1 := by + have hR : (0 : ℝ) (length (R n) J : ℝ)/(R n : ℝ)) atTop (𝓝 (1/(2^J.1 : ℕ) : ℝ)) := by + apply tendsto_iff_dist_tendsto_zero.mpr + apply squeeze_zero (fun _ => dist_nonneg) (fun n => by simpa only [Real.dist_eq] using length_error (R n) J) + have hn : Tendsto (fun n => (R n : ℝ)) atTop atTop := tendsto_natCast_atTop_atTop.comp hR + simpa only [div_eq_mul_inv,Function.comp_def,mul_zero] using (tendsto_inv_atTop_zero.comp hn).const_mul 2 + +lemma eventually_length_pos (R : ℕ → ℕ) [∀ n, NeZero (R n)] (hR : Tendsto R atTop atTop) (J : Window) : + ∀ᶠ n in atTop, 0 hS.ordConnected.out ha hb ⟨hx.1.le,hx.2.le⟩ + exact (isOpen_Ioo.subset_interior_iff.mpr hs) ⟨hqa,hqb⟩ + +lemma ae_subsingleton (μ : Measure ℝ) [NullSingletonClass μ] + (K : Set ℝ) (hK : Bornology.IsBounded K) (D : ℝ → Set ℝ) + (hc : ∀ t ∈ K, Convex ℝ (D t)) + (hd : ∀ s ∈ K, ∀ t ∈ K, s ht.1)) + intro s hs t ht hst + apply le_antisymm _ zero_le + by_contra h + have hp : 0<μ (Ioo s t) := lt_of_not_ge h + exact Set.disjoint_left.mp (hd s hs.1 t ht.1 hst hp) + (interior_subset hs.2) (interior_subset ht.2) + apply measure_mono_null (t := ⋃ q : ℚ, S q) + · intro t ht + obtain ⟨q,hq⟩ := interval_has_rat_interior (hc t ht.1) ht.2 + exact mem_iUnion.mpr ⟨q,ht.1,hq⟩ + · exact measure_iUnion_null hz + +theorem exists_three_singletons (μ : Measure ℝ) [NullSingletonClass μ] + (K : Set ℝ) (hK : Bornology.IsBounded K) (hpos : 0<μ K) (D : ℝ → Set ℝ) + (hne : ∀ t ∈ K, (D t).Nonempty) (hc : ∀ t ∈ K, Convex ℝ (D t)) + (hd : ∀ s ∈ K, ∀ t ∈ K, s (S.trace e.property).batch=b).card=a^2 := by + classical + have he : (Finset.univ.filter fun e : ↥S.edges => (S.trace e.property).batch=b).card = + ((S.loss b).product (S.gain b)).card := by + apply Finset.card_bij (fun e _ => e.val) + · intro e he + have hh := (Finset.mem_filter.mp he).2 + exact Finset.mem_product.mpr (hh ▸ ⟨(S.trace e.property).loss,(S.trace e.property).gain⟩) + · intro e _ f _ h; exact Subtype.ext h + · intro e he + have hm : e∈S.edges := (S.mem_edges e).mpr ⟨b,Finset.mem_product.mp he⟩ + refine ⟨⟨e,hm⟩,Finset.mem_filter.mpr ⟨Finset.mem_univ _,?_⟩,rfl⟩ + exact S.batch_unique ⟨(S.trace hm).loss,(S.trace hm).gain⟩ (Finset.mem_product.mp he) + rw [he] + calc + _ = (S.loss b).card * (S.gain b).card := Finset.card_product _ _ + _ = a^2 := by rw [S.card_loss,S.card_gain,pow_two] + +end PlanarHalving.Batches + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/Zoom.lean b/lean/OAI/Combinatorics/HalvingLines/Zoom.lean new file mode 100644 index 0000000000000000000000000000000000000000..72320fcb8bafcfba750532da7bb46db19d549f86 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/Zoom.lean @@ -0,0 +1,407 @@ +import OAI.Combinatorics.HalvingLines.Rigidity + +namespace OAI + +namespace PlanarHalving + +namespace Zoom + +open scoped NNReal Topology +open Filter + +lemma LineControl.between_chord {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + {f : ℕ → E → E} {v : E} (C : LineControl f v) + (n : ℕ) (x : E) (a t b : ℝ) (hat : a ≤ t) (htb : t ≤ b) : + ‖f n (x + t • v) - f n (x + a • v)‖ ≤ + (C.constant * ‖C.level‖) * ‖f n (x + b • v) - f n (x + a • v)‖ := by + have h₁ := (C.strict n x).monotone hat + have h₂ := (C.strict n x).monotone htb + simp only [map_sub] at h₁ h₂ + have hz : 0 ≤ C.level (f n (x + t • v) - f n (x + a • v)) := by + rw [map_sub] + linarith only [h₁] + have hle : C.level (f n (x + t • v) - f n (x + a • v)) ≤ + C.level (f n (x + b • v) - f n (x + a • v)) := by + rw [map_sub, map_sub] + linarith only [h₂] + calc + _ ≤ C.constant * |C.level (f n (x + t • v) - f n (x + a • v))| := C.chord n x t a + _ ≤ C.constant * (C.level (f n (x + b • v) - f n (x + a • v))) := by + rw [abs_of_nonneg hz] + exact mul_le_mul_of_nonneg_left hle C.constant.coe_nonneg + _ ≤ C.constant * (‖C.level‖ * ‖f n (x + b • v) - f n (x + a • v)‖) := by + apply mul_le_mul_of_nonneg_left _ C.constant.coe_nonneg + exact (le_abs_self _).trans (C.level.le_opNorm _) + _ = _ := by ring + +lemma FoliatedSequence.axis_bounded (F : FoliatedSequence) (σ t : ℝ) + (hzero : F.Good σ 0) (hone : F.Good σ (1, 0)) + (ht₀ : 0 ≤ t) (ht₁ : t ≤ 1) : + ∃ B : ℝ, ∀ n, ‖F.map n (t, 0)‖ ≤ B := by + obtain ⟨A, _, hA⟩ := (Metric.isBounded_range_of_tendsto _ hzero).exists_pos_norm_le + obtain ⟨B, _, hB⟩ := (Metric.isBounded_range_of_tendsto _ hone).exists_pos_norm_le + let C := F.control .horizontal + refine ⟨(C.constant * ‖C.level‖) * (B + A) + A, fun n => ?_⟩ + have hh := C.between_chord n 0 0 t 1 ht₀ ht₁ + simp only [Foliation.direction, zero_smul, zero_add, one_smul, + Prod.smul_mk, smul_eq_mul, mul_one, mul_zero] at hh + have hA' := hA _ (Set.mem_range_self n) + have hB' := hB _ (Set.mem_range_self n) + calc + ‖F.map n (t, 0)‖ ≤ ‖F.map n (t, 0) - F.map n 0‖ + ‖F.map n 0‖ := norm_le_norm_sub_add _ _ + _ ≤ (C.constant * ‖C.level‖) * ‖F.map n (1, 0) - F.map n 0‖ + A := add_le_add hh hA' + _ ≤ (C.constant * ‖C.level‖) * (B + A) + A := by + apply add_le_add_left + apply mul_le_mul_of_nonneg_left _ (mul_nonneg C.constant.coe_nonneg (norm_nonneg _)) + exact (norm_sub_le _ _).trans (add_le_add hB' hA') + +lemma FoliatedSequence.good_reciprocal (F : FoliatedSequence) (σ : ℝ) + (hzero : F.Good σ 0) (hone : F.Good σ (1, 0)) + (m : ℕ) (hm : 0 < m) : F.Good σ ((m : ℝ)⁻¹, 0) := by + have hm₀ : (0 : ℝ) < m := Nat.cast_pos.mpr hm + have hm₁ : (1 : ℝ) ≤ m := by exact_mod_cast hm + obtain ⟨B, hB⟩ := F.axis_bounded σ ((m : ℝ)⁻¹) hzero hone + (inv_nonneg.mpr hm₀.le) (inv_le_one_of_one_le₀ hm₁) + apply (isCompact_closedBall (0 : Point) B).tendsto_nhds_of_unique_mapClusterPt + (Filter.Eventually.of_forall (fun n => by + simpa only [Metric.mem_closedBall, dist_zero_right] using hB n)) + intro b _ hcluster + obtain ⟨ρ, hρ, hb⟩ := hcluster.tendsto_subseq + have hz : Tendsto (fun n => F.map (ρ n) 0) atTop (𝓝 (0 : Point)) := by + simpa only [Good, Function.comp_def, smul_zero] using hzero.comp hρ.tendsto_atTop + obtain ⟨r, hr⟩ := F.direction .horizontal ρ hρ (fun _ => 0) + (fun _ => ((m : ℝ)⁻¹, 0)) + (fun _ => ⟨(m : ℝ)⁻¹, by simp [Foliation.direction]⟩) 0 b hz hb + have hb' : b = (r, 0) := by simpa [Foliation.direction] using hr + let G := F.subseq ρ hρ + have hgzero : G.Good (r * m) 0 := by simpa only [Good, G, subseq, smul_zero] using hz + have hgseed : G.Good (r * m) ((m : ℝ)⁻¹, 0) := by + have he : (r * m) • (((m : ℝ)⁻¹, 0) : Point) = b := by + rw [hb'] + ext <;> simp [ne_of_gt hm₀] + simpa only [Good, he, G, subseq, Function.comp_def] using hb + have hg := G.good_nat_axis (r * m) ((m : ℝ)⁻¹) hgzero hgseed m + have hg' : G.Good (r * m) (1, 0) := by simpa only [mul_inv_cancel₀ (ne_of_gt hm₀)] using hg + have he : (r * m) • ((1, 0) : Point) = σ • ((1, 0) : Point) := + tendsto_nhds_unique hg' (hone.subseq ρ hρ) + have he' : r * m = σ := by simpa using congrArg Prod.fst he + rw [hb', ← he'] + ext <;> simp [ne_of_gt hm₀] + +lemma FoliatedSequence.good_rational_grid (F : FoliatedSequence) (σ : ℝ) + (hzero : F.Good σ 0) (hone : F.Good σ (1, 0)) + (m : ℕ) (hm : 0 < m) (a b : ℤ) : + F.Good σ ((a : ℝ) / m, (b : ℝ) / m) := by + simpa only [div_eq_mul_inv] using + F.good_lattice σ ((m : ℝ)⁻¹) hzero (F.good_reciprocal σ hzero hone m hm) a b + +noncomputable def FoliatedSequence.axisConstant (F : FoliatedSequence) (i : Foliation) : ℝ := + (F.control i).constant * ‖(F.control i).level‖ + +lemma FoliatedSequence.axisConstant_nonneg (F : FoliatedSequence) (i : Foliation) : + 0 ≤ F.axisConstant i := mul_nonneg (F.control i).constant.coe_nonneg (norm_nonneg _) + +noncomputable def FoliatedSequence.rectConstant (F : FoliatedSequence) : ℝ := + F.axisConstant .horizontal * (2 * F.axisConstant .vertical + 1) + F.axisConstant .vertical + +lemma FoliatedSequence.rectConstant_nonneg (F : FoliatedSequence) : 0 ≤ F.rectConstant := by + unfold rectConstant + have hh := F.axisConstant_nonneg .horizontal + have hv := F.axisConstant_nonneg .vertical + positivity + +lemma FoliatedSequence.horizontal_between (F : FoliatedSequence) (n : ℕ) + (a t b y : ℝ) (hat : a ≤ t) (htb : t ≤ b) : + ‖F.map n (t, y) - F.map n (a, y)‖ ≤ + F.axisConstant .horizontal * ‖F.map n (b, y) - F.map n (a, y)‖ := by + simpa [Foliation.direction, axisConstant] using + (F.control .horizontal).between_chord n (0, y) a t b hat htb + +lemma FoliatedSequence.vertical_between (F : FoliatedSequence) (n : ℕ) + (a t b x : ℝ) (hat : a ≤ t) (htb : t ≤ b) : + ‖F.map n (x, t) - F.map n (x, a)‖ ≤ + F.axisConstant .vertical * ‖F.map n (x, b) - F.map n (x, a)‖ := by + simpa [Foliation.direction, axisConstant] using + (F.control .vertical).between_chord n (x, 0) a t b hat htb + +lemma FoliatedSequence.rectangle_chord (F : FoliatedSequence) (n : ℕ) + (a b c d q : ℝ) (x : Point) (hx : x.1 ∈ Set.Icc a b) (hy : x.2 ∈ Set.Icc c d) + (hbottom : ‖F.map n (b, c) - F.map n (a, c)‖ ≤ q) + (hleft : ‖F.map n (a, d) - F.map n (a, c)‖ ≤ q) + (hright : ‖F.map n (b, d) - F.map n (b, c)‖ ≤ q) : + ‖F.map n x - F.map n (a, c)‖ ≤ F.rectConstant * q := by + let H := F.axisConstant .horizontal + let V := F.axisConstant .vertical + have hH : 0 ≤ H := F.axisConstant_nonneg _ + have hV : 0 ≤ V := F.axisConstant_nonneg _ + have hl : ‖F.map n (a, x.2) - F.map n (a, c)‖ ≤ V * q := + (F.vertical_between n c x.2 d a hy.1 hy.2).trans (mul_le_mul_of_nonneg_left hleft hV) + have hr : ‖F.map n (b, x.2) - F.map n (b, c)‖ ≤ V * q := + (F.vertical_between n c x.2 d b hy.1 hy.2).trans (mul_le_mul_of_nonneg_left hright hV) + have hb : ‖F.map n (b, x.2) - F.map n (a, x.2)‖ ≤ V * q + q + V * q := by + calc + _ ≤ ‖F.map n (b, x.2) - F.map n (b, c)‖ + + ‖F.map n (b, c) - F.map n (a, c)‖ + + ‖F.map n (a, c) - F.map n (a, x.2)‖ := by + have h₁ := dist_triangle (F.map n (b, x.2)) (F.map n (b, c)) (F.map n (a, c)) + have h₂ := dist_triangle (F.map n (b, x.2)) (F.map n (a, c)) (F.map n (a, x.2)) + simp only [dist_eq_norm] at h₁ h₂ + linarith only [h₁, h₂] + _ ≤ _ := add_le_add (add_le_add hr hbottom) (by rwa [norm_sub_rev]) + have ht : ‖F.map n x - F.map n (a, x.2)‖ ≤ H * (V * q + q + V * q) := + (F.horizontal_between n a x.1 b x.2 hx.1 hx.2).trans (mul_le_mul_of_nonneg_left hb hH) + calc + _ ≤ ‖F.map n x - F.map n (a, x.2)‖ + ‖F.map n (a, x.2) - F.map n (a, c)‖ := by + simpa only [dist_eq_norm] using + dist_triangle (F.map n x) (F.map n (a, x.2)) (F.map n (a, c)) + _ ≤ H * (V * q + q + V * q) + V * q := add_le_add ht hl + _ = _ := by dsimp [H, V, rectConstant]; ring + +lemma norm_rectangle_corner (a b c d δ : ℝ) (x : Point) + (hx : x.1 ∈ Set.Icc a b) (hy : x.2 ∈ Set.Icc c d) + (hab : b - a ≤ δ) (hcd : d - c ≤ δ) : ‖x - (a, c)‖ ≤ δ := by + rw [Prod.norm_def, max_le_iff] + constructor + · change |x.1 - a| ≤ δ + rw [abs_of_nonneg (sub_nonneg.mpr hx.1)] + linarith only [hx.2, hab] + · change |x.2 - c| ≤ δ + rw [abs_of_nonneg (sub_nonneg.mpr hy.1)] + linarith only [hy.2, hcd] + +lemma norm_image_edge (f : Point → Point) (σ δ : ℝ) (x y : Point) + (hx : ‖f x - σ • x‖ ≤ δ) (hy : ‖f y - σ • y‖ ≤ δ) + (hxy : ‖x - y‖ ≤ δ) : ‖f x - f y‖ ≤ (2 + |σ|) * δ := by + have h := dist_triangle (f x) (σ • x) (σ • y) + have h' := dist_triangle (f x) (σ • y) (f y) + simp only [dist_eq_norm, ← smul_sub, norm_smul, Real.norm_eq_abs] at h h' + rw [norm_sub_rev (σ • y)] at h' + have hh := mul_le_mul_of_nonneg_left hxy (abs_nonneg σ) + nlinarith only [h, h', hx, hy, hh] + +lemma FoliatedSequence.rectangle_error (F : FoliatedSequence) (n : ℕ) + (σ a b c d δ : ℝ) (x : Point) (hx : x.1 ∈ Set.Icc a b) (hy : x.2 ∈ Set.Icc c d) + (hab : b - a ≤ δ) (hcd : d - c ≤ δ) + (h₀₀ : ‖F.map n (a, c) - σ • (a, c)‖ ≤ δ) + (h₁₀ : ‖F.map n (b, c) - σ • (b, c)‖ ≤ δ) + (h₀₁ : ‖F.map n (a, d) - σ • (a, d)‖ ≤ δ) + (h₁₁ : ‖F.map n (b, d) - σ • (b, d)‖ ≤ δ) : + ‖F.map n x - σ • x‖ ≤ (F.rectConstant * (2 + |σ|) + 1 + |σ|) * δ := by + have ha : a ≤ b := hx.1.trans hx.2 + have hc : c ≤ d := hy.1.trans hy.2 + have hh := F.rectangle_chord n a b c d ((2 + |σ|) * δ) x hx hy + (norm_image_edge _ σ δ _ _ h₁₀ h₀₀ + (norm_rectangle_corner a b c d δ (b, c) ⟨ha, le_rfl⟩ ⟨le_rfl, hc⟩ hab hcd)) + (norm_image_edge _ σ δ _ _ h₀₁ h₀₀ + (norm_rectangle_corner a b c d δ (a, d) ⟨le_rfl, ha⟩ ⟨hc, le_rfl⟩ hab hcd)) + (norm_image_edge _ σ δ _ _ h₁₁ h₁₀ + (norm_rectangle_corner b b c d δ (b, d) ⟨le_rfl, le_rfl⟩ ⟨hc, le_rfl⟩ + (by linarith only [ha, hab]) hcd)) + have hnorm := norm_rectangle_corner a b c d δ x hx hy hab hcd + have h₁ := dist_triangle (F.map n x) (F.map n (a, c)) (σ • (a, c)) + have h₂ := dist_triangle (F.map n x) (σ • (a, c)) (σ • x) + simp only [dist_eq_norm, ← smul_sub, norm_smul, Real.norm_eq_abs] at h₁ h₂ + rw [norm_sub_rev (a, c)] at h₂ + have hh' := mul_le_mul_of_nonneg_left hnorm (abs_nonneg σ) + nlinarith only [hh, h₀₀, h₁, h₂, hh'] + +lemma FoliatedSequence.small_good_rectangle (F : FoliatedSequence) (σ : ℝ) + (hzero : F.Good σ 0) (hone : F.Good σ (1, 0)) (x : Point) (δ : ℝ) (hδ : 0 < δ) : + ∃ a b c d : ℝ, a < x.1 ∧ x.1 < b ∧ c < x.2 ∧ x.2 < d ∧ + b - a ≤ δ ∧ d - c ≤ δ ∧ F.Good σ (a, c) ∧ F.Good σ (b, c) ∧ + F.Good σ (a, d) ∧ F.Good σ (b, d) := by + obtain ⟨m, hm⟩ := exists_nat_gt (2 / δ) + have hmR : (0 : ℝ) < m := (div_pos (by norm_num) hδ).trans hm + have hmN : 0 < m := Nat.cast_pos.mp hmR + let i : ℤ := ⌊(m : ℝ) * x.1⌋ + let j : ℤ := ⌊(m : ℝ) * x.2⌋ + have hi₀ : (i : ℝ) ≤ m * x.1 := Int.floor_le _ + have hi₁ : m * x.1 < (i : ℝ) + 1 := Int.lt_floor_add_one _ + have hj₀ : (j : ℝ) ≤ m * x.2 := Int.floor_le _ + have hj₁ : m * x.2 < (j : ℝ) + 1 := Int.lt_floor_add_one _ + have hmesh : 2 / (m : ℝ) < δ := by + exact (div_lt_iff₀ hmR).mpr (by nlinarith only [(div_lt_iff₀ hδ).mp hm]) + refine ⟨((i - 1 : ℤ) : ℝ) / m, ((i + 1 : ℤ) : ℝ) / m, + ((j - 1 : ℤ) : ℝ) / m, ((j + 1 : ℤ) : ℝ) / m, ?_, ?_, ?_, ?_, ?_, ?_, + F.good_rational_grid σ hzero hone m hmN (i - 1) (j - 1), + F.good_rational_grid σ hzero hone m hmN (i + 1) (j - 1), + F.good_rational_grid σ hzero hone m hmN (i - 1) (j + 1), + F.good_rational_grid σ hzero hone m hmN (i + 1) (j + 1)⟩ + · rw [div_lt_iff₀ hmR] + push_cast + linarith only [hi₀] + · rw [lt_div_iff₀ hmR] + push_cast + linarith only [hi₁] + · rw [div_lt_iff₀ hmR] + push_cast + linarith only [hj₀] + · rw [lt_div_iff₀ hmR] + push_cast + linarith only [hj₁] + · have he : (((i + 1 : ℤ) : ℝ) / m - ((i - 1 : ℤ) : ℝ) / m) = 2 / (m : ℝ) := by + push_cast + ring + rw [he] + exact hmesh.le + · have he : (((j + 1 : ℤ) : ℝ) / m - ((j - 1 : ℤ) : ℝ) / m) = 2 / (m : ℝ) := by + push_cast + ring + rw [he] + exact hmesh.le + +lemma FoliatedSequence.good_eventual_error (F : FoliatedSequence) (σ : ℝ) + (x : Point) (hx : F.Good σ x) (δ : ℝ) (hδ : 0 < δ) : + ∀ᶠ n in atTop, ‖F.map n x - σ • x‖ ≤ δ := by + exact (Metric.tendsto_nhds.mp hx δ hδ).mono fun n hn => by + simpa only [dist_eq_norm] using hn.le + +lemma FoliatedSequence.locally_uniform (F : FoliatedSequence) (σ : ℝ) + (hzero : F.Good σ 0) (hone : F.Good σ (1, 0)) : + TendstoLocallyUniformly (fun n => F.map n) (fun x => σ • x) atTop := by + rw [Metric.tendstoLocallyUniformly_iff] + intro ε hε x + let L : ℝ := F.rectConstant * (2 + |σ|) + 1 + |σ| + have hL : 0 ≤ L := by + have hc := F.rectConstant_nonneg + dsimp [L] + positivity + let δ : ℝ := ε / (L + 1) + have hδ : 0 < δ := div_pos hε (by positivity) + have hsmall : L * δ < ε := by + dsimp [δ] + rw [← mul_div_assoc] + apply (div_lt_iff₀ (by positivity : 0 < L + 1)).mpr + nlinarith only [hε] + obtain ⟨a, b, c, d, ha, hb, hc, hd, hab, hcd, hg₀₀, hg₁₀, hg₀₁, hg₁₁⟩ := + F.small_good_rectangle σ hzero hone x δ hδ + refine ⟨{y : Point | y.1 ∈ Set.Ioo a b ∧ y.2 ∈ Set.Ioo c d}, ?_, ?_⟩ + · exact ((isOpen_Ioo.preimage continuous_fst).inter + (isOpen_Ioo.preimage continuous_snd)).mem_nhds ⟨⟨ha, hb⟩, ⟨hc, hd⟩⟩ + · filter_upwards [F.good_eventual_error σ _ hg₀₀ δ hδ, + F.good_eventual_error σ _ hg₁₀ δ hδ, F.good_eventual_error σ _ hg₀₁ δ hδ, + F.good_eventual_error σ _ hg₁₁ δ hδ] with n h₀₀ h₁₀ h₀₁ h₁₁ + intro y hy + rw [dist_eq_norm, norm_sub_rev] + exact (F.rectangle_error n σ a b c d δ y ⟨hy.1.1.le, hy.1.2.le⟩ + ⟨hy.2.1.le, hy.2.2.le⟩ hab hcd h₀₀ h₁₀ h₀₁ h₁₁).trans_lt hsmall + +lemma FoliatedSequence.uniform_on_compact (F : FoliatedSequence) (σ : ℝ) + (hzero : F.Good σ 0) (hone : F.Good σ (1, 0)) + (K : Set Point) (hK : IsCompact K) : + TendstoUniformlyOn (fun n => F.map n) (fun x => σ • x) atTop K := by + exact (tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact hK).mp + ((F.locally_uniform σ hzero hone).tendstoLocallyUniformlyOn) + +lemma inverse_bound_sign {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : OpenPartialHomeomorph E E) (hrange : f.source = Set.univ) + (hz : f 0 = 0) (σ : ℝ) (hσ : |σ| = 1) + (R r ε : ℝ) (hR : 0 ≤ R) (hε : 0 ≤ ε) (hgap : R + ε < r) + (htarget : Metric.closedBall (0 : E) R ⊆ f.target) + (hnear : ∀ x : E, ‖x‖ = r → ‖f x - σ • x‖ ≤ ε) + (y : E) (hy : ‖y‖ ≤ R) : ‖f.symm y‖ < r := by + have hinv₀ : f.symm 0 = 0 := by + calc + f.symm 0 = f.symm (f 0) := congrArg f.symm hz.symm + _ = 0 := f.left_inv (by rw [hrange]; trivial) + have hsmul (t : ℝ) (ht : t ∈ Set.Icc (0 : ℝ) 1) : ‖t • y‖ ≤ R := by + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht.1] + exact (mul_le_of_le_one_left (norm_nonneg y) ht.2).trans hy + have hpath : Set.MapsTo (fun t : ℝ => t • y) (Set.Icc 0 1) f.target := by + intro t ht + exact htarget (by simpa only [Metric.mem_closedBall, dist_zero_right] using hsmul t ht) + apply path_stays_inside f (fun t : ℝ => f.symm (t • y)) (f.symm y) r (r - ε) + (by linarith) + (f.continuousOn_symm.comp (continuous_id.smul continuous_const).continuousOn hpath) + · simpa only [zero_smul] using hinv₀ + · simp only [one_smul] + · intro t ht + rw [f.right_inv (hpath ht)] + have hb := hsmul t ht + linarith only [hb, hgap] + · intro x hx + have he := hnear x hx + have hb : ‖x‖ ≤ ‖f x - σ • x‖ + ‖f x‖ := by + calc + ‖x‖ = ‖σ • x‖ := by rw [norm_smul, Real.norm_eq_abs, hσ, one_mul] + _ ≤ ‖σ • x - f x‖ + ‖f x‖ := norm_le_norm_sub_add _ _ + _ = _ := by rw [norm_sub_rev] + linarith only [hx, he, hb] + +lemma norm_sign_inverse_error {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (σ : ℝ) (hσ : σ = 1 ∨ σ = -1) (x y : E) : + ‖x - σ • y‖ = ‖y - σ • x‖ := by + rcases hσ with rfl | rfl + · simpa only [one_smul] using norm_sub_rev x y + · simp only [neg_one_smul, sub_neg_eq_add, add_comm] + +lemma inverse_near_sign {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : OpenPartialHomeomorph E E) (hrange : f.source = Set.univ) + (hz : f 0 = 0) (σ : ℝ) (hσ : σ = 1 ∨ σ = -1) + (R r ε : ℝ) (hR : 0 ≤ R) (hε : 0 ≤ ε) (hgap : R + ε < r) + (htarget : Metric.closedBall (0 : E) R ⊆ f.target) + (hnear : ∀ x : E, ‖x‖ ≤ r → ‖f x - σ • x‖ ≤ ε) + (y : E) (hy : ‖y‖ ≤ R) : ‖f.symm y - σ • y‖ ≤ ε := by + have hyT : y ∈ f.target := htarget (by + simpa only [Metric.mem_closedBall, dist_zero_right] using hy) + have hσ' : |σ| = 1 := (abs_eq (by norm_num)).mpr hσ + have hb := inverse_bound_sign f hrange hz σ hσ' R r ε hR hε hgap htarget + (fun x hx => hnear x hx.le) y hy + have he := hnear (f.symm y) hb.le + rw [f.right_inv hyT] at he + rwa [norm_sign_inverse_error σ hσ] + +lemma FoliatedSequence.inverse_uniform_on_compact (F : FoliatedSequence) (σ : ℝ) + (hz : ∀ n, F.map n 0 = 0) (hσ : σ = 1 ∨ σ = -1) + (hone : F.Good σ (1, 0)) (K : Set Point) (hK : IsCompact K) : + TendstoUniformlyOn (fun n => (F.map n).symm) (fun x => σ • x) atTop K := by + have hzero : F.Good σ 0 := by + simpa only [Good, hz, smul_zero] using (tendsto_const_nhds : Tendsto (fun _ : ℕ => (0 : Point)) atTop (𝓝 0)) + obtain ⟨R₀, hR₀⟩ := (Metric.isBounded_iff_subset_closedBall (0 : Point)).mp hK.isBounded + let R := max R₀ 0 + have hR : 0 ≤ R := le_max_right _ _ + have hKR : K ⊆ Metric.closedBall (0 : Point) R := hR₀.trans (Metric.closedBall_subset_closedBall (le_max_left _ _)) + rw [Metric.tendstoUniformlyOn_iff] + intro ε hε + have hu := F.uniform_on_compact σ hzero hone (Metric.closedBall 0 (R + ε + 1)) + (isCompact_closedBall _ _) + filter_upwards [F.exhaust (Metric.closedBall 0 R) (isCompact_closedBall _ _), + (Metric.tendstoUniformlyOn_iff.mp hu (ε / 2) (by positivity))] with n htarget hn + intro y hy + rw [dist_eq_norm, norm_sub_rev] + have hnear (x : Point) (hx : ‖x‖ ≤ R + ε + 1) : ‖F.map n x - σ • x‖ ≤ ε / 2 := by + have hh := hn x (by simpa only [Metric.mem_closedBall, dist_zero_right] using hx) + simpa only [dist_eq_norm, norm_sub_rev] using hh.le + have hy' : ‖y‖ ≤ R := by simpa only [Metric.mem_closedBall, dist_zero_right] using hKR hy + exact (inverse_near_sign (F.map n) (F.source n) (hz n) σ hσ R (R + ε + 1) (ε / 2) + hR (by positivity) (by linarith only [hε]) htarget hnear y hy').trans_lt (by linarith only [hε]) + +theorem FoliatedSequence.normalized_compactness (F : FoliatedSequence) + (hz : ∀ n, F.map n 0 = 0) (hone : ∀ n, ‖F.map n (1, 0)‖ = 1) : + ∃ (ρ : ℕ → ℕ), StrictMono ρ ∧ ∃ σ : ℝ, (σ = 1 ∨ σ = -1) ∧ + (∀ K : Set Point, IsCompact K → + TendstoUniformlyOn (fun n => F.map (ρ n)) (fun x => σ • x) atTop K) ∧ + (∀ K : Set Point, IsCompact K → + TendstoUniformlyOn (fun n => (F.map (ρ n)).symm) (fun x => σ • x) atTop K) := by + obtain ⟨b, hb, ρ, hρ, hlim⟩ := (isCompact_sphere (0 : Point) 1).tendsto_subseq + (fun n => by simpa only [Metric.mem_sphere, dist_zero_right] using hone n) + have hzero : Tendsto (fun n => F.map (ρ n) 0) atTop (𝓝 (0 : Point)) := by + simpa only [hz] using (tendsto_const_nhds : Tendsto (fun _ : ℕ => (0 : Point)) atTop (𝓝 0)) + obtain ⟨σ, hσb⟩ := F.direction .horizontal ρ hρ (fun _ => 0) (fun _ => (1, 0)) + (fun _ => ⟨1, by simp [Foliation.direction]⟩) 0 b hzero hlim + have hb' : b = (σ, 0) := by simpa [Foliation.direction] using hσb + have hσ : σ = 1 ∨ σ = -1 := by + apply (abs_eq (by norm_num)).mp + simpa [hb', Metric.mem_sphere, Prod.norm_def] using hb + let G := F.subseq ρ hρ + have hgzero : G.Good σ 0 := by simpa only [Good, G, subseq, smul_zero] using hzero + have hgone : G.Good σ (1, 0) := by + simpa [Good, G, subseq, Function.comp_def, hb'] using hlim + exact ⟨ρ, hρ, σ, hσ, G.uniform_on_compact σ hgzero hgone, + G.inverse_uniform_on_compact σ (fun n => hz (ρ n)) hσ hgone⟩ + +end Zoom + +end PlanarHalving + +end OAI diff --git a/lean/OAI/Combinatorics/HalvingLines/ZoomControl.lean b/lean/OAI/Combinatorics/HalvingLines/ZoomControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..c62e83ec3591c3c8c8c6e54d97ded79f40cd90f3 --- /dev/null +++ b/lean/OAI/Combinatorics/HalvingLines/ZoomControl.lean @@ -0,0 +1,441 @@ +import OAI.Combinatorics.HalvingLines.LocalZoom + +namespace OAI + +open Filter Topology + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +lemma detPair_zero_parallel {u v : Point} (hv : v ≠ 0) (h : detPair u v=0) : + ∃ a : ℝ, u=a • v := by + by_cases h₁ : v.1=0 + · have h₂ : v.2≠0 := by intro hh; exact hv (Prod.ext h₁ hh) + refine ⟨u.2/v.2,Prod.ext ?_ ?_⟩ + · change u.1=u.2/v.2*v.1 + rw [h₁,mul_zero] + have he : u.1*v.2=0 := by simpa [detPair,h₁] using h + exact (mul_eq_zero.mp he).resolve_right h₂ + · change u.2=u.2/v.2*v.2 + field_simp + · refine ⟨u.1/v.1,Prod.ext ?_ ?_⟩ + · change u.1=u.1/v.1*v.1 + field_simp + · change u.2=u.1/v.1*v.2 + rw [div_mul_eq_mul_div] + apply (eq_div_iff h₁).mpr + dsimp [detPair] at h + nlinarith + +lemma map_eq_column (A : Point →L[ℝ] Point) (x : Point) : + A x=x.1 • A (1,0)+x.2 • A (0,1) := by + have hx : x=x.1 • ((1,0):Point)+x.2 • ((0,1):Point) := by ext <;> simp + conv_lhs => rw [hx,map_add,map_smul,map_smul] + +lemma detPair_map (A : Point →L[ℝ] Point) (u v : Point) : + detPair (A u) (A v)=detPair (A (1,0)) (A (0,1))*detPair u v := by + rw [map_eq_column A u,map_eq_column A v] + dsimp [detPair]; ring + +lemma map_injective_of_det (A : Point →L[ℝ] Point) + (h : detPair (A (1,0)) (A (0,1)) ≠ 0) : Function.Injective A := by + have he : A= (columnEquiv (A (1,0)) (A (0,1)) h).toContinuousLinearMap := by + apply ContinuousLinearMap.ext + intro x + exact map_eq_column A x + rw [he] + exact (columnEquiv _ _ h).injective + +lemma map_zero_of_two (A : Point →L[ℝ] Point) {u v : Point} (h : detPair u v ≠ 0) + (hu : A u=0) (hv : A v=0) : A=0 := by + apply ContinuousLinearMap.ext + intro x + obtain ⟨a,b,he⟩ := plane_span u v h x + rw [he,map_add,map_smul,map_smul,hu,hv,smul_zero,smul_zero,add_zero] + rfl + +lemma three_lines_injective (A : Point →L[ℝ] Point) (hA : A≠0) + (u v : Fin 3 → Point) + (hu : ∀ i j, i≠j → detPair (u i) (u j) ≠ 0) + (hv : ∀ i j, i≠j → detPair (v i) (v j) ≠ 0) + (hline : ∀ i, detPair (A (u i)) (v i)=0) : Function.Injective A := by + have hv0 (i : Fin 3) : v i≠0 := by + obtain ⟨j,hj⟩ := exists_ne i + intro he + have hh := hv i j hj.symm + simp only [he,detPair,Prod.fst_zero,Prod.snd_zero,zero_mul,sub_self,ne_eq,not_true_eq_false] at hh + choose c hc using fun i => detPair_zero_parallel (hv0 i) (hline i) + apply map_injective_of_det + intro hdet + have hp (i j : Fin 3) (hij : i≠j) : c i=0 ∨ c j=0 := by + have hh := detPair_map A (u i) (u j) + rw [hdet,zero_mul,hc,hc,detPair_smul] at hh + have hz : c i*c j=0 := (mul_eq_zero.mp hh).resolve_right (hv i j hij) + exact mul_eq_zero.mp hz + have hz (i j : Fin 3) (hij : i≠j) (hi : c i=0) (hj : c j=0) : False := by + apply hA + apply map_zero_of_two A (hu i j hij) + · rw [hc,hi,zero_smul] + · rw [hc,hj,zero_smul] + rcases hp 0 1 (by decide) with h0 | h1 + · rcases hp 1 2 (by decide) with h1 | h2 + · exact hz 0 1 (by decide) h0 h1 + · exact hz 0 2 (by decide) h0 h2 + · rcases hp 0 2 (by decide) with h0 | h2 + · exact hz 0 1 (by decide) h0 h1 + · exact hz 1 2 (by decide) h1 h2 + +lemma three_lines_uniform_conorm (v : Fin 3 → Point) + (hv : ∀ i j, i≠j → detPair (v i) (v j) ≠ 0) (δ : ℝ) (hδ : 0<δ) : + ∃ ε : ℝ, 0<ε ∧ ∀ (A : Point →L[ℝ] Point), ‖A‖=1 → + ∀ u : Fin 3 → Point, (∀ i, ‖u i‖=1) → + (∀ i j, i≠j → δ ≤ |detPair (u i) (u j)|) → + (∀ i, detPair (A (u i)) (v i)=0) → + ∀ y : Point, ‖y‖=1 → ε ≤ ‖A y‖ := by + by_contra! hn + have hex (n : ℕ) : ∃ (A : Point →L[ℝ] Point) (u : Fin 3 → Point) (y : Point), + ‖A‖=1 ∧ (∀ i, ‖u i‖=1) ∧ (∀ i j, i≠j → δ ≤ |detPair (u i) (u j)|) ∧ + (∀ i, detPair (A (u i)) (v i)=0) ∧ ‖y‖=1 ∧ ‖A y‖ < 1/(n+1:ℝ) := by + obtain ⟨A,hA,u,hu,hsep,hl,y,hy,hsmall⟩ := hn (1/(n+1:ℝ)) (by positivity) + exact ⟨A,u,y,hA,hu,hsep,hl,hy,hsmall⟩ + choose A u y hA hu hsep hl hy hsmall using hex + let Z := ((Point →L[ℝ] Point) × (Fin 3 → Point)) × Point + let z : ℕ → Z := fun n => ((A n,u n),y n) + have hz (n : ℕ) : z n∈closedBall (0:Z) 1 := by + rw [mem_closedBall_zero_iff] + change max (max ‖A n‖ ‖u n‖) ‖y n‖ ≤ 1 + rw [hA,hy,max_le_iff,max_le_iff] + refine ⟨⟨le_rfl,?_⟩,le_rfl⟩ + exact (pi_norm_le_iff_of_nonneg (by norm_num : (0:ℝ) ≤ 1)).mpr (fun i => (hu n i).le) + obtain ⟨z₀,hz₀,ρ,hρ,hlim⟩ := (isCompact_closedBall (0:Z) 1).tendsto_subseq hz + let A₀ := z₀.1.1 + let u₀ := z₀.1.2 + let y₀ := z₀.2 + have hAL : Tendsto (fun n => A (ρ n)) atTop (𝓝 A₀) := by + exact ((continuous_fst.comp continuous_fst).tendsto z₀).comp hlim + have huL : Tendsto (fun n => u (ρ n)) atTop (𝓝 u₀) := by + exact ((continuous_snd.comp continuous_fst).tendsto z₀).comp hlim + have hyL : Tendsto (fun n => y (ρ n)) atTop (𝓝 y₀) := by + exact (continuous_snd.tendsto z₀).comp hlim + have hAn : ‖A₀‖=1 := tendsto_nhds_unique hAL.norm (by simp only [hA]; exact tendsto_const_nhds) + have hu_n (i : Fin 3) : ‖u₀ i‖=1 := tendsto_nhds_unique ((tendsto_pi_nhds.mp huL i).norm) + (by simp only [hu]; exact tendsto_const_nhds) + have hyn : ‖y₀‖=1 := tendsto_nhds_unique hyL.norm (by simp only [hy]; exact tendsto_const_nhds) + have hsep₀ (i j : Fin 3) (hij : i≠j) : detPair (u₀ i) (u₀ j) ≠ 0 := by + have hi := tendsto_pi_nhds.mp huL i + have hj := tendsto_pi_nhds.mp huL j + have hd : Tendsto (fun n => |detPair (u (ρ n) i) (u (ρ n) j)|) atTop + (𝓝 |detPair (u₀ i) (u₀ j)|) := ((hi.fst_nhds.mul hj.snd_nhds).sub (hi.snd_nhds.mul hj.fst_nhds)).abs + have hb := ge_of_tendsto hd (Eventually.of_forall (fun n => hsep (ρ n) i j hij)) + exact abs_pos.mp (hδ.trans_le hb) + have hl₀ (i : Fin 3) : detPair (A₀ (u₀ i)) (v i)=0 := by + have ht := ((continuous_fst.clm_apply continuous_snd).tendsto (A₀,u₀ i)).comp + (hAL.prodMk_nhds (tendsto_pi_nhds.mp huL i)) + have hd : Tendsto (fun n => detPair (A (ρ n) (u (ρ n) i)) (v i)) atTop + (𝓝 (detPair (A₀ (u₀ i)) (v i))) := (ht.fst_nhds.mul_const _).sub (ht.snd_nhds.mul_const _) + exact tendsto_nhds_unique hd (by simp only [hl]; exact tendsto_const_nhds) + have hInj := three_lines_injective A₀ (by intro he; rw [he,norm_zero] at hAn; norm_num at hAn) + u₀ v hsep₀ hv hl₀ + have hzero : ‖A₀ y₀‖=0 := by + have ht := (((continuous_fst.clm_apply continuous_snd).tendsto (A₀,y₀)).comp (hAL.prodMk_nhds hyL)).norm + have hnlim : Tendsto (fun n : ℕ => 1/(n+1:ℝ)) atTop (𝓝 0) := by + simpa using tendsto_one_div_add_atTop_nhds_zero_nat (𝕜:=ℝ) + have hbound : Tendsto (fun n => ‖A (ρ n) (y (ρ n))‖) atTop (𝓝 0) := + squeeze_zero (fun n => norm_nonneg _) (fun n => (hsmall (ρ n)).le) (hnlim.comp hρ.tendsto_atTop) + exact tendsto_nhds_unique ht hbound + have hye : y₀=0 := hInj ((norm_eq_zero.mp hzero).trans (map_zero A₀).symm) + rw [hye,norm_zero] at hyn + norm_num at hyn + +end PlanarHalving.Zoom + +namespace PlanarHalving.Zoom +open Set Filter Metric +open scoped Topology + +lemma detPair_equiv_ne_zero (B : Point ≃L[ℝ] Point) {u v : Point} + (h : detPair u v≠0) : detPair (B u) (B v)≠0 := by + intro he + have ht := detPair_map B.symm.toContinuousLinearMap (B u) (B v) + apply h + simpa only [ContinuousLinearEquiv.coe_coe,B.symm_apply_apply,he,mul_zero] using ht + +lemma signed_simplex_ne_zero (z : ℝ) : + RankLimits.reflectFirst (Directions.simplex z)≠0 := by + intro he + have h1 := congrArg Prod.fst he + have h2 := congrArg Prod.snd he + dsimp [RankLimits.reflectFirst,Directions.simplex] at h1 h2 + linarith + +lemma unit_simplex_parallel_det_ne_zero (B : Point ≃L[ℝ] Point) + {u v : Point} (hu : ‖u‖=1) (hv : ‖v‖=1) {z w : ℝ} (hzw : z≠w) + (huz : detPair u (B (RankLimits.reflectFirst (Directions.simplex z)))=0) + (hvw : detPair v (B (RankLimits.reflectFirst (Directions.simplex w)))=0) : + detPair u v≠0 := by + have hnon (r : ℝ) : B (RankLimits.reflectFirst (Directions.simplex r))≠0 := by + intro he + exact signed_simplex_ne_zero r (B.injective (he.trans (map_zero B).symm)) + obtain ⟨a,ha⟩ := detPair_zero_parallel (hnon z) huz + obtain ⟨b,hb⟩ := detPair_zero_parallel (hnon w) hvw + have ha0 : a≠0 := by intro he; rw [he,zero_smul] at ha; rw [ha,norm_zero] at hu; norm_num at hu + have hb0 : b≠0 := by intro he; rw [he,zero_smul] at hb; rw [hb,norm_zero] at hv; norm_num at hv + rw [ha,hb,detPair_smul] + apply mul_ne_zero (mul_ne_zero ha0 hb0) + apply detPair_equiv_ne_zero + have ht : detPair (RankLimits.reflectFirst (Directions.simplex z)) + (RankLimits.reflectFirst (Directions.simplex w))=w-z := by + dsimp [detPair,RankLimits.reflectFirst,Directions.simplex]; ring + rw [ht] + exact sub_ne_zero.mpr hzw.symm + +lemma compact_allowed_separation (B : Point ≃L[ℝ] Point) + (S T : Set ℝ) (hS : IsClosed S) (hT : IsClosed T) + (hSb : S ⊆ Icc (0:ℝ) 1) (hTb : T ⊆ Icc (0:ℝ) 1) (hST : Disjoint S T) : + ∃ δ : ℝ, 0<δ ∧ ∀ u v : Point, ‖u‖=1 → ‖v‖=1 → + (∃ z∈S, detPair u (B (RankLimits.reflectFirst (Directions.simplex z)))=0) → + (∃ z∈T, detPair v (B (RankLimits.reflectFirst (Directions.simplex z)))=0) → + δ ≤ |detPair u v| := by + let dir : ℝ → Point := fun z => B (RankLimits.reflectFirst (Directions.simplex z)) + have hdir : Continuous dir := by + apply B.continuous.comp + apply RankLimits.reflectFirst.continuous.comp + exact (continuous_id.prodMk (continuous_const.sub continuous_id)) + let K : Set (Point × ℝ) := {x | ‖x.1‖=1 ∧ x.2∈S ∧ detPair x.1 (dir x.2)=0} + let L : Set (Point × ℝ) := {x | ‖x.1‖=1 ∧ x.2∈T ∧ detPair x.1 (dir x.2)=0} + have hdet : Continuous (fun x : Point × ℝ => detPair x.1 (dir x.2)) := by + exact ((continuous_fst.fst.mul ((hdir.comp continuous_snd).snd)).sub + (continuous_fst.snd.mul ((hdir.comp continuous_snd).fst))) + have hKC : IsClosed K := + (isClosed_eq continuous_fst.norm continuous_const).inter + ((hS.preimage continuous_snd).inter (isClosed_eq hdet continuous_const)) + have hLC : IsClosed L := + (isClosed_eq continuous_fst.norm continuous_const).inter + ((hT.preimage continuous_snd).inter (isClosed_eq hdet continuous_const)) + have hK : IsCompact K := ((isCompact_closedBall (0:Point) 1).prod isCompact_Icc).of_isClosed_subset hKC + (by intro x hx; exact ⟨by simp [hx.1],hSb hx.2.1⟩) + have hL : IsCompact L := ((isCompact_closedBall (0:Point) 1).prod isCompact_Icc).of_isClosed_subset hLC + (by intro x hx; exact ⟨by simp [hx.1],hTb hx.2.1⟩) + let f : (Point × ℝ) × (Point × ℝ) → ℝ := fun x => |detPair x.1.1 x.2.1| + have hf : Continuous f := by + exact ((continuous_fst.fst.fst.mul continuous_snd.fst.snd).sub + (continuous_fst.fst.snd.mul continuous_snd.fst.fst)).abs + have hpos (x) (hx : x∈K ×ˢ L) : 0 (h hij).elim⟩ + · obtain ⟨δ,hδ,hd⟩ := compact_allowed_separation B (S ij.1) (S ij.2) + (hS ij.1) (hS ij.2) (hSb ij.1) (hSb ij.2) (hdis _ _ hij) + exact ⟨δ,hδ,fun u v hu hv hz hw _ => hd u v hu hv hz hw⟩ + choose δ hδ hd using hex + obtain ⟨ij,_,hmin⟩ := isCompact_univ.exists_isMinOn (s:= (univ:Set (Fin 3 × Fin 3))) + (by simp) (continuous_of_discreteTopology (f:=δ)).continuousOn + refine ⟨δ ij,hδ ij,?_⟩ + intro u hu hz i j hij + exact (hmin (show (i,j)∈(univ:Set (Fin 3 × Fin 3)) from mem_univ _)).trans + (hd (i,j) (u i) (u j) (hu i) (hu j) (hz i) (hz j) hij) + +lemma eventually_separated_of_allowed_clusters (B : Point ≃L[ℝ] Point) + (S : Fin 3 → Set ℝ) (hS : ∀ i, IsClosed (S i)) + (hSb : ∀ i, S i ⊆ Icc (0:ℝ) 1) (hdis : ∀ i j, i≠j → Disjoint (S i) (S j)) + : ∃ δ : ℝ, 0<δ ∧ ∀ (u : ℕ → Fin 3 → Point), (∀ n i, ‖u n i‖=1) → + (∀ ρ : ℕ → ℕ, StrictMono ρ → ∀ v : Fin 3 → Point, + Tendsto (u ∘ ρ) atTop (𝓝 v) → + ∀ i, ∃ z∈S i, detPair (v i) (B (RankLimits.reflectFirst (Directions.simplex z)))=0) → + ∀ᶠ n in atTop, ∀ i j, i≠j → δ ≤ |detPair (u n i) (u n j)| := by + obtain ⟨δ,hδ,hsep⟩ := triple_allowed_separation B S hS hSb hdis + refine ⟨δ/2,by positivity,?_⟩ + intro u hu hcluster + by_contra hn + obtain ⟨ρ,hρ,hbad⟩ := extraction_of_frequently_atTop (not_eventually.mp hn) + have hb (n : ℕ) : u (ρ n)∈closedBall (0:Fin 3 → Point) 1 := by + rw [mem_closedBall_zero_iff] + exact (pi_norm_le_iff_of_nonneg (by norm_num : (0:ℝ)≤1)).mpr (fun i => (hu _ i).le) + obtain ⟨v,_,τ,hτ,hlim⟩ := (isCompact_closedBall (0:Fin 3 → Point) 1).tendsto_subseq hb + have hv (i : Fin 3) : ‖v i‖=1 := tendsto_nhds_unique ((tendsto_pi_nhds.mp hlim i).norm) + (by simp only [Function.comp_def,hu]; exact tendsto_const_nhds) + have hd := hsep v hv (hcluster (ρ ∘ τ) (hρ.comp hτ) v hlim) + have he : ∀ᶠ n in atTop, ∀ i j, i≠j → δ/2 ≤ |detPair (u (ρ (τ n)) i) (u (ρ (τ n)) j)| := by + apply eventually_all.mpr + intro i + apply eventually_all.mpr + intro j + by_cases hij : i=j + · exact Eventually.of_forall (fun _ h => (h hij).elim) + · have hi := tendsto_pi_nhds.mp hlim i + have hj := tendsto_pi_nhds.mp hlim j + have ht : Tendsto (fun n => |detPair (u (ρ (τ n)) i) (u (ρ (τ n)) j)|) atTop + (𝓝 |detPair (v i) (v j)|) := + ((hi.fst_nhds.mul hj.snd_nhds).sub (hi.snd_nhds.mul hj.fst_nhds)).abs + have hlt : δ/2 < |detPair (v i) (v j)| := by linarith [hd i j hij] + exact (ht.eventually (lt_mem_nhds hlt)).mono (fun _ hh _ => hh.le) + obtain ⟨n,hn⟩ := he.exists + exact hbad (τ n) hn + +end PlanarHalving.Zoom + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +lemma affine_rank_forward_limit {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hCB : ∀ i, Before (C i) A ∧ Before (C i) B) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (h q : ℕ → ℝ) (hh : ∀ n, 0 affineZoom ((F n).rankChart hAB (hA n) (hB n)) + (E n) B' p (x₀ n) (q n) (h n) (hq n).ne' (hh n).ne' (x n)) atTop (𝓝 a)) + (hb : Tendsto (fun n => affineZoom ((F n).rankChart hAB (hA n) (hB n)) + (E n) B' p (x₀ n) (q n) (h n) (hq n).ne' (hh n).ne' (y n)) atTop (𝓝 b)) + (hj : ∀ i R, 0 ≤ R → TendstoUniformlyOn + (fun n u => (((F n).extendedRank true A B (C i) (p+h n • u) : ℝ)-c i)/h n) + (D i) atTop (closedBall 0 R)) : + ∃ z∈Directions.allowed reflectFirst D + (fun i => (lower (C i):ℝ)) (fun i => (upper (C i):ℝ)) t, + detPair (b-a) (B' (reflectFirst (Directions.simplex z)))=0 := by + let X := fun n => x₀ n+q n • E n (x n) + let Y := fun n => x₀ n+q n • E n (y n) + have hXY (n : ℕ) : Y n=X n+(q n*s n) • (1,(F n).timeSlope t) := by + have he := hE n + have hy : E n (y n)=E n (x n)+s n • (1,(F n).timeSlope t) := by + rw [map_sub] at he; exact eq_add_of_sub_eq' he + dsimp only [X,Y] + rw [hy,smul_add,smul_smul,add_assoc] + have hxa : Tendsto (fun n => (h n)⁻¹ • + ((F n).rankChart hAB (hA n) (hB n) (X n)-p)) atTop (𝓝 (B'.symm a)) := by + simpa only [Function.comp_def,affineZoom_apply,B'.symm_apply_apply,X] + using (B'.symm.continuous.tendsto a).comp ha + have hyb : Tendsto (fun n => (h n)⁻¹ • + ((F n).rankChart hAB (hA n) (hB n) (Y n)-p)) atTop (𝓝 (B'.symm b)) := by + simpa only [Function.comp_def,affineZoom_apply,B'.symm_apply_apply,Y] + using (B'.symm.continuous.tendsto b).comp hb + have hne : B'.symm b-B'.symm a≠0 := by + intro he; apply hab + have hg := congrArg B' he + simpa only [map_sub,B'.apply_symm_apply,map_zero] using hg + obtain ⟨r,_,z,hz,he⟩ := actual_forward_limit F hAB hA hB C hC D c p h hh t htA htB + X Y (fun n => q n*s n) (fun n => mul_nonneg (hq n).le (hs n)) hXY + (B'.symm a) (B'.symm b) hxa hyb + (fun i => jet_at_physical F hAB (hCB i) hA hB (hC i) (D i) (c i) p h hh (hj i) X _ hxa) + (fun i => jet_at_physical F hAB (hCB i) hA hB (hC i) (D i) (c i) p h hh (hj i) Y _ hyb) hne + refine ⟨z,hz,?_⟩ + have ht := congrArg B' he + simp only [map_sub,map_smul,B'.apply_symm_apply] at ht + rw [ht] + dsimp [detPair]; ring + +end PlanarHalving.RankLimits + +namespace PlanarHalving.RankLimits +open Set Filter MeasureTheory Metric Batches TimeWindows RankCoordinates Zoom +open scoped Topology unitInterval + +noncomputable def forwardUnit (F : Configuration) (E : Point ≃L[ℝ] Point) (t : I) : Point := + ‖E.symm (1,F.timeSlope t)‖⁻¹ • E.symm (1,F.timeSlope t) + +lemma forwardUnit_norm (F : Configuration) (E : Point ≃L[ℝ] Point) (t : I) : + ‖forwardUnit F E t‖=1 := by + apply norm_smul_inv_norm + intro he + have hh := congrArg E he + simp at hh + +lemma forwardUnit_map (F : Configuration) (E : Point ≃L[ℝ] Point) (t : I) : + E (forwardUnit F E t)=‖E.symm (1,F.timeSlope t)‖⁻¹ • (1,F.timeSlope t) := by + simp only [forwardUnit,map_smul,E.apply_symm_apply] + +lemma actual_forwardUnit_clusters {ι : Type*} (F : ℕ → Configuration) {A B : Window} + (hAB : Before A B) (hA : ∀ n, 0 < length (F n).R A) + (hB : ∀ n, 0 < length (F n).R B) (C : ι → Window) + (hCB : ∀ i, Before (C i) A ∧ Before (C i) B) + (hC : ∀ i, ∀ᶠ n in atTop, 0 < length (F n).R (C i)) + (D : ι → Point →L[ℝ] ℝ) (c : ι → ℝ) (p : Point) + (hp : p ∈ Ioo (0:ℝ) 1 ×ˢ Ioo (-1:ℝ) 0) + (h q : ℕ → ℝ) (hh : ∀ n, 0 (((F n).extendedRank true A B (C i) (p+h n • u) : ℝ)-c i)/h n) + (D i) atTop (closedBall 0 R)) + (hunif : TendstoUniformlyOn + (fun n => affineZoom ((F n).rankChart hAB (hA n) (hB n)) (E n) B' p + (((F n).rankChart hAB (hA n) (hB n)).symm p) (q n) (h n) (hq n).ne' (hh n).ne') + (fun x => sgn • x) atTop (closedBall 0 1)) + (ρ : ℕ → ℕ) (hρ : StrictMono ρ) (v : Point) + (hvlim : Tendsto (fun n => forwardUnit (F (ρ n)) (E (ρ n)) t) atTop (𝓝 v)) : + ∃ z∈Directions.allowed reflectFirst D + (fun i => (lower (C i):ℝ)) (fun i => (upper (C i):ℝ)) t, + detPair v (B' (reflectFirst (Directions.simplex z)))=0 := by + let f := fun n => (F n).rankChart hAB (hA n) (hB n) + let x₀ := fun n => (f n).symm p + let Z := fun n => affineZoom (f n) (E n) B' p (x₀ n) (q n) (h n) (hq n).ne' (hh n).ne' + have hpt (n : ℕ) : p∈(f n).target := by rw [(F n).rankChart_target]; exact hp + have hz (n : ℕ) : Z n 0=0 := affineZoom_zero (f n) (E n) B' (hpt n) _ _ _ _ + have hvn : ‖v‖=1 := tendsto_nhds_unique hvlim.norm + (by simp only [forwardUnit_norm]; exact tendsto_const_nhds) + have hsgn0 : sgn≠0 := by rcases hsgn with rfl | rfl <;> norm_num + have hne : sgn • v-0≠0 := by + rw [sub_zero] + exact smul_ne_zero hsgn0 (by intro he; rw [he,norm_zero] at hvn; norm_num at hvn) + have hvwithin : Tendsto (fun n => forwardUnit (F (ρ n)) (E (ρ n)) t) atTop + (𝓝[closedBall (0:Point) 1] v) := tendsto_nhdsWithin_iff.mpr ⟨hvlim,Eventually.of_forall + (fun n => by simp [forwardUnit_norm])⟩ + have hyl : Tendsto (fun n => Z (ρ n) (forwardUnit (F (ρ n)) (E (ρ n)) t)) atTop (𝓝 (sgn • v)) := + (hunif.seq_tendstoUniformlyOn ρ hρ.tendsto_atTop).tendsto_comp + ((continuous_const : Continuous (fun _ : Point => sgn)).smul continuous_id).continuousWithinAt hvwithin + obtain ⟨z,hz',hdet⟩ := affine_rank_forward_limit (F ∘ ρ) hAB (fun n => hA (ρ n)) (fun n => hB (ρ n)) + C hCB (fun i => hρ.tendsto_atTop.eventually (hC i)) D c p (h ∘ ρ) (q ∘ ρ) + (fun n => hh (ρ n)) (fun n => hq (ρ n)) (E ∘ ρ) B' (x₀ ∘ ρ) t htA htB + (fun _ => 0) (fun n => forwardUnit (F (ρ n)) (E (ρ n)) t) + (fun n => ‖(E (ρ n)).symm (1,(F (ρ n)).timeSlope t)‖⁻¹) + (fun n => inv_nonneg.mpr (norm_nonneg _)) + (fun n => by rw [sub_zero]; exact forwardUnit_map _ _ _) + 0 (sgn • v) hne + (by change Tendsto (fun n => Z (ρ n) 0) atTop (𝓝 0); simp only [hz]; exact tendsto_const_nhds) hyl + (fun i R hR => (hj i R hR).seq_tendstoUniformlyOn ρ hρ.tendsto_atTop) + refine ⟨z,hz',?_⟩ + rw [sub_zero] at hdet + have he : detPair (sgn • v) (B' (reflectFirst (Directions.simplex z)))= + sgn*detPair v (B' (reflectFirst (Directions.simplex z))) := by dsimp [detPair]; ring + rw [he] at hdet + exact (mul_eq_zero.mp hdet).resolve_left hsgn0 + +end PlanarHalving.RankLimits + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/BMatching.lean b/lean/OAI/Combinatorics/Hamiltonian/BMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5fa133ae22bf29a77d8b3c25e6174748b39e4e1 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/BMatching.lean @@ -0,0 +1,432 @@ +import OAI.Combinatorics.Hamiltonian.MinorDuality + +namespace OAI + +/-! Integral flows, capacitated matchings, and incidence-state pairs. -/ + +namespace Barnette.BMatching +noncomputable section +open scoped Classical +variable {A B : Type*} [Fintype A] [Fintype B] + +lemma count_sum {C D : Type*} [Fintype C] [Fintype D] (p : C ⊕ D → Prop) [DecidablePred p] : + (Finset.univ.filter p).card = (Finset.univ.filter fun c => p (.inl c)).card + + (Finset.univ.filter fun d => p (.inr d)).card := by + simp only [Finset.card_filter,Fintype.sum_sum_type] + +lemma count_prod {C D : Type*} [Fintype C] [Fintype D] (p : C × D → Prop) [DecidablePred p] : + (Finset.univ.filter p).card = ∑ c, (Finset.univ.filter fun d => p (c,d)).card := by + simp only [Finset.card_filter,Fintype.sum_prod_type] + +abbrev Inc (R : A → B → Prop) := {z : A × B // R z.1 z.2} +abbrev Left (R : A → B → Prop) := (A × Fin 2) ⊕ Inc R +abbrev Right (R : A → B → Prop) := (B × Fin 2) ⊕ Inc R + +def gadget (R : A → B → Prop) : Left R → Right R → Prop + | .inl (a,_), .inr e => e.val.1 = a + | .inr e, .inl (b,_) => e.val.2 = b + | .inr e, .inr f => e = f + | _, _ => False + +lemma incidence_fiber (R : A → B → Prop) (S : Finset A) (b : B) : + ((Finset.univ.filter fun e : Inc R => e.val.1 ∈ S).filter + fun e => e.val.2 = b).card = (S.filter fun a => R a b).card := by + apply Finset.card_bij (fun e _ => e.val.1) + · intro e he + obtain ⟨he,hb⟩ := Finset.mem_filter.mp he + exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp he).2,hb ▸ e.property⟩ + · intro e he f hf hh + apply Subtype.ext + exact Prod.ext hh ((Finset.mem_filter.mp he).2.trans (Finset.mem_filter.mp hf).2.symm) + · intro a ha + obtain ⟨ha,hab⟩ := Finset.mem_filter.mp ha + exact ⟨⟨(a,b),hab⟩,by simp [ha],rfl⟩ + +lemma gadget_hall (R : A → B → Prop) + (hcap : ∀ S : Finset A, 2*S.card ≤ ∑ b, min 2 ((S.filter fun a => R a b).card)) + (L : Finset (Left R)) : + L.card ≤ (Finset.univ.filter fun r : Right R => ∃ l ∈ L, gadget R l r).card := by + let S := Finset.univ.filter fun a : A => ∃ k : Fin 2, Sum.inl (a,k) ∈ L + let T := Finset.univ.filter fun e : Inc R => Sum.inr e ∈ L + let I := Finset.univ.filter fun e : Inc R => e.val.1 ∈ S + let Y := Finset.univ.filter fun b : B => ∃ e ∈ T, e.val.2 = b + have hLc : L.card ≤ 2*S.card + T.card := by + have hL : L = Finset.univ.filter (fun l => l ∈ L) := by ext; simp + conv_lhs => rw [hL,count_sum (fun l : Left R => l ∈ L),count_prod] + change (∑ a, (Finset.univ.filter fun k : Fin 2 => Sum.inl (a,k) ∈ L).card) + + T.card ≤ _ + apply Nat.add_le_add_right + calc + _ ≤ ∑ a, if a ∈ S then 2 else 0 := by + apply Finset.sum_le_sum + intro a _ + by_cases ha : a ∈ S + · simp only [ha,ite_true] + exact le_trans (Finset.card_le_card (Finset.filter_subset _ _)) (by simp) + · have hn : ∀ k : Fin 2, Sum.inl (a,k) ∉ L := by simpa [S] using ha + simp [ha,hn] + _ = 2*S.card := by simp [mul_comm] + have hY (b : B) (k : Fin 2) : + (∃ l ∈ L, gadget R l (.inl (b,k))) ↔ b ∈ Y := by + constructor + · rintro ⟨l,hl,hg⟩ + cases l with + | inl a => exact hg.elim + | inr e => exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,e,by simp [T,hl],hg⟩ + · intro hb + obtain ⟨e,he,hb⟩ := (Finset.mem_filter.mp hb).2 + exact ⟨.inr e,(Finset.mem_filter.mp he).2,hb⟩ + have hI (e : Inc R) : (∃ l ∈ L, gadget R l (.inr e)) ↔ e ∈ I ∪ T := by + constructor + · rintro ⟨l,hl,hg⟩ + cases l with + | inl a => + apply Finset.mem_union_left + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _,Finset.mem_filter.mpr ⟨Finset.mem_univ _,a.2,?_⟩⟩ + change e.val.1 = a.1 at hg + simpa only [hg] using hl + | inr f => + change f = e at hg + exact Finset.mem_union_right _ (by simpa [T,← hg] using hl) + · intro he + rcases Finset.mem_union.mp he with he | he + · obtain ⟨k,hk⟩ := (Finset.mem_filter.mp ((Finset.mem_filter.mp he).2)).2 + exact ⟨.inl (e.val.1,k),hk,rfl⟩ + · exact ⟨.inr e,(Finset.mem_filter.mp he).2,rfl⟩ + have hNc : (Finset.univ.filter fun r : Right R => ∃ l ∈ L, gadget R l r).card = + 2*Y.card + (I ∪ T).card := by + rw [count_sum (fun r : Right R => ∃ l ∈ L, gadget R l r),count_prod] + simp only [hY,hI] + have hconst (b : B) : (Finset.univ.filter fun _ : Fin 2 => b ∈ Y).card = + if b ∈ Y then 2 else 0 := by by_cases hb : b ∈ Y <;> simp [hb] + have hfilter : (Finset.univ.filter fun e : Inc R => e ∈ I ∪ T) = I ∪ T := by ext; simp + rw [hfilter] + simp only [hconst] + simp [mul_comm] + have hcap' : 2*S.card ≤ 2*Y.card + (I \ T).card := by + have hsum : ∑ b, min 2 ((S.filter fun a => R a b).card) ≤ + (∑ b, if b ∈ Y then 2 else 0) + ∑ b, ((I \ T).filter fun e => e.val.2 = b).card := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro b _ + by_cases hb : b ∈ Y + · simp only [hb,ite_true] + exact le_trans (Nat.min_le_left _ _) (Nat.le_add_right _ _) + · have hIT : (I \ T).filter (fun e => e.val.2 = b) = I.filter (fun e => e.val.2 = b) := by + ext e + simp only [Finset.mem_filter,Finset.mem_sdiff] + constructor + · exact fun ⟨⟨hi,_⟩,he⟩ => ⟨hi,he⟩ + · rintro ⟨hi,he⟩ + refine ⟨⟨hi,fun ht => hb (Finset.mem_filter.mpr ⟨Finset.mem_univ _,e,ht,he⟩)⟩,he⟩ + rw [hIT] + dsimp only [I] + rw [incidence_fiber] + simp only [hb,ite_false,zero_add] + exact Nat.min_le_right _ _ + have hcount : ∑ b, ((I \ T).filter fun e => e.val.2 = b).card = (I \ T).card := by + simpa using Finset.sum_card_fiberwise_eq_card_filter (I \ T) Finset.univ (fun e => e.val.2) + rw [hcount] at hsum + have hycount : (∑ b, if b ∈ Y then 2 else 0 : ℕ) = 2*Y.card := by + simp [mul_comm] + rw [hycount] at hsum + exact (hcap S).trans hsum + rw [hNc,← Finset.card_sdiff_add_card] + omega + +theorem gadget_matching (R : A → B → Prop) (hcard : Fintype.card A = Fintype.card B) + (hcap : ∀ S : Finset A, 2*S.card ≤ ∑ b, min 2 ((S.filter fun a => R a b).card)) : + ∃ f : Left R ≃ Right R, ∀ l, gadget R l (f l) := by + obtain ⟨f,hfi,hf⟩ := (Fintype.all_card_le_filter_rel_iff_exists_injective (gadget R)).mp + (gadget_hall R hcap) + have hb : Function.Bijective f := (Fintype.bijective_iff_injective_and_card f).mpr ⟨hfi,by + simp only [Fintype.card_sum,Fintype.card_prod,Fintype.card_fin,hcard]⟩ + exact ⟨Equiv.ofBijective f hb,hf⟩ + +end +end Barnette.BMatching +namespace Barnette.BMatching +noncomputable section +open scoped Classical +variable {A B : Type*} [Fintype A] [Fintype B] + +structure FactorData (R : A → B → Prop) where + left : A × Fin 2 ↪ Inc R + right : B × Fin 2 ↪ Inc R + left_coord : ∀ a k, (left (a,k)).val.1 = a + right_coord : ∀ b k, (right (b,k)).val.2 = b + same_range : Set.range left = Set.range right + +omit [Fintype A] [Fintype B] in +lemma data_of_gadget (R : A → B → Prop) (f : Left R ≃ Right R) + (hf : ∀ l, gadget R l (f l)) : Nonempty (FactorData R) := by + have hleft : ∀ ak : A × Fin 2, ∃ e : Inc R, f (.inl ak) = .inr e ∧ e.val.1 = ak.1 := by + intro ak + have h := hf (.inl ak) + cases he : f (.inl ak) with + | inl bk => rw [he] at h; exact h.elim + | inr e => rw [he] at h; exact ⟨e,rfl,h⟩ + have hright : ∀ bk : B × Fin 2, ∃ e : Inc R, f (.inr e) = .inl bk ∧ e.val.2 = bk.1 := by + intro bk + obtain ⟨l,hl⟩ := f.surjective (.inl bk) + have h := hf l + rw [hl] at h + cases l with + | inl ak => exact h.elim + | inr e => exact ⟨e,hl,h⟩ + choose l hl hlc using hleft + choose r hr hrc using hright + have hli : Function.Injective l := by + intro a b h + exact Sum.inl.inj (f.injective ((hl a).trans ((congrArg Sum.inr h).trans (hl b).symm))) + have hri : Function.Injective r := by + intro a b h + exact Sum.inl.inj ((hr a).symm.trans ((congrArg (fun e => f (.inr e)) h).trans (hr b))) + refine ⟨⟨⟨l,hli⟩,⟨r,hri⟩,fun a k => hlc (a,k),fun b k => hrc (b,k),?_⟩⟩ + ext e + constructor + · rintro ⟨ak,rfl⟩ + have h := hf (.inr (l ak)) + cases he : f (.inr (l ak)) with + | inl bk => + exact ⟨bk,Sum.inr.inj (f.injective ((hr bk).trans he.symm))⟩ + | inr d => + rw [he] at h + change l ak = d at h + have hh : Sum.inl ak = Sum.inr (l ak) := f.injective ((hl ak).trans (by simpa [h] using he.symm)) + cases hh + · rintro ⟨bk,rfl⟩ + obtain ⟨z,hz⟩ := f.surjective (.inr (r bk)) + have h := hf z + rw [hz] at h + cases z with + | inl ak => exact ⟨ak,Sum.inr.inj ((hl ak).symm.trans hz)⟩ + | inr e => + change e = r bk at h + subst e + have hh := (hr bk).symm.trans hz + cases hh + +lemma two_image_count {C : Type*} [Fintype C] (f : Fin 2 → C) (hf : Function.Injective f) : + (Finset.univ.filter fun c => ∃ k, f k = c).card = 2 := by + have hs : (Finset.univ.filter fun c => ∃ k, f k = c) = Finset.univ.image f := by ext; simp + rw [hs,Finset.card_image_of_injective _ hf] + simp + +lemma data_two_factor (R : A → B → Prop) (M : FactorData R) : + ∃ Q : A → B → Prop, (∀ a b, Q a b → R a b) ∧ + (∀ a, (Finset.univ.filter (Q a)).card = 2) ∧ + (∀ b, (Finset.univ.filter fun a => Q a b).card = 2) := by + classical + let Q : A → B → Prop := fun a b => ∃ k, (M.left (a,k)).val.2 = b + have hQright (a : A) (b : B) : Q a b ↔ ∃ k, (M.right (b,k)).val.1 = a := by + constructor + · rintro ⟨k,hk⟩ + have he : M.left (a,k) ∈ Set.range M.right := M.same_range ▸ Set.mem_range_self _ + obtain ⟨⟨c,j⟩,he⟩ := he + have hc : c = b := (M.right_coord c j).symm.trans ((congrArg (fun e : Inc R => e.val.2) he).trans hk) + subst c + exact ⟨j,(congrArg (fun e : Inc R => e.val.1) he).trans (M.left_coord a k)⟩ + · rintro ⟨k,hk⟩ + have he : M.right (b,k) ∈ Set.range M.left := M.same_range.symm ▸ Set.mem_range_self _ + obtain ⟨⟨c,j⟩,he⟩ := he + have hc : c = a := (M.left_coord c j).symm.trans ((congrArg (fun e : Inc R => e.val.1) he).trans hk) + subst c + exact ⟨j,(congrArg (fun e : Inc R => e.val.2) he).trans (M.right_coord b k)⟩ + refine ⟨Q,?_,?_,?_⟩ + · rintro a b ⟨k,rfl⟩ + have h := (M.left (a,k)).property + rwa [M.left_coord] at h + · intro a + have hi : Function.Injective (fun k => (M.left (a,k)).val.2) := by + intro i j hij + have he : M.left (a,i) = M.left (a,j) := Subtype.ext (Prod.ext (by simp [M.left_coord]) hij) + exact Prod.mk.inj (M.left.injective he) |>.2 + simpa only [Q] using two_image_count (fun k => (M.left (a,k)).val.2) hi + · intro b + simp only [hQright] + apply two_image_count + intro i j hij + have he : M.right (b,i) = M.right (b,j) := Subtype.ext (Prod.ext hij (by simp [M.right_coord])) + exact Prod.mk.inj (M.right.injective he) |>.2 + +lemma regular_hall (Q : A → B → Prop) (n : ℕ) (hn : 0 < n) + (hrow : ∀ a, (Finset.univ.filter (Q a)).card = n) + (hcol : ∀ b, (Finset.univ.filter fun a => Q a b).card = n) + (S : Finset A) : + S.card ≤ (Finset.univ.filter fun b => ∃ a ∈ S, Q a b).card := by + let T := Finset.univ.filter fun b => ∃ a ∈ S, Q a b + have hc : n*S.card = ∑ b, (S.filter fun a => Q a b).card := by + calc + _ = ∑ a ∈ S, (Finset.univ.filter (Q a)).card := by simp [hrow,mul_comm] + _ = _ := by simp only [Finset.card_filter]; rw [Finset.sum_comm] + have hl : ∑ b, (S.filter fun a => Q a b).card ≤ ∑ b, if b ∈ T then n else 0 := by + apply Finset.sum_le_sum + intro b _ + by_cases hb : b ∈ T + · simp only [hb,ite_true] + rw [← hcol b] + exact Finset.card_le_card (Finset.filter_subset_filter _ (Finset.subset_univ _)) + · have hnone : ∀ a ∈ S, ¬Q a b := by simpa [T] using hb + simp [hb,Finset.filter_false_of_mem hnone] + have hr : (∑ b, if b ∈ T then n else 0) = n*T.card := by simp [mul_comm] + rw [hr,← hc] at hl + exact Nat.le_of_mul_le_mul_left hl hn + +lemma regular_matching (Q : A → B → Prop) (hcard : Fintype.card A = Fintype.card B) + (n : ℕ) (hn : 0 < n) + (hrow : ∀ a, (Finset.univ.filter (Q a)).card = n) + (hcol : ∀ b, (Finset.univ.filter fun a => Q a b).card = n) : + ∃ f : A ≃ B, ∀ a, Q a (f a) := by + obtain ⟨f,hfi,hf⟩ := (Fintype.all_card_le_filter_rel_iff_exists_injective Q).mp + (regular_hall Q n hn hrow hcol) + exact ⟨Equiv.ofBijective f ((Fintype.bijective_iff_injective_and_card f).mpr ⟨hfi,hcard⟩),hf⟩ + +theorem two_matchings (R : A → B → Prop) (hcard : Fintype.card A = Fintype.card B) + (hcap : ∀ S : Finset A, 2*S.card ≤ ∑ b, min 2 ((S.filter fun a => R a b).card)) : + ∃ f g : A ≃ B, (∀ a, R a (f a) ∧ R a (g a)) ∧ (∀ a, f a ≠ g a) := by + classical + obtain ⟨p,hp⟩ := gadget_matching R hcard hcap + obtain ⟨M⟩ := data_of_gadget R p hp + obtain ⟨Q,hQR,hrow,hcol⟩ := data_two_factor R M + obtain ⟨f,hf⟩ := regular_matching Q hcard 2 (by decide) hrow hcol + let Q' : A → B → Prop := fun a b => Q a b ∧ b ≠ f a + have hr : ∀ a, (Finset.univ.filter (Q' a)).card = 1 := by + intro a + have he : Finset.univ.filter (Q' a) = (Finset.univ.filter (Q a)).erase (f a) := by + ext b; simp [Q',and_comm] + rw [he,Finset.card_erase_of_mem (by simp [hf a]),hrow] + have hc : ∀ b, (Finset.univ.filter fun a => Q' a b).card = 1 := by + intro b + have he : (Finset.univ.filter fun a => Q' a b) = + (Finset.univ.filter fun a => Q a b).erase (f.symm b) := by + ext a + simp only [Q',Finset.mem_filter,Finset.mem_univ,true_and,Finset.mem_erase] + constructor + · rintro ⟨hq,hne⟩ + exact ⟨fun he => hne (by rw [he,f.apply_symm_apply]),hq⟩ + · rintro ⟨hne,hq⟩ + exact ⟨hq,fun he => hne (f.injective (by simpa using he.symm))⟩ + rw [he,Finset.card_erase_of_mem (by simpa using hf (f.symm b)),hcol] + obtain ⟨g,hg⟩ := regular_matching Q' hcard 1 (by decide) (by simpa only [Q'] using hr) (by simpa only [Q'] using hc) + exact ⟨f,g,fun a => ⟨hQR _ _ (hf a),hQR _ _ (hg a).1⟩,fun a h => (hg a).2 h.symm⟩ + +end +end Barnette.BMatching +namespace Barnette.TriangleSystem.State +variable {A V : Type*} {T : TriangleSystem A V} {X : Set V} +lemma exists_value (r : A ≃ X) (hr : ∀ t, (r t : V) ∈ Set.range (T.vertex t)) : + ∃ s : T.State X, ∀ t, s.value t = (r t : V) := by + choose c hc using hr + refine ⟨⟨c,?_,?_⟩,hc⟩ + · intro t u h + exact r.injective (Subtype.ext (by simpa only [hc] using h)) + · ext v + constructor + · rintro ⟨t,rfl⟩ + change T.vertex t (c t) ∈ X + rw [hc]; exact (r t).property + · intro hv + obtain ⟨t,ht⟩ := r.surjective ⟨v,hv⟩ + exact ⟨t,(hc t).trans (congrArg Subtype.val ht)⟩ +end Barnette.TriangleSystem.State + +namespace Barnette.Network.ColoredDual +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + {N : Network V E} {D : Network F E} (M : N.ColoredDual D) + +lemma nonroots_card (root : V) (hr : M.black root) : + Fintype.card (M.nonroots root) = Fintype.card (M.Black root) := by + have hf := N.black_dual_card D M.duality M.simple M.cubic M.black M.coloring + have hc : Fintype.card (Set.range (M.face root).corner) = 3 := by + rw [← Fintype.card_congr (Equiv.ofInjective _ (M.face root).corner_injective)] + rfl + have hn := Fintype.card_compl_set (Set.range (M.face root).corner) + have hb : Fintype.card (M.Black root) = (Finset.univ.filter M.black).card - 1 := by + rw [Fintype.card_subtype] + have he : (Finset.univ.filter fun v => M.black v ∧ v ≠ root) = + (Finset.univ.filter M.black).erase root := by ext; simp [and_comm] + rw [he,Finset.card_erase_of_mem (by simp [hr])] + have hnx : Fintype.card (M.nonroots root) = + Fintype.card F - Fintype.card (Set.range (M.face root).corner) := by + convert hn using 1 + congr! + rw [hnx,hc,hb,hf] + omega + +omit [Fintype F] in +lemma corner_filter_card (root : V) (S : Finset (M.nonroots root)) (t : M.Black root) : + (S.filter fun x => x.val ∈ Set.range (M.face t.val).corner).card = + (Finset.univ.filter fun i => (M.face t.val).corner i ∈ S.image Subtype.val).card := by + have he : (S.filter fun x => x.val ∈ Set.range (M.face t.val).corner).image Subtype.val = + (Finset.univ.filter fun i => (M.face t.val).corner i ∈ S.image Subtype.val).image + (M.face t.val).corner := by + ext z + simp only [Finset.mem_image,Finset.mem_filter,Finset.mem_univ,true_and,Set.mem_range] + constructor + · rintro ⟨x,⟨hx,i,hi⟩,rfl⟩ + exact ⟨i,⟨x,hx,hi.symm⟩,hi⟩ + · rintro ⟨i,⟨x,hx,hxi⟩,hi⟩ + exact ⟨x,⟨hx,i,hxi.symm⟩,hxi.trans hi⟩ + have hh := congrArg Finset.card he + rwa [Finset.card_image_of_injective _ Subtype.val_injective, + Finset.card_image_of_injective _ (M.face t.val).corner_injective] at hh + +lemma state_capacity (hcut : N.ThreeEdgeConnected) (htr : N.TrivialThreeCuts) + (root : V) (hr : M.black root) (S : Finset (M.nonroots root)) : + 2*S.card ≤ ∑ t : M.Black root, + min 2 ((S.filter fun x => x.val ∈ Set.range (M.face t.val).corner).card) := by + let U := S.image Subtype.val + have hu : ∀ i, (M.face root).corner i ∉ U := by + intro i hi + obtain ⟨x,_,hx⟩ := Finset.mem_image.mp hi + exact x.property ⟨i,hx.symm⟩ + have hcap := N.capacity_full D M.duality M.simple M.cubic hcut htr M.face M.black + M.coloring root hr U hu + rw [Finset.card_image_of_injective _ Subtype.val_injective] at hcap + have hz : min 2 ((Finset.univ.filter fun i => (M.face root).corner i ∈ U).card) = 0 := by + have hh : (Finset.univ.filter fun i => (M.face root).corner i ∈ U) = ∅ := by + ext i; simp [hu] + rw [hh]; simp + have he : (∑ v ∈ Finset.univ.filter M.black, + min 2 ((Finset.univ.filter fun i => (M.face v).corner i ∈ U).card)) = + ∑ t : M.Black root, min 2 ((Finset.univ.filter fun i => (M.face t.val).corner i ∈ U).card) := by + rw [← Finset.sum_erase_add _ _ (show root ∈ Finset.univ.filter M.black by simp [hr]),hz,add_zero] + apply Finset.sum_subtype + intro v; simp [and_comm] + rw [he] at hcap + simpa only [M.corner_filter_card root S] using hcap + +theorem pair_nonempty (hcut : N.ThreeEdgeConnected) (htr : N.TrivialThreeCuts) + (root : V) (hr : M.black root) : Nonempty ((M.system root).Pair (M.nonroots root)) := by + obtain ⟨f,g,hfg,hne⟩ := Barnette.BMatching.two_matchings + (fun (x : M.nonroots root) (t : M.Black root) => x.val ∈ Set.range (M.face t.val).corner) + (M.nonroots_card root hr) (by + intro S + convert M.state_capacity hcut htr root hr S using 1; congr!) + have hf : ∀ t : M.Black root, (f.symm t : F) ∈ Set.range ((M.system root).vertex t) := by + intro t + have h := (hfg (f.symm t)).1 + rw [f.apply_symm_apply] at h + exact h + have hg : ∀ t : M.Black root, (g.symm t : F) ∈ Set.range ((M.system root).vertex t) := by + intro t + have h := (hfg (g.symm t)).2 + rw [g.apply_symm_apply] at h + exact h + obtain ⟨r,hrv⟩ := Barnette.TriangleSystem.State.exists_value f.symm hf + obtain ⟨s,hsv⟩ := Barnette.TriangleSystem.State.exists_value g.symm hg + refine ⟨⟨(r,s),?_⟩⟩ + intro t he + rw [hrv,hsv] at he + have hh : f.symm t = g.symm t := Subtype.ext he + apply hne (f.symm t) + rw [f.apply_symm_apply,hh,g.apply_symm_apply] + +end +end Barnette.Network.ColoredDual + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Bonds.lean b/lean/OAI/Combinatorics/Hamiltonian/Bonds.lean new file mode 100644 index 0000000000000000000000000000000000000000..d468b14aa291dadcd456928933a659c45b3c8bbf --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Bonds.lean @@ -0,0 +1,305 @@ +import OAI.Combinatorics.Hamiltonian.FlowCircuits + +namespace OAI + +/-! Cycle flows, minimal cuts, and connected shores. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] + (N : Network V E) (C : Barnette.CycleCoordinates N.graph) + +omit [Fintype V] [Fintype E] in +def arcSign (e : E) (v : V) : ℝ := if N.tail e = v then 1 else -1 + +omit [Fintype V] [Fintype E] in +lemma arcSign_ne_zero (e : E) (v : V) : N.arcSign e v ≠ 0 := by + simp only [arcSign]; split_ifs <;> norm_num + +omit [Fintype V] in +lemma boundary_directed_unit {e : E} {v w : V} (hne : v ≠ w) + (he : s(N.tail e,N.head e) = s(v,w)) : + N.boundary (N.arcSign e v • basisVec e) = + fun z => (if z = w then 1 else 0) - (if z = v then 1 else 0) := by + rw [map_smul, N.boundary_basis] + ext z + rcases Sym2.eq_iff.mp he with ⟨ht,hh⟩ | ⟨ht,hh⟩ + · simp only [Pi.smul_apply, smul_eq_mul, incidence, arcSign, ht, hh, ite_true, one_mul] + congr 1 <;> simp only [eq_comm] + · have htv : N.tail e ≠ v := by rw [ht]; exact hne.symm + simp only [Pi.smul_apply, smul_eq_mul] + rw [arcSign, ite_eq_right htv] + simp only [incidence, ht, hh, neg_one_mul, neg_sub] + congr 1 <;> simp only [eq_comm] + +omit [Fintype V] [Fintype E] in +def cycleFlow : E → ℝ := + ∑ i, N.arcSign (N.cycleEdge C i) (C.vertex i) • basisVec (N.cycleEdge C i) + +omit [Fintype V] in +lemma cycleFlow_conserved : N.boundary (N.cycleFlow C) = 0 := by + rw [cycleFlow,map_sum] + have hi (i : Fin (C.n+3)) : + N.boundary (N.arcSign (N.cycleEdge C i) (C.vertex i) • basisVec (N.cycleEdge C i)) = + fun z => (if z = C.vertex (i+1) then 1 else 0) - (if z = C.vertex i then 1 else 0) := + N.boundary_directed_unit (C.adjacent i).ne (N.cycleEdge_ends C i) + simp_rw [hi] + ext z + simp only [Finset.sum_apply, Pi.zero_apply, Finset.sum_sub_distrib] + apply sub_eq_zero.mpr + exact Equiv.sum_comp (Equiv.addRight (1 : Fin (C.n+3))) (fun i => if z = C.vertex i then (1:ℝ) else 0) + +omit [Fintype V] [Fintype E] in +lemma cycleFlow_apply_edge (i : Fin (C.n+3)) : + N.cycleFlow C (N.cycleEdge C i) = N.arcSign (N.cycleEdge C i) (C.vertex i) := by + simp only [cycleFlow, Finset.sum_apply, Pi.smul_apply, smul_eq_mul, basisVec] + rw [Finset.sum_eq_single i] + · simp + · intro j _ hji + have hne : N.cycleEdge C i ≠ N.cycleEdge C j := fun h => hji ((N.cycleEdge_injective C h).symm) + simp [hne] + · simp + +omit [Fintype V] [Fintype E] in +lemma cycleFlow_zero_outside {e : E} (he : e ∉ N.cycleEdges C) : N.cycleFlow C e = 0 := by + have hi : ∀ i, e ≠ N.cycleEdge C i := by + intro i h + apply he + exact (N.mem_cycleEdges C e).mpr ⟨i,h.symm⟩ + simp only [cycleFlow, Finset.sum_apply, Pi.smul_apply, smul_eq_mul, basisVec, hi, + ite_false, mul_zero, Finset.sum_const_zero] + +omit [Fintype V] in +lemma cycleFlow_support : N.flowSupport (N.cycleFlow C) = N.cycleEdges C := by + ext e + constructor + · intro he + by_contra hn + exact (N.mem_flowSupport _ _).mp he (N.cycleFlow_zero_outside C hn) + · intro he + obtain ⟨i,rfl⟩ := (N.mem_cycleEdges C e).mp he + rw [mem_flowSupport, N.cycleFlow_apply_edge] + exact N.arcSign_ne_zero _ _ + +omit [Fintype V] in +lemma cycleFlow_circuit (hN : N.Simple) : N.FlowCircuit (N.cycleFlow C) := + N.flowCircuit_of_cycle C hN _ (N.cycleFlow_conserved C) (N.cycleFlow_support C) + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] [Fintype F] in +lemma support_cut (A : Finset V) : + D.flowSupport (N.gradient (fun v => if v ∈ A then 1 else 0)) = N.cut A := by + ext e + simp only [mem_flowSupport,mem_cut,gradient_apply] + by_cases ht : N.tail e ∈ A <;> by_cases hh : N.head e ∈ A <;> simp [ht,hh] + +structure Bond (A : Finset V) : Prop where + nonempty : (N.cut A).Nonempty + minimal : ∀ B, N.cut B ⊆ N.cut A → N.cut B = ∅ ∨ N.cut B = N.cut A + +omit [Fintype V] [Fintype F] in +lemma Duality.bond_of_circuit (h : N.Duality D) (x : E → ℝ) (hx : D.FlowCircuit x) + (A : Finset V) (hA : N.cut A = D.flowSupport x) : N.Bond A := by + refine ⟨?_,?_⟩ + · rw [hA] + apply Finset.nonempty_iff_ne_empty.mpr + exact fun he => hx.nonzero ((D.flowSupport_eq_empty_iff x).mp he) + · intro B hB + let y := N.gradient (fun v => if v ∈ B then 1 else 0) + have hy : D.flowSupport y = N.cut B := N.support_cut D B + have hys : D.flowSupport y ⊆ D.flowSupport x := by rwa [hy,← hA] + rcases hx.minimal y (h.dual_conserved_gradient N D _) hys with hzero | heq + · left + rw [← hy] + exact (D.flowSupport_eq_empty_iff y).mpr hzero + · right + rwa [hy,← hA] at heq + +omit [Fintype V] in +lemma cuts_equal_subset (h : N.graph.Connected) {A B : Finset V} (hBA : B ⊆ A) + (hout : ∃ v, v ∉ A) (hc : N.cut B = N.cut A) : B = A := by + let f : V → ℝ := fun v => (if v ∈ A then 1 else 0) - (if v ∈ B then 1 else 0) + have hf : N.gradient f = 0 := by + ext e + have he := Finset.ext_iff.mp hc e + simp only [mem_cut] at he + have ht := hBA (x := N.tail e) + have hh := hBA (x := N.head e) + dsimp only [gradient_apply,f,Pi.zero_apply] + by_cases hta : N.tail e ∈ A <;> by_cases hha : N.head e ∈ A <;> + by_cases htb : N.tail e ∈ B <;> by_cases hhb : N.head e ∈ B <;> + simp_all + obtain ⟨r,hr⟩ := hout + have hrB : r ∉ B := fun h => hr (hBA h) + apply Finset.Subset.antisymm hBA + intro v hv + have hh := N.gradient_zero_reachable hf (h r v) + by_contra hvB + norm_num [f,hr,hrB,hv,hvB] at hh + +omit [Fintype V] in +lemma cut_nonempty (h : N.graph.Connected) (A : Finset V) (hin : A.Nonempty) + (hout : ∃ v, v ∉ A) : (N.cut A).Nonempty := by + by_contra hc + have hc' : N.cut A = ∅ := Finset.not_nonempty_iff_eq_empty.mp hc + have hf : N.gradient (fun v => if v ∈ A then (1:ℝ) else 0) = 0 := by + apply (N.flowSupport_eq_empty_iff _).mp + rwa [N.support_cut N A] + obtain ⟨v,hv⟩ := hin + obtain ⟨w,hw⟩ := hout + have hh := N.gradient_zero_reachable hf (h v w) + norm_num [hv,hw] at hh + +omit [Fintype V] in + +lemma Bond.connected_shore (h : N.graph.Connected) {A : Finset V} (hA : N.Bond A) + (hin : A.Nonempty) (hout : ∃ v, v ∉ A) : + (N.graph.induce {v | v ∈ A}).Connected := by + obtain ⟨a,ha⟩ := hin + let H := N.graph.induce {v | v ∈ A} + let B := A.filter fun v => ∃ hv : v ∈ A, H.Reachable ⟨a,ha⟩ ⟨v,hv⟩ + have hBA : B ⊆ A := Finset.filter_subset _ _ + have haB : a ∈ B := Finset.mem_filter.mpr ⟨ha,ha,SimpleGraph.Reachable.refl _⟩ + have hsub : N.cut B ⊆ N.cut A := by + intro e he + have step {v w : V} (hv : v ∈ B) (hw : w ∈ A) (hvw : N.graph.Adj v w) : w ∈ B := by + obtain ⟨hvA,hvR⟩ := Finset.mem_filter.mp hv + obtain ⟨hv',hp⟩ := hvR + exact Finset.mem_filter.mpr ⟨hw,hw,hp.trans (show H.Adj ⟨v,hv'⟩ ⟨w,hw⟩ from hvw).reachable⟩ + rcases (N.mem_cut B e).mp he with ⟨ht,hh⟩ | ⟨hh,ht⟩ + · apply (N.mem_cut A e).mpr + refine Or.inl ⟨hBA ht,?_⟩ + intro hha + have hne : N.tail e ≠ N.head e := fun heq => hh (heq ▸ ht) + exact hh (step ht hha ⟨hne,e,Or.inl ⟨rfl,rfl⟩⟩) + · apply (N.mem_cut A e).mpr + refine Or.inr ⟨hBA hh,?_⟩ + intro hta + have hne : N.head e ≠ N.tail e := fun heq => ht (heq ▸ hh) + exact ht (step hh hta ⟨hne,e,Or.inr ⟨rfl,rfl⟩⟩) + have hBout : ∃ v, v ∉ B := by + obtain ⟨r,hr⟩ := hout + exact ⟨r,fun h => hr (hBA h)⟩ + have hc := (hA.minimal B hsub).resolve_left (N.cut_nonempty h B ⟨a,haB⟩ hBout).ne_empty + have hEq := N.cuts_equal_subset h hBA hout hc + apply (SimpleGraph.connected_iff_exists_forall_reachable H).mpr + refine ⟨⟨a,ha⟩,?_⟩ + intro v + have hvB : v.val ∈ B := by rw [hEq]; exact v.property + obtain ⟨_,hv,hp⟩ := Finset.mem_filter.mp hvB + exact hp + +lemma Bond.compl {A : Finset V} (hA : N.Bond A) : N.Bond Aᶜ where + nonempty := by simpa only [cut_compl] using hA.nonempty + minimal B hB := by + rw [cut_compl] at hB ⊢ + exact hA.minimal B hB + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype E] [Fintype F] in +lemma Triangle.corner_iff_incident {s : Finset E} (t : D.Triangle s) (v : F) : + v ∈ Set.range t.corner ↔ ∃ e ∈ s, D.Incident e v := by + constructor + · rintro ⟨i,rfl⟩ + refine ⟨t.edge i,?_,?_⟩ + · have hm : t.edge i ∈ Finset.univ.image t.edge := Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩ + rwa [t.edge_range] at hm + · rw [D.incident_iff_mem_pair,t.edge_ends]; simp + · rintro ⟨e,he,hv⟩ + rw [← t.edge_range] at he + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he + rw [D.incident_iff_mem_pair,t.edge_ends,Sym2.mem_iff] at hv + rcases hv with rfl | rfl + · exact ⟨i,rfl⟩ + · exact ⟨i+1,rfl⟩ + +omit [Fintype E] [Fintype F] in +lemma Triangle.clique {s : Finset E} (t : D.Triangle s) {i j : Fin 3} (hij : i ≠ j) : + D.graph.Adj (t.corner i) (t.corner j) := by + have hne : t.corner i ≠ t.corner j := fun h => hij (t.corner_injective h) + have hfin : ∀ i j : Fin 3, i ≠ j → j = i+1 ∨ i = j+1 := by decide + have h := hfin i j hij + rcases h with rfl | rfl + · exact ⟨hne,t.edge i,Sym2.eq_iff.mp (t.edge_ends i)⟩ + · exact ⟨hne,t.edge j,(Sym2.eq_iff.mp (t.edge_ends j)).symm⟩ + +omit [Fintype E] [Fintype F] in +lemma Triangle.corner_avoiding {s : Finset E} (t : D.Triangle s) (z : F) : + ∃ w, w ∈ Set.range t.corner ∧ w ≠ z := by + by_cases h : t.corner 0 = z + · refine ⟨t.corner 1,⟨1,rfl⟩,?_⟩ + intro hh + have hi := t.corner_injective (h.trans hh.symm) + norm_num at hi + · exact ⟨t.corner 0,⟨0,rfl⟩,h⟩ + +omit [Fintype E] [Fintype F] in +lemma Triangle.reachable_avoiding {s : Finset E} (t : D.Triangle s) (z : F) + {v w : F} (hv : v ∈ Set.range t.corner) (hw : w ∈ Set.range t.corner) + (hvz : v ≠ z) (hwz : w ≠ z) : + (D.graph.induce {v | v ≠ z}).Reachable ⟨v,hvz⟩ ⟨w,hwz⟩ := by + obtain ⟨i,rfl⟩ := hv + obtain ⟨j,rfl⟩ := hw + by_cases hij : i = j + · subst j; exact SimpleGraph.Reachable.refl _ + · exact (show (D.graph.induce {v | v ≠ z}).Adj ⟨t.corner i,hvz⟩ ⟨t.corner j,hwz⟩ from + t.clique D hij).reachable + +omit [Fintype V] [Fintype F] in + +theorem faces_vertex_deleted_connected (hN : N.graph.Connected) (hD : D.graph.Connected) + (sD : D.Simple) (face : ∀ v, D.Triangle (N.star v)) (z : F) : + (D.graph.induce {v | v ≠ z}).Connected := by + obtain ⟨v₀⟩ := hN.nonempty + let : Nontrivial F := ⟨⟨(face v₀).corner 0,(face v₀).corner 1,by + intro he; have hi := (face v₀).corner_injective he; norm_num at hi⟩⟩ + let H := D.graph.induce {v | v ≠ z} + choose anchor ha hz using fun v => (face v).corner_avoiding D z + let a (v : V) : {w : F | w ≠ z} := ⟨anchor v,hz v⟩ + have in_face (v : V) (e : E) (he : N.Incident e v) (w : F) (hw : D.Incident e w) : + w ∈ Set.range (face v).corner := + ((face v).corner_iff_incident D w).mpr ⟨e,(N.mem_star e v).mpr he,hw⟩ + have step {v w : V} (hvw : N.graph.Adj v w) : H.Reachable (a v) (a w) := by + obtain ⟨_,e,he⟩ := hvw + have hv : N.Incident e v := he.elim (fun h => Or.inl h.1) (fun h => Or.inr h.2) + have hw : N.Incident e w := he.elim (fun h => Or.inr h.2) (fun h => Or.inl h.1) + obtain ⟨u,hu,huz⟩ : ∃ u, D.Incident e u ∧ u ≠ z := by + by_cases ht : D.tail e = z + · exact ⟨D.head e,Or.inr rfl,fun hh => sD.loopless e (ht.trans hh.symm)⟩ + · exact ⟨D.tail e,Or.inl rfl,ht⟩ + have p := (face v).reachable_avoiding D z (ha v) (in_face v e hv u hu) (hz v) huz + have q := (face w).reachable_avoiding D z (in_face w e hw u hu) (ha w) huz (hz w) + exact p.trans q + have all_faces {v w : V} : H.Reachable (a v) (a w) := by + obtain ⟨p⟩ := hN v w + induction p with + | nil => exact SimpleGraph.Reachable.refl _ + | cons hvw p ih => exact (step hvw).trans ih + apply (SimpleGraph.connected_iff_exists_forall_reachable H).mpr + refine ⟨a v₀,?_⟩ + intro w + obtain ⟨u,hu⟩ := hD.preconnected.exists_adj_of_nontrivial w.val + obtain ⟨_,e,he⟩ := hu + have hw : D.Incident e w.val := he.elim (fun he => Or.inl he.1) (fun he => Or.inr he.2) + have hf := in_face (N.tail e) e (Or.inl rfl) w.val hw + exact all_faces.trans ((face (N.tail e)).reachable_avoiding D z (ha _) hf (hz _) w.property) + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/BranchPartition.lean b/lean/OAI/Combinatorics/Hamiltonian/BranchPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..2071312982a04fe1b15454fcd29d8672b0cec20e --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/BranchPartition.lean @@ -0,0 +1,123 @@ +import OAI.Combinatorics.Hamiltonian.MinorModel + +namespace OAI + +/-! Extending disjoint connected branches to a connected vertex partition. -/ + +namespace Barnette +noncomputable section +open scoped Classical + +namespace BranchPartition +variable {V W : Type*} [Fintype V] [Fintype W] [Nonempty V] + (H : SimpleGraph W) + +omit [Fintype W] in +lemma walk_crosses_boundary {S : Set W} {v w : W} (p : H.Walk v w) + (hv : v ∈ S) (hw : w ∉ S) : + ∃ a ∈ S, ∃ b ∉ S, H.Adj a b := by + induction p with + | nil => exact (hw hv).elim + | @cons u z w h p ih => + by_cases hz : z ∈ S + · exact ih hz hw + · exact ⟨u, hv, z, hz, h⟩ + +theorem extend (hH : H.Connected) (B₀ : V → Set W) + (hB₀ : ∀ v, (H.induce (B₀ v)).Connected) + (hd₀ : ∀ v w, v ≠ w → Disjoint (B₀ v) (B₀ w)) : + ∃ B : V → Set W, + (∀ v, B₀ v ⊆ B v) ∧ + (∀ v, (H.induce (B v)).Connected) ∧ + (∀ v w, v ≠ w → Disjoint (B v) (B w)) ∧ + (∀ w, ∃ v, w ∈ B v) := by + let S : Set (V → Set W) := {B | (∀ v, B₀ v ⊆ B v) ∧ + (∀ v, (H.induce (B v)).Connected) ∧ + (∀ v w, v ≠ w → Disjoint (B v) (B w))} + let size (B : V → Set W) := (⋃ v, B v).ncard + have hS : S.Nonempty := ⟨B₀, fun _ => Set.Subset.rfl, hB₀, hd₀⟩ + obtain ⟨B, hB, hmax⟩ := S.exists_max_image size (Set.toFinite _) hS + refine ⟨B, hB.1, hB.2.1, hB.2.2, ?_⟩ + intro w + by_contra hw + have hwU : w ∉ ⋃ v, B v := by simpa only [Set.mem_iUnion] using hw + obtain ⟨v₀⟩ := ‹Nonempty V› + obtain ⟨a₀⟩ := (hB.2.1 v₀).nonempty + obtain ⟨p⟩ := hH a₀.val w + obtain ⟨a, ha, b, hb, hab⟩ := walk_crosses_boundary H p + (Set.mem_iUnion.mpr ⟨v₀, a₀.property⟩) hwU + obtain ⟨v, hv⟩ := Set.mem_iUnion.mp ha + let B' : V → Set W := fun z => if z = v then insert b (B v) else B z + have hle : ∀ z, B z ⊆ B' z := by + intro z x hx + by_cases hz : z = v + · subst z; simp only [B', ite_true]; exact Set.mem_insert_of_mem _ hx + · simpa only [B', hz, ite_false] using hx + have hB' : B' ∈ S := by + refine ⟨fun z => (hB.1 z).trans (hle z), ?_, ?_⟩ + · intro z + by_cases hz : z = v + · subst z + have hsingle : (H.induce ({b} : Set W)).Preconnected := by + intro x y + have he : x = y := Subsingleton.elim _ _ + subst y + exact .rfl + have hh := SimpleGraph.connected_induce_union (hB.2.1 v).preconnected hsingle + hv (show b ∈ ({b} : Set W) by simp) hab + rw [show B' v = insert b (B v) by simp [B']] + rw [Set.union_singleton] at hh + exact hh + · rw [show B' z = B z by simp [B', hz]] + exact hB.2.1 z + · intro z t hzt + rw [Set.disjoint_left] + intro x hxz hxt + by_cases hz : z = v + · subst z + have ht : t ≠ v := Ne.symm hzt + simp only [B', ite_true, Set.mem_insert_iff] at hxz + rw [show B' t = B t by simp only [B', ht, ite_false]] at hxt + rcases hxz with rfl | hxz + · exact hb (Set.mem_iUnion.mpr ⟨t, hxt⟩) + · exact Set.disjoint_left.mp (hB.2.2 v t hzt) hxz hxt + · rw [show B' z = B z by simp only [B', hz, ite_false]] at hxz + by_cases ht : t = v + · subst t + simp only [B', ite_true, Set.mem_insert_iff] at hxt + rcases hxt with rfl | hxt + · exact hb (Set.mem_iUnion.mpr ⟨z, hxz⟩) + · exact Set.disjoint_left.mp (hB.2.2 z v hzt) hxz hxt + · rw [show B' t = B t by simp only [B', ht, ite_false]] at hxt + exact Set.disjoint_left.mp (hB.2.2 z t hzt) hxz hxt + have hstrict : (⋃ z, B z) ⊂ ⋃ z, B' z := by + refine ⟨Set.iUnion_mono hle, ?_⟩ + intro hh + apply hb (hh ?_) + exact Set.mem_iUnion.mpr ⟨v, by simp [B']⟩ + exact (not_lt_of_ge (hmax B' hB')) (Set.ncard_lt_ncard hstrict) + +omit [Fintype V] [Fintype W] [Nonempty V] in + +theorem quotient (B : V → Set W) + (hB : ∀ v, (H.induce (B v)).Connected) + (hd : ∀ v w, v ≠ w → Disjoint (B v) (B w)) + (hcover : ∀ w, ∃ v, w ∈ B v) : + ∃ q : W → V, Function.Surjective q ∧ (∀ w v, q w = v ↔ w ∈ B v) := by + choose q hq using hcover + have he (w : W) (v : V) : q w = v ↔ w ∈ B v := by + constructor + · intro hv; exact hv ▸ hq w + · intro hw + by_contra hne + exact Set.disjoint_left.mp (hd (q w) v hne) (hq w) hw + refine ⟨q, ?_, he⟩ + intro v + obtain ⟨w⟩ := (hB v).nonempty + exact ⟨w.val, (he w.val v).mpr w.property⟩ + +end BranchPartition +end +end Barnette + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/CappedDuality.lean b/lean/OAI/Combinatorics/Hamiltonian/CappedDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f7b2f11c6577485318d5bef8b94dd9c8916dfa4 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/CappedDuality.lean @@ -0,0 +1,251 @@ +import OAI.Combinatorics.Hamiltonian.ThreeCuts + +namespace OAI + +/-! Exact duals of capped graphs and Hamiltonian walks in degree-two graphs. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +universe uF +variable {V E W K : Type*} {F : Type uF} [Fintype V] [Fintype E] [Fintype F] + [Fintype W] [Fintype K] + +omit [Fintype E] in +lemma push_pull_injective {j : K → E} (hj : Function.Injective j) (x : E → ℝ) : + push j (pull j x) = fun e => if e ∈ Set.range j then x e else 0 := by + ext e + by_cases he : e ∈ Set.range j + · obtain ⟨k, rfl⟩ := he + have h := congrFun (pull_push_injective hj (pull j x)) k + simpa only [pull_apply, Set.mem_range_self, ite_true] using h + · rw [push_eq_zero_outside _ he] + simp only [he, ite_false] + +omit [Fintype K] in +lemma pull_push_disjoint {j : K → E} (r : Set E) + (hr : ∀ k, j k ∉ r) (x : r → ℝ) : + pull j (push (Subtype.val : r → E) x) = 0 := by + ext k + exact push_eq_zero_outside x (by simpa using hr k) + +lemma split_support {j : K → E} (hj : Function.Injective j) (r : Set E) + (hr : ∀ k, j k ∉ r) (x : E → ℝ) + (hx : ∀ e, e ∉ r → e ∉ Set.range j → x e = 0) : + x = push j (pull j x) + push (Subtype.val : r → E) (pull Subtype.val x) := by + rw [push_pull_injective hj, push_pull_subtype] + ext e + by_cases he : e ∈ r + · have hj' : e ∉ Set.range j := by + rintro ⟨k, rfl⟩ + exact hr k he + simp only [Pi.add_apply, he, hj', ite_true, ite_false, zero_add] + · by_cases hj' : e ∈ Set.range j + · simp only [Pi.add_apply, he, hj', ite_true, ite_false, add_zero] + · simp only [Pi.add_apply, he, hj', ite_false, hx e he hj', zero_add] + +lemma push_boundary_on_internal (N : Network V E) (q : V → W) (r : Set E) + (hr : r ⊆ N.internal q) (x : r → ℝ) : + push q ((N.restrict Subtype.val).boundary x) = 0 := by + apply eq_of_dot_eq + intro f + rw [push_adjoint, (N.restrict _).boundary_adjoint] + simp only [Pi.zero_apply, zero_mul, Finset.sum_const_zero] + apply Finset.sum_eq_zero + intro e _ + have he : (N.restrict (Subtype.val : r → E)).gradient (pull q f) e = 0 := by + change f (q (N.head e.val)) - f (q (N.tail e.val)) = 0 + rw [show q (N.tail e.val) = q (N.head e.val) from hr e.property] + exact sub_self _ + rw [he, mul_zero] + +theorem Duality.minor (N : Network V E) (D : Network F E) (h : N.Duality D) + (q : V → W) (hq : Function.Surjective q) (hc : N.ConnectedFibers q) + (j : K → E) (hj : Function.Injective j) + (hjext : ∀ k, q (N.tail (j k)) ≠ q (N.head (j k))) + (hM : ((N.mapVertices q).restrict j).graph.Connected) : + ∃ (L : Type uF) (_ : Fintype L) (dual : Network L K), + ((N.mapVertices q).restrict j).Duality dual := by + obtain ⟨r, hr, hir, her⟩ := N.exists_independent_restriction (N.internal q) + have hrj : ∀ k, j k ∉ r := fun k hk => hjext k (hr hk) + let d : Set E := {e | e ∉ r ∧ e ∉ Set.range j} + let H := D.restrict (Subtype.val : d → E) + let qD := H.componentMap + let L := (D.mapVertices qD).restrict j + let M := (N.mapVertices q).restrict j + have hqD : Function.Surjective qD := H.componentMap_surjective + have zeroD (f : H.Components → ℝ) (e : E) (he : e ∈ d) : + D.gradient (pull qD f) e = 0 := congrFun (H.gradient_componentMap f) ⟨e, he⟩ + have orth (f : F → ℝ) : N.boundary (D.gradient f) = 0 := by + change D.gradient f ∈ N.boundary.ker + rw [h.cycles_eq_cuts] + exact ⟨f, rfl⟩ + have hle : L.gradient.range ≤ M.boundary.ker := by + rintro _ ⟨f, rfl⟩ + have hs := split_support hj r hrj (D.gradient (pull qD f)) + (fun e he hej => zeroD f e ⟨he, hej⟩) + have hz := congrArg (push q) (orth (pull qD f)) + rw [hs, map_add, map_add, map_zero, + ← boundary_restrict, ← boundary_restrict, + push_boundary_on_internal N q r hr, add_zero] at hz + change M.boundary (L.gradient f) = 0 + rw [boundary_restrict, boundary_mapVertices] + simpa only [boundary_restrict, L, gradient_restrict, gradient_mapVertices] using hz + have hge : M.boundary.ker ≤ L.gradient.range := by + intro x hx + have hz : push q (N.boundary (push j x)) = 0 := by + have he : M.boundary x = 0 := hx + simpa only [M, boundary_restrict, boundary_mapVertices] using he + have hy : N.boundary (push j x) ∈ (N.restrict (Subtype.val : r → E)).boundary.range := by + rw [her, N.range_internal_boundary hq hc] + exact hz + obtain ⟨y, hy⟩ := hy + let z := push j x - push (Subtype.val : r → E) y + have hzb : N.boundary z = 0 := by + rw [map_sub, ← N.boundary_restrict (Subtype.val : r → E) y, hy, sub_self] + have hzg : z ∈ D.gradient.range := by rw [← h.cycles_eq_cuts]; exact hzb + obtain ⟨g, hg⟩ := hzg + have hgH : H.gradient g = 0 := by + ext e + change D.gradient g e.val = 0 + rw [hg] + have he : e.val ∉ Set.range (Subtype.val : r → E) := by simpa using e.property.1 + simp only [z, Pi.sub_apply, push_eq_zero_outside x e.property.2, + push_eq_zero_outside y he, sub_self] + obtain ⟨f, hf⟩ := H.descends_components g hgH + refine ⟨f, ?_⟩ + change pull j (D.gradient (pull qD f)) = x + rw [hf, hg, map_sub, pull_push_injective hj, pull_push_disjoint r hrj, sub_zero] + have hLc : L.graph.Connected := by + have : Nonempty F := h.dual_connected.nonempty + have : Nonempty H.Components := Nonempty.map qD inferInstance + apply L.connected_of_kernel_constants + intro f hf a b + have hs := split_support hj r hrj (D.gradient (pull qD f)) + (fun e he hej => zeroD f e ⟨he, hej⟩) + have hjzero : pull j (D.gradient (pull qD f)) = 0 := hf + rw [hjzero, map_zero, zero_add] at hs + have hz := orth (pull qD f) + rw [hs, ← boundary_restrict] at hz + have hrzero : pull (Subtype.val : r → E) (D.gradient (pull qD f)) = 0 := by + apply hir + simpa only [map_zero] using hz + rw [hrzero, map_zero] at hs + obtain ⟨a', rfl⟩ := hqD a + obtain ⟨b', rfl⟩ := hqD b + exact D.gradient_zero_reachable hs (h.dual_connected a' b') + exact ⟨H.Components, inferInstance, L, M.duality_of_first_exact L hM hLc (le_antisymm hge hle)⟩ + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +universe uF +variable {V E : Type*} {F : Type uF} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +lemma cap_duality (h : N.Duality D) (hN : N.Simple) (h3 : N.ThreeEdgeConnected) + (A : Finset V) (hcut : (N.cut A).card = 3) (ha : A.Nonempty) (ho : Aᶜ.Nonempty) : + ∃ (L : Type uF) (_ : Fintype L) (dual : Network L (N.regionEdges A)), (N.cap A).Duality dual := by + have hshore : (N.graph.induce {v | v ∉ A}).Connected := by + have hh := (N.threeCut_bond h3 A hcut).compl.connected_shore N h.connected ho + (by obtain ⟨v,hv⟩ := ha; exact ⟨v,by simpa only [Finset.mem_compl,not_not] using hv⟩) + change (N.graph.induce {v | v ∈ Aᶜ}).Connected at hh + have heq : {v | v ∈ Aᶜ} = {v | v ∉ A} := by ext v; simp + rw [heq] at hh + exact hh + exact h.minor N D (N.capMap A) (N.capMap_surjective A ho) + (N.cap_connectedFibers A hshore) Subtype.val Subtype.val_injective + (N.cap_loopless hN A) ((N.cap_threeConnected h3 A ho).connected (N.cap A)) + +lemma cap_card_lt (A : Finset V) (ho : 2 ≤ Aᶜ.card) : Fintype.card (Option A) < Fintype.card V := by + simp only [Fintype.card_option,Fintype.card_coe] + have hh := Finset.card_add_card_compl A + omega + +lemma nontrivial_threeCut (h : ¬N.TrivialThreeCuts) : + ∃ A : Finset V, (N.cut A).card = 3 ∧ 2 ≤ A.card ∧ 2 ≤ Aᶜ.card := by + unfold TrivialThreeCuts at h + push Not at h + obtain ⟨A,hcut,ha,ho⟩ := h + have he : (N.cut A).Nonempty := Finset.card_pos.mp (by omega) + obtain ⟨e,he⟩ := he + have hh := (N.mem_cut A e).mp he + have hi : A.Nonempty := hh.elim (fun h => ⟨_,h.1⟩) (fun h => ⟨_,h.1⟩) + have hout : Aᶜ.Nonempty := hh.elim (fun h => ⟨_,Finset.mem_compl.mpr h.2⟩) (fun h => ⟨_,Finset.mem_compl.mpr h.2⟩) + have hi' := Finset.card_pos.mpr hi + have ho' := Finset.card_pos.mpr hout + exact ⟨A,hcut,by omega,by omega⟩ +end +end Barnette.Network +namespace Barnette.SimpleCycle +noncomputable section +open scoped Classical +variable {V : Type*} [Fintype V] (G : SimpleGraph V) + +lemma cycle_at_of_connected_two [DecidableEq V] (hc : G.Connected) (hd : G.IsRegularOfDegree 2) (v : V) : + ∃ p : G.Walk v v, p.IsHamiltonianCycle := by + have hi : G.IsCycles := by + intro w _ + rw [← Set.fintypeCard_eq_ncard, SimpleGraph.card_neighborSet_eq_degree] + exact hd w + have hn : (G.neighborSet v).Nonempty := by + apply Set.nonempty_of_ncard_ne_zero + have hh : (G.neighborSet v).ncard = 2 := by + rw [← Set.fintypeCard_eq_ncard, SimpleGraph.card_neighborSet_eq_degree] + exact hd v + omega + obtain ⟨p,hp,hs⟩ := hi.exists_cycle_toSubgraph_verts_eq_connectedComponentSupp + (c := G.connectedComponentMk v) rfl hn + refine ⟨p,hp,hp.isPath_tail.isHamiltonian_of_mem ?_⟩ + intro w + by_cases hw : w = v + · subst w + exact p.tail.end_mem_support + · have hm : w ∈ p.support := by + rw [← p.mem_verts_toSubgraph, hs] + exact SimpleGraph.ConnectedComponent.eq.mpr (hc w v) + rw [← p.cons_support_tail hp.not_nil] at hm + exact (List.mem_cons.mp hm).resolve_left hw + +omit [Fintype V] in +lemma induced_support_connected {a b : V} (p : G.Walk a b) (s : Set V) + (hs : ∀ v, v ∈ s ↔ v ∈ p.support) : (G.induce s).Connected := by + have hw : ∀ v ∈ p.support, v ∈ s := fun v hv => (hs v).mpr hv + let q := p.induce s hw + have hq (v : s) : v ∈ q.support := by + simp only [q, SimpleGraph.Walk.support_induce, List.mem_attachWith] + exact (hs v).mp v.property + let : Nonempty s := ⟨⟨a,hw a p.start_mem_support⟩⟩ + exact ⟨fun x y => ((q.takeUntil x (hq x)).reverse.append (q.takeUntil y (hq y))).reachable⟩ + +lemma delete_vertex_connected (hc : G.Connected) (hd : G.IsRegularOfDegree 2) (v : V) : + (G.induce {w | w ≠ v}).Connected := by + obtain ⟨p,hp⟩ := cycle_at_of_connected_two G hc hd v + have hn : ¬p.tail.Nil := by + intro hh + have hl := hp.isCycle.three_le_length + have ht := SimpleGraph.Walk.length_eq_zero_iff.mpr hh + simp only [SimpleGraph.Walk.length_tail] at ht + omega + have heq := p.tail.support_dropLast_concat hn + have hnmem : v ∉ p.tail.dropLast.support := by + have hnd := hp.isHamiltonian_tail.isPath.support_nodup + rw [← heq] at hnd + intro hm + exact (List.nodup_append.mp hnd).2.2 v hm v (by simp) rfl + apply induced_support_connected G p.tail.dropLast + intro w + constructor + · intro hw + have hm := hp.isHamiltonian_tail.mem_support w + rw [←heq, List.mem_append, List.mem_singleton] at hm + exact hm.resolve_right hw + · intro hw h + subst w + exact hnmem hw +end +end Barnette.SimpleCycle + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Circulation.lean b/lean/OAI/Combinatorics/Hamiltonian/Circulation.lean new file mode 100644 index 0000000000000000000000000000000000000000..241dbd629bb5560801a33a8367889c22f085029b --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Circulation.lean @@ -0,0 +1,253 @@ +import OAI.Combinatorics.Hamiltonian.StateDisk + +namespace OAI + +/-! Oriented triangular faces and positive white-face charges. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] in + +lemma FlowCircuit.proportional (x : E → ℝ) (hx : N.FlowCircuit x) + (y : E → ℝ) (hy : N.boundary y = 0) + (hs : N.flowSupport y ⊆ N.flowSupport x) : ∃ c : ℝ, y = c • x := by + obtain ⟨e,he⟩ : ∃ e, x e ≠ 0 := by + by_contra hn + apply hx.nonzero + ext e + exact not_not.mp (fun he => hn ⟨e,he⟩) + let c := y e / x e + let z := y - c • x + have hz : N.boundary z = 0 := by simp [z,map_sub,map_smul,hy,hx.conserved] + have hzs : N.flowSupport z ⊆ N.flowSupport x := by + intro k hk + by_contra hn + have hxk : x k = 0 := not_not.mp (by simpa only [mem_flowSupport] using hn) + have hyk : y k = 0 := by + by_contra hyk + exact hn (hs ((N.mem_flowSupport y k).mpr hyk)) + exact (N.mem_flowSupport z k).mp hk (by simp [z,hxk,hyk]) + have hze : z e = 0 := by simp [z,c,div_mul_cancel₀ _ he] + have hz0 : z = 0 := (hx.minimal z hz hzs).resolve_right (by + intro hh + have hem : e ∈ N.flowSupport z := hh ▸ (N.mem_flowSupport x e).mpr he + exact (N.mem_flowSupport z e).mp hem hze) + exact ⟨c,sub_eq_zero.mp hz0⟩ + +omit [Fintype V] [Fintype E] [Fintype F] in +def Triangle.coordinates {s : Finset E} (t : D.Triangle s) : Barnette.CycleCoordinates D.graph where + n := 0 + vertex := ⟨t.corner,t.corner_injective⟩ + adjacent i := t.clique D (by + intro hh + have h1 : (1 : Fin 3) = 0 := add_left_cancel (by simpa using hh.symm : i+1=i+0) + norm_num at h1) + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma Triangle.coordinates_edge (sD : D.Simple) {s : Finset E} (t : D.Triangle s) (i : Fin 3) : + D.cycleEdge (t.coordinates D) i = t.edge i := by + apply sD.pair_injective + exact (D.cycleEdge_ends (t.coordinates D) i).trans (t.edge_ends i).symm + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma Triangle.coordinates_edges (sD : D.Simple) {s : Finset E} (t : D.Triangle s) : + D.cycleEdges (t.coordinates D) = s := by + have hf : D.cycleEdge (t.coordinates D) = t.edge := funext (t.coordinates_edge D sD) + change Finset.univ.image (D.cycleEdge (t.coordinates D)) = s + rw [hf] + exact t.edge_range + +omit [Fintype V] [Fintype E] [Fintype F] in +def Triangle.reverse {s : Finset E} (t : D.Triangle s) : D.Triangle s where + corner i := t.corner (-i) + corner_injective := t.corner_injective.comp neg_injective + edge i := t.edge (-i-1) + edge_injective := t.edge_injective.comp (by + intro i j hh + apply neg_injective + simpa only [sub_add_cancel] using congrArg (fun k : Fin 3 => k+1) hh) + edge_range := by + have hh : Finset.univ.image (fun i : Fin 3 => t.edge (-i-1)) = Finset.univ.image t.edge := by + ext e + simp only [Finset.mem_image,Finset.mem_univ,true_and] + constructor + · rintro ⟨i,rfl⟩; exact ⟨-i-1,rfl⟩ + · rintro ⟨i,rfl⟩ + refine ⟨-i-1,?_⟩ + congr 1 + abel + exact hh.trans t.edge_range + edge_ends i := by + rw [t.edge_ends] + have h1 : -i-1+1 = -i := sub_add_cancel _ _ + have h2 : -(i+1) = -i-1 := by abel + rw [h1,h2,Sym2.eq_swap] + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma arcSign_opposite {e : E} {v w : F} + (hne : v ≠ w) (he : s(D.tail e,D.head e) = s(v,w)) : + D.arcSign e w = - D.arcSign e v := by + rcases Sym2.eq_iff.mp he with ⟨ht,hh⟩ | ⟨ht,hh⟩ + · simp [arcSign,ht,hne] + · simp [arcSign,ht,hne.symm] + +omit [Fintype V] [Fintype F] in + +theorem oriented_face (h : N.Duality D) (sN : N.Simple) (sD : D.Simple) + (v : V) (t : D.Triangle (N.star v)) : + ∃ u : D.Triangle (N.star v), ∀ i, + N.gradient (fun w => if w = v then 1 else 0) (u.edge i) = + D.arcSign (u.edge i) (u.corner i) := by + let x := D.cycleFlow (t.coordinates D) + let y := N.gradient (fun w => if w = v then 1 else 0) + have hx := D.cycleFlow_circuit (t.coordinates D) sD + have hy := h.dual_conserved_gradient N D (fun w => if w = v then 1 else 0) + have hs : D.flowSupport y = D.flowSupport x := by + rw [D.cycleFlow_support,t.coordinates_edges D sD] + exact N.gradient_indicator_support D sN v + obtain ⟨c,hc⟩ := hx.proportional D x y hy hs.subset + have hxi (i : Fin 3) : x (t.edge i) = D.arcSign (t.edge i) (t.corner i) := by + have hh := D.cycleFlow_apply_edge (t.coordinates D) i + change x (D.cycleEdge (t.coordinates D) i) = D.arcSign (D.cycleEdge (t.coordinates D) i) (t.corner i) at hh + rw [t.coordinates_edge D sD i] at hh + exact hh + have hci (i : Fin 3) : y (t.edge i) = c * D.arcSign (t.edge i) (t.corner i) := by + rw [hc,Pi.smul_apply,smul_eq_mul,hxi] + have he : t.edge 0 ∈ N.star v := by + have hh : t.edge 0 ∈ Finset.univ.image t.edge := Finset.mem_image.mpr ⟨0,Finset.mem_univ _,rfl⟩ + rwa [t.edge_range] at hh + have hcv : c = 1 ∨ c = -1 := by + have hh := hci 0 + have hne := sN.loopless (t.edge 0) + rcases (N.mem_star _ _).mp he with ht | hh' + · have hhead : N.head (t.edge 0) ≠ v := fun h => hne (ht.trans h.symm) + simp only [y,gradient_apply,ht,hhead,ite_true,ite_false,zero_sub] at hh + by_cases hd : D.tail (t.edge 0) = t.corner 0 <;> simp [arcSign,hd] at hh <;> first | exact Or.inl (by linarith) | exact Or.inr (by linarith) + · have htail : N.tail (t.edge 0) ≠ v := fun h => hne (h.trans hh'.symm) + simp only [y,gradient_apply,hh',htail,ite_true,ite_false,sub_zero] at hh + by_cases hd : D.tail (t.edge 0) = t.corner 0 <;> simp [arcSign,hd] at hh <;> first | exact Or.inl (by linarith) | exact Or.inr (by linarith) + rcases hcv with rfl | rfl + · exact ⟨t,fun i => by simpa only [one_mul] using hci i⟩ + · refine ⟨t.reverse D,?_⟩ + intro i + change y (t.edge (-i-1)) = D.arcSign (t.edge (-i-1)) (t.corner (-i)) + have hh := hci (-i-1) + have ha := D.arcSign_opposite ((t.coordinates D).adjacent (-i-1 : Fin 3)).ne (t.edge_ends (-i-1)) + change D.arcSign (t.edge (-i-1)) (t.corner (-i-1+1)) = + - D.arcSign (t.edge (-i-1)) (t.corner (-i-1)) at ha + rw [sub_add_cancel] at ha + rw [ha] + simpa only [neg_one_mul] using hh + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +lemma boundary_of_sum_zero (h : N.graph.Connected) (b : V → ℝ) + (hb : ∑ v, b v = 0) : ∃ x, N.boundary x = b := by + let q : V → Unit := fun _ => () + have hq : Function.Surjective q := by + obtain ⟨v⟩ := h.nonempty + intro u + exact ⟨v,Subsingleton.elim _ _⟩ + have hg : (N.restrict (Subtype.val : N.internal q → E)).graph = N.graph := by + ext v w + constructor + · rintro ⟨hne,e,he⟩ + exact ⟨hne,e.val,he⟩ + · rintro ⟨hne,e,he⟩ + exact ⟨hne,⟨e,rfl⟩,he⟩ + have hc : N.ConnectedFibers q := by + intro v w _ + rw [hg] + exact h v w + have hz : push q b = 0 := by + ext u + cases u + simpa [push,q] using hb + have hm : b ∈ (N.restrict (Subtype.val : N.internal q → E)).boundary.range := by + rw [N.range_internal_boundary hq hc] + exact hz + obtain ⟨x,hx⟩ := hm + refine ⟨push (Subtype.val : N.internal q → E) x,?_⟩ + rw [← boundary_restrict,hx] + +def whiteCharge (black : V → Prop) (root : V) : V → ℝ := fun v => + (if black v then 0 else 1) - + (if v = root then ((Finset.univ.filter fun w => ¬black w).card : ℝ) else 0) + +lemma whiteCharge_sum (black : V → Prop) (root : V) : + ∑ v, whiteCharge black root v = 0 := by + simp only [whiteCharge,Finset.sum_sub_distrib,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rw [show (fun v => if black v then (0:ℝ) else 1) = + (fun v => if ¬black v then 1 else 0) by ext v; by_cases hv : black v <;> simp [hv]] + rw [Finset.sum_boole,sub_self] + +lemma whiteCharge_black (black : V → Prop) (root v : V) + (hv : black v) (hvr : v ≠ root) : whiteCharge black root v = 0 := by + simp [whiteCharge,hv,hvr] + +lemma whiteCharge_inside (black : V → Prop) (root : V) (A : Finset V) + (hr : root ∉ A) : + ∑ v ∈ A, whiteCharge black root v = ((A.filter fun v => ¬black v).card : ℝ) := by + trans ∑ v ∈ A, if ¬black v then (1:ℝ) else 0 + · apply Finset.sum_congr rfl + intro v hv + have hvr : v ≠ root := fun hh => hr (hh ▸ hv) + by_cases hb : black v <;> simp [whiteCharge,hb,hvr] + · exact Finset.sum_boole _ _ + +lemma whiteCharge_cut_integral (black : V → Prop) (root : V) (A : Finset V) + (hr : root ∉ A) (α : E → ℝ) (hα : N.boundary α = whiteCharge black root) + (c : ℝ) (x : E → ℝ) + (hx : x = c • N.gradient (fun v => if v ∈ A then 1 else 0)) : + ∑ e, α e * x e = c * ((A.filter fun v => ¬black v).card : ℝ) := by + simp only [hx,Pi.smul_apply,smul_eq_mul] + have hh : ∑ e, α e * (c * N.gradient (fun v => if v ∈ A then 1 else 0) e) = + c * ∑ e, α e * N.gradient (fun v => if v ∈ A then 1 else 0) e := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro e _ + ring + rw [hh,← N.boundary_adjoint,hα] + congr 1 + simp only [mul_ite,mul_one,mul_zero] + rw [← Finset.sum_filter] + simpa only [Finset.filter_mem_eq_inter,Finset.univ_inter] using whiteCharge_inside black root A hr + +omit [Fintype V] [Fintype F] in +lemma white_positive_of_boundary (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (A : Finset V) + (hcount : (N.cut A).card = 2 * (N.blackCut black A).card + 3) : + 0 < (A.filter fun v => ¬black v).card := by + by_contra hn + have hz : (A.filter fun v => ¬black v) = ∅ := Finset.card_eq_zero.mp (by omega) + have hb : ∀ v ∈ A, black v := by + intro v hv + by_contra hnv + have hh : v ∈ A.filter (fun v => ¬black v) := Finset.mem_filter.mpr ⟨hv,hnv⟩ + rw [hz] at hh + exact Finset.notMem_empty _ hh + have hEq : N.blackCut black A = N.cut A := by + apply Finset.filter_eq_self.mpr + intro e he + rcases (N.mem_cut A e).mp he with ht | hh + · rw [N.blackEndpoint_eq black hc (hb _ ht.1) (Or.inl rfl)] + exact ht.1 + · rw [N.blackEndpoint_eq black hc (hb _ hh.1) (Or.inr rfl)] + exact hh.1 + rw [hEq] at hcount + omega + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/ColoredDual.lean b/lean/OAI/Combinatorics/Hamiltonian/ColoredDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..f77b4e93b857e041fb9589a12eb3c6de5f449b7a --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/ColoredDual.lean @@ -0,0 +1,209 @@ +import OAI.Combinatorics.Hamiltonian.TriangleSystem + +namespace OAI + +/-! Colored dual networks and signed directed state cycles. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +structure ColoredDual where + duality : N.Duality D + simple : N.Simple + dual_simple : D.Simple + cubic : N.graph.IsRegularOfDegree 3 + black : V → Prop + coloring : ∀ e, black (N.tail e) ↔ ¬black (N.head e) + face : ∀ v, D.Triangle (N.star v) + oriented : ∀ v i, N.gradient (fun w => if w = v then 1 else 0) ((face v).edge i) = + D.arcSign ((face v).edge i) ((face v).corner i) + +namespace ColoredDual +variable {N D} (M : N.ColoredDual D) + +abbrev Black (root : V) := {v : V // M.black v ∧ v ≠ root} + +def system (root : V) : Barnette.TriangleSystem (M.Black root) F where + vertex t := (M.face t.val).corner + vertex_injective t := (M.face t.val).corner_injective + edge_unique t u i j k l hij hkl hik hjl := by + have he : (M.face t.val).side D i j = (M.face u.val).side D k l := by + apply M.dual_simple.pair_injective + dsimp only + rw [(M.face t.val).side_ends D hij,(M.face u.val).side_ends D hkl,hik,hjl] + have ht := N.blackEndpoint_eq M.black M.coloring t.property.1 + ((N.mem_star _ _).mp ((M.face t.val).side_mem D i j)) + have hu := N.blackEndpoint_eq M.black M.coloring u.property.1 + ((N.mem_star _ _).mp ((M.face u.val).side_mem D k l)) + apply Subtype.ext + exact ht.symm.trans (he ▸ hu) + +def nonroots (root : V) : Set F := (Set.range (M.face root).corner)ᶜ + +abbrev State (root : V) := (M.system root).State (M.nonroots root) + +def assignment {root : V} (s : M.State root) (v : V) : F := + if hv : M.black v ∧ v ≠ root then s.value ⟨v,hv⟩ else (M.face root).corner 0 + +omit [Fintype F] in +@[simp] lemma assignment_apply {root : V} (s : M.State root) (v : M.Black root) : + M.assignment s v.val = s.value v := by simp [assignment,v.property] + +omit [Fintype F] in +lemma assignment_inj {root : V} (s : M.State root) : + Set.InjOn (M.assignment s) {v | M.black v ∧ v ≠ root} := by + intro v hv w hw h + have hh : s.value ⟨v,hv⟩ = s.value ⟨w,hw⟩ := + (M.assignment_apply s ⟨v,hv⟩).symm.trans (h.trans (M.assignment_apply s ⟨w,hw⟩)) + exact congrArg Subtype.val (s.value_injective hh) + +omit [Fintype F] in +lemma assignment_face {root : V} (s : M.State root) (v : V) + (hv : M.black v) (hr : v ≠ root) : + M.assignment s v ∈ Set.range (M.face v).corner := by + rw [M.assignment_apply s ⟨v,hv,hr⟩] + exact ⟨s.val ⟨v,hv,hr⟩,rfl⟩ + +omit [Fintype F] in +lemma assignment_range {root : V} (s : M.State root) (z : F) : + z ∉ Set.range (M.face root).corner ↔ + ∃ v, M.black v ∧ v ≠ root ∧ M.assignment s v = z := by + constructor + · intro hz + have hm : z ∈ M.nonroots root := hz + obtain ⟨t,ht⟩ := (Set.ext_iff.mp s.value_range z).mpr hm + exact ⟨t.val,t.property.1,t.property.2,(M.assignment_apply s t).trans ht⟩ + · rintro ⟨v,hv,hr,rfl⟩ + rw [M.assignment_apply s ⟨v,hv,hr⟩] + exact s.value_mem ⟨v,hv,hr⟩ + +lemma cycle_disk {root : V} (s : M.State root) + (C : Barnette.CycleCoordinates D.graph) + (t : Fin (C.n+3) → M.Black root) + (he : ∀ i, D.cycleEdge C i ∈ N.star (t i).val) + (hv : ∀ i, s.value (t i) = C.vertex i) : + ∃ (A : Finset V) (c : ℝ), A.Nonempty ∧ root ∉ A ∧ (c = 1 ∨ c = -1) ∧ + D.cycleFlow C = c • N.gradient (fun v => if v ∈ A then 1 else 0) ∧ + N.cut A = D.cycleEdges C ∧ + (N.cut A).card = 2 * (N.blackCut M.black A).card + 3 ∧ + N.blackDelta D M.black C = -3*c := by + apply N.state_disk_delta D M.duality M.simple M.cubic M.dual_simple M.face + M.black M.coloring root (M.assignment s) (M.assignment_inj s) + (M.assignment_face s) (M.assignment_range s) C + intro i + have hb := N.blackEndpoint_eq M.black M.coloring (t i).property.1 + ((N.mem_star _ _).mp (he i)) + rw [hb] + exact ⟨(t i).property.2,(M.assignment_apply s (t i)).trans (hv i)⟩ + +def weights (α : E → ℝ) (root : V) (t : M.Black root) : Fin 3 → ℝ := + (M.face t.val).potential D α + +omit [Fintype F] in +lemma weights_diff (root : V) (α : E → ℝ) + (hα : N.boundary α = whiteCharge M.black root) + (t : M.Black root) {i j : Fin 3} (hij : i ≠ j) : + M.weights α root t j - M.weights α root t i = + α ((M.face t.val).side D i j) * + D.arcSign ((M.face t.val).side D i j) ((M.face t.val).corner i) := by + apply (M.face t.val).potential_side D α _ hij + rw [(M.face t.val).oriented_integral N D M.simple M.dual_simple t.val + (M.oriented t.val) α,hα] + exact whiteCharge_black M.black root t.val t.property.1 t.property.2 + +end ColoredDual +end +end Barnette.Network +namespace Barnette.Network.ColoredDual +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + {N : Network V E} {D : Network F E} (M : N.ColoredDual D) + +structure StateCycle {root : V} (s : M.State root) where + cycle : Barnette.CycleCoordinates D.graph + face : Fin (cycle.n+3) → M.Black root + corner : Fin (cycle.n+3) → Fin 3 + left_eq : ∀ i, s.value (face i) = cycle.vertex i + right_eq : ∀ i, (M.face (face i).val).corner (corner i) = cycle.vertex (i+1) + +namespace StateCycle +variable {M} {root : V} {s : M.State root} (C : M.StateCycle s) + +omit [Fintype F] in +lemma corner_ne (i : Fin (C.cycle.n+3)) : s.val (C.face i) ≠ C.corner i := by + intro hh + have hv : C.cycle.vertex i = C.cycle.vertex (i+1) := + (C.left_eq i).symm.trans ((congrArg (M.face (C.face i).val).corner hh).trans (C.right_eq i)) + exact (C.cycle.adjacent i).1 hv + +omit [Fintype F] in +lemma cycleEdge_eq (i : Fin (C.cycle.n+3)) : + D.cycleEdge C.cycle i = (M.face (C.face i).val).side D (s.val (C.face i)) (C.corner i) := by + apply (M.face (C.face i).val).side_unique D M.dual_simple (C.corner_ne i) + rw [D.cycleEdge_ends,C.right_eq] + change s(C.cycle.vertex i,C.cycle.vertex (i+1)) = + s(s.value (C.face i),C.cycle.vertex (i+1)) + rw [C.left_eq] + +omit [Fintype F] in +lemma edge_mem (i : Fin (C.cycle.n+3)) : D.cycleEdge C.cycle i ∈ N.star (C.face i).val := by + rw [C.cycleEdge_eq] + exact (M.face (C.face i).val).side_mem D _ _ + +def delta : ℤ := ∑ i, Barnette.TriangleSystem.indexDelta (s.val (C.face i)) (C.corner i) + +def slope (α : E → ℝ) : ℝ := + ∑ i, (M.weights α root (C.face i) (C.corner i) - M.weights α root (C.face i) (s.val (C.face i))) + +omit [Fintype F] in +lemma delta_eq : (C.delta : ℝ) = N.blackDelta D M.black C.cycle := by + simp only [delta,Int.cast_sum,blackDelta] + apply Finset.sum_congr rfl + intro i _ + rw [(M.face (C.face i).val).index_delta N D (C.face i).val (M.oriented _) + M.black M.coloring (C.face i).property.1 (C.corner_ne i),← C.cycleEdge_eq] + change _ * D.arcSign _ (s.value (C.face i)) = _ + rw [C.left_eq] + +omit [Fintype F] in +lemma slope_eq (α : E → ℝ) (hα : N.boundary α = whiteCharge M.black root) : + C.slope α = ∑ e, α e * D.cycleFlow C.cycle e := by + rw [D.cycle_integral] + unfold slope + apply Finset.sum_congr rfl + intro i _ + rw [M.weights_diff root α hα (C.face i) (C.corner_ne i),← C.cycleEdge_eq] + change _ * D.arcSign _ (s.value (C.face i)) = _ + rw [C.left_eq] + +theorem signed (α : E → ℝ) (hα : N.boundary α = whiteCharge M.black root) : + (C.delta = -3 ∧ 0 < C.slope α) ∨ (C.delta = 3 ∧ C.slope α < 0) := by + obtain ⟨A,c,_ha,hr,hc,hflow,_hcut,hcount,hd⟩ := + M.cycle_disk s C.cycle C.face C.edge_mem C.left_eq + have hδ : (C.delta : ℝ) = -3*c := C.delta_eq.trans hd + have hs : C.slope α = c * ((A.filter fun v => ¬M.black v).card : ℝ) := by + rw [C.slope_eq α hα] + exact N.whiteCharge_cut_integral M.black root A hr α hα c _ hflow + have hpos : (0:ℝ) < (A.filter fun v => ¬M.black v).card := by + exact_mod_cast N.white_positive_of_boundary M.black M.coloring A hcount + rcases hc with rfl | rfl + · left + constructor + · have hh : (C.delta : ℝ) = (-3:ℝ) := by simpa using hδ + exact_mod_cast hh + · simpa [hs] using hpos + · right + constructor + · have hh : (C.delta : ℝ) = (3:ℝ) := by simpa using hδ + exact_mod_cast hh + · simpa [hs] using neg_neg_of_pos hpos + +end StateCycle +end +end Barnette.Network.ColoredDual + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Contraction.lean b/lean/OAI/Combinatorics/Hamiltonian/Contraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..b46c3b43dae3fa1b31e9274625f205b6dfe765d8 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Contraction.lean @@ -0,0 +1,429 @@ +import OAI.Combinatorics.Hamiltonian.Forest + +namespace OAI + +/-! Contraction and deletion of finite oriented dual networks. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +def inducedEdges (U : Finset F) : Finset E := + Finset.univ.filter fun e => D.tail e ∈ U ∧ D.head e ∈ U + +omit [Fintype F] in +@[simp] lemma mem_inducedEdges (U : Finset F) (e : E) : + e ∈ D.inducedEdges U ↔ D.tail e ∈ U ∧ D.head e ∈ U := by + simp [inducedEdges] + +def inducedNetwork (U : Finset F) : Network U (D.inducedEdges U) where + tail e := ⟨D.tail e.val,((D.mem_inducedEdges U e.val).mp e.property).1⟩ + head e := ⟨D.head e.val,((D.mem_inducedEdges U e.val).mp e.property).2⟩ + +omit [Fintype F] in +lemma inducedNetwork_map (U : Finset F) : + (D.inducedNetwork U).mapVertices Subtype.val = + D.restrict (Subtype.val : D.inducedEdges U → E) := rfl + +lemma inducedNetwork_boundary (U : Finset F) (x : D.inducedEdges U → ℝ) : + push (Subtype.val : U → F) ((D.inducedNetwork U).boundary x) = + D.boundary (push Subtype.val x) := by + rw [← boundary_mapVertices,D.inducedNetwork_map,boundary_restrict] + +def regions (U : Finset F) : Network V {e // e ∉ D.inducedEdges U} := + N.restrict Subtype.val + +abbrev Regions (U : Finset F) := (N.regions D U).Components + +def regionQuotient (U : Finset F) : Network (N.Regions D U) (D.inducedEdges U) := + (N.mapVertices (N.regions D U).componentMap).restrict Subtype.val + +omit [Fintype V] [Fintype F] in +lemma regionQuotient_connected (hN : N.graph.Connected) (U : Finset F) : + (N.regionQuotient D U).graph.Connected := by + let H := N.regions D U + let q := H.componentMap + let L := N.regionQuotient D U + have : Nonempty V := hN.nonempty + have : Nonempty H.Components := Nonempty.map q inferInstance + apply L.connected_of_kernel_constants + intro f hf a b + obtain ⟨a',rfl⟩ := H.componentMap_surjective a + obtain ⟨b',rfl⟩ := H.componentMap_surjective b + apply N.gradient_zero_reachable (f := pull q f) _ (hN a' b') + ext e + by_cases he : e ∈ D.inducedEdges U + · exact congrFun hf ⟨e,he⟩ + · exact congrFun (H.gradient_componentMap f) ⟨e,he⟩ + +omit [Fintype V] in + +lemma induced_cycles_eq_regions (h : N.Duality D) (U : Finset F) : + (D.inducedNetwork U).boundary.ker = (N.regionQuotient D U).gradient.range := by + let H := N.regions D U + let q := H.componentMap + ext x + constructor + · intro hx + have hx' : (D.inducedNetwork U).boundary x = 0 := hx + have hz : D.boundary (push (Subtype.val : D.inducedEdges U → E) x) = 0 := by + rw [← D.inducedNetwork_boundary,hx',map_zero] + obtain ⟨g,hg⟩ : ∃ g, N.gradient g = push (Subtype.val : D.inducedEdges U → E) x := by + have hh : push (Subtype.val : D.inducedEdges U → E) x ∈ D.boundary.ker := hz + rw [h.dual_cycles_eq_cuts] at hh + exact hh + have hgH : H.gradient g = 0 := by + ext e + change N.gradient g e.val = 0 + rw [hg] + exact push_eq_zero_outside x (by simpa using e.property) + obtain ⟨f,hf⟩ := H.descends_components g hgH + refine ⟨f,?_⟩ + change pull (Subtype.val : D.inducedEdges U → E) (N.gradient (pull q f)) = x + rw [hf,hg,pull_push_injective Subtype.val_injective] + · rintro ⟨f,rfl⟩ + have hext : push (Subtype.val : D.inducedEdges U → E) + ((N.regionQuotient D U).gradient f) = N.gradient (pull q f) := by + ext e + by_cases he : e ∈ D.inducedEdges U + · exact push_subtype_apply (D.inducedEdges U) _ ⟨e,he⟩ + · rw [push_eq_zero_outside _ (by simpa using he)] + exact (congrFun (H.gradient_componentMap f) ⟨e,he⟩).symm + have hz : push (Subtype.val : U → F) + ((D.inducedNetwork U).boundary ((N.regionQuotient D U).gradient f)) = 0 := by + rw [D.inducedNetwork_boundary,hext] + exact h.dual_conserved_gradient N D _ + have hz' := congrArg (pull (Subtype.val : U → F)) hz + rw [pull_push_injective Subtype.val_injective,map_zero] at hz' + exact hz' + +omit [Fintype F] in +lemma rank_boundary_le [Nonempty V] : + Module.finrank ℝ N.boundary.range + 1 ≤ Fintype.card V := by + have hle : (constant (V := V)).range ≤ N.gradient.ker := by + rintro _ ⟨c,rfl⟩ + exact N.gradient_const c + have hi : Function.Injective (constant (V := V)) := by + intro a b hh + exact congrFun hh (Classical.choice inferInstance) + have hk : 1 ≤ Module.finrank ℝ N.gradient.ker := by + have hh := Submodule.finrank_mono hle + rwa [LinearMap.finrank_range_of_inj hi,Module.finrank_self] at hh + have hr : Module.finrank ℝ N.boundary.range = Module.finrank ℝ N.gradient.range := by + rw [N.gradient_matrix,boundary,Matrix.toLin'_apply',Matrix.toLin'_apply', + ← Matrix.rank,← Matrix.rank,Matrix.rank_transpose] + have hh := N.gradient.finrank_range_add_finrank_ker + rw [Module.finrank_pi] at hh + omega + +lemma induced_euler_bound (h : N.Duality D) (U : Finset F) (hU : U.Nonempty) : + (D.inducedEdges U).card + 2 ≤ U.card + Fintype.card (N.Regions D U) := by + have : Nonempty U := by obtain ⟨u,hu⟩ := hU; exact ⟨⟨u,hu⟩⟩ + have hr := (D.inducedNetwork U).rank_boundary_le + have hk := (D.inducedNetwork U).boundary.finrank_range_add_finrank_ker + rw [Module.finrank_pi,Fintype.card_coe] at hk + rw [N.induced_cycles_eq_regions D h U] at hk + have ho := (N.regionQuotient D U).rank_gradient (N.regionQuotient_connected D h.connected U) + simp only [Fintype.card_coe] at hr + omega + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] in +lemma star_count (hN : N.Simple) (v : V) : + (N.star v).card = ∑ e, ((if N.tail e = v then 1 else 0) + + (if N.head e = v then 1 else 0)) := by + rw [star,Finset.card_filter] + apply Finset.sum_congr rfl + intro e _ + have hne := hN.loopless e + by_cases ht : N.tail e = v <;> by_cases hh : N.head e = v <;> simp_all [Incident] + +lemma weighted_stars (hN : N.Simple) (f : V → ℤ) : + ∑ v, f v * (N.star v).card = ∑ e, (f (N.tail e) + f (N.head e)) := by + simp only [N.star_count hN,Nat.cast_sum,Nat.cast_add,Nat.cast_ite,Nat.cast_one, + Nat.cast_zero,Finset.mul_sum,mul_add,mul_ite,mul_one,mul_zero] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + simp [Finset.sum_add_distrib,eq_comm] + +def colorSign (black : V → Prop) (v : V) : ℤ := if black v then 1 else -1 + +omit [Fintype V] [Fintype E] in +lemma colorSign_add (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (e : E) : + colorSign black (N.tail e) + colorSign black (N.head e) = 0 := by + have he := hc e + by_cases ht : black (N.tail e) <;> by_cases hh : black (N.head e) <;> + simp_all [colorSign] + +lemma colorSign_sum (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) : + ∑ v, colorSign black v = 0 := by + have hs := N.weighted_stars hN (colorSign black) + have hv : ∀ v, (N.star v).card = 3 := fun v => (N.card_star hN v).trans (h3 v) + simp only [hv,N.colorSign_add black hc,Finset.sum_const_zero,Nat.cast_ofNat, + ← Finset.sum_mul] at hs + omega + +def regionShore (U : Finset F) (q : N.Regions D U) : Finset V := + Finset.univ.filter fun v => (N.regions D U).componentMap v = q + +omit [Fintype F] in +@[simp] lemma mem_regionShore (U : Finset F) (q : N.Regions D U) (v : V) : + v ∈ N.regionShore D U q ↔ (N.regions D U).componentMap v = q := by + simp [regionShore] + +omit [Fintype F] in +lemma regionShore_nonempty (U : Finset F) (q : N.Regions D U) : + (N.regionShore D U q).Nonempty := by + obtain ⟨v,hv⟩ := (N.regions D U).componentMap_surjective q + exact ⟨v,(N.mem_regionShore D U q v).mpr hv⟩ + +omit [Fintype F] in +lemma regionShore_off_edge (U : Finset F) (q : N.Regions D U) {e : E} + (he : e ∉ D.inducedEdges U) : + N.tail e ∈ N.regionShore D U q ↔ N.head e ∈ N.regionShore D U q := by + simp only [N.mem_regionShore] + have hh : (N.regions D U).componentMap (N.tail e) = + (N.regions D U).componentMap (N.head e) := + SimpleGraph.ConnectedComponent.sound ((N.regions D U).edge_reachable ⟨e,he⟩) + rw [hh] + +def rim (U : Finset F) (q : N.Regions D U) : ℕ := + ∑ e ∈ D.inducedEdges U, ((if N.tail e ∈ N.regionShore D U q then 1 else 0) + + (if N.head e ∈ N.regionShore D U q then 1 else 0)) + +def blackRim (black : V → Prop) (U : Finset F) (q : N.Regions D U) : ℕ := + ∑ e ∈ D.inducedEdges U, ((if N.tail e ∈ N.regionShore D U q ∧ black (N.tail e) then 1 else 0) + + (if N.head e ∈ N.regionShore D U q ∧ black (N.head e) then 1 else 0)) + +def regionBalance (black : V → Prop) (U : Finset F) (q : N.Regions D U) : ℤ := + ∑ v ∈ N.regionShore D U q, colorSign black v + +omit [Fintype F] in +lemma blackRim_le (black : V → Prop) (U : Finset F) (q : N.Regions D U) : + N.blackRim D black U q ≤ N.rim D U q := by + apply Finset.sum_le_sum + intro e _ + by_cases ht : N.tail e ∈ N.regionShore D U q <;> + by_cases hh : N.head e ∈ N.regionShore D U q <;> + by_cases bt : black (N.tail e) <;> by_cases bh : black (N.head e) <;> simp [ht,hh,bt,bh] + +omit [Fintype F] in +lemma region_balance_rim (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (U : Finset F) (q : N.Regions D U) : + 3 * N.regionBalance D black U q = 2 * (N.blackRim D black U q : ℤ) - N.rim D U q := by + let A := N.regionShore D U q + let f : V → ℤ := fun v => if v ∈ A then colorSign black v else 0 + have hs := N.weighted_stars hN f + have hv : ∀ v, (N.star v).card = 3 := fun v => (N.card_star hN v).trans (h3 v) + have hleft : (∑ v, f v * (N.star v).card) = 3 * N.regionBalance D black U q := by + simp only [hv,Nat.cast_ofNat,← Finset.sum_mul,f] + rw [← Finset.sum_filter] + simp only [Finset.filter_mem_eq_inter,Finset.univ_inter,regionBalance,A,mul_comm] + rw [hleft] at hs + have hreduce : (∑ e, (f (N.tail e) + f (N.head e))) = + ∑ e ∈ D.inducedEdges U, (f (N.tail e) + f (N.head e)) := by + symm + apply Finset.sum_subset (Finset.subset_univ _) + intro e _ he + have heq := N.regionShore_off_edge D U q he + simp only [f,A,heq] + split_ifs + · exact N.colorSign_add black hc e + · rfl + rw [hreduce] at hs + rw [hs] + simp only [blackRim,rim,Nat.cast_sum,Nat.cast_add,Nat.cast_ite,Nat.cast_one, + Nat.cast_zero,Finset.mul_sum,← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro e _ + simp only [f,A,colorSign] + by_cases ht : N.tail e ∈ N.regionShore D U q <;> + by_cases hh : N.head e ∈ N.regionShore D U q <;> + by_cases bt : black (N.tail e) <;> by_cases bh : black (N.head e) <;> norm_num [ht,hh,bt,bh] + +omit [Fintype F] in +lemma sum_rim (U : Finset F) : + ∑ q : N.Regions D U, N.rim D U q = 2 * (D.inducedEdges U).card := by + simp only [rim] + rw [Finset.sum_comm] + simp [N.mem_regionShore,Finset.sum_add_distrib,Nat.mul_comm] + +omit [Fintype F] in +lemma sum_regionBalance (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (U : Finset F) : ∑ q : N.Regions D U, N.regionBalance D black U q = 0 := by + simp only [regionBalance,regionShore,Finset.sum_filter] + rw [Finset.sum_comm] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true] + exact N.colorSign_sum hN h3 black hc + +lemma rim_defect (b d : ℕ) (β : ℤ) (hb : b ≤ d) (hd : 4 ≤ d) + (hβ : 3*β = 2*(b:ℤ) - d) : β ≤ (d:ℤ)-4 := by + by_cases h4 : d = 4 + · subst d; omega + by_cases h5 : d = 5 + · subst d; omega + have h6 : (6:ℤ) ≤ d := by omega + have hbd : (b:ℤ) ≤ d := by exact_mod_cast hb + omega + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +def ThreeEdgeConnected : Prop := ∀ A : Finset V, A.Nonempty → Aᶜ.Nonempty → 3 ≤ (N.cut A).card + +def TrivialThreeCuts : Prop := ∀ A : Finset V, (N.cut A).card = 3 → A.card = 1 ∨ Aᶜ.card = 1 + +omit [Fintype F] in +lemma region_cut_subset (U : Finset F) (q : N.Regions D U) : + N.cut (N.regionShore D U q) ⊆ D.inducedEdges U := by + intro e he + by_contra hn + have hh := N.regionShore_off_edge D U q hn + have hc := (N.mem_cut _ _).mp he + exact hc.elim (fun h => h.2 (hh.mp h.1)) (fun h => h.2 (hh.mpr h.1)) + +omit [Fintype F] in +lemma rim_cut_count (U : Finset F) (q : N.Regions D U) : + N.rim D U q = (N.cut (N.regionShore D U q)).card + + 2 * ((D.inducedEdges U).filter fun e => + N.tail e ∈ N.regionShore D U q ∧ N.head e ∈ N.regionShore D U q).card := by + have hcut : N.cut (N.regionShore D U q) = + (D.inducedEdges U).filter fun e => e ∈ N.cut (N.regionShore D U q) := by + ext e + simp only [Finset.mem_filter] + exact ⟨fun he => ⟨N.region_cut_subset D U q he,he⟩,And.right⟩ + rw [hcut] + simp only [rim,Finset.card_filter,Finset.mul_sum,← Finset.sum_add_distrib,N.mem_cut] + apply Finset.sum_congr rfl + intro e _ + by_cases ht : N.tail e ∈ N.regionShore D U q <;> + by_cases hh : N.head e ∈ N.regionShore D U q <;> simp [ht,hh] + +omit [Fintype F] in +lemma cut_le_rim (U : Finset F) (q : N.Regions D U) : + (N.cut (N.regionShore D U q)).card ≤ N.rim D U q := by + rw [N.rim_cut_count] + omega + +omit [Fintype F] in +lemma rim_of_shore_univ (U : Finset F) (q : N.Regions D U) + (hq : N.regionShore D U q = Finset.univ) : + N.rim D U q = 2 * (D.inducedEdges U).card := by + simp [rim,hq,Nat.mul_comm] + +omit [Fintype F] in +lemma rim_ge_three (hN : N.ThreeEdgeConnected) (U : Finset F) + (hm : 3 ≤ (D.inducedEdges U).card) (q : N.Regions D U) : 3 ≤ N.rim D U q := by + by_cases hq : N.regionShore D U q = Finset.univ + · rw [N.rim_of_shore_univ D U q hq]; omega + · have hA := N.regionShore_nonempty D U q + have hAc : (N.regionShore D U q)ᶜ.Nonempty := by + apply Finset.nonempty_iff_ne_empty.mpr + intro he + exact hq ((Finset.compl_eq_empty_iff _).mp he) + exact (hN _ hA hAc).trans (N.cut_le_rim D U q) + +omit [Fintype F] in +lemma rim_three_cut (hN : N.ThreeEdgeConnected) (U : Finset F) + (_hm : 3 ≤ (D.inducedEdges U).card) (q : N.Regions D U) (hq : N.rim D U q = 3) : + (N.cut (N.regionShore D U q)).card = 3 := by + have hproper : N.regionShore D U q ≠ Finset.univ := by + intro he + have hh := N.rim_of_shore_univ D U q he + omega + have hAc : (N.regionShore D U q)ᶜ.Nonempty := by + apply Finset.nonempty_iff_ne_empty.mpr + intro he + exact hproper ((Finset.compl_eq_empty_iff _).mp he) + have hl := hN _ (N.regionShore_nonempty D U q) hAc + have hu := N.cut_le_rim D U q + omega + +omit [Fintype F] in +lemma rim_three_no_internal (hN : N.ThreeEdgeConnected) (U : Finset F) + (_hm : 3 ≤ (D.inducedEdges U).card) (q : N.Regions D U) (hq : N.rim D U q = 3) + {e : E} (he : e ∈ D.inducedEdges U) : + ¬(N.tail e ∈ N.regionShore D U q ∧ N.head e ∈ N.regionShore D U q) := by + have hc := N.rim_three_cut D hN U _hm q hq + have hh := N.rim_cut_count D U q + have hz : ((D.inducedEdges U).filter fun e => + N.tail e ∈ N.regionShore D U q ∧ N.head e ∈ N.regionShore D U q) = ∅ := + Finset.card_eq_zero.mp (by omega) + intro hi + have hhmem : e ∈ (D.inducedEdges U).filter (fun e => + N.tail e ∈ N.regionShore D U q ∧ N.head e ∈ N.regionShore D U q) := + Finset.mem_filter.mpr ⟨he,hi⟩ + rw [hz] at hhmem + exact Finset.notMem_empty _ hhmem + +omit [Fintype F] in +lemma singleton_region_star (hN : N.Simple) (U : Finset F) (q : N.Regions D U) + {v : V} (hq : N.regionShore D U q = {v}) : N.star v ⊆ D.inducedEdges U := by + intro e he + by_contra hn + have hi := (N.mem_star e v).mp he + have hh := N.regionShore_off_edge D U q hn + rw [hq] at hh + simp only [Finset.mem_singleton] at hh + exact hN.loopless e (hi.elim (fun hv => hv.trans ((hh.mp hv).symm)) + (fun hv => (hh.mpr hv).trans hv.symm)) + +lemma star_subset_eq (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + {v w : V} (hvw : N.star v ⊆ N.star w) : v = w := by + by_contra hne + have hc : 1 < (N.star v).card := by rw [N.card_star hN,h3 v]; decide + obtain ⟨e,he,f,hf,hef⟩ := Finset.one_lt_card.mp hc + have ends {e : E} (he : e ∈ N.star v) : s(N.tail e,N.head e) = s(v,w) := by + have hv := (N.mem_star e v).mp he + have hw := (N.mem_star e w).mp (hvw he) + apply Sym2.eq_iff.mpr + rcases hv with hv | hv <;> rcases hw with hw | hw + · exact (hne (hv.symm.trans hw)).elim + · exact Or.inl ⟨hv,hw⟩ + · exact Or.inr ⟨hw,hv⟩ + · exact (hne (hv.symm.trans hw)).elim + exact hef (hN.pair_injective ((ends he).trans (ends hf).symm)) + +omit [Fintype F] in +lemma complement_singleton_root (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (hcut : N.ThreeEdgeConnected) (U : Finset F) (root : V) + (hr : N.star root ⊆ D.inducedEdges U) (q : N.Regions D U) + (hq : N.rim D U q = 3) {v : V} (hv : (N.regionShore D U q)ᶜ = {v}) : v = root := by + have hm : 3 ≤ (D.inducedEdges U).card := by + have hh := Finset.card_le_card hr + rwa [N.card_star hN,h3 root] at hh + apply (N.star_subset_eq hN h3 (v := root) (w := v) ?_).symm + intro e he + have hn := N.rim_three_no_internal D hcut U hm q hq (hr he) + rw [N.mem_star] + have ht : N.tail e ∉ N.regionShore D U q ↔ N.tail e = v := by + rw [← Finset.mem_compl,hv,Finset.mem_singleton] + have hh : N.head e ∉ N.regionShore D U q ↔ N.head e = v := by + rw [← Finset.mem_compl,hv,Finset.mem_singleton] + rcases not_and_or.mp hn with ht' | hh' + · exact Or.inl (ht.mp ht') + · exact Or.inr (hh.mp hh') + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Corridors.lean b/lean/OAI/Combinatorics/Hamiltonian/Corridors.lean new file mode 100644 index 0000000000000000000000000000000000000000..698cbc4228ec10da452940b922f48df79c77e3c6 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Corridors.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.Hamiltonian.SquareGrid + +namespace OAI + +/-! Disjoint lattice corridors obtained from a crossing-free plane embedding. -/ + +namespace Barnette + +structure CorridorModel {V W : Type*} (G : SimpleGraph V) (H : SimpleGraph W) where + branch : V → Set W + corridor : G.Dart → Set W + branch_finite : ∀ v, (branch v).Finite + corridor_finite : ∀ d, (corridor d).Finite + branch_connected : ∀ v, (H.induce (branch v)).Connected + corridor_connected : ∀ d, (H.induce (corridor d)).Connected + branches_disjoint : ∀ v w, v ≠ w → Disjoint (branch v) (branch w) + corridors_disjoint : ∀ d e, d.edge ≠ e.edge → Disjoint (corridor d) (corridor e) + nonincident_disjoint : ∀ v d, v ≠ d.fst → v ≠ d.snd → + Disjoint (branch v) (corridor d) + incident_meets : ∀ d, (branch d.fst ∩ corridor d).Nonempty ∧ + (branch d.snd ∩ corridor d).Nonempty + +namespace PlaneEmbedding + +noncomputable section +variable {V : Type*} [Fintype V] [DecidableEq V] {G : SimpleGraph V} + [DecidableRel G.Adj] (E : PlaneEmbedding G) + +private def allSets : V ⊕ G.Dart → Set (ℝ × ℝ) + | .inl v => E.branch v + | .inr d => E.core d + +private def apart : V ⊕ G.Dart → V ⊕ G.Dart → Prop + | .inl v, .inl w => v ≠ w + | .inl v, .inr d => v ≠ d.fst ∧ v ≠ d.snd + | .inr d, .inl v => v ≠ d.fst ∧ v ≠ d.snd + | .inr d, .inr e => d.edge ≠ e.edge + +omit [DecidableEq V] [DecidableRel G.Adj] in +private theorem allSets_compact (i : V ⊕ G.Dart) : IsCompact (E.allSets i) := by + cases i with + | inl v => exact E.branch_compact v + | inr d => exact E.core_compact d + +omit [Fintype V] [DecidableEq V] [DecidableRel G.Adj] in +private theorem allSets_disjoint (i j : V ⊕ G.Dart) (h : apart i j) : + Disjoint (E.allSets i) (E.allSets j) := by + cases i with + | inl v => + cases j with + | inl w => exact E.branch_disjoint h + | inr d => exact E.branch_core_disjoint h.1 h.2 + | inr d => + cases j with + | inl v => exact (E.branch_core_disjoint h.1 h.2).symm + | inr e => exact E.core_disjoint h + +omit [DecidableEq V] in +include E in + +theorem exists_lattice_corridor_model : Nonempty (CorridorModel G SquareGrid.graph) := by + classical + obtain ⟨ε, hε, hsep⟩ := uniform_thickening E.allSets E.allSets_compact apart E.allSets_disjoint + let δ : ℝ := ε / 2 + have hδ : 0 < δ := half_pos hε + have hδε : δ < ε := half_lt_self hε + have hdis (i j : V ⊕ G.Dart) (h : apart i j) : + Disjoint (SquareGrid.cells δ (E.allSets i)) (SquareGrid.cells δ (E.allSets j)) := + SquareGrid.cells_disjoint hδε (hsep i j h) + refine ⟨{ + branch := fun v => SquareGrid.cells δ (E.branch v) + corridor := fun d => SquareGrid.cells δ (E.core d) + branch_finite := fun v => SquareGrid.cells_finite hδ (E.branch_compact v) + corridor_finite := fun d => SquareGrid.cells_finite hδ (E.core_compact d) + branch_connected := fun v => SquareGrid.cells_connected hδ (E.branch_compact v) + (E.branch_connected v) + corridor_connected := fun d => SquareGrid.cells_connected hδ (E.core_compact d) + (E.core_connected d) + branches_disjoint := fun v w h => hdis (.inl v) (.inl w) h + corridors_disjoint := fun d e h => hdis (.inr d) (.inr e) h + nonincident_disjoint := fun v d h₁ h₂ => hdis (.inl v) (.inr d) ⟨h₁, h₂⟩ + incident_meets := ?_ + }⟩ + intro d + have meets {K L : Set (ℝ × ℝ)} (h : (K ∩ L).Nonempty) : + (SquareGrid.cells δ K ∩ SquareGrid.cells δ L).Nonempty := by + obtain ⟨p, hpK, hpL⟩ := h + obtain ⟨z, hz⟩ := SquareGrid.cell_cover hδ p + exact ⟨z, ⟨p, hz, hpK⟩, ⟨p, hz, hpL⟩⟩ + exact ⟨meets (E.branch_core_meets d).1, meets (E.branch_core_meets d).2⟩ + +end +end PlaneEmbedding +end Barnette + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/CutSpaces.lean b/lean/OAI/Combinatorics/Hamiltonian/CutSpaces.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c1dcba8ca36fe7fd4865f742a662356ecc760ec --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/CutSpaces.lean @@ -0,0 +1,315 @@ +import OAI.Combinatorics.Hamiltonian.Network + +namespace OAI + +/-! Cuts, simplicity, and connectivity of finite oriented networks. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +def cut (A : Finset V) : Finset E := Finset.univ.filter fun e => + (N.tail e ∈ A ∧ N.head e ∉ A) ∨ (N.head e ∈ A ∧ N.tail e ∉ A) + +omit [Fintype V] in +@[simp] lemma mem_cut (A : Finset V) (e : E) : e ∈ N.cut A ↔ + (N.tail e ∈ A ∧ N.head e ∉ A) ∨ (N.head e ∈ A ∧ N.tail e ∉ A) := by + simp [cut] + +@[simp] lemma cut_compl (A : Finset V) : N.cut Aᶜ = N.cut A := by + ext e + simp only [mem_cut, Finset.mem_compl] + tauto + +lemma region_card_le_cut (h : ThreeVertexConnected N.graph) + (A : Finset V) (hout : ∃ w, w ∉ A) (hc : (N.cut A).card ≤ 2) : + A.card ≤ (N.cut A).card := by + let p : E → V := fun e => if N.tail e ∈ A then N.tail e else N.head e + let S := (N.cut A).image p + have hS : S.card ≤ 2 := (Finset.card_image_le).trans hc + have hSA : S ⊆ A := by + intro v hv + obtain ⟨e, he, rfl⟩ := Finset.mem_image.mp hv + rcases (N.mem_cut A e).mp he with ⟨ht,hh⟩ | ⟨hh,ht⟩ + · simpa only [p, ite_eq_left ht] using ht + · simpa only [p, ite_eq_right ht] using hh + have hsubset : A ⊆ S := by + apply boundary_cover_of_threeConnected h A S hS hSA hout + intro v hv w hw hvw + obtain ⟨_, e, he⟩ := hvw + apply Finset.mem_image.mpr + rcases he with ⟨ht,hh⟩ | ⟨ht,hh⟩ + · refine ⟨e, (N.mem_cut A e).mpr (Or.inl ?_), ?_⟩ + · simpa only [ht,hh] using And.intro hv hw + · simp only [p, ht, hv, ite_true] + · refine ⟨e, (N.mem_cut A e).mpr (Or.inr ?_), ?_⟩ + · simpa only [ht,hh] using And.intro hv hw + · simp only [p, ht, hh, hw, ite_false] + exact (Finset.card_le_card hsubset).trans Finset.card_image_le + +lemma cut_card_three (h : ThreeVertexConnected N.graph) + (hV : 5 ≤ Fintype.card V) (A : Finset V) (hin : A.Nonempty) + (hout : ∃ w, w ∉ A) : 3 ≤ (N.cut A).card := by + by_contra hc + have hc' : (N.cut A).card ≤ 2 := by omega + have ha := N.region_card_le_cut h A hout hc' + have hccompl : (N.cut Aᶜ).card ≤ 2 := by simpa only [cut_compl] using hc' + have hb := N.region_card_le_cut h Aᶜ (by + obtain ⟨v,hv⟩ := hin; exact ⟨v, by simpa only [Finset.mem_compl, not_not] using hv⟩) hccompl + rw [cut_compl] at hb + have he := Finset.card_add_card_compl A + omega + +lemma gradient_small_support (h : ThreeVertexConnected N.graph) + (hV : 5 ≤ Fintype.card V) (f : V → ℝ) (s : Finset E) (hs : s.card ≤ 2) + (hf : ∀ e, e ∉ s → N.gradient f e = 0) : N.gradient f = 0 := by + ext e + by_contra he + have hne : f (N.head e) ≠ f (N.tail e) := by + simpa only [gradient_apply, Pi.zero_apply, sub_eq_zero] using he + let A := Finset.univ.filter fun v => f v = f (N.tail e) + have hin : A.Nonempty := ⟨N.tail e, by simp [A]⟩ + have hout : ∃ w, w ∉ A := ⟨N.head e, by simp [A, hne]⟩ + have hsub : N.cut A ⊆ s := by + intro k hk + by_contra hks + have hg : f (N.head k) = f (N.tail k) := sub_eq_zero.mp (hf k hks) + rcases (N.mem_cut A k).mp hk with ⟨ht,hh⟩ | ⟨hh,ht⟩ + · apply hh; simp only [A, Finset.mem_filter, Finset.mem_univ, true_and] at ht ⊢ + exact hg.trans ht + · apply ht; simp only [A, Finset.mem_filter, Finset.mem_univ, true_and] at hh ⊢ + exact hg.symm.trans hh + have h₁ := N.cut_card_three h hV A hin hout + have h₂ := Finset.card_le_card hsub + omega + +end +end Barnette.Network + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} (N : Network V E) + +structure Simple : Prop where + loopless : ∀ e, N.tail e ≠ N.head e + pair_injective : Function.Injective (fun e => s(N.tail e, N.head e)) + +def basisVec (e : E) : E → ℝ := fun k => if k = e then 1 else 0 + +variable [Fintype V] [Fintype E] +omit [Fintype V] in +lemma boundary_basis (e : E) : N.boundary (basisVec e) = fun v => N.incidence v e := by + ext v + rw [boundary_apply, Finset.sum_eq_single e] + · simp [basisVec, incidence] + · intro k _ hke; simp [basisVec, hke] + · simp + +variable {F : Type*} [Fintype F] (D : Network F E) + +omit [Fintype F] in + +theorem Duality.simple_dual (h : N.Duality D) + (h3 : ThreeVertexConnected N.graph) (hV : 5 ≤ Fintype.card V) : D.Simple := by + have lift_zero (x : E → ℝ) (hx : D.boundary x = 0) + (s : Finset E) (hs : s.card ≤ 2) (hxs : ∀ e, e ∉ s → x e = 0) : x = 0 := by + have hx' : x ∈ N.gradient.range := by rw [← h.dual_cycles_eq_cuts]; exact hx + obtain ⟨f,hf⟩ := hx' + rw [← hf] + exact N.gradient_small_support h3 hV f s hs (by simpa only [hf] using hxs) + refine ⟨?_, ?_⟩ + · intro e he + have hz : D.boundary (basisVec e) = 0 := by + rw [D.boundary_basis] + ext v + simp [incidence, he] + have hzero := lift_zero (basisVec e) hz {e} (by simp) (by + intro k hk; simp only [Finset.mem_singleton] at hk; simp [basisVec, hk]) + have hh := congrFun hzero e + norm_num [basisVec] at hh + · intro e f hef + by_contra hne + rcases Sym2.eq_iff.mp hef with ⟨ht,hh⟩ | ⟨ht,hh⟩ + · have hz : D.boundary (basisVec e - basisVec f) = 0 := by + rw [map_sub, D.boundary_basis, D.boundary_basis] + ext v + simp [incidence, ht, hh] + have hzero := lift_zero (basisVec e - basisVec f) hz {e,f} + (by simpa using Finset.card_insert_le e ({f} : Finset E)) + (by intro k hk; simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hk + simp [basisVec, hk.1, hk.2]) + have hv := congrFun hzero e + norm_num [basisVec, hne] at hv + · have hz : D.boundary (basisVec e + basisVec f) = 0 := by + rw [map_add, D.boundary_basis, D.boundary_basis] + ext v + dsimp [incidence] + rw [ht, hh] + ring + have hzero := lift_zero (basisVec e + basisVec f) hz {e,f} + (by simpa using Finset.card_insert_le e ({f} : Finset E)) + (by intro k hk; simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hk + simp [basisVec, hk.1, hk.2]) + have hv := congrFun hzero e + norm_num [basisVec, hne] at hv + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +omit [Fintype V] [Fintype E] in +def Incident (e : E) (v : V) : Prop := N.tail e = v ∨ N.head e = v + +omit [Fintype V] [Fintype E] in +lemma incident_iff_mem_pair (e : E) (v : V) : + N.Incident e v ↔ v ∈ s(N.tail e, N.head e) := by + simp only [Incident, Sym2.mem_iff] + tauto + +omit [Fintype V] [Fintype E] in +lemma pair_eq_of_incident {e : E} {v w : V} (hne : v ≠ w) + (hv : N.Incident e v) (hw : N.Incident e w) : s(N.tail e,N.head e) = s(v,w) := by + rcases hv with ht | hh <;> rcases hw with ht' | hh' + · exact (hne (ht.symm.trans ht')).elim + · rw [ht,hh'] + · rw [ht',hh,Sym2.eq_swap] + · exact (hne (hh.symm.trans hh')).elim + +omit [Fintype V] [Fintype E] in +lemma Simple.incident_other (h : N.Simple) {e : E} {v : V} (hi : N.Incident e v) : + ∃ w, v ≠ w ∧ s(N.tail e,N.head e) = s(v,w) := by + rcases hi with ht | hh + · exact ⟨N.head e, ht ▸ h.loopless e, by rw [ht]⟩ + · exact ⟨N.tail e, hh ▸ (h.loopless e).symm, by rw [hh,Sym2.eq_swap]⟩ + +def flowSupport (_N : Network V E) (x : E → ℝ) : Finset E := Finset.univ.filter fun e => x e ≠ 0 + +omit [Fintype V] in +@[simp] lemma mem_flowSupport (x : E → ℝ) (e : E) : + e ∈ N.flowSupport x ↔ x e ≠ 0 := by simp [flowSupport] + +omit [Fintype V] in + +lemma flow_no_leaf (hN : N.Simple) (x : E → ℝ) (hx : N.boundary x = 0) + {e : E} {v : V} (he : x e ≠ 0) (hev : N.Incident e v) : + ∃ f, f ≠ e ∧ x f ≠ 0 ∧ N.Incident f v := by + by_contra hn + have other (f : E) (hfe : f ≠ e) : + (if N.head f = v then x f else 0) - (if N.tail f = v then x f else 0) = 0 := by + by_cases hxf : x f = 0 + · simp [hxf] + · have hif : ¬N.Incident f v := fun hf => hn ⟨f,hfe,hxf,hf⟩ + have hh : N.head f ≠ v := fun h => hif (Or.inr h) + have ht : N.tail f ≠ v := fun h => hif (Or.inl h) + simp [hh,ht] + have hz := congrFun hx v + rw [boundary_apply, Finset.sum_eq_single e] at hz + · rcases hev with ht | hh + · have hh : N.head e ≠ v := fun hh => (hN.loopless e) (ht.trans hh.symm) + simp only [hh, ht, ite_false, ite_true, zero_sub, Pi.zero_apply, neg_eq_zero] at hz + exact he hz + · have ht : N.tail e ≠ v := fun ht => (hN.loopless e) (ht.trans hh.symm) + simp only [hh, ht, ite_false, ite_true, sub_zero, Pi.zero_apply] at hz + exact he hz + · intro f _ hfe; exact other f hfe + · simp + +structure Triangle (s : Finset E) where + corner : Fin 3 → V + corner_injective : Function.Injective corner + edge : Fin 3 → E + edge_injective : Function.Injective edge + edge_range : Finset.univ.image edge = s + edge_ends : ∀ i, s(N.tail (edge i), N.head (edge i)) = s(corner i, corner (i+1)) + +omit [Fintype V] in + +theorem triangle_of_flow (hN : N.Simple) (x : E → ℝ) (hx : N.boundary x = 0) + (hs : (N.flowSupport x).card = 3) : Nonempty (N.Triangle (N.flowSupport x)) := by + let s := N.flowSupport x + have hspos : s.Nonempty := Finset.card_pos.mp (by dsimp [s]; omega) + obtain ⟨e,he⟩ := hspos + have hxe : x e ≠ 0 := (N.mem_flowSupport x e).mp he + let a := N.tail e + let b := N.head e + have hab : a ≠ b := hN.loopless e + obtain ⟨f,hfe,hxf,hfa⟩ := N.flow_no_leaf hN x hx hxe (Or.inl rfl) + have hf : f ∈ s := (N.mem_flowSupport x f).mpr hxf + obtain ⟨c,hac,hfc⟩ := hN.incident_other N hfa + have hbc : b ≠ c := by + intro hbc + have hef : e = f := hN.pair_injective (by dsimp [a,b] at hfc ⊢; rw [hfc, ← hbc]) + exact hfe hef.symm + have hferase : f ∈ s.erase e := Finset.mem_erase.mpr ⟨hfe,hf⟩ + have hrest : ((s.erase e).erase f).card = 1 := by + rw [Finset.card_erase_of_mem hferase, Finset.card_erase_of_mem he] + dsimp [s]; omega + obtain ⟨g,hg⟩ := Finset.card_eq_one.mp hrest + have hsEq : s = {e,f,g} := by + calc s = insert e (s.erase e) := (Finset.insert_erase he).symm + _ = insert e (insert f ((s.erase e).erase f)) := by rw [Finset.insert_erase hferase] + _ = _ := by rw [hg] + have hgmem : g ∈ (s.erase e).erase f := by rw [hg]; simp + obtain ⟨hgf,hge,hgs⟩ := by + simpa only [Finset.mem_erase, and_assoc] using hgmem + have fnotb : ¬N.Incident f b := by + rw [N.incident_iff_mem_pair, hfc] + simp only [Sym2.mem_iff] + exact fun h => h.elim (fun h => hab h.symm) hbc + have enotc : ¬N.Incident e c := by + rw [N.incident_iff_mem_pair] + show ¬(c ∈ s(a,b)) + simp only [Sym2.mem_iff] + exact fun h => h.elim (fun h => hac h.symm) (fun h => hbc h.symm) + have hgb : N.Incident g b := by + obtain ⟨k,hke,hxk,hkb⟩ := N.flow_no_leaf hN x hx hxe (Or.inr rfl) + have hk : k ∈ s := (N.mem_flowSupport x k).mpr hxk + rw [hsEq] at hk + simp only [Finset.mem_insert, Finset.mem_singleton] at hk + rcases hk with rfl | rfl | rfl + · exact (hke rfl).elim + · exact (fnotb hkb).elim + · exact hkb + have hgc : N.Incident g c := by + have hfc' : N.Incident f c := (N.incident_iff_mem_pair f c).mpr (by rw [hfc]; simp) + obtain ⟨k,hkf,hxk,hkc⟩ := N.flow_no_leaf hN x hx hxf hfc' + have hk : k ∈ s := (N.mem_flowSupport x k).mpr hxk + rw [hsEq] at hk + simp only [Finset.mem_insert, Finset.mem_singleton] at hk + rcases hk with rfl | rfl | rfl + · exact (enotc hkc).elim + · exact (hkf rfl).elim + · exact hkc + have hgend := N.pair_eq_of_incident hbc hgb hgc + refine ⟨{ + corner := ![a,b,c] + corner_injective := ?_ + edge := ![e,g,f] + edge_injective := ?_ + edge_range := ?_ + edge_ends := ?_ }⟩ + · intro i j hij + fin_cases i <;> fin_cases j <;> dsimp at hij <;> first | rfl | exact (hab hij).elim | exact (hab hij.symm).elim | exact (hac hij).elim | exact (hac hij.symm).elim | exact (hbc hij).elim | exact (hbc hij.symm).elim + · intro i j hij + fin_cases i <;> fin_cases j <;> dsimp at hij <;> first | rfl | exact (hge hij).elim | exact (hge hij.symm).elim | exact (hfe hij).elim | exact (hfe hij.symm).elim | exact (hgf hij).elim | exact (hgf hij.symm).elim + · change Finset.univ.image ![e,g,f] = s + rw [hsEq] + ext k + simp [Fin.exists_fin_succ] + tauto + · intro i + fin_cases i + · rfl + · exact hgend + · change s(N.tail f, N.head f) = s(c,a) + exact hfc.trans Sym2.eq_swap + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/CycleReversal.lean b/lean/OAI/Combinatorics/Hamiltonian/CycleReversal.lean new file mode 100644 index 0000000000000000000000000000000000000000..d39e19f0e53942f7370e91329fd58b158a6eef8b --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/CycleReversal.lean @@ -0,0 +1,250 @@ +import OAI.Combinatorics.Hamiltonian.ColoredDual + +namespace OAI + +/-! Reversal involutions on partners of a fixed incidence state. -/ + +namespace Barnette + +open Fin.NatCast + +variable {V : Type*} {G : SimpleGraph V} + +theorem cycleCoordinates_of_not_acyclic (hG : ¬G.IsAcyclic) : + Nonempty (CycleCoordinates G) := by + classical + simp only [SimpleGraph.IsAcyclic, not_forall, not_not] at hG + obtain ⟨v, p, hp⟩ := hG + have hlen : 3 ≤ p.length := hp.isCircuit.three_le_length + obtain ⟨f⟩ := (SimpleGraph.cycleGraph_isContained_iff (show 2 < p.length by omega)).mpr + ⟨v, p, hp, rfl⟩ + have heq : p.length = (p.length - 3) + 3 := by omega + rw [heq] at f + refine ⟨⟨p.length - 3, ⟨f.toHom, f.injective⟩, ?_⟩⟩ + intro i + apply f.toHom.map_adj + apply SimpleGraph.cycleGraph_adj'.mpr + right + simp + +namespace TriangleSystem + +variable {A : Type*} (T : TriangleSystem A V) {X : Set V} + +theorem opposite_indices : ∀ i j k l s : Fin 3, + i ≠ j → k ≠ l → i ≠ s → j ≠ s → k ≠ s → l ≠ s → + (i = k ∧ j = l) ∨ (i = l ∧ j = k) := by decide + +structure OppositeCycle (s : T.State X) where + cycle : CycleCoordinates (T.oppositeGraph s) + face : Fin (cycle.n + 3) ↪ A + leftCorner : Fin (cycle.n + 3) → Fin 3 + rightCorner : Fin (cycle.n + 3) → Fin 3 + left_eq : ∀ i, T.vertex (face i) (leftCorner i) = cycle.vertex i + right_eq : ∀ i, T.vertex (face i) (rightCorner i) = cycle.vertex (i + 1) + left_ne : ∀ i, leftCorner i ≠ s.val (face i) + right_ne : ∀ i, rightCorner i ≠ s.val (face i) + +theorem oppositeCycle_nonempty (s : T.State X) (hc : ¬(T.oppositeGraph s).IsAcyclic) : + Nonempty (T.OppositeCycle s) := by + classical + obtain ⟨C⟩ := cycleCoordinates_of_not_acyclic hc + choose face l r hl hr hls hrs using fun i => (C.adjacent i).2 + have hlr (i) : l i ≠ r i := by + intro h + have hh : C.vertex i = C.vertex (i + 1) := (hl i).symm.trans (h ▸ hr i) + have heq := C.vertex.injective hh + apply cyclic_one_ne_zero C.n + exact add_left_cancel (by simpa using heq.symm : i + 1 = i + 0) + have hface : Function.Injective face := by + intro i j hij + have hls' := hls j + have hrs' := hrs j + rw [← hij] at hls' hrs' + have h := opposite_indices (l i) (r i) (l j) (r j) (s.val (face i)) + (hlr i) (hlr j) (hls i) (hrs i) hls' hrs' + apply C.edge_indices_unique i j + rcases h with ⟨h₁, h₂⟩ | ⟨h₁, h₂⟩ + · left + exact ⟨(hl i).symm.trans (by rw [hij, h₁, hl]), + (hr i).symm.trans (by rw [hij, h₂, hr])⟩ + · right + exact ⟨(hl i).symm.trans (by rw [hij, h₁, hr]), + (hr i).symm.trans (by rw [hij, h₂, hl])⟩ + exact ⟨⟨C, ⟨face, hface⟩, l, r, hl, hr, hls, hrs⟩⟩ + +namespace OppositeCycle + +variable {T} {s r : T.State X} (C : T.OppositeCycle s) + +theorem corner_ne (i : Fin (C.cycle.n + 3)) : C.leftCorner i ≠ C.rightCorner i := by + intro h + have heq : C.cycle.vertex i = C.cycle.vertex (i + 1) := + (C.left_eq i).symm.trans (h ▸ C.right_eq i) + apply cyclic_one_ne_zero C.cycle.n + exact add_left_cancel (by simpa using (C.cycle.vertex.injective heq).symm : i + 1 = i + 0) + +theorem partner_endpoints (hrs : T.Partner r s) (i : Fin (C.cycle.n + 3)) : + (r.value (C.face i) = C.cycle.vertex i ∧ + T.vertex (C.face i) (thirdIndex (r.val (C.face i)) (s.val (C.face i))) = + C.cycle.vertex (i + 1)) ∨ + (r.value (C.face i) = C.cycle.vertex (i + 1) ∧ + T.vertex (C.face i) (thirdIndex (r.val (C.face i)) (s.val (C.face i))) = + C.cycle.vertex i) := by + have hne : r.val (C.face i) ≠ s.val (C.face i) := + fun h => hrs _ ((State.value_eq_iff r s _).mpr h) + have h := other_corners (C.leftCorner i) (C.rightCorner i) + (r.val (C.face i)) (s.val (C.face i)) (C.corner_ne i) (C.left_ne i) (C.right_ne i) hne + rcases h with ⟨h₁, h₂⟩ | ⟨h₁, h₂⟩ + · left + exact ⟨by change T.vertex _ _ = _; rw [← h₁, C.left_eq], + by rw [← h₂, C.right_eq]⟩ + · right + exact ⟨by change T.vertex _ _ = _; rw [← h₁, C.right_eq], + by rw [← h₂, C.left_eq]⟩ + +theorem partner_orientation (hrs : T.Partner r s) : + (∀ i, r.value (C.face i) = C.cycle.vertex i) ∨ + (∀ i, r.value (C.face i) = C.cycle.vertex (i + 1)) := by + apply C.cycle.tail_orientation C.face r.value r.value_injective + intro i + exact (C.partner_endpoints hrs i).imp And.left And.left + +end OppositeCycle +end TriangleSystem +end Barnette + +namespace Barnette.TriangleSystem + +open Fin.NatCast + +variable {A V : Type*} {T : TriangleSystem A V} {X : Set V} {s : T.State X} + +namespace OppositeCycle + +variable (C : T.OppositeCycle s) + +noncomputable def changedCorners (r : T.State X) (t : A) : Fin 3 := by + classical + exact if t ∈ Set.range C.face then thirdIndex (r.val t) (s.val t) else r.val t + +@[simp] theorem changedCorners_image (r : T.State X) (i : Fin (C.cycle.n + 3)) : + C.changedCorners r (C.face i) = thirdIndex (r.val (C.face i)) (s.val (C.face i)) := by + classical + simp [changedCorners] + +theorem changed_assignment_permutation (r : T.State X) (hrs : T.Partner r s) : + ∃ e : Equiv.Perm A, ∀ t, T.vertex t (C.changedCorners r t) = r.value (e t) := by + classical + let f := Equiv.ofInjective C.face C.face.injective + rcases C.partner_orientation hrs with hforward | hbackward + · let e := (Equiv.addRight (1 : Fin (C.cycle.n + 3))).extendDomain f + refine ⟨e, ?_⟩ + intro t + by_cases ht : t ∈ Set.range C.face + · obtain ⟨i, rfl⟩ := ht + have he : e (C.face i) = C.face (i + 1) := by + exact (Equiv.Perm.extendDomain_apply_image _ f i) + rw [C.changedCorners_image, he, hforward] + rcases C.partner_endpoints hrs i with ⟨_, h⟩ | ⟨h, _⟩ + · exact h + · exact ((C.cycle.adjacent i).1 ((hforward i).symm.trans h)).elim + · rw [changedCorners, ite_eq_right ht, Equiv.Perm.extendDomain_apply_not_subtype _ f ht] + rfl + · let e := (Equiv.addRight (-1 : Fin (C.cycle.n + 3))).extendDomain f + refine ⟨e, ?_⟩ + intro t + by_cases ht : t ∈ Set.range C.face + · obtain ⟨i, rfl⟩ := ht + have he : e (C.face i) = C.face (i - 1) := by + calc + e (C.face i) = C.face (i + (-1 : Fin (C.cycle.n + 3))) := + Equiv.Perm.extendDomain_apply_image _ f i + _ = C.face (i - 1) := congrArg C.face (sub_eq_add_neg i 1).symm + rw [C.changedCorners_image, he, hbackward, sub_add_cancel] + rcases C.partner_endpoints hrs i with ⟨h, _⟩ | ⟨_, h⟩ + · exact ((C.cycle.adjacent i).1 (h.symm.trans (hbackward i))).elim + · exact h + · rw [changedCorners, ite_eq_right ht, Equiv.Perm.extendDomain_apply_not_subtype _ f ht] + rfl + +noncomputable def reverse (r : T.State X) (hrs : T.Partner r s) : T.State X := by + let e := (C.changed_assignment_permutation r hrs).choose + have he : ∀ t, T.vertex t (C.changedCorners r t) = r.value (e t) := + (C.changed_assignment_permutation r hrs).choose_spec + refine ⟨C.changedCorners r, ?_, ?_⟩ + · intro t u h + change T.vertex t (C.changedCorners r t) = T.vertex u (C.changedCorners r u) at h + rw [he t, he u] at h + exact e.injective (r.value_injective h) + · calc + Set.range (fun t => T.vertex t (C.changedCorners r t)) = Set.range r.value := by + ext v + constructor + · rintro ⟨t, rfl⟩ + exact ⟨e t, (he t).symm⟩ + · rintro ⟨u, rfl⟩ + refine ⟨e.symm u, ?_⟩ + change T.vertex (e.symm u) (C.changedCorners r (e.symm u)) = r.value u + rw [he, e.apply_symm_apply] + _ = X := r.value_range + +@[simp] theorem reverse_val (r : T.State X) (hrs : T.Partner r s) : + (C.reverse r hrs).val = C.changedCorners r := rfl + +theorem reverse_partner (r : T.State X) (hrs : T.Partner r s) : + T.Partner (C.reverse r hrs) s := by + classical + intro t h + have hi : C.changedCorners r t = s.val t := + T.vertex_injective t h + by_cases ht : t ∈ Set.range C.face + · rw [changedCorners, ite_eq_left ht] at hi + have hne : r.val t ≠ s.val t := fun h => hrs t ((State.value_eq_iff r s t).mpr h) + exact (thirdIndex_distinct _ _ hne).2 hi + · rw [changedCorners, ite_eq_right ht] at hi + exact hrs t ((State.value_eq_iff r s t).mpr hi) + +@[simp] theorem reverse_reverse (r : T.State X) (hrs : T.Partner r s) : + C.reverse (C.reverse r hrs) (C.reverse_partner r hrs) = r := by + classical + apply Subtype.ext + funext t + change C.changedCorners (C.reverse r hrs) t = r.val t + by_cases ht : t ∈ Set.range C.face + · simp only [changedCorners, ht, ite_true, reverse_val, thirdIndex_involution] + · simp only [changedCorners, ht, ite_false, reverse_val] + +theorem reverse_ne (r : T.State X) (hrs : T.Partner r s) : C.reverse r hrs ≠ r := by + intro h + have heq := congrFun (congrArg Subtype.val h) (C.face 0) + change C.changedCorners r (C.face 0) = r.val (C.face 0) at heq + rw [C.changedCorners_image] at heq + have hne : r.val (C.face 0) ≠ s.val (C.face 0) := + fun h => hrs _ ((State.value_eq_iff r s _).mpr h) + exact (thirdIndex_distinct _ _ hne).1 heq + +end OppositeCycle + +def Partners (s : T.State X) := {r : T.State X // T.Partner r s} + +namespace OppositeCycle + +variable (C : T.OppositeCycle s) + +noncomputable def reversal (r : T.Partners s) : T.Partners s := + ⟨C.reverse r.val r.property, C.reverse_partner r.val r.property⟩ + +theorem reversal_involutive : Function.Involutive C.reversal := by + intro r + apply Subtype.ext + exact C.reverse_reverse r.val r.property + +theorem reversal_ne (r : T.Partners s) : C.reversal r ≠ r := by + intro h + exact C.reverse_ne r.val r.property (congrArg Subtype.val h) + +end OppositeCycle +end Barnette.TriangleSystem + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/DiskRegions.lean b/lean/OAI/Combinatorics/Hamiltonian/DiskRegions.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9c2f12d1b5d06f175829627cfa44ad7f790e507 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/DiskRegions.lean @@ -0,0 +1,318 @@ +import OAI.Combinatorics.Hamiltonian.Quotients + +namespace OAI + +/-! Connected face regions and the exact disk Euler formula. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +def regionEdges (A : Finset V) : Finset E := + Finset.univ.filter fun e => N.tail e ∈ A ∨ N.head e ∈ A + +omit [Fintype V] in +@[simp] lemma mem_regionEdges (A : Finset V) (e : E) : + e ∈ N.regionEdges A ↔ N.tail e ∈ A ∨ N.head e ∈ A := by + simp [regionEdges] + +def regionVertices (A : Finset V) : Finset F := + Finset.univ.filter fun z => ∃ e ∈ N.regionEdges A, D.Incident e z + +omit [Fintype V] in +@[simp] lemma mem_regionVertices (A : Finset V) (z : F) : + z ∈ N.regionVertices D A ↔ ∃ e ∈ N.regionEdges A, D.Incident e z := by + simp [regionVertices] + +def region (A : Finset V) : Network (N.regionVertices D A) (N.regionEdges A) where + tail e := ⟨D.tail e.val, (N.mem_regionVertices D A _).mpr ⟨e.val,e.property,Or.inl rfl⟩⟩ + head e := ⟨D.head e.val, (N.mem_regionVertices D A _).mpr ⟨e.val,e.property,Or.inr rfl⟩⟩ + +omit [Fintype V] in +lemma region_map (A : Finset V) : + (N.region D A).mapVertices Subtype.val = D.restrict (Subtype.val : N.regionEdges A → E) := rfl + +omit [Fintype V] in +lemma region_boundary (A : Finset V) (x : N.regionEdges A → ℝ) : + push (Subtype.val : N.regionVertices D A → F) ((N.region D A).boundary x) = + D.boundary (push Subtype.val x) := by + rw [← boundary_mapVertices, N.region_map, boundary_restrict] + +omit [Fintype V] in +lemma push_subtype_apply (A : Finset V) (f : A → ℝ) (v : A) : + push (Subtype.val : A → V) f v.val = f v := by + have h := congrFun (pull_push_injective (E := V) Subtype.val_injective f) v + exact h + +omit [Fintype V] in +lemma push_subtype_outside (A : Finset V) (f : A → ℝ) {v : V} (hv : v ∉ A) : + push (Subtype.val : A → V) f v = 0 := + push_eq_zero_outside f (by simpa using hv) + +omit [Fintype V] in +lemma extend_gradient_outside (A : Finset V) (f : A → ℝ) {e : E} + (he : e ∉ N.regionEdges A) : N.gradient (push (Subtype.val : A → V) f) e = 0 := by + have hh : N.head e ∉ A := fun h => he ((N.mem_regionEdges A e).mpr (Or.inr h)) + have ht : N.tail e ∉ A := fun h => he ((N.mem_regionEdges A e).mpr (Or.inl h)) + simp only [gradient_apply, push_subtype_outside A f hh, push_subtype_outside A f ht, sub_self] + +omit [Fintype V] in +lemma extend_restrict_gradient (A : Finset V) (f : A → ℝ) : + push (Subtype.val : N.regionEdges A → E) + (pull Subtype.val (N.gradient (push (Subtype.val : A → V) f))) = + N.gradient (push (Subtype.val : A → V) f) := by + ext e + by_cases he : e ∈ N.regionEdges A + · exact push_subtype_apply (N.regionEdges A) _ ⟨e,he⟩ + · rw [push_subtype_outside (N.regionEdges A) _ he] + exact (N.extend_gradient_outside A f he).symm + +omit [Fintype V] in + +lemma region_connected (A : Finset V) (hA : (N.graph.induce {v | v ∈ A}).Connected) + (sD : D.Simple) (face : ∀ v, D.Triangle (N.star v)) : + (N.region D A).graph.Connected := by + let R := N.region D A + have in_face {v : V} (hv : v ∈ A) {z : F} (hz : z ∈ Set.range (face v).corner) : + z ∈ N.regionVertices D A := by + obtain ⟨e,he,hz⟩ := ((face v).corner_iff_incident D z).mp hz + have hv' := (N.mem_star e v).mp he + have heA : e ∈ N.regionEdges A := by + apply (N.mem_regionEdges A e).mpr + exact hv'.elim (fun he => Or.inl (he ▸ hv)) (fun he => Or.inr (he ▸ hv)) + exact (N.mem_regionVertices D A z).mpr ⟨e,heA,hz⟩ + let a (v : {v // v ∈ A}) : N.regionVertices D A := + ⟨(face v.val).corner 0,in_face v.property ⟨0,rfl⟩⟩ + have local_path {v : V} (hv : v ∈ A) {z w : N.regionVertices D A} + (hz : z.val ∈ Set.range (face v).corner) (hw : w.val ∈ Set.range (face v).corner) : + R.graph.Reachable z w := by + obtain ⟨i,hi⟩ := hz + obtain ⟨j,hj⟩ := hw + by_cases hij : i = j + · have he : z = w := Subtype.ext (hi.symm.trans (hij ▸ hj)) + rw [he] + · have hadj := (face v).clique D hij + rw [hi,hj] at hadj + obtain ⟨hne,e,he⟩ := hadj + have heface : e ∈ N.star v := by + have hfin : ∀ i j : Fin 3, i ≠ j → j = i+1 ∨ i = j+1 := by decide + rcases hfin i j hij with h | h + · have ep : s(D.tail e,D.head e) = s(D.tail ((face v).edge i),D.head ((face v).edge i)) := by + rw [(face v).edge_ends, ← h, hi, hj] + exact Sym2.eq_iff.mpr he + have ee := sD.pair_injective ep + rw [ee] + have hm : (face v).edge i ∈ Finset.univ.image (face v).edge := + Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩ + rwa [(face v).edge_range] at hm + · have ep : s(D.tail e,D.head e) = s(D.tail ((face v).edge j),D.head ((face v).edge j)) := by + rw [(face v).edge_ends, ← h, hi, hj] + exact Sym2.eq_iff.mpr he.symm + rw [sD.pair_injective ep] + have hm : (face v).edge j ∈ Finset.univ.image (face v).edge := + Finset.mem_image.mpr ⟨j,Finset.mem_univ _,rfl⟩ + rwa [(face v).edge_range] at hm + have heA : e ∈ N.regionEdges A := by + rcases (N.mem_star e v).mp heface with h | h + · exact (N.mem_regionEdges A e).mpr (Or.inl (h ▸ hv)) + · exact (N.mem_regionEdges A e).mpr (Or.inr (h ▸ hv)) + apply SimpleGraph.Adj.reachable + refine ⟨fun h => hne (congrArg Subtype.val h),⟨e,heA⟩,?_⟩ + exact he.elim (fun h => Or.inl ⟨Subtype.ext h.1,Subtype.ext h.2⟩) + (fun h => Or.inr ⟨Subtype.ext h.1,Subtype.ext h.2⟩) + have step {v w : {v // v ∈ A}} (hvw : (N.graph.induce {v | v ∈ A}).Adj v w) : + R.graph.Reachable (a v) (a w) := by + obtain ⟨_,e,he⟩ := hvw + have hv : N.Incident e v.val := he.elim (fun h => Or.inl h.1) (fun h => Or.inr h.2) + have hw : N.Incident e w.val := he.elim (fun h => Or.inr h.2) (fun h => Or.inl h.1) + have hf (u : V) (hu : N.Incident e u) : D.tail e ∈ Set.range (face u).corner := + ((face u).corner_iff_incident D _).mpr ⟨e,(N.mem_star e u).mpr hu,Or.inl rfl⟩ + let z : N.regionVertices D A := ⟨D.tail e,in_face v.property (hf _ hv)⟩ + exact (local_path v.property ⟨0,rfl⟩ (hf _ hv)).trans + (local_path w.property (z := z) (hf _ hw) ⟨0,rfl⟩) + have all_faces {v w : {v // v ∈ A}} : R.graph.Reachable (a v) (a w) := by + obtain ⟨p⟩ := hA v w + induction p with + | nil => exact SimpleGraph.Reachable.refl _ + | cons h p ih => exact (step h).trans ih + obtain ⟨v₀⟩ := hA.nonempty + apply (SimpleGraph.connected_iff_exists_forall_reachable _).mpr + refine ⟨a v₀,?_⟩ + intro z + obtain ⟨e,he,hz⟩ := (N.mem_regionVertices D A z.val).mp z.property + rcases (N.mem_regionEdges A e).mp he with ht | hh + · have hf := ((face (N.tail e)).corner_iff_incident D z.val).mpr + ⟨e,(N.mem_star _ _).mpr (Or.inl rfl),hz⟩ + exact (all_faces (w := ⟨N.tail e,ht⟩)).trans (local_path ht ⟨0,rfl⟩ hf) + · have hf := ((face (N.head e)).corner_iff_incident D z.val).mpr + ⟨e,(N.mem_star _ _).mpr (Or.inr rfl),hz⟩ + exact (all_faces (w := ⟨N.head e,hh⟩)).trans (local_path hh ⟨0,rfl⟩ hf) + +end +end Barnette.Network + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +def regionCycleMap (A : Finset V) : (A → ℝ) →ₗ[ℝ] (N.regionEdges A → ℝ) := + (pull (Subtype.val : N.regionEdges A → E)).comp + (N.gradient.comp (push (Subtype.val : A → V))) + +omit [Fintype V] in +lemma regionCycleMap_injective (hN : N.graph.Connected) (A : Finset V) + (hout : ∃ v, v ∉ A) : Function.Injective (N.regionCycleMap A) := by + apply LinearMap.ker_eq_bot.mp + apply eq_bot_iff.mpr + intro f hf + change f = 0 + have hz : N.regionCycleMap A f = 0 := hf + have hg : N.gradient (push (Subtype.val : A → V) f) = 0 := by + rw [← N.extend_restrict_gradient A f] + change push (Subtype.val : N.regionEdges A → E) (N.regionCycleMap A f) = 0 + rw [hz,map_zero] + obtain ⟨r,hr⟩ := hout + ext v + have he := N.gradient_zero_reachable hg (hN r v.val) + rw [push_subtype_outside A f hr, push_subtype_apply A f v] at he + exact he.symm + +omit [Fintype V] in +lemma region_cycles_eq_range (h : N.Duality D) (A : Finset V) + (hAc : (N.graph.induce {v | v ∉ A}).Connected) : + (N.region D A).boundary.ker = (N.regionCycleMap A).range := by + ext x + constructor + · intro hx + have hx' : (N.region D A).boundary x = 0 := hx + let y : E → ℝ := push (Subtype.val : N.regionEdges A → E) x + have hy : D.boundary y = 0 := by + rw [← N.region_boundary D A x, hx',map_zero] + obtain ⟨f,hf⟩ : ∃ f, N.gradient f = y := by + have hm : y ∈ D.boundary.ker := hy + rw [h.dual_cycles_eq_cuts] at hm + exact hm + obtain ⟨r⟩ := hAc.nonempty + have fstep {v w : {v // v ∉ A}} + (hvw : (N.graph.induce {v | v ∉ A}).Adj v w) : f v.val = f w.val := by + obtain ⟨_,e,he⟩ := hvw + have heA : e ∉ N.regionEdges A := by + rw [N.mem_regionEdges] + exact he.elim (fun he => by rw [he.1,he.2]; exact not_or.mpr ⟨v.property,w.property⟩) + (fun he => by rw [he.1,he.2]; exact not_or.mpr ⟨w.property,v.property⟩) + have hy0 : y e = 0 := push_eq_zero_outside x (by simpa using heA) + have heq := congrFun hf e + rw [hy0,gradient_apply,sub_eq_zero] at heq + exact he.elim (fun he => by rw [he.1,he.2] at heq; exact heq.symm) + (fun he => by rwa [he.1,he.2] at heq) + have fconstant (v : {v // v ∉ A}) : f v.val = f r.val := by + obtain ⟨p⟩ := hAc v r + induction p with + | nil => rfl + | cons h p ih => exact (fstep h).trans ih + let u : A → ℝ := fun v => f v.val - f r.val + have hext : push (Subtype.val : A → V) u = f - (fun _ => f r.val) := by + ext v + by_cases hv : v ∈ A + · exact push_subtype_apply A u ⟨v,hv⟩ + · rw [push_subtype_outside A u hv] + exact (sub_eq_zero.mpr (fconstant ⟨v,hv⟩)).symm + refine ⟨u,?_⟩ + change pull (Subtype.val : N.regionEdges A → E) (N.gradient (push Subtype.val u)) = x + rw [hext,map_sub,N.gradient_const,sub_zero,hf] + exact pull_push_injective Subtype.val_injective x + · rintro ⟨f,rfl⟩ + have hz : push (Subtype.val : N.regionVertices D A → F) + ((N.region D A).boundary (N.regionCycleMap A f)) = 0 := by + rw [N.region_boundary] + change D.boundary (push (Subtype.val : N.regionEdges A → E) + (pull Subtype.val (N.gradient (push (Subtype.val : A → V) f)))) = 0 + rw [N.extend_restrict_gradient] + exact h.dual_conserved_gradient N D _ + have hh := congrArg (pull (Subtype.val : N.regionVertices D A → F)) hz + rw [pull_push_injective Subtype.val_injective,map_zero] at hh + exact hh + +omit [Fintype V] in +lemma region_dim_cycles (h : N.Duality D) (A : Finset V) + (hAc : (N.graph.induce {v | v ∉ A}).Connected) : + Module.finrank ℝ (N.region D A).boundary.ker = A.card := by + rw [N.region_cycles_eq_range D h A hAc, + LinearMap.finrank_range_of_inj (N.regionCycleMap_injective h.connected A ?_), + Module.finrank_pi,Fintype.card_coe] + obtain ⟨v⟩ := hAc.nonempty + exact ⟨v.val,v.property⟩ + +omit [Fintype V] in + +theorem region_euler (h : N.Duality D) (A : Finset V) + (hA : (N.graph.induce {v | v ∈ A}).Connected) + (hAc : (N.graph.induce {v | v ∉ A}).Connected) + (sD : D.Simple) (face : ∀ v, D.Triangle (N.star v)) : + A.card + (N.regionVertices D A).card = (N.regionEdges A).card + 1 := by + have hh := (N.region D A).dim_cycles (N.region_connected D A hA sD face) + rwa [N.region_dim_cycles D h A hAc,Fintype.card_coe,Fintype.card_coe] at hh + +end +end Barnette.Network + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] in +lemma sum_stars (hN : N.Simple) (A : Finset V) : + ∑ v ∈ A, (N.star v).card = + ∑ e, ((if N.tail e ∈ A then 1 else 0) + (if N.head e ∈ A then 1 else 0)) := by + calc + ∑ v ∈ A, (N.star v).card = + ∑ v ∈ A, ∑ e, ((if N.tail e = v then 1 else 0) + (if N.head e = v then 1 else 0)) := by + apply Finset.sum_congr rfl + intro v _ + rw [star,Finset.card_filter] + simp only [Incident] + apply Finset.sum_congr rfl + intro e _ + have hne := hN.loopless e + by_cases ht : N.tail e = v <;> by_cases hh : N.head e = v <;> simp_all + _ = _ := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + simp [Finset.sum_add_distrib] + +lemma cubic_region_count (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) (A : Finset V) : + 3 * A.card + (N.cut A).card = 2 * (N.regionEdges A).card := by + have hsum := N.sum_stars hN A + have hv : (∑ v ∈ A, (N.star v).card) = 3 * A.card := by + have hc' : ∀ v, N.graph.degree v = 3 := hc + simp only [N.card_star hN,hc'] + simp [Nat.mul_comm] + rw [hv] at hsum + rw [hsum] + simp only [cut,regionEdges,Finset.card_filter, + ← Finset.sum_add_distrib,Finset.mul_sum] + apply Finset.sum_congr rfl + intro e _ + by_cases ht : N.tail e ∈ A <;> by_cases hh : N.head e ∈ A <;> simp [ht,hh] + +lemma disk_euler_count (h : N.Duality D) (hN : N.Simple) + (hc : N.graph.IsRegularOfDegree 3) (A : Finset V) + (hA : (N.graph.induce {v | v ∈ A}).Connected) + (hAc : (N.graph.induce {v | v ∉ A}).Connected) + (sD : D.Simple) (face : ∀ v, D.Triangle (N.star v)) : + (A.card : ℤ) = 2 * (N.regionVertices D A).card - (N.cut A).card - 2 := by + have he := N.region_euler D h A hA hAc sD face + have hc := N.cubic_region_count hN hc A + omega + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/ExactDual.lean b/lean/OAI/Combinatorics/Hamiltonian/ExactDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..84a403f205f9018d6755f303d7e8c579752b3787 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/ExactDual.lean @@ -0,0 +1,125 @@ +import OAI.Combinatorics.Hamiltonian.Rectangle + +namespace OAI + +/-! Graph realization and exact finite duality for topological plane embeddings. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V W E : Type*} [Fintype V] [Fintype W] [Fintype E] + +def Realizes (G : SimpleGraph V) (M : Network V G.edgeSet) : Prop := + ∀ e, s(M.tail e, M.head e) = e.val + +omit [Fintype V] in +lemma Realizes.graph_eq {G : SimpleGraph V} {M : Network V G.edgeSet} + (h : M.Realizes G) : M.graph = G := by + ext v w + constructor + · rintro ⟨_, e, ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩⟩ + · exact G.mem_edgeSet.mp ((h e).symm ▸ e.property) + · exact (G.mem_edgeSet.mp ((h e).symm ▸ e.property)).symm + · intro hvw + let e : G.edgeSet := ⟨s(v,w), hvw⟩ + refine ⟨hvw.ne, e, ?_⟩ + have he := h e + change s(M.tail e, M.head e) = s(v,w) at he + exact Sym2.eq_iff.mp he + +omit [Fintype V] in +lemma Realizes.loopless {G : SimpleGraph V} {M : Network V G.edgeSet} + (h : M.Realizes G) (e : G.edgeSet) : M.tail e ≠ M.head e := by + have he : G.Adj (M.tail e) (M.head e) := G.mem_edgeSet.mp ((h e).symm ▸ e.property) + exact he.ne + +omit [Fintype V] in +lemma exists_dart_for_edge (G : SimpleGraph V) (e : G.edgeSet) : + ∃ d : G.Dart, d.edge = e.val := by + obtain ⟨e, he⟩ := e + induction e using Sym2.inductionOn with + | hf x y => exact ⟨⟨(x,y), he⟩, rfl⟩ + +omit [Fintype V] [Fintype W] [Fintype E] in +lemma connectedFibers_of_partition (N : Network W E) (q : W → V) + (B : V → Set W) (hB : ∀ v, (N.graph.induce (B v)).Connected) + (hmem : ∀ w v, q w = v ↔ w ∈ B v) : N.ConnectedFibers q := by + intro x y hxy + let T := N.restrict (Subtype.val : N.internal q → E) + let f : N.graph.induce (B (q x)) →g T.graph := { + toFun := Subtype.val + map_rel' := by + intro a b hab + rcases hab with ⟨hne, e, he⟩ + have ha : q a.val = q x := (hmem _ _).mpr a.property + have hb : q b.val = q x := (hmem _ _).mpr b.property + have hei : e ∈ N.internal q := by + rcases he with ⟨ht, hh⟩ | ⟨ht, hh⟩ + · change q (N.tail e) = q (N.head e) + rw [ht, hh]; exact ha.trans hb.symm + · change q (N.tail e) = q (N.head e) + rw [ht, hh]; exact hb.trans ha.symm + exact ⟨hne, ⟨e, hei⟩, he⟩ } + have hx : x ∈ B (q x) := (hmem x (q x)).mp rfl + have hy : y ∈ B (q x) := (hmem y (q x)).mp hxy.symm + exact ((hB (q x)) ⟨x,hx⟩ ⟨y,hy⟩).map f + +omit [Fintype E] in + +theorem minor_quotient {G : SimpleGraph V} (hG : G.Connected) + (N : Network W E) (hN : N.graph.Connected) (M : MinorModel G N.graph) : + ∃ (q : W → V) (j : G.edgeSet → E), Function.Surjective q ∧ + N.ConnectedFibers q ∧ Function.Injective j ∧ + ((N.mapVertices q).restrict j).Realizes G := by + have : Nonempty V := hG.nonempty + obtain ⟨B, hsub, hconn, hdisj, hcover⟩ := BranchPartition.extend N.graph hN + M.branch M.branch_connected M.branches_disjoint + obtain ⟨q, hq, hmem⟩ := BranchPartition.quotient N.graph B hconn hdisj hcover + choose d hd using exists_dart_for_edge G + have hex (e : G.edgeSet) : ∃ k : E, s(q (N.tail k), q (N.head k)) = e.val := by + obtain ⟨a, ha, b, hb, _, k, hk⟩ := M.adjacency (d e).fst (d e).snd (d e).adj + have ha' : q a = (d e).fst := (hmem _ _).mpr (hsub _ ha) + have hb' : q b = (d e).snd := (hmem _ _).mpr (hsub _ hb) + refine ⟨k, ?_⟩ + rcases hk with ⟨ht, hh⟩ | ⟨ht, hh⟩ + · rw [ht, hh, ha', hb']; exact hd e + · rw [ht, hh, ha', hb', Sym2.eq_swap]; exact hd e + choose j hj using hex + refine ⟨q, j, hq, N.connectedFibers_of_partition q B hconn hmem, ?_, hj⟩ + intro e f hef + apply Subtype.ext + exact (hj e).symm.trans ((congrArg (fun k => s(q (N.tail k), q (N.head k))) hef).trans (hj f)) + +universe uF +variable {F : Type uF} [Fintype F] + +theorem Duality.graphMinor {G : SimpleGraph V} (hG : G.Connected) + (N : Network W E) (D : Network F E) (h : N.Duality D) + (M : MinorModel G N.graph) : + ∃ (P : Network V G.edgeSet) (L : Type uF) (_ : Fintype L) (Q : Network L G.edgeSet), + P.Realizes G ∧ P.Duality Q := by + obtain ⟨q,j,hq,hc,hj,hreal⟩ := minor_quotient hG N h.connected M + have he (e : G.edgeSet) : q (N.tail (j e)) ≠ q (N.head (j e)) := hreal.loopless e + have hPc : ((N.mapVertices q).restrict j).graph.Connected := by + rw [hreal.graph_eq]; exact hG + obtain ⟨L, hL, Q, hQ⟩ := h.minor N D q hq hc j hj he hPc + exact ⟨_, L, hL, Q, hreal, hQ⟩ + +end +end Barnette.Network + +namespace Barnette.PlaneEmbedding +noncomputable section +open scoped Classical +variable {V : Type*} [Fintype V] {G : SimpleGraph V} + +theorem exists_exact_dual (E : PlaneEmbedding G) (hG : G.Connected) : + ∃ (P : Network V G.edgeSet) (F : Type) (_ : Fintype F) (D : Network F G.edgeSet), + P.Realizes G ∧ P.Duality D := by + obtain ⟨M⟩ := E.exists_lattice_minor_model + obtain ⟨r, ⟨M'⟩⟩ := RectangularDual.lattice_minor_in_rectangle M + exact (RectangularDual.grid_duality (2*r) (2*r)).graphMinor hG _ _ M' +end +end Barnette.PlaneEmbedding + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/FlowCircuits.lean b/lean/OAI/Combinatorics/Hamiltonian/FlowCircuits.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb13a2d975f55e4390339421a194c6a2f55327a7 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/FlowCircuits.lean @@ -0,0 +1,360 @@ +import OAI.Combinatorics.Hamiltonian.CutSpaces + +namespace OAI + +/-! Minimal flow circuits, triangular faces, and simple cycle coordinates. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +structure FlowCircuit (x : E → ℝ) : Prop where + conserved : N.boundary x = 0 + nonzero : x ≠ 0 + minimal : ∀ y, N.boundary y = 0 → N.flowSupport y ⊆ N.flowSupport x → + y = 0 ∨ N.flowSupport y = N.flowSupport x + +omit [Fintype V] in +lemma flowSupport_eq_empty_iff (x : E → ℝ) : N.flowSupport x = ∅ ↔ x = 0 := by + simp only [Finset.eq_empty_iff_forall_notMem, mem_flowSupport, not_not, + funext_iff, Pi.zero_apply] + +omit [Fintype V] [Fintype F] in +lemma Duality.dual_conserved_gradient (h : N.Duality D) (f : V → ℝ) : + D.boundary (N.gradient f) = 0 := by + have hh : N.gradient f ∈ N.gradient.range := ⟨f,rfl⟩ + rwa [← h.dual_cycles_eq_cuts] at hh + +omit [Fintype V] [Fintype F] in +lemma Duality.gradient_of_dual_conserved (h : N.Duality D) {x : E → ℝ} + (hx : D.boundary x = 0) : ∃ f, N.gradient f = x := by + have hh : x ∈ D.boundary.ker := hx + rwa [h.dual_cycles_eq_cuts] at hh + +omit [Fintype V] [Fintype F] in + +theorem Duality.circuit_two_levels (h : N.Duality D) (x : E → ℝ) + (hx : D.FlowCircuit x) (f : V → ℝ) (hf : N.gradient f = x) + {e : E} (he : x e ≠ 0) : + ∀ v, f v = f (N.tail e) ∨ f v = f (N.head e) := by + have he' : f (N.head e) ≠ f (N.tail e) := by + simpa only [← hf, gradient_apply, sub_ne_zero] using he + intro v + by_contra hv + obtain ⟨hvt,hvh⟩ := not_or.mp hv + let g : V → ℝ := fun w => if f w = f v then 1 else 0 + have hgsub : D.flowSupport (N.gradient g) ⊆ D.flowSupport x := by + intro k hk + apply (D.mem_flowSupport x k).mpr + intro hxk + have hfk : f (N.head k) = f (N.tail k) := by + apply sub_eq_zero.mp + simpa only [← hf, gradient_apply] using hxk + have hgk : N.gradient g k = 0 := by simp only [gradient_apply, g, hfk, sub_self] + exact (D.mem_flowSupport _ k).mp hk hgk + have hg : N.gradient g ≠ 0 := by + intro hg + have hh := N.gradient_zero_reachable hg (h.connected v (N.tail e)) + have htv : f (N.tail e) ≠ f v := Ne.symm hvt + norm_num [g,htv] at hh + have hgs := (hx.minimal (N.gradient g) (h.dual_conserved_gradient N D g) hgsub).resolve_left hg + have hek : N.gradient g e ≠ 0 := (D.mem_flowSupport _ e).mp (by + rw [hgs]; exact (D.mem_flowSupport _ e).mpr he) + have htv : f (N.tail e) ≠ f v := Ne.symm hvt + have hhv : f (N.head e) ≠ f v := Ne.symm hvh + exact hek (by simp [gradient_apply, g, htv, hhv]) + +omit [Fintype F] in + +theorem Duality.circuit_cut (h : N.Duality D) (x : E → ℝ) + (hx : D.FlowCircuit x) (root : V) : + ∃ (A : Finset V) (c : ℝ), A.Nonempty ∧ root ∉ A ∧ c ≠ 0 ∧ + x = c • N.gradient (fun v => if v ∈ A then 1 else 0) ∧ + N.cut A = D.flowSupport x := by + obtain ⟨f,hf⟩ := h.gradient_of_dual_conserved N D hx.conserved + obtain ⟨e,he⟩ : ∃ e, x e ≠ 0 := by + by_contra hn + apply hx.nonzero + ext e + exact not_not.mp (fun he => hn ⟨e,he⟩) + have he' : f (N.head e) ≠ f (N.tail e) := by + simpa only [← hf, gradient_apply, sub_ne_zero] using he + have hall := h.circuit_two_levels N D x hx f hf he + let a := f root + let b := if a = f (N.tail e) then f (N.head e) else f (N.tail e) + have hab : b ≠ a := by + dsimp [b,a] + split_ifs with ha + · rw [ha]; exact he' + · exact Ne.symm ha + have hlevels (v : V) : f v = a ∨ f v = b := by + dsimp [b,a] at ⊢ + rcases hall root with ht | hh + · rw [ite_eq_left ht,ht]; exact hall v + · have ht : f root ≠ f (N.tail e) := hh ▸ he' + rw [ite_eq_right ht,hh] + exact (hall v).symm + have hb : ∃ v, f v = b := by + dsimp [b] + split_ifs + · exact ⟨N.head e,rfl⟩ + · exact ⟨N.tail e,rfl⟩ + let A := Finset.univ.filter fun v => f v = b + have fform (v : V) : f v = a + (b-a) * (if v ∈ A then 1 else 0) := by + rcases hlevels v with hv | hv + · have hvA : v ∉ A := by simp [A,hv,Ne.symm hab] + simp [hvA,hv] + · have hvA : v ∈ A := by simp [A,hv] + simp [hvA,hv] + refine ⟨A,b-a,?_,?_,sub_ne_zero.mpr hab,?_,?_⟩ + · obtain ⟨v,hv⟩ := hb; exact ⟨v,by simp [A,hv]⟩ + · simp [A,show f root = a from rfl, Ne.symm hab] + · rw [← hf] + ext k + simp only [gradient_apply, Pi.smul_apply, smul_eq_mul] + rw [fform (N.head k), fform (N.tail k)] + ring + · ext k + simp only [mem_cut, mem_flowSupport, ← hf, gradient_apply, sub_ne_zero] + rw [fform (N.head k), fform (N.tail k)] + by_cases ht : N.tail k ∈ A <;> by_cases hh : N.head k ∈ A <;> + simp [ht,hh,hab,Ne.symm hab] + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] in +def star (v : V) : Finset E := Finset.univ.filter fun e => N.Incident e v + +omit [Fintype V] in +@[simp] lemma mem_star (e : E) (v : V) : e ∈ N.star v ↔ N.Incident e v := by + simp [star] + +omit [Fintype V] in +def otherEnd (e : E) (v : V) : V := if N.tail e = v then N.head e else N.tail e + +omit [Fintype V] [Fintype E] in +lemma otherEnd_spec (h : N.Simple) {e : E} {v : V} (hi : N.Incident e v) : + v ≠ N.otherEnd e v ∧ s(N.tail e,N.head e) = s(v,N.otherEnd e v) := by + rcases hi with ht | hh + · rw [otherEnd,ite_eq_left ht] + exact ⟨ht ▸ h.loopless e, by rw [ht]⟩ + · by_cases ht : N.tail e = v + · exact (h.loopless e (ht.trans hh.symm)).elim + · rw [otherEnd,ite_eq_right ht] + exact ⟨hh ▸ (h.loopless e).symm, by rw [hh,Sym2.eq_swap]⟩ + +omit [Fintype V] [Fintype E] in +lemma otherEnd_adj (h : N.Simple) {e : E} {v : V} (hi : N.Incident e v) : + N.graph.Adj v (N.otherEnd e v) := by + obtain ⟨hne,he⟩ := N.otherEnd_spec h hi + exact ⟨hne,e,Sym2.eq_iff.mp he⟩ + +lemma card_star (h : N.Simple) (v : V) : (N.star v).card = N.graph.degree v := by + let f : {e // e ∈ N.star v} → N.graph.neighborSet v := fun e => + ⟨N.otherEnd e.val v, N.otherEnd_adj h ((N.mem_star _ _).mp e.property)⟩ + have hf : Function.Bijective f := by + constructor + · intro e k hek + apply Subtype.ext + apply h.pair_injective + change s(N.tail e.val, N.head e.val) = s(N.tail k.val, N.head k.val) + rw [(N.otherEnd_spec h ((N.mem_star _ _).mp e.property)).2, + (N.otherEnd_spec h ((N.mem_star _ _).mp k.property)).2] + exact congrArg (fun w => s(v,w)) (congrArg Subtype.val hek) + · intro w + obtain ⟨hne,e,he⟩ := w.property + have hi : N.Incident e v := he.elim (fun h => Or.inl h.1) (fun h => Or.inr h.2) + refine ⟨⟨e,(N.mem_star _ _).mpr hi⟩,Subtype.ext ?_⟩ + change N.otherEnd e v = w.val + rcases he with ⟨ht,hh⟩ | ⟨ht,hh⟩ + · simp only [otherEnd,ht,ite_true,hh] + · have ht' : N.tail e ≠ v := by rw [ht]; exact hne.symm + rw [otherEnd,ite_eq_right ht',ht] + have hh := Fintype.card_congr (Equiv.ofBijective f hf) + simpa only [Fintype.card_coe, SimpleGraph.card_neighborSet_eq_degree] using hh + +omit [Fintype V] [Fintype F] in +lemma gradient_indicator_support (h : N.Simple) (v : V) : + D.flowSupport (N.gradient (fun w => if w = v then 1 else 0)) = N.star v := by + ext e + simp only [mem_flowSupport, mem_star, gradient_apply, Incident] + have hne := h.loopless e + by_cases ht : N.tail e = v <;> by_cases hh : N.head e = v <;> simp [ht,hh] at * + +omit [Fintype F] in + +theorem Duality.cubic_face_triangles (h : N.Duality D) (hN : N.Simple) + (h3 : ThreeVertexConnected N.graph) (hV : 5 ≤ Fintype.card V) + (hc : N.graph.IsRegularOfDegree 3) : ∀ v, Nonempty (D.Triangle (N.star v)) := by + intro v + have hD := h.simple_dual N D h3 hV + have hx := h.dual_conserved_gradient N D (fun w => if w = v then 1 else 0) + have hs : (D.flowSupport (N.gradient (fun w => if w = v then 1 else 0))).card = 3 := by + rw [N.gradient_indicator_support D hN, N.card_star hN, hc v] + simpa only [N.gradient_indicator_support D hN] using D.triangle_of_flow hD _ hx hs + +end +end Barnette.Network +namespace Barnette + +open Fin.NatCast + +theorem cyclic_propagation {n : ℕ} [NeZero n] (P : Fin n → Prop) + (hstep : ∀ i, P (i + 1) → P i) {q : Fin n} (hq : P q) : ∀ i, P i := by + have h : ∀ k : ℕ, P (q - (k : Fin n)) := by + intro k + induction k with + | zero => simpa using hq + | succ k hk => + apply hstep (q - ((k + 1 : ℕ) : Fin n)) + simpa only [Nat.cast_add, Nat.cast_one, sub_add_eq_sub_sub, sub_add_cancel] using hk + intro i + simpa only [Fin.cast_val_eq_self, sub_sub_cancel] using h (q - i).val + +theorem cyclic_one_ne_zero (n : ℕ) : (1 : Fin (n + 3)) ≠ 0 := by + intro h + have := congrArg Fin.val h + simp at this + +theorem cyclic_two_ne_zero (n : ℕ) : (2 : Fin (n + 3)) ≠ 0 := by + intro h + have := congrArg Fin.val h + simp [Nat.mod_eq_of_lt (show 2 < n + 3 by omega)] at this + +structure CycleCoordinates {V : Type*} (G : SimpleGraph V) where + n : ℕ + vertex : Fin (n + 3) ↪ V + adjacent : ∀ i, G.Adj (vertex i) (vertex (i + 1)) + +namespace CycleCoordinates + +variable {V : Type*} {G : SimpleGraph V} (C : CycleCoordinates G) + +theorem edge_indices_unique (i j : Fin (C.n + 3)) + (h : (C.vertex i = C.vertex j ∧ C.vertex (i + 1) = C.vertex (j + 1)) ∨ + (C.vertex i = C.vertex (j + 1) ∧ C.vertex (i + 1) = C.vertex j)) : i = j := by + rcases h with h | h + · exact C.vertex.injective h.1 + · have hi := C.vertex.injective h.1 + have hj := C.vertex.injective h.2 + have hh : (2 : Fin (C.n + 3)) = 0 := by + have : j + (1 + 1) = j + 0 := by simpa [hi, add_assoc] using hj + simpa only [show (1 : Fin (C.n + 3)) + 1 = 2 by + apply Fin.ext + simp [Fin.val_add, Nat.mod_eq_of_lt (show 2 < C.n + 3 by omega)]] using (add_left_cancel this) + exact (cyclic_two_ne_zero C.n hh).elim + +theorem tail_orientation {A : Type*} (face : Fin (C.n + 3) ↪ A) + (tail : A → V) (htail : Function.Injective tail) + (hend : ∀ i, tail (face i) = C.vertex i ∨ tail (face i) = C.vertex (i + 1)) : + (∀ i, tail (face i) = C.vertex i) ∨ + (∀ i, tail (face i) = C.vertex (i + 1)) := by + classical + by_cases h : ∃ q, tail (face q) = C.vertex q + · obtain ⟨q, hq⟩ := h + left + apply cyclic_propagation (fun i => tail (face i) = C.vertex i) _ hq + intro i hi + rcases hend i with h | h + · exact h + · have heq : face i = face (i + 1) := htail (h.trans hi.symm) + have hi1 := face.injective heq + have hbad : (1 : Fin (C.n + 3)) = 0 := by + exact add_left_cancel (by simpa using hi1.symm : i + 1 = i + 0) + exact (cyclic_one_ne_zero C.n hbad).elim + · right + intro i + exact (hend i).resolve_left (fun hi => h ⟨i, hi⟩) + +end CycleCoordinates +end Barnette + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] + (N : Network V E) (C : Barnette.CycleCoordinates N.graph) + +omit [Fintype V] [Fintype E] in +def cycleEdge (i : Fin (C.n+3)) : E := (C.adjacent i).2.choose + +omit [Fintype V] [Fintype E] in +lemma cycleEdge_ends (i : Fin (C.n+3)) : + s(N.tail (N.cycleEdge C i),N.head (N.cycleEdge C i)) = s(C.vertex i,C.vertex (i+1)) := + Sym2.eq_iff.mpr (C.adjacent i).2.choose_spec + +omit [Fintype V] [Fintype E] in +lemma cycleEdge_injective : Function.Injective (N.cycleEdge C) := by + intro i j hij + apply C.edge_indices_unique i j + apply Sym2.eq_iff.mp + rw [← N.cycleEdge_ends C i, ← N.cycleEdge_ends C j, hij] + +omit [Fintype V] [Fintype E] in +lemma cycleEdge_incident (i : Fin (C.n+3)) (v : V) : + N.Incident (N.cycleEdge C i) v ↔ v = C.vertex i ∨ v = C.vertex (i+1) := by + rw [N.incident_iff_mem_pair, N.cycleEdge_ends] + exact Sym2.mem_iff + +omit [Fintype V] [Fintype E] in +def cycleEdges : Finset E := Finset.univ.image (N.cycleEdge C) + +omit [Fintype V] [Fintype E] in +@[simp] lemma mem_cycleEdges (e : E) : e ∈ N.cycleEdges C ↔ ∃ i, N.cycleEdge C i = e := by + simp [cycleEdges] + +omit [Fintype V] in + +lemma cycle_support_minimal (hN : N.Simple) (y : E → ℝ) (hy : N.boundary y = 0) + (hsub : N.flowSupport y ⊆ N.cycleEdges C) (hne : y ≠ 0) : + N.flowSupport y = N.cycleEdges C := by + have hs : (N.flowSupport y).Nonempty := Finset.nonempty_iff_ne_empty.mpr (by + exact fun h => hne ((N.flowSupport_eq_empty_iff y).mp h)) + obtain ⟨e,he⟩ := hs + obtain ⟨q,hq⟩ := (N.mem_cycleEdges C e).mp (hsub he) + have hq' : y (N.cycleEdge C q) ≠ 0 := by rw [hq]; exact (N.mem_flowSupport _ _).mp he + have hall : ∀ i, y (N.cycleEdge C i) ≠ 0 := by + apply Barnette.cyclic_propagation (fun i => y (N.cycleEdge C i) ≠ 0) _ hq' + intro i hi + have hv : N.Incident (N.cycleEdge C (i+1)) (C.vertex (i+1)) := + (N.cycleEdge_incident C _ _).mpr (Or.inl rfl) + obtain ⟨f,hfe,hyf,hfv⟩ := N.flow_no_leaf hN y hy hi hv + obtain ⟨j,rfl⟩ := (N.mem_cycleEdges C f).mp (hsub ((N.mem_flowSupport y f).mpr hyf)) + rcases (N.cycleEdge_incident C j _).mp hfv with hj | hj + · have hj' := C.vertex.injective hj + exact (hfe (congrArg (N.cycleEdge C) hj'.symm)).elim + · have hj' := add_right_cancel (C.vertex.injective hj) + simpa only [← hj'] using hyf + apply Finset.Subset.antisymm hsub + intro e he + obtain ⟨i,rfl⟩ := (N.mem_cycleEdges C e).mp he + exact (N.mem_flowSupport y _).mpr (hall i) + +omit [Fintype V] in +lemma flowCircuit_of_cycle (hN : N.Simple) (x : E → ℝ) + (hx : N.boundary x = 0) (hs : N.flowSupport x = N.cycleEdges C) : N.FlowCircuit x := by + have hcs : (N.cycleEdges C).Nonempty := ⟨N.cycleEdge C 0, by simp⟩ + refine ⟨hx,?_,?_⟩ + · intro hz; subst x + have he := (N.flowSupport_eq_empty_iff 0).mpr rfl + rw [he] at hs + exact hcs.ne_empty hs.symm + · intro y hy hsub + by_cases hzero : y = 0 + · exact Or.inl hzero + · right + rw [hs] at hsub ⊢ + exact N.cycle_support_minimal C hN y hy hsub hzero + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Forest.lean b/lean/OAI/Combinatorics/Hamiltonian/Forest.lean new file mode 100644 index 0000000000000000000000000000000000000000..b390bee308ef1d024d0d612706f86bcd1f574050 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Forest.lean @@ -0,0 +1,295 @@ +import OAI.Combinatorics.Hamiltonian.PairPolynomials + +namespace OAI + +/-! Common-phase nonvanishing and forest extraction from actual states. -/ + +namespace Barnette +noncomputable section +open scoped Classical + +structure PermutationCoordinates {A : Type*} (p : Equiv.Perm A) (a : A) where + n : ℕ + face : Fin (n+3) ↪ A + step : ∀ i, face (i+1) = p (face i) + range_eq : Set.range face = {b | p.SameCycle a b} + +lemma permutationCoordinates_exists {A : Type*} [Finite A] (p : Equiv.Perm A) (a : A) + (h1 : p a ≠ a) (h2 : p (p a) ≠ a) : Nonempty (PermutationCoordinates p a) := by + have hp : 0 < Function.minimalPeriod p a := + Function.minimalPeriod_pos_of_mem_periodicPts (p.injective.mem_periodicPts a) + have hp1 : Function.minimalPeriod p a ≠ 1 := by + intro hh + have hh' := Function.iterate_minimalPeriod (f := (p : A → A)) (x := a) + rw [hh] at hh' + exact h1 (by simpa using hh') + have hp2 : Function.minimalPeriod p a ≠ 2 := by + intro hh + have hh' := Function.iterate_minimalPeriod (f := (p : A → A)) (x := a) + rw [hh] at hh' + exact h2 (by simpa [Function.iterate_succ_apply] using hh') + let n := Function.minimalPeriod p a - 3 + have hn : n+3 = Function.minimalPeriod p a := by omega + let f : Fin (n+3) → A := fun i => (p : A → A)^[i.val] a + have hf : Function.Injective f := by + intro i j hij + apply Fin.ext + exact Function.iterate_injOn_Iio_minimalPeriod (by simpa only [← hn, Set.mem_Iio] using i.isLt) + (by simpa only [← hn, Set.mem_Iio] using j.isLt) hij + refine ⟨⟨n,⟨f,hf⟩,?_,?_⟩⟩ + · intro i + change (p : A → A)^[(i+1).val] a = p ((p : A → A)^[i.val] a) + have hval : (i+1).val = (i.val+1) % Function.minimalPeriod p a := by + rw [Fin.val_add] + simp only [Fin.val_one,hn] + rw [hval,Function.iterate_mod_minimalPeriod_eq,Function.iterate_succ_apply'] + · ext b + constructor + · rintro ⟨i,rfl⟩ + change p.SameCycle a ((p : A → A)^[i.val] a) + rw [← Equiv.Perm.coe_pow] + exact (Equiv.Perm.SameCycle.refl p a).pow_right + · intro hb + obtain ⟨m,hm⟩ := hb.exists_nat_pow_eq + refine ⟨⟨m % Function.minimalPeriod p a,by rw [hn]; exact Nat.mod_lt _ hp⟩,?_⟩ + change (p : A → A)^[m % Function.minimalPeriod p a] a = b + rw [Function.iterate_mod_minimalPeriod_eq,← Equiv.Perm.coe_pow,hm] + +namespace TriangleSystem.Pair +variable {A V : Type*} {T : TriangleSystem A V} {X : Set V} + +lemma next_next_ne (P : @Pair A V T X) (t : A) : P.next (P.next t) ≠ t := by + intro hh + have hrt : P.left.val t ≠ P.right.val t := fun he => + P.partner t ((State.value_eq_iff _ _ _).mpr he) + have hru : P.right.val (P.next t) ≠ P.left.val (P.next t) := fun he => + P.partner (P.next t) ((State.value_eq_iff _ _ _).mpr he.symm) + have hx : T.vertex t (P.left.val t) = T.vertex (P.next t) (P.right.val (P.next t)) := by + change P.left.value t = P.right.value (P.next t) + rw [← P.value_next,hh] + have hy : T.vertex t (P.right.val t) = T.vertex (P.next t) (P.left.val (P.next t)) := + (P.value_next t).symm + exact P.next_ne t (T.edge_unique _ _ _ _ _ _ hrt hru hx hy).symm + +variable [Fintype A] + +def cycleCoordinates (P : @Pair A V T X) (a : A) : PermutationCoordinates P.next a := + (permutationCoordinates_exists P.next a (P.next_ne a) (P.next_next_ne a)).some + +lemma cycleCoordinates_faces (P : @Pair A V T X) (c : CycleClass P.next) (a : A) + (ha : classOf P.next a = c) : + Finset.univ.image (P.cycleCoordinates a).face = P.cycleFaces c := by + ext b + simp only [Finset.mem_image,Finset.mem_univ,true_and,mem_cycleFaces] + change b ∈ Set.range (P.cycleCoordinates a).face ↔ _ + rw [(P.cycleCoordinates a).range_eq] + change P.next.SameCycle a b ↔ _ + rw [← classOf_eq_iff,ha] + exact eq_comm + +end TriangleSystem.Pair +end +end Barnette +namespace Barnette.Network.ColoredDual +noncomputable section +open scoped Classical +open Barnette.TriangleSystem +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + {N : Network V E} {D : Network F E} (M : N.ColoredDual D) {root : V} + +def pairedCycle (P : (M.system root).Pair (M.nonroots root)) (a : M.Black root) : + M.StateCycle P.left where + cycle := + { n := (P.cycleCoordinates a).n + vertex := ⟨fun i => P.left.value ((P.cycleCoordinates a).face i), + P.left.value_injective.comp (P.cycleCoordinates a).face.injective⟩ + adjacent := by + intro i + let t := (P.cycleCoordinates a).face i + have ht : P.left.value ((P.cycleCoordinates a).face (i+1)) = P.right.value t := by + rw [(P.cycleCoordinates a).step,P.value_next] + change D.graph.Adj (P.left.value t) (P.left.value ((P.cycleCoordinates a).face (i+1))) + rw [ht] + have hij : P.left.val t ≠ P.right.val t := fun hh => + P.partner t ((State.value_eq_iff _ _ _).mpr hh) + exact ⟨P.partner t,(M.face t.val).side D (P.left.val t) (P.right.val t), + Sym2.eq_iff.mp ((M.face t.val).side_ends D hij)⟩ } + face := (P.cycleCoordinates a).face + corner i := P.right.val ((P.cycleCoordinates a).face i) + left_eq _ := rfl + right_eq i := by + change P.right.value ((P.cycleCoordinates a).face i) = + P.left.value ((P.cycleCoordinates a).face (i+1)) + rw [(P.cycleCoordinates a).step,P.value_next] + +omit [Fintype F] in +lemma pairedCycle_delta (P : (M.system root).Pair (M.nonroots root)) + (c : Barnette.CycleClass P.next) (a : M.Black root) (ha : Barnette.classOf P.next a = c) : + (M.pairedCycle P a).delta = P.cycleDelta c := by + let : DecidableEq (M.Black root) := Classical.decEq _ + change (∑ i, indexDelta (P.left.val ((P.cycleCoordinates a).face i)) + (P.right.val ((P.cycleCoordinates a).face i))) = + ∑ t ∈ P.cycleFaces c, indexDelta (P.left.val t) (P.right.val t) + rw [← P.cycleCoordinates_faces c a ha] + exact (Finset.sum_image (f := fun t => indexDelta (P.left.val t) (P.right.val t)) + (s := Finset.univ) (P.cycleCoordinates a).face.injective.injOn).symm + +omit [Fintype F] in +lemma pairedCycle_slope (P : (M.system root).Pair (M.nonroots root)) + (c : Barnette.CycleClass P.next) (a : M.Black root) (ha : Barnette.classOf P.next a = c) + (α : E → ℝ) : + (M.pairedCycle P a).slope α = P.cycleSlope (M.weights α root) c := by + let : DecidableEq (M.Black root) := Classical.decEq _ + change (∑ i, (M.weights α root ((P.cycleCoordinates a).face i) + (P.right.val ((P.cycleCoordinates a).face i)) - + M.weights α root ((P.cycleCoordinates a).face i) + (P.left.val ((P.cycleCoordinates a).face i)))) = + (∑ t ∈ P.cycleFaces c, M.weights α root t (P.right.val t)) - + (∑ t ∈ P.cycleFaces c, M.weights α root t (P.left.val t)) + rw [← P.cycleCoordinates_faces c a ha,Finset.sum_sub_distrib] + congr 1 + · exact (Finset.sum_image (f := fun t => M.weights α root t (P.right.val t)) + (s := Finset.univ) (P.cycleCoordinates a).face.injective.injOn).symm + · exact (Finset.sum_image (f := fun t => M.weights α root t (P.left.val t)) + (s := Finset.univ) (P.cycleCoordinates a).face.injective.injOn).symm + +lemma paired_sign (P : (M.system root).Pair (M.nonroots root)) + (c : Barnette.CycleClass P.next) (α : E → ℝ) + (hα : N.boundary α = whiteCharge M.black root) : + (P.cycleDelta c = -3 ∧ 0 < P.cycleSlope (M.weights α root) c) ∨ + (P.cycleDelta c = 3 ∧ P.cycleSlope (M.weights α root) c < 0) := by + obtain ⟨a,ha⟩ := Barnette.classOf_surjective P.next c + have hh := (M.pairedCycle P a).signed α hα + rwa [M.pairedCycle_delta P c a ha,M.pairedCycle_slope P c a ha α] at hh + +omit [Fintype F] in +lemma opposite_forward_end {s r : M.State root} (C : (M.system root).OppositeCycle s) + (hrs : (M.system root).Partner r s) + (hf : ∀ i, r.value (C.face i) = C.cycle.vertex i) (i : Fin (C.cycle.n+3)) : + (M.system root).vertex (C.face i) (thirdIndex (r.val (C.face i)) (s.val (C.face i))) = + C.cycle.vertex (i+1) := by + rcases C.partner_endpoints hrs i with ⟨_,he⟩ | ⟨he,_⟩ + · exact he + · exact ((C.cycle.adjacent i).1 ((hf i).symm.trans he)).elim + +def oppositeForward {s r : M.State root} (C : (M.system root).OppositeCycle s) + (hrs : (M.system root).Partner r s) + (hf : ∀ i, r.value (C.face i) = C.cycle.vertex i) : M.StateCycle r where + cycle := + { n := C.cycle.n + vertex := C.cycle.vertex + adjacent i := by + have hij : r.val (C.face i) ≠ thirdIndex (r.val (C.face i)) (s.val (C.face i)) := + (thirdIndex_distinct _ _ (fun hh => hrs _ ((State.value_eq_iff _ _ _).mpr hh))).1.symm + have he := (M.face (C.face i).val).side_ends D hij + change s(D.tail _,D.head _) = s(r.value (C.face i), + (M.system root).vertex (C.face i) (thirdIndex (r.val (C.face i)) (s.val (C.face i)))) at he + rw [hf,M.opposite_forward_end C hrs hf] at he + exact ⟨(C.cycle.adjacent i).1,_,Sym2.eq_iff.mp he⟩ } + face := C.face + corner i := thirdIndex (r.val (C.face i)) (s.val (C.face i)) + left_eq := hf + right_eq := M.opposite_forward_end C hrs hf + +omit [Fintype F] in +lemma oppositeForward_delta {s r : M.State root} (C : (M.system root).OppositeCycle s) + (hrs : (M.system root).Partner r s) + (hf : ∀ i, r.value (C.face i) = C.cycle.vertex i) : + (M.oppositeForward C hrs hf).delta = C.cyclicDelta r := rfl + +lemma opposite_disk {s : M.State root} (C : (M.system root).OppositeCycle s) + (r : (M.system root).Partners s) (α : E → ℝ) + (hα : N.boundary α = whiteCharge M.black root) : + C.cyclicDelta r.val = 3 ∨ C.cyclicDelta r.val = -3 := by + rcases C.partner_orientation r.property with hf | hb + · have hs := (M.oppositeForward C r.property hf).signed α hα + rw [M.oppositeForward_delta] at hs + exact hs.elim (fun h => Or.inr h.1) (fun h => Or.inl h.1) + · let r' := C.reverse r.val r.property + have hrs' : (M.system root).Partner r' s := C.reverse_partner r.val r.property + have hf : ∀ i, r'.value (C.face i) = C.cycle.vertex i := by + intro i + have hr : r'.value (C.face i) = (M.system root).vertex (C.face i) + (thirdIndex (r.val.val (C.face i)) (s.val (C.face i))) := by + change (M.system root).vertex _ (C.changedCorners r.val (C.face i)) = _ + rw [C.changedCorners_image] + rw [hr] + rcases C.partner_endpoints r.property i with ⟨he,_⟩ | ⟨_,he⟩ + · exact ((C.cycle.adjacent i).1 (he.symm.trans (hb i))).elim + · exact he + have hδ : C.cyclicDelta r' = -C.cyclicDelta r.val := by + unfold OppositeCycle.cyclicDelta + rw [← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro i _ + change indexDelta (C.changedCorners r.val (C.face i)) + (thirdIndex (C.changedCorners r.val (C.face i)) (s.val (C.face i))) = _ + rw [C.changedCorners_image,thirdIndex_involution,indexDelta_antisymm] + have hs := (M.oppositeForward C hrs' hf).signed α hα + rw [M.oppositeForward_delta,hδ] at hs + rcases hs with ⟨hs,_⟩ | ⟨hs,_⟩ + · left; omega + · right; omega + +theorem forest_pair (hex : Nonempty ((M.system root).Pair (M.nonroots root))) : + ∃ P : (M.system root).Pair (M.nonroots root), ((M.system root).oppositeGraph P.right).IsAcyclic := by + obtain ⟨α,hα⟩ := N.boundary_of_sum_zero M.duality.connected + (whiteCharge M.black root) (whiteCharge_sum M.black root) + exact Pair.forest_pair_of_disk_circulation hex + (fun _ C r => M.opposite_disk C r α hα) (M.weights α root) + (fun P c => M.paired_sign P c α hα) + +end +end Barnette.Network.ColoredDual +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) +omit [Fintype V] [Fintype E] in +lemma connected_of_kernel_constants [Nonempty V] + (hc : ∀ f : V → ℝ, N.gradient f = 0 → ∀ v w, f v = f w) : N.graph.Connected := by + rw [SimpleGraph.connected_iff] + refine ⟨?_, inferInstance⟩ + intro v w + by_contra hw + let f : V → ℝ := fun z => if N.graph.Reachable v z then 1 else 0 + have hf : N.gradient f = 0 := by + apply (N.gradient_eq_zero_iff f).mpr + intro e + have he := N.edge_reachable e + have hh : N.graph.Reachable v (N.head e) ↔ N.graph.Reachable v (N.tail e) := + ⟨fun h => h.trans he.symm, fun h => h.trans he⟩ + simp only [f, hh] + have he := hc f hf v w + simp [f, hw] at he + +variable {F : Type*} [Fintype F] +abbrev Components (H : Network F E) := H.graph.ConnectedComponent + +instance componentsFintype (H : Network F E) : Fintype H.Components := Fintype.ofFinite _ + +def componentMap (H : Network F E) : F → H.Components := H.graph.connectedComponentMk + +omit [Fintype E] [Fintype F] in +lemma componentMap_surjective (H : Network F E) : Function.Surjective H.componentMap := by + intro c + induction c using SimpleGraph.ConnectedComponent.ind with + | h f => exact ⟨f, rfl⟩ + +omit [Fintype E] [Fintype F] in +lemma gradient_componentMap (H : Network F E) (f : H.Components → ℝ) : + H.gradient (pull H.componentMap f) = 0 := by + apply (H.gradient_eq_zero_iff _).mpr + intro e + exact congrArg f (SimpleGraph.ConnectedComponent.sound (H.edge_reachable e)).symm + +omit [Fintype E] [Fintype F] in +lemma descends_components (H : Network F E) (g : F → ℝ) (hg : H.gradient g = 0) : + ∃ f : H.Components → ℝ, pull H.componentMap f = g := by + refine ⟨Quot.lift g (fun v w h => H.gradient_zero_reachable hg h), ?_⟩ + rfl + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/ForestMatching.lean b/lean/OAI/Combinatorics/Hamiltonian/ForestMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..48a3f13cd45b3121f778f6b48a242ec45ec2f4db --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/ForestMatching.lean @@ -0,0 +1,395 @@ +import OAI.Combinatorics.Hamiltonian.Matching + +namespace OAI + +/-! From opposite forests to connected spanning matching complements. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +omit [Fintype V] [Fintype E] in +lemma complement_coloring (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) : + ∀ e, ¬black (N.tail e) ↔ ¬¬black (N.head e) := fun e => not_congr (hc e) + +omit [Fintype V] [Fintype E] in +lemma colored_endpoints (black : V → Prop) + (_hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (e : E) : + s(N.tail e,N.head e) = s(N.blackEndpoint black e,N.blackEndpoint (fun v => ¬black v) e) := by + by_cases hb : black (N.tail e) + · simp [blackEndpoint,hb] + · simp [blackEndpoint,hb,Sym2.eq_swap] + +lemma black_fiber_count (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (H : Finset E) (T : Finset V) (hT : ∀ v ∈ T, black v) : + (H.filter fun e => N.blackEndpoint black e ∈ T).card = + ∑ v ∈ T, ((N.star v).filter fun e => e ∈ H).card := by + rw [← N.black_edge_partition black hc] + have hf (v : V) (hv : black v) : + (N.star v).filter (fun e => e ∈ H.filter (fun e => N.blackEndpoint black e ∈ T)) = + if v ∈ T then (N.star v).filter (fun e => e ∈ H) else ∅ := by + ext e + by_cases ht : v ∈ T + · simp only [ite_eq_left ht,Finset.mem_filter] + constructor + · tauto + · rintro ⟨he,hh⟩ + exact ⟨he,hh,(N.blackEndpoint_eq black hc hv ((N.mem_star _ _).mp he)) ▸ ht⟩ + · simp only [ite_eq_right ht,Finset.notMem_empty,Finset.mem_filter,iff_false] + rintro ⟨he,_,hbe⟩ + exact ht ((N.blackEndpoint_eq black hc hv ((N.mem_star _ _).mp he)) ▸ hbe) + rw [Finset.sum_congr rfl (fun v hv => congrArg Finset.card (hf v (Finset.mem_filter.mp hv).2))] + simp only [apply_ite Finset.card,Finset.card_empty,Finset.sum_ite_mem] + apply Finset.sum_congr ?_ (fun _ _ => rfl) + ext v + simp only [Finset.mem_inter,Finset.mem_filter,Finset.mem_univ,true_and] + exact ⟨And.right,fun hv => ⟨hT v hv,hv⟩⟩ + +lemma tree_matching (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (H : Finset E) (hi : Function.Injective (N.restrict (Subtype.val : H → E)).boundary) + (root : V) (_hr : black root) + (hd : ∀ v, black v → ((N.star v).filter (fun e => e ∈ H)).card = if v = root then 1 else 2) + (hbal : Fintype.card {v // black v} = Fintype.card {v // ¬black v}) : + ∃ P : Finset E, P ⊆ H ∧ ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1 := by + let B := {v // black v} + let W := {v // ¬black v} + let R : B → W → Prop := fun b w => ∃ e ∈ H, + N.blackEndpoint black e = b.val ∧ N.blackEndpoint (fun v => ¬black v) e = w.val + have hhall (S : Finset B) : S.card ≤ (Finset.univ.filter fun w : W => ∃ b ∈ S, R b w).card := by + let Y := Finset.univ.filter fun w : W => ∃ b ∈ S, R b w + let T := S.image Subtype.val + let Z := Y.image Subtype.val + let J := H.filter fun e => N.blackEndpoint black e ∈ T + have hTc : T.card = S.card := Finset.card_image_of_injective _ Subtype.val_injective + have hZc : Z.card = Y.card := Finset.card_image_of_injective _ Subtype.val_injective + have hT : ∀ v ∈ T, black v := by + intro v hv; obtain ⟨b,_,rfl⟩ := Finset.mem_image.mp hv; exact b.property + have hZ : ∀ v ∈ Z, ¬black v := by + intro v hv; obtain ⟨w,_,rfl⟩ := Finset.mem_image.mp hv; exact w.property + have hdis : Disjoint T Z := Finset.disjoint_left.mpr (fun v ht hz => hZ v hz (hT v ht)) + by_cases hS : S.Nonempty + · have hJc : 2*T.card ≤ J.card + 1 := by + have he := N.black_fiber_count black hc H T hT + have hd' : ∀ v ∈ T, ((N.star v).filter fun e => e ∈ H).card = 2 - if v = root then 1 else 0 := by + intro v hv; rw [hd v (hT v hv)]; split_ifs <;> rfl + have hn (v : V) : (2 - if v = root then 1 else 0 : ℕ) + (if v = root then 1 else 0) = 2 := by split_ifs <;> rfl + have hh : J.card + ∑ v ∈ T, (if v = root then 1 else 0 : ℕ) = 2*T.card := by + rw [he,Finset.sum_congr rfl hd',← Finset.sum_add_distrib] + simp only [hn,Finset.sum_const,smul_eq_mul,mul_comm] + have hx : (∑ v ∈ T, (if v = root then 1 else 0 : ℕ)) ≤ 1 := by simp; split_ifs <;> omega + omega + let J' : Finset H := Finset.univ.filter fun e => e.val ∈ J + have hJ' : J'.card = J.card := by + apply Finset.card_bij (fun e _ => e.val) + · intro e he; exact (Finset.mem_filter.mp he).2 + · intro _ _ _ _ hh; exact Subtype.ext hh + · intro e he; exact ⟨⟨e,(Finset.mem_filter.mp he).1⟩,by simp [J',he],rfl⟩ + have hn : (T ∪ Z).Nonempty := by obtain ⟨b,hb⟩ := hS; exact ⟨b.val,Finset.mem_union_left _ (Finset.mem_image.mpr ⟨b,hb,rfl⟩)⟩ + have hsupp : ∀ e ∈ J', (N.restrict (Subtype.val : H → E)).tail e ∈ T ∪ Z ∧ + (N.restrict (Subtype.val : H → E)).head e ∈ T ∪ Z := by + intro e he + have hJ : e.val ∈ J := (Finset.mem_filter.mp he).2 + have hb : N.blackEndpoint black e.val ∈ T := (Finset.mem_filter.mp hJ).2 + obtain ⟨b,hbS,hbe⟩ := Finset.mem_image.mp hb + let w : W := ⟨N.blackEndpoint (fun v => ¬black v) e.val, + (N.blackEndpoint_spec (fun v => ¬black v) (N.complement_coloring black hc) e.val).1⟩ + have hw : w ∈ Y := by + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,b,hbS,e.val,e.property,hbe.symm,rfl⟩ + have hz : N.blackEndpoint (fun v => ¬black v) e.val ∈ Z := Finset.mem_image.mpr ⟨w,hw,rfl⟩ + rcases Sym2.eq_iff.mp (N.colored_endpoints black hc e.val) with hh|hh + · exact ⟨Finset.mem_union_left _ (hh.1 ▸ hb),Finset.mem_union_right _ (hh.2 ▸ hz)⟩ + · exact ⟨Finset.mem_union_right _ (hh.1 ▸ hz),Finset.mem_union_left _ (hh.2 ▸ hb)⟩ + have hb := (N.restrict (Subtype.val : H → E)).independent_edges_bound hi J' (T ∪ Z) hn hsupp + rw [hJ',Finset.card_union_of_disjoint hdis,hTc,hZc] at hb + rw [hTc] at hJc + change S.card ≤ Y.card + omega + · have hz : S = ∅ := Finset.not_nonempty_iff_eq_empty.mp hS + simp [hz] + obtain ⟨f,hfi,hf⟩ := (Fintype.all_card_le_filter_rel_iff_exists_injective R).mp hhall + have hfs : Function.Surjective f := (Fintype.bijective_iff_injective_and_card f).mpr ⟨hfi,hbal⟩ |>.2 + choose p hp hb hw using hf + let P := Finset.univ.image p + have hpP (b : B) : p b ∈ P := Finset.mem_image.mpr ⟨b,Finset.mem_univ _,rfl⟩ + have hsub : P ⊆ H := by intro e he; obtain ⟨b,_,rfl⟩ := Finset.mem_image.mp he; exact hp b + refine ⟨P,hsub,?_⟩ + intro v + by_cases hv : black v + · let b : B := ⟨v,hv⟩ + apply Finset.card_eq_one.mpr + refine ⟨p b,?_⟩ + ext e + simp only [Finset.mem_filter,Finset.mem_singleton] + constructor + · rintro ⟨he,hP⟩ + obtain ⟨b',_,rfl⟩ := Finset.mem_image.mp hP + have hh : b' = b := Subtype.ext ((hb b').symm.trans (N.blackEndpoint_eq black hc hv ((N.mem_star _ _).mp he))) + rw [hh] + · rintro rfl + have hh : N.blackEndpoint black (p b) = v := hb b + exact ⟨(N.mem_star _ _).mpr (hh ▸ (N.blackEndpoint_spec black hc (p b)).2),hpP b⟩ + · obtain ⟨b,hbv⟩ := hfs ⟨v,hv⟩ + have hwv : N.blackEndpoint (fun v => ¬black v) (p b) = v := (hw b).trans (congrArg Subtype.val hbv) + apply Finset.card_eq_one.mpr + refine ⟨p b,?_⟩ + ext e + simp only [Finset.mem_filter,Finset.mem_singleton] + constructor + · rintro ⟨he,hP⟩ + obtain ⟨b',_,rfl⟩ := Finset.mem_image.mp hP + have hh : f b' = f b := Subtype.ext ((hw b').symm.trans + ((N.blackEndpoint_eq (fun v => ¬black v) (N.complement_coloring black hc) hv ((N.mem_star _ _).mp he)).trans ((congrArg Subtype.val hbv).symm))) + rw [hfi hh] + · rintro rfl + exact ⟨(N.mem_star _ _).mpr (hwv ▸ (N.blackEndpoint_spec (fun v => ¬black v) (N.complement_coloring black hc) (p b)).2),hpP b⟩ +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +omit [Fintype V] in +lemma sum_substars (hN : N.Simple) (P : Finset E) (A : Finset V) : + ∑ v ∈ A, ((N.star v).filter fun e => e ∈ P).card = + ∑ e, if e ∈ P then ((if N.tail e ∈ A then 1 else 0) + (if N.head e ∈ A then 1 else 0)) else 0 := by + calc + _ = ∑ v ∈ A, ∑ e, if e ∈ P then ((if N.tail e = v then 1 else 0) + (if N.head e = v then 1 else 0)) else 0 := by + apply Finset.sum_congr rfl + intro v _ + rw [star,Finset.filter_filter,Finset.card_filter] + simp only [Incident] + apply Finset.sum_congr rfl + intro e _ + have hne := hN.loopless e + by_cases hp : e ∈ P <;> by_cases ht : N.tail e = v <;> by_cases hh : N.head e = v <;> simp_all + _ = _ := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + by_cases hp : e ∈ P <;> simp [hp,Finset.sum_add_distrib] + +lemma matching_cut_balance (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (P : Finset E) (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) + (A : Finset V) (hcut : N.cut A ⊆ P) : + (N.cut A).card = 2*(N.blackCut black A).card := by + have hsum := N.sum_substars hN P A + simp only [hd,Finset.sum_const,smul_eq_mul,mul_one] at hsum + have htotal : A.card + (N.cut A).card = 2*((N.regionEdges A).filter fun e => e ∈ P).card := by + rw [hsum] + simp only [cut,regionEdges,Finset.card_filter,Finset.sum_filter, + ← Finset.sum_add_distrib,Finset.mul_sum] + apply Finset.sum_congr rfl + intro e _ + have hh : (N.tail e ∈ A ∧ N.head e ∉ A ∨ N.head e ∈ A ∧ N.tail e ∉ A) → e ∈ P := by + intro hh; apply hcut; simpa [cut] using hh + by_cases ht : N.tail e ∈ A <;> by_cases hh' : N.head e ∈ A <;> by_cases hp : e ∈ P <;> simp_all + have hbsum := N.sum_substars hN P (A.filter black) + simp only [hd,Finset.sum_const,smul_eq_mul,mul_one] at hbsum + have hblack : (A.filter black).card + (N.cut A).card = + ((N.regionEdges A).filter fun e => e ∈ P).card + (N.blackCut black A).card := by + rw [hbsum] + simp only [cut,regionEdges,blackCut,Finset.card_filter,Finset.mem_filter,Finset.sum_filter, + ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro e _ + have hh : (N.tail e ∈ A ∧ N.head e ∉ A ∨ N.head e ∈ A ∧ N.tail e ∉ A) → e ∈ P := by + intro hh; apply hcut; simpa [cut] using hh + have hc' := hc e + by_cases ht : N.tail e ∈ A <;> by_cases hh' : N.head e ∈ A <;> + by_cases hp : e ∈ P <;> by_cases hb : black (N.tail e) <;> by_cases hw : black (N.head e) <;> + simp_all [blackEndpoint] + have hcub := N.cubic_region_count hN h3 A + have hbcub := N.cubic_black_region_count hN h3 black hc A + omega +end +end Barnette.Network + +namespace Barnette.Network.ColoredDual +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + {N : Network V E} {D : Network F E} (M : N.ColoredDual D) {root : V} + +lemma black_white_balance : Fintype.card {v // M.black v} = Fintype.card {v // ¬M.black v} := by + have hc := M.cubic_cards.2 + rw [Fintype.card_subtype_compl] + simp only [Fintype.card_subtype] + change (Finset.univ.filter M.black).card = Fintype.card V - (Finset.univ.filter M.black).card + omega + +lemma recovery_matching (P : (M.system root).Pair (M.nonroots root)) (hr : M.black root) + (ha : ((M.system root).oppositeGraph P.right).IsAcyclic) (i : Fin 3) : + ∃ S : Finset E, S ⊆ (M.removed P i)ᶜ ∧ ∀ v, ((N.star v).filter fun e => e ∈ S).card = 1 := + N.tree_matching M.black M.coloring _ (M.remainder_independent P hr ha i) root hr + (M.remainder_black_degree P hr i) M.black_white_balance + +end +end Barnette.Network.ColoredDual +namespace Barnette.CycleCoordinates +variable {V : Type*} {G : SimpleGraph V} (C : Barnette.CycleCoordinates G) +abbrev reverseCycle : Barnette.CycleCoordinates G where + n := C.n + vertex := ⟨fun i => C.vertex (-i),fun _ _ h => neg_injective (C.vertex.injective h)⟩ + adjacent i := by + have hh := (C.adjacent (-i-1)).symm + change G.Adj (C.vertex (-i)) (C.vertex (-(i+1))) + rw [sub_add_cancel,show -i-1 = -(i+1) by abel] at hh + exact hh +end Barnette.CycleCoordinates + +namespace Barnette.Network +noncomputable section +variable {V E : Type*} (N : Network V E) +lemma directed_cycle_of_not_acyclic (ht : Function.Injective N.tail) (hn : ¬N.graph.IsAcyclic) : + ∃ (C : Barnette.CycleCoordinates N.graph) (e : Fin (C.n+3) → E), + ∀ i, N.tail (e i) = C.vertex i ∧ N.head (e i) = C.vertex (i+1) := by + obtain ⟨C⟩ := Barnette.cycleCoordinates_of_not_acyclic hn + let e : Fin (C.n+3) ↪ E := ⟨N.cycleEdge C,N.cycleEdge_injective C⟩ + have he (i) : (N.tail (e i) = C.vertex i ∧ N.head (e i) = C.vertex (i+1)) ∨ + (N.tail (e i) = C.vertex (i+1) ∧ N.head (e i) = C.vertex i) := + Sym2.eq_iff.mp (N.cycleEdge_ends C i) + rcases C.tail_orientation e N.tail ht (fun i => (he i).elim (Or.inl ∘ And.left) (Or.inr ∘ And.left)) with hf|hb + · refine ⟨C,e,fun i => ⟨hf i,?_⟩⟩ + rcases he i with h|h + · exact h.2 + · exact ((C.adjacent i).1 ((hf i).symm.trans h.1)).elim + · refine ⟨C.reverseCycle,fun i => e (-i-1),fun i => ?_⟩ + have hh : N.head (e (-i-1)) = C.vertex (-i-1) := by + rcases he (-i-1) with h|h + · exact ((C.adjacent (-i-1)).1 (h.1.symm.trans (hb (-i-1)))).elim + · exact h.2 + constructor + · change N.tail (e (-i-1)) = C.vertex (-i) + simpa only [sub_add_cancel] using hb (-i-1) + · change N.head (e (-i-1)) = C.vertex (-(i+1)) + exact hh.trans (congrArg C.vertex (show -i-1 = -(i+1) by abel)) +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype E] (N : Network V E) + +def matchingEdge (P : Finset E) (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) (v : V) : E := + (Finset.card_eq_one.mp (hd v)).choose + +lemma matchingEdge_spec (P : Finset E) (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) (v : V) : + (N.star v).filter (fun e => e ∈ P) = {N.matchingEdge P hd v} := + (Finset.card_eq_one.mp (hd v)).choose_spec + +lemma matchingEdge_mem (P : Finset E) (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) (v : V) : + N.matchingEdge P hd v ∈ N.star v ∧ N.matchingEdge P hd v ∈ P := by + exact Finset.mem_filter.mp (by rw [N.matchingEdge_spec P hd v]; exact Finset.mem_singleton_self _) + +lemma matchingEdge_eq (P : Finset E) (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) + {v : V} {e : E} (he : e ∈ N.star v) (hp : e ∈ P) : e = N.matchingEdge P hd v := by + exact Finset.mem_singleton.mp ((N.matchingEdge_spec P hd v) ▸ Finset.mem_filter.mpr ⟨he,hp⟩) +end +end Barnette.Network + +namespace Barnette.Network.ColoredDual +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + {N : Network V E} {D : Network F E} (M : N.ColoredDual D) {root : V} + +abbrev selectNet (s : M.State root) (P : Finset E) + (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) : Network F (M.Black root) where + tail t := s.value t + head t := D.otherEnd (N.matchingEdge P hd t.val) (s.value t) + +lemma selectNet_forest (s : M.State root) (P : Finset E) + (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) + (hi : ∀ t : M.Black root, D.Incident (N.matchingEdge P hd t.val) (s.value t)) : + (M.selectNet s P hd).graph.IsAcyclic := by + by_contra hn + obtain ⟨C,t,ht⟩ := (M.selectNet s P hd).directed_cycle_of_not_acyclic s.value_injective hn + have he (i) : s(D.tail (N.matchingEdge P hd (t i).val),D.head (N.matchingEdge P hd (t i).val)) = + s(C.vertex i,C.vertex (i+1)) := by + rw [(D.otherEnd_spec M.dual_simple (hi (t i))).2] + change s((M.selectNet s P hd).tail (t i),(M.selectNet s P hd).head (t i)) = _ + rw [(ht i).1,(ht i).2] + let C' : Barnette.CycleCoordinates D.graph := { + n := C.n + vertex := C.vertex + adjacent i := ⟨(C.adjacent i).1,N.matchingEdge P hd (t i).val,Sym2.eq_iff.mp (he i)⟩ } + have hedge (i) : D.cycleEdge C' i = N.matchingEdge P hd (t i).val := by + apply M.dual_simple.pair_injective + dsimp only + rw [D.cycleEdge_ends] + exact (he i).symm + obtain ⟨A,c,_,_,_,_,hcut,hcount,_⟩ := M.cycle_disk s C' t + (fun i => hedge i ▸ (N.matchingEdge_mem P hd (t i).val).1) (fun i => (ht i).1) + have hsub : N.cut A ⊆ P := by + intro e he + rw [hcut] at he + obtain ⟨i,rfl⟩ := (D.mem_cycleEdges C' e).mp he + rw [hedge] + exact (N.matchingEdge_mem P hd (t i).val).2 + have hbal := N.matching_cut_balance M.simple M.cubic M.black M.coloring P hd A hsub + omega + +lemma selected_forest (s : M.State root) (P : Finset E) + (hd : ∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) (_hr : M.black root) + (hi : ∀ t : M.Black root, D.Incident (N.matchingEdge P hd t.val) (s.value t)) + (i : Fin 3) (he0 : N.matchingEdge P hd root = (M.face root).edge i) : + (D.restrict (Subtype.val : P → E)).graph.IsAcyclic := by + let L := M.selectNet s P hd + let K := L.addSink (fun j => (M.face root).corner (rootStart (i+2) j)) ((M.face root).corner (i+2+2)) + have hK : K.graph.IsAcyclic := by + apply L.addSink_acyclic (M.selectNet_forest s P hd hi) s.value_injective _ + ((M.face root).corner_injective.comp (rootStart_inj (i+2))) + · intro t j h + exact s.value_mem t ⟨rootStart (i+2) j,h.symm⟩ + · rintro ⟨t|j,h⟩ + · exact s.value_mem t ⟨i+2+2,h.symm⟩ + · exact rootStart_ne (i+2) j ((M.face root).corner_injective h) + apply SimpleGraph.IsAcyclic.anti ?_ hK + intro v w ⟨hvw,e,he⟩ + let b := N.blackEndpoint M.black e.val + have hb : M.black b := (N.blackEndpoint_spec M.black M.coloring e.val).1 + have heb : e.val ∈ N.star b := (N.mem_star _ _).mpr (N.blackEndpoint_spec M.black M.coloring e.val).2 + have hep : e.val = N.matchingEdge P hd b := N.matchingEdge_eq P hd heb e.property + have hends : s(D.tail e.val,D.head e.val) = s(v,w) := Sym2.eq_iff.mpr he + by_cases hbr : b = root + · have hstart : rootStart (i+2) 1 = i := by fin_cases i <;> rfl + have hend : i+2+2 = i+1 := by fin_cases i <;> rfl + refine ⟨hvw,Sum.inr 1,?_⟩ + apply Sym2.eq_iff.mp + change s((M.face root).corner (rootStart (i+2) 1),(M.face root).corner (i+2+2)) = s(v,w) + rw [hstart,hend,← (M.face root).edge_ends i,← he0,← hbr,← hep] + exact hends + · let t : M.Black root := ⟨b,hb,hbr⟩ + refine ⟨hvw,Sum.inl t,?_⟩ + apply Sym2.eq_iff.mp + change s(s.value t,D.otherEnd (N.matchingEdge P hd b) (s.value t)) = s(v,w) + rw [← (D.otherEnd_spec M.dual_simple (hi t)).2,← hep] + exact hends + +lemma recover_connected_complement (Q : (M.system root).Pair (M.nonroots root)) + (hr : M.black root) (ha : ((M.system root).oppositeGraph Q.right).IsAcyclic) (i : Fin 3) : + ∃ P : Finset E, (M.face root).edge i ∈ P ∧ + (∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) ∧ + (N.restrict (Subtype.val : ↥(Pᶜ) → E)).graph.Connected := by + obtain ⟨P,hsub,hd⟩ := M.recovery_matching Q hr ha i + have hi (t : M.Black root) : D.Incident (N.matchingEdge P hd t.val) (Q.right.value t) := + M.remainder_incident Q hr i t (N.matchingEdge_mem P hd t.val).1 + (hsub (N.matchingEdge_mem P hd t.val).2) + have he0 : N.matchingEdge P hd root = (M.face root).edge i := by + have hmem := (N.matchingEdge_mem P hd root) + have hm := M.removed_at_black Q hr i root hr hmem.1 + have hn := (not_congr hm).mp (Finset.mem_compl.mp (hsub hmem.2)) + simpa using hn + refine ⟨P,he0 ▸ (N.matchingEdge_mem P hd root).2,hd,?_⟩ + exact M.duality.complement_connected N D M.dual_simple P + (M.selected_forest Q.right P hd hr hi i he0) +end +end Barnette.Network.ColoredDual + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Gluing.lean b/lean/OAI/Combinatorics/Hamiltonian/Gluing.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec128174b3db5eb411511c2718ffa28e9bf5c336 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Gluing.lean @@ -0,0 +1,303 @@ +import OAI.Combinatorics.Hamiltonian.CappedDuality + +namespace OAI + +/-! Compatible boundary matchings and strong induction over three-edge cuts. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) +local instance (priority := high) capMatchingEq (A : Finset V) : + DecidableEq (N.regionEdges A) := Classical.decEq _ + +omit [Fintype V] in +lemma restrict_star_image (S : Finset E) (v : V) : + ((N.restrict (Subtype.val : S → E)).star v).image Subtype.val = + (N.star v).filter (· ∈ S) := by + ext e + simp only [Finset.mem_image,Finset.mem_filter,mem_star] + constructor + · rintro ⟨k,hk,rfl⟩ + exact ⟨hk,k.property⟩ + · rintro ⟨he,hs⟩ + exact ⟨⟨e,hs⟩,he,rfl⟩ + +lemma matching_complement_two (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) + (P : Finset E) (hP : ∀ v, ((N.star v).filter (· ∈ P)).card = 1) : + (N.restrict (Subtype.val : ↥Pᶜ → E)).graph.IsRegularOfDegree 2 := by + intro v + rw [← card_star _ (hN.restrict N _ Subtype.val_injective), + ← Finset.card_image_of_injective _ Subtype.val_injective,N.restrict_star_image] + have he := Finset.card_filter_add_card_filter_not (s := N.star v) (p := fun e => e ∈ P) + rw [hP v,N.card_star hN,hc v] at he + simpa only [Finset.mem_compl] using (show ((N.star v).filter (fun e => e ∉ P)).card = 2 by omega) + +omit [Fintype V] in +lemma cap_matching_some (A : Finset V) (P : Finset (N.regionEdges A)) (v : A) : + (((N.cap A).star (some v)).filter (· ∈ P)).image Subtype.val = + (N.star v.val).filter (· ∈ P.image Subtype.val) := by + rw [Finset.filter_mem_eq_inter,Finset.image_inter _ _ Subtype.val_injective, + N.cap_star_some,Finset.filter_mem_eq_inter] + +omit [Fintype V] in +lemma cap_matching_none (A : Finset V) (P : Finset (N.regionEdges A)) : + (((N.cap A).star none).filter (· ∈ P)).image Subtype.val = + (N.cut A).filter (· ∈ P.image Subtype.val) := by + rw [Finset.filter_mem_eq_inter,Finset.image_inter _ _ Subtype.val_injective, + N.cap_star_none,Finset.filter_mem_eq_inter] + +omit [Fintype V] in +lemma cap_matching_boundary (A : Finset V) (P : Finset (N.regionEdges A)) + (hP : ∀ v, (((N.cap A).star v).filter (· ∈ P)).card = 1) : + ∃ c : E, c ∈ N.cut A ∧ c ∈ P.image Subtype.val ∧ + ∀ e ∈ N.cut A, e ∈ P.image Subtype.val ↔ e = c := by + have hh := hP none + rw [← Finset.card_image_of_injective _ Subtype.val_injective,N.cap_matching_none] at hh + obtain ⟨c,hc⟩ := Finset.card_eq_one.mp hh + have hmem : c ∈ (N.cut A).filter (· ∈ P.image Subtype.val) := by rw [hc]; simp + refine ⟨c,(Finset.mem_filter.mp hmem).1,(Finset.mem_filter.mp hmem).2,?_⟩ + intro e he + have heq : e ∈ (N.cut A).filter (· ∈ P.image Subtype.val) ↔ e = c := by rw [hc]; simp + simpa only [Finset.mem_filter,he,true_and] using heq + +omit [Fintype V] in +lemma cap_image_subset (A : Finset V) (P : Finset (N.regionEdges A)) : + P.image Subtype.val ⊆ N.regionEdges A := by + rintro e he + obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp he + exact k.property + +lemma region_pair_inter (A : Finset V) (e : E) : + e ∈ N.regionEdges A → e ∈ N.regionEdges Aᶜ → e ∈ N.cut A := by + simp only [mem_regionEdges,mem_cut,Finset.mem_compl] + tauto + +lemma cap_glue_agrees (A : Finset V) (P : Finset (N.regionEdges A)) + (Q : Finset (N.regionEdges Aᶜ)) + (hcut : ∀ e ∈ N.cut A, e ∈ P.image Subtype.val ↔ e ∈ Q.image Subtype.val) + (e : E) (he : e ∈ N.regionEdges A) : + e ∈ P.image Subtype.val ∪ Q.image Subtype.val ↔ e ∈ P.image Subtype.val := by + rw [Finset.mem_union,or_iff_left_iff_imp] + intro hq + exact (hcut e (N.region_pair_inter A e he (N.cap_image_subset Aᶜ Q hq))).mpr hq + +lemma cap_glue_agrees_right (A : Finset V) (P : Finset (N.regionEdges A)) + (Q : Finset (N.regionEdges Aᶜ)) + (hcut : ∀ e ∈ N.cut A, e ∈ P.image Subtype.val ↔ e ∈ Q.image Subtype.val) + (e : E) (he : e ∈ N.regionEdges Aᶜ) : + e ∈ P.image Subtype.val ∪ Q.image Subtype.val ↔ e ∈ Q.image Subtype.val := by + rw [Finset.mem_union,or_iff_right_iff_imp] + intro hp + exact (hcut e (N.region_pair_inter A e (N.cap_image_subset A P hp) he)).mp hp + +lemma cap_glue_matching (A : Finset V) (P : Finset (N.regionEdges A)) + (Q : Finset (N.regionEdges Aᶜ)) + (hP : ∀ v, (((N.cap A).star v).filter (· ∈ P)).card = 1) + (hQ : ∀ v, (((N.cap Aᶜ).star v).filter (· ∈ Q)).card = 1) + (hcut : ∀ e ∈ N.cut A, e ∈ P.image Subtype.val ↔ e ∈ Q.image Subtype.val) : + ∀ v, ((N.star v).filter (· ∈ P.image Subtype.val ∪ Q.image Subtype.val)).card = 1 := by + have side (B : Finset V) (P : Finset (N.regionEdges B)) (R : Finset E) + (hP : ∀ v, (((N.cap B).star v).filter (· ∈ P)).card = 1) + (hR : ∀ e ∈ N.regionEdges B, e ∈ R ↔ e ∈ P.image Subtype.val) + (v : B) : ((N.star v.val).filter (· ∈ R)).card = 1 := by + have heq : (N.star v.val).filter (· ∈ R) = (N.star v.val).filter (· ∈ P.image Subtype.val) := by + apply Finset.filter_congr + intro e he + apply hR e + rcases (N.mem_star e v.val).mp he with ht|hh + · exact (N.mem_regionEdges B e).mpr (Or.inl (ht ▸ v.property)) + · exact (N.mem_regionEdges B e).mpr (Or.inr (hh ▸ v.property)) + rw [heq,← N.cap_matching_some B P v,Finset.card_image_of_injective _ Subtype.val_injective] + exact hP (some v) + intro v + by_cases hv : v ∈ A + · exact side A P _ hP (N.cap_glue_agrees A P Q hcut) ⟨v,hv⟩ + · exact side Aᶜ Q _ hQ (N.cap_glue_agrees_right A P Q hcut) ⟨v,Finset.mem_compl.mpr hv⟩ +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) +local instance (priority := high) capReachableEq (A : Finset V) : + DecidableEq (N.regionEdges A) := Classical.decEq _ + +omit [Fintype V] in +lemma cap_complement_reachable (A : Finset V) (P : Finset (N.regionEdges A)) + (R : Finset E) + (hc : ((N.cap A).restrict (Subtype.val : ↥Pᶜ → N.regionEdges A)).graph.Connected) + (hd : ((N.cap A).restrict (Subtype.val : ↥Pᶜ → N.regionEdges A)).graph.IsRegularOfDegree 2) + (hR : ∀ e ∈ N.regionEdges A, e ∈ R ↔ e ∈ P.image Subtype.val) + (v w : A) : (N.restrict (Subtype.val : ↥Rᶜ → E)).graph.Reachable v.val w.val := by + let C := ((N.cap A).restrict (Subtype.val : ↥Pᶜ → N.regionEdges A)).graph + have hC : (C.induce {x | x ≠ none}).Connected := + Barnette.SimpleCycle.delete_vertex_connected C hc hd none + let f : (C.induce {x | x ≠ none}) →g (N.restrict (Subtype.val : ↥Rᶜ → E)).graph := { + toFun := fun x => (x.val.getD v).val + map_rel' := by + rintro ⟨x,hx⟩ ⟨y,hy⟩ hxy + cases x with + | none => exact (hx rfl).elim + | some x => + cases y with + | none => exact (hy rfl).elim + | some y => + obtain ⟨hne,k,hk⟩ := hxy + have hxy' : x.val ≠ y.val := by + intro hh + have hh' : x = y := Subtype.ext hh + subst y + exact hne rfl + have hk' : (N.tail k.val.val = x.val ∧ N.head k.val.val = y.val) ∨ + (N.tail k.val.val = y.val ∧ N.head k.val.val = x.val) := by + change (N.capMap A (N.tail k.val.val) = some x ∧ N.capMap A (N.head k.val.val) = some y) ∨ + (N.capMap A (N.tail k.val.val) = some y ∧ N.capMap A (N.head k.val.val) = some x) at hk + simpa only [capMap_eq_some] using hk + have hnot : k.val.val ∉ P.image Subtype.val := by + intro hm + obtain ⟨e,he,hee⟩ := Finset.mem_image.mp hm + have hee' : e = k.val := Subtype.ext hee + exact (Finset.mem_compl.mp k.property) (hee' ▸ he) + have hkR : k.val.val ∈ Rᶜ := + Finset.mem_compl.mpr (hnot ∘ (hR k.val.val k.val.property).mp) + exact ⟨hxy',⟨k.val.val,hkR⟩,hk'⟩ } + exact (hC ⟨some v,by simp⟩ ⟨some w,by simp⟩).map f + +lemma cap_glue_connected (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) + (h3 : N.ThreeEdgeConnected) (A : Finset V) (hA : (N.cut A).card = 3) + (ha : 2 ≤ A.card) (ho : 2 ≤ Aᶜ.card) + (P : Finset (N.regionEdges A)) (Q : Finset (N.regionEdges Aᶜ)) + (hP : ∀ v, (((N.cap A).star v).filter (· ∈ P)).card = 1) + (hQ : ∀ v, (((N.cap Aᶜ).star v).filter (· ∈ Q)).card = 1) + (hPc : ((N.cap A).restrict (Subtype.val : ↥Pᶜ → N.regionEdges A)).graph.Connected) + (hQc : ((N.cap Aᶜ).restrict (Subtype.val : ↥Qᶜ → N.regionEdges Aᶜ)).graph.Connected) + (hcut : ∀ e ∈ N.cut A, e ∈ P.image Subtype.val ↔ e ∈ Q.image Subtype.val) : + (N.restrict (Subtype.val : ↥(P.image Subtype.val ∪ Q.image Subtype.val)ᶜ → E)).graph.Connected := by + have ha' : A.Nonempty := Finset.card_pos.mp (by omega) + have ho' : Aᶜ.Nonempty := Finset.card_pos.mp (by omega) + have hc' : (N.cut Aᶜ).card = 3 := by simpa only [cut_compl] using hA + have ha'' : (Aᶜ)ᶜ.Nonempty := by simpa only [compl_compl] using ha' + have hmP := (N.cap A).matching_complement_two (N.cap_simple hN hc h3 A hA ha ho') + (N.cap_cubic hN hc h3 A hA ha ho') P hP + have hmQ := (N.cap Aᶜ).matching_complement_two (N.cap_simple hN hc h3 Aᶜ hc' ho ha'') + (N.cap_cubic hN hc h3 Aᶜ hc' ho ha'') Q hQ + let R := P.image Subtype.val ∪ Q.image Subtype.val + let H := (N.restrict (Subtype.val : ↥Rᶜ → E)).graph + have rA (v w : A) : H.Reachable v.val w.val := + N.cap_complement_reachable A P R hPc hmP (N.cap_glue_agrees A P Q hcut) v w + have rB (v w : ↥(Aᶜ)) : H.Reachable v.val w.val := + N.cap_complement_reachable Aᶜ Q R hQc hmQ (N.cap_glue_agrees_right A P Q hcut) v w + obtain ⟨c,hcA,hcP,hcuniq⟩ := N.cap_matching_boundary A P hP + have hdex : ((N.cut A).erase c).Nonempty := by + apply Finset.card_pos.mp + rw [Finset.card_erase_of_mem hcA,hA] + decide + obtain ⟨d,hd⟩ := hdex + obtain ⟨hdc,hdA⟩ := Finset.mem_erase.mp hd + have hdP : d ∉ P.image Subtype.val := fun hh => hdc ((hcuniq d hdA).mp hh) + have hdr : d ∈ N.regionEdges A := by + have hh := (N.mem_cut A d).mp hdA + exact (N.mem_regionEdges A d).mpr (hh.elim (Or.inl ∘ And.left) (Or.inr ∘ And.left)) + have hdR : d ∈ Rᶜ := Finset.mem_compl.mpr + (hdP ∘ (N.cap_glue_agrees A P Q hcut d hdr).mp) + have adj : H.Adj (N.tail d) (N.head d) := ⟨hN.loopless d,⟨d,hdR⟩,Or.inl ⟨rfl,rfl⟩⟩ + have cross (x y : V) (hx : x ∈ A) (hy : y ∉ A) (hxy : H.Adj x y) : H.Connected := by + apply (SimpleGraph.connected_iff_exists_forall_reachable H).mpr + refine ⟨x,?_⟩ + intro z + by_cases hz : z ∈ A + · exact rA ⟨x,hx⟩ ⟨z,hz⟩ + · exact hxy.reachable.trans (rB ⟨y,Finset.mem_compl.mpr hy⟩ ⟨z,Finset.mem_compl.mpr hz⟩) + rcases (N.mem_cut A d).mp hdA with ⟨ht,hh⟩|⟨hh,ht⟩ + · exact cross _ _ ht hh adj + · exact cross _ _ hh ht adj.symm +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +universe uV uE uF +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] (N : Network V E) +local instance (priority := high) unrestrictedInductionEq (A : Finset V) : + DecidableEq (N.regionEdges A) := Classical.decEq _ + +omit [Fintype V] in +lemma cap_matching_boundary_at (A : Finset V) (P : Finset (N.regionEdges A)) + (hP : ∀ v, (((N.cap A).star v).filter (· ∈ P)).card = 1) + (c : E) (hc : c ∈ N.cut A) (hm : c ∈ P.image Subtype.val) : + ∀ e ∈ N.cut A, e ∈ P.image Subtype.val ↔ e = c := by + obtain ⟨d,_,_,hd⟩ := N.cap_matching_boundary A P hP + have hh : c = d := (hd c hc).mp hm + subst d + exact hd + +lemma nontrivial_threeCut_at (h : ¬N.TrivialThreeCuts) (e : E) : + ∃ A : Finset V, (N.cut A).card = 3 ∧ 2 ≤ A.card ∧ 2 ≤ Aᶜ.card ∧ e ∈ N.regionEdges A := by + obtain ⟨A,hA,ha,ho⟩ := N.nontrivial_threeCut h + by_cases he : e ∈ N.regionEdges A + · exact ⟨A,hA,ha,ho,he⟩ + · have ht : N.tail e ∉ A := fun hh => he ((N.mem_regionEdges A e).mpr (Or.inl hh)) + refine ⟨Aᶜ,by simpa only [cut_compl] using hA,ho,by simpa only [compl_compl] using ha,?_⟩ + exact (N.mem_regionEdges Aᶜ e).mpr (Or.inl (Finset.mem_compl.mpr ht)) + +private theorem matching_strong (n : ℕ) : + ∀ {V : Type uV} {E : Type uE} {F : Type uF} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E), Fintype.card V = n → + N.Duality D → N.Simple → N.graph.IsRegularOfDegree 3 → N.ThreeEdgeConnected → + ∀ (black : V → Prop), (∀ e, black (N.tail e) ↔ ¬black (N.head e)) → + ∀ e : E, ∃ P : Finset E, e ∈ P ∧ (∀ v, ((N.star v).filter (· ∈ P)).card = 1) ∧ + (N.restrict (Subtype.val : ↥Pᶜ → E)).graph.Connected := by + induction n using Nat.strong_induction_on with + | h n ih => + intro V E F _ _ _ N D hn h hN hc h3 black hb e + by_cases ht : N.TrivialThreeCuts + · obtain ⟨M⟩ := N.make_coloredDual D h hN h3 hc black hb + exact N.irreducible_matching D M h3 ht e + · obtain ⟨A,hA,ha,ho,he⟩ := N.nontrivial_threeCut_at ht e + have ha' : A.Nonempty := Finset.card_pos.mp (by omega) + have ho' : Aᶜ.Nonempty := Finset.card_pos.mp (by omega) + have hc' : (N.cut Aᶜ).card = 3 := by simpa only [cut_compl] using hA + have ha'' : (Aᶜ)ᶜ.Nonempty := by simpa only [compl_compl] using ha' + obtain ⟨F₁,f₁,D₁,h₁⟩ := N.cap_duality D h hN h3 A hA ha' ho' + let : Fintype F₁ := f₁ + have hlt₁ : Fintype.card (Option A) < n := hn ▸ cap_card_lt A ho + obtain ⟨P,heP,hP,hPc⟩ := ih _ hlt₁ (N.cap A) D₁ rfl h₁ + (N.cap_simple hN hc h3 A hA ha ho') (N.cap_cubic hN hc h3 A hA ha ho') + (N.cap_threeConnected h3 A ho') (N.capBlack black A) + (N.cap_coloring hN hc black hb A hA) ⟨e,he⟩ + obtain ⟨c,hca,hcp,hcu⟩ := N.cap_matching_boundary A P hP + have hcb : c ∈ N.cut Aᶜ := by simpa only [cut_compl] using hca + have hcr : c ∈ N.regionEdges Aᶜ := by + have hh := (N.mem_cut Aᶜ c).mp hcb + exact (N.mem_regionEdges Aᶜ c).mpr (hh.elim (Or.inl ∘ And.left) (Or.inr ∘ And.left)) + obtain ⟨F₂,f₂,D₂,h₂⟩ := N.cap_duality D h hN h3 Aᶜ hc' ho' ha'' + let : Fintype F₂ := f₂ + have hlt₂ : Fintype.card (Option ↥(Aᶜ)) < n := by + rw [← hn] + exact cap_card_lt Aᶜ (by simpa only [compl_compl] using ha) + obtain ⟨Q,hcQ,hQ,hQc⟩ := ih _ hlt₂ (N.cap Aᶜ) D₂ rfl h₂ + (N.cap_simple hN hc h3 Aᶜ hc' ho ha'') (N.cap_cubic hN hc h3 Aᶜ hc' ho ha'') + (N.cap_threeConnected h3 Aᶜ ha'') (N.capBlack black Aᶜ) + (N.cap_coloring hN hc black hb Aᶜ hc') ⟨c,hcr⟩ + have hcQ' : c ∈ Q.image Subtype.val := Finset.mem_image.mpr ⟨⟨c,hcr⟩,hcQ,rfl⟩ + have hqcut : ∀ d ∈ N.cut A, d ∈ Q.image Subtype.val ↔ d = c := by + simpa only [cut_compl] using N.cap_matching_boundary_at Aᶜ Q hQ c hcb hcQ' + have hcut : ∀ d ∈ N.cut A, d ∈ P.image Subtype.val ↔ d ∈ Q.image Subtype.val := + fun d hd => (hcu d hd).trans (hqcut d hd).symm + refine ⟨P.image Subtype.val ∪ Q.image Subtype.val,?_,N.cap_glue_matching A P Q hP hQ hcut,?_⟩ + · exact Finset.mem_union_left _ (Finset.mem_image.mpr ⟨⟨e,he⟩,heP,rfl⟩) + · exact N.cap_glue_connected hN hc h3 A hA ha ho P Q hP hQ hPc hQc hcut + +variable {F : Type uF} [Fintype F] (D : Network F E) + +theorem Duality.connected_complement_matching (h : N.Duality D) (hN : N.Simple) + (hc : N.graph.IsRegularOfDegree 3) (h3 : N.ThreeEdgeConnected) + (black : V → Prop) (hb : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (e : E) : + ∃ P : Finset E, e ∈ P ∧ (∀ v, ((N.star v).filter (· ∈ P)).card = 1) ∧ + (N.restrict (Subtype.val : ↥Pᶜ → E)).graph.Connected := + matching_strong (Fintype.card V) N D rfl h hN hc h3 black hb e +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Main.lean b/lean/OAI/Combinatorics/Hamiltonian/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..6583fc95fec9859dde830e3f80e56018917eeeb2 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Main.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.Hamiltonian.ExactDual + +namespace OAI + +/-! Hamiltonian cycles in cubic bipartite three-vertex-connected plane graphs. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + [DecidableEq V] (N : Network V E) (D : Network F E) + +theorem Duality.hamiltonian (h : N.Duality D) (hN : N.Simple) + (hc : N.graph.IsRegularOfDegree 3) (h3 : N.ThreeEdgeConnected) + (black : V → Prop) (hb : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) : + HasHamiltonianCycle N.graph := by + obtain ⟨v⟩ := h.connected.nonempty + have hs : (N.star v).Nonempty := by + apply Finset.card_pos.mp + rw [N.card_star hN,hc v] + decide + obtain ⟨e,_⟩ := hs + obtain ⟨P,_,hP,hPc⟩ := h.connected_complement_matching N D hN hc h3 black hb e + let H := (N.restrict (Subtype.val : ↥Pᶜ → E)).graph + have hdeg : H.IsRegularOfDegree 2 := N.matching_complement_two hN hc P hP + obtain ⟨p,hp⟩ := Barnette.SimpleCycle.cycle_at_of_connected_two H hPc hdeg v + let f : H →g N.graph := { + toFun := id + map_rel' := by + rintro a b ⟨hne,k,hk⟩ + exact ⟨hne,k.val,hk⟩ } + exact ⟨v,p.map f,hp.map Function.bijective_id⟩ +end +end Barnette.Network + +namespace Barnette +universe u +noncomputable section +open scoped Classical +variable {V : Type u} [Fintype V] {G : SimpleGraph V} + +lemma ThreeVertexConnected.connected (h : ThreeVertexConnected G) : G.Connected := by + let H := G.induce {v | v ∉ (∅ : Finset V)} + let f : H →g G := { toFun := Subtype.val, map_rel' := fun h => h } + exact (h.2 ∅ (by simp)).map f (fun v => ⟨⟨v,by simp⟩,rfl⟩) + +theorem main : MainStatement.{u} := by + intro V hV dV G dG hc hb hp h3 + have hdeq : dV = Classical.decEq V := Subsingleton.elim _ _ + subst dV + have hdrel : dG = fun a b => Classical.propDecidable (G.Adj a b) := Subsingleton.elim _ _ + subst dG + obtain ⟨E⟩ := hp + have hconn := h3.connected + let : Nonempty V := hconn.nonempty + have horder := cubic_bipartite_order hc hb + obtain ⟨N,F,f,D,hr,hd⟩ := E.exists_exact_dual hconn + let : Fintype F := f + have hN : N.Simple := by + refine ⟨hr.loopless,?_⟩ + intro e f hef + apply Subtype.ext + rw [← hr e,← hr f] + exact hef + have hc' : N.graph.IsRegularOfDegree 3 := by rw [hr.graph_eq]; exact hc + have h3' : ThreeVertexConnected N.graph := hr.graph_eq.symm ▸ h3 + have hec : N.ThreeEdgeConnected := by + intro A ha ho + obtain ⟨w,hw⟩ := ho + exact N.cut_card_three h3' (by omega) A ha ⟨w,Finset.mem_compl.mp hw⟩ + obtain ⟨color⟩ := hb + let black : V → Prop := fun v => color v = 0 + have hcolor (e : G.edgeSet) : black (N.tail e) ↔ ¬black (N.head e) := by + have hne := color.valid (G.mem_edgeSet.mp ((hr e).symm ▸ e.property)) + have ht := (color (N.tail e)).isLt + have hh := (color (N.head e)).isLt + have hne' : (color (N.tail e)).val ≠ (color (N.head e)).val := fun h => hne (Fin.ext h) + change color (N.tail e) = 0 ↔ ¬color (N.head e) = 0 + simp only [Fin.ext_iff,Fin.val_zero] + omega + have hh := hd.hamiltonian N D hN hc' hec black hcolor + rwa [hr.graph_eq] at hh +end +end Barnette + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Matching.lean b/lean/OAI/Combinatorics/Hamiltonian/Matching.lean new file mode 100644 index 0000000000000000000000000000000000000000..76be3dc11570ed971fca0b68a8a8d74e248734f9 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Matching.lean @@ -0,0 +1,509 @@ +import OAI.Combinatorics.Hamiltonian.BMatching + +namespace OAI + +/-! Disk and spoke signs and matching complements. -/ + +namespace Barnette.CycleCoordinates +variable {V : Type*} {G : SimpleGraph V} (C : Barnette.CycleCoordinates G) +include C in +lemma not_acyclic : ¬ G.IsAcyclic := by + intro ha + apply (SimpleGraph.isAcyclic_iff_free_cycleGraph.mp ha) (C.n+3) (by omega) + refine ⟨⟨⟨C.vertex,?_⟩,C.vertex.injective⟩⟩ + intro i j hij + rcases SimpleGraph.cycleGraph_adj.mp hij with hij | hij + · have hi : i = j+1 := (sub_eq_iff_eq_add.mp hij).trans (add_comm _ _) + rw [hi]; exact (C.adjacent j).symm + · have hj : j = i+1 := (sub_eq_iff_eq_add.mp hij).trans (add_comm _ _) + rw [hj]; exact C.adjacent i +end Barnette.CycleCoordinates + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +lemma acyclic_conserved_zero (hN : N.Simple) (ha : N.graph.IsAcyclic) + (x : E → ℝ) (hx : N.boundary x = 0) : x = 0 := by + ext e + let K := N.graph.deleteEdges {s(N.tail e,N.head e)} + have he : N.graph.Adj (N.tail e) (N.head e) := ⟨hN.loopless e,e,Or.inl ⟨rfl,rfl⟩⟩ + have hb : ¬K.Reachable (N.tail e) (N.head e) := + (SimpleGraph.isAcyclic_iff_forall_adj_isBridge.mp ha he) + let f : V → ℝ := fun v => if K.Reachable (N.tail e) v then 1 else 0 + have hg : N.gradient f e = -1 := by simp [gradient_apply,f,hb] + have hk : ∀ k, k ≠ e → N.gradient f k = 0 := by + intro k hke + have hp : s(N.tail k,N.head k) ≠ s(N.tail e,N.head e) := + fun h => hke (hN.pair_injective h) + have hadj : K.Adj (N.tail k) (N.head k) := by + apply SimpleGraph.deleteEdges_adj.mpr + exact ⟨⟨hN.loopless k,k,Or.inl ⟨rfl,rfl⟩⟩,by simpa only [Set.mem_singleton_iff] using hp⟩ + have hh : K.Reachable (N.tail e) (N.head k) ↔ K.Reachable (N.tail e) (N.tail k) := + ⟨fun h => h.trans hadj.reachable.symm,fun h => h.trans hadj.reachable⟩ + simp [gradient_apply,f,hh] + have hi := N.boundary_adjoint x f + rw [hx] at hi + simp only [Pi.zero_apply,zero_mul,Finset.sum_const_zero] at hi + rw [Finset.sum_eq_single e] at hi + · simpa [hg] using hi.symm + · intro k _ hke; rw [hk k hke,mul_zero] + · simp + +omit [Fintype V] [Fintype E] in +lemma Simple.restrict (hN : N.Simple) {K : Type*} (j : K → E) (hj : Function.Injective j) : + (N.restrict j).Simple where + loopless k := hN.loopless (j k) + pair_injective _ _ h := hj (hN.pair_injective h) + +omit [Fintype E] in +lemma extend_restriction (S : Finset E) (x : E → ℝ) (hx : ∀ e, e ∉ S → x e = 0) : + push (Subtype.val : S → E) (fun e => x e.val) = x := by + ext e + by_cases he : e ∈ S + · exact push_subtype_apply S (fun e => x e.val) ⟨e,he⟩ + · rw [push_subtype_outside S _ he,hx e he] + +lemma conserved_supported_acyclic (hN : N.Simple) (S : Finset E) + (ha : (N.restrict (Subtype.val : S → E)).graph.IsAcyclic) + (x : E → ℝ) (hx : N.boundary x = 0) (hs : ∀ e, e ∉ S → x e = 0) : x = 0 := by + have hz : (N.restrict (Subtype.val : S → E)).boundary (fun e => x e.val) = 0 := by + rw [boundary_restrict,extend_restriction S x hs,hx] + have hh := (N.restrict (Subtype.val : S → E)).acyclic_conserved_zero + (hN.restrict N _ Subtype.val_injective) ha _ hz + rw [← extend_restriction S x hs,hh,map_zero] + +variable {F : Type*} [Fintype F] (D : Network F E) +omit [Fintype V] in +lemma Duality.complement_connected (h : N.Duality D) (hD : D.Simple) (S : Finset E) + (ha : (D.restrict (Subtype.val : S → E)).graph.IsAcyclic) : + (N.restrict (Subtype.val : ↥(Sᶜ) → E)).graph.Connected := by + have : Nonempty V := h.connected.nonempty + apply (N.restrict (Subtype.val : ↥(Sᶜ) → E)).connected_of_kernel_constants + intro f hf v w + have hz : D.boundary (N.gradient f) = 0 := by + rw [← LinearMap.mem_ker,h.dual_cycles_eq_cuts] + exact ⟨f,rfl⟩ + have hs : ∀ e, e ∉ S → N.gradient f e = 0 := by + intro e he + exact congrFun hf ⟨e,Finset.mem_compl.mpr he⟩ + exact N.gradient_zero_reachable (D.conserved_supported_acyclic hD S ha _ hz hs) (h.connected v w) + +end +end Barnette.Network + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V A : Type*} (Q : Network V A) + +def addSink (r : Fin 2 → V) (z : V) : Network V (A ⊕ Fin 2) where + tail := Sum.elim Q.tail r + head := Sum.elim Q.head (fun _ => z) + +lemma addSink_tail_injective (ht : Function.Injective Q.tail) (r : Fin 2 → V) + (hr : Function.Injective r) (hd : ∀ a i, Q.tail a ≠ r i) (z : V) : + Function.Injective (Q.addSink r z).tail := by + rintro (a|i) (b|j) h + · exact congrArg Sum.inl (ht h) + · exact (hd a j h).elim + · exact (hd b i h.symm).elim + · exact congrArg Sum.inr (hr h) + +lemma addSink_acyclic (ha : Q.graph.IsAcyclic) (ht : Function.Injective Q.tail) + (r : Fin 2 → V) (hr : Function.Injective r) (hd : ∀ a i, Q.tail a ≠ r i) + (z : V) (hz : z ∉ Set.range (Q.addSink r z).tail) : (Q.addSink r z).graph.IsAcyclic := by + classical + by_contra hnot + obtain ⟨C⟩ := Barnette.cycleCoordinates_of_not_acyclic hnot + let L := Q.addSink r z + let edge : Fin (C.n+3) ↪ A ⊕ Fin 2 := ⟨L.cycleEdge C,L.cycleEdge_injective C⟩ + have hend (i) : L.tail (edge i) = C.vertex i ∨ L.tail (edge i) = C.vertex (i+1) := by + rcases Sym2.eq_iff.mp (L.cycleEdge_ends C i) with h|h + · exact Or.inl h.1 + · exact Or.inr h.1 + have hor := C.tail_orientation edge L.tail (Q.addSink_tail_injective ht r hr hd z) hend + have hrange (i) : C.vertex i ∈ Set.range L.tail := by + rcases hor with hf|hb + · exact ⟨edge i,hf i⟩ + · refine ⟨edge (i-1),?_⟩ + simpa using hb (i-1) + have hbase (i) : ∃ a, edge i = Sum.inl a := by + cases he : edge i with + | inl a => exact ⟨a,rfl⟩ + | inr j => + have hh : L.head (edge i) = z := by rw [he]; rfl + rcases Sym2.eq_iff.mp (L.cycleEdge_ends C i) with h|h + · exact (hz (hh ▸ (h.2 ▸ hrange (i+1)))).elim + · exact (hz (hh ▸ (h.2 ▸ hrange i))).elim + have hc : Nonempty (Barnette.CycleCoordinates Q.graph) := by + refine ⟨⟨C.n,C.vertex,?_⟩⟩ + intro i + obtain ⟨a,hea⟩ := hbase i + refine ⟨(C.adjacent i).1,a,?_⟩ + have he := L.cycleEdge_ends C i + change s(L.tail (edge i),L.head (edge i)) = _ at he + rw [hea] at he + exact Sym2.eq_iff.mp he + exact hc.elim (fun C' => C'.not_acyclic ha) + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +lemma boundary_injective_of_tree_card (hc : N.graph.Connected) + (he : Fintype.card E + 1 = Fintype.card V) : Function.Injective N.boundary := by + have hh := N.dim_cycles hc + have hz : Module.finrank ℝ N.boundary.ker = 0 := by omega + exact LinearMap.ker_eq_bot.mp (Submodule.finrank_eq_zero.mp hz) + +lemma boundary_restrict_injective (hi : Function.Injective N.boundary) + {K : Type*} [Fintype K] (j : K → E) (hj : Function.Injective j) : + Function.Injective (N.restrict j).boundary := by + intro x y h + rw [boundary_restrict,boundary_restrict] at h + have hh := congrArg (pull j) (hi h) + simpa only [pull_push_injective hj] using hh + +omit [Fintype V] [Fintype E] in +lemma boundary_supported_vertices {K : Type*} [Fintype K] (j : K → E) + (U : Finset V) (hU : ∀ k, N.tail (j k) ∈ U ∧ N.head (j k) ∈ U) + (x : K → ℝ) {v : V} (hv : v ∉ U) : (N.restrict j).boundary x v = 0 := by + rw [boundary_apply] + apply Finset.sum_eq_zero + intro k _ + have ht : (N.restrict j).tail k ≠ v := fun hh => hv (hh ▸ (hU k).1) + have hh : (N.restrict j).head k ≠ v := fun hh => hv (hh ▸ (hU k).2) + simp [ht,hh] + +lemma independent_edges_bound (hi : Function.Injective N.boundary) + (S : Finset E) (U : Finset V) (hne : U.Nonempty) + (hU : ∀ e ∈ S, N.tail e ∈ U ∧ N.head e ∈ U) : S.card + 1 ≤ U.card := by + obtain ⟨v,hv⟩ := hne + let H := N.restrict (Subtype.val : S → E) + let L : (S → ℝ) →ₗ[ℝ] (U.erase v → ℝ) := (pull Subtype.val).comp H.boundary + have hL : Function.Injective L := by + intro x y hxy + apply N.boundary_restrict_injective hi Subtype.val Subtype.val_injective + have hrow : ∀ w, w ≠ v → H.boundary x w = H.boundary y w := by + intro w hw + by_cases hwU : w ∈ U + · exact congrFun hxy ⟨w,Finset.mem_erase.mpr ⟨hw,hwU⟩⟩ + · rw [N.boundary_supported_vertices Subtype.val U (fun e => hU e.val e.property) x hwU, + N.boundary_supported_vertices Subtype.val U (fun e => hU e.val e.property) y hwU] + ext w + by_cases hw : w = v + · subst w + have hsx := H.sum_boundary x + have hsy := H.sum_boundary y + rw [← Finset.sum_erase_add _ _ (Finset.mem_univ v)] at hsx hsy + have hh : (∑ w ∈ Finset.univ.erase v, H.boundary x w) = + ∑ w ∈ Finset.univ.erase v, H.boundary y w := by + apply Finset.sum_congr rfl + intro w hw; exact hrow w (Finset.mem_erase.mp hw).1 + linarith + · exact hrow w hw + have hc := LinearMap.finrank_le_finrank_of_injective hL + simp only [Module.finrank_pi,Fintype.card_coe] at hc + rw [Finset.card_erase_of_mem hv] at hc + have hvp : 0 < U.card := Finset.card_pos.mpr ⟨v,hv⟩ + omega + +end +end Barnette.Network +namespace Barnette.Network.ColoredDual +noncomputable section +open scoped Classical +open Barnette.TriangleSystem +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + {N : Network V E} {D : Network F E} (M : N.ColoredDual D) {root : V} + +abbrev QNet (P : (M.system root).Pair (M.nonroots root)) : Network F (M.Black root) where + tail t := P.left.value t + head t := (M.face t.val).corner (thirdIndex (P.left.val t) (P.right.val t)) + +omit [Fintype F] in +lemma pair_val_ne (P : (M.system root).Pair (M.nonroots root)) (t : M.Black root) : + P.left.val t ≠ P.right.val t := fun h => P.partner t ((State.value_eq_iff _ _ _).mpr h) + +omit [Fintype F] in +lemma q_graph (P : (M.system root).Pair (M.nonroots root)) : + (M.QNet P).graph = (M.system root).oppositeGraph P.right := by + ext v w + rw [(M.system root).oppositeGraph_adj_iff P.partner] + constructor + · rintro ⟨_,t,h|h⟩ + · exact ⟨t,Or.inl ⟨h.1.symm,h.2.symm⟩⟩ + · exact ⟨t,Or.inr ⟨h.1.symm,h.2.symm⟩⟩ + · rintro ⟨t,h|h⟩ + all_goals have hn := (thirdIndex_distinct _ _ (M.pair_val_ne P t)).1 + · exact ⟨fun he => hn ((M.face t.val).corner_injective (h.2.symm.trans (he.symm.trans h.1))), + t,Or.inl ⟨h.1.symm,h.2.symm⟩⟩ + · exact ⟨fun he => hn ((M.face t.val).corner_injective (h.2.symm.trans (he.trans h.1))), + t,Or.inr ⟨h.1.symm,h.2.symm⟩⟩ + +def qLabel (P : (M.system root).Pair (M.nonroots root)) (t : M.Black root) : E := + (M.face t.val).side D (P.left.val t) (thirdIndex (P.left.val t) (P.right.val t)) + +omit [Fintype F] in +lemma qLabel_ends (P : (M.system root).Pair (M.nonroots root)) (t : M.Black root) : + s(D.tail (M.qLabel P t),D.head (M.qLabel P t)) = + s((M.QNet P).tail t,(M.QNet P).head t) := + (M.face t.val).side_ends D (thirdIndex_distinct _ _ (M.pair_val_ne P t)).1.symm + +omit [Fintype F] in +lemma qLabel_black (P : (M.system root).Pair (M.nonroots root)) (t : M.Black root) : + N.blackEndpoint M.black (M.qLabel P t) = t.val := + N.blackEndpoint_eq M.black M.coloring t.property.1 + ((N.mem_star _ _).mp ((M.face t.val).side_mem D _ _)) + +omit [Fintype F] in +lemma qLabel_inj (P : (M.system root).Pair (M.nonroots root)) : + Function.Injective (M.qLabel P) := by + intro t u h + apply Subtype.ext + exact (M.qLabel_black P t).symm.trans ((congrArg (N.blackEndpoint M.black) h).trans (M.qLabel_black P u)) + +def rootStart (i : Fin 3) (j : Fin 2) : Fin 3 := i + j.castLE (by decide) + +lemma rootStart_inj (i : Fin 3) : Function.Injective (rootStart i) := by revert i; decide +lemma rootStart_ne (i : Fin 3) (j : Fin 2) : rootStart i j ≠ i+2 := by revert i j; decide + +abbrev augQ (P : (M.system root).Pair (M.nonroots root)) (i : Fin 3) : + Network F (M.Black root ⊕ Fin 2) := + (M.QNet P).addSink (fun j => (M.face root).corner (rootStart i j)) ((M.face root).corner (i+2)) + +omit [Fintype F] in +lemma augQ_acyclic (P : (M.system root).Pair (M.nonroots root)) + (ha : ((M.system root).oppositeGraph P.right).IsAcyclic) (i : Fin 3) : + (M.augQ P i).graph.IsAcyclic := by + apply (M.QNet P).addSink_acyclic (M.q_graph P ▸ ha) P.left.value_injective _ + ((M.face root).corner_injective.comp (rootStart_inj i)) + · intro t j h + exact P.left.value_mem t ⟨rootStart i j,h.symm⟩ + · rintro ⟨t|j,h⟩ + · exact P.left.value_mem t ⟨i+2,h.symm⟩ + · exact rootStart_ne i j ((M.face root).corner_injective h) + +def augLabel (P : (M.system root).Pair (M.nonroots root)) (i : Fin 3) : + M.Black root ⊕ Fin 2 → E := + Sum.elim (M.qLabel P) (fun j => (M.face root).side D (rootStart i j) (i+2)) + +omit [Fintype F] in +lemma augLabel_ends (P : (M.system root).Pair (M.nonroots root)) (i : Fin 3) + (t : M.Black root ⊕ Fin 2) : + s(D.tail (M.augLabel P i t),D.head (M.augLabel P i t)) = + s((M.augQ P i).tail t,(M.augQ P i).head t) := by + cases t with + | inl t => exact M.qLabel_ends P t + | inr j => exact (M.face root).side_ends D (rootStart_ne i j) + +omit [Fintype F] in +lemma augLabel_inj (P : (M.system root).Pair (M.nonroots root)) (hr : M.black root) + (i : Fin 3) : Function.Injective (M.augLabel P i) := by + have hb (j : Fin 2) : N.blackEndpoint M.black (M.augLabel P i (.inr j)) = root := + N.blackEndpoint_eq M.black M.coloring hr ((N.mem_star _ _).mp ((M.face root).side_mem D _ _)) + rintro (t|j) (u|k) he + · exact congrArg Sum.inl (M.qLabel_inj P he) + · have hh := congrArg (N.blackEndpoint M.black) he + change N.blackEndpoint M.black (M.qLabel P t) = _ at hh + rw [M.qLabel_black P t,hb] at hh + exact (t.property.2 hh).elim + · have hh := congrArg (N.blackEndpoint M.black) he + change _ = N.blackEndpoint M.black (M.qLabel P u) at hh + rw [hb,M.qLabel_black P u] at hh + exact (u.property.2 hh.symm).elim + · have hh := (M.augLabel_ends P i (.inr j)).symm.trans + ((congrArg (fun e => s(D.tail e,D.head e)) he).trans (M.augLabel_ends P i (.inr k))) + rcases Sym2.eq_iff.mp hh with h|h + · exact congrArg Sum.inr (rootStart_inj i ((M.face root).corner_injective h.1)) + · exact (rootStart_ne i j ((M.face root).corner_injective h.1)).elim + +def removed (P : (M.system root).Pair (M.nonroots root)) (i : Fin 3) : Finset E := + Finset.univ.image (M.augLabel P i) + +omit [Fintype F] in +lemma removed_acyclic (P : (M.system root).Pair (M.nonroots root)) + (ha : ((M.system root).oppositeGraph P.right).IsAcyclic) (i : Fin 3) : + (D.restrict (Subtype.val : M.removed P i → E)).graph.IsAcyclic := by + apply SimpleGraph.IsAcyclic.anti ?_ (M.augQ_acyclic P ha i) + rintro v w ⟨hv,e,he⟩ + obtain ⟨k,_,hk⟩ := Finset.mem_image.mp e.property + refine ⟨hv,k,?_⟩ + apply Sym2.eq_iff.mp + have hh : s(D.tail e.val,D.head e.val) = s(v,w) := Sym2.eq_iff.mpr he + rw [← hk,M.augLabel_ends] at hh + exact hh + +lemma remainder_connected (P : (M.system root).Pair (M.nonroots root)) + (ha : ((M.system root).oppositeGraph P.right).IsAcyclic) (i : Fin 3) : + (N.restrict (Subtype.val : ↥((M.removed P i)ᶜ) → E)).graph.Connected := + M.duality.complement_connected N D M.dual_simple _ (M.removed_acyclic P ha i) + +omit [Fintype F] in +lemma removed_card (P : (M.system root).Pair (M.nonroots root)) (hr : M.black root) (i : Fin 3) : + (M.removed P i).card = (Finset.univ.filter M.black).card + 1 := by + rw [removed,Finset.card_image_of_injective _ (M.augLabel_inj P hr i),Finset.card_univ,Fintype.card_sum] + have hb : Fintype.card (M.Black root) + 1 = (Finset.univ.filter M.black).card := by + rw [Fintype.card_subtype] + have he : (Finset.univ.filter fun v => M.black v ∧ v ≠ root) = + (Finset.univ.filter M.black).erase root := by ext; simp [and_comm] + rw [he,Finset.card_erase_add_one (by simp [hr])] + change Fintype.card (M.Black root) + 2 = _ + omega +end +end Barnette.Network.ColoredDual +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} (D : Network V E) + +lemma Triangle.edge_incident {S : Finset E} (t : D.Triangle S) (i j : Fin 3) : + D.Incident (t.edge i) (t.corner j) ↔ j = i ∨ j = i+1 := by + rw [D.incident_iff_mem_pair,t.edge_ends,Sym2.mem_iff] + exact or_congr t.corner_injective.eq_iff t.corner_injective.eq_iff + +lemma Triangle.other_root_sides {S : Finset E} (t : D.Triangle S) (i : Fin 3) {e : E} + (he : e ∈ S) : + (∃ j : Fin 2, t.side D (ColoredDual.rootStart i j) (i+2) = e) ↔ e ≠ t.edge i := by + have he' := he + rw [← t.edge_range] at he' + obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp he' + have hh : ∀ i k : Fin 3, + (∃ j : Fin 2, (if i+2 = ColoredDual.rootStart i j+1 then ColoredDual.rootStart i j else i+2) = k) ↔ k ≠ i := by decide + have hs (a b : Fin 3) : t.side D a b = t.edge (if b = a+1 then a else b) := by + unfold Triangle.side; split_ifs <;> rfl + simp only [hs, ne_eq, t.edge_injective.eq_iff] + exact hh i k + +lemma Triangle.opposite_characteristic {S : Finset E} (t : D.Triangle S) + {a b : Fin 3} (hab : a ≠ b) {e : E} (he : e ∈ S) : + e ≠ t.side D a (Barnette.TriangleSystem.thirdIndex a b) ↔ D.Incident e (t.corner b) := by + have he' := he + rw [← t.edge_range] at he' + obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp he' + rw [t.edge_incident] + have hh : ∀ a b k : Fin 3, a ≠ b → + (k ≠ (if Barnette.TriangleSystem.thirdIndex a b = a+1 then a else Barnette.TriangleSystem.thirdIndex a b) ↔ + b = k ∨ b = k+1) := by decide + have hs (a b : Fin 3) : t.side D a b = t.edge (if b = a+1 then a else b) := by + unfold Triangle.side; split_ifs <;> rfl + simp only [hs, ne_eq, t.edge_injective.eq_iff] + exact hh a b k hab + +end +end Barnette.Network + +namespace Barnette.Network.ColoredDual +noncomputable section +open scoped Classical +open Barnette.TriangleSystem +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + {N : Network V E} {D : Network F E} (M : N.ColoredDual D) {root : V} + +omit [Fintype F] in +lemma removed_at_black (P : (M.system root).Pair (M.nonroots root)) (hr : M.black root) + (i : Fin 3) (v : V) (hv : M.black v) {e : E} (he : e ∈ N.star v) : + (e ∈ M.removed P i ↔ + if h : v = root then e ≠ (M.face root).edge i else e = M.qLabel P ⟨v,hv,h⟩) := by + have hb : N.blackEndpoint M.black e = v := N.blackEndpoint_eq M.black M.coloring hv ((N.mem_star _ _).mp he) + by_cases hh : v = root + · clear hb + subst v + simp only + have hb : N.blackEndpoint M.black e = root := N.blackEndpoint_eq M.black M.coloring hr ((N.mem_star _ _).mp he) + constructor + · intro hmem + obtain ⟨t|j,_,ht⟩ := Finset.mem_image.mp hmem + · have hbr : (t : V) = root := (M.qLabel_black P t).symm.trans ((congrArg (N.blackEndpoint M.black) ht).trans hb) + exact (t.property.2 hbr).elim + · exact ((M.face root).other_root_sides D i he).mp ⟨j,ht⟩ + · intro hne + obtain ⟨j,hj⟩ := ((M.face root).other_root_sides D i he).mpr hne + exact Finset.mem_image.mpr ⟨Sum.inr j,Finset.mem_univ _,hj⟩ + · simp only [dite_eq_right hh] + constructor + · intro hmem + obtain ⟨t|j,_,ht⟩ := Finset.mem_image.mp hmem + · have htv : t.val = v := (M.qLabel_black P t).symm.trans ((congrArg (N.blackEndpoint M.black) ht).trans hb) + have ht' : t = ⟨v,hv,hh⟩ := Subtype.ext htv + change M.qLabel P t = e at ht + rw [ht'] at ht + exact ht.symm + · have hbr : N.blackEndpoint M.black (M.augLabel P i (.inr j)) = root := + N.blackEndpoint_eq M.black M.coloring hr ((N.mem_star _ _).mp ((M.face root).side_mem D _ _)) + exact (hh (hb.symm.trans ((congrArg (N.blackEndpoint M.black) ht).symm.trans hbr))).elim + · intro heq + exact Finset.mem_image.mpr ⟨Sum.inl ⟨v,hv,hh⟩,Finset.mem_univ _,heq.symm⟩ + +omit [Fintype F] in +lemma remainder_black_degree (P : (M.system root).Pair (M.nonroots root)) (hr : M.black root) + (i : Fin 3) (v : V) (hv : M.black v) : + ((N.star v).filter fun e => e ∈ (M.removed P i)ᶜ).card = if v = root then 1 else 2 := by + by_cases hh : v = root + · subst v + rw [ite_eq_left rfl] + have he : (N.star root).filter (fun e => e ∈ (M.removed P i)ᶜ) = {(M.face root).edge i} := by + ext e + simp only [Finset.mem_filter,Finset.mem_compl,Finset.mem_singleton] + constructor + · rintro ⟨he,hn⟩ + have hm := M.removed_at_black P hr i root hr he + simpa using (not_congr hm).mp hn + · intro heq; subst e + have hm : (M.face root).edge i ∈ N.star root := by + have hx : (M.face root).edge i ∈ Finset.univ.image (M.face root).edge := Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩ + simpa only [(M.face root).edge_range] using hx + exact ⟨hm,by rw [M.removed_at_black P hr i root hr hm]; simp⟩ + rw [he,Finset.card_singleton] + · rw [ite_eq_right hh] + have he : (N.star v).filter (fun e => e ∈ (M.removed P i)ᶜ) = + (N.star v).erase (M.qLabel P ⟨v,hv,hh⟩) := by + ext e + simp only [Finset.mem_filter,Finset.mem_compl,Finset.mem_erase] + constructor + · rintro ⟨he,hn⟩ + have hm := M.removed_at_black P hr i v hv he + simp only [dite_eq_right hh] at hm + exact ⟨(not_congr hm).mp hn,he⟩ + · rintro ⟨hn,he⟩ + exact ⟨he,by rw [M.removed_at_black P hr i v hv he]; simpa [hh]⟩ + rw [he,Finset.card_erase_of_mem (show M.qLabel P ⟨v,hv,hh⟩ ∈ N.star v from (M.face v).side_mem D _ _),N.card_star M.simple,M.cubic v] + +lemma cubic_cards : Fintype.card E = 3*(Finset.univ.filter M.black).card ∧ + Fintype.card V = 2*(Finset.univ.filter M.black).card := by + have hdeg : ∀ v, N.graph.degree v = 3 := M.cubic + have he := N.black_edge_partition M.black M.coloring Finset.univ + simp only [Finset.filter_true_of_mem (fun _ _ => Finset.mem_univ _),N.card_star M.simple, + hdeg,Finset.sum_const,smul_eq_mul,Finset.card_univ] at he + have hf := N.black_dual_card D M.duality M.simple M.cubic M.black M.coloring + have heu := M.duality.euler N D + constructor <;> omega + +lemma remainder_independent (P : (M.system root).Pair (M.nonroots root)) (hr : M.black root) + (ha : ((M.system root).oppositeGraph P.right).IsAcyclic) (i : Fin 3) : + Function.Injective (N.restrict (Subtype.val : ↥((M.removed P i)ᶜ) → E)).boundary := by + apply boundary_injective_of_tree_card _ (M.remainder_connected P ha i) + rw [Fintype.card_coe] + have hc := Finset.card_add_card_compl (M.removed P i) + rw [M.removed_card P hr i] at hc + have hE := M.cubic_cards.1 + have hV := M.cubic_cards.2 + omega + +omit [Fintype F] in +lemma remainder_incident (P : (M.system root).Pair (M.nonroots root)) (hr : M.black root) + (i : Fin 3) (t : M.Black root) {e : E} (he : e ∈ N.star t.val) + (hm : e ∈ (M.removed P i)ᶜ) : D.Incident e (P.right.value t) := by + have hn := (not_congr (M.removed_at_black P hr i t.val t.property.1 he)).mp (Finset.mem_compl.mp hm) + simp only [dite_eq_right t.property.2] at hn + exact ((M.face t.val).opposite_characteristic D (M.pair_val_ne P t) he).mp hn + +end +end Barnette.Network.ColoredDual + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/MinorDuality.lean b/lean/OAI/Combinatorics/Hamiltonian/MinorDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..18cb9c72dd291d793934434725af57ec74ff648f --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/MinorDuality.lean @@ -0,0 +1,240 @@ +import OAI.Combinatorics.Hamiltonian.Contraction + +namespace OAI + +/-! Exact duality under finite network minors. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +def fullBlack (black : V → Prop) (U : Finset F) : Finset V := + Finset.univ.filter fun v => black v ∧ N.star v ⊆ D.inducedEdges U + +def regionBlack (black : V → Prop) (U : Finset F) (q : N.Regions D U) : ℕ := + ((N.fullBlack D black U).filter fun v => v ∈ N.regionShore D U q).card + +omit [Fintype F] in +lemma sum_regionBlack (black : V → Prop) (U : Finset F) : + ∑ q : N.Regions D U, N.regionBlack D black U q = (N.fullBlack D black U).card := by + simp only [regionBlack,Finset.card_filter,N.mem_regionShore] + rw [Finset.sum_comm] + simp + +omit [Fintype F] in +lemma regionBalance_singleton (black : V → Prop) (U : Finset F) (q : N.Regions D U) + {v : V} (hq : N.regionShore D U q = {v}) : + N.regionBalance D black U q = colorSign black v := by + simp [regionBalance,hq] + +omit [Fintype F] in +lemma regionBalance_complement_singleton (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (U : Finset F) (q : N.Regions D U) {v : V} (hq : (N.regionShore D U q)ᶜ = {v}) : + N.regionBalance D black U q = -colorSign black v := by + have hh := Finset.sum_add_sum_compl (N.regionShore D U q) (colorSign black) + rw [N.colorSign_sum hN h3 black hc,hq,Finset.sum_singleton] at hh + change (∑ v ∈ N.regionShore D U q, colorSign black v) = _ + omega + +omit [Fintype F] in +lemma singleton_regionBlack (hN : N.Simple) (black : V → Prop) + (U : Finset F) (q : N.Regions D U) {v : V} + (hq : N.regionShore D U q = {v}) (hv : black v) : + 1 ≤ N.regionBlack D black U q := by + apply Finset.card_pos.mpr + refine ⟨v,Finset.mem_filter.mpr ⟨?_,?_⟩⟩ + · simp only [fullBlack,Finset.mem_filter,Finset.mem_univ,true_and] + exact ⟨hv,N.singleton_region_star D hN U q hq⟩ + · simp [hq] + +omit [Fintype F] in + +lemma region_density (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (hcut : N.ThreeEdgeConnected) (htr : N.TrivialThreeCuts) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (root : V) (hbroot : black root) (U : Finset F) + (hr : N.star root ⊆ D.inducedEdges U) (q : N.Regions D U) : + 4 + N.regionBalance D black U q - 2*(N.regionBlack D black U q : ℤ) ≤ N.rim D U q := by + have hm : 3 ≤ (D.inducedEdges U).card := by + have hh := Finset.card_le_card hr + rwa [N.card_star hN,h3 root] at hh + have hd := N.rim_ge_three D hcut U hm q + by_cases hd4 : 4 ≤ N.rim D U q + · have hh := rim_defect (N.blackRim D black U q) (N.rim D U q) + (N.regionBalance D black U q) (N.blackRim_le D black U q) hd4 + (N.region_balance_rim D hN h3 black hc U q) + omega + · have hd3 : N.rim D U q = 3 := by omega + rcases htr _ (N.rim_three_cut D hcut U hm q hd3) with hsing | hsing + · obtain ⟨v,hv⟩ := Finset.card_eq_one.mp hsing + have hβ := N.regionBalance_singleton D black U q hv + by_cases hb : black v + · have hB := N.singleton_regionBlack D hN black U q hv hb + simp only [colorSign,hb,ite_true] at hβ + omega + · simp only [colorSign,hb,ite_false] at hβ + omega + · obtain ⟨v,hv⟩ := Finset.card_eq_one.mp hsing + have hvr := N.complement_singleton_root D hN h3 hcut U root hr q hd3 hv + have hβ := N.regionBalance_complement_singleton D hN h3 black hc U q hv + rw [hvr] at hβ + simp only [colorSign,hbroot,ite_true] at hβ + omega + +theorem induced_density (h : N.Duality D) (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (hcut : N.ThreeEdgeConnected) (htr : N.TrivialThreeCuts) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (root : V) (hbroot : black root) (U : Finset F) + (hr : N.star root ⊆ D.inducedEdges U) : + ((D.inducedEdges U).card : ℤ) - (N.fullBlack D black U).card ≤ 2*(U.card : ℤ)-4 := by + have hU : U.Nonempty := by + have hstar : (N.star root).Nonempty := Finset.card_pos.mp (by rw [N.card_star hN,h3 root]; decide) + obtain ⟨e,he⟩ := hstar + exact ⟨D.tail e,((D.mem_inducedEdges U e).mp (hr he)).1⟩ + have heuler := N.induced_euler_bound D h U hU + have hsum := Finset.sum_le_sum (s := Finset.univ) + (fun q _ => N.region_density D hN h3 hcut htr black hc root hbroot U hr q) + simp only [Finset.sum_sub_distrib,Finset.sum_add_distrib,Finset.sum_const, + Finset.card_univ,nsmul_eq_mul,← Finset.mul_sum,← Nat.cast_sum, + N.sum_regionBalance D hN h3 black hc,N.sum_regionBlack,N.sum_rim] at hsum + push_cast at hsum + omega + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma three_corner_count (p : Fin 3 → Prop) : + ((min (2 : ℕ) ((Finset.univ.filter fun i => ¬p i).card) : ℕ) : ℤ) + + (∑ i : Fin 3, if p i ∧ p (i+1) then (1 : ℤ) else 0) = + 2 + if ∀ i, p i then 1 else 0 := by + have h11 : (1 : Fin 3) + 1 = 2 := by decide + have h21 : (2 : Fin 3) + 1 = 0 := by decide + by_cases h0 : p 0 <;> by_cases h1 : p 1 <;> by_cases h2 : p 2 <;> + simp only [Finset.card_filter,Fin.sum_univ_succ,Fin.forall_fin_succ] <;> + norm_num [h0,h1,h2,h11,h21] + +omit [Fintype V] [Fintype F] in +lemma Triangle.edges_in_count {s : Finset E} (t : D.Triangle s) (U : Finset F) : + ((s.filter fun e => e ∈ D.inducedEdges U).card : ℤ) = + ∑ i : Fin 3, if t.corner i ∈ U ∧ t.corner (i+1) ∈ U then (1 : ℤ) else 0 := by + conv_lhs => rw [← t.edge_range] + rw [Finset.filter_image,Finset.card_image_of_injective _ t.edge_injective, + Finset.card_filter,Nat.cast_sum] + apply Finset.sum_congr rfl + intro i _ + have he := t.edge_ends i + have hh : t.edge i ∈ D.inducedEdges U ↔ t.corner i ∈ U ∧ t.corner (i+1) ∈ U := by + rw [D.mem_inducedEdges] + rcases Sym2.eq_iff.mp he with ⟨ht,hh⟩ | ⟨ht,hh⟩ <;> simp [ht,hh,and_comm] + simp [hh] + +omit [Fintype V] [Fintype F] in +lemma Triangle.all_corners {s : Finset E} (t : D.Triangle s) (U : Finset F) : + s ⊆ D.inducedEdges U ↔ ∀ i, t.corner i ∈ U := by + constructor + · intro h i + have hm : t.edge i ∈ s := by + have hi : t.edge i ∈ Finset.univ.image t.edge := Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩ + simpa only [t.edge_range] using hi + have he := (D.mem_inducedEdges U _).mp (h hm) + rcases Sym2.eq_iff.mp (t.edge_ends i) with ⟨ht,hh⟩ | ⟨ht,hh⟩ + · exact ht ▸ he.1 + · exact hh ▸ he.2 + · intro h e he + rw [← t.edge_range] at he + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he + apply (D.mem_inducedEdges U _).mpr + rcases Sym2.eq_iff.mp (t.edge_ends i) with ⟨ht,hh⟩ | ⟨ht,hh⟩ <;> simp [ht,hh,h] + +omit [Fintype F] in +lemma black_edge_partition (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (K : Finset E) : + ∑ v ∈ Finset.univ.filter black, ((N.star v).filter fun e => e ∈ K).card = K.card := by + have hstar : ∀ v, ((N.star v).filter fun e => e ∈ K) = + K.filter fun e => N.Incident e v := by + intro v; ext e; simp [star,and_comm] + simp only [hstar,Finset.card_filter] + rw [Finset.sum_comm] + have he (e : E) : ∀ v, black v → (N.Incident e v ↔ N.blackEndpoint black e = v) := by + intro v hv + exact ⟨N.blackEndpoint_eq black hc hv,fun hh => hh ▸ (N.blackEndpoint_spec black hc e).2⟩ + conv_rhs => rw [Finset.card_eq_sum_ones] + apply Finset.sum_congr rfl + intro e _ + have hrewrite : ∀ v ∈ Finset.univ.filter black, + (if N.Incident e v then 1 else 0 : ℕ) = if N.blackEndpoint black e = v then 1 else 0 := by + intro v hv; rw [he e v ((Finset.mem_filter.mp hv).2)] + rw [Finset.sum_congr rfl hrewrite] + simp [(N.blackEndpoint_spec black hc e).1] + +lemma black_dual_card (h : N.Duality D) (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) : + Fintype.card F = (Finset.univ.filter black).card + 2 := by + have hdeg : ∀ v, N.graph.degree v = 3 := h3 + have he := N.black_edge_partition black hc Finset.univ + simp only [Finset.filter_true_of_mem (fun _ _ => Finset.mem_univ _),N.card_star hN,hdeg, + Finset.sum_const,smul_eq_mul,Finset.card_univ] at he + have hv := N.cubic_region_count hN h3 Finset.univ + have hcut : N.cut Finset.univ = ∅ := by ext e; simp [cut] + have hreg : N.regionEdges Finset.univ = Finset.univ := by ext e; simp [regionEdges] + rw [hcut,hreg,Finset.card_empty,Finset.card_univ] at hv + simp only [Finset.card_univ,add_zero] at hv + have heu := h.euler N D + omega + +omit [Fintype F] in +lemma capacity_identity (face : ∀ v, D.Triangle (N.star v)) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (U : Finset F) : + (∑ v ∈ Finset.univ.filter black, + ((min (2 : ℕ) ((Finset.univ.filter fun i => (face v).corner i ∉ U).card) : ℕ) : ℤ)) + + (D.inducedEdges U).card = + 2 * ((Finset.univ.filter black).card : ℤ) + (N.fullBlack D black U).card := by + have he := N.black_edge_partition black hc (D.inducedEdges U) + have hb : (∑ v ∈ Finset.univ.filter black, + if N.star v ⊆ D.inducedEdges U then (1 : ℤ) else 0) = (N.fullBlack D black U).card := by + simp only [fullBlack,Finset.card_filter,Nat.cast_sum,Finset.sum_filter, + ite_and,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + calc + _ = ∑ v ∈ Finset.univ.filter black, + (((min (2 : ℕ) ((Finset.univ.filter fun i => (face v).corner i ∉ U).card) : ℕ) : ℤ) + + ((N.star v).filter fun e => e ∈ D.inducedEdges U).card) := by + simp only [Finset.sum_add_distrib,← Nat.cast_sum,he] + _ = ∑ v ∈ Finset.univ.filter black, + (2 + if N.star v ⊆ D.inducedEdges U then (1 : ℤ) else 0) := by + apply Finset.sum_congr rfl + intro v _ + rw [(face v).edges_in_count D U] + simp only [(face v).all_corners D U] + convert three_corner_count (fun i => (face v).corner i ∈ U) using 1 <;> congr! + _ = _ := by rw [Finset.sum_add_distrib,hb]; simp [mul_comm] + +theorem capacity_full (h : N.Duality D) (hN : N.Simple) (h3 : N.graph.IsRegularOfDegree 3) + (hcut : N.ThreeEdgeConnected) (htr : N.TrivialThreeCuts) + (face : ∀ v, D.Triangle (N.star v)) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (root : V) (hbroot : black root) (S : Finset F) + (hr : ∀ i, (face root).corner i ∉ S) : + 2*S.card ≤ ∑ v ∈ Finset.univ.filter black, + min 2 ((Finset.univ.filter fun i => (face v).corner i ∈ S).card) := by + have hd := N.induced_density D h hN h3 hcut htr black hc root hbroot Sᶜ + ((face root).all_corners D Sᶜ |>.mpr (by simpa using hr)) + have hi := N.capacity_identity D face black hc Sᶜ + simp only [Finset.mem_compl,not_not] at hi + have hu := Finset.card_add_card_compl S + have hb := N.black_dual_card D h hN h3 black hc + simp only [← Nat.cast_sum] at hi + omega + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/MinorModel.lean b/lean/OAI/Combinatorics/Hamiltonian/MinorModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..681f0b0feeb85dd50473347fb15ab040d63fb2e3 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/MinorModel.lean @@ -0,0 +1,279 @@ +import OAI.Combinatorics.Hamiltonian.Corridors + +namespace OAI + +/-! Clean finite walks, disjoint grown branches, and lattice minors. -/ + +namespace Barnette + +noncomputable section + +structure MinorModel {V W : Type*} (G : SimpleGraph V) (H : SimpleGraph W) where + branch : V → Set W + branch_finite : ∀ v, (branch v).Finite + branch_connected : ∀ v, (H.induce (branch v)).Connected + branches_disjoint : ∀ v w, v ≠ w → Disjoint (branch v) (branch w) + adjacency : ∀ v w, G.Adj v w → ∃ a ∈ branch v, ∃ b ∈ branch w, H.Adj a b + +namespace WalkSelection + +variable {W : Type*} {H : SimpleGraph W} + +theorem shortest_join {A B : Set W} + (hex : ∃ a ∈ A, ∃ b ∈ B, H.Reachable a b) : + ∃ (a : W) (_ha : a ∈ A) (b : W) (_hb : b ∈ B) (p : H.Walk a b), + p.IsPath ∧ (∀ x ∈ p.support, x ∈ A → x = a) ∧ + (∀ x ∈ p.support, x ∈ B → x = b) := by + classical + let P : ℕ → Prop := fun n => ∃ a ∈ A, ∃ b ∈ B, ∃ p : H.Walk a b, p.length = n + have hp : ∃ n, P n := by + obtain ⟨a, ha, b, hb, ⟨p⟩⟩ := hex + exact ⟨p.length, a, ha, b, hb, p, rfl⟩ + obtain ⟨a, ha, b, hb, p, hlen⟩ := Nat.find_spec hp + have minimal {x y : W} (hx : x ∈ A) (hy : y ∈ B) (q : H.Walk x y) : + p.length ≤ q.length := by + rw [hlen] + exact Nat.find_min' hp ⟨x, hx, y, hy, q, rfl⟩ + have hpath : p.IsPath := by + obtain ⟨q, hq⟩ := p.reachable.exists_walk_length_eq_dist + apply p.isPath_of_length_eq_dist + exact le_antisymm (hq ▸ minimal ha hb q) (SimpleGraph.dist_le p) + refine ⟨a, ha, b, hb, p, hpath, ?_, ?_⟩ + · intro x hx hxA + by_contra hxa + have hshort := p.length_dropUntil_lt_length hx hxa + exact (not_lt_of_ge (minimal hxA hb (p.dropUntil x hx))) hshort + · intro x hx hxB + by_contra hxb + have hshort := p.length_takeUntil_lt_length hx hxb + exact (not_lt_of_ge (minimal ha hxB (p.takeUntil x hx))) hshort + +structure CleanConnection (A B C : Set W) where + start : W + finish : W + start_mem : start ∈ A + finish_mem : finish ∈ B + walk : H.Walk start finish + isPath : walk.IsPath + support_subset : ∀ x ∈ walk.support, x ∈ C + clean_start : ∀ x ∈ walk.support, x ∈ A → x = start + clean_finish : ∀ x ∈ walk.support, x ∈ B → x = finish + +theorem exists_clean_connection {A B C : Set W} + (hC : (H.induce C).Connected) (hA : (A ∩ C).Nonempty) (hB : (B ∩ C).Nonempty) : + Nonempty (CleanConnection (H := H) A B C) := by + classical + obtain ⟨a, ha, haC⟩ := hA + obtain ⟨b, hb, hbC⟩ := hB + obtain ⟨u, hu, v, hv, p, hpath, hcleanA, hcleanB⟩ := + shortest_join (H := H.induce C) (A := {x | x.val ∈ A}) (B := {x | x.val ∈ B}) + ⟨⟨a, haC⟩, ha, ⟨b, hbC⟩, hb, hC _ _⟩ + let f : H.induce C →g H := ⟨Subtype.val, fun h => h⟩ + let q : H.Walk u.val v.val := p.map f + have hs : q.support = p.support.map Subtype.val := p.support_map _ + refine ⟨{ + start := u.val + finish := v.val + start_mem := hu + finish_mem := hv + walk := q + isPath := hpath.map Subtype.val_injective + support_subset := ?_ + clean_start := ?_ + clean_finish := ?_ + }⟩ + · intro x hx + rw [hs] at hx + obtain ⟨z, _, rfl⟩ := List.mem_map.mp hx + exact z.property + · intro x hx hxA + rw [hs] at hx + obtain ⟨z, hz, rfl⟩ := List.mem_map.mp hx + exact congrArg Subtype.val (hcleanA z hz hxA) + · intro x hx hxB + rw [hs] at hx + obtain ⟨z, hz, rfl⟩ := List.mem_map.mp hx + exact congrArg Subtype.val (hcleanB z hz hxB) + +namespace CleanConnection +variable {A B C : Set W} (p : CleanConnection (H := H) A B C) + +def leftSet : Set W := {x | x ∈ p.walk.dropLast.support} + +theorem leftSet_finite : p.leftSet.Finite := p.walk.dropLast.support.finite_toSet + +theorem leftSet_connected : (H.induce p.leftSet).Connected := + p.walk.dropLast.connected_induce_support + +theorem start_mem_leftSet : p.start ∈ p.leftSet := p.walk.dropLast.start_mem_support + +theorem leftSet_subset : p.leftSet ⊆ C := by + intro x hx + apply p.support_subset x + exact (p.walk.isSubwalk_take _).support_subset hx + +theorem leftSet_disjoint_finish (hAB : Disjoint A B) : Disjoint p.leftSet B := by + have hne : p.start ≠ p.finish := by + intro heq + exact Set.disjoint_left.mp hAB p.start_mem (heq ▸ p.finish_mem) + have hn : ¬p.walk.Nil := SimpleGraph.Walk.not_nil_of_ne hne + have hd := p.isPath.support_nodup + rw [← p.walk.support_dropLast_concat hn] at hd + have hfinish : p.finish ∉ p.leftSet := by + intro h + exact hd.disjoint h (by simp) + rw [Set.disjoint_left] + intro x hx hxB + have hs : x ∈ p.walk.support := (p.walk.isSubwalk_take _).support_subset hx + have heq := p.clean_finish x hs hxB + exact hfinish (heq ▸ hx) + +theorem leftSet_adj_finish (hAB : Disjoint A B) : + ∃ a ∈ p.leftSet, H.Adj a p.finish := by + have hne : p.start ≠ p.finish := by + intro heq + exact Set.disjoint_left.mp hAB p.start_mem (heq ▸ p.finish_mem) + exact ⟨p.walk.penultimate, p.walk.dropLast.end_mem_support, + p.walk.adj_penultimate (SimpleGraph.Walk.not_nil_of_ne hne)⟩ + +end CleanConnection + +end WalkSelection +end +end Barnette + +namespace Barnette + +namespace CorridorModel +noncomputable section +variable {V W : Type*} {G : SimpleGraph V} {H : SimpleGraph W} + +private theorem exists_edgeDart (e : G.edgeSet) : ∃ d : G.Dart, d.edge = e.val := by + rcases e with ⟨e, he⟩ + induction e using Sym2.inductionOn with + | _ a b => exact ⟨⟨(a, b), he⟩, rfl⟩ + +def edgeDart (e : G.edgeSet) : G.Dart := Classical.choose (exists_edgeDart e) + +@[simp] theorem edgeDart_edge (e : G.edgeSet) : (edgeDart e).edge = e.val := + Classical.choose_spec (exists_edgeDart e) + +variable (M : CorridorModel G H) + +def connection (e : G.edgeSet) : WalkSelection.CleanConnection (H := H) + (M.branch (edgeDart e).fst) (M.branch (edgeDart e).snd) (M.corridor (edgeDart e)) := + Classical.choice (WalkSelection.exists_clean_connection + (M.corridor_connected _) (M.incident_meets _).1 (M.incident_meets _).2) + +def extension (e : G.edgeSet) : Set W := (M.connection e).leftSet + +theorem extension_finite (e : G.edgeSet) : (M.extension e).Finite := + (M.connection e).leftSet_finite + +theorem extension_connected (e : G.edgeSet) : (H.induce (M.extension e)).Connected := + (M.connection e).leftSet_connected + +theorem extension_subset (e : G.edgeSet) : M.extension e ⊆ M.corridor (edgeDart e) := + (M.connection e).leftSet_subset + +theorem extension_disjoint_branch (e : G.edgeSet) (v : V) (hv : v ≠ (edgeDart e).fst) : + Disjoint (M.extension e) (M.branch v) := by + by_cases hs : v = (edgeDart e).snd + · subst v + exact (M.connection e).leftSet_disjoint_finish + (M.branches_disjoint _ _ (edgeDart e).fst_ne_snd) + · exact ((M.nonincident_disjoint _ _ hv hs).mono_right (M.extension_subset e)).symm + +theorem extensions_disjoint (e f : G.edgeSet) (hef : e ≠ f) : + Disjoint (M.extension e) (M.extension f) := by + have hne : (edgeDart e).edge ≠ (edgeDart f).edge := by + simpa only [edgeDart_edge] using (fun h => hef (Subtype.ext h) : e.val ≠ f.val) + exact (M.corridors_disjoint _ _ hne).mono (M.extension_subset e) (M.extension_subset f) + +def grownBranch (v : V) : Set W := M.branch v ∪ + ⋃ e : {e : G.edgeSet // (edgeDart e).fst = v}, M.extension e.val + +theorem branch_subset_grown (v : V) : M.branch v ⊆ M.grownBranch v := + Set.subset_union_left + +theorem extension_subset_grown (e : G.edgeSet) : M.extension e ⊆ M.grownBranch (edgeDart e).fst := + fun _ hx => Or.inr (Set.mem_iUnion.mpr ⟨⟨e, rfl⟩, hx⟩) + +theorem grownBranch_connected (v : V) : (H.induce (M.grownBranch v)).Connected := by + obtain ⟨⟨a, ha⟩⟩ := (M.branch_connected v).nonempty + apply H.induce_connected_of_patches a (M.branch_subset_grown v ha) + intro x hx + rcases hx with hx | hx + · exact ⟨M.branch v, M.branch_subset_grown v, ha, hx, M.branch_connected v _ _⟩ + · obtain ⟨⟨e, he⟩, hx⟩ := Set.mem_iUnion.mp hx + have hext : M.extension e ⊆ M.grownBranch v := by + simpa only [he] using M.extension_subset_grown e + have hi : (M.branch v ∩ M.extension e).Nonempty := by + refine ⟨(M.connection e).start, ?_, (M.connection e).start_mem_leftSet⟩ + simpa only [he] using (M.connection e).start_mem + exact ⟨M.branch v ∪ M.extension e, + Set.union_subset (M.branch_subset_grown v) hext, Or.inl ha, Or.inr hx, + SimpleGraph.induce_union_connected (M.branch_connected v).preconnected + (M.extension_connected e).preconnected hi _ _⟩ + +theorem grownBranches_disjoint (v w : V) (hvw : v ≠ w) : + Disjoint (M.grownBranch v) (M.grownBranch w) := by + rw [Set.disjoint_left] + intro x hx hy + rcases hx with hx | hx <;> rcases hy with hy | hy + · exact Set.disjoint_left.mp (M.branches_disjoint v w hvw) hx hy + · obtain ⟨⟨e, he⟩, hy⟩ := Set.mem_iUnion.mp hy + exact Set.disjoint_left.mp (M.extension_disjoint_branch e v (he ▸ hvw)) hy hx + · obtain ⟨⟨e, he⟩, hx⟩ := Set.mem_iUnion.mp hx + exact Set.disjoint_left.mp (M.extension_disjoint_branch e w (he ▸ hvw.symm)) hx hy + · obtain ⟨⟨e, he⟩, hx⟩ := Set.mem_iUnion.mp hx + obtain ⟨⟨f, hf⟩, hy⟩ := Set.mem_iUnion.mp hy + have hef : e ≠ f := by + intro h + subst f + exact hvw (he.symm.trans hf) + exact Set.disjoint_left.mp (M.extensions_disjoint e f hef) hx hy + +theorem grownBranch_adjacency (v w : V) (hvw : G.Adj v w) : + ∃ a ∈ M.grownBranch v, ∃ b ∈ M.grownBranch w, H.Adj a b := by + let e : G.edgeSet := ⟨s(v, w), hvw⟩ + have hAB := M.branches_disjoint _ _ (edgeDart e).fst_ne_snd + obtain ⟨a, ha, hadj⟩ := (M.connection e).leftSet_adj_finish hAB + have ha' : a ∈ M.grownBranch (edgeDart e).fst := M.extension_subset_grown e ha + have hb' : (M.connection e).finish ∈ M.grownBranch (edgeDart e).snd := + M.branch_subset_grown _ (M.connection e).finish_mem + have hd : (edgeDart e).edge = s(v, w) := edgeDart_edge e + rcases SimpleGraph.dart_edge_eq_mk'_iff'.mp hd with ⟨h₁, h₂⟩ | ⟨h₂, h₁⟩ + · exact ⟨a, h₁ ▸ ha', (M.connection e).finish, h₂ ▸ hb', hadj⟩ + · exact ⟨(M.connection e).finish, h₁ ▸ hb', a, h₂ ▸ ha', hadj.symm⟩ + +variable [Fintype V] + +theorem grownBranch_finite (v : V) : (M.grownBranch v).Finite := by + classical + exact (M.branch_finite v).union (Set.finite_iUnion (fun e => M.extension_finite e.val)) + +def toMinorModel : MinorModel G H where + branch := M.grownBranch + branch_finite := M.grownBranch_finite + branch_connected := M.grownBranch_connected + branches_disjoint := M.grownBranches_disjoint + adjacency := M.grownBranch_adjacency + +end +end CorridorModel +end Barnette + +namespace Barnette.PlaneEmbedding +noncomputable section +variable {V : Type*} [Fintype V] {G : SimpleGraph V} + +theorem exists_lattice_minor_model (E : PlaneEmbedding G) : + Nonempty (MinorModel G SquareGrid.graph) := by + classical + obtain ⟨M⟩ := E.exists_lattice_corridor_model + exact ⟨M.toMinorModel⟩ +end +end Barnette.PlaneEmbedding + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Model.lean b/lean/OAI/Combinatorics/Hamiltonian/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..056f49d1fea317b20475f19474222b82d3cec820 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Model.lean @@ -0,0 +1,50 @@ +import Mathlib + +namespace OAI + +namespace Barnette + +universe u + +/-- A topological plane drawing of a simple graph, with no crossings. -/ +structure PlaneEmbedding {V : Type u} (G : SimpleGraph V) where + point : V → ℝ × ℝ + point_injective : Function.Injective point + arc : ∀ (v w : V), G.Adj v w → Path (point v) (point w) + arc_injective : ∀ (v w : V) (h : G.Adj v w), + Function.Injective (arc v w h) + arc_reverse : ∀ (v w : V) (h : G.Adj v w), + arc w v h.symm = (arc v w h).symm + arc_avoids_vertices : ∀ (v w : V) (h : G.Adj v w) + (t : unitInterval) (z : V), + arc v w h t = point z → + (t = 0 ∧ z = v) ∨ (t = 1 ∧ z = w) + interiors_disjoint : ∀ (v w x y : V) (h : G.Adj v w) (k : G.Adj x y) + (t s : unitInterval), + t ≠ 0 → t ≠ 1 → s ≠ 0 → s ≠ 1 → + arc v w h t = arc x y k s → + (v = x ∧ w = y) ∨ (v = y ∧ w = x) + +/-- Planarity means existence of a crossing-free topological plane embedding. -/ +def Planar {V : Type u} (G : SimpleGraph V) : Prop := + Nonempty (PlaneEmbedding G) + +/-- Deleting any set of at most two vertices leaves a connected graph of order at least two. -/ +def ThreeVertexConnected {V : Type u} [Fintype V] (G : SimpleGraph V) : Prop := + 4 ≤ Fintype.card V ∧ + ∀ S : Finset V, S.card ≤ 2 → (G.induce {v | v ∉ S}).Connected + +/-- A single spanning cycle, not a possibly disconnected spanning 2-factor. -/ +def HasHamiltonianCycle {V : Type u} [DecidableEq V] (G : SimpleGraph V) : Prop := + ∃ v : V, ∃ p : G.Walk v v, p.IsHamiltonianCycle + +/-- Cubic bipartite three-vertex-connected plane graphs have a Hamiltonian cycle. -/ +def MainStatement : Prop := + ∀ (V : Type u) [Fintype V] [DecidableEq V] (G : SimpleGraph V) + [DecidableRel G.Adj], + G.IsRegularOfDegree 3 → G.IsBipartite → Planar G → + ThreeVertexConnected G → HasHamiltonianCycle G + +end Barnette + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Network.lean b/lean/OAI/Combinatorics/Hamiltonian/Network.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6214da3554cd07d02efc91210f27deee2924c3a --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Network.lean @@ -0,0 +1,266 @@ +import OAI.Combinatorics.Hamiltonian.Model + +namespace OAI + +/-! Oriented finite networks, cycle and cut spaces, and graph realization. -/ + +namespace Barnette + +structure Network (V E : Type*) where + tail : E → V + head : E → V + +namespace Network +noncomputable section +variable {V E : Type*} (N : Network V E) + +def graph : SimpleGraph V where + Adj v w := v ≠ w ∧ ∃ e, (N.tail e = v ∧ N.head e = w) ∨ + (N.tail e = w ∧ N.head e = v) + symm := ⟨by rintro v w ⟨h, e, hi⟩; exact ⟨h.symm, e, hi.symm⟩⟩ + loopless := ⟨fun v h => h.1 rfl⟩ + +theorem edge_reachable (e : E) : N.graph.Reachable (N.tail e) (N.head e) := by + by_cases h : N.tail e = N.head e + · rw [h] + · exact (show N.graph.Adj (N.tail e) (N.head e) from + ⟨h, e, Or.inl ⟨rfl, rfl⟩⟩).reachable + +def gradient : (V → ℝ) →ₗ[ℝ] (E → ℝ) where + toFun f e := f (N.head e) - f (N.tail e) + map_add' f g := by ext e; dsimp; ring + map_smul' c f := by ext e; dsimp; ring + +@[simp] theorem gradient_apply (f : V → ℝ) (e : E) : + N.gradient f e = f (N.head e) - f (N.tail e) := rfl + +@[simp] theorem gradient_const (a : ℝ) : N.gradient (fun _ => a) = 0 := by + ext e; simp + +theorem gradient_eq_zero_iff (f : V → ℝ) : + N.gradient f = 0 ↔ ∀ e, f (N.head e) = f (N.tail e) := by + simp only [funext_iff, gradient_apply, Pi.zero_apply, sub_eq_zero] + +theorem gradient_zero_adj {f : V → ℝ} (hf : N.gradient f = 0) + {v w : V} (h : N.graph.Adj v w) : f v = f w := by + obtain ⟨_, e, ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩⟩ := h + · exact ((N.gradient_eq_zero_iff f).mp hf e).symm + · exact (N.gradient_eq_zero_iff f).mp hf e + +theorem gradient_zero_reachable {f : V → ℝ} (hf : N.gradient f = 0) + {v w : V} (h : N.graph.Reachable v w) : f v = f w := by + obtain ⟨p⟩ := h + induction p with + | nil => rfl + | cons h p ih => exact (N.gradient_zero_adj hf h).trans ih + +def constant : ℝ →ₗ[ℝ] (V → ℝ) where + toFun a _ := a + map_add' _ _ := rfl + map_smul' _ _ := rfl + +theorem ker_gradient (h : N.graph.Connected) : + N.gradient.ker = (constant (V := V)).range := by + obtain ⟨v⟩ := h.nonempty + ext f + constructor + · intro hf + refine ⟨f v, ?_⟩ + ext w + exact N.gradient_zero_reachable hf (h v w) + · rintro ⟨a, rfl⟩ + exact N.gradient_const a + +variable [Fintype V] [Fintype E] +local instance : DecidableEq V := Classical.decEq _ +local instance : DecidableEq E := Classical.decEq _ + +def incidence : Matrix V E ℝ := fun v e => + (if N.head e = v then 1 else 0) - (if N.tail e = v then 1 else 0) + +def boundary : (E → ℝ) →ₗ[ℝ] (V → ℝ) := Matrix.toLin' N.incidence + +omit [Fintype V] in +@[simp] theorem boundary_apply (x : E → ℝ) (v : V) : + N.boundary x v = ∑ e, ((if N.head e = v then x e else 0) - + (if N.tail e = v then x e else 0)) := by + classical + simp [boundary, Matrix.toLin'_apply, Matrix.mulVec, dotProduct, incidence, + sub_mul, ite_mul] + +omit [Fintype E] in +theorem gradient_matrix : N.gradient = Matrix.toLin' N.incidence.transpose := by + classical + apply LinearMap.ext + intro f + ext e + simp [Matrix.toLin'_apply, Matrix.mulVec, dotProduct, incidence, + sub_mul, ite_mul, Finset.sum_sub_distrib] + +theorem sum_boundary (x : E → ℝ) : ∑ v, N.boundary x v = 0 := by + classical + simp only [boundary_apply] + rw [Finset.sum_comm] + simp [Finset.sum_sub_distrib] + +omit [Fintype E] in +theorem rank_gradient (h : N.graph.Connected) : + Module.finrank ℝ N.gradient.range + 1 = Fintype.card V := by + obtain ⟨v⟩ := h.nonempty + have hi : Function.Injective (constant (V := V)) := by + intro a b hab + exact congrFun hab v + have hk : Module.finrank ℝ N.gradient.ker = 1 := by + rw [N.ker_gradient h, LinearMap.finrank_range_of_inj hi] + exact Module.finrank_self ℝ + have hh := N.gradient.finrank_range_add_finrank_ker + simpa only [hk, Module.finrank_pi] using hh + +theorem rank_boundary (h : N.graph.Connected) : + Module.finrank ℝ N.boundary.range + 1 = Fintype.card V := by + have hh := N.rank_gradient h + have he : Module.finrank ℝ N.boundary.range = Module.finrank ℝ N.gradient.range := by + rw [N.gradient_matrix, boundary, Matrix.toLin'_apply', Matrix.toLin'_apply', + ← Matrix.rank, ← Matrix.rank, Matrix.rank_transpose] + rwa [he] + +theorem dim_cycles (h : N.graph.Connected) : + Module.finrank ℝ N.boundary.ker + Fintype.card V = Fintype.card E + 1 := by + have hr := N.rank_boundary h + have hk := N.boundary.finrank_range_add_finrank_ker + rw [Module.finrank_pi] at hk + omega + +theorem boundary_adjoint (x : E → ℝ) (f : V → ℝ) : + ∑ v, N.boundary x v * f v = ∑ e, x e * N.gradient f e := by + classical + simp only [boundary_apply, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + simp [sub_mul, ite_mul, Finset.sum_sub_distrib, mul_sub] + +variable {F : Type*} [Fintype F] (D : Network F E) + +theorem orthogonal_symm (h : ∀ f, N.boundary (D.gradient f) = 0) : + ∀ f, D.boundary (N.gradient f) = 0 := by + classical + intro f + ext y + calc + D.boundary (N.gradient f) y = + ∑ z, D.boundary (N.gradient f) z * (fun z : F => if z = y then (1 : ℝ) else 0) z := by + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + _ = ∑ e, N.gradient f e * D.gradient ((fun z : F => if z = y then (1 : ℝ) else 0)) e := + D.boundary_adjoint _ _ + _ = ∑ e, D.gradient ((fun z : F => if z = y then (1 : ℝ) else 0)) e * N.gradient f e := by + apply Finset.sum_congr rfl + intro e _ + exact mul_comm _ _ + _ = ∑ v, N.boundary (D.gradient ((fun z : F => if z = y then (1 : ℝ) else 0))) v * f v := + (N.boundary_adjoint _ _).symm + _ = 0 := by rw [h]; simp + +structure Duality : Prop where + connected : N.graph.Connected + dual_connected : D.graph.Connected + cycles_eq_cuts : N.boundary.ker = D.gradient.range + dual_cycles_eq_cuts : D.boundary.ker = N.gradient.range + +private theorem ker_eq_range_of_orth_card + (hN : N.graph.Connected) (hD : D.graph.Connected) + (hc : Fintype.card V + Fintype.card F = Fintype.card E + 2) + (ho : ∀ f, N.boundary (D.gradient f) = 0) : + N.boundary.ker = D.gradient.range := by + have hle : D.gradient.range ≤ N.boundary.ker := by + rintro _ ⟨f, rfl⟩ + exact ho f + have hd₁ := N.dim_cycles hN + have hd₂ := D.rank_gradient hD + exact (Submodule.eq_of_le_of_finrank_eq hle (by omega)).symm + +theorem duality_of_orth_card + (hN : N.graph.Connected) (hD : D.graph.Connected) + (hc : Fintype.card V + Fintype.card F = Fintype.card E + 2) + (ho : ∀ f, N.boundary (D.gradient f) = 0) : N.Duality D where + connected := hN + dual_connected := hD + cycles_eq_cuts := N.ker_eq_range_of_orth_card D hN hD hc ho + dual_cycles_eq_cuts := D.ker_eq_range_of_orth_card N hD hN (by omega) + (N.orthogonal_symm D ho) + +theorem Duality.euler (h : N.Duality D) : + Fintype.card V + Fintype.card F = Fintype.card E + 2 := by + have h₁ := N.dim_cycles h.connected + rw [h.cycles_eq_cuts] at h₁ + have h₂ := D.rank_gradient h.dual_connected + omega + +end +end Network +end Barnette + +namespace Barnette +noncomputable section +open scoped Classical +variable {V : Type*} [Fintype V] [DecidableEq V] {G : SimpleGraph V} + [DecidableRel G.Adj] + +omit [DecidableEq V] in +lemma cubic_bipartite_order [Nonempty V] (hc : G.IsRegularOfDegree 3) + (hb : G.IsBipartite) : 6 ≤ Fintype.card V := by + obtain ⟨c⟩ := hb + obtain ⟨v⟩ := ‹Nonempty V› + have hp : (G.neighborFinset v).Nonempty := by + apply Finset.card_pos.mp + rw [G.card_neighborFinset_eq_degree, hc v] + norm_num + obtain ⟨w, hw⟩ := hp + have hvw : G.Adj v w := (G.mem_neighborFinset v w).mp hw + have hd : Disjoint (G.neighborFinset v) (G.neighborFinset w) := by + rw [Finset.disjoint_left] + intro x hx hy + have h₁ := c.valid hvw + have h₂ := c.valid ((G.mem_neighborFinset v x).mp hx) + have h₃ := c.valid ((G.mem_neighborFinset w x).mp hy) + have hv := (c v).isLt + have hw := (c w).isLt + have hx := (c x).isLt + have h₁' : (c v).val ≠ (c w).val := fun h => h₁ (Fin.ext h) + have h₂' : (c v).val ≠ (c x).val := fun h => h₂ (Fin.ext h) + have h₃' : (c w).val ≠ (c x).val := fun h => h₃ (Fin.ext h) + omega + have hle := Finset.card_le_card (Finset.subset_univ + (G.neighborFinset v ∪ G.neighborFinset w)) + rw [Finset.card_union_of_disjoint hd, G.card_neighborFinset_eq_degree, + G.card_neighborFinset_eq_degree, hc v, hc w, Finset.card_univ] at hle + exact hle + +omit [DecidableRel G.Adj] in + +lemma boundary_cover_of_threeConnected (h : ThreeVertexConnected G) + (A S : Finset V) (hS : S.card ≤ 2) (hSA : S ⊆ A) + (hout : ∃ w, w ∉ A) + (hboundary : ∀ v ∈ A, ∀ w, w ∉ A → G.Adj v w → v ∈ S) : A ⊆ S := by + intro v hv + by_contra hvS + obtain ⟨w, hw⟩ := hout + have hwS : w ∉ S := fun hs => hw (hSA hs) + let H := G.induce {v | v ∉ S} + have hr := (h.2 S hS) (⟨v,hvS⟩ : {v | v ∉ S}) ⟨w,hwS⟩ + obtain ⟨p⟩ := hr + have hp : ∀ {a b : {v | v ∉ S}}, H.Walk a b → a.val ∈ A → b.val ∈ A := by + intro a b p + induction p with + | nil => exact id + | @cons a z b haz p ih => + intro ha + apply ih + by_contra hz + exact a.property (hboundary a.val ha z.val hz haz) + exact hw (hp p hv) + +end +end Barnette + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/PairPhases.lean b/lean/OAI/Combinatorics/Hamiltonian/PairPhases.lean new file mode 100644 index 0000000000000000000000000000000000000000..edeacc4405c2bf3306ce9727db5c6db53fdc3a18 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/PairPhases.lean @@ -0,0 +1,369 @@ +import OAI.Combinatorics.Hamiltonian.CycleReversal + +namespace OAI + +/-! Paired states, permutation cycle classes, and phase cancellation. -/ + +namespace Barnette + +noncomputable def phase (n : ℤ) : ℂ := Complex.I ^ (n / 3) + +theorem phase_add_six (n : ℤ) : phase (n + 6) = -phase n := by + unfold phase + have h : (n + 6) / 3 = n / 3 + 2 := by omega + rw [h, zpow_add₀ Complex.I_ne_zero] + norm_num + +theorem phase_sub_six (n : ℤ) : phase (n - 6) = -phase n := by + have h := phase_add_six (n - 6) + rw [sub_add_cancel] at h + exact neg_eq_iff_eq_neg.mp h.symm + +theorem disk_count_identity {B W I h l : ℤ} + (heuler : B + W = 2 * I + h - 2) (hsides : 3 * (B - W) = 2 * l - h) + (hmatching : B = I + l) : 2 * l - h = -3 := by omega + +namespace TriangleSystem + +variable {A V : Type*} {T : TriangleSystem A V} {X : Set V} + +def rawIndexSum [Fintype A] (r s : T.State X) : ℤ := + ∑ t, indexDelta (r.val t) (s.val t) + +noncomputable instance [Fintype A] (s : T.State X) : Fintype (T.Partners s) := + Fintype.ofFinite {r : T.State X // T.Partner r s} + +namespace OppositeCycle + +variable {s : T.State X} (C : T.OppositeCycle s) + +noncomputable def faceSet : Finset A := by + classical + exact Finset.univ.image C.face + +@[simp] theorem mem_faceSet (t : A) : t ∈ C.faceSet ↔ t ∈ Set.range C.face := by + classical + simp [faceSet] + +def cyclicDelta (r : T.State X) : ℤ := + ∑ i, indexDelta (r.val (C.face i)) (thirdIndex (r.val (C.face i)) (s.val (C.face i))) + +theorem reverse_rawIndexSum_diff [Fintype A] (r : T.State X) (hrs : T.Partner r s) : + rawIndexSum (C.reverse r hrs) s - rawIndexSum r s = 2 * C.cyclicDelta r := by + classical + rw [rawIndexSum, rawIndexSum, ← Finset.sum_sub_distrib] + let h (t : A) := indexDelta ((C.reverse r hrs).val t) (s.val t) - + indexDelta (r.val t) (s.val t) + change ∑ t, h t = _ + calc + ∑ t, h t = ∑ t ∈ C.faceSet, h t := by + symm + apply Finset.sum_subset (Finset.subset_univ _) + intro t _ ht + have hnot : t ∉ Set.range C.face := fun h => ht ((C.mem_faceSet t).mpr h) + simp only [h, reverse_val, changedCorners, ite_eq_right hnot, sub_self] + _ = ∑ t ∈ C.faceSet, + 2 * indexDelta (r.val t) (thirdIndex (r.val t) (s.val t)) := by + apply Finset.sum_congr rfl + intro t ht + have hrst : r.val t ≠ s.val t := fun h => hrs t ((State.value_eq_iff r s t).mpr h) + change indexDelta (C.changedCorners r t) (s.val t) - + indexDelta (r.val t) (s.val t) = _ + rw [changedCorners, ite_eq_left ((C.mem_faceSet t).mp ht)] + exact indexDelta_third _ _ hrst + _ = ∑ i, 2 * indexDelta (r.val (C.face i)) + (thirdIndex (r.val (C.face i)) (s.val (C.face i))) := by + unfold faceSet + apply Finset.sum_image + exact C.face.injective.injOn + _ = 2 * C.cyclicDelta r := by rw [cyclicDelta, Finset.mul_sum] + +theorem reverse_phase [Fintype A] (r : T.State X) (hrs : T.Partner r s) + (hdisk : C.cyclicDelta r = 3 ∨ C.cyclicDelta r = -3) : + phase (rawIndexSum (C.reverse r hrs) s) = -phase (rawIndexSum r s) := by + have hdiff := C.reverse_rawIndexSum_diff r hrs + rcases hdisk with h | h + · have heq : rawIndexSum (C.reverse r hrs) s = rawIndexSum r s + 6 := by omega + rw [heq, phase_add_six] + · have heq : rawIndexSum (C.reverse r hrs) s = rawIndexSum r s - 6 := by omega + rw [heq, phase_sub_six] + +theorem fixed_second_state_cancels [Fintype A] {M : Type*} [AddCommGroup M] [Module ℂ M] + (hdisk : ∀ r : T.Partners s, C.cyclicDelta r.val = 3 ∨ C.cyclicDelta r.val = -3) + (weight : M) : (∑ r : T.Partners s, phase (rawIndexSum r.val s) • weight) = 0 := by + classical + apply Finset.sum_ninvolution C.reversal + · intro r + change phase (rawIndexSum r.val s) • weight + + phase (rawIndexSum (C.reverse r.val r.property) s) • weight = 0 + rw [C.reverse_phase r.val r.property (hdisk r), neg_smul, add_neg_cancel] + · intro r _ + exact C.reversal_ne r + · intro r + exact Finset.mem_univ _ + · intro r + exact C.reversal_involutive r + +end OppositeCycle +end TriangleSystem +end Barnette + +namespace Barnette + +variable {A : Type*} + +def CycleClass (p : Equiv.Perm A) := Quotient (Equiv.Perm.SameCycle.setoid p) + +def classOf (p : Equiv.Perm A) (a : A) : CycleClass p := Quotient.mk _ a + +noncomputable instance [Finite A] (p : Equiv.Perm A) : Fintype (CycleClass p) := + Fintype.ofFinite (Quotient (Equiv.Perm.SameCycle.setoid p)) + +@[simp] theorem classOf_apply (p : Equiv.Perm A) (a : A) : classOf p (p a) = classOf p a := by + apply Quotient.sound + exact (Equiv.Perm.SameCycle.refl p a).apply_left + +@[simp] theorem classOf_symm_apply (p : Equiv.Perm A) (a : A) : + classOf p (p.symm a) = classOf p a := by + have h := classOf_apply p (p.symm a) + simpa using h.symm + +theorem classOf_surjective (p : Equiv.Perm A) : Function.Surjective (classOf p) := + Quotient.mk_surjective + +theorem classOf_eq_iff (p : Equiv.Perm A) (a b : A) : + classOf p a = classOf p b ↔ p.SameCycle a b := Quotient.eq + +theorem invariant_on_cycle [Finite A] {p : Equiv.Perm A} {B : Type*} (f : A → B) + (hf : ∀ a, f (p a) = f a) {a b : A} (hab : p.SameCycle a b) : f a = f b := by + obtain ⟨n, rfl⟩ := hab.exists_nat_pow_eq + have hpow : ∀ n : ℕ, ∀ a, f ((p ^ n) a) = f a := by + intro n + induction n with + | zero => intro a; rfl + | succ n ih => + intro a + rw [pow_succ', Equiv.Perm.mul_apply, hf, ih] + exact (hpow n a).symm + +noncomputable def descendCycle [Finite A] {p : Equiv.Perm A} {B : Type*} (f : A → B) + (hf : ∀ a, f (p a) = f a) : CycleClass p → B := + Quotient.lift f (fun _ _ h => invariant_on_cycle f hf h) + +@[simp] theorem descendCycle_classOf [Finite A] {p : Equiv.Perm A} {B : Type*} (f : A → B) + (hf : ∀ a, f (p a) = f a) (a : A) : descendCycle f hf (classOf p a) = f a := rfl + +def partialPerm (p : Equiv.Perm A) (b : A → Bool) (hb : ∀ a, b (p a) = b a) : Equiv.Perm A where + toFun a := if b a then p a else a + invFun a := if b a then p.symm a else a + left_inv a := by + cases h : b a <;> simp [h, hb] + right_inv a := by + have hb' (a) : b (p.symm a) = b a := by simpa using (hb (p.symm a)).symm + cases h : b a <;> simp [h, hb'] + +@[simp] theorem partialPerm_apply (p : Equiv.Perm A) (b : A → Bool) + (hb : ∀ a, b (p a) = b a) (a : A) : + partialPerm p b hb a = if b a then p a else a := rfl + +end Barnette + +namespace Barnette.TriangleSystem + +variable {A V : Type*} {T : TriangleSystem A V} {X : Set V} + +def State.ofPermutation (s : T.State X) (e : Equiv.Perm A) (c : A → Fin 3) + (hc : ∀ t, T.vertex t (c t) = s.value (e t)) : T.State X := + ⟨c, by + constructor + · intro t u h + exact e.injective (s.value_injective (by simpa only [hc] using h)) + · rw [← s.value_range] + ext v + constructor + · rintro ⟨t, rfl⟩ + exact ⟨e t, (hc t).symm⟩ + · rintro ⟨t, rfl⟩ + exact ⟨e.symm t, (hc _).trans (congrArg s.value (e.apply_symm_apply t))⟩⟩ + +def Pair (X : Set V) := {rs : T.State X × T.State X // T.Partner rs.1 rs.2} + +namespace Pair + +def left (P : @Pair A V T X) : T.State X := P.val.1 +def right (P : @Pair A V T X) : T.State X := P.val.2 + +theorem partner (P : @Pair A V T X) : T.Partner P.left P.right := P.property + +@[ext] theorem ext {P Q : @Pair A V T X} (hl : P.left = Q.left) + (hr : P.right = Q.right) : P = Q := Subtype.ext (Prod.ext hl hr) + +instance [Finite A] : Finite (@Pair A V T X) := inferInstanceAs (Finite (Subtype _)) +noncomputable instance [Fintype A] : Fintype (@Pair A V T X) := Fintype.ofFinite _ + +noncomputable def next (P : @Pair A V T X) : Equiv.Perm A := + P.right.toEquiv.trans P.left.toEquiv.symm + +@[simp] theorem value_next (P : @Pair A V T X) (t : A) : + P.left.value (P.next t) = P.right.value t := by + change (P.left.toEquiv (P.left.toEquiv.symm (P.right.toEquiv t)) : V) = _ + rw [Equiv.apply_symm_apply, State.coe_toEquiv] + +@[simp] theorem value_prev (P : @Pair A V T X) (t : A) : + P.right.value (P.next.symm t) = P.left.value t := by + have h := P.value_next (P.next.symm t) + simpa using h.symm + +theorem next_ne (P : @Pair A V T X) (t : A) : P.next t ≠ t := by + intro h + exact P.partner t (by simpa only [h] using P.value_next t) + +def third (P : @Pair A V T X) : A → Fin 3 := + fun t => thirdIndex (P.left.val t) (P.right.val t) + +def Group (P : @Pair A V T X) := {Q : @Pair A V T X // Q.third = P.third} + +noncomputable instance [Fintype A] (P : @Pair A V T X) : Fintype P.Group := + Fintype.ofFinite {Q : @Pair A V T X // Q.third = P.third} + +def flipCorners (r s : T.State X) (b : A → Bool) : A → Fin 3 := + fun t => if b t then s.val t else r.val t + +noncomputable def flipLeft (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) : T.State X := + P.left.ofPermutation (partialPerm P.next b hb) (flipCorners P.left P.right b) (by + intro t + cases h : b t + · simp [flipCorners, h, State.value] + · simpa only [flipCorners, h, ↓reduceIte, partialPerm_apply, State.value] using + (P.value_next t).symm) + +noncomputable def flipRight (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) : T.State X := + P.right.ofPermutation + (partialPerm P.next.symm b (fun t => by simpa using (hb (P.next.symm t)).symm)) + (flipCorners P.right P.left b) (by + intro t + cases h : b t + · simp [flipCorners, h, State.value] + · simpa only [flipCorners, h, ↓reduceIte, partialPerm_apply, State.value] using + (P.value_prev t).symm) + +@[simp] theorem flipLeft_val (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) : + (P.flipLeft b hb).val = flipCorners P.left P.right b := rfl + +@[simp] theorem flipRight_val (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) : + (P.flipRight b hb).val = flipCorners P.right P.left b := rfl + +@[simp] theorem flipLeft_value (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) (t : A) : + (P.flipLeft b hb).value t = if b t then P.right.value t else P.left.value t := by + cases h : b t <;> simp [State.value, flipLeft_val, flipCorners, h] + +@[simp] theorem flipRight_value (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) (t : A) : + (P.flipRight b hb).value t = if b t then P.left.value t else P.right.value t := by + cases h : b t <;> simp [State.value, flipRight_val, flipCorners, h] + +noncomputable def flip (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) : @Pair A V T X := + ⟨(P.flipLeft b hb, P.flipRight b hb), by + intro t + change (P.flipLeft b hb).value t ≠ (P.flipRight b hb).value t + rw [flipLeft_value, flipRight_value] + cases h : b t + · simpa [h] using P.partner t + · simpa [h] using (P.partner t).symm⟩ + +theorem flip_third (P : @Pair A V T X) (b : A → Bool) + (hb : ∀ t, b (P.next t) = b t) : (P.flip b hb).third = P.third := by + funext t + change thirdIndex (flipCorners P.left P.right b t) (flipCorners P.right P.left b t) = _ + cases h : b t <;> simp [flipCorners, h, third, thirdIndex, add_comm] + +noncomputable def orient (P : @Pair A V T X) (b : CycleClass P.next → Bool) : P.Group := + ⟨P.flip (fun t => b (classOf P.next t)) (fun t => by rw [classOf_apply]), + P.flip_third _ _⟩ + +theorem same_third_corners : ∀ i j k l : Fin 3, i ≠ j → k ≠ l → + thirdIndex i j = thirdIndex k l → (i = k ∧ j = l) ∨ (i = l ∧ j = k) := by decide + +theorem group_local (P : @Pair A V T X) (Q : P.Group) (t : A) : + (Q.val.left.val t = P.left.val t ∧ Q.val.right.val t = P.right.val t) ∨ + (Q.val.left.val t = P.right.val t ∧ Q.val.right.val t = P.left.val t) := by + apply same_third_corners + · exact fun h => Q.val.partner t ((State.value_eq_iff _ _ _).mpr h) + · exact fun h => P.partner t ((State.value_eq_iff _ _ _).mpr h) + · exact congrFun Q.property t + +noncomputable def bits (P : @Pair A V T X) (Q : P.Group) (t : A) : Bool := + decide (Q.val.left.val t = P.right.val t) + +theorem group_values (P : @Pair A V T X) (Q : P.Group) (t : A) : + Q.val.left.value t = (if P.bits Q t then P.right.value t else P.left.value t) ∧ + Q.val.right.value t = (if P.bits Q t then P.left.value t else P.right.value t) := by + have hn : P.left.val t ≠ P.right.val t := fun h => + P.partner t ((State.value_eq_iff _ _ _).mpr h) + rcases P.group_local Q t with ⟨hl, hr⟩ | ⟨hl, hr⟩ <;> + simp [bits, hl, hr, hn, State.value] + +theorem bits_invariant (P : @Pair A V T X) (Q : P.Group) (t : A) : + P.bits Q (P.next t) = P.bits Q t := by + have h0 := P.group_values Q t + have h1 := P.group_values Q (P.next t) + cases ht : P.bits Q t <;> cases hn : P.bits Q (P.next t) + · rfl + · simp only [ht, hn, Bool.false_eq_true, ↓reduceIte] at h0 h1 + exact False.elim (P.next_ne t (Q.val.right.value_injective + (h1.2.trans ((P.value_next t).trans h0.2.symm)))) + · simp only [ht, hn, Bool.false_eq_true, ↓reduceIte] at h0 h1 + exact False.elim (P.next_ne t (Q.val.left.value_injective + (h1.1.trans ((P.value_next t).trans h0.1.symm)))) + · rfl + +noncomputable def orientations [Finite A] (P : @Pair A V T X) (Q : P.Group) : + CycleClass P.next → Bool := descendCycle (P.bits Q) (P.bits_invariant Q) + +@[simp] theorem orient_orientations [Finite A] (P : @Pair A V T X) (Q : P.Group) : + P.orient (P.orientations Q) = Q := by + apply Subtype.ext + apply Pair.ext + · apply State.ext + intro t + change (P.flipLeft (fun t => P.orientations Q (classOf P.next t)) + (fun t => by rw [classOf_apply])).value t = _ + rw [flipLeft_value] + dsimp [orientations, descendCycle, classOf] + exact (P.group_values Q t).1.symm + · apply State.ext + intro t + change (P.flipRight (fun t => P.orientations Q (classOf P.next t)) + (fun t => by rw [classOf_apply])).value t = _ + rw [flipRight_value] + dsimp [orientations, descendCycle, classOf] + exact (P.group_values Q t).2.symm + +@[simp] theorem orientations_orient [Finite A] (P : @Pair A V T X) + (b : CycleClass P.next → Bool) : P.orientations (P.orient b) = b := by + funext c + obtain ⟨t, rfl⟩ := classOf_surjective P.next c + change P.bits (P.orient b) t = b (classOf P.next t) + have hn : P.left.val t ≠ P.right.val t := fun h => + P.partner t ((State.value_eq_iff _ _ _).mpr h) + change decide ((if b (classOf P.next t) then P.right.val t else P.left.val t) = + P.right.val t) = b (classOf P.next t) + cases b (classOf P.next t) <;> simp [hn] + +noncomputable def groupEquiv [Finite A] (P : @Pair A V T X) : + (CycleClass P.next → Bool) ≃ P.Group where + toFun := P.orient + invFun := P.orientations + left_inv := P.orientations_orient + right_inv := P.orient_orientations + +end Pair +end Barnette.TriangleSystem + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/PairPolynomials.lean b/lean/OAI/Combinatorics/Hamiltonian/PairPolynomials.lean new file mode 100644 index 0000000000000000000000000000000000000000..9258eee539076415b6b8f47be26a9d3dbe631c1c --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/PairPolynomials.lean @@ -0,0 +1,450 @@ +import OAI.Combinatorics.Hamiltonian.PairPhases + +namespace OAI + +/-! First nonzero coefficients of paired-state polynomials. -/ + +namespace Barnette + +open scoped BigOperators Polynomial +open Polynomial + +theorem common_phase_sum_ne_zero {D : Type*} (s : Finset D) (hs : s.Nonempty) + (c : D → ℕ) (p : D → ℂ[X]) (a : D → ℝ) + (ha : ∀ d ∈ s, 0 < a d) + (hp : ∀ d ∈ s, (p d).coeff 0 = (a d : ℂ)) : + (∑ d ∈ s, C ((-Complex.I) ^ c d) * (X ^ c d * p d)) ≠ 0 := by + classical + obtain ⟨d₀, hd₀, hmin⟩ := s.exists_min_image c hs + let m := c d₀ + let t := s.filter (fun d => c d = m) + have ht : t.Nonempty := ⟨d₀, Finset.mem_filter.mpr ⟨hd₀, rfl⟩⟩ + have hpos : 0 < ∑ d ∈ t, a d := by + exact Finset.sum_pos (fun d hd => ha d (Finset.mem_filter.mp hd).1) ht + have hterm (d : D) (hd : d ∈ s) : + (C ((-Complex.I) ^ c d) * (X ^ c d * p d)).coeff m = + if c d = m then (-Complex.I) ^ m * (a d : ℂ) else 0 := by + rw [coeff_C_mul, coeff_X_pow_mul'] + by_cases heq : c d = m + · simp only [heq, le_refl, ite_true, Nat.sub_self, hp d hd] + · have hlt : m < c d := lt_of_le_of_ne (hmin d hd) (Ne.symm heq) + simp only [heq, not_le.mpr hlt, ite_false, mul_zero] + have hcoeff : + (∑ d ∈ s, C ((-Complex.I) ^ c d) * (X ^ c d * p d)).coeff m = + (-Complex.I) ^ m * (∑ d ∈ t, a d : ℝ) := by + rw [finsetSum_coeff] + calc + _ = ∑ d ∈ s, if c d = m then (-Complex.I) ^ m * (a d : ℂ) else 0 := + Finset.sum_congr rfl hterm + _ = _ := by + simp only [t, Finset.sum_filter, Complex.ofReal_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro d _ + split_ifs <;> simp only [Complex.ofReal_zero, mul_zero] + intro hz + have hnz : (-Complex.I) ^ m * ((∑ d ∈ t, a d : ℝ) : ℂ) ≠ 0 := + mul_ne_zero (pow_ne_zero _ (neg_ne_zero.mpr Complex.I_ne_zero)) + (by exact_mod_cast ne_of_gt hpos) + apply hnz + rw [← hcoeff, hz, coeff_zero] + +noncomputable def linearProduct {A R : Type*} [CommRing R] (s : Finset A) (a : A → R) : R[X] := + ∏ t ∈ s, (1 + C (a t) * X) + +@[simp] theorem linearProduct_coeff_zero {A R : Type*} [CommRing R] + (s : Finset A) (a : A → R) : (linearProduct s a).coeff 0 = 1 := by + simp [linearProduct, coeff_zero_prod] + +theorem linearProduct_coeff_one {A R : Type*} [CommRing R] + (s : Finset A) (a : A → R) : (linearProduct s a).coeff 1 = ∑ t ∈ s, a t := by + classical + induction s using Finset.induction_on with + | empty => simp [linearProduct, coeff_one] + | @insert t s ht ih => + rw [linearProduct, Finset.prod_insert ht, mul_coeff_one] + change (1 + C (a t) * X).coeff 0 * (linearProduct s a).coeff 1 + + (1 + C (a t) * X).coeff 1 * (linearProduct s a).coeff 0 = _ + simp [ih, Finset.sum_insert ht, add_comm, coeff_one] + +theorem cycle_difference_divX_coeff_zero {A R : Type*} [CommRing R] + (s : Finset A) (a b : A → R) : + (divX (linearProduct s a - linearProduct s b)).coeff 0 = + (∑ t ∈ s, a t) - ∑ t ∈ s, b t := by + rw [coeff_divX, zero_add, coeff_sub, linearProduct_coeff_one, linearProduct_coeff_one] + +theorem cycle_difference_eq_X_mul_divX {A R : Type*} [CommRing R] + (s : Finset A) (a b : A → R) : + linearProduct s a - linearProduct s b = + X * divX (linearProduct s a - linearProduct s b) := by + have h := X_mul_divX_add (linearProduct s a - linearProduct s b) + simpa using h.symm + +theorem cycle_group_polynomials_ne_zero {D A : Type*} + (s : Finset D) (hs : s.Nonempty) (cycles : D → Finset A) + (q : D → A → ℂ[X]) (a : D → A → ℝ) + (ha : ∀ d ∈ s, ∀ t ∈ cycles d, 0 < a d t) + (hq : ∀ d ∈ s, ∀ t ∈ cycles d, (q d t).coeff 0 = (a d t : ℂ)) : + (∑ d ∈ s, ∏ t ∈ cycles d, C (-Complex.I) * (X * q d t)) ≠ 0 := by + have h := common_phase_sum_ne_zero s hs (fun d => (cycles d).card) + (fun d => ∏ t ∈ cycles d, q d t) (fun d => ∏ t ∈ cycles d, a d t) + (fun d hd => Finset.prod_pos (ha d hd)) (by + intro d hd + rw [coeff_zero_prod, Complex.ofReal_prod] + exact Finset.prod_congr rfl (hq d hd)) + convert h using 1 + apply Finset.sum_congr rfl + intro d _ + simp only [Finset.prod_mul_distrib, Finset.prod_const, ← map_pow] + +end Barnette + +namespace Barnette + +open scoped BigOperators Polynomial +open Polynomial + +theorem phase_sum {K : Type*} (s : Finset K) (a : K → ℤ) + (ha : ∀ k ∈ s, 3 ∣ a k) : phase (∑ k ∈ s, a k) = ∏ k ∈ s, phase (a k) := by + classical + unfold phase + rw [Int.sum_div ha] + induction s using Finset.induction_on with + | empty => simp + | @insert k s hk ih => + rw [Finset.sum_insert hk, Finset.prod_insert hk, zpow_add₀ Complex.I_ne_zero] + congr 1 + exact ih (fun i hi => ha i (Finset.mem_insert_of_mem hi)) + +@[simp] theorem phase_three : phase 3 = Complex.I := by norm_num [phase] +@[simp] theorem phase_neg_three : phase (-3) = -Complex.I := by norm_num [phase, Complex.inv_I] + +theorem phase_neg_of_disk {n : ℤ} (hn : n = 3 ∨ n = -3) : phase (-n) = -phase n := by + rcases hn with rfl | rfl <;> norm_num + +namespace TriangleSystem.Pair + +variable {A V : Type*} [Fintype A] {T : TriangleSystem A V} {X : Set V} + +noncomputable def cycleFaces (P : @Pair A V T X) (c : CycleClass P.next) : Finset A := by + classical + exact Finset.univ.filter (fun t => classOf P.next t = c) + +@[simp] theorem mem_cycleFaces (P : @Pair A V T X) (c : CycleClass P.next) (t : A) : + t ∈ P.cycleFaces c ↔ classOf P.next t = c := by + classical + simp [cycleFaces] + +noncomputable def cycleDelta (P : @Pair A V T X) (c : CycleClass P.next) : ℤ := + ∑ t ∈ P.cycleFaces c, indexDelta (P.left.val t) (P.right.val t) + +omit [Fintype A] in +@[simp] theorem orient_left_val (P : @Pair A V T X) (b : CycleClass P.next → Bool) (t : A) : + (P.orient b).val.left.val t = + if b (classOf P.next t) then P.right.val t else P.left.val t := rfl + +omit [Fintype A] in +@[simp] theorem orient_right_val (P : @Pair A V T X) (b : CycleClass P.next → Bool) (t : A) : + (P.orient b).val.right.val t = + if b (classOf P.next t) then P.left.val t else P.right.val t := rfl + +theorem orient_delta_sum (P : @Pair A V T X) (b : CycleClass P.next → Bool) + (c : CycleClass P.next) : + (∑ t ∈ P.cycleFaces c, indexDelta ((P.orient b).val.left.val t) + ((P.orient b).val.right.val t)) = + if b c then -P.cycleDelta c else P.cycleDelta c := by + classical + rw [cycleDelta] + cases hb : b c + · simp only [Bool.false_eq_true, ↓reduceIte] + apply Finset.sum_congr rfl + intro t ht + rw [orient_left_val, orient_right_val, (P.mem_cycleFaces c t).mp ht, hb] + rfl + · simp only [↓reduceIte, ← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro t ht + rw [orient_left_val, orient_right_val, (P.mem_cycleFaces c t).mp ht, hb] + exact indexDelta_antisymm _ _ + +theorem orient_rawIndexSum (P : @Pair A V T X) (b : CycleClass P.next → Bool) : + rawIndexSum (P.orient b).val.left (P.orient b).val.right = + ∑ c, if b c then -P.cycleDelta c else P.cycleDelta c := by + classical + unfold rawIndexSum + rw [← Finset.sum_fiberwise Finset.univ (classOf P.next)] + apply Finset.sum_congr rfl + intro c _ + exact P.orient_delta_sum b c + +theorem orient_phase (P : @Pair A V T X) + (hdisk : ∀ c, P.cycleDelta c = 3 ∨ P.cycleDelta c = -3) + (b : CycleClass P.next → Bool) : + phase (rawIndexSum (P.orient b).val.left (P.orient b).val.right) = + ∏ c, if b c then -phase (P.cycleDelta c) else phase (P.cycleDelta c) := by + classical + rw [P.orient_rawIndexSum b, phase_sum] + · apply Finset.prod_congr rfl + intro c _ + cases hb : b c <;> simp [phase_neg_of_disk (hdisk c)] + · intro c _ + rcases hdisk c with h | h <;> cases b c <;> simp [h] + +noncomputable def stateWeight (w : A → Fin 3 → ℝ) (s : T.State X) : ℂ[X] := + linearProduct Finset.univ (fun t => (w t (s.val t) : ℂ)) + +noncomputable def cycleLeftWeight (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (c : CycleClass P.next) : ℂ[X] := + linearProduct (P.cycleFaces c) (fun t => (w t (P.left.val t) : ℂ)) + +noncomputable def cycleRightWeight (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (c : CycleClass P.next) : ℂ[X] := + linearProduct (P.cycleFaces c) (fun t => (w t (P.right.val t) : ℂ)) + +theorem orient_weight (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (b : CycleClass P.next → Bool) : stateWeight w (P.orient b).val.right = + ∏ c, if b c then P.cycleLeftWeight w c else P.cycleRightWeight w c := by + classical + unfold stateWeight linearProduct + rw [← Finset.prod_fiberwise Finset.univ (classOf P.next)] + apply Finset.prod_congr rfl + intro c _ + change (∏ t ∈ P.cycleFaces c, _) = _ + cases hb : b c + · simp only [Bool.false_eq_true, ↓reduceIte, cycleRightWeight, linearProduct] + apply Finset.prod_congr rfl + intro t ht + rw [orient_right_val, (P.mem_cycleFaces c t).mp ht, hb] + rfl + · simp only [↓reduceIte, cycleLeftWeight, linearProduct] + apply Finset.prod_congr rfl + intro t ht + rw [orient_right_val, (P.mem_cycleFaces c t).mp ht, hb] + rfl + +noncomputable def term (w : A → Fin 3 → ℝ) (P : @Pair A V T X) : ℂ[X] := + C (phase (rawIndexSum P.left P.right)) * stateWeight w P.right + +theorem orient_term (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (hdisk : ∀ c, P.cycleDelta c = 3 ∨ P.cycleDelta c = -3) + (b : CycleClass P.next → Bool) : term w (P.orient b).val = + ∏ c, if b c then -C (phase (P.cycleDelta c)) * P.cycleLeftWeight w c + else C (phase (P.cycleDelta c)) * P.cycleRightWeight w c := by + classical + rw [term, P.orient_phase hdisk, P.orient_weight, map_prod, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro c _ + cases b c <;> simp + +theorem group_sum_product (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (hdisk : ∀ c, P.cycleDelta c = 3 ∨ P.cycleDelta c = -3) : + (∑ Q : P.Group, term w Q.val) = + ∏ c, C (phase (P.cycleDelta c)) * + (P.cycleRightWeight w c - P.cycleLeftWeight w c) := by + classical + rw [← Fintype.sum_equiv P.groupEquiv _ (fun Q : P.Group => term w Q.val) + (fun _ => rfl)] + calc + _ = ∑ b : CycleClass P.next → Bool, + ∏ c, if b c then -C (phase (P.cycleDelta c)) * P.cycleLeftWeight w c + else C (phase (P.cycleDelta c)) * P.cycleRightWeight w c := by + apply Finset.sum_congr rfl + intro b _ + exact P.orient_term w hdisk b + _ = ∏ c, ∑ b : Bool, if b then -C (phase (P.cycleDelta c)) * P.cycleLeftWeight w c + else C (phase (P.cycleDelta c)) * P.cycleRightWeight w c := + (Fintype.prod_sum (ι := CycleClass P.next) (κ := fun _ => Bool) + (fun c b => if b then -C (phase (P.cycleDelta c)) * P.cycleLeftWeight w c + else C (phase (P.cycleDelta c)) * P.cycleRightWeight w c)).symm + _ = _ := by + apply Finset.prod_congr rfl + intro c _ + rw [Fintype.sum_bool] + simp only [↓reduceIte, Bool.false_eq_true] + ring + +end TriangleSystem.Pair +end Barnette +namespace Barnette + +open scoped BigOperators Polynomial +open Polynomial + +namespace TriangleSystem.Pair + +variable {A V : Type*} [Fintype A] {T : TriangleSystem A V} {X : Set V} + +noncomputable def cycleSlope (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (c : CycleClass P.next) : ℝ := + (∑ t ∈ P.cycleFaces c, w t (P.right.val t)) - + ∑ t ∈ P.cycleFaces c, w t (P.left.val t) + +theorem cycle_diff_coeff_one (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (c : CycleClass P.next) : + (divX (P.cycleRightWeight w c - P.cycleLeftWeight w c)).coeff 0 = + (P.cycleSlope w c : ℂ) := by + rw [cycleRightWeight, cycleLeftWeight, cycle_difference_divX_coeff_zero] + simp only [cycleSlope, Complex.ofReal_sub, Complex.ofReal_sum] + +theorem cycle_factor_witness (P : @Pair A V T X) (w : A → Fin 3 → ℝ) + (c : CycleClass P.next) + (hsign : (P.cycleDelta c = -3 ∧ 0 < P.cycleSlope w c) ∨ + (P.cycleDelta c = 3 ∧ P.cycleSlope w c < 0)) : + ∃ (q : ℂ[X]) (a : ℝ), 0 < a ∧ q.coeff 0 = (a : ℂ) ∧ + C (phase (P.cycleDelta c)) * (P.cycleRightWeight w c - P.cycleLeftWeight w c) = + C (-Complex.I) * (Polynomial.X * q) := by + rcases hsign with ⟨hd, hs⟩ | ⟨hd, hs⟩ + · refine ⟨divX (P.cycleRightWeight w c - P.cycleLeftWeight w c), + P.cycleSlope w c, hs, P.cycle_diff_coeff_one w c, ?_⟩ + rw [hd, phase_neg_three] + congr 1 + exact cycle_difference_eq_X_mul_divX _ _ _ + · refine ⟨-divX (P.cycleRightWeight w c - P.cycleLeftWeight w c), + -P.cycleSlope w c, neg_pos.mpr hs, ?_, ?_⟩ + · rw [coeff_neg, P.cycle_diff_coeff_one, Complex.ofReal_neg] + · rw [hd, phase_three] + have heq : P.cycleRightWeight w c - P.cycleLeftWeight w c = + Polynomial.X * divX (P.cycleRightWeight w c - P.cycleLeftWeight w c) := + cycle_difference_eq_X_mul_divX _ _ _ + calc + _ = C Complex.I * (Polynomial.X * + divX (P.cycleRightWeight w c - P.cycleLeftWeight w c)) := congrArg _ heq + _ = _ := by simp only [map_neg, mul_neg, neg_mul, neg_neg] + +def GroupIndex : Type _ := Set.range (@third A V T X) + +noncomputable instance : Fintype (@GroupIndex A V T X) := + Fintype.ofFinite (Set.range (@third A V T X)) + +noncomputable def GroupIndex.representative (d : @GroupIndex A V T X) : @Pair A V T X := + Classical.choose d.property + +omit [Fintype A] in +theorem GroupIndex.representative_third (d : @GroupIndex A V T X) : d.representative.third = d.val := + Classical.choose_spec d.property + +def groupIndex (P : @Pair A V T X) : @GroupIndex A V T X := ⟨P.third, P, rfl⟩ + +noncomputable def GroupIndex.fiberEquivGroup (d : @GroupIndex A V T X) : + {P : @Pair A V T X // P.groupIndex = d} ≃ d.representative.Group := + Equiv.subtypeEquivRight (fun P => by + constructor + · intro h + have hh := congrArg Subtype.val h + change P.third = d.val at hh + exact hh.trans d.representative_third.symm + · intro h + apply Subtype.ext + exact h.trans d.representative_third) + +theorem sum_groups (w : A → Fin 3 → ℝ) : + (∑ P : @Pair A V T X, term w P) = + ∑ d : @GroupIndex A V T X, ∑ Q : d.representative.Group, term w Q.val := by + classical + rw [← Fintype.sum_fiberwise groupIndex (term w)] + apply Finset.sum_congr rfl + intro d _ + exact Fintype.sum_equiv d.fiberEquivGroup _ _ (fun _ => rfl) + +theorem total_sum_ne_zero (hex : Nonempty (@Pair A V T X)) (w : A → Fin 3 → ℝ) + (hsign : ∀ (P : @Pair A V T X) c, + (P.cycleDelta c = -3 ∧ 0 < P.cycleSlope w c) ∨ + (P.cycleDelta c = 3 ∧ P.cycleSlope w c < 0)) : + (∑ P : @Pair A V T X, term w P) ≠ 0 := by + classical + let D := @GroupIndex A V T X + have hnonempty : (Finset.univ : Finset D).Nonempty := + ⟨hex.some.groupIndex, Finset.mem_univ _⟩ + have hw : ∀ d : D, ∀ c : CycleClass d.representative.next, + ∃ (q : ℂ[X]) (a : ℝ), 0 < a ∧ q.coeff 0 = (a : ℂ) ∧ + C (phase (d.representative.cycleDelta c)) * + (d.representative.cycleRightWeight w c - d.representative.cycleLeftWeight w c) = + C (-Complex.I) * (Polynomial.X * q) := by + intro d c + exact d.representative.cycle_factor_witness w c (hsign d.representative c) + choose q a ha hq hf using hw + have h := common_phase_sum_ne_zero Finset.univ hnonempty + (fun d : D => Fintype.card (CycleClass d.representative.next)) + (fun d => ∏ c, q d c) (fun d => ∏ c, a d c) + (fun d _ => Finset.prod_pos (fun c _ => ha d c)) (by + intro d _ + rw [coeff_zero_prod, Complex.ofReal_prod] + exact Finset.prod_congr rfl (fun c _ => hq d c)) + rw [sum_groups] + convert h using 1 + apply Finset.sum_congr rfl + intro d _ + rw [d.representative.group_sum_product w (fun c => by + rcases hsign d.representative c with ⟨hd, _⟩ | ⟨hd, _⟩ + · exact Or.inr hd + · exact Or.inl hd)] + calc + _ = ∏ c, C (-Complex.I) * (Polynomial.X * q d c) := + Finset.prod_congr rfl (fun c _ => hf d c) + _ = _ := by simp only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, + ← map_pow] + +end TriangleSystem.Pair +end Barnette +namespace Barnette + +open scoped BigOperators Polynomial +open Polynomial + +namespace TriangleSystem.Pair + +variable {A V : Type*} [Fintype A] {T : TriangleSystem A V} {X : Set V} + +noncomputable def secondFiberEquiv (s : T.State X) : + {P : @Pair A V T X // P.right = s} ≃ T.Partners s where + toFun P := ⟨P.val.left, + Eq.mp (congrArg (fun z => T.Partner P.val.left z) P.property) P.val.partner⟩ + invFun r := ⟨⟨(r.val, s), r.property⟩, rfl⟩ + left_inv P := by + apply Subtype.ext + apply Pair.ext + · rfl + · exact P.property.symm + right_inv _ := rfl + +theorem sum_second_states (w : A → Fin 3 → ℝ) : + (∑ P : @Pair A V T X, term w P) = + ∑ s : T.State X, ∑ r : T.Partners s, + C (phase (rawIndexSum r.val s)) * stateWeight w s := by + classical + rw [← Fintype.sum_fiberwise right (term w)] + apply Finset.sum_congr rfl + intro s _ + apply Fintype.sum_equiv (secondFiberEquiv s) + intro P + change C (phase (rawIndexSum P.val.left P.val.right)) * stateWeight w P.val.right = _ + rw [P.property] + rfl + +theorem forest_pair_of_disk_circulation (hex : Nonempty (@Pair A V T X)) + (hdisk : ∀ (s : T.State X) (C : T.OppositeCycle s) (r : T.Partners s), + C.cyclicDelta r.val = 3 ∨ C.cyclicDelta r.val = -3) + (w : A → Fin 3 → ℝ) + (hsign : ∀ (P : @Pair A V T X) c, + (P.cycleDelta c = -3 ∧ 0 < P.cycleSlope w c) ∨ + (P.cycleDelta c = 3 ∧ P.cycleSlope w c < 0)) : + ∃ P : @Pair A V T X, (T.oppositeGraph P.right).IsAcyclic := by + classical + by_contra hforest + have hcyclic (P : @Pair A V T X) : ¬(T.oppositeGraph P.right).IsAcyclic := + fun h => hforest ⟨P, h⟩ + apply total_sum_ne_zero hex w hsign + rw [sum_second_states] + apply Finset.sum_eq_zero + intro s _ + by_cases hp : Nonempty (T.Partners s) + · let P : @Pair A V T X := ⟨(hp.some.val, s), hp.some.property⟩ + obtain ⟨C⟩ := T.oppositeCycle_nonempty s (hcyclic P) + simpa only [Polynomial.smul_eq_C_mul] using + C.fixed_second_state_cancels (hdisk s C) (stateWeight w s) + · have : IsEmpty (T.Partners s) := not_nonempty_iff.mp hp + exact Finset.sum_eq_zero (fun r _ => isEmptyElim r) + +end TriangleSystem.Pair +end Barnette + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Quotients.lean b/lean/OAI/Combinatorics/Hamiltonian/Quotients.lean new file mode 100644 index 0000000000000000000000000000000000000000..51c494a63173dc3ff44d65bb8178e63747aa0092 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Quotients.lean @@ -0,0 +1,195 @@ +import OAI.Combinatorics.Hamiltonian.Bonds + +namespace OAI + +/-! Vertex quotients and connected fibers of incidence networks. -/ + +namespace Barnette.Network +noncomputable section +variable {V W E K : Type*} +open scoped Classical + +def push [Fintype V] (q : V → W) : (V → ℝ) →ₗ[ℝ] (W → ℝ) where + toFun x w := ∑ v, if q v = w then x v else 0 + map_add' x y := by + ext w + simp only [Pi.add_apply] + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro v _ + split_ifs <;> simp + map_smul' c x := by + ext w + simp [Finset.mul_sum, mul_ite] + +def pull (q : V → W) : (W → ℝ) →ₗ[ℝ] (V → ℝ) := + LinearMap.funLeft ℝ ℝ q + +@[simp] theorem pull_apply (q : V → W) (f : W → ℝ) (v : V) : + pull q f v = f (q v) := rfl + +@[simp] theorem push_apply [Fintype V] (q : V → W) (x : V → ℝ) (w : W) : + push q x w = ∑ v, if q v = w then x v else 0 := rfl + +def mapVertices (N : Network V E) (q : V → W) : Network W E := + ⟨q ∘ N.tail, q ∘ N.head⟩ + +def restrict (N : Network V E) (j : K → E) : Network V K := + ⟨N.tail ∘ j, N.head ∘ j⟩ + +@[simp] theorem gradient_mapVertices (N : Network V E) (q : V → W) (f : W → ℝ) : + (N.mapVertices q).gradient f = N.gradient (pull q f) := rfl + +@[simp] theorem gradient_restrict (N : Network V E) (j : K → E) (f : V → ℝ) : + (N.restrict j).gradient f = pull j (N.gradient f) := rfl + +variable [Fintype V] [Fintype W] [Fintype E] [Fintype K] + +lemma push_adjoint (q : V → W) (x : V → ℝ) (f : W → ℝ) : + ∑ w, push q x w * f w = ∑ v, x v * pull q f v := by + classical + simp only [push_apply, Finset.sum_mul] + rw [Finset.sum_comm] + simp [ite_mul] + +lemma push_surjective {q : V → W} (hq : Function.Surjective q) : + Function.Surjective (push q) := by + classical + let r := Function.surjInv hq + have hr : Function.RightInverse r q := Function.rightInverse_surjInv hq + intro f + refine ⟨fun v => if h : v ∈ Set.range r then f (q v) else 0, ?_⟩ + ext w + simp only [push_apply] + rw [Finset.sum_eq_single (r w)] + · simp [hr w] + · intro v _ hv + by_cases h : v ∈ Set.range r + · obtain ⟨z, rfl⟩ := h + have hz : z ≠ w := fun he => hv (congrArg r he) + simp [hr z, hz] + · simp [h] + · simp + +omit [Fintype V] [Fintype W] in +lemma pull_injective {q : V → W} (hq : Function.Surjective q) : + Function.Injective (pull q) := by + intro f g h + ext w + obtain ⟨v, rfl⟩ := hq w + exact congrFun h v + +lemma eq_of_dot_eq (x y : V → ℝ) + (h : ∀ f : V → ℝ, ∑ v, x v * f v = ∑ v, y v * f v) : x = y := by + ext v + have hh := h (fun w => if w = v then 1 else 0) + simpa only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', + Finset.mem_univ, ite_true] using hh + +lemma boundary_mapVertices (N : Network V E) (q : V → W) (x : E → ℝ) : + (N.mapVertices q).boundary x = push q (N.boundary x) := by + apply eq_of_dot_eq + intro f + rw [(N.mapVertices q).boundary_adjoint, N.gradient_mapVertices, + push_adjoint, N.boundary_adjoint] + +lemma boundary_restrict (N : Network V E) (j : K → E) (x : K → ℝ) : + (N.restrict j).boundary x = N.boundary (push j x) := by + apply eq_of_dot_eq + intro f + rw [(N.restrict j).boundary_adjoint, N.gradient_restrict, + N.boundary_adjoint, push_adjoint] + +omit [Fintype E] in +lemma pull_push_injective {j : K → E} (hj : Function.Injective j) (x : K → ℝ) : + pull j (push j x) = x := by + classical + ext k + simp [hj.eq_iff] + +omit [Fintype E] in +lemma push_eq_zero_outside {j : K → E} (x : K → ℝ) {e : E} (he : e ∉ Set.range j) : + push j x e = 0 := by + classical + apply Finset.sum_eq_zero + intro k _ + have hk : j k ≠ e := fun h => he ⟨k, h⟩ + simp [hk] + +lemma push_pull_subtype (s : Set E) (x : E → ℝ) : + push (Subtype.val : s → E) (pull Subtype.val x) = fun e => if e ∈ s then x e else 0 := by + classical + ext e + by_cases he : e ∈ s + · change (pull Subtype.val (push Subtype.val (pull Subtype.val x))) ⟨e, he⟩ = _ + rw [pull_push_injective Subtype.val_injective] + simp [he] + · rw [push_eq_zero_outside _ (by simpa using he)] + simp [he] + +def internal (N : Network V E) (q : V → W) : Set E := + {e | q (N.tail e) = q (N.head e)} + +lemma push_boundary_internal (N : Network V E) (q : V → W) + (x : N.internal q → ℝ) : + push q ((N.restrict Subtype.val).boundary x) = 0 := by + apply eq_of_dot_eq + intro f + rw [push_adjoint, (N.restrict _).boundary_adjoint] + simp only [Pi.zero_apply, zero_mul, Finset.sum_const_zero] + apply Finset.sum_eq_zero + intro e _ + have he : (N.restrict (Subtype.val : N.internal q → E)).gradient (pull q f) e = 0 := by + change f (q (N.head e.val)) - f (q (N.tail e.val)) = 0 + rw [e.property] + exact sub_self _ + rw [he, mul_zero] + +def ConnectedFibers (N : Network V E) (q : V → W) : Prop := + ∀ v w, q v = q w → (N.restrict (Subtype.val : N.internal q → E)).graph.Reachable v w + +omit [Fintype V] [Fintype W] [Fintype E] in +lemma ker_internal_gradient (N : Network V E) {q : V → W} + (hq : Function.Surjective q) (hc : N.ConnectedFibers q) : + (N.restrict (Subtype.val : N.internal q → E)).gradient.ker = (pull q).range := by + classical + ext f + constructor + · intro hf + let r := Function.surjInv hq + have hr := Function.rightInverse_surjInv hq + refine ⟨fun w => f (r w), ?_⟩ + ext v + exact (N.restrict _).gradient_zero_reachable hf (hc _ _ (hr (q v))) + · rintro ⟨f, rfl⟩ + apply (N.restrict _).gradient_eq_zero_iff _ |>.mpr + intro e + exact congrArg f e.property.symm + +lemma range_internal_boundary (N : Network V E) {q : V → W} + (hq : Function.Surjective q) (hc : N.ConnectedFibers q) : + (N.restrict (Subtype.val : N.internal q → E)).boundary.range = (push q).ker := by + classical + let : DecidableEq (N.internal q) := Classical.decEq _ + let I := N.restrict (Subtype.val : N.internal q → E) + have hle : I.boundary.range ≤ (push q).ker := by + rintro _ ⟨x, rfl⟩ + exact N.push_boundary_internal q x + apply Submodule.eq_of_le_of_finrank_eq hle + have hk : Module.finrank ℝ I.gradient.ker = Fintype.card W := by + rw [show I.gradient.ker = (pull q).range from N.ker_internal_gradient hq hc, + LinearMap.finrank_range_of_inj (pull_injective hq), Module.finrank_pi] + have hgrad := I.gradient.finrank_range_add_finrank_ker + have hpush := (push q).finrank_range_add_finrank_ker + rw [LinearMap.range_eq_top.mpr (push_surjective hq), finrank_top, + Module.finrank_pi, Module.finrank_pi] at hpush + have hr : Module.finrank ℝ I.boundary.range = Module.finrank ℝ I.gradient.range := by + rw [I.gradient_matrix, boundary, Matrix.toLin'_apply', Matrix.toLin'_apply', + ← Matrix.rank, ← Matrix.rank, Matrix.rank_transpose] + rw [Module.finrank_pi, hk] at hgrad + omega + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Rectangle.lean b/lean/OAI/Combinatorics/Hamiltonian/Rectangle.lean new file mode 100644 index 0000000000000000000000000000000000000000..c38ba2bbafb2b7ab1cea5dfd54f55fc7febd7915 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Rectangle.lean @@ -0,0 +1,316 @@ +import OAI.Combinatorics.Hamiltonian.BranchPartition + +namespace OAI + +/-! Rectangular primal and dual networks and finite lattice containment. -/ + +namespace Barnette.RectangularDual +noncomputable section + +abbrev Vertex (n m : ℕ) := Fin (n + 1) × Fin (m + 1) +abbrev Edge (n m : ℕ) := (Fin n × Fin (m + 1)) ⊕ (Fin (n + 1) × Fin m) +abbrev Face (n m : ℕ) := Option (Fin n × Fin m) + +def primal (n m : ℕ) : Network (Vertex n m) (Edge n m) where + tail := Sum.elim (fun e => (e.1.castSucc, e.2)) (fun e => (e.1, e.2.castSucc)) + head := Sum.elim (fun e => (e.1.succ, e.2)) (fun e => (e.1, e.2.succ)) + +def lower {n : ℕ} : Fin (n + 1) → Option (Fin n) := Fin.cases none some +def upper {n : ℕ} : Fin (n + 1) → Option (Fin n) := Fin.lastCases none some + +def dual (n m : ℕ) : Network (Face n m) (Edge n m) where + tail := Sum.elim + (fun e => (lower e.2).map (fun j => (e.1, j))) + (fun e => (upper e.1).map (fun i => (i, e.2))) + head := Sum.elim + (fun e => (upper e.2).map (fun j => (e.1, j))) + (fun e => (lower e.1).map (fun i => (i, e.2))) + +def lowerValue {n : ℕ} (f : Fin n → ℝ) : Fin (n + 1) → ℝ := Fin.cases 0 f +def upperValue {n : ℕ} (f : Fin n → ℝ) : Fin (n + 1) → ℝ := Fin.lastCases 0 f + +def stepCoeff {n : ℕ} (v : Fin (n + 1)) (e : Fin n) : ℝ := + (if e.succ = v then 1 else 0) - (if e.castSucc = v then 1 else 0) + +lemma sum_succ {n : ℕ} (f : Fin n → ℝ) (v : Fin (n + 1)) : + (∑ i, if i.succ = v then f i else 0) = lowerValue f v := by + induction v using Fin.cases with + | zero => simp [lowerValue] + | succ v => simp [lowerValue] + +lemma sum_castSucc {n : ℕ} (f : Fin n → ℝ) (v : Fin (n + 1)) : + (∑ i, if i.castSucc = v then f i else 0) = upperValue f v := by + induction v using Fin.lastCases with + | last => simp [upperValue, Fin.castSucc_ne_last] + | cast v => simp [upperValue] + +lemma sum_stepCoeff {n : ℕ} (f : Fin n → ℝ) (v : Fin (n + 1)) : + (∑ i, stepCoeff v i * f i) = lowerValue f v - upperValue f v := by + simp only [stepCoeff, sub_mul, ite_mul, one_mul, zero_mul, + Finset.sum_sub_distrib, sum_succ, sum_castSucc] + +lemma lower_eval {n : ℕ} (f : Fin n → ℝ) (v : Fin (n + 1)) : + (lower v).elim 0 f = lowerValue f v := by + induction v using Fin.cases <;> simp [lower, lowerValue] + +lemma upper_eval {n : ℕ} (f : Fin n → ℝ) (v : Fin (n + 1)) : + (upper v).elim 0 f = upperValue f v := by + induction v using Fin.lastCases <;> simp [upper, upperValue] + +def potential {n m : ℕ} (f : Fin n × Fin m → ℝ) : Face n m → ℝ := + fun z => z.elim 0 f + +lemma eval_map {A B : Type*} (g : B → ℝ) (f : A → B) (z : Option A) : + (z.map f).elim 0 g = z.elim 0 (g ∘ f) := by cases z <;> rfl + +lemma dual_horizontal {n m : ℕ} (f : Fin n × Fin m → ℝ) + (i : Fin n) (j : Fin (m + 1)) : + (dual n m).gradient (potential f) (.inl (i, j)) = + -∑ q, stepCoeff j q * f (i, q) := by + change ((upper j).map _).elim 0 f - ((lower j).map _).elim 0 f = _ + rw [eval_map, eval_map, upper_eval, lower_eval, sum_stepCoeff] + dsimp only [Function.comp_def] + ring + +lemma dual_vertical {n m : ℕ} (f : Fin n × Fin m → ℝ) + (i : Fin (n + 1)) (j : Fin m) : + (dual n m).gradient (potential f) (.inr (i, j)) = + ∑ p, stepCoeff i p * f (p, j) := by + change ((lower i).map _).elim 0 f - ((upper i).map _).elim 0 f = _ + rw [eval_map, eval_map, upper_eval, lower_eval, sum_stepCoeff] + rfl + +lemma boundary_formula {n m : ℕ} (x : Edge n m → ℝ) (i : Fin (n + 1)) + (j : Fin (m + 1)) : + (primal n m).boundary x (i, j) = + (∑ p, stepCoeff i p * x (.inl (p, j))) + + (∑ q, stepCoeff j q * x (.inr (i, q))) := by + classical + rw [Network.boundary_apply, Fintype.sum_sum_type] + simp only [primal, Sum.elim_inl, Sum.elim_inr, Prod.mk.injEq, + Fintype.sum_prod_type, stepCoeff, sub_mul, ite_mul, one_mul, zero_mul, + Finset.sum_sub_distrib, ite_and] + simp + +lemma orthogonal_potential (n m : ℕ) (f : Fin n × Fin m → ℝ) : + (primal n m).boundary ((dual n m).gradient (potential f)) = 0 := by + ext ⟨i, j⟩ + rw [boundary_formula] + simp only [dual_horizontal, dual_vertical, mul_neg, Finset.sum_neg_distrib, + Finset.mul_sum] + rw [Finset.sum_comm (f := fun q p => stepCoeff j q * (stepCoeff i p * f (p, q)))] + have he : (∑ p, ∑ q, stepCoeff j q * (stepCoeff i p * f (p, q))) = + ∑ p, ∑ q, stepCoeff i p * (stepCoeff j q * f (p, q)) := by + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + ring + rw [he] + exact neg_add_cancel _ + +lemma orthogonal (n m : ℕ) (f : Face n m → ℝ) : + (primal n m).boundary ((dual n m).gradient f) = 0 := by + let g : Fin n × Fin m → ℝ := fun t => f (some t) - f none + have hf : f = potential g + (fun _ => f none) := by + ext z + cases z <;> simp [potential, g] + rw [hf, map_add, Network.gradient_const, add_zero] + exact orthogonal_potential n m g + +lemma horizontal_adj {n m : ℕ} (i : Fin n) (j : Fin (m + 1)) : + (primal n m).graph.Adj (i.castSucc, j) (i.succ, j) := by + refine ⟨?_, .inl (i, j), Or.inl ⟨rfl, rfl⟩⟩ + intro h + have hh := congrArg (fun z : Vertex n m => z.1.val) h + simp only [Fin.val_castSucc, Fin.val_succ] at hh + omega + +lemma vertical_adj {n m : ℕ} (i : Fin (n + 1)) (j : Fin m) : + (primal n m).graph.Adj (i, j.castSucc) (i, j.succ) := by + refine ⟨?_, .inr (i, j), Or.inl ⟨rfl, rfl⟩⟩ + intro h + have hh := congrArg (fun z : Vertex n m => z.2.val) h + simp only [Fin.val_castSucc, Fin.val_succ] at hh + omega + +lemma primal_connected (n m : ℕ) : (primal n m).graph.Connected := by + apply (SimpleGraph.connected_iff_exists_forall_reachable _).mpr + refine ⟨(0, 0), ?_⟩ + rintro ⟨i, j⟩ + have hv : (primal n m).graph.Reachable (0, 0) (0, j) := by + induction j using Fin.induction with + | zero => exact .rfl + | succ j ih => exact ih.trans (vertical_adj (0 : Fin (n + 1)) j).reachable + have hh : (primal n m).graph.Reachable (0, j) (i, j) := by + induction i using Fin.induction with + | zero => exact .rfl + | succ i ih => exact ih.trans (horizontal_adj i j).reachable + exact hv.trans hh + +lemma dual_connected (n m : ℕ) : (dual n m).graph.Connected := by + apply (SimpleGraph.connected_iff_exists_forall_reachable _).mpr + refine ⟨none, ?_⟩ + intro z + cases z with + | none => exact .rfl + | some z => + obtain ⟨i, j⟩ := z + cases n with + | zero => exact isEmptyElim i + | succ n => + induction i using Fin.induction with + | zero => + have h := ((dual (n + 1) m).edge_reachable (.inr (0, j))).symm + have hu : upper (0 : Fin (n + 2)) = some (0 : Fin (n + 1)) := by + change upper (0 : Fin (n + 1)).castSucc = _ + exact Fin.lastCases_castSucc _ + simpa only [dual, Sum.elim_inr, lower, Fin.cases_zero, hu, + Option.map_none, Option.map_some] using h + | succ i ih => + have h := ((dual (n + 1) m).edge_reachable (.inr (i.succ.castSucc, j))).symm + have hl : lower i.succ.castSucc = some i.castSucc := by + have he : i.succ.castSucc = i.castSucc.succ := by ext; rfl + rw [he] + simp [lower] + have hu : upper i.succ.castSucc = some i.succ := Fin.lastCases_castSucc _ + exact ih.trans (by + simpa only [dual, Sum.elim_inr, hl, hu, Option.map_some] using h) + +theorem grid_duality (n m : ℕ) : (primal n m).Duality (dual n m) := by + apply Network.duality_of_orth_card (primal n m) (dual n m) + (primal_connected n m) (dual_connected n m) + · simp only [Vertex, Face, Edge, Fintype.card_prod, Fintype.card_fin, + Fintype.card_option, Fintype.card_sum] + ring + · exact orthogonal n m + +end +end Barnette.RectangularDual + +namespace Barnette.MinorModel +noncomputable section +open scoped Classical +variable {V W U : Type*} {G : SimpleGraph V} {H : SimpleGraph W} + {J : SimpleGraph U} [Fintype U] + +def pullHost (M : MinorModel G H) (f : J ↪g H) + (hf : ∀ v, M.branch v ⊆ Set.range f) : MinorModel G J where + branch v := f ⁻¹' M.branch v + branch_finite _ := Set.toFinite _ + branch_connected v := by + let g : {x // f x ∈ M.branch v} → M.branch v := fun x => ⟨f x.val, x.property⟩ + have hg : Function.Bijective g := by + refine ⟨?_, ?_⟩ + · intro x y hxy + apply Subtype.ext + exact f.injective (congrArg Subtype.val hxy) + · intro y + obtain ⟨x, hx⟩ := hf v y.property + refine ⟨⟨x, hx ▸ y.property⟩, ?_⟩ + exact Subtype.ext hx + let e : J.induce (f ⁻¹' M.branch v) ≃g H.induce (M.branch v) := + { toEquiv := Equiv.ofBijective g hg + map_rel_iff' := by intro x y; exact f.map_rel_iff } + exact e.connected_iff.mpr (M.branch_connected v) + branches_disjoint v w hvw := (M.branches_disjoint v w hvw).preimage f + adjacency v w h := by + obtain ⟨a, ha, b, hb, hab⟩ := M.adjacency v w h + obtain ⟨a', rfl⟩ := hf v ha + obtain ⟨b', rfl⟩ := hf w hb + exact ⟨a', ha, b', hb, f.map_rel_iff.mp hab⟩ +end +end Barnette.MinorModel + +namespace Barnette.RectangularDual +noncomputable section +open scoped Classical + +lemma primal_adj_iff {n m : ℕ} (p q : Vertex n m) : + (primal n m).graph.Adj p q ↔ + ((p.1.val + 1 = q.1.val ∨ q.1.val + 1 = p.1.val) ∧ p.2 = q.2) ∨ + ((p.2.val + 1 = q.2.val ∨ q.2.val + 1 = p.2.val) ∧ p.1 = q.1) := by + constructor + · rintro ⟨_, e, he⟩ + rcases e with ⟨i, j⟩ | ⟨i, j⟩ <;> + rcases he with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ <;> simp [primal] + · have hx (a b : Vertex n m) (h : a.1.val + 1 = b.1.val) (hj : a.2 = b.2) : + (primal n m).graph.Adj a b := by + have hi : a.1.val < n := by have := b.1.isLt; omega + refine ⟨?_, .inl (⟨a.1.val, hi⟩, a.2), Or.inl ⟨?_, ?_⟩⟩ + · intro he; have hh := congrArg (fun x : Vertex n m => x.1.val) he; omega + · apply Prod.ext <;> rfl + · apply Prod.ext + · apply Fin.ext; exact h + · exact hj + have hy (a b : Vertex n m) (h : a.2.val + 1 = b.2.val) (hi : a.1 = b.1) : + (primal n m).graph.Adj a b := by + have hj : a.2.val < m := by have := b.2.isLt; omega + refine ⟨?_, .inr (a.1, ⟨a.2.val, hj⟩), Or.inl ⟨?_, ?_⟩⟩ + · intro he; have hh := congrArg (fun x : Vertex n m => x.2.val) he; omega + · apply Prod.ext <;> rfl + · apply Prod.ext + · exact hi + · apply Fin.ext; exact h + rintro (⟨h | h, hj⟩ | ⟨h | h, hi⟩) + · exact hx p q h hj + · exact (hx q p h hj.symm).symm + · exact hy p q h hi + · exact (hy q p h hi.symm).symm + +def latticePoint (r : ℕ) (p : Vertex (2 * r) (2 * r)) : ℤ × ℤ := + ((p.1.val : ℤ) - r, (p.2.val : ℤ) - r) + +lemma latticePoint_injective (r : ℕ) : Function.Injective (latticePoint r) := by + intro p q h + have h₁ := congrArg Prod.fst h + have h₂ := congrArg Prod.snd h + dsimp [latticePoint] at h₁ h₂ + apply Prod.ext <;> apply Fin.ext <;> omega + +def latticeEmbedding (r : ℕ) : (primal (2 * r) (2 * r)).graph ↪g SquareGrid.graph where + toFun := latticePoint r + inj' := latticePoint_injective r + map_rel_iff' := by + intro p q + rw [primal_adj_iff] + change SquareGrid.graph.Adj (latticePoint r p) (latticePoint r q) ↔ _ + simp only [SquareGrid.graph, latticePoint, Fin.ext_iff] + omega + +lemma bounded_mem_range (r : ℕ) (z : ℤ × ℤ) + (h₁ : z.1.natAbs ≤ r) (h₂ : z.2.natAbs ≤ r) : + z ∈ Set.range (latticeEmbedding r) := by + have ha : z.1 ≤ (z.1.natAbs : ℤ) := Int.le_natAbs + have hb : -z.1 ≤ (z.1.natAbs : ℤ) := by simpa using (Int.le_natAbs (a := -z.1)) + have hc : z.2 ≤ (z.2.natAbs : ℤ) := Int.le_natAbs + have hd : -z.2 ≤ (z.2.natAbs : ℤ) := by simpa using (Int.le_natAbs (a := -z.2)) + refine ⟨(⟨(z.1 + r).toNat, ?_⟩, ⟨(z.2 + r).toNat, ?_⟩), ?_⟩ + · omega + · omega + · apply Prod.ext <;> dsimp [latticeEmbedding, latticePoint] <;> omega + +lemma finite_subset_box (s : Set (ℤ × ℤ)) (hs : s.Finite) : + ∃ r : ℕ, s ⊆ Set.range (latticeEmbedding r) := by + let r := ∑ z ∈ hs.toFinset, (z.1.natAbs + z.2.natAbs) + refine ⟨r, ?_⟩ + intro z hz + have hle : z.1.natAbs + z.2.natAbs ≤ r := + Finset.single_le_sum (f := fun z : ℤ × ℤ => z.1.natAbs + z.2.natAbs) + (fun _ _ => Nat.zero_le _) (hs.mem_toFinset.mpr hz) + exact bounded_mem_range r z (by omega) (by omega) + +theorem lattice_minor_in_rectangle {V : Type*} [Fintype V] {G : SimpleGraph V} + (M : MinorModel G SquareGrid.graph) : + ∃ r : ℕ, Nonempty (MinorModel G (primal (2 * r) (2 * r)).graph) := by + let s := ⋃ v, M.branch v + have hs : s.Finite := Set.finite_iUnion M.branch_finite + obtain ⟨r, hr⟩ := finite_subset_box s hs + refine ⟨r, ⟨M.pullHost (latticeEmbedding r) ?_⟩⟩ + intro v z hz + exact hr (Set.mem_iUnion.mpr ⟨v, hz⟩) + +end +end Barnette.RectangularDual + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/SquareGrid.lean b/lean/OAI/Combinatorics/Hamiltonian/SquareGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..65272b99725a13edffcd3dd7b60520da5ac2b203 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/SquareGrid.lean @@ -0,0 +1,189 @@ +import OAI.Combinatorics.Hamiltonian.Traces + +namespace OAI + +/-! Ordinary square cells and connected finite lattice corridors. -/ + +namespace Barnette.SquareGrid + +noncomputable section + +def graph : SimpleGraph (ℤ × ℤ) where + Adj a b := ((a.1 + 1 = b.1 ∨ b.1 + 1 = a.1) ∧ a.2 = b.2) ∨ + ((a.2 + 1 = b.2 ∨ b.2 + 1 = a.2) ∧ a.1 = b.1) + symm := ⟨by + intro a b h + rcases h with ⟨h, he⟩ | ⟨h, he⟩ + · exact Or.inl ⟨h.symm, he.symm⟩ + · exact Or.inr ⟨h.symm, he.symm⟩⟩ + loopless := ⟨by intro a h; rcases h with ⟨h, _⟩ | ⟨h, _⟩ <;> omega⟩ + +def cell (δ : ℝ) (z : ℤ × ℤ) : Set (ℝ × ℝ) := + Set.Icc (δ * z.1) (δ * ((z.1 : ℝ) + 1)) ×ˢ + Set.Icc (δ * z.2) (δ * ((z.2 : ℝ) + 1)) + +def cells (δ : ℝ) (K : Set (ℝ × ℝ)) : Set (ℤ × ℤ) := + {z | (cell δ z ∩ K).Nonempty} + +theorem cell_closed (δ : ℝ) (z : ℤ × ℤ) : IsClosed (cell δ z) := + isClosed_Icc.prod isClosed_Icc + +theorem cell_compact (δ : ℝ) (z : ℤ × ℤ) : IsCompact (cell δ z) := + isCompact_Icc.prod isCompact_Icc + +theorem cell_cover {δ : ℝ} (hδ : 0 < δ) (p : ℝ × ℝ) : ∃ z, p ∈ cell δ z := by + refine ⟨(⌊p.1 / δ⌋, ⌊p.2 / δ⌋), ?_⟩ + constructor + · constructor + · have h := (le_div_iff₀ hδ).mp (Int.floor_le (p.1 / δ)) + simpa only [mul_comm] using h + · have h := (div_lt_iff₀ hδ).mp (Int.lt_floor_add_one (p.1 / δ)) + exact le_of_lt (by simpa only [mul_comm] using h) + · constructor + · have h := (le_div_iff₀ hδ).mp (Int.floor_le (p.2 / δ)) + simpa only [mul_comm] using h + · have h := (div_lt_iff₀ hδ).mp (Int.lt_floor_add_one (p.2 / δ)) + exact le_of_lt (by simpa only [mul_comm] using h) + +theorem subset_union_cells {δ : ℝ} (hδ : 0 < δ) (K : Set (ℝ × ℝ)) : + K ⊆ ⋃ z : cells δ K, cell δ z.val := by + intro p hp + obtain ⟨z, hz⟩ := cell_cover hδ p + exact Set.mem_iUnion.mpr ⟨⟨z, p, hz, hp⟩, hz⟩ + +private theorem int_bound_of_cell {δ R : ℝ} (hδ : 0 < δ) {a : ℤ} {x : ℝ} + (hx : -R ≤ x ∧ x ≤ R) (ha : δ * a ≤ x ∧ x ≤ δ * ((a : ℝ) + 1)) : + -(R / δ + 1) ≤ (a : ℝ) ∧ (a : ℝ) ≤ R / δ + 1 := by + have hu : (a : ℝ) ≤ R / δ := + (le_div_iff₀ hδ).mpr (by nlinarith [ha.1, hx.2]) + have hl : -R / δ ≤ (a : ℝ) + 1 := + (div_le_iff₀ hδ).mpr (by nlinarith [ha.2, hx.1]) + rw [neg_div] at hl + constructor <;> linarith + +theorem cells_finite {δ : ℝ} (hδ : 0 < δ) {K : Set (ℝ × ℝ)} + (hK : IsCompact K) : (cells δ K).Finite := by + obtain ⟨R, _, hR⟩ := hK.isBounded.exists_pos_norm_le + obtain ⟨N, hN⟩ := exists_int_ge (R / δ + 1) + apply ((Set.finite_Icc (-N) N).prod (Set.finite_Icc (-N) N)).subset + rintro z ⟨p, hp, hpK⟩ + have hp₁ : -R ≤ p.1 ∧ p.1 ≤ R := abs_le.mp ((norm_fst_le p).trans (hR p hpK)) + have hp₂ : -R ≤ p.2 ∧ p.2 ≤ R := abs_le.mp ((norm_snd_le p).trans (hR p hpK)) + obtain ⟨hz₁, hz₁'⟩ := int_bound_of_cell hδ hp₁ hp.1 + obtain ⟨hz₂, hz₂'⟩ := int_bound_of_cell hδ hp₂ hp.2 + have hb₁ : (-(N : ℝ)) ≤ z.1 ∧ (z.1 : ℝ) ≤ N := by constructor <;> linarith + have hb₂ : (-(N : ℝ)) ≤ z.2 ∧ (z.2 : ℝ) ≤ N := by constructor <;> linarith + exact ⟨⟨by exact_mod_cast hb₁.1, by exact_mod_cast hb₁.2⟩, + ⟨by exact_mod_cast hb₂.1, by exact_mod_cast hb₂.2⟩⟩ + +theorem dist_le_of_mem_cell {δ : ℝ} {z : ℤ × ℤ} {p q : ℝ × ℝ} + (hp : p ∈ cell δ z) (hq : q ∈ cell δ z) : dist p q ≤ δ := by + rw [Prod.dist_eq, max_le_iff, Real.dist_eq, Real.dist_eq] + constructor <;> rw [abs_le] <;> constructor <;> + nlinarith [hp.1.1, hp.1.2, hp.2.1, hp.2.2, hq.1.1, hq.1.2, hq.2.1, hq.2.2] + +theorem cell_subset_thickening {δ ε : ℝ} (hδε : δ < ε) {K : Set (ℝ × ℝ)} + {z : ℤ × ℤ} (hz : z ∈ cells δ K) : cell δ z ⊆ Metric.thickening ε K := by + obtain ⟨q, hq, hqK⟩ := hz + intro p hp + exact Metric.mem_thickening_iff.mpr ⟨q, hqK, (dist_le_of_mem_cell hp hq).trans_lt hδε⟩ + +theorem cells_disjoint {δ ε : ℝ} (hδε : δ < ε) + {K L : Set (ℝ × ℝ)} + (hKL : Disjoint (Metric.thickening ε K) (Metric.thickening ε L)) : + Disjoint (cells δ K) (cells δ L) := by + rw [Set.disjoint_left] at hKL ⊢ + intro z hz hz' + have hzp := hz + obtain ⟨p, hp, _⟩ := hzp + exact hKL (cell_subset_thickening hδε hz hp) (cell_subset_thickening hδε hz' hp) + +end +end Barnette.SquareGrid +namespace Barnette.SquareGrid + +noncomputable section + +theorem finite_closed_cover_preconnected {ι α : Type*} [Finite ι] [TopologicalSpace α] + (H : SimpleGraph ι) (K : Set α) (C : ι → Set α) + (hK : IsPreconnected K) (hC : ∀ i, IsClosed (C i)) + (hcover : K ⊆ ⋃ i, C i) (hne : ∀ i, (K ∩ C i).Nonempty) + (hjoin : ∀ p ∈ K, ∀ i j, p ∈ C i → p ∈ C j → H.Reachable i j) : + H.Preconnected := by + classical + intro a b + by_contra hab + let U : Set α := ⋃ i : {i // H.Reachable a i}, C i.val + let W : Set α := ⋃ i : {i // ¬H.Reachable a i}, C i.val + have hU : IsClosed U := isClosed_iUnion_of_finite (fun i => hC i.val) + have hW : IsClosed W := isClosed_iUnion_of_finite (fun i => hC i.val) + have hUW : K ⊆ U ∪ W := by + intro p hp + obtain ⟨i, hi⟩ := Set.mem_iUnion.mp (hcover hp) + by_cases hai : H.Reachable a i + · exact Or.inl (Set.mem_iUnion.mpr ⟨⟨i, hai⟩, hi⟩) + · exact Or.inr (Set.mem_iUnion.mpr ⟨⟨i, hai⟩, hi⟩) + have haU : (K ∩ U).Nonempty := by + obtain ⟨p, hpK, hpa⟩ := hne a + exact ⟨p, hpK, Set.mem_iUnion.mpr ⟨⟨a, .rfl⟩, hpa⟩⟩ + have hbW : (K ∩ W).Nonempty := by + obtain ⟨p, hpK, hpb⟩ := hne b + exact ⟨p, hpK, Set.mem_iUnion.mpr ⟨⟨b, hab⟩, hpb⟩⟩ + obtain ⟨p, hpK, hpU, hpW⟩ := + isPreconnected_closed_iff.mp hK U W hU hW hUW haU hbW + obtain ⟨i, hi⟩ := Set.mem_iUnion.mp hpU + obtain ⟨j, hj⟩ := Set.mem_iUnion.mp hpW + exact j.property (i.property.trans (hjoin p hpK i.val j.val hi hj)) + +private theorem coordinates_close {δ : ℝ} (hδ : 0 < δ) {a b : ℤ} {p : ℝ} + (ha : δ * a ≤ p ∧ p ≤ δ * ((a : ℝ) + 1)) + (hb : δ * b ≤ p ∧ p ≤ δ * ((b : ℝ) + 1)) : + a ≤ b + 1 ∧ b ≤ a + 1 := by + have hab : (a : ℝ) ≤ (b : ℝ) + 1 := (mul_le_mul_iff_right₀ hδ).mp (ha.1.trans hb.2) + have hba : (b : ℝ) ≤ (a : ℝ) + 1 := (mul_le_mul_iff_right₀ hδ).mp (hb.1.trans ha.2) + exact ⟨by exact_mod_cast hab, by exact_mod_cast hba⟩ + +theorem reachable_of_common_point {δ : ℝ} (hδ : 0 < δ) {K : Set (ℝ × ℝ)} + {p : ℝ × ℝ} (hp : p ∈ K) (a b : cells δ K) + (ha : p ∈ cell δ a.val) (hb : p ∈ cell δ b.val) : + (graph.induce (cells δ K)).Reachable a b := by + obtain ⟨hx, hx'⟩ := coordinates_close hδ ha.1 hb.1 + obtain ⟨hy, hy'⟩ := coordinates_close hδ ha.2 hb.2 + let c : cells δ K := ⟨(b.val.1, a.val.2), p, ⟨hb.1, ha.2⟩, hp⟩ + have hac : (graph.induce (cells δ K)).Reachable a c := by + by_cases h : a.val.1 = b.val.1 + · have heq : a = c := Subtype.ext (Prod.ext h rfl) + rw [← heq] + · apply SimpleGraph.Adj.reachable + change graph.Adj a.val c.val + exact Or.inl ⟨by dsimp [c]; omega, rfl⟩ + have hcb : (graph.induce (cells δ K)).Reachable c b := by + by_cases h : a.val.2 = b.val.2 + · have heq : c = b := Subtype.ext (Prod.ext rfl h) + rw [heq] + · apply SimpleGraph.Adj.reachable + change graph.Adj c.val b.val + exact Or.inr ⟨by dsimp [c]; omega, rfl⟩ + exact hac.trans hcb + +theorem cells_connected {δ : ℝ} (hδ : 0 < δ) {K : Set (ℝ × ℝ)} + (hK : IsCompact K) (hc : IsConnected K) : + (graph.induce (cells δ K)).Connected := by + classical + let _ : Fintype (cells δ K) := (cells_finite hδ hK).fintype + have hone : Nonempty (cells δ K) := by + obtain ⟨p, hp⟩ := hc.nonempty + obtain ⟨z, hz⟩ := cell_cover hδ p + exact ⟨⟨z, p, hz, hp⟩⟩ + refine ⟨finite_closed_cover_preconnected _ K (fun z : cells δ K => cell δ z.val) + hc.isPreconnected (fun z => cell_closed _ _) (subset_union_cells hδ K) ?_ ?_⟩ + · intro z + obtain ⟨p, hp, hpK⟩ := z.property + exact ⟨p, hpK, hp⟩ + · intro p hp a b ha hb + exact reachable_of_common_point hδ hp a b ha hb + +end +end Barnette.SquareGrid + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/StateDisk.lean b/lean/OAI/Combinatorics/Hamiltonian/StateDisk.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4ae683dbe83786048422f3d23ae067c448f1a50 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/StateDisk.lean @@ -0,0 +1,483 @@ +import OAI.Combinatorics.Hamiltonian.DiskRegions + +namespace OAI + +/-! Minimal links, incidence states, and the signed disk identity. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] [Fintype F] in +lemma Duality.symm (h : N.Duality D) : D.Duality N := + ⟨h.dual_connected,h.connected,h.dual_cycles_eq_cuts,h.cycles_eq_cuts⟩ + +omit [Fintype V] [Fintype F] in + +lemma Duality.vertex_flow_circuit (h : N.Duality D) (z : F) + (hz : (D.graph.induce {v | v ≠ z}).Connected) : + N.FlowCircuit (D.gradient (fun w => if w = z then 1 else 0)) := by + obtain ⟨r⟩ := hz.nonempty + let x := D.gradient (fun w => if w = z then (1:ℝ) else 0) + have hx : N.boundary x = 0 := (h.symm N D).dual_conserved_gradient D N _ + have hn : x ≠ 0 := by + intro he + have hh := D.gradient_zero_reachable he (h.dual_connected z r.val) + norm_num at hh + exact r.property hh + refine ⟨hx,hn,?_⟩ + intro y hy hs + by_cases hy0 : y = 0 + · exact Or.inl hy0 + right + obtain ⟨f,hf⟩ := (h.symm N D).gradient_of_dual_conserved D N hy + have fstep {v w : {v // v ≠ z}} + (hvw : (D.graph.induce {v | v ≠ z}).Adj v w) : f v.val = f w.val := by + obtain ⟨_,e,he⟩ := hvw + have hxe : x e = 0 := by + dsimp only [x,gradient_apply] + rcases he with he | he <;> rw [he.1,he.2] <;> simp [v.property,w.property] + have hye : y e = 0 := by + by_contra he + exact (N.mem_flowSupport x e).mp (hs ((N.mem_flowSupport y e).mpr he)) hxe + have heq := congrFun hf e + rw [hye,gradient_apply,sub_eq_zero] at heq + exact he.elim (fun he => by rw [he.1,he.2] at heq; exact heq.symm) + (fun he => by rwa [he.1,he.2] at heq) + have fconstant (v : {v // v ≠ z}) : f v.val = f r.val := by + obtain ⟨p⟩ := hz v r + induction p with + | nil => rfl + | cons h p ih => exact (fstep h).trans ih + have hne : f z ≠ f r.val := by + intro he + apply hy0 + rw [← hf] + apply (D.gradient_eq_zero_iff f).mpr + have hall (v : F) : f v = f r.val := by + by_cases hv : v = z + · rwa [hv] + · exact fconstant ⟨v,hv⟩ + intro e + exact (hall _).trans (hall _).symm + apply Finset.Subset.antisymm hs + intro e he + apply (N.mem_flowSupport y e).mpr + rw [← hf,gradient_apply] + have hxe := (N.mem_flowSupport x e).mp he + dsimp only [x,gradient_apply] at hxe + by_cases ht : D.tail e = z <;> by_cases hh : D.head e = z + · simp [ht,hh] at hxe + · rw [ht,fconstant ⟨D.head e,hh⟩] + exact sub_ne_zero.mpr hne.symm + · rw [hh,fconstant ⟨D.tail e,ht⟩] + exact sub_ne_zero.mpr hne + · simp [ht,hh] at hxe + +omit [Fintype V] in + +lemma cut_restrict_conserved (x : E → ℝ) (hx : N.boundary x = 0) (A : Finset V) + (hcut : ∀ e ∈ N.cut A, x e = 0) : + N.boundary (fun e => if N.tail e ∈ A then x e else 0) = 0 := by + ext v + have hb : N.boundary (fun e => if N.tail e ∈ A then x e else 0) v = + if v ∈ A then N.boundary x v else 0 := by + simp only [boundary_apply] + trans ∑ e, if v ∈ A then + ((if N.head e = v then x e else 0) - (if N.tail e = v then x e else 0)) else 0 + swap + · by_cases hv : v ∈ A <;> simp [hv] + apply Finset.sum_congr rfl + intro e _ + have hcross : N.tail e ∈ A ∨ N.head e ∈ A → + ¬(N.tail e ∈ A ∧ N.head e ∈ A) → x e = 0 := by + intro h1 h2 + apply hcut e + rw [N.mem_cut] + tauto + by_cases ht : N.tail e = v <;> by_cases hh : N.head e = v <;> + by_cases ha : N.tail e ∈ A <;> by_cases hb : N.head e ∈ A <;> + by_cases hv : v ∈ A <;> simp_all + rw [hb,hx] + simp + +omit [Fintype V] in + +lemma FlowCircuit.no_split (x : E → ℝ) (hx : N.FlowCircuit x) (A : Finset V) + (hcut : ∀ e ∈ N.cut A, x e = 0) + {e : E} (he : x e ≠ 0) (heA : N.tail e ∈ A) : + ∀ k, x k ≠ 0 → N.tail k ∈ A := by + let y : E → ℝ := fun k => if N.tail k ∈ A then x k else 0 + have hy := N.cut_restrict_conserved x hx.conserved A hcut + have hs : N.flowSupport y ⊆ N.flowSupport x := by + intro k hk + simp only [mem_flowSupport,y] at hk ⊢ + split_ifs at hk <;> tauto + have hyn : y ≠ 0 := by + intro hy0 + have hh := congrFun hy0 e + apply he + simpa [y,heA] using hh + have hEq := (hx.minimal y hy hs).resolve_left hyn + intro k hk + have hyk := (N.mem_flowSupport y k).mp (by rw [hEq]; exact (N.mem_flowSupport x k).mpr hk) + by_contra hn + exact hyk (by simp [y,hn]) + +theorem mixed_corner_on_boundary (h : N.Duality D) (sD : D.Simple) + (face : ∀ v, D.Triangle (N.star v)) (A : Finset V) {z : F} + (hzin : z ∈ N.regionVertices D A) (hzout : z ∈ N.regionVertices D Aᶜ) : + ∃ e ∈ N.cut A, D.Incident e z := by + by_contra hn + have hc := h.vertex_flow_circuit N D z + (faces_vertex_deleted_connected N D h.connected h.dual_connected sD face z) + let x := D.gradient (fun w => if w = z then (1:ℝ) else 0) + have hs : N.flowSupport x = D.star z := D.gradient_indicator_support N sD z + have hcut : ∀ e ∈ N.cut A, x e = 0 := by + intro e he + by_contra hx + have hh : D.Incident e z := (D.mem_star e z).mp (by + rw [← hs]; exact (N.mem_flowSupport x e).mpr hx) + exact hn ⟨e,he,hh⟩ + obtain ⟨e,he,hez⟩ := (N.mem_regionVertices D A z).mp hzin + have hex : x e ≠ 0 := (N.mem_flowSupport x e).mp (by rw [hs]; exact (D.mem_star e z).mpr hez) + have heA : N.tail e ∈ A := by + rcases (N.mem_regionEdges A e).mp he with ht | hh + · exact ht + · by_contra ht + exact hex (hcut e ((N.mem_cut A e).mpr (Or.inr ⟨hh,ht⟩))) + have hall := hc.no_split N x A hcut hex heA + obtain ⟨k,hk,hkz⟩ := (N.mem_regionVertices D Aᶜ z).mp hzout + have hkx : x k ≠ 0 := (N.mem_flowSupport x k).mp (by rw [hs]; exact (D.mem_star k z).mpr hkz) + have hkA := hall k hkx + rcases (N.mem_regionEdges Aᶜ k).mp hk with ht | hh + · exact (Finset.mem_compl.mp ht) hkA + · exact hkx (hcut k ((N.mem_cut A k).mpr (Or.inl ⟨hkA,Finset.mem_compl.mp hh⟩))) + +end +end Barnette.Network + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] [Fintype E] in +def cycleVertices (C : Barnette.CycleCoordinates D.graph) : Finset F := + Finset.univ.image C.vertex + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma mem_cycleVertices (C : Barnette.CycleCoordinates D.graph) (z : F) : + z ∈ D.cycleVertices C ↔ ∃ i, C.vertex i = z := by + simp [cycleVertices] + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma incident_cycle_iff (C : Barnette.CycleCoordinates D.graph) (z : F) : + (∃ e ∈ D.cycleEdges C, D.Incident e z) ↔ z ∈ D.cycleVertices C := by + constructor + · rintro ⟨e,he,hz⟩ + obtain ⟨i,rfl⟩ := (D.mem_cycleEdges C e).mp he + rw [D.incident_iff_mem_pair,D.cycleEdge_ends,Sym2.mem_iff] at hz + rcases hz with rfl | rfl + · exact (D.mem_cycleVertices C _).mpr ⟨i,rfl⟩ + · exact (D.mem_cycleVertices C _).mpr ⟨i+1,rfl⟩ + · intro hz + obtain ⟨i,rfl⟩ := (D.mem_cycleVertices C z).mp hz + refine ⟨D.cycleEdge C i,(D.mem_cycleEdges C _).mpr ⟨i,rfl⟩,?_⟩ + rw [D.incident_iff_mem_pair,D.cycleEdge_ends]; simp + +omit [Fintype V] in +lemma regionVertices_iff_face (face : ∀ v, D.Triangle (N.star v)) + (A : Finset V) (z : F) : + z ∈ N.regionVertices D A ↔ ∃ v ∈ A, z ∈ Set.range (face v).corner := by + constructor + · intro hz + obtain ⟨e,he,hez⟩ := (N.mem_regionVertices D A z).mp hz + rcases (N.mem_regionEdges A e).mp he with ht | hh + · exact ⟨N.tail e,ht,((face _).corner_iff_incident D z).mpr + ⟨e,(N.mem_star e _).mpr (Or.inl rfl),hez⟩⟩ + · exact ⟨N.head e,hh,((face _).corner_iff_incident D z).mpr + ⟨e,(N.mem_star e _).mpr (Or.inr rfl),hez⟩⟩ + · rintro ⟨v,hv,hz⟩ + obtain ⟨e,he,hez⟩ := ((face v).corner_iff_incident D z).mp hz + refine (N.mem_regionVertices D A z).mpr ⟨e,?_,hez⟩ + rcases (N.mem_star e v).mp he with ht | hh + · exact (N.mem_regionEdges A e).mpr (Or.inl (ht ▸ hv)) + · exact (N.mem_regionEdges A e).mpr (Or.inr (hh ▸ hv)) + +omit [Fintype V] [Fintype E] [Fintype F] in +def blackEndpoint (black : V → Prop) (e : E) : V := + if black (N.tail e) then N.tail e else N.head e + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma blackEndpoint_spec (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (e : E) : + black (N.blackEndpoint black e) ∧ N.Incident e (N.blackEndpoint black e) := by + by_cases ht : black (N.tail e) + · simp only [blackEndpoint,ite_eq_left ht]; exact ⟨ht,Or.inl rfl⟩ + · simp only [blackEndpoint,ite_eq_right ht] + exact ⟨not_not.mp (fun hh => ht ((hc e).mpr hh)),Or.inr rfl⟩ + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma blackEndpoint_eq (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + {e : E} {v : V} (hv : black v) (he : N.Incident e v) : + N.blackEndpoint black e = v := by + rcases he with ht | hh + · simp [blackEndpoint,ht,hv] + · have hnt : ¬black (N.tail e) := fun ht => (hc e).mp ht (hh ▸ hv) + simp [blackEndpoint,hnt,hh] + +omit [Fintype V] [Fintype F] in +def blackCut (black : V → Prop) (A : Finset V) : Finset E := + (N.cut A).filter fun e => N.blackEndpoint black e ∈ A + +omit [Fintype F] in +lemma cubic_black_region_count (sN : N.Simple) (hdeg : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (A : Finset V) : + 3 * (A.filter black).card + (N.cut A).card = + (N.regionEdges A).card + (N.blackCut black A).card := by + have hs := N.sum_stars sN (A.filter black) + have hd : ∀ v, N.graph.degree v = 3 := hdeg + have hh : (∑ v ∈ A.filter black, (N.star v).card) = 3 * (A.filter black).card := by + simp only [N.card_star sN,hd] + simp [Nat.mul_comm] + rw [hh] at hs + rw [hs] + simp only [cut,regionEdges,blackCut,Finset.card_filter,Finset.mem_filter, + Finset.sum_filter,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro e _ + have hcol := hc e + by_cases ht : N.tail e ∈ A <;> by_cases hh : N.head e ∈ A <;> + by_cases hb : black (N.tail e) <;> by_cases hw : black (N.head e) <;> + simp_all [blackEndpoint] + +theorem state_disk_count (h : N.Duality D) (sD : D.Simple) + (face : ∀ v, D.Triangle (N.star v)) (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (root : V) + (m : V → F) + (hm_inj : Set.InjOn m {v | black v ∧ v ≠ root}) + (hm_face : ∀ v, black v → v ≠ root → m v ∈ Set.range (face v).corner) + (hm_range : ∀ z, z ∉ Set.range (face root).corner ↔ + ∃ v, black v ∧ v ≠ root ∧ m v = z) + (C : Barnette.CycleCoordinates D.graph) + (hchoice : ∀ i, N.blackEndpoint black (D.cycleEdge C i) ≠ root ∧ + m (N.blackEndpoint black (D.cycleEdge C i)) = C.vertex i) + (A : Finset V) (hroot : root ∉ A) (hcut : N.cut A = D.cycleEdges C) : + (A.filter black).card + (N.cut A).card = + (N.regionVertices D A).card + (N.blackCut black A).card := by + let U := N.regionVertices D A + let Z := D.cycleVertices C + let B := A.filter black + let M := B.image m + let J := Finset.univ.filter fun i : Fin (C.n+3) => + N.blackEndpoint black (D.cycleEdge C i) ∈ A + have face_region {v : V} (hv : v ∈ A) {z : F} + (hz : z ∈ Set.range (face v).corner) : z ∈ U := + (N.regionVertices_iff_face D face A z).mpr ⟨v,hv,hz⟩ + have hZroot : ∀ z ∈ Z, z ∉ Set.range (face root).corner := by + intro z hz + obtain ⟨i,rfl⟩ := (D.mem_cycleVertices C z).mp hz + apply (hm_range _).mpr + exact ⟨_,(N.blackEndpoint_spec black hc _).1,(hchoice i).1,(hchoice i).2⟩ + have hZU : Z ⊆ U := by + intro z hz + obtain ⟨e,he,hez⟩ := (D.incident_cycle_iff C z).mpr hz + rw [← hcut] at he + refine (N.mem_regionVertices D A z).mpr ⟨e,?_,hez⟩ + rcases (N.mem_cut A e).mp he with ht | hh + · exact (N.mem_regionEdges A e).mpr (Or.inl ht.1) + · exact (N.mem_regionEdges A e).mpr (Or.inr hh.1) + have hUroot : ∀ z ∈ U, z ∉ Set.range (face root).corner := by + intro z hz hr + have hzout : z ∈ N.regionVertices D Aᶜ := + (N.regionVertices_iff_face D face Aᶜ z).mpr ⟨root,Finset.mem_compl.mpr hroot,hr⟩ + have hh := N.mixed_corner_on_boundary D h sD face A hz hzout + rw [hcut] at hh + exact hZroot z ((D.incident_cycle_iff C z).mp hh) hr + have hMU : M ⊆ U := by + intro z hz + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hz + obtain ⟨hvA,hvb⟩ := Finset.mem_filter.mp hv + exact face_region hvA (hm_face v hvb (fun he => hroot (he ▸ hvA))) + have h_union : M ∪ Z = U := by + apply Finset.Subset.antisymm + · exact Finset.union_subset hMU hZU + · intro z hz + by_cases hzZ : z ∈ Z + · exact Finset.mem_union_right _ hzZ + obtain ⟨v,hvb,hvr,hvz⟩ := (hm_range z).mp (hUroot z hz) + have hvA : v ∈ A := by + by_contra hvA + have hzout : z ∈ N.regionVertices D Aᶜ := + (N.regionVertices_iff_face D face Aᶜ z).mpr + ⟨v,Finset.mem_compl.mpr hvA,hvz ▸ hm_face v hvb hvr⟩ + have hh := N.mixed_corner_on_boundary D h sD face A hz hzout + rw [hcut] at hh + exact hzZ ((D.incident_cycle_iff C z).mp hh) + exact Finset.mem_union_left _ (Finset.mem_image.mpr + ⟨v,Finset.mem_filter.mpr ⟨hvA,hvb⟩,hvz⟩) + have h_inter : M ∩ Z = J.image C.vertex := by + ext z + constructor + · rintro hz + obtain ⟨hzM,hzZ⟩ := Finset.mem_inter.mp hz + obtain ⟨v,hv,hvz⟩ := Finset.mem_image.mp hzM + obtain ⟨hvA,hvb⟩ := Finset.mem_filter.mp hv + obtain ⟨i,hi⟩ := (D.mem_cycleVertices C z).mp hzZ + have heq : v = N.blackEndpoint black (D.cycleEdge C i) := + hm_inj ⟨hvb,fun he => hroot (he ▸ hvA)⟩ + ⟨(N.blackEndpoint_spec black hc _).1,(hchoice i).1⟩ + (hvz.trans (hi.symm.trans (hchoice i).2.symm)) + exact Finset.mem_image.mpr ⟨i,Finset.mem_filter.mpr ⟨Finset.mem_univ _,heq ▸ hvA⟩,hi⟩ + · rintro hz + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hz + have hiA := (Finset.mem_filter.mp hi).2 + refine Finset.mem_inter.mpr ⟨?_,(D.mem_cycleVertices C _).mpr ⟨i,rfl⟩⟩ + exact Finset.mem_image.mpr ⟨_,Finset.mem_filter.mpr + ⟨hiA,(N.blackEndpoint_spec black hc _).1⟩,(hchoice i).2⟩ + have hCJ : J.image (D.cycleEdge C) = N.blackCut black A := by + ext e + simp only [blackCut,Finset.mem_filter] + constructor + · intro he + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp he + refine ⟨?_,(Finset.mem_filter.mp hi).2⟩ + rw [hcut] + exact (D.mem_cycleEdges C _).mpr ⟨i,rfl⟩ + · rintro ⟨he,hb⟩ + rw [hcut] at he + obtain ⟨i,rfl⟩ := (D.mem_cycleEdges C e).mp he + exact Finset.mem_image.mpr ⟨i,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hb⟩,rfl⟩ + have hMcard : M.card = B.card := Finset.card_image_iff.mpr (by + intro v hv w hw he + obtain ⟨hvA,hvb⟩ := Finset.mem_filter.mp hv + obtain ⟨hwA,hwb⟩ := Finset.mem_filter.mp hw + exact hm_inj ⟨hvb,fun he => hroot (he ▸ hvA)⟩ + ⟨hwb,fun he => hroot (he ▸ hwA)⟩ he) + have hZcard : Z.card = (N.cut A).card := by + rw [hcut] + simp only [Z,cycleVertices,cycleEdges,Finset.card_image_of_injective _ C.vertex.injective, + Finset.card_image_of_injective _ (D.cycleEdge_injective C)] + have hIcard : (M ∩ Z).card = (N.blackCut black A).card := by + rw [h_inter,← hCJ] + rw [Finset.card_image_of_injective _ C.vertex.injective, + Finset.card_image_of_injective _ (D.cycleEdge_injective C)] + have hh := Finset.card_union_add_card_inter M Z + rw [h_union,hMcard,hZcard,hIcard] at hh + exact hh.symm + +end +end Barnette.Network + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] [Fintype E] [Fintype F] in +def blackDelta (black : V → Prop) (C : Barnette.CycleCoordinates D.graph) : ℝ := + ∑ i, N.gradient (fun v => if black v then 1 else 0) (D.cycleEdge C i) * + D.arcSign (D.cycleEdge C i) (C.vertex i) + +omit [Fintype V] [Fintype F] in +lemma blackDelta_cut (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (C : Barnette.CycleCoordinates D.graph) (A : Finset V) (c : ℝ) + (hx : D.cycleFlow C = c • N.gradient (fun v => if v ∈ A then 1 else 0)) + (hcut : N.cut A = D.cycleEdges C) : + N.blackDelta D black C = c * (2 * (N.blackCut black A).card - (N.cut A).card) := by + have hsum : N.blackDelta D black C = ∑ e ∈ N.cut A, + N.gradient (fun v => if black v then 1 else 0) e * D.cycleFlow C e := by + rw [hcut,cycleEdges,Finset.sum_image (D.cycleEdge_injective C).injOn] + simp only [blackDelta,D.cycleFlow_apply_edge] + rw [hsum] + simp only [hx,Pi.smul_apply,smul_eq_mul] + have heq (e : E) (he : e ∈ N.cut A) : + N.gradient (fun v => if black v then (1:ℝ) else 0) e * + (c * N.gradient (fun v => if v ∈ A then 1 else 0) e) = + c * (2 * (if N.blackEndpoint black e ∈ A then 1 else 0) - 1) := by + have hcol := hc e + have he' := (N.mem_cut A e).mp he + by_cases ht : N.tail e ∈ A <;> by_cases hh : N.head e ∈ A <;> + by_cases hb : black (N.tail e) <;> by_cases hw : black (N.head e) <;> + simp_all [gradient_apply,blackEndpoint] <;> ring + rw [Finset.sum_congr rfl heq,← Finset.mul_sum,Finset.sum_sub_distrib, + ← Finset.mul_sum,Finset.sum_boole] + simp [blackCut] + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma cycle_cut_scalar (C : Barnette.CycleCoordinates D.graph) (A : Finset V) (c : ℝ) + (hx : D.cycleFlow C = c • N.gradient (fun v => if v ∈ A then 1 else 0)) : + c = 1 ∨ c = -1 := by + have hh := congrFun hx (D.cycleEdge C 0) + rw [D.cycleFlow_apply_edge] at hh + simp only [Pi.smul_apply,smul_eq_mul,gradient_apply] at hh + by_cases ht : N.tail (D.cycleEdge C 0) ∈ A <;> + by_cases hh' : N.head (D.cycleEdge C 0) ∈ A <;> + by_cases hd : D.tail (D.cycleEdge C 0) = C.vertex 0 <;> + simp [arcSign,ht,hh',hd] at hh <;> + first | exact Or.inl (by linarith) | exact Or.inr (by linarith) + +lemma disk_boundary_imbalance (h : N.Duality D) (sN : N.Simple) + (hdeg : N.graph.IsRegularOfDegree 3) (sD : D.Simple) + (face : ∀ v, D.Triangle (N.star v)) + (black : V → Prop) (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (A : Finset V) (hA : (N.graph.induce {v | v ∈ A}).Connected) + (hAc : (N.graph.induce {v | v ∉ A}).Connected) + (hm : (A.filter black).card + (N.cut A).card = + (N.regionVertices D A).card + (N.blackCut black A).card) : + (N.cut A).card = 2 * (N.blackCut black A).card + 3 := by + have he := N.region_euler D h A hA hAc sD face + have ht := N.cubic_region_count sN hdeg A + have hb := N.cubic_black_region_count sN hdeg black hc A + omega + +theorem state_disk_delta (h : N.Duality D) (sN : N.Simple) + (hdeg : N.graph.IsRegularOfDegree 3) (sD : D.Simple) + (face : ∀ v, D.Triangle (N.star v)) (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (root : V) + (m : V → F) + (hm_inj : Set.InjOn m {v | black v ∧ v ≠ root}) + (hm_face : ∀ v, black v → v ≠ root → m v ∈ Set.range (face v).corner) + (hm_range : ∀ z, z ∉ Set.range (face root).corner ↔ + ∃ v, black v ∧ v ≠ root ∧ m v = z) + (C : Barnette.CycleCoordinates D.graph) + (hchoice : ∀ i, N.blackEndpoint black (D.cycleEdge C i) ≠ root ∧ + m (N.blackEndpoint black (D.cycleEdge C i)) = C.vertex i) : + ∃ (A : Finset V) (c : ℝ), A.Nonempty ∧ root ∉ A ∧ (c = 1 ∨ c = -1) ∧ + D.cycleFlow C = c • N.gradient (fun v => if v ∈ A then 1 else 0) ∧ + N.cut A = D.cycleEdges C ∧ + (N.cut A).card = 2 * (N.blackCut black A).card + 3 ∧ + N.blackDelta D black C = -3*c := by + have hx := D.cycleFlow_circuit C sD + obtain ⟨A,c,ha,hr,_hc0,he,hcut⟩ := h.circuit_cut N D (D.cycleFlow C) hx root + rw [D.cycleFlow_support] at hcut + have hb : N.Bond A := h.bond_of_circuit N D (D.cycleFlow C) hx A (by + rw [D.cycleFlow_support]; exact hcut) + have hA := hb.connected_shore N h.connected ha ⟨root,hr⟩ + have hAc := hb.compl.connected_shore N h.connected + (Finset.mem_compl.mpr hr |> fun hh => ⟨root,hh⟩) (by + obtain ⟨v,hv⟩ := ha + exact ⟨v,by simpa using hv⟩) + have hsides : {v : V | v ∈ Aᶜ} = {v : V | v ∉ A} := by + ext v + exact Finset.mem_compl + rw [hsides] at hAc + have hm := N.state_disk_count D h sD face black hc root m hm_inj hm_face hm_range C hchoice A hr hcut + have hcount := N.disk_boundary_imbalance D h sN hdeg sD face black hc A hA hAc hm + refine ⟨A,c,ha,hr,N.cycle_cut_scalar D C A c he,he,hcut,hcount,?_⟩ + rw [N.blackDelta_cut D black hc C A c he hcut,hcount] + push_cast + ring + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/ThreeCuts.lean b/lean/OAI/Combinatorics/Hamiltonian/ThreeCuts.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa380e04ba26efdf2c7b59a57e0aa921a6940619 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/ThreeCuts.lean @@ -0,0 +1,466 @@ +import OAI.Combinatorics.Hamiltonian.ForestMatching + +namespace OAI + +/-! Three-edge cuts, capped graphs, and preservation of graph properties. -/ + +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +lemma gradient_small_support_edge (h : N.ThreeEdgeConnected) (f : V → ℝ) (s : Finset E) (hs : s.card ≤ 2) + (hf : ∀ e, e ∉ s → N.gradient f e = 0) : N.gradient f = 0 := by + ext e + by_contra he + have hne : f (N.head e) ≠ f (N.tail e) := by + simpa only [gradient_apply, Pi.zero_apply, sub_eq_zero] using he + let A := Finset.univ.filter fun v => f v = f (N.tail e) + have hin : A.Nonempty := ⟨N.tail e, by simp [A]⟩ + have hout : ∃ w, w ∉ A := ⟨N.head e, by simp [A, hne]⟩ + have hsub : N.cut A ⊆ s := by + intro k hk + by_contra hks + have hg : f (N.head k) = f (N.tail k) := sub_eq_zero.mp (hf k hks) + rcases (N.mem_cut A k).mp hk with ⟨ht,hh⟩ | ⟨hh,ht⟩ + · apply hh; simp only [A, Finset.mem_filter, Finset.mem_univ, true_and] at ht ⊢ + exact hg.trans ht + · apply ht; simp only [A, Finset.mem_filter, Finset.mem_univ, true_and] at hh ⊢ + exact hg.symm.trans hh + have h₁ := h A hin (by obtain ⟨w,hw⟩ := hout; exact ⟨w,Finset.mem_compl.mpr hw⟩) + have h₂ := Finset.card_le_card hsub + omega + +variable {F : Type*} [Fintype F] (D : Network F E) + +omit [Fintype F] in +theorem Duality.simple_dual_edge (h : N.Duality D) + (h3 : N.ThreeEdgeConnected) : D.Simple := by + have lift_zero (x : E → ℝ) (hx : D.boundary x = 0) + (s : Finset E) (hs : s.card ≤ 2) (hxs : ∀ e, e ∉ s → x e = 0) : x = 0 := by + have hx' : x ∈ N.gradient.range := by rw [← h.dual_cycles_eq_cuts]; exact hx + obtain ⟨f,hf⟩ := hx' + rw [← hf] + exact N.gradient_small_support_edge h3 f s hs (by simpa only [hf] using hxs) + refine ⟨?_, ?_⟩ + · intro e he + have hz : D.boundary (basisVec e) = 0 := by + rw [D.boundary_basis] + ext v + simp [incidence, he] + have hzero := lift_zero (basisVec e) hz {e} (by simp) (by + intro k hk; simp only [Finset.mem_singleton] at hk; simp [basisVec, hk]) + have hh := congrFun hzero e + norm_num [basisVec] at hh + · intro e f hef + by_contra hne + rcases Sym2.eq_iff.mp hef with ⟨ht,hh⟩ | ⟨ht,hh⟩ + · have hz : D.boundary (basisVec e - basisVec f) = 0 := by + rw [map_sub, D.boundary_basis, D.boundary_basis] + ext v + simp [incidence, ht, hh] + have hzero := lift_zero (basisVec e - basisVec f) hz {e,f} + (by simpa using Finset.card_insert_le e ({f} : Finset E)) + (by intro k hk; simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hk + simp [basisVec, hk.1, hk.2]) + have hv := congrFun hzero e + norm_num [basisVec, hne] at hv + · have hz : D.boundary (basisVec e + basisVec f) = 0 := by + rw [map_add, D.boundary_basis, D.boundary_basis] + ext v + dsimp [incidence] + rw [ht, hh] + ring + have hzero := lift_zero (basisVec e + basisVec f) hz {e,f} + (by simpa using Finset.card_insert_le e ({f} : Finset E)) + (by intro k hk; simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hk + simp [basisVec, hk.1, hk.2]) + have hv := congrFun hzero e + norm_num [basisVec, hne] at hv + +omit [Fintype F] in +theorem Duality.cubic_face_triangles_edge (h : N.Duality D) (hN : N.Simple) + (h3 : N.ThreeEdgeConnected) + (hc : N.graph.IsRegularOfDegree 3) : ∀ v, Nonempty (D.Triangle (N.star v)) := by + intro v + have hD := h.simple_dual_edge N D h3 + have hx := h.dual_conserved_gradient N D (fun w => if w = v then 1 else 0) + have hs : (D.flowSupport (N.gradient (fun w => if w = v then 1 else 0))).card = 3 := by + rw [N.gradient_indicator_support D hN, N.card_star hN, hc v] + simpa only [N.gradient_indicator_support D hN] using D.triangle_of_flow hD _ hx hs + +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype F] in +lemma make_coloredDual (h : N.Duality D) (hN : N.Simple) (h3 : N.ThreeEdgeConnected) + (hc : N.graph.IsRegularOfDegree 3) (black : V → Prop) + (hb : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) : Nonempty (N.ColoredDual D) := by + have hs := h.simple_dual_edge N D h3 + have ht := h.cubic_face_triangles_edge N D hN h3 hc + choose t ho using fun v => N.oriented_face D h hN hs v (ht v).some + exact ⟨⟨h,hN,hs,hc,black,hb,t,ho⟩⟩ + +lemma irreducible_matching (M : N.ColoredDual D) + (h3 : N.ThreeEdgeConnected) (htr : N.TrivialThreeCuts) (e : E) : + ∃ P : Finset E, e ∈ P ∧ (∀ v, ((N.star v).filter fun e => e ∈ P).card = 1) ∧ + (N.restrict (Subtype.val : ↥(Pᶜ) → E)).graph.Connected := by + let root := N.blackEndpoint M.black e + have hr := (N.blackEndpoint_spec M.black M.coloring e).1 + have he : e ∈ N.star root := (N.mem_star _ _).mpr (N.blackEndpoint_spec M.black M.coloring e).2 + obtain ⟨i,_,hi⟩ := Finset.mem_image.mp ((M.face root).edge_range.symm ▸ he) + obtain ⟨Q,hQ⟩ := M.forest_pair (M.pair_nonempty h3 htr root hr) + simpa only [hi] using M.recover_connected_complement Q hr hQ i +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +def capMap (_N : Network V E) (A : Finset V) (v : V) : Option A := if h : v ∈ A then some ⟨v,h⟩ else none + +omit [Fintype V] [Fintype E] in +@[simp] lemma capMap_some (A : Finset V) (v : A) : N.capMap A v.val = some v := by + simp [capMap,v.property] +omit [Fintype V] [Fintype E] in +@[simp] lemma capMap_eq_none (A : Finset V) (v : V) : N.capMap A v = none ↔ v ∉ A := by + simp [capMap] +omit [Fintype V] [Fintype E] in +@[simp] lemma capMap_eq_some (A : Finset V) (v : V) (w : A) : + N.capMap A v = some w ↔ v = w.val := by + by_cases h : v ∈ A + · simp [capMap,h,Subtype.ext_iff] + · simp only [capMap,dite_eq_right h,reduceCtorEq,false_iff] + exact fun he => h (he ▸ w.property) + +omit [Fintype E] in +lemma capMap_surjective (A : Finset V) (hA : Aᶜ.Nonempty) : Function.Surjective (N.capMap A) := by + rintro (_|v) + · obtain ⟨v,hv⟩ := hA + exact ⟨v,(N.capMap_eq_none A v).mpr (Finset.mem_compl.mp hv)⟩ + · exact ⟨v.val,N.capMap_some A v⟩ + +abbrev cap (A : Finset V) : Network (Option A) (N.regionEdges A) := + (N.mapVertices (N.capMap A)).restrict Subtype.val + +omit [Fintype V] in +lemma cap_loopless (hN : N.Simple) (A : Finset V) (e : N.regionEdges A) : + (N.cap A).tail e ≠ (N.cap A).head e := by + change N.capMap A (N.tail e.val) ≠ N.capMap A (N.head e.val) + intro he + rcases (N.mem_regionEdges A e.val).mp e.property with ht|hh + · have ht' := N.capMap_some A ⟨N.tail e.val,ht⟩ + rw [ht'] at he + exact hN.loopless e.val (((N.capMap_eq_some A _ _).mp he.symm).symm) + · have hh' := N.capMap_some A ⟨N.head e.val,hh⟩ + rw [hh'] at he + exact hN.loopless e.val ((N.capMap_eq_some A _ _).mp he) + +omit [Fintype V] in +lemma cap_star_some (A : Finset V) (v : A) : + ((N.cap A).star (some v)).image Subtype.val = N.star v.val := by + ext e + simp only [Finset.mem_image,mem_star,Incident] + constructor + · rintro ⟨k,hk,rfl⟩ + exact hk.elim (fun h => Or.inl ((N.capMap_eq_some A _ v).mp h)) + (fun h => Or.inr ((N.capMap_eq_some A _ v).mp h)) + · intro he + have hm : e ∈ N.regionEdges A := (N.mem_regionEdges A e).mpr + (he.elim (fun h => Or.inl (h ▸ v.property)) (fun h => Or.inr (h ▸ v.property))) + refine ⟨⟨e,hm⟩,?_,rfl⟩ + exact he.elim (fun h => Or.inl ((N.capMap_eq_some A _ v).mpr h)) + (fun h => Or.inr ((N.capMap_eq_some A _ v).mpr h)) + +omit [Fintype V] in +lemma cap_star_none (A : Finset V) : + ((N.cap A).star none).image Subtype.val = N.cut A := by + ext e + simp only [Finset.mem_image,mem_star,Incident,mem_cut] + constructor + · rintro ⟨k,hk,rfl⟩ + have hm := (N.mem_regionEdges A k.val).mp k.property + change N.capMap A (N.tail k.val) = none ∨ N.capMap A (N.head k.val) = none at hk + simp only [capMap_eq_none] at hk + tauto + · intro he + have hm : e ∈ N.regionEdges A := (N.mem_regionEdges A e).mpr (he.elim (Or.inl ∘ And.left) (Or.inr ∘ And.left)) + refine ⟨⟨e,hm⟩,?_,rfl⟩ + change N.capMap A (N.tail e) = none ∨ N.capMap A (N.head e) = none + simp only [capMap_eq_none] + tauto + +lemma cap_star_card (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) + (A : Finset V) (hA : (N.cut A).card = 3) (v : Option A) : ((N.cap A).star v).card = 3 := by + rw [← Finset.card_image_of_injective _ Subtype.val_injective] + cases v with + | none => rw [N.cap_star_none,hA] + | some v => rw [N.cap_star_some,N.card_star hN,hc v.val] + +def capPreimage (A : Finset V) (B : Finset (Option A)) : Finset V := + Finset.univ.filter fun v => N.capMap A v ∈ B + +omit [Fintype E] in +@[simp] lemma mem_capPreimage (A : Finset V) (B : Finset (Option A)) (v : V) : + v ∈ N.capPreimage A B ↔ N.capMap A v ∈ B := by simp [capPreimage] + +lemma cap_cut (A : Finset V) (B : Finset (Option A)) : + ((N.cap A).cut B).image Subtype.val = N.cut (N.capPreimage A B) := by + ext e + simp only [Finset.mem_image,mem_cut,mem_capPreimage] + constructor + · rintro ⟨k,hk,rfl⟩ + exact hk + · intro he + have hm : e ∈ N.regionEdges A := by + apply (N.mem_regionEdges A e).mpr + by_contra hn + have ht := (N.capMap_eq_none A (N.tail e)).mpr (not_or.mp hn).1 + have hh := (N.capMap_eq_none A (N.head e)).mpr (not_or.mp hn).2 + rw [ht,hh] at he + tauto + exact ⟨⟨e,hm⟩,he,rfl⟩ + +lemma cap_threeConnected (hN : N.ThreeEdgeConnected) (A : Finset V) (hA : Aᶜ.Nonempty) : + (N.cap A).ThreeEdgeConnected := by + intro B hB hBc + rw [← Finset.card_image_of_injective _ Subtype.val_injective,N.cap_cut] + apply hN + · obtain ⟨v,hv⟩ := hB + obtain ⟨w,rfl⟩ := N.capMap_surjective A hA v + exact ⟨w,(N.mem_capPreimage A B w).mpr hv⟩ + · obtain ⟨v,hv⟩ := hBc + obtain ⟨w,rfl⟩ := N.capMap_surjective A hA v + exact ⟨w,by simpa only [Finset.mem_compl,mem_capPreimage] using hv⟩ + +lemma ThreeEdgeConnected.connected [Nonempty V] (h : N.ThreeEdgeConnected) : N.graph.Connected := by + apply N.connected_of_kernel_constants + intro f hf v w + by_contra hn + let A := Finset.univ.filter fun z => f z = f v + have hA : (N.cut A).card = 0 := by + apply Finset.card_eq_zero.mpr + apply Finset.eq_empty_iff_forall_notMem.mpr + intro e he + have hh := (N.gradient_eq_zero_iff f).mp hf e + have hc := (N.mem_cut A e).mp he + simp only [A,Finset.mem_filter,Finset.mem_univ,true_and,hh] at hc + tauto + have hc := h A ⟨v,by simp [A]⟩ ⟨w,by simp [A,Ne.symm hn]⟩ + omega + +lemma threeCut_bond (h : N.ThreeEdgeConnected) (A : Finset V) (hA : (N.cut A).card = 3) : N.Bond A := by + refine ⟨Finset.card_pos.mp (by omega),?_⟩ + intro B hB + by_cases hn : (N.cut B).Nonempty + · right + obtain ⟨e,he⟩ := hn + have hc := (N.mem_cut B e).mp he + have hi : B.Nonempty := hc.elim (fun h => ⟨_,h.1⟩) (fun h => ⟨_,h.1⟩) + have ho : Bᶜ.Nonempty := hc.elim (fun h => ⟨_,Finset.mem_compl.mpr h.2⟩) (fun h => ⟨_,Finset.mem_compl.mpr h.2⟩) + exact Finset.eq_of_subset_of_card_le hB (by have hh := h B hi ho; omega) + · exact Or.inl (Finset.not_nonempty_iff_eq_empty.mp hn) + +omit [Fintype V] [Fintype E] in +lemma cap_connectedFibers (A : Finset V) + (hc : (N.graph.induce {v | v ∉ A}).Connected) : N.ConnectedFibers (N.capMap A) := by + intro v w he + by_cases hv : v ∈ A + · have hv' := N.capMap_some A ⟨v,hv⟩ + rw [hv'] at he + have hh : w = v := (N.capMap_eq_some A _ _).mp he.symm + subst w + exact SimpleGraph.Reachable.refl v + · have hw : w ∉ A := (N.capMap_eq_none A w).mp (he.symm.trans ((N.capMap_eq_none A v).mpr hv)) + let f : (N.graph.induce {v | v ∉ A}) →g (N.restrict (Subtype.val : N.internal (N.capMap A) → E)).graph := { + toFun := Subtype.val + map_rel' := by + intro x y hxy + obtain ⟨hne,e,hee⟩ := hxy + change (N.tail e = x.val ∧ N.head e = y.val) ∨ (N.tail e = y.val ∧ N.head e = x.val) at hee + have hm : e ∈ N.internal (N.capMap A) := by + rcases hee with ⟨ht,hh⟩|⟨ht,hh⟩ <;> + change N.capMap A (N.tail e) = N.capMap A (N.head e) <;> + rw [ht,hh,(N.capMap_eq_none A _).mpr x.property,(N.capMap_eq_none A _).mpr y.property] + exact ⟨hne,⟨e,hm⟩,hee⟩ } + exact (hc ⟨v,hv⟩ ⟨w,hw⟩).map f +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +lemma simple_of_cubic_stars (hl : ∀ e, N.tail e ≠ N.head e) + (hc : ∀ v, (N.star v).card = 3) (h3 : N.ThreeEdgeConnected) + (hV : 3 ≤ Fintype.card V) : N.Simple := by + refine ⟨hl,?_⟩ + intro e f hef + by_contra hne + dsimp only at hef + let a := N.tail e + let b := N.head e + have hab : a ≠ b := hl e + have hfa : N.Incident f a := (N.incident_iff_mem_pair f a).mpr (by rw [← hef]; simp [a]) + have hfb : N.Incident f b := (N.incident_iff_mem_pair f b).mpr (by rw [← hef]; simp [b]) + have hsa : ({e,f} : Finset E) ⊆ N.star a := by + intro k hk + rcases Finset.mem_insert.mp hk with rfl|hk + · exact (N.mem_star _ _).mpr (Or.inl rfl) + · have hk' := Finset.mem_singleton.mp hk + subst k + exact (N.mem_star _ _).mpr hfa + have hsb : ({e,f} : Finset E) ⊆ N.star b := by + intro k hk + rcases Finset.mem_insert.mp hk with rfl|hk + · exact (N.mem_star _ _).mpr (Or.inr rfl) + · have hk' := Finset.mem_singleton.mp hk + subst k + exact (N.mem_star _ _).mpr hfb + have hein : e ∉ N.cut {a,b} := by simp [mem_cut,a,b] + have hfin : f ∉ N.cut {a,b} := by + have hh := Sym2.eq_iff.mp hef + rcases hh with ⟨ht,hh⟩|⟨ht,hh⟩ <;> simp [mem_cut,← ht,← hh,a,b] + have hsub : N.cut {a,b} ⊆ (N.star a \ {e,f}) ∪ (N.star b \ {e,f}) := by + intro k hk + have hke : k ∉ ({e,f} : Finset E) := by + simp only [Finset.mem_insert,Finset.mem_singleton,not_or] + exact ⟨fun hh => hein (hh ▸ hk),fun hh => hfin (hh ▸ hk)⟩ + have hi : N.Incident k a ∨ N.Incident k b := by + have hh := (N.mem_cut {a,b} k).mp hk + simp only [Finset.mem_insert,Finset.mem_singleton] at hh + simp only [Incident] + tauto + exact hi.elim (fun hi => Finset.mem_union_left _ (Finset.mem_sdiff.mpr ⟨(N.mem_star _ _).mpr hi,hke⟩)) + (fun hi => Finset.mem_union_right _ (Finset.mem_sdiff.mpr ⟨(N.mem_star _ _).mpr hi,hke⟩)) + have hcard := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) + rw [Finset.card_sdiff_of_subset hsa,Finset.card_sdiff_of_subset hsb,hc,hc] at hcard + simp only [Finset.card_pair hne] at hcard + have hout : ({a,b} : Finset V)ᶜ.Nonempty := by + apply Finset.card_pos.mp + rw [Finset.card_compl,Finset.card_pair hab] + omega + have hh := h3 {a,b} (by simp) hout + omega + +lemma cap_simple (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) (h3 : N.ThreeEdgeConnected) + (A : Finset V) (hcut : (N.cut A).card = 3) (hA : 2 ≤ A.card) (ho : Aᶜ.Nonempty) : + (N.cap A).Simple := by + apply (N.cap A).simple_of_cubic_stars (N.cap_loopless hN A) + (N.cap_star_card hN hc A hcut) (N.cap_threeConnected h3 A ho) + simp only [Fintype.card_option,Fintype.card_coe] + omega + +lemma cap_cubic (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) (h3 : N.ThreeEdgeConnected) + (A : Finset V) (hcut : (N.cut A).card = 3) (hA : 2 ≤ A.card) (ho : Aᶜ.Nonempty) : + (N.cap A).graph.IsRegularOfDegree 3 := by + intro v + rw [← (N.cap A).card_star (N.cap_simple hN hc h3 A hcut hA ho)] + exact N.cap_star_card hN hc A hcut v + +lemma threeCut_black_card (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hb : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (A : Finset V) (hA : (N.cut A).card = 3) : + (N.blackCut black A).card = 0 ∨ (N.blackCut black A).card = 3 := by + have h₁ := N.cubic_region_count hN hc A + have h₂ := N.cubic_black_region_count hN hc black hb A + have h₃ := Finset.card_le_card (Finset.filter_subset (fun e => N.blackEndpoint black e ∈ A) (N.cut A)) + change (N.blackCut black A).card ≤ (N.cut A).card at h₃ + omega + +def capBlack (black : V → Prop) (A : Finset V) : Option A → Prop + | none => (N.blackCut black A).card = 0 + | some v => black v.val + +lemma cap_coloring (hN : N.Simple) (hc : N.graph.IsRegularOfDegree 3) + (black : V → Prop) (hb : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) + (A : Finset V) (hA : (N.cut A).card = 3) : + ∀ e, N.capBlack black A ((N.cap A).tail e) ↔ ¬N.capBlack black A ((N.cap A).head e) := by + intro e + have hm := (N.mem_regionEdges A e.val).mp e.property + have hcol := hb e.val + have hboundary : e.val ∈ N.cut A → + ((N.blackCut black A).card = 0 ↔ N.blackEndpoint black e.val ∉ A) := by + intro he + rcases N.threeCut_black_card hN hc black hb A hA with hz|hf + · have hn : N.blackEndpoint black e.val ∉ A := by + intro hh + have hh' : e.val ∈ N.blackCut black A := Finset.mem_filter.mpr ⟨he,hh⟩ + rw [Finset.card_eq_zero.mp hz] at hh' + exact Finset.notMem_empty _ hh' + simp [hz,hn] + · have heq : N.blackCut black A = N.cut A := + Finset.eq_of_subset_of_card_le (Finset.filter_subset _ _) (by omega) + have hh := (Finset.mem_filter.mp (show e.val ∈ N.blackCut black A by rw [heq]; exact he)).2 + simp [hf,hh] + change N.capBlack black A (N.capMap A (N.tail e.val)) ↔ ¬N.capBlack black A (N.capMap A (N.head e.val)) + by_cases ht : N.tail e.val ∈ A <;> by_cases hh : N.head e.val ∈ A + · simpa only [capMap,dite_eq_left ht,dite_eq_left hh,capBlack] using hcol + · have he : e.val ∈ N.cut A := (N.mem_cut A e.val).mpr (Or.inl ⟨ht,hh⟩) + simp only [capMap,dite_eq_left ht,dite_eq_right hh,capBlack,hboundary he] + by_cases hb' : black (N.tail e.val) <;> simp [blackEndpoint,hb',ht,hh] + · have he : e.val ∈ N.cut A := (N.mem_cut A e.val).mpr (Or.inr ⟨hh,ht⟩) + simp only [capMap,dite_eq_right ht,dite_eq_left hh,capBlack,hboundary he] + by_cases hb' : black (N.tail e.val) <;> simp [blackEndpoint,hb',ht,hh] at hcol ⊢ <;> tauto + · exact (hm.elim ht hh).elim +end +end Barnette.Network +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E : Type*} [Fintype V] [Fintype E] (N : Network V E) + +omit [Fintype V] in +lemma boundary_range_restrict (s : Set E) : + (N.restrict (Subtype.val : s → E)).boundary.range = + Submodule.span ℝ (N.incidence.col '' s) := by + let : DecidableEq s := Classical.decEq _ + rw [boundary, Matrix.range_toLin'] + congr 1 + ext x + constructor + · rintro ⟨e, rfl⟩ + exact ⟨e.val, e.property, rfl⟩ + · rintro ⟨e, he, rfl⟩ + exact ⟨⟨e, he⟩, rfl⟩ + +omit [Fintype V] in + +lemma exists_independent_restriction (s : Set E) : + ∃ r ⊆ s, + Function.Injective (N.restrict (Subtype.val : r → E)).boundary ∧ + (N.restrict (Subtype.val : r → E)).boundary.range = + (N.restrict (Subtype.val : s → E)).boundary.range := by + obtain ⟨r, hrs, _, hspan, hi⟩ := exists_linearIndepOn_extension + (v := N.incidence.col) (linearIndepOn_empty ℝ _) (Set.empty_subset s) + refine ⟨r, hrs, ?_, ?_⟩ + · exact Matrix.mulVec_injective_iff.mpr hi + · rw [N.boundary_range_restrict, N.boundary_range_restrict] + apply le_antisymm + · exact Submodule.span_mono (Set.image_mono hrs) + · exact Submodule.span_le.mpr hspan + +variable {F : Type*} [Fintype F] (D : Network F E) + +lemma duality_of_first_exact (hN : N.graph.Connected) (hD : D.graph.Connected) + (he : N.boundary.ker = D.gradient.range) : N.Duality D := by + have ho : ∀ f, N.boundary (D.gradient f) = 0 := by + intro f + change D.gradient f ∈ N.boundary.ker + rw [he] + exact ⟨f, rfl⟩ + have h₁ := N.dim_cycles hN + rw [he] at h₁ + have h₂ := D.rank_gradient hD + exact N.duality_of_orth_card D hN hD (by omega) ho + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/Traces.lean b/lean/OAI/Combinatorics/Hamiltonian/Traces.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8a0cf66ea89c59ebdb066e483006d90014f11a3 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/Traces.lean @@ -0,0 +1,260 @@ +import OAI.Combinatorics.Hamiltonian.Gluing + +namespace OAI + +/-! Compact connected arc traces and uniform positive thickenings. -/ + +namespace Barnette.PlaneEmbedding + +noncomputable section + +variable {V : Type*} {G : SimpleGraph V} (E : PlaneEmbedding G) + +def curve (d : G.Dart) : Path (E.point d.fst) (E.point d.snd) := + E.arc d.fst d.snd d.adj + +@[simp] theorem curve_zero (d : G.Dart) : E.curve d 0 = E.point d.fst := + (E.curve d).source + +@[simp] theorem curve_one (d : G.Dart) : E.curve d 1 = E.point d.snd := + (E.curve d).target + +theorem curve_injective (d : G.Dart) : Function.Injective (E.curve d) := + E.arc_injective d.fst d.snd d.adj + +theorem curve_symm (d : G.Dart) (t : unitInterval) : + E.curve d.symm t = E.curve d (unitInterval.symm t) := by + change E.arc d.snd d.fst d.adj.symm t = _ + rw [E.arc_reverse] + rfl + +theorem curve_eq_point_iff (d : G.Dart) (t : unitInterval) (v : V) : + E.curve d t = E.point v ↔ (t = 0 ∧ v = d.fst) ∨ (t = 1 ∧ v = d.snd) := by + constructor + · exact E.arc_avoids_vertices d.fst d.snd d.adj t v + · rintro (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩) <;> simp + +theorem curve_eq_curve_interior {d e : G.Dart} {t s : unitInterval} + (ht₀ : t ≠ 0) (ht₁ : t ≠ 1) (hs₀ : s ≠ 0) (hs₁ : s ≠ 1) + (h : E.curve d t = E.curve e s) : d = e ∨ d = e.symm := by + rcases E.interiors_disjoint d.fst d.snd e.fst e.snd d.adj e.adj + t s ht₀ ht₁ hs₀ hs₁ h with h | h + · exact Or.inl (SimpleGraph.Dart.ext _ _ (Prod.ext h.1 h.2)) + · exact Or.inr (SimpleGraph.Dart.ext _ _ (Prod.ext h.1 h.2)) + +private def third : unitInterval := ⟨1 / 3, by norm_num⟩ +private def twoThirds : unitInterval := ⟨2 / 3, by norm_num⟩ + +def trace (d : G.Dart) (a b : unitInterval) : Set (ℝ × ℝ) := + (E.curve d) '' Set.Icc a b + +theorem trace_compact (d : G.Dart) (a b : unitInterval) : + IsCompact (E.trace d a b) := + isCompact_Icc.image (E.curve d).continuous + +theorem trace_preconnected (d : G.Dart) (a b : unitInterval) : + IsPreconnected (E.trace d a b) := + isPreconnected_Icc.image _ (E.curve d).continuous.continuousOn + +def branch (v : V) : Set (ℝ × ℝ) := + {E.point v} ∪ ⋃ d : {d : G.Dart // d.fst = v}, E.trace d.val 0 third + +def core (d : G.Dart) : Set (ℝ × ℝ) := E.trace d third twoThirds + +theorem branch_point (v : V) : E.point v ∈ E.branch v := + Or.inl rfl + +theorem branch_compact [Finite V] (v : V) : IsCompact (E.branch v) := by + classical + have : Finite G.Dart := Finite.of_injective SimpleGraph.Dart.toProd + SimpleGraph.Dart.toProd_injective + exact isCompact_singleton.union (isCompact_iUnion fun d => E.trace_compact d.val 0 third) + +theorem core_compact (d : G.Dart) : IsCompact (E.core d) := E.trace_compact _ _ _ + +theorem core_preconnected (d : G.Dart) : IsPreconnected (E.core d) := + E.trace_preconnected _ _ _ + +private theorem initial_meeting {d e : G.Dart} {t s : unitInterval} + (ht : (t : ℝ) ≤ 1 / 3) (hs : (s : ℝ) ≤ 1 / 3) + (h : E.curve d t = E.curve e s) : d.fst = e.fst := by + have ht₁ : t ≠ 1 := by intro heq; subst t; norm_num at ht + have hs₁ : s ≠ 1 := by intro heq; subst s; norm_num at hs + by_cases ht₀ : t = 0 + · subst t + rw [E.curve_zero] at h + rcases (E.curve_eq_point_iff e s d.fst).mp h.symm with h | h + · exact h.2 + · exact (hs₁ h.1).elim + by_cases hs₀ : s = 0 + · subst s + rw [E.curve_zero] at h + rcases (E.curve_eq_point_iff d t e.fst).mp h with h | h + · exact h.2.symm + · exact (ht₁ h.1).elim + rcases E.curve_eq_curve_interior ht₀ ht₁ hs₀ hs₁ h with heq | heq + · exact congrArg (fun d : G.Dart => d.fst) heq + · subst d + rw [E.curve_symm] at h + have hp := congrArg Subtype.val (E.curve_injective e h) + simp only [unitInterval.coe_symm_eq] at hp + linarith + +theorem branch_disjoint {v w : V} (hvw : v ≠ w) : + Disjoint (E.branch v) (E.branch w) := by + rw [Set.disjoint_left] + intro p hp hq + rcases hp with hp | hp <;> rcases hq with hq | hq + · exact hvw (E.point_injective (hp.symm.trans hq)) + · obtain ⟨⟨d, hd⟩, t, ht, heq⟩ := Set.mem_iUnion.mp hq + have ha : E.curve d t = E.point v := heq.trans hp + rcases (E.curve_eq_point_iff d t v).mp ha with ha | ha + · exact hvw (ha.2.trans hd) + · have : (1 : unitInterval) ≤ third := ha.1 ▸ ht.2 + change (1 : ℝ) ≤ 1 / 3 at this + norm_num at this + · obtain ⟨⟨d, hd⟩, t, ht, heq⟩ := Set.mem_iUnion.mp hp + have ha : E.curve d t = E.point w := heq.trans hq + rcases (E.curve_eq_point_iff d t w).mp ha with ha | ha + · exact hvw (hd.symm.trans ha.2.symm) + · have : (1 : unitInterval) ≤ third := ha.1 ▸ ht.2 + change (1 : ℝ) ≤ 1 / 3 at this + norm_num at this + · obtain ⟨⟨d, hd⟩, t, ht, heq⟩ := Set.mem_iUnion.mp hp + obtain ⟨⟨e, he⟩, s, hs, heq'⟩ := Set.mem_iUnion.mp hq + exact hvw (hd.symm.trans ((E.initial_meeting ht.2 hs.2 (heq.trans heq'.symm)).trans he)) + +private theorem middle_nonendpoint {t : unitInterval} (ht : t ∈ Set.Icc third twoThirds) : + t ≠ 0 ∧ t ≠ 1 := by + constructor + · intro h + have hh : (1 : ℝ) / 3 ≤ t := ht.1 + rw [h] at hh + norm_num at hh + · intro h + have hh : (t : ℝ) ≤ 2 / 3 := ht.2 + rw [h] at hh + norm_num at hh + +theorem core_avoids_vertices (d : G.Dart) (v : V) : E.point v ∉ E.core d := by + rintro ⟨t, ht, heq⟩ + have hn := middle_nonendpoint ht + rcases (E.curve_eq_point_iff d t v).mp heq with h | h + · exact hn.1 h.1 + · exact hn.2 h.1 + +theorem core_disjoint {d e : G.Dart} (hde : d.edge ≠ e.edge) : + Disjoint (E.core d) (E.core e) := by + rw [Set.disjoint_left] + rintro p ⟨t, ht, heq⟩ ⟨s, hs, heq'⟩ + obtain ⟨ht₀, ht₁⟩ := middle_nonendpoint ht + obtain ⟨hs₀, hs₁⟩ := middle_nonendpoint hs + rcases E.curve_eq_curve_interior ht₀ ht₁ hs₀ hs₁ (heq.trans heq'.symm) with h | h + · exact hde (congrArg SimpleGraph.Dart.edge h) + · exact hde ((congrArg SimpleGraph.Dart.edge h).trans e.edge_symm) + +theorem branch_core_disjoint {v : V} {e : G.Dart} + (hv₁ : v ≠ e.fst) (hv₂ : v ≠ e.snd) : Disjoint (E.branch v) (E.core e) := by + rw [Set.disjoint_left] + intro p hp hq + rcases hp with hp | hp + · exact E.core_avoids_vertices e v (hp ▸ hq) + obtain ⟨⟨d, hd⟩, t, ht, heq⟩ := Set.mem_iUnion.mp hp + obtain ⟨s, hs, heq'⟩ := hq + have h : E.curve d t = E.curve e s := heq.trans heq'.symm + obtain ⟨hs₀, hs₁⟩ := middle_nonendpoint hs + have ht₁ : t ≠ 1 := by + intro heq + have hh : (t : ℝ) ≤ 1 / 3 := ht.2 + rw [heq] at hh + norm_num at hh + by_cases ht₀ : t = 0 + · subst t + rw [E.curve_zero] at h + rcases (E.curve_eq_point_iff e s d.fst).mp h.symm with h | h + · exact hs₀ h.1 + · exact hs₁ h.1 + rcases E.curve_eq_curve_interior ht₀ ht₁ hs₀ hs₁ h with h | h + · exact hv₁ (hd.symm.trans (congrArg (fun d : G.Dart => d.fst) h)) + · exact hv₂ (hd.symm.trans (congrArg (fun d : G.Dart => d.fst) h)) + +theorem branch_preconnected (v : V) : IsPreconnected (E.branch v) := by + apply isPreconnected_of_forall (E.point v) + intro y hy + rcases hy with hy | hy + · exact ⟨{E.point v}, Set.subset_union_left, rfl, hy, isPreconnected_singleton⟩ + · obtain ⟨d, hd⟩ := Set.mem_iUnion.mp hy + refine ⟨E.trace d.val 0 third, ?_, ?_, hd, E.trace_preconnected _ _ _⟩ + · exact fun x hx => Or.inr (Set.mem_iUnion.mpr ⟨d, hx⟩) + · refine ⟨0, ⟨le_rfl, ?_⟩, ?_⟩ + · change (0 : ℝ) ≤ 1 / 3 + norm_num + · simpa only [E.curve_zero] using congrArg E.point d.property + +theorem branch_connected (v : V) : IsConnected (E.branch v) := + ⟨⟨_, E.branch_point v⟩, E.branch_preconnected v⟩ + +private theorem third_le_twoThirds : third ≤ twoThirds := by + change (1 : ℝ) / 3 ≤ 2 / 3 + norm_num + +private theorem symm_third : unitInterval.symm third = twoThirds := by + apply Subtype.ext + change 1 - (1 : ℝ) / 3 = 2 / 3 + norm_num + +theorem core_connected (d : G.Dart) : IsConnected (E.core d) := + ⟨⟨E.curve d third, third, ⟨le_rfl, third_le_twoThirds⟩, rfl⟩, + E.core_preconnected d⟩ + +theorem branch_core_meets (d : G.Dart) : + (E.branch d.fst ∩ E.core d).Nonempty ∧ (E.branch d.snd ∩ E.core d).Nonempty := by + constructor + · refine ⟨E.curve d third, ?_, third, ⟨le_rfl, third_le_twoThirds⟩, rfl⟩ + refine Or.inr (Set.mem_iUnion.mpr ⟨⟨d, rfl⟩, third, ⟨?_, le_rfl⟩, rfl⟩) + change (0 : ℝ) ≤ 1 / 3 + norm_num + · refine ⟨E.curve d twoThirds, ?_, twoThirds, ⟨third_le_twoThirds, le_rfl⟩, rfl⟩ + refine Or.inr (Set.mem_iUnion.mpr ⟨⟨d.symm, rfl⟩, third, ⟨?_, le_rfl⟩, ?_⟩) + · change (0 : ℝ) ≤ 1 / 3 + norm_num + · rw [E.curve_symm, symm_third] + +theorem finite_positive_radius {ι : Type*} [Finite ι] (r : ι → ℝ) + (hr : ∀ i, 0 < r i) : ∃ δ : ℝ, 0 < δ ∧ ∀ i, δ ≤ r i := by + classical + let _ := Fintype.ofFinite ι + have aux (s : Finset ι) : ∃ δ : ℝ, 0 < δ ∧ ∀ i ∈ s, δ ≤ r i := by + induction s using Finset.induction_on with + | empty => exact ⟨1, zero_lt_one, by simp⟩ + | @insert a s ha ih => + obtain ⟨δ, hδ, h⟩ := ih + refine ⟨min δ (r a), lt_min hδ (hr a), ?_⟩ + intro i hi + rcases Finset.mem_insert.mp hi with rfl | hi + · exact min_le_right _ _ + · exact (min_le_left _ _).trans (h i hi) + obtain ⟨δ, hδ, h⟩ := aux Finset.univ + exact ⟨δ, hδ, fun i => h i (Finset.mem_univ i)⟩ + +theorem uniform_thickening {ι : Type*} [Finite ι] (K : ι → Set (ℝ × ℝ)) + (hK : ∀ i, IsCompact (K i)) (R : ι → ι → Prop) + (hR : ∀ i j, R i j → Disjoint (K i) (K j)) : + ∃ δ : ℝ, 0 < δ ∧ ∀ i j, R i j → + Disjoint (Metric.thickening δ (K i)) (Metric.thickening δ (K j)) := by + classical + let I := {p : ι × ι // R p.1 p.2} + have hex (p : I) : ∃ δ : ℝ, 0 < δ ∧ + Disjoint (Metric.thickening δ (K p.val.1)) (Metric.thickening δ (K p.val.2)) := + (hR _ _ p.property).exists_thickenings (hK _) (hK _).isClosed + choose r hr hd using hex + obtain ⟨δ, hδ, hle⟩ := finite_positive_radius r hr + refine ⟨δ, hδ, ?_⟩ + intro i j hij + let p : I := ⟨(i, j), hij⟩ + exact (hd p).mono (Metric.thickening_mono (hle p) _) (Metric.thickening_mono (hle p) _) + +end +end Barnette.PlaneEmbedding + +end OAI diff --git a/lean/OAI/Combinatorics/Hamiltonian/TriangleSystem.lean b/lean/OAI/Combinatorics/Hamiltonian/TriangleSystem.lean new file mode 100644 index 0000000000000000000000000000000000000000..eea928c0019bd2e4b6faf3ab56a9acb39b992bc6 --- /dev/null +++ b/lean/OAI/Combinatorics/Hamiltonian/TriangleSystem.lean @@ -0,0 +1,319 @@ +import OAI.Combinatorics.Hamiltonian.Circulation + +namespace OAI + +/-! Triangle incidence states, opposite graphs, and oriented potentials. -/ + +namespace Barnette + +structure TriangleSystem (A V : Type*) where + vertex : A → Fin 3 → V + vertex_injective : ∀ t, Function.Injective (vertex t) + edge_unique : ∀ t u i j k l, i ≠ j → k ≠ l → + vertex t i = vertex u k → vertex t j = vertex u l → t = u + +namespace TriangleSystem + +variable {A V : Type*} (T : TriangleSystem A V) + +def State (X : Set V) := + {c : A → Fin 3 // Function.Injective (fun t => T.vertex t (c t)) ∧ + Set.range (fun t => T.vertex t (c t)) = X} + +namespace State + +variable {T} {X : Set V} + +def value (s : T.State X) (t : A) : V := T.vertex t (s.val t) + +theorem value_injective (s : T.State X) : Function.Injective s.value := s.property.1 + +theorem value_range (s : T.State X) : Set.range s.value = X := s.property.2 + +theorem value_mem (s : T.State X) (t : A) : s.value t ∈ X := by + exact (Set.ext_iff.mp s.value_range _).mp ⟨t, rfl⟩ + +noncomputable def toEquiv (s : T.State X) : A ≃ X := + Equiv.ofBijective (fun t => ⟨s.value t, s.value_mem t⟩) ⟨by + intro t u h + exact s.value_injective (congrArg Subtype.val h), by + intro v + obtain ⟨t, ht⟩ := (Set.ext_iff.mp s.value_range v.val).mpr v.property + exact ⟨t, Subtype.ext ht⟩⟩ + +@[simp] theorem coe_toEquiv (s : T.State X) (t : A) : (s.toEquiv t : V) = s.value t := rfl + +theorem value_eq_iff (r s : T.State X) (t : A) : + r.value t = s.value t ↔ r.val t = s.val t := T.vertex_injective t |>.eq_iff + +@[ext] theorem ext {r s : T.State X} (h : ∀ t, r.value t = s.value t) : r = s := by + apply Subtype.ext + funext t + exact (value_eq_iff r s t).mp (h t) + +instance [Finite A] : Finite (T.State X) := inferInstanceAs (Finite (Subtype _)) + +noncomputable instance [Fintype A] : Fintype (T.State X) := Fintype.ofFinite _ + +end State + +theorem state_nonempty_iff (X : Set V) : + Nonempty (T.State X) ↔ ∃ r : A ≃ X, ∀ t, (r t : V) ∈ Set.range (T.vertex t) := by + classical + constructor + · rintro ⟨s⟩ + exact ⟨s.toEquiv, fun t => ⟨s.val t, rfl⟩⟩ + · rintro ⟨r, hr⟩ + choose c hc using hr + refine ⟨⟨c, ?_, ?_⟩⟩ + · intro t u h + apply r.injective + exact Subtype.ext (by simpa only [hc] using h) + · ext v + constructor + · rintro ⟨t, rfl⟩ + change T.vertex t (c t) ∈ X + rw [hc t] + exact (r t).property + · intro hv + obtain ⟨t, ht⟩ := r.surjective ⟨v, hv⟩ + exact ⟨t, (hc t).trans (congrArg Subtype.val ht)⟩ + +def Partner {X : Set V} (r s : T.State X) : Prop := ∀ t, r.value t ≠ s.value t + +def thirdIndex (i j : Fin 3) : Fin 3 := -(i + j) + +theorem thirdIndex_distinct : ∀ i j : Fin 3, i ≠ j → + thirdIndex i j ≠ i ∧ thirdIndex i j ≠ j := by decide + +theorem thirdIndex_involution : ∀ i j : Fin 3, thirdIndex (thirdIndex i j) j = i := by + decide + +theorem other_corners : ∀ i j r s : Fin 3, + i ≠ j → i ≠ s → j ≠ s → r ≠ s → + (i = r ∧ j = thirdIndex r s) ∨ (j = r ∧ i = thirdIndex r s) := by decide + +def indexDelta (i j : Fin 3) : ℤ := if i = j then 0 else if j = i + 1 then 1 else -1 + +theorem indexDelta_antisymm : ∀ i j : Fin 3, indexDelta i j = -indexDelta j i := by + decide + +theorem indexDelta_third : ∀ i j : Fin 3, i ≠ j → + indexDelta (thirdIndex i j) j - indexDelta i j = + 2 * indexDelta i (thirdIndex i j) := by decide + +def oppositeGraph {X : Set V} (s : T.State X) : SimpleGraph V where + Adj v w := v ≠ w ∧ ∃ t i j, T.vertex t i = v ∧ T.vertex t j = w ∧ + i ≠ s.val t ∧ j ≠ s.val t + symm := ⟨by + rintro v w ⟨hvw, t, i, j, hi, hj, his, hjs⟩ + exact ⟨hvw.symm, t, j, i, hj, hi, hjs, his⟩⟩ + loopless := ⟨by intro v h; exact h.1 rfl⟩ + +theorem oppositeGraph_adj_iff {X : Set V} {r s : T.State X} (hrs : T.Partner r s) + (v w : V) : (T.oppositeGraph s).Adj v w ↔ + ∃ t, (v = r.value t ∧ w = T.vertex t (thirdIndex (r.val t) (s.val t))) ∨ + (w = r.value t ∧ v = T.vertex t (thirdIndex (r.val t) (s.val t))) := by + constructor + · rintro ⟨hvw, t, i, j, hi, hj, his, hjs⟩ + have hij : i ≠ j := fun h => hvw (hi.symm.trans (h ▸ hj)) + have hrs' : r.val t ≠ s.val t := fun h => hrs t ((State.value_eq_iff r s t).mpr h) + refine ⟨t, ?_⟩ + rcases other_corners i j (r.val t) (s.val t) hij his hjs hrs' with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ + · exact Or.inl ⟨hi.symm, hj.symm⟩ + · exact Or.inr ⟨hj.symm, hi.symm⟩ + · rintro ⟨t, h | h⟩ + all_goals + have hrs' : r.val t ≠ s.val t := fun h => hrs t ((State.value_eq_iff r s t).mpr h) + have hne := thirdIndex_distinct (r.val t) (s.val t) hrs' + · rcases h with ⟨rfl, rfl⟩ + exact ⟨fun heq => hne.1 (T.vertex_injective t heq.symm), + t, r.val t, thirdIndex (r.val t) (s.val t), rfl, rfl, hrs', hne.2⟩ + · rcases h with ⟨rfl, rfl⟩ + exact ⟨fun heq => hne.1 (T.vertex_injective t heq), + t, thirdIndex (r.val t) (s.val t), r.val t, rfl, rfl, hne.2, hrs'⟩ + +end TriangleSystem +end Barnette +namespace Barnette.Network +noncomputable section +open scoped Classical +variable {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + (N : Network V E) (D : Network F E) + +omit [Fintype V] [Fintype F] in +lemma Triangle.oriented_cycleFlow (sN : N.Simple) (sD : D.Simple) + (v : V) (t : D.Triangle (N.star v)) + (ht : ∀ i, N.gradient (fun w => if w = v then 1 else 0) (t.edge i) = + D.arcSign (t.edge i) (t.corner i)) : + D.cycleFlow (t.coordinates D) = N.gradient (fun w => if w = v then 1 else 0) := by + ext e + by_cases he : e ∈ N.star v + · have hh : e ∈ Finset.univ.image t.edge := t.edge_range.symm ▸ he + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hh + have hflow := D.cycleFlow_apply_edge (t.coordinates D) i + change D.cycleFlow (t.coordinates D) (D.cycleEdge (t.coordinates D) i) = + D.arcSign (D.cycleEdge (t.coordinates D) i) (t.corner i) at hflow + rw [t.coordinates_edge D sD i] at hflow + exact hflow.trans (ht i).symm + · have heC : e ∉ D.cycleEdges (t.coordinates D) := by + rw [t.coordinates_edges D sD]; exact he + rw [D.cycleFlow_zero_outside _ heC] + have hy : e ∉ D.flowSupport (N.gradient (fun w => if w = v then 1 else 0)) := by + rw [N.gradient_indicator_support D sN v]; exact he + have hz : N.gradient (fun w => if w = v then 1 else 0) e = 0 := by + simpa only [mem_flowSupport,not_not] using hy + exact hz.symm + +omit [Fintype V] [Fintype F] in +lemma cycle_integral (C : Barnette.CycleCoordinates D.graph) (α : E → ℝ) : + ∑ e, α e * D.cycleFlow C e = + ∑ i, α (D.cycleEdge C i) * D.arcSign (D.cycleEdge C i) (C.vertex i) := by + simp only [cycleFlow,Finset.sum_apply,Pi.smul_apply,smul_eq_mul,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + simp [basisVec,mul_ite] + +omit [Fintype F] in +lemma Triangle.oriented_integral (sN : N.Simple) (sD : D.Simple) + (v : V) (t : D.Triangle (N.star v)) + (ht : ∀ i, N.gradient (fun w => if w = v then 1 else 0) (t.edge i) = + D.arcSign (t.edge i) (t.corner i)) (α : E → ℝ) : + ∑ i, α (t.edge i) * D.arcSign (t.edge i) (t.corner i) = N.boundary α v := by + have hh := D.cycle_integral (t.coordinates D) α + rw [t.oriented_cycleFlow N D sN sD v ht] at hh + have hb := N.boundary_adjoint α (fun w => if w = v then 1 else 0) + simp only [mul_ite,mul_one,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] at hb + rw [← hb] at hh + have hf : D.cycleEdge (t.coordinates D) = t.edge := funext (t.coordinates_edge D sD) + rw [hf] at hh + exact hh.symm + +omit [Fintype V] [Fintype E] [Fintype F] in +def Triangle.potential {s : Finset E} (t : D.Triangle s) (α : E → ℝ) : Fin 3 → ℝ := + ![0, α (t.edge 0) * D.arcSign (t.edge 0) (t.corner 0), + α (t.edge 0) * D.arcSign (t.edge 0) (t.corner 0) + + α (t.edge 1) * D.arcSign (t.edge 1) (t.corner 1)] + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma Triangle.potential_step {s : Finset E} (t : D.Triangle s) (α : E → ℝ) + (hα : ∑ i, α (t.edge i) * D.arcSign (t.edge i) (t.corner i) = 0) (i : Fin 3) : + t.potential D α (i+1) - t.potential D α i = + α (t.edge i) * D.arcSign (t.edge i) (t.corner i) := by + have hs : α (t.edge 0) * D.arcSign (t.edge 0) (t.corner 0) + + α (t.edge 1) * D.arcSign (t.edge 1) (t.corner 1) + + α (t.edge 2) * D.arcSign (t.edge 2) (t.corner 2) = 0 := by + simpa [Fin.sum_univ_succ,add_assoc] using hα + fin_cases i + · change t.potential D α 1 - t.potential D α 0 = + α (t.edge 0) * D.arcSign (t.edge 0) (t.corner 0) + simp [potential] + · change t.potential D α 2 - t.potential D α 1 = + α (t.edge 1) * D.arcSign (t.edge 1) (t.corner 1) + simp [potential] + · change t.potential D α 0 - t.potential D α 2 = + α (t.edge 2) * D.arcSign (t.edge 2) (t.corner 2) + simp [potential] + linarith + +omit [Fintype V] [Fintype E] [Fintype F] in +def Triangle.side {s : Finset E} (t : D.Triangle s) (i j : Fin 3) : E := + if j = i+1 then t.edge i else t.edge j + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma Triangle.side_mem {s : Finset E} (t : D.Triangle s) (i j : Fin 3) : + t.side D i j ∈ s := by + have hh (k : Fin 3) : t.edge k ∈ s := by + have hm : t.edge k ∈ Finset.univ.image t.edge := Finset.mem_image.mpr ⟨k,Finset.mem_univ _,rfl⟩ + rwa [t.edge_range] at hm + unfold side + split_ifs <;> apply hh + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma Triangle.side_ends {s : Finset E} (t : D.Triangle s) {i j : Fin 3} (hij : i ≠ j) : + s(D.tail (t.side D i j),D.head (t.side D i j)) = s(t.corner i,t.corner j) := by + have hfin : ∀ i j : Fin 3, i ≠ j → j = i+1 ∨ i = j+1 := by decide + rcases hfin i j hij with hj | hi + · simp only [side,ite_eq_left hj] + exact (t.edge_ends i).trans (by rw [hj]) + · have hj : j ≠ i+1 := by + intro hh + exact (by decide : ∀ i j : Fin 3, i = j+1 → j = i+1 → False) i j hi hh + simp only [side,ite_eq_right hj] + exact (t.edge_ends j).trans (by rw [hi,Sym2.eq_swap]) + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma Triangle.side_unique (sD : D.Simple) {s : Finset E} (t : D.Triangle s) + {i j : Fin 3} (hij : i ≠ j) {e : E} + (he : s(D.tail e,D.head e) = s(t.corner i,t.corner j)) : e = t.side D i j := + sD.pair_injective (he.trans (t.side_ends D hij).symm) + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma Triangle.potential_side {s : Finset E} (t : D.Triangle s) (α : E → ℝ) + (hα : ∑ i, α (t.edge i) * D.arcSign (t.edge i) (t.corner i) = 0) + {i j : Fin 3} (hij : i ≠ j) : + t.potential D α j - t.potential D α i = + α (t.side D i j) * D.arcSign (t.side D i j) (t.corner i) := by + have hfin : ∀ i j : Fin 3, i ≠ j → j = i+1 ∨ i = j+1 := by decide + rcases hfin i j hij with hj | hi + · simp only [side,ite_eq_left hj] + rw [hj] + exact t.potential_step D α hα i + · have hj : j ≠ i+1 := by + intro hh + exact (by decide : ∀ i j : Fin 3, i = j+1 → j = i+1 → False) i j hi hh + simp only [side,ite_eq_right hj] + have hne : t.corner j ≠ t.corner i := fun h => hij (t.corner_injective h).symm + have he : s(D.tail (t.edge j),D.head (t.edge j)) = s(t.corner j,t.corner i) := by + rw [t.edge_ends,hi] + rw [D.arcSign_opposite hne he] + have hs := t.potential_step D α hα j + rw [← hi] at hs + linarith + +omit [Fintype V] [Fintype E] [Fintype F] in +lemma blackGradient_face (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) {v : V} + (hv : black v) {e : E} (he : N.Incident e v) : + N.gradient (fun w => if black w then 1 else 0) e = + N.gradient (fun w => if w = v then 1 else 0) e := by + have hcol := hc e + rcases he with ht | hh + · have hhead : ¬black (N.head e) := (hc e).mp (ht ▸ hv) + have hne : N.head e ≠ v := fun hh => hhead (hh ▸ hv) + simp [gradient_apply,ht,hhead,hne,hv] + · have htail : ¬black (N.tail e) := fun ht => (hc e).mp ht (hh ▸ hv) + have hne : N.tail e ≠ v := fun ht => htail (ht ▸ hv) + simp [gradient_apply,hh,htail,hne,hv] + +omit [Fintype V] [Fintype F] in +lemma Triangle.index_delta (v : V) (t : D.Triangle (N.star v)) + (ht : ∀ i, N.gradient (fun w => if w = v then 1 else 0) (t.edge i) = + D.arcSign (t.edge i) (t.corner i)) (black : V → Prop) + (hc : ∀ e, black (N.tail e) ↔ ¬black (N.head e)) (hv : black v) + {i j : Fin 3} (hij : i ≠ j) : + (Barnette.TriangleSystem.indexDelta i j : ℝ) = + N.gradient (fun w => if black w then 1 else 0) (t.side D i j) * + D.arcSign (t.side D i j) (t.corner i) := by + rw [N.blackGradient_face black hc hv ((N.mem_star _ _).mp (t.side_mem D i j))] + have hfin : ∀ i j : Fin 3, i ≠ j → j = i+1 ∨ i = j+1 := by decide + rcases hfin i j hij with hj | hi + · simp only [TriangleSystem.indexDelta,ite_eq_right hij,Int.cast_one,side,ite_eq_left hj,ht] + unfold arcSign + split_ifs <;> norm_num + · have hj : j ≠ i+1 := by + intro hh + exact (by decide : ∀ i j : Fin 3, i = j+1 → j = i+1 → False) i j hi hh + simp only [TriangleSystem.indexDelta,ite_eq_right hij,ite_eq_right hj,Int.cast_neg,Int.cast_one,side,ht] + have hne : t.corner j ≠ t.corner i := fun h => hij (t.corner_injective h).symm + have he : s(D.tail (t.edge j),D.head (t.edge j)) = s(t.corner j,t.corner i) := by + rw [t.edge_ends,hi] + rw [D.arcSign_opposite hne he] + unfold arcSign + split_ifs <;> norm_num + +end +end Barnette.Network + +end OAI diff --git a/lean/OAI/Combinatorics/Honeycomb/FiniteCylinder.lean b/lean/OAI/Combinatorics/Honeycomb/FiniteCylinder.lean new file mode 100644 index 0000000000000000000000000000000000000000..b956cc002f94ec7686b1cf4bc1360aef6f0ab4c7 --- /dev/null +++ b/lean/OAI/Combinatorics/Honeycomb/FiniteCylinder.lean @@ -0,0 +1,643 @@ +import Mathlib + +namespace OAI + +/-! Finite hard-core cylinder partitions and planar polygon bounds. -/ + +open scoped BigOperators Topology + +open Polynomial Classical + +noncomputable section + +namespace HoneycombCylinder +namespace FiniteHardCore + +variable {α : Type*} [DecidableEq α] + +abbrev Independent (I : α → α → Prop) (s : Finset α) : Prop := + (s : Set α).Pairwise (fun a b => ¬ I a b) + +def partition (I : α → α → Prop) (w : α → ℝ) (U : Finset α) : ℝ[X] := by + classical + exact ∑ s ∈ U.powerset, + if Independent I s then Polynomial.monomial s.card (∏ a ∈ s, w a) else 0 + +def neighbors (I : α → α → Prop) (U : Finset α) (a : α) : Finset α := by + classical + exact U.filter (fun b => ¬ I a b) + +lemma independent_insert {I : α → α → Prop} (hI : ∀ ⦃a b⦄, I a b → I b a) + {U : Finset α} {a : α} (ha : a ∉ U) : + Independent I (insert a U) ↔ Independent I U ∧ ∀ b ∈ U, ¬ I a b := by + classical + unfold Independent + rw [Finset.coe_insert, Set.pairwise_insert] + constructor + · rintro ⟨h, h₁⟩ + exact ⟨h, fun b hb => (h₁ b hb (by rintro rfl; exact ha hb)).1⟩ + · rintro ⟨h, hU⟩ + exact ⟨h, fun b hb _ => ⟨hU b hb, fun hba => hU b hb (hI hba)⟩⟩ + +lemma partition_insert {I : α → α → Prop} (hI : ∀ ⦃a b⦄, I a b → I b a) + (w : α → ℝ) {U : Finset α} {a : α} (ha : a ∉ U) : + partition I w (insert a U) = partition I w U + + Polynomial.monomial 1 (w a) * partition I w (neighbors I U a) := by + classical + rw [partition, Finset.sum_powerset_insert ha] + congr 1 + rw [partition, Finset.mul_sum] + have hsub : (neighbors I U a).powerset ⊆ U.powerset := by + intro s hs + exact Finset.mem_powerset.mpr ((Finset.mem_powerset.mp hs).trans (Finset.filter_subset _ _)) + have has (s : Finset α) (hs : s ∈ U.powerset) : a ∉ s := + fun h => ha (Finset.mem_powerset.mp hs h) + have hn (s : Finset α) (hs : s ∈ U.powerset) : + s ∈ (neighbors I U a).powerset ↔ ∀ b ∈ s, ¬ I a b := by + simp only [Finset.mem_powerset, neighbors, Finset.subset_iff, Finset.mem_filter] + exact ⟨fun h b hb => (h hb).2, fun h b hb => ⟨Finset.mem_powerset.mp hs hb, h b hb⟩⟩ + calc + _ = ∑ s ∈ (neighbors I U a).powerset, + if Independent I (insert a s) then + Polynomial.monomial (insert a s).card (∏ b ∈ insert a s, w b) else 0 := by + symm + apply Finset.sum_subset hsub + intro s hs hsn + have hc : ¬ ∀ b ∈ s, ¬ I a b := fun h => hsn ((hn s hs).mpr h) + simp [independent_insert hI (has s hs), hc] + _ = _ := by + apply Finset.sum_congr rfl + intro s hs + have hc := (hn s (hsub hs)).mp hs + by_cases hi : Independent I s + · rw [ite_eq_left ((independent_insert hI (has s (hsub hs))).mpr ⟨hi, hc⟩), + ite_eq_left hi] + rw [Finset.card_insert_of_notMem (has s (hsub hs)), + Finset.prod_insert (has s (hsub hs)), Polynomial.monomial_mul_monomial] + simp only [Nat.add_comm] + + · simp [independent_insert hI (has s (hsub hs)), hi] + +@[simp] lemma partition_empty (I : α → α → Prop) (w : α → ℝ) : + partition I w ∅ = 1 := by + simp [partition, Independent] + +lemma coeff_zero (I : α → α → Prop) (w : α → ℝ) (U : Finset α) : + (partition I w U).coeff 0 = 1 := by + classical + simp only [partition, Polynomial.finsetSum_coeff] + rw [Finset.sum_eq_single (∅ : Finset α)] + · simp [Independent] + · intro s hs hns + by_cases hi : Independent I s + · simp [hi, Polynomial.coeff_monomial, Finset.card_ne_zero.mpr (Finset.nonempty_iff_ne_empty.mpr hns)] + · simp [hi] + · simp + +lemma coeff_one (I : α → α → Prop) (hI : ∀ ⦃a b⦄, I a b → I b a) + (w : α → ℝ) (U : Finset α) : + (partition I w U).coeff 1 = ∑ a ∈ U, w a := by + classical + induction U using Finset.induction_on with + | empty => simp [Polynomial.coeff_one] + | @insert a U ha ih => + rw [partition_insert hI w ha, Polynomial.coeff_add] + rw [Polynomial.coeff_monomial_mul _ 1 0, coeff_zero, mul_one] + rw [Finset.sum_insert ha, ih, add_comm] + +def compatiblePairs (I : α → α → Prop) (w : α → ℝ) (U : Finset α) : ℝ := by + classical + exact ∑ a ∈ U, ∑ b ∈ U, if a ≠ b ∧ ¬ I a b then w a * w b else 0 + +lemma compatiblePairs_insert (I : α → α → Prop) + (hI : ∀ ⦃a b⦄, I a b → I b a) + (w : α → ℝ) {U : Finset α} {a : α} (ha : a ∉ U) : + compatiblePairs I w (insert a U) = compatiblePairs I w U + + 2 * w a * ∑ b ∈ neighbors I U a, w b := by + classical + have hsymm (b : α) : I b a ↔ I a b := ⟨fun h => hI h, fun h => hI h⟩ + have hne {b} (hb : b ∈ U) : a ≠ b := fun h => ha (h ▸ hb) + unfold compatiblePairs + rw [Finset.sum_insert ha] + simp only [Finset.sum_insert ha, ne_eq, not_true_eq_false, false_and, ↓reduceIte, zero_add] + rw [Finset.sum_add_distrib] + have h₁ : (∑ b ∈ U, if a ≠ b ∧ ¬ I a b then w a * w b else 0) = + w a * ∑ b ∈ neighbors I U a, w b := by + rw [neighbors, Finset.sum_filter, Finset.mul_sum] + apply Finset.sum_congr rfl + intro b hb + simp [hne hb, mul_ite] + have h₂ : (∑ b ∈ U, if b ≠ a ∧ ¬ I b a then w b * w a else 0) = + w a * ∑ b ∈ neighbors I U a, w b := by + rw [← h₁] + apply Finset.sum_congr rfl + intro b hb + simp [hne hb, (hne hb).symm, hsymm, mul_comm] + rw [h₁, h₂] + ring + +lemma twice_coeff_two (I : α → α → Prop) + (hI : ∀ ⦃a b⦄, I a b → I b a) (w : α → ℝ) (U : Finset α) : + 2 * (partition I w U).coeff 2 = compatiblePairs I w U := by + classical + induction U using Finset.induction_on with + | empty => simp [compatiblePairs, Polynomial.coeff_one] + | @insert a U ha ih => + rw [partition_insert hI w ha, Polynomial.coeff_add, + Polynomial.coeff_monomial_mul _ 1 1] + rw [coeff_one I hI, compatiblePairs_insert I hI w ha, ← ih] + ring + +def incompatiblePairs (I : α → α → Prop) (w : α → ℝ) (U : Finset α) : ℝ := by + classical + exact ∑ a ∈ U, ∑ b ∈ U, if I a b then w a * w b else 0 + +lemma pair_decomposition (I : α → α → Prop) (hdiag : ∀ a, I a a) + (w : α → ℝ) (U : Finset α) : + (∑ a ∈ U, w a)^2 - compatiblePairs I w U = incompatiblePairs I w U := by + classical + rw [pow_two, Finset.sum_mul_sum] + unfold compatiblePairs incompatiblePairs + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro a ha + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro b hb + by_cases hi : I a b + · simp [hi] + · have hab : a ≠ b := fun h => hi (h ▸ hdiag a) + simp [hi, hab] + +lemma negative_log_second_derivative (P : ℝ[X]) (hP : P.coeff 0 = 1) : + -(deriv (deriv (fun g : ℝ => Real.log (P.eval g))) 0) = + P.coeff 1 ^ 2 - 2 * P.coeff 2 := by + have hp : P.eval 0 ≠ 0 := by rw [← Polynomial.coeff_zero_eq_eval_zero, hP]; norm_num + have heq : deriv (fun g : ℝ => Real.log (P.eval g)) =ᶠ[𝓝 (0 : ℝ)] + (fun g => P.derivative.eval g / P.eval g) := by + filter_upwards [P.continuous.continuousAt.eventually_ne hp] with g hg + exact ((P.hasDerivAt g).log hg).deriv + rw [heq.deriv_eq] + have hd := ((P.derivative.hasDerivAt 0).div (P.hasDerivAt 0) hp).deriv + change deriv (fun g => P.derivative.eval g / P.eval g) 0 = _ at hd + rw [hd] + simp only [← Polynomial.coeff_zero_eq_eval_zero, Polynomial.coeff_derivative, hP] + norm_num + ring + +theorem log_second_derivative_eq_incompatiblePairs (I : α → α → Prop) + (hI : ∀ ⦃a b⦄, I a b → I b a) (hdiag : ∀ a, I a a) + (w : α → ℝ) (U : Finset α) : + -(deriv (deriv (fun g : ℝ => Real.log ((partition I w U).eval g))) 0) = + incompatiblePairs I w U := by + rw [negative_log_second_derivative _ (coeff_zero I w U), coeff_one I hI, + twice_coeff_two I hI] + exact pair_decomposition I hdiag w U + +lemma eval_partition (I : α → α → Prop) (w : α → ℝ) (U : Finset α) (g : ℝ) : + (partition I w U).eval g = + ∑ s ∈ U.powerset, if Independent I s then ∏ a ∈ s, g * w a else 0 := by + classical + rw [partition, Polynomial.eval_finsetSum] + apply Finset.sum_congr rfl + intro s hs + by_cases hi : Independent I s + · simp only [hi, ↓reduceIte, Polynomial.eval_monomial, Finset.prod_mul_distrib, + Finset.prod_const] + ring + · simp [hi] + +end FiniteHardCore +end HoneycombCylinder + + +open Classical +open scoped BigOperators Topology + +namespace HoneycombCylinder +namespace Lattice + +abbrev Face (H : Type*) := H × ℤ +abbrev Vertex (H : Type*) := Face H × Bool +abbrev Bond (H : Type*) := Face H × Fin 3 + +variable {H : Type*} [AddGroupWithOne H] + +def bondSource (e : Bond H) : Vertex H := (e.1, true) + +def bondTarget (e : Bond H) : Vertex H := + if e.2 = 0 then (e.1, false) + else if e.2 = 1 then ((e.1.1, e.1.2 - 1), false) + else ((e.1.1 - 1, e.1.2), false) + +def dualEnds (e : Bond H) : Face H × Face H := + if e.2 = 0 then ((e.1.1 + 1, e.1.2), (e.1.1, e.1.2 + 1)) + else if e.2 = 1 then (e.1, (e.1.1 + 1, e.1.2)) + else (e.1, (e.1.1, e.1.2 + 1)) + +def vertices (E : Finset (Bond H)) : Finset (Vertex H) := + E.image bondSource ∪ E.image bondTarget + +def Incident (v : Vertex H) (e : Bond H) : Prop := + v = bondSource e ∨ v = bondTarget e + +def AdjWithin (E : Finset (Bond H)) (u v : Vertex H) : Prop := + ∃ e ∈ E, (u = bondSource e ∧ v = bondTarget e) ∨ + (v = bondSource e ∧ u = bondTarget e) + +def IsCycle (E : Finset (Bond H)) : Prop := + E.Nonempty ∧ + (∀ v ∈ vertices E, (E.filter (Incident v)).card = 2) ∧ + (∀ u ∈ vertices E, ∀ v ∈ vertices E, + Relation.ReflTransGen (AdjWithin E) u v) + +abbrev Polygon (H : Type*) [AddGroupWithOne H] := + {E : Finset (Bond H) // IsCycle E} + +namespace Polygon + +def vertices (p : Polygon H) : Finset (Vertex H) := Lattice.vertices p.val + +def length (p : Polygon H) : ℕ := p.val.card + +def Incompatible (p q : Polygon H) : Prop := + ∃ v, v ∈ p.vertices ∧ v ∈ q.vertices + +lemma vertices_nonempty (p : Polygon H) : p.vertices.Nonempty := by + obtain ⟨e, he⟩ := p.property.1 + refine ⟨bondSource e, ?_⟩ + exact Finset.mem_union_left _ (Finset.mem_image.mpr ⟨e, he, rfl⟩) + +lemma incompatible_symm {p q : Polygon H} (h : Incompatible p q) : + Incompatible q p := by + obtain ⟨v, hp, hq⟩ := h + exact ⟨v, hq, hp⟩ + +lemma incompatible_self (p : Polygon H) : Incompatible p p := by + obtain ⟨v, hv⟩ := vertices_nonempty p + exact ⟨v, hv, hv⟩ + +lemma not_incompatible_iff_disjoint (p q : Polygon H) : + ¬ Incompatible p q ↔ Disjoint p.vertices q.vertices := by + simp [Incompatible, Finset.disjoint_left] + +end Polygon + +def DualAvoiding (E : Finset (Bond H)) (a b : Face H) : Prop := + ∃ e : Bond H, e ∉ E ∧ + ((dualEnds e).1 = a ∧ (dualEnds e).2 = b ∨ + (dualEnds e).1 = b ∧ (dualEnds e).2 = a) + +def Separates (p : Polygon H) (a b : Face H) : Prop := + ¬ Relation.ReflTransGen (DualAvoiding p.val) a b + +def InHex (R : ℕ) (q : Face ℤ) : Prop := + |q.1| ≤ (R : ℤ) ∧ |q.2| ≤ (R : ℤ) ∧ |q.1 + q.2| ≤ (R : ℤ) + +def TriangleInHex (R : ℕ) (v : Vertex ℤ) : Prop := + InHex R (v.1.1 + 1, v.1.2) ∧ InHex R (v.1.1, v.1.2 + 1) ∧ + if v.2 then InHex R v.1 else InHex R (v.1.1 + 1, v.1.2 + 1) + +def ContainedInHex (R : ℕ) (p : Polygon ℤ) : Prop := + ∀ v ∈ p.vertices, TriangleInHex R v + +def SurroundsOrigin (p : Polygon ℤ) : Prop := + ∃ R : ℕ, ∀ q : Face ℤ, + Relation.ReflTransGen (DualAvoiding p.val) (0, 0) q → InHex R q + +end Lattice + +open HoneycombCylinder.Lattice + +def criticalActivity : ℝ := 1 / Real.sqrt (2 + Real.sqrt 2) + +abbrev CylFace (m : ℕ) := Face (ZMod (2 * m)) +abbrev CylPolygon (m : ℕ) := Lattice.Polygon (ZMod (2 * m)) + +def firstMark (m : ℕ) : CylFace m := (0, 0) +def secondMark (m : ℕ) : CylFace m := ((m : ZMod (2 * m)), 0) + +abbrev SeparatingPolygon (m : ℕ) := + {p : CylPolygon m // Separates p (firstMark m) (secondMark m)} + +def cylinderLength {m : ℕ} (p : SeparatingPolygon m) : ℕ := p.val.length + +def CylinderIncompatible {m : ℕ} (p q : SeparatingPolygon m) : Prop := + Lattice.Polygon.Incompatible p.val q.val + +abbrev CylinderConfiguration (m : ℕ) := + {s : Finset (SeparatingPolygon m) // + (s : Set (SeparatingPolygon m)).Pairwise (fun p q => ¬ CylinderIncompatible p q)} + +def cylinderWeight (m : ℕ) (g : ℝ) (s : CylinderConfiguration m) : ℝ := + ∏ p ∈ s.val, g * criticalActivity ^ cylinderLength p + +def cylinderComplexWeight (m : ℕ) (g : ℂ) (s : CylinderConfiguration m) : ℂ := + ∏ p ∈ s.val, g * (criticalActivity : ℂ) ^ cylinderLength p + +def G (m : ℕ) (g : ℝ) : ℝ := ∑' s, cylinderWeight m g s + +def GComplex (m : ℕ) (g : ℂ) : ℂ := ∑' s, cylinderComplexWeight m g s + +def pairWeight (m : ℕ) (pq : SeparatingPolygon m × SeparatingPolygon m) : ℝ := + if CylinderIncompatible pq.1 pq.2 then + criticalActivity ^ (cylinderLength pq.1 + cylinderLength pq.2) else 0 + +def pairMass (m : ℕ) : ℝ := ∑' pq, pairWeight m pq + +def cylinderFluctuation (m : ℕ) : ℝ := + -(deriv (deriv (fun g : ℝ => Real.log (G m g))) 0) + +abbrev PlanarPolygon (R : ℕ) := + {p : Lattice.Polygon ℤ // ContainedInHex R p ∧ SurroundsOrigin p} + +def PlanarIncompatible {R : ℕ} (p q : PlanarPolygon R) : Prop := + Lattice.Polygon.Incompatible p.val q.val + +abbrev PlanarConfiguration (R : ℕ) := + {s : Finset (PlanarPolygon R) // + (s : Set (PlanarPolygon R)).Pairwise (fun p q => ¬ PlanarIncompatible p q)} + +def planarWeight (R : ℕ) (s : PlanarConfiguration R) : ℝ := + ∏ p ∈ s.val, 2 * criticalActivity ^ p.val.length + +def Z (R : ℕ) : ℝ := ∑' s, planarWeight R s + +def evenAtTop : Filter ℕ := Filter.atTop ⊓ Filter.principal {m : ℕ | Even m} + +def stripExponent (θ : ℂ) : ℝ := + ((1 / 6 : ℂ) - 2 * θ ^ 2 / (3 * (Real.pi : ℂ) ^ 2)).re + +lemma criticalActivity_pos : 0 < criticalActivity := by + unfold criticalActivity + apply one_div_pos.mpr + exact Real.sqrt_pos.mpr (by positivity) + +def cutBond (m i : ℕ) : Bond (ZMod (2 * m)) := (((i : ZMod (2 * m)), 0), 1) + +lemma cutBond_dualEnds (m i : ℕ) : + dualEnds (cutBond m i) = (((i : ZMod (2 * m)), 0), (((i + 1 : ℕ) : ZMod (2 * m)), 0)) := by + simp [cutBond, dualEnds, Nat.cast_add, Nat.cast_one] + +lemma separator_meets_cut {m : ℕ} (p : SeparatingPolygon m) : + ∃ i : ℕ, i < m ∧ cutBond m i ∈ p.val.val := by + by_contra h + push Not at h + have hpath (i : ℕ) (hi : i ≤ m) : + Relation.ReflTransGen (DualAvoiding p.val.val) (firstMark m) + ((i : ZMod (2 * m)), 0) := by + induction i with + | zero => simpa [firstMark] using + (Relation.ReflTransGen.refl : Relation.ReflTransGen (DualAvoiding p.val.val) + (firstMark m) (firstMark m)) + | succ i ih => + refine (ih (Nat.le_trans (Nat.le_succ i) hi)).tail ?_ + refine ⟨cutBond m i, h i (by omega), Or.inl ?_⟩ + simp [cutBond_dualEnds] + exact p.property (hpath m le_rfl) + +def cutIndex {m : ℕ} (p : SeparatingPolygon m) : ℕ := + Nat.find (separator_meets_cut p) + +lemma cutIndex_spec {m : ℕ} (p : SeparatingPolygon m) : + cutIndex p < m ∧ cutBond m (cutIndex p) ∈ p.val.val := + Nat.find_spec (separator_meets_cut p) + +lemma source_mem_vertices {H : Type*} [AddGroupWithOne H] + {E : Finset (Bond H)} {e : Bond H} (he : e ∈ E) : + bondSource e ∈ Lattice.vertices E := + Finset.mem_union_left _ (Finset.mem_image.mpr ⟨e, he, rfl⟩) + +lemma cylinder_configuration_card_le {m : ℕ} (s : CylinderConfiguration m) : + s.val.card ≤ m := by + suffices s.val.card ≤ (Finset.range m).card by simpa using this + apply Finset.card_le_card_of_injOn cutIndex + · intro p hp + exact Finset.mem_range.mpr (cutIndex_spec p).1 + · intro p hp q hq hpq + by_contra hne + apply s.property hp hq hne + unfold CylinderIncompatible Lattice.Polygon.Incompatible + refine ⟨bondSource (cutBond m (cutIndex p)), + source_mem_vertices (cutIndex_spec p).2, ?_⟩ + rw [hpq] + exact source_mem_vertices (cutIndex_spec q).2 + +lemma cylinder_configuration_card_le_two_mul {m : ℕ} (s : CylinderConfiguration m) : + s.val.card ≤ 2 * m := by + have := cylinder_configuration_card_le s + omega + +def emptyCylinderConfiguration (m : ℕ) : CylinderConfiguration m := + ⟨∅, by simp⟩ + +@[simp] lemma cylinderWeight_empty (m : ℕ) (g : ℝ) : + cylinderWeight m g (emptyCylinderConfiguration m) = 1 := by + simp [cylinderWeight, emptyCylinderConfiguration] + +@[simp] lemma cylinderComplexWeight_empty (m : ℕ) (g : ℂ) : + cylinderComplexWeight m g (emptyCylinderConfiguration m) = 1 := by + simp [cylinderComplexWeight, emptyCylinderConfiguration] + +lemma cylinderWeight_zero_of_ne_empty (m : ℕ) (s : CylinderConfiguration m) + (h : s ≠ emptyCylinderConfiguration m) : cylinderWeight m 0 s = 0 := by + have hn : s.val ≠ ∅ := fun he => h (Subtype.ext he) + have hcard : s.val.card ≠ 0 := Finset.card_ne_zero.mpr (Finset.nonempty_iff_ne_empty.mpr hn) + simp [cylinderWeight, hcard] + +lemma cylinderComplexWeight_zero_of_ne_empty (m : ℕ) (s : CylinderConfiguration m) + (h : s ≠ emptyCylinderConfiguration m) : cylinderComplexWeight m 0 s = 0 := by + have hn : s.val ≠ ∅ := fun he => h (Subtype.ext he) + have hcard : s.val.card ≠ 0 := Finset.card_ne_zero.mpr (Finset.nonempty_iff_ne_empty.mpr hn) + simp [cylinderComplexWeight, hcard] + +@[simp] theorem G_zero (m : ℕ) : G m 0 = 1 := by + rw [G, tsum_eq_single (emptyCylinderConfiguration m)] + · exact cylinderWeight_empty m 0 + · exact fun s h => cylinderWeight_zero_of_ne_empty m s h + +@[simp] theorem GComplex_zero (m : ℕ) : GComplex m 0 = 1 := by + rw [GComplex, tsum_eq_single (emptyCylinderConfiguration m)] + · exact cylinderComplexWeight_empty m 0 + · exact fun s h => cylinderComplexWeight_zero_of_ne_empty m s h + +end HoneycombCylinder + +end + +noncomputable section +open Classical Polynomial +open scoped BigOperators Topology + +namespace HoneycombCylinder + +def cylinderCutoff (m : ℕ) (B : Finset (Lattice.Bond (ZMod (2 * m)))) : + Finset (SeparatingPolygon m) := + B.powerset.preimage (fun p : SeparatingPolygon m => p.val.val) + (by intro p hp q hq h; exact Subtype.ext (Subtype.ext h)) + +@[simp] lemma mem_cylinderCutoff (m : ℕ) (B : Finset (Lattice.Bond (ZMod (2 * m)))) + (p : SeparatingPolygon m) : p ∈ cylinderCutoff m B ↔ p.val.val ⊆ B := by + exact Finset.mem_preimage.trans Finset.mem_powerset + +def heightBonds (m h : ℕ) : Finset (Lattice.Bond (ZMod (2 * m))) := + ((Finset.range (2 * m)).product (Finset.Icc (-(h : ℤ)) (h : ℤ))).biUnion + (fun ij => (Finset.univ : Finset (Fin 3)).image + (fun k => (((ij.1 : ZMod (2 * m)), ij.2), k))) + +def finiteCylinderPolynomial (m : ℕ) (B : Finset (Lattice.Bond (ZMod (2 * m)))) : ℝ[X] := + FiniteHardCore.partition CylinderIncompatible + (fun p => criticalActivity ^ cylinderLength p) (cylinderCutoff m B) + +lemma finiteCylinderPolynomial_eval (m : ℕ) (B : Finset (Lattice.Bond (ZMod (2 * m)))) + (g : ℝ) : + (finiteCylinderPolynomial m B).eval g = + ∑ s ∈ (cylinderCutoff m B).powerset, + if (s : Set (SeparatingPolygon m)).Pairwise (fun p q => ¬ CylinderIncompatible p q) + then ∏ p ∈ s, g * criticalActivity ^ cylinderLength p else 0 := + by + simpa only [finiteCylinderPolynomial, FiniteHardCore.Independent] using + (FiniteHardCore.eval_partition (CylinderIncompatible (m := m)) + (fun p => criticalActivity ^ cylinderLength p) (cylinderCutoff m B) g) + +@[simp] lemma finiteCylinderPolynomial_coeff_zero (m : ℕ) + (B : Finset (Lattice.Bond (ZMod (2 * m)))) : + (finiteCylinderPolynomial m B).coeff 0 = 1 := + FiniteHardCore.coeff_zero _ _ _ + +lemma finiteCylinderPolynomial_degree_le (m : ℕ) + (B : Finset (Lattice.Bond (ZMod (2 * m)))) : + (finiteCylinderPolynomial m B).natDegree ≤ 2 * m := by + unfold finiteCylinderPolynomial FiniteHardCore.partition + apply Polynomial.natDegree_sum_le_of_forall_le + intro s hs + split_ifs with hind + · exact (Polynomial.natDegree_monomial_le _).trans + (cylinder_configuration_card_le_two_mul (⟨s, hind⟩ : CylinderConfiguration m)) + · simp + +theorem finite_cylinder_negative_log_second_derivative (m : ℕ) + (B : Finset (Lattice.Bond (ZMod (2 * m)))) : + -(deriv (deriv (fun g : ℝ => Real.log ((finiteCylinderPolynomial m B).eval g))) 0) = + ∑ p ∈ cylinderCutoff m B, ∑ q ∈ cylinderCutoff m B, + if CylinderIncompatible p q then + criticalActivity ^ (cylinderLength p + cylinderLength q) else 0 := by + simpa only [finiteCylinderPolynomial, FiniteHardCore.incompatiblePairs, pow_add] using + (FiniteHardCore.log_second_derivative_eq_incompatiblePairs + (CylinderIncompatible (m := m)) + (fun {_ _} h => Lattice.Polygon.incompatible_symm h) + (fun p => Lattice.Polygon.incompatible_self p.val) + (fun p => criticalActivity ^ cylinderLength p) (cylinderCutoff m B)) + +def planarBondBox (R : ℕ) : Finset (Lattice.Bond ℤ) := + ((Finset.Icc (-(R : ℤ)) (R : ℤ)).product + (Finset.Icc (-(R : ℤ)) (R : ℤ))).product Finset.univ + +lemma planarPolygon_bonds_subset (R : ℕ) (p : PlanarPolygon R) : + p.val.val ⊆ planarBondBox R := by + intro e he + have hv : Lattice.bondSource e ∈ p.val.vertices := source_mem_vertices he + have hc := p.property.1 _ hv + have hanchor : Lattice.InHex R e.1 := by + simpa only [Lattice.TriangleInHex, Lattice.bondSource, Bool.true_eq, ↓reduceIte] using hc.2.2 + rcases hanchor with ⟨hx, hy, _⟩ + rcases e with ⟨⟨i, j⟩, k⟩ + exact Finset.mem_product.mpr ⟨Finset.mem_product.mpr + ⟨Finset.mem_Icc.mpr (abs_le.mp hx), Finset.mem_Icc.mpr (abs_le.mp hy)⟩, + Finset.mem_univ k⟩ + +def planarPolygonCode (R : ℕ) : PlanarPolygon R ↪ (planarBondBox R).powerset where + toFun p := ⟨p.val.val, Finset.mem_powerset.mpr (planarPolygon_bonds_subset R p)⟩ + inj' := by + intro p q h + have h' : p.val.val = q.val.val := + congrArg (fun x : (planarBondBox R).powerset => x.val) h + exact Subtype.ext (Subtype.ext h') + +instance planarPolygon_finite (R : ℕ) : Finite (PlanarPolygon R) := + Finite.of_injective (planarPolygonCode R) (planarPolygonCode R).injective + +theorem planarWeight_summable (R : ℕ) : Summable (planarWeight R) := + Summable.of_finite + +lemma planarWeight_nonneg (R : ℕ) (s : PlanarConfiguration R) : + 0 ≤ planarWeight R s := by + apply Finset.prod_nonneg + intro p hp + exact mul_nonneg (by norm_num) (pow_nonneg criticalActivity_pos.le _) + +def emptyPlanarConfiguration (R : ℕ) : PlanarConfiguration R := ⟨∅, by simp⟩ + +@[simp] lemma planarWeight_empty (R : ℕ) : + planarWeight R (emptyPlanarConfiguration R) = 1 := by + simp [planarWeight, emptyPlanarConfiguration] + +theorem one_le_Z (R : ℕ) : 1 ≤ Z R := by + simpa only [Z, planarWeight_empty] using + (planarWeight_summable R).le_tsum (emptyPlanarConfiguration R) + (fun s _ => planarWeight_nonneg R s) + +instance evenAtTop_neBot : Filter.NeBot evenAtTop := by + apply Filter.frequently_iff_neBot.mp + apply Filter.frequently_atTop.mpr + intro n + exact ⟨2 * n, by omega, even_two_mul n⟩ + +end HoneycombCylinder +end + +noncomputable section +open Classical +open scoped BigOperators + +namespace HoneycombCylinder + +lemma inHex_mono {R S : ℕ} (h : R ≤ S) {q : Lattice.Face ℤ} + (hq : Lattice.InHex R q) : Lattice.InHex S q := by + have hRS : (R : ℤ) ≤ S := Int.ofNat_le.mpr h + exact ⟨hq.1.trans hRS, hq.2.1.trans hRS, hq.2.2.trans hRS⟩ + +lemma triangleInHex_mono {R S : ℕ} (h : R ≤ S) {v : Lattice.Vertex ℤ} + (hv : Lattice.TriangleInHex R v) : Lattice.TriangleInHex S v := by + refine ⟨inHex_mono h hv.1, inHex_mono h hv.2.1, ?_⟩ + have hv' := hv.2.2 + split_ifs at hv' ⊢ <;> exact inHex_mono h hv' + +def planarPolygonInclusion {R S : ℕ} (h : R ≤ S) : PlanarPolygon R ↪ PlanarPolygon S where + toFun p := ⟨p.val, (fun v hv => triangleInHex_mono h (p.property.1 v hv)), p.property.2⟩ + inj' := by + intro p q hpq + have hval : p.val = q.val := congrArg (fun z : PlanarPolygon S => z.val) hpq + exact Subtype.ext hval + +def planarConfigurationInclusion {R S : ℕ} (h : R ≤ S) : + PlanarConfiguration R ↪ PlanarConfiguration S where + toFun s := ⟨s.val.map (planarPolygonInclusion h), by + intro p hp q hq hpq + obtain ⟨p', hp', rfl⟩ := Finset.mem_map.mp hp + obtain ⟨q', hq', rfl⟩ := Finset.mem_map.mp hq + exact s.property hp' hq' (fun heq => hpq (congrArg (planarPolygonInclusion h) heq))⟩ + inj' := by + intro s t hst + exact Subtype.ext ((Finset.map_injective (planarPolygonInclusion h)) + (congrArg (fun z : PlanarConfiguration S => z.val) hst)) + +@[simp] lemma planarWeight_inclusion {R S : ℕ} (h : R ≤ S) (s : PlanarConfiguration R) : + planarWeight S (planarConfigurationInclusion h s) = planarWeight R s := by + change (∏ p ∈ s.val.map (planarPolygonInclusion h), 2 * criticalActivity ^ p.val.length) = + ∏ p ∈ s.val, 2 * criticalActivity ^ p.val.length + rw [Finset.prod_map] + rfl + +theorem Z_mono : Monotone Z := by + intro R S h + exact Summable.tsum_le_tsum_of_inj + (planarConfigurationInclusion h) (planarConfigurationInclusion h).injective + (fun s _ => planarWeight_nonneg S s) + (fun s => (planarWeight_inclusion h s).ge) + (planarWeight_summable R) (planarWeight_summable S) + +end HoneycombCylinder +end + +end OAI diff --git a/lean/OAI/Combinatorics/Honeycomb/PolygonMoment.lean b/lean/OAI/Combinatorics/Honeycomb/PolygonMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5cb0f891bd0e9b3767082a70f7634daa4058e76 --- /dev/null +++ b/lean/OAI/Combinatorics/Honeycomb/PolygonMoment.lean @@ -0,0 +1,505 @@ +import Mathlib + +namespace OAI + + + +noncomputable section + +namespace Honeycomb + +abbrev Cell := ℤ × ℤ + +structure Vertex where + i : ℤ + j : ℤ + isR : Bool + deriving DecidableEq + + + +structure Edge where + i : ℤ + j : ℤ + kind : Fin 3 + deriving DecidableEq + +def Edge.p (e : Edge) : Vertex := ⟨e.i, e.j, false⟩ + +def Edge.r (e : Edge) : Vertex := + ⟨e.i - if e.kind = 1 then 1 else 0, + e.j - if e.kind = 2 then 1 else 0, true⟩ + +def Edge.ends (e : Edge) : Sym2 Vertex := s(e.p, e.r) + +def h : ℂ := ⟨Real.sqrt 3, 0⟩ +def v : ℂ := ⟨Real.sqrt 3 / 2, 3 / 2⟩ + +def cellPosition (t : Cell) : ℂ := (t.1 : ℂ) * h + (t.2 : ℂ) * v + + +def position (a : Vertex) : ℂ := + cellPosition (a.i, a.j) + if a.isR then (h + v) / 3 else 0 + +def cyclicSucc {n : ℕ} (k : Fin n) : Fin n := + ⟨(k.val + 1) % n, Nat.mod_lt _ (Nat.zero_lt_of_lt k.isLt)⟩ + + + +def IsSimpleCycle (s : Finset Edge) : Prop := + ∃ (n : ℕ), 3 ≤ n ∧ ∃ a : Fin n → Vertex, Function.Injective a ∧ + s.image Edge.ends = Finset.univ.image (fun k => s(a k, a (cyclicSucc k))) + +structure EmbeddedPolygon where + edges : Finset Edge + isCycle : IsSimpleCycle edges + +@[ext] theorem EmbeddedPolygon.ext {p q : EmbeddedPolygon} (h : p.edges = q.edges) : + p = q := by + cases p + cases q + cases h + rfl + +theorem EmbeddedPolygon.edges_nonempty (p : EmbeddedPolygon) : p.edges.Nonempty := by + obtain ⟨n, hn, a, _, ha⟩ := p.isCycle + have hn0 : 0 < n := by omega + have hu : (Finset.univ : Finset (Fin n)).Nonempty := ⟨⟨0, hn0⟩, Finset.mem_univ _⟩ + have hh := hu.image (fun k => s(a k, a (cyclicSucc k))) + rw [← ha] at hh + exact Finset.image_nonempty.mp hh + +def Vertex.translate (t : Cell) (a : Vertex) : Vertex := + ⟨a.i + t.1, a.j + t.2, a.isR⟩ + +def Edge.translate (t : Cell) (e : Edge) : Edge := + ⟨e.i + t.1, e.j + t.2, e.kind⟩ + +@[simp] theorem Edge.translate_zero (e : Edge) : Edge.translate 0 e = e := by + cases e + simp [Edge.translate] + +@[simp] theorem Edge.translate_translate (t u : Cell) (e : Edge) : + Edge.translate t (Edge.translate u e) = Edge.translate (t + u) e := by + cases e + simp [Edge.translate, add_left_comm, add_comm] + +theorem Edge.translate_injective (t : Cell) : Function.Injective (Edge.translate t) := by + intro e f h + have hh := congrArg (Edge.translate (-t)) h + simpa using hh + +@[simp] theorem Edge.p_translate (t : Cell) (e : Edge) : + (Edge.translate t e).p = Vertex.translate t e.p := rfl + +@[simp] theorem Edge.r_translate (t : Cell) (e : Edge) : + (Edge.translate t e).r = Vertex.translate t e.r := by + dsimp [Edge.r, Edge.translate, Vertex.translate] + congr 1 <;> omega + +@[simp] theorem position_translate (t : Cell) (a : Vertex) : + position (Vertex.translate t a) = position a + cellPosition t := by + simp only [position, Vertex.translate, cellPosition, Int.cast_add] + ring_nf + +def translateEdges (t : Cell) (s : Finset Edge) : Finset Edge := + s.image (Edge.translate t) + +@[simp] theorem translateEdges_zero (s : Finset Edge) : translateEdges 0 s = s := by + have hh : Edge.translate (0 : Cell) = id := funext Edge.translate_zero + simp [translateEdges, hh] + +@[simp] theorem translateEdges_translate (t u : Cell) (s : Finset Edge) : + translateEdges t (translateEdges u s) = translateEdges (t + u) s := by + simp only [translateEdges, Finset.image_image] + congr 1 + funext e + exact Edge.translate_translate t u e + +@[simp] theorem translateEdges_card (t : Cell) (s : Finset Edge) : + (translateEdges t s).card = s.card := + Finset.card_image_of_injective _ (Edge.translate_injective t) + + +def vertices (s : Finset Edge) : Finset Vertex := s.image Edge.p ∪ s.image Edge.r + +def pointSet (s : Finset Edge) : Set ℂ := position '' (vertices s : Set Vertex) + +def embeddedDiameter (s : Finset Edge) : ℝ := Metric.diam (pointSet s) + +@[simp] theorem vertices_translate (t : Cell) (s : Finset Edge) : + vertices (translateEdges t s) = (vertices s).image (Vertex.translate t) := by + simp [vertices, translateEdges, Finset.image_union, Finset.image_image, Function.comp_def] + +theorem pointSet_translate (t : Cell) (s : Finset Edge) : + pointSet (translateEdges t s) = (fun z => z + cellPosition t) '' pointSet s := by + simp only [pointSet, vertices_translate, Finset.coe_image, Set.image_image] + simp only [position_translate] + +theorem embeddedDiameter_translate (t : Cell) (s : Finset Edge) : + embeddedDiameter (translateEdges t s) = embeddedDiameter s := by + rw [embeddedDiameter, pointSet_translate] + exact (show Isometry (fun z : ℂ => z + cellPosition t) from + fun z w => by simp [edist_dist, dist_eq_norm]).diam_image _ + + +def TranslationEquivalent (p q : EmbeddedPolygon) : Prop := + ∃ t : Cell, translateEdges t p.edges = q.edges + +instance polygonSetoid : Setoid EmbeddedPolygon where + r := TranslationEquivalent + iseqv := { + refl := fun p => ⟨0, translateEdges_zero _⟩ + symm := by + intro p q h + obtain ⟨t, ht⟩ := h + refine ⟨-t, ?_⟩ + rw [← ht] + simp + trans := by + intro p q r h₁ h₂ + obtain ⟨t, ht⟩ := h₁ + obtain ⟨u, hu⟩ := h₂ + refine ⟨u + t, ?_⟩ + rw [← translateEdges_translate, ht, hu] + } + + +abbrev Polygon := Quotient polygonSetoid + +def length : Polygon → ℕ := Quotient.lift (fun p => p.edges.card) (by + intro p q h + obtain ⟨t, ht⟩ := h + rw [← ht, translateEdges_card]) + +def diameter : Polygon → ℝ := Quotient.lift (fun p => embeddedDiameter p.edges) (by + intro p q h + obtain ⟨t, ht⟩ := h + rw [← ht, embeddedDiameter_translate]) + + +def xStar : ℝ := (Real.sqrt (2 + Real.sqrt 2))⁻¹ + +def weight (γ : Polygon) : ℝ := xStar ^ length γ + +def massTerm (r : ℝ) (γ : Polygon) : ℝ := + if r ≤ diameter γ then weight γ else 0 + +def lengthTerm (r : ℝ) (γ : Polygon) : ℝ := + if r ≤ diameter γ then (length γ : ℝ) * weight γ else 0 + +def secondMomentTerm (r : ℝ) (γ : Polygon) : ℝ := + if diameter γ ≤ r then (length γ : ℝ) ^ 2 * weight γ else 0 + + +def A (r : ℝ) : ℝ := ∑' γ : Polygon, massTerm r γ + + +def P (r : ℝ) : ℝ := ∑' γ : Polygon, lengthTerm r γ + + +def M2 (r : ℝ) : ℝ := ∑' γ : Polygon, secondMomentTerm r γ + + + +theorem Edge.ends_injective : Function.Injective Edge.ends := by + rintro ⟨ei, ej, ek⟩ ⟨fi, fj, fk⟩ hh + rcases Sym2.eq_iff.mp hh with ⟨hp, hr⟩ | ⟨hp, _⟩ + · have hi := congrArg Vertex.i hp + have hj := congrArg Vertex.j hp + dsimp [Edge.p] at hi hj + subst fi + subst fj + have hk : ek = fk := by + have hri := congrArg Vertex.i hr + have hrj := congrArg Vertex.j hr + dsimp [Edge.r] at hri hrj + clear hh hp hr + fin_cases ek <;> fin_cases fk <;> simp at hri hrj ⊢ <;> omega + cases hk + rfl + · have hf := congrArg Vertex.isR hp + simp [Edge.p, Edge.r] at hf + +theorem diameter_nonneg (γ : Polygon) : 0 ≤ diameter γ := by + induction γ using Quotient.inductionOn with + | h p => exact Metric.diam_nonneg + +theorem xStar_pos : 0 < xStar := by + unfold xStar + positivity + +theorem xStar_lt_one : xStar < 1 := by + have hh : 1 < Real.sqrt (2 + Real.sqrt 2) := by + apply (Real.lt_sqrt (by norm_num)).2 + have h2 := Real.sqrt_nonneg (2 : ℝ) + linarith + exact inv_lt_one_of_one_lt₀ hh + +theorem weight_pos (γ : Polygon) : 0 < weight γ := pow_pos xStar_pos _ + +theorem weight_nonneg (γ : Polygon) : 0 ≤ weight γ := (weight_pos γ).le + +theorem massTerm_nonneg (r : ℝ) (γ : Polygon) : 0 ≤ massTerm r γ := by + have hw := weight_nonneg γ + unfold massTerm + split_ifs <;> positivity + +theorem lengthTerm_nonneg (r : ℝ) (γ : Polygon) : 0 ≤ lengthTerm r γ := by + have hw := weight_nonneg γ + unfold lengthTerm + split_ifs <;> positivity + +theorem secondMomentTerm_nonneg (r : ℝ) (γ : Polygon) : 0 ≤ secondMomentTerm r γ := by + have hw := weight_nonneg γ + unfold secondMomentTerm + split_ifs <;> positivity + +theorem A_nonneg (r : ℝ) : 0 ≤ A r := tsum_nonneg (massTerm_nonneg r) +theorem P_nonneg (r : ℝ) : 0 ≤ P r := tsum_nonneg (lengthTerm_nonneg r) +theorem M2_nonneg (r : ℝ) : 0 ≤ M2 r := tsum_nonneg (secondMomentTerm_nonneg r) + + + +def anchor (γ : Polygon) : Edge := γ.out.edges_nonempty.choose + +theorem anchor_mem (γ : Polygon) : anchor γ ∈ γ.out.edges := + γ.out.edges_nonempty.choose_spec + +def anchorCell (γ : Polygon) : Cell := ((anchor γ).i, (anchor γ).j) + +def anchoredEdges (γ : Polygon) : Finset Edge := + translateEdges (-anchorCell γ) γ.out.edges + +theorem anchoredEdges_injective : Function.Injective anchoredEdges := by + intro γ δ hh + have hshift := congrArg (translateEdges (anchorCell δ)) hh + simp only [anchoredEdges, translateEdges_translate, add_neg_cancel, + translateEdges_zero] at hshift + have hq : (⟦γ.out⟧ : Polygon) = ⟦δ.out⟧ := + Quotient.sound ⟨anchorCell δ + -anchorCell γ, hshift⟩ + simpa only [Quotient.out_eq] using hq + +theorem embeddedDiameter_out (γ : Polygon) : + embeddedDiameter γ.out.edges = diameter γ := by + change diameter (Quotient.mk _ γ.out) = diameter γ + rw [Quotient.out_eq] + +theorem anchoredEdges_diameter (γ : Polygon) : + embeddedDiameter (anchoredEdges γ) = diameter γ := by + rw [anchoredEdges, embeddedDiameter_translate, embeddedDiameter_out] + +theorem pointSet_finite (s : Finset Edge) : (pointSet s).Finite := + (vertices s).finite_toSet.image position + +theorem p_mem_pointSet {e : Edge} {s : Finset Edge} (he : e ∈ s) : + position e.p ∈ pointSet s := by + exact ⟨e.p, Finset.mem_union_left _ (Finset.mem_image.mpr ⟨e, he, rfl⟩), rfl⟩ + +theorem zero_mem_anchored_pointSet (γ : Polygon) : + 0 ∈ pointSet (anchoredEdges γ) := by + have he : Edge.translate (-anchorCell γ) (anchor γ) ∈ anchoredEdges γ := + Finset.mem_image.mpr ⟨anchor γ, anchor_mem γ, rfl⟩ + have hp := p_mem_pointSet he + simpa [Edge.translate, anchorCell, Edge.p, position, cellPosition] using hp + +theorem norm_position_p_le_diameter (γ : Polygon) {e : Edge} + (he : e ∈ anchoredEdges γ) : ‖position e.p‖ ≤ diameter γ := by + have hd := Metric.dist_le_diam_of_mem + (pointSet_finite (anchoredEdges γ)).isBounded + (p_mem_pointSet he) (zero_mem_anchored_pointSet γ) + rw [dist_zero_right] at hd + change ‖position e.p‖ ≤ embeddedDiameter (anchoredEdges γ) at hd + rwa [anchoredEdges_diameter] at hd + +@[simp] theorem position_p_re (e : Edge) : + (position e.p).re = (e.i : ℝ) * Real.sqrt 3 + (e.j : ℝ) * (Real.sqrt 3 / 2) := by + simp [position, Edge.p, cellPosition, h, v] + +@[simp] theorem position_p_im (e : Edge) : + (position e.p).im = (e.j : ℝ) * (3 / 2) := by + simp [position, Edge.p, cellPosition, h, v] + + +theorem edge_coordinate_bound {e : Edge} {r : ℝ} (hr : ‖position e.p‖ ≤ r) : + |(e.i : ℝ)| ≤ 2 * r ∧ |(e.j : ℝ)| ≤ 2 * r := by + have hr0 : 0 ≤ r := (norm_nonneg _).trans hr + have hy : |(e.j : ℝ) * (3 / 2)| ≤ r := by + simpa using (Complex.abs_im_le_norm (position e.p)).trans hr + have hj : |(e.j : ℝ)| ≤ r := by + rw [abs_le] at hy ⊢ + constructor <;> linarith + have hx : |(e.i : ℝ) * Real.sqrt 3 + (e.j : ℝ) * (Real.sqrt 3 / 2)| ≤ r := by + simpa using (Complex.abs_re_le_norm (position e.p)).trans hr + have hs0 : 0 ≤ Real.sqrt 3 := Real.sqrt_nonneg _ + have hs1 : 1 ≤ Real.sqrt 3 := by + apply (Real.le_sqrt (by norm_num) (by norm_num)).2 + norm_num + have hs2 : Real.sqrt 3 ≤ 2 := by + apply (Real.sqrt_le_iff).2 + norm_num + have hjs : |(e.j : ℝ) * (Real.sqrt 3 / 2)| ≤ r := by + rw [abs_mul, abs_of_nonneg (by positivity : 0 ≤ Real.sqrt 3 / 2)] + calc + |(e.j : ℝ)| * (Real.sqrt 3 / 2) ≤ r * 1 := + mul_le_mul hj (by linarith) (by positivity) hr0 + _ = r := mul_one _ + have his : |(e.i : ℝ) * Real.sqrt 3| ≤ 2 * r := by + calc + |(e.i : ℝ) * Real.sqrt 3| = + |((e.i : ℝ) * Real.sqrt 3 + (e.j : ℝ) * (Real.sqrt 3 / 2)) - + (e.j : ℝ) * (Real.sqrt 3 / 2)| := by ring_nf + _ ≤ |(e.i : ℝ) * Real.sqrt 3 + (e.j : ℝ) * (Real.sqrt 3 / 2)| + + |(e.j : ℝ) * (Real.sqrt 3 / 2)| := abs_sub _ _ + _ ≤ 2 * r := by linarith + refine ⟨?_, by linarith⟩ + calc + |(e.i : ℝ)| ≤ |(e.i : ℝ)| * Real.sqrt 3 := le_mul_of_one_le_right (abs_nonneg _) hs1 + _ = |(e.i : ℝ) * Real.sqrt 3| := by rw [abs_mul, abs_of_nonneg hs0] + _ ≤ 2 * r := his + + +def edgeBox (b : ℤ) : Finset Edge := + ((Finset.Icc (-b) b ×ˢ Finset.Icc (-b) b) ×ˢ (Finset.univ : Finset (Fin 3))).image + (fun t => ⟨t.1.1, t.1.2, t.2⟩) + +theorem mem_edgeBox {b : ℤ} {e : Edge} : + e ∈ edgeBox b ↔ (-b ≤ e.i ∧ e.i ≤ b) ∧ (-b ≤ e.j ∧ e.j ≤ b) := by + simp only [edgeBox, Finset.mem_image, Finset.mem_product, Finset.mem_Icc, + Finset.mem_univ, and_true] + constructor + · rintro ⟨⟨⟨i, j⟩, k⟩, hh, he⟩ + cases he + exact hh + · intro hh + exact ⟨((e.i, e.j), e.kind), hh, by cases e; rfl⟩ + +theorem anchoredEdges_subset_box {γ : Polygon} {r : ℝ} (hr : diameter γ ≤ r) : + anchoredEdges γ ⊆ edgeBox ⌈2 * r⌉ := by + intro e he + have hh := edge_coordinate_bound ((norm_position_p_le_diameter γ he).trans hr) + have hceil := Int.le_ceil (2 * r) + have hi : |(e.i : ℝ)| ≤ (⌈2 * r⌉ : ℤ) := hh.1.trans hceil + have hj : |(e.j : ℝ)| ≤ (⌈2 * r⌉ : ℤ) := hh.2.trans hceil + rw [abs_le] at hi hj + apply mem_edgeBox.mpr + constructor <;> constructor + · exact_mod_cast hi.1 + · exact_mod_cast hi.2 + · exact_mod_cast hj.1 + · exact_mod_cast hj.2 + + +theorem finite_diameter_le (r : ℝ) : {γ : Polygon | diameter γ ≤ r}.Finite := by + apply Set.Finite.of_injOn (f := anchoredEdges) + (t := ↑(edgeBox ⌈2 * r⌉).powerset) + · intro γ hγ + exact Finset.mem_powerset.mpr (anchoredEdges_subset_box hγ) + · exact anchoredEdges_injective.injOn + · exact Finset.finite_toSet _ + +theorem summable_diameter_truncation (r : ℝ) (f : Polygon → ℝ) : + Summable (fun γ => if diameter γ ≤ r then f γ else 0) := by + apply summable_of_hasFiniteSupport + apply (finite_diameter_le r).subset + intro γ hγ + by_contra hh + exact hγ (ite_eq_right hh) + +theorem summable_secondMomentTerm (r : ℝ) : Summable (secondMomentTerm r) := + summable_diameter_truncation r (fun γ => (length γ : ℝ) ^ 2 * weight γ) + + +theorem M2_monotone : Monotone M2 := by + intro r s hrs + apply (summable_secondMomentTerm r).tsum_le_tsum _ (summable_secondMomentTerm s) + intro γ + have hw := weight_nonneg γ + unfold secondMomentTerm + split_ifs with h₁ h₂ h₂ + · exact le_rfl + · exact False.elim (h₂ (h₁.trans hrs)) + · positivity + · exact le_rfl + + + +instance : Countable Edge := by + have hinj : Function.Injective (fun e : Edge => (e.i, e.j, e.kind)) := by + rintro ⟨i, j, k⟩ ⟨i', j', k'⟩ hh + simpa only [Prod.mk.injEq, Edge.mk.injEq] using hh + exact hinj.countable + +instance : Countable EmbeddedPolygon := by + have hinj : Function.Injective EmbeddedPolygon.edges := by + intro p q hpq + exact EmbeddedPolygon.ext hpq + exact hinj.countable + +theorem polygon_countable : Countable Polygon := inferInstance + +theorem length_pos (γ : Polygon) : 0 < length γ := by + induction γ using Quotient.inductionOn with + | h p => exact Finset.card_pos.mpr p.edges_nonempty + +def hexagonEdges : Finset Edge := + {⟨0, 0, 0⟩, ⟨1, 0, 1⟩, ⟨1, 0, 2⟩, ⟨1, -1, 0⟩, ⟨1, -1, 1⟩, ⟨0, 0, 2⟩} + + +def hexagon : EmbeddedPolygon where + edges := hexagonEdges + isCycle := by + refine ⟨6, by omega, ![⟨0, 0, false⟩, ⟨0, 0, true⟩, ⟨1, 0, false⟩, + ⟨1, -1, true⟩, ⟨1, -1, false⟩, ⟨0, -1, true⟩], ?_, ?_⟩ + · decide + · decide + +theorem hexagon_length : length ⟦hexagon⟧ = 6 := by decide + +instance : Nonempty Polygon := ⟨⟦hexagon⟧⟩ + + +theorem Edge.unit_length (e : Edge) : dist (position e.p) (position e.r) = 1 := by + rw [dist_eq_norm, Complex.norm_def] + suffices hh : Complex.normSq (position e.p - position e.r) = 1 by + rw [hh, Real.sqrt_one] + rcases e with ⟨i, j, k⟩ + have hsq : Real.sqrt 3 ^ 2 = 3 := Real.sq_sqrt (by norm_num) + fin_cases k <;> + simp [Complex.normSq_apply, Edge.p, Edge.r, position, cellPosition, h, v] <;> + ring_nf <;> nlinarith + + +theorem position_injective : Function.Injective position := by + rintro ⟨i, j, b⟩ ⟨i', j', b'⟩ hh + have hx := congrArg Complex.re hh + have hy := congrArg Complex.im hh + have hs : Real.sqrt 3 ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (by norm_num)) + cases b <;> cases b' <;> + simp [position, cellPosition, h, v] at hx hy + · have hj : j = j' := hy + subst j' + have hi : i = i' := by + exact_mod_cast (mul_right_cancel₀ hs + (show (i : ℝ) * Real.sqrt 3 = (i' : ℝ) * Real.sqrt 3 by linarith)) + subst i' + rfl + · have hbad : 3 * j = 3 * j' + 1 := by + exact_mod_cast (show 3 * (j : ℝ) = 3 * (j' : ℝ) + 1 by linarith) + omega + · have hbad : 3 * j + 1 = 3 * j' := by + exact_mod_cast (show 3 * (j : ℝ) + 1 = 3 * (j' : ℝ) by linarith) + omega + · have hj : j = j' := hy + subst j' + have hi : i = i' := by + exact_mod_cast (mul_right_cancel₀ hs + (show (i : ℝ) * Real.sqrt 3 = (i' : ℝ) * Real.sqrt 3 by linarith)) + subst i' + rfl + +end Honeycomb + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombBridges/Basic.lean b/lean/OAI/Combinatorics/HoneycombBridges/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..eff85755171656d3ff231cde23c9e4ad92460e57 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombBridges/Basic.lean @@ -0,0 +1,502 @@ +import Mathlib + +namespace OAI + +/-! Strict honeycomb bridges and their finite length classes. -/ + + + +noncomputable section +open scoped ENNReal +open Filter + +namespace HoneycombActual + +structure Vertex where + col : ℤ + row : ℤ + up : Bool + deriving DecidableEq + +def up (i j : ℤ) : Vertex := ⟨i, j, true⟩ +def down (i j : ℤ) : Vertex := ⟨i, j, false⟩ + +def UpDownAdj (v w : Vertex) : Prop := + v.up = true ∧ w.up = false ∧ + ((w.col = v.col ∧ w.row + 1 = v.row) ∨ + (w.col = v.col ∧ w.row = v.row) ∨ + (w.col + 1 = v.col ∧ w.row = v.row)) + +def Adj (v w : Vertex) : Prop := UpDownAdj v w ∨ UpDownAdj w v + +def rowSpacing : ℝ := Real.sqrt 3 / 2 + +def position (v : Vertex) : ℂ := + if v.up then + ⟨(v.col : ℝ) + (v.row : ℝ) / 2 + 1/2, + rowSpacing * ((v.row : ℝ) + 1/3)⟩ + else + ⟨(v.col : ℝ) + (v.row : ℝ) / 2 + 1, + rowSpacing * ((v.row : ℝ) + 2/3)⟩ + +def port (i j : ℤ) : ℂ := + ⟨(i : ℝ) + (j : ℝ) / 2 + 1/2, rowSpacing * (j : ℝ)⟩ + +structure Bridge where + height : ℕ + terminal : ℤ + vertices : List Vertex + height_pos : 0 < height + self_avoiding : vertices.Nodup + connected : vertices.IsChain Adj + initiates : vertices.head? = some (up 0 0) + terminates : vertices.getLast? = some (down terminal ((height : ℤ) - 1)) + in_strip : ∀ v ∈ vertices, 0 ≤ v.row ∧ v.row < (height : ℤ) + +namespace Bridge + +def length (b : Bridge) : ℕ := b.vertices.length + +def endpointDistance (b : Bridge) : ℝ := + dist (port 0 0) (port b.terminal b.height) + +def trace (b : Bridge) : Set ℂ := + {port 0 0, port b.terminal b.height} ∪ (position '' {v | v ∈ b.vertices}) + +def diameter (b : Bridge) : ℝ := Metric.diam b.trace + +def crosses (r : ℕ) (e : Vertex × Vertex) : Bool := + decide ((e.1.row < (r : ℤ) ∧ (r : ℤ) ≤ e.2.row) ∨ + (e.2.row < (r : ℤ) ∧ (r : ℤ) ≤ e.1.row)) + +def crossingCount (b : Bridge) (r : ℕ) : ℕ := + (b.vertices.zip b.vertices.tail).countP (crosses r) + +def Irreducible (b : Bridge) : Prop := + ∀ r : ℕ, 0 < r → r < b.height → b.crossingCount r ≠ 1 + +end Bridge + +def rho : ℝ := (Real.sqrt (2 + Real.sqrt 2))⁻¹ + +def weight (b : Bridge) : ℝ≥0∞ := ENNReal.ofReal (rho ^ b.length) + +def criticalMass (P : Bridge → Prop) : ℝ≥0∞ := by + classical + exact ∑' b : Bridge, if P b then weight b else 0 + +def bridgeMass (h : ℕ) : ℝ≥0∞ := + if h = 0 then 1 else criticalMass (fun b => b.height = h) + +def lengthReward (h : ℕ) : ℝ≥0∞ := by + classical + exact ∑' b : Bridge, if b.height = h then (b.length : ℝ≥0∞) * weight b else 0 + +def uniformLengthProbability (n : ℕ) (P : Bridge → Prop) : ℝ := + (Nat.card {b : Bridge // b.length = n ∧ P b} : ℝ) / + (Nat.card {b : Bridge // b.length = n} : ℝ) + +def FiniteBridgeEstimates : Prop := + ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ + (∃ h₀ : ℕ, 0 < h₀ ∧ ∀ h : ℕ, h₀ ≤ h → + ENNReal.ofReal (c * (h : ℝ) ^ (-(1/4 : ℝ))) ≤ bridgeMass h ∧ + bridgeMass h ≤ ENNReal.ofReal (C * (h : ℝ) ^ (-(1/4 : ℝ))) ∧ + lengthReward h ≤ ENNReal.ofReal (C * (h : ℝ) ^ (13/12 : ℝ)) ∧ + ENNReal.ofReal (c * (h : ℝ) ^ (-(1/4 : ℝ))) ≤ + criticalMass (fun b => b.height = h ∧ c * (h : ℝ) ^ (4/3 : ℝ) ≤ b.length)) ∧ + (∀ h : ℕ, 0 < h → ∀ x : ℝ, 1 ≤ x → + criticalMass (fun b => b.height = h ∧ x < b.diameter) ≤ + ENNReal.ofReal (C * x ^ (-(1/4 : ℝ)))) ∧ + (∀ h : ℕ, bridgeMass h ≠ ⊤ ∧ lengthReward h ≠ ⊤) + +def ExactLengthSpatialLaw : Prop := + ∀ ξ : ℝ, 0 < ξ → + Tendsto (fun m : ℕ => uniformLengthProbability (2*m) (fun b => + (2*m : ℝ) ^ ((3/4 : ℝ) - ξ) ≤ b.endpointDistance ∧ + b.endpointDistance ≤ b.diameter ∧ + b.diameter ≤ (2*m : ℝ) ^ ((3/4 : ℝ) + ξ))) atTop (nhds 1) + +theorem rho_pos : 0 < rho := by + unfold rho + exact inv_pos.mpr (Real.sqrt_pos.mpr (by positivity)) + +theorem Adj.side_ne {v w : Vertex} (h : Adj v w) : v.up ≠ w.up := by + rcases h with ⟨hv, hw, _⟩ | ⟨hw, hv, _⟩ <;> simp [hv, hw] + +theorem chain_length_parity (v : Vertex) (xs : List Vertex) + (h : (v :: xs).IsChain Adj) (z : Vertex) + (hz : (v :: xs).getLast? = some z) : + (v :: xs).length % 2 = 0 ↔ v.up ≠ z.up := by + induction xs generalizing v with + | nil => + simp only [List.getLast?_singleton, Option.some.injEq] at hz + subst z + simp + | cons w xs ih => + obtain ⟨hvw, hw⟩ := List.isChain_cons_cons.mp h + have hcol := Adj.side_ne hvw + have hlast : (w :: xs).getLast? = some z := by simpa using hz + have hp := ih w hw hlast + simp only [List.length_cons] at hp ⊢ + cases hv : v.up <;> cases hw' : w.up <;> cases hz' : z.up <;> + simp_all <;> omega + +theorem Bridge.even_length (b : Bridge) : Even b.length := by + have hh := b.initiates + cases hlist : b.vertices with + | nil => simp [hlist] at hh + | cons v xs => + have hv : v = up 0 0 := by simpa [hlist] using hh + subst v + have hc : (up 0 0 :: xs).IsChain Adj := by simpa [hlist] using b.connected + have ht : (up 0 0 :: xs).getLast? = + some (down b.terminal ((b.height : ℤ) - 1)) := by + simpa [hlist] using b.terminates + have hp := (chain_length_parity (up 0 0) xs hc _ ht).mpr (by simp [up, down]) + exact even_iff_two_dvd.mpr (Nat.dvd_of_mod_eq_zero (by simpa [Bridge.length, hlist] using hp)) + +def zigzagTwo : Bridge where + height := 1 + terminal := 0 + vertices := [up 0 0, down 0 0] + height_pos := by decide + self_avoiding := by simp [up, down] + connected := by simp [List.isChain_cons_cons, Adj, UpDownAdj, up, down] + initiates := rfl + terminates := by rfl + in_strip := by + intro v hv + simp only [List.mem_cons, List.not_mem_nil, or_false] at hv + rcases hv with rfl | rfl <;> norm_num [up, down] + +def zigzagFour : Bridge where + height := 1 + terminal := 1 + vertices := [up 0 0, down 0 0, up 1 0, down 1 0] + height_pos := by decide + self_avoiding := by simp [up, down] + connected := by simp [List.isChain_cons_cons, Adj, UpDownAdj, up, down] + initiates := rfl + terminates := by rfl + in_strip := by + intro v hv + simp only [List.mem_cons, List.not_mem_nil, or_false] at hv + rcases hv with rfl | rfl | rfl | rfl <;> norm_num [up, down] + +theorem Bridge.irreducible_of_height_one (b : Bridge) (h : b.height = 1) : + b.Irreducible := by + intro r hr hrh + omega + +theorem zigzagTwo_irreducible : zigzagTwo.Irreducible := + zigzagTwo.irreducible_of_height_one rfl + +theorem zigzagFour_irreducible : zigzagFour.Irreducible := + zigzagFour.irreducible_of_height_one rfl + +theorem weight_pos (b : Bridge) : 0 < weight b := by + exact ENNReal.ofReal_pos.mpr (pow_pos rho_pos _) + +theorem weight_le_criticalMass (P : Bridge → Prop) (b : Bridge) (h : P b) : + weight b ≤ criticalMass P := by + classical + unfold criticalMass + have ht : (if P b then weight b else 0) ≤ + ∑' a : Bridge, if P a then weight a else 0 := + ENNReal.le_tsum (f := fun bridge : Bridge => if P bridge then weight bridge else 0) b + simpa only [ite_eq_left h] using ht + +def halfLengthMass (m : ℕ) : ℝ≥0∞ := + criticalMass (fun b => b.Irreducible ∧ b.length = 2*m) + +theorem halfLengthMass_one_pos : 0 < halfLengthMass 1 := by + have h : zigzagTwo.Irreducible ∧ zigzagTwo.length = 2*1 := + ⟨zigzagTwo_irreducible, rfl⟩ + exact (weight_pos zigzagTwo).trans_le (weight_le_criticalMass _ _ h) + +theorem halfLengthMass_two_pos : 0 < halfLengthMass 2 := by + have h : zigzagFour.Irreducible ∧ zigzagFour.length = 2*2 := + ⟨zigzagFour_irreducible, rfl⟩ + exact (weight_pos zigzagFour).trans_le (weight_le_criticalMass _ _ h) + +def SpanOne (w : ℕ → ℝ≥0∞) : Prop := + AddSubgroup.closure {z : ℤ | ∃ m n : ℕ, 0 < w m ∧ 0 < w n ∧ + z = (m : ℤ) - (n : ℤ)} = ⊤ + +theorem actual_halfLength_span_one : SpanOne halfLengthMass := by + apply top_unique + intro z _ + have hOne : (1 : ℤ) ∈ AddSubgroup.closure + {z : ℤ | ∃ m n : ℕ, 0 < halfLengthMass m ∧ 0 < halfLengthMass n ∧ + z = (m : ℤ) - (n : ℤ)} := by + apply AddSubgroup.subset_closure + exact ⟨2, 1, halfLengthMass_two_pos, halfLengthMass_one_pos, by norm_num⟩ + simpa using AddSubgroup.zsmul_mem _ hOne z + +def neighbors (v : Vertex) : Finset Vertex := + if v.up then + {down v.col (v.row-1), down v.col v.row, down (v.col-1) v.row} + else + {up v.col (v.row+1), up v.col v.row, up (v.col+1) v.row} + +theorem mem_neighbors_iff (v w : Vertex) : w ∈ neighbors v ↔ Adj v w := by + rcases v with ⟨i, j, s⟩ + rcases w with ⟨k, l, t⟩ + cases s <;> cases t <;> + simp [neighbors, Adj, UpDownAdj, up, down, Vertex.mk.injEq] <;> omega + +def walkLists (v : Vertex) : ℕ → Finset (List Vertex) + | 0 => {[v]} + | n+1 => (neighbors v).biUnion (fun w => (walkLists w n).image (List.cons v)) + +theorem isChain_mem_walkLists (v : Vertex) (xs : List Vertex) + (h : (v :: xs).IsChain Adj) : v :: xs ∈ walkLists v xs.length := by + induction xs generalizing v with + | nil => simp [walkLists] + | cons w xs ih => + obtain ⟨hvw, hc⟩ := List.isChain_cons_cons.mp h + change v :: w :: xs ∈ + (neighbors v).biUnion (fun a => (walkLists a xs.length).image (List.cons v)) + exact Finset.mem_biUnion.mpr ⟨w, (mem_neighbors_iff v w).mpr hvw, + Finset.mem_image.mpr ⟨w :: xs, ih w hc, rfl⟩⟩ + +theorem Bridge.vertices_mem_walkLists (b : Bridge) : + b.vertices ∈ walkLists (up 0 0) (b.length - 1) := by + have hh := b.initiates + cases hv : b.vertices with + | nil => simp [hv] at hh + | cons v xs => + have heq : v = up 0 0 := by simpa [hv] using hh + subst v + simpa [Bridge.length, hv] using + isChain_mem_walkLists (up 0 0) xs (by simpa [hv] using b.connected) + +theorem Bridge.length_pos (b : Bridge) : 0 < b.length := by + have hh := b.initiates + cases hv : b.vertices with + | nil => simp [hv] at hh + | cons v xs => simp [Bridge.length, hv] + +theorem Bridge.vertices_injective : Function.Injective Bridge.vertices := by + intro b c heq + rcases b with ⟨h, t, vs, hp, hs, hc, hi, ht, hv⟩ + rcases c with ⟨h', t', vs', hp', hs', hc', hi', ht', hv'⟩ + dsimp at heq + subst vs' + have he : down t ((h : ℤ)-1) = down t' ((h' : ℤ)-1) := + Option.some.inj (ht.symm.trans ht') + have het := congrArg Vertex.col he + have heh := congrArg Vertex.row he + dsimp [down] at het heh + have heh' : h = h' := by omega + subst t' + subst h' + rfl + +instance finiteBridgeLength (n : ℕ) : Finite {b : Bridge // b.length = n} := by + let f : {b : Bridge // b.length = n} → + {l : List Vertex // l ∈ walkLists (up 0 0) (n-1)} := fun b => + ⟨b.val.vertices, by simpa [b.property] using b.val.vertices_mem_walkLists⟩ + apply Finite.of_injective f + intro b c heq + apply Subtype.ext + apply Bridge.vertices_injective + exact congrArg Subtype.val heq + +instance finiteBridgeLengthEvent (n : ℕ) (P : Bridge → Prop) : + Finite {b : Bridge // b.length = n ∧ P b} := by + let f : {b : Bridge // b.length = n ∧ P b} → + {b : Bridge // b.length = n} := fun b => ⟨b.val, b.property.1⟩ + apply Finite.of_injective f + intro b c heq + apply Subtype.ext + exact congrArg (fun a : {b : Bridge // b.length = n} => a.val) heq + +theorem exactLengthMass_eq (n : ℕ) (P : Bridge → Prop) : + criticalMass (fun b => b.length = n ∧ P b) = + (Nat.card {b : Bridge // b.length = n ∧ P b} : ℝ≥0∞) * + ENNReal.ofReal (rho ^ n) := by + classical + let := Fintype.ofFinite {b : Bridge // b.length = n ∧ P b} + have hsub : criticalMass (fun b => b.length = n ∧ P b) = + ∑' b : {b : Bridge // b.length = n ∧ P b}, weight b.val := by + calc + criticalMass (fun b => b.length = n ∧ P b) = + ∑' b : Bridge, {b : Bridge | b.length = n ∧ P b}.indicator weight b := by + unfold criticalMass + apply tsum_congr + intro b + by_cases hb : b.length = n ∧ P b <;> simp [hb] + _ = _ := (tsum_subtype {b : Bridge | b.length = n ∧ P b} weight).symm + rw [hsub] + have hweights : (fun b : {b : Bridge // b.length = n ∧ P b} => weight b.val) = + fun _ => ENNReal.ofReal (rho ^ n) := by + funext b + simp only [weight, b.property.1] + rw [hweights, tsum_fintype] + simp [Nat.card_eq_fintype_card, nsmul_eq_mul] + +theorem lengthMass_eq (n : ℕ) : + criticalMass (fun b => b.length = n) = + (Nat.card {b : Bridge // b.length = n} : ℝ≥0∞) * + ENNReal.ofReal (rho ^ n) := by + classical + let := Fintype.ofFinite {b : Bridge // b.length = n} + have hsub : criticalMass (fun b => b.length = n) = + ∑' b : {b : Bridge // b.length = n}, weight b.val := by + calc + criticalMass (fun b => b.length = n) = + ∑' b : Bridge, {b : Bridge | b.length = n}.indicator weight b := by + unfold criticalMass + apply tsum_congr + intro b + by_cases hb : b.length = n <;> simp [hb] + _ = _ := (tsum_subtype {b : Bridge | b.length = n} weight).symm + rw [hsub] + have hweights : (fun b : {b : Bridge // b.length = n} => weight b.val) = + fun _ => ENNReal.ofReal (rho ^ n) := by + funext b + simp only [weight, b.property] + rw [hweights, tsum_fintype] + simp [Nat.card_eq_fintype_card, nsmul_eq_mul] + +theorem lengthMass_ne_top (n : ℕ) : criticalMass (fun b => b.length = n) ≠ ⊤ := by + rw [lengthMass_eq] + exact ENNReal.mul_ne_top (by simp) ENNReal.ofReal_ne_top + +theorem uniformLengthProbability_eq_critical_ratio (n : ℕ) (P : Bridge → Prop) : + uniformLengthProbability n P = + (criticalMass (fun b => b.length = n ∧ P b) / + criticalMass (fun b => b.length = n)).toReal := by + rw [exactLengthMass_eq, lengthMass_eq, ENNReal.toReal_div] + simp only [ENNReal.toReal_mul, ENNReal.toReal_natCast, + ENNReal.toReal_ofReal (le_of_lt (pow_pos rho_pos n))] + exact (mul_div_mul_right _ _ (ne_of_gt (pow_pos rho_pos n))).symm + +theorem Bridge.halfLength_pos (b : Bridge) : 0 < b.length / 2 := by + obtain ⟨k, hk⟩ := b.even_length + have hp := b.length_pos + omega + +theorem Bridge.twice_halfLength (b : Bridge) : 2 * (b.length / 2) = b.length := by + obtain ⟨k, hk⟩ := b.even_length + omega + +theorem halfLengthMass_eq_pushforward (m : ℕ) : + halfLengthMass m = criticalMass (fun b => b.Irreducible ∧ b.length / 2 = m) := by + unfold halfLengthMass + congr 1 + funext b + have he := b.twice_halfLength + exact propext (by constructor <;> rintro ⟨hI, hL⟩ <;> exact ⟨hI, by omega⟩) + +theorem halfLengthMass_zero : halfLengthMass 0 = 0 := by + classical + rw [halfLengthMass_eq_pushforward] + unfold criticalMass + calc + _ = ∑' _ : Bridge, (0 : ℝ≥0∞) := by + apply tsum_congr + intro b + split_ifs with hb + · have hp := b.halfLength_pos + omega + · rfl + _ = 0 := tsum_zero + +def rowVertex (k : ℕ) : Vertex := + if k % 2 = 0 then up ((k / 2 : ℕ) : ℤ) 0 else down ((k / 2 : ℕ) : ℤ) 0 + +theorem rowVertex_injective : Function.Injective rowVertex := by + intro k l h + have hc := congrArg Vertex.col h + have hs := congrArg Vertex.up h + by_cases hk : k % 2 = 0 <;> by_cases hl : l % 2 = 0 <;> + simp [rowVertex, hk, hl, up, down] at hc hs <;> omega + +theorem rowVertex_adj (k : ℕ) : Adj (rowVertex k) (rowVertex (k+1)) := by + by_cases hk : k % 2 = 0 + · have hk' : (k+1) % 2 ≠ 0 := by omega + have he : (k+1) / 2 = k / 2 := by omega + simp [rowVertex, hk, hk', Adj, UpDownAdj, up, down, he] + · have hk' : (k+1) % 2 = 0 := by omega + have he : (k+1) / 2 = k / 2 + 1 := by omega + simp [rowVertex, hk, hk', Adj, UpDownAdj, up, down, he] + +def rowZigzag (m : ℕ) (hm : 0 < m) : Bridge where + height := 1 + terminal := m - 1 + vertices := List.ofFn (fun i : Fin (2*m) => rowVertex i.val) + height_pos := by decide + self_avoiding := List.nodup_ofFn.mpr (rowVertex_injective.comp Fin.val_injective) + connected := by + rw [List.isChain_iff_getElem] + intro i hi + simp only [List.getElem_ofFn] + exact rowVertex_adj i + initiates := by + rw [List.head?_eq_getElem?] + simp [show 0 < 2*m by omega, rowVertex] + terminates := by + rw [List.getLast?_eq_getElem?] + have hn : 2*m-1 < 2*m := by omega + have hp : (2*m-1) % 2 ≠ 0 := by omega + have hq : (2*m-1) / 2 = m-1 := by omega + simp only [List.length_ofFn, List.getElem?_ofFn, dite_eq_left hn] + simp only [rowVertex, hp, ite_false, hq] + norm_num [Nat.cast_sub (by omega : 1 ≤ m)] + in_strip := by + intro v hv + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp hv + simp [rowVertex, up, down] + split_ifs <;> simp + +theorem rowZigzag_length (m : ℕ) (hm : 0 < m) : (rowZigzag m hm).length = 2*m := by + simp [Bridge.length, rowZigzag] + +theorem rowZigzag_irreducible (m : ℕ) (hm : 0 < m) : (rowZigzag m hm).Irreducible := by + intro r hr hr' + change r < 1 at hr' + omega + +theorem nonempty_bridgeLength (m : ℕ) (hm : 0 < m) : + Nonempty {b : Bridge // b.length = 2*m} := + ⟨⟨rowZigzag m hm, rowZigzag_length m hm⟩⟩ + +theorem card_bridgeLength_pos (m : ℕ) (hm : 0 < m) : + 0 < Nat.card {b : Bridge // b.length = 2*m} := by + let := nonempty_bridgeLength m hm + exact Nat.card_pos + +theorem Bridge.trace_finite (b : Bridge) : b.trace.Finite := by + exact (Set.toFinite _).union (b.vertices.finite_toSet.image position) + +theorem Bridge.endpointDistance_le_diameter (b : Bridge) : + b.endpointDistance ≤ b.diameter := by + apply Metric.dist_le_diam_of_mem b.trace_finite.isBounded <;> simp [trace] + +def IrreducibleNormalization : Prop := criticalMass Bridge.Irreducible = 1 + +def lengthLaplaceReward (u : ℝ) : ℝ≥0∞ := by + classical + exact ∑' b : Bridge, if b.Irreducible then + weight b * ENNReal.ofReal (1 - Real.exp (-u * (b.length : ℝ))) else 0 + +def ActualLengthTailBound : Prop := + ∃ C n₀ : ℝ, 0 < C ∧ 0 < n₀ ∧ ∀ n : ℝ, n₀ ≤ n → + criticalMass (fun b => b.Irreducible ∧ n < (b.length : ℝ)) ≤ + ENNReal.ofReal (C * n ^ (-(9/16 : ℝ))) + +def ActualLengthLaplaceLower : Prop := + ∃ c u₀ : ℝ, 0 < c ∧ 0 < u₀ ∧ ∀ u : ℝ, 0 < u → u ≤ u₀ → + ENNReal.ofReal (c * u ^ (9/16 : ℝ)) ≤ lengthLaplaceReward u + +def ActualLengthLaplaceUpper : Prop := + ∃ C u₀ : ℝ, 0 < C ∧ 0 < u₀ ∧ ∀ u : ℝ, 0 < u → u ≤ u₀ → + lengthLaplaceReward u ≤ ENNReal.ofReal (C * u ^ (9/16 : ℝ)) + +end HoneycombActual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombBridges/Concatenation.lean b/lean/OAI/Combinatorics/HoneycombBridges/Concatenation.lean new file mode 100644 index 0000000000000000000000000000000000000000..44e8a045444b99eb7a5a8ee3a6e694a93cf32639 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombBridges/Concatenation.lean @@ -0,0 +1,433 @@ +import Mathlib +import OAI.Combinatorics.HoneycombBridges.Basic + +namespace OAI + +/-! Bridge concatenation and single-crossing cuts. -/ + +noncomputable section +open scoped ENNReal +open Filter + +namespace HoneycombActual + +def shiftVertex (i j : ℤ) (v : Vertex) : Vertex := + ⟨v.col + i, v.row + j, v.up⟩ + +def concatenateVertices : List Bridge → List Vertex + | [] => [] + | b :: bs => b.vertices ++ + (concatenateVertices bs).map (shiftVertex b.terminal b.height) + +def BridgeFactorizationLaw : Prop := + ∀ b : Bridge, ∃! bs : List Bridge, + (∀ a ∈ bs, a.Irreducible) ∧ concatenateVertices bs = b.vertices + + + +@[simp] theorem shiftVertex_col (i j : ℤ) (v : Vertex) : + (shiftVertex i j v).col = v.col + i := rfl +@[simp] theorem shiftVertex_row (i j : ℤ) (v : Vertex) : + (shiftVertex i j v).row = v.row + j := rfl +@[simp] theorem shiftVertex_side (i j : ℤ) (v : Vertex) : + (shiftVertex i j v).up = v.up := rfl +@[simp] theorem shiftVertex_up (i j a b : ℤ) : + shiftVertex i j (up a b) = up (a+i) (b+j) := rfl +@[simp] theorem shiftVertex_down (i j a b : ℤ) : + shiftVertex i j (down a b) = down (a+i) (b+j) := rfl +@[simp] theorem shiftVertex_zero (v : Vertex) : shiftVertex 0 0 v = v := by + cases v; simp [shiftVertex] +@[simp] theorem shiftVertex_shift (i j k l : ℤ) (v : Vertex) : + shiftVertex i j (shiftVertex k l v) = shiftVertex (k+i) (l+j) v := by + cases v; simp [shiftVertex, add_assoc] + +theorem shiftVertex_injective (i j : ℤ) : Function.Injective (shiftVertex i j) := by + intro v w h + have he := congrArg (shiftVertex (-i) (-j)) h + simpa using he + +@[simp] theorem shiftVertex_adj (i j : ℤ) (v w : Vertex) : + Adj (shiftVertex i j v) (shiftVertex i j w) ↔ Adj v w := by + simp only [Adj, UpDownAdj, shiftVertex_col, shiftVertex_row, shiftVertex_side] + constructor <;> intro h <;> rcases h with ⟨hv, hw, h⟩ | ⟨hw, hv, h⟩ + · left; refine ⟨hv, hw, ?_⟩; omega + · right; refine ⟨hw, hv, ?_⟩; omega + · left; refine ⟨hv, hw, ?_⟩; omega + · right; refine ⟨hw, hv, ?_⟩; omega + +namespace Bridge + +theorem vertices_ne_nil (b : Bridge) : b.vertices ≠ [] := by + intro h + have := b.initiates + simp [h] at this + +def concat (b c : Bridge) : Bridge where + height := b.height + c.height + terminal := b.terminal + c.terminal + vertices := b.vertices ++ c.vertices.map (shiftVertex b.terminal b.height) + height_pos := by have := b.height_pos; omega + self_avoiding := by + refine List.nodup_append.mpr ⟨b.self_avoiding, + c.self_avoiding.map (shiftVertex_injective _ _), ?_⟩ + intro v hv w hw he + obtain ⟨z, hz, rfl⟩ := List.mem_map.mp hw + have hv' := (b.in_strip v hv).2 + have hz' := (c.in_strip z hz).1 + have her := congrArg Vertex.row he + simp only [shiftVertex_row] at her + omega + connected := by + refine b.connected.append + (List.isChain_map_of_isChain (shiftVertex b.terminal b.height) + (fun v w h => (shiftVertex_adj _ _ _ _).mpr h) c.connected) ?_ + intro v hv w hw + have hv' : v = down b.terminal ((b.height : ℤ)-1) := by + symm; simpa [b.terminates] using hv + have hw' : w = up b.terminal b.height := by + symm; simpa [List.head?_map, c.initiates] using hw + subst v; subst w + simp [Adj, UpDownAdj, up, down] + initiates := by simp [List.head?_append, b.initiates] + terminates := by + simp [List.getLast?_append, List.getLast?_map, c.terminates, b.terminates, + sub_eq_add_neg, add_comm, add_assoc] + in_strip := by + intro v hv + rcases List.mem_append.mp hv with hb | hc + · have := b.in_strip v hb + constructor + · exact this.1 + · push_cast; have := c.height_pos; omega + · obtain ⟨z, hz, rfl⟩ := List.mem_map.mp hc + have := c.in_strip z hz + simp only [shiftVertex_row, Nat.cast_add] + constructor <;> omega + +@[simp] theorem concat_vertices (b c : Bridge) : + (b.concat c).vertices = b.vertices ++ c.vertices.map (shiftVertex b.terminal b.height) := rfl +@[simp] theorem concat_height (b c : Bridge) : (b.concat c).height = b.height + c.height := rfl +@[simp] theorem concat_terminal (b c : Bridge) : (b.concat c).terminal = b.terminal + c.terminal := rfl +@[simp] theorem concat_length (b c : Bridge) : (b.concat c).length = b.length + c.length := by + simp [length] + +theorem concat_assoc (a b c : Bridge) : (a.concat b).concat c = a.concat (b.concat c) := by + apply vertices_injective + simp only [concat_vertices, concat_height, concat_terminal, List.map_append, List.map_map, + Function.comp_def, shiftVertex_shift, Nat.cast_add, List.append_assoc] + congr 2 + apply List.map_congr_left + intro v hv + congr 1 <;> omega + +end Bridge + +@[simp] theorem weight_concat (b c : Bridge) : weight (b.concat c) = weight b * weight c := by + simp only [weight, Bridge.concat_length, pow_add] + exact ENNReal.ofReal_mul (pow_nonneg rho_pos.le _) + +end HoneycombActual + +namespace HoneycombActual.RenewalList + +def changes {α : Type*} (q : α → Bool) (xs : List α) : ℕ := + (xs.zip xs.tail).countP (fun e => decide (q e.1 ≠ q e.2)) + +@[simp] theorem changes_nil {α : Type*} (q : α → Bool) : changes q [] = 0 := rfl +@[simp] theorem changes_singleton {α : Type*} (q : α → Bool) (x : α) : + changes q [x] = 0 := rfl + +@[simp] theorem changes_cons_cons {α : Type*} (q : α → Bool) (x y : α) (xs : List α) : + changes q (x :: y :: xs) = changes q (y :: xs) + if q x = q y then 0 else 1 := by + simp only [changes, List.tail_cons, List.zip_cons_cons, List.countP_cons] + by_cases h : q x = q y <;> simp [h] + +theorem constant_of_changes_zero {α : Type*} (q : α → Bool) (x : α) (xs : List α) + (h : changes q (x :: xs) = 0) : ∀ y ∈ x :: xs, q y = q x := by + induction xs generalizing x with + | nil => simp + | cons z xs ih => + rw [changes_cons_cons] at h + have he : q x = q z := by split_ifs at h with he; omega + have hz : changes q (z :: xs) = 0 := by simp [he] at h; exact h + intro y hy + rcases List.mem_cons.mp hy with rfl | hy + · rfl + · exact (ih z hz y hy).trans he.symm + +theorem split_of_changes_one {α : Type*} (q : α → Bool) (x : α) (xs : List α) + (hx : q x = true) (h : changes q (x :: xs) = 1) : + ∃ lo hi : List α, x :: xs = lo ++ hi ∧ lo ≠ [] ∧ hi ≠ [] ∧ + (∀ y ∈ lo, q y = true) ∧ (∀ y ∈ hi, q y = false) := by + induction xs generalizing x with + | nil => simp at h + | cons z xs ih => + by_cases hz : q z = true + · have hc : changes q (z :: xs) = 1 := by simpa [hx, hz] using h + obtain ⟨lo, hi, he, hlo, hhi, hl, hu⟩ := ih z hz hc + refine ⟨x :: lo, hi, by rw [he]; rfl, List.cons_ne_nil _ _, hhi, ?_, hu⟩ + intro y hy + rcases List.mem_cons.mp hy with rfl | hy + · exact hx + · exact hl y hy + · have hz' : q z = false := Bool.eq_false_iff.mpr hz + have hc : changes q (z :: xs) = 0 := by simpa [hx, hz'] using h + refine ⟨[x], z :: xs, rfl, List.cons_ne_nil _ _, List.cons_ne_nil _ _, ?_, ?_⟩ + · intro y hy + have : y = x := by simpa using hy + simpa [this] using hx + · intro y hy + exact (constant_of_changes_zero q z xs hc y hy).trans hz' + +end HoneycombActual.RenewalList + +namespace HoneycombActual + +def below (r : ℕ) (v : Vertex) : Bool := decide (v.row < (r : ℤ)) + +theorem crosses_eq_change (r : ℕ) (v w : Vertex) : + Bridge.crosses r (v,w) = decide (below r v ≠ below r w) := by + by_cases hv : v.row < (r : ℤ) <;> by_cases hw : w.row < (r : ℤ) + all_goals simp [Bridge.crosses, below, hv, hw] <;> omega + +theorem crossingCount_eq_changes (b : Bridge) (r : ℕ) : + b.crossingCount r = RenewalList.changes (below r) b.vertices := by + unfold Bridge.crossingCount RenewalList.changes + congr 1 + funext e + exact crosses_eq_change r e.1 e.2 + +theorem upward_crossing_shape (r : ℤ) {v w : Vertex} + (ha : Adj v w) (hv : v.row < r) (hw : r ≤ w.row) : + ∃ i : ℤ, v = down i (r-1) ∧ w = up i r := by + rcases v with ⟨vc, vr, vu⟩ + rcases w with ⟨wc, wr, wu⟩ + simp only [Adj, UpDownAdj] at ha + dsimp at ha hv hw + rcases ha with ⟨hv', hw', hs⟩ | ⟨hw', hv', hs⟩ + · rcases hs with hs | hs | hs <;> omega + · subst vu; subst wu + rcases hs with ⟨hc, hr⟩ | ⟨hc, hr⟩ | ⟨hc, hr⟩ + · have he : vr = r-1 := by omega + have he' : wr = r := by omega + refine ⟨wc, ?_, ?_⟩ <;> simp [up, down, hc, he, he'] + · omega + · omega + +namespace Bridge + +theorem split_at_of_crossingCount_one (b : Bridge) (r : ℕ) + (hr : 0 < r) (hrb : r < b.height) (hc : b.crossingCount r = 1) : + ∃ a c : Bridge, a.height = r ∧ b = a.concat c := by + obtain ⟨xs, hxs⟩ := List.head?_eq_some_iff.mp b.initiates + have hc' : RenewalList.changes (below r) (up 0 0 :: xs) = 1 := by + simpa [crossingCount_eq_changes, hxs] using hc + have hb : below r (up 0 0) = true := by simp [below, up]; omega + obtain ⟨lo, hi, hlohi, hlo, hhi, hlow, hhigh⟩ := + RenewalList.split_of_changes_one (below r) (up 0 0) xs hb hc' + have he : b.vertices = lo ++ hi := hxs.trans hlohi + have hlo_sub (v : Vertex) (hv : v ∈ lo) : v ∈ b.vertices := by + rw [he]; exact List.mem_append_left _ hv + have hhi_sub (v : Vertex) (hv : v ∈ hi) : v ∈ b.vertices := by + rw [he]; exact List.mem_append_right _ hv + have hlr (v : Vertex) (hv : v ∈ lo) : v.row < (r : ℤ) := by + simpa [below] using hlow v hv + have hhr (v : Vertex) (hv : v ∈ hi) : (r : ℤ) ≤ v.row := by + have := hhigh v hv + simpa [below, not_lt] using this + have hchain := List.isChain_append.mp (he ▸ b.connected) + let v := lo.getLast hlo + let w := hi.head hhi + have hlv : lo.getLast? = some v := List.getLast?_eq_some_getLast hlo + have hhw : hi.head? = some w := List.head?_eq_some_head hhi + have hv : v ∈ lo := List.getLast_mem hlo + have hw : w ∈ hi := List.head_mem hhi + have hvw : Adj v w := hchain.2.2 v (by simp [hlv]) w (by simp [hhw]) + obtain ⟨i, hvi, hwi⟩ := upward_crossing_shape (r : ℤ) hvw (hlr v hv) (hhr w hw) + have hn := List.nodup_append.mp (he ▸ b.self_avoiding) + have hlhead : lo.head? = some (up 0 0) := by + have := b.initiates + rw [he, List.head?_append] at this + cases hh : lo.head? with + | none => exact False.elim (hlo (List.head?_eq_none_iff.mp hh)) + | some z => simpa [hh] using this + have hhlast : hi.getLast? = some (down b.terminal ((b.height : ℤ)-1)) := by + have := b.terminates + rw [he, List.getLast?_append] at this + cases hh : hi.getLast? with + | none => exact False.elim (hhi (List.getLast?_eq_none_iff.mp hh)) + | some z => simpa [hh] using this + let a : Bridge := { + height := r + terminal := i + vertices := lo + height_pos := hr + self_avoiding := hn.1 + connected := hchain.1 + initiates := hlhead + terminates := by simpa [hvi] using hlv + in_strip := by + intro z hz + exact ⟨(b.in_strip z (hlo_sub z hz)).1, hlr z hz⟩ } + let c : Bridge := { + height := b.height - r + terminal := b.terminal - i + vertices := hi.map (shiftVertex (-i) (-(r : ℤ))) + height_pos := by omega + self_avoiding := hn.2.1.map (shiftVertex_injective _ _) + connected := List.isChain_map_of_isChain _ + (fun z z' ha => (shiftVertex_adj _ _ _ _).mpr ha) hchain.2.1 + initiates := by simp [List.head?_map, hhw, hwi] + terminates := by + simp only [List.getLast?_map, hhlast, Option.map_some, shiftVertex_down, + Nat.cast_sub hrb.le] + congr 1; congr 1; omega + in_strip := by + intro z hz + obtain ⟨y, hy, rfl⟩ := List.mem_map.mp hz + have hs := (b.in_strip y (hhi_sub y hy)).2 + have hr' := hhr y hy + simp only [shiftVertex_row, Nat.cast_sub hrb.le] + constructor <;> omega } + refine ⟨a, c, rfl, ?_⟩ + apply vertices_injective + simp only [concat_vertices] + change b.vertices = lo ++ (hi.map (shiftVertex (-i) (-(r : ℤ)))).map (shiftVertex i r) + simpa [List.map_map, Function.comp_def] using he + +end Bridge +end HoneycombActual + +namespace HoneycombActual.RenewalList + +theorem changes_zero_of_constant {α : Type*} (q : α → Bool) (xs : List α) (a : Bool) + (h : ∀ x ∈ xs, q x = a) : changes q xs = 0 := by + induction xs with + | nil => rfl + | cons x xs ih => + cases xs with + | nil => rfl + | cons y ys => + rw [changes_cons_cons, ih (by intro z hz; exact h z (List.mem_cons_of_mem _ hz))] + simp [h x (by simp), h y (by simp)] + +theorem changes_append {α : Type*} (q : α → Bool) (lo hi : List α) (v w : α) + (hl : lo.getLast? = some v) (hh : hi.head? = some w) : + changes q (lo ++ hi) = changes q lo + changes q hi + if q v = q w then 0 else 1 := by + induction lo generalizing v with + | nil => simp at hl + | cons x xs ih => + cases xs with + | nil => + have hx : x = v := by simpa using hl + obtain ⟨ys, rfl⟩ := List.head?_eq_some_iff.mp hh + simp [hx] + | cons y ys => + have hl' : (y :: ys).getLast? = some v := by simpa using hl + simp only [List.cons_append, changes_cons_cons] + have hih := ih v hl' + simp only [List.cons_append] at hih + omega + +theorem takeWhile_append_of_sides {α : Type*} (q : α → Bool) (lo hi : List α) + (hl : ∀ x ∈ lo, q x = true) (hh : ∀ x ∈ hi, q x = false) : + (lo ++ hi).takeWhile q = lo := by + induction lo with + | nil => + cases hi with + | nil => rfl + | cons y ys => simp [hh y (by simp)] + | cons x xs ih => + simp only [List.cons_append, List.takeWhile_cons] + rw [hl x (by simp)] + simpa using congrArg (List.cons x) + (ih (by intro y hy; exact hl y (List.mem_cons_of_mem _ hy))) + +end HoneycombActual.RenewalList + +namespace HoneycombActual.Bridge + +@[simp] theorem concat_crossing_at (b c : Bridge) : + (b.concat c).crossingCount b.height = 1 := by + let hi := c.vertices.map (shiftVertex b.terminal b.height) + have hl0 : RenewalList.changes (below b.height) b.vertices = 0 := + RenewalList.changes_zero_of_constant _ _ true (by + intro v hv; simpa [below] using (b.in_strip v hv).2) + have hh0 : RenewalList.changes (below b.height) hi = 0 := + RenewalList.changes_zero_of_constant _ _ false (by + intro v hv + obtain ⟨z, hz, rfl⟩ := List.mem_map.mp hv + have := (c.in_strip z hz).1 + simp [below]; omega) + have hlast : below b.height (down b.terminal ((b.height : ℤ)-1)) = true := by + simp [below, down] + have hfirst : below b.height (up b.terminal b.height) = false := by simp [below, up] + have hc := RenewalList.changes_append (below b.height) b.vertices hi + (down b.terminal ((b.height : ℤ)-1)) (up b.terminal b.height) + b.terminates (by simp [hi, List.head?_map, c.initiates]) + simpa [crossingCount_eq_changes, concat_vertices, hi, hl0, hh0, hlast, hfirst] using hc + +theorem concat_crossing_below (b c : Bridge) (r : ℕ) (hr : r < b.height) : + (b.concat c).crossingCount r = b.crossingCount r := by + let hi := c.vertices.map (shiftVertex b.terminal b.height) + have hh0 : RenewalList.changes (below r) hi = 0 := + RenewalList.changes_zero_of_constant _ _ false (by + intro v hv + obtain ⟨z, hz, rfl⟩ := List.mem_map.mp hv + have hz0 := (c.in_strip z hz).1 + change decide (z.row + (b.height : ℤ) < (r : ℤ)) = false + simp only [decide_eq_false_iff_not, not_lt] + omega) + have hlast : below r (down b.terminal ((b.height : ℤ)-1)) = false := by + simp [below, down]; omega + have hfirst : below r (up b.terminal b.height) = false := by simp [below, up]; omega + have hc := RenewalList.changes_append (below r) b.vertices hi + (down b.terminal ((b.height : ℤ)-1)) (up b.terminal b.height) + b.terminates (by simp [hi, List.head?_map, c.initiates]) + simpa [crossingCount_eq_changes, concat_vertices, hi, hh0, hlast, hfirst] using hc + +theorem takeWhile_concat (b c : Bridge) : + (b.concat c).vertices.takeWhile (below b.height) = b.vertices := by + apply RenewalList.takeWhile_append_of_sides + · intro v hv + simpa [below] using (b.in_strip v hv).2 + · intro v hv + obtain ⟨z, hz, rfl⟩ := List.mem_map.mp hv + have := (c.in_strip z hz).1 + simp [below]; omega + +theorem concat_first_eq_of_height_eq {a b c d : Bridge} + (he : a.concat b = c.concat d) (hh : a.height = c.height) : a = c := by + apply vertices_injective + calc + a.vertices = (a.concat b).vertices.takeWhile (below a.height) := (takeWhile_concat _ _).symm + _ = (c.concat d).vertices.takeWhile (below c.height) := by rw [he, hh] + _ = c.vertices := takeWhile_concat _ _ + +theorem concat_left_cancel {a b c : Bridge} (he : a.concat b = a.concat c) : b = c := by + apply vertices_injective + have hv := congrArg Bridge.vertices he + simp only [concat_vertices, List.append_cancel_left_eq] at hv + have hi := congrArg (List.map (shiftVertex (-a.terminal) (-(a.height : ℤ)))) hv + simpa [List.map_map, Function.comp_def] using hi + +theorem concat_irreducible_first_height_eq {a b c d : Bridge} + (ha : a.Irreducible) (hc : c.Irreducible) (he : a.concat b = c.concat d) : + a.height = c.height := by + apply le_antisymm + · by_contra hn + have hh : c.height < a.height := by omega + have hf : (a.concat b).crossingCount c.height = 1 := by rw [he]; exact concat_crossing_at _ _ + rw [concat_crossing_below _ _ _ hh] at hf + exact ha _ c.height_pos hh hf + · by_contra hn + have hh : a.height < c.height := by omega + have hf : (c.concat d).crossingCount a.height = 1 := by rw [← he]; exact concat_crossing_at _ _ + rw [concat_crossing_below _ _ _ hh] at hf + exact hc _ a.height_pos hh hf + +end HoneycombActual.Bridge + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombBridges/ExactLength.lean b/lean/OAI/Combinatorics/HoneycombBridges/ExactLength.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b9b2011ec08a5696be12848169cd2c66a9a404e --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombBridges/ExactLength.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Combinatorics.HoneycombBridges.LengthTransform + +namespace OAI + +/-! Exact-length renewal coefficients and bridge probabilities. -/ + +noncomputable section +open scoped ENNReal +open Filter + +namespace HoneycombActual + +def irreducibleListLength (bs : List IrreducibleBridge) : ℕ := + (bs.map (fun b => b.val.length)).sum + +def irreducibleListWeight (bs : List IrreducibleBridge) : ℝ≥0∞ := + (bs.map (fun b => weight b.val)).prod + +def exactPieceMass (n k : ℕ) : ℝ≥0∞ := by + classical + exact ∑' bs : {bs : List IrreducibleBridge // bs.length = k}, + if irreducibleListLength bs.val = n then irreducibleListWeight bs.val else 0 + +@[simp] theorem discountedWeight_zero (b : Bridge) : discountedWeight 0 0 b = weight b := by + simp [discountedWeight] + +theorem optionLength_irreducibleProduct_nat (bs : List IrreducibleBridge) : + optionLength (irreducibleProduct bs) = irreducibleListLength bs := by + simp [irreducibleProduct, optionLength_bridgeProduct, irreducibleListLength] + +theorem optionWeight_irreducibleProduct_zero (bs : List IrreducibleBridge) : + optionWeight 0 0 (irreducibleProduct bs) = irreducibleListWeight bs := by + simpa [irreducibleListWeight] using optionWeight_irreducibleProduct 0 0 bs + +theorem lengthMass_eq_listMass (n : ℕ) (hn : 0 < n) : + criticalMass (fun b => b.length = n) = ∑' bs : List IrreducibleBridge, + if irreducibleListLength bs = n then irreducibleListWeight bs else 0 := by + classical + let f : Option Bridge → ℝ≥0∞ := fun b => + if optionLength b = n then optionWeight 0 0 b else 0 + have hf : (∑' b : Option Bridge, f b) = criticalMass (fun b => b.length = n) := by + rw [← (Equiv.optionEquivSumPUnit.{0,0} Bridge).symm.tsum_eq f, + ENNReal.summable.tsum_sum ENNReal.summable] + simp [f, optionLength, optionWeight, hn.ne, criticalMass, tsum_fintype] + apply tsum_congr + intro b + by_cases hb : b.length = n <;> simp [hb] + rw [← hf, ← irreducibleProductEquiv.tsum_eq f] + apply tsum_congr + intro bs + change (if optionLength (irreducibleProduct bs) = n then + optionWeight 0 0 (irreducibleProduct bs) else 0) = _ + rw [optionLength_irreducibleProduct_nat, optionWeight_irreducibleProduct_zero] + +theorem lengthMass_eq_tsum_exactPieceMass (n : ℕ) (hn : 0 < n) : + criticalMass (fun b => b.length = n) = ∑' k : ℕ, exactPieceMass n k := by + classical + rw [lengthMass_eq_listMass n hn, + ← ENNReal.tsum_fiberwise (fun bs : List IrreducibleBridge => + if irreducibleListLength bs = n then irreducibleListWeight bs else 0) List.length] + rfl + +theorem exactPieceMass_zero_count (n : ℕ) (hn : 0 < n) : exactPieceMass n 0 = 0 := by + classical + apply ENNReal.tsum_eq_zero.mpr + intro bs + have he : bs.val = [] := List.length_eq_zero_iff.mp bs.property + simp [he, irreducibleListLength, hn.ne] + +theorem exactLengthRenewalIdentity (m : ℕ) (hm : 0 < m) : + criticalMass (fun b => b.length = 2*m) = + ∑' k : ℕ, exactPieceMass (2*m) (k+1) := by + rw [lengthMass_eq_tsum_exactPieceMass (2*m) (by omega), + tsum_eq_zero_add' ENNReal.summable, + exactPieceMass_zero_count (2*m) (by omega), zero_add] + +theorem two_mul_pieceCount_le_length (bs : List IrreducibleBridge) : + 2 * bs.length ≤ irreducibleListLength bs := by + induction bs with + | nil => simp [irreducibleListLength] + | cons b bs ih => + have hpos := b.val.halfLength_pos + have he := b.val.twice_halfLength + simp only [List.length_cons, irreducibleListLength, List.map_cons, List.sum_cons] at ih ⊢ + omega + +theorem exactPieceMass_eq_zero_of_halfLength_lt (m k : ℕ) (hk : m < k) : + exactPieceMass (2*m) k = 0 := by + classical + apply ENNReal.tsum_eq_zero.mpr + intro bs + have h := two_mul_pieceCount_le_length bs.val + have he : irreducibleListLength bs.val ≠ 2*m := by + rw [bs.property] at h + omega + simp [he] + +theorem exactLengthRenewalMass_pos_finite (m : ℕ) (hm : 0 < m) : + 0 < (∑' k : ℕ, exactPieceMass (2*m) (k+1)) ∧ + (∑' k : ℕ, exactPieceMass (2*m) (k+1)) < ⊤ := by + rw [← exactLengthRenewalIdentity m hm] + refine ⟨?_, (lengthMass_ne_top (2*m)).lt_top⟩ + exact (weight_pos (rowZigzag m hm)).trans_le + (weight_le_criticalMass _ _ (rowZigzag_length m hm)) + + + +theorem uniformLengthProbability_mem_unitInterval (n : ℕ) (P : Bridge → Prop) : + 0 ≤ uniformLengthProbability n P ∧ uniformLengthProbability n P ≤ 1 := by + constructor + · exact div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + · let inclusion : {b : Bridge // b.length = n ∧ P b} → + {b : Bridge // b.length = n} := fun b => ⟨b.val, b.property.1⟩ + have hi : Function.Injective inclusion := by + intro b c he + apply Subtype.ext + exact congrArg (fun a : {b : Bridge // b.length = n} => a.val) he + have hc := Nat.card_le_card_of_injective inclusion hi + exact div_le_one_of_le₀ (by exact_mod_cast hc) (Nat.cast_nonneg _) + +theorem uniformLengthProbability_univ (m : ℕ) (hm : 0 < m) : + uniformLengthProbability (2*m) (fun _ => True) = 1 := by + rw [uniformLengthProbability_eq_critical_ratio] + simp only [and_true] + have hp : 0 < criticalMass (fun b => b.length = 2*m) := + (weight_pos (rowZigzag m hm)).trans_le + (weight_le_criticalMass _ _ (rowZigzag_length m hm)) + rw [ENNReal.div_self hp.ne' (lengthMass_ne_top (2*m))] + norm_num + +end HoneycombActual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombBridges/Factorization.lean b/lean/OAI/Combinatorics/HoneycombBridges/Factorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..6afadc62c117aa60f7a9c14199d4bfe63fdf0fe6 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombBridges/Factorization.lean @@ -0,0 +1,165 @@ +import Mathlib +import OAI.Combinatorics.HoneycombBridges.Concatenation + +namespace OAI + +/-! Unique irreducible factorization of strict bridges. -/ + +noncomputable section +open scoped ENNReal +open Filter + +namespace HoneycombActual + +def bridgeProduct : List Bridge → Option Bridge + | [] => none + | b :: bs => some (match bridgeProduct bs with + | none => b + | some c => b.concat c) + +@[simp] theorem bridgeProduct_nil : bridgeProduct [] = none := rfl +@[simp] theorem bridgeProduct_singleton (b : Bridge) : bridgeProduct [b] = some b := rfl + +@[simp] theorem bridgeProduct_eq_none_iff (bs : List Bridge) : + bridgeProduct bs = none ↔ bs = [] := by + cases bs <;> simp [bridgeProduct] + +theorem bridgeProduct_exists_of_ne_nil (bs : List Bridge) (hn : bs ≠ []) : + ∃ b : Bridge, bridgeProduct bs = some b := by + cases he : bridgeProduct bs with + | none => exact False.elim (hn ((bridgeProduct_eq_none_iff _).mp he)) + | some b => exact ⟨b, rfl⟩ + +theorem bridgeProduct_vertices {bs : List Bridge} {b : Bridge} + (h : bridgeProduct bs = some b) : concatenateVertices bs = b.vertices := by + induction bs generalizing b with + | nil => simp at h + | cons a as ih => + cases he : bridgeProduct as with + | none => + have hn := (bridgeProduct_eq_none_iff _).mp he + subst as + have hb : a = b := by simpa using h + subst b + simp [concatenateVertices] + | some c => + have hb : a.concat c = b := by simpa [bridgeProduct, he] using h + rw [← hb, concatenateVertices, ih he] + rfl + +theorem bridgeProduct_of_vertices {bs : List Bridge} {b : Bridge} + (h : concatenateVertices bs = b.vertices) : bridgeProduct bs = some b := by + have hn : bs ≠ [] := by + intro he + subst bs + exact b.vertices_ne_nil (by simpa [concatenateVertices] using h.symm) + obtain ⟨c, hc⟩ := bridgeProduct_exists_of_ne_nil bs hn + have he : c = b := Bridge.vertices_injective ((bridgeProduct_vertices hc).symm.trans h) + simpa [he] using hc + +theorem bridgeProduct_append {as bs : List Bridge} {a b : Bridge} + (ha : bridgeProduct as = some a) (hb : bridgeProduct bs = some b) : + bridgeProduct (as ++ bs) = some (a.concat b) := by + induction as generalizing a with + | nil => simp at ha + | cons c cs ih => + cases hc : bridgeProduct cs with + | none => + have hn := (bridgeProduct_eq_none_iff _).mp hc + subst cs + have he : c = a := by simpa using ha + subst a + simp [bridgeProduct, hb] + | some d => + have he : c.concat d = a := by simpa [bridgeProduct, hc] using ha + rw [← he] + simp [bridgeProduct, ih hc, Bridge.concat_assoc] + +theorem irreducible_factorization_exists (b : Bridge) : + ∃ bs : List Bridge, bridgeProduct bs = some b ∧ ∀ a ∈ bs, a.Irreducible := by + classical + induction h : b.height using Nat.strong_induction_on generalizing b with + | h n ih => + by_cases hb : b.Irreducible + · exact ⟨[b], rfl, by simpa using hb⟩ + · simp only [Bridge.Irreducible, not_forall, not_not] at hb + obtain ⟨r, hr, hrb, hc⟩ := hb + obtain ⟨a, c, har, hac⟩ := b.split_at_of_crossingCount_one r hr hrb hc + have hca : c.height < b.height := by + have hp := a.height_pos + have hh := congrArg Bridge.height hac + simp only [Bridge.concat_height] at hh + omega + obtain ⟨as, has, hai⟩ := ih a.height (by omega) a rfl + obtain ⟨cs, hcs, hci⟩ := ih c.height (by omega) c rfl + refine ⟨as ++ cs, ?_, ?_⟩ + · rw [bridgeProduct_append has hcs, ← hac] + · intro d hd + exact (List.mem_append.mp hd).elim (hai d) (hci d) + + + +theorem Bridge.concat_not_irreducible (a b : Bridge) : ¬ (a.concat b).Irreducible := by + intro h + have hb := b.height_pos + exact h a.height a.height_pos (by simp; omega) (a.concat_crossing_at b) + +theorem irreducible_product_unique (as bs : List Bridge) + (ha : ∀ a ∈ as, a.Irreducible) (hb : ∀ b ∈ bs, b.Irreducible) + (he : bridgeProduct as = bridgeProduct bs) : as = bs := by + induction as generalizing bs with + | nil => + have hnil : bs = [] := (bridgeProduct_eq_none_iff bs).mp he.symm + exact hnil.symm + | cons a as ih => + cases bs with + | nil => simp [bridgeProduct] at he + | cons c cs => + have hai : a.Irreducible := ha a (by simp) + have hci : c.Irreducible := hb c (by simp) + cases hpa : bridgeProduct as with + | none => + have hn := (bridgeProduct_eq_none_iff as).mp hpa + subst as + cases hpc : bridgeProduct cs with + | none => + have hn := (bridgeProduct_eq_none_iff cs).mp hpc + subst cs + have he' : a = c := by simpa using he + simp [he'] + | some d => + have he' : a = c.concat d := by simpa [bridgeProduct, hpc] using he + rw [he'] at hai + exact False.elim ((c.concat_not_irreducible d) hai) + | some b => + cases hpc : bridgeProduct cs with + | none => + have hn := (bridgeProduct_eq_none_iff cs).mp hpc + subst cs + have he' : a.concat b = c := by simpa [bridgeProduct, hpa] using he + rw [← he'] at hci + exact False.elim ((a.concat_not_irreducible b) hci) + | some d => + have he' : a.concat b = c.concat d := by simpa [bridgeProduct, hpa, hpc] using he + have hh := Bridge.concat_irreducible_first_height_eq hai hci he' + have hf := Bridge.concat_first_eq_of_height_eq he' hh + subst c + have ht : b = d := Bridge.concat_left_cancel he' + have hp : bridgeProduct as = bridgeProduct cs := by rw [hpa, hpc, ht] + have htail := ih cs (by intro z hz; exact ha z (List.mem_cons_of_mem _ hz)) + (by intro z hz; exact hb z (List.mem_cons_of_mem _ hz)) hp + simp [htail] + +theorem bridgeFactorization : BridgeFactorizationLaw := by + intro b + obtain ⟨bs, hbs, hbi⟩ := irreducible_factorization_exists b + refine ⟨bs, ⟨hbi, bridgeProduct_vertices hbs⟩, ?_⟩ + intro cs hcs + apply irreducible_product_unique cs bs hcs.1 hbi + rw [bridgeProduct_of_vertices hcs.2, hbs] + +end HoneycombActual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombBridges/Geometry.lean b/lean/OAI/Combinatorics/HoneycombBridges/Geometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecf568c7df5bb083a13f479d5578cc76da4ef029 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombBridges/Geometry.lean @@ -0,0 +1,309 @@ +import Mathlib +import OAI.Combinatorics.HoneycombBridges.Factorization + +namespace OAI + +/-! Geometry of concatenation and vertex-port conventions. -/ + +noncomputable section +open scoped ENNReal +open Filter + +namespace HoneycombActual + +def BridgeGeometryLaw : Prop := + (∀ b : Bridge, rowSpacing * (b.height : ℝ) ≤ b.endpointDistance) ∧ + (∀ b c : Bridge, + max b.diameter c.diameter ≤ (b.concat c).diameter ∧ + (b.concat c).diameter ≤ b.diameter + c.diameter) ∧ + (∀ (bs : List Bridge) (b : Bridge), bridgeProduct bs = some b → + rowSpacing * (bs.map (fun a => (a.height : ℝ))).sum ≤ b.endpointDistance ∧ + b.diameter ≤ (bs.map Bridge.diameter).sum ∧ + ∀ a ∈ bs, a.diameter ≤ b.diameter) + + + +def shiftPoint (i j : ℤ) (z : ℂ) : ℂ := z + (port i j - port 0 0) + +@[simp] theorem shiftPoint_port (i j a b : ℤ) : + shiftPoint i j (port a b) = port (a+i) (b+j) := by + apply Complex.ext <;> simp [shiftPoint, port] <;> ring + +@[simp] theorem position_shiftVertex (i j : ℤ) (v : Vertex) : + position (shiftVertex i j v) = shiftPoint i j (position v) := by + cases hv : v.up <;> apply Complex.ext <;> + simp [position, shiftVertex, hv, shiftPoint, port] <;> ring + +theorem shiftPoint_isometry (i j : ℤ) : Isometry (shiftPoint i j) := by + apply Isometry.of_dist_eq + intro x y + simp [shiftPoint] + +theorem port_eq_midpoint (i j : ℤ) : + port i j = midpoint ℝ (position (down i (j-1))) (position (up i j)) := by + rw [midpoint_eq_smul_add] + apply Complex.ext <;> simp [position, up, down, port] <;> ring + +namespace Bridge + +theorem height_le_endpointDistance (b : Bridge) : + rowSpacing * (b.height : ℝ) ≤ b.endpointDistance := by + have h := Complex.abs_im_le_norm (port b.terminal b.height - port 0 0) + have he : (port b.terminal b.height - port 0 0).im = rowSpacing * (b.height : ℝ) := by + simp [port] + rw [he, abs_of_nonneg (by unfold rowSpacing; positivity)] at h + simpa [endpointDistance, dist_eq_norm, norm_sub_rev] using h + +theorem concat_trace_subset (b c : Bridge) : + (b.concat c).trace ⊆ b.trace ∪ shiftPoint b.terminal b.height '' c.trace := by + intro z hz + rcases hz with hp | ⟨v, hv, rfl⟩ + · rcases hp with he | he + · exact Or.inl (Or.inl (Or.inl he)) + · right + refine ⟨port c.terminal c.height, by simp [trace], ?_⟩ + simpa [concat_terminal, concat_height, add_comm] using he.symm + · rcases List.mem_append.mp hv with hb | hc + · exact Or.inl (Or.inr ⟨v, hb, rfl⟩) + · obtain ⟨w, hw, rfl⟩ := List.mem_map.mp hc + right + exact ⟨position w, Or.inr ⟨w, hw, rfl⟩, (position_shiftVertex _ _ _).symm⟩ + +theorem concat_diameter_le (b c : Bridge) : + (b.concat c).diameter ≤ b.diameter + c.diameter := by + have hb : Bornology.IsBounded (b.trace ∪ shiftPoint b.terminal b.height '' c.trace) := + (b.trace_finite.union (c.trace_finite.image _)).isBounded + have hm : (b.trace ∩ shiftPoint b.terminal b.height '' c.trace).Nonempty := by + refine ⟨port b.terminal b.height, by simp [trace], ?_⟩ + exact ⟨port 0 0, by simp [trace], by simp⟩ + calc + (b.concat c).diameter ≤ Metric.diam (b.trace ∪ shiftPoint b.terminal b.height '' c.trace) := + Metric.diam_mono (concat_trace_subset b c) hb + _ ≤ Metric.diam b.trace + Metric.diam (shiftPoint b.terminal b.height '' c.trace) := + Metric.diam_union' hm + _ = b.diameter + c.diameter := by rw [(shiftPoint_isometry _ _).diam_image]; rfl + +end Bridge +end HoneycombActual + +namespace HoneycombActual.Bridge + +theorem concat_cut_mem_convexHull (b c : Bridge) : + port b.terminal b.height ∈ convexHull ℝ (b.concat c).trace := by + rw [port_eq_midpoint] + apply (convex_convexHull ℝ _).midpoint_mem + · apply subset_convexHull ℝ _ + right + refine ⟨down b.terminal ((b.height : ℤ)-1), ?_, rfl⟩ + exact List.mem_append_left _ (List.mem_of_getLast? b.terminates) + · apply subset_convexHull ℝ _ + right + refine ⟨up b.terminal b.height, ?_, rfl⟩ + apply List.mem_append_right + exact List.mem_map.mpr ⟨up 0 0, List.mem_of_head? c.initiates, by simp⟩ + +theorem left_trace_subset_convexHull_concat (b c : Bridge) : + b.trace ⊆ convexHull ℝ (b.concat c).trace := by + intro z hz + rcases hz with hp | ⟨v, hv, rfl⟩ + · simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hp + rcases hp with rfl | rfl + · exact subset_convexHull ℝ _ (by simp [trace]) + · exact concat_cut_mem_convexHull b c + · apply subset_convexHull ℝ _ + exact Or.inr ⟨v, List.mem_append_left _ hv, rfl⟩ + +theorem right_trace_subset_convexHull_concat (b c : Bridge) : + shiftPoint b.terminal b.height '' c.trace ⊆ convexHull ℝ (b.concat c).trace := by + intro z hz + obtain ⟨w, hw, rfl⟩ := hz + rcases hw with hp | ⟨v, hv, rfl⟩ + · simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hp + rcases hp with rfl | rfl + · simpa using concat_cut_mem_convexHull b c + · apply subset_convexHull ℝ _ + left + right + simp [concat_height, concat_terminal, add_comm] + · apply subset_convexHull ℝ _ + right + exact ⟨shiftVertex b.terminal b.height v, + List.mem_append_right _ (List.mem_map.mpr ⟨v, hv, rfl⟩), + position_shiftVertex _ _ _⟩ + +theorem le_concat_diameter (b c : Bridge) : + max b.diameter c.diameter ≤ (b.concat c).diameter := by + have hb : Bornology.IsBounded (convexHull ℝ (b.concat c).trace) := + isBounded_convexHull.mpr (b.concat c).trace_finite.isBounded + apply max_le + · calc + b.diameter ≤ Metric.diam (convexHull ℝ (b.concat c).trace) := + Metric.diam_mono (left_trace_subset_convexHull_concat b c) hb + _ = (b.concat c).diameter := convexHull_diam _ + · calc + c.diameter = Metric.diam (shiftPoint b.terminal b.height '' c.trace) := + ((shiftPoint_isometry _ _).diam_image _).symm + _ ≤ Metric.diam (convexHull ℝ (b.concat c).trace) := + Metric.diam_mono (right_trace_subset_convexHull_concat b c) hb + _ = (b.concat c).diameter := convexHull_diam _ + +end HoneycombActual.Bridge + +namespace HoneycombActual + +theorem bridgeProduct_height_sum {bs : List Bridge} {b : Bridge} + (h : bridgeProduct bs = some b) : + (b.height : ℝ) = (bs.map (fun a => (a.height : ℝ))).sum := by + induction bs generalizing b with + | nil => simp at h + | cons a as ih => + cases he : bridgeProduct as with + | none => + have hn := (bridgeProduct_eq_none_iff _).mp he + subst as + have heq : a = b := by simpa using h + simp [← heq] + | some c => + have heq : a.concat c = b := by simpa [bridgeProduct, he] using h + rw [← heq] + simpa using congrArg (fun x : ℝ => (a.height : ℝ) + x) (ih he) + +theorem bridgeProduct_diameter {bs : List Bridge} {b : Bridge} + (h : bridgeProduct bs = some b) : + b.diameter ≤ (bs.map Bridge.diameter).sum ∧ + ∀ a ∈ bs, a.diameter ≤ b.diameter := by + induction bs generalizing b with + | nil => simp at h + | cons a as ih => + cases he : bridgeProduct as with + | none => + have hn := (bridgeProduct_eq_none_iff _).mp he + subst as + have heq : a = b := by simpa using h + simp [← heq] + | some c => + have heq : a.concat c = b := by simpa [bridgeProduct, he] using h + rw [← heq] + obtain ⟨hupper, hlower⟩ := ih he + constructor + · simpa using (a.concat_diameter_le c).trans (add_le_add le_rfl hupper) + · intro d hd + rcases List.mem_cons.mp hd with rfl | hd + · exact (le_max_left _ _).trans (Bridge.le_concat_diameter _ _) + · exact (hlower d hd).trans ((le_max_right _ _).trans (a.le_concat_diameter c)) + +theorem bridgeGeometry : BridgeGeometryLaw := by + refine ⟨Bridge.height_le_endpointDistance, ?_, ?_⟩ + · intro b c + exact ⟨b.le_concat_diameter c, b.concat_diameter_le c⟩ + · intro bs b hb + refine ⟨?_, bridgeProduct_diameter hb⟩ + rw [← bridgeProduct_height_sum hb] + exact b.height_le_endpointDistance + + + +namespace Bridge + +def vertexEndpointDistance (b : Bridge) : ℝ := + dist (position (up 0 0)) (position (down b.terminal ((b.height : ℤ) - 1))) + +def vertexTrace (b : Bridge) : Set ℂ := position '' {v | v ∈ b.vertices} + +def vertexDiameter (b : Bridge) : ℝ := Metric.diam b.vertexTrace + +end Bridge + +def BoundedVertexConventions : Prop := + ∃ C : ℝ, 0 ≤ C ∧ ∀ b : Bridge, + |b.endpointDistance - b.vertexEndpointDistance| ≤ C ∧ + |b.diameter - b.vertexDiameter| ≤ C + +theorem rowSpacing_nonneg : 0 ≤ rowSpacing := by + unfold rowSpacing + positivity + +theorem port_dist_up (i j : ℤ) : + dist (port i j) (position (up i j)) = rowSpacing / 3 := by + rw [Complex.dist_of_re_eq (by simp [port, position, up]), Real.dist_eq] + have he : (port i j).im - (position (up i j)).im = -(rowSpacing / 3) := by + simp [port, position, up] + ring + rw [he, abs_neg, abs_of_nonneg (div_nonneg rowSpacing_nonneg (by norm_num))] + +theorem port_dist_down (i j : ℤ) : + dist (port i j) (position (down i (j-1))) = rowSpacing / 3 := by + rw [Complex.dist_of_re_eq (by simp [port, position, down]; ring), Real.dist_eq] + have he : (port i j).im - (position (down i (j-1))).im = rowSpacing / 3 := by + simp [port, position, down] + ring + rw [he, abs_of_nonneg (div_nonneg rowSpacing_nonneg (by norm_num))] + +namespace Bridge + +theorem endpointDistance_vertex_change (b : Bridge) : + |b.endpointDistance - b.vertexEndpointDistance| ≤ 2 * rowSpacing / 3 := by + have h₁ := dist_triangle4_right (port 0 0) (port b.terminal b.height) + (position (up 0 0)) (position (down b.terminal ((b.height : ℤ)-1))) + have h₂ := dist_triangle4_left (port 0 0) (port b.terminal b.height) + (position (up 0 0)) (position (down b.terminal ((b.height : ℤ)-1))) + rw [port_dist_up, port_dist_down] at h₁ h₂ + dsimp [endpointDistance, vertexEndpointDistance] + apply abs_sub_le_iff.mpr + constructor <;> linarith + +theorem vertexTrace_finite (b : Bridge) : b.vertexTrace.Finite := + b.vertices.finite_toSet.image position + +theorem first_vertex_mem_vertexTrace (b : Bridge) : + position (up 0 0) ∈ b.vertexTrace := + ⟨up 0 0, List.mem_of_head? b.initiates, rfl⟩ + +theorem last_vertex_mem_vertexTrace (b : Bridge) : + position (down b.terminal ((b.height : ℤ)-1)) ∈ b.vertexTrace := + ⟨down b.terminal ((b.height : ℤ)-1), List.mem_of_getLast? b.terminates, rfl⟩ + +theorem vertexEndpointDistance_le_vertexDiameter (b : Bridge) : + b.vertexEndpointDistance ≤ b.vertexDiameter := + Metric.dist_le_diam_of_mem b.vertexTrace_finite.isBounded + b.first_vertex_mem_vertexTrace b.last_vertex_mem_vertexTrace + +theorem vertexDiameter_le_diameter (b : Bridge) : b.vertexDiameter ≤ b.diameter := + Metric.diam_mono (fun _ hz => Or.inr hz) b.trace_finite.isBounded + +theorem trace_near_vertexTrace (b : Bridge) (z : ℂ) (hz : z ∈ b.trace) : + ∃ w ∈ b.vertexTrace, dist z w ≤ rowSpacing / 3 := by + rcases hz with hp | hv + · rcases hp with rfl | rfl + · exact ⟨_, b.first_vertex_mem_vertexTrace, (port_dist_up 0 0).le⟩ + · exact ⟨_, b.last_vertex_mem_vertexTrace, (port_dist_down b.terminal b.height).le⟩ + · exact ⟨z, hv, by simpa using div_nonneg rowSpacing_nonneg (by norm_num : (0 : ℝ) ≤ 3)⟩ + +theorem diameter_le_vertexDiameter_add (b : Bridge) : + b.diameter ≤ b.vertexDiameter + 2 * rowSpacing / 3 := by + apply Metric.diam_le_of_forall_dist_le + (add_nonneg Metric.diam_nonneg (by positivity [rowSpacing_nonneg])) + intro x hx y hy + obtain ⟨v, hv, hxv⟩ := b.trace_near_vertexTrace x hx + obtain ⟨w, hw, hyw⟩ := b.trace_near_vertexTrace y hy + have hdist := dist_triangle4_right x y v w + have hdiam := Metric.dist_le_diam_of_mem b.vertexTrace_finite.isBounded hv hw + linarith + +theorem diameter_vertex_change (b : Bridge) : + |b.diameter - b.vertexDiameter| ≤ 2 * rowSpacing / 3 := by + rw [abs_of_nonneg (sub_nonneg.mpr b.vertexDiameter_le_diameter)] + linarith [b.diameter_le_vertexDiameter_add] + +end Bridge + +theorem boundedVertexConventions : BoundedVertexConventions := by + refine ⟨2 * rowSpacing / 3, by positivity [rowSpacing_nonneg], ?_⟩ + intro b + exact ⟨b.endpointDistance_vertex_change, b.diameter_vertex_change⟩ + +end HoneycombActual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombBridges/LengthTransform.lean b/lean/OAI/Combinatorics/HoneycombBridges/LengthTransform.lean new file mode 100644 index 0000000000000000000000000000000000000000..5479af6e1b0554939fc744593097c603bdff1c3e --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombBridges/LengthTransform.lean @@ -0,0 +1,513 @@ +import Mathlib +import OAI.Combinatorics.HoneycombBridges.Factorization + +namespace OAI + +/-! Renewal transforms and irreducible length kernels. -/ + +noncomputable section +open scoped ENNReal +open Filter + +namespace HoneycombActual + +def discountedWeight (s u : ℝ) (b : Bridge) : ℝ≥0∞ := + weight b * ENNReal.ofReal (Real.exp (-s * (b.height : ℝ) - u * (b.length : ℝ))) + +def bridgePartition (s u : ℝ) : ℝ≥0∞ := + 1 + ∑' b : Bridge, discountedWeight s u b + +def irreducibleLaplace (s u : ℝ) : ℝ≥0∞ := + ∑' b : {b : Bridge // b.Irreducible}, discountedWeight s u b.val + +def UnnormalizedRenewalIdentity : Prop := + ∀ s u : ℝ, 0 < s → 0 ≤ u → + bridgePartition s u = (1 - irreducibleLaplace s u)⁻¹ + + + +abbrev IrreducibleBridge := {b : Bridge // b.Irreducible} + +def irreducibleProduct (bs : List IrreducibleBridge) : Option Bridge := + bridgeProduct (bs.map Subtype.val) + +theorem irreducibleProduct_injective : Function.Injective irreducibleProduct := by + intro as bs h + apply (List.map_inj_right (fun _ _ he => Subtype.ext he)).mp + apply irreducible_product_unique _ _ _ _ h + · intro a ha + obtain ⟨x, hx, rfl⟩ := List.mem_map.mp ha + exact x.property + · intro a ha + obtain ⟨x, hx, rfl⟩ := List.mem_map.mp ha + exact x.property + +theorem irreducibleProduct_surjective : Function.Surjective irreducibleProduct := by + intro x + cases x with + | none => exact ⟨[], rfl⟩ + | some b => + obtain ⟨bs, hp, hi⟩ := irreducible_factorization_exists b + refine ⟨bs.attachWith Bridge.Irreducible hi, ?_⟩ + simpa [irreducibleProduct, List.attachWith_map_val] using hp + +noncomputable def irreducibleProductEquiv : List IrreducibleBridge ≃ Option Bridge := + Equiv.ofBijective irreducibleProduct + ⟨irreducibleProduct_injective, irreducibleProduct_surjective⟩ + +@[simp] theorem discountedWeight_concat (s u : ℝ) (b c : Bridge) : + discountedWeight s u (b.concat c) = discountedWeight s u b * discountedWeight s u c := by + simp only [discountedWeight, weight_concat, Bridge.concat_height, Bridge.concat_length, + Nat.cast_add] + have he : -s * ((b.height : ℝ) + c.height) - u * ((b.length : ℝ) + c.length) = + (-s * b.height - u * b.length) + (-s * c.height - u * c.length) := by ring + rw [he, Real.exp_add, ENNReal.ofReal_mul (Real.exp_nonneg _)] + ring + +def optionWeight (s u : ℝ) : Option Bridge → ℝ≥0∞ + | none => 1 + | some b => discountedWeight s u b + +theorem optionWeight_bridgeProduct (s u : ℝ) (bs : List Bridge) : + optionWeight s u (bridgeProduct bs) = (bs.map (discountedWeight s u)).prod := by + induction bs with + | nil => rfl + | cons b bs ih => + cases h : bridgeProduct bs with + | none => + have hn := (bridgeProduct_eq_none_iff bs).mp h + subst bs + simp [bridgeProduct, optionWeight] + | some c => + simpa [bridgeProduct, h, optionWeight, discountedWeight_concat] using + congrArg (fun x => discountedWeight s u b * x) ih + +theorem optionWeight_irreducibleProduct (s u : ℝ) (bs : List IrreducibleBridge) : + optionWeight s u (irreducibleProduct bs) = + (bs.map (fun b => discountedWeight s u b.val)).prod := by + simpa [irreducibleProduct, List.map_map, Function.comp_def] using + optionWeight_bridgeProduct s u (bs.map Subtype.val) + +end HoneycombActual + +namespace HoneycombActual.RenewalList + +def lengthSuccEquiv (α : Type*) (n : ℕ) : + (α × {l : List α // l.length = n}) ≃ {l : List α // l.length = n+1} where + toFun p := ⟨p.1 :: p.2.val, by simp [p.2.property]⟩ + invFun l := by + rcases l with ⟨l, hl⟩ + cases l with + | nil => simp at hl + | cons a as => exact (a, ⟨as, by simpa using hl⟩) + left_inv p := by rcases p with ⟨a, ⟨l, hl⟩⟩; rfl + right_inv p := by + rcases p with ⟨l, hl⟩ + cases l with + | nil => simp at hl + | cons a as => rfl + +theorem sum_prod_length {α : Type*} (q : α → ℝ≥0∞) (n : ℕ) : + (∑' l : {l : List α // l.length = n}, (l.val.map q).prod) = (∑' a, q a)^n := by + classical + induction n with + | zero => + let : Unique {l : List α // l.length = 0} := + ⟨⟨⟨[], rfl⟩⟩, fun l => Subtype.ext (List.length_eq_zero_iff.mp l.property)⟩ + simp only [tsum_fintype, Finset.univ_unique, Finset.sum_singleton, pow_zero] + rfl + | succ n ih => + rw [← (lengthSuccEquiv α n).tsum_eq (fun l => (l.val.map q).prod)] + change (∑' p : α × {l : List α // l.length = n}, q p.1 * (p.2.val.map q).prod) = _ + rw [@ENNReal.tsum_prod α {l : List α // l.length = n} + (fun a l => q a * (l.val.map q).prod)] + simp_rw [ENNReal.tsum_mul_left, ih] + rw [ENNReal.tsum_mul_right, pow_succ'] + +theorem sum_prod {α : Type*} (q : α → ℝ≥0∞) : + (∑' l : List α, (l.map q).prod) = (1 - ∑' a, q a)⁻¹ := by + rw [← ENNReal.tsum_fiberwise (fun l : List α => (l.map q).prod) List.length] + change (∑' n : ℕ, ∑' l : {l : List α // l.length = n}, (l.val.map q).prod) = _ + simp_rw [sum_prod_length] + exact ENNReal.tsum_geometric _ + +end HoneycombActual.RenewalList + +namespace HoneycombActual + +theorem optionWeight_tsum (s u : ℝ) : + (∑' b : Option Bridge, optionWeight s u b) = bridgePartition s u := by + rw [← (Equiv.optionEquivSumPUnit.{0,0} Bridge).symm.tsum_eq (optionWeight s u)] + rw [ENNReal.summable.tsum_sum ENNReal.summable] + simp [optionWeight, bridgePartition, tsum_fintype, add_comm] + +theorem bridgePartition_geometric (s u : ℝ) : + bridgePartition s u = (1 - irreducibleLaplace s u)⁻¹ := by + rw [← optionWeight_tsum, ← irreducibleProductEquiv.tsum_eq (optionWeight s u)] + calc + (∑' bs : List IrreducibleBridge, optionWeight s u (irreducibleProductEquiv bs)) = + ∑' bs : List IrreducibleBridge, + (bs.map (fun b => discountedWeight s u b.val)).prod := by + apply tsum_congr + intro bs + exact optionWeight_irreducibleProduct s u bs + _ = (1 - irreducibleLaplace s u)⁻¹ := + RenewalList.sum_prod (fun b : IrreducibleBridge => discountedWeight s u b.val) + +theorem unnormalizedRenewalIdentity : UnnormalizedRenewalIdentity := by + intro s u _ _ + exact bridgePartition_geometric s u + + + +def lengthPartition (s : ℝ) : ℝ≥0∞ := + ∑' b : Bridge, (b.length : ℝ≥0∞) * discountedWeight s 0 b + +def irreducibleLengthPartition (s : ℝ) : ℝ≥0∞ := + ∑' b : IrreducibleBridge, (b.val.length : ℝ≥0∞) * discountedWeight s 0 b.val + +def LengthRewardTransformIdentity : Prop := + ∀ s : ℝ, 0 < s → + lengthPartition s = bridgePartition s 0 ^ 2 * irreducibleLengthPartition s + +end HoneycombActual + +namespace HoneycombActual.RenewalList + +abbrev Marked (α : Type*) := (l : List α) × Fin l.length + +def mark {α : Type*} (p : List α × α × List α) : Marked α := + ⟨p.1 ++ p.2.1 :: p.2.2, ⟨p.1.length, by simp⟩⟩ + +def unmark {α : Type*} (p : Marked α) : List α × α × List α := + (p.1.take p.2.val, p.1[p.2.val], p.1.drop (p.2.val+1)) + +theorem unmark_mark {α : Type*} (p : List α × α × List α) : unmark (mark p) = p := by + rcases p with ⟨as, a, bs⟩ + simp [mark, unmark, List.drop_append] + +theorem mark_unmark {α : Type*} (p : Marked α) : mark (unmark p) = p := by + rcases p with ⟨l, i⟩ + have hl : l.take i.val ++ l[i.val] :: l.drop (i.val+1) = l := by + rw [← List.drop_eq_getElem_cons i.isLt, List.take_append_drop] + apply Sigma.ext hl + apply (Fin.heq_ext_iff (congrArg List.length hl)).mpr + change (l.take i.val).length = i.val + simp [List.length_take, i.isLt.le] + +noncomputable def markedEquiv (α : Type*) : (List α × α × List α) ≃ Marked α where + toFun := mark + invFun := unmark + left_inv := unmark_mark + right_inv := mark_unmark + +def markedWeight {α : Type*} (q r : α → ℝ≥0∞) (p : Marked α) : ℝ≥0∞ := + (p.1.map q).prod * r p.1[p.2.val] + +theorem sum_map_eq_sum_fin {α : Type*} (r : α → ℝ≥0∞) (l : List α) : + (l.map r).sum = ∑ i : Fin l.length, r l[i.val] := by + calc + (l.map r).sum = ((List.ofFn (fun i : Fin l.length => l[i.val])).map r).sum := by + rw [List.ofFn_getElem] + _ = _ := by rw [List.map_ofFn, List.sum_ofFn]; rfl + +theorem sum_markedWeight {α : Type*} (q r : α → ℝ≥0∞) : + (∑' l : List α, (l.map q).prod * (l.map r).sum) = + ∑' p : Marked α, markedWeight q r p := by + rw [ENNReal.tsum_sigma'] + apply tsum_congr + intro l + simp only [markedWeight, tsum_fintype, ← Finset.mul_sum] + rw [sum_map_eq_sum_fin] + +theorem markedWeight_mark {α : Type*} (q r : α → ℝ≥0∞) (p : List α × α × List α) : + markedWeight q r (mark p) = + (p.1.map q).prod * (q p.2.1 * r p.2.1) * (p.2.2.map q).prod := by + rcases p with ⟨as, a, bs⟩ + simp [markedWeight, mark, List.prod_append] + ring + +theorem sum_prod_reward {α : Type*} (q r : α → ℝ≥0∞) : + (∑' l : List α, (l.map q).prod * (l.map r).sum) = + (∑' l : List α, (l.map q).prod)^2 * ∑' a : α, q a * r a := by + rw [sum_markedWeight, ← (markedEquiv α).tsum_eq (markedWeight q r)] + simp_rw [show ∀ p : List α × α × List α, + markedWeight q r (markedEquiv α p) = + (p.1.map q).prod * (q p.2.1 * r p.2.1) * (p.2.2.map q).prod from + markedWeight_mark q r] + rw [@ENNReal.tsum_prod (List α) (α × List α) + (fun as p => (as.map q).prod * (q p.1 * r p.1) * (p.2.map q).prod)] + trans ∑' as : List α, ∑' a : α, ∑' bs : List α, + (as.map q).prod * (q a * r a) * (bs.map q).prod + · apply tsum_congr + intro as + exact @ENNReal.tsum_prod α (List α) + (fun a bs => (as.map q).prod * (q a * r a) * (bs.map q).prod) + · simp_rw [mul_assoc, ENNReal.tsum_mul_left, ENNReal.tsum_mul_right] + simp_rw [← mul_assoc, ENNReal.tsum_mul_right] + ring + +end HoneycombActual.RenewalList + +namespace HoneycombActual + +def optionLength : Option Bridge → ℕ + | none => 0 + | some b => b.length + +theorem optionLength_bridgeProduct (bs : List Bridge) : + optionLength (bridgeProduct bs) = (bs.map Bridge.length).sum := by + induction bs with + | nil => rfl + | cons b bs ih => + cases h : bridgeProduct bs with + | none => + have hn := (bridgeProduct_eq_none_iff bs).mp h + subst bs + simp [bridgeProduct, optionLength] + | some c => + simpa [bridgeProduct, h, optionLength] using + congrArg (fun n => b.length + n) ih + +theorem optionLength_irreducibleProduct (bs : List IrreducibleBridge) : + (optionLength (irreducibleProduct bs) : ℝ≥0∞) = + (bs.map (fun b => (b.val.length : ℝ≥0∞))).sum := by + simp [irreducibleProduct, optionLength_bridgeProduct, List.map_map, Function.comp_def] + +theorem optionLengthWeight_tsum (s : ℝ) : + (∑' b : Option Bridge, (optionLength b : ℝ≥0∞) * optionWeight s 0 b) = + lengthPartition s := by + rw [← (Equiv.optionEquivSumPUnit.{0,0} Bridge).symm.tsum_eq + (fun b => (optionLength b : ℝ≥0∞) * optionWeight s 0 b)] + rw [ENNReal.summable.tsum_sum ENNReal.summable] + simp [optionWeight, optionLength, lengthPartition, tsum_fintype] + +theorem listWeight_tsum (s u : ℝ) : + (∑' bs : List IrreducibleBridge, + (bs.map (fun b => discountedWeight s u b.val)).prod) = bridgePartition s u := by + rw [← optionWeight_tsum, ← irreducibleProductEquiv.tsum_eq (optionWeight s u)] + apply tsum_congr + intro bs + exact (optionWeight_irreducibleProduct s u bs).symm + +theorem lengthPartition_marked (s : ℝ) : + lengthPartition s = bridgePartition s 0 ^ 2 * irreducibleLengthPartition s := by + rw [← optionLengthWeight_tsum, ← irreducibleProductEquiv.tsum_eq + (fun b => (optionLength b : ℝ≥0∞) * optionWeight s 0 b)] + calc + (∑' bs : List IrreducibleBridge, + (optionLength (irreducibleProductEquiv bs) : ℝ≥0∞) * + optionWeight s 0 (irreducibleProductEquiv bs)) = + ∑' bs : List IrreducibleBridge, + (bs.map (fun b => discountedWeight s 0 b.val)).prod * + (bs.map (fun b => (b.val.length : ℝ≥0∞))).sum := by + apply tsum_congr + intro bs + change (optionLength (irreducibleProduct bs) : ℝ≥0∞) * + optionWeight s 0 (irreducibleProduct bs) = _ + rw [optionLength_irreducibleProduct, optionWeight_irreducibleProduct, mul_comm] + _ = _ := by + rw [RenewalList.sum_prod_reward, listWeight_tsum] + congr 1 + apply tsum_congr + intro b + exact mul_comm _ _ + +theorem lengthRewardTransformIdentity : LengthRewardTransformIdentity := by + intro s _ + exact lengthPartition_marked s + + + +theorem tsum_by_halfLength (f : Bridge → ℝ≥0∞) : + (∑' b : Bridge, f b) = + ∑' m : ℕ, ∑' b : Bridge, if b.length = 2*m then f b else 0 := by + classical + rw [ENNReal.tsum_comm] + apply tsum_congr + intro b + have hiff (m : ℕ) : b.length = 2*m ↔ m = b.length / 2 := by + have hb := b.twice_halfLength + omega + simp_rw [hiff] + simp + + + +def truncatedIrreducibleLength (T : ℝ) : ℝ≥0∞ := by + classical + exact ∑' b : Bridge, if b.Irreducible then + weight b * ENNReal.ofReal (min (b.length : ℝ) T) else 0 + +def ActualTruncatedLengthLower : Prop := + ∃ c T₀ : ℝ, 0 < c ∧ 0 < T₀ ∧ ∀ T : ℝ, T₀ ≤ T → + ENNReal.ofReal (c * T ^ (7/16 : ℝ)) ≤ truncatedIrreducibleLength T + +theorem half_min_le_length_kernel (t : ℝ) (ht : 0 ≤ t) : + (min t 1) / 2 ≤ 1 - Real.exp (-t) := by + have hp : Real.exp (-t) * (t + 1) ≤ 1 := by + calc + Real.exp (-t) * (t + 1) ≤ Real.exp (-t) * Real.exp t := + mul_le_mul_of_nonneg_left (Real.add_one_le_exp t) (Real.exp_pos _).le + _ = 1 := by rw [← Real.exp_add]; simp + have he := Real.exp_pos (-t) + rcases le_total t 1 with ht1 | ht1 + · rw [min_eq_left ht1] + by_cases h : Real.exp (-t) ≤ 1/2 + · linarith + · have hh : (1/2 : ℝ) ≤ Real.exp (-t) := le_of_lt (lt_of_not_ge h) + nlinarith + · rw [min_eq_right ht1] + nlinarith + +theorem length_kernel_le_min (t : ℝ) : + 1 - Real.exp (-t) ≤ min t 1 := by + apply le_min + · have := Real.add_one_le_exp (-t) + linarith + · have := Real.exp_pos (-t) + linarith + +theorem lengthLaplaceReward_le_truncated (u : ℝ) (hu : 0 < u) : + lengthLaplaceReward u ≤ + ENNReal.ofReal u * truncatedIrreducibleLength u⁻¹ := by + classical + unfold lengthLaplaceReward truncatedIrreducibleLength + rw [← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro b + by_cases hi : b.Irreducible + · simp only [hi, ite_true] + have hm : u * min (b.length : ℝ) u⁻¹ = min (u * b.length) 1 := by + rw [mul_min_of_nonneg _ _ hu.le, mul_inv_cancel₀ hu.ne'] + have hk : 1 - Real.exp (-u * (b.length : ℝ)) ≤ + u * min (b.length : ℝ) u⁻¹ := by + rw [hm] + simpa only [neg_mul] using length_kernel_le_min (u * b.length) + calc + weight b * ENNReal.ofReal (1 - Real.exp (-u * (b.length : ℝ))) ≤ + weight b * ENNReal.ofReal (u * min (b.length : ℝ) u⁻¹) := + mul_le_mul_right (ENNReal.ofReal_le_ofReal hk) _ + _ = _ := by rw [ENNReal.ofReal_mul hu.le]; ac_rfl + · simp only [hi, ite_false, mul_zero] + exact le_rfl + +theorem truncated_le_lengthLaplaceReward (u : ℝ) (hu : 0 < u) : + ENNReal.ofReal (u/2) * truncatedIrreducibleLength u⁻¹ ≤ + lengthLaplaceReward u := by + classical + unfold lengthLaplaceReward truncatedIrreducibleLength + rw [← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro b + by_cases hi : b.Irreducible + · simp only [hi, ite_true] + have hm : u * min (b.length : ℝ) u⁻¹ = min (u * b.length) 1 := by + rw [mul_min_of_nonneg _ _ hu.le, mul_inv_cancel₀ hu.ne'] + have hk : (u/2) * min (b.length : ℝ) u⁻¹ ≤ + 1 - Real.exp (-u * (b.length : ℝ)) := by + calc + (u/2) * min (b.length : ℝ) u⁻¹ = min (u * b.length) 1 / 2 := by + rw [← hm]; ring + _ ≤ _ := by + simpa only [neg_mul] using + half_min_le_length_kernel (u * b.length) (by positivity) + calc + ENNReal.ofReal (u/2) * (weight b * ENNReal.ofReal (min (b.length : ℝ) u⁻¹)) = + weight b * ENNReal.ofReal ((u/2) * min (b.length : ℝ) u⁻¹) := by + rw [ENNReal.ofReal_mul (by positivity : 0 ≤ u/2)]; ac_rfl + _ ≤ _ := mul_le_mul_right (ENNReal.ofReal_le_ofReal hk) _ + · simp only [hi, ite_false, mul_zero] + exact le_rfl + +private theorem exponent_balance (t : ℝ) (ht : 0 < t) : + t * (t⁻¹) ^ (7/16 : ℝ) = t ^ (9/16 : ℝ) := by + rw [Real.inv_rpow ht.le, ← Real.rpow_neg ht.le] + calc + t * t ^ (-(7/16 : ℝ)) = t ^ (1 : ℝ) * t ^ (-(7/16 : ℝ)) := by + rw [Real.rpow_one] + _ = t ^ ((1 : ℝ) + -(7/16 : ℝ)) := (Real.rpow_add ht _ _).symm + _ = _ := by norm_num + +theorem actualLengthLaplaceLower_iff_truncated : + ActualLengthLaplaceLower ↔ ActualTruncatedLengthLower := by + constructor + · rintro ⟨c, u₀, hc, hu₀, h⟩ + refine ⟨c, u₀⁻¹, hc, inv_pos.mpr hu₀, ?_⟩ + intro T hT + have hTp : 0 < T := lt_of_lt_of_le (inv_pos.mpr hu₀) hT + have hu : T⁻¹ ≤ u₀ := by + have hi := (inv_le_inv₀ hTp (inv_pos.mpr hu₀)).mpr hT + simpa only [inv_inv] using hi + have hl := (h T⁻¹ (inv_pos.mpr hTp) hu).trans + (lengthLaplaceReward_le_truncated T⁻¹ (inv_pos.mpr hTp)) + simp only [inv_inv] at hl + have heq : ENNReal.ofReal (T⁻¹) * ENNReal.ofReal (c * T ^ (7/16 : ℝ)) = + ENNReal.ofReal (c * (T⁻¹) ^ (9/16 : ℝ)) := by + rw [← ENNReal.ofReal_mul (inv_pos.mpr hTp).le] + congr 1 + have hb := exponent_balance T⁻¹ (inv_pos.mpr hTp) + simp only [inv_inv] at hb + calc + T⁻¹ * (c * T ^ (7/16 : ℝ)) = c * (T⁻¹ * T ^ (7/16 : ℝ)) := by ring + _ = _ := by rw [hb] + apply (ENNReal.mul_le_mul_iff_right + (ne_of_gt (ENNReal.ofReal_pos.mpr (inv_pos.mpr hTp))) ENNReal.ofReal_ne_top).mp + rw [heq] + exact hl + · rintro ⟨c, T₀, hc, hT₀, h⟩ + refine ⟨c/2, T₀⁻¹, by positivity, inv_pos.mpr hT₀, ?_⟩ + intro u hu hu₀ + have hT : T₀ ≤ u⁻¹ := by + have hi := (inv_le_inv₀ (inv_pos.mpr hT₀) hu).mpr hu₀ + simpa only [inv_inv] using hi + have hl := mul_le_mul_right (h u⁻¹ hT) (ENNReal.ofReal (u/2)) + have heq : ENNReal.ofReal (u/2) * ENNReal.ofReal (c * (u⁻¹) ^ (7/16 : ℝ)) = + ENNReal.ofReal ((c/2) * u ^ (9/16 : ℝ)) := by + rw [← ENNReal.ofReal_mul (by positivity : 0 ≤ u/2)] + congr 1 + calc + (u/2) * (c * (u⁻¹) ^ (7/16 : ℝ)) = + (c/2) * (u * (u⁻¹) ^ (7/16 : ℝ)) := by ring + _ = _ := by rw [exponent_balance u hu] + rw [heq] at hl + exact hl.trans (truncated_le_lengthLaplaceReward u hu) + +def irreducibleCount (m : ℕ) : ℕ := + Nat.card {b : Bridge // b.length = 2*m ∧ b.Irreducible} + +theorem truncatedIrreducibleLength_eq_count_series (T : ℝ) : + truncatedIrreducibleLength T = ∑' m : ℕ, + ENNReal.ofReal (min (2*m : ℕ) T) * + ((irreducibleCount m : ℝ≥0∞) * ENNReal.ofReal (rho ^ (2*m))) := by + classical + rw [truncatedIrreducibleLength, tsum_by_halfLength] + apply tsum_congr + intro m + unfold irreducibleCount + rw [← exactLengthMass_eq (2*m) Bridge.Irreducible] + unfold criticalMass + rw [← ENNReal.tsum_mul_left] + apply tsum_congr + intro b + by_cases hl : b.length = 2*m <;> by_cases hi : b.Irreducible <;> + simp [hl, hi] + ac_rfl + +def ActualCoefficientLower : Prop := + ∃ c T₀ : ℝ, 0 < c ∧ 0 < T₀ ∧ ∀ T : ℝ, T₀ ≤ T → + ENNReal.ofReal (c * T ^ (7/16 : ℝ)) ≤ ∑' m : ℕ, + ENNReal.ofReal (min (2*m : ℕ) T) * + ((irreducibleCount m : ℝ≥0∞) * ENNReal.ofReal (rho ^ (2*m))) + +theorem actualLengthLaplaceLower_iff_coefficients : + ActualLengthLaplaceLower ↔ ActualCoefficientLower := by + rw [actualLengthLaplaceLower_iff_truncated] + simp only [ActualTruncatedLengthLower, ActualCoefficientLower, + truncatedIrreducibleLength_eq_count_series] + +end HoneycombActual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords.lean b/lean/OAI/Combinatorics/HoneycombChords.lean new file mode 100644 index 0000000000000000000000000000000000000000..259e3b9f4ae101bcf9752e0b9ed4c8cb46b25fd4 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords.lean @@ -0,0 +1,14 @@ +import OAI.Combinatorics.HoneycombChords.BridgeLaplace + +/-! +# Critical honeycomb bridge mass + +For simple honeycomb paths weighted by the critical activity per visited center, +the strict bridge mass at height `h` is comparable to `(1 + h)^(-1/4)`, with +height-zero mass equal to one. Its height Laplace transform is comparable to +`s^(-3/4)` for `0 < s ≤ 1`. + +The geometric port convention and finite strip transfer estimates follow OpenAI, +*Critical honeycomb chords with prescribed boundary endpoints* and its companion +*Uniform marked-polygon estimates and sharp finite bridge moments* (September 26, 2026). +-/ diff --git a/lean/OAI/Combinatorics/HoneycombChords/ArchContinuation.lean b/lean/OAI/Combinatorics/HoneycombChords/ArchContinuation.lean new file mode 100644 index 0000000000000000000000000000000000000000..be3d1174547cd737fb943ae6da354a30a64e83e0 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ArchContinuation.lean @@ -0,0 +1,426 @@ +import OAI.Combinatorics.HoneycombChords.BoundarySystems + +namespace OAI + +/-! Arch continuation for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section + +namespace CriticalHoneycomb.FiniteContinuation + +def halfRect (W : ℕ) : Set Center := {v | 0≤v.1 ∧ v.1<(W:ℤ) ∧ 0≤v.2.1} +def BottomArch (W : ℕ) (i j : Fin (W+1)) := + {p : List Center // IsTrace (halfRect (W+1)) p ∧ + p.head?=some (up i.val 0) ∧ p.getLast?=some (up j.val 0)} + +def archRun (j : ℕ) : List Center := (row 0 0 (j+1)).reverse +lemma archRun_head (j : ℕ) : (archRun j).head?=some (down j 0) := by + simp [archRun,row_last] +lemma archRun_last (j : ℕ) : (archRun j).getLast?=some (up 0 0) := by + simp [archRun,row_head] +lemma archRun_mem (j : ℕ) (v : Center) (hv : v∈archRun j) : + 0≤v.1 ∧ v.1≤j ∧ v.2.1=0 := by + rw [archRun,List.mem_reverse] at hv + have hh := (mem_row 0 0 (j+1) v).mp hv + simp only [Nat.cast_add,Nat.cast_one,zero_add] at hh + omega + +lemma eastRun_min (W : ℕ) (i : Fin W) (j : ℤ) {v : Center} + (hv : v∈eastRun W i j) : (i.val : ℤ)≤v.1 := by + simp only [eastRun,List.mem_reverse,List.mem_cons] at hv + rcases hv with rfl|hv + · simp [down] + · have hh := (mem_row _ _ _ _).mp hv + omega + +noncomputable def archExtend {W : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) : List Center := + eastRun (W+1) i 0++γ.val.map (shift 1)++archRun j.val +lemma archExtend_head {W : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) : + (archExtend γ).head?=some (down W 0) := by + simp [archExtend,List.head?_append,eastRun_head] +lemma archExtend_last {W : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) : + (archExtend γ).getLast?=some (up 0 0) := by + simp [archExtend,List.getLast?_append,archRun_last] +lemma archExtend_length {W : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) : + (archExtend γ).length≤γ.val.length+4*(W+1) := by + have hi := i.isLt + have hj := j.isLt + simp only [archExtend,archRun,List.length_append,List.length_map,List.length_reverse, + row_length,eastRun_length] + omega +lemma archExtend_chain {W : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) : + (archExtend γ).IsChain Adj := by + have hm : (γ.val.map (shift 1)).IsChain Adj := + List.isChain_map_of_isChain _ (fun _ _ hh=>(shift_adj 1 _ _).mpr hh) γ.property.1.2.1 + have hw : (archRun j.val).IsChain Adj := reverse_chain (row_chain 0 0 (j.val+1)) + unfold archExtend + apply ((eastRun_chain _ _ _).append hm ?_).append hw + · simp only [List.getLast?_append,List.getLast?_map,γ.property.2.2,Option.map_some, + Option.some_or,archRun_head,Option.mem_def,Option.some.injEq] + intro u hu v hv + subst u;subst v + simp [shift,Adj,up,down] + · simp only [eastRun_last,List.head?_map,γ.property.2.1,Option.map_some,Option.mem_def, + Option.some.injEq] + intro u hu v hv + subst u;subst v + simp [shift,Adj,up,down] +lemma archExtend_nodup {W : ℕ} {i j : Fin (W+1)} (hji : j < i) (γ : BottomArch W i j) : + (archExtend γ).Nodup := by + have hn := γ.property.1.1 + have hp := γ.property.1.2.2 + have hm := hn.map (shift_injective 1) + have hd₁ : List.Disjoint (eastRun (W+1) i 0) (γ.val.map (shift 1)) := by + intro v hv hv' + have hr := eastRun_mem (W+1) i 0 hv + obtain ⟨u,hu,rfl⟩ := List.mem_map.mp hv' + have hh := hp u hu + simp only [halfRect,Set.mem_ofPred_eq,shift] at hh hr + omega + have hd₂ : List.Disjoint (eastRun (W+1) i 0) (archRun j.val) := by + intro v hv hv' + have h₁ := eastRun_min (W+1) i 0 hv + have h₂ := archRun_mem j.val v hv' + have hji : j.val < i.val := hji + omega + have hd₃ : List.Disjoint (γ.val.map (shift 1)) (archRun j.val) := by + intro v hv hv' + have hr := archRun_mem j.val v hv' + obtain ⟨u,hu,rfl⟩ := List.mem_map.mp hv + have hh := hp u hu + simp only [halfRect,Set.mem_ofPred_eq,shift] at hh hr + omega + simp only [archExtend,List.nodup_append] + refine ⟨⟨eastRun_nodup _ _ _,hm,?_⟩,?_,?_⟩ + · intro a ha b hb hab;subst b;exact hd₁ ha hb + · simpa [archRun] using row_nodup 0 0 (j.val+1) + · intro a ha b hb hab;subst b + rcases List.mem_append.mp ha with ha|ha + · exact hd₂ ha hb + · exact hd₃ ha hb + +def aboveZero (v : Center) : Bool := decide (0γ.val.toFinset.image (fun v=>v.2.1.natAbs)) + refine ⟨t.sup id,?_⟩ + intro γ hγ v hv + have ht : v.2.1.natAbs∈t := by + apply Finset.mem_biUnion.mpr + exact ⟨γ,hγ,Finset.mem_image.mpr ⟨v,List.mem_toFinset.mpr hv,rfl⟩⟩ + have hh : v.2.1.natAbs≤t.sup id := Finset.le_sup (f:=id) ht + have ha : v.2.1≤(v.2.1.natAbs:ℤ) := Int.le_natAbs + omega + +lemma archExtend_mem {W N : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) + (hb : ∀ v∈γ.val,v.2.1≤N) : + ∀ v∈archExtend γ,v∈rect (W+1) (N+2) := by + intro v hv + simp only [archExtend,List.mem_append] at hv + rcases hv with (hv|hv)|hv + · have hh:=eastRun_mem (W+1) i 0 hv + have hi:=i.isLt + simp only [rect,Set.mem_ofPred_eq] + omega + · obtain ⟨u,hu,rfl⟩ := List.mem_map.mp hv + have hh:=γ.property.1.2.2 u hu + have hu:=hb u hu + simp only [halfRect,Set.mem_ofPred_eq] at hh + simp only [rect,Set.mem_ofPred_eq,shift] + omega + · have hh:=archRun_mem j.val v hv + have hj:=j.isLt + simp only [rect,Set.mem_ofPred_eq] + omega +end CriticalHoneycomb.FiniteContinuation + +namespace CriticalHoneycomb.FiniteContinuation +open CriticalHoneycomb.Transfer +noncomputable def archChord {W N : ℕ} {i j : Fin (W+1)} (hji : j < i) + (γ : BottomArch W i j) (hb : ∀ v∈γ.val,v.2.1≤N) : + RasterGrid.RectChord W (N+1) 0 0 := by + refine ⟨(archExtend γ).reverse,⟨by simpa using archExtend_nodup hji γ, + reverse_chain (archExtend_chain γ),?_⟩,?_,?_⟩ + · intro v hv + have hh := archExtend_mem γ hb v (List.mem_reverse.mp hv) + apply (RasterGrid.mem_domain_iff v).mpr + simp only [rect,Set.mem_ofPred_eq] at hh + simp only [Nat.cast_add,Nat.cast_one] + omega + · simp [List.head?_reverse,archExtend_last,RasterGrid.westPort,RasterGrid.cellCenter,up] + · simp [List.getLast?_reverse,archExtend_head,RasterGrid.eastPort,RasterGrid.cellCenter,down] + +lemma archChord_injective {W N : ℕ} {i j : Fin (W+1)} (hji : j < i) + (s : Finset (BottomArch W i j)) (hb : ∀ γ∈s,∀ v∈γ.val,v.2.1≤N) : + Function.Injective (fun γ : {γ // γ∈s}=>archChord hji γ.val (hb γ.val γ.property)) := by + intro γ δ he + have hh := congrArg (fun p : RasterGrid.RectChord W (N+1) 0 0=>p.val.reverse) he + simp only [archChord,List.reverse_reverse] at hh + exact Subtype.ext (archExtend_injective hh) + +lemma arch_extended_weight {W : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) : + kappa^(4*(W+1))*kappa^γ.val.length≤kappa^(archExtend γ).length := by + rw [←pow_add] + apply pow_le_pow_of_le_one kappa_positive.le kappa_at_most_one + have hh:=archExtend_length γ + omega + +theorem arch_partial_sum_le {W : ℕ} {i j : Fin (W+1)} (hji : j < i) + (s : Finset (BottomArch W i j)) : + kappa^(4*(W+1))*(∑ γ∈s,kappa^γ.val.length)≤1 := by + classical + obtain ⟨N,hN⟩ := finite_arch_bound s + let B := Σ k : Fin (N+2),RasterGrid.RectChord W (N+1) k 0 + let f : {γ // γ∈s} → B := fun γ=>⟨0,archChord hji γ.val (hN γ.val γ.property)⟩ + have hi : Function.Injective f := by + intro γ δ he + have hh : (archExtend γ.val).reverse=(archExtend δ.val).reverse := + congrArg (fun p : B=>p.2.val) he + apply Subtype.ext + apply archExtend_injective + exact List.reverse_injective hh + have hb : (∑ p : B,kappa^p.2.val.length)≤1 := by + rw [Fintype.sum_sigma] + exact FluxWard.rectangle_actual_sum_bound W (N+1) 0 + calc + kappa^(4*(W+1))*(∑ γ∈s,kappa^γ.val.length) = + ∑ γ : {γ // γ∈s},kappa^(4*(W+1))*kappa^γ.val.val.length := by + rw [Finset.mul_sum] + exact Finset.sum_subtype s (fun _=>Iff.rfl) _ + _ ≤ ∑ γ : {γ // γ∈s},kappa^(f γ).2.val.length := by + apply Finset.sum_le_sum + intro γ hγ + simpa only [f,archChord,List.length_reverse] using arch_extended_weight γ.val + _ = ∑ p∈Finset.univ.image f,kappa^p.2.val.length := + (Finset.sum_image (f:=fun p : B=>kappa^p.2.val.length) (s:=Finset.univ) hi.injOn).symm + _ ≤ ∑ p : B,kappa^p.2.val.length := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro p hp hn + exact (pow_pos kappa_positive _).le + _ ≤ 1 := hb + +theorem bottom_arch_summable_of_lt {W : ℕ} {i j : Fin (W+1)} (hji : j < i) : + Summable (fun γ : BottomArch W i j=>kappa^γ.val.length) := by + apply summable_of_sum_le (c:=1/kappa^(4*(W+1))) + · intro γ + exact (pow_pos kappa_positive _).le + · intro s + apply (le_div_iff₀ (pow_pos kappa_positive _)).mpr + simpa only [mul_comm] using arch_partial_sum_le hji s + +def reverseArch {W : ℕ} {i j : Fin (W+1)} (γ : BottomArch W i j) : BottomArch W j i := + ⟨γ.val.reverse,⟨List.nodup_reverse.mpr γ.property.1.1, + reverse_chain γ.property.1.2.1,fun v hv=>γ.property.1.2.2 v (List.mem_reverse.mp hv)⟩, + by simpa only [List.head?_reverse] using γ.property.2.2, + by simpa only [List.getLast?_reverse] using γ.property.2.1⟩ + +def reverseArchEquiv {W : ℕ} (i j : Fin (W+1)) : BottomArch W i j ≃ BottomArch W j i where + toFun := reverseArch + invFun := reverseArch + left_inv γ := by apply Subtype.ext; exact List.reverse_reverse _ + right_inv γ := by apply Subtype.ext; exact List.reverse_reverse _ + +theorem bottom_arch_summable {W : ℕ} {i j : Fin (W+1)} (hne : i≠j) : + Summable (fun γ : BottomArch W i j=>kappa^γ.val.length) := by + rcases lt_or_gt_of_ne hne with hij|hji + · have hh := bottom_arch_summable_of_lt hij + have he := (reverseArchEquiv i j).summable_iff.mpr hh + change Summable (fun γ : BottomArch W i j=>kappa^γ.val.reverse.length) at he + simpa only [List.length_reverse] using he + · exact bottom_arch_summable_of_lt hji +end CriticalHoneycomb.FiniteContinuation + +namespace CriticalHoneycomb.FiniteContinuation +open Filter Topology + +structure ArchEnds (W : ℕ) where + first : Fin (W+1) + last : Fin (W+1) + distinct : first≠last + +def ArchFamily {W : ℕ} : List (ArchEnds W) → Type + | [] => PUnit + | a::as => BottomArch W a.first a.last × ArchFamily as + +def archNodes {W : ℕ} : {as : List (ArchEnds W)} → ArchFamily as → List Center + | [],_ => [] + | _::_,γ => γ.1.val++archNodes γ.2 + +noncomputable def archFamilyWeight {W : ℕ} {as : List (ArchEnds W)} + (γ : ArchFamily as) : ℝ := kappa^(archNodes γ).length + +lemma archFamilyWeight_nonnegative {W : ℕ} {as : List (ArchEnds W)} (γ : ArchFamily as) : + 0≤archFamilyWeight γ := (pow_pos kappa_positive _).le + +lemma arch_family_summable {W : ℕ} (as : List (ArchEnds W)) : + Summable (archFamilyWeight (as:=as)) := by + induction as with + | nil => + change Summable (fun _ : PUnit=>kappa^([] : List Center).length) + exact (hasSum_fintype _).summable + | cons a as ih => + change Summable (fun γ : BottomArch W a.first a.last × ArchFamily as => + kappa^(γ.1.val++archNodes γ.2).length) + simp only [List.length_append,pow_add] + apply (summable_prod_of_nonneg (fun γ=>mul_nonneg + (pow_pos kappa_positive _).le (pow_pos kappa_positive _).le)).mpr + refine ⟨fun γ=>ih.mul_left (kappa^γ.val.length),?_⟩ + simpa only [tsum_mul_left,archFamilyWeight] using + (bottom_arch_summable a.distinct).mul_right (∑' δ : ArchFamily as,archFamilyWeight δ) + +def ArchSystem {W : ℕ} (as : List (ArchEnds W)) := + {γ : ArchFamily as // (archNodes γ).Nodup} + +noncomputable def archSystemWeight {W : ℕ} {as : List (ArchEnds W)} (γ : ArchSystem as) : ℝ := + archFamilyWeight γ.val + +lemma arch_system_summable {W : ℕ} (as : List (ArchEnds W)) : + Summable (archSystemWeight (as:=as)) := (arch_family_summable as).subtype _ + +lemma archNodes_mem {W : ℕ} {as : List (ArchEnds W)} (γ : ArchFamily as) : + ∀ v∈archNodes γ,0≤v.1 ∧ v.1<(W+1:ℕ) ∧ 0≤v.2.1 := by + induction as with + | nil => simp [archNodes] + | cons a as ih => + intro v hv + rcases List.mem_append.mp hv with hv|hv + · exact γ.1.property.1.2.2 v hv + · exact ih γ.2 v hv + +noncomputable def archHeight {W : ℕ} {as : List (ArchEnds W)} (γ : ArchFamily as) : ℕ := + (archNodes γ).toFinset.sup (fun v=>v.2.1.natAbs) + +lemma archNodes_height {W : ℕ} {as : List (ArchEnds W)} (γ : ArchFamily as) + {v : Center} (hv : v∈archNodes γ) : v.2.1≤(archHeight γ:ℤ) := by + have hh : v.2.1.natAbs≤archHeight γ := Finset.le_sup (f:=fun v : Center=>v.2.1.natAbs) (List.mem_toFinset.mpr hv) + have ha : v.2.1≤(v.2.1.natAbs:ℤ) := Int.le_natAbs + omega + +def topTurn (W h : ℕ) (v : Center) : Center := ((W:ℤ)-v.1,(h:ℤ)-v.2.1,!v.2.2) +lemma topTurn_injective (W h : ℕ) : Function.Injective (topTurn W h) := by + rintro ⟨x,y,b⟩ ⟨x',y',b'⟩ he + simp only [topTurn,Prod.mk.injEq] at he + rcases he with ⟨hx,hy,hb⟩ + have hxx : x=x' := by omega + have hyy : y=y' := by omega + have hb' : b=b' := by simpa using congrArg Bool.not hb + subst x';subst y';subst b' + rfl +lemma topTurn_adj (W h : ℕ) (v w : Center) : + Adj (topTurn W h v) (topTurn W h w) ↔ Adj v w := by + rcases v with ⟨x,y,b⟩;rcases w with ⟨x',y',b'⟩ + cases b <;> cases b' <;> simp [topTurn,Adj] <;> omega + +noncomputable def archSystemNodes {W : ℕ} {as bs : List (ArchEnds W)} + (h : ℕ) (γ : ArchSystem as) (δ : ArchSystem bs) : List Center := + archNodes γ.val++(archNodes δ.val).map (topTurn W h) + +def ArchSystemsFit {W : ℕ} {as bs : List (ArchEnds W)} + (h : ℕ) (γ : ArchSystem as) (δ : ArchSystem bs) : Prop := + (archSystemNodes h γ δ).Nodup ∧ + ∀ v∈archSystemNodes h γ δ,v∈rect (W+1) (h+1) + +lemma archSystemsFit_of_height {W h : ℕ} {as bs : List (ArchEnds W)} + (γ : ArchSystem as) (δ : ArchSystem bs) + (hh : archHeight γ.val+archHeight δ.valv.2.1) hvu + simp only [topTurn] at he + omega + · intro v hv + rcases List.mem_append.mp hv with hv|hv + · have hm:=archNodes_mem γ.val v hv + have hγ:=archNodes_height γ.val hv + simp only [rect,Set.mem_ofPred_eq] + omega + · obtain ⟨u,hu,rfl⟩ := List.mem_map.mp hv + have hm:=archNodes_mem δ.val u hu + have hδ:=archNodes_height δ.val hu + simp only [rect,Set.mem_ofPred_eq,topTurn] + omega + +lemma eventually_archSystemsFit {W : ℕ} {as bs : List (ArchEnds W)} + (γ : ArchSystem as) (δ : ArchSystem bs) : + ∀ᶠ h : ℕ in atTop,ArchSystemsFit h γ δ := by + filter_upwards [eventually_gt_atTop (archHeight γ.val+archHeight δ.val)] with h hh + exact archSystemsFit_of_height γ δ hh + +noncomputable def halfStripSystemMass {W : ℕ} (as : List (ArchEnds W)) : ℝ := + ∑' γ : ArchSystem as,archSystemWeight γ + +noncomputable def finitePureArchMass {W : ℕ} (as bs : List (ArchEnds W)) (h : ℕ) : ℝ := by + classical + exact ∑' p : ArchSystem as × ArchSystem bs, + if ArchSystemsFit h p.1 p.2 then archSystemWeight p.1*archSystemWeight p.2 else 0 + +theorem pure_arch_limit {W : ℕ} (as bs : List (ArchEnds W)) : + Tendsto (finitePureArchMass as bs) atTop + (𝓝 (halfStripSystemMass as*halfStripSystemMass bs)) := by + classical + have hn : ∀ p : ArchSystem as × ArchSystem bs, + 0≤archSystemWeight p.1*archSystemWeight p.2 := fun p=> + mul_nonneg (archFamilyWeight_nonnegative p.1.val) (archFamilyWeight_nonnegative p.2.val) + have hs : Summable (fun p : ArchSystem as × ArchSystem bs=> + archSystemWeight p.1*archSystemWeight p.2) := by + apply (summable_prod_of_nonneg hn).mpr + refine ⟨fun γ=>(arch_system_summable bs).mul_left (archSystemWeight γ),?_⟩ + simpa only [tsum_mul_left,halfStripSystemMass] using + (arch_system_summable as).mul_right (halfStripSystemMass bs) + have he : (∑' p : ArchSystem as × ArchSystem bs,archSystemWeight p.1*archSystemWeight p.2) = + halfStripSystemMass as*halfStripSystemMass bs := by + exact ((arch_system_summable as).hasSum.mul (arch_system_summable bs).hasSum hs).tsum_eq + rw [←he] + apply tendsto_tsum_of_dominated_convergence hs + · intro p + apply tendsto_const_nhds.congr' + filter_upwards [eventually_archSystemsFit p.1 p.2] with h hh + simp only [hh,ite_eq_left] + · apply Eventually.of_forall + intro h p + split_ifs + · rw [Real.norm_eq_abs,abs_of_nonneg (hn p)] + · simp only [norm_zero] + exact hn p +end CriticalHoneycomb.FiniteContinuation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/BetaKernel.lean b/lean/OAI/Combinatorics/HoneycombChords/BetaKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b4a38a13c873b327610d14eca90993b59d7f100 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/BetaKernel.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.HoneycombChords.PositiveJets +import OAI.Combinatorics.HoneycombChords.HyperbolicTransform + +namespace OAI + +/-! Calculus, total positivity, and exponential bounds for the entire beta kernel. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Filter Topology +lemma cosineKernelJet_zero_zero_cos {b x : ℝ} (hb : 0 ≤ b) (hx : x ≤ 0) : + cosineKernelJet 0 0 b x=Real.cos (Real.sqrt b*Real.sqrt (-x)) := by + apply HasSum.tsum_eq + convert Real.hasSum_cos (Real.sqrt b*Real.sqrt (-x)) using 1 + ext k + dsimp [kernelJetTerm] + rw [polynomialJet_X_pow,polynomialJet_X_pow] + simp only [Nat.choose_zero_right,Nat.cast_one,one_mul,Nat.sub_zero] + rw [mul_pow,pow_mul,pow_mul,Real.sq_sqrt hb,Real.sq_sqrt (neg_nonneg.mpr hx)] + simp_rw [←mul_pow] + congr 2 + ring +lemma polynomialJet_at_zero_X_pow (k r : ℕ) : + polynomialJet ((X:Polynomial ℝ)^k) 0 r=if k=r then 1 else 0 := by + simp [polynomialJet,Polynomial.coeff_X_pow,eq_comm] +lemma cosineKernelJet_at_zero (r : ℕ) (x : ℝ) : + cosineKernelJet r 0 0 x=x^r/(2*r).factorial := by + unfold cosineKernelJet kernelJetTerm + simp only [polynomialJet_at_zero_X_pow] + rw [tsum_eq_single r] + · simp [polynomialJet_X_pow] + · intro k hk + simp [hk] +lemma cosineKernelJet_contDiff_right (r s : ℕ) (b : ℝ) : + ∀ k : ℕ,ContDiff ℝ k (fun x=>cosineKernelJet r s b x) := by + intro k + induction k generalizing s with + | zero => exact contDiff_zero.mpr (continuous_iff_continuousAt.mpr (fun x=>(cosineKernelJet_hasDerivAt_right r s b x).continuousAt)) + | succ k ih => + rw [Nat.cast_add,Nat.cast_one,contDiff_succ_iff_deriv] + refine ⟨fun x=>(cosineKernelJet_hasDerivAt_right r s b x).differentiableAt,?_,?_⟩ + · simp + · have he : deriv (fun x=>cosineKernelJet r s b x)=fun x=>(s+1:ℝ)*cosineKernelJet r (s+1) b x := + funext (fun x=>(cosineKernelJet_hasDerivAt_right r s b x).deriv) + rw [he] + exact contDiff_const.mul (ih (s+1)) +lemma cosineKernelJet_contDiff_left (r s : ℕ) (x : ℝ) (k : ℕ) : + ContDiff ℝ k (fun b=>cosineKernelJet r s b x) := by + simpa only [cosineKernelJet_symm r s] using cosineKernelJet_contDiff_right s r x k +/-- The complete jet determinant with literal iterated derivatives, not a series interface. -/ +lemma complete_beta_jet_det_pos {n : ℕ} (b x : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hx : Monotone (fun i : Fin n=>x i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hx0 : ∀ i : Fin n,0 ≤ x i) : + 0 < Matrix.det (fun i j : Fin n=>iteratedDeriv (nodalOrder x j) + (fun y=>iteratedDeriv (nodalOrder b i) (fun z=>cosineKernelJet 0 0 z y) (b i)) (x j)) := by + simp_rw [cosineKernelJet_mixed] + let A : Matrix (Fin n) (Fin n) ℝ := fun i j=>cosineKernelJet (nodalOrder b i) (nodalOrder x j) (b i) (x j) + have hm : Matrix.of (fun i j : Fin n=>( (nodalOrder b i).factorial:ℝ)*((nodalOrder x j).factorial:ℝ)*A i j)= + Matrix.of (fun i j : Fin n=>((nodalOrder b i).factorial:ℝ)* + (Matrix.of (fun i j : Fin n=>((nodalOrder x j).factorial:ℝ)*A i j)) i j) := by + ext i j + simp only [Matrix.of_apply] + ring + change 0 < (Matrix.of (fun i j : Fin n=>((nodalOrder b i).factorial:ℝ)*((nodalOrder x j).factorial:ℝ)*A i j)).det + rw [hm,Matrix.det_mul_column,Matrix.det_mul_row] + apply mul_pos (prod_pos (fun i _=>by positivity)) + exact mul_pos (prod_pos (fun i _=>by positivity)) (cosineKernelJet_det_pos b x hb hx hb0 hx0) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset MeasureTheory Filter Topology +lemma binomial_term_le_add_pow {b δ : ℝ} (hb : 0 ≤ b) (hd : 0 ≤ δ) (k r : ℕ) : + (k.choose r:ℝ)*b^(k-r)*δ^r ≤ (b+δ)^k := by + by_cases hr : r ≤ k + · rw [add_comm,add_pow] + have h:=single_le_sum (f:=fun i=>δ^i*b^(k-i)*(k.choose i:ℝ)) + (s:=range (k+1)) (fun i _=>by positivity) (mem_range.mpr (by omega : rleft (markedDoubleMatrix H w e) +noncomputable def markedRight (H : ℕ) : Matrix (Column H) (Column H) ℂ := + fun w e=>right (markedDoubleMatrix H w e) +noncomputable def markedMixed (H : ℕ) : Matrix (Column H) (Column H) ℂ := + fun w e=>both (markedDoubleMatrix H w e) +lemma marked_base (H : ℕ) : + (fun w e=>base (markedDoubleMatrix H w e))=physicalDoubleMatrix H := by + rw [markedDoubleMatrix_eq,physicalDoubleMatrix_eq] + exact (marked_power_coords H 2).1 +lemma markedLeft_eq (H : ℕ) : markedLeft H= + rowTransfer H*columnKernel H 2 1+columnKernel H 2 1*rowTransfer H := by + funext w e + simp only [markedLeft,markedDoubleMatrix_eq,pow_two,Matrix.mul_apply,left_sum,left_mul, + markedColumn,base_form,left_form,Finset.sum_add_distrib,Matrix.add_apply,rowTransfer] +lemma markedRight_eq (H : ℕ) : markedRight H= + rowTransfer H*columnKernel H 1 2+columnKernel H 1 2*rowTransfer H := by + funext w e + simp only [markedRight,markedDoubleMatrix_eq,pow_two,Matrix.mul_apply,right_sum,right_mul, + markedColumn,base_form,right_form,Finset.sum_add_distrib,Matrix.add_apply,rowTransfer] +lemma markedLeft_shift (H : ℕ) : HasShift (markedLeft H) 1 := by + rw [markedLeft_eq] + have h0 : HasShift (rowTransfer H) 0 := by simpa using transfer_power_shift H 1 + have h1 : HasShift (columnKernel H 2 1) 1 := by + simpa [spinCharge] using kernel_hasShift H 2 1 + exact shift_add (by simpa using shift_mul h0 h1) (by simpa using shift_mul h1 h0) +lemma markedRight_shift (H : ℕ) : HasShift (markedRight H) (-1) := by + rw [markedRight_eq] + have h0 : HasShift (rowTransfer H) 0 := by simpa using transfer_power_shift H 1 + have h1 : HasShift (columnKernel H 1 2) (-1) := by + simpa [spinCharge] using kernel_hasShift H 1 2 + exact shift_add (by simpa using shift_mul h0 h1) (by simpa using shift_mul h1 h0) +lemma projection_shift_zero {W : ℕ} {M : Matrix (Column (W+1)) (Column (W+1)) ℂ} + {q : ℤ} (hM : HasShift M q) (hq : q≠0) : + ∑ s,archRow W s*(M.mulVec (archColumn W)) s=0 := by + classical + simp only [Matrix.mulVec,dotProduct,Finset.mul_sum] + apply Finset.sum_eq_zero + intro s hs + apply Finset.sum_eq_zero + intro t ht + by_cases hs0 : columnCharge s=0 + · by_cases ht0 : columnCharge t=0 + · have hm : M s t=0 := by + by_contra hn + have hh:=hM s t hn + simp only [hs0,ht0,zero_add] at hh + exact hq hh.symm + simp [hm] + · simp [archColumn_charge t ht0] + · simp [archRow_charge s hs0] +noncomputable def archDual (W : ℕ) (v : Column (W+1)→ℂ) : ℂ := + ∑ s,archRow W s*v s +lemma archDual_add (W : ℕ) (v w : Column (W+1)→ℂ) : + archDual W (v+w)=archDual W v+archDual W w := by + simp [archDual,mul_add,Finset.sum_add_distrib] +lemma archDual_sub (W : ℕ) (v w : Column (W+1)→ℂ) : + archDual W (v-w)=archDual W v-archDual W w := by + simp [archDual,mul_sub,Finset.sum_sub_distrib] +lemma archDual_smul (W : ℕ) (z : ℂ) (v : Column (W+1)→ℂ) : + archDual W (z•v)=z*archDual W v := by + simp only [archDual,Pi.smul_apply,smul_eq_mul,Finset.mul_sum] + apply Finset.sum_congr rfl + intro s hs + ring +lemma archDual_A (W : ℕ) : archDual W (archColumn W)=1 := arch_pairing W +lemma archDual_left_A (W : ℕ) : + archDual W ((markedLeft (W+1)).mulVec (archColumn W))=0 := + projection_shift_zero (markedLeft_shift (W+1)) (by norm_num) +lemma archDual_right_A (W : ℕ) : + archDual W ((markedRight (W+1)).mulVec (archColumn W))=0 := + projection_shift_zero (markedRight_shift (W+1)) (by norm_num) +lemma archDual_gap (W : ℕ) (v : Column (W+1)→ℂ) : + archDual W ((gapMatrix W).mulVec v)=archDual W v := by + have hh:=congrFun (congrArg (fun M=>M.mulVec v) (projection_mul_gap W)) (fun _=>1) + rw [←Matrix.mulVec_mulVec,projection_mulVec,projection_mulVec] at hh + simpa [archColumn_vacuum,Pi.smul_apply,smul_eq_mul,archDual] using hh +lemma archDual_double (W : ℕ) (v : Column (W+1)→ℂ) : + archDual W ((physicalDoubleMatrix (W+1)).mulVec v)=archDual W v := by + have hh:=congrFun (congrArg (fun M=>M.mulVec v) (projection_mul_double W)) (fun _=>1) + rw [←Matrix.mulVec_mulVec,projection_mulVec,projection_mulVec] at hh + simpa [archColumn_vacuum,Pi.smul_apply,smul_eq_mul,archDual] using hh +noncomputable def reducedSolve (W : ℕ) (v : Column (W+1)→ℂ) : Column (W+1)→ℂ := + (gapMatrix W)⁻¹|>fun M=>M.mulVec v +lemma gap_reducedSolve (W : ℕ) (v : Column (W+1)→ℂ) : + (gapMatrix W).mulVec (reducedSolve W v)=v := by + rw [reducedSolve,Matrix.mulVec_mulVec,Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr (physical_gap_det_ne_zero W)),Matrix.one_mulVec] +lemma archDual_reducedSolve (W : ℕ) (v : Column (W+1)→ℂ) : + archDual W (reducedSolve W v)=archDual W v := by + rw [←archDual_gap W (reducedSolve W v),gap_reducedSolve] +lemma reducedSolve_equation (W : ℕ) (v : Column (W+1)→ℂ) (hv : archDual W v=0) : + (physicalDoubleMatrix (W+1)).mulVec (reducedSolve W v)+v=reducedSolve W v := by + have hg:=gap_reducedSolve W v + have hp : (archProjection W).mulVec (reducedSolve W v)=0 := by + rw [projection_mulVec] + change (archDual W (reducedSolve W v))•archColumn W=0 + rw [archDual_reducedSolve,hv,zero_smul] + simp only [gapMatrix,Matrix.add_mulVec,Matrix.sub_mulVec,Matrix.one_mulVec,hp,add_zero] at hg + rw [sub_eq_iff_eq_add] at hg + exact (add_comm _ _).trans hg.symm +noncomputable def eigenLeft (W : ℕ) : Column (W+1)→ℂ := + reducedSolve W ((markedLeft (W+1)).mulVec (archColumn W)) +noncomputable def eigenRight (W : ℕ) : Column (W+1)→ℂ := + reducedSolve W ((markedRight (W+1)).mulVec (archColumn W)) +noncomputable def eigenSource (W : ℕ) : Column (W+1)→ℂ := + (markedMixed (W+1)).mulVec (archColumn W)+ + (markedLeft (W+1)).mulVec (eigenRight W)+(markedRight (W+1)).mulVec (eigenLeft W) +noncomputable def eigenCoefficient (W : ℕ) : ℂ := archDual W (eigenSource W) +noncomputable def eigenMixed (W : ℕ) : Column (W+1)→ℂ := + reducedSolve W (eigenSource W-eigenCoefficient W•archColumn W) +noncomputable def markedEigenvector (W : ℕ) : Column (W+1)→Jet := + fun s=>form (archColumn W s) (eigenLeft W s) (eigenRight W s) (eigenMixed W s) +lemma eigenLeft_equation (W : ℕ) : + (physicalDoubleMatrix (W+1)).mulVec (eigenLeft W)+ + (markedLeft (W+1)).mulVec (archColumn W)=eigenLeft W := + reducedSolve_equation _ _ (archDual_left_A W) +lemma eigenRight_equation (W : ℕ) : + (physicalDoubleMatrix (W+1)).mulVec (eigenRight W)+ + (markedRight (W+1)).mulVec (archColumn W)=eigenRight W := + reducedSolve_equation _ _ (archDual_right_A W) +lemma eigenMixed_equation (W : ℕ) : + (physicalDoubleMatrix (W+1)).mulVec (eigenMixed W)+eigenSource W= + eigenMixed W+eigenCoefficient W•archColumn W := by + have hz : archDual W (eigenSource W-eigenCoefficient W•archColumn W)=0 := by + simp [archDual_sub,archDual_smul,archDual_A,eigenCoefficient] + have hh:=reducedSolve_equation W _ hz + change (physicalDoubleMatrix (W+1)).mulVec (eigenMixed W)+ + (eigenSource W-eigenCoefficient W•archColumn W)=eigenMixed W at hh + rw [←add_sub_assoc] at hh + exact sub_eq_iff_eq_add.mp hh +lemma double_archColumn (W : ℕ) : + (physicalDoubleMatrix (W+1)).mulVec (archColumn W)=archColumn W := by + rw [physicalDoubleMatrix_eq,pow_two,←Matrix.mulVec_mulVec,archColumn_eigen,archColumn_eigen] + +theorem source_marked_eigenvector (W : ℕ) : + (markedDoubleMatrix (W+1)).mulVec (markedEigenvector W)= + fun s=>form 1 0 0 (eigenCoefficient W)*markedEigenvector W s := by + funext s + have h0:=congrFun (double_archColumn W) s + have h1:=congrFun (eigenLeft_equation W) s + have h2:=congrFun (eigenRight_equation W) s + have h3:=congrFun (eigenMixed_equation W) s + have hb w e : base (markedDoubleMatrix (W+1) w e)=physicalDoubleMatrix (W+1) w e := + congrFun (congrFun (marked_base (W+1)) w) e + apply jet_ext <;> + simp only [Matrix.mulVec,dotProduct,base_sum,left_sum,right_sum,both_sum,base_mul,left_mul, + right_mul,both_mul,markedEigenvector,base_form,left_form,right_form,both_form,hb, + zero_mul,one_mul,add_zero,Finset.sum_add_distrib] + · exact h0 + · exact h1 + · exact h2 + · convert h3 using 1 ; + simp only [eigenSource,Pi.add_apply,Matrix.mulVec,dotProduct,markedMixed,markedLeft,markedRight] ; abel +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet +open scoped Matrix +lemma gap_archColumn (W : ℕ) : (gapMatrix W).mulVec (archColumn W)=archColumn W := by + simp only [gapMatrix,Matrix.add_mulVec,Matrix.sub_mulVec,Matrix.one_mulVec,double_archColumn,sub_self,zero_add] + rw [projection_mulVec,arch_pairing,one_smul] +lemma inv_gap_archColumn (W : ℕ) : (gapMatrix W)⁻¹.mulVec (archColumn W)=archColumn W := by + conv_lhs => rw [←gap_archColumn W] + rw [Matrix.mulVec_mulVec,Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (physical_gap_det_ne_zero W)),Matrix.one_mulVec] +lemma archRow_double (W : ℕ) : (archRow W) ᵥ* (physicalDoubleMatrix (W+1))=archRow W := by + funext s + have h:=congrFun (congrFun (projection_mul_double W) (fun _=>1)) s + simpa [archProjection,archColumn_vacuum,Matrix.mul_apply,Matrix.vecMul,dotProduct] using h +lemma vecMul_projection (W : ℕ) (v : Column (W+1)→ℂ) : + v ᵥ* (archProjection W)=(v ⬝ᵥ archColumn W)•archRow W := by + funext s + simp only [Matrix.vecMul,dotProduct,archProjection,Pi.smul_apply,smul_eq_mul,Finset.sum_mul] + apply Finset.sum_congr rfl + intro t ht + ring +noncomputable def dualSolve (W : ℕ) (v : Column (W+1)→ℂ) : Column (W+1)→ℂ := + v ᵥ* (gapMatrix W)⁻¹ +lemma dualSolve_gap (W : ℕ) (v : Column (W+1)→ℂ) : + (dualSolve W v) ᵥ* (gapMatrix W)=v := by + rw [dualSolve,Matrix.vecMul_vecMul,Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (physical_gap_det_ne_zero W)),Matrix.vecMul_one] +lemma dualSolve_pair (W : ℕ) (v w : Column (W+1)→ℂ) : + dualSolve W v ⬝ᵥ w=v ⬝ᵥ reducedSolve W w := by + exact (Matrix.dotProduct_mulVec _ _ _).symm +lemma dualSolve_A (W : ℕ) (v : Column (W+1)→ℂ) : + dualSolve W v ⬝ᵥ archColumn W=v ⬝ᵥ archColumn W := by + rw [dualSolve,←Matrix.dotProduct_mulVec,inv_gap_archColumn] +lemma dualSolve_equation (W : ℕ) (v : Column (W+1)→ℂ) (hv : v ⬝ᵥ archColumn W=0) : + (dualSolve W v) ᵥ* (physicalDoubleMatrix (W+1))+v=dualSolve W v := by + have hg:=dualSolve_gap W v + have hp : (dualSolve W v) ᵥ* (archProjection W)=0 := by + rw [vecMul_projection,dualSolve_A,hv,zero_smul] + simp only [gapMatrix,Matrix.vecMul_add,Matrix.vecMul_sub,Matrix.vecMul_one,hp,add_zero] at hg + rw [sub_eq_iff_eq_add] at hg + exact (add_comm _ _).trans hg.symm +noncomputable def dualLeft (W : ℕ) : Column (W+1)→ℂ := + dualSolve W ((archRow W) ᵥ* (markedLeft (W+1))) +noncomputable def dualRight (W : ℕ) : Column (W+1)→ℂ := + dualSolve W ((archRow W) ᵥ* (markedRight (W+1))) +noncomputable def dualSource (W : ℕ) : Column (W+1)→ℂ := + (archRow W) ᵥ* (markedMixed (W+1))+ + (dualLeft W) ᵥ* (markedRight (W+1))+(dualRight W) ᵥ* (markedLeft (W+1)) +lemma dualSource_pair (W : ℕ) : dualSource W ⬝ᵥ archColumn W=eigenCoefficient W := by + simp only [dualSource,eigenCoefficient,eigenSource,archDual_add,add_dotProduct, + ←Matrix.dotProduct_mulVec,dualLeft,dualRight,dualSolve_pair] + change archDual W ((markedMixed (W+1)).mulVec (archColumn W))+ + _+_=archDual W ((markedMixed (W+1)).mulVec (archColumn W))+_+_ + rfl +noncomputable def dualMixed (W : ℕ) : Column (W+1)→ℂ := + dualSolve W (dualSource W-eigenCoefficient W•archRow W) +noncomputable def dualEigenvector (W : ℕ) : Column (W+1)→Jet := + fun s=>form (archRow W s) (dualLeft W s) (dualRight W s) (dualMixed W s) +lemma dualLeft_equation (W : ℕ) : + (dualLeft W) ᵥ* (physicalDoubleMatrix (W+1))+ + (archRow W) ᵥ* (markedLeft (W+1))=dualLeft W := by + apply dualSolve_equation + rw [←Matrix.dotProduct_mulVec] + exact archDual_left_A W +lemma dualRight_equation (W : ℕ) : + (dualRight W) ᵥ* (physicalDoubleMatrix (W+1))+ + (archRow W) ᵥ* (markedRight (W+1))=dualRight W := by + apply dualSolve_equation + rw [←Matrix.dotProduct_mulVec] + exact archDual_right_A W +lemma dualMixed_equation (W : ℕ) : + (dualMixed W) ᵥ* (physicalDoubleMatrix (W+1))+dualSource W= + dualMixed W+eigenCoefficient W•archRow W := by + have hz : (dualSource W-eigenCoefficient W•archRow W) ⬝ᵥ archColumn W=0 := by + rw [sub_dotProduct,smul_dotProduct,dualSource_pair] + change eigenCoefficient W-eigenCoefficient W*archDual W (archColumn W)=0 + rw [archDual_A,mul_one,sub_self] + have hh:=dualSolve_equation W _ hz + change (dualMixed W) ᵥ* (physicalDoubleMatrix (W+1))+ + (dualSource W-eigenCoefficient W•archRow W)=dualMixed W at hh + rw [←add_sub_assoc] at hh + exact sub_eq_iff_eq_add.mp hh + +theorem source_dual_eigenvector (W : ℕ) : + (dualEigenvector W) ᵥ* (markedDoubleMatrix (W+1))= + fun s=>form 1 0 0 (eigenCoefficient W)*dualEigenvector W s := by + funext s + have h0:=congrFun (archRow_double W) s + have h1:=congrFun (dualLeft_equation W) s + have h2:=congrFun (dualRight_equation W) s + have h3:=congrFun (dualMixed_equation W) s + have hb w e : base (markedDoubleMatrix (W+1) w e)=physicalDoubleMatrix (W+1) w e := + congrFun (congrFun (marked_base (W+1)) w) e + apply jet_ext <;> + simp only [Matrix.vecMul,dotProduct,base_sum,left_sum,right_sum,both_sum,base_mul,left_mul, + right_mul,both_mul,dualEigenvector,base_form,left_form,right_form,both_form,hb, + zero_mul,one_mul,add_zero,Finset.sum_add_distrib] + · exact h0 + · simpa only [Pi.add_apply,Matrix.vecMul,dotProduct,markedLeft,add_comm] using h1 + · simpa only [Pi.add_apply,Matrix.vecMul,dotProduct,markedRight,add_comm] using h2 + · convert h3 using 1 ; + simp only [dualSource,Pi.add_apply,Matrix.vecMul,dotProduct,markedMixed,markedLeft,markedRight] ; abel +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.BoundaryJet +open Filter Topology +open scoped Matrix Matrix.Norms.Operator +lemma powers_of_power_small {R : Type*} [NormedRing R] [NormOneClass R] (x : R) + {n : ℕ} (hn : n≠0) (hx : ‖x^n‖<1) : Tendsto (fun m : ℕ=>x^m) atTop (𝓝 0) := by + let C : ℝ := ∑ r∈Finset.range n,‖x^r‖ + have hb (m : ℕ) : ‖x^m‖≤‖x^n‖^(m/n)*C := by + have he : m=n*(m/n)+m%n := (Nat.div_add_mod m n).symm + calc + ‖x^m‖ = ‖(x^n)^(m/n)*x^(m%n)‖ := by conv_lhs => rw [he];rw [pow_add,pow_mul] + _ ≤ ‖(x^n)^(m/n)‖*‖x^(m%n)‖ := norm_mul_le _ _ + _ ≤ ‖x^n‖^(m/n)*C := by + apply mul_le_mul (norm_pow_le _ _) _ (norm_nonneg _) (by positivity) + exact Finset.single_le_sum (fun r hr=>norm_nonneg _) (Finset.mem_range.mpr (Nat.mod_lt m (Nat.pos_of_ne_zero hn))) + have hl:=((tendsto_pow_atTop_nhds_zero_of_lt_one (norm_nonneg (x^n)) hx).comp + (Nat.tendsto_div_const_atTop hn)).mul_const C + simp only [zero_mul] at hl + exact tendsto_zero_iff_norm_tendsto_zero.mpr (squeeze_zero (fun m=>norm_nonneg _) hb hl) +lemma continuous_base : Continuous base := + TrivSqZeroExt.continuous_fst.comp TrivSqZeroExt.continuous_fst +lemma continuous_left : Continuous left := + TrivSqZeroExt.continuous_fst.comp TrivSqZeroExt.continuous_snd +lemma continuous_right : Continuous right := + TrivSqZeroExt.continuous_snd.comp TrivSqZeroExt.continuous_fst +lemma continuous_both : Continuous both := + TrivSqZeroExt.continuous_snd.comp TrivSqZeroExt.continuous_snd +lemma continuous_C : Continuous C := + TrivSqZeroExt.continuous_inl.comp TrivSqZeroExt.continuous_inl +noncomputable def scaleHom (z : ℂ) : Jet→+*Jet where + toFun a := form (base a) (z*left a) (z*right a) (z^2*both a) + map_zero' := by apply jet_ext <;> simp [form,base,left,right,both,C,eL,eR] + map_one' := by apply jet_ext <;> simp [form,base,left,right,both,C,eL,eR] + map_add' a b := by apply jet_ext <;> simp [mul_add] + map_mul' a b := by apply jet_ext <;> simp <;> ring +@[simp] lemma base_scale (z : ℂ) (a : Jet) : base (scaleHom z a)=base a := by simp [scaleHom] +@[simp] lemma left_scale (z : ℂ) (a : Jet) : left (scaleHom z a)=z*left a := by simp [scaleHom] +@[simp] lemma right_scale (z : ℂ) (a : Jet) : right (scaleHom z a)=z*right a := by simp [scaleHom] +@[simp] lemma both_scale (z : ℂ) (a : Jet) : both (scaleHom z a)=z^2*both a := by simp [scaleHom] +lemma scale_zero (a : Jet) : scaleHom 0 a=C (base a) := by apply jet_ext <;> simp +lemma scale_inverse (z : ℂ) (hz : z≠0) (a : Jet) : scaleHom z⁻¹ (scaleHom z a)=a := by + apply jet_ext <;> simp [hz] +lemma continuous_scale (z : ℂ) : Continuous (scaleHom z) := by + dsimp [scaleHom,form] + exact ((continuous_C.comp continuous_base).add + (continuous_const.mul (continuous_C.comp (continuous_const.mul continuous_left)))).add + (continuous_const.mul (continuous_C.comp (continuous_const.mul continuous_right))) |>.add + (continuous_const.mul (continuous_C.comp (continuous_const.mul continuous_both))) +lemma continuous_scale_parameter (a : Jet) : Continuous (fun z : ℂ=>scaleHom z a) := by + change Continuous (fun z : ℂ=>form (base a) (z*left a) (z*right a) (z^2*both a)) + unfold form + exact ((continuous_const.add (continuous_const.mul (continuous_C.comp (continuous_id.mul_const _)))).add + (continuous_const.mul (continuous_C.comp (continuous_id.mul_const _)))).add + (continuous_const.mul (continuous_C.comp ((continuous_id.pow 2).mul_const _))) +noncomputable def scaleMatrix {ι : Type*} (z : ℂ) (M : Matrix ι ι Jet) : Matrix ι ι Jet := + M.map (scaleHom z) +lemma scaleMatrix_pow {ι : Type*} [Fintype ι] [DecidableEq ι] (z : ℂ) (M : Matrix ι ι Jet) (m : ℕ) : + scaleMatrix z (M^m)=(scaleMatrix z M)^m := by + exact (scaleHom z).mapMatrix.map_pow M m +lemma scaleMatrix_inverse {ι : Type*} (z : ℂ) (hz : z≠0) (M : Matrix ι ι Jet) : + scaleMatrix z⁻¹ (scaleMatrix z M)=M := by + funext i j + exact scale_inverse z hz (M i j) +lemma continuous_scaleMatrix {ι : Type*} (z : ℂ) : Continuous (scaleMatrix (ι:=ι) z) := by + apply continuous_pi + intro i + apply continuous_pi + intro j + exact (continuous_scale z).comp ((continuous_apply j).comp (continuous_apply i)) +lemma continuous_scaleMatrix_parameter {ι : Type*} (M : Matrix ι ι Jet) : + Continuous (fun z : ℂ=>scaleMatrix z M) := by + apply continuous_pi + intro i + apply continuous_pi + intro j + exact continuous_scale_parameter (M i j) + +theorem stable_jet_powers {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] + (M : Matrix ι ι Jet) + (hM : Tendsto (fun n : ℕ=>fun i j=>base ((M^n) i j)) atTop (𝓝 0)) : + Tendsto (fun n : ℕ=>M^n) atTop (𝓝 0) := by + have h0 : Tendsto (fun n : ℕ=>scaleMatrix 0 (M^n)) atTop (𝓝 0) := by + apply tendsto_pi_nhds.mpr + intro i + apply tendsto_pi_nhds.mpr + intro j + have hh:=(continuous_C.tendsto 0).comp (tendsto_pi_nhds.mp (tendsto_pi_nhds.mp hM i) j) + simpa only [scaleMatrix,Matrix.map_apply,scale_zero,map_zero,Pi.zero_apply,Matrix.zero_apply,Function.comp_def] using hh + have hev : ∀ᶠ n : ℕ in atTop,‖scaleMatrix 0 (M^n)‖<1 := by + exact h0.norm.eventually (gt_mem_nhds (by norm_num)) + obtain ⟨n,hn,hsmall⟩:=((eventually_ge_atTop 1).and hev).exists + have hn0 : n≠0 := by omega + have hcont : ContinuousAt (fun z : ℂ=>‖scaleMatrix z (M^n)‖) 0 := + ((continuous_scaleMatrix_parameter (M^n)).norm).continuousAt + have hez : ∀ᶠ z : ℂ in 𝓝 (0:ℂ),‖scaleMatrix z (M^n)‖<1 := + hcont.eventually (gt_mem_nhds hsmall) + obtain ⟨z,hz,hzn⟩ : ∃ z : ℂ,‖scaleMatrix z (M^n)‖<1 ∧ z≠0 := by + have ht : ∀ᶠ z : ℂ in 𝓝[≠] (0:ℂ),‖scaleMatrix z (M^n)‖<1 ∧ z≠0 := + (hez.filter_mono nhdsWithin_le_nhds).and self_mem_nhdsWithin + exact ht.exists + have hp:=powers_of_power_small (scaleMatrix z M) hn0 (by simpa only [scaleMatrix_pow] using hz) + have hg:=(continuous_scaleMatrix z⁻¹).tendsto (0:Matrix ι ι Jet) |>.comp hp + have he (m : ℕ) : scaleMatrix z⁻¹ (scaleMatrix z M^m)=M^m := by + rw [←scaleMatrix_pow,scaleMatrix_inverse z hzn] + simp only [Function.comp_def,he] at hg + simpa only [scaleMatrix,Matrix.map_zero,map_zero] using hg +end CriticalHoneycomb.BoundaryJet + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/BoundaryFusionEquation.lean b/lean/OAI/Combinatorics/HoneycombChords/BoundaryFusionEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad868829417c874856d0f68d38c9e18afe2ceb15 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/BoundaryFusionEquation.lean @@ -0,0 +1,437 @@ +import OAI.Combinatorics.HoneycombChords.ReflectionEquation + +namespace OAI + +/-! Polynomial boundary fusion identities for the honeycomb strip transfer. +The fusion maps preserve the exact boundary normalization. -/ + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix +noncomputable def wNum (r : ℂ) : Matrix Pair (Fin 3) ℂ := fun p j=> + match p.1.val,p.2.val,j.val with + | 0,1,0 => 1 + | 1,0,0 => 1 + | 2,1,2 => 1 + | 1,2,2 => 1 + | 1,1,1 => r^2-r^14 + | 0,2,1 => -r^12 + | 2,0,1 => r^4 + | _,_,_ => 0 +noncomputable def wBarNum (r : ℂ) : Matrix Pair (Fin 3) ℂ := fun p j=> + match p.1.val,p.2.val,j.val with + | 0,1,0 => 1 + | 1,0,0 => 1 + | 2,1,2 => 1 + | 1,2,2 => 1 + | 1,1,1 => r^2-r^14 + | 0,2,1 => r^4 + | 2,0,1 => -r^12 + | _,_,_ => 0 +noncomputable def bNum (r z : ℂ) : ℂ := z*(r^3*z^2+r^13) +noncomputable def aNum (r z : ℂ) : ℂ := (r^4*z^4+r^12)*(r^6*z^4+r^10) +noncomputable def fusionL0 (r z : ℂ) : Matrix Pair (Fin 3) ℂ := + bNum r z • (slot2 (dConstant r (-z*r^14)) * + ((rNumerator r (z^2) 1 * slot1 (dConstant r (z*r^2))) * wBarNum r)) +noncomputable def fusionL1 (r z : ℂ) : Matrix Pair (Fin 3) ℂ := + bNum r z • (slot2 (dLinear r (-z*r^14)) * + ((rNumerator r (z^2) 1 * slot1 (dConstant r (z*r^2))) * wBarNum r)+ + slot2 (dConstant r (-z*r^14)) * + ((rNumerator r (z^2) 1 * slot1 (dLinear r (z*r^2))) * wBarNum r)) +noncomputable def fusionR0 (r z : ℂ) : Matrix Pair (Fin 3) ℂ := + (aNum r z*bNum r (z*r^2)*bNum r (-z*r^14)) • (wNum r * dConstant r z) +noncomputable def fusionR1 (r z : ℂ) : Matrix Pair (Fin 3) ℂ := + (aNum r z*bNum r (z*r^2)*bNum r (-z*r^14)) • (wNum r * dLinear r z) +lemma slot2_constant_rect (r z : ℂ) (M : Matrix Pair (Fin 3) ℂ) (p : Pair) (j : Fin 3) : + (slot2 (dConstant r z)*M) p j=dValue r z p.2*M p j := by + classical + simp [Matrix.mul_apply,slot2,dConstant,dValue,Fintype.sum_prod_type,ite_mul] +lemma slot2_linear_rect (r z : ℂ) (M : Matrix Pair (Fin 3) ℂ) (p : Pair) (j : Fin 3) : + (slot2 (dLinear r z)*M) p j= + if p.2=0 then (z^4-1)*M (p.1,1) j else + if p.2=1 then (r^4*(z^4-1))*M (p.1,2) j else 0 := by + classical + rcases p with ⟨a,b⟩ + fin_cases b <;> simp [Matrix.mul_apply,slot2,dLinear,Fintype.sum_prod_type,ite_mul] +lemma core0_rect (r z : ℂ) (A : Matrix Pair Pair ℂ) (B : Matrix Pair (Fin 3) ℂ) + (p : Pair) (j : Fin 3) : + (A*slot1 (dConstant r z)*B) p j=∑ k,A p k*dValue r z k.1*B k j := by + rw [Matrix.mul_apply] + simp only [mul_slot1_constant] +lemma core1_rect (r z : ℂ) (A : Matrix Pair Pair ℂ) (B : Matrix Pair (Fin 3) ℂ) + (p : Pair) (j : Fin 3) : + (A*slot1 (dLinear r z)*B) p j=∑ k, + (if k.1=1 then A p (0,k.2)*(z^4-1) else + if k.1=2 then A p (1,k.2)*(r^4*(z^4-1)) else 0)*B k j := by + rw [Matrix.mul_apply] + simp only [mul_slot1_linear] +private abbrev boundaryFusionAdd (a b : ℂ) : ℂ := a+b +private abbrev boundaryFusionMul (a b : ℂ) : ℂ := a*b +private abbrev boundaryFusionPow (a : ℂ) (n : ℕ) : ℂ := a^n +section +variable (r z : ℂ) (hr : r^16+1=0) + +private lemma boundaryFusionComponent0000 : fusionL0 r z (0,0) 0 = fusionR0 r z (0,0) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0001 : fusionL0 r z (0,0) 1 = fusionR0 r z (0,0) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0002 : fusionL0 r z (0,0) 2 = fusionR0 r z (0,0) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate0010 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 11)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 7))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 11))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 5))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 15)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 11))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 11))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 5)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 5))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 3))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 13)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 5)))))) +include hr in +private lemma boundaryFusionComponent0010 : fusionL0 r z (0,1) 0 = fusionR0 r z (0,1) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate0010 r z*x) hr + dsimp only [boundaryFusionCertificate0010,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma boundaryFusionComponent0011 : fusionL0 r z (0,1) 1 = fusionR0 r z (0,1) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0012 : fusionL0 r z (0,1) 2 = fusionR0 r z (0,1) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0020 : fusionL0 r z (0,2) 0 = fusionR0 r z (0,2) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate0021 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 105) (boundaryFusionPow z 15))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 105) (boundaryFusionPow z 11)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 105) (boundaryFusionPow z 7)) (boundaryFusionMul (boundaryFusionPow r 101) (boundaryFusionPow z 11)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 99) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 99) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 97) (boundaryFusionPow z 7)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 95) (boundaryFusionPow z 17)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 95) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 95) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 93) (boundaryFusionPow z 11))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 93) (boundaryFusionPow z 7))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 91) (boundaryFusionPow z 13))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 91) (boundaryFusionPow z 5)))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 15))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 11))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 87) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 85) (boundaryFusionPow z 7))) (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 13))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 15))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 11))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 7)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 17))) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 77) (boundaryFusionPow z 15)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 77) (boundaryFusionPow z 11))) (boundaryFusionMul ((-3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 9)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 5)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 15)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 11))))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 7)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 3)))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 13))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 9)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 7)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 13)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 9))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 5)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 11)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 7)) (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 15)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 3))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 13)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 5))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 11))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 13)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 9)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 5)) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 11))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 43) (boundaryFusionPow z 13)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 43) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 3))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 31) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 31) (boundaryFusionPow z 5))))))))) +include hr in +private lemma boundaryFusionComponent0021 : fusionL0 r z (0,2) 1 = fusionR0 r z (0,2) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate0021 r z*x) hr + dsimp only [boundaryFusionCertificate0021,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + linear_combination hq + +private lemma boundaryFusionComponent0022 : fusionL0 r z (0,2) 2 = fusionR0 r z (0,2) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate0100 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 93) (boundaryFusionPow z 13))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 9)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 85) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 15))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 9)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 77) (boundaryFusionPow z 9)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 11)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 5)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 13))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 5)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 15))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 13)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 9)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 11))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 7)) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 5))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 15)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 7)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 5)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 15)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 5))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 11)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 3)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 9))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 11)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 43) (boundaryFusionPow z 7))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 5)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 39) (boundaryFusionPow z 15))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 35) (boundaryFusionPow z 11)))))))) +include hr in +private lemma boundaryFusionComponent0100 : fusionL0 r z (1,0) 0 = fusionR0 r z (1,0) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate0100 r z*x) hr + dsimp only [boundaryFusionCertificate0100,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma boundaryFusionComponent0101 : fusionL0 r z (1,0) 1 = fusionR0 r z (1,0) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0102 : fusionL0 r z (1,0) 2 = fusionR0 r z (1,0) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0110 : fusionL0 r z (1,1) 0 = fusionR0 r z (1,1) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate0111 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 97) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 97) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 13))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 87) (boundaryFusionPow z 15)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 87) (boundaryFusionPow z 11)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 11)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 7)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 9)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 11))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 7)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 13))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 13)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 5)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 13)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 9)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 5)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 7)))))) +include hr in +private lemma boundaryFusionComponent0111 : fusionL0 r z (1,1) 1 = fusionR0 r z (1,1) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate0111 r z*x) hr + dsimp only [boundaryFusionCertificate0111,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma boundaryFusionComponent0112 : fusionL0 r z (1,1) 2 = fusionR0 r z (1,1) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0120 : fusionL0 r z (1,2) 0 = fusionR0 r z (1,2) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0121 : fusionL0 r z (1,2) 1 = fusionR0 r z (1,2) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate0122 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 93) (boundaryFusionPow z 13))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 9)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 85) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 15))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 9)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 77) (boundaryFusionPow z 9)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 11)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 5)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 13))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 5)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 15))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 13)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 9)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 11))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 7)) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 5))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 15)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 7)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 5)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 15)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 5))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 11)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 3)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 9))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 11)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 43) (boundaryFusionPow z 7))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 5)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 39) (boundaryFusionPow z 15))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 35) (boundaryFusionPow z 11)))))))) +include hr in +private lemma boundaryFusionComponent0122 : fusionL0 r z (1,2) 2 = fusionR0 r z (1,2) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate0122 r z*x) hr + dsimp only [boundaryFusionCertificate0122,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma boundaryFusionComponent0200 : fusionL0 r z (2,0) 0 = fusionR0 r z (2,0) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate0201 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 97) (boundaryFusionPow z 15))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 97) (boundaryFusionPow z 11)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 97) (boundaryFusionPow z 7))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 93) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 91) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 91) (boundaryFusionPow z 9))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 89) (boundaryFusionPow z 7)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 87) (boundaryFusionPow z 17))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 87) (boundaryFusionPow z 13)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 87) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 85) (boundaryFusionPow z 11))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 13)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 83) (boundaryFusionPow z 5)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 15))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 81) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 13))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 77) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 17)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 13))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 9))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 5)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 15))) (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 11)))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 5))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 15))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 11))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 65) (boundaryFusionPow z 3)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 13)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 11)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 7))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 13))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 9))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 5))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 15)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 11))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 7))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 9))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 11)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 7)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 3)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 47) (boundaryFusionPow z 13))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 7)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 43) (boundaryFusionPow z 9))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 39) (boundaryFusionPow z 13)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 39) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 39) (boundaryFusionPow z 5)))))))) +include hr in +private lemma boundaryFusionComponent0201 : fusionL0 r z (2,0) 1 = fusionR0 r z (2,0) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate0201 r z*x) hr + dsimp only [boundaryFusionCertificate0201,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma boundaryFusionComponent0202 : fusionL0 r z (2,0) 2 = fusionR0 r z (2,0) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0210 : fusionL0 r z (2,1) 0 = fusionR0 r z (2,1) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0211 : fusionL0 r z (2,1) 1 = fusionR0 r z (2,1) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate0212 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 79) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 11)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 75) (boundaryFusionPow z 7))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 73) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 71) (boundaryFusionPow z 11))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 69) (boundaryFusionPow z 5))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 15)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 67) (boundaryFusionPow z 11))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 15))) (boundaryFusionMul (boundaryFusionPow r 63) (boundaryFusionPow z 11))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 61) (boundaryFusionPow z 5)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 59) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 9)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 57) (boundaryFusionPow z 5))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 11))) (boundaryFusionMul (boundaryFusionPow r 55) (boundaryFusionPow z 7))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 53) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 7))) (boundaryFusionMul (boundaryFusionPow r 51) (boundaryFusionPow z 3))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 13)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 49) (boundaryFusionPow z 9))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 13))) (boundaryFusionMul (boundaryFusionPow r 45) (boundaryFusionPow z 9))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 9))) (boundaryFusionMul (boundaryFusionPow r 41) (boundaryFusionPow z 5)))))) +include hr in +private lemma boundaryFusionComponent0212 : fusionL0 r z (2,1) 2 = fusionR0 r z (2,1) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate0212 r z*x) hr + dsimp only [boundaryFusionCertificate0212,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma boundaryFusionComponent0220 : fusionL0 r z (2,2) 0 = fusionR0 r z (2,2) 0 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0221 : fusionL0 r z (2,2) 1 = fusionR0 r z (2,2) 1 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent0222 : fusionL0 r z (2,2) 2 = fusionR0 r z (2,2) 2 := by + simp only [fusionL0,fusionR0,Matrix.smul_apply,smul_eq_mul,slot2_constant_rect,core0_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dConstant,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate1000 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 90) (boundaryFusionPow z 12)) (boundaryFusionMul (boundaryFusionPow r 86) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 14)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 14)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 10))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 14)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 10)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 10)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 12)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 16)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 8)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 14)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 12)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 4)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 14))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 10))) (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 10))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 6)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 14)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 6))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 4))) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 10))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 6))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 14))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 6))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 10))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 6)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 26) (boundaryFusionPow z 12))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 24) (boundaryFusionPow z 6)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 24) (boundaryFusionPow z 2)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 22) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 18) (boundaryFusionPow z 12))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 18) (boundaryFusionPow z 8)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 14) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 14) (boundaryFusionPow z 4))))))) +include hr in +private lemma boundaryFusionComponent1000 : fusionL1 r z (0,0) 0 = fusionR1 r z (0,0) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate1000 r z*x) hr + dsimp only [boundaryFusionCertificate1000,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + linear_combination hq + +private lemma boundaryFusionComponent1001 : fusionL1 r z (0,0) 1 = fusionR1 r z (0,0) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1002 : fusionL1 r z (0,0) 2 = fusionR1 r z (0,0) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1010 : fusionL1 r z (0,1) 0 = fusionR1 r z (0,1) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate1011 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 110) (boundaryFusionPow z 16))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 110) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 110) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 106) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 104) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 104) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 102) (boundaryFusionPow z 8))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 100) (boundaryFusionPow z 18))))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 100) (boundaryFusionPow z 14))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 100) (boundaryFusionPow z 10))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 98) (boundaryFusionPow z 12))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 98) (boundaryFusionPow z 8)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 96) (boundaryFusionPow z 14))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 94) (boundaryFusionPow z 16))))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 94) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 94) (boundaryFusionPow z 8)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 92) (boundaryFusionPow z 14)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 92) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 90) (boundaryFusionPow z 8)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 10)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 86) (boundaryFusionPow z 16))) (boundaryFusionMul (boundaryFusionPow r 86) (boundaryFusionPow z 8))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 18)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 14))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 10))))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 16))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 12)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 10)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 16))) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 14)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 10))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 14)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 16)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 12)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 18))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionMul ((-3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 16)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 12))))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 4)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 18)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 14))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 10)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 12)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 4)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 14)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 10))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 12))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 4))) (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 4)) (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 10)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 16))) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 4))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 10)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 6)))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 2))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 16)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 12))))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 14)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 6)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 2)) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 12))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 4))))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 6))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 8))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 4))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 34) (boundaryFusionPow z 12)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 34) (boundaryFusionPow z 8))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 34) (boundaryFusionPow z 4)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 10)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 6)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 12)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 2))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 18) (boundaryFusionPow z 8)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 18) (boundaryFusionPow z 4))))))))) +include hr in +private lemma boundaryFusionComponent1011 : fusionL1 r z (0,1) 1 = fusionR1 r z (0,1) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate1011 r z*x) hr + dsimp only [boundaryFusionCertificate1011,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + linear_combination hq + +private lemma boundaryFusionComponent1012 : fusionL1 r z (0,1) 2 = fusionR1 r z (0,1) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1020 : fusionL1 r z (0,2) 0 = fusionR1 r z (0,2) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1021 : fusionL1 r z (0,2) 1 = fusionR1 r z (0,2) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate1022 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 14)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 4)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 14)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 6)) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 16))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 10))) (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 16)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 8)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 14))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 10)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 14))) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 12))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 8)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 4))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 14)))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 10))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 6))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 2)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 12))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 8)))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 16))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 4)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 14)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 4))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 14)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 12)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 8))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 4)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 14))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 10))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 6))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 2))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 8)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 10))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 6)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 16))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 8))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 4))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 34) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 34) (boundaryFusionPow z 8)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 6))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 2)) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 22) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 22) (boundaryFusionPow z 4)))))))) +include hr in +private lemma boundaryFusionComponent1022 : fusionL1 r z (0,2) 2 = fusionR1 r z (0,2) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate1022 r z*x) hr + dsimp only [boundaryFusionCertificate1022,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + linear_combination hq + +private lemma boundaryFusionComponent1100 : fusionL1 r z (1,0) 0 = fusionR1 r z (1,0) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate1101 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 108) (boundaryFusionPow z 14)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 108) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 104) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 100) (boundaryFusionPow z 14)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 100) (boundaryFusionPow z 10)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 98) (boundaryFusionPow z 16)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 98) (boundaryFusionPow z 12))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 98) (boundaryFusionPow z 8))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 96) (boundaryFusionPow z 14)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 96) (boundaryFusionPow z 10))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 94) (boundaryFusionPow z 8))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 92) (boundaryFusionPow z 14))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 92) (boundaryFusionPow z 10)) (boundaryFusionMul (boundaryFusionPow r 92) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 90) (boundaryFusionPow z 16)) (boundaryFusionAdd (boundaryFusionMul ((-3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 90) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 6)) (boundaryFusionMul (boundaryFusionPow r 86) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 86) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 14))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 10)))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 6))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 8)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 14)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 16)) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 6))) (boundaryFusionMul ((4:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 12))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 4)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 14)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 8))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 14)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 6)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 12))))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 4))) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 18)))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 14)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 16))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 12))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 8)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 14)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 6)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 12))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 8)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 4))) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 16)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 4))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 6))) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 4))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 14)))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 10))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 4)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 6)) (boundaryFusionMul ((-3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 8))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 4)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 14)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 10)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 34) (boundaryFusionPow z 12))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 10))))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 6)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 12))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 8)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 4)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 10))) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 24) (boundaryFusionPow z 14))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 20) (boundaryFusionPow z 10))) (boundaryFusionMul (boundaryFusionPow r 20) (boundaryFusionPow z 6)))))))) +include hr in +private lemma boundaryFusionComponent1101 : fusionL1 r z (1,0) 1 = fusionR1 r z (1,0) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate1101 r z*x) hr + dsimp only [boundaryFusionCertificate1101,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + linear_combination hq + +private lemma boundaryFusionComponent1102 : fusionL1 r z (1,0) 2 = fusionR1 r z (1,0) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1110 : fusionL1 r z (1,1) 0 = fusionR1 r z (1,1) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1111 : fusionL1 r z (1,1) 1 = fusionR1 r z (1,1) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate1112 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 98) (boundaryFusionPow z 14)) (boundaryFusionMul (boundaryFusionPow r 94) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 90) (boundaryFusionPow z 14)) (boundaryFusionMul (boundaryFusionPow r 88) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 86) (boundaryFusionPow z 10)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 4))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 10))) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 16))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 12))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 8))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 78) (boundaryFusionPow z 10))) (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 16))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 14))) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 10)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 16))) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 4))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 14))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 10)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 8))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 10)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 6))) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 2))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 16))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 12))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 14))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 6)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 12))))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 4)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 12)) (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 4)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 14))) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 2))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 8)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 4)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 14))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 10))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 6))) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 4))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 14)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 6)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 12))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 4))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 6))) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 2))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 12))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 34) (boundaryFusionPow z 10))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 12))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 6))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 4)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 26) (boundaryFusionPow z 14))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 22) (boundaryFusionPow z 10))))))))) +include hr in +private lemma boundaryFusionComponent1112 : fusionL1 r z (1,1) 2 = fusionR1 r z (1,1) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate1112 r z*x) hr + dsimp only [boundaryFusionCertificate1112,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + linear_combination hq + +private lemma boundaryFusionComponent1120 : fusionL1 r z (1,2) 0 = fusionR1 r z (1,2) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1121 : fusionL1 r z (1,2) 1 = fusionR1 r z (1,2) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1122 : fusionL1 r z (1,2) 2 = fusionR1 r z (1,2) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1200 : fusionL1 r z (2,0) 0 = fusionR1 r z (2,0) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1201 : fusionL1 r z (2,0) 1 = fusionR1 r z (2,0) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private noncomputable def boundaryFusionCertificate1202 (r z : ℂ) : ℂ := + boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 90) (boundaryFusionPow z 12)) (boundaryFusionMul (boundaryFusionPow r 86) (boundaryFusionPow z 8))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 84) (boundaryFusionPow z 14)) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 16)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 82) (boundaryFusionPow z 12))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 80) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 14)) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 76) (boundaryFusionPow z 10)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 16)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 12))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 74) (boundaryFusionPow z 4))) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 18)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 14))) (boundaryFusionMul ((3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 10)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 72) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 16))) (boundaryFusionMul ((4:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 12)))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 70) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 68) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 66) (boundaryFusionPow z 12))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 64) (boundaryFusionPow z 6))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 12))) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 62) (boundaryFusionPow z 4))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 14)) (boundaryFusionMul ((-3:ℂ)) (boundaryFusionMul (boundaryFusionPow r 60) (boundaryFusionPow z 10))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 12)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 58) (boundaryFusionPow z 4)) (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 14)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 10))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 56) (boundaryFusionPow z 2))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 16)) (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 12))))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 54) (boundaryFusionPow z 8)) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 52) (boundaryFusionPow z 6)))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 50) (boundaryFusionPow z 4))) (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 48) (boundaryFusionPow z 6)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 12))) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 8)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 46) (boundaryFusionPow z 4))) (boundaryFusionMul (boundaryFusionPow r 44) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 12))) (boundaryFusionMul ((2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 8))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 42) (boundaryFusionPow z 4))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 14)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 10)) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 6))) (boundaryFusionMul (boundaryFusionPow r 40) (boundaryFusionPow z 2))))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 12)) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 38) (boundaryFusionPow z 8)))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 10))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 36) (boundaryFusionPow z 6))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 14))) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 10))) (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 32) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 30) (boundaryFusionPow z 4)))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-2:ℂ)) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 10))) (boundaryFusionMul (boundaryFusionPow r 28) (boundaryFusionPow z 6))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 26) (boundaryFusionPow z 12))) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 24) (boundaryFusionPow z 6))) (boundaryFusionMul (boundaryFusionPow r 24) (boundaryFusionPow z 2))))) (boundaryFusionAdd (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 22) (boundaryFusionPow z 8))) (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 18) (boundaryFusionPow z 12)))) (boundaryFusionAdd (boundaryFusionMul (boundaryFusionPow r 18) (boundaryFusionPow z 8)) (boundaryFusionAdd (boundaryFusionMul ((-1:ℂ)) (boundaryFusionMul (boundaryFusionPow r 14) (boundaryFusionPow z 8))) (boundaryFusionMul (boundaryFusionPow r 14) (boundaryFusionPow z 4)))))))) +include hr in +private lemma boundaryFusionComponent1202 : fusionL1 r z (2,0) 2 = fusionR1 r z (2,0) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>boundaryFusionCertificate1202 r z*x) hr + dsimp only [boundaryFusionCertificate1202,boundaryFusionAdd,boundaryFusionMul,boundaryFusionPow] at hq + linear_combination hq + +private lemma boundaryFusionComponent1210 : fusionL1 r z (2,1) 0 = fusionR1 r z (2,1) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1211 : fusionL1 r z (2,1) 1 = fusionR1 r z (2,1) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1212 : fusionL1 r z (2,1) 2 = fusionR1 r z (2,1) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1220 : fusionL1 r z (2,2) 0 = fusionR1 r z (2,2) 0 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1221 : fusionL1 r z (2,2) 1 = fusionR1 r z (2,2) 1 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +private lemma boundaryFusionComponent1222 : fusionL1 r z (2,2) 2 = fusionR1 r z (2,2) 2 := by + simp only [fusionL1,fusionR1,Matrix.smul_apply,smul_eq_mul,Matrix.add_apply,slot2_constant_rect,slot2_linear_rect,core0_rect,core1_rect] + simp [Matrix.mul_apply,dValue,rNumerator,wNum,wBarNum,dLinear,bNum,aNum,-mul_eq_zero] + +include hr in +theorem source_numerator0 : fusionL0 r z=fusionR0 r z := by + funext p q + rcases p with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> fin_cases q + · exact boundaryFusionComponent0000 r z + · exact boundaryFusionComponent0001 r z + · exact boundaryFusionComponent0002 r z + · exact boundaryFusionComponent0010 r z hr + · exact boundaryFusionComponent0011 r z + · exact boundaryFusionComponent0012 r z + · exact boundaryFusionComponent0020 r z + · exact boundaryFusionComponent0021 r z hr + · exact boundaryFusionComponent0022 r z + · exact boundaryFusionComponent0100 r z hr + · exact boundaryFusionComponent0101 r z + · exact boundaryFusionComponent0102 r z + · exact boundaryFusionComponent0110 r z + · exact boundaryFusionComponent0111 r z hr + · exact boundaryFusionComponent0112 r z + · exact boundaryFusionComponent0120 r z + · exact boundaryFusionComponent0121 r z + · exact boundaryFusionComponent0122 r z hr + · exact boundaryFusionComponent0200 r z + · exact boundaryFusionComponent0201 r z hr + · exact boundaryFusionComponent0202 r z + · exact boundaryFusionComponent0210 r z + · exact boundaryFusionComponent0211 r z + · exact boundaryFusionComponent0212 r z hr + · exact boundaryFusionComponent0220 r z + · exact boundaryFusionComponent0221 r z + · exact boundaryFusionComponent0222 r z +include hr in +theorem source_numerator1 : fusionL1 r z=fusionR1 r z := by + funext p q + rcases p with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> fin_cases q + · exact boundaryFusionComponent1000 r z hr + · exact boundaryFusionComponent1001 r z + · exact boundaryFusionComponent1002 r z + · exact boundaryFusionComponent1010 r z + · exact boundaryFusionComponent1011 r z hr + · exact boundaryFusionComponent1012 r z + · exact boundaryFusionComponent1020 r z + · exact boundaryFusionComponent1021 r z + · exact boundaryFusionComponent1022 r z hr + · exact boundaryFusionComponent1100 r z + · exact boundaryFusionComponent1101 r z hr + · exact boundaryFusionComponent1102 r z + · exact boundaryFusionComponent1110 r z + · exact boundaryFusionComponent1111 r z + · exact boundaryFusionComponent1112 r z hr + · exact boundaryFusionComponent1120 r z + · exact boundaryFusionComponent1121 r z + · exact boundaryFusionComponent1122 r z + · exact boundaryFusionComponent1200 r z + · exact boundaryFusionComponent1201 r z + · exact boundaryFusionComponent1202 r z hr + · exact boundaryFusionComponent1210 r z + · exact boundaryFusionComponent1211 r z + · exact boundaryFusionComponent1212 r z + · exact boundaryFusionComponent1220 r z + · exact boundaryFusionComponent1221 r z + · exact boundaryFusionComponent1222 r z +end +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/BoundarySystems.lean b/lean/OAI/Combinatorics/HoneycombChords/BoundarySystems.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dd03a710b3366883c0d7cb50e2b4eab7b0f8586 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/BoundarySystems.lean @@ -0,0 +1,1288 @@ +import OAI.Combinatorics.HoneycombChords.Continuation + +namespace OAI + +/-! +# All-boundary chord decompositions + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations + +/-- The actual four rectangle cuts; internal edges are not constrained. -/ +def BoundaryWire {W H : ℕ} : GridWire W H → Prop + | .inl (i,_) => i=0 ∨ i=Fin.last W + | .inr (_,j) => j=0 ∨ j=Fin.last H + +def SameBoundary {W H : ℕ} (x y : Assignment W H) : Prop := + ∀ w,BoundaryWire w → x.1 w=y.1 w + +lemma sameBoundary_refl {W H : ℕ} (x : Assignment W H) : SameBoundary x x := fun _ _=>rfl +lemma sameBoundary_symm {W H : ℕ} {x y : Assignment W H} (h : SameBoundary x y) : + SameBoundary y x := fun w hw=>(h w hw).symm +lemma sameBoundary_trans {W H : ℕ} {x y z : Assignment W H} + (h : SameBoundary x y) (h' : SameBoundary y z) : SameBoundary x z := + fun w hw=>(h w hw).trans (h' w hw) +lemma sameBoundary_hasBoundary {W H : ℕ} (x y : Assignment W H) : + SameBoundary x y ↔ HasBoundary (fun j=>y.1 (.inl (0,j))) + (fun j=>y.1 (.inl (Fin.last W,j))) (fun i=>y.1 (.inr (i,0))) + (fun i=>y.1 (.inr (i,Fin.last H))) x.1 := by + constructor + · intro hh + exact ⟨⟨fun j=>hh _ (Or.inl rfl),fun i=>hh _ (Or.inr rfl)⟩, + fun j=>hh _ (Or.inr rfl),fun i=>hh _ (Or.inl rfl)⟩ + · intro hh w hw + cases w with + | inl w => + rcases w with ⟨i,j⟩ + rcases hw with rfl|rfl + · exact hh.1.1 j + · exact hh.2.1 j + | inr w => + rcases w with ⟨i,j⟩ + rcases hw with rfl|rfl + · exact hh.2.2 i + · exact hh.1.2 i + +lemma erase_sameBoundary {W H n : ℕ} (p : CenterPath n) {x y : Assignment W H} + (h : SameBoundary x y) : SameBoundary (eraseAssignment p x) (eraseAssignment p y) := by + intro w hw + change p.erase (assignmentSpins x) (wireEmbedding (.inl w))= + p.erase (assignmentSpins y) (wireEmbedding (.inl w)) + unfold CenterPath.erase + split_ifs + · rfl + · simp only [assignmentSpins,spins_wire] + exact h w hw + +lemma fill_sameBoundary {W H n : ℕ} (p : CenterPath n) {x y : Assignment W H} + (h : SameBoundary x y) : SameBoundary (fillAssignment p x) (fillAssignment p y) := by + intro w hw + change p.fill (assignmentSpins x) (wireEmbedding (.inl w))= + p.fill (assignmentSpins y) (wireEmbedding (.inl w)) + unfold CenterPath.fill + split_ifs + · rfl + · simp only [assignmentSpins,spins_wire] + exact h w hw + +noncomputable instance {W H : ℕ} (x y : Assignment W H) : Decidable (SameBoundary x y) := + Classical.propDecidable _ +noncomputable def relativeTerm {W H : ℕ} (cfg : Cell W H → Shape) + (x₀ x : Assignment W H) : ℂ := + if SameBoundary x x₀ ∧ Matches cfg x.1 x.2 then + centerProduct (domain W H) (assignmentSpins x) else 0 +lemma relativeTerm_ne_zero {W H : ℕ} (cfg : Cell W H → Shape) + (x₀ x : Assignment W H) : relativeTerm cfg x₀ x≠0 ↔ + SameBoundary x x₀ ∧ Matches cfg x.1 x.2 ∧ + centerProduct (domain W H) (assignmentSpins x)≠0 := by + unfold relativeTerm + split_ifs <;> tauto + +lemma relativeTerm_eq_masked {W H : ℕ} (cfg : Cell W H → Shape) + (x₀ x : Assignment W H) : relativeTerm cfg x₀ x= + maskedTerm cfg (fun j=>x₀.1 (.inl (0,j))) (fun j=>x₀.1 (.inl (Fin.last W,j))) + (fun i=>x₀.1 (.inr (i,0))) (fun i=>x₀.1 (.inr (i,Fin.last H))) x := by + simp only [relativeTerm,maskedTerm,sameBoundary_hasBoundary] + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations + +/-- Removing one actual oriented component, retaining every other boundary +port in the residual path system. -/ +theorem arbitrary_boundary_path_factorization {W H n : ℕ} (hW : 0eraseAssignment p x) + · intro x hx hn; exact Finset.mem_univ _ + · intro x hx hn y hy hm he + have hxf := (forward x hn).2 + have hyf := (forward y hm).2 + rw [←hxf,←hyf,he] + · intro y hy hn + have hg : G y≠0 := (mul_ne_zero_iff.mp hn).2 + have hh := backward y hg + exact ⟨fillAssignment p y,Finset.mem_univ _,hh.1,hh.2⟩ + · intro x hx hn + exact (forward x hn).1 + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition + +lemma localTensor_pair_unique (v : Center) (a b : Fin 3) (hab : a≠b) + (s t u : Fin 3) + (ht : localTensor v (fun k=>if k=a then s else if k=b then t else 1)≠0) + (hu : localTensor v (fun k=>if k=a then s else if k=b then u else 1)≠0) : t=u := by + rcases v with ⟨i,j,c⟩ + cases c <;> fin_cases a <;> fin_cases b <;> fin_cases s <;> fin_cases t <;> fin_cases u <;> + simp_all [localTensor,upTensor,downTensor,Planar.empty,Planar.occupied,Planar.cup] + +/-- Unique propagation for either orientation of an actual path. -/ +lemma CenterPath.orientation_agree {n : ℕ} (p : CenterPath n) + (σ τ : Fin (n+1)→Fin 3) (hr : σ 0=τ 0) + (hs : ∀ i,p.factor i σ≠0) (ht : ∀ i,p.factor i τ≠0) : σ=τ := by + funext i + induction i using Fin.induction with + | zero => exact hr + | succ i ih => + apply localTensor_pair_unique (p.center i) (p.side i.castSucc) (p.side i.succ) + (p.sides_distinct i) (σ i.castSucc) (σ i.succ) (τ i.succ) + · exact hs i + · simpa only [CenterPath.factor,ih] using ht i + +lemma CenterPath.selected_orientation_agree {n : ℕ} (p : CenterPath n) + (σ τ : Wire→Fin 3) (hr : σ (p.edge 0)=τ (p.edge 0)) + (hs : ∀ i,σ (p.edge i)≠1) (ht : ∀ i,τ (p.edge i)≠1) + (hsn : ∀ i,centerTensor σ (p.center i)≠0) + (htn : ∀ i,centerTensor τ (p.center i)≠0) : + ∀ i,σ (p.edge i)=τ (p.edge i) := by + have he:=p.orientation_agree (fun i=>σ (p.edge i)) (fun i=>τ (p.edge i)) hr + (fun i=>by rw [←p.factor_of_isolated σ (p.isolated σ hs hsn)];exact hsn i) + (fun i=>by rw [←p.factor_of_isolated τ (p.isolated τ ht htn)];exact htn i) + exact congrFun he +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition + +noncomputable def CenterPath.restrictSpins {n : ℕ} (p : CenterPath n) (σ : Wire→Fin 3) : Wire→Fin 3 := + fun w=>if w∈Set.range p.edge then σ w else 1 +noncomputable def CenterPath.superpose {n : ℕ} (p : CenterPath n) (σ τ : Wire→Fin 3) : Wire→Fin 3 := + fun w=>if w∈Set.range p.edge then σ w else τ w +lemma CenterPath.restrict_center {n : ℕ} (p : CenterPath n) (σ : Wire→Fin 3) + (hi : ∀ i k,incidentWire (p.center i) k∉Set.range p.edge → σ (incidentWire (p.center i) k)=1) + (i : Fin n) : centerTensor (p.restrictSpins σ) (p.center i)=centerTensor σ (p.center i) := by + have he (k) : p.restrictSpins σ (incidentWire (p.center i) k)=σ (incidentWire (p.center i) k) := by + unfold CenterPath.restrictSpins + split_ifs with h + · rfl + · exact (hi i k h).symm + unfold centerTensor + simp only [he] +lemma CenterPath.restrict_off {n : ℕ} (p : CenterPath n) (σ : Wire→Fin 3) + (v : Center) (h0 : v≠p.point 0) (hl : v≠p.point (Fin.last (n+1))) + (hv : v∉Set.range p.center) : centerTensor (p.restrictSpins σ) v=1 := by + apply tensor_empty + intro k + exact ite_eq_right (p.incident_off v h0 hl hv k) +lemma CenterPath.restrict_product_ne_zero {n : ℕ} (p : CenterPath n) (D : Finset Center) (σ : Wire→Fin 3) + (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) + (he : ∀ i,σ (p.edge i)≠1) (hn : ∀ i,centerTensor σ (p.center i)≠0) : + centerProduct D (p.restrictSpins σ)≠0 := by + apply Finset.prod_ne_zero_iff.mpr + intro v hv + by_cases hc : v∈Set.range p.center + · obtain ⟨i,rfl⟩:=hc + rw [p.restrict_center σ (p.isolated σ he hn)] + exact hn i + · rw [p.restrict_off σ v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc] + exact one_ne_zero +lemma CenterPath.restrict_center_agree {n : ℕ} (p : CenterPath n) (σ τ : Wire→Fin 3) + (he : ∀ i,σ (p.edge i)=τ (p.edge i)) : p.restrictSpins σ=p.restrictSpins τ := by + funext w + unfold CenterPath.restrictSpins + split_ifs with h + · obtain ⟨i,rfl⟩:=h;exact he i + · rfl + +lemma CenterPath.remove_reference_product {n : ℕ} (p : CenterPath n) (D : Finset Center) + (σ₀ σ : Wire→Fin 3) (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) + (he : ∀ i,σ (p.edge i)≠1) (hn : ∀ i,centerTensor σ (p.center i)≠0) + (ha : ∀ i,σ (p.edge i)=σ₀ (p.edge i)) : + centerProduct D σ=centerProduct D (p.restrictSpins σ₀)*centerProduct D (p.erase σ) := by + have heq:=p.restrict_center_agree σ σ₀ ha + rw [←heq] + unfold centerProduct + rw [←Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro v hv + by_cases hc : v∈Set.range p.center + · obtain ⟨i,rfl⟩:=hc + rw [p.erased_center σ (p.isolated σ he hn),mul_one,p.restrict_center σ (p.isolated σ he hn)] + · rw [p.erased_off σ v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc, + p.restrict_off σ v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc,one_mul] + +lemma CenterPath.superpose_tensor {n : ℕ} (p : CenterPath n) (σ τ : Wire→Fin 3) + (hi : ∀ i k,τ (incidentWire (p.center i) k)=1) (i : Fin n) : + centerTensor (p.superpose σ τ) (p.center i)=centerTensor (p.restrictSpins σ) (p.center i) := by + have hs (k) : p.superpose σ τ (incidentWire (p.center i) k)= + p.restrictSpins σ (incidentWire (p.center i) k) := by + unfold CenterPath.superpose CenterPath.restrictSpins + split_ifs + · rfl + · exact hi i k + unfold centerTensor + simp only [hs] +lemma CenterPath.superpose_off {n : ℕ} (p : CenterPath n) (σ τ : Wire→Fin 3) + (v : Center) (h0 : v≠p.point 0) (hl : v≠p.point (Fin.last (n+1))) + (hv : v∉Set.range p.center) : centerTensor (p.superpose σ τ) v=centerTensor τ v := by + have hs (k) : p.superpose σ τ (incidentWire v k)=τ (incidentWire v k) := + ite_eq_right (p.incident_off v h0 hl hv k) + unfold centerTensor + simp only [hs] +lemma CenterPath.superpose_product {n : ℕ} (p : CenterPath n) (D : Finset Center) + (σ τ : Wire→Fin 3) (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) + (hi : ∀ i k,τ (incidentWire (p.center i) k)=1) : + centerProduct D (p.superpose σ τ)=centerProduct D (p.restrictSpins σ)*centerProduct D τ := by + unfold centerProduct + rw [←Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro v hv + by_cases hc : v∈Set.range p.center + · obtain ⟨i,rfl⟩:=hc + rw [p.superpose_tensor σ τ hi i,tensor_empty τ _ (hi i),mul_one] + · rw [p.superpose_off σ τ v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc, + p.restrict_off σ v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc,one_mul] +lemma CenterPath.erase_superpose {n : ℕ} (p : CenterPath n) (σ τ : Wire→Fin 3) + (he : ∀ i,τ (p.edge i)=1) : p.erase (p.superpose σ τ)=τ := by + funext w + unfold CenterPath.erase CenterPath.superpose + split_ifs with h + · obtain ⟨i,rfl⟩:=h;exact (he i).symm + · rfl +lemma CenterPath.superpose_erase {n : ℕ} (p : CenterPath n) (σ τ : Wire→Fin 3) + (he : ∀ i,τ (p.edge i)=σ (p.edge i)) : p.superpose σ (p.erase τ)=τ := by + funext w + unfold CenterPath.erase CenterPath.superpose + split_ifs with h + · obtain ⟨i,rfl⟩:=h;exact (he i).symm + · simp only [ite_eq_right h] +lemma CenterPath.selected_superpose_congr {n : ℕ} (p : CenterPath n) (σ : Wire→Fin 3) + {τ η : Wire→Fin 3} (he : selected τ=selected η) : + selected (p.superpose σ τ)=selected (p.superpose σ η) := by + funext w + unfold selected CenterPath.superpose + split_ifs + · rfl + · exact congrFun he w +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +noncomputable def superposeAssignment {W H n : ℕ} (p : CenterPath n) + (σ : Wire→Fin 3) (x : Assignment W H) : Assignment W H := + restrictAssignment (p.superpose σ (assignmentSpins x)) +lemma superposeAssignment_spins {W H n : ℕ} (p : CenterPath n) (σ : Wire→Fin 3) (x : Assignment W H) + (hp : ∀ i,p.edge i∈Set.range (wireEmbedding (W:=W) (H:=H))) : + assignmentSpins (superposeAssignment p σ x)=p.superpose σ (assignmentSpins x) := by + apply assignmentSpins_restrict + intro w hw + have hn : w∉Set.range p.edge := by rintro ⟨i,rfl⟩;exact hw (hp i) + rw [CenterPath.superpose,ite_eq_right hn,assignmentSpins_supported x hw] +lemma superpose_sameBoundary {W H n : ℕ} (p : CenterPath n) (σ : Wire→Fin 3) + {x y : Assignment W H} (h : SameBoundary x y) : + SameBoundary (superposeAssignment p σ x) (superposeAssignment p σ y) := by + intro w hw + change p.superpose σ (assignmentSpins x) (wireEmbedding (.inl w))= + p.superpose σ (assignmentSpins y) (wireEmbedding (.inl w)) + unfold CenterPath.superpose + split_ifs + · rfl + · simp only [assignmentSpins,spins_wire];exact h w hw + +theorem all_orientation_path_factorization {W H n : ℕ} (hW : 0rfl)] + have hfill₀ : superposeAssignment p (assignmentSpins x₀) (eraseAssignment p x₀)=x₀ := by + apply assignmentSpins_injective + rw [superposeAssignment_spins p _ _ hcover,eraseAssignment_spins] + exact p.superpose_erase _ _ (fun _=>rfl) + have hbF : SameBoundary (superposeAssignment p (assignmentSpins x₀) y) x₀ := by + simpa only [hfill₀] using (superpose_sameBoundary p (assignmentSpins x₀) hB) + constructor + · apply (relativeTerm_ne_zero cfg x₀ _).mpr + refine ⟨hbF,hmF,?_⟩ + rw [superposeAssignment_spins p _ y hcover,p.superpose_product _ _ _ h0 hl hlocal] + exact mul_ne_zero hP hN + · apply assignmentSpins_injective + rw [eraseAssignment_spins,superposeAssignment_spins p _ y hcover,p.erase_superpose _ _ he] + change (∑ x, F x)=P*∑ y, G y + rw [Finset.mul_sum] + apply Finset.sum_bij_ne_zero (fun x _ _=>eraseAssignment p x) + · intro x hx hn; exact Finset.mem_univ _ + · intro x hx hn y hy hm he + have hxf := (forward x hn).2 + have hyf := (forward y hm).2 + rw [←hxf,←hyf,he] + · intro y hy hn + have hg : G y≠0 := (mul_ne_zero_iff.mp hn).2 + have hh := backward y hg + exact ⟨superposeAssignment p (assignmentSpins x₀) y,Finset.mem_univ _,hh.1,hh.2⟩ + · intro x hx hn + exact (forward x hn).1 + + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.AllPorts +open SimpleGraph FiniteConfigurations + +noncomputable instance portFintype (D : Finset Center) : Fintype (Port (D : Set Center)) := + Fintype.ofInjective (fun p : Port (D : Set Center)=>(portInside p,p.side)) (by + intro p q he + apply Port.wire_ext + have hi:=congrArg (fun x : Interior D × Fin 3=>x.1.val) he + have hs:=congrArg Prod.snd he + change p.inside=q.inside at hi + change p.side=q.side at hs + simp only [Port.wire,hi,hs]) + +abbrev Vertices (D : Finset Center) := Interior D ⊕ Port (D : Set Center) + +def selectedRel {D : Finset Center} (s : Wire→Bool) : Vertices D→Vertices D→Prop + | .inl v,.inl w => ∃ k : Fin 3,neighbor v.val k=w.val ∧ s (incidentWire v.val k)=true + | .inl v,.inr q => v.val=q.inside ∧ s q.wire=true + | .inr q,.inl v => v.val=q.inside ∧ s q.wire=true + | .inr _,.inr _ => False +lemma selectedRel_symm {D : Finset Center} (s : Wire→Bool) : + ∀ ⦃v w : Vertices D⦄, selectedRel s v w → selectedRel s w v := by + intro x y h + cases x with + | inl v => + cases y with + | inl w => + obtain ⟨k,hk,hs⟩ := h + refine ⟨k,?_,?_⟩ + · rw [←hk,neighbor_neighbor] + · rw [←hk,incidentWire_neighbor];exact hs + | inr q => exact h + | inr q => cases y <;> exact h +noncomputable def graph (D : Finset Center) (s : Wire→Bool) : SimpleGraph (Vertices D) where + Adj := selectedRel s + symm := ⟨selectedRel_symm s⟩ + loopless := ⟨by + intro x h + cases x with + | inl v => obtain ⟨k,hk,_⟩:=h;exact neighbor_ne v.val k hk + | inr q => exact h⟩ + +noncomputable instance graphDecidable {D : Finset Center} (s : Wire→Bool) : + DecidableRel (graph D s).Adj := Classical.decRel _ + +lemma port_neighbors {D : Finset Center} (s : Wire→Bool) (q : Port (D : Set Center)) : + (graph D s).neighborSet (.inr q)=if s q.wire then {.inl (portInside q)} else ∅ := by + ext x + cases hs : s q.wire <;> cases x with + | inl v => simp [SimpleGraph.neighborSet,graph,selectedRel,hs,portInside,Subtype.ext_iff] + | inr r => simp [SimpleGraph.neighborSet,graph,selectedRel] +lemma port_degree {D : Finset Center} (s : Wire→Bool) (q : Port (D : Set Center)) : + (graph D s).degree (.inr q)=(s q.wire).toNat := by + classical + rw [←PathComponents.ncard_neighbors,port_neighbors] + cases hs : s q.wire <;> simp + +def sideNeighbor {D : Finset Center} (v : Interior D) (k : Fin 3) : Vertices D→Prop + | .inl w => neighbor v.val k=w.val + | .inr q => v.val=q.inside ∧ k=q.side +lemma side_unique {D : Finset Center} (v : Interior D) {k l : Fin 3} {w : Vertices D} + (hk : sideNeighbor v k w) (hl : sideNeighbor v l w) : k=l := by + cases w with + | inl w => exact neighbor_injective v.val (hk.trans hl.symm) + | inr q => exact hk.2.trans hl.2.symm +lemma neighbor_unique {D : Finset Center} (v : Interior D) (k : Fin 3) {x y : Vertices D} + (hx : sideNeighbor v k x) (hy : sideNeighbor v k y) : x=y := by + cases x with + | inl x => cases y with + | inl y => exact congrArg Sum.inl (Subtype.ext (hx.symm.trans hy)) + | inr q => + have hh : neighbor v.val k=q.outside := by rw [hy.1,hy.2,q.neighbor_side] + exact (q.outside_not_mem (hh ▸ hx.symm ▸ x.property)).elim + | inr p => cases y with + | inl y => + have hh : neighbor v.val k=p.outside := by rw [hx.1,hx.2,p.neighbor_side] + exact (p.outside_not_mem (hh ▸ hy.symm ▸ y.property)).elim + | inr q => + apply congrArg Sum.inr + apply Port.wire_ext + simp only [Port.wire,←hx.1,←hy.1,←hx.2,←hy.2] + +lemma side_has_neighbor {D : Finset Center} (v : Interior D) (k : Fin 3) : + ∃ w : Vertices D,sideNeighbor v k w := by + classical + by_cases hh : neighbor v.val k∈D + · exact ⟨.inl ⟨_,hh⟩,rfl⟩ + · let q : Port (D : Set Center) := ⟨v.val,neighbor v.val k, + (adj_iff_neighbor _ _).mpr ⟨k,rfl⟩,v.property,hh⟩ + refine ⟨.inr q,rfl,?_⟩ + exact neighbor_injective v.val (by exact q.neighbor_side.symm) +lemma side_adj {D : Finset Center} (s : Wire→Bool) (v : Interior D) (k : Fin 3) + (w : Vertices D) (hk : s (incidentWire v.val k)=true) (hw : sideNeighbor v k w) : + (graph D s).Adj (.inl v) w := by + cases w with + | inl w => exact ⟨k,hw,hk⟩ + | inr q => exact ⟨hw.1,by simpa [Port.wire,←hw.1,←hw.2] using hk⟩ +lemma adj_side {D : Finset Center} (s : Wire→Bool) (v : Interior D) (w : Vertices D) + (h : (graph D s).Adj (.inl v) w) : + ∃ k : Fin 3,s (incidentWire v.val k)=true ∧ sideNeighbor v k w := by + cases w with + | inl w => obtain ⟨k,hw,hk⟩:=h;exact ⟨k,hk,hw⟩ + | inr q => exact ⟨q.side,by simpa [h.1,Port.wire] using h.2,h.1,rfl⟩ + +noncomputable def neighborEquiv {D : Finset Center} (s : Wire→Bool) (v : Interior D) : + {k : Fin 3//s (incidentWire v.val k)=true} ≃ (graph D s).neighborSet (.inl v) := by + classical + let f : {k : Fin 3//s (incidentWire v.val k)=true}→(graph D s).neighborSet (.inl v) := fun k=> + ⟨(side_has_neighbor v k.val).choose,side_adj s v k.val _ k.property (side_has_neighbor v k.val).choose_spec⟩ + apply Equiv.ofBijective f + constructor + · intro k l he + apply Subtype.ext + apply side_unique v (side_has_neighbor v k.val).choose_spec + have he' := congrArg Subtype.val he + change (side_has_neighbor v k.val).choose=(side_has_neighbor v l.val).choose at he' + rw [he'] + exact (side_has_neighbor v l.val).choose_spec + · intro w + obtain ⟨k,hk,hw⟩:=adj_side s v w.val w.property + exact ⟨⟨k,hk⟩,Subtype.ext (neighbor_unique v k (side_has_neighbor v k).choose_spec hw)⟩ + +lemma center_degree {D : Finset Center} (s : Wire→Bool) (v : Interior D) : + (graph D s).degree (.inl v)=selectedSideCount s v.val := by + classical + rw [←PathComponents.ncard_neighbors] + change Nat.card ((graph D s).neighborSet (.inl v))=_ + rw [Nat.card_eq_fintype_card,selectedSideCount_eq_card] + exact (Fintype.card_congr (neighborEquiv s v)).symm + +end CriticalHoneycomb.Transfer.AllPorts + +namespace CriticalHoneycomb.Transfer.AllPorts +open SimpleGraph FiniteConfigurations + +/-- A selected boundary component ends at another selected boundary port. +This is derived from the actual local 0/2 rule and the finite handshake +lemma, with no prescribed pairing assumed. -/ +theorem selected_port_partner {D : Finset Center} (s : Wire→Bool) + (hd : ∀ v∈D,selectedSideCount s v=0 ∨ selectedSideCount s v=2) + (a : Port (D : Set Center)) (ha : s a.wire=true) : + ∃ b : Port (D : Set Center), b≠a ∧ s b.wire=true ∧ + ∃ p : (graph D s).Walk (.inr a) (.inr b),p.IsPath ∧ + ∀ v∈p.support,p.toSubgraph.neighborSet v=(graph D s).neighborSet v := by + classical + let G := graph D s + let S : Set (Vertices D) := {v | G.Reachable (.inr a) v} + let A : S := ⟨.inr a,SimpleGraph.Reachable.rfl⟩ + have deg (v : S) : (G.induce S).degree v=G.degree v := by + apply G.degree_induce_of_neighborSet_subset + intro w hw + exact v.property.trans hw.reachable + have hA : Odd ((G.induce S).degree A) := by + rw [deg,show G.degree (.inr a)=1 from by change (graph D s).degree (.inr a)=1; rw [port_degree,ha];rfl] + decide + obtain ⟨v,hvA,hv⟩:=(G.induce S).exists_ne_odd_degree_of_exists_odd_degree A hA + have hodd : Odd (G.degree v.val) := by simpa only [deg] using hv + cases hvv : v.val with + | inl u => + rw [hvv] at hodd + change Odd ((graph D s).degree (.inl u)) at hodd + rw [center_degree] at hodd + rcases hd u.val u.property with h|h <;> rw [h] at hodd <;> norm_num at hodd + | inr b => + have hba : b≠a := by + intro he + apply hvA + apply Subtype.ext + exact hvv.trans (congrArg Sum.inr he) + have hb : s b.wire=true := by + rw [hvv] at hodd + change Odd ((graph D s).degree (.inr b)) at hodd + rw [port_degree] at hodd + cases hh : s b.wire + · simp [hh] at hodd + · rfl + have hr : G.Reachable (.inr a) (.inr b) := hvv ▸ v.property + obtain ⟨p,hp⟩:=hr.exists_isPath + refine ⟨b,hba,hb,p,hp,?_⟩ + have hu (w : Vertices D) : G.degree w≤2 := by + cases w with + | inl w => + change (graph D s).degree (.inl w)≤2 + rw [center_degree] + rcases hd w.val w.property with h|h <;> omega + | inr q => change (graph D s).degree (.inr q)≤2; rw [port_degree];cases s q.wire <;> decide + intro w hw + apply PathComponents.path_neighbor_eq G (by simpa using hba.symm) + (by change (graph D s).degree (.inr a)=1; rw [port_degree,ha];rfl) (by change (graph D s).degree (.inr b)=1; rw [port_degree,hb];rfl) hu p hp hw + +lemma port_degree_le_one {D : Finset Center} (s : Wire→Bool) (q : Port (D : Set Center)) : + (graph D s).degree (.inr q)≤1 := by + rw [port_degree] + cases s q.wire <;> decide + +end CriticalHoneycomb.Transfer.AllPorts + +namespace CriticalHoneycomb.Transfer.PathComponents +open SimpleGraph +variable {α β : Type*} [Fintype α] [Fintype β] + +lemma port_mem_support_ends (G : SimpleGraph (α⊕β)) [DecidableRel G.Adj] + (hd : ∀ q : β,G.degree (.inr q)≤1) {a b q : β} + (p : G.Walk (.inr a) (.inr b)) (hp : p.IsPath) (hq : Sum.inr q∈p.support) : + q=a ∨ q=b := by + classical + by_contra hh + have hqa : q≠a := fun he=>hh (Or.inl he) + have hqb : q≠b := fun he=>hh (Or.inr he) + obtain ⟨i,hi,hil⟩:=Walk.mem_support_iff_exists_getVert.mp hq + have hi0 : i≠0 := by + intro he;subst i + exact hqa (Sum.inr.inj (hi.symm.trans p.getVert_zero)) + have hiL : i exact ⟨[],rfl⟩ + | cons t l ih => + cases t with + | inr b => exact (h _ (by simp) b rfl).elim + | inl x => + obtain ⟨xs,hxs⟩:=ih (by aesop) + exact ⟨x::xs,by simp [hxs]⟩ + +/-- The inside trace of any simple component between degree-one ports; +other marked boundary ports cannot occur in its interior. -/ +lemma support_decomposition_many (G : SimpleGraph (α⊕β)) [DecidableRel G.Adj] + (hd : ∀ q : β,G.degree (.inr q)≤1) {a b : β} (hab : a≠b) + (p : G.Walk (.inr a) (.inr b)) (hp : p.IsPath) : + ∃ xs : List α,p.support=Sum.inr a::(xs.map Sum.inl++[Sum.inr b]) ∧ xs.Nodup := by + have hs:=p.cons_tail_support.symm + have hn:=hp.support_nodup + rw [hs] at hn + obtain ⟨hna,hnt⟩:=List.nodup_cons.mp hn + have ht : p.support.tail.getLast?=some (.inr b) := by + have hl : p.support.getLast?=some (.inr b) := by + rw [List.getLast?_eq_some_getLast (by simp),p.getLast_support] + cases h : p.support.tail with + | nil => + have he:=congrArg List.getLast? hs + simp [h,hl] at he + exact (hab he.symm).elim + | cons t ts => + have he:=congrArg List.getLast? hs + simpa [h,hl] using he.symm + obtain ⟨mid,hmid⟩:=List.getLast?_eq_some_iff.mp ht + rw [hmid] at hna hnt + obtain ⟨hnm,_,hdm⟩:=List.nodup_append.mp hnt + obtain ⟨xs,hxs⟩:=list_all_inl_many mid (by + intro t ht q he + have hm : Sum.inr q∈p.support := by rw [hs,hmid];simp [←he,ht] + rcases port_mem_support_ends G hd p hp hm with hqa|hqb + · subst q + exact hna (by simp [←he,ht]) + · subst q + exact hdm t ht (.inr b) (by simp) he) + exact ⟨xs,by simpa [hmid,←hxs] using hs,List.Nodup.of_map Sum.inl (hxs.symm ▸ hnm)⟩ +end CriticalHoneycomb.Transfer.PathComponents + +namespace CriticalHoneycomb.Transfer.AllPorts +open SimpleGraph FiniteConfigurations ChordOrientations PhysicalTiles CenterPartition + +def hardRel {D : Finset Center} : Vertices D→Vertices D→Prop + | .inl v,.inl w => CriticalHoneycomb.Adj v.val w.val + | .inl v,.inr q => v=portInside q + | .inr q,.inl v => v=portInside q + | .inr _,.inr _ => False +lemma selected_hard {D : Finset Center} (s : Wire→Bool) (v w : Vertices D) + (h : (graph D s).Adj v w) : hardRel v w := by + cases v with + | inl v => cases w with + | inl w => obtain ⟨k,hk,_⟩:=h;exact (adj_iff_neighbor _ _).mpr ⟨k,hk⟩ + | inr q => exact Subtype.ext h.1 + | inr q => cases w with + | inl v => exact Subtype.ext h.1 + | inr r => exact h +lemma chain_snoc_ports {D : Finset Center} (b : Port (D : Set Center)) (xs : List (Interior D)) : + (xs.map Sum.inl++[Sum.inr b]).IsChain hardRel ↔ + xs.IsChain (fun x y=>CriticalHoneycomb.Adj x.val y.val) ∧ ∀ z∈xs.getLast?,z=portInside b := by + rw [List.isChain_append,List.isChain_map] + constructor + · rintro ⟨hc,_,hl⟩ + refine ⟨hc,?_⟩ + intro z hz + exact hl (.inl z) (by simpa only [List.getLast?_map] using Option.mem_map.mpr ⟨z,hz,rfl⟩) + (.inr b) (by simp) + · rintro ⟨hc,hl⟩ + refine ⟨hc,by simp,?_⟩ + intro x hx y hy + have hy' : Sum.inr b=y := by simpa using hy + subst y + rw [List.getLast?_map] at hx + obtain ⟨z,hz,rfl⟩ := Option.mem_map.mp hx + exact hl z hz + +lemma chain_ports {D : Finset Center} (a b : Port (D : Set Center)) (xs : List (Interior D)) : + (Sum.inr a::(xs.map Sum.inl++[Sum.inr b])).IsChain hardRel ↔ + xs.IsChain (fun x y=>CriticalHoneycomb.Adj x.val y.val) ∧ + xs.head?=some (portInside a) ∧ xs.getLast?=some (portInside b) := by + cases xs with + | nil => simp [hardRel] + | cons x xs => + rw [List.isChain_cons,chain_snoc_ports] + have hh : (∀ y∈((x::xs).map Sum.inl++[Sum.inr b]).head?,hardRel (.inr a) y) ↔ x=portInside a := by + simp [hardRel] + have hl : (∀ z∈(x::xs).getLast?,z=portInside b) ↔ (x::xs).getLast?=some (portInside b) := by + rw [List.getLast?_eq_some_getLast (by simp)] + simp + rw [hh,hl] + simp only [List.head?_cons,Option.some.injEq] + tauto + +noncomputable def vertexCenter {D : Finset Center} : Vertices D→Center + | .inl v => v.val + | .inr q => q.outside +lemma selected_to_actual {D : Finset Center} (s : Wire→Bool) (x y : Vertices D) + (h : (graph D s).Adj x y) : + ∃ k : Fin 3,neighbor (vertexCenter x) k=vertexCenter y ∧ + s (incidentWire (vertexCenter x) k)=true := by + cases x with + | inl v => cases y with + | inl w => exact h + | inr q => + refine ⟨q.side,?_,?_⟩ + · change neighbor v.val q.side=q.outside + rw [h.1];exact q.neighbor_side + · change s (incidentWire v.val _)=true + rw [h.1];exact h.2 + | inr q => cases y with + | inl v => + refine ⟨q.side,?_,?_⟩ + · change neighbor q.outside _=v.val + rw [←q.neighbor_side,neighbor_neighbor,h.1] + · change s (incidentWire q.outside _)=true + rw [←q.neighbor_side,incidentWire_neighbor] + exact h.2 + | inr r => exact h.elim + +lemma chord_edges {D : Finset Center} {a b : Port (D : Set Center)} + (γ : Chord (D : Set Center) a b) (hab : a.outside≠b.outside) (s : Wire→Bool) + (xs : List (Interior D)) (p : (graph D s).Walk (.inr a) (.inr b)) + (hm : xs.map Subtype.val=γ.val) + (hs : p.support=Sum.inr a::(xs.map Sum.inl++[Sum.inr b])) : + ∀ i,s ((ofChord γ hab).edge i)=true := by + let R : Center→Center→Prop := fun x y=>∃ k : Fin 3, + neighbor x k=y ∧ s (incidentWire x k)=true + have hc : (p.support.map vertexCenter).IsChain R := + List.isChain_map_of_isChain _ (selected_to_actual s) p.isChain_adj_support + have hl : p.support.map vertexCenter=extendedTrace γ := by + rw [hs,List.map_cons,List.map_append,List.map_map] + have hx : (fun x : Interior D=>vertexCenter (Sum.inl x))=Subtype.val := rfl + simp only [Function.comp_def,hm,List.map_cons,List.map_nil,vertexCenter,extendedTrace] + rw [hl] at hc + intro i + obtain ⟨k,hk,hsk⟩:=List.isChain_iff_getElem.mp hc i.val (by rw [extendedTrace_length];omega) + have hp : neighbor ((ofChord γ hab).point i.castSucc) k=(ofChord γ hab).point i.succ := hk + have he : k=(ofChord γ hab).side i := neighbor_injective _ (hp.trans ((ofChord γ hab).step i).symm) + change s (incidentWire ((ofChord γ hab).point i.castSucc) ((ofChord γ hab).side i))=true + rw [←he];exact hsk + +/-- At each selected port of an actual nonzero configuration, its isolated +component is a literal simple-center chord, even with other marked ports. -/ +theorem nonzero_contains_chord {D : Finset Center} (σ : Wire→Fin 3) + (h : centerProduct D σ≠0) (a : Port (D : Set Center)) + (ha : σ a.wire≠1) : + ∃ b : Port (D : Set Center),b≠a ∧ σ b.wire≠1 ∧ + ∃ γ : Chord (D : Set Center) a b, + ∀ hab : a.outside≠b.outside,∀ i,σ ((ofChord γ hab).edge i)≠1 := by + have hd (v) (hv : v∈D) : selectedSideCount (selected σ) v=0 ∨ selectedSideCount (selected σ) v=2 := + nonzero_center_degree σ v (Finset.prod_ne_zero_iff.mp h v hv) + have has : selected σ a.wire=true := by simpa [selected,spinOccupied] using ha + obtain ⟨b,hba,hb,p,hp,_⟩:=selected_port_partner (selected σ) hd a has + obtain ⟨xs,hxs,hn⟩:=PathComponents.support_decomposition_many (graph D (selected σ)) + (port_degree_le_one _) hba.symm p hp + have hch : p.support.IsChain hardRel := p.isChain_adj_support.imp (selected_hard _) + rw [hxs] at hch + obtain ⟨hchain,hhead,hlast⟩:=(chain_ports a b xs).mp hch + let γ : Chord (D : Set Center) a b := ⟨xs.map Subtype.val,by + refine ⟨⟨hn.map Subtype.val_injective,?_,?_⟩,?_,?_⟩ + · exact (List.isChain_map Subtype.val).mpr hchain + · intro v hv;obtain ⟨x,_,rfl⟩:=List.mem_map.mp hv;exact x.property + · rw [List.head?_map,hhead];rfl + · rw [List.getLast?_map,hlast];rfl⟩ + refine ⟨b,hba,by simpa [selected,spinOccupied] using hb,γ,?_⟩ + intro hab i + have he:=chord_edges γ hab (selected σ) xs p rfl hxs i + simpa [selected,spinOccupied] using he +end CriticalHoneycomb.Transfer.AllPorts + +namespace CriticalHoneycomb.Transfer.RasterGrid +lemma port_exhaustive {W H : ℕ} (p : Port (domain (W+1) (H+1) : Set Center)) : + (∃ j,p=westPort W H j) ∨ (∃ j,p=eastPort W H j) ∨ + (∃ i,p=southPort W H i) ∨ (∃ i,p=northPort W H i) := by + have hh:=boundary_wire_exhaustive p.inside_mem p.side + (by rw [p.neighbor_side];exact p.outside_not_mem) + rcases hh with ⟨j,hj⟩|⟨j,hj⟩|⟨i,hi⟩|⟨i,hi⟩ + · exact Or.inl ⟨j,Port.wire_ext _ _ hj⟩ + · exact Or.inr (Or.inl ⟨j,Port.wire_ext _ _ hj⟩) + · exact Or.inr (Or.inr (Or.inl ⟨i,Port.wire_ext _ _ hi⟩)) + · exact Or.inr (Or.inr (Or.inr ⟨i,Port.wire_ext _ _ hi⟩)) + +lemma port_outside_injective (W H : ℕ) : + Function.Injective (fun p : Port (domain (W+1) (H+1) : Set Center)=>p.outside) := by + intro p q he + rcases port_exhaustive p with ⟨i,rfl⟩|⟨i,rfl⟩|⟨i,rfl⟩|⟨i,rfl⟩ <;> + rcases port_exhaustive q with ⟨j,rfl⟩|⟨j,rfl⟩|⟨j,rfl⟩|⟨j,rfl⟩ <;> + simp only [westPort,eastPort,southPort,northPort,up,down,Prod.mk.injEq, + Bool.false_eq_true, Bool.true_eq_false,and_false,and_true] at he + all_goals first + | exact he.elim + | have hij : i=j := by apply Fin.ext;omega + subst j + rfl + | have hi:=i.isLt; have hj:=j.isLt; omega +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +lemma sameBoundary_port {W H : ℕ} {x y : Assignment (W+1) (H+1)} (h : SameBoundary x y) + (a : Port (domain (W+1) (H+1) : Set Center)) : + assignmentSpins x a.wire=assignmentSpins y a.wire := by + rcases port_exhaustive a with ⟨i,rfl⟩|⟨i,rfl⟩|⟨i,rfl⟩|⟨i,rfl⟩ + · rw [westPort_wire,assignmentSpins,assignmentSpins,spins_wire,spins_wire] + exact h _ (Or.inl rfl) + · rw [eastPort_wire,assignmentSpins,assignmentSpins,spins_wire,spins_wire] + exact h _ (Or.inr rfl) + · rw [southPort_wire,assignmentSpins,assignmentSpins,spins_wire,spins_wire] + exact h _ (Or.inl rfl) + · rw [northPort_wire,assignmentSpins,assignmentSpins,spins_wire,spins_wire] + exact h _ (Or.inr rfl) + +lemma relativeTerm_change_reference {W H : ℕ} (cfg : Cell W H→Shape) + {x y : Assignment W H} (h : SameBoundary y x) : relativeTerm cfg x=relativeTerm cfg y := by + funext z + have hb : SameBoundary z x ↔ SameBoundary z y := + ⟨fun hh=>sameBoundary_trans hh (sameBoundary_symm h),fun hh=>sameBoundary_trans hh h⟩ + simp only [relativeTerm,hb] + +noncomputable def occupiedWires {W H : ℕ} (x : Assignment W H) : Finset (FullWire W H) := + Finset.univ.filter (fun w=>Sum.elim x.1 x.2 w≠1) + +lemma erase_occupied_subset {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) : + occupiedWires (eraseAssignment p x)⊆occupiedWires x := by + intro w hw + have he : assignmentSpins (eraseAssignment p x) (wireEmbedding w)≠1 := by + simpa only [occupiedWires,Finset.mem_filter,Finset.mem_univ,true_and,assignmentSpins,spins_wire] using hw + rw [eraseAssignment_spins] at he + have hn : assignmentSpins x (wireEmbedding w)≠1 := by + unfold CenterPath.erase at he + split_ifs at he with h + · exact (he rfl).elim + · exact he + simpa only [occupiedWires,Finset.mem_filter,Finset.mem_univ,true_and,assignmentSpins,spins_wire] using hn + +lemma erase_occupied_card_lt {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) + (hc : p.edge 0∈Set.range (wireEmbedding (W:=W) (H:=H))) + (hs : assignmentSpins x (p.edge 0)≠1) : + (occupiedWires (eraseAssignment p x)).card<(occupiedWires x).card := by + obtain ⟨w,hw⟩:=hc + apply Finset.card_lt_card + refine Finset.ssubset_iff_subset_ne.mpr ⟨erase_occupied_subset p x,?_⟩ + intro heq + have hm : w∈occupiedWires x := by + simpa only [occupiedWires,Finset.mem_filter,Finset.mem_univ,true_and,←hw,assignmentSpins,spins_wire] using hs + rw [←heq] at hm + have he : assignmentSpins (eraseAssignment p x) (wireEmbedding w)≠1 := by + simpa only [occupiedWires,Finset.mem_filter,Finset.mem_univ,true_and,assignmentSpins,spins_wire] using hm + rw [eraseAssignment_spins,hw,CenterPath.erase,ite_eq_left (Set.mem_range_self 0)] at he + exact he rfl + +/-- One genuine all-boundary recursion step: an actual chord is removed, +any detached cycles remain in the residual sum, and the finite support +strictly decreases. No global path expansion is assumed. -/ +theorem boundary_recursion_step {W H : ℕ} (cfg : Cell (W+1) (H+1)→Shape) + (x : Assignment (W+1) (H+1)) + (hx : relativeTerm cfg x x≠0) + (a : Port (domain (W+1) (H+1) : Set Center)) + (ha : assignmentSpins x a.wire≠1) : + ∃ (b : Port (domain (W+1) (H+1) : Set Center)) (hab : a.outside≠b.outside) + (γ : Chord (domain (W+1) (H+1) : Set Center) a b) + (cfgR : Cell (W+1) (H+1)→Shape), + let p:=ofChord γ hab + (∀ i,assignmentSpins x (p.edge i)≠1) ∧ + relativeTerm cfgR (eraseAssignment p x) (eraseAssignment p x)≠0 ∧ + (occupiedWires (eraseAssignment p x)).card<(occupiedWires x).card ∧ + (∑ z : Assignment (W+1) (H+1),relativeTerm cfg x z)= + centerProduct (domain (W+1) (H+1)) (p.restrictSpins (assignmentSpins x))* + ∑ z : Assignment (W+1) (H+1),relativeTerm cfgR (eraseAssignment p x) z := by + classical + obtain ⟨_,hM,hN⟩:=(relativeTerm_ne_zero cfg x x).mp hx + obtain ⟨b,hba,_,γ,hsel⟩:=AllPorts.nonzero_contains_chord (assignmentSpins x) hN a ha + have hab : a.outside≠b.outside := fun hh=>hba ((port_outside_injective W H) hh).symm + let p:=ofChord γ hab + have hc : ∀ i,p.center i∈domain (W+1) (H+1) := ofChord_center_mem γ hab + have h0 : p.point 0∉domain (W+1) (H+1) := by + rw [ofChord_first];exact a.outside_not_mem + have hl : p.point (Fin.last (γ.val.length+1))∉domain (W+1) (H+1) := by + rw [ofChord_last];exact b.outside_not_mem + have hcover:=path_wire_covered p (chord_length_pos γ) hc + have hs:=hsel hab + have hn (i) : centerTensor (assignmentSpins x) (p.center i)≠0 := + Finset.prod_ne_zero_iff.mp hN _ (hc i) + have hprod:=p.remove_reference_product _ (assignmentSpins x) (assignmentSpins x) h0 hl hs hn (fun _=>rfl) + have hE : centerProduct (domain (W+1) (H+1)) (assignmentSpins (eraseAssignment p x))≠0 := by + rw [eraseAssignment_spins] + intro he;rw [he,mul_zero] at hprod;exact hN hprod + let cfgR:=occupancyShape (eraseAssignment p x).1 (eraseAssignment p x).2 hE + have hR : Matches cfgR (eraseAssignment p x).1 (eraseAssignment p x).2 := occupancyShape_matches _ _ _ + refine ⟨b,hab,γ,cfgR,hs,?_,erase_occupied_card_lt p x (hcover 0) (hs 0),?_⟩ + · exact (relativeTerm_ne_zero _ _ _).mpr ⟨sameBoundary_refl _,hR,hE⟩ + · apply all_orientation_path_factorization (Nat.succ_pos W) (Nat.succ_pos H) + cfg cfgR p x hx hc h0 hl hcover hs _ hR + intro y hy + rw [ofChord_first_edge] + exact sameBoundary_port hy a +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +lemma ports_vacuum_sameBoundary {W H : ℕ} (x : Assignment (W+1) (H+1)) + (h : ∀ a : Port (domain (W+1) (H+1) : Set Center),assignmentSpins x a.wire=1) : + SameBoundary x ((fun _=>1),(fun _=>1)) := by + intro w hw + cases w with + | inl w => + rcases w with ⟨i,j⟩ + rcases hw with rfl|rfl + · have hh:=h (westPort W H j) + simpa only [westPort_wire,assignmentSpins,spins_wire,Sum.elim_inl] using hh + · have hh:=h (eastPort W H j) + simpa only [eastPort_wire,assignmentSpins,spins_wire,Sum.elim_inl] using hh + | inr w => + rcases w with ⟨i,j⟩ + rcases hw with rfl|rfl + · have hh:=h (southPort W H i) + simpa only [southPort_wire,assignmentSpins,spins_wire,Sum.elim_inl] using hh + · have hh:=h (northPort W H i) + simpa only [northPort_wire,assignmentSpins,spins_wire,Sum.elim_inl] using hh + +lemma relative_sum_vacuum {W H : ℕ} (cfg : Cell (W+1) (H+1)→Shape) + (x : Assignment (W+1) (H+1)) + (hv : ∀ a : Port (domain (W+1) (H+1) : Set Center),assignmentSpins x a.wire=1) : + (∑ y : Assignment (W+1) (H+1),relativeTerm cfg x y)= + (kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) := by + rw [relativeTerm_change_reference cfg (sameBoundary_symm (ports_vacuum_sameBoundary x hv))] + simp only [relativeTerm_eq_masked] + exact sum_maskedTerm _ _ _ _ _ + +lemma nonzero_vacuum_empty {W H : ℕ} (cfg : Cell (W+1) (H+1)→Shape) + (x : Assignment (W+1) (H+1)) (hx : relativeTerm cfg x x≠0) + (hn : (∑ y : Assignment (W+1) (H+1),relativeTerm cfg x y)≠0) + (hv : ∀ a : Port (domain (W+1) (H+1) : Set Center),assignmentSpins x a.wire=1) : + x=((fun _=>1),(fun _=>1)) ∧ (∑ y : Assignment (W+1) (H+1),relativeTerm cfg x y)=1 := by + have he : cfg=fun _=>.empty := by + by_contra hh + have hz:=chosen_nonempty_vacuum_zero cfg hh + rw [relative_sum_vacuum cfg x hv,hz,mul_zero] at hn + exact hn rfl + subst cfg + have hM:=(relativeTerm_ne_zero _ _ _).mp hx |>.2.1 + have hs:=assignment_empty (Nat.succ_pos W) (Nat.succ_pos H) x hM + constructor + · apply assignmentSpins_injective + rw [hs] + symm + apply assignmentSpins_restrict (fun _=>1) + intro w hw;rfl + · rw [relative_sum_vacuum _ x hv,chosen_empty_partition] + simp [Shape.visits] +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +/-- Literal chord components with endpoints on any two distinct rectangle ports. -/ +structure BoundaryChord (W H : ℕ) where + source : Port (domain (W+1) (H+1) : Set Center) + target : Port (domain (W+1) (H+1) : Set Center) + distinct : source.outside≠target.outside + chord : Chord (domain (W+1) (H+1) : Set Center) source target +noncomputable def BoundaryChord.path {W H : ℕ} (c : BoundaryChord W H) : CenterPath c.chord.val.length := + ofChord c.chord c.distinct +noncomputable def BoundaryChord.amplitude {W H : ℕ} (c : BoundaryChord W H) + (x : Assignment (W+1) (H+1)) : ℂ := + centerProduct (domain (W+1) (H+1)) (c.path.restrictSpins (assignmentSpins x)) +noncomputable def systemAmplitude {W H : ℕ} (x : Assignment (W+1) (H+1)) : List (BoundaryChord W H)→ℂ + | []=>1 + | c::cs=>c.amplitude x*systemAmplitude (eraseAssignment c.path x) cs + +/-- A fully selected list of actual path components, ending with no occupied +wire. This is a structural conclusion, not an axiom enumerating tensor terms. -/ +inductive SelectedSystem {W H : ℕ} : Assignment (W+1) (H+1)→List (BoundaryChord W H)→Prop + | nil : SelectedSystem ((fun _=>1),(fun _=>1)) [] + | cons (x : Assignment (W+1) (H+1)) (c : BoundaryChord W H) (cs : List (BoundaryChord W H)) + (selected : ∀ i,assignmentSpins x (c.path.edge i)≠1) + (nonzero : ∀ i,centerTensor (assignmentSpins x) (c.path.center i)≠0) + (rest : SelectedSystem (eraseAssignment c.path x) cs) : SelectedSystem x (c::cs) + +/-- No detached polygon survives the all-boundary orientation sum. Every +nonzero resolved shape is a finite system of literal honeycomb chords, +and its coefficient is the exact product of their isolated amplitudes. -/ +theorem all_boundary_shape_decomposition {W H : ℕ} (cfg : Cell (W+1) (H+1)→Shape) + (x : Assignment (W+1) (H+1)) (hx : relativeTerm cfg x x≠0) + (hn : (∑ y : Assignment (W+1) (H+1),relativeTerm cfg x y)≠0) : + ∃ cs : List (BoundaryChord W H),SelectedSystem x cs ∧ + (∑ y : Assignment (W+1) (H+1),relativeTerm cfg x y)=systemAmplitude x cs := by + classical + generalize hm : (occupiedWires x).card=m + induction m using Nat.strong_induction_on generalizing cfg x with + | h m ih => + by_cases hb : ∃ a : Port (domain (W+1) (H+1) : Set Center),assignmentSpins x a.wire≠1 + · obtain ⟨a,ha⟩:=hb + obtain ⟨b,hab,γ,cfgR,hs,hR,hlt,hfact⟩:=boundary_recursion_step cfg x hx a ha + let c : BoundaryChord W H:=⟨a,b,hab,γ⟩ + have hNR : (∑ z : Assignment (W+1) (H+1),relativeTerm cfgR (eraseAssignment c.path x) z)≠0 := by + exact (mul_ne_zero_iff.mp (hfact ▸ hn)).2 + obtain ⟨cs,hcs,hval⟩:=ih (occupiedWires (eraseAssignment c.path x)).card + (by simpa [c,BoundaryChord.path,hm] using hlt) cfgR (eraseAssignment c.path x) hR hNR rfl + refine ⟨c::cs,SelectedSystem.cons x c cs hs ?_ hcs,?_⟩ + · intro i + exact Finset.prod_ne_zero_iff.mp ((relativeTerm_ne_zero _ _ _).mp hx).2.2 _ + (ofChord_center_mem γ hab i) + · change _=c.amplitude x*systemAmplitude (eraseAssignment c.path x) cs + rw [←hval] + exact hfact + · have hv : ∀ a : Port (domain (W+1) (H+1) : Set Center),assignmentSpins x a.wire=1 := by + intro a;by_contra hh;exact hb ⟨a,hh⟩ + obtain ⟨he,hv⟩:=nonzero_vacuum_empty cfg x hx hn hv + refine ⟨[],?_,hv⟩ + rw [he] + exact SelectedSystem.nil +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition +lemma physical_phase_norm : ‖Planar.phase‖=1 := by + exact Complex.norm_exp_ofReal_mul_I _ +lemma localTensor_norm_nonempty (v : Center) (s : Fin 3→Fin 3) + (hn : localTensor v s≠0) (k : Fin 3) (hk : s k≠1) : ‖localTensor v s‖=kappa := by + have he : s=![s 0,s 1,s 2] := by ext i;fin_cases i<;>rfl + rw [he] at hn hk ⊢ + rcases v with ⟨i,j,b⟩ + generalize ha : s 0=a at hn hk ⊢ + generalize hb : s 1=c at hn hk ⊢ + generalize hc : s 2=d at hn hk ⊢ + cases b <;> fin_cases k <;> fin_cases a <;> fin_cases c <;> fin_cases d <;> + simp_all [localTensor,upTensor,downTensor,Planar.empty,Planar.occupied,Planar.cup, + physical_phase_norm,Complex.norm_real,Real.norm_eq_abs,abs_of_pos FiniteContinuation.kappa_positive] + +lemma CenterPath.restrict_product_norm {n : ℕ} (p : CenterPath n) (D : Finset Center) + (σ : Wire→Fin 3) (hc : ∀ i,p.center i∈D) + (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) + (hs : ∀ i,σ (p.edge i)≠1) (hn : ∀ i,centerTensor σ (p.center i)≠0) : + ‖centerProduct D (p.restrictSpins σ)‖=kappa^n := by + classical + have hinj := p.center_injective + let S : Finset Center:=Finset.univ.image p.center + have hS : S⊆D := by intro v hv;obtain ⟨i,_,rfl⟩:=Finset.mem_image.mp hv;exact hc i + have hoff (v) (hv : v∈D) (hh : v∉S) : centerTensor (p.restrictSpins σ) v=1 := by + apply p.restrict_off σ v (fun he=>h0 (he ▸ hv)) (fun he=>hl (he ▸ hv)) + simpa [S] using hh + rw [centerProduct] + rw [←Finset.prod_subset hS (fun v hv hh=>hoff v hv hh)] + rw [Finset.prod_image (fun i _ j _ he=>hinj he),norm_prod] + have hnorm (i) : ‖centerTensor (p.restrictSpins σ) (p.center i)‖=kappa := by + rw [p.restrict_center σ (p.isolated σ hs hn)] + apply localTensor_norm_nonempty (p.center i) (fun k=>σ (incidentWire (p.center i) k)) + (hn i) (p.side i.castSucc) + rw [p.in_wire] + exact hs i.castSucc + simp only [hnorm,Finset.prod_const,Finset.card_univ,Fintype.card_fin] +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +def systemNodes {W H : ℕ} (cs : List (BoundaryChord W H)) : List Center := + cs.flatMap (fun c=>c.chord.val) +lemma BoundaryChord.nodes_mem {W H : ℕ} (c : BoundaryChord W H) (v : Center) : + v∈c.chord.val ↔ v∈Set.range c.path.center := by + constructor + · intro hv + obtain ⟨i,hi⟩:=List.mem_iff_get.mp hv + refine ⟨i,?_⟩ + simpa [BoundaryChord.path,ofChord_center] using hi + · rintro ⟨i,rfl⟩ + rw [BoundaryChord.path,ofChord_center] + exact List.getElem_mem _ +lemma BoundaryChord.amplitude_norm {W H : ℕ} (c : BoundaryChord W H) + (x : Assignment (W+1) (H+1)) + (hs : ∀ i,assignmentSpins x (c.path.edge i)≠1) + (hn : ∀ i,centerTensor (assignmentSpins x) (c.path.center i)≠0) : + ‖c.amplitude x‖=kappa^c.chord.val.length := by + apply c.path.restrict_product_norm _ _ (ofChord_center_mem c.chord c.distinct) _ _ hs hn + · rw [BoundaryChord.path,ofChord_first];exact c.source.outside_not_mem + · rw [BoundaryChord.path,ofChord_last];exact c.target.outside_not_mem + +lemma SelectedSystem.amplitude_norm {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) : + ‖systemAmplitude x cs‖=kappa^(systemNodes cs).length := by + induction h with + | nil => simp [systemAmplitude,systemNodes] + | cons x c cs hs hn hr ih => + rw [systemAmplitude,norm_mul,c.amplitude_norm x hs hn,ih] + simp only [systemNodes,List.flatMap_cons,List.length_append,pow_add] + +lemma SelectedSystem.empty_center {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) (v : Center) + (hv : ∀ k,assignmentSpins x (incidentWire v k)=1) : v∉systemNodes cs := by + induction h with + | nil => simp [systemNodes] + | cons x c cs hs hn hr ih => + have hoff : v∉c.chord.val := by + intro hh + obtain ⟨i,hi⟩:=(c.nodes_mem v).mp hh + have he:=hv (c.path.side i.castSucc) + rw [←hi,c.path.in_wire] at he + exact hs i.castSucc he + have hrest : ∀ k,assignmentSpins (eraseAssignment c.path x) (incidentWire v k)=1 := by + intro k;rw [eraseAssignment_spins] + unfold CenterPath.erase + split_ifs + · rfl + · exact hv k + change v∉c.chord.val++systemNodes cs + intro hm + exact (List.mem_append.mp hm).elim hoff (ih hrest) + +lemma SelectedSystem.nodes_nodup {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) : (systemNodes cs).Nodup := by + induction h with + | nil => simp [systemNodes] + | cons x c cs hs hn hr ih => + apply List.nodup_append.mpr + refine ⟨c.chord.property.1.1,ih,?_⟩ + intro v hv w hw he + subst w + obtain ⟨i,rfl⟩:=(c.nodes_mem v).mp hv + apply hr.empty_center _ _ hw + intro k + rw [eraseAssignment_spins] + unfold CenterPath.erase + split_ifs with he + · rfl + · exact c.path.isolated _ hs hn i k he +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +lemma SelectedSystem.edge_union {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) (w : Wire) : + assignmentSpins x w≠1 ↔ ∃ c∈cs,w∈Set.range c.path.edge := by + induction h with + | nil => + have he : assignmentSpins ((fun _ : GridWire (W+1) (H+1)=>1),(fun _=>1))=(fun _=>1) := by + exact assignmentSpins_restrict (fun _=>1) (fun _ _=>rfl) + simp [he] + | cons x c cs hs hn hr ih => + by_cases hw : w∈Set.range c.path.edge + · obtain ⟨i,hi⟩:=hw + exact iff_of_true (hi ▸ hs i) ⟨c,List.mem_cons_self,⟨i,hi⟩⟩ + · have he : assignmentSpins (eraseAssignment c.path x) w=assignmentSpins x w := by + rw [eraseAssignment_spins,CenterPath.erase,ite_eq_right hw] + rw [←he,ih] + simp only [List.mem_cons,exists_eq_or_imp,hw,false_or] + +lemma SelectedSystem.selected_eq {W H : ℕ} {x y : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (hx : SelectedSystem x cs) (hy : SelectedSystem y cs) : + selected (assignmentSpins x)=selected (assignmentSpins y) := by + funext w + have he:=(hx.edge_union w).trans (hy.edge_union w).symm + by_cases hh : assignmentSpins x w≠1 + · have hh':=he.mp hh + simp [selected,spinOccupied,hh,hh'] + · have hh' : ¬assignmentSpins y w≠1:=fun hh'=>hh (he.mpr hh') + simp [selected,spinOccupied,hh,hh'] + +lemma SelectedSystem.shape_unique {W H : ℕ} {x y : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (hx : SelectedSystem x cs) (hy : SelectedSystem y cs) + {cfg cfg' : Cell (W+1) (H+1)→Shape} (hM : Matches cfg x.1 x.2) (hM' : Matches cfg' y.1 y.2) : + cfg=cfg' := by + exact matches_unique hM (matches_of_occupied_eq hM' (hy.selected_eq hx)) + +/-- Full all-boundary shape decomposition at exactly its actual κ-weight, +including center-disjointness and the uniqueness required for subsequent +mass comparisons. -/ +theorem all_boundary_literal_norm {W H : ℕ} (cfg : Cell (W+1) (H+1)→Shape) + (x : Assignment (W+1) (H+1)) (hx : relativeTerm cfg x x≠0) + (hn : (∑ y : Assignment (W+1) (H+1),relativeTerm cfg x y)≠0) : + ∃ cs : List (BoundaryChord W H),SelectedSystem x cs ∧ (systemNodes cs).Nodup ∧ + ‖∑ y : Assignment (W+1) (H+1),relativeTerm cfg x y‖=kappa^(systemNodes cs).length := by + obtain ⟨cs,hcs,he⟩:=all_boundary_shape_decomposition cfg x hx hn + exact ⟨cs,hcs,hcs.nodes_nodup,he ▸ hcs.amplitude_norm⟩ +end CriticalHoneycomb.Transfer.RasterGrid + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/BridgeLaplace.lean b/lean/OAI/Combinatorics/HoneycombChords/BridgeLaplace.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba9202f0c6ac99d4d643cd7d7c1b6f53deb59f83 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/BridgeLaplace.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.HoneycombChords.BridgeMass +import OAI.Combinatorics.HoneycombChords.LaplaceProfile + +namespace OAI + +/-! +# Height Laplace estimates for critical strict bridges + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section + +namespace CriticalHoneycomb +open MeasureTheory Set Filter Topology StripExhaustion RenewalInput + +/-- The height Laplace transform of the strict bridge mass. -/ +noncomputable def bridgeLaplace (s : ℝ) : ℝ := + ∑' h : ℕ, Real.exp (-(s*h)) * (bridgeMass h).toReal + +lemma bridgeMass_toReal_bounds : ∃ c C : ℝ, 0 [up 0 0,down 0 0] + | n+1 => verticalTrace n ++ [up 0 (n+1),down 0 (n+1)] + +lemma verticalTrace_bounds (n : ℕ) {v : Center} (hv : v ∈ verticalTrace n) : + 0 ≤ v.2.1 ∧ v.2.1 ≤ (n:ℤ) := by + induction n with + | zero => simp only [verticalTrace,List.mem_cons,List.not_mem_nil,or_false] at hv; rcases hv with rfl|rfl <;> simp [up,down] + | succ n ih => + simp only [verticalTrace,List.mem_append,List.mem_cons,List.not_mem_nil,or_false] at hv + rcases hv with hv|rfl|rfl + · have h:=ih hv + constructor + · exact h.1 + · push_cast; omega + · simp [up]; omega + · simp [down]; omega + +lemma verticalTrace_last (n : ℕ) : (verticalTrace n).getLast?=some (down 0 n) := by + cases n with + | zero => simp [verticalTrace] + | succ n => simp [verticalTrace] +lemma verticalTrace_head (n : ℕ) : (verticalTrace n).head?=some (up 0 0) := by + induction n with + | zero => simp [verticalTrace] + | succ n ih => simp [verticalTrace,List.head?_append,ih] + +lemma verticalTrace_nodup (n : ℕ) : (verticalTrace n).Nodup := by + induction n with + | zero => simp [verticalTrace,up,down] + | succ n ih => + rw [verticalTrace,List.nodup_append] + refine ⟨ih,by simp [up,down],?_⟩ + intro a ha b hb hab + subst b + have h:=verticalTrace_bounds n ha + simp only [List.mem_cons,List.not_mem_nil,or_false] at hb + rcases hb with rfl|rfl <;> simp only [up,down] at h <;> omega + +lemma verticalTrace_chain (n : ℕ) : (verticalTrace n).IsChain Adj := by + induction n with + | zero => simp [verticalTrace,Adj,up,down] + | succ n ih => + rw [verticalTrace,List.isChain_append] + refine ⟨ih,by simp [Adj,up,down],?_⟩ + intro x hx y hy + simp only [verticalTrace_last,Option.mem_some_iff] at hx + simp only [List.head?_cons,Option.mem_some_iff] at hy + subst x; subst y + simp [Adj,up,down] + +noncomputable def straightBridge (n : ℕ) : StrictBridge (n+1) := + ⟨verticalTrace n,⟨verticalTrace_nodup n,verticalTrace_chain n,by + intro v hv + have h:=verticalTrace_bounds n hv + exact ⟨h.1,by push_cast; omega⟩⟩, + verticalTrace_head n,0,by simpa using verticalTrace_last n⟩ + +lemma bridgeMass_pos (h : ℕ) : 0 simp [bridgeMass] + | succ n => + have hκ : 0 exact ⟨1,1,by norm_num,by norm_num,by simp⟩ + | succ K ih => + obtain ⟨c,C,hc,hC,h⟩:=ih + refine ⟨min c (f K),max C (f K),lt_min hc (hf K),lt_of_lt_of_le hC (le_max_left _ _),?_⟩ + intro n hn + rcases Nat.lt_succ_iff_lt_or_eq.mp hn with hn|rfl + · exact ⟨(min_le_left _ _).trans (h n hn).1,(h n hn).2.trans (le_max_left _ _)⟩ + · exact ⟨min_le_right _ _,le_max_right _ _⟩ + +/-- The critical strict bridge mass is comparable to `(1 + h)^(-1/4)` at every height. -/ +theorem finiteBridgeMassEstimate : FiniteBridgeMassEstimate := by + obtain ⟨a,ha,hlo⟩:=FiniteFunctional.physical_bridge_mass_lower + obtain ⟨A,hA,hup⟩:=FiniteFunctional.physical_bridge_mass_upper + obtain ⟨K,hK⟩:=eventually_atTop.mp (hlo.and hup) + let P : ℕ → ℝ := fun n ↦ (1+(n:ℝ))^(-(1:ℝ)/4) + have hP n : 0

simp_all + +private lemma fusionNumerator_eq_zero_of_sum_ne (r : ℂ) (p : Pair) (j : Fin 3) + (h : p.1.val + p.2.val ≠ j.val + 1) : wNum r p j = 0 := by + unfold wNum + split <;> simp_all + +private lemma bulkFusionLeft_eq_zero_of_sum_ne (r z : ℂ) (a b c j k : Fin 3) + (h : a.val + b.val + c.val ≠ j.val + k.val + 1) : + bulkFusionLeft r z a b c j k = 0 := by + unfold bulkFusionLeft + suffices hs : (∑ u : Fin 3,∑ v : Fin 3,∑ m : Fin 3, + rNumerator r (-z*r^14) 1 (b,c) (v,m)* + rNumerator r (z*r^2) 1 (a,m) (u,k)*wNum r (u,v) j) = 0 by rw [hs,mul_zero] + apply Finset.sum_eq_zero + intro u _ + apply Finset.sum_eq_zero + intro v _ + apply Finset.sum_eq_zero + intro m _ + by_cases h₁ : b.val + c.val = v.val + m.val + · by_cases h₂ : a.val + m.val = u.val + k.val + · have h₃ : u.val + v.val ≠ j.val + 1 := by omega + rw [fusionNumerator_eq_zero_of_sum_ne r (u,v) j h₃,mul_zero] + · rw [bulkNumerator_eq_zero_of_sum_ne r (z*r^2) 1 (a,m) (u,k) h₂,mul_zero,zero_mul] + · rw [bulkNumerator_eq_zero_of_sum_ne r (-z*r^14) 1 (b,c) (v,m) h₁,zero_mul,zero_mul] + +private lemma bulkFusionRight_eq_zero_of_sum_ne (r z : ℂ) (a b c j k : Fin 3) + (h : a.val + b.val + c.val ≠ j.val + k.val + 1) : + bulkFusionRight r z a b c j k = 0 := by + unfold bulkFusionRight + suffices hs : (∑ f : Fin 3,wNum r (a,b) f*rNumerator r z 1 (f,c) (j,k))=0 by rw [hs,mul_zero] + apply Finset.sum_eq_zero + intro f _ + by_cases h₁ : a.val + b.val = f.val + 1 + · have h₂ : f.val + c.val ≠ j.val + k.val := by omega + rw [bulkNumerator_eq_zero_of_sum_ne r z 1 (f,c) (j,k) h₂,mul_zero] + · rw [fusionNumerator_eq_zero_of_sum_ne r (a,b) f h₁,zero_mul] + +private abbrev bulkFusionAdd (a b : ℂ) : ℂ := a+b +private abbrev bulkFusionMul (a b : ℂ) : ℂ := a*b +private abbrev bulkFusionPow (a : ℂ) (n : ℕ) : ℂ := a^n +section +variable (r z : ℂ) (hr : r^16+1=0) + +private lemma bulkFusionBulkComponent00000 : bulkFusionLeft r z 0 0 0 0 0 = bulkFusionRight r z 0 0 0 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 0 0 (by decide)] + +private lemma bulkFusionBulkComponent00001 : bulkFusionLeft r z 0 0 0 0 1 = bulkFusionRight r z 0 0 0 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 0 1 (by decide)] + +private lemma bulkFusionBulkComponent00002 : bulkFusionLeft r z 0 0 0 0 2 = bulkFusionRight r z 0 0 0 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 0 2 (by decide)] + +private lemma bulkFusionBulkComponent00010 : bulkFusionLeft r z 0 0 0 1 0 = bulkFusionRight r z 0 0 0 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 1 0 (by decide)] + +private lemma bulkFusionBulkComponent00011 : bulkFusionLeft r z 0 0 0 1 1 = bulkFusionRight r z 0 0 0 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 1 1 (by decide)] + +private lemma bulkFusionBulkComponent00012 : bulkFusionLeft r z 0 0 0 1 2 = bulkFusionRight r z 0 0 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 1 2 (by decide)] + +private lemma bulkFusionBulkComponent00020 : bulkFusionLeft r z 0 0 0 2 0 = bulkFusionRight r z 0 0 0 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 2 0 (by decide)] + +private lemma bulkFusionBulkComponent00021 : bulkFusionLeft r z 0 0 0 2 1 = bulkFusionRight r z 0 0 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent00022 : bulkFusionLeft r z 0 0 0 2 2 = bulkFusionRight r z 0 0 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 0 2 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate00100 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent00100 : bulkFusionLeft r z 0 0 1 0 0 = bulkFusionRight r z 0 0 1 0 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate00100 r z*x) hr + dsimp only [bulkFusionBulkCertificate00100,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent00101 : bulkFusionLeft r z 0 0 1 0 1 = bulkFusionRight r z 0 0 1 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 0 1 (by decide)] + +private lemma bulkFusionBulkComponent00102 : bulkFusionLeft r z 0 0 1 0 2 = bulkFusionRight r z 0 0 1 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 0 2 (by decide)] + +private lemma bulkFusionBulkComponent00110 : bulkFusionLeft r z 0 0 1 1 0 = bulkFusionRight r z 0 0 1 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 1 0 (by decide)] + +private lemma bulkFusionBulkComponent00111 : bulkFusionLeft r z 0 0 1 1 1 = bulkFusionRight r z 0 0 1 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 1 1 (by decide)] + +private lemma bulkFusionBulkComponent00112 : bulkFusionLeft r z 0 0 1 1 2 = bulkFusionRight r z 0 0 1 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 1 2 (by decide)] + +private lemma bulkFusionBulkComponent00120 : bulkFusionLeft r z 0 0 1 2 0 = bulkFusionRight r z 0 0 1 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 2 0 (by decide)] + +private lemma bulkFusionBulkComponent00121 : bulkFusionLeft r z 0 0 1 2 1 = bulkFusionRight r z 0 0 1 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 2 1 (by decide)] + +private lemma bulkFusionBulkComponent00122 : bulkFusionLeft r z 0 0 1 2 2 = bulkFusionRight r z 0 0 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent00200 : bulkFusionLeft r z 0 0 2 0 0 = bulkFusionRight r z 0 0 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 2 0 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate00201 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (z)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (z)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent00201 : bulkFusionLeft r z 0 0 2 0 1 = bulkFusionRight r z 0 0 2 0 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate00201 r z*x) hr + dsimp only [bulkFusionBulkCertificate00201,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent00202 : bulkFusionLeft r z 0 0 2 0 2 = bulkFusionRight r z 0 0 2 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 2 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 2 0 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate00210 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 126) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 122) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 118) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 118) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 12))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 6))) (bulkFusionMul ((-5:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 10))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 6))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 4)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))) (bulkFusionMul ((6:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 4))))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-5:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6)))))))) +include hr in +private lemma bulkFusionBulkComponent00210 : bulkFusionLeft r z 0 0 2 1 0 = bulkFusionRight r z 0 0 2 1 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate00210 r z*x) hr + dsimp only [bulkFusionBulkCertificate00210,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent00211 : bulkFusionLeft r z 0 0 2 1 1 = bulkFusionRight r z 0 0 2 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 2 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 2 1 1 (by decide)] + +private lemma bulkFusionBulkComponent00212 : bulkFusionLeft r z 0 0 2 1 2 = bulkFusionRight r z 0 0 2 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 2 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 2 1 2 (by decide)] + +private lemma bulkFusionBulkComponent00220 : bulkFusionLeft r z 0 0 2 2 0 = bulkFusionRight r z 0 0 2 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 2 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 2 2 0 (by decide)] + +private lemma bulkFusionBulkComponent00221 : bulkFusionLeft r z 0 0 2 2 1 = bulkFusionRight r z 0 0 2 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 2 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 2 2 1 (by decide)] + +private lemma bulkFusionBulkComponent00222 : bulkFusionLeft r z 0 0 2 2 2 = bulkFusionRight r z 0 0 2 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 0 2 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 0 2 2 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate01000 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 38)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent01000 : bulkFusionLeft r z 0 1 0 0 0 = bulkFusionRight r z 0 1 0 0 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate01000 r z*x) hr + dsimp only [bulkFusionBulkCertificate01000,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent01001 : bulkFusionLeft r z 0 1 0 0 1 = bulkFusionRight r z 0 1 0 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 0 1 (by decide)] + +private lemma bulkFusionBulkComponent01002 : bulkFusionLeft r z 0 1 0 0 2 = bulkFusionRight r z 0 1 0 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 0 2 (by decide)] + +private lemma bulkFusionBulkComponent01010 : bulkFusionLeft r z 0 1 0 1 0 = bulkFusionRight r z 0 1 0 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 1 0 (by decide)] + +private lemma bulkFusionBulkComponent01011 : bulkFusionLeft r z 0 1 0 1 1 = bulkFusionRight r z 0 1 0 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 1 1 (by decide)] + +private lemma bulkFusionBulkComponent01012 : bulkFusionLeft r z 0 1 0 1 2 = bulkFusionRight r z 0 1 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 1 2 (by decide)] + +private lemma bulkFusionBulkComponent01020 : bulkFusionLeft r z 0 1 0 2 0 = bulkFusionRight r z 0 1 0 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 2 0 (by decide)] + +private lemma bulkFusionBulkComponent01021 : bulkFusionLeft r z 0 1 0 2 1 = bulkFusionRight r z 0 1 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent01022 : bulkFusionLeft r z 0 1 0 2 2 = bulkFusionRight r z 0 1 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent01100 : bulkFusionLeft r z 0 1 1 0 0 = bulkFusionRight r z 0 1 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 1 0 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate01101 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))))))) +include hr in +private lemma bulkFusionBulkComponent01101 : bulkFusionLeft r z 0 1 1 0 1 = bulkFusionRight r z 0 1 1 0 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate01101 r z*x) hr + dsimp only [bulkFusionBulkCertificate01101,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent01102 : bulkFusionLeft r z 0 1 1 0 2 = bulkFusionRight r z 0 1 1 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 1 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 1 0 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate01110 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 11)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 9))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 5)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 9))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (z)) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (z))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (z)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (z))) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent01110 : bulkFusionLeft r z 0 1 1 1 0 = bulkFusionRight r z 0 1 1 1 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate01110 r z*x) hr + dsimp only [bulkFusionBulkCertificate01110,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent01111 : bulkFusionLeft r z 0 1 1 1 1 = bulkFusionRight r z 0 1 1 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 1 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 1 1 1 (by decide)] + +private lemma bulkFusionBulkComponent01112 : bulkFusionLeft r z 0 1 1 1 2 = bulkFusionRight r z 0 1 1 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 1 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 1 1 2 (by decide)] + +private lemma bulkFusionBulkComponent01120 : bulkFusionLeft r z 0 1 1 2 0 = bulkFusionRight r z 0 1 1 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 1 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 1 2 0 (by decide)] + +private lemma bulkFusionBulkComponent01121 : bulkFusionLeft r z 0 1 1 2 1 = bulkFusionRight r z 0 1 1 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 1 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 1 2 1 (by decide)] + +private lemma bulkFusionBulkComponent01122 : bulkFusionLeft r z 0 1 1 2 2 = bulkFusionRight r z 0 1 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent01200 : bulkFusionLeft r z 0 1 2 0 0 = bulkFusionRight r z 0 1 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent01201 : bulkFusionLeft r z 0 1 2 0 1 = bulkFusionRight r z 0 1 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 2 0 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate01202 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 30)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 18) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent01202 : bulkFusionLeft r z 0 1 2 0 2 = bulkFusionRight r z 0 1 2 0 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate01202 r z*x) hr + dsimp only [bulkFusionBulkCertificate01202,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent01210 : bulkFusionLeft r z 0 1 2 1 0 = bulkFusionRight r z 0 1 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 2 1 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate01211 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 116) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 112) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 112) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 11)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 7))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent01211 : bulkFusionLeft r z 0 1 2 1 1 = bulkFusionRight r z 0 1 2 1 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate01211 r z*x) hr + dsimp only [bulkFusionBulkCertificate01211,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent01212 : bulkFusionLeft r z 0 1 2 1 2 = bulkFusionRight r z 0 1 2 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 2 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 2 1 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate01220 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6)))))))) +include hr in +private lemma bulkFusionBulkComponent01220 : bulkFusionLeft r z 0 1 2 2 0 = bulkFusionRight r z 0 1 2 2 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate01220 r z*x) hr + dsimp only [bulkFusionBulkCertificate01220,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent01221 : bulkFusionLeft r z 0 1 2 2 1 = bulkFusionRight r z 0 1 2 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 2 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 2 2 1 (by decide)] + +private lemma bulkFusionBulkComponent01222 : bulkFusionLeft r z 0 1 2 2 2 = bulkFusionRight r z 0 1 2 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 1 2 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 1 2 2 2 (by decide)] + +private lemma bulkFusionBulkComponent02000 : bulkFusionLeft r z 0 2 0 0 0 = bulkFusionRight r z 0 2 0 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 0 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 0 0 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate02001 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((6:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (z)) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (z)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent02001 : bulkFusionLeft r z 0 2 0 0 1 = bulkFusionRight r z 0 2 0 0 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate02001 r z*x) hr + dsimp only [bulkFusionBulkCertificate02001,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent02002 : bulkFusionLeft r z 0 2 0 0 2 = bulkFusionRight r z 0 2 0 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 0 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 0 0 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate02010 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 118) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 12)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 10))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))) (bulkFusionMul ((-5:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 46)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent02010 : bulkFusionLeft r z 0 2 0 1 0 = bulkFusionRight r z 0 2 0 1 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate02010 r z*x) hr + dsimp only [bulkFusionBulkCertificate02010,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent02011 : bulkFusionLeft r z 0 2 0 1 1 = bulkFusionRight r z 0 2 0 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 0 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 0 1 1 (by decide)] + +private lemma bulkFusionBulkComponent02012 : bulkFusionLeft r z 0 2 0 1 2 = bulkFusionRight r z 0 2 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 0 1 2 (by decide)] + +private lemma bulkFusionBulkComponent02020 : bulkFusionLeft r z 0 2 0 2 0 = bulkFusionRight r z 0 2 0 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 0 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 0 2 0 (by decide)] + +private lemma bulkFusionBulkComponent02021 : bulkFusionLeft r z 0 2 0 2 1 = bulkFusionRight r z 0 2 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent02022 : bulkFusionLeft r z 0 2 0 2 2 = bulkFusionRight r z 0 2 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent02100 : bulkFusionLeft r z 0 2 1 0 0 = bulkFusionRight r z 0 2 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 1 0 0 (by decide)] + +private lemma bulkFusionBulkComponent02101 : bulkFusionLeft r z 0 2 1 0 1 = bulkFusionRight r z 0 2 1 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 1 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 1 0 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate02102 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 11)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent02102 : bulkFusionLeft r z 0 2 1 0 2 = bulkFusionRight r z 0 2 1 0 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate02102 r z*x) hr + dsimp only [bulkFusionBulkCertificate02102,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma bulkFusionBulkComponent02110 : bulkFusionLeft r z 0 2 1 1 0 = bulkFusionRight r z 0 2 1 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 1 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 1 1 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate02111 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8))) (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 4)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionPow r 62) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 46))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent02111 : bulkFusionLeft r z 0 2 1 1 1 = bulkFusionRight r z 0 2 1 1 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate02111 r z*x) hr + dsimp only [bulkFusionBulkCertificate02111,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent02112 : bulkFusionLeft r z 0 2 1 1 2 = bulkFusionRight r z 0 2 1 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 1 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 1 1 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate02120 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 11))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 3)) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (z)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (z)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent02120 : bulkFusionLeft r z 0 2 1 2 0 = bulkFusionRight r z 0 2 1 2 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate02120 r z*x) hr + dsimp only [bulkFusionBulkCertificate02120,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent02121 : bulkFusionLeft r z 0 2 1 2 1 = bulkFusionRight r z 0 2 1 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 1 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 1 2 1 (by decide)] + +private lemma bulkFusionBulkComponent02122 : bulkFusionLeft r z 0 2 1 2 2 = bulkFusionRight r z 0 2 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent02200 : bulkFusionLeft r z 0 2 2 0 0 = bulkFusionRight r z 0 2 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent02201 : bulkFusionLeft r z 0 2 2 0 1 = bulkFusionRight r z 0 2 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 2 0 1 (by decide)] + +private lemma bulkFusionBulkComponent02202 : bulkFusionLeft r z 0 2 2 0 2 = bulkFusionRight r z 0 2 2 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 2 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 2 0 2 (by decide)] + +private lemma bulkFusionBulkComponent02210 : bulkFusionLeft r z 0 2 2 1 0 = bulkFusionRight r z 0 2 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 2 1 0 (by decide)] + +private lemma bulkFusionBulkComponent02211 : bulkFusionLeft r z 0 2 2 1 1 = bulkFusionRight r z 0 2 2 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 2 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 2 1 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate02212 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 118) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 12))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 4)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 46)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent02212 : bulkFusionLeft r z 0 2 2 1 2 = bulkFusionRight r z 0 2 2 1 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate02212 r z*x) hr + dsimp only [bulkFusionBulkCertificate02212,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma bulkFusionBulkComponent02220 : bulkFusionLeft r z 0 2 2 2 0 = bulkFusionRight r z 0 2 2 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 2 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 2 2 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate02221 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 9))) (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 58) (z))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (z)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent02221 : bulkFusionLeft r z 0 2 2 2 1 = bulkFusionRight r z 0 2 2 2 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate02221 r z*x) hr + dsimp only [bulkFusionBulkCertificate02221,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma bulkFusionBulkComponent02222 : bulkFusionLeft r z 0 2 2 2 2 = bulkFusionRight r z 0 2 2 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 0 2 2 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 0 2 2 2 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate10000 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 38))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent10000 : bulkFusionLeft r z 1 0 0 0 0 = bulkFusionRight r z 1 0 0 0 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate10000 r z*x) hr + dsimp only [bulkFusionBulkCertificate10000,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent10001 : bulkFusionLeft r z 1 0 0 0 1 = bulkFusionRight r z 1 0 0 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 0 1 (by decide)] + +private lemma bulkFusionBulkComponent10002 : bulkFusionLeft r z 1 0 0 0 2 = bulkFusionRight r z 1 0 0 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 0 2 (by decide)] + +private lemma bulkFusionBulkComponent10010 : bulkFusionLeft r z 1 0 0 1 0 = bulkFusionRight r z 1 0 0 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 1 0 (by decide)] + +private lemma bulkFusionBulkComponent10011 : bulkFusionLeft r z 1 0 0 1 1 = bulkFusionRight r z 1 0 0 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 1 1 (by decide)] + +private lemma bulkFusionBulkComponent10012 : bulkFusionLeft r z 1 0 0 1 2 = bulkFusionRight r z 1 0 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 1 2 (by decide)] + +private lemma bulkFusionBulkComponent10020 : bulkFusionLeft r z 1 0 0 2 0 = bulkFusionRight r z 1 0 0 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 2 0 (by decide)] + +private lemma bulkFusionBulkComponent10021 : bulkFusionLeft r z 1 0 0 2 1 = bulkFusionRight r z 1 0 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent10022 : bulkFusionLeft r z 1 0 0 2 2 = bulkFusionRight r z 1 0 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent10100 : bulkFusionLeft r z 1 0 1 0 0 = bulkFusionRight r z 1 0 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 1 0 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate10101 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6)))))))) +include hr in +private lemma bulkFusionBulkComponent10101 : bulkFusionLeft r z 1 0 1 0 1 = bulkFusionRight r z 1 0 1 0 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate10101 r z*x) hr + dsimp only [bulkFusionBulkCertificate10101,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent10102 : bulkFusionLeft r z 1 0 1 0 2 = bulkFusionRight r z 1 0 1 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 1 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 1 0 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate10110 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (z))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent10110 : bulkFusionLeft r z 1 0 1 1 0 = bulkFusionRight r z 1 0 1 1 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate10110 r z*x) hr + dsimp only [bulkFusionBulkCertificate10110,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent10111 : bulkFusionLeft r z 1 0 1 1 1 = bulkFusionRight r z 1 0 1 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 1 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 1 1 1 (by decide)] + +private lemma bulkFusionBulkComponent10112 : bulkFusionLeft r z 1 0 1 1 2 = bulkFusionRight r z 1 0 1 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 1 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 1 1 2 (by decide)] + +private lemma bulkFusionBulkComponent10120 : bulkFusionLeft r z 1 0 1 2 0 = bulkFusionRight r z 1 0 1 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 1 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 1 2 0 (by decide)] + +private lemma bulkFusionBulkComponent10121 : bulkFusionLeft r z 1 0 1 2 1 = bulkFusionRight r z 1 0 1 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 1 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 1 2 1 (by decide)] + +private lemma bulkFusionBulkComponent10122 : bulkFusionLeft r z 1 0 1 2 2 = bulkFusionRight r z 1 0 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent10200 : bulkFusionLeft r z 1 0 2 0 0 = bulkFusionRight r z 1 0 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent10201 : bulkFusionLeft r z 1 0 2 0 1 = bulkFusionRight r z 1 0 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 2 0 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate10202 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 30)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 18) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent10202 : bulkFusionLeft r z 1 0 2 0 2 = bulkFusionRight r z 1 0 2 0 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate10202 r z*x) hr + dsimp only [bulkFusionBulkCertificate10202,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent10210 : bulkFusionLeft r z 1 0 2 1 0 = bulkFusionRight r z 1 0 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 2 1 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate10211 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 124) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 120) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 116) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 116) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 116) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 112) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 112) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 112) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 7))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 11))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 3)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 11)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 9))) (bulkFusionMul ((4:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 5))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 80) (z)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 72) (z)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 7))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 9)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (z))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 48) (z)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 40) (z))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent10211 : bulkFusionLeft r z 1 0 2 1 1 = bulkFusionRight r z 1 0 2 1 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate10211 r z*x) hr + dsimp only [bulkFusionBulkCertificate10211,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent10212 : bulkFusionLeft r z 1 0 2 1 2 = bulkFusionRight r z 1 0 2 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 2 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 2 1 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate10220 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4)) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent10220 : bulkFusionLeft r z 1 0 2 2 0 = bulkFusionRight r z 1 0 2 2 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate10220 r z*x) hr + dsimp only [bulkFusionBulkCertificate10220,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent10221 : bulkFusionLeft r z 1 0 2 2 1 = bulkFusionRight r z 1 0 2 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 2 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 2 2 1 (by decide)] + +private lemma bulkFusionBulkComponent10222 : bulkFusionLeft r z 1 0 2 2 2 = bulkFusionRight r z 1 0 2 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 0 2 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 0 2 2 2 (by decide)] + +private lemma bulkFusionBulkComponent11000 : bulkFusionLeft r z 1 1 0 0 0 = bulkFusionRight r z 1 1 0 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 0 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 0 0 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate11001 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 5)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 11))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 7))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent11001 : bulkFusionLeft r z 1 1 0 0 1 = bulkFusionRight r z 1 1 0 0 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate11001 r z*x) hr + dsimp only [bulkFusionBulkCertificate11001,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent11002 : bulkFusionLeft r z 1 1 0 0 2 = bulkFusionRight r z 1 1 0 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 0 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 0 0 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate11010 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 10)) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 48)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 4))) (bulkFusionPow r 36)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 24) (bulkFusionPow z 4))))))) +include hr in +private lemma bulkFusionBulkComponent11010 : bulkFusionLeft r z 1 1 0 1 0 = bulkFusionRight r z 1 1 0 1 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate11010 r z*x) hr + dsimp only [bulkFusionBulkCertificate11010,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent11011 : bulkFusionLeft r z 1 1 0 1 1 = bulkFusionRight r z 1 1 0 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 0 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 0 1 1 (by decide)] + +private lemma bulkFusionBulkComponent11012 : bulkFusionLeft r z 1 1 0 1 2 = bulkFusionRight r z 1 1 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 0 1 2 (by decide)] + +private lemma bulkFusionBulkComponent11020 : bulkFusionLeft r z 1 1 0 2 0 = bulkFusionRight r z 1 1 0 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 0 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 0 2 0 (by decide)] + +private lemma bulkFusionBulkComponent11021 : bulkFusionLeft r z 1 1 0 2 1 = bulkFusionRight r z 1 1 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent11022 : bulkFusionLeft r z 1 1 0 2 2 = bulkFusionRight r z 1 1 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent11100 : bulkFusionLeft r z 1 1 1 0 0 = bulkFusionRight r z 1 1 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 1 0 0 (by decide)] + +private lemma bulkFusionBulkComponent11101 : bulkFusionLeft r z 1 1 1 0 1 = bulkFusionRight r z 1 1 1 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 1 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 1 0 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate11102 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 11)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 11)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 11))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (z))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (z))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent11102 : bulkFusionLeft r z 1 1 1 0 2 = bulkFusionRight r z 1 1 1 0 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate11102 r z*x) hr + dsimp only [bulkFusionBulkCertificate11102,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent11110 : bulkFusionLeft r z 1 1 1 1 0 = bulkFusionRight r z 1 1 1 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 1 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 1 1 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate11111 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 112) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 8))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 6)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 8)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 6))))))) +include hr in +private lemma bulkFusionBulkComponent11111 : bulkFusionLeft r z 1 1 1 1 1 = bulkFusionRight r z 1 1 1 1 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate11111 r z*x) hr + dsimp only [bulkFusionBulkCertificate11111,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent11112 : bulkFusionLeft r z 1 1 1 1 2 = bulkFusionRight r z 1 1 1 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 1 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 1 1 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate11120 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 66) (z)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (z)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent11120 : bulkFusionLeft r z 1 1 1 2 0 = bulkFusionRight r z 1 1 1 2 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate11120 r z*x) hr + dsimp only [bulkFusionBulkCertificate11120,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent11121 : bulkFusionLeft r z 1 1 1 2 1 = bulkFusionRight r z 1 1 1 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 1 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 1 2 1 (by decide)] + +private lemma bulkFusionBulkComponent11122 : bulkFusionLeft r z 1 1 1 2 2 = bulkFusionRight r z 1 1 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent11200 : bulkFusionLeft r z 1 1 2 0 0 = bulkFusionRight r z 1 1 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent11201 : bulkFusionLeft r z 1 1 2 0 1 = bulkFusionRight r z 1 1 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 2 0 1 (by decide)] + +private lemma bulkFusionBulkComponent11202 : bulkFusionLeft r z 1 1 2 0 2 = bulkFusionRight r z 1 1 2 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 2 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 2 0 2 (by decide)] + +private lemma bulkFusionBulkComponent11210 : bulkFusionLeft r z 1 1 2 1 0 = bulkFusionRight r z 1 1 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 2 1 0 (by decide)] + +private lemma bulkFusionBulkComponent11211 : bulkFusionLeft r z 1 1 2 1 1 = bulkFusionRight r z 1 1 2 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 2 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 2 1 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate11212 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 10)) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 48)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 4))) (bulkFusionPow r 36)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 24) (bulkFusionPow z 4))))))) +include hr in +private lemma bulkFusionBulkComponent11212 : bulkFusionLeft r z 1 1 2 1 2 = bulkFusionRight r z 1 1 2 1 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate11212 r z*x) hr + dsimp only [bulkFusionBulkCertificate11212,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent11220 : bulkFusionLeft r z 1 1 2 2 0 = bulkFusionRight r z 1 1 2 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 2 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 2 2 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate11221 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 5)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 11))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 7))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent11221 : bulkFusionLeft r z 1 1 2 2 1 = bulkFusionRight r z 1 1 2 2 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate11221 r z*x) hr + dsimp only [bulkFusionBulkCertificate11221,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent11222 : bulkFusionLeft r z 1 1 2 2 2 = bulkFusionRight r z 1 1 2 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 1 2 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 1 2 2 2 (by decide)] + +private lemma bulkFusionBulkComponent12000 : bulkFusionLeft r z 1 2 0 0 0 = bulkFusionRight r z 1 2 0 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 0 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 0 0 0 (by decide)] + +private lemma bulkFusionBulkComponent12001 : bulkFusionLeft r z 1 2 0 0 1 = bulkFusionRight r z 1 2 0 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 0 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 0 0 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate12002 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionPow r 38))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent12002 : bulkFusionLeft r z 1 2 0 0 2 = bulkFusionRight r z 1 2 0 0 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate12002 r z*x) hr + dsimp only [bulkFusionBulkCertificate12002,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent12010 : bulkFusionLeft r z 1 2 0 1 0 = bulkFusionRight r z 1 2 0 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 0 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 0 1 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate12011 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 116) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 112) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 7))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 11))) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 7)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 11)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 9))))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (z))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (z))) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 60) (z))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7)) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 56) (z)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 9)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 52) (z)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 48) (z)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent12011 : bulkFusionLeft r z 1 2 0 1 1 = bulkFusionRight r z 1 2 0 1 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate12011 r z*x) hr + dsimp only [bulkFusionBulkCertificate12011,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent12012 : bulkFusionLeft r z 1 2 0 1 2 = bulkFusionRight r z 1 2 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 0 1 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate12020 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 30)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 18) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent12020 : bulkFusionLeft r z 1 2 0 2 0 = bulkFusionRight r z 1 2 0 2 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate12020 r z*x) hr + dsimp only [bulkFusionBulkCertificate12020,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent12021 : bulkFusionLeft r z 1 2 0 2 1 = bulkFusionRight r z 1 2 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent12022 : bulkFusionLeft r z 1 2 0 2 2 = bulkFusionRight r z 1 2 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent12100 : bulkFusionLeft r z 1 2 1 0 0 = bulkFusionRight r z 1 2 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 1 0 0 (by decide)] + +private lemma bulkFusionBulkComponent12101 : bulkFusionLeft r z 1 2 1 0 1 = bulkFusionRight r z 1 2 1 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 1 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 1 0 1 (by decide)] + +private lemma bulkFusionBulkComponent12102 : bulkFusionLeft r z 1 2 1 0 2 = bulkFusionRight r z 1 2 1 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 1 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 1 0 2 (by decide)] + +private lemma bulkFusionBulkComponent12110 : bulkFusionLeft r z 1 2 1 1 0 = bulkFusionRight r z 1 2 1 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 1 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 1 1 0 (by decide)] + +private lemma bulkFusionBulkComponent12111 : bulkFusionLeft r z 1 2 1 1 1 = bulkFusionRight r z 1 2 1 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 1 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 1 1 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate12112 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (z))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent12112 : bulkFusionLeft r z 1 2 1 1 2 = bulkFusionRight r z 1 2 1 1 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate12112 r z*x) hr + dsimp only [bulkFusionBulkCertificate12112,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent12120 : bulkFusionLeft r z 1 2 1 2 0 = bulkFusionRight r z 1 2 1 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 1 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 1 2 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate12121 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6)))))))) +include hr in +private lemma bulkFusionBulkComponent12121 : bulkFusionLeft r z 1 2 1 2 1 = bulkFusionRight r z 1 2 1 2 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate12121 r z*x) hr + dsimp only [bulkFusionBulkCertificate12121,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent12122 : bulkFusionLeft r z 1 2 1 2 2 = bulkFusionRight r z 1 2 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent12200 : bulkFusionLeft r z 1 2 2 0 0 = bulkFusionRight r z 1 2 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent12201 : bulkFusionLeft r z 1 2 2 0 1 = bulkFusionRight r z 1 2 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 0 1 (by decide)] + +private lemma bulkFusionBulkComponent12202 : bulkFusionLeft r z 1 2 2 0 2 = bulkFusionRight r z 1 2 2 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 0 2 (by decide)] + +private lemma bulkFusionBulkComponent12210 : bulkFusionLeft r z 1 2 2 1 0 = bulkFusionRight r z 1 2 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 1 0 (by decide)] + +private lemma bulkFusionBulkComponent12211 : bulkFusionLeft r z 1 2 2 1 1 = bulkFusionRight r z 1 2 2 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 1 1 (by decide)] + +private lemma bulkFusionBulkComponent12212 : bulkFusionLeft r z 1 2 2 1 2 = bulkFusionRight r z 1 2 2 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 1 2 (by decide)] + +private lemma bulkFusionBulkComponent12220 : bulkFusionLeft r z 1 2 2 2 0 = bulkFusionRight r z 1 2 2 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 2 0 (by decide)] + +private lemma bulkFusionBulkComponent12221 : bulkFusionLeft r z 1 2 2 2 1 = bulkFusionRight r z 1 2 2 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 1 2 2 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 1 2 2 2 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate12222 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 38))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent12222 : bulkFusionLeft r z 1 2 2 2 2 = bulkFusionRight r z 1 2 2 2 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate12222 r z*x) hr + dsimp only [bulkFusionBulkCertificate12222,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent20000 : bulkFusionLeft r z 2 0 0 0 0 = bulkFusionRight r z 2 0 0 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 0 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 0 0 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate20001 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 9))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 9)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (z)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent20001 : bulkFusionLeft r z 2 0 0 0 1 = bulkFusionRight r z 2 0 0 0 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate20001 r z*x) hr + dsimp only [bulkFusionBulkCertificate20001,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent20002 : bulkFusionLeft r z 2 0 0 0 2 = bulkFusionRight r z 2 0 0 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 0 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 0 0 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate20010 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 12)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionPow r 38) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4))))))) +include hr in +private lemma bulkFusionBulkComponent20010 : bulkFusionLeft r z 2 0 0 1 0 = bulkFusionRight r z 2 0 0 1 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate20010 r z*x) hr + dsimp only [bulkFusionBulkCertificate20010,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent20011 : bulkFusionLeft r z 2 0 0 1 1 = bulkFusionRight r z 2 0 0 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 0 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 0 1 1 (by decide)] + +private lemma bulkFusionBulkComponent20012 : bulkFusionLeft r z 2 0 0 1 2 = bulkFusionRight r z 2 0 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 0 1 2 (by decide)] + +private lemma bulkFusionBulkComponent20020 : bulkFusionLeft r z 2 0 0 2 0 = bulkFusionRight r z 2 0 0 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 0 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 0 2 0 (by decide)] + +private lemma bulkFusionBulkComponent20021 : bulkFusionLeft r z 2 0 0 2 1 = bulkFusionRight r z 2 0 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent20022 : bulkFusionLeft r z 2 0 0 2 2 = bulkFusionRight r z 2 0 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent20100 : bulkFusionLeft r z 2 0 1 0 0 = bulkFusionRight r z 2 0 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 1 0 0 (by decide)] + +private lemma bulkFusionBulkComponent20101 : bulkFusionLeft r z 2 0 1 0 1 = bulkFusionRight r z 2 0 1 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 1 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 1 0 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate20102 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 9))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3)) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (z))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent20102 : bulkFusionLeft r z 2 0 1 0 2 = bulkFusionRight r z 2 0 1 0 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate20102 r z*x) hr + dsimp only [bulkFusionBulkCertificate20102,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent20110 : bulkFusionLeft r z 2 0 1 1 0 = bulkFusionRight r z 2 0 1 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 1 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 1 1 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate20111 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 54)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 8))) (bulkFusionPow r 38)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4))))))) +include hr in +private lemma bulkFusionBulkComponent20111 : bulkFusionLeft r z 2 0 1 1 1 = bulkFusionRight r z 2 0 1 1 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate20111 r z*x) hr + dsimp only [bulkFusionBulkCertificate20111,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent20112 : bulkFusionLeft r z 2 0 1 1 2 = bulkFusionRight r z 2 0 1 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 1 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 1 1 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate20120 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 11)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent20120 : bulkFusionLeft r z 2 0 1 2 0 = bulkFusionRight r z 2 0 1 2 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate20120 r z*x) hr + dsimp only [bulkFusionBulkCertificate20120,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + first | linear_combination hq | linear_combination -hq + +private lemma bulkFusionBulkComponent20121 : bulkFusionLeft r z 2 0 1 2 1 = bulkFusionRight r z 2 0 1 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 1 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 1 2 1 (by decide)] + +private lemma bulkFusionBulkComponent20122 : bulkFusionLeft r z 2 0 1 2 2 = bulkFusionRight r z 2 0 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent20200 : bulkFusionLeft r z 2 0 2 0 0 = bulkFusionRight r z 2 0 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent20201 : bulkFusionLeft r z 2 0 2 0 1 = bulkFusionRight r z 2 0 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 2 0 1 (by decide)] + +private lemma bulkFusionBulkComponent20202 : bulkFusionLeft r z 2 0 2 0 2 = bulkFusionRight r z 2 0 2 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 2 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 2 0 2 (by decide)] + +private lemma bulkFusionBulkComponent20210 : bulkFusionLeft r z 2 0 2 1 0 = bulkFusionRight r z 2 0 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 2 1 0 (by decide)] + +private lemma bulkFusionBulkComponent20211 : bulkFusionLeft r z 2 0 2 1 1 = bulkFusionRight r z 2 0 2 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 2 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 2 1 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate20212 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 122) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 118) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 118) (bulkFusionPow z 6))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-6:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 8))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-5:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 4))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 12))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 4))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8)) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((5:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8)) (bulkFusionMul ((5:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6)) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionPow r 38) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent20212 : bulkFusionLeft r z 2 0 2 1 2 = bulkFusionRight r z 2 0 2 1 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate20212 r z*x) hr + dsimp only [bulkFusionBulkCertificate20212,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent20220 : bulkFusionLeft r z 2 0 2 2 0 = bulkFusionRight r z 2 0 2 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 2 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 2 2 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate20221 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 9))) (bulkFusionMul ((-5:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3))) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 7))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 9)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent20221 : bulkFusionLeft r z 2 0 2 2 1 = bulkFusionRight r z 2 0 2 2 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate20221 r z*x) hr + dsimp only [bulkFusionBulkCertificate20221,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent20222 : bulkFusionLeft r z 2 0 2 2 2 = bulkFusionRight r z 2 0 2 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 0 2 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 0 2 2 2 (by decide)] + +private lemma bulkFusionBulkComponent21000 : bulkFusionLeft r z 2 1 0 0 0 = bulkFusionRight r z 2 1 0 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 0 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 0 0 0 (by decide)] + +private lemma bulkFusionBulkComponent21001 : bulkFusionLeft r z 2 1 0 0 1 = bulkFusionRight r z 2 1 0 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 0 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 0 0 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate21002 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 8))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionPow r 38))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent21002 : bulkFusionLeft r z 2 1 0 0 2 = bulkFusionRight r z 2 1 0 0 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate21002 r z*x) hr + dsimp only [bulkFusionBulkCertificate21002,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent21010 : bulkFusionLeft r z 2 1 0 1 0 = bulkFusionRight r z 2 1 0 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 0 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 0 1 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate21011 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 108) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 104) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 100) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 11))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 9)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 96) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 92) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 11))) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 7))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 48) (z)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 40) (z)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent21011 : bulkFusionLeft r z 2 1 0 1 1 = bulkFusionRight r z 2 1 0 1 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate21011 r z*x) hr + dsimp only [bulkFusionBulkCertificate21011,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent21012 : bulkFusionLeft r z 2 1 0 1 2 = bulkFusionRight r z 2 1 0 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 0 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 0 1 2 (by decide)] + +private noncomputable def bulkFusionBulkCertificate21020 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 2))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 8)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 4)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 30)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 2))))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 18) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent21020 : bulkFusionLeft r z 2 1 0 2 0 = bulkFusionRight r z 2 1 0 2 0 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate21020 r z*x) hr + dsimp only [bulkFusionBulkCertificate21020,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent21021 : bulkFusionLeft r z 2 1 0 2 1 = bulkFusionRight r z 2 1 0 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 0 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 0 2 1 (by decide)] + +private lemma bulkFusionBulkComponent21022 : bulkFusionLeft r z 2 1 0 2 2 = bulkFusionRight r z 2 1 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent21100 : bulkFusionLeft r z 2 1 1 0 0 = bulkFusionRight r z 2 1 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 1 0 0 (by decide)] + +private lemma bulkFusionBulkComponent21101 : bulkFusionLeft r z 2 1 1 0 1 = bulkFusionRight r z 2 1 1 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 1 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 1 0 1 (by decide)] + +private lemma bulkFusionBulkComponent21102 : bulkFusionLeft r z 2 1 1 0 2 = bulkFusionRight r z 2 1 1 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 1 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 1 0 2 (by decide)] + +private lemma bulkFusionBulkComponent21110 : bulkFusionLeft r z 2 1 1 1 0 = bulkFusionRight r z 2 1 1 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 1 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 1 1 0 (by decide)] + +private lemma bulkFusionBulkComponent21111 : bulkFusionLeft r z 2 1 1 1 1 = bulkFusionRight r z 2 1 1 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 1 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 1 1 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate21112 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 7))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 5))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 11))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 7)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 5))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 7)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9)) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 5))) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (z))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 7)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (z))) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 5))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (z)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 3)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent21112 : bulkFusionLeft r z 2 1 1 1 2 = bulkFusionRight r z 2 1 1 1 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate21112 r z*x) hr + dsimp only [bulkFusionBulkCertificate21112,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent21120 : bulkFusionLeft r z 2 1 1 2 0 = bulkFusionRight r z 2 1 1 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 1 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 1 2 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate21121 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))))))) +include hr in +private lemma bulkFusionBulkComponent21121 : bulkFusionLeft r z 2 1 1 2 1 = bulkFusionRight r z 2 1 1 2 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate21121 r z*x) hr + dsimp only [bulkFusionBulkCertificate21121,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent21122 : bulkFusionLeft r z 2 1 1 2 2 = bulkFusionRight r z 2 1 1 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 1 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 1 2 2 (by decide)] + +private lemma bulkFusionBulkComponent21200 : bulkFusionLeft r z 2 1 2 0 0 = bulkFusionRight r z 2 1 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent21201 : bulkFusionLeft r z 2 1 2 0 1 = bulkFusionRight r z 2 1 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 0 1 (by decide)] + +private lemma bulkFusionBulkComponent21202 : bulkFusionLeft r z 2 1 2 0 2 = bulkFusionRight r z 2 1 2 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 0 2 (by decide)] + +private lemma bulkFusionBulkComponent21210 : bulkFusionLeft r z 2 1 2 1 0 = bulkFusionRight r z 2 1 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 1 0 (by decide)] + +private lemma bulkFusionBulkComponent21211 : bulkFusionLeft r z 2 1 2 1 1 = bulkFusionRight r z 2 1 2 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 1 1 (by decide)] + +private lemma bulkFusionBulkComponent21212 : bulkFusionLeft r z 2 1 2 1 2 = bulkFusionRight r z 2 1 2 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 1 2 (by decide)] + +private lemma bulkFusionBulkComponent21220 : bulkFusionLeft r z 2 1 2 2 0 = bulkFusionRight r z 2 1 2 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 2 0 (by decide)] + +private lemma bulkFusionBulkComponent21221 : bulkFusionLeft r z 2 1 2 2 1 = bulkFusionRight r z 2 1 2 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 1 2 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 1 2 2 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate21222 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 10)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))) (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-3:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionPow r 38)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 6))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 2))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 4)))))))) +include hr in +private lemma bulkFusionBulkComponent21222 : bulkFusionLeft r z 2 1 2 2 2 = bulkFusionRight r z 2 1 2 2 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate21222 r z*x) hr + dsimp only [bulkFusionBulkCertificate21222,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent22000 : bulkFusionLeft r z 2 2 0 0 0 = bulkFusionRight r z 2 2 0 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 0 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 0 0 0 (by decide)] + +private lemma bulkFusionBulkComponent22001 : bulkFusionLeft r z 2 2 0 0 1 = bulkFusionRight r z 2 2 0 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 0 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 0 0 1 (by decide)] + +private lemma bulkFusionBulkComponent22002 : bulkFusionLeft r z 2 2 0 0 2 = bulkFusionRight r z 2 2 0 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 0 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 0 0 2 (by decide)] + +private lemma bulkFusionBulkComponent22010 : bulkFusionLeft r z 2 2 0 1 0 = bulkFusionRight r z 2 2 0 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 0 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 0 1 0 (by decide)] + +private lemma bulkFusionBulkComponent22011 : bulkFusionLeft r z 2 2 0 1 1 = bulkFusionRight r z 2 2 0 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 0 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 0 1 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate22012 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 114) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 110) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 106) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 102) (bulkFusionPow z 6))) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 10)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 8)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 10))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 10))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 4)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 10)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 4))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 10))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 4))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 8)))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 6))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 4)))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-4:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 6))) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 4))))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 8))) (bulkFusionAdd (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 2))) (bulkFusionMul ((-2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 8)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 2)))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 8))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 6)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 4))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 2))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 6)) (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 2))) (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 8))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 6)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 2)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 6)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((3:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 4))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 2)) (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 6))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((2:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 4))) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 6))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 4)) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 6))))))) +include hr in +private lemma bulkFusionBulkComponent22012 : bulkFusionLeft r z 2 2 0 1 2 = bulkFusionRight r z 2 2 0 1 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate22012 r z*x) hr + dsimp only [bulkFusionBulkCertificate22012,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent22020 : bulkFusionLeft r z 2 2 0 2 0 = bulkFusionRight r z 2 2 0 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 0 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 0 2 0 (by decide)] + +private noncomputable def bulkFusionBulkCertificate22021 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 98) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 94) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 90) (bulkFusionPow z 9))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 11)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 86) (bulkFusionPow z 5)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 82) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 11))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 78) (bulkFusionPow z 7)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 74) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 7))) (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 70) (bulkFusionPow z 3)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 66) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 9))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 5)) (bulkFusionMul (bulkFusionPow r 62) (bulkFusionPow z 3))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 9)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 58) (bulkFusionPow z 3))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 54) (bulkFusionPow z 9))) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 7)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 50) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 7))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 46) (bulkFusionPow z 3)) (bulkFusionMul (bulkFusionPow r 42) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 42) (z))) (bulkFusionMul (bulkFusionPow r 38) (bulkFusionPow z 5))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 5)) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 34) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 30) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 7)) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 26) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 22) (bulkFusionPow z 5)))))))) +include hr in +private lemma bulkFusionBulkComponent22021 : bulkFusionLeft r z 2 2 0 2 1 = bulkFusionRight r z 2 2 0 2 1 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate22021 r z*x) hr + dsimp only [bulkFusionBulkCertificate22021,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent22022 : bulkFusionLeft r z 2 2 0 2 2 = bulkFusionRight r z 2 2 0 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 0 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 0 2 2 (by decide)] + +private lemma bulkFusionBulkComponent22100 : bulkFusionLeft r z 2 2 1 0 0 = bulkFusionRight r z 2 2 1 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 0 0 (by decide)] + +private lemma bulkFusionBulkComponent22101 : bulkFusionLeft r z 2 2 1 0 1 = bulkFusionRight r z 2 2 1 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 0 1 (by decide)] + +private lemma bulkFusionBulkComponent22102 : bulkFusionLeft r z 2 2 1 0 2 = bulkFusionRight r z 2 2 1 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 0 2 (by decide)] + +private lemma bulkFusionBulkComponent22110 : bulkFusionLeft r z 2 2 1 1 0 = bulkFusionRight r z 2 2 1 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 1 0 (by decide)] + +private lemma bulkFusionBulkComponent22111 : bulkFusionLeft r z 2 2 1 1 1 = bulkFusionRight r z 2 2 1 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 1 1 (by decide)] + +private lemma bulkFusionBulkComponent22112 : bulkFusionLeft r z 2 2 1 1 2 = bulkFusionRight r z 2 2 1 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 1 2 (by decide)] + +private lemma bulkFusionBulkComponent22120 : bulkFusionLeft r z 2 2 1 2 0 = bulkFusionRight r z 2 2 1 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 2 0 (by decide)] + +private lemma bulkFusionBulkComponent22121 : bulkFusionLeft r z 2 2 1 2 1 = bulkFusionRight r z 2 2 1 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 1 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 1 2 1 (by decide)] + +private noncomputable def bulkFusionBulkCertificate22122 (r z : ℂ) : ℂ := + bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 88) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 84) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 5))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 80) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 9)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 76) (bulkFusionPow z 5)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 72) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 9))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 7))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 68) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 64) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 60) (bulkFusionPow z 7))))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 56) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 52) (bulkFusionPow z 5)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (bulkFusionPow z 3))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 48) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 7)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 44) (bulkFusionPow z 3)))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 40) (z))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 7))))) (bulkFusionAdd (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 5))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 36) (bulkFusionPow z 3)))) (bulkFusionAdd (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 32) (bulkFusionPow z 3))) (bulkFusionMul ((-1:ℂ)) (bulkFusionMul (bulkFusionPow r 28) (bulkFusionPow z 5))))))) +include hr in +private lemma bulkFusionBulkComponent22122 : bulkFusionLeft r z 2 2 1 2 2 = bulkFusionRight r z 2 2 1 2 2 := by + simp [bulkFusionLeft,bulkFusionRight,Fin.sum_univ_three,rNumerator,wNum,qNumerator,-mul_eq_zero] + have hq:=congrArg (fun x : ℂ=>bulkFusionBulkCertificate22122 r z*x) hr + dsimp only [bulkFusionBulkCertificate22122,bulkFusionAdd,bulkFusionMul,bulkFusionPow] at hq + linear_combination hq + +private lemma bulkFusionBulkComponent22200 : bulkFusionLeft r z 2 2 2 0 0 = bulkFusionRight r z 2 2 2 0 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 0 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 0 0 (by decide)] + +private lemma bulkFusionBulkComponent22201 : bulkFusionLeft r z 2 2 2 0 1 = bulkFusionRight r z 2 2 2 0 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 0 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 0 1 (by decide)] + +private lemma bulkFusionBulkComponent22202 : bulkFusionLeft r z 2 2 2 0 2 = bulkFusionRight r z 2 2 2 0 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 0 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 0 2 (by decide)] + +private lemma bulkFusionBulkComponent22210 : bulkFusionLeft r z 2 2 2 1 0 = bulkFusionRight r z 2 2 2 1 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 1 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 1 0 (by decide)] + +private lemma bulkFusionBulkComponent22211 : bulkFusionLeft r z 2 2 2 1 1 = bulkFusionRight r z 2 2 2 1 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 1 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 1 1 (by decide)] + +private lemma bulkFusionBulkComponent22212 : bulkFusionLeft r z 2 2 2 1 2 = bulkFusionRight r z 2 2 2 1 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 1 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 1 2 (by decide)] + +private lemma bulkFusionBulkComponent22220 : bulkFusionLeft r z 2 2 2 2 0 = bulkFusionRight r z 2 2 2 2 0 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 2 0 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 2 0 (by decide)] + +private lemma bulkFusionBulkComponent22221 : bulkFusionLeft r z 2 2 2 2 1 = bulkFusionRight r z 2 2 2 2 1 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 2 1 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 2 1 (by decide)] + +private lemma bulkFusionBulkComponent22222 : bulkFusionLeft r z 2 2 2 2 2 = bulkFusionRight r z 2 2 2 2 2 := by + rw [bulkFusionLeft_eq_zero_of_sum_ne r z 2 2 2 2 2 (by decide), + bulkFusionRight_eq_zero_of_sum_ne r z 2 2 2 2 2 (by decide)] + +include hr in +theorem bulk_fusion_numerator (a b c j k : Fin 3) : bulkFusionLeft r z a b c j k=bulkFusionRight r z a b c j k := by + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases j <;> fin_cases k + · exact bulkFusionBulkComponent00000 r z + · exact bulkFusionBulkComponent00001 r z + · exact bulkFusionBulkComponent00002 r z + · exact bulkFusionBulkComponent00010 r z + · exact bulkFusionBulkComponent00011 r z + · exact bulkFusionBulkComponent00012 r z + · exact bulkFusionBulkComponent00020 r z + · exact bulkFusionBulkComponent00021 r z + · exact bulkFusionBulkComponent00022 r z + · exact bulkFusionBulkComponent00100 r z hr + · exact bulkFusionBulkComponent00101 r z + · exact bulkFusionBulkComponent00102 r z + · exact bulkFusionBulkComponent00110 r z + · exact bulkFusionBulkComponent00111 r z + · exact bulkFusionBulkComponent00112 r z + · exact bulkFusionBulkComponent00120 r z + · exact bulkFusionBulkComponent00121 r z + · exact bulkFusionBulkComponent00122 r z + · exact bulkFusionBulkComponent00200 r z + · exact bulkFusionBulkComponent00201 r z hr + · exact bulkFusionBulkComponent00202 r z + · exact bulkFusionBulkComponent00210 r z hr + · exact bulkFusionBulkComponent00211 r z + · exact bulkFusionBulkComponent00212 r z + · exact bulkFusionBulkComponent00220 r z + · exact bulkFusionBulkComponent00221 r z + · exact bulkFusionBulkComponent00222 r z + · exact bulkFusionBulkComponent01000 r z hr + · exact bulkFusionBulkComponent01001 r z + · exact bulkFusionBulkComponent01002 r z + · exact bulkFusionBulkComponent01010 r z + · exact bulkFusionBulkComponent01011 r z + · exact bulkFusionBulkComponent01012 r z + · exact bulkFusionBulkComponent01020 r z + · exact bulkFusionBulkComponent01021 r z + · exact bulkFusionBulkComponent01022 r z + · exact bulkFusionBulkComponent01100 r z + · exact bulkFusionBulkComponent01101 r z hr + · exact bulkFusionBulkComponent01102 r z + · exact bulkFusionBulkComponent01110 r z hr + · exact bulkFusionBulkComponent01111 r z + · exact bulkFusionBulkComponent01112 r z + · exact bulkFusionBulkComponent01120 r z + · exact bulkFusionBulkComponent01121 r z + · exact bulkFusionBulkComponent01122 r z + · exact bulkFusionBulkComponent01200 r z + · exact bulkFusionBulkComponent01201 r z + · exact bulkFusionBulkComponent01202 r z hr + · exact bulkFusionBulkComponent01210 r z + · exact bulkFusionBulkComponent01211 r z hr + · exact bulkFusionBulkComponent01212 r z + · exact bulkFusionBulkComponent01220 r z hr + · exact bulkFusionBulkComponent01221 r z + · exact bulkFusionBulkComponent01222 r z + · exact bulkFusionBulkComponent02000 r z + · exact bulkFusionBulkComponent02001 r z hr + · exact bulkFusionBulkComponent02002 r z + · exact bulkFusionBulkComponent02010 r z hr + · exact bulkFusionBulkComponent02011 r z + · exact bulkFusionBulkComponent02012 r z + · exact bulkFusionBulkComponent02020 r z + · exact bulkFusionBulkComponent02021 r z + · exact bulkFusionBulkComponent02022 r z + · exact bulkFusionBulkComponent02100 r z + · exact bulkFusionBulkComponent02101 r z + · exact bulkFusionBulkComponent02102 r z hr + · exact bulkFusionBulkComponent02110 r z + · exact bulkFusionBulkComponent02111 r z hr + · exact bulkFusionBulkComponent02112 r z + · exact bulkFusionBulkComponent02120 r z hr + · exact bulkFusionBulkComponent02121 r z + · exact bulkFusionBulkComponent02122 r z + · exact bulkFusionBulkComponent02200 r z + · exact bulkFusionBulkComponent02201 r z + · exact bulkFusionBulkComponent02202 r z + · exact bulkFusionBulkComponent02210 r z + · exact bulkFusionBulkComponent02211 r z + · exact bulkFusionBulkComponent02212 r z hr + · exact bulkFusionBulkComponent02220 r z + · exact bulkFusionBulkComponent02221 r z hr + · exact bulkFusionBulkComponent02222 r z + · exact bulkFusionBulkComponent10000 r z hr + · exact bulkFusionBulkComponent10001 r z + · exact bulkFusionBulkComponent10002 r z + · exact bulkFusionBulkComponent10010 r z + · exact bulkFusionBulkComponent10011 r z + · exact bulkFusionBulkComponent10012 r z + · exact bulkFusionBulkComponent10020 r z + · exact bulkFusionBulkComponent10021 r z + · exact bulkFusionBulkComponent10022 r z + · exact bulkFusionBulkComponent10100 r z + · exact bulkFusionBulkComponent10101 r z hr + · exact bulkFusionBulkComponent10102 r z + · exact bulkFusionBulkComponent10110 r z hr + · exact bulkFusionBulkComponent10111 r z + · exact bulkFusionBulkComponent10112 r z + · exact bulkFusionBulkComponent10120 r z + · exact bulkFusionBulkComponent10121 r z + · exact bulkFusionBulkComponent10122 r z + · exact bulkFusionBulkComponent10200 r z + · exact bulkFusionBulkComponent10201 r z + · exact bulkFusionBulkComponent10202 r z hr + · exact bulkFusionBulkComponent10210 r z + · exact bulkFusionBulkComponent10211 r z hr + · exact bulkFusionBulkComponent10212 r z + · exact bulkFusionBulkComponent10220 r z hr + · exact bulkFusionBulkComponent10221 r z + · exact bulkFusionBulkComponent10222 r z + · exact bulkFusionBulkComponent11000 r z + · exact bulkFusionBulkComponent11001 r z hr + · exact bulkFusionBulkComponent11002 r z + · exact bulkFusionBulkComponent11010 r z hr + · exact bulkFusionBulkComponent11011 r z + · exact bulkFusionBulkComponent11012 r z + · exact bulkFusionBulkComponent11020 r z + · exact bulkFusionBulkComponent11021 r z + · exact bulkFusionBulkComponent11022 r z + · exact bulkFusionBulkComponent11100 r z + · exact bulkFusionBulkComponent11101 r z + · exact bulkFusionBulkComponent11102 r z hr + · exact bulkFusionBulkComponent11110 r z + · exact bulkFusionBulkComponent11111 r z hr + · exact bulkFusionBulkComponent11112 r z + · exact bulkFusionBulkComponent11120 r z hr + · exact bulkFusionBulkComponent11121 r z + · exact bulkFusionBulkComponent11122 r z + · exact bulkFusionBulkComponent11200 r z + · exact bulkFusionBulkComponent11201 r z + · exact bulkFusionBulkComponent11202 r z + · exact bulkFusionBulkComponent11210 r z + · exact bulkFusionBulkComponent11211 r z + · exact bulkFusionBulkComponent11212 r z hr + · exact bulkFusionBulkComponent11220 r z + · exact bulkFusionBulkComponent11221 r z hr + · exact bulkFusionBulkComponent11222 r z + · exact bulkFusionBulkComponent12000 r z + · exact bulkFusionBulkComponent12001 r z + · exact bulkFusionBulkComponent12002 r z hr + · exact bulkFusionBulkComponent12010 r z + · exact bulkFusionBulkComponent12011 r z hr + · exact bulkFusionBulkComponent12012 r z + · exact bulkFusionBulkComponent12020 r z hr + · exact bulkFusionBulkComponent12021 r z + · exact bulkFusionBulkComponent12022 r z + · exact bulkFusionBulkComponent12100 r z + · exact bulkFusionBulkComponent12101 r z + · exact bulkFusionBulkComponent12102 r z + · exact bulkFusionBulkComponent12110 r z + · exact bulkFusionBulkComponent12111 r z + · exact bulkFusionBulkComponent12112 r z hr + · exact bulkFusionBulkComponent12120 r z + · exact bulkFusionBulkComponent12121 r z hr + · exact bulkFusionBulkComponent12122 r z + · exact bulkFusionBulkComponent12200 r z + · exact bulkFusionBulkComponent12201 r z + · exact bulkFusionBulkComponent12202 r z + · exact bulkFusionBulkComponent12210 r z + · exact bulkFusionBulkComponent12211 r z + · exact bulkFusionBulkComponent12212 r z + · exact bulkFusionBulkComponent12220 r z + · exact bulkFusionBulkComponent12221 r z + · exact bulkFusionBulkComponent12222 r z hr + · exact bulkFusionBulkComponent20000 r z + · exact bulkFusionBulkComponent20001 r z hr + · exact bulkFusionBulkComponent20002 r z + · exact bulkFusionBulkComponent20010 r z hr + · exact bulkFusionBulkComponent20011 r z + · exact bulkFusionBulkComponent20012 r z + · exact bulkFusionBulkComponent20020 r z + · exact bulkFusionBulkComponent20021 r z + · exact bulkFusionBulkComponent20022 r z + · exact bulkFusionBulkComponent20100 r z + · exact bulkFusionBulkComponent20101 r z + · exact bulkFusionBulkComponent20102 r z hr + · exact bulkFusionBulkComponent20110 r z + · exact bulkFusionBulkComponent20111 r z hr + · exact bulkFusionBulkComponent20112 r z + · exact bulkFusionBulkComponent20120 r z hr + · exact bulkFusionBulkComponent20121 r z + · exact bulkFusionBulkComponent20122 r z + · exact bulkFusionBulkComponent20200 r z + · exact bulkFusionBulkComponent20201 r z + · exact bulkFusionBulkComponent20202 r z + · exact bulkFusionBulkComponent20210 r z + · exact bulkFusionBulkComponent20211 r z + · exact bulkFusionBulkComponent20212 r z hr + · exact bulkFusionBulkComponent20220 r z + · exact bulkFusionBulkComponent20221 r z hr + · exact bulkFusionBulkComponent20222 r z + · exact bulkFusionBulkComponent21000 r z + · exact bulkFusionBulkComponent21001 r z + · exact bulkFusionBulkComponent21002 r z hr + · exact bulkFusionBulkComponent21010 r z + · exact bulkFusionBulkComponent21011 r z hr + · exact bulkFusionBulkComponent21012 r z + · exact bulkFusionBulkComponent21020 r z hr + · exact bulkFusionBulkComponent21021 r z + · exact bulkFusionBulkComponent21022 r z + · exact bulkFusionBulkComponent21100 r z + · exact bulkFusionBulkComponent21101 r z + · exact bulkFusionBulkComponent21102 r z + · exact bulkFusionBulkComponent21110 r z + · exact bulkFusionBulkComponent21111 r z + · exact bulkFusionBulkComponent21112 r z hr + · exact bulkFusionBulkComponent21120 r z + · exact bulkFusionBulkComponent21121 r z hr + · exact bulkFusionBulkComponent21122 r z + · exact bulkFusionBulkComponent21200 r z + · exact bulkFusionBulkComponent21201 r z + · exact bulkFusionBulkComponent21202 r z + · exact bulkFusionBulkComponent21210 r z + · exact bulkFusionBulkComponent21211 r z + · exact bulkFusionBulkComponent21212 r z + · exact bulkFusionBulkComponent21220 r z + · exact bulkFusionBulkComponent21221 r z + · exact bulkFusionBulkComponent21222 r z hr + · exact bulkFusionBulkComponent22000 r z + · exact bulkFusionBulkComponent22001 r z + · exact bulkFusionBulkComponent22002 r z + · exact bulkFusionBulkComponent22010 r z + · exact bulkFusionBulkComponent22011 r z + · exact bulkFusionBulkComponent22012 r z hr + · exact bulkFusionBulkComponent22020 r z + · exact bulkFusionBulkComponent22021 r z hr + · exact bulkFusionBulkComponent22022 r z + · exact bulkFusionBulkComponent22100 r z + · exact bulkFusionBulkComponent22101 r z + · exact bulkFusionBulkComponent22102 r z + · exact bulkFusionBulkComponent22110 r z + · exact bulkFusionBulkComponent22111 r z + · exact bulkFusionBulkComponent22112 r z + · exact bulkFusionBulkComponent22120 r z + · exact bulkFusionBulkComponent22121 r z + · exact bulkFusionBulkComponent22122 r z hr + · exact bulkFusionBulkComponent22200 r z + · exact bulkFusionBulkComponent22201 r z + · exact bulkFusionBulkComponent22202 r z + · exact bulkFusionBulkComponent22210 r z + · exact bulkFusionBulkComponent22211 r z + · exact bulkFusionBulkComponent22212 r z + · exact bulkFusionBulkComponent22220 r z + · exact bulkFusionBulkComponent22221 r z + · exact bulkFusionBulkComponent22222 r z +end +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/CauchyResidual.lean b/lean/OAI/Combinatorics/HoneycombChords/CauchyResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..9df0a4f2c38b6bade7e22bf79e0432650c66da32 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/CauchyResidual.lean @@ -0,0 +1,495 @@ +import Mathlib + +namespace OAI + +/-! Cauchy interpolation residual formulas and their quantitative integral lower bounds. -/ + +section + + +namespace Honeycomb370 +open Polynomial Finset + +noncomputable def cauchyDen {n : ℕ} (u : Fin n → ℝ) : Polynomial ℝ := + ∏ i, (1-C (u i)*X) +noncomputable def cauchyDenExcept {n : ℕ} (u : Fin n → ℝ) (i : Fin n) : Polynomial ℝ := + ∏ j∈univ.erase i, (1-C (u j)*X) +noncomputable def cauchyNumerator {n : ℕ} (u c : Fin n → ℝ) : Polynomial ℝ := + cauchyDen u - ∑ i,C (c i)*(1-X)*cauchyDenExcept u i + +lemma cauchyDen_eval {n : ℕ} (u : Fin n → ℝ) (v : ℝ) : + (cauchyDen u).eval v=∏ i,(1-u i*v) := by simp [cauchyDen,eval_prod] +lemma cauchyDenExcept_eval {n : ℕ} (u : Fin n → ℝ) (i : Fin n) (v : ℝ) : + (cauchyDenExcept u i).eval v=∏ j∈univ.erase i,(1-u j*v) := by simp [cauchyDenExcept,eval_prod] +lemma cauchyNumerator_one {n : ℕ} (u c : Fin n → ℝ) : + (cauchyNumerator u c).eval 1=∏ i,(1-u i) := by simp [cauchyNumerator,cauchyDen,eval_prod,eval_finsetSum] +lemma cauchyDen_split {n : ℕ} (u : Fin n → ℝ) (i : Fin n) : + cauchyDen u=(1-C (u i)*X)*cauchyDenExcept u i := by + exact (mul_prod_erase _ _ (mem_univ i)).symm +lemma cauchyNumerator_degree {n : ℕ} (u c : Fin n → ℝ) : + (cauchyNumerator u c).natDegree≤n := by + have hlinear (v : ℝ) : (1-C v*X).natDegree≤1 := by + exact (natDegree_sub_le _ _).trans + (max_le (by simp) (natDegree_mul_le.trans (by simp))) + apply (natDegree_sub_le _ _).trans + apply max_le + · exact (natDegree_prod_le _ _).trans (by + calc + _≤∑ i : Fin n,1 := sum_le_sum (fun i _ ↦ hlinear (u i)) + _=n := by simp) + · apply natDegree_sum_le_of_forall_le + intro i hi + have hd : (cauchyDenExcept u i).natDegree≤n-1 := by + unfold cauchyDenExcept + calc + _≤∑ j∈univ.erase i,(1-C (u j)*X : Polynomial ℝ).natDegree := natDegree_prod_le _ _ + (∑ j∈univ.erase i,(1-C (u j)*X : Polynomial ℝ).natDegree)≤∑ j∈univ.erase i,1 := + sum_le_sum (fun j _ ↦ hlinear (u j)) + _=n-1 := by simp + have he : (C (c i)*(1-X)).natDegree≤1 := + natDegree_mul_le.trans (by simpa using (hlinear (1:ℝ))) + exact natDegree_mul_le.trans ((add_le_add he hd).trans (by have := i.isLt; omega)) + + +theorem cauchy_residual_numerator {n : ℕ} (u t c : Fin n → ℝ) + (ht : Function.Injective t) (ht1 : ∀ j,t j≠1) + (horth : ∀ j,(cauchyNumerator u c).eval (t j)=0) : + cauchyNumerator u c = + C ((∏ i,(1-u i))/(∏ j,(1-t j)))*∏ j,(X-C (t j)) := by + have hn : ∏ j,(1-t j)≠0 := prod_ne_zero_iff.mpr (fun j _ ↦ sub_ne_zero.mpr (ht1 j).symm) + apply Polynomial.eq_of_natDegree_lt_card_of_eval_eq (f:=Fin.cons 1 t) + · exact Fin.cons_injective_iff.mpr ⟨by rintro ⟨j,hj⟩; exact ht1 j hj,ht⟩ + · intro j + refine Fin.cases ?_ (fun j ↦ ?_) j + · simp [cauchyNumerator_one,eval_prod,hn] + · rw [Fin.cons_succ,horth j] + have hz : (∏ k : Fin n,(t j-t k))=0 := + prod_eq_zero (mem_univ j) (sub_self _) + simp [eval_prod,hz] + · have hp := cauchyNumerator_degree u c + have hq : (C ((∏ i,(1-u i))/(∏ j,(1-t j)))*∏ j,(X-C (t j))).natDegree≤n := by + apply natDegree_mul_le.trans + simp only [natDegree_C,zero_add] + exact (natDegree_prod_le _ _).trans (by simp) + simpa using (max_le hp hq).trans_lt (Nat.lt_succ_self n) + +end Honeycomb370 + +end + + +section + +namespace Honeycomb370 +open MeasureTheory Set Real Finset + +/-- Negative of the exact Cauchy-model transform residual at v=-s. +The 2N common nodes are not symmetrized with the final distinct F/G nodes. -/ +noncomputable def sechErrorPositive (N : ℕ) (q : Fin (2*N) → ℝ) (u t s : ℝ) : ℝ := + (∏ i,(s+q i)/(1+q i*s)) * ((1-u)*(s+t)/((1-t)*(1+s)*(1+u*s))) + +lemma sechErrorPositive_lower (N : ℕ) (q : Fin (2*N) → ℝ) (u t s : ℝ) + (hq : ∀ i,0 ≤ q i ∧ q i ≤ 1/2) (hu : 0 ≤ u ∧ u ≤ 1/2) (ht : 0 ≤ t ∧ t ≤ 1/2) + (hs : 0 ≤ s ∧ s ≤ 1) : s^(2*N+1)/8 ≤ sechErrorPositive N q u t s := by + have hs0 := hs.1 + have hp i : 0<1+q i*s := by nlinarith [mul_nonneg (hq i).1 hs.1] + have hprod : s^(2*N) ≤ ∏ i : Fin (2*N),(s+q i)/(1+q i*s) := by + rw [show s^(2*N) = ∏ i : Fin (2*N),s by simp] + apply Finset.prod_le_prod₀ (fun _ _ ↦ hs.1) + intro i _ + apply (le_div_iff₀ (hp i)).mpr + have hss : s^2 ≤ 1 := by nlinarith + nlinarith [mul_le_mul_of_nonneg_left hss (hq i).1] + have htpos : 0<1-t := by linarith + have hup : 0<1+u*s := by nlinarith [mul_nonneg hu.1 hs.1] + have hden : 0<(1-t)*(1+s)*(1+u*s) := by positivity + have hden4 : (1-t)*(1+s)*(1+u*s) ≤ 4 := by + have ha : (1-t)*(1+s) ≤ 2 := calc + _ ≤ 1*(1+s) := mul_le_mul_of_nonneg_right (by linarith) (by linarith) + _ ≤ 2 := by linarith + have hb : 1+u*s ≤ 2 := by nlinarith [mul_le_mul_of_nonneg_left hs.2 hu.1] + nlinarith + have hl : s/8 ≤ (1-u)*(s+t)/((1-t)*(1+s)*(1+u*s)) := by + apply (le_div_iff₀ hden).mpr + have hn : s/2 ≤ (1-u)*(s+t) := by + have hh:=mul_le_mul (show (1:ℝ)/2 ≤ 1-u by linarith) (show s ≤ s+t by linarith) + hs.1 (show 0 ≤ 1-u by linarith) + linarith + nlinarith [mul_le_mul_of_nonneg_left hden4 hs.1] + have hm:=mul_le_mul hprod hl (by positivity : 0 ≤ s/8) + (Finset.prod_nonneg (fun i _ ↦ div_nonneg (by linarith [(hq i).1]) (hp i).le)) + simpa [sechErrorPositive,pow_succ,mul_div_assoc] using hm + +lemma cauchy_scale_power_lower (N : ℕ) {p : ℝ} (hp : 2*Real.sqrt ((N:ℝ)+1) ≤ p) : + (1:ℝ)/2 ≤ (p^2/(1+p^2))^(2*N+1) := by + have hN : 0<(N:ℝ)+1 := by positivity + have hs:=Real.sq_sqrt hN.le + have hp0 : 0 ≤ p := (by positivity : (0:ℝ) ≤ 2*Real.sqrt ((N:ℝ)+1)).trans hp + have hps : 4*((N:ℝ)+1) ≤ p^2 := by + nlinarith [sq_le_sq₀ (by positivity : (0:ℝ) ≤ 2*Real.sqrt ((N:ℝ)+1)) hp0 |>.mpr hp] + have hd : 0<1+p^2 := by positivity + have hi : (1/(1+p^2):ℝ) ≤ 1 := (div_le_one hd).mpr (by nlinarith [sq_nonneg p]) + have hb := one_add_mul_le_pow (a := -(1/(1+p^2):ℝ)) (by linarith) (2*N+1) + have he : 1+ -(1/(1+p^2):ℝ)=p^2/(1+p^2) := by field_simp; ring + rw [he] at hb + have hc : ((2*N+1:ℕ):ℝ)/(1+p^2) ≤ 1/2 := by + apply (div_le_iff₀ hd).mpr + push_cast + nlinarith + push_cast at hb hc + rw [div_eq_mul_inv] at hc + simp only [one_div,mul_neg] at hb + linarith + +lemma sechErrorPositive_tail_lower (N : ℕ) (q : Fin (2*N) → ℝ) (u t : ℝ) + (hq : ∀ i,0 ≤ q i ∧ q i ≤ 1/2) (hu : 0 ≤ u ∧ u ≤ 1/2) (ht : 0 ≤ t ∧ t ≤ 1/2) + {p : ℝ} (hp : 2*Real.sqrt ((N:ℝ)+1) ≤ p) : + (1:ℝ)/16 ≤ sechErrorPositive N q u t (p^2/(1+p^2)) := by + have hd : 0<1+p^2 := by positivity + have hn:=sechErrorPositive_lower N q u t (p^2/(1+p^2)) hq hu ht + ⟨by positivity,(div_le_one hd).mpr (by linarith)⟩ + have he:=cauchy_scale_power_lower N hp + linarith + +end Honeycomb370 + +end + + +section + +namespace Honeycomb370 +open MeasureTheory Set Real + +noncomputable def cauchyEvalFunctional (f : ℝ → ℝ) : ℝ := + (2/Real.pi)*(∫ p in Set.Ioi (0:ℝ),f (-p^2/(1+p^2))/(1+p^2)) + +lemma cauchy_boundary_identity (u p : ℝ) (hu : 0 ≤ u) : + (1/(1-u*(-p^2/(1+p^2))))/(1+p^2)=1/(1+(1+u)*p^2) := by + have h₁ : 0<1+p^2 := by positivity + have h₂ : 0<1+(1+u)*p^2 := by positivity + have hh : 1-u*(-p^2/(1+p^2))=(1+(1+u)*p^2)/(1+p^2) := by + field_simp + ring + rw [hh] + field_simp + + +lemma cauchy_quadratic_integrable (u : ℝ) (hu : 0 ≤ u) : + Integrable (fun p : ℝ ↦ 1/(1+(1+u)*p^2)) := by + apply integrable_inv_one_add_sq.mono' + · exact (continuous_const.div (continuous_const.add + (continuous_const.mul (continuous_id.pow 2))) + (fun p ↦ ne_of_gt (by positivity : (0:ℝ)<1+(1+u)*p^2))).aestronglyMeasurable + · exact Filter.Eventually.of_forall (fun p ↦ by + rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)] + rw [←one_div] + apply one_div_le_one_div_of_le (by positivity) + nlinarith [mul_nonneg hu (sq_nonneg p)]) + +lemma cauchyEval_on_kernel (u : ℝ) (hu : 0 ≤ u) : + cauchyEvalFunctional (fun v ↦ 1/(1-u*v))=1/Real.sqrt (1+u) := by + have hs : 0.mpr hp.2 + dsimp [b] at hh + nlinarith + have hd : 0<1+p^2 := by positivity + have hN : 0<(N:ℝ)+1 := by positivity + dsimp [sechErrorIntegrand] + apply (le_div_iff₀ hd).mpr + have hr : (1+p^2)/(272*((N:ℝ)+1)) ≤ 1/16 := by + apply (div_le_iff₀ (by positivity)).mpr + nlinarith [Nat.cast_nonneg (α:=ℝ) N] + simpa only [div_eq_mul_inv, one_mul, mul_comm] using hr.trans hl + have hmono : (∫ p in Set.Icc a b,(1/(272*((N:ℝ)+1)):ℝ)) ≤ + ∫ p in Set.Icc a b,sechErrorIntegrand N q u t p := by + apply integral_mono_ae (integrable_const _) (hi.mono_set hsub) + filter_upwards [ae_restrict_mem measurableSet_Icc] with p hp + exact hpoint p hp + have hinc : (∫ p in Set.Icc a b,sechErrorIntegrand N q u t p) ≤ + ∫ p in Set.Ioi (0:ℝ),sechErrorIntegrand N q u t p := + setIntegral_mono_set hi (Filter.Eventually.of_forall hnon) (Filter.Eventually.of_forall hsub) + have he : (∫ p in Set.Icc a b,(1/(272*((N:ℝ)+1)):ℝ))=1/(136*Real.sqrt ((N:ℝ)+1)) := by + rw [setIntegral_const,Real.volume_real_Icc_of_le hab] + dsimp [a,b] + field_simp + nlinarith [hsq] + rw [he] at hmono + exact hmono.trans hinc + +end Honeycomb370 + +end + + +section + +namespace Honeycomb370 +open Polynomial Finset MeasureTheory Set + +noncomputable def cauchyResidual {n : ℕ} (u c : Fin n → ℝ) (v : ℝ) : ℝ := + 1/(1-v)-∑ i,c i/(1-u i*v) + +lemma cauchyResidual_fraction {n : ℕ} (u c : Fin n → ℝ) (v : ℝ) + (hv : v≠1) (hu : ∀ i,1-u i*v≠0) : + cauchyResidual u c v=(cauchyNumerator u c).eval v/((1-v)*(cauchyDen u).eval v) := by + have hd : (cauchyDen u).eval v≠0 := by rw [cauchyDen_eval]; exact prod_ne_zero_iff.mpr (fun i _ ↦ hu i) + have he (i : Fin n) : (cauchyDen u).eval v=(1-u i*v)*(cauchyDenExcept u i).eval v := by + rw [cauchyDen_split u i,eval_mul,eval_sub,eval_one,eval_mul,eval_C,eval_X] + have ht (i : Fin n) : c i/(1-u i*v)*((1-v)*(cauchyDen u).eval v)= + c i*(1-v)*(cauchyDenExcept u i).eval v := by + rw [he i] + field_simp [hu i] + apply (eq_div_iff (mul_ne_zero (sub_ne_zero.mpr hv.symm) hd)).mpr + unfold cauchyResidual cauchyNumerator + rw [eval_sub,eval_finsetSum,sub_mul,Finset.sum_mul] + simp only [eval_mul,eval_C,eval_sub,eval_one,eval_X] + simp_rw [ht] + rw [←mul_assoc,one_div_mul_cancel (sub_ne_zero.mpr hv.symm),one_mul] + +lemma cauchyNumerator_zero_of_orth {n : ℕ} (u c : Fin n → ℝ) (v : ℝ) + (hv : v≠1) (hu : ∀ i,1-u i*v≠0) (ho : 1/(1-v)=∑ i,c i/(1-u i*v)) : + (cauchyNumerator u c).eval v=0 := by + have h:=cauchyResidual_fraction u c v hv hu + have hz : cauchyResidual u c v=0 := sub_eq_zero.mpr ho + rw [hz] at h + exact (div_eq_zero_iff.mp h.symm).resolve_right (by + rw [cauchyDen_eval] + exact mul_ne_zero (sub_ne_zero.mpr hv.symm) (prod_ne_zero_iff.mpr (fun i _ ↦ hu i))) + +lemma cauchyResidual_product {n : ℕ} (u t c : Fin n → ℝ) + (ht : Function.Injective t) (ht1 : ∀ j,t j≠1) + (horth : ∀ j,1/(1-t j)=∑ i,c i/(1-u i*t j)) + (hut : ∀ i j,1-u i*t j≠0) (v : ℝ) (hv : v≠1) (huv : ∀ i,1-u i*v≠0) : + cauchyResidual u c v=((∏ i,(1-u i))/(∏ j,(1-t j)))*(∏ j,(v-t j))/ + ((1-v)*(∏ i,(1-u i*v))) := by + rw [cauchyResidual_fraction u c v hv huv,cauchyDen_eval, + cauchy_residual_numerator u t c ht ht1 (fun j ↦ cauchyNumerator_zero_of_orth u c (t j) (ht1 j) (fun i ↦ hut i j) (horth j))] + simp [eval_prod] + +lemma cauchyResidual_common_negative (N : ℕ) (q : Fin (2*N) → ℝ) (u t : ℝ) + (c : Fin (2*N+1) → ℝ) (hq : ∀ i,0≤q i ∧ q i≤1/2) (hu : 0≤u ∧ u≤1/2) + (ht : 0≤t ∧ t≤1/2) (hinj : Function.Injective (Fin.lastCases t q)) + (horth : ∀ j,1/(1-Fin.lastCases t q j)= + ∑ i,c i/(1-Fin.lastCases u q i*Fin.lastCases t q j)) + (s : ℝ) (hs : 0 ≤ s) : + cauchyResidual (Fin.lastCases u q) c (-s) = -sechErrorPositive N q u t s := by + have hbU (i : Fin (2*N+1)) : (0:ℝ)≤Fin.lastCases u q i ∧ (Fin.lastCases u q i:ℝ)≤1/2 := by + refine Fin.lastCases ?_ (fun j ↦ ?_) i + · simpa using hu + · simpa using hq j + have hbT (i : Fin (2*N+1)) : (0:ℝ)≤Fin.lastCases t q i ∧ (Fin.lastCases t q i:ℝ)≤1/2 := by + refine Fin.lastCases ?_ (fun j ↦ ?_) i + · simpa using ht + · simpa using hq j + have hd (i j : Fin (2*N+1)) : (1:ℝ)-Fin.lastCases u q i*Fin.lastCases t q j≠0 := by + have hh:=mul_le_mul (hbU i).2 (hbT j).2 (hbT j).1 (by norm_num : (0:ℝ)≤1/2) + nlinarith + rw [cauchyResidual_product _ _ _ hinj (fun j ↦ by linarith [(hbT j).2]) horth hd (-s) + (by linarith) (fun i ↦ by have hh:=mul_nonneg (hbU i).1 hs; nlinarith)] + simp only [Fin.prod_univ_castSucc,Fin.lastCases_last,Fin.lastCases_castSucc] + have hprod : (∏ i : Fin (2*N),(-s-q i))=∏ i : Fin (2*N),(s+q i) := by + simp_rw [show ∀ i : Fin (2*N),-s-q i= -(s+q i) by intro i; ring] + rw [prod_neg] + simp [Even.neg_pow (even_two_mul N)] + have hq0 : ∏ i : Fin (2*N),(1-q i)≠0 := prod_ne_zero_iff.mpr (fun i _ ↦ by linarith [(hq i).2]) + have hqS : ∏ i : Fin (2*N),(1+q i*s)≠0 := prod_ne_zero_iff.mpr (fun i _ ↦ ne_of_gt (by + have hqi:=(hq i).1; positivity)) + have ht0 : 1-t≠0 := by linarith [ht.2] + have huS : 1+u*s≠0 := ne_of_gt (by have hu0:=hu.1; positivity) + have hs1 : 1+s≠0 := ne_of_gt (by positivity) + rw [hprod] + simp only [mul_neg,sub_neg_eq_add] + unfold sechErrorPositive + rw [prod_div_distrib] + field_simp + ring + +end Honeycomb370 + +end + + +section + +namespace Honeycomb370 +open MeasureTheory Set Real Finset + +lemma cauchyResidual_eval {n : ℕ} (u c : Fin n → ℝ) (hu : ∀ i,0 ≤ u i) : + cauchyEvalFunctional (cauchyResidual u c)= + 1/Real.sqrt 2-∑ i,c i/Real.sqrt (1+u i) := by + have hi (v : ℝ) (hv : 0 ≤ v) : IntegrableOn + (fun p : ℝ ↦ (1/(1-v*(-p^2/(1+p^2))))/(1+p^2)) (Set.Ioi 0) := by + simp_rw [cauchy_boundary_identity v _ hv] + exact (cauchy_quadratic_integrable v hv).integrableOn + have he (p : ℝ) : cauchyResidual u c (-p^2/(1+p^2))/(1+p^2)= + (1/(1-(1:ℝ)*(-p^2/(1+p^2))))/(1+p^2)- + ∑ i,c i*((1/(1-u i*(-p^2/(1+p^2))))/(1+p^2)) := by + unfold cauchyResidual + rw [sub_div,Finset.sum_div] + simp only [one_mul] + congr 1 + apply Finset.sum_congr rfl + intro i _ + ring + unfold cauchyEvalFunctional + simp_rw [he] + rw [integral_sub (hi 1 zero_le_one) (integrable_finsetSum _ (fun i _ ↦ (hi (u i) (hu i)).const_mul (c i))), + integral_finsetSum _ (fun i _ ↦ (hi (u i) (hu i)).const_mul (c i)),mul_sub,Finset.mul_sum] + simp_rw [integral_const_mul] + have ht:=cauchyEval_on_kernel 1 zero_le_one + have hf (i : Fin n):=cauchyEval_on_kernel (u i) (hu i) + change (2/Real.pi)*_-(∑ i,(2/Real.pi)*(c i*_))=_ + simp only [mul_left_comm (2/Real.pi) (c _)] + change cauchyEvalFunctional (fun v ↦ 1/(1-(1:ℝ)*v))- + (∑ i,c i*cauchyEvalFunctional (fun v ↦ 1/(1-u i*v)))=_ + rw [ht] + simp_rw [hf] + norm_num + ring_nf + +/-- Quantitative evaluation at zero of the exact nonsymmetric Cauchy residual. -/ +theorem cauchyResidual_zero_lower (N : ℕ) (q : Fin (2*N) → ℝ) (u t : ℝ) + (c : Fin (2*N+1) → ℝ) (hq : ∀ i,0≤q i ∧ q i≤1/2) (hu : 0≤u ∧ u≤1/2) + (ht : 0≤t ∧ t≤1/2) (hinj : Function.Injective (Fin.lastCases t q)) + (horth : ∀ j,1/(1-Fin.lastCases t q j)= + ∑ i,c i/(1-Fin.lastCases u q i*Fin.lastCases t q j)) : + 1/(68*Real.pi*Real.sqrt ((N:ℝ)+1)) ≤ + -(1/Real.sqrt 2-∑ i,c i/Real.sqrt (1+Fin.lastCases u q i)) := by + have hb (i : Fin (2*N+1)) : (0:ℝ)≤Fin.lastCases u q i := by + refine Fin.lastCases ?_ (fun j ↦ ?_) i <;> simp [hu.1,(hq _).1] + rw [←cauchyResidual_eval _ c hb] + have he (p : ℝ) : cauchyResidual (Fin.lastCases u q) c (-p^2/(1+p^2))/(1+p^2)= + -sechErrorIntegrand N q u t p := by + rw [neg_div,cauchyResidual_common_negative N q u t c hq hu ht hinj horth _ (by positivity)] + simp only [sechErrorIntegrand,neg_div] + unfold cauchyEvalFunctional + simp_rw [he] + rw [integral_neg,mul_neg,neg_neg] + have hh:=mul_le_mul_of_nonneg_left (sechModel_integral_lower N q u t hq hu ht) + (show 0 ≤ 2/Real.pi by positivity) + have hec : (2/Real.pi)*(1/(136*Real.sqrt ((N:ℝ)+1)))= + 1/(68*Real.pi*Real.sqrt ((N:ℝ)+1)) := by ring + rwa [hec] at hh + +end Honeycomb370 + +end + + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/CharacteristicProducts.lean b/lean/OAI/Combinatorics/HoneycombChords/CharacteristicProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab01c749fdee471e06637d1b5347bfc67a53e648 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/CharacteristicProducts.lean @@ -0,0 +1,725 @@ +import OAI.Combinatorics.HoneycombChords.JetCompression + +namespace OAI + +/-! +# Oblique characteristic product estimates + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +lemma positive_ratio_reversal {S Q l:ℝ} (hS:0twoKnot_monotone N hij) (fun i=>twoKnot_nonneg N i) (fun i=>twoKnot_le N i) + have hB : (B.submatrix Fin.castSucc Fin.castSucc).PosDef := by + rw [show B=reorderedKnotGram N s t z from rfl,reorderedKnotGram_corner N hs hsL ht htL] + exact pole_jetGram_posDef _ hz (fun _ _ hij=>twoKnot_monotone N hij) (fun i=>twoKnot_nonneg N i) (fun i=>twoKnot_le N i) + have h0 : 0twoKnot_monotone N hij) (fun _ _ hij=>twoKnot_monotone N hij) + (fun i=>twoKnot_nonneg N i) (fun i=>twoKnot_nonneg N i) + (fun i=>(twoKnot_le N i).trans (by nlinarith [sq_nonneg angle])) (fun i=>twoKnot_le N i) + have hQdet (u:ℝ):0<(jetPencil (n:=2*N+1) (poleAdjustedDensity z) (interiorKnotLabels N s) (interiorKnotLabels N t) (-(u^2))).det:=by + have hh:=reorderedKnotPencil_det_pos_nonpos N hs hsL ht htL hz (neg_nonpos.mpr (sq_nonneg u)) + simpa only [reorderedKnotPencil,Matrix.det_submatrix_equiv_self] using hh + have hS:0characteristicRatio y z p*stripDensity p) (twoJetFamily N) (twoJetFamily N)).det / + (familyGram stripDensity (twoJetFamily N) (twoJetFamily N)).det ∧ + (familyGram (fun p=>characteristicRatio y z p*stripDensity p) (twoJetFamily N) (twoJetFamily N)).det / + (familyGram stripDensity (twoJetFamily N) (twoJetFamily N)).det≤A*((N:ℝ)+1)^(3*(y-z)/8) := by + obtain ⟨C,hC,hcomp⟩:=twoJetPolynomialCompression + obtain ⟨a,A,ha,hA,hpoly⟩:=strip_polynomial_characteristic_product_bounds hy (hy.trans hyz) + obtain ⟨N₀,hN₀⟩:=eventually_atTop.mp hpoly + let s:ℝ:=3*(y-z)/8 + have hs:s≤0:=by dsimp [s];linarith + have hc0:0<(C:ℝ)+1:=by positivity + refine ⟨a*((C:ℝ)+1)^s/4,A,by positivity,hA,?_⟩ + filter_upwards [hcomp y z hy hyz,eventually_ge_atTop N₀] with N hn hN + have hle:N≤C*N:=by nlinarith + have hCN:=hN₀ (C*N) (hN.trans hle) + have hNN:=hN₀ N hN + have hscale:((C:ℝ)+1)^s*((N:ℝ)+1)^s≤((C*N:ℕ)+1:ℝ)^s:=by + rw [←Real.mul_rpow hc0.le (by positivity)] + apply Real.rpow_le_rpow_of_nonpos (by positivity) _ hs + simp only [Nat.cast_mul] + nlinarith [Nat.cast_nonneg (α:=ℝ) C,Nat.cast_nonneg (α:=ℝ) N] + constructor + · calc + (a*((C:ℝ)+1)^s/4)*((N:ℝ)+1)^s=(a/4)*(((C:ℝ)+1)^s*((N:ℝ)+1)^s):=by ring + _≤(a/4)*((C*N:ℕ)+1:ℝ)^s:=mul_le_mul_of_nonneg_left hscale (by positivity) + _≤(monomialGram (C*N) (fun p=>characteristicRatio y z p*stripDensity p)).det/(monomialGram (C*N) stripDensity).det/4:=by + dsimp only [s] + linarith [hCN.1] + _≤_:=hn.1 + · exact hn.2.trans hNN.2 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology +lemma polePencil_characteristic_gram {n:ℕ} (b c:ℕ→ℝ) (y z:ℝ) : + jetPencil (n:=n) (poleAdjustedDensity z) b c (-(y^2))= + jetGram (fun p=>characteristicRatio y z p*stripDensity p) b c := by + ext i j + apply integral_congr_ae + filter_upwards with p + dsimp only [jetPencil,jetGram,poleAdjustedDensity,characteristicRatio] + ring +lemma polePencil_original_gram {n:ℕ} (b c:ℕ→ℝ) {z:ℝ} (hz:0characteristicRatio y z p*stripDensity p) + (interiorKnotLabels N s) (interiorKnotLabels N t)).det / + (jetGram (n:=2*N+1) stripDensity (interiorKnotLabels N s) (interiorKnotLabels N t)).det ∧ + (jetGram (n:=2*N+1) (fun p=>characteristicRatio y z p*stripDensity p) + (interiorKnotLabels N s) (interiorKnotLabels N t)).det / + (jetGram (n:=2*N+1) stripDensity (interiorKnotLabels N s) (interiorKnotLabels N t)).det≤ + A*((N:ℝ)+1)^(3*(y-z)/8) := by + obtain ⟨a,A,ha,hA,hbounds⟩:=twoJet_characteristic_bounds hy hyz + have hz:=hy.trans hyz + have hl:0characteristicRatio y z p*stripDensity p) (twoKnotLabels N) (twoKnotLabels N)).det/ + (jetGram (n:=2*N) stripDensity (twoKnotLabels N) (twoKnotLabels N)).det ∧ _ at hN + constructor + · calc + ((y^2/z^2)*a)*((N:ℝ)+1)^(3*(y-z)/8)=(y^2/z^2)*(a*((N:ℝ)+1)^(3*(y-z)/8)):=by ring + _≤_:=mul_le_mul_of_nonneg_left hN.1 hl.le + _≤_:=h.1 + · exact h.2.trans hN.2 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology +lemma polynomial_characteristic_le_one_square (n:ℕ) {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p)).det/(monomialGram n stripDensity).det ≤ + 1+(monomialGram n (fun p=>characteristicRatio y z p^2*stripDensity p)).det/(monomialGram n stripDensity).det := by + have hB:0<(monomialGram n stripDensity).det:= + (monomialGram_posDef n _ (fun _ hp=>stripDensity_pos hp) stripDensity_moments).det_pos + have hcs:=monomialGram_tilt_square n stripDensity (characteristicRatio y z) + (fun _ hp=>stripDensity_pos hp) stripDensity_moments + (by simpa only [pow_one] using characteristic_tilt_moments hy hz 1) + (characteristic_tilt_moments hy hz 2) + have hsq: + ((monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det/(monomialGram n stripDensity).det)^2 ≤ + (monomialGram n (fun p=>characteristicRatio y z p^2*stripDensity p)).det/(monomialGram n stripDensity).det:=by + rw [div_pow] + have hh:=div_le_div_of_nonneg_right hcs (sq_nonneg (monomialGram n stripDensity).det) + exact hh.trans_eq (by field_simp [hB.ne']) + nlinarith [sq_nonneg ((monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det/(monomialGram n stripDensity).det-1)] +/-- A uniform subexponential characteristic bound for the first nonsymmetric family at the moving scale `y² = 2z² = 2N^(3/2)`. -/ +theorem first_oblique_growing_product_bound : + ∃ D:ℕ,0characteristicRatio y z p*stripDensity p) + (interiorKnotLabels N s) (interiorKnotLabels N t)).det / + (jetGram (n:=2*N+1) stripDensity (interiorKnotLabels N s) (interiorKnotLabels N t)).det ≤ + 8*(1+C*z^4*((D*N:ℕ)+1:ℝ)^3*(4*((D*N:ℕ)+1:ℝ))^(2*c*y/Real.pi+1)) := by + obtain ⟨D,hD,htwo⟩:=twoJet_polynomial_expansion_uniform + obtain ⟨c,C,hc,hC,hpoly⟩:=strip_polynomial_square_product_uniform + refine ⟨D,hD,c,C,hc,hC,?_⟩ + filter_upwards [htwo] with N hN + intro y z hz hzy hyz hs s t hss hsL ht htL + have hz0:0characteristicRatio y z p*stripDensity p) (twoJetFamily N) (twoJetFamily N)= + jetGram (n:=2*N) (fun p=>characteristicRatio y z p*stripDensity p) (twoKnotLabels N) (twoKnotLabels N):=rfl + have he_base:familyGram stripDensity (twoJetFamily N) (twoJetFamily N)= + jetGram (n:=2*N) stripDensity (twoKnotLabels N) (twoKnotLabels N):=rfl + rw [he_tilt,he_base] at hj + have hJpos:0≤(jetGram (n:=2*N) (fun p=>characteristicRatio y z p*stripDensity p) (twoKnotLabels N) (twoKnotLabels N)).det / + (jetGram (n:=2*N) stripDensity (twoKnotLabels N) (twoKnotLabels N)).det:= + (div_pos (twoJetFamily_tilt_posDef N hy0 hz0).det_pos (twoJetFamily_posDef N).det_pos).le + have hratio:y^2/z^2≤2:=(div_le_iff₀ (by positivity)).mpr (by nlinarith) + have ho:=(polynomial_characteristic_le_one_square (D*N) hy0 hz0).trans + (show 1 + _ ≤ 1 + C*z^4*((D*N:ℕ)+1:ℝ)^3*(4*((D*N:ℕ)+1:ℝ))^(2*c*y/Real.pi+1) by + linarith [hpoly y z hz hs (D*N)]) + have htop:=h.2.trans (mul_le_mul_of_nonneg_right hratio hJpos) + have htop':=htop.trans (mul_le_mul_of_nonneg_left hj (by norm_num : (0:ℝ)≤2)) + have hfinal:=mul_le_mul_of_nonneg_left ho (by norm_num : (0:ℝ)≤8) + calc + _≤2*(4*((monomialGram (D*N) (fun p=>characteristicRatio y z p*stripDensity p)).det / + (monomialGram (D*N) stripDensity).det)):=htop' + _=8*((monomialGram (D*N) (fun p=>characteristicRatio y z p*stripDensity p)).det / + (monomialGram (D*N) stripDensity).det):=by ring + _≤_:=hfinal +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +noncomputable def zeroJetMatrix (n:ℕ) (b:ℕ→ℝ) : Matrix (Fin n) (Fin (n+1)) ℝ := + fun i=>Fin.cons (-cosineKernelJet (nodalOrder b (i.val+1)) 0 (b (i.val+1)) 0) (Pi.single i 1) +lemma zeroJetMatrix_representation (n:ℕ) (b:ℕ→ℝ) (hb:b 0=0) (i:Fin n) : + finiteFamilyCombination (fun j:Fin (n+1)=>cosineKernelJet (nodalOrder b j) 0 (b j)) (zeroJetMatrix n b i)=zeroJet b i := by + funext x + dsimp only [finiteFamilyCombination,zeroJetMatrix] + rw [Fin.sum_univ_succ] + simp only [Fin.cons_zero,Fin.cons_succ,Fin.val_zero,Fin.val_succ,jet_first_constant b hb,mul_one] + simp [Pi.single_apply,zeroJet,sub_eq_add_neg,add_comm] +lemma zeroJetMatrix_transpose_injective (n:ℕ) (b:ℕ→ℝ) : + Function.Injective (zeroJetMatrix n b)ᵀ.mulVec := by + intro u v huv + funext i + have h:=congrFun huv i.succ + simpa [Matrix.mulVec,dotProduct,zeroJetMatrix,Pi.single_apply] using h +lemma zeroJet_gram_compression (n:ℕ) (b:ℕ→ℝ) (hb:b 0=0) (w:ℝ→ℝ) + (hi:∀ i j:Fin (n+1),IntegrableOn (fun p=> + cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)*cosineKernelJet (nodalOrder b j) 0 (b j) (p^2)*w p) (Set.Ioi 0)) : + familyGram w (fun i:Fin n=>zeroJet b i) (fun i:Fin n=>zeroJet b i)= + zeroJetMatrix n b*jetGram (n:=n+1) w b b*(zeroJetMatrix n b)ᵀ := by + have h:=familyGram_congruence w (fun i:Fin (n+1)=>cosineKernelJet (nodalOrder b i) 0 (b i)) hi (zeroJetMatrix n b) + simp only [zeroJetMatrix_representation n b hb] at h + have hJ:familyGram w (fun i:Fin (n+1)=>cosineKernelJet (nodalOrder b i) 0 (b i)) + (fun i:Fin (n+1)=>cosineKernelJet (nodalOrder b i) 0 (b i))=jetGram (n:=n+1) w b b:=rfl + rw [hJ] at h + exact h +lemma familyGram_tilt_lower {n:ℕ} (F:Fin n→ℝ→ℝ) + (hF:∀ i,F i∈stripKernelSpan (angle^2)) {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p) F F *ᵥ v) := by + have hz:=hy.trans hyz + have hle:y^2/z^2≤1:=by apply (div_le_one (by positivity)).mpr;nlinarith + rw [familyGram_quad _ F (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y hz), + familyGram_quad _ F (fun i j=>stripSpan_actual_pair (hF i) (hF j))] + have hf:=finiteFamilyCombination_mem_stripSpan hF v + apply (familySquaredNorm_weight_bounds stripDensity (characteristicRatio y z) (finiteFamilyCombination F v) + (fun _ hp=>(stripDensity_pos hp).le) (fun p _=>by simpa only [min_eq_right hle,max_eq_left hle] using characteristicRatio_bounds y hz p) + (by simpa only [pow_two] using stripSpan_actual_pair hf hf) + (by simpa only [pow_two] using stripSpan_tilt_pair hf hf y hz)).1 +/-- Removing the evaluation-at-zero direction changes the characteristic +quotient by at most its single uniform eigenvalue bound. -/ +theorem zeroJet_characteristic_sandwich {m N:ℕ} (hm:m+1=2*N) (hN:0characteristicRatio y z p*stripDensity p + let J:=(jetGram (n:=2*N) w (twoKnotLabels N) (twoKnotLabels N)).det/ + (jetGram (n:=2*N) stripDensity (twoKnotLabels N) (twoKnotLabels N)).det + let U:=(familyGram w (fun i:Fin m=>zeroJet (twoKnotLabels N) i) (fun i:Fin m=>zeroJet (twoKnotLabels N) i)).det/ + (familyGram stripDensity (fun i:Fin m=>zeroJet (twoKnotLabels N) i) (fun i:Fin m=>zeroJet (twoKnotLabels N) i)).det + J≤U ∧ (y^2/z^2)*U≤J := by + classical + dsimp only + let b:=twoKnotLabels N + let F:=fun i:Fin (m+1)=>cosineKernelJet (nodalOrder b i) 0 (b i) + let w:=fun p=>characteristicRatio y z p*stripDensity p + let C:=zeroJetMatrix m b + have hb:b 0=0:=twoKnot_first N hN + have hF i:F i∈stripKernelSpan (angle^2):=kernel_mem_stripSpan (twoKnot_nonneg N i) (twoKnot_le N i) _ + have hB:(jetGram (n:=m+1) stripDensity b b).PosDef:=by + rw [hm] + exact twoJetFamily_posDef N + have hA:(jetGram (n:=m+1) w b b).PosDef:=by + rw [hm] + exact twoJetFamily_tilt_posDef N hy (hy.trans hyz) + have hCB:(C*jetGram (n:=m+1) stripDensity b b*Cᵀ).PosDef:=by + simpa only [Matrix.conjTranspose_eq_transpose_of_trivial,Matrix.transpose_transpose] using + hB.conjTranspose_mul_mul_same (zeroJetMatrix_transpose_injective m b) + have hCa:=zeroJet_gram_compression m b hb w (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y (hy.trans hyz)) + have hCb:=zeroJet_gram_compression m b hb stripDensity (fun i j=>stripSpan_actual_pair (hF i) (hF j)) + have h1:=positive_contraction_compression _ _ C hA hB hCB (familyGram_tilt_contraction F hF hy hyz) + have h2:=positive_compression_codimension _ _ C hA hB hCB (show 0≤y^2/z^2 by positivity) (familyGram_tilt_lower F hF hy hyz) + change _≤(zeroJetMatrix m b*jetGram (n:=m+1) w b b*(zeroJetMatrix m b)ᵀ).det/ + (zeroJetMatrix m b*jetGram (n:=m+1) stripDensity b b*(zeroJetMatrix m b)ᵀ).det at h1 + change (y^2/z^2)^((m+1)-m)*((zeroJetMatrix m b*jetGram (n:=m+1) w b b*(zeroJetMatrix m b)ᵀ).det/ + (zeroJetMatrix m b*jetGram (n:=m+1) stripDensity b b*(zeroJetMatrix m b)ᵀ).det)≤_ at h2 + rw [←hCa,←hCb,hm] at h1 + rw [←hCa,←hCb,Nat.add_sub_cancel_left,pow_one,hm] at h2 + exact ⟨h1,h2⟩ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology +lemma poleZeroPencil_characteristic_gram {n:ℕ} (b c:ℕ→ℝ) (y z:ℝ) : + zeroJetPencil (n:=n) (poleAdjustedDensity z) b c (-(y^2))= + familyGram (fun p=>characteristicRatio y z p*stripDensity p) (fun i:Fin n=>zeroJet b i) (fun i:Fin n=>zeroJet c i) := by + ext i j + apply integral_congr_ae + filter_upwards with p + dsimp only [zeroJetPencil,familyGram,poleAdjustedDensity,characteristicRatio] + ring +lemma poleZeroPencil_original_gram {n:ℕ} (b c:ℕ→ℝ) {z:ℝ} (hz:0zeroJet b i) (fun i:Fin n=>zeroJet c i) := by + rw [poleZeroPencil_characteristic_gram] + congr 1 + funext p + have hd:(p^2+z^2)≠0:=by positivity + simp only [characteristicRatio,div_self hd,one_mul] +lemma poleMixedZeroPencil_characteristic_gram {n:ℕ} (b c:ℕ→ℝ) (y z:ℝ) : + mixedZeroJetPencil (n:=n) (poleAdjustedDensity z) b c (-(y^2))= + familyGram (fun p=>characteristicRatio y z p*stripDensity p) (fun i:Fin n=>zeroJet b i) + (fun j:Fin n=>cosineKernelJet (nodalOrder c j) 0 (c j)) := by + ext i j + apply integral_congr_ae + filter_upwards with p + dsimp only [mixedZeroJetPencil,familyGram,poleAdjustedDensity,characteristicRatio] + ring +lemma poleMixedZeroPencil_original_gram {n:ℕ} (b c:ℕ→ℝ) {z:ℝ} (hz:0zeroJet b i) (fun j:Fin n=>cosineKernelJet (nodalOrder c j) 0 (c j)) := by + rw [poleMixedZeroPencil_characteristic_gram] + congr 1 + funext p + have hd:(p^2+z^2)≠0:=by positivity + simp only [characteristicRatio,div_self hd,one_mul] +/-- A characteristic product bound for the second nonsymmetric family, uniform over its interior label. -/ +theorem second_oblique_characteristic_product_bounds {y z:ℝ} (hy:0zeroJet (extendedKnotLabels N) i + let G:=fun j:Fin (2*N+1)=>cosineKernelJet (nodalOrder (interiorKnotLabels N t) j) 0 (interiorKnotLabels N t j) + a*((N:ℝ)+1)^(3*(y-z)/8)≤ + (familyGram (fun p=>characteristicRatio y z p*stripDensity p) F G).det / (familyGram stripDensity F G).det ∧ + (familyGram (fun p=>characteristicRatio y z p*stripDensity p) F G).det / (familyGram stripDensity F G).det≤ + A*((N:ℝ)+1)^(3*(y-z)/8) := by + obtain ⟨a,A,ha,hA,hbounds⟩:=twoJet_characteristic_bounds hy hyz + have hz:=hy.trans hyz + have hl:0characteristicRatio y z p*stripDensity p) (twoKnotLabels N) (twoKnotLabels N)).det/ + (jetGram (n:=2*N) stripDensity (twoKnotLabels N) (twoKnotLabels N)).det ∧ _ at hN + constructor + · calc + ((y^2/z^2)^2*a)*((N:ℝ)+1)^(3*(y-z)/8)=(y^2/z^2)^2*(a*((N:ℝ)+1)^(3*(y-z)/8)):=by ring + _≤_:=mul_le_mul_of_nonneg_left (hN.1.trans hu.1) (sq_nonneg _) + _≤_:=h.1 + · have hh:=(mul_le_mul_of_nonneg_left h.2 hl.le).trans (hu.2.trans hN.2) + rw [mul_comm] at hh + have hh' := (le_div_iff₀ hl).mpr hh + exact hh'.trans_eq (by ring) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory +lemma zeroJet_tilt_det_pos {m N:ℕ} (hm:m+1=2*N) (hN:0characteristicRatio y z p*stripDensity p) + (fun i:Fin m=>zeroJet (twoKnotLabels N) i) (fun i:Fin m=>zeroJet (twoKnotLabels N) i)).det := by + let b:=twoKnotLabels N + have hb:b 0=0:=twoKnot_first N hN + have hF i:(fun p=>cosineKernelJet (nodalOrder b i) 0 (b i) p)∈stripKernelSpan (angle^2):= + kernel_mem_stripSpan (twoKnot_nonneg N i) (twoKnot_le N i) _ + rw [zeroJet_gram_compression m b hb _ (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y hz)] + have hA:(jetGram (n:=m+1) (fun p=>characteristicRatio y z p*stripDensity p) b b).PosDef:=by + rw [hm] + exact twoJetFamily_tilt_posDef N hy hz + have hC:(zeroJetMatrix m b*jetGram (n:=m+1) (fun p=>characteristicRatio y z p*stripDensity p) b b*(zeroJetMatrix m b)ᵀ).PosDef:=by + simpa only [Matrix.conjTranspose_eq_transpose_of_trivial,Matrix.transpose_transpose] using + hA.conjTranspose_mul_mul_same (zeroJetMatrix_transpose_injective m b) + exact hC.det_pos +lemma secondOblique_expansion_aux {m N:ℕ} (hm:m+1=2*N) (hN:0secondLeftFlag m N i (p^2)*secondRightFlag m N t j (p^2)*poleAdjustedDensity z p) (Set.Ioi 0):=by + simpa only [pow_zero,one_mul] using stripSpan_pair_integrable hz 0 (secondLeft_mem m N i) (secondRight_mem m N j ht htL) + have h := unorientedPencil_two_steps (secondLeftFlag m N) (secondRightFlag m N t) (poleAdjustedDensity z) + (secondLeft_nonvanishing hm hN) (secondRight_nonvanishing hm hN ht htL) + (fun i=>stripSpan_continuous (secondLeft_mem m N i)) (fun i=>stripSpan_continuous (secondRight_mem m N i ht htL)) + (fun _ hp=>poleAdjustedDensity_pos hz hp) hi + (fun i j=>stripSpan_pair_integrable hz 2 (secondLeft_mem m N i) (secondRight_mem m N j ht htL)) + (sq_pos_of_pos hz) (by nlinarith : z^2characteristicRatio y z p*stripDensity p) F F *ᵥ v) := by + have hle:1≤y^2/z^2:=by apply (le_div_iff₀ (by positivity)).mpr;nlinarith + rw [familyGram_quad _ F (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y hz), + familyGram_quad _ F (fun i j=>stripSpan_actual_pair (hF i) (hF j))] + have hf:=finiteFamilyCombination_mem_stripSpan hF v + apply (familySquaredNorm_weight_bounds stripDensity (characteristicRatio y z) (finiteFamilyCombination F v) + (fun _ hp=>(stripDensity_pos hp).le) (fun p _=>by simpa only [min_eq_left hle,max_eq_right hle] using characteristicRatio_bounds y hz p) + (by simpa only [pow_two] using stripSpan_actual_pair hf hf) + (by simpa only [pow_two] using stripSpan_tilt_pair hf hf y hz)).1 +/-- Removing the evaluation direction under an expanding characteristic +factor only decreases the characteristic determinant quotient. -/ +theorem zeroJet_expansion_upper {m N:ℕ} (hm:m+1=2*N) (hN:0characteristicRatio y z p*stripDensity p) + (fun i:Fin m=>zeroJet (twoKnotLabels N) i) (fun i:Fin m=>zeroJet (twoKnotLabels N) i)).det/ + (familyGram stripDensity (fun i:Fin m=>zeroJet (twoKnotLabels N) i) (fun i:Fin m=>zeroJet (twoKnotLabels N) i)).det ≤ + (jetGram (n:=2*N) (fun p=>characteristicRatio y z p*stripDensity p) (twoKnotLabels N) (twoKnotLabels N)).det/ + (jetGram (n:=2*N) stripDensity (twoKnotLabels N) (twoKnotLabels N)).det := by + classical + let b:=twoKnotLabels N + let F:=fun i:Fin (m+1)=>cosineKernelJet (nodalOrder b i) 0 (b i) + let w:=fun p=>characteristicRatio y z p*stripDensity p + let C:=zeroJetMatrix m b + have hb:b 0=0:=twoKnot_first N hN + have hF i:F i∈stripKernelSpan (angle^2):=kernel_mem_stripSpan (twoKnot_nonneg N i) (twoKnot_le N i) _ + have hB:(jetGram (n:=m+1) stripDensity b b).PosDef:=by rw [hm];exact twoJetFamily_posDef N + have hA:(jetGram (n:=m+1) w b b).PosDef:=by rw [hm];exact twoJetFamily_tilt_posDef N (hz.trans_le hzy) hz + have hCB:(C*jetGram (n:=m+1) stripDensity b b*Cᵀ).PosDef:=by + simpa only [Matrix.conjTranspose_eq_transpose_of_trivial,Matrix.transpose_transpose] using + hB.conjTranspose_mul_mul_same (zeroJetMatrix_transpose_injective m b) + have hCa:=zeroJet_gram_compression m b hb w (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y hz) + have hCb:=zeroJet_gram_compression m b hb stripDensity (fun i j=>stripSpan_actual_pair (hF i) (hF j)) + have h2:=positive_compression_codimension _ _ C hA hB hCB (by norm_num : (0:ℝ)≤1) (familyGram_expansion_lower F hF hz hzy) + simp only [one_pow,one_mul] at h2 + change (zeroJetMatrix m b*jetGram (n:=m+1) w b b*(zeroJetMatrix m b)ᵀ).det/ + (zeroJetMatrix m b*jetGram (n:=m+1) stripDensity b b*(zeroJetMatrix m b)ᵀ).det≤_ at h2 + rw [←hCa,←hCb,hm] at h2 + exact h2 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology +/-- A moving-parameter characteristic bound for the second nonsymmetric family. -/ +theorem second_oblique_growing_product_bound : + ∃ D:ℕ,0zeroJet (extendedKnotLabels N) i + let G:=fun j:Fin (2*N+1)=>cosineKernelJet (nodalOrder (interiorKnotLabels N t) j) 0 (interiorKnotLabels N t j) + (familyGram (fun p=>characteristicRatio y z p*stripDensity p) F G).det / + (familyGram stripDensity F G).det ≤ + 16*(1+C*z^4*((D*N:ℕ)+1:ℝ)^3*(4*((D*N:ℕ)+1:ℝ))^(2*c*y/Real.pi+1)) := by + obtain ⟨D,hD,htwo⟩:=twoJet_polynomial_expansion_uniform + obtain ⟨c,C,hc,hC,hpoly⟩:=strip_polynomial_square_product_uniform + refine ⟨D,hD,c,C,hc,hC,?_⟩ + filter_upwards [htwo,eventually_ge_atTop (1:ℕ)] with N hN hNN + intro y z hz hzy hyz hs t ht htL + dsimp only + have hz0:0characteristicRatio y z p*stripDensity p) (twoKnotLabels N) (twoKnotLabels N)).det / + (jetGram (n:=2*N) stripDensity (twoKnotLabels N) (twoKnotLabels N)).det ≤ _ at hj + have hbase:=zeroJet_tilt_det_pos hm hNp hz0 hz0 + have he:(fun p=>characteristicRatio z z p*stripDensity p)=stripDensity:=by + funext p + have hd:p^2+z^2≠0:=by positivity + simp only [characteristicRatio,div_self hd,one_mul] + rw [he] at hbase + have hU:0≤(familyGram (fun p=>characteristicRatio y z p*stripDensity p) + (fun i:Fin (2*N-1)=>zeroJet (twoKnotLabels N) i) (fun i:Fin (2*N-1)=>zeroJet (twoKnotLabels N) i)).det/ + (familyGram stripDensity (fun i:Fin (2*N-1)=>zeroJet (twoKnotLabels N) i) (fun i:Fin (2*N-1)=>zeroJet (twoKnotLabels N) i)).det:= + (div_pos (zeroJet_tilt_det_pos hm hNp hy0 hz0) hbase).le + have hratio:y^2/z^2≤2:=(div_le_iff₀ (by positivity)).mpr (by nlinarith) + have hratio0:0≤y^2/z^2:=by positivity + have hratio2:(y^2/z^2)^2≤4:=by nlinarith + have ho:=(polynomial_characteristic_le_one_square (D*N) hy0 hz0).trans + (show 1 + _ ≤ 1+C*z^4*((D*N:ℕ)+1:ℝ)^3*(4*((D*N:ℕ)+1:ℝ))^(2*c*y/Real.pi+1) by + linarith [hpoly y z hz hs (D*N)]) + have hh:=(h.2.trans (mul_le_mul_of_nonneg_right hratio2 hU)).trans + (mul_le_mul_of_nonneg_left (hu.trans hj) (by norm_num : (0:ℝ)≤4)) + have hf:=mul_le_mul_of_nonneg_left ho (by norm_num : (0:ℝ)≤16) + calc + _≤4*(4*((monomialGram (D*N) (fun p=>characteristicRatio y z p*stripDensity p)).det / + (monomialGram (D*N) stripDensity).det)):=hh + _=16*((monomialGram (D*N) (fun p=>characteristicRatio y z p*stripDensity p)).det / + (monomialGram (D*N) stripDensity).det):=by ring + _≤_:=hf +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology Asymptotics +/-- A scalar estimate for moving-parameter characteristic products with exponent `3/4`. -/ +lemma rpow_log_isLittleO_id {r:ℝ} (hr:r<1) : + (fun x:ℝ=>x^r*log x)=o[atTop] fun x=>x := by + have h:=(isLittleO_log_rpow_atTop (show 0<1-r by linarith)).mul_isBigO + (isBigO_refl (fun x:ℝ=>x^r) atTop) + apply h.congr' + · exact Eventually.of_forall (fun x=>mul_comm _ _) + · filter_upwards [eventually_gt_atTop (0:ℝ)] with x hx + rw [←rpow_add hx,show 1-r+r=(1:ℝ) by ring,rpow_one] +lemma rpow_isLittleO_id {r:ℝ} (hr:r<1) : + (fun x:ℝ=>x^r)=o[atTop] fun x=>x := by + apply isLittleO_of_tendsto' + · filter_upwards [eventually_gt_atTop (0:ℝ)] with x hx + exact fun h=>(hx.ne' h).elim + · apply (tendsto_rpow_neg_atTop (show 0<1-r by linarith)).congr' + filter_upwards [eventually_gt_atTop (0:ℝ)] with x hx + rw [show -(1-r)=r-1 by ring,rpow_sub hx,rpow_one] +lemma log_majorant_isLittleO_id (A a b c d r:ℝ) (hr:r<1) : + (fun x:ℝ=>log A+a*log x+(b*x^r+c)*(log d+log x))=o[atTop] fun x=>x := by + have h0:=isLittleO_const_id_atTop (log A) + have h1:=isLittleO_log_id_atTop.const_mul_left a + have h2:=(rpow_isLittleO_id hr).const_mul_left (b*log d) + have h3:=(rpow_log_isLittleO_id hr).const_mul_left b + have h4:=isLittleO_const_id_atTop (c*log d) + have h5:=isLittleO_log_id_atTop.const_mul_left c + have h:=((((h0.add h1).add h2).add h3).add h4).add h5 + apply h.congr' + · exact Eventually.of_forall (fun x=>by dsimp;ring) + · exact Eventually.of_forall (fun _=>rfl) +/-- Polynomial power products are exponentially negligible at every fixed sublinear moving exponent. -/ +theorem polynomial_power_product_subexponential {A d r:ℝ} (hA:0(N:ℝ)) atTop atTop).eventually + (polynomial_power_product_subexponential hA hd (by norm_num : (3/4:ℝ)<1) 7 k 1 hε) + filter_upwards [hlim,eventually_ge_atTop (1:ℕ)] with N hN hNN + have hx:1≤(N:ℝ):=by exact_mod_cast hNN + have hx0:0<(N:ℝ):=by linarith + have hroot:(N:ℝ)^(3/4:ℝ)≤(N:ℝ):=by + simpa only [rpow_one] using rpow_le_rpow_of_exponent_le hx (by norm_num : (3/4:ℝ)≤1) + have ht:((D*N:ℕ)+1:ℝ)≤T*N:=by + push_cast + dsimp [T] + nlinarith + have he:0≤k*(N:ℝ)^(3/4:ℝ)+1:=by positivity + have hb:1≤4*T*(N:ℝ):=by nlinarith + let F:ℝ:=(N:ℝ)^7*(4*T*(N:ℝ))^(k*(N:ℝ)^(3/4:ℝ)+1) + have hF:1≤F:=by + have h1:1≤(N:ℝ)^7:=one_le_pow₀ hx + have h2:=one_le_rpow hb he + dsimp [F] + nlinarith + have hu:C*((N:ℝ)^(3/4:ℝ))^4*((D*N:ℕ)+1:ℝ)^3* + (4*((D*N:ℕ)+1:ℝ))^(k*(N:ℝ)^(3/4:ℝ)+1)≤C*T^3*F:=by + calc + _≤C*(N:ℝ)^4*(T*N)^3*(4*T*(N:ℝ))^(k*(N:ℝ)^(3/4:ℝ)+1):=by + have hbase:4*((D*N:ℕ)+1:ℝ)≤4*T*(N:ℝ):=by linarith + have hp:=rpow_le_rpow (by positivity : (0:ℝ)≤4*((D*N:ℕ)+1:ℝ)) hbase he + have hz4:=pow_le_pow_left₀ (rpow_nonneg (Nat.cast_nonneg N) _) hroot 4 + have ht3:=pow_le_pow_left₀ (by positivity : (0:ℝ)≤((D*N:ℕ)+1:ℝ)) ht 3 + have hprod:=mul_le_mul (mul_le_mul_of_nonneg_left hz4 hC) ht3 (by positivity) (by positivity) + exact mul_le_mul hprod hp (by positivity) (by positivity) + _=C*T^3*F:=by dsimp [F];ring + have hf:16*(1+C*T^3*F)≤16*(1+C*T^3)*F:=by nlinarith + have hmajor:16*(1+C*((N:ℝ)^(3/4:ℝ))^4*((D*N:ℕ)+1:ℝ)^3* + (4*((D*N:ℕ)+1:ℝ))^(k*(N:ℝ)^(3/4:ℝ)+1))≤16*(1+C*T^3)*F:=by + nlinarith + have hN':16*(1+C*T^3)*F≤exp (ε*N):=by + rw [show (N:ℝ)^(7:ℝ)=(N:ℝ)^(7:ℕ) from rpow_natCast _ _] at hN + simpa only [F,mul_assoc] using hN + exact hmajor.trans hN' +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Real Filter Topology +noncomputable def movingPole (N:ℕ) : ℝ := (N:ℝ)^(3/4:ℝ) +lemma movingPole_conditions {c:ℝ} (hc:0 < c) : + ∀ᶠ N:ℕ in atTop, 1 ≤ movingPole N ∧ movingPole N < sqrt 2*movingPole N ∧ + (sqrt 2*movingPole N)^2 ≤ 2*(movingPole N)^2 ∧ 1/2 ≤ c*(sqrt 2*movingPole N)/Real.pi := by + have hs:sqrt 2 > 1:=by nlinarith [sq_sqrt (by norm_num : (0:ℝ) ≤ 2),sqrt_nonneg (2:ℝ)] + have hd:0 < 2*c*sqrt 2:=by positivity + have hlim: Tendsto movingPole atTop atTop := + (tendsto_rpow_atTop (by norm_num : (0:ℝ) < 3/4)).comp tendsto_natCast_atTop_atTop + filter_upwards [hlim.eventually_ge_atTop 1,hlim.eventually_ge_atTop (Real.pi/(2*c*sqrt 2))] with N hN hB + have hp:0 < movingPole N:=by linarith + refine ⟨hN,by nlinarith,?_,?_⟩ + · rw [mul_pow,sq_sqrt (by norm_num : (0:ℝ) ≤ 2)] + · apply (le_div_iff₀ pi_pos).mpr + have h:Real.pi ≤ movingPole N*(2*c*sqrt 2):=(div_le_iff₀ hd).mp hB + nlinarith +/-- First actual two-endpoint ensemble has exp(o(N)) characteristic moment +at y²=2z²=2N^(3/2), uniformly in both interior labels. -/ +theorem first_oblique_moving_subexponential {ε:ℝ} (hε:0 < ε) : + ∀ᶠ N:ℕ in atTop,∀ s t:ℝ,0 < s→s < angle→0 < t→t < angle→ + (jetGram (n:=2*N+1) (fun p=>characteristicRatio (sqrt 2*movingPole N) (movingPole N) p*stripDensity p) + (interiorKnotLabels N s) (interiorKnotLabels N t)).det / + (jetGram (n:=2*N+1) stripDensity (interiorKnotLabels N s) (interiorKnotLabels N t)).det ≤ exp (ε*N) := by + obtain ⟨D,hD,c,C,hc,hC,hbound⟩:=first_oblique_growing_product_bound + let k:ℝ:=2*c*sqrt 2/Real.pi + have hk:0 ≤ k:=by dsimp [k];positivity + have hmajor:=moving_majorant_subexponential D hC.le hk hε + filter_upwards [hbound,hmajor,movingPole_conditions hc] with N hN hM hP + intro s t hs hsL ht htL + have hh:=hN (sqrt 2*movingPole N) (movingPole N) hP.1 hP.2.1.le hP.2.2.1 hP.2.2.2 s t hs hsL ht htL + have he:2*c*(sqrt 2*movingPole N)/Real.pi+1=k*movingPole N+1:=by dsimp [k];ring + rw [he] at hh + have hnonneg:0 ≤ 1+C*(movingPole N)^4*((D*N:ℕ)+1:ℝ)^3*(4*((D*N:ℕ)+1:ℝ))^(k*movingPole N+1):=by positivity + exact (hh.trans (mul_le_mul_of_nonneg_right (by norm_num : (8:ℝ) ≤ 16) hnonneg)).trans hM +/-- A subexponential moving-parameter bound for the second nonsymmetric family. -/ +theorem second_oblique_moving_subexponential {ε:ℝ} (hε:0 < ε) : + ∀ᶠ N:ℕ in atTop,∀ t:ℝ,0 < t→t < angle→ + let F:=fun i:Fin (2*N+1)=>zeroJet (extendedKnotLabels N) i + let G:=fun j:Fin (2*N+1)=>cosineKernelJet (nodalOrder (interiorKnotLabels N t) j) 0 (interiorKnotLabels N t j) + (familyGram (fun p=>characteristicRatio (sqrt 2*movingPole N) (movingPole N) p*stripDensity p) F G).det / + (familyGram stripDensity F G).det ≤ exp (ε*N) := by + obtain ⟨D,hD,c,C,hc,hC,hbound⟩:=second_oblique_growing_product_bound + let k:ℝ:=2*c*sqrt 2/Real.pi + have hk:0 ≤ k:=by dsimp [k];positivity + have hmajor:=moving_majorant_subexponential D hC.le hk hε + filter_upwards [hbound,hmajor,movingPole_conditions hc] with N hN hM hP + intro t ht htL + have hh:=hN (sqrt 2*movingPole N) (movingPole N) hP.1 hP.2.1 hP.2.2.1 hP.2.2.2 t ht htL + have he:2*c*(sqrt 2*movingPole N)/Real.pi+1=k*movingPole N+1:=by dsimp [k];ring + dsimp only at hh ⊢ + rw [he] at hh + exact hh.trans hM +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ChebyshevSystems.lean b/lean/OAI/Combinatorics/HoneycombChords/ChebyshevSystems.lean new file mode 100644 index 0000000000000000000000000000000000000000..c68baef5ebb5c6e35f130159845224b86c306d4a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ChebyshevSystems.lean @@ -0,0 +1,600 @@ +import OAI.Combinatorics.HoneycombChords.StripGram + +namespace OAI + +/-! Chebyshev spaces, sign changes, orthogonality, and nested jet flags. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +/-- Literal complete labels of M: N jets at 0, N at L^2. -/ +noncomputable def twoKnotLabels (N : ℕ) (k : ℕ) : ℝ := if k(contDiff_const.mul (cosineKernelJet_contDiff_right _ _ _ k)).contDiffAt)] + simp_rw [iteratedDeriv_const_mul_field,cosineKernelJet_iteratedDeriv_right] + rw [mul_sum] + apply sum_congr rfl + intro i _ + ring +/-- The literal complete beta-jet family is Chebyshev counting multiplicities. -/ +theorem jetCombination_confluent_unique {n : ℕ} (b x : ℕ → ℝ) (a : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hx : Monotone (fun i : Fin n=>x i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hx0 : ∀ i : Fin n,0 ≤ x i) + (hz : ∀ j : Fin n,iteratedDeriv (nodalOrder x j) (jetCombination b a) (x j)=0) : a=0 := by + let A : Matrix (Fin n) (Fin n) ℝ := fun i j=>cosineKernelJet (nodalOrder b i) (nodalOrder x j) (b i) (x j) + have hu : IsUnit A := (Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr (cosineKernelJet_det_pos b x hb hx hb0 hx0).ne') + apply (Matrix.vecMul_injective_iff_isUnit.mpr hu) + ext j + dsimp only + rw [Matrix.zero_vecMul] + change (∑ i,a i*A i j)=0 + have h:=hz j + rw [jetCombination_iteratedDeriv] at h + exact (mul_eq_zero.mp h).resolve_left (by positivity) +lemma jetCombination_unique {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) (x : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) + (hx : Function.Injective x) (hx0 : ∀ i,0 ≤ x i) + (hz : ∀ i,jetCombination b a (x i)=0) : a=0 := by + have hd : (jetEvaluation b x).det ≠ 0 := by + have h:=jetEvaluation_det_product_pos b b x hb hb hb0 hb0 hx hx0 + exact fun he=>by rw [he,zero_mul] at h;exact lt_irrefl _ h + apply (Matrix.vecMul_injective_iff_isUnit.mpr + ((Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr hd))) + ext j + dsimp only + rw [Matrix.zero_vecMul] + exact hz j +lemma jetCombination_zeros_card_lt {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) (ha : a ≠ 0) + (s : Finset ℝ) (hs : ∀ x∈s,0 ≤ x ∧ jetCombination b a x=0) : s.card(o.symm i).val + apply ha + apply jetCombination_unique b a x hb hb0 + · intro i j he + exact o.symm.injective (Subtype.ext he) + · intro i + exact (hs _ (ht (o.symm i).property)).1 + · intro i + exact (hs _ (ht (o.symm i).property)).2 +lemma jetCombination_finite_zeros {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) (ha : a ≠ 0) : + {x : ℝ | 0 ≤ x ∧ jetCombination b a x=0}.Finite := by + by_contra hf + obtain ⟨s,hs,hcard⟩ := Set.Infinite.exists_subset_card_eq hf n + have h:=jetCombination_zeros_card_lt b a hb hb0 ha s (fun x hx=>hs hx) + omega +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Set +lemma continuous_nonzero_sign {f : ℝ → ℝ} {s : Set ℝ} (hc : IsPreconnected s) + (hf : ContinuousOn f s) (hz : ∀ x∈s,f x ≠ 0) {u v : ℝ} (hu : u∈s) (hv : v∈s) : + 0 < f u*f v := by + have hu0:=hz u hu + have hv0:=hz v hv + rcases lt_or_gt_of_ne hu0 with hn|hp + · have hn' : f v<0 := by + by_contra h + obtain ⟨x,hx,hfx⟩ := hc.intermediate_value hu hv hf (show 0∈Icc (f u) (f v) from ⟨hn.le,le_of_not_gt h⟩) + exact hz x hx hfx + exact mul_pos_of_neg_of_neg hn hn' + · have hp' : 0 + intro a hs hz + by_cases hempty : s=∅ + · subst s + refine ⟨∅,Finset.Subset.rfl,f (a+1),?_,?_⟩ + · intro h + have hmem := (hz (a+1) (by linarith)).mp h + simp at hmem + · intro x hx _ + simpa using continuous_nonzero_sign isPreconnected_Ioi hf.continuousOn + (fun y hy h=>by simpa using (hz y hy).mp h) hx (show a⟨ne_of_gt hy,h⟩,fun h=>h.2⟩) + let P : ℝ → ℝ := fun x=>e*∏ z∈t,(x-z) + have hP : Continuous P := by dsimp [P];fun_prop + have hp0 (x) (hx : xlinarith + have hprod : f u*P u≠0 := mul_ne_zero (hf0 u hu) (hp0 u hu.2) + have hsame {x : ℝ} (hx : x∈Ioo a r) : 0<(f x*P x)*(f u*P u) := + continuous_nonzero_sign isPreconnected_Ioo (hf.mul hP).continuousOn + (fun y hy=>mul_ne_zero (hf0 y hy) (hp0 y hy.2)) hx hu + rcases lt_or_gt_of_ne hprod with hn|hp + · refine ⟨insert r t,?_,e,he,?_⟩ + · exact insert_subset hr (fun x hx=>mem_of_mem_erase (ht hx)) + · intro x hx hxs + have hxr : x≠r := fun hh=>hxs (hh.symm ▸ hr) + have hrt : r∉t := fun hh=>(ne_of_mem_erase (ht hh)) rfl + rw [prod_insert hrt] + change 0hxs (mem_of_mem_erase hh))) (sub_pos.mpr hgt) + · refine ⟨t,fun x hx=>mem_of_mem_erase (ht hx),e,he,?_⟩ + intro x hx hxs + have hxr : x≠r := fun hh=>hxs (hh.symm ▸ hr) + rcases lt_or_gt_of_ne hxr with hlt|hgt + · exact pos_of_mul_pos_left (hsame ⟨hx,hlt⟩) hp.le + · exact hpos x hgt (fun hh=>hxs (mem_of_mem_erase hh)) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +lemma vandermonde_cons_det {n : ℕ} (x : ℝ) (v : Fin n → ℝ) : + (Matrix.vandermonde (Fin.cons x v)).det=(∏ i,(v i-x))*(Matrix.vandermonde v).det := by + have eqn {m : ℕ} (w : Fin m → ℝ) : (Matrix.vandermonde w).det= + ∏ i,∏ j,if i0) x).det= + (∏ i : Fin n,((2*i.val).factorial:ℝ)⁻¹)*(Matrix.vandermonde x).det := by + have hno (k : ℕ) : nodalOrder (fun _ : ℕ=>(0:ℝ)) k=k := by simp [nodalOrder] + have he : jetEvaluation (fun _=>0) x=fun i j : Fin n=> + ((2*i.val).factorial:ℝ)⁻¹*(Matrix.vandermonde x)ᵀ i j := by + ext i j + simp [jetEvaluation,hno,cosineKernelJet_at_zero,div_eq_mul_inv,mul_comm] + rw [he] + change (Matrix.of (fun i j : Fin n=>((2*i.val).factorial:ℝ)⁻¹*(Matrix.vandermonde x)ᵀ i j)).det=_ + rw [Matrix.det_mul_column,Matrix.det_transpose] +/-- Cofactor coefficients of the literal complete-jet interpolant test. -/ +noncomputable def jetTestCoeffs {n : ℕ} (b : ℕ → ℝ) (v : Fin n → ℝ) : Fin (n+1) → ℝ := + fun i=>(-1)^i.val*(Matrix.of (fun k j : Fin n=>cosineKernelJet (nodalOrder b (i.succAbove k)) 0 + (b (i.succAbove k)) (v j))).det +lemma jetTest_eq_det {n : ℕ} (b : ℕ → ℝ) (v : Fin n → ℝ) (x : ℝ) : + jetCombination b (jetTestCoeffs b v) x=(jetEvaluation b (Fin.cons x v)).det := by + rw [Matrix.det_succ_column_zero] + unfold jetCombination jetTestCoeffs + apply sum_congr rfl + intro i _ + simp only [jetEvaluation,Fin.cons_zero,Matrix.submatrix,Fin.cons_succ] + ring +lemma jetTest_sign_product {n : ℕ} (b : ℕ → ℝ) (v : Fin n → ℝ) {x : ℝ} + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hb0 : ∀ i : Fin (n+1),0 ≤ b i) + (hv : StrictMono v) (hv0 : ∀ i,0 ≤ v i) (hx0 : 0≤x) (hx : ∀ i,x≠v i) : + 0 < jetCombination b (jetTestCoeffs b v) x*(∏ i,(v i-x)) := by + have hix : Function.Injective (Fin.cons x v) := by + intro i j he + refine Fin.cases (Fin.cases (fun _=>rfl) (fun j h=>False.elim (hx j h)) j) + (fun i=>Fin.cases (fun h=>False.elim (hx i h.symm)) (fun j h=>congrArg Fin.succ (hv.injective h)) j) i he + have hp:=jetEvaluation_det_product_pos b (fun _=>0) (Fin.cons x v) hb + (fun _ _ _=>le_refl _) hb0 (fun _=>le_refl _) hix (Fin.cases hx0 hv0) + rw [jetEvaluation_zero_labels,vandermonde_cons_det,←jetTest_eq_det] at hp + have hc : 0<(∏ i : Fin (n+1),((2*i.val).factorial:ℝ)⁻¹)*(Matrix.vandermonde v).det := by + apply mul_pos (prod_pos (fun _ _=>by positivity)) + rw [Matrix.det_vandermonde] + exact prod_pos (fun i _=>prod_pos (fun j hj=>sub_pos.mpr (hv (mem_Ioi.mp hj)))) + have heq : jetCombination b (jetTestCoeffs b v) x* + ((∏ i : Fin (n+1),((2*i.val).factorial:ℝ)⁻¹)*((∏ i,(v i-x))*(Matrix.vandermonde v).det))= + (jetCombination b (jetTestCoeffs b v) x*(∏ i,(v i-x)))* + ((∏ i : Fin (n+1),((2*i.val).factorial:ℝ)⁻¹)*(Matrix.vandermonde v).det) := by ring + rw [heq] at hp + exact pos_of_mul_pos_left hp hc.le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +lemma jetCombination_smul {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) (e x : ℝ) : + jetCombination b (fun i=>e*a i) x=e*jetCombination b a x := by + simp only [jetCombination,mul_sum] + apply sum_congr rfl + intro i _ + ring + +theorem jet_flag_sign_matching {m : ℕ} (b : ℕ → ℝ) (f : ℝ → ℝ) + (hb : Monotone (fun i : Fin m=>b i)) (hb0 : ∀ i : Fin m,0 ≤ b i) + (hf : Continuous f) (s : Finset ℝ) (hs : ∀ x ∈ s,0 < x) + (hz : ∀ x,0 < x → (f x = 0 ↔ x ∈ s)) (hc : s.card < m) : + ∃ k : ℕ,k + 1 ≤ m ∧ ∃ a : Fin (k+1) → ℝ, + (∀ x,0 < x → 0 ≤ f x*jetCombination b a x) ∧ + (∀ x,0 < x → f x≠0 → 0 < f x*jetCombination b a x) := by + classical + obtain ⟨t,ht,e,he,hpos⟩ := finite_zero_sign_polynomial f hf s 0 hs hz + let o := t.orderIsoOfFin rfl + let v : Fin t.card → ℝ := fun i=>(o i).val + have hv : StrictMono v := o.strictMono + have hvpos i : 0b i) := + fun i j hij=>hb (show (i.castLE hdim : Fin m) ≤ j.castLE hdim from hij) + have hb0' (i : Fin (t.card+1)) : 0 ≤ b i := hb0 (i.castLE hdim) + let A : Fin (t.card+1) → ℝ := fun i=>(e*(-1)^t.card)*jetTestCoeffs b v i + have hstrict : ∀ x,0 < x → f x≠0 → 0 < f x*jetCombination b A x := by + intro x hx hfx + have hxs : x∉s := fun h=>(hfx ((hz x hx).mpr h)) + have hxv i : x≠v i := fun h=>hxs (h.symm ▸ ht (o i).property) + have hp:=hpos x hx hxs + have hj:=jetTest_sign_product b v hb' hb0' hv (fun i=>(hvpos i).le) hx.le hxv + have hprod : (∏ i : Fin t.card,(x-v i))=∏ z∈t,(x-z) := by + calc + _ = ∏ z : t,(x-z.val) := Equiv.prod_comp o.toEquiv (fun z : t=>x-z.val) + _ = _ := Finset.prod_attach _ _ + have hneg : (∏ i : Fin t.card,(v i-x))=(-1:ℝ)^t.card*(∏ z∈t,(x-z)) := by + simp_rw [show ∀ i : Fin t.card,v i-x=(-1:ℝ)*(x-v i) from fun i=>by ring] + rw [prod_mul_distrib,prod_const,card_univ,Fintype.card_fin,hprod] + rw [hneg] at hj + have hpp:=mul_pos hp hj + have heq : (f x*(e*∏ z∈t,(x-z)))*(jetCombination b (jetTestCoeffs b v) x* + ((-1:ℝ)^t.card*∏ z∈t,(x-z)))= + (f x*jetCombination b A x)*(∏ z∈t,(x-z))^2 := by + dsimp [A] + rw [jetCombination_smul] + ring + rw [heq] at hpp + exact pos_of_mul_pos_left hpp (sq_nonneg _) + refine ⟨t.card,hdim,A,?_,hstrict⟩ + intro x hx + by_cases hfx : f x = 0 + · simp [hfx] + · exact (hstrict x hx hfx).le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter +/-- Orthogonality forces at least m distinct zeros (indeed m sign changes) for +continuous functions against a complete m-dimensional jet flag. The measure +and the squared p-coordinate are those used by the actual strip pairing. -/ +theorem jet_flag_integral_nonzero {m : ℕ} (b : ℕ → ℝ) (f w : ℝ → ℝ) + (hb : Monotone (fun i : Fin m=>b i)) (hb0 : ∀ i : Fin m,0 ≤ b i) + (hf : Continuous f) (hw : ∀ p,0

f (p^2)*cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)*w p) (Set.Ioi 0)) + (s : Finset ℝ) (hs : ∀ x ∈ s,0 < x) (hz : ∀ x,0 < x → (f x = 0 ↔ x ∈ s)) (hc : s.card < m) : + ∃ i : Fin m,(∫ p in Set.Ioi (0:ℝ),f (p^2)*cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)*w p)≠0 := by + classical + by_contra hall + push Not at hall + obtain ⟨k,hk,a,hnonneg,hpos⟩ := jet_flag_sign_matching b f hb hb0 hf s hs hz hc + let F : Fin (k+1) → ℝ → ℝ := fun i p=>a i*(f (p^2)*cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)*w p) + let H : ℝ → ℝ := fun p=>f (p^2)*jetCombination b a (p^2) + let g : ℝ → ℝ := fun p=>H p*w p + have heq : g=fun p=>∑ i,F i p := by + funext p + dsimp [g,H,F,jetCombination] + rw [mul_sum,sum_mul] + apply sum_congr rfl + intro i _ + ring + have hiF (i : Fin (k+1)) : IntegrableOn (F i) (Set.Ioi 0) := (hi (i.castLE hk)).const_mul (a i) + have hig : IntegrableOn g (Set.Ioi 0) := by rw [heq];exact integrable_finsetSum _ (fun i _=>hiF i) + have hzero : (∫ p in Set.Ioi (0:ℝ),g p)=0 := by + rw [heq,integral_finsetSum _ (fun i _=>hiF i)] + apply sum_eq_zero + intro i _ + rw [show (F i)=fun p=>a i*(f (p^2)*cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)*w p) from rfl, + integral_const_mul] + have hz := hall (i.castLE hk) + change (∫ p in Set.Ioi (0:ℝ),f (p^2)*cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)*w p)=0 at hz + rw [hz,mul_zero] + have hgnonneg : 0 ≤ᵐ[volume.restrict (Set.Ioi (0:ℝ))] g := by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact mul_nonneg (hnonneg (p^2) (sq_pos_of_pos hp)) (hw p hp).le + have hH : Continuous H := by + exact (hf.comp (continuous_id.pow 2)).mul ((jetCombination_contDiff b a 0).continuous.comp (continuous_id.pow 2)) + let U : Set ℝ := Set.Ioi 0 ∩ {p | 0hxs ((hz x hx).mp h)) + have hup : 0<(volume.restrict (Set.Ioi (0:ℝ))) U := by + rw [Measure.restrict_apply hopen.measurableSet,Set.inter_eq_left.mpr Set.inter_subset_left] + exact hopen.measure_pos volume hune + have hus : U⊆Function.support g := by + intro p hp + exact (mul_pos hp.2 (hw p hp.1)).ne' + have hgpos : 0<∫ p in Set.Ioi (0:ℝ),g p := + (integral_pos_iff_support_of_nonneg_ae hgnonneg hig).mpr (hup.trans_le (measure_mono hus)) + exact hgpos.ne' hzero +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset MeasureTheory + +theorem jet_linear_nonorthogonality {n m : ℕ} (b c : ℕ → ℝ) (a : Fin n → ℝ) + (w : ℝ → ℝ) (t : ℝ) (hnm : n < m) + (hb : Monotone (fun i : Fin n=>b i)) (hc : Monotone (fun i : Fin m=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin m,0 ≤ c i) (ha : a≠0) + (hw : ∀ p,0

(p^2-t)*jetCombination b a (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p) (Set.Ioi 0)) : + ∃ j : Fin m,(∫ p in Set.Ioi (0:ℝ),(p^2-t)*jetCombination b a (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p)≠0 := by + classical + let Z := (jetCombination_finite_zeros b a hb hb0 ha).toFinset + have hZ : ∀ x,x∈Z ↔ 0 ≤ x ∧ jetCombination b a x=0 := by + intro x + exact Set.Finite.mem_toFinset _ + have hZcard : Z.card(hZ x).mp hx) + let s := (insert t Z).filter (fun x=>0(mem_filter.mp hx).2 + have hz : ∀ x,0⟨hx.le,h⟩),hx⟩ + · rintro ⟨h|h,_⟩ + · exact Or.inl h + · exact Or.inr h.2 + have hsc : s.card < m := by + have h : s.card ≤ Z.card+1 := (card_filter_le _ _).trans (card_insert_le _ _) + omega + exact jet_flag_integral_nonzero c (fun x=>(x-t)*jetCombination b a x) w hc hc0 + ((continuous_id.sub continuous_const).mul (jetCombination_contDiff b a 0).continuous) + hw hi s hs hz hsc + +lemma pole_jetCombination_linear_pair_integrable {n m : ℕ} (b c : ℕ → ℝ) + (a : Fin n → ℝ) {z : ℝ} (hz : 0(p^2-t)*jetCombination b a (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*poleAdjustedDensity z p) (Set.Ioi 0) := by + have hi (i : Fin n) := (pole_jet_pair_pencil_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) hz + (nodalOrder b i) (nodalOrder c j) t).const_mul (a i) + apply (integrable_finsetSum _ (fun i _=>hi i)).congr + filter_upwards with p + dsimp [jetCombination] + rw [mul_sum,sum_mul,sum_mul] + apply sum_congr rfl + intro i _ + ring +theorem pole_jet_linear_nonorthogonality {n m : ℕ} (b c : ℕ → ℝ) (a : Fin n → ℝ) + {z : ℝ} (hz : 0b i)) (hc : Monotone (fun i : Fin m=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin m,0 ≤ c i) (ha : a≠0) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin m,c i ≤ angle^2) : + ∃ j : Fin m,(∫ p in Set.Ioi (0:ℝ),(p^2-t)*jetCombination b a (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*poleAdjustedDensity z p)≠0 := + jet_linear_nonorthogonality b c a _ t hnm hb hc hb0 hc0 ha (fun _ hp=>poleAdjustedDensity_pos hz hp) + (pole_jetCombination_linear_pair_integrable b c a hz t hb0 hc0 hb1 hc1) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset +lemma strip_angle_pos : 0 first | positivity | omega | exact le_rfl +lemma twoKnot_nonneg (N k : ℕ) : 0 ≤ twoKnotLabels N k := by + unfold twoKnotLabels + split_ifs <;> positivity +lemma twoKnot_le (N k : ℕ) : twoKnotLabels N k ≤ angle^2 := by + unfold twoKnotLabels + split_ifs <;> first | positivity | exact le_rfl +lemma interiorKnot_monotone (N : ℕ) {t : ℝ} (ht : 0 first | assumption | positivity | omega | exact le_rfl +lemma interiorKnot_nonneg (N k : ℕ) (t : ℝ) : 0 ≤ interiorKnotLabels N t k := by + unfold interiorKnotLabels + split_ifs <;> positivity +lemma interiorKnot_le (N k : ℕ) {t : ℝ} (ht : 0 first | assumption | positivity | exact le_rfl +lemma twoKnot_nodalOrder (N k : ℕ) : + nodalOrder (twoKnotLabels N) k=if ktwoKnotLabels N j=twoKnotLabels N k)=range k := by + apply filter_eq_self.mpr + intro j hj + have hjN : jtwoKnotLabels N j=twoKnotLabels N k)=Ico N k := by + ext j + simp only [mem_filter,mem_range,mem_Ico] + by_cases hj : jinteriorKnotLabels N t j=interiorKnotLabels N t k)=range k := by + apply filter_eq_self.mpr + intro j hj + have hjN : jinteriorKnotLabels N t j=interiorKnotLabels N t k)=Ico (N+1) k := by + ext j + simp only [mem_filter,mem_range,mem_Ico] + by_cases hj : j omega⟩ +lemma insertKnot_row (N : ℕ) {t : ℝ} (ht : 0 omega +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Equiv +/-- Move the inserted t² label to the last index, leaving M in its original +order. This is only a simultaneous change of basis of the actual pencil. -/ +def knotPermutation (N : ℕ) : Equiv.Perm (Fin (2*N+1)) := + (finSuccEquiv' (Fin.last (2*N))).trans (finSuccEquiv' ⟨N,by omega⟩).symm +lemma knotPermutation_castSucc (N : ℕ) (i : Fin (2*N)) : + knotPermutation N i.castSucc=insertKnotIndex N i := by + simp only [knotPermutation,Equiv.trans_apply,finSuccEquiv'_last_apply_castSucc,finSuccEquiv'_symm_some] + by_cases hi : i.valPUnit + | n+1=>Option α × Pad α n +noncomputable instance padFintype (α : Type*) [Fintype α] : (n : ℕ)→Fintype (Pad α n) + | 0=>by change Fintype PUnit;infer_instance + | n+1=>by letI:=padFintype α n;change Fintype (Option α × Pad α n);infer_instance + +def encode {α : Type*} : (n : ℕ)→List α→Pad α n + | 0,_=>PUnit.unit + | n+1,[] => (none,encode n []) + | n+1,a::as => (some a,encode n as) +def decode {α : Type*} : {n : ℕ}→Pad α n→List α + | 0,_=>[] + | _+1,(none,p)=>decode p + | _+1,(some a,p)=>a::decode p +lemma decode_encode {α : Type*} (n : ℕ) (as : List α) (h : as.length≤n) : + decode (encode n as)=as := by + induction n generalizing as with + | zero => have he : as=[]:=List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero h);subst as;rfl + | succ n ih => + cases as with + | nil => exact ih [] (Nat.zero_le n) + | cons a as => + change a::decode (encode n as)=a::as + rw [ih as (Nat.le_of_succ_le_succ h)] +noncomputable def weight {α : Type*} (w : α→ℝ) : {n : ℕ}→Pad α n→ℝ + | 0,_=>1 + | _+1,(a,p)=>a.elim 1 w*weight w p +lemma weight_nonnegative {α : Type*} {w : α→ℝ} (hw : ∀ a,0≤w a) + {n : ℕ} (p : Pad α n) : 0≤weight w p := by + induction n with + | zero => exact zero_le_one + | succ n ih => + rcases p with ⟨a,p⟩ + apply mul_nonneg (show 0≤a.elim 1 w by cases a <;> simp_all) + exact ih p +lemma weight_encode {α : Type*} (w : α→ℝ) (n : ℕ) (as : List α) (h : as.length≤n) : + weight w (encode n as)=(as.map w).prod := by + induction n generalizing as with + | zero => have he : as=[]:=List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero h);subst as;rfl + | succ n ih => + cases as with + | nil => simpa only [encode,weight,Option.elim_none,one_mul,List.map_nil,List.prod_nil] using ih [] (Nat.zero_le n) + | cons a as => + change w a*weight w (encode n as)=w a*(as.map w).prod + rw [ih as (Nat.le_of_succ_le_succ h)] +lemma sum_weight {α : Type*} [Fintype α] (w : α→ℝ) (n : ℕ) : + (∑ p : Pad α n,weight w p)=(1+∑ a,w a)^n := by + induction n with + | zero => change (∑ _ : PUnit, (1:ℝ))=1; simp + | succ n ih => + change (∑ p : Option α × Pad α n,p.1.elim 1 w*weight w p.2)=_ + rw [Fintype.sum_prod_type] + simp only [←Finset.mul_sum] + rw [ih,←Finset.sum_mul,Fintype.sum_option] + simp only [Option.elim_none,Option.elim_some] + rw [pow_succ] + ring + +lemma finite_system_bound {α : Type*} [Fintype α] (w : α→ℝ) (hw : ∀ a,0≤w a) + (S : Finset (List α)) (n : ℕ) (hlen : ∀ as∈S,as.length≤n) : + (∑ as∈S,(as.map w).prod)≤(1+∑ a,w a)^n := by + classical + calc + _ = ∑ as∈S,weight w (encode n as) := by + apply Finset.sum_congr rfl + intro as has + exact (weight_encode w n as (hlen as has)).symm + _ = ∑ p∈S.image (encode n),weight w p := by + symm + apply Finset.sum_image + intro as has bs hbs he + have hh:=congrArg decode he + simpa only [decode_encode n as (hlen as has),decode_encode n bs (hlen bs hbs)] using hh + _ ≤ ∑ p : Pad α n,weight w p := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro p hp hn + exact weight_nonnegative hw p + _ = _ := sum_weight w n +end CriticalHoneycomb.Transfer.ListBound + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations +open scoped BigOperators + +noncomputable def relativePartition {W H : ℕ} (x₀ : Assignment W H) : ℂ := + ∑ cfg : Cell W H→Shape,∑ x : Assignment W H,relativeTerm cfg x₀ x +lemma relativePartition_eq_prescribed {W H : ℕ} (x₀ : Assignment W H) : + relativePartition x₀=prescribedPartition W H + (fun j=>x₀.1 (.inl (0,j))) (fun j=>x₀.1 (.inl (Fin.last W,j))) + (fun i=>x₀.1 (.inr (i,0))) (fun i=>x₀.1 (.inr (i,Fin.last H))) := by + simp only [relativePartition,relativeTerm_eq_masked,sum_maskedTerm,prescribed_shape_expansion] + +lemma active_shape_decomposition {W H : ℕ} (x₀ : Assignment (W+1) (H+1)) + (cfg : Cell (W+1) (H+1)→Shape) + (hn : (∑ x,relativeTerm cfg x₀ x)≠0) : + ∃ (x : Assignment (W+1) (H+1)) (cs : List (BoundaryChord W H)), + SameBoundary x x₀ ∧ Matches cfg x.1 x.2 ∧ SelectedSystem x cs ∧ + (∑ y,relativeTerm cfg x₀ y)=systemAmplitude x cs := by + classical + obtain ⟨x,_,hx⟩:=Finset.exists_ne_zero_of_sum_ne_zero hn + obtain ⟨hb,hm,hp⟩:=(relativeTerm_ne_zero cfg x₀ x).mp hx + have hx' : relativeTerm cfg x x≠0 := + (relativeTerm_ne_zero cfg x x).mpr ⟨sameBoundary_refl x,hm,hp⟩ + have hr:=relativeTerm_change_reference cfg hb + obtain ⟨cs,hcs,hval⟩:=all_boundary_shape_decomposition cfg x hx' (by simpa only [hr] using hn) + exact ⟨x,cs,hb,hm,hcs,by simpa only [hr] using hval⟩ + +theorem actual_partition_component_bound {W H : ℕ} (x₀ : Assignment (W+1) (H+1)) : + ∃ S : Finset (List (BoundaryChord W H)), + (∀ cs∈S, ∃ x : Assignment (W+1) (H+1),SameBoundary x x₀ ∧ SelectedSystem x cs) ∧ + (∀ cs∈S,(systemNodes cs).Nodup) ∧ + ‖relativePartition x₀‖≤∑ cs∈S,kappa^(systemNodes cs).length := by + classical + let F := fun cfg : Cell (W+1) (H+1)→Shape=>∑ x,relativeTerm cfg x₀ x + let A := {cfg : Cell (W+1) (H+1)→Shape // F cfg≠0} + have hd : ∀ a : A,∃ x cs,SameBoundary x x₀ ∧ Matches a.val x.1 x.2 ∧ + SelectedSystem x cs ∧ F a.val=systemAmplitude x cs := fun a=> + active_shape_decomposition x₀ a.val a.property + choose x cs hb hm hs hc using hd + have hi : Function.Injective cs := by + intro a b he + apply Subtype.ext + exact SelectedSystem.shape_unique (hs a) (he ▸ hs b) (hm a) (hm b) + let S := Finset.univ.image cs + refine ⟨S,?_,?_,?_⟩ + · intro z hz + obtain ⟨a,_,rfl⟩:=Finset.mem_image.mp hz + exact ⟨x a,hb a,hs a⟩ + · intro z hz + obtain ⟨a,_,rfl⟩:=Finset.mem_image.mp hz + exact (hs a).nodes_nodup + · have hsum : relativePartition x₀=∑ a : A,F a.val := by + change (∑ cfg,F cfg)=_ + rw [←sum_subtype_indicator (fun cfg=>F cfg≠0) F] + apply Finset.sum_congr rfl + intro cfg hcfg + by_cases hh : F cfg=0 <;> simp [hh] + rw [hsum] + calc + _ ≤ ∑ a : A,‖F a.val‖ := norm_sum_le _ _ + _ = ∑ a : A,kappa^(systemNodes (cs a)).length := by + apply Finset.sum_congr rfl + intro a ha + rw [hc a,(hs a).amplitude_norm] + _ = _ := by + change (∑ a : A,kappa^(systemNodes (cs a)).length)= + ∑ z∈Finset.univ.image cs,kappa^(systemNodes z).length + symm + exact Finset.sum_image (f:=fun z : List (BoundaryChord W H)=>kappa^(systemNodes z).length) + (s:=(Finset.univ : Finset A)) hi.injOn +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology + +noncomputable def hardWeight {W H : ℕ} (c : BoundaryChord W H) : ℝ := by + classical + exact if EndPort c.source ∧ EndPort c.target then kappa^c.chord.val.length else 0 +lemma hardWeight_nonnegative {W H : ℕ} (c : BoundaryChord W H) : 0≤hardWeight c := by + unfold hardWeight + split_ifs + · exact (pow_pos kappa_positive _).le + · exact le_refl _ +lemma sum_hardWeight (W H : ℕ) : (∑ c : BoundaryChord W H,hardWeight c)=singleSystemMass W H := by + classical + unfold hardWeight singleSystemMass + rw [←Finset.sum_filter] + exact Finset.sum_subtype _ (by simp) _ +lemma systemNodes_weight {W H : ℕ} (cs : List (BoundaryChord W H)) : + kappa^(systemNodes cs).length=(cs.map (fun c=>kappa^c.chord.val.length)).prod := by + induction cs with + | nil => simp [systemNodes] + | cons c cs ih => + change kappa^(c.chord.val++systemNodes cs).length=_ + simp only [List.length_append,pow_add,List.map_cons,List.prod_cons,ih] +lemma system_hardWeight {W H : ℕ} {cs : List (BoundaryChord W H)} + (hp : ∀ c∈cs,EndPort c.source ∧ EndPort c.target) : + kappa^(systemNodes cs).length=(cs.map hardWeight).prod := by + rw [systemNodes_weight] + apply congrArg List.prod + apply List.map_congr_left + intro c hc + simp only [hardWeight,ite_eq_left (hp c hc)] + +theorem hard_wall_partition_bound {W H : ℕ} (x₀ : Assignment (W+1) (H+1)) + (hw : ∀ j,assignmentSpins x₀ (westPort W H j).wire=1) + (he : ∀ j,assignmentSpins x₀ (eastPort W H j).wire=1) : + ‖relativePartition x₀‖≤(1+poolMass W H)^(2*(W+1)) := by + classical + obtain ⟨S,hS,hN,hB⟩:=actual_partition_component_bound x₀ + have walls : ∀ cs∈S,∃ x : Assignment (W+1) (H+1),SelectedSystem x cs ∧ + (∀ j,assignmentSpins x (westPort W H j).wire=1) ∧ + (∀ j,assignmentSpins x (eastPort W H j).wire=1) := by + intro cs hc + obtain ⟨x,hx,hs⟩:=hS cs hc + exact ⟨x,hs,fun j=>(sameBoundary_port hx _).trans (hw j), + fun j=>(sameBoundary_port hx _).trans (he j)⟩ + have hn : ∀ cs∈S,cs.length≤2*(W+1) := by + intro cs hc + obtain ⟨x,hx,hw,he⟩:=walls cs hc + exact hx.length_le_width hw he + have hprod : ∀ cs∈S,kappa^(systemNodes cs).length=(cs.map hardWeight).prod := by + intro cs hc + obtain ⟨x,hx,hw,he⟩:=walls cs hc + exact system_hardWeight (fun c hc=>hx.hard_endpoints hw he hc) + calc + _ ≤ ∑ cs∈S,kappa^(systemNodes cs).length := hB + _ = ∑ cs∈S,(cs.map hardWeight).prod := Finset.sum_congr rfl (fun cs hc=>hprod cs hc) + _ ≤ (1+∑ c : BoundaryChord W H,hardWeight c)^(2*(W+1)) := + ListBound.finite_system_bound hardWeight hardWeight_nonnegative S _ hn + _ = (1+singleSystemMass W H)^(2*(W+1)) := by rw [sum_hardWeight] + _ ≤ _ := pow_le_pow_left₀ (by + have hh : 0 ≤ singleSystemMass W H := Finset.sum_nonneg (fun c hc=>(pow_pos kappa_positive _).le) + linarith) (by have hh:=singleSystemMass_le W H; linarith) _ + +theorem eventually_hard_wall_partition_bound (W : ℕ) : + ∃ C : ℝ,∀ᶠ H : ℕ in atTop,∀ x₀ : Assignment (W+1) (H+1), + (∀ j,assignmentSpins x₀ (westPort W H j).wire=1)→ + (∀ j,assignmentSpins x₀ (eastPort W H j).wire=1)→‖relativePartition x₀‖≤C := by + refine ⟨(2+2*archPoolMass W)^(2*(W+1)),?_⟩ + filter_upwards [(poolMass_limit W).eventually_lt_const (show 2*archPoolMass W<1+2*archPoolMass W by linarith)] with H hH + intro x hw he + apply (hard_wall_partition_bound x hw he).trans + apply pow_le_pow_left₀ + · have hn : 0≤poolMass W H:=tsum_nonneg poolWeight_nonnegative + linarith + · linarith +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology + +noncomputable def poolArchHeight {W : ℕ} (a : ArchPool W) : ℕ := + a.2.val.toFinset.sup (fun v=>v.2.1.natAbs) +lemma poolArchHeight_ge {W : ℕ} (a : ArchPool W) {v : Center} (hv : v∈a.2.val) : + v.2.1≤(poolArchHeight a:ℤ) := by + have hn : v.2.1.natAbs≤poolArchHeight a:=Finset.le_sup (f:=fun v : Center=>v.2.1.natAbs) (List.mem_toFinset.mpr hv) + have ha : v.2.1≤(v.2.1.natAbs:ℤ):=Int.le_natAbs + omega +noncomputable def archTailWeight {W : ℕ} (k : ℕ) (a : ArchPool W) : ℝ := + if k≤poolArchHeight a then archPoolWeight a else 0 +noncomputable def archTailMass (W k : ℕ) : ℝ := ∑' a : ArchPool W,archTailWeight k a +lemma archTailWeight_nonnegative {W k : ℕ} (a : ArchPool W) : 0≤archTailWeight k a := by + unfold archTailWeight + split_ifs + · exact (pow_pos kappa_positive _).le + · exact le_refl _ +lemma archTailWeight_le {W k : ℕ} (a : ArchPool W) : archTailWeight k a≤archPoolWeight a := by + unfold archTailWeight + split_ifs + · exact le_refl _ + · exact (pow_pos kappa_positive _).le +lemma archTail_summable (W k : ℕ) : Summable (archTailWeight (W:=W) k) := + (archPool_summable W).of_nonneg_of_le (fun a=>archTailWeight_nonnegative a) (fun a=>archTailWeight_le a) +lemma archTailMass_limit (W : ℕ) : Tendsto (archTailMass W) atTop (𝓝 0) := by + classical + have ht : Tendsto (fun k=>∑' a : ArchPool W,archTailWeight k a) atTop (𝓝 (∑' _a : ArchPool W,(0:ℝ))) := by + apply tendsto_tsum_of_dominated_convergence (archPool_summable W) + · intro a + apply tendsto_const_nhds.congr' + filter_upwards [eventually_gt_atTop (poolArchHeight a)] with k hk + simp only [archTailWeight,ite_eq_right (not_le_of_gt hk)] + · apply Eventually.of_forall + intro k a + rw [Real.norm_eq_abs,abs_of_nonneg (archTailWeight_nonnegative a)] + exact archTailWeight_le a + change Tendsto (fun k=>∑' a : ArchPool W,archTailWeight k a) atTop (𝓝 0) + simpa only [tsum_zero] using ht + +noncomputable def badPoolWeight {W H : ℕ} (k : ℕ) : OnePathPool W H→ℝ + | .inl (.inl a)=>archTailWeight k a + | .inl (.inr a)=>archTailWeight k a + | .inr (.inl a)=>bridgePoolWeight a + | .inr (.inr a)=>bridgePoolWeight a +noncomputable def badPoolMass (W H k : ℕ) : ℝ := ∑' a : OnePathPool W H,badPoolWeight k a +lemma badPoolWeight_nonnegative {W H k : ℕ} (a : OnePathPool W H) : 0≤badPoolWeight k a := by + rcases a with (a|a)|(a|a) + · exact archTailWeight_nonnegative a + · exact archTailWeight_nonnegative a + · exact (pow_pos kappa_positive _).le + · exact (pow_pos kappa_positive _).le +lemma badPoolWeight_le {W H k : ℕ} (a : OnePathPool W H) : badPoolWeight k a≤poolWeight a := by + rcases a with (a|a)|(a|a) + · exact archTailWeight_le a + · exact archTailWeight_le a + · exact le_refl _ + · exact le_refl _ +lemma badPool_summable (W H k : ℕ) : Summable (badPoolWeight (W:=W) (H:=H) k) := + (pool_summable W H).of_nonneg_of_le badPoolWeight_nonnegative badPoolWeight_le +lemma badPoolMass_eq (W H k : ℕ) : badPoolMass W H k=2*archTailMass W k+2*bridgePoolMass W H := by + have ht : HasSum (badPoolWeight (W:=W) (H:=H) k) + ((archTailMass W k+archTailMass W k)+(bridgePoolMass W H+bridgePoolMass W H)) := by + apply HasSum.sum + · apply HasSum.sum + · exact (archTail_summable W k).hasSum + · exact (archTail_summable W k).hasSum + · apply HasSum.sum + · exact hasSum_fintype _ + · exact hasSum_fintype _ + change (∑' a : OnePathPool W H,badPoolWeight k a)=_ + rw [ht.tsum_eq] + ring +lemma nat_half_tendsto : Tendsto (fun H : ℕ=>H/2) atTop atTop := by + apply tendsto_atTop.2 + intro k + filter_upwards [eventually_ge_atTop (2*k)] with H hH + omega +lemma badPoolMass_limit (W : ℕ) : Tendsto (fun H=>badPoolMass W H (H/2)) atTop (𝓝 0) := by + simp_rw [badPoolMass_eq] + simpa using ((archTailMass_limit W).comp nat_half_tendsto |>.const_mul 2).add ((bridgePoolMass_limit W).const_mul 2) + +lemma pool_midrow_weight {W H : ℕ} (a : OnePathPool W H) + (hm : ∃ v∈recoverTrace a,v.2.1=(H/2:ℕ)) : + badPoolWeight (H/2) a=poolWeight a := by + classical + obtain ⟨v,hv,hy⟩:=hm + rcases a with (a|a)|(a|a) + · change archTailWeight (H/2) a=archPoolWeight a + unfold archTailWeight + rw [ite_eq_left] + have hh:=poolArchHeight_ge a hv + omega + · change archTailWeight (H/2) a=archPoolWeight a + unfold archTailWeight + rw [ite_eq_left] + obtain ⟨u,hu,rfl⟩:=List.mem_map.mp hv + have hh:=poolArchHeight_ge a hu + change (H:ℤ)-u.2.1=(H/2:ℕ) at hy + omega + · rfl + · rfl + +lemma HardChord.midrow_weight {W H : ℕ} (c : HardChord W H) + (hm : ∃ v∈c.val.chord.val,v.2.1=(H/2:ℕ)) : + badPoolWeight (H/2) c.encode=poolWeight c.encode := by + apply pool_midrow_weight + simpa only [c.recover_encode] using hm +end CriticalHoneycomb.Transfer.RasterGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ChordRemoval.lean b/lean/OAI/Combinatorics/HoneycombChords/ChordRemoval.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4597e9d66f7680b06215373e14539ae8317f8fb --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ChordRemoval.lean @@ -0,0 +1,853 @@ +import OAI.Combinatorics.HoneycombChords.RasterChords + +namespace OAI + +/-! +# Chord removal and finite partition identities + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition FiniteConfigurations +open scoped BigOperators + +lemma three_slots_excludes_third (σ : Fin 3 → Fin 3) (a b k : Fin 3) + (hab : a≠b) (hka : k≠a) (hkb : k≠b) (ha : σ a≠1) (hb : σ b≠1) + (hd : centerOccupied (σ 2) (σ 1) (σ 0)=0 ∨ + centerOccupied (σ 2) (σ 1) (σ 0)=2) : σ k=1 := by + by_contra hk + fin_cases a <;> fin_cases b <;> fin_cases k <;> + simp_all [centerOccupied,spinOccupied] + +/-- In a contributing center configuration, the two sides of a selected +simple path occupy the full local degree. Thus all detached components +are genuinely disjoint from every center on that path. -/ +lemma CenterPath.isolated {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (he : ∀ i, σ (p.edge i)≠1) (hn : ∀ i, centerTensor σ (p.center i)≠0) + (i : Fin n) (k : Fin 3) (hk : incidentWire (p.center i) k∉Set.range p.edge) : + σ (incidentWire (p.center i) k)=1 := by + have hka : k≠p.side i.castSucc := by + intro hh; apply hk; exact (p.incident_edge_iff i k).mpr (Or.inl hh) + have hkb : k≠p.side i.succ := by + intro hh; apply hk; exact (p.incident_edge_iff i k).mpr (Or.inr hh) + apply three_slots_excludes_third (fun k=>σ (incidentWire (p.center i) k)) + (p.side i.castSucc) (p.side i.succ) k (p.sides_distinct i) hka hkb + · rw [p.in_wire]; exact he _ + · rw [p.out_wire]; exact he _ + · have h := hn i + unfold centerTensor at h + split at h + · exact upTensor_degree _ _ _ h + · exact downTensor_degree _ _ _ h + +lemma CenterPath.factor_of_isolated {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (hi : ∀ i k, incidentWire (p.center i) k∉Set.range p.edge → + σ (incidentWire (p.center i) k)=1) (i : Fin n) : + centerTensor σ (p.center i)=p.factor i (fun j=>σ (p.edge j)) := by + change localTensor _ (fun k=>σ (incidentWire (p.center i) k))=_ + unfold CenterPath.factor + congr 1 + funext k + split_ifs with h1 h2 + · rw [h1,p.in_wire] + · rw [h2,p.out_wire] + · apply hi i k + simp only [p.incident_edge_iff] + exact not_or_intro h1 h2 + +lemma CenterPath.selected_orientation_unique {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (he : ∀ i, σ (p.edge i)≠1) (hn : ∀ i, centerTensor σ (p.center i)≠0) + (hroot : σ (p.edge 0)=outSpin (p.point 0) (p.side 0)) : + ∀ i, σ (p.edge i)=p.spins (p.edge i) := by + have hu := p.orientation_unique (fun j=>σ (p.edge j)) hroot (by + intro i + rw [←p.factor_of_isolated σ (p.isolated σ he hn) i] + exact hn i) + intro i + rw [p.spins_edge] + exact congrFun hu i + +noncomputable def CenterPath.erase {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) : Wire → Fin 3 := + fun w=>if w∈Set.range p.edge then 1 else σ w + +noncomputable def CenterPath.fill {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) : Wire → Fin 3 := + fun w=>if w∈Set.range p.edge then p.spins w else σ w + +lemma CenterPath.erased_center {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (hi : ∀ i k, incidentWire (p.center i) k∉Set.range p.edge → + σ (incidentWire (p.center i) k)=1) (i : Fin n) : + centerTensor (p.erase σ) (p.center i)=1 := by + have hs (k : Fin 3) : p.erase σ (incidentWire (p.center i) k)=1 := by + unfold CenterPath.erase + split_ifs with h + · rfl + · exact hi i k h + unfold centerTensor + simp only [hs] + split <;> simp [upTensor,downTensor,Planar.empty,Planar.occupied,Planar.cup] + +lemma CenterPath.erased_off {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (v : Center) (h0 : v≠p.point 0) (hl : v≠p.point (Fin.last (n+1))) + (hv : v∉Set.range p.center) : centerTensor (p.erase σ) v=centerTensor σ v := by + have hs (k : Fin 3) : p.erase σ (incidentWire v k)=σ (incidentWire v k) := + ite_eq_right (p.incident_off v h0 hl hv k) + unfold centerTensor + simp only [hs] + +lemma CenterPath.tensor_selected {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (hi : ∀ i k, incidentWire (p.center i) k∉Set.range p.edge → + σ (incidentWire (p.center i) k)=1) + (he : ∀ i, σ (p.edge i)=p.spins (p.edge i)) (i : Fin n) : + centerTensor σ (p.center i)=centerTensor p.spins (p.center i) := by + rw [p.factor_of_isolated σ hi i] + have he' : (fun j=>σ (p.edge j))=(fun j=>outSpin (p.point j.castSucc) (p.side j)) := by + funext j; rw [he,p.spins_edge] + rw [he',p.factor_true] + +/-- Removing a forced directed chord factors its exact physical weight +from the remaining center product. No independence or loop cancellation +is assumed here. -/ +theorem CenterPath.remove_product {n : ℕ} (p : CenterPath n) (D : Finset Center) + (σ : Wire → Fin 3) (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) + (he : ∀ i, σ (p.edge i)≠1) (hn : ∀ i, centerTensor σ (p.center i)≠0) + (hroot : σ (p.edge 0)=outSpin (p.point 0) (p.side 0)) : + centerProduct D σ=centerProduct D p.spins * centerProduct D (p.erase σ) := by + unfold centerProduct + rw [←Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro v hv + by_cases hc : v∈Set.range p.center + · obtain ⟨i,rfl⟩ := hc + rw [p.erased_center σ (p.isolated σ he hn),mul_one] + exact p.tensor_selected σ (p.isolated σ he hn) (p.selected_orientation_unique σ he hn hroot) i + · rw [p.erased_off σ v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc, + p.off_center_one v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc,one_mul] + +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition FiniteConfigurations SimpleGraph + +noncomputable def vertexCenter {D : Finset Center} (a b : Port (D : Set Center)) : Vertices D → Center + | .inl v => v.val + | .inr q => (portAt a b q).outside + +lemma selected_to_actual {D : Finset Center} (a b : Port (D : Set Center)) (s : Wire → Bool) + (x y : Vertices D) (h : (selectedGraph a b s).Adj x y) : + ∃ k : Fin 3, neighbor (vertexCenter a b x) k=vertexCenter a b y ∧ + s (incidentWire (vertexCenter a b x) k)=true := by + cases x with + | inl v => cases y with + | inl w => exact h + | inr q => + change v.val=(portAt a b q).inside ∧ s (portAt a b q).wire=true at h + refine ⟨(portAt a b q).side,?_,?_⟩ + · change neighbor v.val (portAt a b q).side=(portAt a b q).outside + rw [h.1]; exact (portAt a b q).neighbor_side + · change s (incidentWire v.val _)=true + rw [h.1]; exact h.2 + | inr q => cases y with + | inl v => + change v.val=(portAt a b q).inside ∧ s (portAt a b q).wire=true at h + refine ⟨(portAt a b q).side,?_,?_⟩ + · change neighbor (portAt a b q).outside _=v.val + rw [←(portAt a b q).neighbor_side,neighbor_neighbor,h.1] + · change s (incidentWire (portAt a b q).outside _)=true + rw [←(portAt a b q).neighbor_side,incidentWire_neighbor] + exact h.2 + | inr r => exact h.elim + +/-- Chord extraction remembers the literal occupied wires, so removal is +not an abstraction to a different path model. -/ +theorem chord_edges_of_selected_path {D : Finset Center} {a b : Port (D : Set Center)} + (γ : Chord (D : Set Center) a b) (hab : a.outside≠b.outside) (s : Wire → Bool) + (xs : List (Interior D)) + (p : (selectedGraph a b s).Walk (.inr false) (.inr true)) + (hm : xs.map Subtype.val=γ.val) + (hs : p.support=Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true])) : + ∀ i, s ((ofChord γ hab).edge i)=true := by + let R : Center → Center → Prop := fun x y=>∃ k : Fin 3, + neighbor x k=y ∧ s (incidentWire x k)=true + have hc : (p.support.map (vertexCenter a b)).IsChain R := + List.isChain_map_of_isChain _ (selected_to_actual a b s) p.isChain_adj_support + have hl : p.support.map (vertexCenter a b)=extendedTrace γ := by + rw [hs,List.map_cons,List.map_append,List.map_map] + have hx : (fun x : Interior D=>vertexCenter a b (Sum.inl x))=Subtype.val := rfl + simp only [Function.comp_def,hm,List.map_cons,List.map_nil,vertexCenter,portAt, + Bool.false_eq_true,ite_false,ite_true,extendedTrace] + rw [hl] at hc + intro i + obtain ⟨k,hk,hsk⟩ := List.isChain_iff_getElem.mp hc i.val + (by rw [extendedTrace_length]; omega) + have hp : neighbor ((ofChord γ hab).point i.castSucc) k=(ofChord γ hab).point i.succ := hk + have he : k=(ofChord γ hab).side i := neighbor_injective _ (hp.trans ((ofChord γ hab).step i).symm) + change s (incidentWire ((ofChord γ hab).point i.castSucc) ((ofChord γ hab).side i))=true + rw [←he] + exact hsk + +/-- A contributing physical configuration contains an actual source chord +all of whose center tensors use an isolated two-side passage. -/ +theorem nonzero_contains_selected_chord {D : Finset Center} + (a b : Port (D : Set Center)) (hab : a.outside≠b.outside) (σ : Wire → Fin 3) + (hboundary : BoundarySelection a b (selected σ)) (h : centerProduct D σ≠0) : + ∃ γ : Chord (D : Set Center) a b, + ∀ i, σ ((ofChord γ hab).edge i)≠1 := by + obtain ⟨γ,xs,p,hm,hp,hs,hcycl⟩ := nonzero_product_contains_chord a b + (fun he=>hab (congrArg Port.outside he)) σ hboundary h + refine ⟨γ,?_⟩ + intro i + have he := chord_edges_of_selected_path γ hab (selected σ) xs p hm hs i + simpa [selected,spinOccupied] using he + +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition +open scoped BigOperators + +lemma CenterPath.fill_tensor {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (hi : ∀ i k, σ (incidentWire (p.center i) k)=1) (i : Fin n) : + centerTensor (p.fill σ) (p.center i)=centerTensor p.spins (p.center i) := by + have hs (k : Fin 3) : p.fill σ (incidentWire (p.center i) k)=p.spins (incidentWire (p.center i) k) := by + unfold CenterPath.fill + split_ifs with h + · rfl + · rw [hi,p.spins_off _ h] + unfold centerTensor + simp only [hs] + +lemma CenterPath.fill_off {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (v : Center) (h0 : v≠p.point 0) (hl : v≠p.point (Fin.last (n+1))) + (hv : v∉Set.range p.center) : centerTensor (p.fill σ) v=centerTensor σ v := by + have hs (k : Fin 3) : p.fill σ (incidentWire v k)=σ (incidentWire v k) := + ite_eq_right (p.incident_off v h0 hl hv k) + unfold centerTensor + simp only [hs] + +lemma tensor_empty (σ : Wire → Fin 3) (v : Center) (h : ∀ k, σ (incidentWire v k)=1) : + centerTensor σ v=1 := by + unfold centerTensor + simp only [h] + split <;> simp [upTensor,downTensor,Planar.empty,Planar.occupied,Planar.cup] + +lemma CenterPath.fill_product {n : ℕ} (p : CenterPath n) (D : Finset Center) + (σ : Wire → Fin 3) (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) + (hi : ∀ i k, σ (incidentWire (p.center i) k)=1) : + centerProduct D (p.fill σ)=centerProduct D p.spins * centerProduct D σ := by + unfold centerProduct + rw [←Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro v hv + by_cases hc : v∈Set.range p.center + · obtain ⟨i,rfl⟩ := hc + rw [p.fill_tensor σ hi i,tensor_empty σ _ (hi i),mul_one] + · rw [p.fill_off σ v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc, + p.off_center_one v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) hc,one_mul] + +@[simp] lemma CenterPath.erase_fill {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (he : ∀ i, σ (p.edge i)=1) : p.erase (p.fill σ)=σ := by + funext w + unfold CenterPath.erase CenterPath.fill + split_ifs with hw + · obtain ⟨i,rfl⟩ := hw; exact (he i).symm + · rfl + +lemma CenterPath.fill_erase {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (he : ∀ i, σ (p.edge i)=p.spins (p.edge i)) : p.fill (p.erase σ)=σ := by + funext w + by_cases hw : w∈Set.range p.edge + · obtain ⟨i,rfl⟩ := hw + simpa only [CenterPath.fill,ite_eq_left (Set.mem_range_self i)] using (he i).symm + · simp [CenterPath.fill,CenterPath.erase,hw] + +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +open scoped BigOperators + +abbrev Assignment (W H : ℕ) := (GridWire W H → Fin 3) × (Cell W H → Fin 3) + +noncomputable def assignmentSpins {W H : ℕ} (x : Assignment W H) : Wire → Fin 3 := spins x.1 x.2 + +noncomputable def restrictAssignment {W H : ℕ} (σ : Wire → Fin 3) : Assignment W H := + (restrictGrid σ,restrictMiddle σ) + +lemma restrictAssignment_spins {W H : ℕ} (x : Assignment W H) : + restrictAssignment (assignmentSpins x)=x := by + apply Prod.ext + · funext w; exact spins_wire x.1 x.2 (.inl w) + · funext t; exact spins_wire x.1 x.2 (.inr t) + +lemma assignmentSpins_injective {W H : ℕ} : Function.Injective (assignmentSpins (W:=W) (H:=H)) := by + intro x y h + have he := spins_injective h + exact Prod.ext he.1 he.2 + +lemma assignmentSpins_supported {W H : ℕ} (x : Assignment W H) {w : Wire} + (hw : w∉Set.range (wireEmbedding (W:=W) (H:=H))) : assignmentSpins x w=1 := by + exact Function.extend_apply' (Sum.elim x.1 x.2) (fun _=>1) w hw + +lemma assignmentSpins_restrict {W H : ℕ} (σ : Wire → Fin 3) + (h : ∀ w, w∉Set.range (wireEmbedding (W:=W) (H:=H)) → σ w=1) : + assignmentSpins (restrictAssignment (W:=W) (H:=H) σ)=σ := by + funext w + by_cases hw : w∈Set.range (wireEmbedding (W:=W) (H:=H)) + · obtain ⟨w,rfl⟩ := hw + rw [assignmentSpins,spins_wire] + cases w <;> rfl + · exact (assignmentSpins_supported _ hw).trans (h w hw).symm + +noncomputable def eraseAssignment {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) : Assignment W H := + restrictAssignment (p.erase (assignmentSpins x)) + +noncomputable def fillAssignment {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) : Assignment W H := + restrictAssignment (p.fill (assignmentSpins x)) + +lemma eraseAssignment_spins {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) : + assignmentSpins (eraseAssignment p x)=p.erase (assignmentSpins x) := by + apply assignmentSpins_restrict + intro w hw + unfold CenterPath.erase + split_ifs <;> simp only [assignmentSpins_supported x hw] + +lemma fillAssignment_spins {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) + (hp : ∀ i, p.edge i∈Set.range (wireEmbedding (W:=W) (H:=H))) : + assignmentSpins (fillAssignment p x)=p.fill (assignmentSpins x) := by + apply assignmentSpins_restrict + intro w hw + have hn : w∉Set.range p.edge := by rintro ⟨i,rfl⟩; exact hw (hp i) + rw [CenterPath.fill,ite_eq_right hn,assignmentSpins_supported x hw] + +lemma matches_of_occupied_eq {W H : ℕ} {cfg : Cell W H → Shape} + {x y : Assignment W H} (hm : Matches cfg x.1 x.2) + (he : selected (assignmentSpins x)=selected (assignmentSpins y)) : Matches cfg y.1 y.2 := by + have hh (w : FullWire W H) := congrFun he (wireEmbedding w) + simp only [selected,assignmentSpins,spins_wire] at hh + intro t + exact ⟨(hh (.inl ((network W H).west t))).symm.trans (hm t).1, + (hh (.inl ((network W H).north t))).symm.trans (hm t).2.1, + (hh (.inl ((network W H).south t))).symm.trans (hm t).2.2.1, + (hh (.inl ((network W H).east t))).symm.trans (hm t).2.2.2.1, + (hh (.inr t)).symm.trans (hm t).2.2.2.2⟩ + +lemma selected_erase_congr {n : ℕ} (p : CenterPath n) {σ τ : Wire → Fin 3} + (he : selected σ=selected τ) : selected (p.erase σ)=selected (p.erase τ) := by + funext w + unfold selected CenterPath.erase + split_ifs <;> try rfl + exact congrFun he w + +lemma selected_fill_erase {n : ℕ} (p : CenterPath n) {σ : Wire → Fin 3} + (he : ∀ i, σ (p.edge i)≠1) : selected (p.fill (p.erase σ))=selected σ := by + funext w + unfold selected CenterPath.fill CenterPath.erase + split_ifs with hw + · obtain ⟨i,rfl⟩ := hw + simp [p.spins_edge,spinOccupied,outSpin_ne_empty,he i] + · rfl + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition + +lemma CenterPath.erase_eq_one {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (w : Wire) (h : σ w=p.spins w) : p.erase σ w=1 := by + unfold CenterPath.erase + split_ifs with hw + · rfl + · rw [h,p.spins_off w hw] + +lemma CenterPath.fill_eq_spins {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (w : Wire) (h : σ w=1) : p.fill σ w=p.spins w := by + unfold CenterPath.fill + split_ifs with hw + · rfl + · rw [h,p.spins_off w hw] + +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +open scoped BigOperators + +/-- All four literal cuts, with the prescribed boundary spin at each wire. -/ +def HasBoundary {W H : ℕ} (west east : Column H) (south north : Fin W → Fin 3) + (σ : GridWire W H → Fin 3) : Prop := + HasWestNorth west north σ ∧ (∀ j, σ (.inl (Fin.last W,j))=east j) ∧ + (∀ i, σ (.inr (i,0))=south i) + +noncomputable instance {W H : ℕ} (west east : Column H) (south north : Fin W → Fin 3) + (σ : GridWire W H → Fin 3) : Decidable (HasBoundary west east south north σ) := + Classical.propDecidable _ + +noncomputable def maskedTerm {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) (x : Assignment W H) : ℂ := + if HasBoundary west east south north x.1 ∧ Matches cfg x.1 x.2 then + centerProduct (domain W H) (assignmentSpins x) else 0 + +lemma maskedTerm_ne_zero {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) (x : Assignment W H) : + maskedTerm cfg west east south north x≠0 ↔ + HasBoundary west east south north x.1 ∧ Matches cfg x.1 x.2 ∧ + centerProduct (domain W H) (assignmentSpins x)≠0 := by + unfold maskedTerm + split_ifs <;> tauto + +lemma sum_subtype_indicator {α : Type*} [Fintype α] (P : α → Prop) [DecidablePred P] + (f : α → ℂ) : (∑ x, if P x then f x else 0)=∑ x : {x // P x}, f x.val := by + rw [←Finset.sum_filter] + exact Finset.sum_subtype _ (by simp) _ + +/-- Unrestricted wires with explicit indicators. This form is suitable for +an actual chord erasure bijection of nonzero tensor terms. -/ +theorem sum_maskedTerm {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) : + (∑ x : Assignment W H, maskedTerm cfg west east south north x)= + (kappa:ℂ)^(∑ t, (cfg t).visits) * chosenPartition cfg west east south north := by + classical + rw [masked_chosenPartition,Fintype.sum_prod_type] + calc + _ = ∑ σ : GridWire W H → Fin 3, + if HasWestNorth west north σ then + ∑ μ : Cell W H → Fin 3, if (∀ j, σ (.inl (Fin.last W,j))=east j) ∧ + (∀ i, σ (.inr (i,0))=south i) ∧ Matches cfg σ μ then + centerProduct (domain W H) (spins σ μ) else 0 + else 0 := by + apply Finset.sum_congr rfl + intro σ hσ + by_cases hn : HasWestNorth west north σ + · simp only [hn,ite_true] + apply Finset.sum_congr rfl + intro μ hμ + unfold maskedTerm HasBoundary assignmentSpins + simp only [hn,true_and] + congr 1 + exact propext and_assoc + · simp [maskedTerm,HasBoundary,hn] + _ = _ := by + rw [sum_subtype_indicator] + congr 1 + ext x + simp + +lemma boundary_erase {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) + (west east : Column H) (south north : Fin W → Fin 3) + (hp : HasBoundary west east south north (restrictGrid p.spins)) + (hx : HasBoundary west east south north x.1) : + HasBoundary (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) (eraseAssignment p x).1 := by + have he (w : GridWire W H) (hw : x.1 w=restrictGrid p.spins w) : + (eraseAssignment p x).1 w=1 := by + change p.erase (assignmentSpins x) (wireEmbedding (.inl w))=1 + apply p.erase_eq_one + exact (spins_wire x.1 x.2 (.inl w)).trans hw + refine ⟨⟨?_,?_⟩,?_,?_⟩ + · intro j; exact he _ ((hx.1.1 j).trans (hp.1.1 j).symm) + · intro i; exact he _ ((hx.1.2 i).trans (hp.1.2 i).symm) + · intro j; exact he _ ((hx.2.1 j).trans (hp.2.1 j).symm) + · intro i; exact he _ ((hx.2.2 i).trans (hp.2.2 i).symm) + +lemma boundary_fill {W H n : ℕ} (p : CenterPath n) (x : Assignment W H) + (west east : Column H) (south north : Fin W → Fin 3) + (hp : HasBoundary west east south north (restrictGrid p.spins)) + (hx : HasBoundary (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) x.1) : + HasBoundary west east south north (fillAssignment p x).1 := by + have he (w : GridWire W H) (hw : x.1 w=1) : + (fillAssignment p x).1 w=restrictGrid p.spins w := by + change p.fill (assignmentSpins x) (wireEmbedding (.inl w))=p.spins (wireEmbedding (.inl w)) + apply p.fill_eq_spins + exact (spins_wire x.1 x.2 (.inl w)).trans hw + refine ⟨⟨?_,?_⟩,?_,?_⟩ + · intro j; exact (he _ (hx.1.1 j)).trans (hp.1.1 j) + · intro i; exact (he _ (hx.1.2 i)).trans (hp.1.2 i) + · intro j; exact (he _ (hx.2.1 j)).trans (hp.2.1 j) + · intro i; exact (he _ (hx.2.2 i)).trans (hp.2.2 i) + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +open scoped BigOperators + +lemma selected_fill_congr {n : ℕ} (p : CenterPath n) {σ τ : Wire → Fin 3} + (he : selected σ=selected τ) : selected (p.fill σ)=selected (p.fill τ) := by + funext w + unfold selected CenterPath.fill + split_ifs <;> try rfl + exact congrFun he w + +/-- Factorization by removal of the actual boundary chord. `cfgR` is the +occupancy left on deleting that chord; it has empty boundary, and is not +assumed to have zero coefficient. The next step applies the already proved +vacuum cancellation to it. -/ +theorem actual_path_factorization {W H n : ℕ} (hW : 01) (fun _=>1) (fun _=>1) (fun _=>1) y := by + classical + let P := centerProduct (domain W H) p.spins + let F := maskedTerm cfg west east south north + let G := maskedTerm cfgR (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) + have hP : P≠0 := p.product_nonzero _ h0 hl + obtain ⟨hB₀,hM₀,hN₀⟩ := (maskedTerm_ne_zero cfg west east south north x₀).mp hx₀ + have hNcenter₀ (i) : centerTensor (assignmentSpins x₀) (p.center i)≠0 := + Finset.prod_ne_zero_iff.mp hN₀ _ (hc i) + have erased_empty (i) (k) : p.erase (assignmentSpins x₀) (incidentWire (p.center i) k)=1 := by + unfold CenterPath.erase + split_ifs with hw + · rfl + · exact p.isolated _ hsel hNcenter₀ i k hw + have RX (y : Assignment W H) (hmy : Matches cfgR y.1 y.2) : + selected (assignmentSpins y)=selected (p.erase (assignmentSpins x₀)) := by + have he : selected (assignmentSpins y)=selected (assignmentSpins (eraseAssignment p x₀)) := by + funext w; exact matches_occupied hW hH hmy hR w + rw [eraseAssignment_spins] at he + exact he + have forward (x : Assignment W H) (hx : F x≠0) : + F x=P*G (eraseAssignment p x) ∧ fillAssignment p (eraseAssignment p x)=x := by + obtain ⟨hB,hM,hN⟩ := (maskedTerm_ne_zero cfg west east south north x).mp hx + have heq : selected (assignmentSpins x)=selected (assignmentSpins x₀) := by + funext w; exact matches_occupied hW hH hM hM₀ w + have hs (i) : assignmentSpins x (p.edge i)≠1 := by + have hh := congrFun heq (p.edge i) + simpa [selected,spinOccupied,hsel i] using hh + have hn (i) : centerTensor (assignmentSpins x) (p.center i)≠0 := + Finset.prod_ne_zero_iff.mp hN _ (hc i) + have hr := hroot x hB + have hProd := p.remove_product (domain W H) (assignmentSpins x) h0 hl hs hn hr + have hmE : Matches cfgR (eraseAssignment p x).1 (eraseAssignment p x).2 := by + apply matches_of_occupied_eq hR + rw [eraseAssignment_spins,eraseAssignment_spins] + exact selected_erase_congr p heq.symm + have hbE := boundary_erase p x west east south north hp hB + constructor + · dsimp only [F,G,P] + rw [maskedTerm,ite_eq_left ⟨hB,hM⟩,maskedTerm,ite_eq_left ⟨hbE,hmE⟩,eraseAssignment_spins] + exact hProd + · apply assignmentSpins_injective + rw [fillAssignment_spins p _ hcover,eraseAssignment_spins] + exact p.fill_erase _ (p.selected_orientation_unique _ hs hn hr) + have backward (y : Assignment W H) (hy : G y≠0) : + F (fillAssignment p y)≠0 ∧ eraseAssignment p (fillAssignment p y)=y := by + obtain ⟨hB,hM,hN⟩ := (maskedTerm_ne_zero cfgR (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) y).mp hy + have heq := RX y hM + have hlocal (i) (k) : assignmentSpins y (incidentWire (p.center i) k)=1 := by + have hh := congrFun heq (incidentWire (p.center i) k) + simpa [selected,spinOccupied,erased_empty i k] using hh + have he (i) : assignmentSpins y (p.edge i)=1 := by + have hh := congrFun heq (p.edge i) + simpa [selected,spinOccupied,CenterPath.erase,Set.mem_range_self] using hh + have hmF : Matches cfg (fillAssignment p y).1 (fillAssignment p y).2 := by + apply matches_of_occupied_eq hM₀ + rw [fillAssignment_spins p y hcover] + exact ((selected_fill_congr p heq).trans (selected_fill_erase p hsel)).symm + have hbF := boundary_fill p y west east south north hp hB + constructor + · apply (maskedTerm_ne_zero cfg west east south north _).mpr + refine ⟨hbF,hmF,?_⟩ + rw [fillAssignment_spins p y hcover,p.fill_product _ _ h0 hl hlocal] + exact mul_ne_zero hP hN + · apply assignmentSpins_injective + rw [eraseAssignment_spins,fillAssignment_spins p y hcover,p.erase_fill _ he] + change (∑ x, F x)=P*∑ y, G y + rw [Finset.mul_sum] + apply Finset.sum_bij_ne_zero (fun x _ _=>eraseAssignment p x) + · intro x hx hn; exact Finset.mem_univ _ + · intro x hx hn y hy hm he + have hxf := (forward x hn).2 + have hyf := (forward y hm).2 + rw [←hxf,←hyf,he] + · intro y hy hn + have hg : G y≠0 := (mul_ne_zero_iff.mp hn).2 + have hh := backward y hg + exact ⟨fillAssignment p y,Finset.mem_univ _,hh.1,hh.2⟩ + · intro x hx hn + exact (forward x hn).1 + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +lemma mem_domain_iff {W H : ℕ} (v : Center) : v∈domain W H ↔ + 0≤v.1 ∧ v.1<(W:ℤ) ∧ 0≤v.2.1 ∧ v.2.1<(H:ℤ) := by + constructor + · exact domain_coord_bounds + · rintro ⟨hx,hW,hy,hH⟩ + let i : Fin W := ⟨v.1.toNat,by omega⟩ + let j : Fin H := ⟨v.2.1.toNat,by omega⟩ + have hv : v=cellCenter (i,j) v.2.2 := by + simp [cellCenter,i,j,Int.toNat_of_nonneg hx,Int.toNat_of_nonneg hy] + rw [hv] + exact cellCenter_mem _ _ + +lemma boundary_wire_exhaustive {W H : ℕ} {v : Center} (hv : v∈domain (W+1) (H+1)) + (s : Fin 3) (hn : neighbor v s∉domain (W+1) (H+1)) : + (∃ j, incidentWire v s=(westPort W H j).wire) ∨ + (∃ j, incidentWire v s=(eastPort W H j).wire) ∨ + (∃ i, incidentWire v s=(southPort W H i).wire) ∨ + (∃ i, incidentWire v s=(northPort W H i).wire) := by + obtain ⟨⟨⟨i,j⟩,b⟩,_,rfl⟩ := Finset.mem_image.mp hv + rw [mem_domain_iff] at hn + cases b <;> fin_cases s + · exact False.elim (hn (by simpa [neighbor,cellCenter,up,down] using + (domain_coord_bounds (cellCenter_mem (i,j) true)))) + · have hj : j=Fin.last H := by + apply Fin.ext + have := j.isLt + have := i.isLt + simp [neighbor,cellCenter,up] at hn + simp only [Fin.val_last] + omega + subst j + right; right; right + exact ⟨i,by rw [Port.wire,northPort_side]; rfl⟩ + · have hi : i=Fin.last W := by + apply Fin.ext + have := i.isLt + have := j.isLt + have := i.isLt + simp [neighbor,cellCenter,up] at hn + simp only [Fin.val_last] + omega + subst i + right; left + exact ⟨j,by rw [Port.wire,eastPort_side]; rfl⟩ + · exact False.elim (hn (by simpa [neighbor,cellCenter,up,down] using + (domain_coord_bounds (cellCenter_mem (i,j) false)))) + · have hj : j=0 := by + apply Fin.ext + have := j.isLt + have := i.isLt + simp [neighbor,cellCenter,down] at hn + simp only [Fin.val_zero] + omega + subst j + right; right; left + exact ⟨i,by rw [Port.wire,southPort_side]; rfl⟩ + · have hi : i=0 := by + apply Fin.ext + have := i.isLt + have := j.isLt + have := i.isLt + simp [neighbor,cellCenter,down] at hn + simp only [Fin.val_zero] + omega + subst i + left + exact ⟨j,by rw [Port.wire,westPort_side]; rfl⟩ + +lemma assignment_boundary_selection {W H : ℕ} {j k : Fin (H+1)} + (x : Assignment (W+1) (H+1)) + (hx : HasBoundary (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1) x.1) : + BoundarySelection (westPort W H j) (eastPort W H k) (selected (assignmentSpins x)) := by + have hw (r) : assignmentSpins x (westPort W H r).wire=singleColumn j r := by + rw [westPort_wire]; exact (spins_wire x.1 x.2 _).trans (hx.1.1 r) + have he (r) : assignmentSpins x (eastPort W H r).wire=singleColumn k r := by + rw [eastPort_wire]; exact (spins_wire x.1 x.2 _).trans (hx.2.1 r) + have hs (r) : assignmentSpins x (southPort W H r).wire=1 := by + rw [southPort_wire]; exact (spins_wire x.1 x.2 _).trans (hx.2.2 r) + have hn (r) : assignmentSpins x (northPort W H r).wire=1 := by + rw [northPort_wire]; exact (spins_wire x.1 x.2 _).trans (hx.1.2 r) + refine ⟨?_,?_,?_⟩ + · simp [selected,hw,singleColumn,spinOccupied] + · simp [selected,he,singleColumn,spinOccupied] + · intro v hv s hout hsel + rcases boundary_wire_exhaustive hv s hout with ⟨r,hr⟩|⟨r,hr⟩|⟨r,hr⟩|⟨r,hr⟩ + · rw [hr] at hsel ⊢ + have h : r=j := by + by_contra hc + simp [selected,hw,singleColumn,hc,spinOccupied] at hsel + subst r; exact Or.inl rfl + · rw [hr] at hsel ⊢ + have h : r=k := by + by_contra hc + simp [selected,he,singleColumn,hc,spinOccupied] at hsel + subst r; exact Or.inr rfl + · rw [hr] at hsel + simp [selected,hs,spinOccupied] at hsel + · rw [hr] at hsel + simp [selected,hn,spinOccupied] at hsel + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations +open scoped BigOperators + +lemma matches_unique {W H : ℕ} {cfg cfg' : Cell W H → Shape} + {σ : GridWire W H → Fin 3} {μ : Cell W H → Fin 3} + (h : Matches cfg σ μ) (h' : Matches cfg' σ μ) : cfg=cfg' := by + funext t + have hh := h t + have hh' := h' t + cases hc : cfg t <;> cases hc' : cfg' t <;> simp_all [Shape.selection] + +lemma matches_empty {W H : ℕ} : + Matches (fun _ : Cell W H=>.empty) (fun _=>1) (fun _=>1) := by + intro t + simp [spinOccupied,Shape.selection] + +lemma assignment_empty {W H : ℕ} (hW : 0.empty) x.1 x.2) : assignmentSpins x=fun _=>1 := by + have h (w) := matches_occupied hW hH hx (matches_empty (W:=W) (H:=H)) w + have hv : spins (fun _ : GridWire W H=>1) (fun _=>1)=(fun _=>1) := by + funext w + by_cases he : w∈Set.range (wireEmbedding (W:=W) (H:=H)) + · obtain ⟨w,rfl⟩ := he + rw [spins_wire]; cases w <;> rfl + · exact Function.extend_apply' _ _ _ he + funext w + simpa [assignmentSpins,hv,spinOccupied] using h w + +lemma rectanglePath_boundary {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + HasBoundary (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1) + (restrictGrid (W:=W+1) (H:=H+1) (rectanglePath γ).spins) := + ⟨⟨rectanglePath_west γ,rectanglePath_north γ⟩,rectanglePath_east γ,rectanglePath_south γ⟩ + +lemma rectangle_root {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) + (x : Assignment (W+1) (H+1)) + (hx : HasBoundary (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1) x.1) : + assignmentSpins x ((rectanglePath γ).edge 0)= + outSpin ((rectanglePath γ).point 0) ((rectanglePath γ).side 0) := by + rw [rectanglePath,ofChord_first_edge,westPort_wire] + rw [assignmentSpins,spins_wire] + change x.1 (.inl (0,j))=_ + rw [hx.1.1] + rw [ofChord_first,ofChord_first_side,westPort_side] + simp [singleColumn,outSpin,westPort,down] + +/-- The actual one-strand tensor has no contribution from detached polygons: +every nonzero resolved shape is exactly one literal prescribed-port chord. -/ +theorem nonzero_shape_is_chord {W H : ℕ} (j k : Fin (H+1)) + (cfg : Cell (W+1) (H+1) → Shape) + (hn : chosenPartition cfg (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)≠0) : + ∃ γ : RectChord W H j k, cfg=rectangleShape γ := by + classical + have hκ : (kappa:ℂ)≠0 := by + rw [Complex.ofReal_ne_zero] + unfold kappa + exact_mod_cast (Real.rpow_pos_of_pos (by positivity : (0:ℝ)<2+Real.sqrt 2) (-(1:ℝ)/2)).ne' + have hs : (∑ x : Assignment (W+1) (H+1), + maskedTerm cfg (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1) x)≠0 := by + rw [sum_maskedTerm] + exact mul_ne_zero (pow_ne_zero _ hκ) hn + obtain ⟨x,hxmem,hx⟩ := Finset.exists_ne_zero_of_sum_ne_zero hs + obtain ⟨hB,hM,hN⟩ := (maskedTerm_ne_zero cfg _ _ _ _ x).mp hx + obtain ⟨γ,hsel⟩ := nonzero_contains_selected_chord (westPort W H j) (eastPort W H k) + (west_outside_ne_east W H j k) (assignmentSpins x) (assignment_boundary_selection x hB) hN + let p := rectanglePath γ + have hc : ∀ i, p.center i∈domain (W+1) (H+1) := ofChord_center_mem γ _ + have h0 : p.point 0∉domain (W+1) (H+1) := by + rw [show p.point 0=(westPort W H j).outside from ofChord_first γ _] + exact (westPort W H j).outside_not_mem + have hl : p.point (Fin.last (γ.val.length+1))∉domain (W+1) (H+1) := by + rw [show p.point (Fin.last (γ.val.length+1))=(eastPort W H k).outside from ofChord_last γ _] + exact (eastPort W H k).outside_not_mem + have hcover := path_wire_covered p (chord_length_pos γ) hc + have hroot := rectangle_root γ x hB + have hNi (i) : centerTensor (assignmentSpins x) (p.center i)≠0 := + Finset.prod_ne_zero_iff.mp hN _ (hc i) + have hprod := p.remove_product _ (assignmentSpins x) h0 hl hsel hNi hroot + have hE : centerProduct (domain (W+1) (H+1)) (assignmentSpins (eraseAssignment p x))≠0 := by + rw [eraseAssignment_spins] + intro he + rw [he,mul_zero] at hprod + exact hN hprod + let cfgR := occupancyShape (eraseAssignment p x).1 (eraseAssignment p x).2 hE + have hR : Matches cfgR (eraseAssignment p x).1 (eraseAssignment p x).2 := occupancyShape_matches _ _ _ + have hfact := actual_path_factorization (Nat.succ_pos W) (Nat.succ_pos H) + cfg cfgR _ _ _ _ p x hx hc h0 hl hcover hsel (rectanglePath_boundary γ) + (rectangle_root γ) hR + have hRempty : cfgR=fun _=>.empty := by + by_contra he + have hz := chosen_nonempty_vacuum_zero cfgR he + have hzero : (∑ y : Assignment (W+1) (H+1), + maskedTerm cfgR (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) y)=0 := by + rw [sum_maskedTerm,hz,mul_zero] + rw [hzero,mul_zero] at hfact + exact hs hfact + have he : p.erase (assignmentSpins x)=fun _=>1 := by + rw [←eraseAssignment_spins] + apply assignment_empty (Nat.succ_pos W) (Nat.succ_pos H) + rw [←hRempty] + exact hR + have hp : assignmentSpins x=p.spins := by + rw [←p.fill_erase (assignmentSpins x) (p.selected_orientation_unique _ hsel hNi hroot),he] + funext w + exact p.fill_eq_spins (fun _=>1) w rfl + refine ⟨γ,?_⟩ + apply matches_unique (σ:=restrictGrid p.spins) (μ:=restrictMiddle p.spins) + · apply matches_of_occupied_eq (y:=(restrictGrid p.spins,restrictMiddle p.spins)) hM + change selected (assignmentSpins x)=selected (spins (restrictGrid p.spins) (restrictMiddle p.spins)) + rw [hp,path_spins_restrict p (chord_length_pos γ) hc] + · exact pathShape_matches p (chord_length_pos γ) hc h0 hl + + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +open scoped BigOperators + +/-- Exact finite original-source path partition. Each occupied center has +weight κ; the two prescribed boundary ports are unweighted. Detached cycles +cancel in the tensor contraction rather than being dropped by fiat. -/ +theorem actual_chord_sum_eq_transfer {W H : ℕ} (j k : Fin (H+1)) : + (prescribedPartition (W+1) (H+1) (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)) = + ∑ γ : RectChord W H j k, (kappa:ℂ)^γ.val.length := by + classical + rw [prescribed_shape_expansion] + let F : (Cell (W+1) (H+1) → Shape) → ℂ := fun cfg=> + (kappa:ℂ)^(∑ t, (cfg t).visits) * chosenPartition cfg + (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1) + have hsub : (∑ cfg, F cfg)= + ∑ cfg ∈ Finset.univ.image (rectangleShape (W:=W) (H:=H) (j:=j) (k:=k)), F cfg := by + symm + apply Finset.sum_subset (Finset.subset_univ _) + intro cfg hcfg hnot + have hn : chosenPartition cfg (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)=0 := by + by_contra h + obtain ⟨γ,hγ⟩ := nonzero_shape_is_chord j k cfg h + apply hnot + exact Finset.mem_image.mpr ⟨γ,Finset.mem_univ _,hγ.symm⟩ + simp [F,hn] + change (∑ cfg, F cfg)=_ + rw [hsub,Finset.sum_image (fun x _ y _ h=>rectangleShape_injective h)] + apply Finset.sum_congr rfl + intro γ hγ + dsimp only [F] + rw [actual_chord_chosen_one,mul_one,actual_chord_visits] + +/-- The ENNReal mass defined directly from the literal path subtype agrees +with the finite physical transfer entry. This is finite identification only; +no uniform bound in width or infinite-strip asymptotic is assumed. -/ +theorem actual_chordMass_eq_transfer {W H : ℕ} (j k : Fin (H+1)) : + chordMass (domain (W+1) (H+1) : Set Center) (westPort W H j) (eastPort W H k) = + ENNReal.ofReal (prescribedPartition (W+1) (H+1) + (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)).re := by + classical + rw [actual_chord_sum_eq_transfer] + simp only [Complex.re_sum,←Complex.ofReal_pow,Complex.ofReal_re] + unfold chordMass weight + rw [tsum_fintype,ENNReal.ofReal_sum_of_nonneg] + intro γ hγ + exact pow_nonneg (Real.rpow_pos_of_pos (by positivity : (0:ℝ)<2+Real.sqrt 2) _).le _ + +end CriticalHoneycomb.Transfer.RasterGrid + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ChordSystems.lean b/lean/OAI/Combinatorics/HoneycombChords/ChordSystems.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d937ac4f601df3fe5363852879f976c82d7782d --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ChordSystems.lean @@ -0,0 +1,337 @@ +import OAI.Combinatorics.HoneycombChords.BoundarySystems +import OAI.Combinatorics.HoneycombChords.ArchContinuation + +namespace OAI + +/-! Chord systems for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +lemma BoundaryChord.first_edge {W H : ℕ} (c : BoundaryChord W H) : c.path.edge 0=c.source.wire := + ofChord_first_edge c.chord c.distinct +lemma BoundaryChord.last_edge {W H : ℕ} (c : BoundaryChord W H) : + c.path.edge (Fin.last c.chord.val.length)=c.target.wire := ofChord_last_edge c.chord c.distinct + +lemma SelectedSystem.source_selected {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) + {c : BoundaryChord W H} (hc : c∈cs) : assignmentSpins x c.source.wire≠1 := by + apply (h.edge_union _).mpr + exact ⟨c,hc,⟨0,c.first_edge⟩⟩ +lemma SelectedSystem.target_selected {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) + {c : BoundaryChord W H} (hc : c∈cs) : assignmentSpins x c.target.wire≠1 := by + apply (h.edge_union _).mpr + exact ⟨c,hc,⟨Fin.last c.chord.val.length,c.last_edge⟩⟩ + +lemma SelectedSystem.sources_nodup {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) : (cs.map BoundaryChord.source).Nodup := by + induction h with + | nil => simp + | cons x c cs hs hn hr ih => + apply List.nodup_cons.mpr + refine ⟨?_,ih⟩ + intro hm + obtain ⟨d,hd,he⟩:=List.mem_map.mp hm + have hp:=hr.source_selected hd + rw [he,←c.first_edge,eraseAssignment_spins,CenterPath.erase,ite_eq_left (Set.mem_range_self 0)] at hp + exact hp rfl + +lemma SelectedSystem.length_le_width {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) + (hw : ∀ j,assignmentSpins x (westPort W H j).wire=1) + (he : ∀ j,assignmentSpins x (eastPort W H j).wire=1) : cs.length≤2*(W+1) := by + classical + let bs := Finset.univ.image (southPort W H) + let ts := Finset.univ.image (northPort W H) + have hsub : (cs.map BoundaryChord.source).toFinset⊆bs∪ts := by + intro a ha + obtain ⟨c,hc,rfl⟩:=List.mem_map.mp (List.mem_toFinset.mp ha) + have hs:=h.source_selected hc + rcases port_exhaustive c.source with ⟨i,hh⟩|⟨i,hh⟩|⟨i,hh⟩|⟨i,hh⟩ + · exact (hs (hh ▸ hw i)).elim + · exact (hs (hh ▸ he i)).elim + · exact Finset.mem_union_left _ (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,hh.symm⟩) + · exact Finset.mem_union_right _ (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,hh.symm⟩) + have hc:=(Finset.card_mono hsub).trans (Finset.card_union_le _ _) + have hb : bs.card≤W+1 := (Finset.card_image_le).trans_eq (by simp) + have ht : ts.card≤W+1 := (Finset.card_image_le).trans_eq (by simp) + rw [List.toFinset_card_of_nodup h.sources_nodup,List.length_map] at hc + omega +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations + +noncomputable def BoundaryChord.code {W H : ℕ} (c : BoundaryChord W H) := + (c.source,c.target,restrictAssignment (W:=W+1) (H:=H+1) c.path.spins) +lemma BoundaryChord.spins_restrict {W H : ℕ} (c : BoundaryChord W H) : + assignmentSpins (restrictAssignment (W:=W+1) (H:=H+1) c.path.spins)=c.path.spins := + path_spins_restrict c.path (chord_length_pos c.chord) (ofChord_center_mem c.chord c.distinct) +lemma BoundaryChord.code_injective (W H : ℕ) : Function.Injective (BoundaryChord.code (W:=W) (H:=H)) := by + rintro ⟨a,b,hab,γ⟩ ⟨a',b',hab',δ⟩ he + have ha:=congrArg Prod.fst he + change a=a' at ha + subst a' + have hb:=congrArg (fun z=>z.2.1) he + change b=b' at hb + subst b' + have he':=congrArg (fun z=>assignmentSpins z.2.2) he + rw [BoundaryChord.code,BoundaryChord.code] at he' + change assignmentSpins (restrictAssignment (ofChord γ hab).spins)= + assignmentSpins (restrictAssignment (ofChord δ hab').spins) at he' + rw [show assignmentSpins (restrictAssignment (ofChord γ hab).spins)=(ofChord γ hab).spins from + (⟨a,b,hab,γ⟩ : BoundaryChord W H).spins_restrict, + show assignmentSpins (restrictAssignment (ofChord δ hab').spins)=(ofChord δ hab').spins from + (⟨a,b,hab',δ⟩ : BoundaryChord W H).spins_restrict] at he' + have hγ:=chord_eq_of_selected_eq γ δ hab (congrArg selected he') + subst δ + rfl +noncomputable instance boundaryChordFintype (W H : ℕ) : Fintype (BoundaryChord W H) := + Fintype.ofInjective BoundaryChord.code (BoundaryChord.code_injective W H) + +def EndPort {W H : ℕ} (p : Port (domain (W+1) (H+1) : Set Center)) : Prop := + (∃ i,p=southPort W H i) ∨ (∃ i,p=northPort W H i) +def HardChord (W H : ℕ) := {c : BoundaryChord W H // EndPort c.source ∧ EndPort c.target} +noncomputable instance hardChordFintype (W H : ℕ) : Fintype (HardChord W H) := by + classical + unfold HardChord + infer_instance +noncomputable def singleSystemMass (W H : ℕ) : ℝ := ∑ c : HardChord W H,kappa^c.val.chord.val.length + +lemma endPort_of_selected {W H : ℕ} {x : Assignment (W+1) (H+1)} + (hw : ∀ j,assignmentSpins x (westPort W H j).wire=1) + (he : ∀ j,assignmentSpins x (eastPort W H j).wire=1) + {a : Port (domain (W+1) (H+1) : Set Center)} (ha : assignmentSpins x a.wire≠1) : EndPort a := by + rcases port_exhaustive a with ⟨i,hh⟩|⟨i,hh⟩|⟨i,hh⟩|⟨i,hh⟩ + · exact (ha (hh ▸ hw i)).elim + · exact (ha (hh ▸ he i)).elim + · exact Or.inl ⟨i,hh⟩ + · exact Or.inr ⟨i,hh⟩ +lemma SelectedSystem.hard_endpoints {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) + (hw : ∀ j,assignmentSpins x (westPort W H j).wire=1) + (he : ∀ j,assignmentSpins x (eastPort W H j).wire=1) + {c : BoundaryChord W H} (hc : c∈cs) : EndPort c.source ∧ EndPort c.target := + ⟨endPort_of_selected hw he (h.source_selected hc),endPort_of_selected hw he (h.target_selected hc)⟩ +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation + +lemma endPort_inside_injective {W H : ℕ} {a b : Port (domain (W+1) (H+1) : Set Center)} + (ha : EndPort a) (hb : EndPort b) (he : a.inside=b.inside) : a=b := by + rcases ha with ⟨i,rfl⟩|⟨i,rfl⟩ <;> rcases hb with ⟨j,rfl⟩|⟨j,rfl⟩ <;> + simp only [southPort,northPort,cellCenter,up,down,Prod.mk.injEq,Bool.true_eq_false, + Bool.false_eq_true,and_false,and_true] at he + all_goals first + | exact he.elim + | have he' : i=j := by apply Fin.ext;omega + subst j;rfl +lemma HardChord.trace_injective (W H : ℕ) : + Function.Injective (fun c : HardChord W H=>c.val.chord.val) := by + intro c d he + have hs : c.val.source=d.val.source := endPort_inside_injective c.property.1 d.property.1 + (Option.some.inj (c.val.chord.property.2.1.symm.trans ((congrArg List.head? he).trans d.val.chord.property.2.1))) + have ht : c.val.target=d.val.target := endPort_inside_injective c.property.2 d.property.2 + (Option.some.inj (c.val.chord.property.2.2.symm.trans ((congrArg List.getLast? he).trans d.val.chord.property.2.2))) + apply Subtype.ext + rcases c with ⟨⟨a,b,hab,γ⟩,hc⟩ + rcases d with ⟨⟨a',b',hab',δ⟩,hd⟩ + dsimp at hs ht he + subst a';subst b' + have hh : γ=δ:=Subtype.ext he + subst δ + rfl + +lemma boundaryChord_to_halfRect {W H : ℕ} (c : BoundaryChord W H) : + IsTrace (halfRect (W+1)) c.chord.val := by + refine ⟨c.chord.property.1.1,c.chord.property.1.2.1,?_⟩ + intro v hv + obtain ⟨hx,hW,hy,hH⟩:=domain_coord_bounds (c.chord.property.1.2.2 v hv) + exact ⟨hx,hW,hy⟩ +noncomputable def bottomArchOf {W H : ℕ} (c : BoundaryChord W H) (i j : Fin (W+1)) + (hs : c.source=southPort W H i) (ht : c.target=southPort W H j) : BottomArch W i j := + ⟨c.chord.val,boundaryChord_to_halfRect c,by simpa only [hs,southPort,cellCenter,up,Fin.val_zero,Nat.cast_zero] using c.chord.property.2.1, + by simpa only [ht,southPort,cellCenter,up,Fin.val_zero,Nat.cast_zero] using c.chord.property.2.2⟩ +lemma bottomEnds_distinct {W H : ℕ} (c : BoundaryChord W H) (i j : Fin (W+1)) + (hs : c.source=southPort W H i) (ht : c.target=southPort W H j) : i≠j := by + intro hh;apply c.distinct;rw [hs,ht,hh] + +lemma topTurn_involution (W H : ℕ) (v : Center) : topTurn W H (topTurn W H v)=v := by + rcases v with ⟨i,j,b⟩ + simp [topTurn] +lemma topTurn_trace {W H : ℕ} (c : BoundaryChord W H) : + IsTrace (halfRect (W+1)) (c.chord.val.map (topTurn W H)) := by + refine ⟨c.chord.property.1.1.map (topTurn_injective W H),?_,?_⟩ + · apply (List.isChain_map _).mpr + exact c.chord.property.1.2.1.imp (fun v w h=>(topTurn_adj W H v w).mpr h) + · intro v hv + obtain ⟨w,hw,rfl⟩:=List.mem_map.mp hv + obtain ⟨hx,hW,hy,hH⟩:=domain_coord_bounds (c.chord.property.1.2.2 w hw) + change 0≤(W:ℤ)-w.1 ∧ (W:ℤ)-w.1<(W+1:ℕ) ∧ 0≤(H:ℤ)-w.2.1 + omega +lemma topTurn_north (W H : ℕ) (i : Fin (W+1)) : + topTurn W H (northPort W H i).inside=up i.rev.val 0 := by + simp [topTurn,northPort,cellCenter,up,Fin.rev] + omega +noncomputable def topArchOf {W H : ℕ} (c : BoundaryChord W H) (i j : Fin (W+1)) + (hs : c.source=northPort W H i) (ht : c.target=northPort W H j) : BottomArch W i.rev j.rev := + ⟨c.chord.val.map (topTurn W H),topTurn_trace c,by + rw [List.head?_map,c.chord.property.2.1,hs];simp only [Option.map_some,topTurn_north],by + rw [List.getLast?_map,c.chord.property.2.2,ht];simp only [Option.map_some,topTurn_north]⟩ +lemma topEnds_distinct {W H : ℕ} (c : BoundaryChord W H) (i j : Fin (W+1)) + (hs : c.source=northPort W H i) (ht : c.target=northPort W H j) : i.rev≠j.rev := by + intro hh + have hij : i=j := by simpa using congrArg Fin.rev hh + apply c.distinct;rw [hs,ht,hij] + +lemma boundaryChord_to_rect {W H : ℕ} (c : BoundaryChord W H) : + IsTrace (rect (W+1) (H+1)) c.chord.val := by + refine ⟨c.chord.property.1.1,c.chord.property.1.2.1,?_⟩ + intro v hv + exact domain_coord_bounds (c.chord.property.1.2.2 v hv) + +noncomputable def upBridgeOf {W H : ℕ} (c : BoundaryChord W H) (i j : Fin (W+1)) + (hs : c.source=southPort W H i) (ht : c.target=northPort W H j) : RectBridge W H i := + ⟨c.chord.val,boundaryChord_to_rect c,by simpa only [hs,southPort,cellCenter,up,Fin.val_zero,Nat.cast_zero] using c.chord.property.2.1, + ⟨j,by simpa only [ht,northPort,cellCenter,down,Fin.val_last] using c.chord.property.2.2⟩⟩ +noncomputable def downBridgeOf {W H : ℕ} (c : BoundaryChord W H) (i j : Fin (W+1)) + (hs : c.source=northPort W H i) (ht : c.target=southPort W H j) : RectBridge W H j := + ⟨c.chord.val.reverse,⟨List.nodup_reverse.mpr c.chord.property.1.1, + reverse_chain c.chord.property.1.2.1,by + intro v hv;exact domain_coord_bounds (c.chord.property.1.2.2 v (List.mem_reverse.mp hv))⟩,by + simpa only [List.head?_reverse,ht,southPort,cellCenter,up,Fin.val_zero,Nat.cast_zero] using c.chord.property.2.2, + ⟨i,by simpa only [List.getLast?_reverse,hs,northPort,cellCenter,down,Fin.val_last] using c.chord.property.2.1⟩⟩ + +abbrev ArchPool (W : ℕ) := Σ a : ArchEnds W,BottomArch W a.first a.last +abbrev BridgePool (W H : ℕ) := Σ i : Fin (W+1),RectBridge W H i +abbrev OnePathPool (W H : ℕ) := (ArchPool W ⊕ ArchPool W) ⊕ (BridgePool W H ⊕ BridgePool W H) + +noncomputable def HardChord.encode {W H : ℕ} (c : HardChord W H) : OnePathPool W H := by + classical + exact if hs : ∃ i,c.val.source=southPort W H i then + if ht : ∃ j,c.val.target=southPort W H j then + .inl (.inl ⟨⟨hs.choose,ht.choose,bottomEnds_distinct c.val _ _ hs.choose_spec ht.choose_spec⟩, + bottomArchOf c.val _ _ hs.choose_spec ht.choose_spec⟩) + else + let hnt := c.property.2.resolve_left ht + .inr (.inl ⟨hs.choose,upBridgeOf c.val _ _ hs.choose_spec hnt.choose_spec⟩) + else + let hns := c.property.1.resolve_left hs + if ht : ∃ j,c.val.target=southPort W H j then + .inr (.inr ⟨ht.choose,downBridgeOf c.val _ _ hns.choose_spec ht.choose_spec⟩) + else + let hnt := c.property.2.resolve_left ht + .inl (.inr ⟨⟨hns.choose.rev,hnt.choose.rev, + topEnds_distinct c.val _ _ hns.choose_spec hnt.choose_spec⟩, + topArchOf c.val _ _ hns.choose_spec hnt.choose_spec⟩) + +noncomputable def poolTrace {W H : ℕ} : OnePathPool W H→List Center + | .inl (.inl a)=>a.2.val + | .inl (.inr a)=>a.2.val + | .inr (.inl a)=>a.2.val + | .inr (.inr a)=>a.2.val +noncomputable def recoverTrace {W H : ℕ} : OnePathPool W H→List Center + | .inl (.inl a)=>a.2.val + | .inl (.inr a)=>a.2.val.map (topTurn W H) + | .inr (.inl a)=>a.2.val + | .inr (.inr a)=>a.2.val.reverse +lemma HardChord.recover_encode {W H : ℕ} (c : HardChord W H) : recoverTrace c.encode=c.val.chord.val := by + classical + unfold HardChord.encode + split_ifs <;> simp only [recoverTrace,bottomArchOf,topArchOf,upBridgeOf,downBridgeOf, + List.map_map,List.reverse_reverse] + have hh : topTurn W H ∘ topTurn W H = id := funext (topTurn_involution W H) + rw [hh,List.map_id] +lemma HardChord.encode_injective (W H : ℕ) : Function.Injective (HardChord.encode (W:=W) (H:=H)) := by + intro c d he + apply HardChord.trace_injective W H + change c.val.chord.val=d.val.chord.val + exact c.recover_encode.symm.trans ((congrArg recoverTrace he).trans d.recover_encode) +lemma HardChord.encode_length {W H : ℕ} (c : HardChord W H) : (poolTrace c.encode).length=c.val.chord.val.length := by + classical + unfold HardChord.encode + split_ifs <;> simp [poolTrace,bottomArchOf,topArchOf,upBridgeOf,downBridgeOf] +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology + +noncomputable instance archEndsFintype (W : ℕ) : Fintype (ArchEnds W) := + Fintype.ofInjective (fun a : ArchEnds W=>(a.first,a.last)) (by + rintro ⟨i,j,h⟩ ⟨i',j',h'⟩ he + obtain ⟨rfl,rfl⟩:=Prod.mk.inj he + rfl) + +noncomputable def archPoolWeight {W : ℕ} (a : ArchPool W) : ℝ := kappa^a.2.val.length +noncomputable def bridgePoolWeight {W H : ℕ} (a : BridgePool W H) : ℝ := kappa^a.2.val.length +noncomputable def poolWeight {W H : ℕ} (a : OnePathPool W H) : ℝ := kappa^(poolTrace a).length +noncomputable def archPoolMass (W : ℕ) : ℝ := ∑' a : ArchPool W,archPoolWeight a +noncomputable def bridgePoolMass (W H : ℕ) : ℝ := ∑ a : BridgePool W H,bridgePoolWeight a +noncomputable def poolMass (W H : ℕ) : ℝ := ∑' a : OnePathPool W H,poolWeight a + +lemma archPool_summable (W : ℕ) : Summable (archPoolWeight (W:=W)) := by + apply summable_sigma_of_nonneg (fun a=>(pow_pos kappa_positive _).le) |>.mpr + refine ⟨?_,?_⟩ + · intro a;exact bottom_arch_summable a.distinct + · exact (hasSum_fintype _).summable +lemma pool_hasSum (W H : ℕ) : HasSum (poolWeight (W:=W) (H:=H)) + ((archPoolMass W+archPoolMass W)+(bridgePoolMass W H+bridgePoolMass W H)) := by + apply HasSum.sum + · apply HasSum.sum + · exact (archPool_summable W).hasSum + · exact (archPool_summable W).hasSum + · apply HasSum.sum + · exact hasSum_fintype _ + · exact hasSum_fintype _ +lemma pool_summable (W H : ℕ) : Summable (poolWeight (W:=W) (H:=H)) := + (pool_hasSum W H).summable +lemma poolWeight_nonnegative {W H : ℕ} (a : OnePathPool W H) : 0≤poolWeight a := + (pow_pos kappa_positive _).le +lemma bridgePoolMass_eq (W H : ℕ) : bridgePoolMass W H=∑ i : Fin (W+1),crossingMass W H i := by + rw [bridgePoolMass,Fintype.sum_sigma] + rfl +lemma poolMass_eq (W H : ℕ) : poolMass W H=2*archPoolMass W+2*bridgePoolMass W H := by + change (∑' a : OnePathPool W H,poolWeight a)=_ + rw [(pool_hasSum W H).tsum_eq] + ring +lemma bridgePoolMass_limit (W : ℕ) : Tendsto (bridgePoolMass W) atTop (𝓝 0) := by + change Tendsto (fun H=>bridgePoolMass W H) atTop (𝓝 0) + simp_rw [bridgePoolMass_eq] + have hh:=tendsto_finsetSum Finset.univ (fun i hi=>crossing_tendsto_zero W i) + simpa using hh +lemma poolMass_limit (W : ℕ) : Tendsto (poolMass W) atTop (𝓝 (2*archPoolMass W)) := by + change Tendsto (fun H=>poolMass W H) atTop (𝓝 (2*archPoolMass W)) + simp_rw [poolMass_eq] + simpa using tendsto_const_nhds.add ((bridgePoolMass_limit W).const_mul 2) + +lemma singleSystemMass_le (W H : ℕ) : singleSystemMass W H≤poolMass W H := by + classical + calc + _ = ∑ c : HardChord W H,poolWeight c.encode := by + apply Finset.sum_congr rfl + intro c hc + simp only [poolWeight,c.encode_length] + _ = ∑ a∈Finset.univ.image (HardChord.encode (W:=W) (H:=H)),poolWeight a := + (Finset.sum_image (HardChord.encode_injective W H).injOn).symm + _ ≤ _ := (pool_summable W H).sum_le_tsum _ (fun a ha=>poolWeight_nonnegative a) +end CriticalHoneycomb.Transfer.RasterGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ChordTensors.lean b/lean/OAI/Combinatorics/HoneycombChords/ChordTensors.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef5cf210bc3afbbbad223ac0497a0285610a508c --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ChordTensors.lean @@ -0,0 +1,567 @@ +import OAI.Combinatorics.HoneycombChords.Occupancy + +namespace OAI + +/-! +# Orientations and tensor coefficients of chords + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition +open scoped BigOperators + +/-- A literal simple honeycomb path, including its two exterior endpoint +centers. It will be applied only when those endpoints lie outside the rectangle. -/ +structure CenterPath (n : ℕ) where + point : Fin (n+2) → Center + injective : Function.Injective point + side : Fin (n+1) → Fin 3 + step : ∀ i, neighbor (point i.castSucc) (side i)=point i.succ + +def CenterPath.edge {n : ℕ} (p : CenterPath n) (i : Fin (n+1)) : Wire := + incidentWire (p.point i.castSucc) (p.side i) + +lemma CenterPath.edge_injective {n : ℕ} (p : CenterPath n) : Function.Injective p.edge := by + intro i j he + obtain ⟨hs,hv|hv⟩ := (incidentWire_eq_iff _ _ _ _).mp he + · have hi := p.injective hv + exact Fin.ext (congrArg (fun x : Fin (n+2)=>x.val) hi) + · have h1 : p.point i.succ=p.point j.castSucc := (p.step i).symm.trans hv + have h2 : p.point j.succ=p.point i.castSucc := by + rw [←p.step j,←hs,←hv,neighbor_neighbor] + have h1' := congrArg Fin.val (p.injective h1) + have h2' := congrArg Fin.val (p.injective h2) + simp only [Fin.val_succ,Fin.val_castSucc] at h1' h2' + omega + +/-- Spin zero follows the positive source wire direction: west out of an +up center, and middle/south into it. Spin two is the reverse direction. -/ +def outSpin (v : Center) (k : Fin 3) : Fin 3 := + if v.2.2=decide (k=2) then 0 else 2 + +def inSpin (v : Center) (k : Fin 3) : Fin 3 := + if v.2.2=decide (k=2) then 2 else 0 + +lemma outSpin_neighbor (v : Center) (k : Fin 3) : + outSpin (neighbor v k) k=inSpin v k := by + rcases v with ⟨i,j,b⟩ + cases b <;> fin_cases k <;> simp [outSpin,inSpin,neighbor,up,down] + +lemma inSpin_neighbor (v : Center) (k : Fin 3) : + inSpin (neighbor v k) k=outSpin v k := by + rw [←outSpin_neighbor,neighbor_neighbor] + +lemma outSpin_ne_empty (v : Center) (k : Fin 3) : outSpin v k≠1 := by + unfold outSpin; split_ifs <;> decide + +noncomputable def CenterPath.spins {n : ℕ} (p : CenterPath n) : Wire → Fin 3 := + Function.extend p.edge (fun i=>outSpin (p.point i.castSucc) (p.side i)) (fun _=>1) + +lemma CenterPath.spins_edge {n : ℕ} (p : CenterPath n) (i : Fin (n+1)) : + p.spins (p.edge i)=outSpin (p.point i.castSucc) (p.side i) := + p.edge_injective.extend_apply _ _ _ + +lemma CenterPath.spins_off {n : ℕ} (p : CenterPath n) (w : Wire) + (hw : w ∉ Set.range p.edge) : p.spins w=1 := by + exact Function.extend_apply' _ _ _ hw + +def CenterPath.center {n : ℕ} (p : CenterPath n) (i : Fin n) : Center := + p.point i.castSucc.succ + +lemma CenterPath.in_wire {n : ℕ} (p : CenterPath n) (i : Fin n) : + incidentWire (p.center i) (p.side i.castSucc)=p.edge i.castSucc := by + change incidentWire (p.point i.castSucc.succ) _ = _ + rw [←p.step i.castSucc,incidentWire_neighbor] + rfl + +lemma CenterPath.out_wire {n : ℕ} (p : CenterPath n) (i : Fin n) : + incidentWire (p.center i) (p.side i.succ)=p.edge i.succ := by rfl + +lemma CenterPath.sides_distinct {n : ℕ} (p : CenterPath n) (i : Fin n) : + p.side i.castSucc ≠ p.side i.succ := by + intro he + have hw : p.edge i.castSucc=p.edge i.succ := by + rw [←p.in_wire i,←p.out_wire i,he] + have hi := congrArg Fin.val (p.edge_injective hw) + simp only [Fin.val_castSucc,Fin.val_succ] at hi + omega + +lemma CenterPath.incident_edge_iff {n : ℕ} (p : CenterPath n) (i : Fin n) (k : Fin 3) : + incidentWire (p.center i) k ∈ Set.range p.edge ↔ + k=p.side i.castSucc ∨ k=p.side i.succ := by + constructor + · rintro ⟨j,hj⟩ + obtain ⟨hk,he|he⟩ := (incidentWire_eq_iff _ _ _ _).mp hj + · right + have hi : j=i.succ := by + apply Fin.ext + have hh := congrArg Fin.val (p.injective he) + simpa [CenterPath.center] using hh + simpa [hi] using hk.symm + · left + have hi : j=i.castSucc := by + apply Fin.ext + rw [p.step j] at he + have hh := congrArg Fin.val (p.injective he) + simp only [Fin.val_succ,Fin.val_castSucc] at hh + change j.val=i.val + omega + simpa [hi] using hk.symm + · rintro (rfl|rfl) + · exact ⟨i.castSucc,(p.in_wire i).symm⟩ + · exact ⟨i.succ,(p.out_wire i).symm⟩ + +lemma CenterPath.spins_local {n : ℕ} (p : CenterPath n) (i : Fin n) (k : Fin 3) : + p.spins (incidentWire (p.center i) k) = + if k=p.side i.castSucc then inSpin (p.center i) k + else if k=p.side i.succ then outSpin (p.center i) k else 1 := by + split_ifs with hin hout + · subst k + rw [p.in_wire i,p.spins_edge] + change _ = inSpin (p.point i.castSucc.succ) _ + rw [←p.step i.castSucc,inSpin_neighbor] + · subst k + rw [p.out_wire i,p.spins_edge] + rfl + · apply p.spins_off + rw [p.incident_edge_iff] + tauto + +noncomputable def localTensor (v : Center) (s : Fin 3 → Fin 3) : ℂ := + if v.2.2 then upTensor (s 2) (s 1) (s 0) else downTensor (s 2) (s 1) (s 0) + +lemma localTensor_passage_nonzero (v : Center) (a b : Fin 3) (hab : a≠b) : + localTensor v (fun k=>if k=a then inSpin v k else if k=b then outSpin v k else 1) ≠ 0 := by + have hk : (kappa:ℂ) ≠ 0 := by + apply Complex.ofReal_ne_zero.mpr + exact (Real.rpow_pos_of_pos (by positivity : 0<(2+Real.sqrt 2:ℝ)) (-(1:ℝ)/2)).ne' + rcases v with ⟨i,j,t⟩ + cases t <;> fin_cases a <;> fin_cases b <;> + simp_all [localTensor,inSpin,outSpin,upTensor,downTensor,Planar.empty, + Planar.occupied,Planar.cup,Planar.phase_ne_zero] + +/-- The orientation directed along an actual simple center path has nonzero +local weight at every visited center. All positions and slot orders are literal. -/ +theorem CenterPath.center_nonzero {n : ℕ} (p : CenterPath n) (i : Fin n) : + centerTensor p.spins (p.center i) ≠ 0 := by + have he : centerTensor p.spins (p.center i) = localTensor (p.center i) + (fun k=>if k=p.side i.castSucc then inSpin (p.center i) k + else if k=p.side i.succ then outSpin (p.center i) k else 1) := by + unfold centerTensor localTensor + simp_rw [p.spins_local] + rw [he] + exact localTensor_passage_nonzero _ _ _ (p.sides_distinct i) + +lemma localTensor_propagate (v : Center) (a b : Fin 3) (hab : a≠b) (s : Fin 3) : + localTensor v (fun k=>if k=a then inSpin v k else if k=b then s else 1) ≠ 0 ↔ + s=outSpin v b := by + have hk : (kappa:ℂ) ≠ 0 := by + apply Complex.ofReal_ne_zero.mpr + exact (Real.rpow_pos_of_pos (by positivity : 0<(2+Real.sqrt 2:ℝ)) (-(1:ℝ)/2)).ne' + rcases v with ⟨i,j,t⟩ + cases t <;> fin_cases a <;> fin_cases b <;> fin_cases s <;> + simp_all [localTensor,inSpin,outSpin,upTensor,downTensor,Planar.empty, + Planar.occupied,Planar.cup,Planar.phase_ne_zero] + +/-- The local tensor along the actual ordered center path, with two selected +wires and all other wires vacant. -/ +noncomputable def CenterPath.factor {n : ℕ} (p : CenterPath n) (i : Fin n) + (σ : Fin (n+1) → Fin 3) : ℂ := + localTensor (p.center i) (fun k=>if k=p.side i.castSucc then σ i.castSucc + else if k=p.side i.succ then σ i.succ else 1) + +lemma CenterPath.in_direction {n : ℕ} (p : CenterPath n) (i : Fin n) : + outSpin (p.point i.castSucc.castSucc) (p.side i.castSucc)= + inSpin (p.center i) (p.side i.castSucc) := by + change _=inSpin (p.point i.castSucc.succ) _ + rw [←p.step i.castSucc,inSpin_neighbor] + +lemma CenterPath.factor_true {n : ℕ} (p : CenterPath n) (i : Fin n) : + p.factor i (fun j=>outSpin (p.point j.castSucc) (p.side j))= + centerTensor p.spins (p.center i) := by + change p.factor i _ = localTensor (p.center i) (fun k=>p.spins (incidentWire (p.center i) k)) + unfold CenterPath.factor + have he := p.in_direction i + have he' : p.point i.succ.castSucc = p.center i := rfl + dsimp only + rw [he,he'] + congr 1 + funext k + rw [p.spins_local] + split_ifs <;> simp_all + +/-- Orientation propagates along every actual simple center path. Thus the +boundary condition at the first wire determines all occupied wire labels. -/ +theorem CenterPath.orientation_unique {n : ℕ} (p : CenterPath n) + (σ : Fin (n+1) → Fin 3) + (hroot : σ 0=outSpin (p.point 0) (p.side 0)) + (hf : ∀ i, p.factor i σ≠0) : + σ=(fun i=>outSpin (p.point i.castSucc) (p.side i)) := by + funext i + induction i using Fin.induction with + | zero => exact hroot + | succ i ih => + have hh := hf i + unfold CenterPath.factor at hh + rw [ih,p.in_direction i] at hh + have he : (fun k=>if k=p.side i.castSucc then inSpin (p.center i) (p.side i.castSucc) + else if k=p.side i.succ then σ i.succ else 1) = + (fun k=>if k=p.side i.castSucc then inSpin (p.center i) k + else if k=p.side i.succ then σ i.succ else 1) := by + funext k; split_ifs <;> simp_all + rw [he] at hh + have hc := (localTensor_propagate (p.center i) _ _ (p.sides_distinct i) (σ i.succ)).mp hh + exact hc + +/-- Literal finite orientation contraction of the actual path, with fixed +source arrow and the final arrow summed (it will necessarily be the through +arrow). This is not a new abstract kernel substituted for the center model. -/ +noncomputable def CenterPath.orientationSum {n : ℕ} (p : CenterPath n) : ℂ := by + classical + exact ∑ σ : Fin (n+1) → Fin 3, + if σ 0=outSpin (p.point 0) (p.side 0) then ∏ i, p.factor i σ else 0 + +/-- There is exactly one contributing orientation for a loop-free chord. -/ +theorem CenterPath.orientationSum_eq {n : ℕ} (p : CenterPath n) : + p.orientationSum=∏ i, centerTensor p.spins (p.center i) := by + classical + unfold CenterPath.orientationSum + rw [Finset.sum_eq_single (fun i=>outSpin (p.point i.castSucc) (p.side i))] + · simp only [Fin.castSucc_zero] + exact Finset.prod_congr rfl (fun i _=>p.factor_true i) + · intro σ hσ hne + split_ifs with hr + · by_contra hh + exact hne (p.orientation_unique σ hr (fun i=>(Finset.prod_ne_zero_iff.mp hh) i (Finset.mem_univ i))) + · rfl + · simp + +/-- Noncancellation for a literal loop-free honeycomb center chord, rather +than only for an abstract strand or a tensor with assumed coefficient. -/ +theorem CenterPath.orientationSum_ne_zero {n : ℕ} (p : CenterPath n) : + p.orientationSum≠0 := by + rw [p.orientationSum_eq] + exact Finset.prod_ne_zero_iff.mpr (fun i _=>p.center_nonzero i) + +end CriticalHoneycomb.Transfer.ChordOrientations +namespace CriticalHoneycomb.Transfer.ChordOrientations + +variable {D : Set Center} {a b : Port D} + +def extendedTrace (γ : Chord D a b) : List Center := + a.outside :: (γ.val ++ [b.outside]) + +lemma extendedTrace_length (γ : Chord D a b) : + (extendedTrace γ).length=γ.val.length+2 := by simp [extendedTrace,Nat.add_assoc] + +lemma extendedTrace_nodup (γ : Chord D a b) (hab : a.outside≠b.outside) : + (extendedTrace γ).Nodup := by + have ha : a.outside ∉ γ.val := fun h=>a.outside_not_mem (γ.property.1.2.2 _ h) + have hb : b.outside ∉ γ.val := fun h=>b.outside_not_mem (γ.property.1.2.2 _ h) + rw [extendedTrace,List.nodup_cons,List.nodup_append] + refine ⟨by simpa using ⟨ha,hab⟩,γ.property.1.1,by simp,?_⟩ + intro x hx y hy + have he : y=b.outside := by simpa using hy + subst y + intro he + exact hb (he ▸ hx) + +lemma extendedTrace_chain (γ : Chord D a b) : + List.IsChain Adj (extendedTrace γ) := by + have hc : List.IsChain Adj (a.outside::γ.val) := by + rw [List.isChain_cons] + refine ⟨?_,γ.property.1.2.1⟩ + rw [γ.property.2.1] + intro y hy + have he : a.inside=y := Option.mem_some_iff.mp hy + subst y + exact FiniteConfigurations.adj_symmetric a.adjacent + have hn : γ.val≠[] := by + intro he + have hh := γ.property.2.2 + simp [he] at hh + change List.IsChain Adj ((a.outside::γ.val)++[b.outside]) + apply List.IsChain.append hc (by simp) + intro x hx y hy + have hx' : x=b.inside := by + have hh : (a.outside::γ.val).getLast?=some b.inside := by + rw [List.getLast?_cons_of_ne_nil hn,γ.property.2.2] + symm + simpa [hh] using hx + have hy' : y=b.outside := by symm; simpa using hy + subst x; subst y + exact b.adjacent + +/-- Conversion of an actual simple chord (with its unweighted boundary +ports) to the ordered-center model used in the tensor noncancellation proof. -/ +noncomputable def ofChord (γ : Chord D a b) (hab : a.outside≠b.outside) : + CenterPath γ.val.length := by + let x : Fin (γ.val.length+2) → Center := fun i=> + (extendedTrace γ).get ⟨i.val,by rw [extendedTrace_length]; exact i.isLt⟩ + have hinj : Function.Injective x := by + intro i j he + have hh := (extendedTrace_nodup γ hab).get_inj_iff.mp he + exact Fin.ext (congrArg (fun z : Fin (extendedTrace γ).length=>z.val) hh) + have hc (i : Fin (γ.val.length+1)) : Adj (x i.castSucc) (x i.succ) := by + exact (List.isChain_iff_getElem.mp (extendedTrace_chain γ)) i.val + (by rw [extendedTrace_length]; omega) + exact ⟨x,hinj,fun i=>((adj_iff_neighbor _ _).mp (hc i)).choose, + fun i=>((adj_iff_neighbor _ _).mp (hc i)).choose_spec⟩ + +lemma ofChord_point (γ : Chord D a b) (hab : a.outside≠b.outside) + (i : Fin (γ.val.length+2)) : + (ofChord γ hab).point i=(extendedTrace γ)[i.val]'(by rw [extendedTrace_length]; exact i.isLt) := rfl + +lemma ofChord_center (γ : Chord D a b) (hab : a.outside≠b.outside) + (i : Fin γ.val.length) : (ofChord γ hab).center i=γ.val[i.val] := by + rw [CenterPath.center,ofChord_point] + simp only [Fin.val_succ,Fin.val_castSucc,extendedTrace,List.getElem_cons_succ] + exact List.getElem_append_left i.isLt + +/-- The already defined source Chord has a nonzero exact center-tensor +orientation coefficient. This identifies the finite transfer coefficient with its path contribution. -/ +theorem chord_orientation_nonzero (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).orientationSum ≠ 0 := + (ofChord γ hab).orientationSum_ne_zero + +end CriticalHoneycomb.Transfer.ChordOrientations +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles CenterPartition +open scoped BigOperators + +lemma CenterPath.local_of_support {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (hs : ∀ w, w ∉ Set.range p.edge → σ w=1) (i : Fin n) (k : Fin 3) : + σ (incidentWire (p.center i) k) = + if k=p.side i.castSucc then σ (p.edge i.castSucc) + else if k=p.side i.succ then σ (p.edge i.succ) else 1 := by + split_ifs with hin hout + · subst k; rw [p.in_wire] + · subst k; rw [p.out_wire] + · apply hs + rw [p.incident_edge_iff] + tauto + +lemma CenterPath.factor_of_support {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (hs : ∀ w, w ∉ Set.range p.edge → σ w=1) (i : Fin n) : + centerTensor σ (p.center i)=p.factor i (fun j=>σ (p.edge j)) := by + change localTensor _ (fun k=>σ (incidentWire (p.center i) k))=_ + unfold CenterPath.factor + congr 1 + funext k + exact p.local_of_support σ hs i k + +/-- Uniqueness concerns the actual full honeycomb wire assignment, not only +the ordered list of path coefficients. Vacant wires are fixed to spin one. -/ +theorem CenterPath.full_orientation_unique {n : ℕ} (p : CenterPath n) (σ : Wire → Fin 3) + (hs : ∀ w, w ∉ Set.range p.edge → σ w=1) + (hroot : σ (p.edge 0)=outSpin (p.point 0) (p.side 0)) + (hn : ∀ i, centerTensor σ (p.center i)≠0) : σ=p.spins := by + have he := p.orientation_unique (fun j=>σ (p.edge j)) hroot (by + intro i + rw [←p.factor_of_support σ hs i] + exact hn i) + funext w + by_cases hw : w∈Set.range p.edge + · obtain ⟨i,rfl⟩ := hw + rw [p.spins_edge] + exact congrFun he i + · rw [hs w hw,p.spins_off w hw] + +lemma CenterPath.point_cases {n : ℕ} (p : CenterPath n) (j : Fin (n+2)) : + p.point j=p.point 0 ∨ p.point j=p.point (Fin.last (n+1)) ∨ + ∃ i : Fin n, p.point j=p.center i := by + cases j using Fin.cases with + | zero => exact Or.inl rfl + | succ j => + cases j using Fin.lastCases with + | last => exact Or.inr (Or.inl rfl) + | cast i => exact Or.inr (Or.inr ⟨i,rfl⟩) + +lemma CenterPath.incident_off {n : ℕ} (p : CenterPath n) (v : Center) + (h0 : v≠p.point 0) (hl : v≠p.point (Fin.last (n+1))) + (hv : v∉Set.range p.center) (k : Fin 3) : + incidentWire v k ∉ Set.range p.edge := by + rintro ⟨j,hj⟩ + obtain ⟨hk,hleft|hright⟩ := (incidentWire_eq_iff _ _ _ _).mp hj + · rcases p.point_cases j.castSucc with he|he|⟨i,he⟩ + · exact h0 (hleft.symm.trans he) + · exact hl (hleft.symm.trans he) + · exact hv ⟨i,(hleft.symm.trans he).symm⟩ + · rw [p.step j] at hright + rcases p.point_cases j.succ with he|he|⟨i,he⟩ + · exact h0 (hright.symm.trans he) + · exact hl (hright.symm.trans he) + · exact hv ⟨i,(hright.symm.trans he).symm⟩ + +lemma CenterPath.off_center_one {n : ℕ} (p : CenterPath n) (v : Center) + (h0 : v≠p.point 0) (hl : v≠p.point (Fin.last (n+1))) + (hv : v∉Set.range p.center) : centerTensor p.spins v=1 := by + have hs (k : Fin 3) : p.spins (incidentWire v k)=1 := + p.spins_off _ (p.incident_off v h0 hl hv k) + unfold centerTensor + simp only [hs] + split <;> simp [upTensor,downTensor,Planar.empty,Planar.occupied,Planar.cup] + +lemma CenterPath.product_nonzero {n : ℕ} (p : CenterPath n) (D : Finset Center) + (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) : + centerProduct D p.spins≠0 := by + classical + apply Finset.prod_ne_zero_iff.mpr + intro v hv + by_cases hc : v∈Set.range p.center + · obtain ⟨i,rfl⟩ := hc + exact p.center_nonzero i + · rw [p.off_center_one v (fun he=>h0 (he ▸ hv)) (fun he=>hl (he ▸ hv)) hc] + exact one_ne_zero + +noncomputable def extendFiniteSpins (V : Finset Wire) (σ : V → Fin 3) : Wire → Fin 3 := + fun w=>if h : w∈V then σ ⟨w,h⟩ else 1 + +lemma extendFiniteSpins_at (V : Finset Wire) (σ : V → Fin 3) (w : V) : + extendFiniteSpins V σ w=σ w := by simp [extendFiniteSpins] + +lemma CenterPath.extend_restrict {n : ℕ} (p : CenterPath n) (V : Finset Wire) + (he : ∀ i, p.edge i∈V) : + extendFiniteSpins V (fun w=>p.spins w)=p.spins := by + funext w + unfold extendFiniteSpins + split_ifs with hw + · rfl + · symm + apply p.spins_off + rintro ⟨i,rfl⟩ + exact hw (he i) + +/-- Exact finite center contraction restricted to the occupied set of one +literal chord. Vacant wires have the actual spin one; the first boundary +arrow is fixed. No orientation coefficient has been supplied as an input. -/ +noncomputable def CenterPath.finiteContraction {n : ℕ} (p : CenterPath n) + (D : Finset Center) (V : Finset Wire) : ℂ := by + classical + exact ∑ σ : V → Fin 3, + if (∀ w : V, w.val ∉ Set.range p.edge → σ w=1) ∧ + extendFiniteSpins V σ (p.edge 0)=outSpin (p.point 0) (p.side 0) + then centerProduct D (extendFiniteSpins V σ) else 0 + +/-- The physical full-wire finite contraction is just its single directed +path term. This binds noncancellation to actual center products on a domain. -/ +theorem CenterPath.finiteContraction_eq {n : ℕ} (p : CenterPath n) + (D : Finset Center) (V : Finset Wire) + (he : ∀ i, p.edge i∈V) (hc : ∀ i, p.center i∈D) : + p.finiteContraction D V=centerProduct D p.spins := by + classical + unfold CenterPath.finiteContraction + rw [Finset.sum_eq_single (fun w : V=>p.spins w)] + · have hs : ∀ w : V, w.val ∉ Set.range p.edge → p.spins w=1 := fun w h=>p.spins_off w h + rw [p.extend_restrict V he] + simp only [p.spins_edge,Fin.castSucc_zero,and_true] + exact ite_eq_left hs + · intro σ hσ hne + split_ifs with hbound + · by_contra hn + have hs : ∀ w, w∉Set.range p.edge → extendFiniteSpins V σ w=1 := by + intro w hw + unfold extendFiniteSpins + split_ifs with hm + · exact hbound.1 ⟨w,hm⟩ hw + · rfl + have hu := p.full_orientation_unique (extendFiniteSpins V σ) hs hbound.2 (by + intro i + exact (Finset.prod_ne_zero_iff.mp hn) (p.center i) (hc i)) + apply hne + funext w + have hh := congrFun hu w.val + simpa only [extendFiniteSpins_at] using hh + · rfl + · simp + +/-- Exact noncancellation of the loop-free component inside any containing +finite domain excluding its two exterior endpoints. -/ +theorem CenterPath.finiteContraction_ne_zero {n : ℕ} (p : CenterPath n) + (D : Finset Center) (V : Finset Wire) + (he : ∀ i, p.edge i∈V) (hc : ∀ i, p.center i∈D) + (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) : + p.finiteContraction D V≠0 := by + rw [p.finiteContraction_eq D V he hc] + exact p.product_nonzero D h0 hl + +end CriticalHoneycomb.Transfer.ChordOrientations +namespace CriticalHoneycomb.Transfer.PhysicalTiles +open Planar +open scoped BigOperators + +noncomputable def maskedCell (q : Shape) (w n s e : Fin 3) : ℂ := by + classical + exact if spinOccupied w=q.selection.west ∧ spinOccupied n=q.selection.north ∧ + spinOccupied s=q.selection.south ∧ spinOccupied e=q.selection.east then + ∑ m : Fin 3, if spinOccupied m=q.selection.middle then + upTensor w s m * downTensor e n m else 0 else 0 + +lemma maskedCell_empty (w n s e : Fin 3) : + maskedCell .empty w n s e=(kappa:ℂ)^(Shape.visits .empty) * shapeTensor .empty w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,vacant,occupied,Planar.empty,cup,] + +lemma maskedCell_westSouth (w n s e : Fin 3) : + maskedCell .westSouth w n s e=(kappa:ℂ)^(Shape.visits .westSouth) * shapeTensor .westSouth w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,vacant,occupied,Planar.empty,cup,] + +lemma maskedCell_northEast (w n s e : Fin 3) : + maskedCell .northEast w n s e=(kappa:ℂ)^(Shape.visits .northEast) * shapeTensor .northEast w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,vacant,occupied,Planar.empty,cup,] + +lemma maskedCell_both (w n s e : Fin 3) : + maskedCell .both w n s e=(kappa:ℂ)^(Shape.visits .both) * shapeTensor .both w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,occupied,Planar.empty,cup,] <;> ring + +lemma maskedCell_westNorth (w n s e : Fin 3) : + maskedCell .westNorth w n s e=(kappa:ℂ)^(Shape.visits .westNorth) * shapeTensor .westNorth w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,occupied,Planar.empty,cup,Fin.sum_univ_three] <;> ring + +lemma maskedCell_southEast (w n s e : Fin 3) : + maskedCell .southEast w n s e=(kappa:ℂ)^(Shape.visits .southEast) * shapeTensor .southEast w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,occupied,Planar.empty,cup,Fin.sum_univ_three] <;> ring + +lemma maskedCell_westEast (w n s e : Fin 3) : + maskedCell .westEast w n s e=(kappa:ℂ)^(Shape.visits .westEast) * shapeTensor .westEast w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,occupied,Planar.empty,cup,Fin.sum_univ_three] <;> ring + +lemma maskedCell_northSouth (w n s e : Fin 3) : + maskedCell .northSouth w n s e=(kappa:ℂ)^(Shape.visits .northSouth) * shapeTensor .northSouth w n s e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [maskedCell,shapeTensor,Shape.selection,Shape.visits,spinOccupied, + upTensor,downTensor,occupied,Planar.empty,cup,Fin.sum_univ_three] <;> ring_nf <;> simp [phase_ne_zero] + +/-- The fixed physical occupancy term is exactly the source shape tensor, +including its two center weights and its actual middle-edge contraction. -/ +theorem maskedCell_eq (q : Shape) (w n s e : Fin 3) : + maskedCell q w n s e=(kappa:ℂ)^q.visits * shapeTensor q w n s e := by + cases q + · exact maskedCell_empty w n s e + · exact maskedCell_westSouth w n s e + · exact maskedCell_northEast w n s e + · exact maskedCell_both w n s e + · exact maskedCell_westNorth w n s e + · exact maskedCell_southEast w n s e + · exact maskedCell_westEast w n s e + · exact maskedCell_northSouth w n s e + +end CriticalHoneycomb.Transfer.PhysicalTiles + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ClosedFusion.lean b/lean/OAI/Combinatorics/HoneycombChords/ClosedFusion.lean new file mode 100644 index 0000000000000000000000000000000000000000..b33680f7b41ca10b791cb66d6e36391e13056a1d --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ClosedFusion.lean @@ -0,0 +1,1542 @@ +import OAI.Combinatorics.HoneycombChords.StripProjection + +namespace OAI + +/-! Closed spectral fusion and its physical specialization. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet ClosedFourRow RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma Q_at_L : Q L=(Real.cos L : ℂ) := by + unfold Q + rw [show Real.pi/4+L=3*L by unfold L;ring, + show b+L=4*L by unfold b L;ring] + change ((Real.sin (3*CriticalHoneycombTransfer.L):ℂ)* + (Real.sin (4*CriticalHoneycombTransfer.L):ℂ))=_ + rw [CriticalHoneycombTransfer.sin_three_L,CriticalHoneycombTransfer.sin_four_L] + simp only [Complex.ofReal_one,mul_one] + rfl +lemma Q_at_L_ne_zero : Q L≠0 := by + rw [Q_at_L,Complex.ofReal_ne_zero] + exact ne_of_gt CriticalHoneycombTransfer.cos_L_pos +lemma physicalR_binding : spectralR L=fun p q=> + Planar.sourceR (kappa:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) 0 p q := by + rw [spectralR_normalized L Q_at_L_ne_zero] + have hw : Transfer.a L=kappa ∧ Transfer.h L=kappa^2 ∧ Transfer.v L=kappa^2 ∧ + Transfer.c L=kappa^2 ∧ Transfer.d L=0 := CriticalHoneycombTransfer.physical_weights + have hp : Transfer.phase=Planar.phase := rfl + funext p q + rcases p with ⟨a,b⟩;rcases q with ⟨c,d⟩ + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d <;> + simp [normalizedR,Planar.sourceR,hw.1,hw.2.1,hw.2.2.1,hw.2.2.2.1,hw.2.2.2.2,hp] +noncomputable def reverseSites (n : ℕ) : Space n≃Space n where + toFun x i:=x i.rev + invFun x i:=x i.rev + left_inv x:=by funext i;simp + right_inv x:=by funext i;simp +lemma reverseSites_apply (n : ℕ) (x : Space n) (i : Fin n) : + reverseSites n x i=x i.rev := rfl +lemma row_eq_product (n : ℕ) (A : Fin n→Local) (s t : Space n) : + row n A s t=(List.ofFn (fun i=>block (A i) (s i) (t i))).prod := by + induction n with + | zero => simp [row] + | succ n ih => rw [row,List.ofFn_succ,List.prod_cons,ih];rfl +lemma row_eq_matrixPath (n : ℕ) (A : Fin n→Local) (s t : Space n) (a b : Spin) : + row n A s t a b=matrixPath (fun i=>block (A i) (s i) (t i)) a b := by + rw [matrixPath_eq_prod,row_eq_product] +lemma cons_reverseSites (n : ℕ) (a : Spin) (v : Space n) (i : Fin (n+1)) : + Fin.cons (α:=fun _=>Spin) a (reverseSites n v) i=Fin.snoc (α:=fun _=>Spin) v a i.rev := by + exact (Fin.snoc_rev a v i).symm +lemma physical_row_kernel (n : ℕ) (w e : Space n) (a b : Spin) : + row n (fun _=>spectralR L) (reverseSites n w) (reverseSites n e) a b= + columnKernel n b a w e := by + rw [row_eq_matrixPath] + unfold matrixPath + rw [←(reverseSites n).sum_comp] + unfold columnKernel + apply Finset.sum_congr rfl + intro v hv + simp only [cons_reverseSites,Fin.rev_last,reverseSites_apply] + split_ifs with h + · unfold columnProduct + rw [←Equiv.prod_comp (Fin.revPerm (n:=n))] + apply Finset.prod_congr rfl + intro j hj + simp only [Fin.revPerm_apply,Fin.rev_rev,Fin.rev_castSucc,block,physicalR_binding] + · rfl +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.BoundaryJet +noncomputable def reflected (a : Jet) : Jet := + form (star (base a)) (star (right a)) (star (left a)) (star (both a)) +@[simp] lemma reflected_base (a : Jet) : base (reflected a)=star (base a) := base_form _ _ _ _ +@[simp] lemma reflected_left (a : Jet) : left (reflected a)=star (right a) := left_form _ _ _ _ +@[simp] lemma reflected_right (a : Jet) : right (reflected a)=star (left a) := right_form _ _ _ _ +@[simp] lemma reflected_both (a : Jet) : both (reflected a)=star (both a) := both_form _ _ _ _ +lemma reflected_involutive : Function.Involutive reflected := by + intro a + apply jet_ext <;> simp +noncomputable def reflectJet : Jet ≃+* Jet where + toFun:=reflected + invFun:=reflected + left_inv:=reflected_involutive + right_inv:=reflected_involutive + map_add' a b:=by apply jet_ext <;> simp + map_mul' a b:=by apply jet_ext <;> simp ; ring +lemma reflectJet_apply (a : Jet) : reflectJet a=reflected a := rfl +@[simp] lemma reflectJet_C (z : ℂ) : reflectJet (C z)=C (star z) := by + rw [reflectJet_apply] + apply jet_ext <;> simp only [reflected_base,reflected_left, + reflected_right,reflected_both,base_C,left_C,right_C,both_C,star_zero] +@[simp] lemma reflectJet_eL : reflectJet eL=eR := by + rw [reflectJet_apply] + apply jet_ext <;> + simp only [reflected_base,reflected_left,reflected_right,reflected_both] <;> + norm_num [base,left,right,both,eL,eR] +@[simp] lemma reflectJet_eR : reflectJet eR=eL := by + rw [reflectJet_apply] + apply jet_ext <;> + simp only [reflected_base,reflected_left,reflected_right,reflected_both] <;> + norm_num [base,left,right,both,eL,eR] +end CriticalHoneycomb.BoundaryJet + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma bulk_spin_star_0 (u : ℝ) (b c d : Spin) : + bulkNumerator u ((0:Spin).rev,b.rev) (c.rev,d.rev)= + star (bulkNumerator u (0,b) (c,d)) := by + fin_cases b <;> fin_cases c <;> fin_cases d <;> + simp [bulkNumerator,Fin.rev,coeffA,coeffH,coeffV,coeffC,coeffD,S, + Fusion.sine_star,Fusion.phase_star] +lemma bulk_spin_star_1 (u : ℝ) (b c d : Spin) : + bulkNumerator u ((1:Spin).rev,b.rev) (c.rev,d.rev)= + star (bulkNumerator u (1,b) (c,d)) := by + fin_cases b <;> fin_cases c <;> fin_cases d <;> + simp [bulkNumerator,Fin.rev,coeffA,coeffH,coeffV,Q,S, + Fusion.sine_star,Fusion.phase_star] + all_goals try ring +lemma bulk_spin_star_2 (u : ℝ) (b c d : Spin) : + bulkNumerator u ((2:Spin).rev,b.rev) (c.rev,d.rev)= + star (bulkNumerator u (2,b) (c,d)) := by + fin_cases b <;> fin_cases c <;> fin_cases d <;> + simp [bulkNumerator,Fin.rev,coeffA,coeffH,coeffV,coeffC,coeffD,S, + Fusion.sine_star,Fusion.phase_star] + all_goals try ring +lemma spectralR_spin_star (u : ℝ) (a b c d : Spin) : + spectralR u (a.rev,b.rev) (c.rev,d.rev)=star (spectralR u (a,b) (c,d)) := by + have hQ : star ((Q u)⁻¹)=(Q u)⁻¹ := by simp [Q,Fusion.sine_star] + simp only [spectralR,Matrix.smul_apply,smul_eq_mul,star_mul,hQ] + have h : bulkNumerator u (a.rev,b.rev) (c.rev,d.rev)= + star (bulkNumerator u (a,b) (c,d)) := by + fin_cases a + · exact bulk_spin_star_0 u b c d + · exact bulk_spin_star_1 u b c d + · exact bulk_spin_star_2 u b c d + rw [h,mul_comm] +noncomputable def flipSites (n : ℕ) : Space n≃Space n := + Equiv.piCongrRight (fun _=>Fusion.spinFlip) +@[simp] lemma flipSites_apply (n : ℕ) (w : Space n) (i : Fin n) : + flipSites n w i=(w i).rev := rfl +lemma row_spin_star (n : ℕ) (u : ℝ) (w e : Space n) (a b : Spin) : + row n (fun _=>spectralR u) (flipSites n w) (flipSites n e) a.rev b.rev= + star (row n (fun _=>spectralR u) w e a b) := by + induction n generalizing a b with + | zero => simp [row,Matrix.one_apply] + | succ n ih => + simp only [row,Matrix.mul_apply] + rw [star_sum] + rw [←Equiv.sum_comp Fusion.spinFlip] + apply Finset.sum_congr rfl + intro z hz + change spectralR u (a.rev,(w 0).rev) (z.rev,(e 0).rev)* + row n (fun _=>spectralR u) (flipSites n (fun i=>w i.succ)) + (flipSites n (fun i=>e i.succ)) z.rev b.rev=_ + rw [spectralR_spin_star,ih] + simp only [star_mul,mul_comm,block] + rfl +noncomputable def reflectedSites (n : ℕ) : Space n≃Space n := + (flipSites n).trans (reverseSites n) +lemma physical_reflected_row (n : ℕ) (w e : Space n) (a b : Spin) : + row n (fun _=>spectralR L) (reflectedSites n w) (reflectedSites n e) a.rev b.rev= + star (columnKernel n b a w e) := by + have h : ∀ x : Space n, reflectedSites n x=flipSites n (reverseSites n x) := by + intro x; rfl + rw [h,h,row_spin_star,physical_row_kernel] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def homogeneous (n : ℕ) : Fin n→ℝ := fun _=>-L/2 +lemma b_sub_gamma : b-gamma=gamma := by unfold b gamma;ring +lemma gamma_homogeneous (n : ℕ) (i : Fin n) : gamma+homogeneous n i=L := by + unfold gamma homogeneous L;ring +lemma sine_twice_gamma_ne_zero : sine (2*gamma)≠0 := by + apply Complex.ofReal_ne_zero.mpr + apply ne_of_gt + apply Real.sin_pos_of_pos_of_lt_pi <;> unfold gamma <;> linarith [Real.pi_pos] +lemma homogeneous_nonsingular (n : ℕ) : Nonsingular n (homogeneous n) gamma := by + rw [Nonsingular,b_sub_gamma] + refine ⟨?_,?_,fun i=>?_⟩ + · convert sine_twice_gamma_ne_zero using 1 ; congr 1 ; ring + · convert sine_twice_gamma_ne_zero using 1 ; congr 1 ; ring + · rw [gamma_homogeneous] + exact ⟨Q_at_L_ne_zero,Q_at_L_ne_zero⟩ +noncomputable def positiveK (e : Jet) (a b : Spin) : Jet := + physicalMarkedK e (spinEquiv.symm a) (spinEquiv.symm b) +lemma positiveK_binding (e : Jet) (a b : Spin) : + K e gamma (a.rev,b.rev)=positiveK e a b := by + have h : sine (gamma+gamma)=sine (2*gamma) := by congr 1;ring + have hp : Reflection.phase≠0 := point_ne_zero _ + have hz : sine 0=0 := by simp [sine] + fin_cases a <;> fin_cases b <;> + simp [K,K0,K1,boundary0,boundary1,positiveK,spinEquiv, + physicalMarkedK,Fin.rev,spinValue,h,sine_twice_gamma_ne_zero,hz,hp] +lemma reflect_positiveK (e : Jet) (a b : Spin) : + reflectJet (positiveK e a b)=positiveK (reflectJet e) a b := by + fin_cases a <;> fin_cases b <;> + simp [positiveK,spinEquiv,physicalMarkedK] +lemma markedDoubleMatrix_fin (n : ℕ) (w e : Space n) : + markedDoubleMatrix n w e= + ∑ s₁ : Spin,∑ s₂ : Spin,∑ z₁ : Spin,∑ z₂ : Spin, + positiveK eL s₁ s₂*positiveK eR z₁ z₂* + C ((columnKernel n s₁ z₁*columnKernel n s₂ z₂) w e) := by + simp only [markedDoubleMatrix,fixedDoubleMatrix_eq] + simp only [←Equiv.sum_comp spinEquiv] + simp only [positiveK,Equiv.symm_apply_apply] +lemma markedDoubleMatrix_pair (n : ℕ) (w e : Space n) : + markedDoubleMatrix n w e=∑ p : Pair,∑ q : Pair, + positiveK eL p.1 p.2*positiveK eR q.1 q.2* + C ((columnKernel n p.1 q.1*columnKernel n p.2 q.2) w e) := by + rw [markedDoubleMatrix_fin] + simp only [Fintype.sum_prod_type] +lemma physical_bulkRows (n : ℕ) (w e : Space n) (a b c d : Spin) : + bulkRows n (homogeneous n) gamma (reflectedSites n w) (reflectedSites n e) + (a.rev,b.rev) (c.rev,d.rev)= + star ((columnKernel n c a*columnKernel n d b) w e) := by + have hs : exactSites n (homogeneous n) gamma=fun _=>spectralR L := by + funext i + simp only [exactSites,gamma_homogeneous] + simp only [bulkRows,b_sub_gamma,hs,forward,Matrix.sum_apply,Matrix.kronecker,Matrix.kroneckerMap,Matrix.of_apply,Matrix.mul_apply,star_sum] + rw [←Equiv.sum_comp (reflectedSites n)] + apply Finset.sum_congr rfl + intro v hv + rw [physical_reflected_row,physical_reflected_row] + simp only [star_mul,mul_comm] +noncomputable def physicalFamily (n : ℕ) (u : ℝ) : Matrix (Space n) (Space n) Jet := + ((T n (homogeneous n) u).submatrix (reflectedSites n) (reflectedSites n)).map reflectJet +lemma physicalFamily_at_gamma (n : ℕ) : physicalFamily n gamma=markedDoubleMatrix n := by + funext w e + change reflectJet (T n (homogeneous n) gamma (reflectedSites n w) (reflectedSites n e))=_ + rw [markedDoubleMatrix_pair] + conv_rhs => rw [Finset.sum_comm] + simp only [T,b_sub_gamma,RingEquiv.map_sum,RingEquiv.map_mul,reflectJet_C] + rw [←Equiv.sum_comp (Equiv.prodCongr Fusion.spinFlip Fusion.spinFlip)] + apply Finset.sum_congr rfl + intro p hp + rw [←Equiv.sum_comp (Equiv.prodCongr Fusion.spinFlip Fusion.spinFlip)] + apply Finset.sum_congr rfl + intro q hq + rcases p with ⟨a,b⟩ + rcases q with ⟨c,d⟩ + simp only [Equiv.prodCongr_apply,Prod.map_apply,Fusion.spinFlip_apply,positiveK_binding, + reflect_positiveK,reflectJet_eL,reflectJet_eR,physical_bulkRows,star_star] + ring +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.FusionContraction +open scoped Matrix +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +variable {k n m a b : Type*} [CommSemiring k] +variable [Fintype n] [Fintype m] [Fintype a] [Fintype b] +variable [DecidableEq n] [DecidableEq m] [DecidableEq a] [DecidableEq b] +noncomputable def contract (L R : Matrix n m k) (P : Matrix n n k) (Q : Matrix m m k) : k := + Matrix.trace (Lᵀ*P*R*Qᵀ) +omit [Fintype m] [Fintype a] [DecidableEq n] [DecidableEq m] [DecidableEq a] [DecidableEq b] in +lemma output_transpose (W : Matrix n a k) (Z : Matrix b m k) + (L : Matrix n m k) (l : Matrix a b k) (h : Wᵀ*L=l*Z) : + Lᵀ*W=Zᵀ*lᵀ := by + simpa only [Matrix.transpose_mul,Matrix.transpose_transpose] using congrArg Matrix.transpose h +omit [DecidableEq m] [DecidableEq b] in +lemma quotient_transpose (Z : Matrix b m k) (Q : Matrix m m k) (G : Matrix b b k) + (h : Z*Q=G*Z) : Qᵀ*Zᵀ=Zᵀ*Gᵀ := by + simpa only [Matrix.transpose_mul] using congrArg Matrix.transpose h + +omit [DecidableEq n] [DecidableEq m] [DecidableEq b] in +theorem range_compression + (W : Matrix n a k) (J : Matrix a n k) (Z : Matrix b m k) + (P : Matrix n n k) (Q : Matrix m m k) (F : Matrix a a k) (G : Matrix b b k) + (L R : Matrix n m k) (l r : Matrix a b k) + (hJ : J*W=1) (hP : W*J*P=P) (hF : P*W=W*F) (hG : Z*Q=G*Z) + (hL : Wᵀ*L=l*Z) (hR : R*Zᵀ=W*r) : + contract L R P Q=contract l r F G := by + have hLT := output_transpose W Z L l hL + have hGT := quotient_transpose Z Q G hG + unfold contract + calc + _ = Matrix.trace (Lᵀ*(W*J*P)*R*Qᵀ) := by rw [hP] + _ = Matrix.trace (Zᵀ*(lᵀ*J*P*R*Qᵀ)) := by + simp only [←Matrix.mul_assoc,hLT] + _ = Matrix.trace ((lᵀ*J*P*R*Qᵀ)*Zᵀ) := Matrix.trace_mul_comm _ _ + _ = Matrix.trace (lᵀ*J*P*(R*Zᵀ)*Gᵀ) := by + simp only [Matrix.mul_assoc,hGT] + _ = Matrix.trace (lᵀ*J*(P*W)*r*Gᵀ) := by + rw [hR]; simp only [Matrix.mul_assoc] + _ = Matrix.trace (lᵀ*(J*W)*F*r*Gᵀ) := by + rw [hF]; simp only [Matrix.mul_assoc] + _ = _ := by rw [hJ,Matrix.mul_one] + +omit [DecidableEq n] [DecidableEq m] [DecidableEq a] in +theorem quotient_compression + (W : Matrix n a k) (Z : Matrix b m k) (V : Matrix m b k) + (P : Matrix n n k) (Q : Matrix m m k) (F : Matrix a a k) (G : Matrix b b k) + (L R : Matrix n m k) (l r : Matrix a b k) + (hV : Z*V=1) (hQ : Q*V*Z=Q) (hF : P*W=W*F) (hG : Z*Q=G*Z) + (hL : Wᵀ*L=l*Z) (hR : R*Zᵀ=W*r) : + contract L R P Q=contract l r F G := by + have hLT := output_transpose W Z L l hL + have hGT := quotient_transpose Z Q G hG + have hQ' : Qᵀ=Zᵀ*Vᵀ*Qᵀ := by + simpa only [Matrix.transpose_mul,Matrix.mul_assoc] using + (congrArg Matrix.transpose hQ).symm + have hV' : Vᵀ*Zᵀ=1 := by + simpa only [Matrix.transpose_mul,Matrix.transpose_one] using congrArg Matrix.transpose hV + unfold contract + calc + _ = Matrix.trace (Lᵀ*P*R*(Zᵀ*Vᵀ*Qᵀ)) := by + conv_lhs => rw [hQ'] + _ = Matrix.trace (Lᵀ*P*(R*Zᵀ)*Vᵀ*Qᵀ) := by simp only [Matrix.mul_assoc] + _ = Matrix.trace ((Lᵀ*W)*(F*r*Vᵀ*Qᵀ)) := by + rw [hR] + calc + _ = Matrix.trace (Lᵀ*(P*W)*r*Vᵀ*Qᵀ) := by simp only [Matrix.mul_assoc] + _ = _ := by rw [hF]; simp only [Matrix.mul_assoc] + _ = Matrix.trace (Zᵀ*(lᵀ*F*r*Vᵀ*Qᵀ)) := by + rw [hLT]; simp only [Matrix.mul_assoc] + _ = Matrix.trace ((lᵀ*F*r*Vᵀ*Qᵀ)*Zᵀ) := Matrix.trace_mul_comm _ _ + _ = Matrix.trace ((lᵀ*F*r)*(Vᵀ*Zᵀ)*Gᵀ) := by + simp only [Matrix.mul_assoc,hGT] + _ = _ := by rw [hV',Matrix.mul_one] +end CriticalHoneycomb.Transfer.FusionContraction + +end + +section + +namespace CriticalHoneycomb.Transfer.ClosedFourRow +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +variable {α ι k : Type*} [CommSemiring k] [Fintype α] [DecidableEq α] + [Fintype ι] [DecidableEq ι] +def rotateAux : Aux α ≃ Aux α where + toFun p := (p.2.1,p.2.2.1,p.1,p.2.2.2) + invFun p := (p.2.2.1,p.1,p.2.1,p.2.2.2) + left_inv p := by rcases p with ⟨a,b,c,d⟩;rfl + right_inv p := by rcases p with ⟨a,b,c,d⟩;rfl +def rotateSite : AuxSite α ι ≃ AuxSite α ι := + Equiv.prodCongr rotateAux (Equiv.refl ι) +omit [Fintype α] [Fintype ι] [DecidableEq ι] in +lemma rotate_rowA (M : Row α ι k) : + (rowA M).submatrix rotateSite rotateSite=rowB M := by + funext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [Matrix.submatrix,rowA,rowB,rotateSite,rotateAux,Matrix.one_apply,mul_ite] + all_goals split_ifs <;> simp_all +omit [Fintype α] [Fintype ι] [DecidableEq ι] in +lemma rotate_rowB (M : Row α ι k) : + (rowB M).submatrix rotateSite rotateSite=rowC M := by + funext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [Matrix.submatrix,rowB,rowC,rotateSite,rotateAux,Matrix.one_apply,mul_ite] + all_goals split_ifs <;> simp_all +omit [Fintype α] [Fintype ι] [DecidableEq ι] in +lemma rotate_rowC (M : Row α ι k) : + (rowC M).submatrix rotateSite rotateSite=rowA M := by + funext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [Matrix.submatrix,rowC,rowA,rotateSite,rotateAux,Matrix.one_apply,mul_ite] +omit [Fintype α] [Fintype ι] [DecidableEq ι] in +lemma rotate_rowD (M : Row α ι k) : + (rowD M).submatrix rotateSite rotateSite=rowD M := by + funext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [Matrix.submatrix,rowD,rotateSite,rotateAux,Matrix.one_apply,mul_ite] + all_goals split_ifs <;> simp_all +omit [DecidableEq α] in +lemma close4_rotate (l r : Aux α→k) (X : Total α ι k) : + close4 l r X=close4 (l ∘ rotateAux) (r ∘ rotateAux) + (X.submatrix rotateSite rotateSite) := by + have hl : (leftWall (l ∘ rotateAux) : Matrix ι (AuxSite α ι) k)= + (leftWall l).submatrix id rotateSite := rfl + have hr : (rightWall (r ∘ rotateAux) : Matrix (AuxSite α ι) ι k)= + (rightWall r).submatrix rotateSite id := rfl + simp only [close4,hl,hr,Matrix.submatrix_mul_equiv,Matrix.submatrix_id_id] +omit [DecidableEq ι] in +lemma pairAB_backward (M N : Row α ι k) : rowB N*rowA M=pairAB (backwardPair M N) := by + funext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowA,rowB,pairAB,backwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply,mul_comm] + all_goals split_ifs <;> simp_all +lemma auxBC_mul (F G : Matrix (α×α) (α×α) k) : auxBC (F*G)=auxBC F*auxBC G := by + funext ⟨a,b,c,d⟩ ⟨a',b',c',d'⟩ + simp [auxBC,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply,mul_ite,ite_mul] +omit [Fintype α] in +lemma auxBC_one : auxBC (1 : Matrix (α×α) (α×α) k)=1 := by + funext ⟨a,b,c,d⟩ ⟨a',b',c',d'⟩ + simp only [auxBC,Matrix.one_apply,Prod.mk.injEq] + all_goals split_ifs <;> simp_all +lemma middle_close (A B C D : Row α ι k) (F G : Matrix (α×α) (α×α) k) + (hGF : G*F=1) + (h : ∀ s t,F*forwardPair C A s t=backwardPair C A s t*F) + (l₁ l₂ r₁ r₂ : α×α→k) : + closePair (forwardPair B C) l₁ r₁*closePair (forwardPair A D) l₂ r₂= + close4 ((tensorBoundary l₁ l₂ ᵥ* auxBC G) ∘ rotateAux) + ((auxBC F *ᵥ tensorBoundary r₁ r₂) ∘ rotateAux) + (pairAB (backwardPair A B)*pairCD (forwardPair C D)) := by + let X := rowA B*rowB C*rowC A*rowD D + let Y := rowA B*rowC A*rowB C*rowD D + have hx : closePair (forwardPair B C) l₁ r₁*closePair (forwardPair A D) l₂ r₂= + close4 (tensorBoundary l₁ l₂) (tensorBoundary r₁ r₂) X := by + rw [←close4_pair_product,←pairAB_forward,←pairCD_forward] + simp only [X,Matrix.mul_assoc] + have he : (auxLift (auxBC F) : Total α ι k)*X=Y*auxLift (auxBC F) := by + exact middle_exchange _ _ _ _ _ (exBC_rowA F B) (exBC_rowD F D) + (exchangeBC F C A h) + have hi : (auxLift (auxBC G) : Total α ι k)*auxLift (auxBC F)=1 := by + rw [←auxLift_mul,←auxBC_mul,hGF,auxBC_one] + simp [auxLift] + have hxy : X=auxLift (auxBC G)*Y*auxLift (auxBC F) := by + calc + _= (auxLift (auxBC G)*auxLift (auxBC F))*X := by rw [hi,Matrix.one_mul] + _= _ := by rw [Matrix.mul_assoc,he,←Matrix.mul_assoc] + rw [hx,hxy] + have hc : close4 (tensorBoundary l₁ l₂) (tensorBoundary r₁ r₂) + (auxLift (auxBC G)*Y*auxLift (auxBC F))= + close4 (tensorBoundary l₁ l₂ ᵥ* auxBC G) (auxBC F *ᵥ tensorBoundary r₁ r₂) Y := by + simp only [close4,←leftWall_auxLift,←auxLift_rightWall,Matrix.mul_assoc] + rw [hc,close4_rotate] + congr 1 + simp only [Y,←Matrix.submatrix_mul_equiv _ _ _ rotateSite _, + rotate_rowA,rotate_rowB,rotate_rowC,rotate_rowD] + rw [←pairAB_backward,←pairCD_forward] + simp only [Matrix.mul_assoc] +end CriticalHoneycomb.Transfer.ClosedFourRow + +end + +section + +namespace CriticalHoneycomb.Transfer +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +namespace FusionContraction +variable {k n m : Type*} [CommSemiring k] [Fintype n] [Fintype m] +lemma contract_eq_sum (L R : Matrix n m k) (P : Matrix n n k) (Q : Matrix m m k) : + contract L R P Q = ∑ a,∑ b,∑ c,∑ d,L a b*P a c*R c d*Q b d := by + simp only [contract,Matrix.trace,Matrix.diag,Matrix.mul_apply,Matrix.transpose_apply, + Finset.sum_mul] + conv_lhs => + enter [2,b,2,d] + rw [Finset.sum_comm] + conv_lhs => + enter [2,b] + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl;intro a ha + apply Finset.sum_congr rfl;intro b hb + rw [Finset.sum_comm] +end FusionContraction +namespace ClosedFourRow +variable {α ι k : Type*} [CommSemiring k] [Fintype α] [DecidableEq α] + [Fintype ι] [DecidableEq ι] +noncomputable def matrixBoundary (D : Matrix (α×α) (α×α) k) : Aux α→k := + fun p => D (p.1,p.2.1) (p.2.2.1,p.2.2.2) +lemma close4_fusion_contract (L R : Matrix (α×α) (α×α) k) + (P Q : ι→ι→Matrix (α×α) (α×α) k) (s t : ι) : + close4 (matrixBoundary L) (matrixBoundary R) (pairAB P*pairCD Q) s t= + ∑ v,FusionContraction.contract L R (P s v) (Q v t) := by + rw [close4_apply] + simp only [sum_aux,matrixBoundary,pairAB_mul_CD,Finset.mul_sum,Finset.sum_mul, + FusionContraction.contract_eq_sum] + conv_lhs => + enter [2,a,2,b,2,c] + rw [Finset.sum_comm] + conv_lhs => + enter [2,a,2,b] + rw [Finset.sum_comm] + conv_lhs => + enter [2,a] + rw [Finset.sum_comm] + rw [Finset.sum_comm] + repeat first | apply Finset.sum_congr rfl; intro _ _ | ring +omit [DecidableEq α] [DecidableEq ι] in +lemma closePair_fusion_contract (L R : Matrix α α k) (M N : Row α ι k) (s t : ι) : + closePair (forwardPair M N) (fun p=>L p.1 p.2) (fun p=>R p.1 p.2) s t= + ∑ v,FusionContraction.contract L R (M s v) (N v t) := by + simp only [closePair,forwardPair,Matrix.sum_apply,Matrix.kronecker,Matrix.kroneckerMap, + Fintype.sum_prod_type,Matrix.of_apply,Finset.mul_sum,Finset.sum_mul, + FusionContraction.contract_eq_sum] + conv_lhs => + enter [2,a,2,b,2,c] + rw [Finset.sum_comm] + conv_lhs => + enter [2,a,2,b] + rw [Finset.sum_comm] + conv_lhs => + enter [2,a] + rw [Finset.sum_comm] + rw [Finset.sum_comm] + repeat first | apply Finset.sum_congr rfl; intro _ _ | ring +end ClosedFourRow +end CriticalHoneycomb.Transfer + +end + +section + +namespace CriticalHoneycomb.Transfer.Reflection +open Fusion +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma source_swap_transpose (u : ℝ) (a b c d : Fin 3) : + spectralR u (a,b) (c,d)=spectralR u (d,c) (b,a) := by + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d <;> rfl + +noncomputable def fusionVector (u : ℝ) (A B : Matrix Spin3 Spin3 ℂ) : + Matrix Pair Pair ℂ := fun p q => crossedBC (spectralR (b-u)) A B p.2 q.1 p.1 q.2 +noncomputable def fusionUnbend (G : Matrix Pair Pair ℂ) : Matrix Pair Pair ℂ := fun p q => + phase^(-spinValue q.1-spinValue q.2)*G p (q.2.rev,q.1.rev) +lemma fusion_unbend (u : ℝ) (A B : Matrix Spin3 Spin3 ℂ) : + fusionUnbend (fusionVector u A B)=slot2 A*spectralR u*slot1 B := by + ext ⟨a,b⟩ ⟨c,d⟩ + have hh := congrFun (congrFun (unbend_BC u A B) (b,a)) (d,c) + simp only [unbend] at hh + change phase^(-spinValue c-spinValue d)*crossedBC (spectralR (Reflection.b-u)) A B b d.rev a c.rev=_ + rw [show -spinValue c-spinValue d = -spinValue d-spinValue c by ring,hh] + rw [sandwich12,sandwich21,Finset.sum_comm] + apply Finset.sum_congr rfl; intro i hi + apply Finset.sum_congr rfl; intro j hj + rw [Matrix.transpose_apply,source_swap_transpose u d i j a] +noncomputable def bendPair : Matrix Pair Pair ℂ := fun p q => + if p=(q.2.rev,q.1.rev) then phase^(-spinValue q.1-spinValue q.2) else 0 +noncomputable def bendSpin : Matrix Spin3 Spin3 ℂ := fun p q => + if p=q.rev then phase^(spinValue q.rev) else 0 +lemma mul_bendPair (M : Matrix Pair Pair ℂ) (p q : Pair) : + (M*bendPair) p q=M p (q.2.rev,q.1.rev)*phase^(-spinValue q.1-spinValue q.2) := by + simp [Matrix.mul_apply,bendPair,mul_ite] +lemma mul_bendSpin {a : Type*} (M : Matrix a Spin3 ℂ) (i : a) (j : Spin3) : + (M*bendSpin) i j=M i j.rev*phase^(spinValue j.rev) := by + simp [Matrix.mul_apply,bendSpin,mul_ite] +lemma fusion_bend (u : ℝ) (A B : Matrix Spin3 Spin3 ℂ) : + fusionVector u A B=(slot2 A*spectralR u*slot1 B)*bendPair := by + rw [←fusion_unbend] + ext p q + rw [mul_bendPair] + simp only [fusionUnbend,Fin.rev_rev,spinValue_rev,neg_neg] + have hp : phase≠0 := point_ne_zero _ + rw [mul_right_comm,←zpow_add₀ hp] + simp [show spinValue q.2+spinValue q.1+(-spinValue q.1-spinValue q.2)=0 by ring] +lemma bendPair_Wbar : bendPair*sourceWbar=sourceWbar*bendSpin := by + ext ⟨a,b⟩ j + fin_cases a <;> fin_cases b <;> fin_cases j <;> + simp [Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,bendPair,bendSpin, + sourceWbar,spinValue,Fin.rev,div_eq_mul_inv] <;> ring +lemma Wbar_transpose_bendPair : sourceWbarᵀ*bendPair=bendSpin*sourceWbarᵀ := by + ext j ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> fin_cases j <;> + simp [Matrix.mul_apply,Fin.sum_univ_three,bendPair,bendSpin, + sourceWbar,spinValue,Fin.rev,div_eq_mul_inv] <;> ring +lemma boundary_bend (A : Matrix Spin3 Spin3 ℂ) (i j : Spin3) : + (A*bendSpin) i j=boundaryVector A (i,j) := by + rw [mul_bendSpin] + exact mul_comm _ _ + +lemma fusion_right_close (u : ℝ) (A B D : Matrix Spin3 Spin3 ℂ) + (h : slot2 A*spectralR u*slot1 B*sourceWbar=sourceW*D) : + fusionVector u A B*sourceWbar=sourceW*(D*bendSpin) := by + rw [fusion_bend,Matrix.mul_assoc, bendPair_Wbar,←Matrix.mul_assoc,h,Matrix.mul_assoc] + +lemma fusion_left_close (u : ℝ) (A B D : Matrix Spin3 Spin3 ℂ) + (h : sourceWᵀ*slot2 A*spectralR u*slot1 B=D*sourceWbarᵀ) : + sourceWᵀ*fusionVector u A B=(D*bendSpin)*sourceWbarᵀ := by + rw [fusion_bend] + calc + _=(sourceWᵀ*slot2 A*spectralR u*slot1 B)*bendPair := by simp only [Matrix.mul_assoc] + _=D*sourceWbarᵀ*bendPair := by rw [h] + _=_ := by rw [Matrix.mul_assoc,Wbar_transpose_bendPair,←Matrix.mul_assoc] + +lemma fusion_right_close_add (u : ℝ) (A B A' B' D : Matrix Spin3 Spin3 ℂ) + (h : slot2 A*spectralR u*slot1 B*sourceWbar+ + slot2 A'*spectralR u*slot1 B'*sourceWbar=sourceW*D) : + (fusionVector u A B+fusionVector u A' B')*sourceWbar=sourceW*(D*bendSpin) := by + simp only [fusion_bend,Matrix.add_mul,Matrix.mul_assoc,bendPair_Wbar] + simp only [←Matrix.mul_assoc] + rw [←Matrix.add_mul,h,Matrix.mul_assoc] +lemma fusion_left_close_add (u : ℝ) (A B A' B' D : Matrix Spin3 Spin3 ℂ) + (h : sourceWᵀ*slot2 A*spectralR u*slot1 B+ + sourceWᵀ*slot2 A'*spectralR u*slot1 B'=D*sourceWbarᵀ) : + sourceWᵀ*(fusionVector u A B+fusionVector u A' B')=(D*bendSpin)*sourceWbarᵀ := by + simp only [fusion_bend,Matrix.mul_add,←Matrix.mul_assoc] + rw [←Matrix.add_mul,h,Matrix.mul_assoc,Wbar_transpose_bendPair,←Matrix.mul_assoc] +lemma source_fusion_right_constant (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + fusionVector (2*t) (boundary0 (t-L)) (boundary0 (t+L))*sourceWbar= + sourceW*(boundary0 t*bendSpin) := + fusion_right_close _ _ _ _ (boundary_fusion_constant t hQ ht hm hp) +lemma source_fusion_right_linear (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + (fusionVector (2*t) (boundary1 (t-L)) (boundary0 (t+L))+ + fusionVector (2*t) (boundary0 (t-L)) (boundary1 (t+L)))*sourceWbar= + sourceW*(boundary1 t*bendSpin) := + fusion_right_close_add _ _ _ _ _ _ (boundary_fusion_linear t hQ ht hm hp) +lemma source_fusion_left_constant (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + sourceWᵀ*fusionVector (2*t) (boundary0 (t+L)) (boundary0 (t-L))= + (boundary0 t*bendSpin)*sourceWbarᵀ := + fusion_left_close _ _ _ _ (boundary_fusion_dual_constant t hQ ht hm hp) +lemma source_fusion_left_linear (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + sourceWᵀ*(fusionVector (2*t) (boundary0 (t+L)) (boundary1 (t-L))+ + fusionVector (2*t) (boundary1 (t+L)) (boundary0 (t-L)))= + (boundary1 t*bendSpin)*sourceWbarᵀ := + fusion_left_close_add _ _ _ _ _ _ (boundary_fusion_dual_linear t hQ ht hm hp) +end CriticalHoneycomb.Transfer.Reflection + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection Reflection.Fusion BoundaryJet +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def wallMatrix (e : Jet) (u : ℝ) : Matrix Spin3 Spin3 Jet := + fun i j => K e u (i,j) +noncomputable def markedFusionVector (e : Jet) (x u v : ℝ) : Matrix Pair Pair Jet := + fun p q => ∑ i,∑ j, C (spectralR (b-x) (q.1,p.1) (i,j))* + K e u (p.2,i)*K e v (j,q.2) +lemma wallMatrix_affine (e : Jet) (u : ℝ) : + wallMatrix e u=(boundary0 u*bendSpin).map C+e • (boundary1 u*bendSpin).map C := by + funext i j + simp only [wallMatrix,K,Matrix.add_apply,Matrix.smul_apply,Matrix.map_apply, + boundary_bend,K0,K1,boundaryVector,smul_eq_mul] +lemma markedFusionVector_affine (e : Jet) (he : e*e=0) (x u v : ℝ) : + markedFusionVector e x u v=(fusionVector x (boundary0 u) (boundary0 v)).map C+ + e • (fusionVector x (boundary1 u) (boundary0 v)+ + fusionVector x (boundary0 u) (boundary1 v)).map C := by + funext p q + simp only [markedFusionVector,Matrix.add_apply,Matrix.smul_apply,Matrix.map_apply, + fusionVector,crossedBC,K,K0,K1,boundaryVector,smul_eq_mul,map_add,map_sum,map_mul, + Finset.mul_sum,←Finset.sum_add_distrib] + apply Finset.sum_congr rfl;intro i hi + apply Finset.sum_congr rfl;intro j hj + calc + _ = C (spectralR (b-x) (q.1,p.1) (i,j))* + C (Reflection.phase^(spinValue i.rev)*boundary0 u p.2 i.rev)* + C (Reflection.phase^(spinValue q.2.rev)*boundary0 v j q.2.rev)+ + e*(C (spectralR (b-x) (q.1,p.1) (i,j))* + C (Reflection.phase^(spinValue i.rev)*boundary1 u p.2 i.rev)* + C (Reflection.phase^(spinValue q.2.rev)*boundary0 v j q.2.rev))+ + e*(C (spectralR (b-x) (q.1,p.1) (i,j))* + C (Reflection.phase^(spinValue i.rev)*boundary0 u p.2 i.rev)* + C (Reflection.phase^(spinValue q.2.rev)*boundary1 v j q.2.rev))+ + (e*e)*(C (spectralR (b-x) (q.1,p.1) (i,j))* + C (Reflection.phase^(spinValue i.rev)*boundary1 u p.2 i.rev)* + C (Reflection.phase^(spinValue q.2.rev)*boundary1 v j q.2.rev)) := by simp only [map_mul];ring + _ = _ := by rw [he,zero_mul,add_zero];simp only [map_mul];ring +local instance : IsScalarTower Jet Jet Jet where + smul_assoc a b c := mul_assoc a b c +local instance : SMulCommClass Jet Jet Jet := ⟨fun a b c => by + change a*(b*c)=b*(a*c) + ring⟩ +lemma affine_right {a n m d : Type*} [Fintype a] [Fintype n] [Fintype m] [Fintype d] + (W : Matrix n a ℂ) (Z : Matrix m d ℂ) (G0 G1 : Matrix n m ℂ) + (D0 D1 : Matrix a d ℂ) (e : Jet) + (h0 : G0*Z=W*D0) (h1 : G1*Z=W*D1) : + (G0.map C+e • G1.map C)*Z.map C=W.map C*(D0.map C+e • D1.map C) := by + rw [Matrix.add_mul, Matrix.mul_add, + Matrix.smul_mul e (G1.map C) (Z.map C), + Matrix.mul_smul (W.map C) e (D1.map C)] + simp only [←Matrix.map_mul, h0, h1] +lemma affine_left {a n m d : Type*} [Fintype a] [Fintype n] [Fintype m] [Fintype d] + (W : Matrix a n ℂ) (Z : Matrix d m ℂ) (G0 G1 : Matrix n m ℂ) + (D0 D1 : Matrix a d ℂ) (e : Jet) + (h0 : W*G0=D0*Z) (h1 : W*G1=D1*Z) : + W.map C*(G0.map C+e • G1.map C)=(D0.map C+e • D1.map C)*Z.map C := by + rw [Matrix.mul_add, Matrix.add_mul, + Matrix.mul_smul (W.map C) e (G1.map C), + Matrix.smul_mul e (D1.map C) (Z.map C)] + simp only [←Matrix.map_mul, h0, h1] +lemma marked_fusion_right (e : Jet) (he : e*e=0) (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + markedFusionVector e (2*t) (t-L) (t+L)*sourceWbar.map C= + sourceW.map C*wallMatrix e t := by + rw [markedFusionVector_affine e he,wallMatrix_affine] + exact affine_right _ _ _ _ _ _ e (source_fusion_right_constant t hQ ht hm hp) + (source_fusion_right_linear t hQ ht hm hp) +lemma marked_fusion_left (e : Jet) (he : e*e=0) (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + sourceWᵀ.map C*markedFusionVector e (2*t) (t+L) (t-L)= + wallMatrix e t*sourceWbarᵀ.map C := by + rw [markedFusionVector_affine e he,wallMatrix_affine] + have hh:=affine_left _ _ _ _ _ _ e (source_fusion_left_constant t hQ ht hm hp) + (source_fusion_left_linear t hQ ht hm hp) + simpa only [add_comm] using hh +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +namespace ClosedFourRow +variable {α k : Type*} [CommSemiring k] [Fintype α] [DecidableEq α] +lemma right_middle_boundary (F : Matrix (α×α) (α×α) k) (r₁ r₂ : α×α→k) : + (auxBC F *ᵥ tensorBoundary r₁ r₂) ∘ rotateAux= + matrixBoundary (fun p q=>∑ i,∑ j,F (q.1,p.1) (i,j)*r₁ (p.2,i)*r₂ (j,q.2)) := by + funext ⟨a,b,c,d⟩ + simp [rotateAux,auxBC,tensorBoundary,matrixBoundary, + Matrix.mulVec, dotProduct,Fintype.sum_prod_type,Matrix.one_apply,mul_ite,ite_mul] + apply Finset.sum_congr rfl;intro i hi + apply Finset.sum_congr rfl;intro j hj + ring +lemma left_middle_boundary (G : Matrix (α×α) (α×α) k) (l₁ l₂ : α×α→k) : + (tensorBoundary l₁ l₂ ᵥ* auxBC Gᵀ) ∘ rotateAux= + matrixBoundary (fun p q=>∑ i,∑ j,G (q.1,p.1) (i,j)*l₁ (p.2,i)*l₂ (j,q.2)) := by + funext ⟨a,b,c,d⟩ + simp [rotateAux,auxBC,tensorBoundary,matrixBoundary, + Matrix.vecMul, dotProduct,Fintype.sum_prod_type,Matrix.one_apply,mul_ite,Matrix.transpose_apply] + apply Finset.sum_congr rfl;intro i hi + apply Finset.sum_congr rfl;intro j hj + ring +end ClosedFourRow +namespace SpectralFamily +open Reflection BoundaryJet ClosedFourRow +lemma marked_middle_right (e : Jet) (t : ℝ) : + (auxBC ((spectralR (b-2*t)).map C) *ᵥ tensorBoundary (K e (t-L)) (K e (t+L))) ∘ + rotateAux=matrixBoundary (markedFusionVector e (2*t) (t-L) (t+L)) := by + rw [right_middle_boundary] + rfl +lemma marked_middle_left (e : Jet) (t : ℝ) : + (tensorBoundary (K e ((b-t)+L)) (K e ((b-t)-L)) ᵥ* + auxBC ((spectralR (-(b-2*t)))ᵀ.map C)) ∘ rotateAux= + matrixBoundary (markedFusionVector e (2*(b-t)) ((b-t)+L) ((b-t)-L)) := by + have hr : b-2*(b-t)=-(b-2*t) := by ring + change (tensorBoundary _ _ ᵥ* auxBC (((spectralR (-(b-2*t))).map C)ᵀ)) ∘ _=_ + rw [left_middle_boundary] + unfold markedFusionVector + rw [hr] + rfl +end SpectralFamily +end CriticalHoneycomb.Transfer + +end + +section + +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix BigOperators +noncomputable def sourceJ : Matrix (Fin 3) Pair ℂ := fun j p => + if p=(j,1) then if j=1 then 1 else twoCos else 0 +lemma sourceJ_W : sourceJ*sourceW=1 := by + ext i j + fin_cases i <;> fin_cases j <;> + simp [Matrix.mul_apply,sourceJ,sourceW,kappa_normalization] +lemma sourceJ_Wbar : sourceJ*sourceWbar=1 := by + ext i j + fin_cases i <;> fin_cases j <;> + simp [Matrix.mul_apply,sourceJ,sourceWbar,kappa_normalization] +lemma sourceWbar_J : sourceWbarᵀ*sourceJᵀ=1 := by + simpa only [Matrix.transpose_mul,Matrix.transpose_one] using + congrArg Matrix.transpose sourceJ_Wbar +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer +lemma cos_angle_pos : 0 < Real.cos angle := by + rw [angle,Real.cos_pi_div_eight] + positivity +lemma sine2_sq : sine2^2=(1:ℝ)/2 := by + have hh:=Real.sin_sq_add_cos_sq (2*angle) + rw [cos_two_angle] at hh + change sine2^2+sine2^2=1 at hh + linarith +lemma denominator_two_angle : denominator (2*angle)=Real.cos angle := by + unfold denominator + rw [show 2*angle+2*angle=Real.pi/2 by unfold angle;ring, + show bigAngle+2*angle=Real.pi-bigAngle by unfold bigAngle angle;ring, + Real.sin_pi_div_two,Real.sin_pi_sub,sin_bigAngle,one_mul] +lemma special_two_angle : + a (2*angle)=(1/(2*Real.cos angle))^2 ∧ + h (2*angle)=1/(2*Real.cos angle) ∧ + v (2*angle)=(1/(2*Real.cos angle))^2 ∧ + c (2*angle)=0 ∧ + d (2*angle)=(1/(2*Real.cos angle))^2 := by + have hc : Real.cos angle≠0 := ne_of_gt cos_angle_pos + have hb : bigAngle-2*angle=angle := by unfold bigAngle;ring + have hd : 2*angle-angle=angle := by ring + have he : sine2=2*Real.sin angle*Real.cos angle := Real.sin_two_mul angle + have hs : 8*(Real.sin angle)^2*(Real.cos angle)^2=1 := by + have hsq:=sine2_sq + rw [he] at hsq + nlinarith + have ha : sine2*Real.sin angle/Real.cos angle=(1/(2*Real.cos angle))^2 := by + rw [he] + field_simp + nlinarith + have hh : sine2*sine2/Real.cos angle=1/(2*Real.cos angle) := by + field_simp + nlinarith [sine2_sq] + simp only [a,h,v,c,d,denominator_two_angle,hb,hd,sub_self,Real.sin_zero,mul_zero, + zero_div,show Real.sin (2*angle)=sine2 from rfl] + exact ⟨ha,hh,by simpa only [mul_comm] using ha,True.intro,ha⟩ +lemma denominator_zero : denominator 0=sine2*Real.cos angle := by + simp only [denominator,add_zero,sin_bigAngle];rfl +lemma sine2_pos : 0 + if p.1=q.2 then if p.2=q.1 then 1 else 0 else 0 +noncomputable def sourceOmega : Pair→ℂ := fun p=> + match p.1.val,p.2.val with + | 0,2 => phase⁻¹ + | 1,1 => 1 + | 2,0 => phase + | _,_ => 0 +noncomputable def sourceOmegaBar : Pair→ℂ := fun p=> + match p.1.val,p.2.val with + | 0,2 => phase + | 1,1 => 1 + | 2,0 => phase⁻¹ + | _,_ => 0 +lemma sourceKappa_real : ((1/(2*Real.cos Transfer.angle):ℝ):ℂ)=sourceKappa := by + simp [sourceKappa,twoCos,Transfer.angle,L,one_div] +lemma Q_ne_of_denominator_ne {u : ℝ} (h : Transfer.denominator u≠0) : Q u≠0 := by + rw [←denominator_binding] + exact_mod_cast h +lemma Q_zero_ne : Q 0≠0 := by + apply Q_ne_of_denominator_ne + rw [Transfer.denominator_zero] + exact mul_ne_zero (ne_of_gt Transfer.sine2_pos) (ne_of_gt Transfer.cos_angle_pos) +lemma Q_two_L_ne : Q (2*L)≠0 := by + apply Q_ne_of_denominator_ne + change Transfer.denominator (2*Transfer.angle)≠0 + rw [Transfer.denominator_two_angle] + exact ne_of_gt Transfer.cos_angle_pos +lemma Q_b_ne : Q b≠0 := by + apply Q_ne_of_denominator_ne + rw [←bigAngle_binding,Transfer.denominator_bigAngle] + exact mul_ne_zero (ne_of_gt Transfer.cos_angle_pos) (ne_of_gt Transfer.sine2_pos) +private lemma spectralValueSpecialZero00 (c d : Fin 3) : + normalizedR 0 (0,0) (c,d)=swapR (0,0) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,hc,swapR] +private lemma spectralValueSpecialZero01 (c d : Fin 3) : + normalizedR 0 (0,1) (c,d)=swapR (0,1) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,ha,hv,swapR] +private lemma spectralValueSpecialZero02 (c d : Fin 3) : + normalizedR 0 (0,2) (c,d)=swapR (0,2) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,hh,hc,hd,swapR] +private lemma spectralValueSpecialZero10 (c d : Fin 3) : + normalizedR 0 (1,0) (c,d)=swapR (1,0) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,ha,hv,swapR] +private lemma spectralValueSpecialZero11 (c d : Fin 3) : + normalizedR 0 (1,1) (c,d)=swapR (1,1) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,hh,swapR] +private lemma spectralValueSpecialZero12 (c d : Fin 3) : + normalizedR 0 (1,2) (c,d)=swapR (1,2) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,ha,hv,swapR] +private lemma spectralValueSpecialZero20 (c d : Fin 3) : + normalizedR 0 (2,0) (c,d)=swapR (2,0) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,hh,hc,hd,swapR] +private lemma spectralValueSpecialZero21 (c d : Fin 3) : + normalizedR 0 (2,1) (c,d)=swapR (2,1) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,ha,hv,swapR] +private lemma spectralValueSpecialZero22 (c d : Fin 3) : + normalizedR 0 (2,2) (c,d)=swapR (2,2) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_zero + fin_cases c <;> fin_cases d <;> simp [normalizedR,hc,swapR] + +theorem source_R_zero : spectralR 0=swapR := by + rw [spectralR_normalized 0 Q_zero_ne] + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b + · exact spectralValueSpecialZero00 c d + · exact spectralValueSpecialZero01 c d + · exact spectralValueSpecialZero02 c d + · exact spectralValueSpecialZero10 c d + · exact spectralValueSpecialZero11 c d + · exact spectralValueSpecialZero12 c d + · exact spectralValueSpecialZero20 c d + · exact spectralValueSpecialZero21 c d + · exact spectralValueSpecialZero22 c d +private lemma spectralValueSpecialTwo00 (c d : Fin 3) : + normalizedR (2*L) (0,0) (c,d)=(sourceW*sourceWbarᵀ) (0,0) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,div_eq_mul_inv] +private lemma spectralValueSpecialTwo01 (c d : Fin 3) : + normalizedR (2*L) (0,1) (c,d)=(sourceW*sourceWbarᵀ) (0,1) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,Fin.sum_univ_three, + div_eq_mul_inv] <;> field_simp [hs] +private lemma spectralValueSpecialTwo02 (c d : Fin 3) : + normalizedR (2*L) (0,2) (c,d)=(sourceW*sourceWbarᵀ) (0,2) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,Fin.sum_univ_three, + phase_binding,div_eq_mul_inv] <;> field_simp [hs] +private lemma spectralValueSpecialTwo10 (c d : Fin 3) : + normalizedR (2*L) (1,0) (c,d)=(sourceW*sourceWbarᵀ) (1,0) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,Fin.sum_univ_three, + div_eq_mul_inv] <;> field_simp [hs] +private lemma spectralValueSpecialTwo11 (c d : Fin 3) : + normalizedR (2*L) (1,1) (c,d)=(sourceW*sourceWbarᵀ) (1,1) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,Fin.sum_univ_three, + phase_binding,div_eq_mul_inv] +private lemma spectralValueSpecialTwo12 (c d : Fin 3) : + normalizedR (2*L) (1,2) (c,d)=(sourceW*sourceWbarᵀ) (1,2) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,Fin.sum_univ_three, + div_eq_mul_inv] <;> field_simp [hs] +private lemma spectralValueSpecialTwo20 (c d : Fin 3) : + normalizedR (2*L) (2,0) (c,d)=(sourceW*sourceWbarᵀ) (2,0) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,Fin.sum_univ_three, + phase_binding,div_eq_mul_inv] <;> field_simp [hs] +private lemma spectralValueSpecialTwo21 (c d : Fin 3) : + normalizedR (2*L) (2,1) (c,d)=(sourceW*sourceWbarᵀ) (2,1) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,Fin.sum_univ_three, + div_eq_mul_inv] <;> field_simp [hs] +private lemma spectralValueSpecialTwo22 (c d : Fin 3) : + normalizedR (2*L) (2,2) (c,d)=(sourceW*sourceWbarᵀ) (2,2) (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_two_angle + have hs : phase≠0 := point_ne_zero _ + change normalizedR (2*Transfer.angle) _ _=_ + fin_cases c <;> fin_cases d <;> + simp only [normalizedR,ha,hh,hv,hc,hd,Complex.ofReal_pow,sourceKappa_real] + all_goals simp [sourceW,sourceWbar,Matrix.mul_apply,div_eq_mul_inv] + +theorem source_R_two : spectralR (2*L)=sourceW*sourceWbarᵀ := by + rw [spectralR_normalized (2*L) Q_two_L_ne] + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b + · exact spectralValueSpecialTwo00 c d + · exact spectralValueSpecialTwo01 c d + · exact spectralValueSpecialTwo02 c d + · exact spectralValueSpecialTwo10 c d + · exact spectralValueSpecialTwo11 c d + · exact spectralValueSpecialTwo12 c d + · exact spectralValueSpecialTwo20 c d + · exact spectralValueSpecialTwo21 c d + · exact spectralValueSpecialTwo22 c d +private lemma spectralValueSpecialB00 (c d : Fin 3) : + normalizedR Reflection.b (0,0) (c,d)=sourceOmega (0,0)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,hc,sourceOmega,sourceOmegaBar,] +private lemma spectralValueSpecialB01 (c d : Fin 3) : + normalizedR Reflection.b (0,1) (c,d)=sourceOmega (0,1)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,ha,hv,sourceOmega,sourceOmegaBar,] +private lemma spectralValueSpecialB02 (c d : Fin 3) : + normalizedR Reflection.b (0,2) (c,d)=sourceOmega (0,2)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,hh,hc,hd,phase_binding,sourceOmega,sourceOmegaBar,hs,div_eq_mul_inv] ; ring +private lemma spectralValueSpecialB10 (c d : Fin 3) : + normalizedR Reflection.b (1,0) (c,d)=sourceOmega (1,0)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,ha,hv,sourceOmega,sourceOmegaBar,] +private lemma spectralValueSpecialB11 (c d : Fin 3) : + normalizedR Reflection.b (1,1) (c,d)=sourceOmega (1,1)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,hh,phase_binding,sourceOmega,sourceOmegaBar,div_eq_mul_inv] +private lemma spectralValueSpecialB12 (c d : Fin 3) : + normalizedR Reflection.b (1,2) (c,d)=sourceOmega (1,2)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,ha,hv,sourceOmega,sourceOmegaBar,] +private lemma spectralValueSpecialB20 (c d : Fin 3) : + normalizedR Reflection.b (2,0) (c,d)=sourceOmega (2,0)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,hh,hc,hd,phase_binding,sourceOmega,sourceOmegaBar,hs] ; ring +private lemma spectralValueSpecialB21 (c d : Fin 3) : + normalizedR Reflection.b (2,1) (c,d)=sourceOmega (2,1)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,ha,hv,sourceOmega,sourceOmegaBar,] +private lemma spectralValueSpecialB22 (c d : Fin 3) : + normalizedR Reflection.b (2,2) (c,d)=sourceOmega (2,2)*sourceOmegaBar (c,d) := by + obtain ⟨ha,hh,hv,hc,hd⟩:=Transfer.special_bigAngle + rw [bigAngle_binding] at ha hh hv hc hd + have hs : phase≠0 := point_ne_zero _ + fin_cases c <;> fin_cases d <;> + simp [normalizedR,hc,sourceOmega,sourceOmegaBar,] + +theorem source_R_b : spectralR b=fun p q=>sourceOmega p*sourceOmegaBar q := by + rw [spectralR_normalized b Q_b_ne] + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b + · exact spectralValueSpecialB00 c d + · exact spectralValueSpecialB01 c d + · exact spectralValueSpecialB02 c d + · exact spectralValueSpecialB10 c d + · exact spectralValueSpecialB11 c d + · exact spectralValueSpecialB12 c d + · exact spectralValueSpecialB20 c d + · exact spectralValueSpecialB21 c d + · exact spectralValueSpecialB22 c d +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open scoped Matrix + +lemma localBackward_with_swap (A : Local) (s t a b d e : Spin) : + localBackward A (fun p q=>if p.1=q.2 then if p.2=q.1 then 1 else 0 else 0) + s t (a,b) (d,e)=if e=s then A (a,b) (d,t) else 0 := by + by_cases he : e=s + · subst e + simp [localBackward,block,Matrix.kronecker,Matrix.kroneckerMap,Matrix.sum_apply,Matrix.of_apply,mul_ite] + · simp [localBackward,block,Matrix.kronecker,Matrix.kroneckerMap,Matrix.sum_apply,Matrix.of_apply,mul_ite,he,Ne.symm he] +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open scoped Matrix BigOperators + +theorem row_range_factor (n : ℕ) (W : Matrix (Spin×Spin) Spin ℂ) + (A B C : Fin n→Local) + (hf : ∀ i s t,localBackward (A i) (B i) s t*W=W*block (C i) s t) + (i : Fin n) + (hi : ∀ s t,∃ F : Matrix Spin (Spin×Spin) ℂ,localBackward (A i) (B i) s t=W*F) + (s t : Space n) : + ∃ F : Matrix Spin (Spin×Spin) ℂ,backward n A B s t=W*F := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + rcases Fin.eq_zero_or_eq_succ i with rfl|⟨j,rfl⟩ + · obtain ⟨F,hF⟩:=hi (s 0) (t 0) + refine ⟨F*backward n (Fin.tail A) (Fin.tail B) (Fin.tail s) (Fin.tail t),?_⟩ + rw [backward_succ,hF,Matrix.mul_assoc] + · obtain ⟨F,hF⟩:=ih (Fin.tail A) (Fin.tail B) (Fin.tail C) + (fun k=>hf k.succ) j hi (Fin.tail s) (Fin.tail t) + refine ⟨block (C 0) (s 0) (t 0)*F,?_⟩ + rw [backward_succ,hF,←Matrix.mul_assoc,hf 0,Matrix.mul_assoc] + +theorem row_quotient_factor (n : ℕ) (Z : Matrix Spin (Spin×Spin) ℂ) + (A B C : Fin n→Local) + (hf : ∀ i s t,Z*localForward (A i) (B i) s t=block (C i) s t*Z) + (i : Fin n) + (hi : ∀ s t,∃ F : Matrix (Spin×Spin) Spin ℂ,localForward (A i) (B i) s t=F*Z) + (s t : Space n) : + ∃ F : Matrix (Spin×Spin) Spin ℂ,forward n A B s t=F*Z := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + rcases Fin.eq_zero_or_eq_succ i with rfl|⟨j,rfl⟩ + · obtain ⟨F,hF⟩:=hi (s 0) (t 0) + refine ⟨F*row n (Fin.tail C) (Fin.tail s) (Fin.tail t),?_⟩ + rw [forward_succ,hF,Matrix.mul_assoc,row_quotient_fusion n Z + (Fin.tail A) (Fin.tail B) (Fin.tail C) (fun k=>hf k.succ),←Matrix.mul_assoc] + · obtain ⟨F,hF⟩:=ih (Fin.tail A) (Fin.tail B) (Fin.tail C) + (fun k=>hf k.succ) j hi (Fin.tail s) (Fin.tail t) + refine ⟨localForward (A 0) (B 0) (s 0) (t 0)*F,?_⟩ + rw [forward_succ,hF,←Matrix.mul_assoc] +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open Reflection Reflection.Fusion +open scoped Matrix BigOperators +noncomputable def specialFinish (s t : Spin) : Matrix Spin Pair ℂ := fun j p=> + if p.2=s then sourceWbar (p.1,t) j else 0 + +lemma local_first_node (s t : Spin) : + localBackward (spectralR (2*L)) (spectralR 0) s t=sourceW*specialFinish s t := by + rw [source_R_two,source_R_zero] + ext ⟨a,b⟩ ⟨d,e⟩ + rw [show localBackward (sourceW*sourceWbarᵀ) swapR s t (a,b) (d,e)= + if e=s then (sourceW*sourceWbarᵀ) (a,b) (d,t) else 0 from + localBackward_with_swap (sourceW*sourceWbarᵀ) s t a b d e] + by_cases he : e=s + · simp [Matrix.mul_apply,specialFinish,he] + · simp [Matrix.mul_apply,specialFinish,he] + +theorem source_first_node_range (n : ℕ) (ξ : Fin n→ℝ) (i : Fin n) (u : ℝ) + (hnode : u=L-ξ i) + (hm : ∀ j,Q ((u-L)+ξ j)≠0) (hu : ∀ j,Q (u+ξ j)≠0) + (hp : ∀ j,Q ((u+L)+ξ j)≠0) (s t : Space n) : + ∃ F : Matrix Spin Pair ℂ, + backward n (exactSites n ξ (u+L)) (exactSites n ξ (u-L)) s t=sourceW*F := by + apply row_range_factor n sourceW (exactSites n ξ (u+L)) (exactSites n ξ (u-L)) + (exactSites n ξ u) ?_ i ?_ s t + · intro j a b + have em : (u+ξ j)-L=(u-L)+ξ j := by ring + have ep : (u+ξ j)+L=(u+L)+ξ j := by ring + simpa only [exactSites,em,ep] using local_source_fusion (u+ξ j) + (by simpa only [em] using hm j) (hu j) (by simpa only [ep] using hp j) a b + · intro a b + refine ⟨specialFinish a b,?_⟩ + have em : (u-L)+ξ i=0 := by rw [hnode];ring + have ep : (u+L)+ξ i=2*L := by rw [hnode];ring + simpa only [exactSites,em,ep] using local_first_node a b +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open Reflection Reflection.Fusion +open scoped Matrix BigOperators +lemma source_R_L (i j k l : Spin) : + spectralR L (i,j) (k,l)= + Reflection.phase^(spinValue k-spinValue i)*(sourceW*sourceWbarᵀ) (i.rev,l) (k.rev,j) := by + have hh:=source_crossing (2*L) i j k l + rw [show b-2*L=L by unfold b L;ring,source_R_two] at hh + exact hh +lemma omegaBar_sum (d : Spin) (f : Spin→ℂ) : + (∑ v,sourceOmegaBar (d,v)*f v)=Reflection.phase^(spinValue d)*f d.rev := by + fin_cases d <;> simp [sourceOmegaBar,spinValue,Fin.sum_univ_three,Fin.rev] +noncomputable def secondFinish (s t : Spin) : Matrix Pair Spin ℂ := fun p j=> + sourceOmega (p.1,s)*Reflection.phase^(spinValue j-spinValue p.2)*sourceW (p.2.rev,t) j.rev +lemma local_second_node_entry (s t a b d e : Spin) : + localForward (spectralR Reflection.b) (spectralR L) s t (a,b) (d,e)= + sourceOmega (a,s)*Reflection.phase^(spinValue d)*spectralR L (b,d.rev) (e,t) := by + simp only [localForward,block,Matrix.sum_apply,Matrix.kronecker, + Matrix.kroneckerMap,Matrix.of_apply,source_R_b] + change (∑ v,sourceOmega (a,s)*sourceOmegaBar (d,v)*spectralR L (b,v) (e,t))=_ + calc + _=sourceOmega (a,s)*(∑ v,sourceOmegaBar (d,v)*spectralR L (b,v) (e,t)) := by + simp only [Finset.mul_sum,mul_assoc] + _=_ := by rw [omegaBar_sum];ring + +lemma local_second_node (s t : Spin) : + localForward (spectralR b) (spectralR L) s t=secondFinish s t*sourceWbarᵀ := by + ext ⟨a,b⟩ ⟨d,e⟩ + rw [local_second_node_entry,source_R_L] + simp only [Matrix.mul_apply,Matrix.transpose_apply,secondFinish,Finset.mul_sum] + calc + (∑ j,sourceOmega (a,s)*Reflection.phase^(spinValue d)* + (Reflection.phase^(spinValue e-spinValue b)*(sourceW (b.rev,t) j*sourceWbar (e.rev,d.rev) j)))= + ∑ j,sourceOmega (a,s)*Reflection.phase^(spinValue j.rev-spinValue b)*sourceW (b.rev,t) j* + sourceWbar (d,e) j.rev := by + apply Finset.sum_congr rfl + intro j hj + calc + _=sourceOmega (a,s)*sourceW (b.rev,t) j* + (Reflection.phase^(spinValue d)*Reflection.phase^(spinValue e-spinValue b)*sourceWbar (e.rev,d.rev) j) := by ring + _=sourceOmega (a,s)*sourceW (b.rev,t) j* + (Reflection.phase^(spinValue j.rev-spinValue b)*sourceWbar (d,e) j.rev) := by + rw [sourceWbar_crossing_phase] + _=_ := by ring + _=∑ j,sourceOmega (a,s)*Reflection.phase^(spinValue j-spinValue b)*sourceW (b.rev,t) j.rev* + sourceWbar (d,e) j := by + simpa only [Fin.rev_rev] using sum_fin_rev (fun j=> + sourceOmega (a,s)*Reflection.phase^(spinValue j-spinValue b)*sourceW (b.rev,t) j.rev*sourceWbar (d,e) j) + +theorem source_second_node_quotient (n : ℕ) (ξ : Fin n→ℝ) (i : Fin n) (u : ℝ) + (hnode : u=L+ξ i) + (hm : ∀ j,Q (((b-u)-L)+ξ j)≠0) (hu : ∀ j,Q ((b-u)+ξ j)≠0) + (hp : ∀ j,Q (((b-u)+L)+ξ j)≠0) (s t : Space n) : + ∃ F : Matrix Pair Spin ℂ, + forward n (exactSites n ξ ((b-u)+L)) (exactSites n ξ ((b-u)-L)) s t=F*sourceWbarᵀ := by + apply row_quotient_factor n sourceWbarᵀ (exactSites n ξ ((b-u)+L)) (exactSites n ξ ((b-u)-L)) + (exactSites n ξ (b-u)) ?_ i ?_ s t + · intro j a c + have em : ((b-u)+ξ j)-L=((b-u)-L)+ξ j := by ring + have ep : ((b-u)+ξ j)+L=((b-u)+L)+ξ j := by ring + simpa only [exactSites,em,ep] using local_source_quotient_fusion ((b-u)+ξ j) + (by simpa only [em] using hm j) (hu j) (by simpa only [ep] using hp j) a c + · intro a c + refine ⟨secondFinish a c,?_⟩ + have em : ((b-u)-L)+ξ i=L := by rw [hnode];unfold b L;ring + have ep : ((b-u)+L)+ξ i=b := by rw [hnode];ring + simpa only [exactSites,em,ep] using local_second_node a c +end CriticalHoneycomb.Transfer.RowExchange + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection Reflection.Fusion RowExchange BoundaryJet ClosedFourRow FusionContraction +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma first_node_projection (N : ℕ) (ξ : Fin N→ℝ) (i : Fin N) (u : ℝ) + (hnode : u=L-ξ i) (hm : ∀ j,Q ((u-L)+ξ j)≠0) (hu : ∀ j,Q (u+ξ j)≠0) + (hp : ∀ j,Q ((u+L)+ξ j)≠0) (s t : Space N) : + sourceW*sourceJ*backward N (exactSites N ξ (u+L)) (exactSites N ξ (u-L)) s t= + backward N (exactSites N ξ (u+L)) (exactSites N ξ (u-L)) s t := by + obtain ⟨F,hF⟩:=source_first_node_range N ξ i u hnode hm hu hp s t + rw [hF] + calc + _=sourceW*(sourceJ*sourceW)*F := by simp only [Matrix.mul_assoc] + _=_ := by rw [sourceJ_W,Matrix.mul_one] +lemma second_node_projection (N : ℕ) (ξ : Fin N→ℝ) (i : Fin N) (u : ℝ) + (hnode : u=L+ξ i) (hm : ∀ j,Q (((b-u)-L)+ξ j)≠0) + (hu : ∀ j,Q ((b-u)+ξ j)≠0) (hp : ∀ j,Q (((b-u)+L)+ξ j)≠0) + (s t : Space N) : + forward N (exactSites N ξ ((b-u)+L)) (exactSites N ξ ((b-u)-L)) s t* + sourceJᵀ*sourceWbarᵀ= + forward N (exactSites N ξ ((b-u)+L)) (exactSites N ξ ((b-u)-L)) s t := by + obtain ⟨F,hF⟩:=source_second_node_quotient N ξ i u hnode hm hu hp s t + rw [hF] + simp only [Matrix.mul_assoc,sourceWbar_J,Matrix.one_mul] +lemma JRow_fusion (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hm : ∀ j,Q ((u-L)+ξ j)≠0) (hu : ∀ j,Q (u+ξ j)≠0) + (hp : ∀ j,Q ((u+L)+ξ j)≠0) (s t : Space N) : + backwardPair (JRow N ξ (u+L)) (JRow N ξ (u-L)) s t*sourceW.map C= + sourceW.map C*JRow N ξ u s t := by + rw [backward_JRow] + change _=sourceW.map C*(row N (exactSites N ξ u) s t).map C + rw [←Matrix.map_mul,←Matrix.map_mul,source_row_fusion N ξ u hm hu hp] +lemma JRow_quotient_fusion (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hm : ∀ j,Q ((u-L)+ξ j)≠0) (hu : ∀ j,Q (u+ξ j)≠0) + (hp : ∀ j,Q ((u+L)+ξ j)≠0) (s t : Space N) : + sourceWbarᵀ.map C*forwardPair (JRow N ξ (u+L)) (JRow N ξ (u-L)) s t= + JRow N ξ u s t*sourceWbarᵀ.map C := by + rw [forward_JRow] + change _=(row N (exactSites N ξ u) s t).map C*sourceWbarᵀ.map C + rw [←Matrix.map_mul,←Matrix.map_mul,source_row_quotient_fusion N ξ u hm hu hp] + +theorem closed_fusion_compression (N : ℕ) (ξ : Fin N→ℝ) (i : Fin N) (u : ℝ) + (hnode : u=L-ξ i ∨ u=L+ξ i) (hm : Nonsingular N ξ (u-L)) + (hp : Nonsingular N ξ (u+L)) (hu : Nonsingular N ξ u) + (hQt : Q (2*u)≠0) (hQr : Q (2*(b-u))≠0) : + close4 (matrixBoundary (markedFusionVector eL (2*(b-u)) ((b-u)+L) ((b-u)-L))) + (matrixBoundary (markedFusionVector eR (2*u) (u-L) (u+L))) + (pairAB (backwardPair (JRow N ξ (u+L)) (JRow N ξ (u-L)))* + pairCD (forwardPair (JRow N ξ ((b-u)+L)) (JRow N ξ ((b-u)-L))))=T N ξ u := by + have hpm : b-(u+L)=(b-u)-L := by ring + have hmm : b-(u-L)=(b-u)+L := by ring + have hmR : ∀ j,Q (((b-u)-L)+ξ j)≠0 := by + intro j;simpa only [hpm] using (hp.2.2 j).2 + have hpR : ∀ j,Q (((b-u)+L)+ξ j)≠0 := by + intro j;simpa only [hmm] using (hm.2.2 j).2 + have hrm : sine (gamma+((b-u)-L))≠0 := by simpa only [hpm] using hp.2.1 + have hrp : sine (gamma+((b-u)+L))≠0 := by simpa only [hmm] using hm.2.1 + have hL:=marked_fusion_left eL (by simpa only [pow_two] using eL_sq) (b-u) + hQr hu.2.1 hrm hrp + have hR:=marked_fusion_right eR (by simpa only [pow_two] using eR_sq) u hQt hu.1 hm.1 hp.1 + funext s t + rw [close4_fusion_contract,T_closePair] + change _=closePair (forwardPair (JRow N ξ u) (JRow N ξ (b-u))) + (fun p=>wallMatrix eL (b-u) p.1 p.2) (fun p=>wallMatrix eR u p.1 p.2) s t + rw [closePair_fusion_contract] + apply Finset.sum_congr rfl;intro v hv + have hF:=JRow_fusion N ξ u (fun j=>(hm.2.2 j).1) (fun j=>(hu.2.2 j).1) + (fun j=>(hp.2.2 j).1) s v + have hG:=JRow_quotient_fusion N ξ (b-u) hmR (fun j=>(hu.2.2 j).2) hpR v t + rcases hnode with hn|hn + · have hJ : sourceJ.map C*sourceW.map C=1 := by rw [←Matrix.map_mul,sourceJ_W,Matrix.map_one] <;> simp + have hP : sourceW.map C*sourceJ.map C* + backwardPair (JRow N ξ (u+L)) (JRow N ξ (u-L)) s v= + backwardPair (JRow N ξ (u+L)) (JRow N ξ (u-L)) s v := by + rw [backward_JRow,←Matrix.map_mul,←Matrix.map_mul] + rw [first_node_projection N ξ i u hn (fun j=>(hm.2.2 j).1) + (fun j=>(hu.2.2 j).1) (fun j=>(hp.2.2 j).1)] + exact range_compression (sourceW.map C) (sourceJ.map C) (sourceWbarᵀ.map C) + _ _ _ _ _ _ _ _ hJ hP hF hG hL hR + · have hV : sourceWbarᵀ.map C*sourceJᵀ.map C=1 := by + rw [←Matrix.map_mul,sourceWbar_J,Matrix.map_one] <;> simp + have hQ : forwardPair (JRow N ξ ((b-u)+L)) (JRow N ξ ((b-u)-L)) v t* + sourceJᵀ.map C*sourceWbarᵀ.map C= + forwardPair (JRow N ξ ((b-u)+L)) (JRow N ξ ((b-u)-L)) v t := by + rw [forward_JRow,←Matrix.map_mul,←Matrix.map_mul] + rw [second_node_projection N ξ i u hn hmR (fun j=>(hu.2.2 j).2) hpR] + exact quotient_compression (sourceW.map C) (sourceWbarᵀ.map C) (sourceJᵀ.map C) + _ _ _ _ _ _ _ _ hV hQ hF hG hL hR +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection Reflection.Fusion RowExchange BoundaryJet ClosedFourRow +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid + +theorem closed_fusion_generic (N : ℕ) (ξ : Fin N→ℝ) (i : Fin N) (u : ℝ) + (hnode : u=L-ξ i ∨ u=L+ξ i) (hm : Nonsingular N ξ (u-L)) + (hp : Nonsingular N ξ (u+L)) (hu : Nonsingular N ξ u) + (hQt : Q (2*u)≠0) (hQr : Q (2*(b-u))≠0) : + T N ξ (u-L)*T N ξ (u+L)=T N ξ u := by + have hpm : b-(u+L)=(b-u)-L := by ring + have hmm : b-(u-L)=(b-u)+L := by ring + have hd : Q (b-2*u)≠0 := by rw [reflected_Q];exact hQt + have hnd : Q (-(b-2*u))≠0 := by + rw [show -(b-2*u)=b-2*(b-u) by ring,reflected_Q] + exact hQr + have hGFc : (spectralR (-(b-2*u)))ᵀ*spectralR (b-2*u)=1 := + mul_eq_one_comm.mp (spectral_unitarity (b-2*u) hd hnd) + have hGF : (spectralR (-(b-2*u)))ᵀ.map C*(spectralR (b-2*u)).map C=1 := by + rw [←Matrix.map_mul,hGFc,Matrix.map_one] <;> simp + have he : ∀ s t,(spectralR (b-2*u)).map C* + forwardPair (JRow N ξ ((b-u)+L)) (JRow N ξ (u+L)) s t= + backwardPair (JRow N ξ ((b-u)+L)) (JRow N ξ (u+L)) s t*(spectralR (b-2*u)).map C := by + have hx : ((b-u)+L)-(u+L)=b-2*u := by ring + have hr : ∀ j,Q (((b-u)+L)+ξ j)≠0 := by + intro j;simpa only [hmm] using (hm.2.2 j).2 + simpa only [hx] using JRow_exchange N ξ ((b-u)+L) (u+L) hr + (fun j=>(hp.2.2 j).1) (by simpa only [hx] using hd) + rw [T_closePair,T_closePair,hpm,hmm] + rw [middle_close (JRow N ξ (u+L)) (JRow N ξ (u-L)) + (JRow N ξ ((b-u)+L)) (JRow N ξ ((b-u)-L)) + ((spectralR (b-2*u)).map C) ((spectralR (-(b-2*u)))ᵀ.map C) hGF he] + rw [marked_middle_left,marked_middle_right] + exact closed_fusion_compression N ξ i u hnode hm hp hu hQt hQr +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet Filter Topology +open scoped Matrix BigOperators +lemma continuousAt_row_curve (N : ℕ) (Ξ : ℝ→Fin N→ℝ) (f : ℝ→ℝ) (x : ℝ) + (hΞ : ∀ i,ContinuousAt (fun y=>Ξ y i) x) (hf : ContinuousAt f x) + (hQ : ∀ i,Q (f x+Ξ x i)≠0) (s t : Space N) : + ContinuousAt (fun y=>row N (exactSites N (Ξ y) (f y)) s t) x := by + apply continuousAt_row + intro i + exact (continuousAt_spectralR _ (hQ i)).comp (f:=fun y=>f y+Ξ y i) (hf.add (hΞ i)) +lemma continuousAt_bulkRows_curve (N : ℕ) (Ξ : ℝ→Fin N→ℝ) (f : ℝ→ℝ) (x : ℝ) + (hΞ : ∀ i,ContinuousAt (fun y=>Ξ y i) x) (hf : ContinuousAt f x) + (hns : Nonsingular N (Ξ x) (f x)) (s t : Space N) : + ContinuousAt (fun y=>bulkRows N (Ξ y) (f y) s t) x := by + apply continuousAt_pi.2;intro p + apply continuousAt_pi.2;intro q + unfold bulkRows forward + simp only [Matrix.sum_apply] + apply tendsto_finsetSum;intro v hv + exact (matrix_entry_continuousAt (continuousAt_row_curve N Ξ f x hΞ hf + (fun i=>(hns.2.2 i).1) s v) p.1 q.1).mul + (matrix_entry_continuousAt (continuousAt_row_curve N Ξ (fun y=>b-f y) x hΞ + (continuousAt_const.sub hf) (fun i=>(hns.2.2 i).2) v t) p.2 q.2) +lemma continuousAt_T_curve (N : ℕ) (Ξ : ℝ→Fin N→ℝ) (f : ℝ→ℝ) (x : ℝ) + (hΞ : ∀ i,ContinuousAt (fun y=>Ξ y i) x) (hf : ContinuousAt f x) + (hns : Nonsingular N (Ξ x) (f x)) : + ContinuousAt (fun y=>T N (Ξ y) (f y)) x := by + apply continuousAt_pi.2;intro s + apply continuousAt_pi.2;intro t + unfold T + apply tendsto_finsetSum;intro p hp + apply tendsto_finsetSum;intro q hq + exact (((continuousAt_K eL (b-f x) hns.2.1 p).comp (f:=fun y=>b-f y) + (continuousAt_const.sub hf)).mul + (continuous_C.continuousAt.comp (matrix_entry_continuousAt + (continuousAt_bulkRows_curve N Ξ f x hΞ hf hns s t) p q))).mul + ((continuousAt_K eR (f x) hns.1 q).comp (f:=f) hf) +lemma eventually_nonsingular_curve (N : ℕ) (Ξ : ℝ→Fin N→ℝ) (f : ℝ→ℝ) (x : ℝ) + (hΞ : ∀ i,ContinuousAt (fun y=>Ξ y i) x) (hf : ContinuousAt f x) + (hns : Nonsingular N (Ξ x) (f x)) : + ∀ᶠ y in 𝓝 x,Nonsingular N (Ξ y) (f y) := by + have h0 := (continuous_sine.continuousAt.comp (continuousAt_const.add hf)).eventually_ne hns.1 + have h1 := (continuous_sine.continuousAt.comp + (continuousAt_const.add (continuousAt_const.sub hf))).eventually_ne hns.2.1 + have h2 : ∀ᶠ y in 𝓝 x,∀ i,Q (f y+Ξ y i)≠0 ∧ Q ((b-f y)+Ξ y i)≠0 := by + apply Filter.eventually_all.2;intro i + exact ((continuous_Q.continuousAt.comp (hf.add (hΞ i))).eventually_ne (hns.2.2 i).1).and + ((continuous_Q.continuousAt.comp ((continuousAt_const.sub hf).add (hΞ i))).eventually_ne + (hns.2.2 i).2) + exact h0.and (h1.and h2) +lemma dense_fusion_regular : Dense {u : ℝ|Q (2*u)≠0 ∧ Q (2*(b-u))≠0} := by + have h0:=Q_zero_countable.preimage (f:=fun u : ℝ=>2*u) (fun x y h=>by linarith) + have h1:=Q_zero_countable.preimage (f:=fun u : ℝ=>2*(b-u)) (fun x y h=>by linarith) + have hd:=(h0.union h1).dense_compl ℝ + convert hd using 1 + ext u + simp only [Set.mem_compl_iff,Set.mem_union,Set.mem_preimage,Set.mem_ofPred_eq] + tauto +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection BoundaryJet Filter Topology +open scoped Matrix BigOperators +lemma fusion_along_nodes (N : ℕ) (Ξ : ℝ→Fin N→ℝ) (i : Fin N) (x : ℝ) + (hΞ : ∀ j,ContinuousAt (fun y=>Ξ y j) x) + (hnode : ∀ y,y=L-Ξ y i ∨ y=L+Ξ y i) + (hm : Nonsingular N (Ξ x) (x-L)) (hp : Nonsingular N (Ξ x) (x+L)) + (hu : Nonsingular N (Ξ x) x) : + T N (Ξ x) (x-L)*T N (Ξ x) (x+L)=T N (Ξ x) x := by + let D : Set ℝ := {y | Q (2*y)≠0 ∧ Q (2*(b-y))≠0} + have hd : Dense D := dense_fusion_regular + have : Filter.NeBot (𝓝[D] x) := mem_closure_iff_nhdsWithin_neBot.mp (hd x) + have cm := continuousAt_T_curve N Ξ (fun y=>y-L) x hΞ + (continuousAt_id.sub continuousAt_const) hm + have cp := continuousAt_T_curve N Ξ (fun y=>y+L) x hΞ + (continuousAt_id.add continuousAt_const) hp + have cu := continuousAt_T_curve N Ξ id x hΞ continuousAt_id hu + have hf : Tendsto (fun y=>T N (Ξ y) (y-L)*T N (Ξ y) (y+L)) (𝓝[D] x) + (𝓝 (T N (Ξ x) (x-L)*T N (Ξ x) (x+L))) := + (cm.mul cp).mono_left nhdsWithin_le_nhds + have hg : Tendsto (fun y=>T N (Ξ y) y) (𝓝[D] x) (𝓝 (T N (Ξ x) x)) := + cu.mono_left nhdsWithin_le_nhds + have he : (fun y=>T N (Ξ y) (y-L)*T N (Ξ y) (y+L)) =ᶠ[𝓝[D] x] + (fun y=>T N (Ξ y) y) := by + have hmem : ∀ᶠ y in 𝓝[D] x,y∈D := self_mem_nhdsWithin + have em := (eventually_nonsingular_curve N Ξ (fun y=>y-L) x hΞ + (continuousAt_id.sub continuousAt_const) hm).filter_mono (nhdsWithin_le_nhds (s:=D)) + have ep := (eventually_nonsingular_curve N Ξ (fun y=>y+L) x hΞ + (continuousAt_id.add continuousAt_const) hp).filter_mono (nhdsWithin_le_nhds (s:=D)) + have eu := (eventually_nonsingular_curve N Ξ id x hΞ continuousAt_id hu).filter_mono + (nhdsWithin_le_nhds (s:=D)) + filter_upwards [hmem,em,ep,eu] with y hy hym hyp hyu + exact closed_fusion_generic N (Ξ y) i y (hnode y) hym hyp hyu hy.1 hy.2 + exact tendsto_nhds_unique_of_eventuallyEq hf hg he + +theorem source_global_spectral_fusion : GlobalSpectralFusion := by + intro N ξ i u hnode hm hp hu + rcases hnode with hn|hn + · let Ξ : ℝ→Fin N→ℝ := fun y j=>ξ j+(u-y) + have hx : Ξ u=ξ := by funext j;simp [Ξ] + have hy : ∀ y,y=L-Ξ y i ∨ y=L+Ξ y i := by + intro y;left;dsimp [Ξ];linarith + simpa only [hx] using fusion_along_nodes N Ξ i u + (fun j=>continuousAt_const.add (continuousAt_const.sub continuousAt_id)) hy + (by simpa only [hx] using hm) (by simpa only [hx] using hp) (by simpa only [hx] using hu) + · let Ξ : ℝ→Fin N→ℝ := fun y j=>ξ j+(y-u) + have hx : Ξ u=ξ := by funext j;simp [Ξ] + have hy : ∀ y,y=L-Ξ y i ∨ y=L+Ξ y i := by + intro y;right;dsimp [Ξ];linarith + simpa only [hx] using fusion_along_nodes N Ξ i u + (fun j=>continuousAt_const.add (continuousAt_id.sub continuousAt_const)) hy + (by simpa only [hx] using hm) (by simpa only [hx] using hp) (by simpa only [hx] using hu) +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ClosedRows.lean b/lean/OAI/Combinatorics/HoneycombChords/ClosedRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..87867b291dc1b6a313b865350bb597b33af0be07 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ClosedRows.lean @@ -0,0 +1,645 @@ +import Mathlib.LinearAlgebra.Matrix.Kronecker +import Mathlib.Tactic.Ring + +namespace OAI + +/-! Four-row transfer identities and boundary contractions. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +section + +namespace CriticalHoneycomb.Transfer.ClosedFourRow +open scoped Matrix BigOperators + +section Algebra +variable {R : Type*} [Monoid R] +lemma middle_exchange (A B C D E : R) (hA : Commute E A) (hD : Commute E D) + (h : E*(B*C)=(C*B)*E) : E*(A*B*C*D)=(A*C*B*D)*E := by + calc + _ = (E*A)*(B*C)*D := by simp only [mul_assoc] + _ = (A*E)*(B*C)*D := by rw [hA.eq] + _ = A*(E*(B*C))*D := by simp only [mul_assoc] + _ = A*((C*B)*E)*D := by rw [h] + _ = (A*C*B)*(E*D) := by simp only [mul_assoc] + _ = (A*C*B)*(D*E) := by rw [hD.eq] + _ = _ := by simp only [mul_assoc] +lemma first_exchange (A B C D E : R) (hC : Commute E C) (hD : Commute E D) + (h : E*(A*B)=(B*A)*E) : E*(A*B*C*D)=(B*A*C*D)*E := by + calc + _ = (E*(A*B))*C*D := by simp only [mul_assoc] + _ = ((B*A)*E)*C*D := by rw [h] + _ = (B*A)*(E*C)*D := by simp only [mul_assoc] + _ = (B*A)*(C*E)*D := by rw [hC.eq] + _ = (B*A*C)*(E*D) := by simp only [mul_assoc] + _ = (B*A*C)*(D*E) := by rw [hD.eq] + _ = _ := by simp only [mul_assoc] +lemma last_exchange (A B C D E : R) (hA : Commute E A) (hB : Commute E B) + (h : E*(C*D)=(D*C)*E) : E*(A*B*C*D)=(A*B*D*C)*E := by + calc + _ = (E*A)*(B*(C*D)) := by simp only [mul_assoc] + _ = (A*E)*(B*(C*D)) := by rw [hA.eq] + _ = A*(E*B)*(C*D) := by simp only [mul_assoc] + _ = A*(B*E)*(C*D) := by rw [hB.eq] + _ = (A*B)*(E*(C*D)) := by simp only [mul_assoc] + _ = (A*B)*((D*C)*E) := by rw [h] + _ = _ := by simp only [mul_assoc] + +theorem four_train (A B C D E₁ E₂ E₃ E₄ : R) + (h₁ : E₁*(A*B*C*D)=(A*C*B*D)*E₁) + (h₂ : E₂*(A*C*B*D)=(C*A*B*D)*E₂) + (h₃ : E₃*(C*A*B*D)=(C*A*D*B)*E₃) + (h₄ : E₄*(C*A*D*B)=(C*D*A*B)*E₄) : + (E₄*E₃*E₂*E₁)*(A*B*C*D)=(C*D*A*B)*(E₄*E₃*E₂*E₁) := by + calc + _ = (E₄*E₃*E₂)*(E₁*(A*B*C*D)) := by simp only [mul_assoc] + _ = (E₄*E₃*E₂)*((A*C*B*D)*E₁) := by rw [h₁] + _ = (E₄*E₃)*(E₂*(A*C*B*D))*E₁ := by simp only [mul_assoc] + _ = (E₄*E₃)*((C*A*B*D)*E₂)*E₁ := by rw [h₂] + _ = E₄*(E₃*(C*A*B*D))*E₂*E₁ := by simp only [mul_assoc] + _ = E₄*((C*A*D*B)*E₃)*E₂*E₁ := by rw [h₃] + _ = (E₄*(C*A*D*B))*E₃*E₂*E₁ := by simp only [mul_assoc] + _ = ((C*D*A*B)*E₄)*E₃*E₂*E₁ := by rw [h₄] + _ = _ := by simp only [mul_assoc] +end Algebra + +section Lift +variable {α ι k : Type*} [CommSemiring k] [Fintype α] [DecidableEq α] [Fintype ι] [DecidableEq ι] +abbrev Aux (α : Type*) := α × α × α × α +abbrev AuxSite (α ι : Type*) := Aux α × ι +abbrev Row (α ι k : Type*) := ι → ι → Matrix α α k +abbrev Total (α ι k : Type*) := Matrix (AuxSite α ι) (AuxSite α ι) k +noncomputable def rowA (M : Row α ι k) : Total α ι k := fun p q => + M p.2 q.2 p.1.1 q.1.1 * + (1 : Matrix α α k) p.1.2.1 q.1.2.1 * (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 * + (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 +noncomputable def rowB (M : Row α ι k) : Total α ι k := fun p q => + M p.2 q.2 p.1.2.1 q.1.2.1 * + (1 : Matrix α α k) p.1.1 q.1.1 * (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 * + (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 +noncomputable def rowC (M : Row α ι k) : Total α ι k := fun p q => + M p.2 q.2 p.1.2.2.1 q.1.2.2.1 * + (1 : Matrix α α k) p.1.1 q.1.1 * (1 : Matrix α α k) p.1.2.1 q.1.2.1 * + (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 +noncomputable def rowD (M : Row α ι k) : Total α ι k := fun p q => + M p.2 q.2 p.1.2.2.2 q.1.2.2.2 * + (1 : Matrix α α k) p.1.1 q.1.1 * (1 : Matrix α α k) p.1.2.1 q.1.2.1 * + (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 +noncomputable def exBC (F : Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + F (p.1.2.1,p.1.2.2.1) (q.1.2.1,q.1.2.2.1) * + (1 : Matrix α α k) p.1.1 q.1.1 * (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 * + (1 : Matrix ι ι k) p.2 q.2 +lemma exBC_rowA (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exBC F) (rowA M) := by + change exBC F * rowA M = rowA M * exBC F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBC,rowA,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +lemma exBC_rowD (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exBC F) (rowD M) := by + change exBC F * rowD M = rowD M * exBC F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBC,rowD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +noncomputable def exAC (F : Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + F (p.1.1,p.1.2.2.1) (q.1.1,q.1.2.2.1) * + (1 : Matrix α α k) p.1.2.1 q.1.2.1 * + (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 * + (1 : Matrix ι ι k) p.2 q.2 +lemma exAC_rowB (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exAC F) (rowB M) := by + change exAC F * rowB M = rowB M * exAC F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAC,rowB,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +lemma exAC_rowD (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exAC F) (rowD M) := by + change exAC F * rowD M = rowD M * exAC F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAC,rowD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +noncomputable def exBD (F : Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + F (p.1.2.1,p.1.2.2.2) (q.1.2.1,q.1.2.2.2) * + (1 : Matrix α α k) p.1.1 q.1.1 * + (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 * + (1 : Matrix ι ι k) p.2 q.2 +lemma exBD_rowA (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exBD F) (rowA M) := by + change exBD F * rowA M = rowA M * exBD F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBD,rowA,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +lemma exBD_rowC (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exBD F) (rowC M) := by + change exBD F * rowC M = rowC M * exBD F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBD,rowC,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +noncomputable def exAD (F : Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + F (p.1.1,p.1.2.2.2) (q.1.1,q.1.2.2.2) * + (1 : Matrix α α k) p.1.2.1 q.1.2.1 * + (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 * + (1 : Matrix ι ι k) p.2 q.2 +lemma exAD_rowB (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exAD F) (rowB M) := by + change exAD F * rowB M = rowB M * exAD F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAD,rowB,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +lemma exAD_rowC (F : Matrix (α×α) (α×α) k) (M : Row α ι k) : + Commute (exAD F) (rowC M) := by + change exAD F * rowC M = rowC M * exAD F + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAD,rowC,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + split_ifs <;> ring +noncomputable def forwardPair (M N : Row α ι k) (s t : ι) : Matrix (α×α) (α×α) k := + ∑ v, Matrix.kronecker (M s v) (N v t) +noncomputable def backwardPair (M N : Row α ι k) (s t : ι) : Matrix (α×α) (α×α) k := + ∑ v, Matrix.kronecker (M v t) (N s v) +noncomputable def pairBC (P : ι → ι → Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + P p.2 q.2 (p.1.2.1,p.1.2.2.1) (q.1.2.1,q.1.2.2.1) * + (1 : Matrix α α k) p.1.1 q.1.1 * + (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 +omit [DecidableEq ι] in +lemma pairBC_forward (M N : Row α ι k) : + rowB M * rowC N = pairBC (forwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowB,rowC,pairBC,forwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] +omit [DecidableEq ι] in +lemma pairBC_backward (M N : Row α ι k) : + rowC N * rowB M = pairBC (backwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowB,rowC,pairBC,backwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] + split_ifs <;> simp_all [mul_comm] +lemma exBC_left (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + exBC F * pairBC P = pairBC (fun s t => F * P s t) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBC,pairBC,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exBC_right (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + pairBC P * exBC F = pairBC (fun s t => P s t * F) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBC,pairBC,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exchangeBC (F : Matrix (α×α) (α×α) k) (M N : Row α ι k) + (h : ∀ s t, F * forwardPair M N s t = backwardPair M N s t * F) : + exBC F * (rowB M * rowC N) = (rowC N * rowB M) * exBC F := by + rw [pairBC_forward,pairBC_backward,exBC_left,exBC_right] + congr 1 + funext s t + exact h s t +noncomputable def pairAC (P : ι → ι → Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + P p.2 q.2 (p.1.1,p.1.2.2.1) (q.1.1,q.1.2.2.1) * + (1 : Matrix α α k) p.1.2.1 q.1.2.1 * + (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 +omit [DecidableEq ι] in +lemma pairAC_forward (M N : Row α ι k) : + rowA M * rowC N = pairAC (forwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowA,rowC,pairAC,forwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] +omit [DecidableEq ι] in +lemma pairAC_backward (M N : Row α ι k) : + rowC N * rowA M = pairAC (backwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowA,rowC,pairAC,backwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] + split_ifs <;> simp_all [mul_comm] +lemma exAC_left (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + exAC F * pairAC P = pairAC (fun s t => F * P s t) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAC,pairAC,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exAC_right (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + pairAC P * exAC F = pairAC (fun s t => P s t * F) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAC,pairAC,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exchangeAC (F : Matrix (α×α) (α×α) k) (M N : Row α ι k) + (h : ∀ s t, F * forwardPair M N s t = backwardPair M N s t * F) : + exAC F * (rowA M * rowC N) = (rowC N * rowA M) * exAC F := by + rw [pairAC_forward,pairAC_backward,exAC_left,exAC_right] + congr 1 + funext s t + exact h s t +noncomputable def pairBD (P : ι → ι → Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + P p.2 q.2 (p.1.2.1,p.1.2.2.2) (q.1.2.1,q.1.2.2.2) * + (1 : Matrix α α k) p.1.1 q.1.1 * + (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 +omit [DecidableEq ι] in +lemma pairBD_forward (M N : Row α ι k) : + rowB M * rowD N = pairBD (forwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowB,rowD,pairBD,forwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] +omit [DecidableEq ι] in +lemma pairBD_backward (M N : Row α ι k) : + rowD N * rowB M = pairBD (backwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowB,rowD,pairBD,backwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] + split_ifs <;> simp_all [mul_comm] +lemma exBD_left (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + exBD F * pairBD P = pairBD (fun s t => F * P s t) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBD,pairBD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exBD_right (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + pairBD P * exBD F = pairBD (fun s t => P s t * F) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exBD,pairBD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exchangeBD (F : Matrix (α×α) (α×α) k) (M N : Row α ι k) + (h : ∀ s t, F * forwardPair M N s t = backwardPair M N s t * F) : + exBD F * (rowB M * rowD N) = (rowD N * rowB M) * exBD F := by + rw [pairBD_forward,pairBD_backward,exBD_left,exBD_right] + congr 1 + funext s t + exact h s t +noncomputable def pairAD (P : ι → ι → Matrix (α×α) (α×α) k) : Total α ι k := fun p q => + P p.2 q.2 (p.1.1,p.1.2.2.2) (q.1.1,q.1.2.2.2) * + (1 : Matrix α α k) p.1.2.1 q.1.2.1 * + (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 +omit [DecidableEq ι] in +lemma pairAD_forward (M N : Row α ι k) : + rowA M * rowD N = pairAD (forwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowA,rowD,pairAD,forwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] +omit [DecidableEq ι] in +lemma pairAD_backward (M N : Row α ι k) : + rowD N * rowA M = pairAD (backwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowA,rowD,pairAD,backwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] + split_ifs <;> simp_all [mul_comm] +lemma exAD_left (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + exAD F * pairAD P = pairAD (fun s t => F * P s t) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAD,pairAD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exAD_right (F : Matrix (α×α) (α×α) k) + (P : ι → ι → Matrix (α×α) (α×α) k) : + pairAD P * exAD F = pairAD (fun s t => P s t * F) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [exAD,pairAD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +lemma exchangeAD (F : Matrix (α×α) (α×α) k) (M N : Row α ι k) + (h : ∀ s t, F * forwardPair M N s t = backwardPair M N s t * F) : + exAD F * (rowA M * rowD N) = (rowD N * rowA M) * exAD F := by + rw [pairAD_forward,pairAD_backward,exAD_left,exAD_right] + congr 1 + funext s t + exact h s t + +theorem lifted_four_train (A B C D : Row α ι k) + (F₁ F₂ F₃ F₄ : Matrix (α×α) (α×α) k) + (h₁ : ∀ s t, F₁ * forwardPair B C s t = backwardPair B C s t * F₁) + (h₂ : ∀ s t, F₂ * forwardPair A C s t = backwardPair A C s t * F₂) + (h₃ : ∀ s t, F₃ * forwardPair B D s t = backwardPair B D s t * F₃) + (h₄ : ∀ s t, F₄ * forwardPair A D s t = backwardPair A D s t * F₄) : + (exAD F₄ * exBD F₃ * exAC F₂ * exBC F₁) * + (rowA A * rowB B * rowC C * rowD D) = + (rowC C * rowD D * rowA A * rowB B) * + (exAD F₄ * exBD F₃ * exAC F₂ * exBC F₁) := by + apply four_train + · exact middle_exchange _ _ _ _ _ (exBC_rowA F₁ A) (exBC_rowD F₁ D) + (exchangeBC F₁ B C h₁) + · exact first_exchange _ _ _ _ _ (exAC_rowB F₂ B) (exAC_rowD F₂ D) + (exchangeAC F₂ A C h₂) + · exact last_exchange _ _ _ _ _ (exBD_rowC F₃ C) (exBD_rowA F₃ A) + (exchangeBD F₃ B D h₃) + · exact middle_exchange _ _ _ _ _ (exAD_rowC F₄ C) (exAD_rowB F₄ B) + (exchangeAD F₄ A D h₄) +end Lift +end CriticalHoneycomb.Transfer.ClosedFourRow + +end + +section + +namespace CriticalHoneycomb.Transfer.ClosedFourRow +open scoped Matrix BigOperators + +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +section +variable {α ι k : Type*} [CommSemiring k] [Fintype α] [DecidableEq α] + [Fintype ι] [DecidableEq ι] +noncomputable def auxLift (U : Matrix (Aux α) (Aux α) k) : Total α ι k := Matrix.kronecker U 1 +noncomputable def leftWall (l : Aux α → k) : Matrix ι (AuxSite α ι) k := + fun s p => l p.1 * (1 : Matrix ι ι k) s p.2 +noncomputable def rightWall (r : Aux α → k) : Matrix (AuxSite α ι) ι k := + fun p t => r p.1 * (1 : Matrix ι ι k) p.2 t +omit [DecidableEq α] in +lemma auxLift_mul (U V : Matrix (Aux α) (Aux α) k) : + (auxLift (U*V) : Total α ι k) = auxLift U * auxLift V := by + simpa only [auxLift,Matrix.kronecker,one_mul] using + Matrix.mul_kronecker_mul U V (1 : Matrix ι ι k) (1 : Matrix ι ι k) +omit [DecidableEq α] in +lemma auxLift_rightWall (U : Matrix (Aux α) (Aux α) k) (r : Aux α → k) : + (auxLift U : Total α ι k) * rightWall r = rightWall (U *ᵥ r) := by + ext ⟨a,s⟩ t + simp [auxLift,rightWall,Matrix.mul_apply,Matrix.kronecker,Matrix.kroneckerMap, + Matrix.one_apply,Matrix.mulVec,dotProduct,Fintype.sum_prod_type,mul_ite,ite_mul] +omit [DecidableEq α] in +lemma leftWall_auxLift (U : Matrix (Aux α) (Aux α) k) (l : Aux α → k) : + (leftWall l : Matrix ι (AuxSite α ι) k) * auxLift U = leftWall (l ᵥ* U) := by + ext s ⟨a,t⟩ + simp [auxLift,leftWall,Matrix.mul_apply,Matrix.kronecker,Matrix.kroneckerMap, + Matrix.one_apply,Matrix.vecMul,dotProduct,Fintype.sum_prod_type,mul_ite,ite_mul] +noncomputable def close4 (l r : Aux α → k) (X : Total α ι k) : Matrix ι ι k := + leftWall l * X * rightWall r + +omit [DecidableEq α] in +lemma close_train (U : Matrix (Aux α) (Aux α) k) (X Y : Total α ι k) + (l r : Aux α → k) (h : auxLift U * X = Y * auxLift U) + (hl : l ᵥ* U = l) (hr : U *ᵥ r = r) : + close4 l r X = close4 l r Y := by + have hL : (leftWall l : Matrix ι (AuxSite α ι) k) * auxLift U = leftWall l := by + rw [leftWall_auxLift,hl] + have hR : (auxLift U : Total α ι k) * rightWall r = rightWall r := by + rw [auxLift_rightWall,hr] + let Lw : Matrix ι (AuxSite α ι) k := leftWall l + let Rw : Matrix (AuxSite α ι) ι k := rightWall r + let E : Total α ι k := auxLift U + have hL' : Lw * E = Lw := hL + have hR' : E * Rw = Rw := hR + change Lw * X * Rw = Lw * Y * Rw + calc + _ = (Lw * E) * X * Rw := by rw [hL'] + _ = Lw * (E * X) * Rw := by simp only [Matrix.mul_assoc] + _ = Lw * (Y * E) * Rw := by rw [h] + _ = (Lw * Y) * (E * Rw) := by simp only [Matrix.mul_assoc] + _ = _ := by rw [hR'] +noncomputable def auxBC (F : Matrix (α×α) (α×α) k) : Matrix (Aux α) (Aux α) k := + fun p q => F (p.2.1,p.2.2.1) (q.2.1,q.2.2.1) * + (1 : Matrix α α k) p.1 q.1 * (1 : Matrix α α k) p.2.2.2 q.2.2.2 +noncomputable def auxAC (F : Matrix (α×α) (α×α) k) : Matrix (Aux α) (Aux α) k := + fun p q => F (p.1,p.2.2.1) (q.1,q.2.2.1) * + (1 : Matrix α α k) p.2.1 q.2.1 * (1 : Matrix α α k) p.2.2.2 q.2.2.2 +noncomputable def auxBD (F : Matrix (α×α) (α×α) k) : Matrix (Aux α) (Aux α) k := + fun p q => F (p.2.1,p.2.2.2) (q.2.1,q.2.2.2) * + (1 : Matrix α α k) p.1 q.1 * (1 : Matrix α α k) p.2.2.1 q.2.2.1 +noncomputable def auxAD (F : Matrix (α×α) (α×α) k) : Matrix (Aux α) (Aux α) k := + fun p q => F (p.1,p.2.2.2) (q.1,q.2.2.2) * + (1 : Matrix α α k) p.2.1 q.2.1 * (1 : Matrix α α k) p.2.2.1 q.2.2.1 +omit [Fintype α] [Fintype ι] in +lemma exBC_aux (F : Matrix (α×α) (α×α) k) : + (exBC F : Total α ι k) = auxLift (auxBC F) := rfl +omit [Fintype α] [Fintype ι] in +lemma exAC_aux (F : Matrix (α×α) (α×α) k) : + (exAC F : Total α ι k) = auxLift (auxAC F) := rfl +omit [Fintype α] [Fintype ι] in +lemma exBD_aux (F : Matrix (α×α) (α×α) k) : + (exBD F : Total α ι k) = auxLift (auxBD F) := rfl +omit [Fintype α] [Fintype ι] in +lemma exAD_aux (F : Matrix (α×α) (α×α) k) : + (exAD F : Total α ι k) = auxLift (auxAD F) := rfl +noncomputable def auxTrain (F₁ F₂ F₃ F₄ : Matrix (α×α) (α×α) k) : + Matrix (Aux α) (Aux α) k := auxAD F₄ * auxBD F₃ * auxAC F₂ * auxBC F₁ +lemma auxTrain_lift (F₁ F₂ F₃ F₄ : Matrix (α×α) (α×α) k) : + (auxLift (auxTrain F₁ F₂ F₃ F₄) : Total α ι k) = + exAD F₄ * exBD F₃ * exAC F₂ * exBC F₁ := by + simp only [auxTrain,auxLift_mul,exAD_aux,exBD_aux,exAC_aux,exBC_aux] +end +end CriticalHoneycomb.Transfer.ClosedFourRow + +end + +section + +namespace CriticalHoneycomb.Transfer.ClosedFourRow +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +section +variable {α ι k : Type*} [CommSemiring k] [Fintype α] [DecidableEq α] + [Fintype ι] [DecidableEq ι] +noncomputable def pairAB (P : ι → ι → Matrix (α×α) (α×α) k) : Total α ι k := + fun p q => P p.2 q.2 (p.1.1,p.1.2.1) (q.1.1,q.1.2.1) * + (1 : Matrix α α k) p.1.2.2.1 q.1.2.2.1 * + (1 : Matrix α α k) p.1.2.2.2 q.1.2.2.2 +noncomputable def pairCD (P : ι → ι → Matrix (α×α) (α×α) k) : Total α ι k := + fun p q => P p.2 q.2 (p.1.2.2.1,p.1.2.2.2) (q.1.2.2.1,q.1.2.2.2) * + (1 : Matrix α α k) p.1.1 q.1.1 * (1 : Matrix α α k) p.1.2.1 q.1.2.1 +omit [DecidableEq ι] in +lemma pairAB_forward (M N : Row α ι k) : rowA M * rowB N = pairAB (forwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowA,rowB,pairAB,forwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] +omit [DecidableEq ι] in +lemma pairCD_forward (M N : Row α ι k) : rowC M * rowD N = pairCD (forwardPair M N) := by + ext ⟨⟨a,b,c,d⟩,s⟩ ⟨⟨a',b',c',d'⟩,t⟩ + simp [rowC,rowD,pairCD,forwardPair,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.one_apply,mul_ite,ite_mul, + Matrix.sum_apply,Matrix.of_apply] +omit [DecidableEq ι] in +lemma pairAB_mul_CD (P Q : ι → ι → Matrix (α×α) (α×α) k) + (a b c d a' b' c' d' : α) (s t : ι) : + (pairAB P * pairCD Q) ((a,b,c,d),s) ((a',b',c',d'),t) = + ∑ v, P s v (a,b) (a',b') * Q v t (c,d) (c',d') := by + simp [pairAB,pairCD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] +omit [DecidableEq ι] in +lemma pairCD_mul_AB (P Q : ι → ι → Matrix (α×α) (α×α) k) + (a b c d a' b' c' d' : α) (s t : ι) : + (pairCD Q * pairAB P) ((a,b,c,d),s) ((a',b',c',d'),t) = + ∑ v, P v t (a,b) (a',b') * Q s v (c,d) (c',d') := by + simp [pairAB,pairCD,Matrix.mul_apply,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul,mul_comm] +noncomputable def tensorBoundary (l₁ l₂ : α×α → k) : Aux α → k := + fun p => l₁ (p.1,p.2.1) * l₂ (p.2.2.1,p.2.2.2) +noncomputable def closePair (P : ι → ι → Matrix (α×α) (α×α) k) + (l r : α×α → k) : Matrix ι ι k := fun s t => ∑ p, ∑ q, l p * P s t p q * r q +omit [DecidableEq α] in +lemma close4_apply (l r : Aux α → k) (X : Total α ι k) (s t : ι) : + close4 l r X s t = ∑ p, ∑ q, l p * X (p,s) (q,t) * r q := by + have hR (p : AuxSite α ι) : + (X * (rightWall r : Matrix (AuxSite α ι) ι k)) p t = ∑ q, X p (q,t) * r q := by + rw [Matrix.mul_apply,Fintype.sum_prod_type] + simp [rightWall,Matrix.one_apply,mul_ite] + rw [close4,Matrix.mul_assoc,Matrix.mul_apply,Fintype.sum_prod_type] + simp [leftWall,Matrix.one_apply,mul_ite,ite_mul,hR,Finset.mul_sum,mul_assoc] +omit [DecidableEq α] in +lemma sum_aux (f : Aux α → k) : + ∑ p, f p = ∑ p : α×α, ∑ q : α×α, f (p.1,p.2,q.1,q.2) := by + simp [Fintype.sum_prod_type] + +lemma five_sum_factor {β₁ β₂ β₃ β₄ ν : Type*} + [Fintype β₁] [Fintype β₂] [Fintype β₃] [Fintype β₄] [Fintype ν] + (F : ν → β₁ → β₃ → k) (G : ν → β₂ → β₄ → k) : + (∑ a, ∑ b, ∑ c, ∑ d, ∑ v, F v a c * G v b d) = + ∑ v, (∑ a, ∑ c, F v a c) * (∑ b, ∑ d, G v b d) := by + conv_lhs => + enter [2,a,2,b,2,c] + rw [Finset.sum_comm] + conv_lhs => + enter [2,a,2,b] + rw [Finset.sum_comm] + conv_lhs => + enter [2,a] + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro v hv + simp only [Finset.sum_mul] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a ha + rw [Finset.sum_comm] +lemma close4_pair_product (P Q : ι → ι → Matrix (α×α) (α×α) k) + (l₁ l₂ r₁ r₂ : α×α → k) : + close4 (tensorBoundary l₁ l₂) (tensorBoundary r₁ r₂) (pairAB P * pairCD Q) = + closePair P l₁ r₁ * closePair Q l₂ r₂ := by + ext s t + rw [close4_apply] + simp only [sum_aux,tensorBoundary,pairAB_mul_CD] + rw [Matrix.mul_apply] + simp only [closePair] + convert five_sum_factor + (fun v a c => l₁ a * P s v a c * r₁ c) + (fun v b d => l₂ b * Q v t b d * r₂ d) using 1 + simp only [Finset.mul_sum,Finset.sum_mul] + repeat first | apply Finset.sum_congr rfl; intro _ _ | ring + +lemma close4_pair_reverse (P Q : ι → ι → Matrix (α×α) (α×α) k) + (l₁ l₂ r₁ r₂ : α×α → k) : + close4 (tensorBoundary l₁ l₂) (tensorBoundary r₁ r₂) (pairCD Q * pairAB P) = + closePair Q l₂ r₂ * closePair P l₁ r₁ := by + ext s t + rw [close4_apply] + simp only [sum_aux,tensorBoundary,pairCD_mul_AB] + rw [Matrix.mul_apply] + simp only [closePair] + calc + _ = ∑ v, (∑ a, ∑ c, l₁ a * P v t a c * r₁ c) * + (∑ b, ∑ d, l₂ b * Q s v b d * r₂ d) := by + convert five_sum_factor + (fun v a c => l₁ a * P v t a c * r₁ c) + (fun v b d => l₂ b * Q s v b d * r₂ d) using 1 + simp only [Finset.mul_sum,Finset.sum_mul] + repeat first | apply Finset.sum_congr rfl; intro _ _ | ring + _ = _ := by apply Finset.sum_congr rfl; intro v hv; exact mul_comm _ _ + +theorem closed_four_train (A B C D : Row α ι k) + (F₁ F₂ F₃ F₄ : Matrix (α×α) (α×α) k) + (l₁ l₂ r₁ r₂ : α×α → k) + (h₁ : ∀ s t, F₁ * forwardPair B C s t = backwardPair B C s t * F₁) + (h₂ : ∀ s t, F₂ * forwardPair A C s t = backwardPair A C s t * F₂) + (h₃ : ∀ s t, F₃ * forwardPair B D s t = backwardPair B D s t * F₃) + (h₄ : ∀ s t, F₄ * forwardPair A D s t = backwardPair A D s t * F₄) + (hl : tensorBoundary l₁ l₂ ᵥ* auxTrain F₁ F₂ F₃ F₄ = tensorBoundary l₁ l₂) + (hr : auxTrain F₁ F₂ F₃ F₄ *ᵥ tensorBoundary r₁ r₂ = tensorBoundary r₁ r₂) : + Commute (closePair (forwardPair A B) l₁ r₁) (closePair (forwardPair C D) l₂ r₂) := by + have ht := lifted_four_train A B C D F₁ F₂ F₃ F₄ h₁ h₂ h₃ h₄ + rw [←auxTrain_lift] at ht + have hc := close_train _ _ _ _ _ ht hl hr + have hAB := pairAB_forward A B + have hCD := pairCD_forward C D + have he : rowA A * rowB B * rowC C * rowD D = + pairAB (forwardPair A B) * pairCD (forwardPair C D) := by + rw [←hAB,←hCD]; simp only [Matrix.mul_assoc] + have he' : rowC C * rowD D * rowA A * rowB B = + pairCD (forwardPair C D) * pairAB (forwardPair A B) := by + rw [←hAB,←hCD]; simp only [Matrix.mul_assoc] + rw [he,he',close4_pair_product,close4_pair_reverse] at hc + exact hc + +end +end CriticalHoneycomb.Transfer.ClosedFourRow + +end + +section +namespace CriticalHoneycomb.Transfer.ClosedFourRow +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +variable {α ι k : Type*} [Fintype α] [DecidableEq α] [Fintype ι] + [CommSemiring k] +noncomputable def pairSwap : Matrix (α×α) (α×α) k := + fun p q=> if p=(q.2,q.1) then 1 else 0 +lemma pairSwap_mulVec (v : α×α→k) (p : α×α) : + (pairSwap *ᵥ v) p=v (p.2,p.1) := by + classical + simp [pairSwap,Matrix.mulVec,dotProduct,Fintype.sum_prod_type,Prod.ext_iff,ite_and] +lemma pairSwap_sq : (pairSwap : Matrix (α×α) (α×α) k)*pairSwap=1 := by + classical + funext p q + simp [pairSwap,Matrix.mul_apply,Fintype.sum_prod_type,Prod.ext_iff,Matrix.one_apply,ite_and] +omit [Fintype α] in +lemma pairSwap_transpose : (pairSwap : Matrix (α×α) (α×α) k)ᵀ=pairSwap := by + classical + funext p q + simp [pairSwap,Matrix.transpose_apply,Prod.ext_iff,eq_comm,and_comm] +lemma pairSwap_mul (M : Matrix (α×α) (α×α) k) (p q : α×α) : + (pairSwap*M : Matrix (α×α) (α×α) k) p q=M (p.2,p.1) q := by + classical + simp [pairSwap,Matrix.mul_apply,Fintype.sum_prod_type,Prod.ext_iff,ite_mul,ite_and] +lemma mul_pairSwap (M : Matrix (α×α) (α×α) k) (p q : α×α) : + (M*pairSwap : Matrix (α×α) (α×α) k) p q=M p (q.2,q.1) := by + classical + simp [pairSwap,Matrix.mul_apply,Fintype.sum_prod_type,Prod.ext_iff,mul_ite,ite_and] +lemma pairSwap_conjugate (M : Matrix (α×α) (α×α) k) (p q : α×α) : + (pairSwap*M*pairSwap : Matrix (α×α) (α×α) k) p q=M (p.2,p.1) (q.2,q.1) := by + classical + simp [pairSwap,Matrix.mul_apply,Fintype.sum_prod_type,Prod.ext_iff,ite_mul,mul_ite,ite_and] +lemma swap_backward (X Y : Row α ι k) (s t : ι) : + pairSwap * backwardPair X Y s t * pairSwap = forwardPair Y X s t := by + funext p q + simp only [pairSwap_conjugate,backwardPair,forwardPair,Matrix.sum_apply, + Matrix.kronecker,Matrix.kroneckerMap,Matrix.of_apply,mul_comm] +lemma closed_pair_reflection (R F B : Matrix (α×α) (α×α) k) + (v w v' w' : α×α→k) + (hE : R*F=B*R) (hPT : Rᵀ*pairSwap=pairSwap*R) + (hv : R*ᵥv'=pairSwap*ᵥv) (hw : R*ᵥw=pairSwap*ᵥw') : + v ⬝ᵥ (F*ᵥw) = v' ⬝ᵥ ((pairSwap*B*pairSwap)*ᵥw') := by + have hv' : v=(pairSwap*R)*ᵥv' := by + rw [←Matrix.mulVec_mulVec,hv,Matrix.mulVec_mulVec,pairSwap_sq,Matrix.one_mulVec] + rw [hv'] + calc + _=v' ⬝ᵥ ((Rᵀ*pairSwap)*ᵥ(F*ᵥw)) := by + conv_rhs => rw [←pairSwap_transpose,←Matrix.transpose_mul] + conv_rhs => rw [Matrix.dotProduct_mulVec,Matrix.vecMul_transpose] + _=v' ⬝ᵥ ((pairSwap*R*F)*ᵥw) := by + rw [hPT,Matrix.mulVec_mulVec] + _=v' ⬝ᵥ ((pairSwap*B*R)*ᵥw) := by rw [Matrix.mul_assoc,hE,←Matrix.mul_assoc] + _=v' ⬝ᵥ ((pairSwap*B*pairSwap)*ᵥw') := by + rw [←Matrix.mulVec_mulVec,hw,Matrix.mulVec_mulVec] +omit [DecidableEq α] [Fintype ι] in +lemma closePair_dot (F : ι→ι→Matrix (α×α) (α×α) k) (v w : α×α→k) (s t : ι) : + closePair F v w s t=v ⬝ᵥ (F s t*ᵥw) := by + simp only [closePair,dotProduct,Matrix.mulVec,Finset.mul_sum,mul_assoc] +end CriticalHoneycomb.Transfer.ClosedFourRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ColumnExpansion.lean b/lean/OAI/Combinatorics/HoneycombChords/ColumnExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..057fc579212bb49f4183ca13fa41ffd6c78f4021 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ColumnExpansion.lean @@ -0,0 +1,501 @@ +import OAI.Combinatorics.HoneycombChords.ChordMass + +namespace OAI + +/-! Column expansion for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.ListBound +open Filter Topology + +noncomputable def marked {α : Type*} (w v : α→ℝ) : {n : ℕ}→Pad α n→ℝ + | 0,_=>0 + | _+1,(a,p)=>a.elim 0 v*weight w p+a.elim 1 w*marked w v p +lemma marked_nonnegative {α : Type*} {w v : α→ℝ} + (hw : ∀ a,0≤ w a) (hv : ∀ a,0≤ v a) {n : ℕ} (p : Pad α n) : 0≤ marked w v p := by + induction n with + | zero => exact le_refl _ + | succ n ih => + rcases p with ⟨a,p⟩ + apply add_nonneg + · exact mul_nonneg (by cases a <;> simp_all) (weight_nonnegative hw p) + · exact mul_nonneg (by cases a <;> simp_all) (ih p) +lemma weight_le_marked_encode {α : Type*} {w v : α→ℝ} + (hw : ∀ a,0≤ w a) (hv : ∀ a,0≤ v a) (n : ℕ) (as : List α) + (hl : as.length≤ n) (hb : ∃ a∈as,w a≤ v a) : + weight w (encode n as)≤ marked w v (encode n as) := by + induction n generalizing as with + | zero => + have he : as=[]:=List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero hl) + subst as + simp at hb + | succ n ih => + cases as with + | nil => simp at hb + | cons a as => + obtain ⟨b,hb,hbv⟩:=hb + rcases List.mem_cons.mp hb with hba|hb + · subst b + change w a*weight w (encode n as)≤ v a*weight w (encode n as)+w a*marked w v (encode n as) + exact (mul_le_mul_of_nonneg_right hbv (weight_nonnegative hw _)).trans + (le_add_of_nonneg_right (mul_nonneg (hw a) (marked_nonnegative hw hv _))) + · change w a*weight w (encode n as)≤ v a*weight w (encode n as)+w a*marked w v (encode n as) + exact (mul_le_mul_of_nonneg_left (ih as (Nat.le_of_succ_le_succ hl) ⟨b,hb,hbv⟩) (hw a)).trans + (le_add_of_nonneg_left (mul_nonneg (hv a) (weight_nonnegative hw _))) + +noncomputable def markTotal (U V : ℝ) : ℕ→ℝ + | 0=>0 + | n+1=>V*U^n+U*markTotal U V n +lemma sum_marked {α : Type*} [Fintype α] (w v : α→ℝ) (n : ℕ) : + (∑ p : Pad α n,marked w v p)=markTotal (1+∑ a,w a) (∑ a,v a) n := by + induction n with + | zero => change (∑ _ : PUnit,(0:ℝ))=0; simp + | succ n ih => + change (∑ p : Option α × Pad α n,(p.1.elim 0 v*weight w p.2+p.1.elim 1 w*marked w v p.2))=_ + rw [Fintype.sum_prod_type] + simp only [Finset.sum_add_distrib,←Finset.mul_sum] + rw [sum_weight,ih,←Finset.sum_mul,←Finset.sum_mul,Fintype.sum_option,Fintype.sum_option] + simp only [Option.elim_none,Option.elim_some,zero_add,markTotal] +lemma finite_marked_system_bound {α : Type*} [Fintype α] (w v : α→ℝ) + (hw : ∀ a,0≤ w a) (hv : ∀ a,0≤ v a) (S : Finset (List α)) (n : ℕ) + (hlen : ∀ as∈S,as.length≤ n) (hbad : ∀ as∈S,∃ a∈as,w a≤ v a) : + (∑ as∈S,(as.map w).prod)≤ markTotal (1+∑ a,w a) (∑ a,v a) n := by + classical + calc + _ ≤ ∑ as∈S,marked w v (encode n as) := by + apply Finset.sum_le_sum + intro as ha + rw [←weight_encode w n as (hlen as ha)] + exact weight_le_marked_encode hw hv n as (hlen as ha) (hbad as ha) + _ = ∑ p∈S.image (encode n),marked w v p := by + symm + apply Finset.sum_image + intro as has bs hbs he + have hh:=congrArg decode he + simpa only [decode_encode n as (hlen as has),decode_encode n bs (hlen bs hbs)] using hh + _ ≤ ∑ p : Pad α n,marked w v p := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro p hp hn + exact marked_nonnegative hw hv p + _ = _ := sum_marked w v n +lemma markTotal_limit {U V : ℕ→ℝ} {u : ℝ} + (hU : Tendsto U atTop (𝓝 u)) (hV : Tendsto V atTop (𝓝 0)) (n : ℕ) : + Tendsto (fun H=>markTotal (U H) (V H) n) atTop (𝓝 0) := by + induction n with + | zero => exact tendsto_const_nhds + | succ n ih => + simpa only [markTotal,zero_mul,mul_zero,add_zero] using (hV.mul (hU.pow n)).add (hU.mul ih) +end CriticalHoneycomb.Transfer.ListBound + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology +lemma SelectedSystem.node_of_incident {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) {v : Center} + (hv : v∈domain (W+1) (H+1)) {k : Fin 3} + (hs : assignmentSpins x (incidentWire v k)≠1) : v∈systemNodes cs := by + obtain ⟨c,hc,he⟩:=(h.edge_union _).mp hs + have hm : v∈Set.range c.path.center := by + by_contra hm + apply c.path.incident_off v _ _ hm k he + · rw [BoundaryChord.path,ofChord_first] + exact fun hh=>c.source.outside_not_mem (hh ▸ hv) + · rw [BoundaryChord.path,ofChord_last] + exact fun hh=>c.target.outside_not_mem (hh ▸ hv) + exact List.mem_flatMap.mpr ⟨c,hc,(c.nodes_mem v).mpr hm⟩ +lemma Matches.nonempty_selected {W H : ℕ} {cfg : Cell W H→Shape} + {x : Assignment W H} (hm : Matches cfg x.1 x.2) {t : Cell W H} + (hn : cfg t≠.empty) : ∃ b k,assignmentSpins x (incidentWire (cellCenter t b) k)≠1 := by + obtain ⟨hw,hn',hs,he,hm'⟩:=hm t + have west (hh : (cfg t).selection.west=true) : + assignmentSpins x (incidentWire (cellCenter t true) 2)≠1 := by + rw [assignmentSpins,(up_wires t).2.2,spins_wire] + simpa only [hh,spinOccupied,decide_eq_true_eq,Sum.elim_inl] using hw + have south (hh : (cfg t).selection.south=true) : + assignmentSpins x (incidentWire (cellCenter t true) 1)≠1 := by + rw [assignmentSpins,(up_wires t).2.1,spins_wire] + simpa only [hh,spinOccupied,decide_eq_true_eq,Sum.elim_inl] using hs + have north (hh : (cfg t).selection.north=true) : + assignmentSpins x (incidentWire (cellCenter t false) 1)≠1 := by + rw [assignmentSpins,(down_wires t).2.1,spins_wire] + simpa only [hh,spinOccupied,decide_eq_true_eq,Sum.elim_inl] using hn' + cases hq : cfg t with + | empty => exact (hn hq).elim + | westSouth => exact ⟨true,2,west (by rw [hq];rfl)⟩ + | northEast => exact ⟨false,1,north (by rw [hq];rfl)⟩ + | both => exact ⟨true,2,west (by rw [hq];rfl)⟩ + | westNorth => exact ⟨true,2,west (by rw [hq];rfl)⟩ + | southEast => exact ⟨true,1,south (by rw [hq];rfl)⟩ + | westEast => exact ⟨true,2,west (by rw [hq];rfl)⟩ + | northSouth => exact ⟨true,1,south (by rw [hq];rfl)⟩ +lemma SelectedSystem.nonempty_row {W H : ℕ} {x : Assignment (W+1) (H+1)} + {cs : List (BoundaryChord W H)} (h : SelectedSystem x cs) + {cfg : Cell (W+1) (H+1)→Shape} (hm : Matches cfg x.1 x.2) + {j : Fin (H+1)} (hn : ∃ i,cfg (i,j)≠.empty) : + ∃ c∈cs,∃ v∈c.chord.val,v.2.1=(j.val:ℤ) := by + obtain ⟨i,hi⟩:=hn + obtain ⟨b,k,hk⟩:=hm.nonempty_selected hi + obtain ⟨c,hc,hv⟩:=List.mem_flatMap.mp (h.node_of_incident (cellCenter_mem (i,j) b) hk) + exact ⟨c,hc,cellCenter (i,j) b,hv,rfl⟩ +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations +noncomputable def restrictedPartition {W H : ℕ} (x₀ : Assignment W H) + (Q : (Cell W H→Shape)→Prop) : ℂ := by + classical + exact ∑ cfg : Cell W H→Shape,if Q cfg then ∑ x,relativeTerm cfg x₀ x else 0 + +theorem actual_restricted_component_bound {W H : ℕ} (x₀ : Assignment (W+1) (H+1)) + (Q : (Cell (W+1) (H+1)→Shape)→Prop) : + ∃ S : Finset (List (BoundaryChord W H)), + (∀ cs∈S,∃ x cfg,SameBoundary x x₀ ∧ Matches cfg x.1 x.2 ∧ Q cfg ∧ SelectedSystem x cs) ∧ + ‖restrictedPartition x₀ Q‖ + ≤∑ cs∈S,kappa^(systemNodes cs).length := by + classical + let F := fun cfg : Cell (W+1) (H+1)→Shape=>∑ x,relativeTerm cfg x₀ x + let A := {cfg : Cell (W+1) (H+1)→Shape // Q cfg ∧ F cfg≠0} + have hd : ∀ a : A,∃ x cs,SameBoundary x x₀ ∧ Matches a.val x.1 x.2 ∧ + SelectedSystem x cs ∧ F a.val=systemAmplitude x cs := fun a=> + active_shape_decomposition x₀ a.val a.property.2 + choose x cs hb hm hs hc using hd + have hi : Function.Injective cs := by + intro a b he + apply Subtype.ext + exact SelectedSystem.shape_unique (hs a) (he ▸ hs b) (hm a) (hm b) + let S := Finset.univ.image cs + refine ⟨S,?_,?_⟩ + · intro z hz + obtain ⟨a,_,rfl⟩:=Finset.mem_image.mp hz + exact ⟨x a,a.val,hb a,hm a,a.property.1,hs a⟩ + · have hsum : (∑ cfg,if Q cfg then F cfg else 0)=∑ a : A,F a.val := by + rw [←sum_subtype_indicator (fun cfg=>Q cfg ∧ F cfg≠0) F] + apply Finset.sum_congr rfl + intro cfg hcfg + by_cases hh : F cfg=0 <;> by_cases hq : Q cfg <;> simp [hh,hq] + change ‖∑ cfg,if Q cfg then F cfg else 0‖≤_ + rw [hsum] + calc + _ ≤ ∑ a : A,‖F a.val‖ := norm_sum_le _ _ + _ = ∑ a : A,kappa^(systemNodes (cs a)).length := by + apply Finset.sum_congr rfl + intro a ha + rw [hc a,(hs a).amplitude_norm] + _ = _ := by + change (∑ a : A,kappa^(systemNodes (cs a)).length)= + ∑ z∈Finset.univ.image cs,kappa^(systemNodes z).length + symm + exact Finset.sum_image (f:=fun z : List (BoundaryChord W H)=>kappa^(systemNodes z).length) + (s:=(Finset.univ : Finset A)) hi.injOn +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology +noncomputable def badHardWeight {W H : ℕ} (c : BoundaryChord W H) : ℝ := by + classical + exact if hp : EndPort c.source ∧ EndPort c.target then + badPoolWeight (H/2) (HardChord.encode ⟨c,hp⟩) else 0 +lemma badHardWeight_nonnegative {W H : ℕ} (c : BoundaryChord W H) : 0≤badHardWeight c := by + unfold badHardWeight + split_ifs + · exact badPoolWeight_nonnegative _ + · exact le_refl _ +lemma sum_badHardWeight_le (W H : ℕ) : + (∑ c : BoundaryChord W H,badHardWeight c)≤badPoolMass W H (H/2) := by + classical + have he : (∑ c : BoundaryChord W H,badHardWeight c)= + ∑ c : HardChord W H,badPoolWeight (H/2) c.encode := by + have hs : ∀ c : HardChord W H,badHardWeight c.val=badPoolWeight (H/2) c.encode := by + rintro ⟨c,hp⟩ + simp only [badHardWeight,dite_eq_left hp] + calc + _ = ∑ c : BoundaryChord W H,if EndPort c.source ∧ EndPort c.target then badHardWeight c else 0 := by + apply Finset.sum_congr rfl + intro c hc + by_cases hp : EndPort c.source ∧ EndPort c.target <;> simp [badHardWeight,hp] + _ = ∑ c : HardChord W H,badHardWeight c.val := + by + rw [←Finset.sum_filter] + exact Finset.sum_subtype _ (by simp) _ + _ = _ := Finset.sum_congr rfl (fun c hc=>hs c) + rw [he] + calc + _ = ∑ a∈Finset.univ.image (HardChord.encode (W:=W) (H:=H)),badPoolWeight (H/2) a := + (Finset.sum_image (HardChord.encode_injective W H).injOn).symm + _ ≤ _ := (badPool_summable W H (H/2)).sum_le_tsum _ (fun a ha=>badPoolWeight_nonnegative a) +lemma hardWeight_le_bad {W H : ℕ} (c : BoundaryChord W H) + (hp : EndPort c.source ∧ EndPort c.target) + (hm : ∃ v∈c.chord.val,v.2.1=(H/2:ℕ)) : hardWeight c≤badHardWeight c := by + classical + let a : HardChord W H:=⟨c,hp⟩ + have hh:=a.midrow_weight hm + unfold hardWeight badHardWeight + rw [ite_eq_left hp,dite_eq_left hp] + change kappa^c.chord.val.length≤badPoolWeight (H/2) a.encode + rw [hh,poolWeight,a.encode_length] + +lemma markTotal_nonnegative {U V : ℝ} (hU : 0≤U) (hV : 0≤V) (n : ℕ) : + 0≤ListBound.markTotal U V n := by + induction n with + | zero => exact le_refl _ + | succ n ih => exact add_nonneg (mul_nonneg hV (pow_nonneg hU _)) (mul_nonneg hU ih) +lemma markTotal_mono {U U' V V' : ℝ} (hnU : 0≤U) (hnV : 0≤V) + (hU : U≤U') (hV : V≤V') (n : ℕ) : + ListBound.markTotal U V n≤ListBound.markTotal U' V' n := by + induction n with + | zero => exact le_refl _ + | succ n ih => + exact add_le_add (mul_le_mul hV (pow_le_pow_left₀ hnU hU n) (pow_nonneg hnU _) (hnV.trans hV)) + (mul_le_mul hU ih (markTotal_nonnegative hnU hnV n) (hnU.trans hU)) + +noncomputable def middleErrorBound (W H : ℕ) : ℝ := + ListBound.markTotal (1+poolMass W H) (badPoolMass W H (H/2)) (2*(W+1)) +lemma middleErrorBound_limit (W : ℕ) : Tendsto (middleErrorBound W) atTop (𝓝 0) := + ListBound.markTotal_limit (tendsto_const_nhds.add (poolMass_limit W)) (badPoolMass_limit W) _ + +theorem actual_middle_row_bound {W H : ℕ} (x₀ : Assignment (W+1) (H+1)) + (hw : ∀ j,assignmentSpins x₀ (westPort W H j).wire=1) + (he : ∀ j,assignmentSpins x₀ (eastPort W H j).wire=1) : + ‖restrictedPartition x₀ (fun cfg=>∃ i,cfg (i,⟨H/2,by omega⟩)≠.empty)‖≤ middleErrorBound W H := by + classical + let Q := fun cfg : Cell (W+1) (H+1)→Shape=>∃ i,cfg (i,⟨H/2,by omega⟩)≠.empty + obtain ⟨S,hS,hB⟩:=actual_restricted_component_bound x₀ Q + have walls : ∀ cs∈S,∃ x cfg,SelectedSystem x cs ∧ Matches cfg x.1 x.2 ∧ Q cfg ∧ + (∀ j,assignmentSpins x (westPort W H j).wire=1) ∧ + (∀ j,assignmentSpins x (eastPort W H j).wire=1) := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hs⟩:=hS cs hc + exact ⟨x,cfg,hs,hm,hq,fun j=>(sameBoundary_port hx _).trans (hw j), + fun j=>(sameBoundary_port hx _).trans (he j)⟩ + have hn : ∀ cs∈S,cs.length≤2*(W+1) := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hw,he⟩:=walls cs hc + exact hx.length_le_width hw he + have hp : ∀ cs∈S,kappa^(systemNodes cs).length=(cs.map hardWeight).prod := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hw,he⟩:=walls cs hc + exact system_hardWeight (fun c hc=>hx.hard_endpoints hw he hc) + have hb : ∀ cs∈S,∃ c∈cs,hardWeight c≤badHardWeight c := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hw,he⟩:=walls cs hc + obtain ⟨c,hc,hv⟩:=hx.nonempty_row hm hq + exact ⟨c,hc,hardWeight_le_bad c (hx.hard_endpoints hw he hc) hv⟩ + calc + _ ≤ ∑ cs∈S,kappa^(systemNodes cs).length := hB + _ = ∑ cs∈S,(cs.map hardWeight).prod := Finset.sum_congr rfl (fun cs hc=>hp cs hc) + _ ≤ ListBound.markTotal (1+∑ c : BoundaryChord W H,hardWeight c) + (∑ c : BoundaryChord W H,badHardWeight c) (2*(W+1)) := + ListBound.finite_marked_system_bound hardWeight badHardWeight hardWeight_nonnegative badHardWeight_nonnegative S _ hn hb + _ ≤ _ := by + apply markTotal_mono + · have hh := Finset.sum_nonneg (fun c (_ : c∈(Finset.univ : Finset (BoundaryChord W H)))=>hardWeight_nonnegative c) + linarith + · exact Finset.sum_nonneg (fun c hc=>badHardWeight_nonnegative c) + · rw [sum_hardWeight] + exact add_le_add (le_refl 1) (singleSystemMass_le W H) + · exact sum_badHardWeight_le W H +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open scoped Matrix +lemma sourceR_PT (a h v c d : ℂ) (w n s e : Fin 3) : + Planar.sourceR a h v c d (n,w) (s,e)=Planar.sourceR a h v c d (e,s) (w,n) := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> rfl + +def transposeWire (W H : ℕ) : GridWire W H ≃ GridWire H W where + toFun := Sum.elim (fun p=>.inr (p.2,p.1)) (fun p=>.inl (p.2,p.1)) + invFun := Sum.elim (fun p=>.inr (p.2,p.1)) (fun p=>.inl (p.2,p.1)) + left_inv := by rintro (⟨i,j⟩|⟨i,j⟩) <;> rfl + right_inv := by rintro (⟨i,j⟩|⟨i,j⟩) <;> rfl +def transposeSpins {W H : ℕ} (σ : GridWire W H→Fin 3) : GridWire H W→Fin 3 := + σ ∘ (transposeWire W H).symm +lemma physical_transpose {W H : ℕ} (σ : GridWire W H→Fin 3) : + (network W H).physical σ=(network H W).physical (transposeSpins σ) := by + unfold TileNetwork.physical + rw [Fintype.prod_prod_type] + rw [Fintype.prod_prod_type,Finset.prod_comm] + apply Finset.prod_congr rfl + intro i hi + apply Finset.prod_congr rfl + intro j hj + exact sourceR_PT _ _ _ _ _ _ _ _ _ +noncomputable def allGridPartition (W H : ℕ) (west east : Column H) + (south north : Column W) : ℂ := by + classical + exact ∑ σ : GridWire W H→Fin 3,if + (∀ j,σ (.inl (0,j))=west j) ∧ (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ + (∀ i,σ (.inr (i,0))=south i) ∧ (∀ i,σ (.inr (i,Fin.last H))=north i) + then (network W H).physical σ else 0 +lemma prescribed_eq_allGrid (W H : ℕ) (west east : Column H) (south north : Column W) : + prescribedPartition W H west east south north=allGridPartition W H west east south north := by + classical + rw [prescribedPartition_eq_grid_sum] + unfold allGridPartition + trans ∑ σ : GridWire W H→Fin 3,if HasWestNorth west north σ then + (if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i) + then (network W H).physical σ else 0) else 0 + · convert (sum_subtype_indicator (HasWestNorth west north) (fun σ=> + if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i) + then (network W H).physical σ else 0)).symm using 1 + congr 1 + ext x + simp + apply Finset.sum_congr rfl + intro σ hσ + simp only [HasWestNorth,ite_and] + split_ifs <;> simp_all +lemma allGrid_transpose (W H : ℕ) (west east : Column H) (south north : Column W) : + allGridPartition W H west east south north=allGridPartition H W south north west east := by + classical + unfold allGridPartition + let e := Equiv.arrowCongr (transposeWire W H) (Equiv.refl (Fin 3)) + rw [←e.sum_comp] + apply Finset.sum_congr rfl + intro σ hσ + have he : e σ=transposeSpins σ := rfl + rw [he] + have hb : ((∀ j,σ (.inl (0,j))=west j) ∧ (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ + (∀ i,σ (.inr (i,0))=south i) ∧ (∀ i,σ (.inr (i,Fin.last H))=north i)) ↔ + ((∀ j,transposeSpins σ (.inl (0,j))=south j) ∧ + (∀ j,transposeSpins σ (.inl (Fin.last H,j))=north j) ∧ + (∀ i,transposeSpins σ (.inr (i,0))=west i) ∧ + (∀ i,transposeSpins σ (.inr (i,Fin.last W))=east i)) := by + dsimp [transposeSpins,transposeWire] + tauto + simp only [←hb,physical_transpose σ] +lemma prescribed_transpose (W H : ℕ) (west east : Column H) (south north : Column W) : + prescribedPartition W H west east south north=prescribedPartition H W south north west east := by + rw [prescribed_eq_allGrid,allGrid_transpose,←prescribed_eq_allGrid] +noncomputable def rowTransfer (W : ℕ) : Matrix (Column W) (Column W) ℂ := columnKernel W 1 1 +lemma prescribed_hard_transfer (W H : ℕ) (south north : Column W) : + prescribedPartition W H (fun _=>1) (fun _=>1) south north=(rowTransfer W^H) south north := by + rw [prescribed_transpose,prescribedPartition_eq_transfer] + simp only [rowTransfer,List.ofFn_const,List.prod_replicate] +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open scoped Matrix + +def transposeShape : Shape→Shape + | .westNorth=>.southEast + | .southEast=>.westNorth + | .westEast=>.northSouth + | .northSouth=>.westEast + | q=>q +lemma transposeShape_involutive : Function.Involutive transposeShape := by intro q;cases q<;>rfl +lemma transposeShape_visits (q : Shape) : (transposeShape q).visits=q.visits := by cases q<;>rfl +lemma transposeShape_empty (q : Shape) : transposeShape q=.empty ↔ q=.empty := by cases q<;>simp [transposeShape] +lemma occupied_symm (x y : Fin 3) : Planar.occupied x y=Planar.occupied y x := by + have h : (x=y ∧ x≠1) ↔ (y=x ∧ y≠1) := by + constructor <;> rintro ⟨rfl,h⟩ <;> exact ⟨rfl,h⟩ + simp only [Planar.occupied,h] +lemma vacant_symm (x y : Fin 3) : Planar.vacant x y=Planar.vacant y x := by + simp [Planar.vacant,and_comm] +lemma shapeTensor_PT (q : Shape) (w n s e : Fin 3) : + shapeTensor q w n s e=shapeTensor (transposeShape q) s e w n := by + cases q + all_goals simp only [shapeTensor,transposeShape] + case empty => rw [vacant_symm w s,vacant_symm n e] + case westSouth => rw [occupied_symm w s,vacant_symm n e] + case northEast => rw [vacant_symm w s,occupied_symm n e] + case both => rw [occupied_symm w s,occupied_symm n e] + case westNorth => ring + case southEast => ring + case westEast => rw [occupied_symm w e]; ring + case northSouth => rw [occupied_symm n s]; ring + +def transposeConfiguration {W H : ℕ} (cfg : Cell W H→Shape) : Cell H W→Shape := + fun t=>transposeShape (cfg (t.2,t.1)) +lemma orientation_transpose {W H : ℕ} (cfg : Cell W H→Shape) (σ : GridWire W H→Fin 3) : + (network W H).orientation cfg σ= + (network H W).orientation (transposeConfiguration cfg) (transposeSpins σ) := by + unfold TileNetwork.orientation + rw [Fintype.prod_prod_type,Fintype.prod_prod_type,Finset.prod_comm] + apply Finset.prod_congr rfl + intro i hi + apply Finset.prod_congr rfl + intro j hj + exact shapeTensor_PT _ _ _ _ _ + +noncomputable def allChosenGrid {W H : ℕ} (cfg : Cell W H→Shape) (west east : Column H) + (south north : Column W) : ℂ := by + classical + exact ∑ σ : GridWire W H→Fin 3,if + (∀ j,σ (.inl (0,j))=west j) ∧ (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ + (∀ i,σ (.inr (i,0))=south i) ∧ (∀ i,σ (.inr (i,Fin.last H))=north i) + then (network W H).orientation cfg σ else 0 +lemma chosen_eq_allGrid {W H : ℕ} (cfg : Cell W H→Shape) (west east : Column H) (south north : Column W) : + chosenPartition cfg west east south north=allChosenGrid cfg west east south north := by + classical + rw [chosenPartition_eq_grid_sum] + unfold allChosenGrid + trans ∑ σ : GridWire W H→Fin 3,if HasWestNorth west north σ then + (if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i) + then (network W H).orientation cfg σ else 0) else 0 + · convert (sum_subtype_indicator (HasWestNorth west north) (fun σ=> + if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i) + then (network W H).orientation cfg σ else 0)).symm using 1 + congr 1 + ext x + simp + apply Finset.sum_congr rfl + intro σ hσ + simp only [HasWestNorth,ite_and] + split_ifs <;> simp_all +lemma chosen_transpose {W H : ℕ} (cfg : Cell W H→Shape) (west east : Column H) (south north : Column W) : + chosenPartition cfg west east south north= + chosenPartition (transposeConfiguration cfg) south north west east := by + classical + rw [chosen_eq_allGrid,chosen_eq_allGrid] + unfold allChosenGrid + let e := Equiv.arrowCongr (transposeWire W H) (Equiv.refl (Fin 3)) + rw [←e.sum_comp] + apply Finset.sum_congr rfl + intro σ hσ + have he : e σ=transposeSpins σ := rfl + rw [he] + have hb : ((∀ j,σ (.inl (0,j))=west j) ∧ (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ + (∀ i,σ (.inr (i,0))=south i) ∧ (∀ i,σ (.inr (i,Fin.last H))=north i)) ↔ + ((∀ j,transposeSpins σ (.inl (0,j))=south j) ∧ + (∀ j,transposeSpins σ (.inl (Fin.last H,j))=north j) ∧ + (∀ i,transposeSpins σ (.inr (i,0))=west i) ∧ + (∀ i,transposeSpins σ (.inr (i,Fin.last W))=east i)) := by + dsimp [transposeSpins,transposeWire] + tauto + simp only [←hb,orientation_transpose cfg σ] +lemma sum_visits_transpose {W H : ℕ} (cfg : Cell W H→Shape) : + (∑ t,(transposeConfiguration cfg t).visits)=∑ t,(cfg t).visits := by + simp only [transposeConfiguration,transposeShape_visits] + rw [Fintype.sum_prod_type,Fintype.sum_prod_type,Finset.sum_comm] +lemma weighted_chosen_transpose {W H : ℕ} (cfg : Cell W H→Shape) + (west east : Column H) (south north : Column W) : + (kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg west east south north= + (kappa:ℂ)^(∑ t,(transposeConfiguration cfg t).visits)* + chosenPartition (transposeConfiguration cfg) south north west east := by + rw [sum_visits_transpose,chosen_transpose] +end CriticalHoneycomb.Transfer.RasterGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ColumnPositivity.lean b/lean/OAI/Combinatorics/HoneycombChords/ColumnPositivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f89125d2c0aed178da8dca1b512eea076ced214 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ColumnPositivity.lean @@ -0,0 +1,210 @@ +import OAI.Combinatorics.HoneycombChords.ColumnProjection + +namespace OAI + +/-! Column positivity for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology +open scoped Matrix +lemma row_vacuum (W H : ℕ) : (rowTransfer W^H) (fun _=>1) (fun _=>1)=1 := + physical_vacuum_entry W H +lemma actual_any_cut_bound {W H k j : ℕ} (hk : k≤j) (hj : j+k≤H) + (south north : Column (W+1)) : + ‖(rowTransfer (W+1)^(H+1)) south north- + (rowTransfer (W+1)^j) south (fun _=>1)* + (rowTransfer (W+1)^(H-j)) (fun _=>1) north‖ ≤ AnyRow.rowErrorBound W H k := by + rw [transfer_cut_difference south north (⟨j,by omega⟩ : Fin (H+1))] + obtain ⟨hw,he⟩:=hardAssignment_walls (H:=H) south north + exact AnyRow.actual_cutrow_bound hk hj _ hw he +lemma vacuum_column_cauchy (W : ℕ) (s : Column (W+1)) : + CauchySeq (fun H=>(rowTransfer (W+1)^(H+1)) s (fun _=>1)) := by + apply AnyRow.cauchy_of_cut_approximation _ (fun k=>(rowTransfer (W+1)^k) s (fun _=>1)) + (fun k H=>AnyRow.rowErrorBound W H k) (AnyRow.rowLimitError W) + (AnyRow.rowErrorBound_limit W) (AnyRow.rowLimitError_limit W) + intro k + filter_upwards [eventually_ge_atTop (2*k)] with H hH + have hh:=actual_any_cut_bound (W:=W) (H:=H) (j:=k) (k:=k) le_rfl (by omega) s (fun _=>1) + simpa only [row_vacuum,mul_one] using hh +lemma vacuum_row_cauchy (W : ℕ) (s : Column (W+1)) : + CauchySeq (fun H=>(rowTransfer (W+1)^(H+1)) (fun _=>1) s) := by + apply AnyRow.cauchy_of_cut_approximation _ (fun k=>(rowTransfer (W+1)^k) (fun _=>1) s) + (fun k H=>AnyRow.rowErrorBound W H k) (AnyRow.rowLimitError W) + (AnyRow.rowErrorBound_limit W) (AnyRow.rowLimitError_limit W) + intro k + filter_upwards [eventually_ge_atTop (2*k)] with H hH + have hh:=actual_any_cut_bound (W:=W) (H:=H) (j:=H-k) (k:=k) (by omega) (by omega) (fun _=>1) s + have he : H-(H-k)=k := by omega + simpa only [row_vacuum,one_mul,he] using hh +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles Filter Topology +open scoped Matrix +lemma exists_vacuum_column_limit (W : ℕ) (s : Column (W+1)) : + ∃ a : ℂ,Tendsto (fun H=>(rowTransfer (W+1)^H) s (fun _=>1)) atTop (𝓝 a) := by + obtain ⟨a,ha⟩:=cauchySeq_tendsto_of_complete (vacuum_column_cauchy W s) + exact ⟨a,(tendsto_add_atTop_iff_nat 1).mp ha⟩ +lemma exists_vacuum_row_limit (W : ℕ) (s : Column (W+1)) : + ∃ a : ℂ,Tendsto (fun H=>(rowTransfer (W+1)^H) (fun _=>1) s) atTop (𝓝 a) := by + obtain ⟨a,ha⟩:=cauchySeq_tendsto_of_complete (vacuum_row_cauchy W s) + exact ⟨a,(tendsto_add_atTop_iff_nat 1).mp ha⟩ +noncomputable def archColumn (W : ℕ) (s : Column (W+1)) : ℂ := + (exists_vacuum_column_limit W s).choose +noncomputable def archRow (W : ℕ) (s : Column (W+1)) : ℂ := + (exists_vacuum_row_limit W s).choose +lemma archColumn_limit (W : ℕ) (s : Column (W+1)) : + Tendsto (fun H=>(rowTransfer (W+1)^H) s (fun _=>1)) atTop (𝓝 (archColumn W s)) := + (exists_vacuum_column_limit W s).choose_spec +lemma archRow_limit (W : ℕ) (s : Column (W+1)) : + Tendsto (fun H=>(rowTransfer (W+1)^H) (fun _=>1) s) atTop (𝓝 (archRow W s)) := + (exists_vacuum_row_limit W s).choose_spec +lemma archColumn_vacuum (W : ℕ) : archColumn W (fun _=>1)=1 := by + apply tendsto_nhds_unique (archColumn_limit W _) + simpa only [row_vacuum] using (tendsto_const_nhds : Tendsto (fun _ : ℕ=>(1:ℂ)) atTop (𝓝 1)) +lemma archRow_vacuum (W : ℕ) : archRow W (fun _=>1)=1 := by + apply tendsto_nhds_unique (archRow_limit W _) + simpa only [row_vacuum] using (tendsto_const_nhds : Tendsto (fun _ : ℕ=>(1:ℂ)) atTop (𝓝 1)) + +theorem physical_rank_one_limit (W : ℕ) (s n : Column (W+1)) : + Tendsto (fun H=>(rowTransfer (W+1)^H) s n) atTop + (𝓝 (archColumn W s*archRow W n)) := by + have ht : Tendsto (fun H : ℕ=>H/2) atTop atTop := by + exact le_of_eq (map_div_atTop_eq_nat 2 (by omega)) + have hu : Tendsto (fun H : ℕ=>H-H/2) atTop atTop := by + apply tendsto_atTop_mono _ ht + intro H + omega + have hp:=((archColumn_limit W s).comp ht).mul ((archRow_limit W n).comp hu) + have he : Tendsto (fun H=>(rowTransfer (W+1)^(H+1)) s n- + (rowTransfer (W+1)^(H/2)) s (fun _=>1)* + (rowTransfer (W+1)^(H-H/2)) (fun _=>1) n) atTop (𝓝 0) := by + apply tendsto_zero_iff_norm_tendsto_zero.mpr + exact squeeze_zero (fun H=>norm_nonneg _) (fun H=>actual_transfer_cut_bound W H s n) + (middleErrorBound_limit W) + apply (tendsto_add_atTop_iff_nat 1).mp + convert he.add hp using 1 <;> simp +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open Filter Topology PhysicalTiles +open scoped Matrix +noncomputable def archProjection (W : ℕ) : Matrix (Column (W+1)) (Column (W+1)) ℂ := + fun s n=>archColumn W s*archRow W n +lemma physical_matrix_limit (W : ℕ) : + Tendsto (fun H=>rowTransfer (W+1)^H) atTop (𝓝 (archProjection W)) := by + apply tendsto_pi_nhds.mpr + intro s + apply tendsto_pi_nhds.mpr + intro n + exact physical_rank_one_limit W s n +lemma projection_vacuum (W : ℕ) : archProjection W (fun _=>1) (fun _=>1)=1 := by + simp [archProjection,archColumn_vacuum,archRow_vacuum] +lemma projection_mul_transfer (W : ℕ) : archProjection W*rowTransfer (W+1)=archProjection W := by + have h1:=(physical_matrix_limit W).mul (tendsto_const_nhds (x:=rowTransfer (W+1))) + have h2:=(physical_matrix_limit W).comp (tendsto_add_atTop_nat 1) + simp only [Function.comp_def,pow_succ] at h2 + exact tendsto_nhds_unique h1 h2 +lemma transfer_mul_projection (W : ℕ) : rowTransfer (W+1)*archProjection W=archProjection W := by + have h1:=(tendsto_const_nhds (x:=rowTransfer (W+1))).mul (physical_matrix_limit W) + have h2:=(physical_matrix_limit W).comp (tendsto_add_atTop_nat 1) + simp only [Function.comp_def,pow_succ'] at h2 + exact tendsto_nhds_unique h1 h2 +lemma projection_idempotent (W : ℕ) : archProjection W*archProjection W=archProjection W := by + have ht : Tendsto (fun H : ℕ=>H+H) atTop atTop := + tendsto_atTop_mono (fun H=>Nat.le_add_right H H) tendsto_id + have h1:=(physical_matrix_limit W).mul (physical_matrix_limit W) + have h2:=(physical_matrix_limit W).comp ht + simp only [Function.comp_def,pow_add] at h2 + exact tendsto_nhds_unique h1 h2 +lemma arch_pairing (W : ℕ) : (∑ s,archRow W s*archColumn W s)=1 := by + have h:=congrFun (congrFun (projection_idempotent W) (fun _=>1)) (fun _=>1) + simpa [Matrix.mul_apply,archProjection,archColumn_vacuum,archRow_vacuum] using h +lemma projection_mulVec (W : ℕ) (v : Column (W+1)→ℂ) : + (archProjection W).mulVec v=(∑ s,archRow W s*v s) • archColumn W := by + funext s + simp only [Matrix.mulVec,dotProduct,archProjection,Pi.smul_apply,smul_eq_mul] + simp_rw [mul_assoc] + rw [←Finset.mul_sum,mul_comm] +lemma archColumn_eigen (W : ℕ) : + (rowTransfer (W+1)).mulVec (archColumn W)=archColumn W := by + have h:=transfer_mul_projection W + funext s + have hs:=congrFun (congrFun h s) (fun _=>1) + simpa [Matrix.mul_apply,Matrix.mulVec,dotProduct,archProjection,archRow_vacuum] using hs +lemma archColumn_ne_zero (W : ℕ) : archColumn W≠0 := by + intro h + have hh:=archColumn_vacuum W + rw [h] at hh + simp at hh +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open Filter Topology PhysicalTiles +open scoped Matrix +lemma physical_vector_limit (W : ℕ) (v : Column (W+1)→ℂ) : + Tendsto (fun H=>(rowTransfer (W+1)^H).mulVec v) atTop + (𝓝 ((archProjection W).mulVec v)) := by + apply tendsto_pi_nhds.mpr + intro s + exact tendsto_finsetSum _ (fun n hn=>(physical_rank_one_limit W s n).mul_const (v n)) +lemma physical_iterate_eigen {W : ℕ} (v : Column (W+1)→ℂ) (z : ℂ) + (hv : (rowTransfer (W+1)).mulVec v=z • v) (H : ℕ) : + (rowTransfer (W+1)^H).mulVec v=(z^H) • v := by + induction H with + | zero => simp + | succ H ih => + rw [pow_succ',←Matrix.mulVec_mulVec,ih,Matrix.mulVec_smul,hv,smul_smul,pow_succ] + +theorem physical_fixed_line (W : ℕ) (v : Column (W+1)→ℂ) + (hv : (rowTransfer (W+1)).mulVec v=v) : + v=(∑ s,archRow W s*v s) • archColumn W := by + have hi : ∀ H,(rowTransfer (W+1)^H).mulVec v=v := by + intro H + simpa using physical_iterate_eigen v 1 (by simpa using hv) H + have hlim:=physical_vector_limit W v + simp_rw [hi] at hlim + have he:=tendsto_nhds_unique tendsto_const_nhds hlim + exact he.trans (projection_mulVec W v) +lemma projection_eigen_zero {W : ℕ} (v : Column (W+1)→ℂ) (z : ℂ) (hz : z≠1) + (hv : (rowTransfer (W+1)).mulVec v=z • v) : (archProjection W).mulVec v=0 := by + have hx : z • ((archProjection W).mulVec v)=(archProjection W).mulVec v := by + rw [←Matrix.mulVec_smul,←hv,Matrix.mulVec_mulVec,projection_mul_transfer] + funext s + have hs:=congrFun hx s + simp only [Pi.smul_apply,smul_eq_mul] at hs + have hh : (z-1)*((archProjection W).mulVec v s)=0 := by linear_combination hs + exact (mul_eq_zero.mp hh).resolve_left (sub_ne_zero.mpr hz) + +theorem physical_other_eigenvalue_small {W : ℕ} (v : Column (W+1)→ℂ) (z : ℂ) + (hv0 : v≠0) (hz : z≠1) (hv : (rowTransfer (W+1)).mulVec v=z • v) : ‖z‖<1 := by + obtain ⟨s,hs⟩ : ∃ s,v s≠0 := by + by_contra hn + push Not at hn + exact hv0 (funext hn) + have hl:=(tendsto_pi_nhds.mp (physical_vector_limit W v)) s + rw [projection_eigen_zero v z hz hv] at hl + simp only [Pi.zero_apply] at hl + have he : ∀ H,(rowTransfer (W+1)^H).mulVec v s=z^H*v s := by + intro H + simpa only [Pi.smul_apply,smul_eq_mul] using congrFun (physical_iterate_eigen v z hv H) s + simp_rw [he] at hl + have hh:=hl.div_const (v s) + simp only [mul_div_cancel_right₀ _ hs,zero_div] at hh + exact tendsto_pow_atTop_nhds_zero_iff_norm_lt_one.mp hh +end CriticalHoneycomb.Transfer.RasterGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ColumnProjection.lean b/lean/OAI/Combinatorics/HoneycombChords/ColumnProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..022bd4eb58d67d0ab22105bd937b310a21518d0f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ColumnProjection.lean @@ -0,0 +1,452 @@ +import OAI.Combinatorics.HoneycombChords.ColumnExpansion + +namespace OAI + +/-! Column projection for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open scoped Matrix +lemma matrixPath_sum {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β] + {n : ℕ} (K : Fin n→β→Matrix α α ℂ) (a b : α) : + matrixPath (fun i=>∑ q,K i q) a b=∑ qs : Fin n→β,matrixPath (fun i=>K i (qs i)) a b := by + classical + unfold matrixPath + simp only [Matrix.sum_apply] + simp_rw [Fintype.prod_sum,Finset.ite_sum_zero] + rw [Finset.sum_comm] +lemma matrixPath_scale {α : Type*} [Fintype α] [DecidableEq α] {n : ℕ} + (K : Fin n→Matrix α α ℂ) (c : Fin n→ℂ) (a b : α) : + matrixPath (fun i=>c i • K i) a b=(∏ i,c i)*matrixPath K a b := by + classical + unfold matrixPath + simp only [Matrix.smul_apply,smul_eq_mul,Finset.prod_mul_distrib] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro τ hτ + split_ifs <;> simp +lemma matrixPath_restrict {α : Type*} [Fintype α] [DecidableEq α] {n : ℕ} + (K : Fin n→Matrix α α ℂ) (P : Fin n→Prop) [DecidablePred P] (a b : α) : + matrixPath (fun i=>if P i then K i else 0) a b=if ∀ i,P i then matrixPath K a b else 0 := by + classical + by_cases hp : ∀ i,P i + · simp [hp] + obtain ⟨i,hi⟩:=not_forall.mp hp + simp only [ite_eq_right hp,matrixPath] + apply Finset.sum_eq_zero + intro τ hτ + split_ifs + · apply Finset.prod_eq_zero (Finset.mem_univ i) + simp [hi] + · rfl +noncomputable def weightedColumn {H : ℕ} (q : Fin H→Shape) : Matrix (Column H) (Column H) ℂ := + (kappa:ℂ)^(∑ j,(q j).visits) • chosenColumnKernel q 1 1 +lemma weighted_chosen_matrixPath {W H : ℕ} (cfg : Cell W H→Shape) (west east : Column H) : + (kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg west east (fun _=>1) (fun _=>1)= + matrixPath (fun i=>weightedColumn (fun j=>cfg (i,j))) west east := by + rw [chosenPartition_eq_matrixPath] + unfold weightedColumn + rw [matrixPath_scale,Finset.prod_pow_eq_pow_sum,Fintype.sum_prod_type] + +lemma chosen_column_sum (H : ℕ) : + (∑ q : Fin H→Shape,weightedColumn q)=columnKernel H 1 1 := by + classical + ext west east + simp only [Matrix.sum_apply,weightedColumn,Matrix.smul_apply,smul_eq_mul,chosenColumnKernel] + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + unfold columnKernel + apply Finset.sum_congr rfl + intro vertical hvertical + by_cases hh : (Fin.snoc (α:=fun _=>Fin 3) vertical 1) 0=1 + · simp only [hh,ite_true] + unfold columnProduct chosenColumnProduct + simp_rw [physical_tile_expansion] + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro q hq + rw [Finset.prod_mul_distrib,←Finset.prod_pow_eq_pow_sum] + · simp [hh] + +lemma shape_columns_sum {W H : ℕ} (Q : Fin W→(Fin H→Shape)→Prop) [∀ i,DecidablePred (Q i)] + (west east : Column H) : + (∑ cfg : Cell W H→Shape,if ∀ i,Q i (fun j=>cfg (i,j)) then + (kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg west east (fun _=>1) (fun _=>1) else 0)= + matrixPath (fun i=>∑ q : Fin H→Shape,if Q i q then weightedColumn q else 0) west east := by + classical + rw [matrixPath_sum] + let e : (Cell W H→Shape) ≃ (Fin W→Fin H→Shape) := Equiv.curry _ _ _ + rw [←e.sum_comp] + apply Finset.sum_congr rfl + intro cfg hcfg + have he (i : Fin W) : e cfg i=fun j=>cfg (i,j) := rfl + simp only [he] + rw [matrixPath_restrict,←weighted_chosen_matrixPath] +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open scoped Matrix +lemma empty_chosenColumn (H : ℕ) (west east : Column H) : + chosenColumnKernel (fun _ : Fin H=>Shape.empty) 1 1 west east= + if west=(fun _=>1) ∧ east=(fun _=>1) then 1 else 0 := by + classical + have hs : Fin.snoc (α:=fun _=>Fin 3) (fun _ : Fin H=>1) 1 = (fun _ : Fin (H+1)=>1) := by + funext j + simp [Fin.snoc] + unfold chosenColumnKernel + rw [Finset.sum_eq_single (fun _=>1)] + · simp only [hs,ite_true] + unfold chosenColumnProduct + have hh (j : Fin H) : shapeTensor Shape.empty (west j) 1 1 (east j)= + if west j=1 ∧ east j=1 then 1 else 0 := by + simp only [shapeTensor,Planar.vacant,ite_and,mul_ite,mul_one,mul_zero]; split_ifs <;> rfl + simp only [hs,hh] + rw [Fintype.prod_ite_zero] + have ht : (∀ j,west j=1 ∧ east j=1) ↔ west=(fun _=>1) ∧ east=(fun _=>1) := by + constructor + · intro h;exact ⟨funext (fun j=>(h j).1),funext (fun j=>(h j).2)⟩ + · rintro ⟨rfl,rfl⟩;simp + simp [ht] + · intro vertical hv hne + split_ifs + · unfold chosenColumnProduct + have hn : ∃ j,vertical j≠1 := by + by_contra h + push Not at h + exact hne (funext h) + obtain ⟨j,hj⟩:=hn + apply Finset.prod_eq_zero (Finset.mem_univ j) + simp [shapeTensor,Planar.vacant,hj] + · rfl + · simp +lemma weighted_emptyColumn (H : ℕ) : + weightedColumn (fun _ : Fin H=>Shape.empty)= + fun west east=>if west=(fun _=>1) ∧ east=(fun _=>1) then 1 else 0 := by + classical + ext west east + simp [weightedColumn,Shape.visits,empty_chosenColumn] + +lemma constant_cut_product {α : Type*} [Monoid α] (A E : α) {n : ℕ} (k : Fin (n+1)) : + (List.ofFn (fun i : Fin (n+1)=>if i=k then E else A)).prod=A^k.val*E*A^(n-k.val) := by + classical + induction n with + | zero => simp [Fin.eq_zero k] + | succ n ih => + refine Fin.cases ?_ (fun k=>?_) k + · rw [List.ofFn_succ,List.prod_cons] + simp [Fin.succ_ne_zero,List.ofFn_const,List.prod_replicate,pow_succ'] + · rw [List.ofFn_succ,List.prod_cons] + simp only [(Fin.succ_ne_zero k).symm,ite_false,Fin.succ_inj] + rw [ih] + simp only [Fin.val_succ,Nat.add_sub_add_right,pow_succ'] + simp only [mul_assoc] +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open scoped Matrix + +def transposeConfigurationEquiv (W H : ℕ) : (Cell W H→Shape) ≃ (Cell H W→Shape) where + toFun := transposeConfiguration + invFun := transposeConfiguration + left_inv := by intro cfg;funext t;exact transposeShape_involutive _ + right_inv := by intro cfg;funext t;exact transposeShape_involutive _ + +open Classical in +lemma empty_column_shape_sum {W H : ℕ} (k : Fin (W+1)) (west east : Column H) : + (∑ cfg : Cell (W+1) H→Shape,if ∀ j,cfg (k,j)=.empty then + (kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg west east (fun _=>1) (fun _=>1) else 0)= + (rowTransfer H^k.val * weightedColumn (H:=H) (fun _=>.empty) * rowTransfer H^(W-k.val)) west east := by + classical + have hQ (cfg : Cell (W+1) H→Shape) : (∀ j,cfg (k,j)=.empty) ↔ + ∀ i : Fin (W+1),i=k → (fun j=>cfg (i,j))=fun _=>.empty := by + constructor + · intro hh i hi;subst i;exact funext hh + · intro hh j;exact congrFun (hh k rfl) j + simp only [hQ] + refine Eq.trans ?_ ((shape_columns_sum (fun i q=>i=k → q=(fun _=>.empty)) west east).trans ?_) + · apply Finset.sum_congr rfl + intro cfg hcfg + by_cases hp : ∀ i : Fin (W+1),i=k → (fun j=>cfg (i,j))=fun _=>Shape.empty + · simp only [ite_eq_left hp] + · simp only [ite_eq_right hp] + have hK (i : Fin (W+1)) : (∑ q : Fin H→Shape,if i=k → q=(fun _=>.empty) then weightedColumn q else 0)= + if i=k then weightedColumn (H:=H) (fun _=>.empty) else rowTransfer H := by + by_cases hi : i=k + · simp [hi] + · simp [hi,chosen_column_sum,rowTransfer] + have hks : (fun i : Fin (W+1)=>∑ q : Fin H→Shape,if i=k → q=(fun _=>.empty) then weightedColumn q else 0)= + (fun i=>if i=k then weightedColumn (H:=H) (fun _=>.empty) else rowTransfer H) := funext hK + rw [hks,matrixPath_eq_prod] + exact congrArg (fun A : Matrix (Column H) (Column H) ℂ=>A west east) + (constant_cut_product (rowTransfer H) (weightedColumn (H:=H) (fun _=>.empty)) k) + +lemma vacuum_cut_entry {H : ℕ} (A B : Matrix (Column H) (Column H) ℂ) (a b : Column H) : + (A * weightedColumn (fun _ : Fin H=>.empty) * B) a b=A a (fun _=>1)*B (fun _=>1) b := by + classical + rw [weighted_emptyColumn] + change (∑ j,(∑ i,A a i * (if i=(fun _=>1) ∧ j=(fun _=>1) then 1 else 0))*B j b)=_ + simp [ite_and,mul_ite,ite_mul] + +open Classical in +lemma empty_row_shape_sum {W H : ℕ} (k : Fin (H+1)) (south north : Column W) : + (∑ cfg : Cell W (H+1)→Shape,if ∀ i,cfg (i,k)=.empty then + (kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg (fun _=>1) (fun _=>1) south north else 0)= + (rowTransfer W^k.val) south (fun _=>1)*(rowTransfer W^(H-k.val)) (fun _=>1) north := by + classical + rw [←vacuum_cut_entry] + rw [←empty_column_shape_sum] + rw [←(transposeConfigurationEquiv W (H+1)).sum_comp] + apply Finset.sum_congr rfl + intro cfg hcfg + have he : transposeConfigurationEquiv W (H+1) cfg=transposeConfiguration cfg := rfl + simp only [he,transposeConfiguration,transposeShape_empty] + rw [weighted_chosen_transpose] + rfl +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology +open scoped Matrix +noncomputable def hardAssignment {W H : ℕ} (south north : Column W) : Assignment W (H+1) := + (Sum.elim (fun _=>1) (fun p=>if p.2=0 then south p.1 else if p.2=Fin.last (H+1) then north p.1 else 1),fun _=>1) +lemma hardAssignment_boundary {W H : ℕ} (south north : Column W) : + (fun j=> (hardAssignment (H:=H) south north).1 (.inl (0,j)))=(fun _=>1) ∧ + (fun j=> (hardAssignment (H:=H) south north).1 (.inl (Fin.last W,j)))=(fun _=>1) ∧ + (fun i=> (hardAssignment (H:=H) south north).1 (.inr (i,0)))=south ∧ + (fun i=> (hardAssignment (H:=H) south north).1 (.inr (i,Fin.last (H+1))))=north := by + have hn : (Fin.last (H+1) : Fin (H+1+1))≠0 := by intro h;have := congrArg Fin.val h;simp at this + simp [hardAssignment,hn] +lemma hardAssignment_walls {W H : ℕ} (south north : Column (W+1)) : + (∀ j,assignmentSpins (hardAssignment (H:=H) south north) (westPort W H j).wire=1) ∧ + (∀ j,assignmentSpins (hardAssignment (H:=H) south north) (eastPort W H j).wire=1) := by + constructor <;> intro j + · rw [westPort_wire] + simp [assignmentSpins,spins_wire,hardAssignment] + · rw [eastPort_wire] + simp [assignmentSpins,spins_wire,hardAssignment] +lemma hardAssignment_shape {W H : ℕ} (south north : Column W) (cfg : Cell W (H+1)→Shape) : + (∑ x,relativeTerm cfg (hardAssignment south north) x)= + (kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg (fun _=>1) (fun _=>1) south north := by + simp only [relativeTerm_eq_masked] + rw [sum_maskedTerm] + obtain ⟨hw,he,hs,hn⟩:=hardAssignment_boundary (H:=H) south north + rw [hw,he,hs,hn] + +lemma transfer_cut_difference {W H : ℕ} (south north : Column W) (k : Fin (H+1)) : + (rowTransfer W^(H+1)) south north- + (rowTransfer W^k.val) south (fun _=>1)*(rowTransfer W^(H-k.val)) (fun _=>1) north= + restrictedPartition (hardAssignment south north) (fun cfg=>∃ i,cfg (i,k)≠.empty) := by + classical + rw [←prescribed_hard_transfer, prescribed_shape_expansion, ←empty_row_shape_sum] + unfold restrictedPartition + simp only [hardAssignment_shape] + rw [←Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro cfg hcfg + by_cases h : ∀ i,cfg (i,k)=.empty + · simp [h] + · have hh : ∃ i,cfg (i,k)≠.empty := not_forall.mp h + simp [h,hh] + +theorem actual_transfer_cut_bound (W H : ℕ) (south north : Column (W+1)) : + ‖(rowTransfer (W+1)^(H+1)) south north- + (rowTransfer (W+1)^(H/2)) south (fun _=>1)* + (rowTransfer (W+1)^(H-H/2)) (fun _=>1) north‖ ≤ middleErrorBound W H := by + rw [transfer_cut_difference south north (⟨H/2,by omega⟩ : Fin (H+1))] + obtain ⟨hw,he⟩:=hardAssignment_walls (H:=H) south north + exact actual_middle_row_bound _ hw he +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology +lemma pool_cutrow_weight {W H k j : ℕ} (hk : k≤j) (hj : j+k≤H) (a : OnePathPool W H) + (hm : ∃ v∈recoverTrace a,v.2.1=(j:ℤ)) : + badPoolWeight k a=poolWeight a := by + classical + obtain ⟨v,hv,hy⟩:=hm + rcases a with (a|a)|(a|a) + · change archTailWeight k a=archPoolWeight a + unfold archTailWeight + rw [ite_eq_left] + have hh:=poolArchHeight_ge a hv + omega + · change archTailWeight k a=archPoolWeight a + unfold archTailWeight + rw [ite_eq_left] + obtain ⟨u,hu,rfl⟩:=List.mem_map.mp hv + have hh:=poolArchHeight_ge a hu + change (H:ℤ)-u.2.1=(j:ℤ) at hy + omega + · rfl + · rfl +lemma HardChord.cutrow_weight {W H k j : ℕ} (hk : k≤j) (hj : j+k≤H) (c : HardChord W H) + (hm : ∃ v∈c.val.chord.val,v.2.1=(j:ℤ)) : + badPoolWeight k c.encode=poolWeight c.encode := by + apply pool_cutrow_weight hk hj + simpa only [c.recover_encode] using hm +lemma markTotal_tendsto {U V : ℕ→ℝ} {u v : ℝ} + (hU : Tendsto U atTop (𝓝 u)) (hV : Tendsto V atTop (𝓝 v)) (n : ℕ) : + Tendsto (fun H=>ListBound.markTotal (U H) (V H) n) atTop (𝓝 (ListBound.markTotal u v n)) := by + induction n with + | zero => exact tendsto_const_nhds + | succ n ih => exact (hV.mul (hU.pow n)).add (hU.mul ih) +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology +namespace AnyRow +noncomputable def badHardWeight (k : ℕ) {W H : ℕ} (c : BoundaryChord W H) : ℝ := by + classical + exact if hp : EndPort c.source ∧ EndPort c.target then + badPoolWeight k (HardChord.encode ⟨c,hp⟩) else 0 +lemma badHardWeight_nonnegative (k : ℕ) {W H : ℕ} (c : BoundaryChord W H) : 0≤badHardWeight k c := by + unfold badHardWeight + split_ifs + · exact badPoolWeight_nonnegative _ + · exact le_refl _ +lemma sum_badHardWeight_le (W H k : ℕ) : + (∑ c : BoundaryChord W H,badHardWeight k c)≤badPoolMass W H k := by + classical + have he : (∑ c : BoundaryChord W H,badHardWeight k c)= + ∑ c : HardChord W H,badPoolWeight k c.encode := by + have hs : ∀ c : HardChord W H,badHardWeight k c.val=badPoolWeight k c.encode := by + rintro ⟨c,hp⟩ + simp only [badHardWeight,dite_eq_left hp] + calc + _ = ∑ c : BoundaryChord W H,if EndPort c.source ∧ EndPort c.target then badHardWeight k c else 0 := by + apply Finset.sum_congr rfl + intro c hc + by_cases hp : EndPort c.source ∧ EndPort c.target <;> simp [badHardWeight,hp] + _ = ∑ c : HardChord W H,badHardWeight k c.val := + by + rw [←Finset.sum_filter] + exact Finset.sum_subtype _ (by simp) _ + _ = _ := Finset.sum_congr rfl (fun c hc=>hs c) + rw [he] + calc + _ = ∑ a∈Finset.univ.image (HardChord.encode (W:=W) (H:=H)),badPoolWeight k a := + (Finset.sum_image (HardChord.encode_injective W H).injOn).symm + _ ≤ _ := (badPool_summable W H k).sum_le_tsum _ (fun a ha=>badPoolWeight_nonnegative a) +lemma hardWeight_le_bad {W H k j : ℕ} (hk : k≤j) (hj : j+k≤H) (c : BoundaryChord W H) + (hp : EndPort c.source ∧ EndPort c.target) + (hm : ∃ v∈c.chord.val,v.2.1=(j:ℤ)) : hardWeight c≤badHardWeight k c := by + classical + let a : HardChord W H:=⟨c,hp⟩ + have hh:=a.cutrow_weight hk hj hm + unfold hardWeight badHardWeight + rw [ite_eq_left hp,dite_eq_left hp] + change kappa^c.chord.val.length≤badPoolWeight k a.encode + rw [hh,poolWeight,a.encode_length] + +noncomputable def rowErrorBound (W H k : ℕ) : ℝ := + ListBound.markTotal (1+poolMass W H) (badPoolMass W H k) (2*(W+1)) + +theorem actual_cutrow_bound {W H k j : ℕ} (hk : k≤j) (hj : j+k≤H) (x₀ : Assignment (W+1) (H+1)) + (hw : ∀ j,assignmentSpins x₀ (westPort W H j).wire=1) + (he : ∀ j,assignmentSpins x₀ (eastPort W H j).wire=1) : + ‖restrictedPartition x₀ (fun cfg=>∃ i,cfg (i,⟨j,by omega⟩)≠.empty)‖≤ rowErrorBound W H k := by + classical + let Q := fun cfg : Cell (W+1) (H+1)→Shape=>∃ i,cfg (i,⟨j,by omega⟩)≠.empty + obtain ⟨S,hS,hB⟩:=actual_restricted_component_bound x₀ Q + have walls : ∀ cs∈S,∃ x cfg,SelectedSystem x cs ∧ Matches cfg x.1 x.2 ∧ Q cfg ∧ + (∀ j,assignmentSpins x (westPort W H j).wire=1) ∧ + (∀ j,assignmentSpins x (eastPort W H j).wire=1) := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hs⟩:=hS cs hc + exact ⟨x,cfg,hs,hm,hq,fun j=>(sameBoundary_port hx _).trans (hw j), + fun j=>(sameBoundary_port hx _).trans (he j)⟩ + have hn : ∀ cs∈S,cs.length≤2*(W+1) := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hw,he⟩:=walls cs hc + exact hx.length_le_width hw he + have hp : ∀ cs∈S,kappa^(systemNodes cs).length=(cs.map hardWeight).prod := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hw,he⟩:=walls cs hc + exact system_hardWeight (fun c hc=>hx.hard_endpoints hw he hc) + have hb : ∀ cs∈S,∃ c∈cs,hardWeight c≤badHardWeight k c := by + intro cs hc + obtain ⟨x,cfg,hx,hm,hq,hw,he⟩:=walls cs hc + obtain ⟨c,hc,hv⟩:=hx.nonempty_row hm hq + exact ⟨c,hc,hardWeight_le_bad hk hj c (hx.hard_endpoints hw he hc) hv⟩ + calc + _ ≤ ∑ cs∈S,kappa^(systemNodes cs).length := hB + _ = ∑ cs∈S,(cs.map hardWeight).prod := Finset.sum_congr rfl (fun cs hc=>hp cs hc) + _ ≤ ListBound.markTotal (1+∑ c : BoundaryChord W H,hardWeight c) + (∑ c : BoundaryChord W H,badHardWeight k c) (2*(W+1)) := + ListBound.finite_marked_system_bound hardWeight (badHardWeight k) hardWeight_nonnegative (badHardWeight_nonnegative k) S _ hn hb + _ ≤ _ := by + apply markTotal_mono + · have hh := Finset.sum_nonneg (fun c (_ : c∈(Finset.univ : Finset (BoundaryChord W H)))=>hardWeight_nonnegative c) + linarith + · exact Finset.sum_nonneg (fun c hc=>badHardWeight_nonnegative k c) + · rw [sum_hardWeight] + exact add_le_add (le_refl 1) (singleSystemMass_le W H) + · exact sum_badHardWeight_le W H k +end AnyRow +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations FiniteConfigurations FiniteContinuation +open Filter Topology +namespace AnyRow +noncomputable def rowLimitError (W k : ℕ) : ℝ := + ListBound.markTotal (1+2*archPoolMass W) (2*archTailMass W k) (2*(W+1)) +lemma rowErrorBound_limit (W k : ℕ) : Tendsto (fun H=>rowErrorBound W H k) atTop (𝓝 (rowLimitError W k)) := by + apply markTotal_tendsto (tendsto_const_nhds.add (poolMass_limit W)) + simp_rw [badPoolMass_eq] + simpa using tendsto_const_nhds.add ((bridgePoolMass_limit W).const_mul 2) +lemma rowLimitError_limit (W : ℕ) : Tendsto (rowLimitError W) atTop (𝓝 0) := + ListBound.markTotal_limit tendsto_const_nhds (by simpa using (archTailMass_limit W).const_mul 2) _ + +lemma cauchy_of_cut_approximation (u v : ℕ→ℂ) (E : ℕ→ℕ→ℝ) (e : ℕ→ℝ) + (hE : ∀ k,Tendsto (E k) atTop (𝓝 (e k))) (he : Tendsto e atTop (𝓝 0)) + (hB : ∀ k,∀ᶠ H in atTop,‖u H-v k‖≤E k H) : CauchySeq u := by + apply Metric.cauchySeq_iff.mpr + intro ε hε + have hex : ∀ᶠ k in atTop,e k<ε/4 := he.eventually (gt_mem_nhds (by linarith)) + obtain ⟨k,hk⟩:=hex.exists + have hsmall : ∀ᶠ H in atTop,E k H<ε/2 := (hE k).eventually (gt_mem_nhds (by linarith)) + have hdist : ∀ᶠ H in atTop,‖u H-v k‖<ε/2 := by + filter_upwards [hB k,hsmall] with H h1 h2 + exact h1.trans_lt h2 + obtain ⟨N,hN⟩:=eventually_atTop.mp hdist + refine ⟨N,fun m hm n hn=>?_⟩ + have h1:=hN m hm + have h2:=hN n hn + have hh:=dist_triangle (u m) (v k) (u n) + rw [dist_comm (v k) (u n)] at hh + simp only [dist_eq_norm] at hh ⊢ + linarith +end AnyRow +end CriticalHoneycomb.Transfer.RasterGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ColumnTransfer.lean b/lean/OAI/Combinatorics/HoneycombChords/ColumnTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..868d43d58c14989e942102ca8b68a937a286245e --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ColumnTransfer.lean @@ -0,0 +1,454 @@ +import OAI.Combinatorics.HoneycombChords.PlanarDiagrams + +namespace OAI + +/-! +# Column transfer and occupancy normalization + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +lemma act_prefix (t : TileWeights) (pre : List Spin) (i : ℕ) (f : DiluteState) + (xs : List Spin) : + act t (pre.length+i) f (pre++xs) = act t i (fun ys => f (pre++ys)) xs := by + induction pre generalizing f with + | nil => simp + | cons a pre ih => + simpa [act,Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using + (ih (fun ys => f (a::ys))) + +lemma planarRow_prefix (pre : List Spin) (i : ℕ) (ts : List TileWeights) + (f : DiluteState) (xs : List Spin) : + planarRow (pre.length+i) ts f (pre++xs) = + planarRow i ts (fun ys => f (pre++ys)) xs := by + induction ts generalizing i f with + | nil => rfl + | cons t ts ih => + simp only [planarRow] + rw [show pre.length+i+1=pre.length+(i+1) by omega,ih] + congr 1 + funext ys + exact act_prefix t pre i f ys + +lemma sum_spin_vectors_succ {n : ℕ} (F : (Fin (n+1) → Spin) → ℂ) : + (∑ τ, F τ) = ∑ a : Spin, ∑ τ : Fin n → Spin, F (Fin.cons (α:=fun _=>Spin) a τ) := by + rw [←(Fin.consEquiv (fun _ : Fin (n+1) => Spin)).sum_comp F,Fintype.sum_prod_type] + rfl + +/-- Contract the vertical wires within a literal column and all right-side +input wires; the left-side output and upper auxiliary are not summed. -/ +noncomputable def columnContraction (t : TileWeights) (n : ℕ) (f : DiluteState) + (west : Fin n → Spin) (north : Spin) : ℂ := + ∑ east : Fin n → Spin, ∑ vertical : Fin n → Spin, + (∏ j : Fin n, tile t (west j) ((Fin.snoc (α:=fun _=>Spin) vertical north) j.succ) (vertical j) (east j)) * + f (((Fin.snoc (α:=fun _=>Spin) vertical north) 0) :: List.ofFn east) + +lemma columnContraction_zero (t : TileWeights) (f : DiluteState) + (west : Fin 0 → Spin) (north : Spin) : + columnContraction t 0 f west north = f [north] := by + simp [columnContraction,Fin.snoc_zero] + +lemma columnContraction_succ (t : TileWeights) (n : ℕ) (f : DiluteState) + (west : Fin (n+1) → Spin) (north : Spin) : + columnContraction t (n+1) f west north = + columnContraction t n (fun ys => act t 0 f (west 0 :: ys)) + (fun j => west j.succ) north := by + unfold columnContraction + rw [sum_spin_vectors_succ] + simp_rw [sum_spin_vectors_succ,Fin.prod_univ_succ, + ←Fin.cons_snoc_eq_snoc_cons,Fin.cons_succ,Fin.cons_zero,List.ofFn_succ] + simp only [act,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro east heast + conv_lhs => + arg 2 + ext firstEast + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro vertical hvertical + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro south hsouth + apply Finset.sum_congr rfl + intro firstEast hfirstEast + simp only [Fin.cons_zero,Fin.cons_succ] + ring + +/-- This is the exact tensor contraction equality for an arbitrary column, +including each internal spin once. No cancellation or eigenvalue input. -/ +theorem planarRow_eq_columnContraction (t : TileWeights) (n : ℕ) (f : DiluteState) + (west : Fin n → Spin) (north : Spin) : + planarRow 0 (List.replicate n t) f (List.ofFn west ++ [north]) = + columnContraction t n f west north := by + induction n generalizing f with + | zero => simp [planarRow,columnContraction_zero] + | succ n ih => + rw [List.replicate_succ,List.ofFn_succ,List.cons_append,planarRow] + rw [show 0+1=([west 0] : List Spin).length+0 by rfl] + change planarRow (([west 0] : List Spin).length+0) (List.replicate n t) + (act t 0 f) ([west 0] ++ (List.ofFn (fun j => west j.succ) ++ [north])) = _ + rw [planarRow_prefix,ih,columnContraction_succ] + rfl + +noncomputable def columnKernelSpin (t : TileWeights) (n : ℕ) (south north : Spin) + (west east : Fin n → Spin) : ℂ := + ∑ vertical : Fin n → Spin, + if (Fin.snoc (α:=fun _=>Spin) vertical north) 0=south then + ∏ j : Fin n, tile t (west j) ((Fin.snoc (α:=fun _=>Spin) vertical north) j.succ) + (vertical j) (east j) else 0 + +lemma columnContraction_delta (t : TileWeights) (n : ℕ) (south north : Spin) + (west east : Fin n → Spin) : + columnContraction t n (fun xs => if xs=south::List.ofFn east then 1 else 0) west north = + columnKernelSpin t n south north west east := by + classical + unfold columnContraction columnKernelSpin + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro vertical hv + simp only [List.cons.injEq,List.ofFn_injective.eq_iff,mul_ite,mul_one,mul_zero] + by_cases hs : (Fin.snoc (α:=fun _=>Spin) vertical north) 0=south + · simp [hs] + · simp [hs] + +theorem planarRow_delta (t : TileWeights) (n : ℕ) (south north : Spin) + (west east : Fin n → Spin) : + planarRow 0 (List.replicate n t) (fun xs => if xs=south::List.ofFn east then 1 else 0) + (List.ofFn west++[north]) = columnKernelSpin t n south north west east := by + rw [planarRow_eq_columnContraction,columnContraction_delta] + +end CriticalHoneycomb.Transfer.PlanarNormalization + + +namespace CriticalHoneycomb.Transfer.RasterGrid +open scoped BigOperators + +def spinEquiv : PlanarNormalization.Spin ≃ Fin 3 where + toFun := PlanarNormalization.spinIndex + invFun i := if i=1 then none else some (decide (i=2)) + left_inv i := by fin_cases i <;> rfl + right_inv i := by fin_cases i <;> rfl + +@[simp] lemma spinEquiv_apply (i : PlanarNormalization.Spin) : spinEquiv i = PlanarNormalization.spinIndex i := rfl + +noncomputable def physicalWeights : PlanarNormalization.TileWeights := + ⟨(kappa:ℂ),(kappa^2:ℂ),(kappa^2:ℂ),(kappa^2:ℂ),0⟩ + +lemma sourceR_eq (t : PlanarNormalization.TileWeights) (p q : Fin 3 × Fin 3) : + PlanarNormalization.sourceR t p q = Planar.sourceR t.a t.h t.v t.c t.d p q := rfl + +lemma tile_physical (i j k l : PlanarNormalization.Spin) : + PlanarNormalization.tile physicalWeights i j k l = + Planar.sourceR (kappa:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) 0 + (spinEquiv j,spinEquiv i) (spinEquiv k,spinEquiv l) := by + rw [PlanarNormalization.tile_eq_sourceR,sourceR_eq] + rfl + +/-- Changing from vacant/arrow spins to the manuscript's +,0,- ordering. -/ +def columnSpinEquiv (H : ℕ) : (Fin H → PlanarNormalization.Spin) ≃ Column H := + Equiv.piCongrRight (fun _ => spinEquiv) + +@[simp] lemma columnSpinEquiv_apply {H : ℕ} (a : Fin H → PlanarNormalization.Spin) (i : Fin H) : + columnSpinEquiv H a i = spinEquiv (a i) := rfl + +lemma columnKernel_eq_spin (H : ℕ) (south north : PlanarNormalization.Spin) + (west east : Fin H → PlanarNormalization.Spin) : + columnKernel H (spinEquiv south) (spinEquiv north) + (columnSpinEquiv H west) (columnSpinEquiv H east) = + PlanarNormalization.columnKernelSpin physicalWeights H south north west east := by + classical + unfold columnKernel PlanarNormalization.columnKernelSpin + rw [←(columnSpinEquiv H).sum_comp] + apply Finset.sum_congr rfl + intro vertical hv + have hs : ∀ j : Fin (H+1), + Fin.snoc (α:=fun _=> Fin 3) (columnSpinEquiv H vertical) (spinEquiv north) j = + spinEquiv (Fin.snoc (α:=fun _=> PlanarNormalization.Spin) vertical north j) := by + intro j + cases j using Fin.lastCases <;> simp + simp only [hs,Equiv.apply_eq_iff_eq] + split_ifs with h + · unfold columnProduct + apply Finset.prod_congr rfl + intro j hj + rw [hs] + exact (tile_physical _ _ _ _).symm + · rfl + +/-- Exact physical lattice-column transfer as the already normalized +planar cup/cap circuit. The boundary delta has not been replaced by any +probability or connectivity assumption. -/ +theorem columnKernel_eq_planarRow (H : ℕ) (south north : PlanarNormalization.Spin) + (west east : Fin H → PlanarNormalization.Spin) : + columnKernel H (spinEquiv south) (spinEquiv north) + (columnSpinEquiv H west) (columnSpinEquiv H east) = + PlanarNormalization.planarRow 0 (List.replicate H physicalWeights) + (fun xs => if xs=south::List.ofFn east then 1 else 0) + (List.ofFn west++[north]) := by + rw [columnKernel_eq_spin,PlanarNormalization.planarRow_delta] + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +/-- Fix all occupied edges of a frontier, without fixing their orientations. -/ +noncomputable def mask (o : List Bool) (f : DiluteState) : DiluteState := + fun xs => if occupancy xs = o then f xs else 0 + +lemma mask_embed (o p : List Bool) (f : State) : + mask o (embed p f) = if o=p then embed p f else fun _ => 0 := by + classical + funext xs + by_cases h : o=p + · subst p + by_cases hx : occupancy xs = o <;> simp [mask,embed,hx] + · simp only [ite_eq_right h,mask,embed] + split_ifs with hx hy + · exact (h (hx.symm.trans hy)).elim + · rfl + · rfl + +lemma mask_add (o : List Bool) (f g : DiluteState) : + mask o (fun xs => f xs + g xs) = fun xs => mask o f xs + mask o g xs := by + funext xs + simp only [mask] + split_ifs <;> simp + +lemma mask_smul (o : List Bool) (z : ℂ) (f : DiluteState) : + mask o (fun xs => z*f xs) = fun xs => z*mask o f xs := by + funext xs + simp only [mask] + split_ifs <;> simp + +lemma mask_zero (o : List Bool) : mask o (fun _ => 0) = fun _ => 0 := by + funext xs + simp [mask] + +lemma mask_span (o : List Bool) {n : ℕ} {f : DiluteState} + (hf : PlanarSpan n f) : PlanarSpan n (mask o f) := by + induction hf with + | zero => rw [mask_zero]; exact .zero + | basis p k w hl hc => + rw [mask_embed] + split_ifs + · exact .basis p k w hl hc + · exact .zero + | add hf hg ihf ihg => rw [mask_add]; exact .add ihf ihg + | smul z hf ihf => rw [mask_smul]; exact .smul z ihf + +lemma mask_vacuum (o : List Bool) (n : ℕ) (f : DiluteState) : + mask o f (List.replicate n none) = + (if o=List.replicate n false then 1 else 0) * f (List.replicate n none) := by + simp only [mask,occupancy,List.map_replicate,Option.isSome_none] + split_ifs with ho ho ho <;> simp_all + +/-- A fully resolved occupancy history. Summation now remains only over +orientations; it is not a sum over different unoriented configurations. -/ +structure MaskedGate where + weights : TileWeights + site : ℕ + output : List Bool + +noncomputable def maskedAct (g : MaskedGate) (f : DiluteState) : DiluteState := + mask g.output (act g.weights g.site f) + +lemma maskedAct_span {n : ℕ} (g : MaskedGate) (hi : g.site+1 maskedAct g f) f) (List.replicate n none) = + (gs.map (fun g => if g.output=List.replicate n false then (1:ℂ) else 0)).prod * + f (List.replicate n none) := by + induction gs generalizing f with + | nil => simp + | cons g gs ih => + rw [List.foldl_cons,ih (by aesop) (maskedAct_span _ (hg g (by simp)) hf), + maskedAct_vacuum _ (hg g (by simp)) hf] + simp only [List.map_cons,List.prod_cons] + ring + +/-- Exact cancellation of each nonempty closed unoriented configuration, +not only cancellation after all configurations have been summed. -/ +theorem nonempty_closed_history_zero {n : ℕ} (gs : List MaskedGate) + (hg : ∀ g ∈ gs, g.site+1 maskedAct g f) + (embed (List.replicate n false) (fun _ => 1))) (List.replicate n none) = 0 := by + have hf : PlanarSpan n (embed (List.replicate n false) (fun _ => 1)) := + PlanarSpan.basis (List.replicate n false) 0 .start (by simp) (by simp [List.count_replicate]) + rw [masked_history_vacuum gs hg hf] + obtain ⟨g,hg,hne⟩ := hne + have hz : (0:ℂ) ∈ gs.map (fun g => if g.output=List.replicate n false then (1:ℂ) else 0) := by + exact List.mem_map.mpr ⟨g,hg,ite_eq_right hne⟩ + rw [List.prod_eq_zero_iff.mpr hz,zero_mul] + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +/-- Physical tile with the positive center-count factor removed. The +forbidden double-return connectivity still has coefficient exactly zero. -/ +noncomputable def resolvedWeights : TileWeights := ⟨1,1,1,1,0⟩ + +/-- After fixing all occupied wire sets, a physical honeycomb history is a +single planar word or zero, not a linear superposition of connectivities. -/ +inductive Resolved (b n : ℕ) (root : State) : DiluteState → Prop + | zero : Resolved b n root (fun _ => 0) + | basis (o : List Bool) (k : ℕ) (w : PlanarWord b k) + (hl : o.length=n) (hc : o.count true=b+2*k) : + Resolved b n root (embed o (w.eval root)) + +lemma mask_disjoint_pair (out o p : List Bool) (f g : State) (hop : o≠p) : + mask out (fun xs => embed o f xs + embed p g xs) = (fun _ => 0) ∨ + mask out (fun xs => embed o f xs + embed p g xs) = embed o f ∨ + mask out (fun xs => embed o f xs + embed p g xs) = embed p g := by + rw [mask_add,mask_embed,mask_embed] + by_cases ho : out=o + · subst out + simp [hop] + · by_cases hp : out=p + · subst out + simp [ho] + · simp [hp,ho] + +lemma resolved_mask_pair {b n : ℕ} {root : State} + (out o p : List Bool) (f g : State) (hop : o≠p) + (hf : Resolved b n root (embed o f)) (hg : Resolved b n root (embed p g)) : + Resolved b n root (mask out (fun xs => embed o f xs + embed p g xs)) := by + rcases mask_disjoint_pair out o p f g hop with h|h|h <;> rw [h] + · exact .zero + · exact hf + · exact hg + +/-- Exact source physical local action at fixed input and output occupancy. +The positive κ-factors can be restored after this orientation calculation. -/ +lemma resolved_step {b n i : ℕ} (hb : b≤1) (hi : i+1 rw [act_zero,mask_zero]; exact .zero + | basis o k w hl hc => + obtain ⟨pre,a,b',post,rfl,hpre⟩ := two_at o i (by omega) + subst i + cases a <;> cases b' + · rw [act_empty_at] + simp only [resolvedWeights,one_mul] + apply resolved_mask_pair + · simp + · exact .basis _ k w hl hc + · have hip : pre.count true ≤ b+2*k := by simp [List.count_append] at hc; omega + exact .basis _ (k+1) (.insert w (pre.count true) hip) + (by simpa using hl) (by simp_all [List.count_append]; omega) + · rw [act_right_at] + simp only [resolvedWeights,one_mul] + apply resolved_mask_pair + · simp + · exact .basis _ k w hl hc + · exact .basis _ k w (by simpa using hl) + (by simpa [List.count_append,List.count_cons] using hc) + · rw [act_left_at] + simp only [resolvedWeights,one_mul] + apply resolved_mask_pair + · simp + · exact .basis _ k w hl hc + · exact .basis _ k w (by simpa using hl) + (by simpa [List.count_append,List.count_cons] using hc) + · have hk : 0 resolvedAct g f) f) := by + induction gs generalizing f with + | nil => exact hf + | cons g gs ih => + exact ih (by aesop) (resolved_step hb (hg g (by simp)) _ hf) + + +/-- Put the same orientation on the occupied positions of a frontier. This +is used only for frontiers with exactly one occupied edge. -/ +def arrowState (o : List Bool) (a : Bool) : List Spin := + o.map (fun b => if b then some a else none) + +lemma occupancy_arrowState (o : List Bool) (a : Bool) : + occupancy (arrowState o a)=o := by + induction o with + | nil => rfl + | cons b o ih => cases b <;> simp [arrowState,occupancy] at * <;> exact ih + +lemma orientations_arrowState (o : List Bool) (a : Bool) : + orientations (arrowState o a)=List.replicate (o.count true) a := by + induction o with + | nil => rfl + | cons b o ih => + cases b <;> simp [arrowState,orientations,List.replicate_succ] at * <;> exact ih + +lemma embed_arrowState (o p : List Bool) (f : State) (a : Bool) : + embed o f (arrowState p a) = if p=o then f (List.replicate (p.count true) a) else 0 := by + simp [embed,occupancy_arrowState,orientations_arrowState] + +/-- The exact phase normalization with every unoriented history fixed. +There is no positivity assumption on the complex local phases. -/ +theorem resolved_one_strand {n : ℕ} {root : State} {f : DiluteState} + (hf : Resolved 1 n root f) (out : List Bool) (hout : out.count true=1) : + (∀ a : Bool, f (arrowState out a)=0) ∨ + (∀ a : Bool, f (arrowState out a)=root [a]) := by + cases hf with + | zero => exact Or.inl (fun _ => rfl) + | basis o k w hl hc => + by_cases ho : out=o + · subst o + have hk : k=0 := by omega + subst k + rcases one_strand_zero_or_identity w root with h|h + · exact Or.inl (fun a => by simpa [embed_arrowState,hout] using h a) + · exact Or.inr (fun a => by simpa [embed_arrowState,hout] using h a) + · exact Or.inl (fun a => by simp [embed_arrowState,ho]) + +theorem resolved_history_one_strand {n : ℕ} (gs : List ResolvedGate) + (hg : ∀ g∈gs, g.site+1 resolvedAct g f) (embed input root)) + (arrowState out a)=0) ∨ + (∀ a : Bool, (gs.foldl (fun f g => resolvedAct g f) (embed input root)) + (arrowState out a)=root [a]) := by + have hf : Resolved 1 n root (embed input root) := + .basis input 0 .start hi (by simpa using hinput) + exact resolved_one_strand (resolved_history (by omega : 1≤1) gs hg hf) out hout + +end CriticalHoneycomb.Transfer.PlanarNormalization + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/CommonEigenline.lean b/lean/OAI/Combinatorics/HoneycombChords/CommonEigenline.lean new file mode 100644 index 0000000000000000000000000000000000000000..a57613707a8225d019798db2f62a704ff96bd665 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/CommonEigenline.lean @@ -0,0 +1,1134 @@ +import OAI.Combinatorics.HoneycombChords.ClosedFusion +import OAI.Combinatorics.HoneycombChords.StripExhaustion + +namespace OAI + +/-! The physical common eigenline and its crossing observable. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet Filter Topology +open scoped Matrix +lemma marked_double_mixed_ports (H m : ℕ) : + both ((markedDoubleMatrix H^m) (fun _=>1) (fun _=>1))= + ∑ j : Fin (2*m),∑ k : Fin (2*m), + prescribedPartition H (2*m) (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1) := by + rw [markedDoubleMatrix_eq,←pow_mul,marked_power_mixed] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + exact prescribed_transpose _ _ _ _ _ _ + +theorem source_marked_coefficient_limit (W : ℕ) : + Tendsto (fun m : ℕ=> + (both ((markedDoubleMatrix (W+1)^m) (fun _=>1) (fun _=>1))).re/(m:ℝ)) atTop + (𝓝 (2*∑' γ : StrictBridge (W+1),kappa^γ.val.length)) := by + apply (tendsto_add_atTop_iff_nat 1).mp + have ht : Tendsto (fun m : ℕ=>2*m+1) atTop atTop := by + apply tendsto_atTop_mono _ tendsto_id + intro m + dsimp + omega + have hh:=(StripExhaustion.physical_rectangle_average_limit W).comp ht + have hl:=hh.const_mul 2 + convert hl using 1 + funext m + dsimp only [Function.comp_apply] + rw [marked_double_mixed_ports,Complex.re_sum] + simp only [Complex.re_sum] + have hn : 2*(m+1)=2*m+1+1 := by omega + have hs := congrArg (fun n : ℕ=>∑ j : Fin n,∑ k : Fin n, + (prescribedPartition (W+1) n (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)).re) hn + rw [hs,Finset.sum_comm] + have hc : ((2*m+1+1:ℕ):ℝ)=2*((m+1:ℕ):ℝ) := by push_cast;ring + rw [hc] + ring +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet Filter Topology +open scoped Matrix +lemma markedProjection_vacuum_base (W : ℕ) : + base (markedProjection W (fun _=>1) (fun _=>1))=1 := by + have hh:=congrFun (congrFun (markedProjection_base W) (fun _=>1)) (fun _=>1) + exact hh.trans (projection_vacuum W) +lemma marked_vacuum_coefficient (W m : ℕ) : + both ((markedDoubleMatrix (W+1)^(m+1)) (fun _=>1) (fun _=>1))= + ((m+1:ℕ):ℂ)*eigenCoefficient W+ + both (markedProjection W (fun _=>1) (fun _=>1))+ + both ((markedRemainder W^(m+1)) (fun _=>1) (fun _=>1)) := by + rw [marked_power_split,markedEigenvalue_pow] + simp only [Matrix.add_apply,Matrix.smul_apply,smul_eq_mul,both_add,both_mul, + base_form,left_form,right_form,both_form,one_mul,zero_mul,add_zero, + markedProjection_vacuum_base,mul_one] + ring + +theorem marked_eigenvalue_limit (W : ℕ) : + Tendsto (fun m : ℕ=>both ((markedDoubleMatrix (W+1)^m) (fun _=>1) (fun _=>1))/(m:ℂ)) + atTop (𝓝 (eigenCoefficient W)) := by + apply (tendsto_add_atTop_iff_nat 1).mp + have hr : Tendsto (fun m : ℕ=>both ((markedRemainder W^(m+1)) (fun _=>1) (fun _=>1))) + atTop (𝓝 0) := by + have hh:=tendsto_pi_nhds.mp (tendsto_pi_nhds.mp (marked_remainder_limit W) (fun _=>1)) (fun _=>1) + have hq:=(continuous_both.tendsto 0).comp (hh.comp (tendsto_add_atTop_nat 1)) + simpa [Function.comp_def,both] using hq + have hi : Tendsto (fun m : ℕ=>(((m+1:ℕ):ℂ))⁻¹) atTop (𝓝 0) := + tendsto_inv_atTop_nhds_zero_nat.comp (tendsto_add_atTop_nat 1) + have hd:=((tendsto_const_nhds (x:=both (markedProjection W (fun _=>1) (fun _=>1)))).add hr).mul hi + have hl:=(tendsto_const_nhds (x:=eigenCoefficient W)).add hd + simp only [add_zero,mul_zero] at hl + convert hl using 1 + funext m + rw [marked_vacuum_coefficient] + have hm : ((m+1:ℕ):ℂ)≠0 := by exact_mod_cast Nat.succ_ne_zero m + field_simp + ring +lemma rectangular_ports_im_zero (W n : ℕ) : + (∑ j : Fin n,∑ k : Fin n, + prescribedPartition (W+1) n (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)).im=0 := by + classical + cases n with + | zero => simp + | succ n => + simp only [Complex.im_sum] + apply Finset.sum_eq_zero + intro j hj + apply Finset.sum_eq_zero + intro k hk + rw [actual_chord_sum_eq_transfer] + simp only [Complex.im_sum,←Complex.ofReal_pow,Complex.ofReal_im,Finset.sum_const_zero] +lemma marked_coefficient_real (W m : ℕ) : + ((both ((markedDoubleMatrix (W+1)^m) (fun _=>1) (fun _=>1))).re:ℂ)= + both ((markedDoubleMatrix (W+1)^m) (fun _=>1) (fun _=>1)) := by + apply Complex.ext + · simp + · simp only [Complex.ofReal_im] + rw [marked_double_mixed_ports,rectangular_ports_im_zero] + +theorem source_eigenvalue_eq_twice_bridge_mass (W : ℕ) : + eigenCoefficient W=2*((∑' γ : StrictBridge (W+1),kappa^γ.val.length):ℝ) := by + have hl:=(Complex.continuous_ofReal.tendsto + (2*∑' γ : StrictBridge (W+1),kappa^γ.val.length)).comp (source_marked_coefficient_limit W) + have hc : Tendsto (fun m : ℕ=>both ((markedDoubleMatrix (W+1)^m) (fun _=>1) (fun _=>1))/(m:ℂ)) + atTop (𝓝 (2*((∑' γ : StrictBridge (W+1),kappa^γ.val.length):ℝ))) := by + simpa only [Function.comp_def,Complex.ofReal_div,Complex.ofReal_natCast, + marked_coefficient_real,Complex.ofReal_mul,Complex.ofReal_ofNat] using hl + exact tendsto_nhds_unique (marked_eigenvalue_limit W) hc +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def reorient (n : ℕ) (M : Matrix (Space n) (Space n) Jet) : + Matrix (Space n) (Space n) Jet := + (M.submatrix (reflectedSites n) (reflectedSites n)).map reflectJet +lemma reorient_mul (n : ℕ) (M N : Matrix (Space n) (Space n) Jet) : + reorient n (M*N)=reorient n M*reorient n N := by + unfold reorient + rw [Matrix.submatrix_mul _ _ _ _ _ (reflectedSites n).bijective,Matrix.map_mul] +lemma physicalFamily_commute (n : ℕ) (u v : ℝ) + (hu : Nonsingular n (homogeneous n) u) (hv : Nonsingular n (homogeneous n) v) : + Commute (physicalFamily n u) (physicalFamily n v) := by + have h:=congrArg (reorient n) (source_global_spectral_commutation n (homogeneous n) u v hu hv).eq + change reorient n (T n (homogeneous n) u)*reorient n (T n (homogeneous n) v)= + reorient n (T n (homogeneous n) v)*reorient n (T n (homogeneous n) u) + simpa only [reorient_mul] using h +noncomputable def physicalScalar (W : ℕ) (u : ℝ) : Jet := + commonScalar W (physicalFamily (W+1) u) +theorem physical_common_line (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) u) : + physicalFamily (W+1) u*ᵥmarkedEigenvector W= + physicalScalar W u•markedEigenvector W := by + apply commuting_common_line + rw [←physicalFamily_at_gamma] + exact physicalFamily_commute (W+1) gamma u (homogeneous_nonsingular _) hu +lemma physicalScalar_at_gamma (W : ℕ) : physicalScalar W gamma=markedEigenvalue W := by + unfold physicalScalar commonScalar + rw [physicalFamily_at_gamma,source_marked_eigenvector] + change (∑ s,normalizedDual W s*(markedEigenvalue W*markedEigenvector W s))=_ + calc + _=markedEigenvalue W*(normalizedDual W ⬝ᵥ markedEigenvector W) := by + simp only [dotProduct,Finset.mul_sum] + apply Finset.sum_congr rfl + intro s hs + ring + _=markedEigenvalue W := by rw [normalized_pair,mul_one] +lemma physicalScalar_mass (W : ℕ) : + both (physicalScalar W gamma)=2*((∑' γ : StrictBridge (W+1),kappa^γ.val.length):ℝ) := by + rw [physicalScalar_at_gamma,markedEigenvalue,both_form] + exact source_eigenvalue_eq_twice_bridge_mass W +lemma physicalScalar_reflection (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) u) : + physicalScalar W (b-u)=physicalScalar W u := by + unfold physicalScalar physicalFamily + rw [source_spectral_reflection _ _ u hu] +lemma physicalScalar_periodicity (W : ℕ) (u : ℝ) : + physicalScalar W (u+Real.pi)=physicalScalar W u := by + unfold physicalScalar physicalFamily + rw [source_spectral_periodicity] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators +lemma seedAux_eq (k : ℂ) (f : DiluteState) : + act (boundaryWeights k) 0 (addAux f) = seedAux k f := by + funext xs + cases xs with + | nil => rfl + | cons a xs => cases xs with + | nil => rfl + | cons b xs => + simp only [act,Fintype.sum_option,Fintype.sum_bool,addAux,mul_zero,add_zero] + exact congrArg (fun z => z * f xs) (boundary_input k a b) + +def rowGates : ℕ → List TileWeights → List (TileWeights × ℕ) + | _, [] => [] + | i, t::ts => (t,i)::rowGates (i+1) ts + +lemma fold_rowGates (i : ℕ) (ts : List TileWeights) (f : DiluteState) : + (rowGates i ts).foldl (fun f g => act g.1 g.2 f) f = planarRow i ts f := by + induction ts generalizing i f with + | nil => rfl + | cons t ts ih => exact ih (i+1) (act t i f) + +lemma rowGates_valid {w i : ℕ} (ts : List TileWeights) (h : i+ts.length simp [rowGates] + | cons t ts ih => + intro g hg + simp only [rowGates,List.mem_cons] at hg + rcases hg with rfl | hg + · simp at h + simp only + omega + · exact ih (by simp at h; omega) g hg + +noncomputable def twoRowGates (n : ℕ) (tsA tsB : List TileWeights) (kR kL : ℂ) : + List (TileWeights × ℕ) := + [(boundaryWeights kR,0)] ++ rowGates 1 tsB ++ rowGates 0 tsA ++ [(boundaryWeights kL,n)] + +lemma twoRowGates_valid {n : ℕ} (tsA tsB : List TileWeights) + (hA : tsA.length=n) (hB : tsB.length=n) (kR kL : ℂ) : + ∀ g ∈ twoRowGates n tsA tsB kR kL, g.2+1 act g.1 g.2 f) f = + act (boundaryWeights kL) n + (planarRow 0 tsA (planarRow 1 tsB (act (boundaryWeights kR) 0 f))) := by + simp only [twoRowGates,List.foldl_append,List.foldl_cons,List.foldl_nil,fold_rowGates] + +lemma span_zero_of_length {n : ℕ} {f : DiluteState} (hf : PlanarSpan n f) + (xs : List Spin) (hx : xs.length≠n) : f xs=0 := by + induction hf with + | zero => rfl + | basis o k w hl hc => + have hne : occupancy xs≠o := by + intro he + have he' := congrArg List.length he + simp only [occupancy,List.length_map] at he' + exact hx (he'.trans hl) + simp [embed,hne] + | add hf hg ihf ihg => simp [ihf,ihg] + | smul z hf ihf => simp [ihf] + +noncomputable def sourceDoubleRow (n : ℕ) (tsA tsB : List TileWeights) (kR kL : ℂ) + (f : DiluteState) : DiluteState := fun xs => + if xs.length=n then + ∑ a : Spin, ∑ b : Spin, K kL a b * sourceTwoRows tsA tsB (seedAux kR f) (a::b::xs) + else 0 + +theorem sourceDoubleRow_eq_network {n : ℕ} (tsA tsB : List TileWeights) + (hA : tsA.length=n) (hB : tsB.length=n) (kR kL : ℂ) + {f : DiluteState} (hf : PlanarSpan n f) : + sourceDoubleRow n tsA tsB kR kL f = auxNetwork (twoRowGates n tsA tsB kR kL) f := by + funext xs + by_cases hx : xs.length=n + · simp only [sourceDoubleRow,hx,ite_true,auxNetwork,removeAux,fold_twoRowGates,seedAux_eq] + rw [←hx,act_at] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + rw [boundary_output,two_rows_eq tsA tsB hA hB _ xs hx a b] + · simp only [sourceDoubleRow,hx,ite_false] + symm + exact span_zero_of_length + (auxNetwork_span _ (twoRowGates_valid tsA tsB hA hB kR kL) hf) xs hx + +lemma sourceDoubleRow_span {n : ℕ} (tsA tsB : List TileWeights) + (hA : tsA.length=n) (hB : tsB.length=n) (kR kL : ℂ) + {f : DiluteState} (hf : PlanarSpan n f) : + PlanarSpan n (sourceDoubleRow n tsA tsB kR kL f) := by + rw [sourceDoubleRow_eq_network tsA tsB hA hB kR kL hf] + exact auxNetwork_span _ (twoRowGates_valid tsA tsB hA hB kR kL) hf + +theorem sourceDoubleRow_vacuum {n : ℕ} (tsA tsB : List TileWeights) + (hA : tsA.length=n) (hB : tsB.length=n) (kR kL : ℂ) + {f : DiluteState} (hf : PlanarSpan n f) : + sourceDoubleRow n tsA tsB kR kL f (List.replicate n none) = + f (List.replicate n none) := by + rw [sourceDoubleRow_eq_network tsA tsB hA hB kR kL hf] + exact auxNetwork_vacuum _ (twoRowGates_valid tsA tsB hA hB kR kL) hf + +noncomputable def vacuum (n : ℕ) : DiluteState := + embed (List.replicate n false) (fun _ => 1) + +lemma vacuum_span (n : ℕ) : PlanarSpan n (vacuum n) := by + exact .basis _ 0 .start (by simp) (by simp [List.count_replicate]) + +lemma vacuum_value (n : ℕ) : vacuum n (List.replicate n none) = 1 := by + simp [vacuum,embed,occupancy] + +noncomputable def sourceRows (n : ℕ) (tsA tsB : List TileWeights) (kR kL : ℂ) : + ℕ → DiluteState + | 0 => vacuum n + | m+1 => sourceDoubleRow n tsA tsB kR kL (sourceRows n tsA tsB kR kL m) + +lemma sourceRows_span {n : ℕ} (tsA tsB : List TileWeights) + (hA : tsA.length=n) (hB : tsB.length=n) (kR kL : ℂ) (m : ℕ) : + PlanarSpan n (sourceRows n tsA tsB kR kL m) := by + induction m with + | zero => exact vacuum_span n + | succ m ih => exact sourceDoubleRow_span tsA tsB hA hB kR kL ih + +theorem sourceRows_empty_entry {n : ℕ} (tsA tsB : List TileWeights) + (hA : tsA.length=n) (hB : tsB.length=n) (kR kL : ℂ) (m : ℕ) : + sourceRows n tsA tsB kR kL m (List.replicate n none) = 1 := by + induction m with + | zero => exact vacuum_value n + | succ m ih => + rw [sourceRows,sourceDoubleRow_vacuum tsA tsB hA hB kR kL + (sourceRows_span tsA tsB hA hB kR kL m)] + exact ih + +end CriticalHoneycomb.Transfer.PlanarNormalization + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma normalizedR_sourceR (u : ℝ) : normalizedR u= + Planar.sourceR (Transfer.a u) (Transfer.h u) (Transfer.v u) (Transfer.c u) (Transfer.d u) := by + rfl +lemma spectralR_charge (u : ℝ) (a b c d : Spin) + (hz : spectralR u (a,b) (c,d)≠0) : spinCharge a+spinCharge b=spinCharge c+spinCharge d := by + by_cases hQ : Q u=0 + · simp [spectralR,hQ] at hz + · rw [spectralR_normalized u hQ,normalizedR_sourceR] at hz + have h:=sourceR_charge (Transfer.a u) (Transfer.h u) (Transfer.v u) + (Transfer.c u) (Transfer.d u) b a c d hz + omega +lemma row_charge (n : ℕ) (R : Fin n→Matrix Pair Pair ℂ) + (hR : ∀ i a b c d,R i (a,b) (c,d)≠0→spinCharge a+spinCharge b=spinCharge c+spinCharge d) + (w e : Space n) (a b : Spin) (hz : row n R w e a b≠0) : + columnCharge w+spinCharge a=columnCharge e+spinCharge b := by + induction n generalizing a b with + | zero => + have hab : a=b := by + by_contra hab + simp [row,hab] at hz + subst b + simp [columnCharge] + | succ n ih => + simp only [row,Matrix.mul_apply] at hz + obtain ⟨z,_,hz⟩:=Finset.exists_ne_zero_of_sum_ne_zero hz + have h0:=hR 0 a (w 0) z (e 0) (mul_ne_zero_iff.mp hz).1 + have h1:=ih (Fin.tail R) (fun i=>hR i.succ) (Fin.tail w) (Fin.tail e) z b + (mul_ne_zero_iff.mp hz).2 + simp only [columnCharge,Fin.sum_univ_succ,Fin.tail] at h0 h1 ⊢ + omega +lemma spectral_row_charge (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) + (w e : Space n) (a b : Spin) (hz : row n (exactSites n ξ u) w e a b≠0) : + columnCharge w+spinCharge a=columnCharge e+spinCharge b := + row_charge n _ (fun i=> spectralR_charge (u+ξ i)) w e a b hz +lemma bulkRows_charge (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) + (w e : Space n) (p q : Pair) (hz : bulkRows n ξ u w e p q≠0) : + columnCharge w+(spinCharge p.1+spinCharge p.2)= + columnCharge e+(spinCharge q.1+spinCharge q.2) := by + simp only [bulkRows,forward,Matrix.sum_apply,Matrix.kronecker,Matrix.kroneckerMap,Matrix.of_apply] at hz + obtain ⟨v,_,hv⟩:=Finset.exists_ne_zero_of_sum_ne_zero hz + have h1:=spectral_row_charge n ξ u w v p.1 q.1 (mul_ne_zero_iff.mp hv).1 + have h2:=spectral_row_charge n ξ (b-u) v e p.2 q.2 (mul_ne_zero_iff.mp hv).2 + omega +lemma K0_charge (u : ℝ) (p : Pair) (hz : K0 u p≠0) : spinCharge p.1+spinCharge p.2=0 := by + rcases p with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> simp_all [K0,boundary0,Fin.rev,spinCharge] +lemma K1_charge (u : ℝ) (p : Pair) (hz : K1 u p≠0) : spinCharge p.1+spinCharge p.2= -1 := by + rcases p with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> simp_all [K1,boundary1,Fin.rev,spinCharge] +lemma coefficient_shift (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) (i j : Bool) : + HasShift (coefficient n ξ u i j) ((if i then 1 else 0)-(if j then 1 else 0)) := by + intro w e hz + obtain ⟨p,_,hp⟩:=Finset.exists_ne_zero_of_sum_ne_zero hz + obtain ⟨q,_,hq⟩:=Finset.exists_ne_zero_of_sum_ne_zero hp + have hb:=bulkRows_charge n ξ u w e p q (mul_ne_zero_iff.mp (mul_ne_zero_iff.mp hq).1).2 + have hL:= (mul_ne_zero_iff.mp (mul_ne_zero_iff.mp hq).1).1 + have hR:= (mul_ne_zero_iff.mp hq).2 + cases i <;> cases j <;> simp only [Bool.false_eq_true,ite_false,ite_true] at hL hR ⊢ + · have hl:=K0_charge (b-u) p hL;have hr:=K0_charge u q hR;omega + · have hl:=K0_charge (b-u) p hL;have hr:=K1_charge u q hR;omega + · have hl:=K1_charge (b-u) p hL;have hr:=K0_charge u q hR;omega + · have hl:=K1_charge (b-u) p hL;have hr:=K1_charge u q hR;omega +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma spinCharge_rev (a : Spin) : spinCharge a.rev= -spinCharge a := by + fin_cases a <;> norm_num [spinCharge,Fin.rev] +lemma columnCharge_reflected (n : ℕ) (w : Space n) : + columnCharge (reflectedSites n w)= -columnCharge w := by + change (∑ i : Fin n,spinCharge ((w i.rev).rev))= -∑ i : Fin n,spinCharge (w i) + simp only [spinCharge_rev,Finset.sum_neg_distrib] + exact congrArg Neg.neg (Equiv.sum_comp (Fin.revPerm) (fun i : Fin n=>spinCharge (w i))) +lemma physical_base (n : ℕ) (u : ℝ) (w e : Space n) : + base (physicalFamily n u w e)= + star (coefficient n (homogeneous n) u false false (reflectedSites n w) (reflectedSites n e)) := by + change base (reflected (T n (homogeneous n) u (reflectedSites n w) (reflectedSites n e)))=_ + rw [reflected_base,T_coefficients,base_form] +lemma physical_left (n : ℕ) (u : ℝ) (w e : Space n) : + left (physicalFamily n u w e)= + star (coefficient n (homogeneous n) u false true (reflectedSites n w) (reflectedSites n e)) := by + change left (reflected (T n (homogeneous n) u (reflectedSites n w) (reflectedSites n e)))=_ + rw [reflected_left,T_coefficients,right_form] +lemma physical_right (n : ℕ) (u : ℝ) (w e : Space n) : + right (physicalFamily n u w e)= + star (coefficient n (homogeneous n) u true false (reflectedSites n w) (reflectedSites n e)) := by + change right (reflected (T n (homogeneous n) u (reflectedSites n w) (reflectedSites n e)))=_ + rw [reflected_right,T_coefficients,left_form] +lemma physical_left_shift (n : ℕ) (u : ℝ) : + HasShift (fun w e=>left (physicalFamily n u w e)) 1 := by + intro w e hz + change left (physicalFamily n u w e)≠0 at hz + rw [physical_left,star_ne_zero] at hz + have h:=coefficient_shift n (homogeneous n) u false true (reflectedSites n w) (reflectedSites n e) hz + simp only [Bool.false_eq_true,ite_false,ite_true,columnCharge_reflected] at h + omega +lemma physical_right_shift (n : ℕ) (u : ℝ) : + HasShift (fun w e=>right (physicalFamily n u w e)) (-1) := by + intro w e hz + change right (physicalFamily n u w e)≠0 at hz + rw [physical_right,star_ne_zero] at hz + have h:=coefficient_shift n (homogeneous n) u true false (reflectedSites n w) (reflectedSites n e) hz + simp only [Bool.false_eq_true,ite_false,ite_true,columnCharge_reflected] at h + omega +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def spectralWeights (u : ℝ) : PlanarNormalization.TileWeights := + ⟨Transfer.a u,Transfer.h u,Transfer.v u,Transfer.c u,Transfer.d u⟩ +lemma spectralR_weights (u : ℝ) (hu : Q u≠0) : spectralR u= + PlanarNormalization.sourceR (spectralWeights u) := by + rw [spectralR_normalized u hu,normalizedR_sourceR] + rfl +lemma row_planar_kernel (t : PlanarNormalization.TileWeights) (n : ℕ) + (w e : Fin n→PlanarNormalization.Spin) (a b : PlanarNormalization.Spin) : + row n (fun _=>PlanarNormalization.sourceR t) + (reverseSites n (columnSpinEquiv n w)) (reverseSites n (columnSpinEquiv n e)) + (spinEquiv a) (spinEquiv b)=PlanarNormalization.columnKernelSpin t n b a w e := by + rw [row_eq_matrixPath n (fun _=>PlanarNormalization.sourceR t)] + unfold matrixPath + rw [←(reverseSites n).sum_comp,←(columnSpinEquiv n).sum_comp] + unfold PlanarNormalization.columnKernelSpin + apply Finset.sum_congr rfl + intro v hv + simp only [cons_reverseSites,Fin.rev_last,reverseSites_apply] + have he : Fin.snoc (α:=fun _=>Spin) (columnSpinEquiv n v) (spinEquiv a)= + fun i=>spinEquiv (Fin.snoc (α:=fun _=>PlanarNormalization.Spin) v a i) := by + funext i + refine Fin.lastCases ?_ (fun j=>?_) i <;> simp + simp only [he,Equiv.apply_eq_iff_eq] + split_ifs with h + · rw [←Equiv.prod_comp (Fin.revPerm (n:=n))] + apply Finset.prod_congr rfl + intro j hj + simp only [Fin.revPerm_apply,Fin.rev_rev,Fin.rev_castSucc,block,columnSpinEquiv_apply] + exact (PlanarNormalization.tile_eq_sourceR _ _ _ _ _).symm + · rfl +lemma spectral_row_planar_kernel (u : ℝ) (hu : Q u≠0) (n : ℕ) + (w e : Fin n→PlanarNormalization.Spin) (a b : PlanarNormalization.Spin) : + row n (fun _=>spectralR u) + (reverseSites n (columnSpinEquiv n w)) (reverseSites n (columnSpinEquiv n e)) + (spinEquiv a) (spinEquiv b)=PlanarNormalization.columnKernelSpin (spectralWeights u) n b a w e := by + rw [spectralR_weights u hu] + exact row_planar_kernel _ _ _ _ _ _ +noncomputable def boundaryWeight (u : ℝ) : ℂ := sine (gamma-u)/sine (gamma+u) +lemma K0_planar (u : ℝ) (a b : PlanarNormalization.Spin) : + K0 u (spinEquiv a,spinEquiv b)=PlanarNormalization.K (boundaryWeight u) a b := by + fin_cases a <;> fin_cases b <;> + simp [K0,boundary0,spinEquiv,PlanarNormalization.spinIndex,Fin.rev,spinValue, + PlanarNormalization.K,PlanarNormalization.cup,boundaryWeight,Reflection.phase, + PlanarNormalization.phase,point,mul_comm] +lemma K0_spin_star (u : ℝ) (a b : Spin) : + K0 u (a.rev,b.rev)=star (K0 u (a,b)) := by + fin_cases a <;> fin_cases b <;> + simp [K0,boundary0,Fin.rev,spinValue,Fusion.phase_star,Fusion.sine_star] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma bulkRows_spin_star (n : ℕ) (u : ℝ) (w e : Space n) (a b c d : Spin) : + bulkRows n (homogeneous n) u (flipSites n w) (flipSites n e) (a.rev,b.rev) (c.rev,d.rev)= + star (bulkRows n (homogeneous n) u w e (a,b) (c,d)) := by + simp only [bulkRows,forward,Matrix.sum_apply,Matrix.kronecker, + Matrix.kroneckerMap,Matrix.of_apply,star_sum] + rw [←Equiv.sum_comp (flipSites n)] + apply Finset.sum_congr rfl + intro v hv + change row n (fun _=>spectralR (u+-L/2)) (flipSites n w) (flipSites n v) a.rev c.rev * + row n (fun _=>spectralR ((Reflection.b-u)+-L/2)) (flipSites n v) + (flipSites n e) b.rev d.rev = _ + rw [row_spin_star,row_spin_star,star_mul] + exact mul_comm _ _ +lemma coefficient_base_spin_star (n : ℕ) (u : ℝ) (w e : Space n) : + coefficient n (homogeneous n) u false false (flipSites n w) (flipSites n e)= + star (coefficient n (homogeneous n) u false false w e) := by + simp only [coefficient,Bool.false_eq_true,ite_false,star_sum] + rw [←Equiv.sum_comp (Equiv.prodCongr Fusion.spinFlip Fusion.spinFlip)] + apply Finset.sum_congr rfl + intro p hp + rw [←Equiv.sum_comp (Equiv.prodCongr Fusion.spinFlip Fusion.spinFlip)] + apply Finset.sum_congr rfl + intro q hq + rcases p with ⟨a,b⟩ + rcases q with ⟨c,d⟩ + simp only [Equiv.prodCongr_apply,Prod.map_apply,Fusion.spinFlip_apply,K0_spin_star, + bulkRows_spin_star,star_mul] + ring +lemma physical_base_reversed (n : ℕ) (u : ℝ) (w e : Space n) : + base (physicalFamily n u w e)= + coefficient n (homogeneous n) u false false (reverseSites n w) (reverseSites n e) := by + rw [physical_base] + have h : ∀ x : Space n, reflectedSites n x=flipSites n (reverseSites n x) := fun x=>rfl + rw [h,h,coefficient_base_spin_star,star_star] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators +lemma planarRow_sum {α : Type*} (s : Finset α) (i : ℕ) (ts : List TileWeights) + (f : α→DiluteState) : planarRow i ts (∑ a∈s,f a)=∑ a∈s,planarRow i ts (f a) := by + classical + induction s using Finset.induction_on with + | empty => + simp only [Finset.sum_empty] + change planarRow i ts (fun _=>0)=fun _=>0 + exact planarRow_zero i ts + | @insert a s ha ih => + simp only [Finset.sum_insert ha] + change planarRow i ts (fun xs=>f a xs+(∑ a∈s,f a) xs)=_ + rw [planarRow_add,ih] + rfl +lemma seedAux_sum (k : ℂ) (f : DiluteState) : seedAux k f= + ∑ a : Spin,∑ b : Spin,(fun xs=> K k a b*fixedSeed a (fixedSeed b f) xs) := by + funext xs + cases xs with + | nil => simp [seedAux,fixedSeed] + | cons a xs => cases xs with + | nil => simp [seedAux,fixedSeed] + | cons b xs => simp only [seedAux,Finset.sum_apply,fixedSeed]; simp +lemma fixed_double_columns_distinct (tA tB : TileWeights) (n : ℕ) (f : DiluteState) + (s₁ s₂ z₁ z₂ : Spin) (xs : List Spin) (hx : xs.length=n) : + sourceTwoRows (List.replicate n tA) (List.replicate n tB) + (fixedSeed s₁ (fixedSeed s₂ f)) (z₁::z₂::xs)= + fixedColumn tA n s₁ z₁ (fixedColumn tB n s₂ z₂ f) xs := by + rw [←two_rows_eq (List.replicate n tA) (List.replicate n tB) (by simp) (by simp) _ xs hx z₁ z₂] + rw [show xs++[z₁,z₂]=(xs++[z₁])++[z₂] by simp] + rw [planarRow_suffix 0 _ _ (xs++[z₁]) [z₂] (by simp [hx])] + unfold fixedColumn + apply planarRow_congr_of_length 0 (n+1) _ _ _ _ _ (by simp [hx]) + intro ys hy + cases ys with + | nil => simp at hy + | cons a ys => + simp only [List.cons_append,planarRow_under,fixedSeed] + by_cases ha : a=s₁ + · subst a + simp only [ite_true] + rfl + · simp only [ha,ite_false] + exact congrFun (planarRow_zero 0 (List.replicate n tB)) (ys++[z₂]) +lemma sourceDoubleRow_fixed (tA tB : TileWeights) (n : ℕ) (kR kL : ℂ) + (f : DiluteState) (xs : List Spin) (hx : xs.length=n) : + sourceDoubleRow n (List.replicate n tA) (List.replicate n tB) kR kL f xs= + ∑ a : Spin,∑ b : Spin,∑ c : Spin,∑ d : Spin, + K kL a b*K kR c d*fixedColumn tA n c a (fixedColumn tB n d b f) xs := by + simp only [sourceDoubleRow,hx,ite_true] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + rw [←two_rows_eq (List.replicate n tA) (List.replicate n tB) (by simp) (by simp) _ xs hx a b, + seedAux_sum] + simp only [planarRow_sum,planarRow_smul,Finset.sum_apply,Finset.mul_sum] + apply Finset.sum_congr rfl + intro c hc + apply Finset.sum_congr rfl + intro d hd + rw [mul_assoc,two_rows_eq (List.replicate n tA) (List.replicate n tB) (by simp) (by simp) _ xs hx a b, + fixed_double_columns_distinct _ _ _ _ _ _ _ _ _ hx] +end CriticalHoneycomb.Transfer.PlanarNormalization + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def modelKernel (t : PlanarNormalization.TileWeights) (n : ℕ) + (a b : PlanarNormalization.Spin) : Matrix (Space n) (Space n) ℂ := + fun w e=>PlanarNormalization.columnKernelSpin t n a b + ((columnSpinEquiv n).symm w) ((columnSpinEquiv n).symm e) +lemma modelKernel_mulVec (t : PlanarNormalization.TileWeights) (n : ℕ) + (a b : PlanarNormalization.Spin) (f : PlanarNormalization.DiluteState) : + modelKernel t n a b*ᵥcolumnVector n f= + columnVector n (PlanarNormalization.fixedColumn t n a b f) := by + funext w + obtain ⟨w,rfl⟩:=(columnSpinEquiv n).surjective w + simp only [columnVector,columnSpinEquiv_apply,Equiv.symm_apply_apply] + rw [PlanarNormalization.fixedColumn_eq_kernel] + simp only [Matrix.mulVec,dotProduct] + rw [←(columnSpinEquiv n).sum_comp] + apply Finset.sum_congr rfl + intro e he + simp only [modelKernel,Equiv.symm_apply_apply,columnVector,columnSpinEquiv_apply] +lemma spectral_row_modelKernel (u : ℝ) (hu : Q u≠0) (n : ℕ) + (w e : Space n) (a b : PlanarNormalization.Spin) : + row n (fun _=>spectralR u) (reverseSites n w) (reverseSites n e) (spinEquiv a) (spinEquiv b)= + modelKernel (spectralWeights u) n b a w e := by + obtain ⟨w,rfl⟩:=(columnSpinEquiv n).surjective w + obtain ⟨e,rfl⟩:=(columnSpinEquiv n).surjective e + rw [spectral_row_planar_kernel u hu] + simp only [modelKernel,Equiv.symm_apply_apply] +lemma bulkRows_modelKernel (n : ℕ) (u : ℝ) + (h1 : Q (u-L/2)≠0) (h2 : Q (b-u-L/2)≠0) (w e : Space n) + (a b' c d : PlanarNormalization.Spin) : + bulkRows n (homogeneous n) u (reverseSites n w) (reverseSites n e) + (spinEquiv a,spinEquiv b') (spinEquiv c,spinEquiv d)= + (modelKernel (spectralWeights (u-L/2)) n c a* + modelKernel (spectralWeights (b-u-L/2)) n d b') w e := by + simp only [bulkRows,forward,Matrix.sum_apply,Matrix.kronecker, + Matrix.kroneckerMap,Matrix.of_apply,Matrix.mul_apply] + rw [←Equiv.sum_comp (reverseSites n)] + apply Finset.sum_congr rfl + intro v hv + have hs : ∀ t : ℝ,exactSites n (homogeneous n) t=fun _=>spectralR (t-L/2) := by + intro t + funext i + change spectralR (t+-L/2)=spectralR (t-L/2) + congr 1 + ring + rw [hs,hs,spectral_row_modelKernel _ h1,spectral_row_modelKernel _ h2] +lemma physical_base_matrix (n : ℕ) (u : ℝ) + (h1 : Q (u-L/2)≠0) (h2 : Q (b-u-L/2)≠0) : + (physicalFamily n u).map jetBaseHom= + ∑ a : PlanarNormalization.Spin,∑ b' : PlanarNormalization.Spin, + ∑ c : PlanarNormalization.Spin,∑ d : PlanarNormalization.Spin, + (PlanarNormalization.K (boundaryWeight (b-u)) a b'* + PlanarNormalization.K (boundaryWeight u) c d) • + (modelKernel (spectralWeights (u-L/2)) n c a* + modelKernel (spectralWeights (b-u-L/2)) n d b') := by + funext w e + change base (physicalFamily n u w e)=_ + simp only [physical_base_reversed,coefficient,Bool.false_eq_true,ite_false, + Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul,Fintype.sum_prod_type] + simp only [←Equiv.sum_comp spinEquiv] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b' hb + apply Finset.sum_congr rfl + intro c hc + apply Finset.sum_congr rfl + intro d hd + rw [K0_planar,K0_planar,bulkRows_modelKernel n u h1 h2] + ring +lemma physical_base_source (n : ℕ) (u : ℝ) + (h1 : Q (u-L/2)≠0) (h2 : Q (b-u-L/2)≠0) + (f : PlanarNormalization.DiluteState) : + (physicalFamily n u).map jetBaseHom*ᵥcolumnVector n f= + columnVector n (PlanarNormalization.sourceDoubleRow n + (List.replicate n (spectralWeights (u-L/2))) + (List.replicate n (spectralWeights (b-u-L/2))) + (boundaryWeight u) (boundaryWeight (b-u)) f) := by + rw [physical_base_matrix n u h1 h2] + simp only [Matrix.sum_mulVec,Matrix.smul_mulVec,←Matrix.mulVec_mulVec,modelKernel_mulVec] + funext w + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,columnVector, + PlanarNormalization.sourceDoubleRow_fixed _ _ _ _ _ _ _ (List.length_ofFn)] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet Filter Topology +open scoped Matrix +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma commute_archProjection (W : ℕ) (M : Matrix (Column (W+1)) (Column (W+1)) ℂ) + (hM : Commute M (physicalDoubleMatrix (W+1))) : Commute M (archProjection W) := by + have hL := (tendsto_const_nhds (x:=M)).mul (physical_double_rank_one W) + have hR := (physical_double_rank_one W).mul (tendsto_const_nhds (x:=M)) + apply tendsto_nhds_unique hL + exact hR.congr (fun n=>(hM.pow_right n).eq.symm) +lemma base_commute (W : ℕ) (M : Matrix (Column (W+1)) (Column (W+1)) Jet) + (hM : Commute (markedDoubleMatrix (W+1)) M) : + Commute (M.map jetBaseHom) (physicalDoubleMatrix (W+1)) := by + have h:=congrArg jetBaseHom.mapMatrix hM.symm.eq + change Commute (jetBaseHom.mapMatrix M) (physicalDoubleMatrix (W+1)) + change _*_= _*_ + simpa only [map_mul,show jetBaseHom.mapMatrix (markedDoubleMatrix (W+1))=physicalDoubleMatrix (W+1) from marked_base (W+1)] using h +lemma base_common_line (W : ℕ) (M : Matrix (Column (W+1)) (Column (W+1)) Jet) + (hM : Commute (markedDoubleMatrix (W+1)) M) : + (M.map jetBaseHom)*ᵥarchColumn W=base (commonScalar W M)•archColumn W := by + have h:=commuting_common_line W M hM + funext s + have h':=congrArg base (congrFun h s) + simpa only [Matrix.mulVec,dotProduct,base_sum,base_mul,markedEigenvector,base_form, + Matrix.map_apply,jetBaseHom_apply,Pi.smul_apply,smul_eq_mul] using h' +lemma base_common_dual (W : ℕ) (M : Matrix (Column (W+1)) (Column (W+1)) Jet) + (hM : Commute (markedDoubleMatrix (W+1)) M) (v : Column (W+1)→ℂ) : + archDual W ((M.map jetBaseHom)*ᵥv)=base (commonScalar W M)*archDual W v := by + have hp:=commute_archProjection W (M.map jetBaseHom) (base_commute W M hM) + have h:=congrArg (fun A=>A*ᵥv) hp.eq + rw [←Matrix.mulVec_mulVec,←Matrix.mulVec_mulVec,projection_mulVec,Matrix.mulVec_smul, + base_common_line W M hM,projection_mulVec] at h + have h':=congrFun h (fun _=>1) + simpa only [Pi.smul_apply,smul_eq_mul,archColumn_vacuum,mul_one,one_mul,archDual,mul_comm] using h'.symm +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.PlanarNormalization +lemma vacuumIterate_span (t : TileWeights) (n m : ℕ) : + PlanarSpan n (((vacuumColumn t n)^[m]) (vacuum n)) := by + induction m with + | zero => exact vacuum_span n + | succ m ih => + rw [Function.iterate_succ_apply'] + exact vacuumColumn_span t ih +end CriticalHoneycomb.Transfer.PlanarNormalization +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization Filter Topology +open scoped Matrix BigOperators +lemma columnVector_at_vacuum (n : ℕ) (f : DiluteState) : + columnVector n f (fun _=>1)=f (List.replicate n none) := by + simp [columnVector,spinEquiv] +lemma columnVector_physical_iterate (n m : ℕ) (w : Column n) : + columnVector n (((vacuumColumn physicalWeights n)^[m]) (vacuum n)) w= + (rowTransfer n^m) w (fun _=>1) := by + have h:=congrFun (column_pow_mulVec n m (vacuum n)) w + rw [show columnVector n (vacuum n)=fun east=>if east=(fun _=>1) then 1 else 0 from vector_vacuum n] at h + simpa only [Matrix.mulVec,dotProduct,mul_ite,mul_one,mul_zero, + Finset.sum_ite_eq',Finset.mem_univ,ite_true,rowTransfer] using h.symm +lemma physical_iterate_limit (W : ℕ) : + Tendsto (fun m=>columnVector (W+1) + (((vacuumColumn physicalWeights (W+1))^[m]) (vacuum (W+1)))) + atTop (𝓝 (archColumn W)) := by + apply tendsto_pi_nhds.mpr + intro w + simpa only [columnVector_physical_iterate] using archColumn_limit W w +end CriticalHoneycomb.Transfer.RasterGrid +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid PlanarNormalization Filter Topology +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma physical_base_on_vacuumIterate (n m : ℕ) (u : ℝ) + (h1 : Q (u-L/2)≠0) (h2 : Q (b-u-L/2)≠0) : + ((physicalFamily n u).map jetBaseHom*ᵥcolumnVector n + (((vacuumColumn physicalWeights n)^[m]) (vacuum n))) (fun _=>1)=1 := by + rw [physical_base_source n u h1 h2,columnVector_at_vacuum, + sourceDoubleRow_vacuum _ _ (by simp) (by simp) _ _ + (vacuumIterate_span physicalWeights n m)] + exact vacuumRectangle physicalWeights n m +lemma physical_base_archColumn (W : ℕ) (u : ℝ) + (h1 : Q (u-L/2)≠0) (h2 : Q (b-u-L/2)≠0) : + ((physicalFamily (W+1) u).map jetBaseHom*ᵥarchColumn W) (fun _=>1)=1 := by + have hc : Continuous (fun v : Column (W+1)→ℂ => + (physicalFamily (W+1) u).map jetBaseHom*ᵥv) := + continuous_const.matrix_mulVec continuous_id + have hlim := hc.continuousAt.tendsto.comp (physical_iterate_limit W) + have hv := (tendsto_pi_nhds.mp hlim) (fun _=>1) + apply tendsto_nhds_unique hv + exact tendsto_const_nhds.congr (fun m=>(physical_base_on_vacuumIterate (W+1) m u h1 h2).symm) +theorem physicalScalar_base (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) u) : + base (physicalScalar W u)=1 := by + have hM : Commute (markedDoubleMatrix (W+1)) (physicalFamily (W+1) u) := by + rw [←physicalFamily_at_gamma] + exact physicalFamily_commute _ gamma u (homogeneous_nonsingular _) hu + have h := congrFun (base_common_line W (physicalFamily (W+1) u) hM) (fun _=>1) + have h1 : Q (u-L/2)≠0 := by simpa only [homogeneous,sub_eq_add_neg,neg_div] using (hu.2.2 ⟨0,by omega⟩).1 + have h2 : Q (b-u-L/2)≠0 := by simpa only [homogeneous,sub_eq_add_neg,neg_div] using (hu.2.2 ⟨0,by omega⟩).2 + rw [physical_base_archColumn W u h1 h2] at h + simpa only [Pi.smul_apply,smul_eq_mul,archColumn_vacuum,mul_one,physicalScalar] using h.symm +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet +open scoped Matrix +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma common_scalar_left_zero (W : ℕ) (M : Matrix (Column (W+1)) (Column (W+1)) Jet) + (hM : Commute (markedDoubleMatrix (W+1)) M) + {q : ℤ} (hshift : HasShift (fun w e=>left (M w e)) q) (hq : q≠0) : + left (commonScalar W M)=0 := by + have h:=commuting_common_line W M hM + have he : (M.map jetBaseHom)*ᵥeigenLeft W+(fun w e=>left (M w e))*ᵥarchColumn W= + base (commonScalar W M)•eigenLeft W+left (commonScalar W M)•archColumn W := by + funext s + have hs:=congrArg left (congrFun h s) + simpa only [Matrix.mulVec,dotProduct,left_sum,left_mul,markedEigenvector,base_form,left_form, + Matrix.map_apply,jetBaseHom_apply,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Finset.sum_add_distrib] using hs + have hz:=projection_shift_zero hshift hq + have hd:=congrArg (archDual W) he + change archDual W _=0 at hz + rw [archDual_add,archDual_add,base_common_dual W M hM,archDual_smul,archDual_smul,archDual_A, + hz,mul_one,add_zero] at hd + exact (add_eq_left.mp hd.symm) +lemma common_scalar_right_zero (W : ℕ) (M : Matrix (Column (W+1)) (Column (W+1)) Jet) + (hM : Commute (markedDoubleMatrix (W+1)) M) + {q : ℤ} (hshift : HasShift (fun w e=>right (M w e)) q) (hq : q≠0) : + right (commonScalar W M)=0 := by + have h:=commuting_common_line W M hM + have he : (M.map jetBaseHom)*ᵥeigenRight W+(fun w e=>right (M w e))*ᵥarchColumn W= + base (commonScalar W M)•eigenRight W+right (commonScalar W M)•archColumn W := by + funext s + have hs:=congrArg right (congrFun h s) + simpa only [Matrix.mulVec,dotProduct,right_sum,right_mul,markedEigenvector,base_form,right_form, + Matrix.map_apply,jetBaseHom_apply,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Finset.sum_add_distrib] using hs + have hz:=projection_shift_zero hshift hq + have hd:=congrArg (archDual W) he + change archDual W _=0 at hz + rw [archDual_add,archDual_add,base_common_dual W M hM,archDual_smul,archDual_smul,archDual_A, + hz,mul_one,add_zero] at hd + exact (add_eq_left.mp hd.symm) +end CriticalHoneycomb.Transfer.RasterGrid +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +lemma physicalScalar_singles (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) u) : + left (physicalScalar W u)=0 ∧ right (physicalScalar W u)=0 := by + have hc : Commute (markedDoubleMatrix (W+1)) (physicalFamily (W+1) u) := by + rw [←physicalFamily_at_gamma] + exact physicalFamily_commute (W+1) gamma u (homogeneous_nonsingular _) hu + exact ⟨common_scalar_left_zero W _ hc (physical_left_shift (W+1) u) (by norm_num), + common_scalar_right_zero W _ hc (physical_right_shift (W+1) u) (by norm_num)⟩ +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +local instance : SMulCommClass Jet Jet Jet where + smul_comm a b c := by simp only [smul_eq_mul];ring +lemma physicalScalar_form (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) u) : + physicalScalar W u=form 1 0 0 (both (physicalScalar W u)) := by + apply jet_ext + · simpa only [base_form] using physicalScalar_base W u hu + · simpa only [left_form] using (physicalScalar_singles W u hu).1 + · simpa only [right_form] using (physicalScalar_singles W u hu).2 + · simp only [both_form] +lemma sine_ne_zero_interval {x : ℝ} (h0 : 0sine_ne_zero_interval h1 h2 + refine ⟨?_,?_,fun i=>⟨?_,?_⟩⟩ + · apply hsin <;> simp only [gamma] <;> linarith + · apply hsin <;> simp only [gamma,b] <;> linarith + · apply mul_ne_zero <;> apply hsin <;> simp only [homogeneous,L,b] <;> linarith + · apply mul_ne_zero <;> apply hsin <;> simp only [homogeneous,L,b] <;> linarith +lemma physicalFamily_node_fusion (n : ℕ) (i : Fin n) (t : ℝ) + (ht : t=L-homogeneous n i ∨ t=L+homogeneous n i) + (hm : Nonsingular n (homogeneous n) (t-L)) + (hp : Nonsingular n (homogeneous n) (t+L)) + (hc : Nonsingular n (homogeneous n) t) : + physicalFamily n (t-L)*physicalFamily n (t+L)=physicalFamily n t := by + have h:=congrArg (reorient n) (source_global_spectral_fusion n (homogeneous n) i t ht hm hp hc) + change reorient n (T n (homogeneous n) (t-L))*reorient n (T n (homogeneous n) (t+L))= + reorient n (T n (homogeneous n) t) + simpa only [reorient_mul] using h +lemma commonScalar_mul_line (W : ℕ) (M N : Matrix (Column (W+1)) (Column (W+1)) Jet) + (hN : N*ᵥmarkedEigenvector W=commonScalar W N•markedEigenvector W) : + commonScalar W (M*N)=commonScalar W M*commonScalar W N := by + change normalizedDual W ⬝ᵥ ((M*N)*ᵥmarkedEigenvector W)=_ + rw [←Matrix.mulVec_mulVec,hN,Matrix.mulVec_smul,dotProduct_smul] + change commonScalar W N*commonScalar W M=commonScalar W M*commonScalar W N + exact mul_comm (commonScalar W N) (commonScalar W M) +lemma both_mul_normalized (a c : Jet) (ha : base a=1) (hc : base c=1) + (hl : left a=0) (hr : right a=0) : both (a*c)=both a+both c := by + rw [both_mul,ha,hc,hl,hr] + simp only [one_mul,mul_one,zero_mul,add_zero] + exact add_comm _ _ +lemma physicalScalar_node_fusion (W : ℕ) (i : Fin (W+1)) (t : ℝ) + (ht : t=L-homogeneous (W+1) i ∨ t=L+homogeneous (W+1) i) + (hm : Nonsingular (W+1) (homogeneous (W+1)) (t-L)) + (hp : Nonsingular (W+1) (homogeneous (W+1)) (t+L)) + (hc : Nonsingular (W+1) (homogeneous (W+1)) t) : + both (physicalScalar W (t-L))+both (physicalScalar W (t+L))= + both (physicalScalar W t) := by + have h:=congrArg (commonScalar W) (physicalFamily_node_fusion (W+1) i t ht hm hp hc) + rw [commonScalar_mul_line W _ _ (physical_common_line W (t+L) hp)] at h + change physicalScalar W (t-L)*physicalScalar W (t+L)=physicalScalar W t at h + calc + _=both (physicalScalar W (t-L)*physicalScalar W (t+L)) := + (both_mul_normalized _ _ (physicalScalar_base W (t-L) hm) + (physicalScalar_base W (t+L) hp) (physicalScalar_singles W (t-L) hm).1 + (physicalScalar_singles W (t-L) hm).2).symm + _=_ := congrArg both h +noncomputable def physicalP (W : ℕ) (u : ℝ) : ℂ := both (physicalScalar W (gamma+u)) +lemma physicalP_reflection (W : ℕ) {u : ℝ} + (hu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+u)) : + physicalP W (-u)=physicalP W u := by + unfold physicalP + have h : gamma+-u=b-(gamma+u) := by simp only [gamma,b];ring + rw [h,physicalScalar_reflection W _ hu] +lemma physicalP_mass (W : ℕ) : + physicalP W 0=2*((∑' γ : StrictBridge (W+1),kappa^γ.val.length):ℝ) := by + simpa only [physicalP,add_zero] using physicalScalar_mass W +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet +open scoped Matrix BigOperators +lemma K0_at_zero : K0 0=cap := by + have hs : sine gamma≠0 := sine_ne_zero_interval (by unfold gamma;positivity) + (by unfold gamma;linarith [Real.pi_pos]) + funext ⟨a,c⟩ + fin_cases a <;> fin_cases c <;> + simp [K0,boundary0,cap,Fin.rev,hs,spinValue] +lemma K1_at_zero : K1 0=0 := by + funext p + simp [K1,boundary1,sine] +lemma K1_at_halfpi : K1 (Real.pi/2)=0 := by + have hs : sine (2*(Real.pi/2))=0 := by rw [show 2*(Real.pi/2)=Real.pi by ring];simp [sine] + funext p + simp only [K1,boundary1,hs] + split_ifs <;> simp +lemma boundary_ratio_halfpi : sine (gamma-Real.pi/2)/sine (gamma+Real.pi/2)= -1 := by + have hn : sine (gamma+Real.pi/2)≠0 := sine_ne_zero_interval + (by unfold gamma;positivity) (by unfold gamma;linarith [Real.pi_pos]) + have he : sine (gamma-Real.pi/2)= -sine (gamma+Real.pi/2) := by + simpa only [show gamma-Real.pi/2+Real.pi=gamma+Real.pi/2 by ring,neg_neg] using + (congrArg Neg.neg (sine_add_pi (gamma-Real.pi/2))).symm + rw [he,neg_div,div_self hn] +lemma K0_at_halfpi : K0 (Real.pi/2)=fun p=> -(parity p.1*cap p) := by + funext ⟨a,c⟩ + fin_cases a <;> fin_cases c <;> + simp [K0,boundary0,cap,parity,Fin.rev,spinValue,boundary_ratio_halfpi] +lemma phase_cap_cancel : Reflection.phase*Reflection.phase+ + Reflection.phase⁻¹*Reflection.phase⁻¹=0 := by + rw [←pow_two,←pow_two,inv_pow,phase_eq,←pow_mul,show 4*2=8 by rfl,root_eight] + simp +lemma K0_close_cap (u : ℝ) : (∑ p,K0 u p*cap p)=1 := by + rw [sum_cap] + simp only [Fin.sum_univ_succ,K0,boundary0,Fin.rev_rev,spinValue] + norm_num [Fin.rev] + linear_combination (sine (gamma-u)/sine (gamma+u))*phase_cap_cancel +lemma K1_close_cap (u : ℝ) : (∑ p,K1 u p*cap p)=0 := by + rw [sum_cap] + simp [Fin.sum_univ_succ,K1,boundary1,Fin.rev_rev,spinValue] +lemma K0_close_twisted_cap (u : ℝ) : (∑ p,K0 u p* -(parity p.1*cap p))=1 := by + have he : (∑ p,K0 u p* -(parity p.1*cap p))= + ∑ a : Spin,K0 u (a,a.rev)* -(parity a*Reflection.phase^(spinValue a)) := by + rw [Fintype.sum_prod_type] + simp [cap,mul_ite] + rw [he] + simp only [Fin.sum_univ_succ,K0,boundary0,Fin.rev_rev,parity,spinValue] + norm_num [Fin.rev] + linear_combination -(sine (gamma-u)/sine (gamma+u))*phase_cap_cancel +lemma K1_close_twisted_cap (u : ℝ) : (∑ p,K1 u p* -(parity p.1*cap p))=0 := by + rw [Fintype.sum_prod_type] + simp [cap,mul_ite,Fin.sum_univ_succ,K1,boundary1,parity,spinValue,Fin.rev] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma forward_cap_all (n : ℕ) (A B : Fin n→Local) (v : Pair→ℂ) + (h : ∀ i s t,localForward (A i) (B i) s t*ᵥv=if s=t then v else 0) + (s t : Space n) : forward n A B s t*ᵥv=if s=t then v else 0 := by + induction n with + | zero => simp [forward,row,Subsingleton.elim s t] + | succ n ih => + rw [forward_succ,←Matrix.mulVec_mulVec,ih (Fin.tail A) (Fin.tail B) (fun i=>h i.succ)] + have he : s=t ↔ s 0=t 0 ∧ Fin.tail s=Fin.tail t := by + constructor + · intro h;subst t;exact ⟨rfl,rfl⟩ + · rintro ⟨hh,ht⟩ + rw [←Fin.cons_self_tail s,←Fin.cons_self_tail t,hh,ht] + by_cases ht : Fin.tail s=Fin.tail t + · rw [ite_eq_left ht,h 0] + simp only [he,ht,and_true] + · rw [ite_eq_right ht,Matrix.mulVec_zero] + simp only [he,ht,and_false,ite_false] +lemma closed_at_cap (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) (v : Pair→ℂ) + (hr : K1 u=0) (h0 : K0 u=v) + (hbulk : ∀ s t,bulkRows N ξ u s t*ᵥv=if s=t then v else 0) + (hc0 : ∑ p,K0 (b-u) p*v p=1) (hc1 : ∑ p,K1 (b-u) p*v p=0) : + T N ξ u=1 := by + funext s t + rw [T_coefficients] + have coeff (i : Bool) : coefficient N ξ u i false s t=if s=t then if i then 0 else 1 else 0 := by + unfold coefficient + simp only [Bool.false_eq_true,ite_false] + have he : (∑ p,∑ q,(if i=true then K1 (b-u) p else K0 (b-u) p)* + bulkRows N ξ u s t p q*K0 u q)= + ∑ p,(if i=true then K1 (b-u) p else K0 (b-u) p)*(bulkRows N ξ u s t*ᵥv) p := by + simp only [Matrix.mulVec,dotProduct,Finset.mul_sum,h0,mul_assoc] + rw [he,hbulk] + by_cases hs : s=t + · simp only [ite_eq_left hs] + cases i + · simpa only [Bool.false_eq_true,ite_false] using hc0 + · simpa only [ite_true] using hc1 + · simp [hs] + have coeffR (i : Bool) : coefficient N ξ u i true s t=0 := by + simp [coefficient,hr] + apply jet_ext <;> simp only [base_form,left_form,right_form,both_form,coeff,coeffR] + all_goals { by_cases hs : s=t <;> simp [Matrix.one_apply,hs,base,left,right,both] } +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma Q_endpoint_ne_zero : Q (-L/2)≠0 ∧ Q (-(-L/2))≠0 ∧ + Q (-L/2-Real.pi/2)≠0 ∧ Q (-(-L/2-Real.pi/2))≠0 := by + have hp:=Real.pi_pos + have hs : ∀ x : ℝ, 0sine_ne_zero_interval h0 h1 + have hn : ∀ x : ℝ, -Real.pi first | apply hs <;> simp only [L,b] <;> linarith | apply hn <;> simp only [L,b] <;> linarith } +lemma homogeneous_T_zero (n : ℕ) : T n (homogeneous n) 0=1 := by + apply closed_at_cap n (homogeneous n) 0 cap K1_at_zero K0_at_zero + · intro s t + apply forward_cap_all + intro i a c + simpa only [exactSites,zero_add,sub_zero,homogeneous] using + localForward_cap (-L/2) Q_endpoint_ne_zero.1 Q_endpoint_ne_zero.2.1 a c + · exact K0_close_cap _ + · exact K1_close_cap _ +lemma homogeneous_T_halfpi (n : ℕ) : T n (homogeneous n) (Real.pi/2)=1 := by + apply closed_at_cap n (homogeneous n) (Real.pi/2) (fun p=> -(parity p.1*cap p)) + K1_at_halfpi K0_at_halfpi + · intro s t + apply forward_cap_all + intro i a c + have h:=congrArg Neg.neg (localForward_period_cap (-L/2-Real.pi/2) + Q_endpoint_ne_zero.2.2.1 Q_endpoint_ne_zero.2.2.2 a c) + rw [←Matrix.mulVec_neg] at h + simpa only [exactSites,homogeneous, + show -L/2-Real.pi/2+Real.pi=Real.pi/2+-L/2 by ring, + show b+(-L/2-Real.pi/2)=b-Real.pi/2+-L/2 by ring,neg_ite,neg_zero,Pi.neg_def] using h + · exact K0_close_twisted_cap _ + · exact K1_close_twisted_cap _ +lemma physicalFamily_of_T_one (n : ℕ) (u : ℝ) (h : T n (homogeneous n) u=1) : + physicalFamily n u=1 := by + unfold physicalFamily + rw [h,Matrix.submatrix_one_equiv,Matrix.map_one] <;> simp +lemma commonScalar_one (W : ℕ) : commonScalar W 1=1 := by + unfold commonScalar + rw [Matrix.one_mulVec,normalized_pair] +lemma physicalP_endpoint_zeros (W : ℕ) : + physicalP W (3*L/2)=0 ∧ physicalP W (5*L/2)=0 := by + have hg : gamma+3*L/2=b := by simp only [gamma,b,L];ring + have hh : gamma+5*L/2=Real.pi/2 := by simp only [gamma,L];ring + constructor + · unfold physicalP + rw [hg,show b=b-0 by ring,physicalScalar_reflection W 0 + (homogeneous_nonsingular_interval _ (by unfold gamma;linarith [Real.pi_pos]) + (by simp only [b,gamma];linarith [Real.pi_pos]))] + unfold physicalScalar + rw [physicalFamily_of_T_one _ _ (homogeneous_T_zero _),commonScalar_one] + rfl + · unfold physicalP physicalScalar + rw [hh,physicalFamily_of_T_one _ _ (homogeneous_T_halfpi _),commonScalar_one] + rfl +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ConfluentInterpolation.lean b/lean/OAI/Combinatorics/HoneycombChords/ConfluentInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d907b78d5127ff41a0a573d76db9448b899af60d --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ConfluentInterpolation.lean @@ -0,0 +1,606 @@ +import OAI.Combinatorics.HoneycombChords.LaurentTransfer +import OAI.Combinatorics.HoneycombChords.InterpolationDefinitions +import OAI.Combinatorics.HoneycombChords.ConfluentZeros + +namespace OAI + +/-! Confluent spectral zeros and physical rational interpolation. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +section +open scoped ContDiff Matrix.Norms.Elementwise +namespace CriticalHoneycomb.Transfer.Reflection +@[fun_prop] lemma contDiff_sine (m : ℕ∞ω) : ContDiff ℝ m sine := by + unfold sine + exact Complex.ofRealCLM.contDiff.comp Real.contDiff_sin +lemma contDiff_Q (m : ℕ∞ω) : ContDiff ℝ m Q := by + unfold Q + exact ((contDiff_sine m).comp (contDiff_const.add contDiff_id)).mul + ((contDiff_sine m).comp (contDiff_const.add contDiff_id)) +lemma contDiff_bulkNumerator (m : ℕ∞ω) : ContDiff ℝ m bulkNumerator := by + apply contDiff_pi.2; intro p + apply contDiff_pi.2; intro q + unfold bulkNumerator + split <;> (try simp only [coeffA,coeffH,coeffV,coeffC,coeffD,Q,S]) <;> fun_prop +lemma contDiffAt_spectralR (m : ℕ∞ω) (u : ℝ) (hu : Q u≠0) : + ContDiffAt ℝ m spectralR u := by + exact ((contDiff_Q m).contDiffAt.inv hu).smul (contDiff_bulkNumerator m).contDiffAt +lemma contDiffAt_boundary0 (m : ℕ∞ω) (t : ℝ) (ht : sine (gamma+t)≠0) : + ContDiffAt ℝ m boundary0 t := by + apply contDiffAt_pi.2; intro p + apply contDiffAt_pi.2; intro q + unfold boundary0 + split_ifs + · exact contDiffAt_const + · simpa only [div_eq_mul_inv,Function.comp_apply,id_eq,Pi.inv_apply] using + (((contDiff_sine m).comp (contDiff_const.sub contDiff_id)).contDiffAt).mul + ((((contDiff_sine m).comp (contDiff_const.add contDiff_id)).contDiffAt).inv ht) + · exact contDiffAt_const +lemma contDiffAt_boundary1 (m : ℕ∞ω) (t : ℝ) (ht : sine (gamma+t)≠0) : + ContDiffAt ℝ m boundary1 t := by + have h : ContDiffAt ℝ m (fun u => sine (2*u)/sine (gamma+u)) t := + by simpa only [div_eq_mul_inv,Function.comp_apply,id_eq,Pi.inv_apply] using + (((contDiff_sine m).comp (contDiff_const.mul contDiff_id)).contDiffAt).mul + ((((contDiff_sine m).comp (contDiff_const.add contDiff_id)).contDiffAt).inv ht) + apply contDiffAt_pi.2; intro p + apply contDiffAt_pi.2; intro q + unfold boundary1 + split_ifs + · exact h + · exact contDiffAt_const.mul h + · exact contDiffAt_const +end CriticalHoneycomb.Transfer.Reflection +namespace CriticalHoneycomb.Transfer.RowExchange +open Reflection +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] +lemma contDiffAt_matrix_entry {a c k : Type*} [Fintype a] [Fintype c] + [NormedAddCommGroup k] [NormedSpace ℝ k] + {m : ℕ∞ω} {f : E→Matrix a c k} {u : E} (h : ContDiffAt ℝ m f u) (i : a) (j : c) : + ContDiffAt ℝ m (fun x=>f x i j) u := contDiffAt_pi.1 (contDiffAt_pi.1 h i) j +lemma contDiffAt_row (m : ℕ∞ω) (n : ℕ) (A : E→Fin n→Local) (u : E) + (hA : ∀ i,ContDiffAt ℝ m (fun x=>A x i) u) (s t : Space n) : + ContDiffAt ℝ m (fun x=>row n (A x) s t) u := by + induction n with + | zero => exact contDiffAt_const + | succ n ih => + apply contDiffAt_pi.2; intro i + apply contDiffAt_pi.2; intro j + change ContDiffAt ℝ m (fun x=>∑ k,block (A x 0) (s 0) (t 0) i k* + row n (Fin.tail (A x)) (Fin.tail s) (Fin.tail t) k j) u + apply ContDiffAt.sum + intro k hk + exact (contDiffAt_matrix_entry (hA 0) (i,s 0) (k,t 0)).mul + (contDiffAt_matrix_entry (ih (fun x=>Fin.tail (A x)) (fun i=>hA i.succ) _ _) k j) +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +open scoped ContDiff +namespace CriticalHoneycomb.BoundaryJet +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] +@[simp] lemma base_sub (a b : Jet) : base (a-b)=base a-base b := rfl +@[simp] lemma left_sub (a b : Jet) : left (a-b)=left a-left b := rfl +@[simp] lemma right_sub (a b : Jet) : right (a-b)=right a-right b := rfl +@[simp] lemma both_sub (a b : Jet) : both (a-b)=both a-both b := rfl + +def SmoothJetAt (m : ℕ∞ω) (f : E→Jet) (x : E) : Prop := + ContDiffAt ℝ m (fun y=>base (f y)) x ∧ + ContDiffAt ℝ m (fun y=>left (f y)) x ∧ + ContDiffAt ℝ m (fun y=>right (f y)) x ∧ + ContDiffAt ℝ m (fun y=>both (f y)) x +lemma SmoothJetAt.const (m : ℕ∞ω) (a : Jet) (x : E) : SmoothJetAt m (fun _=>a) x := + ⟨contDiffAt_const,contDiffAt_const,contDiffAt_const,contDiffAt_const⟩ +lemma SmoothJetAt.add {m : ℕ∞ω} {f g : E→Jet} {x : E} + (hf : SmoothJetAt m f x) (hg : SmoothJetAt m g x) : + SmoothJetAt m (fun y=>f y+g y) x := by + refine ⟨?_,?_,?_,?_⟩ <;> simp only [base_add,left_add,right_add,both_add] + · exact hf.1.add hg.1 + · exact hf.2.1.add hg.2.1 + · exact hf.2.2.1.add hg.2.2.1 + · exact hf.2.2.2.add hg.2.2.2 +lemma SmoothJetAt.sub {m : ℕ∞ω} {f g : E→Jet} {x : E} + (hf : SmoothJetAt m f x) (hg : SmoothJetAt m g x) : + SmoothJetAt m (fun y=>f y-g y) x := by + refine ⟨?_,?_,?_,?_⟩ <;> simp only [base_sub,left_sub,right_sub,both_sub] + · exact hf.1.sub hg.1 + · exact hf.2.1.sub hg.2.1 + · exact hf.2.2.1.sub hg.2.2.1 + · exact hf.2.2.2.sub hg.2.2.2 +lemma SmoothJetAt.mul {m : ℕ∞ω} {f g : E→Jet} {x : E} + (hf : SmoothJetAt m f x) (hg : SmoothJetAt m g x) : + SmoothJetAt m (fun y=>(f y*g y : Jet)) x := by + refine ⟨?_,?_,?_,?_⟩ <;> simp only [base_mul,left_mul,right_mul,both_mul] + · exact hf.1.mul hg.1 + · exact (hf.1.mul hg.2.1).add (hf.2.1.mul hg.1) + · exact (hf.1.mul hg.2.2.1).add (hf.2.2.1.mul hg.1) + · exact (((hf.1.mul hg.2.2.2).add (hf.2.1.mul hg.2.2.1)).add + (hf.2.2.1.mul hg.2.1)).add (hf.2.2.2.mul hg.1) +lemma SmoothJetAt.sum {ι : Type*} (s : Finset ι) {m : ℕ∞ω} {f : ι→E→Jet} {x : E} + (hf : ∀ i∈s,SmoothJetAt m (f i) x) : SmoothJetAt m (fun y=>∑ i∈s,f i y) x := by + refine ⟨?_,?_,?_,?_⟩ <;> simp only [base_sum,left_sum,right_sum,both_sum] + · exact ContDiffAt.sum (fun i hi=>(hf i hi).1) + · exact ContDiffAt.sum (fun i hi=>(hf i hi).2.1) + · exact ContDiffAt.sum (fun i hi=>(hf i hi).2.2.1) + · exact ContDiffAt.sum (fun i hi=>(hf i hi).2.2.2) +lemma SmoothJetAt.C {m : ℕ∞ω} {f : E→ℂ} {x : E} (hf : ContDiffAt ℝ m f x) : + SmoothJetAt m (fun y=>C (f y)) x := by + exact ⟨by simpa only [base_C] using hf,by simpa only [left_C] using contDiffAt_const, + by simpa only [right_C] using contDiffAt_const,by simpa only [both_C] using contDiffAt_const⟩ +lemma SmoothJetAt.reflect {m : ℕ∞ω} {f : E→Jet} {x : E} (hf : SmoothJetAt m f x) : + SmoothJetAt m (fun y=>reflectJet (f y)) x := by + refine ⟨?_,?_,?_,?_⟩ <;> + simp only [reflectJet_apply,reflected_base,reflected_left,reflected_right,reflected_both] + · exact Complex.conjCLE.contDiff.contDiffAt.comp x hf.1 + · exact Complex.conjCLE.contDiff.contDiffAt.comp x hf.2.2.1 + · exact Complex.conjCLE.contDiff.contDiffAt.comp x hf.2.1 + · exact Complex.conjCLE.contDiff.contDiffAt.comp x hf.2.2.2 +end CriticalHoneycomb.BoundaryJet + +end + +section +open scoped ContDiff Matrix.Norms.Elementwise +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] +lemma contDiffAt_row_curve (m : ℕ∞ω) (N : ℕ) (Ξ : E→Fin N→ℝ) (f : E→ℝ) (x : E) + (hΞ : ∀ i,ContDiffAt ℝ m (fun y=>Ξ y i) x) (hf : ContDiffAt ℝ m f x) + (hQ : ∀ i,Q (f x+Ξ x i)≠0) (s t : Space N) : + ContDiffAt ℝ m (fun y=>row N (exactSites N (Ξ y) (f y)) s t) x := by + apply contDiffAt_row + intro i + exact (contDiffAt_spectralR _ _ (hQ i)).comp x (hf.add (hΞ i)) +lemma contDiffAt_bulkRows_curve (m : ℕ∞ω) (N : ℕ) (Ξ : E→Fin N→ℝ) (f : E→ℝ) (x : E) + (hΞ : ∀ i,ContDiffAt ℝ m (fun y=>Ξ y i) x) (hf : ContDiffAt ℝ m f x) + (hns : Nonsingular N (Ξ x) (f x)) (s t : Space N) : + ContDiffAt ℝ m (fun y=>bulkRows N (Ξ y) (f y) s t) x := by + apply contDiffAt_pi.2;intro p + apply contDiffAt_pi.2;intro q + unfold bulkRows forward + simp only [Matrix.sum_apply] + apply ContDiffAt.sum;intro v hv + exact (contDiffAt_matrix_entry (contDiffAt_row_curve m N Ξ f x hΞ hf + (fun i=>(hns.2.2 i).1) s v) p.1 q.1).mul + (contDiffAt_matrix_entry (contDiffAt_row_curve m N Ξ (fun y=>b-f y) x hΞ + (contDiffAt_const.sub hf) (fun i=>(hns.2.2 i).2) v t) p.2 q.2) +lemma smoothJetAt_K (m : ℕ∞ω) (e : Jet) (f : E→ℝ) (x : E) + (hf : ContDiffAt ℝ m f x) (hu : sine (gamma+f x)≠0) (p : Pair) : + SmoothJetAt m (fun y=>K e (f y) p) x := by + have h0 : ContDiffAt ℝ m (fun y=>K0 (f y) p) x := + contDiffAt_const.mul ((contDiffAt_matrix_entry (contDiffAt_boundary0 m (f x) hu) p.1 p.2.rev).comp x hf) + have h1 : ContDiffAt ℝ m (fun y=>K1 (f y) p) x := + contDiffAt_const.mul ((contDiffAt_matrix_entry (contDiffAt_boundary1 m (f x) hu) p.1 p.2.rev).comp x hf) + exact SmoothJetAt.C h0 |>.add ((SmoothJetAt.const m e x).mul (SmoothJetAt.C h1)) +lemma smoothJetAt_T_curve (m : ℕ∞ω) (N : ℕ) (Ξ : E→Fin N→ℝ) (f : E→ℝ) (x : E) + (hΞ : ∀ i,ContDiffAt ℝ m (fun y=>Ξ y i) x) (hf : ContDiffAt ℝ m f x) + (hns : Nonsingular N (Ξ x) (f x)) (s t : Space N) : + SmoothJetAt m (fun y=>T N (Ξ y) (f y) s t) x := by + unfold T + apply SmoothJetAt.sum;intro p hp + apply SmoothJetAt.sum;intro q hq + exact ((smoothJetAt_K m eL (fun y=>b-f y) x (contDiffAt_const.sub hf) hns.2.1 p).mul + (SmoothJetAt.C (contDiffAt_matrix_entry (contDiffAt_bulkRows_curve m N Ξ f x hΞ hf hns s t) p q))).mul + (smoothJetAt_K m eR f x hf hns.1 q) +lemma smoothJetAt_reorient (m : ℕ∞ω) (n : ℕ) + (M : E→Matrix (Space n) (Space n) Jet) (x : E) + (hM : ∀ s t,SmoothJetAt m (fun y=>M y s t) x) (s t : Space n) : + SmoothJetAt m (fun y=>reorient n (M y) s t) x := + (hM (reflectedSites n s) (reflectedSites n t)).reflect +lemma smoothJetAt_commonScalar (m : ℕ∞ω) (W : ℕ) + (M : E→Matrix (Column (W+1)) (Column (W+1)) Jet) (x : E) + (hM : ∀ s t,SmoothJetAt m (fun y=>M y s t) x) : + SmoothJetAt m (fun y=>commonScalar W (M y)) x := by + unfold commonScalar Matrix.mulVec dotProduct + apply SmoothJetAt.sum;intro s hs + apply SmoothJetAt.mul (SmoothJetAt.const _ _ _) + apply SmoothJetAt.sum;intro t ht + exact (hM s t).mul (SmoothJetAt.const _ _ _) +lemma smoothJetAt_matrix_mul {ι : Type*} [Fintype ι] (m : ℕ∞ω) + (M N : E→Matrix ι ι Jet) (x : E) + (hM : ∀ s t,SmoothJetAt m (fun y=>M y s t) x) + (hN : ∀ s t,SmoothJetAt m (fun y=>N y s t) x) (s t : ι) : + SmoothJetAt m (fun y=>(M y*N y) s t) x := by + change SmoothJetAt m (fun y=>∑ z,(M y s z*N y z t : Jet)) x + exact SmoothJetAt.sum Finset.univ (fun z _=>(hM s z).mul (hN z t)) +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +open scoped ContDiff Matrix.Norms.Elementwise +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def fusionDefect (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) : + Matrix (Space N) (Space N) Jet := + T N ξ (gamma+u-L)*T N ξ (gamma+u+L)-T N ξ (gamma+u) +def FusionRegular (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) : Prop := + Nonsingular N ξ (gamma+u-L) ∧ Nonsingular N ξ (gamma+u+L) ∧ Nonsingular N ξ (gamma+u) +noncomputable def physicalDefect (W : ℕ) (ξ : Fin (W+1)→ℝ) (u : ℝ) : ℂ := + both (commonScalar W (reorient (W+1) (fusionDefect (W+1) ξ u))) +lemma centered_T_reflect (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hu : Nonsingular N ξ (gamma+u)) : + T N ξ (gamma-u)=T N ξ (gamma+u) := by + have h : gamma-u=b-(gamma+u) := by simp only [gamma,b]; ring + rw [h,←source_spectral_reflection N ξ (gamma+u) hu] +lemma fusionRegular_neg (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) (hu : FusionRegular N ξ u) : + FusionRegular N ξ (-u) := by + have h1 : gamma+-u-L=b-(gamma+u+L) := by simp only [gamma,b,L];ring + have h2 : gamma+-u+L=b-(gamma+u-L) := by simp only [gamma,b,L];ring + have h3 : gamma+-u=b-(gamma+u) := by simp only [gamma,b];ring + exact ⟨by rw [h1];exact nonsingular_reflect _ _ _ hu.2.1, + by rw [h2];exact nonsingular_reflect _ _ _ hu.1, + by rw [h3];exact nonsingular_reflect _ _ _ hu.2.2⟩ +lemma fusionDefect_reflect (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) (hu : FusionRegular N ξ u) : + fusionDefect N ξ (-u)=fusionDefect N ξ u := by + have hm : T N ξ (gamma+-u-L)=T N ξ (gamma+u+L) := by + convert centered_T_reflect N ξ (u+L) (by convert hu.2.1 using 1 ; ring) using 1 <;> congr 1 <;> ring + have hp : T N ξ (gamma+-u+L)=T N ξ (gamma+u-L) := by + convert centered_T_reflect N ξ (u-L) (by convert hu.1 using 1 ; ring) using 1 <;> congr 1 <;> ring + have hc : T N ξ (gamma+-u)=T N ξ (gamma+u) := by + simpa only [sub_eq_add_neg] using centered_T_reflect N ξ u hu.2.2 + unfold fusionDefect + rw [hm,hp,hc,(source_global_spectral_commutation N ξ _ _ hu.2.1 hu.1).eq] +lemma fusionDefect_node (N : ℕ) (ξ : Fin N→ℝ) (i : Fin N) (u : ℝ) + (hn : u=L/2-ξ i ∨ u=L/2+ξ i) (hr : FusionRegular N ξ u) : + fusionDefect N ξ u=0 := by + have hn' : gamma+-u=L-ξ i ∨ gamma+-u=L+ξ i := by + rcases hn with hn|hn + · right;rw [hn];unfold gamma L;ring + · left;rw [hn];unfold gamma L;ring + have hr':=fusionRegular_neg N ξ u hr + rw [←fusionDefect_reflect N ξ u hr,fusionDefect, + source_global_spectral_fusion N ξ i (gamma+-u) hn' hr'.1 hr'.2.1 hr'.2.2,sub_self] +lemma physicalDefect_node (W : ℕ) (ξ : Fin (W+1)→ℝ) (i : Fin (W+1)) (u : ℝ) + (hn : u=L/2-ξ i ∨ u=L/2+ξ i) (hr : FusionRegular (W+1) ξ u) : + physicalDefect W ξ u=0 := by + unfold physicalDefect + rw [fusionDefect_node _ _ i u hn hr] + simp [reorient,commonScalar,Matrix.mulVec,dotProduct,both] +lemma physicalDefect_reflect (W : ℕ) (ξ : Fin (W+1)→ℝ) (u : ℝ) + (hr : FusionRegular (W+1) ξ u) : physicalDefect W ξ (-u)=physicalDefect W ξ u := by + unfold physicalDefect + rw [fusionDefect_reflect _ _ _ hr] +lemma reorient_sub (n : ℕ) (M N : Matrix (Space n) (Space n) Jet) : + reorient n (M-N)=reorient n M-reorient n N := by + funext s t + exact map_sub reflectJet _ _ +lemma commonScalar_sub (W : ℕ) (M N : Matrix (Column (W+1)) (Column (W+1)) Jet) : + commonScalar W (M-N)=commonScalar W M-commonScalar W N := by + unfold commonScalar + rw [Matrix.sub_mulVec,dotProduct_sub] +lemma physicalDefect_homogeneous (W : ℕ) (u : ℝ) + (hr : FusionRegular (W+1) (homogeneous (W+1)) u) : + physicalDefect W (homogeneous (W+1)) u=physicalP W (u-L)+physicalP W (u+L)-physicalP W u := by + unfold physicalDefect fusionDefect + rw [reorient_sub,reorient_mul,commonScalar_sub] + change both (commonScalar W (physicalFamily (W+1) (gamma+u-L)*physicalFamily (W+1) (gamma+u+L))- + physicalScalar W (gamma+u))=_ + rw [commonScalar_mul_line W _ _ (physical_common_line W _ hr.2.1),both_sub] + change both (physicalScalar W (gamma+u-L)*physicalScalar W (gamma+u+L))-both (physicalScalar W (gamma+u))=_ + rw [both_mul_normalized _ _ (physicalScalar_base W _ hr.1) (physicalScalar_base W _ hr.2.1) + (physicalScalar_singles W _ hr.1).1 (physicalScalar_singles W _ hr.1).2] + simp only [physicalP,add_sub_assoc,add_assoc] +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] +lemma smoothJetAt_fusionDefect (m : ℕ∞ω) (N : ℕ) (Ξ : E→Fin N→ℝ) (f : E→ℝ) (x : E) + (hΞ : ∀ i,ContDiffAt ℝ m (fun y=>Ξ y i) x) (hf : ContDiffAt ℝ m f x) + (hr : FusionRegular N (Ξ x) (f x)) (s t : Space N) : + SmoothJetAt m (fun y=>fusionDefect N (Ξ y) (f y) s t) x := by + have hm : ∀ v w,SmoothJetAt m (fun y=>T N (Ξ y) (gamma+f y-L) v w) x := + smoothJetAt_T_curve m N Ξ (fun y=>gamma+f y-L) x hΞ + ((contDiffAt_const.add hf).sub contDiffAt_const) hr.1 + have hp : ∀ v w,SmoothJetAt m (fun y=>T N (Ξ y) (gamma+f y+L) v w) x := + smoothJetAt_T_curve m N Ξ (fun y=>gamma+f y+L) x hΞ + ((contDiffAt_const.add hf).add contDiffAt_const) hr.2.1 + have hc : ∀ v w,SmoothJetAt m (fun y=>T N (Ξ y) (gamma+f y) v w) x := + smoothJetAt_T_curve m N Ξ (fun y=>gamma+f y) x hΞ + (contDiffAt_const.add hf) hr.2.2 + exact (smoothJetAt_matrix_mul m _ _ x hm hp s t).sub (hc s t) +lemma contDiffAt_physicalDefect (m : ℕ∞ω) (W : ℕ) (Ξ : E→Fin (W+1)→ℝ) (f : E→ℝ) (x : E) + (hΞ : ∀ i,ContDiffAt ℝ m (fun y=>Ξ y i) x) (hf : ContDiffAt ℝ m f x) + (hr : FusionRegular (W+1) (Ξ x) (f x)) : + ContDiffAt ℝ m (fun y=>physicalDefect W (Ξ y) (f y)) x := by + have hD := smoothJetAt_fusionDefect m (W+1) Ξ f x hΞ hf hr + have hR := smoothJetAt_reorient m (W+1) (fun y=>fusionDefect (W+1) (Ξ y) (f y)) x hD + exact (smoothJetAt_commonScalar m W (fun y=>reorient (W+1) (fusionDefect (W+1) (Ξ y) (f y))) x hR).2.2.2 +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +lemma L_pos : 0 < L := by unfold L; positivity +lemma nonsingular_core (N : ℕ) (ξ : Fin N→ℝ) (hξ : ∀ i,-L < ξ i ∧ ξ i < 0) + (t : ℝ) (ht : 0⟨?_,?_⟩⟩ + · apply sine_ne_zero_interval <;> simp only [gamma] <;> linarith + · apply sine_ne_zero_interval <;> simp only [gamma,b] <;> linarith + · have hi:=hξ i + simp only [L] at hi + unfold Q + apply mul_ne_zero <;> apply sine_ne_zero_interval <;> (try simp only [b] at *) <;> linarith + · have hi:=hξ i + simp only [L] at hi + unfold Q + apply mul_ne_zero <;> apply sine_ne_zero_interval <;> (try simp only [b] at *) <;> linarith +noncomputable def perturb (N : ℕ) (r : ℝ) (i : Fin N) : ℝ := -L/2+((i.val:ℝ)+1)*r +noncomputable def radius (N : ℕ) : ℝ := L/(4*((N:ℝ)+1)) +lemma radius_pos (N : ℕ) : 0 < radius N := by unfold radius;exact div_pos L_pos (by positivity) +lemma radius_mul (N : ℕ) : radius N*((N:ℝ)+1)=L/4 := by + unfold radius + have h : (N:ℝ)+1 ≠ 0 := by positivity + field_simp +lemma perturb_zero (N : ℕ) : perturb N 0=homogeneous N := by funext i;simp [perturb,homogeneous] +lemma perturb_core (N : ℕ) {r : ℝ} (hr : |r| < radius N) : + ∀ i,-L < perturb N r i ∧ perturb N r i < 0 := by + intro i + have hi : (i.val:ℝ)+1 ≤ (N:ℝ)+1 := by exact_mod_cast Nat.le_of_lt i.isLt |> Nat.succ_le_succ + have hi0 : 0 ≤ (i.val:ℝ)+1 := by positivity + have hN : 0 < (N:ℝ)+1 := by positivity + have hB := mul_lt_mul_of_pos_right hr hN + rw [radius_mul] at hB + have hab : |((i.val:ℝ)+1)*r| < L/4 := by + rw [abs_mul,abs_of_nonneg hi0] + calc _ ≤ |r| *((N:ℝ)+1) := by nlinarith [abs_nonneg r] + _ < L/4 := hB + rw [abs_lt] at hab + unfold perturb + constructor <;> linarith [L_pos] +lemma perturb_regular (N : ℕ) {r u x : ℝ} (hx : 0≤x ∧ x≤L) + (hr : |r| < radius N) (hu : |u-x| < radius N*((N:ℝ)+1)) : + FusionRegular N (perturb N r) u := by + rw [radius_mul,abs_lt] at hu + have hL:=L_pos + have hg : gamma=3*L/2 := by unfold gamma L;ring + refine ⟨nonsingular_core N _ (perturb_core N hr) _ ?_, + nonsingular_core N _ (perturb_core N hr) _ ?_, + nonsingular_core N _ (perturb_core N hr) _ ?_⟩ <;> rw [hg] <;> constructor <;> linarith +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +open scoped ContDiff +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet RasterGrid +open CriticalHoneycomb.Analysis +noncomputable def zeroSlope (N i : ℕ) : ℝ := + (i:ℝ)-N+(if i (try omega) <;> linarith +lemma zeroSlope_bound (N i : ℕ) (hi : i<2*N) : |zeroSlope N i| ≤ (N:ℝ)+1 := by + have hi' : (i:ℝ)<2*N := by exact_mod_cast hi + have hi0 : (0:ℝ) ≤ i := by positivity + rw [abs_le] + unfold zeroSlope + split_ifs <;> constructor <;> linarith +lemma zeroSlope_signed (N i : ℕ) (hi : i<2*N) : + ∃ k : Fin N,zeroSlope N i=((k.val:ℝ)+1) ∨ zeroSlope N i=-((k.val:ℝ)+1) := by + by_cases h : iphysicalDefect W (perturb (W+1) p.1) p.2) (r,u) := by + exact contDiffAt_physicalDefect ∞ W (fun p : ℝ×ℝ=>perturb (W+1) p.1) Prod.snd (r,u) + (by intro i;unfold perturb;fun_prop) (by fun_prop) (perturb_regular _ hx hr hu) + +lemma physicalDefect_zero_jets (W j : ℕ) (hj : j<2*(W+1)) : + iteratedDeriv j (physicalDefect W (homogeneous (W+1))) 0=0 := by + let a : Fin (j+1)→ℝ:=fun i=>zeroSlope (W+1) i.val + have ha : StrictMono a := fun _ _ h=>zeroSlope_strict (W+1) h + have hb : ∀ i,|a i|≤((W+1:ℕ):ℝ)+1 := fun i=>zeroSlope_bound _ _ (by omega) + have hm := confluent_affine_complex j (fun r=>physicalDefect W (perturb (W+1) r)) 0 + a ha (((W+1:ℕ):ℝ)+1) (by positivity) hb (radius (W+1)) (radius_pos _) ?_ ?_ + · simpa only [perturb_zero] using hm + · intro r hr hd i + have hi : i.val<2*(W+1) := by omega + have hclose : |(0+r*a i)-0| < radius (W+1)*(((W+1:ℕ):ℝ)+1) := by + simpa using affine_node_close hr hd (show (0:ℝ)<((W+1:ℕ):ℝ)+1 by positivity) (hb i) + have hreg:=perturb_regular (W+1) ⟨le_rfl,L_pos.le⟩ + (show |r| < radius (W+1) by rwa [abs_of_pos hr]) hclose + obtain ⟨k,hk|hk⟩:=zeroSlope_signed (W+1) i.val hi + · exact perturb_signed_zero W r _ k (Or.inl (by dsimp [a];rw [hk];ring)) hreg + · exact perturb_signed_zero W r _ k (Or.inr (by dsimp [a];rw [hk];ring)) hreg + · intro r u hr hu + exact smooth_perturb_defect W ⟨le_rfl,L_pos.le⟩ hr hu + +lemma physicalDefect_L_jets (W j : ℕ) (hj : j(i.val:ℝ)-(W+1:ℕ) + have ha : StrictMono a := by + intro i k hik + exact sub_lt_sub_right (by exact_mod_cast hik) _ + have hb : ∀ i,|a i|≤((W+1:ℕ):ℝ)+1 := by + intro i + have hi : (i.val:ℝ)<(W+1:ℕ) := by exact_mod_cast (show i.val linarith + have hm := confluent_affine_complex j (fun r=>physicalDefect W (perturb (W+1) r)) L + a ha (((W+1:ℕ):ℝ)+1) (by positivity) hb (radius (W+1)) (radius_pos _) ?_ ?_ + · simpa only [perturb_zero] using hm + · intro r hr hd i + have hclose : |(L+r*a i)-L| < radius (W+1)*(((W+1:ℕ):ℝ)+1) := by + simpa using affine_node_close hr hd (show (0:ℝ)<((W+1:ℕ):ℝ)+1 by positivity) (hb i) + have hreg:=perturb_regular (W+1) ⟨L_pos.le,le_rfl⟩ + (show |r| < radius (W+1) by rwa [abs_of_pos hr]) hclose + let k : Fin (W+1):=⟨W-i.val,by omega⟩ + have hk : k.val+1+i.val=W+1 := by dsimp [k];omega + have hk' : (k.val:ℝ)+1+i.val=(W+1:ℕ) := by exact_mod_cast hk + apply physicalDefect_node W _ k _ (Or.inl ?_) hreg + dsimp [perturb,a] + nlinarith + · intro r u hr hu + exact smooth_perturb_defect W ⟨L_pos.le,le_rfl⟩ hr hu +lemma physicalDefect_eventually (W : ℕ) {x : ℝ} (hx : 0≤x ∧ x≤L) : + physicalDefect W (homogeneous (W+1)) =ᶠ[nhds x] + (fun u=>physicalP W (u-L)+physicalP W (u+L)-physicalP W u) := by + have hd : 0 < radius (W+1)*(((W+1:ℕ):ℝ)+1) := mul_pos (radius_pos _) (by positivity) + have he : ∀ᶠ u in nhds x,|u-x| < radius (W+1)*(((W+1:ℕ):ℝ)+1) := by + filter_upwards [Metric.ball_mem_nhds x hd] with u hu + simpa only [Real.dist_eq] using (Metric.mem_ball.mp hu) + filter_upwards [he] with u hu + apply physicalDefect_homogeneous + rw [←perturb_zero] + exact perturb_regular _ hx (by simpa using radius_pos (W+1)) hu + +theorem physicalP_zero_fusion_jets (W j : ℕ) (hj : j<2*(W+1)) : + iteratedDeriv j (fun u : ℝ=>physicalP W (u-L)+physicalP W (u+L)-physicalP W u) 0=0 := by + rw [←Filter.EventuallyEq.iteratedDeriv_eq j (physicalDefect_eventually W ⟨le_rfl,L_pos.le⟩)] + exact physicalDefect_zero_jets W j hj + +theorem physicalP_L_fusion_jets (W j : ℕ) (hj : jphysicalP W (u-L)+physicalP W (u+L)-physicalP W u) L=0 := by + rw [←Filter.EventuallyEq.iteratedDeriv_eq j (physicalDefect_eventually W ⟨L_pos.le,le_rfl⟩)] + exact physicalDefect_L_jets W j hj +end CriticalHoneycomb.Transfer.SpectralFamily + +end + + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Polynomial Reflection CriticalHoneycomb.FiniteFunctional Filter Topology +lemma polePoly_eval (N : ℕ) (X : ℂ) : + (polePoly N).eval X=interpolationDenominator N X := by + simp only [polePoly,eval_mul,eval_pow,eval_add,eval_X,eval_C] + rfl +lemma physicalNumerator_eval (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+u)) : + (physicalNumerator W).eval (Real.cos (2*u):ℂ)= + interpolationDenominator (W+1) (Real.cos (2*u):ℂ)*physicalP W u := by + rw [physicalNumerator,eval_mul,eval_C,cosinePoly_physical W u hu,den_cos] + change (2:ℂ)^(2*(W+1)+1)* + ((2:ℂ)⁻¹^(2*(W+1)+1)*((Real.cos (2*u):ℂ)+1)^(W+1)* + ((Real.cos (2*u):ℂ)+(Real.cos (2*L):ℂ))^(W+1+1)*physicalP W u)=_ + rw [inv_pow,←mul_assoc,←mul_assoc,←mul_assoc,mul_inv_cancel₀ (pow_ne_zero _ (by norm_num)),one_mul] + rfl +lemma interpolationDenominator_ne (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+u)) : + interpolationDenominator (W+1) (Real.cos (2*u):ℂ)≠0 := by + have hd:=(homogeneous_nonsingular_den _ (by omega) u).mp hu + rw [den_cos] at hd + change ((Real.cos (2*u):ℂ)+1)^(W+1)* + ((Real.cos (2*u):ℂ)+(Real.cos (2*L):ℂ))^(W+1+1)≠0 + rw [mul_assoc] at hd + exact (mul_ne_zero_iff.mp hd).2 +lemma interpolant_is_physical {W : ℕ} {ρ : ℂ} {P : Polynomial ℂ} + (hP : physicalNumerator W=(C 4*X+C ρ)*polePoly (W+1)+P) + (u : ℝ) (hu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+u)) : + interpolant (W+1) ρ P u=physicalP W u := by + have he:=congrArg (fun p : Polynomial ℂ=>p.eval (Real.cos (2*u):ℂ)) hP + rw [physicalNumerator_eval W u hu,eval_add,eval_mul,eval_add,eval_mul,eval_C, + eval_X,eval_C,polePoly_eval] at he + have hd:=interpolationDenominator_ne W u hu + unfold interpolant + apply mul_right_cancel₀ hd + rw [add_mul,div_mul_cancel₀ _ hd] + exact he.symm.trans (mul_comm _ _) +lemma interpolant_is_physical_interval {W : ℕ} {ρ : ℂ} {P : Polynomial ℂ} + (hP : physicalNumerator W=(C 4*X+C ρ)*polePoly (W+1)+P) + {u : ℝ} (hu0 : -binterpolant (W+1) ρ P (u-L)+interpolant (W+1) ρ P (u+L)- + interpolant (W+1) ρ P u)=ᶠ[𝓝 x] + (fun u : ℝ=>physicalP W (u-L)+physicalP W (u+L)-physicalP W u) := by + have hlo : L-b(pow_pos FiniteContinuation.kappa_positive _).le) + · rw [interpolant_is_physical_interval hP (by dsimp [b,L];linarith [Real.pi_pos]) + (by dsimp [b,L];linarith [Real.pi_pos])] + exact physicalP_mass W + · change interpolant (W+1) ρ P (3*L/2)=0 + rw [interpolant_is_physical_interval hP (by dsimp [b,L];linarith [Real.pi_pos]) + (by dsimp [b,L];linarith [Real.pi_pos])] + exact (physicalP_endpoint_zeros W).1 + · change interpolant (W+1) ρ P (5*L/2)=0 + rw [interpolant_is_physical_interval hP (by dsimp [b,L];linarith [Real.pi_pos]) + (by dsimp [b,L];linarith [Real.pi_pos])] + exact (physicalP_endpoint_zeros W).2 + · intro j hj + change iteratedDeriv j (fun u : ℝ=>interpolant (W+1) ρ P (u-L)+ + interpolant (W+1) ρ P (u+L)-interpolant (W+1) ρ P u) 0=0 + rw [Filter.EventuallyEq.iteratedDeriv_eq j (interpolant_fusion_eventually hP ⟨le_rfl,L_pos.le⟩)] + exact physicalP_zero_fusion_jets W j hj + · intro j hj + change iteratedDeriv j (fun u : ℝ=>interpolant (W+1) ρ P (u-L)+ + interpolant (W+1) ρ P (u+L)-interpolant (W+1) ρ P u) L=0 + rw [Filter.EventuallyEq.iteratedDeriv_eq j (interpolant_fusion_eventually hP ⟨L_pos.le,le_rfl⟩)] + exact physicalP_L_fusion_jets W j hj +end CriticalHoneycomb.FiniteFunctional + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ConfluentZeros.lean b/lean/OAI/Combinatorics/HoneycombChords/ConfluentZeros.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cee73527ad764ec0b6e5268a0a8e80708b2cde5 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ConfluentZeros.lean @@ -0,0 +1,191 @@ +import Mathlib + +namespace OAI + +/-! Coalescing real and complex zeros through Rolle's theorem. + +The affine specialization gives vanishing jets when distinct zeros converge to one point. -/ + +section + +namespace CriticalHoneycomb.Analysis +open Set Filter Topology +lemma rolle_many (n : ℕ) (f : ℝ→ℝ) (a b : ℝ) + (xs : Fin (n+1)→ℝ) (hxs : StrictMono xs) + (hbound : ∀ i, xs i∈Icc a b) (hzero : ∀ i,f (xs i)=0) + (hc : ∀ j : ℕ,j exact ⟨xs 0,hbound 0,by simpa using hzero 0⟩ + | succ n ih => + have hex : ∀ i : Fin (n+1),∃ c∈Ioo (xs i.castSucc) (xs i.succ),deriv f c=0 := by + intro i + apply exists_deriv_eq_zero (hxs (Fin.castSucc_lt_succ (i:=i))) + · have hcf : ContinuousOn f (Icc a b) := by + simpa only [iteratedDeriv_zero] using hc 0 (by omega) + exact hcf.mono (Icc_subset_Icc (hbound i.castSucc).1 (hbound i.succ).2) + · rw [hzero,hzero] + choose cs hcs hcz using hex + have hm : StrictMono cs := by + intro i j hij + have hij' : i.succ≤j.castSucc := by exact_mod_cast (show i.val+1≤j.val by omega) + exact (hcs i).2.trans_le ((hxs.monotone hij').trans (hcs j).1.le) + have hb : ∀ i,cs i∈Icc a b := fun i=> + ⟨(hbound i.castSucc).1.trans (hcs i).1.le,(hcs i).2.le.trans (hbound i.succ).2⟩ + have hd : ∀ j : ℕ,jiteratedDeriv n (f p.1) p.2) (0,x)) : + iteratedDeriv n (f 0) x=0 := by + have hex : ∀ k,∃ c∈Icc (lo k) (hi k),iteratedDeriv n (f (r k)) c=0 := + fun k=>rolle_many n (f (r k)) (lo k) (hi k) (xs k) (hxs k) (hb k) (hz k) (hc k) + choose cs hcs hcz using hex + have hcs' : Tendsto cs atTop (𝓝 x) := tendsto_of_tendsto_of_tendsto_of_le_of_le hl hh (fun k=>(hcs k).1) (fun k=>(hcs k).2) + have hp : Tendsto (fun k=>(r k,cs k)) atTop (𝓝 (0,x)) := hr.prodMk_nhds hcs' + have hresult:=hlim.tendsto.comp hp + have hzero : Tendsto (fun k=>iteratedDeriv n (f (r k)) (cs k)) atTop (𝓝 0) := by + simpa only [hcz] using (tendsto_const_nhds : Tendsto (fun _ : ℕ=>(0:ℝ)) atTop (𝓝 0)) + exact tendsto_nhds_unique hresult hzero +end CriticalHoneycomb.Analysis + +end + +section + +open scoped ContDiff +namespace CriticalHoneycomb.Analysis +variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] +lemma contDiffAt_partial_deriv (f : ℝ→ℝ→F) (r u : ℝ) + (hf : ContDiffAt ℝ ∞ (Function.uncurry f) (r,u)) : + ContDiffAt ℝ ∞ (fun p : ℝ×ℝ=>deriv (f p.1) p.2) (r,u) := by + let g : (ℝ×ℝ)→ℝ→F := fun p t=>f p.1 t + have hproj : ContDiffAt ℝ ∞ (fun p : (ℝ×ℝ)×ℝ=>(p.1.1,p.2)) ((r,u),u) := + (contDiffAt_fst.fst).prodMk contDiffAt_snd + have hg : ContDiffAt ℝ ∞ (Function.uncurry g) ((r,u),u) := + by simpa only [Function.comp_def,Function.uncurry_def,g] using + (ContDiffAt.comp (f:=fun p : (ℝ×ℝ)×ℝ=>(p.1.1,p.2)) + (g:=Function.uncurry f) ((r,u),u) hf hproj) + have hd : ContDiffAt ℝ ∞ (fun p : ℝ×ℝ=>fderiv ℝ (g p) p.2) (r,u) := + hg.fderiv (g:=fun p : ℝ×ℝ=>p.2) contDiffAt_snd (by simp) + exact hd.clm_apply (contDiffAt_const (c:=(1:ℝ))) +lemma contDiffAt_partial_iteratedDeriv (n : ℕ) (f : ℝ→ℝ→F) (r u : ℝ) + (hf : ContDiffAt ℝ ∞ (Function.uncurry f) (r,u)) : + ContDiffAt ℝ ∞ (fun p : ℝ×ℝ=>iteratedDeriv n (f p.1) p.2) (r,u) := by + induction n with + | zero => simpa only [iteratedDeriv_zero,Function.uncurry_def] using hf + | succ n ih => + simpa only [iteratedDeriv_succ] using + contDiffAt_partial_deriv (fun r=>iteratedDeriv n (f r)) r u ih +end CriticalHoneycomb.Analysis + +end + +section +open scoped ContDiff +namespace CriticalHoneycomb.Analysis +open Set Filter Topology +lemma confluent_zero_eventually {α : Type*} (l : Filter α) [l.NeBot] + (n : ℕ) (f : ℝ→ℝ→ℝ) (r : α→ℝ) (x : ℝ) + (lo hi : α→ℝ) (xs : α→Fin (n+1)→ℝ) + (hr : Tendsto r l (𝓝 0)) (hl : Tendsto lo l (𝓝 x)) (hh : Tendsto hi l (𝓝 x)) + (hdata : ∀ᶠ k in l,StrictMono (xs k) ∧ (∀ i,xs k i∈Icc (lo k) (hi k)) ∧ + (∀ i,f (r k) (xs k i)=0) ∧ + (∀ j,j < n → ContinuousOn (iteratedDeriv j (f (r k))) (Icc (lo k) (hi k)))) + (hlim : ContinuousAt (fun p : ℝ×ℝ=>iteratedDeriv n (f p.1) p.2) (0,x)) : + iteratedDeriv n (f 0) x=0 := by + classical + let P := fun k c=>c∈Icc (lo k) (hi k) ∧ iteratedDeriv n (f (r k)) c=0 + have hex : ∀ᶠ k in l,∃ c,P k c := by + filter_upwards [hdata] with k hk + exact rolle_many n (f (r k)) (lo k) (hi k) (xs k) hk.1 hk.2.1 hk.2.2.1 hk.2.2.2 + let cs : α→ℝ := fun k=>if h : ∃ c,P k c then Classical.choose h else x + have hc : ∀ᶠ k in l,P k (cs k) := by + filter_upwards [hex] with k hk + simpa only [cs,dite_eq_left hk] using Classical.choose_spec hk + have hcs : Tendsto cs l (𝓝 x) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hl hh + (hc.mono (fun _ h=>h.1.1)) (hc.mono (fun _ h=>h.1.2)) + have hd:=hlim.tendsto.comp (hr.prodMk_nhds hcs) + have hz : Tendsto (fun k=>iteratedDeriv n (f (r k)) (cs k)) l (𝓝 0) := + tendsto_const_nhds.congr' (hc.mono (fun _ h=>h.2.symm)) + exact tendsto_nhds_unique hd hz + +lemma confluent_affine (n : ℕ) (f : ℝ→ℝ→ℝ) (x : ℝ) + (a : Fin (n+1)→ℝ) (ha : StrictMono a) (C : ℝ) (hC : 0 < C) + (hb : ∀ i,|a i|≤C) (δ : ℝ) (hδ : 0<δ) + (hzero : ∀ r,0] 0) (𝓝 0) := nhdsWithin_le_nhds + have hl : Tendsto (fun r : ℝ=>x-r*C) (𝓝[>] 0) (𝓝 x) := by + simpa using (tendsto_const_nhds.sub (hr.mul_const C)) + have hh : Tendsto (fun r : ℝ=>x+r*C) (𝓝[>] 0) (𝓝 x) := by + simpa using (tendsto_const_nhds.add (hr.mul_const C)) + apply confluent_zero_eventually (𝓝[>] 0) n f id x (fun r=>x-r*C) (fun r=>x+r*C) + (fun r i=>x+r*a i) hr hl hh + · have he : ∀ᶠ r : ℝ in 𝓝[>] 0,0] 0,0 nlinarith + · intro j hj u hu + rcases hu with ⟨hu0,hu1⟩ + have hx : |u-x| < δ*C := by + rw [abs_lt] + constructor <;> nlinarith [mul_lt_mul_of_pos_right hr.2 hC] + have hs:=hsmooth r u (by simpa only [abs_of_pos hr.1] using hr.2) hx + have hd:=(contDiffAt_partial_iteratedDeriv j f r u hs).continuousAt + exact (hd.comp (f:=fun t : ℝ=>(r,t)) (continuousAt_const.prodMk continuousAt_id)).continuousWithinAt + · apply (contDiffAt_partial_iteratedDeriv n f 0 x ?_).continuousAt + exact hsmooth 0 x (by simpa using hδ) (by simpa using mul_pos hδ hC) +lemma iteratedDeriv_clm {F G : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] + [NormedAddCommGroup G] [NormedSpace ℝ G] (A : F→L[ℝ] G) + (n : ℕ) (f : ℝ→F) (x : ℝ) (hf : ContDiffAt ℝ ∞ f x) : + iteratedDeriv n (fun u=>A (f u)) x=A (iteratedDeriv n f x) := by + simp only [iteratedDeriv_eq_iteratedFDeriv] + change (iteratedFDeriv ℝ n (A ∘ f) x) (fun _=>1)=_ + rw [A.iteratedFDeriv_comp_left hf (by exact_mod_cast (show (n : ℕ∞) ≤ ⊤ from le_top))] + rfl + +lemma confluent_affine_complex (n : ℕ) (f : ℝ→ℝ→ℂ) (x : ℝ) + (a : Fin (n+1)→ℝ) (ha : StrictMono a) (C : ℝ) (hC : 0 < C) + (hb : ∀ i,|a i|≤C) (δ : ℝ) (hδ : 0<δ) + (hzero : ∀ r,0(f r u).re) x a ha C hC hb δ hδ + (by intro r hr hd i;rw [hzero r hr hd i];rfl) + (by intro r u hr hu;exact Complex.reCLM.contDiff.contDiffAt.comp (r,u) (hsmooth r u hr hu)) + have him := confluent_affine n (fun r u=>(f r u).im) x a ha C hC hb δ hδ + (by intro r hr hd i;rw [hzero r hr hd i];rfl) + (by intro r u hr hu;exact Complex.imCLM.contDiff.contDiffAt.comp (r,u) (hsmooth r u hr hu)) + change iteratedDeriv n (fun u=>Complex.reCLM (f 0 u)) x=0 at hre + change iteratedDeriv n (fun u=>Complex.imCLM (f 0 u)) x=0 at him + rw [iteratedDeriv_clm Complex.reCLM n (f 0) x hf0] at hre + rw [iteratedDeriv_clm Complex.imCLM n (f 0) x hf0] at him + exact Complex.ext hre him +end CriticalHoneycomb.Analysis + +end + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Continuation.lean b/lean/OAI/Combinatorics/HoneycombChords/Continuation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cda7ec3ba930353ea94a64be47128abe3b0d13f7 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Continuation.lean @@ -0,0 +1,541 @@ +import OAI.Combinatorics.HoneycombChords.FluxBounds + +namespace OAI + +/-! +# Fresh-row continuation of honeycomb bridges + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.FiniteContinuation +open CriticalHoneycomb + +/-- A fresh deterministic lattice row. Every two new centers advance one +pure-cut spacing; this construction contributes no boundary-port weight. -/ +def row (i j : ℤ) : ℕ → List Center + | 0 => [] + | n+1 => up i j::down i j::row (i+1) j n + +lemma row_length (i j : ℤ) (n : ℕ) : (row i j n).length=2*n := by + induction n generalizing i with + | zero => rfl + | succ n ih => simp [row,ih];omega + +lemma mem_row (i j : ℤ) (n : ℕ) (v : Center) : + v∈row i j n ↔ i≤v.1 ∧ v.1 < i + n ∧ v.2.1=j := by + induction n generalizing i with + | zero => simp [row];omega + | succ n ih => + rcases v with ⟨x,y,t⟩ + cases t <;> simp only [row,List.mem_cons,ih,up,down,Prod.mk.injEq,Nat.cast_add,Nat.cast_one] + all_goals constructor + all_goals intro hv + all_goals simp_all + all_goals omega + +lemma row_nodup (i j : ℤ) (n : ℕ) : (row i j n).Nodup := by + induction n generalizing i with + | zero => simp [row] + | succ n ih => + simp only [row,List.nodup_cons,List.mem_cons,not_or] + refine ⟨⟨by simp [up,down],?_⟩,⟨?_,ih _⟩⟩ <;> simp [mem_row,up,down] + +lemma row_head (i j : ℤ) (n : ℕ) : (row i j (n+1)).head?=some (up i j) := rfl +lemma row_last (i j : ℤ) (n : ℕ) : + (row i j (n+1)).getLast?=some (down (i+n) j) := by + induction n generalizing i with + | zero => simp [row,down] + | succ n ih => + simpa [row,List.getLast?_cons_cons,ih,down,add_assoc,add_comm,add_left_comm] using ih (i+1) + +lemma row_chain (i j : ℤ) (n : ℕ) : (row i j n).IsChain Adj := by + induction n generalizing i with + | zero => simp [row] + | succ n ih => + cases n with + | zero => simp [row,Adj,up,down] + | succ n => + have hh := ih (i+1) + simpa only [row,List.isChain_cons_cons] using + (show Adj (up i j) (down i j) ∧ Adj (down i j) (up (i+1) j) ∧ + (row (i+1) j (n+1)).IsChain Adj from + ⟨by simp [Adj,up,down],by simp [Adj,up,down],hh⟩) + +def shift (dy : ℤ) (v : Center) : Center := (v.1,v.2.1+dy,v.2.2) +lemma shift_injective (dy : ℤ) : Function.Injective (shift dy) := by + intro v w h + rcases v with ⟨x,y,t⟩;rcases w with ⟨x',y',t'⟩ + simp [shift,Prod.mk.injEq] at h + simp [h] +lemma shift_adj (dy : ℤ) (v w : Center) : Adj (shift dy v) (shift dy w) ↔ Adj v w := by + rcases v with ⟨x,y,t⟩;rcases w with ⟨x',y',t'⟩ + cases t <;> simp only [Adj,shift,Bool.false_eq_true,ite_false,ite_true] + all_goals constructor <;> intro h <;> rcases h with ⟨ht,h⟩ <;> refine ⟨ht,?_⟩ <;> omega +lemma shift_up (dy i j : ℤ) : shift dy (up i j)=up i (j+dy) := rfl +lemma shift_down (dy i j : ℤ) : shift dy (down i j)=down i (j+dy) := rfl +lemma shift_shift (dx dy : ℤ) (v : Center) : shift dx (shift dy v)=shift (dy+dx) v := by + rcases v with ⟨x,y,t⟩;simp [shift,add_assoc] +lemma shift_zero (v : Center) : shift 0 v=v := by cases v;simp [shift] + +/-- The same finite pure rectangle as the tensor grid, given by its literal +integer-coordinate inequalities for the geometric continuation proof. -/ +def rect (W H : ℕ) : Set Center := + {v | 0≤v.1 ∧ v.1<(W:ℤ) ∧ 0≤v.2.1 ∧ v.2.1<(H:ℤ)} + +/-- The original bottom/top chord trace, with two fresh disjoint rows. -/ +def extend (W h : ℕ) (i x : Fin W) (p : List Center) : List Center := + row 0 0 (i.val+1)++p.map (shift 1)++row x.val (h+1) (W-x.val) + +lemma extend_length (W h : ℕ) (i x : Fin W) (p : List Center) : + (extend W h i x p).length=p.length+2*(i.val+1)+2*(W-x.val) := by + simp [extend,row_length];omega + +lemma extend_length_le (W h : ℕ) (i x : Fin W) (p : List Center) : + (extend W h i x p).length≤p.length+4*W := by + rw [extend_length] + have hi := i.isLt + have hx := x.isLt + omega + +lemma extend_mem (W h : ℕ) (i x : Fin W) (p : List Center) + (hp : ∀ v∈p,v∈rect W h) : ∀ v∈extend W h i x p,v∈rect W (h+2) := by + intro v hv + simp only [extend,List.mem_append] at hv + rcases hv with (hv|hv)|hv + · have hm := (mem_row _ _ _ _).mp hv + have hi := i.isLt + simp only [rect,Set.mem_ofPred_eq] + omega + · obtain ⟨u,hu,rfl⟩ := List.mem_map.mp hv + have hu := hp u hu + simp only [rect,Set.mem_ofPred_eq,shift] at hu ⊢ + omega + · have hm := (mem_row _ _ _ _).mp hv + have hx := x.isLt + simp only [rect,Set.mem_ofPred_eq] + omega + +lemma extend_nodup (W h : ℕ) (i x : Fin W) (p : List Center) + (hpos : 0 cases u <;> simp [Adj] at h ⊢ <;> omega + +lemma reverse_chain {p : List Center} (h : p.IsChain Adj) : p.reverse.IsChain Adj := by + rw [List.isChain_reverse] + exact h.imp (fun _ _ h=>adj_symm h) + +/-- Enter from the EAST wall on the bottom fresh row, ending immediately +below the original source. This direction matches the checked flux bound. -/ +def eastRun (W : ℕ) (i : Fin W) (j : ℤ) : List Center := + (down i.val j::row (i.val+1) j (W-i.val-1)).reverse +/-- Leave from the original top endpoint through a new row to the WEST wall. -/ +def westRun (x : ℕ) (j : ℤ) : List Center := + (row 0 j x++[up x j]).reverse + +lemma eastRun_length (W : ℕ) (i : Fin W) (j : ℤ) : + (eastRun W i j).length=1+2*(W-i.val-1) := by simp [eastRun,row_length];omega +lemma westRun_length (x : ℕ) (j : ℤ) : (westRun x j).length=2*x+1 := by + simp [westRun,row_length] +lemma eastRun_last (W : ℕ) (i : Fin W) (j : ℤ) : + (eastRun W i j).getLast?=some (down i.val j) := by simp [eastRun] +lemma westRun_head (x : ℕ) (j : ℤ) : + (westRun x j).head?=some (up x j) := by simp [westRun] +lemma westRun_last (x : ℕ) (j : ℤ) : + (westRun x j).getLast?=some (up 0 j) := by + unfold westRun + rw [List.getLast?_reverse] + cases x <;> simp [row,up] +lemma eastRun_head (W : ℕ) (i : Fin W) (j : ℤ) : + (eastRun W i j).head?=some (down (W-1:ℕ) j) := by + have hi := i.isLt + unfold eastRun + rw [List.head?_reverse] + cases hn : W-i.val-1 with + | zero => + have he : i.val=W-1 := by omega + simp [row,he] + | succ n => + have hh := row_last (i.val+1) j n + have he : (i.val:ℤ)+1+n=(W-1:ℕ) := by omega + simpa [List.getLast?_cons_cons,row,he] using hh + +lemma eastRun_mem (W : ℕ) (i : Fin W) (j : ℤ) {v : Center} + (hv : v∈eastRun W i j) : 0≤v.1 ∧ v.1<(W:ℤ) ∧ v.2.1=j := by + have hi := i.isLt + simp only [eastRun,List.mem_reverse,List.mem_cons] at hv + rcases hv with rfl|hv + · simp [down] + · have hm := (mem_row _ _ _ _).mp hv + omega +lemma westRun_mem (x : ℕ) (j : ℤ) {v : Center} + (hv : v∈westRun x j) : 0≤v.1 ∧ v.1≤(x:ℤ) ∧ v.2.1=j := by + simp only [westRun,List.mem_reverse,List.mem_append,List.mem_singleton] at hv + rcases hv with hv|rfl + · have hm := (mem_row _ _ _ _).mp hv + omega + · simp [up] +lemma eastRun_nodup (W : ℕ) (i : Fin W) (j : ℤ) : (eastRun W i j).Nodup := by + rw [eastRun,List.nodup_reverse,List.nodup_cons] + refine ⟨?_,row_nodup _ _ _⟩ + rw [mem_row] + simp [down] +lemma westRun_nodup (x : ℕ) (j : ℤ) : (westRun x j).Nodup := by + rw [westRun,List.nodup_reverse,List.nodup_append] + refine ⟨row_nodup _ _ _,by simp,?_⟩ + intro a ha b hb hab + have he : b=up x j := by simpa using hb + subst b;subst a + have hm := (mem_row _ _ _ _).mp ha + simp [up] at hm +lemma eastRun_chain (W : ℕ) (i : Fin W) (j : ℤ) : (eastRun W i j).IsChain Adj := by + apply reverse_chain + rw [List.isChain_cons] + refine ⟨?_,row_chain _ _ _⟩ + cases hn : W-i.val-1 with + | zero => simp [row] + | succ n => simp [row,Adj,up,down] +lemma westRun_chain (x : ℕ) (j : ℤ) : (westRun x j).IsChain Adj := by + apply reverse_chain + apply (row_chain 0 j x).append (by simp) + cases x with + | zero => simp [row] + | succ n => + simp only [row_last,zero_add,List.head?_singleton,Option.mem_def,Option.some.injEq] + intro u hu v hv + subst u;subst v + simp [Adj,up,down] + +/-- Injective continuation along fresh rows. -/ +def turnedExtend (W h : ℕ) (i x : Fin W) (p : List Center) : List Center := + eastRun W i 0++p.map (shift 1)++westRun x.val (h+1) +lemma turnedExtend_length (W h : ℕ) (i x : Fin W) (p : List Center) : + (turnedExtend W h i x p).length=p.length+2*(W-i.val-1)+2*x.val+2 := by + simp [turnedExtend,eastRun_length,westRun_length];omega +lemma turnedExtend_length_le (W h : ℕ) (i x : Fin W) (p : List Center) : + (turnedExtend W h i x p).length≤p.length+4*W := by + rw [turnedExtend_length] + have hi := i.isLt;have hx := x.isLt + omega +lemma turnedExtend_mem (W h : ℕ) (i x : Fin W) (p : List Center) + (hp : ∀ v∈p,v∈rect W h) : ∀ v∈turnedExtend W h i x p,v∈rect W (h+2) := by + intro v hv + simp only [turnedExtend,List.mem_append] at hv + rcases hv with (hv|hv)|hv + · have hm := eastRun_mem W i 0 hv + simp only [rect,Set.mem_ofPred_eq] + omega + · obtain ⟨u,hu,rfl⟩ := List.mem_map.mp hv + have hu := hp u hu + simp only [rect,Set.mem_ofPred_eq,shift] at hu ⊢ + omega + · have hm := westRun_mem x.val (h+1) hv + have hx := x.isLt + simp only [rect,Set.mem_ofPred_eq] + omega +lemma turnedExtend_nodup (W h : ℕ) (i x : Fin W) (p : List Center) + (hpos : 0(shift_adj 1 _ _).mpr h) hc + unfold turnedExtend + apply ((eastRun_chain W i 0).append hm ?_).append (westRun_chain x.val (h+1)) + · simp only [List.getLast?_append,List.getLast?_map,hl,Option.map_some,Option.some_or, + westRun_head,Option.mem_def,Option.some.injEq] + intro u hu v hv + subst u;subst v + simp [shift,Adj,up,down] + · simp only [eastRun_last,List.head?_map,hh,Option.map_some,Option.mem_def,Option.some.injEq] + intro u hu v hv + subst u;subst v + simp [shift,Adj,up,down] + +lemma turnedExtend_head (W h : ℕ) (i x : Fin W) (p : List Center) : + (turnedExtend W h i x p).head?=some (down (W-1:ℕ) 0) := by + simp [turnedExtend,List.head?_append,eastRun_head] +lemma turnedExtend_last (W h : ℕ) (i x : Fin W) (p : List Center) : + (turnedExtend W h i x p).getLast?=some (up 0 (h+1)) := by + simp [turnedExtend,List.getLast?_append,westRun_last] + +def middle (h : ℕ) (v : Center) : Bool := decide (0 continuedChord γ hN) := by + intro γ δ he + exact continuedTrace_injective (congrArg Subtype.val he) + +noncomputable instance rectBridgeFintype {W h : ℕ} {i : Fin (W+1)} : + Fintype (RectBridge W h i) := + Fintype.ofInjective (fun γ : RectBridge W h i => continuedChord γ (le_refl h)) + (continuedChord_injective (le_refl h)) + +noncomputable def continues {W N : ℕ} {i : Fin (W+1)} + (γ : Σ h : Fin (N+1),RectBridge W h.val i) : + Σ j : Fin (N+3),RasterGrid.RectChord W (N+2) j 0 := + ⟨⟨γ.1.val+2,by have hh:=γ.1.isLt;omega⟩, + continuedChord γ.2 (by have hh:=γ.1.isLt;omega)⟩ + +lemma continues_injective {W N : ℕ} {i : Fin (W+1)} : + Function.Injective (continues (W:=W) (N:=N) (i:=i)) := by + rintro ⟨h,γ⟩ ⟨k,δ⟩ he + have ht : continuedTrace γ=continuedTrace δ := + congrArg (fun p : Σ j : Fin (N+3),RasterGrid.RectChord W (N+2) j 0 => p.2.val) he + have hh : h=k := Fin.ext (continuedTrace_height γ δ ht) + subst k + have hg := continuedTrace_injective ht + subst δ + rfl + +lemma kappa_positive : 0 kappa^p.2.val.length + have hfi : Function.Injective f := continues_injective + have hb : (∑ p : B,g p)≤1 := by + rw [Fintype.sum_sigma] + exact FluxWard.rectangle_actual_sum_bound W (N+2) 0 + calc + kappa^(4*(W+1))*(∑ h : Fin (N+1),crossingMass W h.val i) = + ∑ p : A,kappa^(4*(W+1))*kappa^p.2.val.length := by + rw [Fintype.sum_sigma] + simp only [crossingMass,Finset.mul_sum] + _ ≤ ∑ p : A,g (f p) := by + apply Finset.sum_le_sum + intro p hp + exact continued_weight p.2 + _ = ∑ p ∈ Finset.univ.image f,g p := + (Finset.sum_image hfi.injOn).symm + _ ≤ ∑ p : B,g p := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro p hp hn + exact (pow_pos kappa_positive _).le + _ ≤ 1 := hb + +/-- The actual fixed-width tall-crossing masses are summable. This is +stronger than the qualitative decay needed for the physical transfer gap, +and is a dependency only, not any of the manuscript's main theorems. -/ +theorem crossing_summable (W : ℕ) (i : Fin (W+1)) : + Summable (fun h : ℕ => crossingMass W h i) := by + apply summable_of_sum_range_le (fun h => crossingMass_nonnegative W h i) + (c:=1/kappa^(4*(W+1))) + intro n + cases n with + | zero => simp [kappa_positive.le] + | succ N => + rw [le_div_iff₀ (pow_pos kappa_positive _)] + rw [mul_comm,←Fin.sum_univ_eq_sum_range] + exact crossing_partial_sum W N i + +/-- Uniform over the finitely many terminal sites, with the original +literal center weights and no assumed path estimates. -/ +theorem crossing_tendsto_zero (W : ℕ) (i : Fin (W+1)) : + Filter.Tendsto (fun h : ℕ => crossingMass W h i) Filter.atTop (nhds 0) := + (crossing_summable W i).tendsto_atTop_zero + +end CriticalHoneycomb.FiniteContinuation + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ControlledTransforms.lean b/lean/OAI/Combinatorics/HoneycombChords/ControlledTransforms.lean new file mode 100644 index 0000000000000000000000000000000000000000..67fe0114b1b07a863aa7d92e55daa1a15ba1ba04 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ControlledTransforms.lean @@ -0,0 +1,306 @@ +import OAI.Combinatorics.HoneycombChords.TransformSurjectivity + +namespace OAI + +/-! Exponential control, differentiation under the integral, and fusion identities. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real MeasureTheory Filter Topology + +lemma sinh_le_mul_exp (x : ℝ) : + Real.sinh x ≤ x * Real.exp x := by + have h := mul_le_mul_of_nonneg_left (Real.add_one_le_exp (-2*x)) (Real.exp_pos x).le + rw [← Real.exp_add, show x+(-2*x) = -x by ring] at h + rw [Real.sinh_eq] + nlinarith + +lemma zG_norm_le (m : ℝ) {z : ℝ} (hz : 0 < z) : + ‖zG m z‖ ≤ |m| * Real.exp (|m| * z) := by + simp only [zG,Complex.norm_real,Real.norm_eq_abs,abs_div,Real.abs_sinh,abs_mul,abs_of_pos hz] + apply (div_le_iff₀ hz).mpr + have h := sinh_le_mul_exp (|m| * z) + nlinarith + +lemma power_le_one_add {z : ℝ} (hz : 0 ≤ z) {j d : ℕ} (hjd : j ≤ d) : + z^j ≤ 1+z^d := by + by_cases h : z ≤ 1 + · exact (pow_le_one₀ hz h).trans (by linarith [pow_nonneg hz d]) + · have hle : z^j ≤ z^d := pow_le_pow_right₀ (by linarith : 1 ≤ z) hjd + linarith + +def ControlledDensity (c : ℝ) (d : ℕ) (f : ℝ → ℂ) : Prop := + Measurable f ∧ ∃ A : ℝ, 0 ≤ A ∧ ∀ z, 0 < z → + ‖f z‖ ≤ A*(1+z^d)*Real.exp (c*z) + +lemma ControlledDensity.zero (c : ℝ) (d : ℕ) : ControlledDensity c d 0 := by + refine ⟨measurable_const,0,le_rfl,?_⟩ + intros; simp +lemma ControlledDensity.add {c : ℝ} {d : ℕ} {f g : ℝ → ℂ} + (hf : ControlledDensity c d f) (hg : ControlledDensity c d g) : ControlledDensity c d (f+g) := by + rcases hf with ⟨hf,A,hA,hfA⟩ + rcases hg with ⟨hg,B,hB,hgB⟩ + refine ⟨hf.add hg,A+B,add_nonneg hA hB,?_⟩ + intro z hz + have h := (norm_add_le (f z) (g z)).trans (add_le_add (hfA z hz) (hgB z hz)) + simpa only [Pi.add_apply,add_mul] using h +lemma ControlledDensity.smul {c : ℝ} {d : ℕ} {f : ℝ → ℂ} + (hf : ControlledDensity c d f) (a : ℂ) : ControlledDensity c d (a • f) := by + rcases hf with ⟨hf,A,hA,hfA⟩ + refine ⟨hf.const_smul a,‖a‖*A,mul_nonneg (norm_nonneg a) hA,?_⟩ + intro z hz + simpa only [Pi.smul_apply,norm_smul,mul_assoc] using + mul_le_mul_of_nonneg_left (hfA z hz) (norm_nonneg a) + +lemma zMonomial_controlled (m : ℝ) {d j : ℕ} (hj : 2*j ≤ d) : + ControlledDensity |m| d (zMonomial j) := by + refine ⟨by unfold zMonomial; fun_prop,1,by norm_num,?_⟩ + intro z hz + have hp := power_le_one_add hz.le hj + have he : 1 ≤ Real.exp (|m| * z) := Real.one_le_exp (mul_nonneg (abs_nonneg m) hz.le) + simp only [zMonomial,Complex.norm_real,Real.norm_eq_abs,abs_pow,abs_of_pos hz,one_mul,← pow_mul] + exact hp.trans (le_mul_of_one_le_right (by positivity) he) + +lemma zCoshJet_controlled (m : ℝ) {d j : ℕ} (hj : j ≤ d) : + ControlledDensity |m| d (zCoshJet m j) := by + refine ⟨by unfold zCoshJet hypJet; fun_prop,1,by norm_num,?_⟩ + intro z hz + simp only [zCoshJet,Complex.norm_real,Real.norm_eq_abs,abs_mul,abs_pow,abs_of_pos hz,one_mul] + have hh := hypJet_abs_le (j+1) (m*z) + rw [abs_mul,abs_of_pos hz] at hh + exact mul_le_mul (power_le_one_add hz.le hj) hh (abs_nonneg _) (by positivity) + +lemma zG_controlled (m : ℝ) (d : ℕ) : ControlledDensity |m| d (zG m) := by + refine ⟨by unfold zG; fun_prop,|m|,abs_nonneg m,?_⟩ + intro z hz + apply (zG_norm_le m hz).trans + exact mul_le_mul_of_nonneg_right + (le_mul_of_one_le_right (abs_nonneg m) (by linarith [pow_nonneg hz.le d])) (Real.exp_pos _).le + +lemma zDensity_controlled {m : ℝ} {N : ℕ} {f : ℝ → ℂ} (hf : f ∈ zDensity m N) : + ControlledDensity |m| (2*N) f := by + induction hf using Submodule.span_induction with + | mem f hf => + rcases hf with ((⟨j,rfl⟩ | ⟨j,rfl⟩) | rfl) + · exact zMonomial_controlled m (by have := j.isLt; omega) + · exact zCoshJet_controlled m (by have := j.isLt; omega) + · exact zG_controlled m (2*N) + | zero => exact ControlledDensity.zero _ _ + | add f g hf hg hfi hgi => exact hfi.add hgi + | smul a f hf hfi => exact hfi.smul a + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real MeasureTheory Filter Topology + +noncomputable def weightedJet (f : ℝ → ℂ) (j : ℕ) (u z : ℝ) : ℂ := + f z * ((z^j*hypJet (j+1) (u*z) : ℝ) : ℂ) * z / (Real.sinh (Real.pi*z/2) : ℂ) +noncomputable def weightedIntegral (f : ℝ → ℂ) (j : ℕ) (u : ℝ) : ℂ := + ∫ z in Set.Ioi (0:ℝ), weightedJet f j u z +noncomputable def jetBound (A a : ℝ) (d j : ℕ) (z : ℝ) : ℝ := + A*(z^(j+1)+z^(d+j+1))*Real.exp (a*z)/Real.sinh (Real.pi*z/2) + +lemma weightedJet_zero (f : ℝ → ℂ) (u z : ℝ) : weightedJet f 0 u z = zKernel f u z := by + simp only [weightedJet,zKernel,pow_zero,one_mul,Nat.zero_add,hypJet_one] +lemma weightedIntegral_zero (f : ℝ → ℂ) (u : ℝ) : weightedIntegral f 0 u = zTransform f u := by + simp only [weightedIntegral,zTransform,weightedJet_zero] + +lemma weightedJet_hasDerivAt (f : ℝ → ℂ) (j : ℕ) (u z : ℝ) : + HasDerivAt (fun t => weightedJet f j t z) (weightedJet f (j+1) u z) u := by + have hr := ((hypJet_hasDerivAt (j+1) (u*z)).comp u + ((hasDerivAt_id u).mul_const z)).const_mul (z^j) + have hd := (hr.ofReal_comp.const_mul (f z)).mul_const (z:ℂ) + have he := hd.div_const (Real.sinh (Real.pi*z/2):ℂ) + convert he using 1 <;> try rfl + dsimp [weightedJet] + push_cast + rw [pow_succ] + ring + +lemma weightedJet_measurable {f : ℝ → ℂ} (hf : Measurable f) (j : ℕ) (u : ℝ) : + Measurable (weightedJet f j u) := by + unfold weightedJet hypJet + fun_prop + +lemma jetBound_integrable (A : ℝ) {a : ℝ} (ha : 0 ≤ a) (ha' : a < Real.pi/2) (d j : ℕ) : + IntegrableOn (jetBound A a d j) (Set.Ioi 0) := by + have hi := ((polynomial_kernel_integrable j ha ha').add + (polynomial_kernel_integrable (d+j) ha ha')).const_mul A + change Integrable _ _ + convert hi using 1 + ext z + dsimp [jetBound] + ring + +lemma weightedJet_norm_le {f : ℝ → ℂ} {c A a z u : ℝ} {d : ℕ} + (hA : 0 ≤ A) (hz : 0 < z) + (hf : ‖f z‖ ≤ A*(1+z^d)*Real.exp (c*z)) (ha : c+|u| ≤ a) (j : ℕ) : + ‖weightedJet f j u z‖ ≤ jetBound A a d j z := by + have hz0 := hz.le + have hden : 0 ≤ Real.sinh (Real.pi*z/2) := Real.sinh_nonneg_iff.mpr (by positivity) + have hh := hypJet_abs_le (j+1) (u*z) + rw [abs_mul,abs_of_pos hz] at hh + simp only [weightedJet, norm_div, norm_mul,Complex.norm_real,Real.norm_eq_abs, + abs_pow,abs_of_pos hz,abs_of_nonneg hden] + calc + ‖f z‖ * (z^j * |hypJet (j+1) (u*z)|) * z / Real.sinh (Real.pi*z/2) + ≤ (A*(1+z^d)*Real.exp (c*z)) * (z^j*Real.exp (|u| * z)) * z / Real.sinh (Real.pi*z/2) := by + gcongr + _ = A*(z^(j+1)+z^(d+j+1))*Real.exp ((c+|u|)*z)/Real.sinh (Real.pi*z/2) := by + simp only [add_mul,Real.exp_add,pow_add,pow_one] + ring + _ ≤ jetBound A a d j z := by + dsimp [jetBound] + gcongr + +lemma weightedJet_integrable {f : ℝ → ℂ} {c : ℝ} {d : ℕ} + (hf : ControlledDensity c d f) (hc : 0 ≤ c) {u : ℝ} (hu : c+|u| < Real.pi/2) (j : ℕ) : + IntegrableOn (weightedJet f j u) (Set.Ioi 0) := by + obtain ⟨A,hA,hfA⟩ := hf.2 + apply (jetBound_integrable A (add_nonneg hc (abs_nonneg u)) hu d j).mono' + · exact (weightedJet_measurable hf.1 j u).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + exact weightedJet_norm_le hA hz (hfA z hz) le_rfl j + +lemma weightedIntegral_hasDerivAt {f : ℝ → ℂ} {c : ℝ} {d : ℕ} + (hf : ControlledDensity c d f) (hc : 0 ≤ c) {u : ℝ} (hu : c+|u| < Real.pi/2) (j : ℕ) : + HasDerivAt (weightedIntegral f j) (weightedIntegral f (j+1) u) u := by + obtain ⟨A,hA,hfA⟩ := hf.2 + let a := (Real.pi/2+(c+|u|))/2 + have ha : c+|u| < a := by dsimp [a]; linarith + have ha0 : 0 ≤ a := (add_nonneg hc (abs_nonneg u)).trans ha.le + have ha' : a < Real.pi/2 := by dsimp [a]; linarith + let s := {t : ℝ | c+|t| < a} + have hs : s ∈ 𝓝 u := (isOpen_lt (continuous_const.add continuous_abs) continuous_const).mem_nhds ha + exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le hs + (Filter.Eventually.of_forall (fun t => (weightedJet_measurable hf.1 j t).aestronglyMeasurable)) + (weightedJet_integrable hf hc hu j) (weightedJet_measurable hf.1 (j+1) u).aestronglyMeasurable + (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + intro t ht + exact weightedJet_norm_le hA hz (hfA z hz) (le_of_lt ht) (j+1)) + (jetBound_integrable A ha0 ha' d (j+1)) + (ae_of_all _ (fun z t _ => weightedJet_hasDerivAt f j t z))).2 + +lemma weightedIntegral_iteratedDeriv {f : ℝ → ℂ} {c : ℝ} {d : ℕ} + (hf : ControlledDensity c d f) (hc : 0 ≤ c) {u : ℝ} (hu : c+|u| < Real.pi/2) (j : ℕ) : + iteratedDeriv j (zTransform f) u = weightedIntegral f j u := by + induction j generalizing u with + | zero => exact (weightedIntegral_zero f u).symm + | succ j ih => + have hn : ∀ᶠ t in 𝓝 u, c+|t| < Real.pi/2 := + (isOpen_lt (continuous_const.add continuous_abs) continuous_const).mem_nhds hu + have he : iteratedDeriv j (zTransform f) =ᶠ[𝓝 u] weightedIntegral f j := + hn.mono (fun t ht => ih ht) + rw [iteratedDeriv_succ,he.deriv_eq] + exact (weightedIntegral_hasDerivAt hf hc hu j).deriv + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real MeasureTheory Filter Topology + +noncomputable def zD (m z : ℝ) : ℂ := (2 * Real.cosh (m*z) - 1 : ℝ) + +lemma zD_norm_le (m : ℝ) {z : ℝ} (hz : 0 ≤ z) : + ‖zD m z‖ ≤ 3 * Real.exp (|m| * z) := by + have hh := hypJet_abs_le 1 (m*z) + rw [hypJet_one, abs_mul, abs_of_nonneg hz] at hh + have hcosh := Real.one_le_cosh (m*z) + have he : 1 ≤ Real.exp (|m| * z) := Real.one_le_exp (mul_nonneg (abs_nonneg m) hz) + simp only [zD, Complex.norm_real, Real.norm_eq_abs] + rw [abs_of_nonneg (by linarith : 0 ≤ 2*Real.cosh (m*z)-1)] + have hc : Real.cosh (m*z) ≤ Real.exp (|m| * z) := (le_abs_self _).trans hh + linarith + +lemma ControlledDensity.mul_zD {f : ℝ → ℂ} {c : ℝ} {d : ℕ} + (hf : ControlledDensity c d f) (m : ℝ) : + ControlledDensity (c+|m|) d (fun z => zD m z * f z) := by + rcases hf with ⟨hf,A,hA,hfA⟩ + refine ⟨?_,3*A,by positivity,?_⟩ + · exact (by unfold zD; fun_prop : Measurable (zD m)).mul hf + · intro z hz + calc + ‖zD m z * f z‖ = ‖zD m z‖ * ‖f z‖ := norm_mul _ _ + _ ≤ (3*Real.exp (|m| * z)) * (A*(1+z^d)*Real.exp (c*z)) := + mul_le_mul (zD_norm_le m hz.le) (hfA z hz) (norm_nonneg _) (by positivity) + _ = (3*A)*(1+z^d)*Real.exp ((c+|m|)*z) := by + rw [add_mul, Real.exp_add]; ring + +lemma zKernel_fusion (f : ℝ → ℂ) (m u z : ℝ) : + zKernel f (u-m) z + zKernel f (u+m) z - zKernel f u z = + zKernel (fun z => zD m z * f z) u z := by + simp only [zKernel,zD,sub_mul,add_mul,Real.cosh_sub,Real.cosh_add] + push_cast + ring + +lemma zTransform_fusion {f : ℝ → ℂ} {c : ℝ} {d : ℕ} + (hf : ControlledDensity c d f) (hc : 0 ≤ c) (m u : ℝ) + (hu : c+|u|+|m| < Real.pi/2) : + zTransform f (u-m) + zTransform f (u+m) - zTransform f u = + zTransform (fun z => zD m z * f z) u := by + have h₁ : c+|u-m| < Real.pi/2 := by linarith [abs_sub u m] + have h₂ : c+|u+m| < Real.pi/2 := by linarith [abs_add_le u m] + have h₃ : c+|u| < Real.pi/2 := by linarith [abs_nonneg m] + have hi₁ := weightedJet_integrable hf hc h₁ 0 + have hi₂ := weightedJet_integrable hf hc h₂ 0 + have hi₃ := weightedJet_integrable hf hc h₃ 0 + have he (t : ℝ) : weightedJet f 0 t = zKernel f t := funext (weightedJet_zero f t) + rw [he] at hi₁ hi₂ hi₃ + unfold zTransform + rw [← integral_add hi₁ hi₂] + have his : IntegrableOn (fun z => zKernel f (u-m) z + zKernel f (u+m) z) (Set.Ioi 0) := hi₁.add hi₂ + rw [← integral_sub his hi₃] + apply integral_congr_ae + exact ae_of_all _ (fun z => zKernel_fusion f m u z) + +noncomputable def integralInterpolant (ρ : ℂ) (f : ℝ → ℂ) (u : ℝ) : ℂ := + 4*(Real.cos (2*u):ℂ)+ρ+zTransform f u +noncomputable def integralFusion (m : ℝ) (ρ : ℂ) (f : ℝ → ℂ) (u : ℝ) : ℂ := + 4*(2*(Real.cos (2*m):ℂ)-1)*(Real.cos (2*u):ℂ)+ρ+ + zTransform (fun z => zD m z*f z) u + +lemma integralInterpolant_fusion {f : ℝ → ℂ} {c : ℝ} {d : ℕ} + (hf : ControlledDensity c d f) (hc : 0 ≤ c) (m u : ℝ) (ρ : ℂ) + (hu : c+|u|+|m| < Real.pi/2) : + integralInterpolant ρ f (u-m) + integralInterpolant ρ f (u+m) - integralInterpolant ρ f u = + integralFusion m ρ f u := by + have ht := zTransform_fusion hf hc m u hu + dsimp [integralInterpolant,integralFusion] + rw [show (2:ℝ)*(u-m)=2*u-2*m by ring, + show (2:ℝ)*(u+m)=2*u+2*m by ring,Real.cos_sub, Real.cos_add] + push_cast + linear_combination ht + +lemma integralInterpolant_fusion_eventually {f : ℝ → ℂ} {c : ℝ} {d : ℕ} + (hf : ControlledDensity c d f) (hc : 0 ≤ c) (m u : ℝ) (ρ : ℂ) + (hu : c+|u|+|m| < Real.pi/2) : + (fun t => integralInterpolant ρ f (t-m)+integralInterpolant ρ f (t+m)-integralInterpolant ρ f t) + =ᶠ[𝓝 u] integralFusion m ρ f := by + have hn : ∀ᶠ t in 𝓝 u, c+|t|+|m| < Real.pi/2 := + (isOpen_lt ((continuous_const.add continuous_abs).add continuous_const) continuous_const).mem_nhds hu + exact hn.mono (fun t ht => integralInterpolant_fusion hf hc m t ρ ht) + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/EntireCosine.lean b/lean/OAI/Combinatorics/HoneycombChords/EntireCosine.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fb22adb588fd8867c474c1d7cf6710a27341fce --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/EntireCosine.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.HoneycombChords.FiniteFunctional +import OAI.Combinatorics.HoneycombChords.BetaKernel + +namespace OAI + +/-! Calculus of the entire cosine continuation on the real line. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional +open Real Filter Topology MeasureTheory +open Analytic +lemma C_sq (t : ℝ) {z : ℝ} (hz : 0 ≤ z) : C t (z^2)=(Real.cosh (t*z):ℂ) := by + simp [C,sq_nonneg,Real.sqrt_sq hz] +lemma C_zero (t : ℝ) : C t 0=1 := by simp [C] +lemma C_neg_four (t : ℝ) : C t (-4)=(Real.cos (2*t):ℂ) := by + norm_num [C,mul_comm] +lemma C_contDiff (x : ℝ) : ContDiff ℝ ⊤ (fun t => C t x) := by + unfold C + split_ifs + · exact Complex.ofRealCLM.contDiff.comp (show ContDiff ℝ ⊤ (fun t : ℝ => Real.cosh (t*Real.sqrt x)) by fun_prop) + · exact Complex.ofRealCLM.contDiff.comp (show ContDiff ℝ ⊤ (fun t : ℝ => Real.cos (t*Real.sqrt (-x))) by fun_prop) +lemma hypJet_succ_zero (j : ℕ) : hypJet (j+1) 0=(1+(-1:ℝ)^j)/2 := by + simp only [hypJet,Real.exp_zero,neg_zero,mul_one,pow_succ];ring +lemma C_sq_jet (j : ℕ) (t : ℝ) {z : ℝ} (hz : 0 ≤ z) : + iteratedDeriv j (fun u => C u (z^2)) t=(z^j*hypJet (j+1) (t*z):ℝ) := by + induction j generalizing t with + | zero => simp [C_sq _ hz] + | succ j ih => + rw [iteratedDeriv_succ,show iteratedDeriv j (fun u => C u (z^2))= + (fun u => ((z^j*hypJet (j+1) (u*z):ℝ):ℂ)) from funext ih] + have hd := ((hypJet_hasDerivAt (j+1) (t*z)).comp t ((hasDerivAt_id t).mul_const z)).const_mul (z^j) + have he:=hd.ofReal_comp.deriv + change deriv (fun u => ((z^j*hypJet (j+1) (u*z):ℝ):ℂ)) t = _ at he + rw [he] + congr 1 + rw [pow_succ] + ring +lemma angle_pos : 0 < angle := by unfold angle;positivity +lemma D_sq {z : ℝ} (hz : 0 ≤ z) : D (z^2)=(2*Real.cosh (angle*z)-1:ℝ) := by + simp only [D,C_sq _ hz];push_cast;rfl +lemma D_sq_ne_zero {z : ℝ} (hz : 0 ≤ z) : D (z^2) ≠ 0 := by + rw [D_sq hz] + apply Complex.ofReal_ne_zero.mpr + have h:=Real.one_le_cosh (angle*z) + linarith +lemma g_sq {z : ℝ} (hz : 0 < z) : g (z^2)=(Real.sinh (angle*z)/z:ℝ) := by + unfold g + simp only [C_sq _ hz.le] + rw [intervalIntegral.integral_ofReal] + congr 1 + have hd (t : ℝ) : HasDerivAt (fun t => Real.sinh (t*z)/z) (Real.cosh (t*z)) t := by + convert (((Real.hasDerivAt_sinh (t*z)).comp t ((hasDerivAt_id t).mul_const z)).div_const z) using 1 <;> try rfl + field_simp + have he:=intervalIntegral.integral_eq_sub_of_hasDerivAt (a:=0) (b:=angle) (fun t _ => hd t) + ((show Continuous (fun t : ℝ => Real.cosh (t*z)) by fun_prop).intervalIntegrable 0 angle) + simpa using he +end CriticalHoneycomb.FiniteFunctional + +end + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +lemma cosineKernelJet_eq_C {b : ℝ} (hb : 0 ≤ b) (x : ℝ) : + (cosineKernelJet 0 0 b x:ℂ)=C (Real.sqrt b) x := by + by_cases hx : 0 ≤ x + · rw [cosineKernelJet_zero_zero_cosh hb hx,C,ite_eq_left hx] + · rw [cosineKernelJet_zero_zero_cos hb (le_of_not_ge hx),C,ite_eq_right hx] + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/FamilyGram.lean b/lean/OAI/Combinatorics/HoneycombChords/FamilyGram.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d13e4fe6b276cd39f4da22a54e347c728033af1 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/FamilyGram.lean @@ -0,0 +1,1112 @@ +import OAI.Combinatorics.HoneycombChords.PositivePencils +import OAI.Combinatorics.HoneycombChords.NewtonKernel + +namespace OAI + +/-! Positive function families, Gram compression, basis changes, and knot continuity. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +noncomputable def zeroJetLift {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) : Fin (n+1) → ℝ := + Fin.cons (-(∑ i,a i*cosineKernelJet (nodalOrder b (i.val+1)) 0 (b (i.val+1)) 0)) a +lemma zeroJetLift_eq {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) (hb : b 0=0) (x : ℝ) : + jetCombination b (zeroJetLift b a) x=zeroJetCombination b a x := by + unfold jetCombination zeroJetLift zeroJetCombination zeroJet + rw [Fin.sum_univ_succ] + simp only [Fin.cons_zero,Fin.cons_succ,Fin.val_zero,Fin.val_succ,jet_first_constant b hb,mul_one,mul_sub,sum_sub_distrib] + ring +lemma zeroJetLift_ne_zero {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) (ha : a ≠ 0) : zeroJetLift b a ≠ 0 := by + intro h + apply ha + funext i + exact congrFun h i.succ +lemma zeroJetCombination_zero {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) : + zeroJetCombination b a 0=0 := by simp [zeroJetCombination,zeroJet] +lemma zeroJetCombination_continuous {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) : + Continuous (zeroJetCombination b a) := by + apply continuous_finsetSum + intro i _ + exact continuous_const.mul ((cosineKernelJet_contDiff_right _ _ _ 0).continuous.sub continuous_const) +lemma zeroJetCombination_zeros_card_lt {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hb0 : ∀ i : Fin (n+1),0 ≤ b i) + (hfirst : b 0=0) (ha : a ≠ 0) (s : Finset ℝ) + (hs : ∀ x∈s,0(lt_irrefl 0 (hs 0 h).1) + have h:=jetCombination_zeros_card_lt b (zeroJetLift b a) hb hb0 (zeroJetLift_ne_zero b a ha) (insert 0 s) (by + intro x hx + rcases mem_insert.mp hx with rfl | hx + · rw [zeroJetLift_eq b a hfirst,zeroJetCombination_zero];exact ⟨le_rfl,rfl⟩ + · exact ⟨(hs x hx).1.le,by rw [zeroJetLift_eq b a hfirst];exact (hs x hx).2⟩) + rw [card_insert_of_notMem h0] at h + omega +lemma zeroJetCombination_finite_zeros {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hb0 : ∀ i : Fin (n+1),0 ≤ b i) + (hfirst : b 0=0) (ha : a ≠ 0) : + {x : ℝ | 0zeroJet b i (x j) +lemma zeroJetEvaluation_det {n : ℕ} (b : ℕ → ℝ) (x : Fin n → ℝ) (hf : b 0=0) : + (zeroJetEvaluation b x).det=(jetEvaluation b (Fin.cons 0 x)).det := by + let B:=jetEvaluation b (Fin.cons 0 x) + let A : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := + .of (fun i j=>Fin.cases 1 (fun i=>zeroJet b i ((Fin.cons 0 x : Fin (n+1) → ℝ) j)) i) + let c : Fin (n+1) → ℝ := Fin.cons 0 (fun i : Fin n=> -cosineKernelJet (nodalOrder b (i.val+1)) 0 (b (i.val+1)) 0) + have he : A.det=B.det := by + apply Matrix.det_eq_of_forall_row_eq_smul_add_const c 0 (by simp [c]) + intro i j + refine Fin.cases ?_ (fun i=>?_) i + · simp [A,B,c,jetEvaluation,jet_first_constant b hf] + · simp only [A,B,c,Matrix.of_apply,Fin.cases_succ,Fin.cons_succ,jetEvaluation,Fin.val_succ,Fin.val_zero,jet_first_constant b hf,mul_one] + dsimp [zeroJet] + ring + rw [Matrix.det_succ_column_zero,Fin.sum_univ_succ] at he + have hsum : (∑ i : Fin n,(-1:ℝ)^(i.succ.val)*A i.succ 0*(A.submatrix i.succ.succAbove Fin.succ).det)=0 := by + apply sum_eq_zero + intro i _ + simp [A,zeroJet] + rw [hsum,add_zero] at he + have he' : (Matrix.of (fun i j : Fin n=>zeroJet b i (x j))).det=(jetEvaluation b (Fin.cons 0 x)).det := by + simpa [A,B,Matrix.submatrix] using he + rw [show Matrix.of (fun i j : Fin n=>zeroJet b i (x j))=zeroJetEvaluation b x from by ext i j;rfl] at he' + exact he' +lemma zeroJetEvaluation_det_pos {n : ℕ} (b : ℕ → ℝ) (x : Fin n → ℝ) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hb0 : ∀ i : Fin (n+1),0 ≤ b i) + (hf : b 0=0) (hx : StrictMono x) (hx0 : ∀ i,0?_) i + · refine Fin.cases (fun h=>False.elim (lt_irrefl _ h)) (fun j _=>hx0 j) j + · refine Fin.cases (fun h=>False.elim (Fin.not_lt_zero _ h)) (fun j h=>hx (Fin.succ_lt_succ_iff.mp h)) j + · exact hb0 + · exact Fin.cases le_rfl (fun i=>(hx0 i).le) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv +/-- Positivity of the actual ordered evaluation determinant. Used below for +both regular and zero-at-origin jet bases, including the mixed second chain. -/ +def PositiveEvaluation {n : ℕ} (F : Fin n → ℝ → ℝ) : Prop := + ∀ x : Fin n → ℝ,StrictMono x → (∀ i,0b i)) (hb0 : ∀ i : Fin n,0≤b i) : + PositiveEvaluation (fun i : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i)) := by + intro x hx hx0 + exact jetEvaluation_det_pos b x hb hx hb0 (fun i=>(hx0 i).le) +lemma zeroJet_positiveEvaluation {n : ℕ} (b : ℕ → ℝ) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hb0 : ∀ i : Fin (n+1),0≤b i) (hfirst : b 0=0) : + PositiveEvaluation (fun i : Fin n=>zeroJet b i) := by + intro x hx hx0 + exact zeroJetEvaluation_det_pos b x hb hb0 hfirst hx hx0 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Equiv MeasureTheory Filter +noncomputable def familyGram {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) : Matrix (Fin n) (Fin n) ℝ := + fun i j=>∫ p in Set.Ioi (0:ℝ),F i (p^2)* + G j (p^2)*w p +noncomputable def familyPointDensity {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) (p : Fin n → ℝ) : ℝ := + (∏ i,w (p i))*(evaluationMatrix F (fun i=>(p i)^2)).det*(evaluationMatrix G (fun i=>(p i)^2)).det +lemma weighted_family_evaluation {n : ℕ} (w : ℝ → ℝ) (F : Fin n → ℝ → ℝ) (p : Fin n → ℝ) : + (evaluationMatrix (fun i : Fin n=>fun q=>F i (q^2)*w q) p).det= + (∏ i,w (p i))*(evaluationMatrix F (fun i=>(p i)^2)).det := by + change (Matrix.of (fun i j : Fin n=>F i ((p j)^2)*w (p j))).det=_ + have he : Matrix.of (fun i j : Fin n=>F i ((p j)^2)*w (p j))= + Matrix.of (fun i j : Fin n=>w (p j)*F i ((p j)^2)) := by + ext i j + exact mul_comm _ _ + rw [he] + exact Matrix.det_mul_row (fun j=>w (p j)) (evaluationMatrix F (fun i=>(p i)^2)) +lemma family_gram_andreief {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>F i (p^2)* + G j (p^2)*w p) (Set.Ioi 0)) : + Integrable (familyPointDensity (n:=n) w F G) (Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ)))) ∧ + (∫ p,familyPointDensity (n:=n) w F G p ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))))= + Fintype.card (Perm (Fin n))*(familyGram (n:=n) w F G).det := by + let FF : Fin n → ℝ → ℝ := fun i p=>F i (p^2)*w p + let GG : Fin n → ℝ → ℝ := fun i p=>G i (p^2) + have hFG i j : Integrable (fun p=>FF i p*GG j p) (volume.restrict (Set.Ioi (0:ℝ))) := by + apply (hi i j).congr + filter_upwards with p + dsimp [FF,GG] + ring + have he p : (evaluationMatrix FF p).det*(evaluationMatrix GG p).det=familyPointDensity w F G p := by + rw [show (evaluationMatrix FF p).det=(∏ i,w (p i))*(evaluationMatrix F (fun i=>(p i)^2)).det from weighted_family_evaluation w F p] + rfl + have hgram : gramMatrix (volume.restrict (Set.Ioi (0:ℝ))) FF GG=familyGram w F G := by + ext i j + apply integral_congr_ae + filter_upwards with p + dsimp [FF,GG] + ring + constructor + · simpa only [he] using integrable_det_evaluation_product _ FF GG hFG + · simpa only [he,hgram] using andreief _ FF GG hFG +lemma familyPointDensity_pos {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) (p : Fin n → ℝ) + (hF : PositiveEvaluation F) (hG : PositiveEvaluation G) + (hp : ∀ i,0

(p i)^2) := by + intro i j hij + apply hpi + exact (sq_eq_sq₀ (hp i).le (hp j).le).mp hij + rw [familyPointDensity,mul_assoc] + exact mul_pos (prod_pos (fun i _=>hw _ (hp i))) + (evaluation_det_product_pos F G hF hG _ hin (fun i=>sq_pos_of_pos (hp i))) +lemma familyGram_det_pos {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (hF : PositiveEvaluation F) (hG : PositiveEvaluation G) (hw : ∀ q,0F i (p^2)* + G j (p^2)*w p) (Set.Ioi 0)) : + 0 < (familyGram (n:=n) w F G).det := by + let μ : Measure (Fin n → ℝ) := Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))) + obtain ⟨hI,hA⟩ := family_gram_andreief w F G hi + have hae : ∀ᵐ p ∂μ,∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) (i:=i)).eventually (ae_restrict_mem measurableSet_Ioi) + have hnn : 0 ≤ᵐ[μ] familyPointDensity w F G := by + filter_upwards [hae] with p hp + dsimp only [Pi.zero_apply] + rw [familyPointDensity,mul_assoc] + exact mul_nonneg (prod_nonneg (fun i _=>(hw _ (hp i)).le)) + (evaluation_det_product_nonneg F G hF hG _ (fun i=>sq_pos_of_pos (hp i))) + let box : Set (Fin n → ℝ) := Set.pi Set.univ (fun i=>Set.Ioo ((i:ℝ)+1) ((i:ℝ)+3/2)) + have hbox : box ⊆ Function.support (familyPointDensity w F G) := by + intro p hp + have hp' (i : Fin n) : (i:ℝ)+1

volume.restrict (Set.Ioi (0:ℝ))) (Set.pi Set.univ _) + rw [Measure.pi_pi] + apply pos_iff_ne_zero.mpr + apply Finset.prod_ne_zero_iff.mpr + intro i _ + apply ne_of_gt + rw [Measure.restrict_apply measurableSet_Ioo,Set.inter_eq_left.mpr,Real.volume_Ioo] + · exact ENNReal.ofReal_pos.mpr (by norm_num) + · intro p hp + have hn : (0:ℝ) ≤ i := Nat.cast_nonneg _ + exact lt_trans (by linarith) hp.1 + have hpos : 0<∫ p,familyPointDensity w F G p ∂μ := + (integral_pos_iff_support_of_nonneg_ae hnn hI).mpr (hboxpos.trans_le (measure_mono hbox)) + rw [hA] at hpos + exact (mul_pos_iff.mp hpos).elim (fun h=>h.2) (fun h=>False.elim (not_lt_of_ge (Nat.cast_nonneg _) h.1)) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +/-- Quadratic-form bounds give determinant bounds with the exact dimension. +This is the finite-dimensional stability estimate required in the polynomial +compression step of strip-asymptotics.tex:83--84. -/ +theorem determinant_quotient_of_quadratic_bounds {n : ℕ} + (A B : Matrix (Fin n) (Fin n) ℝ) (hA:A.IsHermitian) (hB:B.PosDef) + {l u:ℝ} (hl:0≤l) + (hlo:∀ v:Fin n→ℝ,l*(v ⬝ᵥ (B *ᵥ v))≤v ⬝ᵥ (A *ᵥ v)) + (hup:∀ v:Fin n→ℝ,v ⬝ᵥ (A *ᵥ v)≤u*(v ⬝ᵥ (B *ᵥ v))) : + l^n≤A.det/B.det ∧ A.det/B.det≤u^n := by + obtain ⟨P,e,hP,hPB,hPA⟩:=positive_pencil_normal_form A B hA hB + have hquad (T:Matrix (Fin n) (Fin n) ℝ) (v:Fin n→ℝ) : + (P *ᵥ v) ⬝ᵥ (T *ᵥ (P *ᵥ v))=v ⬝ᵥ ((Pᴴ*T*P) *ᵥ v) := by + simp only [Matrix.conjTranspose_eq_transpose_of_trivial,←mulVec_mulVec] + exact (dotProduct_comm _ _).trans (Matrix.dotProduct_transpose_mulVec P v (T *ᵥ (P *ᵥ v))).symm + have he (i:Fin n):l≤e i ∧ e i≤u := by + have ha:=hlo (P *ᵥ Pi.single i 1) + have hb:=hup (P *ᵥ Pi.single i 1) + rw [hquad,hquad,hPB,hPA] at ha hb + simpa [Matrix.mulVec_diagonal] using And.intro ha hb + have hdA:=congrArg Matrix.det hPA + have hdB:=congrArg Matrix.det hPB + simp only [Matrix.det_mul,Matrix.det_conjTranspose,star_trivial,Matrix.det_diagonal,Matrix.det_one] at hdA hdB + have hratio:A.det/B.det=∏ i,e i := by + apply (div_eq_iff hB.det_pos.ne').mpr + nlinarith [congrArg (fun x:ℝ=>x*B.det) hdA,congrArg (fun x:ℝ=>x*A.det) hdB] + rw [hratio] + constructor + · calc + l^n=∏ _i:Fin n,l := by simp + _≤∏ i,e i:=prod_le_prod₀ (fun _ _=>hl) (fun i _=>(he i).1) + · calc + (∏ i,e i)≤∏ _i:Fin n,u:=prod_le_prod₀ (fun i _=>hl.trans (he i).1) (fun i _=>(he i).2) + _=u^n := by simp +/-- Loewner monotonicity of determinant, with a positive definite base. -/ +theorem determinant_mono_of_positive_base {n:ℕ} + (A B:Matrix (Fin n) (Fin n) ℝ) (hA:A.IsHermitian) (hB:B.PosDef) + (h:∀ v:Fin n→ℝ,v ⬝ᵥ (B *ᵥ v)≤v ⬝ᵥ (A *ᵥ v)) : B.det≤A.det := by + obtain ⟨P,e,hP,hPB,hPA⟩:=positive_pencil_normal_form A B hA hB + have hlo:∀ v:Fin n→ℝ,(1:ℝ)*(v ⬝ᵥ (B *ᵥ v))≤v ⬝ᵥ (A *ᵥ v) := by simpa using h + have hn:A.det/B.det≥1 := by + have he (i:Fin n):1≤e i := by + have hh:=h (P *ᵥ Pi.single i 1) + have hquad (T:Matrix (Fin n) (Fin n) ℝ) (v:Fin n→ℝ) : + (P *ᵥ v) ⬝ᵥ (T *ᵥ (P *ᵥ v))=v ⬝ᵥ ((Pᴴ*T*P) *ᵥ v) := by + simp only [Matrix.conjTranspose_eq_transpose_of_trivial,←mulVec_mulVec] + exact (dotProduct_comm _ _).trans (Matrix.dotProduct_transpose_mulVec P v (T *ᵥ (P *ᵥ v))).symm + rw [hquad,hquad,hPB,hPA] at hh + simpa [Matrix.mulVec_diagonal] using hh + have ha:=congrArg Matrix.det hPA + have hb:=congrArg Matrix.det hPB + simp only [det_mul,det_conjTranspose,star_trivial,det_diagonal,det_one] at ha hb + have heprod:(1:ℝ)≤∏ i,e i := by + calc + 1=∏ _i:Fin n,(1:ℝ) := by simp + _≤∏ i,e i:=prod_le_prod₀ (by intro i _;norm_num) (fun i _=>he i) + apply (le_div_iff₀ hB.det_pos).mpr + have hp:0≤B.det:=hB.det_pos.le + nlinarith [congrArg (fun x:ℝ=>x*B.det) ha,congrArg (fun x:ℝ=>x*A.det) hb,mul_le_mul_of_nonneg_right heprod hp] + simpa only [one_mul] using (le_div_iff₀ hB.det_pos).mp hn +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix +lemma small_error_power_bounds {n:ℕ} {η:ℝ} (hη:0≤η) (hη1:η≤1/2) + (hn:(n:ℝ)*η≤1/2) : + (1:ℝ)/2≤(1-η)^n ∧ (1+η)^n≤2 := by + have hl:(1:ℝ)/2≤(1-η)^n := by + have h:=one_add_mul_le_pow (a:= -η) (by linarith : (-2:ℝ)≤-η) n + simp only [mul_neg,←sub_eq_add_neg] at h + linarith + refine ⟨hl,?_⟩ + have hm:(1+η)^n*(1-η)^n≤1 := by + rw [←mul_pow] + apply pow_le_one₀ (by nlinarith) (by nlinarith [sq_nonneg η]) + have hp:0≤(1+η)^n:=pow_nonneg (by linarith) _ + nlinarith [mul_le_mul_of_nonneg_left hl hp] +/-- Uniform constant-factor determinant stability requires dimension times +quadratic error to be small; this factor cannot be omitted. -/ +theorem determinant_small_relative_error {n:ℕ} + (A D:Matrix (Fin n) (Fin n) ℝ) (hA:A.PosDef) (hD:D.IsHermitian) + {η:ℝ} (hη:0≤η) (hη1:η≤1/2) (hn:(n:ℝ)*η≤1/2) + (herr:∀ v:Fin n→ℝ,|v ⬝ᵥ (D *ᵥ v)-v ⬝ᵥ (A *ᵥ v)|≤η*(v ⬝ᵥ (A *ᵥ v))) : + (1:ℝ)/2≤D.det/A.det ∧ D.det/A.det≤2 := by + have hh:=determinant_quotient_of_quadratic_bounds D A hD hA (l:=1-η) (u:=1+η) + (show 0≤1-η by linarith) + (by intro v;have h:=(abs_le.mp (herr v)).1; linarith) + (by intro v;have h:=(abs_le.mp (herr v)).2; linarith) + have hp:=small_error_power_bounds hη hη1 hn + exact ⟨hp.1.trans hh.1,hh.2.trans hp.2⟩ + +theorem gram_quotient_small_relative_error {n:ℕ} + (A B D E:Matrix (Fin n) (Fin n) ℝ) (hA:A.PosDef) (hB:B.PosDef) + (hD:D.IsHermitian) (hE:E.IsHermitian) + {η:ℝ} (hη:0≤η) (hη1:η≤1/2) (hn:(n:ℝ)*η≤1/2) + (hAD:∀ v:Fin n→ℝ,|v ⬝ᵥ (D *ᵥ v)-v ⬝ᵥ (A *ᵥ v)|≤η*(v ⬝ᵥ (A *ᵥ v))) + (hBE:∀ v:Fin n→ℝ,|v ⬝ᵥ (E *ᵥ v)-v ⬝ᵥ (B *ᵥ v)|≤η*(v ⬝ᵥ (B *ᵥ v))) : + (A.det/B.det)/4≤D.det/E.det ∧ D.det/E.det≤4*(A.det/B.det) := by + obtain ⟨hlD,huD⟩:=determinant_small_relative_error A D hA hD hη hη1 hn hAD + obtain ⟨hlE,huE⟩:=determinant_small_relative_error B E hB hE hη hη1 hn hBE + have hlD':A.det/2≤D.det:=by + have h:=(le_div_iff₀ hA.det_pos).mp hlD + linarith + have huD':D.det≤2*A.det:=(div_le_iff₀ hA.det_pos).mp huD + have hlE':B.det/2≤E.det:=by + have h:=(le_div_iff₀ hB.det_pos).mp hlE + linarith + have huE':E.det≤2*B.det:=(div_le_iff₀ hB.det_pos).mp huE + have hEpos:0e j*C i j + let G:Fin n→Fin m→ℝ:=C + have hi i j:Integrable (fun k=>F i k*G j k) (Measure.count:Measure (Fin m)) := by + exact integrable_count_iff.mpr (by exact (hasSum_fintype _).summable) + have h:=andreief (Measure.count:Measure (Fin m)) F G hi + have hg:gramMatrix (Measure.count:Measure (Fin m)) F G=C*diagonal e*Cᵀ := by + ext i j + rw [Matrix.mul_apply] + simp only [gramMatrix,integral_count,Matrix.mul_diagonal,Matrix.transpose_apply] + apply sum_congr rfl + intro k _ + dsimp [F,G] + ring + have he (f:Fin n→Fin m):(evaluationMatrix F f).det*(evaluationMatrix G f).det= + (∏ i,e (f i))*(C.submatrix id f).det^2 := by + have hf:evaluationMatrix F f=Matrix.of (fun i j=>e (f j)*(C.submatrix id f) i j) := rfl + rw [hf,Matrix.det_mul_row] + change (∏ i,e (f i))*(C.submatrix id f).det*(C.submatrix id f).det=_ + ring + rw [integral_fintype (integrable_det_evaluation_product _ F G hi),hg] at h + simp only [Measure.real,Measure.pi_singleton,Measure.count_singleton,prod_const_one,ENNReal.toReal_one,one_smul,he] at h + exact h.symm +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv +lemma diagonal_compression_det_lower {n m:ℕ} (C:Matrix (Fin n) (Fin m) ℝ) (e:Fin m→ℝ) + (he:∀ i,0≤e i) (he1:∀ i,e i≤1) : + (∏ i,e i)*(C*Cᵀ).det≤(C*diagonal e*Cᵀ).det := by + have hn:0<(Fintype.card (Perm (Fin n)):ℝ):=by exact_mod_cast Fintype.card_pos + apply (mul_le_mul_iff_right₀ hn).mp + have hbase:=rectangular_diagonal_gram_det C (fun _=>1) + simp only [Matrix.diagonal_one,Matrix.mul_one,prod_const_one,one_mul] at hbase + have hweight:=rectangular_diagonal_gram_det C e + calc + (Fintype.card (Perm (Fin n)):ℝ)*((∏ i,e i)*(C*Cᵀ).det)= + (∏ i,e i)*((Fintype.card (Perm (Fin n)):ℝ)*(C*Cᵀ).det) := by ring + _=(∏ i,e i)*(∑ f:Fin n→Fin m,(C.submatrix id f).det^2) := by rw [hbase] + _≤∑ f:Fin n→Fin m,(∏ i,e (f i))*(C.submatrix id f).det^2 := by + rw [mul_sum] + apply sum_le_sum + intro f _ + by_cases hf:Function.Injective f + · apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + have hp:(∏ i:Fin m,e i)≤∏ i∈univ.image f,e i:= + prod_le_prod_of_subset_of_le_one₀ (subset_univ _) (fun i _=>he i) (fun i _ _=>he1 i) + rw [prod_image (fun i _ j _ hij=>hf hij)] at hp + exact hp + · obtain ⟨i,j,hij,heq⟩:=Function.not_injective_iff.mp hf + have hz:(C.submatrix id f).det=0:=Matrix.det_zero_of_column_eq heq (fun k=>by simp [hij]) + simp [hz] + _=(Fintype.card (Perm (Fin n)):ℝ)*(C*diagonal e*Cᵀ).det := hweight.symm +/-- Compression to any finite subspace increases the determinant of a positive +contraction. The Gram quotient makes the statement independent of the basis. -/ +theorem positive_contraction_compression {n m:ℕ} + (A B:Matrix (Fin m) (Fin m) ℝ) (C:Matrix (Fin n) (Fin m) ℝ) + (hA:A.PosDef) (hB:B.PosDef) (hCB:(C*B*Cᵀ).PosDef) + (hAB:∀ v:Fin m→ℝ,v ⬝ᵥ (A *ᵥ v)≤v ⬝ᵥ (B *ᵥ v)) : + A.det/B.det≤(C*A*Cᵀ).det/(C*B*Cᵀ).det := by + obtain ⟨P,e,hP,hPB,hPA⟩:=positive_pencil_normal_form A B hA.1 hB + have hPP:P*P⁻¹=1:=Matrix.mul_nonsing_inv P hP + have hPP':P⁻¹*P=1:=Matrix.nonsing_inv_mul P hP + have hPT:Pᵀ*P⁻¹ᵀ=1:=by rw [←Matrix.transpose_mul,hPP',Matrix.transpose_one] + have he:∀ i,0x*B.det) ha,congrArg (fun x:ℝ=>x*A.det) hb] + apply (le_div_iff₀ hCB.det_pos).mpr + rw [hr,hDA,hDB] + exact diagonal_compression_det_lower D e (fun i=>(he i).le) he1 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +noncomputable def finiteFamilyCombination {n:ℕ} (F:Fin n→ℝ→ℝ) (v:Fin n→ℝ) (x:ℝ):ℝ:=∑ i,v i*F i x +noncomputable def familySquaredNorm (w f:ℝ→ℝ):ℝ:=∫ p in Set.Ioi 0,f (p^2)^2*w p +lemma finiteFamilyCombination_pair_integrable {n m:ℕ} (w:ℝ→ℝ) (F:Fin n→ℝ→ℝ) (G:Fin m→ℝ→ℝ) + (hi:∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (a:Fin n→ℝ) (b:Fin m→ℝ) : + IntegrableOn (fun p=>finiteFamilyCombination F a (p^2)*finiteFamilyCombination G b (p^2)*w p) (Set.Ioi 0) := by + have he p:finiteFamilyCombination F a (p^2)*finiteFamilyCombination G b (p^2)*w p= + ∑ i,∑ j,a i*b j*(F i (p^2)*G j (p^2)*w p) := by + simp only [finiteFamilyCombination,sum_mul,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring + simp_rw [he] + exact integrable_finsetSum _ (fun i _=>integrable_finsetSum _ (fun j _=>(hi i j).const_mul _)) +lemma familyGram_congruence {n m:ℕ} (w:ℝ→ℝ) (F:Fin n→ℝ→ℝ) + (hi:∀ i j,IntegrableOn (fun p=>F i (p^2)*F j (p^2)*w p) (Set.Ioi 0)) + (C:Matrix (Fin m) (Fin n) ℝ) : + familyGram w (fun i=>finiteFamilyCombination F (C i)) (fun i=>finiteFamilyCombination F (C i))= + C*familyGram w F F*Cᵀ := by + ext i j + have hp k l:IntegrableOn (fun p=>C i k*C j l*(F k (p^2)*F l (p^2)*w p)) (Set.Ioi 0):=(hi k l).const_mul _ + have he p:finiteFamilyCombination F (C i) (p^2)*finiteFamilyCombination F (C j) (p^2)*w p= + ∑ k,∑ l,C i k*C j l*(F k (p^2)*F l (p^2)*w p) := by + simp only [finiteFamilyCombination,sum_mul,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro k _ + apply sum_congr rfl + intro l _ + ring + simp only [familyGram,he] + rw [integral_finsetSum _ (fun k _=>integrable_finsetSum _ (fun l _=>hp k l))] + simp_rw [integral_finsetSum _ (fun l _=>hp _ l),integral_const_mul] + simp only [Matrix.mul_apply,Matrix.transpose_apply,sum_mul,familyGram] + rw [sum_comm] + apply sum_congr rfl + intro k _ + apply sum_congr rfl + intro l _ + ring +lemma familyGram_quad {n:ℕ} (w:ℝ→ℝ) (F:Fin n→ℝ→ℝ) + (hi:∀ i j,IntegrableOn (fun p=>F i (p^2)*F j (p^2)*w p) (Set.Ioi 0)) + (v:Fin n→ℝ) : + v ⬝ᵥ (familyGram w F F *ᵥ v)=familySquaredNorm w (finiteFamilyCombination F v) := by + have h:=congrArg (fun A:Matrix (Fin 1) (Fin 1) ℝ=>A 0 0) + (familyGram_congruence w F hi (Matrix.of fun (_:Fin 1) i=>v i)) + simp only [familyGram,Matrix.mul_apply,Matrix.transpose_apply,Matrix.of_apply] at h + change (∫ p in Set.Ioi 0, finiteFamilyCombination F v (p^2) * finiteFamilyCombination F v (p^2) * w p) = _ at h + unfold familySquaredNorm + simp_rw [show ∀ a:ℝ, a^2=a*a from fun a=>pow_two a] + rw [show (fun p => finiteFamilyCombination F v (p*p)*finiteFamilyCombination F v (p*p)*w p) = (fun p => finiteFamilyCombination F v (p^2)*finiteFamilyCombination F v (p^2)*w p) by simp only [pow_two]] + rw [h] + simp only [dotProduct,Matrix.mulVec,mul_sum,sum_mul,familyGram] + rw [sum_comm] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring +lemma familyGram_hermitian {n:ℕ} (w:ℝ→ℝ) (F:Fin n→ℝ→ℝ) : (familyGram w F F).IsHermitian := by + apply Matrix.IsHermitian.ext + intro i j + simp only [familyGram,star_trivial] + apply integral_congr_ae + filter_upwards with p + ring +lemma familySquaredNorm_nonneg (w f:ℝ→ℝ) (hw:∀ p,0E i (p^2)*E j (p^2)*w p) (Set.Ioi 0)) + {δ:ℝ} (hE:∀ i,familySquaredNorm w (E i)≤δ) (v:Fin n→ℝ) : + familySquaredNorm w (finiteFamilyCombination E v)≤((n:ℝ)*δ)*(∑ i,v i^2) := by + have hcomb:=finiteFamilyCombination_pair_integrable w E E hi v v + have hsq:IntegrableOn (fun p=>finiteFamilyCombination E v (p^2)^2*w p) (Set.Ioi 0):=by simpa only [pow_two] using hcomb + have hdiag i:IntegrableOn (fun p=>(E i (p^2))^2*w p) (Set.Ioi 0):=by simpa only [pow_two] using hi i i + have hsum:IntegrableOn (fun p=>(∑ i,v i^2)*(∑ i,E i (p^2)^2*w p)) (Set.Ioi 0):= + (integrable_finsetSum _ fun i _=>hdiag i).const_mul _ + have hm:familySquaredNorm w (finiteFamilyCombination E v)≤ + (∑ i,v i^2)*(∑ i,familySquaredNorm w (E i)) := by + unfold familySquaredNorm + rw [←integral_finsetSum _ (fun i _=>hdiag i),←integral_const_mul] + apply integral_mono_ae hsq hsum + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hs:=Finset.sum_mul_sq_le_sq_mul_sq univ v (fun i=>E i (p^2)) + have hh:=mul_le_mul_of_nonneg_right hs (hw p hp) + simpa only [finiteFamilyCombination,mul_sum,sum_mul,mul_assoc] using hh + have htotal:(∑ i,familySquaredNorm w (E i))≤(n:ℝ)*δ:=by + calc + _≤∑ _i:Fin n,δ:=sum_le_sum (fun i _=>hE i) + _=(n:ℝ)*δ:=by simp + calc + _≤(∑ i,v i^2)*(∑ i,familySquaredNorm w (E i)):=hm + _≤(∑ i,v i^2)*((n:ℝ)*δ):=mul_le_mul_of_nonneg_left htotal (sum_nonneg (fun i _=>sq_nonneg _)) + _=_:=by ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Equiv Filter + +/-- Evaluation rows with the rank-one interpolation correction. -/ +noncomputable def residualFamily {n : ℕ} (F : Fin n → ℝ → ℝ) (H : ℝ → ℝ) (a : ℝ) : + Fin n → ℝ → ℝ := fun i x=>F i x-F i a*H x/H a +noncomputable def meanResidualRatio {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) : ℝ := + (familyGram w (residualFamily F H a) G).det/(familyGram w F G).det + +lemma residualFamily_pair_integrable {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) + (hi : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + ∀ i j,IntegrableOn (fun p=>residualFamily F H a i (p^2)*G j (p^2)*w p) (Set.Ioi 0) := by + intro i j + convert (hi i j).sub ((hH j).const_mul (F i a/H a)) using 1 + funext p + simp only [residualFamily, Pi.sub_apply] + ring + +lemma residualFamily_gram {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) + (hi : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + familyGram w (residualFamily F H a) G=familyGram w F G- + vecMulVec (fun i=>F i a/H a) (fun j=>∫ p in Set.Ioi 0,H (p^2)*G j (p^2)*w p) := by + ext i j + have he : (fun p=>residualFamily F H a i (p^2)*G j (p^2)*w p)= + (fun p=>F i (p^2)*G j (p^2)*w p-(F i a/H a)*(H (p^2)*G j (p^2)*w p)) := by + funext p + simp only [residualFamily] + ring + change (∫ p in Set.Ioi 0,residualFamily F H a i (p^2)*G j (p^2)*w p)=_ + rw [he,integral_sub (hi i j) ((hH j).const_mul _),integral_const_mul] + rfl + +lemma det_sub_vecMulVec {n : ℕ} {A : Matrix (Fin n) (Fin n) ℝ} (hA : A.det≠0) + (u v : Fin n → ℝ) : + (A-vecMulVec u v).det=A.det*(1-v ⬝ᵥ (A⁻¹ *ᵥ u)) := by + have he : A-vecMulVec u v=A+replicateCol Unit (-u)*replicateRow Unit v := by + rw [←vecMulVec_eq] + ext i j + simp [sub_eq_add_neg] + rw [he,det_add_replicateCol_mul_replicateRow (isUnit_iff_ne_zero.mpr hA), + Matrix.mul_assoc,←replicateCol_mulVec] + congr 1 + rw [det_unique] + simp only [Matrix.add_apply,Matrix.one_apply_eq,replicateRow_mul_replicateCol_apply, + mulVec_neg,dotProduct_neg,←sub_eq_add_neg] + +lemma meanResidualRatio_formula {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) + (hi : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hd : (familyGram w F G).det≠0) : + meanResidualRatio w F G H a=1- + (fun j=>∫ p in Set.Ioi 0,H (p^2)*G j (p^2)*w p) ⬝ᵥ + ((familyGram w F G)⁻¹ *ᵥ (fun i=>F i a/H a)) := by + rw [meanResidualRatio,residualFamily_gram w F G H a hi hH,det_sub_vecMulVec hd] + exact mul_div_cancel_left₀ _ hd + + +lemma meanResidualRatio_eq_integral {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) + (hi : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + meanResidualRatio w F G H a= + (∫ p,familyPointDensity w (residualFamily F H a) G p + ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ)))) / + (∫ p,familyPointDensity w F G p + ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ)))) := by + rw [(family_gram_andreief w F G hi).2, + (family_gram_andreief w (residualFamily F H a) G (residualFamily_pair_integrable w F G H a hi hH)).2] + exact (mul_div_mul_left _ _ (Nat.cast_ne_zero.mpr Fintype.card_ne_zero)).symm + +lemma familyPointDensity_tilt {n : ℕ} (w r : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) (p : Fin n → ℝ) : + familyPointDensity (fun x=>r x*w x) F G p= + (∏ i,r (p i))*familyPointDensity w F G p := by + simp only [familyPointDensity,prod_mul_distrib] + ring + +/-- Transfer any pointwise residual bound to the exact determinant averages. -/ +lemma meanResidualRatio_bound {n : ℕ} (w w₁ w₂ : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a A B : ℝ) + (hi : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hi₁ : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w₁ p) (Set.Ioi 0)) + (hi₂ : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w₂ p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hd : 0<(familyGram w F G).det) + (hb : ∀ p : Fin n → ℝ,(∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) + have hae : ∀ᵐ p ∂μ,∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) (i:=i)).eventually (ae_restrict_mem measurableSet_Ioi) + have hR:=family_gram_andreief w (residualFamily F H a) G (residualFamily_pair_integrable w F G H a hi hH) + have h₁:=family_gram_andreief w₁ F G hi₁ + have h₂:=family_gram_andreief w₂ F G hi₂ + have hI:=integral_mono_ae hR.1 ((h₁.1.const_mul A).add (h₂.1.const_mul B)) (hae.mono hb) + simp only [Pi.add_apply] at hI + rw [integral_add (h₁.1.const_mul A) (h₂.1.const_mul B),integral_const_mul,integral_const_mul, + hR.2,h₁.2,h₂.2] at hI + have hc : (0:ℝ) linarith + +lemma commonApproach_bounds (N k : ℕ) {ε : ℝ} (he : 0 ≤ ε) (heL : ε ≤ angle^2) : + 0 ≤ commonApproach N ε k ∧ commonApproach N ε k ≤ angle^2 := by + by_cases hk : k < N + · exact ⟨(commonApproach_low hk he).1,(commonApproach_low hk he).2.trans heL⟩ + · have h:=commonApproach_high (by omega : N ≤ k) he + constructor <;> linarith [h.1,h.2] + +lemma commonApproach_strictMono (N : ℕ) {ε : ℝ} (he : 0 < ε) (heL : 2*ε < angle^2) : + StrictMono (fun i : Fin (2*N) ↦ commonApproach N ε i) := by + intro i j hij + have hij' : i.val < j.val := hij + by_cases hj : j.val < N + · have hi : i.val < N := lt_trans hij' hj + simp only [commonApproach,hi,hj,ite_true] + apply (div_lt_div_iff_of_pos_right (by positivity : 0 < (N:ℝ)+1)).mpr + apply mul_lt_mul_of_pos_left _ he + exact_mod_cast (show i.val+1 < j.val+1 by omega) + · by_cases hi : i.val < N + · exact lt_of_le_of_lt (commonApproach_low hi he.le).2 + (lt_of_lt_of_le (by linarith) (commonApproach_high (by omega : N ≤ j.val) he.le).1) + · simp only [commonApproach,hi,hj,ite_false] + apply sub_lt_sub_left + apply (div_lt_div_iff_of_pos_right (by positivity : 0 < (N:ℝ)+1)).mpr + apply mul_lt_mul_of_pos_left _ he + exact_mod_cast (show 2*N-j.val < 2*N-i.val by have := j.isLt; omega) + +lemma interiorApproach_bounds (N k : ℕ) {τ ε : ℝ} (he : 0 ≤ ε) (heL : ε ≤ angle^2) + (ht : 0 ≤ τ ∧ τ ≤ angle^2) : + 0 ≤ interiorApproach N τ ε k ∧ interiorApproach N τ ε k ≤ angle^2 := by + unfold interiorApproach + split_ifs <;> first | exact ht | exact commonApproach_bounds N _ he heL + +lemma interiorApproach_strictMono (N : ℕ) {τ ε : ℝ} (he : 0 < ε) + (hl : ε < τ) (hr : τ < angle^2-ε) : + StrictMono (fun i : Fin (2*N+1) ↦ interiorApproach N τ ε i) := by + have heL : 2*ε < angle^2 := by linarith + have hq:=commonApproach_strictMono N he heL + intro i j hij + have hiN := i.isLt + have hjN := j.isLt + have hij' : i.val < j.val := hij + by_cases hj : j.val < N + · have hi : i.val < N := lt_trans hij' hj + simp only [interiorApproach,hi,hj,ite_true] + exact hq (show (⟨i.val,by omega⟩ : Fin (2*N)) < ⟨j.val,by omega⟩ from hij') + · by_cases hi : i.val < N + · simp only [interiorApproach,hi,hj,ite_true,ite_false] + split_ifs with hje + · exact (commonApproach_low hi he.le).2.trans_lt hl + · exact (commonApproach_low hi he.le).2.trans_lt + (lt_of_lt_of_le (by linarith) (commonApproach_high (by omega : N ≤ j.val-1) he.le).1) + · simp only [interiorApproach,hi,hj,ite_false] + have hje : j.val≠N := by omega + rw [ite_eq_right hje] + split_ifs with hie + · exact hr.trans_le (commonApproach_high (by omega : N ≤ j.val-1) he.le).1 + · exact hq (show (⟨i.val-1,by omega⟩ : Fin (2*N)) < ⟨j.val-1,by omega⟩ by change i.val-1 < j.val-1; omega) + +lemma nodalOrder_eq_zero_of_strictMono_prefix {b : ℕ → ℝ} {n : ℕ} + (hb : StrictMono (fun i : Fin n ↦ b i)) (i : Fin n) : nodalOrder b i=0 := by + unfold nodalOrder + rw [Finset.card_eq_zero] + apply Finset.filter_eq_empty_iff.mpr + intro j hj + have hj' : j < i.val := Finset.mem_range.mp hj + exact (hb (show (⟨j,by omega⟩ : Fin n) < i from hj')).ne + +lemma interiorApproach_permutation (N : ℕ) (τ ε : ℝ) (i : Fin (2*N+1)) : + interiorApproach N τ ε (knotPermutation N i)=Fin.lastCases τ (fun j : Fin (2*N) ↦ commonApproach N ε j) i := by + refine Fin.lastCases ?_ (fun j ↦ ?_) i + · rw [knotPermutation_last] + simp [interiorApproach] + · rw [knotPermutation_castSucc] + by_cases hj : j.val < N + · simp [interiorApproach,insertKnotIndex,hj] + · have hl : ¬j.val+1 < N := by omega + have hn : j.val+1≠N := by omega + simp [interiorApproach,insertKnotIndex,hj,hl,hn] + +lemma tendsto_commonApproach (N : ℕ) {ε : ℕ → ℝ} (he : Tendsto ε atTop (𝓝 0)) : + Tendsto (fun k ↦ commonApproach N (ε k)) atTop (𝓝 (twoKnotLabels N)) := by + apply tendsto_pi_nhds.mpr + intro i + by_cases hi : i < N + · simpa only [commonApproach,twoKnotLabels,hi,ite_true,zero_mul,zero_div] using + (he.mul_const ((i:ℝ)+1)).div_const ((N:ℝ)+1) + · simpa only [commonApproach,twoKnotLabels,hi,ite_false,zero_mul,zero_div,sub_zero] using + tendsto_const_nhds.sub ((he.mul_const ((2*N-i:ℕ):ℝ)).div_const ((N:ℝ)+1)) + +lemma tendsto_interiorApproach (N : ℕ) (t : ℝ) {ε : ℕ → ℝ} (he : Tendsto ε atTop (𝓝 0)) : + Tendsto (fun k ↦ interiorApproach N (t^2) (ε k)) atTop (𝓝 (interiorKnotLabels N t)) := by + apply tendsto_pi_nhds.mpr + intro i + have hq:=tendsto_commonApproach N he + by_cases hi : i < N + · simpa [interiorApproach,interiorKnotLabels,twoKnotLabels,hi] using hq.apply_nhds i + · by_cases hie : i=N + · simp [interiorApproach,interiorKnotLabels,hie] + · have hi' : ¬i-1 < N := by omega + simpa [interiorApproach,interiorKnotLabels,twoKnotLabels,hi,hie,hi'] using hq.apply_nhds (i-1) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/FiniteFunctional.lean b/lean/OAI/Combinatorics/HoneycombChords/FiniteFunctional.lean new file mode 100644 index 0000000000000000000000000000000000000000..df0527e8dc48ab5407a6d8eb9aaa43c986ca8e84 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/FiniteFunctional.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.HoneycombChords.InterpolationDefinitions + +namespace OAI + +/-! The finite strip functional and its polynomial and hyperbolic interpolation space. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional +/-- Entire real continuation of cosh(t sqrt x), also at negative x. -/ +noncomputable def C (t x : ℝ) : ℂ := + if 0 ≤ x then (Real.cosh (t * Real.sqrt x) : ℂ) + else (Real.cos (t * Real.sqrt (-x)) : ℂ) + +noncomputable def D (x : ℝ) : ℂ := 2 * C angle x - 1 +noncomputable def aStar : ℂ := 2 * (Real.cos (2*angle) : ℂ) - 1 + +/-- Both blocks of the exact 2N-dimensional interpolation space. -/ +noncomputable def M (N : ℕ) : Submodule ℂ (ℝ → ℂ) := + Submodule.span ℂ + (Set.range (fun j : Fin N => fun x : ℝ => (x : ℂ)^j.val) ∪ + Set.range (fun j : Fin N => fun x : ℝ => + iteratedDeriv j.val (fun t : ℝ => C t x) angle)) + +/-- Integral of the entire cosine continuation, with removable value `g 0 = angle`. -/ +noncomputable def g (x : ℝ) : ℂ := ∫ t in (0:ℝ)..angle, C t x + +noncomputable def admissibleDensity (N : ℕ) : Submodule ℂ (ℝ → ℂ) := + M N ⊔ Submodule.span ℂ {g} + +/-- Bilinear pairing for the positive strip measure, without complex conjugation. -/ +noncomputable def pairing (H f : ℝ → ℂ) : ℂ := + ∫ z in Set.Ioi (0:ℝ), + H (z^2) * f (z^2) * + ((z : ℂ) * D (z^2) / (Real.sinh (4*angle*z) : ℂ)) + +noncomputable def value (ρ : ℂ) (f H : ℝ → ℂ) : ℂ := + 4*aStar*H (-4) + ρ*H 0 + pairing H f + +/-- Representation of the physical bridge mass by the finite strip functional. -/ +def PhysicalFiniteFunctional : Prop := + ∀ N : ℕ, 1 ≤ N → ∃ (B : ℝ) (ρ : ℂ) (f : ℝ → ℂ), + 0 ≤ B ∧ bridgeMass N = ENNReal.ofReal B ∧ + f ∈ admissibleDensity N ∧ + (∀ H ∈ M N, value ρ f H = 0) ∧ + value ρ f (C (angle/2)) = 0 ∧ + value ρ f (fun x => C (3*angle/2) x - C (angle/2) x / D x) = 0 ∧ + 2*(B:ℂ) = value ρ f (fun x => (D x)⁻¹) + + +end CriticalHoneycomb.FiniteFunctional + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Flux.lean b/lean/OAI/Combinatorics/HoneycombChords/Flux.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a068c582f62dcb39762433f926b04c254514f7a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Flux.lean @@ -0,0 +1,934 @@ +import OAI.Combinatorics.HoneycombChords.ChordRemoval + +namespace OAI + +/-! +# Finite honeycomb current conservation + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.FluxWard +open PhysicalTiles Planar +open scoped BigOperators + +noncomputable def r : ℂ := Complex.exp (((Real.pi/8:ℝ):ℂ)*Complex.I) +lemma r_ne_zero : r≠0 := Complex.exp_ne_zero _ +lemma r_sq : r^2=phase := by + unfold r phase angle + rw [←Complex.exp_nat_mul] + congr 1 + push_cast + ring +lemma r_eight : r^8 = -1 := by + rw [show (8:ℕ)=2*4 by omega,pow_mul,r_sq,show (4:ℕ)=2*2 by omega,pow_mul,phase_sq] + simp +lemma r_inverse : r⁻¹= -r^7 := by + apply mul_left_cancel₀ r_ne_zero + rw [mul_inv_cancel₀ r_ne_zero] + have h : r * (-r^7) = -(r^8) := by ring + rw [h,r_eight] + simp +lemma phase_q : phase=r^2 := r_sq.symm +lemma phase_inv_q : phase⁻¹= -r^6 := by + rw [phase_q,←inv_pow,r_inverse] + have h : r^14=r^6*r^8 := by ring + rw [show (-r^7)^2=r^14 by ring,h,r_eight] + ring +lemma kappa_phase : (kappa:ℂ)*(r+r⁻¹)=1 := by + have hr : r+r⁻¹=(2*Real.cos (Real.pi/8):ℝ) := by + rw [r,←Complex.exp_neg] + have hn : -(((Real.pi/8:ℝ):ℂ)*Complex.I)=((- (Real.pi/8):ℝ):ℂ)*Complex.I := by push_cast; ring + rw [hn,Complex.exp_ofReal_mul_I,Complex.exp_ofReal_mul_I] + simp only [Real.cos_neg,Real.sin_neg] + push_cast + ring + rw [hr] + have h := Complex.ofReal_inj.mpr CriticalHoneycombTransfer.κ_cos + convert h using 1 ; simp [kappa,CriticalHoneycombTransfer.κ,CriticalHoneycombTransfer.L] ; ring + +/-- Off-diagonal raising generator, in the source order +, vacant, -. -/ +def raising (i j : Fin 3) : ℂ := + if i=0 ∧ j=1 then 1 else if i=1 ∧ j=2 then -1 else 0 +/-- Diagonal quantum-group weight, with q=exp(5πi/8). -/ +noncomputable def twist (i : Fin 3) : ℂ := + if i=0 then r^5 else if i=1 then 1 else -r^3 +noncomputable def untwist (i : Fin 3) : ℂ := + if i=0 then -r^3 else if i=1 then 1 else r^5 + +lemma twist_inverse (i : Fin 3) : twist i * untwist i=1 := by + fin_cases i <;> norm_num [twist,untwist] + all_goals calc + _ = -(r^8) := by ring + _ = 1 := by rw [r_eight]; ring + +lemma weight_equation : (kappa:ℂ)*(r^2+1)=r := by + have h := congrArg (fun z : ℂ=>z*r) kappa_phase + simpa [mul_add,add_mul,mul_assoc,r_ne_zero,pow_two] using h + +lemma kappa_polynomial : (kappa:ℂ)=(r-r^3+r^5-r^7)/2 := by + linear_combination (1-r^2+r^4-r^6)/2 * weight_equation + (kappa:ℂ)/2 * r_eight + +lemma r_power_reduce (n : ℕ) : r^n=(-1:ℂ)^(n/8)*r^(n%8) := by + calc + r^n = r^(n%8+8*(n/8)) := congrArg (r^·) (Nat.mod_add_div n 8).symm + _ = _ := by rw [pow_add,pow_mul,r_eight]; ring + +lemma r_pow_8 : r^8 = -(1:ℂ) := by + have h := r_power_reduce 8 + norm_num at h ⊢ + exact h +lemma r_pow_9 : r^9 = -r^1 := by + have h := r_power_reduce 9 + norm_num at h ⊢ + exact h +lemma r_pow_10 : r^10 = -r^2 := by + have h := r_power_reduce 10 + norm_num at h ⊢ + exact h +lemma r_pow_11 : r^11 = -r^3 := by + have h := r_power_reduce 11 + norm_num at h ⊢ + exact h +lemma r_pow_12 : r^12 = -r^4 := by + have h := r_power_reduce 12 + norm_num at h ⊢ + exact h +lemma r_pow_13 : r^13 = -r^5 := by + have h := r_power_reduce 13 + norm_num at h ⊢ + exact h +lemma r_pow_14 : r^14 = -r^6 := by + have h := r_power_reduce 14 + norm_num at h ⊢ + exact h +lemma r_pow_15 : r^15 = -r^7 := by + have h := r_power_reduce 15 + norm_num at h ⊢ + exact h +lemma r_pow_16 : r^16 = (1:ℂ) := by + have h := r_power_reduce 16 + norm_num at h ⊢ + exact h +lemma r_pow_17 : r^17 = r^1 := by + have h := r_power_reduce 17 + norm_num at h ⊢ + exact h +lemma r_pow_18 : r^18 = r^2 := by + have h := r_power_reduce 18 + norm_num at h ⊢ + exact h +lemma r_pow_19 : r^19 = r^3 := by + have h := r_power_reduce 19 + norm_num at h ⊢ + exact h +lemma r_pow_20 : r^20 = r^4 := by + have h := r_power_reduce 20 + norm_num at h ⊢ + exact h +lemma r_pow_21 : r^21 = r^5 := by + have h := r_power_reduce 21 + norm_num at h ⊢ + exact h +lemma r_pow_22 : r^22 = r^6 := by + have h := r_power_reduce 22 + norm_num at h ⊢ + exact h +lemma r_pow_23 : r^23 = r^7 := by + have h := r_power_reduce 23 + norm_num at h ⊢ + exact h +lemma r_pow_24 : r^24 = -(1:ℂ) := by + have h := r_power_reduce 24 + norm_num at h ⊢ + exact h +lemma r_pow_25 : r^25 = -r^1 := by + have h := r_power_reduce 25 + norm_num at h ⊢ + exact h +lemma r_pow_26 : r^26 = -r^2 := by + have h := r_power_reduce 26 + norm_num at h ⊢ + exact h +lemma r_pow_27 : r^27 = -r^3 := by + have h := r_power_reduce 27 + norm_num at h ⊢ + exact h +lemma r_pow_28 : r^28 = -r^4 := by + have h := r_power_reduce 28 + norm_num at h ⊢ + exact h +lemma r_pow_29 : r^29 = -r^5 := by + have h := r_power_reduce 29 + norm_num at h ⊢ + exact h +lemma r_pow_30 : r^30 = -r^6 := by + have h := r_power_reduce 30 + norm_num at h ⊢ + exact h +lemma r_pow_31 : r^31 = -r^7 := by + have h := r_power_reduce 31 + norm_num at h ⊢ + exact h +lemma r_pow_32 : r^32 = (1:ℂ) := by + have h := r_power_reduce 32 + norm_num at h ⊢ + exact h + +lemma inverse_r_sq : (r^2)⁻¹= -r^6 := by rw [←phase_q]; exact phase_inv_q + +/-- Local current conservation at a single actual up-triangle center. -/ +theorem up_current (w a b : Fin 3) : + (∑ v : Fin 3, raising w v * upTensor v a b) = + r * (∑ v : Fin 3, upTensor w v b * raising v a * twist b) + + r⁻¹ * (∑ v : Fin 3, upTensor w a v * untwist a * raising v b) := by + fin_cases w <;> fin_cases a <;> fin_cases b <;> + simp [raising,twist,untwist,upTensor,occupied,Planar.empty,cup,Fin.sum_univ_three, + phase_q,inverse_r_sq,r_inverse] <;> + rw [kappa_polynomial] <;> ring_nf <;> + simp only [r_pow_8,r_pow_9,r_pow_10,r_pow_11,r_pow_12,r_pow_13,r_pow_14,r_pow_15,r_pow_17,r_pow_19,r_pow_21,r_pow_23,r_pow_25,] <;> ring + +noncomputable def physicalTile (w n s e : Fin 3) : ℂ := + sourceR (kappa:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) 0 (n,w) (s,e) + +theorem tile_twist (w n s e : Fin 3) : + twist w * twist n * physicalTile w n s e = physicalTile w n s e * twist s * twist e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [twist,physicalTile,sourceR] <;> ring_nf <;> simp only [r_eight] <;> ring + +theorem tile_untwist (w n s e : Fin 3) : + untwist w * untwist n * physicalTile w n s e = physicalTile w n s e * untwist s * untwist e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [untwist,physicalTile,sourceR] <;> ring_nf <;> simp only [r_eight] <;> ring + +private theorem tile_current_00 (s e : Fin 3) : + (∑ v : Fin 3, raising 0 v * twist 0 * physicalTile v 0 s e) + + r * (∑ v : Fin 3, untwist 0 * raising 0 v * physicalTile 0 v s e) = + r * (∑ v : Fin 3, physicalTile 0 0 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 0 0 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] <;> + simp only [kappa_polynomial] <;> ring_nf <;> + simp only [r_pow_8,r_pow_9,r_pow_10,r_pow_11,r_pow_12,r_pow_13,r_pow_14,r_pow_15,r_pow_16,r_pow_17,r_pow_18,r_pow_19,r_pow_20,] <;> ring + +private theorem tile_current_01 (s e : Fin 3) : + (∑ v : Fin 3, raising 0 v * twist 1 * physicalTile v 1 s e) + + r * (∑ v : Fin 3, untwist 0 * raising 1 v * physicalTile 0 v s e) = + r * (∑ v : Fin 3, physicalTile 0 1 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 0 1 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] <;> + simp only [kappa_polynomial] <;> ring_nf <;> + simp only [r_pow_8,r_pow_10,r_pow_12,r_pow_14,r_pow_16,r_pow_18,r_pow_20,] <;> ring + +private theorem tile_current_02 (s e : Fin 3) : + (∑ v : Fin 3, raising 0 v * twist 2 * physicalTile v 2 s e) + + r * (∑ v : Fin 3, untwist 0 * raising 2 v * physicalTile 0 v s e) = + r * (∑ v : Fin 3, physicalTile 0 2 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 0 2 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] <;> + simp only [kappa_polynomial] <;> ring_nf ; + simp only [r_pow_8,r_pow_10,r_pow_12,r_pow_14,r_pow_16,r_pow_18,] ; ring + +private theorem tile_current_10 (s e : Fin 3) : + (∑ v : Fin 3, raising 1 v * twist 0 * physicalTile v 0 s e) + + r * (∑ v : Fin 3, untwist 1 * raising 0 v * physicalTile 1 v s e) = + r * (∑ v : Fin 3, physicalTile 1 0 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 1 0 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] <;> + simp only [kappa_polynomial] <;> ring_nf <;> + simp only [r_pow_9,r_pow_11,r_pow_13,r_pow_15,r_pow_17,r_pow_19,r_pow_21,r_pow_23,r_pow_25,] <;> ring + +private theorem tile_current_11 (s e : Fin 3) : + (∑ v : Fin 3, raising 1 v * twist 1 * physicalTile v 1 s e) + + r * (∑ v : Fin 3, untwist 1 * raising 1 v * physicalTile 1 v s e) = + r * (∑ v : Fin 3, physicalTile 1 1 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 1 1 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] <;> + simp only [kappa_polynomial] <;> ring_nf <;> + simp only [r_pow_8,r_pow_9,r_pow_10,r_pow_11,r_pow_12,r_pow_13,r_pow_14,r_pow_15,r_pow_16,r_pow_17,r_pow_18,r_pow_19,r_pow_20,r_pow_21,r_pow_23,r_pow_25,] <;> ring + +private theorem tile_current_12 (s e : Fin 3) : + (∑ v : Fin 3, raising 1 v * twist 2 * physicalTile v 2 s e) + + r * (∑ v : Fin 3, untwist 1 * raising 2 v * physicalTile 1 v s e) = + r * (∑ v : Fin 3, physicalTile 1 2 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 1 2 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] ; + simp only [kappa_polynomial] ; ring_nf ; + simp only [r_pow_9,r_pow_11,r_pow_13,r_pow_15,r_pow_17,r_pow_19,] ; ring + +private theorem tile_current_20 (s e : Fin 3) : + (∑ v : Fin 3, raising 2 v * twist 0 * physicalTile v 0 s e) + + r * (∑ v : Fin 3, untwist 2 * raising 0 v * physicalTile 2 v s e) = + r * (∑ v : Fin 3, physicalTile 2 0 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 2 0 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] <;> + simp only [kappa_polynomial] <;> ring_nf ; + simp only [r_pow_9,r_pow_11,r_pow_13,r_pow_15,r_pow_17,r_pow_19,r_pow_21,] ; ring + +private theorem tile_current_21 (s e : Fin 3) : + (∑ v : Fin 3, raising 2 v * twist 1 * physicalTile v 1 s e) + + r * (∑ v : Fin 3, untwist 2 * raising 1 v * physicalTile 2 v s e) = + r * (∑ v : Fin 3, physicalTile 2 1 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 2 1 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] ; + simp only [kappa_polynomial] ; ring_nf ; + simp only [r_pow_8,r_pow_10,r_pow_12,r_pow_14,r_pow_16,r_pow_18,r_pow_20,] ; ring + +private theorem tile_current_22 (s e : Fin 3) : + (∑ v : Fin 3, raising 2 v * twist 2 * physicalTile v 2 s e) + + r * (∑ v : Fin 3, untwist 2 * raising 2 v * physicalTile 2 v s e) = + r * (∑ v : Fin 3, physicalTile 2 2 v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile 2 2 s v * untwist s * raising v e) := by + fin_cases s <;> fin_cases e <;> + simp [raising,twist,untwist,physicalTile,sourceR,phase_q,inverse_r_sq,div_eq_mul_inv] + +/-- The exact R tile transports the weighted current (r,1) to (1,r). +Its phases and κ are those of the original honeycomb model. -/ +theorem tile_current (w n s e : Fin 3) : + (∑ v : Fin 3, raising w v * twist n * physicalTile v n s e) + + r * (∑ v : Fin 3, untwist w * raising n v * physicalTile w v s e) = + r * (∑ v : Fin 3, physicalTile w n v e * raising v s * twist e) + + (∑ v : Fin 3, physicalTile w n s v * untwist s * raising v e) := by + fin_cases w <;> fin_cases n + · exact tile_current_00 s e + · exact tile_current_01 s e + · exact tile_current_02 s e + · exact tile_current_10 s e + · exact tile_current_11 s e + · exact tile_current_12 s e + · exact tile_current_20 s e + · exact tile_current_21 s e + · exact tile_current_22 s e + +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators + +abbrev FState := List (Fin 3) → ℂ +noncomputable def twistProduct (xs : List (Fin 3)) : ℂ := (xs.map twist).prod +noncomputable def untwistProduct (xs : List (Fin 3)) : ℂ := (xs.map untwist).prod + +noncomputable def siteAct : ℕ → FState → FState + | 0, f, x::y::xs => ∑ a : Fin 3, ∑ b : Fin 3, physicalTile x y a b * f (a::b::xs) + | 0, _, _ => 0 + | i+1, f, x::xs => siteAct i (fun ys=>f (x::ys)) xs + | _+1, _, [] => 0 + +/-- The coproduct of the actual spin-raising current, with direction +weights attached to the boundary wires in their planar contour order. -/ +noncomputable def current : List ℂ → FState → FState + | [], _, _ => 0 + | q::qs, f, x::xs => + q * (∑ y : Fin 3, raising x y * f (y::xs)) * twistProduct xs + + untwist x * current qs (fun ys=>f (x::ys)) xs + | _::_, _, [] => 0 + +lemma siteAct_add (i : ℕ) (f g : FState) : + siteAct i (f+g)=siteAct i f+siteAct i g := by + induction i generalizing f g with + | zero => + funext xs + cases xs with + | nil => simp [siteAct] + | cons x xs => cases xs <;> simp [siteAct,mul_add,Finset.sum_add_distrib] + | succ i ih => + funext xs + cases xs with + | nil => simp [siteAct] + | cons x xs => exact congrFun (ih (fun ys=>f (x::ys)) (fun ys=>g (x::ys))) xs + +lemma siteAct_smul (i : ℕ) (z : ℂ) (f : FState) : + siteAct i (z • f)=z • siteAct i f := by + induction i generalizing f with + | zero => + funext xs + cases xs with + | nil => simp [siteAct] + | cons x xs => cases xs <;> simp [siteAct,Finset.mul_sum,mul_left_comm] + | succ i ih => + funext xs + cases xs with + | nil => simp [siteAct] + | cons x xs => exact congrFun (ih (fun ys=>f (x::ys))) xs + +noncomputable def siteLinear (i : ℕ) : FState →ₗ[ℂ] FState where + toFun := siteAct i + map_add' := siteAct_add i + map_smul' := siteAct_smul i + +lemma current_add (qs : List ℂ) (f g : FState) : + current qs (f+g)=current qs f+current qs g := by + induction qs generalizing f g with + | nil => ext xs; simp [current] + | cons q qs ih => + funext xs + cases xs with + | nil => simp [current] + | cons x xs => + simp only [current,Pi.add_apply,mul_add,Finset.sum_add_distrib,add_mul] + rw [show (fun ys=>f (x::ys)+g (x::ys))=(fun ys=>f (x::ys))+(fun ys=>g (x::ys)) from rfl, + ih] + simp only [Pi.add_apply,mul_add] + ring + +lemma current_smul (qs : List ℂ) (z : ℂ) (f : FState) : + current qs (z • f)=z • current qs f := by + induction qs generalizing f with + | nil => ext xs; simp [current] + | cons q qs ih => + funext xs + cases xs with + | nil => simp [current] + | cons x xs => + change q * (∑ y, raising x y * (z*f (y::xs))) * twistProduct xs + + untwist x * current qs (z • (fun ys=>f (x::ys))) xs = _ + rw [ih] + simp only [Pi.smul_apply,smul_eq_mul] + simp only [mul_left_comm (raising _ _) z,←Finset.mul_sum] + simp only [current,] + ring + +noncomputable def currentLinear (qs : List ℂ) : FState →ₗ[ℂ] FState where + toFun := current qs + map_add' := current_add qs + map_smul' := current_smul qs + +lemma siteAct_sum {α : Type*} [Fintype α] (i : ℕ) (f : α → FState) (xs) : + siteAct i (fun ys=>∑ a, f a ys) xs = ∑ a, siteAct i (f a) xs := by + have h := congrFun (map_sum (siteLinear i) f Finset.univ) xs + change siteAct i (∑ a, f a) xs = (∑ a, siteAct i (f a)) xs at h + rw [show (∑ a, f a)=(fun ys=>∑ a, f a ys) from by funext ys; exact Finset.sum_apply ..] at h + simpa only [Finset.sum_apply] using h + +lemma current_sum {α : Type*} [Fintype α] (qs : List ℂ) (f : α → FState) (xs) : + current qs (fun ys=>∑ a, f a ys) xs = ∑ a, current qs (f a) xs := by + have h := congrFun (map_sum (currentLinear qs) f Finset.univ) xs + change current qs (∑ a, f a) xs = (∑ a, current qs (f a)) xs at h + rw [show (∑ a, f a)=(fun ys=>∑ a, f a ys) from by funext ys; exact Finset.sum_apply ..] at h + simpa only [Finset.sum_apply] using h + +lemma siteAct_scalar (i : ℕ) (z : ℂ) (f : FState) (xs) : + siteAct i (fun ys=>z*f ys) xs = z*siteAct i f xs := + congrFun (siteAct_smul i z f) xs +lemma current_scalar (qs : List ℂ) (z : ℂ) (f : FState) (xs) : + current qs (fun ys=>z*f ys) xs = z*current qs f xs := + congrFun (current_smul qs z f) xs + +lemma siteAct_twist (i : ℕ) (f : FState) (xs) : + siteAct i (fun ys=>twistProduct ys*f ys) xs = twistProduct xs*siteAct i f xs := by + induction i generalizing f xs with + | zero => + cases xs with + | nil => simp [siteAct] + | cons x xs => cases xs with + | nil => simp [siteAct] + | cons y xs => + simp only [siteAct,twistProduct,List.map_cons,List.prod_cons,Finset.mul_sum] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + have h := tile_twist x y a b + calc + _ = (physicalTile x y a b * twist a * twist b) * (xs.map twist).prod * f (a::b::xs) := by ring + _ = _ := by rw [←h]; ring + | succ i ih => + cases xs with + | nil => simp [siteAct] + | cons x xs => + simp only [siteAct,twistProduct,List.map_cons,List.prod_cons] + rw [show (fun ys=>(twist x*(ys.map twist).prod)*f (x::ys))= + (fun ys=>twist x*(twistProduct ys*f (x::ys))) from by funext ys; simp [twistProduct]; ring, + siteAct_scalar,ih] + simp [twistProduct,mul_assoc] + +open Matrix +open scoped Matrix +abbrev TwoSpin := Fin 3 × Fin 3 +noncomputable def pairCurrent (u v : ℂ) : Matrix TwoSpin TwoSpin ℂ := fun o i => + (if o.2=i.2 then u*raising o.1 i.1*twist o.2 else 0) + + (if o.1=i.1 then v*untwist o.1*raising o.2 i.2 else 0) +noncomputable def tileMatrix : Matrix TwoSpin TwoSpin ℂ := fun o i => physicalTile o.1 o.2 i.1 i.2 + +lemma pairCurrent_left (u v : ℂ) (M : Matrix TwoSpin TwoSpin ℂ) (o i : TwoSpin) : + (pairCurrent u v * M) o i = + u*(∑ a, raising o.1 a * twist o.2 * M (a,o.2) i) + + v*(∑ b, untwist o.1 * raising o.2 b * M (o.1,b) i) := by + simp only [Matrix.mul_apply,Fintype.sum_prod_type,pairCurrent,add_mul, + Finset.sum_add_distrib,ite_mul,zero_mul,Finset.mul_sum] + rw [Finset.sum_comm (f:=fun a b=>if o.1=a then (v*untwist o.1*raising o.2 b)*M (a,b) i else 0)] + simp [mul_assoc,eq_comm] + +lemma pairCurrent_right (u v : ℂ) (M : Matrix TwoSpin TwoSpin ℂ) (o i : TwoSpin) : + (M * pairCurrent u v) o i = + u*(∑ a, M o (a,i.2) * raising a i.1 * twist i.2) + + v*(∑ b, M o (i.1,b) * untwist i.1 * raising b i.2) := by + simp only [Matrix.mul_apply,Fintype.sum_prod_type,pairCurrent,mul_add, + Finset.sum_add_distrib,mul_ite,mul_zero,Finset.mul_sum] + rw [Finset.sum_comm (f:=fun a b=>if a=i.1 then M o (a,b)*(v*untwist a*raising b i.2) else 0)] + simp [mul_assoc,mul_left_comm,mul_comm] + +lemma pairCurrent_tile : + pairCurrent 1 r * tileMatrix = tileMatrix * pairCurrent r 1 := by + ext o i + rw [pairCurrent_left,pairCurrent_right] + simpa only [one_mul,tileMatrix] using tile_current o.1 o.2 i.1 i.2 + +lemma pairCurrent_act (u v : ℂ) (f : TwoSpin → ℂ) (x y : Fin 3) : + (pairCurrent u v *ᵥ f) (x,y) = + u*(∑ a, raising x a * twist y * f (a,y)) + + v*(∑ b, untwist x * raising y b * f (x,b)) := by + have h := pairCurrent_left u v (fun o (_ : TwoSpin)=>f o) (x,y) (x,y) + exact h + +lemma current_two (u v : ℂ) (qs : List ℂ) (f : FState) (x y : Fin 3) (xs) : + current (u::v::qs) f (x::y::xs) = + (pairCurrent u v *ᵥ (fun p=>f (p.1::p.2::xs))) (x,y) * twistProduct xs + + untwist x * untwist y * current qs (fun ys=>f (x::y::ys)) xs := by + have hs : (∑ a, raising x a*twist y*f (a::y::xs)) = + twist y*(∑ a, raising x a*f (a::y::xs)) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a ha + ring + have ht : (∑ b, untwist x*raising y b*f (x::b::xs)) = + untwist x*(∑ b, raising y b*f (x::b::xs)) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro b hb + ring + rw [pairCurrent_act,hs,ht] + simp only [current,twistProduct,List.map_cons,List.prod_cons] + ring + +lemma siteAct_zero_pair (f : FState) (x y : Fin 3) (xs) : + siteAct 0 f (x::y::xs) = + (tileMatrix *ᵥ (fun p=>f (p.1::p.2::xs))) (x,y) := by + simp only [siteAct,Matrix.mulVec,dotProduct,Fintype.sum_prod_type,tileMatrix] + +lemma current_site_tail (qs : List ℂ) (f : FState) (x y : Fin 3) (xs) : + untwist x * untwist y * current qs (fun ys=>siteAct 0 f (x::y::ys)) xs = + ∑ a : Fin 3, ∑ b : Fin 3, physicalTile x y a b * + (untwist a * untwist b * current qs (fun ys=>f (a::b::ys)) xs) := by + simp only [siteAct,current_sum,current_scalar,Finset.mul_sum] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + have h := tile_untwist x y a b + calc + _ = (untwist x * untwist y * physicalTile x y a b) * + current qs (fun ys=>f (a::b::ys)) xs := by ring + _ = _ := by rw [h]; ring + +theorem current_site_zero (qs : List ℂ) (f : FState) : + current (1::r::qs) (siteAct 0 f) = siteAct 0 (current (r::1::qs) f) := by + funext xs + cases xs with + | nil => simp [current,siteAct] + | cons x xs => cases xs with + | nil => simp [current,siteAct] + | cons y xs => + rw [current_two,current_site_tail] + simp only [siteAct_zero_pair] + rw [Matrix.mulVec_mulVec,pairCurrent_tile,←Matrix.mulVec_mulVec] + simp only [Matrix.mulVec,dotProduct,Fintype.sum_prod_type,tileMatrix, + current_two,Finset.sum_mul] + simp only [mul_add,Finset.sum_add_distrib,Finset.mul_sum,Finset.sum_mul,mul_assoc] + +lemma siteAct_pointwise_add (i : ℕ) (f g : FState) (xs) : + siteAct i (fun ys=>f ys+g ys) xs = siteAct i f xs+siteAct i g xs := + congrFun (siteAct_add i f g) xs + +/-- The local physical Ward identity at any adjacent pair of contour wires. -/ +theorem current_site_prefix (pre qs : List ℂ) (f : FState) : + current (pre++1::r::qs) (siteAct pre.length f) = + siteAct pre.length (current (pre++r::1::qs) f) := by + induction pre generalizing f with + | nil => exact current_site_zero qs f + | cons q pre ih => + funext xs + cases xs with + | nil => simp [current,siteAct] + | cons x xs => + simp only [List.cons_append,List.length_cons,current,siteAct] + rw [ih] + rw [siteAct_pointwise_add,siteAct_scalar] + have h := siteAct_twist pre.length (fun ys=>∑ z, raising x z*f (z::ys)) xs + rw [show (fun ys=>q*(∑ z, raising x z*f (z::ys))*twistProduct ys)= + (fun ys=>q*(twistProduct ys*(∑ z, raising x z*f (z::ys)))) from by funext ys; ring, + siteAct_scalar,h,siteAct_sum] + simp only [siteAct_scalar] + ring + +noncomputable def rowAct : ℕ → ℕ → FState → FState + | _, 0, f => f + | i, n+1, f => rowAct (i+1) n (siteAct i f) + +lemma rowAct_current (pre qs : List ℂ) (n : ℕ) (f : FState) : + current (pre++List.replicate n 1++r::qs) (rowAct pre.length n f) = + rowAct pre.length n (current (pre++r::(List.replicate n 1++qs)) f) := by + induction n generalizing pre f with + | zero => simp [rowAct] + | succ n ih => + simp only [rowAct] + have h := ih (pre++[1]) (siteAct pre.length f) + simp only [List.length_append,List.length_singleton,List.append_assoc, + List.cons_append,List.nil_append] at h + rw [show pre++List.replicate (n+1) 1++r::qs= + pre++1::(List.replicate n 1++r::qs) by simp [List.replicate_succ,List.append_assoc],h] + have hlocal := current_site_prefix pre (List.replicate n 1++qs) f + rw [hlocal] + simp only [List.replicate_succ,List.cons_append] + +noncomputable def rectangleAct : ℕ → ℕ → FState → FState + | 0, _, f => f + | w+1, h, f => rectangleAct w h (rowAct w h f) + +/-- Finite rectangle current conservation, including all boundary indices. +It is an equality for the literal physical tensor network, not an assumed +bound or an infinite-volume assertion. -/ +theorem rectangle_current (w h : ℕ) (qs : List ℂ) (f : FState) : + current (List.replicate h 1 ++ List.replicate w r ++ qs) (rectangleAct w h f) = + rectangleAct w h (current (List.replicate w r ++ List.replicate h 1 ++ qs) f) := by + induction w generalizing qs f with + | zero => simp [rectangleAct] + | succ w ih => + have hw : List.replicate (w+1) r=List.replicate w r++[r] := by + rw [List.replicate_add]; simp + simp only [rectangleAct,hw,List.append_assoc,List.singleton_append] + have hi := ih (r::qs) (rowAct w h f) + simp only [List.append_assoc] at hi + rw [hi] + have hr := rowAct_current (List.replicate w r) qs h f + simp only [List.length_replicate,List.append_assoc] at hr + rw [hr] + simp only [List.cons_append] + + +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators Matrix + +noncomputable def consState (a : Fin 3) (f : FState) : FState + | [] => 0 + | x::xs => if x=a then f xs else 0 +noncomputable def emptyState : FState + | [] => 1 + | _::_ => 0 +noncomputable def vacuum : ℕ → FState + | 0 => emptyState + | n+1 => consState 1 (vacuum n) +noncomputable def twistState (f : FState) : FState := fun xs=> twistProduct xs * f xs + +lemma consState_add (a : Fin 3) (f g : FState) : + consState a (f+g)=consState a f+consState a g := by + funext xs + cases xs <;> simp [consState] ; split <;> simp_all +lemma consState_smul (a : Fin 3) (z : ℂ) (f : FState) : + consState a (z • f)=z • consState a f := by + funext xs + cases xs <;> simp [consState] +lemma consState_zero (a : Fin 3) : consState a 0=0 := by + ext xs; cases xs <;> simp [consState] + +lemma current_zero (qs : List ℂ) : current qs (fun _=>0)=fun _=>0 := + (currentLinear qs).map_zero + +lemma current_emptyHead (q : ℂ) (qs : List ℂ) (f : FState) : + current (q::qs) (consState 1 f) = + q • consState 0 (twistState f) + consState 1 (current qs f) := by + funext xs + cases xs with + | nil => simp [current,consState] + | cons x xs => + fin_cases x <;> simp [current,consState,twistState,raising,untwist,current_zero,mul_assoc,mul_comm] + +lemma current_minusHead (q : ℂ) (qs : List ℂ) (f : FState) : + current (q::qs) (consState 2 f) = + (-q) • consState 1 (twistState f) + r^5 • consState 2 (current qs f) := by + funext xs + cases xs with + | nil => simp [current,consState] + | cons x xs => + fin_cases x <;> simp [current,consState,twistState,raising,untwist,current_zero,mul_assoc,mul_comm] + +lemma twist_consState (a : Fin 3) (f : FState) : + twistState (consState a f)=twist a • consState a (twistState f) := by + ext xs + cases xs with + | nil => simp [consState,twistState] + | cons x xs => + by_cases h : x=a + · subst x; simp [twistState,twistProduct,consState,mul_assoc] + · simp [twistState,consState,h] + +lemma twist_vacuum (n : ℕ) : twistState (vacuum n)=vacuum n := by + induction n with + | zero => ext xs; cases xs <;> simp [vacuum,twistState,twistProduct,emptyState] + | succ n ih => simp only [vacuum,twist_consState,ih]; simp [twist] + +noncomputable def plusSum : List ℂ → FState + | [] => 0 + | q::qs => q • consState 0 (vacuum qs.length)+consState 1 (plusSum qs) + +lemma current_vacuum (qs : List ℂ) : current qs (vacuum qs.length)=plusSum qs := by + induction qs with + | nil => ext xs; rfl + | cons q qs ih => + simp only [List.length_cons,vacuum,current_emptyHead,twist_vacuum,ih,plusSum] + +noncomputable def prefixVac : ℕ → FState → FState + | 0, f => f + | n+1, f => consState 1 (prefixVac n f) +noncomputable def sourceState (pre post : ℕ) : FState := + prefixVac pre (consState 2 (vacuum post)) + +lemma prefixVac_add (n : ℕ) (f g : FState) : prefixVac n (f+g)=prefixVac n f+prefixVac n g := by + induction n with + | zero => rfl + | succ n ih => simp only [prefixVac,ih,consState_add] +lemma prefixVac_smul (n : ℕ) (z : ℂ) (f : FState) : prefixVac n (z • f)=z • prefixVac n f := by + induction n with + | zero => rfl + | succ n ih => simp only [prefixVac,ih,consState_smul] + +lemma twist_source (pre post : ℕ) : twistState (sourceState pre post)=(-r^3) • sourceState pre post := by + induction pre with + | zero => simp [sourceState,prefixVac,twist_consState,twist_vacuum,twist] + | succ pre ih => + change twistState (consState 1 (sourceState pre post))= _ + rw [twist_consState,ih,consState_smul] + simp only [show twist 1=1 from rfl,one_smul] + rfl + +noncomputable def beforeArches : List ℂ → ℕ → FState + | [], _ => 0 + | q::pre, post => q • consState 0 (sourceState pre.length post)+consState 1 (beforeArches pre post) +noncomputable def afterArches (pre : ℕ) (post : List ℂ) : FState := + prefixVac pre (consState 2 (plusSum post)) + +/-- The input side of the boundary Ward identity: the current creates just +one vacuum term and the two ordered classes of source-to-input arcs. -/ +theorem current_source (pre post : List ℂ) (q : ℂ) : + current (pre++q::post) (sourceState pre.length post.length) = + (-q) • vacuum (pre.length+1+post.length) + + (-r^3) • beforeArches pre post.length + r^5 • afterArches pre.length post := by + induction pre with + | nil => + simp only [List.nil_append,List.length_nil,sourceState,prefixVac,current_minusHead, + twist_vacuum,current_vacuum,beforeArches,afterArches,smul_zero,add_zero] + simp [vacuum,Nat.add_comm] + | cons u pre ih => + change current (u::(pre++q::post)) (consState 1 (sourceState pre.length post.length)) = _ + rw [current_emptyHead,twist_source,consState_smul,ih] + simp only [consState_add,consState_smul,List.length_cons,beforeArches,afterArches,prefixVac] + rw [show pre.length+1+1+post.length=(pre.length+1+post.length)+1 by omega] + simp only [vacuum,smul_add,smul_smul] + module + +noncomputable def exitSum : List ℂ → FState → ℂ + | [], _ => 0 + | q::qs, f => q*f (2::List.replicate qs.length 1)+exitSum qs (fun xs=>f (1::xs)) + +lemma twistProduct_vacuum (n : ℕ) : twistProduct (List.replicate n 1)=1 := by + simp [twistProduct,twist] + +lemma current_vacuum_eval (qs : List ℂ) (f : FState) : + current qs f (List.replicate qs.length 1) = -exitSum qs f := by + induction qs generalizing f with + | nil => simp [current,exitSum] + | cons q qs ih => + simp only [List.length_cons,List.replicate_succ,current,exitSum] + rw [ih,twistProduct_vacuum] + simp [raising,untwist,add_comm] + +lemma rowAct_add (i n : ℕ) (f g : FState) : rowAct i n (f+g)=rowAct i n f+rowAct i n g := by + induction n generalizing i f g with + | zero => rfl + | succ n ih => simp only [rowAct,siteAct_add,ih] +lemma rowAct_smul (i n : ℕ) (z : ℂ) (f : FState) : rowAct i n (z • f)=z • rowAct i n f := by + induction n generalizing i f with + | zero => rfl + | succ n ih => simp only [rowAct,siteAct_smul,ih] +lemma rectangleAct_add (w h : ℕ) (f g : FState) : + rectangleAct w h (f+g)=rectangleAct w h f+rectangleAct w h g := by + induction w generalizing f g with + | zero => rfl + | succ w ih => simp only [rectangleAct,rowAct_add,ih] +lemma rectangleAct_smul (w h : ℕ) (z : ℂ) (f : FState) : + rectangleAct w h (z • f)=z • rectangleAct w h f := by + induction w generalizing f with + | zero => rfl + | succ w ih => simp only [rectangleAct,rowAct_smul,ih] + +/-- Exact boundary flux equality for a prescribed input port of the finite +physical lozenge rectangle. The three non-vacuum terms enumerate output +exits and the two contour-ordered classes of input-side arches. -/ +theorem rectangle_boundary_flux (w h : ℕ) (pre post : List ℂ) (q : ℂ) + (directions : List.replicate w r++List.replicate h 1=pre++q::post) : + exitSum (List.replicate h 1++List.replicate w r) + (rectangleAct w h (sourceState pre.length post.length)) + + (-r^3)*(rectangleAct w h (beforeArches pre post.length)) (List.replicate (h+w) 1) + + r^5*(rectangleAct w h (afterArches pre.length post)) (List.replicate (h+w) 1) = + q*(rectangleAct w h (vacuum (w+h))) (List.replicate (h+w) 1) := by + have len : pre.length+1+post.length=w+h := by + have he := congrArg List.length directions + simp only [List.length_append,List.length_replicate,List.length_cons] at he + omega + have hc := congrFun (rectangle_current w h [] (sourceState pre.length post.length)) + (List.replicate (h+w) 1) + simp only [List.append_nil,directions] at hc + rw [current_source,rectangleAct_add,rectangleAct_add,rectangleAct_smul, + rectangleAct_smul,rectangleAct_smul,len] at hc + rw [show h+w=(List.replicate h (1:ℂ)++List.replicate w r).length by simp] at hc + rw [current_vacuum_eval] at hc + simp only [List.length_append,List.length_replicate,Pi.add_apply,Pi.smul_apply,smul_eq_mul] at hc + linear_combination -hc + + +end CriticalHoneycomb.Transfer.FluxWard + +/-! +Planar loop erasure for physical finite strips. +This implements the adjacent cup/cap contractions of the exact dilute +Temperley--Lieb tile. No physical partition-function estimate is assumed. +-/ + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators Matrix +namespace Diagram +abbrev Spin := PlanarNormalization.Spin + +def spinEquiv : Spin ≃ Fin 3 where + toFun := PlanarNormalization.spinIndex + invFun i := if i=1 then none else some (decide (i=2)) + left_inv i := by fin_cases i <;> rfl + right_inv i := by fin_cases i <;> rfl +noncomputable def physicalWeights : PlanarNormalization.TileWeights := + ⟨(kappa:ℂ),(kappa^2:ℂ),(kappa^2:ℂ),(kappa^2:ℂ),0⟩ + +lemma tile_physical (i j k l : Spin) : + PlanarNormalization.tile physicalWeights i j k l = + physicalTile (spinEquiv i) (spinEquiv j) (spinEquiv k) (spinEquiv l) := by + rw [PlanarNormalization.tile_eq_sourceR] + rfl + +noncomputable def decode (f : FState) : PlanarNormalization.DiluteState := + fun xs=>f (xs.map spinEquiv) + +lemma decode_siteAct (i : ℕ) (f : FState) : + decode (siteAct i f)=PlanarNormalization.act physicalWeights i (decode f) := by + induction i generalizing f with + | zero => + funext xs + cases xs with + | nil => rfl + | cons a xs => cases xs with + | nil => rfl + | cons b xs => + simp only [decode,List.map_cons,siteAct,PlanarNormalization.act,tile_physical] + rw [←spinEquiv.sum_comp] + apply Finset.sum_congr rfl + intro s hs + rw [←spinEquiv.sum_comp] + | succ i ih => + funext xs + cases xs with + | nil => rfl + | cons a xs => + change siteAct i (fun ys=>f (spinEquiv a::ys)) (xs.map spinEquiv) = + PlanarNormalization.act physicalWeights i + (decode (fun ys=>f (spinEquiv a::ys))) xs + exact congrFun (ih (fun ys=>f (spinEquiv a::ys))) xs + +lemma decode_vacuum (n : ℕ) : decode (vacuum n)= + PlanarNormalization.embed (List.replicate n false) (fun _=>1) := by + funext xs + induction n generalizing xs with + | zero => cases xs <;> simp [decode,vacuum,emptyState,PlanarNormalization.embed,PlanarNormalization.occupancy] + | succ n ih => + cases xs with + | nil => simp [decode,vacuum,consState,PlanarNormalization.embed,PlanarNormalization.occupancy] + | cons x xs => + fin_cases x <;> + simp [decode,vacuum,consState,spinEquiv,PlanarNormalization.spinIndex, + PlanarNormalization.embed,PlanarNormalization.occupancy,List.replicate_succ] at ih ⊢ + exact ih xs + +lemma decode_vacuum_eval (f : FState) (n : ℕ) : + decode f (List.replicate n none)=f (List.replicate n 1) := by + simp [decode,spinEquiv,PlanarNormalization.spinIndex] + +lemma row_span {N i h : ℕ} (hi : i+h exact hf + | succ h ih => + apply ih (by omega) + rw [decode_siteAct] + exact PlanarNormalization.act_span physicalWeights (by omega) hf + +lemma row_vacuum {N i h : ℕ} (hi : i+h rfl + | succ h ih => + change rowAct (i+1) h (siteAct i f) _ = _ + have ha : PlanarNormalization.PlanarSpan N (decode (siteAct i f)) := by + rw [decode_siteAct] + exact PlanarNormalization.act_span physicalWeights (by omega) hf + rw [ih (by omega) ha] + have he := PlanarNormalization.act_vacuum physicalWeights (by omega : i+1 exact hf + | succ w ih => + apply ih (by omega) + exact row_span (by omega) hf + +lemma rectangle_vacuum {N w h : ℕ} (hi : w+h ≤ N) {f : FState} + (hf : PlanarNormalization.PlanarSpan N (decode f)) : + rectangleAct w h f (List.replicate N 1)=f (List.replicate N 1) := by + induction w generalizing f with + | zero => rfl + | succ w ih => + change rectangleAct w h (rowAct w h f) _ = _ + rw [ih (by omega) (row_span (by omega) hf)] + exact row_vacuum (by omega) hf + +end Diagram + +/-- The boundary Ward identity's normalization is the literal empty +partition: all detached closed honeycomb loops cancel. -/ +theorem rectangle_vacuum_one (w h : ℕ) : + rectangleAct w h (vacuum (w+h)) (List.replicate (h+w) 1)=1 := by + have hs : PlanarNormalization.PlanarSpan (w+h) (Diagram.decode (vacuum (w+h))) := by + rw [Diagram.decode_vacuum] + exact PlanarNormalization.PlanarSpan.basis (List.replicate (w+h) false) 0 .start + (by simp) (by simp [List.count_replicate]) + rw [show h+w=w+h by omega,Diagram.rectangle_vacuum (by omega) hs] + have he := congrFun (Diagram.decode_vacuum (w+h)) (List.replicate (w+h) none) + rw [Diagram.decode_vacuum_eval] at he + simpa [PlanarNormalization.embed,PlanarNormalization.occupancy] using he + +end CriticalHoneycomb.Transfer.FluxWard + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/FluxBounds.lean b/lean/OAI/Combinatorics/HoneycombChords/FluxBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..338bbbdce5364ede2a5af4d855ed02bfc8db6d7b --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/FluxBounds.lean @@ -0,0 +1,1106 @@ +import OAI.Combinatorics.HoneycombChords.Flux + +namespace OAI + +/-! +# Boundary flux estimates + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +/-- Positive combinations of genuine planar tensor diagrams. -/ +inductive PositiveSpan (n b : ℕ) (seed : State) : DiluteState → Prop + | zero : PositiveSpan n b seed (fun _=>0) + | basis (o : List Bool) (k : ℕ) (w : PlanarWord b k) + (hl : o.length=n) (hc : o.count true=b+2*k) : + PositiveSpan n b seed (embed o (w.eval seed)) + | add {F G : DiluteState} (hF : PositiveSpan n b seed F) + (hG : PositiveSpan n b seed G) : PositiveSpan n b seed (fun xs=>F xs+G xs) + | smul (a : ℝ) (ha : 0≤a) {F : DiluteState} (hF : PositiveSpan n b seed F) : + PositiveSpan n b seed (fun xs=>(a:ℂ)*F xs) + +noncomputable def realWeights (a h v c d : ℝ) : TileWeights := + ⟨a,h,v,c,d⟩ + +lemma act_positive {a h v c d : ℝ} (ha : 0≤a) (hh : 0≤h) (hv : 0≤v) + (hc : 0≤c) (hd : 0≤d) {n b i : ℕ} (hb : b≤1) (hi : i+1 rw [act_zero]; exact .zero + | add hF hG ihF ihG => rw [act_add]; exact .add ihF ihG + | smul a ha hF ihF => rw [act_smul]; exact .smul a ha ihF + | basis o k w hl hcount => + obtain ⟨pre,x,y,post,rfl,hpre⟩ := two_at o i (by omega) + subst i + cases x <;> cases y + · rw [act_empty_at] + apply PositiveSpan.add (.basis _ k w hl hcount) + apply PositiveSpan.smul h hh + have hip : pre.count true ≤ b+2*k := by simp [List.count_append] at hcount; omega + exact .basis _ (k+1) (.insert w (pre.count true) hip) + (by simpa using hl) (by simp_all [List.count_append]; omega) + · rw [act_right_at] + exact .add (.smul a ha (.basis _ k w hl hcount)) + (.smul v hv (.basis _ k w (by simpa using hl) + (by simpa [List.count_append,List.count_cons] using hcount))) + · rw [act_left_at] + exact .add (.smul a ha (.basis _ k w hl hcount)) + (.smul v hv (.basis _ k w (by simpa using hl) + (by simpa [List.count_append,List.count_cons] using hcount))) + · have hk : 0 exact .zero _ + | add hF hG ihF ihG => exact ihF.add ihG + | smul a ha hF ihF => exact ihF.smul ha + | basis o k w hl hc => + by_cases ho : occupancy xs=o + · have hx := orientations_length xs + rw [hxs,ho] at hx + have hk : k=0 := by simp at hx; omega + subst k + obtain hw|hw := one_strand_zero_or_identity w seed + · simp only [embed,ho,ite_true,hxs,hw]; exact .zero _ + · simpa only [embed,ho,ite_true,hxs,hw] using hs + · simp only [embed,ho,ite_false]; exact .zero _ + +lemma two_orientation_positive {n : ℕ} {F : DiluteState} + (hF : PositiveSpan n 0 (fun _=>1) F) {xs : List Spin} {a b : Bool} + (hxs : orientations xs=[a,b]) : PhasePositive (F xs) (cup a b) := by + induction hF with + | zero => exact .zero _ + | add hF hG ihF ihG => exact ihF.add ihG + | smul a ha hF ihF => exact ihF.smul ha + | basis o k w hl hc => + by_cases ho : occupancy xs=o + · have hx := orientations_length xs + rw [hxs,ho] at hx + have hk : k=1 := by simp at hx; omega + subst k + obtain ⟨r,hr⟩ := word_normal_form (by omega : 0≤1) w (fun _=>1) + have he := hr [a,b] (by simp) + cases r with + | none => simp only [optionEval] at he + simp only [embed,ho,ite_true,hxs,he]; exact .zero _ + | some ch => + cases ch with + | insert ch i hi => + have hi0 : i=0 := by omega + subst i + cases ch + simp [optionEval,CupHistory.eval,create] at he + refine ⟨1,by positivity,?_⟩ + simpa [embed,ho,hxs] using he + · simp only [embed,ho,ite_false]; exact .zero _ + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +noncomputable def pointState (xs : List Spin) : DiluteState := + fun ys=>if ys=xs then 1 else 0 + +noncomputable def finitePair : ℕ → DiluteState → DiluteState → ℂ + | 0,f,g => f [] * g [] + | n+1,f,g => ∑ x : Spin, finitePair n (fun xs=>f (x::xs)) (fun xs=>g (x::xs)) + +lemma finitePair_comm (n : ℕ) (f g : DiluteState) : finitePair n f g=finitePair n g f := by + induction n generalizing f g with + | zero => simp [finitePair,mul_comm] + | succ n ih => simp only [finitePair,ih] + +lemma finitePair_zero (n : ℕ) (f : DiluteState) : finitePair n (fun _=>0) f=0 := by + induction n generalizing f with + | zero => simp [finitePair] + | succ n ih => simp [finitePair,ih] +lemma finitePair_scalar (n : ℕ) (a : ℂ) (f g : DiluteState) : + finitePair n (fun xs=>a*f xs) g=a*finitePair n f g := by + induction n generalizing f g with + | zero => simp [finitePair,mul_assoc] + | succ n ih => simp only [finitePair,ih,Finset.mul_sum] +lemma finitePair_sum {ι : Type*} [Fintype ι] (n : ℕ) (f : ι → DiluteState) (g : DiluteState) : + finitePair n (fun xs=>∑ i,f i xs) g=∑ i,finitePair n (f i) g := by + induction n generalizing f g with + | zero => simp [finitePair,Finset.sum_mul] + | succ n ih => + simp only [finitePair,ih] + exact Finset.sum_comm +lemma finitePair_scalar_right (n : ℕ) (a : ℂ) (f g : DiluteState) : + finitePair n f (fun xs=>a*g xs)=a*finitePair n f g := by + rw [finitePair_comm,finitePair_scalar,finitePair_comm n g f] +lemma finitePair_sum_right {ι : Type*} [Fintype ι] (n : ℕ) (f : DiluteState) (g : ι → DiluteState) : + finitePair n f (fun xs=>∑ i,g i xs)=∑ i,finitePair n f (g i) := by + rw [finitePair_comm,finitePair_sum] + simp only [finitePair_comm n f] + +lemma pointState_cons (a : Spin) (xs : List Spin) (b : Spin) : + (fun ys=>pointState (a::xs) (b::ys)) = + if b=a then pointState xs else (fun _=>0) := by + funext ys + by_cases h : b=a <;> simp [pointState,h] +lemma finitePair_point (xs : List Spin) (g : DiluteState) : + finitePair xs.length (pointState xs) g=g xs := by + induction xs generalizing g with + | nil => simp [finitePair,pointState] + | cons a xs ih => + change (∑ b : Spin, finitePair xs.length + (fun ys=>pointState (a::xs) (b::ys)) (fun ys=>g (b::ys))) = _ + calc + _ = ∑ b : Spin, if b=a then g (b::xs) else 0 := by + apply Finset.sum_congr rfl + intro b hb + rw [pointState_cons] + by_cases h : b=a <;> simp [h,finitePair_zero,ih] + _ = _ := by simp +lemma finitePair_point_right (xs : List Spin) (g : DiluteState) : + finitePair xs.length g (pointState xs)=g xs := by + rw [finitePair_comm,finitePair_point] + +lemma tile_transpose (t : TileWeights) (x y a b : Spin) : tile t x y a b=tile t a b x y := by + cases x <;> cases y <;> cases a <;> cases b <;> + simp [tile,eq_comm] ; ring + +lemma finitePair_act_zero (t : TileWeights) (n : ℕ) (f g : DiluteState) : + finitePair (n+2) (act t 0 f) g=finitePair (n+2) f (act t 0 g) := by + simp only [finitePair,act,finitePair_sum,finitePair_scalar, + finitePair_sum_right,finitePair_scalar_right] + calc + _ = ∑ a : Spin, ∑ b : Spin, ∑ x : Spin, ∑ y : Spin, + tile t x y a b * finitePair n (fun xs=>f (a::b::xs)) (fun xs=>g (x::y::xs)) := by + calc + _ = ∑ x : Spin, ∑ a : Spin, ∑ y : Spin, ∑ b : Spin, + tile t x y a b * finitePair n (fun xs=>f (a::b::xs)) (fun xs=>g (x::y::xs)) := by + apply Finset.sum_congr rfl + intro x hx + exact Finset.sum_comm + _ = ∑ a : Spin, ∑ x : Spin, ∑ y : Spin, ∑ b : Spin, + tile t x y a b * finitePair n (fun xs=>f (a::b::xs)) (fun xs=>g (x::y::xs)) := Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl + intro a ha + calc + _ = ∑ x : Spin, ∑ b : Spin, ∑ y : Spin, + tile t x y a b * finitePair n (fun xs=>f (a::b::xs)) (fun xs=>g (x::y::xs)) := by + apply Finset.sum_congr rfl + intro x hx + exact Finset.sum_comm + _ = _ := Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + apply Finset.sum_congr rfl + intro x hx + apply Finset.sum_congr rfl + intro y hy + rw [tile_transpose] + +lemma finitePair_act (t : TileWeights) {n i : ℕ} (hi : i+1 + obtain ⟨n,rfl⟩ : ∃ k,n=k+2 := ⟨n-2,by omega⟩ + exact finitePair_act_zero t n f g + | succ i ih => + cases n with + | zero => omega + | succ n => + simp only [finitePair,act] + apply Finset.sum_congr rfl + intro a ha + exact ih (by omega) _ _ + +noncomputable def gates (t : TileWeights) (gs : List ℕ) (f : DiluteState) : DiluteState := + gs.foldl (fun f i=>act t i f) f + +lemma gates_append (t : TileWeights) (gs hs : List ℕ) (f : DiluteState) : + gates t (gs++hs) f=gates t hs (gates t gs f) := by + simp [gates,List.foldl_append] + +lemma finitePair_gates (t : TileWeights) {n : ℕ} (gs : List ℕ) + (hg : ∀ i∈gs,i+1 rfl + | cons i gs ih => + rw [show gates t (i::gs) f=gates t gs (act t i f) from rfl, + ih (by aesop),finitePair_act t (hg i (by simp))] + simp only [List.reverse_cons,gates,List.foldl_append,List.foldl_cons,List.foldl_nil] + +/-- Ordinary transpose, not the Hermitian adjoint: precisely the cup gauge. -/ +theorem gates_kernel_transpose (t : TileWeights) {n : ℕ} (gs : List ℕ) + (hg : ∀ i∈gs,i+1 exact hf + | cons i gs ih => + exact ih (by aesop) (act_positive ha hh hv hc hd hb (hg i (by simp)) hf) + +lemma point_one_positive (xs : List Spin) (a : Bool) (hxs : orientations xs=[a]) : + PositiveSpan xs.length 1 (fun ys=>if ys=[a] then 1 else 0) (pointState xs) := by + unfold pointState + rw [←embed_delta,hxs] + apply PositiveSpan.basis _ 0 .start + · simp [occupancy] + · have h := orientations_length xs + rw [hxs] at h + simpa using h.symm + +lemma point_vacuum_positive (n : ℕ) : + PositiveSpan n 0 (fun _=>1) (pointState (List.replicate n none)) := by + have he : pointState (List.replicate n none)=embed (List.replicate n false) (fun _=>1) := by + funext xs + simp only [pointState,embed,] + congr 1 + apply propext + constructor + · rintro rfl; simp [occupancy] + · intro h + have he : occupancy xs=occupancy (List.replicate n none) := by simpa [occupancy] using h + apply occupancy_orientations_injective he + have hh := orientations_length xs + rw [h] at hh + have hz : orientations xs=[] := List.length_eq_zero_iff.mp (by simpa [List.count_replicate] using hh) + rw [hz] + simp [orientations] + rw [he] + exact .basis _ 0 .start (by simp) (by simp [List.count_replicate]) + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators +namespace Diagram +open PlanarNormalization + +def rowSites : ℕ → ℕ → List ℕ + | _,0 => [] + | i,h+1 => i::rowSites (i+1) h +def rectangleSites : ℕ → ℕ → List ℕ + | 0,_ => [] + | w+1,h => rowSites w h++rectangleSites w h +lemma rowSites_valid {N i h : ℕ} (hi : i+h simp [rowSites] + | succ h ih => + intro j hj + simp only [rowSites,List.mem_cons] at hj + rcases hj with rfl|hj + · omega + · exact ih (by omega) _ hj +lemma rectangleSites_valid {N w h : ℕ} (hi : w+h≤N) : + ∀ j∈rectangleSites w h,j+1 simp [rectangleSites] + | succ w ih => + intro j hj + simp only [rectangleSites,List.mem_append] at hj + rcases hj with hj|hj + · exact rowSites_valid (by omega) _ hj + · exact ih (by omega) _ hj +lemma decode_row (i h : ℕ) (f : FState) : + decode (rowAct i h f)=gates physicalWeights (rowSites i h) (decode f) := by + induction h generalizing i f with + | zero => rfl + | succ h ih => + simp only [rowAct,rowSites,gates,List.foldl_cons] + rw [ih,decode_siteAct] + rfl +lemma decode_rectangle (w h : ℕ) (f : FState) : + decode (rectangleAct w h f)=gates physicalWeights (rectangleSites w h) (decode f) := by + induction w generalizing f with + | zero => rfl + | succ w ih => + simp only [rectangleAct,rectangleSites,gates_append] + rw [ih,decode_row] + +/-- A literal prescribed spin word; the vacant positions are not summed. -/ +noncomputable def stateOn : List Spin → FState + | [] => emptyState + | a::xs => consState (spinEquiv a) (stateOn xs) +lemma decode_stateOn (xs : List Spin) : decode (stateOn xs)=pointState xs := by + induction xs with + | nil => ext ys; cases ys <;> simp [decode,stateOn,emptyState,pointState] + | cons a xs ih => + funext ys + cases ys with + | nil => simp [decode,stateOn,consState,pointState] + | cons b ys => + change (if spinEquiv b=spinEquiv a then decode (stateOn xs) ys else 0)=_ + rw [ih] + simp only [pointState,spinEquiv.injective.eq_iff,List.cons.injEq] + by_cases h : b=a <;> simp [h] +lemma stateOn_vacuum (n : ℕ) : stateOn (List.replicate n none)=vacuum n := by + induction n with + | zero => rfl + | succ n ih => simp only [List.replicate_succ,stateOn,vacuum,ih]; rfl +lemma stateOn_prefix (n : ℕ) (xs : List Spin) : + stateOn (List.replicate n none++xs)=prefixVac n (stateOn xs) := by + induction n with + | zero => rfl + | succ n ih => simp only [List.replicate_succ,List.cons_append,stateOn,prefixVac,ih]; rfl +lemma stateOn_source (pre post : ℕ) : + stateOn (List.replicate pre none++some true::List.replicate post none)=sourceState pre post := by + rw [stateOn_prefix] + simp only [stateOn,stateOn_vacuum,sourceState] + rfl + +lemma physical_nonneg : 0≤kappa := + (Real.rpow_pos_of_pos (by positivity : (0:ℝ)<2+Real.sqrt 2) _).le +lemma physical_eq_realWeights : physicalWeights=realWeights kappa (kappa^2) (kappa^2) (kappa^2) 0 := by + simp [physicalWeights,realWeights,Complex.ofReal_pow] + +lemma rectangle_one_phase (w h : ℕ) (xs ys : List Spin) (hx : xs.length=w+h) + (_hy : ys.length=w+h) {a : Bool} (hxs : orientations xs=[a]) + (hys : orientations ys=[a]) : + PhasePositive (rectangleAct w h (stateOn xs) (ys.map spinEquiv)) 1 := by + change PhasePositive (decode (rectangleAct w h (stateOn xs)) ys) 1 + rw [decode_rectangle,decode_stateOn,physical_eq_realWeights] + have hs : PositiveSpan (w+h) 1 (fun zs=>if zs=[a] then 1 else 0) (pointState xs) := by + simpa only [hx] using point_one_positive xs a hxs + have hg := gates_positive physical_nonneg (sq_nonneg kappa) (sq_nonneg kappa) + (sq_nonneg kappa) le_rfl (by omega : 1≤1) (rectangleSites w h) + (rectangleSites_valid (N:=w+h) (by omega)) hs + exact one_orientation_positive hg hys (by exact ⟨1,by positivity,by simp⟩) + +lemma rectangle_input_pair_phase (w h : ℕ) (xs : List Spin) (hx : xs.length=w+h) + {a b : Bool} (hxs : orientations xs=[a,b]) : + PhasePositive (rectangleAct w h (stateOn xs) (List.replicate (w+h) 1)) (cup a b) := by + have hv : (List.replicate (w+h) none).map spinEquiv=List.replicate (w+h) 1 := by simp [spinEquiv,PlanarNormalization.spinIndex] + rw [←hv] + change PhasePositive (decode (rectangleAct w h (stateOn xs)) (List.replicate (w+h) none)) _ + rw [decode_rectangle,decode_stateOn] + rw [gates_kernel_transpose physicalWeights (rectangleSites w h) + (rectangleSites_valid (by omega)) xs _ hx (by simp),physical_eq_realWeights] + have hg := gates_positive physical_nonneg (sq_nonneg kappa) (sq_nonneg kappa) + (sq_nonneg kappa) le_rfl (by omega : 0≤1) (rectangleSites w h).reverse + (by intro i hi; exact rectangleSites_valid (N:=w+h) (by omega) i (List.mem_reverse.mp hi)) + (point_vacuum_positive (w+h)) + exact two_orientation_positive hg hxs + +end Diagram +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators +open PlanarNormalization + +lemma r_pow_re (n : ℕ) : (r^n).re=Real.cos ((n:ℝ)*Real.pi/8) := by + unfold r + rw [←Complex.exp_nat_mul] + have he : (n:ℂ)*(((Real.pi/8:ℝ):ℂ)*Complex.I)= + (((n:ℝ)*Real.pi/8:ℝ):ℂ)*Complex.I := by push_cast;ring + rw [he,Complex.exp_ofReal_mul_I_re] +lemma r_re_pos : 0 linarith) +lemma r_re_le_one : r.re≤1 := by + simpa using (show (r^1).re≤1 from by rw [r_pow_re]; exact Real.cos_le_one _) +lemma diagram_phase : PlanarNormalization.phase=r^2 := by + rw [r_sq] + unfold PlanarNormalization.phase Planar.phase Planar.angle + congr 1 + push_cast + ring +lemma before_coefficient_nonneg {q : ℂ} (hq : q=1 ∨ q=r) : + 0≤((-r^3)*q*PlanarNormalization.phase).re := by + rw [diagram_phase] + obtain rfl|rfl := hq + · rw [show (-r^3)*(1:ℂ)*r^2= -r^5 by ring,Complex.neg_re,r_pow_re] + have he : (5:ℝ)*Real.pi/8=Real.pi-3*Real.pi/8 := by ring + norm_num only [Nat.cast_ofNat] at * + rw [he,Real.cos_pi_sub,neg_neg] + apply (Real.cos_pos_of_mem_Ioo _).le + constructor <;> linarith [Real.pi_pos] + · rw [show (-r^3)*r*r^2= -r^6 by ring,Complex.neg_re,r_pow_re] + have he : (6:ℝ)*Real.pi/8=Real.pi-Real.pi/4 := by ring + norm_num only [Nat.cast_ofNat] at * + rw [he,Real.cos_pi_sub,neg_neg] + apply (Real.cos_pos_of_mem_Ioo _).le + constructor <;> linarith [Real.pi_pos] +lemma after_coefficient_nonneg {q : ℂ} (hq : q=1 ∨ q=r) : + 0≤(r^5*q*PlanarNormalization.phase⁻¹).re := by + rw [diagram_phase] + have hn : r≠0 := r_ne_zero + obtain rfl|rfl := hq + · rw [show r^5*(1:ℂ)*(r^2)⁻¹=r^3 from by field_simp [hn],r_pow_re] + apply (Real.cos_pos_of_mem_Ioo _).le + constructor <;> linarith [Real.pi_pos] + · rw [show r^5*r*(r^2)⁻¹=r^4 from by field_simp [hn],r_pow_re] + have he : (4:ℝ)*Real.pi/8=Real.pi/2 := by ring + norm_num only [Nat.cast_ofNat] + rw [he,Real.cos_pi_div_two] + +lemma phasePositive_mul_real_nonneg {z p q : ℂ} (hz : PhasePositive z p) + (hq : 0≤(q*p).re) : 0≤(q*z).re := by + obtain ⟨a,ha,rfl⟩ := hz + rw [show q*((a:ℂ)*p)=(a:ℂ)*(q*p) by ring] + simpa using mul_nonneg ha hq + +lemma prefixVac_zero (n : ℕ) : prefixVac n 0=0 := by + have h := prefixVac_smul n 0 (0:FState) + simpa using h +lemma rectangleAct_zero (w h : ℕ) : rectangleAct w h 0=0 := by + have he := rectangleAct_smul w h 0 (0:FState) + simpa using he + +noncomputable def emptyEval (w h : ℕ) (f : FState) : ℂ := + rectangleAct w h f (List.replicate (w+h) 1) +lemma emptyEval_add (w h : ℕ) (f g : FState) : + emptyEval w h (f+g)=emptyEval w h f+emptyEval w h g := by + simp [emptyEval,rectangleAct_add] +lemma emptyEval_smul (w h : ℕ) (q : ℂ) (f : FState) : + emptyEval w h (q • f)=q*emptyEval w h f := by + simp [emptyEval,rectangleAct_smul] +lemma emptyEval_zero (w h : ℕ) : emptyEval w h 0=0 := by simp [emptyEval,rectangleAct_zero] + +noncomputable def twoState (pre gap post : ℕ) (a b : Bool) : FState := + prefixVac pre (consState (Diagram.spinEquiv (some a)) + (prefixVac gap (consState (Diagram.spinEquiv (some b)) (vacuum post)))) +lemma twoState_phase (w h pre gap post : ℕ) (a b : Bool) + (hlen : pre+gap+post+2=w+h) : + PhasePositive (emptyEval w h (twoState pre gap post a b)) (cup a b) := by + let xs : List Diagram.Spin := List.replicate pre none++some a:: + (List.replicate gap none++some b::List.replicate post none) + have hx : xs.length=w+h := by simp [xs];omega + have he : Diagram.stateOn xs=twoState pre gap post a b := by + simp only [xs,Diagram.stateOn_prefix,Diagram.stateOn,Diagram.stateOn_vacuum,twoState] + rw [←he] + exact Diagram.rectangle_input_pair_phase w h xs hx (by simp [xs,orientations]) + +lemma prefixVac_cons_one (n : ℕ) (f : FState) : + prefixVac n (consState 1 f)=prefixVac (n+1) f := by + induction n with + | zero => rfl + | succ n ih => simpa only [prefixVac] using congrArg (consState 1) ih + +lemma before_real_nonneg (w h : ℕ) (pre : List ℂ) (post lead : ℕ) + (hlen : lead+pre.length+1+post=w+h) + (hpre : ∀ q∈pre,q=1 ∨ q=r) : + 0≤((-r^3)*emptyEval w h (prefixVac lead (beforeArches pre post))).re := by + induction pre generalizing lead with + | nil => simp [beforeArches,prefixVac_zero,emptyEval_zero] + | cons q pre ih => + have hhead : 0≤((-r^3)*q*emptyEval w h + (prefixVac lead (consState 0 (sourceState pre.length post)))).re := by + apply phasePositive_mul_real_nonneg _ (before_coefficient_nonneg (hpre q (by simp))) + change PhasePositive (emptyEval w h (twoState lead pre.length post false true)) (cup false true) + exact twoState_phase w h lead pre.length post false true (by simp at hlen;omega) + have htail := ih (lead+1) (by simp at hlen;omega) (by aesop) + simp only [beforeArches,prefixVac_add,prefixVac_smul,emptyEval_add,emptyEval_smul] + have he : prefixVac lead (consState 1 (beforeArches pre post))= + prefixVac (lead+1) (beforeArches pre post) := by + exact prefixVac_cons_one lead _ + rw [he,mul_add,Complex.add_re] + simpa only [mul_assoc] using add_nonneg hhead htail + +lemma after_real_nonneg (w h : ℕ) (post : List ℂ) (lead gap : ℕ) + (hlen : lead+gap+1+post.length=w+h) + (hpost : ∀ q∈post,q=1 ∨ q=r) : + 0≤(r^5*emptyEval w h + (prefixVac lead (consState 2 (prefixVac gap (plusSum post))))).re := by + induction post generalizing gap with + | nil => simp [plusSum,prefixVac_zero,consState_zero,emptyEval_zero] + | cons q post ih => + have hhead : 0≤(r^5*q*emptyEval w h (twoState lead gap post.length true false)).re := by + apply phasePositive_mul_real_nonneg _ (after_coefficient_nonneg (hpost q (by simp))) + exact twoState_phase w h lead gap post.length true false (by simp at hlen;omega) + have htail := ih (gap+1) (by simp at hlen;omega) (by aesop) + simp only [plusSum,prefixVac_smul,prefixVac_add,consState_add,consState_smul, + emptyEval_add,emptyEval_smul] + have he : prefixVac gap (consState 1 (plusSum post))=prefixVac (gap+1) (plusSum post) := by + exact prefixVac_cons_one gap _ + rw [he,mul_add,Complex.add_re] + change 0≤(r^5*(q*emptyEval w h (twoState lead gap post.length true false))).re+_ + exact add_nonneg (by simpa only [mul_assoc] using hhead) htail + +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators +open PlanarNormalization + +def minusWord (pre post : ℕ) : List (Fin 3) := + List.replicate pre 1++2::List.replicate post 1 + +def OneNonneg (n : ℕ) (f : FState) : Prop := + ∀ pre post,pre+1+post=n → PhasePositive (f (minusWord pre post)) 1 + +lemma rectangle_source_positive (w h pre post : ℕ) (hlen : pre+1+post=w+h) : + OneNonneg (w+h) (rectangleAct w h (sourceState pre post)) := by + intro a b hab + let xs : List Diagram.Spin := List.replicate pre none++some true::List.replicate post none + let ys : List Diagram.Spin := List.replicate a none++some true::List.replicate b none + have hx : xs.length=w+h := by simp [xs];omega + have hy : ys.length=w+h := by simp [ys];omega + have hs : Diagram.stateOn xs=sourceState pre post := Diagram.stateOn_source pre post + have ht : ys.map Diagram.spinEquiv=minusWord a b := by + simp [ys,minusWord,Diagram.spinEquiv,spinIndex] + rw [←hs,←ht] + exact Diagram.rectangle_one_phase w h xs ys hx hy (a:=true) (by simp [xs,orientations]) + (by simp [ys,orientations]) + +lemma exitSum_real_nonneg (qs : List ℂ) (f : FState) + (hf : OneNonneg qs.length f) (hq : ∀ q∈qs,0≤q.re) : + 0≤(exitSum qs f).re := by + induction qs generalizing f with + | nil => simp [exitSum] + | cons q qs ih => + rw [exitSum,Complex.add_re] + apply add_nonneg + · apply phasePositive_mul_real_nonneg (hf 0 qs.length (by simp;omega)) + simpa using hq q (by simp) + · apply ih + · intro a b hab + simpa [minusWord,List.replicate_succ] using hf (a+1) b (by simp;omega) + · intro u hu;exact hq u (by simp [hu]) + +lemma exitSum_append (as bs : List ℂ) (f : FState) : + exitSum (as++bs) f = + exitSum as (fun xs=>f (xs++List.replicate bs.length 1)) + + exitSum bs (fun xs=>f (List.replicate as.length 1++xs)) := by + induction as generalizing f with + | nil => simp [exitSum] + | cons a as ih => + simp only [List.cons_append,exitSum,List.length_append,List.length_cons] + rw [ih] + simp only [List.replicate_add,List.cons_append,List.replicate_succ] + ring + +lemma rectangle_output_bound (w h : ℕ) (pre post : List ℂ) (q : ℂ) + (directions : List.replicate w r++List.replicate h 1=pre++q::post) : + (exitSum (List.replicate h 1++List.replicate w r) + (rectangleAct w h (sourceState pre.length post.length))).re≤q.re := by + have len : pre.length+1+post.length=w+h := by + have he := congrArg List.length directions + simp only [List.length_append,List.length_replicate,List.length_cons] at he + omega + have hd : ∀ z∈pre++q::post,z=1 ∨ z=r := by + rw [←directions] + intro z hz + simp only [List.mem_append,List.mem_replicate] at hz + aesop + have hb := before_real_nonneg w h pre post.length 0 (by omega) + (by intro z hz;exact hd z (List.mem_append_left _ hz)) + have ha := after_real_nonneg w h post pre.length 0 (by omega) + (by intro z hz;exact hd z (List.mem_append_right _ (List.mem_cons_of_mem _ hz))) + simp only [prefixVac] at hb ha + have he := rectangle_boundary_flux w h pre post q directions + rw [rectangle_vacuum_one,show h+w=w+h by omega] at he + have hre := congrArg Complex.re he + simp only [Complex.add_re,mul_one] at hre + change (exitSum _ _).re+((-r^3)*emptyEval w h (beforeArches pre post.length)).re+ + (r^5*emptyEval w h (afterArches pre.length post)).re=q.re at hre + change 0≤(r^5*emptyEval w h (afterArches pre.length post)).re at ha + linarith + +/-- Finite physical parafermionic flux bounds the total opposite-side +one-strand coefficient, uniformly in both rectangle dimensions. -/ +theorem rectangle_west_exit_bound (w k post : ℕ) : + (exitSum (List.replicate (k+1+post) 1) + (fun xs=>rectangleAct w (k+1+post) (sourceState (w+k) post) + (xs++List.replicate w 1))).re≤1 := by + let h := k+1+post + have hd : List.replicate w r++List.replicate h (1:ℂ)= + (List.replicate w r++List.replicate k 1)++1::List.replicate post 1 := by + change List.replicate w r++List.replicate (k+1+post) (1:ℂ)=_ + rw [show k+1+post=k+(1+post) by omega,List.replicate_add] + simp only [show 1+post=post+1 by omega,List.replicate_succ,List.append_assoc] + have he := rectangle_output_bound w h (List.replicate w r++List.replicate k 1) + (List.replicate post 1) 1 hd + simp only [List.length_append,List.length_replicate,Complex.one_re] at he + rw [exitSum_append,Complex.add_re] at he + have hn : 0≤(exitSum (List.replicate w r) + (fun xs=>rectangleAct w h (sourceState (w+k) post) + (List.replicate h 1++xs))).re := by + apply exitSum_real_nonneg + · intro a b hab + have hp := rectangle_source_positive w h (w+k) post (by dsimp [h];omega) + simpa only [minusWord,List.replicate_add,List.append_assoc] using hp (h+a) b (by simp at hab;omega) + · intro q hq + obtain ⟨_,rfl⟩ := List.mem_replicate.mp hq + exact r_re_pos.le + simp only [List.length_replicate] at he + dsimp [h] at he hn + linarith + +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators Matrix + +lemma siteAct_zero_state (i : ℕ) : siteAct i 0=0 := by + have h := siteAct_smul i 0 (0:FState) + simpa using h + +lemma siteAct_congr_length (i n : ℕ) (f g : FState) + (hfg : ∀ xs,xs.length=n → f xs=g xs) : + ∀ xs,xs.length=n → siteAct i f xs=siteAct i g xs := by + induction i generalizing n f g with + | zero => + intro xs hx + cases xs with + | nil => rfl + | cons a xs => cases xs with + | nil => rfl + | cons b xs => + simp only [siteAct] + apply Finset.sum_congr rfl + intro c hc + apply Finset.sum_congr rfl + intro d hd + rw [hfg (c::d::xs) (by simpa using hx)] + | succ i ih => + intro xs hx + cases xs with + | nil => rfl + | cons a xs => + simp only [siteAct] + apply ih (n-1) + · intro ys hy;apply hfg; simp at hx ⊢; omega + · simp at hx;omega + +lemma rowAct_congr_length (i h n : ℕ) (f g : FState) + (hfg : ∀ xs,xs.length=n → f xs=g xs) : + ∀ xs,xs.length=n → rowAct i h f xs=rowAct i h g xs := by + induction h generalizing i f g with + | zero => exact hfg + | succ h ih => exact ih (i+1) _ _ (siteAct_congr_length i n f g hfg) + +lemma rectangleAct_congr_length (w h n : ℕ) (f g : FState) + (hfg : ∀ xs,xs.length=n → f xs=g xs) : + ∀ xs,xs.length=n → rectangleAct w h f xs=rectangleAct w h g xs := by + induction w generalizing f g with + | zero => exact hfg + | succ w ih => exact ih _ _ (rowAct_congr_length w h n f g hfg) + +lemma siteAct_suffix (i : ℕ) (f : FState) (xs ys : List (Fin 3)) + (hi : i+2≤xs.length) : + siteAct i f (xs++ys)=siteAct i (fun zs=>f (zs++ys)) xs := by + induction i generalizing f xs with + | zero => + cases xs with + | nil => simp at hi + | cons a xs => cases xs with + | nil => simp at hi + | cons b xs => rfl + | succ i ih => + cases xs with + | nil => simp at hi + | cons a xs => + simpa only [List.cons_append,siteAct] using + ih (fun zs=>f (a::zs)) xs (by simp at hi;omega) + +lemma rowAct_suffix (i h : ℕ) (f : FState) (xs ys : List (Fin 3)) + (hi : i+hf (zs++ys)) xs := by + induction h generalizing i f with + | zero => rfl + | succ h ih => + simp only [rowAct] + rw [ih (i+1) (siteAct i f) (by omega)] + apply rowAct_congr_length (i+1) h xs.length _ _ _ xs rfl + intro zs hz + exact siteAct_suffix i f zs ys (by omega) + +lemma rectangleAct_suffix (w h : ℕ) (f : FState) (xs ys : List (Fin 3)) + (hi : w+h≤xs.length) : + rectangleAct w h f (xs++ys)=rectangleAct w h (fun zs=>f (zs++ys)) xs := by + induction w generalizing f with + | zero => rfl + | succ w ih => + simp only [rectangleAct] + rw [ih (rowAct w h f) (by omega)] + apply rectangleAct_congr_length w h xs.length _ _ _ xs rfl + intro zs hz + exact rowAct_suffix w h f zs ys (by omega) + +lemma siteAct_prefixVac (pre i : ℕ) (f : FState) : + siteAct (pre+i) (prefixVac pre f)=prefixVac pre (siteAct i f) := by + induction pre generalizing f with + | zero => simp only [Nat.zero_add,prefixVac] + | succ pre ih => + rw [show pre+1+i=(pre+i)+1 by omega] + funext xs + cases xs with + | nil => rfl + | cons a xs => + simp only [prefixVac,siteAct,consState] + by_cases ha : a=1 + · simp only [ha,ite_true] + exact congrFun (ih f) xs + · simp only [ha,ite_false] + change siteAct (pre+i) (0:FState) xs=0 + rw [siteAct_zero_state] + rfl + +lemma rowAct_prefixVac (pre i h : ℕ) (f : FState) : + rowAct (pre+i) h (prefixVac pre f)=prefixVac pre (rowAct i h f) := by + induction h generalizing i f with + | zero => rfl + | succ h ih => + simp only [rowAct,siteAct_prefixVac] + rw [show pre+i+1=pre+(i+1) by omega,ih] + +lemma prefixVac_eval_append (pre : ℕ) (f : FState) (xs ys : List (Fin 3)) + (hx : pre≤xs.length) : + prefixVac pre f (xs++ys)=prefixVac pre (fun zs=>f (zs++ys)) xs := by + induction pre generalizing xs with + | zero => rfl + | succ pre ih => + cases xs with + | nil => simp at hx + | cons a xs => + simp only [List.cons_append,prefixVac,consState] + split_ifs + · exact ih xs (by simp at hx;omega) + · rfl + +noncomputable def vacuumColumn (h : ℕ) (f : FState) : FState := + fun xs=>rowAct 0 h (consState 1 f) (xs++[1]) + +/-- Sweeping the lozenge rectangle and then fixing the north boundary +is exactly iteration of its literal empty-auxiliary column. -/ +theorem rectangle_eq_columns (w h : ℕ) (f : FState) (xs : List (Fin 3)) + (hx : xs.length=h) : + rectangleAct w h (prefixVac w f) (xs++List.replicate w 1)= + (vacuumColumn h)^[w] f xs := by + induction w generalizing f with + | zero => simp [rectangleAct,prefixVac] + | succ w ih => + have hp : prefixVac (w+1) f=prefixVac w (consState 1 f) := by + exact (prefixVac_cons_one w f).symm + rw [rectangleAct,hp] + have hr := rowAct_prefixVac w 0 h (consState 1 f) + simp only [Nat.add_zero] at hr + rw [hr] + rw [show List.replicate (w+1) (1:Fin 3)=List.replicate w 1++[1] by + rw [List.replicate_add];rfl,←List.append_assoc] + rw [rectangleAct_suffix w h _ _ _ (by simp [hx];omega)] + have he : ∀ zs,zs.length=w+h → + prefixVac w (rowAct 0 h (consState 1 f)) (zs++[1])= + prefixVac w (vacuumColumn h f) zs := by + intro zs hz + exact prefixVac_eval_append w _ zs [1] (by omega) + rw [rectangleAct_congr_length w h (w+h) _ _ he _ (by simp [hx];omega),ih] + rw [Function.iterate_succ_apply] + +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators Matrix + +lemma decode_rowAct (i h : ℕ) (f : FState) : + Diagram.decode (rowAct i h f)= + PlanarNormalization.planarRow i (List.replicate h Diagram.physicalWeights) (Diagram.decode f) := by + induction h generalizing i f with + | zero => rfl + | succ h ih => + simp only [rowAct,List.replicate_succ,PlanarNormalization.planarRow,ih,Diagram.decode_siteAct] + +lemma spinEquiv_eq : Diagram.spinEquiv=RasterGrid.spinEquiv := rfl +lemma physicalWeights_eq : Diagram.physicalWeights=RasterGrid.physicalWeights := rfl + +noncomputable def columnBasis {h : ℕ} (east : RasterGrid.Column h) : FState := + fun xs=>if xs=List.ofFn east then 1 else 0 + +lemma cons_columnBasis {h : ℕ} (east : RasterGrid.Column h) : + consState 1 (columnBasis east)=fun xs=>if xs=1::List.ofFn east then 1 else 0 := by + funext xs + cases xs with + | nil => simp [consState] + | cons a xs => + by_cases ha : a=1 <;> by_cases hx : xs=List.ofFn east <;> + simp [consState,columnBasis,ha,hx] + +lemma vacuumColumn_basis_eq_kernel (h : ℕ) (west east : RasterGrid.Column h) : + vacuumColumn h (columnBasis east) (List.ofFn west)= + RasterGrid.columnKernel h 1 1 west east := by + let we := (RasterGrid.columnSpinEquiv h).symm west + let ea := (RasterGrid.columnSpinEquiv h).symm east + have hw : RasterGrid.columnSpinEquiv h we=west := (RasterGrid.columnSpinEquiv h).apply_symm_apply west + have he : RasterGrid.columnSpinEquiv h ea=east := (RasterGrid.columnSpinEquiv h).apply_symm_apply east + rw [←hw,←he] + have hk := RasterGrid.columnKernel_eq_planarRow h none none we ea + change RasterGrid.columnKernel h 1 1 _ _ = _ at hk + rw [hk] + change vacuumColumn h (columnBasis _) (List.ofFn _)=_ + have hl : List.ofFn (RasterGrid.columnSpinEquiv h we)++[1]= + (List.ofFn we++[none]).map Diagram.spinEquiv := by + simp [RasterGrid.columnSpinEquiv,List.map_ofFn,Diagram.spinEquiv,PlanarNormalization.spinIndex] + rfl + unfold vacuumColumn + rw [hl] + change Diagram.decode (rowAct 0 h (consState 1 (columnBasis _))) (List.ofFn we++[none])=_ + rw [decode_rowAct,physicalWeights_eq,cons_columnBasis] + congr 2 + funext xs + unfold Diagram.decode + have hmap : Diagram.spinEquiv <$> (none::List.ofFn ea)=1::List.ofFn (RasterGrid.columnSpinEquiv h ea) := by + simp [RasterGrid.columnSpinEquiv,List.map_ofFn,Diagram.spinEquiv,PlanarNormalization.spinIndex] + rfl + rw [←hmap] + change (if xs.map Diagram.spinEquiv = (none::List.ofFn ea).map Diagram.spinEquiv then 1 else 0)=_ + simp only [List.map_inj_right (fun _ _ h=>Diagram.spinEquiv.injective h)] + +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators Matrix + +lemma consState_sum {α : Type*} [Fintype α] (b : Fin 3) (f : α → FState) : + consState b (fun xs=>∑ a,f a xs)=fun xs=>∑ a,consState b (f a) xs := by + funext xs + cases xs <;> simp [consState] + +lemma rowAct_sum {α : Type*} [Fintype α] (i h : ℕ) (f : α → FState) : + rowAct i h (fun xs=>∑ a,f a xs)=fun xs=>∑ a,rowAct i h (f a) xs := by + induction h generalizing i f with + | zero => rfl + | succ h ih => + simp only [rowAct] + rw [show siteAct i (fun xs=>∑ a,f a xs)=fun xs=>∑ a,siteAct i (f a) xs from by + funext xs; exact siteAct_sum i f xs,ih] + +lemma vacuumColumn_sum {α : Type*} [Fintype α] (h : ℕ) (f : α → FState) : + vacuumColumn h (fun xs=>∑ a,f a xs)=fun xs=>∑ a,vacuumColumn h (f a) xs := by + funext xs + simp only [vacuumColumn,consState_sum,rowAct_sum] +lemma vacuumColumn_scalar (h : ℕ) (z : ℂ) (f : FState) : + vacuumColumn h (fun xs=>z*f xs)=fun xs=>z*vacuumColumn h f xs := by + funext xs + change vacuumColumn h (z • f) xs=_ + simp only [vacuumColumn,consState_smul,rowAct_smul,Pi.smul_apply,smul_eq_mul] + +lemma columnBasis_expansion (h : ℕ) (f : FState) (xs : List (Fin 3)) (hx : xs.length=h) : + f xs=∑ east : RasterGrid.Column h,f (List.ofFn east)*columnBasis east xs := by + classical + subst h + have he : List.ofFn xs.get=xs := List.ofFn_get xs + have hb (east : RasterGrid.Column xs.length) : xs=List.ofFn east ↔ xs.get=east := by + calc + xs=List.ofFn east ↔ List.ofFn xs.get=List.ofFn east := by rw [List.ofFn_get] + _ ↔ xs.get=east := List.ofFn_inj + simp [columnBasis,hb,mul_ite,he] + +lemma vacuumColumn_congr (h : ℕ) (f g : FState) + (hfg : ∀ xs,xs.length=h → f xs=g xs) (xs : List (Fin 3)) (hx : xs.length=h) : + vacuumColumn h f xs=vacuumColumn h g xs := by + apply rowAct_congr_length 0 h (h+1) _ _ _ _ (by simp [hx]) + intro ys hy + cases ys with + | nil => simp at hy + | cons a ys => + by_cases ha : a=1 + · simp only [consState,ha,ite_true] + exact hfg ys (by simpa using hy) + · simp [consState,ha] + +lemma vacuumColumn_as_matrix (h : ℕ) (f : FState) (west : RasterGrid.Column h) : + vacuumColumn h f (List.ofFn west)= + ∑ east : RasterGrid.Column h,RasterGrid.columnKernel h 1 1 west east*f (List.ofFn east) := by + rw [vacuumColumn_congr h f (fun xs=>∑ east : RasterGrid.Column h, + f (List.ofFn east)*columnBasis east xs) (columnBasis_expansion h f) _ (List.length_ofFn), + vacuumColumn_sum] + apply Finset.sum_congr rfl + intro east he + rw [vacuumColumn_scalar] + change f (List.ofFn east)*vacuumColumn h (columnBasis east) (List.ofFn west)=_ + rw [vacuumColumn_basis_eq_kernel,mul_comm] + +lemma iterateColumn_basis_eq_power (w h : ℕ) (west east : RasterGrid.Column h) : + (vacuumColumn h)^[w] (columnBasis east) (List.ofFn west)= + ((RasterGrid.columnKernel h 1 1)^w) west east := by + induction w generalizing west with + | zero => simp [columnBasis,Matrix.one_apply,List.ofFn_inj] + | succ w ih => + rw [Function.iterate_succ_apply',vacuumColumn_as_matrix,pow_succ',Matrix.mul_apply] + apply Finset.sum_congr rfl + intro middle hm + rw [ih] + +/-- Literal finite rectangle: the flux raster and the actual center/path +matrix use exactly the same vacuum north/south boundary and ordering. -/ +theorem rectangle_columnBasis_eq_prescribed (w h : ℕ) (west east : RasterGrid.Column h) : + rectangleAct w h (prefixVac w (columnBasis east)) + (List.ofFn west++List.replicate w 1)= + RasterGrid.prescribedPartition w h west east (fun _=>1) (fun _=>1) := by + rw [rectangle_eq_columns w h _ _ (List.length_ofFn),iterateColumn_basis_eq_power, + RasterGrid.prescribedPartition_eq_transfer] + simp + +end CriticalHoneycomb.Transfer.FluxWard + +namespace CriticalHoneycomb.Transfer.FluxWard +open scoped BigOperators +lemma vacuum_indicator (n : ℕ) (xs : List (Fin 3)) : + vacuum n xs=if xs=List.replicate n 1 then 1 else 0 := by + induction n generalizing xs with + | zero => cases xs <;> simp [vacuum,emptyState] + | succ n ih => + cases xs with + | nil => simp [vacuum,consState] + | cons a xs => + by_cases ha : a=1 <;> simp [vacuum,consState,ha,ih,List.replicate_succ] + +lemma prefixVac_indicator (n : ℕ) (ys : List (Fin 3)) : + prefixVac n (fun xs=>if xs=ys then 1 else 0)= + fun xs=>if xs=List.replicate n 1++ys then 1 else 0 := by + induction n with + | zero => rfl + | succ n ih => + funext xs + cases xs with + | nil => simp [prefixVac,consState] + | cons a xs => + by_cases ha : a=1 <;> simp [prefixVac,consState,ha,ih,List.replicate_succ] + +lemma sourceState_indicator (pre post : ℕ) : + sourceState pre post = + fun xs=>if xs=List.replicate pre 1++2::List.replicate post 1 then 1 else 0 := by + have hv : vacuum post=fun xs=>if xs=List.replicate post 1 then 1 else 0 := + funext (vacuum_indicator post) + unfold sourceState + rw [hv] + have hc : consState 2 (fun xs=>if xs=List.replicate post 1 then 1 else 0)= + fun xs=>if xs=2::List.replicate post 1 then 1 else 0 := by + funext xs + cases xs with + | nil => simp [consState] + | cons a xs => by_cases ha : a=2 <;> simp [consState,ha] + rw [hc,prefixVac_indicator] + +lemma singleColumn_list {h : ℕ} (j : Fin h) : + List.ofFn (RasterGrid.singleColumn j)= + List.replicate j.val 1++2::List.replicate (h-1-j.val) 1 := by + apply List.ext_getElem + · simp + omega + · intro n h₁ h₂ + have hnH : n simp [prefixVac] + | succ w ih => simpa [sourceState,prefixVac,Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using congrArg (consState 1) ih + +lemma exitSum_eq_sum (h : ℕ) (f : FState) : + exitSum (List.replicate h 1) f=∑ j : Fin h,f (List.ofFn (RasterGrid.singleColumn j)) := by + induction h generalizing f with + | zero => simp [exitSum] + | succ h ih => + rw [List.replicate_succ,exitSum,ih,Fin.sum_univ_succ] + simp only [List.length_replicate,one_mul] + congr 1 + · congr 1 + rw [singleColumn_list] + simp + · apply Finset.sum_congr rfl + intro j hj + congr 1 + rw [singleColumn_list,singleColumn_list] + simp only [Fin.val_succ,List.replicate_succ,List.cons_append] + rw [show h-1-j.val=(h+1)-1-(j.val+1) by omega] + +/-- The actual literal honeycomb chord sum to the opposite wall, not an +abstract positivity assumption on a transfer matrix. -/ +theorem rectangle_actual_sum_bound (W H : ℕ) (k : Fin (H+1)) : + (∑ j : Fin (H+1),∑ γ : RasterGrid.RectChord W H j k, + kappa^γ.val.length)≤1 := by + classical + have hf := rectangle_west_exit_bound (W+1) k.val (H-k.val) + have hk := k.isLt + have hl : k.val+1+(H-k.val)=H+1 := by omega + rw [hl] at hf + have hs : sourceState (W+1+k.val) (H-k.val)= + prefixVac (W+1) (columnBasis (RasterGrid.singleColumn k)) := by + rw [←sourceState_eq_basis,prefixVac_source] + simp + rw [hs,exitSum_eq_sum] at hf + simpa only [rectangle_columnBasis_eq_prescribed,RasterGrid.actual_chord_sum_eq_transfer, + Complex.re_sum,←Complex.ofReal_pow,Complex.ofReal_re] using hf + +theorem rectangle_actual_mass_bound (W H : ℕ) (k : Fin (H+1)) : + (∑ j : Fin (H+1),chordMass (RasterGrid.domain (W+1) (H+1) : Set Center) + (RasterGrid.westPort W H j) (RasterGrid.eastPort W H k))≤1 := by + classical + simp_rw [RasterGrid.actual_chordMass_eq_transfer,RasterGrid.actual_chord_sum_eq_transfer, + Complex.re_sum,←Complex.ofReal_pow,Complex.ofReal_re] + rw [←ENNReal.ofReal_sum_of_nonneg] + · exact (ENNReal.ofReal_le_ofReal (rectangle_actual_sum_bound W H k)).trans (by simp) + · intro j hj + apply Finset.sum_nonneg + intro γ hγ + apply pow_nonneg + exact (Real.rpow_pos_of_pos (by positivity : (0:ℝ)<2+Real.sqrt 2) _).le +end CriticalHoneycomb.Transfer.FluxWard + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/FourFunctions.lean b/lean/OAI/Combinatorics/HoneycombChords/FourFunctions.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a2da77aa054326c7013ac8a441dc944c672de16 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/FourFunctions.lean @@ -0,0 +1,273 @@ +import Mathlib + +namespace OAI + +/-! +# Four-functions inequalities for ordered real vectors + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section + +/-! A continuous four-functions inequality on bounded sublattices. -/ +namespace Honeycomb370 +open MeasureTheory Filter Set +open scoped Topology Pointwise + +private def rationalGrid {ι : Type*} [Fintype ι] (n : ℕ) [NeZero n] : + Sublattice (ι → ℝ) where + carrier := (n : ℝ)⁻¹ • Submodule.span ℤ (Set.range (Pi.basisFun ℝ ι)) + supClosed' := by + intro x hx y hy + rw [← Submodule.coe_pointwise_smul] at hx hy ⊢ + have hx := (BoxIntegral.unitPartition.mem_smul_span_iff (n := n) (v := x)).mp hx + have hy := (BoxIntegral.unitPartition.mem_smul_span_iff (n := n) (v := y)).mp hy + apply (BoxIntegral.unitPartition.mem_smul_span_iff (n := n)).mpr + intro i + rcases le_total (x i) (y i) with h | h + · simpa [Pi.sup_apply, max_eq_right h] using hy i + · simpa [Pi.sup_apply, max_eq_left h] using hx i + infClosed' := by + intro x hx y hy + rw [← Submodule.coe_pointwise_smul] at hx hy ⊢ + have hx := (BoxIntegral.unitPartition.mem_smul_span_iff (n := n) (v := x)).mp hx + have hy := (BoxIntegral.unitPartition.mem_smul_span_iff (n := n) (v := y)).mp hy + apply (BoxIntegral.unitPartition.mem_smul_span_iff (n := n)).mpr + intro i + rcases le_total (x i) (y i) with h | h + · simpa [Pi.inf_apply, min_eq_left h] using hx i + · simpa [Pi.inf_apply, min_eq_right h] using hy i + +theorem continuous_four_functions {ι : Type*} [Fintype ι] + (S : Sublattice (ι → ℝ)) (hs₁ : Bornology.IsBounded (S : Set (ι → ℝ))) + (hs₂ : MeasurableSet (S : Set (ι → ℝ))) + (hs₃ : volume (frontier (S : Set (ι → ℝ))) = 0) + (f₁ f₂ f₃ f₄ : (ι → ℝ) → ℝ) + (hc₁ : Continuous f₁) (hc₂ : Continuous f₂) + (hc₃ : Continuous f₃) (hc₄ : Continuous f₄) + (h₁ : ∀ x ∈ S, 0 ≤ f₁ x) (h₂ : ∀ x ∈ S, 0 ≤ f₂ x) + (h₃ : ∀ x ∈ S, 0 ≤ f₃ x) (h₄ : ∀ x ∈ S, 0 ≤ f₄ x) + (h : ∀ x ∈ S, ∀ y ∈ S, f₁ x * f₂ y ≤ f₃ (x ⊓ y) * f₄ (x ⊔ y)) : + (∫ x in (S : Set (ι → ℝ)), f₁ x) * (∫ x in (S : Set (ι → ℝ)), f₂ x) ≤ + (∫ x in (S : Set (ι → ℝ)), f₃ x) * (∫ x in (S : Set (ι → ℝ)), f₄ x) := by + have lim₁ := tendsto_tsum_div_pow_atTop_integral (S : Set (ι → ℝ)) f₁ hc₁ hs₁ hs₂ hs₃ + have lim₂ := tendsto_tsum_div_pow_atTop_integral (S : Set (ι → ℝ)) f₂ hc₂ hs₁ hs₂ hs₃ + have lim₃ := tendsto_tsum_div_pow_atTop_integral (S : Set (ι → ℝ)) f₃ hc₃ hs₁ hs₂ hs₃ + have lim₄ := tendsto_tsum_div_pow_atTop_integral (S : Set (ι → ℝ)) f₄ hc₄ hs₁ hs₂ hs₃ + refine le_of_tendsto_of_tendsto (lim₁.mul lim₂) (lim₃.mul lim₄) ?_ + filter_upwards [eventually_gt_atTop 0] with n hn + let _ : NeZero n := ⟨Nat.ne_of_gt hn⟩ + let T := S ⊓ rationalGrid (ι := ι) n + have hT : (T : Set (ι → ℝ)).Finite := by + change ((S : Set (ι → ℝ)) ∩ (n : ℝ)⁻¹ • + Submodule.span ℤ (Set.range (Pi.basisFun ℝ ι))).Finite + rw [← Submodule.coe_pointwise_smul, ZSpan.smul _ (inv_ne_zero (NeZero.ne _))] + exact ZSpan.setFinite_inter _ hs₁ + let _ : Fintype T := hT.fintype + have ff := four_functions_theorem_univ + (fun x : T ↦ f₁ x) (fun x : T ↦ f₂ x) + (fun x : T ↦ f₃ x) (fun x : T ↦ f₄ x) + (fun x ↦ h₁ x x.property.1) (fun x ↦ h₂ x x.property.1) + (fun x ↦ h₃ x x.property.1) (fun x ↦ h₄ x x.property.1) + (fun x y ↦ h x x.property.1 y y.property.1) + change (∑' x : T, f₁ x) / (n : ℝ) ^ Fintype.card ι * + ((∑' x : T, f₂ x) / (n : ℝ) ^ Fintype.card ι) ≤ + (∑' x : T, f₃ x) / (n : ℝ) ^ Fintype.card ι * + ((∑' x : T, f₄ x) / (n : ℝ) ^ Fintype.card ι) + simp only [tsum_fintype, div_mul_div_comm] + exact div_le_div_of_nonneg_right ff (mul_self_nonneg _) +end Honeycomb370 + +end + + +section + +namespace Honeycomb370 +open Set MeasureTheory + +/-- Closed truncations of the actual ordered positive-node chamber. -/ +def orderedBox (n : ℕ) (a b : ℝ) : Sublattice (Fin n → ℝ) where + carrier := {x | Monotone x ∧ ∀ i,a≤x i ∧ x i≤b} + supClosed' := by + rintro x ⟨hx,hxb⟩ y ⟨hy,hyb⟩ + refine ⟨fun i j hij ↦ max_le_max (hx hij) (hy hij),fun i ↦ ?_⟩ + exact ⟨(hxb i).1.trans (le_max_left _ _),max_le (hxb i).2 (hyb i).2⟩ + infClosed' := by + rintro x ⟨hx,hxb⟩ y ⟨hy,hyb⟩ + refine ⟨fun i j hij ↦ min_le_min (hx hij) (hy hij),fun i ↦ ?_⟩ + exact ⟨le_min (hxb i).1 (hyb i).1,(min_le_left _ _).trans (hxb i).2⟩ + +lemma orderedBox_closed (n : ℕ) (a b : ℝ) : + IsClosed (orderedBox n a b : Set (Fin n → ℝ)) := by + change IsClosed {x | Monotone x ∧ ∀ i,a≤x i ∧ x i≤b} + apply IsClosed.inter + · change IsClosed {x : Fin n → ℝ | ∀ (i j : Fin n),i≤j → x i≤x j} + simp only [Set.ofPred_forall] + exact isClosed_iInter (fun i ↦ isClosed_iInter (fun j ↦ isClosed_iInter + (fun _ ↦ isClosed_le (continuous_apply i) (continuous_apply j)))) + · change IsClosed {x : Fin n → ℝ | ∀ i,a≤x i ∧ x i≤b} + simp only [Set.ofPred_forall,Set.ofPred_and] + exact isClosed_iInter (fun i ↦ (isClosed_le continuous_const (continuous_apply i)).inter + (isClosed_le (continuous_apply i) continuous_const)) + +lemma orderedBox_bounded (n : ℕ) (a b : ℝ) : + Bornology.IsBounded (orderedBox n a b : Set (Fin n → ℝ)) := by + apply (isCompact_Icc (a:=fun _ : Fin n ↦ a) (b:=fun _ ↦ b)).isBounded.subset + intro x hx + exact ⟨fun i ↦ (hx.2 i).1,fun i ↦ (hx.2 i).2⟩ + +lemma orderedBox_convex (n : ℕ) (a b : ℝ) : + Convex ℝ (orderedBox n a b : Set (Fin n → ℝ)) := by + intro x hx y hy u v hu hv huv + refine ⟨?_,?_⟩ + · intro i j hij + exact add_le_add (mul_le_mul_of_nonneg_left (hx.1 hij) hu) + (mul_le_mul_of_nonneg_left (hy.1 hij) hv) + · intro i + constructor + · have hl:=add_le_add (mul_le_mul_of_nonneg_left (hx.2 i).1 hu) + (mul_le_mul_of_nonneg_left (hy.2 i).1 hv) + change a≤u*x i+v*y i + nlinarith [hl,congrArg (fun t : ℝ ↦ t*a) huv] + · have hl:=add_le_add (mul_le_mul_of_nonneg_left (hx.2 i).2 hu) + (mul_le_mul_of_nonneg_left (hy.2 i).2 hv) + change u*x i+v*y i≤b + nlinarith [hl,congrArg (fun t : ℝ ↦ t*b) huv] + +lemma orderedBox_four_functions (n : ℕ) (a b : ℝ) + (f₁ f₂ f₃ f₄ : (Fin n → ℝ) → ℝ) + (hc₁ : Continuous f₁) (hc₂ : Continuous f₂) + (hc₃ : Continuous f₃) (hc₄ : Continuous f₄) + (h₁ : ∀ x∈orderedBox n a b,0≤f₁ x) (h₂ : ∀ x∈orderedBox n a b,0≤f₂ x) + (h₃ : ∀ x∈orderedBox n a b,0≤f₃ x) (h₄ : ∀ x∈orderedBox n a b,0≤f₄ x) + (h : ∀ x∈orderedBox n a b,∀ y∈orderedBox n a b, + f₁ x*f₂ y≤f₃ (x⊓y)*f₄ (x⊔y)) : + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₁ x)* + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₂ x) ≤ + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₃ x)* + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₄ x) := by + exact continuous_four_functions (orderedBox n a b) (orderedBox_bounded n a b) + (orderedBox_closed n a b).measurableSet ((orderedBox_convex n a b).addHaar_frontier volume) + f₁ f₂ f₃ f₄ hc₁ hc₂ hc₃ hc₄ h₁ h₂ h₃ h₄ h + +end Honeycomb370 + +end + + +section + +namespace Honeycomb370 +open MeasureTheory Set Filter Topology + +lemma continuousOn_closed_extension {d : ℕ} {S : Set (Fin d → ℝ)} + (hs : IsClosed S) (f : (Fin d → ℝ) → ℝ) (hc : ContinuousOn f S) : + ∃ g : (Fin d → ℝ) → ℝ,Continuous g ∧ EqOn g f S := by + obtain ⟨g,hg⟩ := ContinuousMap.exists_restrict_eq hs + (⟨fun x : S ↦ f x,hc.domRestrict⟩ : C(S,ℝ)) + refine ⟨g,g.continuous,?_⟩ + intro x hx + exact congrArg (fun k : C(S,ℝ) ↦ k ⟨x,hx⟩) hg + +lemma orderedBox_continuousOn_four_functions (n : ℕ) (a b : ℝ) + (f₁ f₂ f₃ f₄ : (Fin n → ℝ) → ℝ) + (hc₁ : ContinuousOn f₁ (orderedBox n a b)) (hc₂ : ContinuousOn f₂ (orderedBox n a b)) + (hc₃ : ContinuousOn f₃ (orderedBox n a b)) (hc₄ : ContinuousOn f₄ (orderedBox n a b)) + (h₁ : ∀ x∈orderedBox n a b,0≤f₁ x) (h₂ : ∀ x∈orderedBox n a b,0≤f₂ x) + (h₃ : ∀ x∈orderedBox n a b,0≤f₃ x) (h₄ : ∀ x∈orderedBox n a b,0≤f₄ x) + (h : ∀ x∈orderedBox n a b,∀ y∈orderedBox n a b, + f₁ x*f₂ y≤f₃ (x⊓y)*f₄ (x⊔y)) : + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₁ x)* + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₂ x) ≤ + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₃ x)* + (∫ x in (orderedBox n a b : Set (Fin n → ℝ)),f₄ x) := by + obtain ⟨g₁,hg₁,he₁⟩:=continuousOn_closed_extension (orderedBox_closed n a b) f₁ hc₁ + obtain ⟨g₂,hg₂,he₂⟩:=continuousOn_closed_extension (orderedBox_closed n a b) f₂ hc₂ + obtain ⟨g₃,hg₃,he₃⟩:=continuousOn_closed_extension (orderedBox_closed n a b) f₃ hc₃ + obtain ⟨g₄,hg₄,he₄⟩:=continuousOn_closed_extension (orderedBox_closed n a b) f₄ hc₄ + have hh:=orderedBox_four_functions n a b g₁ g₂ g₃ g₄ hg₁ hg₂ hg₃ hg₄ + (fun x hx ↦ by rw [he₁ hx]; exact h₁ x hx) + (fun x hx ↦ by rw [he₂ hx]; exact h₂ x hx) + (fun x hx ↦ by rw [he₃ hx]; exact h₃ x hx) + (fun x hx ↦ by rw [he₄ hx]; exact h₄ x hx) + (fun x hx y hy ↦ by + rw [he₁ hx,he₂ hy,he₃ ((orderedBox n a b).inf_mem hx hy), + he₄ ((orderedBox n a b).sup_mem hx hy)] + exact h x hx y hy) + rwa [setIntegral_congr_fun (orderedBox_closed n a b).measurableSet (fun x hx ↦ he₁ hx), + setIntegral_congr_fun (orderedBox_closed n a b).measurableSet (fun x hx ↦ he₂ hx), + setIntegral_congr_fun (orderedBox_closed n a b).measurableSet (fun x hx ↦ he₃ hx), + setIntegral_congr_fun (orderedBox_closed n a b).measurableSet (fun x hx ↦ he₄ hx)] at hh + +def orderedPositive (n : ℕ) : Set (Fin n → ℝ) := + {x | Monotone x ∧ ∀ i,0twoJetCombination N a x-P.eval x) ≤ + Real.exp (-2*(N:ℝ))*stripSquaredNorm (twoJetCombination N a) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology MeasureTheory +lemma pollaczek_series_bound_gen {H B : ℝ → ℝ} (hB : ∀ p,0 ≤ B p) + (hBe : ∀ p,B (-p)=B p) (hH : ∀ p,|H p| ≤ B p) {t : ℝ} (ht : |t| ≤ 1/4) (n : ℕ) (p : ℝ) : + ‖((pollaczekCoeff p n*H p+pollaczekCoeff (-p) n*H (-p))/Real.cosh (Real.pi*p))*t^n‖ ≤ + (meixnerCoeff |p| n*(1/4)^n)*(2*B p/Real.cosh (Real.pi*p)) := by + have hq := pollaczekCoeff_abs_le p n + have hqm := pollaczekCoeff_abs_le (-p) n + have hh := hH p + have hhm := hH (-p) + simp only [abs_neg] at hqm + rw [hBe] at hhm + simp only [norm_mul,Real.norm_eq_abs,abs_div,abs_of_pos (Real.cosh_pos _),abs_pow] + have hb : |pollaczekCoeff p n*H p+pollaczekCoeff (-p) n*H (-p)| ≤ + 2*(meixnerCoeff |p| n*(B p)) := by + calc + _ ≤ |pollaczekCoeff p n*H p|+|pollaczekCoeff (-p) n*H (-p)| := abs_add_le _ _ + _ ≤ meixnerCoeff |p| n*(B p)+meixnerCoeff |p| n*(B p) := by + rw [abs_mul,abs_mul] + exact add_le_add (mul_le_mul hq hh (abs_nonneg _) (meixnerCoeff_nonneg (abs_nonneg p) n)) + (mul_le_mul hqm hhm (abs_nonneg _) (meixnerCoeff_nonneg (abs_nonneg p) n)) + _ = _ := by ring + calc + _ ≤ (2*(meixnerCoeff |p| n*(B p))/Real.cosh (Real.pi*p))*(1/4)^n := by + have hmn := meixnerCoeff_nonneg (abs_nonneg p) n + have hp := hB p + gcongr + _ = _ := by ring +lemma pollaczek_pair_hasSum_gen {H B : ℝ → ℝ} (hHc : Continuous H) + (hB : ∀ p,0 ≤ B p) (hBe : ∀ p,B (-p)=B p) (hH : ∀ p,|H p| ≤ B p) + (hBi : IntegrableOn (fun p=>pollaczekMajorant p*B p/Real.cosh (Real.pi*p)) (Set.Ioi 0)) + {t : ℝ} (ht : |t| ≤ 1/4) : + HasSum (fun n => symmetricSechPair (fun p=>pollaczekCoeff p n) H*t^n) + (symmetricSechPair (fun p=>pollaczekGenerator p t) H) := by + let F : ℕ → ℝ → ℝ := fun n p => + ((pollaczekCoeff p n*H p+pollaczekCoeff (-p) n*H (-p))/Real.cosh (Real.pi*p))*t^n + let bound : ℕ → ℝ → ℝ := fun n p => + (meixnerCoeff |p| n*(1/4)^n)*(2*B p/Real.cosh (Real.pi*p)) + have hmeas (n : ℕ) : AEStronglyMeasurable (F n) (volume.restrict (Set.Ioi 0)) := by + apply Continuous.aestronglyMeasurable + unfold F + apply Continuous.mul _ continuous_const + apply Continuous.div _ (by fun_prop) (fun p => (Real.cosh_pos _).ne') + exact ((pollaczekCoeff_continuous n).mul hHc).add + (((pollaczekCoeff_continuous n).comp continuous_neg).mul (hHc.comp continuous_neg)) + have hb (n : ℕ) : ∀ᵐ p ∂volume.restrict (Set.Ioi 0), ‖F n p‖ ≤ bound n p := + Eventually.of_forall (pollaczek_series_bound_gen hB hBe hH ht n) + have hsum (p : ℝ) : HasSum (fun n => bound n p) + (2*(pollaczekMajorant p*B p/Real.cosh (Real.pi*p))) := by + convert! (meixnerCoeff_hasSum |p| (u:=1/4) (by norm_num)).mul_right + (2*B p/Real.cosh (Real.pi*p)) using 1 + unfold pollaczekMajorant + ring + have hint : Integrable (fun p => ∑' n,bound n p) (volume.restrict (Set.Ioi 0)) := by + simp_rw [(hsum _).tsum_eq] + exact hBi.const_mul 2 + have hlim : ∀ᵐ p ∂volume.restrict (Set.Ioi 0),HasSum (fun n=>F n p) + ((pollaczekGenerator p t*H p+pollaczekGenerator (-p) t*H (-p))/Real.cosh (Real.pi*p)) := by + apply Eventually.of_forall + intro p + convert! ((pollaczekCoeff_hasSum p (t:=t) (by linarith)).mul_right (H p) |>.add + ((pollaczekCoeff_hasSum (-p) (t:=t) (by linarith)).mul_right (H (-p)))).div_const + (Real.cosh (Real.pi*p)) using 1 + funext n + unfold F + ring + have hz := hasSum_integral_of_dominated_convergence bound hmeas hb + (Eventually.of_forall fun p => (hsum p).summable) hint hlim + simpa only [F,integral_mul_const,symmetricSechPair] using hz + + +lemma pollaczekMajorant_mul_exp_integrable {a : ℝ} + (ha : 2*Real.artanh (1/4)+a < Real.pi) : + IntegrableOn (fun p=>pollaczekMajorant p*Real.exp (a*|p|)/Real.cosh (Real.pi*p)) (Set.Ioi 0) := by + have hi := (exp_div_cosh_integrable ha).const_mul ((1-(1/4:ℝ)^2)^(-(1:ℝ)/2)) + apply hi.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [pollaczekMajorant_exp hp.le,abs_of_nonneg hp.le,add_mul,Real.exp_add] + ring +lemma pollaczekGenerator_exp_bound (p : ℝ) {u : ℝ} (hu : |u|<1) : + |pollaczekGenerator p u| ≤ Real.exp ((Real.pi/2)*|p|) := by + rw [pollaczekGenerator,generator_prefactor,abs_mul,abs_of_pos (Real.cos_arctan_pos u),abs_of_pos (Real.exp_pos _)] + calc + _ ≤ 1*Real.exp ((Real.pi/2)*|p|) := by + apply mul_le_mul (Real.cos_le_one _) _ (by positivity) (by norm_num) + apply Real.exp_le_exp.mpr + calc + 2*p*Real.arctan u ≤ |2*p*Real.arctan u| := le_abs_self _ + _ = 2*|p| *|Real.arctan u| := by rw [abs_mul,abs_mul,abs_of_pos (by norm_num : (0:ℝ)<2)] + _ ≤ 2*|p| *(Real.pi/4) := mul_le_mul_of_nonneg_left (arctan_quarter_bound hu).le (by positivity) + _ = _ := by ring + _ = _ := one_mul _ +lemma symmetricSechPair_coeff_generator_full {u : ℝ} (hu : |u| < 1) (n : ℕ) : + symmetricSechPair (fun p=>pollaczekCoeff p n) (fun p=>pollaczekGenerator p u)=u^n := by + refine coefficients_unique (a:=fun n => symmetricSechPair (fun p=>pollaczekCoeff p n) (fun p=>pollaczekGenerator p u)) + (b:=fun n=>u^n) (f:=fun t=>1/(1-t*u)) ?_ ?_ n + · filter_upwards [Metric.ball_mem_nhds (0:ℝ) (by norm_num : (0:ℝ)<1/4)] with t ht + have ht' : |t| < 1/4 := by simpa [Metric.mem_ball] using ht + have hs := pollaczek_pair_hasSum_gen (pollaczekGenerator_continuous_p u) + (B:=fun p=>Real.exp ((Real.pi/2)*|p|)) (fun _=>(Real.exp_pos _).le) + (fun _=>by rw [abs_neg]) (fun p=>pollaczekGenerator_exp_bound p hu) + (pollaczekMajorant_mul_exp_integrable (by linarith [quarter_artanh_bounds.2])) ht'.le + rw [symmetricSechPair_generator (by linarith) hu] at hs + exact hs + · filter_upwards [Metric.ball_mem_nhds (0:ℝ) (by norm_num : (0:ℝ)<1)] with t ht + have ht' : |t| < 1 := by simpa [Metric.mem_ball] using ht + have hp : ‖t*u‖ < 1 := by rw [Real.norm_eq_abs,abs_mul];nlinarith [abs_nonneg t,abs_nonneg u] + simpa [mul_pow,mul_comm,one_div] using hasSum_geometric_of_norm_lt_one hp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Filter +noncomputable def sechPairIntegrand (f g : ℝ → ℝ) (p : ℝ) : ℝ := + (f p*g p+f (-p)*g (-p))/Real.cosh (Real.pi*p) +lemma symmetricSechPair_nonneg (f : ℝ → ℝ) : 0 ≤ symmetricSechPair f f := by + apply integral_nonneg + intro p + exact div_nonneg (add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)) (Real.cosh_pos _).le +lemma sechPairIntegrand_exp_integrable {f g : ℝ → ℝ} (hf : Continuous f) (hg : Continuous g) + {C D a b : ℝ} (hC : 0 ≤ C) (hab : a+b(Real.cosh_pos _).ne') + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_eq_abs,sechPairIntegrand,abs_div,abs_of_pos (Real.cosh_pos _)] + have hp' : 0

c*f p) g=c*symmetricSechPair f g := by + unfold symmetricSechPair + rw [←integral_const_mul] + apply integral_congr_ae + filter_upwards with p + ring +lemma symmetricSechPair_sum_left {ι : Type*} (s : Finset ι) (f : ι → ℝ → ℝ) (g : ℝ → ℝ) + (h : ∀ i∈s,IntegrableOn (sechPairIntegrand (f i) g) (Set.Ioi 0)) : + symmetricSechPair (fun p=>∑ i∈s,f i p) g=∑ i∈s,symmetricSechPair (f i) g := by + unfold symmetricSechPair + simp only [Finset.sum_mul,←Finset.sum_add_distrib,Finset.sum_div] + exact integral_finsetSum s h +lemma symmetricSechPair_sub_left (f g h : ℝ → ℝ) + (hf : IntegrableOn (sechPairIntegrand f h) (Set.Ioi 0)) + (hg : IntegrableOn (sechPairIntegrand g h) (Set.Ioi 0)) : + symmetricSechPair (fun p=>f p-g p) h=symmetricSechPair f h-symmetricSechPair g h := by + change (∫ p in Set.Ioi (0:ℝ),sechPairIntegrand (fun p=>f p-g p) h p)= + (∫ p in Set.Ioi (0:ℝ),sechPairIntegrand f h p)-(∫ p in Set.Ioi (0:ℝ),sechPairIntegrand g h p) + rw [←integral_sub hf hg] + apply integral_congr_ae + filter_upwards with p + unfold sechPairIntegrand + ring +lemma sechPairIntegrand_smul_left (f g : ℝ → ℝ) (c : ℝ) : + sechPairIntegrand (fun p=>c*f p) g=fun p=>c*sechPairIntegrand f g p := by + funext p + unfold sechPairIntegrand + ring +lemma sechPairIntegrand_comm (f g : ℝ → ℝ) : sechPairIntegrand f g=sechPairIntegrand g f := by + funext p + unfold sechPairIntegrand + ring +lemma pollaczekCoeff_exp_bound (n : ℕ) (p : ℝ) : + |pollaczekCoeff p n| ≤ (4^n*(1-(1/4:ℝ)^2)^(-(1:ℝ)/2))*Real.exp (2*Real.artanh (1/4)*|p|) := by + have he : pollaczekMajorant p=(1-(1/4:ℝ)^2)^(-(1:ℝ)/2)*Real.exp (2*Real.artanh (1/4)*|p|) := by + rw [pollaczekMajorant,meixnerGenerator_exp (by norm_num)] + congr 2; ring + simpa only [he,mul_assoc] using pollaczekCoeff_majorant p n +lemma pollaczekGenerator_exp_bound_sharp (p u : ℝ) : + |pollaczekGenerator p u| ≤ Real.exp ((2*|Real.arctan u|)*|p|) := by + rw [pollaczekGenerator,generator_prefactor,abs_mul,abs_of_pos (Real.cos_arctan_pos u),abs_of_pos (Real.exp_pos _)] + calc + _ ≤ 1*Real.exp ((2*|Real.arctan u|)*|p|) := by + apply mul_le_mul (Real.cos_le_one _) _ (by positivity) (by norm_num) + apply Real.exp_le_exp.mpr + calc + 2*p*Real.arctan u ≤ |2*p*Real.arctan u| := le_abs_self _ + _ = _ := by rw [abs_mul,abs_mul,abs_of_pos (by norm_num : (0:ℝ)<2)];ring + _ = _ := one_mul _ +lemma pollaczekCoeff_pair_integrable (n m : ℕ) : + IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p n) (fun p=>pollaczekCoeff p m)) (Set.Ioi 0) := + sechPairIntegrand_exp_integrable (pollaczekCoeff_continuous n) (pollaczekCoeff_continuous m) + (by positivity) (by linarith [quarter_artanh_bounds.2]) + (pollaczekCoeff_exp_bound n) (pollaczekCoeff_exp_bound m) +lemma pollaczekCoeff_generator_integrable (n : ℕ) {u : ℝ} (hu : |u|<1) : + IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p n) (fun p=>pollaczekGenerator p u)) (Set.Ioi 0) := by + apply sechPairIntegrand_exp_integrable (pollaczekCoeff_continuous n) (pollaczekGenerator_continuous_p u) + (C:=4^n*(1-(1/4:ℝ)^2)^(-(1:ℝ)/2)) (D:=1) (a:=2*Real.artanh (1/4)) (b:=2*|Real.arctan u|) + (by positivity) (by linarith [quarter_artanh_bounds.2,arctan_quarter_bound hu]) + (pollaczekCoeff_exp_bound n) + intro p + simpa only [one_mul] using pollaczekGenerator_exp_bound_sharp p u +lemma pollaczekGenerator_pair_integrable {t u : ℝ} (ht : |t|<1) (hu : |u|<1) : + IntegrableOn (sechPairIntegrand (fun p=>pollaczekGenerator p t) (fun p=>pollaczekGenerator p u)) (Set.Ioi 0) := by + apply sechPairIntegrand_exp_integrable (pollaczekGenerator_continuous_p t) (pollaczekGenerator_continuous_p u) + (C:=1) (D:=1) (a:=2*|Real.arctan t|) (b:=2*|Real.arctan u|) + (by norm_num) (by linarith [arctan_quarter_bound ht,arctan_quarter_bound hu]) + · intro p;simpa only [one_mul] using pollaczekGenerator_exp_bound_sharp p t + · intro p;simpa only [one_mul] using pollaczekGenerator_exp_bound_sharp p u +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter Topology +noncomputable def kernelJetTruncation (r : ℕ) (b : ℝ) (K : ℕ) : Polynomial ℝ := + ∑ k∈range K,Polynomial.C ((k.choose r:ℝ)*b^(k-r)/((2*k).factorial:ℝ))*X^k +lemma kernelJetTruncation_eval (r K : ℕ) (b x : ℝ) : + (kernelJetTruncation r b K).eval x=∑ k∈range K,kernelJetTerm r 0 b x k := by + simp only [kernelJetTruncation,eval_finsetSum,eval_mul,eval_C,eval_pow,eval_X, + kernelJetTerm,polynomialJet_X_pow,Nat.choose_zero_right,Nat.cast_one,one_mul,Nat.sub_zero] + apply sum_congr rfl + intro k _ + ring +lemma kernelJetTruncation_bounds (r K : ℕ) {b x : ℝ} (hb : 0≤b) (hx : 0≤x) : + 0≤(kernelJetTruncation r b K).eval x ∧ (kernelJetTruncation r b K).eval x≤cosineKernelJet r 0 b x := by + have hnon (k : ℕ) : 0≤kernelJetTerm r 0 b x k := by + simp only [kernelJetTerm,polynomialJet_X_pow] + positivity + rw [kernelJetTruncation_eval] + exact ⟨sum_nonneg (fun k _=>hnon k),(kernelJetTerm_summable r 0 b x).sum_le_tsum (range K) (fun k _=>hnon k)⟩ +lemma kernelJetTruncation_tendsto (r : ℕ) (b x : ℝ) : + Tendsto (fun K=>(kernelJetTruncation r b K).eval x) atTop (𝓝 (cosineKernelJet r 0 b x)) := by + simp only [kernelJetTruncation_eval] + exact (kernelJetTerm_summable r 0 b x).hasSum.tendsto_sum_nat +lemma kernelJetSech_square_integrable {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) + (hlim : Real.sqrt (b+δ)(cosineKernelJet r 0 b (p^2))^2/Real.cosh (Real.pi*p)) (Set.Ioi 0) := by + apply ((exp_div_cosh_integrable (show 2*Real.sqrt (b+δ)cosineKernelJet r 0 b x) := continuous_iff_continuousAt.mpr + (fun x=>(cosineKernelJet_hasDerivAt_right r 0 b x).continuousAt) + exact ((hc.comp (continuous_id.pow 2)).pow 2).div (by fun_prop) (fun p=>(Real.cosh_pos _).ne') + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)] + have hh := cosineKernelJet_exp_bound hb hd r (le_of_lt hp) + have he : (δ^(-(r:ℤ))*Real.exp (Real.sqrt (b+δ)*p))^2= + (δ^(-(r:ℤ)))^2*Real.exp ((2*Real.sqrt (b+δ))*p) := by + rw [mul_pow,←Real.exp_nat_mul] + congr 2; ring + rw [←mul_div_assoc] + apply div_le_div_of_nonneg_right _ (Real.cosh_pos _).le + calc + _ = |cosineKernelJet r 0 b (p^2)|^2 := (sq_abs _).symm + _ ≤ (δ^(-(r:ℤ))*Real.exp (Real.sqrt (b+δ)*p))^2 := by gcongr + _ = _ := he +lemma kernelJetTruncation_L2_tendsto {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) + (hlim : Real.sqrt (b+δ)∫ p in Set.Ioi (0:ℝ), + (cosineKernelJet r 0 b (p^2)-(kernelJetTruncation r b K).eval (p^2))^2/Real.cosh (Real.pi*p)) atTop (𝓝 0) := by + have hc : Continuous (fun x=>cosineKernelJet r 0 b x) := continuous_iff_continuousAt.mpr + (fun x=>(cosineKernelJet_hasDerivAt_right r 0 b x).continuousAt) + have hh := tendsto_integral_of_dominated_convergence (μ:=volume.restrict (Set.Ioi (0:ℝ))) + (fun p=>(cosineKernelJet r 0 b (p^2))^2/Real.cosh (Real.pi*p)) + (F:=fun K p=>(cosineKernelJet r 0 b (p^2)-(kernelJetTruncation r b K).eval (p^2))^2/Real.cosh (Real.pi*p)) + (f:=fun _=>0) + convert! hh ?_ (kernelJetSech_square_integrable hb hd hlim r) ?_ ?_ using 1 <;> try simp only [integral_zero] + · intro K + apply Continuous.aestronglyMeasurable + exact (((hc.comp (continuous_id.pow 2)).sub ((kernelJetTruncation r b K).continuous.comp (continuous_id.pow 2))).pow 2).div + (by fun_prop) (fun p=>(Real.cosh_pos _).ne') + · intro K + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)] + apply div_le_div_of_nonneg_right _ (Real.cosh_pos _).le + obtain ⟨hl,hu⟩ := kernelJetTruncation_bounds r K hb (sq_nonneg p) + have hj:=cosineKernelJet_nonneg hb (sq_nonneg p) r 0 + nlinarith + · filter_upwards with p + convert! ((tendsto_const_nhds.sub (kernelJetTruncation_tendsto r b (p^2))).pow 2).div_const (Real.cosh (Real.pi*p)) using 1; simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Filter Finset +noncomputable def pollaczekFinite (s : Finset ℕ) (a : ℕ → ℝ) (p : ℝ) : ℝ := + ∑ n∈s,a n*pollaczekCoeff p n +lemma sechPairIntegrand_pollaczekFinite (s : Finset ℕ) (a : ℕ → ℝ) (f : ℝ → ℝ) : + sechPairIntegrand (pollaczekFinite s a) f= + fun p=>∑ n∈s,a n*sechPairIntegrand (fun p=>pollaczekCoeff p n) f p := by + funext p + simp only [sechPairIntegrand,pollaczekFinite,sum_mul,←sum_add_distrib,sum_div] + apply sum_congr rfl + intro n _ + ring +lemma sechPairIntegrand_pollaczekFinite_integrable (s : Finset ℕ) (a : ℕ → ℝ) (f : ℝ → ℝ) + (h : ∀ n∈s,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p n) f) (Set.Ioi 0)) : + IntegrableOn (sechPairIntegrand (pollaczekFinite s a) f) (Set.Ioi 0) := by + rw [sechPairIntegrand_pollaczekFinite] + exact integrable_finsetSum s (fun n hn=>(h n hn).const_mul (a n)) +lemma symmetricSechPair_pollaczekFinite (s : Finset ℕ) (a : ℕ → ℝ) (f : ℝ → ℝ) + (h : ∀ n∈s,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p n) f) (Set.Ioi 0)) : + symmetricSechPair (pollaczekFinite s a) f=∑ n∈s,a n*symmetricSechPair (fun p=>pollaczekCoeff p n) f := by + change (∫ p in Set.Ioi (0:ℝ),sechPairIntegrand (pollaczekFinite s a) f p)=_ + rw [sechPairIntegrand_pollaczekFinite,integral_finsetSum s (fun n hn=>(h n hn).const_mul (a n))] + simp only [integral_const_mul,symmetricSechPair,sechPairIntegrand] +lemma pollaczekFinite_coeff (s : Finset ℕ) (a : ℕ → ℝ) (n : ℕ) : + symmetricSechPair (pollaczekFinite s a) (fun p=>pollaczekCoeff p n)=if n∈s then a n else 0 := by + rw [symmetricSechPair_pollaczekFinite s a _ (fun _ _=>pollaczekCoeff_pair_integrable _ n)] + simp only [symmetricSechPair_orthogonal,mul_ite,mul_one,mul_zero] + simp +lemma pollaczekFinite_pair_integrable (s t : Finset ℕ) (a b : ℕ → ℝ) : + IntegrableOn (sechPairIntegrand (pollaczekFinite s a) (pollaczekFinite t b)) (Set.Ioi 0) := by + apply sechPairIntegrand_pollaczekFinite_integrable + intro n _ + rw [sechPairIntegrand_comm] + exact sechPairIntegrand_pollaczekFinite_integrable t b _ (fun _ _=>pollaczekCoeff_pair_integrable _ n) +lemma pollaczekFinite_norm (s : Finset ℕ) (a : ℕ → ℝ) : + symmetricSechPair (pollaczekFinite s a) (pollaczekFinite s a)=∑ n∈s,(a n)^2 := by + rw [symmetricSechPair_pollaczekFinite] + · apply sum_congr rfl + intro n hn + rw [symmetricSechPair_comm,pollaczekFinite_coeff,ite_eq_left hn,pow_two] + · intro n _ + rw [sechPairIntegrand_comm] + exact sechPairIntegrand_pollaczekFinite_integrable s a _ (fun _ _=>pollaczekCoeff_pair_integrable _ n) +lemma sechPairIntegrand_sub_left (f g h : ℝ → ℝ) : + sechPairIntegrand (fun p=>f p-g p) h=fun p=>sechPairIntegrand f h p-sechPairIntegrand g h p := by + funext p + unfold sechPairIntegrand + ring +lemma symmetricSechPair_difference_norm (f g : ℝ → ℝ) + (hff : IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hgg : IntegrableOn (sechPairIntegrand g g) (Set.Ioi 0)) + (hfg : IntegrableOn (sechPairIntegrand f g) (Set.Ioi 0)) : + symmetricSechPair (fun p=>f p-g p) (fun p=>f p-g p)= + symmetricSechPair f f-2*symmetricSechPair f g+symmetricSechPair g g := by + have hgf : IntegrableOn (sechPairIntegrand g f) (Set.Ioi 0) := by rw [sechPairIntegrand_comm];exact hfg + rw [symmetricSechPair_sub_left] + · rw [symmetricSechPair_comm f (fun p=>f p-g p),symmetricSechPair_sub_left _ _ _ hff hgf, + symmetricSechPair_comm g (fun p=>f p-g p),symmetricSechPair_sub_left _ _ _ hfg hgg,symmetricSechPair_comm g f] + ring + · rw [sechPairIntegrand_comm,sechPairIntegrand_sub_left] + exact hff.sub hgf + · rw [sechPairIntegrand_comm,sechPairIntegrand_sub_left] + exact hfg.sub hgg +lemma pollaczek_projection_squared_error (s : Finset ℕ) (f : ℝ → ℝ) + (hff : IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hf : ∀ n∈s,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p n) f) (Set.Ioi 0)) : + let a := fun n=>symmetricSechPair (fun p=>pollaczekCoeff p n) f + symmetricSechPair (fun p=>f p-pollaczekFinite s a p) (fun p=>f p-pollaczekFinite s a p)= + symmetricSechPair f f-∑ n∈s,(a n)^2 := by + intro a + rw [symmetricSechPair_difference_norm f _ hff (pollaczekFinite_pair_integrable _ _ _ _) + (by rw [sechPairIntegrand_comm];exact sechPairIntegrand_pollaczekFinite_integrable s a f hf), + pollaczekFinite_norm,symmetricSechPair_comm f (pollaczekFinite s a),symmetricSechPair_pollaczekFinite s a f hf] + change symmetricSechPair f f-2*(∑ n∈s,a n*a n)+(∑ n∈s,(a n)^2)=_ + simp only [←pow_two] + ring +lemma pollaczek_bessel (s : Finset ℕ) (f : ℝ → ℝ) + (hff : IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hf : ∀ n∈s,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p n) f) (Set.Ioi 0)) : + (∑ n∈s,(symmetricSechPair (fun p=>pollaczekCoeff p n) f)^2) ≤ symmetricSechPair f f := by + have h:=symmetricSechPair_nonneg (fun p=>f p-pollaczekFinite s (fun n=>symmetricSechPair (fun p=>pollaczekCoeff p n) f) p) + rw [pollaczek_projection_squared_error s f hff hf] at h + linarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset +noncomputable def evenPollaczekFinite (K : ℕ) (a : Fin K → ℝ) (p : ℝ) : ℝ := + ∑ j,a j*pollaczekCoeff p (2*j) +lemma evenPollaczekFinite_polynomial (K : ℕ) (a : Fin K → ℝ) (p : ℝ) : + evenPollaczekFinite K a p=(∑ j,a j • evenPoly (-1) j).eval (p^2) := by + simp only [evenPollaczekFinite,eval_finsetSum,eval_smul,smul_eq_mul] + apply sum_congr rfl + intro i _ + rw [←(pollaczekCoeff_evenOdd p i).1] +lemma polynomial_evenPollaczekFinite (P : Polynomial ℝ) {n : ℕ} (hn : P.natDegree≤n) : + ∃ a : Fin (n+1) → ℝ,(fun p=>P.eval (p^2))=evenPollaczekFinite (n+1) a := by + obtain ⟨a,ha⟩:=polynomial_eq_pollaczek_sum P hn + refine ⟨a,funext (fun p=>?_)⟩ + rw [evenPollaczekFinite_polynomial,ha] +lemma sechPairIntegrand_evenFinite (K : ℕ) (a : Fin K → ℝ) (f : ℝ → ℝ) : + sechPairIntegrand (evenPollaczekFinite K a) f= + fun p=>∑ j,a j*sechPairIntegrand (fun p=>pollaczekCoeff p (2*j)) f p := by + funext p + simp only [sechPairIntegrand,evenPollaczekFinite,sum_mul,←sum_add_distrib,sum_div] + apply sum_congr rfl + intro j _ + ring +lemma evenFinite_pair_integrable (K : ℕ) (a : Fin K → ℝ) (f : ℝ → ℝ) + (hf : ∀ j:Fin K,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p (2*j)) f) (Set.Ioi 0)) : + IntegrableOn (sechPairIntegrand (evenPollaczekFinite K a) f) (Set.Ioi 0) := by + rw [sechPairIntegrand_evenFinite] + exact integrable_finsetSum _ (fun j _=>(hf j).const_mul _) +lemma evenFinite_pair (K : ℕ) (a : Fin K → ℝ) (f : ℝ → ℝ) + (hf : ∀ j:Fin K,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p (2*j)) f) (Set.Ioi 0)) : + symmetricSechPair (evenPollaczekFinite K a) f= + ∑ j,a j*symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f := by + change (∫ p in Set.Ioi (0:ℝ),sechPairIntegrand (evenPollaczekFinite K a) f p)=_ + rw [sechPairIntegrand_evenFinite,integral_finsetSum univ (fun j _=>(hf j).const_mul (a j))] + simp only [integral_const_mul,symmetricSechPair,sechPairIntegrand] +lemma evenFinite_coeff (K : ℕ) (a : Fin K → ℝ) (j : Fin K) : + symmetricSechPair (evenPollaczekFinite K a) (fun p=>pollaczekCoeff p (2*j))=a j := by + rw [evenFinite_pair K a _ (fun i=>pollaczekCoeff_pair_integrable _ _)] + simp only [symmetricSechPair_orthogonal] + have he (i : Fin K) : (2*(i:ℕ)=2*j)↔i=j := by constructor <;> intro h <;> omega + simp only [he,mul_ite,mul_one,mul_zero] + simp +lemma evenFinite_square_integrable (K : ℕ) (a : Fin K → ℝ) : + IntegrableOn (sechPairIntegrand (evenPollaczekFinite K a) (evenPollaczekFinite K a)) (Set.Ioi 0) := by + apply evenFinite_pair_integrable + intro j + rw [sechPairIntegrand_comm] + exact evenFinite_pair_integrable K a _ (fun _=>pollaczekCoeff_pair_integrable _ _) +lemma evenFinite_norm (K : ℕ) (a : Fin K → ℝ) : + symmetricSechPair (evenPollaczekFinite K a) (evenPollaczekFinite K a)=∑ j,(a j)^2 := by + rw [evenFinite_pair K a _ (fun j=>by + rw [sechPairIntegrand_comm];exact evenFinite_pair_integrable K a _ (fun _=>pollaczekCoeff_pair_integrable _ _))] + apply sum_congr rfl + intro j _ + rw [symmetricSechPair_comm,evenFinite_coeff,pow_two] +lemma even_projection_error (K : ℕ) (f : ℝ → ℝ) + (hff : IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hf : ∀ j:Fin K,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p (2*j)) f) (Set.Ioi 0)) + (a : Fin K → ℝ) : + symmetricSechPair (fun p=>f p-evenPollaczekFinite K a p) (fun p=>f p-evenPollaczekFinite K a p)= + symmetricSechPair f f-2*(∑ j,a j*symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)+∑ j,(a j)^2 := by + rw [symmetricSechPair_difference_norm f _ hff (evenFinite_square_integrable K a) + (by rw [sechPairIntegrand_comm];exact evenFinite_pair_integrable K a f hf), + evenFinite_norm,symmetricSechPair_comm f (evenPollaczekFinite K a),evenFinite_pair K a f hf] +lemma even_projection_minimal (K : ℕ) (f : ℝ → ℝ) + (hff : IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hf : ∀ j:Fin K,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p (2*j)) f) (Set.Ioi 0)) + (a : Fin K → ℝ) : + symmetricSechPair f f-∑ j:Fin K,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2 ≤ + symmetricSechPair (fun p=>f p-evenPollaczekFinite K a p) (fun p=>f p-evenPollaczekFinite K a p) := by + rw [even_projection_error K f hff hf a] + have h:=sum_nonneg (s:=univ) (fun (j:Fin K) _=>sq_nonneg (a j-symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)) + simp only [sub_sq,sum_add_distrib,sum_sub_distrib,mul_assoc,←mul_sum] at h + linarith +lemma even_projection_bessel (K : ℕ) (f : ℝ → ℝ) + (hff : IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hf : ∀ j:Fin K,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p (2*j)) f) (Set.Ioi 0)) : + 0 ≤ symmetricSechPair f f-∑ j:Fin K,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2 := by + have h:=symmetricSechPair_nonneg (fun p=>f p-evenPollaczekFinite K + (fun j=>symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f) p) + rw [even_projection_error K f hff hf] at h + simp only [←pow_two] at h + linarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter Topology +lemma kernelJetTruncation_degree (r n : ℕ) (b : ℝ) : + (kernelJetTruncation r b (n+1)).natDegree≤n := by + apply natDegree_sum_le_of_forall_le + intro k hk + exact ((natDegree_C_mul_le _ _).trans (show (X^k:Polynomial ℝ).natDegree≤k by simp)).trans (by have:=mem_range.mp hk;omega) +lemma kernelJetSech_pair_integrable {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) + (hlim : Real.sqrt (b+δ)pollaczekCoeff p n) (fun p=>cosineKernelJet r 0 b (p^2))) (Set.Ioi 0) := by + have hc : Continuous (fun p=>cosineKernelJet r 0 b (p^2)) := + (continuous_iff_continuousAt.mpr (fun x=>(cosineKernelJet_hasDerivAt_right r 0 b x).continuousAt)).comp + (continuous_id.pow 2) + apply sechPairIntegrand_exp_integrable (pollaczekCoeff_continuous n) hc + (C:=4^n*(1-(1/4:ℝ)^2)^(-(1:ℝ)/2)) (D:=δ^(-(r:ℤ))) + (a:=2*Real.artanh (1/4)) (b:=Real.sqrt (b+δ)) (by positivity) + (by linarith [quarter_artanh_bounds.2]) (pollaczekCoeff_exp_bound n) + intro p + simpa only [sq_abs] using cosineKernelJet_exp_bound hb hd r (abs_nonneg p) +lemma evenSech_squaredNorm (f : ℝ → ℝ) : + symmetricSechPair (fun p=>f (p^2)) (fun p=>f (p^2))= + 2*(∫ p in Set.Ioi (0:ℝ),(f (p^2))^2/Real.cosh (Real.pi*p)) := by + unfold symmetricSechPair + rw [←integral_const_mul] + apply integral_congr_ae + filter_upwards with p + simp only [neg_sq] + ring +lemma kernelJetSech_norm_integrable {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) + (hlim : Real.sqrt (b+δ)cosineKernelJet r 0 b (p^2)) (fun p=>cosineKernelJet r 0 b (p^2))) (Set.Ioi 0) := by + have he : sechPairIntegrand (fun p=>cosineKernelJet r 0 b (p^2)) (fun p=>cosineKernelJet r 0 b (p^2))= + fun p=>2*((cosineKernelJet r 0 b (p^2))^2/Real.cosh (Real.pi*p)) := by + funext p + simp only [sechPairIntegrand,neg_sq] + ring + rw [he] + exact (kernelJetSech_square_integrable hb hd hlim r).const_mul 2 +lemma kernelJetSech_parseval_residual {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) + (hlim : Real.sqrt (b+δ)symmetricSechPair (fun p=>cosineKernelJet r 0 b (p^2)) (fun p=>cosineKernelJet r 0 b (p^2))- + ∑ j:Fin (n+1),(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) (fun p=>cosineKernelJet r 0 b (p^2)))^2) + atTop (𝓝 0) := by + let f:=fun p=>cosineKernelJet r 0 b (p^2) + apply squeeze_zero (g:=fun n=>2*(∫ p in Set.Ioi (0:ℝ), + (cosineKernelJet r 0 b (p^2)-(kernelJetTruncation r b (n+1)).eval (p^2))^2/Real.cosh (Real.pi*p))) (fun n=>even_projection_bessel (n+1) f (kernelJetSech_norm_integrable hb hd hlim r) + (fun j=>kernelJetSech_pair_integrable hb hd hlim r (2*j))) + · intro n + obtain ⟨a,ha⟩:=polynomial_evenPollaczekFinite (kernelJetTruncation r b (n+1)) (kernelJetTruncation_degree r n b) + have hh:=even_projection_minimal (n+1) f (kernelJetSech_norm_integrable hb hd hlim r) + (fun j=>kernelJetSech_pair_integrable hb hd hlim r (2*j)) a + rw [←ha] at hh + change _ ≤ symmetricSechPair (fun p=>(fun x=>cosineKernelJet r 0 b x-(kernelJetTruncation r b (n+1)).eval x) (p^2)) + (fun p=>(fun x=>cosineKernelJet r 0 b x-(kernelJetTruncation r b (n+1)).eval x) (p^2)) at hh + rw [evenSech_squaredNorm (fun x=>cosineKernelJet r 0 b x-(kernelJetTruncation r b (n+1)).eval x)] at hh + exact hh + · have hh:=((kernelJetTruncation_L2_tendsto hb hd hlim r).comp (tendsto_add_atTop_nat 1)).const_mul 2 + simpa only [Function.comp_apply,mul_zero] using hh +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter Topology +noncomputable def finiteJetCombination (M : ℕ) (a b : Fin M → ℝ) (r : Fin M → ℕ) (x : ℝ) : ℝ := + ∑ i,a i*cosineKernelJet (r i) 0 (b i) x +noncomputable def finiteJetTruncation (M K : ℕ) (a b : Fin M → ℝ) (r : Fin M → ℕ) : Polynomial ℝ := + ∑ i,a i • kernelJetTruncation (r i) (b i) K +lemma finiteJetTruncation_eval (M K : ℕ) (a b : Fin M → ℝ) (r : Fin M → ℕ) (x : ℝ) : + (finiteJetTruncation M K a b r).eval x=∑ i,a i*(kernelJetTruncation (r i) (b i) K).eval x := by + simp only [finiteJetTruncation,eval_finsetSum,eval_smul,smul_eq_mul] +lemma finiteJetTruncation_degree (M n : ℕ) (a b : Fin M → ℝ) (r : Fin M → ℕ) : + (finiteJetTruncation M (n+1) a b r).natDegree≤n := by + apply natDegree_sum_le_of_forall_le + intro i _ + rw [Polynomial.smul_eq_C_mul] + exact (natDegree_C_mul_le _ _).trans (kernelJetTruncation_degree (r i) n (b i)) +lemma finiteJetCombination_continuous (M : ℕ) (a b : Fin M → ℝ) (r : Fin M → ℕ) : + Continuous (finiteJetCombination M a b r) := by + apply continuous_finsetSum + intro i _ + exact (continuous_iff_continuousAt.mpr (fun x=>(cosineKernelJet_hasDerivAt_right (r i) 0 (b i) x).continuousAt)).const_mul _ +lemma finiteJetTruncation_error_bound (M K : ℕ) (a b : Fin M → ℝ) (r : Fin M → ℕ) + (hb : ∀ i,0≤b i) {x : ℝ} (hx : 0≤x) : + (finiteJetCombination M a b r x-(finiteJetTruncation M K a b r).eval x)^2 ≤ + (∑ i,(a i)^2)*(∑ i,(cosineKernelJet (r i) 0 (b i) x)^2) := by + rw [finiteJetTruncation_eval,finiteJetCombination,←sum_sub_distrib] + simp only [←mul_sub] + apply (sum_mul_sq_le_sq_mul_sq univ a (fun i=>cosineKernelJet (r i) 0 (b i) x-(kernelJetTruncation (r i) (b i) K).eval x)).trans + apply mul_le_mul_of_nonneg_left _ (sum_nonneg (fun i _=>sq_nonneg _)) + apply sum_le_sum + intro i _ + obtain ⟨hl,hu⟩:=kernelJetTruncation_bounds (r i) K (hb i) hx + have hJ:=cosineKernelJet_nonneg (hb i) hx (r i) 0 + nlinarith +lemma finiteJetTruncation_L2_tendsto (M : ℕ) (a b δ : Fin M → ℝ) (r : Fin M → ℕ) + (hb : ∀ i,0≤b i) (hd : ∀ i,0<δ i) (hlim : ∀ i,Real.sqrt (b i+δ i)∫ p in Set.Ioi (0:ℝ), + (finiteJetCombination M a b r (p^2)-(finiteJetTruncation M K a b r).eval (p^2))^2/Real.cosh (Real.pi*p)) atTop (𝓝 0) := by + let B:=fun p=>(∑ i,(a i)^2)*(∑ i,(cosineKernelJet (r i) 0 (b i) (p^2))^2/Real.cosh (Real.pi*p)) + have hB : IntegrableOn B (Set.Ioi 0) := + (integrable_finsetSum univ (fun i _=>kernelJetSech_square_integrable (hb i) (hd i) (hlim i) (r i))).const_mul _ + have hh:=tendsto_integral_of_dominated_convergence (μ:=volume.restrict (Set.Ioi (0:ℝ))) B + (F:=fun K p=>(finiteJetCombination M a b r (p^2)-(finiteJetTruncation M K a b r).eval (p^2))^2/Real.cosh (Real.pi*p)) + (f:=fun _=>0) + convert! hh ?_ hB ?_ ?_ using 1 <;> try simp only [integral_zero] + · intro K + apply Continuous.aestronglyMeasurable + exact ((((finiteJetCombination_continuous M a b r).comp (continuous_id.pow 2)).sub + ((finiteJetTruncation M K a b r).continuous.comp (continuous_id.pow 2))).pow 2).div (by fun_prop) (fun p=>(Real.cosh_pos _).ne') + · intro K + filter_upwards with p + rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)] + change _≤(∑ i,(a i)^2)*(∑ i,(cosineKernelJet (r i) 0 (b i) (p^2))^2/_) + rw [←sum_div,←mul_div_assoc] + exact div_le_div_of_nonneg_right (finiteJetTruncation_error_bound M K a b r hb (sq_nonneg p)) (Real.cosh_pos _).le + · filter_upwards with p + have ht : Tendsto (fun K=>(finiteJetTruncation M K a b r).eval (p^2)) atTop (𝓝 (finiteJetCombination M a b r (p^2))) := by + simp only [finiteJetTruncation_eval,finiteJetCombination] + exact tendsto_finsetSum univ (fun i _=>(kernelJetTruncation_tendsto (r i) (b i) (p^2)).const_mul (a i)) + convert! ((tendsto_const_nhds.sub ht).pow 2).div_const (Real.cosh (Real.pi*p)) using 1; simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter Topology +lemma finiteJetSech_pair_integrable (M : ℕ) (a b δ : Fin M → ℝ) (r : Fin M → ℕ) + (hb : ∀ i,0≤b i) (hd : ∀ i,0<δ i) (hlim : ∀ i,Real.sqrt (b i+δ i)pollaczekCoeff p n) (fun p=>finiteJetCombination M a b r (p^2))) (Set.Ioi 0) := by + have he : sechPairIntegrand (fun p=>pollaczekCoeff p n) (fun p=>finiteJetCombination M a b r (p^2))= + fun p=>∑ i,a i*sechPairIntegrand (fun p=>pollaczekCoeff p n) (fun p=>cosineKernelJet (r i) 0 (b i) (p^2)) p := by + funext p + simp only [sechPairIntegrand,finiteJetCombination,mul_sum,←sum_add_distrib,sum_div] + apply sum_congr rfl + intro i _ + ring + rw [he] + exact integrable_finsetSum univ (fun i _=>(kernelJetSech_pair_integrable (hb i) (hd i) (hlim i) (r i) n).const_mul _) +lemma finiteJetSech_norm_integrable (M : ℕ) (a b δ : Fin M → ℝ) (r : Fin M → ℕ) + (hb : ∀ i,0≤b i) (hd : ∀ i,0<δ i) (hlim : ∀ i,Real.sqrt (b i+δ i)finiteJetCombination M a b r (p^2)) (fun p=>finiteJetCombination M a b r (p^2))) (Set.Ioi 0) := by + let B:=fun p=>2*(∑ i,(a i)^2)*(∑ i,(cosineKernelJet (r i) 0 (b i) (p^2))^2/Real.cosh (Real.pi*p)) + have hB : IntegrableOn B (Set.Ioi 0) := + (integrable_finsetSum univ (fun i _=>kernelJetSech_square_integrable (hb i) (hd i) (hlim i) (r i))).const_mul _ + refine hB.mono' ?_ ?_ + · apply Continuous.aestronglyMeasurable + have hc:Continuous (fun p=>finiteJetCombination M a b r (p^2)):= + (finiteJetCombination_continuous M a b r).comp (continuous_id.pow 2) + exact ((hc.mul hc).add ((hc.comp continuous_neg).mul (hc.comp continuous_neg))).div + (by fun_prop) (fun p=>(Real.cosh_pos _).ne') + · filter_upwards with p + have hh:=finiteJetTruncation_error_bound M 0 a b r hb (sq_nonneg p) + simp only [finiteJetTruncation,kernelJetTruncation,sum_range_zero,smul_zero,sum_const_zero,eval_zero,sub_zero] at hh + simp only [sechPairIntegrand,neg_sq,Real.norm_eq_abs] + rw [abs_of_nonneg (div_nonneg (add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)) (Real.cosh_pos _).le)] + dsimp [B] + rw [←sum_div,←mul_div_assoc] + apply div_le_div_of_nonneg_right _ (Real.cosh_pos _).le + nlinarith +lemma finiteJetSech_parseval_residual (M : ℕ) (a b δ : Fin M → ℝ) (r : Fin M → ℕ) + (hb : ∀ i,0≤b i) (hd : ∀ i,0<δ i) (hlim : ∀ i,Real.sqrt (b i+δ i)symmetricSechPair (fun p=>finiteJetCombination M a b r (p^2)) (fun p=>finiteJetCombination M a b r (p^2))- + ∑ j:Fin (n+1),(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) (fun p=>finiteJetCombination M a b r (p^2)))^2) + atTop (𝓝 0) := by + let f:=fun p=>finiteJetCombination M a b r (p^2) + have hff:=finiteJetSech_norm_integrable M a b δ r hb hd hlim + have hf:=finiteJetSech_pair_integrable M a b δ r hb hd hlim + apply squeeze_zero (g:=fun n=>2*(∫ p in Set.Ioi (0:ℝ), + (finiteJetCombination M a b r (p^2)-(finiteJetTruncation M (n+1) a b r).eval (p^2))^2/Real.cosh (Real.pi*p))) + (fun n=>even_projection_bessel (n+1) f hff (fun j=>hf (2*j))) + · intro n + obtain ⟨c,hc⟩:=polynomial_evenPollaczekFinite (finiteJetTruncation M (n+1) a b r) (finiteJetTruncation_degree M n a b r) + have hh:=even_projection_minimal (n+1) f hff (fun j=>hf (2*j)) c + rw [←hc] at hh + change _ ≤ symmetricSechPair (fun p=>(fun x=>finiteJetCombination M a b r x-(finiteJetTruncation M (n+1) a b r).eval x) (p^2)) + (fun p=>(fun x=>finiteJetCombination M a b r x-(finiteJetTruncation M (n+1) a b r).eval x) (p^2)) at hh + rw [evenSech_squaredNorm (fun x=>finiteJetCombination M a b r x-(finiteJetTruncation M (n+1) a b r).eval x)] at hh + exact hh + · have hh:=((finiteJetTruncation_L2_tendsto M a b δ r hb hd hlim).comp (tendsto_add_atTop_nat 1)).const_mul 2 + simpa only [Function.comp_apply,mul_zero] using hh +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial +noncomputable def jetCoshPolynomial (m : ℝ) : ℕ → Polynomial ℝ + | 0 => 1 + | 1 => 0 + | r+2 => Polynomial.C ((4*m^2*((r:ℝ)+1)*((r:ℝ)+2))⁻¹)* + (X^2*jetCoshPolynomial m r-Polynomial.C (2*((r:ℝ)+1)*(2*(r:ℝ)+1))*jetCoshPolynomial m (r+1)) +noncomputable def jetSinhPolynomial (m : ℝ) : ℕ → Polynomial ℝ + | 0 => 0 + | 1 => Polynomial.C ((2*m)⁻¹)*X + | r+2 => Polynomial.C ((4*m^2*((r:ℝ)+1)*((r:ℝ)+2))⁻¹)* + (X^2*jetSinhPolynomial m r-Polynomial.C (2*((r:ℝ)+1)*(2*(r:ℝ)+1))*jetSinhPolynomial m (r+1)) +lemma jetPolynomial_degrees (m : ℝ) (r : ℕ) : + (jetCoshPolynomial m r).natDegree≤r ∧ (jetSinhPolynomial m r).natDegree≤r := by + induction r using Nat.twoStepInduction with + | zero => simp [jetCoshPolynomial,jetSinhPolynomial] + | one => + constructor + · simp [jetCoshPolynomial] + · exact (natDegree_C_mul_le _ _).trans (by simp) + | more r ih ih' => + constructor + · rw [jetCoshPolynomial] + apply (natDegree_C_mul_le _ _).trans + apply (natDegree_sub_le _ _).trans + apply max_le + · apply natDegree_mul_le.trans + have hh := Nat.add_le_add (show (X^2:Polynomial ℝ).natDegree≤2 by simp) ih.1 + omega + · exact ((natDegree_C_mul_le _ _).trans ih'.1).trans (by omega) + · rw [jetSinhPolynomial] + apply (natDegree_C_mul_le _ _).trans + apply (natDegree_sub_le _ _).trans + apply max_le + · apply natDegree_mul_le.trans + have hh := Nat.add_le_add (show (X^2:Polynomial ℝ).natDegree≤2 by simp) ih.2 + omega + · exact ((natDegree_C_mul_le _ _).trans ih'.2).trans (by omega) +lemma cosineKernelJet_polynomials {m : ℝ} (hm : m≠0) (r : ℕ) (p : ℝ) : + cosineKernelJet r 0 (m^2) (p^2)= + (jetCoshPolynomial m r).eval p*Real.cosh (m*p)+(jetSinhPolynomial m r).eval p*Real.sinh (m*p) := by + induction r using Nat.twoStepInduction with + | zero => simp [jetCoshPolynomial,jetSinhPolynomial,cosineKernelJet_square_cosh] + | one => + simp only [jetCoshPolynomial,jetSinhPolynomial,eval_zero,eval_mul,eval_C,eval_X,zero_mul,zero_add] + have hd := cosineKernelJet_first_square m p + field_simp [hm] + nlinarith only [hd] + | more r ih ih' => + rw [jetCoshPolynomial,jetSinhPolynomial] + simp only [eval_mul,eval_C,eval_sub,eval_pow,eval_X] + have hd := cosineKernelJet_ode r (sq_pos_of_ne_zero hm) p + rw [ih,ih'] at hd + have hden : 4*m^2*((r:ℝ)+1)*((r:ℝ)+2)≠0 := by positivity + field_simp [hm] + nlinarith only [hd] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory +noncomputable def generatorMoment (u : ℝ) (k : ℕ) (p : ℝ) : ℝ := p^k*pollaczekGenerator p u +lemma generatorMoment_continuous (u : ℝ) (k : ℕ) : Continuous (generatorMoment u k) := + (continuous_id.pow k).mul (pollaczekGenerator_continuous_p u) +lemma power_exp_bound {δ : ℝ} (hδ : 0<δ) (k : ℕ) (p : ℝ) : + |p|^k ≤ ((k.factorial:ℝ)/δ^k)*Real.exp (δ*|p|) := by + have h := Real.pow_div_factorial_le_exp (δ*|p|) (by positivity) k + rw [div_le_iff₀ (by positivity : (0:ℝ)<(k.factorial:ℝ)),mul_pow] at h + rw [div_mul_eq_mul_div,le_div_iff₀ (pow_pos hδ k)] + nlinarith only [h] +lemma generatorMoment_bound {δ : ℝ} (hδ : 0<δ) (u : ℝ) (k : ℕ) (p : ℝ) : + |generatorMoment u k p| ≤ ((k.factorial:ℝ)/δ^k)*Real.exp ((δ+2*|Real.arctan u|)*|p|) := by + rw [generatorMoment,abs_mul,abs_pow] + calc + _ ≤ ((k.factorial:ℝ)/δ^k)*Real.exp (δ*|p|)*Real.exp ((2*|Real.arctan u|)*|p|) := + mul_le_mul (power_exp_bound hδ k p) (pollaczekGenerator_exp_bound_sharp p u) (abs_nonneg _) (by positivity) + _ = _ := by rw [add_mul,Real.exp_add];ring +lemma generatorMoment_pair_integrable {t u : ℝ} (ht : |t|<1) (hu : |u|<1) (k j : ℕ) : + IntegrableOn (sechPairIntegrand (generatorMoment t k) (generatorMoment u j)) (Set.Ioi 0) := by + let δ := (Real.pi-(2*|Real.arctan t|+2*|Real.arctan u|))/4 + have hδ : 0<δ := by dsimp [δ];linarith [arctan_quarter_bound ht,arctan_quarter_bound hu] + exact sechPairIntegrand_exp_integrable (generatorMoment_continuous t k) (generatorMoment_continuous u j) + (by positivity) (by dsimp [δ];linarith [arctan_quarter_bound ht,arctan_quarter_bound hu]) + (generatorMoment_bound hδ t k) (generatorMoment_bound hδ u j) +lemma pollaczekCoeff_moment_integrable {u : ℝ} (hu : |u|<1) (n k : ℕ) : + IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p n) (generatorMoment u k)) (Set.Ioi 0) := by + let δ := (Real.pi-(2*Real.artanh (1/4)+2*|Real.arctan u|))/2 + have hδ : 0<δ := by dsimp [δ];linarith [quarter_artanh_bounds.2,arctan_quarter_bound hu] + exact sechPairIntegrand_exp_integrable (pollaczekCoeff_continuous n) (generatorMoment_continuous u k) + (by positivity) (by dsimp [δ];linarith [quarter_artanh_bounds.2,arctan_quarter_bound hu]) + (pollaczekCoeff_exp_bound n) (generatorMoment_bound hδ u k) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial +noncomputable def generatorMomentCoefficient (u : ℝ) (k n : ℕ) : ℝ := + symmetricSechPair (fun p=>pollaczekCoeff p n) (generatorMoment u k) +lemma generatorMomentCoefficient_zero {u : ℝ} (hu : |u|<1) (n : ℕ) : + generatorMomentCoefficient u 0 n=u^n := by + change symmetricSechPair (fun p=>pollaczekCoeff p n) (fun p=>p^0*pollaczekGenerator p u)=_ + simpa only [pow_zero,one_mul] using symmetricSechPair_coeff_generator_full hu n +lemma pollaczek_coeff_recurrence (n : ℕ) (p : ℝ) : + 2*p*pollaczekCoeff p (n+1)=(n+2:ℝ)*pollaczekCoeff p (n+2)+(n+1:ℝ)*pollaczekCoeff p n := by + rw [pollaczekCoeff] + have hn : (n:ℝ)+2≠0 := by positivity + field_simp + ring +lemma generatorMomentCoefficient_succ {u : ℝ} (hu : |u|<1) (k n : ℕ) : + generatorMomentCoefficient u (k+1) (n+1)= + (((n:ℝ)+2)*generatorMomentCoefficient u k (n+2)+((n:ℝ)+1)*generatorMomentCoefficient u k n)/2 := by + have he : sechPairIntegrand (fun p=>pollaczekCoeff p (n+1)) (generatorMoment u (k+1))= + fun p=>(((n:ℝ)+2)/2)*sechPairIntegrand (fun p=>pollaczekCoeff p (n+2)) (generatorMoment u k) p+ + (((n:ℝ)+1)/2)*sechPairIntegrand (fun p=>pollaczekCoeff p n) (generatorMoment u k) p := by + funext p + unfold sechPairIntegrand generatorMoment + rw [pow_succ,pow_succ] + linear_combination (p^k*pollaczekGenerator p u)/(2*Real.cosh (Real.pi*p))*pollaczek_coeff_recurrence n p+ + ((-p)^k*pollaczekGenerator (-p) u)/(2*Real.cosh (Real.pi*p))*pollaczek_coeff_recurrence n (-p) + change (∫ p in Set.Ioi (0:ℝ),sechPairIntegrand (fun p=>pollaczekCoeff p (n+1)) (generatorMoment u (k+1)) p)=_ + rw [he,integral_add ((pollaczekCoeff_moment_integrable hu (n+2) k).const_mul _) + ((pollaczekCoeff_moment_integrable hu n k).const_mul _),integral_const_mul,integral_const_mul] + change (((n:ℝ)+2)/2)*generatorMomentCoefficient u k (n+2)+(((n:ℝ)+1)/2)*generatorMomentCoefficient u k n=_ + ring +noncomputable def generatorMomentPolynomial (u : ℝ) : ℕ → Polynomial ℝ + | 0 => 1 + | k+1 => Polynomial.C (1/2)*(Polynomial.C u*(X+1)*(generatorMomentPolynomial u k).comp (X+1)+ + Polynomial.C u⁻¹*X*(generatorMomentPolynomial u k).comp (X-1)) +lemma generatorMomentPolynomial_degree (u : ℝ) (k : ℕ) : (generatorMomentPolynomial u k).natDegree ≤ k := by + induction k with + | zero => simp [generatorMomentPolynomial] + | succ k ih => + rw [generatorMomentPolynomial] + apply (natDegree_C_mul_le _ _).trans + apply natDegree_add_le_of_degree_le + · apply natDegree_mul_le.trans + have hcomp : ((generatorMomentPolynomial u k).comp (X+1)).natDegree ≤ k := by + have h := (natDegree_comp_le (p:=generatorMomentPolynomial u k) (q:=(X+1))) + simpa using h.trans (Nat.mul_le_mul ih (show (X+1:Polynomial ℝ).natDegree ≤ 1 by simpa only [← C_1] using (natDegree_X_add_C (1:ℝ)).le)) + apply (Nat.add_le_add ((natDegree_C_mul_le _ _).trans (show (X+1:Polynomial ℝ).natDegree≤1 by simpa only [← C_1] using (natDegree_X_add_C (1:ℝ)).le)) hcomp).trans + omega + · apply natDegree_mul_le.trans + have hcomp : ((generatorMomentPolynomial u k).comp (X-1)).natDegree ≤ k := by + have h := (natDegree_comp_le (p:=generatorMomentPolynomial u k) (q:=(X-1))) + simpa using h.trans (Nat.mul_le_mul ih (show (X-1:Polynomial ℝ).natDegree ≤ 1 by simpa only [← C_1] using (natDegree_X_sub_C (1:ℝ)).le)) + apply (Nat.add_le_add ((natDegree_C_mul_le _ _).trans (show (X:Polynomial ℝ).natDegree≤1 by simp)) hcomp).trans + omega +lemma generatorMomentCoefficient_polynomial {u : ℝ} (hu : |u|<1) (hu0 : u≠0) (k n : ℕ) (hkn : k≤n) : + generatorMomentCoefficient u k n=u^n*(generatorMomentPolynomial u k).eval (n:ℝ) := by + induction k generalizing n with + | zero => simp only [generatorMomentCoefficient_zero hu,generatorMomentPolynomial,eval_one,mul_one] + | succ k ih => + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (show n≠0 by omega) + rw [generatorMomentCoefficient_succ hu,ih (n+2) (by omega),ih n (by omega),generatorMomentPolynomial] + simp only [eval_mul,eval_C,eval_add,eval_sub,eval_X,eval_one,eval_comp,Nat.cast_succ] + rw [show (n:ℝ)+1+1=(n:ℝ)+2 by ring,show (n:ℝ)+1-1=(n:ℝ) by ring,pow_succ,pow_succ] + field_simp [hu0] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Polynomial MeasureTheory Finset +noncomputable def generatorPolynomial (u : ℝ) (P : Polynomial ℝ) (p : ℝ) : ℝ := P.eval p*pollaczekGenerator p u +lemma generatorPolynomial_sum (u : ℝ) (P : Polynomial ℝ) : + generatorPolynomial u P=fun p=>∑ k∈range (P.natDegree+1),P.coeff k*generatorMoment u k p := by + funext p + have h:=congrArg (fun Q:Polynomial ℝ=>Q.eval p) P.as_sum_range_C_mul_X_pow + simp only [eval_finsetSum,eval_mul,eval_C,eval_pow,eval_X] at h + simp only [generatorPolynomial,generatorMoment,h,sum_mul] + apply sum_congr rfl + intro k _ + ring +lemma generatorPolynomial_pair_integrable {u : ℝ} (hu : |u|<1) (P : Polynomial ℝ) (n : ℕ) : + IntegrableOn (sechPairIntegrand (generatorPolynomial u P) (fun p=>pollaczekCoeff p n)) (Set.Ioi 0) := by + rw [generatorPolynomial_sum] + have he : sechPairIntegrand (fun p=>∑ k∈range (P.natDegree+1),P.coeff k*generatorMoment u k p) (fun p=>pollaczekCoeff p n)= + fun p=>∑ k∈range (P.natDegree+1),P.coeff k*sechPairIntegrand (generatorMoment u k) (fun p=>pollaczekCoeff p n) p := by + funext p + simp only [sechPairIntegrand,sum_mul,←sum_add_distrib,sum_div] + apply sum_congr rfl + intro k _ + ring + rw [he] + apply integrable_finsetSum + intro k _ + rw [sechPairIntegrand_comm] + exact (pollaczekCoeff_moment_integrable hu n k).const_mul _ +noncomputable def generatorPolynomialCoefficient (u : ℝ) (P : Polynomial ℝ) : Polynomial ℝ := + ∑ k∈range (P.natDegree+1),Polynomial.C (P.coeff k)*generatorMomentPolynomial u k +lemma generatorPolynomialCoefficient_degree (u : ℝ) (P : Polynomial ℝ) : + (generatorPolynomialCoefficient u P).natDegree≤P.natDegree := by + apply natDegree_sum_le_of_forall_le + intro k hk + exact ((natDegree_C_mul_le _ _).trans (generatorMomentPolynomial_degree u k)).trans (by simpa using mem_range.mp hk) +lemma generatorPolynomial_coefficient {u : ℝ} (hu : |u|<1) (hu0 : u≠0) (P : Polynomial ℝ) (n : ℕ) (hn : P.natDegree≤n) : + symmetricSechPair (fun p=>pollaczekCoeff p n) (generatorPolynomial u P)= + u^n*(generatorPolynomialCoefficient u P).eval (n:ℝ) := by + rw [symmetricSechPair_comm,generatorPolynomial_sum] + rw [symmetricSechPair_sum_left] + · simp only [symmetricSechPair_smul_left] + simp only [generatorPolynomialCoefficient,eval_finsetSum,eval_mul,eval_C,mul_sum] + apply sum_congr rfl + intro k hk + rw [symmetricSechPair_comm] + change P.coeff k*generatorMomentCoefficient u k n=_ + rw [generatorMomentCoefficient_polynomial hu hu0 k n (by have :=mem_range.mp hk;omega)] + ring + · intro k _ + rw [sechPairIntegrand_smul_left,sechPairIntegrand_comm] + exact (pollaczekCoeff_moment_integrable hu n k).const_mul _ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Polynomial MeasureTheory +lemma generator_even_sum (u p : ℝ) : + pollaczekGenerator p u+pollaczekGenerator p (-u)= + 2*Real.cos (Real.arctan u)*Real.cosh ((2*Real.arctan u)*p) := by + simp only [pollaczekGenerator,generator_prefactor,Real.arctan_neg,Real.cos_neg,Real.cosh_eq] + rw [show 2*p*(-Real.arctan u)=-(2*Real.arctan u*p) by ring,show 2*p*Real.arctan u=2*Real.arctan u*p by ring] + ring +lemma generator_odd_sum (u p : ℝ) : + pollaczekGenerator p u-pollaczekGenerator p (-u)= + 2*Real.cos (Real.arctan u)*Real.sinh ((2*Real.arctan u)*p) := by + simp only [pollaczekGenerator,generator_prefactor,Real.arctan_neg,Real.cos_neg,Real.sinh_eq] + rw [show 2*p*(-Real.arctan u)=-(2*Real.arctan u*p) by ring,show 2*p*Real.arctan u=2*Real.arctan u*p by ring] + ring +lemma cosineKernelJet_generator_polynomials {u : ℝ} (hu : u≠0) (r : ℕ) : + ∃ A B : Polynomial ℝ,A.natDegree≤r ∧ B.natDegree≤r ∧ + (fun p=>cosineKernelJet r 0 ((2*Real.arctan u)^2) (p^2))= + fun p=>generatorPolynomial u A p+generatorPolynomial (-u) B p := by + let m:=2*Real.arctan u + let c:=2*Real.cos (Real.arctan u) + have hm : m≠0 := mul_ne_zero (by norm_num) (Real.arctan_eq_zero_iff.not.mpr hu) + have hc : c≠0 := by dsimp [c];positivity + let A:=Polynomial.C c⁻¹*(jetCoshPolynomial m r+jetSinhPolynomial m r) + let B:=Polynomial.C c⁻¹*(jetCoshPolynomial m r-jetSinhPolynomial m r) + refine ⟨A,B,?_,?_,?_⟩ + · exact (natDegree_C_mul_le _ _).trans (natDegree_add_le_of_degree_le (jetPolynomial_degrees m r).1 (jetPolynomial_degrees m r).2) + · exact (natDegree_C_mul_le _ _).trans ((natDegree_sub_le _ _).trans (max_le (jetPolynomial_degrees m r).1 (jetPolynomial_degrees m r).2)) + · funext p + rw [cosineKernelJet_polynomials hm] + simp only [generatorPolynomial,A,B,eval_mul,eval_C,eval_add,eval_sub] + have he:=generator_even_sum u p + have ho:=generator_odd_sum u p + change pollaczekGenerator p u+pollaczekGenerator p (-u)=c*Real.cosh (m*p) at he + change pollaczekGenerator p u-pollaczekGenerator p (-u)=c*Real.sinh (m*p) at ho + field_simp + linear_combination -((jetCoshPolynomial m r).eval p)*he-((jetSinhPolynomial m r).eval p)*ho +lemma symmetricSechPair_add_right (f g h : ℝ → ℝ) + (hg : IntegrableOn (sechPairIntegrand f g) (Set.Ioi 0)) + (hh : IntegrableOn (sechPairIntegrand f h) (Set.Ioi 0)) : + symmetricSechPair f (fun p=>g p+h p)=symmetricSechPair f g+symmetricSechPair f h := by + change (∫ p in Set.Ioi (0:ℝ),sechPairIntegrand f (fun p=>g p+h p) p)= + (∫ p in Set.Ioi (0:ℝ),sechPairIntegrand f g p)+(∫ p in Set.Ioi (0:ℝ),sechPairIntegrand f h p) + rw [←integral_add hg hh] + apply integral_congr_ae + filter_upwards with p + unfold sechPairIntegrand + ring +lemma cosineKernelJet_evenCoefficient {u : ℝ} (hu : |u|<1) (hu0 : u≠0) (r : ℕ) : + ∃ P : Polynomial ℝ,P.natDegree≤r ∧ ∀ j : ℕ,r≤2*j → + symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) + (fun p=>cosineKernelJet r 0 ((2*Real.arctan u)^2) (p^2))=(u^2)^j*P.eval (j:ℝ) := by + obtain ⟨A,B,hA,hB,he⟩:=cosineKernelJet_generator_polynomials hu0 r + let P:=(generatorPolynomialCoefficient u A+generatorPolynomialCoefficient (-u) B).comp (Polynomial.C 2*X) + refine ⟨P,?_,?_⟩ + · apply natDegree_comp_le.trans + have hdeg : (generatorPolynomialCoefficient u A+generatorPolynomialCoefficient (-u) B).natDegree≤r := + natDegree_add_le_of_degree_le ((generatorPolynomialCoefficient_degree u A).trans hA) + ((generatorPolynomialCoefficient_degree (-u) B).trans hB) + have hlinear : (Polynomial.C 2*X:Polynomial ℝ).natDegree≤1 := (natDegree_C_mul_le _ _).trans (by simp) + simpa using Nat.mul_le_mul hdeg hlinear + · intro j hj + rw [he,symmetricSechPair_add_right] + · rw [generatorPolynomial_coefficient hu hu0 A (2*j) (hA.trans hj), + generatorPolynomial_coefficient (by simpa using hu) (neg_ne_zero.mpr hu0) B (2*j) (hB.trans hj)] + simp only [P,eval_comp,eval_add,eval_mul,eval_C,eval_X,Nat.cast_mul,Nat.cast_ofNat, + pow_mul,neg_sq] + ring + · rw [sechPairIntegrand_comm];exact generatorPolynomial_pair_integrable hu A (2*j) + · rw [sechPairIntegrand_comm];exact generatorPolynomial_pair_integrable (by simpa using hu) B (2*j) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Polynomial MeasureTheory Finset +lemma polynomialSech_pair_integrable (P : Polynomial ℝ) (n : ℕ) : + IntegrableOn (sechPairIntegrand (fun p=>P.eval (p^2)) (fun p=>pollaczekCoeff p n)) (Set.Ioi 0) := by + obtain ⟨a,ha⟩:=polynomial_evenPollaczekFinite P (le_refl P.natDegree) + rw [ha] + exact evenFinite_pair_integrable _ a _ (fun _=>pollaczekCoeff_pair_integrable _ _) +lemma polynomialSech_coefficient_zero (P : Polynomial ℝ) (j : ℕ) (hj : P.natDegreepollaczekCoeff p (2*j)) (fun p=>P.eval (p^2))=0 := by + obtain ⟨a,ha⟩:=polynomial_evenPollaczekFinite P (le_refl P.natDegree) + rw [ha,symmetricSechPair_comm,evenFinite_pair _ a _ (fun _=>pollaczekCoeff_pair_integrable _ _)] + apply sum_eq_zero + intro i _ + rw [symmetricSechPair_orthogonal,ite_eq_right (by have:=i.isLt;omega),mul_zero] +lemma kernelJet_zeroLabel_polynomial (r : ℕ) : + (fun p=>cosineKernelJet r 0 0 (p^2))= + fun p=>(Polynomial.C ((2*r).factorial:ℝ)⁻¹*X^r).eval (p^2) := by + funext p + simp only [cosineKernelJet_at_zero,eval_mul,eval_C,eval_pow,eval_X] + ring +lemma kernelJet_zeroLabel_coefficient (r j : ℕ) (hr : rpollaczekCoeff p (2*j)) (fun p=>cosineKernelJet r 0 0 (p^2))=0 := by + rw [kernelJet_zeroLabel_polynomial] + apply polynomialSech_coefficient_zero + exact lt_of_le_of_lt ((natDegree_C_mul_le _ _).trans (by simp)) hr +lemma kernelJet_zeroLabel_pair_integrable (r n : ℕ) : + IntegrableOn (sechPairIntegrand (fun p=>cosineKernelJet r 0 0 (p^2)) (fun p=>pollaczekCoeff p n)) (Set.Ioi 0) := by + rw [kernelJet_zeroLabel_polynomial] + exact polynomialSech_pair_integrable _ _ +lemma kernelJet_arctan_pair_integrable {u : ℝ} (hu : |u|<1) (hu0 : u≠0) (r n : ℕ) : + IntegrableOn (sechPairIntegrand (fun p=>cosineKernelJet r 0 ((2*Real.arctan u)^2) (p^2)) + (fun p=>pollaczekCoeff p n)) (Set.Ioi 0) := by + obtain ⟨A,B,_,_,he⟩:=cosineKernelJet_generator_polynomials hu0 r + rw [he] + have he' : sechPairIntegrand (fun p=>generatorPolynomial u A p+generatorPolynomial (-u) B p) + (fun p=>pollaczekCoeff p n)= + fun p=>sechPairIntegrand (generatorPolynomial u A) (fun p=>pollaczekCoeff p n) p+ + sechPairIntegrand (generatorPolynomial (-u) B) (fun p=>pollaczekCoeff p n) p := by + funext p + unfold sechPairIntegrand + ring + rw [he'] + exact (generatorPolynomial_pair_integrable hu A n).add (generatorPolynomial_pair_integrable (by simpa using hu) B n) +noncomputable def completeJetCombination (N : ℕ) (b : ℝ) (a c : Fin N → ℝ) (p : ℝ) : ℝ := + (∑ i,a i*cosineKernelJet i 0 0 (p^2))+(∑ i,c i*cosineKernelJet i 0 b (p^2)) +lemma completeJetCombination_coefficient {u : ℝ} (hu : |u|<1) (hu0 : u≠0) + (N : ℕ) (hN : 0pollaczekCoeff p (2*j)) (completeJetCombination N ((2*Real.arctan u)^2) a c)= + (u^2)^j*P.eval (j:ℝ) := by + choose P hP using fun i:Fin N=>cosineKernelJet_evenCoefficient hu hu0 i + refine ⟨∑ i,Polynomial.C (c i)*P i,?_,?_⟩ + · apply lt_of_le_of_lt (b:=N-1) + · apply natDegree_sum_le_of_forall_le + intro i _ + exact ((natDegree_C_mul_le _ _).trans (hP i).1).trans (by have:=i.isLt;omega) + · omega + · intro j hj + let Q:=fun p=>pollaczekCoeff p (2*j) + have hzero (i : Fin N) : IntegrableOn (sechPairIntegrand (fun p=>a i*cosineKernelJet i 0 0 (p^2)) Q) (Set.Ioi 0) := by + rw [sechPairIntegrand_smul_left] + exact (kernelJet_zeroLabel_pair_integrable i (2*j)).const_mul (a i) + have hpos (i : Fin N) : IntegrableOn (sechPairIntegrand (fun p=>c i*cosineKernelJet i 0 ((2*Real.arctan u)^2) (p^2)) Q) (Set.Ioi 0) := by + rw [sechPairIntegrand_smul_left] + exact (kernelJet_arctan_pair_integrable hu hu0 i (2*j)).const_mul (c i) + have hs (f : Fin N→ℝ→ℝ) : sechPairIntegrand (fun p=>∑ i,f i p) Q=fun p=>∑ i,sechPairIntegrand (f i) Q p := by + funext p + simp only [sechPairIntegrand,sum_mul,←sum_add_distrib,sum_div] + have h0 : IntegrableOn (sechPairIntegrand Q (fun p=>∑ i,a i*cosineKernelJet i 0 0 (p^2))) (Set.Ioi 0) := by + rw [sechPairIntegrand_comm,hs] + exact integrable_finsetSum univ (fun i _=>hzero i) + have h1 : IntegrableOn (sechPairIntegrand Q (fun p=>∑ i,c i*cosineKernelJet i 0 ((2*Real.arctan u)^2) (p^2))) (Set.Ioi 0) := by + rw [sechPairIntegrand_comm,hs] + exact integrable_finsetSum univ (fun i _=>hpos i) + change symmetricSechPair Q (fun p=>(∑ i,a i*cosineKernelJet i 0 0 (p^2))+ + (∑ i,c i*cosineKernelJet i 0 ((2*Real.arctan u)^2) (p^2)))=_ + rw [symmetricSechPair_add_right Q _ _ h0 h1,symmetricSechPair_comm Q (fun p=>∑ i,a i*cosineKernelJet i 0 0 (p^2)), + symmetricSechPair_sum_left _ _ Q (fun i _=>hzero i),symmetricSechPair_comm Q (fun p=>∑ i,c i*cosineKernelJet i 0 ((2*Real.arctan u)^2) (p^2)), + symmetricSechPair_sum_left _ _ Q (fun i _=>hpos i)] + simp only [symmetricSechPair_smul_left] + have hz : ∑ i:Fin N,a i*symmetricSechPair (fun p=>cosineKernelJet i 0 0 (p^2)) Q=0 := by + apply sum_eq_zero + intro i _ + rw [symmetricSechPair_comm,kernelJet_zeroLabel_coefficient i j (by have:=i.isLt;omega),mul_zero] + rw [hz,zero_add] + simp only [eval_finsetSum,eval_mul,eval_C,mul_sum] + apply sum_congr rfl + intro i _ + rw [symmetricSechPair_comm,(hP i).2 j (by have:=i.isLt;omega)] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter Topology +lemma completeJetCombination_finite (N : ℕ) (b : ℝ) (a c : Fin N → ℝ) : + completeJetCombination N b a c=fun p=>finiteJetCombination (N+N) (Fin.addCases a c) + (Fin.addCases (fun _=>(0:ℝ)) (fun _=>b)) (Fin.addCases Fin.val Fin.val) (p^2) := by + funext p + simp only [finiteJetCombination,Fin.sum_univ_add,Fin.addCases_left,Fin.addCases_right,completeJetCombination] +lemma completeJetSech_bounds {b δ : ℝ} (hb : 0≤b) (hlim : Real.sqrt (b+δ)(0:ℝ)) (fun _=>b) i) ∧ + (∀ i:Fin (N+N),Real.sqrt (Fin.addCases (fun _=>(0:ℝ)) (fun _=>b) i+δ)?_) (fun j=>?_) i <;> simp only [Fin.addCases_left,Fin.addCases_right] + · exact le_refl _ + · exact hb + · intro i + refine Fin.addCases (fun j=>?_) (fun j=>?_) i <;> simp only [Fin.addCases_left,Fin.addCases_right] + · exact lt_of_le_of_lt (Real.sqrt_le_sqrt (by linarith)) hlim + · exact hlim +lemma completeJetSech_norm_integrable {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) (hlim : Real.sqrt (b+δ)δ) _ hb' (fun _=>hd) hl' +lemma completeJetSech_pair_integrable {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) (hlim : Real.sqrt (b+δ)pollaczekCoeff p n) (completeJetCombination N b a c)) (Set.Ioi 0) := by + rw [completeJetCombination_finite] + obtain ⟨hb',hl'⟩:=completeJetSech_bounds hb hlim N + exact finiteJetSech_pair_integrable _ _ _ (fun _=>δ) _ hb' (fun _=>hd) hl' n +lemma completeJetSech_parseval_residual {b δ : ℝ} (hb : 0≤b) (hd : 0<δ) (hlim : Real.sqrt (b+δ)symmetricSechPair (completeJetCombination N b a c) (completeJetCombination N b a c)- + ∑ j:Fin (n+1),(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) (completeJetCombination N b a c))^2) + atTop (𝓝 0) := by + rw [completeJetCombination_finite] + obtain ⟨hb',hl'⟩:=completeJetSech_bounds hb hlim N + exact finiteJetSech_parseval_residual _ _ _ (fun _=>δ) _ hb' (fun _=>hd) hl' +lemma label_margin_exists {b : ℝ} (hb : b<(Real.pi/2)^2) : + ∃ δ : ℝ,0<δ ∧ Real.sqrt (b+δ)pollaczekCoeff p (2*j)) f) (Set.Ioi 0)) + (hnorm : symmetricSechPair f f≤1) (j : ℕ) : + |symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f|≤1 := by + have hB:=even_projection_bessel (j+1) f hff (fun i=>hf i) + have hs:=single_le_sum (s:=univ) (f:=fun i:Fin (j+1)=>(symmetricSechPair (fun p=>pollaczekCoeff p (2*i)) f)^2) + (fun i _=>sq_nonneg _) (mem_univ (⟨j,by omega⟩:Fin (j+1))) + simp only at hs + rw [abs_le] + constructor <;> nlinarith +lemma evenProjection_hasSum (f : ℝ → ℝ) + (hres : Tendsto (fun n=>symmetricSechPair f f- + ∑ j:Fin (n+1),(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2) atTop (𝓝 0)) : + HasSum (fun j=>(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2) (symmetricSechPair f f) := by + apply (hasSum_iff_tendsto_nat_of_nonneg (fun j=>sq_nonneg _) _).mpr + apply (Filter.tendsto_add_atTop_iff_nat 1).mp + have hh:=(tendsto_const_nhds (x:=symmetricSechPair f f)).sub hres + have hs (n:ℕ) : (∑ j:Fin n,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2)= + ∑ j∈range n,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2 := + Fin.sum_univ_eq_sum_range (fun j=>(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2) n + simpa only [sub_sub_cancel,sub_zero,hs] using hh +lemma evenProjection_exponential_error (f : ℝ → ℝ) + (hff : IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hf : ∀ j:ℕ,IntegrableOn (sechPairIntegrand (fun p=>pollaczekCoeff p (2*j)) f) (Set.Ioi 0)) + (hres : Tendsto (fun n=>symmetricSechPair f f- + ∑ j:Fin (n+1),(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2) atTop (𝓝 0)) + {γ : ℝ} (hγ : 0<γ) (K : ℕ) + (htail : ∀ j:ℕ,K≤j → |symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f|≤Real.exp (-γ*(j:ℝ))) : + symmetricSechPair (fun p=>f p-evenPollaczekFinite K (fun j=>symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f) p) + (fun p=>f p-evenPollaczekFinite K (fun j=>symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f) p) ≤ + Real.exp (-2*γ*(K:ℝ))/(1-Real.exp (-2*γ)) := by + have hsum:=evenProjection_hasSum f hres + have ht:=(hasSum_nat_add_iff' K).mpr hsum + rw [even_projection_error K f hff (fun j=>hf j)] + simp only [←pow_two] + have he : symmetricSechPair f f-2*(∑ j:Fin K,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2)+ + ∑ j:Fin K,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2= + ∑' j:ℕ,(symmetricSechPair (fun p=>pollaczekCoeff p (2*(j+K))) f)^2 := by + have hs : (∑ j:Fin K,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2)= + ∑ j∈range K,(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2 := + Fin.sum_univ_eq_sum_range (fun j=>(symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f)^2) K + rw [ht.tsum_eq,hs] + ring + rw [he] + have hex : Real.exp (-2*γ)<1 := by rw [Real.exp_lt_one_iff];linarith + have hgeo:=summable_geometric_of_lt_one (Real.exp_pos (-2*γ)).le hex + have hbound (j : ℕ) : (symmetricSechPair (fun p=>pollaczekCoeff p (2*(j+K))) f)^2 ≤ + Real.exp (-2*γ*(K:ℝ))*(Real.exp (-2*γ))^j := by + calc + _ ≤ (Real.exp (-γ*((j+K:ℕ):ℝ)))^2 := by + simpa only [sq_abs] using pow_le_pow_left₀ (abs_nonneg _) (htail (j+K) (by omega)) 2 + _ = _ := by + rw [←Real.exp_nat_mul,←Real.exp_nat_mul,←Real.exp_add] + congr 1 + push_cast + ring + calc + _ ≤ ∑' j:ℕ,Real.exp (-2*γ*(K:ℝ))*(Real.exp (-2*γ))^j := + Summable.tsum_le_tsum hbound ht.summable (hgeo.mul_left _) + _ = _ := by rw [tsum_mul_left,tsum_geometric_of_lt_one (Real.exp_pos _).le hex,div_eq_mul_inv] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/FunctionalTransforms.lean b/lean/OAI/Combinatorics/HoneycombChords/FunctionalTransforms.lean new file mode 100644 index 0000000000000000000000000000000000000000..c94ba08ed9ec09ac4a7b100dcea85b2599cc57ca --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/FunctionalTransforms.lean @@ -0,0 +1,453 @@ +import OAI.Combinatorics.HoneycombChords.ControlledTransforms +import OAI.Combinatorics.HoneycombChords.EntireCosine + +namespace OAI + +/-! Integral transforms and endpoint constraints for the finite strip functional. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Real MeasureTheory Filter Topology +open Analytic + +def RepresentsDensity (F f : ℝ → ℂ) : Prop := ∀ z, 0 < z → F (z^2) = f z + +lemma lift_zDensity {N : ℕ} {f : ℝ → ℂ} (hf : f ∈ zDensity angle N) : + ∃ F ∈ admissibleDensity N, RepresentsDensity F f := by + induction hf using Submodule.span_induction with + | mem f hf => + rcases hf with ((⟨j,rfl⟩ | ⟨j,rfl⟩) | rfl) + · refine ⟨(fun x : ℝ => (x:ℂ)^j.val),?_,?_⟩ + · exact Submodule.mem_sup_left (Submodule.subset_span (Or.inl ⟨j,rfl⟩)) + · intro z hz + simp only [zMonomial,Complex.ofReal_pow] + · refine ⟨(fun x : ℝ => iteratedDeriv j.val (fun t : ℝ => C t x) angle),?_,?_⟩ + · exact Submodule.mem_sup_left (Submodule.subset_span (Or.inr ⟨j,rfl⟩)) + · intro z hz + exact C_sq_jet j.val angle hz.le + · refine ⟨g,Submodule.mem_sup_right (Submodule.subset_span (Set.mem_singleton g)),?_⟩ + intro z hz + exact g_sq hz + | zero => + refine ⟨0,(admissibleDensity N).zero_mem,?_⟩ + intro z hz + rfl + | add f g hf hg hfi hgi => + obtain ⟨F,hF,hfF⟩ := hfi + obtain ⟨G,hG,hgG⟩ := hgi + refine ⟨F+G,(admissibleDensity N).add_mem hF hG,?_⟩ + intro z hz + exact congrArg₂ (·+·) (hfF z hz) (hgG z hz) + | smul a f hf hfi => + obtain ⟨F,hF,hfF⟩ := hfi + refine ⟨a • F,(admissibleDensity N).smul_mem a hF,?_⟩ + intro z hz + exact congrArg (a • ·) (hfF z hz) + +lemma angle_identity : 4*angle = Real.pi/2 := by unfold angle; ring +lemma angle_abs : |angle| = angle := abs_of_pos angle_pos +lemma angle_lt_pi_half : angle < Real.pi/2 := by unfold angle; linarith [Real.pi_pos] + +lemma density_transform_surjective (N : ℕ) (P : Polynomial ℂ) (hP : P.natDegree < 2*N+1) : + ∃ (F f : ℝ → ℂ), F ∈ admissibleDensity N ∧ f ∈ zDensity angle N ∧ RepresentsDensity F f ∧ + ∀ u : ℝ, |u|+angle < Real.pi/2 → + zTransform f u = P.eval (Real.cos (2*u):ℂ) / + interpolationDenominator N (Real.cos (2*u):ℂ) := by + obtain ⟨f,hf,hT⟩ := zTransform_surjective angle_pos angle_lt_pi_half N P hP + obtain ⟨F,hF,hrep⟩ := lift_zDensity hf + refine ⟨F,f,hF,hf,hrep,?_⟩ + intro u hu + exact hT ⟨u,by simpa only [angle_abs] using hu⟩ + +lemma pairing_eq_zIntegral {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) (H : ℝ → ℂ) : + pairing H F = ∫ z in Set.Ioi (0:ℝ), + H (z^2) * f z * (z * zD angle z / (Real.sinh (Real.pi*z/2):ℂ)) := by + unfold pairing + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + rw [hrep z hz,D_sq hz.le] + simp only [zD] + rw [show 4*angle*z = Real.pi*z/2 by rw [angle_identity]; ring] + +lemma value_C_eq_fusion {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) (ρ : ℂ) (u : ℝ) : + value ρ F (C u) = integralFusion angle ρ f u := by + rw [value,C_neg_four,C_zero,mul_one,pairing_eq_zIntegral hrep] + unfold integralFusion aStar zTransform + congr 1 + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + rw [C_sq _ hz.le] + dsimp [zKernel] + ring + +lemma C_parameter_zero (x : ℝ) : C 0 x = 1 := by simp [C] +lemma D_zero : D 0 = 1 := by norm_num [D,C_zero] +lemma D_neg_four : D (-4) = aStar := by unfold D aStar; rw [C_neg_four] +lemma aStar_ne_zero : aStar ≠ 0 := by + unfold aStar angle + rw [show 2*(Real.pi/8) = Real.pi/4 by ring,Real.cos_pi_div_four] + have h : 1 < Real.sqrt 2 := by + nlinarith [Real.sq_sqrt (by norm_num : (0:ℝ) ≤ 2),Real.sqrt_nonneg (2:ℝ)] + have hr : 2*(Real.sqrt 2/2)-1 ≠ 0 := by linarith + exact_mod_cast hr + +lemma value_div_D_eq_interpolant {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) (ρ : ℂ) (u : ℝ) : + value ρ F (fun x => C u x / D x) = integralInterpolant ρ f u := by + rw [value,D_neg_four,D_zero,C_zero,C_neg_four,div_one,mul_one,pairing_eq_zIntegral hrep] + have ha := aStar_ne_zero + have hdisc : 4*aStar*((Real.cos (2*u):ℂ)/aStar) = 4*(Real.cos (2*u):ℂ) := by field_simp + rw [hdisc] + unfold integralInterpolant zTransform + congr 1 + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + have hd := D_sq_ne_zero hz.le + rw [C_sq _ hz.le] + change (Real.cosh (u*z):ℂ)/D (z^2) * f z * + ((z:ℂ)*zD angle z/(Real.sinh (Real.pi*z/2):ℂ)) = _ + have he : D (z^2) = zD angle z := D_sq hz.le + rw [← he] + dsimp [zKernel] + field_simp + +lemma value_inv_D_eq_interpolant {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) (ρ : ℂ) : + value ρ F (fun x => (D x)⁻¹) = integralInterpolant ρ f 0 := by + convert value_div_D_eq_interpolant hrep ρ 0 using 1 + congr 1 + ext x + rw [C_parameter_zero,one_div] + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Real Filter Topology +open Analytic + +lemma iteratedDeriv_complex_ofReal {f : ℝ → ℝ} (hf : ContDiff ℝ ⊤ f) (j : ℕ) (u : ℝ) : + iteratedDeriv j (fun t => (f t : ℂ)) u = (iteratedDeriv j f u : ℝ) := by + induction j generalizing u with + | zero => rfl + | succ j ih => + rw [iteratedDeriv_succ,show iteratedDeriv j (fun t => (f t : ℂ)) = + (fun t => ((iteratedDeriv j f t : ℝ) : ℂ)) from funext ih] + simpa only [iteratedDeriv_succ] using + (((hf.differentiable_iteratedDeriv j (by simp)) u).hasDerivAt.ofReal_comp).deriv + +lemma C_even_jet_zero (j : ℕ) (x : ℝ) : + iteratedDeriv (2*j) (fun t => C t x) 0 = (x:ℂ)^j := by + by_cases hx : 0 ≤ x + · have hs := Real.sq_sqrt hx + rw [← hs,C_sq_jet _ _ (Real.sqrt_nonneg x)] + simp only [zero_mul,hypJet_odd,Real.cosh_zero,mul_one,pow_mul,Complex.ofReal_pow] + · have he (t : ℝ) : C t x = (Real.cos (Real.sqrt (-x)*t):ℂ) := by + simp only [C,hx,ite_false,mul_comm] + rw [show (fun t => C t x) = (fun t => (Real.cos (Real.sqrt (-x)*t):ℂ)) from funext he] + rw [iteratedDeriv_complex_ofReal (by fun_prop)] + rw [iteratedDeriv_comp_const_mul (n := 2*j) (show ContDiff ℝ (2*j) Real.cos by fun_prop)] + rw [Real.iteratedDeriv_even_cos] + simp only [mul_zero,Pi.mul_apply,Pi.pow_apply,Pi.neg_apply,Pi.one_apply,Real.cos_zero,mul_one] + have hsq := Real.sq_sqrt (by linarith : 0 ≤ -x) + rw [pow_mul,hsq] + push_cast + rw [← mul_pow] + congr 1 + ring + +lemma C_jet_hasDerivAt (j : ℕ) (x u : ℝ) : + HasDerivAt (iteratedDeriv j (fun t => C t x)) + (iteratedDeriv (j+1) (fun t => C t x) u) u := by + rw [iteratedDeriv_succ] + exact ((C_contDiff x).differentiable_iteratedDeriv j (by simp)).differentiableAt.hasDerivAt + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Real Filter Topology MeasureTheory +open Analytic + +noncomputable def pairingKernel (H F : ℝ → ℂ) (z : ℝ) : ℂ := + H (z^2)*F (z^2)*((z:ℂ)*D (z^2)/(Real.sinh (4*angle*z):ℂ)) +def PairingIntegrable (H F : ℝ → ℂ) : Prop := + IntegrableOn (pairingKernel H F) (Set.Ioi 0) + +lemma pairingKernel_jet_ae {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) (j : ℕ) (u : ℝ) : + pairingKernel (fun x => iteratedDeriv j (fun t => C t x) u) F =ᵐ[volume.restrict (Set.Ioi 0)] + weightedJet (fun z => zD angle z*f z) j u := by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + dsimp [pairingKernel] + rw [hrep z hz,C_sq_jet j u hz.le,D_sq hz.le] + rw [show 4*angle*z = Real.pi*z/2 by rw [angle_identity]; ring] + dsimp [weightedJet,zD] + ring + +lemma pairingJet_integrable {F f : ℝ → ℂ} {N : ℕ} (hrep : RepresentsDensity F f) + (hf : f ∈ zDensity angle N) (j : ℕ) (u : ℝ) (hu : 2*angle+|u| < Real.pi/2) : + PairingIntegrable (fun x => iteratedDeriv j (fun t => C t x) u) F := by + have hfc := (zDensity_controlled hf).mul_zD angle + rw [angle_abs] at hfc + apply (weightedJet_integrable (u := u) hfc (add_nonneg angle_pos.le angle_pos.le) (by linarith) j).congr + exact (pairingKernel_jet_ae hrep j u).symm + +noncomputable def functionalJet (ρ : ℂ) (f : ℝ → ℂ) (j : ℕ) (u : ℝ) : ℂ := + 4*aStar*iteratedDeriv j (fun t => C t (-4)) u + + ρ*iteratedDeriv j (fun t => C t 0) u + + weightedIntegral (fun z => zD angle z*f z) j u + +lemma functionalJet_zero (ρ : ℂ) (f : ℝ → ℂ) (u : ℝ) : + functionalJet ρ f 0 u = integralFusion angle ρ f u := by + simp only [functionalJet,iteratedDeriv_zero,C_neg_four,C_zero,mul_one,weightedIntegral_zero, + integralFusion,aStar] + +lemma functionalJet_hasDerivAt {f : ℝ → ℂ} {N : ℕ} (hf : f ∈ zDensity angle N) + (ρ : ℂ) (j : ℕ) (u : ℝ) (hu : 2*angle+|u| < Real.pi/2) : + HasDerivAt (functionalJet ρ f j) (functionalJet ρ f (j+1) u) u := by + have hfc := (zDensity_controlled hf).mul_zD angle + rw [angle_abs] at hfc + exact (((C_jet_hasDerivAt j (-4) u).const_mul (4*aStar)).add + ((C_jet_hasDerivAt j 0 u).const_mul ρ)).add + (weightedIntegral_hasDerivAt (u := u) hfc (add_nonneg angle_pos.le angle_pos.le) (by linarith) j) + +lemma iteratedDeriv_integralFusion {f : ℝ → ℂ} {N : ℕ} (hf : f ∈ zDensity angle N) + (ρ : ℂ) (j : ℕ) (u : ℝ) (hu : 2*angle+|u| < Real.pi/2) : + iteratedDeriv j (integralFusion angle ρ f) u = functionalJet ρ f j u := by + induction j generalizing u with + | zero => exact (functionalJet_zero ρ f u).symm + | succ j ih => + have hn : ∀ᶠ t in 𝓝 u, 2*angle+|t| < Real.pi/2 := + (isOpen_lt (continuous_const.add continuous_abs) continuous_const).mem_nhds hu + have he : iteratedDeriv j (integralFusion angle ρ f) =ᶠ[𝓝 u] functionalJet ρ f j := + hn.mono (fun t ht => ih t ht) + rw [iteratedDeriv_succ,he.deriv_eq] + exact (functionalJet_hasDerivAt hf ρ j u hu).deriv + +lemma value_jet_eq {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) (ρ : ℂ) (j : ℕ) (u : ℝ) : + value ρ F (fun x => iteratedDeriv j (fun t => C t x) u) = functionalJet ρ f j u := by + unfold value functionalJet + congr 1 + exact integral_congr_ae (pairingKernel_jet_ae hrep j u) + +lemma pairingKernel_add (H K F : ℝ → ℂ) : + pairingKernel (H+K) F = pairingKernel H F + pairingKernel K F := by + ext z + simp only [pairingKernel,Pi.add_apply] + ring +lemma pairingKernel_smul (a : ℂ) (H F : ℝ → ℂ) : + pairingKernel (a • H) F = a • pairingKernel H F := by + ext z + simp only [pairingKernel,Pi.smul_apply,smul_eq_mul] + ring +lemma pairingKernel_zero (F : ℝ → ℂ) : pairingKernel 0 F = 0 := by + ext z; simp [pairingKernel] + +lemma PairingIntegrable.add {H K F : ℝ → ℂ} (hH : PairingIntegrable H F) + (hK : PairingIntegrable K F) : PairingIntegrable (H+K) F := by + unfold PairingIntegrable + rw [pairingKernel_add] + exact Integrable.add hH hK +lemma PairingIntegrable.smul {H F : ℝ → ℂ} (hH : PairingIntegrable H F) (a : ℂ) : + PairingIntegrable (a • H) F := by + unfold PairingIntegrable + rw [pairingKernel_smul] + exact Integrable.const_mul hH a +lemma PairingIntegrable.zero (F : ℝ → ℂ) : PairingIntegrable 0 F := by + unfold PairingIntegrable + rw [pairingKernel_zero] + exact integrableOn_zero + +lemma value_add {H K F : ℝ → ℂ} (hH : PairingIntegrable H F) + (hK : PairingIntegrable K F) (ρ : ℂ) : + value ρ F (H+K) = value ρ F H + value ρ F K := by + have he : pairing (H+K) F = pairing H F + pairing K F := by + change (∫ z in Set.Ioi (0:ℝ), pairingKernel (H+K) F z) = _ + rw [pairingKernel_add] + exact integral_add hH hK + simp only [value,Pi.add_apply,he] + ring +lemma value_smul (H F : ℝ → ℂ) (ρ a : ℂ) : value ρ F (a • H) = a * value ρ F H := by + have he : pairing (a • H) F = a * pairing H F := by + change (∫ z in Set.Ioi (0:ℝ), pairingKernel (a • H) F z) = _ + rw [pairingKernel_smul] + exact integral_const_mul a _ + simp only [value,Pi.smul_apply,smul_eq_mul,he] + ring +lemma value_zero (F : ℝ → ℂ) (ρ : ℂ) : value ρ F 0 = 0 := by + simp [value,pairing] + +lemma M_integrable_and_annihilated {N : ℕ} {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) + (hf : f ∈ zDensity angle N) (ρ : ℂ) + (hzero : ∀ j < 2*N, iteratedDeriv j (integralFusion angle ρ f) 0 = 0) + (hangle : ∀ j < N, iteratedDeriv j (integralFusion angle ρ f) angle = 0) : + ∀ H ∈ M N, PairingIntegrable H F ∧ value ρ F H = 0 := by + have hu0 : 2*angle+|(0:ℝ)| < Real.pi/2 := by + rw [abs_zero]; unfold angle; linarith [Real.pi_pos] + have huL : 2*angle+|angle| < Real.pi/2 := by + rw [angle_abs]; unfold angle; linarith [Real.pi_pos] + intro H hH + induction hH using Submodule.span_induction with + | mem H hH => + rcases hH with (⟨j,rfl⟩ | ⟨j,rfl⟩) + · have he : (fun x : ℝ => (x:ℂ)^j.val) = + (fun x => iteratedDeriv (2*j.val) (fun t => C t x) 0) := funext (fun x => (C_even_jet_zero j.val x).symm) + change PairingIntegrable (fun x : ℝ => (x:ℂ)^j.val) F ∧ value ρ F (fun x : ℝ => (x:ℂ)^j.val) = 0 + rw [he] + refine ⟨pairingJet_integrable hrep hf _ _ hu0,?_⟩ + rw [value_jet_eq hrep,← iteratedDeriv_integralFusion hf ρ _ _ hu0] + exact hzero _ (by have := j.isLt; omega) + · refine ⟨pairingJet_integrable hrep hf _ _ huL,?_⟩ + rw [value_jet_eq hrep,← iteratedDeriv_integralFusion hf ρ _ _ huL] + exact hangle _ j.isLt + | zero => exact ⟨PairingIntegrable.zero F,value_zero F ρ⟩ + | add H K hH hK hiH hiK => + refine ⟨hiH.1.add hiK.1,?_⟩ + rw [value_add hiH.1 hiK.1,hiH.2,hiK.2,add_zero] + | smul a H hH hiH => + refine ⟨hiH.1.smul a,?_⟩ + rw [value_smul,hiH.2,mul_zero] + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Real Filter Topology MeasureTheory +open Analytic + +lemma integralInterpolant_even (ρ : ℂ) (f : ℝ → ℂ) (u : ℝ) : + integralInterpolant ρ f (-u) = integralInterpolant ρ f u := by + unfold integralInterpolant zTransform + rw [mul_neg,Real.cos_neg] + congr 1 + apply integral_congr_ae + exact ae_of_all _ (fun z => by simp only [zKernel,neg_mul,Real.cosh_neg]) + +lemma pairingKernel_div_D_ae {F f : ℝ → ℂ} (hrep : RepresentsDensity F f) (u : ℝ) : + pairingKernel (fun x => C u x/D x) F =ᵐ[volume.restrict (Set.Ioi 0)] weightedJet f 0 u := by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + dsimp [pairingKernel] + rw [hrep z hz,C_sq _ hz.le,weightedJet_zero] + rw [show 4*angle*z = Real.pi*z/2 by rw [angle_identity]; ring] + have hd := D_sq_ne_zero hz.le + dsimp [zKernel] + field_simp + +lemma pairing_div_D_integrable {F f : ℝ → ℂ} {N : ℕ} (hrep : RepresentsDensity F f) + (hf : f ∈ zDensity angle N) (u : ℝ) (hu : angle+|u| < Real.pi/2) : + PairingIntegrable (fun x => C u x/D x) F := by + have hfc := zDensity_controlled hf + rw [angle_abs] at hfc + apply (weightedJet_integrable hfc angle_pos.le hu 0).congr + exact (pairingKernel_div_D_ae hrep u).symm + +lemma value_sub {H K F : ℝ → ℂ} (hH : PairingIntegrable H F) + (hK : PairingIntegrable K F) (ρ : ℂ) : + value ρ F (H-K) = value ρ F H - value ρ F K := by + rw [show H-K = H+(-1:ℂ) • K by ext x; simp [sub_eq_add_neg]] + rw [value_add hH (hK.smul (-1)),value_smul] + ring + +lemma finite_endpoint_constraints {F f : ℝ → ℂ} {N : ℕ} (hrep : RepresentsDensity F f) + (hf : f ∈ zDensity angle N) (ρ : ℂ) + (h₃ : integralInterpolant ρ f (3*angle/2) = 0) + (h₅ : integralInterpolant ρ f (5*angle/2) = 0) : + value ρ F (C (angle/2)) = 0 ∧ + value ρ F (fun x => C (3*angle/2) x - C (angle/2) x/D x) = 0 := by + have hc := zDensity_controlled hf + have hp := angle_pos + have hhalf : |angle/2| = angle/2 := abs_of_pos (by positivity) + have hthree : |3*angle/2| = 3*angle/2 := abs_of_pos (by positivity) + have hu₁ : |angle|+|angle/2|+|angle| < Real.pi/2 := by + rw [angle_abs,hhalf]; unfold angle; linarith [Real.pi_pos] + have hu₃ : |angle|+|3*angle/2|+|angle| < Real.pi/2 := by + rw [angle_abs,hthree]; unfold angle; linarith [Real.pi_pos] + have hf₁ := integralInterpolant_fusion hc (abs_nonneg _) angle (angle/2) ρ hu₁ + rw [show angle/2-angle = -(angle/2) by ring, + show angle/2+angle = 3*angle/2 by ring,integralInterpolant_even,h₃] at hf₁ + have hf₃ := integralInterpolant_fusion hc (abs_nonneg _) angle (3*angle/2) ρ hu₃ + rw [show 3*angle/2-angle = angle/2 by ring, + show 3*angle/2+angle = 5*angle/2 by ring,h₃,h₅] at hf₃ + constructor + · rw [value_C_eq_fusion hrep] + simpa using hf₁.symm + · have hi₃ : PairingIntegrable (C (3*angle/2)) F := by + convert pairingJet_integrable hrep hf 0 (3*angle/2) (by + rw [hthree]; unfold angle; linarith [Real.pi_pos]) using 1 + ext x + simp + have hi₁ := pairing_div_D_integrable hrep hf (angle/2) (by + rw [hhalf]; unfold angle; linarith [Real.pi_pos]) + change value ρ F (C (3*angle/2) - (fun x => C (angle/2) x/D x)) = 0 + rw [value_sub hi₃ hi₁,value_C_eq_fusion hrep,value_div_D_eq_interpolant hrep,← hf₃] + ring + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Real Filter Topology MeasureTheory +open Analytic + +lemma interpolant_eq_integralInterpolant {N : ℕ} {ρ : ℂ} {P : Polynomial ℂ} {f : ℝ → ℂ} + (hT : ∀ u, |u|+angle < Real.pi/2 → zTransform f u = + P.eval (Real.cos (2*u):ℂ)/interpolationDenominator N (Real.cos (2*u):ℂ)) + {u : ℝ} (hu : |u|+angle < Real.pi/2) : + interpolant N ρ P u = integralInterpolant ρ f u := by + unfold interpolant integralInterpolant + rw [hT u hu] + +lemma interpolant_fusion_eq_integral_eventually {N : ℕ} {ρ : ℂ} {P : Polynomial ℂ} {f : ℝ → ℂ} + (hf : f ∈ zDensity angle N) + (hT : ∀ u, |u|+angle < Real.pi/2 → zTransform f u = + P.eval (Real.cos (2*u):ℂ)/interpolationDenominator N (Real.cos (2*u):ℂ)) + {u : ℝ} (hu : |u|+2*angle < Real.pi/2) : + (fun t => interpolant N ρ P (t-angle)+interpolant N ρ P (t+angle)-interpolant N ρ P t) + =ᶠ[𝓝 u] integralFusion angle ρ f := by + have hn : ∀ᶠ t in 𝓝 u, |t|+2*angle < Real.pi/2 := + (isOpen_lt (continuous_abs.add continuous_const) continuous_const).mem_nhds hu + filter_upwards [hn] with t ht + have ht₁ : |t-angle|+angle < Real.pi/2 := by + have hi := abs_sub t angle + rw [angle_abs] at hi + linarith + have ht₂ : |t+angle|+angle < Real.pi/2 := by + have hi := abs_add_le t angle + rw [angle_abs] at hi + linarith + have ht₀ : |t|+angle < Real.pi/2 := by linarith [angle_pos] + rw [interpolant_eq_integralInterpolant hT ht₁,interpolant_eq_integralInterpolant hT ht₂, + interpolant_eq_integralInterpolant hT ht₀] + apply integralInterpolant_fusion (zDensity_controlled hf) (abs_nonneg _) + rw [angle_abs] + linarith + + +end CriticalHoneycomb.FiniteFunctional + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Geometry.lean b/lean/OAI/Combinatorics/HoneycombChords/Geometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee7f2b466a4f6aff6777afa78cb4110bb324f3a4 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Geometry.lean @@ -0,0 +1,487 @@ +import OAI.Combinatorics.HoneycombChords.PathComponents +import Mathlib + +namespace OAI + +/-! +# Honeycomb centers, ports and simple chords + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb +open scoped ENNReal + +abbrev Center := ℤ × ℤ × Bool + +def up (i j : ℤ) : Center := (i, j, true) +def down (i j : ℤ) : Center := (i, j, false) + +/-- Adjacency across a full triangular edge. -/ +def Adj (v w : Center) : Prop := + if v.2.2 then + w.2.2 = false ∧ ((w.1 = v.1 ∧ w.2.1 = v.2.1) ∨ + (w.1 = v.1 ∧ w.2.1 = v.2.1 - 1) ∨ + (w.1 = v.1 - 1 ∧ w.2.1 = v.2.1)) + else + w.2.2 = true ∧ ((w.1 = v.1 ∧ w.2.1 = v.2.1) ∨ + (w.1 = v.1 ∧ w.2.1 = v.2.1 + 1) ∨ + (w.1 = v.1 + 1 ∧ w.2.1 = v.2.1)) + +noncomputable def rowSpacing : ℝ := Real.sqrt 3 / 2 + +/-- The fixed Euclidean embedding in the unit triangular tiling. -/ +noncomputable def centerPosition (v : Center) : ℝ × ℝ := + if v.2.2 then + ((v.1 : ℝ) + (v.2.1 : ℝ) / 2 + 1 / 2, + rowSpacing * ((v.2.1 : ℝ) + 1 / 3)) + else + ((v.1 : ℝ) + (v.2.1 : ℝ) / 2 + 1, + rowSpacing * ((v.2.1 : ℝ) + 2 / 3)) + +/-- A midpoint port, oriented into the triangle domain. -/ +structure Port (D : Set Center) where + inside : Center + outside : Center + adjacent : Adj inside outside + inside_mem : inside ∈ D + outside_not_mem : outside ∉ D + +noncomputable def Port.position {D : Set Center} (p : Port D) : ℝ × ℝ := + ((centerPosition p.inside).1 / 2 + (centerPosition p.outside).1 / 2, + (centerPosition p.inside).2 / 2 + (centerPosition p.outside).2 / 2) + +/-- A simple center trace, with no premature boundary exit. -/ +def IsTrace (D : Set Center) (p : List Center) : Prop := + p.Nodup ∧ p.IsChain Adj ∧ ∀ v ∈ p, v ∈ D + +def Chord (D : Set Center) (a b : Port D) := + {p : List Center // IsTrace D p ∧ + p.head? = some a.inside ∧ p.getLast? = some b.inside} + +noncomputable def kappa : ℝ := (2 + Real.sqrt 2) ^ (-(1 : ℝ) / 2) + +/-- Length counts centers; the port half-edges contribute no factors. -/ +noncomputable def weight (p : List Center) : ℝ≥0∞ := + ENNReal.ofReal (kappa ^ p.length) + +noncomputable def chordMass (D : Set Center) (a b : Port D) : ℝ≥0∞ := + ∑' p : Chord D a b, weight p.val + + +end CriticalHoneycomb + +namespace CriticalHoneycomb.Transfer.FiniteConfigurations +open SimpleGraph + +lemma adj_symmetric : ∀ ⦃v w : Center⦄, CriticalHoneycomb.Adj v w → CriticalHoneycomb.Adj w v := by + rintro ⟨i,j,c⟩ ⟨k,l,d⟩ h + cases c <;> cases d <;> simp_all [CriticalHoneycomb.Adj] <;> omega + +lemma adj_irrefl (v : Center) : ¬ CriticalHoneycomb.Adj v v := by + rcases v with ⟨i,j,c⟩ + cases c <;> simp [CriticalHoneycomb.Adj] + +abbrev Interior (D : Finset Center) := {v // v ∈ D} +abbrev Vertices (D : Finset Center) := Interior D ⊕ Bool + +def portInside {D : Finset Center} (a : Port (D : Set Center)) : Interior D := + ⟨a.inside,a.inside_mem⟩ + +def hardWallGraph (D : Finset Center) (a b : Port (D : Set Center)) : + SimpleGraph (Vertices D) where + Adj := portRel (fun x y : Interior D => CriticalHoneycomb.Adj x.val y.val) + (portInside a) (portInside b) + symm := ⟨by + intro x y h + cases x with + | inl x => + cases y with + | inl y => exact adj_symmetric h + | inr q => cases q <;> exact h + | inr q => + cases y with + | inl y => cases q <;> exact h + | inr r => cases q <;> cases r <;> exact h.elim⟩ + loopless := ⟨by + intro v + cases v with + | inl v => exact adj_irrefl v.val + | inr q => cases q <;> exact id⟩ + +/-- All hard-wall, unoriented 0/2-degree configurations with the two specified +ports occupied. This is finite graph data, not a probabilistic input. -/ +structure Configuration (D : Finset Center) (a b : Port (D : Set Center)) where + graph : SimpleGraph (Vertices D) + allowed : graph ≤ hardWallGraph D a b + port_degree : ∀ q : Bool, (graph.neighborSet (.inr q)).ncard = 1 + center_degree : ∀ v : Interior D, + (graph.neighborSet (.inl v)).ncard = 0 ∨ (graph.neighborSet (.inl v)).ncard = 2 + +/-- The unique open component supplied by a local physical configuration is +an actual source center trace, with no other exit and with no repeated center. +Only the additionally detached cycle graph remains. -/ +theorem configuration_contains_chord {D : Finset Center} {a b : Port (D : Set Center)} + (C : Configuration D a b) : + ∃ (γ : Chord (D : Set Center) a b) (xs : List (Interior D)) + (p : C.graph.Walk (.inr false) (.inr true)), + xs.map Subtype.val = γ.val ∧ p.IsPath ∧ + p.support = Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true]) ∧ + (C.graph \ p.toSubgraph.spanningCoe).IsCycles := by + classical + have hp (q : Bool) : C.graph.degree (.inr q) = 1 := by + rw [← PathComponents.ncard_neighbors] + exact C.port_degree q + have hc (v : Vertices D) (ha : v ≠ .inr false) (hb : v ≠ .inr true) : + C.graph.degree v = 0 ∨ C.graph.degree v = 2 := by + cases v with + | inl v => + simpa only [PathComponents.ncard_neighbors] using C.center_degree v + | inr q => cases q <;> contradiction + obtain ⟨p,hp',hcycles,_⟩ := PathComponents.path_and_cycles C.graph + (by simp : (Sum.inr false : Vertices D) ≠ .inr true) (hp false) (hp true) hc + obtain ⟨xs,hxs,hn⟩ := support_decomposition p hp' + have hch : p.support.IsChain (hardWallGraph D a b).Adj := + p.isChain_adj_support.imp (fun _ _ h => C.allowed h) + rw [hxs] at hch + have hch' := (chain_ports (fun x y : Interior D => CriticalHoneycomb.Adj x.val y.val) + (portInside a) (portInside b) xs).mp hch + let γ : Chord (D : Set Center) a b := ⟨xs.map Subtype.val, by + refine ⟨⟨hn.map Subtype.val_injective,?_,?_⟩,?_,?_⟩ + · exact (List.isChain_map Subtype.val).mpr hch'.1 + · intro v hv + obtain ⟨x,_,rfl⟩ := List.mem_map.mp hv + exact x.property + · rw [List.head?_map,hch'.2.1] + rfl + · rw [List.getLast?_map,hch'.2.2] + rfl⟩ + exact ⟨γ,xs,p,rfl,hp',hxs,hcycles⟩ + +end CriticalHoneycomb.Transfer.FiniteConfigurations + +namespace CriticalHoneycomb.Transfer.FiniteConfigurations +open SimpleGraph + +/-- Conversely, every actual center chord determines a simple path in the +hard-wall graph with the exact two specified boundary markers. -/ +theorem chord_has_hardWall_path {D : Finset Center} {a b : Port (D : Set Center)} + (γ : Chord (D : Set Center) a b) : + ∃ (xs : List (Interior D)) + (p : (hardWallGraph D a b).Walk (.inr false) (.inr true)), + xs.map Subtype.val = γ.val ∧ p.IsPath ∧ + p.support = Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true]) := by + let xs : List (Interior D) := γ.val.attach.map fun v => + ⟨v.val, γ.property.1.2.2 v.val v.property⟩ + have hmap : xs.map Subtype.val = γ.val := by + simpa only [xs,List.map_map,Function.comp_def] using List.attach_map_subtype_val γ.val + have hnd : xs.Nodup := List.Nodup.of_map _ (hmap.symm ▸ γ.property.1.1) + have hchain : xs.IsChain (fun x y => CriticalHoneycomb.Adj x.val y.val) := by + exact (List.isChain_map Subtype.val).mp (hmap.symm ▸ γ.property.1.2.1) + have hhead : xs.head? = some (portInside a) := by + apply Option.map_injective Subtype.val_injective + change xs.head?.map Subtype.val = some a.inside + rw [← List.head?_map,hmap] + exact γ.property.2.1 + have hlast : xs.getLast? = some (portInside b) := by + apply Option.map_injective Subtype.val_injective + change xs.getLast?.map Subtype.val = some b.inside + rw [← List.getLast?_map,hmap] + exact γ.property.2.2 + let support : List (Vertices D) := Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true]) + have hne : support ≠ [] := List.cons_ne_nil _ _ + have hsc : support.IsChain (hardWallGraph D a b).Adj := + (chain_ports _ (portInside a) (portInside b) xs).mpr ⟨hchain,hhead,hlast⟩ + have hsh : support.head hne = .inr false := by rfl + have hsl : support.getLast hne = .inr true := by simp [support] + let p : (hardWallGraph D a b).Walk (.inr false) (.inr true) := + (Walk.ofSupport support hne hsc).copy hsh hsl + have hps : p.support = support := by + dsimp only [p] + rw [Walk.support_copy,Walk.support_ofSupport] + refine ⟨xs,p,hmap,?_,hps⟩ + rw [Walk.isPath_def,hps] + simp [support,List.nodup_append,hnd.map Sum.inl_injective] +end CriticalHoneycomb.Transfer.FiniteConfigurations + +namespace CriticalHoneycomb +/-- A full triangular edge indexed from its up-triangle side: middle, +south, west. All tensor wires are actual edges, not abstract crossings. -/ +abbrev Wire := ℤ × ℤ × Fin 3 + +def neighbor (v : Center) (k : Fin 3) : Center := + if v.2.2 then down (v.1 - if k=2 then 1 else 0) (v.2.1 - if k=1 then 1 else 0) + else up (v.1 + if k=2 then 1 else 0) (v.2.1 + if k=1 then 1 else 0) + +def incidentWire (v : Center) (k : Fin 3) : Wire := + if v.2.2 then (v.1,v.2.1,k) + else (v.1 + if k=2 then 1 else 0,v.2.1 + if k=1 then 1 else 0,k) + +lemma neighbor_neighbor (v : Center) (k : Fin 3) : neighbor (neighbor v k) k = v := by + rcases v with ⟨i,j,t⟩ + cases t <;> fin_cases k <;> simp [neighbor,up,down] + +lemma neighbor_ne (v : Center) (k : Fin 3) : neighbor v k ≠ v := by + rcases v with ⟨i,j,t⟩ + cases t <;> simp [neighbor,up,down] + +lemma neighbor_injective (v : Center) : Function.Injective (neighbor v) := by + rcases v with ⟨i,j,t⟩ + intro k l h + cases t <;> fin_cases k <;> fin_cases l <;> simp_all [neighbor,up,down] <;> omega + +lemma incidentWire_neighbor (v : Center) (k : Fin 3) : + incidentWire (neighbor v k) k = incidentWire v k := by + rcases v with ⟨i,j,t⟩ + cases t <;> fin_cases k <;> simp [neighbor,incidentWire,up,down] + +lemma incidentWire_injective (v : Center) : Function.Injective (incidentWire v) := by + intro k l h + have hi := congrArg (fun w : Wire => w.2.2) h + cases hv : v.2.2 <;> simpa [incidentWire,hv] using hi + +lemma incidentWire_eq_iff (v w : Center) (k l : Fin 3) : + incidentWire v k = incidentWire w l ↔ k=l ∧ (v=w ∨ neighbor v k=w) := by + rcases v with ⟨i,j,t⟩ + rcases w with ⟨i',j',t'⟩ + cases t <;> cases t' <;> fin_cases k <;> fin_cases l <;> + simp [incidentWire,neighbor,up,down,Prod.mk.injEq] <;> omega + +lemma adj_iff_neighbor (v w : Center) : Adj v w ↔ ∃ k : Fin 3, neighbor v k=w := by + rcases v with ⟨i,j,t⟩ + rcases w with ⟨i',j',t'⟩ + cases t <;> cases t' <;> simp [Adj,neighbor,up,down,Fin.exists_fin_succ] <;> omega + +noncomputable def Port.side {D : Set Center} (p : Port D) : Fin 3 := + ((adj_iff_neighbor p.inside p.outside).mp p.adjacent).choose + +lemma Port.neighbor_side {D : Set Center} (p : Port D) : + neighbor p.inside p.side = p.outside := + ((adj_iff_neighbor p.inside p.outside).mp p.adjacent).choose_spec + +noncomputable def Port.wire {D : Set Center} (p : Port D) : Wire := + incidentWire p.inside p.side + +/-- A selected exterior midpoint may become a prescribed boundary vertex +only at its original inside center. -/ +lemma Port.wire_eq_incident {D : Set Center} (p : Port D) {v : Center} (hv : v∈D) + {k : Fin 3} (h : incidentWire v k=p.wire) : v=p.inside ∧ k=p.side := by + have he := (incidentWire_eq_iff v p.inside k p.side).mp h + have hk := he.1 + refine ⟨?_,hk⟩ + rcases he.2 with he | he + · exact he + · have ho : neighbor p.inside p.side = v := by rw [←he,←hk,neighbor_neighbor] + exact False.elim (p.outside_not_mem (by rw [←p.neighbor_side,ho]; exact hv)) + +lemma Port.wire_ext {D : Set Center} (a b : Port D) (h : a.wire=b.wire) : a=b := by + have he := b.wire_eq_incident a.inside_mem h + have ho : a.outside=b.outside := by rw [←a.neighbor_side,←b.neighbor_side,he.1,he.2] + cases a + cases b + simp_all + +end CriticalHoneycomb + +namespace CriticalHoneycomb.Transfer.FiniteConfigurations +open SimpleGraph + +noncomputable def portAt {D : Finset Center} (a b : Port (D : Set Center)) + (q : Bool) : Port (D : Set Center) := if q then b else a + +/-- Occupied actual midpoint edges, with only the two prescribed exits. -/ +def BoundarySelection {D : Finset Center} (a b : Port (D : Set Center)) + (s : Wire → Bool) : Prop := + s a.wire=true ∧ s b.wire=true ∧ ∀ v∈D, ∀ k : Fin 3, + neighbor v k ∉ D → s (incidentWire v k)=true → + incidentWire v k=a.wire ∨ incidentWire v k=b.wire + +def selectedRel {D : Finset Center} (a b : Port (D : Set Center)) + (s : Wire → Bool) : Vertices D → Vertices D → Prop + | .inl v,.inl w => ∃ k : Fin 3, neighbor v.val k=w.val ∧ s (incidentWire v.val k)=true + | .inl v,.inr q => v.val=(portAt a b q).inside ∧ s (portAt a b q).wire=true + | .inr q,.inl v => v.val=(portAt a b q).inside ∧ s (portAt a b q).wire=true + | .inr _,.inr _ => False + +lemma selectedRel_symm {D : Finset Center} (a b : Port (D : Set Center)) (s : Wire → Bool) : + ∀ ⦃v w : Vertices D⦄, selectedRel a b s v w → selectedRel a b s w v := by + intro x y h + cases x with + | inl v => + cases y with + | inl w => + obtain ⟨k,hk,hs⟩ := h + refine ⟨k,?_,?_⟩ + · rw [←hk,neighbor_neighbor] + · rw [←hk,incidentWire_neighbor]; exact hs + | inr q => exact h + | inr q => cases y <;> exact h + +noncomputable def selectedGraph {D : Finset Center} (a b : Port (D : Set Center)) (s : Wire → Bool) : + SimpleGraph (Vertices D) where + Adj := selectedRel a b s + symm := ⟨selectedRel_symm a b s⟩ + loopless := ⟨by + intro x h + cases x with + | inl v => obtain ⟨k,hk,_⟩ := h; exact neighbor_ne v.val k hk + | inr q => exact h⟩ + +lemma selectedGraph_allowed {D : Finset Center} (a b : Port (D : Set Center)) (s : Wire → Bool) : + selectedGraph a b s ≤ hardWallGraph D a b := by + intro x y h + cases x with + | inl v => cases y with + | inl w => + exact (adj_iff_neighbor v.val w.val).mpr ⟨h.choose,h.choose_spec.1⟩ + | inr q => cases q <;> exact Subtype.ext h.1 + | inr q => cases y with + | inl v => cases q <;> exact Subtype.ext h.1 + | inr r => exact False.elim h + +lemma selectedGraph_port_neighbors {D : Finset Center} (a b : Port (D : Set Center)) + (s : Wire → Bool) (hs : BoundarySelection a b s) (q : Bool) : + (selectedGraph a b s).neighborSet (.inr q) = {.inl (portInside (portAt a b q))} := by + ext x + cases x with + | inl v => + change (v.val=(portAt a b q).inside ∧ _) ↔ _ + have hq : s (portAt a b q).wire=true := by cases q <;> simp_all [portAt,BoundarySelection] + simp [hq,portInside,Subtype.ext_iff] + | inr r => simp [SimpleGraph.neighborSet,selectedGraph,selectedRel] + +/-- The neighbor of a center represented by one of its three actual edges. -/ +def sideNeighbor {D : Finset Center} (a b : Port (D : Set Center)) + (v : Interior D) (k : Fin 3) : Vertices D → Prop + | .inl w => neighbor v.val k = w.val + | .inr q => v.val=(portAt a b q).inside ∧ k=(portAt a b q).side + +lemma sideNeighbor_side_unique {D : Finset Center} (a b : Port (D : Set Center)) + (v : Interior D) {k l : Fin 3} {w : Vertices D} + (hk : sideNeighbor a b v k w) (hl : sideNeighbor a b v l w) : k=l := by + cases w with + | inl w => exact neighbor_injective v.val (hk.trans hl.symm) + | inr q => exact hk.2.trans hl.2.symm + +lemma sideNeighbor_neighbor_unique {D : Finset Center} (a b : Port (D : Set Center)) + (hab : a≠b) (v : Interior D) (k : Fin 3) {x y : Vertices D} + (hx : sideNeighbor a b v k x) (hy : sideNeighbor a b v k y) : x=y := by + cases x with + | inl x => cases y with + | inl y => exact congrArg Sum.inl (Subtype.ext (hx.symm.trans hy)) + | inr q => + have ho : x.val=(portAt a b q).outside := by rw [←hx,hy.1,hy.2,Port.neighbor_side] + exact False.elim ((portAt a b q).outside_not_mem (ho ▸ x.property)) + | inr q => cases y with + | inl y => + have ho : y.val=(portAt a b q).outside := by rw [←hy,hx.1,hx.2,Port.neighbor_side] + exact False.elim ((portAt a b q).outside_not_mem (ho ▸ y.property)) + | inr r => + have he : (portAt a b q).wire=(portAt a b r).wire := by + unfold Port.wire; rw [←hx.1,←hx.2,←hy.1,←hy.2] + have hp := Port.wire_ext _ _ he + cases q <;> cases r <;> simp_all [portAt] + +lemma selected_side_has_neighbor {D : Finset Center} (a b : Port (D : Set Center)) + (s : Wire → Bool) (hs : BoundarySelection a b s) + (v : Interior D) (k : Fin 3) (hk : s (incidentWire v.val k)=true) : + ∃ w : Vertices D, sideNeighbor a b v k w := by + by_cases hi : neighbor v.val k ∈ D + · exact ⟨.inl ⟨_,hi⟩,rfl⟩ + · rcases hs.2.2 v.val v.property k hi hk with ha | hb + · exact ⟨.inr false,by simpa [sideNeighbor,portAt] using a.wire_eq_incident v.property ha⟩ + · exact ⟨.inr true,by simpa [sideNeighbor,portAt] using b.wire_eq_incident v.property hb⟩ + +lemma sideNeighbor_adj {D : Finset Center} (a b : Port (D : Set Center)) + (s : Wire → Bool) (v : Interior D) (k : Fin 3) (w : Vertices D) + (hk : s (incidentWire v.val k)=true) (hw : sideNeighbor a b v k w) : + (selectedGraph a b s).Adj (.inl v) w := by + cases w with + | inl w => exact ⟨k,hw,hk⟩ + | inr q => + refine ⟨hw.1,?_⟩ + simpa [Port.wire,←hw.1,←hw.2] using hk + +lemma adj_sideNeighbor {D : Finset Center} (a b : Port (D : Set Center)) + (s : Wire → Bool) (v : Interior D) (w : Vertices D) + (h : (selectedGraph a b s).Adj (.inl v) w) : + ∃ k : Fin 3, s (incidentWire v.val k)=true ∧ sideNeighbor a b v k w := by + cases w with + | inl w => obtain ⟨k,hw,hk⟩ := h; exact ⟨k,hk,hw⟩ + | inr q => + refine ⟨(portAt a b q).side,?_,h.1,rfl⟩ + simpa [h.1,Port.wire] using h.2 + +end CriticalHoneycomb.Transfer.FiniteConfigurations + +namespace CriticalHoneycomb.Transfer.FiniteConfigurations +open SimpleGraph + +/-- Selected geometric sides and selected graph neighbors are in exact +bijection; the hard-wall condition is used only for the missing exterior +neighbors. Distinct ports may share an inside center. -/ +noncomputable def centerNeighborEquiv {D : Finset Center} (a b : Port (D : Set Center)) + (hab : a≠b) (s : Wire → Bool) (hs : BoundarySelection a b s) (v : Interior D) : + {k : Fin 3 // s (incidentWire v.val k)=true} ≃ + (selectedGraph a b s).neighborSet (.inl v) := by + classical + let f : {k : Fin 3 // s (incidentWire v.val k)=true} → + (selectedGraph a b s).neighborSet (.inl v) := fun k => + ⟨(selected_side_has_neighbor a b s hs v k.val k.property).choose, + sideNeighbor_adj a b s v k.val _ k.property + (selected_side_has_neighbor a b s hs v k.val k.property).choose_spec⟩ + apply Equiv.ofBijective f + constructor + · intro k l h + apply Subtype.ext + apply sideNeighbor_side_unique a b v + (selected_side_has_neighbor a b s hs v k.val k.property).choose_spec + have hval := congrArg Subtype.val h + change (selected_side_has_neighbor a b s hs v k.val k.property).choose = + (selected_side_has_neighbor a b s hs v l.val l.property).choose at hval + rw [hval] + exact (selected_side_has_neighbor a b s hs v l.val l.property).choose_spec + · intro w + obtain ⟨k,hk,hw⟩ := adj_sideNeighbor a b s v w.val w.property + refine ⟨⟨k,hk⟩,Subtype.ext ?_⟩ + exact sideNeighbor_neighbor_unique a b hab v k + (selected_side_has_neighbor a b s hs v k hk).choose_spec hw + +def selectedSideCount (s : Wire → Bool) (v : Center) : ℕ := + (s (incidentWire v 0)).toNat+(s (incidentWire v 1)).toNat+(s (incidentWire v 2)).toNat + +lemma selectedSideCount_eq_card (s : Wire → Bool) (v : Center) : + selectedSideCount s v = Fintype.card {k : Fin 3 // s (incidentWire v k)=true} := by + classical + rw [Fintype.card_subtype,Finset.card_filter,Fin.sum_univ_three] + cases h0 : s (incidentWire v 0) <;> cases h1 : s (incidentWire v 1) <;> + cases h2 : s (incidentWire v 2) <;> + simp [selectedSideCount,h0,h1,h2] + +lemma selectedGraph_center_degree {D : Finset Center} (a b : Port (D : Set Center)) + (hab : a≠b) (s : Wire → Bool) (hs : BoundarySelection a b s) (v : Interior D) : + ((selectedGraph a b s).neighborSet (.inl v)).ncard = selectedSideCount s v.val := by + classical + change Nat.card ((selectedGraph a b s).neighborSet (.inl v)) = _ + rw [Nat.card_eq_fintype_card,selectedSideCount_eq_card] + exact (Fintype.card_congr (centerNeighborEquiv a b hab s hs v)).symm + +/-- The exact local 0/2 rule, rather than an assumed path partition, gives +an admissible finite configuration on the actual honeycomb graph. -/ +noncomputable def configurationOfSides {D : Finset Center} (a b : Port (D : Set Center)) + (hab : a≠b) (s : Wire → Bool) (hs : BoundarySelection a b s) + (hdeg : ∀ v∈D, selectedSideCount s v=0 ∨ selectedSideCount s v=2) : + Configuration D a b where + graph := selectedGraph a b s + allowed := selectedGraph_allowed a b s + port_degree := by intro q; rw [selectedGraph_port_neighbors a b s hs q]; simp + center_degree := by + intro v + rw [selectedGraph_center_degree a b hab s hs v] + exact hdeg v.val v.property + +end CriticalHoneycomb.Transfer.FiniteConfigurations + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/HyperbolicTransform.lean b/lean/OAI/Combinatorics/HoneycombChords/HyperbolicTransform.lean new file mode 100644 index 0000000000000000000000000000000000000000..296d58c97d9e988f6ee892cd029832604eea7896 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/HyperbolicTransform.lean @@ -0,0 +1,361 @@ +import Mathlib + +namespace OAI + +/-! Hyperbolic integral transforms, their domination estimates, and derivatives. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Complex Filter Topology +lemma real_unit_mem_integerComplement {x : ℝ} (h0 : 01/(x-(n+1))+1/(x+(n+1))) + (Real.pi*(Real.tan (Real.pi*x))⁻¹-1/x) := by + have hx:=real_unit_mem_integerComplement h0 h1 + have hs:=(summable_cotTerm hx).hasSum + rw [←cot_series_rep' hx] at hs + have hr:=Complex.hasSum_re hs + simpa only [cotTerm,Complex.cot,Real.tan_eq_sin_div_cos,inv_div,←Complex.ofReal_cos,←Complex.ofReal_sin,←Complex.ofReal_natCast,←Complex.ofReal_one, + ←Complex.ofReal_add,←Complex.ofReal_sub,←Complex.ofReal_div,←Complex.ofReal_mul, + ←Complex.ofReal_tan,←Complex.ofReal_inv,Complex.ofReal_re,one_div] using hr +lemma shifted_reciprocal_sums (x : ℝ) (m : ℕ) : + (∑ n∈Finset.range m,(1/(x+n)+1/(x-(n+1))))= + (∑ n∈Finset.range m,(1/(x-(n+1))+1/(x+(n+1))))+1/x-1/(x+m) := by + induction m with + | zero => simp + | succ m ih => + rw [Finset.sum_range_succ,Finset.sum_range_succ,ih] + push_cast + ring +lemma positive_shifted_reciprocal_hasSum {x : ℝ} (h0 : 01/(x+n)+1/(x-(n+1))) (Real.pi*(Real.tan (Real.pi*x))⁻¹) := by + have h1 : x<1 := by linarith + have hn : ∀ n : ℕ,0≤1/(x+n)+1/(x-(n+1)) := by + intro n + have hb : 01/(x+(n:ℝ))) atTop (𝓝 0) := by + simpa only [one_div, Function.comp_def] using + (tendsto_inv_atTop_zero.comp (tendsto_atTop_add_const_left atTop x tendsto_natCast_atTop_atTop)) + have ht:=((cot_sum_real h0 h1).tendsto_sum_nat.add_const (1/x)).sub ha + simpa only [sub_add_cancel,sub_zero] using ht +noncomputable def tanTerm (m : ℝ) (n : ℕ) : ℝ := + 1/(((n:ℝ)+1/2)*Real.pi-m)-1/(((n:ℝ)+1/2)*Real.pi+m) +lemma tanTerm_nonneg {m : ℝ} (hm : 0 ≤ m) (hM : m < Real.pi / 2) (n : ℕ) : + 0≤tanTerm m n := by + have h : 0<((n:ℝ)+1/2)*Real.pi-m := by + have hn : (0:ℝ)≤n := by positivity + nlinarith [Real.pi_pos] + exact sub_nonneg.mpr (one_div_le_one_div_of_le h (by linarith)) +lemma tan_partial_fractions {m : ℝ} (hm : 0 ≤ m) (hM : m < Real.pi / 2) : + HasSum (tanTerm m) (Real.tan m) := by + let x : ℝ:=1/2-m/Real.pi + have hp:=Real.pi_pos + have hx0 : 0 congr 1 <;> ring +lemma sinh_quotient_exponential (m z : ℝ) : + Real.sinh (m*z)/Real.sinh (Real.pi*z/2)= + ((Real.exp (m*z)-Real.exp (-m*z))*Real.exp (-Real.pi*z/2))/(1-Real.exp (-Real.pi*z)) := by + have he : Real.exp (Real.pi*z/2)*Real.exp (-Real.pi*z/2)=1 := by + rw [←Real.exp_add];ring_nf;simp + have hf : Real.exp (-Real.pi*z)=Real.exp (-Real.pi*z/2)^2 := by + rw [←Real.exp_nat_mul];congr 1;ring + have hd : 1-Real.exp (-Real.pi*z/2)^2= + (Real.exp (Real.pi*z/2)-Real.exp (-Real.pi*z/2))*Real.exp (-Real.pi*z/2) := by + nlinarith [he] + rw [Real.sinh_eq,Real.sinh_eq] + rw [show -(m*z)=-m*z by ring,show -(Real.pi*z/2)=-Real.pi*z/2 by ring,hf,hd] + rw [div_div_div_cancel_right₀ (by norm_num : (2:ℝ)≠0)] + exact (mul_div_mul_right _ _ (Real.exp_ne_zero _)).symm +lemma sinh_kernel_hasSum (m : ℝ) {z : ℝ} (hz : 0 < z) : + HasSum (fun n=>laplaceTerm m n z) (Real.sinh (m*z)/Real.sinh (Real.pi*z/2)) := by + have hq : ‖Real.exp (-Real.pi*z)‖< 1 := by + rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _),Real.exp_lt_one_iff] + nlinarith [Real.pi_pos] + have h:=(hasSum_geometric_of_norm_lt_one hq).mul_left + ((Real.exp (m*z)-Real.exp (-m*z))*Real.exp (-Real.pi*z/2)) + rw [sinh_quotient_exponential,div_eq_mul_inv] + exact h.congr_fun (laplaceTerm_factor m z) +lemma sinh_kernel_integral_nonneg {m : ℝ} (hm : 0 ≤ m) (hM : m < Real.pi/2) : + ∫ z in Set.Ioi (0:ℝ),Real.sinh (m*z)/Real.sinh (Real.pi*z/2)=Real.tan m := by + have he (n : ℕ) : ∫ z in Set.Ioi (0:ℝ),‖laplaceTerm m n z‖=tanTerm m n := by + rw [←laplaceTerm_integral hm hM n] + apply setIntegral_congr_fun measurableSet_Ioi + intro z hz + exact Real.norm_of_nonneg (laplaceTerm_nonneg hm hz.le n) + have hs := hasSum_integral_of_summable_integral_norm + (fun n=>laplaceTerm_integrable hm hM n) + (show Summable (fun n=>∫ z in Set.Ioi (0:ℝ),‖laplaceTerm m n z‖) by + simpa only [he] using (tan_partial_fractions hm hM).summable) + simp_rw [laplaceTerm_integral hm hM] at hs + have hi : (∫ z in Set.Ioi (0:ℝ),∑' n,laplaceTerm m n z)= + ∫ z in Set.Ioi (0:ℝ),Real.sinh (m*z)/Real.sinh (Real.pi*z/2) := by + apply setIntegral_congr_fun measurableSet_Ioi + intro z hz + exact (sinh_kernel_hasSum m hz).tsum_eq + rw [hi] at hs + exact hs.unique (tan_partial_fractions hm hM) +lemma sinh_kernel_integrable_nonneg {m : ℝ} (hm : 0 ≤ m) (hM : m < Real.pi/2) : + IntegrableOn (fun z=>Real.sinh (m*z)/Real.sinh (Real.pi*z/2)) (Set.Ioi 0) := by + rcases hm.eq_or_lt with hm|hm + · subst m;simp + · apply Integrable.of_integral_ne_zero + rw [sinh_kernel_integral_nonneg hm.le hM] + exact (Real.tan_pos_of_pos_of_lt_pi_div_two hm hM).ne' +lemma sinh_kernel_integrable {m : ℝ} (hm : |m| < Real.pi/2) : + IntegrableOn (fun z=>Real.sinh (m*z)/Real.sinh (Real.pi*z/2)) (Set.Ioi 0) := by + by_cases h : 0 ≤ m + · exact sinh_kernel_integrable_nonneg h (lt_of_le_of_lt (le_abs_self _) hm) + · have hn : 0 ≤ -m := by linarith + have h:=(sinh_kernel_integrable_nonneg hn (by simpa [abs_of_neg (lt_of_not_ge h)] using hm)).neg + change IntegrableOn (fun z=>-(Real.sinh (-m*z)/Real.sinh (Real.pi*z/2))) (Set.Ioi 0) at h + simpa only [neg_mul,Real.sinh_neg,neg_div,neg_neg] using h +lemma sinh_kernel_integral {m : ℝ} (hm : |m| < Real.pi/2) : + ∫ z in Set.Ioi (0:ℝ),Real.sinh (m*z)/Real.sinh (Real.pi*z/2)=Real.tan m := by + by_cases h : 0 ≤ m + · exact sinh_kernel_integral_nonneg h (lt_of_le_of_lt (le_abs_self _) hm) + · have hn : 0 ≤ -m := by linarith + have he:=sinh_kernel_integral_nonneg hn (by simpa [abs_of_neg (lt_of_not_ge h)] using hm) + simp only [neg_mul,Real.sinh_neg,neg_div,integral_neg,Real.tan_neg] at he + linarith +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Filter Topology MeasureTheory +lemma cosh_sinh_split (u m z : ℝ) : + Real.cosh (u*z)*Real.sinh (m*z)= + (Real.sinh ((m+u)*z)+Real.sinh ((m-u)*z))/2 := by + rw [add_mul,sub_mul,Real.sinh_add,Real.sinh_sub] + ring +lemma cosh_sinh_kernel_integrable {u m : ℝ} (h : |m|+|u| < Real.pi/2) : + IntegrableOn (fun z=>Real.cosh (u*z)*Real.sinh (m*z)/Real.sinh (Real.pi*z/2)) (Set.Ioi 0) := by + have h₁ : |m+u| < Real.pi/2 := lt_of_le_of_lt (abs_add_le _ _) h + have h₂ : |m-u| < Real.pi/2 := lt_of_le_of_lt (abs_sub _ _) h + have hi:=((sinh_kernel_integrable h₁).add (sinh_kernel_integrable h₂)).div_const 2 + apply hi.congr + filter_upwards [] with z + dsimp + rw [cosh_sinh_split] + ring +lemma cosh_sinh_kernel_integral_tan {u m : ℝ} (h : |m|+|u| < Real.pi/2) : + ∫ z in Set.Ioi (0:ℝ),Real.cosh (u*z)*Real.sinh (m*z)/Real.sinh (Real.pi*z/2)= + (Real.tan (m+u)+Real.tan (m-u))/2 := by + have h₁ : |m+u| < Real.pi/2 := lt_of_le_of_lt (abs_add_le _ _) h + have h₂ : |m-u| < Real.pi/2 := lt_of_le_of_lt (abs_sub _ _) h + have he : (fun z=>Real.cosh (u*z)*Real.sinh (m*z)/Real.sinh (Real.pi*z/2))= + fun z=>(Real.sinh ((m+u)*z)/Real.sinh (Real.pi*z/2)+ + Real.sinh ((m-u)*z)/Real.sinh (Real.pi*z/2))/2 := by + funext z;rw [cosh_sinh_split];ring + rw [he,integral_div,integral_add (sinh_kernel_integrable h₁) (sinh_kernel_integrable h₂), + sinh_kernel_integral h₁,sinh_kernel_integral h₂] +lemma tan_midpoint_identity {u m : ℝ} (h : |m|+|u| < Real.pi/2) : + (Real.tan (m+u)+Real.tan (m-u))/2= + Real.sin (2*m)/(Real.cos (2*u)+Real.cos (2*m)) := by + have h₁ : |m+u| < Real.pi/2 := lt_of_le_of_lt (abs_add_le _ _) h + have h₂ : |m-u| < Real.pi/2 := lt_of_le_of_lt (abs_sub _ _) h + have hc₁ := Real.cos_pos_of_mem_Ioo (abs_lt.mp h₁) + have hc₂ := Real.cos_pos_of_mem_Ioo (abs_lt.mp h₂) + have hd : Real.cos (2*u)+Real.cos (2*m)=2*Real.cos (m+u)*Real.cos (m-u) := by + rw [Real.two_mul_cos_mul_cos] + congr 1 <;> congr 1 <;> ring + have hn : Real.sin (2*m)=Real.sin (m+u)*Real.cos (m-u)+Real.cos (m+u)*Real.sin (m-u) := by + rw [←Real.sin_add] + congr 1;ring + rw [hd,hn,Real.tan_eq_sin_div_cos,Real.tan_eq_sin_div_cos] + field_simp +lemma cosh_sinh_kernel_integral {u m : ℝ} (h : |m|+|u| < Real.pi/2) : + ∫ z in Set.Ioi (0:ℝ),Real.cosh (u*z)*Real.sinh (m*z)/Real.sinh (Real.pi*z/2)= + Real.sin (2*m)/(Real.cos (2*u)+Real.cos (2*m)) := by + rw [cosh_sinh_kernel_integral_tan h,tan_midpoint_identity h] +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Filter Topology MeasureTheory +lemma exp_mul_sinh_le_sinh_add {a b : ℝ} (ha : 0 ≤ a) : + Real.exp a*Real.sinh b ≤ Real.sinh (a+b) := by + have he : Real.exp a*Real.sinh b=(Real.exp (a+b)-Real.exp (a-b))/2 := by + rw [Real.sinh_eq,Real.exp_add,Real.exp_sub,Real.exp_neg] + ring + rw [he,Real.sinh_eq] + have h:=Real.exp_le_exp.mpr (show -(a+b) ≤ a-b by linarith) + linarith +lemma pow_mul_exp_le_sinh {a δ z : ℝ} (ha : 0 ≤ a) (hd : 0 < δ) (hz : 0 ≤ z) (k : ℕ) : + z^(k+1)*Real.exp (a*z) ≤ ((k.factorial:ℝ)/δ^(k+1))*Real.sinh ((a+2*δ)*z) := by + have hk : (0:ℝ) < k.factorial := by positivity + have hp : 0 < δ^k := pow_pos hd _ + have hh := (div_le_iff₀ hk).mp (Real.pow_div_factorial_le_exp (δ*z) (mul_nonneg hd.le hz) k) + rw [mul_pow] at hh + have hpow : z^k ≤ (k.factorial:ℝ)/δ^k*Real.exp (δ*z) := by + rw [div_mul_eq_mul_div,le_div_iff₀ hp] + nlinarith + have hlin : z ≤ Real.sinh (δ*z)/δ := by + apply (le_div_iff₀ hd).mpr + simpa [mul_comm] using Real.self_le_sinh_iff.mpr (mul_nonneg hd.le hz) + calc + z^(k+1)*Real.exp (a*z) = z^k*z*Real.exp (a*z) := by rw [pow_succ] + _ ≤ ((k.factorial:ℝ)/δ^k*Real.exp (δ*z))*(Real.sinh (δ*z)/δ)*Real.exp (a*z) := by + gcongr + _ = ((k.factorial:ℝ)/δ^(k+1))*(Real.exp ((a+δ)*z)*Real.sinh (δ*z)) := by + rw [add_mul,Real.exp_add,pow_succ] + field_simp + _ ≤ ((k.factorial:ℝ)/δ^(k+1))*Real.sinh ((a+2*δ)*z) := by + gcongr + convert exp_mul_sinh_le_sinh_add (b:=δ*z) (mul_nonneg (add_nonneg ha hd.le) hz) using 1; congr 1; ring +lemma polynomial_kernel_integrable (k : ℕ) {a : ℝ} (ha : 0 ≤ a) (hA : a < Real.pi/2) : + IntegrableOn (fun z=>z^(k+1)*Real.exp (a*z)/Real.sinh (Real.pi*z/2)) (Set.Ioi 0) := by + let δ : ℝ := (Real.pi/2-a)/4 + have hd : 0 < δ := by dsimp [δ];linarith + have hs : |a+2*δ| < Real.pi/2 := by + rw [abs_of_nonneg (by positivity)] + dsimp [δ];linarith + have hi := (sinh_kernel_integrable hs).const_mul ((k.factorial:ℝ)/δ^(k+1)) + apply hi.mono' + · exact (by fun_prop : Measurable (fun z=>z^(k+1)*Real.exp (a*z)/Real.sinh (Real.pi*z/2))).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + have hz0 : 0 ≤ z := hz.le + have hden : 0 ≤ Real.sinh (Real.pi*z/2) := Real.sinh_nonneg_iff.mpr (by positivity) + rw [Real.norm_of_nonneg (by positivity),←mul_div_assoc] + exact div_le_div_of_nonneg_right (pow_mul_exp_le_sinh ha hd hz0 k) hden +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Filter Topology MeasureTheory +noncomputable def hypJet (j : ℕ) (x : ℝ) : ℝ := + (Real.exp x-(-1:ℝ)^j*Real.exp (-x))/2 +@[simp] lemma hypJet_zero (x : ℝ) : hypJet 0 x=Real.sinh x := by simp [hypJet,Real.sinh_eq] +@[simp] lemma hypJet_one (x : ℝ) : hypJet 1 x=Real.cosh x := by simp [hypJet,Real.cosh_eq] +lemma hypJet_hasDerivAt (j : ℕ) (x : ℝ) : HasDerivAt (hypJet j) (hypJet (j+1) x) x := by + have h:=((Real.hasDerivAt_exp x).sub (((hasDerivAt_id x).neg.exp).const_mul ((-1:ℝ)^j))).div_const 2 + convert h using 1 <;> try rfl + dsimp [hypJet] + rw [pow_succ] + ring +lemma hypJet_abs_le (j : ℕ) (x : ℝ) : |hypJet j x| ≤ Real.exp |x| := by + have h:=abs_sub (Real.exp x) ((-1:ℝ)^j*Real.exp (-x)) + have h₁:=Real.exp_le_exp.mpr (le_abs_self x) + have h₂:=Real.exp_le_exp.mpr (neg_le_abs x) + simp only [hypJet,abs_div,abs_of_nonneg (by norm_num : (0:ℝ) ≤ 2)] + simp only [abs_mul,abs_pow,abs_neg,abs_one,one_pow,one_mul, + abs_of_pos (Real.exp_pos _)] at h + linarith +lemma cosh_abs_le_exp_abs (x : ℝ) : |Real.cosh x| ≤ Real.exp |x| := by + simpa using hypJet_abs_le 1 x +noncomputable def transformJet (u : ℝ) (j : ℕ) (m z : ℝ) : ℝ := + Real.cosh (u*z)*z^j*hypJet j (m*z)/Real.sinh (Real.pi*z/2) +lemma transformJet_zero (u m z : ℝ) : transformJet u 0 m z= + Real.cosh (u*z)*Real.sinh (m*z)/Real.sinh (Real.pi*z/2) := by + simp [transformJet] +lemma transformJet_hasDerivAt (u : ℝ) (j : ℕ) (m z : ℝ) : + HasDerivAt (fun t=>transformJet u j t z) (transformJet u (j+1) m z) m := by + have h:=(((hypJet_hasDerivAt j (m*z)).comp m ((hasDerivAt_id m).mul_const z)).const_mul + (Real.cosh (u*z)*z^j)).div_const (Real.sinh (Real.pi*z/2)) + convert h using 1 <;> try rfl + dsimp [transformJet] + rw [pow_succ] + ring +lemma transformJet_norm_le {u m a z : ℝ} (j : ℕ) (hz : 0 ≤ z) (ha : |u|+|m| ≤ a) : + ‖transformJet u j m z‖ ≤ z^j*Real.exp (a*z)/Real.sinh (Real.pi*z/2) := by + have hd : 0 ≤ Real.sinh (Real.pi*z/2) := Real.sinh_nonneg_iff.mpr (by positivity) + rw [Real.norm_eq_abs,transformJet,abs_div,abs_of_nonneg hd,abs_mul,abs_mul,abs_pow,abs_of_nonneg hz] + apply div_le_div_of_nonneg_right _ hd + calc + |Real.cosh (u*z)| * z^j*|hypJet j (m*z)| ≤ Real.exp |u*z| * z^j*Real.exp |m*z| := by + gcongr + · exact cosh_abs_le_exp_abs _ + · exact hypJet_abs_le _ _ + _ = z^j*Real.exp ((|u|+|m|)*z) := by + rw [abs_mul,abs_mul,abs_of_nonneg hz,add_mul,Real.exp_add] + ring + _ ≤ z^j*Real.exp (a*z) := by gcongr +lemma transformJet_integrable {u m : ℝ} (j : ℕ) (h : |m|+|u| < Real.pi/2) : + IntegrableOn (transformJet u j m) (Set.Ioi 0) := by + cases j with + | zero => exact (cosh_sinh_kernel_integrable h).congr (ae_of_all _ (fun z=>(transformJet_zero u m z).symm)) + | succ j => + have hi:=polynomial_kernel_integrable j (add_nonneg (abs_nonneg u) (abs_nonneg m)) (by linarith : |u|+|m| < Real.pi/2) + apply hi.mono' + · exact (by unfold transformJet hypJet;fun_prop : Measurable (transformJet u (j+1) m)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + exact transformJet_norm_le _ hz.le le_rfl +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Interlacing.lean b/lean/OAI/Combinatorics/HoneycombChords/Interlacing.lean new file mode 100644 index 0000000000000000000000000000000000000000..91cc699e85dd593a017cf8f4273a0b4dd225904a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Interlacing.lean @@ -0,0 +1,1354 @@ +import OAI.Combinatorics.HoneycombChords.PositiveFlags + +namespace OAI + +/-! +# Moment pencils and positive root interlacing + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +noncomputable def flagPencil (n : ℕ) (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) : + Matrix (Fin n) (Fin n) ℝ := + fun i j=>∫ p in Set.Ioi (0:ℝ),(p^2-r)*F i (p^2)*G j (p^2)*w p +lemma flagPencil_prefix (n : ℕ) (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) : + (flagPencil (n+1) F G w r).submatrix Fin.castSucc Fin.castSucc=flagPencil n F G w r := rfl +lemma flagPencil_transpose (n : ℕ) (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) : + (flagPencil n F G w r).transpose=flagPencil n G F w r := by + ext i j + apply integral_congr_ae + filter_upwards [] with p + ring +lemma flagPencil_pairing {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (a : Fin n → ℝ) (j : ℕ) + (hi : ∀ i : Fin n,IntegrableOn (fun p=>(p^2-r)*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + IntegrableOn (fun p=>(p^2-r)*familyCombination F a (p^2)*G j (p^2)*w p) (Set.Ioi 0) ∧ + (∫ p in Set.Ioi (0:ℝ),(p^2-r)*familyCombination F a (p^2)*G j (p^2)*w p)= + ∑ i,a i*(∫ p in Set.Ioi (0:ℝ),(p^2-r)*F i (p^2)*G j (p^2)*w p) := by + have he : (fun p=>(p^2-r)*familyCombination F a (p^2)*G j (p^2)*w p)= + fun p=>∑ i,a i*((p^2-r)*F i (p^2)*G j (p^2)*w p) := by + funext p + simp only [familyCombination,mul_sum,sum_mul] + apply sum_congr rfl + intro i _ + ring + rw [he] + constructor + · exact integrable_finsetSum _ (fun i _=>(hi i).const_mul (a i)) + · rw [integral_finsetSum _ (fun i _=>(hi i).const_mul (a i))] + simp only [integral_const_mul] +lemma flagPencil_kernel_last_ne {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (a : Fin (n+1) → ℝ) (ha : a ≠ 0) (hk : a ᵥ* flagPencil (n+1) F G w r=0) + (hF : PositiveFlag F (n+1)) (hG : PositiveFlag G (n+1)) + (hFc : ∀ i : Fin (n+1),Continuous (F i)) (hGc : ∀ i : Fin (n+1),Continuous (G i)) + (hw : ∀ p,0 < p → 0 < w p) + (hi : ∀ i j : Fin (n+1),IntegrableOn (fun p=>(p^2-r)*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + a (Fin.last n) ≠ 0 ∧ 0 < r := by + have hoi (j : Fin (n+1)) := flagPencil_pairing F G w r a j (fun i=>hi i j) + have ho (j : Fin (n+1)) : + (∫ p in Set.Ioi (0:ℝ),(p^2-r)*familyCombination F a (p^2)*G j (p^2)*w p)=0 := by + rw [(hoi j).2] + exact congrFun hk j + obtain ⟨Z,hZc,hZ,hr,_⟩ := flag_orthogonal_linear_zeros F G a w r (hF _ le_rfl) hG hFc hGc ha hw + (fun j=>(hoi j).1) ho + refine ⟨?_,hr⟩ + intro he + let b : Fin n → ℝ := fun i=>a i.castSucc + have hb : b ≠ 0 := by + intro hz + apply ha + ext i + refine Fin.lastCases ?_ (fun k=>?_) i + · exact he + · exact congrFun hz k + have hab x : familyCombination F a x=familyCombination F b x := by + simp [familyCombination,Fin.sum_univ_castSucc,he,b] + have hc := familyCombination_zeros_card_lt F b (hF _ (by omega)) hb Z + (fun x hx=>⟨((hZ x).mp hx).1,by rw [←hab];exact ((hZ x).mp hx).2⟩) + omega +lemma flagPencil_monic_left_kernel {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (hz : (flagPencil (n+1) F G w r).det=0) + (hF : PositiveFlag F (n+1)) (hG : PositiveFlag G (n+1)) + (hFc : ∀ i : Fin (n+1),Continuous (F i)) (hGc : ∀ i : Fin (n+1),Continuous (G i)) + (hw : ∀ p,0 < p → 0 < w p) + (hi : ∀ i j : Fin (n+1),IntegrableOn (fun p=>(p^2-r)*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + 0 < r ∧ ∃ a : Fin (n+1) → ℝ,a (Fin.last n)=1 ∧ a ᵥ* flagPencil (n+1) F G w r=0 := by + obtain ⟨a,ha,hk⟩ := Matrix.exists_vecMul_eq_zero_iff.mpr hz + obtain ⟨hl,hr⟩ := flagPencil_kernel_last_ne F G w r a ha hk hF hG hFc hGc hw hi + refine ⟨hr,(a (Fin.last n))⁻¹ • a,?_,?_⟩ + · simp [hl] + · rw [smul_vecMul,hk,smul_zero] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +/-- Exact signed-border identity with positive factors at every real root. +This proves the Sturm sign needed for the second oblique comparison. -/ +theorem flagPencil_sturm {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (hz : (flagPencil (n+1) F G w r).det=0) + (hF : PositiveFlag F (n+2)) (hG : PositiveFlag G (n+2)) + (hFc : ∀ i : Fin (n+2),Continuous (F i)) (hGc : ∀ i : Fin (n+2),Continuous (G i)) + (hw : ∀ p,0 < p → 0 < w p) + (hi : ∀ i j : Fin (n+2),IntegrableOn (fun p=>(p^2-r)*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + 0 < r ∧ ∃ L R : ℝ,0 < L ∧ 0 < R ∧ + (flagPencil (n+2) F G w r).det= -(flagPencil n F G w r).det*L*R := by + have hF' : PositiveFlag F (n+1) := fun k hk=>hF k (by omega) + have hG' : PositiveFlag G (n+1) := fun k hk=>hG k (by omega) + obtain ⟨hr,a,ha,hak⟩ := flagPencil_monic_left_kernel F G w r hz hF' hG' + (fun i=>hFc i.castSucc) (fun j=>hGc j.castSucc) hw (fun i j=>hi i.castSucc j.castSucc) + have hzt : (flagPencil (n+1) G F w r).det=0 := by + rw [←flagPencil_transpose,det_transpose,hz] + have hit (i j : Fin (n+2)) : IntegrableOn (fun p=>(p^2-r)*G i (p^2)*F j (p^2)*w p) (Set.Ioi 0) := by + have he : (fun p=>(p^2-r)*G i (p^2)*F j (p^2)*w p)=(fun p=>(p^2-r)*F j (p^2)*G i (p^2)*w p) := by + funext p + ring + rw [he] + exact hi j i + obtain ⟨_,h,hh,hht⟩ := flagPencil_monic_left_kernel G F w r hzt hG' hF' + (fun i=>hGc i.castSucc) (fun j=>hFc j.castSucc) hw (fun i j=>hit i.castSucc j.castSucc) + have hhk : flagPencil (n+1) F G w r *ᵥ h=0 := by + rw [←flagPencil_transpose,vecMul_transpose] at hht + exact hht + let L := ∫ p in Set.Ioi (0:ℝ),(p^2-r)*familyCombination F a (p^2)*G (n+1) (p^2)*w p + let R := ∫ p in Set.Ioi (0:ℝ),(p^2-r)*familyCombination G h (p^2)*F (n+1) (p^2)*w p + have hL : 0 < L := by + apply monic_cross_pairing_pos F G a w r hF' hG (fun i=>hFc i.castSucc) hGc ha hw + · intro j + exact (flagPencil_pairing F G w r a j (fun i=>hi i.castSucc j)).1 + · intro j + rw [(flagPencil_pairing F G w r a j (fun i=>hi i.castSucc j.castSucc)).2] + exact congrFun hak j + have hR : 0 < R := by + apply monic_cross_pairing_pos G F h w r hG' hF (fun i=>hGc i.castSucc) hFc hh hw + · intro j + exact (flagPencil_pairing G F w r h j (fun i=>hit i.castSucc j)).1 + · intro j + rw [(flagPencil_pairing G F w r h j (fun i=>hit i.castSucc j.castSucc)).2] + exact congrFun hht j + refine ⟨hr,L,R,hL,hR,?_⟩ + have hDL : ((Fin.lastCases 0 a) ᵥ* flagPencil (n+2) F G w r) (Fin.last (n+1))=L := by + dsimp [L] + rw [(flagPencil_pairing F G w r a (n+1) (fun i=>hi i.castSucc (Fin.last (n+1)))).2] + simp [vecMul,dotProduct,Fin.sum_univ_castSucc,flagPencil] + have hDR : (flagPencil (n+2) F G w r *ᵥ (Fin.lastCases 0 h)) (Fin.last (n+1))=R := by + rw [←vecMul_transpose,flagPencil_transpose] + dsimp [R] + rw [(flagPencil_pairing G F w r h (n+1) (fun i=>hit i.castSucc (Fin.last (n+1)))).2] + simp [vecMul,dotProduct,Fin.sum_univ_castSucc,flagPencil] + have he := det_double_border_at_nullvectors (flagPencil (n+2) F G w r) a h ha hh hak hhk + rw [hDL,hDR] at he + exact he +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Polynomial +noncomputable def generalizedCharpoly {n : ℕ} (W X : Matrix (Fin n) (Fin n) ℝ) : ℝ[X] := + (W⁻¹*X).charpoly +lemma generalizedCharpoly_monic {n : ℕ} (W X : Matrix (Fin n) (Fin n) ℝ) : + (generalizedCharpoly W X).Monic := Matrix.charpoly_monic _ +lemma generalizedCharpoly_natDegree {n : ℕ} (W X : Matrix (Fin n) (Fin n) ℝ) : + (generalizedCharpoly W X).natDegree=n := by simp [generalizedCharpoly] +lemma generalizedCharpoly_eval {n : ℕ} (W X : Matrix (Fin n) (Fin n) ℝ) + (hW : W.det ≠ 0) (r : ℝ) : + W.det*(generalizedCharpoly W X).eval r = (-1:ℝ)^n*(X-r • W).det := by + have hu : IsUnit W.det := isUnit_iff_ne_zero.mpr hW + have he : W*(Matrix.scalar (Fin n) r-W⁻¹*X)=r • W-X := by + rw [mul_sub,←Matrix.mul_assoc,Matrix.mul_nonsing_inv W hu,Matrix.one_mul] + rw [Matrix.scalar_apply,←Matrix.smul_eq_mul_diagonal] + rw [generalizedCharpoly,Matrix.eval_charpoly,←Matrix.det_mul,he] + have hn : r • W-X= -(X-r • W) := by abel + rw [hn,Matrix.det_neg,Fintype.card_fin] +lemma generalizedCharpoly_eval_zero_iff {n : ℕ} (W X : Matrix (Fin n) (Fin n) ℝ) + (hW : W.det ≠ 0) (r : ℝ) : + (generalizedCharpoly W X).eval r=0 ↔ (X-r • W).det=0 := by + have h := generalizedCharpoly_eval W X hW r + have hs : (-1:ℝ)^n ≠ 0 := pow_ne_zero _ (by norm_num) + exact ⟨fun hz=>by rw [hz,mul_zero] at h;exact (mul_eq_zero.mp h.symm).resolve_left hs, + fun hz=>by rw [hz,mul_zero] at h;exact (mul_eq_zero.mp h).resolve_left hW⟩ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Polynomial +noncomputable def flagGram (n : ℕ) (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) : Matrix (Fin n) (Fin n) ℝ := + familyGram w (fun i=>F i) (fun j=>G j) +noncomputable def flagCharacteristic (n : ℕ) (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) : ℝ[X] := + generalizedCharpoly (flagGram n F G w) (flagPencil n F G w 0) +lemma flagPencil_affine {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin n,IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + flagPencil n F G w r=flagPencil n F G w 0-r • flagGram n F G w := by + ext i j + have he : (fun p=>(p^2-r)*F i (p^2)*G j (p^2)*w p)= + (fun p=>p^2*F i (p^2)*G j (p^2)*w p)-(fun p=>r*(F i (p^2)*G j (p^2)*w p)) := by + funext p + simp only [Pi.sub_apply] + ring + simp only [flagPencil,flagGram,familyGram,Matrix.sub_apply,Matrix.smul_apply,smul_eq_mul,sub_zero,he] + change (∫ p in Set.Ioi 0, (p^2*F i (p^2)*G j (p^2)*w p)-r*(F i (p^2)*G j (p^2)*w p)) = _ + rw [integral_sub (h2 i j) ((hi i j).const_mul r),integral_const_mul] +lemma flagPencil_integrable {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin n,IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + ∀ i j : Fin n,IntegrableOn (fun p=>(p^2-r)*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0) := by + intro i j + have he : (fun p=>(p^2-r)*F i (p^2)*G j (p^2)*w p)= + (fun p=>p^2*F i (p^2)*G j (p^2)*w p)-(fun p=>r*(F i (p^2)*G j (p^2)*w p)) := by + funext p + simp only [Pi.sub_apply] + ring + rw [he] + exact (h2 i j).sub ((hi i j).const_mul r) +lemma flagGram_det_pos {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hF : PositiveFlag F n) (hG : PositiveFlag G n) (hw : ∀ p,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + 0 < (flagGram n F G w).det := familyGram_det_pos w _ _ (hF _ le_rfl) (hG _ le_rfl) hw hi +lemma flagPencil_zero_det_pos {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hF : PositiveFlag F n) (hG : PositiveFlag G n) (hw : ∀ p,0

p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + 0 < (flagPencil n F G w 0).det := by + have he : flagPencil n F G w 0=familyGram (fun p=>p^2*w p) (fun i : Fin n=>F i) (fun j : Fin n=>G j) := by + ext i j + apply integral_congr_ae + filter_upwards [] with p + ring + rw [he] + apply familyGram_det_pos _ _ _ (hF _ le_rfl) (hG _ le_rfl) + · intro p hp + exact mul_pos (sq_pos_of_pos hp) (hw p hp) + · intro i j + have he' : (fun p=>F i (p^2)*G j (p^2)*(p^2*w p))=(fun p=>p^2*F i (p^2)*G j (p^2)*w p) := by + funext p + ring + rw [he'] + exact h2 i j +lemma flagCharacteristic_eval {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (hW : (flagGram n F G w).det ≠ 0) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin n,IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + (flagGram n F G w).det*(flagCharacteristic n F G w).eval r= + (-1:ℝ)^n*(flagPencil n F G w r).det := by + rw [flagCharacteristic,generalizedCharpoly_eval _ _ hW,←flagPencil_affine F G w r hi h2] +lemma flagCharacteristic_eval_zero_iff {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r : ℝ) + (hW : (flagGram n F G w).det ≠ 0) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin n,IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + (flagCharacteristic n F G w).eval r=0 ↔ (flagPencil n F G w r).det=0 := by + rw [flagCharacteristic,generalizedCharpoly_eval_zero_iff _ _ hW,←flagPencil_affine F G w r hi h2] +lemma flagCharacteristic_zero_sign {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hF : PositiveFlag F n) (hG : PositiveFlag G n) (hw : ∀ p,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin N,IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + ∀ n,n+1 ≤ N → PositiveInterlacing (flagCharacteristic n F G w) (flagCharacteristic (n+1) F G w) n := by + apply polynomial_sturm_chain (fun n=>flagCharacteristic n F G w) + · intro k _ + exact generalizedCharpoly_monic _ _ + · intro k _ + exact generalizedCharpoly_natDegree _ _ + · intro k hk + exact flagCharacteristic_zero_sign F G w (fun j hj=>hF j (hj.trans hk)) (fun j hj=>hG j (hj.trans hk)) hw + (fun i j=>hi (i.castLE hk) (j.castLE hk)) (fun i j=>h2 (i.castLE hk) (j.castLE hk)) + · intro k hk r hz + exact flagCharacteristic_sturm F G w r hz (fun j hj=>hF j (hj.trans hk)) (fun j hj=>hG j (hj.trans hk)) + (fun i=>hFc (i.castLE hk)) (fun i=>hGc (i.castLE hk)) hw + (fun i j=>hi (i.castLE hk) (j.castLE hk)) (fun i j=>h2 (i.castLE hk) (j.castLE hk)) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Polynomial +lemma flagPencil_ratio {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r s : ℝ) + (hW : (flagGram n F G w).det ≠ 0) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin n,IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + (flagPencil n F G w r).det/(flagPencil n F G w s).det= + (flagCharacteristic n F G w).eval r/(flagCharacteristic n F G w).eval s := by + have hr:=flagCharacteristic_eval F G w r hW hi h2 + have hs:=flagCharacteristic_eval F G w s hW hi h2 + have he:=congrArg₂ (fun a b : ℝ=>a/b) hr hs + simpa only [mul_div_mul_left _ _ hW,mul_div_mul_left _ _ (pow_ne_zero n (by norm_num : (-1:ℝ)≠0))] using he.symm +/-- A one-dimensional determinant comparison for oblique chains with positive Chebyshev extensions. -/ +theorem flagPencil_one_step {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hF : PositiveFlag F (n+1)) (hG : PositiveFlag G (n+1)) + (hFc : ∀ i : Fin (n+1),Continuous (F i)) (hGc : ∀ i : Fin (n+1),Continuous (G i)) + (hw : ∀ p,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin (n+1),IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + {A B : ℝ} (hA : 0hF k (by omega)) + (fun k hk=>hG k (by omega)) hw (fun i j : Fin n=>hi i.castSucc j.castSucc) + rw [flagPencil_ratio F G w _ _ hW.ne' hi h2, + flagPencil_ratio F G w _ _ hWn.ne' (fun i j=>hi i.castSucc j.castSucc) (fun i j=>h2 i.castSucc j.castSucc)] + exact positive_interlacing_ratio _ _ (flagCharacteristic_interlaces F G w hF hG hFc hGc hw hi h2 n le_rfl) hA hAB +theorem flagPencil_two_steps {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hF : PositiveFlag F (n+2)) (hG : PositiveFlag G (n+2)) + (hFc : ∀ i : Fin (n+2),Continuous (F i)) (hGc : ∀ i : Fin (n+2),Continuous (G i)) + (hw : ∀ p,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin (n+2),IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + {A B : ℝ} (hA : 0hF k (by omega)) (fun k hk=>hG k (by omega)) + (fun i=>hFc i.castSucc) (fun i=>hGc i.castSucc) hw (fun i j=>hi i.castSucc j.castSucc) + (fun i j=>h2 i.castSucc j.castSucc) hA hAB + have h2':=flagPencil_one_step (n:=n+1) F G w hF hG hFc hGc hw hi h2 hA hAB + refine ⟨?_,h2'.2.trans h1.2⟩ + calc + _ = (A/B)*((A/B)*((flagPencil n F G w (-A)).det/(flagPencil n F G w (-B)).det)) := by ring + _ ≤ _ := (mul_le_mul_of_nonneg_left h1.1 (div_nonneg hA.le (hA.trans hAB).le)).trans h2'.1 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +/-- For the actual second oblique chain, the bases are reordered relative to +the sorted complete jets. The orientation is immaterial for a pencil ratio. -/ +def NonvanishingFlag (F : ℕ → ℝ → ℝ) (N : ℕ) : Prop := + ∀ k,k ≤ N → ∀ x : Fin k → ℝ,StrictMono x → (∀ i,0F i) x).det ≠ 0 +noncomputable def flagAnchor (F : ℕ → ℝ → ℝ) (n : ℕ) : ℝ := + (evaluationMatrix (fun i : Fin n=>F i) (fun i : Fin n=>(i.val:ℝ)+1)).det +noncomputable def flagOrientation (F : ℕ → ℝ → ℝ) (i : ℕ) : ℝ := flagAnchor F i/flagAnchor F (i+1) +noncomputable def orientedFlag (F : ℕ → ℝ → ℝ) (i : ℕ) (x : ℝ) : ℝ := flagOrientation F i*F i x +lemma flagAnchor_ne_zero {N : ℕ} (F : ℕ → ℝ → ℝ) (hF : NonvanishingFlag F N) (k : ℕ) (hk : k ≤ N) : + flagAnchor F k ≠ 0 := by + apply hF k hk + · intro i j hij + have h : (i.val:ℝ)(1-t)*x i+t*y i + let f : ℝ → ℝ := fun t=>(evaluationMatrix F (v t)).det + have hc' : Continuous f := by + apply Continuous.matrix_det + apply continuous_pi + intro i + apply continuous_pi + intro j + exact (hc i).comp ((continuous_const.sub continuous_id).mul continuous_const |>.add (continuous_id.mul continuous_const)) + have hv t (ht : t∈Set.Icc (0:ℝ) 1) : StrictMono (v t) ∧ ∀ i,0 intro hneg <;> by_contra hh + · obtain ⟨t,ht,he⟩ := isPreconnected_Icc.intermediate_value (by simp : (0:ℝ)∈Set.Icc 0 1) + (by simp : (1:ℝ)∈Set.Icc 0 1) hc'.continuousOn ⟨hneg.le,le_of_not_gt hh⟩ + exact hn t ht he + · obtain ⟨t,ht,he⟩ := isPreconnected_Icc.intermediate_value (by simp : (1:ℝ)∈Set.Icc 0 1) + (by simp : (0:ℝ)∈Set.Icc 0 1) hc'.continuousOn ⟨hneg.le,le_of_not_gt hh⟩ + exact hn t ht he + have hp : 0not_lt_of_gt h (hs.mpr hn))) (Ne.symm (hn 1 (by simp))) + exact mul_pos h h1 + simpa [f,v] using hp +lemma flagOrientation_product {N : ℕ} (F : ℕ → ℝ → ℝ) (hF : NonvanishingFlag F N) : + ∀ n,n ≤ N → (∏ i : Fin n,flagOrientation F i)=1/flagAnchor F n := by + intro n + induction n with + | zero => intro _;simp [flagAnchor] + | succ n ih => + intro hn + rw [Fin.prod_univ_castSucc] + simp only [Fin.val_castSucc,Fin.val_last] + rw [ih (by omega)] + dsimp [flagOrientation] + field_simp [flagAnchor_ne_zero F hF n (by omega),flagAnchor_ne_zero F hF (n+1) hn] +lemma orientedFlag_positive {N : ℕ} (F : ℕ → ℝ → ℝ) (hF : NonvanishingFlag F N) + (hc : ∀ i : Fin N,Continuous (F i)) : PositiveFlag (orientedFlag F) N := by + intro n hn x hx hx0 + have hy : StrictMono (fun i : Fin n=>(i.val:ℝ)+1) := by + intro i j hij + have h : (i.val:ℝ)F i) (hF n hn) (fun i=>hc (i.castLE hn)) x + (fun i : Fin n=>(i.val:ℝ)+1) hx hy hx0 (fun i=>by positivity) + change 0 < (Matrix.of (fun i j : Fin n=>flagOrientation F i*F i (x j))).det + have hd := Matrix.det_mul_column (fun i : Fin n=>flagOrientation F i) (evaluationMatrix (fun i : Fin n=>F i) x) + simp only [evaluationMatrix] at hd + rw [hd,flagOrientation_product F hF n hn] + change 0<(1/flagAnchor F n)*(evaluationMatrix (fun i : Fin n=>F i) x).det + rw [one_div,mul_comm,←div_eq_mul_inv] + exact (div_pos_iff).mpr (by + rcases mul_pos_iff.mp hp with h|h + · exact Or.inl h + · exact Or.inr h) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Equiv Finset +/-- Move one selected row to the end, preserving the order of the rest. -/ +def moveLast (n : ℕ) (p : Fin (n+1)) : Equiv.Perm (Fin (n+1)) := + (finSuccEquiv' (Fin.last n)).trans (finSuccEquiv' p).symm +lemma moveLast_castSucc (n : ℕ) (p : Fin (n+1)) (i : Fin n) : + moveLast n p i.castSucc=p.succAbove i := by + simp [moveLast,finSuccEquiv'_last_apply_castSucc] +lemma moveLast_last (n : ℕ) (p : Fin (n+1)) : moveLast n p (Fin.last n)=p := by simp [moveLast] +def liftLastPerm {n : ℕ} (σ : Equiv.Perm (Fin n)) : Equiv.Perm (Fin (n+1)) := + (finSuccEquiv' (Fin.last n)).trans ((Equiv.optionCongr σ).trans (finSuccEquiv' (Fin.last n)).symm) +lemma liftLastPerm_castSucc {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + liftLastPerm σ i.castSucc=(σ i).castSucc := by + simp [liftLastPerm,finSuccEquiv'_last_apply_castSucc] +lemma liftLastPerm_last {n : ℕ} (σ : Equiv.Perm (Fin n)) : liftLastPerm σ (Fin.last n)=Fin.last n := by + simp [liftLastPerm] +def liftFirstPerm {n : ℕ} (σ : Equiv.Perm (Fin n)) : Equiv.Perm (Fin (n+1)) := + (finSuccEquiv' 0).trans ((Equiv.optionCongr σ).trans (finSuccEquiv' 0).symm) +lemma liftFirstPerm_zero {n : ℕ} (σ : Equiv.Perm (Fin n)) : liftFirstPerm σ 0=0 := by simp [liftFirstPerm] +lemma liftFirstPerm_succ {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + liftFirstPerm σ i.succ=(σ i).succ := by + simp [liftFirstPerm,finSuccEquiv'_above (Fin.zero_le i.castSucc)] +lemma evaluation_perm_det_ne_zero {n : ℕ} (F : Fin n → ℝ → ℝ) (σ : Equiv.Perm (Fin n)) (x : Fin n → ℝ) + (h : (evaluationMatrix F x).det ≠ 0) : (evaluationMatrix (fun i=>F (σ i)) x).det ≠ 0 := by + have he : evaluationMatrix (fun i=>F (σ i)) x=(evaluationMatrix F x).submatrix σ id := by ext;rfl + rw [he,Matrix.det_permute] + exact mul_ne_zero (by exact_mod_cast (Perm.sign σ).ne_zero) h +lemma constant_row_subtraction_det {n : ℕ} (H : Fin (n+1) → ℝ → ℝ) (hH : ∀ x,H 0 x=1) (x : Fin (n+1) → ℝ) : + (evaluationMatrix (Fin.cons (fun _=>1) (fun i y=>H i.succ y-H i.succ 0)) x).det=(evaluationMatrix H x).det := by + let c : Fin (n+1) → ℝ := Fin.cons 0 (fun i=> -H i.succ 0) + apply Matrix.det_eq_of_forall_row_eq_smul_add_const c 0 (by simp [c]) + intro i j + refine Fin.cases ?_ (fun i=>?_) i + · simp [evaluationMatrix,c,hH] + · simp [evaluationMatrix,c,hH,sub_eq_add_neg] +lemma cons_zeroJet_det {n : ℕ} (b : ℕ → ℝ) (hb : b 0=0) (x : Fin (n+1) → ℝ) : + (evaluationMatrix (Fin.cons (fun _=>1) (fun i : Fin n=>zeroJet b i)) x).det=(jetEvaluation b x).det := by + exact constant_row_subtraction_det (fun i : Fin (n+1)=>cosineKernelJet (nodalOrder b i) 0 (b i)) + (jet_first_constant b hb) x +lemma prepend_permuted_det_ne_zero {n : ℕ} (u : Fin n → ℝ → ℝ) (a : ℝ → ℝ) (σ : Equiv.Perm (Fin n)) + (x : Fin (n+1) → ℝ) (h : (evaluationMatrix (Fin.cons a u) x).det ≠ 0) : + (evaluationMatrix (Fin.cons a (fun i=>u (σ i))) x).det ≠ 0 := by + have he : Fin.cons a (fun i=>u (σ i))=(fun i=>(Fin.cons a u : Fin (n+1) → ℝ → ℝ) (liftFirstPerm σ i)) := by + funext i + refine Fin.cases ?_ (fun i=>?_) i + · simp [liftFirstPerm_zero] + · simp [liftFirstPerm_succ] + rw [he] + exact evaluation_perm_det_ne_zero _ _ _ h +lemma append_permuted_det_ne_zero {n : ℕ} (u : Fin n → ℝ → ℝ) (a : ℝ → ℝ) (σ : Equiv.Perm (Fin n)) + (x : Fin (n+1) → ℝ) (h : (evaluationMatrix (Fin.lastCases a u) x).det ≠ 0) : + (evaluationMatrix (Fin.lastCases a (fun i=>u (σ i))) x).det ≠ 0 := by + have he : Fin.lastCases a (fun i=>u (σ i))=(fun i=>(Fin.lastCases a u : Fin (n+1) → ℝ → ℝ) (liftLastPerm σ i)) := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [liftLastPerm_last] + · simp [liftLastPerm_castSucc] + rw [he] + exact evaluation_perm_det_ne_zero _ _ _ h +lemma constant_to_last_det_ne_zero {n : ℕ} (u : Fin n → ℝ → ℝ) (a : ℝ → ℝ) + (x : Fin (n+1) → ℝ) (h : (evaluationMatrix (Fin.cons a u) x).det ≠ 0) : + (evaluationMatrix (Fin.lastCases a u) x).det ≠ 0 := by + have he : Fin.lastCases a u=(fun i=>(Fin.cons a u : Fin (n+1) → ℝ → ℝ) (moveLast n 0 i)) := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [moveLast_last] + · simp [moveLast_castSucc] + rw [he] + exact evaluation_perm_det_ne_zero _ _ _ h +lemma cons_lastCases_swap {n : ℕ} (u : Fin n → ℝ → ℝ) (a b : ℝ → ℝ) : + (Fin.cons a (Fin.lastCases b u) : Fin (n+2) → ℝ → ℝ)=Fin.lastCases b (Fin.cons a u) := by + funext i + refine Fin.cases ?_ (fun i=>?_) i + · change a=(Fin.lastCases b (Fin.cons a u) : Fin (n+2) → ℝ → ℝ) (0 : Fin (n+1)).castSucc + simp only [Fin.lastCases_castSucc,Fin.cons_zero] + · refine Fin.lastCases ?_ (fun i=>?_) i + · simp only [Fin.cons_succ,Fin.lastCases_last] + change b=(Fin.lastCases b (Fin.cons a u) : Fin (n+2) → ℝ → ℝ) (Fin.last (n+1)) + simp only [Fin.lastCases_last] + · simp only [Fin.cons_succ,Fin.lastCases_castSucc] + rw [←Fin.castSucc_succ] + simp only [Fin.lastCases_castSucc,Fin.cons_succ] +lemma constant_to_penultimate_det_ne_zero {n : ℕ} (u : Fin n → ℝ → ℝ) (a b : ℝ → ℝ) + (x : Fin (n+2) → ℝ) (h : (evaluationMatrix (Fin.cons a (Fin.lastCases b u)) x).det ≠ 0) : + (evaluationMatrix (Fin.lastCases b (Fin.lastCases a u)) x).det ≠ 0 := by + rw [cons_lastCases_swap] at h + have he : Fin.lastCases a u=(fun i=>(Fin.cons a u : Fin (n+1) → ℝ → ℝ) (moveLast n 0 i)) := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [moveLast_last] + · simp [moveLast_castSucc] + rw [he] + exact append_permuted_det_ne_zero _ _ _ _ h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv +lemma extendedKnot_before (N k : ℕ) (hk : k<2*N+1) : + extendedKnotLabels N k=interiorKnotLabels N (angle/2) k := by simp [extendedKnotLabels,hk] +lemma extendedKnot_order_before (N k : ℕ) (hk : k<2*N+1) : + nodalOrder (extendedKnotLabels N) k=nodalOrder (interiorKnotLabels N (angle/2)) k := by + unfold nodalOrder + congr 1 + apply filter_congr + intro j hj + rw [extendedKnot_before N k hk,extendedKnot_before N j ((mem_range.mp hj).trans hk)] +lemma zero_extended_before (N j : ℕ) (hj : j+1<2*N+1) : + zeroJet (extendedKnotLabels N) j=zeroJet (interiorKnotLabels N (angle/2)) j := by + funext x + simp [zeroJet,extendedKnot_before N (j+1) hj,extendedKnot_order_before N (j+1) hj] +lemma extendedKnot_monotone (N : ℕ) : Monotone (extendedKnotLabels N) := by + have hhalf : 0zeroJet (interiorKnotLabels N s) (moveLast m (zeroInsertion hm) i))= + Fin.lastCases (zeroJet (interiorKnotLabels N s) (N-1)) (fun i : Fin m=>zeroJet (twoKnotLabels N) i) := by + funext i x + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [moveLast_last,zeroInsertion] + · rw [moveLast_castSucc] + simp only [Fin.lastCases_castSucc] + by_cases hi : i.valzeroJet (twoKnotLabels N) i)) x).det ≠ 0 := by + rw [←zero_insertion_reorder hm hN hs hsL] + apply evaluation_perm_det_ne_zero (fun i : Fin (m+1)=>zeroJet (interiorKnotLabels N s) i) (moveLast m (zeroInsertion hm)) x + exact (zeroJet_positiveEvaluation (interiorKnotLabels N s) + (fun i j hij=>interiorKnot_monotone N hs hsL hij) (fun i=>interiorKnot_nonneg N i s) + (interiorKnot_first N hN s) x hx hx0).ne' +lemma zero_extended_split {m N : ℕ} (hm : m+1=2*N) : + (fun i : Fin (m+2)=>zeroJet (extendedKnotLabels N) i)= + Fin.lastCases (zeroJet (extendedKnotLabels N) (m+1)) (fun i : Fin (m+1)=>zeroJet (interiorKnotLabels N (angle/2)) i) := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i + · simp + · simp only [Fin.lastCases_castSucc,Fin.val_castSucc] + exact zero_extended_before N i (by omega) +lemma secondLeft_top_det_ne_zero {m N : ℕ} (hm : m+1=2*N) (hN : 0zeroJet (twoKnotLabels N) i))) x).det ≠ 0 := by + have hs : 0zeroJet (interiorKnotLabels N (angle/2)) i) + (zeroJet (extendedKnotLabels N) (m+1)) (moveLast m (zeroInsertion hm)) x + rw [←zero_extended_split hm] + exact (zeroJet_positiveEvaluation (extendedKnotLabels N) + (fun i j hij=>extendedKnot_monotone N hij) (fun i=>extendedKnot_nonneg N i) + (extendedKnot_first N hN) x hx hx0).ne' +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +lemma scalar_familyPencil_det {n : ℕ} (F G : ℕ → ℝ → ℝ) (a b : ℕ → ℝ) (w : ℝ → ℝ) (r : ℝ) : + (flagPencil n (fun i x=>a i*F i x) (fun i x=>b i*G i x) w r).det= + (∏ i : Fin n,a i)*(∏ j : Fin n,b j)*(flagPencil n F G w r).det := by + have he : flagPencil n (fun i x=>a i*F i x) (fun i x=>b i*G i x) w r= + Matrix.of (fun i j : Fin n=>a i*(b j*flagPencil n F G w r i j)) := by + ext i j + dsimp [flagPencil] + rw [←integral_const_mul,←integral_const_mul] + apply integral_congr_ae + filter_upwards [] with p + ring + have hd := Matrix.det_mul_column (fun i : Fin n=>a i) (Matrix.of (fun i j : Fin n=>b j*flagPencil n F G w r i j)) + simp only [Matrix.of_apply] at hd + rw [he,hd,Matrix.det_mul_row,mul_assoc] +lemma orientedFlagPencil_ratio {N n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) (r s : ℝ) + (hF : NonvanishingFlag F N) (hG : NonvanishingFlag G N) (hn : n ≤ N) : + (flagPencil n (orientedFlag F) (orientedFlag G) w r).det/ + (flagPencil n (orientedFlag F) (orientedFlag G) w s).det= + (flagPencil n F G w r).det/(flagPencil n F G w s).det := by + unfold orientedFlag + rw [scalar_familyPencil_det,scalar_familyPencil_det] + apply mul_div_mul_left + exact mul_ne_zero (by rw [flagOrientation_product F hF n hn];exact one_div_ne_zero (flagAnchor_ne_zero F hF n hn)) + (by rw [flagOrientation_product G hG n hn];exact one_div_ne_zero (flagAnchor_ne_zero G hG n hn)) +lemma orientedFlag_integrable {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + ∀ i j : Fin n,IntegrableOn (fun p=>orientedFlag F i (p^2)*orientedFlag G j (p^2)*w p) (Set.Ioi 0) := by + intro i j + have he : (fun p=>orientedFlag F i (p^2)*orientedFlag G j (p^2)*w p)= + fun p=>(flagOrientation F i*flagOrientation G j)*(F i (p^2)*G j (p^2)*w p) := by + funext p;dsimp [orientedFlag];ring + rw [he] + exact (hi i j).const_mul _ +/-- A two-step determinant comparison for Chebyshev families. -/ +theorem unorientedPencil_two_steps {n : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hF : NonvanishingFlag F (n+2)) (hG : NonvanishingFlag G (n+2)) + (hFc : ∀ i : Fin (n+2),Continuous (F i)) (hGc : ∀ i : Fin (n+2),Continuous (G i)) + (hw : ∀ p,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin (n+2),IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + {A B : ℝ} (hA : 0p^2*orientedFlag F i (p^2)*orientedFlag G j (p^2)*w p) (Set.Ioi 0) := by + intro i j + have he : (fun p=>p^2*orientedFlag F i (p^2)*orientedFlag G j (p^2)*w p)= + fun p=>(flagOrientation F i*flagOrientation G j)*(p^2*F i (p^2)*G j (p^2)*w p) := by + funext p;dsimp [orientedFlag];ring + rw [he] + exact (h2 i j).const_mul _ + have h:=flagPencil_two_steps (orientedFlag F) (orientedFlag G) w + (orientedFlag_positive F hF hFc) (orientedFlag_positive G hG hGc) + (fun i=>(hFc i).const_mul _) (fun i=>(hGc i).const_mul _) hw + (orientedFlag_integrable F G w hi) h2' hA hAB + rw [orientedFlagPencil_ratio F G w _ _ hF hG le_rfl, + orientedFlagPencil_ratio F G w _ _ hF hG (by omega)] at h + exact h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv +lemma secondRight_middle_det_ne_zero {m N : ℕ} (hN : 01) (fun i : Fin m=>zeroJet (twoKnotLabels N) i)) x).det ≠ 0 := by + apply constant_to_last_det_ne_zero + rw [cons_zeroJet_det _ (twoKnot_first N hN)] + exact (jetEvaluation_det_pos (twoKnotLabels N) x (fun i j hij=>twoKnot_monotone N hij) hx + (fun i=>twoKnot_nonneg N i) (fun i=>(hx0 i).le)).ne' +lemma secondRight_top_det_ne_zero {m N : ℕ} (hm : m+1=2*N) (hN : 01) (fun i : Fin m=>zeroJet (twoKnotLabels N) i))) x).det ≠ 0 := by + apply constant_to_penultimate_det_ne_zero + rw [←zero_insertion_reorder hm hN ht htL] + apply prepend_permuted_det_ne_zero (fun i : Fin (m+1)=>zeroJet (interiorKnotLabels N t) i) + (fun _=>1) (moveLast m (zeroInsertion hm)) x + rw [cons_zeroJet_det _ (interiorKnot_first N hN t)] + exact (jetEvaluation_det_pos (interiorKnotLabels N t) x (fun i j hij=>interiorKnot_monotone N ht htL hij) hx + (fun i=>interiorKnot_nonneg N i t) (fun i=>(hx0 i).le)).ne' +noncomputable def appendTwo (F : ℕ → ℝ → ℝ) (m : ℕ) (a b : ℝ → ℝ) (k : ℕ) (x : ℝ) : ℝ := + if k < m then F k x else if k=m then a x else b x +lemma appendTwo_prefix {m n : ℕ} (F : ℕ → ℝ → ℝ) (a b : ℝ → ℝ) (hn : n ≤ m) : + (fun i : Fin n=>appendTwo F m a b i)=(fun i : Fin n=>F i) := by + funext i x + simp [appendTwo,show i.val < m from i.isLt.trans_le hn] +lemma appendTwo_middle (m : ℕ) (F : ℕ → ℝ → ℝ) (a b : ℝ → ℝ) : + (fun i : Fin (m+1)=>appendTwo F m a b i)=Fin.lastCases a (fun i : Fin m=>F i) := by + funext i x + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [appendTwo] + · simp [appendTwo,i.isLt] +lemma appendTwo_top (m : ℕ) (F : ℕ → ℝ → ℝ) (a b : ℝ → ℝ) : + (fun i : Fin (m+2)=>appendTwo F m a b i)=Fin.lastCases b (Fin.lastCases a (fun i : Fin m=>F i)) := by + funext i x + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [appendTwo] + · simpa only [Fin.val_castSucc,Fin.lastCases_castSucc] using congrFun (congrFun (appendTwo_middle m F a b) i) x +noncomputable def secondLeftFlag (m N : ℕ) : ℕ → ℝ → ℝ := + appendTwo (zeroJet (twoKnotLabels N)) m (zeroJet (interiorKnotLabels N (angle/2)) (N-1)) + (zeroJet (extendedKnotLabels N) (m+1)) +noncomputable def secondRightFlag (m N : ℕ) (t : ℝ) : ℕ → ℝ → ℝ := + appendTwo (zeroJet (twoKnotLabels N)) m (fun _=>1) (zeroJet (interiorKnotLabels N t) (N-1)) +lemma zero_twoKnot_nonvanishing (N : ℕ) (hN : 0twoKnot_monotone N hij) + (fun i=>twoKnot_nonneg N i) (twoKnot_first N hN) x hx hx0).ne' +lemma secondLeft_nonvanishing {m N : ℕ} (hm : m+1=2*N) (hN : 0appendTwo _ m _ _ i) x).det ≠ 0 + rw [appendTwo_prefix _ _ _ hnm] + exact zero_twoKnot_nonvanishing N hN m n hnm x hx hx0 + · have hc : n=m+1 ∨ n=m+2 := by omega + rcases hc with rfl|rfl + · change (evaluationMatrix (fun i : Fin (m+1)=>appendTwo _ m _ _ i) x).det ≠ 0 + rw [appendTwo_middle] + exact zero_interior_appended_det_ne_zero hm hN (half_pos strip_angle_pos) (by linarith [strip_angle_pos]) x hx hx0 + · change (evaluationMatrix (fun i : Fin (m+2)=>appendTwo _ m _ _ i) x).det ≠ 0 + rw [appendTwo_top] + exact secondLeft_top_det_ne_zero hm hN x hx hx0 +lemma secondRight_nonvanishing {m N : ℕ} (hm : m+1=2*N) (hN : 0appendTwo _ m _ _ i) x).det ≠ 0 + rw [appendTwo_prefix _ _ _ hnm] + exact zero_twoKnot_nonvanishing N hN m n hnm x hx hx0 + · have hc : n=m+1 ∨ n=m+2 := by omega + rcases hc with rfl|rfl + · change (evaluationMatrix (fun i : Fin (m+1)=>appendTwo _ m _ _ i) x).det ≠ 0 + rw [appendTwo_middle] + exact secondRight_middle_det_ne_zero hN x hx hx0 + · change (evaluationMatrix (fun i : Fin (m+2)=>appendTwo _ m _ _ i) x).det ≠ 0 + rw [appendTwo_top] + exact secondRight_top_det_ne_zero hm hN ht htL x hx hx0 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +noncomputable def stripKernelSpan (B : ℝ) : Submodule ℝ (ℝ → ℝ) := + Submodule.span ℝ {f | ∃ b : ℝ,∃ r : ℕ,0 ≤ b ∧ b ≤ B ∧ f=cosineKernelJet r 0 b} +lemma kernel_mem_stripSpan {B b : ℝ} (hb : 0 ≤ b) (hbB : b ≤ B) (r : ℕ) : + cosineKernelJet r 0 b ∈ stripKernelSpan B := Submodule.subset_span ⟨b,r,hb,hbB,rfl⟩ +lemma one_mem_stripSpan {B : ℝ} (hB : 0 ≤ B) : (fun _ : ℝ=>1) ∈ stripKernelSpan B := by + have he : cosineKernelJet 0 0 0=(fun _ : ℝ=>1) := by + funext x + simpa [nodalOrder] using jet_first_constant (fun _ : ℕ=>0) rfl x + rw [←he] + exact kernel_mem_stripSpan le_rfl hB 0 +lemma zeroJet_mem_stripSpan {B : ℝ} (b : ℕ → ℝ) (j : ℕ) (hB : 0 ≤ B) + (hb : 0 ≤ b (j+1)) (hbB : b (j+1) ≤ B) : zeroJet b j ∈ stripKernelSpan B := by + have h0 := (stripKernelSpan B).smul_mem (cosineKernelJet (nodalOrder b (j+1)) 0 (b (j+1)) 0) (one_mem_stripSpan hB) + have h:= (stripKernelSpan B).sub_mem (kernel_mem_stripSpan hb hbB (nodalOrder b (j+1))) h0 + have he : zeroJet b j = cosineKernelJet (nodalOrder b (j+1)) 0 (b (j+1)) - + cosineKernelJet (nodalOrder b (j+1)) 0 (b (j+1)) 0 • (fun _ : ℝ=>1) := by + funext x + simp [zeroJet] + rw [he] + exact h +lemma stripSpan_continuous {B : ℝ} {f : ℝ → ℝ} (hf : f ∈ stripKernelSpan B) : Continuous f := by + induction hf using Submodule.span_induction with + | mem f hf => obtain ⟨b,r,_,_,rfl⟩ := hf;exact (cosineKernelJet_contDiff_right r 0 b 0).continuous + | zero => exact continuous_const + | add f g _ _ hf hg => exact hf.add hg + | smul c f _ hf => exact hf.const_smul c +lemma stripSpan_pair_integrable {z : ℝ} (hz : 0p^k*f (p^2)*g (p^2)*poleAdjustedDensity z p) (Set.Ioi 0) := by + induction hf using Submodule.span_induction with + | mem f hf => + obtain ⟨b,r,hb,hbB,rfl⟩ := hf + induction hg using Submodule.span_induction with + | mem g hg => + obtain ⟨c,s,hc,hcB,rfl⟩ := hg + exact pole_adjusted_pair_moment_integrable hb hc hbB hcB hz r s k + | zero => simp + | add g h _ _ hg hh => + apply (hg.add hh).congr + filter_upwards with p + simp only [Pi.add_apply] + ring + | smul a g _ hg => + have he : (fun p=>p^k*cosineKernelJet r 0 b (p^2)*(a • g) (p^2)*poleAdjustedDensity z p)= + fun p=>a*(p^k*cosineKernelJet r 0 b (p^2)*g (p^2)*poleAdjustedDensity z p) := by + funext p;simp only [Pi.smul_apply,smul_eq_mul];ring + rw [he] + exact hg.const_mul a + | zero => simp + | add f h _ _ hf hh => + apply (hf.add hh).congr + filter_upwards with p + simp only [Pi.add_apply] + ring + | smul a f _ hf => + have he : (fun p=>p^k*(a • f) (p^2)*g (p^2)*poleAdjustedDensity z p)= + fun p=>a*(p^k*f (p^2)*g (p^2)*poleAdjustedDensity z p) := by + funext p;simp only [Pi.smul_apply,smul_eq_mul];ring + rw [he] + exact hf.const_mul a +lemma secondLeft_mem (m N j : ℕ) : secondLeftFlag m N j ∈ stripKernelSpan ((3*angle/2)^2) := by + unfold secondLeftFlag appendTwo + split_ifs + · apply zeroJet_mem_stripSpan _ _ (sq_nonneg _) (twoKnot_nonneg N _) + have h:=twoKnot_le N (j+1) + nlinarith [strip_angle_pos] + · apply zeroJet_mem_stripSpan _ _ (sq_nonneg _) (interiorKnot_nonneg N _ _) + have h:=interiorKnot_le N (N-1+1) (half_pos strip_angle_pos) (by linarith [strip_angle_pos]) + nlinarith [strip_angle_pos] + · exact zeroJet_mem_stripSpan _ _ (sq_nonneg _) (extendedKnot_nonneg N _) (extendedKnot_bound N _) +lemma secondRight_mem (m N j : ℕ) {t : ℝ} (ht : 0F (σ i)) x).det=permutationFactor σ*(evaluationMatrix F x).det := by + have he : evaluationMatrix (fun i=>F (σ i)) x=(evaluationMatrix F x).submatrix σ id := by ext;rfl + rw [he,Matrix.det_permute] + rfl +lemma evaluation_append_perm_factor {n : ℕ} (u : Fin n → ℝ → ℝ) (a : ℝ → ℝ) (σ : Equiv.Perm (Fin n)) (x : Fin (n+1) → ℝ) : + (evaluationMatrix (Fin.lastCases a (fun i=>u (σ i))) x).det= + permutationFactor (liftLastPerm σ)*(evaluationMatrix (Fin.lastCases a u) x).det := by + have he : Fin.lastCases a (fun i=>u (σ i))=(fun i=>(Fin.lastCases a u : Fin (n+1) → ℝ → ℝ) (liftLastPerm σ i)) := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [liftLastPerm_last] + · simp [liftLastPerm_castSucc] + rw [he,evaluation_perm_factor] +lemma evaluation_prepend_perm_factor {n : ℕ} (u : Fin n → ℝ → ℝ) (a : ℝ → ℝ) (σ : Equiv.Perm (Fin n)) (x : Fin (n+1) → ℝ) : + (evaluationMatrix (Fin.cons a (fun i=>u (σ i))) x).det= + permutationFactor (liftFirstPerm σ)*(evaluationMatrix (Fin.cons a u) x).det := by + have he : Fin.cons a (fun i=>u (σ i))=(fun i=>(Fin.cons a u : Fin (n+1) → ℝ → ℝ) (liftFirstPerm σ i)) := by + funext i + refine Fin.cases ?_ (fun i=>?_) i + · simp [liftFirstPerm_zero] + · simp [liftFirstPerm_succ] + rw [he,evaluation_perm_factor] +lemma constant_to_penultimate_factor {n : ℕ} (u : Fin n → ℝ → ℝ) (a b : ℝ → ℝ) (x : Fin (n+2) → ℝ) : + (evaluationMatrix (Fin.lastCases b (Fin.lastCases a u)) x).det= + permutationFactor (liftLastPerm (moveLast n 0))*(evaluationMatrix (Fin.cons a (Fin.lastCases b u)) x).det := by + rw [cons_lastCases_swap] + have he : Fin.lastCases a u=(fun i=>(Fin.cons a u : Fin (n+1) → ℝ → ℝ) (moveLast n 0 i)) := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [moveLast_last] + · simp [moveLast_castSucc] + rw [he,evaluation_append_perm_factor] +lemma familyGram_evaluation_factors {n : ℕ} (F G F' G' : Fin n → ℝ → ℝ) (w : ℝ → ℝ) (a b : ℝ) + (hF : ∀ x,(evaluationMatrix F' x).det=a*(evaluationMatrix F x).det) + (hG : ∀ x,(evaluationMatrix G' x).det=b*(evaluationMatrix G x).det) + (hi : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hi' : ∀ i j,IntegrableOn (fun p=>F' i (p^2)*G' j (p^2)*w p) (Set.Ioi 0)) : + (familyGram w F' G').det=(a*b)*(familyGram w F G).det := by + have h:= (family_gram_andreief w F G hi).2 + have h':= (family_gram_andreief w F' G' hi').2 + have he : familyPointDensity w F' G'=(fun p=>(a*b)*familyPointDensity w F G p) := by + funext p + dsimp [familyPointDensity] + rw [hF,hG] + ring + rw [he,integral_const_mul,h] at h' + have hc : (Fintype.card (Perm (Fin n)):ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + apply mul_left_cancel₀ hc + rw [←h'] + ring +lemma stripSpan_pair_pencil_integrable {z : ℝ} (hz : 0f (p^2)*g (p^2)*((p^2-r)*poleAdjustedDensity z p)) (Set.Ioi 0) := by + have h0 := stripSpan_pair_integrable hz 0 hf hg + have h2 := stripSpan_pair_integrable hz 2 hf hg + apply (h2.sub (h0.const_mul r)).congr + filter_upwards with p + simp only [Pi.sub_apply,pow_zero,one_mul] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv MeasureTheory +noncomputable def secondLeftFactor {m N : ℕ} (hm : m+1=2*N) : ℝ := + permutationFactor (liftLastPerm (moveLast m (zeroInsertion hm))) +noncomputable def secondRightFactor {m N : ℕ} (hm : m+1=2*N) : ℝ := + permutationFactor (liftLastPerm (moveLast m 0))*permutationFactor (liftFirstPerm (moveLast m (zeroInsertion hm))) +lemma secondLeftFactor_ne_zero {m N : ℕ} (hm : m+1=2*N) : secondLeftFactor hm ≠ 0 := + permutationFactor_ne_zero _ +lemma secondRightFactor_ne_zero {m N : ℕ} (hm : m+1=2*N) : secondRightFactor hm ≠ 0 := + mul_ne_zero (permutationFactor_ne_zero _) (permutationFactor_ne_zero _) +lemma secondLeft_evaluation_factor {m N : ℕ} (hm : m+1=2*N) (hN : 0secondLeftFlag m N i) x).det= + secondLeftFactor hm*(evaluationMatrix (fun i : Fin (m+2)=>zeroJet (extendedKnotLabels N) i) x).det := by + unfold secondLeftFlag + rw [appendTwo_top,←zero_insertion_reorder hm hN (half_pos strip_angle_pos) (by linarith [strip_angle_pos]), + evaluation_append_perm_factor (fun i : Fin (m+1)=>zeroJet (interiorKnotLabels N (angle/2)) i) + (zeroJet (extendedKnotLabels N) (m+1)) (moveLast m (zeroInsertion hm)),←zero_extended_split hm] + rfl +lemma secondRight_evaluation_factor {m N : ℕ} (hm : m+1=2*N) (hN : 0secondRightFlag m N t i) x).det= + secondRightFactor hm*(evaluationMatrix (fun i : Fin (m+2)=>cosineKernelJet + (nodalOrder (interiorKnotLabels N t) i) 0 (interiorKnotLabels N t i)) x).det := by + unfold secondRightFlag + rw [appendTwo_top,constant_to_penultimate_factor, + ←zero_insertion_reorder hm hN ht htL, + evaluation_prepend_perm_factor (fun i : Fin (m+1)=>zeroJet (interiorKnotLabels N t) i) + (fun _=>1) (moveLast m (zeroInsertion hm)), + cons_zeroJet_det _ (interiorKnot_first N hN t)] + simp only [secondRightFactor,mul_assoc] + rfl +lemma extendedZero_mem (N j : ℕ) : zeroJet (extendedKnotLabels N) j ∈ stripKernelSpan ((3*angle/2)^2) := + zeroJet_mem_stripSpan _ _ (sq_nonneg _) (extendedKnot_nonneg N _) (extendedKnot_bound N _) +lemma interiorRaw_mem (N j : ℕ) {t : ℝ} (ht : 0zeroJet (extendedKnotLabels N) i) + (fun i : Fin (m+2)=>cosineKernelJet (nodalOrder (interiorKnotLabels N t) i) 0 (interiorKnotLabels N t i)) + (fun i : Fin (m+2)=>secondLeftFlag m N i) (fun i : Fin (m+2)=>secondRightFlag m N t i) + (fun p=>(p^2-r)*poleAdjustedDensity z p) (secondLeftFactor hm) (secondRightFactor hm) + (secondLeft_evaluation_factor hm hN) (secondRight_evaluation_factor hm hN ht htL) + (fun i j=>stripSpan_pair_pencil_integrable hz r (extendedZero_mem N i) (interiorRaw_mem N j ht htL)) + (fun i j=>stripSpan_pair_pencil_integrable hz r (secondLeft_mem m N i) (secondRight_mem m N j ht htL)) + have h1 : familyGram (fun p=>(p^2-r)*poleAdjustedDensity z p) + (fun i : Fin (m+2)=>secondLeftFlag m N i) (fun i : Fin (m+2)=>secondRightFlag m N t i)= + flagPencil (m+2) (secondLeftFlag m N) (secondRightFlag m N t) (poleAdjustedDensity z) r := by + ext i j + apply integral_congr_ae + filter_upwards with p + ring + have h2 : familyGram (fun p=>(p^2-r)*poleAdjustedDensity z p) + (fun i : Fin (m+2)=>zeroJet (extendedKnotLabels N) i) + (fun i : Fin (m+2)=>cosineKernelJet (nodalOrder (interiorKnotLabels N t) i) 0 (interiorKnotLabels N t i))= + mixedZeroJetPencil (n:=m+2) (poleAdjustedDensity z) (extendedKnotLabels N) (interiorKnotLabels N t) r := by + ext i j + apply integral_congr_ae + filter_upwards with p + ring + rwa [h1,h2] at h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory +lemma secondChain_bottom_pencil (m N : ℕ) (t r : ℝ) (w : ℝ → ℝ) : + flagPencil m (secondLeftFlag m N) (secondRightFlag m N t) w r= + zeroJetPencil (n:=m) w (twoKnotLabels N) (twoKnotLabels N) r := by + ext i j + dsimp [flagPencil,zeroJetPencil,secondLeftFlag,secondRightFlag] + simp only [appendTwo,i.isLt,j.isLt,ite_true] +lemma secondChain_pencil_ratio {m N : ℕ} (hm : m+1=2*N) (hN : 0secondLeftFlag m N i (p^2)*secondRightFlag m N t j (p^2)*poleAdjustedDensity z p) (Set.Ioi 0) := by + simpa only [pow_zero,one_mul] using stripSpan_pair_integrable hz 0 (secondLeft_mem m N i) (secondRight_mem m N j ht htL) + have h := unorientedPencil_two_steps (secondLeftFlag m N) (secondRightFlag m N t) (poleAdjustedDensity z) + (secondLeft_nonvanishing hm hN) (secondRight_nonvanishing hm hN ht htL) + (fun i=>stripSpan_continuous (secondLeft_mem m N i)) (fun i=>stripSpan_continuous (secondRight_mem m N i ht htL)) + (fun _ hp=>poleAdjustedDensity_pos hz hp) hi + (fun i j=>stripSpan_pair_integrable hz 2 (secondLeft_mem m N i) (secondRight_mem m N j ht htL)) + (sq_pos_of_pos hy) (by nlinarith : y^2 interpolant N ρ P (u-angle)+ + interpolant N ρ P (u+angle)-interpolant N ρ P u) 0 = 0) ∧ + (∀ j : ℕ, j < N → + iteratedDeriv j (fun u : ℝ => interpolant N ρ P (u-angle)+ + interpolant N ρ P (u+angle)-interpolant N ρ P u) angle = 0) + +end CriticalHoneycomb.FiniteFunctional + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/JetApproximation.lean b/lean/OAI/Combinatorics/HoneycombChords/JetApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..471a98daab18554ae25e5b8d179c6426f51ba7fe --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/JetApproximation.lean @@ -0,0 +1,892 @@ +import OAI.Combinatorics.HoneycombChords.FourierApproximation +import OAI.Combinatorics.HoneycombChords.StripProducts + +namespace OAI + +/-! +# Polynomial approximation of complete strip jets + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +/- Necessary coefficient estimate for the actual two-jet polynomial +approximation in UniformMarked, strip-asymptotics.tex:85--86. -/ +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Polynomial +lemma integerGapProduct (n : ℕ) (i : Fin (n+1)) : + (∏ j : Fin (n+1),if j=i then (1:ℝ) else |(i:ℝ)-(j:ℝ)|)= + (Nat.factorial i.val:ℝ)*(Nat.factorial (n-i.val):ℝ) := by + induction n with + | zero => fin_cases i;simp + | succ n ih => + refine Fin.lastCases ?_ (fun i=>?_) i + · rw [Fin.prod_univ_castSucc] + simp only [Fin.val_last,ite_true,Fin.castSucc_ne_last,ite_false,Fin.val_castSucc,mul_one] + have he : (∏ j : Fin (n+1),|((n+1:ℕ):ℝ)-(j:ℝ)|)=((n+1).factorial:ℝ) := by + rw [Fin.prod_univ_eq_prod_range (fun j : ℕ=>|((n+1:ℕ):ℝ)-(j:ℝ)|)] + rw [show (∏ j∈range (n+1),|((n+1:ℕ):ℝ)-(j:ℝ)|)=∏ j∈range (n+1),(((n+1)-j:ℕ):ℝ) from by + apply prod_congr rfl + intro j hj + have hj' : j ≤ n+1 := (mem_range.mp hj).le + rw [Nat.cast_sub hj',abs_of_nonneg (sub_nonneg.mpr (by exact_mod_cast hj'))]] + exact_mod_cast (Nat.descFactorial_eq_prod_range (n+1) (n+1)).symm.trans (Nat.descFactorial_self (n+1)) + rw [he] + simp + · rw [Fin.prod_univ_castSucc] + simp only [Fin.castSucc_inj,Fin.val_castSucc,Ne.symm (Fin.castSucc_ne_last i),ite_false,Fin.val_last,ih i] + have hi : i.val ≤ n := by omega + have habs : |(i:ℝ)-((n+1:ℕ):ℝ)|=((n+1-i.val:ℕ):ℝ) := by + rw [abs_of_nonpos (sub_nonpos.mpr (by exact_mod_cast (show i.val ≤ n+1 by omega))),Nat.cast_sub (by omega)] + ring + rw [habs,show n+1-i.val=(n-i.val)+1 by omega,Nat.factorial_succ,Nat.cast_mul,Nat.cast_add,Nat.cast_one] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Polynomial +lemma integerGapProduct_erase (n : ℕ) (i : Fin (n+1)) : + (∏ j∈(univ.erase i),|(i:ℝ)-(j:ℝ)|)=(Nat.factorial i.val:ℝ)*(Nat.factorial (n-i.val):ℝ) := by + rw [←integerGapProduct n i] + rw [←prod_erase_mul (s:=univ) (f:=fun j : Fin (n+1)=>if j=i then (1:ℝ) else |(i:ℝ)-(j:ℝ)|) (mem_univ i)] + simp only [ite_true,mul_one] + apply prod_congr rfl + intro j hj + simp only [(mem_erase.mp hj).1,ite_false] +lemma integer_lagrange_basis_bound (n : ℕ) (a x : ℝ) (ha : 0 ≤ a) (hx : a+(n:ℝ) ≤ x) (i : Fin (n+1)) : + |(Lagrange.basis univ (fun j : Fin (n+1)=>a+(j:ℝ)) i).eval x| ≤ + x^n/((Nat.factorial i.val:ℝ)*(Nat.factorial (n-i.val):ℝ)) := by + have hx0 : 0 ≤ x := le_trans (by positivity) hx + have he : |(Lagrange.basis univ (fun j : Fin (n+1)=>a+(j:ℝ)) i).eval x|= + (∏ j∈univ.erase i,|x-(a+(j:ℝ))|)/(∏ j∈univ.erase i,|(i:ℝ)-(j:ℝ)|) := by + simp only [Lagrange.basis,eval_prod,Lagrange.basisDivisor,eval_mul,eval_C,eval_sub,eval_X, + abs_prod,abs_mul,abs_inv] + simp_rw [show ∀ j : Fin (n+1),a+(i:ℝ)-(a+(j:ℝ))=(i:ℝ)-(j:ℝ) from fun _=>by ring] + rw [prod_mul_distrib,prod_inv_distrib] + ring + rw [he,integerGapProduct_erase] + apply div_le_div_of_nonneg_right _ (by positivity) + calc + _ ≤ ∏ j∈(univ.erase i),x := by + apply prod_le_prod₀ (fun _ _=>abs_nonneg _) + intro j hj + have hjn : (j:ℝ) ≤ n := by exact_mod_cast (show j.val ≤ n by omega) + rw [abs_of_nonneg (by linarith)] + linarith [show (0:ℝ) ≤ (j:ℝ) by positivity] + _ = x^n := by simp +lemma integer_polynomial_bound (n : ℕ) (a x B : ℝ) (ha : 0 ≤ a) (hx : a+(n:ℝ) ≤ x) (hB : 0 ≤ B) + (P : Polynomial ℝ) (hP : P.natDegree ≤ n) (hvalues : ∀ i : Fin (n+1),|P.eval (a+(i:ℝ))| ≤ B) : + |P.eval x| ≤ B*(2*x)^n/(Nat.factorial n:ℝ) := by + have hinj : Set.InjOn (fun j : Fin (n+1)=>a+(j:ℝ)) (↑(univ : Finset (Fin (n+1)))) := by + intro i _ j _ hij + apply Fin.ext + exact_mod_cast add_left_cancel hij + have hdeg : P.degree < ((univ : Finset (Fin (n+1))).card:WithBot ℕ) := by + simp only [card_univ,Fintype.card_fin] + exact lt_of_le_of_lt Polynomial.degree_le_natDegree (by exact_mod_cast (show P.natDegreeQ.eval x) he + simp only [Lagrange.interpolate,LinearMap.coe_mk,AddHom.coe_mk,eval_finsetSum,eval_mul,eval_C] at he' + rw [he'] + calc + _ ≤ ∑ i : Fin (n+1),|P.eval (a+(i:ℝ))| *|(Lagrange.basis univ (fun j : Fin (n+1)=>a+(j:ℝ)) i).eval x| := by + simpa only [abs_mul] using abs_sum_le_sum_abs (fun i : Fin (n+1)=>P.eval (a+(i:ℝ))*(Lagrange.basis univ (fun j : Fin (n+1)=>a+(j:ℝ)) i).eval x) univ + _ ≤ ∑ i : Fin (n+1),B*(x^n/((Nat.factorial i.val:ℝ)*(Nat.factorial (n-i.val):ℝ))) := by + apply sum_le_sum + intro i _ + exact mul_le_mul (hvalues i) (integer_lagrange_basis_bound n a x ha hx i) (abs_nonneg _) hB + _ = B*(2*x)^n/(Nat.factorial n:ℝ) := by + have hb (i : Fin (n+1)) : B*(x^n/((Nat.factorial i.val:ℝ)*(Nat.factorial (n-i.val):ℝ)))= + (B*x^n/(Nat.factorial n:ℝ))*(Nat.choose n i.val:ℝ) := by + have h := Nat.choose_mul_factorial_mul_factorial (show i.val ≤ n by omega) + have hf : (Nat.choose n i.val:ℝ)*(Nat.factorial i.val:ℝ)*(Nat.factorial (n-i.val):ℝ)=(Nat.factorial n:ℝ) := by exact_mod_cast h + field_simp + linear_combination -B*x^n*hf + simp_rw [hb] + rw [←mul_sum,Fin.sum_univ_eq_sum_range (fun i : ℕ => (Nat.choose n i:ℝ))] + have hs : (∑ i∈range (n+1),(Nat.choose n i:ℝ))=(2:ℝ)^n := by exact_mod_cast Nat.sum_range_choose n + rw [hs,mul_pow] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Polynomial +/-- Quantitative Lagrange bound, with an arbitrarily small exponential instead +of a Stirling asymptotic. Used on the literal q^j p(j) Pollaczek tails. -/ +lemma integer_polynomial_exponential_bound (n : ℕ) (a x B α : ℝ) + (ha : 0 ≤ a) (hx : a+(n:ℝ) ≤ x) (hB : 0 ≤ B) (hα : 0<α) + (P : Polynomial ℝ) (hP : P.natDegree ≤ n) + (hvalues : ∀ i : Fin (n+1),|P.eval (a+(i:ℝ))| ≤ B) : + |P.eval x| ≤ B*(2/α)^n*Real.exp (α*x) := by + refine (integer_polynomial_bound n a x B ha hx hB P hP hvalues).trans ?_ + have hx0 : 0 ≤ x := le_trans (by positivity) hx + calc + B*(2*x)^n/(Nat.factorial n:ℝ)=B*(2/α)^n*((α*x)^n/(Nat.factorial n:ℝ)) := by + rw [mul_pow,mul_pow,div_pow] + field_simp + _ ≤ _ := mul_le_mul_of_nonneg_left (Real.pow_div_factorial_le_exp _ (mul_nonneg hα.le hx0) n) (by positivity) +lemma exp_power_bound (A γ : ℝ) (hA : 1 ≤ A) (hγ : 0<γ) (n j : ℕ) + (hnj : (4*(2*γ+Real.log A)/γ)*(n:ℝ) ≤ j) : + Real.exp (-γ*(j:ℝ))*Real.exp (2*γ*(n:ℝ))*A^n*Real.exp (γ/4*(j:ℝ)) ≤ + Real.exp (-γ/2*(j:ℝ)) := by + have hA0 : 0by simpa only [hn,Fin.val_cast] using hvalues (Fin.cast hn i)) + have hr : (2/(γ/4))^(N-1) ≤ A^N := by + apply (pow_le_pow_left₀ (by positivity) (show 2/(γ/4) ≤ A by rw [show 2/(γ/4)=8/γ by ring];exact le_max_right _ _) _).trans + exact pow_le_pow_right₀ hA (Nat.sub_le _ _) + have hqj : q^j=Real.exp (-γ*(j:ℝ)) := by + rw [show -γ*(j:ℝ)=(j:ℝ)*Real.log q by dsimp [γ];ring,Real.exp_nat_mul,Real.exp_log hq0] + have hqN : (q^(2*N))⁻¹=Real.exp (2*γ*(N:ℝ)) := by + rw [show 2*γ*(N:ℝ)=-((2*N:ℕ):ℝ)*Real.log q by dsimp [γ];push_cast;ring, + neg_mul,Real.exp_neg,Real.exp_nat_mul,Real.exp_log hq0] + rw [abs_mul,abs_of_pos (pow_pos hq0 _),hqj] + calc + _ ≤ Real.exp (-γ*(j:ℝ))*(((q^(2*N))⁻¹)*(2/(γ/4))^(N-1)*Real.exp (γ/4*(j:ℝ))) := + mul_le_mul_of_nonneg_left hbound (by positivity) + _ ≤ Real.exp (-γ*(j:ℝ))*(((q^(2*N))⁻¹)*A^N*Real.exp (γ/4*(j:ℝ))) := by gcongr + _ = Real.exp (-γ*(j:ℝ))*Real.exp (2*γ*(N:ℝ))*A^N*Real.exp (γ/4*(j:ℝ)) := by rw [hqN];ring + _ ≤ _ := by + simpa only [neg_div] using exp_power_bound A γ hA hγ N j + (le_trans (mul_le_mul_of_nonneg_right (le_max_right _ _) (by positivity)) hj) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter Topology +/-- The uniform coefficient decay asserted in the approximation paragraph, +for the literal complete zero/L² jet space and the explicit sech weight. -/ +lemma completeJetSech_exponential_coefficients {u : ℝ} (hu : |u|<1) (hu0 : u≠0) : + ∃ D γ : ℝ,0pollaczekCoeff p (2*j)) (completeJetCombination N ((2*Real.arctan u)^2) a c)|≤ + Real.exp (-γ*(j:ℝ)) := by + let q:=u^2 + have hq0:0hf (2*j)) hnorm (N+i) + dsimp [f] at hc + rw [hcoef (N+i) (by omega),abs_mul,abs_of_pos (pow_pos hq0 _)] at hc + have hp : q^(2*N)≤q^(N+(i:ℕ)) := pow_le_pow_of_le_one hq0.le hq1.le (by have:=i.isLt;omega) + have htmp:=mul_le_mul_of_nonneg_right hp (abs_nonneg (P.eval ((N+i:ℕ):ℝ))) + have hconc: q^(2*N)*|P.eval ((N+i:ℕ):ℝ)|≤1:=htmp.trans hc + rw [←one_div] + apply (le_div_iff₀ (pow_pos hq0 _)).mpr + simpa only [Nat.cast_add,mul_comm] using hconc + have hNj:N≤j := by + have hh:=le_trans (mul_le_mul_of_nonneg_right (le_max_left 1 D) (by positivity : 0≤(N:ℝ))) hj + simp only [one_mul] at hh + exact_mod_cast hh + rw [hcoef j hNj] + exact hdecay N hN P hP hsample j + ((mul_le_mul_of_nonneg_right (le_max_right 1 D) (by positivity)).trans hj) +lemma completeJetSech_projection_approximation {u : ℝ} (hu : |u|<1) (hu0 : u≠0) : + ∃ D γ : ℝ,0f p-evenPollaczekFinite K (fun j=>symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f) p) + (fun p=>f p-evenPollaczekFinite K (fun j=>symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f) p) ≤ + Real.exp (-2*γ*(K:ℝ))/(1-Real.exp (-2*γ)) := by + obtain ⟨D,γ,hD,hγ,hc⟩:=completeJetSech_exponential_coefficients hu hu0 + obtain ⟨δ,hd,hlim⟩:=arctan_label_margin hu + refine ⟨D,γ,hD,hγ,?_⟩ + intro N hN a c hnorm K hK + apply evenProjection_exponential_error _ + (completeJetSech_norm_integrable (sq_nonneg _) hd hlim N a c) + (fun j=>completeJetSech_pair_integrable (sq_nonneg _) hd hlim N a c (2*j)) + (completeJetSech_parseval_residual (sq_nonneg _) hd hlim N a c) hγ K + intro j hj + exact hc N hN a c hnorm j (hK.trans (by exact_mod_cast hj)) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter Topology +lemma cosineKernelJet_scale_right (r : ℕ) (b d x : ℝ) : + cosineKernelJet r 0 b (d*x)=d^r*cosineKernelJet r 0 (d*b) x := by + unfold cosineKernelJet + rw [←tsum_mul_left] + apply tsum_congr + intro k + simp only [kernelJetTerm,polynomialJet_X_pow,Nat.choose_zero_right,Nat.cast_one,one_mul,Nat.sub_zero,mul_pow] + by_cases hr:r≤k + · have he:d^r*d^(k-r)=d^k:=by rw [←pow_add,Nat.add_sub_of_le hr] + calc + _ = ((k.choose r:ℕ):ℝ)*b^(k-r)*(d^r*d^(k-r))*x^k/(2*k).factorial := by rw [he];ring + _ = _ := by ring + · simp only [Nat.choose_eq_zero_of_lt (by omega : ka i*(s^2)^(i:ℕ)) (fun i=>c i*(s^2)^(i:ℕ)) p := by + unfold completeJetCombination + simp only [mul_pow,cosineKernelJet_scale_right,mul_zero] + congr 1 <;> apply sum_congr rfl <;> intro i _ <;> ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset +lemma twoJetCombination_split (N:ℕ) (a:Fin (2*N)→ℝ) : + ∃ b c:Fin N→ℝ,∀ p:ℝ,twoJetCombination N a (p^2)=completeJetCombination N (angle^2) b c p := by + have hn:2*N=N+N:=by omega + let v:Fin (N+N)→ℝ:=fun i=>a (Fin.cast hn.symm i) + refine ⟨fun i=>v (Fin.castAdd N i),fun i=>v (Fin.natAdd N i),?_⟩ + intro p + have hsum:twoJetCombination N a (p^2)= + ∑ i:Fin (N+N),v i*cosineKernelJet (nodalOrder (twoKnotLabels N) i) 0 (twoKnotLabels N i) (p^2) := by + unfold twoJetCombination + exact Fintype.sum_equiv (finCongr hn) _ _ (fun i=>by simp [v]) + rw [hsum,Fin.sum_univ_add] + unfold completeJetCombination + congr 1 + · apply sum_congr rfl + intro i _ + simp only [Fin.val_castAdd,twoKnot_nodalOrder,twoKnotLabels,ite_eq_left i.isLt] + · apply sum_congr rfl + intro i _ + simp only [Fin.val_natAdd,twoKnot_nodalOrder,twoKnotLabels,show ¬N+(i:ℕ) simp + | succ K ih => + rw [Fin.sum_univ_castSucc] + simp only [Fin.val_castSucc,Fin.val_last] + calc + (∑ j:Fin K,r^(j:ℕ))+r^K ≤ r^K+r^K := by linarith + _ ≤ r^K*r := by nlinarith [pow_nonneg (by linarith : 0≤r) K] + _ = r^(K+1) := (pow_succ _ _).symm + +lemma evenFinite_pointwise_bound (K : ℕ) (a : Fin K→ℝ) (ha : ∑ j,(a j)^2≤1) (p : ℝ) : + (evenPollaczekFinite K a p)^2≤ + ((1-(1/4:ℝ)^2)^(-(1:ℝ)/2))^2*256^K*Real.exp (4*Real.artanh (1/4)*|p|) := by + let C:ℝ:=(1-(1/4:ℝ)^2)^(-(1:ℝ)/2) + have hC:0pollaczekCoeff p (2*j)) + change (evenPollaczekFinite K a p)^2≤(∑ j,(a j)^2)*(∑ j:Fin K,(pollaczekCoeff p (2*j))^2) at hs + calc + _ ≤ (∑ j,(a j)^2)*(∑ j:Fin K,(pollaczekCoeff p (2*j))^2) := hs + _ ≤ ∑ j:Fin K,(pollaczekCoeff p (2*j))^2 := by + simpa using mul_le_mul_of_nonneg_right ha (sum_nonneg (fun j _=>sq_nonneg _)) + _ ≤ ∑ j:Fin K,C^2*256^(j:ℕ)*Real.exp (4*Real.artanh (1/4)*|p|) := sum_le_sum (fun j _=>hQ j) + _ = C^2*(∑ j:Fin K,(256:ℝ)^(j:ℕ))*Real.exp (4*Real.artanh (1/4)*|p|) := by rw [←sum_mul,←mul_sum] + _ ≤ _ := by gcongr;exact sum_fin_geometric_le (by norm_num) K +lemma evenFinite_spatial_tail (K : ℕ) (a : Fin K→ℝ) (ha : ∑ j,(a j)^2≤1) {R : ℝ} (hR : 0≤R) : + (∫ p in Set.Ioi R,sechPairIntegrand (evenPollaczekFinite K a) (evenPollaczekFinite K a) p) ≤ + (4*((1-(1/4:ℝ)^2)^(-(1:ℝ)/2))^2*256^K)* + (Real.exp ((4*Real.artanh (1/4)-Real.pi)*R)/(Real.pi-4*Real.artanh (1/4))) := by + let C:ℝ:=(1-(1/4:ℝ)^2)^(-(1:ℝ)/2) + let d:ℝ:=4*Real.artanh (1/4)-Real.pi + have hd:d<0:=by dsimp [d];linarith [quarter_artanh_bounds.2] + have hi:IntegrableOn (fun p=>(4*C^2*256^K)*Real.exp (d*p)) (Set.Ioi R):= + (integrableOn_exp_mul_Ioi hd R).const_mul _ + have hleft:= (evenFinite_square_integrable K a).mono_set (Set.Ioi_subset_Ioi hR) + calc + _ ≤ ∫ p in Set.Ioi R,(4*C^2*256^K)*Real.exp (d*p) := by + apply integral_mono_ae hleft hi + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hp0:0≤p:=hR.trans hp.le + have h1:=evenFinite_pointwise_bound K a ha p + have h2:=evenFinite_pointwise_bound K a ha (-p) + simp only [abs_neg,abs_of_nonneg hp0] at h1 h2 + have hc:Real.exp (Real.pi*p)/2≤Real.cosh (Real.pi*p):=by + rw [Real.cosh_eq];linarith [Real.exp_pos (-(Real.pi*p))] + unfold sechPairIntegrand + calc + _ ≤ (2*C^2*256^K*Real.exp (4*Real.artanh (1/4)*p))/Real.cosh (Real.pi*p) := by + apply div_le_div_of_nonneg_right _ (Real.cosh_pos _).le + dsimp [C] at * + nlinarith + _ ≤ (2*C^2*256^K*Real.exp (4*Real.artanh (1/4)*p))/(Real.exp (Real.pi*p)/2) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hc + _ = _ := by dsimp [d];rw [sub_mul,Real.exp_sub];ring + _ = _ := by + rw [integral_const_mul,integral_exp_mul_Ioi hd] + dsimp [C,d] + rw [show Real.pi-4*Real.artanh (1/4)=-(4*Real.artanh (1/4)-Real.pi) by ring,div_neg] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory +lemma sechPairIntegrand_self_nonneg (f : ℝ→ℝ) (p:ℝ) : 0≤ sechPairIntegrand f f p := by + unfold sechPairIntegrand + exact div_nonneg (add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)) (Real.cosh_pos _).le +lemma sechPair_difference_integrable (f g:ℝ→ℝ) + (hf:IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hg:IntegrableOn (sechPairIntegrand g g) (Set.Ioi 0)) + (hfg:IntegrableOn (sechPairIntegrand f g) (Set.Ioi 0)) : + IntegrableOn (sechPairIntegrand (fun p=>f p-g p) (fun p=>f p-g p)) (Set.Ioi 0) := by + have he:sechPairIntegrand (fun p=>f p-g p) (fun p=>f p-g p)= + fun p=>sechPairIntegrand f f p-2*sechPairIntegrand f g p+sechPairIntegrand g g p := by + funext p;unfold sechPairIntegrand;ring + rw [he] + exact (hf.sub (hfg.const_mul 2)).add hg +lemma sech_local_mass (f g:ℝ→ℝ) + (hf:IntegrableOn (sechPairIntegrand f f) (Set.Ioi 0)) + (hg:IntegrableOn (sechPairIntegrand g g) (Set.Ioi 0)) + (hfg:IntegrableOn (sechPairIntegrand f g) (Set.Ioi 0)) + (hn:symmetricSechPair f f=1) {R:ℝ} (hR:0≤R) + (he:symmetricSechPair (fun p=>f p-g p) (fun p=>f p-g p)≤1/8) + (ht:(∫ p in Set.Ioi R,sechPairIntegrand g g p)≤1/8) : + 1/2≤∫ p in Set.Ioc 0 R,sechPairIntegrand f f p := by + have hd:=sechPair_difference_integrable f g hf hg hfg + have hsub:Set.Ioi R⊆Set.Ioi (0:ℝ):=Set.Ioi_subset_Ioi hR + have hdtail:(∫ p in Set.Ioi R,sechPairIntegrand (fun p=>f p-g p) (fun p=>f p-g p) p)≤ + symmetricSechPair (fun p=>f p-g p) (fun p=>f p-g p) := by + apply setIntegral_mono_set hd + · exact Filter.Eventually.of_forall (sechPairIntegrand_self_nonneg _) + · exact Filter.Eventually.of_forall hsub + have htail:(∫ p in Set.Ioi R,sechPairIntegrand f f p)≤1/2 := by + calc + _ ≤ ∫ p in Set.Ioi R,2*sechPairIntegrand (fun p=>f p-g p) (fun p=>f p-g p) p+2*sechPairIntegrand g g p := by + apply integral_mono_ae (hf.mono_set hsub) (((hd.mono_set hsub).const_mul 2).add ((hg.mono_set hsub).const_mul 2)) + filter_upwards with p + change (f p*f p+f (-p)*f (-p))/Real.cosh (Real.pi*p) ≤ + 2*(((f p-g p)*(f p-g p)+(f (-p)-g (-p))*(f (-p)-g (-p)))/Real.cosh (Real.pi*p))+ + 2*((g p*g p+g (-p)*g (-p))/Real.cosh (Real.pi*p)) + have hc:=Real.cosh_pos (Real.pi*p) + rw [←mul_div_assoc,←mul_div_assoc,←add_div] + apply (div_le_div_iff_of_pos_right hc).mpr + nlinarith [sq_nonneg (f p-2*g p),sq_nonneg (f (-p)-2*g (-p))] + _ = 2*(∫ p in Set.Ioi R,sechPairIntegrand (fun p=>f p-g p) (fun p=>f p-g p) p)+2*(∫ p in Set.Ioi R,sechPairIntegrand g g p) := by + rw [integral_add ((hd.mono_set hsub).const_mul _) ((hg.mono_set hsub).const_mul _),integral_const_mul,integral_const_mul] + _ ≤ _ := by linarith + have hsum:(∫ p in Set.Ioc 0 R,sechPairIntegrand f f p)+(∫ p in Set.Ioi R,sechPairIntegrand f f p)=1 := by + rw [←setIntegral_union Set.Ioc_disjoint_Ioi_same measurableSet_Ioi (hf.mono_set Set.Ioc_subset_Ioi_self) (hf.mono_set hsub),Set.Ioc_union_Ioi_eq_Ioi hR] + exact hn + linarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real +lemma exponential_nat_uniform_small {r B:ℝ} (hr:0symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f + let g:=evenPollaczekFinite (J*N) v + obtain ⟨δ,hd,hlim⟩:=arctan_label_margin hu + have hff:=completeJetSech_norm_integrable (sq_nonneg _) hd hlim N a c + have hfp:=completeJetSech_pair_integrable (sq_nonneg _) hd hlim N a c + have hcoef : (∑ j:Fin (J*N),(v j)^2)≤1:=by + have hh:=even_projection_bessel (J*N) f hff (fun j=>hfp (2*j)) + change 0≤ symmetricSechPair f f-∑ j:Fin (J*N),(v j)^2 at hh + change symmetricSechPair f f=1 at hnorm + linarith + have herror:symmetricSechPair (fun p=>f p-g p) (fun p=>f p-g p)≤1/8 := by + have hK:D*(N:ℝ)≤((J*N:ℕ):ℝ):=by simpa only [Nat.cast_mul] using mul_le_mul_of_nonneg_right hJD (by positivity : 0≤(N:ℝ)) + have hh:=happ N hN a c hnorm.le (J*N) hK + change symmetricSechPair (fun p=>f p-g p) (fun p=>f p-g p)≤_ at hh + have hhsmall := hsmall N hN + rw [show -(2*γ)= -2*γ by ring] at hhsmall + exact hh.trans (by simpa only [div_eq_mul_inv,mul_comm] using hhsmall) + have htail:(∫ p in Set.Ioi (R*(N:ℝ)),sechPairIntegrand g g p)≤1/8 := by + have hh:=evenFinite_spatial_tail (J*N) v hcoef (R:=R*(N:ℝ)) (by positivity) + change (∫ p in Set.Ioi (R*(N:ℝ)),sechPairIntegrand g g p)≤_ at hh + convert hh.trans (le_of_eq_of_le (by dsimp [lam]; rw [show (4*Real.artanh (1/4)-Real.pi)*(R*(N:ℝ))=-(Real.pi-4*Real.artanh (1/4))*(R*(N:ℝ)) by ring]; ring : (4*C^2*256^(J*N))*(Real.exp ((4*Real.artanh (1/4)-Real.pi)*(R*(N:ℝ)))/lam)= + (4*C^2/lam)*256^(J*N)*Real.exp (-lam*(R*(N:ℝ)))) (hspatial N hN)) using 1 + exact sech_local_mass f g hff (evenFinite_square_integrable _ v) + (by rw [sechPairIntegrand_comm];exact evenFinite_pair_integrable _ v f (fun j=>hfp (2*j))) hnorm (by positivity) herror htail +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Filter +noncomputable def weightedHalfNorm (w f:ℝ→ℝ):ℝ:=∫ p in Set.Ioi 0,(f p)^2*w p +lemma sechPairIntegrand_even {f:ℝ→ℝ} (he:∀ p,f (-p)=f p) (p:ℝ) : + sechPairIntegrand f f p=2*(f p)^2/Real.cosh (Real.pi*p) := by + unfold sechPairIntegrand;rw [he];ring +lemma weightedHalf_integrable {w f:ℝ→ℝ} {A:ℝ} + (hw:Measurable w) (hf:Measurable f) (he:∀ p,f (-p)=f p) + (hwn:∀ p,0

(f p)^2*w p) (Set.Ioi 0) := by + apply (hff.const_mul (A/2)).mono' ((hf.pow_const 2).mul hw).aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + simp only [Pi.mul_apply] + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (sq_nonneg _) (hwn p hp)),sechPairIntegrand_even he] + calc + _ ≤ (f p)^2*(A/Real.cosh (Real.pi*p)):=mul_le_mul_of_nonneg_left (hwu p hp) (sq_nonneg _) + _ = _ := by ring +lemma weightedHalf_le_sech {w f:ℝ→ℝ} {A:ℝ} + (hw:Measurable w) (hf:Measurable f) (he:∀ p,f (-p)=f p) + (hwn:∀ p,0

(f p)^2*w p) (Set.Ioi 0)) + (hloc:1/2≤∫ p in Set.Ioc 0 R,sechPairIntegrand f f p) : + a/4≤weightedHalfNorm w f := by + have hlocw:(a/2)*(∫ p in Set.Ioc 0 R,sechPairIntegrand f f p)≤∫ p in Set.Ioc 0 R,(f p)^2*w p := by + rw [←integral_const_mul] + apply integral_mono_ae ((hf.mono_set Set.Ioc_subset_Ioi_self).const_mul _) (hfw.mono_set Set.Ioc_subset_Ioi_self) + filter_upwards [ae_restrict_mem measurableSet_Ioc] with p hp + rw [sechPairIntegrand_even he] + calc + _ = (f p)^2*(a/Real.cosh (Real.pi*p)) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left (hwl p hp.1 hp.2) (sq_nonneg _) + have hbig:(∫ p in Set.Ioc 0 R,(f p)^2*w p)≤weightedHalfNorm w f := by + apply setIntegral_mono_set hfw + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact mul_nonneg (sq_nonneg _) (hwn p hp) + · exact Eventually.of_forall Set.Ioc_subset_Ioi_self + have hh:=mul_le_mul_of_nonneg_left hloc (show 0≤a/2 by positivity) + nlinarith +lemma scaledStripDensity_measurable (s:ℝ) : Measurable (scaledStripDensity s) := by + unfold scaledStripDensity stripDensity + fun_prop +lemma scaledStripDensity_pos {s p:ℝ} (hs:0cosineKernelJet r 0 b (p^2)):= + (continuous_iff_continuousAt.mpr (fun x=>(cosineKernelJet_hasDerivAt_right r 0 b x).continuousAt)).comp (continuous_id.pow 2) + unfold completeJetCombination + exact (continuous_finsetSum _ (fun (i:Fin N) _=>(hc (i:ℕ) 0).const_mul (a i))).add + (continuous_finsetSum _ (fun (i:Fin N) _=>(hc (i:ℕ) b).const_mul (c i))) +lemma completeJetCombination_even (N:ℕ) (b:ℝ) (a c:Fin N→ℝ) (p:ℝ) : + completeJetCombination N b a c (-p)=completeJetCombination N b a c p := by + simp only [completeJetCombination,neg_sq] +lemma completeJetCombination_smul (N:ℕ) (b d:ℝ) (a c:Fin N→ℝ) : + completeJetCombination N b (fun i=>d*a i) (fun i=>d*c i)=fun p=>d*completeJetCombination N b a c p := by + funext p + simp only [completeJetCombination,mul_assoc,←mul_sum,←mul_add] +lemma evenFinite_continuous (K:ℕ) (v:Fin K→ℝ):Continuous (evenPollaczekFinite K v) := by + have he:evenPollaczekFinite K v=fun p=>(∑ j,v j • evenPoly (-1) j).eval (p^2):=funext (evenPollaczekFinite_polynomial K v) + rw [he] + exact (∑ j,v j • evenPoly (-1) j).continuous.comp (continuous_id.pow 2) +lemma evenFinite_even (K:ℕ) (v:Fin K→ℝ) (p:ℝ) : evenPollaczekFinite K v (-p)=evenPollaczekFinite K v p := by + rw [evenPollaczekFinite_polynomial,evenPollaczekFinite_polynomial,neg_sq] +lemma evenFinite_polynomial_degree {K:ℕ} (hK:0?_) (Nat.sub_lt hK (by omega : 0<1)) + exact (natDegree_smul_le _ _).trans (by rw [(pollaczek_evenOdd_degree j).1];omega) +lemma symmetricSechPair_smul_both (f:ℝ→ℝ) (d:ℝ) : + symmetricSechPair (fun p=>d*f p) (fun p=>d*f p)=d^2*symmetricSechPair f f := by + rw [symmetricSechPair_smul_left,symmetricSechPair_comm,symmetricSechPair_smul_left,symmetricSechPair_comm] + ring +lemma weightedHalfNorm_smul (w f:ℝ→ℝ) (d:ℝ) : weightedHalfNorm w (fun p=>d*f p)=d^2*weightedHalfNorm w f := by + unfold weightedHalfNorm + rw [←integral_const_mul] + apply integral_congr_ae + filter_upwards with p + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset +lemma normalizedJetWeightedApproximation {u:ℝ} (hu:|u|<1) (hu0:u≠0) + {w:ℝ→ℝ} (hw:Measurable w) (hwn:∀ p,0

completeJetCombination N ((2*Real.arctan u)^2) b c p-P.eval (p^2))≤ + Real.exp (-2*(N:ℝ))*weightedHalfNorm w (completeJetCombination N ((2*Real.arctan u)^2) b c) := by + obtain ⟨R,hR,hconc⟩:=completeJetSech_concentration hu hu0 + obtain ⟨D,γ,hD,hγ,happ⟩:=completeJetSech_projection_approximation hu hu0 + have hden:0<1-Real.exp (-2*γ):=by have:=Real.exp_lt_one_iff.mpr (by linarith : -2*γ<0);linarith + obtain ⟨J,hJ,hJD,hsmall⟩:=exponential_relative_constant (by positivity : 0<2*γ) + (by positivity : 0<(A/2)/(1-Real.exp (-2*γ))) (by positivity : 0symmetricSechPair (fun p=>pollaczekCoeff p (2*j)) f + let P:Polynomial ℝ:=∑ j,v j • evenPoly (-1) j + let g:=evenPollaczekFinite (J*N) v + have hgp (p:ℝ):g p=P.eval (p^2):=evenPollaczekFinite_polynomial _ _ _ + obtain ⟨δ,hd,hlim⟩:=arctan_label_margin hu + have hff:=completeJetSech_norm_integrable (sq_nonneg _) hd hlim N b c + have hfp:=completeJetSech_pair_integrable (sq_nonneg _) hd hlim N b c + have hf:Measurable f:=(completeJetCombination_continuous _ _ _ _).measurable + have hfe:∀ p,f (-p)=f p:=completeJetCombination_even _ _ _ _ + have hfw:=weightedHalf_integrable hw hf hfe hwn hwu hff + have hlow:(a/4)*Real.exp (-β*(R*(N:ℝ)))≤weightedHalfNorm w f := by + have hh:=weightedHalf_lower_local (by positivity : 0hfp (2*j)) + have he:IntegrableOn (sechPairIntegrand (fun p=>f p-g p) (fun p=>f p-g p)) (Set.Ioi 0):= + sechPair_difference_integrable f g hff (evenFinite_square_integrable _ v) hfg + have hupper:=weightedHalf_le_sech hw (hf.sub (evenFinite_continuous _ v).measurable) + (fun p=>by simp only [Pi.sub_apply,hfe,evenFinite_even]) hwn hwu he + have hK:D*(N:ℝ)≤((J*N:ℕ):ℝ):=by simpa only [Nat.cast_mul] using mul_le_mul_of_nonneg_right hJD (by positivity : 0≤(N:ℝ)) + have herr:=happ N hN b c hnorm.le (J*N) hK + change symmetricSechPair (fun p=>f p-g p) (fun p=>f p-g p)≤_ at herr + refine ⟨P,evenFinite_polynomial_degree (Nat.mul_pos hJ hN) v,?_⟩ + change weightedHalfNorm w (fun p=>f p-P.eval (p^2))≤_ + rw [show (fun p=>f p-P.eval (p^2))=(fun p=>f p-g p) from funext (fun p=>by rw [hgp])] + calc + _ ≤ (A/2)*symmetricSechPair (fun p=>f p-g p) (fun p=>f p-g p):=hupper + _ ≤ (A/2)*(Real.exp (-2*γ*((J*N:ℕ):ℝ))/(1-Real.exp (-2*γ))):=mul_le_mul_of_nonneg_left herr (by positivity) + _ = ((A/2)/(1-Real.exp (-2*γ)))*Real.exp (-(2*γ)*((J*N:ℕ):ℝ)) := by rw [show -2*γ=-(2*γ) by ring];ring + _ ≤ (a/4)*Real.exp (-(2+β*R)*(N:ℝ)):=hsmall N hN + _ = Real.exp (-2*(N:ℝ))*((a/4)*Real.exp (-β*(R*(N:ℝ)))):=by + rw [←mul_assoc,mul_comm (Real.exp _) (a/4),mul_assoc,←Real.exp_add] + congr 2;ring + _ ≤ _ := mul_le_mul_of_nonneg_left hlow (Real.exp_pos _).le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial Finset Filter +lemma weightedHalfNorm_nonneg {w:ℝ→ℝ} (hwn:∀ p,0

completeJetCombination N ((2*Real.arctan u)^2) b c p-P.eval (p^2))≤ + Real.exp (-2*(N:ℝ))*weightedHalfNorm w (completeJetCombination N ((2*Real.arctan u)^2) b c) := by + obtain ⟨J,hJ,happ⟩:=normalizedJetWeightedApproximation hu hu0 hw hwn hA ha hwu hwl + obtain ⟨δ,hd,hlim⟩:=arctan_label_margin hu + refine ⟨J,hJ,?_⟩ + intro N hN b c + let f:=completeJetCombination N ((2*Real.arctan u)^2) b c + let S:=symmetricSechPair f f + have hS0:0≤S:=symmetricSechPair_nonneg _ + by_cases hS:S=0 + · have hh:=weightedHalf_le_sech hw (completeJetCombination_continuous _ _ _ _).measurable + (completeJetCombination_even _ _ _ _) hwn hwu + (completeJetSech_norm_integrable (sq_nonneg _) hd hlim N b c) + change weightedHalfNorm w f≤(A/2)*S at hh + rw [hS,mul_zero] at hh + have hnorm0:weightedHalfNorm w f=0:=le_antisymm hh (weightedHalfNorm_nonneg hwn f) + refine ⟨0,by simpa using Nat.mul_pos hJ hN,?_⟩ + simp only [eval_zero,sub_zero] + change weightedHalfNorm w f≤Real.exp (-2*(N:ℝ))*weightedHalfNorm w f + rw [hnorm0,mul_zero] + · have hSpos:0d⁻¹*b i) (fun i=>d⁻¹*c i)) + (completeJetCombination N ((2*Real.arctan u)^2) (fun i=>d⁻¹*b i) (fun i=>d⁻¹*c i))=1 := by + rw [completeJetCombination_smul,symmetricSechPair_smul_both] + change (d⁻¹)^2*S=1 + rw [←hdsq,←mul_pow,inv_mul_cancel₀ hdpos.ne',one_pow] + obtain ⟨P,hP,herr⟩:=happ N hN (fun i=>d⁻¹*b i) (fun i=>d⁻¹*c i) hn + rw [completeJetCombination_smul] at herr + change weightedHalfNorm w (fun p=>d⁻¹*f p-P.eval (p^2))≤Real.exp (-2*(N:ℝ))*weightedHalfNorm w (fun p=>d⁻¹*f p) at herr + refine ⟨d • P,(natDegree_smul_le _ _).trans_lt hP,?_⟩ + have heq:(fun p=>f p-(d • P).eval (p^2))=(fun p=>d*(d⁻¹*f p-P.eval (p^2))):=by + funext p + simp only [eval_smul,smul_eq_mul] + rw [mul_sub,←mul_assoc,mul_inv_cancel₀ hdpos.ne',one_mul] + change weightedHalfNorm w (fun p=>f p-(d • P).eval (p^2))≤_ + rw [heq,weightedHalfNorm_smul] + have hh:=mul_le_mul_of_nonneg_left herr (sq_nonneg d) + rw [weightedHalfNorm_smul] at hh + rw [show d^2*(Real.exp (-2*(N:ℝ))*((d⁻¹)^2*weightedHalfNorm w f))= + (d*d⁻¹)^2*(Real.exp (-2*(N:ℝ))*weightedHalfNorm w f) by ring,mul_inv_cancel₀ hdpos.ne',one_pow,one_mul] at hh + exact hh +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial +lemma weightedHalfNorm_scale {s:ℝ} (hs:0f (s*p))=weightedHalfNorm stripDensity f := by + unfold weightedHalfNorm scaledStripDensity + have he:(fun p=>(f (s*p))^2*(s*stripDensity (s*p)))= + (fun p=>s*((f (s*p))^2*stripDensity (s*p))):=by funext p;ring + rw [he,integral_const_mul] + have ht:=integral_comp_mul_left_Ioi (fun p=>(f p)^2*stripDensity p) 0 hs + simp only [mul_zero,smul_eq_mul] at ht + rw [ht,←mul_assoc,mul_inv_cancel₀ hs.ne',one_mul] +lemma stripApproximation_scale_parameters : + let s:ℝ:=16/5 + let u:ℝ:=Real.tan (Real.pi/5) + 0completeJetCombination N (angle^2) b c p-P.eval (p^2))≤ + Real.exp (-2*(N:ℝ))*weightedHalfNorm stripDensity (completeJetCombination N (angle^2) b c) := by + let s:ℝ:=16/5 + let u:ℝ:=Real.tan (Real.pi/5) + obtain ⟨hs,hsL,hu,hu0,hlabel⟩:=stripApproximation_scale_parameters + change 0(scaledStripDensity_pos hs hp).le) hA ha hwu hwl + refine ⟨J,hJ,?_⟩ + intro N hN b c + let B:Fin N→ℝ:=fun i=>b i*(s^2)^(i:ℕ) + let C:Fin N→ℝ:=fun i=>c i*(s^2)^(i:ℕ) + obtain ⟨P,hP,herr⟩:=happ N hN B C + let Q:=polynomialDilate (s^2)⁻¹ P + have hscale (p:ℝ):completeJetCombination N (angle^2) b c (s*p)= + completeJetCombination N ((2*Real.arctan u)^2) B C p := by + rw [completeJetCombination_scale,hlabel] + have hQ (p:ℝ):Q.eval ((s*p)^2)=P.eval (p^2) := by + rw [polynomialDilate_eval,mul_pow,←mul_assoc,inv_mul_cancel₀ (pow_ne_zero _ hs.ne'),one_mul] + refine ⟨Q,(polynomialDilate_degree _ P).trans_lt hP,?_⟩ + rw [←weightedHalfNorm_scale hs (fun p=>completeJetCombination N (angle^2) b c p-Q.eval (p^2)), + ←weightedHalfNorm_scale hs (completeJetCombination N (angle^2) b c)] + simp_rw [hscale,hQ] + exact herr +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial +/-- Polynomial approximation for the strip weight and complete nodal jet space. -/ +theorem twoJetPolynomialApproximation : TwoJetPolynomialApproximation := by + obtain ⟨J,hJ,happ⟩:=completeJetStripApproximation + refine ⟨J,0,hJ,?_⟩ + intro N _ hN a + obtain ⟨b,c,hbc⟩:=twoJetCombination_split N a + obtain ⟨P,hP,herr⟩:=happ N hN b c + refine ⟨P,hP,?_⟩ + unfold stripSquaredNorm + simp_rw [hbc] + exact herr +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/JetCompression.lean b/lean/OAI/Combinatorics/HoneycombChords/JetCompression.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef61cdac2716c8f1c7a7d9d437cda08ac3db8bf1 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/JetCompression.lean @@ -0,0 +1,896 @@ +import OAI.Combinatorics.HoneycombChords.JetApproximation + +namespace OAI + +/-! +# Polynomial compression of complete jet Gram matrices + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open MeasureTheory +lemma scalar_young_abs {t:ℝ} (ht:0 nlinarith [sq_nonneg (a-b)] +lemma familySquaredNorm_sub_integrable (w f g:ℝ→ℝ) + (hf:IntegrableOn (fun p=>f (p^2)^2*w p) (Set.Ioi 0)) + (hg:IntegrableOn (fun p=>g (p^2)^2*w p) (Set.Ioi 0)) + (hfg:IntegrableOn (fun p=>f (p^2)*g (p^2)*w p) (Set.Ioi 0)) : + IntegrableOn (fun p=>(f (p^2)-g (p^2))^2*w p) (Set.Ioi 0) := by + apply ((hf.add hg).sub (hfg.const_mul 2)).congr + filter_upwards with p + simp only [Pi.add_apply,Pi.sub_apply] + ring +lemma familySquaredNorm_young (w f g:ℝ→ℝ) (hw:∀ p,0f (p^2)^2*w p) (Set.Ioi 0)) + (hg:IntegrableOn (fun p=>g (p^2)^2*w p) (Set.Ioi 0)) + (hfg:IntegrableOn (fun p=>f (p^2)*g (p^2)*w p) (Set.Ioi 0)) + {t:ℝ} (ht:0f x-g x) := by + have he:=familySquaredNorm_sub_integrable w f g hf hg hfg + have hb:IntegrableOn (fun p=>t*(f (p^2)^2*w p)+(1+1/t)*((f (p^2)-g (p^2))^2*w p)) (Set.Ioi 0):= + (hf.const_mul _).add (he.const_mul _) + have hbound: (∫ p in Set.Ioi 0,t*(f (p^2)^2*w p)+(1+1/t)*((f (p^2)-g (p^2))^2*w p))= + t*familySquaredNorm w f+(1+1/t)*familySquaredNorm w (fun x=>f x-g x) := by + rw [integral_add (hf.const_mul _) (he.const_mul _),integral_const_mul,integral_const_mul] + rfl + apply abs_le.mpr + constructor + · have hm:(∫ p in Set.Ioi 0,f (p^2)^2*w p-g (p^2)^2*w p)≤ + ∫ p in Set.Ioi 0,t*(f (p^2)^2*w p)+(1+1/t)*((f (p^2)-g (p^2))^2*w p) := by + apply integral_mono_ae (hf.sub hg) hb + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hh:=mul_le_mul_of_nonneg_right (abs_le.mp (scalar_square_perturbation ht (f (p^2)) (g (p^2)))).1 (hw p hp) + simp only [Pi.sub_apply] + nlinarith + rw [hbound,integral_sub hf hg] at hm + change familySquaredNorm w f-familySquaredNorm w g≤_ at hm + linarith + · have hm:(∫ p in Set.Ioi 0,g (p^2)^2*w p-f (p^2)^2*w p)≤ + ∫ p in Set.Ioi 0,t*(f (p^2)^2*w p)+(1+1/t)*((f (p^2)-g (p^2))^2*w p) := by + apply integral_mono_ae (hg.sub hf) hb + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hh:=mul_le_mul_of_nonneg_right (abs_le.mp (scalar_square_perturbation ht (f (p^2)) (g (p^2)))).2 (hw p hp) + simp only [Pi.sub_apply] + nlinarith + rw [hbound,integral_sub hg hf] at hm + exact hm +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset MeasureTheory Matrix +lemma stripSpan_mono {A B:ℝ} (h:A≤B) : stripKernelSpan A ≤ stripKernelSpan B := by + apply Submodule.span_mono + rintro f ⟨b,r,hb,hA,rfl⟩ + exact ⟨b,r,hb,hA.trans h,rfl⟩ +lemma stripSpan_actual_pair {f g:ℝ→ℝ} + (hf:f∈stripKernelSpan (angle^2)) (hg:g∈stripKernelSpan (angle^2)) : + IntegrableOn (fun p=>f (p^2)*g (p^2)*stripDensity p) (Set.Ioi 0) := by + have hb:angle^2≤(3*angle/2)^2:=by nlinarith [sq_nonneg angle] + have hi2:=stripSpan_pair_integrable (by norm_num : (0:ℝ)<1) 2 (stripSpan_mono hb hf) hg + have hi0:=stripSpan_pair_integrable (by norm_num : (0:ℝ)<1) 0 (stripSpan_mono hb hf) hg + apply (hi2.add hi0).congr + filter_upwards with p + dsimp only [Pi.add_apply,poleAdjustedDensity] + have hd:(p^2+(1:ℝ)^2)≠0:=by positivity + field_simp +lemma stripSpan_tilt_pair {f g:ℝ→ℝ} + (hf:f∈stripKernelSpan (angle^2)) (hg:g∈stripKernelSpan (angle^2)) + (y:ℝ) {z:ℝ} (hz:0f (p^2)*g (p^2)*(characteristicRatio y z p*stripDensity p)) (Set.Ioi 0) := by + have hb:angle^2≤(3*angle/2)^2:=by nlinarith [sq_nonneg angle] + have hi2:=stripSpan_pair_integrable hz 2 (stripSpan_mono hb hf) hg + have hi0:=stripSpan_pair_integrable hz 0 (stripSpan_mono hb hf) hg + apply (hi2.add (hi0.const_mul (y^2))).congr + filter_upwards with p + dsimp only [Pi.add_apply,poleAdjustedDensity,characteristicRatio] + ring +lemma monomial_mem_stripSpan (k:ℕ) : (fun x:ℝ=>x^k)∈stripKernelSpan (angle^2) := by + have h:=(stripKernelSpan (angle^2)).smul_mem ((2*k).factorial:ℝ) + (kernel_mem_stripSpan le_rfl (sq_nonneg angle) k) + have he:((2*k).factorial:ℝ) • cosineKernelJet k 0 0=(fun x:ℝ=>x^k) := by + funext x + simp only [Pi.smul_apply,smul_eq_mul,cosineKernelJet_at_zero] + have hn : ((2*k).factorial:ℝ)≠0:=by positivity + field_simp + rwa [he] at h +lemma polynomial_mem_stripSpan (P:Polynomial ℝ) : (fun x=>P.eval x)∈stripKernelSpan (angle^2) := by + classical + have he:(fun x=>P.eval x)=∑ k∈P.support,P.coeff k • (fun x:ℝ=>x^k):=by + funext x + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul] + exact Polynomial.eval_eq_sum + rw [he] + exact Submodule.sum_mem _ fun k _=>(stripKernelSpan (angle^2)).smul_mem _ (monomial_mem_stripSpan k) +noncomputable def twoJetFamily (N:ℕ) (i:Fin (2*N)) : ℝ→ℝ := + cosineKernelJet (nodalOrder (twoKnotLabels N) i) 0 (twoKnotLabels N i) +lemma twoJetFamily_mem (N:ℕ) (i:Fin (2*N)) : twoJetFamily N i∈stripKernelSpan (angle^2) := + kernel_mem_stripSpan (twoKnot_nonneg N _) (twoKnot_le N _) _ +lemma finiteFamilyCombination_mem_stripSpan {n:ℕ} {F:Fin n→ℝ→ℝ} + (hF:∀ i,F i∈stripKernelSpan (angle^2)) (a:Fin n→ℝ) : + finiteFamilyCombination F a∈stripKernelSpan (angle^2) := by + have he:finiteFamilyCombination F a=∑ i,a i • F i:=by ext x;simp [finiteFamilyCombination] + rw [he] + exact Submodule.sum_mem _ fun i _=>(stripKernelSpan (angle^2)).smul_mem _ (hF i) +lemma twoJetFamily_posDef (N:ℕ) : (familyGram stripDensity (twoJetFamily N) (twoJetFamily N)).PosDef := by + apply jetGram_posDef stripDensity (twoKnotLabels N) + (fun i j hij=>(twoKnot_monotone N) hij) (fun i=>twoKnot_nonneg N i) (fun _ hp=>stripDensity_pos hp) + intro i j + exact stripSpan_actual_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Filter Topology +/-- Fixed-parameter determinant compression for the complete jet family. -/ +def TwoJetPolynomialCompression : Prop := + ∃ C:ℕ,0characteristicRatio y z p*stripDensity p + let J := (familyGram w (twoJetFamily N) (twoJetFamily N)).det / + (familyGram stripDensity (twoJetFamily N) (twoJetFamily N)).det + (monomialGram (C*N) w).det/(monomialGram (C*N) stripDensity).det/4 ≤ J ∧ + J≤(monomialGram N w).det/(monomialGram N stripDensity).det +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Matrix MeasureTheory +/-- An integral perturbation bound for polynomial compression. -/ +theorem familyGram_error_from_norm {n:ℕ} (w:ℝ→ℝ) (F G:Fin n→ℝ→ℝ) + (hw:∀ p,0F i (p^2)*F j (p^2)*w p) (Set.Ioi 0)) + (hGG:∀ i j,IntegrableOn (fun p=>G i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hFG:∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + {δ t:ℝ} (ht:0finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + δ*familySquaredNorm w (finiteFamilyCombination F v)) : + ∀ v:Fin n→ℝ, + |v ⬝ᵥ (familyGram w G G *ᵥ v)-v ⬝ᵥ (familyGram w F F *ᵥ v)|≤ + (t+(1+1/t)*δ)*(v ⬝ᵥ (familyGram w F F *ᵥ v)) := by + intro v + rw [familyGram_quad w F hFF,familyGram_quad w G hGG] + have hF:=finiteFamilyCombination_pair_integrable w F F hFF v v + have hG:=finiteFamilyCombination_pair_integrable w G G hGG v v + have hfg:=finiteFamilyCombination_pair_integrable w F G hFG v v + have hy:=familySquaredNorm_young w (finiteFamilyCombination F v) (finiteFamilyCombination G v) hw + (by simpa only [pow_two] using hF) (by simpa only [pow_two] using hG) hfg ht + calc + _≤t*familySquaredNorm w (finiteFamilyCombination F v)+(1+1/t)* + familySquaredNorm w (fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x):=hy + _≤t*familySquaredNorm w (finiteFamilyCombination F v)+(1+1/t)* + (δ*familySquaredNorm w (finiteFamilyCombination F v)):=add_le_add (le_refl _) + (mul_le_mul_of_nonneg_left (herr v) (show 0≤1+1/t by positivity)) + _=_:=by ring +lemma familySquaredNorm_weight_bounds (w r f:ℝ→ℝ) {l u:ℝ} + (hw:∀ p,0f (p^2)^2*w p) (Set.Ioi 0)) + (hrf:IntegrableOn (fun p=>f (p^2)^2*(r p*w p)) (Set.Ioi 0)) : + l*familySquaredNorm w f≤familySquaredNorm (fun p=>r p*w p) f ∧ + familySquaredNorm (fun p=>r p*w p) f≤u*familySquaredNorm w f := by + unfold familySquaredNorm + rw [←integral_const_mul,←integral_const_mul] + constructor + · apply integral_mono_ae (hf.const_mul l) hrf + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have h:=mul_le_mul_of_nonneg_right (hr p hp).1 (mul_nonneg (sq_nonneg (f (p^2))) (hw p hp)) + nlinarith + · apply integral_mono_ae hrf (hf.const_mul u) + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have h:=mul_le_mul_of_nonneg_right (hr p hp).2 (mul_nonneg (sq_nonneg (f (p^2))) (hw p hp)) + nlinarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Polynomial Finset MeasureTheory +/-- The genuine complete-jet space admits one simultaneous polynomial +approximation on an orthonormal basis; constants do not depend on its vectors. -/ +theorem twoJet_orthonormal_polynomial_approximation : + ∃ C N₀:ℕ,0finiteFamilyCombination (twoJetFamily N) (T i) + familyGram stripDensity F F=1 ∧ + (∀ i,(P i).natDegreeF i x-(P i).eval x)≤Real.exp (-2*(N:ℝ))) := by + classical + obtain ⟨C,N₀,hC,happ⟩:=twoJetPolynomialApproximation + refine ⟨C,N₀,hC,?_⟩ + intro N hNN hN + let J:=twoJetFamily N + let B:=familyGram stripDensity J J + have hB:B.PosDef:=twoJetFamily_posDef N + obtain ⟨S,e,hS,hBS,_⟩:=positive_pencil_normal_form B B hB.isHermitian hB + let T:=Sᵀ + let F:=fun i=>finiteFamilyCombination J (T i) + have hi i j:IntegrableOn (fun p=>J i (p^2)*J j (p^2)*stripDensity p) (Set.Ioi 0):= + stripSpan_actual_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j) + have hF:familyGram stripDensity F F=1:=by + rw [show familyGram stripDensity F F=T*B*Tᵀ from familyGram_congruence stripDensity J hi T] + simpa only [T,transpose_transpose,conjTranspose_eq_transpose_of_trivial] using hBS + have hFp:∀ i,familySquaredNorm stripDensity (F i)=1:=by + intro i + have h:=congrArg (fun M:Matrix (Fin (2*N)) (Fin (2*N)) ℝ=>M i i) hF + simpa only [familyGram,familySquaredNorm,pow_two,Matrix.one_apply_eq] using h + have hPick:∀ i:Fin (2*N),∃ P:Polynomial ℝ,P.natDegreeF i x-P.eval x)≤Real.exp (-2*(N:ℝ)) := by + intro i + obtain ⟨P,hP,herr⟩:=happ N hNN hN (T i) + refine ⟨P,hP,?_⟩ + change familySquaredNorm stripDensity (fun x=>F i x-P.eval x)≤ + Real.exp (-2*(N:ℝ))*familySquaredNorm stripDensity (F i) at herr + simpa only [hFp,mul_one] using herr + choose P hP using hPick + refine ⟨T,P,?_,hF,fun i=>(hP i).1,fun i=>(hP i).2⟩ + simpa only [T,det_transpose] using hS +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +lemma orthonormal_family_error {n:ℕ} (F G:Fin n→ℝ→ℝ) + (hF:∀ i,F i∈stripKernelSpan (angle^2)) (hG:∀ i,G i∈stripKernelSpan (angle^2)) + (hI:familyGram stripDensity F F=1) {δ:ℝ} + (hE:∀ i,familySquaredNorm stripDensity (fun x=>F i x-G i x)≤δ) + (v:Fin n→ℝ) : + familySquaredNorm stripDensity (fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + ((n:ℝ)*δ)*familySquaredNorm stripDensity (finiteFamilyCombination F v) := by + let E:Fin n→ℝ→ℝ:=fun i=>F i-G i + have hmem i:E i∈stripKernelSpan (angle^2):=(stripKernelSpan (angle^2)).sub_mem (hF i) (hG i) + have h:=familySquaredNorm_error_bound stripDensity E (fun _ hp=>(stripDensity_pos hp).le) + (fun i j=>stripSpan_actual_pair (hmem i) (hmem j)) hE v + have he:finiteFamilyCombination E v=(fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x):=by + funext x + simp [finiteFamilyCombination,E,mul_sub,sum_sub_distrib] + rw [he] at h + have hn:familySquaredNorm stripDensity (finiteFamilyCombination F v)=∑ i,v i^2:=by + rw [←familyGram_quad stripDensity F (fun i j=>stripSpan_actual_pair (hF i) (hF j)),hI,one_mulVec] + simp only [dotProduct,pow_two] + rwa [hn] +lemma orthonormal_family_tilt_error {n:ℕ} (F G:Fin n→ℝ→ℝ) + (hF:∀ i,F i∈stripKernelSpan (angle^2)) (hG:∀ i,G i∈stripKernelSpan (angle^2)) + (hI:familyGram stripDensity F F=1) {δ:ℝ} (hδ:0≤δ) + (hE:∀ i,familySquaredNorm stripDensity (fun x=>F i x-G i x)≤δ) + {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p) + (fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + (((n:ℝ)*δ)/(y^2/z^2))*familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) + (finiteFamilyCombination F v) := by + have hz:0finiteFamilyCombination F v x-finiteFamilyCombination G v x + have hf:f∈stripKernelSpan (angle^2):=finiteFamilyCombination_mem_stripSpan hF v + have he:e∈stripKernelSpan (angle^2):=(stripKernelSpan (angle^2)).sub_mem hf (finiteFamilyCombination_mem_stripSpan hG v) + have heint:IntegrableOn (fun p=>e (p^2)^2*stripDensity p) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_actual_pair he he + have herint:IntegrableOn (fun p=>e (p^2)^2*(characteristicRatio y z p*stripDensity p)) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_tilt_pair he he y hz + have hfint:IntegrableOn (fun p=>f (p^2)^2*stripDensity p) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_actual_pair hf hf + have hfrint:IntegrableOn (fun p=>f (p^2)^2*(characteristicRatio y z p*stripDensity p)) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_tilt_pair hf hf y hz + have hne:familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) e≤familySquaredNorm stripDensity e:=by + simpa only [one_mul] using (familySquaredNorm_weight_bounds stripDensity (characteristicRatio y z) e + (fun _ hp=>(stripDensity_pos hp).le) hr heint herint).2 + have hnf: l*familySquaredNorm stripDensity f≤familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) f:= + (familySquaredNorm_weight_bounds stripDensity (characteristicRatio y z) f + (fun _ hp=>(stripDensity_pos hp).le) hr hfint hfrint).1 + have hn:=orthonormal_family_error F G hF hG hI hE v + change familySquaredNorm stripDensity e≤((n:ℝ)*δ)*familySquaredNorm stripDensity f at hn + calc + _≤familySquaredNorm stripDensity e:=hne + _≤((n:ℝ)*δ)*familySquaredNorm stripDensity f:=hn + _=(((n:ℝ)*δ)/l)*(l*familySquaredNorm stripDensity f):=by field_simp + _≤_:=mul_le_mul_of_nonneg_left hnf (by positivity) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Polynomial Finset MeasureTheory +lemma posDef_real_congruence {n:ℕ} (A C:Matrix (Fin n) (Fin n) ℝ) + (hA:A.PosDef) (hC:IsUnit C.det) : (C*A*Cᵀ).PosDef := by + have ht:IsUnit Cᵀ.det:=by simpa only [det_transpose] using hC + have h:=hA.conjTranspose_mul_mul_same (Matrix.mulVec_injective_of_isUnit (Cᵀ.isUnit_iff_isUnit_det.mpr ht)) + simpa only [conjTranspose_eq_transpose_of_trivial,transpose_transpose] using h +lemma determinant_quotient_congruence {n:ℕ} (A B C:Matrix (Fin n) (Fin n) ℝ) + (hC:IsUnit C.det) : (C*A*Cᵀ).det/(C*B*Cᵀ).det=A.det/B.det := by + have hc:C.det≠0:=isUnit_iff_ne_zero.mp hC + simp only [det_mul,det_transpose] + by_cases hb:B.det=0 + · simp [hb] + · field_simp +lemma posDef_of_relative_error {n:ℕ} (A D:Matrix (Fin n) (Fin n) ℝ) + (hA:A.PosDef) (hD:D.IsHermitian) {η:ℝ} (hη:η<1) + (herr:∀ v:Fin n→ℝ,|v ⬝ᵥ (D *ᵥ v)-v ⬝ᵥ (A *ᵥ v)|≤η*(v ⬝ᵥ (A *ᵥ v))) : D.PosDef := by + apply Matrix.PosDef.of_dotProduct_mulVec_pos hD + intro v hv + have hp:=hA.dotProduct_mulVec_pos hv + have hh:=(abs_le.mp (herr v)).1 + simp only [star_trivial] at hp ⊢ + nlinarith +lemma polynomial_family_compression {n d:ℕ} (P:Fin n→Polynomial ℝ) (hP:∀ i,(P i).natDegreep^k*w p) (Set.Ioi 0)) : + familyGram w (fun i x=>(P i).eval x) (fun i x=>(P i).eval x)= + (Matrix.of fun i (j:Fin d)=>(P i).coeff j)*monomialGram d w*(Matrix.of fun i (j:Fin d)=>(P i).coeff j)ᵀ := by + let C:Matrix (Fin n) (Fin d) ℝ:=fun i j=>(P i).coeff j + let V:Fin d→ℝ→ℝ:=fun j x=>x^j.val + have hV:∀ i,finiteFamilyCombination V (C i)=(fun x=>(P i).eval x):=by + intro i + funext x + rw [Polynomial.eval_eq_sum_range' (hP i)] + simp only [finiteFamilyCombination,V,C] + exact Fin.sum_univ_eq_sum_range (fun k=>(P i).coeff k*x^k) d + have hh:=familyGram_congruence w V (fun i j=>monomial_pair_integrable w hi i.val j.val) C + simp only [hV] at hh + exact hh +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +noncomputable def compressionError (l:ℝ) (N:ℕ) : ℝ := + Real.exp (-(N:ℝ))+(1+1/Real.exp (-(N:ℝ)))*((2*(N:ℝ))*Real.exp (-2*(N:ℝ))/l) +lemma compressionError_nonneg {l:ℝ} (hl:0(N:ℝ)) atTop atTop:=tendsto_natCast_atTop_atTop + have h1:Tendsto (fun N:ℕ=>(N:ℝ)*Real.exp (-(N:ℝ))) atTop (𝓝 0):=by + simpa only [Function.comp_def,pow_one] using (Real.tendsto_pow_mul_exp_neg_atTop_nhds_zero 1).comp hc + have h2:Tendsto (fun N:ℕ=>(N:ℝ)^2*Real.exp (-(N:ℝ))) atTop (𝓝 0):= + (Real.tendsto_pow_mul_exp_neg_atTop_nhds_zero 2).comp hc + have hh:Tendsto (fun N:ℕ=>2*((N:ℝ)*Real.exp (-(N:ℝ)))+(8/l)*((N:ℝ)^2*Real.exp (-(N:ℝ)))) atTop (𝓝 0):=by + simpa using (h1.const_mul 2).add (h2.const_mul (8/l)) + have hb:=hh.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/2)) + filter_upwards [hb,eventually_ge_atTop (1:ℕ)] with N hN hN1 + have hn:(1:ℝ)≤N:=by exact_mod_cast hN1 + have he: Real.exp (-2*(N:ℝ))=Real.exp (-(N:ℝ))^2:=by + rw [sq,←Real.exp_add];congr 1;ring + have he1:Real.exp (-(N:ℝ))≤1:=Real.exp_le_one_iff.mpr (by linarith) + have hx:1/Real.exp (-(N:ℝ))*Real.exp (-2*(N:ℝ))=Real.exp (-(N:ℝ)):=by + rw [he];field_simp + have hs:(2*(N:ℝ))*compressionError l N≤ + 2*((N:ℝ)*Real.exp (-(N:ℝ)))+(8/l)*((N:ℝ)^2*Real.exp (-(N:ℝ))) := by + have hp:Real.exp (-2*(N:ℝ))≤Real.exp (-(N:ℝ)):=Real.exp_le_exp.mpr (by linarith) + have hm:=mul_le_mul_of_nonneg_left hp (show 0≤4*(N:ℝ)^2/l by positivity) + unfold compressionError + have hxs:(1+1/Real.exp (-(N:ℝ)))*Real.exp (-2*(N:ℝ))= + Real.exp (-2*(N:ℝ))+Real.exp (-(N:ℝ)):=by rw [add_mul,one_mul,hx] + calc + _=2*((N:ℝ)*Real.exp (-(N:ℝ)))+(4*(N:ℝ)^2/l)*(Real.exp (-2*(N:ℝ))+Real.exp (-(N:ℝ))):=by + rw [←hxs];ring + _≤_:=by ring_nf at hm ⊢;linarith + have hsmall: (2*(N:ℝ))*compressionError l N≤1/2:=hs.trans hN.le + refine ⟨?_,hsmall⟩ + have h0:=compressionError_nonneg hl N + nlinarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +lemma orthonormal_stripGram_transfer {N:ℕ} (F G:Fin (2*N)→ℝ→ℝ) + (hF:∀ i,F i∈stripKernelSpan (angle^2)) (hG:∀ i,G i∈stripKernelSpan (angle^2)) + (hI:familyGram stripDensity F F=1) + (hE:∀ i,familySquaredNorm stripDensity (fun x=>F i x-G i x)≤Real.exp (-2*(N:ℝ))) + {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p) F F).PosDef) + (hsmall:compressionError (y^2/z^2) N≤1/2 ∧ (2*(N:ℝ))*compressionError (y^2/z^2) N≤1/2) : + (familyGram stripDensity G G).PosDef ∧ + (familyGram (fun p=>characteristicRatio y z p*stripDensity p) G G).det/(familyGram stripDensity G G).det≤ + 4*((familyGram (fun p=>characteristicRatio y z p*stripDensity p) F F).det/(familyGram stripDensity F F).det) := by + have hz:=hy.trans hyz + let l:=y^2/z^2 + have hl:0finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + δ*familySquaredNorm stripDensity (finiteFamilyCombination F v):=by + intro v + have h:=orthonormal_family_error F G hF hG hI hE v + simp only [Nat.cast_mul,Nat.cast_ofNat] at h + apply h.trans + apply mul_le_mul_of_nonneg_right _ (familySquaredNorm_nonneg stripDensity _ (fun _ hp=>(stripDensity_pos hp).le)) + change (2*(N:ℝ))*Real.exp (-2*(N:ℝ))≤(2*(N:ℝ))*Real.exp (-2*(N:ℝ))/l + apply (le_div_iff₀ hl).mpr + exact mul_le_of_le_one_right (by positivity) hl1 + have hBE:=familyGram_error_from_norm stripDensity F G (fun _ hp=>(stripDensity_pos hp).le) + hFF hGG hFG ht hbase + change ∀ v,|v ⬝ᵥ (familyGram stripDensity G G *ᵥ v)-v ⬝ᵥ (familyGram stripDensity F F *ᵥ v)|≤ + η*(v ⬝ᵥ (familyGram stripDensity F F *ᵥ v)) at hBE + have htilt:∀ v:Fin (2*N)→ℝ, + familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) + (fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + δ*familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) (finiteFamilyCombination F v):=by + intro v + simpa only [Nat.cast_mul,Nat.cast_ofNat] using + orthonormal_family_tilt_error F G hF hG hI (Real.exp_pos _).le hE hy hyz v + have hAD:=familyGram_error_from_norm (fun p=>characteristicRatio y z p*stripDensity p) F G + (fun p hp=>(mul_pos (characteristicRatio_pos hy hz p) (stripDensity_pos hp)).le) + (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y hz) + (fun i j=>stripSpan_tilt_pair (hG i) (hG j) y hz) + (fun i j=>stripSpan_tilt_pair (hF i) (hG j) y hz) ht htilt + change ∀ v,|v ⬝ᵥ (familyGram (fun p=>characteristicRatio y z p*stripDensity p) G G *ᵥ v)- + v ⬝ᵥ (familyGram (fun p=>characteristicRatio y z p*stripDensity p) F F *ᵥ v)|≤ + η*(v ⬝ᵥ (familyGram (fun p=>characteristicRatio y z p*stripDensity p) F F *ᵥ v)) at hAD + have hB:(familyGram stripDensity F F).PosDef:=by rw [hI];exact Matrix.PosDef.one + have hn:((2*N:ℕ):ℝ)*η≤1/2:=by simpa only [Nat.cast_mul,Nat.cast_ofNat] using hsmall.2 + have hη:0≤η:=compressionError_nonneg hl N + refine ⟨posDef_of_relative_error _ _ hB (familyGram_hermitian _ G) (by linarith only [hsmall.1]) hBE,?_⟩ + exact (gram_quotient_small_relative_error _ _ _ _ hA hB + (familyGram_hermitian _ G) (familyGram_hermitian _ G) hη hsmall.1 hn hAD hBE).2 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +lemma characteristicRatio_le_one {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p) (twoJetFamily N) (twoJetFamily N)).PosDef := by + apply jetGram_posDef _ (twoKnotLabels N) + (fun i j hij=>(twoKnot_monotone N) hij) (fun i=>twoKnot_nonneg N i) + (fun p hp=>mul_pos (characteristicRatio_pos hy hz p) (stripDensity_pos hp)) + intro i j + exact stripSpan_tilt_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j) y hz +lemma familyGram_tilt_contraction {n:ℕ} (F:Fin n→ℝ→ℝ) + (hF:∀ i,F i∈stripKernelSpan (angle^2)) {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p) F F *ᵥ v)≤ + v ⬝ᵥ (familyGram stripDensity F F *ᵥ v) := by + rw [familyGram_quad _ F (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y (hy.trans hyz)), + familyGram_quad _ F (fun i j=>stripSpan_actual_pair (hF i) (hF j))] + have hf:=finiteFamilyCombination_mem_stripSpan hF v + apply integral_mono_ae + · simpa only [IntegrableOn,pow_two] using stripSpan_tilt_pair hf hf y (hy.trans hyz) + · simpa only [IntegrableOn,pow_two] using stripSpan_actual_pair hf hf + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hh:=mul_le_mul_of_nonneg_right (characteristicRatio_le_one hy hyz p) + (mul_nonneg (sq_nonneg (finiteFamilyCombination F v (p^2))) (stripDensity_pos hp).le) + nlinarith +lemma twoJet_contains_monomials (N:ℕ) : + ∃ C:Matrix (Fin N) (Fin (2*N)) ℝ,∀ i,finiteFamilyCombination (twoJetFamily N) (C i)=(fun x=>x^i.val) := by + classical + let ix:Fin N→Fin (2*N):=fun i=>⟨i.val,by omega⟩ + let C:Matrix (Fin N) (Fin (2*N)) ℝ:=fun i j=>if j=ix i then ((2*i.val).factorial:ℝ) else 0 + refine ⟨C,?_⟩ + intro i + funext x + unfold finiteFamilyCombination + rw [sum_eq_single (ix i)] + · simp only [C,ite_eq_left rfl,twoJetFamily,ix,twoKnot_nodalOrder,twoKnotLabels,ite_eq_left i.isLt,cosineKernelJet_at_zero] + have hn:((2*i.val).factorial:ℝ)≠0:=by positivity + field_simp + · intro j _ hj + simp only [C,ite_eq_right hj,zero_mul] + · simp +/-- A containment inequality for polynomial compression at every natural index. -/ +theorem twoJet_polynomial_compression_upper (N:ℕ) {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p) (twoJetFamily N) (twoJetFamily N)).det / + (familyGram stripDensity (twoJetFamily N) (twoJetFamily N)).det≤ + (monomialGram N (fun p=>characteristicRatio y z p*stripDensity p)).det/(monomialGram N stripDensity).det := by + obtain ⟨C,hC⟩:=twoJet_contains_monomials N + have he (w:ℝ→ℝ) (hi:∀ i j,IntegrableOn + (fun p=>twoJetFamily N i (p^2)*twoJetFamily N j (p^2)*w p) (Set.Ioi 0)) : + C*familyGram w (twoJetFamily N) (twoJetFamily N)*Cᵀ=monomialGram N w:=by + rw [←familyGram_congruence w (twoJetFamily N) hi C] + simp only [hC] + rfl + have heB:=he stripDensity (fun i j=>stripSpan_actual_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j)) + have heA:=he (fun p=>characteristicRatio y z p*stripDensity p) + (fun i j=>stripSpan_tilt_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j) y (hy.trans hyz)) + have hcb:(C*familyGram stripDensity (twoJetFamily N) (twoJetFamily N)*Cᵀ).PosDef:=by + rw [heB] + exact monomialGram_posDef N stripDensity (fun _ hp=>stripDensity_pos hp) stripDensity_moments + have h:=positive_contraction_compression _ _ C (twoJetFamily_tilt_posDef N hy (hy.trans hyz)) + (twoJetFamily_posDef N) hcb (familyGram_tilt_contraction _ (twoJetFamily_mem N) hy hyz) + simpa only [heA,heB] using h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter Topology Polynomial +/-- Determinant compression for the complete jet family with the strip weight. -/ +theorem twoJetPolynomialCompression : TwoJetPolynomialCompression := by + classical + obtain ⟨C,N₀,hC,happrox⟩:=twoJet_orthonormal_polynomial_approximation + refine ⟨C,hC,?_⟩ + intro y z hy hyz + have hz:=hy.trans hyz + have hl:0characteristicRatio y z p*stripDensity p + let J:=twoJetFamily N + let F:=fun i=>finiteFamilyCombination J (T i) + let G:Fin (2*N)→ℝ→ℝ:=fun i x=>(P i).eval x + have hFm i:F i∈stripKernelSpan (angle^2):=finiteFamilyCombination_mem_stripSpan (twoJetFamily_mem N) (T i) + have hGm i:G i∈stripKernelSpan (angle^2):=polynomial_mem_stripSpan (P i) + have hcongB:familyGram stripDensity F F=T*familyGram stripDensity J J*Tᵀ:= + familyGram_congruence stripDensity J (fun i j=>stripSpan_actual_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j)) T + have hcongA:familyGram w F F=T*familyGram w J J*Tᵀ:= + familyGram_congruence w J (fun i j=>stripSpan_tilt_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j) y hz) T + have hAF:(familyGram w F F).PosDef:=by + rw [hcongA] + exact posDef_real_congruence _ T (twoJetFamily_tilt_posDef N hy hz) hT + have htrans:=orthonormal_stripGram_transfer F G hFm hGm hI hE hy hyz hAF hsmall + have hInv:(familyGram w F F).det/(familyGram stripDensity F F).det= + (familyGram w J J).det/(familyGram stripDensity J J).det:=by + rw [hcongA,hcongB] + exact determinant_quotient_congruence _ _ T hT + let Q:Matrix (Fin (2*N)) (Fin (C*N)) ℝ:=fun i j=>(P i).coeff j + have hwint k:IntegrableOn (fun p=>p^k*w p) (Set.Ioi 0):=by + simpa only [pow_one] using characteristic_tilt_moments hy hz 1 k + have hpA:familyGram w G G=Q*monomialGram (C*N) w*Qᵀ:=polynomial_family_compression P hP w hwint + have hpB:familyGram stripDensity G G=Q*monomialGram (C*N) stripDensity*Qᵀ:= + polynomial_family_compression P hP stripDensity stripDensity_moments + have hPolyA:(monomialGram (C*N) w).PosDef:=monomialGram_posDef _ w + (fun p hp=>mul_pos (characteristicRatio_pos hy hz p) (stripDensity_pos hp)) hwint + have hPolyB:(monomialGram (C*N) stripDensity).PosDef:=monomialGram_posDef _ stripDensity + (fun _ hp=>stripDensity_pos hp) stripDensity_moments + have hQB:(Q*monomialGram (C*N) stripDensity*Qᵀ).PosDef:=by rw [←hpB];exact htrans.1 + have hContract:∀ v:Fin (C*N)→ℝ,v ⬝ᵥ (monomialGram (C*N) w *ᵥ v)≤v ⬝ᵥ (monomialGram (C*N) stripDensity *ᵥ v):=by + intro v + exact familyGram_tilt_contraction (fun i:Fin (C*N)=>fun x:ℝ=>x^i.val) (fun i=>monomial_mem_stripSpan i.val) hy hyz v + have hlow:=positive_contraction_compression _ _ Q hPolyA hPolyB hQB hContract + rw [←hpA,←hpB] at hlow + have hu:=htrans.2 + change (familyGram w G G).det/(familyGram stripDensity G G).det≤ + 4*((familyGram w F F).det/(familyGram stripDensity F F).det) at hu + rw [hInv] at hu + constructor + · change (monomialGram (C*N) w).det/(monomialGram (C*N) stripDensity).det/4≤ + (familyGram w J J).det/(familyGram stripDensity J J).det + linarith [hlow.trans hu] + · exact twoJet_polynomial_compression_upper N hy hyz +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +lemma orthonormal_family_expansion_error {n:ℕ} (F G:Fin n→ℝ→ℝ) + (hF:∀ i,F i∈stripKernelSpan (angle^2)) (hG:∀ i,G i∈stripKernelSpan (angle^2)) + (hI:familyGram stripDensity F F=1) {δ:ℝ} (hδ:0≤δ) + (hE:∀ i,familySquaredNorm stripDensity (fun x=>F i x-G i x)≤δ) + {y z:ℝ} (hz:0characteristicRatio y z p*stripDensity p) + (fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + (2*((n:ℝ)*δ))*familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) + (finiteFamilyCombination F v) := by + let f:=finiteFamilyCombination F v + let e:=fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x + have hf:f∈stripKernelSpan (angle^2):=finiteFamilyCombination_mem_stripSpan hF v + have he:e∈stripKernelSpan (angle^2):=(stripKernelSpan (angle^2)).sub_mem hf (finiteFamilyCombination_mem_stripSpan hG v) + have heint:IntegrableOn (fun p=>e (p^2)^2*stripDensity p) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_actual_pair he he + have herint:IntegrableOn (fun p=>e (p^2)^2*(characteristicRatio y z p*stripDensity p)) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_tilt_pair he he y hz + have hfint:IntegrableOn (fun p=>f (p^2)^2*stripDensity p) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_actual_pair hf hf + have hfrint:IntegrableOn (fun p=>f (p^2)^2*(characteristicRatio y z p*stripDensity p)) (Set.Ioi 0):=by + simpa only [pow_two] using stripSpan_tilt_pair hf hf y hz + have hne:familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) e≤2*familySquaredNorm stripDensity e:=by + exact (familySquaredNorm_weight_bounds stripDensity (characteristicRatio y z) e + (fun _ hp=>(stripDensity_pos hp).le) hr heint herint).2 + have hnf: 1*familySquaredNorm stripDensity f≤familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) f:= + (familySquaredNorm_weight_bounds stripDensity (characteristicRatio y z) f + (fun _ hp=>(stripDensity_pos hp).le) hr hfint hfrint).1 + have hn:=orthonormal_family_error F G hF hG hI hE v + change familySquaredNorm stripDensity e≤((n:ℝ)*δ)*familySquaredNorm stripDensity f at hn + calc + _≤2*familySquaredNorm stripDensity e:=hne + _≤2*(((n:ℝ)*δ)*familySquaredNorm stripDensity f):=mul_le_mul_of_nonneg_left hn (by norm_num) + _=(2*((n:ℝ)*δ))*(1*familySquaredNorm stripDensity f):=by ring + _≤_:=mul_le_mul_of_nonneg_left hnf (by positivity) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +lemma orthonormal_stripGram_expansion_transfer {N:ℕ} (F G:Fin (2*N)→ℝ→ℝ) + (hF:∀ i,F i∈stripKernelSpan (angle^2)) (hG:∀ i,G i∈stripKernelSpan (angle^2)) + (hI:familyGram stripDensity F F=1) + (hE:∀ i,familySquaredNorm stripDensity (fun x=>F i x-G i x)≤Real.exp (-2*(N:ℝ))) + {y z:ℝ} (hy:0characteristicRatio y z p*stripDensity p) F F).PosDef) + (hsmall:compressionError ((1:ℝ)/2) N≤1/2 ∧ (2*(N:ℝ))*compressionError ((1:ℝ)/2) N≤1/2) : + (familyGram stripDensity G G).PosDef ∧ + ((familyGram (fun p=>characteristicRatio y z p*stripDensity p) F F).det/(familyGram stripDensity F F).det)/4≤ + (familyGram (fun p=>characteristicRatio y z p*stripDensity p) G G).det/(familyGram stripDensity G G).det := by + let l:ℝ:=1/2 + have hl:0finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + δ*familySquaredNorm stripDensity (finiteFamilyCombination F v):=by + intro v + have h:=orthonormal_family_error F G hF hG hI hE v + simp only [Nat.cast_mul,Nat.cast_ofNat] at h + apply h.trans + apply mul_le_mul_of_nonneg_right _ (familySquaredNorm_nonneg stripDensity _ (fun _ hp=>(stripDensity_pos hp).le)) + change (2*(N:ℝ))*Real.exp (-2*(N:ℝ))≤(2*(N:ℝ))*Real.exp (-2*(N:ℝ))/l + apply (le_div_iff₀ hl).mpr + exact mul_le_of_le_one_right (by positivity) hl1 + have hBE:=familyGram_error_from_norm stripDensity F G (fun _ hp=>(stripDensity_pos hp).le) + hFF hGG hFG ht hbase + change ∀ v,|v ⬝ᵥ (familyGram stripDensity G G *ᵥ v)-v ⬝ᵥ (familyGram stripDensity F F *ᵥ v)|≤ + η*(v ⬝ᵥ (familyGram stripDensity F F *ᵥ v)) at hBE + have htilt:∀ v:Fin (2*N)→ℝ, + familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) + (fun x=>finiteFamilyCombination F v x-finiteFamilyCombination G v x)≤ + δ*familySquaredNorm (fun p=>characteristicRatio y z p*stripDensity p) (finiteFamilyCombination F v):=by + intro v + have h:=orthonormal_family_expansion_error F G hF hG hI (Real.exp_pos _).le hE hz hr v + convert h using 1; dsimp [δ,l]; push_cast; ring + have hAD:=familyGram_error_from_norm (fun p=>characteristicRatio y z p*stripDensity p) F G + (fun p hp=>(mul_pos (characteristicRatio_pos hy hz p) (stripDensity_pos hp)).le) + (fun i j=>stripSpan_tilt_pair (hF i) (hF j) y hz) + (fun i j=>stripSpan_tilt_pair (hG i) (hG j) y hz) + (fun i j=>stripSpan_tilt_pair (hF i) (hG j) y hz) ht htilt + change ∀ v,|v ⬝ᵥ (familyGram (fun p=>characteristicRatio y z p*stripDensity p) G G *ᵥ v)- + v ⬝ᵥ (familyGram (fun p=>characteristicRatio y z p*stripDensity p) F F *ᵥ v)|≤ + η*(v ⬝ᵥ (familyGram (fun p=>characteristicRatio y z p*stripDensity p) F F *ᵥ v)) at hAD + have hB:(familyGram stripDensity F F).PosDef:=by rw [hI];exact Matrix.PosDef.one + have hn:((2*N:ℕ):ℝ)*η≤1/2:=by simpa only [Nat.cast_mul,Nat.cast_ofNat] using hsmall.2 + have hη:0≤η:=compressionError_nonneg hl N + refine ⟨posDef_of_relative_error _ _ hB (familyGram_hermitian _ G) (by linarith only [hsmall.1]) hBE,?_⟩ + exact (gram_quotient_small_relative_error _ _ _ _ hA hB + (familyGram_hermitian _ G) (familyGram_hermitian _ G) hη hsmall.1 hn hAD hBE).1 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv +lemma diagonal_compression_codimension {n m:ℕ} (C:Matrix (Fin n) (Fin m) ℝ) (e:Fin m→ℝ) + {l:ℝ} (hl:0≤l) (he:∀ i,l≤e i) : + l^(m-n)*(C*diagonal e*Cᵀ).det≤(∏ i,e i)*(C*Cᵀ).det := by + classical + have hn:0<(Fintype.card (Perm (Fin n)):ℝ):=by exact_mod_cast Fintype.card_pos + apply (mul_le_mul_iff_right₀ hn).mp + have hbase:=rectangular_diagonal_gram_det C (fun _=>1) + simp only [Matrix.diagonal_one,Matrix.mul_one,prod_const_one,one_mul] at hbase + have hweight:=rectangular_diagonal_gram_det C e + calc + (Fintype.card (Perm (Fin n)):ℝ)*(l^(m-n)*(C*diagonal e*Cᵀ).det)= + l^(m-n)*((Fintype.card (Perm (Fin n)):ℝ)*(C*diagonal e*Cᵀ).det):=by ring + _=l^(m-n)*(∑ f:Fin n→Fin m,(∏ i,e (f i))*(C.submatrix id f).det^2):=by rw [hweight] + _≤(∏ i,e i)*(∑ f:Fin n→Fin m,(C.submatrix id f).det^2):=by + rw [mul_sum,mul_sum] + apply sum_le_sum + intro f _ + by_cases hf:Function.Injective f + · let S:Finset (Fin m):=univ.image f + have hcard:(univ\S).card=m-n:=by + rw [card_sdiff] + simp only [inter_univ] + simp [S,card_image_iff.mpr (fun i _ j _ h=>hf h)] + have hc:l^(m-n)≤∏ i∈univ\S,e i:=by + rw [←hcard,←prod_const] + exact prod_le_prod₀ (fun _ _=>hl) (fun i _=>he i) + have hp:(∏ i,e i)=(∏ i∈univ\S,e i)*(∏ i,e (f i)):=by + rw [←prod_image (fun i _ j _ h=>hf h)] + exact (prod_sdiff (subset_univ S)).symm + have hh:=mul_le_mul_of_nonneg_right hc (show 0≤∏ i,e (f i) from prod_nonneg (fun i _=>hl.trans (he (f i)))) + rw [←hp] at hh + nlinarith [mul_le_mul_of_nonneg_right hh (sq_nonneg (C.submatrix id f).det)] + · obtain ⟨i,j,hij,heq⟩:=Function.not_injective_iff.mp hf + have hz:(C.submatrix id f).det=0:=Matrix.det_zero_of_column_eq heq (fun k=>by simp [hij]) + simp [hz] + _=(Fintype.card (Perm (Fin n)):ℝ)*((∏ i,e i)*(C*Cᵀ).det):=by rw [←hbase];ring +/-- The matching compression bound with the codimension factor. -/ +theorem positive_compression_codimension {n m:ℕ} + (A B:Matrix (Fin m) (Fin m) ℝ) (C:Matrix (Fin n) (Fin m) ℝ) + (hA:A.PosDef) (hB:B.PosDef) (hCB:(C*B*Cᵀ).PosDef) {l:ℝ} (hl:0≤l) + (hAB:∀ v:Fin m→ℝ,l*(v ⬝ᵥ (B *ᵥ v))≤v ⬝ᵥ (A *ᵥ v)) : + l^(m-n)*((C*A*Cᵀ).det/(C*B*Cᵀ).det)≤A.det/B.det := by + obtain ⟨P,e,hP,hPB,hPA⟩:=positive_pencil_normal_form A B hA.1 hB + have hPP:P*P⁻¹=1:=Matrix.mul_nonsing_inv P hP + have hPP':P⁻¹*P=1:=Matrix.nonsing_inv_mul P hP + have he (i:Fin m):l≤e i := by + have hh:=hAB (P *ᵥ Pi.single i 1) + have hquad (T:Matrix (Fin m) (Fin m) ℝ) (v:Fin m→ℝ) : + (P *ᵥ v) ⬝ᵥ (T *ᵥ (P *ᵥ v))=v ⬝ᵥ ((Pᴴ*T*P) *ᵥ v) := by + simp only [Matrix.conjTranspose_eq_transpose_of_trivial,←mulVec_mulVec] + exact (dotProduct_comm _ _).trans (Matrix.dotProduct_transpose_mulVec P v (T *ᵥ (P *ᵥ v))).symm + rw [hquad,hquad,hPA,hPB] at hh + simpa [Matrix.mulVec_diagonal] using hh + have hnormal (T U:Matrix (Fin m) (Fin m) ℝ) (h:Pᴴ*T*P=U) : T=P⁻¹ᵀ*U*P⁻¹ := by + have hl':P⁻¹ᵀ*Pᵀ=1:=by rw [←Matrix.transpose_mul,hPP,Matrix.transpose_one] + rw [←h,Matrix.conjTranspose_eq_transpose_of_trivial] + calc + T=(P⁻¹ᵀ*Pᵀ)*T*(P*P⁻¹) := by rw [hl',hPP];simp + _=P⁻¹ᵀ*(Pᵀ*T*P)*P⁻¹ := by simp only [Matrix.mul_assoc] + let D:Matrix (Fin n) (Fin m) ℝ:=C*P⁻¹ᵀ + have hDA:C*A*Cᵀ=D*diagonal e*Dᵀ := by + rw [hnormal A _ hPA] + dsimp [D] + rw [Matrix.transpose_mul,Matrix.transpose_transpose] + simp only [Matrix.mul_assoc] + have hDB:C*B*Cᵀ=D*Dᵀ := by + rw [hnormal B _ hPB] + dsimp [D] + rw [Matrix.transpose_mul,Matrix.transpose_transpose] + simp only [Matrix.mul_assoc,Matrix.mul_one] + have hr:A.det/B.det=∏ i,e i := by + have ha:=congrArg Matrix.det hPA + have hb:=congrArg Matrix.det hPB + simp only [det_mul,det_conjTranspose,star_trivial,det_diagonal,det_one] at ha hb + apply (div_eq_iff hB.det_pos.ne').mpr + nlinarith [congrArg (fun x:ℝ=>x*B.det) ha,congrArg (fun x:ℝ=>x*A.det) hb] + rw [←mul_div_assoc] + apply (div_le_iff₀ hCB.det_pos).mpr + rw [hr,hDA,hDB] + exact diagonal_compression_codimension D e hl he +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter Topology Polynomial +/-- One uniform polynomial compression bound for every parameter pair with +1≤(y/z)²≤2, including the moving pair in strip-asymptotics:107. -/ +theorem twoJet_polynomial_expansion_uniform : + ∃ C:ℕ,0characteristicRatio y z p*stripDensity p) (twoJetFamily N) (twoJetFamily N)).det / + (familyGram stripDensity (twoJetFamily N) (twoJetFamily N)).det ≤ + 4*((monomialGram (C*N) (fun p=>characteristicRatio y z p*stripDensity p)).det / + (monomialGram (C*N) stripDensity).det) := by + classical + obtain ⟨C,N₀,hC,happrox⟩:=twoJet_orthonormal_polynomial_approximation + refine ⟨C,hC,?_⟩ + filter_upwards [eventually_ge_atTop N₀,eventually_ge_atTop (1:ℕ), + compressionError_eventually_small (by norm_num : 0<(1:ℝ)/2)] with N hNN hN' hsmall + intro y z hz hzy hyz2 + have hN:0characteristicRatio y z p*stripDensity p + let J:=twoJetFamily N + let F:=fun i=>finiteFamilyCombination J (T i) + let G:Fin (2*N)→ℝ→ℝ:=fun i x=>(P i).eval x + have hFm i:F i∈stripKernelSpan (angle^2):=finiteFamilyCombination_mem_stripSpan (twoJetFamily_mem N) (T i) + have hGm i:G i∈stripKernelSpan (angle^2):=polynomial_mem_stripSpan (P i) + have hcongB:familyGram stripDensity F F=T*familyGram stripDensity J J*Tᵀ:= + familyGram_congruence stripDensity J (fun i j=>stripSpan_actual_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j)) T + have hcongA:familyGram w F F=T*familyGram w J J*Tᵀ:= + familyGram_congruence w J (fun i j=>stripSpan_tilt_pair (twoJetFamily_mem N i) (twoJetFamily_mem N j) y hz) T + have hAF:(familyGram w F F).PosDef:=by + rw [hcongA] + exact posDef_real_congruence _ T (twoJetFamily_tilt_posDef N hy hz) hT + have htrans:=orthonormal_stripGram_expansion_transfer F G hFm hGm hI hE hy hz hr hAF hsmall + have hInv:(familyGram w F F).det/(familyGram stripDensity F F).det= + (familyGram w J J).det/(familyGram stripDensity J J).det:=by + rw [hcongA,hcongB] + exact determinant_quotient_congruence _ _ T hT + let Q:Matrix (Fin (2*N)) (Fin (C*N)) ℝ:=fun i j=>(P i).coeff j + have hwint k:IntegrableOn (fun p=>p^k*w p) (Set.Ioi 0):=by + simpa only [pow_one] using characteristic_tilt_moments hy hz 1 k + have hpA:familyGram w G G=Q*monomialGram (C*N) w*Qᵀ:=polynomial_family_compression P hP w hwint + have hpB:familyGram stripDensity G G=Q*monomialGram (C*N) stripDensity*Qᵀ:= + polynomial_family_compression P hP stripDensity stripDensity_moments + have hPolyA:(monomialGram (C*N) w).PosDef:=monomialGram_posDef _ w + (fun p hp=>mul_pos (characteristicRatio_pos hy hz p) (stripDensity_pos hp)) hwint + have hPolyB:(monomialGram (C*N) stripDensity).PosDef:=monomialGram_posDef _ stripDensity + (fun _ hp=>stripDensity_pos hp) stripDensity_moments + have hQB:(Q*monomialGram (C*N) stripDensity*Qᵀ).PosDef:=by rw [←hpB];exact htrans.1 + have hExpand:∀ v:Fin (C*N)→ℝ,(1:ℝ)*(v ⬝ᵥ (monomialGram (C*N) stripDensity *ᵥ v))≤v ⬝ᵥ (monomialGram (C*N) w *ᵥ v):=by + intro v + rw [one_mul,monomialGram_quadratic _ stripDensity_moments,monomialGram_quadratic _ hwint] + apply integral_mono_ae (weightedPolynomialNorm_integrable _ stripDensity_moments _) + (weightedPolynomialNorm_integrable _ hwint _) + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hh:=mul_le_mul_of_nonneg_right (hr p hp).1 + (mul_nonneg (sq_nonneg ((Polynomial.ofFn (C*N) v).eval (p^2))) (stripDensity_pos hp).le) + change _≤_*(characteristicRatio y z p*stripDensity p) + nlinarith only [hh] + have hpoly:=positive_compression_codimension _ _ Q hPolyA hPolyB hQB (by norm_num : (0:ℝ)≤1) hExpand + simp only [one_pow,one_mul] at hpoly + rw [←hpA,←hpB] at hpoly + have hu:=htrans.2 + change ((familyGram w F F).det/(familyGram stripDensity F F).det)/4≤ + (familyGram w G G).det/(familyGram stripDensity G G).det at hu + rw [hInv] at hu + change (familyGram w J J).det/(familyGram stripDensity J J).det≤ + 4*((monomialGram (C*N) w).det/(monomialGram (C*N) stripDensity).det) + linarith [hu.trans hpoly] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/LaplaceProducts.lean b/lean/OAI/Combinatorics/HoneycombChords/LaplaceProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..07d12c98c663794c3436bc7179dd08ab7098f62f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/LaplaceProducts.lean @@ -0,0 +1,399 @@ +import OAI.Combinatorics.HoneycombChords.ObliqueProjection + +namespace OAI + +/-! Euler products and positive rational approximants of the strip test functions. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Finset Filter Topology + +lemma prod_range_even_odd {R : Type*} [CommMonoid R] (f : ℕ → R) (n : ℕ) : + (∏ j ∈ range (2*n), f j) = (∏ j ∈ range n,f (2*j))*(∏ j ∈ range n,f (2*j+1)) := by + induction n with + | zero => simp + | succ n ih => + rw [show 2*(n+1)=2*n+1+1 by omega,prod_range_succ,prod_range_succ,ih, + prod_range_succ,prod_range_succ] + ac_rfl + +noncomputable def cosineEulerProduct (z : ℂ) (n : ℕ) : ℂ := + ∏ j ∈ range n,(1-4*z^2/((Real.pi:ℂ)^2*(2*(j:ℂ)+1)^2)) + +lemma cosineEulerProduct_relation (z : ℂ) (n : ℕ) : + (∏ j ∈ range (2*n),((1:ℂ)-(2*z/(Real.pi:ℂ))^2/((j:ℂ)+1)^2)) = + cosineEulerProduct z n * (∏ j ∈ range n,((1:ℂ)-(z/(Real.pi:ℂ))^2/((j:ℂ)+1)^2)) := by + rw [prod_range_even_odd] + apply congrArg₂ (·*·) + · unfold cosineEulerProduct + apply prod_congr rfl + intro j hj + push_cast + have hp : (Real.pi:ℂ)≠0 := Complex.ofReal_ne_zero.mpr Real.pi_ne_zero + have hj : 2*(j:ℂ)+1≠0 := by exact_mod_cast (show (2*j+1:ℕ)≠0 by omega) + field_simp [hp,hj] + ring + · apply prod_congr rfl + intro j hj + push_cast + have hj : (j:ℂ)+1≠0 := Nat.cast_add_one_ne_zero j + have hp : (Real.pi:ℂ)≠0 := Complex.ofReal_ne_zero.mpr Real.pi_ne_zero + have hk : 2*(j:ℂ)+1+1≠0 := by exact_mod_cast (show (2*j+1+1:ℕ)≠0 by omega) + field_simp [hp,hj,hk] + ring + +lemma tendsto_cosineEulerProduct {z : ℂ} (hz : Complex.sin z ≠ 0) : + Tendsto (cosineEulerProduct z) atTop (𝓝 (Complex.cos z)) := by + have hz0 : z≠0 := by intro h;apply hz;simp [h] + have hp : (Real.pi:ℂ)≠0 := Complex.ofReal_ne_zero.mpr Real.pi_ne_zero + have h₁ := Complex.tendsto_euler_sin_prod (z/(Real.pi:ℂ)) + have h₂ := (Complex.tendsto_euler_sin_prod (2*z/(Real.pi:ℂ))).comp + (tendsto_id.const_mul_atTop' (by norm_num : (0:ℕ)<2)) + have he₁ : (Real.pi:ℂ)*(z/(Real.pi:ℂ))=z := by field_simp + have he₂ : (Real.pi:ℂ)*(2*z/(Real.pi:ℂ))=2*z := by field_simp + simp only [he₁] at h₁ + simp only [Function.comp_def,he₂] at h₂ + have hd := h₂.div (h₁.const_mul 2) (mul_ne_zero (by norm_num) hz) + have he : Complex.sin (2*z)/(2*Complex.sin z)=Complex.cos z := by + rw [Complex.sin_two_mul] + field_simp + rw [he] at hd + apply hd.congr' + filter_upwards [h₁.eventually (eventually_ne_nhds hz)] with n hn + dsimp only [Pi.div_apply,id_eq] + rw [cosineEulerProduct_relation] + apply (div_eq_iff (mul_ne_zero (by norm_num) hn)).mpr + ring + +noncomputable def cEulerProduct (t x : ℝ) (n : ℕ) : ℂ := + ∏ j ∈ range n,(1+4*(t:ℂ)^2*(x:ℂ)/((Real.pi:ℂ)^2*(2*(j:ℂ)+1)^2)) + +lemma cEulerProduct_eq_cosineEulerProduct {t x : ℝ} {z : ℂ} + (hz : z^2= -(t:ℂ)^2*(x:ℂ)) (n : ℕ) : + cEulerProduct t x n=cosineEulerProduct z n := by + unfold cEulerProduct cosineEulerProduct + apply prod_congr rfl + intro j hj + rw [hz] + ring + +lemma tendsto_cEulerProduct {t x : ℝ} (ht : 01 := by ext n;simp [cEulerProduct] + rw [he,C_zero] + exact tendsto_const_nhds + · let y:=t*Real.sqrt x + have hy : 0 + rcases hF with (⟨j,rfl⟩|⟨j,rfl⟩) + · refine ⟨zMonomial j,Submodule.subset_span (Or.inl (Or.inl ⟨j,rfl⟩)),?_⟩ + intro z hz + simp only [zMonomial,Complex.ofReal_pow] + · refine ⟨zCoshJet angle j,Submodule.subset_span (Or.inl (Or.inr ⟨j,rfl⟩)),?_⟩ + intro z hz + exact C_sq_jet j angle hz.le + | zero => exact ⟨0,(zDensity angle N).zero_mem,fun _ _=>rfl⟩ + | add F G hF hG hiF hiG => + obtain ⟨f,hf,hrep⟩ := hiF + obtain ⟨g,hg,hrep'⟩ := hiG + exact ⟨f+g,(zDensity angle N).add_mem hf hg,fun z hz=>congrArg₂ (·+·) (hrep z hz) (hrep' z hz)⟩ + | smul a F hF hiF => + obtain ⟨f,hf,hrep⟩ := hiF + exact ⟨a • f,(zDensity angle N).smul_mem a hf,fun z hz=>congrArg (a • ·) (hrep z hz)⟩ + rw [gBasis_span] at hF + obtain ⟨F₀,h₀,F₁,h₁,rfl⟩ := Submodule.mem_sup.mp hF + obtain ⟨f,hf,hrep⟩ := hM h₀ + obtain ⟨a,rfl⟩ := Submodule.mem_span_singleton.mp h₁ + refine ⟨f+a • zG angle,(zDensity angle N).add_mem hf + ((zDensity angle N).smul_mem a (Submodule.subset_span (Or.inr rfl))),?_⟩ + intro z hz + simp only [Pi.add_apply,Pi.smul_apply] + rw [hrep z hz,g_sq hz] + rfl + +lemma C_in_pairingDomain (N : ℕ) (u : ℝ) (hu : 2*angle+|u|C u x/D x) := by + intro j + have hg : gBasis N j ∈ admissibleDensity N := by + rw [←gBasis_span] + exact Submodule.subset_span ⟨j,rfl⟩ + obtain ⟨f,hf,hrep⟩ := restrict_admissibleDensity hg + exact pairing_div_D_integrable hrep hf u hu + +noncomputable def hZero (x : ℝ) : ℂ := (D x)⁻¹ +noncomputable def hOne (x : ℝ) : ℂ := C (angle/2) x/D x +noncomputable def cThreeCorrection : ℝ → ℂ := C (3*angle/2)-hOne + +lemma hZero_in_pairingDomain (N : ℕ) : InPairingDomain N hZero := by + have h := div_D_in_pairingDomain N 0 (by rw [abs_zero,add_zero];exact angle_lt_pi_half) + change InPairingDomain N (fun x => (D x)⁻¹) + simpa only [C_parameter_zero,one_div] using h +lemma hOne_in_pairingDomain (N : ℕ) : InPairingDomain N hOne := by + apply div_D_in_pairingDomain + rw [abs_of_pos (half_pos angle_pos)] + unfold angle + linarith [Real.pi_pos] +lemma cThree_in_pairingDomain (N : ℕ) : InPairingDomain N (C (3*angle/2)) := by + apply C_in_pairingDomain + rw [abs_of_pos (by have := angle_pos;positivity : 0<3*angle/2)] + unfold angle + linarith [Real.pi_pos] +lemma cThreeCorrection_in_pairingDomain (N : ℕ) : InPairingDomain N cThreeCorrection := + fun j=>(cThree_in_pairingDomain N j).sub (hOne_in_pairingDomain N j) + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Finset Filter Topology + +lemma C_re_pos {t x : ℝ} (ht : 0 simp + | succ n ih => + rw [show 3*(n+1)=3*n+2+1 by omega,prod_range_succ, + show 3*n+2=3*n+1+1 by omega,prod_range_succ,prod_range_succ,ih, + prod_range_succ,prod_range_succ,prod_range_succ] + simp only [show 3*n+1+1=3*n+2 by omega] + ac_rfl + +lemma hZeroProduct_eq_ratio (n : ℕ) {x : ℝ} (hx : -4≤x) : + hZeroProduct n x=cEulerProduct (angle/2) x n/cEulerProduct (3*angle/2) x (3*n) := by + rw [cEulerProduct_half,cEulerProduct_three_half,prod_range_three] + unfold hZeroProduct + rw [prod_inv_distrib,prod_mul_distrib] + have h₀ : (∏ j ∈ range n,poleFactor (3*j) x)≠0 := prod_ne_zero_iff.mpr (fun j _=>poleFactor_ne_zero _ hx) + have h₁ : (∏ j ∈ range n,poleFactor (3*j+1) x)≠0 := prod_ne_zero_iff.mpr (fun j _=>poleFactor_ne_zero _ hx) + have h₂ : (∏ j ∈ range n,poleFactor (3*j+2) x)≠0 := prod_ne_zero_iff.mpr (fun j _=>poleFactor_ne_zero _ hx) + field_simp + +lemma hOneProduct_eq_ratio (n : ℕ) {x : ℝ} (hx : -4≤x) : + hOneProduct n x=(cEulerProduct (angle/2) x n)^2/cEulerProduct (3*angle/2) x (3*n) := by + have he : hOneProduct n x=cEulerProduct (angle/2) x n*hZeroProduct n x := by + rw [cEulerProduct_half,hOneProduct,hZeroProduct,←prod_mul_distrib] + apply prod_congr rfl + intro j hj + exact div_eq_mul_inv _ _ + rw [he,hZeroProduct_eq_ratio n hx] + ring + +lemma tendsto_hZeroProduct {x : ℝ} (hx : -4≤x) : + Tendsto (fun n=>hZeroProduct n x) atTop (𝓝 (hZero x)) := by + rw [hZero_cosh_ratio hx] + have h₀:=tendsto_cEulerProduct (by linarith [angle_pos] : 0(hZeroProduct_eq_ratio n hx).symm) + +lemma tendsto_hOneProduct {x : ℝ} (hx : -4≤x) : + Tendsto (fun n=>hOneProduct n x) atTop (𝓝 (hOne x)) := by + rw [hOne_cosh_ratio hx] + have h₀:=tendsto_cEulerProduct (by linarith [angle_pos] : 0(hOneProduct_eq_ratio n hx).symm) + +end CriticalHoneycomb.FiniteFunctional + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/LaplaceProfile.lean b/lean/OAI/Combinatorics/HoneycombChords/LaplaceProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..35db459a64c4a522fe6dd993d60d9d709f173d02 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/LaplaceProfile.lean @@ -0,0 +1,127 @@ +import Mathlib + +namespace OAI + +/-! +# Scalar Laplace profile estimates + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section + +namespace CriticalHoneycomb.RenewalInput +open MeasureTheory Set Filter + +/-- Scalar comparison used in the actual bridge renewal transform. -/ +noncomputable def laplaceProfile (s x : ℝ) : ℝ := + Real.exp (-(s*x)) * (1+x)^(-(1:ℝ)/4) + +lemma laplaceProfile_pos {x : ℝ} (hx : 0 ≤ x) (s : ℝ) : 0.aestronglyMeasurable measurableSet_Ioi) ?_ + filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx + rw [Real.norm_of_nonneg (laplaceProfile_pos hx.le s).le] + exact mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow_of_nonpos hx (by linarith : x ≤ 1+x) (by norm_num)) (Real.exp_pos _).le + +lemma laplaceProfile_summable {s : ℝ} (hs : 0 push_cast <;> omega +lemma Band.sum {ι : Type*} (s : Finset ι) {d : ℕ} (p : ι→LP) + (h : ∀ i∈s,Band d (p i)) : Band d (∑ i∈s,p i) := by + classical + induction s using Finset.induction_on with + | empty => simpa using band_zero d + | @insert a s ha ih => + rw [Finset.sum_insert ha] + apply (h a (Finset.mem_insert_self _ _)).add + exact ih (fun i hi=>h i (Finset.mem_insert_of_mem hi)) +lemma Band.C_mul {d : ℕ} {p : LP} (hp : Band d p) (c : ℂ) : Band d (LaurentPolynomial.C c*p) := by + simpa only [zero_add] using (band_C c).mul hp +lemma Band.mul_C {d : ℕ} {p : LP} (hp : Band d p) (c : ℂ) : Band d (p*LaurentPolynomial.C c) := by + simpa only [add_zero] using hp.mul (band_C c) +lemma Band.pow {d : ℕ} {p : LP} (hp : Band d p) (m : ℕ) : Band (m*d) (p^m) := by + induction m with + | zero => simpa using band_C 1 + | succ m ih => simpa only [pow_succ,Nat.succ_mul] using ih.mul hp +@[simp] lemma ev_C (u : ℝ) (c : ℂ) : ev u (LaurentPolynomial.C c)=c := by simp [ev] +lemma ev_T (u : ℝ) (k : ℤ) : ev u (LaurentPolynomial.T k)=point ((k:ℝ)*u) := by + rw [ev,LaurentPolynomial.eval₂_T] + rw [Units.val_zpow_eq_zpow_val] + change (point u)^k=point ((k:ℝ)*u) + unfold point + rw [←Complex.exp_int_mul] + congr 1 + push_cast + ring +lemma ev_sum (u : ℝ) (p : LP) : ev u p=∑ k∈p.coeff.support,p.coeff k*point ((k:ℝ)*u) := by + have hp : p=∑ k∈p.coeff.support,LaurentPolynomial.C (p.coeff k)*LaurentPolynomial.T k := by + simpa only [Finsupp.sum,LaurentPolynomial.single_eq_C_mul_T] using (AddMonoidAlgebra.sum_coeff_single p).symm + conv_lhs => rw [hp] + simp only [map_sum,map_mul,ev_C,ev_T] +noncomputable def sn (a : ℝ) (k : ℤ) : LP := + LaurentPolynomial.C ((2*Complex.I)⁻¹) * + (LaurentPolynomial.C (point a)*LaurentPolynomial.T k- + LaurentPolynomial.C (point (-a))*LaurentPolynomial.T (-k)) +lemma sn_band (a : ℝ) (k : ℤ) : Band k.natAbs (sn a k) := by + apply Band.C_mul + apply Band.sub + · exact (band_T k).C_mul _ + · simpa only [Int.natAbs_neg] using (band_T (-k)).C_mul (point (-a)) +lemma ev_sn (u a : ℝ) (k : ℤ) : ev u (sn a k)=sine (a+(k:ℝ)*u) := by + simp only [sn,map_mul,map_sub,ev_C,ev_T] + rw [←point_add,←point_add] + have he : -a+((-k:ℤ):ℝ)*u= -(a+(k:ℝ)*u) := by push_cast;ring + rw [he,←sine_exp] + change _=sine (a+(k:ℝ)*u) + have hi : (2*Complex.I:ℂ)≠0 := mul_ne_zero (by norm_num) Complex.I_ne_zero + rw [←mul_assoc,inv_mul_cancel₀ hi,one_mul] + rfl +lemma top_mul {d e : ℕ} {p q : LP} (hp : Band d p) (hq : Band e q) : + (p*q).coeff (d+e)=p.coeff d*q.coeff e := by + classical + rw [AddMonoidAlgebra.coeff_mul_apply_left] + change (∑ k∈p.coeff.support,p.coeff k*q.coeff (-k+(d+e)))=_ + by_cases hd : (d:ℤ)∈p.coeff.support + · rw [Finset.sum_eq_single (d:ℤ)] + · congr 1 + congr 1 + omega + · intro k hk hkd + have hlt : (e:ℤ)< -k+(d+e) := by have:=hp k hk;omega + have hz : q.coeff (-k+(d+e))=0 := by + by_contra hz + have:=hq _ (Finsupp.mem_support_iff.mpr hz) + omega + simp [hz] + · exact fun h=>False.elim (h hd) + · have hz : p.coeff (d:ℤ)=0 := Finsupp.notMem_support_iff.mp hd + rw [hz,zero_mul] + apply Finset.sum_eq_zero + intro k hk + have hlt : (e:ℤ)< -k+(d+e) := by + have:=hp k hk + have : k≠(d:ℤ) := by intro h;subst k;exact hd hk + omega + have hzq : q.coeff (-k+(d+e))=0 := by + by_contra hzq + have:=hq _ (Finsupp.mem_support_iff.mpr hzq) + omega + simp [hzq] +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection +open scoped BigOperators +lemma coeff_C_mul (c : ℂ) (p : LP) (k : ℤ) : + (LC c*p).coeff k=c*p.coeff k := + AddMonoidAlgebra.coeff_single_zero_mul p c k +lemma coeff_mul_C (p : LP) (c : ℂ) (k : ℤ) : + (p*LC c).coeff k=p.coeff k*c := + AddMonoidAlgebra.coeff_mul_single_zero p c k +lemma coeff_add (p q : LP) (k : ℤ) : (p+q).coeff k=p.coeff k+q.coeff k := rfl +lemma coeff_sub (p q : LP) (k : ℤ) : (p-q).coeff k=p.coeff k-q.coeff k := rfl +lemma coeff_zero (k : ℤ) : (0:LP).coeff k=0 := rfl +lemma coeff_sum {ι : Type*} (s : Finset ι) (p : ι→LP) (k : ℤ) : + (∑ i∈s,p i).coeff k=∑ i∈s,(p i).coeff k := by simp +lemma Band.coeff_zero {d : ℕ} {p : LP} (hp : Band d p) {k : ℤ} (hk : (d:ℤ) simp +lemma sn_top_plus (a : ℝ) : (sn a 1).coeff 1=(2*Complex.I)⁻¹*point a := by + simp only [sn_coeff];norm_num +lemma sn_top_minus (a : ℝ) : (sn a (-1)).coeff 1= -(2*Complex.I)⁻¹*point (-a) := by + simp only [sn_coeff];norm_num +lemma sn_pair_top (a b : ℝ) (s t : ℤ) (hs : s.natAbs=1) (ht : t.natAbs=1) : + (sn a s*sn b t).coeff 2=(sn a s).coeff 1*(sn b t).coeff 1 := by + simpa only [hs,ht,Nat.cast_one,one_add_one_eq_two] using top_mul (sn_band a s) (sn_band b t) +lemma inv_two_I_sq : ((2*Complex.I)⁻¹:ℂ)^2= -1/4 := by + rw [inv_pow,mul_pow,Complex.I_sq];norm_num +lemma sn_plus_plus (a b : ℝ) : (sn a 1*sn b 1).coeff 2= -point (a+b)/4 := by + rw [sn_pair_top _ _ _ _ rfl rfl,sn_top_plus,sn_top_plus] + rw [show (2*Complex.I)⁻¹*point a*((2*Complex.I)⁻¹*point b)=((2*Complex.I)⁻¹)^2*(point a*point b) by ring] + rw [inv_two_I_sq,←point_add];ring +lemma sn_minus_minus (a b : ℝ) : (sn a (-1)*sn b (-1)).coeff 2= -point (-(a+b))/4 := by + rw [sn_pair_top _ _ _ _ rfl rfl,sn_top_minus,sn_top_minus] + rw [show -(2*Complex.I)⁻¹*point (-a)*(-(2*Complex.I)⁻¹*point (-b))=((2*Complex.I)⁻¹)^2*(point (-a)*point (-b)) by ring] + rw [inv_two_I_sq,←point_add,←neg_add];ring +lemma sn_minus_plus (a b : ℝ) : (sn a (-1)*sn b 1).coeff 2=point (b-a)/4 := by + rw [sn_pair_top _ _ _ _ rfl rfl,sn_top_minus,sn_top_plus] + rw [show -(2*Complex.I)⁻¹*point (-a)*((2*Complex.I)⁻¹*point b)= -((2*Complex.I)⁻¹)^2*(point (-a)*point b) by ring] + rw [inv_two_I_sq,←point_add,show -a+b=b-a by ring];ring +lemma sn_plus_minus (a b : ℝ) : (sn a 1*sn b (-1)).coeff 2=point (a-b)/4 := by + rw [mul_comm,sn_minus_plus] +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection +open scoped BigOperators +lemma point_pair (x : ℝ) : point x+point (-x)=2*(Real.cos x:ℂ) := by + simpa only [point,Complex.ofReal_neg,←Complex.ofReal_cos] using (Complex.two_cos (x:ℂ)).symm +lemma point_even_pi {k : ℤ} (h : Even k) : point ((k:ℝ)*Real.pi)=1 := by + obtain ⟨j,rfl⟩:=h + unfold point + convert Complex.exp_int_mul_two_pi_mul_I j using 1; congr 1; push_cast; ring +lemma point_odd_pi {k : ℤ} (h : Odd k) : point ((k:ℝ)*Real.pi)= -1 := by + obtain ⟨j,rfl⟩:=h + rw [show (((2*j+1:ℤ):ℝ)*Real.pi)=(j:ℝ)*(2*Real.pi)+Real.pi by push_cast;ring,point_add] + have hp : point ((j:ℝ)*(2*Real.pi))=1 := by + unfold point + convert Complex.exp_int_mul_two_pi_mul_I j using 1; congr 1; push_cast; ring + rw [hp,one_mul] + exact Complex.exp_pi_mul_I +lemma cheb_cos (u : ℝ) (j : ℤ) : + (Polynomial.Chebyshev.T ℂ j).eval (Real.cos (2*u):ℂ)=(Real.cos ((j:ℝ)*(2*u)):ℂ) := by + simpa only [Complex.ofReal_cos,Complex.ofReal_mul,Complex.ofReal_intCast] using + Polynomial.Chebyshev.T_complex_cos ((2*u:ℝ):ℂ) j +lemma monomial_average (u : ℝ) (k : ℤ) : + (point ((k:ℝ)*u)+point ((k:ℝ)*(-u))+point ((k:ℝ)*(u+Real.pi))+ + point ((k:ℝ)*(-u+Real.pi)))/4= + if Even k then (Polynomial.Chebyshev.T ℂ (k/2)).eval (Real.cos (2*u):ℂ) else 0 := by + have hp (v : ℝ) : point ((k:ℝ)*(v+Real.pi))=point ((k:ℝ)*v)*point ((k:ℝ)*Real.pi) := by + rw [mul_add,point_add] + rw [hp,hp,show (k:ℝ)*(-u)= -((k:ℝ)*u) by ring] + by_cases hk : Even k + · rw [ite_eq_left hk,point_even_pi hk,mul_one,mul_one,cheb_cos] + have hdiv : k/2*2=k := Int.ediv_mul_cancel (even_iff_two_dvd.mp hk) + have he : ((k/2:ℤ):ℝ)*(2*u)=(k:ℝ)*u := by + have h : ((k/2:ℤ):ℝ)*2=(k:ℝ) := by exact_mod_cast hdiv + linear_combination u*h + rw [he] + have hh:=point_pair ((k:ℝ)*u) + linear_combination hh/2 + · rw [ite_eq_right hk,point_odd_pi ((Int.even_or_odd k).resolve_left hk)] + ring +noncomputable def cosinePoly (D : ℕ) (p : LP) : Polynomial ℂ := + ∑ k∈Finset.Icc (-(2*D:ℕ):ℤ) (2*D), + if Even k then Polynomial.C (p.coeff k)*Polynomial.Chebyshev.T ℂ (k/2) else 0 +lemma cos_index_bound (D : ℕ) {k : ℤ} (hk : k∈Finset.Icc (-(2*D:ℕ):ℤ) (2*D)) : + (k/2).natAbs≤D := by + have h:=Finset.mem_Icc.mp hk + have h1 : -(D:ℤ)≤k/2 := by omega + have h2 : k/2≤(D:ℤ) := by omega + have ha : |k/2|≤(D:ℤ) := abs_le.mpr ⟨h1,h2⟩ + have hb : ((k/2).natAbs:ℤ)≤(D:ℤ) := by simpa only [Int.natCast_natAbs] using ha + exact_mod_cast hb +lemma cosinePoly_degree (D : ℕ) (p : LP) : (cosinePoly D p).natDegree≤D := by + apply Polynomial.natDegree_sum_le_of_forall_le + intro k hk + split_ifs + · exact (Polynomial.natDegree_C_mul_le _ _).trans + ((Polynomial.Chebyshev.natDegree_T ℂ (k/2)).le.trans (cos_index_bound D hk)) + · simp +lemma ev_interval {D : ℕ} {p : LP} (h : Band D p) (u : ℝ) : + ev u p=∑ k∈Finset.Icc (-(D:ℤ)) D,p.coeff k*point ((k:ℝ)*u) := by + rw [ev_sum] + apply Finset.sum_subset + · intro k hk + exact Finset.mem_Icc.mpr (h k hk) + · intro k hk hn + simp [Finsupp.notMem_support_iff.mp hn] +lemma cosinePoly_eval {D : ℕ} {p : LP} (h : Band (2*D) p) (u : ℝ) : + (cosinePoly D p).eval (Real.cos (2*u):ℂ)= + (ev u p+ev (-u) p+ev (u+Real.pi) p+ev (-u+Real.pi) p)/4 := by + simp only [cosinePoly,Polynomial.eval_finsetSum,apply_ite,Polynomial.eval_mul, + Polynomial.eval_C,Polynomial.eval_zero,ev_interval h,←Finset.sum_add_distrib,Finset.sum_div] + apply Finset.sum_congr rfl + intro k hk + have hh:=monomial_average u k + by_cases he : Even k + · simp only [ite_eq_left he] at hh ⊢ + rw [←hh] + ring + · simp only [ite_eq_right he] at hh ⊢ + linear_combination -(p.coeff k)*hh +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection +open scoped BigOperators +noncomputable def flip : LP ≃+* LP := AddMonoidAlgebra.mapDomainRingEquiv ℂ (AddEquiv.neg ℤ) +noncomputable def conjugate : LP →+* LP := + (AddMonoidAlgebra.mapRingHom ℤ (starRingEnd ℂ)).comp flip.toRingHom +lemma conjugate_coeff (p : LP) (k : ℤ) : (conjugate p).coeff k=star (p.coeff (-k)) := by + simp [conjugate,flip,AddMonoidAlgebra.coeff_mapRingHom,AddMonoidAlgebra.coeff_mapDomainRingEquiv, + Finsupp.equivMapDomain_apply] +lemma Band.conjugate {d : ℕ} {p : LP} (h : Band d p) : Band d (conjugate p) := by + intro k hk + have hn : p.coeff (-k)≠0 := by simpa only [conjugate_coeff,star_ne_zero] using Finsupp.mem_support_iff.mp hk + have:=h (-k) (Finsupp.mem_support_iff.mpr hn) + omega +lemma conjugate_single (c : ℂ) (k : ℤ) : + conjugate (AddMonoidAlgebra.single k c)=AddMonoidAlgebra.single (-k) (star c) := by + ext j + simp only [conjugate_coeff,AddMonoidAlgebra.coeff_single,Finsupp.single_apply] + by_cases h : k= -j + · simp [h] + · have h' : -k≠j := by omega + simp [h,h'] +lemma point_star (u : ℝ) : star (point u)=point (-u) := by + simp [point,←Complex.exp_conj,mul_comm] +lemma conjugate_C (c : ℂ) : conjugate (LaurentPolynomial.C c)=LaurentPolynomial.C (star c) := by + change conjugate (AddMonoidAlgebra.single 0 c)=AddMonoidAlgebra.single 0 (star c) + simpa only [neg_zero] using conjugate_single c 0 +lemma conjugate_T (k : ℤ) : conjugate (LaurentPolynomial.T k)=LaurentPolynomial.T (-k) := by + change conjugate (AddMonoidAlgebra.single k 1)=AddMonoidAlgebra.single (-k) 1 + simpa only [star_one] using conjugate_single 1 k +lemma ev_conjugate (u : ℝ) (p : LP) : ev u (conjugate p)=star (ev u p) := by + have hp : p=∑ k∈p.coeff.support,AddMonoidAlgebra.single k (p.coeff k) := + (AddMonoidAlgebra.sum_coeff_single p).symm + conv_lhs => rw [hp] + conv_rhs => rw [hp] + simp only [map_sum,star_sum,LaurentPolynomial.single_eq_C_mul_T, + map_mul,conjugate_C,conjugate_T,ev_C,ev_T,star_mul,point_star] + apply Finset.sum_congr rfl + intro k hk + rw [show ((-k:ℤ):ℝ)*u= -((k:ℝ)*u) by push_cast; ring] + exact mul_comm _ _ +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection +open scoped BigOperators +lemma continuous_ev (p : LP) : Continuous (fun u : ℝ=> ev u p) := by + simp_rw [ev_sum] + apply continuous_finsetSum + intro k hk + unfold point + fun_prop +lemma point_range_infinite : (Set.range point).Infinite := by + intro hf + have he : Complex.re '' Set.range point=Set.range Real.cos := by + rw [←Set.range_comp] + congr 1 + funext u + exact Complex.exp_ofReal_mul_I_re u + exact Real.range_cos_infinite (he ▸ hf.image Complex.re) +lemma ev_toLaurent (u : ℝ) (p : Polynomial ℂ) : ev u p.toLaurent=p.eval (point u) := by + change LaurentPolynomial.eval₂ (RingHom.id ℂ) (Units.mk0 (point u) (point_ne_zero u)) p.toLaurent=_ + rw [LaurentPolynomial.eval₂_toLaurent] + rfl + +lemma ev_eq_zero {p : LP} (he : ∀ u : ℝ,ev u p=0) : p=0 := by + obtain ⟨n,f,hf⟩:=LaurentPolynomial.exists_T_pow p + have hz : f=0 := by + apply Polynomial.eq_zero_of_infinite_isRoot + apply point_range_infinite.mono + rintro z ⟨u,rfl⟩ + change f.eval (point u)=0 + rw [←ev_toLaurent,hf,map_mul,he,zero_mul] + rw [hz,map_zero] at hf + have ht : (LaurentPolynomial.T (n:ℤ):LP)≠0 := by + apply_fun ev 0 + simp only [map_zero,ev_T] + exact point_ne_zero _ + exact (mul_eq_zero.mp hf.symm).resolve_right ht +lemma ev_ext {p q : LP} (he : ∀ u : ℝ,ev u p=ev u q) : p=q := by + apply sub_eq_zero.mp + apply ev_eq_zero + intro u + rw [map_sub,he,sub_self] +lemma ev_ext_dense {S : Set ℝ} (hS : Dense S) {p q : LP} + (he : ∀ u∈S,ev u p=ev u q) : p=q := by + apply ev_ext + intro u + exact Set.EqOn.closure he (continuous_ev p) (continuous_ev q) (by rw [hS.closure_eq];exact Set.mem_univ u) +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection +open scoped BigOperators +lemma cheb_coeff_top (D : ℕ) (k : ℤ) (hk : k.natAbs=D) : + (Polynomial.Chebyshev.T ℂ k).coeff D=2^(D-1) := by + rw [←hk,←Polynomial.Chebyshev.natDegree_T ℂ k,Polynomial.coeff_natDegree, + Polynomial.Chebyshev.leadingCoeff_T,Polynomial.Chebyshev.natDegree_T] +lemma cosinePoly_top (D : ℕ) (hD : 0 simp + have hz (k : ℤ) (hk : k∈Finset.Icc (-(2*D:ℕ):ℤ) (2*D)) + (hn : k∉({(-(2*D:ℤ)),(2*D:ℤ)} : Finset ℤ)) : + (if Even k then Polynomial.C (p.coeff k)*Polynomial.Chebyshev.T ℂ (k/2) else 0).coeff D=0 := by + by_cases he : Even k + · rw [ite_eq_left he,Polynomial.coeff_C_mul] + have hd : (Polynomial.Chebyshev.T ℂ (k/2)).natDegree + match p.1.val,p.2.val,q.1.val,q.2.val with + | 0,0,0,0 => cNum a k + | 2,2,2,2 => cNum a k + | 0,1,0,1 => vNum a k + | 1,0,1,0 => vNum a k + | 2,1,2,1 => vNum a k + | 1,2,1,2 => vNum a k + | 0,1,1,0 => aNum a k + | 1,0,0,1 => aNum a k + | 2,1,1,2 => aNum a k + | 1,2,2,1 => aNum a k + | 0,2,0,2 => dNum a k + | 0,2,1,1 => hNum a k*LC (Reflection.phase⁻¹) + | 0,2,2,0 => cNum a k+dNum a k*LC ((Reflection.phase^2)⁻¹) + | 1,1,0,2 => hNum a k*LC Reflection.phase + | 1,1,1,1 => qNum a k + | 1,1,2,0 => hNum a k*LC (Reflection.phase⁻¹) + | 2,0,0,2 => cNum a k+dNum a k*LC (Reflection.phase^2) + | 2,0,1,1 => hNum a k*LC Reflection.phase + | 2,0,2,0 => dNum a k + | _,_,_,_ => 0 +lemma ev_qNum (u a : ℝ) (k : ℤ) : ev u (qNum a k)=Q (a+(k:ℝ)*u) := by + simp only [qNum,map_mul,ev_sn,Q] + congr 1 <;> congr 1 <;> ring +lemma ev_local_coefficients (u a : ℝ) (k : ℤ) : + ev u (aNum a k)=coeffA (a+(k:ℝ)*u) ∧ + ev u (hNum a k)=coeffH (a+(k:ℝ)*u) ∧ + ev u (vNum a k)=coeffV (a+(k:ℝ)*u) ∧ + ev u (cNum a k)=coeffC (a+(k:ℝ)*u) ∧ + ev u (dNum a k)=coeffD (a+(k:ℝ)*u) := by + have he (x : ℝ) : x-a+((-k:ℤ):ℝ)*u=x-(a+(k:ℝ)*u) := by push_cast;ring + simp only [aNum,hNum,vNum,cNum,dNum,map_mul,ev_C,ev_sn,coeffA,coeffH,coeffV,coeffC,coeffD,he] + refine ⟨True.intro,True.intro,True.intro,True.intro,?_⟩ + congr 1 + congr 1 + ring +lemma ev_rNum (u a : ℝ) (k : ℤ) (p q : Pair) : + ev u (rNum a k p q)=bulkNumerator (a+(k:ℝ)*u) p q := by + obtain ⟨ha,hh,hv,hc,hd⟩:=ev_local_coefficients u a k + rcases p with ⟨p1,p2⟩;rcases q with ⟨q1,q2⟩ + fin_cases p1 <;> fin_cases p2 <;> fin_cases q1 <;> fin_cases q2 <;> + simp only [rNum,bulkNumerator,map_mul,map_add,map_zero,ev_C,ha,hh,hv,hc,hd,ev_qNum,div_eq_mul_inv] +lemma local_bands (a : ℝ) (k : ℤ) : + Band k.natAbs (aNum a k) ∧ Band k.natAbs (hNum a k) ∧ + Band (2*k.natAbs) (vNum a k) ∧ Band (2*k.natAbs) (cNum a k) ∧ + Band (2*k.natAbs) (dNum a k) ∧ Band (2*k.natAbs) (qNum a k) := by + have hs (x : ℝ) : Band k.natAbs (sn x (-k)) := by simpa using sn_band x (-k) + refine ⟨(hs _).C_mul _,(sn_band _ _).C_mul _,?_,?_,?_,?_⟩ + · simpa only [two_mul,vNum] using (hs (b-a)).mul (sn_band a k) + · simpa only [two_mul,cNum] using (hs (b-a)).mul (hs (Real.pi/4-a)) + · simpa only [two_mul,dNum] using (sn_band a k).mul (sn_band (a-L) k) + · simpa only [two_mul,qNum] using (sn_band (Real.pi/4+a) k).mul (sn_band (b+a) k) +attribute [local irreducible] Band aNum hNum vNum cNum dNum qNum sn +lemma rNum_band0 (a : ℝ) (k : ℤ) (p₂ q₁ q₂ : Spin) : Band (2*k.natAbs) (rNum a k (0,p₂) (q₁,q₂)) := by + obtain ⟨ha,hh,hv,hc,hd,hq⟩:=local_bands a k + have ha':=ha.mono (by omega : k.natAbs≤2*k.natAbs) + have hh':=hh.mono (by omega : k.natAbs≤2*k.natAbs) + fin_cases p₂ <;> fin_cases q₁ <;> fin_cases q₂ <;> simp only [rNum] <;> + first + | exact band_zero _ + | exact hc + | exact hv + | exact ha' + | exact hd + | exact hq + | exact hh'.mul_C _ + | exact hc.add (hd.mul_C _) +lemma rNum_band1 (a : ℝ) (k : ℤ) (p₂ q₁ q₂ : Spin) : Band (2*k.natAbs) (rNum a k (1,p₂) (q₁,q₂)) := by + obtain ⟨ha,hh,hv,hc,hd,hq⟩:=local_bands a k + have ha':=ha.mono (by omega : k.natAbs≤2*k.natAbs) + have hh':=hh.mono (by omega : k.natAbs≤2*k.natAbs) + fin_cases p₂ <;> fin_cases q₁ <;> fin_cases q₂ <;> simp only [rNum] <;> + first + | exact band_zero _ + | exact hc + | exact hv + | exact ha' + | exact hd + | exact hq + | exact hh'.mul_C _ +lemma rNum_band2 (a : ℝ) (k : ℤ) (p₂ q₁ q₂ : Spin) : Band (2*k.natAbs) (rNum a k (2,p₂) (q₁,q₂)) := by + obtain ⟨ha,hh,hv,hc,hd,hq⟩:=local_bands a k + have ha':=ha.mono (by omega : k.natAbs≤2*k.natAbs) + have hh':=hh.mono (by omega : k.natAbs≤2*k.natAbs) + fin_cases p₂ <;> fin_cases q₁ <;> fin_cases q₂ <;> simp only [rNum] <;> + first + | exact band_zero _ + | exact hc + | exact hv + | exact ha' + | exact hd + | exact hq + | exact hh'.mul_C _ + | exact hc.add (hd.mul_C _) +lemma rNum_band (a : ℝ) (k : ℤ) (p q : Pair) : Band (2*k.natAbs) (rNum a k p q) := by + rcases p with ⟨p₁,p₂⟩ + fin_cases p₁ + · exact rNum_band0 a k p₂ q.1 q.2 + · exact rNum_band1 a k p₂ q.1 q.2 + · exact rNum_band2 a k p₂ q.1 q.2 +noncomputable def kNum (a : ℝ) (k : ℤ) (i : Bool) (p : Pair) : LP := + LC (Reflection.phase^(spinValue p.2.rev)) * + if i then + if p.1=0 ∧ p.2.rev=1 then sn (2*a) (2*k) else + if p.1=1 ∧ p.2.rev=2 then LC Reflection.phase*sn (2*a) (2*k) else 0 + else if p.1=p.2.rev then if p.1=1 then sn (gamma+a) k else sn (gamma-a) (-k) else 0 +lemma kNum_band (a : ℝ) (k : ℤ) (i : Bool) (p : Pair) : + Band ((if i then 2 else 1)*k.natAbs) (kNum a k i p) := by + unfold kNum + apply Band.C_mul + cases i <;> simp only [Bool.false_eq_true,ite_false,ite_true,one_mul] + · split_ifs + · exact sn_band _ _ + · simpa using sn_band (gamma-a) (-k) + · exact band_zero _ + · have hs : Band (2*k.natAbs) (sn (2*a) (2*k)) := by simpa only [Int.natAbs_mul,show Int.natAbs 2=2 from rfl] using sn_band (2*a) (2*k) + split_ifs + · exact hs + · exact hs.C_mul _ + · exact band_zero _ +lemma ev_kNum (u a : ℝ) (k : ℤ) (i : Bool) (p : Pair) + (hn : sine (gamma+(a+(k:ℝ)*u))≠0) : + ev u (kNum a k i p)=sine (gamma+(a+(k:ℝ)*u))*(if i then K1 (a+(k:ℝ)*u) p else K0 (a+(k:ℝ)*u) p) := by + have he : gamma-a+((-k:ℤ):ℝ)*u=gamma-(a+(k:ℝ)*u) := by push_cast;ring + have hd : 2*a+((2*k:ℤ):ℝ)*u=2*(a+(k:ℝ)*u) := by push_cast;ring + have hp : gamma+a+(k:ℝ)*u=gamma+(a+(k:ℝ)*u) := by ring + cases i <;> unfold kNum K0 K1 boundary0 boundary1 + all_goals simp only [Bool.false_eq_true,ite_false,ite_true] + all_goals split_ifs <;> simp only [map_mul,map_zero,LC,ev_C,ev_sn,he,hd,hp] <;> field_simp [hn] ; ring +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection RasterGrid RowExchange +open scoped BigOperators +noncomputable def qPlus : ℂ := -root^14/4 +noncomputable def qMinus : ℂ := root^2/4 +noncomputable def leadWeight (s : Spin) : ℂ := if s=0 then root^12 else if s=1 then 1 else -root^4 +noncomputable def backWeight (s : Spin) : ℂ := if s=0 then -root^4 else if s=1 then 1 else root^12 +lemma v_top_plus : (vNum L 1).coeff 2=-root^14/4 := by + simp only [vNum,] + rw [sn_minus_plus,show L-(b-L)=-(((2:ℕ):ℝ)*(Real.pi/16)) by dsimp only [L,b];push_cast;ring] + rw [point_neg_angle 2 (by omega)] +lemma c_top_plus : (cNum L 1).coeff 2=root^10/4 := by + simp only [cNum,] + rw [sn_minus_minus,show -(b-L+(Real.pi/4-L))=-(((6:ℕ):ℝ)*(Real.pi/16)) by dsimp only [L,b];push_cast;ring] + rw [point_neg_angle 6 (by omega)] + all_goals norm_num +lemma d_top_plus : (dNum L 1).coeff 2=-root^2/4 := by + simp only [dNum,] + rw [sn_plus_plus,show L+(L-L)=((2:ℕ):ℝ)*(Real.pi/16) by dsimp only [L,b];push_cast;ring] + rw [point_nat_angle 2] +lemma q_top_plus : (qNum L 1).coeff 2=-root^14/4 := by + simp only [qNum,] + rw [sn_plus_plus,show Real.pi/4+L+(b+L)=((14:ℕ):ℝ)*(Real.pi/16) by dsimp only [L,b];push_cast;ring] + rw [point_nat_angle 14] +lemma v_top_minus : (vNum L (-1)).coeff 2=root^2/4 := by + simp only [vNum,neg_neg] + rw [sn_plus_minus,show b-L-L=((2:ℕ):ℝ)*(Real.pi/16) by dsimp only [L,b];push_cast;ring] + rw [point_nat_angle 2] +lemma c_top_minus : (cNum L (-1)).coeff 2=-root^6/4 := by + simp only [cNum,neg_neg] + rw [sn_plus_plus,show b-L+(Real.pi/4-L)=((6:ℕ):ℝ)*(Real.pi/16) by dsimp only [L,b];push_cast;ring] + rw [point_nat_angle 6] +lemma d_top_minus : (dNum L (-1)).coeff 2=root^14/4 := by + simp only [dNum,] + rw [sn_minus_minus,show -(L+(L-L))=-(((2:ℕ):ℝ)*(Real.pi/16)) by dsimp only [L,b];push_cast;ring] + rw [point_neg_angle 2 (by omega)] + all_goals norm_num +lemma q_top_minus : (qNum L (-1)).coeff 2=root^2/4 := by + simp only [qNum,] + rw [sn_minus_minus,show -(Real.pi/4+L+(b+L))=-(((14:ℕ):ℝ)*(Real.pi/16)) by dsimp only [L,b];push_cast;ring] + rw [point_neg_angle 14 (by omega)] + all_goals norm_num +lemma a_top_zero (k : ℤ) (hk : k.natAbs=1) : (aNum L k).coeff 2=0 := by + exact ((local_bands L k).1).coeff_zero (by rw [hk];norm_num) +lemma h_top_zero (k : ℤ) (hk : k.natAbs=1) : (hNum L k).coeff 2=0 := by + exact ((local_bands L k).2.1).coeff_zero (by rw [hk];norm_num) +lemma root_18 : root^18= -root^2 := by + rw [show 18=16+2 from rfl,pow_add,root_sixteen];ring +lemma root_20 : root^20= -root^4 := by + rw [show 20=16+4 from rfl,pow_add,root_sixteen];ring +lemma root_22 : root^22= -root^6 := by + rw [show 22=16+6 from rfl,pow_add,root_sixteen];ring +lemma root_24 : root^24= -root^8 := by + rw [show 24=16+8 from rfl,pow_add,root_sixteen];ring +lemma root_26 : root^26= -root^10 := by + rw [show 26=16+10 from rfl,pow_add,root_sixteen];ring +lemma root_28 : root^28= -root^12 := by + rw [show 28=16+12 from rfl,pow_add,root_sixteen];ring +lemma root_30 : root^30= -root^14 := by + rw [show 30=16+14 from rfl,pow_add,root_sixteen];ring +lemma r_top_plus_small (i j s t : Spin) (hj : j.val<2) : + (rNum L 1 (i,s) (j,t)).coeff 2= + if i=j ∧ s=t then qPlus*(if j=0 then leadWeight s else 1) else 0 := by + have ha:=a_top_zero 1 rfl + have hh:=h_top_zero 1 rfl + fin_cases j <;> norm_num at hj + all_goals fin_cases i <;> fin_cases s <;> fin_cases t <;> + simp only [rNum,coeff_add,coeff_mul_C,v_top_plus,c_top_plus,d_top_plus,q_top_plus, + ha,hh,coeff_zero,qPlus,leadWeight] <;> (try simp only [Reflection.phase_eq]) <;> norm_num <;> + (try ring_nf) <;> (try simp only [root_18,root_26,]) <;> ring +lemma r_top_minus_small (i j s t : Spin) (hi : i.val<2) : + (rNum L (-1) (i,s) (j,t)).coeff 2= + if i=j ∧ s=t then qMinus*(if i=0 then backWeight s else 1) else 0 := by + have ha:=a_top_zero (-1) rfl + have hh:=h_top_zero (-1) rfl + fin_cases i <;> norm_num at hi + all_goals fin_cases j <;> fin_cases s <;> fin_cases t <;> + simp only [rNum,coeff_add,coeff_mul_C,v_top_minus,c_top_minus,d_top_minus,q_top_minus, + ha,hh,coeff_zero,Reflection.phase_inv_sq,qMinus,backWeight] <;> (try simp only [Reflection.phase_eq]) <;> norm_num <;> + (try ring_nf) <;> (try simp only [root_22,]) <;> ring +lemma qPlus_mul_qMinus : qPlus*qMinus=1/16 := by + unfold qPlus qMinus + rw [show -root^14/4*(root^2/4)= -root^(14+2)/16 by ring,root_sixteen] + all_goals norm_num +lemma leadWeight_zpow (s : Spin) : leadWeight s=(-Reflection.phase)^(spinCharge s) := by + fin_cases s <;> simp [leadWeight,spinCharge,inv_neg,Reflection.phase_eq] + rw [←Reflection.phase_eq,Reflection.phase_inv,neg_neg] +lemma backWeight_zpow (s : Spin) : backWeight s=(-Reflection.phase)^(-spinCharge s) := by + fin_cases s <;> simp [backWeight,spinCharge,inv_neg,Reflection.phase_eq] + rw [←Reflection.phase_eq,Reflection.phase_inv,neg_neg] +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection RowExchange BoundaryJet +open scoped BigOperators Matrix +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def rowNum : (n : ℕ)→ℝ→ℤ→Space n→Space n→Matrix Spin Spin LP + | 0,_,_,_,_=>1 + | n+1,a,k,s,t=>fun i j=>∑ v : Spin,rNum a k (i,s 0) (v,t 0)*rowNum n a k (Fin.tail s) (Fin.tail t) v j +lemma rowNum_band (n : ℕ) (a : ℝ) (k : ℤ) (s t : Space n) (i j : Spin) : + Band (2*n*k.natAbs) (rowNum n a k s t i j) := by + induction n generalizing i j with + | zero => + simp only [rowNum,Matrix.one_apply] + split_ifs + · simpa using (band_C (1:ℂ)) + · exact band_zero _ + | succ n ih => + simp only [rowNum] + apply Band.sum + intro v hv + have h:=(rNum_band a k (i,s 0) (v,t 0)).mul (ih (Fin.tail s) (Fin.tail t) v j) + convert h using 1 ; ring +lemma ev_rNum_scaled (u a : ℝ) (k : ℤ) (p q : Pair) (hq : Q (a+(k:ℝ)*u)≠0) : + ev u (rNum a k p q)=Q (a+(k:ℝ)*u)*spectralR (a+(k:ℝ)*u) p q := by + rw [ev_rNum] + change bulkNumerator (a+(k:ℝ)*u) p q=Q (a+(k:ℝ)*u)*((Q (a+(k:ℝ)*u))⁻¹*bulkNumerator (a+(k:ℝ)*u) p q) + rw [←mul_assoc,mul_inv_cancel₀ hq,one_mul] +lemma ev_rowNum (n : ℕ) (u a : ℝ) (k : ℤ) (s t : Space n) (i j : Spin) + (hq : Q (a+(k:ℝ)*u)≠0) : + ev u (rowNum n a k s t i j)=Q (a+(k:ℝ)*u)^n * + row n (fun _=>spectralR (a+(k:ℝ)*u)) s t i j := by + induction n generalizing i j with + | zero => + simp only [rowNum,row,Matrix.one_apply,pow_zero,one_mul] + split_ifs <;> simp + | succ n ih => + simp only [rowNum,row,Matrix.mul_apply,map_sum,map_mul,ev_rNum_scaled _ _ _ _ _ hq] + simp only [ih,block,Finset.mul_sum,pow_succ] + apply Finset.sum_congr rfl + intro v hv + change Q (a+(k:ℝ)*u)*spectralR (a+(k:ℝ)*u) (i,s 0) (v,t 0) * + (Q (a+(k:ℝ)*u)^n * row n (fun _=>spectralR (a+(k:ℝ)*u)) (Fin.tail s) (Fin.tail t) v j) = + Q (a+(k:ℝ)*u)^n*Q (a+(k:ℝ)*u)*(spectralR (a+(k:ℝ)*u) (i,s 0) (v,t 0) * + row n (fun _=>spectralR (a+(k:ℝ)*u)) (Fin.tail s) (Fin.tail t) v j) + ring +noncomputable def bulkNum (n : ℕ) (s t : Space n) (p q : Pair) : LP := + ∑ v : Space n,rowNum n L 1 s v p.1 q.1 * rowNum n L (-1) v t p.2 q.2 +lemma bulkNum_band (n : ℕ) (s t : Space n) (p q : Pair) : Band (4*n) (bulkNum n s t p q) := by + apply Band.sum + intro v hv + have h:=(rowNum_band n L 1 s v p.1 q.1).mul (rowNum_band n L (-1) v t p.2 q.2) + convert h using 1 ; simp ; omega +lemma ev_bulkNum (n : ℕ) (u : ℝ) (s t : Space n) (p q : Pair) + (hp : Q (L+u)≠0) (hm : Q (L-u)≠0) : + ev u (bulkNum n s t p q)=Q (L+u)^n*Q (L-u)^n* + bulkRows n (homogeneous n) (gamma+u) s t p q := by + have hs : exactSites n (homogeneous n) (gamma+u)=fun _=>spectralR (L+u) := by + funext i + dsimp only [exactSites] + rw [show gamma+u+homogeneous n i=L+u by unfold homogeneous gamma L;ring] + have ht : exactSites n (homogeneous n) (b-(gamma+u))=fun _=>spectralR (L-u) := by + funext i + dsimp only [exactSites] + rw [show b-(gamma+u)+homogeneous n i=L-u by unfold homogeneous gamma L b;ring] + have h1 : L+(1:ℤ)*u=L+u := by simp + have h2 : L+(-1:ℤ)*u=L-u := by simp [sub_eq_add_neg] + simp only [bulkNum,map_sum,map_mul,bulkRows,hs,ht,forward,Matrix.sum_apply,Finset.mul_sum] + apply Finset.sum_congr rfl + intro v hv + rw [ev_rowNum _ _ _ _ _ _ _ _ (by simpa only [Int.cast_one,one_mul] using hp), + ev_rowNum _ _ _ _ _ _ _ _ (by simpa only [Int.cast_neg,Int.cast_one,neg_one_mul,←sub_eq_add_neg] using hm)] + simp only [Int.cast_one,Int.cast_neg,one_mul,neg_one_mul,←sub_eq_add_neg] + change _ = Q (L+u)^n*Q (L-u)^n* + (row n (fun _=>spectralR (L+u)) s v p.1 q.1 * row n (fun _=>spectralR (L-u)) v t p.2 q.2) + ring +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection RasterGrid RowExchange +open scoped BigOperators +lemma rowNum_top_step (n : ℕ) (k : ℤ) (hk : k.natAbs=1) (s t : Space (n+1)) (i j : Spin) : + (rowNum (n+1) L k s t i j).coeff (2*((n+1:ℕ):ℤ))= + ∑ v : Spin,(rNum L k (i,s 0) (v,t 0)).coeff 2* + (rowNum n L k (Fin.tail s) (Fin.tail t) v j).coeff (2*n) := by + simp only [rowNum,coeff_sum] + apply Finset.sum_congr rfl + intro v hv + have hr : Band 2 (rNum L k (i,s 0) (v,t 0)) := by simpa only [hk,mul_one] using rNum_band L k (i,s 0) (v,t 0) + have ht : Band (2*n) (rowNum n L k (Fin.tail s) (Fin.tail t) v j) := by simpa only [hk,mul_one] using rowNum_band n L k (Fin.tail s) (Fin.tail t) v j + convert top_mul hr ht using 1 <;> congr 1 ; push_cast ; ring +lemma space_eq_iff {n : ℕ} (s t : Space (n+1)) : s=t ↔ s 0=t 0 ∧ Fin.tail s=Fin.tail t := by + constructor + · rintro rfl;exact ⟨rfl,rfl⟩ + · rintro ⟨h₀,ht⟩ + funext i + refine Fin.cases h₀ (fun j=>congrFun ht j) i +noncomputable def weightProd {n : ℕ} (w : Spin→ℂ) (s : Space n) : ℂ := ∏ i,w (s i) +lemma weightProd_succ {n : ℕ} (w : Spin→ℂ) (s : Space (n+1)) : + weightProd w s=w (s 0)*weightProd w (Fin.tail s) := by + unfold weightProd + rw [Fin.prod_univ_succ] + rfl +lemma row_top_plus_small (n : ℕ) (s t : Space n) (i j : Spin) (hj : j.val<2) : + (rowNum n L 1 s t i j).coeff (2*n)= + if i=j ∧ s=t then qPlus^n*(if j=0 then weightProd leadWeight s else 1) else 0 := by + induction n generalizing i j with + | zero => + have hst : s=t := Subsingleton.elim _ _ + by_cases hij : i=j <;> simp [rowNum,hst,hij,Matrix.one_apply,weightProd] + | succ n ih => + rw [rowNum_top_step n 1 rfl] + simp_rw [ih _ _ _ _ hj,ite_and,mul_ite,mul_zero] + simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rw [r_top_plus_small _ _ _ _ hj] + by_cases hij : i=j <;> by_cases hhead : s 0=t 0 <;> by_cases htail : Fin.tail s=Fin.tail t <;> + simp [hij,hhead,htail,space_eq_iff,weightProd_succ,pow_succ] ; split_ifs <;> ring +lemma row_top_minus_small (n : ℕ) (s t : Space n) (i j : Spin) (hi : i.val<2) : + (rowNum n L (-1) s t i j).coeff (2*n)= + if i=j ∧ s=t then qMinus^n*(if i=0 then weightProd backWeight s else 1) else 0 := by + induction n generalizing i j with + | zero => + have hst : s=t := Subsingleton.elim _ _ + by_cases hij : i=j <;> simp [rowNum,hst,hij,Matrix.one_apply,weightProd] + | succ n ih => + rw [rowNum_top_step n (-1) rfl] + simp_rw [r_top_minus_small _ _ _ _ hi,ite_and,ite_mul,zero_mul] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true] + rw [ih _ _ _ _ hi] + by_cases hij : i=j <;> by_cases hhead : s 0=t 0 <;> by_cases htail : Fin.tail s=Fin.tail t <;> + simp [hij,hhead,htail,space_eq_iff,weightProd_succ,pow_succ] ; split_ifs <;> ring +lemma columnCharge_succ {n : ℕ} (s : Space (n+1)) : + columnCharge s=spinCharge (s 0)+columnCharge (Fin.tail s) := by + unfold columnCharge + rw [Fin.sum_univ_succ] + rfl +lemma weightProd_lead_zpow {n : ℕ} (s : Space n) : + weightProd leadWeight s=(-Reflection.phase)^(columnCharge s) := by + have hn : Reflection.phase≠0 := point_ne_zero _ + induction n with + | zero => simp [weightProd,columnCharge] + | succ n ih => + rw [weightProd_succ,leadWeight_zpow,ih,columnCharge_succ, + zpow_add₀ (neg_ne_zero.mpr hn)] +lemma weightProd_back_zpow {n : ℕ} (s : Space n) : + weightProd backWeight s=(-Reflection.phase)^(-columnCharge s) := by + have hn : Reflection.phase≠0 := point_ne_zero _ + induction n with + | zero => simp [weightProd,columnCharge] + | succ n ih => + rw [weightProd_succ,backWeight_zpow,ih,columnCharge_succ,neg_add, + zpow_add₀ (neg_ne_zero.mpr hn)] +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection +noncomputable def den (n : ℕ) (u : ℝ) : ℂ := + Q (L+u)^n*Q (L-u)^n*sine (b+u)*sine (b-u) +lemma sine_pair (a u : ℝ) : sine (a+u)*sine (a-u)= + ((Real.cos (2*u):ℂ)-(Real.cos (2*a):ℂ))/2 := by + have h:=Real.cos_sub (a+u) (a-u) + have hh:=Real.cos_add (a+u) (a-u) + rw [show a+u-(a-u)=2*u by ring] at h + rw [show a+u+(a-u)=2*a by ring] at hh + have he : Real.sin (a+u)*Real.sin (a-u)=(Real.cos (2*u)-Real.cos (2*a))/2 := by linarith + unfold sine + exact_mod_cast he +lemma boundary_den_cos (u : ℝ) : sine (b+u)*sine (b-u)= + ((Real.cos (2*u):ℂ)+(Real.cos (2*L):ℂ))/2 := by + rw [sine_pair,show 2*b=Real.pi-2*L by unfold b L;ring,Real.cos_pi_sub] + push_cast + ring +lemma Q_pair_cos (u : ℝ) : Q (L+u)*Q (L-u)= + (((Real.cos (2*u):ℂ)+1)*((Real.cos (2*u):ℂ)+(Real.cos (2*L):ℂ)))/4 := by + have hb : Real.pi/4+L=b := by unfold b L;ring + have hh : b+L=Real.pi/2 := by unfold b L;ring + simp only [Q,←add_assoc,←add_sub_assoc,hb,hh] + rw [show sine (b+u)*sine (Real.pi/2+u)*(sine (b-u)*sine (Real.pi/2-u))= + (sine (b+u)*sine (b-u))*(sine (Real.pi/2+u)*sine (Real.pi/2-u)) by ring] + rw [boundary_den_cos,sine_pair,show 2*(Real.pi/2)=Real.pi by ring,Real.cos_pi] + push_cast + ring +lemma den_cos (n : ℕ) (u : ℝ) : den n u= + (2:ℂ)⁻¹^(2*n+1)*((Real.cos (2*u):ℂ)+1)^n* + ((Real.cos (2*u):ℂ)+(Real.cos (2*L):ℂ))^(n+1) := by + unfold den + rw [←mul_pow,mul_assoc (_^n) (sine _) (sine _),boundary_den_cos,Q_pair_cos] + simp only [div_eq_mul_inv,mul_pow,pow_add,pow_mul,pow_one] + have hf : (4:ℂ)⁻¹=(2:ℂ)⁻¹^2 := by norm_num + rw [hf] + ring +lemma den_star (n : ℕ) (u : ℝ) : star (den n u)=den n u := by + simp only [den,Q,sine,map_mul,map_pow,Complex.star_def,Complex.conj_ofReal] +lemma den_reflection (n : ℕ) (u : ℝ) : den n (-u)=den n u := by + rw [den_cos,den_cos] + simp only [mul_neg,Real.cos_neg] +lemma den_periodicity (n : ℕ) (u : ℝ) : den n (u+Real.pi)=den n u := by + rw [den_cos,den_cos,mul_add,Real.cos_add_two_pi] +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection RowExchange BoundaryJet RasterGrid +open scoped BigOperators Matrix +noncomputable def coefficientNum (n : ℕ) (i j : Bool) (s t : Space n) : LP := + ∑ p : Pair,∑ q : Pair,kNum gamma (-1) i p*bulkNum n s t p q*kNum gamma 1 j q +lemma coefficientNum_band (n : ℕ) (i j : Bool) (s t : Space n) : + Band (4*n+2+(if i then 1 else 0)+(if j then 1 else 0)) (coefficientNum n i j s t) := by + apply Band.sum;intro p hp + apply Band.sum;intro q hq + have h:=((kNum_band gamma (-1) i p).mul (bulkNum_band n s t p q)).mul (kNum_band gamma 1 j q) + convert h using 1 ; cases i <;> cases j <;> simp <;> omega +lemma homogeneous_nonsingular_iff (n : ℕ) (hn : 0hp⟩ +lemma ev_coefficientNum (n : ℕ) (u : ℝ) (s t : Space n) (i j : Bool) + (hb : sine (b+u)≠0) (hm : sine (b-u)≠0) (hq : Q (L+u)≠0) (hq' : Q (L-u)≠0) : + ev u (coefficientNum n i j s t)=den n u*coefficient n (homogeneous n) (gamma+u) i j s t := by + have ha : gamma+((-1:ℤ):ℝ)*u=b-(gamma+u) := by unfold gamma b;push_cast;ring + have ha' : gamma+(1:ℤ)*u=gamma+u := by simp + have hp : gamma+(gamma+(1:ℤ)*u)=b+u := by unfold gamma b;push_cast;ring + have hn : gamma+(gamma+((-1:ℤ):ℝ)*u)=b-u := by unfold gamma b;push_cast;ring + have hkm (p : Pair) : ev u (kNum gamma (-1) i p)=sine (b-u)*(if i then K1 (b-(gamma+u)) p else K0 (b-(gamma+u)) p) := by + rw [ev_kNum _ _ _ _ _ (by rw [hn];exact hm),hn,ha] + have hkp (p : Pair) : ev u (kNum gamma 1 j p)=sine (b+u)*(if j then K1 (gamma+u) p else K0 (gamma+u) p) := by + rw [ev_kNum _ _ _ _ _ (by rw [hp];exact hb),hp,ha'] + simp only [coefficientNum,map_sum,map_mul,hkm,hkp,ev_bulkNum _ _ _ _ _ _ hq hq'] + simp only [coefficient,den,Finset.mul_sum] + apply Finset.sum_congr rfl;intro p hp + apply Finset.sum_congr rfl;intro q hq + ring +lemma den_ne_zero (n : ℕ) (u : ℝ) + (hb : sine (b+u)≠0) (hm : sine (b-u)≠0) (hq : Q (L+u)≠0) (hq' : Q (L-u)≠0) : + den n u≠0 := by exact mul_ne_zero (mul_ne_zero (mul_ne_zero (pow_ne_zero _ hq) (pow_ne_zero _ hq')) hb) hm +noncomputable def pairNum (n : ℕ) (a d : Jet) (s t : Space n) : LP := + LC (both (a*d))*conjugate (coefficientNum n false false s t)+ + LC (base a*right d+right a*base d)*conjugate (coefficientNum n false true s t)+ + LC (base a*left d+left a*base d)*conjugate (coefficientNum n true false s t)+ + LC (base a*base d)*conjugate (coefficientNum n true true s t) +lemma pairNum_band (n : ℕ) (a d : Jet) (s t : Space n) : Band (4*n+4) (pairNum n a d s t) := by + have h (i j : Bool) : Band (4*n+4) (conjugate (coefficientNum n i j s t)) := + ((coefficientNum_band n i j s t).mono (by cases i <;> cases j <;> simp )).conjugate + exact (((h false false).C_mul _).add ((h false true).C_mul _)).add + ((h true false).C_mul _) |>.add ((h true true).C_mul _) + +lemma both_pair_form (a d : Jet) (x y z w : ℂ) : + both (a*form x y z w*d)=both (a*d)*x+(base a*right d+right a*base d)*y+ + (base a*left d+left a*base d)*z+base a*base d*w := by + simp only [both_mul,base_mul,left_mul,right_mul,base_form,left_form,right_form,both_form] + ring +lemma ev_pairNum (n : ℕ) (u : ℝ) (a d : Jet) (s t : Space n) + (hb : sine (b+u)≠0) (hm : sine (b-u)≠0) (hq : Q (L+u)≠0) (hq' : Q (L-u)≠0) : + ev u (pairNum n a d s t)=den n u*both (a*reflectJet (T n (homogeneous n) (gamma+u) s t)*d) := by + simp only [pairNum,map_add,map_mul,LC,ev_C,ev_conjugate,ev_coefficientNum _ _ _ _ _ _ hb hm hq hq'] + rw [T_coefficients] + have hr (x y z w : ℂ) : reflectJet (form x y z w)=form (star x) (star z) (star y) (star w) := by + apply jet_ext <;> simp only [reflectJet_apply,reflected_base,reflected_left,reflected_right,reflected_both,base_form,left_form,right_form,both_form] + rw [hr,both_pair_form] + simp only [star_mul,den_star] + ring +noncomputable def scalarNum (W : ℕ) : LP := + ∑ s : Space (W+1),∑ t : Space (W+1),pairNum (W+1) (normalizedDual W s) (markedEigenvector W t) + (reflectedSites (W+1) s) (reflectedSites (W+1) t) +lemma scalarNum_band (W : ℕ) : Band (4*(W+1)+4) (scalarNum W) := by + apply Band.sum;intro s hs + apply Band.sum;intro t ht + exact pairNum_band _ _ _ _ _ +lemma ev_scalarNum (W : ℕ) (u : ℝ) (hu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+u)) : + ev u (scalarNum W)=den (W+1) u*physicalP W u := by + obtain ⟨hb,hm,hq,hq'⟩:=(homogeneous_nonsingular_iff (W+1) (by omega) u).mp hu + simp only [scalarNum,map_sum,ev_pairNum _ _ _ _ _ _ hb hm hq hq',physicalP,physicalScalar, + commonScalar,Matrix.mulVec,dotProduct,Finset.mul_sum,both_sum] + apply Finset.sum_congr rfl;intro s hs + apply Finset.sum_congr rfl;intro t ht + congr 2 + rw [mul_assoc] + rfl +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection RasterGrid RowExchange +open scoped BigOperators +lemma bulkNum_top (n : ℕ) (s t : Space n) (p q : Pair) : + (bulkNum n s t p q).coeff (4*n)= + ∑ v : Space n,(rowNum n L 1 s v p.1 q.1).coeff (2*n)* + (rowNum n L (-1) v t p.2 q.2).coeff (2*n) := by + simp only [bulkNum,coeff_sum] + apply Finset.sum_congr rfl + intro v hv + have hp : Band (2*n) (rowNum n L 1 s v p.1 q.1) := by simpa using rowNum_band n L 1 s v p.1 q.1 + have hm : Band (2*n) (rowNum n L (-1) v t p.2 q.2) := by simpa using rowNum_band n L (-1) v t p.2 q.2 + convert top_mul hp hm using 1 <;> congr 1 ; push_cast ; ring +lemma bulkNum_top_small (n : ℕ) (s t : Space n) (i j k l : Spin) (hk : k.val<2) (hj : j.val<2) : + (bulkNum n s t (i,j) (k,l)).coeff (4*n)= + if i=k ∧ j=l ∧ s=t then (1/16:ℂ)^n*(if k=0 then weightProd leadWeight s else 1)* + (if j=0 then weightProd backWeight s else 1) else 0 := by + rw [bulkNum_top] + simp_rw [row_top_plus_small _ _ _ _ _ hk,row_top_minus_small _ _ _ _ _ hj] + by_cases hi : i=k <;> by_cases hl : j=l + all_goals simp only [hi,hl,ite_false,zero_mul,mul_zero,Finset.sum_const_zero,false_and,true_and] + by_cases hst : s=t + · subst t + rw [Finset.sum_eq_single s] + · simp only [ite_true] + rw [show qPlus^n*(if k=0 then weightProd leadWeight s else 1)* + (qMinus^n*(if l=0 then weightProd backWeight s else 1))= + (qPlus*qMinus)^n*(if k=0 then weightProd leadWeight s else 1)* + (if l=0 then weightProd backWeight s else 1) by rw [mul_pow];ring, + qPlus_mul_qMinus] + · intro v hv hn + simp [hn,Ne.symm hn] + · simp + · simp only [hst,ite_false] + apply Finset.sum_eq_zero + intro v hv + by_cases hsv : s=v + · subst v;simp [hst] + · simp [hsv] +lemma kNum_true (a : ℝ) (k : ℤ) (p : Pair) : + kNum a k true p=if p=(0,1) ∨ p=(1,0) then sn (2*a) (2*k) else 0 := by + rcases p with ⟨p,q⟩ + have hp : Reflection.phase≠0 := point_ne_zero _ + fin_cases p <;> fin_cases q <;> simp [kNum,Fin.rev,spinValue,LC,←map_mul,hp,←mul_assoc] +lemma coefficientNum_TT (n : ℕ) (s t : Space n) : + coefficientNum n true true s t= + sn (2*gamma) (-2)*(bulkNum n s t (0,1) (0,1)+bulkNum n s t (0,1) (1,0)+ + bulkNum n s t (1,0) (0,1)+bulkNum n s t (1,0) (1,0))*sn (2*gamma) 2 := by + simp only [coefficientNum,kNum_true] + simp [Fintype.sum_prod_type,Fin.sum_univ_succ,mul_ite,ite_mul,] + ring +lemma wall_top_product : (sn (2*gamma) (-2)).coeff 2*(sn (2*gamma) 2).coeff 2=1/4 := by + calc + _= -((2*Complex.I)⁻¹)^2*(point (-(2*gamma))*point (2*gamma)) := by + simp only [sn_coeff] + norm_num + ring + _=1/4 := by rw [inv_two_I_sq,←point_add,neg_add_cancel];norm_num [point] +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection RasterGrid RowExchange +open scoped BigOperators +lemma wall_bulk_wall_top (n : ℕ) (p : LP) (hp : Band (4*n) p) : + (sn (2*gamma) (-2)*p*sn (2*gamma) 2).coeff (4*n+4)= + (sn (2*gamma) (-2)).coeff 2*p.coeff (4*n)*(sn (2*gamma) 2).coeff 2 := by + have hm : Band 2 (sn (2*gamma) (-2)) := sn_band (2*gamma) (-2) + have ht : Band 2 (sn (2*gamma) 2) := sn_band (2*gamma) 2 + have h : (sn (2*gamma) (-2)*p).coeff (2+4*n)= + (sn (2*gamma) (-2)).coeff 2*p.coeff (4*n) := by + simpa only [Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat] using top_mul hm hp + have hh:=top_mul (hm.mul hp) ht + simp only [Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat] at hh + rw [show (2+4*(n:ℤ))+2=4*n+4 by ring,h] at hh + exact hh +lemma coefficientNum_TT_top (n : ℕ) (s t : Space n) : + (coefficientNum n true true s t).coeff (4*n+4)= + if s=t then (1/4:ℂ)*(1/16:ℂ)^n*(weightProd leadWeight s+weightProd backWeight s) else 0 := by + rw [coefficientNum_TT,wall_bulk_wall_top _ _ + ((((bulkNum_band n s t (0,1) (0,1)).add (bulkNum_band n s t (0,1) (1,0))).add + (bulkNum_band n s t (1,0) (0,1))).add (bulkNum_band n s t (1,0) (1,0)))] + simp only [coeff_add] + rw [bulkNum_top_small _ _ _ _ _ _ _ (by decide) (by decide), + bulkNum_top_small _ _ _ _ _ _ _ (by decide) (by decide), + bulkNum_top_small _ _ _ _ _ _ _ (by decide) (by decide), + bulkNum_top_small _ _ _ _ _ _ _ (by decide) (by decide)] + by_cases h : s=t + · simp only [h,ite_true,ite_false,show (0:Spin)≠1 from by decide, + show (1:Spin)≠0 from by decide,false_and,and_self,mul_one,add_zero] + rw [show (sn (2*gamma) (-2)).coeff 2*((1/16:ℂ)^n*weightProd leadWeight t+ + (1/16:ℂ)^n*weightProd backWeight t)*(sn (2*gamma) 2).coeff 2= + ((sn (2*gamma) (-2)).coeff 2*(sn (2*gamma) 2).coeff 2)* + (1/16:ℂ)^n*(weightProd leadWeight t+weightProd backWeight t) by ring,wall_top_product] + · simp [h] +lemma coefficientNum_TT_top_zeroCharge (n : ℕ) (s t : Space n) (hs : columnCharge s=0) : + (coefficientNum n true true s t).coeff (4*n+4)= + if s=t then (1/2:ℂ)*(1/16:ℂ)^n else 0 := by + rw [coefficientNum_TT_top,weightProd_lead_zpow,weightProd_back_zpow,hs] + split_ifs <;> norm_num ; ring +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection BoundaryJet +open scoped BigOperators +lemma physicalP_reflection (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+u)) : physicalP W (-u)=physicalP W u := by + unfold physicalP + rw [show gamma+-u=b-(gamma+u) by unfold gamma b;ring,physicalScalar_reflection W (gamma+u) hu] +lemma physicalP_periodicity (W : ℕ) (u : ℝ) : physicalP W (u+Real.pi)=physicalP W u := by + unfold physicalP + rw [←add_assoc,physicalScalar_periodicity] +lemma homogeneous_nonsingular_den (n : ℕ) (hn : 0b+u) (fun x y h=>add_left_cancel h) + have h₂:=sine_zero_countable.preimage (f:=fun u : ℝ=>b-u) (fun x y h=>sub_right_injective h) + have h₃:=Q_zero_countable.preimage (f:=fun u : ℝ=>L+u) (fun x y h=>add_left_cancel h) + have h₄:=Q_zero_countable.preimage (f:=fun u : ℝ=>L-u) (fun x y h=>sub_right_injective h) + have hd:=(((h₁.union h₂).union h₃).union h₄).dense_compl ℝ + convert hd using 1 + ext u + simp only [Set.mem_ofPred_eq,homogeneous_nonsingular_iff n hn,Set.mem_compl_iff, + Set.mem_union,Set.mem_preimage,Set.mem_ofPred_eq] + tauto +lemma flip_coeff (p : LP) (k : ℤ) : (flip p).coeff k=p.coeff (-k) := by + simp [flip,AddMonoidAlgebra.coeff_mapDomainRingEquiv,Finsupp.equivMapDomain_apply] +lemma flip_C (c : ℂ) : flip (LaurentPolynomial.C c)=LaurentPolynomial.C c := by + ext k + simp only [flip_coeff,LaurentPolynomial.C_apply,neg_eq_zero] +lemma flip_T (k : ℤ) : flip (LaurentPolynomial.T k)=LaurentPolynomial.T (-k) := by + ext j + simp only [flip_coeff,LaurentPolynomial.T_apply,neg_eq_iff_eq_neg] +lemma ev_flip (u : ℝ) (p : LP) : ev u (flip p)=ev (-u) p := by + have hp : p=∑ k∈p.coeff.support,LaurentPolynomial.C (p.coeff k)*LaurentPolynomial.T k := by + simpa only [Finsupp.sum,LaurentPolynomial.single_eq_C_mul_T] using (AddMonoidAlgebra.sum_coeff_single p).symm + conv_lhs => rw [hp] + conv_rhs => rw [hp] + simp only [map_sum,map_mul,flip_C,flip_T,ev_C,ev_T] + apply Finset.sum_congr rfl + intro k hk + congr 2 + push_cast + ring +lemma scalarNum_flip (W : ℕ) : flip (scalarNum W)=scalarNum W := by + apply ev_ext_dense (dense_homogeneous_nonsingular (W+1) (by omega)) + intro u hu + have hn : Nonsingular (W+1) (homogeneous (W+1)) (gamma+-u) := by + rw [homogeneous_nonsingular_den _ (by omega),den_reflection] + exact (homogeneous_nonsingular_den _ (by omega) u).mp hu + rw [ev_flip,ev_scalarNum _ _ hn,ev_scalarNum _ _ hu,den_reflection,physicalP_reflection _ _ hu] +lemma scalarNum_coeff_reflection (W : ℕ) (k : ℤ) : (scalarNum W).coeff (-k)=(scalarNum W).coeff k := by + rw [←flip_coeff,scalarNum_flip] +lemma cosinePoly_physical (W : ℕ) (u : ℝ) + (hu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+u)) : + (cosinePoly (2*(W+1)+2) (scalarNum W)).eval (Real.cos (2*u):ℂ)=den (W+1) u*physicalP W u := by + have hh : Band (2*(2*(W+1)+2)) (scalarNum W) := by convert scalarNum_band W using 1 ; omega + rw [cosinePoly_eval hh] + have hd:= (homogeneous_nonsingular_den _ (by omega) u).mp hu + have hnu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+-u) := by + rw [homogeneous_nonsingular_den _ (by omega),den_reflection];exact hd + have hpu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+(u+Real.pi)) := by + rw [homogeneous_nonsingular_den _ (by omega),den_periodicity];exact hd + have hnpu : Nonsingular (W+1) (homogeneous (W+1)) (gamma+(-u+Real.pi)) := by + rw [homogeneous_nonsingular_den _ (by omega),den_periodicity,den_reflection];exact hd + rw [ev_scalarNum _ _ hu,ev_scalarNum _ _ hnu,ev_scalarNum _ _ hpu,ev_scalarNum _ _ hnpu, + den_periodicity,den_periodicity,den_reflection,physicalP_periodicity,physicalP_periodicity, + physicalP_reflection _ _ hu] + ring +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Reflection RasterGrid RowExchange BoundaryJet +open scoped BigOperators +lemma pairNum_bottom (n : ℕ) (a d : Jet) (s t : Space n) : + (pairNum n a d s t).coeff (-(4*n+4))= + base a*base d*star ((coefficientNum n true true s t).coeff (4*n+4)) := by + have h (i j : Bool) (hij : i=false ∨ j=false) : + (coefficientNum n i j s t).coeff (4*n+4)=0 := by + apply (coefficientNum_band n i j s t).coeff_zero + cases i <;> cases j <;> simp_all <;> omega + simp only [pairNum,coeff_add,coeff_C_mul,conjugate_coeff,neg_neg, + h false false (Or.inl rfl),h false true (Or.inl rfl),h true false (Or.inr rfl), + star_zero,mul_zero,zero_add] +lemma spinCharge_rev (s : Spin) : spinCharge s.rev= -spinCharge s := by + fin_cases s <;> norm_num [spinCharge,Fin.rev] +lemma reflectedSites_charge (n : ℕ) (s : Space n) : + columnCharge (reflectedSites n s)= -columnCharge s := by + change (∑ i : Fin n,spinCharge ((s i.rev).rev))= -(∑ i : Fin n,spinCharge (s i)) + simp_rw [spinCharge_rev] + rw [Finset.sum_neg_distrib,neg_inj] + exact Equiv.sum_comp Fin.revPerm (fun i=>spinCharge (s i)) +lemma base_normalizedDual (W : ℕ) (s : Space (W+1)) : + base (normalizedDual W s)=archRow W s := by + simp [normalizedDual,inverseAtOne,dualEigenvector] +lemma base_markedEigenvector (W : ℕ) (s : Space (W+1)) : + base (markedEigenvector W s)=archColumn W s := by simp [markedEigenvector] +lemma physical_pair_bottom (W : ℕ) (s t : Space (W+1)) : + (pairNum (W+1) (normalizedDual W s) (markedEigenvector W t) + (reflectedSites (W+1) s) (reflectedSites (W+1) t)).coeff (-(4*((W+1:ℕ):ℤ)+4))= + if s=t then archRow W s*archColumn W s*((1/2:ℂ)*(1/16:ℂ)^(W+1)) else 0 := by + rw [pairNum_bottom,base_normalizedDual,base_markedEigenvector] + by_cases hst : s=t + · subst t + by_cases hs : columnCharge s=0 + · rw [coefficientNum_TT_top_zeroCharge _ _ _ (by rw [reflectedSites_charge,hs,neg_zero])] + simp + · rw [archRow_charge s hs] + simp + · rw [coefficientNum_TT_top] + have hr : reflectedSites (W+1) s≠reflectedSites (W+1) t := + fun h=>hst ((reflectedSites (W+1)).injective h) + simp [hst,hr] +lemma scalarNum_bottom (W : ℕ) : (scalarNum W).coeff (-(4*((W+1:ℕ):ℤ)+4))=(1/2:ℂ)*(1/16:ℂ)^(W+1) := by + simp only [scalarNum,coeff_sum,physical_pair_bottom] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true] + rw [←Finset.sum_mul,arch_pairing,one_mul] +lemma scalarNum_top (W : ℕ) : (scalarNum W).coeff (4*((W+1:ℕ):ℤ)+4)=(1/2:ℂ)*(1/16:ℂ)^(W+1) := by + rw [←scalarNum_coeff_reflection,scalarNum_bottom] +noncomputable def physicalNumerator (W : ℕ) : Polynomial ℂ := + Polynomial.C ((2:ℂ)^(2*(W+1)+1))*cosinePoly (2*(W+1)+2) (scalarNum W) +lemma physicalNumerator_degree (W : ℕ) : (physicalNumerator W).natDegree≤2*(W+1)+2 := by + calc + _≤(cosinePoly (2*(W+1)+2) (scalarNum W)).natDegree := Polynomial.natDegree_C_mul_le _ _ + _≤_ := cosinePoly_degree _ _ +lemma physicalNumerator_top (W : ℕ) : (physicalNumerator W).coeff (2*(W+1)+2)=4 := by + rw [physicalNumerator,Polynomial.coeff_C_mul,cosinePoly_top _ (by omega)] + have he : (2*((2*(W+1)+2:ℕ):ℤ))=4*((W+1:ℕ):ℤ)+4 := by push_cast;ring + rw [he,scalarNum_top,scalarNum_bottom] + have hd : 2*(W+1)+2-1=2*(W+1)+1 := by omega + rw [hd] + rw [show (1/16:ℂ)^(W+1)=((2:ℂ)^(4*(W+1)))⁻¹ by rw [pow_mul,←inv_pow];norm_num] + have hp : (2:ℂ)^((2*(W+1)+1)+(2*(W+1)+1))=(2:ℂ)^(4*(W+1)+2) := by congr 1;omega + rw [show (2:ℂ)^(2*(W+1)+1)*((2:ℂ)^(2*(W+1)+1)* + ((1/2)*((2:ℂ)^(4*(W+1)))⁻¹+(1/2)*((2:ℂ)^(4*(W+1)))⁻¹))= + (2:ℂ)^((2*(W+1)+1)+(2*(W+1)+1))*((2:ℂ)^(4*(W+1)))⁻¹ by rw [pow_add];ring, + hp,pow_add,mul_assoc,mul_comm ((2:ℂ)^2),←mul_assoc,mul_inv_cancel₀ (pow_ne_zero _ (by norm_num))] + norm_num +end CriticalHoneycomb.Transfer.SpectralFamily.Trig + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily.Trig +open Polynomial +lemma drop_top_degree {p : Polynomial ℂ} {d : ℕ} + (hp : p.natDegree ≤ d+1) (hc : p.coeff (d+1)=0) : p.natDegree≤d := by + apply natDegree_le_iff_coeff_eq_zero.mpr + intro n hn + by_cases hnd : n=d+1 + · simpa only [hnd] using hc + · exact coeff_eq_zero_of_natDegree_lt (lt_of_le_of_lt hp (by omega)) +noncomputable def polePoly (N : ℕ) : Polynomial ℂ := + (X+C 1)^N*(X+C (Real.cos (2*Reflection.L):ℂ))^(N+1) +lemma polePoly_monic (N : ℕ) : (polePoly N).Monic := by + exact ((monic_X_add_C _).pow N).mul ((monic_X_add_C _).pow (N+1)) +lemma polePoly_degree (N : ℕ) : (polePoly N).natDegree=2*N+1 := by + unfold polePoly + rw [natDegree_mul ((monic_X_add_C _).pow N).ne_zero ((monic_X_add_C _).pow (N+1)).ne_zero, + natDegree_pow,natDegree_pow,natDegree_X_add_C,natDegree_X_add_C] + omega +lemma polePoly_top (N : ℕ) : (polePoly N).coeff (2*N+1)=1 := by + rw [←polePoly_degree] + exact (polePoly_monic N).coeff_natDegree +lemma polynomial_linear_decomposition {A D : Polynomial ℂ} {d : ℕ} + (hD : D.Monic) (hdeg : D.natDegree=d) + (hA : A.natDegree ≤ d+1) (hc : A.coeff (d+1)=4) (hd : 0 simp [Matrix.scalar_apply,Matrix.diagonal,Matrix.smul_apply,hij] + rw [hs] + module + rw [hm,Matrix.det_smul,Fintype.card_fin] at h + have hp : (∏ i : Fin n,(t-hA.eigenvalues i))=(-1:ℝ)^n*(∏ i : Fin n,(hA.eigenvalues i-t)) := by + simp_rw [show ∀ i : Fin n,t-hA.eigenvalues i=(-1:ℝ)*(hA.eigenvalues i-t) from fun i=>by ring] + rw [Finset.prod_mul_distrib,Finset.prod_const,Finset.card_univ,Fintype.card_fin] + rw [hp] at h + exact mul_left_cancel₀ (by exact pow_ne_zero _ (by norm_num) : (-1:ℝ)^n≠0) h + +theorem positive_gram_pencil_real_factorization {n : ℕ} (A B : Matrix (Fin n) (Fin n) ℝ) + (hA : A.IsHermitian) (hB : B.PosDef) : + ∃ e : Fin n → ℝ,∀ t : ℝ,(A-t • B).det=B.det*∏ i,(e i-t) := by + classical + obtain ⟨R,hR⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hB.posSemidef.nonneg + have hdR : IsUnit R.det := by + apply isUnit_iff_ne_zero.mpr + intro hz + have hdB:=hB.det_pos + rw [hR,Matrix.det_mul] at hdB + change 0<(R.conjTranspose).det*R.det at hdB + rw [hz,mul_zero] at hdB + exact lt_irrefl _ hdB + have hRR : R*R⁻¹=1 := Matrix.mul_nonsing_inv R hdR + have hRR' : R⁻¹*R=1 := Matrix.nonsing_inv_mul R hdR + let C : Matrix (Fin n) (Fin n) ℝ := R⁻¹ᴴ*A*R⁻¹ + have hC : C.IsHermitian := Matrix.isHermitian_conjTranspose_mul_mul R⁻¹ hA + refine ⟨hC.eigenvalues,fun t=>?_⟩ + have he : A-t • B=Rᴴ*(C-t • 1)*R := by + have hleft : Rᴴ*R⁻¹ᴴ=1 := by rw [←Matrix.conjTranspose_mul,hRR',Matrix.conjTranspose_one] + dsimp [C] + rw [mul_sub,sub_mul,Matrix.mul_smul,Matrix.smul_mul,mul_one] + rw [←mul_assoc Rᴴ,←mul_assoc Rᴴ,hleft,one_mul,mul_assoc,hRR',mul_one] + rw [hR] + rfl + rw [he,Matrix.det_mul,Matrix.det_mul,hermitian_det_shift _ hC] + have hbdet : B.det=Rᴴ.det*R.det := by rw [hR,Matrix.det_mul];rfl + rw [hbdet] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +open scoped MatrixOrder + +theorem positive_pencil_normal_form {n : ℕ} (A B : Matrix (Fin n) (Fin n) ℝ) + (hA : A.IsHermitian) (hB : B.PosDef) : + ∃ (P : Matrix (Fin n) (Fin n) ℝ) (e : Fin n → ℝ), + IsUnit P.det ∧ Pᴴ*B*P=1 ∧ Pᴴ*A*P=diagonal e := by + classical + obtain ⟨R,hR⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hB.posSemidef.nonneg + have hdR : IsUnit R.det := by + apply isUnit_iff_ne_zero.mpr + intro hz + have hdB:=hB.det_pos + rw [hR,Matrix.det_mul] at hdB + change 0<(R.conjTranspose).det*R.det at hdB + rw [hz,mul_zero] at hdB + exact lt_irrefl _ hdB + have hRR : R*R⁻¹=1 := Matrix.mul_nonsing_inv R hdR + let C : Matrix (Fin n) (Fin n) ℝ := R⁻¹ᴴ*A*R⁻¹ + have hC : C.IsHermitian := Matrix.isHermitian_conjTranspose_mul_mul R⁻¹ hA + let U : Matrix (Fin n) (Fin n) ℝ := hC.eigenvectorUnitary + have hU : Uᴴ*U=1 := Unitary.coe_star_mul_self hC.eigenvectorUnitary + have hdiag : Uᴴ*C*U=diagonal hC.eigenvalues := by + have h:=hC.conjStarAlgAut_star_eigenvectorUnitary + simpa only [U,Unitary.conjStarAlgAut_star_apply,RCLike.ofReal_real_eq_id,Function.id_comp,Matrix.star_eq_conjTranspose] using h + refine ⟨R⁻¹*U,hC.eigenvalues,?_,?_,?_⟩ + · rw [Matrix.det_mul] + exact (Matrix.isUnit_nonsing_inv_det R hdR).mul (isUnit_iff_ne_zero.mpr (by + intro hz + have h:=congrArg Matrix.det hU + rw [Matrix.det_mul,hz,mul_zero,Matrix.det_one] at h + exact zero_ne_one h)) + · rw [Matrix.conjTranspose_mul,hR] + change Uᴴ*R⁻¹ᴴ*(Rᴴ*R)*(R⁻¹*U)=1 + have ht : R⁻¹ᴴ*Rᴴ=1 := by rw [←Matrix.conjTranspose_mul,hRR,Matrix.conjTranspose_one] + calc + _=Uᴴ*(R⁻¹ᴴ*Rᴴ)*(R*R⁻¹)*U := by noncomm_ring + _=1 := by rw [ht,hRR,mul_one,mul_one,hU] + · rw [Matrix.conjTranspose_mul] + calc + _=Uᴴ*C*U := by dsimp [C];noncomm_ring + _=diagonal hC.eigenvalues := hdiag +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset +/-- The affine oblique Schur complement after diagonalizing the shared +positive symmetric pencil. -/ +noncomputable def affineSchur {n : ℕ} (e a b c d : Fin n → ℝ) (D E u : ℝ) : ℝ := + D+u*E-∑ i,(a i+u*b i)*(c i+u*d i)/(e i+u) +lemma affineSchur_decomposition {n : ℕ} (e a b c d : Fin n → ℝ) (D E u : ℝ) + (he : ∀ i,e i≠0) (heu : ∀ i,e i+u≠0) : + affineSchur e a b c d D E u=affineSchur e a b c d D E 0+ + u*(E-∑ i,b i*d i)+∑ i,(a i-e i*b i)*(c i-e i*d i)*u/(e i*(e i+u)) := by + have hf (i : Fin n) : (a i+u*b i)*(c i+u*d i)/(e i+u)= + a i*c i/e i+u*(b i*d i)-(a i-e i*b i)*(c i-e i*d i)*u/(e i*(e i+u)) := by + field_simp [he i,heu i] + ring + simp_rw [affineSchur,hf,sum_sub_distrib,sum_add_distrib,←mul_sum] + simp only [zero_mul,add_zero] + ring +/-- A positive constant, nonnegative linear term and positive Stieltjes +residues give exactly the bounded-factor comparison needed in the first +oblique chain. -/ +theorem affineSchur_ratio_bounds {n : ℕ} (e a b c d : Fin n → ℝ) (D E : ℝ) + (he : ∀ i,0(a i-e i*b i)*(c i-e i*d i) + let B:=E-∑ i,b i*d i + have hf {t : ℝ} (ht : 0(he i).ne') (fun i=>(add_pos (he i) ht).ne') + have hpos {t : ℝ} (ht : 0div_nonneg (mul_nonneg (hres i) ht.le) (mul_nonneg (he i).le (add_nonneg (he i).le ht.le)))) + have hmono : f u ≤ f v := by + rw [hf hu,hf hv] + apply add_le_add (add_le_add le_rfl (mul_le_mul_of_nonneg_right huv hlin)) + apply sum_le_sum + intro i _ + have hfrac : u/(e i+u) ≤ v/(e i+v) := by + rw [div_le_div_iff₀ (add_pos (he i) hu) (add_pos (he i) hv)] + nlinarith [mul_nonneg (he i).le (sub_nonneg.mpr huv)] + have hh:=mul_le_mul_of_nonneg_left hfrac (div_nonneg (hres i) (he i).le) + convert hh using 1 <;> dsimp [R] <;> field_simp [(he i).ne',(add_pos (he i) hu).ne',(add_pos (he i) hv).ne'] + have hquot : f v/v ≤ f u/u := by + have hdiv {t : ℝ} (ht : 0b i) (Matrix.of fun _ j=>c j) (Matrix.of fun _ _=>d) +lemma blockBorder_det {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (b c : Fin n → ℝ) (d : ℝ) + (hA : IsUnit A.det) : + (blockBorder A b c d).det=A.det*(d-c ⬝ᵥ (A⁻¹ *ᵥ b)) := by + let := Matrix.invertibleOfIsUnitDet A hA + rw [blockBorder,Matrix.det_fromBlocks₁₁,Matrix.invOf_eq_nonsing_inv,Matrix.det_fin_one] + congr 1 + simp only [Matrix.sub_apply,Matrix.mul_apply,Matrix.of_apply,dotProduct,mulVec] + congr 1 + simp_rw [sum_mul,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring +lemma blockBorder_diagonal_det {n : ℕ} (e b c : Fin n → ℝ) (d : ℝ) + (he : ∀ i,e i≠0) : + (blockBorder (diagonal e) b c d).det=(∏ i,e i)*(d-∑ i,c i*b i/e i) := by + have hunit : IsUnit (diagonal e).det := isUnit_iff_ne_zero.mpr (by simpa only [Matrix.det_diagonal] using prod_ne_zero_iff.mpr (fun i _=>he i)) + rw [blockBorder_det _ _ _ _ hunit,Matrix.det_diagonal] + have hinv : (diagonal e)⁻¹=diagonal (fun i=>(e i)⁻¹) := by + exact Matrix.inv_eq_left_inv (by rw [Matrix.diagonal_mul_diagonal];simp [he]) + rw [hinv] + congr 2 + dsimp only [dotProduct] + apply sum_congr rfl + intro i _ + rw [Matrix.mulVec_diagonal] + simp only [div_eq_mul_inv] + ring +lemma blockBorder_affine_schur {n : ℕ} (e a b c d : Fin n → ℝ) (D E u : ℝ) + (he : ∀ i,e i+u≠0) : + (blockBorder (diagonal (fun i=>e i+u)) (fun i=>a i+u*b i) (fun i=>c i+u*d i) (D+u*E)).det= + (∏ i,(e i+u))*affineSchur e a b c d D E u := by + rw [blockBorder_diagonal_det _ _ _ _ he] + congr 1 + dsimp [affineSchur] + congr 1 + apply sum_congr rfl + intro i _ + ring +/-- Extension of the corner change of basis to the actual bordered pencil. -/ +noncomputable def extendCorner {n : ℕ} (P : Matrix (Fin n) (Fin n) ℝ) : + Matrix (Fin n ⊕ Fin 1) (Fin n ⊕ Fin 1) ℝ := Matrix.fromBlocks P 0 0 1 +lemma extendCorner_det {n : ℕ} (P : Matrix (Fin n) (Fin n) ℝ) : (extendCorner P).det=P.det := by + simp [extendCorner] +lemma blockBorder_congruence {n : ℕ} (A P : Matrix (Fin n) (Fin n) ℝ) (b c : Fin n → ℝ) (d : ℝ) : + (extendCorner P)ᴴ*blockBorder A b c d*extendCorner P= + blockBorder (Pᴴ*A*P) (Pᴴ *ᵥ b) (c ᵥ* P) d := by + simp only [extendCorner,blockBorder,Matrix.fromBlocks_conjTranspose,Matrix.conjTranspose_zero, + Matrix.conjTranspose_one,Matrix.fromBlocks_multiply,Matrix.zero_mul,Matrix.mul_zero, + add_zero,zero_add,Matrix.one_mul,Matrix.mul_one] + congr 1 +lemma blockBorder_congruence_det {n : ℕ} (A P : Matrix (Fin n) (Fin n) ℝ) (b c : Fin n → ℝ) (d : ℝ) : + (blockBorder (Pᴴ*A*P) (Pᴴ *ᵥ b) (c ᵥ* P) d).det=P.det^2*(blockBorder A b c d).det := by + rw [←blockBorder_congruence,Matrix.det_mul,Matrix.det_mul,Matrix.det_conjTranspose,extendCorner_det] + simp only [star_trivial] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +lemma positive_pencil_normal_form_pos {n : ℕ} (A B : Matrix (Fin n) (Fin n) ℝ) + (hA : A.PosDef) (hB : B.PosDef) : + ∃ (P : Matrix (Fin n) (Fin n) ℝ) (e : Fin n → ℝ), + IsUnit P.det ∧ Pᴴ*B*P=1 ∧ Pᴴ*A*P=diagonal e ∧ ∀ i,0e i+u) := by + rw [Matrix.mul_add,Matrix.mul_smul,Matrix.add_mul,Matrix.smul_mul,hA,hB] + ext i j + by_cases h:i=j <;> simp [h] + +theorem border_pencil_ratio {n : ℕ} (A B : Matrix (Fin n) (Fin n) ℝ) + (a b c d : Fin n → ℝ) (D E : ℝ) (hA : A.PosDef) (hB : B.PosDef) + (hzero : 0<(blockBorder A a c D).det) (hlead : 0<(blockBorder B b d E).det) + (hres : ∀ r : ℝ,∀ x : Fin n → ℝ,x≠0 → x ᵥ* (A-r • B)=0 → + 0 ≤ (x ⬝ᵥ a-r*(x ⬝ᵥ b))*(x ⬝ᵥ c-r*(x ⬝ᵥ d))) + {u v : ℝ} (hu : 0(A+t • B).det + let J:=fun t : ℝ=>(blockBorder (A+t • B) (a+t • b) (c+t • d) (D+t*E)).det + u/v*(K u/K v) ≤ J u/J v ∧ J u/J v ≤ K u/K v := by + dsimp only + obtain ⟨P,e,hP,hPB,hPA,he⟩ := positive_pencil_normal_form_pos A B hA hB + let aa:=Pᴴ *ᵥ a + let bb:=Pᴴ *ᵥ b + let cc:=c ᵥ* P + let dd:=d ᵥ* P + let f:=affineSchur e aa bb cc dd D E + have hdP : P.det^2≠0 := pow_ne_zero _ (isUnit_iff_ne_zero.mp hP) + have hpP : 0e i+t) := normalForm_add A B P e hPB hPA t + have hK (t : ℝ) : P.det^2*(A+t • B).det=∏ i,(e i+t) := by + have h:=congrArg Matrix.det (hnorm t) + simpa only [Matrix.det_mul,Matrix.det_conjTranspose,star_trivial,Matrix.det_diagonal,pow_two,mul_assoc,mul_left_comm,mul_comm] using h + have hJ (t : ℝ) (ht : 0 ≤ t) : P.det^2*(blockBorder (A+t • B) (a+t • b) (c+t • d) (D+t*E)).det=(∏ i,(e i+t))*f t := by + rw [←blockBorder_congruence_det,hnorm] + simp only [Matrix.mulVec_add,Matrix.mulVec_smul,Matrix.add_vecMul,Matrix.smul_vecMul] + exact blockBorder_affine_schur e aa bb cc dd D E t (fun i=>(add_pos_of_pos_of_nonneg (he i) ht).ne') + have hz : 0he i))).mp (hh ▸ mul_pos hpP hzero) + have hlin : 0 ≤ E-∑ i,bb i*dd i := by + have hh:=blockBorder_congruence_det B P b d E + rw [hPB] at hh + have hId : (1:Matrix (Fin n) (Fin n) ℝ)=diagonal (fun _=>1) := by ext i j; simp + rw [hId,blockBorder_diagonal_det _ _ _ _ (fun _=>one_ne_zero)] at hh + simp only [prod_const_one,div_one,one_mul] at hh + have hpos : 0add_pos (he i) hv) + rw [←hh] at hpos + exact (mul_pos_iff_of_pos_left hpP).mp hpos + have hKu : 0<(A+u • B).det := by + have hh:=hK u + have hpos:=prod_pos (fun i (_ : i∈univ)=>add_pos (he i) hu) + rw [←hh] at hpos + exact (mul_pos_iff_of_pos_left hpP).mp hpos + have hratio : (blockBorder (A+u • B) (a+u • b) (c+u • d) (D+u*E)).det / + (blockBorder (A+v • B) (a+v • b) (c+v • d) (D+v*E)).det = + ((A+u • B).det/(A+v • B).det)*(f u/f v) := by + rw [←mul_div_mul_left _ _ hdP,hJ u hu.le,hJ v hv.le,mul_div_mul_comm] + congr 1 + rw [←hK u,←hK v,mul_div_mul_left _ _ hdP] + rw [hratio] + constructor + · simpa only [mul_comm] using mul_le_mul_of_nonneg_left hb.1 (div_nonneg hKu.le hKv.le) + · simpa only [mul_one] using mul_le_mul_of_nonneg_left hb.2 (div_nonneg hKu.le hKv.le) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +lemma finBorder_submatrix {n : ℕ} (M : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) : + blockBorder (M.submatrix Fin.castSucc Fin.castSucc) + (fun i=>M i.castSucc (Fin.last n)) (fun j=>M (Fin.last n) j.castSucc) (M (Fin.last n) (Fin.last n))= + M.submatrix finSumFinEquiv finSumFinEquiv := by + ext i j + rcases i with i|i <;> rcases j with j|j + · rfl + · have hi : j=0 := Subsingleton.elim _ _ + subst j + rfl + · have hi : i=0 := Subsingleton.elim _ _ + subst i + rfl + · have hi : i=0 := Subsingleton.elim _ _ + have hj : j=0 := Subsingleton.elim _ _ + subst i; subst j + rfl +lemma finBorder_det {n : ℕ} (M : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) : + (blockBorder (M.submatrix Fin.castSucc Fin.castSucc) + (fun i=>M i.castSucc (Fin.last n)) (fun j=>M (Fin.last n) j.castSucc) (M (Fin.last n) (Fin.last n))).det=M.det := by + rw [finBorder_submatrix,Matrix.det_submatrix_equiv_self] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +noncomputable def lastPairing {n : ℕ} (M : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) (x : Fin n → ℝ) : ℝ := + ((Fin.lastCases 0 x) ᵥ* M) (Fin.last n) +lemma lastPairing_dot {n : ℕ} (M : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) (x : Fin n → ℝ) : + lastPairing M x=x ⬝ᵥ (fun i=>M i.castSucc (Fin.last n)) := by + simp only [lastPairing,Matrix.vecMul,dotProduct] + rw [Fin.sum_univ_castSucc] + simp only [Fin.lastCases_castSucc,Fin.lastCases_last,zero_mul,add_zero] +lemma lastPairing_sub_smul {n : ℕ} (A B : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) (r : ℝ) (x : Fin n → ℝ) : + lastPairing (A-r • B) x=lastPairing A x-r*lastPairing B x := by + simp only [lastPairing,Matrix.vecMul_sub,Matrix.vecMul_smul,Pi.sub_apply,Pi.smul_apply,smul_eq_mul] +lemma fin_pencil_ratio {n : ℕ} (A B : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) + (hA : (A.submatrix Fin.castSucc Fin.castSucc).PosDef) + (hB : (B.submatrix Fin.castSucc Fin.castSucc).PosDef) + (hzero : 0A i.castSucc (Fin.last n) + let b:=fun i : Fin n=>B i.castSucc (Fin.last n) + let c:=fun i : Fin n=>A (Fin.last n) i.castSucc + let d:=fun i : Fin n=>B (Fin.last n) i.castSucc + let D:=A (Fin.last n) (Fin.last n) + let E:=B (Fin.last n) (Fin.last n) + have h0 : 0<(blockBorder (A.submatrix Fin.castSucc Fin.castSucc) a c D).det := by + rw [show blockBorder (A.submatrix Fin.castSucc Fin.castSucc) a c D= + blockBorder (A.submatrix Fin.castSucc Fin.castSucc) (fun i=>A i.castSucc (Fin.last n)) (fun j=>A (Fin.last n) j.castSucc) (A (Fin.last n) (Fin.last n)) from rfl,finBorder_det] + exact hzero + have h1 : 0<(blockBorder (B.submatrix Fin.castSucc Fin.castSucc) b d E).det := by + exact (finBorder_det B).symm ▸ hlead + have hr (r : ℝ) (x : Fin n → ℝ) (hx : x≠0) + (hk : x ᵥ* (A.submatrix Fin.castSucc Fin.castSucc-r • B.submatrix Fin.castSucc Fin.castSucc)=0) : + 0 ≤ (x ⬝ᵥ a-r*(x ⬝ᵥ b))*(x ⬝ᵥ c-r*(x ⬝ᵥ d)) := by + have h:=hres r x hx hk + rw [lastPairing_sub_smul,Matrix.transpose_sub,Matrix.transpose_smul,lastPairing_sub_smul] at h + simpa only [lastPairing_dot,Matrix.transpose_apply,a,b,c,d] using h + have h:=border_pencil_ratio (A.submatrix Fin.castSucc Fin.castSucc) (B.submatrix Fin.castSucc Fin.castSucc) + a b c d D E hA hB h0 h1 hr hu huv + have hd (t : ℝ) : (blockBorder (A.submatrix Fin.castSucc Fin.castSucc+t • B.submatrix Fin.castSucc Fin.castSucc) + (a+t • b) (c+t • d) (D+t*E)).det=(A+t • B).det := finBorder_det (A+t • B) + dsimp only at h + rw [hd u,hd v] at h + exact h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset + +theorem bordered_det_nonzero {n : ℕ} (B : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) + (hl : ∀ a : Fin n → ℝ,a≠0 → (Fin.lastCases 0 a) ᵥ* B≠0) + (hr : ∀ a : Fin n → ℝ,a≠0 → B *ᵥ (Fin.lastCases 0 a)≠0) + (hA : (B.submatrix Fin.castSucc Fin.castSucc).det=0) : B.det≠0 := by + intro hB + obtain ⟨a,ha,haz⟩ := Matrix.exists_vecMul_eq_zero_iff.mpr hA + obtain ⟨h,hh,hhz⟩ := Matrix.exists_mulVec_eq_zero_iff.mpr hB + let v : Fin (n+1) → ℝ := (Fin.lastCases 0 a) ᵥ* B + have hv (i : Fin n) : v i.castSucc=0 := by + have haz' := congrFun haz i + dsimp [v,Matrix.vecMul,dotProduct] + rw [Fin.sum_univ_castSucc] + simpa only [Fin.lastCases_castSucc,Fin.lastCases_last,zero_mul,add_zero,Matrix.vecMul,dotProduct,Matrix.submatrix,Matrix.of_apply,Pi.zero_apply] using haz' + have hvl : v (Fin.last n)≠0 := by + intro hz + apply hl a ha + ext i + refine Fin.lastCases ?_ (fun j=>?_) i + · exact hz + · exact hv j + have hdot : v ⬝ᵥ h=0 := by + dsimp [v] + rw [←dotProduct_mulVec,hhz,dotProduct_zero] + have hlast : h (Fin.last n)=0 := by + rw [dotProduct,Fin.sum_univ_castSucc] at hdot + have hsum : (∑ i : Fin n,v i.castSucc*h i.castSucc)=0 := by simp [hv] + rw [hsum,zero_add] at hdot + exact (mul_eq_zero.mp hdot).resolve_left hvl + let h' : Fin n → ℝ := fun i=>h i.castSucc + have heq : h=Fin.lastCases 0 h' := by + ext i + refine Fin.lastCases ?_ (fun j=>?_) i + · simpa using hlast + · simp [h'] + have hn : h'≠0 := by + intro hz + apply hh + rw [heq,hz] + ext i + refine Fin.lastCases ?_ (fun j=>?_) i <;>simp + exact hr h' hn (heq ▸ hhz) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Meixner.lean b/lean/OAI/Combinatorics/HoneycombChords/Meixner.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfa7c37a888af5186c9d8e797137cfe1ebc98027 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Meixner.lean @@ -0,0 +1,882 @@ +import Mathlib + +namespace OAI + +/-! +# Meixner and Pollaczek generating coefficients + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Filter Topology +open scoped BigOperators +variable {𝕜 : Type*} [RCLike 𝕜] +noncomputable def taylorCoeff (f : 𝕜 → 𝕜) (n : ℕ) : 𝕜 := + iteratedDeriv n f 0/(n.factorial:𝕜) +lemma taylorCoeff_zero (f : 𝕜 → 𝕜) : taylorCoeff f 0=f 0 := by simp [taylorCoeff] +lemma taylorCoeff_one (f : 𝕜 → 𝕜) : taylorCoeff f 1=deriv f 0 := by simp [taylorCoeff] +lemma taylorCoeff_congr {f g : 𝕜 → 𝕜} (h : f =ᶠ[𝓝 0] g) (n : ℕ) : + taylorCoeff f n=taylorCoeff g n := by rw [taylorCoeff,taylorCoeff,h.iteratedDeriv_eq n] +lemma taylorCoeff_add {f g : 𝕜 → 𝕜} (hf : ContDiffAt 𝕜 ⊤ f 0) (hg : ContDiffAt 𝕜 ⊤ g 0) (n : ℕ) : + taylorCoeff (fun t => f t+g t) n=taylorCoeff f n+taylorCoeff g n := by + rw [taylorCoeff,iteratedDeriv_fun_add (hf.of_le (by simp)) (hg.of_le (by simp)),add_div];rfl +lemma taylorCoeff_sub {f g : 𝕜 → 𝕜} (hf : ContDiffAt 𝕜 ⊤ f 0) (hg : ContDiffAt 𝕜 ⊤ g 0) (n : ℕ) : + taylorCoeff (fun t => f t-g t) n=taylorCoeff f n-taylorCoeff g n := by + change iteratedDeriv n (f-g) 0/(n.factorial:𝕜)=_ + rw [iteratedDeriv_sub (hf.of_le (by simp)) (hg.of_le (by simp)),sub_div];rfl +lemma taylorCoeff_const_mul (c : 𝕜) (f : 𝕜 → 𝕜) (n : ℕ) : + taylorCoeff (fun t => c*f t) n=c*taylorCoeff f n := by + rw [taylorCoeff,iteratedDeriv_const_mul_field] + unfold taylorCoeff + ring +lemma taylorCoeff_deriv (f : 𝕜 → 𝕜) (n : ℕ) : + taylorCoeff (deriv f) n=(n+1)*taylorCoeff f (n+1) := by + unfold taylorCoeff + rw [←iteratedDeriv_succ',Nat.factorial_succ] + push_cast + field_simp +lemma taylorCoeff_monomial_mul {f : 𝕜 → 𝕜} (hf : ContDiffAt 𝕜 ⊤ f 0) (n k : ℕ) : + taylorCoeff (fun t => t^k*f t) (n+k)=taylorCoeff f n := by + unfold taylorCoeff + rw [iteratedDeriv_fun_mul (by fun_prop) (hf.of_le (by simp))] + simp_rw [iteratedDeriv_fun_pow_zero] + rw [Finset.sum_eq_single k] + · simp only [ite_true,Nat.add_sub_cancel] + have he : ((n+k).choose k:𝕜)*(k.factorial:𝕜)*(n.factorial:𝕜)=((n+k).factorial:𝕜) := by + exact_mod_cast (by simpa [mul_assoc,mul_left_comm,mul_comm] using Nat.add_choose_mul_factorial_mul_factorial n k : (n+k).choose k*k.factorial*n.factorial=(n+k).factorial) + have hn : (n.factorial:𝕜) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero n + have hnk : ((n+k).factorial:𝕜) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero (n+k) + field_simp + rw [←he] + ring + · intro j hj hjk;simp [hjk] + · simp +lemma taylorCoeff_monomial_mul_low {f : 𝕜 → 𝕜} (hf : ContDiffAt 𝕜 ⊤ f 0) {n k : ℕ} (h : n < k) : + taylorCoeff (fun t => t^k*f t) n=0 := by + unfold taylorCoeff + rw [iteratedDeriv_fun_mul (by fun_prop) (hf.of_le (by simp))] + apply div_eq_zero_iff.2 + left + apply Finset.sum_eq_zero + intro j hj + have hj' : j ≤ n := by simpa using Finset.mem_range.1 hj + rw [iteratedDeriv_fun_pow_zero,ite_eq_right (show j ≠ k by omega),Nat.cast_zero,mul_zero,zero_mul] +lemma taylorCoeff_id_mul {f : 𝕜 → 𝕜} (hf : ContDiffAt 𝕜 ⊤ f 0) (n : ℕ) : + taylorCoeff (fun t => t*f t) (n+1)=taylorCoeff f n := by + simpa using taylorCoeff_monomial_mul hf n 1 +lemma taylorCoeff_sq_deriv {f : 𝕜 → 𝕜} (hf : ContDiffAt 𝕜 ⊤ f 0) (n : ℕ) : + taylorCoeff (fun t => t^2*deriv f t) (n+1)=n*taylorCoeff f n := by + have hd : ContDiffAt 𝕜 ⊤ (deriv f) 0 := hf.derivWithin (by simp) + cases n with + | zero => simp [taylorCoeff_monomial_mul_low hd (by norm_num : 1 < 2)] + | succ n => + rw [show n+1+1=n+2 by omega,taylorCoeff_monomial_mul hd n 2,taylorCoeff_deriv] + push_cast + rfl +/-- Coefficient recurrence for the exact generating differential equation. +This is local at zero; no global power series assumption is made. -/ +theorem taylorCoeff_ode_recurrence {f : 𝕜 → 𝕜} (hf : ContDiffAt 𝕜 ⊤ f 0) (a e : 𝕜) + (hode : (fun t => (1-e*t^2)*deriv f t) =ᶠ[𝓝 0] (fun t => (a+e*t)*f t)) (n : ℕ) : + (n+2)*taylorCoeff f (n+2)=a*taylorCoeff f (n+1)+e*(n+1)*taylorCoeff f n := by + have hd : ContDiffAt 𝕜 ⊤ (deriv f) 0 := hf.derivWithin (by simp) + have he : (fun t => deriv f t-e*(t^2*deriv f t)) =ᶠ[𝓝 0] + (fun t => a*f t+e*(t*f t)) := by + filter_upwards [hode] with t ht + linear_combination ht + have h := taylorCoeff_congr he (n+1) + rw [taylorCoeff_sub hd (by fun_prop),taylorCoeff_add (by fun_prop) (by fun_prop), + taylorCoeff_const_mul,taylorCoeff_const_mul,taylorCoeff_const_mul, + taylorCoeff_deriv,taylorCoeff_sq_deriv hf,taylorCoeff_id_mul hf] at h + push_cast at h ⊢ + linear_combination h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +/-! Coefficient bounds for `(1 + u)^(s - 1/2) (1 - u)^(-s - 1/2)`. Its even coefficients evaluate the polynomial Christoffel kernels at `-y²`, with `s = c*y/pi`. -/ +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +open scoped BigOperators +noncomputable def meixnerCoeff (s : ℝ) : ℕ → ℝ + | 0 => 1 + | 1 => 2*s + | n+2 => (2*s*meixnerCoeff s (n+1)+(n+1)*meixnerCoeff s n)/(n+2) +noncomputable def baseFactor (s : ℝ) (n : ℕ) : ℝ := ((n:ℝ)+s+1/2)/(n+1) +noncomputable def factorError (s : ℝ) (n : ℕ) : ℝ := (2*s-1)^2/((2*n+2)*(2*n+3)) +noncomputable def baseProduct (s : ℝ) (n : ℕ) : ℝ := ∏ j ∈ Finset.range n,baseFactor s j +noncomputable def upperProduct (s : ℝ) (n : ℕ) : ℝ := ∏ j ∈ Finset.range n,(baseFactor s j+factorError s j) +lemma baseFactor_pos {s : ℝ} (hs : 0 < s) (n : ℕ) : 0 < baseFactor s n := by + unfold baseFactor;positivity +lemma factorError_nonneg (s : ℝ) (n : ℕ) : 0 ≤ factorError s n := by + unfold factorError;positivity +lemma baseProduct_pos {s : ℝ} (hs : 0 < s) (n : ℕ) : 0 < baseProduct s n := + Finset.prod_pos (fun j _ => baseFactor_pos hs j) +lemma upperProduct_pos {s : ℝ} (hs : 0 < s) (n : ℕ) : 0 < upperProduct s n := + Finset.prod_pos (fun j _ => add_pos_of_pos_of_nonneg (baseFactor_pos hs j) (factorError_nonneg s j)) +lemma baseProduct_succ (s : ℝ) (n : ℕ) : baseProduct s (n+1)=baseProduct s n*baseFactor s n := by + exact Finset.prod_range_succ _ _ +lemma upperProduct_succ (s : ℝ) (n : ℕ) : upperProduct s (n+1)=upperProduct s n*(baseFactor s n+factorError s n) := by + exact Finset.prod_range_succ _ _ +lemma meixner_pair_step (s : ℝ) (n : ℕ) : + meixnerCoeff s (2*(n+1))=((2*n+1)/(2*n+2):ℝ)*meixnerCoeff s (2*n)+ + (2*s/(2*n+2))*meixnerCoeff s (2*n+1) ∧ + meixnerCoeff s (2*(n+1)+1)=(2*s/(2*n+3))*meixnerCoeff s (2*(n+1))+ + ((2*n+2)/(2*n+3):ℝ)*meixnerCoeff s (2*n+1) := by + constructor + · rw [show 2*(n+1)=2*n+2 by omega,meixnerCoeff] + push_cast + ring + · rw [show 2*(n+1)+1=(2*n+1)+2 by omega,meixnerCoeff] + rw [show 2*n+1+1=2*(n+1) by omega] + push_cast + ring +lemma pair_rowsums (s : ℝ) (n : ℕ) : + ((2*n+1)/(2*n+2):ℝ)+2*s/(2*n+2)=baseFactor s n ∧ + (2*s/(2*n+3))*baseFactor s n+(2*n+2)/(2*n+3)=baseFactor s n+factorError s n := by + have h1 : (2*(n:ℝ)+2) ≠ 0 := by positivity + have h2 : (2*(n:ℝ)+3) ≠ 0 := by positivity + have h3 : (n:ℝ)+1 ≠ 0 := by positivity + unfold baseFactor factorError + constructor <;> field_simp <;> ring +lemma meixner_pair_lower {s : ℝ} (hs : 0 < s) (n : ℕ) : + min 1 (2*s)*baseProduct s n ≤ meixnerCoeff s (2*n) ∧ + min 1 (2*s)*baseProduct s n ≤ meixnerCoeff s (2*n+1) := by + have hm : 0 < min 1 (2*s) := lt_min (by norm_num) (by positivity) + induction n with + | zero => simp [baseProduct,meixnerCoeff] + | succ n ih => + obtain ⟨he,ho⟩ := meixner_pair_step s n + obtain ⟨hr,hr'⟩ := pair_rowsums s n + have hA : 0 ≤ ((2*n+1)/(2*n+2):ℝ) := by positivity + have hB : 0 ≤ 2*s/(2*n+2) := by positivity + have hC : 0 ≤ 2*s/(2*n+3) := by positivity + have hD : 0 ≤ ((2*n+2)/(2*n+3):ℝ) := by positivity + have hE : 0 ≤ min 1 (2*s)*baseProduct s n := (mul_pos hm (baseProduct_pos hs n)).le + have he' : min 1 (2*s)*baseProduct s (n+1) ≤ meixnerCoeff s (2*(n+1)) := by + rw [baseProduct_succ,he] + calc + _=(((2*n+1)/(2*n+2):ℝ)+2*s/(2*n+2))*(min 1 (2*s)*baseProduct s n) := by rw [hr];ring + _≤_ := by rw [add_mul];exact add_le_add (mul_le_mul_of_nonneg_left ih.1 hA) (mul_le_mul_of_nonneg_left ih.2 hB) + refine ⟨he',?_⟩ + rw [ho,baseProduct_succ] at ⊢ + calc + _≤(baseFactor s n+factorError s n)*(min 1 (2*s)*baseProduct s n) := by + nlinarith [mul_nonneg (factorError_nonneg s n) hE] + _=(2*s/(2*n+3))*(min 1 (2*s)*baseProduct s (n+1))+ + ((2*n+2)/(2*n+3):ℝ)*(min 1 (2*s)*baseProduct s n) := by rw [baseProduct_succ,←hr'];ring + _≤_ := add_le_add (mul_le_mul_of_nonneg_left he' hC) (mul_le_mul_of_nonneg_left ih.2 hD) +lemma meixner_pair_upper {s : ℝ} (hs : 0 < s) (n : ℕ) : + meixnerCoeff s (2*n) ≤ max 1 (2*s)*upperProduct s n ∧ + meixnerCoeff s (2*n+1) ≤ max 1 (2*s)*upperProduct s n := by + have hm : 0 < max 1 (2*s) := lt_of_lt_of_le (by norm_num) (le_max_left _ _) + induction n with + | zero => simp [upperProduct,meixnerCoeff] + | succ n ih => + obtain ⟨he,ho⟩ := meixner_pair_step s n + obtain ⟨hr,hr'⟩ := pair_rowsums s n + have hA : 0 ≤ ((2*n+1)/(2*n+2):ℝ) := by positivity + have hB : 0 ≤ 2*s/(2*n+2) := by positivity + have hC : 0 ≤ 2*s/(2*n+3) := by positivity + have hD : 0 ≤ ((2*n+2)/(2*n+3):ℝ) := by positivity + have hE : 0 ≤ max 1 (2*s)*upperProduct s n := (mul_pos hm (upperProduct_pos hs n)).le + have he' : meixnerCoeff s (2*(n+1)) ≤ (max 1 (2*s)*upperProduct s n)*baseFactor s n := by + rw [he] + calc + _≤(((2*n+1)/(2*n+2):ℝ)+2*s/(2*n+2))*(max 1 (2*s)*upperProduct s n) := by + rw [add_mul];exact add_le_add (mul_le_mul_of_nonneg_left ih.1 hA) (mul_le_mul_of_nonneg_left ih.2 hB) + _=_ := by rw [hr];ring + constructor + · rw [upperProduct_succ] + exact he'.trans (by nlinarith [mul_nonneg hE (factorError_nonneg s n)]) + · rw [ho,upperProduct_succ] + calc + _≤(2*s/(2*n+3))*((max 1 (2*s)*upperProduct s n)*baseFactor s n)+ + ((2*n+2)/(2*n+3):ℝ)*(max 1 (2*s)*upperProduct s n) := + add_le_add (mul_le_mul_of_nonneg_left he' hC) (mul_le_mul_of_nonneg_left ih.2 hD) + _=_ := by rw [show (2*s/(2*n+3))*((max 1 (2*s)*upperProduct s n)*baseFactor s n)+ + ((2*n+2)/(2*n+3):ℝ)*(max 1 (2*s)*upperProduct s n)= + (max 1 (2*s)*upperProduct s n)*((2*s/(2*n+3))*baseFactor s n+(2*n+2)/(2*n+3)) by ring,hr'];ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +open scoped BigOperators +lemma baseFactor_ge_half {s : ℝ} (hs : 0 < s) (n : ℕ) : (1:ℝ)/2 ≤ baseFactor s n := by + unfold baseFactor + apply (le_div_iff₀ (by positivity)).2 + nlinarith [Nat.cast_nonneg (α:=ℝ) n] +lemma factorError_le {s : ℝ} (hs : 0 < s) (n : ℕ) : + factorError s n ≤ baseFactor s n*((2*s-1)^2/((n:ℝ)+1)^2) := by + have hden : 2*((n:ℝ)+1)^2 ≤ (2*n+2)*(2*n+3) := by + nlinarith [Nat.cast_nonneg (α:=ℝ) n,sq_nonneg (n:ℝ)] + calc + _≤(2*s-1)^2/(2*((n:ℝ)+1)^2) := + div_le_div_of_nonneg_left (sq_nonneg _) (by positivity) hden + _=(1/2)*((2*s-1)^2/((n:ℝ)+1)^2) := by rw [div_mul_eq_div_div];ring + _≤_ := mul_le_mul_of_nonneg_right (baseFactor_ge_half hs n) (by positivity) +lemma reciprocal_square_sum_bound (n : ℕ) : + (∑ j ∈ Finset.range n,(1:ℝ)/((j:ℝ)+1)^2) ≤ 2-2/((n:ℝ)+1) := by + induction n with + | zero => norm_num + | succ n ih => + rw [Finset.sum_range_succ] + push_cast + have hp : (0:ℝ) < n+1 := by positivity + have hq : (0:ℝ) < n+2 := by positivity + have hd : (1:ℝ)/((n:ℝ)+1)^2 ≤ 2/((n:ℝ)+1)-2/((n:ℝ)+2) := by + apply (div_le_iff₀ (sq_pos_of_pos hp)).2 + field_simp + nlinarith [Nat.cast_nonneg (α:=ℝ) n] + have he : (n:ℝ)+1+1=(n:ℝ)+2 := by ring + rw [he] + linarith +lemma reciprocal_square_sum_le_two (n : ℕ) : + (∑ j ∈ Finset.range n,(1:ℝ)/((j:ℝ)+1)^2) ≤ 2 := by + have h:=reciprocal_square_sum_bound n + have hp : 0 ≤ (2:ℝ)/((n:ℝ)+1) := by positivity + linarith +lemma upperProduct_le_exp {s : ℝ} (hs : 0 < s) (n : ℕ) : + upperProduct s n ≤ baseProduct s n*Real.exp (2*(2*s-1)^2) := by + have hf (j : ℕ) : baseFactor s j+factorError s j ≤ + baseFactor s j*Real.exp ((2*s-1)^2/((j:ℝ)+1)^2) := by + calc + _≤baseFactor s j*(1+(2*s-1)^2/((j:ℝ)+1)^2) := by nlinarith [factorError_le hs j] + _≤_ := mul_le_mul_of_nonneg_left (by simpa [add_comm] using Real.add_one_le_exp ((2*s-1)^2/((j:ℝ)+1)^2)) (baseFactor_pos hs j).le + calc + _≤∏ j ∈ Finset.range n,baseFactor s j*Real.exp ((2*s-1)^2/((j:ℝ)+1)^2) := by + apply Finset.prod_le_prod₀ + · intro j hj;exact add_nonneg (baseFactor_pos hs j).le (factorError_nonneg s j) + · intro j hj;exact hf j + _=baseProduct s n*Real.exp ((2*s-1)^2*(∑ j ∈ Finset.range n,(1:ℝ)/((j:ℝ)+1)^2)) := by + rw [Finset.prod_mul_distrib,←Real.exp_sum] + congr 2 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + ring + _≤_ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.2 (by nlinarith [mul_le_mul_of_nonneg_left (reciprocal_square_sum_le_two n) (sq_nonneg (2*s-1))])) (baseProduct_pos hs n).le +/-- Uniform bounds on the exact recurrence; the finite products have exponent +s-1/2, obtained by Euler's Gamma limit in ProductGammaAsymptotic. -/ +theorem meixner_even_product_bounds {s : ℝ} (hs : 0 < s) (n : ℕ) : + min 1 (2*s)*baseProduct s n ≤ meixnerCoeff s (2*n) ∧ + meixnerCoeff s (2*n) ≤ (max 1 (2*s)*Real.exp (2*(2*s-1)^2))*baseProduct s n := by + refine ⟨(meixner_pair_lower hs n).1,?_⟩ + calc + _ ≤ max 1 (2*s)*upperProduct s n := (meixner_pair_upper hs n).1 + _ ≤ max 1 (2*s)*(baseProduct s n*Real.exp (2*(2*s-1)^2)) := + mul_le_mul_of_nonneg_left (upperProduct_le_exp hs n) (by positivity) + _=_ := by ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +open scoped BigOperators +noncomputable def pochRatio (a : ℝ) (n : ℕ) : ℝ := + ∏ j ∈ Finset.range n,(a+j)/(j+1) +lemma pochRatio_formula (a : ℝ) (n : ℕ) : + pochRatio a n=(∏ j ∈ Finset.range n,(a+j))/(n.factorial:ℝ) := by + unfold pochRatio + rw [Finset.prod_div_distrib] + congr 1 + exact_mod_cast Finset.prod_range_add_one_eq_factorial n +lemma pochRatio_gamma_identity {a : ℝ} (ha : 0 < a) (n : ℕ) : + GammaSeq a n*(pochRatio a (n+1)/((n:ℝ)+1)^(a-1))=((n:ℝ)/(n+1))^a := by + have hp : (∏ j ∈ Finset.range (n+1),(a+j)) ≠ 0 := + (Finset.prod_pos (fun j _ => by positivity)).ne' + have hn : (n:ℝ)+1 ≠ 0 := by positivity + have hnf : (n.factorial:ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero n + have hpow : ((n:ℝ)+1)^a ≠ 0 := (Real.rpow_pos_of_pos (by positivity) _).ne' + rw [Real.div_rpow (Nat.cast_nonneg n) (by positivity),Real.rpow_sub_one hn, + pochRatio_formula,GammaSeq,Nat.factorial_succ] + push_cast + field_simp +lemma pochRatio_normalized_tendsto {a : ℝ} (ha : 0 < a) : + Tendsto (fun n : ℕ => pochRatio a (n+1)/((n:ℝ)+1)^(a-1)) atTop (𝓝 (1/Gamma a)) := by + have hΓ : Gamma a ≠ 0 := (Real.Gamma_pos_of_pos ha).ne' + have hq := ((tendsto_natCast_div_add_atTop (1:ℝ)).rpow_const (p:=a) (Or.inl one_ne_zero)).div + (GammaSeq_tendsto_Gamma a) hΓ + simp only [Real.one_rpow] at hq + apply hq.congr' + filter_upwards [eventually_gt_atTop (0:ℕ)] with n hn + have hgp : GammaSeq a n ≠ 0 := by + unfold GammaSeq + apply div_ne_zero + · exact mul_ne_zero (Real.rpow_pos_of_pos (by exact_mod_cast hn) _).ne' (by exact_mod_cast Nat.factorial_ne_zero n) + · exact (Finset.prod_pos (fun j _ => by positivity)).ne' + exact (eq_div_iff hgp).2 (by rw [mul_comm,pochRatio_gamma_identity ha]) |>.symm +/-- Constant-factor, not epsilon-loss, asymptotics for the rising-factorial +product needed by the polynomial determinant compression. -/ +lemma pochRatio_eventual_bounds {a : ℝ} (ha : 0 < a) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + c*((n:ℝ)+1)^(a-1) ≤ pochRatio a (n+1) ∧ + pochRatio a (n+1) ≤ C*((n:ℝ)+1)^(a-1) := by + have hp : 0 < 1/Gamma a := one_div_pos.2 (Real.Gamma_pos_of_pos ha) + have ht := pochRatio_normalized_tendsto ha + refine ⟨(1/Gamma a)/2,2*(1/Gamma a),by positivity,by positivity,?_⟩ + have he := (tendsto_order.1 ht).1 ((1/Gamma a)/2) (by linarith) + have hf := (tendsto_order.1 ht).2 (2*(1/Gamma a)) (by linarith) + filter_upwards [he,hf] with n hn hm + have hr : 0 < ((n:ℝ)+1)^(a-1) := Real.rpow_pos_of_pos (by positivity) _ + exact ⟨(le_div_iff₀ hr).1 hn.le,(div_le_iff₀ hr).1 hm.le⟩ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +open scoped BigOperators +lemma positive_sequence_global_bounds {f : ℕ → ℝ} {l : ℝ} + (hf : ∀ n,0 < f n) (hl : 0 < l) (ht : Tendsto f atTop (𝓝 l)) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n,c ≤ f n ∧ f n ≤ C := by + obtain ⟨C,hC⟩ := ht.bddAbove_range + obtain ⟨D,hD⟩ := (ht.inv₀ hl.ne').bddAbove_range + have hc : 0 < C := lt_of_lt_of_le (hf 0) (hC (Set.mem_range_self 0)) + have hd : 0 < D := lt_of_lt_of_le (inv_pos.2 (hf 0)) (hD (Set.mem_range_self 0)) + refine ⟨D⁻¹,C,inv_pos.2 hd,hc,fun n => ⟨?_,hC (Set.mem_range_self n)⟩⟩ + exact (inv_le_comm₀ hd (hf n)).2 (hD (Set.mem_range_self n)) +lemma baseProduct_eq_poch (s : ℝ) (n : ℕ) : + baseProduct s n=pochRatio (s+1/2) n := by + unfold baseProduct baseFactor pochRatio + apply Finset.prod_congr rfl + intro j hj + congr 1 + ring +lemma pochRatio_pos {a : ℝ} (ha : 0 < a) (n : ℕ) : 0 < pochRatio a n := + Finset.prod_pos (fun j _ => div_pos (by positivity) (by positivity)) +lemma pochRatio_succ (a : ℝ) (n : ℕ) : + pochRatio a (n+1)=pochRatio a n*((a+n)/(n+1)) := Finset.prod_range_succ _ _ +lemma baseProduct_square_normalized_tendsto {s : ℝ} (hs : 0 < s) : + Tendsto (fun n : ℕ => baseProduct s n^2/pochRatio (2*s) n) atTop + (𝓝 ((1/Gamma (s+1/2))^2/(1/Gamma (2*s)))) := by + have ha : 0 < s+1/2 := by linarith + have hb : 0 < 2*s := by positivity + have h := ((pochRatio_normalized_tendsto ha).pow 2).div + (pochRatio_normalized_tendsto hb) (by positivity) + have he (n : ℕ) : (pochRatio (s+1/2) (n+1)/((n:ℝ)+1)^(s+1/2-1))^2 / + (pochRatio (2*s) (n+1)/((n:ℝ)+1)^(2*s-1))= + baseProduct s (n+1)^2/pochRatio (2*s) (n+1) := by + rw [baseProduct_eq_poch] + have hp : (((n:ℝ)+1)^(s+1/2-1))^2=((n:ℝ)+1)^(2*s-1) := by + rw [←Real.rpow_natCast,←Real.rpow_mul (by positivity)] + congr 1 + ring + rw [div_pow,hp] + field_simp + apply (tendsto_add_atTop_iff_nat 1).1 + exact h.congr (fun n => he n) +lemma baseProduct_square_poch_bounds {s : ℝ} (hs : 0 < s) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n, + c*pochRatio (2*s) n ≤ baseProduct s n^2 ∧ + baseProduct s n^2 ≤ C*pochRatio (2*s) n := by + obtain ⟨c,C,hc,hC,h⟩ := positive_sequence_global_bounds + (fun n => div_pos (sq_pos_of_pos (baseProduct_pos hs n)) (pochRatio_pos (by positivity) n)) + (by positivity : 0 < (1/Gamma (s+1/2))^2/(1/Gamma (2*s))) + (baseProduct_square_normalized_tendsto hs) + refine ⟨c,C,hc,hC,fun n => ?_⟩ + exact ⟨(le_div_iff₀ (pochRatio_pos (by positivity) n)).1 (h n).1, + (div_le_iff₀ (pochRatio_pos (by positivity) n)).1 (h n).2⟩ +lemma meixner_even_square_poch_bounds {s : ℝ} (hs : 0 < s) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n, + c*pochRatio (2*s) n ≤ meixnerCoeff s (2*n)^2 ∧ + meixnerCoeff s (2*n)^2 ≤ C*pochRatio (2*s) n := by + obtain ⟨c,C,hc,hC,h⟩ := baseProduct_square_poch_bounds hs + let m := min 1 (2*s) + let M := max 1 (2*s)*Real.exp (2*(2*s-1)^2) + have hm : 0 < m := lt_min (by norm_num) (by positivity) + have hM : 0 < M := by dsimp [M];positivity + refine ⟨m^2*c,M^2*C,by positivity,by positivity,fun n => ?_⟩ + have hb := meixner_even_product_bounds hs n + change m*baseProduct s n ≤ _ ∧ _ ≤ M*baseProduct s n at hb + have hbp : 0 < baseProduct s n := baseProduct_pos hs n + have hp : 0 ≤ meixnerCoeff s (2*n) := le_trans (by positivity) hb.1 + constructor + · have hl := mul_self_le_mul_self (by positivity : 0 ≤ m*baseProduct s n) hb.1 + have hl' := mul_le_mul_of_nonneg_left (h n).1 (sq_nonneg m) + nlinarith + · have hu := mul_self_le_mul_self hp hb.2 + have hu' := mul_le_mul_of_nonneg_left (h n).2 (sq_nonneg M) + nlinarith +lemma sum_pochRatio {a : ℝ} (ha : 0 < a) (n : ℕ) : + (∑ j ∈ Finset.range (n+1),pochRatio a j)=((n:ℝ)+1)/a*pochRatio a (n+1) := by + induction n with + | zero => simp [pochRatio];field_simp + | succ n ih => + rw [Finset.sum_range_succ,ih,pochRatio_succ a (n+1)] + push_cast + field_simp + ring +noncomputable def evenCoefficientKernel (s : ℝ) (n : ℕ) : ℝ := + ∑ j ∈ Finset.range (n+1),meixnerCoeff s (2*j)^2 +/-- The exact squared-coefficient sum needed for the negative-axis +Christoffel kernel. The link with the orthogonal polynomial generating +function is a separate obligation, not an assumed kernel identification. -/ +theorem evenCoefficientKernel_bounds {s : ℝ} (hs : 0 < s) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + c*((n:ℝ)+1)^(2*s) ≤ evenCoefficientKernel s n ∧ + evenCoefficientKernel s n ≤ C*((n:ℝ)+1)^(2*s) := by + obtain ⟨c,C,hc,hC,h⟩ := meixner_even_square_poch_bounds hs + obtain ⟨d,D,hd,hD,hp⟩ := pochRatio_eventual_bounds (show 0 < 2*s by positivity) + refine ⟨c*d/(2*s),C*D/(2*s),by positivity,by positivity,?_⟩ + filter_upwards [hp] with n hn + have hlo : c*(((n:ℝ)+1)/(2*s)*pochRatio (2*s) (n+1)) ≤ evenCoefficientKernel s n := by + rw [←sum_pochRatio (by positivity),Finset.mul_sum] + exact Finset.sum_le_sum (fun j _ => (h j).1) + have hhi : evenCoefficientKernel s n ≤ C*(((n:ℝ)+1)/(2*s)*pochRatio (2*s) (n+1)) := by + rw [←sum_pochRatio (by positivity),Finset.mul_sum] + exact Finset.sum_le_sum (fun j _ => (h j).2) + have he : ((n:ℝ)+1)*((n:ℝ)+1)^(2*s-1)=((n:ℝ)+1)^(2*s) := by + rw [Real.rpow_sub_one (by positivity)] + field_simp + constructor + · have hmul := mul_le_mul_of_nonneg_left hn.1 (show 0 ≤ c*(((n:ℝ)+1)/(2*s)) by positivity) + calc + _=c*(((n:ℝ)+1)/(2*s)*(d*((n:ℝ)+1)^(2*s-1))) := by rw [←he];ring + _≤c*(((n:ℝ)+1)/(2*s)*pochRatio (2*s) (n+1)) := by simpa [mul_assoc] using hmul + _≤_ := hlo + · have hmul := mul_le_mul_of_nonneg_left hn.2 (show 0 ≤ C*(((n:ℝ)+1)/(2*s)) by positivity) + calc + _≤C*(((n:ℝ)+1)/(2*s)*pochRatio (2*s) (n+1)) := hhi + _≤C*(((n:ℝ)+1)/(2*s)*(D*((n:ℝ)+1)^(2*s-1))) := by simpa [mul_assoc] using hmul + _=_ := by rw [←he];ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +noncomputable def meixnerGenerator (s u : ℝ) : ℝ := + (1+u)^(s-1/2)*(1-u)^(-s-1/2) +lemma meixnerGenerator_smooth (s : ℝ) : ContDiffAt ℝ ⊤ (meixnerGenerator s) 0 := by + apply ContDiffAt.mul + · exact ContDiffAt.rpow_const_of_ne (by fun_prop) (by norm_num) + · exact ContDiffAt.rpow_const_of_ne (by fun_prop) (by norm_num) +lemma meixnerGenerator_zero (s : ℝ) : meixnerGenerator s 0=1 := by simp [meixnerGenerator] +lemma meixnerGenerator_ode (s : ℝ) : + (fun u => (1-u^2)*deriv (meixnerGenerator s) u) =ᶠ[𝓝 0] + (fun u => (2*s+u)*meixnerGenerator s u) := by + have hi : Set.Ioo (-1:ℝ) 1 ∈ 𝓝 0 := Ioo_mem_nhds (by norm_num) (by norm_num) + filter_upwards [hi] with u hu + have hp : 0 < 1+u := by linarith [hu.1] + have hm : 0 < 1-u := by linarith [hu.2] + have h1 := (Real.hasDerivAt_rpow_const (x:=1+u) (p:=s-1/2) (Or.inl hp.ne')).comp u + ((hasDerivAt_id u).const_add 1) + have h2 := (Real.hasDerivAt_rpow_const (x:=1-u) (p:=-s-1/2) (Or.inl hm.ne')).comp u + ((hasDerivAt_id u).const_sub 1) + have hder := (h1.mul h2).deriv + change deriv (meixnerGenerator s) u=_ at hder + rw [hder,Real.rpow_sub_one hp.ne',Real.rpow_sub_one hm.ne'] + unfold meixnerGenerator + dsimp only [Function.comp_apply] + field_simp + ring +lemma meixnerGenerator_one_coeff (s : ℝ) : taylorCoeff (meixnerGenerator s) 1=2*s := by + have h:= (meixnerGenerator_ode s).eq_of_nhds + simpa [taylorCoeff_one,meixnerGenerator_zero] using h +/-- The recurrence coefficients equal the Taylor coefficients of the generating function. -/ +lemma meixnerGenerator_taylor (s : ℝ) (n : ℕ) : + taylorCoeff (meixnerGenerator s) n=meixnerCoeff s n := by + induction n using Nat.twoStepInduction with + | zero => simp [taylorCoeff_zero,meixnerGenerator_zero,meixnerCoeff] + | one => simp [meixnerGenerator_one_coeff,meixnerCoeff] + | more n ih0 ih1 => + have he := taylorCoeff_ode_recurrence (meixnerGenerator_smooth s) (2*s) 1 + (by simpa using meixnerGenerator_ode s) n + rw [ih0,ih1] at he + rw [meixnerCoeff] + apply (eq_div_iff (by positivity : (n:ℝ)+2 ≠ 0)).2 + convert he using 1 <;> ring +noncomputable def meixnerEvenGenerator (s u : ℝ) : ℝ := + (1-u^2)^(-(1:ℝ)/2)*Real.cosh (2*s*Real.artanh u) +lemma meixnerGenerator_exp {u : ℝ} (hu : u ∈ Set.Ioo (-1) 1) (s : ℝ) : + meixnerGenerator s u=(1-u^2)^(-(1:ℝ)/2)*Real.exp (2*s*Real.artanh u) := by + have hp : 0 < 1+u := by linarith [hu.1] + have hm : 0 < 1-u := by linarith [hu.2] + have hsq : 0 < 1-u^2 := by nlinarith [mul_pos hp hm] + rw [meixnerGenerator,Real.rpow_def_of_pos hp,Real.rpow_def_of_pos hm, + Real.rpow_def_of_pos hsq,Real.artanh_eq_half_log ⟨hu.1.le,hu.2.le⟩, + Real.log_div hp.ne' hm.ne',←Real.exp_add,←Real.exp_add] + have hlog : Real.log (1-u^2)=Real.log (1+u)+Real.log (1-u) := by + rw [show 1-u^2=(1+u)*(1-u) by ring,Real.log_mul hp.ne' hm.ne'] + rw [hlog] + congr 1 + ring +lemma meixnerEvenGenerator_eq {u : ℝ} (hu : u ∈ Set.Ioo (-1) 1) (s : ℝ) : + meixnerEvenGenerator s u=(meixnerGenerator s u+meixnerGenerator s (-u))/2 := by + rw [meixnerGenerator_exp hu,meixnerGenerator_exp (u:=-u) ⟨by linarith [hu.2],by linarith [hu.1]⟩] + have hp : 0 < 1+u := by linarith [hu.1] + have hm : 0 < 1-u := by linarith [hu.2] + have ha : Real.artanh (-u) = -Real.artanh u := by + rw [Real.artanh_eq_half_log ⟨by linarith [hu.2],by linarith [hu.1]⟩, + Real.artanh_eq_half_log ⟨hu.1.le,hu.2.le⟩] + simp only [←sub_eq_add_neg,sub_neg_eq_add] + rw [Real.log_div hm.ne' hp.ne',Real.log_div hp.ne' hm.ne'] + ring + simp only [neg_sq,ha] + unfold meixnerEvenGenerator + rw [Real.cosh_eq,show 2*s*(-Real.artanh u)=-(2*s*Real.artanh u) by ring] + ring +lemma meixnerEvenGenerator_taylor (s : ℝ) (n : ℕ) : + taylorCoeff (meixnerEvenGenerator s) (2*n)=meixnerCoeff s (2*n) := by + have he : meixnerEvenGenerator s =ᶠ[𝓝 0] + (fun u => (meixnerGenerator s u+meixnerGenerator s (-u))/2) := by + filter_upwards [Ioo_mem_nhds (by norm_num : (-1:ℝ) < 0) (by norm_num : (0:ℝ) < 1)] with u hu + exact meixnerEvenGenerator_eq hu s + rw [taylorCoeff_congr he] + unfold taylorCoeff + have hneg : ContDiffAt ℝ ⊤ (fun u => meixnerGenerator s (-u)) 0 := by + have hf : ContDiffAt ℝ ⊤ (meixnerGenerator s) (-(0:ℝ)) := by simpa using meixnerGenerator_smooth s + exact hf.comp (0:ℝ) (show ContDiffAt ℝ ⊤ (fun u : ℝ => -u) 0 by fun_prop) + rw [iteratedDeriv_div_const,iteratedDeriv_fun_add (meixnerGenerator_smooth s |>.of_le (by simp)) + (hneg.of_le (by simp)),iteratedDeriv_comp_neg] + simp only [neg_zero,pow_mul,neg_one_sq,one_pow,one_smul] + rw [←meixnerGenerator_taylor s (2*n)] + unfold taylorCoeff + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial +noncomputable def evenOddPolynomials (e : ℝ) : ℕ → Polynomial ℝ × Polynomial ℝ + | 0 => (1,C 2) + | n+1 => + let E := (evenOddPolynomials e n).1 + let O := (evenOddPolynomials e n).2 + let E' := C ((2*(n:ℝ)+2)⁻¹)*(C 2*X*O+C (e*(2*n+1))*E) + (E',C ((2*(n:ℝ)+3)⁻¹)*(C 2*E'+C (e*(2*n+2))*O)) +noncomputable def evenPoly (e : ℝ) (n : ℕ) : Polynomial ℝ := (evenOddPolynomials e n).1 +noncomputable def oddPoly (e : ℝ) (n : ℕ) : Polynomial ℝ := (evenOddPolynomials e n).2 +@[simp] lemma evenPoly_zero (e : ℝ) : evenPoly e 0=1 := rfl +@[simp] lemma oddPoly_zero (e : ℝ) : oddPoly e 0=C 2 := rfl +lemma evenPoly_succ (e : ℝ) (n : ℕ) : evenPoly e (n+1)= + C ((2*(n:ℝ)+2)⁻¹)*(C 2*X*oddPoly e n+C (e*(2*n+1))*evenPoly e n) := rfl +lemma oddPoly_succ (e : ℝ) (n : ℕ) : oddPoly e (n+1)= + C ((2*(n:ℝ)+3)⁻¹)*(C 2*evenPoly e (n+1)+C (e*(2*n+2))*oddPoly e n) := rfl +lemma eval_evenPoly_succ (e x : ℝ) (n : ℕ) : + (evenPoly e (n+1)).eval x=(2*x*(oddPoly e n).eval x+e*(2*n+1)*(evenPoly e n).eval x)/(2*n+2) := by + rw [evenPoly_succ];simp;ring +lemma eval_oddPoly_succ (e x : ℝ) (n : ℕ) : + (oddPoly e (n+1)).eval x=(2*(evenPoly e (n+1)).eval x+e*(2*n+2)*(oddPoly e n).eval x)/(2*n+3) := by + rw [oddPoly_succ];simp;ring +lemma meixnerCoeff_even_step (s : ℝ) (n : ℕ) : + meixnerCoeff s (2*(n+1))=(2*s*meixnerCoeff s (2*n+1)+(2*n+1)*meixnerCoeff s (2*n))/(2*n+2) := by + rw [show 2*(n+1)=2*n+2 by omega,meixnerCoeff];push_cast;ring +lemma meixnerCoeff_odd_step (s : ℝ) (n : ℕ) : + meixnerCoeff s (2*(n+1)+1)=(2*s*meixnerCoeff s (2*(n+1))+(2*n+2)*meixnerCoeff s (2*n+1))/(2*n+3) := by + rw [show 2*(n+1)+1=(2*n+1)+2 by omega,meixnerCoeff] + simp only [show 2*n+1+1=2*(n+1) by omega];push_cast;ring +/-- The even Pollaczek polynomials form a basis. -/ +lemma evenOdd_plus_eval (s : ℝ) (n : ℕ) : + (evenPoly 1 n).eval (s^2)=meixnerCoeff s (2*n) ∧ + s*(oddPoly 1 n).eval (s^2)=meixnerCoeff s (2*n+1) := by + induction n with + | zero => simp [meixnerCoeff,mul_comm] + | succ n ih => + have he : (evenPoly 1 (n+1)).eval (s^2)=meixnerCoeff s (2*(n+1)) := by + rw [eval_evenPoly_succ,meixnerCoeff_even_step,←ih.1,←ih.2];ring + refine ⟨he,?_⟩ + rw [eval_oddPoly_succ,meixnerCoeff_odd_step,he,←ih.2];ring +lemma evenOdd_sign_eval (x : ℝ) (n : ℕ) : + (evenPoly (-1) n).eval (-x)=(-1)^n*(evenPoly 1 n).eval x ∧ + (oddPoly (-1) n).eval (-x)=(-1)^n*(oddPoly 1 n).eval x := by + induction n with + | zero => simp + | succ n ih => + have he : (evenPoly (-1) (n+1)).eval (-x)=(-1)^(n+1)*(evenPoly 1 (n+1)).eval x := by + rw [eval_evenPoly_succ,eval_evenPoly_succ,ih.1,ih.2,pow_succ];ring + refine ⟨he,?_⟩ + rw [eval_oddPoly_succ,eval_oddPoly_succ,he,ih.2,pow_succ];ring +/-- Evaluation on the negative axis gives alternating Meixner coefficients. -/ +lemma evenPoly_negative_eval (s : ℝ) (n : ℕ) : + (evenPoly (-1) n).eval (-(s^2))=(-1)^n*meixnerCoeff s (2*n) := by + rw [(evenOdd_sign_eval (s^2) n).1,(evenOdd_plus_eval s n).1] +lemma evenPoly_negative_eval_sq (s : ℝ) (n : ℕ) : + ((evenPoly (-1) n).eval (-(s^2)))^2=(meixnerCoeff s (2*n))^2 := by + rw [evenPoly_negative_eval,mul_pow,←pow_mul, mul_comm n 2,pow_mul,neg_one_sq,one_pow,one_mul] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +open scoped ContDiff +noncomputable def pollaczekGenerator (p t : ℝ) : ℝ := + (1+t^2)^(-(1:ℝ)/2)*Real.exp (2*p*Real.arctan t) +lemma pollaczekGenerator_smooth (p : ℝ) {n : WithTop ℕ∞} : ContDiff ℝ n (pollaczekGenerator p) := by + apply contDiff_iff_contDiffAt.2 + intro t + apply ContDiffAt.mul + · exact ContDiffAt.rpow_const_of_ne (by fun_prop) (by positivity) + · exact (contDiffAt_const.mul (Real.contDiff_arctan (n:=n)).contDiffAt).exp +lemma pollaczekGenerator_analytic (p t : ℝ) : AnalyticAt ℝ (pollaczekGenerator p) t := + (pollaczekGenerator_smooth p (n:=ω)).contDiffAt.analyticAt +@[simp] lemma pollaczekGenerator_zero (p : ℝ) : pollaczekGenerator p 0=1 := by simp [pollaczekGenerator] +lemma pollaczekGenerator_ode (p t : ℝ) : + (1+t^2)*deriv (pollaczekGenerator p) t=(2*p-t)*pollaczekGenerator p t := by + have hp : 0 < 1+t^2 := by positivity + have h1 := (Real.hasDerivAt_rpow_const (x:=1+t^2) (p:=-(1:ℝ)/2) (Or.inl hp.ne')).comp t + (((hasDerivAt_id t).pow 2).const_add 1) + have h2 := ((Real.hasDerivAt_arctan t).const_mul (2*p)).exp + have hd := (h1.mul h2).deriv + change deriv (pollaczekGenerator p) t=_ at hd + rw [hd,Real.rpow_sub_one hp.ne'] + unfold pollaczekGenerator + simp only [Function.comp_apply, Pi.pow_apply, id_eq, Nat.cast_ofNat, Nat.reduceSub, pow_one, mul_one] + field_simp + ring +noncomputable def pollaczekCoeff (p : ℝ) : ℕ → ℝ + | 0 => 1 + | 1 => 2*p + | n+2 => (2*p*pollaczekCoeff p (n+1)-(n+1)*pollaczekCoeff p n)/(n+2) +lemma pollaczekGenerator_taylor (p : ℝ) (n : ℕ) : + taylorCoeff (pollaczekGenerator p) n=pollaczekCoeff p n := by + induction n using Nat.twoStepInduction with + | zero => simp [taylorCoeff_zero,pollaczekCoeff] + | one => + have h := pollaczekGenerator_ode p 0 + simpa [taylorCoeff_one,pollaczekCoeff] using h + | more n ih0 ih1 => + have hode : (fun t => (1-(-1)*t^2)*deriv (pollaczekGenerator p) t) =ᶠ[𝓝 0] + (fun t => (2*p+(-1)*t)*pollaczekGenerator p t) := by + exact Eventually.of_forall (fun t => by simpa [sub_eq_add_neg] using pollaczekGenerator_ode p t) + have he := taylorCoeff_ode_recurrence (pollaczekGenerator_smooth p |>.contDiffAt) (2*p) (-1) hode n + rw [ih0,ih1] at he + rw [pollaczekCoeff] + apply (eq_div_iff (by positivity : (n:ℝ)+2 ≠ 0)).2 + convert he using 1 <;> ring +lemma pollaczekCoeff_even_step (p : ℝ) (n : ℕ) : + pollaczekCoeff p (2*(n+1))=(2*p*pollaczekCoeff p (2*n+1)-(2*n+1)*pollaczekCoeff p (2*n))/(2*n+2) := by + rw [show 2*(n+1)=2*n+2 by omega,pollaczekCoeff];push_cast;ring +lemma pollaczekCoeff_odd_step (p : ℝ) (n : ℕ) : + pollaczekCoeff p (2*(n+1)+1)=(2*p*pollaczekCoeff p (2*(n+1))-(2*n+2)*pollaczekCoeff p (2*n+1))/(2*n+3) := by + rw [show 2*(n+1)+1=(2*n+1)+2 by omega,pollaczekCoeff] + simp only [show 2*n+1+1=2*(n+1) by omega];push_cast;ring +lemma pollaczekCoeff_evenOdd (p : ℝ) (n : ℕ) : + (evenPoly (-1) n).eval (p^2)=pollaczekCoeff p (2*n) ∧ + p*(oddPoly (-1) n).eval (p^2)=pollaczekCoeff p (2*n+1) := by + induction n with + | zero => simp [pollaczekCoeff,mul_comm] + | succ n ih => + have he : (evenPoly (-1) (n+1)).eval (p^2)=pollaczekCoeff p (2*(n+1)) := by + rw [eval_evenPoly_succ,pollaczekCoeff_even_step,←ih.1,←ih.2];ring + refine ⟨he,?_⟩ + rw [eval_oddPoly_succ,pollaczekCoeff_odd_step,he,←ih.2];ring +lemma meixnerCoeff_nonneg {s : ℝ} (hs : 0 ≤ s) (n : ℕ) : 0 ≤ meixnerCoeff s n := by + induction n using Nat.twoStepInduction with + | zero => simp [meixnerCoeff] + | one => simp [meixnerCoeff];positivity + | more n ih0 ih1 => rw [meixnerCoeff];positivity +lemma pollaczekCoeff_abs_le (p : ℝ) (n : ℕ) : + |pollaczekCoeff p n| ≤ meixnerCoeff |p| n := by + induction n using Nat.twoStepInduction with + | zero => simp [pollaczekCoeff,meixnerCoeff] + | one => simp [pollaczekCoeff,meixnerCoeff,abs_mul] + | more n ih0 ih1 => + rw [pollaczekCoeff,meixnerCoeff,abs_div,abs_of_pos (by positivity : 0 < (n:ℝ)+2)] + apply div_le_div_of_nonneg_right _ (by positivity) + calc + _ ≤ |2*p*pollaczekCoeff p (n+1)|+|((n:ℝ)+1)*pollaczekCoeff p n| := abs_sub _ _ + _ = 2*|p| *|pollaczekCoeff p (n+1)|+((n:ℝ)+1)*|pollaczekCoeff p n| := by + simp [abs_mul,abs_of_nonneg (show (0:ℝ) ≤ n+1 by positivity)] + _ ≤ _ := by gcongr +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +open scoped BigOperators +lemma scalarSeries_taylor {f : ℝ → ℝ} {a : ℕ → ℝ} + (h : HasFPowerSeriesAt f (FormalMultilinearSeries.ofScalars ℝ a) 0) (n : ℕ) : + taylorCoeff f n=a n := by + obtain ⟨r,hr⟩ := h + have he := hr.factorial_smul (1:ℝ) n + simp only [FormalMultilinearSeries.ofScalars_apply_eq,nsmul_eq_mul,smul_eq_mul, + one_pow,mul_one] at he + rw [←iteratedDeriv_eq_iteratedFDeriv] at he + exact (div_eq_iff (by exact_mod_cast Nat.factorial_ne_zero n)).2 (by simpa [mul_comm] using he.symm) +noncomputable def binomialProductCoeff (a b : ℝ) (n : ℕ) : ℝ := + ∑ j ∈ Finset.range (n+1),Ring.choose a j*Ring.choose b (n-j)*(-1)^(n-j) +lemma binomialProduct_hasSum (a b : ℝ) {u : ℝ} (hu : |u| < 1) : + HasSum (fun n => binomialProductCoeff a b n*u^n) ((1+u)^a*(1-u)^b) := by + have hu' : u ∈ Metric.eball (0:ℝ) 1 := by + rw [mem_eball_zero_iff,enorm_eq_nnnorm] + exact_mod_cast (show ‖u‖ < 1 by simpa [Real.norm_eq_abs] using hu) + have hmu' : -u ∈ Metric.eball (0:ℝ) 1 := by simpa only [enorm_neg,mem_eball_zero_iff] using hu' + have ha := (Real.one_add_rpow_hasFPowerSeriesOnBall_zero (a:=a)).hasSum hu' + have hb := (Real.one_add_rpow_hasFPowerSeriesOnBall_zero (a:=b)).hasSum hmu' + simp only [zero_add,binomialSeries,FormalMultilinearSeries.ofScalars_apply_eq,smul_eq_mul] at ha hb + have h := hasSum_sum_range_mul_of_summable_norm ha.summable.norm hb.summable.norm + rw [ha.tsum_eq,hb.tsum_eq] at h + convert! h using 1 + · funext n + unfold binomialProductCoeff + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro j hj + have hj' : j ≤ n := by simpa using Finset.mem_range.1 hj + rw [neg_pow] + have he : u^n=u^j*u^(n-j) := by rw [←pow_add,Nat.add_sub_of_le hj'] + rw [he] + ring +lemma binomialProduct_series (a b : ℝ) : + HasFPowerSeriesAt (fun u => (1+u)^a*(1-u)^b) + (FormalMultilinearSeries.ofScalars ℝ (binomialProductCoeff a b)) 0 := by + apply hasFPowerSeriesAt_iff.2 + filter_upwards [Metric.ball_mem_nhds (0:ℝ) (by norm_num : (0:ℝ)<1)] with u hu + have hu' : |u| < 1 := by simpa [Metric.mem_ball] using hu + simpa [FormalMultilinearSeries.coeff_ofScalars,smul_eq_mul,mul_comm] using binomialProduct_hasSum a b hu' +lemma meixnerCoeff_eq_binomialProduct (s : ℝ) (n : ℕ) : + meixnerCoeff s n=binomialProductCoeff (s-1/2) (-s-1/2) n := by + rw [←meixnerGenerator_taylor] + exact scalarSeries_taylor (binomialProduct_series _ _) n +/-- The generating series converges absolutely for arguments of absolute value less than one. -/ +lemma meixnerCoeff_hasSum (s : ℝ) {u : ℝ} (hu : |u| < 1) : + HasSum (fun n => meixnerCoeff s n*u^n) (meixnerGenerator s u) := by + simpa only [meixnerCoeff_eq_binomialProduct,meixnerGenerator] using binomialProduct_hasSum (s-1/2) (-s-1/2) hu +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +open scoped NNReal ENNReal +lemma pollaczekCoeff_summable_norm (p : ℝ) {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1) : + Summable (fun n => |pollaczekCoeff p n| *r^n) := by + apply Summable.of_nonneg_of_le (fun n => by positivity) + (fun n => mul_le_mul_of_nonneg_right (pollaczekCoeff_abs_le p n) (pow_nonneg hr0 n)) + (meixnerCoeff_hasSum |p| (by rwa [abs_of_nonneg hr0])).summable +lemma pollaczekCoeff_radius (p : ℝ) : + (1:ENNReal) ≤ (FormalMultilinearSeries.ofScalars ℝ (pollaczekCoeff p)).radius := by + apply ENNReal.le_of_forall_nnreal_lt + intro r hr + apply FormalMultilinearSeries.le_radius_of_summable + simpa only [FormalMultilinearSeries.ofScalars_norm, Real.norm_eq_abs] using + pollaczekCoeff_summable_norm p r.coe_nonneg (by exact_mod_cast hr) +lemma pollaczekCoeff_hasSum (p : ℝ) {t : ℝ} (ht : |t| < 1) : + HasSum (fun n => pollaczekCoeff p n*t^n) (pollaczekGenerator p t) := by + have hc : (fun n => iteratedDeriv n (pollaczekGenerator p) 0 / n.factorial)=pollaczekCoeff p := + funext (pollaczekGenerator_taylor p) + have ha : AnalyticOn ℝ (pollaczekGenerator p) (Metric.eball 0 1) := + fun t _ => (pollaczekGenerator_analytic p t).analyticWithinAt + have hs := ha.hasFPowerSeriesOnSubball (by norm_num : (0:ENNReal)<1) + simp only [hc] at hs + have hmem : t ∈ Metric.eball (0:ℝ) 1 := by + rw [mem_eball_zero_iff,enorm_eq_nnnorm] + exact_mod_cast (show ‖t‖ < 1 by simpa [Real.norm_eq_abs] using ht) + simpa only [FormalMultilinearSeries.ofScalars_apply_eq,smul_eq_mul,zero_add] using + (hs (pollaczekCoeff_radius p)).hasSum hmem +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology MeasureTheory +noncomputable def pollaczekMajorant (p : ℝ) : ℝ := meixnerGenerator |p| (1/4) +lemma quarter_artanh_bounds : 0 ≤ Real.artanh (1/4) ∧ 4*Real.artanh (1/4) < Real.pi := by + have he : Real.artanh (1/4)=Real.log (5/3)/2 := by + rw [Real.artanh_eq_half_log (by norm_num : (1/4:ℝ) ∈ Set.Icc (-1) 1)];norm_num;ring + rw [he] + have hl := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<5/3) + have h0 := Real.log_nonneg (by norm_num : (1:ℝ) ≤ 5/3) + constructor <;> linarith [Real.pi_gt_three] +lemma pollaczekMajorant_pos (p : ℝ) : 0 < pollaczekMajorant p := by + unfold pollaczekMajorant meixnerGenerator + positivity +lemma pollaczekMajorant_continuous : Continuous pollaczekMajorant := by + unfold pollaczekMajorant meixnerGenerator + fun_prop (disch := norm_num) +lemma pollaczekMajorant_exp {p : ℝ} (hp : 0 ≤ p) : + pollaczekMajorant p=(1-(1/4:ℝ)^2)^(-(1:ℝ)/2)*Real.exp (2*Real.artanh (1/4)*p) := by + rw [pollaczekMajorant,abs_of_nonneg hp,meixnerGenerator_exp (by norm_num)] + congr 2; ring +lemma exp_div_cosh_integrable {a : ℝ} (ha : a < Real.pi) : + IntegrableOn (fun p => Real.exp (a*p)/Real.cosh (Real.pi*p)) (Set.Ioi 0) := by + have hi := (integrableOn_exp_mul_Ioi (a:=a-Real.pi) (by linarith) 0).const_mul 2 + have hc : Continuous (fun p : ℝ => Real.exp (a*p)/Real.cosh (Real.pi*p)) := + (show Continuous (fun p : ℝ => Real.exp (a*p)) by fun_prop).div + (by fun_prop) (fun p => (Real.cosh_pos _).ne') + apply hi.mono' hc.aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_eq_abs,abs_of_pos (by positivity)] + have hc : Real.exp (Real.pi*p)/2 ≤ Real.cosh (Real.pi*p) := by + rw [Real.cosh_eq];linarith [Real.exp_pos (-(Real.pi*p))] + calc + _ ≤ Real.exp (a*p)/(Real.exp (Real.pi*p)/2) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hc + _ = 2*Real.exp ((a-Real.pi)*p) := by + rw [sub_mul,Real.exp_sub];ring +lemma pollaczekMajorant_sq_integrable : + IntegrableOn (fun p => pollaczekMajorant p^2/Real.cosh (Real.pi*p)) (Set.Ioi 0) := by + have hi := (exp_div_cosh_integrable quarter_artanh_bounds.2).const_mul + (((1-(1/4:ℝ)^2)^(-(1:ℝ)/2))^2) + apply hi.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [pollaczekMajorant_exp hp.le] + rw [show 4*Real.artanh (1/4)*p=2*Real.artanh (1/4)*p+2*Real.artanh (1/4)*p by ring] + rw [Real.exp_add] + ring +lemma pollaczekCoeff_majorant (p : ℝ) (n : ℕ) : + |pollaczekCoeff p n| ≤ 4^n*pollaczekMajorant p := by + have hs := meixnerCoeff_hasSum |p| (u:=1/4) (by norm_num) + have hn := hs.summable.le_tsum n (fun j _ => mul_nonneg (meixnerCoeff_nonneg (abs_nonneg p) j) (by positivity)) + rw [hs.tsum_eq] at hn + have h := (mul_le_mul_of_nonneg_right (pollaczekCoeff_abs_le p n) (show (0:ℝ) ≤ (1/4)^n by positivity)).trans hn + have he : (4:ℝ)^n*(1/4)^n=1 := by rw [←mul_pow];norm_num + calc + _ = 4^n*(|pollaczekCoeff p n| *(1/4)^n) := by linear_combination -|pollaczekCoeff p n| * he + _ ≤ _ := mul_le_mul_of_nonneg_left h (by positivity) +lemma pollaczekGenerator_majorant (p : ℝ) {t : ℝ} (ht : |t| ≤ 1/4) : + |pollaczekGenerator p t| ≤ pollaczekMajorant p := by + have hs := pollaczekCoeff_hasSum p (t:=t) (by linarith) + have hm := meixnerCoeff_hasSum |p| (u:=1/4) (by norm_num) + rw [←Real.norm_eq_abs,←hs.tsum_eq] + apply (norm_tsum_le_tsum_norm hs.summable.norm).trans + unfold pollaczekMajorant + rw [←hm.tsum_eq] + apply hs.summable.norm.tsum_le_tsum _ hm.summable + intro n + simp only [norm_mul,Real.norm_eq_abs,abs_pow] + exact mul_le_mul (pollaczekCoeff_abs_le p n) (pow_le_pow_left₀ (abs_nonneg t) ht n) + (by positivity) (meixnerCoeff_nonneg (abs_nonneg p) n) +lemma pollaczekCoeff_continuous (n : ℕ) : Continuous (fun p => pollaczekCoeff p n) := by + induction n using Nat.twoStepInduction with + | zero => simpa [pollaczekCoeff] using continuous_const (y:=(1:ℝ)) + | one => simp only [pollaczekCoeff];fun_prop + | more n ih0 ih1 => simp only [pollaczekCoeff];fun_prop +lemma pollaczekGenerator_continuous_p (t : ℝ) : Continuous (fun p => pollaczekGenerator p t) := by + unfold pollaczekGenerator + fun_prop +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/NewtonKernel.lean b/lean/OAI/Combinatorics/HoneycombChords/NewtonKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b26ac5ba23220e1111d1df1d2c73c3b9ce9c1d4 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/NewtonKernel.lean @@ -0,0 +1,635 @@ +import OAI.Combinatorics.HoneycombChords.BetaKernel + +namespace OAI + +/-! Total positivity and convergence of Newton interpolation kernels. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv + +def TotallyNonnegative {d : ℕ} (A : Matrix (Fin d) (Fin d) ℝ) : Prop := + ∀ (n : ℕ) (r c : Fin n → Fin d),StrictMono r → StrictMono c → + 0≤(A.submatrix r c).det + +lemma lowerBidiagonal_totallyNonnegative {d : ℕ} (A : Matrix (Fin d) (Fin d) ℝ) + (ha : ∀ i j,0≤A i j) + (hz : ∀ i j,A i j≠0 → i.val=j.val ∨ i.val=j.val+1) : TotallyNonnegative A := by + classical + intro n r c hr hc + rw [Matrix.det_apply'] + apply sum_nonneg + intro σ hσ + by_cases hp : (∏ i : Fin n,A (r (σ i)) (c i))=0 + · simp only [Matrix.submatrix_apply,hp,mul_zero,le_refl] + · have he : ∀ i,A (r (σ i)) (c i)≠0 := fun i=> (prod_ne_zero_iff.mp hp) i (mem_univ i) + have hm : StrictMono σ := by + intro i j hij + by_contra hn + have hji : σ j<σ i := lt_of_le_of_ne (le_of_not_gt hn) (by intro h;exact (ne_of_lt hij) (σ.injective h).symm) + have hR := hr hji + have hC := hc hij + have hi := hz _ _ (he i) + have hj := hz _ _ (he j) + change (r (σ j)).val<(r (σ i)).val at hR + change (c i).val<(c j).val at hC + omega + have hid : σ=1 := by apply Equiv.ext;intro i;exact congrFun hm.eq_id i + subst σ + simpa using (prod_nonneg (s:=univ) (fun i _=>ha (r i) (c i))) + +lemma totallyNonnegative_one (d : ℕ) : TotallyNonnegative (1 : Matrix (Fin d) (Fin d) ℝ) := by + apply lowerBidiagonal_totallyNonnegative + · intro i j;simp only [Matrix.one_apply];split_ifs <;> norm_num + · intro i j hij + by_cases h:i=j + · exact Or.inl (congrArg Fin.val h) + · exfalso;exact hij (by simp [h]) + +lemma sorted_injective_fin {n d : ℕ} {f : Fin n → Fin d} (hf : Function.Injective f) : + ∃ (g : Fin n → Fin d) (σ : Perm (Fin n)),StrictMono g ∧ f=g∘σ := by + classical + let s:=univ.image f + have hs : s.card=n := by simp [s,card_image_of_injective _ hf] + let o:=s.orderIsoOfFin hs + let q : Fin n ≃ s := Equiv.ofBijective (fun i=>⟨f i,mem_image.mpr ⟨i,mem_univ _,rfl⟩⟩) (by + constructor + · intro i j h;exact hf (congrArg Subtype.val h) + · intro a;obtain ⟨i,_,hi⟩:=mem_image.mp a.property;exact ⟨i,Subtype.ext hi⟩) + refine ⟨fun i=>(o i).val,q.trans o.symm,o.strictMono,?_⟩ + funext i + exact (congrArg Subtype.val (o.apply_symm_apply (q i))).symm + +lemma TotallyNonnegative.mul {d : ℕ} {A B : Matrix (Fin d) (Fin d) ℝ} + (hA : TotallyNonnegative A) (hB : TotallyNonnegative B) : TotallyNonnegative (A*B) := by + classical + intro n r c hr hc + have he : (A*B).submatrix r c=A.submatrix r id * B.submatrix id c := by + ext i j;simp [Matrix.mul_apply] + rw [he] + have hs : 0≤ ∑ f : Fin n → Fin d, + ((A.submatrix r id).submatrix id f).det*((B.submatrix id c).submatrix f id).det := by + apply sum_nonneg + intro f hf + change 0≤(A.submatrix r f).det*(B.submatrix f c).det + by_cases hi : Function.Injective f + · obtain ⟨g,σ,hg,rfl⟩:=sorted_injective_fin hi + have hx : A.submatrix r (g∘σ)=(A.submatrix r g).submatrix id σ := rfl + have hy : B.submatrix (g∘σ) c=(B.submatrix g c).submatrix σ id := rfl + rw [hx,hy,Matrix.det_permute',Matrix.det_permute] + have hp:=mul_nonneg (sq_nonneg (((Perm.sign σ:ℤ):ℝ))) (mul_nonneg (hA n r g hr hg) (hB n g c hg hc)) + nlinarith only [hp] + · obtain ⟨i,j,hij,hne⟩:=Function.not_injective_iff.mp hi + have hz : (A.submatrix r f).det=0 := by + apply Matrix.det_zero_of_column_eq hne + intro k + simp only [Matrix.submatrix_apply,hij] + rw [hz,zero_mul] + rw [det_rectangular_binet] at hs + exact (mul_nonneg_iff_of_pos_left (by positivity : (0:ℝ) positivity + · intro u v huv + by_cases hui:u=i + · subst u + by_cases hvi:v=i + · exact Or.inl (congrArg Fin.val hvi.symm) + · by_cases hvj:v=j + · exact Or.inr (by simpa [hvj] using hij) + · exfalso;exact huv (by simp [L,Matrix.updateRow_apply,Ne.symm hvi,Ne.symm hvj]) + · have huv' : u=v := by + by_contra h + exact huv (by simp [L,Matrix.updateRow_apply,hui,h]) + exact Or.inl (congrArg Fin.val huv') + have he : L*A=A.updateRow i (A i+a • A j) := by + ext u v + by_cases hu:u=i + · subst u + simp [Matrix.mul_apply,L,Matrix.updateRow_apply,add_mul,Finset.sum_add_distrib,Matrix.one_apply] + · simp [Matrix.mul_apply,L,Matrix.updateRow_apply,hu,Matrix.one_apply] + rw [←he] + exact hL.mul hA + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv + +lemma TotallyNonnegative.prefix_recursive {d : ℕ} + {A B : Matrix (Fin (d+1)) (Fin (d+1)) ℝ} (hA : TotallyNonnegative A) + {a : ℝ} (ha : 0≤a) (hzero : B 0=A 0) + (hstep : ∀ k : Fin d,B k.succ=A k.succ+a • B k.castSucc) : TotallyNonnegative B := by + classical + let P (k : ℕ) : Matrix (Fin (d+1)) (Fin (d+1)) ℝ := fun i j=>if i.val≤k then B i j else A i j + have hp0 : P 0=A := by + ext i j + by_cases hi:i=0 + · subst i;simp [P,hzero] + · have hv : ¬i.val≤0 := by intro h;apply hi;apply Fin.ext;simpa using h + simp [P,hv] + have hp : ∀ k,k≤d → TotallyNonnegative (P k) := by + intro k + induction k with + | zero => intro _;rw [hp0];exact hA + | succ k ih => + intro hk + let j : Fin (d+1):=⟨k,by omega⟩ + let i : Fin (d+1):=⟨k+1,by omega⟩ + have he : P (k+1)=(P k).updateRow i (P k i+a • P k j) := by + ext u v + by_cases hu:u=i + · subst u + have hs := congrFun (hstep ⟨k,by omega⟩) v + simpa [P,Matrix.updateRow,i,j] using hs + · have hc : (u.val≤k+1) ↔ u.val≤k := by + have hn : u.val≠k+1 := by intro h;apply hu;exact Fin.ext h + omega + simp [P,Matrix.updateRow,hu,hc] + rw [he] + exact (ih (by omega)).adjacent_row (i:=i) (j:=j) (by rfl) ha + have he : P d=B := by ext i j;simp [P,show i.val≤d by omega] + rw [←he] + exact hp d le_rfl + +noncomputable def liftNewton {d : ℕ} (A : Matrix (Fin d) (Fin d) ℝ) : + Matrix (Fin (d+1)) (Fin (d+1)) ℝ := + Fin.cases (fun j=>if j=0 then 1 else 0) (fun i=>Fin.cases 0 (A i)) + +@[simp] lemma liftNewton_zero_zero {d : ℕ} (A : Matrix (Fin d) (Fin d) ℝ) : liftNewton A 0 0=1 := rfl +@[simp] lemma liftNewton_zero_succ {d : ℕ} (A : Matrix (Fin d) (Fin d) ℝ) (j : Fin d) : liftNewton A 0 j.succ=0 := by simp [liftNewton] +@[simp] lemma liftNewton_succ_zero {d : ℕ} (A : Matrix (Fin d) (Fin d) ℝ) (i : Fin d) : liftNewton A i.succ 0=0 := rfl +@[simp] lemma liftNewton_succ_succ {d : ℕ} (A : Matrix (Fin d) (Fin d) ℝ) (i j : Fin d) : liftNewton A i.succ j.succ=A i j := rfl + +lemma TotallyNonnegative.lift_newton {d : ℕ} {A : Matrix (Fin d) (Fin d) ℝ} + (hA : TotallyNonnegative A) : TotallyNonnegative (liftNewton A) := by + classical + intro n r c hr hc + cases n with + | zero => simp + | succ n => + by_cases hr0:r 0=0 + · by_cases hc0:c 0=0 + · let r' : Fin n → Fin d:=fun i=>(r i.succ).pred (by + have h:=hr (Fin.succ_pos i);rw [hr0] at h;exact ne_of_gt h) + let c' : Fin n → Fin d:=fun i=>(c i.succ).pred (by + have h:=hc (Fin.succ_pos i);rw [hc0] at h;exact ne_of_gt h) + have hr' : StrictMono r' := by intro i j hij;simpa [r',Fin.pred_lt_pred_iff] using hr (Fin.succ_lt_succ_iff.mpr hij) + have hc' : StrictMono c' := by intro i j hij;simpa [c',Fin.pred_lt_pred_iff] using hc (Fin.succ_lt_succ_iff.mpr hij) + have he : (liftNewton A).submatrix r c=liftNewton (A.submatrix r' c') := by + ext i j + refine Fin.cases ?_ (fun i=>?_) i <;> refine Fin.cases ?_ (fun j=>?_) j + · simp [Matrix.submatrix_apply,hr0,hc0] + · rw [Matrix.submatrix_apply,hr0,←Fin.succ_pred (c j.succ) (by + have h:=hc (Fin.succ_pos j);rw [hc0] at h;exact ne_of_gt h)] + simp only [liftNewton_zero_succ] + · rw [Matrix.submatrix_apply,hc0,←Fin.succ_pred (r i.succ) (by + have h:=hr (Fin.succ_pos i);rw [hr0] at h;exact ne_of_gt h)] + simp only [liftNewton_succ_zero] + · change liftNewton A (r i.succ) (c j.succ)=A (r' i) (c' j) + rw [←Fin.succ_pred (r i.succ) (by have h:=hr (Fin.succ_pos i);rw [hr0] at h;exact ne_of_gt h), + ←Fin.succ_pred (c j.succ) (by have h:=hc (Fin.succ_pos j);rw [hc0] at h;exact ne_of_gt h)] + rfl + have hd (Q : Matrix (Fin n) (Fin n) ℝ) : (liftNewton Q).det=Q.det := by + rw [Matrix.det_succ_row_zero,Fin.sum_univ_succ] + simp only [liftNewton_zero_zero,Fin.succAbove_zero, + liftNewton_zero_succ,mul_zero,zero_mul,sum_const_zero,add_zero] + simp only [Fin.val_zero,pow_zero,one_mul,mul_one] + rfl + rw [he,hd] + exact hA n r' c' hr' hc' + · have hz : ((liftNewton A).submatrix r c).det=0 := by + apply Matrix.det_eq_zero_of_row_eq_zero 0 + intro j + have hj : c j≠0 := by + intro h + have hle:=hc.monotone (Fin.zero_le j) + rw [h] at hle + exact hc0 (le_antisymm hle (Fin.zero_le _)) + simp [Matrix.submatrix_apply,hr0,liftNewton,hj] + rw [hz] + · by_cases hc0:c 0=0 + · have hz : ((liftNewton A).submatrix r c).det=0 := by + apply Matrix.det_eq_zero_of_column_eq_zero 0 + intro i + have hi : r i≠0 := by + intro h + have hle:=hr.monotone (Fin.zero_le i) + rw [h] at hle + exact hr0 (le_antisymm hle (Fin.zero_le _)) + rw [Matrix.submatrix_apply,hc0,←Fin.succ_pred (r i) hi] + simp only [liftNewton_succ_zero] + rw [hz] + · let r' : Fin (n+1) → Fin d:=fun i=>(r i).pred (by + intro h;exact hr0 (le_antisymm (h ▸ hr.monotone (Fin.zero_le i)) (Fin.zero_le _))) + let c' : Fin (n+1) → Fin d:=fun i=>(c i).pred (by + intro h;exact hc0 (le_antisymm (h ▸ hc.monotone (Fin.zero_le i)) (Fin.zero_le _))) + have hr' : StrictMono r' := by intro i j hij;simpa [r',Fin.pred_lt_pred_iff] using hr hij + have hc' : StrictMono c' := by intro i j hij;simpa [c',Fin.pred_lt_pred_iff] using hc hij + have he : (liftNewton A).submatrix r c=A.submatrix r' c' := by + ext i j + change liftNewton A (r i) (c j)=A (r' i) (c' j) + have hrp : (r' i).succ=r i := Fin.succ_pred _ _ + have hcp : (c' j).succ=c j := Fin.succ_pred _ _ + rw [←hrp,←hcp] + rfl + rw [he] + exact hA (n+1) r' c' hr' hc' + +noncomputable def powerNewton (v : ℕ → ℝ) : ℕ → ℕ → ℝ + | 0,k => if k=0 then 1 else 0 + | n+1,0 => v 0*powerNewton v n 0 + | n+1,k+1 => v 0*powerNewton v n (k+1)+powerNewton (fun i=>v (i+1)) n k + +lemma powerNewton_zero (v : ℕ → ℝ) (n : ℕ) : powerNewton v n 0=(v 0)^n := by + induction n with + | zero => simp [powerNewton] + | succ n ih => rw [powerNewton,ih,pow_succ']; +lemma powerNewton_eq_zero (v : ℕ → ℝ) {n k : ℕ} (h:n simp [powerNewton,show k≠0 by omega] + | succ n ih => + cases k with + | zero => omega + | succ k => rw [powerNewton,ih v (by omega),ih (fun i=>v (i+1)) (by omega),mul_zero,add_zero] + +lemma powerNewton_totallyNonnegative (d : ℕ) (v : ℕ → ℝ) (hv : ∀ i,0≤v i) : + TotallyNonnegative (fun i j : Fin d=>powerNewton v i.val j.val) := by + induction d generalizing v with + | zero => + intro n r c hr hc + have hn:n=0 := by by_contra h;exact Fin.elim0 (r ⟨0,by omega⟩) + subst n + simp + | succ d ih => + apply TotallyNonnegative.prefix_recursive + ((ih (fun i=>v (i+1)) (fun i=>hv (i+1))).lift_newton) (hv 0) + · funext j + refine Fin.cases ?_ (fun j=>?_) j <;> simp [powerNewton,liftNewton] + · intro k + funext j + refine Fin.cases ?_ (fun j=>?_) j + · simp [powerNewton,liftNewton] + · simp only [Pi.add_apply,Pi.smul_apply,smul_eq_mul,liftNewton,Fin.cases_succ,Fin.val_succ,Fin.val_castSucc,powerNewton] + ring + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix + +lemma powerNewton_det_nonneg {n : ℕ} (v : ℕ → ℝ) (hv : ∀ i,0≤v i) + (e c : Fin n → ℕ) (he : StrictMono e) (hc : StrictMono c) : + 0≤Matrix.det (fun i j=>powerNewton v (e i) (c j)) := by + classical + let D:=1+univ.sup e+univ.sup c + let r : Fin n → Fin D:=fun i=>⟨e i,by + have h: e i≤univ.sup e:=le_sup (mem_univ i) + dsimp [D];omega⟩ + let s : Fin n → Fin D:=fun i=>⟨c i,by + have h:c i≤univ.sup c:=le_sup (mem_univ i) + dsimp [D];omega⟩ + exact powerNewton_totallyNonnegative D v hv n r s he hc + +lemma newtonBasis_head (v : ℕ → ℝ) (k : ℕ) : + newtonBasis v (k+1)=(X-Polynomial.C (v 0))*newtonBasis (fun i=>v (i+1)) k := by + simp only [newtonBasis,Finset.prod_range_succ'] + ring + +lemma powerNewton_expansion (v : ℕ → ℝ) (n : ℕ) : + (X:Polynomial ℝ)^n=∑ k ∈ range (n+1),Polynomial.C (powerNewton v n k)*newtonBasis v k := by + induction n generalizing v with + | zero => simp [powerNewton,newtonBasis] + | succ n ih => + have hs : (∑ k ∈ range (n+2),Polynomial.C (powerNewton v (n+1) k)*newtonBasis v k)= + Polynomial.C (v 0)*(∑ k ∈ range (n+2),Polynomial.C (powerNewton v n k)*newtonBasis v k)+ + (X-Polynomial.C (v 0))*(∑ k ∈ range (n+1),Polynomial.C (powerNewton (fun i=>v (i+1)) n k)*newtonBasis (fun i=>v (i+1)) k) := by + rw [sum_range_succ' _ (n+1),sum_range_succ' _ (n+1)] + simp only [powerNewton,C_mul,show newtonBasis v 0=1 by simp [newtonBasis],mul_one] + rw [mul_add,add_assoc,add_comm] + rw [Finset.mul_sum,Finset.mul_sum,add_left_comm] + congr 1 + rw [←Finset.sum_add_distrib] + apply sum_congr rfl + intro k hk + rw [newtonBasis_head,C_add,C_mul] + ring + have hl : (∑ k ∈ range (n+2),Polynomial.C (powerNewton v n k)*newtonBasis v k)= + ∑ k ∈ range (n+1),Polynomial.C (powerNewton v n k)*newtonBasis v k := by + rw [sum_range_succ,powerNewton_eq_zero v (by omega),C_0,zero_mul,add_zero] + rw [hs,hl,←ih v,←ih (fun i=>v (i+1))] + ring + +lemma powerNewton_expansion_truncated (v : ℕ → ℝ) (n D : ℕ) (h:nP.eval (v j)) (powerNewton_expansion_truncated v n D (by dsimp [D];omega)) + simp only [Polynomial.eval_pow,Polynomial.eval_X,Polynomial.eval_finsetSum,Polynomial.eval_mul,Polynomial.eval_C] at hp + rw [show (∑ k : Fin m,powerNewton v n k*(newtonBasis v k).eval (v j)) = + ∑ k ∈ range m,powerNewton v n k*(newtonBasis v k).eval (v j) from + Fin.sum_univ_eq_sum_range (fun k : ℕ=>powerNewton v n k*(newtonBasis v k).eval (v j)) m] + rw [hp] + symm + apply sum_subset (range_mono (by dsimp [D];omega)) + intro k hk hn + have hmk:m≤k := by simpa using hn + rw [newtonBasis_eval_zero (lt_of_lt_of_le j.isLt hmk),mul_zero] + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Filter Topology + +lemma powerNewton_bound (k n : ℕ) {b : ℕ → ℝ} {R : ℝ} + (hR : 1 ≤ R) (hb : ∀ i,|b i| ≤ R) : |powerNewton b k n| ≤ (2*R)^k := by + induction k generalizing b n with + | zero => simp only [powerNewton,pow_zero];split_ifs <;> norm_num + | succ k ih => + cases n with + | zero => + rw [powerNewton,abs_mul,pow_succ'] + exact (mul_le_mul (hb 0) (ih _ hb) (abs_nonneg _) (by linarith)).trans + (mul_le_mul_of_nonneg_right (by linarith) (by positivity)) + | succ n => + rw [powerNewton,pow_succ'] + calc + |b 0*powerNewton b k (n+1)+powerNewton (fun i=>b (i+1)) k n| ≤ + |b 0| *|powerNewton b k (n+1)|+|powerNewton (fun i=>b (i+1)) k n| := by + simpa only [abs_mul] using abs_add_le (b 0*powerNewton b k (n+1)) _ + _ ≤ R*(2*R)^k+(2*R)^k := add_le_add + (mul_le_mul (hb 0) (ih _ hb) (abs_nonneg _) (by linarith)) + (ih _ (fun i => hb (i+1))) + _ ≤ 2*R*(2*R)^k := by nlinarith [pow_nonneg (show 0 ≤ 2*R by linarith) k] + +lemma continuous_powerNewton (k n : ℕ) : Continuous (fun b : ℕ → ℝ => powerNewton b k n) := by + induction k generalizing n with + | zero => simp only [powerNewton];split_ifs <;> exact continuous_const + | succ k ih => + cases n with + | zero => exact (continuous_apply 0).mul (ih 0) + | succ n => + exact ((continuous_apply 0).mul (ih (n+1))).add + ((ih n).comp (continuous_pi (fun i => continuous_apply (i+1)))) + +lemma powerNewton_jet_evaluation {m : ℕ} (b : ℕ → ℝ) (k : ℕ) (j : Fin m) : + polynomialJet (X^k) (b j) (nodalOrder b j)= + ∑ r : Fin m,powerNewton b k r*polynomialJet (newtonBasis b r) (b j) (nodalOrder b j) := by + let D:=k+m+1 + have hp:=congrArg (fun P : Polynomial ℝ => polynomialJet P (b j) (nodalOrder b j)) + (powerNewton_expansion_truncated b k D (by dsimp [D];omega)) + have hsum : polynomialJet (∑ r∈range D,Polynomial.C (powerNewton b k r)*newtonBasis b r) (b j) (nodalOrder b j)= + ∑ r∈range D,powerNewton b k r*polynomialJet (newtonBasis b r) (b j) (nodalOrder b j) := by + simp [polynomialJet,map_sum,taylor_mul,Polynomial.coeff_C_mul] + rw [hsum] at hp + rw [Fin.sum_univ_eq_sum_range (fun r => powerNewton b k r*polynomialJet (newtonBasis b r) (b j) (nodalOrder b j)) m,hp] + symm + apply sum_subset (range_mono (by dsimp [D];omega)) + intro r hr hnr + have hmr : m ≤ r := by simpa using hnr + rw [polynomialJet_newtonBasis_gt (lt_of_lt_of_le j.isLt hmr),mul_zero] + +noncomputable def newtonKernelTerm (b : ℕ → ℝ) (x : ℝ) (e r k : ℕ) : ℝ := + powerNewton b k r*polynomialJet (X^k) x e/(2*k).factorial +noncomputable def newtonKernel (b : ℕ → ℝ) (x : ℝ) (e r : ℕ) : ℝ := + ∑' k,newtonKernelTerm b x e r k + +lemma newtonKernelTerm_bound {b : ℕ → ℝ} {x R S : ℝ} (hR : 1 ≤ R) (hS : 1 ≤ S) + (hb : ∀ i,|b i| ≤ R) (hx : |x| ≤ S) (e r k : ℕ) : + ‖newtonKernelTerm b x e r k‖ ≤ (4*R*S)^k/(2*k).factorial := by + rw [newtonKernelTerm,Real.norm_eq_abs,abs_div,abs_mul,abs_of_nonneg (show (0:ℝ) ≤ ((2*k).factorial:ℝ) from Nat.cast_nonneg _)] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + calc + |powerNewton b k r| *|polynomialJet (X^k) x e| ≤ (2*R)^k*(2*S)^k := + mul_le_mul (powerNewton_bound k r hR hb) (polynomialJet_X_pow_bound k e hS hx) + (abs_nonneg _) (by positivity) + _=(4*R*S)^k := by rw [←mul_pow];ring_nf + +lemma newtonKernelTerm_summable {b : ℕ → ℝ} {R : ℝ} (hR : 1 ≤ R) (hb : ∀ i,|b i| ≤ R) + (x : ℝ) (e r : ℕ) : Summable (newtonKernelTerm b x e r) := by + apply (summable_evenFactorial (show 0 ≤ 4*R*(|x|+1) by positivity)).of_norm_bounded + intro k + exact newtonKernelTerm_bound hR (by linarith [abs_nonneg x]) hb (by linarith) e r k + +lemma cosineKernelJet_newton {m : ℕ} {b : ℕ → ℝ} {R : ℝ} + (hR : 1 ≤ R) (hb : ∀ i,|b i| ≤ R) (x : ℝ) (e : ℕ) (j : Fin m) : + cosineKernelJet (nodalOrder b j) e (b j) x= + ∑ r : Fin m,newtonKernel b x e r*newtonJetMatrix m b r j := by + simp only [newtonKernel,←tsum_mul_right] + rw [←Summable.tsum_finsetSum] + · apply tsum_congr + intro k + simp only [kernelJetTerm,newtonKernelTerm,newtonJetMatrix] + rw [powerNewton_jet_evaluation b k j] + rw [Finset.sum_mul,Finset.sum_div] + apply sum_congr rfl + intro r hr + ring + · intro r hr + exact (newtonKernelTerm_summable hR hb x e r).mul_right _ + +lemma continuousOn_newtonKernel {α : Type*} [TopologicalSpace α] + {s : Set α} {b : α → ℕ → ℝ} {R : ℝ} (hR : 1 ≤ R) + (hb : ContinuousOn b s) (hbound : ∀ z ∈ s,∀ i,|b z i| ≤ R) + (x : ℝ) (e r : ℕ) : ContinuousOn (fun z => newtonKernel (b z) x e r) s := by + apply continuousOn_tsum + · intro k + exact (((continuous_powerNewton k r).comp_continuousOn hb).mul continuousOn_const).div_const _ + · exact summable_evenFactorial (show 0 ≤ 4*R*(|x|+1) by positivity) + · intro k z hz + exact newtonKernelTerm_bound hR (by linarith [abs_nonneg x]) (hbound z hz) (by linarith) e r k + +lemma cosineKernelJet_det_newton {m : ℕ} {b : ℕ → ℝ} {R : ℝ} + (hR : 1 ≤ R) (hb : ∀ i,|b i| ≤ R) (x : ℝ) (e : Fin m → ℕ) : + Matrix.det (fun i j : Fin m => cosineKernelJet (nodalOrder b j) (e i) (b j) x)= + Matrix.det (fun i j : Fin m => newtonKernel b x (e i) j)*(newtonJetMatrix m b).det := by + have hm : (Matrix.of (fun i j : Fin m => cosineKernelJet (nodalOrder b j) (e i) (b j) x))= + (Matrix.of (fun i j : Fin m => newtonKernel b x (e i) j))*newtonJetMatrix m b := by + ext i j + exact cosineKernelJet_newton hR hb x (e i) j + exact (congrArg Matrix.det hm).trans (Matrix.det_mul _ _) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset + +lemma powerNewton_nonneg {b : ℕ → ℝ} (hb : ∀ i,0 ≤ b i) (k r : ℕ) : 0 ≤ powerNewton b k r := by + induction k generalizing b r with + | zero => simp only [powerNewton]; split_ifs <;> norm_num + | succ k ih => + cases r with + | zero => exact mul_nonneg (hb 0) (ih hb 0) + | succ r => exact add_nonneg (mul_nonneg (hb 0) (ih hb _)) (ih (fun i ↦ hb (i+1)) r) + +lemma powerNewton_mono {b c : ℕ → ℝ} (hb : ∀ i,0 ≤ b i) (hbc : ∀ i,b i ≤ c i) + (k r : ℕ) : powerNewton b k r ≤ powerNewton c k r := by + induction k generalizing b c r with + | zero => rfl + | succ k ih => + cases r with + | zero => exact mul_le_mul (hbc 0) (ih hb hbc 0) (powerNewton_nonneg hb _ _) ((hb 0).trans (hbc 0)) + | succ r => + exact add_le_add + (mul_le_mul (hbc 0) (ih hb hbc _) (powerNewton_nonneg hb _ _) ((hb 0).trans (hbc 0))) + (ih (fun i ↦ hb (i+1)) (fun i ↦ hbc (i+1)) r) + +lemma nodalOrder_const (a : ℝ) (k : ℕ) : nodalOrder (fun _ ↦ a) k=k := by + simp [nodalOrder] + +lemma polynomialJet_newtonBasis_const (a : ℝ) (r k : ℕ) : + polynomialJet (newtonBasis (fun _ ↦ a) r) a k = if r=k then 1 else 0 := by + have he : newtonBasis (fun _ ↦ a) r=(X-Polynomial.C a)^r := by simp [newtonBasis] + rw [he,polynomialJet] + simp [taylor_pow,map_sub,taylor_X,taylor_C,eq_comm] + +lemma powerNewton_const (a : ℝ) (k r : ℕ) : + powerNewton (fun _ ↦ a) k r=polynomialJet (X^k) a r := by + have h:=powerNewton_jet_evaluation (m:=r+1) (fun _ ↦ a) k (Fin.last r) + simp only [nodalOrder_const,Fin.val_last,polynomialJet_newtonBasis_const] at h + have he (i : Fin (r+1)) : (i:ℕ)=r ↔ i=Fin.last r := ⟨fun h ↦ Fin.ext h,fun h ↦ congrArg Fin.val h⟩ + simpa only [mul_ite,mul_one,mul_zero,he,sum_ite_eq',mem_univ,ite_true,Fin.val_last] using h.symm + +lemma newtonKernel_const (a x : ℝ) (r : ℕ) : + newtonKernel (fun _ ↦ a) x 0 r=cosineKernelJet r 0 a x := by + unfold newtonKernel cosineKernelJet + apply tsum_congr + intro k + simp only [newtonKernelTerm,kernelJetTerm,powerNewton_const] + +lemma newtonKernel_nonneg {b : ℕ → ℝ} (hb : ∀ i,0 ≤ b i) {x : ℝ} (hx : 0 ≤ x) (r : ℕ) : + 0 ≤ newtonKernel b x 0 r := by + apply tsum_nonneg + intro k + unfold newtonKernelTerm + apply div_nonneg (mul_nonneg (powerNewton_nonneg hb _ _) _) (Nat.cast_nonneg _) + simp only [polynomialJet_X_pow,Nat.choose_zero_right,Nat.cast_one,one_mul,Nat.sub_zero] + positivity + +lemma newtonKernel_le_jet {b : ℕ → ℝ} {a x : ℝ} (hb : ∀ i,0 ≤ b i) (hba : ∀ i,b i ≤ a) + (hx : 0 ≤ x) (r : ℕ) : newtonKernel b x 0 r ≤ cosineKernelJet r 0 a x := by + have ha : 0 ≤ a := (hb 0).trans (hba 0) + have hs:=newtonKernelTerm_summable (b:=b) (R:=a+1) (by linarith) + (fun i ↦ by rw [abs_of_nonneg (hb i)]; linarith [hba i]) x 0 r + have ht:=newtonKernelTerm_summable (b:=fun _ ↦ a) (R:=a+1) (by linarith) + (fun _ ↦ by rw [abs_of_nonneg ha]; linarith) x 0 r + rw [←newtonKernel_const] + apply hs.tsum_le_tsum _ ht + intro k + unfold newtonKernelTerm + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + apply mul_le_mul_of_nonneg_right (powerNewton_mono hb hba k r) + simp only [polynomialJet_X_pow,Nat.choose_zero_right,Nat.cast_one,one_mul,Nat.sub_zero] + exact pow_nonneg hx k + +lemma newtonKernel_exp_bound {b : ℕ → ℝ} {a δ : ℝ} (hb : ∀ i,0 ≤ b i) + (hba : ∀ i,b i ≤ a) (hd : 0<δ) (r : ℕ) {p : ℝ} (hp : 0 ≤ p) : + |newtonKernel b (p^2) 0 r| ≤ δ^(-(r:ℤ))*Real.exp (Real.sqrt (a+δ)*p) := by + rw [abs_of_nonneg (newtonKernel_nonneg hb (sq_nonneg p) r)] + exact (newtonKernel_le_jet hb hba (sq_nonneg p) r).trans + ((le_abs_self _).trans (cosineKernelJet_exp_bound ((hb 0).trans (hba 0)) hd r hp)) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix Filter Topology + +lemma newtonJetMatrix_det_ne_zero (n : ℕ) (b : ℕ → ℝ) : (newtonJetMatrix n b).det≠0 := by + rw [newtonJetMatrix_det] + apply prod_ne_zero_iff.mpr + intro k _ + apply prod_ne_zero_iff.mpr + intro j hj + exact sub_ne_zero.mpr (mem_filter.mp hj).2.symm + +lemma newtonKernel_as_combination {n : ℕ} {b : ℕ → ℝ} {R : ℝ} + (hR : 1 ≤ R) (hb : ∀ i,|b i| ≤ R) (x : ℝ) (r : Fin n) : + newtonKernel b x 0 r = ∑ j : Fin n,cosineKernelJet (nodalOrder b j) 0 (b j) x * + (newtonJetMatrix n b)⁻¹ j r := by + have h : (fun j : Fin n ↦ cosineKernelJet (nodalOrder b j) 0 (b j) x)= + (fun r : Fin n ↦ newtonKernel b x 0 r) ᵥ* newtonJetMatrix n b := by + funext j + exact cosineKernelJet_newton hR hb x 0 j + have he:=congrArg (fun v : Fin n → ℝ ↦ (v ᵥ* (newtonJetMatrix n b)⁻¹) r) h + rw [Matrix.vecMul_vecMul,Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr (newtonJetMatrix_det_ne_zero n b)),Matrix.vecMul_one] at he + exact he.symm + +lemma continuous_newtonKernel {b : ℕ → ℝ} {R : ℝ} (hR : 1 ≤ R) (hb : ∀ i,|b i| ≤ R) (r : ℕ) : + Continuous (fun x ↦ newtonKernel b x 0 r) := by + have he : (fun x ↦ newtonKernel b x 0 r)= + fun x ↦ ∑ j : Fin (r+1),cosineKernelJet (nodalOrder b j) 0 (b j) x * + (newtonJetMatrix (r+1) b)⁻¹ j (Fin.last r) := by + funext x + exact newtonKernel_as_combination hR hb x (Fin.last r) + rw [he] + exact continuous_finsetSum _ (fun i _ ↦ ((cosineKernelJet_contDiff_right _ _ _ 0).continuous).mul continuous_const) + +lemma tendsto_newtonKernel_of_bounded {b : ℕ → ℕ → ℝ} {a : ℕ → ℝ} {R : ℝ} + (hR : 1 ≤ R) (hb : ∀ k i,|b k i|≤R) (ha : ∀ i,|a i|≤R) + (ht : Tendsto b atTop (𝓝 a)) (x : ℝ) (r : ℕ) : + Tendsto (fun k ↦ newtonKernel (b k) x 0 r) atTop (𝓝 (newtonKernel a x 0 r)) := by + let S : Set (ℕ → ℝ):={v | ∀ i,|v i|≤R} + have hc : ContinuousOn (fun v ↦ newtonKernel v x 0 r) S := + continuousOn_newtonKernel hR continuousOn_id (fun v hv ↦ hv) x 0 r + exact (hc a ha).tendsto.comp (tendsto_nhdsWithin_iff.mpr ⟨ht,Filter.Eventually.of_forall hb⟩) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ObliqueBounds.lean b/lean/OAI/Combinatorics/HoneycombChords/ObliqueBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..13c6069b93a55f4d5861f6fae7b7b7faac103920 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ObliqueBounds.lean @@ -0,0 +1,1017 @@ +import OAI.Combinatorics.HoneycombChords.OrderedAssociation + +namespace OAI + +/-! +# Oblique residual and denominator bounds + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section + +namespace CriticalHoneycomb.FiniteFunctional +open StripAsymptotic Matrix MeasureTheory + +lemma obliqueProjection_sub {N : ℕ} {H K : ℝ → ℂ} + (hH : InPairingDomain N H) (hK : InPairingDomain N K) : + obliqueProjection N (H-K)=obliqueProjection N H-obliqueProjection N K := by + symm + apply projection_unique + · exact Submodule.sub_mem _ (projection_mem N H) (projection_mem N K) + · intro j + rw [pairing_sub (projection_integrable N H j) (projection_integrable N K j), + projection_pairing,projection_pairing,pairing_sub (hH j) (hK j)] + +lemma obliqueResidual_sub {N : ℕ} {H K : ℝ → ℂ} + (hH : InPairingDomain N H) (hK : InPairingDomain N K) : + obliqueResidual N (H-K)=obliqueResidual N H-obliqueResidual N K := by + simp only [obliqueResidual,obliqueProjection_sub hH hK] + abel + +lemma familyGram_neg_left {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) : + familyGram w (fun i x=> -F i x) G= -(familyGram w F G) := by + ext i j + simp only [familyGram,neg_mul,integral_neg,Matrix.neg_apply] + +lemma cThree_neg_residual_positiveEvaluation (N : ℕ) : + PositiveEvaluation (fun i x=> + -residualFamily (fixedFamily N) (fun x=>(C (3*angle/2) x).re) 0 i x) := by + intro x hx hx0 + have he : evaluationMatrix (fun i x=> + -residualFamily (fixedFamily N) (fun x=>(C (3*angle/2) x).re) 0 i x) x= + -(evaluationMatrix (residualFamily (fixedFamily N) (fun x=>(C (3*angle/2) x).re) 0) x) := rfl + rw [he,Matrix.det_neg] + simp only [Fintype.card_fin,pow_add,pow_mul,neg_one_sq,one_pow,one_mul,pow_one,neg_mul,one_mul] + exact neg_pos.mpr (cThree_residual_evaluation_neg N x hx hx0) + +lemma cThree_residual_gram_neg (N : ℕ) : + (familyGram stripDensity (residualFamily (fixedFamily N) (fun x=>(C (3*angle/2) x).re) 0) + (mixedFamily N)).det<0 := by + have hi := residualFamily_pair_integrable stripDensity (fixedFamily N) (mixedFamily N) + (fun x=>(C (3*angle/2) x).re) 0 (fixed_mixed_pair_integrable N) + (pairingDomain_real_integrable (N:=N) (H:=C (3*angle/2)) + (C_ofReal_re (3*angle/2)) (cThree_in_pairingDomain N)) + have hn : ∀ i j,IntegrableOn (fun p=> + (-residualFamily (fixedFamily N) (fun x=>(C (3*angle/2) x).re) 0 i (p^2))* + mixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0) := by + intro i j + apply (hi i j).neg.congr + filter_upwards with p + simp only [Pi.neg_apply,neg_mul] + have hp:=familyGram_det_pos stripDensity _ (mixedFamily N) (cThree_neg_residual_positiveEvaluation N) + (mixedFamily_positiveEvaluation N) (fun _ h=>stripDensity_pos h) hn + rw [familyGram_neg_left,Matrix.det_neg] at hp + simp only [Fintype.card_fin,pow_add,pow_mul,neg_one_sq,one_pow,one_mul,pow_one,neg_mul,one_mul] at hp + exact neg_pos.mp hp + +lemma cThree_residual_zero_neg (N : ℕ) : + (obliqueResidual N (C (3*angle/2)) 0).re<0 := by + have h0 : (C (3*angle/2) 0).re ≠ 0 := by rw [cThree_zero];norm_num + rw [source_residual_mean (N:=N) (H:=C (3*angle/2)) (C_ofReal_re (3*angle/2)) (cThree_in_pairingDomain N) h0] + simp only [Complex.ofReal_re,cThree_zero,one_mul,meanResidualRatio] + exact div_neg_of_neg_of_pos (cThree_residual_gram_neg N) (fixed_mixed_Gram_det_pos N) + +lemma hOne_residual_positiveEvaluation {N : ℕ} (hN : 1 ≤ N) : + PositiveEvaluation (residualFamily (fixedFamily N) (fun x=>(hOne x).re) 0) := by + intro x hx hx0 + let z:=nodeExtension x + have hz i : 0z i) := by simpa only [z,nodeExtension_fin] using hx + have h:= (source_hOne_kernel_bounds hN (u:=0) le_rfl (by norm_num) + (half_pos strip_angle_pos) (by linarith [strip_angle_pos]) z hz hzo).1 + have pp : 0z j+0) (shiftedPole 0 0) (2*N+1) := by + apply poleProduct_pos _ (by simpa only [add_zero] using hz) + norm_num [shiftedPole,physicalPole] + rw [kernelOriginFunctional_eq_residual_det (interiorKnotLabels N (angle/2)) z 0 + (fun x=>(hOne x).re)] at h + simp only [neg_zero,z,nodeExtension_fin] at h + have hd:=(fixedFamily_positiveEvaluation N) x hx hx0 + have hh : 0<(evaluationMatrix (residualFamily (fixedFamily N) (fun x=>(hOne x).re) 0) x).det / + (evaluationMatrix (fixedFamily N) x).det := by + exact lt_of_lt_of_le (mul_pos (by norm_num) pp) h + exact (div_pos_iff.mp hh).elim (fun h=>h.1) (fun h=>False.elim (not_lt_of_ge hd.le h.2)) + +lemma hOne_residual_zero_pos {N : ℕ} (hN : 1 ≤ N) : + 0<(obliqueResidual N hOne 0).re := by + have hi:=residualFamily_pair_integrable stripDensity (fixedFamily N) (mixedFamily N) + (fun x=>(hOne x).re) 0 (fixed_mixed_pair_integrable N) + (pairingDomain_real_integrable hOne_ofReal_re (hOne_in_pairingDomain N)) + have hp:=familyGram_det_pos stripDensity _ (mixedFamily N) (hOne_residual_positiveEvaluation hN) + (mixedFamily_positiveEvaluation N) (fun _ h=>stripDensity_pos h) hi + have h0:=hOne_re_pos (x:=0) (by norm_num) + rw [source_residual_mean hOne_ofReal_re (hOne_in_pairingDomain N) h0.ne',Complex.ofReal_re] + exact mul_pos h0 (div_pos hp (fixed_mixed_Gram_det_pos N)) + +/-- The residual denominator is strictly negative. -/ +theorem source_residual_denominator_neg {N : ℕ} (hN : 1 ≤ N) : + (obliqueResidual N cThreeCorrection 0).re<0 := by + rw [cThreeCorrection,obliqueResidual_sub (cThree_in_pairingDomain N) (hOne_in_pairingDomain N), + Pi.sub_apply,Complex.sub_re] + linarith [cThree_residual_zero_neg N,hOne_residual_zero_pos hN] + +theorem source_residual_denominator_ne_zero {N : ℕ} (hN : 1 ≤ N) : + obliqueResidual N cThreeCorrection 0≠0 := by + intro he + have h:=source_residual_denominator_neg hN + rw [he,Complex.zero_re] at h + exact (lt_irrefl 0 h) + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open StripAsymptotic Matrix MeasureTheory Filter + +lemma cThree_minus_four_pos : 0<(C (3*angle/2) (-4)).re := by + rw [C,ite_eq_right (show ¬(0:ℝ)≤ -4 by norm_num),Complex.ofReal_re] + have hs : Real.sqrt (-(-4:ℝ))=2 := by norm_num + rw [hs,show 3*angle/2*2=3*angle by ring] + apply Real.cos_pos_of_mem_Ioo + constructor <;> unfold angle <;> linarith [Real.pi_pos] + +lemma extended_negative_phase : Real.sqrt ((3*angle/2)^2)*Real.sqrt 4(C (3*angle/2) x).re) (-4)) x).det≤0 := by + have he:=residual_det_augment_at (fixedFamily N) (fun x=>(C (3*angle/2) x).re) (-4) + cThree_minus_four_pos.ne' x + have hh : 0≤(evaluationMatrix (Fin.lastCases (fun x=>(C (3*angle/2) x).re) (fixedFamily N)) + (Fin.cons (-4) x)).det := by + rw [←extended_family] + let v : Fin (2*N+2) → ℝ := Fin.cons 0 (fun i=>x i+4) + have hv : StrictMono v := by + intro i j + refine Fin.cases ?_ (fun i=>?_) i + · refine Fin.cases (fun h=>False.elim (lt_irrefl _ h)) (fun j _=>?_) j + change 0False.elim (Fin.not_lt_zero _ h)) (fun j h=>?_) j + change x i+4by change 0≤x i+4;linarith [hx0 i]) + have ht:=translated_kernel_det_nonneg (a:=4) (R:=(3*angle/2)^2) (by norm_num) + (sq_pos_of_pos (by linarith [strip_angle_pos] : 0<3*angle/2)) extended_negative_phase (extendedKnotLabels N) + ((extendedKnot_monotone N).comp (fun _ _ h=>h)) + (fun i=>⟨extendedKnot_nonneg N i,extendedKnot_bound N i⟩) v hv hv0 + have hvx : (fun j=> -4+v j)=Fin.cons (-4) x := by + funext j + refine Fin.cases ?_ (fun j=>?_) j + · simp [v] + · simp [v] + change 0≤(evaluationMatrix (fun i : Fin (2*N+2)=>cosineKernelJet + (nodalOrder (extendedKnotLabels N) i) 0 (extendedKnotLabels N i)) (fun j : Fin (2*N+2)=> -4+v j)).det at ht + rw [hvx] at ht + exact ht + have hn : (-1:ℝ)^(2*N+1)= -1 := by simp [pow_add,pow_mul] + rw [hn] at he + nlinarith [cThree_minus_four_pos] + +lemma familyGram_det_nonneg_of_sorted {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (hD : ∀ p : Fin n → ℝ,StrictMono p → (∀ i,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + 0≤(familyGram w F G).det := by + let μ:=Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))) + have hae : ∀ᵐ p ∂μ,∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) (i:=i)).eventually (ae_restrict_mem measurableSet_Ioi) + have hp:=pointDensity_lower_of_sorted w w F G F 0 (by simpa only [zero_mul] using hD) + have hI : 0≤∫ p,familyPointDensity w F G p ∂μ := integral_nonneg_of_ae (hae.mono (by simpa only [zero_mul,Pi.zero_apply] using hp)) + rw [(family_gram_andreief w F G hi).2] at hI + have hc : (0:ℝ)(C (3*angle/2) x).re) (-4) + have hi:=residualFamily_pair_integrable stripDensity (fixedFamily N) (mixedFamily N) + (fun x=>(C (3*angle/2) x).re) (-4) (fixed_mixed_pair_integrable N) + (pairingDomain_real_integrable (N:=N) (H:=C (3*angle/2)) + (C_ofReal_re (3*angle/2)) (cThree_in_pairingDomain N)) + have hn : ∀ i j,IntegrableOn (fun p=>(-R i (p^2))*mixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0) := by + intro i j + apply (hi i j).neg.congr + filter_upwards with p + simp only [Pi.neg_apply,neg_mul,R] + have hg : 0≤(familyGram stripDensity (fun i x=> -R i x) (mixedFamily N)).det := by + apply familyGram_det_nonneg_of_sorted _ _ _ _ hn + intro p hp hp0 + have hp2 : StrictMono (fun i=>(p i)^2) := by + intro i j hij + exact (sq_lt_sq₀ (hp0 i).le (hp0 j).le).mpr (hp hij) + have hs:=cThree_residual_evaluation_minus_four_nonpos N (fun i=>(p i)^2) hp2 (fun i=>sq_pos_of_pos (hp0 i)) + have he : evaluationMatrix (fun i x=> -R i x) (fun i=>(p i)^2)= + -(evaluationMatrix R (fun i=>(p i)^2)) := rfl + rw [familyPointDensity,he,Matrix.det_neg] + simp only [Fintype.card_fin,pow_add,pow_mul,neg_one_sq,one_pow,one_mul,pow_one,neg_mul] + exact mul_nonneg (mul_nonneg (Finset.prod_nonneg (fun i _=>(stripDensity_pos (hp0 i)).le)) + (neg_nonneg.mpr hs)) ((mixedFamily_positiveEvaluation N) _ hp2 (fun i=>sq_pos_of_pos (hp0 i))).le + rw [familyGram_neg_left,Matrix.det_neg] at hg + simp only [Fintype.card_fin,pow_add,pow_mul,neg_one_sq,one_pow,one_mul,pow_one,neg_mul] at hg + rw [source_residual_mean (N:=N) (H:=C (3*angle/2)) (C_ofReal_re (3*angle/2)) + (cThree_in_pairingDomain N) cThree_minus_four_pos.ne',Complex.ofReal_re] + apply mul_nonpos_of_nonneg_of_nonpos cThree_minus_four_pos.le + exact div_nonpos_of_nonpos_of_nonneg (neg_nonneg.mp hg) (fixed_mixed_Gram_det_pos N).le + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter Topology + +lemma familyGram_det_le_of_sorted {n : ℕ} (w v : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (hD : ∀ p : Fin n → ℝ,StrictMono p → (∀ i,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hv : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*v p) (Set.Ioi 0)) : + (familyGram w F G).det≤(familyGram v F G).det := by + let μ:=Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))) + have hae : ∀ᵐ p ∂μ,∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) (i:=i)).eventually (ae_restrict_mem measurableSet_Ioi) + have hp:=pointDensity_lower_of_sorted v w F G F 1 (by simpa only [one_mul] using hD) + have hI:=integral_mono_ae (family_gram_andreief w F G hi).1 + (family_gram_andreief v F G hv).1 (hae.mono (by simpa only [one_mul] using hp)) + rw [(family_gram_andreief w F G hi).2,(family_gram_andreief v F G hv).2] at hI + have hc : (0:ℝ) + stripJetFamily N s i (p^2)*stripJetFamily N t j (p^2)*(physicalFixedWeight u p*stripDensity p)) (Set.Ioi 0) := by + rw [physicalFixedWeight_characteristic hu] + exact stripJet_characteristic_pair_integrable N hs hsL ht htL (by norm_num) _ + have hn : 0<(familyGram (fun p=>physicalFixedWeight 0 p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t)).det := by + apply familyGram_det_pos _ _ _ (stripJet_positiveEvaluation N hs hsL) (stripJet_positiveEvaluation N ht htL) + _ (hi 0 le_rfl) + intro p hp + apply mul_pos _ (stripDensity_pos hp) + unfold physicalFixedWeight physicalPole + positivity + have hm := familyGram_det_le_of_sorted + (fun p=>physicalFixedWeight 0 p*stripDensity p) (fun p=>physicalFixedWeight 1 p*stripDensity p) + (stripJetFamily N s) (stripJetFamily N t) ?_ (hi 0 le_rfl) (hi 1 (by norm_num)) + · exact ⟨(div_pos hn (stripJet_gram_det_pos N hs hsL ht htL)).le, + div_le_div_of_nonneg_right hm (stripJet_gram_det_pos N hs hsL ht htL).le⟩ + · intro p hpo hp0 + rw [familyPointDensity_tilt,familyPointDensity_tilt] + apply mul_le_mul_of_nonneg_right _ (familyPointDensity_pos _ _ _ _ + (stripJet_positiveEvaluation N hs hsL) (stripJet_positiveEvaluation N ht htL) + hp0 (fun _ h=>stripDensity_pos h) hpo.injective).le + apply Finset.prod_le_prod₀ + · intro i _ + unfold physicalFixedWeight physicalPole + positivity + · intro i _ + unfold physicalFixedWeight + apply div_le_div_of_nonneg_right (by linarith) (by unfold physicalPole;positivity) + +/-- A decaying upper bound for residual means at the origin. -/ +lemma physical_means_at_zero_upper : + ∃ A : ℝ,0(hZero x).re) 0 ∧ + meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hZero x).re) 0 ≤ A*P) ∧ + (0 ≤ meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hOne x).re) 0 ∧ + meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hOne x).re) 0 ≤ A*P) := by + obtain ⟨a,A,ha,hA,hbound⟩:=jetFixedMean_bounds (u:=1) (by norm_num) (by norm_num) + simp only [Real.sqrt_one, show (3 * (1 - 8 / 3) / 8 : ℝ) = -5 / 8 by norm_num] at hbound + let E : ℝ:=Real.exp (3*physicalPole 0) + let ε : ℝ:=Real.log (3/2)/2 + have he : 0<ε := by dsimp [ε];exact div_pos (Real.log_pos (by norm_num)) (by norm_num) + refine ⟨2*E*A+2,by dsimp [E];positivity,?_⟩ + filter_upwards [hbound,jetMovingMean_bound he,exponential_tail_below_power (-5/8),eventually_ge_atTop (1:ℕ)] with N hB hM htail hN + intro s t hs hsL ht htL + dsimp only + let P : ℝ:=((N:ℝ)+1)^(-5/8:ℝ) + have hP : 0

F i.succ y-F i.succ 0) + (fun y=>H y-H 0) a) x).det := by + let B:=evaluationMatrix (residualFamily F H a) (Fin.cons 0 x) + let R:=evaluationMatrix (residualFamily (fun i y=>F i.succ y-F i.succ 0) + (fun y=>H y-H 0) a) x + let A : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := fun i j=> + Fin.cases (B 0 j) (fun i=>Fin.cases 0 (fun j=>R i j) j) i + let c : Fin (n+1) → ℝ:=Fin.cons 0 (fun i=> -B i.succ 0 / B 0 0) + have he : A.det=B.det := by + apply Matrix.det_eq_of_forall_row_eq_smul_add_const c 0 (by simp [c]) + intro i j + refine Fin.cases ?_ (fun i=>?_) i + · simp [A,c] + · refine Fin.cases ?_ (fun j=>?_) j + · have hh : B 0 0≠0 := by + dsimp [B,evaluationMatrix,residualFamily] + simp only [hF,Fin.cons_zero] + field_simp + simpa only [mul_zero] using hHa + simp [A,c,hh] + · simp only [A,c,Fin.cases_succ,Fin.cons_succ] + dsimp [B,R,evaluationMatrix,residualFamily] + simp only [Fin.cons_succ,Fin.cons_zero,hF] + field_simp + ring + rw [Matrix.det_succ_column_zero,Fin.sum_univ_succ] at he + have hs : (∑ i : Fin n,(-1:ℝ)^i.succ.val*A i.succ 0* + (A.submatrix i.succ.succAbove Fin.succ).det)=0 := by + apply sum_eq_zero + intro i _ + simp [A] + rw [hs,add_zero] at he + have hm : A.submatrix (0:Fin (n+1)).succAbove Fin.succ=R := by + ext i j + simp [A,Matrix.submatrix] + rw [hm] at he + have hb : A 0 0=(H a-H 0)/H a := by + simp only [A,Fin.cases_zero,B,evaluationMatrix,residualFamily,Fin.cons_zero,hF] + field_simp + simpa only [Fin.val_zero,pow_zero,one_mul,hb,A,B,R] using he.symm + +lemma zeroJet_as_tail {n : ℕ} (b : ℕ → ℝ) : + (fun i : Fin (n+1) =>fun x=>cosineKernelJet (nodalOrder b i) 0 (b i) x) = + Fin.cons (cosineKernelJet (nodalOrder b 0) 0 (b 0)) + (fun i : Fin n=>fun x=>cosineKernelJet (nodalOrder b (i+1)) 0 (b (i+1)) x) := by + funext i + refine Fin.cases rfl (fun i=>rfl) i + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open StripAsymptotic Matrix MeasureTheory Filter Topology + +lemma hZero_residual_zero_pos {N : ℕ} (hN : 1≤N) : + 0<(obliqueResidual N hZero 0).re := by + have hF : PositiveEvaluation (residualFamily (fixedFamily N) (fun x=>(hZero x).re) 0) := by + intro x hx hx0 + let z:=nodeExtension x + have hz i : 0z i) := by simpa only [z,nodeExtension_fin] using hx + have h:= (source_hZero_kernel_bounds hN (u:=0) le_rfl (by norm_num) + (half_pos strip_angle_pos) (by linarith [strip_angle_pos]) z hz hzo).1 + have pp : 0z j+0) (shiftedPole 0 0) (2*N+1) := by + apply poleProduct_pos _ (by simpa only [add_zero] using hz) + norm_num [shiftedPole,physicalPole] + rw [kernelOriginFunctional_eq_residual_det (interiorKnotLabels N (angle/2)) z 0 + (fun x=>(hZero x).re)] at h + simp only [neg_zero,z,nodeExtension_fin] at h + have hd:=(fixedFamily_positiveEvaluation N) x hx hx0 + have hh : 0<(evaluationMatrix (residualFamily (fixedFamily N) (fun x=>(hZero x).re) 0) x).det / + (evaluationMatrix (fixedFamily N) x).det := lt_of_lt_of_le pp h + exact (div_pos_iff.mp hh).elim (fun h=>h.1) (fun h=>False.elim (not_lt_of_ge hd.le h.2)) + have hi:=residualFamily_pair_integrable stripDensity (fixedFamily N) (mixedFamily N) + (fun x=>(hZero x).re) 0 (fixed_mixed_pair_integrable N) + (pairingDomain_real_integrable hZero_ofReal_re (hZero_in_pairingDomain N)) + have hp:=familyGram_det_pos stripDensity _ (mixedFamily N) hF + (mixedFamily_positiveEvaluation N) (fun _ h=>stripDensity_pos h) hi + have h0:=hZero_re_pos (x:=0) (by norm_num) + rw [source_residual_mean hZero_ofReal_re (hZero_in_pairingDomain N) h0.ne',Complex.ofReal_re] + exact mul_pos h0 (div_pos hp (fixed_mixed_Gram_det_pos N)) + +lemma residual_ofReal_re (N : ℕ) {H : ℝ → ℂ} (hr : ∀ x,((H x).re:ℂ)=H x) (a : ℝ) : + (((obliqueResidual N H a).re):ℂ)=obliqueResidual N H a := by + have he : H=fun x=>((H x).re:ℂ) := by funext x;exact (hr x).symm + rw [he,obliqueResidual,Pi.sub_apply,projection_ofReal,←Complex.ofReal_sub,Complex.ofReal_re] + +lemma correction_ofReal_re (x : ℝ) : ((cThreeCorrection x).re:ℂ)=cThreeCorrection x := by + change (((C (3*angle/2) x-hOne x).re):ℂ)=_ + rw [Complex.sub_re,Complex.ofReal_sub,C_ofReal_re,hOne_ofReal_re] + rfl + +lemma aStar_eq_ofReal : aStar=((2*Real.cos (2*angle)-1:ℝ):ℂ) := by + simp only [aStar,Complex.ofReal_sub,Complex.ofReal_mul,Complex.ofReal_one,Complex.ofReal_ofNat] +lemma aStar_ofReal_re : ((aStar.re):ℂ)=aStar := by + rw [aStar_eq_ofReal,Complex.ofReal_re] +lemma aStar_re_pos : 0zeroJet (extendedKnotLabels N) i +noncomputable def pinnedHZero (x : ℝ) : ℝ := (hZero x).re-1 + +lemma hZero_zero : (hZero 0).re=1 := by simp [hZero,D_zero] + +lemma hZero_minus_four_gt_one : 1<(hZero (-4)).re := by + have he : (hZero (-4)).re=1/(2*Real.cos (2*angle)-1) := by + rw [hZero,D_neg_four,aStar_eq_ofReal,←Complex.ofReal_inv,Complex.ofReal_re,one_div] + rw [he] + have hd : 0<2*Real.cos (2*angle)-1 := by + unfold angle + rw [show 2*(Real.pi/8)=Real.pi/4 by ring,Real.cos_pi_div_four] + nlinarith [Real.sq_sqrt (by norm_num : (0:ℝ)≤2),Real.sqrt_nonneg (2:ℝ)] + apply (one_lt_div hd).mpr + unfold angle + rw [show 2*(Real.pi/8)=Real.pi/4 by ring,Real.cos_pi_div_four] + nlinarith [Real.sq_sqrt (by norm_num : (0:ℝ)≤2),Real.sqrt_nonneg (2:ℝ)] + +lemma pinnedHZero_minus_four_pos : 0extendedKnot_monotone N h) (fun i=>extendedKnot_nonneg N i) + (extendedKnot_first N (by omega)) hx hx0 + +lemma pinned_kernel_ratio {N : ℕ} (hN : 1≤N) (x : Fin (2*N+1) → ℝ) : + (evaluationMatrix (residualFamily + (fun i : Fin (2*N+2)=>cosineKernelJet (nodalOrder (extendedKnotLabels N) i) 0 (extendedKnotLabels N i)) + (fun x=>(hZero x).re) (-4)) (Fin.cons 0 x)).det / + (jetEvaluation (extendedKnotLabels N) (Fin.cons 0 x)).det = + (pinnedHZero (-4)/(hZero (-4)).re)* + ((evaluationMatrix (residualFamily (pinnedFamily N) pinnedHZero (-4)) x).det / + (evaluationMatrix (pinnedFamily N) x).det) := by + have hf : extendedKnotLabels N 0=0 := extendedKnot_first N (by omega) + have he:=pinned_residual_det + (fun i : Fin (2*N+2)=>cosineKernelJet (nodalOrder (extendedKnotLabels N) i) 0 (extendedKnotLabels N i)) + (fun y=>jet_first_constant (extendedKnotLabels N) hf y) (fun x=>(hZero x).re) (-4) x + (by linarith [hZero_minus_four_gt_one]) (by rw [hZero_zero];exact pinnedHZero_minus_four_pos.ne') + rw [hZero_zero] at he + rw [he,←zeroJetEvaluation_det (extendedKnotLabels N) x hf] + exact mul_div_assoc _ _ _ + +lemma pinned_kernel_lower {N : ℕ} (hN : 1≤N) (x : Fin (2*N+1) → ℝ) + (hx : StrictMono x) (hx0 : ∀ i,0(hx0 i).le) ⟨i,h⟩ + · norm_num + have hzo : StrictMono (fun i : Fin (2*N+2)=>z i) := by + simp only [z,nodeExtension_fin] + intro i j + refine Fin.cases ?_ (fun i=>?_) i + · refine Fin.cases (fun h=>False.elim (lt_irrefl _ h)) (fun j _=>hx0 j) j + · refine Fin.cases (fun h=>False.elim (Fin.not_lt_zero _ h)) (fun j h=>?_) j + exact hx (Fin.succ_lt_succ_iff.mp h) + have hb:=kernel_hZero_bounds (n:=2*N+1) (q:=0) (u:=4) (R:=(3*angle/2)^2) + (by norm_num) le_rfl (sq_pos_of_pos (by linarith [strip_angle_pos])) + CriticalHoneycomb.FiniteFunctional.extended_negative_phase + (extendedKnotLabels N) (fun i=>z i+4) + (fun _ _ h=>extendedKnot_monotone N h) + (fun i=>⟨extendedKnot_nonneg N i,extendedKnot_bound N i⟩) (by omega) + (fun i hi=>by + have he : i=0 := by omega + subst i + exact extendedKnot_first N (by omega)) + (fun i=>by linarith [hz i]) (fun i=>by linarith [hz i]) + (fun _ _ h=>by have ht:=hzo h;linarith) + rw [kernelOriginFunctional_eq_residual_det (extendedKnotLabels N) z 4 + (fun x=>(hZero x).re)] at hb + have he : (fun i : Fin (2*N+2)=>z i)=Fin.cons 0 x := by + funext i;simp [z,nodeExtension_fin] + rw [he,pinned_kernel_ratio hN x] at hb + have hp : poleProduct (fun i=>z i+4) (shiftedPole 4 0) (2*N+2)= + (9/16:ℝ)*(∏ i,(x i+4)/(x i+physicalPole 0)) := by + rw [physical_pole_product] + unfold fixedPoleProduct + dsimp only [z] + rw [nodeExtension_prod (Fin.cons 0 x) (fun y=>(y+4)/(y+physicalPole 0)),Fin.prod_univ_succ] + simp only [Fin.cons_zero,Fin.cons_succ,zero_add] + norm_num [physicalPole] + rw [hp] at hb + have hc : 0cosineKernelJet s 0 c (p^2)*stripDensity p) (Set.Ioi 0) := by + simpa only [cosineKernelJet_at_zero,pow_zero,mul_zero,Nat.factorial_zero,Nat.cast_one,div_one,one_mul] + using strip_jet_pair_integrable (b:=0) (by rfl) hc0 (by positivity) hc 0 s + +lemma pinnedFamily_pair_integrable (N : ℕ) {t : ℝ} (ht : 0pinnedFamily N i (p^2)*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0) := by + have hi:=strip_jet_pair_integrable (extendedKnot_nonneg N (i+1)) (interiorKnot_nonneg N j t) + (extendedKnot_bound N (i+1)) (interiorKnot_le N j ht htL) + (nodalOrder (extendedKnotLabels N) (i+1)) (nodalOrder (interiorKnotLabels N t) j) + have h0:=strip_jet_constant_pair_integrable (interiorKnot_nonneg N j t) + (interiorKnot_le N j ht htL) (nodalOrder (interiorKnotLabels N t) j) + convert hi.sub (h0.const_mul (cosineKernelJet (nodalOrder (extendedKnotLabels N) (i+1)) 0 (extendedKnotLabels N (i+1)) 0)) using 1 + funext p + simp only [pinnedFamily,zeroJet,stripJetFamily,Pi.sub_apply] + ring + +lemma pinnedFamily_characteristic_pair_integrable (N : ℕ) {t z : ℝ} (ht : 0pinnedFamily N i (p^2)*stripJetFamily N t j (p^2)* + (characteristicRatio y z p*stripDensity p)) (Set.Ioi 0) := by + have hi:=pole_jet_pair_pencil_integrable (extendedKnot_nonneg N (i+1)) (interiorKnot_nonneg N j t) + (extendedKnot_bound N (i+1)) (interiorKnot_le N j ht htL) hz + (nodalOrder (extendedKnotLabels N) (i+1)) (nodalOrder (interiorKnotLabels N t) j) (-(y^2)) + have h0:=pole_jet_pair_pencil_integrable (b:=0) (by rfl) (interiorKnot_nonneg N j t) + (by positivity) (interiorKnot_le N j ht htL) hz 0 (nodalOrder (interiorKnotLabels N t) j) (-(y^2)) + simp only [cosineKernelJet_at_zero,pow_zero,mul_zero,Nat.factorial_zero,Nat.cast_one,div_one] at h0 + apply (hi.sub (h0.const_mul (cosineKernelJet (nodalOrder (extendedKnotLabels N) (i+1)) 0 (extendedKnotLabels N (i+1)) 0))).congr + filter_upwards with p + simp only [Pi.sub_apply] + rw [congrFun (pole_pencil_tilt_weight y z) p] + simp only [pinnedFamily,zeroJet,stripJetFamily] + ring + +lemma pinnedFamily_jet_Gram_pos {N : ℕ} (hN : 1≤N) {t : ℝ} (ht : 0stripDensity_pos h) (pinnedFamily_pair_integrable N ht htL) + +lemma pinnedHZero_jet_integrable (N : ℕ) {t : ℝ} (ht : 0pinnedHZero (p^2)*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0) := by + convert (hZero_stripJet_integrable N ht htL j).sub + (strip_jet_constant_pair_integrable (interiorKnot_nonneg N j t) (interiorKnot_le N j ht htL) + (nodalOrder (interiorKnotLabels N t) j)) using 1 + funext p + simp only [pinnedHZero,stripJetFamily,Pi.sub_apply] + ring + +lemma pinnedFamily_measurable (N : ℕ) (i : Fin (2*N+1)) : + Measurable (fun p=>pinnedFamily N i (p^2)*stripDensity p) := by + have hc : Continuous (fun p : ℝ=>pinnedFamily N i (p^2)) := + ((cosineKernelJet_contDiff_right _ 0 _ 0).continuous.comp (by fun_prop)).sub continuous_const + exact hc.measurable.mul (by unfold stripDensity;fun_prop) + +lemma pinnedFamily_cosh_integrable (N : ℕ) (i : Fin (2*N+1)) : + IntegrableOn (fun p=>|pinnedFamily N i (p^2)*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0) := by + apply weighted_cosh_norm_integrable + have hi:=strip_jet_pair_integrable (extendedKnot_nonneg N (i+1)) (sq_nonneg angle) + (extendedKnot_bound N (i+1)) le_rfl (nodalOrder (extendedKnotLabels N) (i+1)) 0 + have h0:=strip_jet_constant_pair_integrable (sq_nonneg angle) le_rfl 0 + apply (hi.sub (h0.const_mul (cosineKernelJet (nodalOrder (extendedKnotLabels N) (i+1)) 0 (extendedKnotLabels N (i+1)) 0))).congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have he : cosineKernelJet 0 0 (angle^2) (p^2)=Real.cosh (angle*p) := by + apply Complex.ofReal_injective + rw [←C_eq_beta_square,C_sq _ hp.le] + simp only [Pi.sub_apply,he,pinnedFamily,zeroJet] + ring + +lemma pinnedHZero_measurable : Measurable (fun p=>pinnedHZero (p^2)*stripDensity p) := + (hZero_sq_measurable.sub measurable_const).mul (by unfold stripDensity;fun_prop) + +lemma pinnedHZero_cosh_integrable : + IntegrableOn (fun p=>|pinnedHZero (p^2)*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0) := by + have hi:=bounded_target_cosh_integrable (fun x=>(hZero x).re) hZero_sq_measurable + (fun p hp=>hZero_sq_unit hp.le) + have h0:=bounded_target_cosh_integrable (fun _=>1) measurable_const (by intros;norm_num) + apply weighted_cosh_norm_integrable + convert (weighted_cosh_signed_integrable (hZero_sq_measurable.mul (by unfold stripDensity;fun_prop)) hi).sub + (weighted_cosh_signed_integrable (by simpa only [one_mul] using + (show Measurable stripDensity by unfold stripDensity;fun_prop)) h0) using 1 + funext p + simp only [Pi.sub_apply,Pi.mul_apply,pinnedHZero] + ring + +lemma pinnedFamily_mixed_pair_integrable (N : ℕ) (i j : Fin (2*N+1)) : + IntegrableOn (fun p=>pinnedFamily N i (p^2)*mixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0) := by + by_cases hj : j=centralIndex N + · subst j + simp only [mixedFamily,Function.update_self] + have hi:=jet_realG_pair_integrable (extendedKnot_nonneg N (i+1)) (extendedKnot_bound N (i+1)) + (nodalOrder (extendedKnotLabels N) (i+1)) + have h0:=jet_realG_pair_integrable (b:=0) (by rfl) (by positivity) 0 + simp only [cosineKernelJet_at_zero,pow_zero,mul_zero,Nat.factorial_zero,Nat.cast_one,div_one,one_mul] at h0 + convert hi.sub (h0.const_mul (cosineKernelJet (nodalOrder (extendedKnotLabels N) (i+1)) 0 (extendedKnotLabels N (i+1)) 0)) using 1 + funext p + simp only [Pi.sub_apply,pinnedFamily,zeroJet] + ring + · simp only [mixedFamily,Function.update_of_ne hj] + exact pinnedFamily_pair_integrable N (half_pos strip_angle_pos) (by linarith [strip_angle_pos]) i j + +lemma pinnedFamily_mixed_Gram_pos {N : ℕ} (hN : 1≤N) : + 0<(familyGram stripDensity (pinnedFamily N) (mixedFamily N)).det := + familyGram_det_pos _ _ _ (pinnedFamily_positiveEvaluation hN) (mixedFamily_positiveEvaluation N) + (fun _ h=>stripDensity_pos h) (pinnedFamily_mixed_pair_integrable N) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter Topology + +lemma pinned_density_lower {N : ℕ} (hN : 1≤N) {t : ℝ} (ht : 0physicalFixedWeight 4 p*stripDensity p) (pinnedFamily N) (stripJetFamily N t) p ≤ + familyPointDensity stripDensity (residualFamily (pinnedFamily N) pinnedHZero (-4)) (stripJetFamily N t) p := by + apply pointDensity_lower_of_sorted + intro p hp hp0 + have hp2 : StrictMono (fun i=>(p i)^2) := by + intro i j hij + exact (sq_lt_sq₀ (hp0 i).le (hp0 j).le).mpr (hp hij) + have hx0 i : 0<(p i)^2 := sq_pos_of_pos (hp0 i) + have hd:=(pinnedFamily_positiveEvaluation hN) _ hp2 hx0 + have hbase : 0≤familyPointDensity stripDensity (pinnedFamily N) (stripJetFamily N t) p := + (familyPointDensity_pos _ _ _ _ (pinnedFamily_positiveEvaluation hN) + (stripJet_positiveEvaluation N ht htL) hp0 (fun _ h=>stripDensity_pos h) hp.injective).le + have h:=mul_le_mul_of_nonneg_right (pinned_kernel_lower hN (fun i=>(p i)^2) hp2 hx0) hbase + rw [normalized_residual_density _ _ _ _ _ _ hd.ne',familyPointDensity_tilt] + change _ ≤ _ at h + simpa only [physicalFixedWeight,mul_assoc] using h + +lemma pinned_mean_lower {N : ℕ} (hN : 1≤N) {t : ℝ} (ht : 0characteristicRatio 2 (8/3) p*stripDensity p) (pinnedFamily N) (stripJetFamily N t)).det/ + (familyGram stripDensity (pinnedFamily N) (stripJetFamily N t)).det) ≤ + meanResidualRatio stripDensity (pinnedFamily N) (stripJetFamily N t) pinnedHZero (-4) := by + have he : physicalFixedWeight 4=characteristicRatio 2 (8/3) := by + rw [physicalFixedWeight_characteristic (by norm_num : (0:ℝ)≤4)] + norm_num + rw [←he] + apply meanResidualRatio_lower + · exact pinnedFamily_pair_integrable N ht htL + · rw [he] + exact pinnedFamily_characteristic_pair_integrable N ht htL (by norm_num) 2 + · exact pinnedHZero_jet_integrable N ht htL + · exact pinnedFamily_jet_Gram_pos hN ht htL + · exact pinned_density_lower hN ht htL + +lemma mixedGram_ratio_lower (N : ℕ) (w : ℝ → ℝ) (F R : Fin (2*N+1) → ℝ → ℝ) (a : ℝ) + (hfm : ∀ i,Measurable (fun p=>F i (p^2)*w p)) + (hfi : ∀ i,IntegrableOn (fun p=>|F i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) + (hrm : ∀ i,Measurable (fun p=>R i (p^2)*w p)) + (hri : ∀ i,IntegrableOn (fun p=>|R i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) + (hd : 0<(familyGram w F (mixedFamily N)).det) + (hdt : ∀ t,0(familyGram w F (parameterFamily N t)).det) (Set.uIcc 0 angle) := by + rw [Set.uIcc_of_le strip_angle_pos.le] + exact (continuous_id.matrix_det).comp_continuousOn (parameterGram_continuousOn N w F hfm hfi) + have hcontR : ContinuousOn (fun t=>(familyGram w R (parameterFamily N t)).det) (Set.uIcc 0 angle) := by + rw [Set.uIcc_of_le strip_angle_pos.le] + exact (continuous_id.matrix_det).comp_continuousOn (parameterGram_continuousOn N w R hrm hri) + have hlo:=intervalIntegral.integral_mono_on_of_le_Ioo (μ:=volume) strip_angle_pos.le + (hcontF.intervalIntegrable.const_mul a) hcontR.intervalIntegrable + (fun t ht=>by + rw [parameterFamily_interior N ht.1 ht.2] + exact (le_div_iff₀ (hdt t ht.1 ht.2)).mp (hb t ht.1 ht.2)) + rw [intervalIntegral.integral_const_mul,←mixedGram_det_integral N w F hfm hfi, + ←mixedGram_det_integral N w R hrm hri] at hlo + exact (le_div_iff₀ hd).mpr hlo + +/-- A lower bound for the zero-pinned interpolation functional. -/ +theorem pinned_mixed_mean_lower : + ∃ a : ℝ,0(hr i).1) (fun i=>(hr i).2) + (pinnedFamily_mixed_Gram_pos hN) (fun t ht htL=>pinnedFamily_jet_Gram_pos hN ht htL) + intro t ht htL + have hl:=(hB t ht htL).1 + norm_num only [show (3*((2:ℝ)-8/3)/8)= -1/4 by norm_num] at hl + have hm:=mul_le_mul_of_nonneg_left hl hc.le + rw [←mul_assoc] at hm + simpa only [meanResidualRatio,neg_div] using hm.trans (pinned_mean_lower hN ht htL) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory + +lemma meanResidualRatio_realization {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H P : ℝ → ℝ) (a : ℝ) + (hi : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hd : (familyGram w F G).det≠0) (ha : H a≠0) + (hP : P ∈ Submodule.span ℝ (Set.range F)) + (hp : ∀ j,(∫ p in Set.Ioi 0,P (p^2)*G j (p^2)*w p)= + ∫ p in Set.Ioi 0,H (p^2)*G j (p^2)*w p) : + H a*meanResidualRatio w F G H a=H a-P a := by + obtain ⟨c,rfl⟩:=(Submodule.mem_span_range_iff_exists_fun ℝ).mp hP + let A:=familyGram w F G + let v:=fun j=>∫ p in Set.Ioi 0,H (p^2)*G j (p^2)*w p + have hc : A.transpose *ᵥ c=v := by + ext j + have hej : (fun p=>(∑ i,c i • F i) (p^2)*G j (p^2)*w p)= + fun p=>∑ i,c i*(F i (p^2)*G j (p^2)*w p) := by + funext p + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,sum_mul] + apply sum_congr rfl + intro i _ + ring + have hpj := hp j + rw [hej,integral_finsetSum _ (fun i _=>(hi i j).const_mul (c i))] at hpj + simp_rw [integral_const_mul] at hpj + simpa only [A,v,mulVec,dotProduct,familyGram,transpose_apply,mul_comm] using hpj + have hsolve : c=A.transpose⁻¹ *ᵥ v := by + rw [←hc,Matrix.mulVec_mulVec,Matrix.nonsing_inv_mul A.transpose + (isUnit_iff_ne_zero.mpr (by simpa only [det_transpose] using hd)),Matrix.one_mulVec] + have heval : (∑ i,c i • F i) a=v ⬝ᵥ (A⁻¹ *ᵥ (fun i=>F i a)) := by + rw [hsolve,Matrix.dotProduct_mulVec,←Matrix.transpose_nonsing_inv] + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,dotProduct,Matrix.mulVec,Matrix.vecMul,Matrix.transpose_apply,mul_comm] + rw [meanResidualRatio_formula w F G H a hi hH hd,heval] + have he : (fun i=>F i a/H a)=(H a)⁻¹ • (fun i=>F i a) := by + funext i + simp only [Pi.smul_apply,smul_eq_mul,div_eq_mul_inv,mul_comm] + rw [he,Matrix.mulVec_smul,dotProduct_smul] + simp only [smul_eq_mul] + dsimp only [A,v] + field_simp + +lemma zeroJet_span_of_eq_zero {n : ℕ} (b : ℕ → ℝ) (hb : b 0=0) (P : ℝ → ℝ) + (hP : P ∈ Submodule.span ℝ (Set.range (fun i : Fin (n+1)=>cosineKernelJet (nodalOrder b i) 0 (b i)))) + (h0 : P 0=0) : + P ∈ Submodule.span ℝ (Set.range (fun i : Fin n=>zeroJet b i)) := by + obtain ⟨c,rfl⟩:=(Submodule.mem_span_range_iff_exists_fun ℝ).mp hP + refine (Submodule.mem_span_range_iff_exists_fun ℝ).mpr ⟨fun i=>c i.succ,?_⟩ + funext x + symm + have hc : jetCombination b c 0=0 := by + simpa only [jetCombination,Finset.sum_apply,Pi.smul_apply,smul_eq_mul] using h0 + simpa only [jetCombination,zeroJetCombination,Finset.sum_apply,Pi.smul_apply,smul_eq_mul] using + jetCombination_eq_zeroCombination b c hb hc x + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open StripAsymptotic Matrix Finset MeasureTheory Filter + +lemma real_projection_mem (N : ℕ) (H : ℝ → ℂ) : + (fun x=>(obliqueProjection N H x).re) ∈ Submodule.span ℝ (Set.range (fixedFamily N)) := by + refine (Submodule.mem_span_range_iff_exists_fun ℝ).mpr ⟨fun i=>(projectionCoefficients N H i).re,?_⟩ + funext x + simp only [obliqueProjection,Finset.sum_apply,Pi.smul_apply,smul_eq_mul,fBasis, + Complex.re_sum,Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,mul_zero,sub_zero] + +lemma real_projection_cast (N : ℕ) {H : ℝ → ℂ} (hr : ∀ x,((H x).re:ℂ)=H x) (x : ℝ) : + (((obliqueProjection N H x).re):ℂ)=obliqueProjection N H x := by + have he : H=fun x=>((H x).re:ℂ) := by funext x;exact (hr x).symm + rw [he,projection_ofReal,Complex.ofReal_re] + +lemma extended_span_contains_fixed (N : ℕ) : + Submodule.span ℝ (Set.range (fixedFamily N)) ≤ + Submodule.span ℝ (Set.range (fun i : Fin (2*N+2)=> + cosineKernelJet (nodalOrder (extendedKnotLabels N) i) 0 (extendedKnotLabels N i))) := by + rw [extended_family] + apply Submodule.span_mono + rintro _ ⟨i,rfl⟩ + exact ⟨i.castSucc,by simp⟩ + +lemma extended_span_contains_cThree (N : ℕ) : + (fun x=>(C (3*angle/2) x).re) ∈ + Submodule.span ℝ (Set.range (fun i : Fin (2*N+2)=> + cosineKernelJet (nodalOrder (extendedKnotLabels N) i) 0 (extendedKnotLabels N i))) := by + rw [extended_family] + apply Submodule.subset_span + exact ⟨Fin.last _,by simp⟩ + +lemma extended_span_contains_one {N : ℕ} (hN : 1≤N) : + (fun _ : ℝ=>(1:ℝ)) ∈ + Submodule.span ℝ (Set.range (fun i : Fin (2*N+2)=> + cosineKernelJet (nodalOrder (extendedKnotLabels N) i) 0 (extendedKnotLabels N i))) := by + apply Submodule.subset_span + refine ⟨0,?_⟩ + funext x + exact jet_first_constant (extendedKnotLabels N) (extendedKnot_first N (by omega)) x + +/-- The zero-pinned mean is realized by the mixed Gram system. -/ +theorem pinned_realization {N : ℕ} (hN : 1≤N) : + pinnedHZero (-4)*meanResidualRatio stripDensity (pinnedFamily N) (mixedFamily N) pinnedHZero (-4)= + (obliqueResidual N hZero (-4)).re- + (obliqueResidual N (C (3*angle/2)) (-4)).re * + (obliqueResidual N hZero 0).re/(obliqueResidual N (C (3*angle/2)) 0).re := by + let H : ℝ → ℝ := fun x=>(hZero x).re + let J : ℝ → ℝ := fun x=>(C (3*angle/2) x).re + let PH : ℝ → ℝ := fun x=>(obliqueProjection N hZero x).re + let PJ : ℝ → ℝ := fun x=>(obliqueProjection N (C (3*angle/2)) x).re + let d : ℝ := (obliqueResidual N hZero 0).re/(obliqueResidual N (C (3*angle/2)) 0).re + let P : ℝ → ℝ := PH-d • PJ+d • J-(fun _=>1) + have hd : (obliqueResidual N (C (3*angle/2)) 0).re≠0 := (cThree_residual_zero_neg N).ne + have hP0 : P 0=0 := by + dsimp [P,PH,PJ,J,d] + simp only [cThree_zero] + simp only [obliqueResidual,Pi.sub_apply,Complex.sub_re,hZero_zero,cThree_zero] + simp only [obliqueResidual,Pi.sub_apply,Complex.sub_re,cThree_zero] at hd + field_simp + ring + have hPs : P∈Submodule.span ℝ (Set.range (pinnedFamily N)) := by + apply zeroJet_span_of_eq_zero (extendedKnotLabels N) (extendedKnot_first N (by omega)) P _ hP0 + apply Submodule.sub_mem + · apply Submodule.add_mem + · exact Submodule.sub_mem _ (extended_span_contains_fixed N (real_projection_mem N hZero)) + (Submodule.smul_mem _ d (extended_span_contains_fixed N (real_projection_mem N (C (3*angle/2))))) + · exact Submodule.smul_mem _ d (extended_span_contains_cThree N) + · exact extended_span_contains_one hN + have hcP : (fun x=>(P x:ℂ))=obliqueProjection N hZero-(d:ℂ) • obliqueProjection N (C (3*angle/2))+ + (d:ℂ) • C (3*angle/2)-(fun _=>1) := by + funext x + simp only [P,PH,PJ,J,Pi.sub_apply,Pi.add_apply,Pi.smul_apply,smul_eq_mul, + Complex.ofReal_sub,Complex.ofReal_add,Complex.ofReal_mul,Complex.ofReal_one, + real_projection_cast N hZero_ofReal_re,real_projection_cast N (C_ofReal_re (3*angle/2)),C_ofReal_re] + have hone : InPairingDomain N (fun _=>1) := by + intro j + have hz:=C_in_pairingDomain N 0 (by rw [abs_zero,add_zero];unfold angle;linarith [Real.pi_pos]) j + have he : C 0=(fun _=>1) := funext C_parameter_zero + rwa [he] at hz + have hHp : InPairingDomain N (fun x=>(pinnedHZero x:ℂ)) := by + have he : (fun x=>(pinnedHZero x:ℂ))=hZero-(fun _=>1) := by + funext x + simp only [pinnedHZero,Complex.ofReal_sub,Complex.ofReal_one,hZero_ofReal_re,Pi.sub_apply] + rw [he] + exact fun j=>(hZero_in_pairingDomain N j).sub (hone j) + have hHi : ∀ j,IntegrableOn (fun p=>pinnedHZero (p^2)*mixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0) := + pairingDomain_real_integrable (by intro x;rfl) hHp + have hp : ∀ j,(∫ p in Set.Ioi 0,P (p^2)*mixedFamily N j (p^2)*stripDensity p)= + ∫ p in Set.Ioi 0,pinnedHZero (p^2)*mixedFamily N j (p^2)*stripDensity p := by + intro j + apply Complex.ofReal_injective + rw [←pairing_ofReal,←pairing_ofReal,hcP] + change pairing _ (gBasis N j)=pairing (fun x=>(pinnedHZero x:ℂ)) (gBasis N j) + have he : (fun x=>(pinnedHZero x:ℂ))=hZero-(fun _=>1) := by + funext x + simp only [pinnedHZero,Complex.ofReal_sub,Complex.ofReal_one,hZero_ofReal_re,Pi.sub_apply] + rw [he,pairing_sub ((projection_integrable N hZero j).sub + ((projection_integrable N (C (3*angle/2)) j).smul (d:ℂ)) |>.add + ((cThree_in_pairingDomain N j).smul (d:ℂ))) (hone j), + pairing_add ((projection_integrable N hZero j).sub + ((projection_integrable N (C (3*angle/2)) j).smul (d:ℂ))) + ((cThree_in_pairingDomain N j).smul (d:ℂ)), + pairing_sub (projection_integrable N hZero j) ((projection_integrable N (C (3*angle/2)) j).smul (d:ℂ)), + pairing_smul,pairing_smul,projection_pairing,projection_pairing, + pairing_sub (hZero_in_pairingDomain N j) (hone j)] + ring + rw [meanResidualRatio_realization stripDensity (pinnedFamily N) (mixedFamily N) pinnedHZero P (-4) + (pinnedFamily_mixed_pair_integrable N) hHi (pinnedFamily_mixed_Gram_pos hN).ne' + pinnedHZero_minus_four_pos.ne' hPs hp] + dsimp [P,PH,PJ,J,d,pinnedHZero] + simp only [Pi.sub_apply,obliqueResidual,Complex.sub_re] + field_simp + ring + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open StripAsymptotic Filter Topology + +/-- A lower bound for the zero-pinned residual in the physical bridge formula. -/ +theorem pinned_source_residual_lower : + ∃ a : ℝ,0(hZero x).re) 0 0 _ hZero_sq_measurable + (fun _ hp=>hZero_sq_unit hp.le) + (fun t ht htL => (hN (angle/2) t hs hsL ht htL).1) + have h₁ := mixedMean_bounds N (fun x=>(hOne x).re) 0 0 _ hOne_sq_measurable + (fun _ hp=>hOne_sq_unit hp.le) + (fun t ht htL => (hN (angle/2) t hs hsL ht htL).2) + have hOne_zero : (hOne 0).re=1 := by simp [hOne,D_zero,C] + rw [source_residual_mean hZero_ofReal_re (hZero_in_pairingDomain N) + (by rw [hZero_zero];norm_num), + source_residual_mean hOne_ofReal_re (hOne_in_pairingDomain N) + (by rw [hOne_zero];norm_num)] + simp only [Complex.ofReal_re,hZero_zero,hOne_zero,one_mul] + exact ⟨h₀,h₁⟩ + +end CriticalHoneycomb.FiniteFunctional + +end + + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ObliqueProjection.lean b/lean/OAI/Combinatorics/HoneycombChords/ObliqueProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..39ca40de6de7cd4ad7a5b08c7eab2512d4f86dc8 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ObliqueProjection.lean @@ -0,0 +1,518 @@ +import OAI.Combinatorics.HoneycombChords.FunctionalTransforms +import OAI.Combinatorics.HoneycombChords.OrderedDeterminants + +namespace OAI + +/-! Bilinear Gram projection onto the finite interpolation space and its residuals. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Finset +open StripAsymptotic + +noncomputable def complexInsertedFamily (N : ℕ) (H : ℝ → ℂ) : Fin (2*N+1) → ℝ → ℂ := + Function.update (fun i x => (fixedFamily N i x : ℂ)) (centralIndex N) H + +lemma complexInsertedFamily_low (N : ℕ) (H : ℝ → ℂ) (k : Fin N) : + complexInsertedFamily N H ⟨k,by omega⟩ = fun x => (cosineKernelJet k 0 0 x : ℂ) := by + have hi : (⟨k,by omega⟩ : Fin (2*N+1)) ≠ centralIndex N := by + simp only [ne_eq,Fin.ext_iff,centralIndex] + exact Nat.ne_of_lt k.isLt + ext x + rw [complexInsertedFamily,Function.update_of_ne hi] + rw [fixedFamily,interiorKnot_nodalOrder N _ (half_pos strip_angle_pos) (by linarith [strip_angle_pos])] + simp [interiorKnotLabels,k.isLt] + +lemma complexInsertedFamily_high (N : ℕ) (H : ℝ → ℂ) (k : Fin N) : + complexInsertedFamily N H ⟨N+1+k,by omega⟩ = fun x => (cosineKernelJet k 0 (angle^2) x : ℂ) := by + have hi : (⟨N+1+k,by omega⟩ : Fin (2*N+1)) ≠ centralIndex N := by + simp only [ne_eq,Fin.ext_iff,centralIndex] + omega + have hlt : ¬N+1+(k:ℕ) (cosineKernelJet k 0 (angle^2) x : ℂ)) ∈ M N := by + have h : (fun x => (cosineKernelJet k 0 (angle^2) x : ℂ)) ∈ + Submodule.span ℂ ((fun j : ℕ => fun x : ℝ => (cosineKernelJet j 0 (angle^2) x : ℂ)) '' Set.Iio N) := + Submodule.subset_span ⟨k,k.isLt,rfl⟩ + rw [parameter_jet_span angle strip_angle_pos.ne' N] at h + apply (Submodule.span_mono (show ((fun j : ℕ=>fun x : ℝ=>iteratedDeriv j (fun t=>C t x) angle) '' Set.Iio N) ⊆ + Set.range (fun j : Fin N => fun x : ℝ => (x:ℂ)^j.val) ∪ + Set.range (fun j : Fin N => fun x : ℝ => iteratedDeriv j.val (fun t=>C t x) angle) from ?_)) h + rintro _ ⟨j,hj,rfl⟩ + exact Or.inr ⟨⟨j,hj⟩,rfl⟩ + +lemma beta_zero_mem_M (N : ℕ) (k : Fin N) : + (fun x => (cosineKernelJet k 0 0 x : ℂ)) ∈ M N := by + have h : (fun x : ℝ => (x:ℂ)^k.val) ∈ M N := Submodule.subset_span (Or.inl ⟨k,rfl⟩) + have he : (fun x => (cosineKernelJet k 0 0 x : ℂ)) = + (((2*(k:ℕ)).factorial:ℂ)⁻¹) • (fun x : ℝ => (x:ℂ)^k.val) := by + ext x + simp [cosineKernelJet_at_zero,div_eq_mul_inv,mul_comm] + rw [he] + exact (M N).smul_mem _ h + +lemma complexInsertedFamily_span (N : ℕ) (H : ℝ → ℂ) : + Submodule.span ℂ (Set.range (complexInsertedFamily N H)) = M N ⊔ Submodule.span ℂ {H} := by + let S := Submodule.span ℂ (Set.range (complexInsertedFamily N H)) + have hlow (k : Fin N) : (fun x => (cosineKernelJet k 0 0 x : ℂ)) ∈ S := by + rw [← complexInsertedFamily_low N H k] + exact Submodule.subset_span ⟨_,rfl⟩ + have hhigh (k : Fin N) : (fun x => (cosineKernelJet k 0 (angle^2) x : ℂ)) ∈ S := by + rw [← complexInsertedFamily_high N H k] + exact Submodule.subset_span ⟨_,rfl⟩ + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨i,rfl⟩ + by_cases hic : i=centralIndex N + · subst i + simp only [complexInsertedFamily,Function.update_self] + exact (show Submodule.span ℂ {H} ≤ M N ⊔ Submodule.span ℂ {H} from le_sup_right) (Submodule.subset_span (Set.mem_singleton H)) + · by_cases hil : (i:ℕ)(x:ℂ)^k.val)=((2*(k:ℕ)).factorial:ℂ) • + (fun x => (cosineKernelJet k 0 0 x : ℂ)) := by + ext x + simp only [Pi.smul_apply,smul_eq_mul,cosineKernelJet_at_zero,Complex.ofReal_div, + Complex.ofReal_pow,Complex.ofReal_natCast] + have hfac : (((2*(k:ℕ)).factorial:ℂ)) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero _) + field_simp + change (fun x : ℝ => (x:ℂ)^k.val) ∈ S + rw [he] + exact S.smul_mem _ (hlow k) + · have hspan : Submodule.span ℂ ((fun j : ℕ=>fun x : ℝ=>(cosineKernelJet j 0 (angle^2) x:ℂ)) '' Set.Iio N) ≤ S := by + apply Submodule.span_le.mpr + rintro _ ⟨j,hj,rfl⟩ + exact hhigh ⟨j,hj⟩ + rw [parameter_jet_span angle strip_angle_pos.ne' N] at hspan + exact hspan (Submodule.subset_span ⟨k,k.isLt,rfl⟩) + · apply Submodule.span_le.mpr + intro f hf + have : f=H := Set.mem_singleton_iff.mp hf + subst f + have he : complexInsertedFamily N H (centralIndex N)=H := Function.update_self _ _ _ + exact Submodule.subset_span ⟨centralIndex N,he⟩ + +lemma fixedFamily_span (N : ℕ) : + Submodule.span ℂ (Set.range (fun i x => (fixedFamily N i x : ℂ))) = + M N ⊔ Submodule.span ℂ {C (angle/2)} := by + have he : complexInsertedFamily N (C (angle/2)) = fun i x=>(fixedFamily N i x:ℂ) := by + unfold complexInsertedFamily + apply Function.update_eq_self_iff.mpr + ext x + rw [fixedFamily_central,C_eq_beta_square] + rw [←he] + exact complexInsertedFamily_span _ _ + +lemma mixedFamily_span (N : ℕ) : + Submodule.span ℂ (Set.range (fun i x => (mixedFamily N i x : ℂ))) = admissibleDensity N := by + have he : complexInsertedFamily N g = fun i x=>(mixedFamily N i x:ℂ) := by + ext i x + by_cases hi : i=centralIndex N + · subst i + simp only [complexInsertedFamily,mixedFamily,Function.update_self,realG_complex] + · simp only [complexInsertedFamily,mixedFamily,Function.update_of_ne hi] + rw [←he,complexInsertedFamily_span] + rfl + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Finset MeasureTheory + +lemma pairing_sub {H K F : ℝ → ℂ} (hH : PairingIntegrable H F) + (hK : PairingIntegrable K F) : pairing (H-K) F=pairing H F-pairing K F := by + unfold pairing + have he : (fun z : ℝ => (H-K) (z^2)*F (z^2)*((z:ℂ)*D (z^2)/(Real.sinh (4*angle*z):ℂ))) = + pairingKernel H F - pairingKernel K F := by ext z; simp [pairingKernel];ring + rw [he] + exact integral_sub hH hK + +lemma pairing_add {H K F : ℝ → ℂ} (hH : PairingIntegrable H F) + (hK : PairingIntegrable K F) : pairing (H+K) F=pairing H F+pairing K F := by + change (∫ z in Set.Ioi (0:ℝ),pairingKernel (H+K) F z)=_ + rw [pairingKernel_add] + exact integral_add hH hK + +lemma pairing_smul (a : ℂ) (H F : ℝ → ℂ) : pairing (a • H) F = a*pairing H F := by + change (∫ z in Set.Ioi (0:ℝ),pairingKernel (a • H) F z)=_ + rw [pairingKernel_smul] + exact integral_const_mul _ _ + +lemma pairing_comm (H F : ℝ → ℂ) : pairing H F=pairing F H := by + unfold pairing + congr 1 + ext z + ring + +lemma PairingIntegrable.comm {H F : ℝ → ℂ} (h : PairingIntegrable H F) : PairingIntegrable F H := by + have he : pairingKernel F H=pairingKernel H F := by ext z; dsimp [pairingKernel];ring + unfold PairingIntegrable at * + rw [he] + exact h + +lemma PairingIntegrable.sub {H K F : ℝ → ℂ} (hH : PairingIntegrable H F) + (hK : PairingIntegrable K F) : PairingIntegrable (H-K) F := by + simpa only [sub_eq_add_neg,neg_one_smul] using hH.add (hK.smul (-1)) + +lemma PairingIntegrable.finset_sum {ι : Type*} (s : Finset ι) (H : ι → ℝ → ℂ) (F : ℝ → ℂ) + (hi : ∀ i ∈ s,PairingIntegrable (H i) F) : PairingIntegrable (∑ i ∈ s,H i) F := by + classical + induction s using Finset.induction_on with + | empty => simpa only [sum_empty] using PairingIntegrable.zero F + | @insert a s ha ih => + rw [sum_insert ha] + exact (hi a (mem_insert_self _ _)).add (ih (fun i hi'=>hi i (mem_insert_of_mem hi'))) + +lemma pairing_finset_sum {ι : Type*} (s : Finset ι) (H : ι → ℝ → ℂ) (F : ℝ → ℂ) + (hi : ∀ i ∈ s,PairingIntegrable (H i) F) : pairing (∑ i ∈ s,H i) F=∑ i ∈ s,pairing (H i) F := by + classical + induction s using Finset.induction_on with + | empty => simp [pairing] + | @insert a s ha ih => + rw [sum_insert ha,sum_insert ha,pairing_add (hi a (mem_insert_self _ _)) + (PairingIntegrable.finset_sum s H F (fun i hi'=>hi i (mem_insert_of_mem hi'))), + ih (fun i hi'=>hi i (mem_insert_of_mem hi'))] + +lemma PairingIntegrable.span_left {S : Set (ℝ → ℂ)} {F : ℝ → ℂ} + (hi : ∀ H ∈ S,PairingIntegrable H F) {H : ℝ → ℂ} (hH : H ∈ Submodule.span ℂ S) : + PairingIntegrable H F := by + induction hH using Submodule.span_induction with + | mem H hH => exact hi H hH + | zero => exact PairingIntegrable.zero F + | add H K hH hK hiH hiK => exact hiH.add hiK + | smul a H hH hiH => exact hiH.smul a + +lemma pairing_annihilates_span {S : Set (ℝ → ℂ)} {H : ℝ → ℂ} + (hi : ∀ F ∈ S,PairingIntegrable H F) (hz : ∀ F ∈ S,pairing H F=0) + {F : ℝ → ℂ} (hF : F ∈ Submodule.span ℂ S) : pairing H F=0 := by + induction hF using Submodule.span_induction with + | mem F hF => exact hz F hF + | zero => simp [pairing] + | add F K hF hK hiF hiK => + rw [pairing_comm,pairing_add (PairingIntegrable.span_left (fun F hF=>(hi F hF).comm) hF) + (PairingIntegrable.span_left (fun F hF=>(hi F hF).comm) hK),pairing_comm F H,pairing_comm K H,hiF,hiK,add_zero] + | smul a F hF hiF => rw [pairing_comm,pairing_smul,pairing_comm F H,hiF,mul_zero] + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Finset Matrix MeasureTheory +open StripAsymptotic +noncomputable def fBasis (N : ℕ) (i : Fin (2*N+1)) (x : ℝ) : ℂ := fixedFamily N i x +noncomputable def gBasis (N : ℕ) (i : Fin (2*N+1)) (x : ℝ) : ℂ := mixedFamily N i x +noncomputable def pairingMatrix (N : ℕ) : Matrix (Fin (2*N+1)) (Fin (2*N+1)) ℂ := + Matrix.of (fun j i=>pairing (fBasis N i) (gBasis N j)) + +lemma pairingKernel_ofReal (H F : ℝ → ℝ) {p : ℝ} (hp : 0≤p) : + pairingKernel (fun x=>(H x:ℂ)) (fun x=>(F x:ℂ)) p = + ((H (p^2)*F (p^2)*stripDensity p:ℝ):ℂ) := by + rw [pairingKernel,D_sq hp] + simp only [stripDensity,Complex.ofReal_mul,Complex.ofReal_sub,Complex.ofReal_ofNat, + Complex.ofReal_one,Complex.ofReal_div] + +lemma pairing_ofReal (H F : ℝ → ℝ) : + pairing (fun x=>(H x:ℂ)) (fun x=>(F x:ℂ)) = + ((∫ p in Set.Ioi (0:ℝ),H (p^2)*F (p^2)*stripDensity p:ℝ):ℂ) := by + change (∫ p in Set.Ioi (0:ℝ),pairingKernel (fun x=>(H x:ℂ)) (fun x=>(F x:ℂ)) p)=_ + rw [← integral_complex_ofReal] + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact pairingKernel_ofReal H F hp.le + +lemma fBasis_gBasis_integrable (N : ℕ) (i j : Fin (2*N+1)) : + PairingIntegrable (fBasis N i) (gBasis N j) := by + have hi : IntegrableOn (fun p=>((fixedFamily N i (p^2)*mixedFamily N j (p^2)*stripDensity p:ℝ):ℂ)) (Set.Ioi 0) := + (fixed_mixed_pair_integrable N i j).ofReal + apply hi.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact (pairingKernel_ofReal (fixedFamily N i) (mixedFamily N j) hp.le).symm + +lemma pairingMatrix_eq (N : ℕ) : + pairingMatrix N = ((familyGram stripDensity (fixedFamily N) (mixedFamily N)).map Complex.ofReal).transpose := by + ext j i + exact pairing_ofReal _ _ + +lemma pairingMatrix_det_ne_zero (N : ℕ) : (pairingMatrix N).det ≠ 0 := by + rw [pairingMatrix_eq,Matrix.det_transpose] + change (Complex.ofRealHom.mapMatrix (familyGram stripDensity (fixedFamily N) (mixedFamily N))).det ≠ 0 + rw [← RingHom.map_det Complex.ofRealHom] + exact Complex.ofReal_ne_zero.mpr (fixed_mixed_Gram_det_pos N).ne' + +lemma fBasis_span (N : ℕ) : Submodule.span ℂ (Set.range (fBasis N)) = + M N ⊔ Submodule.span ℂ {C (angle/2)} := fixedFamily_span N +lemma gBasis_span (N : ℕ) : Submodule.span ℂ (Set.range (gBasis N)) = + admissibleDensity N := mixedFamily_span N + +lemma fBasis_density_integrable {N : ℕ} {F : ℝ → ℂ} (hF : F ∈ admissibleDensity N) + (i : Fin (2*N+1)) : PairingIntegrable (fBasis N i) F := by + rw [← gBasis_span] at hF + apply PairingIntegrable.comm + apply PairingIntegrable.span_left (S:=Set.range (gBasis N)) _ hF + rintro _ ⟨j,rfl⟩ + exact (fBasis_gBasis_integrable N i j).comm + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Finset Matrix MeasureTheory + +noncomputable def projectionCoefficients (N : ℕ) (H : ℝ → ℂ) : Fin (2*N+1) → ℂ := + (pairingMatrix N)⁻¹ *ᵥ (fun j=>pairing H (gBasis N j)) +noncomputable def obliqueProjection (N : ℕ) (H : ℝ → ℂ) : ℝ → ℂ := + ∑ i,projectionCoefficients N H i • fBasis N i +noncomputable def obliqueResidual (N : ℕ) (H : ℝ → ℂ) : ℝ → ℂ := H-obliqueProjection N H + +def InPairingDomain (N : ℕ) (H : ℝ → ℂ) : Prop := ∀ j,PairingIntegrable H (gBasis N j) + +lemma projection_mem (N : ℕ) (H : ℝ → ℂ) : + obliqueProjection N H ∈ M N ⊔ Submodule.span ℂ {C (angle/2)} := by + rw [← fBasis_span] + exact (Submodule.mem_span_range_iff_exists_fun ℂ).mpr ⟨projectionCoefficients N H,rfl⟩ + +lemma projection_integrable (N : ℕ) (H : ℝ → ℂ) (j : Fin (2*N+1)) : + PairingIntegrable (obliqueProjection N H) (gBasis N j) := by + apply PairingIntegrable.finset_sum + intro i _ + exact (fBasis_gBasis_integrable N i j).smul _ + +lemma projection_pairing (N : ℕ) (H : ℝ → ℂ) (j : Fin (2*N+1)) : + pairing (obliqueProjection N H) (gBasis N j)=pairing H (gBasis N j) := by + rw [obliqueProjection,pairing_finset_sum _ _ _ (fun i _=>(fBasis_gBasis_integrable N i j).smul _)] + simp_rw [pairing_smul] + have h := congrFun (show (pairingMatrix N) *ᵥ projectionCoefficients N H= + (fun j=>pairing H (gBasis N j)) from by + rw [projectionCoefficients,Matrix.mulVec_mulVec,Matrix.mul_nonsing_inv _ + (isUnit_iff_ne_zero.mpr (pairingMatrix_det_ne_zero N)),Matrix.one_mulVec]) j + simpa only [Matrix.mulVec, dotProduct, pairingMatrix,Matrix.of_apply,mul_comm] using h + +lemma residual_pairing_zero {N : ℕ} {H : ℝ → ℂ} (hH : InPairingDomain N H) (j : Fin (2*N+1)) : + pairing (obliqueResidual N H) (gBasis N j)=0 := by + rw [obliqueResidual,pairing_sub (hH j) (projection_integrable N H j),projection_pairing,sub_self] + +lemma residual_density_pairing_zero {N : ℕ} {H F : ℝ → ℂ} (hH : InPairingDomain N H) + (hF : F ∈ admissibleDensity N) : pairing (obliqueResidual N H) F=0 := by + rw [← gBasis_span] at hF + apply pairing_annihilates_span (S:=Set.range (gBasis N)) _ _ hF + · rintro _ ⟨j,rfl⟩ + exact (hH j).sub (projection_integrable N H j) + · rintro _ ⟨j,rfl⟩ + exact residual_pairing_zero hH j + +lemma domain_density_integrable {N : ℕ} {H F : ℝ → ℂ} (hH : InPairingDomain N H) + (hF : F ∈ admissibleDensity N) : PairingIntegrable H F := by + rw [← gBasis_span] at hF + apply PairingIntegrable.comm + apply PairingIntegrable.span_left (S:=Set.range (gBasis N)) _ hF + rintro _ ⟨j,rfl⟩ + exact (hH j).comm + +lemma projection_density_integrable {N : ℕ} {F : ℝ → ℂ} (H : ℝ → ℂ) + (hF : F ∈ admissibleDensity N) : PairingIntegrable (obliqueProjection N H) F := + domain_density_integrable (projection_integrable N H) hF + +lemma projection_unique {N : ℕ} {H P : ℝ → ℂ} + (hP : P ∈ M N ⊔ Submodule.span ℂ {C (angle/2)}) + (hp : ∀ j,pairing P (gBasis N j)=pairing H (gBasis N j)) : P=obliqueProjection N H := by + rw [← fBasis_span] at hP + obtain ⟨v,rfl⟩ := (Submodule.mem_span_range_iff_exists_fun ℂ).mp hP + have hv : (pairingMatrix N) *ᵥ v=(pairingMatrix N) *ᵥ projectionCoefficients N H := by + ext j + have he (u : Fin (2*N+1)→ℂ) : + pairing (∑ i,u i • fBasis N i) (gBasis N j)=((pairingMatrix N)*ᵥ u) j := by + rw [pairing_finset_sum _ _ _ (fun i _=>(fBasis_gBasis_integrable N i j).smul _)] + simp only [pairing_smul,pairingMatrix,Matrix.mulVec,dotProduct,Matrix.of_apply,mul_comm] + rw [←he v,←he (projectionCoefficients N H),hp j] + exact (projection_pairing N H j).symm + have hv' : v=projectionCoefficients N H := + (Matrix.mulVec_injective_iff_isUnit.mpr ((Matrix.isUnit_iff_isUnit_det _).mpr + (isUnit_iff_ne_zero.mpr (pairingMatrix_det_ne_zero N)))) hv + rw [hv'] + rfl + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open Finset Matrix MeasureTheory +open StripAsymptotic + +lemma real_projection_coefficients (N : ℕ) (H : ℝ → ℝ) : + projectionCoefficients N (fun x=>(H x:ℂ))= + fun i=>(((familyGram stripDensity (fixedFamily N) (mixedFamily N)).transpose⁻¹ *ᵥ + (fun j=>∫ p in Set.Ioi 0,H (p^2)*mixedFamily N j (p^2)*stripDensity p)) i:ℂ) := by + let A:=familyGram stripDensity (fixedFamily N) (mixedFamily N) + let v:=fun j=>∫ p in Set.Ioi 0,H (p^2)*mixedFamily N j (p^2)*stripDensity p + let c:=A.transpose⁻¹ *ᵥ v + have hd : IsUnit A.transpose.det := by + rw [Matrix.det_transpose] + exact isUnit_iff_ne_zero.mpr (fixed_mixed_Gram_det_pos N).ne' + have hc : A.transpose *ᵥ c=v := by + change A.transpose *ᵥ (A.transpose⁻¹ *ᵥ v)=v + rw [Matrix.mulVec_mulVec,Matrix.mul_nonsing_inv _ hd,Matrix.one_mulVec] + have hcx : pairingMatrix N *ᵥ (fun i=>(c i:ℂ))= + fun j=>pairing (fun x=>(H x:ℂ)) (gBasis N j) := by + ext j + rw [pairingMatrix_eq] + change (∑ i,(A i j:ℂ)*(c i:ℂ))=pairing (fun x=>(H x:ℂ)) (fun x=>(mixedFamily N j x:ℂ)) + rw [pairing_ofReal] + norm_cast + exact congrFun hc j + have hsol : projectionCoefficients N (fun x=>(H x:ℂ))=fun i=>(c i:ℂ) := by + rw [projectionCoefficients,←hcx,Matrix.mulVec_mulVec, + Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (pairingMatrix_det_ne_zero N)),Matrix.one_mulVec] + exact hsol + +lemma projection_ofReal (N : ℕ) (H : ℝ → ℝ) (a : ℝ) : + obliqueProjection N (fun x=>(H x:ℂ)) a= + (((fun j=>∫ p in Set.Ioi 0,H (p^2)*mixedFamily N j (p^2)*stripDensity p) ⬝ᵥ + ((familyGram stripDensity (fixedFamily N) (mixedFamily N))⁻¹ *ᵥ + (fun i=>fixedFamily N i a))):ℝ) := by + rw [obliqueProjection,real_projection_coefficients] + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,fBasis] + simp_rw [←Complex.ofReal_mul] + rw [←Complex.ofReal_sum] + congr 1 + rw [Matrix.dotProduct_mulVec,←Matrix.transpose_nonsing_inv] + simp only [dotProduct,Matrix.vecMul,Matrix.mulVec,Matrix.transpose_apply,mul_comm] + +lemma residual_ofReal_mean (N : ℕ) (H : ℝ → ℝ) {a : ℝ} (ha : H a≠0) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*mixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0)) : + obliqueResidual N (fun x=>(H x:ℂ)) a= + ((H a*meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) H a:ℝ):ℂ) := by + rw [obliqueResidual,Pi.sub_apply,projection_ofReal,←Complex.ofReal_sub] + congr 1 + rw [meanResidualRatio_formula _ _ _ _ _ (fixed_mixed_pair_integrable N) hH + (fixed_mixed_Gram_det_pos N).ne'] + have he : (fun i : Fin (2*N+1)=>fixedFamily N i a/H a)=(H a)⁻¹ • (fun i=>fixedFamily N i a) := by + funext i + simp only [Pi.smul_apply,smul_eq_mul,div_eq_mul_inv,mul_comm] + rw [he,Matrix.mulVec_smul,dotProduct_smul] + simp only [smul_eq_mul] + field_simp + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology + +lemma cosh_parameter_norm {p t : ℝ} (hp : 0 ≤ p) (ht : t ∈ Set.Icc (0:ℝ) angle) : + |Real.cosh (t*p)| ≤ Real.cosh (angle*p) := by + rw [abs_of_pos (Real.cosh_pos _)] + apply Real.cosh_le_cosh.mpr + rw [abs_of_nonneg (mul_nonneg ht.1 hp),abs_of_nonneg (mul_nonneg strip_angle_pos.le hp)] + exact mul_le_mul_of_nonneg_right ht.2 hp + +lemma cosh_pair_continuousOn (q : ℝ → ℝ) (hq : Measurable q) + (hi : IntegrableOn (fun p=>|q p| *Real.cosh (angle*p)) (Set.Ioi 0)) : + ContinuousOn (fun t=>∫ p in Set.Ioi 0,q p*Real.cosh (t*p)) (Set.Icc 0 angle) := by + apply continuousOn_of_dominated (bound:=fun p=>|q p| *Real.cosh (angle*p)) + · intro t ht + exact (hq.mul (by fun_prop)).aestronglyMeasurable + · intro t ht + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_eq_abs,abs_mul] + exact mul_le_mul_of_nonneg_left (cosh_parameter_norm hp.le ht) (abs_nonneg _) + · exact hi + · filter_upwards with p + exact (show Continuous (fun t=>q p*Real.cosh (t*p)) by fun_prop).continuousOn + +lemma cosh_pair_fubini (q : ℝ → ℝ) (hq : Measurable q) + (hi : IntegrableOn (fun p=>|q p| *Real.cosh (angle*p)) (Set.Ioi 0)) : + (∫ p in Set.Ioi 0,q p*realG (p^2)) = + ∫ t in (0:ℝ)..angle,∫ p in Set.Ioi 0,q p*Real.cosh (t*p) := by + let μ:=volume.restrict (Set.Ioc (0:ℝ) angle) + let ν:=volume.restrict (Set.Ioi (0:ℝ)) + have hprod : Integrable (fun z : ℝ × ℝ=>q z.2*Real.cosh (z.1*z.2)) (μ.prod ν) := by + apply (hi.comp_snd μ).mono' + · exact ((hq.comp measurable_snd).mul (by fun_prop)).aestronglyMeasurable + · have ht : ∀ᵐ z : ℝ × ℝ ∂μ.prod ν,z.1 ∈ Set.Ioc (0:ℝ) angle := + (Measure.quasiMeasurePreserving_fst.ae (ae_restrict_mem measurableSet_Ioc)) + have hp : ∀ᵐ z : ℝ × ℝ ∂μ.prod ν,0∫ t in a..b,v t j)).det = + ∫ t in a..b,(A.updateCol i (v t)).det := by + let L := (rowDetLinear A.transpose i).toContinuousLinearMap + have he : (∫ t in a..b,v t)=fun j=>∫ t in a..b,v t j := by + funext j + exact ((ContinuousLinearMap.proj j : (Fin n → ℝ) →L[ℝ] ℝ).intervalIntegral_comp_comm hv).symm + have h:=L.intervalIntegral_comp_comm hv + rw [he] at h + have htrans (w : Fin n → ℝ) : (A.transpose.updateRow i w).det=(A.updateCol i w).det := by + rw [←Matrix.det_transpose (A.updateCol i w)] + congr 1 + ext k j + simp [Matrix.updateRow_apply,Matrix.updateCol_apply] + change (∫ t in a..b,(A.transpose.updateRow i (v t)).det)= + (A.transpose.updateRow i (fun j=>∫ t in a..b,v t j)).det at h + simpa only [htrans] using h.symm + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Occupancy.lean b/lean/OAI/Combinatorics/HoneycombChords/Occupancy.lean new file mode 100644 index 0000000000000000000000000000000000000000..3409e3ab63d723b74a9a1ffc3aaa3a013dee399a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Occupancy.lean @@ -0,0 +1,1122 @@ +import OAI.Combinatorics.HoneycombChords.ColumnTransfer + +namespace OAI + +/-! +# Resolved occupancy contractions + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +/-- Local occupancy projection. Unlike an entire frontier mask this fixes +only the two wires touched by one actual lozenge. -/ +noncomputable def pairMask : ℕ → Bool → Bool → DiluteState → DiluteState + | 0,a,b,f,x::y::xs => if x.isSome=a ∧ y.isSome=b then f (x::y::xs) else 0 + | 0,_,_,_,_ => 0 + | i+1,a,b,f,x::xs => pairMask i a b (fun ys => f (x::ys)) xs + | _+1,_,_,_,[] => 0 + +lemma pairMask_zero (i : ℕ) (a b : Bool) : + pairMask i a b (fun _=>0) = fun _=>0 := by + induction i with + | zero => funext xs; cases xs with + | nil => rfl + | cons x xs => cases xs <;> simp [pairMask] + | succ i ih => + funext xs; cases xs with + | nil => rfl + | cons x xs => exact congrFun ih xs + +lemma pairMask_add (i : ℕ) (a b : Bool) (f g : DiluteState) : + pairMask i a b (fun xs => f xs+g xs) = fun xs => pairMask i a b f xs+pairMask i a b g xs := by + induction i generalizing f g with + | zero => funext xs; cases xs with + | nil => simp [pairMask] + | cons x xs => cases xs <;> simp [pairMask]; split_ifs <;> simp + | succ i ih => + funext xs; cases xs with + | nil => simp [pairMask] + | cons x xs => exact congrFun (ih _ _) xs + +lemma pairMask_smul (i : ℕ) (a b : Bool) (z : ℂ) (f : DiluteState) : + pairMask i a b (fun xs => z*f xs) = fun xs => z*pairMask i a b f xs := by + induction i generalizing f with + | zero => funext xs; cases xs with + | nil => simp [pairMask] + | cons x xs => cases xs <;> simp [pairMask] + | succ i ih => + funext xs; cases xs with + | nil => simp [pairMask] + | cons x xs => exact congrFun (ih _) xs + +lemma pairMask_embed (pre post : List Bool) (a b c d : Bool) (f : State) : + pairMask pre.length a b (embed (pre++c::d::post) f) = + if c=a ∧ d=b then embed (pre++c::d::post) f else fun _=>0 := by + induction pre generalizing f with + | nil => + funext xs + cases xs with + | nil => simp [pairMask,embed,occupancy,ite_apply] + | cons x xs => cases xs with + | nil => simp [pairMask,embed,occupancy,ite_apply] + | cons y xs => + cases x <;> cases y <;> cases a <;> cases b <;> cases c <;> cases d <;> + simp [pairMask,embed,occupancy] + | cons p pre ih => + funext xs + cases xs with + | nil => simp [pairMask,embed,occupancy,ite_apply] + | cons x xs => + cases p <;> cases x <;> + simp only [List.length_cons,List.cons_append,pairMask,embed_false,embed_true, + embed_false_some,embed_true_none,ite_apply,pairMask_zero] + · simpa only [ite_apply] using congrFun (ih f) xs + · simp + · simp + · rename_i z + simpa only [ite_apply] using congrFun (ih (fun ys=>f (z::ys))) xs + +lemma pairMask_resolved {b n i : ℕ} {root : State} {f : DiluteState} + (hi : i+1 rw [pairMask_zero]; exact .zero + | basis o k w hl hc => + obtain ⟨pre,x,y,post,rfl,hpre⟩ := two_at o i (by omega) + subst i + rw [pairMask_embed] + split_ifs + · exact .basis _ k w hl hc + · exact .zero + +lemma pairMask_two_choices (pre post : List Bool) (a b c d x y : Bool) + (f g : State) (h : (a,b)≠(c,d)) : + pairMask pre.length x y (fun xs => embed (pre++a::b::post) f xs + + embed (pre++c::d::post) g xs) = (fun _=>0) ∨ + pairMask pre.length x y (fun xs => embed (pre++a::b::post) f xs + + embed (pre++c::d::post) g xs) = embed (pre++a::b::post) f ∨ + pairMask pre.length x y (fun xs => embed (pre++a::b::post) f xs + + embed (pre++c::d::post) g xs) = embed (pre++c::d::post) g := by + rw [pairMask_add,pairMask_embed,pairMask_embed] + by_cases hab : a=x ∧ b=y + · rcases hab with ⟨rfl,rfl⟩ + have hcd : ¬(c=a ∧ d=b) := by intro hh; exact h (Prod.ext hh.1.symm hh.2.symm) + simp [hcd] + · by_cases hcd : c=x ∧ d=y + · simp [hab,hcd] + · simp [hab,hcd] + +lemma pairMask_two_resolved {b n : ℕ} {root : State} + (pre post : List Bool) (a c d e x y : Bool) (f g : State) + (h : (a,c)≠(d,e)) + (hf : Resolved b n root (embed (pre++a::c::post) f)) + (hg : Resolved b n root (embed (pre++d::e::post) g)) : + Resolved b n root (pairMask pre.length x y + (fun xs => embed (pre++a::c::post) f xs + embed (pre++d::e::post) g xs)) := by + rcases pairMask_two_choices pre post a c d e x y f g h with hh|hh|hh <;> rw [hh] + · exact .zero + · exact hf + · exact hg + +/-- A specified local output pair selects at most one of the source's two +allowed physical connectivities; no superposition of planar words remains. -/ +lemma pair_resolved_step {b n i : ℕ} (hb : b≤1) (hi : i+1 rw [act_zero,pairMask_zero]; exact .zero + | basis o k w hl hc => + obtain ⟨pre,a,c,post,rfl,hpre⟩ := two_at o i (by omega) + subst i + cases a <;> cases c + · rw [act_empty_at] + simp only [resolvedWeights,one_mul] + apply pairMask_two_resolved + · decide + · exact .basis _ k w hl hc + · have hip : pre.count true ≤ b+2*k := by simp [List.count_append] at hc; omega + exact .basis _ (k+1) (.insert w (pre.count true) hip) + (by simpa using hl) (by simp_all [List.count_append]; omega) + · rw [act_right_at] + simp only [resolvedWeights,one_mul] + apply pairMask_two_resolved + · decide + · exact .basis _ k w hl hc + · exact .basis _ k w (by simpa using hl) (by simpa [List.count_append,List.count_cons] using hc) + · rw [act_left_at] + simp only [resolvedWeights,one_mul] + apply pairMask_two_resolved + · decide + · exact .basis _ k w hl hc + · exact .basis _ k w (by simpa using hl) (by simpa [List.count_append,List.count_cons] using hc) + · have hk : 0 fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [PhysicalTiles.shapeTensor,PhysicalTiles.Shape.selection,Planar.cup,Planar.occupied, + Planar.vacant,Planar.empty,spinIndex,tile,resolvedWeights,cup,hp] + +/-- A chosen shape operation is the literal source orientation tensor, +not merely an abstraction with the same support. -/ +lemma shapeAction_zero (q : PhysicalTiles.Shape) (f : DiluteState) (w n : Spin) (xs : List Spin) : + shapeAction q 0 f (w::n::xs) = + ∑ s : Spin, ∑ e : Spin, + PhysicalTiles.shapeTensor q (spinIndex w) (spinIndex n) (spinIndex s) (spinIndex e) * + f (s::e::xs) := by + unfold shapeAction + simp only [pairMask,act] + by_cases ho : w.isSome=q.selection.west ∧ n.isSome=q.selection.north + · rw [ite_eq_left ho] + apply Finset.sum_congr rfl + intro s hs + apply Finset.sum_congr rfl + intro e he + rw [←chosen_tile_eq_shape] + by_cases hi : s.isSome=q.selection.south ∧ e.isSome=q.selection.east + · simp [ho.1,ho.2,hi.1,hi.2] + · simp only [ite_eq_right hi] + have h : ¬(w.isSome=q.selection.west ∧ n.isSome=q.selection.north ∧ + s.isSome=q.selection.south ∧ e.isSome=q.selection.east) := by tauto + simp [h] + · rw [ite_eq_right ho] + symm + apply Finset.sum_eq_zero + intro s hs + apply Finset.sum_eq_zero + intro e he + rw [←chosen_tile_eq_shape] + have h : ¬(w.isSome=q.selection.west ∧ n.isSome=q.selection.north ∧ + s.isSome=q.selection.south ∧ e.isSome=q.selection.east) := by tauto + simp [h] + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +noncomputable def addOne (f : DiluteState) : DiluteState + | none::xs => f xs + | _ => 0 + +noncomputable def removeOne (f : DiluteState) : DiluteState := fun xs => f (xs++[none]) + +lemma addOne_embed (o : List Bool) (f : State) : + addOne (embed o f) = embed (false::o) f := by + funext xs + cases xs with + | nil => simp [addOne,embed,occupancy] + | cons x xs => cases x <;> simp [addOne,embed,occupancy,orientations] + +lemma removeOne_embed (o : List Bool) (a : Bool) (f : State) : + removeOne (embed (o++[a]) f) = if a=false then embed o f else fun _ => 0 := by + funext xs + have heq : occupancy (xs++[none])=o++[a] ↔ occupancy xs=o ∧ a=false := by + simp only [occupancy,List.map_append] + constructor + · intro h + have hh := List.append_inj' h (by simp) + simpa using hh + · rintro ⟨rfl,rfl⟩; rfl + simp only [removeOne,embed,heq,orientations,List.filterMap_append] + cases a <;> simp [embed,orientations] + + +lemma addOne_resolved {b n : ℕ} {root : State} {f : DiluteState} + (hf : Resolved b n root f) : Resolved b (n+1) root (addOne f) := by + cases hf with + | zero => + have h : addOne (fun _=>0) = fun _=>0 := by + funext xs; cases xs with + | nil => rfl + | cons x xs => cases x <;> rfl + rw [h]; exact .zero + | basis o k w hl hc => + rw [addOne_embed] + exact .basis _ k w (by simp [hl]) (by simpa using hc) + +lemma removeOne_resolved {b n : ℕ} {root : State} {f : DiluteState} + (hf : Resolved b (n+1) root f) : Resolved b n root (removeOne f) := by + cases hf with + | zero => exact .zero + | basis o k w hl hc => + cases o using List.reverseRecOn with + | nil => simp at hl + | append_singleton pre a => + rw [removeOne_embed] + cases a + · simp only [ite_true] + exact .basis _ k w (by simp at hl; omega) (by simpa using hc) + · simp only [Bool.true_eq_false,ite_false] + exact .zero + +noncomputable def shapeRow : ℕ → List PhysicalTiles.Shape → DiluteState → DiluteState + | _,[],f => f + | i,q::qs,f => shapeRow (i+1) qs (shapeAction q i f) + +lemma shapeRow_resolved {b n i : ℕ} (hb : b≤1) (qs : List PhysicalTiles.Shape) + (hi : i+qs.length exact hf + | cons q qs ih => + exact ih (by simp at hi; omega) (shapeAction_resolved hb (by simp at hi; omega) q hf) + +noncomputable def shapeColumn (qs : List PhysicalTiles.Shape) (f : DiluteState) : DiluteState := + removeOne (shapeRow 0 qs (addOne f)) + +lemma shapeColumn_resolved {b n : ℕ} (hb : b≤1) (qs : List PhysicalTiles.Shape) + (hn : qs.length=n) {root : State} {f : DiluteState} (hf : Resolved b n root f) : + Resolved b n root (shapeColumn qs f) := by + exact removeOne_resolved (shapeRow_resolved hb qs (by simp [hn]) (addOne_resolved hf)) + +/-- A specified lozenge-shape configuration in a literal finite rectangle, +scanned east-to-west with unmarked north/south boundaries. -/ +noncomputable def shapeRectangle (cfg : List (List PhysicalTiles.Shape)) + (f : DiluteState) : DiluteState := cfg.foldl (fun f qs=>shapeColumn qs f) f + +lemma shapeRectangle_resolved {b n : ℕ} (hb : b≤1) (cfg : List (List PhysicalTiles.Shape)) + (hn : ∀ qs∈cfg, qs.length=n) {root : State} {f : DiluteState} (hf : Resolved b n root f) : + Resolved b n root (shapeRectangle cfg f) := by + induction cfg generalizing f with + | nil => exact hf + | cons qs cfg ih => + exact ih (by aesop) (shapeColumn_resolved hb qs (hn _ (by simp)) hf) + +/-- Endpointwise normalized orientation coefficient for a fixed finite +physical configuration. This is 0 or the identity, without assuming +nonnegativity of the complex local tensor entries. -/ +theorem shapeRectangle_one_strand {n : ℕ} (cfg : List (List PhysicalTiles.Shape)) + (hn : ∀ qs∈cfg, qs.length=n) (input out : List Bool) (hi : input.length=n) + (hc : input.count true=1) (hout : out.count true=1) (root : State) : + (∀ a : Bool, shapeRectangle cfg (embed input root) (arrowState out a)=0) ∨ + (∀ a : Bool, shapeRectangle cfg (embed input root) (arrowState out a)=root [a]) := by + apply resolved_one_strand (shapeRectangle_resolved (by omega : 1≤1) cfg hn _) out hout + exact .basis input 0 .start hi (by simpa using hc) + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +lemma pairMask_prefix (pre : List Spin) (i : ℕ) (a b : Bool) (f : DiluteState) (xs : List Spin) : + pairMask (pre.length+i) a b f (pre++xs) = + pairMask i a b (fun ys=>f (pre++ys)) xs := by + induction pre generalizing f with + | nil => simp + | cons x pre ih => + simpa [pairMask,Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using ih (fun ys=>f (x::ys)) + +lemma shapeAction_prefix (q : PhysicalTiles.Shape) (pre : List Spin) (i : ℕ) + (f : DiluteState) (xs : List Spin) : + shapeAction q (pre.length+i) f (pre++xs) = + shapeAction q i (fun ys=>f (pre++ys)) xs := by + unfold shapeAction + rw [pairMask_prefix] + congr 1 + funext ys + rw [act_prefix] + congr 1 + funext zs + exact pairMask_prefix pre i _ _ f zs + +lemma shapeRow_prefix (pre : List Spin) (i : ℕ) (qs : List PhysicalTiles.Shape) + (f : DiluteState) (xs : List Spin) : + shapeRow (pre.length+i) qs f (pre++xs) = + shapeRow i qs (fun ys=>f (pre++ys)) xs := by + induction qs generalizing i f with + | nil => rfl + | cons q qs ih => + simp only [shapeRow] + rw [show pre.length+i+1=pre.length+(i+1) by omega,ih] + congr 1 + funext ys + exact shapeAction_prefix q pre i f ys + +noncomputable def shapeContraction {n : ℕ} (q : Fin n → PhysicalTiles.Shape) (f : DiluteState) + (west : Fin n → Spin) (north : Spin) : ℂ := + ∑ east : Fin n → Spin, ∑ vertical : Fin n → Spin, + (∏ j : Fin n, PhysicalTiles.shapeTensor (q j) (spinIndex (west j)) + (spinIndex ((Fin.snoc (α:=fun _=>Spin) vertical north) j.succ)) + (spinIndex (vertical j)) (spinIndex (east j))) * + f (((Fin.snoc (α:=fun _=>Spin) vertical north) 0) :: List.ofFn east) + +lemma shapeContraction_zero (q : Fin 0 → PhysicalTiles.Shape) (f : DiluteState) + (west : Fin 0 → Spin) (north : Spin) : shapeContraction q f west north=f [north] := by + simp [shapeContraction,Fin.snoc_zero] + +lemma shapeContraction_succ {n : ℕ} (q : Fin (n+1) → PhysicalTiles.Shape) (f : DiluteState) + (west : Fin (n+1) → Spin) (north : Spin) : + shapeContraction q f west north = + shapeContraction (fun j=>q j.succ) (fun ys=>shapeAction (q 0) 0 f (west 0::ys)) + (fun j=>west j.succ) north := by + unfold shapeContraction + rw [sum_spin_vectors_succ] + simp_rw [sum_spin_vectors_succ,Fin.prod_univ_succ, + ←Fin.cons_snoc_eq_snoc_cons,Fin.cons_succ,Fin.cons_zero,List.ofFn_succ] + simp only [shapeAction_zero,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro east heast + conv_lhs => + arg 2 + ext firstEast + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro vertical hvertical + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro south hsouth + apply Finset.sum_congr rfl + intro firstEast hfirstEast + simp only [Fin.cons_zero,Fin.cons_succ] + ring + +/-- Every internal vertical variable of the normalized physical shape +column is summed exactly once by the literal planar raster scan. -/ +theorem shapeRow_eq_contraction {n : ℕ} (q : Fin n → PhysicalTiles.Shape) (f : DiluteState) + (west : Fin n → Spin) (north : Spin) : + shapeRow 0 (List.ofFn q) f (List.ofFn west++[north]) = shapeContraction q f west north := by + induction n generalizing f with + | zero => simp [shapeRow,shapeContraction_zero] + | succ n ih => + rw [List.ofFn_succ,List.ofFn_succ,List.cons_append,shapeRow] + rw [show 0+1=([west 0] : List Spin).length+0 by rfl] + change shapeRow (([west 0] : List Spin).length+0) (List.ofFn (fun j=>q j.succ)) + (shapeAction (q 0) 0 f) ([west 0]++(List.ofFn (fun j=>west j.succ)++[north])) = _ + rw [shapeRow_prefix,ih,shapeContraction_succ] + rfl + +noncomputable def shapeKernel {n : ℕ} (q : Fin n → PhysicalTiles.Shape) + (south north : Spin) (west east : Fin n → Spin) : ℂ := + ∑ vertical : Fin n → Spin, + if (Fin.snoc (α:=fun _=>Spin) vertical north) 0=south then + ∏ j : Fin n, PhysicalTiles.shapeTensor (q j) (spinIndex (west j)) + (spinIndex ((Fin.snoc (α:=fun _=>Spin) vertical north) j.succ)) + (spinIndex (vertical j)) (spinIndex (east j)) else 0 + +lemma shapeColumn_eq_kernel {n : ℕ} (q : Fin n → PhysicalTiles.Shape) (f : DiluteState) + (west : Fin n → Spin) : + shapeColumn (List.ofFn q) f (List.ofFn west) = + ∑ east : Fin n → Spin, shapeKernel q none none west east * f (List.ofFn east) := by + classical + unfold shapeColumn removeOne + rw [shapeRow_eq_contraction] + unfold shapeContraction shapeKernel + apply Finset.sum_congr rfl + intro east heast + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro vertical hvertical + have h : ∀ (x : Spin) (xs : List Spin), addOne f (x::xs) = if x=none then f xs else 0 := by + intro x xs; cases x <;> rfl + rw [h] + split_ifs <;> simp + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.RasterGrid +open scoped BigOperators Matrix +open PhysicalTiles PlanarNormalization + +noncomputable def chosenColumnProduct {H : ℕ} (q : Fin H → Shape) + (west east vertical : Column H) (north : Fin 3) : ℂ := + ∏ j : Fin H, shapeTensor (q j) (west j) + ((Fin.snoc (α:=fun _=>Fin 3) vertical north) j.succ) (vertical j) (east j) + +noncomputable def chosenColumnKernel {H : ℕ} (q : Fin H → Shape) (south north : Fin 3) : + Matrix (Column H) (Column H) ℂ := fun west east => + ∑ vertical : Column H, if (Fin.snoc (α:=fun _=>Fin 3) vertical north) 0=south then + chosenColumnProduct q west east vertical north else 0 + +lemma orientation_columns {W H : ℕ} (cfg : Cell W H → Shape) + (west : Column H) (north : Fin W → Fin 3) (horizontal vertical : Fin W → Column H) : + (network W H).orientation cfg (spinsFromColumns west north horizontal vertical) = + ∏ i : Fin W, chosenColumnProduct (fun j=>cfg (i,j)) + ((Fin.cons (α:=fun _=>Column H) west horizontal) i.castSucc) + (horizontal i) (vertical i) (north i) := by + unfold TileNetwork.orientation chosenColumnProduct + rw [Fintype.prod_prod_type] + apply Finset.prod_congr rfl + intro i hi + apply Finset.prod_congr rfl + intro j hj + simp [network,spinsFromColumns] + +/-- The finite prescribed-boundary orientation coefficient of one exact +unoriented honeycomb configuration. -/ +noncomputable def chosenPartition {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) : ℂ := + ∑ horizontal : Fin W → Column H, ∑ vertical : Fin W → Column H, + if (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W)=east ∧ + (∀ i, (Fin.snoc (α:=fun _=>Fin 3) (vertical i) (north i)) 0=south i) then + (network W H).orientation cfg (spinsFromColumns west north horizontal vertical) else 0 + +lemma chosenPartition_eq_matrixPath {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) : + chosenPartition cfg west east south north = + matrixPath (fun i=>chosenColumnKernel (fun j=>cfg (i,j)) (south i) (north i)) west east := by + classical + unfold chosenPartition matrixPath + apply Finset.sum_congr rfl + intro horizontal hhorizontal + by_cases he : (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W)=east + · simp only [he,true_and,ite_true] + simp_rw [orientation_columns] + unfold chosenColumnKernel + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro vertical hvertical + rw [Fintype.prod_ite_zero] + split_ifs <;> rfl + · simp [he] + +lemma chosenPartition_eq_transfer {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) : + chosenPartition cfg west east south north = + (List.ofFn (fun i=>chosenColumnKernel (fun j=>cfg (i,j)) (south i) (north i))).prod west east := by + rw [chosenPartition_eq_matrixPath,matrixPath_eq_prod] + +lemma chosenPartition_eq_grid_sum {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) : + chosenPartition cfg west east south north = + ∑ σ : {σ : GridWire W H → Fin 3 // HasWestNorth west north σ}, + if (∀ j, σ.val (.inl (Fin.last W,j))=east j) ∧ + (∀ i, σ.val (.inr (i,0))=south i) then + (network W H).orientation cfg σ.val else 0 := by + classical + rw [←(gridSpinsEquiv west north).sum_comp,Fintype.sum_prod_type] + unfold chosenPartition + apply Finset.sum_congr rfl + intro horizontal hh + apply Finset.sum_congr rfl + intro vertical hv + change (if (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W)=east ∧ + (∀ i, (Fin.snoc (α:=fun _=>Fin 3) (vertical i) (north i)) 0=south i) then + (network W H).orientation cfg (spinsFromColumns west north horizontal vertical) else 0) = + (if (∀ j, (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W) j=east j) ∧ + (∀ i, (Fin.snoc (α:=fun _=>Fin 3) (vertical i) (north i)) 0=south i) then + (network W H).orientation cfg (spinsFromColumns west north horizontal vertical) else 0) + congr 1 + exact propext (and_congr funext_iff Iff.rfl) + +lemma chosenColumnKernel_eq_spin {H : ℕ} (q : Fin H → Shape) (south north : Spin) + (west east : Fin H → Spin) : + chosenColumnKernel q (spinEquiv south) (spinEquiv north) + (columnSpinEquiv H west) (columnSpinEquiv H east) = shapeKernel q south north west east := by + classical + unfold chosenColumnKernel shapeKernel + rw [←(columnSpinEquiv H).sum_comp] + apply Finset.sum_congr rfl + intro vertical hv + have hs : ∀ j : Fin (H+1), + Fin.snoc (α:=fun _=>Fin 3) (columnSpinEquiv H vertical) (spinEquiv north) j = + spinEquiv (Fin.snoc (α:=fun _=>Spin) vertical north j) := by + intro j + cases j using Fin.lastCases <;> simp + simp only [hs,Equiv.apply_eq_iff_eq] + split_ifs + · unfold chosenColumnProduct + apply Finset.prod_congr rfl + intro j hj + rw [hs] + rfl + · rfl + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +lemma occupancy_orientations_injective {xs ys : List Spin} + (ho : occupancy xs=occupancy ys) (hs : orientations xs=orientations ys) : xs=ys := by + induction xs generalizing ys with + | nil => cases ys <;> simp_all [occupancy] + | cons x xs ih => + cases ys with + | nil => simp [occupancy] at ho + | cons y ys => + cases x with + | none => + cases y with + | none => + have ho' : occupancy xs=occupancy ys := by simpa [occupancy] using ho + have hs' : orientations xs=orientations ys := by simpa [orientations] using hs + exact congrArg (List.cons none) (ih ho' hs') + | some b => simp [occupancy] at ho + | some a => + cases y with + | none => simp [occupancy] at ho + | some b => + have ho' : occupancy xs=occupancy ys := by simpa [occupancy] using ho + have hs' : a=b ∧ orientations xs=orientations ys := by simpa [orientations] using hs + rcases hs' with ⟨rfl,hs'⟩ + exact congrArg (List.cons (some a)) (ih ho' hs') + +lemma orientations_length (xs : List Spin) : + (orientations xs).length=(occupancy xs).count true := by + induction xs with + | nil => rfl + | cons x xs ih => cases x <;> simpa [orientations,occupancy,List.count_cons] using ih + +lemma embed_delta (xs : List Spin) : + embed (occupancy xs) (fun ys=>if ys=orientations xs then (1:ℂ) else 0) = + (fun ys=>if ys=xs then 1 else 0) := by + funext ys + unfold embed + by_cases ho : occupancy ys=occupancy xs + · rw [ite_eq_left ho] + by_cases hs : orientations ys=orientations xs + · simp [occupancy_orientations_injective ho hs] + · have hne : ys≠xs := by intro h; subst ys; exact hs rfl + simp [hs,hne] + · have hne : ys≠xs := by intro h; subst ys; exact ho rfl + simp [ho,hne] + +lemma eq_arrowState (xs : List Spin) (a : Bool) (hc : (occupancy xs).count true=1) + (hs : orientations xs=[a]) : xs=arrowState (occupancy xs) a := by + apply occupancy_orientations_injective + · rw [occupancy_arrowState] + · rw [orientations_arrowState,hc,hs] + rfl + +noncomputable def shapeFold {n : ℕ} (cs : List (Fin n → PhysicalTiles.Shape)) (f : DiluteState) : DiluteState := + cs.foldr (fun q f=>shapeColumn (List.ofFn q) f) f + +lemma shapeFold_resolved {b n : ℕ} (hb : b≤1) (cs : List (Fin n → PhysicalTiles.Shape)) + {root : State} {f : DiluteState} (hf : Resolved b n root f) : + Resolved b n root (shapeFold cs f) := by + induction cs with + | nil => exact hf + | cons q cs ih => exact shapeColumn_resolved hb _ (by simp) ih + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization PhysicalTiles +open scoped BigOperators Matrix + +noncomputable def columnVector (H : ℕ) (f : DiluteState) : Column H → ℂ := + fun east => f (List.ofFn (fun j=>spinEquiv.symm (east j))) + +lemma chosenColumn_mulVec {H : ℕ} (q : Fin H → Shape) (f : DiluteState) : + (chosenColumnKernel q 1 1).mulVec (columnVector H f) = + columnVector H (shapeColumn (List.ofFn q) f) := by + classical + funext w + obtain ⟨west,rfl⟩ := (columnSpinEquiv H).surjective w + simp only [columnVector,columnSpinEquiv_apply,Equiv.symm_apply_apply] + rw [shapeColumn_eq_kernel] + unfold Matrix.mulVec dotProduct + rw [←(columnSpinEquiv H).sum_comp] + apply Finset.sum_congr rfl + intro east heast + change chosenColumnKernel q (spinEquiv none) (spinEquiv none) + (columnSpinEquiv H west) (columnSpinEquiv H east) * _ = _ + rw [chosenColumnKernel_eq_spin] + change _ * f (List.ofFn (fun j=>spinEquiv.symm (spinEquiv (east j)))) = _ + simp only [Equiv.symm_apply_apply] + +lemma chosenProduct_mulVec {H : ℕ} (cs : List (Fin H → Shape)) (f : DiluteState) : + (cs.map (fun q=>chosenColumnKernel q 1 1)).prod.mulVec (columnVector H f) = + columnVector H (shapeFold cs f) := by + induction cs generalizing f with + | nil => simp [shapeFold] + | cons q cs ih => + rw [List.map_cons,List.prod_cons,←Matrix.mulVec_mulVec,ih,chosenColumn_mulVec] + rfl + +lemma vector_delta {H : ℕ} (east : Column H) : + columnVector H (fun xs=>if xs=List.ofFn (fun j=>spinEquiv.symm (east j)) then (1:ℂ) else 0) = + fun e=>if e=east then 1 else 0 := by + classical + funext e + change (if List.ofFn (fun j=>spinEquiv.symm (e j)) = + List.ofFn (fun j=>spinEquiv.symm (east j)) then (1:ℂ) else 0) = _ + have heq : List.ofFn (fun j=>spinEquiv.symm (e j)) = + List.ofFn (fun j=>spinEquiv.symm (east j)) ↔ e=east := by + constructor + · intro hh + have hf := List.ofFn_injective hh + funext j + exact spinEquiv.symm.injective (congrFun hf j) + · rintro rfl; rfl + simp only [heq] + +/-- Fixed-shape normalized crossing coefficients on the exact source grid +are 0 or 1, endpointwise. No positivity of local complex phases is assumed. -/ +theorem chosenPartition_zero_or_one {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) + (hi : (occupancy (List.ofFn (fun j=>spinEquiv.symm (east j)))).count true=1) + (ho : (occupancy (List.ofFn (fun j=>spinEquiv.symm (west j)))).count true=1) : + chosenPartition cfg west east (fun _=>1) (fun _=>1)=0 ∨ + chosenPartition cfg west east (fun _=>1) (fun _=>1)=1 := by + classical + let xs := List.ofFn (fun j=>spinEquiv.symm (east j)) + let ys := List.ofFn (fun j=>spinEquiv.symm (west j)) + let root : State := fun zs=>if zs=orientations xs then 1 else 0 + let cs := List.ofFn (fun i : Fin W => fun j : Fin H => cfg (i,j)) + have hf : Resolved 1 H root (embed (occupancy xs) root) := + .basis (occupancy xs) 0 .start (by simp [xs,occupancy]) (by simpa using hi) + have hylen : (orientations ys).length=1 := (orientations_length ys).trans ho + obtain ⟨a,ha⟩ := List.length_eq_one_iff.mp hylen + have hy : ys=arrowState (occupancy ys) a := eq_arrowState ys a ho ha + have hv := congrFun (chosenProduct_mulVec cs (embed (occupancy xs) root)) west + have hemb : embed (occupancy xs) root = fun zs=>if zs=xs then 1 else 0 := embed_delta xs + rw [hemb,vector_delta] at hv + simp only [Matrix.mulVec,dotProduct,mul_ite,mul_one,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] at hv + have hmat : chosenPartition cfg west east (fun _=>1) (fun _=>1) = + shapeFold cs (embed (occupancy xs) root) ys := by + rw [chosenPartition_eq_transfer] + have hcs : List.ofFn (fun i=>chosenColumnKernel (fun j=>cfg (i,j)) 1 1) = + cs.map (fun q=>chosenColumnKernel q 1 1) := by + rw [List.map_ofFn] + rfl + rw [hcs] + simpa only [columnVector,xs,ys,hemb] using hv + rw [hmat,hy] + rcases resolved_one_strand (shapeFold_resolved (by omega : 1≤1) cs hf) + (occupancy ys) ho with hzero|hone + · exact Or.inl (hzero a) + · rw [hone a] + unfold root + split_ifs <;> simp + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +lemma resolved_vacuum {n : ℕ} {root : State} {f : DiluteState} + (hf : Resolved 0 n root f) : + f (List.replicate n none)=0 ∨ f (List.replicate n none)=root [] := by + cases hf with + | zero => exact Or.inl rfl + | basis o k w hl hc => + by_cases ho : List.replicate n false=o + · subst o + have hk : k=0 := by simp [List.count_replicate] at hc; omega + subst k + by_cases hw : w=.start + · subst w + right + simp [embed,occupancy,orientations,PlanarWord.eval] + · left + simpa [embed,occupancy,orientations] using closed_word_zero w hw root + · left + simp [embed,occupancy,ho] + +lemma vacuum_delta_resolved (n : ℕ) : + Resolved 0 n (fun _=>1) + (fun zs=>if zs=List.replicate n none then (1:ℂ) else 0) := by + have hf : Resolved 0 n (fun _=>1) + (embed (List.replicate n false) (fun _=>1)) := + .basis _ 0 .start (by simp) (by simp [List.count_replicate]) + convert hf using 1 + funext zs + simp only [embed] + have heq : occupancy zs=List.replicate n false ↔ zs=List.replicate n none := by + constructor + · intro hz + apply occupancy_orientations_injective + · simpa [occupancy] using hz + · have hh := orientations_length zs + rw [hz] at hh + have hcnt : (List.replicate n false).count true=0 := by simp [List.count_replicate] + rw [hcnt] at hh + have hn : orientations zs=[] := List.length_eq_zero_iff.mp hh + rw [hn] + simp [orientations] + · rintro rfl; simp [occupancy] + simp only [heq] + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization PhysicalTiles +open scoped BigOperators Matrix + +lemma chosenPartition_eq_shapeFold {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) : + chosenPartition cfg west east (fun _=>1) (fun _=>1) = + shapeFold (List.ofFn (fun i : Fin W => fun j : Fin H=>cfg (i,j))) + (fun xs=>if xs=List.ofFn (fun j=>spinEquiv.symm (east j)) then (1:ℂ) else 0) + (List.ofFn (fun j=>spinEquiv.symm (west j))) := by + classical + let cs := List.ofFn (fun i : Fin W => fun j : Fin H=>cfg (i,j)) + have hv := congrFun (chosenProduct_mulVec cs + (fun xs=>if xs=List.ofFn (fun j=>spinEquiv.symm (east j)) then (1:ℂ) else 0)) west + rw [vector_delta] at hv + simp only [Matrix.mulVec,dotProduct,mul_ite,mul_one,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] at hv + rw [chosenPartition_eq_transfer] + have hcs : List.ofFn (fun i=>chosenColumnKernel (fun j=>cfg (i,j)) 1 1) = + cs.map (fun q=>chosenColumnKernel q 1 1) := by + rw [List.map_ofFn] + rfl + rw [hcs] + exact hv + +/-- Actual finite-grid orientation coefficient with fixed unoriented +configuration and vacant boundary. It is real and nonnegative, despite +its complex local factors. -/ +theorem chosen_vacuum_zero_or_one {W H : ℕ} (cfg : Cell W H → Shape) : + chosenPartition cfg (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1)=0 ∨ + chosenPartition cfg (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1)=1 := by + rw [chosenPartition_eq_shapeFold] + have hn : List.ofFn (fun _ : Fin H=>spinEquiv.symm (1:Fin 3)) = + List.replicate H none := by simp [spinEquiv] + simp only [hn] + exact resolved_vacuum (shapeFold_resolved (by omega : 0≤1) _ (vacuum_delta_resolved H)) + +lemma prescribed_shape_expansion {W H : ℕ} (west east : Column H) + (south north : Fin W → Fin 3) : + prescribedPartition W H west east south north = + ∑ cfg : Cell W H → Shape, (kappa:ℂ)^(∑ t, (cfg t).visits) * + chosenPartition cfg west east south north := by + classical + rw [prescribedPartition_eq_grid_sum] + simp_rw [physical_network_expansion,Finset.ite_sum_zero] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro cfg hcfg + rw [chosenPartition_eq_grid_sum,Finset.mul_sum] + apply Finset.sum_congr rfl + intro σ hσ + split_ifs <;> simp + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators +lemma addOne_span {n : ℕ} {f : DiluteState} (hf : PlanarSpan n f) : + PlanarSpan (n+1) (addOne f) := by + induction hf with + | zero => + have h : addOne (fun _ => 0) = fun _ => 0 := by + funext xs; cases xs with + | nil => rfl + | cons x xs => cases x <;> rfl + rw [h]; exact .zero + | basis o k w hl hc => + rw [addOne_embed] + exact .basis _ k w (by simp [hl]) (by simpa using hc) + | add hf hg ihf ihg => + have h : ∀ f g, addOne (fun xs => f xs + g xs) = + fun xs => addOne f xs + addOne g xs := by + intro f g; funext xs; cases xs with + | nil => simp [addOne] + | cons x xs => cases x <;> simp [addOne] + rw [h]; exact .add ihf ihg + | smul z hf ihf => + have h : ∀ f, addOne (fun xs => z * f xs) = fun xs => z * addOne f xs := by + intro f; funext xs; cases xs with + | nil => simp [addOne] + | cons x xs => cases x <;> simp [addOne] + rw [h]; exact .smul z ihf + +lemma removeOne_span {n : ℕ} {f : DiluteState} (hf : PlanarSpan (n+1) f) : + PlanarSpan n (removeOne f) := by + induction hf with + | zero => exact .zero + | add hf hg ihf ihg => exact .add ihf ihg + | smul z hf ihf => exact .smul z ihf + | basis o k w hl hc => + cases o using List.reverseRecOn with + | nil => simp at hl + | append_singleton pre a => + rw [removeOne_embed] + split_ifs with ha + · subst a + exact .basis _ k w (by simpa using hl) (by simpa using hc) + · exact .zero + +lemma planarRow_span {n i : ℕ} (ts : List TileWeights) (hi : i+ts.length exact hf + | cons t ts ih => + apply ih (by simp at hi; omega) + exact act_span t (by simp at hi; omega) hf + +lemma planarRow_vacuum {n i : ℕ} (ts : List TileWeights) (hi : i+ts.length rfl + | cons t ts ih => + have hstep : i+1 1)) + (List.replicate n none) = 1 := by + have gen : ∀ m {f : DiluteState}, PlanarSpan n f → + ((vacuumColumn t n)^[m]) f (List.replicate n none) = f (List.replicate n none) := by + intro m + induction m with + | zero => intro f hf; rfl + | succ m ih => + intro f hf + rw [Function.iterate_succ_apply,ih (vacuumColumn_span t hf),vacuumColumn_vacuum t hf] + have hf : PlanarSpan n (embed (List.replicate n false) (fun _ => 1)) := + PlanarSpan.basis (List.replicate n false) 0 .start + (by simp) (by simp [List.count_replicate]) + rw [gen m hf] + simp [embed,occupancy] + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators Matrix + +lemma addOne_cons (f : DiluteState) (x : Spin) (xs : List Spin) : + addOne f (x::xs) = if x=none then f xs else 0 := by cases x <;> rfl + +/-- The finite orientation sum and the column operator agree also for a +general boundary state, so that consecutive columns compose exactly. -/ +lemma vacuumColumn_eq_kernel (t : TileWeights) (n : ℕ) (f : DiluteState) + (west : Fin n → Spin) : + vacuumColumn t n f (List.ofFn west) = + ∑ east : Fin n → Spin, columnKernelSpin t n none none west east * f (List.ofFn east) := by + classical + unfold vacuumColumn removeOne + rw [planarRow_eq_columnContraction] + unfold columnContraction columnKernelSpin + apply Finset.sum_congr rfl + intro east heast + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro vertical hvertical + rw [addOne_cons] + split_ifs <;> simp + +end CriticalHoneycomb.Transfer.PlanarNormalization + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization +open scoped BigOperators Matrix + +lemma column_mulVec (H : ℕ) (f : DiluteState) : + (columnKernel H 1 1).mulVec (columnVector H f) = + columnVector H (vacuumColumn physicalWeights H f) := by + classical + funext w + obtain ⟨west,rfl⟩ := (columnSpinEquiv H).surjective w + simp only [columnVector,columnSpinEquiv_apply,Equiv.symm_apply_apply] + rw [vacuumColumn_eq_kernel] + unfold Matrix.mulVec dotProduct + rw [←(columnSpinEquiv H).sum_comp] + apply Finset.sum_congr rfl + intro east heast + change columnKernel H (spinEquiv none) (spinEquiv none) + (columnSpinEquiv H west) (columnSpinEquiv H east) * _ = _ + rw [columnKernel_eq_spin] + change _ * f (List.ofFn (fun j => spinEquiv.symm (spinEquiv (east j)))) = _ + simp only [Equiv.symm_apply_apply] + +lemma column_pow_mulVec (H W : ℕ) (f : DiluteState) : + ((columnKernel H 1 1)^W).mulVec (columnVector H f) = + columnVector H (((vacuumColumn physicalWeights H)^[W]) f) := by + induction W generalizing f with + | zero => simp + | succ W ih => + rw [pow_succ,←Matrix.mulVec_mulVec,column_mulVec,ih,Function.iterate_succ_apply] + +lemma vector_vacuum (H : ℕ) : + columnVector H (embed (List.replicate H false) (fun _=>1)) = + fun east => if east=(fun _=>1) then 1 else 0 := by + classical + funext east + have he : occupancy (List.ofFn (fun j => spinEquiv.symm (east j))) = + List.replicate H false ↔ east=fun _=>1 := by + rw [occupancy,List.map_ofFn,←List.ofFn_const, List.ofFn_injective.eq_iff] + constructor + · intro h + funext j + have hh := congrFun h j + simpa [Function.comp_def,spinEquiv] using hh + · rintro rfl + rfl + simp only [columnVector,embed,he] + +/-- The actual finite strip transfer has unmarked empty-empty entry one. +This is a literal honeycomb-grid identity, not an assumed loop pairing. -/ +theorem physical_vacuum_entry (H W : ℕ) : + ((columnKernel H 1 1)^W) (fun _=>1) (fun _=>1) = 1 := by + classical + have hm := congrFun (column_pow_mulVec H W (embed (List.replicate H false) (fun _=>1))) + (fun _=>1) + rw [vector_vacuum] at hm + simp only [Matrix.mulVec,dotProduct,mul_ite,mul_one,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] at hm + rw [hm] + change ((vacuumColumn physicalWeights H)^[W]) _ (List.ofFn (fun _ : Fin H => none))=1 + simpa using vacuumRectangle physicalWeights H W + +/-- Equivalent four-wall statement for the finite physical tensor partition. -/ +theorem prescribed_vacuum_partition (W H : ℕ) : + prescribedPartition W H (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) = 1 := by + rw [prescribedPartition_eq_transfer] + simp only [List.ofFn_const,List.prod_replicate] + exact physical_vacuum_entry H W + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization PhysicalTiles +open scoped BigOperators Matrix + +lemma shapeTensor_empty_ne_zero (w n s e : Fin 3) : + shapeTensor .empty w n s e ≠ 0 ↔ w=1 ∧ n=1 ∧ s=1 ∧ e=1 := by + simp only [shapeTensor,Planar.vacant,mul_ne_zero_iff] + split_ifs <;> simp_all + +lemma chosenColumnProduct_empty {H : ℕ} (west east vertical : Column H) : + chosenColumnProduct (fun _=>.empty) west east vertical 1 = + if west=(fun _=>1) ∧ east=(fun _=>1) ∧ vertical=(fun _=>1) then 1 else 0 := by + classical + split_ifs with he + · rcases he with ⟨rfl,rfl,rfl⟩ + unfold chosenColumnProduct + have hv : Fin.snoc (α:=fun _=>Fin 3) (fun _ : Fin H=>1) 1=(fun _=>1) := by + funext i; cases i using Fin.lastCases <;> simp + simp [hv,shapeTensor,Planar.vacant] + · by_contra hn + apply he + have hp (j : Fin H) := shapeTensor_empty_ne_zero (west j) + ((Fin.snoc (α:=fun _=>Fin 3) vertical 1) j.succ) (vertical j) (east j) + have hh (j : Fin H) : west j=1 ∧ + (Fin.snoc (α:=fun _=>Fin 3) vertical 1) j.succ=1 ∧ vertical j=1 ∧ east j=1 := + (hp j).mp ((Finset.prod_ne_zero_iff.mp hn) j (Finset.mem_univ j)) + exact ⟨funext (fun j=>(hh j).1),funext (fun j=>(hh j).2.2.2), + funext (fun j=>(hh j).2.2.1)⟩ + +lemma chosenColumnKernel_empty {H : ℕ} (west east : Column H) : + chosenColumnKernel (fun _=>.empty) 1 1 west east = + if west=(fun _=>1) ∧ east=(fun _=>1) then 1 else 0 := by + classical + unfold chosenColumnKernel + rw [Finset.sum_eq_single (fun _=>1)] + · rw [chosenColumnProduct_empty] + have hv : Fin.snoc (α:=fun _=>Fin 3) (fun _ : Fin H=>1) 1=(fun _=>1) := by + funext i; cases i using Fin.lastCases <;> simp + simp [hv] + · intro v hv hne + rw [chosenColumnProduct_empty] + simp [hne] + · simp + +lemma chosenProduct_empty_vacuum (H W : ℕ) : + ((chosenColumnKernel (fun _ : Fin H=>.empty) 1 1)^W) + (fun _=>1) (fun _=>1) = 1 := by + classical + induction W with + | zero => simp + | succ W ih => + rw [pow_succ,Matrix.mul_apply] + simp_rw [chosenColumnKernel_empty] + simpa using ih + +lemma chosen_empty_partition (W H : ℕ) : + chosenPartition (fun _ : Cell W H=>.empty) + (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1) = 1 := by + rw [chosenPartition_eq_transfer] + simp only [List.ofFn_const,List.prod_replicate] + exact chosenProduct_empty_vacuum H W + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization PhysicalTiles +open scoped BigOperators Matrix + +/-- Every nonempty fixed unoriented configuration with vacant boundary has +vanishing orientation sum on the actual finite honeycomb grid. No turning +lemma or assumed graphical cancellation is being invoked. -/ +theorem chosen_nonempty_vacuum_zero {W H : ℕ} (cfg : Cell W H → Shape) + (hne : cfg ≠ fun _=>.empty) : + chosenPartition cfg (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1)=0 := by + classical + let F : (Cell W H → Shape) → ℝ := fun q=> + kappa^(∑ t, (q t).visits) * + (chosenPartition q (fun _=>1) (fun _=>1) (fun _=>1) (fun _=>1)).re + have hk : 01) (fun _=>1) + (fun _ : Fin W=>1) (fun _=>1) + rw [prescribed_vacuum_partition] at hh + have hs := congrArg Complex.re hh + simpa only [F,Complex.re_sum,←Complex.ofReal_pow,Complex.mul_re,Complex.ofReal_re, + Complex.ofReal_im,zero_mul,sub_zero,Complex.one_re] using hs.symm + have he : F (fun _=>.empty)=1 := by + simp [F,chosen_empty_partition,Shape.visits] + rcases chosen_vacuum_zero_or_one cfg with hz|hone + · exact hz + · have hq : F cfg=kappa^(∑ t, (cfg t).visits) := by simp [F,hone] + have hle : (∑ q ∈ ({(fun _=>.empty),cfg} : Finset (Cell W H → Shape)),F q) ≤ + ∑ q, F q := + Finset.sum_le_sum_of_subset_of_nonneg (by simp) (by intros; exact hnonneg _) + rw [Finset.sum_pair (Ne.symm hne),he,hq,hsum] at hle + have hp := pow_pos hk (∑ t, (cfg t).visits) + linarith + +end CriticalHoneycomb.Transfer.RasterGrid + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/OrderedAssociation.lean b/lean/OAI/Combinatorics/HoneycombChords/OrderedAssociation.lean new file mode 100644 index 0000000000000000000000000000000000000000..a606ba40b3dad7b6f9c925f3918e52cf8e07cc7d --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/OrderedAssociation.lean @@ -0,0 +1,828 @@ +import OAI.Combinatorics.HoneycombChords.ResidualAsymptotics +import OAI.Combinatorics.HoneycombChords.FourFunctions + +namespace OAI + +/-! +# Ordered integral association and strip coefficient bounds + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Honeycomb370 Matrix Finset Set + +noncomputable def gramNodeDensity {n : ℕ} (F G : Fin n → ℝ → ℝ) (w : ℝ → ℝ) + (x : Fin n → ℝ) : ℝ := + (evaluationMatrix F x).det * (evaluationMatrix G x).det * ∏ i,w (x i) +noncomputable def errorNodeDensity {n : ℕ} (F G : Fin n → ℝ → ℝ) (H w : ℝ → ℝ) + (x : Fin n → ℝ) : ℝ := + (evaluationMatrix (Fin.lastCases H F) (Fin.cons 0 x)).det * + (evaluationMatrix G x).det * ∏ i,w (x i) + +lemma ordered_eval_nonneg {n : ℕ} (F : Fin n → ℝ → ℝ) (hF : PositiveEvaluation F) + {x : Fin n → ℝ} (hx : Monotone x) (hx0 : ∀ i,0v j^e i) := by + let f : ℝ → ℝ := fun t=>Matrix.det (fun i j=> (v j+t)^e i) + have hc : Continuous f := by unfold f;fun_prop + have hp : ∀ᶠ t in 𝓝[>] (0:ℝ),0≤f t := by + filter_upwards [self_mem_nhdsWithin] with t ht + apply (power_det_pos e (fun j=>v j+t) he _ _).le + · intro i j hij + change v i+tb i)) + (hball : ∀ i,0≤b i ∧ b i≤R) (v : Fin n → ℝ) + (hv : StrictMono v) (hv0 : ∀ i,0≤v i) (e : Fin n → ℕ) : + 0≤Matrix.det (fun i j : Fin n=>cosineKernelJet (nodalOrder b j) (e i) (b j) (-a))* + Matrix.det (fun i j=>v j^e i) := by + classical + by_cases hi : Function.Injective e + · obtain ⟨d,σ,hd,he⟩:=sorted_injective_exponents hi + rw [he] + let A : Matrix (Fin n) (Fin n) ℝ := fun i j=>cosineKernelJet (nodalOrder b j) (d i) (b j) (-a) + let B : Matrix (Fin n) (Fin n) ℝ := fun i j=>v j^d i + change 0≤(A.submatrix σ id).det*(B.submatrix σ id).det + rw [Matrix.det_permute,Matrix.det_permute] + have hA:=translated_beta_jet_det_nonneg ha hR hphase b hb hball d hd + have hB:=power_det_nonneg_nonnegative d v hd hv hv0 + have hp:=mul_nonneg (sq_nonneg (((Equiv.Perm.sign σ:ℤ):ℝ))) (mul_nonneg hA hB) + dsimp [A,B] at * + nlinarith only [hp] + · obtain ⟨i,j,heq,hij⟩:=Function.not_injective_iff.mp hi + have hz : Matrix.det (fun i j : Fin n=>cosineKernelJet (nodalOrder b j) (e i) (b j) (-a))=0 := by + apply Matrix.det_zero_of_row_eq hij + change (fun j : Fin n=>cosineKernelJet (nodalOrder b j) (e i) (b j) (-a))= + (fun k : Fin n=>cosineKernelJet (nodalOrder b k) (e j) (b k) (-a)) + rw [heq] + rw [hz,zero_mul] + +lemma translated_kernel_det_nonneg {n : ℕ} {a R : ℝ} + (ha : 0≤a) (hR : 0b i)) + (hball : ∀ i,0≤b i ∧ b i≤R) (v : Fin n → ℝ) + (hv : StrictMono v) (hv0 : ∀ i,0≤v i) : + 0≤Matrix.det (fun i j : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i) (-a+v j)) := by + let A (m : ℕ) : Matrix (Fin n) (Fin m) ℝ := fun i k=>cosineKernelJet (nodalOrder b i) k (b i) (-a) + let B (m : ℕ) : Matrix (Fin m) (Fin n) ℝ := fun k j=>v j^k.val + have hp (m : ℕ) : 0≤(A m*B m).det := by + have hsum : 0≤∑ f : Fin n → Fin m,((A m).submatrix id f).det * ((B m).submatrix f id).det := by + apply sum_nonneg + intro f _ + rw [←Matrix.det_transpose ((A m).submatrix id f)] + exact translated_kernel_minor_pair_nonneg ha hR hphase b hb hball v hv hv0 (fun i=>(f i).val) + rw [det_rectangular_binet] at hsum + have hc : (0:ℝ)A m*B m) atTop + (𝓝 (fun i j : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i) (-a+v j))) := by + apply tendsto_pi_nhds.mpr + intro i + apply tendsto_pi_nhds.mpr + intro j + have h := (cosineKernelJet_translation_summable (nodalOrder b i) (b i) (-a) (v j)).hasSum.tendsto_sum_nat + rw [←cosineKernelJet_translation] at h + convert h using 1 + · funext m + change (∑ k : Fin m,cosineKernelJet (nodalOrder b i) k (b i) (-a)*(v j)^k.val)=_ + exact Fin.sum_univ_eq_sum_range (fun k : ℕ=>cosineKernelJet (nodalOrder b i) k (b i) (-a)*(v j)^k) m + exact ge_of_tendsto ((continuous_id.matrix_det).continuousAt.tendsto.comp ht) (Eventually.of_forall hp) + +lemma residual_det_augment_at {n : ℕ} (F : Fin n → ℝ → ℝ) (H : ℝ → ℝ) + (a : ℝ) (hH : H a≠0) (x : Fin n → ℝ) : + (-1:ℝ)^n * H a * (evaluationMatrix (residualFamily F H a) x).det = + (evaluationMatrix (Fin.lastCases H F) (Fin.cons a x)).det := by + let B:=evaluationMatrix (Fin.lastCases H F) (Fin.cons a x) + let A:=evaluationMatrix (Fin.lastCases H (residualFamily F H a)) (Fin.cons a x) + let c : Fin (n+1) → ℝ := Fin.lastCases 0 (fun i=> -F i a/H a) + have he : A.det=B.det := by + apply Matrix.det_eq_of_forall_row_eq_smul_add_const c (Fin.last n) (by simp [c]) + intro i j + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [A,B,c,evaluationMatrix] + · simp only [A,B,c,evaluationMatrix,Fin.lastCases_castSucc,Fin.lastCases_last,residualFamily] + ring + rw [Matrix.det_succ_column_zero,Fin.sum_univ_castSucc] at he + have hz : (∑ i : Fin n,(-1:ℝ)^(i.castSucc.val)*A i.castSucc 0* + (A.submatrix i.castSucc.succAbove Fin.succ).det)=0 := by + apply sum_eq_zero + intro i _ + simp [A,evaluationMatrix,residualFamily,hH] + rw [hz,zero_add] at he + have hm : A.submatrix (Fin.last n).succAbove Fin.succ= + evaluationMatrix (residualFamily F H a) x := by + ext i j + simp [A,Matrix.submatrix,evaluationMatrix,Fin.succAbove_last] + simpa only [hm,A,B,evaluationMatrix,Fin.lastCases_last,Fin.cons_zero,Fin.val_last] using he + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Honeycomb370 MeasureTheory Set Matrix Finset + +lemma familyPointDensity_integrable_ordered {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (hi : ∀ i j,IntegrableOn (fun p ↦ F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + IntegrableOn (familyPointDensity w F G) (orderedPositive n) := by + have hh:=(family_gram_andreief w F G hi).1 + rw [←Measure.restrict_pi_pi] at hh + change IntegrableOn (familyPointDensity w F G) (Set.pi Set.univ (fun _ : Fin n ↦ Set.Ioi (0:ℝ))) at hh + exact hh.mono_set (fun x hx i hi ↦ hx.2 i) + +/-- Exact ordered Andreief identity for distinct left and right families. -/ +theorem familyGram_ordered_integral {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (hi : ∀ i j,IntegrableOn (fun p ↦ F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + (∫ p in orderedPositive n,familyPointDensity w F G p)=(familyGram w F G).det := by + have ha:=(family_gram_andreief w F G hi).2 + have ho:=integral_symmetric_ordered (familyPointDensity w F G) + (familyPointDensity_perm w F G) (familyPointDensity_eq_zero_of_not_injective w F G) + (familyPointDensity_integrable_ordered w F G hi) + rw [←Measure.restrict_pi_pi] at ha + have he : (Fintype.card (Equiv.Perm (Fin n)):ℝ)*(∫ p in orderedPositive n,familyPointDensity w F G p)= + (Fintype.card (Equiv.Perm (Fin n)):ℝ)*(familyGram w F G).det := ho.symm.trans ha + exact (mul_left_cancel₀ (Nat.cast_ne_zero.mpr Fintype.card_ne_zero)) he + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Honeycomb370 MeasureTheory Set Matrix Finset + +lemma PositiveEvaluation.square {n : ℕ} {F : Fin n → ℝ → ℝ} (hF : PositiveEvaluation F) : + PositiveEvaluation (fun i p ↦ F i (p^2)) := by + intro p hp hp0 + exact hF (fun i ↦ (p i)^2) (fun i j hij ↦ (sq_lt_sq₀ (hp0 i).le (hp0 j).le).mpr (hp hij)) + (fun i ↦ sq_pos_of_pos (hp0 i)) + +lemma gramNodeDensity_square {n : ℕ} (F G : Fin n → ℝ → ℝ) (w : ℝ → ℝ) (p : Fin n → ℝ) : + gramNodeDensity (fun i p ↦ F i (p^2)) (fun i p ↦ G i (p^2)) w p=familyPointDensity w F G p := by + unfold gramNodeDensity familyPointDensity evaluationMatrix + ring + +lemma errorNodeDensity_square {n : ℕ} (F G : Fin n → ℝ → ℝ) (H w : ℝ → ℝ) + (hH : H 0≠0) (p : Fin n → ℝ) : + errorNodeDensity (fun i p ↦ F i (p^2)) (fun i p ↦ G i (p^2)) (fun p ↦ H (p^2)) w p= + ((-1:ℝ)^n*H 0)*familyPointDensity w (residualFamily F H 0) G p := by + have he : evaluationMatrix (Fin.lastCases (fun p ↦ H (p^2)) (fun i p ↦ F i (p^2))) (Fin.cons 0 p)= + evaluationMatrix (Fin.lastCases H F) (Fin.cons 0 (fun i ↦ (p i)^2)) := by + ext i j + refine Fin.lastCases ?_ (fun i ↦ ?_) i <;> refine Fin.cases ?_ (fun j ↦ ?_) j <;> simp [evaluationMatrix] + unfold errorNodeDensity + rw [he,←residual_det_augment_at F H 0 hH] + unfold familyPointDensity evaluationMatrix + ring + +/-- The actual negative coefficient can only increase when the weight is +multiplied by an increasing ratio. Left and right systems are kept distinct. -/ +theorem negative_meanResidualRatio_compare (N : ℕ) (F G : Fin (2*N+1) → ℝ → ℝ) + (H w r : ℝ → ℝ) (hF : PositiveEvaluation F) (hG : PositiveEvaluation G) + (hA : PositiveEvaluation (Fin.lastCases H F)) + (hcF : ∀ i,Continuous (F i)) (hcG : ∀ i,Continuous (G i)) (hcH : Continuous H) + (hcw : ContinuousOn w (Set.Ioi 0)) (hcr : ContinuousOn r (Set.Ioi 0)) + (hU : ∀ x,StrictMono x → (∀ i,0 simp [h,f] + have hUp (x : Fin (2*N+1) → ℝ) (hx : StrictMono x) (hx0 : ∀ i,0 refine Fin.cases ?_ (fun j ↦ ?_) j <;> simp [f,h,evaluationMatrix] + have hD (v : ℝ → ℝ) : gramNodeDensity f g v=familyPointDensity v F G := funext (gramNodeDensity_square F G v) + have hE (v : ℝ → ℝ) : errorNodeDensity f g h v=fun p ↦ -(H 0)*familyPointDensity v (residualFamily F H 0) G p := by + funext p + rw [errorNodeDensity_square F G H v hH.ne'] + simp [pow_add,pow_mul] + have hiR:=residualFamily_pair_integrable w F G H 0 hi hH₁ + have hiR':=residualFamily_pair_integrable (fun p ↦ w p*r p) F G H 0 hi' hH₂ + have hcompare:=ordered_error_association f g h w r hF.square hG.square hAp + (fun i ↦ (hcF i).comp (continuous_id.pow 2)) (fun i ↦ (hcG i).comp (continuous_id.pow 2)) + (hcH.comp (continuous_id.pow 2)) hcw hcr hUp hw hr hm + (by rw [hE]; exact (familyPointDensity_integrable_ordered w _ G hiR).const_mul _) + (by rw [hD]; exact familyPointDensity_integrable_ordered _ F G hi') + (by rw [hD]; exact familyPointDensity_integrable_ordered _ F G hi) + (by rw [hE]; exact (familyPointDensity_integrable_ordered _ _ G hiR').const_mul _) + simp_rw [hD,hE,integral_const_mul,familyGram_ordered_integral w F G hi, + familyGram_ordered_integral _ F G hi',familyGram_ordered_integral w _ G hiR, + familyGram_ordered_integral _ _ G hiR'] at hcompare + unfold meanResidualRatio + rw [←neg_div,←neg_div] + apply (div_le_div_iff₀ hd hd').mpr + nlinarith only [hcompare,hH] + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +/-! The strip weight has an increasing ratio to the hyperbolic secant comparison weight. -/ +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real + +private noncomputable def ratioP (u : ℝ) : ℝ := (2*u-1)*(4*u^2-3) +private noncomputable def ratioQ (u : ℝ) : ℝ := 2*u^2-1 +private noncomputable def ratioE (v : ℝ) : ℝ := 11*v+64*v^2+142*v^3+104*v^4+24*v^5 +private noncomputable def sechRatio (x : ℝ) : ℝ := + x*ratioP (Real.cosh x)/(4*Real.sinh x*ratioQ (Real.cosh x)) + +private lemma ratioP_pos {u : ℝ} (hu : 1≤u) : 0 nlinarith [sq_nonneg (u-1)] +private lemma ratioQ_pos {u : ℝ} (hu : 1≤u) : 0F i (p^2)*w p)) + (hfi : ∀ i,IntegrableOn (fun p=>|F i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) + (hrm : ∀ i,Measurable (fun p=>R i (p^2)*w p)) + (hri : ∀ i,IntegrableOn (fun p=>|R i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) + (hd : 0<(familyGram w F (mixedFamily N)).det) + (hdt : ∀ t,0(familyGram w F (parameterFamily N t)).det) (Set.uIcc 0 angle) := by + rw [Set.uIcc_of_le strip_angle_pos.le] + exact (continuous_id.matrix_det).comp_continuousOn (parameterGram_continuousOn N w F hfm hfi) + have hcontR : ContinuousOn (fun t=>(familyGram w R (parameterFamily N t)).det) (Set.uIcc 0 angle) := by + rw [Set.uIcc_of_le strip_angle_pos.le] + exact (continuous_id.matrix_det).comp_continuousOn (parameterGram_continuousOn N w R hrm hri) + have hup:=intervalIntegral.integral_mono_on_of_le_Ioo (μ:=volume) strip_angle_pos.le + hcontR.intervalIntegrable (hcontF.intervalIntegrable.const_mul A) + (fun t ht=>by + rw [parameterFamily_interior N ht.1 ht.2] + exact (div_le_iff₀ (hdt t ht.1 ht.2)).mp (hb t ht.1 ht.2)) + rw [intervalIntegral.integral_const_mul,←mixedGram_det_integral N w F hfm hfi, + ←mixedGram_det_integral N w R hrm hri] at hup + exact (div_le_iff₀ hd).mpr hup + +lemma cThree_cosh_integrable : + IntegrableOn (fun p ↦ |(C (3*angle/2) (p^2)).re*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0) := by + apply weighted_cosh_norm_integrable + have hi:=strip_jet_pair_integrable (sq_nonneg (3*angle/2)) (sq_nonneg angle) le_rfl le_rfl 0 0 + apply hi.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have he : cosineKernelJet 0 0 (angle^2) (p^2)=Real.cosh (angle*p) := by + apply Complex.ofReal_injective + rw [←C_eq_beta_square,C_sq _ hp.le] + rw [he,C_eq_beta_square] + simp only [Complex.ofReal_re] + ring + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open StripAsymptotic Matrix MeasureTheory + +lemma strip_jet_coefficient_lower (N : ℕ) {t : ℝ} (ht : 0 intro i <;> dsimp [mix] <;> split_ifs + · exact le_rfl + · exact hxy i + · exact hxy i + · exact le_rfl + +private lemma mix_zero {n : ℕ} (x y : Fin n → ℝ) : mix x y 0 = y := by + ext i + simp [mix] + +private lemma mix_end {n : ℕ} (x y : Fin n → ℝ) : mix x y n = x := by + ext i + simp [mix, i.isLt] + +private lemma mix_step {n : ℕ} (x y : Fin n → ℝ) (k : ℕ) (hk : k < n) : + mix x y k = Function.update (mix x y (k+1)) ⟨k,hk⟩ (y ⟨k,hk⟩) := by + ext i + by_cases hi : i = ⟨k,hk⟩ + · subst i + simp [mix] + · have hine : i.val ≠ k := by simpa [Fin.ext_iff] using hi + have hh : i.val < k+1 ↔ i.val < k := by omega + simp [Function.update_of_ne hi, mix, hh] + +/-- Coordinatewise monotonicity on the ordered positive chamber. -/ +theorem monotone_ordered_of_coordinate {n : ℕ} (a : ℝ) (f : (Fin n → ℝ) → ℝ) + (hlocal : ∀ x i r, (∀ k,a exact le_rfl + | succ k ih => exact (step k (by omega)).trans (ih (by omega)) + simpa only [mix_end,mix_zero] using hh n le_rfl + +/-- Increasing a single coordinate has a larger increment at a larger ordered +base, provided all four ordered tuples are admissible. -/ +theorem increasing_increment_ordered {n : ℕ} (f : (Fin n → ℝ) → ℝ) + (hlocal : ∀ (x : Fin n → ℝ) (i j : Fin n) (r s : ℝ), i ≠ j → + x i ≤ r → x j ≤ s → (∀ k, 0 < x k) → StrictMono x → + StrictMono (Function.update x i r) → StrictMono (Function.update x j s) → + StrictMono (Function.update (Function.update x i r) j s) → + f (Function.update x i r) + f (Function.update x j s) ≤ + f x + f (Function.update (Function.update x i r) j s)) + {x y : Fin n → ℝ} (i : Fin n) (r : ℝ) + (hxy : x ≤ y) (hi : x i = y i) (hr : y i ≤ r) + (hxpos : ∀ k, 0 < x k) (hx : StrictMono x) (hy : StrictMono y) + (hxr : StrictMono (Function.update x i r)) + (hyr : StrictMono (Function.update y i r)) : + f (Function.update x i r) - f x ≤ f (Function.update y i r) - f y := by + have hup : Function.update x i r ≤ Function.update y i r := by + intro j + by_cases hji : j = i + · subst j; simp + · simpa [Function.update_of_ne hji] using hxy j + have hmixup (k : ℕ) : Function.update (mix x y k) i r = + mix (Function.update x i r) (Function.update y i r) k := by + ext j + by_cases hji : j = i + · subst j; simp [mix] + · simp [Function.update_of_ne hji, mix] + have hadd (k : ℕ) (hk : k < n) : + f (Function.update (mix x y (k+1)) i r) - f (mix x y (k+1)) ≤ + f (Function.update (mix x y k) i r) - f (mix x y k) := by + let j : Fin n := ⟨k,hk⟩ + by_cases hij : i = j + · subst i + have he : mix x y k = mix x y (k+1) := by + rw [mix_step x y k hk] + apply Function.update_eq_self_iff.mpr + dsimp [mix,j] + simpa using hi.symm + rw [he] + · have hb : mix x y (k+1) j = x j := by simp [mix,j] + have hbi : mix x y (k+1) i ≤ r := ((mix_le hxy _).2 i).trans hr + have hl := hlocal (mix x y (k+1)) i j r (y j) hij hbi + (by rw [hb]; exact hxy j) (fun l ↦ (hxpos l).trans_le ((mix_le hxy _).1 l)) + (mix_strictMono hx hy hxy _) + (by rw [hmixup]; exact mix_strictMono hxr hyr hup _) + (by rw [←mix_step x y k hk]; exact mix_strictMono hx hy hxy _) + (by rw [Function.update_comm hij,←mix_step x y k hk,hmixup] + exact mix_strictMono hxr hyr hup _) + rw [Function.update_comm hij,←mix_step x y k hk] at hl + linarith + have hh (k : ℕ) (hk : k ≤ n) : + f (Function.update (mix x y k) i r) - f (mix x y k) ≤ + f (Function.update (mix x y 0) i r) - f (mix x y 0) := by + induction k with + | zero => exact le_rfl + | succ k ih => exact (hadd k (by omega)).trans (ih (by omega)) + simpa only [mix_zero,mix_end] using hh n le_rfl + +/-- The exact global lattice inequality needed in the four-functions theorem. +All inputs here are local two-coordinate inequalities, not association. -/ +theorem supermodular_ordered_of_local {n : ℕ} (f : (Fin n → ℝ) → ℝ) + (hlocal : ∀ (x : Fin n → ℝ) (i j : Fin n) (r s : ℝ), i ≠ j → + x i ≤ r → x j ≤ s → (∀ k, 0 < x k) → StrictMono x → + StrictMono (Function.update x i r) → StrictMono (Function.update x j s) → + StrictMono (Function.update (Function.update x i r) j s) → + f (Function.update x i r) + f (Function.update x j s) ≤ + f x + f (Function.update (Function.update x i r) j s)) + {x y : Fin n → ℝ} (hxpos : ∀ k, 0 < x k) (hypos : ∀ k, 0 < y k) + (hx : StrictMono x) (hy : StrictMono y) : + f x + f y ≤ f (x ⊓ y) + f (x ⊔ y) := by + let a := x ⊓ y + let b := x ⊔ y + have ha : StrictMono a := by + intro i j hij + exact lt_min ((min_le_left _ _).trans_lt (hx hij)) + ((min_le_right _ _).trans_lt (hy hij)) + have hb : StrictMono b := by + intro i j hij + exact max_lt ((hx hij).trans_le (le_max_left _ _)) + ((hy hij).trans_le (le_max_right _ _)) + have hax : a ≤ x := inf_le_left + have hyb : y ≤ b := le_sup_right + have halve (k : ℕ) : mix a x k ≤ mix y b k := by + intro i + dsimp [mix] + split_ifs + · exact inf_le_right (a := x) (b := y) i + · exact le_sup_left (a := x) (b := y) i + have step (k : ℕ) (hk : k < n) : + f (mix y b (k+1)) - f (mix a x (k+1)) ≤ + f (mix y b k) - f (mix a x k) := by + let i : Fin n := ⟨k,hk⟩ + by_cases hi : x i ≤ y i + · have haxi : a i = x i := min_eq_left hi + have hbyi : b i = y i := max_eq_right hi + have h1 : mix a x k = mix a x (k+1) := by + rw [mix_step a x k hk] + apply Function.update_eq_self_iff.mpr + simpa [mix,i] using haxi.symm + have h2 : mix y b k = mix y b (k+1) := by + rw [mix_step y b k hk] + apply Function.update_eq_self_iff.mpr + simpa [mix,i] using hbyi + rw [h1,h2] + · have hi' : y i ≤ x i := le_of_not_ge hi + have hai : a i = y i := min_eq_right hi' + have hbi : b i = x i := max_eq_left hi' + have hu : mix a x (k+1) i = y i := by simpa [mix,i] using hai + have hv : mix y b (k+1) i = y i := by simp [mix,i] + have hinc := increasing_increment_ordered f hlocal i (x i) + (halve (k+1)) (hu.trans hv.symm) (by rw [hv]; exact hi') + (fun j ↦ (lt_min (hxpos j) (hypos j)).trans_le ((mix_le hax _).1 j)) + (mix_strictMono ha hx hax _) (mix_strictMono hy hb hyb _) + (by rw [←mix_step a x k hk]; exact mix_strictMono ha hx hax _) + (by rw [←hbi,←mix_step y b k hk]; exact mix_strictMono hy hb hyb _) + rw [←mix_step a x k hk,←hbi,←mix_step y b k hk] at hinc + linarith + have hh (k : ℕ) (hk : k ≤ n) : + f (mix y b k) - f (mix a x k) ≤ f (mix y b 0) - f (mix a x 0) := by + induction k with + | zero => exact le_rfl + | succ k ih => exact (step k (by omega)).trans (ih (by omega)) + have he := hh n le_rfl + simp only [mix_zero,mix_end] at he + dsimp [a,b] at he + linarith +end Honeycomb370 + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +noncomputable def familyCombination {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin n → ℝ) (x : ℝ) : ℝ := + ∑ i,a i*F i x +def PositiveFlag (F : ℕ → ℝ → ℝ) (m : ℕ) : Prop := + ∀ k,k ≤ m → PositiveEvaluation (fun i : Fin k=>F i) +noncomputable def familyTestCoeffs {n : ℕ} (F : ℕ → ℝ → ℝ) (v : Fin n → ℝ) : Fin (n+1) → ℝ := + fun i=>(-1)^i.val*(Matrix.of (fun k j : Fin n=>F (i.succAbove k) (v j))).det +lemma familyTest_eq_det {n : ℕ} (F : ℕ → ℝ → ℝ) (v : Fin n → ℝ) (x : ℝ) : + familyCombination F (familyTestCoeffs F v) x=(evaluationMatrix (fun i : Fin (n+1)=>F i) (Fin.cons x v)).det := by + rw [Matrix.det_succ_column_zero] + unfold familyCombination familyTestCoeffs + apply sum_congr rfl + intro i _ + simp only [evaluationMatrix,Fin.cons_zero,Matrix.submatrix,Fin.cons_succ] + ring +lemma monomial_positiveEvaluation (n : ℕ) : PositiveEvaluation (fun i : Fin n=>fun x : ℝ=>x^i.val) := by + intro x hx _ + have he : evaluationMatrix (fun i : Fin n=>fun y : ℝ=>y^i.val) x=(Matrix.vandermonde x).transpose := by ext;rfl + rw [he,Matrix.det_transpose,Matrix.det_vandermonde] + exact prod_pos (fun i _=>prod_pos (fun j hj=>sub_pos.mpr (hx (mem_Ioi.mp hj)))) +lemma familyTest_sign_product {n : ℕ} (F : ℕ → ℝ → ℝ) (v : Fin n → ℝ) {x : ℝ} + (hF : PositiveEvaluation (fun i : Fin (n+1)=>F i)) + (hv : StrictMono v) (hv0 : ∀ i,0 < v i) (hx0 : 0 < x) (hx : ∀ i,x ≠ v i) : + 0 < familyCombination F (familyTestCoeffs F v) x*(∏ i,(v i-x)) := by + have hix : Function.Injective (Fin.cons x v) := by + intro i j he + refine Fin.cases (Fin.cases (fun _=>rfl) (fun j h=>False.elim (hx j h)) j) + (fun i=>Fin.cases (fun h=>False.elim (hx i h.symm)) (fun j h=>congrArg Fin.succ (hv.injective h)) j) i he + have hp:=evaluation_det_product_pos (fun i : Fin (n+1)=>F i) (fun i : Fin (n+1)=>fun y : ℝ=>y^i.val) + hF (monomial_positiveEvaluation _) (Fin.cons x v) hix (Fin.cases hx0 hv0) + have he : evaluationMatrix (fun i : Fin (n+1)=>fun y : ℝ=>y^i.val) (Fin.cons x v)= + (Matrix.vandermonde (Fin.cons x v)).transpose := by ext;rfl + rw [he,Matrix.det_transpose,vandermonde_cons_det,←familyTest_eq_det] at hp + have hc : 0 < (Matrix.vandermonde v).det := by + rw [Matrix.det_vandermonde] + exact prod_pos (fun i _=>prod_pos (fun j hj=>sub_pos.mpr (hv (mem_Ioi.mp hj)))) + rw [←mul_assoc] at hp + exact pos_of_mul_pos_left hp hc.le +lemma familyCombination_smul {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin n → ℝ) (e x : ℝ) : + familyCombination F (fun i=>e*a i) x=e*familyCombination F a x := by + simp only [familyCombination,mul_sum] + apply sum_congr rfl + intro i _ + ring +lemma familyCombination_continuous {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin n → ℝ) + (hF : ∀ i : Fin n,Continuous (F i)) : Continuous (familyCombination F a) := by + exact continuous_finsetSum _ (fun i _=>(hF i).const_mul (a i)) + +theorem positive_flag_sign_matching {m : ℕ} (F : ℕ → ℝ → ℝ) (f : ℝ → ℝ) + (hF : PositiveFlag F m) (hf : Continuous f) (s : Finset ℝ) (hs : ∀ x ∈ s,0 < x) + (hz : ∀ x,0 < x → (f x=0 ↔ x ∈ s)) (hc : s.card < m) : + ∃ k : ℕ,k+1 ≤ m ∧ ∃ a : Fin (k+1) → ℝ, + (∀ x,0 < x → 0 ≤ f x*familyCombination F a x) ∧ + (∀ x,0 < x → f x ≠ 0 → 0 < f x*familyCombination F a x) := by + classical + obtain ⟨t,ht,e,he,hpos⟩ := finite_zero_sign_polynomial f hf s 0 hs hz + let o := t.orderIsoOfFin rfl + let v : Fin t.card → ℝ := fun i=>(o i).val + have hv : StrictMono v := o.strictMono + have hvpos i : 0 < v i := hs _ (ht (o i).property) + have hdim : t.card+1 ≤ m := Nat.add_one_le_iff.mpr ((card_le_card ht).trans_lt hc) + let A : Fin (t.card+1) → ℝ := fun i=>(e*(-1)^t.card)*familyTestCoeffs F v i + have hstrict : ∀ x,0 < x → f x ≠ 0 → 0 < f x*familyCombination F A x := by + intro x hx hfx + have hxs : x∉s := fun h=>hfx ((hz x hx).mpr h) + have hxv i : x ≠ v i := fun h=>hxs (h.symm ▸ ht (o i).property) + have hp:=hpos x hx hxs + have hj:=familyTest_sign_product F v (hF _ hdim) hv hvpos hx hxv + have hprod : (∏ i : Fin t.card,(x-v i))=∏ z ∈ t,(x-z) := by + calc + _ = ∏ z : t,(x-z.val) := Equiv.prod_comp o.toEquiv (fun z : t=>x-z.val) + _ = _ := Finset.prod_attach _ _ + have hneg : (∏ i : Fin t.card,(v i-x))=(-1:ℝ)^t.card*(∏ z ∈ t,(x-z)) := by + simp_rw [show ∀ i : Fin t.card,v i-x=(-1:ℝ)*(x-v i) from fun i=>by ring] + rw [prod_mul_distrib,prod_const,card_univ,Fintype.card_fin,hprod] + rw [hneg] at hj + have hpp:=mul_pos hp hj + have heq : (f x*(e*∏ z ∈ t,(x-z)))*(familyCombination F (familyTestCoeffs F v) x* + ((-1:ℝ)^t.card*∏ z ∈ t,(x-z)))= + (f x*familyCombination F A x)*(∏ z ∈ t,(x-z))^2 := by + dsimp [A] + rw [familyCombination_smul] + ring + rw [heq] at hpp + exact pos_of_mul_pos_left hpp (sq_nonneg _) + refine ⟨t.card,hdim,A,?_,hstrict⟩ + intro x hx + by_cases hfx : f x=0 + · simp [hfx] + · exact (hstrict x hx hfx).le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Honeycomb370 + +lemma vandermonde_local_logsupermodular {n : ℕ} (x : Fin n → ℝ) + (i j : Fin n) (hij : i ≠ j) (r s : ℝ) (hr : x i ≤ r) (hs : x j ≤ s) + (hu : StrictMono (Function.update x i r)) + (hv : StrictMono (Function.update x j s)) : + (Matrix.vandermonde (Function.update x i r)).det * + (Matrix.vandermonde (Function.update x j s)).det ≤ + (Matrix.vandermonde x).det * + (Matrix.vandermonde (Function.update (Function.update x i r) j s)).det := by + simp only [Matrix.det_vandermonde,←Finset.prod_mul_distrib] + apply Finset.prod_le_prod₀ + · intro a _ + apply prod_nonneg + intro b hb + exact mul_nonneg (sub_nonneg.mpr (hu (mem_Ioi.mp hb)).le) + (sub_nonneg.mpr (hv (mem_Ioi.mp hb)).le) + · intro a _ + apply Finset.prod_le_prod₀ + · intro b hb + exact mul_nonneg (sub_nonneg.mpr (hu (mem_Ioi.mp hb)).le) + (sub_nonneg.mpr (hv (mem_Ioi.mp hb)).le) + · intro b hb + have hab : a ≠ b := ne_of_lt (mem_Ioi.mp hb) + simp only [Function.update_apply] + split_ifs <;> simp_all only [ne_eq, not_true_eq_false, not_false_eq_true] <;> nlinarith [mul_nonneg (sub_nonneg.mpr hr) (sub_nonneg.mpr hs)] + +private lemma eval_update {n : ℕ} (F : Fin n → ℝ → ℝ) (x : Fin n → ℝ) + (i : Fin n) (r : ℝ) : + evaluationMatrix F (Function.update x i r) = (evaluationMatrix F x).updateCol i (fun a ↦ F a r) := by + ext a b + by_cases h : b = i <;> simp [evaluationMatrix,h] + +private lemma eval_det_zero_of_noninjective {n : ℕ} (F : Fin n → ℝ → ℝ) (x : Fin n → ℝ) + (hx : ¬Function.Injective x) : (evaluationMatrix F x).det = 0 := by + obtain ⟨i,j,hx,hij⟩ := Function.not_injective_iff.mp hx + apply Matrix.det_zero_of_column_eq hij + intro a + simp only [evaluationMatrix,hx] + + +theorem positiveEvaluation_local_logsupermodular {n : ℕ} (F : Fin n → ℝ → ℝ) + (hF : PositiveEvaluation F) (x : Fin n → ℝ) + (i j : Fin n) (hij : i ≠ j) (r s : ℝ) (hr : x i ≤ r) (hs : x j ≤ s) + (hx0 : ∀ k, 0 < x k) (hx : StrictMono x) + (hu : StrictMono (Function.update x i r)) + (hv : StrictMono (Function.update x j s)) : + (evaluationMatrix F (Function.update x i r)).det * + (evaluationMatrix F (Function.update x j s)).det ≤ + (evaluationMatrix F x).det * + (evaluationMatrix F (Function.update (Function.update x i r) j s)).det := by + let P : Fin n → ℝ → ℝ := fun a t ↦ t^a.val + have hP : PositiveEvaluation P := monomial_positiveEvaluation n + have hd := determinant_column_diamond (evaluationMatrix F x) (hF x hx hx0).ne' + i j hij (fun a ↦ F a r) (fun a ↦ F a s) + have hpd := determinant_column_diamond (evaluationMatrix P x) (hP x hx hx0).ne' + i j hij (fun a ↦ P a r) (fun a ↦ P a s) + simp only [←eval_update] at hd hpd + have hvd := vandermonde_local_logsupermodular x i j hij r s hr hs hu hv + have he (z : Fin n → ℝ) : (evaluationMatrix P z).det = (Matrix.vandermonde z).det := by + change (Matrix.vandermonde z).transpose.det = _ + exact Matrix.det_transpose _ + simp only [he] at hpd + have hprodV : (Matrix.vandermonde (Function.update x i s)).det * + (Matrix.vandermonde (Function.update x j r)).det ≤ 0 := by linarith + have hcross : (evaluationMatrix F (Function.update x i s)).det * + (evaluationMatrix F (Function.update x j r)).det ≤ 0 := by + by_cases h1 : Function.Injective (Function.update x i s) + · by_cases h2 : Function.Injective (Function.update x j r) + · have hp1 := evaluation_det_product_pos F P hF hP (Function.update x i s) h1 (by + intro k + by_cases hk : k = i + · subst k; simpa using (hx0 j).trans_le hs + · simpa [Function.update_of_ne hk] using hx0 k) + have hp2 := evaluation_det_product_pos F P hF hP (Function.update x j r) h2 (by + intro k + by_cases hk : k = j + · subst k; simpa using (hx0 i).trans_le hr + · simpa [Function.update_of_ne hk] using hx0 k) + rw [he] at hp1 hp2 + have hh := mul_pos hp1 hp2 + have hrel : + ((evaluationMatrix F (Function.update x i s)).det * + (evaluationMatrix F (Function.update x j r)).det) * + ((Matrix.vandermonde (Function.update x i s)).det * + (Matrix.vandermonde (Function.update x j r)).det) > 0 := by nlinarith [hh] + exact le_of_lt (neg_of_mul_pos_left hrel hprodV) + · rw [eval_det_zero_of_noninjective F _ h2,mul_zero] + · rw [eval_det_zero_of_noninjective F _ h1,zero_mul] + linarith + +/-- Ordered-node MTP2 for a genuine (not necessarily polynomial) positive +Chebyshev evaluation determinant. -/ +theorem positiveEvaluation_logsupermodular {n : ℕ} (F : Fin n → ℝ → ℝ) + (hF : PositiveEvaluation F) {x y : Fin n → ℝ} + (hx0 : ∀ i, 0 < x i) (hy0 : ∀ i, 0 < y i) + (hx : StrictMono x) (hy : StrictMono y) : + (evaluationMatrix F x).det * (evaluationMatrix F y).det ≤ + (evaluationMatrix F (x ⊓ y)).det * (evaluationMatrix F (x ⊔ y)).det := by + have ha : StrictMono (x ⊓ y) := by + intro i j hij + exact lt_min ((min_le_left _ _).trans_lt (hx hij)) + ((min_le_right _ _).trans_lt (hy hij)) + have hb : StrictMono (x ⊔ y) := by + intro i j hij + exact max_lt ((hx hij).trans_le (le_max_left _ _)) + ((hy hij).trans_le (le_max_right _ _)) + have hlocal (z : Fin n → ℝ) (i j : Fin n) (r s : ℝ) + (hij : i ≠ j) (hr : z i ≤ r) (hs : z j ≤ s) + (hz0 : ∀ k,0 cosineKernelJet (nodalOrder (interiorKnotLabels N (angle/2)) i) 0 + (interiorKnotLabels N (angle/2) i) +noncomputable def realG (x : ℝ) : ℝ := ∫ t in (0:ℝ)..angle, cosineKernelJet 0 0 (t^2) x +noncomputable def mixedFamily (N : ℕ) : Fin (2*N+1) → ℝ → ℝ := + Function.update (fixedFamily N) (centralIndex N) realG + +lemma realG_complex (x : ℝ) : (realG x : ℂ) = g x := by + simp only [realG,g,C_eq_beta_square,intervalIntegral.integral_ofReal] + +lemma fixedFamily_central (N : ℕ) (x : ℝ) : + fixedFamily N (centralIndex N) x=cosineKernelJet 0 0 ((angle/2)^2) x := by + rw [fixedFamily,interiorKnot_nodalOrder N _ (by linarith [strip_angle_pos] : 0 cosineKernelJet (nodalOrder (interiorKnotLabels N t) i) 0 + (interiorKnotLabels N t i) := by + funext i + by_cases hi : i=centralIndex N + · subst i + rw [Function.update_self,interiorKnot_nodalOrder N _ ht htL] + simp [centralIndex,interiorKnotLabels] + · rw [Function.update_of_ne hi] + exact fixedFamily_eq_interior_away N ht htL hi + +noncomputable def rowDetLinear {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (i : Fin n) : + (Fin n → ℝ) →ₗ[ℝ] ℝ where + toFun v := (A.updateRow i v).det + map_add' u v := Matrix.det_updateRow_add A i u v + map_smul' s v := by simpa using Matrix.det_updateRow_smul A i s v + +lemma rowDet_integral {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (i : Fin n) + (v : ℝ → Fin n → ℝ) {a b : ℝ} (hv : Continuous v) : + (A.updateRow i (fun j => ∫ t in a..b, v t j)).det = + ∫ t in a..b, (A.updateRow i (v t)).det := by + let L := (rowDetLinear A i).toContinuousLinearMap + have he : (∫ t in a..b, v t) = fun j=>∫ t in a..b, v t j := by + funext j + exact ((ContinuousLinearMap.proj j : (Fin n → ℝ) →L[ℝ] ℝ).intervalIntegral_comp_comm + (hv.intervalIntegrable (μ:=volume) a b)).symm + have h := L.intervalIntegral_comp_comm (hv.intervalIntegrable (μ:=volume) a b) + rw [he] at h + exact h.symm + +lemma evaluationMatrix_update {n : ℕ} (F : Fin n → ℝ → ℝ) (x : Fin n → ℝ) + (i : Fin n) (H : ℝ → ℝ) : + evaluationMatrix (Function.update F i H) x = + (evaluationMatrix F x).updateRow i (fun j=>H (x j)) := by + ext k j + rw [Matrix.updateRow_apply] + change (Function.update F i H k) (x j) = _ + by_cases hk : k=i + · subst k + rw [Function.update_self,ite_eq_left rfl] + · rw [Function.update_of_ne hk,ite_eq_right hk] + rfl + +lemma fixedFamily_positiveEvaluation (N : ℕ) : PositiveEvaluation (fixedFamily N) := by + apply jet_positiveEvaluation + · exact (interiorKnot_monotone N (by linarith [strip_angle_pos] : 0 h) + · intro i + exact interiorKnot_nonneg N i (angle/2) + +lemma mixedFamily_positiveEvaluation (N : ℕ) : PositiveEvaluation (mixedFamily N) := by + intro x hx hx0 + let A := evaluationMatrix (fixedFamily N) x + let v : ℝ → Fin (2*N+1) → ℝ := fun t j=>cosineKernelJet 0 0 (t^2) (x j) + have hv : Continuous v := by + apply continuous_pi + intro j + exact (cosineKernelJet_contDiff_left 0 0 (x j) 0).continuous.comp (by fun_prop) + have hd : Continuous (fun t => (A.updateRow (centralIndex N) (v t)).det) := + ((rowDetLinear A (centralIndex N)).toContinuousLinearMap.continuous).comp hv + have hpos {t : ℝ} (ht : 0cosineKernelJet 0 0 (t^2) (x j))).det + rw [← evaluationMatrix_update,fixedFamily_update_interior N ht htL] + exact jet_positiveEvaluation (interiorKnotLabels N t) + ((interiorKnot_monotone N ht htL).comp (fun _ _ h => h)) + (fun i=>interiorKnot_nonneg N i t) x hx hx0 + have hnonneg : Set.Icc (0:ℝ) angle ⊆ {t | 0 ≤ (A.updateRow (centralIndex N) (v t)).det} := by + rw [← closure_Ioo strip_angle_pos.ne] + apply closure_minimal + · intro t ht + exact (hpos ht.1 ht.2).le + · exact isClosed_le continuous_const hd + change 0<(evaluationMatrix (Function.update (fixedFamily N) (centralIndex N) realG) x).det + rw [evaluationMatrix_update] + change 0<(A.updateRow (centralIndex N) (fun j=>∫ t in (0:ℝ)..angle,v t j)).det + rw [rowDet_integral A (centralIndex N) v hv] + apply intervalIntegral.integral_pos strip_angle_pos hd.continuousOn + · intro t ht + exact hnonneg ⟨ht.1.le,ht.2⟩ + · exact ⟨angle/2,⟨by linarith [strip_angle_pos],by linarith [strip_angle_pos]⟩, + hpos (by linarith [strip_angle_pos]) (by linarith [strip_angle_pos])⟩ + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter Topology + +lemma realG_sq {p : ℝ} (hp : 0Real.cosh (t*p)) by fun_prop).intervalIntegrable 0 angle) + (continuous_const.intervalIntegrable 0 angle) (fun t (ht : t ∈ Set.Icc (0:ℝ) angle) => + Real.cosh_le_cosh.mpr (by + rw [abs_of_nonneg (mul_nonneg ht.1 hp),abs_of_nonneg (mul_nonneg strip_angle_pos.le hp)] + exact mul_le_mul_of_nonneg_right ht.2 hp)) + simpa [mul_comm] using h + +lemma jet_realG_pair_integrable {b : ℝ} (hb0 : 0 ≤ b) (hb : b ≤ (3*angle/2)^2) (r : ℕ) : + IntegrableOn (fun p => cosineKernelJet r 0 b (p^2)*realG (p^2)*stripDensity p) (Set.Ioi 0) := by + have hbase := (strip_jet_pair_integrable hb0 (sq_nonneg angle) hb le_rfl r 0).const_mul angle + have hf : Continuous (fun p : ℝ=>cosineKernelJet r 0 b (p^2)) := + (cosineKernelJet_contDiff_right r 0 b 0).continuous.comp (by fun_prop) + have hg : AEStronglyMeasurable (fun p : ℝ=>realG (p^2)) (volume.restrict (Set.Ioi 0)) := by + apply (show Measurable (fun p : ℝ=>Real.sinh (angle*p)/p) by fun_prop).aestronglyMeasurable.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact (realG_sq hp).symm + apply hbase.mono' + · exact (hf.aestronglyMeasurable.mul hg).mul + (show Measurable stripDensity by unfold stripDensity;fun_prop).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hf0 := cosineKernelJet_nonneg hb0 (sq_nonneg p) r 0 + have hg0 := realG_sq_nonneg hp + have hw0 := (stripDensity_pos hp).le + rw [Real.norm_of_nonneg (by positivity)] + calc + _ ≤ cosineKernelJet r 0 b (p^2)*(angle*cosineKernelJet 0 0 (angle^2) (p^2))*stripDensity p := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (realG_sq_le hp.le) hf0) hw0 + _ = _ := by ring + +lemma fixedFamily_pair_integrable (N : ℕ) (i j : Fin (2*N+1)) : + IntegrableOn (fun p=>fixedFamily N i (p^2)*fixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0) := by + have ht : 0fixedFamily N i (p^2)*mixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0) := by + by_cases hj : j=centralIndex N + · subst j + simp only [mixedFamily,Function.update_self] + apply jet_realG_pair_integrable (interiorKnot_nonneg N i _) + exact (interiorKnot_le N i (by linarith [strip_angle_pos] : 0stripDensity_pos hp) (fixed_mixed_pair_integrable N) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ParameterJets.lean b/lean/OAI/Combinatorics/HoneycombChords/ParameterJets.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a5c05059a880fe65576192bc25738b6f673e451 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ParameterJets.lean @@ -0,0 +1,437 @@ +import OAI.Combinatorics.HoneycombChords.TransformSurjectivity +import OAI.Combinatorics.HoneycombChords.SechResidual + +namespace OAI + +/-! Parameter jet spans and confluent hyperbolic secant coefficients. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional +open Finset Filter Topology +open StripAsymptotic Analytic + +lemma C_eq_beta_square (t x : ℝ) : C t x = (cosineKernelJet 0 0 (t^2) x : ℂ) := by + rw [cosineKernelJet_eq_C (sq_nonneg t),Real.sqrt_sq_eq_abs] + by_cases ht : 0 ≤ t + · rw [abs_of_nonneg ht] + · rw [abs_of_neg (lt_of_not_ge ht)] + unfold C + split_ifs <;> simp only [neg_mul,Real.cosh_neg,Real.cos_neg] + +noncomputable def composeCoeff : ℕ → ℕ → ℝ → ℝ + | 0,0 => 1 + | 0,_+1 => 0 + | n+1,0 => deriv (composeCoeff n 0) + | n+1,k+1 => fun t => deriv (composeCoeff n (k+1)) t + + 2*t*(k+1:ℕ)*composeCoeff n k t + +lemma composeCoeff_smooth (n k : ℕ) : ContDiff ℝ ⊤ (composeCoeff n k) := by + induction n generalizing k with + | zero => cases k <;> exact contDiff_const + | succ n ih => + cases k with + | zero => exact (ih 0).deriv' + | succ k => + exact (ih (k+1)).deriv'.add + (((contDiff_const.mul contDiff_id).mul contDiff_const).mul (ih k)) + +lemma composeCoeff_zero {n k : ℕ} (h : n < k) : composeCoeff n k = 0 := by + induction n generalizing k with + | zero => cases k <;> first | omega | rfl + | succ n ih => + cases k with + | zero => omega + | succ k => + ext t + simp [composeCoeff,ih (show n exact one_ne_zero + | succ n ih => + change deriv (composeCoeff n (n+1)) t + 2*t*(n+1:ℕ)*composeCoeff n n t ≠ 0 + rw [composeCoeff_zero (by omega)] + rw [show deriv (0:ℝ→ℝ) t = 0 from deriv_const t 0,zero_add] + exact mul_ne_zero (mul_ne_zero (mul_ne_zero (by norm_num) ht) + (Nat.cast_ne_zero.mpr (Nat.succ_ne_zero n))) ih + +lemma beta_square_hasDerivAt (k : ℕ) (t x : ℝ) : + HasDerivAt (fun s => (cosineKernelJet k 0 (s^2) x : ℂ)) + ((2*t*(k+1:ℕ)*cosineKernelJet (k+1) 0 (t^2) x : ℝ) : ℂ) t := by + have h := (cosineKernelJet_hasDerivAt_left k 0 (t^2) x).comp t + ((hasDerivAt_id t).pow 2) + convert h.ofReal_comp using 1 <;> try rfl + push_cast + simp only [id_eq,pow_one] + ring + +lemma C_parameter_jet_expansion (n : ℕ) (t x : ℝ) : + iteratedDeriv n (fun s => C s x) t = + ∑ k ∈ range (n+1), (composeCoeff n k t : ℂ) * + (cosineKernelJet k 0 (t^2) x : ℂ) := by + induction n generalizing t with + | zero => simp [composeCoeff,C_eq_beta_square] + | succ n ih => + rw [iteratedDeriv_succ,show iteratedDeriv n (fun s=>C s x) = + (fun t=>∑ k ∈ range (n+1),(composeCoeff n k t:ℂ)*(cosineKernelJet k 0 (t^2) x:ℂ)) + from funext ih] + have hd (k : ℕ) := + (((composeCoeff_smooth n k).differentiable (by simp)).differentiableAt.hasDerivAt.ofReal_comp).mul + (beta_square_hasDerivAt k t x) + have hds := HasDerivAt.fun_sum (fun k (_ : k ∈ range (n+1)) => hd k) + simp only [Pi.mul_apply] at hds + rw [hds.deriv] + let A := fun k => ((deriv (composeCoeff n k) t : ℝ) : ℂ) * (cosineKernelJet k 0 (t^2) x : ℂ) + have hz : A (n+1) = 0 := by simp [A,composeCoeff_zero (show n rw [sum_range_succ'] + rw [add_comm (∑ _ ∈ _, _)] + congr 1 + apply sum_congr rfl + intro k hk + simp only [A,composeCoeff,Complex.ofReal_add,Complex.ofReal_mul] + ring + +lemma parameter_jet_span (t : ℝ) (ht : t ≠ 0) (N : ℕ) : + Submodule.span ℂ ((fun k : ℕ => fun x : ℝ => (cosineKernelJet k 0 (t^2) x : ℂ)) '' Set.Iio N) = + Submodule.span ℂ ((fun k : ℕ => fun x : ℝ => iteratedDeriv k (fun s=>C s x) t) '' Set.Iio N) := by + apply triangular_span _ _ (fun n k => (composeCoeff n k t : ℂ)) + · intro k + ext x + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul] + exact C_parameter_jet_expansion k t x + · intro k + exact Complex.ofReal_ne_zero.mpr (composeCoeff_diagonal ht k) + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Honeycomb370 Matrix Finset MeasureTheory + +lemma A_eq_jet (c m x : ℝ) : A c m x=Real.cos (alpha c*m)*cosineKernelJet 0 0 (m^2) x := by + rw [A,C_eq_beta_square,Complex.ofReal_re] + +lemma A_eq_jet_fun (c m : ℝ) : A c m=fun x ↦ Real.cos (alpha c*m)*cosineKernelJet 0 0 (m^2) x := + funext (A_eq_jet c m) + +lemma cos_alpha_pos {c m : ℝ} (hc : 0 simp + have hinj' : Function.Injective (Fin.lastCases (w c t) (fun j ↦ w c (q j))) := by + intro i j h + simp only [he] at h + apply hinj + exact w_injectiveOn_third hc ⟨(hd' i).1,by dsimp [c]; linarith [(hd' i).2]⟩ + ⟨(hd' j).1,by dsimp [c]; linarith [(hd' j).2]⟩ h + have hbound:=cauchyGram_coefficient_lower N (fun i ↦ w c (q i)) (w c u) (w c t) + (sechProbDensity c) (fun i ↦ A c (b i)) (fun i ↦ A c (d i)) (A c (c/2)) hwq hwu hwt hinj' + (fun i j ↦ A_pair_prob_integrable hc (hpair i j)) + (fun j ↦ A_pair_prob_integrable hc (htarget j)) hGram + (fun i j ↦ by rw [he,he]; exact A_pair_prob_integral hc (hpair i j)) + (fun j ↦ by rw [he]; rw [A_pair_prob_integral hc (htarget j),w_half hc.ne',one_mul]) + (fun i ↦ by rw [he]; exact A_zero hc (by rw [abs_of_nonneg (hb i).1]; dsimp [c]; linarith [(hb i).2])) + (by rw [A_zero hc (by rw [abs_of_pos (half_pos hc)]; linarith),w_half hc.ne']; norm_num) + have heq : meanResidualRatio (sechProbDensity c) (fun i ↦ A c (b i)) (fun i ↦ A c (d i)) (A c (c/2)) 0= + meanResidualRatio (sechProbDensity c) F G H 0 := by + simp_rw [A_eq_jet_fun] + rw [meanResidualRatio_scale_target _ _ _ H _ _ (cos_alpha_pos hc (by rw [abs_of_pos (half_pos hc)]; linarith)).ne'] + exact meanResidualRatio_scalars _ F G H 0 _ _ (fun i ↦ (hpF i).ne') (fun i ↦ (hpG i).ne') hi hH + rw [heq,A_zero hc (by rw [abs_of_pos (half_pos hc)]; linarith),w_half hc.ne'] at hbound + have hs : 0<1/Real.sqrt ((1:ℝ)+1) := by positivity + have hs1 : 1/Real.sqrt ((1:ℝ)+1) ≤ 1 := by + apply (div_le_one (by positivity)).mpr + exact Real.one_le_sqrt.mpr (by norm_num) + have hpos : 0<1/(68*Real.pi*Real.sqrt ((N:ℝ)+1)) := by positivity + have hn : 0 ≤ -meanResidualRatio (sechProbDensity c) F G H 0 := by nlinarith + change _ ≤ -meanResidualRatio (sechProbDensity c) F G H 0 + nlinarith + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory + +lemma sech_approximate_coefficient_lower (N : ℕ) {u t ε : ℝ} + (hu : 0.trans (min_le_left _ _)).trans_lt (by linarith) + have hδt : δ.trans (min_le_right _ _) |>.trans (min_le_left _ _)).trans_lt (by linarith) + have hδt' : δ.trans (min_le_right _ _) |>.trans (min_le_right _ _)).trans_lt (by linarith) + let ε:=fun k : ℕ ↦ δ/((k:ℝ)+1) + have he k : 0<ε k := by dsimp [ε]; positivity + have heδ k : ε k ≤ δ := by + dsimp [ε] + apply (div_le_iff₀ (by positivity : 0<(k:ℝ)+1)).mpr + nlinarith [Nat.cast_nonneg (α:=ℝ) k] + have heu k : ε k omega + intro v hv + have hvnot : v ∉ p.support := by + intro hvp + obtain ⟨w, hw⟩ := hv + have h := path_neighbor_eq G hab ha hb upper p hp hvp + simp only [SimpleGraph.mem_neighborSet, SimpleGraph.sdiff_adj, + SimpleGraph.Subgraph.spanningCoe_adj] at hw + apply hw.2 + change w ∈ p.toSubgraph.neighborSet v + rw [h] + exact hw.1 + have heq : (G \ p.toSubgraph.spanningCoe).neighborSet v = G.neighborSet v := by + ext w + simp only [SimpleGraph.mem_neighborSet, SimpleGraph.sdiff_adj, + SimpleGraph.Subgraph.spanningCoe_adj] + constructor + · exact And.left + · intro hw + refine ⟨hw, ?_⟩ + intro hf + exact hvnot (p.mem_verts_toSubgraph.mp (p.toSubgraph.edge_vert hf)) + rw [heq, ncard_neighbors] + have hva : v ≠ a := by intro e; subst v; exact hvnot p.start_mem_support + have hvb : v ≠ b := by intro e; subst v; exact hvnot p.end_mem_support + rcases other v hva hvb with h | h + · rw [heq] at hv + have hn := hv.ncard_pos (Set.toFinite _) + rw [ncard_neighbors, h] at hn + omega + · exact h + +/-- Every finite nonbranching two-port configuration is a path plus cycles. The +path has no edge to the residual cycle graph. -/ +theorem path_and_cycles {a b : V} (hab : a ≠ b) + (ha : G.degree a = 1) (hb : G.degree b = 1) + (other : ∀ v, v ≠ a → v ≠ b → G.degree v = 0 ∨ G.degree v = 2) : + ∃ p : G.Walk a b, p.IsPath ∧ (G \ p.toSubgraph.spanningCoe).IsCycles ∧ + ∀ v ∈ p.support, p.toSubgraph.neighborSet v = G.neighborSet v := by + have upper (v : V) : G.degree v ≤ 2 := by + by_cases h : v = a + · subst v; rw [ha]; decide + by_cases h' : v = b + · subst v; rw [hb]; decide + rcases other v h h' with h | h <;> omega + have hr := ports_reachable G ha (fun v h h' => by + rcases other v h h' with e | e <;> rw [e] <;> decide) + obtain ⟨p, hp⟩ := hr.exists_isPath + exact ⟨p, hp, residual_isCycles G hab ha hb other p hp, + fun v hv => path_neighbor_eq G hab ha hb upper p hp hv⟩ +end CriticalHoneycomb.Transfer.PathComponents + +namespace CriticalHoneycomb.Transfer.FiniteConfigurations +open SimpleGraph +variable {α : Type*} + +/-- The hard-wall two-port graph: the two exterior markers have only their +prescribed incident edge; internal adjacency remains unchanged. -/ +def portRel (R : α → α → Prop) (a b : α) : (α ⊕ Bool) → (α ⊕ Bool) → Prop + | .inl x, .inl y => R x y + | .inr false, .inl y | .inl y, .inr false => y=a + | .inr true, .inl y | .inl y, .inr true => y=b + | .inr _, .inr _ => False + +lemma chain_snoc_ports (R : α → α → Prop) (a b : α) (xs : List α) : + (xs.map Sum.inl ++ [Sum.inr true]).IsChain (portRel R a b) ↔ + xs.IsChain R ∧ ∀ z ∈ xs.getLast?, z=b := by + rw [List.isChain_append,List.isChain_map] + simp [portRel,List.getLast?_map] + +lemma chain_ports (R : α → α → Prop) (a b : α) (xs : List α) : + (Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true])).IsChain (portRel R a b) ↔ + xs.IsChain R ∧ xs.head?=some a ∧ xs.getLast?=some b := by + cases xs with + | nil => simp [portRel] + | cons x xs => + rw [List.isChain_cons,chain_snoc_ports] + have hh : (∀ y ∈ ((x::xs).map Sum.inl ++ [Sum.inr true]).head?, + portRel R a b (.inr false) y) ↔ x=a := by + simp [portRel] + have hl : (∀ z ∈ (x::xs).getLast?, z=b) ↔ (x::xs).getLast?=some b := by + rw [List.getLast?_eq_some_getLast (by simp)] + simp + rw [hh,hl] + simp only [List.head?_cons,Option.some.injEq] + tauto + +lemma list_all_inl (l : List (α ⊕ Bool)) + (h : ∀ t ∈ l, ∀ b : Bool, t ≠ Sum.inr b) : + ∃ xs : List α, xs.map Sum.inl=l := by + induction l with + | nil => exact ⟨[],rfl⟩ + | cons t l ih => + cases t with + | inr b => exact (h _ (by simp) b rfl).elim + | inl x => + obtain ⟨xs,hxs⟩ := ih (by aesop) + exact ⟨x::xs,by simp [hxs]⟩ + +lemma support_decomposition {G : SimpleGraph (α ⊕ Bool)} + (p : G.Walk (.inr false) (.inr true)) (hp : p.IsPath) : + ∃ xs : List α, p.support = Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true]) ∧ xs.Nodup := by + have hs := p.cons_tail_support.symm + have hn := hp.support_nodup + rw [hs] at hn + obtain ⟨hna,hnt⟩ := List.nodup_cons.mp hn + have ht : p.support.tail.getLast? = some (.inr true) := by + have hl : p.support.getLast? = some (.inr true) := by + rw [List.getLast?_eq_some_getLast (by simp),p.getLast_support] + cases h : p.support.tail with + | nil => + have he := congrArg List.getLast? hs + simp [h,hl] at he + | cons t ts => + have he := congrArg List.getLast? hs + simpa [h,hl] using he.symm + obtain ⟨mid,hmid⟩ := List.getLast?_eq_some_iff.mp ht + rw [hmid] at hna hnt + obtain ⟨hnm,_,hd⟩ := List.nodup_append.mp hnt + obtain ⟨xs,hxs⟩ := list_all_inl mid (by + intro t ht b he + cases b + · subst t + exact hna (by simp [ht]) + · exact hd t ht (.inr true) (by simp) he) + refine ⟨xs,?_,?_⟩ + · simpa [hmid,←hxs] using hs + · exact List.Nodup.of_map Sum.inl (hxs.symm ▸ hnm) + +end CriticalHoneycomb.Transfer.FiniteConfigurations + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PhysicalFactors.lean b/lean/OAI/Combinatorics/HoneycombChords/PhysicalFactors.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c6c93c30bf4b312c0f629eebc0967ff7e4979c0 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PhysicalFactors.lean @@ -0,0 +1,516 @@ +import OAI.Combinatorics.HoneycombChords.SparseInterpolation + +namespace OAI + +/-! Physical pole factors and positive mixtures of interpolation kernels. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + +namespace CriticalHoneycomb.FiniteFunctional +open Finset + +lemma physicalPole_strictMono : StrictMono physicalPole := by + intro m n hmn + have hm : (0:ℝ) ≤ m := Nat.cast_nonneg m + have hn : (m:ℝ) < n := by exact_mod_cast hmn + unfold physicalPole + nlinarith + +noncomputable def poleTailRatio (u : ℝ) (n : ℕ) : ℝ := + (physicalPole n-u)/(physicalPole n-physicalPole 0) + +lemma poleTailRatio_ge_one {u : ℝ} (hu : u ≤ 4) {n : ℕ} (hn : 1 ≤ n) : + 1 ≤ poleTailRatio u n := by + have hd : 0 < physicalPole n-physicalPole 0 := sub_pos.mpr (physicalPole_strictMono (by omega)) + apply (le_div_iff₀ hd).mpr + have h0 : (4:ℝ) < physicalPole 0 := by norm_num [physicalPole] + linarith + +lemma poleTailRatio_le {u : ℝ} (hu : 0 ≤ u) {n : ℕ} (hn : 1 ≤ n) : + poleTailRatio u n ≤ ((n:ℝ)+1)^2/((n:ℝ)*((n:ℝ)+2)) := by + have hnp : (0:ℝ) < n := by exact_mod_cast (show 0 norm_num + | succ m ih => + rw [prod_range_succ] + have hpos : 0 ≤ poleTailRatio u (m+1) := le_trans zero_le_one (poleTailRatio_ge_one hu4 (by omega)) + have hh := mul_le_mul ih (poleTailRatio_le hu (by omega : 1 ≤ m+1)) hpos (by positivity) + apply hh.trans_eq + push_cast + field_simp + ring + +lemma poleTailProduct_uniform {u : ℝ} (hu : 0 ≤ u) (hu4 : u ≤ 4) (m : ℕ) : + (∏ j ∈ range m,poleTailRatio u (j+1)) ≤ 2 := by + apply (poleTailProduct_le hu hu4 m).trans + apply (div_le_iff₀ (by positivity)).mpr + linarith [Nat.cast_nonneg (α:=ℝ) m] + +lemma poleTailSubset_uniform {u : ℝ} (hu : 0 ≤ u) (hu4 : u ≤ 4) + (s : Finset ℕ) (m : ℕ) (hs : ∀ j ∈ s,j < m) : + (∏ j ∈ s,poleTailRatio u (j+1)) ≤ 2 := by + have hsub : s ⊆ range m := fun j hj => mem_range.mpr (hs j hj) + apply (prod_le_prod_of_subset_of_one_le₀ hsub + (fun j _ => le_trans zero_le_one (poleTailRatio_ge_one hu4 (by omega))) + (fun j _ _ => poleTailRatio_ge_one hu4 (by omega))).trans + exact poleTailProduct_uniform hu hu4 m + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset +namespace ReciprocalExpr + +noncomputable def rangeProduct (f : ℕ → ReciprocalExpr) : ℕ → ReciprocalExpr + | 0 => const 1 + | n+1 => mulExpr (rangeProduct f n) (f n) + +lemma rangeProduct_eval (f : ℕ → ReciprocalExpr) (n : ℕ) (x : ℝ) : + (rangeProduct f n).eval x = ∏ i ∈ range n,(f i).eval x := by + induction n with + | zero => simp [rangeProduct,eval] + | succ n ih => simp [rangeProduct,mulExpr_eval,prod_range_succ,ih] +lemma rangeProduct_poles {f : ℕ → ReciprocalExpr} {L : ℝ} (n : ℕ) + (h : ∀ i < n,(f i).PolesAbove L) : (rangeProduct f n).PolesAbove L := by + induction n with + | zero => trivial + | succ n ih => exact mulExpr_poles (ih (fun i hi => h i (by omega))) (h n (by omega)) +lemma rangeProduct_coeff {f : ℕ → ReciprocalExpr} (n : ℕ) + (h : ∀ i < n,(f i).CoeffNonneg) : (rangeProduct f n).CoeffNonneg := by + induction n with + | zero => exact zero_le_one + | succ n ih => exact mulExpr_coeff (ih (fun i hi => h i (by omega))) (h n (by omega)) + +noncomputable def tripleWeight (a b c : ℝ) : ℝ := c*(b-a)/(b*(c-a)) +noncomputable def tripleFactor (a b c : ℝ) : ReciprocalExpr := + add (scale (tripleWeight a b c) (normalizedPole a)) + (scale (1-tripleWeight a b c) (normalizedPole c)) + +lemma tripleWeight_pos {a b c : ℝ} (ha : 0 < a) (hab : a < b) (hbc : b < c) : + 0 < tripleWeight a b c := by + exact div_pos (mul_pos (by linarith) (sub_pos.mpr hab)) + (mul_pos (by linarith) (sub_pos.mpr (hab.trans hbc))) +lemma tripleWeight_lt_one {a b c : ℝ} (ha : 0 < a) (hab : a < b) (hbc : b < c) : + tripleWeight a b c < 1 := by + unfold tripleWeight + apply (div_lt_one (mul_pos (by linarith) (by linarith))).mpr + nlinarith +lemma tripleFactor_coeff {a b c : ℝ} (ha : 0 < a) (hab : a < b) (hbc : b < c) : + (tripleFactor a b c).CoeffNonneg := + ⟨⟨(tripleWeight_pos ha hab hbc).le,normalizedPole_coeff ha.le⟩, + ⟨(sub_pos.mpr (tripleWeight_lt_one ha hab hbc)).le,normalizedPole_coeff (by linarith)⟩⟩ +lemma tripleFactor_poles {a b c L : ℝ} (hL : L < a) (hac : a < c) : + (tripleFactor a b c).PolesAbove L := + ⟨normalizedPole_poles hL,normalizedPole_poles (hL.trans hac)⟩ +lemma tripleFactor_eval {a b c x : ℝ} + (ha : 0 < a) (hab : a < b) (hbc : b < c) + (hax : a+x ≠ 0) (hcx : c+x ≠ 0) : + (tripleFactor a b c).eval x = (1+x/b)*(a/(a+x))*(c/(c+x)) := by + simp only [tripleFactor,eval,normalizedPole_eval,tripleWeight] + have hb : b ≠ 0 := ne_of_gt (ha.trans hab) + have hca : c-a ≠ 0 := sub_ne_zero.mpr (ne_of_gt (hab.trans hbc)) + field_simp + ring +lemma normalizedPole_zero {a : ℝ} (ha : 0 < a) : + (normalizedPole a).eval 0=1 := by rw [normalizedPole_eval,add_zero,div_self ha.ne'] +lemma tripleFactor_zero {a b c : ℝ} (ha : 0 < a) (hab : a < b) (hbc : b < c) : + (tripleFactor a b c).eval 0=1 := by + simp only [tripleFactor,eval,normalizedPole_zero ha,normalizedPole_zero (ha.trans (hab.trans hbc))] + ring + +end ReciprocalExpr + +noncomputable def shiftedPole (u : ℝ) (n : ℕ) := physicalPole n-u +lemma shiftedPole_pos {u : ℝ} (hu : u ≤ 4) (n : ℕ) : 0 < shiftedPole u n := by + unfold shiftedPole + linarith [physicalPole_ge n] +lemma shiftedPole_strictMono (u : ℝ) : StrictMono (shiftedPole u) := + fun _ _ h => sub_lt_sub_right (physicalPole_strictMono h) u + +noncomputable def physicalPairExpr (u : ℝ) (n : ℕ) : ReciprocalExpr := + ReciprocalExpr.mulExpr (ReciprocalExpr.normalizedPole (shiftedPole u (3*n))) + (ReciprocalExpr.normalizedPole (shiftedPole u (3*n+2))) +noncomputable def physicalTripleExpr (u : ℝ) (n : ℕ) : ReciprocalExpr := + ReciprocalExpr.tripleFactor (shiftedPole u (3*n)) (shiftedPole u (3*n+1)) (shiftedPole u (3*n+2)) + +lemma physicalTripleExpr_poles {u : ℝ} (n : ℕ) : + (physicalTripleExpr u (n+1)).PolesAbove (shiftedPole u 0) := by + apply ReciprocalExpr.tripleFactor_poles + · exact shiftedPole_strictMono u (by omega) + · exact shiftedPole_strictMono u (by omega) +lemma physicalTripleExpr_coeff {u : ℝ} (hu : u ≤ 4) (n : ℕ) : + (physicalTripleExpr u n).CoeffNonneg := + ReciprocalExpr.tripleFactor_coeff (shiftedPole_pos hu _) + (shiftedPole_strictMono u (by omega)) (shiftedPole_strictMono u (by omega)) +lemma physicalTripleExpr_zero {u : ℝ} (hu : u ≤ 4) (n : ℕ) : + (physicalTripleExpr u n).eval 0=1 := + ReciprocalExpr.tripleFactor_zero (shiftedPole_pos hu _) + (shiftedPole_strictMono u (by omega)) (shiftedPole_strictMono u (by omega)) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset + +lemma slowPole_eval {u : ℝ} (n : ℕ) : + (ReciprocalExpr.normalizedPole (shiftedPole u n)).eval (-shiftedPole u 0)=poleTailRatio u n := by + rw [ReciprocalExpr.normalizedPole_eval] + simp only [shiftedPole,poleTailRatio] + congr 1 + ring + +lemma tripleFactor_le_pair {a b c x : ℝ} (ha : 0 < a) (hab : a < b) (hbc : b < c) + (hx : -a < x) (hx0 : x ≤ 0) : + (ReciprocalExpr.tripleFactor a b c).eval x ≤ (a/(a+x))*(c/(c+x)) := by + rw [ReciprocalExpr.tripleFactor_eval ha hab hbc (by linarith) (by linarith)] + have hp : 0 ≤ (a/(a+x))*(c/(c+x)) := mul_nonneg (div_nonneg ha.le (by linarith)) (div_nonneg (by linarith) (by linarith)) + have h : 1+x/b ≤ 1 := by apply add_le_of_nonpos_right;exact div_nonpos_of_nonpos_of_nonneg hx0 (by linarith) + nlinarith [mul_le_mul_of_nonneg_right h hp] + +lemma tailScalar_majorant {u : ℝ} (hu4 : u ≤ 4) (f : ℕ → ℝ) + (hf : ∀ j,0 ≤ f j) (hbound : ∀ j,f j ≤ poleTailRatio u (3*j+3)*poleTailRatio u (3*j+5)) (m : ℕ) : + poleTailRatio u 2*(∏ j ∈ range m,f j) ≤ ∏ j ∈ range (3*m+2),poleTailRatio u (j+1) := by + have hR (j : ℕ) : 1 ≤ poleTailRatio u (j+1) := poleTailRatio_ge_one hu4 (by omega) + induction m with + | zero => + simp only [mul_zero,zero_add,prod_range_zero,mul_one] + norm_num [prod_range_succ,prod_range_zero] + nlinarith [hR 0,hR 1] + | succ m ih => + rw [prod_range_succ,mul_left_comm] -- put old product together below + have hh := mul_le_mul ih (hbound m) (hf m) + (prod_nonneg (fun j hj=>le_trans zero_le_one (hR j))) + have hmid : 1 ≤ poleTailRatio u (3*m+4) := by simpa using hR (3*m+3) + have hr1 : 0 ≤ poleTailRatio u (3*m+3) := by exact le_trans zero_le_one (poleTailRatio_ge_one hu4 (by omega)) + have hr2 : 0 ≤ poleTailRatio u (3*m+5) := by exact le_trans zero_le_one (poleTailRatio_ge_one hu4 (by omega)) + have hp : 0 ≤ ∏ j ∈ range (3*m+2),poleTailRatio u (j+1) := prod_nonneg (fun j hj=>le_trans zero_le_one (hR j)) + have ht := mul_le_mul_of_nonneg_left hmid (mul_nonneg hp (mul_nonneg hr1 hr2)) + rw [show 3*(m+1)+2=(3*m+2)+1+1+1 by omega,prod_range_succ,prod_range_succ,prod_range_succ] + simpa only [Nat.add_assoc] using (show + (∏ j ∈ range m,f j)*(poleTailRatio u 2*f m) ≤ + (((∏ j ∈ range (3*m+2),poleTailRatio u (j+1))*poleTailRatio u (3*m+3))*poleTailRatio u (3*m+4))*poleTailRatio u (3*m+5) by + nlinarith [hh,ht]) + +lemma tailScalar_uniform {u : ℝ} (hu : 0 ≤ u) (hu4 : u ≤ 4) (f : ℕ → ℝ) + (hf : ∀ j,0 ≤ f j) (hbound : ∀ j,f j ≤ poleTailRatio u (3*j+3)*poleTailRatio u (3*j+5)) (m : ℕ) : + poleTailRatio u 2*(∏ j ∈ range m,f j) ≤ 2 := + (tailScalar_majorant hu4 f hf hbound m).trans (poleTailProduct_uniform hu hu4 (3*m+2)) + +noncomputable def physicalPairTail (u : ℝ) (m : ℕ) : ReciprocalExpr := + ReciprocalExpr.rangeProduct (fun j=>physicalPairExpr u (j+1)) m +noncomputable def physicalTripleTail (u : ℝ) (m : ℕ) : ReciprocalExpr := + ReciprocalExpr.rangeProduct (fun j=>physicalTripleExpr u (j+1)) m + +lemma physicalPairExpr_poles (u : ℝ) (n : ℕ) : + (physicalPairExpr u (n+1)).PolesAbove (shiftedPole u 0) := by + apply ReciprocalExpr.mulExpr_poles + · exact ReciprocalExpr.normalizedPole_poles (shiftedPole_strictMono u (by omega)) + · exact ReciprocalExpr.normalizedPole_poles (shiftedPole_strictMono u (by omega)) +lemma physicalPairExpr_coeff {u : ℝ} (hu4 : u ≤ 4) (n : ℕ) : + (physicalPairExpr u n).CoeffNonneg := ReciprocalExpr.mulExpr_coeff + (ReciprocalExpr.normalizedPole_coeff (shiftedPole_pos hu4 _).le) + (ReciprocalExpr.normalizedPole_coeff (shiftedPole_pos hu4 _).le) +lemma physicalPairExpr_zero {u : ℝ} (hu4 : u ≤ 4) (n : ℕ) : + (physicalPairExpr u n).eval 0=1 := by + rw [physicalPairExpr,ReciprocalExpr.mulExpr_eval,ReciprocalExpr.normalizedPole_zero (shiftedPole_pos hu4 _), + ReciprocalExpr.normalizedPole_zero (shiftedPole_pos hu4 _),mul_one] +lemma physicalPairTail_poles (u : ℝ) (m : ℕ) : (physicalPairTail u m).PolesAbove (shiftedPole u 0) := + ReciprocalExpr.rangeProduct_poles m (fun j _=>physicalPairExpr_poles u j) +lemma physicalTripleTail_poles (u : ℝ) (m : ℕ) : (physicalTripleTail u m).PolesAbove (shiftedPole u 0) := + ReciprocalExpr.rangeProduct_poles m (fun j _=>physicalTripleExpr_poles j) +lemma physicalPairTail_coeff {u : ℝ} (hu4 : u ≤ 4) (m : ℕ) : (physicalPairTail u m).CoeffNonneg := + ReciprocalExpr.rangeProduct_coeff m (fun _ _=>physicalPairExpr_coeff hu4 _) +lemma physicalTripleTail_coeff {u : ℝ} (hu4 : u ≤ 4) (m : ℕ) : (physicalTripleTail u m).CoeffNonneg := + ReciprocalExpr.rangeProduct_coeff m (fun _ _=>physicalTripleExpr_coeff hu4 _) +lemma physicalPairTail_zero {u : ℝ} (hu4 : u ≤ 4) (m : ℕ) : (physicalPairTail u m).eval 0=1 := by + simp [physicalPairTail,ReciprocalExpr.rangeProduct_eval,physicalPairExpr_zero hu4] +lemma physicalTripleTail_zero {u : ℝ} (hu4 : u ≤ 4) (m : ℕ) : (physicalTripleTail u m).eval 0=1 := by + simp [physicalTripleTail,ReciprocalExpr.rangeProduct_eval,physicalTripleExpr_zero hu4] + +lemma physicalPairTail_uniform {u : ℝ} (hu : 0 ≤ u) (hu4 : u ≤ 4) (m : ℕ) : + poleTailRatio u 2*(physicalPairTail u m).eval (-shiftedPole u 0) ≤ 2 := by + unfold physicalPairTail + rw [ReciprocalExpr.rangeProduct_eval] + apply tailScalar_uniform hu hu4 + · intro j + exact ReciprocalExpr.eval_nonneg (physicalPairExpr_poles u j) (physicalPairExpr_coeff hu4 _) le_rfl + · intro j + simp only [physicalPairExpr,ReciprocalExpr.mulExpr_eval,slowPole_eval] + rw [show 3*(j+1)+2=3*j+5 by omega,show 3*(j+1)=3*j+3 by omega] + +lemma physicalTripleTail_uniform {u : ℝ} (hu : 0 ≤ u) (hu4 : u ≤ 4) (m : ℕ) : + poleTailRatio u 2*(physicalTripleTail u m).eval (-shiftedPole u 0) ≤ 2 := by + unfold physicalTripleTail + rw [ReciprocalExpr.rangeProduct_eval] + apply tailScalar_uniform hu hu4 + · intro j + exact ReciprocalExpr.eval_nonneg (physicalTripleExpr_poles j) (physicalTripleExpr_coeff hu4 _) le_rfl + · intro j + have h := tripleFactor_le_pair (shiftedPole_pos hu4 (3*(j+1))) + (shiftedPole_strictMono u (by omega : 3*(j+1)<3*(j+1)+1)) + (shiftedPole_strictMono u (by omega : 3*(j+1)+1<3*(j+1)+2)) + (neg_lt_neg (shiftedPole_strictMono u (by omega : 0<3*(j+1)))) + (neg_nonpos.mpr (shiftedPole_pos hu4 0).le) + change (physicalTripleExpr u (j+1)).eval (-shiftedPole u 0) ≤ _ at h + have h1 := slowPole_eval (u:=u) (3*(j+1)) + have h2 := slowPole_eval (u:=u) (3*(j+1)+2) + rw [ReciprocalExpr.normalizedPole_eval] at h1 h2 + rw [h1,h2,show 3*(j+1)+2=3*j+5 by omega,show 3*(j+1)=3*j+3 by omega] at h + exact h + +lemma physical_first_weight_half {u : ℝ} (hu : 0 ≤ u) (hu4 : u ≤ 4) : + (1/2:ℝ) ≤ ReciprocalExpr.tripleWeight (shiftedPole u 0) (shiftedPole u 1) (shiftedPole u 2) := by + unfold ReciprocalExpr.tripleWeight shiftedPole physicalPole + norm_num + apply (le_div_iff₀ (by nlinarith : 0 < (64-u)*(512/3))).mpr + nlinarith + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset + +noncomputable def originPowerData {n : ℕ} (v : ℕ → ℝ) (g : ℝ → ℝ) + (k : ℕ) (j : Fin (n+1)) : ℝ := if k=0 then g (v j) else (v j)^k +noncomputable def coefficientMinor {n : ℕ} (C : Fin (n+1) → ℕ → ℝ) + (e : Fin (n+1) → ℕ) : ℝ := Matrix.det (fun i j => C j (e i)) + +lemma increasing_zero_sparse {n : ℕ} {d : Fin (n+1) → ℕ} + (hd : StrictMono d) (h0 : d 0=0) : + ∃ e : Fin n → ℕ,StrictMono e ∧ d=sparseExponent e := by + let e : Fin n → ℕ := fun i=>d i.succ-1 + have hp (i : Fin n) : 0?_) i + · simpa [sparseExponent] using h0 + · simp only [sparseExponent,Fin.cons_succ,e] + have hi := hp i + omega + +lemma originPowerData_sparse {n : ℕ} (v : ℕ → ℝ) (g : ℝ → ℝ) (e : Fin n → ℕ) : + (fun i j : Fin (n+1)=>originPowerData v g (sparseExponent e i) j)= + Fin.cases (fun j=>g (v j)) (fun i j=>(v j)^(e i+1)) := by + ext i j + refine Fin.cases ?_ (fun i=>?_) i <;> simp [originPowerData,sparseExponent] + +lemma originPowerData_sparse_det {n : ℕ} (v : ℕ → ℝ) (g : ℝ → ℝ) (e : Fin n → ℕ) + (hv : ∀ i : Fin (n+1),0v i)) + (he : StrictMono e) : + Matrix.det (fun i j : Fin (n+1)=>originPowerData v g (sparseExponent e i) j)= + (sparseMatrix v e).det*sparseEval v e g := by + rw [originPowerData_sparse] + unfold sparseEval + rw [sparseWeight_eval] + field_simp [(sparseMatrix_det_pos hv hord he).ne'] + +lemma coefficient_power_pair_permute {n : ℕ} (C : Fin (n+1) → ℕ → ℝ) + (v : ℕ → ℝ) (g : ℝ → ℝ) (d : Fin (n+1) → ℕ) (σ : Equiv.Perm (Fin (n+1))) : + coefficientMinor C (d∘σ)*Matrix.det (fun i j=>originPowerData v g ((d∘σ) i) j)= + coefficientMinor C d*Matrix.det (fun i j=>originPowerData v g (d i) j) := by + let A : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := fun i j=>C j (d i) + let B : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := fun i j=>originPowerData v g (d i) j + change (A.submatrix σ id).det*(B.submatrix σ id).det=A.det*B.det + rw [Matrix.det_permute,Matrix.det_permute] + have hs : (((Equiv.Perm.sign σ:ℤ):ℝ))^2=1 := by + rcases Int.units_eq_one_or (Equiv.Perm.sign σ) with h|h <;> simp [h] + calc + _=(((Equiv.Perm.sign σ:ℤ):ℝ))^2*(A.det*B.det) := by ring + _=A.det*B.det := by rw [hs,one_mul] + + +lemma positive_mixture_finite_bounds {n m q : ℕ} + (C : Fin (n+1) → ℕ → ℝ) (v : ℕ → ℝ) (g : ℝ → ℝ) + (hv : ∀ i : Fin (n+1),0v i)) + (hc : ∀ d : Fin (n+1) → ℕ,StrictMono d → 0≤coefficientMinor C d) + (hz : ∀ d : Fin (n+1) → ℕ,StrictMono d → + (∃ k,k≤q ∧ ∀ i,d i≠k) → coefficientMinor C d=0) + {L U : ℝ} + (hbound : ∀ e : Fin n → ℕ,StrictMono e → + (∀ k,1≤k → k≤q → ∃ i,e i+1=k) → L ≤ sparseEval v e g ∧ sparseEval v e g ≤ U) : + let A : Matrix (Fin (n+1)) (Fin m) ℝ := fun i k=>C i k + let B : Matrix (Fin m) (Fin (n+1)) ℝ := fun k j=>(v j)^k.val + let D : Matrix (Fin m) (Fin (n+1)) ℝ := fun k j=>originPowerData v g k j + L*(A*B).det≤(A*D).det ∧ (A*D).det≤U*(A*B).det := by + classical + dsimp only + let A : Matrix (Fin (n+1)) (Fin m) ℝ := fun i k=>C i k + let B : Matrix (Fin m) (Fin (n+1)) ℝ := fun k j=>(v j)^k.val + let D : Matrix (Fin m) (Fin (n+1)) ℝ := fun k j=>originPowerData v g k j + have hminor (f : Fin (n+1) → Fin m) : (A.submatrix id f).det=coefficientMinor C (fun i=>(f i).val) := by + rw [←Matrix.det_transpose] + rfl + have hterm (e : Fin (n+1) → ℕ) : + L*(coefficientMinor C e*Matrix.det (fun i j=>originPowerData v (fun _=>1) (e i) j))≤ + coefficientMinor C e*Matrix.det (fun i j=>originPowerData v g (e i) j) ∧ + coefficientMinor C e*Matrix.det (fun i j=>originPowerData v g (e i) j)≤ + U*(coefficientMinor C e*Matrix.det (fun i j=>originPowerData v (fun _=>1) (e i) j)) := by + by_cases hi : Function.Injective e + · obtain ⟨d,σ,hd,rfl⟩ := sorted_injective_exponents hi + rw [coefficient_power_pair_permute,coefficient_power_pair_permute] + by_cases hz' : ∃ k,k≤q ∧ ∀ i,d i≠k + · rw [hz d hd hz'] + simp + · push Not at hz' + obtain ⟨i,hi⟩ := hz' 0 (Nat.zero_le q) + have h0 : d 0=0 := by + have hle := hd.monotone (Fin.zero_le i) + omega + obtain ⟨f,hf,rfl⟩ := increasing_zero_sparse hd h0 + have hq : ∀ k,1≤k → k≤q → ∃ i,f i+1=k := by + intro k hk hkq + obtain ⟨i,hi⟩ := hz' k hkq + refine Fin.cases ?_ (fun j=>?_) i hi + · simp [sparseExponent] at * + omega + · intro hi + exact ⟨j,by simpa [sparseExponent] using hi⟩ + rw [originPowerData_sparse_det v _ f hv hord hf,originPowerData_sparse_det v _ f hv hord hf] + have hs : sparseEval v f (fun _=>1)=1 := by + simpa [sparseEval] using sparseWeight_sum hv hord hf + rw [hs,mul_one] + have hm := mul_nonneg (hc _ hd) (sparseMatrix_det_pos hv hord hf).le + have hb := hbound f hf hq + constructor <;> nlinarith only [mul_nonneg hm (sub_nonneg.mpr hb.1),mul_nonneg hm (sub_nonneg.mpr hb.2)] + · have hh : coefficientMinor C e=0 := by + obtain ⟨i,j,heq,hij⟩ := Function.not_injective_iff.mp hi + apply Matrix.det_zero_of_row_eq hij + funext k + + rw [heq] + rw [hh] + simp + have hb (f : Fin (n+1) → Fin m) : + L*((A.submatrix id f).det*(B.submatrix f id).det)≤ + (A.submatrix id f).det*(D.submatrix f id).det ∧ + (A.submatrix id f).det*(D.submatrix f id).det≤ + U*((A.submatrix id f).det*(B.submatrix f id).det) := by + have h := hterm (fun i=>(f i).val) + rw [hminor] + have he : B.submatrix f id = (fun i j=>originPowerData v (fun _=>1) ((f i).val) j) := by + ext i j + change (v j)^(f i).val = if (f i).val=0 then 1 else (v j)^(f i).val + split_ifs with h <;> simp [h] + rw [he] + exact h + have hL := sum_le_sum (fun f (_ : f∈univ)=> (hb f).1) + have hU := sum_le_sum (fun f (_ : f∈univ)=> (hb f).2) + rw [←mul_sum,det_rectangular_binet,det_rectangular_binet] at hL hU + have hp : (0:ℝ)cosineKernelJet 0 0 (b^2) (p^2))=(fun b=>Real.cosh (b*p)) := funext (fun b=>cosineKernelJet_square_cosh b p) + have h' : HasDerivAt (fun b=>cosineKernelJet 0 0 (b^2) (p^2)) + (((0+1:ℝ)*cosineKernelJet (0+1) 0 (m^2) (p^2))*(2*m)) m := by convert! h using 1 ; simp only [id_eq,pow_one,Nat.cast_ofNat,mul_one,Nat.cast_zero,zero_add,show 2-1=1 by omega] + rw [he] at h' + have hc : HasDerivAt (fun b=>Real.cosh (b*p)) (Real.sinh (m*p)*p) m := by + convert! ((Real.hasDerivAt_cosh (m*p)).comp m ((hasDerivAt_id m).mul_const p)) using 1 ; simp only [one_mul] + have hd:=h'.unique hc + simp only [zero_add,one_mul] at hd + nlinarith only [hd] +lemma cosineKernelJet_ode_zero {b : ℝ} (hb : 02*s*cosineKernelJet 1 0 (s^2) (p^2)) + (2*cosineKernelJet 1 0 (m^2) (p^2)+8*m^2*cosineKernelJet 2 0 (m^2) (p^2)) m := by + convert! (((hasDerivAt_id m).const_mul 2).mul hJ) using 1 ; simp only [Function.comp_def,Pi.pow_apply,id_eq,pow_one,Nat.cast_ofNat,mul_one,show 2-1=1 by omega] ; ring + have he : (fun s=>2*s*cosineKernelJet 1 0 (s^2) (p^2))=(fun s=>p*Real.sinh (s*p)) := + funext (fun s=>cosineKernelJet_first_square s p) + rw [he] at h + have hs : HasDerivAt (fun s=>p*Real.sinh (s*p)) (p*(Real.cosh (m*p)*p)) m := by + convert! (((Real.hasDerivAt_sinh (m*p)).comp m ((hasDerivAt_id m).mul_const p)).const_mul p) using 1 ; simp only [one_mul] + have hd:=h.unique hs + rw [←cosineKernelJet_square_cosh m p,hm] at hd + nlinarith only [hd] +lemma cosineKernelJet_ode (r : ℕ) {b : ℝ} (hb : 0 + norm_num + nlinarith only [cosineKernelJet_ode_zero hb p] + | succ r ih => + have hL := (cosineKernelJet_hasDerivAt_left r 0 b (p^2)).const_mul (p^2) + have hR := ((((hasDerivAt_id b).const_mul 4).mul_const ((r:ℝ)+1)).mul_const ((r:ℝ)+2)).mul + (cosineKernelJet_hasDerivAt_left (r+2) 0 b (p^2)) |>.add + ((cosineKernelJet_hasDerivAt_left (r+1) 0 b (p^2)).const_mul (2*((r:ℝ)+1)*(2*(r:ℝ)+1))) + have hev : (fun s=>p^2*cosineKernelJet r 0 s (p^2)) =ᶠ[𝓝 b] + (fun s=>4*s*((r:ℝ)+1)*((r:ℝ)+2)*cosineKernelJet (r+2) 0 s (p^2)+ + (2*((r:ℝ)+1)*(2*(r:ℝ)+1))*cosineKernelJet (r+1) 0 s (p^2)) := by + filter_upwards [eventually_gt_nhds hb] with s hs + exact ih hs + have hd := (hL.congr_of_eventuallyEq hev.symm).unique hR + simp only [id_eq,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat,show r+1+1=r+2 by omega,show r+2+1=r+1+2 by omega] at hd ⊢ + have hn : (r:ℝ)+1≠0 := by positivity + apply (mul_left_cancel₀ hn) + linear_combination hd +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PhysicalFunctional.lean b/lean/OAI/Combinatorics/HoneycombChords/PhysicalFunctional.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f7249f09c3a8e777db0baf46f4762844c471538 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PhysicalFunctional.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.HoneycombChords.ConfluentInterpolation +import OAI.Combinatorics.HoneycombChords.FunctionalTransforms + +namespace OAI + +/-! Construction of the finite strip functional from physical spectral interpolation. -/ + +namespace CriticalHoneycomb.FiniteFunctional +open Real Filter Topology MeasureTheory Analytic + +theorem source_physical_finite_functional : PhysicalFiniteFunctional := by + intro N hN + obtain ⟨B,ρ,P,hB,hMass,hdeg,h₀,h₃,h₅,hzero,hangle⟩ := + source_physical_spectral_interpolation N hN + obtain ⟨F,f,hF,hf,hrep,hT⟩ := density_transform_surjective N P hdeg + have hu₀ : |(0:ℝ)|+2*angle < Real.pi/2 := by + rw [abs_zero]; unfold angle; linarith [Real.pi_pos] + have huL : |angle|+2*angle < Real.pi/2 := by + rw [angle_abs]; unfold angle; linarith [Real.pi_pos] + have hz : ∀ j < 2*N, iteratedDeriv j (integralFusion angle ρ f) 0 = 0 := by + intro j hj + rw [← (interpolant_fusion_eq_integral_eventually hf hT hu₀).iteratedDeriv_eq j] + exact hzero j hj + have hL : ∀ j < N, iteratedDeriv j (integralFusion angle ρ f) angle = 0 := by + intro j hj + rw [← (interpolant_fusion_eq_integral_eventually hf hT huL).iteratedDeriv_eq j] + exact hangle j hj + have hm := M_integrable_and_annihilated hrep hf ρ hz hL + have hI₃ : integralInterpolant ρ f (3*angle/2) = 0 := by + rw [← interpolant_eq_integralInterpolant (ρ := ρ) hT (by + rw [abs_of_pos (by linarith [angle_pos] : 0 < 3*angle/2)]; unfold angle; linarith [Real.pi_pos])] + exact h₃ + have hI₅ : integralInterpolant ρ f (5*angle/2) = 0 := by + rw [← interpolant_eq_integralInterpolant (ρ := ρ) hT (by + rw [abs_of_pos (by linarith [angle_pos] : 0 < 5*angle/2)]; unfold angle; linarith [Real.pi_pos])] + exact h₅ + obtain ⟨hc₁,hc₃⟩ := finite_endpoint_constraints hrep hf ρ hI₃ hI₅ + refine ⟨B,ρ,F,hB,hMass,hF,(fun H hH => (hm H hH).2),hc₁,hc₃,?_⟩ + rw [value_inv_D_eq_interpolant hrep,← interpolant_eq_integralInterpolant (ρ := ρ) hT (by + rw [abs_zero,zero_add]; exact angle_lt_pi_half)] + exact h₀.symm + +end CriticalHoneycomb.FiniteFunctional + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PhysicalMass.lean b/lean/OAI/Combinatorics/HoneycombChords/PhysicalMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..315b438a585f6fdb739c49792461d931fcf7e943 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PhysicalMass.lean @@ -0,0 +1,254 @@ +import OAI.Combinatorics.HoneycombChords.ObliqueBounds +import OAI.Combinatorics.HoneycombChords.PhysicalFunctional + +namespace OAI + +/-! +# Physical residual identities and strict bridge mass bounds + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section + +/-! Derivation of the manuscript's exact uneliminated and eliminated oblique +residual formulas from the actual infinite bridge mass. -/ +namespace CriticalHoneycomb.FiniteFunctional +open Finset + +lemma F0_density_integrable {N : ℕ} {H F : ℝ → ℂ} + (hH : H ∈ M N ⊔ Submodule.span ℂ {C (angle/2)}) (hF : F ∈ admissibleDensity N) : + PairingIntegrable H F := by + rw [←fBasis_span] at hH + apply PairingIntegrable.span_left (S:=Set.range (fBasis N)) _ hH + rintro _ ⟨i,rfl⟩ + exact fBasis_density_integrable hF i + +lemma value_annihilates_F0 {N : ℕ} {F : ℝ → ℂ} {ρ : ℂ} + (hF : F ∈ admissibleDensity N) (hM : ∀ H ∈ M N,value ρ F H=0) + (hc : value ρ F (C (angle/2))=0) {H : ℝ → ℂ} + (hH : H ∈ M N ⊔ Submodule.span ℂ {C (angle/2)}) : value ρ F H=0 := by + obtain ⟨H₀,h₀,H₁,h₁,rfl⟩ := Submodule.mem_sup.mp hH + obtain ⟨a,rfl⟩ := Submodule.mem_span_singleton.mp h₁ + rw [value_add (F0_density_integrable (Submodule.mem_sup_left h₀) hF) + (F0_density_integrable (Submodule.mem_sup_right (Submodule.smul_mem _ a + (Submodule.subset_span (Set.mem_singleton (C (angle/2)))))) hF),hM _ h₀,value_smul,hc,mul_zero,add_zero] + +lemma value_eq_residual {N : ℕ} {F H : ℝ → ℂ} {ρ : ℂ} + (hF : F ∈ admissibleDensity N) (hM : ∀ H ∈ M N,value ρ F H=0) + (hc : value ρ F (C (angle/2))=0) (hH : InPairingDomain N H) : + value ρ F H=4*aStar*obliqueResidual N H (-4)+ρ*obliqueResidual N H 0 := by + have he : value ρ F (obliqueResidual N H)=value ρ F H := by + rw [obliqueResidual,value_sub (domain_density_integrable hH hF) (projection_density_integrable H hF), + value_annihilates_F0 hF hM hc (projection_mem N H),sub_zero] + rw [←he,value,residual_density_pairing_zero hH hF,add_zero] + +/-- The physical bridge mass satisfies two residual equations before elimination of the scalar coefficient. -/ +theorem source_physical_uneliminated_residual (N : ℕ) (hN : 1≤N) : + ∃ (B : ℝ) (s : ℂ),0≤B ∧ bridgeMass N=ENNReal.ofReal B ∧ + 2*(B:ℂ)=4*aStar*(obliqueResidual N hZero (-4)+s*obliqueResidual N hZero 0) ∧ + obliqueResidual N cThreeCorrection (-4)+s*obliqueResidual N cThreeCorrection 0=0 := by + obtain ⟨B,ρ,F,hB,hMass,hF,hM,hc,hcorr,hval⟩ := source_physical_finite_functional N hN + have he₀ := value_eq_residual hF hM hc (hZero_in_pairingDomain N) + have he₁ := value_eq_residual hF hM hc (cThreeCorrection_in_pairingDomain N) + change 2*(B:ℂ)=value ρ F hZero at hval + change value ρ F cThreeCorrection=0 at hcorr + have ha : 4*aStar ≠ 0 := mul_ne_zero (by norm_num) aStar_ne_zero + refine ⟨B,ρ/(4*aStar),hB,hMass,?_,?_⟩ + · rw [hval,he₀] + field_simp [aStar_ne_zero] + · have hh : 4*aStar*obliqueResidual N cThreeCorrection (-4)+ρ*obliqueResidual N cThreeCorrection 0=0 := by + rw [←he₁,hcorr] + apply (mul_left_cancel₀ ha) + rw [mul_zero] + calc + _=4*aStar*obliqueResidual N cThreeCorrection (-4)+ρ*obliqueResidual N cThreeCorrection 0 := by field_simp [aStar_ne_zero] + _=0 := hh + +/-- The physical bridge mass equals the eliminated oblique residual expression when its denominator is nonzero. -/ +theorem source_physical_residual_formula (N : ℕ) (hN : 1≤N) + (hd : obliqueResidual N cThreeCorrection 0 ≠ 0) : + ∃ B : ℝ,0≤B ∧ bridgeMass N=ENNReal.ofReal B ∧ + (B:ℂ)=2*aStar*(obliqueResidual N hZero (-4)- + obliqueResidual N cThreeCorrection (-4)*obliqueResidual N hZero 0/ + obliqueResidual N cThreeCorrection 0) := by + obtain ⟨B,s,hB,hMass,hm,hs⟩ := source_physical_uneliminated_residual N hN + have he : s= -obliqueResidual N cThreeCorrection (-4)/obliqueResidual N cThreeCorrection 0 := by + apply (eq_div_iff hd).mpr + linear_combination hs + refine ⟨B,hB,hMass,?_⟩ + rw [he] at hm + linear_combination (1/2:ℂ)*hm + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional + +/-- The physical bridge mass equals an oblique residual expression. -/ +theorem physical_residual_formula (N : ℕ) (hN : 1≤N) : + ∃ B : ℝ,0≤B ∧ bridgeMass N=ENNReal.ofReal B ∧ + (B:ℂ)=2*aStar*(obliqueResidual N hZero (-4)- + obliqueResidual N cThreeCorrection (-4)*obliqueResidual N hZero 0/ + obliqueResidual N cThreeCorrection 0) := + source_physical_residual_formula N hN (source_residual_denominator_ne_zero hN) + +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open StripAsymptotic Matrix MeasureTheory Filter Topology + +lemma physical_real_residual_formula (N : ℕ) (hN : 1≤N) : + ∃ B : ℝ,0≤B ∧ bridgeMass N=ENNReal.ofReal B ∧ + B=2*aStar.re*((obliqueResidual N hZero (-4)).re- + (obliqueResidual N cThreeCorrection (-4)).re*(obliqueResidual N hZero 0).re/ + (obliqueResidual N cThreeCorrection 0).re) := by + obtain ⟨B,hB,hM,he⟩:=physical_residual_formula N hN + refine ⟨B,hB,hM,?_⟩ + rw [←aStar_ofReal_re,←residual_ofReal_re N hZero_ofReal_re (-4), + ←residual_ofReal_re N correction_ofReal_re (-4),←residual_ofReal_re N hZero_ofReal_re 0, + ←residual_ofReal_re N correction_ofReal_re 0] at he + exact_mod_cast he + +/-- An upper bound for the infinite strict bridge path sum. -/ +theorem physical_bridge_mass_upper : + ∃ A : ℝ,0 fin_cases j <;> simp_all [cup] + +/-- Nonzero local orientation factors have exactly the selected occupied +edges. Thus matching a wire spin also matches the unoriented occupancy. -/ +theorem shapeTensor_support (q : Shape) (w n s e : Fin 3) + (h : shapeTensor q w n s e ≠ 0) : + spinOccupied w = q.selection.west ∧ spinOccupied n = q.selection.north ∧ + spinOccupied s = q.selection.south ∧ spinOccupied e = q.selection.east := by + cases q <;> simp only [shapeTensor,mul_ne_zero_iff] at h + · obtain ⟨hw,hs⟩ := vacant_support h.1 + obtain ⟨hn,he⟩ := vacant_support h.2 + simp [spinOccupied,Shape.selection,hw,hs,hn,he] + · obtain ⟨hws,hw⟩ := occupied_support h.1 + obtain ⟨hn,he⟩ := vacant_support h.2 + simp [spinOccupied,Shape.selection,←hws,hw,hn,he] + · obtain ⟨hw,hs⟩ := vacant_support h.1 + obtain ⟨hne,hn⟩ := occupied_support h.2 + simp [spinOccupied,Shape.selection,hw,hs,←hne,hn] + · obtain ⟨hws,hw⟩ := occupied_support h.1 + obtain ⟨hne,hn⟩ := occupied_support h.2 + simp [spinOccupied,Shape.selection,←hws,hw,←hne,hn] + · obtain ⟨hw,hn⟩ := cup_support h.1.1 + have hs := empty_support h.1.2 + have he := empty_support h.2 + simp [spinOccupied,Shape.selection,hw,hs,hn,he] + · have hw := empty_support h.1.1 + have hn := empty_support h.1.2 + obtain ⟨hs,he⟩ := cup_support h.2 + simp [spinOccupied,Shape.selection,hw,hs,hn,he] + · have hn := empty_support h.1.1 + have hs := empty_support h.1.2 + obtain ⟨hwe,hw⟩ := occupied_support h.2 + simp [spinOccupied,Shape.selection,←hwe,hw,hs,hn] + · have hw := empty_support h.1.1 + have he := empty_support h.1.2 + obtain ⟨hns,hn⟩ := occupied_support h.2 + simp [spinOccupied,Shape.selection,hw,he,←hns,hn] + +/-- A finite gluing of the exact physical lozenges. A wire label shared by +tiles is summed only once; open boundary values are imposed separately. -/ +structure TileNetwork (V T : Type*) where + west : T → V + north : T → V + south : T → V + east : T → V + +noncomputable def TileNetwork.orientation {V T : Type*} [Fintype T] [DecidableEq T] + (A : TileNetwork V T) (q : T → Shape) (σ : V → Fin 3) : ℂ := + ∏ t, shapeTensor (q t) (σ (A.west t)) (σ (A.north t)) + (σ (A.south t)) (σ (A.east t)) + +noncomputable def TileNetwork.physical {V T : Type*} [Fintype T] [DecidableEq T] + (A : TileNetwork V T) (σ : V → Fin 3) : ℂ := + ∏ t, sourceR (kappa:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) 0 + (σ (A.north t),σ (A.west t)) (σ (A.south t),σ (A.east t)) + +/-- The global finite product expansion, with the exact visited-center +weight. No path/loop cancellation is assumed in this algebraic equality. -/ +theorem physical_network_expansion {V T : Type*} [Fintype T] [DecidableEq T] + (A : TileNetwork V T) (σ : V → Fin 3) : + A.physical σ = ∑ q : T → Shape, + (kappa:ℂ) ^ (∑ t, (q t).visits) * A.orientation q σ := by + classical + simp only [TileNetwork.physical,physical_tile_expansion] + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro q hq + rw [Finset.prod_mul_distrib,←Finset.prod_pow_eq_pow_sum] + rfl + +/-- Full finite contraction with any fixed boundary weight. For a prescribed +boundary spin assignment this factor is its zero/one indicator. -/ +theorem contracted_network_expansion {V T : Type*} [Fintype V] [Fintype T] [DecidableEq V] [DecidableEq T] + (A : TileNetwork V T) (boundary : (V → Fin 3) → ℂ) : + (∑ σ, boundary σ * A.physical σ) = + ∑ q : T → Shape, (kappa:ℂ) ^ (∑ t, (q t).visits) * + ∑ σ, boundary σ * A.orientation q σ := by + classical + simp_rw [physical_network_expansion,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro q hq + apply Finset.sum_congr rfl + intro σ hσ + ring + +/-- Every contributing shape assignment is globally consistent on all +identified wires; there can be no spurious unmatched occupied half-edge. -/ +theorem orientation_support {V T : Type*} [Fintype T] [DecidableEq T] + (A : TileNetwork V T) (q : T → Shape) (σ : V → Fin 3) + (h : A.orientation q σ ≠ 0) (t : T) : + spinOccupied (σ (A.west t)) = (q t).selection.west ∧ + spinOccupied (σ (A.north t)) = (q t).selection.north ∧ + spinOccupied (σ (A.south t)) = (q t).selection.south ∧ + spinOccupied (σ (A.east t)) = (q t).selection.east := by + classical + apply shapeTensor_support + exact (Finset.prod_ne_zero_iff.mp h) t (Finset.mem_univ t) + +end CriticalHoneycomb.Transfer.PhysicalTiles + +namespace CriticalHoneycomb.Transfer.PhysicalTiles +open scoped BigOperators +open Planar + +/-- The three-leg tensor at one actual up triangle center. Its empty state +has weight one, and each of the three simple passages has exactly one κ. -/ +noncomputable def upTensor (w s m : Fin 3) : ℂ := + Planar.empty w * Planar.empty s * Planar.empty m + + (kappa:ℂ) * (occupied w s * Planar.empty m + + occupied w m * Planar.empty s + cup s m * Planar.empty w) + +/-- The down-center tensor, with the ordinary, not conjugate, contraction +on the internal edge. The order m,n is essential for the snake identity. -/ +noncomputable def downTensor (e n m : Fin 3) : ℂ := + Planar.empty e * Planar.empty n * Planar.empty m + + (kappa:ℂ) * (occupied n e * Planar.empty m + + occupied m e * Planar.empty n + cup m n * Planar.empty e) + +/-- Exact factorization through the actual middle honeycomb edge. Thus the +integrable physical tile is a contraction of two genuine visited-center +tensors, not only a list of formal connectivities. -/ +theorem sourceR_eq_center_contraction (w n s e : Fin 3) : + sourceR (kappa:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) 0 (n,w) (s,e) = + ∑ m : Fin 3, upTensor w s m * downTensor e n m := by + rw [tile_decomposition] + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp [upTensor,downTensor,vacant,occupied,Planar.empty,cup, + Fin.sum_univ_three] <;> ring_nf <;> + simp [phase_ne_zero] + +noncomputable def centerOccupied (a b c : Fin 3) : ℕ := + (spinOccupied a).toNat+(spinOccupied b).toNat+(spinOccupied c).toNat + +/-- A nonzero occupied center has exactly two selected incident edges. +Repeated centers and degree-four crossings are not hidden in the transfer. -/ +theorem upTensor_degree (w s m : Fin 3) (h : upTensor w s m ≠ 0) : + centerOccupied w s m=0 ∨ centerOccupied w s m=2 := by + fin_cases w <;> fin_cases s <;> fin_cases m <;> + norm_num [upTensor,centerOccupied,spinOccupied,Planar.empty,occupied,cup] at * + +theorem downTensor_degree (e n m : Fin 3) (h : downTensor e n m ≠ 0) : + centerOccupied e n m=0 ∨ centerOccupied e n m=2 := by + fin_cases e <;> fin_cases n <;> fin_cases m <;> + norm_num [downTensor,centerOccupied,spinOccupied,Planar.empty,occupied,cup] at * + +/-- In any finite lozenge network, all internal middle-edge indices can be +introduced simultaneously. All remaining wire indices are left unchanged. -/ +theorem physical_network_center_expansion {V T : Type*} [Fintype T] [DecidableEq T] + (A : TileNetwork V T) (σ : V → Fin 3) : + A.physical σ = ∑ μ : T → Fin 3, + ∏ t, upTensor (σ (A.west t)) (σ (A.south t)) (μ t) * + downTensor (σ (A.east t)) (σ (A.north t)) (μ t) := by + simp only [TileNetwork.physical,sourceR_eq_center_contraction] + exact Fintype.prod_sum _ + +/-- The genuine finite center partition, including any prescribed boundary +indicator. This is the exact tensor precursor to selecting the unique chord +and cancelling its detached loop components. -/ +theorem contracted_center_expansion {V T : Type*} [Fintype V] [Fintype T] + [DecidableEq V] [DecidableEq T] (A : TileNetwork V T) + (boundary : (V → Fin 3) → ℂ) : + (∑ σ, boundary σ * A.physical σ) = + ∑ σ : V → Fin 3, ∑ μ : T → Fin 3, boundary σ * + ∏ t, upTensor (σ (A.west t)) (σ (A.south t)) (μ t) * + downTensor (σ (A.east t)) (σ (A.north t)) (μ t) := by + simp_rw [physical_network_center_expansion,Finset.mul_sum] + +end CriticalHoneycomb.Transfer.PhysicalTiles + +namespace CriticalHoneycomb.Transfer.CenterPartition +open SimpleGraph PhysicalTiles FiniteConfigurations + +/-- The tensor sits at an actual honeycomb center, indexed by its actual +three honeycomb wires. The order at an up and a down center is the source +physical R factorization order, not a symmetrized substitute. -/ +noncomputable def centerTensor (σ : Wire → Fin 3) (v : Center) : ℂ := + if v.2.2 then + upTensor (σ (incidentWire v 2)) (σ (incidentWire v 1)) (σ (incidentWire v 0)) + else + downTensor (σ (incidentWire v 2)) (σ (incidentWire v 1)) (σ (incidentWire v 0)) + +noncomputable def centerProduct (D : Finset Center) (σ : Wire → Fin 3) : ℂ := + ∏ v∈D, centerTensor σ v + +def selected (σ : Wire → Fin 3) : Wire → Bool := fun w => spinOccupied (σ w) + +lemma nonzero_center_degree (σ : Wire → Fin 3) (v : Center) + (h : centerTensor σ v ≠ 0) : + selectedSideCount (selected σ) v=0 ∨ selectedSideCount (selected σ) v=2 := by + have he : selectedSideCount (selected σ) v = + centerOccupied (σ (incidentWire v 2)) (σ (incidentWire v 1)) + (σ (incidentWire v 0)) := by + simp [selectedSideCount,selected,centerOccupied,Nat.add_comm,Nat.add_assoc] + rw [he] + unfold centerTensor at h + split at h + · exact upTensor_degree _ _ _ h + · exact downTensor_degree _ _ _ h + +/-- This packages *derived*, not assumed, local degree conditions. -/ +noncomputable def configurationOfNonzero {D : Finset Center} + (a b : Port (D : Set Center)) (hab : a≠b) (σ : Wire → Fin 3) + (hboundary : BoundarySelection a b (selected σ)) + (h : centerProduct D σ ≠ 0) : Configuration D a b := + configurationOfSides a b hab (selected σ) hboundary (by + intro v hv + apply nonzero_center_degree σ v + exact (Finset.prod_ne_zero_iff.mp h) v hv) + +/-- Every contributing physical center configuration has an actual simple +chord with precisely the prescribed ports. All other occupied components +are detached cycles: the ensuing loop cancellation is a separate obligation. -/ +theorem nonzero_product_contains_chord {D : Finset Center} + (a b : Port (D : Set Center)) (hab : a≠b) (σ : Wire → Fin 3) + (hboundary : BoundarySelection a b (selected σ)) + (h : centerProduct D σ ≠ 0) : + ∃ (γ : Chord (D : Set Center) a b) (xs : List (Interior D)) + (p : (selectedGraph a b (selected σ)).Walk (.inr false) (.inr true)), + xs.map Subtype.val = γ.val ∧ p.IsPath ∧ + p.support = Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true]) ∧ + ((selectedGraph a b (selected σ)) \ p.toSubgraph.spanningCoe).IsCycles := + configuration_contains_chord (configurationOfNonzero a b hab σ hboundary h) + +end CriticalHoneycomb.Transfer.CenterPartition + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PhysicalWeights.lean b/lean/OAI/Combinatorics/HoneycombChords/PhysicalWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..f72ea948e6712a7de5595ad8df90e15ee0ddc253 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PhysicalWeights.lean @@ -0,0 +1,344 @@ +import OAI.Combinatorics.HoneycombChords.Geometry + +namespace OAI + +/-! +# Critical honeycomb tile weights + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycombTransfer +noncomputable def L : ℝ := Real.pi / 8 +noncomputable def S : ℝ := Real.sin (2 * L) +noncomputable def b : ℝ := 3 * L +noncomputable def Q (u : ℝ) : ℝ := Real.sin (2*L+u) * Real.sin (b+u) +noncomputable def a (u : ℝ) : ℝ := S * Real.sin (b-u) / Q u +noncomputable def h (u : ℝ) : ℝ := S * Real.sin u / Q u +noncomputable def v (u : ℝ) : ℝ := Real.sin (b-u) * Real.sin u / Q u +noncomputable def c (u : ℝ) : ℝ := Real.sin (b-u) * Real.sin (2*L-u) / Q u +noncomputable def d (u : ℝ) : ℝ := Real.sin u * Real.sin (u-L) / Q u +noncomputable def κ : ℝ := (2 + Real.sqrt 2) ^ (-(1:ℝ)/2) + + theorem κ_eq_inv_sqrt : κ = (Real.sqrt (2 + Real.sqrt 2))⁻¹ := by + rw [κ, neg_div, Real.rpow_neg (by positivity), ← Real.sqrt_eq_rpow] + + theorem L_pos : 0 < L := by unfold L; positivity + theorem L_lt_pi_div_two : L < Real.pi / 2 := by unfold L; linarith [Real.pi_pos] + theorem cos_L_pos : 0 < Real.cos L := by + exact Real.cos_pos_of_mem_Ioo ⟨by linarith [L_pos, Real.pi_pos], L_lt_pi_div_two⟩ + theorem sin_two_L : Real.sin (2*L) = Real.sqrt 2 / 2 := by + convert Real.sin_pi_div_four using 1 + congr 1 + unfold L + ring + theorem cos_two_L : Real.cos (2*L) = Real.sqrt 2 / 2 := by + convert Real.cos_pi_div_four using 1 + congr 1 + unfold L + ring + theorem sin_three_L : Real.sin (3*L) = Real.cos L := by + have hh : 3*L = Real.pi/2 - L := by unfold L; ring + rw [hh, Real.sin_pi_div_two_sub] + theorem sin_four_L : Real.sin (4*L) = 1 := by + have hh : 4*L = Real.pi/2 := by unfold L; ring + rw [hh, Real.sin_pi_div_two] + theorem four_cos_sq : (2 * Real.cos L)^2 = 2 + Real.sqrt 2 := by + have hh := Real.cos_two_mul L + rw [cos_two_L] at hh + nlinarith + theorem κ_cos : 2 * κ * Real.cos L = 1 := by + have hh : Real.sqrt (2 + Real.sqrt 2) = 2 * Real.cos L := by + rw [← four_cos_sq, Real.sqrt_sq (mul_nonneg (by norm_num) (le_of_lt cos_L_pos))] + rw [κ_eq_inv_sqrt, hh] + field_simp [ne_of_gt cos_L_pos] + + theorem physical_weights : + a L = κ ∧ h L = κ^2 ∧ v L = κ^2 ∧ c L = κ^2 ∧ d L = 0 := by + have hQ : Q L = Real.cos L := by + unfold Q b + convert congrArg (fun x : ℝ => x * 1) sin_three_L using 1 <;> + simp only [mul_one] + rw [show 2*L + L = 3*L by ring, show 3*L+L=4*L by ring, + sin_four_L, mul_one] + have hS : S = Real.sqrt 2 / 2 := sin_two_L + have hsq : (Real.sqrt 2)^2 = 2 := by norm_num + have ha : a L = κ := by + unfold a b + rw [hQ, show 3*L-L=2*L by ring, sin_two_L, hS] + apply (div_eq_iff (ne_of_gt cos_L_pos)).mpr + nlinarith only [κ_cos, hsq] + have hh : h L = κ^2 := by + unfold h + rw [hQ, hS] + apply (div_eq_iff (ne_of_gt cos_L_pos)).mpr + have ht := Real.sin_two_mul L + rw [sin_two_L] at ht + have hmul := congrArg (fun x : ℝ => x * (Real.sqrt 2)) ht + have he : (Real.sqrt 2 / 2 * Real.sin L) * Real.cos L = 1/4 := by + nlinarith only [hmul, hsq] + have he' : (κ / 2) * Real.cos L = 1/4 := by + nlinarith only [κ_cos, hsq] + have hsin : Real.sqrt 2 / 2 * Real.sin L = κ/2 := + (mul_right_cancel₀ (ne_of_gt cos_L_pos)) (he.trans he'.symm) + have hk := congrArg (fun x : ℝ => x * κ) κ_cos + rw [hsin] + nlinarith only [hk] + refine ⟨ha,hh,?_,?_,?_⟩ + · convert hh using 1 + unfold v h b S + rw [show 3*L-L=2*L by ring] + · convert hh using 1 + unfold c h b S + rw [show 3*L-L=2*L by ring, show 2*L-L=L by ring] + · simp [d] +end CriticalHoneycombTransfer + + +namespace CriticalHoneycomb.Transfer.Planar +open scoped BigOperators + +noncomputable def angle : ℝ := Real.pi / 8 +noncomputable def bigAngle : ℝ := 3 * angle +noncomputable def sine2 : ℝ := Real.sin (2 * angle) +noncomputable def denominator (u : ℝ) : ℝ := + Real.sin (2 * angle + u) * Real.sin (bigAngle + u) + +noncomputable def a (u : ℝ) : ℝ := + sine2 * Real.sin (bigAngle - u) / denominator u +noncomputable def h (u : ℝ) : ℝ := + sine2 * Real.sin u / denominator u +noncomputable def v (u : ℝ) : ℝ := + Real.sin (bigAngle - u) * Real.sin u / denominator u +noncomputable def c (u : ℝ) : ℝ := + Real.sin (bigAngle - u) * Real.sin (2 * angle - u) / denominator u +noncomputable def d (u : ℝ) : ℝ := + Real.sin u * Real.sin (u - angle) / denominator u + +noncomputable def phase : ℂ := Complex.exp ((2 * angle : ℝ) * Complex.I) + +lemma phase_sq : phase^2 = Complex.I := by + unfold phase + rw [← Complex.exp_nat_mul] + convert Complex.exp_pi_div_two_mul_I using 1 + push_cast + unfold angle + push_cast + ring_nf + +lemma phase_ne_zero : phase ≠ 0 := Complex.exp_ne_zero _ + +lemma phase_inv : phase⁻¹ = -phase * Complex.I := by + apply mul_left_cancel₀ phase_ne_zero + rw [mul_inv_cancel₀ phase_ne_zero] + calc + 1 = -phase^2 * Complex.I := by rw [phase_sq]; simp + _ = phase * (-phase * Complex.I) := by ring + +/-! +Planar local-to-global identity for the physical crossing observable. +The full source R is displayed with its diagonal spin order +,0,-. +`braidR` is the planar tile after exchanging its two output slots. +-/ +noncomputable def sourceR (a h v c d : ℂ) (p q : Fin 3 × Fin 3) : ℂ := + match p.1.val, p.2.val, q.1.val, q.2.val with + | 0, 0, 0, 0 => c + | 2, 2, 2, 2 => c + | 0, 1, 0, 1 | 1, 0, 1, 0 | 2, 1, 2, 1 | 1, 2, 1, 2 => v + | 0, 1, 1, 0 | 1, 0, 0, 1 | 2, 1, 1, 2 | 1, 2, 2, 1 => a + | 0, 2, 0, 2 => d + | 0, 2, 1, 1 => h / phase + | 0, 2, 2, 0 => c+d/phase^2 + | 1, 1, 0, 2 => h*phase + | 1, 1, 1, 1 => 1 + | 1, 1, 2, 0 => h/phase + | 2, 0, 0, 2 => c+d*phase^2 + | 2, 0, 1, 1 => h*phase + | 2, 0, 2, 0 => d + | _, _, _, _ => 0 + +noncomputable def cup (i j : Fin 3) : ℂ := + if i=0 ∧ j=2 then phase else if i=2 ∧ j=0 then phase⁻¹ else 0 + +noncomputable def occupied (i j : Fin 3) : ℂ := if i=j ∧ i≠1 then 1 else 0 +noncomputable def vacant (i j : Fin 3) : ℂ := if i=1 ∧ j=1 then 1 else 0 +noncomputable def empty (i : Fin 3) : ℂ := if i=1 then 1 else 0 + +/-- Ordinary transpose, not Hermitian adjoint: a closed unoriented loop +has exactly weight zero at the source's phase. -/ +theorem loop_erasure : (∑ i : Fin 3, ∑ j : Fin 3, cup i j * cup i j) = 0 := by + simp [cup, Fin.sum_univ_three] + rw [← sq, ← sq, inv_pow, phase_sq, Complex.inv_I] + simp + +/-- Straightening a cup-cap pair leaves the occupied strand unchanged. -/ +theorem snake_left (i j : Fin 3) : + (∑ k : Fin 3, cup i k * cup k j) = occupied i j := by + fin_cases i <;> fin_cases j <;> + simp [cup, occupied, phase_ne_zero] + +theorem snake_right (i j : Fin 3) : + (∑ k : Fin 3, cup k i * cup j k) = occupied i j := by + rw [show (∑ k : Fin 3, cup k i * cup j k) = ∑ k : Fin 3, cup j k * cup k i by + apply Finset.sum_congr rfl; intro k hk; ring] + rw [snake_left] + simp only [occupied] + split_ifs <;> simp_all + +/-- Exact dilute Temperley--Lieb decomposition of the source local tile. +The eight connectivities carry precisely the coefficients listed in the +physical crossing observable paragraph. -/ +theorem tile_decomposition (a h v c d : ℂ) (i j k l : Fin 3) : + sourceR a h v c d (j,i) (k,l) = + vacant i k * vacant j l + + a * (occupied i k * vacant j l + vacant i k * occupied j l) + + c * occupied i k * occupied j l + + v * (empty i * empty l * occupied j k + empty j * empty k * occupied i l) + + h * (cup i j * empty k * empty l + empty i * empty j * cup k l) + + d * cup i j * cup k l := by + fin_cases i <;> fin_cases j <;> fin_cases k <;> fin_cases l <;> + simp [sourceR, vacant, occupied, empty, cup, phase_ne_zero, div_eq_mul_inv] <;> + ring + +end CriticalHoneycomb.Transfer.Planar + +namespace CriticalHoneycomb.Transfer.PhysicalTiles +open scoped BigOperators +open Planar + +/-- The eight choices of non-intersecting arcs in one actual triangular pair. +W,S meet the up triangle; E,N meet the down triangle. The forbidden second +two-arc choice would use both centers twice and is absent. -/ +inductive Shape + | empty | westSouth | northEast | both | westNorth | southEast | westEast | northSouth + deriving DecidableEq +instance : Fintype Shape := ⟨{.empty,.westSouth,.northEast,.both,.westNorth,.southEast,.westEast,.northSouth}, + by intro q; cases q <;> simp⟩ + +structure Selection where + west : Bool + south : Bool + east : Bool + north : Bool + middle : Bool + deriving DecidableEq, Fintype + +def Shape.selection : Shape → Selection + | .empty => ⟨false,false,false,false,false⟩ + | .westSouth => ⟨true,true,false,false,false⟩ + | .northEast => ⟨false,false,true,true,false⟩ + | .both => ⟨true,true,true,true,false⟩ + | .westNorth => ⟨true,false,false,true,true⟩ + | .southEast => ⟨false,true,true,false,true⟩ + | .westEast => ⟨true,false,true,false,true⟩ + | .northSouth => ⟨false,true,false,true,true⟩ + +def Selection.upDegree (s : Selection) : ℕ := s.west.toNat+s.south.toNat+s.middle.toNat +def Selection.downDegree (s : Selection) : ℕ := s.east.toNat+s.north.toNat+s.middle.toNat + +def Admissible (s : Selection) : Prop := + (s.upDegree=0 ∨ s.upDegree=2) ∧ (s.downDegree=0 ∨ s.downDegree=2) +instance (s : Selection) : Decidable (Admissible s) := inferInstanceAs (Decidable (_ ∧ _)) + +/-- Local self-avoiding connectivity classification by both center degrees. -/ +theorem selection_classification (s : Selection) : + Admissible s ↔ ∃ q : Shape, q.selection=s := by + revert s + decide + +theorem selection_injective : Function.Injective Shape.selection := by decide + +def Shape.visits : Shape → ℕ + | .empty => 0 + | .westSouth | .northEast => 1 + | _ => 2 + +/-- The actual number of used centers, not the number of ports or arcs. -/ +theorem visits_eq (q : Shape) : + q.visits = (if q.selection.upDegree=0 then 0 else 1) + + (if q.selection.downDegree=0 then 0 else 1) := by + cases q <;> rfl + +/-- Pure orientation kernel for a local connectivity. Indices are W,N,S,E, +respectively: output order W,N, input order S,E in the braided drawing. -/ +noncomputable def shapeTensor (q : Shape) (w n s e : Fin 3) : ℂ := + match q with + | .empty => vacant w s * vacant n e + | .westSouth => occupied w s * vacant n e + | .northEast => vacant w s * occupied n e + | .both => occupied w s * occupied n e + | .westNorth => cup w n * Planar.empty s * Planar.empty e + | .southEast => Planar.empty w * Planar.empty n * cup s e + | .westEast => Planar.empty n * Planar.empty s * occupied w e + | .northSouth => Planar.empty w * Planar.empty e * occupied n s + +/-- Critical weights count precisely the visited centers of the lozenge. +This is a local equality of the exact R entries and actual path choices. -/ +theorem physical_tile_expansion (w n s e : Fin 3) : + sourceR (kappa:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) 0 (n,w) (s,e) = + ∑ q : Shape, (kappa:ℂ)^q.visits * shapeTensor q w n s e := by + rw [tile_decomposition] + change _ = ∑ q ∈ ({.empty,.westSouth,.northEast,.both,.westNorth,.southEast,.westEast,.northSouth} : Finset Shape), + (kappa:ℂ)^q.visits * shapeTensor q w n s e + simp [Shape.visits,shapeTensor] + ring + +inductive Node | up | down | west | south | east | north + deriving DecidableEq +instance : Fintype Node := ⟨{.up,.down,.west,.south,.east,.north}, + by intro q; cases q <;> simp⟩ + +def Node.position (i j : ℤ) : Node → Center + | .up => CriticalHoneycomb.up i j + | .down => CriticalHoneycomb.down i j + | .west => CriticalHoneycomb.down (i-1) j + | .south => CriticalHoneycomb.down i (j-1) + | .east => CriticalHoneycomb.up (i+1) j + | .north => CriticalHoneycomb.up i (j+1) + +def Selection.adj (s : Selection) : Node → Node → Prop + | .up,.down | .down,.up => s.middle=true + | .up,.west | .west,.up => s.west=true + | .up,.south | .south,.up => s.south=true + | .down,.east | .east,.down => s.east=true + | .down,.north | .north,.down => s.north=true + | _,_ => False +instance (s : Selection) (a b : Node) : Decidable (s.adj a b) := by + cases a <;> cases b <;> unfold Selection.adj <;> infer_instance + +/-- Every selected local edge is the exact source honeycomb adjacency. -/ +theorem selected_adjacent (s : Selection) (i j : ℤ) (a b : Node) + (h : s.adj a b) : Adj (a.position i j) (b.position i j) := by + cases a <;> cases b <;> + simp_all [Selection.adj,Node.position,Adj,CriticalHoneycomb.up,CriticalHoneycomb.down] + +/-- The local graph contains genuinely distinct centers, including its +four exterior neighbor centers; no loop or collision is hidden by the drawing. -/ +theorem node_position_injective (i j : ℤ) : Function.Injective (Node.position i j) := by + intro a b h + cases a <;> cases b <;> + simp_all [Node.position,CriticalHoneycomb.up,CriticalHoneycomb.down] <;> omega + +end CriticalHoneycomb.Transfer.PhysicalTiles + +namespace CriticalHoneycomb.Transfer.PhysicalTiles +open scoped BigOperators +open Planar + +/-- The actual spectral weights, at the physical honeycomb specialization, +are the exact local path expansion above. No R entries are altered. -/ +theorem spectral_physical_tile_expansion (w n s e : Fin 3) : + sourceR (CriticalHoneycombTransfer.a CriticalHoneycombTransfer.L : ℂ) + (CriticalHoneycombTransfer.h CriticalHoneycombTransfer.L : ℂ) + (CriticalHoneycombTransfer.v CriticalHoneycombTransfer.L : ℂ) + (CriticalHoneycombTransfer.c CriticalHoneycombTransfer.L : ℂ) + (CriticalHoneycombTransfer.d CriticalHoneycombTransfer.L : ℂ) (n,w) (s,e) = + ∑ q : Shape, (kappa:ℂ)^q.visits * shapeTensor q w n s e := by + obtain ⟨ha,hh,hv,hc,hd⟩ := CriticalHoneycombTransfer.physical_weights + rw [ha,hh,hv,hc,hd] + simpa only [Complex.ofReal_pow,Complex.ofReal_zero,CriticalHoneycombTransfer.κ,kappa] using physical_tile_expansion w n s e + +end CriticalHoneycomb.Transfer.PhysicalTiles + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PlanarDiagrams.lean b/lean/OAI/Combinatorics/HoneycombChords/PlanarDiagrams.lean new file mode 100644 index 0000000000000000000000000000000000000000..68f24a8f6908b7ed8e66d0bbf34cdc6538fbb99b --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PlanarDiagrams.lean @@ -0,0 +1,1228 @@ +import OAI.Combinatorics.HoneycombChords.RasterGrid + +namespace OAI + +/-! +# Planar cup and cap normalization + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +/-! +Planar loop erasure for physical finite strips. +This implements the adjacent cup/cap contractions of the exact dilute +Temperley--Lieb tile. No physical partition-function estimate is assumed. +-/ +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped BigOperators + +noncomputable def phase : ℂ := Complex.exp (((Real.pi/4:ℝ):ℂ)*Complex.I) +lemma phase_ne_zero : phase ≠ 0 := Complex.exp_ne_zero _ +lemma phase_sq : phase^2 = Complex.I := by + unfold phase + rw [← Complex.exp_nat_mul] + convert Complex.exp_pi_div_two_mul_I using 1 + push_cast + ring_nf + +noncomputable def cup (a b : Bool) : ℂ := + if a=b then 0 else if a then phase⁻¹ else phase + +lemma loop_value : (∑ a : Bool, ∑ b : Bool, cup a b * cup a b) = 0 := by + simp [cup] + rw [← sq, ← sq, inv_pow, phase_sq, Complex.inv_I] + simp + +lemma snake_left (a c : Bool) : + (∑ b : Bool, cup a b * cup b c) = if a=c then 1 else 0 := by + cases a <;> cases c <;> simp [cup, phase_ne_zero] + +lemma snake_right (a c : Bool) : + (∑ b : Bool, cup b a * cup c b) = if a=c then 1 else 0 := by + cases a <;> cases c <;> simp [cup, phase_ne_zero] + +abbrev State := List Bool → ℂ + +/-- Insert an adjacent cup at a frontier position. States are zero on +words too short for the requested position. -/ +noncomputable def create : ℕ → State → State + | 0, f, a::b::xs => cup a b * f xs + | 0, _, _ => 0 + | i+1, f, a::xs => create i (fun ys => f (a::ys)) xs + | _+1, _, [] => 0 + +/-- Contract two adjacent frontier strands with the ordinary transpose cap. -/ +noncomputable def contract : ℕ → State → State + | 0, f, xs => ∑ a : Bool, ∑ b : Bool, cup a b * f (a::b::xs) + | i+1, f, a::xs => contract i (fun ys => f (a::ys)) xs + | _+1, _, [] => 0 + +lemma create_prefix (i : ℕ) (f : State) (a : Bool) : + (fun xs => create (i+1) f (a::xs)) = create i (fun xs => f (a::xs)) := rfl +lemma contract_prefix (i : ℕ) (f : State) (a : Bool) : + (fun xs => contract (i+1) f (a::xs)) = contract i (fun xs => f (a::xs)) := rfl + +lemma create_zero : ∀ i : ℕ, create i (fun _ => 0) = fun _ => 0 := by + intro i + induction i with + | zero => funext xs; cases xs with + | nil => rfl + | cons a xs => cases xs <;> simp [create] + | succ i ih => + funext xs + cases xs with + | nil => rfl + | cons a xs => simpa only [create] using congrFun ih xs + +lemma contract_zero : ∀ i : ℕ, contract i (fun _ => 0) = fun _ => 0 := by + intro i + induction i with + | zero => funext xs; simp [contract] + | succ i ih => + funext xs + cases xs with + | nil => rfl + | cons a xs => simpa only [contract] using congrFun ih xs + +lemma contract_create_same (i : ℕ) (f : State) : + contract i (create i f) = fun _ => 0 := by + induction i generalizing f with + | zero => + funext xs + have hl := loop_value + simp only [Fintype.sum_bool] at hl + simp only [contract, create, Fintype.sum_bool] + linear_combination f xs * hl + | succ i ih => + funext xs + cases xs with + | nil => rfl + | cons a xs => + simpa only [contract, create_prefix] using congrFun (ih (fun ys => f (a::ys))) xs + +lemma contract_create_next (i : ℕ) (f : State) (xs : List Bool) + (h : i < xs.length) : + contract i (create (i+1) f) xs = f xs := by + induction i generalizing f xs with + | zero => + cases xs with + | nil => simp at h + | cons x xs => + cases x <;> simp [contract, create, cup, phase_ne_zero] + | succ i ih => + cases xs with + | nil => simp at h + | cons x xs => + simpa only [contract, create_prefix] using + ih (fun ys => f (x::ys)) xs (by simpa using h) + +lemma contract_next_create (i : ℕ) (f : State) (xs : List Bool) + (h : i < xs.length) : + contract (i+1) (create i f) xs = f xs := by + induction i generalizing f xs with + | zero => + cases xs with + | nil => simp at h + | cons x xs => + cases x <;> simp [contract, create, cup, phase_ne_zero, ← mul_assoc] + | succ i ih => + cases xs with + | nil => simp at h + | cons x xs => + simpa only [contract, create_prefix] using + ih (fun ys => f (x::ys)) xs (by simpa using h) + +lemma create_add (i : ℕ) (f g : State) : + create i (fun xs => f xs + g xs) = fun xs => create i f xs + create i g xs := by + induction i generalizing f g with + | zero => + funext xs + cases xs with + | nil => simp [create] + | cons x xs => cases xs <;> simp [create, mul_add] + | succ i ih => + funext xs + cases xs with + | nil => simp [create] + | cons x xs => exact congrFun (ih (fun ys => f (x::ys)) (fun ys => g (x::ys))) xs + +lemma create_mul (i : ℕ) (z : ℂ) (f : State) : + create i (fun xs => z * f xs) = fun xs => z * create i f xs := by + induction i generalizing f with + | zero => + funext xs + cases xs with + | nil => simp [create] + | cons x xs => cases xs <;> simp [create]; ring + | succ i ih => + funext xs + cases xs with + | nil => simp [create] + | cons x xs => exact congrFun (ih (fun ys => f (x::ys))) xs + +lemma contract_mul (i : ℕ) (z : ℂ) (f : State) : + contract i (fun xs => z * f xs) = fun xs => z * contract i f xs := by + induction i generalizing f with + | zero => funext xs; simp only [contract, Fintype.sum_bool]; ring + | succ i ih => + funext xs + cases xs with + | nil => simp [contract] + | cons x xs => exact congrFun (ih (fun ys => f (x::ys))) xs + +lemma create_mul_apply (i : ℕ) (z : ℂ) (f : State) (xs : List Bool) : + create i (fun ys => z * f ys) xs = z * create i f xs := congrFun (create_mul i z f) xs + +lemma create_sum_bool (i : ℕ) (f : Bool → State) (xs : List Bool) : + create i (fun ys => ∑ a : Bool, f a ys) xs = ∑ a : Bool, create i (f a) xs := by + simp only [Fintype.sum_bool] + exact congrFun (create_add i (f true) (f false)) xs + +/-- A cap wholly to the left of a newly inserted cup commutes past it. -/ +lemma contract_create_before (i gap : ℕ) (f : State) : + contract i (create (i+gap+2) f) = create (i+gap) (contract i f) := by + induction i generalizing f with + | zero => + funext xs + simp only [Nat.zero_add] + change (∑ a : Bool, ∑ b : Bool, + cup a b * create gap (fun ys => f (a::b::ys)) xs) = + create gap (fun ys => ∑ a : Bool, ∑ b : Bool, cup a b * f (a::b::ys)) xs + simp only [create_sum_bool, create_mul_apply] + | succ i ih => + funext xs + cases xs with + | nil => simp [Nat.succ_add, contract, create] + | cons x xs => + simpa only [Nat.succ_add, contract, create_prefix, contract_prefix, create] using + congrFun (ih (fun ys => f (x::ys))) xs + +/-- A cap wholly to the right of a newly inserted cup commutes past it. -/ +lemma contract_create_after (i gap : ℕ) (f : State) : + contract (i+gap+2) (create i f) = create i (contract (i+gap) f) := by + induction i generalizing f with + | zero => + funext xs + cases xs with + | nil => simp [contract, create] + | cons x xs => + cases xs with + | nil => simp [contract, create] + | cons y xs => + simp only [Nat.zero_add] + change contract gap (fun ys => cup x y * f ys) xs = + cup x y * contract gap f xs + exact congrFun (contract_mul gap (cup x y) f) xs + | succ i ih => + funext xs + cases xs with + | nil => simp [contract, create] + | cons x xs => + simpa only [Nat.succ_add, contract, create_prefix, contract_prefix, create] using + congrFun (ih (fun ys => f (x::ys))) xs + +lemma create_congr_length (i : ℕ) (f g : State) (xs : List Bool) + (hfg : ∀ ys, ys.length + 2 = xs.length → f ys = g ys) : + create i f xs = create i g xs := by + induction i generalizing f g xs with + | zero => + cases xs with + | nil => rfl + | cons x xs => + cases xs with + | nil => rfl + | cons y xs => simp only [create]; rw [hfg xs (by simp)] + | succ i ih => + cases xs with + | nil => rfl + | cons x xs => + apply ih (fun ys => f (x::ys)) (fun ys => g (x::ys)) xs + intro ys hy + apply hfg (x::ys) + simp only [List.length_cons] + omega + +lemma contract_congr_length (i : ℕ) (f g : State) (xs : List Bool) + (hfg : ∀ ys, ys.length = xs.length + 2 → f ys = g ys) : + contract i f xs = contract i g xs := by + induction i generalizing f g xs with + | zero => + simp only [contract] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + rw [hfg (a::b::xs) (by simp)] + | succ i ih => + cases xs with + | nil => rfl + | cons x xs => + apply ih (fun ys => f (x::ys)) (fun ys => g (x::ys)) xs + intro ys hy + apply hfg (x::ys) + simp only [List.length_cons] + omega + +/-- A planar cup-only normal form. `b` is the number of through strands +(0 for the empty boundary, 1 for one specified oriented path). -/ +inductive CupHistory (b : ℕ) : ℕ → Type + | base : CupHistory b 0 + | insert {k : ℕ} (h : CupHistory b k) (i : ℕ) (hi : i ≤ b + 2*k) : + CupHistory b (k+1) + +noncomputable def CupHistory.eval {b : ℕ} : {k : ℕ} → CupHistory b k → State → State + | _, .base, f => f + | _, .insert h i _, f => create i (h.eval f) + +noncomputable def optionEval {b k : ℕ} (h : Option (CupHistory b k)) (f : State) : State := + match h with + | none => fun _ => 0 + | some h => h.eval f + +lemma optionEval_map_insert {b k : ℕ} (r : Option (CupHistory b k)) + (i : ℕ) (hi : i ≤ b+2*k) (f : State) : + optionEval (r.map (fun h => CupHistory.insert h i hi)) f = + create i (optionEval r f) := by + cases r with + | none => exact (create_zero i).symm + | some h => rfl + +/-- Contracting any adjacent two frontier strands in a planar cup normal +form either removes a closed zero-weight loop or gives another cup normal +form. This is the local-to-global cancellation step, at exact phase pi/4. -/ +theorem contract_history {b k : ℕ} (hb : b ≤ 1) + (h : CupHistory b (k+1)) (j : ℕ) (hj : j ≤ b+2*k) (f : State) : + ∃ r : Option (CupHistory b k), ∀ xs : List Bool, xs.length = b+2*k → + contract j (h.eval f) xs = optionEval r f xs := by + induction k using Nat.strong_induction_on generalizing j with + | h k ih => + cases h with + | insert old i hi => + by_cases heq : j=i + · subst j + refine ⟨none, ?_⟩ + intro xs hxs + exact congrFun (contract_create_same i (old.eval f)) xs + by_cases hnext : i=j+1 + · refine ⟨some old, ?_⟩ + intro xs hxs + change contract j (create i (old.eval f)) xs = old.eval f xs + rw [hnext] + apply contract_create_next + omega + by_cases hprev : j=i+1 + · refine ⟨some old, ?_⟩ + intro xs hxs + change contract j (create i (old.eval f)) xs = old.eval f xs + rw [hprev] + apply contract_next_create + omega + by_cases hlt : j+2 ≤ i + · cases k with + | zero => omega + | succ k => + obtain ⟨r,hr⟩ := ih k (by omega) old j (by omega) + have hi' : i-2 ≤ b+2*k := by omega + refine ⟨r.map (fun q => CupHistory.insert q (i-2) hi'), ?_⟩ + intro xs hxs + rw [optionEval_map_insert] + change contract j (create i (old.eval f)) xs = _ + have hc : contract j (create i (old.eval f)) = + create (i-2) (contract j (old.eval f)) := by + have hh := contract_create_before j (i-j-2) (old.eval f) + have ha : j+(i-j-2)=i-2 := by omega + have hh' : j+(i-j-2)+2=i := by omega + rw [hh', ha] at hh + exact hh + rw [hc] + apply create_congr_length + intro ys hys + apply hr + omega + · have hgt : i+2 ≤ j := by omega + cases k with + | zero => omega + | succ k => + obtain ⟨r,hr⟩ := ih k (by omega) old (j-2) (by omega) + have hi' : i ≤ b+2*k := by omega + refine ⟨r.map (fun q => CupHistory.insert q i hi'), ?_⟩ + intro xs hxs + rw [optionEval_map_insert] + change contract j (create i (old.eval f)) xs = _ + have hc : contract j (create i (old.eval f)) = + create i (contract (j-2) (old.eval f)) := by + have hh := contract_create_after i (j-i-2) (old.eval f) + have ha : i+(j-i-2)=j-2 := by omega + have hh' : i+(j-i-2)+2=j := by omega + rw [hh', ha] at hh + exact hh + rw [hc] + apply create_congr_length + intro ys hys + apply hr + omega + +/-- A sliced planar diagram, with all vacant strands suppressed. The local +moves are exactly cup creation and adjacent cap contraction; any number +of identity tiles can be inserted without changing this word. -/ +inductive PlanarWord (b : ℕ) : ℕ → Type + | start : PlanarWord b 0 + | insert {k : ℕ} (w : PlanarWord b k) (i : ℕ) (hi : i ≤ b+2*k) : + PlanarWord b (k+1) + | erase {k : ℕ} (w : PlanarWord b (k+1)) (i : ℕ) (hi : i ≤ b+2*k) : + PlanarWord b k + +noncomputable def PlanarWord.eval {b : ℕ} : {k : ℕ} → PlanarWord b k → State → State + | _, .start, f => f + | _, .insert w i _, f => create i (w.eval f) + | _, .erase w i _, f => contract i (w.eval f) + +theorem word_normal_form {b k : ℕ} (hb : b ≤ 1) (w : PlanarWord b k) (f : State) : + ∃ r : Option (CupHistory b k), ∀ xs : List Bool, xs.length = b+2*k → + w.eval f xs = optionEval r f xs := by + induction w with + | start => exact ⟨some .base, fun _ _ => rfl⟩ + | @insert k w i hi ih => + obtain ⟨r,hr⟩ := ih + refine ⟨r.map (fun q => CupHistory.insert q i hi), ?_⟩ + intro xs hxs + rw [optionEval_map_insert] + change create i (w.eval f) xs = create i (optionEval r f) xs + apply create_congr_length + intro ys hys + apply hr + omega + | @erase k w i hi ih => + obtain ⟨r,hr⟩ := ih + cases r with + | none => + refine ⟨none, ?_⟩ + intro xs hxs + change contract i (w.eval f) xs = 0 + calc + _ = contract i (fun _ => 0) xs := by + apply contract_congr_length + intro ys hys + apply hr + omega + _ = 0 := congrFun (contract_zero i) xs + | some h => + obtain ⟨r,hr'⟩ := contract_history hb h i hi f + refine ⟨r, ?_⟩ + intro xs hxs + change contract i (w.eval f) xs = optionEval r f xs + calc + _ = contract i (h.eval f) xs := by + apply contract_congr_length + intro ys hys + apply hr + omega + _ = optionEval r f xs := hr' xs hxs + +/-- Every nonempty closed planar arc diagram has zero contraction. +This is a proved normalization theorem, not a loop-cancellation assumption. -/ +theorem closed_word_zero (w : PlanarWord 0 0) (hw : w ≠ .start) (f : State) : + w.eval f [] = 0 := by + cases w with + | start => exact (hw rfl).elim + | erase w i hi => + have hi0 : i=0 := by omega + subst i + obtain ⟨r,hr⟩ := word_normal_form (by omega : 0 ≤ 1) w f + change contract 0 (w.eval f) [] = 0 + have hc : contract 0 (w.eval f) [] = contract 0 (optionEval r f) [] := by + apply contract_congr_length + intro ys hys + apply hr + simpa using hys + rw [hc] + cases r with + | none => exact congrFun (contract_zero 0) [] + | some h => + cases h with + | insert q j hj => + have hj0 : j=0 := by omega + subst j + exact congrFun (contract_create_same 0 (q.eval f)) [] + +/-- A one-strand planar rectangle is either killed by a loop or acts as +identity on its specified orientation. This gives the phase-1 alternative +used for a surviving right-to-left path in the physical matrix expansion. -/ +theorem one_strand_zero_or_identity (w : PlanarWord 1 0) (f : State) : + (∀ a : Bool, w.eval f [a] = 0) ∨ (∀ a : Bool, w.eval f [a] = f [a]) := by + obtain ⟨r,hr⟩ := word_normal_form (by omega : 1 ≤ 1) w f + cases r with + | none => exact Or.inl (fun a => hr [a] (by simp)) + | some h => + cases h with + | base => exact Or.inr (fun a => hr [a] (by simp)) + + +/-! Finite dilute networks. The following operator acts on the *actual* three +spin states (vacant and two occupied orientations); it is the planar local +matrix `P R` in the source. No loop-erasure hypothesis enters this definition. -/ +abbrev Spin := Option Bool +abbrev DiluteState := List Spin → ℂ + +def occupancy (xs : List Spin) : List Bool := xs.map Option.isSome +def orientations (xs : List Spin) : List Bool := xs.filterMap id +noncomputable def embed (o : List Bool) (f : State) : DiluteState := + fun xs => if occupancy xs = o then f (orientations xs) else 0 + +lemma embed_add (o : List Bool) (f g : State) : + embed o (fun xs => f xs + g xs) = fun xs => embed o f xs + embed o g xs := by + funext xs + simp only [embed] + split <;> simp +lemma embed_smul (o : List Bool) (z : ℂ) (f : State) : + embed o (fun xs => z * f xs) = fun xs => z * embed o f xs := by + funext xs + simp only [embed] + split <;> simp +lemma embed_zero (o : List Bool) : embed o (fun _ => 0) = fun _ => 0 := by + funext xs; simp [embed] +@[simp] lemma embed_false (o : List Bool) (f : State) (xs : List Spin) : + embed (false::o) f (none::xs) = embed o f xs := by + simp [embed, occupancy, orientations] +@[simp] lemma embed_true (o : List Bool) (f : State) (a : Bool) (xs : List Spin) : + embed (true::o) f (some a::xs) = embed o (fun ys => f (a::ys)) xs := by + simp [embed, occupancy, orientations] +@[simp] lemma embed_false_some (o : List Bool) (f : State) (a : Bool) (xs : List Spin) : + embed (false::o) f (some a::xs) = 0 := by simp [embed,occupancy] +@[simp] lemma embed_true_none (o : List Bool) (f : State) (xs : List Spin) : + embed (true::o) f (none::xs) = 0 := by simp [embed,occupancy] +@[simp] lemma embed_cons_nil (a : Bool) (o : List Bool) (f : State) : + embed (a::o) f [] = 0 := by simp [embed,occupancy] + +structure TileWeights where + a : ℂ + h : ℂ + v : ℂ + c : ℂ + d : ℂ + +noncomputable def tile (t : TileWeights) : Spin → Spin → Spin → Spin → ℂ + | none, none, none, none => 1 + | some i, none, some k, none => if i=k then t.a else 0 + | none, some i, none, some k => if i=k then t.a else 0 + | some i, none, none, some k => if i=k then t.v else 0 + | none, some i, some k, none => if i=k then t.v else 0 + | some i, some j, none, none => t.h * cup i j + | none, none, some k, some l => t.h * cup k l + | some i, some j, some k, some l => + (if i=k ∧ j=l then t.c else 0) + t.d * cup i j * cup k l + | _,_,_,_ => 0 + +noncomputable def act (t : TileWeights) : ℕ → DiluteState → DiluteState + | 0, f, x::y::xs => ∑ a : Spin, ∑ b : Spin, tile t x y a b * f (a::b::xs) + | 0, _, _ => 0 + | i+1, f, x::xs => act t i (fun ys => f (x::ys)) xs + | _+1, _, [] => 0 + +lemma act_add (t : TileWeights) (i : ℕ) (f g : DiluteState) : + act t i (fun xs => f xs + g xs) = fun xs => act t i f xs + act t i g xs := by + induction i generalizing f g with + | zero => + funext xs + cases xs with + | nil => simp [act] + | cons a xs => cases xs <;> simp [act, mul_add, Finset.sum_add_distrib] + | succ i ih => + funext xs + cases xs with + | nil => simp [act] + | cons a xs => exact congrFun (ih (fun ys => f (a::ys)) (fun ys => g (a::ys))) xs +lemma act_smul (t : TileWeights) (i : ℕ) (z : ℂ) (f : DiluteState) : + act t i (fun xs => z * f xs) = fun xs => z * act t i f xs := by + induction i generalizing f with + | zero => + funext xs + cases xs with + | nil => simp [act] + | cons a xs => cases xs <;> simp [act, mul_left_comm, mul_add] + | succ i ih => + funext xs + cases xs with + | nil => simp [act] + | cons a xs => exact congrFun (ih (fun ys => f (a::ys))) xs +lemma act_zero (t : TileWeights) (i : ℕ) : act t i (fun _ => 0) = fun _ => 0 := by + simpa only [zero_mul] using act_smul t i 0 (fun _ => 0) + +lemma act_empty_pair (t : TileWeights) (o : List Bool) (f : State) : + act t 0 (embed (false::false::o) f) = fun xs => + embed (false::false::o) f xs + t.h * embed (true::true::o) (create 0 f) xs := by + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases xs with + | nil => cases x <;> simp [act] + | cons y xs => + fin_cases x <;> fin_cases y <;> + simp [act, tile, Fintype.sum_option, create, embed, occupancy, orientations, mul_assoc] + +lemma act_left_pair (t : TileWeights) (o : List Bool) (f : State) : + act t 0 (embed (true::false::o) f) = fun xs => + t.a * embed (true::false::o) f xs + t.v * embed (false::true::o) f xs := by + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases xs with + | nil => cases x <;> simp [act] + | cons y xs => + fin_cases x <;> fin_cases y <;> + simp [act, tile, Fintype.sum_option, embed, occupancy, orientations] + +lemma act_right_pair (t : TileWeights) (o : List Bool) (f : State) : + act t 0 (embed (false::true::o) f) = fun xs => + t.a * embed (false::true::o) f xs + t.v * embed (true::false::o) f xs := by + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases xs with + | nil => cases x <;> simp [act] + | cons y xs => + fin_cases x <;> fin_cases y <;> + simp [act, tile, Fintype.sum_option, embed, occupancy, orientations] + +lemma act_full_pair (t : TileWeights) (o : List Bool) (f : State) : + act t 0 (embed (true::true::o) f) = fun xs => + t.c * embed (true::true::o) f xs + + t.h * embed (false::false::o) (contract 0 f) xs + + t.d * embed (true::true::o) (create 0 (contract 0 f)) xs := by + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases xs with + | nil => cases x <;> simp [act] + | cons y xs => + fin_cases x <;> fin_cases y <;> + simp [act, tile, Fintype.sum_option, contract, create, + Finset.sum_add_distrib, add_mul, mul_assoc, embed, occupancy, orientations] <;> split_ifs <;> ring + + +lemma act_empty_at (t : TileWeights) (pre o : List Bool) (f : State) : + act t pre.length (embed (pre ++ false::false::o) f) = fun xs => + embed (pre ++ false::false::o) f xs + + t.h * embed (pre ++ true::true::o) (create (pre.count true) f) xs := by + induction pre generalizing f with + | nil => exact act_empty_pair t o f + | cons b pre ih => + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases b <;> cases x with + | none => simp [act, ih, act_zero] + | some a => + simp [act, create_prefix, act_zero, ih] + +lemma act_left_at (t : TileWeights) (pre o : List Bool) (f : State) : + act t pre.length (embed (pre ++ true::false::o) f) = fun xs => + t.a * embed (pre ++ true::false::o) f xs + + t.v * embed (pre ++ false::true::o) f xs := by + induction pre generalizing f with + | nil => exact act_left_pair t o f + | cons b pre ih => + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases b <;> cases x with + | none => simp [act, ih, act_zero] + | some a => + simp [act, act_zero, ih] + +lemma act_right_at (t : TileWeights) (pre o : List Bool) (f : State) : + act t pre.length (embed (pre ++ false::true::o) f) = fun xs => + t.a * embed (pre ++ false::true::o) f xs + + t.v * embed (pre ++ true::false::o) f xs := by + induction pre generalizing f with + | nil => exact act_right_pair t o f + | cons b pre ih => + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases b <;> cases x with + | none => simp [act, ih, act_zero] + | some a => + simp [act, act_zero, ih] + +lemma act_full_at (t : TileWeights) (pre o : List Bool) (f : State) : + act t pre.length (embed (pre ++ true::true::o) f) = fun xs => + t.c * embed (pre ++ true::true::o) f xs + + t.h * embed (pre ++ false::false::o) (contract (pre.count true) f) xs + + t.d * embed (pre ++ true::true::o) (create (pre.count true) (contract (pre.count true) f)) xs := by + induction pre generalizing f with + | nil => exact act_full_pair t o f + | cons b pre ih => + funext xs + cases xs with + | nil => simp [act] + | cons x xs => + cases b <;> cases x with + | none => simp [act, ih, act_zero] + | some a => + simp [act, create_prefix, contract_prefix, act_zero, ih] + + +/-- Finite linear combinations of sliced planar diagrams with no incoming +occupied strand. The count equality fixes the exact frontier arity. -/ +inductive PlanarSpan (n : ℕ) : DiluteState → Prop + | zero : PlanarSpan n (fun _ => 0) + | basis (o : List Bool) (k : ℕ) (w : PlanarWord 0 k) + (hl : o.length = n) (hc : o.count true = 2*k) : + PlanarSpan n (embed o (w.eval (fun _ => 1))) + | add {f g : DiluteState} (hf : PlanarSpan n f) (hg : PlanarSpan n g) : + PlanarSpan n (fun xs => f xs + g xs) + | smul (z : ℂ) {f : DiluteState} (hf : PlanarSpan n f) : + PlanarSpan n (fun xs => z * f xs) + +lemma two_at (o : List Bool) (i : ℕ) (hi : i+1 < o.length) : + ∃ pre : List Bool, ∃ a b : Bool, ∃ post : List Bool, + o = pre ++ a::b::post ∧ pre.length = i := by + induction i generalizing o with + | zero => + cases o with + | nil => simp at hi + | cons a o => + cases o with + | nil => simp at hi + | cons b post => exact ⟨[],a,b,post,rfl,rfl⟩ + | succ i ih => + cases o with + | nil => simp at hi + | cons a o => + obtain ⟨pre,b,c,post,ho,hpre⟩ := ih o (by simpa using hi) + exact ⟨a::pre,b,c,post,by simp [ho],by simp [hpre]⟩ + +lemma act_span (t : TileWeights) {n i : ℕ} (hi : i+1 rw [act_zero]; exact .zero + | add hf hg ihf ihg => rw [act_add]; exact .add ihf ihg + | smul z hf ihf => rw [act_smul]; exact .smul z ihf + | basis o k w hl hc => + obtain ⟨pre,a,b,post,rfl,hpre⟩ := two_at o i (by omega) + subst i + cases a <;> cases b + · rw [act_empty_at] + apply PlanarSpan.add (.basis _ k w hl hc) + apply PlanarSpan.smul + have hip : pre.count true ≤ 0+2*k := by simp [List.count_append] at hc; omega + exact .basis _ (k+1) (.insert w (pre.count true) hip) + (by simpa using hl) (by simp_all [List.count_append]; omega) + · rw [act_right_at] + exact .add (.smul _ (.basis _ k w hl hc)) + (.smul _ (.basis _ k w (by simpa using hl) + (by simpa [List.count_append, List.count_cons] using hc))) + · rw [act_left_at] + exact .add (.smul _ (.basis _ k w hl hc)) + (.smul _ (.basis _ k w (by simpa using hl) + (by simpa [List.count_append, List.count_cons] using hc))) + · have hk : 0 1)) [] = 0 := by + exact closed_word_zero (.erase w i hi) (by intro h; cases h) (fun _ => 1) + +lemma act_basis_vacuum (t : TileWeights) {n i : ℕ} (hi : i+1 1))) (List.replicate n none) = + embed o (w.eval (fun _ => 1)) (List.replicate n none) := by + obtain ⟨pre,a,b,post,rfl,hpre⟩ := two_at o i (by omega) + subst i + cases a <;> cases b + · rw [act_empty_at] + simp only + rw [embed_vacuum_pos (pre ++ true::true::post) _ n (by simp [List.count_append])] + ring + · rw [act_right_at] + simp only + rw [embed_vacuum_pos _ _ n (by simp [List.count_append])] + rw [embed_vacuum_pos _ _ n (by simp [List.count_append])] + ring + · rw [act_left_at] + simp only + rw [embed_vacuum_pos _ _ n (by simp [List.count_append])] + rw [embed_vacuum_pos _ _ n (by simp [List.count_append])] + ring + · rw [act_full_at] + simp only + have hpos : 0 < (pre ++ true::true::post).count true := by simp [List.count_append] + simp only [embed_vacuum_pos (pre ++ true::true::post) _ n hpos] + have hzero : embed (pre ++ false::false::post) + (contract (pre.count true) (w.eval (fun _ => 1))) (List.replicate n none)=0 := by + by_cases hp : 0<(pre ++ false::false::post).count true + · exact embed_vacuum_pos _ _ n hp + · apply embed_vacuum_zero + have he : (pre ++ false::false::post).count true = pre.count true + post.count true := by simp + have ht : (pre ++ true::true::post).count true = pre.count true + post.count true + 2 := by simp; omega + rw [he] at hp + rw [ht] at hc + have hk : k=1 := by omega + subst k + apply erased_empty + omega + rw [hzero] + ring + +lemma act_vacuum (t : TileWeights) {n i : ℕ} (hi : i+1 simp [act_zero] + | basis o k w hl hc => exact act_basis_vacuum t hi o k w hl hc + | add hf hg ihf ihg => simp only [act_add, ihf, ihg] + | smul z hf ihf => simp only [act_smul, ihf] + +/-- A sequence of arbitrary nearest-neighbor dilute planar tiles cannot +change the vacuum-to-vacuum coefficient. Nonempty closed diagrams cancel; +this is the finite-network statement used in the physical crossing proof. -/ +theorem circuit_vacuum (n : ℕ) (gates : List (TileWeights × ℕ)) + (hg : ∀ g ∈ gates, g.2+1 act g.1 g.2 f) + (embed (List.replicate n false) (fun _ => 1))) (List.replicate n none) = 1 := by + have general : ∀ (gs : List (TileWeights × ℕ)) (f : DiluteState), + (∀ g ∈ gs, g.2+1 act g.1 g.2 f) f (List.replicate n none) = + f (List.replicate n none) := by + intro gs + induction gs with + | nil => intro f _ _; rfl + | cons g gs ih => + intro f hg hf + rw [List.foldl_cons, ih _ (by aesop) (act_span g.1 (hg g (by simp)) hf)] + exact act_vacuum g.1 (hg g (by simp)) hf + have hf : PlanarSpan n (embed (List.replicate n false) (fun _ => 1)) := + PlanarSpan.basis (List.replicate n false) 0 .start (by simp) (by simp [List.count_replicate]) + rw [general gates _ hg hf] + simp [embed, occupancy] + + +/-- The manuscript's spin order is +,0,-; vacancies are not weighted. -/ +def spinIndex : Spin → Fin 3 + | none => 1 + | some false => 0 + | some true => 2 + +noncomputable def sourcePhase : ℂ := + Complex.exp (((2*(Real.pi/8):ℝ):ℂ)*Complex.I) +lemma sourcePhase_eq : sourcePhase = phase := by + unfold sourcePhase phase + congr 3 + ring + +/-- Verbatim source local R entries. -/ +noncomputable def sourceR (t : TileWeights) (p q : Fin 3 × Fin 3) : ℂ := + match p.1.val, p.2.val, q.1.val, q.2.val with + | 0, 0, 0, 0 => t.c + | 2, 2, 2, 2 => t.c + | 0, 1, 0, 1 | 1, 0, 1, 0 | 2, 1, 2, 1 | 1, 2, 1, 2 => t.v + | 0, 1, 1, 0 | 1, 0, 0, 1 | 2, 1, 1, 2 | 1, 2, 2, 1 => t.a + | 0, 2, 0, 2 => t.d + | 0, 2, 1, 1 => t.h / sourcePhase + | 0, 2, 2, 0 => t.c+t.d/sourcePhase^2 + | 1, 1, 0, 2 => t.h*sourcePhase + | 1, 1, 1, 1 => 1 + | 1, 1, 2, 0 => t.h/sourcePhase + | 2, 0, 0, 2 => t.c+t.d*sourcePhase^2 + | 2, 0, 1, 1 => t.h*sourcePhase + | 2, 0, 2, 0 => t.d + | _, _, _, _ => 0 + +/-- The circuit tiles are exactly P R, not a substituted planar model. -/ +theorem tile_eq_sourceR (t : TileWeights) (i j k l : Spin) : + tile t i j k l = sourceR t (spinIndex j, spinIndex i) (spinIndex k, spinIndex l) := by + fin_cases i <;> fin_cases j <;> fin_cases k <;> fin_cases l <;> + simp [tile, sourceR, spinIndex, cup, sourcePhase_eq, phase_ne_zero, div_eq_mul_inv] <;> + ring + + +/-- Introduce two vacant auxiliary wires at the input boundary. -/ +noncomputable def addAux (f : DiluteState) : DiluteState + | none::none::xs => f xs + | _ => 0 + +/-- Cap two vacant auxiliary wires at the output boundary. Boundary K is +implemented by one adjacent tile before this cap. -/ +noncomputable def removeAux (f : DiluteState) : DiluteState := + fun xs => f (xs ++ [none,none]) + +lemma addAux_embed (o : List Bool) (f : State) : + addAux (embed o f) = embed (false::false::o) f := by + funext xs + cases xs with + | nil => simp [addAux] + | cons x xs => + cases xs with + | nil => cases x <;> simp [addAux] + | cons y xs => cases x <;> cases y <;> simp [addAux] + +lemma removeAux_embed (o : List Bool) (a b : Bool) (f : State) : + removeAux (embed (o ++ [a,b]) f) = + if a=false ∧ b=false then embed o f else fun _ => 0 := by + funext xs + have heq : occupancy (xs ++ [none,none]) = o ++ [a,b] ↔ + occupancy xs = o ∧ a=false ∧ b=false := by + simp only [occupancy, List.map_append] + constructor + · intro h + have hh := List.append_inj' h (by simp) + simpa using hh + · rintro ⟨rfl,rfl,rfl⟩ + rfl + simp only [removeAux,embed,heq,orientations,List.filterMap_append] + cases a <;> cases b <;> simp [embed,orientations] + +lemma addAux_span {n : ℕ} {f : DiluteState} (hf : PlanarSpan n f) : + PlanarSpan (n+2) (addAux f) := by + induction hf with + | zero => + have h : addAux (fun _ => 0) = fun _ => 0 := by + funext xs; cases xs with + | nil => rfl + | cons x xs => cases xs with + | nil => cases x <;> rfl + | cons y xs => cases x <;> cases y <;> rfl + rw [h]; exact .zero + | basis o k w hl hc => + rw [addAux_embed] + exact .basis _ k w (by simp [hl]) (by simpa using hc) + | add hf hg ihf ihg => + have h : ∀ f g, addAux (fun xs => f xs + g xs) = + fun xs => addAux f xs + addAux g xs := by + intro f g; funext xs; cases xs with + | nil => simp [addAux] + | cons x xs => cases xs with + | nil => cases x <;> simp [addAux] + | cons y xs => cases x <;> cases y <;> simp [addAux] + rw [h]; exact .add ihf ihg + | smul z hf ihf => + have h : ∀ f, addAux (fun xs => z * f xs) = fun xs => z * addAux f xs := by + intro f; funext xs; cases xs with + | nil => simp [addAux] + | cons x xs => cases xs with + | nil => cases x <;> simp [addAux] + | cons y xs => cases x <;> cases y <;> simp [addAux] + rw [h]; exact .smul z ihf + +lemma removeAux_span {n : ℕ} {f : DiluteState} (hf : PlanarSpan (n+2) f) : + PlanarSpan n (removeAux f) := by + induction hf with + | zero => exact .zero + | add hf hg ihf ihg => exact .add ihf ihg + | smul z hf ihf => exact .smul z ihf + | basis o k w hl hc => + obtain ⟨pre,a,b,post,rfl,hpre⟩ := two_at o n (by omega) + have hp : post=[] := List.length_eq_zero_iff.mp (by simp at hl; omega) + subst post + rw [removeAux_embed] + split_ifs with hab + · rcases hab with ⟨rfl,rfl⟩ + exact .basis _ k w hpre (by simpa using hc) + · exact .zero + +lemma gates_span {n : ℕ} (gs : List (TileWeights × ℕ)) + (hg : ∀ g ∈ gs, g.2+1 act g.1 g.2 f) f) := by + induction gs generalizing f with + | nil => exact hf + | cons g gs ih => exact ih (by aesop) (act_span g.1 (hg g (by simp)) hf) + +lemma gates_vacuum {n : ℕ} (gs : List (TileWeights × ℕ)) + (hg : ∀ g ∈ gs, g.2+1 act g.1 g.2 f) f (List.replicate n none) = + f (List.replicate n none) := by + induction gs generalizing f with + | nil => rfl + | cons g gs ih => + rw [List.foldl_cons, ih (by aesop) (act_span g.1 (hg g (by simp)) hf)] + exact act_vacuum g.1 (hg g (by simp)) hf + +noncomputable def auxNetwork (gs : List (TileWeights × ℕ)) (f : DiluteState) : DiluteState := + removeAux (gs.foldl (fun f g => act g.1 g.2 f) (addAux f)) + +lemma auxNetwork_span {n : ℕ} (gs : List (TileWeights × ℕ)) + (hg : ∀ g ∈ gs, g.2+1 1 + | some a,some b => k * cup a b + | _,_ => 0 + +lemma boundary_input (k : ℂ) (a b : Spin) : + tile (boundaryWeights k) a b none none = K k a b := by + cases a <;> cases b <;> rfl +lemma boundary_output (k : ℂ) (a b : Spin) : + tile (boundaryWeights k) none none a b = K k a b := by + cases a <;> cases b <;> rfl + + +/-- The unswapped source R matrix, in the vacant/occupied encoding. -/ +noncomputable def rEntry (t : TileWeights) (a b p q : Spin) : ℂ := + sourceR t (spinIndex a, spinIndex b) (spinIndex p, spinIndex q) + +/-- Source R_{aux,i}: the auxiliary is the first wire, physical site i +is at position i+1. All other wires are spectators. -/ +noncomputable def rAux (t : TileWeights) : ℕ → DiluteState → DiluteState + | 0, f, a::b::xs => ∑ p : Spin, ∑ q : Spin, rEntry t a b p q * f (p::q::xs) + | 0, _, _ => 0 + | i+1, f, a::b::xs => + rAux t i (fun zs => match zs with + | p::ys => f (p::b::ys) + | [] => 0) (a::xs) + | _+1, _, _ => 0 + +/-- Move the auxiliary from the front to position i, preserving the +order of all physical sites. This is only a permutation, not a trace. -/ +noncomputable def moveAux : ℕ → DiluteState → DiluteState + | 0, f => f + | i+1, f => fun xs => match xs with + | x::ys => moveAux i (fun zs => match zs with + | a::ws => f (a::x::ws) + | [] => 0) ys + | [] => 0 + +lemma rAux_nil (t : TileWeights) (i : ℕ) (f : DiluteState) : + rAux t i f [] = 0 := by cases i <;> rfl +lemma rAux_singleton (t : TileWeights) (i : ℕ) (f : DiluteState) (a : Spin) : + rAux t i f [a] = 0 := by cases i <;> rfl + +/-- The exact local permutation identity behind the planar row drawing. -/ +theorem act_moveAux (t : TileWeights) (i : ℕ) (f : DiluteState) : + act t i (moveAux i f) = moveAux (i+1) (rAux t i f) := by + induction i generalizing f with + | zero => + funext xs + cases xs with + | nil => rfl + | cons a xs => cases xs with + | nil => rfl + | cons b xs => + simp only [act,moveAux,rAux,rEntry] + apply Finset.sum_congr rfl + intro p hp + apply Finset.sum_congr rfl + intro q hq + rw [tile_eq_sourceR] + | succ i ih => + funext xs + cases xs with + | nil => rfl + | cons x xs => + simp only [act,moveAux] + rw [ih] + congr 1 + +/-- Apply a row in visiting order; source U is this composition with +its physical sites listed N,...,1, since the rightmost matrix acts first. -/ +noncomputable def unswappedRow : ℕ → List TileWeights → DiluteState → DiluteState + | _, [], f => f + | i, t::ts, f => unswappedRow (i+1) ts (rAux t i f) + +noncomputable def planarRow : ℕ → List TileWeights → DiluteState → DiluteState + | _, [], f => f + | i, t::ts, f => planarRow (i+1) ts (act t i f) + +/-- A whole row of adjacent P R gates is exactly the source row of R +matrices followed by moving its auxiliary wire to the output. -/ +theorem planarRow_eq (i : ℕ) (ts : List TileWeights) (f : DiluteState) : + planarRow i ts (moveAux i f) = + moveAux (i+ts.length) (unswappedRow i ts f) := by + induction ts generalizing i f with + | nil => rfl + | cons t ts ih => + simp only [planarRow,unswappedRow,List.length_cons] + rw [act_moveAux,ih] + congr 1 + omega + + +lemma moveAux_at (pre : List Spin) (a : Spin) (post : List Spin) (f : DiluteState) : + moveAux pre.length f (pre ++ a::post) = f (a::(pre++post)) := by + induction pre generalizing f with + | nil => rfl + | cons x pre ih => + simp only [List.length_cons,List.cons_append,moveAux] + rw [ih] + +lemma rAux_at (t : TileWeights) (pre : List Spin) (a b : Spin) + (post : List Spin) (f : DiluteState) : + rAux t pre.length f (a::(pre++b::post)) = + ∑ p : Spin, ∑ q : Spin, rEntry t a b p q * f (p::(pre++q::post)) := by + induction pre generalizing f with + | nil => rfl + | cons x pre ih => + simp only [List.length_cons,List.cons_append,rAux] + rw [ih] + +lemma act_at (t : TileWeights) (pre : List Spin) (a b : Spin) + (post : List Spin) (f : DiluteState) : + act t pre.length f (pre++a::b::post) = + ∑ p : Spin, ∑ q : Spin, tile t a b p q * f (pre++p::q::post) := by + induction pre generalizing f with + | nil => rfl + | cons x pre ih => + simpa only [List.length_cons,List.cons_append,act] using + ih (fun xs => f (x::xs)) + +/-- Lift an operator through a spectator wire. -/ +noncomputable def behind (F : DiluteState → DiluteState) (f : DiluteState) : DiluteState + | a::xs => F (fun ys => f (a::ys)) xs + | [] => 0 + +lemma act_behind (t : TileWeights) (i : ℕ) (F : DiluteState → DiluteState) + (f : DiluteState) : + act t (i+1) (behind F f) = behind (fun g => act t i (F g)) f := by + funext xs + cases xs <;> rfl + +lemma planarRow_behind (i : ℕ) (ts : List TileWeights) + (F : DiluteState → DiluteState) (f : DiluteState) : + planarRow (i+1) ts (behind F f) = behind (fun g => planarRow i ts (F g)) f := by + induction ts generalizing i F f with + | nil => rfl + | cons t ts ih => + simp only [planarRow,act_behind] + rw [ih] + +/-- Equivalence of coordinates when B is moved past n physical sites, +with the A auxiliary fixed at the front. -/ +def BCoordinates (n : ℕ) (f g : DiluteState) : Prop := + ∀ (a b : Spin) (xs : List Spin), xs.length=n → + f (a::(xs++[b])) = g (a::b::xs) + +lemma behind_move_B (n : ℕ) (f : DiluteState) : + BCoordinates n (behind (moveAux n) f) f := by + intro a b xs hx + simp only [behind] + rw [← hx,moveAux_at] + simp + +lemma one_at {α : Type*} (xs : List α) (i : ℕ) (hi : i + cases xs with + | nil => simp at hi + | cons x xs => exact ⟨[],x,xs,rfl,rfl⟩ + | succ i ih => + cases xs with + | nil => simp at hi + | cons x xs => + obtain ⟨pre,y,post,hp,hl⟩ := ih xs (by simpa using hi) + exact ⟨x::pre,y,post,by simp [hp],by simp [hl]⟩ + +lemma rAux_BCoordinates {n i : ℕ} (hi : i exact h + | cons t ts ih => + exact ih (by simp at hi; omega) (rAux_BCoordinates (by simp at hi; omega) t h) + +lemma planarRow_under (i : ℕ) (ts : List TileWeights) (f : DiluteState) + (a : Spin) (xs : List Spin) : + planarRow (i+1) ts f (a::xs) = planarRow i ts (fun ys => f (a::ys)) xs := by + induction ts generalizing i f with + | nil => rfl + | cons t ts ih => + simpa only [planarRow,act] using ih (i+1) (act t (i+1) f) + +lemma planarRow_BCoordinates (ts : List TileWeights) {n : ℕ} (hn : ts.length=n) + (f : DiluteState) : + BCoordinates n (planarRow 1 ts f) (behind (unswappedRow 0 ts) f) := by + intro a b xs hx + rw [planarRow_under 0] + change planarRow 0 ts (moveAux 0 (fun ys => f (a::ys))) (xs++[b]) = _ + rw [planarRow_eq] + simp only [Nat.zero_add] + rw [hn,←hx,moveAux_at] + simp [behind] + +/-- Source U_A U_B in its original, unswapped spin labels A,B,sites. -/ +noncomputable def sourceTwoRows (tsA tsB : List TileWeights) (f : DiluteState) : DiluteState := + unswappedRow 1 tsA (behind (unswappedRow 0 tsB) f) + +lemma two_rows_eq {n : ℕ} (tsA tsB : List TileWeights) + (hA : tsA.length=n) (hB : tsB.length=n) (f : DiluteState) + (xs : List Spin) (hx : xs.length=n) (a b : Spin) : + planarRow 0 tsA (planarRow 1 tsB f) (xs++[a,b]) = + sourceTwoRows tsA tsB f (a::b::xs) := by + change planarRow 0 tsA (moveAux 0 (planarRow 1 tsB f)) (xs++[a,b]) = _ + rw [planarRow_eq] + simp only [Nat.zero_add] + rw [hA,←hx,moveAux_at] + exact unswappedRow_BCoordinates tsA (by omega) + (planarRow_BCoordinates tsB hB f) a b xs hx + +end CriticalHoneycomb.Transfer.PlanarNormalization + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PlanarRows.lean b/lean/OAI/Combinatorics/HoneycombChords/PlanarRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..35079b7daa005f664e0d9057b89da163c8cd7459 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PlanarRows.lean @@ -0,0 +1,136 @@ +import OAI.Combinatorics.HoneycombChords.BoundarySystems + +namespace OAI + +/-! Planar rows for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped Matrix +lemma act_congr_of_length (t : TileWeights) (i n : ℕ) (f g : DiluteState) + (h : ∀ xs,xs.length=n→f xs=g xs) (xs : List Spin) (hx : xs.length=n) : + act t i f xs=act t i g xs := by + induction i generalizing xs f g n with + | zero => + cases xs with + | nil => rfl + | cons a xs => + cases xs with + | nil => rfl + | cons b xs => + simp only [act] + apply Finset.sum_congr rfl + intro c hc + apply Finset.sum_congr rfl + intro d hd + rw [h (c::d::xs) (by simpa using hx)] + | succ i ih => + cases xs with + | nil => rfl + | cons a xs => + apply ih (n:=xs.length) (fun ys =>f (a::ys)) (fun ys=>g (a::ys)) _ xs rfl + intro ys hy + exact h (a::ys) (by simpa [hy] using hx) +lemma planarRow_congr_of_length (i n : ℕ) (ts : List TileWeights) (f g : DiluteState) + (h : ∀ xs,xs.length=n→f xs=g xs) (xs : List Spin) (hx : xs.length=n) : + planarRow i ts f xs=planarRow i ts g xs := by + induction ts generalizing i f g with + | nil => exact h xs hx + | cons t ts ih => + apply ih + intro ys hy + exact act_congr_of_length t i n f g h ys hy +lemma act_suffix (t : TileWeights) (i : ℕ) (f : DiluteState) + (xs tail : List Spin) (hi : i+1f (ys++tail)) xs := by + induction i generalizing xs f with + | zero => + cases xs with + | nil => simp at hi + | cons a xs => + cases xs with + | nil => simp at hi + | cons b xs => rfl + | succ i ih => + cases xs with + | nil => simp at hi + | cons a xs => + exact ih (fun ys=>f (a::ys)) xs (by simpa using hi) +lemma planarRow_suffix (i : ℕ) (ts : List TileWeights) (f : DiluteState) + (xs tail : List Spin) (hi : i+ts.lengthf (ys++tail)) xs := by + induction ts generalizing i f with + | nil => rfl + | cons t ts ih => + simp only [planarRow] + rw [ih (i+1) (act t i f) (by simp at hi;omega)] + apply planarRow_congr_of_length (i+1) xs.length ts _ _ _ xs rfl + intro ys hy + exact act_suffix t i f ys tail (by simp at hi;omega) +lemma planarRow_zero (i : ℕ) (ts : List TileWeights) : + planarRow i ts (fun _=>0)=(fun _=>0) := by + induction ts generalizing i with + | nil => rfl + | cons t ts ih => + have hz : act t i (fun _=>0)=(fun _=>0) := by + funext xs + induction i generalizing xs with + | zero => cases xs with + | nil => rfl + | cons a xs => cases xs <;> simp [act] + | succ i ih => cases xs with + | nil => rfl + | cons a xs => exact ih xs + simp only [planarRow,hz,ih] +noncomputable def seedAux (k : ℂ) (f : DiluteState) : DiluteState + | a::b::xs => K k a b * f xs + | _ => 0 +lemma seedAux_zero (f : DiluteState) : seedAux 0 f=addAux f := by + funext xs + cases xs with + | nil => rfl + | cons a xs => cases xs with + | nil => cases a <;> rfl + | cons b xs => cases a <;> cases b <;> simp [seedAux,K,addAux] + +noncomputable def hardDoubleRow (t : TileWeights) (n : ℕ) (f : DiluteState) : DiluteState := + fun xs=>∑ a : Spin,∑ b : Spin,K 0 a b* + sourceTwoRows (List.replicate n t) (List.replicate n t) (seedAux 0 f) (a::b::xs) +lemma hardDoubleRow_eq_columns (t : TileWeights) (n : ℕ) (f : DiluteState) + (xs : List Spin) (hx : xs.length=n) : + hardDoubleRow t n f xs=vacuumColumn t n (vacuumColumn t n f) xs := by + classical + simp only [hardDoubleRow,Fintype.sum_option,Fintype.sum_bool,K,zero_mul,one_mul,add_zero,seedAux_zero] + rw [←two_rows_eq (List.replicate n t) (List.replicate n t) (by simp) (by simp) _ xs hx none none] + rw [show xs++[none,none]=(xs++[none])++[none] by simp] + rw [planarRow_suffix 0 _ _ (xs++[none]) [none] (by simp [hx])] + change _=planarRow 0 (List.replicate n t) (addOne (vacuumColumn t n f)) (xs++[none]) + apply planarRow_congr_of_length 0 (n+1) _ _ _ _ _ (by simp [hx]) + intro ys hy + cases ys with + | nil => simp at hy + | cons a ys => + simp only [List.cons_append,planarRow_under] + cases a with + | none => + have hh : (fun us=>addAux f (none::us))=addOne f := by + funext us + cases us with + | nil => rfl + | cons a us => cases a <;> rfl + rw [hh] + rfl + | some a => + have hh : (fun us=>addAux f (some a::us))=(fun _=>0) := by + funext us + cases us <;> rfl + rw [hh,planarRow_zero] + rfl +end CriticalHoneycomb.Transfer.PlanarNormalization + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Pollaczek.lean b/lean/OAI/Combinatorics/HoneycombChords/Pollaczek.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9f80f690d597a00c7edb2e44f974c063b47b2ed --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Pollaczek.lean @@ -0,0 +1,513 @@ +import OAI.Combinatorics.HoneycombChords.Meixner +import OAI.Combinatorics.HoneycombChords.PolynomialKernels +import OAI.Combinatorics.HoneycombChords.SechExpectation +import OAI.Combinatorics.HoneycombChords.TransformSurjectivity + +namespace OAI + +/-! +# Pollaczek orthogonality and polynomial kernels + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory +open Analytic +noncomputable def symmetricSechPair (f g : ℝ → ℝ) : ℝ := + ∫ p in Set.Ioi (0:ℝ),(f p*g p+f (-p)*g (-p))/Real.cosh (Real.pi*p) +lemma symmetricSechPair_comm (f g : ℝ → ℝ) : symmetricSechPair f g=symmetricSechPair g f := by + unfold symmetricSechPair + congr 1 + funext p + ring +lemma generator_prefactor (t : ℝ) : + (1+t^2)^(-(1:ℝ)/2)=Real.cos (Real.arctan t) := by + rw [Real.cos_arctan,show -(1:ℝ)/2=-((1:ℝ)/2) by ring,Real.rpow_neg (by positivity),Real.sqrt_eq_rpow] + simp only [one_div] +lemma generator_symmetric_product (t u p : ℝ) : + pollaczekGenerator p t*pollaczekGenerator p u+ + pollaczekGenerator (-p) t*pollaczekGenerator (-p) u= + 2*(Real.cos (Real.arctan t)*Real.cos (Real.arctan u))* + Real.cosh ((2*(Real.arctan t+Real.arctan u))*p) := by + simp only [pollaczekGenerator,generator_prefactor,Real.cosh_eq] + rw [show -(2*(Real.arctan t+Real.arctan u)*p)=2*(-p)*Real.arctan t+2*(-p)*Real.arctan u by ring, + show 2*(Real.arctan t+Real.arctan u)*p=2*p*Real.arctan t+2*p*Real.arctan u by ring, + Real.exp_add,Real.exp_add] + ring +lemma arctan_quarter_bound {t : ℝ} (ht : |t| < 1) : |Real.arctan t| < Real.pi/4 := by + obtain ⟨hl,hu⟩ := abs_lt.1 ht + apply abs_lt.2 + constructor + · have h := Real.arctan_strictMono hl + simpa [Real.arctan_neg,Real.arctan_one] using h + · simpa [Real.arctan_one] using Real.arctan_strictMono hu +lemma symmetricSechPair_generator {t u : ℝ} (ht : |t| < 1) (hu : |u| < 1) : + symmetricSechPair (fun p=>pollaczekGenerator p t) (fun p=>pollaczekGenerator p u)= + 1/(1-t*u) := by + have hm : |2*(Real.arctan t+Real.arctan u)| < Real.pi := by + rw [abs_mul,abs_of_pos (by norm_num : (0:ℝ)<2)] + have h := abs_add_le (Real.arctan t) (Real.arctan u) + linarith [arctan_quarter_bound ht,arctan_quarter_bound hu] + unfold symmetricSechPair + simp only [generator_symmetric_product] + simp_rw [mul_div_assoc] + rw [integral_const_mul,sech_kernel_integral Real.pi_pos hm] + have hpi : Real.pi*(2*(Real.arctan t+Real.arctan u))/(2*Real.pi)=Real.arctan t+Real.arctan u := by + field_simp + rw [hpi,Real.cos_add] + have hct := (Real.cos_arctan_pos t).ne' + have hcu := (Real.cos_arctan_pos u).ne' + have hst : Real.sin (Real.arctan t)=t*Real.cos (Real.arctan t) := by + rw [Real.sin_arctan,Real.cos_arctan];ring + have hsu : Real.sin (Real.arctan u)=u*Real.cos (Real.arctan u) := by + rw [Real.sin_arctan,Real.cos_arctan];ring + rw [hst,hsu] + have hh : Real.cos (Real.arctan t)*Real.cos (Real.arctan u)- + t*Real.cos (Real.arctan t)*(u*Real.cos (Real.arctan u))= + (Real.cos (Real.arctan t)*Real.cos (Real.arctan u))*(1-t*u) := by ring + rw [hh] + field_simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology MeasureTheory +lemma pollaczek_series_bound {H : ℝ → ℝ} {C : ℝ} (hC : 0 ≤ C) + (hH : ∀ p,|H p| ≤ C*pollaczekMajorant p) {t : ℝ} (ht : |t| ≤ 1/4) (n : ℕ) (p : ℝ) : + ‖((pollaczekCoeff p n*H p+pollaczekCoeff (-p) n*H (-p))/Real.cosh (Real.pi*p))*t^n‖ ≤ + (meixnerCoeff |p| n*(1/4)^n)*(2*C*pollaczekMajorant p/Real.cosh (Real.pi*p)) := by + have hq := pollaczekCoeff_abs_le p n + have hqm := pollaczekCoeff_abs_le (-p) n + have hh := hH p + have hhm := hH (-p) + simp only [abs_neg] at hqm + simp only [pollaczekMajorant,abs_neg] at hhm + change |H (-p)| ≤ C*pollaczekMajorant p at hhm + simp only [norm_mul,Real.norm_eq_abs,abs_div,abs_of_pos (Real.cosh_pos _),abs_pow] + have hb : |pollaczekCoeff p n*H p+pollaczekCoeff (-p) n*H (-p)| ≤ + 2*(meixnerCoeff |p| n*(C*pollaczekMajorant p)) := by + calc + _ ≤ |pollaczekCoeff p n*H p|+|pollaczekCoeff (-p) n*H (-p)| := abs_add_le _ _ + _ ≤ meixnerCoeff |p| n*(C*pollaczekMajorant p)+meixnerCoeff |p| n*(C*pollaczekMajorant p) := by + rw [abs_mul,abs_mul] + exact add_le_add (mul_le_mul hq hh (abs_nonneg _) (meixnerCoeff_nonneg (abs_nonneg p) n)) + (mul_le_mul hqm hhm (abs_nonneg _) (meixnerCoeff_nonneg (abs_nonneg p) n)) + _ = _ := by ring + calc + _ ≤ (2*(meixnerCoeff |p| n*(C*pollaczekMajorant p))/Real.cosh (Real.pi*p))*(1/4)^n := by + have hmn := meixnerCoeff_nonneg (abs_nonneg p) n + have hp := (pollaczekMajorant_pos p).le + gcongr + _ = _ := by ring +lemma pollaczek_pair_hasSum {H : ℝ → ℝ} (hHc : Continuous H) {C : ℝ} (hC : 0 ≤ C) + (hH : ∀ p,|H p| ≤ C*pollaczekMajorant p) {t : ℝ} (ht : |t| ≤ 1/4) : + HasSum (fun n => symmetricSechPair (fun p=>pollaczekCoeff p n) H*t^n) + (symmetricSechPair (fun p=>pollaczekGenerator p t) H) := by + let F : ℕ → ℝ → ℝ := fun n p => + ((pollaczekCoeff p n*H p+pollaczekCoeff (-p) n*H (-p))/Real.cosh (Real.pi*p))*t^n + let bound : ℕ → ℝ → ℝ := fun n p => + (meixnerCoeff |p| n*(1/4)^n)*(2*C*pollaczekMajorant p/Real.cosh (Real.pi*p)) + have hmeas (n : ℕ) : AEStronglyMeasurable (F n) (volume.restrict (Set.Ioi 0)) := by + apply Continuous.aestronglyMeasurable + unfold F + apply Continuous.mul _ continuous_const + apply Continuous.div _ (by fun_prop) (fun p => (Real.cosh_pos _).ne') + exact ((pollaczekCoeff_continuous n).mul hHc).add + (((pollaczekCoeff_continuous n).comp continuous_neg).mul (hHc.comp continuous_neg)) + have hb (n : ℕ) : ∀ᵐ p ∂volume.restrict (Set.Ioi 0), ‖F n p‖ ≤ bound n p := + Eventually.of_forall (pollaczek_series_bound hC hH ht n) + have hsum (p : ℝ) : HasSum (fun n => bound n p) + (2*C*(pollaczekMajorant p^2/Real.cosh (Real.pi*p))) := by + convert! (meixnerCoeff_hasSum |p| (u:=1/4) (by norm_num)).mul_right + (2*C*pollaczekMajorant p/Real.cosh (Real.pi*p)) using 1 + unfold pollaczekMajorant + ring + have hint : Integrable (fun p => ∑' n,bound n p) (volume.restrict (Set.Ioi 0)) := by + simp_rw [(hsum _).tsum_eq] + exact pollaczekMajorant_sq_integrable.const_mul (2*C) + have hlim : ∀ᵐ p ∂volume.restrict (Set.Ioi 0),HasSum (fun n=>F n p) + ((pollaczekGenerator p t*H p+pollaczekGenerator (-p) t*H (-p))/Real.cosh (Real.pi*p)) := by + apply Eventually.of_forall + intro p + convert! ((pollaczekCoeff_hasSum p (t:=t) (by linarith)).mul_right (H p) |>.add + ((pollaczekCoeff_hasSum (-p) (t:=t) (by linarith)).mul_right (H (-p)))).div_const + (Real.cosh (Real.pi*p)) using 1 + funext n + unfold F + ring + have hz := hasSum_integral_of_dominated_convergence bound hmeas hb + (Eventually.of_forall fun p => (hsum p).summable) hint hlim + simpa only [F,integral_mul_const,symmetricSechPair] using hz +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +lemma coefficients_unique {f : ℝ → ℝ} {a b : ℕ → ℝ} + (ha : ∀ᶠ t in 𝓝 0, HasSum (fun n=>a n*t^n) (f t)) + (hb : ∀ᶠ t in 𝓝 0, HasSum (fun n=>b n*t^n) (f t)) (n : ℕ) : a n=b n := by + have ha' : HasFPowerSeriesAt f (FormalMultilinearSeries.ofScalars ℝ a) 0 := + hasFPowerSeriesAt_iff.2 (by simpa only [FormalMultilinearSeries.coeff_ofScalars,smul_eq_mul,mul_comm,zero_add] using ha) + have hb' : HasFPowerSeriesAt f (FormalMultilinearSeries.ofScalars ℝ b) 0 := + hasFPowerSeriesAt_iff.2 (by simpa only [FormalMultilinearSeries.coeff_ofScalars,smul_eq_mul,mul_comm,zero_add] using hb) + exact (scalarSeries_taylor ha' n).symm.trans (scalarSeries_taylor hb' n) +lemma symmetricSechPair_coeff_generator {u : ℝ} (hu : |u| < 1/4) (n : ℕ) : + symmetricSechPair (fun p=>pollaczekCoeff p n) (fun p=>pollaczekGenerator p u)=u^n := by + refine coefficients_unique (a:=fun n => symmetricSechPair (fun p=>pollaczekCoeff p n) (fun p=>pollaczekGenerator p u)) + (b:=fun n=>u^n) (f:=fun t=>1/(1-t*u)) ?_ ?_ n + · filter_upwards [Metric.ball_mem_nhds (0:ℝ) (by norm_num : (0:ℝ)<1/4)] with t ht + have ht' : |t| < 1/4 := by simpa [Metric.mem_ball] using ht + have hs := pollaczek_pair_hasSum (pollaczekGenerator_continuous_p u) (C:=1) (by norm_num) + (fun p=>by simpa using pollaczekGenerator_majorant p hu.le) ht'.le + rw [symmetricSechPair_generator (by linarith) (by linarith)] at hs + exact hs + · filter_upwards [Metric.ball_mem_nhds (0:ℝ) (by norm_num : (0:ℝ)<1)] with t ht + have ht' : |t| < 1 := by simpa [Metric.mem_ball] using ht + have hp : ‖t*u‖ < 1 := by rw [Real.norm_eq_abs,abs_mul];nlinarith [abs_nonneg t,abs_nonneg u] + simpa [mul_pow,mul_comm,one_div] using hasSum_geometric_of_norm_lt_one hp +lemma symmetricSechPair_orthogonal (n m : ℕ) : + symmetricSechPair (fun p=>pollaczekCoeff p n) (fun p=>pollaczekCoeff p m)=if n=m then 1 else 0 := by + refine coefficients_unique (a:=fun n => symmetricSechPair (fun p=>pollaczekCoeff p n) (fun p=>pollaczekCoeff p m)) + (b:=fun n=>if n=m then 1 else 0) (f:=fun t:ℝ=>t^m) ?_ ?_ n + · filter_upwards [Metric.ball_mem_nhds (0:ℝ) (by norm_num : (0:ℝ)<1/4)] with t ht + have ht' : |t| < 1/4 := by simpa [Metric.mem_ball] using ht + have hs := pollaczek_pair_hasSum (pollaczekCoeff_continuous m) (C:=4^m) (by positivity) + (fun p=>pollaczekCoeff_majorant p m) ht'.le + rw [symmetricSechPair_comm,symmetricSechPair_coeff_generator ht'] at hs + exact hs + · apply Eventually.of_forall + intro t + convert! (hasSum_ite_eq m (t^m)) using 1 + funext j + by_cases hj : j=m <;> simp [hj] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial +lemma meixnerCoeff_pos {s : ℝ} (hs : 0 < s) (n : ℕ) : 0 < meixnerCoeff s n := by + induction n using Nat.twoStepInduction with + | zero => simp [meixnerCoeff] + | one => simp only [meixnerCoeff];positivity + | more n ih0 ih1 => rw [meixnerCoeff];positivity +lemma evenPoly_ne_zero (n : ℕ) : evenPoly (-1) n ≠ 0 := by + intro h + have he := evenPoly_negative_eval 1 n + rw [h] at he + simp only [eval_zero] at he + exact mul_ne_zero (pow_ne_zero _ (by norm_num)) (meixnerCoeff_pos (by norm_num : (0:ℝ)<1) _).ne' he.symm +lemma oddPoly_ne_zero (n : ℕ) : oddPoly (-1) n ≠ 0 := by + intro h + have he := (evenOdd_sign_eval 1 n).2 + rw [h] at he + have hh := (evenOdd_plus_eval 1 n).2 + simp only [one_pow,one_mul] at hh + rw [hh] at he + simp only [eval_zero] at he + exact mul_ne_zero (pow_ne_zero _ (by norm_num)) (meixnerCoeff_pos (by norm_num : (0:ℝ)<1) _).ne' he.symm +lemma pollaczek_evenOdd_degree (n : ℕ) : + (evenPoly (-1) n).natDegree=n ∧ (oddPoly (-1) n).natDegree=n := by + induction n with + | zero => simp + | succ n ih => + have hc2 : (2:ℝ) ≠ 0 := by norm_num + have hE : (evenPoly (-1) (n+1)).natDegree=n+1 := by + rw [evenPoly_succ,natDegree_C_mul (by positivity),mul_assoc,natDegree_add_eq_left_of_natDegree_lt] + · rw [natDegree_C_mul hc2,natDegree_X_mul (oddPoly_ne_zero n),ih.2] + · rw [natDegree_C_mul hc2,natDegree_X_mul (oddPoly_ne_zero n)] + exact (natDegree_C_mul_le _ _).trans_lt (by rw [ih.1,ih.2];omega) + refine ⟨hE,?_⟩ + rw [oddPoly_succ,natDegree_C_mul (by positivity),natDegree_add_eq_left_of_natDegree_lt] + · rw [natDegree_C_mul hc2,hE] + · rw [natDegree_C_mul hc2,hE] + exact (natDegree_C_mul_le _ _).trans_lt (by rw [ih.2];omega) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset +lemma pollaczek_span (N : ℕ) : + Submodule.span ℝ ((fun j:ℕ=>(X:Polynomial ℝ)^j) '' Set.Iio N)= + Submodule.span ℝ ((evenPoly (-1)) '' Set.Iio N) := by + apply Analytic.triangular_span (fun j:ℕ=>(X:Polynomial ℝ)^j) (evenPoly (-1)) + (fun k j => (evenPoly (-1) k).coeff j) + · intro k + have h := (evenPoly (-1) k).as_sum_range_C_mul_X_pow + rw [(pollaczek_evenOdd_degree k).1] at h + simpa only [Polynomial.smul_eq_C_mul] using h + · intro k + have h := Polynomial.leadingCoeff_ne_zero.mpr (evenPoly_ne_zero k) + rwa [←Polynomial.coeff_natDegree,(pollaczek_evenOdd_degree k).1] at h +lemma polynomial_eq_pollaczek_sum (p : Polynomial ℝ) {n : ℕ} (hn : p.natDegree ≤ n) : + ∃ a : Fin (n+1) → ℝ,∑ j,a j • evenPoly (-1) j=p := by + have hp : p ∈ Submodule.span ℝ ((fun j:ℕ=>(X:Polynomial ℝ)^j) '' Set.Iio (n+1)) := by + rw [p.as_sum_range_C_mul_X_pow' (by omega : p.natDegree < n+1)] + apply Submodule.sum_mem + intro j hj + rw [←Polynomial.smul_eq_C_mul] + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨j,mem_range.mp hj,rfl⟩) + rw [pollaczek_span] at hp + have he : (evenPoly (-1)) '' Set.Iio (n+1)=Set.range (fun j:Fin (n+1)=>evenPoly (-1) j) := by + ext p + constructor + · rintro ⟨j,hj,rfl⟩ + exact ⟨⟨j,hj⟩,rfl⟩ + · rintro ⟨j,rfl⟩ + exact ⟨j,j.isLt,rfl⟩ + rw [he] at hp + exact (Submodule.mem_span_range_iff_exists_fun ℝ).1 hp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Real MeasureTheory +lemma pow_sech_integrable (n : ℕ) {c : ℝ} (hc : 0 < c) : + IntegrableOn (fun p:ℝ=>p^n/Real.cosh (c*p)) (Set.Ioi 0) := by + have hi : IntegrableOn (fun p:ℝ=>2*(p^n*Real.exp (-c*p))) (Set.Ioi 0) := by + simpa only [IntegrableOn, Real.rpow_natCast, Real.rpow_one, neg_mul] using (integrableOn_rpow_mul_exp_neg_mul_rpow (s:=(n:ℝ)) (p:=1) + (by linarith [Nat.cast_nonneg (α:=ℝ) n]) (by norm_num) hc).const_mul 2 + have hm : Continuous (fun p:ℝ=>p^n/Real.cosh (c*p)) := + (show Continuous (fun p:ℝ=>p^n) by fun_prop).div (by fun_prop) (fun _=>(Real.cosh_pos _).ne') + apply hi.mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hp0 : 0 ≤ p := le_of_lt hp + rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)] + have hh : Real.exp (c*p)/2 ≤ Real.cosh (c*p) := by + rw [Real.cosh_eq];linarith [Real.exp_pos (-(c*p))] + calc + _ ≤ p^n/(Real.exp (c*p)/2) := div_le_div_of_nonneg_left (by positivity) (by positivity) hh + _ = _ := by rw [neg_mul,Real.exp_neg];ring +lemma polynomial_sech_integrable (P : Polynomial ℝ) {c : ℝ} (hc : 0 < c) : + IntegrableOn (fun p:ℝ=>P.eval (p^2)/Real.cosh (c*p)) (Set.Ioi 0) := by + induction P using Polynomial.induction_on' with + | add P Q hP hQ => + apply (hP.add hQ).congr + filter_upwards with p + simp only [eval_add,Pi.add_apply,add_div] + | monomial n a => + apply ((pow_sech_integrable (2*n) hc).const_mul a).congr + filter_upwards with p + simp only [eval_monomial,pow_mul] + ring +lemma polynomial_sech_pair_integrable (P Q : Polynomial ℝ) {c : ℝ} (hc : 0 < c) : + IntegrableOn (fun p:ℝ=>P.eval (p^2)*Q.eval (p^2)/Real.cosh (c*p)) (Set.Ioi 0) := by + simpa only [eval_mul] using polynomial_sech_integrable (P*Q) hc +noncomputable def polynomialSechInner (P Q : Polynomial ℝ) : ℝ := + sechExpectation Real.pi (fun x=>P.eval x*Q.eval x) +lemma polynomialSechInner_eq (P Q : Polynomial ℝ) : + polynomialSechInner P Q=2*∫ p in Set.Ioi (0:ℝ),P.eval (p^2)*Q.eval (p^2)/Real.cosh (Real.pi*p) := by + unfold polynomialSechInner sechExpectation + rw [mul_div_cancel_right₀ _ Real.pi_ne_zero] +lemma polynomialSechInner_orthogonal (n m : ℕ) : + polynomialSechInner (evenPoly (-1) n) (evenPoly (-1) m)=if n=m then 1 else 0 := by + have h := symmetricSechPair_orthogonal (2*n) (2*m) + have he : polynomialSechInner (evenPoly (-1) n) (evenPoly (-1) m)= + symmetricSechPair (fun p=>pollaczekCoeff p (2*n)) (fun p=>pollaczekCoeff p (2*m)) := by + rw [polynomialSechInner_eq,symmetricSechPair,←integral_const_mul] + apply integral_congr_ae + filter_upwards with p + rw [←(pollaczekCoeff_evenOdd p n).1,←(pollaczekCoeff_evenOdd p m).1, + ←(pollaczekCoeff_evenOdd (-p) n).1,←(pollaczekCoeff_evenOdd (-p) m).1] + simp only [neg_sq] + ring + rw [he,h] + have hnm : (2*n=2*m) ↔ n=m := by omega + simp only [hnm] +lemma polynomialSechInner_sum_left {ι : Type*} (s : Finset ι) (P : ι → Polynomial ℝ) (Q : Polynomial ℝ) : + polynomialSechInner (∑ i∈s,P i) Q=∑ i∈s,polynomialSechInner (P i) Q := by + simp only [polynomialSechInner_eq,eval_finsetSum,Finset.sum_mul,Finset.sum_div] + rw [integral_finsetSum s (fun i _=>polynomial_sech_pair_integrable _ _ Real.pi_pos),Finset.mul_sum] +lemma polynomialSechInner_smul_left (a : ℝ) (P Q : Polynomial ℝ) : + polynomialSechInner (a • P) Q=a*polynomialSechInner P Q := by + simp only [polynomialSechInner_eq,eval_smul,smul_eq_mul] + simp_rw [mul_assoc,mul_div_assoc] + rw [integral_const_mul] + ring +lemma polynomialSechInner_comm (P Q : Polynomial ℝ) : polynomialSechInner P Q=polynomialSechInner Q P := by + simp only [polynomialSechInner_eq,mul_comm] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Real Filter Topology +noncomputable def pollaczekCombination {n : ℕ} (a : Fin (n+1) → ℝ) : Polynomial ℝ := + ∑ j,a j • evenPoly (-1) j +lemma pollaczekCombination_eval {n : ℕ} (a : Fin (n+1) → ℝ) (x : ℝ) : + (pollaczekCombination a).eval x=∑ j,a j*(evenPoly (-1) j).eval x := by + simp only [pollaczekCombination,eval_finsetSum,eval_smul,smul_eq_mul] +lemma pollaczekCombination_inner {n : ℕ} (a : Fin (n+1) → ℝ) : + polynomialSechInner (pollaczekCombination a) (pollaczekCombination a)=∑ j,a j^2 := by + rw [pollaczekCombination,polynomialSechInner_sum_left] + apply sum_congr rfl + intro j _ + rw [polynomialSechInner_smul_left,polynomialSechInner_comm,polynomialSechInner_sum_left] + simp only [polynomialSechInner_smul_left,polynomialSechInner_orthogonal,Fin.val_inj, + mul_ite,mul_one,mul_zero,sum_ite_eq',mem_univ,ite_true,pow_two] +lemma pollaczekCombination_degree {n : ℕ} (a : Fin (n+1) → ℝ) : + (pollaczekCombination a).natDegree ≤ n := by + apply Polynomial.natDegree_sum_le_of_forall_le + intro j _ + exact (Polynomial.natDegree_smul_le _ _).trans (by rw [(pollaczek_evenOdd_degree j).1];omega) +noncomputable def sechChristoffelSum (n : ℕ) (x : ℝ) : ℝ := + ∑ j:Fin (n+1),((evenPoly (-1) j).eval x)^2 +lemma sechChristoffelSum_pos (n : ℕ) (x : ℝ) : 0 < sechChristoffelSum n x := by + have h := Finset.single_le_sum (f:=fun j:Fin (n+1)=>((evenPoly (-1) j).eval x)^2) + (fun j _=>sq_nonneg _) (Finset.mem_univ (⟨0,by omega⟩:Fin (n+1))) + simp only [evenPoly_zero,eval_one,one_pow] at h + exact lt_of_lt_of_le (by norm_num : (0:ℝ)<1) h +lemma polynomialSechInner_nonneg (P : Polynomial ℝ) : 0 ≤ polynomialSechInner P P := by + obtain ⟨a,ha⟩ := polynomial_eq_pollaczek_sum P le_rfl + rw [←ha] + change 0 ≤ polynomialSechInner (pollaczekCombination a) (pollaczekCombination a) + rw [pollaczekCombination_inner] + exact sum_nonneg (fun j _=>sq_nonneg _) +lemma polynomial_evaluation_bound (P : Polynomial ℝ) {n : ℕ} (hP : P.natDegree ≤ n) (x : ℝ) : + P.eval x^2 ≤ polynomialSechInner P P*sechChristoffelSum n x := by + obtain ⟨a,ha⟩ := polynomial_eq_pollaczek_sum P hP + change pollaczekCombination a=P at ha + rw [←ha,pollaczekCombination_eval,pollaczekCombination_inner] + exact sum_mul_sq_le_sq_mul_sq _ _ _ +lemma polynomial_evaluation_ratio_bound (P : Polynomial ℝ) {n : ℕ} (hP : P.natDegree ≤ n) (x : ℝ) : + P.eval x^2/polynomialSechInner P P ≤ sechChristoffelSum n x := by + rcases (polynomialSechInner_nonneg P).eq_or_lt with hz|hp + · rw [←hz,div_zero] + exact (sechChristoffelSum_pos n x).le + · apply (div_le_iff₀ hp).2 + simpa only [mul_comm] using polynomial_evaluation_bound P hP x +lemma polynomial_evaluation_ratio_attained (n : ℕ) (x : ℝ) : + ∃ P : Polynomial ℝ,P.natDegree ≤ n ∧ P.eval x^2/polynomialSechInner P P=sechChristoffelSum n x := by + let a : Fin (n+1) → ℝ := fun j=>(evenPoly (-1) j).eval x + refine ⟨pollaczekCombination a,pollaczekCombination_degree a,?_⟩ + rw [pollaczekCombination_eval,pollaczekCombination_inner] + change (∑ j,a j*a j)^2/(∑ j,a j^2)=sechChristoffelSum n x + simp only [←pow_two] + change (sechChristoffelSum n x)^2/sechChristoffelSum n x=sechChristoffelSum n x + rw [pow_two,mul_div_cancel_right₀ _ (sechChristoffelSum_pos n x).ne'] +noncomputable def polynomialChristoffel (n : ℕ) (x : ℝ) : ℝ := + sSup {r : ℝ | ∃ P : Polynomial ℝ,P.natDegree ≤ n ∧ r=P.eval x^2/polynomialSechInner P P} +lemma polynomialChristoffel_eq_sum (n : ℕ) (x : ℝ) : polynomialChristoffel n x=sechChristoffelSum n x := by + obtain ⟨P,hP,hPe⟩ := polynomial_evaluation_ratio_attained n x + have hm : sechChristoffelSum n x ∈ {r : ℝ | ∃ P : Polynomial ℝ,P.natDegree ≤ n ∧ r=P.eval x^2/polynomialSechInner P P} := + ⟨P,hP,hPe.symm⟩ + apply le_antisymm + · apply csSup_le ⟨_,hm⟩ + rintro r ⟨Q,hQ,rfl⟩ + exact polynomial_evaluation_ratio_bound Q hQ x + · apply le_csSup _ hm + refine ⟨sechChristoffelSum n x,?_⟩ + rintro r ⟨Q,hQ,rfl⟩ + exact polynomial_evaluation_ratio_bound Q hQ x +lemma polynomialChristoffel_negative (s : ℝ) (n : ℕ) : + polynomialChristoffel n (-(s^2))=evenCoefficientKernel s n := by + rw [polynomialChristoffel_eq_sum] + simp only [sechChristoffelSum,evenPoly_negative_eval_sq,evenCoefficientKernel,←Fin.sum_univ_eq_sum_range] +/-- Source Christoffel estimate for the genuine normalized sech measure at +c=pi, not just the formal generating coefficients. -/ +theorem polynomialChristoffel_bounds {s : ℝ} (hs : 0 < s) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + c*((n:ℝ)+1)^(2*s) ≤ polynomialChristoffel n (-(s^2)) ∧ + polynomialChristoffel n (-(s^2)) ≤ C*((n:ℝ)+1)^(2*s) := by + simpa only [polynomialChristoffel_negative] using evenCoefficientKernel_bounds hs +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Real MeasureTheory Filter Topology +lemma sechExpectation_scale {c : ℝ} (hc : 0 < c) (H : ℝ → ℝ) : + sechExpectation c H=sechExpectation Real.pi (fun x=>H ((Real.pi/c)^2*x)) := by + have ht:=integral_comp_mul_left_Ioi + (fun q : ℝ=>H ((Real.pi/c)^2*q^2)/Real.cosh (Real.pi*q)) 0 + (by positivity : 0 < c/Real.pi) + have he (p : ℝ) : H ((Real.pi/c)^2*(c/Real.pi*p)^2)/Real.cosh (Real.pi*(c/Real.pi*p))= + H (p^2)/Real.cosh (c*p) := by + congr 2 <;> field_simp + simp only [he,mul_zero,smul_eq_mul] at ht + unfold sechExpectation + rw [ht,mul_div_cancel_right₀ _ Real.pi_ne_zero] + field_simp +noncomputable def polynomialDilate (a : ℝ) (P : Polynomial ℝ) : Polynomial ℝ := + P.comp (Polynomial.C a*X) +lemma polynomialDilate_eval (a : ℝ) (P : Polynomial ℝ) (x : ℝ) : + (polynomialDilate a P).eval x=P.eval (a*x) := by simp [polynomialDilate] +lemma polynomialDilate_degree (a : ℝ) (P : Polynomial ℝ) : + (polynomialDilate a P).natDegree ≤ P.natDegree := by + unfold polynomialDilate + calc + _ ≤ P.natDegree*(Polynomial.C a*X).natDegree := natDegree_comp_le + _ ≤ P.natDegree*1 := Nat.mul_le_mul_left _ (by simpa using (natDegree_mul_le (p:=Polynomial.C a) (q:=X))) + _ = _ := Nat.mul_one _ +lemma polynomialDilate_mul (a b : ℝ) (P : Polynomial ℝ) : + polynomialDilate a (polynomialDilate b P)=polynomialDilate (b*a) P := by + apply Polynomial.funext + intro x + simp only [polynomialDilate_eval] + congr 1 + ring +noncomputable def scaledSechInner (c : ℝ) (P Q : Polynomial ℝ) : ℝ := + sechExpectation c (fun x=>P.eval x*Q.eval x) +lemma scaledSechInner_eq {c : ℝ} (hc : 0 < c) (P Q : Polynomial ℝ) : + scaledSechInner c P Q=polynomialSechInner (polynomialDilate ((Real.pi/c)^2) P) + (polynomialDilate ((Real.pi/c)^2) Q) := by + rw [scaledSechInner,sechExpectation_scale hc] + simp only [polynomialSechInner,polynomialDilate_eval] +noncomputable def scaledPolynomialChristoffel (c : ℝ) (n : ℕ) (x : ℝ) : ℝ := + sSup {r : ℝ | ∃ P : Polynomial ℝ,P.natDegree ≤ n ∧ r=P.eval x^2/scaledSechInner c P P} +lemma scaledPolynomialChristoffel_eq {c : ℝ} (hc : 0 < c) (n : ℕ) (x : ℝ) : + scaledPolynomialChristoffel c n x=polynomialChristoffel n ((c/Real.pi)^2*x) := by + unfold scaledPolynomialChristoffel polynomialChristoffel + congr 1 + ext r + constructor + · rintro ⟨P,hP,rfl⟩ + refine ⟨polynomialDilate ((Real.pi/c)^2) P,(polynomialDilate_degree _ P).trans hP,?_⟩ + rw [scaledSechInner_eq hc,polynomialDilate_eval] + congr 3 + field_simp + · rintro ⟨P,hP,rfl⟩ + refine ⟨polynomialDilate ((c/Real.pi)^2) P,(polynomialDilate_degree _ P).trans hP,?_⟩ + rw [scaledSechInner_eq hc,polynomialDilate_mul,polynomialDilate_eval] + have he : (c/Real.pi)^2*(Real.pi/c)^2=1 := by field_simp + rw [he] + simp only [polynomialDilate,Polynomial.C_1,one_mul,comp_X] +/-- Inverse Christoffel kernel for the actual normalized sech measure at +arbitrary positive decay rate, evaluated at a fixed negative square. -/ +theorem scaledPolynomialChristoffel_bounds {c y : ℝ} (hc : 0 < c) (hy : 0 < y) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*(n+1:ℝ)^(2*c*y/Real.pi) ≤ scaledPolynomialChristoffel c n (-(y^2)) ∧ + scaledPolynomialChristoffel c n (-(y^2)) ≤ C*(n+1:ℝ)^(2*c*y/Real.pi) := by + have he (n : ℕ) : scaledPolynomialChristoffel c n (-(y^2))= + polynomialChristoffel n (-((c*y/Real.pi)^2)) := by + rw [scaledPolynomialChristoffel_eq hc] + congr 2 + ring + simpa only [he,show 2*(c*y/Real.pi)=2*c*y/Real.pi by ring] using + polynomialChristoffel_bounds (by positivity : 0 < c*y/Real.pi) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PolynomialKernels.lean b/lean/OAI/Combinatorics/HoneycombChords/PolynomialKernels.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8fb07338412d812c672873bfa5dd0e493567f77 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PolynomialKernels.lean @@ -0,0 +1,375 @@ +import Mathlib.Algebra.Polynomial.OfFn +import Mathlib.Algebra.Polynomial.Roots +import Mathlib.LinearAlgebra.Matrix.PosDef +import Mathlib.MeasureTheory.Integral.Bochner.Set +import Mathlib.MeasureTheory.Measure.Lebesgue.Basic +import Mathlib.Tactic + +namespace OAI + +/-! +# Matrix and polynomial Christoffel kernels + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +noncomputable def matrixChristoffel {n : Type*} [Fintype n] [DecidableEq n] + (A : Matrix n n ℝ) (v : n → ℝ) : ℝ := v ⬝ᵥ (A⁻¹ *ᵥ v) +lemma matrixChristoffel_pos {n : Type*} [Fintype n] [DecidableEq n] + {A : Matrix n n ℝ} (hA : A.PosDef) {v : n → ℝ} (hv : v ≠ 0) : 0 < matrixChristoffel A v := by + simpa only [matrixChristoffel,star_trivial] using hA.inv.dotProduct_mulVec_pos hv +lemma symmetric_dot_mulVec {n : Type*} [Fintype n] [DecidableEq n] + {A : Matrix n n ℝ} (hA : A.IsHermitian) (x y : n → ℝ) : x ⬝ᵥ (A *ᵥ y)=y ⬝ᵥ (A *ᵥ x) := by + have hs : Aᵀ=A := by simpa using hA.eq + rw [dotProduct_mulVec,←mulVec_transpose,hs,dotProduct_comm] +lemma matrixChristoffel_bound {n : Type*} [Fintype n] [DecidableEq n] + {A : Matrix n n ℝ} (hA : A.PosDef) (v x : n → ℝ) : + (x ⬝ᵥ v)^2 ≤ matrixChristoffel A v*(x ⬝ᵥ (A *ᵥ x)) := by + by_cases hv : v=0 + · simp [hv,matrixChristoffel] + have hK:=matrixChristoffel_pos hA hv + let u : n → ℝ := A⁻¹ *ᵥ v + have hAu : A *ᵥ u=v := by + dsimp [u] + rw [mulVec_mulVec,mul_nonsing_inv A (isUnit_iff_ne_zero.mpr hA.det_pos.ne'),one_mulVec] + have hKu : u ⬝ᵥ (A *ᵥ u)=matrixChristoffel A v := by + rw [hAu,dotProduct_comm] + rfl + let t := (x ⬝ᵥ v)/matrixChristoffel A v + have hnn:=hA.posSemidef.dotProduct_mulVec_nonneg (x-t • u) + simp only [star_trivial,mulVec_sub,mulVec_smul,sub_dotProduct,dotProduct_sub, + dotProduct_smul,smul_dotProduct] at hnn + rw [symmetric_dot_mulVec hA.1 u x,hKu,hAu] at hnn + simp only [smul_eq_mul] at hnn + have ht : t*matrixChristoffel A v=x ⬝ᵥ v := by dsimp [t];field_simp + nlinarith [mul_nonneg hK.le hnn] +lemma matrixChristoffel_ratio_bound {n : Type*} [Fintype n] [DecidableEq n] + {A : Matrix n n ℝ} (hA : A.PosDef) (v x : n → ℝ) : + (x ⬝ᵥ v)^2/(x ⬝ᵥ (A *ᵥ x)) ≤ matrixChristoffel A v := by + by_cases hx : x=0 + · simp only [hx,zero_dotProduct,zero_pow (by omega : 2≠0),zero_div] + by_cases hv : v=0 + · simp [hv,matrixChristoffel] + · exact (matrixChristoffel_pos hA hv).le + have hp : 0x^i.val +noncomputable def monomialGram (n : ℕ) (w : ℝ → ℝ) : Matrix (Fin n) (Fin n) ℝ := + fun i j=>∫ p in Set.Ioi (0:ℝ),(p^2)^i.val*(p^2)^j.val*w p +lemma ofFn_eval_eq_dot {n : ℕ} (a : Fin n → ℝ) (x : ℝ) : + (Polynomial.ofFn n a).eval x=a ⬝ᵥ monomialVector n x := by + simp [Polynomial.ofFn_eq_sum_monomial, Polynomial.eval_finsetSum, dotProduct,monomialVector] +lemma monomial_pair_integrable (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) (i j : ℕ) : + IntegrableOn (fun p : ℝ=>(p^2)^i*(p^2)^j*w p) (Set.Ioi 0) := by + simpa only [←pow_mul,←pow_add] using hi (2*i+2*j) +lemma monomialGram_quadratic {n : ℕ} (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) (a : Fin n → ℝ) : + a ⬝ᵥ ((monomialGram n w) *ᵥ a)=∫ p in Set.Ioi (0:ℝ),(Polynomial.ofFn n a).eval (p^2)^2*w p := by + have hpair i j : IntegrableOn (fun p : ℝ=>a i*((p^2)^i.val*(p^2)^j.val*w p)*a j) (Set.Ioi 0) := + (monomial_pair_integrable w hi i.val j.val).const_mul (a i) |>.mul_const (a j) + have he p : (Polynomial.ofFn n a).eval (p^2)^2*w p= + ∑ i : Fin n,∑ j : Fin n,a i*((p^2)^i.val*(p^2)^j.val*w p)*a j := by + rw [ofFn_eval_eq_dot,pow_two] + simp only [dotProduct,monomialVector,sum_mul,mul_sum] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring + simp_rw [he] + rw [integral_finsetSum _ (fun i _=>integrable_finsetSum _ (fun j _=>hpair i j))] + simp_rw [integral_finsetSum _ (fun j _=>hpair _ j),integral_mul_const,integral_const_mul] + simp [dotProduct,mulVec,monomialGram,mul_sum,mul_assoc] +lemma monomialGram_norm_integrable {n : ℕ} (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) (a : Fin n → ℝ) : + IntegrableOn (fun p : ℝ=>(Polynomial.ofFn n a).eval (p^2)^2*w p) (Set.Ioi 0) := by + have he p : (Polynomial.ofFn n a).eval (p^2)^2*w p= + ∑ i : Fin n,∑ j : Fin n,a i*((p^2)^i.val*(p^2)^j.val*w p)*a j := by + rw [ofFn_eval_eq_dot,pow_two] + simp only [dotProduct,monomialVector,sum_mul,mul_sum] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring + simp_rw [he] + exact integrable_finsetSum _ (fun i _=>integrable_finsetSum _ (fun j _=> + (monomial_pair_integrable w hi i.val j.val).const_mul (a i) |>.mul_const (a j))) +lemma polynomial_square_eval_ae_ne_zero {P : Polynomial ℝ} (hP : P ≠ 0) : + ∀ᵐ p : ℝ ∂volume.restrict (Set.Ioi (0:ℝ)), P.eval (p^2) ≠ 0 := by + have hQ : P.comp (X^2) ≠ 0 := by + rw [ne_eq,Polynomial.comp_eq_zero_iff] + simp only [hP,false_or,not_and_or] + right + intro h + have hh:=congrArg (fun Q : Polynomial ℝ=>Q.coeff 2) h + simp at hh + have hf := Polynomial.finite_setOfPred_isRoot hQ + have hzero : (volume.restrict (Set.Ioi (0:ℝ))) {p : ℝ | (P.comp (X^2)).eval p=0}=0 := hf.measure_zero _ + rw [ae_iff] + simpa only [not_not,Polynomial.eval_comp,Polynomial.eval_pow,Polynomial.eval_X] using hzero +lemma monomialGram_posDef (n : ℕ) (w : ℝ → ℝ) + (hw : ∀ p,0

p^k*w p) (Set.Ioi 0)) : (monomialGram n w).PosDef := by + apply Matrix.PosDef.of_dotProduct_mulVec_pos + · rw [Matrix.isHermitian_iff_isSymm] + ext i j + dsimp [monomialGram,Matrix.transpose] + congr 1 + funext p + ring + · intro a ha + simp only [star_trivial,monomialGram_quadratic w hi] + have hP : Polynomial.ofFn n a ≠ 0 := fun h=>ha ((Polynomial.injective_ofFn n) (by simpa using h)) + have hae : ∀ᵐ p : ℝ ∂volume.restrict (Set.Ioi (0:ℝ)),0<(Polynomial.ofFn n a).eval (p^2)^2*w p := by + filter_upwards [ae_restrict_mem measurableSet_Ioi,polynomial_square_eval_ae_ne_zero hP] with p hp hn + exact mul_pos (sq_pos_of_ne_zero hn) (hw p hp) + apply (integral_pos_iff_support_of_nonneg_ae (hae.mono fun _ h=>h.le) (monomialGram_norm_integrable w hi a)).mpr + have hs : Function.support (fun p : ℝ=>(Polynomial.ofFn n a).eval (p^2)^2*w p)=ᵐ[volume.restrict (Set.Ioi (0:ℝ))] Set.univ := by + filter_upwards [hae] with p hp + exact propext (iff_of_true hp.ne' trivial) + rw [measure_congr hs] + simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset MeasureTheory Filter +noncomputable def rootBasisMatrix (n : ℕ) (a : ℝ) : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := + fun i=>Fin.cases (Pi.single 0 1) (fun j=>Pi.single j.succ 1-a • Pi.single j.castSucc 1) i +lemma rootBasisMatrix_det (n : ℕ) (a : ℝ) : (rootBasisMatrix n a).det=1 := by + have ht : (rootBasisMatrix n a).IsLowerTriangular := by + intro i j hij + change i < j at hij + cases i using Fin.cases with + | zero => + simp only [rootBasisMatrix,Fin.cases_zero,Pi.single_apply] + rw [ite_eq_right (by simp only [Fin.lt_def,Fin.ext_iff,Fin.val_zero] at *; omega)] + | succ i => + have h1 : i.succ ≠ j := ne_of_lt hij + have h2 : i.castSucc ≠ j := ne_of_lt (i.castSucc_lt_succ.trans hij) + simp [rootBasisMatrix,h1,h2] + rw [Matrix.det_of_isLowerTriangular _ ht] + have hd (i : Fin (n+1)) : rootBasisMatrix n a i i=1 := by + cases i using Fin.cases with + | zero => simp [rootBasisMatrix] + | succ i => + have hne : i.castSucc ≠ i.succ := ne_of_lt i.castSucc_lt_succ + simp [rootBasisMatrix,hne] + simp only [hd,prod_const_one] +lemma rootBasisMatrix_eval_zero (n : ℕ) (a x : ℝ) : + (rootBasisMatrix n a *ᵥ monomialVector (n+1) x) 0=1 := by + simp [rootBasisMatrix,mulVec,monomialVector,dotProduct,Pi.single_apply] +lemma rootBasisMatrix_eval_succ {n : ℕ} (a x : ℝ) (i : Fin n) : + (rootBasisMatrix n a *ᵥ monomialVector (n+1) x) i.succ=(x-a)*x^i.val := by + change (Pi.single i.succ 1-a • Pi.single i.castSucc 1) ⬝ᵥ monomialVector (n+1) x=_ + rw [sub_dotProduct,smul_dotProduct] + simp only [single_dotProduct,one_mul,monomialVector,Fin.val_succ,Fin.val_castSucc,smul_eq_mul,pow_succ] + ring +lemma rootBasisMatrix_eval_self (n : ℕ) (a : ℝ) : + rootBasisMatrix n a *ᵥ monomialVector (n+1) a=Pi.single 0 1 := by + ext i + cases i using Fin.cases with + | zero => simp [rootBasisMatrix_eval_zero] + | succ i => simp [rootBasisMatrix_eval_succ] +lemma monomialGram_congruence_entry {n : ℕ} (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) + (T : Matrix (Fin n) (Fin n) ℝ) (i j : Fin n) : + (T*monomialGram n w*Tᵀ) i j= + ∫ p in Set.Ioi (0:ℝ),(T *ᵥ monomialVector n (p^2)) i*(T *ᵥ monomialVector n (p^2)) j*w p := by + have hpair k l : IntegrableOn (fun p : ℝ=>T i k*((p^2)^k.val*(p^2)^l.val*w p)*T j l) (Set.Ioi 0) := + (monomial_pair_integrable w hi k.val l.val).const_mul (T i k) |>.mul_const (T j l) + have he p : (T *ᵥ monomialVector n (p^2)) i*(T *ᵥ monomialVector n (p^2)) j*w p= + ∑ k : Fin n,∑ l : Fin n,T i k*((p^2)^k.val*(p^2)^l.val*w p)*T j l := by + simp only [mulVec,dotProduct,monomialVector,sum_mul,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro k _ + apply sum_congr rfl + intro l _ + ring + simp_rw [he] + rw [integral_finsetSum _ (fun k _=>integrable_finsetSum _ (fun l _=>hpair k l))] + simp_rw [integral_finsetSum _ (fun l _=>hpair _ l),integral_mul_const,integral_const_mul] + simp only [Matrix.mul_apply,transpose_apply,monomialGram,sum_mul] + rw [sum_comm] +lemma rootBasisGram_minor (n : ℕ) (a : ℝ) (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) : + (rootBasisMatrix n a*monomialGram (n+1) w*(rootBasisMatrix n a)ᵀ).submatrix Fin.succ Fin.succ= + monomialGram n (fun p=>(p^2-a)^2*w p) := by + ext i j + rw [Matrix.submatrix_apply,monomialGram_congruence_entry w hi] + simp_rw [rootBasisMatrix_eval_succ] + apply integral_congr_ae + filter_upwards with p + ring +/-- Gram cofactor identity used in the manuscript's polynomial comparison. -/ +theorem polynomial_compression_cofactor (n : ℕ) (a : ℝ) (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) : + (monomialGram n (fun p=>(p^2-a)^2*w p)).det/(monomialGram (n+1) w).det= + matrixChristoffel (monomialGram (n+1) w) (monomialVector (n+1) a) := by + have hdet : IsUnit (rootBasisMatrix n a).det := by rw [rootBasisMatrix_det];exact isUnit_one + have h:=matrixChristoffel_congruence (monomialGram (n+1) w) (rootBasisMatrix n a) hdet (monomialVector (n+1) a) + rw [rootBasisMatrix_eval_self,matrixChristoffel_first_cofactor,rootBasisGram_minor n a w hi, + det_mul,det_mul,det_transpose,rootBasisMatrix_det,one_mul,mul_one] at h + exact h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset MeasureTheory Filter +noncomputable def weightedPolynomialNorm (w : ℝ → ℝ) (P : Polynomial ℝ) : ℝ := + ∫ p in Set.Ioi (0:ℝ), P.eval (p^2)^2*w p +noncomputable def weightedPolynomialChristoffel (w : ℝ → ℝ) (n : ℕ) (x : ℝ) : ℝ := + sSup {r : ℝ | ∃ P : Polynomial ℝ, P.natDegree ≤ n ∧ r=P.eval x^2/weightedPolynomialNorm w P} +lemma weightedPolynomialNorm_integrable (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) (P : Polynomial ℝ) : + IntegrableOn (fun p : ℝ=>P.eval (p^2)^2*w p) (Set.Ioi 0) := by + have he := Polynomial.ofFn_comp_toFn_eq_id_of_natDegree_lt (Nat.lt_succ_self P.natDegree) + rw [←he] + exact monomialGram_norm_integrable w hi _ +lemma weightedPolynomialNorm_nonneg (w : ℝ → ℝ) (hw : ∀ p,0

p^k*w p) (Set.Ioi 0)) : + weightedPolynomialChristoffel w n x=matrixChristoffel (monomialGram (n+1) w) (monomialVector (n+1) x) := by + rw [←matrixChristoffel_variational (monomialGram_posDef (n+1) w hw hi)] + unfold weightedPolynomialChristoffel + congr 1 + ext r + constructor + · rintro ⟨P,hP,rfl⟩ + have he := Polynomial.ofFn_comp_toFn_eq_id_of_natDegree_lt (Nat.lt_succ_of_le hP) + refine ⟨P.toFn (n+1),?_⟩ + rw [monomialGram_quadratic w hi,he] + rw [←ofFn_eval_eq_dot,he] + rfl + · rintro ⟨a,rfl⟩ + refine ⟨Polynomial.ofFn (n+1) a,Nat.le_of_lt_succ (Polynomial.ofFn_natDegree_lt (by omega) a),?_⟩ + rw [monomialGram_quadratic w hi,ofFn_eval_eq_dot] + rfl +lemma weightedPolynomial_ratio_bound (n : ℕ) (x : ℝ) (w : ℝ → ℝ) + (hw : ∀ p,0

p^k*w p) (Set.Ioi 0)) + (P : Polynomial ℝ) (hP : P.natDegree≤n) : + P.eval x^2/weightedPolynomialNorm w P≤weightedPolynomialChristoffel w n x := by + rw [weightedPolynomialChristoffel_eq n x w hw hi] + have he := Polynomial.ofFn_comp_toFn_eq_id_of_natDegree_lt (Nat.lt_succ_of_le hP) + have h:=matrixChristoffel_ratio_bound (monomialGram_posDef (n+1) w hw hi) (monomialVector (n+1) x) (P.toFn (n+1)) + rw [monomialGram_quadratic w hi,←ofFn_eval_eq_dot,he] at h + exact h +lemma weightedPolynomial_ratio_attained (n : ℕ) (x : ℝ) (w : ℝ → ℝ) + (hw : ∀ p,0

p^k*w p) (Set.Ioi 0)) : + ∃ P : Polynomial ℝ,P.natDegree≤n ∧ P.eval x^2/weightedPolynomialNorm w P=weightedPolynomialChristoffel w n x := by + rw [weightedPolynomialChristoffel_eq n x w hw hi] + obtain ⟨a,ha⟩:=matrixChristoffel_ratio_attained (monomialGram_posDef (n+1) w hw hi) (monomialVector (n+1) x) + refine ⟨Polynomial.ofFn (n+1) a,Nat.le_of_lt_succ (Polynomial.ofFn_natDegree_lt (by omega) a),?_⟩ + rw [monomialGram_quadratic w hi,←ofFn_eval_eq_dot] at ha + exact ha +lemma weightedPolynomialNorm_pos (w : ℝ → ℝ) (hw : ∀ p,0

p^k*w p) (Set.Ioi 0)) + {P : Polynomial ℝ} (hP : P≠0) : 0p^k*w₁ p) (Set.Ioi 0)) + (hi₂ : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w₂ p) (Set.Ioi 0)) + (h : ∀ p,0

b i)) (hb0 : ∀ i : Fin (m+1),0 ≤ b i) (hbfirst : b 0=0) + (hf : Continuous f) (hw : ∀ p,0

f (p^2)*zeroJet b i (p^2)*w p) (Set.Ioi 0)) + (s : Finset ℝ) (hs : ∀ x ∈ s,0 < x) (hz : ∀ x,0 < x → (f x = 0 ↔ x ∈ s)) (hc : s.card < m) : + ∃ i : Fin m,(∫ p in Set.Ioi (0:ℝ),f (p^2)*zeroJet b i (p^2)*w p)≠0 := by + classical + by_contra hall + push Not at hall + obtain ⟨k,hk,a,hnonneg,hpos⟩ := zero_jet_flag_sign_matching b f hb hb0 hbfirst hf s hs hz hc + let F : Fin (k+1) → ℝ → ℝ := fun i p=>a i*(f (p^2)*zeroJet b i (p^2)*w p) + let H : ℝ → ℝ := fun p=>f (p^2)*zeroJetCombination b a (p^2) + let g : ℝ → ℝ := fun p=>H p*w p + have heq : g=fun p=>∑ i,F i p := by + funext p + dsimp [g,H,F,zeroJetCombination] + rw [mul_sum,sum_mul] + apply sum_congr rfl + intro i _ + ring + have hiF (i : Fin (k+1)) : IntegrableOn (F i) (Set.Ioi 0) := (hi (i.castLE hk)).const_mul (a i) + have hig : IntegrableOn g (Set.Ioi 0) := by rw [heq];exact integrable_finsetSum _ (fun i _=>hiF i) + have hzero : (∫ p in Set.Ioi (0:ℝ),g p)=0 := by + rw [heq,integral_finsetSum _ (fun i _=>hiF i)] + apply sum_eq_zero + intro i _ + rw [show (F i)=fun p=>a i*(f (p^2)*zeroJet b i (p^2)*w p) from rfl, + integral_const_mul] + have hz := hall (i.castLE hk) + change (∫ p in Set.Ioi (0:ℝ),f (p^2)*zeroJet b i (p^2)*w p)=0 at hz + rw [hz,mul_zero] + have hgnonneg : 0 ≤ᵐ[volume.restrict (Set.Ioi (0:ℝ))] g := by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact mul_nonneg (hnonneg (p^2) (sq_pos_of_pos hp)) (hw p hp).le + have hH : Continuous H := by + exact (hf.comp (continuous_id.pow 2)).mul ((zeroJetCombination_continuous b a).comp (continuous_id.pow 2)) + let U : Set ℝ := Set.Ioi 0 ∩ {p | 0hxs ((hz x hx).mp h)) + have hup : 0<(volume.restrict (Set.Ioi (0:ℝ))) U := by + rw [Measure.restrict_apply hopen.measurableSet,Set.inter_eq_left.mpr Set.inter_subset_left] + exact hopen.measure_pos volume hune + have hus : U⊆Function.support g := by + intro p hp + exact (mul_pos hp.2 (hw p hp.1)).ne' + have hgpos : 0<∫ p in Set.Ioi (0:ℝ),g p := + (integral_pos_iff_support_of_nonneg_ae hgnonneg hig).mpr (hup.trans_le (measure_mono hus)) + exact hgpos.ne' hzero +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset MeasureTheory +lemma zeroJet_linear_zero_set {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) (t : ℝ) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hb0 : ∀ i : Fin (n+1),0 ≤ b i) + (hbfirst : b 0=0) (ha : a ≠ 0) : + ∃ s : Finset ℝ,(∀ x∈s,0Set.Finite.mem_toFinset _ + have hZcard : Z.card(hZ x).mp hx) + let s := (insert t Z).filter (fun x=>0(mem_filter.mp hx).2,?_,?_⟩ + · intro x hx + simp only [s,mem_filter,mem_insert,hZ,mul_eq_zero,sub_eq_zero] + constructor + · intro hh + exact ⟨hh.imp_right (fun h=>⟨hx,h⟩),hx⟩ + · rintro ⟨h|h,_⟩ + · exact Or.inl h + · exact Or.inr h.2 + · have h : s.card ≤ Z.card+1 := (card_filter_le _ _).trans (card_insert_le _ _) + omega +/-- The constant removed at zero gives exactly the stronger zero count +required for the first step of the second interlacing chain. -/ +theorem zero_jet_linear_nonorthogonality {n m : ℕ} (b c : ℕ → ℝ) (a : Fin n → ℝ) + (w : ℝ → ℝ) (t : ℝ) (hnm : n < m) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hc : Monotone (fun i : Fin m=>c i)) + (hb0 : ∀ i : Fin (n+1),0 ≤ b i) (hc0 : ∀ i : Fin m,0 ≤ c i) + (hbfirst : b 0=0) (ha : a ≠ 0) (hw : ∀ p,0

(p^2-t)*zeroJetCombination b a (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p) (Set.Ioi 0)) : + ∃ j : Fin m,(∫ p in Set.Ioi (0:ℝ),(p^2-t)*zeroJetCombination b a (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p) ≠ 0 := by + obtain ⟨s,hs,hz,hcard⟩ := zeroJet_linear_zero_set b a t hb hb0 hbfirst ha + exact jet_flag_integral_nonzero c (fun x=>(x-t)*zeroJetCombination b a x) w hc hc0 + ((continuous_id.sub continuous_const).mul (zeroJetCombination_continuous b a)) + hw hi s hs hz (hcard.trans_lt hnm) +theorem zero_jet_linear_zero_nonorthogonality {n m : ℕ} (b c : ℕ → ℝ) (a : Fin n → ℝ) + (w : ℝ → ℝ) (t : ℝ) (hnm : n < m) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hc : Monotone (fun i : Fin (m+1)=>c i)) + (hb0 : ∀ i : Fin (n+1),0 ≤ b i) (hc0 : ∀ i : Fin (m+1),0 ≤ c i) + (hbfirst : b 0=0) (hcfirst : c 0=0) (ha : a ≠ 0) (hw : ∀ p,0

(p^2-t)*zeroJetCombination b a (p^2)*zeroJet c j (p^2)*w p) (Set.Ioi 0)) : + ∃ j : Fin m,(∫ p in Set.Ioi (0:ℝ),(p^2-t)*zeroJetCombination b a (p^2)*zeroJet c j (p^2)*w p) ≠ 0 := by + obtain ⟨s,hs,hz,hcard⟩ := zeroJet_linear_zero_set b a t hb hb0 hbfirst ha + exact zero_jet_flag_integral_nonzero c (fun x=>(x-t)*zeroJetCombination b a x) w hc hc0 hcfirst + ((continuous_id.sub continuous_const).mul (zeroJetCombination_continuous b a)) + hw hi s hs hz (hcard.trans_lt hnm) +lemma pole_zeroJetCombination_linear_pair_integrable {n m : ℕ} (b c : ℕ → ℝ) + (a : Fin n → ℝ) {z : ℝ} (hz : 0(p^2-t)*zeroJetCombination b a (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*poleAdjustedDensity z p) (Set.Ioi 0) := by + simpa only [zeroJetLift_eq b a hbfirst] using + pole_jetCombination_linear_pair_integrable b c (zeroJetLift b a) hz t hb0 hc0 hb1 hc1 j +lemma pole_zeroJetCombination_linear_zero_pair_integrable {n m : ℕ} (b c : ℕ → ℝ) + (a : Fin n → ℝ) {z : ℝ} (hz : 0(p^2-t)*zeroJetCombination b a (p^2)*zeroJet c j (p^2)*poleAdjustedDensity z p) (Set.Ioi 0) := by + have hi:=pole_zeroJetCombination_linear_pair_integrable b c a hz t hbfirst hb0 hc0 hb1 hc1 j.succ + have hi0:=pole_zeroJetCombination_linear_pair_integrable b c a hz t hbfirst hb0 hc0 hb1 hc1 0 + simp only [Fin.val_zero,jet_first_constant c hcfirst,mul_one] at hi0 + apply (hi.sub (hi0.mul_const (cosineKernelJet (nodalOrder c (j.val+1)) 0 (c (j.val+1)) 0))).congr + filter_upwards with p + dsimp [zeroJet] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Matrix MeasureTheory +lemma twoKnot_first (N : ℕ) (hN : 0F i)) (hx : Function.Injective x) (hx0 : ∀ i,0 < x i) + (hz : ∀ i,familyCombination F a (x i)=0) : a=0 := by + have hd : (evaluationMatrix (fun i : Fin n=>F i) x).det ≠ 0 := by + have h:=evaluation_det_product_pos _ _ hF hF x hx hx0 + exact fun he=>by rw [he,zero_mul] at h;exact lt_irrefl _ h + apply (Matrix.vecMul_injective_iff_isUnit.mpr + ((Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr hd))) + ext j + dsimp only + rw [Matrix.zero_vecMul] + exact hz j +lemma familyCombination_zeros_card_lt {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin n → ℝ) + (hF : PositiveEvaluation (fun i : Fin n=>F i)) (ha : a ≠ 0) + (s : Finset ℝ) (hs : ∀ x ∈ s,0 < x ∧ familyCombination F a x=0) : s.card < n := by + classical + by_contra hc + obtain ⟨t,ht,htc⟩ := Finset.exists_subset_card_eq (le_of_not_gt hc) + let o := t.equivFinOfCardEq htc + let x : Fin n → ℝ := fun i=>(o.symm i).val + apply ha + apply familyCombination_unique F a x hF + · intro i j he + exact o.symm.injective (Subtype.ext he) + · intro i + exact (hs _ (ht (o.symm i).property)).1 + · intro i + exact (hs _ (ht (o.symm i).property)).2 +lemma familyCombination_finite_zeros {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin n → ℝ) + (hF : PositiveEvaluation (fun i : Fin n=>F i)) (ha : a ≠ 0) : + {x : ℝ | 0 < x ∧ familyCombination F a x=0}.Finite := by + by_contra hf + obtain ⟨s,hs,hcard⟩ := Set.Infinite.exists_subset_card_eq hf n + have h:=familyCombination_zeros_card_lt F a hF ha s (fun x hx=>hs hx) + omega +lemma family_linear_zero_set {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin n → ℝ) (r : ℝ) + (hF : PositiveEvaluation (fun i : Fin n=>F i)) (ha : a ≠ 0) : + ∃ s : Finset ℝ,(∀ x ∈ s,0 < x) ∧ (∀ x,0 < x → ((x-r)*familyCombination F a x=0 ↔ x ∈ s)) ∧ s.card ≤ n := by + classical + let Z := (familyCombination_finite_zeros F a hF ha).toFinset + have hZ : ∀ x,x ∈ Z ↔ 0 < x ∧ familyCombination F a x=0 := fun _=>Set.Finite.mem_toFinset _ + have hc : Z.card < n := familyCombination_zeros_card_lt F a hF ha Z (fun x hx=>(hZ x).mp hx) + let s := (insert r Z).filter (fun x=>0 < x) + refine ⟨s,fun x hx=>(mem_filter.mp hx).2,?_,?_⟩ + · intro x hx + simp only [s,mem_filter,mem_insert,hZ,mul_eq_zero,sub_eq_zero] + constructor + · intro hh + exact ⟨hh.imp_right (fun h=>⟨hx,h⟩),hx⟩ + · rintro ⟨h|h,_⟩ + · exact Or.inl h + · exact Or.inr h.2 + · have h : s.card ≤ Z.card+1 := (card_filter_le _ _).trans (card_insert_le _ _) + omega +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset +lemma familyTestCoeffs_last {n : ℕ} (F : ℕ → ℝ → ℝ) (v : Fin n → ℝ) : + familyTestCoeffs F v (Fin.last n)=(-1:ℝ)^n*(evaluationMatrix (fun i : Fin n=>F i) v).det := by + simp only [familyTestCoeffs,Fin.val_last,Fin.succAbove_last,Fin.val_castSucc] + rfl +lemma familyTest_zero {n : ℕ} (F : ℕ → ℝ → ℝ) (v : Fin n → ℝ) (i : Fin n) : + familyCombination F (familyTestCoeffs F v) (v i)=0 := by + rw [familyTest_eq_det] + apply Matrix.det_zero_of_column_eq (i:=0) (j:=i.succ) (Fin.succ_ne_zero _).symm + intro k + simp [evaluationMatrix] +lemma familyCombination_sub {n : ℕ} (F : ℕ → ℝ → ℝ) (a b : Fin n → ℝ) (x : ℝ) : + familyCombination F (a-b) x=familyCombination F a x-familyCombination F b x := by + simp [familyCombination,sub_mul,sum_sub_distrib] +lemma familyCombination_last_zero {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin (n+1) → ℝ) + (ha : a (Fin.last n)=0) (x : ℝ) : + familyCombination F a x=familyCombination F (fun i : Fin n=>a i.castSucc) x := by + simp [familyCombination,Fin.sum_univ_castSucc,ha] +/-- A monic combination with the maximum number of positive zeros has the +same orientation at those zeros as a monic ordinary polynomial. -/ +theorem monic_family_sign {n : ℕ} (F : ℕ → ℝ → ℝ) (a : Fin (n+1) → ℝ) (v : Fin n → ℝ) + (hF : PositiveEvaluation (fun i : Fin (n+1)=>F i)) + (hF0 : PositiveEvaluation (fun i : Fin n=>F i)) + (ha : a (Fin.last n)=1) (hv : StrictMono v) (hv0 : ∀ i,0 < v i) + (haz : ∀ i,familyCombination F a (v i)=0) {x : ℝ} (hx : 0 < x) (hxv : ∀ i,x ≠ v i) : + 0 < familyCombination F a x*(∏ i,(x-v i)) := by + let T := familyTestCoeffs F v + let D := (evaluationMatrix (fun i : Fin n=>F i) v).det + have hD : 0 < D := hF0 v hv hv0 + have hT : T (Fin.last n)=(-1:ℝ)^n*D := familyTestCoeffs_last F v + let c : Fin (n+1) → ℝ := (fun i=>T (Fin.last n)*a i)-T + have hc : c (Fin.last n)=0 := by simp [c,ha] + have hcz (i : Fin n) : familyCombination F c (v i)=0 := by + rw [show c=(fun i=>T (Fin.last n)*a i)-T from rfl,familyCombination_sub,familyCombination_smul,haz,mul_zero] + rw [show T=familyTestCoeffs F v from rfl,familyTest_zero,sub_self] + have hc0 : (fun i : Fin n=>c i.castSucc)=0 := + familyCombination_unique F _ v hF0 hv.injective hv0 (fun i=>by + rw [←familyCombination_last_zero F c hc];exact hcz i) + have hcall : c=0 := by + ext i + refine Fin.lastCases hc (fun j=>congrFun hc0 j) i + have he : familyCombination F T x=T (Fin.last n)*familyCombination F a x := by + have h := congrArg (fun b=>familyCombination F b x) hcall + rw [show c=(fun i=>T (Fin.last n)*a i)-T from rfl,familyCombination_sub,familyCombination_smul] at h + have hz : familyCombination F (0 : Fin (n+1) → ℝ) x=0 := by simp [familyCombination] + rw [hz] at h + linarith + have hh:=familyTest_sign_product F v hF hv hv0 hx hxv + change 0 < familyCombination F T x*(∏ i,(v i-x)) at hh + have hn : (∏ i : Fin n,(v i-x))=(-1:ℝ)^n*(∏ i,(x-v i)) := by + simp_rw [show ∀ i : Fin n,v i-x=(-1:ℝ)*(x-v i) from fun i=>by ring] + rw [prod_mul_distrib,prod_const,card_univ,Fintype.card_fin] + rw [he,hT,hn] at hh + have hs : ((-1:ℝ)^n)^2=1 := by rw [←pow_mul,show n*2=2*n by omega,pow_mul];norm_num + have heq : ((-1:ℝ)^n*D*familyCombination F a x)*((-1:ℝ)^n*∏ i,(x-v i))= + D*(familyCombination F a x*∏ i,(x-v i)) := by + calc + _ = ((-1:ℝ)^n)^2 * (D*(familyCombination F a x*∏ i,(x-v i))) := by ring + _ = _ := by rw [hs,one_mul] + rw [heq] at hh + exact pos_of_mul_pos_right hh hD.le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter +/-- Orthogonality forces at least m distinct zeros (indeed m sign changes) for +continuous functions against a positive m-dimensional function flag. The measure +and the squared p-coordinate are those used by the actual strip pairing. -/ +theorem positive_flag_integral_nonzero {m : ℕ} (B : ℕ → ℝ → ℝ) (f w : ℝ → ℝ) + (hB : PositiveFlag B m) (hBc : ∀ i : Fin m,Continuous (B i)) + (hf : Continuous f) (hw : ∀ p,0

f (p^2)*B i (p^2)*w p) (Set.Ioi 0)) + (s : Finset ℝ) (hs : ∀ x ∈ s,0 < x) (hz : ∀ x,0 < x → (f x = 0 ↔ x ∈ s)) (hc : s.card < m) : + ∃ i : Fin m,(∫ p in Set.Ioi (0:ℝ),f (p^2)*B i (p^2)*w p)≠0 := by + classical + by_contra hall + push Not at hall + obtain ⟨k,hk,a,hnonneg,hpos⟩ := positive_flag_sign_matching B f hB hf s hs hz hc + let F : Fin (k+1) → ℝ → ℝ := fun i p=>a i*(f (p^2)*B i (p^2)*w p) + let H : ℝ → ℝ := fun p=>f (p^2)*familyCombination B a (p^2) + let g : ℝ → ℝ := fun p=>H p*w p + have heq : g=fun p=>∑ i,F i p := by + funext p + dsimp [g,H,F,familyCombination] + rw [mul_sum,sum_mul] + apply sum_congr rfl + intro i _ + ring + have hiF (i : Fin (k+1)) : IntegrableOn (F i) (Set.Ioi 0) := (hi (i.castLE hk)).const_mul (a i) + have hig : IntegrableOn g (Set.Ioi 0) := by rw [heq];exact integrable_finsetSum _ (fun i _=>hiF i) + have hzero : (∫ p in Set.Ioi (0:ℝ),g p)=0 := by + rw [heq,integral_finsetSum _ (fun i _=>hiF i)] + apply sum_eq_zero + intro i _ + rw [show (F i)=fun p=>a i*(f (p^2)*B i (p^2)*w p) from rfl, + integral_const_mul] + have hz := hall (i.castLE hk) + change (∫ p in Set.Ioi (0:ℝ),f (p^2)*B i (p^2)*w p)=0 at hz + rw [hz,mul_zero] + have hgnonneg : 0 ≤ᵐ[volume.restrict (Set.Ioi (0:ℝ))] g := by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact mul_nonneg (hnonneg (p^2) (sq_pos_of_pos hp)) (hw p hp).le + have hH : Continuous H := by + exact (hf.comp (continuous_id.pow 2)).mul ((familyCombination_continuous B a (fun i=>hBc (i.castLE hk))).comp (continuous_id.pow 2)) + let U : Set ℝ := Set.Ioi 0 ∩ {p | 0hxs ((hz x hx).mp h)) + have hup : 0<(volume.restrict (Set.Ioi (0:ℝ))) U := by + rw [Measure.restrict_apply hopen.measurableSet,Set.inter_eq_left.mpr Set.inter_subset_left] + exact hopen.measure_pos volume hune + have hus : U⊆Function.support g := by + intro p hp + exact (mul_pos hp.2 (hw p hp.1)).ne' + have hgpos : 0<∫ p in Set.Ioi (0:ℝ),g p := + (integral_pos_iff_support_of_nonneg_ae hgnonneg hig).mpr (hup.trans_le (measure_mono hus)) + exact hgpos.ne' hzero +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +/-- The maximal zero count at a real pencil root. In particular the root is +positive and distinct from the zeros of its root function. -/ +theorem flag_orthogonal_linear_zeros {n : ℕ} (F G : ℕ → ℝ → ℝ) (a : Fin (n+1) → ℝ) + (w : ℝ → ℝ) (r : ℝ) + (hF : PositiveEvaluation (fun i : Fin (n+1)=>F i)) + (hG : PositiveFlag G (n+1)) (hFc : ∀ i : Fin (n+1),Continuous (F i)) + (hGc : ∀ i : Fin (n+1),Continuous (G i)) (ha : a ≠ 0) (hw : ∀ p,0 < p → 0 < w p) + (hi : ∀ i : Fin (n+1),IntegrableOn (fun p=>(p^2-r)*familyCombination F a (p^2)*G i (p^2)*w p) (Set.Ioi 0)) + (ho : ∀ i : Fin (n+1),(∫ p in Set.Ioi (0:ℝ),(p^2-r)*familyCombination F a (p^2)*G i (p^2)*w p)=0) : + ∃ Z : Finset ℝ,Z.card=n ∧ (∀ x,x ∈ Z ↔ 0 < x ∧ familyCombination F a x=0) ∧ 0 < r ∧ r ∉ Z := by + classical + let Z := (familyCombination_finite_zeros F a hF ha).toFinset + have hZ : ∀ x,x ∈ Z ↔ 0 < x ∧ familyCombination F a x=0 := fun _=>Set.Finite.mem_toFinset _ + have hc : Z.card < n+1 := familyCombination_zeros_card_lt F a hF ha Z (fun x hx=>(hZ x).mp hx) + let s := (insert r Z).filter (fun x=>0 < x) + have hs : ∀ x ∈ s,0 < x := fun x hx=>(mem_filter.mp hx).2 + have hz : ∀ x,0 < x → ((x-r)*familyCombination F a x=0 ↔ x ∈ s) := by + intro x hx + simp only [s,mem_filter,mem_insert,hZ,mul_eq_zero,sub_eq_zero] + constructor + · intro hh + exact ⟨hh.imp_right (fun h=>⟨hx,h⟩),hx⟩ + · rintro ⟨h|h,_⟩ + · exact Or.inl h + · exact Or.inr h.2 + have hsc : n+1 ≤ s.card := by + by_contra hh + obtain ⟨i,hi⟩ := positive_flag_integral_nonzero G (fun x=>(x-r)*familyCombination F a x) w hG hGc + ((continuous_id.sub continuous_const).mul (familyCombination_continuous F a hFc)) hw hi s hs hz (by omega) + exact hi (ho i) + have hsc' : s.card ≤ Z.card+1 := (card_filter_le _ _).trans (card_insert_le _ _) + have hZc : Z.card=n := by omega + have hzfilter : Z.filter (fun x=>0 < x)=Z := filter_eq_self.mpr (fun x hx=>((hZ x).mp hx).1) + have hr : 0 < r := by + by_contra h + have he : s=Z := by simp [s,filter_insert,h,hzfilter] + rw [he,hZc] at hsc + omega + have hrZ : r ∉ Z := by + intro h + have he : s=Z := by dsimp [s];rw [insert_eq_of_mem h,hzfilter] + rw [he,hZc] at hsc + omega + exact ⟨Z,hZc,hZ,hr,hrZ⟩ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter +lemma positive_continuous_pairing (f H w : ℝ → ℝ) + (hf : Continuous f) (hH : Continuous H) (hw : ∀ p,0 < p → 0 < w p) + (hi : IntegrableOn (fun p=>f (p^2)*H (p^2)*w p) (Set.Ioi 0)) + (hn : ∀ x,0 < x → 0 ≤ f x*H x) (hp : ∃ x,0 < x ∧ 0 < f x*H x) : + 0 < ∫ p in Set.Ioi (0:ℝ),f (p^2)*H (p^2)*w p := by + let K : ℝ → ℝ := fun p=>f (p^2)*H (p^2) + let g : ℝ → ℝ := fun p=>K p*w p + have hgn : 0 ≤ᵐ[volume.restrict (Set.Ioi (0:ℝ))] g := by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact mul_nonneg (hn (p^2) (sq_pos_of_pos hp)) (hw p hp).le + have hK : Continuous K := (hf.comp (continuous_id.pow 2)).mul (hH.comp (continuous_id.pow 2)) + let U : Set ℝ := Set.Ioi 0 ∩ {p | 0 < K p} + have hopen : IsOpen U := isOpen_Ioi.inter (isOpen_lt continuous_const hK) + have hune : U.Nonempty := by + obtain ⟨x,hx,hp⟩ := hp + refine ⟨Real.sqrt x,Real.sqrt_pos.mpr hx,?_⟩ + dsimp [K] + rwa [Real.sq_sqrt hx.le] + have hup : 0 < (volume.restrict (Set.Ioi (0:ℝ))) U := by + rw [Measure.restrict_apply hopen.measurableSet,Set.inter_eq_left.mpr Set.inter_subset_left] + exact hopen.measure_pos volume hune + have hus : U⊆Function.support g := by + intro p hp + exact (mul_pos hp.2 (hw p hp.1)).ne' + exact (integral_pos_iff_support_of_nonneg_ae hgn hi).mpr (hup.trans_le (measure_mono hus)) +lemma family_pairing_integral {n : ℕ} (G : ℕ → ℝ → ℝ) (a : Fin n → ℝ) (f w : ℝ → ℝ) + (hi : ∀ i : Fin n,IntegrableOn (fun p=>f (p^2)*G i (p^2)*w p) (Set.Ioi 0)) : + IntegrableOn (fun p=>f (p^2)*familyCombination G a (p^2)*w p) (Set.Ioi 0) ∧ + (∫ p in Set.Ioi (0:ℝ),f (p^2)*familyCombination G a (p^2)*w p)= + ∑ i,a i*(∫ p in Set.Ioi (0:ℝ),f (p^2)*G i (p^2)*w p) := by + have he : (fun p=>f (p^2)*familyCombination G a (p^2)*w p)= + fun p=>∑ i,a i*(f (p^2)*G i (p^2)*w p) := by + funext p + simp only [familyCombination,mul_sum,sum_mul] + apply sum_congr rfl + intro i _ + ring + have hi' (i : Fin n) := (hi i).const_mul (a i) + rw [he] + constructor + · exact integrable_finsetSum _ (fun i _=>hi' i) + · rw [integral_finsetSum _ (fun i _=>hi' i)] + simp only [integral_const_mul] +lemma family_pairing_last {n : ℕ} (G : ℕ → ℝ → ℝ) (a : Fin (n+1) → ℝ) (f w : ℝ → ℝ) + (hi : ∀ i : Fin (n+1),IntegrableOn (fun p=>f (p^2)*G i (p^2)*w p) (Set.Ioi 0)) + (hz : ∀ i : Fin n,(∫ p in Set.Ioi (0:ℝ),f (p^2)*G i (p^2)*w p)=0) : + (∫ p in Set.Ioi (0:ℝ),f (p^2)*familyCombination G a (p^2)*w p)= + a (Fin.last n)*(∫ p in Set.Ioi (0:ℝ),f (p^2)*G n (p^2)*w p) := by + rw [(family_pairing_integral G a f w hi).2,Fin.sum_univ_castSucc] + have h : (∑ i : Fin n,a i.castSucc*(∫ p in Set.Ioi (0:ℝ),f (p^2)*G i.castSucc (p^2)*w p))=0 := by + apply sum_eq_zero + intro i _ + rw [show G i.castSucc=G i from rfl,hz,mul_zero] + rw [h,zero_add] + rfl +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +/-- Chebyshev interpolation gives positive orientation of a border pairing at a real root. -/ +theorem monic_cross_pairing_pos {n : ℕ} (F G : ℕ → ℝ → ℝ) (a : Fin (n+1) → ℝ) + (w : ℝ → ℝ) (r : ℝ) (hF : PositiveFlag F (n+1)) (hG : PositiveFlag G (n+2)) + (hFc : ∀ i : Fin (n+1),Continuous (F i)) (hGc : ∀ i : Fin (n+2),Continuous (G i)) + (ha : a (Fin.last n)=1) (hw : ∀ p,0 < p → 0 < w p) + (hi : ∀ i : Fin (n+2),IntegrableOn (fun p=>(p^2-r)*familyCombination F a (p^2)*G i (p^2)*w p) (Set.Ioi 0)) + (ho : ∀ i : Fin (n+1),(∫ p in Set.Ioi (0:ℝ),(p^2-r)*familyCombination F a (p^2)*G i (p^2)*w p)=0) : + 0 < (∫ p in Set.Ioi (0:ℝ),(p^2-r)*familyCombination F a (p^2)*G (n+1) (p^2)*w p) := by + classical + have han : a ≠ 0 := by intro he;have hh:=congrFun he (Fin.last n);simp [ha] at hh + obtain ⟨Z,hZc,hZ,hr,hrZ⟩ := flag_orthogonal_linear_zeros F G a w r (hF _ le_rfl) + (fun k hk=>hG k (by omega)) hFc (fun i=>hGc i.castSucc) han hw (fun i=>hi i.castSucc) ho + let o := Z.orderIsoOfFin hZc + let v : Fin n → ℝ := fun i=>(o i).val + have hv : StrictMono v := o.strictMono + have hv0 i : 0 < v i := ((hZ _).mp (o i).property).1 + have haz i : familyCombination F a (v i)=0 := ((hZ _).mp (o i).property).2 + have hprod (x : ℝ) : (∏ i : Fin n,(x-v i))=∏ z ∈ Z,(x-z) := by + calc + _ = ∏ z : Z,(x-z.val) := Equiv.prod_comp o.toEquiv (fun z : Z=>x-z.val) + _ = _ := Finset.prod_attach _ _ + let S := insert r Z + have hSc : S.card=n+1 := by simp [S,card_insert_of_notMem hrZ,hZc] + have hS0 : ∀ x ∈ S,0 < x := by + intro x hx + rcases mem_insert.mp hx with he|hz + · exact he ▸ hr + · exact ((hZ x).mp hz).1 + let q := S.orderIsoOfFin hSc + let u : Fin (n+1) → ℝ := fun i=>(q i).val + have hu : StrictMono u := q.strictMono + have hu0 i : 0 < u i := hS0 _ (q i).property + have hprodS (x : ℝ) : (∏ i : Fin (n+1),(x-u i))=∏ z ∈ S,(x-z) := by + calc + _ = ∏ z : S,(x-z.val) := Equiv.prod_comp q.toEquiv (fun z : S=>x-z.val) + _ = _ := Finset.prod_attach _ _ + let g : ℝ → ℝ := fun x=>(x-r)*familyCombination F a x + have hgsign (x : ℝ) (hx : 0 < x) (hxS : x ∉ S) : 0 < g x*(∏ z ∈ S,(x-z)) := by + have hxZ : x ∉ Z := fun h=>hxS (mem_insert_of_mem h) + have hxr : x ≠ r := fun h=>hxS (h ▸ mem_insert_self _ _) + have hxv i : x ≠ v i := fun h=>hxZ (h.symm ▸ (o i).property) + have hh:=monic_family_sign F a v (hF _ le_rfl) (hF _ (by omega)) ha hv hv0 haz hx hxv + rw [hprod] at hh + have hp:=mul_pos (sq_pos_of_ne_zero (sub_ne_zero.mpr hxr)) hh + dsimp [g,S] + rw [prod_insert hrZ] + nlinarith only [hp] + let e : ℝ := (-1)^(n+1) + let B : Fin (n+2) → ℝ := fun i=>e*familyTestCoeffs G u i + have hBl : 0 < B (Fin.last (n+1)) := by + change 0 < e*familyTestCoeffs G u (Fin.last (n+1)) + rw [familyTestCoeffs_last] + have hD:=hG (n+1) (by omega) u hu hu0 + have he : e*((-1:ℝ)^(n+1))=1 := by dsimp [e];rw [←pow_add,show n+1+(n+1)=2*(n+1) by omega,pow_mul];norm_num + rw [←mul_assoc,he,one_mul] + exact hD + have hBsign (x : ℝ) (hx : 0 < x) (hxS : x ∉ S) : + 0 < familyCombination G B x*(∏ z ∈ S,(x-z)) := by + have hxu i : x ≠ u i := fun h=>hxS (h.symm ▸ (q i).property) + have hh:=familyTest_sign_product G u (hG _ le_rfl) hu hu0 hx hxu + have hn : (∏ i : Fin (n+1),(u i-x))=e*(∏ z ∈ S,(x-z)) := by + simp_rw [show ∀ i : Fin (n+1),u i-x=(-1:ℝ)*(x-u i) from fun i=>by ring] + rw [prod_mul_distrib,prod_const,card_univ,Fintype.card_fin,hprodS] + rw [hn] at hh + dsimp [B] + rw [familyCombination_smul] + nlinarith only [hh] + have hstrict (x : ℝ) (hx : 0 < x) (hxS : x ∉ S) : 0 < g x*familyCombination G B x := by + have hh:=mul_pos (hgsign x hx hxS) (hBsign x hx hxS) + have he : (g x*(∏ z ∈ S,(x-z)))*(familyCombination G B x*(∏ z ∈ S,(x-z)))= + (g x*familyCombination G B x)*(∏ z ∈ S,(x-z))^2 := by ring + rw [he] at hh + exact pos_of_mul_pos_left hh (sq_nonneg _) + have hn (x : ℝ) (hx : 0 < x) : 0 ≤ g x*familyCombination G B x := by + by_cases hxS : x ∈ S + · have hg : g x=0 := by + rcases mem_insert.mp hxS with h|h + · simp [g,h] + · simp [g,((hZ x).mp h).2] + simp [hg] + · exact (hstrict x hx hxS).le + have hp : ∃ x,0 < x ∧ 0 < g x*familyCombination G B x := by + obtain ⟨R,hR⟩ := (insert 0 S).finite_toSet.bddAbove + have hR0 : 0 ≤ R := hR (by simp) + refine ⟨R+1,by linarith,hstrict _ (by linarith) ?_⟩ + intro hh + have h := hR (mem_insert_of_mem hh) + linarith + have hc : Continuous g := (continuous_id.sub continuous_const).mul (familyCombination_continuous F a hFc) + have hpos := positive_continuous_pairing g (familyCombination G B) w hc + (familyCombination_continuous G B hGc) hw (family_pairing_integral G B g w hi).1 hn hp + rw [family_pairing_last G B g w hi ho] at hpos + exact pos_of_mul_pos_right hpos hBl.le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset + +theorem det_border_last_column {n : ℕ} (B : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) + (h : Fin (n+1) → ℝ) (hh : h (Fin.last n)=1) + (hz : ∀ i : Fin n,(B *ᵥ h) i.castSucc=0) : + B.det = (B *ᵥ h) (Fin.last n) * + (B.submatrix Fin.castSucc Fin.castSucc).det := by + classical + let C := updateCol B (Fin.last n) (B *ᵥ h) + have hdet : C.det=B.det := by + have he : B *ᵥ h=(fun i=>∑ j,h j • B i j) := by + ext i + simp only [mulVec, dotProduct, smul_eq_mul] + apply sum_congr rfl + intro j _ + ring + dsimp [C] + rw [he,det_updateCol_sum,hh,one_smul] + rw [←hdet,det_succ_column C (Fin.last n)] + rw [Fin.sum_univ_castSucc] + have hz' : ∀ i : Fin n,C i.castSucc (Fin.last n)=0 := by + intro i + simpa [C] using hz i + simp only [hz',mul_zero,zero_mul,sum_const_zero,zero_add] + have hm : C.submatrix (Fin.last n).succAbove (Fin.last n).succAbove= + B.submatrix Fin.castSucc Fin.castSucc := by + ext i j + simp [C,Fin.succAbove_last] + rw [hm] + simp only [C,updateCol_self,Fin.val_last] + rw [show n+n=2*n by omega,pow_mul] + norm_num + + theorem det_double_border_at_nullvectors {n : ℕ} + (B : Matrix (Fin (n+2)) (Fin (n+2)) ℝ) + (a h : Fin (n+1) → ℝ) (ha : a (Fin.last n)=1) (hh : h (Fin.last n)=1) + (hla : a ᵥ* (B.submatrix Fin.castSucc Fin.castSucc)=0) + (hrh : (B.submatrix Fin.castSucc Fin.castSucc) *ᵥ h=0) : + B.det = - (B.submatrix (fun i : Fin n=>i.castSucc.castSucc) + (fun i : Fin n=>i.castSucc.castSucc)).det * + ((Fin.lastCases 0 a) ᵥ* B) (Fin.last (n+1)) * + (B *ᵥ (Fin.lastCases 0 h)) (Fin.last (n+1)) := by + classical + let j : Fin (n+2) := (Fin.last n).castSucc + let aa : Fin (n+2) → ℝ := Fin.lastCases 0 a + let C := updateRow B j (aa ᵥ* B) + have hdet : C.det=B.det := by + have he : aa ᵥ* B=∑ k,aa k • B k := by + ext i + simp only [vecMul, dotProduct, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + dsimp [C] + rw [he,det_updateRow_sum] + simp [aa,j,ha] + have hz (i : Fin (n+1)) : (aa ᵥ* B) i.castSucc=0 := by + have H:=congrFun hla i + simpa [vecMul,dotProduct,Fin.sum_univ_castSucc,aa,submatrix_apply] using H + have hentry (i : Fin (n+1)) : C j i.castSucc=0 := by simpa [C] using hz i + rw [←hdet,det_succ_row C j,Fin.sum_univ_castSucc] + simp only [hentry,mul_zero,zero_mul,sum_const_zero,zero_add] + have hs : (-1:ℝ)^(j.val+(Fin.last (n+1)).val)= -1 := by + change (-1:ℝ)^(n+(n+1))= -1 + rw [show n+(n+1)=2*n+1 by omega,pow_succ,pow_mul] + norm_num + rw [hs] + let D := C.submatrix j.succAbove (Fin.last (n+1)).succAbove + have hi (i : Fin n) : j.succAbove i.castSucc=i.castSucc.castSucc := by + apply Fin.succAbove_castSucc_of_lt + change i.val rw [Fin.sum_univ_castSucc] + simp only [Fin.lastCases_castSucc,Fin.lastCases_last,mul_zero,add_zero] + have hDP : D.submatrix Fin.castSucc Fin.castSucc= + B.submatrix (fun i : Fin n=>i.castSucc.castSucc) (fun i : Fin n=>i.castSucc.castSucc) := by + ext i k + exact (hD i.castSucc k.castSucc).trans (by rw [hi];rfl) + change -1*C j (Fin.last (n+1))*D.det= _ + rw [det_border_last_column D h hh hDz,hDl,hDP] + simp only [C,updateRow_self] + dsimp [aa] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PositiveJets.lean b/lean/OAI/Combinatorics/HoneycombChords/PositiveJets.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e628a8b29f7b2b4088244abd6560aa91651196f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PositiveJets.lean @@ -0,0 +1,826 @@ +import Mathlib + +namespace OAI + +/-! Positive confluent power and hyperbolic kernel determinants and Andreief integration. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix +open Set (Icc) +lemma signVariations_lt_support (P : Polynomial ℝ) (hP : P ≠ 0) : + P.signVariations < P.support.card := by + generalize hn : P.support.card = n + induction n using Nat.strong_induction_on generalizing P with + | h n ih => + have hc := Polynomial.card_support_eraseLead_add_one hP + rw [Polynomial.signVariations_eq_eraseLead_add_ite hP] + by_cases he : P.eraseLead = 0 + · have hs : SignType.sign P.leadingCoeff ≠ 0 := by + simpa using hP + simp only [he, signVariations_zero, leadingCoeff_zero, sign_zero, neg_zero, + ite_eq_right hs, add_zero] + have : 0 < P.support.card := Finset.card_pos.mpr (Polynomial.support_nonempty.mpr hP) + omega + · have hh := ih P.eraseLead.support.card (by omega) P.eraseLead he rfl + split_ifs <;> omega + +lemma positive_roots_lt_support (P : Polynomial ℝ) (hP : P ≠ 0) : + P.roots.countP (0 < ·) < P.support.card := + (P.roots_countP_pos_le_signVariations).trans_lt (signVariations_lt_support P hP) + +lemma sparse_polynomial_eq_zero {n : ℕ} (e : Fin n → ℕ) (c : Fin n → ℝ) + (x : Fin n → ℝ) (hx : Function.Injective x) (hpos : ∀ j,0 < x j) + (hz : ∀ j,∑ i : Fin n,c i*(x j)^e i=0) : + (∑ i : Fin n,Polynomial.monomial (e i) (c i)) = 0 := by + classical + let P : Polynomial ℝ := ∑ i : Fin n,Polynomial.monomial (e i) (c i) + by_contra hP + have hs : P.support ⊆ univ.image e := by + intro k hk + by_contra hn + have he : ∀ i : Fin n,k ≠ e i := by + intro i hi + exact hn (mem_image.mpr ⟨i,mem_univ _,hi.symm⟩) + have : P.coeff k = 0 := by + simp [P, Polynomial.finsetSum_coeff, Polynomial.coeff_monomial,fun i=>(he i).symm] + exact (Polynomial.mem_support_iff.mp hk) this + have hcard : P.support.card ≤ n := (card_le_card hs).trans (by simpa using card_image_le (s:=univ) (f:=e)) + have hroots : univ.image x ⊆ (P.roots.filter (0 < ·)).toFinset := by + rintro r hr + rcases mem_image.mp hr with ⟨j,_,rfl⟩ + simp only [Multiset.mem_toFinset,Multiset.mem_filter] + refine ⟨?_,hpos j⟩ + apply (Polynomial.mem_roots hP).mpr + change P.eval (x j)=0 + simpa [P,Polynomial.eval_finsetSum] using hz j + have hRootCard : n ≤ P.roots.countP (0 < ·) := by + rw [Multiset.countP_eq_card_filter] + calc + n=(univ.image x).card := by simp [card_image_of_injective _ hx] + _ ≤ (P.roots.filter (0 < ·)).toFinset.card := card_le_card hroots + _ ≤ _ := Multiset.toFinset_card_le _ + have hlt := positive_roots_lt_support P hP + omega + +lemma power_det_ne_zero {n : ℕ} (e : Fin n → ℕ) (x : Fin n → ℝ) + (he : Function.Injective e) (hx : Function.Injective x) (hpos : ∀ j,0 < x j) : + Matrix.det (fun i j=>x j^e i) ≠ 0 := by + classical + apply isUnit_iff_ne_zero.mp + apply (Matrix.isUnit_iff_isUnit_det _).mp + apply Matrix.linearIndependent_rows_iff_isUnit.mp + rw [Fintype.linearIndependent_iff] + intro c hc i + have hz : ∀ j,∑ k : Fin n,c k*x j^e k=0 := by + intro j + simpa [Matrix.row] using congrFun hc j + have hp := sparse_polynomial_eq_zero e c x hx hpos hz + have hcoeff := congrArg (fun P : Polynomial ℝ=>P.coeff (e i)) hp + simpa [Polynomial.finsetSum_coeff, Polynomial.coeff_monomial,he.eq_iff,eq_comm] using hcoeff + +lemma power_det_pos_geometric {n : ℕ} (e : Fin n → ℕ) (he : StrictMono e) : + 0 < Matrix.det (fun i j : Fin n=>(2:ℝ)^(j.val*e i)) := by + have hm : (fun i j : Fin n=>(2:ℝ)^(j.val*e i))=Matrix.vandermonde (fun i=>(2:ℝ)^e i) := by + ext i j + change (2:ℝ)^(j.val*e i)=((2:ℝ)^e i)^j.val + rw [←pow_mul,mul_comm] + rw [hm,Matrix.det_vandermonde] + apply Finset.prod_pos + intro i _ + apply Finset.prod_pos + intro j hj + apply sub_pos.mpr + exact pow_lt_pow_right₀ (by norm_num) (he (Finset.mem_Ioi.mp hj)) + +lemma power_det_pos {n : ℕ} (e : Fin n → ℕ) (x : Fin n → ℝ) + (he : StrictMono e) (hx : StrictMono x) (hpos : ∀ j,0 < x j) : + 0 < Matrix.det (fun i j=>x j^e i) := by + let z : ℝ → Fin n → ℝ := fun t j=>(1-t)*x j+t*2^j.val + let f : ℝ → ℝ := fun t=>Matrix.det (fun i j=>z t j^e i) + have hc : Continuous f := by + apply Continuous.matrix_det + fun_prop + have h0 : f 0=Matrix.det (fun i j=>x j^e i) := by simp [f,z] + have h1 : 0 < f 1 := by + simpa [f,z,←pow_mul] using power_det_pos_geometric e he + have hne : ∀ t∈Icc (0:ℝ) 1,f t≠0 := by + intro t ht + apply power_det_ne_zero e (z t) he.injective + · apply StrictMono.injective + intro i j hij + have hp : (2:ℝ)^i.val < 2^j.val := pow_lt_pow_right₀ (by norm_num) hij + have hxp := hx hij + dsimp [z] + rcases ht.1.eq_or_lt with rfl|htt + · simpa using hxp + · nlinarith [mul_pos htt (sub_pos.mpr hp),mul_nonneg (sub_nonneg.mpr ht.2) (sub_nonneg.mpr hxp.le)] + · intro j + dsimp [z] + have hp : 0 < (2:ℝ)^j.val := by positivity + rcases ht.1.eq_or_lt with rfl|htt + · simpa using hpos j + · exact add_pos_of_nonneg_of_pos (mul_nonneg (sub_nonneg.mpr ht.2) (hpos j).le) (mul_pos htt hp) + by_contra hh + have hf0 : f 0 ≤ 0 := by rw [h0];exact le_of_not_gt hh + obtain ⟨t,ht,heq⟩:=intermediate_value_Icc (show (0:ℝ) ≤ 1 by norm_num) hc.continuousOn ⟨hf0,h1.le⟩ + exact hne t ht heq +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix +noncomputable def newtonBasis (b : ℕ → ℝ) (n : ℕ) : Polynomial ℝ := + ∏ j ∈ range n,(X-Polynomial.C (b j)) +noncomputable def newtonQuot (b : ℕ → ℝ) (P : Polynomial ℝ) : ℕ → Polynomial ℝ + | 0 => P + | n+1 => newtonQuot b P n /ₘ (X-Polynomial.C (b n)) +noncomputable def newtonCoeff (b : ℕ → ℝ) (P : Polynomial ℝ) (n : ℕ) : ℝ := + (newtonQuot b P n).eval (b n) +noncomputable def nodalOrder (b : ℕ → ℝ) (n : ℕ) : ℕ := + ((range n).filter (fun j=>b j=b n)).card +noncomputable def polynomialJet (P : Polynomial ℝ) (a : ℝ) (k : ℕ) : ℝ := + (taylor a P).coeff k +lemma newtonBasis_succ (b : ℕ → ℝ) (n : ℕ) : + newtonBasis b (n+1)=newtonBasis b n*(X-Polynomial.C (b n)) := by + simp [newtonBasis,prod_range_succ] +lemma newton_decomposition (b : ℕ → ℝ) (P : Polynomial ℝ) (n : ℕ) : + P=(∑ j ∈ range n,Polynomial.C (newtonCoeff b P j)*newtonBasis b j)+newtonBasis b n*newtonQuot b P n := by + induction n with + | zero => simp [newtonBasis,newtonQuot] + | succ n ih => + have h := (newtonQuot b P n).modByMonic_add_div (X-Polynomial.C (b n)) + rw [modByMonic_X_sub_C_eq_C_eval] at h + calc + P=(∑ j ∈ range n,Polynomial.C (newtonCoeff b P j)*newtonBasis b j)+newtonBasis b n*newtonQuot b P n := ih + _=(∑ j ∈ range n,Polynomial.C (newtonCoeff b P j)*newtonBasis b j)+newtonBasis b n*(Polynomial.C ((newtonQuot b P n).eval (b n))+(X-Polynomial.C (b n))*(newtonQuot b P n/ₘ(X-Polynomial.C (b n)))) := by rw [h] + _=_ := by rw [sum_range_succ,newtonBasis_succ,newtonQuot,newtonCoeff];ring +lemma newtonQuot_natDegree_le (b : ℕ → ℝ) (P : Polynomial ℝ) (n : ℕ) : + (newtonQuot b P n).natDegree ≤ P.natDegree := by + induction n with + | zero => rfl + | succ n ih => exact (natDegree_le_natDegree (degree_divByMonic_le _ _)).trans ih +lemma coeff_divByMonic_linear_fixed (P : Polynomial ℝ) (a : ℝ) (k D : ℕ) + (hD : P.natDegree ≤ D) : + (P/ₘ(X-Polynomial.C a)).coeff k=∑ j ∈ Icc (k+1) D,a^(j-(k+1))*P.coeff j := by + rw [coeff_divByMonic_X_sub_C] + apply sum_subset + · intro j hj + exact mem_Icc.mpr ⟨(mem_Icc.mp hj).1,(mem_Icc.mp hj).2.trans hD⟩ + · intro j hj hn + rw [coeff_eq_zero_of_natDegree_lt,mul_zero] + exact lt_of_not_ge (fun hh=>hn (mem_Icc.mpr ⟨(mem_Icc.mp hj).1,hh⟩)) +lemma continuous_newtonQuot_coeff (P : Polynomial ℝ) (n k : ℕ) : + Continuous (fun b : ℕ → ℝ=>(newtonQuot b P n).coeff k) := by + induction n generalizing k with + | zero => + change Continuous (fun _ : ℕ → ℝ => P.coeff k) + exact continuous_const + | succ n ih => + have he : (fun b : ℕ → ℝ=>(newtonQuot b P (n+1)).coeff k)= + fun b=>∑ j ∈ Icc (k+1) P.natDegree,b n^(j-(k+1))*(newtonQuot b P n).coeff j := by + funext b + exact coeff_divByMonic_linear_fixed _ _ _ _ (newtonQuot_natDegree_le b P n) + rw [he] + exact continuous_finsetSum _ (fun j _=>(continuous_apply n).pow _ |>.mul (ih j)) +lemma continuous_newtonCoeff (P : Polynomial ℝ) (n : ℕ) : + Continuous (fun b=>newtonCoeff b P n) := by + have he : (fun b=>newtonCoeff b P n)=fun b=>∑ j ∈ range (P.natDegree+1), + (newtonQuot b P n).coeff j*b n^j := by + funext b + dsimp [newtonCoeff] + rw [Polynomial.eval_eq_sum_range] + apply sum_subset + · exact range_mono (Nat.add_le_add_right (newtonQuot_natDegree_le b P n) 1) + · intro j _ hj + rw [coeff_eq_zero_of_natDegree_lt,zero_mul] + exact Nat.lt_of_succ_le ((not_lt).mp (by simpa using hj)) + rw [he] + exact continuous_finsetSum _ (fun j _=>(continuous_newtonQuot_coeff P n j).mul ((continuous_apply n).pow j)) + +lemma taylor_nodal_product (b : ℕ → ℝ) (s : Finset ℕ) (a : ℝ) : + taylor a (∏ j∈s,(X-Polynomial.C (b j)))= + X^((s.filter (fun j=>b j=a)).card)*∏ j∈s.filter (fun j=>b j≠a),(X+Polynomial.C (a-b j)) := by + classical + change (taylorAlgHom a) (∏ j∈s,(X-Polynomial.C (b j)))=_ + rw [map_prod] + change (∏ j∈s,taylor a (X-Polynomial.C (b j)))=_ + have he : (fun j=>taylor a (X-Polynomial.C (b j)))=fun j=>X+Polynomial.C (a-b j) := by + funext j + simp [taylor_X,taylor_C,sub_eq_add_neg,add_assoc] + rw [he,←Finset.prod_filter_mul_prod_filter_not (s:=s) (p:=fun j=>b j=a)] + congr 1 + calc + ∏ j∈s.filter (fun j=>b j=a),(X+Polynomial.C (a-b j))=∏ _j∈s.filter (fun j=>b j=a),(X:Polynomial ℝ) := by + apply prod_congr rfl + intro j hj + simp [(mem_filter.mp hj).2] + _ = _ := by simp +lemma polynomialJet_nodal_product_self (b : ℕ → ℝ) (s : Finset ℕ) (a : ℝ) : + polynomialJet (∏ j∈s,(X-Polynomial.C (b j))) a ((s.filter (fun j=>b j=a)).card)= + ∏ j∈s.filter (fun j=>b j≠a),(a-b j) := by + rw [polynomialJet,taylor_nodal_product] + rw [coeff_X_pow_mul'] + simp only [Nat.le_refl,ite_true,Nat.sub_self] + rw [coeff_zero_eq_eval_zero,Polynomial.eval_prod] + simp +lemma polynomialJet_mul_nodal_product_zero (b : ℕ → ℝ) (s : Finset ℕ) (a : ℝ) + (k : ℕ) (Q : Polynomial ℝ) (hk : k < (s.filter (fun j=>b j=a)).card) : + polynomialJet ((∏ j∈s,(X-Polynomial.C (b j)))*Q) a k=0 := by + rw [polynomialJet,taylor_mul,taylor_nodal_product,mul_assoc,coeff_X_pow_mul'] + simp [not_le.mpr hk] +lemma nodalOrder_lt_count {b : ℕ → ℝ} {k n : ℕ} (hkn : k < n) : + nodalOrder b k < ((range n).filter (fun j=>b j=b k)).card := by + classical + have hs : insert k ((range k).filter (fun j=>b j=b k)) ⊆ (range n).filter (fun j=>b j=b k) := by + intro j hj + rcases mem_insert.mp hj with rfl|hj + · simp [hkn] + · exact mem_filter.mpr ⟨mem_range.mpr ((mem_range.mp (mem_filter.mp hj).1).trans hkn),(mem_filter.mp hj).2⟩ + have hcard := card_le_card hs + have hk : k ∉ (range k).filter (fun j=>b j=b k) := by simp + rw [card_insert_of_notMem hk] at hcard + exact Nat.lt_of_lt_of_le (Nat.lt_succ_self _) hcard +lemma polynomialJet_newtonBasis_gt {b : ℕ → ℝ} {k n : ℕ} (hkn : k < n) : + polynomialJet (newtonBasis b n) (b k) (nodalOrder b k)=0 := by + simpa [newtonBasis] using polynomialJet_mul_nodal_product_zero b (range n) (b k) (nodalOrder b k) 1 (nodalOrder_lt_count hkn) +lemma polynomialJet_newtonBasis_diagonal (b : ℕ → ℝ) (k : ℕ) : + polynomialJet (newtonBasis b k) (b k) (nodalOrder b k)= + ∏ j∈(range k).filter (fun j=>b j≠b k),(b k-b j) := + polynomialJet_nodal_product_self b (range k) (b k) +lemma polynomialJet_decomposition {n : ℕ} (b : ℕ → ℝ) (P : Polynomial ℝ) (k : Fin n) : + polynomialJet P (b k) (nodalOrder b k)=∑ j : Fin n,newtonCoeff b P j*polynomialJet (newtonBasis b j) (b k) (nodalOrder b k) := by + have h := congrArg (fun Q=>polynomialJet Q (b k) (nodalOrder b k)) (newton_decomposition b P n) + have hz:=polynomialJet_mul_nodal_product_zero b (range n) (b k) (nodalOrder b k) (newtonQuot b P n) (nodalOrder_lt_count k.isLt) + have hsum : polynomialJet (∑ j∈range n,Polynomial.C (newtonCoeff b P j)*newtonBasis b j) (b k) (nodalOrder b k)= + ∑ j∈range n,newtonCoeff b P j*polynomialJet (newtonBasis b j) (b k) (nodalOrder b k) := by + simp [polynomialJet,map_sum,taylor_mul,Polynomial.coeff_C_mul] + have h2 : polynomialJet P (b k) (nodalOrder b k)= + polynomialJet (∑ j∈range n,Polynomial.C (newtonCoeff b P j)*newtonBasis b j) (b k) (nodalOrder b k)+ + polynomialJet (newtonBasis b n*newtonQuot b P n) (b k) (nodalOrder b k) := by + simpa only [polynomialJet,map_add,coeff_add] using h + rw [hsum,show polynomialJet (newtonBasis b n*newtonQuot b P n) (b k) (nodalOrder b k)=0 from hz,add_zero] at h2 + rw [Fin.sum_univ_eq_sum_range (fun j=>newtonCoeff b P j*polynomialJet (newtonBasis b j) (b k) (nodalOrder b k)) n] + exact h2 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix Filter Topology +noncomputable def newtonJetMatrix (n : ℕ) (b : ℕ → ℝ) : Matrix (Fin n) (Fin n) ℝ := + fun i j=>polynomialJet (newtonBasis b i) (b j) (nodalOrder b j) +lemma newtonJetMatrix_det (n : ℕ) (b : ℕ → ℝ) : + (newtonJetMatrix n b).det=∏ k : Fin n,∏ j∈(range k.val).filter (fun j=>b j≠b k),(b k-b j) := by + rw [Matrix.det_of_isUpperTriangular] + · apply prod_congr rfl + intro k _ + exact polynomialJet_newtonBasis_diagonal b k + · intro i j hij + exact polynomialJet_newtonBasis_gt hij +lemma newtonJetMatrix_det_pos {n : ℕ} (b : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) : 0 < (newtonJetMatrix n b).det := by + rw [newtonJetMatrix_det] + apply prod_pos + intro k _ + apply prod_pos + intro j hj + have hjk : j < k.val := mem_range.mp (mem_filter.mp hj).1 + have hbj := hb (show (⟨j,hjk.trans k.isLt⟩:Fin n) ≤ k from Nat.le_of_lt hjk) + exact sub_pos.mpr (lt_of_le_of_ne hbj (mem_filter.mp hj).2) +lemma jet_det_factorization {n : ℕ} (b : ℕ → ℝ) (P : Fin n → Polynomial ℝ) : + Matrix.det (fun i j=>polynomialJet (P i) (b j) (nodalOrder b j))= + Matrix.det (fun i j : Fin n=>newtonCoeff b (P i) j)*(newtonJetMatrix n b).det := by + have hm : (Matrix.of fun i j : Fin n=>polynomialJet (P i) (b j) (nodalOrder b j))= + (Matrix.of fun i j : Fin n=>newtonCoeff b (P i) j)*newtonJetMatrix n b := by + ext i j + exact polynomialJet_decomposition b (P i) j + exact (congrArg Matrix.det hm).trans (Matrix.det_mul _ _) +lemma nodalOrder_eq_zero_strict {n : ℕ} {b : ℕ → ℝ} (hb : StrictMono (fun i : Fin n=>b i)) (k : Fin n) : + nodalOrder b k=0 := by + classical + unfold nodalOrder + rw [card_eq_zero,filter_eq_empty_iff] + intro j hj + have hlt := hb (show (⟨j,(mem_range.mp hj).trans k.isLt⟩:Fin n) < k from mem_range.mp hj) + exact hlt.ne +lemma polynomialJet_zero (P : Polynomial ℝ) (a : ℝ) : polynomialJet P a 0=P.eval a := by + simp [polynomialJet,coeff_zero_eq_eval_zero,Polynomial.taylor_eval] +lemma newton_power_det_pos {n : ℕ} (b : ℕ → ℝ) (e : Fin n → ℕ) + (hb : StrictMono (fun i : Fin n=>b i)) (hpos : ∀ i : Fin n,0 < b i) (he : StrictMono e) : + 0 < Matrix.det (fun i j : Fin n=>newtonCoeff b (X^e i) j) := by + have h := power_det_pos e (fun i : Fin n=>b i) he hb hpos + have hf := jet_det_factorization b (fun i=>X^e i) + have hj : (fun i j : Fin n=>polynomialJet ((X:Polynomial ℝ)^e i) (b j) (nodalOrder b j))= + fun i j : Fin n=>b j^e i := by + ext i j + rw [nodalOrder_eq_zero_strict hb,polynomialJet_zero] + simp + rw [←hj,hf] at h + exact (mul_pos_iff_of_pos_right (newtonJetMatrix_det_pos b hb.monotone)).mp h +lemma newton_power_det_nonneg {n : ℕ} (b : ℕ → ℝ) (e : Fin n → ℕ) + (hb : Monotone (fun i : Fin n=>b i)) (hpos : ∀ i : Fin n,0 ≤ b i) (he : StrictMono e) : + 0 ≤ Matrix.det (fun i j : Fin n=>newtonCoeff b (X^e i) j) := by + let B : ℝ → ℕ → ℝ := fun t j=>b j+t*(j+1) + let f : ℝ → ℝ := fun t=>Matrix.det (fun i j : Fin n=>newtonCoeff (B t) (X^e i) j) + have hc : Continuous f := by + apply Continuous.matrix_det + apply continuous_pi + intro i + apply continuous_pi + intro j + exact (continuous_newtonCoeff (X^e i) j).comp (by dsimp [B];fun_prop) + have hp : ∀ᶠ t in 𝓝[>] (0:ℝ),0 ≤ f t := by + filter_upwards [self_mem_nhdsWithin] with t ht + apply (newton_power_det_pos (B t) e _ _ he).le + · intro i j hij + have hb' := hb hij.le + have hc' : (i:ℝ) < (j:ℝ) := by exact_mod_cast hij + dsimp [B] + nlinarith [mul_pos ht (sub_pos.mpr hc')] + · intro i + dsimp [B] + exact add_pos_of_nonneg_of_pos (hpos i) (mul_pos ht (by positivity)) + have hh : 0 ≤ f 0 := ge_of_tendsto (hc.continuousAt.tendsto.mono_left (show 𝓝[>] (0:ℝ) ≤ 𝓝 0 from nhdsWithin_le_nhds)) hp + simpa [f,B] using hh +lemma power_jet_det_nonneg {n : ℕ} (b : ℕ → ℝ) (e : Fin n → ℕ) + (hb : Monotone (fun i : Fin n=>b i)) (hpos : ∀ i : Fin n,0 ≤ b i) (he : StrictMono e) : + 0 ≤ Matrix.det (fun i j : Fin n=>polynomialJet (X^e i) (b j) (nodalOrder b j)) := by + rw [jet_det_factorization] + exact mul_nonneg (newton_power_det_nonneg b e hb hpos he) (newtonJetMatrix_det_pos b hb).le + +lemma newtonQuot_natDegree (b : ℕ → ℝ) (P : Polynomial ℝ) (n : ℕ) : + (newtonQuot b P n).natDegree=P.natDegree-n := by + induction n with + | zero => simp [newtonQuot] + | succ n ih => simp [newtonQuot,natDegree_divByMonic _ (monic_X_sub_C _),ih,Nat.sub_sub] +lemma newtonQuot_leadingCoeff {b : ℕ → ℝ} {P : Polynomial ℝ} {n : ℕ} (hn : n ≤ P.natDegree) : + (newtonQuot b P n).leadingCoeff=P.leadingCoeff := by + induction n with + | zero => rfl + | succ n ih => + rw [newtonQuot,leadingCoeff_divByMonic_X_sub_C,ih (by omega)] + intro hz + have hdeg : (newtonQuot b P n).natDegree=0 := natDegree_eq_of_degree_eq_some hz + rw [newtonQuot_natDegree] at hdeg + omega +lemma newtonQuot_eq_zero_of_lt {b : ℕ → ℝ} {P : Polynomial ℝ} {n : ℕ} (hn : P.natDegree < n) : + newtonQuot b P n=0 := by + induction n with + | zero => omega + | succ n ih => + rw [newtonQuot] + apply (divByMonic_eq_zero_iff (monic_X_sub_C _)).mpr + rw [degree_X_sub_C] + have hh : (newtonQuot b P n).natDegree=0 := by rw [newtonQuot_natDegree];omega + exact (natDegree_eq_zero_iff_degree_le_zero.mp hh).trans_lt (by norm_num) +lemma newtonCoeff_X_pow_diagonal (b : ℕ → ℝ) (n : ℕ) : newtonCoeff b (X^n) n=1 := by + have hd : (newtonQuot b (X^n) n).natDegree=0 := by rw [newtonQuot_natDegree,natDegree_X_pow];omega + have hl : (newtonQuot b (X^n) n).leadingCoeff=1 := by + rw [newtonQuot_leadingCoeff (by simp),leadingCoeff_X_pow] + have he : newtonQuot b (X^n) n=1 := by + rw [eq_C_of_natDegree_eq_zero hd] + have hc := hl + rw [leadingCoeff,hd] at hc + rw [hc,Polynomial.C_1] + simp [newtonCoeff,he] +lemma newtonCoeff_X_pow_above {b : ℕ → ℝ} {i j : ℕ} (hij : i < j) : + newtonCoeff b (X^i) j=0 := by + rw [newtonCoeff,newtonQuot_eq_zero_of_lt (by simpa using hij)] + simp +lemma newton_consecutive_det (n : ℕ) (b : ℕ → ℝ) : + Matrix.det (fun i j : Fin n=>newtonCoeff b (X^i.val) j)=1 := by + have ht : (Matrix.of fun i j : Fin n=>newtonCoeff b (X^i.val) j).IsLowerTriangular := by + intro i j hij + exact newtonCoeff_X_pow_above hij + exact (Matrix.det_of_isLowerTriangular _ ht).trans (by simp [newtonCoeff_X_pow_diagonal]) +lemma consecutive_jet_det_pos {n : ℕ} (b : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) : + 0 < Matrix.det (fun i j : Fin n=>polynomialJet (X^i.val) (b j) (nodalOrder b j)) := by + rw [jet_det_factorization,newton_consecutive_det,one_mul] + exact newtonJetMatrix_det_pos b hb +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Equiv +lemma det_rectangular_expansion {n m : Type*} [Fintype n] [DecidableEq n] [Fintype m] + (A : Matrix n m ℝ) (B : Matrix m n ℝ) : + (A*B).det=∑ f : n → m, (A.submatrix id f).det*∏ i,B (f i) i := by + classical + simp only [Matrix.det_apply',Matrix.mul_apply,Finset.prod_univ_sum, + Finset.mul_sum,Fintype.piFinset_univ,Matrix.submatrix_apply,id_eq] + rw [Finset.sum_comm] + apply sum_congr rfl + intro f _ + rw [Finset.sum_mul] + apply sum_congr rfl + intro σ _ + rw [Finset.prod_mul_distrib,mul_assoc] +lemma det_rectangular_binet {n m : Type*} [Fintype n] [DecidableEq n] [Fintype m] + (A : Matrix n m ℝ) (B : Matrix m n ℝ) : + ∑ f : n → m,(A.submatrix id f).det*(B.submatrix f id).det= + Fintype.card (Equiv.Perm n)*(A*B).det := by + classical + simp_rw [Matrix.det_apply' (B.submatrix _ _),Finset.mul_sum] + rw [Finset.sum_comm] + have he (σ : Equiv.Perm n) : + (∑ f : n → m,(A.submatrix id f).det* + ((Equiv.Perm.sign σ:ℤ)*∏ i,(B.submatrix f id) (σ i) i))=(A*B).det := by + rw [det_rectangular_expansion] + let e : (n → m) ≃ (n → m) := Equiv.arrowCongr σ.symm (Equiv.refl m) + apply Fintype.sum_equiv e + intro f + have hm : A.submatrix id (e f)=(A.submatrix id f).submatrix id σ := by + ext i j + rfl + rw [hm,Matrix.det_permute'] + have hp : (∏ i,(B.submatrix f id) (σ i) i)=∏ i,B ((e f) i) i := by + rfl + rw [hp] + ring + simp_rw [he] + simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Equiv +lemma sorted_injective_exponents {n : ℕ} {e : Fin n → ℕ} (he : Function.Injective e) : + ∃ (d : Fin n → ℕ) (σ : Equiv.Perm (Fin n)),StrictMono d ∧ e=d∘σ := by + classical + let s := univ.image e + have hc : s.card=n := by simp [s,card_image_of_injective _ he] + let o := s.orderIsoOfFin hc + let q : Fin n ≃ s := Equiv.ofBijective (fun i=>⟨e i,mem_image.mpr ⟨i,mem_univ _,rfl⟩⟩) (by + constructor + · intro i j h + exact he (congrArg Subtype.val h) + · intro a + obtain ⟨i,_,hi⟩ := mem_image.mp a.property + exact ⟨i,Subtype.ext hi⟩) + refine ⟨fun i=>(o i).val,q.trans o.symm,?_,?_⟩ + · exact o.strictMono + · ext i + exact (congrArg Subtype.val (o.apply_symm_apply (q i))).symm +lemma power_jet_det_pair_nonneg {n : ℕ} (b x : ℕ → ℝ) (e : Fin n → ℕ) + (hb : Monotone (fun i : Fin n=>b i)) (hx : Monotone (fun i : Fin n=>x i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hx0 : ∀ i : Fin n,0 ≤ x i) : + 0 ≤ Matrix.det (fun i j : Fin n=>polynomialJet (X^e i) (b j) (nodalOrder b j))* + Matrix.det (fun i j : Fin n=>polynomialJet (X^e i) (x j) (nodalOrder x j)) := by + classical + by_cases he : Function.Injective e + · obtain ⟨d,σ,hd,he⟩ := sorted_injective_exponents he + rw [he] + let A : Matrix (Fin n) (Fin n) ℝ := fun i j=>polynomialJet (X^d i) (b j) (nodalOrder b j) + let B : Matrix (Fin n) (Fin n) ℝ := fun i j=>polynomialJet (X^d i) (x j) (nodalOrder x j) + change 0 ≤ (A.submatrix σ id).det*(B.submatrix σ id).det + rw [Matrix.det_permute,Matrix.det_permute] + have hA := power_jet_det_nonneg b d hb hb0 hd + have hB := power_jet_det_nonneg x d hx hx0 hd + have hp := mul_nonneg (sq_nonneg (((Equiv.Perm.sign σ:ℤ):ℝ))) (mul_nonneg hA hB) + dsimp [A,B] at * + nlinarith only [hp] + · obtain ⟨i,j,heq,hij⟩ := Function.not_injective_iff.mp he + have hz : (Matrix.of fun i j : Fin n=>polynomialJet (X^e i) (b j) (nodalOrder b j)).det=0 := by + apply Matrix.det_zero_of_row_eq hij + change (fun j : Fin n=>polynomialJet (X^e i) (b j) (nodalOrder b j))= + (fun k : Fin n=>polynomialJet (X^e j) (b k) (nodalOrder b k)) + rw [heq] + change 0 ≤ (Matrix.of fun i j : Fin n=>polynomialJet (X^e i) (b j) (nodalOrder b j)).det*_ + rw [hz,zero_mul] +noncomputable def kernelPartial (m : ℕ) (b x : ℕ → ℝ) (i j : ℕ) : ℝ := + ∑ k∈range m,polynomialJet (X^k) (b i) (nodalOrder b i)* + polynomialJet (X^k) (x j) (nodalOrder x j)/(2*k).factorial +lemma kernelPartial_det_lower {n m : ℕ} (hnm : n ≤ m) (b x : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hx : Monotone (fun i : Fin n=>x i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hx0 : ∀ i : Fin n,0 ≤ x i) : + (∏ i : Fin n,((2*i.val).factorial:ℝ)⁻¹)* + Matrix.det (fun i j : Fin n=>polynomialJet (X^i.val) (b j) (nodalOrder b j))* + Matrix.det (fun i j : Fin n=>polynomialJet (X^i.val) (x j) (nodalOrder x j)) ≤ + Fintype.card (Equiv.Perm (Fin n))*Matrix.det (fun i j : Fin n=>kernelPartial m b x i j) := by + classical + let A : Matrix (Fin n) (Fin m) ℝ := fun i k=> + ((2*k.val).factorial:ℝ)⁻¹*polynomialJet (X^k.val) (b i) (nodalOrder b i) + let B : Matrix (Fin m) (Fin n) ℝ := fun k j=>polynomialJet (X^k.val) (x j) (nodalOrder x j) + have hm : (A*B)=Matrix.of (fun i j : Fin n=>kernelPartial m b x i j) := by + ext i j + rw [Matrix.mul_apply] + dsimp [A,B,kernelPartial] + rw [Fin.sum_univ_eq_sum_range (fun k=>((2*k).factorial:ℝ)⁻¹*polynomialJet (X^k) (b i) (nodalOrder b i)*polynomialJet (X^k) (x j) (nodalOrder x j)) m] + apply sum_congr rfl + intro k _ + ring + have hdet (f : Fin n → Fin m) : + (A.submatrix id f).det=(∏ i : Fin n,((2*(f i).val).factorial:ℝ)⁻¹)* + Matrix.det (fun i j : Fin n=>polynomialJet (X^(f i).val) (b j) (nodalOrder b j)) := by + rw [←Matrix.det_transpose] + change Matrix.det (Matrix.of fun i j : Fin n=>((2*(f i).val).factorial:ℝ)⁻¹* + polynomialJet (X^(f i).val) (b j) (nodalOrder b j))=_ + exact Matrix.det_mul_column _ _ + have hn (f : Fin n → Fin m) : 0 ≤ (A.submatrix id f).det*(B.submatrix f id).det := by + rw [hdet,mul_assoc] + exact mul_nonneg (prod_nonneg (fun i _=>by positivity)) + (power_jet_det_pair_nonneg b x (fun i=>(f i).val) hb hx hb0 hx0) + have hl := single_le_sum (fun f _=>hn f) (mem_univ (fun i : Fin n=>i.castLE hnm)) + rw [det_rectangular_binet,hm] at hl + rw [hdet] at hl + exact hl +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Filter Topology +lemma polynomialJet_X_pow (k r : ℕ) (a : ℝ) : polynomialJet (X^k) a r=(k.choose r:ℝ)*a^(k-r) := by + rw [polynomialJet,taylor_coeff,←monomial_one_right_eq_X_pow,hasseDeriv_monomial] + simp +lemma polynomialJet_hasDerivAt (P : Polynomial ℝ) (r : ℕ) (a : ℝ) : + HasDerivAt (fun y=>polynomialJet P y r) ((r+1:ℝ)*polynomialJet P a (r+1)) a := by + have he : (hasseDeriv r P).derivative=(r+1) • hasseDeriv (r+1) P := by + have h := DFunLike.congr_fun (hasseDeriv_comp (R:=ℝ) 1 r) P + simpa [Nat.add_comm,add_mul] using h + have h := (hasseDeriv r P).hasDerivAt a + rw [he] at h + simpa [polynomialJet,taylor_coeff,eval_smul,nsmul_eq_mul] using h +lemma polynomialJet_X_pow_bound (k r : ℕ) {a R : ℝ} (hR : 1 ≤ R) (ha : |a| ≤ R) : + |polynomialJet (X^k) a r| ≤ (2*R)^k := by + rw [polynomialJet_X_pow,abs_mul,abs_of_nonneg (Nat.cast_nonneg _),abs_pow,mul_pow] + apply mul_le_mul + · exact_mod_cast Nat.choose_le_two_pow k r + · exact (pow_le_pow_left₀ (abs_nonneg _) ha _).trans (pow_le_pow_right₀ hR (Nat.sub_le _ _)) + · positivity + · positivity +lemma summable_evenFactorial {T : ℝ} (hT : 0 ≤ T) : Summable (fun k : ℕ=>T^k/(2*k).factorial) := by + convert (Real.hasSum_cosh (Real.sqrt T)).summable using 1 + funext k + rw [pow_mul,Real.sq_sqrt hT] +noncomputable def kernelJetTerm (r s : ℕ) (b x : ℝ) (k : ℕ) : ℝ := + polynomialJet (X^k) b r*polynomialJet (X^k) x s/(2*k).factorial +noncomputable def cosineKernelJet (r s : ℕ) (b x : ℝ) : ℝ := ∑' k,kernelJetTerm r s b x k +lemma kernelJetTerm_bound (r s k : ℕ) {b x R S : ℝ} + (hR : 1 ≤ R) (hS : 1 ≤ S) (hb : |b| ≤ R) (hx : |x| ≤ S) : + ‖kernelJetTerm r s b x k‖ ≤ (4*R*S)^k/(2*k).factorial := by + rw [kernelJetTerm,Real.norm_eq_abs,abs_div,abs_mul,abs_of_nonneg (show (0:ℝ) ≤ ((2*k).factorial:ℝ) from Nat.cast_nonneg _)] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + calc + |polynomialJet (X^k) b r| * |polynomialJet (X^k) x s| ≤ (2*R)^k*(2*S)^k := + mul_le_mul (polynomialJet_X_pow_bound k r hR hb) (polynomialJet_X_pow_bound k s hS hx) (abs_nonneg _) (by positivity) + _=(4*R*S)^k := by rw [←mul_pow];ring_nf +lemma kernelJetTerm_summable (r s : ℕ) (b x : ℝ) : Summable (kernelJetTerm r s b x) := by + exact (summable_evenFactorial (show 0 ≤ 4*(|b|+1)*(|x|+1) by positivity)).of_norm_bounded + (fun k=>kernelJetTerm_bound r s k (by linarith [abs_nonneg b]) (by linarith [abs_nonneg x]) (by linarith) (by linarith)) +lemma cosineKernelJet_hasDerivAt_left (r s : ℕ) (b x : ℝ) : + HasDerivAt (fun y=>cosineKernelJet r s y x) ((r+1:ℝ)*cosineKernelJet (r+1) s b x) b := by + let R := |b|+2 + let S := |x|+1 + have hR : 1 ≤ R := by dsimp [R];linarith [abs_nonneg b] + have hS : 1 ≤ S := by dsimp [S];linarith [abs_nonneg x] + have hg (k : ℕ) (y : ℝ) : HasDerivAt (fun z=>kernelJetTerm r s z x k) + ((r+1:ℝ)*kernelJetTerm (r+1) s y x k) y := by + convert ((polynomialJet_hasDerivAt (X^k) r y).mul_const (polynomialJet (X^k) x s)).div_const ((2*k).factorial:ℝ) using 1 <;> first | rfl | (unfold kernelJetTerm; ring) + have hu : Summable (fun k : ℕ=>(r+1:ℝ)*((4*R*S)^k/(2*k).factorial)) := + (summable_evenFactorial (by positivity : 0 ≤ 4*R*S)).mul_left _ + have h := hasDerivAt_tsum_of_isPreconnected hu isOpen_Ioo (convex_Ioo (-R) R).isPreconnected + (fun k y _=>hg k y) (y₀:=b) (y:=b) (t:=Set.Ioo (-R) R) + have hb : b ∈ Set.Ioo (-R) R := by dsimp [R];constructor <;> linarith [le_abs_self b,neg_abs_le b] + have hh := h (fun k y hy=>by + rw [norm_mul,Real.norm_eq_abs,abs_of_nonneg (by positivity : 0 ≤ (r+1:ℝ))] + exact mul_le_mul_of_nonneg_left + (kernelJetTerm_bound (r+1) s k hR hS ((abs_lt.mpr hy).le) (by dsimp [S];linarith)) (by positivity)) + hb (kernelJetTerm_summable r s b x) hb + simpa only [cosineKernelJet,tsum_mul_left] using hh +lemma cosineKernelJet_symm (r s : ℕ) (b x : ℝ) : cosineKernelJet r s b x=cosineKernelJet s r x b := by + unfold cosineKernelJet + apply tsum_congr + intro k + unfold kernelJetTerm + rw [mul_comm] +lemma cosineKernelJet_hasDerivAt_right (r s : ℕ) (b x : ℝ) : + HasDerivAt (fun y=>cosineKernelJet r s b y) ((s+1:ℝ)*cosineKernelJet r (s+1) b x) x := by + simpa only [cosineKernelJet_symm r s,cosineKernelJet_symm r (s+1)] using cosineKernelJet_hasDerivAt_left s r x b +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Filter Topology +lemma cosineKernelJet_iteratedDeriv_left (r s : ℕ) (b x : ℝ) : + iteratedDeriv r (fun y=>cosineKernelJet 0 s y x) b=(r.factorial:ℝ)*cosineKernelJet r s b x := by + induction r generalizing b with + | zero => simp + | succ r ih => + rw [iteratedDeriv_succ,show iteratedDeriv r (fun y=>cosineKernelJet 0 s y x)= + (fun y=>(r.factorial:ℝ)*cosineKernelJet r s y x) from funext (fun y=>ih y)] + rw [((cosineKernelJet_hasDerivAt_left r s b x).const_mul (r.factorial:ℝ)).deriv] + simp only [Nat.factorial_succ,Nat.cast_mul,Nat.cast_add,Nat.cast_one] + ring +lemma cosineKernelJet_iteratedDeriv_right (r s : ℕ) (b x : ℝ) : + iteratedDeriv s (fun y=>cosineKernelJet r 0 b y) x=(s.factorial:ℝ)*cosineKernelJet r s b x := by + simpa only [cosineKernelJet_symm r 0,cosineKernelJet_symm r s] using cosineKernelJet_iteratedDeriv_left s r x b +lemma cosineKernelJet_mixed (r s : ℕ) (b x : ℝ) : + iteratedDeriv s (fun y=>iteratedDeriv r (fun z=>cosineKernelJet 0 0 z y) b) x= + (r.factorial:ℝ)*(s.factorial:ℝ)*cosineKernelJet r s b x := by + simp_rw [cosineKernelJet_iteratedDeriv_left] + rw [iteratedDeriv_const_mul_field,cosineKernelJet_iteratedDeriv_right] + ring +lemma cosineKernelJet_zero_zero_cosh {b x : ℝ} (hb : 0 ≤ b) (hx : 0 ≤ x) : + cosineKernelJet 0 0 b x=Real.cosh (Real.sqrt b*Real.sqrt x) := by + apply HasSum.tsum_eq + convert Real.hasSum_cosh (Real.sqrt b*Real.sqrt x) using 1 + ext k + dsimp [kernelJetTerm] + rw [polynomialJet_X_pow,polynomialJet_X_pow] + simp only [Nat.choose_zero_right,Nat.cast_one,one_mul,Nat.sub_zero] + rw [mul_pow,pow_mul,pow_mul,Real.sq_sqrt hb,Real.sq_sqrt hx] +lemma kernelPartial_tendsto (b x : ℕ → ℝ) (i j : ℕ) : + Tendsto (fun m=>kernelPartial m b x i j) atTop + (𝓝 (cosineKernelJet (nodalOrder b i) (nodalOrder x j) (b i) (x j))) := + (kernelJetTerm_summable _ _ _ _).hasSum.tendsto_sum_nat +lemma cosineKernelJet_det_pos {n : ℕ} (b x : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hx : Monotone (fun i : Fin n=>x i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hx0 : ∀ i : Fin n,0 ≤ x i) : + 0 < Matrix.det (fun i j : Fin n=>cosineKernelJet (nodalOrder b i) (nodalOrder x j) (b i) (x j)) := by + let c := (∏ i : Fin n,((2*i.val).factorial:ℝ)⁻¹)* + Matrix.det (fun i j : Fin n=>polynomialJet (X^i.val) (b j) (nodalOrder b j))* + Matrix.det (fun i j : Fin n=>polynomialJet (X^i.val) (x j) (nodalOrder x j)) + have hc : 0 < c := by + apply mul_pos + · exact mul_pos (prod_pos (fun i _=>by positivity)) (consecutive_jet_det_pos b hb) + · exact consecutive_jet_det_pos x hx + have hd : Continuous (Matrix.det : Matrix (Fin n) (Fin n) ℝ → ℝ) := continuous_id.matrix_det + have ht := hd.continuousAt.tendsto.comp + (tendsto_pi_nhds.mpr (fun i : Fin n=>tendsto_pi_nhds.mpr (fun j : Fin n=>kernelPartial_tendsto b x i j))) + have hl : c ≤ Fintype.card (Equiv.Perm (Fin n))*Matrix.det (fun i j : Fin n=>cosineKernelJet (nodalOrder b i) (nodalOrder x j) (b i) (x j)) := by + apply ge_of_tendsto (ht.const_mul (Fintype.card (Equiv.Perm (Fin n)):ℝ)) + filter_upwards [eventually_ge_atTop n] with m hm + exact kernelPartial_det_lower hm b x hb hx hb0 hx0 + have hp : 0 < (Fintype.card (Equiv.Perm (Fin n)):ℝ) := by positivity + exact pos_of_mul_pos_right (hc.trans_le hl) hp.le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open MeasureTheory Matrix Finset Equiv +variable {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] +variable (μ : Measure α) [SigmaFinite μ] (F G : ι → α → ℝ) +noncomputable def evaluationMatrix (x : ι → α) : Matrix ι ι ℝ := fun i j=>F i (x j) +noncomputable def gramMatrix : Matrix ι ι ℝ := fun i j=>∫ x,F i x*G j x ∂μ +omit [MeasurableSpace α] in +lemma det_evaluation_product_expansion (x : ι → α) : + (evaluationMatrix F x).det*(evaluationMatrix G x).det= + ∑ σ : Perm ι,∑ τ : Perm ι,((Perm.sign σ:ℤ):ℝ)*((Perm.sign τ:ℤ):ℝ)* + ∏ i,F (σ i) (x i)*G (τ i) (x i) := by + simp only [Matrix.det_apply',evaluationMatrix,sum_mul,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro σ _ + apply sum_congr rfl + intro τ _ + rw [prod_mul_distrib] + ring +lemma integrable_det_evaluation_product (h : ∀ i j,Integrable (fun x=>F i x*G j x) μ) : + Integrable (fun x : ι → α=>(evaluationMatrix F x).det*(evaluationMatrix G x).det) + (Measure.pi (fun _ : ι=>μ)) := by + simp_rw [det_evaluation_product_expansion] + apply integrable_finsetSum + intro σ _ + apply integrable_finsetSum + intro τ _ + exact (Integrable.fintype_prod (fun i=>h (σ i) (τ i))).const_mul _ +lemma andreief (h : ∀ i j,Integrable (fun x=>F i x*G j x) μ) : + (∫ x : ι → α,(evaluationMatrix F x).det*(evaluationMatrix G x).det ∂Measure.pi (fun _ : ι=>μ))= + Fintype.card (Perm ι)*(gramMatrix μ F G).det := by + classical + have hi (σ τ : Perm ι) : Integrable (fun x : ι → α=> + ((Perm.sign σ:ℤ):ℝ)*((Perm.sign τ:ℤ):ℝ)*(∏ i,F (σ i) (x i)*G (τ i) (x i))) + (Measure.pi (fun _ : ι=>μ)) := + (Integrable.fintype_prod (fun i=>h (σ i) (τ i))).const_mul _ + simp_rw [det_evaluation_product_expansion] + rw [integral_finsetSum univ (fun σ _=>integrable_finsetSum _ (fun τ _=>hi σ τ))] + simp only [integral_finsetSum univ (fun τ _=>hi _ τ),integral_const_mul] + rw [sum_comm] + have he (τ : Perm ι) : + (∑ σ : Perm ι,((Perm.sign σ:ℤ):ℝ)*((Perm.sign τ:ℤ):ℝ)* + ∏ i,∫ x,F (σ i) x*G (τ i) x ∂μ)=(gramMatrix μ F G).det := by + calc + _=((Perm.sign τ:ℤ):ℝ)*(gramMatrix μ F G |>.submatrix id τ).det := by + rw [Matrix.det_apply',mul_sum] + apply sum_congr rfl + intro σ _ + simp only [Matrix.submatrix_apply,gramMatrix,id_eq] + ring + _=_ := by + rw [Matrix.det_permute',←mul_assoc,←Int.cast_mul,←Units.val_mul,Int.units_mul_self] + simp + have ip (σ τ : Perm ι) : + (∫ x : ι → α,∏ i,F (σ i) (x i)*G (τ i) (x i) ∂Measure.pi (fun _ : ι=>μ))= + ∏ i,∫ x,F (σ i) x*G (τ i) x ∂μ := + integral_fintype_prod_eq_prod (fun i x=>F (σ i) x*G (τ i) x) + simp_rw [ip] + simp_rw [he] + simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Equiv +lemma sorted_injective_real {n : ℕ} {e : Fin n → ℝ} (he : Function.Injective e) : + ∃ (d : Fin n → ℝ) (σ : Equiv.Perm (Fin n)),StrictMono d ∧ e=d∘σ := by + classical + let s := univ.image e + have hc : s.card=n := by simp [s,card_image_of_injective _ he] + let o := s.orderIsoOfFin hc + let q : Fin n ≃ s := Equiv.ofBijective (fun i=>⟨e i,mem_image.mpr ⟨i,mem_univ _,rfl⟩⟩) (by + constructor + · intro i j h + exact he (congrArg Subtype.val h) + · intro a + obtain ⟨i,_,hi⟩ := mem_image.mp a.property + exact ⟨i,Subtype.ext hi⟩) + refine ⟨fun i=>(o i).val,q.trans o.symm,?_,?_⟩ + · exact o.strictMono + · ext i + exact (congrArg Subtype.val (o.apply_symm_apply (q i))).symm +noncomputable def jetEvaluation {n : ℕ} (b : ℕ → ℝ) (x : Fin n → ℝ) : Matrix (Fin n) (Fin n) ℝ := + fun i j=>cosineKernelJet (nodalOrder b i) 0 (b i) (x j) +lemma jetEvaluation_det_pos {n : ℕ} (b : ℕ → ℝ) (x : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hx : StrictMono x) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hx0 : ∀ i,0 ≤ x i) : + 0 < (jetEvaluation b x).det := by + classical + let y : ℕ → ℝ := fun k=> if hk : kby simpa only [hy] using hx.monotone hij) hb0 + (fun i=>by simpa only [hy] using hx0 i) + change 0 < Matrix.det (fun i j : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i) (x j)) + simpa only [ho,hy] using h +lemma jetEvaluation_det_product_pos {n : ℕ} (b c : ℕ → ℝ) (x : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hx : Function.Injective x) (hx0 : ∀ i,0 ≤ x i) : + 0 < (jetEvaluation b x).det*(jetEvaluation c x).det := by + obtain ⟨d,σ,hd,he⟩ := sorted_injective_real hx + have hd0 (i) : 0 ≤ d i := by + have h:=hx0 (σ.symm i) + simpa only [he,Function.comp_apply,σ.apply_symm_apply] using h + have hA := jetEvaluation_det_pos b d hb hd hb0 hd0 + have hB := jetEvaluation_det_pos c d hc hd hc0 hd0 + have hhe (a : ℕ → ℝ) : jetEvaluation a x=(jetEvaluation a d).submatrix id σ := by + ext i j + simp [jetEvaluation,he] + rw [hhe b,hhe c,Matrix.det_permute',Matrix.det_permute'] + have hs : (((Perm.sign σ:ℤ):ℝ))*(((Perm.sign σ:ℤ):ℝ))=1 := by + rw [←Int.cast_mul,←Units.val_mul,Int.units_mul_self];norm_num + nlinarith only [mul_pos hA hB,hs] +lemma jetEvaluation_det_product_nonneg {n : ℕ} (b c : ℕ → ℝ) (x : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) (hx0 : ∀ i,0 ≤ x i) : + 0 ≤ (jetEvaluation b x).det*(jetEvaluation c x).det := by + by_cases hx : Function.Injective x + · exact (jetEvaluation_det_product_pos b c x hb hc hb0 hc0 hx hx0).le + · obtain ⟨i,j,he,hij⟩ := Function.not_injective_iff.mp hx + have hz : (jetEvaluation b x).det=0 := by + apply Matrix.det_zero_of_column_eq hij + intro k + simp only [jetEvaluation,he] + rw [hz,zero_mul] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/PositivePencils.lean b/lean/OAI/Combinatorics/HoneycombChords/PositivePencils.lean new file mode 100644 index 0000000000000000000000000000000000000000..8815ef83f1c3a7e820eb0f173829b6cc3c752a02 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/PositivePencils.lean @@ -0,0 +1,603 @@ +import OAI.Combinatorics.HoneycombChords.MatrixPencils +import OAI.Combinatorics.HoneycombChords.ChebyshevSystems + +namespace OAI + +/-! Oblique comparison and noncoincidence for the strip jet pencils. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +noncomputable def jetRectPencil {n m : ℕ} (b c : ℕ → ℝ) (z t : ℝ) : Matrix (Fin n) (Fin m) ℝ := + fun i j=>∫ p in Set.Ioi (0:ℝ),cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*((p^2-t)*poleAdjustedDensity z p) +lemma jetRectPencil_square {n : ℕ} (b c : ℕ → ℝ) (z t : ℝ) : + jetRectPencil (n:=n) (m:=n) b c z t=jetPencil (poleAdjustedDensity z) b c t := rfl +lemma jetRectPencil_transpose {n m : ℕ} (b c : ℕ → ℝ) (z t : ℝ) : + (jetRectPencil (n:=n) (m:=m) b c z t).transpose=jetRectPencil c b z t := by + ext i j + dsimp [jetRectPencil] + apply integral_congr_ae + filter_upwards with p + ring +lemma jetRectPencil_vecMul {n m : ℕ} (b c : ℕ → ℝ) (a : Fin n → ℝ) + {z : ℝ} (hz : 0hi i)] + apply integral_congr_ae + filter_upwards with p + dsimp [jetCombination] + rw [mul_sum,sum_mul,sum_mul] + apply sum_congr rfl + intro i _ + ring +lemma pole_jetRectPencil_vecMul_nonzero {n m : ℕ} (b c : ℕ → ℝ) (a : Fin n → ℝ) + {z : ℝ} (hz : 0b i)) (hc : Monotone (fun i : Fin m=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin m,0 ≤ c i) (ha : a≠0) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin m,c i ≤ angle^2) : + a ᵥ* jetRectPencil (m:=m) b c z t≠0 := by + obtain ⟨j,hj⟩ := pole_jet_linear_nonorthogonality b c a hz t hnm hb hc hb0 hc0 ha hb1 hc1 + intro he + have hh := congrFun he j + rw [jetRectPencil_vecMul b c a hz t hb0 hc0 hb1 hc1 j] at hh + exact hj hh +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +noncomputable def reorderedKnotPencil (N : ℕ) (s t z r : ℝ) : Matrix (Fin (2*N+1)) (Fin (2*N+1)) ℝ := + (jetPencil (poleAdjustedDensity z) (interiorKnotLabels N s) (interiorKnotLabels N t) r).submatrix + (knotPermutation N) (knotPermutation N) +lemma reorderedKnotPencil_transpose (N : ℕ) (s t z r : ℝ) : + (reorderedKnotPencil N s t z r).transpose=reorderedKnotPencil N t s z r := by + rw [reorderedKnotPencil,Matrix.transpose_submatrix,←jetRectPencil_square,jetRectPencil_transpose,jetRectPencil_square] + rfl +lemma reorderedKnotPencil_corner (N : ℕ) {s t : ℝ} + (hs : 0twoKnot_monotone N hij) (fun i j hij=>interiorKnot_monotone N ht htL hij) + (fun i=>twoKnot_nonneg N i) (fun i=>interiorKnot_nonneg N i t) ha + (fun i=>(twoKnot_le N i).trans hL) (fun i=>interiorKnot_le N i ht htL) + intro he + apply hn + ext j + have hp := congrFun he ((knotPermutation N).symm j) + rw [reorderedKnotPencil_vecMul N hs hsL] at hp + simpa only [Equiv.apply_symm_apply,Pi.zero_apply] using hp + +theorem pole_knotPencil_no_common_root (N : ℕ) {s t z : ℝ} + (hs : 0cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder b j) 0 (b j) (p^2)*w p) (Set.Ioi 0)) : + a ⬝ᵥ (jetGram w b b *ᵥ a)=∫ p in Set.Ioi (0:ℝ),jetCombination b a (p^2)^2*w p := by + have hij (i j : Fin n) := ((hi i j).const_mul (a i)).mul_const (a j) + have he p : jetCombination b a (p^2)^2*w p= + ∑ i : Fin n,∑ j : Fin n,a i*(cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder b j) 0 (b j) (p^2)*w p)*a j := by + rw [pow_two] + simp only [jetCombination,sum_mul,mul_sum] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring + simp_rw [he] + rw [integral_finsetSum _ (fun i _=>integrable_finsetSum _ (fun j _=>hij i j))] + simp_rw [integral_finsetSum _ (fun j _=>hij _ j),integral_mul_const,integral_const_mul] + simp [dotProduct,mulVec,jetGram,mul_sum,mul_assoc] +lemma jetGram_posDef {n : ℕ} (w : ℝ → ℝ) (b : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) + (hw : ∀ p,0

cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder b j) 0 (b j) (p^2)*w p) (Set.Ioi 0)) : + (jetGram (n:=n) w b b).PosDef := by + have hp : (jetGram (n:=n) w b b).PosSemidef := by + apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg (jetGram_isHermitian w b) + intro a + rw [star_trivial,jetGram_quadratic w b a hi] + apply integral_nonneg_of_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact mul_nonneg (sq_nonneg _) (hw p hp).le + exact hp.posDef_iff_det_ne_zero.mpr (jetGram_det_pos w b b hb hb hb0 hb0 hw hi).ne' +/-- The symmetric M pencil has only positive real roots. -/ +theorem pole_symmetric_jet_pencil_factors {n : ℕ} (b : ℕ → ℝ) {z : ℝ} (hz : 0b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) + (hb1 : ∀ i : Fin n,b i ≤ angle^2) : + ∃ e : Fin n → ℝ,(∀ i,0cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder b j) 0 (b j) (p^2)*poleAdjustedDensity z p) (Set.Ioi 0) := by + intro i j + simpa only [pow_zero,one_mul] using hi i j + have hi2 i j := pole_adjusted_pair_moment_integrable (hb0 i) (hb0 j) ((hb1 i).trans hL) (hb1 j) hz + (nodalOrder b i) (nodalOrder b j) 2 + obtain ⟨e,he⟩ := positive_gram_pencil_real_factorization + (jetPencil (n:=n) (poleAdjustedDensity z) b b 0) (jetGram (n:=n) (poleAdjustedDensity z) b b) + (jetGram_isHermitian _ b) (jetGram_posDef _ b hb hb0 (fun _ hp=>poleAdjustedDensity_pos hz hp) hi0) + have he' (t : ℝ) := he t + simp_rw [←jetPencil_affine _ b b _ hi0 hi2] at he' + refine ⟨e,?_,he'⟩ + intro i + apply pole_jetPencil_real_root_positive b b hz hb hb hb0 hb0 (fun i=>(hb1 i).trans hL) hb1 + rw [he' (e i)] + have hp : (∏ j : Fin n,(e j-e i))=0 := prod_eq_zero (mem_univ i) (sub_self _) + rw [hp,mul_zero] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +lemma pole_jetPencil_affine {n : ℕ} (b c : ℕ → ℝ) {z : ℝ} (hz : 0b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin n,c i ≤ angle^2) : + 0<(jetGram (n:=n) (poleAdjustedDensity z) b c).det := by + apply jetGram_det_pos _ b c hb hc hb0 hc0 (fun _ hp=>poleAdjustedDensity_pos hz hp) + intro i j + simpa only [pow_zero,one_mul] using pole_adjusted_pair_moment_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) hz (nodalOrder b i) (nodalOrder c j) 0 +lemma pole_jetGram_posDef {n : ℕ} (b : ℕ → ℝ) {z : ℝ} (hz : 0b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) (hb1 : ∀ i : Fin n,b i ≤ angle^2) : + (jetGram (n:=n) (poleAdjustedDensity z) b b).PosDef := by + have hL : angle^2 ≤ (3*angle/2)^2 := by nlinarith [sq_nonneg angle] + apply jetGram_posDef _ b hb hb0 (fun _ hp=>poleAdjustedDensity_pos hz hp) + intro i j + simpa only [pow_zero,one_mul] using pole_adjusted_pair_moment_integrable (hb0 i) (hb0 j) ((hb1 i).trans hL) (hb1 j) hz (nodalOrder b i) (nodalOrder b j) 0 +lemma pole_jetPencil_zero_posDef {n : ℕ} (b : ℕ → ℝ) {z : ℝ} (hz : 0b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) (hb1 : ∀ i : Fin n,b i ≤ angle^2) : + (jetPencil (n:=n) (poleAdjustedDensity z) b b 0).PosDef := by + have hL : angle^2 ≤ (3*angle/2)^2 := by nlinarith [sq_nonneg angle] + apply jetGram_posDef _ b hb hb0 + · intro p hp + exact mul_pos (by simpa using sq_pos_of_pos hp) (poleAdjustedDensity_pos hz hp) + · intro i j + exact pole_jet_pair_pencil_integrable (hb0 i) (hb0 j) ((hb1 i).trans hL) (hb1 j) hz _ _ 0 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open MeasureTheory Filter Finset Matrix +lemma pole_cosh_moment_continuousOn {b z : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ (3*angle/2)^2) + (hz : 0∫ p in Set.Ioi (0:ℝ), + (p^2-r)*cosineKernelJet k 0 b (p^2)*Real.cosh (t*p)*poleAdjustedDensity z p) + (Set.Icc 0 angle) := by + let f : ℝ → ℝ := fun p=>cosineKernelJet k 0 b (p^2)*Real.cosh (angle*p)*poleAdjustedDensity z p + have hf0 : IntegrableOn f (Set.Ioi 0) := by + have h:=pole_adjusted_pair_moment_integrable hb (sq_nonneg angle) hb1 le_rfl hz k 0 0 + apply h.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + simp only [pow_zero,one_mul,cosineKernelJet_zero_zero_cosh (sq_nonneg angle) (sq_nonneg p),Real.sqrt_sq strip_angle_pos.le,Real.sqrt_sq hp.le,f] + have hf2 : IntegrableOn (fun p=>p^2*f p) (Set.Ioi 0) := by + have h:=pole_adjusted_pair_moment_integrable hb (sq_nonneg angle) hb1 le_rfl hz k 0 2 + apply h.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + simp only [cosineKernelJet_zero_zero_cosh (sq_nonneg angle) (sq_nonneg p),Real.sqrt_sq strip_angle_pos.le,Real.sqrt_sq hp.le,f] + ring + apply continuousOn_of_dominated (bound:=fun p=>(p^2+|r|)*f p) + · intro t ht + have hjet : Continuous (fun p : ℝ=>cosineKernelJet k 0 b (p^2)) := + (cosineKernelJet_contDiff_right k 0 b 0).continuous.comp (by fun_prop) + exact (((by fun_prop : Continuous (fun p : ℝ=>p^2-r)).aestronglyMeasurable.mul hjet.aestronglyMeasurable).mul + (by fun_prop : Continuous (fun p : ℝ=>Real.cosh (t*p))).aestronglyMeasurable).mul + (by unfold poleAdjustedDensity stripDensity;fun_prop : Measurable (poleAdjustedDensity z)).aestronglyMeasurable + · intro t ht + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hc : Real.cosh (t*p) ≤ Real.cosh (angle*p) := by + apply Real.cosh_le_cosh.mpr + rw [abs_of_nonneg (mul_nonneg ht.1 hp.le),abs_of_nonneg (mul_nonneg strip_angle_pos.le hp.le)] + exact mul_le_mul_of_nonneg_right ht.2 hp.le + have hq : |p^2-r| ≤ p^2+|r| := by + exact (abs_sub _ _).trans_eq (by rw [abs_of_nonneg (sq_nonneg p)]) + rw [Real.norm_eq_abs,abs_mul,abs_mul,abs_mul, + abs_of_nonneg (cosineKernelJet_nonneg hb (sq_nonneg p) k 0), + abs_of_pos (Real.cosh_pos _),abs_of_pos (poleAdjustedDensity_pos hz hp)] + dsimp [f] + rw [←mul_assoc,←mul_assoc] + exact mul_le_mul_of_nonneg_right + (mul_le_mul (mul_le_mul_of_nonneg_right hq (cosineKernelJet_nonneg hb (sq_nonneg p) k 0)) hc + (Real.cosh_pos _).le (mul_nonneg (by positivity) (cosineKernelJet_nonneg hb (sq_nonneg p) k 0))) + (poleAdjustedDensity_pos hz hp).le + · apply (hf2.add (hf0.const_mul |r|)).congr + filter_upwards with p + dsimp [f] + ring + · filter_upwards with p + exact (by fun_prop : Continuous (fun t : ℝ=>(p^2-r)*cosineKernelJet k 0 b (p^2)*Real.cosh (t*p)*poleAdjustedDensity z p)).continuousOn +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open MeasureTheory Matrix Finset Filter +noncomputable def knotPairing (N : ℕ) (z : ℝ) (a : Fin (2*N) → ℝ) (r t : ℝ) : ℝ := + ∑ i,a i*(∫ p in Set.Ioi (0:ℝ),(p^2-r)* + cosineKernelJet (nodalOrder (twoKnotLabels N) i) 0 (twoKnotLabels N i) (p^2)* + Real.cosh (t*p)*poleAdjustedDensity z p) +lemma knotPairing_continuousOn (N : ℕ) {z : ℝ} (hz : 0?_) j + · simpa only [Pi.zero_apply,reorderedKnotPencil_vecMul_last N hs hsL ht htL] using he + · have hcorner:=reorderedKnotPencil_corner N hs hsL ht htL z r + have h:=congrFun har k + simp only [Matrix.vecMul,dotProduct] at h ⊢ + rw [Fin.sum_univ_castSucc] + simp only [Fin.lastCases_castSucc,Fin.lastCases_last,zero_mul,add_zero,Pi.zero_apply] + rw [←hcorner] at h + exact h +lemma continuousOn_nonzero_mul_pos {f : ℝ → ℝ} {a b : ℝ} + (hf : ContinuousOn f (Set.Icc a b)) (hn : ∀ x∈Set.Ioo a b,f x≠0) + {s t : ℝ} (hs : s∈Set.Ioo a b) (ht : t∈Set.Ioo a b) : 0 intro hneg + · by_contra hh + have hnon : 0 ≤ f t := le_of_not_gt hh + obtain ⟨x,hx,hfx⟩ := hi.intermediate_value hs ht hc ⟨hneg.le,hnon⟩ + exact hn x hx hfx + · by_contra hh + have hnon : 0 ≤ f s := le_of_not_gt hh + obtain ⟨x,hx,hfx⟩ := hi.intermediate_value ht hs hc ⟨hneg.le,hnon⟩ + exact hn x hx hfx + rcases lt_or_gt_of_ne (hn s hs) with hneg|hpos + · exact mul_pos_of_neg_of_neg hneg (hsign.mp hneg) + · have htp : 0knotPairing_ne_zero N hz a ha r har h.1 h.2) ⟨hs,hsL⟩ ⟨ht,htL⟩ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory +noncomputable def reorderedKnotGram (N : ℕ) (s t z : ℝ) : Matrix (Fin (2*N+1)) (Fin (2*N+1)) ℝ := + (jetGram (poleAdjustedDensity z) (interiorKnotLabels N s) (interiorKnotLabels N t)).submatrix + (knotPermutation N) (knotPermutation N) +lemma reorderedKnotGram_corner (N : ℕ) {s t : ℝ} + (hs : 0interiorKnot_nonneg N i s) (fun i=>interiorKnot_nonneg N i t) + (fun i=>(interiorKnot_le N i hs hsL).trans hL) (fun i=>interiorKnot_le N i ht htL) + rw [reorderedKnotPencil,h] + rfl +lemma reorderedKnotPencil_det_pos_nonpos (N : ℕ) {s t z r : ℝ} + (hs : 0interiorKnot_monotone N hs hsL hij) (fun _ _ hij=>interiorKnot_monotone N ht htL hij) + (fun i=>interiorKnot_nonneg N i s) (fun i=>interiorKnot_nonneg N i t) + (fun i=>(interiorKnot_le N i hs hsL).trans hL) (fun i=>interiorKnot_le N i ht htL) +lemma reorderedKnotGram_det_pos (N : ℕ) {s t z : ℝ} + (hs : 0interiorKnot_monotone N hs hsL hij) (fun _ _ hij=>interiorKnot_monotone N ht htL hij) + (fun i=>interiorKnot_nonneg N i s) (fun i=>interiorKnot_nonneg N i t) + (fun i=>(interiorKnot_le N i hs hsL).trans hL) (fun i=>interiorKnot_le N i ht htL) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset + +theorem pole_knot_characteristic_comparison (N : ℕ) {s t y z : ℝ} + (hs : 0twoKnot_monotone N hij) (fun i=>twoKnot_nonneg N i) (fun i=>twoKnot_le N i) + have hB : (B.submatrix Fin.castSucc Fin.castSucc).PosDef := by + rw [show B=reorderedKnotGram N s t z from rfl,reorderedKnotGram_corner N hs hsL ht htL] + exact pole_jetGram_posDef _ hz (fun _ _ hij=>twoKnot_monotone N hij) (fun i=>twoKnot_nonneg N i) (fun i=>twoKnot_le N i) + have h0 : 0 ∫ p in Set.Ioi (0:ℝ),(p^2-t)*zeroJet b i (p^2)*zeroJet c j (p^2)*w p +noncomputable def mixedZeroJetPencil {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) (t : ℝ) : + Matrix (Fin n) (Fin n) ℝ := + fun i j => ∫ p in Set.Ioi (0:ℝ),(p^2-t)*zeroJet b i (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p + +def SecondObliqueCharacteristicComparison : Prop := + ∀ (N : ℕ),0a i.succ) x := by + have h0 : a 0 + ∑ i : Fin n,a i.succ*cosineKernelJet (nodalOrder b (i.val+1)) 0 (b (i.val+1)) 0 = 0 := by + simpa only [jetCombination,Fin.sum_univ_succ,Fin.val_zero,Fin.val_succ,jet_first_constant b hb,mul_one] using ha + unfold jetCombination zeroJetCombination zeroJet + rw [Fin.sum_univ_succ] + simp only [Fin.val_zero,Fin.val_succ,jet_first_constant b hb,mul_one,mul_sub,sum_sub_distrib] + linarith +lemma zeroJetCombination_smul {n : ℕ} (b : ℕ → ℝ) (a : Fin n → ℝ) (e x : ℝ) : + zeroJetCombination b (fun i=>e*a i) x=e*zeroJetCombination b a x := by + simp only [zeroJetCombination,mul_sum] + apply sum_congr rfl + intro i _ + ring +lemma jetTest_zero_at_zero {n : ℕ} (b : ℕ → ℝ) (v : Fin n → ℝ) : + jetCombination b (jetTestCoeffs b (Fin.cons 0 v)) 0 = 0 := by + rw [jetTest_eq_det] + apply Matrix.det_zero_of_column_eq (i:=0) (j:=Fin.succ (0 : Fin (n+1))) + · exact (Fin.succ_ne_zero _).symm + · intro k + simp [jetEvaluation] +/-- The zero-at-the-origin flag has a sign-matching test for each continuous +function with fewer positive zeros than its dimension. This is the exact +flag used in the second oblique chain, not an additional Chebyshev input. -/ +theorem zero_jet_flag_sign_matching {m : ℕ} (b : ℕ → ℝ) (f : ℝ → ℝ) + (hb : Monotone (fun i : Fin (m+1)=>b i)) (hb0 : ∀ i : Fin (m+1),0 ≤ b i) + (hbfirst : b 0 = 0) (hf : Continuous f) (s : Finset ℝ) (hs : ∀ x ∈ s,0 < x) + (hz : ∀ x,0 < x → (f x=0 ↔ x ∈ s)) (hc : s.card < m) : + ∃ k : ℕ,k+1 ≤ m ∧ ∃ a : Fin (k+1) → ℝ, + (∀ x,0 < x → 0 ≤ f x*zeroJetCombination b a x) ∧ + (∀ x,0 < x → f x ≠ 0 → 0 < f x*zeroJetCombination b a x) := by + classical + obtain ⟨t,ht,e,he,hpos⟩ := finite_zero_sign_polynomial f hf s 0 hs hz + let o := t.orderIsoOfFin rfl + let v : Fin t.card → ℝ := fun i=>(o i).val + have hv : StrictMono v := o.strictMono + have hvpos i : 0 < v i := hs _ (ht (o i).property) + let w : Fin (t.card+1) → ℝ := Fin.cons 0 v + have hw : StrictMono w := by + intro i j + refine Fin.cases ?_ (fun i=>?_) i + · refine Fin.cases (fun h=>False.elim (lt_irrefl _ h)) (fun j _=>hvpos j) j + · refine Fin.cases (fun h=>False.elim (Fin.not_lt_zero _ h)) (fun j h=>hv (Fin.succ_lt_succ_iff.mp h)) j + have hw0 (i : Fin (t.card+1)) : 0 ≤ w i := Fin.cases le_rfl (fun i=>(hvpos i).le) i + have hdim : t.card+1 ≤ m := Nat.add_one_le_iff.mpr ((card_le_card ht).trans_lt hc) + have hd : t.card+2 ≤ m+1 := by omega + have hb' : Monotone (fun i : Fin (t.card+2)=>b i) := fun i j hij=>hb (show (i.castLE hd : Fin (m+1)) ≤ j.castLE hd from hij) + have hb0' (i : Fin (t.card+2)) : 0 ≤ b i := hb0 (i.castLE hd) + let A : Fin (t.card+2) → ℝ := fun i=>(e*(-1)^(t.card+1))*jetTestCoeffs b w i + have hA0 : jetCombination b A 0 = 0 := by + rw [show A=(fun i=>(e*(-1)^(t.card+1))*jetTestCoeffs b w i) from rfl,jetCombination_smul] + rw [show w=Fin.cons 0 v from rfl,jetTest_zero_at_zero,mul_zero] + let a : Fin (t.card+1) → ℝ := fun i=>A i.succ + have hstrict : ∀ x,0 < x → f x ≠ 0 → 0 < f x*zeroJetCombination b a x := by + intro x hx hfx + have hxs : x∉s := fun h=>hfx ((hz x hx).mpr h) + have hxv i : x ≠ v i := fun h=>hxs (h.symm ▸ ht (o i).property) + have hxw i : x ≠ w i := Fin.cases (ne_of_gt hx) hxv i + have hp:=hpos x hx hxs + have hj:=jetTest_sign_product b w hb' hb0' hw hw0 hx.le hxw + have hprod : (∏ i : Fin t.card,(x-v i))=∏ z ∈ t,(x-z) := by + calc + _ = ∏ z : t,(x-z.val) := Equiv.prod_comp o.toEquiv (fun z : t=>x-z.val) + _ = _ := Finset.prod_attach _ _ + have hneg : (∏ i : Fin (t.card+1),(w i-x))=(-1:ℝ)^(t.card+1)*x*(∏ z ∈ t,(x-z)) := by + rw [Fin.prod_univ_succ] + simp only [w,Fin.cons_zero,Fin.cons_succ,zero_sub] + simp_rw [show ∀ i : Fin t.card,v i-x=(-1:ℝ)*(x-v i) from fun i=>by ring] + rw [prod_mul_distrib,prod_const,card_univ,Fintype.card_fin,hprod,pow_succ] + ring + rw [hneg] at hj + have hpp:=mul_pos hp hj + have heq : (f x*(e*∏ z ∈ t,(x-z)))*(jetCombination b (jetTestCoeffs b w) x* + ((-1:ℝ)^(t.card+1)*x*∏ z ∈ t,(x-z)))= + (f x*zeroJetCombination b a x)*(x*(∏ z ∈ t,(x-z))^2) := by + rw [←jetCombination_eq_zeroCombination b A hbfirst hA0] + dsimp only [A] + rw [jetCombination_smul] + ring + rw [heq] at hpp + exact pos_of_mul_pos_left hpp (mul_nonneg hx.le (sq_nonneg _)) + refine ⟨t.card,hdim,a,?_,hstrict⟩ + intro x hx + by_cases hfx : f x=0 + · simp [hfx] + · exact (hstrict x hx hfx).le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/RasterChords.lean b/lean/OAI/Combinatorics/HoneycombChords/RasterChords.lean new file mode 100644 index 0000000000000000000000000000000000000000..94eaa7955c51790b628577db88836af6aaaee320 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/RasterChords.lean @@ -0,0 +1,1143 @@ +import OAI.Combinatorics.HoneycombChords.ChordTensors + +namespace OAI + +/-! +# Literal chord expansions in finite rectangles + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition +open scoped BigOperators + +def Matches {W H : ℕ} (cfg : Cell W H → Shape) + (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) : Prop := + ∀ t, spinOccupied (σ ((network W H).west t))=(cfg t).selection.west ∧ + spinOccupied (σ ((network W H).north t))=(cfg t).selection.north ∧ + spinOccupied (σ ((network W H).south t))=(cfg t).selection.south ∧ + spinOccupied (σ ((network W H).east t))=(cfg t).selection.east ∧ + spinOccupied (μ t)=(cfg t).selection.middle + +instance {W H : ℕ} (cfg : Cell W H → Shape) + (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) : Decidable (Matches cfg σ μ) := by + unfold Matches + infer_instance + +lemma maskedCell_sum (q : Shape) (w n s e : Fin 3) : + maskedCell q w n s e = ∑ m : Fin 3, + if spinOccupied w=q.selection.west ∧ spinOccupied n=q.selection.north ∧ + spinOccupied s=q.selection.south ∧ spinOccupied e=q.selection.east ∧ + spinOccupied m=q.selection.middle then upTensor w s m * downTensor e n m else 0 := by + classical + unfold maskedCell + split_ifs with h + · apply Finset.sum_congr rfl + intro m hm + simp only [h.1,h.2.1,h.2.2.1,h.2.2.2,true_and] + · have h' : ∀ m : Fin 3, ¬ (spinOccupied w=q.selection.west ∧ + spinOccupied n=q.selection.north ∧ spinOccupied s=q.selection.south ∧ + spinOccupied e=q.selection.east ∧ spinOccupied m=q.selection.middle) := by + intro m hm + exact h ⟨hm.1,hm.2.1,hm.2.2.1,hm.2.2.2.1⟩ + simp [h'] + +/-- A resolved occupancy history is the literal finite-domain center sum +with exactly its five occupied-edge masks, including each middle edge. -/ +theorem masked_orientation {W H : ℕ} (cfg : Cell W H → Shape) + (σ : GridWire W H → Fin 3) : + (kappa:ℂ)^(∑ t, (cfg t).visits) * (network W H).orientation cfg σ = + ∑ μ : Cell W H → Fin 3, if Matches cfg σ μ then + centerProduct (domain W H) (spins σ μ) else 0 := by + classical + calc + _ = ∏ t, (kappa:ℂ)^(cfg t).visits * shapeTensor (cfg t) + (σ ((network W H).west t)) (σ ((network W H).north t)) + (σ ((network W H).south t)) (σ ((network W H).east t)) := by + rw [Finset.prod_mul_distrib,←Finset.prod_pow_eq_pow_sum] + rfl + _ = ∏ t, maskedCell (cfg t) (σ ((network W H).west t)) + (σ ((network W H).north t)) (σ ((network W H).south t)) + (σ ((network W H).east t)) := by simp_rw [maskedCell_eq] + _ = _ := by + simp_rw [maskedCell_sum] + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro μ hμ + rw [Fintype.prod_ite_zero,center_product_eq] + rfl + +/-- Its prescribed-boundary contraction, with no auxiliary local model. -/ +theorem masked_chosenPartition {W H : ℕ} (cfg : Cell W H → Shape) + (west east : Column H) (south north : Fin W → Fin 3) : + (kappa:ℂ)^(∑ t, (cfg t).visits) * chosenPartition cfg west east south north = + ∑ σ : {σ : GridWire W H → Fin 3 // HasWestNorth west north σ}, + ∑ μ : Cell W H → Fin 3, + if (∀ j, σ.val (.inl (Fin.last W,j))=east j) ∧ + (∀ i, σ.val (.inr (i,0))=south i) ∧ Matches cfg σ.val μ then + centerProduct (domain W H) (spins σ.val μ) else 0 := by + classical + rw [chosenPartition_eq_grid_sum,Finset.mul_sum] + apply Finset.sum_congr rfl + intro σ hσ + by_cases he : (∀ j, σ.val (.inl (Fin.last W,j))=east j) ∧ + (∀ i, σ.val (.inr (i,0))=south i) + · rw [ite_eq_left he,masked_orientation] + apply Finset.sum_congr rfl + intro μ hμ + congr 1 + exact propext ⟨fun hm=>⟨he.1,he.2,hm⟩,fun hh=>hh.2.2⟩ + · rw [ite_eq_right he,mul_zero] + symm + apply Finset.sum_eq_zero + intro μ hμ + apply ite_eq_right + intro he' + exact he ⟨he'.1,he'.2.1⟩ + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +open scoped BigOperators + +def selectionAt {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (t : Cell W H) : Selection := + ⟨spinOccupied (σ ((network W H).west t)),spinOccupied (σ ((network W H).south t)), + spinOccupied (σ ((network W H).east t)),spinOccupied (σ ((network W H).north t)), + spinOccupied (μ t)⟩ + +lemma selectionAt_admissible {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (h : centerProduct (domain W H) (spins σ μ)≠0) (t : Cell W H) : + Admissible (selectionAt σ μ t) := by + rw [center_product_eq] at h + have ht := (Finset.prod_ne_zero_iff.mp h) t (Finset.mem_univ t) + exact ⟨upTensor_degree _ _ _ (mul_ne_zero_iff.mp ht).1, + downTensor_degree _ _ _ (mul_ne_zero_iff.mp ht).2⟩ + +noncomputable def occupancyShape {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (h : centerProduct (domain W H) (spins σ μ)≠0) (t : Cell W H) : Shape := + ((selection_classification _).mp (selectionAt_admissible σ μ h t)).choose + +lemma occupancyShape_selection {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (h : centerProduct (domain W H) (spins σ μ)≠0) (t : Cell W H) : + (occupancyShape σ μ h t).selection=selectionAt σ μ t := + ((selection_classification _).mp (selectionAt_admissible σ μ h t)).choose_spec + +lemma occupancyShape_matches {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (h : centerProduct (domain W H) (spins σ μ)≠0) : + Matches (occupancyShape σ μ h) σ μ := by + intro t + rw [occupancyShape_selection] + exact ⟨rfl,rfl,rfl,rfl,rfl⟩ + +lemma matches_grid_occupied {W H : ℕ} (hW : 0 + rcases w with ⟨i,j⟩ + cases W with + | zero => omega + | succ W => + cases i using Fin.lastCases with + | last => exact (ha (Fin.last W,j)).2.2.2.1.trans (hb (Fin.last W,j)).2.2.2.1.symm + | cast i => exact (ha (i,j)).1.trans (hb (i,j)).1.symm + | inr w => + rcases w with ⟨i,j⟩ + cases H with + | zero => omega + | succ H => + cases j using Fin.lastCases with + | last => exact (ha (i,Fin.last H)).2.1.trans (hb (i,Fin.last H)).2.1.symm + | cast j => exact (ha (i,j)).2.2.1.trans (hb (i,j)).2.2.1.symm + +lemma matches_occupied {W H : ℕ} (hW : 0 exact matches_grid_occupied hW hH ha hb w + | inr t => exact (ha t).2.2.2.2.trans (hb t).2.2.2.2.symm + · rw [show spins σ μ w=1 from Function.extend_apply' _ _ _ hw, + show spins τ ν w=1 from Function.extend_apply' _ _ _ hw] + +lemma spins_injective {W H : ℕ} {σ τ : GridWire W H → Fin 3} {μ ν : Cell W H → Fin 3} + (h : spins σ μ=spins τ ν) : σ=τ ∧ μ=ν := by + constructor + · funext w + exact (spins_wire σ μ (.inl w)).symm.trans ((congrFun h (wireEmbedding (.inl w))).trans + (spins_wire τ ν (.inl w))) + · funext t + exact (spins_wire σ μ (.inr t)).symm.trans ((congrFun h (wireEmbedding (.inr t))).trans + (spins_wire τ ν (.inr t))) + +/-- If a fixed occupancy really is a simple actual path, every nonzero +center term is its unique rooted orientation. This excludes the zero-branch +without assuming any phase or noncancellation conclusion. -/ +theorem path_mask_unique {W H n : ℕ} (hW : 0if (∀ j, x.1.val (.inl (Fin.last W,j))=east j) ∧ + (∀ i, x.1.val (.inr (i,0))=south i) ∧ Matches cfg x.1.val x.2 then + centerProduct (domain W H) (spins x.1.val x.2) else 0 + change (∑ σ, ∑ μ, F (σ,μ))=_ + rw [←Fintype.sum_prod_type] + let x₀ : {σ : GridWire W H → Fin 3 // HasWestNorth west north σ} × (Cell W H → Fin 3) := + (⟨τ,hτ⟩,ν) + rw [Finset.sum_eq_single x₀] + · dsimp only [F,x₀] + rw [ite_eq_left ⟨hE,hS,hb⟩,hp] + · intro x hx hne + dsimp only [F] + split_ifs with hcond + · by_contra hn + have hr : spins x.1.val x.2 (p.edge 0)=outSpin (p.point 0) (p.side 0) := by + rw [hroot,spins_wire] + exact (x.1.property.1 j).trans hrootSpin + have he := path_mask_unique hW hH p hcond.2.2 hb hp hc hr hn + apply hne + apply Prod.ext + · exact Subtype.ext he.1 + · exact he.2 + · rfl + · simp + +theorem path_chosen_nonzero {W H n : ℕ} (hW : 0spinEquiv.symm (east j)))).count true=1) + (ho : (PlanarNormalization.occupancy (List.ofFn (fun j=>spinEquiv.symm (west j)))).count true=1) + (τ : GridWire W H → Fin 3) (ν : Cell W H → Fin 3) + (hτ : HasWestNorth west (fun _=>1) τ) + (hE : ∀ j, τ (.inl (Fin.last W,j))=east j) + (hS : ∀ i, τ (.inr (i,0))=1) + (hb : Matches cfg τ ν) (hp : spins τ ν=p.spins) + (hc : ∀ i, p.center i∈domain W H) + (h0 : p.point 0∉domain W H) (hl : p.point (Fin.last (n+1))∉domain W H) + (j : Fin H) (hroot : p.edge 0=wireEmbedding (W:=W) (H:=H) (.inl (.inl (0,j)))) + (hrootSpin : west j=outSpin (p.point 0) (p.side 0)) : + chosenPartition cfg west east (fun _=>1) (fun _=>1)=1 := by + exact (chosenPartition_zero_or_one cfg west east hi ho).resolve_left + (path_chosen_nonzero hW hH p cfg west east (fun _=>1) (fun _=>1) τ ν hτ hE hS hb hp hc + h0 hl j hroot hrootSpin) + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +open scoped BigOperators + +lemma cellCenter_mem {W H : ℕ} (t : Cell W H) (b : Bool) : + cellCenter t b∈domain W H := by + classical + exact Finset.mem_image.mpr ⟨(t,b),Finset.mem_univ _,rfl⟩ + +lemma domain_coord_bounds {W H : ℕ} {v : Center} (hv : v∈domain W H) : + 0≤v.1 ∧ v.1<(W:ℤ) ∧ 0≤v.2.1 ∧ v.2.1<(H:ℤ) := by + obtain ⟨⟨⟨i,j⟩,b⟩,_,rfl⟩ := Finset.mem_image.mp hv + simp only [cellCenter] + exact ⟨Int.natCast_nonneg _,by exact_mod_cast i.isLt, + Int.natCast_nonneg _,by exact_mod_cast j.isLt⟩ + +lemma domain_wire_covered {W H : ℕ} {v : Center} (hv : v∈domain W H) (k : Fin 3) : + incidentWire v k∈Set.range (wireEmbedding (W:=W) (H:=H)) := by + obtain ⟨⟨t,b⟩,_,rfl⟩ := Finset.mem_image.mp hv + cases b + · fin_cases k + · exact ⟨.inr t,(down_wires t).1.symm⟩ + · exact ⟨.inl ((network W H).north t),(down_wires t).2.1.symm⟩ + · exact ⟨.inl ((network W H).east t),(down_wires t).2.2.symm⟩ + · fin_cases k + · exact ⟨.inr t,(up_wires t).1.symm⟩ + · exact ⟨.inl ((network W H).south t),(up_wires t).2.1.symm⟩ + · exact ⟨.inl ((network W H).west t),(up_wires t).2.2.symm⟩ + +lemma path_wire_covered {W H n : ℕ} (p : CenterPath n) (hn : 0 + have he := p.in_wire ⟨0,hn⟩ + have hz : (⟨0,hn⟩ : Fin n).castSucc=0 := Fin.ext rfl + rw [hz] at he + rw [←he] + exact domain_wire_covered (hc _) _ + | succ i => + rw [←p.out_wire i] + exact domain_wire_covered (hc i) _ + +noncomputable def restrictGrid {W H : ℕ} (f : Wire → Fin 3) : GridWire W H → Fin 3 := + fun w=>f (wireEmbedding (.inl w)) +noncomputable def restrictMiddle {W H : ℕ} (f : Wire → Fin 3) : Cell W H → Fin 3 := + fun t=>f (wireEmbedding (.inr t)) + +lemma path_spins_restrict {W H n : ℕ} (p : CenterPath n) (hn : 0 rfl + · rw [show spins (restrictGrid (W:=W) (H:=H) p.spins) (restrictMiddle p.spins) w=1 from + Function.extend_apply' _ _ _ hw] + symm + apply p.spins_off + rintro ⟨j,rfl⟩ + exact hw (path_wire_covered p hn hc j) + +/-- Every actual loop-free path through the rectangle supplies an exact +occupancy shape; no hypothetical shape data is needed. -/ +noncomputable def pathShape {W H n : ℕ} (p : CenterPath n) (hn : 0q.outside.2.1) he + simpa only [westPort,down,Int.natCast_inj,Fin.val_inj] using hh + +lemma eastPort_injective (W H : ℕ) : Function.Injective (eastPort W H) := by + intro i j he + have hh := congrArg (fun q=>q.outside.2.1) he + simpa only [eastPort,up,Int.natCast_inj,Fin.val_inj] using hh + +lemma west_ne_east (W H : ℕ) (j k : Fin (H+1)) : westPort W H j≠eastPort W H k := by + intro he + have hh := congrArg (fun q=>q.outside.2.2) he + simp [westPort,eastPort,down,up] at hh + +lemma south_ne_west (W H : ℕ) (i : Fin (W+1)) (j : Fin (H+1)) : + southPort W H i≠westPort W H j := by + intro he + have hh := congrArg (fun q=>q.outside.1) he + simp only [southPort,westPort,down] at hh + omega + +lemma south_ne_east (W H : ℕ) (i : Fin (W+1)) (j : Fin (H+1)) : + southPort W H i≠eastPort W H j := by + intro he + have hh := congrArg (fun q=>q.outside.2.2) he + simp [southPort,eastPort,down,up] at hh + +lemma north_ne_west (W H : ℕ) (i : Fin (W+1)) (j : Fin (H+1)) : + northPort W H i≠westPort W H j := by + intro he + have hh := congrArg (fun q=>q.outside.2.2) he + simp [northPort,westPort,down,up] at hh + +lemma north_ne_east (W H : ℕ) (i : Fin (W+1)) (j : Fin (H+1)) : + northPort W H i≠eastPort W H j := by + intro he + have hh := congrArg (fun q=>q.outside.1) he + simp only [northPort,eastPort,up] at hh + have hi := i.isLt + omega + +lemma west_outside_ne_east (W H : ℕ) (j k : Fin (H+1)) : + (westPort W H j).outside≠(eastPort W H k).outside := by + simp [westPort,eastPort,down,up] + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open CenterPartition +variable {D : Set Center} {a b : Port D} + +lemma chord_length_pos (γ : Chord D a b) : 0<γ.val.length := by + obtain ⟨xs,hxs⟩ := List.head?_eq_some_iff.mp γ.property.2.1 + simp [hxs] + +lemma ofChord_first (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).point 0=a.outside := by + rw [ofChord_point] + rfl + +lemma ofChord_last (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).point (Fin.last (γ.val.length+1))=b.outside := by + rw [ofChord_point] + simp only [Fin.val_last,extendedTrace,List.getElem_cons_succ] + rw [List.getElem_append_right (le_refl _)] + simp + +lemma ofChord_second (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).point (0 : Fin (γ.val.length+1)).succ=a.inside := by + rw [ofChord_point] + obtain ⟨xs,hxs⟩ := List.head?_eq_some_iff.mp γ.property.2.1 + simp [extendedTrace,hxs] + +lemma ofChord_penultimate (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).point (Fin.last γ.val.length).castSucc=b.inside := by + rw [ofChord_point] + have hn := chord_length_pos γ + have he : (Fin.last γ.val.length).castSucc.val=γ.val.length-1+1 := by + simp only [Fin.val_castSucc,Fin.val_last] + omega + simp only [he,extendedTrace,List.getElem_cons_succ] + rw [List.getElem_append_left (by omega)] + apply Option.some.inj + rw [←List.getElem?_eq_getElem (by omega),←List.getLast?_eq_getElem?,γ.property.2.2] + +lemma ofChord_center_mem (γ : Chord D a b) (hab : a.outside≠b.outside) + (i : Fin γ.val.length) : (ofChord γ hab).center i∈D := by + rw [ofChord_center] + exact γ.property.1.2.2 _ (List.getElem_mem i.isLt) + +lemma ofChord_first_side (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).side 0=a.side := by + apply neighbor_injective a.outside + have he := (ofChord γ hab).step 0 + rw [show (0 : Fin (γ.val.length+1)).castSucc=0 from rfl,ofChord_first,ofChord_second] at he + rw [he,←a.neighbor_side,neighbor_neighbor] + +lemma ofChord_last_side (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).side (Fin.last γ.val.length)=b.side := by + apply neighbor_injective b.inside + have he := (ofChord γ hab).step (Fin.last γ.val.length) + rw [ofChord_penultimate,show (Fin.last γ.val.length).succ=Fin.last (γ.val.length+1) from rfl, + ofChord_last] at he + rw [he,b.neighbor_side] + +lemma ofChord_first_edge (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).edge 0=a.wire := by + unfold CenterPath.edge + rw [show (0 : Fin (γ.val.length+1)).castSucc=0 from rfl,ofChord_first,ofChord_first_side] + rw [←a.neighbor_side,incidentWire_neighbor] + rfl + +lemma ofChord_last_edge (γ : Chord D a b) (hab : a.outside≠b.outside) : + (ofChord γ hab).edge (Fin.last γ.val.length)=b.wire := by + unfold CenterPath.edge + rw [ofChord_penultimate,ofChord_last_side] + rfl + +/-- A path never uses another exterior edge: its only outside incidences +are the first and last edges, with their literal chronological indices. -/ +lemma CenterPath.outside_incident_index {n : ℕ} (p : CenterPath n) + (hc : ∀ i, p.center i∈D) {v : Center} (hv : v∉D) + (k : Fin 3) (j : Fin (n+1)) (he : incidentWire v k=p.edge j) : + j=0 ∨ j=Fin.last n := by + obtain ⟨hk,hleft|hright⟩ := (incidentWire_eq_iff _ _ _ _).mp he + · rcases p.point_cases j.castSucc with h0|hl|⟨i,hi⟩ + · left + have he' := congrArg (fun z : Fin (n+2)=>z.val) (p.injective h0) + apply Fin.ext + exact he' + · have he' := congrArg (fun z : Fin (n+2)=>z.val) (p.injective hl) + have hj := j.isLt + simp only [Fin.val_castSucc,Fin.val_last] at he' + omega + · exact False.elim (hv (hleft ▸ hi.symm ▸ hc i)) + · have he' : v=p.point j.succ := by + rw [←p.step j,←hk,←hright,neighbor_neighbor] + rcases p.point_cases j.succ with h0|hl|⟨i,hi⟩ + · have hh := congrArg (fun z : Fin (n+2)=>z.val) (p.injective h0) + simp only [Fin.val_succ,Fin.val_zero] at hh + omega + · right + have hh := congrArg (fun z : Fin (n+2)=>z.val) (p.injective hl) + apply Fin.ext + simp only [Fin.val_succ,Fin.val_last] at hh ⊢ + omega + · exact False.elim (hv (he' ▸ hi.symm ▸ hc i)) + +lemma ofChord_boundary_wire (γ : Chord D a b) (hab : a.outside≠b.outside) + (q : Port D) : q.wire∈Set.range (ofChord γ hab).edge ↔ q=a ∨ q=b := by + constructor + · rintro ⟨j,hj⟩ + have hi : incidentWire q.outside q.side=(ofChord γ hab).edge j := by + rw [←q.neighbor_side,incidentWire_neighbor] + exact hj.symm + rcases (ofChord γ hab).outside_incident_index (ofChord_center_mem γ hab) + q.outside_not_mem q.side j hi with h0|hl + · left + apply Port.wire_ext + rw [←hj,h0,ofChord_first_edge] + · right + apply Port.wire_ext + rw [←hj,hl,ofChord_last_edge] + · rintro (rfl|rfl) + · exact ⟨0,ofChord_first_edge γ hab⟩ + · exact ⟨Fin.last γ.val.length,ofChord_last_edge γ hab⟩ + +lemma ofChord_boundary_vacant (γ : Chord D a b) (hab : a.outside≠b.outside) + (q : Port D) (qa : q≠a) (qb : q≠b) : (ofChord γ hab).spins q.wire=1 := by + apply CenterPath.spins_off + rw [ofChord_boundary_wire] + exact not_or.mpr ⟨qa,qb⟩ + +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations + +abbrev RectChord (W H : ℕ) (j k : Fin (H+1)) := + Chord (domain (W+1) (H+1) : Set Center) (westPort W H j) (eastPort W H k) + +noncomputable def rectanglePath {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + CenterPath γ.val.length := ofChord γ (west_outside_ne_east W H j k) + +lemma rectanglePath_first_spins {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + (rectanglePath γ).spins (westPort W H j).wire=2 := by + rw [←ofChord_first_edge γ (west_outside_ne_east W H j k)] + change (rectanglePath γ).spins ((rectanglePath γ).edge 0)=2 + rw [CenterPath.spins_edge] + change outSpin ((ofChord γ _).point 0) ((ofChord γ _).side 0)=2 + rw [ofChord_first,ofChord_first_side,westPort_side] + simp [westPort,outSpin,down] + +lemma rectanglePath_last_spins {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + (rectanglePath γ).spins (eastPort W H k).wire=2 := by + rw [←ofChord_last_edge γ (west_outside_ne_east W H j k)] + change (rectanglePath γ).spins ((rectanglePath γ).edge (Fin.last γ.val.length))=2 + rw [CenterPath.spins_edge] + change outSpin ((ofChord γ _).point (Fin.last γ.val.length).castSucc) + ((ofChord γ _).side (Fin.last γ.val.length))=2 + rw [ofChord_penultimate,ofChord_last_side,eastPort_side] + simp [eastPort,outSpin,cellCenter] + +def singleColumn {H : ℕ} (j : Fin H) : Column H := fun k=>if k=j then 2 else 1 + +lemma singleColumn_occupancy {H : ℕ} (j : Fin H) : + (PlanarNormalization.occupancy (List.ofFn (fun k=>spinEquiv.symm (singleColumn j k)))).count true=1 := by + have he : PlanarNormalization.occupancy (List.ofFn (fun k=>spinEquiv.symm (singleColumn j k))) = + List.ofFn (fun k=>decide (k=j)) := by + simp only [PlanarNormalization.occupancy,List.map_ofFn] + congr 1 + funext k + by_cases hk : k=j <;> simp [singleColumn,hk,spinEquiv] + rw [he] + clear he + induction H with + | zero => exact Fin.elim0 j + | succ H ih => + cases j using Fin.cases with + | zero => simp [List.ofFn_succ,List.count_replicate] + | succ j => + have hz : (0:Fin (H+1))≠j.succ := by intro h; have := congrArg Fin.val h; simp at this + simpa [List.ofFn_succ,hz] using ih j + +lemma rectanglePath_west {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) + (r : Fin (H+1)) : + restrictGrid (W:=W+1) (H:=H+1) (rectanglePath γ).spins (.inl (0,r))=singleColumn j r := by + unfold restrictGrid + rw [←westPort_wire] + by_cases hr : r=j + · subst r + rw [rectanglePath_first_spins] + simp [singleColumn] + · change (ofChord γ (west_outside_ne_east W H j k)).spins _ = _ + rw [ofChord_boundary_vacant γ (west_outside_ne_east W H j k) (westPort W H r) + (fun he=>hr (westPort_injective W H he)) (west_ne_east W H r k)] + simp [singleColumn,hr] + +lemma rectanglePath_east {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) + (r : Fin (H+1)) : + restrictGrid (W:=W+1) (H:=H+1) (rectanglePath γ).spins (.inl (Fin.last (W+1),r))=singleColumn k r := by + unfold restrictGrid + rw [←eastPort_wire] + by_cases hr : r=k + · subst r + rw [rectanglePath_last_spins] + simp [singleColumn] + · change (ofChord γ (west_outside_ne_east W H j k)).spins _ = _ + rw [ofChord_boundary_vacant γ (west_outside_ne_east W H j k) (eastPort W H r) + (Ne.symm (west_ne_east W H j r)) (fun he=>hr (eastPort_injective W H he))] + simp [singleColumn,hr] + +lemma rectanglePath_north {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) + (r : Fin (W+1)) : + restrictGrid (W:=W+1) (H:=H+1) (rectanglePath γ).spins (.inr (r,Fin.last (H+1)))=1 := by + unfold restrictGrid + rw [←northPort_wire] + exact ofChord_boundary_vacant γ (west_outside_ne_east W H j k) (northPort W H r) + (north_ne_west W H r j) (north_ne_east W H r k) + +lemma rectanglePath_south {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) + (r : Fin (W+1)) : + restrictGrid (W:=W+1) (H:=H+1) (rectanglePath γ).spins (.inr (r,0))=1 := by + unfold restrictGrid + rw [←southPort_wire] + exact ofChord_boundary_vacant γ (west_outside_ne_east W H j k) (southPort W H r) + (south_ne_west W H r j) (south_ne_east W H r k) + +noncomputable def rectangleShape {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + Cell (W+1) (H+1) → Shape := + pathShape (rectanglePath γ) (chord_length_pos γ) (ofChord_center_mem γ _) (by + rw [rectanglePath,ofChord_first]; exact (westPort W H j).outside_not_mem) (by + rw [rectanglePath,ofChord_last]; exact (eastPort W H k).outside_not_mem) + +/-- The normalized finite transfer coefficient of each literal source chord +is exactly one. No path noncancellation or single-strand phase has been +postulated; both are proved from the exact center tensors. -/ +theorem actual_chord_chosen_one {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + chosenPartition (rectangleShape γ) (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)=1 := by + apply path_chosen_eq_one (by omega) (by omega) (rectanglePath γ) (rectangleShape γ) + (singleColumn j) (singleColumn k) (singleColumn_occupancy k) (singleColumn_occupancy j) + (restrictGrid (rectanglePath γ).spins) (restrictMiddle (rectanglePath γ).spins) (j:=j) + · exact ⟨rectanglePath_west γ,rectanglePath_north γ⟩ + · exact rectanglePath_east γ + · exact rectanglePath_south γ + · exact pathShape_matches _ _ _ _ _ + · exact path_spins_restrict (rectanglePath γ) (chord_length_pos γ) (ofChord_center_mem γ _) + · exact ofChord_center_mem γ _ + · rw [rectanglePath,ofChord_first] + exact (westPort W H j).outside_not_mem + · rw [rectanglePath,ofChord_last] + exact (eastPort W H k).outside_not_mem + · rw [rectanglePath,ofChord_first_edge,westPort_wire] + · rw [rectanglePath,ofChord_first,ofChord_first_side,westPort_side] + simp [singleColumn,outSpin,westPort,down] + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open PhysicalTiles FiniteConfigurations CenterPartition +open scoped BigOperators + +noncomputable def usedCenter (σ : Wire → Fin 3) (v : Center) : ℕ := + if ∃ k : Fin 3, σ (incidentWire v k)≠1 then 1 else 0 + +lemma usedCenter_degree (σ : Wire → Fin 3) (v : Center) : + usedCenter σ v = if selectedSideCount (fun w=>spinOccupied (σ w)) v=0 then 0 else 1 := by + classical + have hz : selectedSideCount (fun w=>spinOccupied (σ w)) v=0 ↔ + ∀ k : Fin 3, σ (incidentWire v k)=1 := by + simp [selectedSideCount,spinOccupied,Fin.forall_fin_succ,and_assoc] + simp only [hz] + by_cases h : ∃ k : Fin 3, σ (incidentWire v k)≠1 + · have hn : ¬∀ k : Fin 3, σ (incidentWire v k)=1 := by + rintro hf; obtain ⟨k,hk⟩ := h; exact hk (hf k) + simp [usedCenter,h,hn] + · have hn : ∀ k : Fin 3, σ (incidentWire v k)=1 := by simpa only [not_exists,not_not] using h + simp [usedCenter,hn] + +lemma CenterPath.used_iff {n : ℕ} (p : CenterPath n) (v : Center) + (h0 : v≠p.point 0) (hl : v≠p.point (Fin.last (n+1))) : + usedCenter p.spins v = if v∈Set.range p.center then 1 else 0 := by + classical + by_cases hv : v∈Set.range p.center + · obtain ⟨i,rfl⟩ := hv + have h : ∃ k : Fin 3, p.spins (incidentWire (p.center i) k)≠1 := by + refine ⟨p.side i.succ,?_⟩ + rw [p.out_wire,p.spins_edge] + exact outSpin_ne_empty _ _ + simp [usedCenter,h] + · have h : ¬∃ k : Fin 3, p.spins (incidentWire v k)≠1 := by + rintro ⟨k,hk⟩ + exact hk (p.spins_off _ (p.incident_off v h0 hl hv k)) + simp [usedCenter,h,hv] + +lemma CenterPath.center_injective {n : ℕ} (p : CenterPath n) : Function.Injective p.center := by + intro i j h + have he := congrArg Fin.val (p.injective h) + apply Fin.ext + simpa [CenterPath.center] using he + +lemma CenterPath.sum_used {n : ℕ} (p : CenterPath n) (D : Finset Center) + (hc : ∀ i, p.center i∈D) (h0 : p.point 0∉D) (hl : p.point (Fin.last (n+1))∉D) : + ∑ v ∈ D, usedCenter p.spins v = n := by + classical + have he : D.filter (fun v=>v∈Set.range p.center)=Finset.univ.image p.center := by + ext v + simp only [Finset.mem_filter,Finset.mem_image,Finset.mem_univ,true_and,Set.mem_range] + exact ⟨fun h=>h.2,fun ⟨i,hi⟩=>⟨hi ▸ hc i,⟨i,hi⟩⟩⟩ + calc + _ = ∑ v ∈ D, if v∈Set.range p.center then 1 else 0 := by + apply Finset.sum_congr rfl + intro v hv + exact p.used_iff v (fun h=>h0 (h ▸ hv)) (fun h=>hl (h ▸ hv)) + _ = (D.filter (fun v=>v∈Set.range p.center)).card := by simp + _ = n := by rw [he,Finset.card_image_of_injective _ p.center_injective]; simp + +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles FiniteConfigurations CenterPartition ChordOrientations +open scoped BigOperators + +lemma shape_visits_used {W H : ℕ} {cfg : Cell W H → Shape} + {σ : GridWire W H → Fin 3} {μ : Cell W H → Fin 3} (hm : Matches cfg σ μ) (t : Cell W H) : + (cfg t).visits = usedCenter (spins σ μ) (cellCenter t true) + + usedCenter (spins σ μ) (cellCenter t false) := by + rw [visits_eq,usedCenter_degree,usedCenter_degree] + have hu : selectedSideCount (fun w=>spinOccupied (spins σ μ w)) (cellCenter t true)= + (cfg t).selection.upDegree := by + unfold selectedSideCount + rw [(up_wires t).1,(up_wires t).2.1,(up_wires t).2.2] + simp only [spins_wire,Sum.elim_inl,Sum.elim_inr,(hm t).1,(hm t).2.2.1,(hm t).2.2.2.2] + unfold Selection.upDegree + omega + have hd : selectedSideCount (fun w=>spinOccupied (spins σ μ w)) (cellCenter t false)= + (cfg t).selection.downDegree := by + unfold selectedSideCount + rw [(down_wires t).1,(down_wires t).2.1,(down_wires t).2.2] + simp only [spins_wire,Sum.elim_inl,Sum.elim_inr,(hm t).2.1,(hm t).2.2.2.1,(hm t).2.2.2.2] + unfold Selection.downDegree + omega + rw [hu,hd] + +lemma sum_visits_used {W H : ℕ} {cfg : Cell W H → Shape} + {σ : GridWire W H → Fin 3} {μ : Cell W H → Fin 3} (hm : Matches cfg σ μ) : + (∑ t, (cfg t).visits) = ∑ v ∈ domain W H, usedCenter (spins σ μ) v := by + classical + rw [domain,Finset.sum_image (fun x _ y _ h=>cellCenter_injective W H h)] + rw [Fintype.sum_prod_type (fun p : Cell W H × Bool=>usedCenter (spins σ μ) (cellCenter p.1 p.2))] + apply Finset.sum_congr rfl + intro t ht + rw [Fintype.sum_bool] + exact shape_visits_used hm t + +/-- Port half-edges are unweighted: the exact raster exponent is the number +of centers in the source trace, with no additive endpoint correction. -/ +theorem actual_chord_visits {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + (∑ t, (rectangleShape γ t).visits)=γ.val.length := by + have hm : Matches (rectangleShape γ) (restrictGrid (rectanglePath γ).spins) + (restrictMiddle (rectanglePath γ).spins) := pathShape_matches _ _ _ _ _ + rw [sum_visits_used hm,path_spins_restrict (rectanglePath γ) (chord_length_pos γ) (ofChord_center_mem γ _)] + apply CenterPath.sum_used + · exact ofChord_center_mem γ _ + · rw [rectanglePath,ofChord_first]; exact (westPort W H j).outside_not_mem + · rw [rectanglePath,ofChord_last]; exact (eastPort W H k).outside_not_mem + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.PathComponents +open SimpleGraph +variable {V : Type*} {G : SimpleGraph V} + +lemma paths_eq_of_edges_subset {a b : V} (p q : G.Walk a b) + (hp : p.IsPath) (hq : q.IsPath) (hsub : p.edges ⊆ q.edges) : p = q := by + induction p with + | nil => + have hnil : q.Nil := Walk.isPath_iff_nil.mp hq + cases hnil + rfl + | @cons a c b hac p ih => + cases q with + | nil => simp at hp + | @cons _ d _ had q => + have hcd : c = d := by + have he : s(a,c) ∈ (Walk.cons had q).edges := hsub (by simp) + simpa using hq.eq_snd_of_mem_edges he + subst d + have hn : a ∉ p.support := (Walk.cons_isPath_iff hac p).mp hp |>.2 + congr 1 + apply ih q hp.of_cons hq.of_cons + intro e he + have heq := hsub (List.mem_cons_of_mem _ he) + simp only [Walk.edges_cons,List.mem_cons] at heq + rcases heq with heq | heq + · subst e + exact (hn (p.fst_mem_support_of_mem_edges he)).elim + · exact heq + +lemma walk_in_closed_set (S : Set V) + (hclosed : ∀ v ∈ S, ∀ w, G.Adj v w → w ∈ S) + {a b : V} (p : G.Walk a b) (ha : a ∈ S) : ∀ v ∈ p.support, v ∈ S := by + induction p with + | nil => simpa using ha + | @cons a c b hac p ih => + intro v hv + rcases List.mem_cons.mp hv with rfl | hv + · exact ha + · exact ih (hclosed a ha c hac) v hv + +/-- The boundary path of a finite 0/2-degree configuration is unique. +This prevents multiplicity in the physical path expansion. -/ +theorem two_port_path_unique [Fintype V] [DecidableRel G.Adj] + {a b : V} (hab : a ≠ b) (ha : G.degree a = 1) (hb : G.degree b = 1) + (upper : ∀ v, G.degree v ≤ 2) (p q : G.Walk a b) + (hp : p.IsPath) (hq : q.IsPath) : p = q := by + have hs : ∀ v ∈ p.support, v ∈ q.support := + walk_in_closed_set {v | v ∈ q.support} + (fun _ hv _ h => path_closed G hab ha hb upper q hq hv h) p q.start_mem_support + apply paths_eq_of_edges_subset p q hp hq + intro e he + induction e using Sym2.inductionOn with + | _ x y => + apply Walk.adj_toSubgraph_iff_mem_edges.mp + change y ∈ q.toSubgraph.neighborSet x + rw [path_neighbor_eq G hab ha hb upper q hq (hs x (p.fst_mem_support_of_mem_edges he))] + exact p.adj_of_mem_edges he +end CriticalHoneycomb.Transfer.PathComponents + +namespace CriticalHoneycomb.Transfer.ChordOrientations +open SimpleGraph PhysicalTiles CenterPartition FiniteConfigurations + +lemma CenterPath.selected_edge {n : ℕ} (p : CenterPath n) (i : Fin (n+1)) : + selected p.spins (p.edge i)=true := by + simp [selected,spinOccupied,p.spins_edge,outSpin_ne_empty] + +lemma chord_boundary_selection {D : Finset Center} {a b : Port (D : Set Center)} + (γ : Chord (D : Set Center) a b) (hab : a.outside≠b.outside) : + BoundarySelection a b (selected (ofChord γ hab).spins) := by + refine ⟨?_,?_,?_⟩ + · rw [←ofChord_first_edge γ hab]; exact CenterPath.selected_edge _ _ + · rw [←ofChord_last_edge γ hab]; exact CenterPath.selected_edge _ _ + · intro v hv k hk hs + let q : Port (D : Set Center) := ⟨v,neighbor v k,(adj_iff_neighbor _ _).mpr ⟨k,rfl⟩,hv,hk⟩ + have hq : q.wire=incidentWire v k := by + unfold Port.wire + congr 1 + apply neighbor_injective v + exact q.neighbor_side + have hw : q.wire ∈ Set.range (ofChord γ hab).edge := by + by_contra he + have hh := (ofChord γ hab).spins_off q.wire he + rw [hq] at hh + simp [selected,spinOccupied,hh] at hs + rcases (ofChord_boundary_wire γ hab q).mp hw with h|h + · left; rw [←hq,h] + · right; rw [←hq,h] + +/-- The converse path is bound to the actual selected midpoint edges, not +just to the underlying hard-wall graph. -/ +theorem chord_selected_path {D : Finset Center} {a b : Port (D : Set Center)} + (γ : Chord (D : Set Center) a b) (hab : a.outside≠b.outside) (s : Wire → Bool) + (he : ∀ i, s ((ofChord γ hab).edge i)=true) : + ∃ (xs : List (Interior D)) + (p : (selectedGraph a b s).Walk (.inr false) (.inr true)), + xs.map Subtype.val=γ.val ∧ p.IsPath ∧ + p.support=Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true]) := by + classical + let xs : List (Interior D) := γ.val.attach.map fun v=>⟨v.val,γ.property.1.2.2 v.val v.property⟩ + have hmap : xs.map Subtype.val=γ.val := by + simpa only [xs,List.map_map,Function.comp_def] using List.attach_map_subtype_val γ.val + have hnd : xs.Nodup := List.Nodup.of_map _ (hmap.symm ▸ γ.property.1.1) + have hlen : xs.length=γ.val.length := by + simpa only [List.length_map] using congrArg List.length hmap + have hget (i : ℕ) (hi : il[i]?) hmap + have h1 : (xs.map Subtype.val)[i]?=some (xs[i]).val := by + simp [List.getElem?_map,List.getElem?_eq_getElem hi] + have h2 : γ.val[i]?=some (γ.val[i]'(by omega)) := List.getElem?_eq_getElem _ + exact Option.some.inj (h1.symm.trans (hh.trans h2)) + have hchain : xs.IsChain (fun v w=>∃ k : Fin 3, neighbor v.val k=w.val ∧ s (incidentWire v.val k)=true) := by + apply List.isChain_iff_getElem.mpr + intro i hi + let z : Fin (γ.val.length+1) := ⟨i+1,by omega⟩ + let u : Fin γ.val.length := ⟨i,by omega⟩ + let v : Fin γ.val.length := ⟨i+1,by omega⟩ + have hu : (ofChord γ hab).point z.castSucc=(xs[i]).val := by + change (ofChord γ hab).center u=_ + rw [ofChord_center,hget] + have hv : (ofChord γ hab).point z.succ=(xs[i+1]).val := by + change (ofChord γ hab).center v=_ + rw [ofChord_center,hget] + refine ⟨(ofChord γ hab).side z,?_,?_⟩ + · rw [←hu,←hv]; exact (ofChord γ hab).step z + · rw [←hu] + exact he z + have hhead : xs.head?=some (portInside a) := by + apply Option.map_injective Subtype.val_injective + change xs.head?.map Subtype.val=some a.inside + rw [←List.head?_map,hmap]; exact γ.property.2.1 + have hlast : xs.getLast?=some (portInside b) := by + apply Option.map_injective Subtype.val_injective + change xs.getLast?.map Subtype.val=some b.inside + rw [←List.getLast?_map,hmap]; exact γ.property.2.2 + have ha : s a.wire=true := by rw [←ofChord_first_edge γ hab]; exact he _ + have hb : s b.wire=true := by rw [←ofChord_last_edge γ hab]; exact he _ + let support : List (Vertices D) := Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true]) + have hsc : support.IsChain (selectedGraph a b s).Adj := by + have hc := (chain_ports (fun v w : Interior D=>∃ k : Fin 3, + neighbor v.val k=w.val ∧ s (incidentWire v.val k)=true) (portInside a) (portInside b) xs).mpr + ⟨hchain,hhead,hlast⟩ + apply hc.imp + intro x y h + cases x with + | inl v => cases y with + | inl w => exact h + | inr q => cases q <;> exact ⟨congrArg Subtype.val h,by assumption⟩ + | inr q => cases y with + | inl v => cases q <;> exact ⟨congrArg Subtype.val h,by assumption⟩ + | inr r => cases q <;> cases r <;> exact h.elim + have hne : support≠[] := List.cons_ne_nil _ _ + have hsh : support.head hne = .inr false := rfl + have hsl : support.getLast hne = .inr true := by simp [support] + let p : (selectedGraph a b s).Walk (.inr false) (.inr true) := + (Walk.ofSupport support hne hsc).copy hsh hsl + have hps : p.support=support := by simp [p] + refine ⟨xs,p,hmap,?_,hps⟩ + rw [Walk.isPath_def,hps] + simp [support,List.nodup_append,hnd.map Sum.inl_injective] + +/-- An unoriented occupied configuration has at most one literal source +chord. This prevents hidden multiplicity in the finite transfer expansion. -/ +theorem chord_eq_of_selected_eq {D : Finset Center} {a b : Port (D : Set Center)} + (γ δ : Chord (D : Set Center) a b) (hab : a.outside≠b.outside) + (hs : selected (ofChord γ hab).spins=selected (ofChord δ hab).spins) : γ=δ := by + classical + let C := configurationOfNonzero a b (fun h=>hab (congrArg Port.outside h)) + (ofChord γ hab).spins (chord_boundary_selection γ hab) + ((ofChord γ hab).product_nonzero D (by rw [ofChord_first]; exact a.outside_not_mem) + (by rw [ofChord_last]; exact b.outside_not_mem)) + obtain ⟨xs,p,hxs,hp,hps⟩ := chord_selected_path γ hab _ (CenterPath.selected_edge _) + obtain ⟨ys,q,hys,hq,hqs⟩ := chord_selected_path δ hab (selected (ofChord γ hab).spins) (by + intro i; rw [hs]; exact CenterPath.selected_edge _ _) + have hd (r : Bool) : C.graph.degree (.inr r)=1 := by + rw [←PathComponents.ncard_neighbors]; exact C.port_degree r + have hu (v : Vertices D) : C.graph.degree v≤2 := by + cases v with + | inl v => + have h := C.center_degree v + rw [PathComponents.ncard_neighbors] at h + omega + | inr r => rw [hd]; omega + have hpq : p=q := PathComponents.two_port_path_unique (G:=C.graph) (by simp) + (hd false) (hd true) hu p q hp hq + have hl := congrArg Walk.support hpq + rw [hps,hqs] at hl + have he : xs.map Sum.inl=ys.map (Sum.inl : Interior D → Vertices D) := + List.append_cancel_right (List.cons.inj hl).2 + have hxy : xs=ys := List.map_injective_iff.mpr Sum.inl_injective he + apply Subtype.ext + rw [←hxs,←hys,hxy] + +end CriticalHoneycomb.Transfer.ChordOrientations + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations + +/-- No two different actual source chords are counted by the same literal +raster shape configuration. -/ +theorem rectangleShape_injective {W H : ℕ} {j k : Fin (H+1)} : + Function.Injective (rectangleShape (W:=W) (H:=H) (j:=j) (k:=k)) := by + intro γ δ he + apply chord_eq_of_selected_eq γ δ (west_outside_ne_east W H j k) + have hg : Matches (rectangleShape γ) (restrictGrid (rectanglePath γ).spins) + (restrictMiddle (rectanglePath γ).spins) := pathShape_matches _ _ _ _ _ + have hd : Matches (rectangleShape δ) (restrictGrid (rectanglePath δ).spins) + (restrictMiddle (rectanglePath δ).spins) := pathShape_matches _ _ _ _ _ + rw [←he] at hd + funext w + have hh := matches_occupied (by omega) (by omega) hg hd w + rw [path_spins_restrict (rectanglePath γ) (chord_length_pos γ) (ofChord_center_mem γ _), + path_spins_restrict (rectanglePath δ) (chord_length_pos δ) (ofChord_center_mem δ _)] at hh + exact hh + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition ChordOrientations +open scoped BigOperators + +noncomputable instance rectChordFintype {W H : ℕ} {j k : Fin (H+1)} : Fintype (RectChord W H j k) := + Fintype.ofInjective rectangleShape rectangleShape_injective + +lemma chord_term_real {W H : ℕ} {j k : Fin (H+1)} (γ : RectChord W H j k) : + ((kappa:ℂ)^(∑ t, (rectangleShape γ t).visits) * chosenPartition (rectangleShape γ) + (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)).re=kappa^γ.val.length := by + rw [actual_chord_chosen_one,mul_one] + calc + ((kappa:ℂ)^(∑ t, (rectangleShape γ t).visits)).re = kappa^(∑ t, (rectangleShape γ t).visits) := + congrArg Complex.re (Complex.ofReal_pow kappa _).symm + _ = kappa^γ.val.length := congrArg (fun n : ℕ=>kappa^n) (actual_chord_visits γ) + +lemma shape_term_nonnegative {W H : ℕ} (j k : Fin (H+1)) (cfg : Cell (W+1) (H+1) → Shape) : + 0≤((kappa:ℂ)^(∑ t, (cfg t).visits) * chosenPartition cfg + (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)).re := by + rcases chosenPartition_zero_or_one cfg _ _ (singleColumn_occupancy k) (singleColumn_occupancy j) with h|h + · simp [h] + · simp only [h,mul_one,←Complex.ofReal_pow,Complex.ofReal_re] + exact pow_nonneg (le_of_lt (Real.rpow_pos_of_pos (by positivity : 0<(2+Real.sqrt 2:ℝ)) (-(1:ℝ)/2))) _ + +/-- Every literal source chord appears with its exact critical weight and +multiplicity one in the finite physical transfer expansion. Detached loops +are not ignored here: all other fixed configurations are nonnegative. -/ +theorem actual_chord_sum_le_transfer {W H : ℕ} (j k : Fin (H+1)) : + (∑ γ : RectChord W H j k, kappa^γ.val.length) ≤ + (prescribedPartition (W+1) (H+1) (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)).re := by + classical + let F : (Cell (W+1) (H+1) → Shape) → ℝ := fun cfg=> + ((kappa:ℂ)^(∑ t, (cfg t).visits) * chosenPartition cfg + (singleColumn j) (singleColumn k) (fun _=>1) (fun _=>1)).re + have hsum : (∑ γ : RectChord W H j k, kappa^γ.val.length) = + ∑ cfg ∈ Finset.univ.image (rectangleShape (W:=W) (H:=H) (j:=j) (k:=k)), F cfg := by + rw [Finset.sum_image (fun x _ y _ h=>rectangleShape_injective h)] + apply Finset.sum_congr rfl + intro γ hγ + exact (chord_term_real γ).symm + rw [hsum,prescribed_shape_expansion] + simp only [Complex.re_sum] + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro cfg hcfg hnot + exact shape_term_nonnegative j k cfg + +/-- A finite-domain mass bound: the actual ENNReal chord mass is dominated by the literal source +physical transfer coefficient. -/ +theorem actual_chordMass_le_transfer {W H : ℕ} (j k : Fin (H+1)) : + chordMass (domain (W+1) (H+1) : Set Center) (westPort W H j) (eastPort W H k) ≤ + ENNReal.ofReal (prescribedPartition (W+1) (H+1) (singleColumn j) (singleColumn k) + (fun _=>1) (fun _=>1)).re := by + rw [chordMass,tsum_fintype] + simp only [weight] + rw [←ENNReal.ofReal_sum_of_nonneg (fun γ _=>pow_nonneg (le_of_lt (Real.rpow_pos_of_pos (by positivity : 0<(2+Real.sqrt 2:ℝ)) (-(1:ℝ)/2))) γ.val.length)] + exact ENNReal.ofReal_le_ofReal (actual_chord_sum_le_transfer j k) + +end CriticalHoneycomb.Transfer.RasterGrid + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/RasterGrid.lean b/lean/OAI/Combinatorics/HoneycombChords/RasterGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..817ca60eaebdd2c286255b776702887fcd9bf712 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/RasterGrid.lean @@ -0,0 +1,311 @@ +import OAI.Combinatorics.HoneycombChords.PhysicalTiles + +namespace OAI + +/-! +# Finite honeycomb raster contractions + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition +open scoped BigOperators + +abbrev Cell (W H : ℕ) := Fin W × Fin H +/-- Horizontal wires run west/east; vertical wires run south/north. The +extra endpoint in each coordinate is literal, not periodic boundary data. -/ +abbrev GridWire (W H : ℕ) := (Fin (W+1) × Fin H) ⊕ (Fin W × Fin (H+1)) +abbrev FullWire (W H : ℕ) := GridWire W H ⊕ Cell W H + +def network (W H : ℕ) : TileNetwork (GridWire W H) (Cell W H) where + west t := .inl (t.1.castSucc,t.2) + east t := .inl (t.1.succ,t.2) + south t := .inr (t.1,t.2.castSucc) + north t := .inr (t.1,t.2.succ) + +def wireEmbedding {W H : ℕ} : FullWire W H → Wire + | .inl (.inl (i,j)) => (i.val,j.val,2) + | .inl (.inr (i,j)) => (i.val,j.val,1) + | .inr (i,j) => (i.val,j.val,0) + +lemma wireEmbedding_injective (W H : ℕ) : + Function.Injective (wireEmbedding (W:=W) (H:=H)) := by + intro x y h + cases x with + | inl x => cases x with + | inl x => cases y with + | inl y => cases y with + | inl y => simpa [wireEmbedding,Prod.ext_iff,Fin.ext_iff] using h + | inr y => simp [wireEmbedding] at h + | inr y => simp [wireEmbedding] at h + | inr x => cases y with + | inl y => cases y with + | inl y => simp [wireEmbedding] at h + | inr y => simpa [wireEmbedding,Prod.ext_iff,Fin.ext_iff] using h + | inr y => simp [wireEmbedding] at h + | inr x => cases y with + | inl y => cases y <;> simp [wireEmbedding] at h + | inr y => simpa [wireEmbedding,Prod.ext_iff,Fin.ext_iff] using h + +noncomputable def spins {W H : ℕ} (σ : GridWire W H → Fin 3) + (μ : Cell W H → Fin 3) : Wire → Fin 3 := + Function.extend wireEmbedding (Sum.elim σ μ) (fun _ => 1) + +lemma spins_wire {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (w : FullWire W H) : spins σ μ (wireEmbedding w)=Sum.elim σ μ w := by + exact (wireEmbedding_injective W H).extend_apply _ _ _ + +def cellCenter {W H : ℕ} (t : Cell W H) (b : Bool) : Center := + (t.1.val,t.2.val,b) + +lemma cellCenter_injective (W H : ℕ) : + Function.Injective (fun p : Cell W H × Bool => cellCenter p.1 p.2) := by + intro x y h + rcases x with ⟨⟨i,j⟩,b⟩ + rcases y with ⟨⟨i',j'⟩,b'⟩ + simpa [cellCenter,Prod.ext_iff,Fin.ext_iff,and_assoc] using h + +noncomputable def domain (W H : ℕ) : Finset Center := + Finset.univ.image (fun p : Cell W H × Bool => cellCenter p.1 p.2) + +lemma up_wires {W H : ℕ} (t : Cell W H) : + incidentWire (cellCenter t true) 0 = wireEmbedding (.inr t) ∧ + incidentWire (cellCenter t true) 1 = wireEmbedding (.inl ((network W H).south t)) ∧ + incidentWire (cellCenter t true) 2 = wireEmbedding (.inl ((network W H).west t)) := by + simp [incidentWire,cellCenter,wireEmbedding,network] + +lemma down_wires {W H : ℕ} (t : Cell W H) : + incidentWire (cellCenter t false) 0 = wireEmbedding (.inr t) ∧ + incidentWire (cellCenter t false) 1 = wireEmbedding (.inl ((network W H).north t)) ∧ + incidentWire (cellCenter t false) 2 = wireEmbedding (.inl ((network W H).east t)) := by + simp [incidentWire,cellCenter,wireEmbedding,network,Nat.cast_add] + +lemma up_centerTensor {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (t : Cell W H) : centerTensor (spins σ μ) (cellCenter t true) = + upTensor (σ ((network W H).west t)) (σ ((network W H).south t)) (μ t) := by + change upTensor _ _ _ = _ + rw [(up_wires t).1,(up_wires t).2.1,(up_wires t).2.2] + simp only [spins_wire,Sum.elim_inl,Sum.elim_inr] + +lemma down_centerTensor {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) + (t : Cell W H) : centerTensor (spins σ μ) (cellCenter t false) = + downTensor (σ ((network W H).east t)) (σ ((network W H).north t)) (μ t) := by + change downTensor _ _ _ = _ + rw [(down_wires t).1,(down_wires t).2.1,(down_wires t).2.2] + simp only [spins_wire,Sum.elim_inl,Sum.elim_inr] + +/-- Product of actual visited-center tensors on the literal rectangle. -/ +lemma center_product_eq {W H : ℕ} (σ : GridWire W H → Fin 3) (μ : Cell W H → Fin 3) : + centerProduct (domain W H) (spins σ μ) = + ∏ t : Cell W H, upTensor (σ ((network W H).west t)) (σ ((network W H).south t)) (μ t) * + downTensor (σ ((network W H).east t)) (σ ((network W H).north t)) (μ t) := by + classical + rw [centerProduct,domain,Finset.prod_image (fun x _ y _ h => cellCenter_injective W H h)] + rw [Fintype.prod_prod_type] + apply Finset.prod_congr rfl + intro t ht + simp only [Fintype.prod_bool,up_centerTensor,down_centerTensor] + +/-- The source finite physical network contracts precisely to the actual +center tensors on the rectangle, with every internal middle wire summed. -/ +theorem grid_physical_eq_centers (W H : ℕ) (σ : GridWire W H → Fin 3) : + (network W H).physical σ = ∑ μ : Cell W H → Fin 3, + centerProduct (domain W H) (spins σ μ) := by + rw [physical_network_center_expansion] + apply Finset.sum_congr rfl + intro μ hμ + exact (center_product_eq σ μ).symm + +end CriticalHoneycomb.Transfer.RasterGrid + +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles CenterPartition +open scoped BigOperators Matrix + +lemma sum_vectors_cons {α : Type*} [Fintype α] {n : ℕ} + (F : (Fin (n+1) → α) → ℂ) : + (∑ τ, F τ) = ∑ a : α, ∑ τ : Fin n → α, F (Fin.cons (α:=fun _=>α) a τ) := by + rw [←(Fin.consEquiv (fun _ : Fin (n+1) => α)).sum_comp F,Fintype.sum_prod_type] + rfl + +/-- A finite matrix path expansion, used only for the actual physical +column kernels below. All intermediate states are summed once. -/ +noncomputable def matrixPath {α : Type*} [Fintype α] [DecidableEq α] {n : ℕ} + (K : Fin n → Matrix α α ℂ) (a b : α) : ℂ := + ∑ τ : Fin n → α, if (Fin.cons (α:=fun _=>α) a τ) (Fin.last n)=b then + ∏ j : Fin n, K j ((Fin.cons (α:=fun _=>α) a τ) j.castSucc) (τ j) else 0 + +lemma matrixPath_zero {α : Type*} [Fintype α] [DecidableEq α] + (K : Fin 0 → Matrix α α ℂ) (a b : α) : + matrixPath K a b = if a=b then 1 else 0 := by + simp [matrixPath] + +lemma matrixPath_succ {α : Type*} [Fintype α] [DecidableEq α] {n : ℕ} + (K : Fin (n+1) → Matrix α α ℂ) (a b : α) : + matrixPath K a b = ∑ c, K 0 a c * matrixPath (fun j => K j.succ) c b := by + unfold matrixPath + rw [sum_vectors_cons] + apply Finset.sum_congr rfl + intro c hc + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro τ hτ + have hl : (Fin.cons (α:=fun _=>α) a (Fin.cons (α:=fun _=>α) c τ)) (Fin.last (n+1)) = + (Fin.cons (α:=fun _=>α) c τ) (Fin.last n) := rfl + rw [hl] + split_ifs with hb + · rw [Fin.prod_univ_succ] + congr 1 + · simp + +theorem matrixPath_eq_prod {α : Type*} [Fintype α] [DecidableEq α] {n : ℕ} + (K : Fin n → Matrix α α ℂ) (a b : α) : + matrixPath K a b = (List.ofFn K).prod a b := by + induction n generalizing a b with + | zero => simp [matrixPath_zero,Matrix.one_apply] + | succ n ih => + rw [matrixPath_succ,List.ofFn_succ,List.prod_cons,Matrix.mul_apply] + apply Finset.sum_congr rfl + intro c hc + rw [ih] + +abbrev Column (H : ℕ) := Fin H → Fin 3 + +noncomputable def columnProduct {H : ℕ} (west east vertical : Column H) (north : Fin 3) : ℂ := + ∏ j : Fin H, Planar.sourceR (kappa:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) (kappa^2:ℂ) 0 + ((Fin.snoc (α:=fun _=>Fin 3) vertical north) j.succ,west j) (vertical j,east j) + +noncomputable def columnKernel (H : ℕ) (south north : Fin 3) : Matrix (Column H) (Column H) ℂ := + fun west east => ∑ vertical : Column H, + if (Fin.snoc (α:=fun _=>Fin 3) vertical north) 0=south then + columnProduct west east vertical north else 0 + +/-- Literal grid spins after fixing the west and north outer boundaries. +The remaining horizontal and vertical wires are genuine independent +coordinates, not redundant copies at the centers. -/ +def spinsFromColumns {W H : ℕ} (west : Column H) (north : Fin W → Fin 3) + (horizontal : Fin W → Column H) (vertical : Fin W → Column H) : GridWire W H → Fin 3 + | .inl (i,j) => (Fin.cons (α:=fun _=>Column H) west horizontal) i j + | .inr (i,j) => (Fin.snoc (α:=fun _=>Fin 3) (vertical i) (north i)) j + +lemma physical_columns {W H : ℕ} (west : Column H) (north : Fin W → Fin 3) + (horizontal vertical : Fin W → Column H) : + (network W H).physical (spinsFromColumns west north horizontal vertical) = + ∏ i : Fin W, columnProduct ((Fin.cons (α:=fun _=>Column H) west horizontal) i.castSucc) + (horizontal i) (vertical i) (north i) := by + unfold TileNetwork.physical columnProduct + rw [Fintype.prod_prod_type] + apply Finset.prod_congr rfl + intro i hi + apply Finset.prod_congr rfl + intro j hj + simp [network,spinsFromColumns] + +/-- Actual finite grid tensor with all four boundary spin lists prescribed. +West and north are built into the parametrization; east and south are +imposed by their exact indicator, before performing any orientation sum. -/ +noncomputable def prescribedPartition (W H : ℕ) (west east : Column H) + (south north : Fin W → Fin 3) : ℂ := + ∑ horizontal : Fin W → Column H, ∑ vertical : Fin W → Column H, + if (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W)=east ∧ + (∀ i, (Fin.snoc (α:=fun _=>Fin 3) (vertical i) (north i)) 0=south i) then + (network W H).physical (spinsFromColumns west north horizontal vertical) else 0 + +lemma prescribedPartition_eq_matrixPath (W H : ℕ) (west east : Column H) + (south north : Fin W → Fin 3) : + prescribedPartition W H west east south north = + matrixPath (fun i => columnKernel H (south i) (north i)) west east := by + classical + unfold prescribedPartition matrixPath + apply Finset.sum_congr rfl + intro horizontal hhorizontal + by_cases he : (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W)=east + · simp only [he,true_and,ite_true] + simp_rw [physical_columns] + unfold columnKernel + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro vertical hvertical + rw [Fintype.prod_ite_zero] + split_ifs <;> rfl + · simp [he] + +/-- The exact full finite rectangle contraction is the product of its +physical column matrices. Together with `grid_physical_eq_centers` this +connects the transfer ordering to the literal center tensors. -/ +theorem prescribedPartition_eq_transfer (W H : ℕ) (west east : Column H) + (south north : Fin W → Fin 3) : + prescribedPartition W H west east south north = + (List.ofFn (fun i => columnKernel H (south i) (north i))).prod west east := by + rw [prescribedPartition_eq_matrixPath,matrixPath_eq_prod] + +/-- The parametrization has exactly the actual spin assignments with the +west/north walls fixed; no geometric configurations are dropped. -/ +def HasWestNorth {W H : ℕ} (west : Column H) (north : Fin W → Fin 3) + (σ : GridWire W H → Fin 3) : Prop := + (∀ j, σ (.inl (0,j))=west j) ∧ (∀ i, σ (.inr (i,Fin.last H))=north i) + +lemma spinsFromColumns_boundary {W H : ℕ} (west : Column H) (north : Fin W → Fin 3) + (horizontal vertical : Fin W → Column H) : + HasWestNorth west north (spinsFromColumns west north horizontal vertical) := by + constructor <;> intro i <;> simp [spinsFromColumns] + +def gridSpinsEquiv {W H : ℕ} (west : Column H) (north : Fin W → Fin 3) : + ((Fin W → Column H) × (Fin W → Column H)) ≃ + {σ : GridWire W H → Fin 3 // HasWestNorth west north σ} where + toFun p := ⟨spinsFromColumns west north p.1 p.2, + spinsFromColumns_boundary west north p.1 p.2⟩ + invFun σ := (fun i j => σ.val (.inl (i.succ,j)), + fun i j => σ.val (.inr (i,j.castSucc))) + left_inv p := by + rcases p with ⟨horizontal,vertical⟩ + ext i j <;> simp [spinsFromColumns] + right_inv σ := by + apply Subtype.ext + funext wire + cases wire with + | inl p => + rcases p with ⟨i,j⟩ + cases i using Fin.cases with + | zero => simpa [spinsFromColumns] using (σ.property.1 j).symm + | succ i => simp [spinsFromColumns] + | inr p => + rcases p with ⟨i,j⟩ + cases j using Fin.lastCases with + | last => simpa [spinsFromColumns] using (σ.property.2 i).symm + | cast j => simp [spinsFromColumns] + +noncomputable instance fixedGridSpinsFintype {W H : ℕ} (west : Column H) (north : Fin W → Fin 3) : + Fintype {σ : GridWire W H → Fin 3 // HasWestNorth west north σ} := + Fintype.ofEquiv ((Fin W → Column H) × (Fin W → Column H)) (gridSpinsEquiv west north) + +/-- Exact literal finite-network expression for the prescribed partition. -/ +theorem prescribedPartition_eq_grid_sum (W H : ℕ) (west east : Column H) + (south north : Fin W → Fin 3) : + prescribedPartition W H west east south north = + ∑ σ : {σ : GridWire W H → Fin 3 // HasWestNorth west north σ}, + if (∀ j, σ.val (.inl (Fin.last W,j))=east j) ∧ + (∀ i, σ.val (.inr (i,0))=south i) then + (network W H).physical σ.val else 0 := by + classical + rw [←(gridSpinsEquiv west north).sum_comp] + rw [Fintype.sum_prod_type] + unfold prescribedPartition + apply Finset.sum_congr rfl + intro horizontal hh + apply Finset.sum_congr rfl + intro vertical hv + change (if (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W)=east ∧ + (∀ i, (Fin.snoc (α:=fun _=>Fin 3) (vertical i) (north i)) 0=south i) then + (network W H).physical (spinsFromColumns west north horizontal vertical) else 0) = + (if (∀ j, (Fin.cons (α:=fun _=>Column H) west horizontal) (Fin.last W) j=east j) ∧ + (∀ i, (Fin.snoc (α:=fun _=>Fin 3) (vertical i) (north i)) 0=south i) then + (network W H).physical (spinsFromColumns west north horizontal vertical) else 0) + congr 1 + exact propext (and_congr funext_iff Iff.rfl) + +end CriticalHoneycomb.Transfer.RasterGrid + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Reflection.lean b/lean/OAI/Combinatorics/HoneycombChords/Reflection.lean new file mode 100644 index 0000000000000000000000000000000000000000..98300fc0dda60dd12ea5f17a96134010320ab8e9 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Reflection.lean @@ -0,0 +1,733 @@ +import OAI.Combinatorics.HoneycombChords.ClosedRows +import OAI.Combinatorics.HoneycombChords.BoundarySystems +import OAI.Combinatorics.HoneycombChords.BulkFusionEquation + +namespace OAI + +/-! Reflection equations, boundary fusion and bulk fusion. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.Reflection +noncomputable def root : ℂ := Complex.exp (((Real.pi/16:ℝ):ℂ)*Complex.I) +noncomputable def point (t : ℝ) : ℂ := Complex.exp ((t:ℂ)*Complex.I) +lemma root_ne_zero : root≠0 := Complex.exp_ne_zero _ +lemma point_ne_zero (t : ℝ) : point t≠0 := Complex.exp_ne_zero _ +lemma point_add (t u : ℝ) : point (t+u)=point t*point u := by + simp [point,Complex.ofReal_add,add_mul,Complex.exp_add] +lemma point_sub (t u : ℝ) : point (t-u)=point t/point u := by + simp [point,Complex.ofReal_sub,sub_mul,Complex.exp_sub] +lemma root_pow (n : ℕ) : root^n=point ((n:ℝ)*(Real.pi/16)) := by + unfold root point + rw [←Complex.exp_nat_mul] + congr 1 + push_cast + ring +lemma root_sixteen : root^16=-1 := by + rw [root_pow] + norm_num [point,show (16:ℝ)*(Real.pi/16)=Real.pi by ring,Complex.exp_pi_mul_I] +lemma root_constraint : root^16+1=0 := by rw [root_sixteen];ring +lemma point_nat_angle (n : ℕ) : point ((n:ℝ)*(Real.pi/16))=root^n := (root_pow n).symm +lemma root_eight : root^8=Complex.I := by + rw [root_pow] + convert Complex.exp_pi_div_two_mul_I using 1 ; unfold point ; congr 1 ; push_cast ; ring +lemma root_complement (n : ℕ) (hn : n≤16) : root^n*(-root^(16-n))=1 := by + rw [mul_neg,←pow_add,Nat.add_sub_of_le hn,root_sixteen] + ring +lemma point_neg_angle (n : ℕ) (hn : n≤16) : point (-((n:ℝ)*(Real.pi/16)))=-root^(16-n) := by + apply (mul_left_cancel₀ (pow_ne_zero n root_ne_zero)) + rw [←point_nat_angle,←point_add,add_neg_cancel] + rw [point_nat_angle,root_complement n hn] + simp [point] +lemma sine_exp (t : ℝ) : 2*Complex.I*(Real.sin t:ℂ)=point t-point (-t) := by + have hh:=Complex.two_sin (t:ℂ) + rw [←Complex.ofReal_sin] at hh + have hI : Complex.I^2+1=0 := by simp + simp only [point,Complex.ofReal_neg] at * + linear_combination Complex.I*hh + (Complex.exp (-(t:ℂ)*Complex.I)-Complex.exp ((t:ℂ)*Complex.I))*hI +lemma sine_positive_shift (n : ℕ) (hn : n≤16) (t : ℝ) : + (2*Complex.I*point t)*(Real.sin ((n:ℝ)*(Real.pi/16)+t):ℂ)= + root^n*(point t)^2+root^(16-n) := by + calc + _=point t*(point ((n:ℝ)*(Real.pi/16)+t)-point (-((n:ℝ)*(Real.pi/16)+t))) := by + rw [←sine_exp];ring + _=root^n*(point t)^2+root^(16-n) := by + rw [neg_add,point_add,point_add,point_nat_angle,point_neg_angle n hn] + have hp : point t*point (-t)=1 := by rw [←point_add,add_neg_cancel];simp [point] + linear_combination root^(16-n)*hp +lemma sine_negative_shift (n : ℕ) (hn : n≤16) (t : ℝ) : + (2*Complex.I*point t)*(Real.sin ((n:ℝ)*(Real.pi/16)-t):ℂ)= + root^n+root^(16-n)*(point t)^2 := by + calc + _=point t*(point ((n:ℝ)*(Real.pi/16)-t)-point (-((n:ℝ)*(Real.pi/16)-t))) := by + rw [←sine_exp];ring + _=root^n+root^(16-n)*(point t)^2 := by + simp only [sub_eq_add_neg,neg_add,neg_neg,point_add,point_nat_angle,point_neg_angle n hn] + have hp : point t*point (-t)=1 := by rw [←point_add,add_neg_cancel];simp [point] + linear_combination root^n*hp +lemma sine_zero_shift (t : ℝ) : + (2*Complex.I*point t)*(Real.sin t:ℂ)=(point t)^2-1 := by + have hh:=sine_positive_shift 0 (by omega) t + simpa [root_sixteen,sub_eq_add_neg] using hh +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +noncomputable def sine (t : ℝ) : ℂ := (Real.sin t:ℂ) +noncomputable def tau (t : ℝ) : ℂ := 2*Complex.I*point t +noncomputable def S : ℂ := sine (Real.pi/4) +noncomputable def gamma : ℝ := 3*Real.pi/16 +noncomputable def b : ℝ := 3*Real.pi/8 +noncomputable def L : ℝ := Real.pi/8 +noncomputable def phase : ℂ := point (Real.pi/4) +noncomputable def Q (u : ℝ) : ℂ := sine (Real.pi/4+u)*sine (b+u) +noncomputable def coeffA (u : ℝ) : ℂ := S*sine (b-u) +noncomputable def coeffH (u : ℝ) : ℂ := S*sine u +noncomputable def coeffV (u : ℝ) : ℂ := sine (b-u)*sine u +noncomputable def coeffC (u : ℝ) : ℂ := sine (b-u)*sine (Real.pi/4-u) +noncomputable def coeffD (u : ℝ) : ℂ := sine u*sine (u-L) +noncomputable def bulkNumerator (u : ℝ) : Matrix Pair Pair ℂ := fun p q=> + match p.1.val,p.2.val,q.1.val,q.2.val with + | 0,0,0,0 => coeffC u + | 2,2,2,2 => coeffC u + | 0,1,0,1 => coeffV u + | 1,0,1,0 => coeffV u + | 2,1,2,1 => coeffV u + | 1,2,1,2 => coeffV u + | 0,1,1,0 => coeffA u + | 1,0,0,1 => coeffA u + | 2,1,1,2 => coeffA u + | 1,2,2,1 => coeffA u + | 0,2,0,2 => coeffD u + | 0,2,1,1 => coeffH u/phase + | 0,2,2,0 => coeffC u+coeffD u/phase^2 + | 1,1,0,2 => coeffH u*phase + | 1,1,1,1 => Q u + | 1,1,2,0 => coeffH u/phase + | 2,0,0,2 => coeffC u+coeffD u*phase^2 + | 2,0,1,1 => coeffH u*phase + | 2,0,2,0 => coeffD u + | _,_,_,_ => 0 + +noncomputable def spectralR (u : ℝ) : Matrix Pair Pair ℂ := (Q u)⁻¹ • bulkNumerator u +noncomputable def boundary0 (t : ℝ) : Matrix (Fin 3) (Fin 3) ℂ := fun p q=> + if p=q then if p=1 then 1 else sine (gamma-t)/sine (gamma+t) else 0 +noncomputable def boundary1 (t : ℝ) : Matrix (Fin 3) (Fin 3) ℂ := fun p q=> + if p=0 ∧ q=1 then sine (2*t)/sine (gamma+t) else + if p=1 ∧ q=2 then phase*(sine (2*t)/sine (gamma+t)) else 0 +lemma tau_ne_zero (t : ℝ) : tau t≠0 := by + exact mul_ne_zero (mul_ne_zero (by norm_num) Complex.I_ne_zero) (point_ne_zero t) +lemma phase_eq : phase=root^4 := by + convert point_nat_angle 4 using 1 ; unfold phase ; congr 1 ; ring +lemma phase_inv : phase⁻¹=-root^12 := by + apply (mul_left_cancel₀ (point_ne_zero (Real.pi/4))) + change phase*phase⁻¹=phase*(-root^12) + have hn : phase≠0 := point_ne_zero _ + rw [mul_inv_cancel₀ hn,phase_eq] + exact (root_complement 4 (by omega)).symm +lemma phase_inv_sq : (phase^2)⁻¹=-root^8 := by + rw [←inv_pow,phase_inv,neg_sq,←pow_mul] + have hh : root^24=root^16*root^8 := by rw [←pow_add] + rw [hh,root_sixteen];ring +lemma sin_b_minus (u : ℝ) : tau u*sine (b-u)=root^6+root^10*(point u)^2 := by + convert sine_negative_shift 6 (by omega) u using 1 ; unfold tau sine b ; congr 2 ; ring_nf +lemma sin_quarter_minus (u : ℝ) : tau u*sine (Real.pi/4-u)=root^4+root^12*(point u)^2 := by + convert sine_negative_shift 4 (by omega) u using 1 ; unfold tau sine ; congr 2 ; ring_nf +lemma sin_b_plus (u : ℝ) : tau u*sine (b+u)=root^6*(point u)^2+root^10 := by + convert sine_positive_shift 6 (by omega) u using 1 ; unfold tau sine b ; congr 2 ; ring_nf +lemma sin_quarter_plus (u : ℝ) : tau u*sine (Real.pi/4+u)=root^4*(point u)^2+root^12 := by + convert sine_positive_shift 4 (by omega) u using 1 ; unfold tau sine ; congr 2 ; ring_nf +lemma sin_minus_L (u : ℝ) : tau u*sine (u-L)=-root^2-root^14*(point u)^2 := by + have hh:=sine_negative_shift 2 (by omega) u + have he : u-L=-(2*(Real.pi/16)-u) := by unfold L;ring + rw [he]; simp only [sine,Real.sin_neg,Complex.ofReal_neg,mul_neg] + rw [show 2*(Real.pi/16)=((2:ℕ):ℝ)*(Real.pi/16) by norm_num] + change -(tau u*sine (((2:ℕ):ℝ)*(Real.pi/16)-u))=_ + change tau u*sine (((2:ℕ):ℝ)*(Real.pi/16)-u)=_ at hh + rw [hh];ring +lemma sin_zero (u : ℝ) : tau u*sine u=(point u)^2-1 := sine_zero_shift u +lemma sin_S (u : ℝ) : tau u*S=(root^4+root^12)*point u := by + have hh:=sine_positive_shift 4 (by omega) 0 + have h0 : point 0=1 := by simp [point] + rw [h0] at hh + have ht : tau u=(2*Complex.I)*point u := rfl + change tau u*sine (Real.pi/4)=_ + have hs : 2*Complex.I*sine (Real.pi/4)=root^4+root^12 := by + simpa only [sine,Nat.cast_ofNat,show (4:ℝ)*(Real.pi/16)+0=Real.pi/4 by ring, + one_pow,mul_one,Nat.reduceSub] using hh + rw [ht,mul_assoc,mul_comm (point u),←mul_assoc,hs] +lemma coeffA_scaled (u : ℝ) : (tau u)^2*coeffA u=(root^4+root^12)*(point u)*(root^6+root^10*(point u)^2) := by + rw [coeffA,show (tau u)^2*(S*sine (b-u))=(tau u*S)*(tau u*sine (b-u)) by ring,sin_S,sin_b_minus] +lemma coeffH_scaled (u : ℝ) : (tau u)^2*coeffH u=(root^4+root^12)*(point u)*((point u)^2-1) := by + rw [coeffH,show (tau u)^2*(S*sine u)=(tau u*S)*(tau u*sine u) by ring,sin_S,sin_zero] +lemma coeffV_scaled (u : ℝ) : (tau u)^2*coeffV u=(root^6+root^10*(point u)^2)*((point u)^2-1) := by + rw [coeffV,show (tau u)^2*(sine (b-u)*sine u)=(tau u*sine (b-u))*(tau u*sine u) by ring,sin_b_minus,sin_zero] +lemma coeffC_scaled (u : ℝ) : (tau u)^2*coeffC u=(root^6+root^10*(point u)^2)*(root^4+root^12*(point u)^2) := by + rw [coeffC,show (tau u)^2*(sine (b-u)*sine (Real.pi/4-u))=(tau u*sine (b-u))*(tau u*sine (Real.pi/4-u)) by ring,sin_b_minus,sin_quarter_minus] +lemma coeffD_scaled (u : ℝ) : (tau u)^2*coeffD u=((point u)^2-1)*(-root^2-root^14*(point u)^2) := by + rw [coeffD,show (tau u)^2*(sine u*sine (u-L))=(tau u*sine u)*(tau u*sine (u-L)) by ring,sin_zero,sin_minus_L] +lemma Q_scaled (u : ℝ) : (tau u)^2*Q u=(root^4*(point u)^2+root^12)*(root^6*(point u)^2+root^10) := by + rw [Q,show (tau u)^2*(sine (Real.pi/4+u)*sine (b+u))=(tau u*sine (Real.pi/4+u))*(tau u*sine (b+u)) by ring,sin_quarter_plus,sin_b_plus] +lemma bulk_scaled (u : ℝ) : (tau u)^2 • bulkNumerator u=rNumerator root (point u) 1 := by + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d <;> + simp only [Matrix.smul_apply,smul_eq_mul,bulkNumerator,rNumerator,one_pow,mul_one,div_eq_mul_inv] + all_goals try simp only [phase_inv,phase_inv_sq] + all_goals try simp only [phase_eq,mul_add,←mul_assoc, + coeffA_scaled,coeffH_scaled,coeffV_scaled,coeffC_scaled,coeffD_scaled,Q_scaled] + all_goals ring +lemma r_homogeneous (r z w v : ℂ) : rNumerator r (z*v) (w*v)=v^4 • rNumerator r z w := by + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d <;> + simp only [Matrix.smul_apply,smul_eq_mul,rNumerator] <;> ring +lemma spectralR_scaled (u : ℝ) (hQ : Q u≠0) : + ((tau u)^2*Q u) • spectralR u=rNumerator root (point u) 1 := by + rw [spectralR,smul_smul,mul_assoc,mul_inv_cancel₀ hQ,mul_one,bulk_scaled] + +lemma sin_gamma_minus (t : ℝ) : tau t*sine (gamma-t)=root^3+root^13*(point t)^2 := by + convert sine_negative_shift 3 (by omega) t using 1 ; unfold tau sine gamma ; congr 2 ; ring_nf +lemma sin_gamma_plus (t : ℝ) : tau t*sine (gamma+t)=root^3*(point t)^2+root^13 := by + convert sine_positive_shift 3 (by omega) t using 1 ; unfold tau sine gamma ; congr 2 ; ring_nf +noncomputable def beta (t : ℝ) : ℂ := point t*tau t*sine (gamma+t) +lemma beta_ne_zero (t : ℝ) (ht : sine (gamma+t)≠0) : beta t≠0 := + mul_ne_zero (mul_ne_zero (point_ne_zero t) (tau_ne_zero t)) ht +lemma beta_polynomial (t : ℝ) : beta t=point t*(root^3*(point t)^2+root^13) := by + rw [beta,mul_assoc,sin_gamma_plus] +lemma beta_k (t : ℝ) (ht : sine (gamma+t)≠0) : + beta t*(sine (gamma-t)/sine (gamma+t))=point t*(root^3+root^13*(point t)^2) := by + calc + _=point t*(tau t*sine (gamma-t)) := by unfold beta;field_simp [ht] + _=_ := by rw [sin_gamma_minus] +lemma point_twice (t : ℝ) : point (2*t)=(point t)^2 := by + rw [two_mul,point_add,pow_two] +lemma beta_l (t : ℝ) (ht : sine (gamma+t)≠0) : + beta t*(sine (2*t)/sine (gamma+t))=(point t)^4-1 := by + calc + _=tau (2*t)*sine (2*t) := by unfold beta tau;rw [point_twice];field_simp [ht] + _=_ := by rw [sin_zero,point_twice];ring +lemma boundary0_scaled (t : ℝ) (ht : sine (gamma+t)≠0) : + beta t • boundary0 t=dConstant root (point t) := by + ext p q + fin_cases p <;> fin_cases q <;> + simp [Matrix.smul_apply,smul_eq_mul,boundary0,dConstant,beta_k t ht] + all_goals exact beta_polynomial t +lemma boundary1_scaled (t : ℝ) (ht : sine (gamma+t)≠0) : + beta t • boundary1 t=dLinear root (point t) := by + ext p q + fin_cases p <;> fin_cases q <;> + simp [Matrix.smul_apply,smul_eq_mul,boundary1,dLinear,phase_eq, + show beta t*(root^4*(sine (2*t)/sine (gamma+t)))= + root^4*(beta t*(sine (2*t)/sine (gamma+t))) by ring,beta_l t ht] +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix +noncomputable def alphaMinus (t y : ℝ) : ℂ := (point y)^4*((tau (t-y))^2*Q (t-y)) +noncomputable def alphaPlus (t y : ℝ) : ℂ := (tau (t+y))^2*Q (t+y) +lemma alphaMinus_ne_zero (t y : ℝ) (h : Q (t-y)≠0) : alphaMinus t y≠0 := + mul_ne_zero (pow_ne_zero 4 (point_ne_zero y)) (mul_ne_zero (pow_ne_zero 2 (tau_ne_zero _)) h) +lemma alphaPlus_ne_zero (t y : ℝ) (h : Q (t+y)≠0) : alphaPlus t y≠0 := + mul_ne_zero (pow_ne_zero 2 (tau_ne_zero _)) h +lemma rminus_scaled (t y : ℝ) (h : Q (t-y)≠0) : + alphaMinus t y • spectralR (t-y)=rNumerator root (point t) (point y) := by + rw [alphaMinus,mul_smul,spectralR_scaled _ h] + have hh:=r_homogeneous root (point (t-y)) 1 (point y) + rw [one_mul,←point_add,sub_add_cancel] at hh + exact hh.symm +lemma rplus_scaled (t y : ℝ) (h : Q (t+y)≠0) : + alphaPlus t y • spectralR (t+y)=rNumerator root (point t*point y) 1 := by + simpa only [alphaPlus,point_add] using spectralR_scaled (t+y) h +lemma slot1_smul (c : ℂ) (M : Matrix (Fin 3) (Fin 3) ℂ) : slot1 (c•M)=c•slot1 M := by + ext p q + by_cases h : p.2=q.2 <;> simp [slot1,h] +lemma slot2_smul (c : ℂ) (M : Matrix (Fin 3) (Fin 3) ℂ) : slot2 (c•M)=c•slot2 M := by + ext p q + by_cases h : p.1=q.1 <;> simp [slot2,h] +lemma scale_four (a b c d : ℂ) (A B C D : Matrix Pair Pair ℂ) : + (a•A)*(b•B)*(c•C)*(d•D)=(a*b*c*d)•(A*B*C*D) := by + simp only [Matrix.smul_mul,Matrix.mul_smul,smul_smul,mul_assoc] + congr 1 + ring +lemma scalar_cancel {A B : Matrix Pair Pair ℂ} (c : ℂ) (hc : c≠0) (h : c•A=c•B) : A=B := by + ext p q + have hh:=congrFun (congrFun h p) q + exact mul_left_cancel₀ hc hh + +theorem source_reflection_constant (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + spectralR (t-y)*slot1 (boundary0 t)*(spectralR (t+y))ᵀ*slot2 (boundary0 y)= + slot2 (boundary0 y)*spectralR (t+y)*slot1 (boundary0 t)*(spectralR (t-y))ᵀ := by + have hh:=reflection_constant root (point t) (point y) root_constraint + unfold reflectionLeft0 reflectionRight0 at hh + rw [←rminus_scaled t y hm,←rplus_scaled t y hp, + ←boundary0_scaled t ht,←boundary0_scaled y hy,slot1_smul,slot2_smul] at hh + simp only [Matrix.transpose_smul,←Matrix.mul_assoc,scale_four] at hh + have he : beta y*alphaPlus t y*beta t*alphaMinus t y= + alphaMinus t y*beta t*alphaPlus t y*beta y := by ring + rw [he] at hh + exact scalar_cancel _ (mul_ne_zero (mul_ne_zero + (mul_ne_zero (alphaMinus_ne_zero t y hm) (beta_ne_zero t ht)) + (alphaPlus_ne_zero t y hp)) (beta_ne_zero y hy)) hh + +theorem source_reflection_linear (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + spectralR (t-y)*slot1 (boundary1 t)*(spectralR (t+y))ᵀ*slot2 (boundary0 y)+ + spectralR (t-y)*slot1 (boundary0 t)*(spectralR (t+y))ᵀ*slot2 (boundary1 y)= + slot2 (boundary0 y)*spectralR (t+y)*slot1 (boundary1 t)*(spectralR (t-y))ᵀ+ + slot2 (boundary1 y)*spectralR (t+y)*slot1 (boundary0 t)*(spectralR (t-y))ᵀ := by + have hh:=reflection_linear root (point t) (point y) root_constraint + unfold reflectionLeft1 reflectionRight1 at hh + rw [←rminus_scaled t y hm,←rplus_scaled t y hp, + ←boundary0_scaled t ht,←boundary0_scaled y hy, + ←boundary1_scaled t ht,←boundary1_scaled y hy] at hh + simp only [slot1_smul,slot2_smul,Matrix.transpose_smul,←Matrix.mul_assoc,scale_four] at hh + have he : beta y*alphaPlus t y*beta t*alphaMinus t y= + alphaMinus t y*beta t*alphaPlus t y*beta y := by ring + rw [he,←smul_add,←smul_add] at hh + exact scalar_cancel _ (mul_ne_zero (mul_ne_zero + (mul_ne_zero (alphaMinus_ne_zero t y hm) (beta_ne_zero t ht)) + (alphaPlus_ne_zero t y hp)) (beta_ne_zero y hy)) hh +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +lemma swap_constant_algebra (r z w : ℂ) (hr : r^16+1=0) (hzw : z*w-r^6=0) : + (w*(r^3*w^2+r^13))* (((r^6*w^2+r^10*z^2)*(r^4*w^2+r^12*z^2))*(z*(r^3+r^13*z^2)) + ((r^4+r^12)*z*w*(z^2-w^2))*(z*(r^3*z^2+r^13))) = ((r^4*z^2+r^12*w^2)*(r^6*z^2+r^10*w^2))*(z*(r^3*z^2+r^13))*(w*(r^3+r^13*w^2)) := by + linear_combination (z^7*w^3*r^22 - 1*z^7*w^3*r^10 - 1*z^7*w^3*r^6 + z^7*w*r^32 - 1*z^7*w*r^16 + z^6*w^4*r^2 + z^6*w^2*r^12 + z^6*w^2*r^4 + z^6*w^2 + z^5*w^3*r^28 + z^5*w^3*r^24 - 1*z^5*w^3*r^20 - 2*z^5*w^3*r^8 + z^5*w^3 + z^5*w*r^22 - 1*z^5*w*r^10 - 1*z^5*w*r^6 - 1*z^4*w^6*r^2 + z^4*w^2*r^22 + z^4*w^2*r^14 - 1*z^4*w^2*r^6 - 1*z^3*w^7*r^22 + z^3*w^7*r^10 + z^3*w^7*r^6 - 1*z^3*w^5*r^28 - 1*z^3*w^5*r^24 + z^3*w^5*r^20 + 2*z^3*w^5*r^8 - 1*z^3*w^5 - 1*z^2*w^6*r^12 - 1*z^2*w^6*r^4 - 1*z^2*w^6 - 1*z^2*w^4*r^22 - 1*z^2*w^4*r^14 + z^2*w^4*r^6 - 1*z*w^7*r^32 + z*w^7*r^16 - 1*z*w^5*r^22 + z*w^5*r^10 + z*w^5*r^6)*hr + (z^6*w^2*r^10 + z^6*w^2*r^6 + z^5*w^3*r^10 - 1*z^5*w^3*r^2 - 1*z^5*w*r^4 - 1*z^5*w + z^4*w^2*r^8 - 1*z^4*w^2 - 1*z^3*w^5*r^10 + z^3*w^5*r^2 - 1*z^2*w^6*r^10 - 1*z^2*w^6*r^6 - 1*z^2*w^4*r^8 + z^2*w^4 + z*w^5*r^4 + z*w^5)*hzw +lemma swap_linear_algebra (r z w : ℂ) (hr : r^16+1=0) (hzw : z*w-r^6=0) : + (w*(r^3*w^2+r^13))*(((r^6*w^2+r^10*z^2)*(z^2-w^2)) + ((r^4+r^12)*z*w*(r^6*w^2+r^10*z^2)))*(z^4-1) = ((r^4*z^2+r^12*w^2)*(r^6*z^2+r^10*w^2))*(z*(r^3*z^2+r^13))*(w^4-1) := by + linear_combination (z^8*w*r^7 + z^7*w^4*r^9 + z^7*w^4*r + z^7*w^2*r^19 + z^7*w^2*r^11 - 1*z^6*w^3*r^7 - 1*z^6*w*r - 1*z^5*w^6*r + z^5*w^4*r^15 - 1*z^5*w^4*r^3 + z^5*w^2*r + z^5*r^7 - 1*z^4*w*r^7 - 1*z^3*w^8*r^9 - 1*z^3*w^6*r^15 - 1*z^3*w^6*r^11 - 1*z^3*w^4*r - 1*z^3*w^2*r^19 + z^3*w^2*r^15 + z^2*w^5*r + z^2*w^3*r^7 - 1*z*w^8*r^19 + z*w^8*r^3 + z*w^4*r^19 - 1*z*w^4*r^15 - 1*z*w^4*r^7)*hr + (z^7*w^2*r^13 - 1*z^7*r^7 - 1*z^6*w^3*r^13 - 1*z^6*w^3*r^9 - 1*z^6*w^3*r - 1*z^6*w*r^11 - 1*z^5*w^4*r^13 + z^5*w^4*r^9 - 1*z^5*w^2*r^15 + z^5*r + z^4*w^5*r^13 + z^4*w^5*r + z^4*w^3*r^3 - 1*z^4*w*r - 1*z^3*w^6*r^9 + z^3*w^4*r^7 - 1*z^3*w^2*r^13 + z^3*w^2*r^9 + z^2*w^7*r^9 + z^2*w^5*r^11 + z^2*w^3*r^13 + z^2*w^3*r + z*w^6*r^15 + z*w^4*r^13 - 1*z*w^4*r^9 - 1*z*w^4*r - 1*w^7*r^3 - 1*w^5*r^13)*hzw +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix +noncomputable def twoCos : ℂ := 2*(Real.cos L:ℂ) +noncomputable def sourceKappa : ℂ := twoCos⁻¹ +noncomputable def sourceW : Matrix Pair (Fin 3) ℂ := fun p j=> + match p.1.val,p.2.val,j.val with + | 0,1,0 => sourceKappa + | 1,0,0 => sourceKappa + | 2,1,2 => sourceKappa + | 1,2,2 => sourceKappa + | 1,1,1 => 1 + | 0,2,1 => sourceKappa/phase + | 2,0,1 => sourceKappa*phase + | _,_,_ => 0 +noncomputable def sourceWbar : Matrix Pair (Fin 3) ℂ := fun p j=> + match p.1.val,p.2.val,j.val with + | 0,1,0 => sourceKappa + | 1,0,0 => sourceKappa + | 2,1,2 => sourceKappa + | 1,2,2 => sourceKappa + | 1,1,1 => 1 + | 0,2,1 => sourceKappa*phase + | 2,0,1 => sourceKappa/phase + | _,_,_ => 0 +lemma point_L : point L=root^2 := by + convert point_nat_angle 2 using 1 ; unfold L ; congr 1 ; ring +lemma point_neg_L : point (-L)=-root^14 := by + convert point_neg_angle 2 (by omega) using 1 ; unfold L ; congr 1 ; ring +lemma point_add_L (t : ℝ) : point (t+L)=point t*root^2 := by rw [point_add,point_L] +lemma point_sub_L (t : ℝ) : point (t-L)=-point t*root^14 := by + rw [sub_eq_add_neg,point_add,point_neg_L];ring +lemma twoCos_polynomial : twoCos=root^2-root^14 := by + have hh:=Complex.two_cos (L:ℂ) + rw [←Complex.ofReal_cos] at hh + simpa only [twoCos,point,Complex.ofReal_neg,neg_mul] using hh.trans + (show Complex.exp ((L:ℂ)*Complex.I)+Complex.exp (-(L:ℂ)*Complex.I)=root^2-root^14 by + have hz : point L+point (-L)=root^2-root^14 := by rw [point_L,point_neg_L];ring + simpa only [point,Complex.ofReal_neg,neg_mul] using hz) +lemma twoCos_ne_zero : twoCos≠0 := by + have hp : 0 fin_cases b <;> fin_cases j <;> + simp [Matrix.smul_apply,smul_eq_mul,sourceW,wNum,div_eq_mul_inv, + ←mul_assoc,kappa_normalization,phase_inv] + all_goals simp only [phase_eq,twoCos_polynomial] +lemma sourceWbar_scaled : twoCos • sourceWbar=wBarNum root := by + ext ⟨a,b⟩ j + fin_cases a <;> fin_cases b <;> fin_cases j <;> + simp [Matrix.smul_apply,smul_eq_mul,sourceWbar,wBarNum,div_eq_mul_inv, + ←mul_assoc,kappa_normalization,phase_inv] + all_goals simp only [phase_eq,twoCos_polynomial] +lemma star_point (t : ℝ) : star (point t)=point (-t) := by + simp only [point,Complex.star_def,←Complex.exp_conj,map_mul, + Complex.conj_ofReal,Complex.conj_I,Complex.ofReal_neg] + congr 1 + ring +lemma phase_star : star phase=phase⁻¹ := by + rw [phase_inv] + unfold phase + rw [star_point] + convert point_neg_angle 4 (by omega) using 1 ; congr 1 ; ring +lemma sourceKappa_star : star sourceKappa=sourceKappa := by + simp only [sourceKappa,twoCos,Complex.star_def,map_inv₀,map_mul,map_ofNat,Complex.conj_ofReal] +lemma sourceWbar_eq_conj (p : Pair) (j : Fin 3) : sourceWbar p j=star (sourceW p j) := by + rcases p with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> fin_cases j <;> + simp [sourceWbar,sourceW,sourceKappa_star,phase_star,div_eq_mul_inv] +lemma bNum_binding (t : ℝ) : bNum root (point t)=beta t := (beta_polynomial t).symm +lemma aNum_binding (t : ℝ) : aNum root (point t)=(tau (2*t))^2*Q (2*t) := by + rw [Q_scaled,point_twice] + unfold aNum + ring +lemma bNum_plus_binding (t : ℝ) : bNum root (point t*root^2)=beta (t+L) := by rw [←point_add_L,bNum_binding] +lemma bNum_minus_binding (t : ℝ) : bNum root (-point t*root^14)=beta (t-L) := by rw [←point_sub_L,bNum_binding] +lemma constant_plus_binding (t : ℝ) (ht : sine (gamma+(t+L))≠0) : + dConstant root (point t*root^2)=beta (t+L) • boundary0 (t+L) := by + rw [←point_add_L,←boundary0_scaled _ ht] +lemma constant_minus_binding (t : ℝ) (ht : sine (gamma+(t-L))≠0) : + dConstant root (-point t*root^14)=beta (t-L) • boundary0 (t-L) := by + rw [←point_sub_L,←boundary0_scaled _ ht] +lemma linear_plus_binding (t : ℝ) (ht : sine (gamma+(t+L))≠0) : + dLinear root (point t*root^2)=beta (t+L) • boundary1 (t+L) := by + rw [←point_add_L,←boundary1_scaled _ ht] +lemma linear_minus_binding (t : ℝ) (ht : sine (gamma+(t-L))≠0) : + dLinear root (-point t*root^14)=beta (t-L) • boundary1 (t-L) := by + rw [←point_sub_L,←boundary1_scaled _ ht] +lemma bulk_twice_binding (t : ℝ) (hQ : Q (2*t)≠0) : + rNumerator root ((point t)^2) 1=((tau (2*t))^2*Q (2*t)) • spectralR (2*t) := by + rw [←point_twice,←spectralR_scaled _ hQ] +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix BigOperators + +lemma sourceKappa_eq_critical : sourceKappa = + (((2 + Real.sqrt 2) ^ (-(1:ℝ)/2) : ℝ) : ℂ) := by + unfold sourceKappa twoCos L + rw [Real.cos_pi_div_eight] + have hc : (2:ℂ)*((Real.sqrt (2+Real.sqrt 2)/2:ℝ):ℂ)= + (Real.sqrt (2+Real.sqrt 2):ℂ) := by push_cast;ring + rw [hc,←Complex.ofReal_inv] + congr 1 + rw [show -(1:ℝ)/2=-(1/2) by ring,Real.rpow_neg (by positivity),←Real.sqrt_eq_rpow] +noncomputable def fusionProduct (A B : Matrix Pair Pair ℂ) (W : Matrix Pair (Fin 3) ℂ) + (a b c j k : Fin 3) : ℂ := + ∑ u : Fin 3,∑ v : Fin 3,∑ m : Fin 3,A (b,c) (v,m)*B (a,m) (u,k)*W (u,v) j +noncomputable def fusionLift (W : Matrix Pair (Fin 3) ℂ) (A : Matrix Pair Pair ℂ) + (a b c j k : Fin 3) : ℂ := + ∑ f : Fin 3,W (a,b) f*A (f,c) (j,k) +lemma fusionProduct_smul (x y z : ℂ) (A B : Matrix Pair Pair ℂ) + (W : Matrix Pair (Fin 3) ℂ) (a b c j k : Fin 3) : + fusionProduct (x•A) (y•B) (z•W) a b c j k= + (x*y*z)*fusionProduct A B W a b c j k := by + simp only [fusionProduct,Matrix.smul_apply,smul_eq_mul,Finset.mul_sum] + apply Finset.sum_congr rfl;intro u hu + apply Finset.sum_congr rfl;intro v hv + apply Finset.sum_congr rfl;intro m hm + ring +lemma fusionLift_smul (x y : ℂ) (W : Matrix Pair (Fin 3) ℂ) + (A : Matrix Pair Pair ℂ) (a b c j k : Fin 3) : + fusionLift (x•W) (y•A) a b c j k=x*y*fusionLift W A a b c j k := by + simp only [fusionLift,Matrix.smul_apply,smul_eq_mul,Finset.mul_sum] + apply Finset.sum_congr rfl;intro u hu + ring +noncomputable def bulkScale (t : ℝ) : ℂ := (tau t)^2*Q t +lemma bulkScale_ne_zero (t : ℝ) (ht : Q t≠0) : bulkScale t≠0 := + mul_ne_zero (pow_ne_zero 2 (tau_ne_zero t)) ht +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix BigOperators +lemma qNumerator_binding (t : ℝ) : qNumerator root (point t)=bulkScale t := + (Q_scaled t).symm +lemma plusNumerator_binding (t : ℝ) (ht : Q (t+L)≠0) : + rNumerator root (point t*root^2) 1=bulkScale (t+L)•spectralR (t+L) := by + rw [←point_add_L] + exact (spectralR_scaled _ ht).symm +lemma minusNumerator_binding (t : ℝ) (ht : Q (t-L)≠0) : + rNumerator root (-point t*root^14) 1=bulkScale (t-L)•spectralR (t-L) := by + rw [←point_sub_L] + exact (spectralR_scaled _ ht).symm + +theorem source_bulk_fusion (t : ℝ) (hm : Q (t-L)≠0) (ht : Q t≠0) (hp : Q (t+L)≠0) + (a b c j k : Fin 3) : + fusionProduct (spectralR (t-L)) (spectralR (t+L)) sourceW a b c j k= + fusionLift sourceW (spectralR t) a b c j k := by + have hh:=bulk_fusion_numerator root (point t) root_constraint a b c j k + change qNumerator root (point t)*fusionProduct + (rNumerator root (-point t*root^14) 1) (rNumerator root (point t*root^2) 1) + (wNum root) a b c j k= + qNumerator root (point t*root^2)*qNumerator root (-point t*root^14)* + fusionLift (wNum root) (rNumerator root (point t) 1) a b c j k at hh + rw [qNumerator_binding,minusNumerator_binding t hm,plusNumerator_binding t hp, + ←sourceW_scaled,←spectralR_scaled t ht,←point_add_L,←point_sub_L, + qNumerator_binding,qNumerator_binding,fusionProduct_smul,fusionLift_smul] at hh + have hn : bulkScale t*bulkScale (t-L)*bulkScale (t+L)*twoCos≠0 := + mul_ne_zero (mul_ne_zero (mul_ne_zero (bulkScale_ne_zero t ht) + (bulkScale_ne_zero (t-L) hm)) (bulkScale_ne_zero (t+L) hp)) twoCos_ne_zero + apply mul_left_cancel₀ hn + dsimp only [bulkScale] at * + linear_combination hh +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix +noncomputable def fusionScalar (t : ℝ) : ℂ := + beta t*beta (t-L)*((tau (2*t))^2*Q (2*t))*beta (t+L)*twoCos +lemma fusionScalar_ne_zero (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + fusionScalar t≠0 := by + exact mul_ne_zero (mul_ne_zero (mul_ne_zero + (mul_ne_zero (beta_ne_zero t ht) (beta_ne_zero (t-L) hm)) + (mul_ne_zero (pow_ne_zero 2 (tau_ne_zero _)) hQ)) + (beta_ne_zero (t+L) hp)) twoCos_ne_zero +lemma scalar_cancel_rect {A B : Matrix Pair (Fin 3) ℂ} (c : ℂ) (hc : c≠0) + (hh : c•A=c•B) : A=B := by + funext p j + exact mul_left_cancel₀ hc (congrFun (congrFun hh p) j) + +theorem boundary_fusion_constant (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + slot2 (boundary0 (t-L))*spectralR (2*t)*slot1 (boundary0 (t+L))*sourceWbar= + sourceW*boundary0 t := by + have hh:=source_numerator0 root (point t) root_constraint + unfold fusionL0 fusionR0 at hh + rw [bNum_binding,aNum_binding,bNum_plus_binding,bNum_minus_binding, + constant_minus_binding t hm,constant_plus_binding t hp,bulk_twice_binding t hQ, + ←sourceWbar_scaled,←sourceW_scaled,←boundary0_scaled t ht] at hh + simp only [slot1_smul,slot2_smul,Matrix.smul_mul,Matrix.mul_smul,smul_smul, + ←Matrix.mul_assoc] at hh + have hscaled : fusionScalar t • + (slot2 (boundary0 (t-L))*spectralR (2*t)*slot1 (boundary0 (t+L))*sourceWbar)= + fusionScalar t • (sourceW*boundary0 t) := by + convert hh using 1 <;> congr 1 <;> unfold fusionScalar <;> ring + exact scalar_cancel_rect _ (fusionScalar_ne_zero t hQ ht hm hp) hscaled + +theorem boundary_fusion_linear (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + slot2 (boundary1 (t-L))*spectralR (2*t)*slot1 (boundary0 (t+L))*sourceWbar+ + slot2 (boundary0 (t-L))*spectralR (2*t)*slot1 (boundary1 (t+L))*sourceWbar= + sourceW*boundary1 t := by + have hh:=source_numerator1 root (point t) root_constraint + unfold fusionL1 fusionR1 at hh + rw [bNum_binding,aNum_binding,bNum_plus_binding,bNum_minus_binding, + constant_minus_binding t hm,constant_plus_binding t hp, + linear_minus_binding t hm,linear_plus_binding t hp,bulk_twice_binding t hQ, + ←sourceWbar_scaled,←sourceW_scaled,←boundary1_scaled t ht] at hh + simp only [slot1_smul,slot2_smul,Matrix.smul_mul,Matrix.mul_smul,smul_smul, + ←Matrix.mul_assoc] at hh + simp only [←smul_add,smul_smul] at hh + have hscaled : fusionScalar t • + (slot2 (boundary1 (t-L))*spectralR (2*t)*slot1 (boundary0 (t+L))*sourceWbar+ + slot2 (boundary0 (t-L))*spectralR (2*t)*slot1 (boundary1 (t+L))*sourceWbar)= + fusionScalar t • (sourceW*boundary1 t) := by + convert hh using 1 <;> congr 1 <;> try { unfold fusionScalar;ring } + exact scalar_cancel_rect _ (fusionScalar_ne_zero t hQ ht hm hp) hscaled +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix +noncomputable def mirror {m n : Type*} (f : m ≃ m) (g : n ≃ n) + (A : Matrix m n ℂ) : Matrix n m ℂ := A.conjTranspose.submatrix g f +lemma mirror_mul {m n p : Type*} [Fintype n] (f : m ≃ m) (g : n ≃ n) (h : p ≃ p) + (A : Matrix m n ℂ) (B : Matrix n p ℂ) : + mirror f h (A*B)=mirror g h B*mirror f g A := by + unfold mirror + rw [Matrix.conjTranspose_mul] + exact (Matrix.submatrix_mul_equiv B.conjTranspose A.conjTranspose h g f).symm +lemma mirror_add {m n : Type*} (f : m ≃ m) (g : n ≃ n) (A B : Matrix m n ℂ) : + mirror f g (A+B)=mirror f g A+mirror f g B := by + ext i j + simp [mirror] +def spinFlip : Fin 3 ≃ Fin 3 where + toFun := Fin.rev + invFun := Fin.rev + left_inv := Fin.rev_involutive + right_inv := Fin.rev_involutive +@[simp] lemma spinFlip_apply (a : Fin 3) : spinFlip a = a.rev := rfl +noncomputable def pairFlip : Pair ≃ Pair := + (Equiv.prodCongr spinFlip spinFlip).trans (Equiv.prodComm _ _) +lemma sine_star (t : ℝ) : star (sine t)=sine t := by + simp only [sine,Complex.star_def,Complex.conj_ofReal] +lemma mirror_boundary0 (t : ℝ) : mirror spinFlip spinFlip (boundary0 t)=boundary0 t := by + ext i j + fin_cases i <;> fin_cases j <;> + simp [mirror,spinFlip_apply,Fin.rev,boundary0,sine_star] +lemma mirror_boundary1 (t : ℝ) : mirror spinFlip spinFlip (boundary1 t)=phase⁻¹ • boundary1 t := by + ext i j + fin_cases i <;> fin_cases j <;> + simp [mirror,spinFlip_apply,Fin.rev,boundary1,sine_star,phase_star] + all_goals field_simp [phase,point_ne_zero] +lemma mirror_slot1 (M : Matrix (Fin 3) (Fin 3) ℂ) : + mirror pairFlip pairFlip (slot1 M)=slot2 (mirror spinFlip spinFlip M) := by + ext ⟨a,b⟩ ⟨c,d⟩ + by_cases h : a=c <;> simp [mirror,pairFlip,slot1,slot2,h,eq_comm] +lemma mirror_slot2 (M : Matrix (Fin 3) (Fin 3) ℂ) : + mirror pairFlip pairFlip (slot2 M)=slot1 (mirror spinFlip spinFlip M) := by + ext ⟨a,b⟩ ⟨c,d⟩ + by_cases h : b=d <;> simp [mirror,pairFlip,slot1,slot2,h,eq_comm] +lemma mirror_W : mirror pairFlip spinFlip sourceW=sourceWbarᵀ := by + ext j ⟨a,b⟩ + fin_cases j <;> fin_cases a <;> fin_cases b <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,sourceW,sourceWbar, + sourceKappa_star,phase_star,div_eq_mul_inv] +lemma mirror_Wbar : mirror pairFlip spinFlip sourceWbar=sourceWᵀ := by + ext j ⟨a,b⟩ + fin_cases j <;> fin_cases a <;> fin_cases b <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,sourceW,sourceWbar, + sourceKappa_star,phase_star,div_eq_mul_inv] +lemma mirror_bulk_00 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (0,0) (c,d)=spectralR u (0,0) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffC,sine_star,div_eq_mul_inv] +lemma mirror_bulk_01 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (0,1) (c,d)=spectralR u (0,1) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +lemma mirror_bulk_02 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (0,2) (c,d)=spectralR u (0,2) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffH,coeffC,coeffD,S,sine_star,phase_star,div_eq_mul_inv] +lemma mirror_bulk_10 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (1,0) (c,d)=spectralR u (1,0) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +lemma mirror_bulk_11 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (1,1) (c,d)=spectralR u (1,1) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffH,S,sine_star,phase_star,div_eq_mul_inv] +lemma mirror_bulk_12 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (1,2) (c,d)=spectralR u (1,2) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +lemma mirror_bulk_20 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (2,0) (c,d)=spectralR u (2,0) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffH,coeffC,coeffD,S,sine_star,phase_star,div_eq_mul_inv] +lemma mirror_bulk_21 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (2,1) (c,d)=spectralR u (2,1) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +lemma mirror_bulk_22 (u : ℝ) (c d : Fin 3) : + mirror pairFlip pairFlip (spectralR u) (2,2) (c,d)=spectralR u (2,2) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [mirror,pairFlip,spinFlip_apply,Fin.rev,spectralR,bulkNumerator,Q,coeffC,sine_star,div_eq_mul_inv] +lemma mirror_bulk (u : ℝ) : mirror pairFlip pairFlip (spectralR u)=spectralR u := by + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b + · exact mirror_bulk_00 u c d + · exact mirror_bulk_01 u c d + · exact mirror_bulk_02 u c d + · exact mirror_bulk_10 u c d + · exact mirror_bulk_11 u c d + · exact mirror_bulk_12 u c d + · exact mirror_bulk_20 u c d + · exact mirror_bulk_21 u c d + · exact mirror_bulk_22 u c d + +theorem boundary_fusion_dual_constant (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + sourceWᵀ*slot2 (boundary0 (t+L))*spectralR (2*t)*slot1 (boundary0 (t-L))= + boundary0 t*sourceWbarᵀ := by + have hh:=congrArg (mirror pairFlip spinFlip) (boundary_fusion_constant t hQ ht hm hp) + simpa only [mirror_mul pairFlip pairFlip spinFlip,mirror_mul pairFlip spinFlip spinFlip,mirror_W,mirror_Wbar,mirror_slot1,mirror_slot2, + mirror_boundary0,mirror_bulk,Matrix.mul_assoc] using hh + +theorem boundary_fusion_dual_linear (t : ℝ) (hQ : Q (2*t)≠0) + (ht : sine (gamma+t)≠0) (hm : sine (gamma+(t-L))≠0) (hp : sine (gamma+(t+L))≠0) : + sourceWᵀ*slot2 (boundary0 (t+L))*spectralR (2*t)*slot1 (boundary1 (t-L))+ + sourceWᵀ*slot2 (boundary1 (t+L))*spectralR (2*t)*slot1 (boundary0 (t-L))= + boundary1 t*sourceWbarᵀ := by + have hh:=congrArg (mirror pairFlip spinFlip) (boundary_fusion_linear t hQ ht hm hp) + simp only [mirror_add,mirror_mul pairFlip pairFlip spinFlip,mirror_mul pairFlip spinFlip spinFlip,mirror_W,mirror_Wbar,mirror_slot1,mirror_slot2, + mirror_boundary0,mirror_boundary1,mirror_bulk,Matrix.mul_assoc, + slot1_smul,slot2_smul,Matrix.smul_mul,Matrix.mul_smul,←smul_add] at hh + have hn : phase⁻¹≠0 := inv_ne_zero (by exact point_ne_zero _) + funext j p + apply mul_left_cancel₀ hn + simpa only [Matrix.mul_assoc, Matrix.smul_apply, smul_eq_mul] using congrFun (congrFun hh j) p +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +open scoped Matrix +private lemma hermitianHermitianBulk00 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (0,0) (c,d)=spectralR u (0,0) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffC,sine_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk01 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (0,1) (c,d)=spectralR u (0,1) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk02 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (0,2) (c,d)=spectralR u (0,2) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffH,coeffC,coeffD,S,sine_star,phase_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk10 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (1,0) (c,d)=spectralR u (1,0) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk11 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (1,1) (c,d)=spectralR u (1,1) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffH,S,sine_star,phase_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk12 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (1,2) (c,d)=spectralR u (1,2) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk20 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (2,0) (c,d)=spectralR u (2,0) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffH,coeffC,coeffD,S,sine_star,phase_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk21 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (2,1) (c,d)=spectralR u (2,1) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffA,coeffV,S,sine_star,div_eq_mul_inv] +private lemma hermitianHermitianBulk22 (u : ℝ) (c d : Fin 3) : + (spectralR u).conjTranspose (2,2) (c,d)=spectralR u (2,2) (c,d) := by + fin_cases c <;> fin_cases d <;> + simp [Matrix.conjTranspose_apply,spectralR,bulkNumerator,Q,coeffC,sine_star,div_eq_mul_inv] + +theorem spectralR_hermitian (u : ℝ) : (spectralR u).conjTranspose=spectralR u := by + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b + · exact hermitianHermitianBulk00 u c d + · exact hermitianHermitianBulk01 u c d + · exact hermitianHermitianBulk02 u c d + · exact hermitianHermitianBulk10 u c d + · exact hermitianHermitianBulk11 u c d + · exact hermitianHermitianBulk12 u c d + · exact hermitianHermitianBulk20 u c d + · exact hermitianHermitianBulk21 u c d + · exact hermitianHermitianBulk22 u c d +lemma sourceW_conjTranspose : sourceW.conjTranspose=sourceWbarᵀ := by + ext j p + exact (sourceWbar_eq_conj p j).symm +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ReflectionEquation.lean b/lean/OAI/Combinatorics/HoneycombChords/ReflectionEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fcb33bc0389b98db7c7a97be19ec88412d6776b --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ReflectionEquation.lean @@ -0,0 +1,1354 @@ +import Mathlib.Data.Matrix.Mul +import Mathlib.Basic.Complex.Basic +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.LinearCombination + +namespace OAI + +/-! Polynomial matrix verification of the two-boundary reflection equation. + +The specialization at a sixteenth root of minus one gives the honeycomb +reflection identity in the finite strip transfer calculation. -/ +section + +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix +abbrev Pair := Fin 3 × Fin 3 +noncomputable def rNumerator (r z w : ℂ) : Matrix Pair Pair ℂ := fun p q=> + let cc:=(r^6*w^2+r^10*z^2)*(r^4*w^2+r^12*z^2) + let aa:=(r^4+r^12)*z*w*(r^6*w^2+r^10*z^2) + let hh:=(r^4+r^12)*z*w*(z^2-w^2) + let vv:=(r^6*w^2+r^10*z^2)*(z^2-w^2) + let dd:=(z^2-w^2)*(-r^14*z^2-r^2*w^2) + let qq:=(r^4*z^2+r^12*w^2)*(r^6*z^2+r^10*w^2) + match p.1.val,p.2.val,q.1.val,q.2.val with + | 0,0,0,0 => cc + | 2,2,2,2 => cc + | 0,1,0,1 => vv + | 1,0,1,0 => vv + | 2,1,2,1 => vv + | 1,2,1,2 => vv + | 0,1,1,0 => aa + | 1,0,0,1 => aa + | 2,1,1,2 => aa + | 1,2,2,1 => aa + | 0,2,0,2 => dd + | 0,2,1,1 => -r^12*hh + | 0,2,2,0 => cc-r^8*dd + | 1,1,0,2 => r^4*hh + | 1,1,1,1 => qq + | 1,1,2,0 => -r^12*hh + | 2,0,0,2 => cc+r^8*dd + | 2,0,1,1 => r^4*hh + | 2,0,2,0 => dd + | _,_,_,_ => 0 +noncomputable def dConstant (r z : ℂ) : Matrix (Fin 3) (Fin 3) ℂ := fun p q=> + if p=q then if p=1 then z*(r^3*z^2+r^13) else z*(r^3+r^13*z^2) else 0 +noncomputable def dLinear (r z : ℂ) : Matrix (Fin 3) (Fin 3) ℂ := fun p q=> + if p=0 ∧ q=1 then z^4-1 else if p=1 ∧ q=2 then r^4*(z^4-1) else 0 +noncomputable def slot1 (M : Matrix (Fin 3) (Fin 3) ℂ) : Matrix Pair Pair ℂ := + fun p q=>if p.2=q.2 then M p.1 q.1 else 0 +noncomputable def slot2 (M : Matrix (Fin 3) (Fin 3) ℂ) : Matrix Pair Pair ℂ := + fun p q=>if p.1=q.1 then M p.2 q.2 else 0 +noncomputable def reflectionLeft0 (r z w : ℂ) : Matrix Pair Pair ℂ := + rNumerator r z w * slot1 (dConstant r z) * (rNumerator r (z*w) 1)ᵀ * slot2 (dConstant r w) +noncomputable def reflectionRight0 (r z w : ℂ) : Matrix Pair Pair ℂ := + slot2 (dConstant r w) * (rNumerator r (z*w) 1 * slot1 (dConstant r z) * (rNumerator r z w)ᵀ) +noncomputable def reflectionLeft1 (r z w : ℂ) : Matrix Pair Pair ℂ := + rNumerator r z w * slot1 (dLinear r z) * (rNumerator r (z*w) 1)ᵀ * slot2 (dConstant r w)+ + rNumerator r z w * slot1 (dConstant r z) * (rNumerator r (z*w) 1)ᵀ * slot2 (dLinear r w) +noncomputable def reflectionRight1 (r z w : ℂ) : Matrix Pair Pair ℂ := + slot2 (dConstant r w) * (rNumerator r (z*w) 1 * slot1 (dLinear r z) * (rNumerator r z w)ᵀ)+ + slot2 (dLinear r w) * (rNumerator r (z*w) 1 * slot1 (dConstant r z) * (rNumerator r z w)ᵀ) +noncomputable def dValue (r z : ℂ) (p : Fin 3) : ℂ := + if p=1 then z*(r^3*z^2+r^13) else z*(r^3+r^13*z^2) +lemma mul_slot1_constant (r z : ℂ) (M : Matrix Pair Pair ℂ) (p q : Pair) : + (M*slot1 (dConstant r z)) p q=M p q*dValue r z q.1 := by + classical + simp [Matrix.mul_apply,slot1,dConstant,dValue,Fintype.sum_prod_type,mul_ite] +lemma mul_slot2_constant (r z : ℂ) (M : Matrix Pair Pair ℂ) (p q : Pair) : + (M*slot2 (dConstant r z)) p q=M p q*dValue r z q.2 := by + classical + simp [Matrix.mul_apply,slot2,dConstant,dValue,Fintype.sum_prod_type,mul_ite] +lemma slot2_constant_mul (r z : ℂ) (M : Matrix Pair Pair ℂ) (p q : Pair) : + (slot2 (dConstant r z)*M) p q=dValue r z p.2*M p q := by + classical + simp [Matrix.mul_apply,slot2,dConstant,dValue,Fintype.sum_prod_type,ite_mul] +lemma mul_slot1_linear (r z : ℂ) (M : Matrix Pair Pair ℂ) (p q : Pair) : + (M*slot1 (dLinear r z)) p q= + if q.1=1 then M p (0,q.2)*(z^4-1) else + if q.1=2 then M p (1,q.2)*(r^4*(z^4-1)) else 0 := by + classical + rcases q with ⟨a,b⟩ + fin_cases a <;> simp [Matrix.mul_apply,slot1,dLinear,Fintype.sum_prod_type,mul_ite] +lemma mul_slot2_linear (r z : ℂ) (M : Matrix Pair Pair ℂ) (p q : Pair) : + (M*slot2 (dLinear r z)) p q= + if q.2=1 then M p (q.1,0)*(z^4-1) else + if q.2=2 then M p (q.1,1)*(r^4*(z^4-1)) else 0 := by + classical + rcases q with ⟨a,b⟩ + fin_cases b <;> simp [Matrix.mul_apply,slot2,dLinear,Fintype.sum_prod_type,mul_ite] +lemma slot2_linear_mul (r z : ℂ) (M : Matrix Pair Pair ℂ) (p q : Pair) : + (slot2 (dLinear r z)*M) p q= + if p.2=0 then (z^4-1)*M (p.1,1) q else + if p.2=1 then (r^4*(z^4-1))*M (p.1,2) q else 0 := by + classical + rcases p with ⟨a,b⟩ + fin_cases b <;> simp [Matrix.mul_apply,slot2,dLinear,Fintype.sum_prod_type,ite_mul] +lemma core0_apply (r z : ℂ) (A B : Matrix Pair Pair ℂ) (p q : Pair) : + (A*slot1 (dConstant r z)*Bᵀ) p q=∑ k,A p k*dValue r z k.1*B q k := by + rw [Matrix.mul_apply] + simp only [mul_slot1_constant,Matrix.transpose_apply] +lemma core1_apply (r z : ℂ) (A B : Matrix Pair Pair ℂ) (p q : Pair) : + (A*slot1 (dLinear r z)*Bᵀ) p q=∑ k, + (if k.1=1 then A p (0,k.2)*(z^4-1) else + if k.1=2 then A p (1,k.2)*(r^4*(z^4-1)) else 0)*B q k := by + rw [Matrix.mul_apply] + simp only [mul_slot1_linear,Matrix.transpose_apply] +private lemma reflectionFinThreeTwo : (2:Fin 3).val=2 := rfl +private abbrev reflectionAdd (a b : ℂ) : ℂ := a+b +private abbrev reflectionMul (a b : ℂ) : ℂ := a*b +private abbrev reflectionPow (a : ℂ) (n : ℕ) : ℂ := a^n +section +variable (r z w : ℂ) (hr : r^16+1=0) +include hr +omit hr in +private lemma reflectionComponent00000 : reflectionLeft0 r z w (0,0) (0,0) = reflectionRight0 r z w (0,0) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent00001 : reflectionLeft0 r z w (0,0) (0,1) = reflectionRight0 r z w (0,0) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00002 : reflectionLeft0 r z w (0,0) (0,2) = reflectionRight0 r z w (0,0) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00010 : reflectionLeft0 r z w (0,0) (1,0) = reflectionRight0 r z w (0,0) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00011 : reflectionLeft0 r z w (0,0) (1,1) = reflectionRight0 r z w (0,0) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00012 : reflectionLeft0 r z w (0,0) (1,2) = reflectionRight0 r z w (0,0) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00020 : reflectionLeft0 r z w (0,0) (2,0) = reflectionRight0 r z w (0,0) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00021 : reflectionLeft0 r z w (0,0) (2,1) = reflectionRight0 r z w (0,0) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00022 : reflectionLeft0 r z w (0,0) (2,2) = reflectionRight0 r z w (0,0) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00100 : reflectionLeft0 r z w (0,1) (0,0) = reflectionRight0 r z w (0,1) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00101 : reflectionLeft0 r z w (0,1) (0,1) = reflectionRight0 r z w (0,1) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent00102 : reflectionLeft0 r z w (0,1) (0,2) = reflectionRight0 r z w (0,1) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00110 : reflectionLeft0 r z w (0,1) (1,0) = reflectionRight0 r z w (0,1) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent00111 : reflectionLeft0 r z w (0,1) (1,1) = reflectionRight0 r z w (0,1) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00112 : reflectionLeft0 r z w (0,1) (1,2) = reflectionRight0 r z w (0,1) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00120 : reflectionLeft0 r z w (0,1) (2,0) = reflectionRight0 r z w (0,1) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00121 : reflectionLeft0 r z w (0,1) (2,1) = reflectionRight0 r z w (0,1) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00122 : reflectionLeft0 r z w (0,1) (2,2) = reflectionRight0 r z w (0,1) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00200 : reflectionLeft0 r z w (0,2) (0,0) = reflectionRight0 r z w (0,2) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00201 : reflectionLeft0 r z w (0,2) (0,1) = reflectionRight0 r z w (0,2) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00202 : reflectionLeft0 r z w (0,2) (0,2) = reflectionRight0 r z w (0,2) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent00210 : reflectionLeft0 r z w (0,2) (1,0) = reflectionRight0 r z w (0,2) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate00211 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 56) (reflectionMul (reflectionPow z 6) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 6) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 56) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 56) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))) (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 6) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 6) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 46) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 46)) (reflectionMul (reflectionPow z 8) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 46)) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionMul (reflectionPow r 46) (reflectionMul (reflectionPow z 6) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 46) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 46)) (reflectionMul (reflectionPow z 4) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 10) (reflectionPow w 4))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 8) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 2) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 38) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 38)) (reflectionMul (reflectionPow z 8) (reflectionPow w 4))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 38)) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionMul (reflectionPow r 38) (reflectionMul (reflectionPow z 6) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 38) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 38)) (reflectionMul (reflectionPow z 4) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 34)) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionPow r 34) (reflectionMul (reflectionPow z 8) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 34) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 34)) (reflectionMul (reflectionPow z 6) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 34)) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 34) (reflectionMul (reflectionPow z 4) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 10) (reflectionPow w 4))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 26)) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionPow r 26) (reflectionMul (reflectionPow z 8) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 26) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 26)) (reflectionMul (reflectionPow z 6) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 26)) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))) (reflectionMul (reflectionPow r 26) (reflectionMul (reflectionPow z 4) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 6) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 6) (reflectionPow w 4))) (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 16)) (reflectionMul (reflectionPow z 6) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 16) (reflectionMul (reflectionPow z 6) (reflectionPow w 4))) (reflectionMul (reflectionPow r 16) (reflectionMul (reflectionPow z 4) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 16)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 16)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionPow r 16) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))))))))) +private lemma reflectionComponent00211 : reflectionLeft0 r z w (0,2) (1,1) = reflectionRight0 r z w (0,2) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate00211 r z w*x) hr + dsimp only [reflectionCertificate00211,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent00212 : reflectionLeft0 r z w (0,2) (1,2) = reflectionRight0 r z w (0,2) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00220 : reflectionLeft0 r z w (0,2) (2,0) = reflectionRight0 r z w (0,2) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent00221 : reflectionLeft0 r z w (0,2) (2,1) = reflectionRight0 r z w (0,2) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent00222 : reflectionLeft0 r z w (0,2) (2,2) = reflectionRight0 r z w (0,2) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01000 : reflectionLeft0 r z w (1,0) (0,0) = reflectionRight0 r z w (1,0) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01001 : reflectionLeft0 r z w (1,0) (0,1) = reflectionRight0 r z w (1,0) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent01002 : reflectionLeft0 r z w (1,0) (0,2) = reflectionRight0 r z w (1,0) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01010 : reflectionLeft0 r z w (1,0) (1,0) = reflectionRight0 r z w (1,0) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent01011 : reflectionLeft0 r z w (1,0) (1,1) = reflectionRight0 r z w (1,0) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01012 : reflectionLeft0 r z w (1,0) (1,2) = reflectionRight0 r z w (1,0) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01020 : reflectionLeft0 r z w (1,0) (2,0) = reflectionRight0 r z w (1,0) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01021 : reflectionLeft0 r z w (1,0) (2,1) = reflectionRight0 r z w (1,0) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01022 : reflectionLeft0 r z w (1,0) (2,2) = reflectionRight0 r z w (1,0) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01100 : reflectionLeft0 r z w (1,1) (0,0) = reflectionRight0 r z w (1,1) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01101 : reflectionLeft0 r z w (1,1) (0,1) = reflectionRight0 r z w (1,1) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate01102 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 6) (reflectionPow w 8))) (reflectionMul (reflectionPow r 56) (reflectionMul (reflectionPow z 6) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 56) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionMul (reflectionPow r 56) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 56)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 6) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 6) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 46)) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionPow r 46) (reflectionMul (reflectionPow z 8) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 46) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 46)) (reflectionMul (reflectionPow z 6) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 46)) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 46) (reflectionMul (reflectionPow z 4) (reflectionPow w 4))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 38)) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionPow r 38) (reflectionMul (reflectionPow z 8) (reflectionPow w 4))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 38) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 38)) (reflectionMul (reflectionPow z 6) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 38)) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))) (reflectionMul (reflectionPow r 38) (reflectionMul (reflectionPow z 4) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 34) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 34)) (reflectionMul (reflectionPow z 8) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 34)) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 34) (reflectionMul (reflectionPow z 6) (reflectionPow w 2))) (reflectionMul (reflectionPow r 34) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 34)) (reflectionMul (reflectionPow z 4) (reflectionPow w 4))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 10) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 4) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 26) (reflectionMul (reflectionPow z 8) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 26)) (reflectionMul (reflectionPow z 8) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 26)) (reflectionMul (reflectionPow z 6) (reflectionPow w 10))) (reflectionMul (reflectionPow r 26) (reflectionMul (reflectionPow z 6) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 26) (reflectionMul (reflectionPow z 4) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 26)) (reflectionMul (reflectionPow z 4) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 6) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 6) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 2) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))) (reflectionMul (reflectionPow r 16) (reflectionMul (reflectionPow z 6) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 16)) (reflectionMul (reflectionPow z 6) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 16)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 16) (reflectionMul (reflectionPow z 4) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 16) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 16)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))))))))) +private lemma reflectionComponent01102 : reflectionLeft0 r z w (1,1) (0,2) = reflectionRight0 r z w (1,1) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate01102 r z w*x) hr + dsimp only [reflectionCertificate01102,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent01110 : reflectionLeft0 r z w (1,1) (1,0) = reflectionRight0 r z w (1,1) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01111 : reflectionLeft0 r z w (1,1) (1,1) = reflectionRight0 r z w (1,1) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent01112 : reflectionLeft0 r z w (1,1) (1,2) = reflectionRight0 r z w (1,1) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate01120 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))))))) +private lemma reflectionComponent01120 : reflectionLeft0 r z w (1,1) (2,0) = reflectionRight0 r z w (1,1) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate01120 r z w*x) hr + dsimp only [reflectionCertificate01120,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent01121 : reflectionLeft0 r z w (1,1) (2,1) = reflectionRight0 r z w (1,1) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01122 : reflectionLeft0 r z w (1,1) (2,2) = reflectionRight0 r z w (1,1) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01200 : reflectionLeft0 r z w (1,2) (0,0) = reflectionRight0 r z w (1,2) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01201 : reflectionLeft0 r z w (1,2) (0,1) = reflectionRight0 r z w (1,2) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01202 : reflectionLeft0 r z w (1,2) (0,2) = reflectionRight0 r z w (1,2) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01210 : reflectionLeft0 r z w (1,2) (1,0) = reflectionRight0 r z w (1,2) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01211 : reflectionLeft0 r z w (1,2) (1,1) = reflectionRight0 r z w (1,2) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01212 : reflectionLeft0 r z w (1,2) (1,2) = reflectionRight0 r z w (1,2) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent01220 : reflectionLeft0 r z w (1,2) (2,0) = reflectionRight0 r z w (1,2) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent01221 : reflectionLeft0 r z w (1,2) (2,1) = reflectionRight0 r z w (1,2) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent01222 : reflectionLeft0 r z w (1,2) (2,2) = reflectionRight0 r z w (1,2) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02000 : reflectionLeft0 r z w (2,0) (0,0) = reflectionRight0 r z w (2,0) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02001 : reflectionLeft0 r z w (2,0) (0,1) = reflectionRight0 r z w (2,0) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02002 : reflectionLeft0 r z w (2,0) (0,2) = reflectionRight0 r z w (2,0) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent02010 : reflectionLeft0 r z w (2,0) (1,0) = reflectionRight0 r z w (2,0) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate02011 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 48) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 48)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 40) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 40)) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 32)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionPow r 32) (reflectionMul (reflectionPow z 2) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 10) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 10) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 8) (reflectionPow w 10))) (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 8) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 4) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 4) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 24)) (reflectionMul (reflectionPow z 2) (reflectionPow w 8))) (reflectionMul (reflectionPow r 24) (reflectionMul (reflectionPow z 2) (reflectionPow w 4))))))) +private lemma reflectionComponent02011 : reflectionLeft0 r z w (2,0) (1,1) = reflectionRight0 r z w (2,0) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate02011 r z w*x) hr + dsimp only [reflectionCertificate02011,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent02012 : reflectionLeft0 r z w (2,0) (1,2) = reflectionRight0 r z w (2,0) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02020 : reflectionLeft0 r z w (2,0) (2,0) = reflectionRight0 r z w (2,0) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent02021 : reflectionLeft0 r z w (2,0) (2,1) = reflectionRight0 r z w (2,0) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02022 : reflectionLeft0 r z w (2,0) (2,2) = reflectionRight0 r z w (2,0) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02100 : reflectionLeft0 r z w (2,1) (0,0) = reflectionRight0 r z w (2,1) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02101 : reflectionLeft0 r z w (2,1) (0,1) = reflectionRight0 r z w (2,1) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02102 : reflectionLeft0 r z w (2,1) (0,2) = reflectionRight0 r z w (2,1) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02110 : reflectionLeft0 r z w (2,1) (1,0) = reflectionRight0 r z w (2,1) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02111 : reflectionLeft0 r z w (2,1) (1,1) = reflectionRight0 r z w (2,1) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02112 : reflectionLeft0 r z w (2,1) (1,2) = reflectionRight0 r z w (2,1) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent02120 : reflectionLeft0 r z w (2,1) (2,0) = reflectionRight0 r z w (2,1) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02121 : reflectionLeft0 r z w (2,1) (2,1) = reflectionRight0 r z w (2,1) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent02122 : reflectionLeft0 r z w (2,1) (2,2) = reflectionRight0 r z w (2,1) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02200 : reflectionLeft0 r z w (2,2) (0,0) = reflectionRight0 r z w (2,2) (0,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02201 : reflectionLeft0 r z w (2,2) (0,1) = reflectionRight0 r z w (2,2) (0,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02202 : reflectionLeft0 r z w (2,2) (0,2) = reflectionRight0 r z w (2,2) (0,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02210 : reflectionLeft0 r z w (2,2) (1,0) = reflectionRight0 r z w (2,2) (1,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02211 : reflectionLeft0 r z w (2,2) (1,1) = reflectionRight0 r z w (2,2) (1,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02212 : reflectionLeft0 r z w (2,2) (1,2) = reflectionRight0 r z w (2,2) (1,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02220 : reflectionLeft0 r z w (2,2) (2,0) = reflectionRight0 r z w (2,2) (2,0) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02221 : reflectionLeft0 r z w (2,2) (2,1) = reflectionRight0 r z w (2,2) (2,1) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent02222 : reflectionLeft0 r z w (2,2) (2,2) = reflectionRight0 r z w (2,2) (2,2) := by + simp only [reflectionLeft0,reflectionRight0,mul_slot2_constant,slot2_constant_mul] + simp only [core0_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent10000 : reflectionLeft1 r z w (0,0) (0,0) = reflectionRight1 r z w (0,0) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate10001 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 11) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 7) (reflectionPow w 12))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul ((-1:ℂ)) (reflectionMul (reflectionPow r 29) (reflectionPow z 7)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 5) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 12))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul ((-1:ℂ)) (reflectionMul (reflectionPow r 19) (reflectionPow z 5)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 3) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionPow r 15) (reflectionMul (z) (reflectionPow w 4)))))))) +private lemma reflectionComponent10001 : reflectionLeft1 r z w (0,0) (0,1) = reflectionRight1 r z w (0,0) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate10001 r z w*x) hr + dsimp only [reflectionCertificate10001,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent10002 : reflectionLeft1 r z w (0,0) (0,2) = reflectionRight1 r z w (0,0) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10010 : reflectionLeft1 r z w (0,0) (1,0) = reflectionRight1 r z w (0,0) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent10011 : reflectionLeft1 r z w (0,0) (1,1) = reflectionRight1 r z w (0,0) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10012 : reflectionLeft1 r z w (0,0) (1,2) = reflectionRight1 r z w (0,0) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10020 : reflectionLeft1 r z w (0,0) (2,0) = reflectionRight1 r z w (0,0) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10021 : reflectionLeft1 r z w (0,0) (2,1) = reflectionRight1 r z w (0,0) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10022 : reflectionLeft1 r z w (0,0) (2,2) = reflectionRight1 r z w (0,0) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10100 : reflectionLeft1 r z w (0,1) (0,0) = reflectionRight1 r z w (0,1) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10101 : reflectionLeft1 r z w (0,1) (0,1) = reflectionRight1 r z w (0,1) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate10102 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 49)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionPow r 49) (reflectionMul (reflectionPow z 7) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 49) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 49)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 49)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionPow r 49) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 7) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 11) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 9) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 7) (reflectionPow w 2)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionMul (reflectionPow r 27) (reflectionMul (z) (reflectionPow w 8)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (z) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 3) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (z) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (z) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 11)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 11) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionPow r 11) (reflectionMul (reflectionPow z 3) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 11)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 11)) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionPow r 11) (reflectionMul (z) (reflectionPow w 4))))))))) +private lemma reflectionComponent10102 : reflectionLeft1 r z w (0,1) (0,2) = reflectionRight1 r z w (0,1) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate10102 r z w*x) hr + dsimp only [reflectionCertificate10102,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent10110 : reflectionLeft1 r z w (0,1) (1,0) = reflectionRight1 r z w (0,1) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate10111 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 10) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionMul (reflectionPow r 47) (reflectionMul (reflectionPow z 6) (reflectionPow w 9)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 6) (reflectionPow w 5))) (reflectionMul (reflectionPow r 47) (reflectionMul (reflectionPow z 4) (reflectionPow w 11)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionPow r 47) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 10) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 6) (reflectionPow w 9)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 6) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 8) (reflectionPow w 9)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 8) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 6) (reflectionPow w 11)))) (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 4) (reflectionPow w 5)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 8) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 6) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 6) (w))) (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 4) (reflectionPow w 7))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 10) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 10) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 8) (reflectionPow w 5))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 8) (w)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 6) (reflectionPow w 11))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 4) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 4) (w)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 8) (reflectionPow w 7))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 6) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 6) (w))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 4) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 6) (reflectionPow w 7))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 10) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 4) (reflectionPow w 11)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 10) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 4) (reflectionPow w 11)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 2) (reflectionPow w 5)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 6) (reflectionPow w 7))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))))) (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))))) +private lemma reflectionComponent10111 : reflectionLeft1 r z w (0,1) (1,1) = reflectionRight1 r z w (0,1) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate10111 r z w*x) hr + dsimp only [reflectionCertificate10111,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent10112 : reflectionLeft1 r z w (0,1) (1,2) = reflectionRight1 r z w (0,1) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate10120 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 3) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 11) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 9) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 11) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 7) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 11) (reflectionPow w 4))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 3) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionPow r 19) (reflectionMul (z) (reflectionPow w 4)))))))) +private lemma reflectionComponent10120 : reflectionLeft1 r z w (0,1) (2,0) = reflectionRight1 r z w (0,1) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate10120 r z w*x) hr + dsimp only [reflectionCertificate10120,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent10121 : reflectionLeft1 r z w (0,1) (2,1) = reflectionRight1 r z w (0,1) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10122 : reflectionLeft1 r z w (0,1) (2,2) = reflectionRight1 r z w (0,1) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10200 : reflectionLeft1 r z w (0,2) (0,0) = reflectionRight1 r z w (0,2) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10201 : reflectionLeft1 r z w (0,2) (0,1) = reflectionRight1 r z w (0,2) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10202 : reflectionLeft1 r z w (0,2) (0,2) = reflectionRight1 r z w (0,2) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10210 : reflectionLeft1 r z w (0,2) (1,0) = reflectionRight1 r z w (0,2) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent10211 : reflectionLeft1 r z w (0,2) (1,1) = reflectionRight1 r z w (0,2) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate10212 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 6) (reflectionPow w 7)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 47) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 47) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionPow r 47) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 47)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 6) (reflectionPow w 7)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 8) (reflectionPow w 7))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 8) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 6) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 6) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 4) (reflectionPow w 7)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 8) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 6) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 4) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 4) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 8) (reflectionPow w 7))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 8) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 6) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 6) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 4) (reflectionPow w 7)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 8) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 6) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 4) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 10) (reflectionPow w 5))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 8) (reflectionPow w 11)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 6) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 6) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 8) (w)))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 4) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 6) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 6) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 2) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 10) (reflectionPow w 3))) (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 8) (reflectionPow w 9)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))))) +private lemma reflectionComponent10212 : reflectionLeft1 r z w (0,2) (1,2) = reflectionRight1 r z w (0,2) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate10212 r z w*x) hr + dsimp only [reflectionCertificate10212,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent10220 : reflectionLeft1 r z w (0,2) (2,0) = reflectionRight1 r z w (0,2) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate10221 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 11) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 11) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 7) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (z) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (z) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 5) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (z) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (z) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 3) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (z) (reflectionPow w 4)))))))) +private lemma reflectionComponent10221 : reflectionLeft1 r z w (0,2) (2,1) = reflectionRight1 r z w (0,2) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate10221 r z w*x) hr + dsimp only [reflectionCertificate10221,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent10222 : reflectionLeft1 r z w (0,2) (2,2) = reflectionRight1 r z w (0,2) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11000 : reflectionLeft1 r z w (1,0) (0,0) = reflectionRight1 r z w (1,0) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11001 : reflectionLeft1 r z w (1,0) (0,1) = reflectionRight1 r z w (1,0) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate11002 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 43)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 43)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 43)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 43)) (reflectionMul (reflectionPow z 8) (w))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 43) (reflectionMul (reflectionPow z 6) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 43)) (reflectionMul (reflectionPow z 6) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 43) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 43)) (reflectionMul (reflectionPow z 4) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 43)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 43) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 6) (reflectionPow w 7)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 4) (w)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 2) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 8) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 6) (reflectionPow w 9))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 6) (w)))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 4) (reflectionPow w 7))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 8) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 6) (reflectionPow w 11)))) (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 4) (reflectionPow w 5))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 10) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 10) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 4) (w))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 2) (reflectionPow w 7)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 8) (reflectionPow w 7))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 6) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 6) (w))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 4) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 8) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 6) (reflectionPow w 11))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 6) (reflectionPow w 3))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 4) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 6) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 6) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 2) (reflectionPow w 9)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))) (reflectionMul (reflectionPow r 13) (reflectionMul (reflectionPow z 6) (reflectionPow w 9))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 13)) (reflectionMul (reflectionPow z 6) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 13)) (reflectionMul (reflectionPow z 4) (reflectionPow w 11)))) (reflectionAdd (reflectionMul (reflectionPow r 13) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 13) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 13)) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))))))))) +private lemma reflectionComponent11002 : reflectionLeft1 r z w (1,0) (0,2) = reflectionRight1 r z w (1,0) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate11002 r z w*x) hr + dsimp only [reflectionCertificate11002,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent11010 : reflectionLeft1 r z w (1,0) (1,0) = reflectionRight1 r z w (1,0) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate11011 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionPow r 45) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 45) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 45) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (z) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionPow r 41) (reflectionMul (z) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 3) (reflectionPow w 2)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (z) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 9) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 7) (reflectionPow w 2)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 12))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionPow z 5)) (reflectionMul (reflectionPow r 29) (reflectionMul (z) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (z) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (z) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 3) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 7) (reflectionPow w 12))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionPow z 7)) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))))))))) +private lemma reflectionComponent11011 : reflectionLeft1 r z w (1,0) (1,1) = reflectionRight1 r z w (1,0) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate11011 r z w*x) hr + dsimp only [reflectionCertificate11011,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent11012 : reflectionLeft1 r z w (1,0) (1,2) = reflectionRight1 r z w (1,0) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate11020 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 8) (w))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 4) (w)))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 8) (w))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 4) (w)))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 10) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 4) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 2) (reflectionPow w 5)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 8) (w))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 4) (w)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))) +private lemma reflectionComponent11020 : reflectionLeft1 r z w (1,0) (2,0) = reflectionRight1 r z w (1,0) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate11020 r z w*x) hr + dsimp only [reflectionCertificate11020,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent11021 : reflectionLeft1 r z w (1,0) (2,1) = reflectionRight1 r z w (1,0) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11022 : reflectionLeft1 r z w (1,0) (2,2) = reflectionRight1 r z w (1,0) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11100 : reflectionLeft1 r z w (1,1) (0,0) = reflectionRight1 r z w (1,1) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11101 : reflectionLeft1 r z w (1,1) (0,1) = reflectionRight1 r z w (1,1) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11102 : reflectionLeft1 r z w (1,1) (0,2) = reflectionRight1 r z w (1,1) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11110 : reflectionLeft1 r z w (1,1) (1,0) = reflectionRight1 r z w (1,1) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11111 : reflectionLeft1 r z w (1,1) (1,1) = reflectionRight1 r z w (1,1) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate11112 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 49) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 49)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 49)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionPow r 49) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 49) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 49)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 45) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionPow r 45) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 45)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionPow r 45) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 45) (reflectionMul (z) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 45)) (reflectionMul (z) (reflectionPow w 4))) (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionPow r 41) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 41)) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionPow r 41) (reflectionMul (z) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-3:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionMul ((3:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 5) (reflectionPow w 12))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionAdd (reflectionMul ((-1:ℂ)) (reflectionMul (reflectionPow r 33) (reflectionPow z 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (z) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (z) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 5) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (z) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (z) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (z) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 7) (reflectionPow w 12))))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul ((-1:ℂ)) (reflectionMul (reflectionPow r 23) (reflectionPow z 7)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))))) (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (z) (reflectionPow w 4))))))))) +private lemma reflectionComponent11112 : reflectionLeft1 r z w (1,1) (1,2) = reflectionRight1 r z w (1,1) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate11112 r z w*x) hr + dsimp only [reflectionCertificate11112,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent11120 : reflectionLeft1 r z w (1,1) (2,0) = reflectionRight1 r z w (1,1) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate11121 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 10) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 35)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 35) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 10) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 8) (w))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 4) (w))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 2) (reflectionPow w 3)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 10) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 10) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 4) (reflectionPow w 3))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 2) (reflectionPow w 5))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionAdd (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 8) (w))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 4) (w))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 21)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionPow r 21) (reflectionMul (reflectionPow z 2) (reflectionPow w 3)))))))) +private lemma reflectionComponent11121 : reflectionLeft1 r z w (1,1) (2,1) = reflectionRight1 r z w (1,1) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate11121 r z w*x) hr + dsimp only [reflectionCertificate11121,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent11122 : reflectionLeft1 r z w (1,1) (2,2) = reflectionRight1 r z w (1,1) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11200 : reflectionLeft1 r z w (1,2) (0,0) = reflectionRight1 r z w (1,2) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11201 : reflectionLeft1 r z w (1,2) (0,1) = reflectionRight1 r z w (1,2) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11202 : reflectionLeft1 r z w (1,2) (0,2) = reflectionRight1 r z w (1,2) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11210 : reflectionLeft1 r z w (1,2) (1,0) = reflectionRight1 r z w (1,2) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11211 : reflectionLeft1 r z w (1,2) (1,1) = reflectionRight1 r z w (1,2) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11212 : reflectionLeft1 r z w (1,2) (1,2) = reflectionRight1 r z w (1,2) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11220 : reflectionLeft1 r z w (1,2) (2,0) = reflectionRight1 r z w (1,2) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11221 : reflectionLeft1 r z w (1,2) (2,1) = reflectionRight1 r z w (1,2) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent11222 : reflectionLeft1 r z w (1,2) (2,2) = reflectionRight1 r z w (1,2) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + all_goals ring + +omit hr in +private lemma reflectionComponent12000 : reflectionLeft1 r z w (2,0) (0,0) = reflectionRight1 r z w (2,0) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12001 : reflectionLeft1 r z w (2,0) (0,1) = reflectionRight1 r z w (2,0) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12002 : reflectionLeft1 r z w (2,0) (0,2) = reflectionRight1 r z w (2,0) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12010 : reflectionLeft1 r z w (2,0) (1,0) = reflectionRight1 r z w (2,0) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12011 : reflectionLeft1 r z w (2,0) (1,1) = reflectionRight1 r z w (2,0) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate12012 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 8) (w))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 4) (w)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 39)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionPow r 39) (reflectionMul (reflectionPow z 2) (reflectionPow w 3)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 8) (w))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 4) (w)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 31)) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionPow r 31) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 10) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 10) (reflectionPow w 5)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 8) (reflectionPow w 11))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 8) (reflectionPow w 3))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 4) (reflectionPow w 11))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 4) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 2) (reflectionPow w 9))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 2) (reflectionPow w 5)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 10) (reflectionPow w 7))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 10) (reflectionPow w 3)))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 8) (reflectionPow w 9))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 8) (w))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 4) (reflectionPow w 9))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 4) (w)))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 2) (reflectionPow w 7))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 2) (reflectionPow w 3))))))) +private lemma reflectionComponent12012 : reflectionLeft1 r z w (2,0) (1,2) = reflectionRight1 r z w (2,0) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate12012 r z w*x) hr + dsimp only [reflectionCertificate12012,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent12020 : reflectionLeft1 r z w (2,0) (2,0) = reflectionRight1 r z w (2,0) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate12021 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 3) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 9) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 9) (reflectionPow w 2)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))) (reflectionMul (reflectionPow r 25) (reflectionMul (reflectionPow z 7) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-2:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionMul ((2:ℂ)) (reflectionPow r 25)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionMul (reflectionPow r 23) (reflectionMul (z) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (z) (reflectionPow w 4))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 9) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 17) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 17)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 5) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 15) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2)))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 15)) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionPow r 15) (reflectionMul (z) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionPow r 7) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 7)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 7)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionMul (reflectionPow r 7) (reflectionMul (reflectionPow z 3) (reflectionPow w 2)))) (reflectionAdd (reflectionMul (reflectionPow r 7) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 7)) (reflectionMul (z) (reflectionPow w 4)))))))) +private lemma reflectionComponent12021 : reflectionLeft1 r z w (2,0) (2,1) = reflectionRight1 r z w (2,0) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate12021 r z w*x) hr + dsimp only [reflectionCertificate12021,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent12022 : reflectionLeft1 r z w (2,0) (2,2) = reflectionRight1 r z w (2,0) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12100 : reflectionLeft1 r z w (2,1) (0,0) = reflectionRight1 r z w (2,1) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12101 : reflectionLeft1 r z w (2,1) (0,1) = reflectionRight1 r z w (2,1) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12102 : reflectionLeft1 r z w (2,1) (0,2) = reflectionRight1 r z w (2,1) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12110 : reflectionLeft1 r z w (2,1) (1,0) = reflectionRight1 r z w (2,1) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12111 : reflectionLeft1 r z w (2,1) (1,1) = reflectionRight1 r z w (2,1) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12112 : reflectionLeft1 r z w (2,1) (1,2) = reflectionRight1 r z w (2,1) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12120 : reflectionLeft1 r z w (2,1) (2,0) = reflectionRight1 r z w (2,1) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12121 : reflectionLeft1 r z w (2,1) (2,1) = reflectionRight1 r z w (2,1) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +private noncomputable def reflectionCertificate12122 (r z w : ℂ) : ℂ := + reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 11) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 11) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 9) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionMul (reflectionPow r 37) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 37)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 9) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 9) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 12))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 7) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionPow r 33) (reflectionPow z 7))) (reflectionAdd (reflectionMul (reflectionPow r 33) (reflectionMul (reflectionPow z 5) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 33)) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 7) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 7) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 5) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 5) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 29) (reflectionMul (reflectionPow z 3) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 29)) (reflectionMul (reflectionPow z 3) (reflectionPow w 4)))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 9) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 9) (reflectionPow w 4)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 7) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionMul (reflectionPow r 27) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 27)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 7) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 7) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 12))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 5) (reflectionPow w 8))))))) (reflectionAdd (reflectionAdd (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionPow r 23) (reflectionPow z 5))) (reflectionAdd (reflectionMul (reflectionPow r 23) (reflectionMul (reflectionPow z 3) (reflectionPow w 10))) (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 23)) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 5) (reflectionPow w 8)))))) (reflectionAdd (reflectionAdd (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 5) (reflectionPow w 4))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (reflectionPow z 3) (reflectionPow w 10)))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (reflectionPow z 3) (reflectionPow w 2))) (reflectionAdd (reflectionMul (reflectionPow r 19) (reflectionMul (z) (reflectionPow w 8))) (reflectionMul (reflectionMul ((-1:ℂ)) (reflectionPow r 19)) (reflectionMul (z) (reflectionPow w 4)))))))) +private lemma reflectionComponent12122 : reflectionLeft1 r z w (2,1) (2,2) = reflectionRight1 r z w (2,1) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + have hq:=congrArg (fun x : ℂ=>reflectionCertificate12122 r z w*x) hr + dsimp only [reflectionCertificate12122,reflectionAdd,reflectionMul,reflectionPow] at hq + linear_combination hq + +omit hr in +private lemma reflectionComponent12200 : reflectionLeft1 r z w (2,2) (0,0) = reflectionRight1 r z w (2,2) (0,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12201 : reflectionLeft1 r z w (2,2) (0,1) = reflectionRight1 r z w (2,2) (0,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12202 : reflectionLeft1 r z w (2,2) (0,2) = reflectionRight1 r z w (2,2) (0,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12210 : reflectionLeft1 r z w (2,2) (1,0) = reflectionRight1 r z w (2,2) (1,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12211 : reflectionLeft1 r z w (2,2) (1,1) = reflectionRight1 r z w (2,2) (1,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12212 : reflectionLeft1 r z w (2,2) (1,2) = reflectionRight1 r z w (2,2) (1,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12220 : reflectionLeft1 r z w (2,2) (2,0) = reflectionRight1 r z w (2,2) (2,0) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12221 : reflectionLeft1 r z w (2,2) (2,1) = reflectionRight1 r z w (2,2) (2,1) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +omit hr in +private lemma reflectionComponent12222 : reflectionLeft1 r z w (2,2) (2,2) = reflectionRight1 r z w (2,2) (2,2) := by + simp only [reflectionLeft1,reflectionRight1,Matrix.add_apply,mul_slot2_constant,slot2_constant_mul,mul_slot2_linear,slot2_linear_mul] + simp only [core0_apply,core1_apply] + simp [Fintype.sum_prod_type,Fin.sum_univ_three,dValue,rNumerator] + +theorem reflection_constant : reflectionLeft0 r z w=reflectionRight0 r z w := by + funext p q + rcases p with ⟨a,b⟩ + rcases q with ⟨c,d⟩ + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d + · exact reflectionComponent00000 r z w + · exact reflectionComponent00001 r z w + · exact reflectionComponent00002 r z w + · exact reflectionComponent00010 r z w + · exact reflectionComponent00011 r z w + · exact reflectionComponent00012 r z w + · exact reflectionComponent00020 r z w + · exact reflectionComponent00021 r z w + · exact reflectionComponent00022 r z w + · exact reflectionComponent00100 r z w + · exact reflectionComponent00101 r z w + · exact reflectionComponent00102 r z w + · exact reflectionComponent00110 r z w + · exact reflectionComponent00111 r z w + · exact reflectionComponent00112 r z w + · exact reflectionComponent00120 r z w + · exact reflectionComponent00121 r z w + · exact reflectionComponent00122 r z w + · exact reflectionComponent00200 r z w + · exact reflectionComponent00201 r z w + · exact reflectionComponent00202 r z w + · exact reflectionComponent00210 r z w + · exact reflectionComponent00211 r z w hr + · exact reflectionComponent00212 r z w + · exact reflectionComponent00220 r z w + · exact reflectionComponent00221 r z w + · exact reflectionComponent00222 r z w + · exact reflectionComponent01000 r z w + · exact reflectionComponent01001 r z w + · exact reflectionComponent01002 r z w + · exact reflectionComponent01010 r z w + · exact reflectionComponent01011 r z w + · exact reflectionComponent01012 r z w + · exact reflectionComponent01020 r z w + · exact reflectionComponent01021 r z w + · exact reflectionComponent01022 r z w + · exact reflectionComponent01100 r z w + · exact reflectionComponent01101 r z w + · exact reflectionComponent01102 r z w hr + · exact reflectionComponent01110 r z w + · exact reflectionComponent01111 r z w + · exact reflectionComponent01112 r z w + · exact reflectionComponent01120 r z w hr + · exact reflectionComponent01121 r z w + · exact reflectionComponent01122 r z w + · exact reflectionComponent01200 r z w + · exact reflectionComponent01201 r z w + · exact reflectionComponent01202 r z w + · exact reflectionComponent01210 r z w + · exact reflectionComponent01211 r z w + · exact reflectionComponent01212 r z w + · exact reflectionComponent01220 r z w + · exact reflectionComponent01221 r z w + · exact reflectionComponent01222 r z w + · exact reflectionComponent02000 r z w + · exact reflectionComponent02001 r z w + · exact reflectionComponent02002 r z w + · exact reflectionComponent02010 r z w + · exact reflectionComponent02011 r z w hr + · exact reflectionComponent02012 r z w + · exact reflectionComponent02020 r z w + · exact reflectionComponent02021 r z w + · exact reflectionComponent02022 r z w + · exact reflectionComponent02100 r z w + · exact reflectionComponent02101 r z w + · exact reflectionComponent02102 r z w + · exact reflectionComponent02110 r z w + · exact reflectionComponent02111 r z w + · exact reflectionComponent02112 r z w + · exact reflectionComponent02120 r z w + · exact reflectionComponent02121 r z w + · exact reflectionComponent02122 r z w + · exact reflectionComponent02200 r z w + · exact reflectionComponent02201 r z w + · exact reflectionComponent02202 r z w + · exact reflectionComponent02210 r z w + · exact reflectionComponent02211 r z w + · exact reflectionComponent02212 r z w + · exact reflectionComponent02220 r z w + · exact reflectionComponent02221 r z w + · exact reflectionComponent02222 r z w +theorem reflection_linear : reflectionLeft1 r z w=reflectionRight1 r z w := by + funext p q + rcases p with ⟨a,b⟩ + rcases q with ⟨c,d⟩ + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d + · exact reflectionComponent10000 r z w + · exact reflectionComponent10001 r z w hr + · exact reflectionComponent10002 r z w + · exact reflectionComponent10010 r z w + · exact reflectionComponent10011 r z w + · exact reflectionComponent10012 r z w + · exact reflectionComponent10020 r z w + · exact reflectionComponent10021 r z w + · exact reflectionComponent10022 r z w + · exact reflectionComponent10100 r z w + · exact reflectionComponent10101 r z w + · exact reflectionComponent10102 r z w hr + · exact reflectionComponent10110 r z w + · exact reflectionComponent10111 r z w hr + · exact reflectionComponent10112 r z w + · exact reflectionComponent10120 r z w hr + · exact reflectionComponent10121 r z w + · exact reflectionComponent10122 r z w + · exact reflectionComponent10200 r z w + · exact reflectionComponent10201 r z w + · exact reflectionComponent10202 r z w + · exact reflectionComponent10210 r z w + · exact reflectionComponent10211 r z w + · exact reflectionComponent10212 r z w hr + · exact reflectionComponent10220 r z w + · exact reflectionComponent10221 r z w hr + · exact reflectionComponent10222 r z w + · exact reflectionComponent11000 r z w + · exact reflectionComponent11001 r z w + · exact reflectionComponent11002 r z w hr + · exact reflectionComponent11010 r z w + · exact reflectionComponent11011 r z w hr + · exact reflectionComponent11012 r z w + · exact reflectionComponent11020 r z w hr + · exact reflectionComponent11021 r z w + · exact reflectionComponent11022 r z w + · exact reflectionComponent11100 r z w + · exact reflectionComponent11101 r z w + · exact reflectionComponent11102 r z w + · exact reflectionComponent11110 r z w + · exact reflectionComponent11111 r z w + · exact reflectionComponent11112 r z w hr + · exact reflectionComponent11120 r z w + · exact reflectionComponent11121 r z w hr + · exact reflectionComponent11122 r z w + · exact reflectionComponent11200 r z w + · exact reflectionComponent11201 r z w + · exact reflectionComponent11202 r z w + · exact reflectionComponent11210 r z w + · exact reflectionComponent11211 r z w + · exact reflectionComponent11212 r z w + · exact reflectionComponent11220 r z w + · exact reflectionComponent11221 r z w + · exact reflectionComponent11222 r z w + · exact reflectionComponent12000 r z w + · exact reflectionComponent12001 r z w + · exact reflectionComponent12002 r z w + · exact reflectionComponent12010 r z w + · exact reflectionComponent12011 r z w + · exact reflectionComponent12012 r z w hr + · exact reflectionComponent12020 r z w + · exact reflectionComponent12021 r z w hr + · exact reflectionComponent12022 r z w + · exact reflectionComponent12100 r z w + · exact reflectionComponent12101 r z w + · exact reflectionComponent12102 r z w + · exact reflectionComponent12110 r z w + · exact reflectionComponent12111 r z w + · exact reflectionComponent12112 r z w + · exact reflectionComponent12120 r z w + · exact reflectionComponent12121 r z w + · exact reflectionComponent12122 r z w hr + · exact reflectionComponent12200 r z w + · exact reflectionComponent12201 r z w + · exact reflectionComponent12202 r z w + · exact reflectionComponent12210 r z w + · exact reflectionComponent12211 r z w + · exact reflectionComponent12212 r z w + · exact reflectionComponent12220 r z w + · exact reflectionComponent12221 r z w + · exact reflectionComponent12222 r z w +end +end CriticalHoneycomb.Transfer.Reflection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/ResidualAsymptotics.lean b/lean/OAI/Combinatorics/HoneycombChords/ResidualAsymptotics.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ba8e640ea02e74d8f091bdb2ef8830a402349c8 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/ResidualAsymptotics.lean @@ -0,0 +1,838 @@ +import OAI.Combinatorics.HoneycombChords.CharacteristicProducts +import OAI.Combinatorics.HoneycombChords.ResidualMeans + +namespace OAI + +/-! +# Asymptotic estimates for strip residual means + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology Asymptotics + +lemma movingPole_sq_ge {N : ℕ} (hN : 1 ≤ N) : (N:ℝ) ≤ (movingPole N)^2 := by + have hN' : (1:ℝ) ≤ N := by exact_mod_cast hN + rw [movingPole,← Real.rpow_natCast _ 2,←Real.rpow_mul (Nat.cast_nonneg N)] + calc + (N:ℝ) = (N:ℝ)^(1:ℝ) := (rpow_one _).symm + _ ≤ _ := rpow_le_rpow_of_exponent_le hN' (by norm_num) + +lemma prefix_penalty_uniform {N : ℕ} (hN : 1 ≤ N) {c : ℝ} (hc : 0 ≤ c) : + (1+c/(movingPole N)^2)^(2*N+1) ≤ Real.exp (3*c) := by + have hN' : (1:ℝ) ≤ N := by exact_mod_cast hN + have hT:0<(movingPole N)^2 := lt_of_lt_of_le (by linarith) (movingPole_sq_ge hN) + have hbase: 1+c/(movingPole N)^2 ≤ Real.exp (c/(movingPole N)^2) := by + linarith [Real.add_one_le_exp (c/(movingPole N)^2)] + calc + _ ≤ (Real.exp (c/(movingPole N)^2))^(2*N+1) := + pow_le_pow_left₀ (by positivity) hbase _ + _ = Real.exp ((2*N+1:ℕ)*(c/(movingPole N)^2)) := by rw [Real.exp_nat_mul] + _ ≤ Real.exp (3*c) := by + apply Real.exp_le_exp.mpr + have hh : ((2*N+1:ℕ):ℝ) ≤ 3*(movingPole N)^2 := by + push_cast + nlinarith [movingPole_sq_ge hN] + rw [←mul_div_assoc] + apply (div_le_iff₀ hT).mpr + nlinarith [mul_le_mul_of_nonneg_right hh hc] + +lemma exponential_tail_below_power (a : ℝ) : + ∀ᶠ N : ℕ in atTop,(2/3:ℝ)^N*Real.exp ((Real.log (3/2)/2)*N) ≤ ((N:ℝ)+1)^a := by + let ε : ℝ:=Real.log (3/2)/2 + have he : 0<ε := by dsimp [ε]; exact div_pos (Real.log_pos (by norm_num)) (by norm_num) + have hlim:=((isLittleO_exp_neg_mul_rpow_atTop he a).def (show (0:ℝ)(N:ℝ)+1) atTop atTop := tendsto_atTop_add_const_right atTop 1 tendsto_natCast_atTop_atTop + filter_upwards [ht.eventually hlim] with N hN + have hpos : 0<(N:ℝ)+1 := by positivity + simp only [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _),abs_of_pos (Real.rpow_pos_of_pos hpos _)] at hN + have heq : (2/3:ℝ)^N*Real.exp (ε*N)=Real.exp (-ε*N) := by + rw [←Real.exp_log (by norm_num : (0:ℝ)<2/3),←Real.exp_nat_mul,←Real.exp_add] + congr 1 + dsimp [ε] + rw [Real.log_div (by norm_num : (2:ℝ)≠0) (by norm_num : (3:ℝ)≠0), + Real.log_div (by norm_num : (3:ℝ)≠0) (by norm_num : (2:ℝ)≠0)] + ring + change (2/3:ℝ)^N*Real.exp (ε*N) ≤ _ + rw [heq] + have hx : Real.exp (-ε*N)=Real.exp ε*Real.exp (-ε*((N:ℝ)+1)) := by + rw [←Real.exp_add] + congr 1; ring + rw [hx] + have h:=mul_le_mul_of_nonneg_left hN (le_of_lt (Real.exp_pos ε)) + have hc : Real.exp ε*Real.exp (-ε)=1 := by rw [←Real.exp_add,add_neg_cancel,Real.exp_zero] + simpa only [←mul_assoc,hc,one_mul] using h + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Real Filter Topology + +lemma stripJet_familyGram (N : ℕ) (s t : ℝ) (w : ℝ → ℝ) : + familyGram w (stripJetFamily N s) (stripJetFamily N t)= + jetGram (n:=2*N+1) w (interiorKnotLabels N s) (interiorKnotLabels N t) := rfl + +lemma jetFixedMean_bounds {u : ℝ} (hu : 0(hZero x).re) (-u) ∧ + meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hZero x).re) (-u) ≤ A*P ∧ + a*P ≤ meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hOne x).re) (-u) ∧ + meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hOne x).re) (-u) ≤ A*P := by + obtain ⟨a,A,ha,hA,hbound⟩:=jetFixedMean_bounds hu hu4 + let E : ℝ:=Real.exp (3*physicalPole 0) + let ε : ℝ:=Real.log (3/2)/2 + have he : 0<ε := by dsimp [ε]; exact div_pos (Real.log_pos (by norm_num)) (by norm_num) + refine ⟨a/2,2*E*A+2,by positivity,by dsimp [E];positivity,?_⟩ + filter_upwards [hbound,jetMovingMean_bound he,exponential_tail_below_power (3*(Real.sqrt u-8/3)/8), + eventually_ge_atTop (1:ℕ)] with N hB hM htail hN + intro s t hs hsL ht htL + dsimp only + let P : ℝ:=((N:ℝ)+1)^(3*(Real.sqrt u-8/3)/8) + have hP : 0

(hZero x).re) (-4) ∧ + meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hZero x).re) (-4) ≤ A*P ∧ + a*P ≤ meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hOne x).re) (-4) ∧ + meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) (fun x=>(hOne x).re) (-4) ≤ A*P := by + have h:=physical_means_asymptotic (u:=4) (by norm_num) le_rfl + norm_num at h ⊢ + exact h + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology + +noncomputable def parameterFamily (N : ℕ) (t : ℝ) : Fin (2*N+1) → ℝ → ℝ := + Function.update (fixedFamily N) (centralIndex N) (cosineKernelJet 0 0 (t^2)) +lemma parameterFamily_interior (N : ℕ) {t : ℝ} (ht : 0∫ p in Set.Ioi 0,F j (p^2)*H (p^2)*w p) := by + ext j k + rw [Matrix.updateCol_apply] + by_cases hk : k=i + · subst k + simp only [familyGram,Function.update_self,ite_true] + · simp only [familyGram,Function.update_of_ne hk,ite_eq_right hk] + +lemma cosineMoment_as_cosh (q : ℝ → ℝ) (t : ℝ) : + (∫ p in Set.Ioi 0,q p*cosineKernelJet 0 0 (t^2) (p^2))= + ∫ p in Set.Ioi 0,q p*Real.cosh (t*p) := by + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + congr 1 + apply Complex.ofReal_injective + rw [←C_eq_beta_square,C_sq _ hp.le] + +lemma parameterGram_continuousOn {n : ℕ} (N : ℕ) (w : ℝ → ℝ) (F : Fin n → ℝ → ℝ) + (hqm : ∀ i,Measurable (fun p=>F i (p^2)*w p)) + (hqi : ∀ i,IntegrableOn (fun p=>|F i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) : + ContinuousOn (fun t : ℝ=>fun i : Fin n=>fun j : Fin (2*N+1)=> + ∫ p in Set.Ioi 0,F i (p^2)*parameterFamily N t j (p^2)*w p) (Set.Icc 0 angle) := by + apply continuousOn_pi.mpr + intro i + apply continuousOn_pi.mpr + intro j + by_cases hj : j=centralIndex N + · subst j + simp only [parameterFamily,Function.update_self] + have he (t : ℝ) : (∫ p in Set.Ioi 0,F i (p^2)*cosineKernelJet 0 0 (t^2) (p^2)*w p)= + ∫ p in Set.Ioi 0,(F i (p^2)*w p)*Real.cosh (t*p) := by + rw [←cosineMoment_as_cosh] + congr 1 + funext p + ring + simp_rw [he] + exact cosh_pair_continuousOn _ (hqm i) (hqi i) + · simp only [parameterFamily,Function.update_of_ne hj] + exact continuousOn_const + +lemma mixedGram_det_integral (N : ℕ) (w : ℝ → ℝ) (F : Fin (2*N+1) → ℝ → ℝ) + (hqm : ∀ i,Measurable (fun p=>F i (p^2)*w p)) + (hqi : ∀ i,IntegrableOn (fun p=>|F i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) : + (familyGram w F (mixedFamily N)).det= + ∫ t in (0:ℝ)..angle,(familyGram w F (parameterFamily N t)).det := by + have hvec : ContinuousOn (fun t=>fun j=>∫ p in Set.Ioi 0,(F j (p^2)*w p)*Real.cosh (t*p)) + (Set.uIcc 0 angle) := by + rw [Set.uIcc_of_le strip_angle_pos.le] + exact continuousOn_pi.mpr (fun j=>cosh_pair_continuousOn _ (hqm j) (hqi j)) + have he (i : Fin (2*N+1)) : (∫ p in Set.Ioi 0,F i (p^2)*realG (p^2)*w p)= + ∫ t in (0:ℝ)..angle,∫ p in Set.Ioi 0,(F i (p^2)*w p)*Real.cosh (t*p) := by + rw [←cosh_pair_fubini _ (hqm i) (hqi i)] + congr 1 + funext p + ring + rw [mixedFamily,familyGram_update_right] + simp_rw [he] + rw [colDet_integral _ _ _ hvec.intervalIntegrable] + apply intervalIntegral.integral_congr + intro t ht + dsimp only + unfold parameterFamily + rw [familyGram_update_right] + congr 2 + funext i + rw [←cosineMoment_as_cosh] + congr 1 + funext p + ring + +lemma mixedGram_ratio_bounds (N : ℕ) (w : ℝ → ℝ) (F R : Fin (2*N+1) → ℝ → ℝ) (a A : ℝ) + (hfm : ∀ i,Measurable (fun p=>F i (p^2)*w p)) + (hfi : ∀ i,IntegrableOn (fun p=>|F i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) + (hrm : ∀ i,Measurable (fun p=>R i (p^2)*w p)) + (hri : ∀ i,IntegrableOn (fun p=>|R i (p^2)*w p| *Real.cosh (angle*p)) (Set.Ioi 0)) + (hd : 0<(familyGram w F (mixedFamily N)).det) + (hdt : ∀ t,0(familyGram w F (parameterFamily N t)).det) (Set.uIcc 0 angle) := by + rw [Set.uIcc_of_le strip_angle_pos.le] + exact (continuous_id.matrix_det).comp_continuousOn (parameterGram_continuousOn N w F hfm hfi) + have hcontR : ContinuousOn (fun t=>(familyGram w R (parameterFamily N t)).det) (Set.uIcc 0 angle) := by + rw [Set.uIcc_of_le strip_angle_pos.le] + exact (continuous_id.matrix_det).comp_continuousOn (parameterGram_continuousOn N w R hrm hri) + have hlo:=intervalIntegral.integral_mono_on_of_le_Ioo (μ:=volume) strip_angle_pos.le + (hcontF.intervalIntegrable.const_mul a) hcontR.intervalIntegrable + (fun t ht=>by + rw [parameterFamily_interior N ht.1 ht.2] + exact (le_div_iff₀ (hdt t ht.1 ht.2)).mp (hb t ht.1 ht.2).1) + have hup:=intervalIntegral.integral_mono_on_of_le_Ioo (μ:=volume) strip_angle_pos.le + hcontR.intervalIntegrable (hcontF.intervalIntegrable.const_mul A) + (fun t ht=>by + rw [parameterFamily_interior N ht.1 ht.2] + exact (div_le_iff₀ (hdt t ht.1 ht.2)).mp (hb t ht.1 ht.2).2) + rw [intervalIntegral.integral_const_mul,←mixedGram_det_integral N w F hfm hfi, + ←mixedGram_det_integral N w R hrm hri] at hlo + rw [intervalIntegral.integral_const_mul,←mixedGram_det_integral N w F hfm hfi, + ←mixedGram_det_integral N w R hrm hri] at hup + exact ⟨(le_div_iff₀ hd).mpr hlo,(div_le_iff₀ hd).mpr hup⟩ + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology + +lemma fixedFamily_measurable (N : ℕ) (i : Fin (2*N+1)) : + Measurable (fun p=>fixedFamily N i (p^2)*stripDensity p) := by + have hc : Continuous (fun p : ℝ=>fixedFamily N i (p^2)) := + (cosineKernelJet_contDiff_right _ 0 _ 0).continuous.comp (by fun_prop) + exact hc.measurable.mul (by unfold stripDensity;fun_prop) + +lemma weighted_cosh_norm_integrable {q : ℝ → ℝ} + (hi : IntegrableOn (fun p=>q p*Real.cosh (angle*p)) (Set.Ioi 0)) : + IntegrableOn (fun p=>|q p| *Real.cosh (angle*p)) (Set.Ioi 0) := by + apply hi.norm.congr + filter_upwards with p + simp only [Real.norm_eq_abs,abs_mul,abs_of_pos (Real.cosh_pos _)] + +lemma weighted_cosh_signed_integrable {q : ℝ → ℝ} (hq : Measurable q) + (hi : IntegrableOn (fun p=>|q p| *Real.cosh (angle*p)) (Set.Ioi 0)) : + IntegrableOn (fun p=>q p*Real.cosh (angle*p)) (Set.Ioi 0) := by + apply hi.mono' (hq.mul (by fun_prop)).aestronglyMeasurable + filter_upwards with p + simp only [Pi.mul_apply,Real.norm_eq_abs,abs_mul,abs_of_pos (Real.cosh_pos _),le_refl] + +lemma fixedFamily_cosh_integrable (N : ℕ) (i : Fin (2*N+1)) : + IntegrableOn (fun p=>|fixedFamily N i (p^2)*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0) := by + apply weighted_cosh_norm_integrable + have hi:=strip_jet_pair_integrable (interiorKnot_nonneg N i (angle/2)) (sq_nonneg angle) + ((interiorKnot_le N i (half_pos strip_angle_pos) (by linarith [strip_angle_pos])).trans + (by nlinarith [sq_nonneg angle])) le_rfl (nodalOrder (interiorKnotLabels N (angle/2)) i) 0 + apply hi.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have he : cosineKernelJet 0 0 (angle^2) (p^2)=Real.cosh (angle*p) := by + apply Complex.ofReal_injective + rw [←C_eq_beta_square,C_sq _ hp.le] + change fixedFamily N i (p^2)*cosineKernelJet 0 0 (angle^2) (p^2)*stripDensity p=_ + rw [he] + ring + +lemma bounded_target_cosh_integrable (H : ℝ → ℝ) (hHm : Measurable (fun p=>H (p^2))) + (hH : ∀ p : ℝ,0

|H (p^2)*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0) := by + have hi:=strip_jet_pair_integrable (b:=0) (c:=angle^2) + (by rfl) (sq_nonneg angle) (by positivity) le_rfl 0 0 + simp only [cosineKernelJet_at_zero,pow_zero,mul_zero,Nat.factorial_zero,Nat.cast_one,div_one,one_mul] at hi + apply hi.mono' + · exact (((hHm.mul (by unfold stripDensity;fun_prop)).abs).mul (by fun_prop)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hw:=(stripDensity_pos hp).le + have hH0:=(hH p hp).1 + have he : cosineKernelJet 0 0 (angle^2) (p^2)=Real.cosh (angle*p) := by + apply Complex.ofReal_injective + rw [←C_eq_beta_square,C_sq _ hp.le] + rw [Real.norm_of_nonneg (mul_nonneg (abs_nonneg _) (Real.cosh_pos _).le), + abs_of_nonneg (mul_nonneg hH0 hw),he] + nlinarith [mul_nonneg (sub_nonneg.mpr (hH p hp).2) (mul_nonneg hw (Real.cosh_pos (angle*p)).le)] + +lemma residual_cosh_integrable {n : ℕ} (F : Fin n → ℝ → ℝ) (H : ℝ → ℝ) (a : ℝ) + (hFm : ∀ i,Measurable (fun p=>F i (p^2)*stripDensity p)) + (hHm : Measurable (fun p=>H (p^2)*stripDensity p)) + (hFi : ∀ i,IntegrableOn (fun p=>|F i (p^2)*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0)) + (hHi : IntegrableOn (fun p=>|H (p^2)*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0)) : + ∀ i,Measurable (fun p=>residualFamily F H a i (p^2)*stripDensity p) ∧ + IntegrableOn (fun p=>|residualFamily F H a i (p^2)*stripDensity p| *Real.cosh (angle*p)) (Set.Ioi 0) := by + intro i + have he : (fun p=>residualFamily F H a i (p^2)*stripDensity p)= + (fun p=>F i (p^2)*stripDensity p-(F i a/H a)*(H (p^2)*stripDensity p)) := by + funext p + simp only [residualFamily] + ring + rw [he] + refine ⟨(hFm i).sub (hHm.const_mul _),?_⟩ + apply weighted_cosh_norm_integrable + convert (weighted_cosh_signed_integrable (hFm i) (hFi i)).sub + ((weighted_cosh_signed_integrable hHm hHi).const_mul (F i a/H a)) using 1 + funext p + simp only [Pi.sub_apply,residualFamily] + ring + +lemma hZero_sq_measurable : Measurable (fun p=>(hZero (p^2)).re) := by + have he : (fun p=>(hZero (p^2)).re)=fun p=>1/(2*Real.cosh (angle*Real.sqrt (p^2))-1) := by + funext p + simp only [hZero,D,C,ite_eq_left (sq_nonneg p)] + norm_cast + simp only [one_div] + rw [he] + fun_prop + +lemma hOne_sq_measurable : Measurable (fun p=>(hOne (p^2)).re) := by + have he : (fun p=>(hOne (p^2)).re)=fun p=>Real.cosh ((angle/2)*Real.sqrt (p^2))/(2*Real.cosh (angle*Real.sqrt (p^2))-1) := by + funext p + simp only [hOne,D,C,ite_eq_left (sq_nonneg p)] + norm_cast + rw [he] + fun_prop + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +/-! The positive mixture retains the distinct left and right Gram families. -/ +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix MeasureTheory Filter Topology + +lemma mixedMean_bounds (N : ℕ) (H : ℝ → ℝ) (x a A : ℝ) + (hHm : Measurable (fun p=>H (p^2))) + (hH : ∀ p : ℝ,0

H (p^2)*stripDensity p) := hHm.mul (by unfold stripDensity;fun_prop) + have hr:=residual_cosh_integrable (fixedFamily N) H x (fixedFamily_measurable N) hm + (fixedFamily_cosh_integrable N) (bounded_target_cosh_integrable H hHm hH) + exact mixedGram_ratio_bounds N stripDensity (fixedFamily N) (residualFamily (fixedFamily N) H x) a A + (fixedFamily_measurable N) (fixedFamily_cosh_integrable N) (fun i=>(hr i).1) (fun i=>(hr i).2) + (fixed_mixed_Gram_det_pos N) + (fun t ht htL=>stripJet_gram_det_pos N (half_pos strip_angle_pos) (by linarith [strip_angle_pos]) ht htL) hb + +theorem mixed_physical_means_asymptotic {u : ℝ} (hu : 0(hZero x).re) (-u) ∧ + meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) (fun x=>(hZero x).re) (-u) ≤ A*P ∧ + a*P ≤ meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) (fun x=>(hOne x).re) (-u) ∧ + meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) (fun x=>(hOne x).re) (-u) ≤ A*P := by + obtain ⟨a,A,ha,hA,hB⟩:=physical_means_asymptotic hu hu4 + refine ⟨a,A,ha,hA,?_⟩ + filter_upwards [hB] with N hN + have hs : 0(hZero x).re) (-u) _ _ hZero_sq_measurable + (fun _ hp=>hZero_sq_unit hp.le) + (fun t ht htL=>⟨(hN (angle/2) t hs hsL ht htL).1,(hN (angle/2) t hs hsL ht htL).2.1⟩) + have h₁:=mixedMean_bounds N (fun x=>(hOne x).re) (-u) _ _ hOne_sq_measurable + (fun _ hp=>hOne_sq_unit hp.le) + (fun t ht htL=>(hN (angle/2) t hs hsL ht htL).2.2) + exact ⟨h₀.1,h₀.2,h₁⟩ + +/-- Normalized residuals for the two mixed families have exponent `-1/4`. -/ +theorem mixed_physical_means_at_minus_four : + ∃ a A : ℝ,0(hZero x).re) (-4) ∧ + meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) (fun x=>(hZero x).re) (-4) ≤ A*P ∧ + a*P ≤ meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) (fun x=>(hOne x).re) (-4) ∧ + meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) (fun x=>(hOne x).re) (-4) ≤ A*P := by + have h:=mixed_physical_means_asymptotic (u:=4) (by norm_num) le_rfl + norm_num at h ⊢ + exact h + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open Matrix MeasureTheory Filter Topology StripAsymptotic + +lemma pairingDomain_real_integrable {N : ℕ} {H : ℝ → ℂ} + (hr : ∀ x,((H x).re:ℂ)=H x) (hH : InPairingDomain N H) (j : Fin (2*N+1)) : + IntegrableOn (fun p=>(H (p^2)).re*mixedFamily N j (p^2)*stripDensity p) (Set.Ioi 0) := by + apply (hH j).re.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have he : H=fun x=>((H x).re:ℂ) := by funext x;exact (hr x).symm + rw [he] + change (pairingKernel (fun x=>((H x).re:ℂ)) (fun x=>(mixedFamily N j x:ℂ)) p).re=_ + rw [pairingKernel_ofReal _ _ hp.le,Complex.ofReal_re] + rfl + +lemma source_residual_mean {N : ℕ} {H : ℝ → ℂ} {a : ℝ} + (hr : ∀ x,((H x).re:ℂ)=H x) (hH : InPairingDomain N H) (ha : (H a).re≠0) : + obliqueResidual N H a= + (((H a).re*meanResidualRatio stripDensity (fixedFamily N) (mixedFamily N) (fun x=>(H x).re) a:ℝ):ℂ) := by + have he : H=(fun x=>((H x).re:ℂ)) := by funext x;exact (hr x).symm + conv_lhs => rw [he] + exact residual_ofReal_mean N _ ha (pairingDomain_real_integrable hr hH) + +theorem source_h_residuals_at_minus_four : + ∃ a A : ℝ,0 -F i 0) + have he : A.det=B.det := by + apply Matrix.det_eq_of_forall_row_eq_smul_add_const c (Fin.last n) (by simp [c]) + intro i j + refine Fin.lastCases ?_ (fun i=>?_) i + · simp [A,B,c,evaluationMatrix] + · simp only [A,B,c,evaluationMatrix,Fin.lastCases_castSucc,Fin.lastCases_last, + residualFamily,hH,div_one] + ring + rw [Matrix.det_succ_column_zero,Fin.sum_univ_castSucc] at he + have hz : (∑ i : Fin n,(-1:ℝ)^(i.castSucc.val)*A i.castSucc 0* + (A.submatrix i.castSucc.succAbove Fin.succ).det)=0 := by + apply sum_eq_zero + intro i _ + simp [A,evaluationMatrix,residualFamily,hH] + rw [hz,zero_add] at he + have hm : A.submatrix (Fin.last n).succAbove Fin.succ= + evaluationMatrix (residualFamily F H 0) x := by + ext i j + simp [A,Matrix.submatrix,evaluationMatrix,Fin.succAbove_last] + simpa only [hm,A,B,evaluationMatrix,Fin.lastCases_last,Fin.cons_zero,hH, + Fin.val_last,mul_one] using he + +lemma cThree_real (x : ℝ) : (C (3*angle/2) x).re=cosineKernelJet 0 0 ((3*angle/2)^2) x := by + rw [C_eq_beta_square,Complex.ofReal_re] + +lemma cThree_zero : (C (3*angle/2) 0).re=1 := by simp [C] + +lemma extendedKnot_last (N : ℕ) : + extendedKnotLabels N (2*N+1)=(3*angle/2)^2 := by + simp [extendedKnotLabels] + +lemma extendedKnot_last_order (N : ℕ) : nodalOrder (extendedKnotLabels N) (2*N+1)=0 := by + unfold nodalOrder + apply card_eq_zero.mpr + apply eq_empty_iff_forall_notMem.mpr + intro j hj + simp only [mem_filter,mem_range] at hj + have h:=interiorKnot_le N j (half_pos strip_angle_pos) (by linarith [strip_angle_pos]) + rw [extendedKnot_before N j hj.1,extendedKnot_last] at hj + have hpos:=strip_angle_pos + nlinarith [h] + +lemma extended_family (N : ℕ) : + (fun i : Fin (2*N+2)=>cosineKernelJet (nodalOrder (extendedKnotLabels N) i) 0 + (extendedKnotLabels N i))=Fin.lastCases (fun x=>(C (3*angle/2) x).re) (fixedFamily N) := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i + · simp only [Fin.val_last,Fin.lastCases_last,extendedKnot_last_order,extendedKnot_last] + funext x + exact (cThree_real x).symm + · simp only [Fin.lastCases_castSucc,Fin.val_castSucc,fixedFamily] + rw [extendedKnot_before N i i.isLt,extendedKnot_order_before N i i.isLt] + +lemma cThree_residual_evaluation_neg (N : ℕ) (x : Fin (2*N+1) → ℝ) + (hx : StrictMono x) (hx0 : ∀ i,0(C (3*angle/2) x).re) 0) x).det<0 := by + have h:=residual_det_augment (fixedFamily N) (fun x=>(C (3*angle/2) x).re) cThree_zero x + have hp : 0<(evaluationMatrix (Fin.lastCases (fun x=>(C (3*angle/2) x).re) (fixedFamily N)) + (Fin.cons 0 x)).det := by + rw [←extended_family] + apply jetEvaluation_det_pos (extendedKnotLabels N) (Fin.cons 0 x) + · exact (extendedKnot_monotone N).comp (fun _ _ h=>h) + · intro i j + refine Fin.cases ?_ (fun i=>?_) i + · refine Fin.cases (fun h=>False.elim (lt_irrefl _ h)) (fun j _=>hx0 j) j + · refine Fin.cases (fun h=>False.elim (Fin.not_lt_zero _ h)) + (fun j h=>hx (Fin.succ_lt_succ_iff.mp h)) j + · intro i + exact extendedKnot_nonneg N i + · exact Fin.cases le_rfl (fun i=>(hx0 i).le) + have hn : (-1:ℝ)^(2*N+1)= -1 := by simp [pow_add,pow_mul] + rw [hn] at h + linarith + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset Honeycomb370 Filter Topology Set + +lemma evaluation_unitLast_column_det {n : ℕ} (F : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (x : Fin (n+1) → ℝ) (i : Fin (n+1)) : + ((evaluationMatrix (Fin.lastCases H F) x).updateCol i (Pi.single (Fin.last n) 1)).det = + (-1:ℝ)^(n+i.val) * (evaluationMatrix F (x ∘ i.succAbove)).det := by + rw [Matrix.det_succ_column _ i] + rw [Finset.sum_eq_single (Fin.last n)] + · simp only [Matrix.updateCol_self,Pi.single_eq_same,Fin.val_last,mul_one] + congr 1 + congr 1 + ext a b + simp [Matrix.submatrix,evaluationMatrix,Fin.succAbove_last, + Fin.succAbove_ne] + · intro j _ hj + simp [hj] + · simp + +lemma augmented_monomial_det {n : ℕ} (x : Fin n → ℝ) (a : ℝ) : + (evaluationMatrix (Fin.lastCases (fun t : ℝ ↦ t^n) + (fun i : Fin n ↦ fun t : ℝ ↦ t^i.val)) (Fin.cons a x)).det = + (∏ i,(x i-a)) * (evaluationMatrix (fun i : Fin n ↦ fun t : ℝ ↦ t^i.val) x).det := by + have he : Fin.lastCases (fun t : ℝ ↦ t^n) + (fun i : Fin n ↦ fun t : ℝ ↦ t^i.val) = fun i : Fin (n+1) ↦ fun t : ℝ ↦ t^i.val := by + funext i + refine Fin.lastCases ?_ (fun j ↦ ?_) i <;> simp + rw [he] + change (Matrix.vandermonde (Fin.cons a x)).transpose.det = + _ * (Matrix.vandermonde x).transpose.det + rw [Matrix.det_transpose,Matrix.det_transpose,vandermonde_cons_det] + +/-- Raising one ordered node raises the generalized interpolation error at +an earlier positive point. Both the original and augmented systems have +positive evaluation determinants; no monotonicity conclusion is an input. -/ +lemma augmented_ratio_coordinate {n : ℕ} (F : Fin n → ℝ → ℝ) (H : ℝ → ℝ) + (hF : PositiveEvaluation F) (hA : PositiveEvaluation (Fin.lastCases H F)) + (x : Fin n → ℝ) (i : Fin n) (r a : ℝ) + (ha : 0 simp [Q,P] + rw [he] + exact monomial_positiveEvaluation _ + let z : Fin (n+1) → ℝ := Fin.cons a x + let k := i.succ + let e : Fin (n+1) → ℝ := Pi.single (Fin.last n) 1 + have hk : (0 : Fin (n+1)) ≠ k := (Fin.succ_ne_zero i).symm + have hsort : (evaluationMatrix (Fin.lastCases H F) z).det ≠ 0 := + (hA z hmono hp).ne' + have hpsort : (evaluationMatrix (Fin.lastCases Q P) z).det ≠ 0 := + (hQ z hmono hp).ne' + have hd:=determinant_column_diamond (evaluationMatrix (Fin.lastCases H F) z) hsort + 0 k hk e (fun j ↦ Fin.lastCases H F j r) + have hpd:=determinant_column_diamond (evaluationMatrix (Fin.lastCases Q P) z) hpsort + 0 k hk e (fun j ↦ Fin.lastCases Q P j r) + have hu (K : Fin (n+1) → ℝ → ℝ) : + (evaluationMatrix K z).updateCol k (fun j ↦ K j r) = + evaluationMatrix K (Fin.cons a (Function.update x i r)) := by + ext j l + refine Fin.cases ?_ (fun l ↦ ?_) l + · simp [z,k,hk,evaluationMatrix] + · by_cases hl : l=i <;> simp [z,k,evaluationMatrix,hl] + have hv (K : Fin (n+1) → ℝ → ℝ) : + (evaluationMatrix K z).updateCol 0 (fun j ↦ K j r) = + evaluationMatrix K (Fin.cons r x) := by + ext j l + refine Fin.cases ?_ (fun l ↦ ?_) l <;> + simp [z,evaluationMatrix] + have hun (K : Fin n → ℝ → ℝ) (J : ℝ → ℝ) : + (((evaluationMatrix (Fin.lastCases J K) z).updateCol 0 e).updateCol k + (fun j ↦ Fin.lastCases J K j r)).det = + (-1:ℝ)^n*(evaluationMatrix K (Function.update x i r)).det := by + rw [Matrix.updateCol_comm _ hk,hu,evaluation_unitLast_column_det] + simp only [Fin.val_zero,add_zero] + congr 2 + have hzc : Function.Injective (Fin.cons r x) := by + apply Fin.cons_injective_iff.mpr + refine ⟨?_,hx.injective⟩ + rintro ⟨j,he⟩ + by_cases hji : j=i + · subst j; exact hr.ne he + · have heq : Function.update x i r i = Function.update x i r j := by simp [he,hji] + exact hji (hy.injective heq).symm + have hpz : ∀ j : Fin (n+1),0<(Fin.cons r x : Fin (n+1) → ℝ) j := by + intro j + exact Fin.cases ((hx0 i).trans hr) (fun l ↦ hx0 l) j + have hcross₁ := evaluation_det_product_pos (Fin.lastCases H F) (Fin.lastCases Q P) + hA hQ (Fin.cons r x) hzc hpz + have hzmin : Function.Injective (z ∘ k.succAbove) := hmono.injective.comp Fin.succAbove_right_injective + have hcross₂ := evaluation_det_product_pos F P hF hP (z ∘ k.succAbove) + hzmin (fun j ↦ hp (k.succAbove j)) + have he0 (K : Fin n → ℝ → ℝ) (J : ℝ → ℝ) : + ((evaluationMatrix (Fin.lastCases J K) z).updateCol 0 e).det = + (-1:ℝ)^n*(evaluationMatrix K x).det := by + rw [evaluation_unitLast_column_det] + simp [z,Function.comp_def] + rw [he0,hu,hun,hv,evaluation_unitLast_column_det] at hd hpd + have hs : ((-1:ℝ)^(n+k.val))^2=1 := by rw [←pow_mul,mul_comm (n+k.val) 2,pow_mul]; norm_num + have hcross : ( (-1:ℝ)^n * + ((evaluationMatrix F x).det * + (evaluationMatrix (Fin.lastCases H F) (Fin.cons a (Function.update x i r))).det - + (evaluationMatrix (Fin.lastCases H F) z).det * (evaluationMatrix F (Function.update x i r)).det)) * + ((-1:ℝ)^n * + ((evaluationMatrix P x).det * + (evaluationMatrix (Fin.lastCases Q P) (Fin.cons a (Function.update x i r))).det - + (evaluationMatrix (Fin.lastCases Q P) z).det * (evaluationMatrix P (Function.update x i r)).det)) > 0 := by + have hd' : (-1:ℝ)^n * + ((evaluationMatrix F x).det * + (evaluationMatrix (Fin.lastCases H F) (Fin.cons a (Function.update x i r))).det - + (evaluationMatrix (Fin.lastCases H F) z).det * (evaluationMatrix F (Function.update x i r)).det) = + (evaluationMatrix (Fin.lastCases H F) (Fin.cons r x)).det * + ((-1:ℝ)^(n+k.val)*(evaluationMatrix F (z ∘ k.succAbove)).det) := by + linear_combination hd + have hpd' : (-1:ℝ)^n * + ((evaluationMatrix P x).det * + (evaluationMatrix (Fin.lastCases Q P) (Fin.cons a (Function.update x i r))).det - + (evaluationMatrix (Fin.lastCases Q P) z).det * (evaluationMatrix P (Function.update x i r)).det) = + (evaluationMatrix (Fin.lastCases Q P) (Fin.cons r x)).det * + ((-1:ℝ)^(n+k.val)*(evaluationMatrix P (z ∘ k.succAbove)).det) := by + linear_combination hpd + rw [hd',hpd'] + have hmul:=mul_pos hcross₁ hcross₂ + have heq : + (evaluationMatrix (Fin.lastCases H F) (Fin.cons r x)).det * + ((-1:ℝ)^(n+k.val)*(evaluationMatrix F (z ∘ k.succAbove)).det) * + ((evaluationMatrix (Fin.lastCases Q P) (Fin.cons r x)).det * + ((-1:ℝ)^(n+k.val)*(evaluationMatrix P (z ∘ k.succAbove)).det)) = + ((-1:ℝ)^(n+k.val))^2 * + ((evaluationMatrix (Fin.lastCases H F) (Fin.cons r x)).det * + (evaluationMatrix (Fin.lastCases Q P) (Fin.cons r x)).det) * + ((evaluationMatrix F (z ∘ k.succAbove)).det * (evaluationMatrix P (z ∘ k.succAbove)).det) := by ring + rw [heq,hs,one_mul] + exact hmul + have hvprod : (∏ j,(x j-a)) ≤ ∏ j,(Function.update x i r j-a) := by + apply Finset.prod_le_prod₀ + · intro j _; exact sub_nonneg.mpr (hax j).le + · intro j _ + by_cases hj : j=i + · subst j; simp; exact hr.le + · simp [hj] + have hdiff : 0 ≤ (evaluationMatrix P x).det * + (evaluationMatrix (Fin.lastCases Q P) (Fin.cons a (Function.update x i r))).det - + (evaluationMatrix (Fin.lastCases Q P) z).det * (evaluationMatrix P (Function.update x i r)).det := by + dsimp only [P,Q,z] + rw [augmented_monomial_det,augmented_monomial_det] + have hl:=hP x hx hx0 + have hu:=hP _ hy hy0 + nlinarith [mul_nonneg (sub_nonneg.mpr hvprod) (mul_pos hl hu).le] + have hn : ((-1:ℝ)^n)^2=1 := by rw [←pow_mul,mul_comm n 2,pow_mul]; norm_num + have hdiffF : (evaluationMatrix (Fin.lastCases H F) z).det * + (evaluationMatrix F (Function.update x i r)).det ≤ + (evaluationMatrix (Fin.lastCases H F) (Fin.cons a (Function.update x i r))).det * + (evaluationMatrix F x).det := by + have hcross' : 0 < + ((evaluationMatrix F x).det * + (evaluationMatrix (Fin.lastCases H F) (Fin.cons a (Function.update x i r))).det - + (evaluationMatrix (Fin.lastCases H F) z).det * (evaluationMatrix F (Function.update x i r)).det) * + ((evaluationMatrix P x).det * + (evaluationMatrix (Fin.lastCases Q P) (Fin.cons a (Function.update x i r))).det - + (evaluationMatrix (Fin.lastCases Q P) z).det * (evaluationMatrix P (Function.update x i r)).det) := by + convert hcross using 1 + rw [show ∀ b c : ℝ, ((-1:ℝ)^n*b)*((-1:ℝ)^n*c)=((-1:ℝ)^n)^2*(b*c) by intros; ring,hn,one_mul] + have hh:=pos_of_mul_pos_left hcross' hdiff + linarith + exact (div_le_div_iff₀ (hF x hx hx0) (hF _ hy hy0)).mpr hdiffF + +lemma augmented_ratio_monotone_pos {n : ℕ} (F : Fin n → ℝ → ℝ) (H : ℝ → ℝ) + (hF : PositiveEvaluation F) (hA : PositiveEvaluation (Fin.lastCases H F)) + {x y : Fin n → ℝ} (hxy : x≤y) (hx : StrictMono x) (hy : StrictMono y) + (a : ℝ) (ha : 0(p (σ i))^2)=(evaluationMatrix K (fun i=>(p i)^2)).submatrix id σ := rfl + simp only [familyPointDensity,Function.comp_apply,he,Matrix.det_permute'] + have hp : (∏ i,w (p (σ i)))=∏ i,w (p i) := Equiv.prod_comp σ (fun i=>w (p i)) + rw [hp] + have hs : (((Perm.sign σ:ℤ):ℝ))*(((Perm.sign σ:ℤ):ℝ))=1 := by + rw [←Int.cast_mul,←Units.val_mul,Int.units_mul_self];norm_num + calc + _=((((Perm.sign σ:ℤ):ℝ))*(((Perm.sign σ:ℤ):ℝ)))* + ((∏ i,w (p i))*(evaluationMatrix F (fun i=>(p i)^2)).det* + (evaluationMatrix G (fun i=>(p i)^2)).det) := by ring + _=_ := by rw [hs,one_mul] + +lemma familyPointDensity_eq_zero_of_not_injective {n : ℕ} (w : ℝ → ℝ) + (F G : Fin n → ℝ → ℝ) (p : Fin n → ℝ) (hp : ¬Function.Injective p) : + familyPointDensity w F G p=0 := by + obtain ⟨i,j,he,hij⟩:=Function.not_injective_iff.mp hp + have hz : (evaluationMatrix F (fun i=>(p i)^2)).det=0 := by + apply Matrix.det_zero_of_column_eq hij + intro k + simp only [evaluationMatrix,he] + rw [familyPointDensity,hz,mul_zero,zero_mul] + +/-- Sorting is legitimate for the actual product of the two, possibly +nonsymmetric, evaluation determinants: both acquire the same sign. -/ +lemma pointDensity_bound_of_sorted {n : ℕ} (w w₁ w₂ : ℝ → ℝ) (F G R : Fin n → ℝ → ℝ) + (A B : ℝ) + (hb : ∀ p : Fin n → ℝ,StrictMono p → (∀ i,0

x i+u) (fun y=>1-H (y-u)/H (-u))= + (evaluationMatrix (residualFamily (fun i : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i)) H (-u)) + (fun i=>x i)).det / (jetEvaluation b (fun i : Fin n=>x i)).det := by + have he : translatedKernelMatrix (n:=n) b u (fun i=>x i+u)=jetEvaluation b (fun i : Fin n=>x i) := by + ext i j + dsimp [translatedKernelMatrix,jetEvaluation] + congr 1 ; ring + have hR : kernelComplementMatrix (n:=n) b u (fun i=>x i+u) (fun y=>1-H (y-u)/H (-u))= + evaluationMatrix (residualFamily (fun i : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i)) H (-u)) + (fun i=>x i) := by + ext i j + dsimp [kernelComplementMatrix,evaluationMatrix,residualFamily] + rw [show -u+(x j+u)=x j by ring,show x j+u-u=x j by ring] + ring + rw [kernelOriginFunctional,he,hR] + +lemma normalized_residual_density {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) (p : Fin n → ℝ) + (hd : (evaluationMatrix F (fun i=>(p i)^2)).det≠0) : + familyPointDensity w (residualFamily F H a) G p= + ((evaluationMatrix (residualFamily F H a) (fun i=>(p i)^2)).det / + (evaluationMatrix F (fun i=>(p i)^2)).det)*familyPointDensity w F G p := by + dsimp [familyPointDensity] + field_simp + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset + +noncomputable def fixedPoleProduct (x : ℕ → ℝ) (u c : ℝ) (n : ℕ) : ℝ := + ∏ i ∈ range n,(x i+u)/(x i+c) +noncomputable def movingProduct (x : ℕ → ℝ) (T : ℝ) (n : ℕ) : ℝ := + ∏ i ∈ range n,(x i+2*T)/(x i+T) + +lemma fixedPoleProduct_pos (x : ℕ → ℝ) {u c : ℝ} (hx : ∀ i,0 < x i) + (hu : 0 ≤ u) (hc : 0 < c) (n : ℕ) : 0 < fixedPoleProduct x u c n := + prod_pos (fun i _ => div_pos (add_pos_of_pos_of_nonneg (hx i) hu) (add_pos (hx i) hc)) +lemma fixedPoleProduct_le_one (x : ℕ → ℝ) {u c : ℝ} (hx : ∀ i,0 < x i) + (hu : 0 ≤ u) (hc : 0 < c) (huc : u ≤ c) (n : ℕ) : fixedPoleProduct x u c n ≤ 1 := by + apply prod_le_one₀ + · intro i _ + exact (div_pos (add_pos_of_pos_of_nonneg (hx i) hu) (add_pos (hx i) hc)).le + · intro i _ + exact (div_le_one (add_pos (hx i) hc)).mpr (by linarith) + +lemma movingProduct_ge_one (x : ℕ → ℝ) {T : ℝ} (hx : ∀ i,0 < x i) (hT : 0 < T) (n : ℕ) : + 1 ≤ movingProduct x T n := by + apply one_le_prod₀ + intro i _ + exact (one_le_div (add_pos (hx i) hT)).mpr (by linarith) + +lemma fixedPole_prefix_good {m n : ℕ} (hmn : m ≤ n) (x : ℕ → ℝ) {u c T : ℝ} + (hx : ∀ i,0 < x i) (hu : 0 ≤ u) (hc : 0 < c) (hT : 0 < T) + (hlarge : ∀ i,m ≤ i → i < n → T ≤ x i) : + fixedPoleProduct x u c m ≤ (1+c/T)^n*fixedPoleProduct x u c n := by + have hK : 1 ≤ 1+c/T := by linarith [le_of_lt (div_pos hc hT)] + have hfac (i) : 0 ≤ (x i+u)/(x i+c) := (div_pos (add_pos_of_pos_of_nonneg (hx i) hu) (add_pos (hx i) hc)).le + have he : (∏ i ∈ range n,if i < m then (x i+u)/(x i+c) else 1)=fixedPoleProduct x u c m := by + rw [←Nat.add_sub_of_le hmn,prod_range_add] + have hz : (∏ i ∈ range (n-m),if m+i < m then (x (m+i)+u)/(x (m+i)+c) else 1)=1 := by + apply prod_eq_one + intro i _ + rw [ite_eq_right (by omega)] + rw [hz,mul_one] + apply prod_congr rfl + intro i hi + rw [ite_eq_left (mem_range.mp hi)] + rw [←he] + calc + _ ≤ ∏ i ∈ range n,(1+c/T)*((x i+u)/(x i+c)) := by + apply prod_le_prod₀ + · intro i _ + split_ifs + · exact hfac i + · exact zero_le_one + · intro i hi + by_cases him : i < m + · rw [ite_eq_left him] + exact le_mul_of_one_le_left (hfac i) hK + · rw [ite_eq_right him] + have hXi:=hlarge i (by omega) (mem_range.mp hi) + have hd : 0 < x i+c := add_pos (hx i) hc + have hem : (1+c/T)*((x i+u)/(x i+c))=((1+c/T)*(x i+u))/(x i+c) := by ring + rw [hem] + apply (le_div_iff₀ hd).mpr + have hTX : c ≤ c/T*x i := by + have hmul:=mul_le_mul_of_nonneg_left hXi (div_pos hc hT).le + simpa only [div_mul_cancel₀ _ hT.ne'] using hmul + nlinarith [mul_nonneg (div_pos hc hT).le hu] + _=(1+c/T)^n*fixedPoleProduct x u c n := by rw [prod_mul_distrib,prod_const,card_range];rfl + +lemma movingProduct_prefix_bad {m n : ℕ} (hmn : m ≤ n) (x : ℕ → ℝ) {T : ℝ} + (hx : ∀ i,0 < x i) (hT : 0 < T) (hsmall : ∀ i,i < m → x i ≤ T) : + 1 ≤ (2/3:ℝ)^m*movingProduct x T n := by + have hprefix : (3/2:ℝ)^m ≤ movingProduct x T m := by + have he : (3/2:ℝ)^m=∏ i ∈ range m,(3/2:ℝ) := by rw [prod_const,card_range] + rw [he] + apply prod_le_prod₀ + · intro i _; norm_num + · intro i hi + apply (le_div_iff₀ (add_pos (hx i) hT)).mpr + linarith [hsmall i (mem_range.mp hi)] + have hmono : movingProduct x T m ≤ movingProduct x T n := by + apply prod_le_prod_of_subset_of_one_le₀ (range_mono hmn) + · intro i _ + exact (div_pos (by linarith [hx i]) (add_pos (hx i) hT)).le + · intro i _ _ + exact (one_le_div (add_pos (hx i) hT)).mpr (by linarith) + have h:=mul_le_mul_of_nonneg_left (hprefix.trans hmono) (by positivity : 0 ≤ (2/3:ℝ)^m) + simpa only [←mul_pow,show (2/3:ℝ)*(3/2)=1 by norm_num,one_pow] using h + +/-- A deterministic ordered-node estimate converting the first-N pole +product to the full characteristic product, with a moving-parameter error. -/ +lemma fixedPole_prefix_bound {m n : ℕ} (hm : 1 ≤ m) (hmn : m ≤ n) (x : ℕ → ℝ) {u c T : ℝ} + (hx : ∀ i,0 < x i) (hu : 0 ≤ u) (hc : 0 < c) (huc : u ≤ c) (hT : 0 < T) + (hord : Monotone (fun i : Fin n => x i)) : + fixedPoleProduct x u c m ≤ (1+c/T)^n*fixedPoleProduct x u c n+ + (2/3:ℝ)^m*movingProduct x T n := by + by_cases h : x (m-1) ≤ T + · have hsmall (i : ℕ) (hi : i < m) : x i ≤ T := + (hord (show (⟨i,by omega⟩:Fin n) ≤ ⟨m-1,by omega⟩ from by simp;omega)).trans h + have hb:=movingProduct_prefix_bad hmn x hx hT hsmall + have hn : 0 ≤ (1+c/T)^n*fixedPoleProduct x u c n := by + exact mul_nonneg (by positivity) (fixedPoleProduct_pos x hx hu hc n).le + linarith [fixedPoleProduct_le_one x hx hu hc huc m] + · have hlarge (i : ℕ) (hi : m ≤ i) (hin : i < n) : T ≤ x i := by + have hi' := hord (show (⟨m-1,by omega⟩:Fin n) ≤ ⟨i,hin⟩ from by simp;omega) + linarith + have hb:=fixedPole_prefix_good hmn x hx hu hc hT hlarge + have hn : 0 ≤ (2/3:ℝ)^m*movingProduct x T n := + mul_nonneg (by positivity) (le_trans zero_le_one (movingProduct_ge_one x hx hT n)) + linarith + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset + +noncomputable def stripJetFamily (N : ℕ) (t : ℝ) : Fin (2*N+1) → ℝ → ℝ := + fun i=>cosineKernelJet (nodalOrder (interiorKnotLabels N t) i) 0 (interiorKnotLabels N t i) +noncomputable def nodeExtension {n : ℕ} (x : Fin n → ℝ) : ℕ → ℝ := + fun i=>if hi : ix i+u) (shiftedPole u 0) n=fixedPoleProduct x u (physicalPole 0) n := by + unfold poleProduct fixedPoleProduct shiftedPole + apply prod_congr rfl + intro i _ + congr 1 ; ring + +lemma stripJet_positiveEvaluation (N : ℕ) {t : ℝ} (ht : 0interiorKnot_monotone N ht htL h) + (fun i=>interiorKnot_nonneg N i t) + + +lemma stripJet_residual_density_bound {N : ℕ} (hN : 1 ≤ N) {u T s t : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hT : 0x i) → + kernelOriginFunctional (n:=2*N+1) (interiorKnotLabels N s) u (fun i=>x i+u) + (fun y=>1-H (y-u)/H (-u)) ≤ 2*poleProduct (fun i=>x i+u) (shiftedPole u 0) N) : + ∀ p : Fin (2*N+1) → ℝ,(∀ i,0

physicalFixedWeight u p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p+ + (2*(2/3:ℝ)^N)* + familyPointDensity (fun p=>physicalMovingWeight T p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p := by + apply pointDensity_bound_of_sorted + intro p hp hp0 + let x : ℕ → ℝ:=nodeExtension (fun i=>(p i)^2) + have hx (i) : 0sq_pos_of_pos (hp0 i)) i + have hxo : StrictMono (fun i : Fin (2*N+1)=>x i) := by + intro i j hij + simp only [x,nodeExtension_fin] + exact (sq_lt_sq₀ (hp0 i).le (hp0 j).le).mpr (hp hij) + have hK:=hb x hx hxo + rw [physical_pole_product,kernelOriginFunctional_eq_residual_det] at hK + have hP:=fixedPole_prefix_bound hN (by omega : N ≤ 2*N+1) x hx hu (physicalPole_pos 0) + (hu4.trans (by norm_num [physicalPole])) hT hxo.monotone + have hR : (evaluationMatrix (residualFamily (stripJetFamily N s) H (-u)) (fun i=>(p i)^2)).det / + (evaluationMatrix (stripJetFamily N s) (fun i=>(p i)^2)).det ≤ + 2*(1+physicalPole 0/T)^(2*N+1)*fixedPoleProduct x u (physicalPole 0) (2*N+1)+ + 2*(2/3:ℝ)^N*movingProduct x T (2*N+1) := by + have he : (fun i : Fin (2*N+1)=>x i)=(fun i=>(p i)^2) := by ext i;simp [x,nodeExtension_fin] + rw [he] at hK + change _ ≤ _ at hK + change _ ≤ _ + calc + _ ≤ 2*fixedPoleProduct x u (physicalPole 0) N := hK + _ ≤ 2*((1+physicalPole 0/T)^(2*N+1)*fixedPoleProduct x u (physicalPole 0) (2*N+1)+ + (2/3:ℝ)^N*movingProduct x T (2*N+1)) := by linarith + _=_ := by ring + have hp2 : StrictMono (fun i=>(p i)^2) := by + intro i j hij + exact (sq_lt_sq₀ (hp0 i).le (hp0 j).le).mpr (hp hij) + have hd:=(stripJet_positiveEvaluation N hs hsL) _ hp2 (fun i=>sq_pos_of_pos (hp0 i)) + have hbase : 0 ≤ familyPointDensity stripDensity (stripJetFamily N s) (stripJetFamily N t) p := + (familyPointDensity_pos _ _ _ _ (stripJet_positiveEvaluation N hs hsL) + (stripJet_positiveEvaluation N ht htL) hp0 (fun _ h=>stripDensity_pos h) hp.injective).le + rw [normalized_residual_density _ _ _ _ _ _ hd.ne'] + have he₁ : fixedPoleProduct x u (physicalPole 0) (2*N+1)=∏ i,physicalFixedWeight u (p i) := by + unfold fixedPoleProduct + exact nodeExtension_prod (fun i=>(p i)^2) (fun z=>(z+u)/(z+physicalPole 0)) + have he₂ : movingProduct x T (2*N+1)=∏ i,physicalMovingWeight T (p i) := by + unfold movingProduct + exact nodeExtension_prod (fun i=>(p i)^2) (fun z=>(z+2*T)/(z+T)) + have h:=mul_le_mul_of_nonneg_right hR hbase + rw [he₁,he₂] at h + rw [familyPointDensity_tilt,familyPointDensity_tilt] + nlinarith only [h] + +lemma hZero_point_density_upper {N : ℕ} (hN : 1 ≤ N) {u T s t : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hT : 0(hZero x).re) (-u)) (stripJetFamily N t) p ≤ + (2*(1+physicalPole 0/T)^(2*N+1))* + familyPointDensity (fun p=>physicalFixedWeight u p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p+ + (2*(2/3:ℝ)^N)* + familyPointDensity (fun p=>physicalMovingWeight T p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p := by + apply stripJet_residual_density_bound hN hu hu4 hT hs hsL ht htL + intro x hx hxo + exact (source_hZero_kernel_bounds hN hu hu4 hs hsL x hx hxo).2 + +lemma hOne_point_density_upper {N : ℕ} (hN : 1 ≤ N) {u T s t : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hT : 0(hOne x).re) (-u)) (stripJetFamily N t) p ≤ + (2*(1+physicalPole 0/T)^(2*N+1))* + familyPointDensity (fun p=>physicalFixedWeight u p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p+ + (2*(2/3:ℝ)^N)* + familyPointDensity (fun p=>physicalMovingWeight T p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p := by + apply stripJet_residual_density_bound hN hu hu4 hT hs hsL ht htL + intro x hx hxo + exact (source_hOne_kernel_bounds hN hu hu4 hs hsL x hx hxo).2 + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open MeasureTheory Filter + +lemma stripJet_pair_integrable (N : ℕ) {s t : ℝ} (hs : 0stripJetFamily N s i (p^2)*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0) := by + apply strip_jet_pair_integrable (interiorKnot_nonneg N i _) (interiorKnot_nonneg N j _) + · exact (interiorKnot_le N i hs hsL).trans (by nlinarith [sq_nonneg angle]) + · exact interiorKnot_le N j ht htL + +lemma stripJet_characteristic_pair_integrable (N : ℕ) {s t z : ℝ} (hs : 0stripJetFamily N s i (p^2)*stripJetFamily N t j (p^2)* + (characteristicRatio y z p*stripDensity p)) (Set.Ioi 0) := by + have h:=pole_jet_pair_pencil_integrable (interiorKnot_nonneg N i s) (interiorKnot_nonneg N j t) + ((interiorKnot_le N i hs hsL).trans (by nlinarith [sq_nonneg angle])) + (interiorKnot_le N j ht htL) hz (nodalOrder (interiorKnotLabels N s) i) + (nodalOrder (interiorKnotLabels N t) j) (-(y^2)) + apply h.congr + filter_upwards with p + rw [congrFun (pole_pencil_tilt_weight y z) p] + rfl + +lemma hZero_sq_real (p : ℝ) (hp : 0 ≤ p) : + (hZero (p^2)).re=1/(2*Real.cosh (angle*p)-1) := by + rw [hZero,D_sq hp] + norm_cast + simp only [one_div] + +lemma hOne_sq_real (p : ℝ) (hp : 0 ≤ p) : + (hOne (p^2)).re=Real.cosh ((angle/2)*p)/(2*Real.cosh (angle*p)-1) := by + rw [hOne,D_sq hp,C_sq _ hp] + norm_cast + +lemma hZero_sq_unit {p : ℝ} (hp : 0 ≤ p) : 0 ≤ (hZero (p^2)).re ∧ (hZero (p^2)).re ≤ 1 := by + rw [hZero_sq_real p hp] + have hd : 1 ≤ 2*Real.cosh (angle*p)-1 := by linarith [Real.one_le_cosh (angle*p)] + constructor + · positivity + · exact (div_le_one (by linarith)).mpr hd + +lemma hOne_sq_unit {p : ℝ} (hp : 0 ≤ p) : 0 ≤ (hOne (p^2)).re ∧ (hOne (p^2)).re ≤ 1 := by + rw [hOne_sq_real p hp] + have hd : 1 ≤ 2*Real.cosh (angle*p)-1 := by linarith [Real.one_le_cosh (angle*p)] + have hc : Real.cosh ((angle/2)*p) ≤ Real.cosh (angle*p) := by + apply Real.cosh_le_cosh.mpr + rw [abs_of_nonneg (mul_nonneg (by linarith [strip_angle_pos]) hp), + abs_of_nonneg (mul_nonneg strip_angle_pos.le hp)] + nlinarith [strip_angle_pos] + constructor + · positivity + · apply (div_le_one (by linarith)).mpr + linarith [Real.one_le_cosh (angle*p)] + +lemma bounded_target_stripJet_integrable (N : ℕ) {t : ℝ} (ht : 0H (p^2)) (volume.restrict (Set.Ioi 0))) + (hH : ∀ p : ℝ,0

H (p^2)*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0) := by + have hi:=strip_jet_pair_integrable (b:=0) (by rfl) (interiorKnot_nonneg N j t) + (by positivity) (interiorKnot_le N j ht htL) 0 (nodalOrder (interiorKnotLabels N t) j) + simp only [cosineKernelJet_at_zero,pow_zero,mul_zero,Nat.factorial_zero,Nat.cast_one,div_one,one_mul] at hi + have hfm : Continuous (fun p : ℝ=>stripJetFamily N t j (p^2)) := + (cosineKernelJet_contDiff_right _ 0 _ 0).continuous.comp (by fun_prop) + apply hi.mono' + · exact (hHm.mul hfm.aestronglyMeasurable).mul + (show Measurable stripDensity by unfold stripDensity;fun_prop).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hH0:=(hH p hp).1 + have hf0 : 0 ≤ stripJetFamily N t j (p^2) := cosineKernelJet_nonneg + (interiorKnot_nonneg N j t) (sq_nonneg p) _ _ + have hw0 := (stripDensity_pos hp).le + rw [Real.norm_of_nonneg (by positivity)] + change H (p^2)*stripJetFamily N t j (p^2)*stripDensity p ≤ stripJetFamily N t j (p^2)*stripDensity p + nlinarith [mul_nonneg (sub_nonneg.mpr (hH p hp).2) (mul_nonneg hf0 hw0)] + +lemma hZero_stripJet_integrable (N : ℕ) {t : ℝ} (ht : 0(hZero (p^2)).re*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0) := by + refine bounded_target_stripJet_integrable N ht htL (fun x=>(hZero x).re) ?_ ?_ j + · apply (show Measurable (fun p : ℝ=>1/(2*Real.cosh (angle*p)-1)) by fun_prop).aestronglyMeasurable.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact (hZero_sq_real p hp.le).symm + · intro p hp + exact hZero_sq_unit hp.le + +lemma hOne_stripJet_integrable (N : ℕ) {t : ℝ} (ht : 0(hOne (p^2)).re*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0) := by + refine bounded_target_stripJet_integrable N ht htL (fun x=>(hOne x).re) ?_ ?_ j + · apply (show Measurable (fun p : ℝ=>Real.cosh ((angle/2)*p)/(2*Real.cosh (angle*p)-1)) by fun_prop).aestronglyMeasurable.congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + exact (hOne_sq_real p hp.le).symm + · intro p hp + exact hOne_sq_unit hp.le + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter + +lemma physicalFixedWeight_characteristic {u : ℝ} (hu : 0 ≤ u) : + physicalFixedWeight u=characteristicRatio (Real.sqrt u) (8/3) := by + funext p + simp only [physicalFixedWeight,characteristicRatio,Real.sq_sqrt hu,physicalPole] + norm_num + +lemma physicalMovingWeight_characteristic {T : ℝ} (hT : 0 ≤ T) : + physicalMovingWeight T=characteristicRatio (Real.sqrt (2*T)) (Real.sqrt T) := by + funext p + simp only [physicalMovingWeight,characteristicRatio,Real.sq_sqrt hT, + Real.sq_sqrt (mul_nonneg (by norm_num : (0:ℝ) ≤ 2) hT)] + +lemma stripJet_gram_det_pos (N : ℕ) {s t : ℝ} (hs : 0stripDensity_pos hp) + (stripJet_pair_integrable N hs hsL ht htL) + +noncomputable def jetFixedMean (N : ℕ) (s t u : ℝ) : ℝ := + (familyGram (fun p=>physicalFixedWeight u p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t)).det / + (familyGram stripDensity (stripJetFamily N s) (stripJetFamily N t)).det +noncomputable def jetMovingMean (N : ℕ) (s t T : ℝ) : ℝ := + (familyGram (fun p=>physicalMovingWeight T p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t)).det / + (familyGram stripDensity (stripJetFamily N s) (stripJetFamily N t)).det + +lemma stripJet_residual_mean_upper {N : ℕ} {u T s t : ℝ} + (hu : 0 ≤ u) (hT : 0H (p^2)*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0)) + (hb : ∀ p : Fin (2*N+1) → ℝ,(∀ i,0

physicalFixedWeight u p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p+ + (2*(2/3:ℝ)^N)* + familyPointDensity (fun p=>physicalMovingWeight T p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p) : + meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) H (-u) ≤ + (2*(1+physicalPole 0/T)^(2*N+1))*jetFixedMean N s t u+ + (2*(2/3:ℝ)^N)*jetMovingMean N s t T := by + apply meanResidualRatio_bound + · exact stripJet_pair_integrable N hs hsL ht htL + · rw [physicalFixedWeight_characteristic hu] + exact stripJet_characteristic_pair_integrable N hs hsL ht htL (by norm_num) _ + · rw [physicalMovingWeight_characteristic hT.le] + exact stripJet_characteristic_pair_integrable N hs hsL ht htL (Real.sqrt_pos.mpr hT) _ + · exact hHi + · exact stripJet_gram_det_pos N hs hsL ht htL + · exact hb + +lemma hZero_mean_upper {N : ℕ} (hN : 1 ≤ N) {u T s t : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hT : 0(hZero x).re) (-u) ≤ + (2*(1+physicalPole 0/T)^(2*N+1))*jetFixedMean N s t u+ + (2*(2/3:ℝ)^N)*jetMovingMean N s t T := + stripJet_residual_mean_upper hu hT hs hsL ht htL _ (hZero_stripJet_integrable N ht htL) + (hZero_point_density_upper hN hu hu4 hT hs hsL ht htL) + +lemma hOne_mean_upper {N : ℕ} (hN : 1 ≤ N) {u T s t : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hT : 0(hOne x).re) (-u) ≤ + (2*(1+physicalPole 0/T)^(2*N+1))*jetFixedMean N s t u+ + (2*(2/3:ℝ)^N)*jetMovingMean N s t T := + stripJet_residual_mean_upper hu hT hs hsL ht htL _ (hOne_stripJet_integrable N ht htL) + (hOne_point_density_upper hN hu hu4 hT hs hsL ht htL) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Matrix Finset MeasureTheory Filter Equiv + +lemma pointDensity_lower_of_sorted {n : ℕ} (w w₁ : ℝ → ℝ) (F G R : Fin n → ℝ → ℝ) + (A : ℝ) + (hb : ∀ p : Fin n → ℝ,StrictMono p → (∀ i,0

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hi₁ : ∀ i j,IntegrableOn (fun p=>F i (p^2)*G j (p^2)*w₁ p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p=>H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hd : 0<(familyGram w F G).det) + (hb : ∀ p : Fin n → ℝ,(∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) + have hae : ∀ᵐ p ∂μ,∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) (i:=i)).eventually (ae_restrict_mem measurableSet_Ioi) + have hR:=family_gram_andreief w (residualFamily F H a) G (residualFamily_pair_integrable w F G H a hi hH) + have h₁:=family_gram_andreief w₁ F G hi₁ + have hI:=integral_mono_ae (h₁.1.const_mul A) hR.1 (hae.mono hb) + rw [integral_const_mul,hR.2,h₁.2] at hI + have hc : (0:ℝ)x i) → + A*poleProduct (fun i=>x i+u) (shiftedPole u 0) (2*N+1) ≤ + kernelOriginFunctional (n:=2*N+1) (interiorKnotLabels N s) u (fun i=>x i+u) + (fun y=>1-H (y-u)/H (-u))) : + ∀ p : Fin (2*N+1) → ℝ,(∀ i,0

physicalFixedWeight u p*stripDensity p) (stripJetFamily N s) (stripJetFamily N t) p ≤ + familyPointDensity stripDensity (residualFamily (stripJetFamily N s) H (-u)) (stripJetFamily N t) p := by + apply pointDensity_lower_of_sorted + intro p hp hp0 + let x : ℕ → ℝ:=nodeExtension (fun i=>(p i)^2) + have hx (i) : 0sq_pos_of_pos (hp0 i)) i + have hp2 : StrictMono (fun i=>(p i)^2) := by + intro i j hij + exact (sq_lt_sq₀ (hp0 i).le (hp0 j).le).mpr (hp hij) + have hxo : StrictMono (fun i : Fin (2*N+1)=>x i) := by simpa only [x,nodeExtension_fin] using hp2 + have hd:=(stripJet_positiveEvaluation N hs hsL) _ hp2 (fun i=>sq_pos_of_pos (hp0 i)) + have hbase : 0 ≤ familyPointDensity stripDensity (stripJetFamily N s) (stripJetFamily N t) p := + (familyPointDensity_pos _ _ _ _ (stripJet_positiveEvaluation N hs hsL) + (stripJet_positiveEvaluation N ht htL) hp0 (fun _ h=>stripDensity_pos h) hp.injective).le + have hR:=hb x hx hxo + rw [kernelOriginFunctional_eq_residual_det,physical_pole_product] at hR + simp only [x,nodeExtension_fin] at hR + have he : fixedPoleProduct x u (physicalPole 0) (2*N+1)=∏ i,physicalFixedWeight u (p i) := by + unfold fixedPoleProduct + exact nodeExtension_prod (fun i=>(p i)^2) (fun z=>(z+u)/(z+physicalPole 0)) + rw [he] at hR + have h:=mul_le_mul_of_nonneg_right hR hbase + rw [normalized_residual_density _ _ _ _ _ _ hd.ne',familyPointDensity_tilt] + have heval : jetEvaluation (interiorKnotLabels N s) (fun i : Fin (2*N+1)=>(p i)^2)= + evaluationMatrix (stripJetFamily N s) (fun i=>(p i)^2) := rfl + rw [heval] at h + change (A*(∏ i,physicalFixedWeight u (p i)))*familyPointDensity stripDensity (stripJetFamily N s) (stripJetFamily N t) p ≤ _ at h + rw [mul_assoc] at h + exact h + +lemma stripJet_residual_mean_lower {N : ℕ} {u s t : ℝ} + (hu : 0 ≤ u) (hs : 0H (p^2)*stripJetFamily N t j (p^2)*stripDensity p) (Set.Ioi 0)) + (hb : ∀ x : ℕ → ℝ,(∀ i,0x i) → + A*poleProduct (fun i=>x i+u) (shiftedPole u 0) (2*N+1) ≤ + kernelOriginFunctional (n:=2*N+1) (interiorKnotLabels N s) u (fun i=>x i+u) + (fun y=>1-H (y-u)/H (-u))) : + A*jetFixedMean N s t u ≤ meanResidualRatio stripDensity (stripJetFamily N s) (stripJetFamily N t) H (-u) := by + apply meanResidualRatio_lower + · exact stripJet_pair_integrable N hs hsL ht htL + · rw [physicalFixedWeight_characteristic hu] + exact stripJet_characteristic_pair_integrable N hs hsL ht htL (by norm_num) _ + · exact hHi + · exact stripJet_gram_det_pos N hs hsL ht htL + · exact stripJet_residual_density_lower hs hsL ht htL H A hb + +lemma hZero_mean_lower {N : ℕ} (hN : 1 ≤ N) {u s t : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hs : 0(hZero x).re) (-u) := by + simpa only [one_mul] using stripJet_residual_mean_lower hu hs hsL ht htL (fun x=>(hZero x).re) 1 + (hZero_stripJet_integrable N ht htL) (by intro x hx hxo; simpa only [one_mul] using (source_hZero_kernel_bounds hN hu hu4 hs hsL x hx hxo).1) + +lemma hOne_mean_lower {N : ℕ} (hN : 1 ≤ N) {u s t : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hs : 0(hOne x).re) (-u) := + stripJet_residual_mean_lower hu hs hsL ht htL _ _ (hOne_stripJet_integrable N ht htL) + (fun x hx hxo=>(source_hOne_kernel_bounds hN hu hu4 hs hsL x hx hxo).1) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/Resolvents.lean b/lean/OAI/Combinatorics/HoneycombChords/Resolvents.lean new file mode 100644 index 0000000000000000000000000000000000000000..62563c95d2716d868f6b9ec105113aea1d9764c9 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/Resolvents.lean @@ -0,0 +1,1043 @@ +import OAI.Combinatorics.HoneycombChords.Pollaczek + +namespace OAI + +/-! +# Jacobi resolvents and rational Christoffel kernels + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Real +noncomputable def jacobiA (n : ℕ) : ℝ := (2*n+1)*(2*n+2)/4 +noncomputable def jacobiB (n : ℕ) : ℝ := ((2*n+1)^2+(2*n)^2)/4 +lemma jacobiA_pos (n : ℕ) : 0 < jacobiA n := by unfold jacobiA;positivity +lemma jacobi_zero (x : ℝ) : + x*(evenPoly (-1) 0).eval x=jacobiA 0*(evenPoly (-1) 1).eval x+ + jacobiB 0*(evenPoly (-1) 0).eval x := by + rw [eval_evenPoly_succ (-1) x 0] + norm_num [jacobiA,jacobiB] + ring +lemma jacobi_succ (n : ℕ) (x : ℝ) : + x*(evenPoly (-1) (n+1)).eval x= + jacobiA (n+1)*(evenPoly (-1) (n+2)).eval x+ + jacobiB (n+1)*(evenPoly (-1) (n+1)).eval x+ + jacobiA n*(evenPoly (-1) n).eval x := by + rw [show n+2=(n+1)+1 by omega,eval_evenPoly_succ (-1) x (n+1), + eval_oddPoly_succ (-1) x n,eval_evenPoly_succ (-1) x n] + have h1 : (2*(n:ℝ)+2) ≠ 0 := by positivity + have h2 : (2*((n:ℝ)+1)+2) ≠ 0 := by positivity + have h3 : (2*(n:ℝ)+3) ≠ 0 := by positivity + simp only [jacobiA,jacobiB,Nat.cast_add,Nat.cast_one] + field_simp + ring +lemma jacobi_poly_zero : + X*evenPoly (-1) 0=jacobiA 0 • evenPoly (-1) 1+jacobiB 0 • evenPoly (-1) 0 := by + apply Polynomial.funext + intro x + simpa using jacobi_zero x +lemma jacobi_poly_succ (n : ℕ) : + X*evenPoly (-1) (n+1)=jacobiA (n+1) • evenPoly (-1) (n+2)+ + jacobiB (n+1) • evenPoly (-1) (n+1)+jacobiA n • evenPoly (-1) n := by + apply Polynomial.funext + intro x + simpa using jacobi_succ n x +noncomputable def negativeEval (s : ℝ) (n : ℕ) : ℝ := meixnerCoeff s (2*n) +lemma negativeEval_pos {s : ℝ} (hs : 0 < s) (n : ℕ) : 0 < negativeEval s n := + meixnerCoeff_pos hs _ +@[simp] lemma negativeEval_zero (s : ℝ) : negativeEval s 0=1 := rfl +lemma negativeEval_jacobi_zero (s : ℝ) : + jacobiA 0*negativeEval s 1=(s^2+jacobiB 0)*negativeEval s 0 := by + have h:=jacobi_zero (-(s^2)) + simp only [evenPoly_negative_eval] at h + norm_num at h + simp only [show meixnerCoeff s 0=1 from rfl] at h + dsimp [negativeEval] + linear_combination h +lemma negativeEval_jacobi_succ (s : ℝ) (n : ℕ) : + jacobiA (n+1)*negativeEval s (n+2)=(s^2+jacobiB (n+1))*negativeEval s (n+1)- + jacobiA n*negativeEval s n := by + have h:=jacobi_succ n (-(s^2)) + simp only [evenPoly_negative_eval] at h + simp only [pow_add,pow_one,neg_one_sq,mul_one,mul_neg,neg_mul] at h + have hn : (-1:ℝ)^n ≠ 0 := by positivity + dsimp [negativeEval] + apply (mul_left_cancel₀ hn) + linear_combination -h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Real MeasureTheory +lemma rational_sech_integrable {Y : ℝ} (hY : 0 < Y) (k : ℕ) (P : Polynomial ℝ) : + IntegrableOn (fun p:ℝ=>P.eval (p^2)/(p^2+Y^2)^k/Real.cosh (Real.pi*p)) (Set.Ioi 0) := by + have hd (p : ℝ) : 0 < p^2+Y^2 := by positivity + have hm : Continuous (fun p:ℝ=>P.eval (p^2)/(p^2+Y^2)^k/Real.cosh (Real.pi*p)) := + ((by fun_prop : Continuous (fun p:ℝ=>P.eval (p^2))).div (by fun_prop) + (fun p=>pow_ne_zero _ (hd p).ne')).div (by fun_prop) (fun p=>(Real.cosh_pos _).ne') + apply (((polynomial_sech_integrable P Real.pi_pos).norm).div_const ((Y^2)^k)).mono' hm.aestronglyMeasurable + filter_upwards with p + simp only [Real.norm_eq_abs,abs_div,abs_of_pos (Real.cosh_pos _),abs_of_pos (pow_pos (hd p) k)] + have hh : (Y^2)^k ≤ (p^2+Y^2)^k := pow_le_pow_left₀ (by positivity) (by nlinarith) k + calc + _ = |P.eval (p^2)|/Real.cosh (Real.pi*p)/(p^2+Y^2)^k := by ring + _ ≤ _ := div_le_div_of_nonneg_left (by positivity) (by positivity) hh +noncomputable def rationalSechMoment (Y : ℝ) (k : ℕ) (P : Polynomial ℝ) : ℝ := + 2*∫ p in Set.Ioi (0:ℝ),P.eval (p^2)/(p^2+Y^2)^k/Real.cosh (Real.pi*p) +lemma rationalSechMoment_add {Y : ℝ} (hY : 0 < Y) (k : ℕ) (P Q : Polynomial ℝ) : + rationalSechMoment Y k (P+Q)=rationalSechMoment Y k P+rationalSechMoment Y k Q := by + simp only [rationalSechMoment,eval_add,add_div] + rw [integral_add (rational_sech_integrable hY k P) (rational_sech_integrable hY k Q)] + ring +lemma rationalSechMoment_smul (Y a : ℝ) (k : ℕ) (P : Polynomial ℝ) : + rationalSechMoment Y k (a • P)=a*rationalSechMoment Y k P := by + simp only [rationalSechMoment,eval_smul,smul_eq_mul,mul_div_assoc] + rw [integral_const_mul] + ring +lemma rationalSechMoment_neg (Y : ℝ) (k : ℕ) (P : Polynomial ℝ) : + rationalSechMoment Y k (-P) = -rationalSechMoment Y k P := by + simpa using rationalSechMoment_smul Y (-1) k P +lemma rationalSechMoment_sub {Y : ℝ} (hY : 0 < Y) (k : ℕ) (P Q : Polynomial ℝ) : + rationalSechMoment Y k (P-Q)=rationalSechMoment Y k P-rationalSechMoment Y k Q := by + rw [sub_eq_add_neg,rationalSechMoment_add hY,rationalSechMoment_neg,sub_eq_add_neg] +lemma rationalSechMoment_sum {Y : ℝ} (hY : 0 < Y) (k : ℕ) {ι : Type*} (s : Finset ι) + (P : ι → Polynomial ℝ) : + rationalSechMoment Y k (∑ i∈s,P i)=∑ i∈s,rationalSechMoment Y k (P i) := by + simp only [rationalSechMoment,eval_finsetSum,Finset.sum_div] + rw [integral_finsetSum _ (fun i _ => rational_sech_integrable hY k (P i)),Finset.mul_sum] +lemma rationalSechMoment_den {Y : ℝ} (hY : 0 < Y) (k : ℕ) (P : Polynomial ℝ) : + rationalSechMoment Y (k+1) ((X+Polynomial.C (Y^2))*P)=rationalSechMoment Y k P := by + unfold rationalSechMoment + congr 1 + apply integral_congr_ae + filter_upwards with p + have hd : p^2+Y^2 ≠ 0 := (show 0 < p^2+Y^2 by positivity).ne' + simp only [eval_mul,eval_add,eval_X,eval_C,pow_succ] + field_simp +lemma rationalSechMoment_sq_nonneg (Y : ℝ) (k : ℕ) (P : Polynomial ℝ) : + 0 ≤ rationalSechMoment Y k (P^2) := by + unfold rationalSechMoment + apply mul_nonneg (by norm_num) + apply integral_nonneg + intro p + simp only [eval_pow] + positivity +lemma rationalSechMoment_zero_mul (Y : ℝ) (P Q : Polynomial ℝ) : + rationalSechMoment Y 0 (P*Q)=polynomialSechInner P Q := by + simp only [rationalSechMoment,pow_zero,div_one,eval_mul,polynomialSechInner_eq] +lemma rationalSechMoment_residual {Y : ℝ} (hY : 0 < Y) (P : Polynomial ℝ) : + rationalSechMoment Y 2 ((1-(X+Polynomial.C (Y^2))*P)^2)= + rationalSechMoment Y 2 1-2*rationalSechMoment Y 1 P+polynomialSechInner P P := by + have he : (1-(X+Polynomial.C (Y^2))*P)^2= + 1-(2:ℝ) • ((X+Polynomial.C (Y^2))*P)+(X+Polynomial.C (Y^2))*((X+Polynomial.C (Y^2))*(P*P)) := by + simp only [Algebra.smul_def,map_ofNat] + ring + rw [he,rationalSechMoment_add hY,rationalSechMoment_sub hY,rationalSechMoment_smul, + rationalSechMoment_den hY 1,rationalSechMoment_den hY 1, + rationalSechMoment_den hY 0,rationalSechMoment_zero_mul] +noncomputable def resolventCoeff (Y : ℝ) (n : ℕ) : ℝ := + rationalSechMoment Y 1 (evenPoly (-1) n) +lemma resolventCoeff_bessel {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + ∑ j:Fin (n+1),resolventCoeff Y j^2 ≤ rationalSechMoment Y 2 1 := by + let a : Fin (n+1) → ℝ := fun j=>resolventCoeff Y j + have h:=rationalSechMoment_sq_nonneg Y 2 (1-(X+Polynomial.C (Y^2))*pollaczekCombination a) + rw [rationalSechMoment_residual hY,pollaczekCombination_inner] at h + have he : rationalSechMoment Y 1 (pollaczekCombination a)=∑ j:Fin (n+1),a j^2 := by + rw [pollaczekCombination,rationalSechMoment_sum hY] + simp only [rationalSechMoment_smul,a,resolventCoeff,pow_two] + rw [he] at h + change ∑ j,a j^2 ≤ _ + linarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +/-! Bessel bounds and the discrete Wronskian identify the decaying resolvent solution. -/ +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Filter Topology +lemma square_prefix_monotone (a : ℕ → ℝ) : Monotone (fun n=>∑ j∈range n,a j^2) := by + intro n m hnm + apply sum_le_sum_of_subset_of_nonneg (range_mono hnm) + intro j _ _ + positivity +lemma antitone_ratio_nonneg {a b : ℕ → ℝ} {K : ℝ} + (ha : ∀ n,0 < a n) (hr : Antitone (fun n=>b n/a n)) + (hK : ∀ n,∑ j∈range n,b j^2 ≤ K) + (hdiv : Tendsto (fun n=>∑ j∈range n,a j^2) atTop atTop) : + ∀ n,0 ≤ b n/a n := by + intro n + by_contra hn + have hn : b n/a n < 0 := lt_of_not_ge hn + let r := b n/a n + have hr0 : 0 < r^2 := sq_pos_of_neg hn + obtain ⟨N,hN,hgt⟩ := ((eventually_ge_atTop n).and (hdiv.eventually + (eventually_gt_atTop ((∑ j∈range n,a j^2)+K/r^2)))).exists + have hs : r^2*(∑ j∈Ico n N,a j^2) ≤ ∑ j∈Ico n N,b j^2 := by + rw [mul_sum] + apply sum_le_sum + intro j hj + have hbr : b j ≤ r*a j := (div_le_iff₀ (ha j)).1 (hr (mem_Ico.mp hj).1) + have hneg : r*a j < 0 := mul_neg_of_neg_of_pos hn (ha j) + have hbneg : b j ≤ 0 := by linarith + have hh := mul_self_le_mul_self (by linarith : 0 ≤ -(r*a j)) (by linarith : -(r*a j) ≤ -b j) + nlinarith + have hb : (∑ j∈Ico n N,b j^2) ≤ K := by + apply le_trans (sum_le_sum_of_subset_of_nonneg (by intro j hj;exact mem_range.2 (mem_Ico.mp hj).2) + (fun j _ _ => sq_nonneg _)) (hK N) + rw [sum_Ico_eq_sub _ hN] at hs + have hgt' : K < (∑ j∈range N,a j^2 - ∑ j∈range n,a j^2)*r^2 := by + apply (div_lt_iff₀ hr0).1 + linarith + nlinarith +lemma antitone_ratio_zero {a b : ℕ → ℝ} {K : ℝ} + (ha : ∀ n,0 < a n) (hr : Antitone (fun n=>b n/a n)) + (hK : ∀ n,∑ j∈range n,b j^2 ≤ K) + (hdiv : Tendsto (fun n=>∑ j∈range n,a j^2) atTop atTop) : + Tendsto (fun n=>b n/a n) atTop (𝓝 0) := by + have hnn := antitone_ratio_nonneg ha hr hK hdiv + have hK0 : 0 ≤ K := by simpa using hK 0 + have hs (n : ℕ) : (b n/a n)^2*(∑ j∈range (n+1),a j^2) ≤ K := by + apply le_trans _ (hK (n+1)) + rw [mul_sum] + apply sum_le_sum + intro j hj + have hjn : j ≤ n := by simpa using mem_range.mp hj + have hbr : b n/a n*a j ≤ b j := (le_div_iff₀ (ha j)).1 (hr hjn) + have hpos : 0 ≤ b n/a n*a j := mul_nonneg (hnn n) (ha j).le + have hh := mul_self_le_mul_self hpos hbr + nlinarith + apply tendsto_order.2 + constructor + · intro l hl + exact Eventually.of_forall (fun n=>lt_of_lt_of_le hl (hnn n)) + · intro u hu + have hu2 : 0 < u^2 := sq_pos_of_pos hu + filter_upwards [hdiv.eventually (eventually_gt_atTop (K/u^2))] with n hn + have hmono := square_prefix_monotone a (Nat.le_succ n) + have hn' : K < u^2*(∑ j∈range (n+1),a j^2) := by + have hh := (div_lt_iff₀ hu2).1 (lt_of_lt_of_le hn hmono) + nlinarith + have hsum : 0 ≤ ∑ j∈range (n+1),a j^2 := sum_nonneg (fun j _ => sq_nonneg _) + by_contra hnot + have hb : u ≤ b n/a n := le_of_not_gt hnot + have hsq : u^2 ≤ (b n/a n)^2 := by nlinarith [sq_nonneg (b n/a n-u)] + have hh := mul_le_mul_of_nonneg_right hsq hsum + linarith [hs n] +lemma wronskian_ratio_step {a b A : ℕ → ℝ} (ha : ∀ n,0 < a n) (hA : ∀ n,0 < A n) + (hw : ∀ n,A n*(a (n+1)*b n-a n*b (n+1))=1) (n : ℕ) : + b n/a n-b (n+1)/a (n+1)=1/(A n*a n*a (n+1)) := by + have h0:=ha n + have h1:=ha (n+1) + have h2:=hA n + apply (eq_div_iff (by positivity : A n*a n*a (n+1) ≠ 0)).2 + field_simp + nlinarith [hw n] +lemma wronskian_ratio_antitone {a b A : ℕ → ℝ} (ha : ∀ n,0 < a n) (hA : ∀ n,0 < A n) + (hw : ∀ n,A n*(a (n+1)*b n-a n*b (n+1))=1) : + Antitone (fun n=>b n/a n) := by + apply antitone_nat_of_succ_le + intro n + have h := wronskian_ratio_step ha hA hw n + have hp : 0 < 1/(A n*a n*a (n+1)) := one_div_pos.2 (mul_pos (mul_pos (hA n) (ha n)) (ha (n+1))) + linarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Real Finset Filter Topology +lemma rationalSechMoment_X {Y : ℝ} (hY : 0 < Y) (P : Polynomial ℝ) : + rationalSechMoment Y 1 (X*P)+Y^2*rationalSechMoment Y 1 P=rationalSechMoment Y 0 P := by + have h := rationalSechMoment_den hY 0 P + have he : (X+Polynomial.C (Y^2))*P=X*P+Y^2 • P := by simp [add_mul,smul_eq_C_mul] + rw [he,rationalSechMoment_add hY,rationalSechMoment_smul] at h + exact h +lemma rationalSechMoment_basis_zero (Y : ℝ) (n : ℕ) : + rationalSechMoment Y 0 (evenPoly (-1) n)=if n=0 then 1 else 0 := by + have h:=rationalSechMoment_zero_mul Y (evenPoly (-1) n) (evenPoly (-1) 0) + rw [polynomialSechInner_orthogonal] at h + simpa only [evenPoly_zero,mul_one] using h +lemma resolventCoeff_jacobi_zero {Y : ℝ} (hY : 0 < Y) : + jacobiA 0*resolventCoeff Y 1+(jacobiB 0+Y^2)*resolventCoeff Y 0=1 := by + have h:=rationalSechMoment_X hY (evenPoly (-1) 0) + rw [jacobi_poly_zero,rationalSechMoment_add hY,rationalSechMoment_smul, + rationalSechMoment_smul,rationalSechMoment_basis_zero] at h + simp only [ite_true,evenPoly_zero] at h + dsimp [resolventCoeff] + linarith +lemma resolventCoeff_jacobi_succ {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + jacobiA (n+1)*resolventCoeff Y (n+2)+(jacobiB (n+1)+Y^2)*resolventCoeff Y (n+1)+ + jacobiA n*resolventCoeff Y n=0 := by + have h:=rationalSechMoment_X hY (evenPoly (-1) (n+1)) + rw [jacobi_poly_succ,rationalSechMoment_add hY,rationalSechMoment_add hY, + rationalSechMoment_smul,rationalSechMoment_smul,rationalSechMoment_smul, + rationalSechMoment_basis_zero] at h + simp only [Nat.add_one_ne_zero,ite_false] at h + dsimp [resolventCoeff] + linarith +noncomputable def signedResolventCoeff (Y : ℝ) (n : ℕ) : ℝ := (-1)^n*resolventCoeff Y n +lemma signedResolventCoeff_jacobi_zero {Y : ℝ} (hY : 0 < Y) : + jacobiA 0*signedResolventCoeff Y 1=(Y^2+jacobiB 0)*signedResolventCoeff Y 0-1 := by + have h:=resolventCoeff_jacobi_zero hY + simp only [signedResolventCoeff,pow_zero,pow_one,one_mul,neg_mul,one_mul] + linarith +lemma signedResolventCoeff_jacobi_succ {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + jacobiA (n+1)*signedResolventCoeff Y (n+2)=(Y^2+jacobiB (n+1))*signedResolventCoeff Y (n+1)- + jacobiA n*signedResolventCoeff Y n := by + have h:=resolventCoeff_jacobi_succ hY n + simp only [signedResolventCoeff,pow_add,pow_one,neg_one_sq,mul_one,mul_neg,neg_mul] + linear_combination ((-1:ℝ)^n)*h +lemma resolvent_wronskian {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + jacobiA n*(negativeEval Y (n+1)*signedResolventCoeff Y n- + negativeEval Y n*signedResolventCoeff Y (n+1))=1 := by + induction n with + | zero => + have ha:=negativeEval_jacobi_zero Y + have hb:=signedResolventCoeff_jacobi_zero hY + simp only [negativeEval_zero] at ha ⊢ + linear_combination signedResolventCoeff Y 0*ha-hb + | succ n ih => + have ha:=negativeEval_jacobi_succ Y n + have hb:=signedResolventCoeff_jacobi_succ hY n + linear_combination signedResolventCoeff Y (n+1)*ha-negativeEval Y (n+1)*hb+ih +lemma signedResolventCoeff_sq (Y : ℝ) (n : ℕ) : + signedResolventCoeff Y n^2=resolventCoeff Y n^2 := by + rw [signedResolventCoeff,mul_pow,←pow_mul,show n*2=2*n by omega,pow_mul] + norm_num +lemma signedResolventCoeff_bessel {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + ∑ j∈range n,signedResolventCoeff Y j^2 ≤ rationalSechMoment Y 2 1 := by + cases n with + | zero => + simpa only [sum_range_zero,one_pow] using rationalSechMoment_sq_nonneg Y 2 (1:Polynomial ℝ) + | succ n => + simpa only [signedResolventCoeff_sq,←Fin.sum_univ_eq_sum_range] using resolventCoeff_bessel hY n +lemma negativeEval_square_diverges {Y : ℝ} (hY : 0 < Y) : + Tendsto (fun n=>∑ j∈range n,negativeEval Y j^2) atTop atTop := by + obtain ⟨c,C,hc,hC,h⟩:=evenCoefficientKernel_bounds hY + have ht : Tendsto (fun n:ℕ=>c*((n:ℝ)+1)^(2*Y)) atTop atTop := + Tendsto.const_mul_atTop hc ((tendsto_rpow_atTop (by positivity)).comp + (tendsto_atTop_mono (fun n:ℕ=>(show (n:ℝ) ≤ (n:ℝ)+1 by linarith)) tendsto_natCast_atTop_atTop)) + have hu : Tendsto (evenCoefficientKernel Y) atTop atTop := tendsto_atTop_mono' atTop + (h.mono (fun n hn=>hn.1)) ht + apply (tendsto_add_atTop_iff_nat 1).1 + exact hu +lemma signedResolventCoeff_ratio_zero {Y : ℝ} (hY : 0 < Y) : + Tendsto (fun n=>signedResolventCoeff Y n/negativeEval Y n) atTop (𝓝 0) := by + apply antitone_ratio_zero (negativeEval_pos hY) + (wronskian_ratio_antitone (negativeEval_pos hY) jacobiA_pos (resolvent_wronskian hY)) + (signedResolventCoeff_bessel hY) (negativeEval_square_diverges hY) +lemma signedResolventCoeff_pos {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + 0 < signedResolventCoeff Y n := by + have hn:=antitone_ratio_nonneg (negativeEval_pos hY) + (wronskian_ratio_antitone (negativeEval_pos hY) jacobiA_pos (resolvent_wronskian hY)) + (signedResolventCoeff_bessel hY) (negativeEval_square_diverges hY) (n+1) + have hs:=wronskian_ratio_step (negativeEval_pos hY) jacobiA_pos (resolvent_wronskian hY) n + have hp : 0 < 1/(jacobiA n*negativeEval Y n*negativeEval Y (n+1)) := + one_div_pos.2 (mul_pos (mul_pos (jacobiA_pos n) (negativeEval_pos hY n)) (negativeEval_pos hY (n+1))) + have hh : 0 < signedResolventCoeff Y n/negativeEval Y n := by linarith + exact (div_pos_iff_of_pos_right (negativeEval_pos hY n)).1 hh +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +lemma poch_ratio_factor_tendsto (a : ℝ) : + Tendsto (fun n:ℕ=>(a+n)/(n+1)) atTop (𝓝 1) := by + have ht : Tendsto (fun n:ℕ=>(n:ℝ)+1) atTop atTop := + tendsto_atTop_mono (fun n:ℕ=>(show (n:ℝ) ≤ (n:ℝ)+1 by linarith)) tendsto_natCast_atTop_atTop + have hh := (tendsto_const_nhds.div_atTop ht (a:=a-1)).add_const 1 + simpa only [zero_add] using hh.congr (fun n=>by change (a-1)/((n:ℝ)+1)+1=(a+n)/(n+1);field_simp;ring) +lemma pochRatio_same_normalized_tendsto {a : ℝ} (ha : 0 < a) : + Tendsto (fun n:ℕ=>pochRatio a n/((n:ℝ)+1)^(a-1)) atTop (𝓝 (1/Gamma a)) := by + have hh:=(pochRatio_normalized_tendsto ha).div (poch_ratio_factor_tendsto a) one_ne_zero + simp only [div_one] at hh + apply hh.congr + intro n + change (pochRatio a (n+1)/((n:ℝ)+1)^(a-1))/((a+n)/(n+1)) = _ + rw [pochRatio_succ] + have hf : (a+(n:ℝ))/(n+1) ≠ 0 := by positivity + field_simp +lemma pochRatio_power_bounds {a : ℝ} (ha : 0 < a) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(a-1) ≤ pochRatio a n ∧ pochRatio a n ≤ C*((n:ℝ)+1)^(a-1) := by + obtain ⟨c,C,hc,hC,h⟩:=positive_sequence_global_bounds + (fun n=>div_pos (pochRatio_pos ha n) (Real.rpow_pos_of_pos (by positivity) _)) + (by positivity : 0 < 1/Gamma a) (pochRatio_same_normalized_tendsto ha) + refine ⟨c,C,hc,hC,fun n=>?_⟩ + exact ⟨(le_div_iff₀ (Real.rpow_pos_of_pos (by positivity) _)).1 (h n).1, + (div_le_iff₀ (Real.rpow_pos_of_pos (by positivity) _)).1 (h n).2⟩ +noncomputable def reciprocalPoch (r : ℝ) (n : ℕ) : ℝ := (pochRatio (r+1) n)⁻¹ +lemma reciprocalPoch_pos {r : ℝ} (hr : 0 < r) (n : ℕ) : 0 < reciprocalPoch r n := + inv_pos.2 (pochRatio_pos (by positivity) n) +lemma reciprocalPoch_step {r : ℝ} (hr : 0 < r) (n : ℕ) : + reciprocalPoch r n-reciprocalPoch r (n+1)=r/(r+n+1)*reciprocalPoch r n := by + unfold reciprocalPoch + rw [pochRatio_succ] + have h0 : pochRatio (r+1) n ≠ 0 := (pochRatio_pos (by positivity) n).ne' + have h1 : r+(n:ℝ)+1 ≠ 0 := by positivity + have h2 : r+1+(n:ℝ) ≠ 0 := by positivity + have h3 : (n:ℝ)+1 ≠ 0 := by positivity + field_simp + ring +lemma reciprocalPoch_normalized_tendsto {r : ℝ} (hr : 0 < r) : + Tendsto (fun n:ℕ=>reciprocalPoch r n/((n:ℝ)+1)^(-r)) atTop (𝓝 ((1/Gamma (r+1))⁻¹)) := by + have hh := (pochRatio_same_normalized_tendsto (by positivity : 0 < r+1)).inv₀ (by positivity) + apply hh.congr + intro n + simp only [add_sub_cancel_right,reciprocalPoch,inv_div] + rw [Real.rpow_neg (by positivity)] + field_simp +lemma reciprocalPoch_bounds {r : ℝ} (hr : 0 < r) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(-r) ≤ reciprocalPoch r n ∧ reciprocalPoch r n ≤ C*((n:ℝ)+1)^(-r) := by + obtain ⟨c,C,hc,hC,h⟩:=positive_sequence_global_bounds + (fun n=>div_pos (reciprocalPoch_pos hr n) (Real.rpow_pos_of_pos (by positivity) _)) + (by positivity : 0 < (1/Gamma (r+1))⁻¹) (reciprocalPoch_normalized_tendsto hr) + refine ⟨c,C,hc,hC,fun n=>?_⟩ + exact ⟨(le_div_iff₀ (Real.rpow_pos_of_pos (by positivity) _)).1 (h n).1, + (div_le_iff₀ (Real.rpow_pos_of_pos (by positivity) _)).1 (h n).2⟩ +lemma reciprocalPoch_zero {r : ℝ} (hr : 0 < r) : Tendsto (reciprocalPoch r) atTop (𝓝 0) := by + have ht : Tendsto (fun n:ℕ=>((n:ℝ)+1)^(-r)) atTop (𝓝 0) := + (tendsto_rpow_neg_atTop hr).comp (tendsto_atTop_mono (fun n:ℕ=>(show (n:ℝ) ≤ (n:ℝ)+1 by linarith)) tendsto_natCast_atTop_atTop) + have hh := (reciprocalPoch_normalized_tendsto hr).mul ht + simp only [mul_zero] at hh + apply hh.congr + intro n + exact div_mul_cancel₀ _ (Real.rpow_pos_of_pos (by positivity) _).ne' +lemma reciprocalPoch_difference_bounds {r : ℝ} (hr : 0 < r) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(-r-1) ≤ reciprocalPoch r n-reciprocalPoch r (n+1) ∧ + reciprocalPoch r n-reciprocalPoch r (n+1) ≤ C*((n:ℝ)+1)^(-r-1) := by + obtain ⟨c,C,hc,hC,h⟩:=reciprocalPoch_bounds hr + refine ⟨r*c/(r+1),r*C,by positivity,by positivity,fun n=>?_⟩ + rw [reciprocalPoch_step hr,Real.rpow_sub_one (by positivity)] + have hratio : r/((r+1)*((n:ℝ)+1)) ≤ r/(r+n+1) ∧ r/(r+n+1) ≤ r/((n:ℝ)+1) := by + constructor <;> apply div_le_div_of_nonneg_left hr.le (by positivity) <;> + nlinarith [Nat.cast_nonneg (α:=ℝ) n] + constructor + · have hh:=mul_le_mul hratio.1 (h n).1 (by positivity) (by positivity) + convert hh using 1; first | rfl | field_simp + · have hh:=mul_le_mul hratio.2 (h n).2 (reciprocalPoch_pos hr n).le (by positivity) + convert hh using 1; first | rfl | field_simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Filter Topology +lemma difference_comparison {r t : ℕ → ℝ} {c C : ℝ} + (hr : Tendsto r atTop (𝓝 0)) (ht : Tendsto t atTop (𝓝 0)) + (hd : ∀ n,c*(t n-t (n+1)) ≤ r n-r (n+1) ∧ r n-r (n+1) ≤ C*(t n-t (n+1))) : + ∀ n,c*t n ≤ r n ∧ r n ≤ C*t n := by + have hl : Antitone (fun n=>r n-c*t n) := by + apply antitone_nat_of_succ_le + intro n + linarith [(hd n).1] + have hu : Antitone (fun n=>C*t n-r n) := by + apply antitone_nat_of_succ_le + intro n + linarith [(hd n).2] + have hlt : Tendsto (fun n=>r n-c*t n) atTop (𝓝 0) := by simpa using hr.sub (ht.const_mul c) + have hut : Tendsto (fun n=>C*t n-r n) atTop (𝓝 0) := by simpa using (ht.const_mul C).sub hr + intro n + have hlo := hl.le_of_tendsto hlt n + have hup := hu.le_of_tendsto hut n + constructor <;> linarith +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology +lemma negativeEval_power_bounds {s : ℝ} (hs : 0 < s) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(s-1/2) ≤ negativeEval s n ∧ + negativeEval s n ≤ C*((n:ℝ)+1)^(s-1/2) := by + obtain ⟨c,C,hc,hC,h⟩:=pochRatio_power_bounds (by positivity : 0 < s+1/2) + refine ⟨min 1 (2*s)*c,(max 1 (2*s)*exp (2*(2*s-1)^2))*C,by positivity,by positivity,fun n=>?_⟩ + have hp:=meixner_even_product_bounds hs n + rw [baseProduct_eq_poch] at hp + have he : s+1/2-1=s-1/2 := by ring + rw [he] at h + constructor + · apply le_trans _ hp.1 + simpa [mul_assoc] using mul_le_mul_of_nonneg_left (h n).1 (by positivity : 0 ≤ min 1 (2*s)) + · exact hp.2.trans (by simpa [mul_assoc] using mul_le_mul_of_nonneg_left (h n).2 (show 0 ≤ max 1 (2*s)*exp (2*(2*s-1)^2) by positivity)) +lemma nat_power_shift_bounds (r : ℝ) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^r ≤ ((n:ℝ)+2)^r ∧ ((n:ℝ)+2)^r ≤ C*((n:ℝ)+1)^r := by + have ht : Tendsto (fun n:ℕ=>((n:ℝ)+2)^r/((n:ℝ)+1)^r) atTop (𝓝 1) := by + have hh := (poch_ratio_factor_tendsto 2).rpow_const (p:=r) (by simp) + simp only [Real.one_rpow] at hh + apply hh.congr + intro n + rw [Real.div_rpow (by positivity) (by positivity)] + simp [add_comm] + obtain ⟨c,C,hc,hC,h⟩:=positive_sequence_global_bounds (fun n=>div_pos (Real.rpow_pos_of_pos (by positivity) _) (Real.rpow_pos_of_pos (by positivity) _)) zero_lt_one ht + exact ⟨c,C,hc,hC,fun n=>⟨(le_div_iff₀ (Real.rpow_pos_of_pos (by positivity) _)).1 (h n).1,(div_le_iff₀ (Real.rpow_pos_of_pos (by positivity) _)).1 (h n).2⟩⟩ +lemma jacobiA_power_bounds (n : ℕ) : + (1/2:ℝ)*((n:ℝ)+1)^2 ≤ jacobiA n ∧ jacobiA n ≤ ((n:ℝ)+1)^2 := by + unfold jacobiA + constructor <;> nlinarith [Nat.cast_nonneg (α:=ℝ) n] +lemma resolvent_denominator_bounds {Y : ℝ} (hY : 0 < Y) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(2*Y+1) ≤ jacobiA n*negativeEval Y n*negativeEval Y (n+1) ∧ + jacobiA n*negativeEval Y n*negativeEval Y (n+1) ≤ C*((n:ℝ)+1)^(2*Y+1) := by + obtain ⟨c,C,hc,hC,h⟩:=negativeEval_power_bounds hY + obtain ⟨d,D,hd,hD,hs⟩:=nat_power_shift_bounds (Y-1/2) + refine ⟨(1/2)*c*c*d,C*C*D,by positivity,by positivity,fun n=>?_⟩ + have hlo : c*d*((n:ℝ)+1)^(Y-1/2) ≤ negativeEval Y (n+1) := by + have hh:=mul_le_mul_of_nonneg_left (hs n).1 hc.le + have he : (n:ℝ)+2=((n+1:ℕ):ℝ)+1 := by push_cast;ring + rw [he] at hh + apply le_trans _ (h (n+1)).1 + simpa [mul_assoc] using hh + have hhi : negativeEval Y (n+1) ≤ C*D*((n:ℝ)+1)^(Y-1/2) := by + have hh:=mul_le_mul_of_nonneg_left (hs n).2 hC.le + have he : (n:ℝ)+2=((n+1:ℕ):ℝ)+1 := by push_cast;ring + rw [he] at hh + exact (h (n+1)).2.trans (by simpa [mul_assoc] using hh) + have he : ((n:ℝ)+1)^2*((n:ℝ)+1)^(Y-1/2)*((n:ℝ)+1)^(Y-1/2)=((n:ℝ)+1)^(2*Y+1) := by + rw [←Real.rpow_natCast,←Real.rpow_add (by positivity),←Real.rpow_add (by positivity)] + congr 1 + push_cast + ring + constructor + · have hh:=mul_le_mul (mul_le_mul (jacobiA_power_bounds n).1 (h n).1 (by positivity) (jacobiA_pos n).le) hlo (by positivity) (mul_pos (jacobiA_pos n) (negativeEval_pos hY n)).le + convert hh using 1; first | rfl | (rw [←he]; ring) + · have hh:=mul_le_mul (mul_le_mul (jacobiA_power_bounds n).2 (h n).2 (negativeEval_pos hY n).le (by positivity)) hhi (negativeEval_pos hY (n+1)).le (by positivity) + convert hh using 1; first | rfl | (rw [←he]; ring) +lemma resolvent_ratio_difference_bounds {Y : ℝ} (hY : 0 < Y) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(-2*Y-1) ≤ signedResolventCoeff Y n/negativeEval Y n-signedResolventCoeff Y (n+1)/negativeEval Y (n+1) ∧ + signedResolventCoeff Y n/negativeEval Y n-signedResolventCoeff Y (n+1)/negativeEval Y (n+1) ≤ C*((n:ℝ)+1)^(-2*Y-1) := by + obtain ⟨c,C,hc,hC,h⟩:=resolvent_denominator_bounds hY + refine ⟨C⁻¹,c⁻¹,by positivity,by positivity,fun n=>?_⟩ + rw [wronskian_ratio_step (negativeEval_pos hY) jacobiA_pos (resolvent_wronskian hY)] + have he : ((n:ℝ)+1)^(-2*Y-1)=(((n:ℝ)+1)^(2*Y+1))⁻¹ := by + rw [show -2*Y-1=-(2*Y+1) by ring,Real.rpow_neg (by positivity)] + rw [he,←mul_inv,←mul_inv,one_div] + have hp : 0 < jacobiA n*negativeEval Y n*negativeEval Y (n+1) := mul_pos (mul_pos (jacobiA_pos n) (negativeEval_pos hY n)) (negativeEval_pos hY (n+1)) + exact ⟨(inv_le_inv₀ (by positivity) hp).2 (h n).2,(inv_le_inv₀ hp (by positivity)).2 (h n).1⟩ +lemma resolvent_ratio_power_bounds {Y : ℝ} (hY : 0 < Y) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(-2*Y) ≤ signedResolventCoeff Y n/negativeEval Y n ∧ + signedResolventCoeff Y n/negativeEval Y n ≤ C*((n:ℝ)+1)^(-2*Y) := by + obtain ⟨a,A,ha,hA,h⟩:=resolvent_ratio_difference_bounds hY + obtain ⟨b,B,hb,hB,hd⟩:=reciprocalPoch_difference_bounds (show 0 < 2*Y by positivity) + obtain ⟨c,C,hc,hC,ht⟩:=reciprocalPoch_bounds (show 0 < 2*Y by positivity) + have hh:=difference_comparison (signedResolventCoeff_ratio_zero hY) (reciprocalPoch_zero (show 0 < 2*Y by positivity)) (c:=a/B) (C:=A/b) (fun n=>by + have he : -(2*Y)-1=-2*Y-1 := by ring + rw [he] at hd + constructor + · have hp:=mul_le_mul_of_nonneg_left (hd n).2 (show 0 ≤ a/B by positivity) + have heq : a/B*(B*((n:ℝ)+1)^(-2*Y-1))=a*((n:ℝ)+1)^(-2*Y-1) := by field_simp + rw [heq] at hp + exact hp.trans (h n).1 + · have hp:=mul_le_mul_of_nonneg_left (hd n).1 (show 0 ≤ A/b by positivity) + have heq : A/b*(b*((n:ℝ)+1)^(-2*Y-1))=A*((n:ℝ)+1)^(-2*Y-1) := by field_simp + rw [heq] at hp + exact (h n).2.trans hp) + refine ⟨a/B*c,A/b*C,by positivity,by positivity,fun n=>?_⟩ + have he : -(2*Y)=-2*Y := by ring + rw [he] at ht + constructor + · apply le_trans _ (hh n).1 + simpa [mul_assoc] using mul_le_mul_of_nonneg_left (ht n).1 (show 0 ≤ a/B by positivity) + · exact (hh n).2.trans (by simpa [mul_assoc] using mul_le_mul_of_nonneg_left (ht n).2 (show 0 ≤ A/b by positivity)) +lemma signedResolventCoeff_power_bounds {Y : ℝ} (hY : 0 < Y) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(-Y-1/2) ≤ signedResolventCoeff Y n ∧ + signedResolventCoeff Y n ≤ C*((n:ℝ)+1)^(-Y-1/2) := by + obtain ⟨a,A,ha,hA,h⟩:=negativeEval_power_bounds hY + obtain ⟨b,B,hb,hB,hd⟩:=resolvent_ratio_power_bounds hY + refine ⟨a*b,A*B,by positivity,by positivity,fun n=>?_⟩ + have he : ((n:ℝ)+1)^(Y-1/2)*((n:ℝ)+1)^(-2*Y)=((n:ℝ)+1)^(-Y-1/2) := by + rw [←Real.rpow_add (by positivity)] + congr 1 + ring + have heq : negativeEval Y n*(signedResolventCoeff Y n/negativeEval Y n)=signedResolventCoeff Y n := mul_div_cancel₀ _ (negativeEval_pos hY n).ne' + constructor + · have hh:=mul_le_mul (h n).1 (hd n).1 (by positivity) (negativeEval_pos hY n).le + rw [heq] at hh + convert hh using 1; first | rfl | (rw [←he]; ring) + · have hh:=mul_le_mul (h n).2 (hd n).2 (div_pos (signedResolventCoeff_pos hY n) (negativeEval_pos hY n)).le (by positivity) + rw [heq] at hh + convert hh using 1; first | rfl | (rw [←he]; ring) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Real Filter Topology +noncomputable def mixedWronskian (v Y : ℝ) (n : ℕ) : ℝ := + jacobiA n*(negativeEval v (n+1)*signedResolventCoeff Y n-negativeEval v n*signedResolventCoeff Y (n+1)) +lemma mixedWronskian_sum {Y : ℝ} (hY : 0 < Y) (v : ℝ) (n : ℕ) : + mixedWronskian v Y n=1-(Y^2-v^2)*(∑ j∈range (n+1),negativeEval v j*signedResolventCoeff Y j) := by + induction n with + | zero => + have ha:=negativeEval_jacobi_zero v + have hd:=signedResolventCoeff_jacobi_zero hY + simp only [mixedWronskian,sum_range_succ,sum_range_zero,zero_add,negativeEval_zero,one_mul] at * + linear_combination signedResolventCoeff Y 0*ha-hd + | succ n ih => + have ha:=negativeEval_jacobi_succ v n + have hd:=signedResolventCoeff_jacobi_succ hY n + rw [sum_range_succ] + dsimp [mixedWronskian] at ih ⊢ + linear_combination signedResolventCoeff Y (n+1)*ha-negativeEval v (n+1)*hd+ih +lemma mixedWronskian_power_bound {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) : + ∃ C : ℝ,0 < C ∧ ∀ n:ℕ,|mixedWronskian v Y n| ≤ C*((n:ℝ)+1)^(v-Y+1) := by + obtain ⟨a,A,ha,hA,h⟩:=negativeEval_power_bounds hv + obtain ⟨b,B,hb,hB,hd⟩:=signedResolventCoeff_power_bounds hY + obtain ⟨c,C,hc,hC,hvshift⟩:=nat_power_shift_bounds (v-1/2) + obtain ⟨d,D,hdp,hD,hYshift⟩:=nat_power_shift_bounds (-Y-1/2) + refine ⟨A*B*(C+D),by positivity,fun n=>?_⟩ + have ha' : negativeEval v (n+1) ≤ A*C*((n:ℝ)+1)^(v-1/2) := by + have hh:=mul_le_mul_of_nonneg_left (hvshift n).2 hA.le + have he : (n:ℝ)+2=((n+1:ℕ):ℝ)+1 := by push_cast;ring + rw [he] at hh + exact (h (n+1)).2.trans (by simpa [mul_assoc] using hh) + have hb' : signedResolventCoeff Y (n+1) ≤ B*D*((n:ℝ)+1)^(-Y-1/2) := by + have hh:=mul_le_mul_of_nonneg_left (hYshift n).2 hB.le + have he : (n:ℝ)+2=((n+1:ℕ):ℝ)+1 := by push_cast;ring + rw [he] at hh + exact (hd (n+1)).2.trans (by simpa [mul_assoc] using hh) + have hp := mul_le_mul ha' (hd n).2 (signedResolventCoeff_pos hY n).le (by positivity) + have hq := mul_le_mul (h n).2 hb' (signedResolventCoeff_pos hY (n+1)).le (by positivity) + have habs : |negativeEval v (n+1)*signedResolventCoeff Y n-negativeEval v n*signedResolventCoeff Y (n+1)| ≤ + A*C*((n:ℝ)+1)^(v-1/2)*(B*((n:ℝ)+1)^(-Y-1/2))+A*((n:ℝ)+1)^(v-1/2)*(B*D*((n:ℝ)+1)^(-Y-1/2)) := by + apply le_trans (by simpa only [sub_zero,zero_sub,abs_neg] using (abs_sub_le (negativeEval v (n+1)*signedResolventCoeff Y n) 0 (negativeEval v n*signedResolventCoeff Y (n+1)))) + rw [abs_of_pos (mul_pos (negativeEval_pos hv _) (signedResolventCoeff_pos hY _)),abs_of_pos (mul_pos (negativeEval_pos hv _) (signedResolventCoeff_pos hY _))] + linarith + have hh:=mul_le_mul (jacobiA_power_bounds n).2 habs (abs_nonneg _) (by positivity) + rw [mixedWronskian,abs_mul,abs_of_pos (jacobiA_pos n)] + apply hh.trans_eq + have he : ((n:ℝ)+1)^2*((n:ℝ)+1)^(v-1/2)*((n:ℝ)+1)^(-Y-1/2)=((n:ℝ)+1)^(v-Y+1) := by + rw [←Real.rpow_natCast,←Real.rpow_add (by positivity),←Real.rpow_add (by positivity)] + congr 1 + push_cast + ring + rw [←he] + ring +lemma mixedWronskian_zero {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) (hgap : v+1 < Y) : + Tendsto (mixedWronskian v Y) atTop (𝓝 0) := by + obtain ⟨C,hC,h⟩:=mixedWronskian_power_bound hY hv + have ht : Tendsto (fun n:ℕ=>C*((n:ℝ)+1)^(v-Y+1)) atTop (𝓝 0) := by + have hh := ((tendsto_rpow_neg_atTop (show 0 < Y-v-1 by linarith)).comp + (tendsto_atTop_mono (fun n:ℕ=>(show (n:ℝ) ≤ (n:ℝ)+1 by linarith)) tendsto_natCast_atTop_atTop)).const_mul C + simp only [mul_zero] at hh + simpa only [Function.comp_apply,show -(Y-v-1)=v-Y+1 by ring] using hh + exact squeeze_zero_norm (by simpa only [Real.norm_eq_abs] using h) ht +noncomputable def resolventEvalResidual (v Y : ℝ) (n : ℕ) : ℝ := + 1/(Y^2-v^2)-(∑ j∈range n,negativeEval v j*signedResolventCoeff Y j) +lemma resolventEvalResidual_zero {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) (hgap : v+1 < Y) : + Tendsto (resolventEvalResidual v Y) atTop (𝓝 0) := by + have hden : Y^2-v^2 ≠ 0 := by nlinarith + apply (tendsto_add_atTop_iff_nat 1).1 + have hh := (mixedWronskian_zero hY hv hgap).div_const (Y^2-v^2) + simp only [zero_div] at hh + apply hh.congr + intro n + dsimp [resolventEvalResidual] + rw [mixedWronskian_sum hY] + field_simp +lemma resolventEvalResidual_step (v Y : ℝ) (n : ℕ) : + resolventEvalResidual v Y n-resolventEvalResidual v Y (n+1)=negativeEval v n*signedResolventCoeff Y n := by + simp only [resolventEvalResidual,sum_range_succ] + ring +lemma resolventEvalResidual_power_bounds {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) (hgap : v+1 < Y) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ n:ℕ, + c*((n:ℝ)+1)^(v-Y) ≤ resolventEvalResidual v Y n ∧ + resolventEvalResidual v Y n ≤ C*((n:ℝ)+1)^(v-Y) := by + obtain ⟨a,A,ha,hA,h⟩:=negativeEval_power_bounds hv + obtain ⟨b,B,hb,hB,hd⟩:=signedResolventCoeff_power_bounds hY + have hr : 0 < Y-v := by linarith + obtain ⟨c,C,hc,hC,ht⟩:=reciprocalPoch_difference_bounds hr + obtain ⟨d,D,hdp,hD,hu⟩:=reciprocalPoch_bounds hr + have hprod (n : ℕ) : a*b*((n:ℝ)+1)^(v-Y-1) ≤ negativeEval v n*signedResolventCoeff Y n ∧ + negativeEval v n*signedResolventCoeff Y n ≤ A*B*((n:ℝ)+1)^(v-Y-1) := by + have he : ((n:ℝ)+1)^(v-1/2)*((n:ℝ)+1)^(-Y-1/2)=((n:ℝ)+1)^(v-Y-1) := by + rw [←Real.rpow_add (by positivity)] + congr 1 + ring + constructor + · have hh:=mul_le_mul (h n).1 (hd n).1 (by positivity) (negativeEval_pos hv n).le + convert hh using 1; first | rfl | (rw [←he];ring) + · have hh:=mul_le_mul (h n).2 (hd n).2 (signedResolventCoeff_pos hY n).le (by positivity) + convert hh using 1; first | rfl | (rw [←he];ring) + have hh:=difference_comparison (resolventEvalResidual_zero hY hv hgap) (reciprocalPoch_zero hr) (c:=a*b/C) (C:=A*B/c) (fun n=>by + rw [resolventEvalResidual_step] + have he : -(Y-v)-1=v-Y-1 := by ring + rw [he] at ht + constructor + · have hp:=mul_le_mul_of_nonneg_left (ht n).2 (show 0 ≤ a*b/C by positivity) + have heq : a*b/C*(C*((n:ℝ)+1)^(v-Y-1))=a*b*((n:ℝ)+1)^(v-Y-1) := by field_simp + rw [heq] at hp + exact hp.trans (hprod n).1 + · have hp:=mul_le_mul_of_nonneg_left (ht n).1 (show 0 ≤ A*B/c by positivity) + have heq : A*B/c*(c*((n:ℝ)+1)^(v-Y-1))=A*B*((n:ℝ)+1)^(v-Y-1) := by field_simp + rw [heq] at hp + exact (hprod n).2.trans hp) + refine ⟨a*b/C*d,A*B/c*D,by positivity,by positivity,fun n=>?_⟩ + have he : -(Y-v)=v-Y := by ring + rw [he] at hu + constructor + · apply le_trans _ (hh n).1 + simpa [mul_assoc] using mul_le_mul_of_nonneg_left (hu n).1 (show 0 ≤ a*b/C by positivity) + · exact (hh n).2.trans (by simpa [mul_assoc] using mul_le_mul_of_nonneg_left (hu n).2 (show 0 ≤ A*B/c by positivity)) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Real Filter Topology +lemma difference_lower_of_nonneg {r t : ℕ → ℝ} {c : ℝ} + (hr : ∀ n,0 ≤ r n) (ht : Tendsto t atTop (𝓝 0)) + (hd : ∀ n,c*(t n-t (n+1)) ≤ r n-r (n+1)) : ∀ n,c*t n ≤ r n := by + have ha : Antitone (fun n=>r n-c*t n) := by + apply antitone_nat_of_succ_le + intro n + linarith [hd n] + intro n + have he : ∀ᶠ m:ℕ in atTop,c*t n-c*t m ≤ r n := by + filter_upwards [eventually_ge_atTop n] with m hm + have hh:=ha hm + linarith [hr m] + have hh : Tendsto (fun m=>c*t n-c*t m) atTop (𝓝 (c*t n)) := by + simpa using tendsto_const_nhds.sub (ht.const_mul c) + exact le_of_tendsto hh he +noncomputable def resolventNormResidual (Y : ℝ) (n : ℕ) : ℝ := + rationalSechMoment Y 2 1-∑ j∈range n,resolventCoeff Y j^2 +lemma resolventNormResidual_nonneg {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + 0 ≤ resolventNormResidual Y n := by + have h:=signedResolventCoeff_bessel hY n + simp only [signedResolventCoeff_sq] at h + exact sub_nonneg.2 h +lemma resolventNormResidual_step (Y : ℝ) (n : ℕ) : + resolventNormResidual Y n-resolventNormResidual Y (n+1)=signedResolventCoeff Y n^2 := by + rw [signedResolventCoeff_sq] + simp only [resolventNormResidual,sum_range_succ] + ring +lemma resolventNormResidual_lower {Y : ℝ} (hY : 0 < Y) : + ∃ c : ℝ,0 < c ∧ ∀ n:ℕ,c*((n:ℝ)+1)^(-2*Y) ≤ resolventNormResidual Y n := by + obtain ⟨a,A,ha,hA,h⟩:=signedResolventCoeff_power_bounds hY + obtain ⟨b,B,hb,hB,ht⟩:=reciprocalPoch_difference_bounds (show 0 < 2*Y by positivity) + obtain ⟨c,C,hc,hC,hu⟩:=reciprocalPoch_bounds (show 0 < 2*Y by positivity) + have hh:=difference_lower_of_nonneg (resolventNormResidual_nonneg hY) (reciprocalPoch_zero (show 0 < 2*Y by positivity)) (c:=a^2/B) (fun n=>by + rw [resolventNormResidual_step] + have hp:=mul_le_mul_of_nonneg_left (ht n).2 (show 0 ≤ a^2/B by positivity) + have he : a^2/B*(B*((n:ℝ)+1)^(-(2*Y)-1))=(a*((n:ℝ)+1)^(-Y-1/2))^2 := by + rw [mul_pow,←Real.rpow_natCast (((n:ℝ)+1)^(-Y-1/2)) 2,←Real.rpow_mul (by positivity)] + simp only [Nat.cast_ofNat] + have he : (-Y-1/2)*(2:ℝ)=-(2*Y)-1 := by ring + rw [he] + field_simp + rw [he] at hp + exact hp.trans (pow_le_pow_left₀ (by positivity) (h n).1 2)) + refine ⟨a^2/B*c,by positivity,fun n=>?_⟩ + have he : -(2*Y)=-2*Y := by ring + rw [he] at hu + apply le_trans _ (hh n) + simpa [mul_assoc] using mul_le_mul_of_nonneg_left (hu n).1 (show 0 ≤ a^2/B by positivity) +lemma resolventNormResidual_pos {Y : ℝ} (hY : 0 < Y) (n : ℕ) : + 0 < resolventNormResidual Y n := by + obtain ⟨c,hc,h⟩:=resolventNormResidual_lower hY + exact lt_of_lt_of_le (by positivity) (h n) +lemma resolventEvalResidual_normalized_bound {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) (hgap : v+1 < Y) : + ∃ C : ℝ,0 < C ∧ ∀ n:ℕ,resolventEvalResidual v Y n^2 ≤ C*((n:ℝ)+1)^(2*v)*resolventNormResidual Y n := by + obtain ⟨a,A,ha,hA,h⟩:=resolventEvalResidual_power_bounds hY hv hgap + obtain ⟨b,hb,hd⟩:=resolventNormResidual_lower hY + refine ⟨A^2/b,by positivity,fun n=>?_⟩ + have hp : 0 ≤ resolventEvalResidual v Y n := le_trans (by positivity) (h n).1 + have hh:=pow_le_pow_left₀ hp (h n).2 2 + have he : (A*((n:ℝ)+1)^(v-Y))^2=(A^2/b)*((n:ℝ)+1)^(2*v)*(b*((n:ℝ)+1)^(-2*Y)) := by + rw [mul_pow,←Real.rpow_natCast (((n:ℝ)+1)^(v-Y)) 2,←Real.rpow_mul (by positivity)] + simp only [Nat.cast_ofNat] + have he2 : ((n:ℝ)+1)^(2*v)*((n:ℝ)+1)^(-2*Y)=((n:ℝ)+1)^((v-Y)*2) := by + rw [←Real.rpow_add (by positivity)] + congr 1 + ring + rw [←he2] + field_simp + rw [he] at hh + exact hh.trans (mul_le_mul_of_nonneg_left (hd n) (by positivity)) +lemma rationalSechMoment_den_twice {Y : ℝ} (hY : 0 < Y) (P : Polynomial ℝ) : + rationalSechMoment Y 2 ((X+Polynomial.C (Y^2))^2*P)=rationalSechMoment Y 0 P := by + rw [show (X+Polynomial.C (Y^2))^2*P=(X+Polynomial.C (Y^2))*((X+Polynomial.C (Y^2))*P) by ring, + rationalSechMoment_den hY 1,rationalSechMoment_den hY 0] +lemma rationalSechMoment_combination {Y : ℝ} (hY : 0 < Y) {n : ℕ} (a : Fin (n+1) → ℝ) (c : ℝ) : + rationalSechMoment Y 2 (((X+Polynomial.C (Y^2))*pollaczekCombination a+Polynomial.C c)^2)= + (∑ j:Fin (n+1),(a j+c*resolventCoeff Y j)^2)+c^2*resolventNormResidual Y (n+1) := by + have he : ((X+Polynomial.C (Y^2))*pollaczekCombination a+Polynomial.C c)^2= + (X+Polynomial.C (Y^2))^2*(pollaczekCombination a*pollaczekCombination a)+ + (2*c) • ((X+Polynomial.C (Y^2))*pollaczekCombination a)+c^2 • (1:Polynomial ℝ) := by + simp only [smul_eq_C_mul,map_mul,map_pow,map_ofNat] + ring + rw [he,rationalSechMoment_add hY,rationalSechMoment_add hY,rationalSechMoment_smul, + rationalSechMoment_smul,rationalSechMoment_den_twice hY,rationalSechMoment_den hY 1, + rationalSechMoment_zero_mul,pollaczekCombination_inner] + have hm : rationalSechMoment Y 1 (pollaczekCombination a)=∑ j:Fin (n+1),a j*resolventCoeff Y j := by + rw [pollaczekCombination,rationalSechMoment_sum hY] + simp only [rationalSechMoment_smul,resolventCoeff] + rw [hm,resolventNormResidual,←Fin.sum_univ_eq_sum_range] + have hs : (∑ j:Fin (n+1),(a j+c*resolventCoeff Y j)^2)=(∑ j:Fin (n+1),a j^2)+2*c*(∑ j:Fin (n+1),a j*resolventCoeff Y j)+c^2*(∑ j:Fin (n+1),resolventCoeff Y j^2) := by + simp only [Finset.mul_sum,←Finset.sum_add_distrib] + apply sum_congr rfl + intro j hj + ring + rw [hs] + ring +lemma rational_combination_eval (Y v c : ℝ) (hden : Y^2-v^2 ≠ 0) {n : ℕ} (a : Fin (n+1) → ℝ) : + (((X+Polynomial.C (Y^2))*pollaczekCombination a+Polynomial.C c).eval (-(v^2)))= + (Y^2-v^2)*((pollaczekCombination (fun j=>a j+c*resolventCoeff Y j)).eval (-(v^2))+c*resolventEvalResidual v Y (n+1)) := by + have he (j : ℕ) : resolventCoeff Y j*(evenPoly (-1) j).eval (-(v^2))=negativeEval v j*signedResolventCoeff Y j := by + rw [evenPoly_negative_eval] + dsimp [negativeEval,signedResolventCoeff] + ring + simp only [eval_add,eval_mul,eval_X,eval_C,pollaczekCombination_eval,add_mul,sum_add_distrib,mul_assoc,he,resolventEvalResidual,←Fin.sum_univ_eq_sum_range,←Finset.mul_sum] + field_simp + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Real Filter Topology +lemma polynomial_linear_decomposition (Y : ℝ) (P : Polynomial ℝ) {n : ℕ} (hP : P.natDegree ≤ n) : + ∃ a : Fin (n+1) → ℝ,∃ c : ℝ,P=(X+Polynomial.C (Y^2))*pollaczekCombination a+Polynomial.C c := by + let q : Polynomial ℝ := X+Polynomial.C (Y^2) + let Q : Polynomial ℝ := P /ₘ q + have hQ : Q.natDegree ≤ n := + (Polynomial.natDegree_le_natDegree (degree_divByMonic_le P q)).trans hP + obtain ⟨a,ha⟩:=polynomial_eq_pollaczek_sum Q hQ + refine ⟨a,P.eval (-(Y^2)),?_⟩ + have hq : q=X-Polynomial.C (-(Y^2)) := by simp only [q,map_neg,sub_neg_eq_add] + have hm : P %ₘ q=Polynomial.C (P.eval (-(Y^2))) := by + rw [hq,modByMonic_X_sub_C_eq_C_eval] + have hh : Polynomial.C (P.eval (-(Y^2)))+q*Q=P := by + simpa only [Q,hm] using modByMonic_add_div P q + change pollaczekCombination a=Q at ha + rw [ha] + exact hh.symm.trans (add_comm _ _) +lemma rational_polynomial_evaluation_bound {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) (hgap : v+1 < Y) : + ∃ C : ℝ,0 < C ∧ ∀ᶠ n:ℕ in atTop,∀ P : Polynomial ℝ,P.natDegree ≤ n → + P.eval (-(v^2))^2 ≤ C*((n:ℝ)+1)^(2*v)*rationalSechMoment Y 2 (P^2) := by + obtain ⟨k,K,hk,hK,hkernel⟩:=polynomialChristoffel_bounds hv + obtain ⟨E,hE,he⟩:=resolventEvalResidual_normalized_bound hY hv hgap + obtain ⟨d,D,hd,hD,hshift⟩:=nat_power_shift_bounds (2*v) + have hden : Y^2-v^2 ≠ 0 := by nlinarith + let C0 := 2*(K+E*D) + have hC0 : 0 < C0 := by dsimp [C0];positivity + refine ⟨(Y^2-v^2)^2*C0,mul_pos (sq_pos_of_ne_zero hden) hC0,?_⟩ + filter_upwards [hkernel] with n hn + intro P hP + obtain ⟨a,c,rfl⟩:=polynomial_linear_decomposition Y P hP + let z : Fin (n+1) → ℝ := fun j=>a j+c*resolventCoeff Y j + let F := ∑ j:Fin (n+1),z j^2 + have hF : 0 ≤ F := sum_nonneg (fun j _=>sq_nonneg _) + have hN : 0 ≤ resolventNormResidual Y (n+1) := resolventNormResidual_nonneg hY _ + have hkbound : (pollaczekCombination z).eval (-(v^2))^2 ≤ F*(K*((n:ℝ)+1)^(2*v)) := by + have hh:=polynomial_evaluation_bound (pollaczekCombination z) (pollaczekCombination_degree z) (-(v^2)) + rw [pollaczekCombination_inner,←polynomialChristoffel_eq_sum] at hh + exact hh.trans (mul_le_mul_of_nonneg_left hn.2 hF) + have hebound : resolventEvalResidual v Y (n+1)^2 ≤ E*D*((n:ℝ)+1)^(2*v)*resolventNormResidual Y (n+1) := by + have hh:=mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (hshift n).2 hE.le) hN + have hn2 : (n:ℝ)+2=((n+1:ℕ):ℝ)+1 := by push_cast;ring + rw [hn2] at hh + exact (he (n+1)).trans (by simpa [mul_assoc] using hh) + have hb : ((pollaczekCombination z).eval (-(v^2))+c*resolventEvalResidual v Y (n+1))^2 ≤ + C0*((n:ℝ)+1)^(2*v)*(F+c^2*resolventNormResidual Y (n+1)) := by + have h1:=mul_le_mul_of_nonneg_left hebound (sq_nonneg c) + have hs := sq_nonneg ((pollaczekCombination z).eval (-(v^2))-c*resolventEvalResidual v Y (n+1)) + have hk0 : 0 ≤ K*((n:ℝ)+1)^(2*v)*(c^2*resolventNormResidual Y (n+1)) := by positivity + have he0 : 0 ≤ E*D*((n:ℝ)+1)^(2*v)*F := by positivity + dsimp [C0] + nlinarith + rw [rational_combination_eval Y v c hden,mul_pow,rationalSechMoment_combination hY] + have hh:=mul_le_mul_of_nonneg_left hb (sq_nonneg (Y^2-v^2)) + simpa only [F,z,mul_assoc] using hh +noncomputable def rationalPolynomialChristoffel (Y : ℝ) (n : ℕ) (x : ℝ) : ℝ := + sSup {r : ℝ | ∃ P : Polynomial ℝ,P.natDegree ≤ n ∧ r=P.eval x^2/rationalSechMoment Y 2 (P^2)} +lemma rational_polynomial_ratio_bound {Y v : ℝ} {K : ℝ} (hK : 0 < K) + {n : ℕ} (h : ∀ P : Polynomial ℝ,P.natDegree ≤ n → P.eval (-(v^2))^2 ≤ K*rationalSechMoment Y 2 (P^2)) + (P : Polynomial ℝ) (hP : P.natDegree ≤ n) : + P.eval (-(v^2))^2/rationalSechMoment Y 2 (P^2) ≤ K := by + rcases (rationalSechMoment_sq_nonneg Y 2 P).eq_or_lt with hz|hp + · rw [←hz,div_zero] + exact hK.le + · exact (div_le_iff₀ hp).2 (h P hP) +lemma rationalPolynomialChristoffel_upper {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) (hgap : v+1 < Y) : + ∃ C : ℝ,0 < C ∧ ∀ᶠ n:ℕ in atTop,rationalPolynomialChristoffel Y n (-(v^2)) ≤ C*((n:ℝ)+1)^(2*v) := by + obtain ⟨C,hC,h⟩:=rational_polynomial_evaluation_bound hY hv hgap + refine ⟨C,hC,?_⟩ + filter_upwards [h] with n hn + have hnonempty : {r : ℝ | ∃ P : Polynomial ℝ,P.natDegree ≤ n ∧ r=P.eval (-(v^2))^2/rationalSechMoment Y 2 (P^2)}.Nonempty := + ⟨_,0,by simp, rfl⟩ + apply csSup_le hnonempty + rintro r ⟨P,hP,rfl⟩ + exact rational_polynomial_ratio_bound (by positivity) hn P hP +lemma rationalPolynomialChristoffel_bounds {Y v : ℝ} (hY : 0 < Y) (hv : 0 < v) (hgap : v+1 < Y) : + ∃ c C : ℝ,0 < c ∧ 0 < C ∧ ∀ᶠ n:ℕ in atTop, + c*((n:ℝ)+1)^(2*v) ≤ rationalPolynomialChristoffel Y (n+1) (-(v^2)) ∧ + rationalPolynomialChristoffel Y (n+1) (-(v^2)) ≤ C*((n:ℝ)+1)^(2*v) := by + obtain ⟨a,A,ha,hA,h⟩:=polynomialChristoffel_bounds hv + obtain ⟨B,hB,hb⟩:=rational_polynomial_evaluation_bound hY hv hgap + obtain ⟨d,D,hd,hD,hshift⟩:=nat_power_shift_bounds (2*v) + have hden : Y^2-v^2 ≠ 0 := by nlinarith + refine ⟨(Y^2-v^2)^2*a,B*D,by positivity,by positivity,?_⟩ + have hb' : ∀ᶠ n:ℕ in atTop,∀ P : Polynomial ℝ,P.natDegree ≤ n+1 → P.eval (-(v^2))^2 ≤ B*((((n+1:ℕ):ℝ))+1)^(2*v)*rationalSechMoment Y 2 (P^2) := (tendsto_add_atTop_nat 1).eventually hb + filter_upwards [h,hb'] with n hn hbn + have hbound : BddAbove {r : ℝ | ∃ P : Polynomial ℝ,P.natDegree ≤ n+1 ∧ r=P.eval (-(v^2))^2/rationalSechMoment Y 2 (P^2)} := by + refine ⟨B*((((n+1:ℕ):ℝ))+1)^(2*v),?_⟩ + rintro r ⟨P,hP,rfl⟩ + exact rational_polynomial_ratio_bound (by positivity) hbn P hP + constructor + · obtain ⟨Q,hQ,hQe⟩:=polynomial_evaluation_ratio_attained n (-(v^2)) + let P := (X+Polynomial.C (Y^2))*Q + have hP : P.natDegree ≤ n+1 := by + apply (Polynomial.natDegree_mul_le).trans + have hlin : (X+Polynomial.C (Y^2)).natDegree ≤ 1 := by + apply natDegree_add_le_of_degree_le (by simp) (by simp) + omega + have hPe : P.eval (-(v^2))^2/rationalSechMoment Y 2 (P^2)=(Y^2-v^2)^2*polynomialChristoffel n (-(v^2)) := by + have hm : rationalSechMoment Y 2 (P^2)=polynomialSechInner Q Q := by + dsimp [P] + rw [mul_pow,rationalSechMoment_den_twice hY,show Q^2=Q*Q by ring,rationalSechMoment_zero_mul] + rw [hm] + dsimp [P] + simp only [eval_mul,eval_add,eval_X,eval_C] + rw [show -(v^2)+Y^2=Y^2-v^2 by ring,mul_pow,mul_div_assoc,hQe,polynomialChristoffel_eq_sum] + have hs : P.eval (-(v^2))^2/rationalSechMoment Y 2 (P^2) ≤ rationalPolynomialChristoffel Y (n+1) (-(v^2)) := + le_csSup hbound ⟨P,hP,rfl⟩ + rw [hPe] at hs + apply le_trans _ hs + simpa [mul_assoc] using mul_le_mul_of_nonneg_left hn.1 (sq_nonneg (Y^2-v^2)) + · have hu : rationalPolynomialChristoffel Y (n+1) (-(v^2)) ≤ B*((((n+1:ℕ):ℝ))+1)^(2*v) := by + have hne : {r : ℝ | ∃ P : Polynomial ℝ,P.natDegree ≤ n+1 ∧ r=P.eval (-(v^2))^2/rationalSechMoment Y 2 (P^2)}.Nonempty := ⟨_,0,by simp,rfl⟩ + apply csSup_le hne + rintro r ⟨P,hP,rfl⟩ + exact rational_polynomial_ratio_bound (by positivity) hbn P hP + have hh:=mul_le_mul_of_nonneg_left (hshift n).2 hB.le + have hn2 : (n:ℝ)+2=((n+1:ℕ):ℝ)+1 := by push_cast;ring + rw [hn2] at hh + exact hu.trans (by simpa [mul_assoc] using hh) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Real MeasureTheory Filter Topology +noncomputable def sechWeight (c p : ℝ) : ℝ := (2*c/Real.pi)/Real.cosh (c*p) +noncomputable def rationalSechWeight (c Y p : ℝ) : ℝ := sechWeight c p/(p^2+Y^2)^2 +lemma sechWeight_pos {c : ℝ} (hc : 0 < c) (p : ℝ) : 0 < sechWeight c p := by + unfold sechWeight; positivity +lemma rationalSechWeight_pos {c Y : ℝ} (hc : 0 < c) (hY : 0 < Y) (p : ℝ) : 0 < rationalSechWeight c Y p := + div_pos (sechWeight_pos hc p) (sq_pos_of_pos (by positivity)) +lemma sechWeight_moments {c : ℝ} (hc : 0 < c) (k : ℕ) : + IntegrableOn (fun p : ℝ=>p^k*sechWeight c p) (Set.Ioi 0) := by + apply ((pow_sech_integrable k hc).const_mul (2*c/Real.pi)).congr + filter_upwards with p + unfold sechWeight + ring +lemma rationalSechWeight_moments {c Y : ℝ} (hc : 0 < c) (hY : 0 < Y) (k : ℕ) : + IntegrableOn (fun p : ℝ=>p^k*rationalSechWeight c Y p) (Set.Ioi 0) := by + have hden p : 0 < p^2+Y^2 := by positivity + apply ((sechWeight_moments hc k).norm.div_const ((Y^2)^2)).mono' + · exact (by unfold rationalSechWeight sechWeight;fun_prop : Measurable (fun p : ℝ=>p^k*rationalSechWeight c Y p)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hw := (sechWeight_pos hc p).le + simp only [rationalSechWeight,←mul_div_assoc,Real.norm_eq_abs, + abs_of_pos (sq_pos_of_pos (hden p)),abs_div,abs_of_nonneg (mul_nonneg (pow_nonneg hp.le k) hw)] + exact div_le_div_of_nonneg_left (mul_nonneg (pow_nonneg hp.le k) hw) (by positivity) (by gcongr;exact le_add_of_nonneg_left (sq_nonneg p)) +lemma weightedNorm_sech (c : ℝ) (P : Polynomial ℝ) : + weightedPolynomialNorm (sechWeight c) P=scaledSechInner c P P := by + unfold weightedPolynomialNorm scaledSechInner sechExpectation sechWeight + rw [←integral_const_mul] + congr 1 + ext p + ring +lemma weightedKernel_sech (c : ℝ) (n : ℕ) (x : ℝ) : + weightedPolynomialChristoffel (sechWeight c) n x=scaledPolynomialChristoffel c n x := by + simp only [weightedPolynomialChristoffel,scaledPolynomialChristoffel,weightedNorm_sech] +lemma weightedNorm_rationalSech (c Y : ℝ) (P : Polynomial ℝ) : + weightedPolynomialNorm (rationalSechWeight c Y) P= + sechExpectation c (fun x=>P.eval x^2/(x+Y^2)^2) := by + unfold weightedPolynomialNorm rationalSechWeight sechWeight sechExpectation + rw [←integral_const_mul] + congr 1 + ext p + ring +lemma weightedNorm_rationalSech_scale {c : ℝ} (hc : 0 < c) (Y : ℝ) (P : Polynomial ℝ) : + weightedPolynomialNorm (rationalSechWeight c Y) P= + (c/Real.pi)^4*rationalSechMoment (c*Y/Real.pi) 2 ((polynomialDilate ((Real.pi/c)^2) P)^2) := by + rw [weightedNorm_rationalSech,sechExpectation_scale hc] + unfold sechExpectation rationalSechMoment + simp only [mul_div_cancel_right₀ _ Real.pi_ne_zero,eval_pow,polynomialDilate_eval] + rw [mul_left_comm ((c/Real.pi)^4) 2] + congr 1 + rw [←integral_const_mul] + apply integral_congr_ae + filter_upwards with p + have hd : (Real.pi/c)^2*p^2+Y^2=(Real.pi/c)^2*(p^2+(c*Y/Real.pi)^2) := by field_simp + rw [hd,mul_pow] + field_simp +lemma rationalSechWeight_evaluation_bound {c Y y : ℝ} (hc : 0 < c) (hY : 0 < Y) (hy : 0 < y) + (hgap : c*y/Real.pi+1 < c*Y/Real.pi) : + ∃ C : ℝ,0 < C ∧ ∀ᶠ n : ℕ in atTop,∀ P : Polynomial ℝ,P.natDegree ≤ n → + P.eval (-(y^2))^2 ≤ C*((n:ℝ)+1)^(2*c*y/Real.pi)*weightedPolynomialNorm (rationalSechWeight c Y) P := by + obtain ⟨B,hB,hb⟩:=rational_polynomial_evaluation_bound (by positivity : 0 < c*Y/Real.pi) + (by positivity : 0 < c*y/Real.pi) hgap + refine ⟨B/(c/Real.pi)^4,by positivity,?_⟩ + filter_upwards [hb] with n hn P hP + have h:=hn (polynomialDilate ((Real.pi/c)^2) P) ((polynomialDilate_degree _ P).trans hP) + rw [polynomialDilate_eval] at h + have he : (Real.pi/c)^2*(-((c*y/Real.pi)^2))=-(y^2) := by field_simp + rw [he] at h + rw [weightedNorm_rationalSech_scale hc] + convert h using 1; field_simp +lemma weightedKernel_rationalSech_upper {c Y y : ℝ} (hc : 0 < c) (hY : 0 < Y) (hy : 0 < y) + (hgap : c*y/Real.pi+1 < c*Y/Real.pi) : + ∃ C : ℝ,0 < C ∧ ∀ᶠ n : ℕ in atTop, + weightedPolynomialChristoffel (rationalSechWeight c Y) n (-(y^2)) ≤ C*((n:ℝ)+1)^(2*c*y/Real.pi) := by + obtain ⟨C,hC,h⟩:=rationalSechWeight_evaluation_bound hc hY hy hgap + refine ⟨C,hC,?_⟩ + filter_upwards [h] with n hn + obtain ⟨P,hP,hPe⟩:=weightedPolynomial_ratio_attained n (-(y^2)) (rationalSechWeight c Y) + (fun p _=>rationalSechWeight_pos hc hY p) (rationalSechWeight_moments hc hY) + rw [←hPe] + by_cases hz : P=0 + · simp only [hz,eval_zero,zero_pow (by omega : 2≠0),zero_div] + positivity + · exact (div_le_iff₀ (weightedPolynomialNorm_pos _ (fun p _=>rationalSechWeight_pos hc hY p) + (rationalSechWeight_moments hc hY) hz)).mpr (hn P hP) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/RowExchange.lean b/lean/OAI/Combinatorics/HoneycombChords/RowExchange.lean new file mode 100644 index 0000000000000000000000000000000000000000..5155d61425869de3f65b0d6c845d69300313caba --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/RowExchange.lean @@ -0,0 +1,116 @@ +import Mathlib.Basic.Complex.Basic +import Mathlib.LinearAlgebra.Matrix.ConjTranspose +import Mathlib.LinearAlgebra.Matrix.Kronecker + +namespace OAI + +/-! +# Monodromy row exchange and fusion + +Formalized from *Uniform marked polygon estimates and sharp finite bridge moments* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open scoped Matrix BigOperators +abbrev Spin := Fin 3 +abbrev Local := Matrix (Spin×Spin) (Spin×Spin) ℂ +abbrev Space (n : ℕ) := Fin n→Spin +noncomputable def block (A : Local) (s t : Spin) : Matrix Spin Spin ℂ := + fun a b=>A (a,s) (b,t) + +noncomputable def row : (n : ℕ)→(Fin n→Local)→Space n→Space n→Matrix Spin Spin ℂ + | 0,_,_,_=>1 + | n+1,A,s,t=>block (A 0) (s 0) (t 0)*row n (Fin.tail A) (Fin.tail s) (Fin.tail t) +noncomputable def forward (n : ℕ) (A B : Fin n→Local) (s t : Space n) : Local := + ∑ v : Space n,Matrix.kronecker (row n A s v) (row n B v t) +noncomputable def backward (n : ℕ) (A B : Fin n→Local) (s t : Space n) : Local := + ∑ v : Space n,Matrix.kronecker (row n A v t) (row n B s v) +noncomputable def localForward (A B : Local) (s t : Spin) : Local := + ∑ v : Spin,Matrix.kronecker (block A s v) (block B v t) +noncomputable def localBackward (A B : Local) (s t : Spin) : Local := + ∑ v : Spin,Matrix.kronecker (block A v t) (block B s v) +lemma sum_space_succ {M : Type*} [AddCommMonoid M] (n : ℕ) (f : Space (n+1)→M) : + (∑ v,f v)=∑ a : Spin,∑ v : Space n,f (Fin.cons a v) := by + calc + _ = ∑ p : Spin×Space n,f (Fin.cons p.1 p.2) := (Fintype.sum_equiv (Fin.consEquiv (fun _ : Fin (n+1)=>Spin)) + (fun p : Spin×Space n=>f (Fin.cons p.1 p.2)) f (fun p=>rfl)).symm + _ = _ := Fintype.sum_prod_type _ +lemma forward_succ (n : ℕ) (A B : Fin (n+1)→Local) (s t : Space (n+1)) : + forward (n+1) A B s t= + localForward (A 0) (B 0) (s 0) (t 0)* + forward n (Fin.tail A) (Fin.tail B) (Fin.tail s) (Fin.tail t) := by + unfold forward + rw [sum_space_succ] + simp only [row,Fin.cons_zero,Fin.tail_cons,Matrix.kronecker,Matrix.mul_kronecker_mul] + simp only [localForward,Matrix.kronecker,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] +lemma backward_succ (n : ℕ) (A B : Fin (n+1)→Local) (s t : Space (n+1)) : + backward (n+1) A B s t= + localBackward (A 0) (B 0) (s 0) (t 0)* + backward n (Fin.tail A) (Fin.tail B) (Fin.tail s) (Fin.tail t) := by + unfold backward + rw [sum_space_succ] + simp only [row,Fin.cons_zero,Fin.tail_cons,Matrix.kronecker,Matrix.mul_kronecker_mul] + simp only [localBackward,Matrix.kronecker,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] + +theorem row_exchange (n : ℕ) (F : Local) (A B : Fin n→Local) + (h : ∀ i s t,F*localForward (A i) (B i) s t=localBackward (A i) (B i) s t*F) + (s t : Space n) : F*forward n A B s t=backward n A B s t*F := by + induction n with + | zero => simp [forward,backward,row] + | succ n ih => + rw [forward_succ,backward_succ,←mul_assoc,h 0,mul_assoc, + ih (Fin.tail A) (Fin.tail B) (fun i=>h i.succ),←mul_assoc] +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open scoped Matrix BigOperators + +theorem row_fusion (n : ℕ) (W : Matrix (Spin×Spin) Spin ℂ) + (A B C : Fin n→Local) + (h : ∀ i s t,localBackward (A i) (B i) s t*W=W*block (C i) s t) + (s t : Space n) : backward n A B s t*W=W*row n C s t := by + induction n with + | zero => simp [backward,row,Matrix.kronecker] + | succ n ih => + rw [backward_succ,Matrix.mul_assoc,ih (Fin.tail A) (Fin.tail B) (Fin.tail C) + (fun i=>h i.succ),←Matrix.mul_assoc,h 0,Matrix.mul_assoc] + rfl + +theorem row_quotient_fusion (n : ℕ) (Z : Matrix Spin (Spin×Spin) ℂ) + (A B C : Fin n→Local) + (h : ∀ i s t,Z*localForward (A i) (B i) s t=block (C i) s t*Z) + (s t : Space n) : Z*forward n A B s t=row n C s t*Z := by + induction n with + | zero => simp [forward,row,Matrix.kronecker] + | succ n ih => + rw [forward_succ,←Matrix.mul_assoc,h 0,Matrix.mul_assoc,ih (Fin.tail A) (Fin.tail B) + (Fin.tail C) (fun i=>h i.succ),←Matrix.mul_assoc] + rfl +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open scoped Matrix BigOperators +lemma block_conjTranspose (A : Local) (hA : A.conjTranspose=A) (s t : Spin) : + (block A s t).conjTranspose=block A t s := by + ext a b + exact congrFun (congrFun hA (a,t)) (b,s) +lemma localBackward_conjTranspose (A B : Local) (hA : A.conjTranspose=A) + (hB : B.conjTranspose=B) (s t : Spin) : + (localBackward A B s t).conjTranspose=localForward A B t s := by + simp only [localBackward,localForward,Matrix.conjTranspose_sum,Matrix.kronecker, + Matrix.conjTranspose_kronecker,block_conjTranspose A hA,block_conjTranspose B hB] +end CriticalHoneycomb.Transfer.RowExchange + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/SechExpectation.lean b/lean/OAI/Combinatorics/HoneycombChords/SechExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..191e5c7ae61294823debe6a9cf8883a83f1e9634 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/SechExpectation.lean @@ -0,0 +1,23 @@ +import OAI.Combinatorics.HoneycombChords.SechTransform + +namespace OAI + +/-! Normalized expectation for the hyperbolic secant measure. -/ + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology MeasureTheory Analytic + +/-- The probability average under dp/cosh(cp), pushed forward by p ↦ p². +The transform below also proves its normalization. -/ +noncomputable def sechExpectation (c : ℝ) (H : ℝ → ℝ) : ℝ := + (2*c/Real.pi)*(∫ p in Set.Ioi (0:ℝ),H (p^2)/Real.cosh (c*p)) +lemma sechExpectation_one {c : ℝ} (hc : 0 < c) : sechExpectation c (fun _=>1)=1 := by + unfold sechExpectation + have h:=sech_kernel_integral hc (m:=0) (by simpa using hc) + simp only [zero_mul,Real.cosh_zero,Real.cos_zero,div_one,mul_zero,zero_div] at h + rw [h] + field_simp + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/SechResidual.lean b/lean/OAI/Combinatorics/HoneycombChords/SechResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..d064fa5e9095e26c78e3404eb8de74843ce8cec2 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/SechResidual.lean @@ -0,0 +1,349 @@ +import OAI.Combinatorics.HoneycombChords.FamilyGram +import OAI.Combinatorics.HoneycombChords.SechExpectation +import OAI.Combinatorics.HoneycombChords.CauchyResidual + +namespace OAI + +/-! Polynomial generating functions and hyperbolic secant Gram residuals. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Filter Topology MeasureTheory +open Analytic +noncomputable def alpha (c : ℝ) : ℝ := Real.pi/(2*c) +noncomputable def A (c m x : ℝ) : ℝ := Real.cos (alpha c*m)*(C m x).re +noncomputable def w (c m : ℝ) : ℝ := Real.tan (alpha c*m)^2 +lemma sec_pair_identity {a b : ℝ} (h : |a|+|b| < Real.pi/2) : + Real.cos a*Real.cos b*(1/Real.cos (a+b)+1/Real.cos (a-b))/2= + 1/(1-Real.tan a^2*Real.tan b^2) := by + have hp := (Real.cos_pos_of_mem_Ioo (abs_lt.mp (lt_of_le_of_lt (abs_add_le a b) h))).ne' + have hm := (Real.cos_pos_of_mem_Ioo (abs_lt.mp (lt_of_le_of_lt (abs_sub a b) h))).ne' + have ha := (Real.cos_pos_of_mem_Ioo (abs_lt.mp (show |a| < Real.pi/2 by linarith [abs_nonneg b]))).ne' + have hb := (Real.cos_pos_of_mem_Ioo (abs_lt.mp (show |b| < Real.pi/2 by linarith [abs_nonneg a]))).ne' + have hd : Real.cos (a+b)*Real.cos (a-b)=Real.cos a^2*Real.cos b^2-Real.sin a^2*Real.sin b^2 := by + rw [Real.cos_add,Real.cos_sub];ring + have ht : 1-Real.tan a^2*Real.tan b^2= + Real.cos (a+b)*Real.cos (a-b)/(Real.cos a^2*Real.cos b^2) := by + rw [hd,Real.tan_eq_sin_div_cos,Real.tan_eq_sin_div_cos] + field_simp + rw [ht] + field_simp [ha,hb,hp,hm] + rw [Real.cos_add,Real.cos_sub] + ring +lemma alpha_pair_bound {c m n : ℝ} (hc : 0 < c) (h : |m|+|n| < c) : + |alpha c*m|+|alpha c*n| < Real.pi/2 := by + have hα : 0 < alpha c := by unfold alpha;positivity + have he : alpha c*c=Real.pi/2 := by unfold alpha;field_simp + rw [abs_mul,abs_mul,abs_of_pos hα,←mul_add,←he] + exact mul_lt_mul_of_pos_left h hα +lemma A_sq (c m : ℝ) {p : ℝ} (hp : 0 ≤ p) : + A c m (p^2)=Real.cos (alpha c*m)*Real.cosh (m*p) := by + simp only [A,C_sq m hp,Complex.ofReal_re] +lemma A_pair_integrable {c m n : ℝ} (hc : 0 < c) (h : |m|+|n| < c) : + IntegrableOn (fun p => A c m (p^2)*A c n (p^2)/Real.cosh (c*p)) (Set.Ioi 0) := by + apply ((sech_pair_integrable hc h).const_mul (Real.cos (alpha c*m)*Real.cos (alpha c*n))).congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [A_sq c m hp.le,A_sq c n hp.le] + ring + +lemma polynomial_generating_identity {c m n : ℝ} (hc : 0 < c) (h : |m|+|n| < c) : + sechExpectation c (fun x => A c m x*A c n x)=1/(1-w c m*w c n) := by + have he : (∫ p in Set.Ioi (0:ℝ),A c m (p^2)*A c n (p^2)/Real.cosh (c*p))= + (Real.cos (alpha c*m)*Real.cos (alpha c*n))* + ∫ p in Set.Ioi (0:ℝ),Real.cosh (m*p)*Real.cosh (n*p)/Real.cosh (c*p) := by + rw [←integral_const_mul] + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [A_sq c m hp.le,A_sq c n hp.le] + ring + unfold sechExpectation + rw [he,sech_pair_integral hc h] + have hp : Real.pi*(m+n)/(2*c)=alpha c*m+alpha c*n := by unfold alpha;ring + have hm : Real.pi*(m-n)/(2*c)=alpha c*m-alpha c*n := by unfold alpha;ring + rw [hp,hm] + have coeff : (2*c/Real.pi)*(Real.pi/(4*c))=(1:ℝ)/2 := by field_simp; ring + calc + _=(Real.cos (alpha c*m)*Real.cos (alpha c*n)) * + (1/Real.cos (alpha c*m+alpha c*n)+1/Real.cos (alpha c*m-alpha c*n))/2 := by + calc + _=((2*c/Real.pi)*(Real.pi/(4*c)))* + ((Real.cos (alpha c*m)*Real.cos (alpha c*n))* + (1/Real.cos (alpha c*m+alpha c*n)+1/Real.cos (alpha c*m-alpha c*n))) := by ring + _=_ := by rw [coeff];ring + _=1/(1-w c m*w c n) := sec_pair_identity (alpha_pair_bound hc h) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Honeycomb370 Matrix Finset MeasureTheory + +lemma meanResidualRatio_coefficients {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) (c : Fin n → ℝ) + (hi : ∀ i j,IntegrableOn (fun p ↦ F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p ↦ H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hd : (familyGram w F G).det≠0) (ha : H a≠0) + (horth : c ᵥ* familyGram w F G=fun j ↦ ∫ p in Set.Ioi 0,H (p^2)*G j (p^2)*w p) : + H a*meanResidualRatio w F G H a=H a-∑ i,c i*F i a := by + rw [meanResidualRatio_formula w F G H a hi hH hd,←horth, + Matrix.dotProduct_mulVec,Matrix.vecMul_vecMul,Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr hd), + Matrix.vecMul_one] + simp only [dotProduct,mul_sub,mul_one,mul_sum] + congr 1 + apply sum_congr rfl + intro i _ + field_simp + +/-- Binding the explicit Cauchy model estimate to the actual nonsymmetric +Gram projection. Its analytic realization is supplied by the sech transform. -/ +theorem cauchyGram_coefficient_lower (N : ℕ) (q : Fin (2*N) → ℝ) (u t : ℝ) + (w : ℝ → ℝ) (F G : Fin (2*N+1) → ℝ → ℝ) (H : ℝ → ℝ) + (hq : ∀ i,0≤q i ∧ q i≤1/2) (hu : 0≤u ∧ u≤1/2) (ht : 0≤t ∧ t≤1/2) + (hinj : Function.Injective (Fin.lastCases t q)) + (hi : ∀ i j,IntegrableOn (fun p ↦ F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p ↦ H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hd : (familyGram w F G).det≠0) + (hGram : ∀ i j,familyGram w F G i j=1/(1-Fin.lastCases u q i*Fin.lastCases t q j)) + (hMom : ∀ j,(∫ p in Set.Ioi 0,H (p^2)*G j (p^2)*w p)=1/(1-Fin.lastCases t q j)) + (hF0 : ∀ i,F i 0=1/Real.sqrt (1+Fin.lastCases u q i)) (hH0 : H 0=1/Real.sqrt 2) : + 1/(68*Real.pi*Real.sqrt ((N:ℝ)+1)) ≤ -(H 0*meanResidualRatio w F G H 0) := by + let M:=familyGram w F G + let v:=fun j ↦ ∫ p in Set.Ioi 0,H (p^2)*G j (p^2)*w p + let c:=v ᵥ* M⁻¹ + have horth : c ᵥ* M=v := by + dsimp [c] + rw [Matrix.vecMul_vecMul,Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr hd),Matrix.vecMul_one] + have hco (j : Fin (2*N+1)) : 1/(1-Fin.lastCases t q j)= + ∑ i,c i/(1-Fin.lastCases u q i*Fin.lastCases t q j) := by + have h:=congrFun horth j + dsimp only [Matrix.vecMul,dotProduct,M,v] at h + simp_rw [hGram,hMom,mul_one_div] at h + exact h.symm + have hh:=cauchyResidual_zero_lower N q u t c hq hu ht hinj hco + rw [meanResidualRatio_coefficients w F G H 0 c hi hH hd (by rw [hH0]; positivity) horth,hH0] + simpa only [hF0,mul_one_div] using hh + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Honeycomb370 Matrix Finset MeasureTheory Real + +noncomputable def sechProbDensity (c p : ℝ) : ℝ := (2*c/Real.pi)/Real.cosh (c*p) + +lemma A_pair_prob_integrable {c m n : ℝ} (hc : 0.mpr ht1 + unfold w + constructor + · positivity + · have hsq : (1/Real.sqrt 3)^2=(1:ℝ)/3 := by rw [div_pow,one_pow,hs] + rw [hsq] at ht2 + linarith + +lemma A_zero {c m : ℝ} (hc : 0 linarith [Real.pi_pos]) + (show alpha c*n∈Set.Ioo (-(Real.pi/2)) (Real.pi/2) by constructor <;> linarith [Real.pi_pos]) he + exact mul_left_cancel₀ ha.ne' hh + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open MeasureTheory + +lemma sech_label_margin {b c : ℝ} (hb : b ≤ (3*angle/2)^2) (hc : c ≤ angle^2) : + Real.sqrt (b+angle^2/100)+Real.sqrt (c+angle^2/100)<3*angle := by + have hangle := strip_angle_pos + have hb' : Real.sqrt (b+angle^2/100) ≤ 8*angle/5 := by + apply Real.sqrt_le_iff.mpr + constructor + · positivity + · nlinarith [sq_nonneg angle] + have hc' : Real.sqrt (c+angle^2/100) ≤ 6*angle/5 := by + apply Real.sqrt_le_iff.mpr + constructor + · positivity + · nlinarith [sq_nonneg angle] + linarith [strip_angle_pos] + +lemma sech_jet_pair_integrable {b c : ℝ} (hb0 : 0 ≤ b) (hc0 : 0 ≤ c) + (hb : b ≤ (3*angle/2)^2) (hc : c ≤ angle^2) (r s : ℕ) : + IntegrableOn (fun p ↦ cosineKernelJet r 0 b (p^2)*cosineKernelJet s 0 c (p^2)* + sechProbDensity (3*angle) p) (Set.Ioi 0) := by + have hangle := strip_angle_pos + let δ := angle^2/100 + have hd : 0<δ := by dsimp [δ]; positivity + have hmargin : |Real.sqrt (b+δ)|+|Real.sqrt (c+δ)|<3*angle := by + simp only [abs_of_nonneg (Real.sqrt_nonneg _)] + exact sech_label_margin hb hc + have hi := (Analytic.sech_pair_integrable (show 0<3*angle by positivity) hmargin).const_mul + (δ^(-(r:ℤ))*δ^(-(s:ℤ))*(2*(3*angle)/Real.pi)) + apply hi.mono' + · exact ((((cosineKernelJet_contDiff_right r 0 b 0).continuous.comp (continuous_id.pow 2)).measurable.mul + (((cosineKernelJet_contDiff_right s 0 c 0).continuous.comp (continuous_id.pow 2)).measurable)).mul + (by unfold sechProbDensity; fun_prop)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hr := cosineKernelJet_label_bound hb0 (sq_nonneg p) hd r + have hs := cosineKernelJet_label_bound hc0 (sq_nonneg p) hd s + have he1 : cosineKernelJet 0 0 (b+δ) (p^2)=Real.cosh (Real.sqrt (b+δ)*p) := by + rw [cosineKernelJet_zero_zero_cosh (by positivity) (sq_nonneg p),Real.sqrt_sq hp.le] + have he2 : cosineKernelJet 0 0 (c+δ) (p^2)=Real.cosh (Real.sqrt (c+δ)*p) := by + rw [cosineKernelJet_zero_zero_cosh (by positivity) (sq_nonneg p),Real.sqrt_sq hp.le] + rw [he1] at hr + rw [he2] at hs + rw [Real.norm_of_nonneg (by apply mul_nonneg (mul_nonneg (cosineKernelJet_nonneg hb0 (sq_nonneg p) _ _) + (cosineKernelJet_nonneg hc0 (sq_nonneg p) _ _)); unfold sechProbDensity; positivity)] + calc + _ ≤ (δ^(-(r:ℤ))*Real.cosh (Real.sqrt (b+δ)*p))*(δ^(-(s:ℤ))*Real.cosh (Real.sqrt (c+δ)*p))* + sechProbDensity (3*angle) p := by + apply mul_le_mul_of_nonneg_right _ (by unfold sechProbDensity; positivity) + exact mul_le_mul hr hs (cosineKernelJet_nonneg hc0 (sq_nonneg p) _ _) (by positivity) + _ = _ := by unfold sechProbDensity; ring + +lemma sech_jet_gram_det_pos {n : ℕ} (b c : ℕ → ℝ) + (hb : Monotone (fun i : Fin n ↦ b i)) (hc : Monotone (fun i : Fin n ↦ c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin n,c i ≤ angle^2) : + 0 < (jetGram (n:=n) (sechProbDensity (3*angle)) b c).det := by + have hangle := strip_angle_pos + apply jetGram_det_pos _ b c hb hc hb0 hc0 + · intro p hp + unfold sechProbDensity + positivity + · intro i j + exact sech_jet_pair_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) _ _ + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Matrix MeasureTheory + +lemma meanResidualRatio_reindex {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a : ℝ) (e : Equiv.Perm (Fin n)) : + meanResidualRatio w (F ∘ e) (G ∘ e) H a=meanResidualRatio w F G H a := by + unfold meanResidualRatio + have he (f : Fin n → ℝ → ℝ) : familyGram w (f ∘ e) (G ∘ e)=(familyGram w f G).submatrix e e := rfl + have hr : residualFamily (F ∘ e) H a=(residualFamily F H a) ∘ e := rfl + rw [hr,he,he,Matrix.det_submatrix_equiv_self,Matrix.det_submatrix_equiv_self] + +lemma residualFamily_scale_target {n : ℕ} (F : Fin n → ℝ → ℝ) (H : ℝ → ℝ) (a s : ℝ) (hs : s≠0) : + residualFamily F (fun x ↦ s*H x) a=residualFamily F H a := by + funext i x + unfold residualFamily + congr 1 + rw [mul_left_comm (F i a) s (H x),mul_div_mul_left _ _ hs] + +lemma meanResidualRatio_scale_target {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) + (H : ℝ → ℝ) (a s : ℝ) (hs : s≠0) : + meanResidualRatio w F G (fun x ↦ s*H x) a=meanResidualRatio w F G H a := by + unfold meanResidualRatio + rw [residualFamily_scale_target F H a s hs] + +lemma finiteFamilyCombination_diagonal {n : ℕ} (F : Fin n → ℝ → ℝ) (u : Fin n → ℝ) (i : Fin n) : + finiteFamilyCombination F (Matrix.diagonal u i)=fun x ↦ u i*F i x := by + funext x + simp [finiteFamilyCombination,Matrix.diagonal_apply] + +lemma familyGram_scalars {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) (u v : Fin n → ℝ) + (hi : ∀ i j,IntegrableOn (fun p ↦ F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + familyGram w (fun i x ↦ u i*F i x) (fun j x ↦ v j*G j x)= + Matrix.diagonal u*familyGram w F G*Matrix.diagonal v := by + have h:=familyGram_bichange w F G hi (Matrix.diagonal u) (Matrix.diagonal v) + simpa only [finiteFamilyCombination_diagonal,Matrix.diagonal_transpose] using h + +lemma meanResidualRatio_scalars {n : ℕ} (w : ℝ → ℝ) (F G : Fin n → ℝ → ℝ) (H : ℝ → ℝ) (a : ℝ) + (u v : Fin n → ℝ) (hu : ∀ i,u i≠0) (hv : ∀ i,v i≠0) + (hi : ∀ i j,IntegrableOn (fun p ↦ F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (hH : ∀ j,IntegrableOn (fun p ↦ H (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + meanResidualRatio w (fun i x ↦ u i*F i x) (fun j x ↦ v j*G j x) H a=meanResidualRatio w F G H a := by + have h:=meanResidualRatio_bichange w F G H a hi hH (Matrix.diagonal u) (Matrix.diagonal v) + (by rw [Matrix.det_diagonal]; exact prod_ne_zero_iff.mpr (fun i _ ↦ hu i)) + (by rw [Matrix.det_diagonal]; exact prod_ne_zero_iff.mpr (fun i _ ↦ hv i)) + simpa only [finiteFamilyCombination_diagonal] using h + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/SechTransform.lean b/lean/OAI/Combinatorics/HoneycombChords/SechTransform.lean new file mode 100644 index 0000000000000000000000000000000000000000..387d77d02c91facfaf13baf00965a59f59c415e3 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/SechTransform.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.HoneycombChords.HyperbolicTransform + +namespace OAI + +/-! Exact hyperbolic secant integral transforms and pairings. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Filter Topology MeasureTheory +lemma sech_split {z : ℝ} (hz : 0 < z) (u : ℝ) : + Real.cosh (u*z)/Real.cosh (Real.pi*z/4)= + 2*(Real.cosh (u*z)*Real.sinh (Real.pi/4*z)/Real.sinh (Real.pi*z/2)) := by + have hs : Real.sinh (Real.pi/4*z) ≠ 0 := (Real.sinh_pos_iff.mpr (by positivity)).ne' + have hc : Real.cosh (Real.pi*z/4) ≠ 0 := (Real.cosh_pos _).ne' + rw [show Real.pi*z/2=Real.pi/4*z+Real.pi/4*z by ring,Real.sinh_add] + field_simp + ring +lemma sech_kernel_integrable_pi4 {u : ℝ} (hu : |u| < Real.pi/4) : + IntegrableOn (fun z => Real.cosh (u*z)/Real.cosh (Real.pi*z/4)) (Set.Ioi 0) := by + have h : |Real.pi/4|+|u| < Real.pi/2 := by rw [abs_of_pos (by positivity)];linarith + apply ((cosh_sinh_kernel_integrable h).const_mul 2).congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + exact (sech_split hz u).symm +lemma sech_kernel_integral_pi4 {u : ℝ} (hu : |u| < Real.pi/4) : + ∫ z in Set.Ioi (0:ℝ), Real.cosh (u*z)/Real.cosh (Real.pi*z/4)=2/Real.cos (2*u) := by + have h : |Real.pi/4|+|u| < Real.pi/2 := by rw [abs_of_pos (by positivity)];linarith + calc + (∫ z in Set.Ioi (0:ℝ), Real.cosh (u*z)/Real.cosh (Real.pi*z/4))= + ∫ z in Set.Ioi (0:ℝ),2*(Real.cosh (u*z)*Real.sinh (Real.pi/4*z)/Real.sinh (Real.pi*z/2)) := by + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + exact sech_split hz u + _=2/Real.cos (2*u) := by + rw [integral_const_mul,cosh_sinh_kernel_integral h] + rw [show 2*(Real.pi/4)=Real.pi/2 by ring,Real.sin_pi_div_two,Real.cos_pi_div_two] + ring +lemma sech_scale_bound {c m : ℝ} (hc : 0 < c) (hm : |m| < c) : + |m/(4*c/Real.pi)| < Real.pi/4 := by + have hb : 0 < 4*c/Real.pi := by positivity + rw [abs_div,abs_of_pos hb,div_lt_iff₀ hb] + have he : Real.pi/4*(4*c/Real.pi)=c := by field_simp + rwa [he] +lemma sech_scaled_kernel {c : ℝ} (hc : 0 < c) (m z : ℝ) : + Real.cosh ((m/(4*c/Real.pi))*(4*c/Real.pi*z))/ + Real.cosh (Real.pi*(4*c/Real.pi*z)/4)=Real.cosh (m*z)/Real.cosh (c*z) := by + have hc0 : c ≠ 0 := hc.ne' + congr 2 <;> field_simp +lemma sech_kernel_integrable {c m : ℝ} (hc : 0 < c) (hm : |m| < c) : + IntegrableOn (fun z => Real.cosh (m*z)/Real.cosh (c*z)) (Set.Ioi 0) := by + have hi:=sech_kernel_integrable_pi4 (sech_scale_bound hc hm) + have ht:=(integrableOn_Ioi_comp_mul_left_iff (fun z => Real.cosh ((m/(4*c/Real.pi))*z)/ + Real.cosh (Real.pi*z/4)) 0 (by positivity : 0 < 4*c/Real.pi)).2 (by simpa using hi) + simpa only [sech_scaled_kernel hc] using ht +lemma sech_kernel_integral {c m : ℝ} (hc : 0 < c) (hm : |m| < c) : + ∫ z in Set.Ioi (0:ℝ), Real.cosh (m*z)/Real.cosh (c*z)= + (Real.pi/(2*c))/Real.cos (Real.pi*m/(2*c)) := by + have ht:=integral_comp_mul_left_Ioi (fun z => Real.cosh ((m/(4*c/Real.pi))*z)/ + Real.cosh (Real.pi*z/4)) 0 (by positivity : 0 < 4*c/Real.pi) + simp only [sech_scaled_kernel hc,mul_zero,smul_eq_mul] at ht + rw [ht,sech_kernel_integral_pi4 (sech_scale_bound hc hm)] + have he : 2*(m/(4*c/Real.pi))=Real.pi*m/(2*c) := by field_simp; ring + rw [he] + field_simp + ring +lemma cosh_pair_split (m n z : ℝ) : + Real.cosh (m*z)*Real.cosh (n*z)= + (Real.cosh ((m+n)*z)+Real.cosh ((m-n)*z))/2 := by + rw [add_mul,sub_mul,Real.cosh_add,Real.cosh_sub] + ring +lemma sech_pair_integrable {c m n : ℝ} (hc : 0 < c) (h : |m|+|n| < c) : + IntegrableOn (fun z => Real.cosh (m*z)*Real.cosh (n*z)/Real.cosh (c*z)) (Set.Ioi 0) := by + have hm:=sech_kernel_integrable hc (lt_of_le_of_lt (abs_add_le m n) h) + have hn:=sech_kernel_integrable hc (lt_of_le_of_lt (abs_sub m n) h) + apply ((hm.add hn).div_const 2).congr + filter_upwards with z + simp only [Pi.add_apply] + rw [cosh_pair_split] + ring +lemma sech_pair_integral {c m n : ℝ} (hc : 0 < c) (h : |m|+|n| < c) : + ∫ z in Set.Ioi (0:ℝ),Real.cosh (m*z)*Real.cosh (n*z)/Real.cosh (c*z)= + (Real.pi/(4*c))*(1/Real.cos (Real.pi*(m+n)/(2*c))+ + 1/Real.cos (Real.pi*(m-n)/(2*c))) := by + have hm : |m+n| < c := lt_of_le_of_lt (abs_add_le m n) h + have hn : |m-n| < c := lt_of_le_of_lt (abs_sub m n) h + have he : (fun z => Real.cosh (m*z)*Real.cosh (n*z)/Real.cosh (c*z))= + fun z => (Real.cosh ((m+n)*z)/Real.cosh (c*z)+Real.cosh ((m-n)*z)/Real.cosh (c*z))/2 := by + funext z;rw [cosh_pair_split];ring + rw [he,integral_div,integral_add (sech_kernel_integrable hc hm) (sech_kernel_integrable hc hn), + sech_kernel_integral hc hm,sech_kernel_integral hc hn] + ring +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/SparseInterpolation.lean b/lean/OAI/Combinatorics/HoneycombChords/SparseInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f82f227e0e3a0f5e05d40db3493d68f8c7719709 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/SparseInterpolation.lean @@ -0,0 +1,793 @@ +import OAI.Combinatorics.HoneycombChords.LaplaceProducts + +namespace OAI + +/-! Sparse Newton interpolation and positive reciprocal product comparisons. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix + +noncomputable def newtonEvaluation (m : ℕ) (v : ℕ → ℝ) : Matrix (Fin m) (Fin m) ℝ := + fun i j => (newtonBasis v i).eval (v j) + +lemma newtonEvaluation_det_pos {m : ℕ} {v : ℕ → ℝ} + (hv : StrictMono (fun i : Fin m=>v i)) : 0<(newtonEvaluation m v).det := by + have he : newtonEvaluation m v=newtonJetMatrix m v := by + ext i j + rw [newtonJetMatrix,nodalOrder_eq_zero_strict hv,polynomialJet_zero] + rfl + rw [he] + exact newtonJetMatrix_det_pos v hv.monotone + +noncomputable def sparseCofactorMatrix {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) + (k : Fin (n+1)) : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := + Fin.cases (fun j=>if j=k then (-1)^k.val else 0) (fun i j=>powerNewton v (e i) j) + +lemma sparseCofactorMatrix_det_nonneg {n : ℕ} (v : ℕ → ℝ) (hv : ∀ i,0≤v i) + (e : Fin n → ℕ) (he : StrictMono e) (k : Fin (n+1)) : + 0≤(sparseCofactorMatrix v e k).det := by + classical + have hm : (sparseCofactorMatrix v e k).submatrix Fin.succ k.succAbove= + fun i j=>powerNewton v (e i) (k.succAbove j).val := rfl + rw [Matrix.det_succ_row_zero] + have hs : (∑ j : Fin (n+1),(-1:ℝ)^j.val*sparseCofactorMatrix v e k 0 j* + ((sparseCofactorMatrix v e k).submatrix Fin.succ j.succAbove).det)= + (-1)^(k.val+k.val)*((sparseCofactorMatrix v e k).submatrix Fin.succ k.succAbove).det := by + rw [sum_eq_single k] + · simp [sparseCofactorMatrix,pow_add,mul_assoc] + · intro j _ hj + simp only [sparseCofactorMatrix,Fin.cases_zero,ite_eq_right hj,mul_zero,zero_mul] + · simp + rw [hs,hm,show (-1:ℝ)^(k.val+k.val)=1 by rw [←two_mul,Even.neg_one_pow (even_two_mul k.val)],one_mul] + apply powerNewton_det_nonneg v hv e (fun j=>(k.succAbove j).val) he + exact k.strictMono_succAbove + +noncomputable def sparseTestMatrix {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) + (k : Fin (n+1)) : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := + Fin.cases (fun j=>(-1)^k.val*(newtonBasis v k).eval (v j)) (fun i j=>(v j)^(e i)) + +lemma sparseTestMatrix_factor {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (k : Fin (n+1)) : + sparseTestMatrix v e k=sparseCofactorMatrix v e k*newtonEvaluation (n+1) v := by + classical + ext i j + refine Fin.cases ?_ (fun i=>?_) i + · simp only [sparseTestMatrix,Fin.cases_zero,Matrix.mul_apply,sparseCofactorMatrix] + rw [sum_eq_single k] + · simp [newtonEvaluation] + · intro a _ ha;simp [ha] + · simp + · change (v j)^e i=∑ a : Fin (n+1),powerNewton v (e i) a*(newtonBasis v a).eval (v j) + exact powerNewton_evaluation v (e i) j + +lemma sparseTestMatrix_det_nonneg {n : ℕ} (v : ℕ → ℝ) (hv : ∀ i,0≤v i) + (hord : StrictMono (fun i : Fin (n+1)=>v i)) + (e : Fin n → ℕ) (he : StrictMono e) (k : Fin (n+1)) : + 0≤(sparseTestMatrix v e k).det := by + rw [sparseTestMatrix_factor,Matrix.det_mul] + exact mul_nonneg (sparseCofactorMatrix_det_nonneg v hv e he k) (newtonEvaluation_det_pos hord).le + +/-- The alternating-Newton polynomial divided-difference numerator is +nonnegative against the sparse interpolation weights at the origin. -/ +lemma sparse_newton_numerator_nonneg {n : ℕ} (v : ℕ → ℝ) (hv : ∀ i,0≤v i) + (hord : StrictMono (fun i : Fin (n+1)=>v i)) + (e : Fin n → ℕ) (he : StrictMono e) (k : Fin (n+1)) : + 0≤Matrix.det (Fin.cases (fun j : Fin (n+1)=>v j*((-1)^k.val*(newtonBasis v k).eval (v j))) + (fun i j=>(v j)^(e i+1))) := by + have hm : (Fin.cases (fun j : Fin (n+1)=>v j*((-1)^k.val*(newtonBasis v k).eval (v j))) + (fun i j=>(v j)^(e i+1)))=fun (i j : Fin (n+1))=>v j*sparseTestMatrix v e k i j := by + ext i j + refine Fin.cases ?_ (fun i=>?_) i + · rfl + · simp [sparseTestMatrix,pow_succ'] + rw [hm] + calc + 0≤(∏ i : Fin (n+1),v i)*(sparseTestMatrix v e k).det := + mul_nonneg (prod_nonneg (fun i _=>hv i)) (sparseTestMatrix_det_nonneg v hv hord e he k) + _=Matrix.det (fun i j : Fin (n+1)=>v j*sparseTestMatrix v e k i j) := + (Matrix.det_mul_row (fun j : Fin (n+1)=>v j) (sparseTestMatrix v e k)).symm + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix + +noncomputable def sparseExponent {n : ℕ} (e : Fin n → ℕ) : Fin (n+1) → ℕ := + Fin.cons 0 (fun i=>e i+1) + +lemma sparseExponent_strictMono {n : ℕ} {e : Fin n → ℕ} (he : StrictMono e) : + StrictMono (sparseExponent e) := by + apply Fin.strictMono_cons.mpr + exact ⟨fun i=>Nat.zero_lt_succ _,fun i j hij=>Nat.add_lt_add_right (he hij) 1⟩ + +noncomputable def sparseMatrix {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) : + Matrix (Fin (n+1)) (Fin (n+1)) ℝ := fun i j=>(v j)^sparseExponent e i + +lemma sparseMatrix_eq {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) : + sparseMatrix v e=Fin.cases (fun _=>1) (fun i j=>(v j)^(e i+1)) := by + ext i j + refine Fin.cases ?_ (fun i=>?_) i <;> simp [sparseMatrix,sparseExponent] + +lemma sparseMatrix_det_pos {n : ℕ} {v : ℕ → ℝ} {e : Fin n → ℕ} + (hv : ∀ i : Fin (n+1),0v i)) + (he : StrictMono e) : 0<(sparseMatrix v e).det := + power_det_pos _ _ (sparseExponent_strictMono he) hord hv + +noncomputable def sparseWeight {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (j : Fin (n+1)) : ℝ := + (-1)^j.val*((sparseMatrix v e).submatrix Fin.succ j.succAbove).det/(sparseMatrix v e).det + +lemma sparseWeight_eval {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (f : Fin (n+1) → ℝ) : + (∑ j,sparseWeight v e j*f j)= + Matrix.det (Fin.cases f (fun i j=>(v j)^(e i+1)))/(sparseMatrix v e).det := by + classical + simp only [sparseWeight,div_mul_eq_mul_div,←sum_div] + congr 1 + erw [Matrix.det_succ_row_zero] + apply sum_congr rfl + intro j hj + have hm : Matrix.submatrix (Fin.cases f (fun i j=>(v j)^(e i+1)) : Matrix (Fin (n+1)) (Fin (n+1)) ℝ) + Fin.succ j.succAbove=(sparseMatrix v e).submatrix Fin.succ j.succAbove := by + ext i k + change (v (j.succAbove k))^(e i+1)=(v (j.succAbove k))^(e i+1) + rfl + rw [hm] + simp only [Fin.cases_zero] + ring + +lemma sparseWeight_sum {n : ℕ} {v : ℕ → ℝ} {e : Fin n → ℕ} + (hv : ∀ i : Fin (n+1),0v i)) + (he : StrictMono e) : ∑ j,sparseWeight v e j=1 := by + simpa only [mul_one,←sparseMatrix_eq,div_self (ne_of_gt (sparseMatrix_det_pos hv hord he))] using + sparseWeight_eval v e (fun _=>1) + +lemma sparseWeight_power {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (i : Fin n) : + ∑ j,sparseWeight v e j*(v j)^(e i+1)=0 := by + rw [sparseWeight_eval] + have hz : Matrix.det (Fin.cases (fun j : Fin (n+1)=>(v j)^(e i+1)) + (fun i j=>(v j)^(e i+1)))=0 := by + apply Matrix.det_zero_of_row_eq (Fin.succ_ne_zero i).symm + funext j + simp + rw [hz,zero_div] + +noncomputable def backwardNewton (v : ℕ → ℝ) (k : ℕ) (x : ℝ) : ℝ := + ∏ i ∈ range k,(v i-x) +noncomputable def nodeProd (v : ℕ → ℝ) (k : ℕ) : ℝ := ∏ i ∈ range k,v i + +lemma backwardNewton_eval (v : ℕ → ℝ) (k : ℕ) (x : ℝ) : + backwardNewton v k x=(-1)^k*(newtonBasis v k).eval x := by + simp only [backwardNewton,newtonBasis,Polynomial.eval_prod,Polynomial.eval_sub,Polynomial.eval_X,Polynomial.eval_C] + calc + (∏ i ∈ range k,(v i-x))=∏ i ∈ range k,-(x-v i) := by congr 1;ext i;ring + _=_ := by rw [Finset.prod_neg];simp only [card_range] + +lemma nodeProd_pos (v : ℕ → ℝ) (hv : ∀ i,0hv i) + +noncomputable def coxianWeight {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (k : Fin (n+1)) : ℝ := + (∑ j,sparseWeight v e j*(v j*backwardNewton v k (v j)))/nodeProd v (k+1) + +lemma coxianWeight_nonneg {n : ℕ} (v : ℕ → ℝ) (hv : ∀ i,0v i)) (e : Fin n → ℕ) (he : StrictMono e) + (k : Fin (n+1)) : 0≤coxianWeight v e k := by + unfold coxianWeight + apply div_nonneg _ (nodeProd_pos v hv _).le + rw [sparseWeight_eval] + apply div_nonneg _ (sparseMatrix_det_pos (fun i=>hv i) hord he).le + simp only [backwardNewton_eval] + exact sparse_newton_numerator_nonneg v (fun i=>(hv i).le) hord e he k + +lemma backwardNewton_telescope (v : ℕ → ℝ) (hv : ∀ i,v i≠0) (x : ℝ) (m : ℕ) : + (∑ k ∈ range m,x*backwardNewton v k x/nodeProd v (k+1))= + 1-backwardNewton v m x/nodeProd v m := by + induction m with + | zero => simp [backwardNewton,nodeProd] + | succ m ih => + have hp : nodeProd v m≠0 := prod_ne_zero_iff.mpr (fun i _=>hv i) + rw [sum_range_succ,ih] + simp only [backwardNewton,nodeProd,prod_range_succ] + change 1-backwardNewton v m x/nodeProd v m+x*backwardNewton v m x/(nodeProd v m*v m)= + 1-backwardNewton v m x*(v m-x)/(nodeProd v m*v m) + field_simp [hp,hv m] + ; ring + +lemma backwardNewton_node {m : ℕ} (v : ℕ → ℝ) (j : Fin m) : backwardNewton v m (v j)=0 := by + apply prod_eq_zero (s:=range m) (i:=j.val) (mem_range.mpr j.isLt) + simp + +lemma coxianWeight_sum {n : ℕ} (v : ℕ → ℝ) (hv : ∀ i,0v i)) (e : Fin n → ℕ) (he : StrictMono e) : + ∑ k,coxianWeight v e k=1 := by + have ht (j : Fin (n+1)) : + (∑ k : Fin (n+1),v j*backwardNewton v k (v j)/nodeProd v (k+1))=1 := by + rw [Fin.sum_univ_eq_sum_range (fun k=>v j*backwardNewton v k (v j)/nodeProd v (k+1)) (n+1), + backwardNewton_telescope v (fun i=>(hv i).ne'),backwardNewton_node,zero_div,sub_zero] + simp only [coxianWeight,sum_div] + rw [sum_comm] + calc + _ = ∑ j : Fin (n+1),sparseWeight v e j*(∑ k : Fin (n+1),v j*backwardNewton v k (v j)/nodeProd v (k+1)) := by + apply sum_congr rfl + intro j hj + rw [mul_sum] + apply sum_congr rfl + intro k hk + ring + _=∑ j : Fin (n+1),sparseWeight v e j := by simp only [ht,mul_one] + _=1 := sparseWeight_sum (fun i=>hv i) hord he + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset + +inductive ReciprocalExpr where + | const : ℝ → ReciprocalExpr + | add : ReciprocalExpr → ReciprocalExpr → ReciprocalExpr + | scale : ℝ → ReciprocalExpr → ReciprocalExpr + | pole : ℝ → ReciprocalExpr → ReciprocalExpr + +namespace ReciprocalExpr +noncomputable def eval : ReciprocalExpr → ℝ → ℝ + | const c,_ => c + | add A B,x => eval A x+eval B x + | scale c A,x => c*eval A x + | pole b A,x => eval A x/(b+x) + +def PolesAbove (L : ℝ) : ReciprocalExpr → Prop + | const _ => True + | add A B => PolesAbove L A ∧ PolesAbove L B + | scale _ A => PolesAbove L A + | pole b A => L 0≤c + | add A B => CoeffNonneg A ∧ CoeffNonneg B + | scale c A => 0≤c ∧ CoeffNonneg A + | pole _ A => CoeffNonneg A + +lemma eval_nonneg {A : ReciprocalExpr} {L x : ℝ} + (hA : A.PolesAbove L) (hp : A.CoeffNonneg) (hx : -L≤x) : 0≤A.eval x := by + induction A with + | const c => exact hp + | add A B ihA ihB => exact add_nonneg (ihA hA.1 hp.1) (ihB hA.2 hp.2) + | scale c A ih => exact mul_nonneg hp.1 (ih hA hp.2) + | pole b A ih => exact div_nonneg (ih hA.2 hp) (by linarith [hA.1]) + +noncomputable def difference (v : ℝ) : ReciprocalExpr → ReciprocalExpr + | const _ => const 0 + | add A B => add (difference v A) (difference v B) + | scale c A => scale c (difference v A) + | pole b A => scale ((b+v)⁻¹) (add (difference v A) (pole b A)) + +lemma difference_poles {A : ReciprocalExpr} {L : ℝ} (v : ℝ) (hA : A.PolesAbove L) : + (A.difference v).PolesAbove L := by + induction A with + | const c => trivial + | add A B ihA ihB => exact ⟨ihA hA.1,ihB hA.2⟩ + | scale c A ih => exact ih hA + | pole b A ih => exact ⟨ih hA.2,hA⟩ + +lemma difference_coeff_nonneg {A : ReciprocalExpr} {L v : ℝ} + (hA : A.PolesAbove L) (hp : A.CoeffNonneg) (hv : -L≤v) : + (A.difference v).CoeffNonneg := by + induction A with + | const c => exact le_rfl + | add A B ihA ihB => exact ⟨ihA hA.1 hp.1,ihB hA.2 hp.2⟩ + | scale c A ih => exact ⟨hp.1,ih hA hp.2⟩ + | pole b A ih => exact ⟨inv_nonneg.mpr (by linarith [hA.1]),ih hA.2 hp,hp⟩ + +lemma difference_identity {A : ReciprocalExpr} {L v x : ℝ} + (hA : A.PolesAbove L) (hv : -L≤v) (hx : -L≤x) : + A.eval v-A.eval x=(x-v)*(A.difference v).eval x := by + induction A with + | const c => simp [eval,difference] + | add A B ihA ihB => + simp only [eval,difference] + rw [show A.eval v=A.eval x+(x-v)*(A.difference v).eval x by linarith [ihA hA.1], + show B.eval v=B.eval x+(x-v)*(B.difference v).eval x by linarith [ihB hA.2]] + ring + | scale c A ih => + simp only [eval,difference] + rw [show A.eval v=A.eval x+(x-v)*(A.difference v).eval x by linarith [ih hA]] + ring + | pole b A ih => + have hV : b+v≠0 := ne_of_gt (by linarith [hA.1]) + have hX : b+x≠0 := ne_of_gt (by linarith [hA.1]) + simp only [eval,difference] + rw [show A.eval v=A.eval x+(x-v)*(A.difference v).eval x by linarith [ih hA.2]] + field_simp + ; ring + +noncomputable def newtonExpr (v : ℕ → ℝ) (A : ReciprocalExpr) : ℕ → ReciprocalExpr + | 0 => A + | k+1 => (newtonExpr v A k).difference (v k) +noncomputable def newtonCoefficient (v : ℕ → ℝ) (A : ReciprocalExpr) (k : ℕ) : ℝ := + (newtonExpr v A k).eval (v k) + +lemma newtonExpr_poles {A : ReciprocalExpr} {L : ℝ} (v : ℕ → ℝ) (k : ℕ) + (hA : A.PolesAbove L) : (newtonExpr v A k).PolesAbove L := by + induction k with + | zero => exact hA + | succ k ih => exact difference_poles _ ih + +lemma newtonExpr_coeff_nonneg {A : ReciprocalExpr} {L : ℝ} (v : ℕ → ℝ) (k : ℕ) + (hA : A.PolesAbove L) (hp : A.CoeffNonneg) (hv : ∀ i,-L≤v i) : + (newtonExpr v A k).CoeffNonneg := by + induction k with + | zero => exact hp + | succ k ih => exact difference_coeff_nonneg (newtonExpr_poles v k hA) ih (hv k) + +lemma newtonCoefficient_nonneg {A : ReciprocalExpr} {L : ℝ} (v : ℕ → ℝ) (k : ℕ) + (hA : A.PolesAbove L) (hp : A.CoeffNonneg) (hv : ∀ i,-L≤v i) : + 0≤newtonCoefficient v A k := + eval_nonneg (newtonExpr_poles v k hA) (newtonExpr_coeff_nonneg v k hA hp hv) (hv k) + +lemma newton_expansion {A : ReciprocalExpr} {L x : ℝ} (v : ℕ → ℝ) (m : ℕ) + (hA : A.PolesAbove L) (hv : ∀ i,-L≤v i) (hx : -L≤x) : + A.eval x=(∑ k ∈ range m,newtonCoefficient v A k*backwardNewton v k x)+ + backwardNewton v m x*(newtonExpr v A m).eval x := by + induction m with + | zero => simp [backwardNewton,newtonExpr] + | succ m ih => + rw [sum_range_succ] + have hh := difference_identity (newtonExpr_poles v m hA) (hv m) hx + have he : (newtonExpr v A m).eval x=newtonCoefficient v A m+(v m-x)*(newtonExpr v A (m+1)).eval x := by + dsimp only [newtonCoefficient,newtonExpr] + linarith only [hh] + conv_lhs => rw [ih,he] + simp only [backwardNewton,prod_range_succ] + ring + +lemma newton_evaluation {A : ReciprocalExpr} {L : ℝ} (v : ℕ → ℝ) {m : ℕ} (j : Fin m) + (hA : A.PolesAbove L) (hv : ∀ i,-L≤v i) : + A.eval (v j)=∑ k : Fin m,newtonCoefficient v A k*backwardNewton v k (v j) := by + rw [newton_expansion v m hA hv (hv j),backwardNewton_node,zero_mul,add_zero] + exact (Fin.sum_univ_eq_sum_range (fun k=>newtonCoefficient v A k*backwardNewton v k (v j)) m).symm + +lemma newtonExpr_add (v : ℕ → ℝ) (A B : ReciprocalExpr) (k : ℕ) : + newtonExpr v (add A B) k=add (newtonExpr v A k) (newtonExpr v B k) := by + induction k with + | zero => rfl + | succ k ih => simp only [newtonExpr,ih,difference] +lemma newtonExpr_scale (v : ℕ → ℝ) (c : ℝ) (A : ReciprocalExpr) (k : ℕ) : + newtonExpr v (scale c A) k=scale c (newtonExpr v A k) := by + induction k with + | zero => rfl + | succ k ih => simp only [newtonExpr,ih,difference] +lemma newtonCoefficient_add (v : ℕ → ℝ) (A B : ReciprocalExpr) (k : ℕ) : + newtonCoefficient v (add A B) k=newtonCoefficient v A k+newtonCoefficient v B k := by + simp only [newtonCoefficient,newtonExpr_add,eval] +lemma newtonCoefficient_scale (v : ℕ → ℝ) (c : ℝ) (A : ReciprocalExpr) (k : ℕ) : + newtonCoefficient v (scale c A) k=c*newtonCoefficient v A k := by + simp only [newtonCoefficient,newtonExpr_scale,eval] + +lemma newtonExpr_eval_congr {m : ℕ} {A B : ReciprocalExpr} {L : ℝ} (v : ℕ → ℝ) + (hA : A.PolesAbove L) (hB : B.PolesAbove L) (hv : ∀ i,-L≤v i) + (hord : StrictMono (fun i : Fin m=>v i)) + (he : ∀ j : Fin m,A.eval (v j)=B.eval (v j)) (k : ℕ) (j : Fin m) (hkj : k≤j.val) : + (newtonExpr v A k).eval (v j)=(newtonExpr v B k).eval (v j) := by + induction k generalizing j with + | zero => exact he j + | succ k ih => + let i : Fin m:=⟨k,by omega⟩ + have hi := ih i le_rfl + have hj := ih j (by omega) + have hA' := difference_identity (newtonExpr_poles v k hA) (hv k) (hv j) + have hB' := difference_identity (newtonExpr_poles v k hB) (hv k) (hv j) + have hn : v j-v k≠0 := sub_ne_zero.mpr (ne_of_gt (hord (show iz-(newtonExpr v B k).eval (v j)) hi + +lemma newtonCoefficient_congr {m : ℕ} {A B : ReciprocalExpr} {L : ℝ} (v : ℕ → ℝ) + (hA : A.PolesAbove L) (hB : B.PolesAbove L) (hv : ∀ i,-L≤v i) + (hord : StrictMono (fun i : Fin m=>v i)) + (he : ∀ j : Fin m,A.eval (v j)=B.eval (v j)) (k : Fin m) : + newtonCoefficient v A k=newtonCoefficient v B k := + newtonExpr_eval_congr v hA hB hv hord he k k le_rfl + +end ReciprocalExpr +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Polynomial + +noncomputable def sparseEval {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (f : ℝ → ℝ) : ℝ := + ∑ j : Fin (n+1),sparseWeight v e j*f (v j) + +lemma sparseEval_add {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (f g : ℝ → ℝ) : + sparseEval v e (fun x=>f x+g x)=sparseEval v e f+sparseEval v e g := by + simp [sparseEval,mul_add,sum_add_distrib] +lemma sparseEval_scale {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) (c : ℝ) (f : ℝ → ℝ) : + sparseEval v e (fun x=>c*f x)=c*sparseEval v e f := by + simp only [sparseEval,mul_sum];apply sum_congr rfl;intro i hi;ring + +lemma sparseEval_rational {n : ℕ} {A : ReciprocalExpr} {L : ℝ} + (v : ℕ → ℝ) (e : Fin n → ℕ) (hv : ∀ i,0x*A.eval x)= + ∑ k : Fin (n+1),coxianWeight v e k*nodeProd v (k+1)*ReciprocalExpr.newtonCoefficient v A k := by + unfold sparseEval + simp only [ReciprocalExpr.newton_evaluation v _ hA hL,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro k hk + rw [coxianWeight,div_mul_cancel₀ _ (ne_of_gt (nodeProd_pos v hv _)),sum_mul] + apply sum_congr rfl + intro j hj + ring + +lemma sparseEval_rational_nonneg {n : ℕ} {A : ReciprocalExpr} {L : ℝ} + (v : ℕ → ℝ) (e : Fin n → ℕ) (hv : ∀ i,0v i)) (he : StrictMono e) + (hL : ∀ i,-L≤v i) (hA : A.PolesAbove L) (hp : A.CoeffNonneg) : + 0≤ sparseEval v e (fun x=>x*A.eval x) := by + rw [sparseEval_rational v e hv hL hA] + exact sum_nonneg fun k _=>mul_nonneg + (mul_nonneg (coxianWeight_nonneg v hv hord e he k) (nodeProd_pos v hv _).le) + (ReciprocalExpr.newtonCoefficient_nonneg v k hA hp hL) + +lemma sparseEval_polynomial_zero {n q : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) + (hq : ∀ m,1 ≤ m → m ≤ q → ∃ i,e i+1=m) (P : Polynomial ℝ) + (hd : P.natDegree≤q) (hz : P.coeff 0=0) : sparseEval v e P.eval=0 := by + unfold sparseEval + simp_rw [Polynomial.eval_eq_sum_range' (Nat.lt_succ_of_le hd),mul_sum] + rw [sum_comm] + apply sum_eq_zero + intro m hm + by_cases hm0 : m=0 + · subst m;simp [hz] + · obtain ⟨i,hi⟩ := hq m (by omega) (by simpa using Nat.le_of_lt_succ (mem_range.mp hm)) + have hp:=sparseWeight_power v e i + rw [hi] at hp + calc + _=P.coeff m*(∑ j : Fin (n+1),sparseWeight v e j*v j^m) := by + rw [mul_sum];apply sum_congr rfl;intro j hj;ring + _=0 := by rw [hp,mul_zero] + +lemma coxianWeight_eq_zero {n q : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) + (hq : ∀ m,1 ≤ m → m ≤ q → ∃ i,e i+1=m) (k : Fin (n+1)) (hk : k.valPolynomial.C (v i)-(X:Polynomial ℝ)) + calc + _ ≤ (X:Polynomial ℝ).natDegree+(∏ i ∈ range k.val,(Polynomial.C (v i)-X)).natDegree := Polynomial.natDegree_mul_le + _ ≤ 1+k.val := by rw [Polynomial.natDegree_X];exact Nat.add_le_add_left hp 1 + _ ≤ q := by omega + have hz : P.coeff 0=0 := by simp [P,Polynomial.coeff_zero_eq_eval_zero] + have heval : P.eval=fun x=>x*backwardNewton v k x := by + funext x + simp only [P,Polynomial.eval_mul,Polynomial.eval_X,Polynomial.eval_prod, + Polynomial.eval_sub,Polynomial.eval_C,backwardNewton] + have hh:=sparseEval_polynomial_zero v e hq P hd hz + rw [heval] at hh + change sparseEval v e (fun x=>x*backwardNewton v k x)/nodeProd v (k+1)=0 + rw [hh,zero_div] + +noncomputable def poleProduct (v : ℕ → ℝ) (a : ℝ) (k : ℕ) : ℝ := + ∏ i ∈ range k,v i/(a+v i) + +lemma poleProduct_pos (v : ℕ → ℝ) (hv : ∀ i,0div_pos (hv i) (add_pos ha (hv i))) +lemma poleProduct_antitone (v : ℕ → ℝ) (hv : ∀ i,0v (i+1)) (A.difference (v 0)) k := by + induction k with + | zero => rfl + | succ k ih => + change (ReciprocalExpr.newtonExpr v A (k+1)).difference (v (k+1)) = _ + rw [ih] + rfl + +lemma newtonExpr_zero (v : ℕ → ℝ) (k : ℕ) : + ReciprocalExpr.newtonExpr v (.const 0) k=.const 0 := by + induction k with + | zero => rfl + | succ k ih => simp only [ReciprocalExpr.newtonExpr,ih,ReciprocalExpr.difference] + +lemma newtonExpr_reciprocal (v : ℕ → ℝ) (a : ℝ) (k : ℕ) (x : ℝ) : + (ReciprocalExpr.newtonExpr v (.pole a (.const 1)) k).eval x= + (∏ i ∈ range k,(a+v i))⁻¹/(a+x) := by + induction k generalizing v with + | zero => simp [ReciprocalExpr.newtonExpr,ReciprocalExpr.eval] + | succ k ih => + rw [newtonExpr_head] + simp only [ReciprocalExpr.difference,ReciprocalExpr.newtonExpr_scale, + ReciprocalExpr.newtonExpr_add,newtonExpr_zero,ReciprocalExpr.eval,zero_add,ih] + rw [prod_range_succ',mul_inv_rev] + ring + +lemma newtonCoefficient_reciprocal (v : ℕ → ℝ) (a : ℝ) (k : ℕ) : + ReciprocalExpr.newtonCoefficient v (.pole a (.const 1)) k= + (∏ i ∈ range (k+1),(a+v i))⁻¹ := by + unfold ReciprocalExpr.newtonCoefficient + rw [newtonExpr_reciprocal,prod_range_succ,mul_inv_rev] + ring + +lemma sparseEval_reciprocal {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) + (hv : ∀ i,0x/(a+x))= + ∑ k : Fin (n+1),coxianWeight v e k*poleProduct v a (k+1) := by + have heval : (fun x=>x/(a+x))=(fun x=>x*(ReciprocalExpr.pole a (.const 1)).eval x) := by + funext x;simp [ReciprocalExpr.eval,div_eq_mul_inv] + rw [heval,sparseEval_rational v e hv (L:=0) (fun i=>by simpa using (hv i).le) + (show (ReciprocalExpr.pole a (.const 1)).PolesAbove 0 from ⟨ha,trivial⟩)] + apply sum_congr rfl + intro k hk + rw [newtonCoefficient_reciprocal,poleProduct,Finset.prod_div_distrib] + simp only [nodeProd,div_eq_mul_inv,mul_assoc] + +lemma sparseEval_reciprocal_lower {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) + (hv : ∀ i,0v i)) (he : StrictMono e) + {a : ℝ} (ha : 0x/(a+x)) := by + rw [sparseEval_reciprocal v e hv ha] + calc + _=(∑ k : Fin (n+1),coxianWeight v e k)*poleProduct v a (n+1) := by + rw [coxianWeight_sum v hv hord e he,one_mul] + _=∑ k : Fin (n+1),coxianWeight v e k*poleProduct v a (n+1) := by rw [sum_mul] + _≤_ := sum_le_sum fun k _=>mul_le_mul_of_nonneg_left + (poleProduct_antitone v hv ha (by omega)) (coxianWeight_nonneg v hv hord e he k) + +lemma sparseEval_reciprocal_upper {n q : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) + (hv : ∀ i,0v i)) (he : StrictMono e) + (hq : ∀ m,1 ≤ m → m ≤ q → ∃ i,e i+1=m) {a : ℝ} (ha : 0x/(a+x))≤poleProduct v a (q+1) := by + rw [sparseEval_reciprocal v e hv ha] + calc + _≤∑ k : Fin (n+1),coxianWeight v e k*poleProduct v a (q+1) := by + apply sum_le_sum + intro k hk + by_cases hqk : q≤k.val + · exact mul_le_mul_of_nonneg_left (poleProduct_antitone v hv ha (by omega)) + (coxianWeight_nonneg v hv hord e he k) + · rw [coxianWeight_eq_zero v e hq k (by omega),zero_mul,zero_mul] + _=(∑ k : Fin (n+1),coxianWeight v e k)*poleProduct v a (q+1) := by rw [sum_mul] + _=_ := by rw [coxianWeight_sum v hv hord e he,one_mul] + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset +namespace ReciprocalExpr + +lemma poles_mono {A : ReciprocalExpr} {L K : ℝ} (h : K ≤ L) (hA : A.PolesAbove L) : + A.PolesAbove K := by + induction A with + | const c => trivial + | add A B ihA ihB => exact ⟨ihA hA.1,ihB hA.2⟩ + | scale c A ih => exact ih hA + | pole b A ih => exact ⟨lt_of_le_of_lt h hA.1,ih hA.2⟩ + +noncomputable def mulExpr : ReciprocalExpr → ReciprocalExpr → ReciprocalExpr + | const c,B => scale c B + | add A A',B => add (mulExpr A B) (mulExpr A' B) + | scale c A,B => scale c (mulExpr A B) + | pole b A,B => pole b (mulExpr A B) + +lemma mulExpr_eval (A B : ReciprocalExpr) (x : ℝ) : + (mulExpr A B).eval x = A.eval x * B.eval x := by + induction A with + | const c => rfl + | add A A' ih ih' => simp only [mulExpr,eval,ih,ih'];ring + | scale c A ih => simp only [mulExpr,eval,ih];ring + | pole b A ih => simp only [mulExpr,eval,ih];ring + +lemma mulExpr_poles {A B : ReciprocalExpr} {L : ℝ} + (hA : A.PolesAbove L) (hB : B.PolesAbove L) : (mulExpr A B).PolesAbove L := by + induction A with + | const c => exact hB + | add A A' ih ih' => exact ⟨ih hA.1,ih' hA.2⟩ + | scale c A ih => exact ih hA + | pole b A ih => exact ⟨hA.1,ih hA.2⟩ +lemma mulExpr_coeff {A B : ReciprocalExpr} + (hA : A.CoeffNonneg) (hB : B.CoeffNonneg) : (mulExpr A B).CoeffNonneg := by + induction A with + | const c => exact ⟨hA,hB⟩ + | add A A' ih ih' => exact ⟨ih hA.1,ih' hA.2⟩ + | scale c A ih => exact ⟨hA.1,ih hA.2⟩ + | pole b A ih => exact ih hA + +noncomputable def normalizedPole (b : ℝ) : ReciprocalExpr := scale b (pole b (const 1)) +lemma normalizedPole_eval (b x : ℝ) : (normalizedPole b).eval x = b/(b+x) := by + simp [normalizedPole,eval,div_eq_mul_inv] +lemma normalizedPole_poles {b L : ℝ} (hb : L < b) : (normalizedPole b).PolesAbove L := ⟨hb,trivial⟩ +lemma normalizedPole_coeff {b : ℝ} (hb : 0 ≤ b) : (normalizedPole b).CoeffNonneg := ⟨hb,zero_le_one⟩ + +/-- The positive remainder giving the lower complementary-product bound. -/ +lemma lower_product_identity {A : ReciprocalExpr} {a x : ℝ} + (ha : 0 < a) (hA : A.PolesAbove 0) (hz : A.eval 0 = 1) (hx : 0 ≤ x) : + 1-a/(a+x)*A.eval x = x/(a+x)+x*(scale a (pole a (A.difference 0))).eval x := by + have hd := difference_identity hA (by norm_num : -(0:ℝ) ≤ 0) (by simpa using hx) + rw [hz] at hd + simp only [eval] + have hd' : A.eval x = 1-x*(A.difference 0).eval x := by simpa only [sub_zero] using (eq_sub_iff_add_eq.mpr (by linarith [hd])) + rw [hd'] + field_simp [ne_of_gt (add_pos_of_pos_of_nonneg ha hx)] + ; ring + +/-- The upper comparison is the double positive divided difference at -a,0. -/ +lemma upper_product_identity {A : ReciprocalExpr} {a x : ℝ} + (ha : 0 < a) (hA : A.PolesAbove a) (hz : A.eval 0 = 1) (hx : 0 ≤ x) : + A.eval (-a)*(x/(a+x))-(1-a/(a+x)*A.eval x) = + x*(scale a ((A.difference (-a)).difference 0)).eval x := by + have h0 : -a ≤ (0:ℝ) := by linarith + have hax : -a ≤ x := by linarith + have hd0 := difference_identity hA (le_refl (-a)) h0 + have hdx := difference_identity hA (le_refl (-a)) hax + have hdd := difference_identity (difference_poles (-a) hA) h0 hax + rw [hz] at hd0 + simp only [zero_sub,sub_zero] at hd0 hdd + simp only [sub_neg_eq_add] at hdx + simp only [eval] + have hn : a+x ≠ 0 := ne_of_gt (by linarith) + field_simp [hn] + linear_combination (x+a)*hd0-a*hdx+a*(a+x)*hdd + +lemma complementary_identity {A : ReciprocalExpr} {x : ℝ} + (hA : A.PolesAbove 0) (hz : A.eval 0 = 1) (hx : 0 ≤ x) : + 1-A.eval x = x*(A.difference 0).eval x := by + have h := difference_identity hA (by norm_num : -(0:ℝ) ≤ 0) (by simpa using hx) + simpa [hz] using h + +end ReciprocalExpr + +lemma sparseEval_congr_nodes {n : ℕ} (v : ℕ → ℝ) (e : Fin n → ℕ) {f g : ℝ → ℝ} + (h : ∀ j : Fin (n+1),f (v j)=g (v j)) : sparseEval v e f=sparseEval v e g := by + unfold sparseEval + apply sum_congr rfl + intro j hj + rw [h j] + +lemma sparse_complement_nonneg {n : ℕ} {A : ReciprocalExpr} + (v : ℕ → ℝ) (e : Fin n → ℕ) (hv : ∀ i,0 < v i) + (hord : StrictMono (fun i : Fin (n+1) => v i)) (he : StrictMono e) + (hA : A.PolesAbove 0) (hp : A.CoeffNonneg) (hz : A.eval 0=1) : + 0 ≤ sparseEval v e (fun x => 1-A.eval x) := by + rw [sparseEval_congr_nodes v e (g:=fun x => x*(A.difference 0).eval x) + (fun j => ReciprocalExpr.complementary_identity hA hz (hv j).le)] + exact sparseEval_rational_nonneg v e hv hord he (L:=0) (by intro i;simpa using (hv i).le) + (ReciprocalExpr.difference_poles 0 hA) + (ReciprocalExpr.difference_coeff_nonneg hA hp (by norm_num)) + + +lemma sparse_product_lower {n : ℕ} {A : ReciprocalExpr} + (v : ℕ → ℝ) (e : Fin n → ℕ) (hv : ∀ i,0 < v i) + (hord : StrictMono (fun i : Fin (n+1) => v i)) (he : StrictMono e) + {a : ℝ} (ha : 0 < a) (hA : A.PolesAbove 0) (hp : A.CoeffNonneg) (hz : A.eval 0=1) : + poleProduct v a (n+1) ≤ sparseEval v e (fun x => 1-a/(a+x)*A.eval x) := by + rw [sparseEval_congr_nodes v e + (g:=fun x => x/(a+x)+x*(ReciprocalExpr.scale a (ReciprocalExpr.pole a (A.difference 0))).eval x) + (fun j => ReciprocalExpr.lower_product_identity ha hA hz (hv j).le),sparseEval_add] + apply le_add_of_le_of_nonneg (sparseEval_reciprocal_lower v e hv hord he ha) + apply sparseEval_rational_nonneg v e hv hord he (L:=0) (by intro i;simpa using (hv i).le) + · exact ⟨ha,ReciprocalExpr.difference_poles 0 hA⟩ + · exact ⟨ha.le,ReciprocalExpr.difference_coeff_nonneg hA hp (by norm_num)⟩ + +/-- Exact sparse prefix-node upper product. The harmless constant is the +remaining normalized product evaluated at its slowest pole. -/ +lemma sparse_product_upper {n q : ℕ} {A : ReciprocalExpr} + (v : ℕ → ℝ) (e : Fin n → ℕ) (hv : ∀ i,0 < v i) + (hord : StrictMono (fun i : Fin (n+1) => v i)) (he : StrictMono e) + (hq : ∀ m,1 ≤ m → m ≤ q → ∃ i,e i+1=m) + {a : ℝ} (ha : 0 < a) (hA : A.PolesAbove a) (hp : A.CoeffNonneg) (hz : A.eval 0=1) : + sparseEval v e (fun x => 1-a/(a+x)*A.eval x) ≤ A.eval (-a)*poleProduct v a (q+1) := by + have hc : 0 ≤ sparseEval v e + (fun x => x*(ReciprocalExpr.scale a ((A.difference (-a)).difference 0)).eval x) := by + apply sparseEval_rational_nonneg v e hv hord he (L:=a) (by intro i;linarith [hv i]) + · exact ReciprocalExpr.difference_poles 0 (ReciprocalExpr.difference_poles (-a) hA) + · exact ⟨ha.le,ReciprocalExpr.difference_coeff_nonneg + (ReciprocalExpr.difference_poles (-a) hA) + (ReciprocalExpr.difference_coeff_nonneg hA hp le_rfl) (by linarith)⟩ + have hi := sparseEval_congr_nodes v e + (f:=fun x => A.eval (-a)*(x/(a+x))-(1-a/(a+x)*A.eval x)) + (g:=fun x => x*(ReciprocalExpr.scale a ((A.difference (-a)).difference 0)).eval x) + (fun j => ReciprocalExpr.upper_product_identity ha hA hz (hv j).le) + have hs : sparseEval v e (fun x => A.eval (-a)*(x/(a+x))-(1-a/(a+x)*A.eval x)) = + A.eval (-a)*sparseEval v e (fun x => x/(a+x))-sparseEval v e (fun x => 1-a/(a+x)*A.eval x) := by + simp only [sparseEval,mul_sub,sum_sub_distrib,mul_sum] + congr 1 + apply sum_congr rfl + intro j hj + ring + rw [←hi,hs] at hc + exact (le_of_sub_nonneg hc).trans (mul_le_mul_of_nonneg_left + (sparseEval_reciprocal_upper v e hv hord he hq ha) + (ReciprocalExpr.eval_nonneg hA hp le_rfl)) + + +lemma sparse_complement_upper {n q : ℕ} {A : ReciprocalExpr} + (v : ℕ → ℝ) (e : Fin n → ℕ) (hv : ∀ i,0 < v i) + (hord : StrictMono (fun i : Fin (n+1) => v i)) (he : StrictMono e) + (hq : ∀ m,1 ≤ m → m ≤ q → ∃ i,e i+1=m) + {a : ℝ} (ha : 0 < a) (hA : A.PolesAbove a) (hp : A.CoeffNonneg) (hz : A.eval 0=1) : + sparseEval v e (fun x => 1-A.eval x) ≤ A.eval (-a)*poleProduct v a (q+1) := by + have hab : (ReciprocalExpr.pole a A).PolesAbove 0 := + ⟨ha,ReciprocalExpr.poles_mono ha.le hA⟩ + have hpos := sparseEval_rational_nonneg v e hv hord he + (L:=0) (by intro i;simpa using (hv i).le) hab hp + have hf := sparseEval_congr_nodes v e + (f:=fun x => 1-a/(a+x)*A.eval x) + (g:=fun x => (1-A.eval x)+x*(ReciprocalExpr.pole a A).eval x) + (by intro j;simp only [ReciprocalExpr.eval];field_simp [ne_of_gt (add_pos ha (hv j))];ring) + rw [sparseEval_add] at hf + apply (le_add_of_nonneg_right hpos).trans + rw [←hf] + exact sparse_product_upper v e hv hord he hq ha hA hp hz + +lemma sparse_mixture_bounds {n q : ℕ} {A B : ReciprocalExpr} + (v : ℕ → ℝ) (e : Fin n → ℕ) (hv : ∀ i,0 < v i) + (hord : StrictMono (fun i : Fin (n+1) => v i)) (he : StrictMono e) + (hq : ∀ m,1 ≤ m → m ≤ q → ∃ i,e i+1=m) + {a p C : ℝ} (ha : 0 < a) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (hA : A.PolesAbove a) (hAp : A.CoeffNonneg) (hAz : A.eval 0=1) + (hB : B.PolesAbove a) (hBp : B.CoeffNonneg) (hBz : B.eval 0=1) + (hAC : A.eval (-a) ≤ C) (hBC : B.eval (-a) ≤ C) : + p*poleProduct v a (n+1) ≤ + sparseEval v e (fun x => 1-(p*(a/(a+x)*A.eval x)+(1-p)*B.eval x)) ∧ + sparseEval v e (fun x => 1-(p*(a/(a+x)*A.eval x)+(1-p)*B.eval x)) ≤ + C*poleProduct v a (q+1) := by + have heq : (fun x => 1-(p*(a/(a+x)*A.eval x)+(1-p)*B.eval x)) = + (fun x => p*(1-a/(a+x)*A.eval x)+(1-p)*(1-B.eval x)) := by funext x;ring + rw [heq,sparseEval_add,sparseEval_scale,sparseEval_scale] + have hA0:=ReciprocalExpr.poles_mono ha.le hA + have hB0:=ReciprocalExpr.poles_mono ha.le hB + constructor + · apply le_add_of_le_of_nonneg + (mul_le_mul_of_nonneg_left (sparse_product_lower v e hv hord he ha hA0 hAp hAz) hp0) + exact mul_nonneg (sub_nonneg.mpr hp1) (sparse_complement_nonneg v e hv hord he hB0 hBp hBz) + · have huu:=add_le_add + (mul_le_mul_of_nonneg_left (sparse_product_upper v e hv hord he hq ha hA hAp hAz) hp0) + (mul_le_mul_of_nonneg_left (sparse_complement_upper v e hv hord he hq ha hB hBp hBz) (sub_nonneg.mpr hp1)) + apply huu.trans + have hac:=mul_le_mul_of_nonneg_left hAC hp0 + have hbc:=mul_le_mul_of_nonneg_left hBC (sub_nonneg.mpr hp1) + nlinarith [(poleProduct_pos v hv ha (q+1)), + mul_le_mul_of_nonneg_right (add_le_add hac hbc) (poleProduct_pos v hv ha (q+1)).le] + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/SpectralCommutation.lean b/lean/OAI/Combinatorics/HoneycombChords/SpectralCommutation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3afcf86d535f4ab1170f8f1d8ce47d2de7cc2b87 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/SpectralCommutation.lean @@ -0,0 +1,655 @@ +import OAI.Combinatorics.HoneycombChords.SpectralRows +import OAI.Combinatorics.HoneycombChords.YangBaxter + +namespace OAI + +/-! +# Spectral commutation for critical honeycomb strips + +Formalized from *Uniform marked polygon estimates and sharp finite bridge moments* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open YangBaxter +open scoped Matrix BigOperators +noncomputable def sourceMatrix (u : ℝ) : Local := sourceR u +lemma local_source_exchange (u v : ℝ) + (hu : YangBaxter.denominator u≠0) (hv : YangBaxter.denominator v≠0) (hd : YangBaxter.denominator (u-v)≠0) + (s t : Spin) : sourceMatrix (u-v)*localForward (sourceR u) (sourceR v) s t= + localBackward (sourceR u) (sourceR v) s t*sourceMatrix (u-v) := by + ext ⟨a,b⟩ ⟨d,e⟩ + simp only [Matrix.mul_apply,Fintype.sum_prod_type,localForward,localBackward, + Matrix.kronecker,Matrix.kroneckerMap,block,Matrix.sum_apply,Matrix.of_apply, + Finset.mul_sum,Finset.sum_mul] + simp only [sourceMatrix] + have hh:=source_yang_baxter u v hu hv hd a b s d e t + convert hh using 1 <;> + (apply Finset.sum_congr rfl;intro j hj + apply Finset.sum_congr rfl;intro k hk + apply Finset.sum_congr rfl;intro l hl + ring) +noncomputable def spectralSites (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) : Fin n→Local := + fun i=>sourceR (u+ξ i) + +theorem source_row_exchange (n : ℕ) (ξ : Fin n→ℝ) (u v : ℝ) + (hu : ∀ i,YangBaxter.denominator (u+ξ i)≠0) (hv : ∀ i,YangBaxter.denominator (v+ξ i)≠0) + (hd : YangBaxter.denominator (u-v)≠0) (s t : Space n) : + sourceMatrix (u-v)*forward n (spectralSites n ξ u) (spectralSites n ξ v) s t= + backward n (spectralSites n ξ u) (spectralSites n ξ v) s t*sourceMatrix (u-v) := by + apply row_exchange + intro i a b + have hh : (u+ξ i)-(v+ξ i)=u-v := by ring + simpa only [spectralSites,hh] using + local_source_exchange (u+ξ i) (v+ξ i) (hu i) (hv i) (by simpa only [hh] using hd) a b +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open scoped Matrix +lemma yangBaxter_denominator (u : ℝ) : YangBaxter.denominator u=Reflection.Q u := + Reflection.denominator_binding u +lemma yangBaxter_normalized (u : ℝ) : YangBaxter.sourceR u=Reflection.normalizedR u := by + unfold YangBaxter.sourceR Reflection.normalizedR + simp only [Transfer.a,Transfer.h,Transfer.v,Transfer.c,Transfer.d,Complex.ofReal_div] + rfl +lemma yangBaxter_spectral (u : ℝ) (hu : Reflection.Q u≠0) : + YangBaxter.sourceR u=Reflection.spectralR u := by + rw [yangBaxter_normalized,Reflection.spectralR_normalized u hu] +lemma sourceMatrix_spectral (u : ℝ) (hu : Reflection.Q u≠0) : + sourceMatrix u=Reflection.spectralR u := yangBaxter_spectral u hu +lemma spectralSites_exact (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) + (hu : ∀ i,Reflection.Q (u+ξ i)≠0) : spectralSites n ξ u=exactSites n ξ u := by + funext i + exact yangBaxter_spectral (u+ξ i) (hu i) + +theorem exact_row_exchange (n : ℕ) (ξ : Fin n→ℝ) (u v : ℝ) + (hu : ∀ i,Reflection.Q (u+ξ i)≠0) (hv : ∀ i,Reflection.Q (v+ξ i)≠0) + (hd : Reflection.Q (u-v)≠0) (s t : Space n) : + Reflection.spectralR (u-v)*forward n (exactSites n ξ u) (exactSites n ξ v) s t= + backward n (exactSites n ξ u) (exactSites n ξ v) s t*Reflection.spectralR (u-v) := by + have hh:=source_row_exchange n ξ u v + (fun i=>by simpa only [yangBaxter_denominator] using hu i) + (fun i=>by simpa only [yangBaxter_denominator] using hv i) + (by simpa only [yangBaxter_denominator] using hd) s t + simpa only [sourceMatrix_spectral (u-v) hd,spectralSites_exact n ξ u hu, + spectralSites_exact n ξ v hv] using hh +end CriticalHoneycomb.Transfer.RowExchange + +end + +section + +namespace CriticalHoneycomb.Transfer.Reflection +open Filter Topology +lemma continuous_sine : Continuous sine := by + unfold sine + fun_prop +lemma continuous_Q : Continuous Q := by + unfold Q + exact (continuous_sine.comp (continuous_const.add continuous_id)).mul + (continuous_sine.comp (continuous_const.add continuous_id)) +lemma continuous_bulkNumerator : Continuous bulkNumerator := by + apply continuous_pi; intro p + apply continuous_pi; intro q + unfold bulkNumerator + split <;> (try simp only [coeffA,coeffH,coeffV,coeffC,coeffD,Q,S,sine]) <;> fun_prop +lemma continuousAt_spectralR (u : ℝ) (hu : Q u≠0) : ContinuousAt spectralR u := by + exact (continuous_Q.continuousAt.inv₀ hu).smul continuous_bulkNumerator.continuousAt +lemma continuousAt_boundary0 (t : ℝ) (ht : sine (gamma+t)≠0) : + ContinuousAt boundary0 t := by + apply continuousAt_pi.2; intro p + apply continuousAt_pi.2; intro q + unfold boundary0 + split_ifs + · exact continuousAt_const + · exact ((continuous_sine.comp (continuous_const.sub continuous_id)).continuousAt).div + ((continuous_sine.comp (continuous_const.add continuous_id)).continuousAt) ht + · exact continuousAt_const +lemma continuousAt_boundary1 (t : ℝ) (ht : sine (gamma+t)≠0) : + ContinuousAt boundary1 t := by + have h : ContinuousAt (fun u => sine (2*u)/sine (gamma+u)) t := + ((continuous_sine.comp (continuous_const.mul continuous_id)).continuousAt).div + ((continuous_sine.comp (continuous_const.add continuous_id)).continuousAt) ht + apply continuousAt_pi.2; intro p + apply continuousAt_pi.2; intro q + unfold boundary1 + split_ifs + · exact h + · exact continuousAt_const.mul h + · exact continuousAt_const +lemma sine_zero_countable : Set.Countable {x : ℝ | sine x=0} := by + apply (Set.countable_range (fun n : ℤ => (n:ℝ)*Real.pi)).mono + intro x hx + change sine x=0 at hx + have hx' : Real.sin x=0 := by simpa only [sine,Complex.ofReal_eq_zero] using hx + rcases Real.sin_eq_zero_iff.mp hx' with ⟨n,hn⟩ + exact ⟨n,hn⟩ +lemma Q_zero_countable : Set.Countable {x : ℝ | Q x=0} := by + have h₁ := sine_zero_countable.preimage (f:=fun x : ℝ => Real.pi/4+x) + (fun x y h => add_left_cancel h) + have h₂ := sine_zero_countable.preimage (f:=fun x : ℝ => b+x) + (fun x y h => add_left_cancel h) + change Set.Countable {x : ℝ | sine (Real.pi/4+x)=0} at h₁ + change Set.Countable {x : ℝ | sine (b+x)=0} at h₂ + simpa only [Q,mul_eq_zero,Set.ofPred_or] using h₁.union h₂ + +lemma dense_exchange_regular (u : ℝ) : + Dense {v : ℝ | Q (u-v)≠0 ∧ Q (u+v)≠0 ∧ Q (-(u-v))≠0 ∧ Q (-(b-(u+v)))≠0} := by + have h₁ := Q_zero_countable.preimage (f:=fun v : ℝ => u-v) + (fun x y h => sub_right_injective h) + have h₂ := Q_zero_countable.preimage (f:=fun v : ℝ => u+v) + (fun x y h => add_left_cancel h) + have h₃ := Q_zero_countable.preimage (f:=fun v : ℝ => -(u-v)) + (fun x y h => sub_right_injective (neg_injective h)) + have h₄ := Q_zero_countable.preimage (f:=fun v : ℝ => -(b-(u+v))) + (fun x y h => add_left_cancel (sub_right_injective (neg_injective h))) + have hd := (((h₁.union h₂).union h₃).union h₄).dense_compl ℝ + convert hd using 1 + ext v + simp only [Set.mem_compl_iff,Set.mem_union,Set.mem_preimage,Set.mem_ofPred_eq] + tauto +end CriticalHoneycomb.Transfer.Reflection + +end + +section + +namespace CriticalHoneycomb.Transfer.RowExchange +open Reflection Filter Topology +lemma matrix_entry_continuousAt {a c k : Type*} [TopologicalSpace k] + {f : ℝ → Matrix a c k} {u : ℝ} (h : ContinuousAt f u) (i : a) (j : c) : + ContinuousAt (fun x => f x i j) u := + continuousAt_pi.1 (continuousAt_pi.1 h i) j +lemma continuousAt_row (n : ℕ) (A : ℝ → Fin n → Local) (u : ℝ) + (hA : ∀ i, ContinuousAt (fun x => A x i) u) (s t : Space n) : + ContinuousAt (fun x => row n (A x) s t) u := by + induction n with + | zero => exact continuousAt_const + | succ n ih => + change ContinuousAt (fun x => block (A x 0) (s 0) (t 0) * + row n (Fin.tail (A x)) (Fin.tail s) (Fin.tail t)) u + have hb : ContinuousAt (fun x => block (A x 0) (s 0) (t 0)) u := by + apply continuousAt_pi.2; intro i + apply continuousAt_pi.2; intro j + exact matrix_entry_continuousAt (hA 0) (i,s 0) (j,t 0) + exact hb.mul (ih (fun x => Fin.tail (A x)) (fun i => hA i.succ) _ _) +lemma continuousAt_exact_row (n : ℕ) (ξ : Fin n → ℝ) (u : ℝ) + (hu : ∀ i, Q (u+ξ i)≠0) (s t : Space n) : + ContinuousAt (fun x => row n (exactSites n ξ x) s t) u := by + apply continuousAt_row + intro i + exact (continuousAt_spectralR (u+ξ i) (hu i)).comp (f:=fun x : ℝ => x+ξ i) + (continuousAt_id.add continuousAt_const) +end CriticalHoneycomb.Transfer.RowExchange +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet Filter Topology +open scoped Matrix BigOperators +lemma continuous_C : Continuous C := by + exact TrivSqZeroExt.continuous_inl.comp TrivSqZeroExt.continuous_inl +lemma continuousAt_K (e : Jet) (u : ℝ) (hu : sine (gamma+u)≠0) (p : Pair) : + ContinuousAt (fun x => K e x p) u := by + have h0 : ContinuousAt (fun x => K0 x p) u := + continuousAt_const.mul (matrix_entry_continuousAt (continuousAt_boundary0 u hu) p.1 p.2.rev) + have h1 : ContinuousAt (fun x => K1 x p) u := + continuousAt_const.mul (matrix_entry_continuousAt (continuousAt_boundary1 u hu) p.1 p.2.rev) + exact (continuous_C.continuousAt.comp h0).add + (continuousAt_const.mul (continuous_C.continuousAt.comp h1)) +lemma continuousAt_bulkRows (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hu : Nonsingular N ξ u) (s t : Space N) : + ContinuousAt (fun x => bulkRows N ξ x s t) u := by + apply continuousAt_pi.2; intro p + apply continuousAt_pi.2; intro q + unfold bulkRows forward + simp only [Matrix.sum_apply] + apply tendsto_finsetSum + intro v hv + exact (matrix_entry_continuousAt (continuousAt_exact_row N ξ u (fun i => (hu.2.2 i).1) s v) p.1 q.1).mul + (matrix_entry_continuousAt ((continuousAt_exact_row N ξ (b-u) (fun i => (hu.2.2 i).2) v t).comp (f:=fun x : ℝ => b-x) + (continuousAt_const.sub continuousAt_id)) p.2 q.2) +lemma continuousAt_T (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hu : Nonsingular N ξ u) : ContinuousAt (T N ξ) u := by + apply continuousAt_pi.2; intro s + apply continuousAt_pi.2; intro t + unfold T + apply tendsto_finsetSum; intro p hp + apply tendsto_finsetSum; intro q hq + exact (((continuousAt_K eL (b-u) hu.2.1 p).comp (f:=fun x : ℝ => b-x) + (continuousAt_const.sub continuousAt_id)).mul + (continuous_C.continuousAt.comp (matrix_entry_continuousAt (continuousAt_bulkRows N ξ u hu s t) p q))).mul + (continuousAt_K eR u hu.1 q) +lemma eventually_nonsingular (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hu : Nonsingular N ξ u) : ∀ᶠ x in 𝓝 u, Nonsingular N ξ x := by + have h0 := ((continuous_sine.comp (continuous_const.add continuous_id)).continuousAt + (x:=u)).eventually_ne hu.1 + have h1 := ((continuous_sine.comp (continuous_const.add + (continuous_const.sub continuous_id))).continuousAt (x:=u)).eventually_ne hu.2.1 + have h2 : ∀ᶠ x in 𝓝 u, ∀ i, Q (x+ξ i)≠0 ∧ Q ((b-x)+ξ i)≠0 := by + apply Filter.eventually_all.2 + intro i + exact (((continuous_Q.comp (continuous_id.add continuous_const)).continuousAt + (x:=u)).eventually_ne (hu.2.2 i).1).and + (((continuous_Q.comp ((continuous_const.sub continuous_id).add continuous_const)).continuousAt + (x:=u)).eventually_ne (hu.2.2 i).2) + exact h0.and (h1.and h2) +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet ClosedFourRow +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma K_tensor (e : Jet) (he : e*e=0) (t y : ℝ) : + tensorBoundary (K e t) (K e y) = + fun p => C (flatten4 (pairVector (boundary0 t) (boundary0 y)) p)+ + e*C (flatten4 (pairVector (boundary1 t) (boundary0 y)+ + pairVector (boundary0 t) (boundary1 y)) p) := by + unfold K + rw [square_zero_tensor C e he] + rfl +lemma marked_right_invariant (e : Jet) (he : e*e=0) (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + (exactTrain t y).map C *ᵥ tensorBoundary (K e t) (K e y) = + tensorBoundary (K e t) (K e y) := by + rw [K_tensor e he] + apply map_right_jet (k:=ℂ) (k':=Jet) (ι:=Aux Spin) C (exactTrain t y) + (flatten4 (pairVector (boundary0 t) (boundary0 y))) + (flatten4 (pairVector (boundary1 t) (boundary0 y)+pairVector (boundary0 t) (boundary1 y))) + (exactTrain_right_constant t y hm hp hnm hnp ht hy) + (exactTrain_right_linear t y hm hp hnm hnp ht hy) e +lemma marked_left_invariant (e : Jet) (he : e*e=0) (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+(b-t))≠0) (hy : sine (gamma+(b-y))≠0) : + tensorBoundary (K e (b-t)) (K e (b-y)) ᵥ* (exactTrain t y).map C = + tensorBoundary (K e (b-t)) (K e (b-y)) := by + rw [K_tensor e he] + apply map_left_jet (k:=ℂ) (k':=Jet) (ι:=Aux Spin) C (exactTrain t y) + (flatten4 (pairVector (boundary0 (b-t)) (boundary0 (b-y)))) + (flatten4 (pairVector (boundary1 (b-t)) (boundary0 (b-y))+pairVector (boundary0 (b-t)) (boundary1 (b-y)))) + (exactTrain_left_constant t y hm hp hnm hnp ht hy) + (exactTrain_left_linear t y hm hp hnm hnp ht hy) e +lemma JRow_exchange (N : ℕ) (ξ : Fin N→ℝ) (u v : ℝ) + (hu : ∀ i, Q (u+ξ i)≠0) (hv : ∀ i, Q (v+ξ i)≠0) + (hd : Q (u-v)≠0) : + ∀ s t, (spectralR (u-v)).map C * forwardPair (JRow N ξ u) (JRow N ξ v) s t = + backwardPair (JRow N ξ u) (JRow N ξ v) s t * (spectralR (u-v)).map C := +by + intro s t + rw [forward_JRow,backward_JRow,←Matrix.map_mul,←Matrix.map_mul] + exact congrArg (fun M : Matrix Pair Pair ℂ=>M.map C) + (exact_row_exchange N ξ u v hu hv hd s t) +lemma exactTrain_jet (u v : ℝ) : (exactTrain u v).map C = + auxTrain ((spectralR (b-(u+v))).map C) ((spectralR (u-v)).map C) + ((spectralR (-(u-v))).map C) ((spectralR (-(b-(u+v)))).map C) := by + unfold exactTrain + exact map_auxTrain (k:=ℂ) (k':=Jet) (α:=Spin) C _ _ _ _ + +theorem closed_commutation_generic (N : ℕ) (ξ : Fin N→ℝ) (u v : ℝ) + (hu : Nonsingular N ξ u) (hv : Nonsingular N ξ v) + (hm : Q (u-v)≠0) (hp : Q (u+v)≠0) + (hnm : Q (-(u-v))≠0) (hnp : Q (-(b-(u+v)))≠0) : + Commute (T N ξ u) (T N ξ v) := by + have h₁ : ∀ s t, (spectralR (b-(u+v))).map C * + forwardPair (JRow N ξ (b-u)) (JRow N ξ v) s t = + backwardPair (JRow N ξ (b-u)) (JRow N ξ v) s t * + (spectralR (b-(u+v))).map C := by + have hd : Q ((b-u)-v)≠0 := by + rw [show (b-u)-v=b-(u+v) by ring,reflected_Q] + exact hp + simpa only [show (b-u)-v=b-(u+v) by ring] using + JRow_exchange N ξ (b-u) v (fun i => (hu.2.2 i).2) (fun i => (hv.2.2 i).1) hd + have h₂ := JRow_exchange N ξ u v (fun i => (hu.2.2 i).1) (fun i => (hv.2.2 i).1) hm + have h₃ : ∀ s t, (spectralR (-(u-v))).map C * + forwardPair (JRow N ξ (b-u)) (JRow N ξ (b-v)) s t = + backwardPair (JRow N ξ (b-u)) (JRow N ξ (b-v)) s t * + (spectralR (-(u-v))).map C := by + have hd : Q ((b-u)-(b-v))≠0 := by simpa only [show (b-u)-(b-v)=-(u-v) by ring] using hnm + simpa only [show (b-u)-(b-v)=-(u-v) by ring] using + JRow_exchange N ξ (b-u) (b-v) (fun i => (hu.2.2 i).2) (fun i => (hv.2.2 i).2) hd + have h₄ : ∀ s t, (spectralR (-(b-(u+v)))).map C * + forwardPair (JRow N ξ u) (JRow N ξ (b-v)) s t = + backwardPair (JRow N ξ u) (JRow N ξ (b-v)) s t * + (spectralR (-(b-(u+v)))).map C := by + have hd : Q (u-(b-v))≠0 := by simpa only [show u-(b-v)=-(b-(u+v)) by ring] using hnp + simpa only [show u-(b-v)=-(b-(u+v)) by ring] using + JRow_exchange N ξ u (b-v) (fun i => (hu.2.2 i).1) (fun i => (hv.2.2 i).2) hd + have hl := marked_left_invariant eL (by simpa only [pow_two] using eL_sq) u v + hm hp hnm hnp hu.2.1 hv.2.1 + have hr := marked_right_invariant eR (by simpa only [pow_two] using eR_sq) u v + hm hp hnm hnp hu.1 hv.1 + rw [exactTrain_jet] at hl hr + rw [T_closePair,T_closePair] + exact closed_four_train (JRow N ξ u) (JRow N ξ (b-u)) + (JRow N ξ v) (JRow N ξ (b-v)) + ((spectralR (b-(u+v))).map C) ((spectralR (u-v)).map C) + ((spectralR (-(u-v))).map C) ((spectralR (-(b-(u+v)))).map C) + (K eL (b-u)) (K eL (b-v)) (K eR u) (K eR v) h₁ h₂ h₃ h₄ hl hr +open Filter Topology + +theorem source_global_spectral_commutation : GlobalSpectralCommutation := by + intro N ξ u v hu hv + let D : Set ℝ := {w | Q (u-w)≠0 ∧ Q (u+w)≠0 ∧ + Q (-(u-w))≠0 ∧ Q (-(b-(u+w)))≠0} + have hd : Dense D := dense_exchange_regular u + have : Filter.NeBot (𝓝[D] v) := mem_closure_iff_nhdsWithin_neBot.mp (hd v) + have hc := continuousAt_T N ξ v hv + have hf : Tendsto (fun w => T N ξ u*T N ξ w) (𝓝[D] v) + (𝓝 (T N ξ u*T N ξ v)) := + (continuousAt_const.mul hc).mono_left nhdsWithin_le_nhds + have hg : Tendsto (fun w => T N ξ w*T N ξ u) (𝓝[D] v) + (𝓝 (T N ξ v*T N ξ u)) := + (hc.mul continuousAt_const).mono_left nhdsWithin_le_nhds + have he : (fun w => T N ξ u*T N ξ w) =ᶠ[𝓝[D] v] + (fun w => T N ξ w*T N ξ u) := by + have hmem : ∀ᶠ w in 𝓝[D] v, w∈D := self_mem_nhdsWithin + have hreg := (eventually_nonsingular N ξ v hv).filter_mono (nhdsWithin_le_nhds (s:=D)) + filter_upwards [hmem,hreg] with w hw hns + exact (closed_commutation_generic N ξ u w hu hns hw.1 hw.2.1 hw.2.2.1 hw.2.2.2).eq + exact tendsto_nhds_unique_of_eventuallyEq hf hg he +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet ClosedFourRow Filter Topology +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +lemma spectral_PT_entry (u : ℝ) (p q : Pair) : + spectralR u (q.2,q.1) p = spectralR u (p.2,p.1) q := by + rcases p with ⟨a,b⟩;rcases q with ⟨c,d⟩ + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d <;> rfl +lemma spectral_PT_jet (u : ℝ) : + ((spectralR u).map C)ᵀ*pairSwap=pairSwap*(spectralR u).map C := by + funext p q + rw [mul_pairSwap,pairSwap_mul] + simp only [Matrix.transpose_apply,Matrix.map_apply,spectral_PT_entry] +lemma K_swap (e : Jet) (u : ℝ) (hd : Q (u-(b-u))≠0) + (hu : sine (gamma+u)≠0) (hr : sine (gamma+(b-u))≠0) : + (spectralR (u-(b-u))).map C*ᵥK e u = pairSwap*ᵥK e (b-u) := by + have he : (spectralR (u-(b-u))).map C*ᵥK e u = fun p=> + C ((spectralR (u-(b-u))*ᵥK0 u) p)+e*C ((spectralR (u-(b-u))*ᵥK1 u) p) := by + funext p + simp only [K,Matrix.mulVec,dotProduct,Matrix.map_apply,map_sum,map_mul, + Finset.mul_sum,mul_add,Finset.sum_add_distrib] + congr 1 + apply Finset.sum_congr rfl + intro i hi + ring + rw [he,source_K0_swap u hd hu hr,source_K1_swap u hd hu hr] + funext p + rw [pairSwap_mulVec] + rfl +lemma spectral_reflection_generic (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hu : Nonsingular N ξ u) (hd : Q (u-(b-u))≠0) : + T N ξ u = T N ξ (b-u) := by + rw [T_closePair,T_closePair,sub_sub_cancel] + funext s t + rw [closePair_dot,closePair_dot] + have he := JRow_exchange N ξ u (b-u) (fun i=>(hu.2.2 i).1) + (fun i=>(hu.2.2 i).2) hd s t + have hc := closed_pair_reflection ((spectralR (u-(b-u))).map C) + (forwardPair (JRow N ξ u) (JRow N ξ (b-u)) s t) + (backwardPair (JRow N ξ u) (JRow N ξ (b-u)) s t) + (K eL (b-u)) (K eR u) (K eL u) (K eR (b-u)) + he (spectral_PT_jet (u-(b-u))) (K_swap eL u hd hu.1 hu.2.1) + (K_swap eR u hd hu.1 hu.2.1) + rw [swap_backward] at hc + exact hc +lemma nonsingular_reflect (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hu : Nonsingular N ξ u) : Nonsingular N ξ (b-u) := by + refine ⟨hu.2.1,?_,?_⟩ + · simpa only [sub_sub_cancel] using hu.1 + · intro i + simpa only [sub_sub_cancel] using (hu.2.2 i).symm +lemma dense_swap_regular : Dense {u : ℝ|Q (u-(b-u))≠0} := by + have h:=Q_zero_countable.preimage (f:=fun u : ℝ=>u-(b-u)) (fun x y h=>by linarith) + exact h.dense_compl ℝ + +theorem source_spectral_reflection (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (hu : Nonsingular N ξ u) : T N ξ u=T N ξ (b-u) := by + let D : Set ℝ := {x|Q (x-(b-x))≠0} + have : Filter.NeBot (𝓝[D] u) := mem_closure_iff_nhdsWithin_neBot.mp (dense_swap_regular u) + have hf := (continuousAt_T N ξ u hu).mono_left (nhdsWithin_le_nhds (s:=D)) + have hg := ((continuousAt_T N ξ (b-u) (nonsingular_reflect N ξ u hu)).comp + (f:=fun x : ℝ=>b-x) (continuousAt_const.sub continuousAt_id)).mono_left + (nhdsWithin_le_nhds (s:=D)) + have he : (fun x=>T N ξ x) =ᶠ[𝓝[D] u] (fun x=>T N ξ (b-x)) := by + have hmem : ∀ᶠ x in 𝓝[D] u,x∈D := self_mem_nhdsWithin + have hreg := (eventually_nonsingular N ξ u hu).filter_mono (nhdsWithin_le_nhds (s:=D)) + filter_upwards [hmem,hreg] with x hx hns + exact spectral_reflection_generic N ξ x hns hx + exact tendsto_nhds_unique_of_eventuallyEq hf hg he +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet ClosedFourRow +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def parity (a : Spin) : ℂ := if a=1 then -1 else 1 +lemma parity_sq (a : Spin) : parity a*parity a=1 := by + unfold parity;split <;> ring +lemma sine_add_pi (u : ℝ) : sine (u+Real.pi) = -sine u := by + simp [sine,Real.sin_add_pi] +lemma sine_sub_pi (u : ℝ) : sine (u-Real.pi) = -sine u := by + simp [sine,Real.sin_sub_pi] +lemma Q_periodic (u : ℝ) : Q (u+Real.pi)=Q u := by + simp [Q,←add_assoc,sine_add_pi] +lemma A_antiperiodic (u : ℝ) : coeffA (u+Real.pi)= -coeffA u := by + simp [coeffA,show b-(u+Real.pi)=(b-u)-Real.pi by ring,sine_sub_pi] +lemma H_antiperiodic (u : ℝ) : coeffH (u+Real.pi)= -coeffH u := by + simp [coeffH,sine_add_pi] +lemma V_periodic (u : ℝ) : coeffV (u+Real.pi)=coeffV u := by + simp [coeffV,show b-(u+Real.pi)=(b-u)-Real.pi by ring,sine_sub_pi,sine_add_pi] +lemma C_periodic (u : ℝ) : coeffC (u+Real.pi)=coeffC u := by + simp [coeffC,show b-(u+Real.pi)=(b-u)-Real.pi by ring, + show Real.pi/4-(u+Real.pi)=(Real.pi/4-u)-Real.pi by ring,sine_sub_pi] +lemma D_periodic (u : ℝ) : coeffD (u+Real.pi)=coeffD u := by + simp [coeffD,show u+Real.pi-L=(u-L)+Real.pi by ring,sine_add_pi] +lemma R_periodic_entry (u : ℝ) (p q : Pair) : + spectralR (u+Real.pi) p q=parity p.1*parity q.1*spectralR u p q := by + rcases p with ⟨a,b⟩;rcases q with ⟨c,d⟩ + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,parity,Q_periodic,A_antiperiodic,H_antiperiodic, + V_periodic,C_periodic,D_periodic,neg_div,mul_neg] +lemma boundary0_periodic (u : ℝ) (a b : Spin) : boundary0 (u+Real.pi) a b=boundary0 u a b := by + simp [boundary0,show gamma-(u+Real.pi)=(gamma-u)-Real.pi by ring, + ←add_assoc,sine_add_pi,sine_sub_pi] +lemma boundary1_antiperiodic (u : ℝ) (a b : Spin) : boundary1 (u+Real.pi) a b= -boundary1 u a b := by + have hs : sine (2*(u+Real.pi))=sine (2*u) := by + rw [show 2*(u+Real.pi)=(2*u+Real.pi)+Real.pi by ring,sine_add_pi,sine_add_pi,neg_neg] + simp only [boundary1,hs,←add_assoc,sine_add_pi] + split_ifs <;> simp [div_neg] +lemma K0_periodic_entry (u : ℝ) (p : Pair) : + K0 (u+Real.pi) p=parity p.1*parity p.2*K0 u p := by + simp only [K0,boundary0_periodic] + rcases p with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> simp [parity,boundary0,Fin.rev] +lemma K1_periodic_entry (u : ℝ) (p : Pair) : + K1 (u+Real.pi) p=parity p.1*parity p.2*K1 u p := by + simp only [K1,boundary1_antiperiodic] + rcases p with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> simp [parity,boundary1,Fin.rev] +lemma row_parity (n : ℕ) (A B : Fin n→Local) + (h : ∀ i p q,B i p q=parity p.1*parity q.1*A i p q) + (s t : Space n) (a b : Spin) : + row n B s t a b=parity a*parity b*row n A s t a b := by + induction n generalizing a b with + | zero => + simp only [row,Matrix.one_apply] + split_ifs with he + · subst b;rw [parity_sq,mul_one] + · ring + | succ n ih => + simp only [row,Matrix.mul_apply,block,h,ih (Fin.tail A) (Fin.tail B) (fun i=>h i.succ)] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro c hc + calc + _=(parity a*parity b*(A 0 (a,s 0) (c,t 0)* + row n (Fin.tail A) (Fin.tail s) (Fin.tail t) c b))*(parity c*parity c) := by ring + _=_ := by rw [parity_sq,mul_one] +lemma spectral_row_periodic (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (s t : Space N) (a b : Spin) : + row N (exactSites N ξ (u+Real.pi)) s t a b= + parity a*parity b*row N (exactSites N ξ u) s t a b := by + apply row_parity + intro i p q + simp only [exactSites,show u+Real.pi+ξ i=(u+ξ i)+Real.pi by ring,R_periodic_entry] +lemma spectral_row_sub_period (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (s t : Space N) (a b : Spin) : + row N (exactSites N ξ (u-Real.pi)) s t a b= + parity a*parity b*row N (exactSites N ξ u) s t a b := by + have h:=spectral_row_periodic N ξ (u-Real.pi) s t a b + rw [sub_add_cancel] at h + rw [h] + symm + calc + _=(parity a*parity a)*(parity b*parity b)*row N (exactSites N ξ (u-Real.pi)) s t a b := by ring + _=_ := by rw [parity_sq,parity_sq];ring +noncomputable def pairParity (p : Pair) : ℂ := parity p.1*parity p.2 +lemma pairParity_sq (p : Pair) : pairParity p*pairParity p=1 := by + unfold pairParity + calc + _=(parity p.1*parity p.1)*(parity p.2*parity p.2) := by ring + _=1 := by rw [parity_sq,parity_sq,mul_one] +lemma bulkRows_periodic (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (s t : Space N) (p q : Pair) : + bulkRows N ξ (u+Real.pi) s t p q= + pairParity p*pairParity q*bulkRows N ξ u s t p q := by + simp only [bulkRows,forward,Matrix.sum_apply,Matrix.kronecker,Matrix.kroneckerMap, + Matrix.of_apply,show b-(u+Real.pi)=(b-u)-Real.pi by ring, + spectral_row_periodic,spectral_row_sub_period,Finset.mul_sum] + apply Finset.sum_congr rfl + intro v hv + unfold pairParity + ring +lemma Kpart_periodic (i : Bool) (u : ℝ) (p : Pair) : + (if i then K1 (u+Real.pi) p else K0 (u+Real.pi) p)= + pairParity p*(if i then K1 u p else K0 u p) := by + cases i <;> simp [pairParity,K0_periodic_entry,K1_periodic_entry] +lemma Kpart_sub_period (i : Bool) (u : ℝ) (p : Pair) : + (if i then K1 (u-Real.pi) p else K0 (u-Real.pi) p)= + pairParity p*(if i then K1 u p else K0 u p) := by + have h:=Kpart_periodic i (u-Real.pi) p + rw [sub_add_cancel] at h + rw [h,←mul_assoc,pairParity_sq,one_mul] +lemma coefficient_periodic (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) (i j : Bool) : + coefficient N ξ (u+Real.pi) i j=coefficient N ξ u i j := by + funext s t + simp only [coefficient,show b-(u+Real.pi)=(b-u)-Real.pi by ring, + Kpart_sub_period,Kpart_periodic,bulkRows_periodic] + apply Finset.sum_congr rfl + intro p hp + apply Finset.sum_congr rfl + intro q hq + calc + _=(pairParity p*pairParity p)*(pairParity q*pairParity q)* + ((if i then K1 (b-u) p else K0 (b-u) p)*bulkRows N ξ u s t p q* + (if j then K1 u q else K0 u q)) := by ring + _=_ := by rw [pairParity_sq,pairParity_sq,one_mul,one_mul] + +theorem source_spectral_periodicity (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) : + T N ξ (u+Real.pi)=T N ξ u := by + funext s t + simp only [T_coefficients,coefficient_periodic] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet +open scoped Matrix BigOperators +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +noncomputable def cap (p : Pair) : ℂ := if p.2=p.1.rev then Reflection.phase^(spinValue p.1) else 0 +lemma sum_cap (f : Pair→ℂ) : (∑ p,f p*cap p)=∑ a : Spin,f (a,a.rev)*Reflection.phase^(spinValue a) := by + rw [Fintype.sum_prod_type] + simp [cap,mul_ite] +lemma localForward_cap_expand (A B : Local) (s t : Spin) (p : Pair) : + (localForward A B s t*ᵥcap) p= + ∑ v : Spin,∑ a : Spin,A (p.1,s) (a,v)*B (p.2,v) (a.rev,t)*Reflection.phase^(spinValue a) := by + simp only [localForward,Matrix.sum_mulVec,Finset.sum_apply] + apply Finset.sum_congr rfl;intro v hv + rw [Matrix.mulVec,dotProduct,sum_cap] + rfl +lemma phase_cancel (a c : Spin) : + Reflection.phase^(spinValue a.rev-spinValue c)*Reflection.phase^(spinValue a)=Reflection.phase^(-spinValue c) := by + have hp : Reflection.phase≠0 := point_ne_zero (Real.pi/4) + rw [←zpow_add₀ hp,spinValue_rev] + congr 1 + omega +lemma localForward_cap (u : ℝ) (hu : Q u≠0) (hn : Q (-u)≠0) (s t : Spin) : + localForward (spectralR u) (spectralR (b+u)) s t*ᵥcap= + if s=t then cap else 0 := by + funext p + rw [localForward_cap_expand] + have hcross (v a : Spin) : + spectralR (b+u) (p.2,v) (a.rev,t)*Reflection.phase^(spinValue a)= + Reflection.phase^(-spinValue p.2)*spectralR (-u) (p.2.rev,t) (a,v) := by + rw [show b+u=b-(-u) by ring,source_crossing,Fin.rev_rev] + calc + _=(Reflection.phase^(spinValue a.rev-spinValue p.2)*Reflection.phase^(spinValue a))* + spectralR (-u) (p.2.rev,t) (a,v) := by ring + _=_ := by rw [phase_cancel] + have he : (∑ v : Spin,∑ a : Spin,spectralR u (p.1,s) (a,v)* + spectralR (b+u) (p.2,v) (a.rev,t)*Reflection.phase^(spinValue a))= + Reflection.phase^(-spinValue p.2)*((spectralR u*(spectralR (-u))ᵀ) (p.1,s) (p.2.rev,t)) := by + simp only [Matrix.mul_apply,Matrix.transpose_apply,Fintype.sum_prod_type,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl;intro v hv + apply Finset.sum_congr rfl;intro a ha + rw [mul_assoc,hcross] + ring + rw [he,spectral_unitarity u hu hn,Matrix.one_apply] + by_cases hs : s=t + · subst t + by_cases hp : p.2=p.1.rev + · have hp' : p.2.rev=p.1 := by rw [hp,Fin.rev_rev] + simp [hp,cap,spinValue_rev] + · have hp' : p.1≠p.2.rev := by intro h;apply hp;rw [h,Fin.rev_rev] + simp [hp',cap,hp] + · simp [hs] +lemma localForward_period_cap (u : ℝ) (hu : Q u≠0) (hn : Q (-u)≠0) (s t : Spin) : + localForward (spectralR (u+Real.pi)) (spectralR (b+u)) s t*ᵥ(fun p=>parity p.1*cap p)= + if s=t then (fun p=>parity p.1*cap p) else 0 := by + funext p + have hl (q : Pair) : + localForward (spectralR (u+Real.pi)) (spectralR (b+u)) s t p q= + parity p.1*parity q.1*localForward (spectralR u) (spectralR (b+u)) s t p q := by + simp only [localForward,Matrix.sum_apply,Matrix.kronecker,Matrix.kroneckerMap,Matrix.of_apply,block,R_periodic_entry,Finset.mul_sum] + apply Finset.sum_congr rfl;intro v hv;ring + change (∑ q,localForward (spectralR (u+Real.pi)) (spectralR (b+u)) s t p q* + (parity q.1*cap q))=_ + simp only [hl] + have he : (∑ q,parity p.1*parity q.1*localForward (spectralR u) (spectralR (b+u)) s t p q* + (parity q.1*cap q))=parity p.1*(localForward (spectralR u) (spectralR (b+u)) s t*ᵥcap) p := by + simp only [Matrix.mulVec,dotProduct,Finset.mul_sum] + apply Finset.sum_congr rfl;intro q hq + have hq:=parity_sq q.1 + linear_combination parity p.1*localForward (spectralR u) (spectralR (b+u)) s t p q*cap q*hq + rw [he,localForward_cap u hu hn] + split_ifs <;> simp +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/SpectralRows.lean b/lean/OAI/Combinatorics/HoneycombChords/SpectralRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..9152c0e34fec1aeb0e961f2e6375eea78cce10b8 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/SpectralRows.lean @@ -0,0 +1,2141 @@ +import OAI.Combinatorics.HoneycombChords.Reflection +import OAI.Combinatorics.HoneycombChords.RowExchange + +namespace OAI + +/-! +# Spectral monodromy rows and boundary exchange identities + +Formalized from *Uniform marked polygon estimates and sharp finite bridge moments* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.Transfer.RowExchange +open Reflection Reflection.Fusion +open scoped Matrix BigOperators +lemma local_source_fusion (u : ℝ) (hm : Q (u-L)≠0) (hu : Q u≠0) (hp : Q (u+L)≠0) + (s t : Spin) : localBackward (spectralR (u+L)) (spectralR (u-L)) s t*sourceW= + sourceW*block (spectralR u) s t := by + ext ⟨a,b⟩ j + simp only [Matrix.mul_apply,Fintype.sum_prod_type,localBackward,Matrix.kronecker,Matrix.kroneckerMap,block,Matrix.sum_apply,Matrix.of_apply,Finset.sum_mul] + have hh:=source_bulk_fusion u hm hu hp a b s j t + unfold fusionProduct fusionLift at hh + convert hh using 1 + apply Finset.sum_congr rfl;intro x hx + apply Finset.sum_congr rfl;intro y hy + apply Finset.sum_congr rfl;intro z hz + ring +lemma local_source_quotient_fusion (u : ℝ) (hm : Q (u-L)≠0) (hu : Q u≠0) (hp : Q (u+L)≠0) + (s t : Spin) : sourceWbarᵀ*localForward (spectralR (u+L)) (spectralR (u-L)) s t= + block (spectralR u) s t*sourceWbarᵀ := by + have hh:=congrArg Matrix.conjTranspose (local_source_fusion u hm hu hp t s) + simpa only [Matrix.conjTranspose_mul,sourceW_conjTranspose, + localBackward_conjTranspose _ _ (spectralR_hermitian _) (spectralR_hermitian _), + block_conjTranspose _ (spectralR_hermitian _)] using hh +noncomputable def exactSites (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) : Fin n→Local := + fun i=>spectralR (u+ξ i) + +theorem source_row_fusion (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) + (hm : ∀ i,Q ((u-L)+ξ i)≠0) (hu : ∀ i,Q (u+ξ i)≠0) + (hp : ∀ i,Q ((u+L)+ξ i)≠0) (s t : Space n) : + backward n (exactSites n ξ (u+L)) (exactSites n ξ (u-L)) s t*sourceW= + sourceW*row n (exactSites n ξ u) s t := by + apply row_fusion + intro i a b + have em : (u+ξ i)-L=(u-L)+ξ i := by ring + have ep : (u+ξ i)+L=(u+L)+ξ i := by ring + simpa only [exactSites,em,ep] using local_source_fusion (u+ξ i) + (by simpa only [em] using hm i) (hu i) (by simpa only [ep] using hp i) a b + +theorem source_row_quotient_fusion (n : ℕ) (ξ : Fin n→ℝ) (u : ℝ) + (hm : ∀ i,Q ((u-L)+ξ i)≠0) (hu : ∀ i,Q (u+ξ i)≠0) + (hp : ∀ i,Q ((u+L)+ξ i)≠0) (s t : Space n) : + sourceWbarᵀ*forward n (exactSites n ξ (u+L)) (exactSites n ξ (u-L)) s t= + row n (exactSites n ξ u) s t*sourceWbarᵀ := by + apply row_quotient_fusion + intro i a b + have em : (u+ξ i)-L=(u-L)+ξ i := by ring + have ep : (u+ξ i)+L=(u+L)+ξ i := by ring + simpa only [exactSites,em,ep] using local_source_quotient_fusion (u+ξ i) + (by simpa only [em] using hm i) (hu i) (by simpa only [ep] using hp i) a b +end CriticalHoneycomb.Transfer.RowExchange + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open Fusion +open scoped Matrix +lemma reflected_Q (u : ℝ) : Q (b-u)=Q u := by + have e1 : Real.pi/4+(b-u)=Real.pi-(b+u) := by unfold b;ring + have e2 : b+(b-u)=Real.pi-(Real.pi/4+u) := by unfold b;ring + simp [Q,sine,e1,e2,Real.sin_pi_sub,mul_comm] +lemma reflected_A (u : ℝ) : coeffA (b-u)=coeffH u := by + simp [coeffA,coeffH] +lemma reflected_H (u : ℝ) : coeffH (b-u)=coeffA u := rfl +lemma reflected_V (u : ℝ) : coeffV (b-u)=coeffV u := by + simp [coeffV,mul_comm] +lemma reflected_C (u : ℝ) : coeffC (b-u)=coeffD u := by + have ee : Real.pi/4-(b-u)=u-L := by unfold b L;ring + simp [coeffC,coeffD,ee] +lemma reflected_D (u : ℝ) : coeffD (b-u)=coeffC u := by + have ee : (b-u)-L=Real.pi/4-u := by unfold b L;ring + simp [coeffC,coeffD,ee] +def spinValue (a : Fin 3) : ℤ := 1-(a.val:ℤ) +lemma spinValue_rev (a : Fin 3) : spinValue a.rev = -spinValue a := by + fin_cases a <;> norm_num [spinValue] +private lemma crossingCrossingComponent00 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (0,0) (c,d)= + phase^(spinValue c-spinValue 0)*spectralR u ((0:Fin 3).rev,d) (c.rev,0) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_C,spinValue,Fin.rev] + +private lemma crossingCrossingComponent01 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (0,1) (c,d)= + phase^(spinValue c-spinValue 0)*spectralR u ((0:Fin 3).rev,d) (c.rev,1) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma crossingCrossingComponent02 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (0,2) (c,d)= + phase^(spinValue c-spinValue 0)*spectralR u ((0:Fin 3).rev,d) (c.rev,2) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_H, + reflected_C,reflected_D,spinValue,Fin.rev, + div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] <;> ring } +private lemma crossingCrossingComponent10 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (1,0) (c,d)= + phase^(spinValue c-spinValue 1)*spectralR u ((1:Fin 3).rev,d) (c.rev,0) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev, + div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma crossingCrossingComponent11 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (1,1) (c,d)= + phase^(spinValue c-spinValue 1)*spectralR u ((1:Fin 3).rev,d) (c.rev,1) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_H, + spinValue,Fin.rev, + div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma crossingCrossingComponent12 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (1,2) (c,d)= + phase^(spinValue c-spinValue 1)*spectralR u ((1:Fin 3).rev,d) (c.rev,2) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma crossingCrossingComponent20 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (2,0) (c,d)= + phase^(spinValue c-spinValue 2)*spectralR u ((2:Fin 3).rev,d) (c.rev,0) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_H, + reflected_C,reflected_D,spinValue,Fin.rev, + div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] <;> ring } +private lemma crossingCrossingComponent21 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (2,1) (c,d)= + phase^(spinValue c-spinValue 2)*spectralR u ((2:Fin 3).rev,d) (c.rev,1) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev, + div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma crossingCrossingComponent22 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (2,2) (c,d)= + phase^(spinValue c-spinValue 2)*spectralR u ((2:Fin 3).rev,d) (c.rev,2) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_C,spinValue,Fin.rev] + + +theorem source_crossing (u : ℝ) (i j k l : Fin 3) : + spectralR (b-u) (i,j) (k,l)= + phase^(spinValue k-spinValue i)*spectralR u (i.rev,l) (k.rev,j) := by + fin_cases i <;> fin_cases j + · exact crossingCrossingComponent00 u k l + · exact crossingCrossingComponent01 u k l + · exact crossingCrossingComponent02 u k l + · exact crossingCrossingComponent10 u k l + · exact crossingCrossingComponent11 u k l + · exact crossingCrossingComponent12 u k l + · exact crossingCrossingComponent20 u k l + · exact crossingCrossingComponent21 u k l + · exact crossingCrossingComponent22 u k l +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.BoundaryJet +open TrivSqZeroExt +abbrev Jet := DualNumber (DualNumber ℂ) +noncomputable def C : ℂ →+* Jet := (inlHom (R := DualNumber ℂ) (M := DualNumber ℂ)).comp (inlHom (R := ℂ) (M := ℂ)) +noncomputable def eL : Jet := inr 1 +noncomputable def eR : Jet := inl (inr 1) +noncomputable def base (a : Jet) : ℂ := a.fst.fst +noncomputable def left (a : Jet) : ℂ := a.snd.fst +noncomputable def right (a : Jet) : ℂ := a.fst.snd +noncomputable def both (a : Jet) : ℂ := a.snd.snd +lemma jet_ext (a b : Jet) (h₀ : base a=base b) (h₁ : left a=left b) + (h₂ : right a=right b) (h₃ : both a=both b) : a=b := by + apply TrivSqZeroExt.ext + · exact TrivSqZeroExt.ext h₀ h₂ + · exact TrivSqZeroExt.ext h₁ h₃ +@[simp] lemma base_mul (a b : Jet) : base (a*b)=base a*base b := rfl +@[simp] lemma left_mul (a b : Jet) : left (a*b)=base a*left b+left a*base b := by + simp [left,base,smul_eq_mul] +@[simp] lemma right_mul (a b : Jet) : right (a*b)=base a*right b+right a*base b := by + simp [right,base,smul_eq_mul] +@[simp] lemma both_mul (a b : Jet) : both (a*b)=base a*both b+left a*right b+ + right a*left b+both a*base b := by + simp [both,base,left,right,smul_eq_mul] + ring +@[simp] lemma base_add (a b : Jet) : base (a+b)=base a+base b := rfl +@[simp] lemma left_add (a b : Jet) : left (a+b)=left a+left b := rfl +@[simp] lemma right_add (a b : Jet) : right (a+b)=right a+right b := rfl +@[simp] lemma both_add (a b : Jet) : both (a+b)=both a+both b := rfl +@[simp] lemma base_C (a : ℂ) : base (C a)=a := rfl +@[simp] lemma left_C (a : ℂ) : left (C a)=0 := rfl +@[simp] lemma right_C (a : ℂ) : right (C a)=0 := rfl +@[simp] lemma both_C (a : ℂ) : both (C a)=0 := rfl +@[simp] lemma eL_sq : eL^2=0 := by simp [eL,pow_two] +@[simp] lemma eR_sq : eR^2=0 := by + apply jet_ext <;> simp [eR,pow_two,base,left,right,both,smul_eq_mul] +noncomputable def form (a b c d : ℂ) : Jet := C a+eL*C b+eR*C c+eL*eR*C d +@[simp] lemma base_form (a b c d : ℂ) : base (form a b c d)=a := by simp [form,base,eL,eR,C] +@[simp] lemma left_form (a b c d : ℂ) : left (form a b c d)=b := by simp [form,left,eL,eR,C,smul_eq_mul] +@[simp] lemma right_form (a b c d : ℂ) : right (form a b c d)=c := by simp [form,right,eL,eR,C,smul_eq_mul] +@[simp] lemma both_form (a b c d : ℂ) : both (form a b c d)=d := by simp [form,both,eL,eR,C,smul_eq_mul] +lemma form_coords (a : Jet) : form (base a) (left a) (right a) (both a)=a := by + apply jet_ext <;> simp +noncomputable def baseAdd : Jet →+ ℂ := {toFun := base, map_zero' := rfl, map_add' := base_add} +noncomputable def leftAdd : Jet →+ ℂ := {toFun := left, map_zero' := rfl, map_add' := left_add} +noncomputable def rightAdd : Jet →+ ℂ := {toFun := right, map_zero' := rfl, map_add' := right_add} +noncomputable def bothAdd : Jet →+ ℂ := {toFun := both, map_zero' := rfl, map_add' := both_add} +lemma base_sum {ι : Type*} (s : Finset ι) (f : ι→Jet) : base (∑ i∈s,f i)=∑ i∈s,base (f i) := + map_sum baseAdd f s +lemma left_sum {ι : Type*} (s : Finset ι) (f : ι→Jet) : left (∑ i∈s,f i)=∑ i∈s,left (f i) := + map_sum leftAdd f s +lemma right_sum {ι : Type*} (s : Finset ι) (f : ι→Jet) : right (∑ i∈s,f i)=∑ i∈s,right (f i) := + map_sum rightAdd f s +lemma both_sum {ι : Type*} (s : Finset ι) (f : ι→Jet) : both (∑ i∈s,f i)=∑ i∈s,both (f i) := + map_sum bothAdd f s +end CriticalHoneycomb.BoundaryJet + +end + +section + +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet +open scoped Matrix BigOperators +noncomputable def K0 (t : ℝ) (p : Pair) : ℂ := + phase^(spinValue p.2.rev)*boundary0 t p.1 p.2.rev +noncomputable def K1 (t : ℝ) (p : Pair) : ℂ := + phase^(spinValue p.2.rev)*boundary1 t p.1 p.2.rev + +noncomputable def K (e : Jet) (t : ℝ) (p : Pair) : Jet := C (K0 t p)+e*C (K1 t p) +noncomputable def bulkRows (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) + (s t : Space N) : Matrix Pair Pair ℂ := + forward N (exactSites N ξ u) (exactSites N ξ (b-u)) s t + +noncomputable def T (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) : + Matrix (Space N) (Space N) Jet := fun s t=> + ∑ p : Pair,∑ q : Pair,K eL (b-u) p*C (bulkRows N ξ u s t p q)*K eR u q +noncomputable def coefficient (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) (i j : Bool) : + Matrix (Space N) (Space N) ℂ := fun s t=> + ∑ p : Pair,∑ q : Pair,(if i then K1 (b-u) p else K0 (b-u) p)* + bulkRows N ξ u s t p q*(if j then K1 u q else K0 u q) +lemma K_left (u : ℝ) (p : Pair) : K eL u p=form (K0 u p) (K1 u p) 0 0 := by + apply jet_ext <;> simp [K,form,base,left,right,both,C,eL,eR,smul_eq_mul] +lemma K_right (u : ℝ) (p : Pair) : K eR u p=form (K0 u p) 0 (K1 u p) 0 := by + apply jet_ext <;> simp [K,form,base,left,right,both,C,eL,eR,smul_eq_mul] + +theorem T_coefficients (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) (s t : Space N) : + T N ξ u s t=form (coefficient N ξ u false false s t) + (coefficient N ξ u true false s t) (coefficient N ξ u false true s t) + (coefficient N ξ u true true s t) := by + apply jet_ext <;> + simp [T,coefficient,base_sum,left_sum,right_sum,both_sum,K_left,K_right, + base_mul,left_mul,right_mul,both_mul] + +def Nonsingular (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) : Prop := + sine (gamma+u)≠0 ∧ sine (gamma+(b-u))≠0 ∧ + ∀ i, Q (u+ξ i)≠0 ∧ Q ((b-u)+ξ i)≠0 + +def GlobalSpectralCommutation : Prop := + ∀ N (ξ : Fin N→ℝ) (u v : ℝ), Nonsingular N ξ u→Nonsingular N ξ v→ + Commute (T N ξ u) (T N ξ v) + +def GlobalSpectralFusion : Prop := + ∀ N (ξ : Fin N→ℝ) (i : Fin N) (u : ℝ), + (u=L-ξ i ∨ u=L+ξ i)→Nonsingular N ξ (u-L)→ + Nonsingular N ξ (u+L)→Nonsingular N ξ u→ + T N ξ (u-L)*T N ξ (u+L)=T N ξ u +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix BigOperators +lemma point_reflected_mul (t : ℝ) : point t*point (b-t)-root^6=0 := by + rw [←point_add,add_sub_cancel,root_pow] + + unfold b + ring_nf +lemma alphaMinus_C_poly (t y : ℝ) (h : Q (t-y)≠0) : + alphaMinus t y*(coeffC (t-y)/Q (t-y)) = + (root^6*(point y)^2+root^10*(point t)^2)* + (root^4*(point y)^2+root^12*(point t)^2) := by + have hh:=congrFun (congrFun (rminus_scaled t y h) (0,0)) (0,0) + simpa [spectralR,bulkNumerator,rNumerator,smul_eq_mul,div_eq_mul_inv,mul_comm,mul_left_comm,mul_assoc] using hh +lemma alphaMinus_H_poly (t y : ℝ) (h : Q (t-y)≠0) : + alphaMinus t y*(coeffH (t-y)/Q (t-y)) = + (root^4+root^12)*point t*point y*((point t)^2-(point y)^2) := by + have hh:=congrFun (congrFun (rminus_scaled t y h) (0,2)) (1,1) + simp only [Matrix.smul_apply,smul_eq_mul,spectralR,bulkNumerator,rNumerator, + Fin.val_zero,Fin.val_one,show (2:Fin 3).val=2 from rfl] at hh + rw [div_eq_mul_inv,phase_inv] at hh + have hn : -root^12≠0 := neg_ne_zero.mpr (pow_ne_zero _ root_ne_zero) + apply mul_right_cancel₀ hn + linear_combination hh +lemma alphaMinus_V_poly (t y : ℝ) (h : Q (t-y)≠0) : + alphaMinus t y*(coeffV (t-y)/Q (t-y)) = + (root^6*(point y)^2+root^10*(point t)^2)*((point t)^2-(point y)^2) := by + have hh:=congrFun (congrFun (rminus_scaled t y h) (0,1)) (0,1) + simpa [spectralR,bulkNumerator,rNumerator,smul_eq_mul,div_eq_mul_inv,mul_comm,mul_left_comm,mul_assoc] using hh +lemma alphaMinus_A_poly (t y : ℝ) (h : Q (t-y)≠0) : + alphaMinus t y*(coeffA (t-y)/Q (t-y)) = + (root^4+root^12)*point t*point y*(root^6*(point y)^2+root^10*(point t)^2) := by + have hh:=congrFun (congrFun (rminus_scaled t y h) (0,1)) (1,0) + simpa [spectralR,bulkNumerator,rNumerator,smul_eq_mul,div_eq_mul_inv,mul_comm,mul_left_comm,mul_assoc] using hh +lemma alphaMinus_poly (t y : ℝ) (h : Q (t-y)≠0) : + alphaMinus t y=(root^4*(point t)^2+root^12*(point y)^2)* + (root^6*(point t)^2+root^10*(point y)^2) := by + have hh:=congrFun (congrFun (rminus_scaled t y h) (1,1)) (1,1) + simpa [spectralR,bulkNumerator,rNumerator,smul_eq_mul,h] using hh +lemma source_swap_constant_scalar (t : ℝ) (h : Q (t-(b-t))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+(b-t))≠0) : + (coeffC (t-(b-t))/Q (t-(b-t)))*(sine (gamma-t)/sine (gamma+t))+ + coeffH (t-(b-t))/Q (t-(b-t)) = sine (gamma-(b-t))/sine (gamma+(b-t)) := by + have hh:=swap_constant_algebra root (point t) (point (b-t)) root_constraint (point_reflected_mul t) + rw [←alphaMinus_C_poly t (b-t) h,←alphaMinus_H_poly t (b-t) h, + ←alphaMinus_poly t (b-t) h,←beta_k t ht,←beta_k (b-t) hy, + ←beta_polynomial t,←beta_polynomial (b-t)] at hh + apply mul_left_cancel₀ (mul_ne_zero (mul_ne_zero + (alphaMinus_ne_zero t (b-t) h) (beta_ne_zero t ht)) (beta_ne_zero (b-t) hy)) + linear_combination hh +lemma source_swap_linear_scalar (t : ℝ) (h : Q (t-(b-t))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+(b-t))≠0) : + ((coeffV (t-(b-t))/Q (t-(b-t)))+(coeffA (t-(b-t))/Q (t-(b-t))))* + (sine (2*t)/sine (gamma+t)) = sine (2*(b-t))/sine (gamma+(b-t)) := by + have hh:=swap_linear_algebra root (point t) (point (b-t)) root_constraint (point_reflected_mul t) + rw [←alphaMinus_V_poly t (b-t) h,←alphaMinus_A_poly t (b-t) h, + ←alphaMinus_poly t (b-t) h,←beta_l t ht,←beta_l (b-t) hy, + ←beta_polynomial t,←beta_polynomial (b-t)] at hh + apply mul_left_cancel₀ (mul_ne_zero (mul_ne_zero + (alphaMinus_ne_zero t (b-t) h) (beta_ne_zero t ht)) (beta_ne_zero (b-t) hy)) + linear_combination hh +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection BoundaryJet +open scoped Matrix BigOperators +private lemma boundarySwapPhaseFourRelation : phase^4+1=0 := by + rw [phase_eq,←pow_mul] + exact root_constraint +lemma source_K0_swap (t : ℝ) (h : Q (t-(b-t))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+(b-t))≠0) : + spectralR (t-(b-t)) *ᵥ K0 t = fun p => K0 (b-t) (p.2,p.1) := by + have hc:=source_swap_constant_scalar t h ht hy + have hp:=boundarySwapPhaseFourRelation + have hn : phase≠0 := point_ne_zero _ + funext ⟨a,b'⟩ + fin_cases a <;> fin_cases b' <;> + simp [Matrix.mulVec,dotProduct,Fintype.sum_prod_type,Fin.sum_univ_three, + spectralR,bulkNumerator,K0,boundary0,spinValue,Fin.rev] + all_goals field_simp [h,ht,hy,hn] at hc ⊢ + · linear_combination phase^2*hc + sine (gamma+(b-t))*sine (gamma-t)*coeffD (t-(b-t))*hp + · linear_combination sine (gamma-t)*coeffH (t-(b-t))*hp + · linear_combination phase^2*hc + sine (gamma+(b-t))*sine (gamma-t)*coeffD (t-(b-t))*hp +lemma source_K1_swap (t : ℝ) (h : Q (t-(b-t))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+(b-t))≠0) : + spectralR (t-(b-t)) *ᵥ K1 t = fun p => K1 (b-t) (p.2,p.1) := by + have hc:=source_swap_linear_scalar t h ht hy + funext ⟨a,b'⟩ + fin_cases a <;> fin_cases b' <;> + simp [Matrix.mulVec,dotProduct,Fintype.sum_prod_type,Fin.sum_univ_three, + spectralR,bulkNumerator,K1,boundary1,spinValue,Fin.rev,div_eq_mul_inv] + all_goals + have hn : phase≠0 := point_ne_zero _ + field_simp [h,ht,hy,hn] at hc ⊢ + linear_combination hc +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section + +namespace CriticalHoneycomb.Transfer.ClosedFourRow +open scoped Matrix BigOperators +section +variable {α ι k k' : Type*} [CommSemiring k] [CommSemiring k'] + [Fintype α] [DecidableEq α] [Fintype ι] [DecidableEq ι] +omit [Fintype α] [DecidableEq α] [DecidableEq ι] in +lemma map_forwardPair (f : k →+* k') (M N : Row α ι k) (s t : ι) : + (forwardPair M N s t).map f = + forwardPair (fun s t => (M s t).map f) (fun s t => (N s t).map f) s t := by + ext p q + simp [forwardPair,Matrix.map_apply,Matrix.sum_apply,map_sum, + Matrix.kronecker,Matrix.kroneckerMap] +omit [Fintype α] [DecidableEq α] [DecidableEq ι] in +lemma map_backwardPair (f : k →+* k') (M N : Row α ι k) (s t : ι) : + (backwardPair M N s t).map f = + backwardPair (fun s t => (M s t).map f) (fun s t => (N s t).map f) s t := by + ext p q + simp [backwardPair,Matrix.map_apply,Matrix.sum_apply,map_sum, + Matrix.kronecker,Matrix.kroneckerMap] +omit [DecidableEq α] [DecidableEq ι] in +lemma map_pair_exchange (f : k →+* k') (F : Matrix (α×α) (α×α) k) + (M N : Row α ι k) + (h : ∀ s t, F * forwardPair M N s t = backwardPair M N s t * F) : + ∀ s t, F.map f * forwardPair (fun s t => (M s t).map f) + (fun s t => (N s t).map f) s t = + backwardPair (fun s t => (M s t).map f) + (fun s t => (N s t).map f) s t * F.map f := by + intro s t + have hh := congrArg (fun P : Matrix (α×α) (α×α) k => P.map f) (h s t) + simpa only [Matrix.map_mul,map_forwardPair,map_backwardPair] using hh +omit [Fintype α] in +lemma map_auxBC (f : k →+* k') (F : Matrix (α×α) (α×α) k) : + (auxBC F).map f = auxBC (F.map f) := by + ext p q + simp only [auxBC,Matrix.map_apply,Matrix.one_apply,map_mul] + split_ifs <;> simp_all +omit [Fintype α] in +lemma map_auxAC (f : k →+* k') (F : Matrix (α×α) (α×α) k) : + (auxAC F).map f = auxAC (F.map f) := by + ext p q + simp only [auxAC,Matrix.map_apply,Matrix.one_apply,map_mul] + split_ifs <;> simp_all +omit [Fintype α] in +lemma map_auxBD (f : k →+* k') (F : Matrix (α×α) (α×α) k) : + (auxBD F).map f = auxBD (F.map f) := by + ext p q + simp only [auxBD,Matrix.map_apply,Matrix.one_apply,map_mul] + split_ifs <;> simp_all +omit [Fintype α] in +lemma map_auxAD (f : k →+* k') (F : Matrix (α×α) (α×α) k) : + (auxAD F).map f = auxAD (F.map f) := by + ext p q + simp only [auxAD,Matrix.map_apply,Matrix.one_apply,map_mul] + split_ifs <;> simp_all +lemma map_auxTrain (f : k →+* k') (F₁ F₂ F₃ F₄ : Matrix (α×α) (α×α) k) : + (auxTrain F₁ F₂ F₃ F₄).map f = + auxTrain (F₁.map f) (F₂.map f) (F₃.map f) (F₄.map f) := by + simp only [auxTrain,Matrix.map_mul,map_auxAD,map_auxBD,map_auxAC,map_auxBC] +omit [Fintype α] [DecidableEq α] in +lemma square_zero_tensor (f : k →+* k') (e : k') (he : e*e=0) + (a₀ a₁ b₀ b₁ : α×α → k) : + tensorBoundary (fun p => f (a₀ p)+e*f (a₁ p)) (fun p => f (b₀ p)+e*f (b₁ p)) = + fun p => f (tensorBoundary a₀ b₀ p)+ + e*f ((tensorBoundary a₁ b₀+tensorBoundary a₀ b₁) p) := by + funext p + simp only [tensorBoundary,Pi.add_apply,map_add,map_mul] + calc + _ = f (a₀ (p.1,p.2.1))*f (b₀ (p.2.2.1,p.2.2.2))+ + e*(f (a₁ (p.1,p.2.1))*f (b₀ (p.2.2.1,p.2.2.2))+ + f (a₀ (p.1,p.2.1))*f (b₁ (p.2.2.1,p.2.2.2)))+ + (e*e)*(f (a₁ (p.1,p.2.1))*f (b₁ (p.2.2.1,p.2.2.2))) := by ring + _ = _ := by rw [he,zero_mul,add_zero] +omit [DecidableEq ι] in +lemma map_right_jet (f : k →+* k') (U : Matrix ι ι k) (r₀ r₁ : ι → k) + (h₀ : U *ᵥ r₀=r₀) (h₁ : U *ᵥ r₁=r₁) (e : k') : + U.map f *ᵥ (fun p => f (r₀ p)+ e*f (r₁ p)) = + fun p => f (r₀ p)+e*f (r₁ p) := by + have h₀' : U.map f *ᵥ (f ∘ r₀)=f ∘ r₀ := by + funext p + rw [←RingHom.map_mulVec,h₀] + rfl + have h₁' : U.map f *ᵥ (f ∘ r₁)=f ∘ r₁ := by + funext p + rw [←RingHom.map_mulVec,h₁] + rfl + change U.map f *ᵥ ((f ∘ r₀)+e • (f ∘ r₁)) = (f ∘ r₀)+e • (f ∘ r₁) + rw [Matrix.mulVec_add,Matrix.mulVec_smul,h₀',h₁'] +omit [DecidableEq ι] in +lemma map_left_jet (f : k →+* k') (U : Matrix ι ι k) (l₀ l₁ : ι → k) + (h₀ : l₀ ᵥ* U=l₀) (h₁ : l₁ ᵥ* U=l₁) (e : k') : + (fun p => f (l₀ p)+ e*f (l₁ p)) ᵥ* U.map f = + fun p => f (l₀ p)+e*f (l₁ p) := by + have h₀' : (f ∘ l₀) ᵥ* U.map f=f ∘ l₀ := by + funext p + rw [←RingHom.map_vecMul,h₀] + rfl + have h₁' : (f ∘ l₁) ᵥ* U.map f=f ∘ l₁ := by + funext p + rw [←RingHom.map_vecMul,h₁] + rfl + change ((f ∘ l₀)+e • (f ∘ l₁)) ᵥ* U.map f = (f ∘ l₀)+e • (f ∘ l₁) + rw [Matrix.add_vecMul,Matrix.smul_vecMul,h₀',h₁'] +end +end CriticalHoneycomb.Transfer.ClosedFourRow + +end + +section +namespace CriticalHoneycomb.Transfer.SpectralFamily +open Reflection RowExchange BoundaryJet ClosedFourRow +open scoped Matrix BigOperators +noncomputable def JRow (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) : Row Spin (Space N) Jet := + fun s t => (row N (exactSites N ξ u) s t).map C +lemma forward_JRow (N : ℕ) (ξ : Fin N→ℝ) (u v : ℝ) (s t : Space N) : + forwardPair (JRow N ξ u) (JRow N ξ v) s t = + (forward N (exactSites N ξ u) (exactSites N ξ v) s t).map C := by + funext p q + simp only [forwardPair,JRow,forward,Matrix.map_apply,Matrix.sum_apply,map_sum,Matrix.kronecker,Matrix.kroneckerMap,Matrix.of_apply,map_mul] +lemma T_closePair (N : ℕ) (ξ : Fin N→ℝ) (u : ℝ) : + T N ξ u = closePair (forwardPair (JRow N ξ u) (JRow N ξ (b-u))) + (K eL (b-u)) (K eR u) := by + funext s t + simp only [T,closePair,forward_JRow,bulkRows,Matrix.map_apply] +lemma backward_JRow (N : ℕ) (ξ : Fin N→ℝ) (u v : ℝ) (s t : Space N) : + backwardPair (JRow N ξ u) (JRow N ξ v) s t = + (backward N (exactSites N ξ u) (exactSites N ξ v) s t).map C := by + funext p q + simp only [backwardPair,JRow,backward,Matrix.map_apply,Matrix.sum_apply,map_sum,Matrix.kronecker,Matrix.kroneckerMap,Matrix.of_apply,map_mul] +end CriticalHoneycomb.Transfer.SpectralFamily + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix +private lemma transposeCrossingTransposeCrossing00 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (0,0)= + phase^(spinValue d-spinValue 0)*spectralR u (0,d.rev) (c,(0:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_C,spinValue,Fin.rev] + +private lemma transposeCrossingTransposeCrossing01 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (0,1)= + phase^(spinValue d-spinValue 1)*spectralR u (0,d.rev) (c,(1:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev,div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma transposeCrossingTransposeCrossing02 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (0,2)= + phase^(spinValue d-spinValue 2)*spectralR u (0,d.rev) (c,(2:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_H, + reflected_C,reflected_D,spinValue,Fin.rev,div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] <;> ring } +private lemma transposeCrossingTransposeCrossing10 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (1,0)= + phase^(spinValue d-spinValue 0)*spectralR u (1,d.rev) (c,(0:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma transposeCrossingTransposeCrossing11 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (1,1)= + phase^(spinValue d-spinValue 1)*spectralR u (1,d.rev) (c,(1:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_H, + spinValue,Fin.rev,div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma transposeCrossingTransposeCrossing12 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (1,2)= + phase^(spinValue d-spinValue 2)*spectralR u (1,d.rev) (c,(2:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev,div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma transposeCrossingTransposeCrossing20 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (2,0)= + phase^(spinValue d-spinValue 0)*spectralR u (2,d.rev) (c,(0:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_H, + reflected_C,reflected_D,spinValue,Fin.rev,div_eq_mul_inv] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] <;> ring } +private lemma transposeCrossingTransposeCrossing21 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (2,1)= + phase^(spinValue d-spinValue 1)*spectralR u (2,d.rev) (c,(1:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_A,reflected_V,spinValue,Fin.rev] + all_goals { have hn : phase ≠ 0 := point_ne_zero _ + field_simp [hn] } +private lemma transposeCrossingTransposeCrossing22 (u : ℝ) (c d : Fin 3) : + spectralR (b-u) (c,d) (2,2)= + phase^(spinValue d-spinValue 2)*spectralR u (2,d.rev) (c,(2:Fin 3).rev) := by + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,reflected_Q,reflected_C,spinValue,Fin.rev] + + +lemma source_transpose_crossing (u : ℝ) (i j k l : Fin 3) : + spectralR (b-u) (k,l) (i,j)= + phase^(spinValue l-spinValue j)*spectralR u (i,l.rev) (k,j.rev) := by + fin_cases i <;> fin_cases j + · exact transposeCrossingTransposeCrossing00 u k l + · exact transposeCrossingTransposeCrossing01 u k l + · exact transposeCrossingTransposeCrossing02 u k l + · exact transposeCrossingTransposeCrossing10 u k l + · exact transposeCrossingTransposeCrossing11 u k l + · exact transposeCrossingTransposeCrossing12 u k l + · exact transposeCrossingTransposeCrossing20 u k l + · exact transposeCrossingTransposeCrossing21 u k l + · exact transposeCrossingTransposeCrossing22 u k l +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open TrivSqZeroExt +open scoped Matrix +abbrev Scalar := DualNumber ℂ +noncomputable def pairMatrix {ι : Type*} (A B : Matrix ι ι ℂ) : Matrix ι ι Scalar := + fun p q=>⟨A p q,B p q⟩ +lemma pairMatrix_mul {ι : Type*} [Fintype ι] (A B C D : Matrix ι ι ℂ) : + pairMatrix A B*pairMatrix C D=pairMatrix (A*C) (A*D+B*C) := by + funext p q + apply TrivSqZeroExt.ext + · simp only [Matrix.mul_apply,TrivSqZeroExt.fst_sum] + rfl + · simp only [Matrix.mul_apply,TrivSqZeroExt.snd_sum] + have hh (i : ι) : snd (pairMatrix A B p i * pairMatrix C D i q)= + A p i*D i q+B p i*C i q := by + exact DualNumber.snd_mul (R:=ℂ) (pairMatrix A B p i) (pairMatrix C D i q) + simp only [hh,Finset.sum_add_distrib] + rfl +lemma pairMatrix_transpose {ι : Type*} (A B : Matrix ι ι ℂ) : + (pairMatrix A B)ᵀ=pairMatrix (Matrix.transpose A) (Matrix.transpose B) := rfl +noncomputable def bulkJet (u : ℝ) : Matrix Pair Pair Scalar := pairMatrix (spectralR u) 0 + +noncomputable def boundaryJet (t : ℝ) : Matrix (Fin 3) (Fin 3) Scalar := + pairMatrix (boundary0 t) (boundary1 t) +noncomputable def jetSlot1 (M : Matrix (Fin 3) (Fin 3) Scalar) : Matrix Pair Pair Scalar := + fun p q=>if p.2=q.2 then M p.1 q.1 else 0 +noncomputable def jetSlot2 (M : Matrix (Fin 3) (Fin 3) Scalar) : Matrix Pair Pair Scalar := + fun p q=>if p.1=q.1 then M p.2 q.2 else 0 +lemma jetSlot1_pair (A B : Matrix (Fin 3) (Fin 3) ℂ) : + jetSlot1 (pairMatrix A B)=pairMatrix (slot1 A) (slot1 B) := by + ext p q : 2 <;> by_cases h : p.2=q.2 <;> simp [jetSlot1,slot1,pairMatrix,h] +lemma jetSlot2_pair (A B : Matrix (Fin 3) (Fin 3) ℂ) : + jetSlot2 (pairMatrix A B)=pairMatrix (slot2 A) (slot2 B) := by + ext p q : 2 <;> by_cases h : p.1=q.1 <;> simp [jetSlot2,slot2,pairMatrix,h] + +theorem source_reflection (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + bulkJet (t-y)*jetSlot1 (boundaryJet t)*(bulkJet (t+y))ᵀ*jetSlot2 (boundaryJet y)= + jetSlot2 (boundaryJet y)*bulkJet (t+y)*jetSlot1 (boundaryJet t)*(bulkJet (t-y))ᵀ := by + simp only [bulkJet,boundaryJet,jetSlot1_pair,jetSlot2_pair,pairMatrix_transpose, + Matrix.transpose_zero,pairMatrix_mul,Matrix.zero_mul,Matrix.mul_zero, + zero_add,add_zero,Matrix.add_mul] + rw [source_reflection_constant t y hm hp ht hy] + have hh := source_reflection_linear t y hm hp ht hy + rw [add_comm] at hh + rw [hh] +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection.Fusion +lemma sourceWbar_reverse (d e j : Fin 3) : + sourceWbar (e.rev,d.rev) j=sourceWbar (d,e) j.rev := by + fin_cases d <;> fin_cases e <;> fin_cases j <;> rfl +lemma sourceWbar_spin (d e j : Fin 3) (h : sourceWbar (d,e) j≠0) : + spinValue d+spinValue e=spinValue j := by + fin_cases d <;> fin_cases e <;> fin_cases j <;> + simp_all [sourceWbar,spinValue] + +lemma sourceWbar_crossing_phase (b d e j : Fin 3) : + phase^(spinValue d)*phase^(spinValue e-spinValue b)*sourceWbar (e.rev,d.rev) j= + phase^(spinValue j.rev-spinValue b)*sourceWbar (d,e) j.rev := by + rw [sourceWbar_reverse] + by_cases h : sourceWbar (d,e) j.rev=0 + · simp [h] + · have hs := sourceWbar_spin d e j.rev h + have hn : phase≠0 := point_ne_zero _ + rw [←zpow_add₀ hn] + congr 2 + omega +lemma sum_fin_rev {M : Type*} [AddCommMonoid M] (f : Fin 3→M) : + (∑ j : Fin 3,f j.rev)=∑ j : Fin 3,f j := by + exact Equiv.sum_comp Fin.revPerm f +end CriticalHoneycomb.Transfer.Reflection.Fusion + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix BigOperators +abbrev Spin3 := Fin 3 +noncomputable def boundaryVector (A : Matrix Spin3 Spin3 ℂ) (p : Pair) : ℂ := + phase^(spinValue p.2.rev)*A p.1 p.2.rev +noncomputable def crossedBC (R : Matrix Pair Pair ℂ) (A B : Matrix Spin3 Spin3 ℂ) + (i m j n : Spin3) : ℂ := + ∑ p,∑ q,R (m,j) (p,q)*boundaryVector A (i,p)*boundaryVector B (q,n) +noncomputable def crossedADt (R : Matrix Pair Pair ℂ) (A B : Matrix Spin3 Spin3 ℂ) + (i m j n : Spin3) : ℂ := + ∑ p,∑ q,R (p,q) (i,n)*boundaryVector A (p,m)*boundaryVector B (j,q) +noncomputable def unbend (V : Spin3→Spin3→Spin3→Spin3→ℂ) : Matrix Pair Pair ℂ := fun p q=> + phase^(-spinValue q.1-spinValue q.2)*V p.1 q.1.rev p.2 q.2.rev +lemma phase_cancellation (a c d : ℤ) : + phase^(-a-c)*phase^(d+a)*phase^(-d)*phase^c=1 := by + have hn : phase≠0:=point_ne_zero _ + rw [←zpow_add₀ hn,←zpow_add₀ hn,←zpow_add₀ hn] + convert zpow_zero phase using 1 ; congr 1 ; ring +lemma sandwich12 (A B : Matrix Spin3 Spin3 ℂ) (R : Matrix Pair Pair ℂ) (i j m n : Spin3) : + (slot1 A*R*slot2 B) (i,j) (m,n)= + ∑ p,∑ q,A i p*R (p,j) (m,q)*B q n := by + simp only [Matrix.mul_apply,Fintype.sum_prod_type,slot1,slot2] + simp only [ite_mul,mul_ite,zero_mul,mul_zero,Finset.mem_univ,ite_true, + Finset.sum_ite_eq,Finset.sum_mul] + simp only [Finset.sum_ite_irrel,Finset.sum_const_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rw [Finset.sum_comm] +lemma sandwich21 (A B : Matrix Spin3 Spin3 ℂ) (R : Matrix Pair Pair ℂ) (i j m n : Spin3) : + (slot2 B*R*slot1 A) (i,j) (m,n)= + ∑ p,∑ q,B j q*R (i,q) (p,n)*A p m := by + simp only [Matrix.mul_apply,Fintype.sum_prod_type,slot1,slot2] + simp only [ite_mul,mul_ite,zero_mul,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true, + Finset.sum_mul] + simp only [Finset.sum_ite_irrel,Finset.sum_const_zero,Finset.sum_ite_eq,Finset.mem_univ,ite_true] + +lemma unbend_BC (u : ℝ) (A B : Matrix Spin3 Spin3 ℂ) : + unbend (crossedBC (spectralR (b-u)) A B)=slot1 A*(spectralR u)ᵀ*slot2 B := by + ext ⟨i,j⟩ ⟨m,n⟩ + rw [sandwich12] + simp only [unbend,crossedBC,Finset.mul_sum] + rw [←CriticalHoneycomb.Transfer.Reflection.Fusion.sum_fin_rev (fun p : Spin3=> + ∑ q : Spin3,phase^(-spinValue m-spinValue n)* + (spectralR (b-u) (m.rev,j) (p,q)*boundaryVector A (i,p)*boundaryVector B (q,n.rev)))] + apply Finset.sum_congr rfl + intro p hp + apply Finset.sum_congr rfl + intro q hq + rw [source_crossing] + simp only [boundaryVector,spinValue_rev,Fin.rev_rev,Matrix.transpose_apply] + calc + _=(phase^(-spinValue m-spinValue n)*phase^(-spinValue p+spinValue m)* + phase^(spinValue p)*phase^(spinValue n))* + (A i p*spectralR u (m,q) (p,j)*B q n) := by ring_nf + _=_ := by + have hh:=phase_cancellation (spinValue m) (spinValue n) (-spinValue p) + simp only [neg_neg] at hh + rw [hh,one_mul] +lemma unbend_ADt (u : ℝ) (A B : Matrix Spin3 Spin3 ℂ) : + unbend (crossedADt (spectralR (b-u)) A B)=slot2 B*spectralR u*slot1 A := by + ext ⟨i,j⟩ ⟨m,n⟩ + rw [sandwich21] + simp only [unbend,crossedADt,Finset.mul_sum] + apply Finset.sum_congr rfl + intro p hp + rw [←CriticalHoneycomb.Transfer.Reflection.Fusion.sum_fin_rev (fun q : Spin3=> + phase^(-spinValue m-spinValue n)* + (spectralR (b-u) (p,q) (i,n.rev)*boundaryVector A (p,m.rev)*boundaryVector B (j,q)))] + apply Finset.sum_congr rfl + intro q hq + rw [source_transpose_crossing] + simp only [boundaryVector,spinValue_rev,Fin.rev_rev] + calc + _=(phase^(-spinValue m-spinValue n)*phase^(-spinValue q+spinValue n)* + phase^(spinValue q)*phase^(spinValue m))* + (B j q*spectralR u (i,q) (p,n)*A p m) := by ring_nf + _=_ := by + have hh:=phase_cancellation (spinValue n) (spinValue m) (-spinValue q) + have he : -spinValue m-spinValue n = -spinValue n-spinValue m := by ring + simp only [neg_neg] at hh + rw [he,hh,one_mul] +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix +lemma source_flip_transpose (u : ℝ) (i j k l : Fin 3) : + spectralR u (i.rev,j.rev) (k.rev,l.rev)=spectralR u (k,l) (i,j) := by + fin_cases i <;> fin_cases j <;> fin_cases k <;> fin_cases l <;> + simp [spectralR,bulkNumerator,Fin.rev] +lemma source_spin (u : ℝ) (i j k l : Fin 3) + (h : spectralR u (i,j) (k,l)≠0) : + spinValue i+spinValue j=spinValue k+spinValue l := by + fin_cases i <;> fin_cases j <;> fin_cases k <;> fin_cases l <;> + simp_all [spectralR,bulkNumerator,spinValue] +lemma source_phase_conservation (u : ℝ) (i j k l : Fin 3) : + phase^(spinValue i+spinValue j)*spectralR u (i,j) (k,l)= + phase^(spinValue k+spinValue l)*spectralR u (i,j) (k,l) := by + by_cases h : spectralR u (i,j) (k,l)=0 + · simp [h] + · rw [source_spin u i j k l h] +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix BigOperators +noncomputable def actAC (R : Matrix Pair Pair ℂ) (V : Spin3→Spin3→Spin3→Spin3→ℂ) + (i m j n : Spin3) : ℂ := ∑ p,∑ q,R (i,j) (p,q)*V p m q n +noncomputable def actBDt (R : Matrix Pair Pair ℂ) (V : Spin3→Spin3→Spin3→Spin3→ℂ) + (i m j n : Spin3) : ℂ := ∑ p,∑ q,R (p,q) (m,n)*V i p j q +lemma unbend_injective : Function.Injective unbend := by + intro V W h + funext i m j n + have hh:=congrFun (congrFun h (i,j)) (m.rev,n.rev) + simp only [unbend,Fin.rev_rev] at hh + exact mul_left_cancel₀ (zpow_ne_zero _ (point_ne_zero _)) hh +lemma unbend_add (V W : Spin3→Spin3→Spin3→Spin3→ℂ) : + unbend (V+W)=unbend V+unbend W := by + ext p q + simp [unbend,mul_add] +lemma unbend_AC (R : Matrix Pair Pair ℂ) (V : Spin3→Spin3→Spin3→Spin3→ℂ) : + unbend (actAC R V)=R*unbend V := by + ext ⟨i,j⟩ ⟨m,n⟩ + simp only [unbend,actAC,Matrix.mul_apply,Fintype.sum_prod_type,Finset.mul_sum] + apply Finset.sum_congr rfl + intro p hp + apply Finset.sum_congr rfl + intro q hq + ring +lemma unbend_BDt (u : ℝ) (V : Spin3→Spin3→Spin3→Spin3→ℂ) : + unbend (actBDt (spectralR u) V)=unbend V*(spectralR u)ᵀ := by + ext ⟨i,j⟩ ⟨m,n⟩ + simp only [unbend,actBDt,Matrix.mul_apply,Matrix.transpose_apply,Fintype.sum_prod_type, + Finset.mul_sum] + rw [←Fusion.sum_fin_rev (fun p : Spin3=>∑ q : Spin3, + phase^(-spinValue m-spinValue n)*(spectralR u (p,q) (m.rev,n.rev)*V i p j q))] + apply Finset.sum_congr rfl + intro p hp + rw [←Fusion.sum_fin_rev (fun q : Spin3=> + phase^(-spinValue m-spinValue n)*(spectralR u (p.rev,q) (m.rev,n.rev)*V i p.rev j q))] + apply Finset.sum_congr rfl + intro q hq + rw [source_flip_transpose] + by_cases h : spectralR u (m,n) (p,q)=0 + · simp [h] + · have hs:=source_spin u m n p q h + have he : -spinValue m-spinValue n = -spinValue p-spinValue q := by omega + rw [he] + ring + +theorem source_boundary_pair_constant (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + actAC (spectralR (t-y)) + (crossedBC (spectralR (b-(t+y))) (boundary0 t) (boundary0 y))= + actBDt (spectralR (t-y)) + (crossedADt (spectralR (b-(t+y))) (boundary0 t) (boundary0 y)) := by + apply unbend_injective + rw [unbend_AC,unbend_BDt,unbend_BC,unbend_ADt] + simpa only [mul_assoc] using source_reflection_constant t y hm hp ht hy + +theorem source_boundary_pair_linear (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + actAC (spectralR (t-y)) + (crossedBC (spectralR (b-(t+y))) (boundary1 t) (boundary0 y))+ + actAC (spectralR (t-y)) + (crossedBC (spectralR (b-(t+y))) (boundary0 t) (boundary1 y))= + actBDt (spectralR (t-y)) + (crossedADt (spectralR (b-(t+y))) (boundary1 t) (boundary0 y))+ + actBDt (spectralR (t-y)) + (crossedADt (spectralR (b-(t+y))) (boundary0 t) (boundary1 y)) := by + apply unbend_injective + rw [unbend_add,unbend_add,unbend_AC,unbend_AC,unbend_BDt,unbend_BDt, + unbend_BC,unbend_BC,unbend_ADt,unbend_ADt] + simpa only [mul_assoc] using source_reflection_linear t y hm hp ht hy +end CriticalHoneycomb.Transfer.Reflection + +end + +section + +namespace CriticalHoneycomb.Transfer +open scoped Matrix + +noncomputable def angle : ℝ := Real.pi / 8 +noncomputable def bigAngle : ℝ := 3 * angle +noncomputable def sine2 : ℝ := Real.sin (2 * angle) +noncomputable def denominator (u : ℝ) : ℝ := + Real.sin (2 * angle + u) * Real.sin (bigAngle + u) + +noncomputable def a (u : ℝ) : ℝ := + sine2 * Real.sin (bigAngle - u) / denominator u +noncomputable def h (u : ℝ) : ℝ := + sine2 * Real.sin u / denominator u +noncomputable def v (u : ℝ) : ℝ := + Real.sin (bigAngle - u) * Real.sin u / denominator u +noncomputable def c (u : ℝ) : ℝ := + Real.sin (bigAngle - u) * Real.sin (2 * angle - u) / denominator u +noncomputable def d (u : ℝ) : ℝ := + Real.sin u * Real.sin (u - angle) / denominator u + +noncomputable def phase : ℂ := Complex.exp ((2 * angle : ℝ) * Complex.I) + +noncomputable def blockOne (u : ℝ) : Matrix (Fin 2) (Fin 2) ℂ := + !![(v u : ℂ), (a u : ℂ); (a u : ℂ), (v u : ℂ)] + +noncomputable def blockZero (u : ℝ) : Matrix (Fin 3) (Fin 3) ℂ := + !![(d u : ℂ), (h u : ℂ) / phase, (c u : ℂ) + (d u : ℂ) / phase^2; + (h u : ℂ) * phase, 1, (h u : ℂ) / phase; + (c u : ℂ) + (d u : ℂ) * phase^2, (h u : ℂ) * phase, (d u : ℂ)] + +lemma sine_product (x u : ℝ) : + Real.sin (x+u) * Real.sin (x-u) = (Real.sin x)^2 - (Real.sin u)^2 := by + rw [Real.sin_add, Real.sin_sub] + nlinarith [Real.sin_sq_add_cos_sq x, Real.sin_sq_add_cos_sq u, + mul_nonneg (sq_nonneg (Real.sin x)) (sq_nonneg (Real.sin u))] + +lemma c_as_denominator (u : ℝ) : c u = denominator (-u) / denominator u := by + unfold c denominator + simp only [← sub_eq_add_neg] + rw [mul_comm (Real.sin (bigAngle-u))] + +lemma c_unitary (u : ℝ) (hp : denominator u ≠ 0) (hm : denominator (-u) ≠ 0) : + c u * c (-u) = 1 := by + rw [c_as_denominator, c_as_denominator, neg_neg] + field_simp + +lemma h_conjugate_c (u : ℝ) (hp : denominator u ≠ 0) (hm : denominator (-u) ≠ 0) : + h u + c u * h (-u) = 0 := by + rw [c_as_denominator] + unfold h + rw [Real.sin_neg] + field_simp + ; ring + +lemma denominator_product (u : ℝ) : + denominator u * denominator (-u) = + Real.sin (bigAngle-u) * Real.sin (bigAngle+u) * (sine2^2 - (Real.sin u)^2) := by + unfold denominator sine2 + simp only [← sub_eq_add_neg] + calc + _ = (Real.sin (2*angle+u) * Real.sin (2*angle-u)) * + (Real.sin (bigAngle-u) * Real.sin (bigAngle+u)) := by ring + _ = _ := by rw [sine_product]; ring + +lemma one_diagonal (u : ℝ) (hp : denominator u ≠ 0) (hm : denominator (-u) ≠ 0) : + v u * v (-u) + a u * a (-u) = 1 := by + unfold v a + simp only [sub_neg_eq_add, Real.sin_neg] + field_simp + nlinarith only [denominator_product u] + +lemma one_offdiagonal (u : ℝ) (hp : denominator u ≠ 0) (hm : denominator (-u) ≠ 0) : + v u * a (-u) + a u * v (-u) = 0 := by + unfold v a + simp only [sub_neg_eq_add, Real.sin_neg] + field_simp + ; ring + +lemma sin_bigAngle : Real.sin bigAngle = Real.cos angle := by + rw [show bigAngle = Real.pi/2 - angle by unfold bigAngle angle; ring, + Real.sin_pi_div_two_sub] + +lemma cos_bigAngle : Real.cos bigAngle = Real.sin angle := by + rw [show bigAngle = Real.pi/2 - angle by unfold bigAngle angle; ring, + Real.cos_pi_div_two_sub] + +lemma cos_two_angle : Real.cos (2*angle) = sine2 := by + unfold sine2 + rw [show 2*angle = Real.pi/4 by unfold angle; ring, + Real.cos_pi_div_four, Real.sin_pi_div_four] + +lemma mixed_sine_identity (u : ℝ) : + Real.sin (2*angle-u) * Real.sin (bigAngle-u) * Real.sin (u+angle) + + Real.sin (2*angle+u) * Real.sin (bigAngle+u) * Real.sin (u-angle) = + sine2^2 * Real.sin u := by + rw [Real.sin_sub, Real.sin_sub, Real.sin_add, Real.sin_add, Real.sin_add, + Real.sin_sub, sin_bigAngle, cos_bigAngle, cos_two_angle] + change (sine2 * Real.cos u - sine2 * Real.sin u) * + (Real.cos angle * Real.cos u - Real.sin angle * Real.sin u) * + (Real.sin u * Real.cos angle + Real.cos u * Real.sin angle) + + (sine2 * Real.cos u + sine2 * Real.sin u) * + (Real.cos angle * Real.cos u + Real.sin angle * Real.sin u) * + (Real.sin u * Real.cos angle - Real.cos u * Real.sin angle) = _ + have h₁ : (Real.cos angle)^2 - (Real.sin angle)^2 = sine2 := by + have hh := Real.cos_two_mul angle + rw [cos_two_angle] at hh + nlinarith only [Real.sin_sq_add_cos_sq angle, hh] + have h₂ : 2 * Real.sin angle * Real.cos angle = sine2 := (Real.sin_two_mul angle).symm + linear_combination + 2*sine2*Real.sin u*(Real.cos u)^2 * h₁ + + sine2*Real.sin u*((Real.sin u)^2-(Real.cos u)^2) * h₂ + + sine2^2*Real.sin u * Real.sin_sq_add_cos_sq u + +lemma zero_mixed (u : ℝ) (hp : denominator u ≠ 0) (hm : denominator (-u) ≠ 0) : + h u * h (-u) + c u * d (-u) + c (-u) * d u = 0 := by + unfold h c d + simp only [Real.sin_neg, sub_neg_eq_add] + rw [show -u-angle = -(u+angle) by ring, Real.sin_neg] + field_simp + have ht := mixed_sine_identity u + have ht' := congrArg (fun t : ℝ => t * Real.sin u) ht + nlinarith only [ht'] + +lemma blockOne_unitary (u : ℝ) (hp : denominator u ≠ 0) (hm : denominator (-u) ≠ 0) : + blockOne u * (blockOne (-u)).transpose = 1 := by + have hd : (v u:ℂ)*v (-u)+(a u:ℂ)*a (-u)=1 := by + exact_mod_cast one_diagonal u hp hm + have ho : (v u:ℂ)*a (-u)+(a u:ℂ)*v (-u)=0 := by + exact_mod_cast one_offdiagonal u hp hm + ext i j + fin_cases i <;> fin_cases j <;> + first + | simpa [blockOne, Matrix.mul_apply, Fin.sum_univ_two, add_comm] using hd + | simpa [blockOne, Matrix.mul_apply, Fin.sum_univ_two, add_comm] using ho + +lemma phase_sq : phase^2 = Complex.I := by + unfold phase + rw [← Complex.exp_nat_mul] + convert Complex.exp_pi_div_two_mul_I using 1 + push_cast + unfold angle + push_cast + ring_nf + +lemma phase_ne_zero : phase ≠ 0 := Complex.exp_ne_zero _ + +lemma phase_inv : phase⁻¹ = -phase * Complex.I := by + apply mul_left_cancel₀ phase_ne_zero + rw [mul_inv_cancel₀ phase_ne_zero] + calc + 1 = -phase^2 * Complex.I := by rw [phase_sq]; simp + _ = phase * (-phase * Complex.I) := by ring + +lemma blockZero_unitary (u : ℝ) (hp : denominator u ≠ 0) (hm : denominator (-u) ≠ 0) : + blockZero u * (blockZero (-u)).transpose = 1 := by + have hcc : (c u:ℂ)*c (-u)=1 := by exact_mod_cast c_unitary u hp hm + have hhc : (h u:ℂ)+(c u:ℂ)*h (-u)=0 := by exact_mod_cast h_conjugate_c u hp hm + have hhcr : (h (-u):ℂ)+(c (-u):ℂ)*h u=0 := by + have hh := h_conjugate_c (-u) hm (by simpa using hp) + simpa using congrArg (fun t : ℝ => (t:ℂ)) hh + have hmix : (h u:ℂ)*h (-u)+(c u:ℂ)*d (-u)+(c (-u):ℂ)*d u=0 := by + exact_mod_cast zero_mixed u hp hm + ext i j + fin_cases i <;> fin_cases j <;> + norm_num [blockZero, Matrix.mul_apply, Fin.sum_univ_three, div_eq_mul_inv, + inv_pow, phase_inv, phase_sq, Matrix.cons_val_two, Matrix.head_cons, Matrix.tail_cons] <;> + (try ring_nf) <;> (try simp only [phase_sq, Complex.I_sq]) <;> (try ring_nf) <;> + (try simp only [Complex.I_sq]) + all_goals first + | linear_combination hcc - Complex.I * hmix + | linear_combination hcc + Complex.I * hmix + | linear_combination hmix + | linear_combination (-phase * Complex.I) * hhc + | linear_combination (-phase * Complex.I) * hhcr + | linear_combination phase * hhc + | linear_combination phase * hhcr + +end CriticalHoneycomb.Transfer + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix +lemma angle_double : 2*Transfer.angle=Real.pi/4 := by unfold Transfer.angle;ring +lemma bigAngle_binding : Transfer.bigAngle=b := by unfold Transfer.bigAngle Transfer.angle b;ring +lemma angle_binding : Transfer.angle=L := rfl +lemma denominator_binding (u : ℝ) : (Transfer.denominator u : ℂ)=Q u := by + simp only [Transfer.denominator,angle_double,bigAngle_binding,Q,sine,Complex.ofReal_mul] +lemma phase_binding : Transfer.phase=phase := by + unfold Transfer.phase + rw [angle_double] + rfl +lemma normA (u : ℝ) : (Q u)⁻¹*coeffA u=(Transfer.a u : ℂ) := by + simp only [Transfer.a,Transfer.sine2,angle_double,bigAngle_binding,coeffA,S,sine, + Complex.ofReal_mul,Complex.ofReal_inv,denominator_binding,div_eq_mul_inv] + ring +lemma normH (u : ℝ) : (Q u)⁻¹*coeffH u=(Transfer.h u : ℂ) := by + simp only [Transfer.h,Transfer.sine2,angle_double,coeffH,S,sine, + Complex.ofReal_mul,Complex.ofReal_inv,denominator_binding,div_eq_mul_inv] + ring +lemma normV (u : ℝ) : (Q u)⁻¹*coeffV u=(Transfer.v u : ℂ) := by + simp only [Transfer.v,bigAngle_binding,coeffV,sine, + Complex.ofReal_mul,Complex.ofReal_inv,denominator_binding,div_eq_mul_inv] + ring +lemma normC (u : ℝ) : (Q u)⁻¹*coeffC u=(Transfer.c u : ℂ) := by + simp only [Transfer.c,angle_double,bigAngle_binding,coeffC,sine, + Complex.ofReal_mul,Complex.ofReal_inv,denominator_binding,div_eq_mul_inv] + ring +lemma normD (u : ℝ) : (Q u)⁻¹*coeffD u=(Transfer.d u : ℂ) := by + simp only [Transfer.d,angle_binding,coeffD,sine, + Complex.ofReal_mul,Complex.ofReal_inv,denominator_binding,div_eq_mul_inv] + ring + +noncomputable def normalizedR (u : ℝ) : Matrix Pair Pair ℂ := fun p q=> + let a := Transfer.a u + let h := Transfer.h u + let v := Transfer.v u + let c := Transfer.c u + let d := Transfer.d u + match p.1.val, p.2.val, q.1.val, q.2.val with + | 0, 0, 0, 0 => c + | 2, 2, 2, 2 => c + | 0, 1, 0, 1 => v + | 1, 0, 1, 0 => v + | 2, 1, 2, 1 => v + | 1, 2, 1, 2 => v + | 0, 1, 1, 0 => a + | 1, 0, 0, 1 => a + | 2, 1, 1, 2 => a + | 1, 2, 2, 1 => a + | 0, 2, 0, 2 => d + | 0, 2, 1, 1 => h/Transfer.phase + | 0, 2, 2, 0 => c+d/Transfer.phase^2 + | 1, 1, 0, 2 => h*Transfer.phase + | 1, 1, 1, 1 => 1 + | 1, 1, 2, 0 => h/Transfer.phase + | 2, 0, 0, 2 => c+d*Transfer.phase^2 + | 2, 0, 1, 1 => h*Transfer.phase + | 2, 0, 2, 0 => d + | _, _, _, _ => 0 + +private lemma unitarityNormalization00 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (0,0) (c,d)=normalizedR u (0,0) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normC u,] +private lemma unitarityNormalization01 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (0,1) (c,d)=normalizedR u (0,1) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normA u,←normV u, + ] +private lemma unitarityNormalization02 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (0,2) (c,d)=normalizedR u (0,2) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normH u,←normC u,←normD u,phase_binding,div_eq_mul_inv] <;> ring +private lemma unitarityNormalization10 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (1,0) (c,d)=normalizedR u (1,0) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normA u,←normV u, + ] +private lemma unitarityNormalization11 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (1,1) (c,d)=normalizedR u (1,1) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normH u,phase_binding,div_eq_mul_inv,he] <;> ring +private lemma unitarityNormalization12 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (1,2) (c,d)=normalizedR u (1,2) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normA u,←normV u, + ] +private lemma unitarityNormalization20 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (2,0) (c,d)=normalizedR u (2,0) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normH u,←normC u,←normD u,phase_binding,] <;> ring +private lemma unitarityNormalization21 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (2,1) (c,d)=normalizedR u (2,1) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normA u,←normV u, + ] +private lemma unitarityNormalization22 (u : ℝ) (hQ : Q u≠0) (c d : Fin 3) : + spectralR u (2,2) (c,d)=normalizedR u (2,2) (c,d) := by + have he : (Q u)⁻¹*Q u=1 := inv_mul_cancel₀ hQ + fin_cases c <;> fin_cases d <;> + simp [spectralR,bulkNumerator,normalizedR,←normC u,] +lemma spectralR_normalized (u : ℝ) (hQ : Q u≠0) : spectralR u=normalizedR u := by + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b + · exact unitarityNormalization00 u hQ c d + · exact unitarityNormalization01 u hQ c d + · exact unitarityNormalization02 u hQ c d + · exact unitarityNormalization10 u hQ c d + · exact unitarityNormalization11 u hQ c d + · exact unitarityNormalization12 u hQ c d + · exact unitarityNormalization20 u hQ c d + · exact unitarityNormalization21 u hQ c d + · exact unitarityNormalization22 u hQ c d +private lemma unitarityUnitary0000 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (0,0)= + (1:Matrix Pair Pair ℂ) (0,0) (0,0) := by + have hh : (Transfer.c u:ℂ)*Transfer.c (-u)=1 := by + exact_mod_cast Transfer.c_unitary u hp hm + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary0001 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (0,1)= + (1:Matrix Pair Pair ℂ) (0,0) (0,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0002 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (0,2)= + (1:Matrix Pair Pair ℂ) (0,0) (0,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0010 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (1,0)= + (1:Matrix Pair Pair ℂ) (0,0) (1,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0011 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (1,1)= + (1:Matrix Pair Pair ℂ) (0,0) (1,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0012 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (1,2)= + (1:Matrix Pair Pair ℂ) (0,0) (1,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0020 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (2,0)= + (1:Matrix Pair Pair ℂ) (0,0) (2,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0021 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (2,1)= + (1:Matrix Pair Pair ℂ) (0,0) (2,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0022 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (2,2)= + (1:Matrix Pair Pair ℂ) (0,0) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary00 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (0,0) (c,d)= + (1:Matrix Pair Pair ℂ) (0,0) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary0000 u hp hm + · exact unitarityUnitary0001 u hp hm + · exact unitarityUnitary0002 u hp hm + · exact unitarityUnitary0010 u hp hm + · exact unitarityUnitary0011 u hp hm + · exact unitarityUnitary0012 u hp hm + · exact unitarityUnitary0020 u hp hm + · exact unitarityUnitary0021 u hp hm + · exact unitarityUnitary0022 u hp hm + +private lemma unitarityUnitary0100 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (0,0)= + (1:Matrix Pair Pair ℂ) (0,1) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0101 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (0,1)= + (1:Matrix Pair Pair ℂ) (0,1) (0,1) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (0:Fin 2)) (0:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary0102 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (0,2)= + (1:Matrix Pair Pair ℂ) (0,1) (0,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0110 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (1,0)= + (1:Matrix Pair Pair ℂ) (0,1) (1,0) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (0:Fin 2)) (1:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary0111 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (1,1)= + (1:Matrix Pair Pair ℂ) (0,1) (1,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0112 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (1,2)= + (1:Matrix Pair Pair ℂ) (0,1) (1,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0120 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (2,0)= + (1:Matrix Pair Pair ℂ) (0,1) (2,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0121 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (2,1)= + (1:Matrix Pair Pair ℂ) (0,1) (2,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0122 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (2,2)= + (1:Matrix Pair Pair ℂ) (0,1) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary01 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (0,1) (c,d)= + (1:Matrix Pair Pair ℂ) (0,1) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary0100 u hp hm + · exact unitarityUnitary0101 u hp hm + · exact unitarityUnitary0102 u hp hm + · exact unitarityUnitary0110 u hp hm + · exact unitarityUnitary0111 u hp hm + · exact unitarityUnitary0112 u hp hm + · exact unitarityUnitary0120 u hp hm + · exact unitarityUnitary0121 u hp hm + · exact unitarityUnitary0122 u hp hm + +private lemma unitarityUnitary0200 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (0,0)= + (1:Matrix Pair Pair ℂ) (0,2) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0201 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (0,1)= + (1:Matrix Pair Pair ℂ) (0,2) (0,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0202 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (0,2)= + (1:Matrix Pair Pair ℂ) (0,2) (0,2) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (0:Fin 3)) (0:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary0210 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (1,0)= + (1:Matrix Pair Pair ℂ) (0,2) (1,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0211 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (1,1)= + (1:Matrix Pair Pair ℂ) (0,2) (1,1) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (0:Fin 3)) (1:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary0212 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (1,2)= + (1:Matrix Pair Pair ℂ) (0,2) (1,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0220 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (2,0)= + (1:Matrix Pair Pair ℂ) (0,2) (2,0) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (0:Fin 3)) (2:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary0221 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (2,1)= + (1:Matrix Pair Pair ℂ) (0,2) (2,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary0222 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (2,2)= + (1:Matrix Pair Pair ℂ) (0,2) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary02 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (0,2) (c,d)= + (1:Matrix Pair Pair ℂ) (0,2) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary0200 u hp hm + · exact unitarityUnitary0201 u hp hm + · exact unitarityUnitary0202 u hp hm + · exact unitarityUnitary0210 u hp hm + · exact unitarityUnitary0211 u hp hm + · exact unitarityUnitary0212 u hp hm + · exact unitarityUnitary0220 u hp hm + · exact unitarityUnitary0221 u hp hm + · exact unitarityUnitary0222 u hp hm + +private lemma unitarityUnitary1000 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (0,0)= + (1:Matrix Pair Pair ℂ) (1,0) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1001 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (0,1)= + (1:Matrix Pair Pair ℂ) (1,0) (0,1) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (1:Fin 2)) (0:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary1002 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (0,2)= + (1:Matrix Pair Pair ℂ) (1,0) (0,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1010 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (1,0)= + (1:Matrix Pair Pair ℂ) (1,0) (1,0) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (1:Fin 2)) (1:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary1011 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (1,1)= + (1:Matrix Pair Pair ℂ) (1,0) (1,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1012 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (1,2)= + (1:Matrix Pair Pair ℂ) (1,0) (1,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1020 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (2,0)= + (1:Matrix Pair Pair ℂ) (1,0) (2,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1021 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (2,1)= + (1:Matrix Pair Pair ℂ) (1,0) (2,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1022 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (2,2)= + (1:Matrix Pair Pair ℂ) (1,0) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary10 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (1,0) (c,d)= + (1:Matrix Pair Pair ℂ) (1,0) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary1000 u hp hm + · exact unitarityUnitary1001 u hp hm + · exact unitarityUnitary1002 u hp hm + · exact unitarityUnitary1010 u hp hm + · exact unitarityUnitary1011 u hp hm + · exact unitarityUnitary1012 u hp hm + · exact unitarityUnitary1020 u hp hm + · exact unitarityUnitary1021 u hp hm + · exact unitarityUnitary1022 u hp hm + +private lemma unitarityUnitary1100 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (0,0)= + (1:Matrix Pair Pair ℂ) (1,1) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1101 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (0,1)= + (1:Matrix Pair Pair ℂ) (1,1) (0,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1102 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (0,2)= + (1:Matrix Pair Pair ℂ) (1,1) (0,2) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (1:Fin 3)) (0:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary1110 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (1,0)= + (1:Matrix Pair Pair ℂ) (1,1) (1,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1111 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (1,1)= + (1:Matrix Pair Pair ℂ) (1,1) (1,1) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (1:Fin 3)) (1:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary1112 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (1,2)= + (1:Matrix Pair Pair ℂ) (1,1) (1,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1120 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (2,0)= + (1:Matrix Pair Pair ℂ) (1,1) (2,0) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (1:Fin 3)) (2:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary1121 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (2,1)= + (1:Matrix Pair Pair ℂ) (1,1) (2,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1122 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (2,2)= + (1:Matrix Pair Pair ℂ) (1,1) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary11 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (1,1) (c,d)= + (1:Matrix Pair Pair ℂ) (1,1) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary1100 u hp hm + · exact unitarityUnitary1101 u hp hm + · exact unitarityUnitary1102 u hp hm + · exact unitarityUnitary1110 u hp hm + · exact unitarityUnitary1111 u hp hm + · exact unitarityUnitary1112 u hp hm + · exact unitarityUnitary1120 u hp hm + · exact unitarityUnitary1121 u hp hm + · exact unitarityUnitary1122 u hp hm + +private lemma unitarityUnitary1200 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (0,0)= + (1:Matrix Pair Pair ℂ) (1,2) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1201 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (0,1)= + (1:Matrix Pair Pair ℂ) (1,2) (0,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1202 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (0,2)= + (1:Matrix Pair Pair ℂ) (1,2) (0,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1210 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (1,0)= + (1:Matrix Pair Pair ℂ) (1,2) (1,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1211 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (1,1)= + (1:Matrix Pair Pair ℂ) (1,2) (1,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1212 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (1,2)= + (1:Matrix Pair Pair ℂ) (1,2) (1,2) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (0:Fin 2)) (0:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary1220 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (2,0)= + (1:Matrix Pair Pair ℂ) (1,2) (2,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary1221 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (2,1)= + (1:Matrix Pair Pair ℂ) (1,2) (2,1) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (0:Fin 2)) (1:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary1222 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (2,2)= + (1:Matrix Pair Pair ℂ) (1,2) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary12 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (1,2) (c,d)= + (1:Matrix Pair Pair ℂ) (1,2) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary1200 u hp hm + · exact unitarityUnitary1201 u hp hm + · exact unitarityUnitary1202 u hp hm + · exact unitarityUnitary1210 u hp hm + · exact unitarityUnitary1211 u hp hm + · exact unitarityUnitary1212 u hp hm + · exact unitarityUnitary1220 u hp hm + · exact unitarityUnitary1221 u hp hm + · exact unitarityUnitary1222 u hp hm + +private lemma unitarityUnitary2000 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (0,0)= + (1:Matrix Pair Pair ℂ) (2,0) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2001 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (0,1)= + (1:Matrix Pair Pair ℂ) (2,0) (0,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2002 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (0,2)= + (1:Matrix Pair Pair ℂ) (2,0) (0,2) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (2:Fin 3)) (0:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary2010 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (1,0)= + (1:Matrix Pair Pair ℂ) (2,0) (1,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2011 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (1,1)= + (1:Matrix Pair Pair ℂ) (2,0) (1,1) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (2:Fin 3)) (1:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary2012 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (1,2)= + (1:Matrix Pair Pair ℂ) (2,0) (1,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2020 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (2,0)= + (1:Matrix Pair Pair ℂ) (2,0) (2,0) := by + have hh := congrFun (congrFun (Transfer.blockZero_unitary u hp hm) (2:Fin 3)) (2:Fin 3) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary2021 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (2,1)= + (1:Matrix Pair Pair ℂ) (2,0) (2,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2022 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (2,2)= + (1:Matrix Pair Pair ℂ) (2,0) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary20 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (2,0) (c,d)= + (1:Matrix Pair Pair ℂ) (2,0) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary2000 u hp hm + · exact unitarityUnitary2001 u hp hm + · exact unitarityUnitary2002 u hp hm + · exact unitarityUnitary2010 u hp hm + · exact unitarityUnitary2011 u hp hm + · exact unitarityUnitary2012 u hp hm + · exact unitarityUnitary2020 u hp hm + · exact unitarityUnitary2021 u hp hm + · exact unitarityUnitary2022 u hp hm + +private lemma unitarityUnitary2100 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (0,0)= + (1:Matrix Pair Pair ℂ) (2,1) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2101 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (0,1)= + (1:Matrix Pair Pair ℂ) (2,1) (0,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2102 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (0,2)= + (1:Matrix Pair Pair ℂ) (2,1) (0,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2110 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (1,0)= + (1:Matrix Pair Pair ℂ) (2,1) (1,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2111 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (1,1)= + (1:Matrix Pair Pair ℂ) (2,1) (1,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2112 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (1,2)= + (1:Matrix Pair Pair ℂ) (2,1) (1,2) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (1:Fin 2)) (0:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary2120 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (2,0)= + (1:Matrix Pair Pair ℂ) (2,1) (2,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2121 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (2,1)= + (1:Matrix Pair Pair ℂ) (2,1) (2,1) := by + have hh := congrFun (congrFun (Transfer.blockOne_unitary u hp hm) (1:Fin 2)) (1:Fin 2) + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary2122 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (2,2)= + (1:Matrix Pair Pair ℂ) (2,1) (2,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary21 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (2,1) (c,d)= + (1:Matrix Pair Pair ℂ) (2,1) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary2100 u hp hm + · exact unitarityUnitary2101 u hp hm + · exact unitarityUnitary2102 u hp hm + · exact unitarityUnitary2110 u hp hm + · exact unitarityUnitary2111 u hp hm + · exact unitarityUnitary2112 u hp hm + · exact unitarityUnitary2120 u hp hm + · exact unitarityUnitary2121 u hp hm + · exact unitarityUnitary2122 u hp hm + +private lemma unitarityUnitary2200 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (0,0)= + (1:Matrix Pair Pair ℂ) (2,2) (0,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2201 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (0,1)= + (1:Matrix Pair Pair ℂ) (2,2) (0,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2202 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (0,2)= + (1:Matrix Pair Pair ℂ) (2,2) (0,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2210 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (1,0)= + (1:Matrix Pair Pair ℂ) (2,2) (1,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2211 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (1,1)= + (1:Matrix Pair Pair ℂ) (2,2) (1,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2212 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (1,2)= + (1:Matrix Pair Pair ℂ) (2,2) (1,2) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2220 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (2,0)= + (1:Matrix Pair Pair ℂ) (2,2) (2,0) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2221 (u : ℝ) (_hp : Transfer.denominator u≠0) + (_hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (2,1)= + (1:Matrix Pair Pair ℂ) (2,2) (2,1) := by + simp [normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,] + +private lemma unitarityUnitary2222 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (2,2)= + (1:Matrix Pair Pair ℂ) (2,2) (2,2) := by + have hh : (Transfer.c u:ℂ)*Transfer.c (-u)=1 := by + exact_mod_cast Transfer.c_unitary u hp hm + simpa [Matrix.one_apply,normalizedR,Matrix.mul_apply,Fintype.sum_prod_type,Fin.sum_univ_three,Fin.sum_univ_two,Transfer.blockOne,Transfer.blockZero] using hh + +private lemma unitarityUnitary22 (u : ℝ) (hp : Transfer.denominator u≠0) + (hm : Transfer.denominator (-u)≠0) (c d : Fin 3) : + (normalizedR u*(normalizedR (-u)).transpose) (2,2) (c,d)= + (1:Matrix Pair Pair ℂ) (2,2) (c,d) := by + fin_cases c <;> fin_cases d + · exact unitarityUnitary2200 u hp hm + · exact unitarityUnitary2201 u hp hm + · exact unitarityUnitary2202 u hp hm + · exact unitarityUnitary2210 u hp hm + · exact unitarityUnitary2211 u hp hm + · exact unitarityUnitary2212 u hp hm + · exact unitarityUnitary2220 u hp hm + · exact unitarityUnitary2221 u hp hm + · exact unitarityUnitary2222 u hp hm +theorem spectral_unitarity (u : ℝ) (hp : Q u≠0) (hm : Q (-u)≠0) : + spectralR u*(spectralR (-u)).transpose=1 := by + rw [spectralR_normalized u hp,spectralR_normalized (-u) hm] + have hpr : Transfer.denominator u≠0 := by + intro h;apply hp;rw [←denominator_binding,h];simp + have hmr : Transfer.denominator (-u)≠0 := by + intro h;apply hm;rw [←denominator_binding,h];simp + ext ⟨a,b⟩ ⟨c,d⟩ + fin_cases a <;> fin_cases b + · exact unitarityUnitary00 u hpr hmr c d + · exact unitarityUnitary01 u hpr hmr c d + · exact unitarityUnitary02 u hpr hmr c d + · exact unitarityUnitary10 u hpr hmr c d + · exact unitarityUnitary11 u hpr hmr c d + · exact unitarityUnitary12 u hpr hmr c d + · exact unitarityUnitary20 u hpr hmr c d + · exact unitarityUnitary21 u hpr hmr c d + · exact unitarityUnitary22 u hpr hmr c d +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix BigOperators +abbrev FourVector := Spin3→Spin3→Spin3→Spin3→ℂ +noncomputable def actAD (R : Matrix Pair Pair ℂ) (V : FourVector) + (i m j n : Spin3) : ℂ := (R*ᵥ(fun p : Pair=>V p.1 m j p.2)) (i,n) +noncomputable def actBD (R : Matrix Pair Pair ℂ) (V : FourVector) + (i m j n : Spin3) : ℂ := (R*ᵥ(fun p : Pair=>V i p.1 j p.2)) (m,n) +noncomputable def actBC (R : Matrix Pair Pair ℂ) (V : FourVector) + (i m j n : Spin3) : ℂ := (R*ᵥ(fun p : Pair=>V i p.1 p.2 n)) (m,j) +noncomputable def pairVector (A B : Matrix Spin3 Spin3 ℂ) : FourVector := + fun i m j n=>boundaryVector A (i,m)*boundaryVector B (j,n) +lemma actBD_transpose (R : Matrix Pair Pair ℂ) (V : FourVector) : + actBD Rᵀ V=actBDt R V := by + funext i m j n + simp only [actBD,actBDt,Matrix.mulVec,dotProduct,Fintype.sum_prod_type,Matrix.transpose_apply] +lemma BC_pairVector (R : Matrix Pair Pair ℂ) (A B : Matrix Spin3 Spin3 ℂ) : + actBC R (pairVector A B)=crossedBC R A B := by + funext i m j n + simp only [actBC,crossedBC,pairVector,Matrix.mulVec,dotProduct,Fintype.sum_prod_type,mul_assoc] +lemma ADt_pairVector (R : Matrix Pair Pair ℂ) (A B : Matrix Spin3 Spin3 ℂ) : + actAD Rᵀ (pairVector A B)=crossedADt R A B := by + funext i m j n + simp only [actAD,crossedADt,pairVector,Matrix.mulVec,dotProduct,Fintype.sum_prod_type, + Matrix.transpose_apply,mul_assoc] +lemma actAD_comp (R S : Matrix Pair Pair ℂ) (V : FourVector) : + actAD R (actAD S V)=actAD (R*S) V := by + funext i m j n + exact congrFun (Matrix.mulVec_mulVec (fun p : Pair=>V p.1 m j p.2) R S) (i,n) +lemma actBD_comp (R S : Matrix Pair Pair ℂ) (V : FourVector) : + actBD R (actBD S V)=actBD (R*S) V := by + funext i m j n + exact congrFun (Matrix.mulVec_mulVec (fun p : Pair=>V i p.1 j p.2) R S) (m,n) +lemma actAD_one (V : FourVector) : actAD 1 V=V := by + funext i m j n + simp [actAD] +lemma actBD_one (V : FourVector) : actBD 1 V=V := by + funext i m j n + simp [actBD] +lemma actAD_add (R : Matrix Pair Pair ℂ) (V W : FourVector) : + actAD R (V+W)=actAD R V+actAD R W := by + funext i m j n + simp [actAD,Matrix.mulVec,dotProduct,mul_add,Finset.sum_add_distrib] +lemma actBD_add (R : Matrix Pair Pair ℂ) (V W : FourVector) : + actBD R (V+W)=actBD R V+actBD R W := by + funext i m j n + simp [actBD,Matrix.mulVec,dotProduct,mul_add,Finset.sum_add_distrib] +lemma actBC_add (R : Matrix Pair Pair ℂ) (V W : FourVector) : + actBC R (V+W)=actBC R V+actBC R W := by + funext i m j n + simp [actBC,Matrix.mulVec,dotProduct,mul_add,Finset.sum_add_distrib] +lemma actAC_add (R : Matrix Pair Pair ℂ) (V W : FourVector) : + actAC R (V+W)=actAC R V+actAC R W := by + funext i m j n + simp [actAC,mul_add,Finset.sum_add_distrib] + +noncomputable def fourExchanges (t y : ℝ) (V : FourVector) : FourVector := + actAD (spectralR (-(b-(t+y)))) + (actBD (spectralR (-(t-y))) + (actAC (spectralR (t-y)) (actBC (spectralR (b-(t+y))) V))) + +theorem source_boundary_invariant_constant (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + fourExchanges t y (pairVector (boundary0 t) (boundary0 y))=pairVector (boundary0 t) (boundary0 y) := by + have hU₁ : spectralR (-(t-y))*(spectralR (t-y))ᵀ=1 := by + simpa only [neg_neg] using spectral_unitarity (-(t-y)) hnm (by simpa only [neg_neg] using hm) + have hU₂ : spectralR (-(b-(t+y)))*(spectralR (b-(t+y)))ᵀ=1 := by + simpa only [neg_neg] using spectral_unitarity (-(b-(t+y))) hnp + (by simpa only [neg_neg,reflected_Q] using hp) + have hI : actAC (spectralR (t-y)) (actBC (spectralR (b-(t+y))) (pairVector (boundary0 t) (boundary0 y)))= + actBD (spectralR (t-y))ᵀ (actAD (spectralR (b-(t+y)))ᵀ (pairVector (boundary0 t) (boundary0 y))) := by + simpa only [actBC_add,actAC_add,actAD_add,actBD_add,BC_pairVector, + ADt_pairVector,actBD_transpose] using source_boundary_pair_constant t y hm hp ht hy + unfold fourExchanges + rw [hI,actBD_comp,hU₁,actBD_one,actAD_comp,hU₂,actAD_one] + +theorem source_boundary_invariant_linear (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + fourExchanges t y (pairVector (boundary1 t) (boundary0 y)+pairVector (boundary0 t) (boundary1 y))=(pairVector (boundary1 t) (boundary0 y)+pairVector (boundary0 t) (boundary1 y)) := by + have hU₁ : spectralR (-(t-y))*(spectralR (t-y))ᵀ=1 := by + simpa only [neg_neg] using spectral_unitarity (-(t-y)) hnm (by simpa only [neg_neg] using hm) + have hU₂ : spectralR (-(b-(t+y)))*(spectralR (b-(t+y)))ᵀ=1 := by + simpa only [neg_neg] using spectral_unitarity (-(b-(t+y))) hnp + (by simpa only [neg_neg,reflected_Q] using hp) + have hI : actAC (spectralR (t-y)) (actBC (spectralR (b-(t+y))) (pairVector (boundary1 t) (boundary0 y)+pairVector (boundary0 t) (boundary1 y)))= + actBD (spectralR (t-y))ᵀ (actAD (spectralR (b-(t+y)))ᵀ (pairVector (boundary1 t) (boundary0 y)+pairVector (boundary0 t) (boundary1 y))) := by + simpa only [actBC_add,actAC_add,actAD_add,actBD_add,BC_pairVector, + ADt_pairVector,actBD_transpose] using source_boundary_pair_linear t y hm hp ht hy + unfold fourExchanges + rw [hI,actBD_comp,hU₁,actBD_one,actAD_comp,hU₂,actAD_one] +end CriticalHoneycomb.Transfer.Reflection + +end + +section +namespace CriticalHoneycomb.Transfer.Reflection +open scoped Matrix BigOperators +noncomputable def pair4 (V W : FourVector) : ℂ := + ∑ i,∑ m,∑ j,∑ n,V i m j n*W i m j n +lemma pair4_AD (V W : FourVector) : pair4 V W= + ∑ m,∑ j,(fun p : Pair=>V p.1 m j p.2) ⬝ᵥ (fun p : Pair=>W p.1 m j p.2) := by + simp only [pair4,dotProduct,Fintype.sum_prod_type] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl;intro m hm + rw [Finset.sum_comm] +lemma pair4_BD (V W : FourVector) : pair4 V W= + ∑ i,∑ j,(fun p : Pair=>V i p.1 j p.2) ⬝ᵥ (fun p : Pair=>W i p.1 j p.2) := by + simp only [pair4,dotProduct,Fintype.sum_prod_type] + apply Finset.sum_congr rfl;intro i hi + rw [Finset.sum_comm] +lemma pair4_AC (V W : FourVector) : pair4 V W= + ∑ m,∑ n,(fun p : Pair=>V p.1 m p.2 n) ⬝ᵥ (fun p : Pair=>W p.1 m p.2 n) := by + simp only [pair4,dotProduct,Fintype.sum_prod_type] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl;intro m hm + simp_rw [Finset.sum_comm (s:=Finset.univ) (t:=Finset.univ) (f:=fun j n : Spin3=> V _ m j n*W _ m j n)] + rw [Finset.sum_comm] +lemma pair4_BC (V W : FourVector) : pair4 V W= + ∑ i,∑ n,(fun p : Pair=>V i p.1 p.2 n) ⬝ᵥ (fun p : Pair=>W i p.1 p.2 n) := by + simp only [pair4,dotProduct,Fintype.sum_prod_type] + apply Finset.sum_congr rfl;intro i hi + simp_rw [Finset.sum_comm (s:=Finset.univ) (t:=Finset.univ) (f:=fun j n : Spin3=> V i _ j n*W i _ j n)] + rw [Finset.sum_comm] +lemma dot_pair_cancel (R S : Matrix Pair Pair ℂ) (h : Rᵀ*S=1) (x y : Pair→ℂ) : + (R*ᵥx) ⬝ᵥ (S*ᵥy)=x ⬝ᵥ y := by + rw [Matrix.dotProduct_mulVec,←Matrix.vecMul_transpose,Matrix.vecMul_vecMul,h,Matrix.vecMul_one] +lemma pair4_AD_cancel (R S : Matrix Pair Pair ℂ) (h : Rᵀ*S=1) (V W : FourVector) : + pair4 (actAD R V) (actAD S W)=pair4 V W := by + rw [pair4_AD,pair4_AD] + apply Finset.sum_congr rfl;intro m hm + apply Finset.sum_congr rfl;intro j hj + exact dot_pair_cancel R S h _ _ +lemma pair4_BD_cancel (R S : Matrix Pair Pair ℂ) (h : Rᵀ*S=1) (V W : FourVector) : + pair4 (actBD R V) (actBD S W)=pair4 V W := by + rw [pair4_BD,pair4_BD] + apply Finset.sum_congr rfl;intro i hi + apply Finset.sum_congr rfl;intro j hj + exact dot_pair_cancel R S h _ _ +lemma pair4_AC_cancel (R S : Matrix Pair Pair ℂ) (h : Rᵀ*S=1) (V W : FourVector) : + pair4 (actAC R V) (actAC S W)=pair4 V W := by + rw [pair4_AC,pair4_AC] + apply Finset.sum_congr rfl;intro m hm + apply Finset.sum_congr rfl;intro n hn + simpa only [Matrix.mulVec,dotProduct,Fintype.sum_prod_type,actAC] using dot_pair_cancel R S h + (fun p : Pair=>V p.1 m p.2 n) (fun p : Pair=>W p.1 m p.2 n) +lemma pair4_BC_cancel (R S : Matrix Pair Pair ℂ) (h : Rᵀ*S=1) (V W : FourVector) : + pair4 (actBC R V) (actBC S W)=pair4 V W := by + rw [pair4_BC,pair4_BC] + apply Finset.sum_congr rfl;intro i hi + apply Finset.sum_congr rfl;intro n hn + exact dot_pair_cancel R S h _ _ +lemma spectral_transpose_unitarity (u : ℝ) (hu : Q u≠0) (hn : Q (-u)≠0) : + (spectralR (-u))ᵀ*spectralR u=1 := + mul_eq_one_comm.mp (spectral_unitarity u hu hn) + +theorem four_exchanges_pair (t y : ℝ) (V W : FourVector) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) : + pair4 (fourExchanges (b-t) (b-y) V) (fourExchanges t y W)=pair4 V W := by + have e₁ : (b-t)-(b-y)=-(t-y) := by ring + have e₂ : b-((b-t)+(b-y))=-(b-(t+y)) := by ring + have hp' : Q (b-(t+y))≠0 := by simpa only [reflected_Q] using hp + simp only [fourExchanges,e₁,e₂,neg_neg] + rw [pair4_AD_cancel _ _ (by simpa only [neg_neg] using spectral_transpose_unitarity (-(b-(t+y))) hnp (by simpa only [neg_neg] using hp')), + pair4_BD_cancel _ _ (by simpa only [neg_neg] using spectral_transpose_unitarity (-(t-y)) hnm (by simpa only [neg_neg] using hm)), + pair4_AC_cancel _ _ (spectral_transpose_unitarity (t-y) hm hnm), + pair4_BC_cancel _ _ (spectral_transpose_unitarity (b-(t+y)) hp' hnp)] + +theorem source_left_covector_constant (t y : ℝ) (W : FourVector) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+(b-t))≠0) (hy : sine (gamma+(b-y))≠0) : + pair4 (pairVector (boundary0 (b-t)) (boundary0 (b-y))) (fourExchanges t y W)=pair4 (pairVector (boundary0 (b-t)) (boundary0 (b-y))) W := by + have e₁ : (b-t)-(b-y)=-(t-y) := by ring + have e₂ : b-((b-t)+(b-y))=-(b-(t+y)) := by ring + have hsum : Q ((b-t)+(b-y))≠0 := by + rw [←reflected_Q ((b-t)+(b-y)),e₂] + exact hnp + have hn : Q (-(b-((b-t)+(b-y))))≠0 := by + simpa only [e₂,neg_neg,reflected_Q] using hp + have hleft:=source_boundary_invariant_constant (b-t) (b-y) + (by simpa only [e₁] using hnm) hsum + (by simpa only [e₁,neg_neg] using hm) hn ht hy + have h:=four_exchanges_pair t y (pairVector (boundary0 (b-t)) (boundary0 (b-y))) W hm hp hnm hnp + rw [hleft] at h + exact h + +theorem source_left_covector_linear (t y : ℝ) (W : FourVector) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+(b-t))≠0) (hy : sine (gamma+(b-y))≠0) : + pair4 ((pairVector (boundary1 (b-t)) (boundary0 (b-y))+pairVector (boundary0 (b-t)) (boundary1 (b-y)))) (fourExchanges t y W)=pair4 ((pairVector (boundary1 (b-t)) (boundary0 (b-y))+pairVector (boundary0 (b-t)) (boundary1 (b-y)))) W := by + have e₁ : (b-t)-(b-y)=-(t-y) := by ring + have e₂ : b-((b-t)+(b-y))=-(b-(t+y)) := by ring + have hsum : Q ((b-t)+(b-y))≠0 := by + rw [←reflected_Q ((b-t)+(b-y)),e₂] + exact hnp + have hn : Q (-(b-((b-t)+(b-y))))≠0 := by + simpa only [e₂,neg_neg,reflected_Q] using hp + have hleft:=source_boundary_invariant_linear (b-t) (b-y) + (by simpa only [e₁] using hnm) hsum + (by simpa only [e₁,neg_neg] using hm) hn ht hy + have h:=four_exchanges_pair t y ((pairVector (boundary1 (b-t)) (boundary0 (b-y))+pairVector (boundary0 (b-t)) (boundary1 (b-y)))) W hm hp hnm hnp + rw [hleft] at h + exact h +end CriticalHoneycomb.Transfer.Reflection + +end + +section + +namespace CriticalHoneycomb.Transfer.ClosedFourRow +open Reflection +open scoped Matrix BigOperators +noncomputable def flatten4 (V : FourVector) : Aux Spin3 → ℂ := + fun p => V p.1 p.2.1 p.2.2.1 p.2.2.2 +noncomputable def unflatten4 (v : Aux Spin3 → ℂ) : FourVector := + fun a b c d => v (a,b,c,d) +lemma flatten_unflatten (v : Aux Spin3 → ℂ) : flatten4 (unflatten4 v)=v := rfl +lemma flatten_add (V W : FourVector) : flatten4 (V+W)=flatten4 V+flatten4 W := rfl +lemma flattenBC (R : Matrix Pair Pair ℂ) (V : FourVector) : + auxBC R *ᵥ flatten4 V = flatten4 (actBC R V) := by + funext ⟨a,b,c,d⟩ + simp [auxBC,flatten4,actBC,Matrix.mulVec,dotProduct,Fintype.sum_prod_type, + Matrix.one_apply,mul_ite,ite_mul] +lemma flattenAC (R : Matrix Pair Pair ℂ) (V : FourVector) : + auxAC R *ᵥ flatten4 V = flatten4 (actAC R V) := by + funext ⟨a,b,c,d⟩ + simp [auxAC,flatten4,actAC,Matrix.mulVec,dotProduct,Fintype.sum_prod_type, + Matrix.one_apply,mul_ite,ite_mul] +lemma flattenBD (R : Matrix Pair Pair ℂ) (V : FourVector) : + auxBD R *ᵥ flatten4 V = flatten4 (actBD R V) := by + funext ⟨a,b,c,d⟩ + simp [auxBD,flatten4,actBD,Matrix.mulVec,dotProduct,Fintype.sum_prod_type, + Matrix.one_apply,mul_ite,ite_mul] +lemma flattenAD (R : Matrix Pair Pair ℂ) (V : FourVector) : + auxAD R *ᵥ flatten4 V = flatten4 (actAD R V) := by + funext ⟨a,b,c,d⟩ + simp [auxAD,flatten4,actAD,Matrix.mulVec,dotProduct,Fintype.sum_prod_type, + Matrix.one_apply,mul_ite,ite_mul] +noncomputable def exactTrain (t y : ℝ) : Matrix (Aux Spin3) (Aux Spin3) ℂ := + auxTrain (spectralR (b-(t+y))) (spectralR (t-y)) + (spectralR (-(t-y))) (spectralR (-(b-(t+y)))) +lemma exactTrain_action (t y : ℝ) (V : FourVector) : + exactTrain t y *ᵥ flatten4 V = flatten4 (fourExchanges t y V) := by + simp only [exactTrain,auxTrain,←Matrix.mulVec_mulVec,flattenBC,flattenAC,flattenBD, + flattenAD,fourExchanges] +lemma pair4_flatten (V W : FourVector) : + pair4 V W = flatten4 V ⬝ᵥ flatten4 W := by + simp [pair4,flatten4,dotProduct,Fintype.sum_prod_type] + +theorem exactTrain_right_constant (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + exactTrain t y *ᵥ flatten4 (pairVector (boundary0 t) (boundary0 y)) = + flatten4 (pairVector (boundary0 t) (boundary0 y)) := by + rw [exactTrain_action,source_boundary_invariant_constant t y hm hp hnm hnp ht hy] +theorem exactTrain_right_linear (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+t)≠0) (hy : sine (gamma+y)≠0) : + exactTrain t y *ᵥ flatten4 + (pairVector (boundary1 t) (boundary0 y)+pairVector (boundary0 t) (boundary1 y)) = + flatten4 (pairVector (boundary1 t) (boundary0 y)+pairVector (boundary0 t) (boundary1 y)) := by + rw [exactTrain_action,source_boundary_invariant_linear t y hm hp hnm hnp ht hy] +lemma vecMul_eq_of_pair4 (t y : ℝ) (V : FourVector) + (h : ∀ W, pair4 V (fourExchanges t y W)=pair4 V W) : + flatten4 V ᵥ* exactTrain t y = flatten4 V := by + funext p + have hh := h (unflatten4 (Pi.single p 1)) + rw [pair4_flatten,pair4_flatten,←exactTrain_action,flatten_unflatten, + Matrix.dotProduct_mulVec,dotProduct_single_one,dotProduct_single_one] at hh + exact hh + +theorem exactTrain_left_constant (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+(b-t))≠0) (hy : sine (gamma+(b-y))≠0) : + flatten4 (pairVector (boundary0 (b-t)) (boundary0 (b-y))) ᵥ* exactTrain t y = + flatten4 (pairVector (boundary0 (b-t)) (boundary0 (b-y))) := by + apply vecMul_eq_of_pair4 + intro W + exact source_left_covector_constant t y W hm hp hnm hnp ht hy +theorem exactTrain_left_linear (t y : ℝ) + (hm : Q (t-y)≠0) (hp : Q (t+y)≠0) + (hnm : Q (-(t-y))≠0) (hnp : Q (-(b-(t+y)))≠0) + (ht : sine (gamma+(b-t))≠0) (hy : sine (gamma+(b-y))≠0) : + flatten4 (pairVector (boundary1 (b-t)) (boundary0 (b-y))+ + pairVector (boundary0 (b-t)) (boundary1 (b-y))) ᵥ* exactTrain t y = + flatten4 (pairVector (boundary1 (b-t)) (boundary0 (b-y))+ + pairVector (boundary0 (b-t)) (boundary1 (b-y))) := by + apply vecMul_eq_of_pair4 + intro W + exact source_left_covector_linear t y W hm hp hnm hnp ht hy +end CriticalHoneycomb.Transfer.ClosedFourRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/StripExhaustion.lean b/lean/OAI/Combinatorics/HoneycombChords/StripExhaustion.lean new file mode 100644 index 0000000000000000000000000000000000000000..39e7446fc4858ec704c47c2fa15526dce1fde22f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/StripExhaustion.lean @@ -0,0 +1,481 @@ +import OAI.Combinatorics.HoneycombChords.BoundarySystems +import OAI.Combinatorics.HoneycombChords.Bridges + +namespace OAI + +/-! Finite rectangle exhaustion of strict honeycomb bridges. -/ + +section + +namespace CriticalHoneycomb +open scoped ENNReal + + +namespace StripExhaustion + +def turn (h : ℕ) (m : ℤ) (v : Center) : Center := + ((h:ℤ)-1-v.2.1,m-v.1,!v.2.2) +lemma turn_injective (h : ℕ) (m : ℤ) : Function.Injective (turn h m) := by + rintro ⟨x,y,b⟩ ⟨u,v,c⟩ he + simp only [turn,Prod.mk.injEq] at he ⊢ + rcases he with ⟨h₁,h₂,h₃⟩ + have hb : b=c := by simpa using congrArg Bool.not h₃ + exact ⟨by omega,by omega,hb⟩ +lemma turn_adj (h : ℕ) (m : ℤ) (v w : Center) : + Adj (turn h m v) (turn h m w) ↔ Adj v w := by + rcases v with ⟨x,y,b⟩ + rcases w with ⟨u,v,c⟩ + cases b <;> cases c <;> simp [turn,Adj] <;> omega +lemma adj_symm {v w : Center} (he : Adj v w) : Adj w v := by + rcases v with ⟨x,y,b⟩ + rcases w with ⟨u,v,c⟩ + cases b <;> cases c <;> simp_all [Adj] <;> omega +lemma reverse_chain {p : List Center} (he : p.IsChain Adj) : p.reverse.IsChain Adj := by + rw [List.isChain_reverse] + exact he.imp (fun _ _ hh=>adj_symm hh) + +noncomputable def reflected {h : ℕ} (m : ℤ) (γ : StrictBridge h) : List Center := + (γ.val.map (turn h m)).reverse +lemma reflected_injective {h : ℕ} (m : ℤ) : + Function.Injective (reflected (h:=h) m) := by + intro γ δ he + apply Subtype.ext + apply List.map_injective_iff.mpr (turn_injective h m) + simpa [reflected] using congrArg List.reverse he +lemma reflected_length {h : ℕ} (m : ℤ) (γ : StrictBridge h) : + (reflected m γ).length=γ.val.length := by simp [reflected] +lemma reflected_last {h : ℕ} (m : ℤ) (γ : StrictBridge h) : + (reflected m γ).getLast?=some (down ((h:ℤ)-1) m) := by + simp [reflected,List.head?_map,γ.property.2.1,turn,up,down] +noncomputable def terminal {h : ℕ} (γ : StrictBridge h) : ℤ := Classical.choose γ.property.2.2 +lemma terminal_last {h : ℕ} (γ : StrictBridge h) : + γ.val.getLast?=some (down (terminal γ) ((h:ℤ)-1)) := Classical.choose_spec γ.property.2.2 +lemma reflected_head {h : ℕ} (m : ℤ) (γ : StrictBridge h) : + (reflected m γ).head?=some (up 0 (m-terminal γ)) := by + simp [reflected,List.getLast?_map,terminal_last,turn,up,down] + +lemma finite_trace_bound {h : ℕ} (s : Finset (StrictBridge h)) : + ∃ M : ℕ,∀ γ∈s,∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M := by + classical + let t : Finset ℕ := s.biUnion (fun γ=>γ.val.toFinset.image (fun v=>v.1.natAbs)) + refine ⟨t.sup id,?_⟩ + intro γ hγ v hv + have ht : v.1.natAbs∈t := by + apply Finset.mem_biUnion.mpr + refine ⟨γ,hγ,?_⟩ + exact Finset.mem_image.mpr ⟨v,List.mem_toFinset.mpr hv,rfl⟩ + have hh : v.1.natAbs≤t.sup id := Finset.le_sup (f:=id) ht + have ha : -(v.1.natAbs:ℤ)≤v.1 ∧ v.1≤(v.1.natAbs:ℤ) := + by simpa only [Int.natCast_natAbs] using (abs_le.mp (le_refl |v.1|)) + omega + +lemma reflected_trace {h M : ℕ} (γ : StrictBridge h) + (hb : ∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M) : + IsTrace {v : Center | 0≤v.1 ∧ v.1(turn_adj h M _ _).mpr hh) hc + · intro v hv + rw [reflected,List.mem_reverse,List.mem_map] at hv + obtain ⟨u,hu,rfl⟩ := hv + have hur := hp u hu + have hub := hb u hu + simp only [strip,Set.mem_ofPred_eq] at hur + simp only [turn,Set.mem_ofPred_eq] + omega + +lemma terminal_bound {h M : ℕ} (γ : StrictBridge h) + (hb : ∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M) : + -(M:ℤ)≤terminal γ ∧ terminal γ≤M := by + have hm : down (terminal γ) ((h:ℤ)-1) ∈ γ.val := + List.mem_of_getLast? (terminal_last γ) + exact hb _ hm +end StripExhaustion +end CriticalHoneycomb + +namespace CriticalHoneycomb.StripExhaustion +open CriticalHoneycomb.Transfer + +noncomputable def exitIndex {h M : ℕ} (γ : StrictBridge (h+1)) + (hb : ∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M) : Fin (2*M+1) := + ⟨((M:ℤ)-terminal γ).toNat,by have hh:=terminal_bound γ hb;omega⟩ +lemma exitIndex_value {h M : ℕ} (γ : StrictBridge (h+1)) + (hb : ∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M) : + ((exitIndex γ hb).val:ℤ)=(M:ℤ)-terminal γ := by + apply Int.toNat_of_nonneg + have hh:=terminal_bound γ hb + omega + +noncomputable def reflectedChord {h M : ℕ} (γ : StrictBridge (h+1)) + (hb : ∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M) : + RasterGrid.RectChord h (2*M) (exitIndex γ hb) ⟨M,by omega⟩ := by + refine ⟨reflected M γ,?_,?_,?_⟩ + · obtain ⟨hn,hc,hp⟩ := reflected_trace γ hb + refine ⟨hn,hc,?_⟩ + intro v hv + apply (RasterGrid.mem_domain_iff v).mpr + have hh := hp v hv + simpa only [Set.mem_ofPred_eq,Nat.cast_add,Nat.cast_mul,Nat.cast_one,Nat.cast_ofNat] using hh + · rw [reflected_head] + simp only [RasterGrid.westPort,RasterGrid.cellCenter,up,Fin.val_zero,Int.natCast_zero] + rw [exitIndex_value] + · rw [reflected_last] + simp [RasterGrid.eastPort,RasterGrid.cellCenter,down] + +theorem strip_finite_sum_le (h : ℕ) (s : Finset (StrictBridge (h+1))) : + (∑ γ∈s,kappa^γ.val.length)≤1 := by + classical + obtain ⟨M,hM⟩ := finite_trace_bound s + let B := Σ j : Fin (2*M+1),RasterGrid.RectChord h (2*M) j ⟨M,by omega⟩ + let f : {γ // γ∈s} → B := fun γ => + ⟨exitIndex γ.val (hM γ.val γ.property),reflectedChord γ.val (hM γ.val γ.property)⟩ + have hi : Function.Injective f := by + intro γ δ he + have hh : reflected M γ.val=reflected M δ.val := + congrArg (fun p : B=>p.2.val) he + exact Subtype.ext (reflected_injective M hh) + have hb : (∑ p : B,kappa^p.2.val.length)≤1 := by + rw [Fintype.sum_sigma] + exact FluxWard.rectangle_actual_sum_bound h (2*M) ⟨M,by omega⟩ + calc + (∑ γ∈s,kappa^γ.val.length) = ∑ γ : {γ // γ∈s},kappa^(f γ).2.val.length := by + simp only [f,reflectedChord,reflected_length] + exact Finset.sum_subtype s (fun _=>Iff.rfl) _ + _ = ∑ p∈Finset.univ.image f,kappa^p.2.val.length := (Finset.sum_image (f:=fun p : B=>kappa^p.2.val.length) (s:=Finset.univ) hi.injOn).symm + _ ≤ ∑ p : B,kappa^p.2.val.length := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro p hp hn + exact (pow_pos FiniteContinuation.kappa_positive _).le + _ ≤ 1 := hb + +lemma real_strip_summable (h : ℕ) : + Summable (fun γ : StrictBridge (h+1)=>kappa^γ.val.length) := by + apply summable_of_sum_le (c:=1) + · intro γ + exact (pow_pos FiniteContinuation.kappa_positive _).le + · exact strip_finite_sum_le h + +lemma real_strip_tsum_le (h : ℕ) : + (∑' γ : StrictBridge (h+1),kappa^γ.val.length)≤1 := by + apply Real.tsum_le_of_sum_le + · intro γ + exact (pow_pos FiniteContinuation.kappa_positive _).le + · exact strip_finite_sum_le h + +end CriticalHoneycomb.StripExhaustion +namespace CriticalHoneycomb.StripExhaustion +open scoped ENNReal + +theorem bridgeMass_le_one (h : ℕ) : bridgeMass h≤1 := by + cases h with + | zero => simp [bridgeMass] + | succ h => + simp only [bridgeMass,Nat.add_one_ne_zero,ite_false,weight] + rw [←ENNReal.ofReal_tsum_of_nonneg] + · exact (ENNReal.ofReal_le_ofReal (real_strip_tsum_le h)).trans (by simp) + · intro γ + exact (pow_pos FiniteContinuation.kappa_positive _).le + · exact real_strip_summable h + +theorem bridgeMass_finite (h : ℕ) : bridgeMass h<⊤ := + (bridgeMass_le_one h).trans_lt (by simp) +end CriticalHoneycomb.StripExhaustion + +end + +section + +namespace CriticalHoneycomb.StripExhaustion +open Filter Topology +open CriticalHoneycomb.Transfer + +def ConfinedAt {W : ℕ} (H k : ℕ) (γ : StrictBridge (W+1)) : Prop := + ∀ v∈γ.val,(k:ℤ)-(H:ℤ)≤v.1 ∧ v.1≤k + +noncomputable instance confinedAtDecidable {W : ℕ} (H k : ℕ) (γ : StrictBridge (W+1)) : + Decidable (ConfinedAt H k γ) := Classical.propDecidable _ + +noncomputable def placements {W : ℕ} (H : ℕ) (γ : StrictBridge (W+1)) : ℝ := by + classical + exact ∑ k : Fin (H+1),if ConfinedAt H k.val γ then (1:ℝ) else 0 + +noncomputable def placementFraction {W : ℕ} (H : ℕ) (γ : StrictBridge (W+1)) : ℝ := + placements H γ/(H+1:ℕ) + +lemma placements_nonnegative {W H : ℕ} (γ : StrictBridge (W+1)) : 0≤placements H γ := by + classical + apply Finset.sum_nonneg + intro k hk + split_ifs <;> norm_num +lemma placements_le {W H : ℕ} (γ : StrictBridge (W+1)) : placements H γ≤(H+1:ℕ) := by + classical + calc + placements H γ ≤ ∑ k : Fin (H+1),(1:ℝ) := by + apply Finset.sum_le_sum + intro k hk + split_ifs <;> norm_num + _ = (H+1:ℕ) := by simp +lemma placementFraction_nonnegative {W H : ℕ} (γ : StrictBridge (W+1)) : + 0≤placementFraction H γ := div_nonneg (placements_nonnegative γ) (by positivity) +lemma placementFraction_le_one {W H : ℕ} (γ : StrictBridge (W+1)) : + placementFraction H γ≤1 := by + apply (div_le_one (by positivity : (0:ℝ)<(H+1:ℕ))).mpr + exact placements_le γ + +def interiorPlacement (H M : ℕ) (k : Fin (H+1-2*M)) : Fin (H+1) := + ⟨k.val+M,by have hk:=k.isLt;omega⟩ +lemma interiorPlacement_injective (H M : ℕ) : Function.Injective (interiorPlacement H M) := by + intro k l he + apply Fin.ext + have hh:=congrArg Fin.val he + simp only [interiorPlacement] at hh + omega +lemma interior_confined {W H M : ℕ} (γ : StrictBridge (W+1)) + (hb : ∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M) (k : Fin (H+1-2*M)) : + ConfinedAt H (interiorPlacement H M k).val γ := by + intro v hv + have hh:=hb v hv + have hk:=k.isLt + simp only [interiorPlacement] + omega + +lemma placements_lower {W H M : ℕ} (γ : StrictBridge (W+1)) + (hb : ∀ v∈γ.val,-(M:ℤ)≤v.1 ∧ v.1≤M) : + ((H+1-2*M:ℕ):ℝ)≤placements H γ := by + classical + let f := interiorPlacement H M + let g : Fin (H+1)→ℝ := fun k=>if ConfinedAt H k.val γ then 1 else 0 + calc + ((H+1-2*M:ℕ):ℝ) = ∑ k : Fin (H+1-2*M),g (f k) := by + simp only [g,f,interior_confined γ hb,ite_eq_left] + simp + _ = ∑ k∈Finset.univ.image f,g k := + (Finset.sum_image (f:=g) (s:=Finset.univ) (interiorPlacement_injective H M).injOn).symm + _ ≤ ∑ k : Fin (H+1),g k := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro k hk hn + simp only [g] + split_ifs <;> positivity + _ = placements H γ := rfl + +lemma central_fraction_limit (M : ℕ) : + Tendsto (fun H : ℕ=>((H+1-2*M:ℕ):ℝ)/(H+1:ℕ)) atTop (𝓝 1) := by + have ht : Tendsto (fun H : ℕ=>((H+1:ℕ):ℝ)) atTop atTop := + tendsto_natCast_atTop_atTop.comp (tendsto_add_atTop_nat 1) + have hh := (tendsto_const_nhds (x:=(1:ℝ))).sub (ht.const_div_atTop (2*(M:ℝ))) + have he : (fun H : ℕ=>((H+1-2*M:ℕ):ℝ)/(H+1:ℕ)) =ᶠ[atTop] + (fun H : ℕ=>(1:ℝ)-2*(M:ℝ)/(H+1:ℕ)) := by + filter_upwards [eventually_ge_atTop (2*M)] with H hH + rw [Nat.cast_sub (by omega : 2*M≤H+1)] + push_cast + field_simp + apply (show Tendsto (fun H : ℕ=>(1:ℝ)-2*(M:ℝ)/(H+1:ℕ)) atTop (𝓝 1) from by + simpa using hh).congr' he.symm + +lemma placementFraction_limit {W : ℕ} (γ : StrictBridge (W+1)) : + Tendsto (fun H : ℕ=>placementFraction H γ) atTop (𝓝 1) := by + classical + obtain ⟨M,hM⟩ := finite_trace_bound ({γ} : Finset (StrictBridge (W+1))) + have hb:=hM γ (by simp) + apply tendsto_of_tendsto_of_tendsto_of_le_of_le (central_fraction_limit M) tendsto_const_nhds + · intro H + exact div_le_div_of_nonneg_right (placements_lower γ hb) (by positivity) + · intro H + exact placementFraction_le_one γ + +noncomputable def averagingMass (W H : ℕ) : ℝ := + ∑' γ : StrictBridge (W+1),placementFraction H γ*kappa^γ.val.length + +theorem averagingMass_limit (W : ℕ) : + Tendsto (averagingMass W) atTop + (𝓝 (∑' γ : StrictBridge (W+1),kappa^γ.val.length)) := by + apply tendsto_tsum_of_dominated_convergence (real_strip_summable W) + · intro γ + simpa using (placementFraction_limit γ).mul_const (kappa^γ.val.length) + · apply Eventually.of_forall + intro H γ + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (placementFraction_nonnegative γ) + (pow_pos FiniteContinuation.kappa_positive _).le)] + exact mul_le_of_le_one_left (pow_pos FiniteContinuation.kappa_positive _).le + (placementFraction_le_one γ) +end CriticalHoneycomb.StripExhaustion + +namespace CriticalHoneycomb.StripExhaustion +open CriticalHoneycomb.Transfer + +abbrev RectAllAt (W H : ℕ) (k : Fin (H+1)) := + Σ j : Fin (H+1),RasterGrid.RectChord W H j k + +noncomputable def unplace {W H : ℕ} {k : Fin (H+1)} (γ : RectAllAt W H k) : + StrictBridge (W+1) := by + refine ⟨(γ.2.val.map (turn (k.val+1) W)).reverse,⟨?_,?_,?_⟩,?_,?_⟩ + · simpa only [List.nodup_reverse] using γ.2.property.1.1.map (turn_injective (k.val+1) W) + · apply reverse_chain + exact List.isChain_map_of_isChain _ (fun _ _ hh=>(turn_adj (k.val+1) W _ _).mpr hh) + γ.2.property.1.2.1 + · intro v hv + rw [List.mem_reverse,List.mem_map] at hv + obtain ⟨u,hu,rfl⟩ := hv + have hh := (RasterGrid.mem_domain_iff u).mp (γ.2.property.1.2.2 u hu) + simp only [strip,Set.mem_ofPred_eq,turn] + omega + · simp only [List.head?_reverse,List.getLast?_map,γ.2.property.2.2,Option.map_some] + simp [RasterGrid.eastPort,RasterGrid.cellCenter,turn,up] + · refine ⟨(k.val:ℤ)-γ.1.val,?_⟩ + simp only [List.getLast?_reverse,List.head?_map,γ.2.property.2.1,Option.map_some] + simp [RasterGrid.westPort,RasterGrid.cellCenter,turn,down] + +lemma unplace_length {W H : ℕ} {k : Fin (H+1)} (γ : RectAllAt W H k) : + (unplace γ).val.length=γ.2.val.length := by simp [unplace] +lemma unplace_confined {W H : ℕ} {k : Fin (H+1)} (γ : RectAllAt W H k) : + ConfinedAt H k.val (unplace γ) := by + intro v hv + simp only [unplace,List.mem_reverse,List.mem_map] at hv + obtain ⟨u,hu,rfl⟩ := hv + have hh := (RasterGrid.mem_domain_iff u).mp (γ.2.property.1.2.2 u hu) + simp only [turn] + omega + +lemma terminal_confined {W H k : ℕ} (γ : StrictBridge (W+1)) (hb : ConfinedAt H k γ) : + (k:ℤ)-(H:ℤ)≤terminal γ ∧ terminal γ≤k := by + have hh:=hb _ (List.mem_of_getLast? (terminal_last γ)) + exact hh + +noncomputable def exitAt {W H : ℕ} (k : Fin (H+1)) (γ : StrictBridge (W+1)) + (hb : ConfinedAt H k.val γ) : Fin (H+1) := + ⟨((k.val:ℤ)-terminal γ).toNat,by have hh:=terminal_confined γ hb;omega⟩ +lemma exitAt_value {W H : ℕ} (k : Fin (H+1)) (γ : StrictBridge (W+1)) + (hb : ConfinedAt H k.val γ) : ((exitAt k γ hb).val:ℤ)=(k.val:ℤ)-terminal γ := by + apply Int.toNat_of_nonneg + have hh:=terminal_confined γ hb + omega + +noncomputable def place {W H : ℕ} (k : Fin (H+1)) (γ : StrictBridge (W+1)) + (hb : ConfinedAt H k.val γ) : RectAllAt W H k := by + refine ⟨exitAt k γ hb,reflected k.val γ,⟨?_,?_,?_⟩,?_,?_⟩ + · simpa only [reflected,List.nodup_reverse] using γ.property.1.1.map (turn_injective (W+1) k.val) + · apply reverse_chain + exact List.isChain_map_of_isChain _ (fun _ _ hh=>(turn_adj (W+1) k.val _ _).mpr hh) + γ.property.1.2.1 + · intro v hv + rw [reflected,List.mem_reverse,List.mem_map] at hv + obtain ⟨u,hu,rfl⟩ := hv + have hh:=γ.property.1.2.2 u hu + have hbu:=hb u hu + apply (RasterGrid.mem_domain_iff _).mpr + simp only [strip,Set.mem_ofPred_eq] at hh + simp only [turn] + omega + · rw [reflected_head] + simp only [RasterGrid.westPort,RasterGrid.cellCenter,up,Fin.val_zero,Int.natCast_zero] + rw [exitAt_value] + · rw [reflected_last] + simp [RasterGrid.eastPort,RasterGrid.cellCenter,down] + +lemma turn_turn (W k : ℕ) (v : Center) : turn (k+1) W (turn (W+1) k v)=v := by + rcases v with ⟨x,y,b⟩ + simp [turn] + +lemma unplace_place {W H : ℕ} (k : Fin (H+1)) (γ : StrictBridge (W+1)) + (hb : ConfinedAt H k.val γ) : unplace (place k γ hb)=γ := by + apply Subtype.ext + simp only [unplace,place,reflected,List.map_reverse,List.reverse_reverse,List.map_map] + have he : (fun v=>turn (k.val+1) W (turn (W+1) k.val v))=id := + funext (turn_turn W k.val) + change List.map _ _ = _ + simp only [show (turn (k.val+1) W ∘ turn (W+1) k.val) = id from he,List.map_id] + +lemma rectAll_ext {W H : ℕ} {k : Fin (H+1)} (γ δ : RectAllAt W H k) + (he : γ.2.val=δ.2.val) : γ=δ := by + rcases γ with ⟨j,γ⟩;rcases δ with ⟨l,δ⟩ + have hh:=congrArg List.head? he + rw [γ.property.2.1,δ.property.2.1] at hh + have hj : j=l := by + apply Fin.ext + have hl:=congrArg (fun x : Option Center=>x.map (fun v=>v.2.1)) hh + simpa [RasterGrid.westPort,RasterGrid.cellCenter,up] using hl + subst l + have hγ : γ=δ := Subtype.ext he + subst δ + rfl + +lemma place_unplace {W H : ℕ} (k : Fin (H+1)) (γ : RectAllAt W H k) : + place k (unplace γ) (unplace_confined γ)=γ := by + apply rectAll_ext + simp only [place,reflected,unplace,List.map_reverse,List.reverse_reverse,List.map_map] + have he : (fun v=>turn (W+1) k.val (turn (k.val+1) W v))=id := + funext (turn_turn k.val W) + simp only [show (turn (W+1) k.val ∘ turn (k.val+1) W) = id from he,List.map_id] + +noncomputable def placementEquiv (W H : ℕ) (k : Fin (H+1)) : + RectAllAt W H k ≃ {γ : StrictBridge (W+1)//ConfinedAt H k.val γ} where + toFun γ := ⟨unplace γ,unplace_confined γ⟩ + invFun γ := place k γ.val γ.property + left_inv γ := place_unplace k γ + right_inv γ := by apply Subtype.ext;exact unplace_place k γ.val γ.property +end CriticalHoneycomb.StripExhaustion + +namespace CriticalHoneycomb.StripExhaustion +open Filter Topology CriticalHoneycomb.Transfer + +lemma rectangle_one_source (W H : ℕ) (k : Fin (H+1)) : + (∑ j : Fin (H+1), ∑ γ : RasterGrid.RectChord W H j k,kappa^γ.val.length) = + ∑' γ : StrictBridge (W+1),if ConfinedAt H k.val γ then kappa^γ.val.length else 0 := by + classical + have he := (placementEquiv W H k).tsum_eq + (fun γ : {γ : StrictBridge (W+1)//ConfinedAt H k.val γ}=>kappa^γ.val.val.length) + have hl (γ : RectAllAt W H k) : ((placementEquiv W H k γ).val.val).length = + γ.2.val.length := unplace_length γ + simp only [hl] at he + rw [tsum_fintype,Fintype.sum_sigma] at he + rw [he] + exact tsum_subtype {γ : StrictBridge (W+1) | ConfinedAt H k.val γ} + (fun γ : StrictBridge (W+1)=>kappa^γ.val.length) + +lemma confined_summable (W H : ℕ) (k : Fin (H+1)) : + Summable (fun γ : StrictBridge (W+1)=> + if ConfinedAt H k.val γ then kappa^γ.val.length else 0) := by + classical + exact (real_strip_summable W).indicator {γ | ConfinedAt H k.val γ} + +lemma rectangle_average_eq (W H : ℕ) : + (∑ k : Fin (H+1), ∑ j : Fin (H+1), + ∑ γ : RasterGrid.RectChord W H j k,kappa^γ.val.length)/(H+1:ℕ) = + averagingMass W H := by + classical + have he : ∀ γ : StrictBridge (W+1), + placementFraction H γ*kappa^γ.val.length = + (∑ k : Fin (H+1),if ConfinedAt H k.val γ then kappa^γ.val.length else 0)/(H+1:ℕ) := by + intro γ + rw [placementFraction,placements,div_mul_eq_mul_div,Finset.sum_mul] + congr 1 + apply Finset.sum_congr rfl + intro k hk + split_ifs <;> simp + simp only [rectangle_one_source,averagingMass,he] + rw [tsum_div_const,(Summable.tsum_finsetSum (fun k _=>confined_summable W H k))] + +theorem physical_rectangle_average_limit (W : ℕ) : + Tendsto (fun H : ℕ=> + (∑ k : Fin (H+1), ∑ j : Fin (H+1), + (RasterGrid.prescribedPartition (W+1) (H+1) + (RasterGrid.singleColumn j) (RasterGrid.singleColumn k) (fun _=>1) (fun _=>1)).re) + /(H+1:ℕ)) atTop + (𝓝 (∑' γ : StrictBridge (W+1),kappa^γ.val.length)) := by + have he : ∀ H : ℕ, (∑ k : Fin (H+1), ∑ j : Fin (H+1), + (RasterGrid.prescribedPartition (W+1) (H+1) + (RasterGrid.singleColumn j) (RasterGrid.singleColumn k) (fun _=>1) (fun _=>1)).re) + /(H+1:ℕ) = averagingMass W H := by + intro H + simp only [RasterGrid.actual_chord_sum_eq_transfer,Complex.re_sum, + ←Complex.ofReal_pow,Complex.ofReal_re] + exact rectangle_average_eq W H + simpa only [he] using averagingMass_limit W +end CriticalHoneycomb.StripExhaustion + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/StripGram.lean b/lean/OAI/Combinatorics/HoneycombChords/StripGram.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb43b4e87c375f2ddf8beb8ce829e96738841a6b --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/StripGram.lean @@ -0,0 +1,361 @@ +import OAI.Combinatorics.HoneycombChords.EntireCosine + +namespace OAI + +/-! Beta kernel moments and positive strip Gram determinants. -/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset MeasureTheory Filter Topology +noncomputable def stripDensity (p : ℝ) : ℝ := p*(2*Real.cosh (angle*p)-1)/Real.sinh (4*angle*p) +lemma stripDensity_pos {p : ℝ} (hp : 0cosineKernelJet r 0 b (p^2)*cosineKernelJet s 0 c (p^2)*stripDensity p) + (Set.Ioi 0) := by + let a := Real.sqrt (b+δ)+Real.sqrt (c+δ)+angle + have ha : 0 ≤ a := by dsimp [a];have : 0 < angle := (by unfold angle;positivity);positivity + have hi := (Analytic.polynomial_kernel_integrable 0 ha hbc).const_mul (2*δ^(-(r:ℤ))*δ^(-(s:ℤ))) + apply hi.mono' + · have hf : Continuous (fun p : ℝ=>cosineKernelJet r 0 b (p^2)) := + (cosineKernelJet_contDiff_right r 0 b 0).continuous.comp (by fun_prop) + have hg : Continuous (fun p : ℝ=>cosineKernelJet s 0 c (p^2)) := + (cosineKernelJet_contDiff_right s 0 c 0).continuous.comp (by fun_prop) + exact (hf.measurable.mul hg.measurable |>.mul (by unfold stripDensity;fun_prop)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_eq_abs,abs_mul,abs_mul,abs_of_pos (stripDensity_pos hp)] + calc + _ ≤ (δ^(-(r:ℤ))*Real.exp (Real.sqrt (b+δ)*p))*(δ^(-(s:ℤ))*Real.exp (Real.sqrt (c+δ)*p))* + (2*p*Real.exp (angle*p)/Real.sinh (Real.pi*p/2)) := by + gcongr + · exact le_of_lt (stripDensity_pos hp) + · exact cosineKernelJet_exp_bound hb hd r hp.le + · exact cosineKernelJet_exp_bound hc hd s hp.le + · exact stripDensity_bound hp.le + _ = _ := by + simp only [a,add_mul,Real.exp_add] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Equiv MeasureTheory Filter +noncomputable def jetGram {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) : Matrix (Fin n) (Fin n) ℝ := + fun i j=>∫ p in Set.Ioi (0:ℝ),cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p +noncomputable def jetPointDensity {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) (p : Fin n → ℝ) : ℝ := + (∏ i,w (p i))*(jetEvaluation b (fun i=>(p i)^2)).det*(jetEvaluation c (fun i=>(p i)^2)).det +lemma weighted_jet_evaluation {n : ℕ} (w : ℝ → ℝ) (b : ℕ → ℝ) (p : Fin n → ℝ) : + (evaluationMatrix (fun i : Fin n=>fun q=>cosineKernelJet (nodalOrder b i) 0 (b i) (q^2)*w q) p).det= + (∏ i,w (p i))*(jetEvaluation b (fun i=>(p i)^2)).det := by + change (Matrix.of (fun i j : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i) ((p j)^2)*w (p j))).det=_ + have he : Matrix.of (fun i j : Fin n=>cosineKernelJet (nodalOrder b i) 0 (b i) ((p j)^2)*w (p j))= + Matrix.of (fun i j : Fin n=>w (p j)*cosineKernelJet (nodalOrder b i) 0 (b i) ((p j)^2)) := by + ext i j + exact mul_comm _ _ + rw [he] + exact Matrix.det_mul_row (fun j=>w (p j)) (jetEvaluation b (fun i=>(p i)^2)) +lemma jet_gram_andreief {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p) (Set.Ioi 0)) : + Integrable (jetPointDensity (n:=n) w b c) (Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ)))) ∧ + (∫ p,jetPointDensity (n:=n) w b c p ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))))= + Fintype.card (Perm (Fin n))*(jetGram (n:=n) w b c).det := by + let F : Fin n → ℝ → ℝ := fun i p=>cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)*w p + let G : Fin n → ℝ → ℝ := fun i p=>cosineKernelJet (nodalOrder c i) 0 (c i) (p^2) + have hFG i j : Integrable (fun p=>F i p*G j p) (volume.restrict (Set.Ioi (0:ℝ))) := by + apply (hi i j).congr + filter_upwards with p + dsimp [F,G] + ring + have he p : (evaluationMatrix F p).det*(evaluationMatrix G p).det=jetPointDensity w b c p := by + rw [show (evaluationMatrix F p).det=(∏ i,w (p i))*(jetEvaluation b (fun i=>(p i)^2)).det from weighted_jet_evaluation w b p] + rfl + have hgram : gramMatrix (volume.restrict (Set.Ioi (0:ℝ))) F G=jetGram w b c := by + ext i j + apply integral_congr_ae + filter_upwards with p + dsimp [F,G] + ring + constructor + · simpa only [he] using integrable_det_evaluation_product _ F G hFG + · simpa only [he,hgram] using andreief _ F G hFG +lemma jetPointDensity_pos {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) (p : Fin n → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hp : ∀ i,0

(p i)^2) := by + intro i j hij + apply hpi + exact (sq_eq_sq₀ (hp i).le (hp j).le).mp hij + rw [jetPointDensity,mul_assoc] + exact mul_pos (prod_pos (fun i _=>hw _ (hp i))) + (jetEvaluation_det_product_pos b c _ hb hc hb0 hc0 hin (fun i=>sq_nonneg _)) +lemma jetGram_det_pos {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) (hw : ∀ q,0cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p) (Set.Ioi 0)) : + 0 < (jetGram (n:=n) w b c).det := by + let μ : Measure (Fin n → ℝ) := Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))) + obtain ⟨hI,hA⟩ := jet_gram_andreief w b c hi + have hae : ∀ᵐ p ∂μ,∀ i,0

volume.restrict (Set.Ioi (0:ℝ))) (i:=i)).eventually (ae_restrict_mem measurableSet_Ioi) + have hnn : 0 ≤ᵐ[μ] jetPointDensity w b c := by + filter_upwards [hae] with p hp + dsimp only [Pi.zero_apply] + rw [jetPointDensity,mul_assoc] + exact mul_nonneg (prod_nonneg (fun i _=>(hw _ (hp i)).le)) + (jetEvaluation_det_product_nonneg b c _ hb hc hb0 hc0 (fun i=>sq_nonneg _)) + let box : Set (Fin n → ℝ) := Set.pi Set.univ (fun i=>Set.Ioo ((i:ℝ)+1) ((i:ℝ)+3/2)) + have hbox : box ⊆ Function.support (jetPointDensity w b c) := by + intro p hp + have hp' (i : Fin n) : (i:ℝ)+1

volume.restrict (Set.Ioi (0:ℝ))) (Set.pi Set.univ _) + rw [Measure.pi_pi] + apply pos_iff_ne_zero.mpr + apply Finset.prod_ne_zero_iff.mpr + intro i _ + apply ne_of_gt + rw [Measure.restrict_apply measurableSet_Ioo,Set.inter_eq_left.mpr,Real.volume_Ioo] + · exact ENNReal.ofReal_pos.mpr (by norm_num) + · intro p hp + have hn : (0:ℝ) ≤ i := Nat.cast_nonneg _ + exact lt_trans (by linarith) hp.1 + have hpos : 0<∫ p,jetPointDensity w b c p ∂μ := + (integral_pos_iff_support_of_nonneg_ae hnn hI).mpr (hboxpos.trans_le (measure_mono hbox)) + rw [hA] at hpos + exact (mul_pos_iff.mp hpos).elim (fun h=>h.2) (fun h=>False.elim (not_lt_of_ge (Nat.cast_nonneg _) h.1)) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset MeasureTheory Filter Topology +lemma cosineKernelJet_pair_moment_integrable {b c δ : ℝ} (hb : 0 ≤ b) (hc : 0 ≤ c) (hd : 0<δ) + (hbc : Real.sqrt (b+δ)+Real.sqrt (c+δ)+angle < Real.pi/2) (r s k : ℕ) : + IntegrableOn (fun p=>p^k*cosineKernelJet r 0 b (p^2)*cosineKernelJet s 0 c (p^2)*stripDensity p) + (Set.Ioi 0) := by + let a := Real.sqrt (b+δ)+Real.sqrt (c+δ)+angle + have ha : 0 ≤ a := by dsimp [a];have : 0 < angle := (by unfold angle;positivity);positivity + have hi := (Analytic.polynomial_kernel_integrable k ha hbc).const_mul (2*δ^(-(r:ℤ))*δ^(-(s:ℤ))) + apply hi.mono' + · have hf : Continuous (fun p : ℝ=>cosineKernelJet r 0 b (p^2)) := + (cosineKernelJet_contDiff_right r 0 b 0).continuous.comp (by fun_prop) + have hg : Continuous (fun p : ℝ=>cosineKernelJet s 0 c (p^2)) := + (cosineKernelJet_contDiff_right s 0 c 0).continuous.comp (by fun_prop) + exact ((by fun_prop : Measurable (fun p : ℝ=>p^k)).mul hf.measurable |>.mul hg.measurable |>.mul (by unfold stripDensity;fun_prop)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_eq_abs,abs_mul,abs_mul,abs_mul,abs_of_nonneg (pow_nonneg hp.le k),abs_of_pos (stripDensity_pos hp)] + calc + _ ≤ (p^k*(δ^(-(r:ℤ))*Real.exp (Real.sqrt (b+δ)*p)))*(δ^(-(s:ℤ))*Real.exp (Real.sqrt (c+δ)*p))* + (2*p*Real.exp (angle*p)/Real.sinh (Real.pi*p/2)) := by + have hp0 : 0 ≤ p := le_of_lt hp + gcongr <;> first | positivity | exact le_of_lt (stripDensity_pos hp) | exact cosineKernelJet_exp_bound hb hd r hp0 | exact cosineKernelJet_exp_bound hc hd s hp0 | exact stripDensity_bound hp0 + _ = _ := by + simp only [pow_succ,a,add_mul,Real.exp_add] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix MeasureTheory Filter Topology +lemma strip_label_margin {b c : ℝ} (hb : b ≤ (3*angle/2)^2) (hc : c ≤ angle^2) : + Real.sqrt (b+angle^2/100)+Real.sqrt (c+angle^2/100)+angle < Real.pi/2 := by + have hL : 0p^k*cosineKernelJet r 0 b (p^2)*cosineKernelJet s 0 c (p^2)*stripDensity p) + (Set.Ioi 0) := by + have hd : 0cosineKernelJet r 0 b (p^2)*cosineKernelJet s 0 c (p^2)*stripDensity p) + (Set.Ioi 0) := by + simpa only [pow_zero,one_mul] using strip_jet_pair_moment_integrable hb0 hc0 hb hc r s 0 +lemma strip_jet_gram_det_pos {n : ℕ} (b c : ℕ → ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin n,c i ≤ angle^2) : + 0 < (jetGram (n:=n) stripDensity b c).det := by + apply jetGram_det_pos stripDensity b c hb hc hb0 hc0 (fun _ h=>stripDensity_pos h) + intro i j + exact strip_jet_pair_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) _ _ +noncomputable def poleAdjustedDensity (z p : ℝ) : ℝ := stripDensity p/(p^2+z^2) +lemma poleAdjustedDensity_pos {z p : ℝ} (hz : 0p^k*cosineKernelJet r 0 b (p^2)*cosineKernelJet s 0 c (p^2)*poleAdjustedDensity z p) + (Set.Ioi 0) := by + have hi := (strip_jet_pair_moment_integrable hb0 hc0 hb hc r s k).div_const (z^2) + have hf : Continuous (fun p : ℝ=>cosineKernelJet r 0 b (p^2)) := + (cosineKernelJet_contDiff_right r 0 b 0).continuous.comp (by fun_prop) + have hg : Continuous (fun p : ℝ=>cosineKernelJet s 0 c (p^2)) := + (cosineKernelJet_contDiff_right s 0 c 0).continuous.comp (by fun_prop) + apply hi.mono' + · exact ((by fun_prop : Measurable (fun p : ℝ=>p^k)).mul hf.measurable |>.mul hg.measurable |>.mul + (by unfold poleAdjustedDensity stripDensity;fun_prop)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + have hp0 : 0 ≤ p := le_of_lt hp + have hf0 := cosineKernelJet_nonneg hb0 (sq_nonneg p) r 0 + have hg0 := cosineKernelJet_nonneg hc0 (sq_nonneg p) s 0 + have hw0 := (stripDensity_pos hp).le + rw [Real.norm_of_nonneg (by unfold poleAdjustedDensity;positivity)] + unfold poleAdjustedDensity + rw [←mul_div_assoc] + exact div_le_div_of_nonneg_left (by positivity) (sq_pos_of_pos hz) (by nlinarith [sq_nonneg p]) +lemma pole_adjusted_gram_det_pos {n : ℕ} (b c : ℕ → ℝ) {z : ℝ} (hz : 0b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin n,c i ≤ angle^2) : + 0 < (jetGram (n:=n) (poleAdjustedDensity z) b c).det := by + apply jetGram_det_pos _ b c hb hc hb0 hc0 (fun _ h=>poleAdjustedDensity_pos hz h) + intro i j + simpa only [pow_zero,one_mul] using pole_adjusted_pair_moment_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) hz _ _ 0 +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset MeasureTheory Filter +noncomputable def jetPencil {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) (t : ℝ) : Matrix (Fin n) (Fin n) ℝ := + jetGram (fun p=>(p^2-t)*w p) b c +noncomputable def characteristicRatio (y z p : ℝ) : ℝ := (p^2+y^2)/(p^2+z^2) +lemma jetPointDensity_tilt {n : ℕ} (w r : ℝ → ℝ) (b c : ℕ → ℝ) (p : Fin n → ℝ) : + jetPointDensity (fun q=>r q*w q) b c p=(∏ i,r (p i))*jetPointDensity w b c p := by + simp only [jetPointDensity,prod_mul_distrib] + ring +lemma pole_jet_pair_pencil_integrable {b c z : ℝ} (hb0 : 0 ≤ b) (hc0 : 0 ≤ c) + (hb : b ≤ (3*angle/2)^2) (hc : c ≤ angle^2) (hz : 0cosineKernelJet r 0 b (p^2)*cosineKernelJet s 0 c (p^2)* + ((p^2-t)*poleAdjustedDensity z p)) (Set.Ioi 0) := by + have h0 := pole_adjusted_pair_moment_integrable hb0 hc0 hb hc hz r s 0 + have h2 := pole_adjusted_pair_moment_integrable hb0 hc0 hb hc hz r s 2 + apply (h2.sub (h0.const_mul t)).congr + filter_upwards with p + simp only [Pi.sub_apply,pow_zero,one_mul] + ring +lemma jetPencil_affine {n : ℕ} (w : ℝ → ℝ) (b c : ℕ → ℝ) (t : ℝ) + (hi : ∀ i j : Fin n,IntegrableOn (fun p=>cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin n,IntegrableOn (fun p=>p^2*cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*w p) (Set.Ioi 0)) : + jetPencil (n:=n) w b c t=jetPencil w b c 0-t • jetGram w b c := by + ext i j + change (∫ p in Set.Ioi (0:ℝ),_)= (∫ p in Set.Ioi (0:ℝ),_)-t*(∫ p in Set.Ioi (0:ℝ),_) + rw [←integral_const_mul,←integral_sub] + · apply integral_congr_ae + filter_upwards with p + ring + · apply (h2 i j).congr + filter_upwards with p + ring + · exact (hi i j).const_mul t +lemma pole_jetPencil_det_pos_nonpos {n : ℕ} (b c : ℕ → ℝ) {z t : ℝ} (hz : 0b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin n,c i ≤ angle^2) : + 0 < (jetPencil (n:=n) (poleAdjustedDensity z) b c t).det := by + apply jetGram_det_pos _ b c hb hc hb0 hc0 + · intro p hp + exact mul_pos (by nlinarith [sq_pos_of_pos hp]) (poleAdjustedDensity_pos hz hp) + · intro i j + exact pole_jet_pair_pencil_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) hz _ _ t +lemma pole_jetPencil_real_root_positive {n : ℕ} (b c : ℕ → ℝ) {z t : ℝ} (hz : 0b i)) (hc : Monotone (fun i : Fin n=>c i)) + (hb0 : ∀ i : Fin n,0 ≤ b i) (hc0 : ∀ i : Fin n,0 ≤ c i) + (hb1 : ∀ i : Fin n,b i ≤ (3*angle/2)^2) (hc1 : ∀ i : Fin n,c i ≤ angle^2) + (hroot : (jetPencil (n:=n) (poleAdjustedDensity z) b c t).det=0) : 0(p^2-(-(z^2)))*poleAdjustedDensity z p)=stripDensity := by + funext p + have hd : p^2+z^2 ≠ 0 := ne_of_gt (by positivity) + dsimp [poleAdjustedDensity] + field_simp + ring +lemma pole_pencil_tilt_weight (y z : ℝ) : + (fun p : ℝ=>(p^2-(-(y^2)))*poleAdjustedDensity z p)= + (fun p=>characteristicRatio y z p*stripDensity p) := by + funext p + dsimp [poleAdjustedDensity,characteristicRatio] + ring + +theorem strip_jet_characteristic_product {n : ℕ} (b c : ℕ → ℝ) (y : ℝ) {z : ℝ} (hz : 0volume.restrict (Set.Ioi (0:ℝ)))) / + (∫ p,jetPointDensity (n:=n) stripDensity b c p + ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ)))) = + (jetPencil (n:=n) (poleAdjustedDensity z) b c (-(y^2))).det / + (jetPencil (n:=n) (poleAdjustedDensity z) b c (-(z^2))).det := by + have hi : ∀ i j : Fin n,IntegrableOn (fun p=>cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*stripDensity p) (Set.Ioi 0) := + fun i j=>strip_jet_pair_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) _ _ + have hit : ∀ i j : Fin n,IntegrableOn (fun p=>cosineKernelJet (nodalOrder b i) 0 (b i) (p^2)* + cosineKernelJet (nodalOrder c j) 0 (c j) (p^2)*(characteristicRatio y z p*stripDensity p)) (Set.Ioi 0) := by + intro i j + have h:=pole_jet_pair_pencil_integrable (hb0 i) (hc0 j) (hb1 i) (hc1 j) hz (nodalOrder b i) (nodalOrder c j) (-(y^2)) + apply h.congr + filter_upwards with p + rw [congrFun (pole_pencil_tilt_weight y z) p] + simp_rw [←jetPointDensity_tilt] + rw [(jet_gram_andreief _ b c hit).2,(jet_gram_andreief _ b c hi).2] + have hn : (Fintype.card (Equiv.Perm (Fin n)) : ℝ) ≠ 0 := by positivity + rw [mul_div_mul_left _ _ hn] + rw [jetPencil,jetPencil,pole_pencil_restore_weight hz,pole_pencil_tilt_weight y z] +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/StripPolynomial.lean b/lean/OAI/Combinatorics/HoneycombChords/StripPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4a3a218003a1c9c52fd79cafbcb74e14bb92954 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/StripPolynomial.lean @@ -0,0 +1,126 @@ +import OAI.Combinatorics.HoneycombChords.StripGram +import OAI.Combinatorics.HoneycombChords.PolynomialKernels + +namespace OAI + +/-! +# Hyperbolic bounds for the strip density + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Filter +lemma sinh_le_mul_cosh_nonneg {t : ℝ} (ht : 0 ≤ t) : Real.sinh t ≤ t*Real.cosh t := by + have hd x : HasDerivAt (fun x : ℝ=>x*Real.cosh x-Real.sinh x) (x*Real.sinh x) x := by + convert! ((hasDerivAt_id x).mul (Real.hasDerivAt_cosh x)).sub (Real.hasDerivAt_sinh x) using 1; simp only [id_eq,one_mul,add_sub_cancel_left] + have hm : Monotone (fun x : ℝ=>x*Real.cosh x-Real.sinh x) := by + apply monotone_of_deriv_nonneg (fun x=>(hd x).differentiableAt) + intro x + rw [(hd x).deriv] + rcases le_total 0 x with h|h + · exact mul_nonneg h (Real.sinh_nonneg_iff.mpr h) + · exact mul_nonneg_of_nonpos_of_nonpos h (Real.sinh_nonpos_iff.mpr h) + have h:=hm ht + simpa using h +lemma cosh_add_le_twice (a b : ℝ) : Real.cosh (a+b) ≤ 2*Real.cosh a*Real.cosh b := by + have h:=Real.cosh_pos (a-b) + rw [Real.cosh_add,Real.cosh_sub] at * + linarith +lemma cosh_le_sinh_add_one {t : ℝ} (ht : 0 ≤ t) : Real.cosh t ≤ Real.sinh t+1 := by + have h : Real.exp (-t) ≤ 1 := Real.exp_le_one_iff.mpr (by linarith) + rw [←Real.cosh_sub_sinh] at h + linarith +/-- Global comparison to the exact exponential rate b=3L; no asymptotic +weight hypothesis is being postulated. -/ +theorem stripDensity_sech_bounds {p : ℝ} (hp : 0 < p) : + 1/(8*angle*Real.cosh (3*angle*p)) ≤ stripDensity p ∧ + stripDensity p ≤ (p+1/angle)/Real.cosh (3*angle*p) := by + have hL : 0 < angle := by unfold angle;positivity + have hs : 0 < Real.sinh (4*angle*p) := Real.sinh_pos_iff.mpr (by positivity) + have hc := Real.cosh_pos (3*angle*p) + have hc1 := Real.one_le_cosh (angle*p) + have ht : 0 < angle*p := mul_pos hL hp + constructor + · have h0:=sinh_le_mul_cosh_nonneg (show 0 ≤ 4*angle*p by positivity) + have h1:=cosh_add_le_twice (angle*p) (3*angle*p) + rw [show angle*p+3*angle*p=4*angle*p by ring] at h1 + have h2 : Real.sinh (4*angle*p) ≤ 8*angle*p*Real.cosh (angle*p)*Real.cosh (3*angle*p) := by + nlinarith [mul_le_mul_of_nonneg_left h1 (show 0 ≤ 4*angle*p by positivity)] + unfold stripDensity + apply (div_le_div_iff₀ (by positivity) hs).mpr + nlinarith [mul_nonneg (show 0 ≤ 8*angle*p*Real.cosh (3*angle*p) by positivity) (show 0 ≤ Real.cosh (angle*p)-1 by linarith)] + · have htS : 0 < Real.sinh (angle*p) := Real.sinh_pos_iff.mpr ht + have hadd:=Real.sinh_add (angle*p) (3*angle*p) + have hsub:=Real.sinh_sub (3*angle*p) (angle*p) + rw [show angle*p+3*angle*p=4*angle*p by ring] at hadd + rw [show 3*angle*p-angle*p=2*angle*p by ring] at hsub + have h2 : 2*Real.sinh (angle*p)*Real.cosh (3*angle*p) ≤ Real.sinh (4*angle*p) := by + have hS := Real.sinh_nonneg_iff.mpr (show 0 ≤ 2*angle*p by positivity) + nlinarith + have h3:=cosh_le_sinh_add_one ht.le + have h4:=Real.self_le_sinh_iff.mpr ht.le + have h5 : p*Real.cosh (angle*p) ≤ (p+1/angle)*Real.sinh (angle*p) := by + have hL1 : angle*(1/angle)=1 := by field_simp + have hh : p ≤ Real.sinh (angle*p)/angle := (le_div_iff₀ hL).mpr (by nlinarith) + nlinarith [mul_le_mul_of_nonneg_left h3 hp.le] + unfold stripDensity + apply (div_le_div_iff₀ hs hc).mpr + nlinarith [mul_le_mul_of_nonneg_left h2 (show 0 ≤ p+1/angle by positivity), + mul_le_mul_of_nonneg_right h5 hc.le, + mul_pos hp hc] +noncomputable def squaredPoleDensity (z p : ℝ) : ℝ := stripDensity p/(p^2+z^2)^2 +lemma squaredPoleDensity_pos {z p : ℝ} (hz : 0 < z) (hp : 0 < p) : 0 < squaredPoleDensity z p := by + unfold squaredPoleDensity + exact div_pos (stripDensity_pos hp) (sq_pos_of_pos (by positivity)) +lemma squaredPoleDensity_bounds {z Y : ℝ} (hz : 0 < z) (hzY : z ≤ Y) : + ∃ A : ℝ,0 < A ∧ ∀ p : ℝ,0 < p → + (1/(8*angle))/((p^2+Y^2)^2*Real.cosh (3*angle*p)) ≤ squaredPoleDensity z p ∧ + squaredPoleDensity z p ≤ A/Real.cosh (3*angle*p) := by + have hL : 0 < angle := by unfold angle;positivity + let A : ℝ := ((1+1/angle)/z^2+1)/z^2 + have hA : 0 < A := by dsimp [A];positivity + refine ⟨A,hA,?_⟩ + intro p hp + have hd : 0 < p^2+z^2 := by positivity + have hY : 0 < Y := hz.trans_le hzY + have hdY : 0 < p^2+Y^2 := by positivity + have hcosh := Real.cosh_pos (3*angle*p) + obtain ⟨hl,hu⟩:=stripDensity_sech_bounds hp + constructor + · have hsq : (p^2+z^2)^2 ≤ (p^2+Y^2)^2 := by gcongr + calc + _ = (1/(8*angle*Real.cosh (3*angle*p)))/(p^2+Y^2)^2 := by field_simp + _ ≤ stripDensity p/(p^2+Y^2)^2 := div_le_div_of_nonneg_right hl (sq_nonneg _) + _ ≤ squaredPoleDensity z p := div_le_div_of_nonneg_left (stripDensity_pos hp).le (sq_pos_of_pos hd) hsq + · have hquad : p ≤ 1+p^2 := by nlinarith [sq_nonneg (p-1)] + have hAz : 1+1/angle ≤ ((1+1/angle)/z^2+1)*z^2 := by + have hz0 : z^2≠0 := ne_of_gt (sq_pos_of_pos hz) + rw [add_mul,div_mul_cancel₀ _ (sq_pos_of_pos hz).ne',one_mul] + nlinarith [sq_nonneg z] + have hbig : p+1/angle ≤ ((1+1/angle)/z^2+1)*(p^2+z^2) := by + have hfac : 1 ≤ (1+1/angle)/z^2+1 := by + have hh : 0 ≤ (1+1/angle)/z^2 := by positivity + linarith + nlinarith [mul_le_mul_of_nonneg_right hfac (sq_nonneg p)] + have hnorm : (p+1/angle)/(p^2+z^2)^2 ≤ A := by + apply (div_le_iff₀ (sq_pos_of_pos hd)).mpr + have hcoef : 0 ≤ ((1+1/angle)/z^2+1) := by positivity + have hadd : z^2 ≤ p^2+z^2 := by nlinarith [sq_nonneg p] + have he : A*z^2=((1+1/angle)/z^2+1) := by dsimp [A];field_simp + calc + _ ≤ ((1+1/angle)/z^2+1)*(p^2+z^2) := hbig + _ = A*z^2*(p^2+z^2) := by rw [he] + _ ≤ A*(p^2+z^2)^2 := by nlinarith [mul_le_mul_of_nonneg_left hadd (show 0 ≤ A*(p^2+z^2) by positivity)] + calc + squaredPoleDensity z p ≤ ((p+1/angle)/Real.cosh (3*angle*p))/(p^2+z^2)^2 := + div_le_div_of_nonneg_right hu (sq_nonneg _) + _ = ((p+1/angle)/(p^2+z^2)^2)/Real.cosh (3*angle*p) := by ring + _ ≤ _ := div_le_div_of_nonneg_right hnorm hcosh.le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/StripProducts.lean b/lean/OAI/Combinatorics/HoneycombChords/StripProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc8beea2f9f577bf24b733353fdcf6ad0254b6ea --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/StripProducts.lean @@ -0,0 +1,728 @@ +import OAI.Combinatorics.HoneycombChords.Resolvents +import OAI.Combinatorics.HoneycombChords.StripPolynomial +import OAI.Combinatorics.HoneycombChords.FamilyGram + +namespace OAI + +/-! +# Polynomial characteristic products for the strip density + +Formalized from *Critical honeycomb chords with prescribed boundary endpoints* +(OpenAI, September 26, 2026). +-/ + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Real MeasureTheory Filter Topology +lemma squaredPoleDensity_moments {z : ℝ} (hz : 0 < z) (k : ℕ) : + IntegrableOn (fun p : ℝ=>p^k*squaredPoleDensity z p) (Set.Ioi 0) := by + obtain ⟨A,hA,h⟩:=squaredPoleDensity_bounds hz (le_refl z) + have hb : 0 < 3*angle := by unfold angle;positivity + apply ((pow_sech_integrable k hb).const_mul A).mono' + · exact (by unfold squaredPoleDensity stripDensity;fun_prop : Measurable (fun p : ℝ=>p^k*squaredPoleDensity z p)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg hp.le k) (squaredPoleDensity_pos hz hp).le)] + have hh:=mul_le_mul_of_nonneg_left (h p hp).2 (pow_nonneg hp.le k) + exact hh.trans_eq (by ring) +/-- Christoffel estimates for the strip measure divided by `(x + z²)²`. -/ +theorem stripPolynomialChristoffel_bounds {z y : ℝ} (hz : 0 < z) (hy : 0 < y) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(3*y/4) ≤ weightedPolynomialChristoffel (squaredPoleDensity z) n (-(y^2)) ∧ + weightedPolynomialChristoffel (squaredPoleDensity z) n (-(y^2)) ≤ C*((n:ℝ)+1)^(3*y/4) := by + let b : ℝ := 3*angle + have hb : 0 < b := by dsimp [b];unfold angle;positivity + let Y : ℝ := z+y+2*Real.pi/b + have hY : 0 < Y := by dsimp [Y];positivity + have hzY : z ≤ Y := by + dsimp [Y] + have hh : 0 < 2*Real.pi/b := by positivity + linarith + have hgap : b*y/Real.pi+1 < b*Y/Real.pi := by + dsimp [Y] + have he : b*(z+y+2*Real.pi/b)/Real.pi=b*z/Real.pi+b*y/Real.pi+2 := by field_simp + rw [he] + have hp : 0 < b*z/Real.pi := by positivity + linarith + have hexp : 2*b*y/Real.pi=3*y/4 := by dsimp [b];unfold angle;field_simp;ring + obtain ⟨A,hA,hweight⟩:=squaredPoleDensity_bounds hz hzY + let d : ℝ := 2*b/Real.pi + have hd : 0 < d := by dsimp [d];positivity + let l : ℝ := (1/(8*angle))/d + have hl : 0 < l := by dsimp [l,d,b];unfold angle;positivity + let u : ℝ := d/A + have hu : 0 < u := by dsimp [u];positivity + have hlow (p : ℝ) (hp : 0 < p) : l*rationalSechWeight b Y p ≤ squaredPoleDensity z p := by + have he : l*rationalSechWeight b Y p=(1/(8*angle))/((p^2+Y^2)^2*Real.cosh (3*angle*p)) := by + dsimp [l,d,rationalSechWeight,sechWeight,b] + field_simp + rw [he] + exact (hweight p hp).1 + have hupp (p : ℝ) (hp : 0 < p) : u*squaredPoleDensity z p ≤ sechWeight b p := by + have h:=mul_le_mul_of_nonneg_left (hweight p hp).2 hu.le + have he : u*(A/Real.cosh (3*angle*p))=sechWeight b p := by dsimp [u,d,sechWeight,b];field_simp + rwa [he] at h + obtain ⟨a₀,C₀,ha₀,hC₀,hsech⟩:=scaledPolynomialChristoffel_bounds hb hy + obtain ⟨C₁,hC₁,hrat⟩:=weightedKernel_rationalSech_upper hb hY hy hgap + refine ⟨u*a₀,C₁/l,by positivity,by positivity,?_⟩ + filter_upwards [hsech,hrat] with n hn hn' + have hcL:=weightedPolynomialChristoffel_comparison n (-(y^2)) hu + (fun p hp=>squaredPoleDensity_pos hz hp) (fun p _=>sechWeight_pos hb p) + (squaredPoleDensity_moments hz) (sechWeight_moments hb) hupp + have hcU:=weightedPolynomialChristoffel_comparison n (-(y^2)) hl + (fun p _=>rationalSechWeight_pos hb hY p) (fun p hp=>squaredPoleDensity_pos hz hp) + (rationalSechWeight_moments hb hY) (squaredPoleDensity_moments hz) hlow + rw [weightedKernel_sech] at hcL + rw [hexp] at hn hn' + constructor + · have h := (le_div_iff₀ hu).mp (hn.1.trans hcL) + simpa only [mul_assoc,mul_comm,mul_left_comm] using h + · exact hcU.trans (by simpa only [div_mul_eq_mul_div] using div_le_div_of_nonneg_right hn' hl.le) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset MeasureTheory Filter Topology +lemma polynomial_compression_ratio (n : ℕ) (a b : ℝ) (w : ℝ → ℝ) + (hw : ∀ p,0 < p → 0 < w p) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) : + (monomialGram n (fun p=>(p^2-a)^2*w p)).det / + (monomialGram n (fun p=>(p^2-b)^2*w p)).det = + weightedPolynomialChristoffel w n a / weightedPolynomialChristoffel w n b := by + rw [weightedPolynomialChristoffel_eq n a w hw hi, + weightedPolynomialChristoffel_eq n b w hw hi, + ←polynomial_compression_cofactor n a w hi, + ←polynomial_compression_cofactor n b w hi] + exact (div_div_div_cancel_right₀ (ne_of_gt (monomialGram_posDef (n+1) w hw hi).det_pos) _ _).symm +lemma squaredPole_restore {z : ℝ} (hz : 0 < z) : + (fun p : ℝ=>(p^2-(-(z^2)))^2*squaredPoleDensity z p)=stripDensity := by + funext p + have hd : p^2+z^2 ≠ 0 := ne_of_gt (by positivity) + dsimp [squaredPoleDensity] + field_simp; ring +lemma squaredPole_tilt (y z : ℝ) : + (fun p : ℝ=>(p^2-(-(y^2)))^2*squaredPoleDensity z p)= + (fun p=>characteristicRatio y z p^2*stripDensity p) := by + funext p + dsimp [squaredPoleDensity,characteristicRatio] + rw [div_pow] + ring +/-- Exact square-product identity, with the actual strip measure. -/ +theorem strip_polynomial_square_product (n : ℕ) {y z : ℝ} (hz : 0 < z) : + (monomialGram n (fun p=>characteristicRatio y z p^2*stripDensity p)).det / + (monomialGram n stripDensity).det = + weightedPolynomialChristoffel (squaredPoleDensity z) n (-(y^2)) / + weightedPolynomialChristoffel (squaredPoleDensity z) n (-(z^2)) := by + have h:=polynomial_compression_ratio n (-(y^2)) (-(z^2)) (squaredPoleDensity z) + (fun p hp=>squaredPoleDensity_pos hz hp) (squaredPoleDensity_moments hz) + rwa [squaredPole_restore hz,squaredPole_tilt] at h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Filter Topology +lemma characteristicRatio_pos {y z : ℝ} (hy : 0 < y) (hz : 0 < z) (p : ℝ) : + 0 < characteristicRatio y z p := by unfold characteristicRatio;positivity +lemma characteristicRatio_bounds (y : ℝ) {z : ℝ} (hz : 0 < z) (p : ℝ) : + min 1 (y^2/z^2) ≤ characteristicRatio y z p ∧ + characteristicRatio y z p ≤ max 1 (y^2/z^2) := by + have hz2 : 0 < z^2 := sq_pos_of_pos hz + have hd : 0 < p^2+z^2 := by positivity + have hl := (le_div_iff₀ hz2).mp (min_le_right (1:ℝ) (y^2/z^2)) + have hu := (div_le_iff₀ hz2).mp (le_max_right (1:ℝ) (y^2/z^2)) + unfold characteristicRatio + constructor + · apply (le_div_iff₀ hd).mpr + nlinarith [mul_le_mul_of_nonneg_right (min_le_left (1:ℝ) (y^2/z^2)) (sq_nonneg p)] + · apply (div_le_iff₀ hd).mpr + nlinarith [mul_le_mul_of_nonneg_right (le_max_left (1:ℝ) (y^2/z^2)) (sq_nonneg p)] +lemma weightedPolynomial_moments_bounded (w r : ℝ → ℝ) (hw : ∀ p,0 < p → 0 ≤ w p) + (hr : Measurable r) (hr0 : ∀ p,0 < p → 0 ≤ r p) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) + {C : ℝ} (hb : ∀ p,0 < p → r p ≤ C) (k : ℕ) : + IntegrableOn (fun p : ℝ=>p^k*(r p*w p)) (Set.Ioi 0) := by + apply ((hi k).const_mul C).mono' + · exact (hr.aestronglyMeasurable.mul (hi k).aestronglyMeasurable).congr + (Filter.Eventually.of_forall (fun p=>by dsimp;ring)) + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with p hp + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg hp.le k) (mul_nonneg (hr0 p hp) (hw p hp)))] + nlinarith [mul_le_mul_of_nonneg_right (hb p hp) (mul_nonneg (pow_nonneg hp.le k) (hw p hp))] +lemma tilted_squaredPole_moments {y z : ℝ} (hy : 0 < y) (hz : 0 < z) (k : ℕ) : + IntegrableOn (fun p : ℝ=>p^k*(characteristicRatio y z p*squaredPoleDensity z p)) (Set.Ioi 0) := by + apply weightedPolynomial_moments_bounded (squaredPoleDensity z) (characteristicRatio y z) + (fun p hp=>(squaredPoleDensity_pos hz hp).le) + (by unfold characteristicRatio;fun_prop) + (fun p _=>(characteristicRatio_pos hy hz p).le) (squaredPoleDensity_moments hz) + (fun p _=>(characteristicRatio_bounds y hz p).2) +/-- Kernel exponent is unchanged by the bounded positive characteristic tilt. -/ +theorem tilted_stripPolynomialChristoffel_bounds {y z v : ℝ} (hy : 0 < y) (hz : 0 < z) (hv : 0 < v) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(3*v/4) ≤ weightedPolynomialChristoffel + (fun p=>characteristicRatio y z p*squaredPoleDensity z p) n (-(v^2)) ∧ + weightedPolynomialChristoffel + (fun p=>characteristicRatio y z p*squaredPoleDensity z p) n (-(v^2)) ≤ C*((n:ℝ)+1)^(3*v/4) := by + let l : ℝ := min 1 (y^2/z^2) + let u : ℝ := max 1 (y^2/z^2) + have hl : 0 < l := lt_min (by norm_num) (by positivity) + have hu : 0 < u := (by norm_num : (0:ℝ) < 1).trans_le (le_max_left _ _) + let w' : ℝ → ℝ := fun p=>characteristicRatio y z p*squaredPoleDensity z p + have hw p hp : 0 < w' p := mul_pos (characteristicRatio_pos hy hz p) (squaredPoleDensity_pos hz hp) + have hcL (n : ℕ) :=weightedPolynomialChristoffel_comparison n (-(v^2)) (inv_pos.mpr hu) + hw (fun p hp=>squaredPoleDensity_pos hz hp) (tilted_squaredPole_moments hy hz) (squaredPoleDensity_moments hz) + (fun p hp=>by + have h := mul_le_mul_of_nonneg_right (characteristicRatio_bounds y hz p).2 (squaredPoleDensity_pos hz hp).le + change u⁻¹*(characteristicRatio y z p*squaredPoleDensity z p) ≤ squaredPoleDensity z p + exact (inv_mul_le_iff₀ hu).mpr h) + have hcU (n : ℕ) :=weightedPolynomialChristoffel_comparison n (-(v^2)) hl + (fun p hp=>squaredPoleDensity_pos hz hp) hw (squaredPoleDensity_moments hz) (tilted_squaredPole_moments hy hz) + (fun p hp=>mul_le_mul_of_nonneg_right (characteristicRatio_bounds y hz p).1 (squaredPoleDensity_pos hz hp).le) + obtain ⟨a,C,ha,hC,h⟩:=stripPolynomialChristoffel_bounds hz hv + refine ⟨a/u,C/l,by positivity,by positivity,?_⟩ + filter_upwards [h] with n hn + constructor + · have hh := (div_le_iff₀ hu).mpr (hn.1.trans (by simpa using hcL n)) + simpa only [div_mul_eq_mul_div] using hh + · exact (hcU n).trans (by simpa only [div_mul_eq_mul_div] using div_le_div_of_nonneg_right hn.2 hl.le) +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Filter Topology +lemma power_ratio_bounds (f g : ℕ → ℝ) (α β : ℝ) + (hf : ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^α ≤ f n ∧ f n ≤ C*((n:ℝ)+1)^α) + (hg : ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^β ≤ g n ∧ g n ≤ C*((n:ℝ)+1)^β) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(α-β) ≤ f n/g n ∧ f n/g n ≤ C*((n:ℝ)+1)^(α-β) := by + obtain ⟨a₁,C₁,ha₁,hC₁,hf⟩:=hf + obtain ⟨a₂,C₂,ha₂,hC₂,hg⟩:=hg + refine ⟨a₁/C₂,C₁/a₂,by positivity,by positivity,?_⟩ + filter_upwards [hf,hg] with n hn hn' + have hn0 : 0 < (n:ℝ)+1 := by positivity + have hgn : 0 < g n := (mul_pos ha₂ (rpow_pos_of_pos hn0 β)).trans_le hn'.1 + have hfn : 0 < f n := (mul_pos ha₁ (rpow_pos_of_pos hn0 α)).trans_le hn.1 + rw [rpow_sub hn0] + constructor + · have h:=div_le_div₀ hfn.le hn.1 hgn hn'.2 + exact (by ring : (a₁/C₂)*(((n:ℝ)+1)^α/((n:ℝ)+1)^β) = + (a₁*((n:ℝ)+1)^α)/(C₂*((n:ℝ)+1)^β)).le.trans h + · have h:=div_le_div₀ (mul_pos hC₁ (rpow_pos_of_pos hn0 α)).le hn.2 + (mul_pos ha₂ (rpow_pos_of_pos hn0 β)) hn'.1 + exact h.trans_eq (by ring) +/-- Polynomial square-product exponent for the genuine strip density. -/ +theorem strip_polynomial_square_product_bounds {y z : ℝ} (hy : 0 < y) (hz : 0 < z) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(3*(y-z)/4) ≤ + (monomialGram n (fun p=>characteristicRatio y z p^2*stripDensity p)).det/(monomialGram n stripDensity).det ∧ + (monomialGram n (fun p=>characteristicRatio y z p^2*stripDensity p)).det/(monomialGram n stripDensity).det ≤ + C*((n:ℝ)+1)^(3*(y-z)/4) := by + have h:=power_ratio_bounds + (fun n=>weightedPolynomialChristoffel (squaredPoleDensity z) n (-(y^2))) + (fun n=>weightedPolynomialChristoffel (squaredPoleDensity z) n (-(z^2))) + (3*y/4) (3*z/4) (stripPolynomialChristoffel_bounds hz hy) (stripPolynomialChristoffel_bounds hz hz) + simpa only [←strip_polynomial_square_product (y:=y) _ hz,show 3*y/4-3*z/4=3*(y-z)/4 by ring] using h +lemma tilted_squaredPole_restore {y z : ℝ} (hz : 0 < z) : + (fun p : ℝ=>(p^2-(-(z^2)))^2*(characteristicRatio y z p*squaredPoleDensity z p))= + (fun p=>characteristicRatio y z p*stripDensity p) := by + funext p + have h:=congrFun (squaredPole_restore hz) p + rw [←h] + ring +lemma tilted_squaredPole_tilt (y z : ℝ) : + (fun p : ℝ=>(p^2-(-(y^2)))^2*(characteristicRatio y z p*squaredPoleDensity z p))= + (fun p=>characteristicRatio y z p^2*(characteristicRatio y z p*stripDensity p)) := by + funext p + have h:=congrFun (squaredPole_tilt y z) p + rw [←mul_assoc, mul_comm ((p^2-(-(y^2)))^2) (characteristicRatio y z p),mul_assoc,h] + ring +lemma tilted_strip_polynomial_square_product (n : ℕ) {y z : ℝ} (hy : 0 < y) (hz : 0 < z) : + (monomialGram n (fun p=>characteristicRatio y z p^2*(characteristicRatio y z p*stripDensity p))).det / + (monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det = + weightedPolynomialChristoffel (fun p=>characteristicRatio y z p*squaredPoleDensity z p) n (-(y^2)) / + weightedPolynomialChristoffel (fun p=>characteristicRatio y z p*squaredPoleDensity z p) n (-(z^2)) := by + have h:=polynomial_compression_ratio n (-(y^2)) (-(z^2)) + (fun p=>characteristicRatio y z p*squaredPoleDensity z p) + (fun p hp=>mul_pos (characteristicRatio_pos hy hz p) (squaredPoleDensity_pos hz hp)) + (tilted_squaredPole_moments hy hz) + rwa [tilted_squaredPole_restore hz,tilted_squaredPole_tilt] at h +/-- The second square-product estimate needed for the Cauchy--Schwarz squeeze. -/ +theorem tilted_strip_polynomial_square_product_bounds {y z : ℝ} (hy : 0 < y) (hz : 0 < z) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(3*(y-z)/4) ≤ + (monomialGram n (fun p=>characteristicRatio y z p^2*(characteristicRatio y z p*stripDensity p))).det / + (monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det ∧ + (monomialGram n (fun p=>characteristicRatio y z p^2*(characteristicRatio y z p*stripDensity p))).det / + (monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det ≤ C*((n:ℝ)+1)^(3*(y-z)/4) := by + have h:=power_ratio_bounds + (fun n=>weightedPolynomialChristoffel (fun p=>characteristicRatio y z p*squaredPoleDensity z p) n (-(y^2))) + (fun n=>weightedPolynomialChristoffel (fun p=>characteristicRatio y z p*squaredPoleDensity z p) n (-(z^2))) + (3*y/4) (3*z/4) (tilted_stripPolynomialChristoffel_bounds hy hz hy) (tilted_stripPolynomialChristoffel_bounds hy hz hz) + simpa only [←tilted_strip_polynomial_square_product _ hy hz,show 3*y/4-3*z/4=3*(y-z)/4 by ring] using h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Equiv MeasureTheory Filter +noncomputable def monomialPointDensity (n : ℕ) (w : ℝ → ℝ) (p : Fin n → ℝ) : ℝ := + (∏ i,w (p i))*(evaluationMatrix (fun i : Fin n=>fun q : ℝ=>(q^2)^i.val) p).det^2 +lemma monomial_gram_andreief (n : ℕ) (w : ℝ → ℝ) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) : + Integrable (monomialPointDensity n w) (Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ)))) ∧ + (∫ p,monomialPointDensity n w p ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))))= + Fintype.card (Perm (Fin n))*(monomialGram n w).det := by + let F : Fin n → ℝ → ℝ := fun i p=>(p^2)^i.val*w p + let G : Fin n → ℝ → ℝ := fun i p=>(p^2)^i.val + have hiFG i j : Integrable (fun p=>F i p*G j p) (volume.restrict (Set.Ioi (0:ℝ))) := by + apply (monomial_pair_integrable w hi i.val j.val).congr + filter_upwards with p + dsimp [F,G] + ring + have he p : (evaluationMatrix F p).det*(evaluationMatrix G p).det=monomialPointDensity n w p := by + have hF : evaluationMatrix F p=Matrix.of (fun i j=>w (p j)*evaluationMatrix G p i j) := by + ext i j + dsimp [evaluationMatrix,F,G] + ring + rw [hF,Matrix.det_mul_row] + dsimp [monomialPointDensity,G] + ring + have hg : gramMatrix (volume.restrict (Set.Ioi (0:ℝ))) F G=monomialGram n w := by + ext i j + apply integral_congr_ae + filter_upwards with p + dsimp [F,G] + ring + constructor + · simpa only [he] using integrable_det_evaluation_product _ F G hiFG + · simpa only [he,hg] using andreief _ F G hiFG +lemma monomialPointDensity_tilt (n : ℕ) (w r : ℝ → ℝ) (p : Fin n → ℝ) : + monomialPointDensity n (fun q=>r q*w q) p=(∏ i,r (p i))*monomialPointDensity n w p := by + simp only [monomialPointDensity,prod_mul_distrib] + ring +lemma monomialPointDensity_nonneg (n : ℕ) (w : ℝ → ℝ) (hw : ∀ p,0 < p → 0 ≤ w p) : + ∀ᵐ p ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))),0 ≤ monomialPointDensity n w p := by + have hae : ∀ᵐ p ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))),∀ i,0 < p i := by + apply eventually_all.mpr + intro i + exact (Measure.tendsto_eval_ae_ae (μ:=fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))) (i:=i)).eventually (ae_restrict_mem measurableSet_Ioi) + filter_upwards [hae] with p hp + exact mul_nonneg (prod_nonneg (fun i _=>hw _ (hp i))) (sq_nonneg _) +lemma integral_weighted_square {α : Type*} [MeasurableSpace α] (μ : Measure α) (ρ f : α → ℝ) + (hρ : Integrable ρ μ) (h1 : Integrable (fun x=>f x*ρ x) μ) + (h2 : Integrable (fun x=>f x^2*ρ x) μ) (hρ0 : 0 ≤ᵐ[μ] ρ) + (hI : 0 < ∫ x,ρ x ∂μ) : + (∫ x,f x*ρ x ∂μ)^2 ≤ (∫ x,f x^2*ρ x ∂μ)*(∫ x,ρ x ∂μ) := by + let a : ℝ := (∫ x,f x*ρ x ∂μ)/(∫ x,ρ x ∂μ) + have he : (fun x=>(f x-a)^2*ρ x)= + (fun x=>f x^2*ρ x-2*a*(f x*ρ x)+a^2*ρ x) := by funext x;ring + have hh : 0 ≤ ∫ x,(f x-a)^2*ρ x ∂μ := integral_nonneg_of_ae (hρ0.mono (fun x hx=>mul_nonneg (sq_nonneg _) hx)) + have hadd:=integral_add (h2.sub (h1.const_mul (2*a))) (hρ.const_mul (a^2)) + have hsub:=integral_sub h2 (h1.const_mul (2*a)) + simp only [Pi.sub_apply] at hadd hsub + rw [he,hadd,hsub,integral_const_mul,integral_const_mul] at hh + have he' : a*(∫ x,ρ x ∂μ)=∫ x,f x*ρ x ∂μ := div_mul_cancel₀ _ hI.ne' + nlinarith [mul_nonneg hh hI.le] +/-- Cauchy--Schwarz for the genuine polynomial determinant density. -/ +theorem monomialGram_tilt_square (n : ℕ) (w r : ℝ → ℝ) + (hw : ∀ p,0 < p → 0 < w p) + (hi : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*w p) (Set.Ioi 0)) + (hi1 : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*(r p*w p)) (Set.Ioi 0)) + (hi2 : ∀ k : ℕ,IntegrableOn (fun p : ℝ=>p^k*(r p^2*w p)) (Set.Ioi 0)) : + (monomialGram n (fun p=>r p*w p)).det^2 ≤ + (monomialGram n (fun p=>r p^2*w p)).det*(monomialGram n w).det := by + obtain ⟨h0,he0⟩:=monomial_gram_andreief n w hi + obtain ⟨h1,he1⟩:=monomial_gram_andreief n (fun p=>r p*w p) hi1 + obtain ⟨h2,he2⟩:=monomial_gram_andreief n (fun p=>r p^2*w p) hi2 + change Integrable (fun p=>monomialPointDensity n (fun p=>r p*w p) p) _ at h1 + change Integrable (fun p=>monomialPointDensity n (fun p=>r p^2*w p) p) _ at h2 + simp_rw [monomialPointDensity_tilt] at h1 h2 he1 he2 + simp_rw [Finset.prod_pow] at h2 he2 + have hpos : 0 < ∫ p,monomialPointDensity n w p ∂Measure.pi (fun _ : Fin n=>volume.restrict (Set.Ioi (0:ℝ))) := by + rw [he0] + exact mul_pos (by positivity) (monomialGram_posDef n w hw hi).det_pos + have h:=integral_weighted_square _ (monomialPointDensity n w) (fun p=>∏ i,r (p i)) h0 h1 h2 + (monomialPointDensity_nonneg n w (fun p hp=>(hw p hp).le)) hpos + rw [he0,he1,he2] at h + have hn : (0:ℝ) < Fintype.card (Perm (Fin n)) := by positivity + have hh : ((Fintype.card (Perm (Fin n)) : ℝ)^2)*(monomialGram n (fun p=>r p*w p)).det^2 ≤ + ((Fintype.card (Perm (Fin n)) : ℝ)^2)*((monomialGram n (fun p=>r p^2*w p)).det*(monomialGram n w).det) := by nlinarith only [h] + exact (mul_le_mul_iff_right₀ (sq_pos_of_pos hn)).mp hh +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Filter Topology +lemma stripDensity_moments (k : ℕ) : + IntegrableOn (fun p : ℝ=>p^k*stripDensity p) (Set.Ioi 0) := by + have h:=strip_jet_pair_moment_integrable (b:=0) (c:=0) (le_refl _) (le_refl _) + (sq_nonneg _) (sq_nonneg _) 0 0 k + simpa only [cosineKernelJet_zero_zero_cosh (le_refl (0:ℝ)) (sq_nonneg _), + Real.sqrt_zero,zero_mul,Real.cosh_zero,mul_one] using h +lemma characteristic_tilt_moments {y z : ℝ} (hy : 0 < y) (hz : 0 < z) (j k : ℕ) : + IntegrableOn (fun p : ℝ=>p^k*(characteristicRatio y z p^j*stripDensity p)) (Set.Ioi 0) := by + apply weightedPolynomial_moments_bounded stripDensity (fun p=>characteristicRatio y z p^j) + (fun p hp=>(stripDensity_pos hp).le) (by unfold characteristicRatio;fun_prop) + (fun p _=>pow_nonneg (characteristicRatio_pos hy hz p).le j) stripDensity_moments + (fun p _=>pow_le_pow_left₀ (characteristicRatio_pos hy hz p).le (characteristicRatio_bounds y hz p).2 j) +lemma square_le_power_upper {u x C t : ℝ} (hu : 0 ≤ u) (hx : 0 < x) (hC : 0 < C) + (h : u^2 ≤ C*x^(2*t)) : u ≤ Real.sqrt C*x^t := by + apply (sq_le_sq₀ hu (mul_nonneg (Real.sqrt_nonneg _) (rpow_nonneg hx.le _))).mp + have he : (Real.sqrt C*x^t)^2=C*x^(2*t) := by + rw [mul_pow,Real.sq_sqrt hC.le,show 2*t=t*2 by ring,rpow_mul hx.le,rpow_two] + rwa [he] +lemma polynomial_product_squeeze (G S T : ℕ → ℝ) (t : ℝ) + (hG : ∀ n,0 < G n) (hS : ∀ n,0 ≤ S n) + (hCS : ∀ n,(G n)^2 ≤ S n) (hCST : ∀ n,(S n/G n)^2 ≤ T n) + (hSb : ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(2*t) ≤ S n ∧ S n ≤ C*((n:ℝ)+1)^(2*t)) + (hTb : ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(2*t) ≤ T n ∧ T n ≤ C*((n:ℝ)+1)^(2*t)) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^t ≤ G n ∧ G n ≤ C*((n:ℝ)+1)^t := by + obtain ⟨a,C,ha,hC,hs⟩:=hSb + obtain ⟨a',C',_,hC',ht⟩:=hTb + have hc' : 0 < Real.sqrt C' := Real.sqrt_pos.mpr hC' + refine ⟨a/Real.sqrt C',Real.sqrt C,by positivity,by positivity,?_⟩ + filter_upwards [hs,ht] with n hn hn' + have hx : 0 < (n:ℝ)+1 := by positivity + have hv : 0 < ((n:ℝ)+1)^t := rpow_pos_of_pos hx t + constructor + · have hh:=square_le_power_upper (div_nonneg (hS n) (hG n).le) hx hC' ((hCST n).trans hn'.2) + have hh':= (div_le_iff₀ (hG n)).mp hh + have hl:=hn.1.trans hh' + rw [show 2*t=t*2 by ring,rpow_mul hx.le,rpow_two] at hl + have hl' : a*((n:ℝ)+1)^t ≤ Real.sqrt C'*G n := by + by_contra h + have hlt:=mul_lt_mul_of_pos_right (lt_of_not_ge h) hv + nlinarith only [hl,hlt] + calc a/Real.sqrt C'*((n:ℝ)+1)^t=(a*((n:ℝ)+1)^t)/Real.sqrt C' := by ring + _ ≤ G n := (div_le_iff₀ hc').mpr (by simpa only [mul_comm] using hl') + · exact square_le_power_upper (hG n).le hx hC ((hCS n).trans hn.2) +/-- Characteristic product estimates for the strip density. -/ +theorem strip_polynomial_characteristic_product_bounds {y z : ℝ} (hy : 0 < y) (hz : 0 < z) : + ∃ a C : ℝ,0 < a ∧ 0 < C ∧ ∀ᶠ n : ℕ in atTop, + a*((n:ℝ)+1)^(3*(y-z)/8) ≤ + (monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det/(monomialGram n stripDensity).det ∧ + (monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det/(monomialGram n stripDensity).det ≤ + C*((n:ℝ)+1)^(3*(y-z)/8) := by + let d (n j : ℕ) : ℝ := (monomialGram n (fun p=>characteristicRatio y z p^j*stripDensity p)).det + have hd n j : 0 < d n j := (monomialGram_posDef n _ + (fun p hp=>mul_pos (pow_pos (characteristicRatio_pos hy hz p) j) (stripDensity_pos hp)) + (characteristic_tilt_moments hy hz j)).det_pos + have hd0 n : d n 0=(monomialGram n stripDensity).det := by simp only [d,pow_zero,one_mul] + have hd1 n : d n 1=(monomialGram n (fun p=>characteristicRatio y z p*stripDensity p)).det := by simp only [d,pow_one] + have hd3 n : d n 3=(monomialGram n (fun p=>characteristicRatio y z p^2*(characteristicRatio y z p*stripDensity p))).det := by + dsimp [d] + congr 2 + funext p + ring + have hCS n : (d n 1/d n 0)^2 ≤ d n 2/d n 0 := by + have h:=monomialGram_tilt_square n stripDensity (characteristicRatio y z) + (fun p hp=>stripDensity_pos hp) stripDensity_moments + (by simpa only [pow_one] using characteristic_tilt_moments hy hz 1) + (characteristic_tilt_moments hy hz 2) + rw [←hd0 n,←hd1 n] at h + change (d n 1)^2 ≤ d n 2*d n 0 at h + rw [div_pow] + have hh:=div_le_div_of_nonneg_right h (sq_nonneg (d n 0)) + exact hh.trans_eq (by field_simp [(hd n 0).ne']) + have hCST n : ((d n 2/d n 0)/(d n 1/d n 0))^2 ≤ d n 3/d n 1 := by + rw [div_div_div_cancel_right₀ (hd n 0).ne'] + have hi j k : IntegrableOn (fun p : ℝ=>p^k*(characteristicRatio y z p^j*(characteristicRatio y z p*stripDensity p))) (Set.Ioi 0) := by + apply (characteristic_tilt_moments hy hz (j+1) k).congr + filter_upwards with p + rw [pow_succ] + ring + have h:=monomialGram_tilt_square n (fun p=>characteristicRatio y z p*stripDensity p) (characteristicRatio y z) + (fun p hp=>mul_pos (characteristicRatio_pos hy hz p) (stripDensity_pos hp)) + (by simpa only [pow_one] using characteristic_tilt_moments hy hz 1) + (by simpa only [pow_one] using hi 1) (hi 2) + have he : (fun p=>characteristicRatio y z p*(characteristicRatio y z p*stripDensity p))= + (fun p=>characteristicRatio y z p^2*stripDensity p) := by funext p;ring + rw [he,←hd1 n,←hd3 n] at h + change (d n 2)^2 ≤ d n 3*d n 1 at h + rw [div_pow] + have hh:=div_le_div_of_nonneg_right h (sq_nonneg (d n 1)) + exact hh.trans_eq (by field_simp [(hd n 1).ne']) + have hs:=strip_polynomial_square_product_bounds hy hz + have ht:=tilted_strip_polynomial_square_product_bounds hy hz + have he : 3*(y-z)/4=2*(3*(y-z)/8) := by ring + simp only [←hd0,←hd1,←hd3,he] at hs ht + have h:=polynomial_product_squeeze (fun n=>d n 1/d n 0) (fun n=>d n 2/d n 0) (fun n=>d n 3/d n 1) + (3*(y-z)/8) (fun n=>div_pos (hd n 1) (hd n 0)) (fun n=>(div_pos (hd n 2) (hd n 0)).le) + hCS hCST hs ht + simpa only [hd0,hd1] using h +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Finset +/-- A parameter-uniform bound for growing arguments of order `N^(3/4)`. -/ +lemma meixner_even_coefficient_uniform {s:ℝ} (hs : (1 : ℝ) / 2 ≤ s) (n j:ℕ) (hj : j ≤ n) : + meixnerCoeff s (2*j) ≤ ((n:ℝ)+1)*(4*((n:ℝ)+1))^(s+1/2) := by + let u:ℝ:=1-1/(2*((n:ℝ)+1)) + have hn:0<(n:ℝ)+1:=by positivity + have hd:0<2*((n:ℝ)+1):=by positivity + have ht:0<1/(2*((n:ℝ)+1)):=by positivity + have ht':1/(2*((n:ℝ)+1)) ≤ 1/2:=by apply one_div_le_one_div_of_le (by norm_num); nlinarith [Nat.cast_nonneg (α:=ℝ) n] + have hu:0mul_nonneg (meixnerCoeff_nonneg (by linarith) k) (pow_nonneg hu.le k)) + have hpow:1/((n:ℝ)+1) ≤ u^(2*j):=by + have hb:=one_add_mul_le_pow (a:=-(1/(2*((n:ℝ)+1)))) (by linarith : (-2:ℝ) ≤ -(1/(2*((n:ℝ)+1)))) (2*j) + change 1+(2*j:ℕ)*(-(1/(2*((n:ℝ)+1)))) ≤ u^(2*j) at hb + have hj':(j:ℝ) ≤ n:=by exact_mod_cast hj + have he:1+(2*j:ℕ)*(-(1/(2*((n:ℝ)+1))))=((n:ℝ)+1-j)/((n:ℝ)+1):=by push_cast;field_simp;ring + rw [he] at hb + exact (div_le_div_of_nonneg_right (by linarith : (1:ℝ) ≤ (n:ℝ)+1-j) hn.le).trans hb + have hgen:meixnerGenerator s u ≤ (4*((n:ℝ)+1))^(s+1/2):=by + have he:1-u=1/(2*((n:ℝ)+1)):=by dsimp [u];ring + have hfactor:(1-u)^(-s-1/2)=(2*((n:ℝ)+1))^(s+1/2):=by + rw [he,show -s-1/2=-(s+1/2) by ring,Real.rpow_neg,one_div,Real.inv_rpow,inv_inv] <;> positivity + unfold meixnerGenerator + rw [hfactor] + have ha:(1+u)^(s-1/2) ≤ (2:ℝ)^(s+1/2):=by + calc + _ ≤ (2:ℝ)^(s-1/2):=Real.rpow_le_rpow (by linarith) (by linarith) (by linarith) + _ ≤ _:=Real.rpow_le_rpow_of_exponent_le (by norm_num) (by linarith) + calc + _ ≤ (2:ℝ)^(s+1/2)*(2*((n:ℝ)+1))^(s+1/2):=mul_le_mul_of_nonneg_right ha (by positivity) + _=(4*((n:ℝ)+1))^(s+1/2):=by rw [←Real.mul_rpow (by norm_num) (by positivity)];congr 1;ring + have hc:=meixnerCoeff_nonneg (show 0 ≤ s by linarith) (2*j) + have ht'':meixnerCoeff s (2*j)/((n:ℝ)+1) ≤ (4*((n:ℝ)+1))^(s+1/2):=by + calc + _=meixnerCoeff s (2*j)*(1/((n:ℝ)+1)):=by ring + _ ≤ _:=mul_le_mul_of_nonneg_left hpow hc + _ ≤ _:=hterm.trans hgen + exact (by simpa only [mul_comm] using (div_le_iff₀ hn).mp ht'') +theorem evenCoefficientKernel_uniform {s:ℝ} (hs : (1 : ℝ) / 2 ≤ s) (n:ℕ) : + evenCoefficientKernel s n ≤ ((n:ℝ)+1)^3*(4*((n:ℝ)+1))^(2*s+1) := by + unfold evenCoefficientKernel + calc + _ ≤ ∑ j∈range (n+1),(((n:ℝ)+1)*(4*((n:ℝ)+1))^(s+1/2))^2:=by + apply sum_le_sum + intro j hj + exact pow_le_pow_left₀ (meixnerCoeff_nonneg (by linarith) _) (meixner_even_coefficient_uniform hs n j (by have := mem_range.mp hj; omega)) 2 + _=((n:ℝ)+1)^3*(4*((n:ℝ)+1))^(2*s+1):=by + simp only [sum_const,card_range,nsmul_eq_mul,Nat.cast_add,Nat.cast_one,mul_pow] + rw [←Real.rpow_natCast ((4*((n:ℝ)+1))^(s+1/2)) 2,←Real.rpow_mul (by positivity)] + norm_num only [Nat.cast_ofNat] + rw [show (s+1/2)*(2:ℝ)=2*s+1 by ring] + ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory +lemma stripDensity_exponential_lower {p : ℝ} (hp : 0 first | rfl | ring +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real MeasureTheory Polynomial +lemma growing_pole_denominator {p z : ℝ} (hp : 0 < p) (hz : 1 ≤ z) : + (p^2+z^2)^2 ≤ z^4*Real.exp (4*p) := by + have hz2 : 1 ≤ z^2 := by nlinarith + have hbase : p^2+z^2 ≤ z^2*(p+1)^2 := by + nlinarith [mul_nonneg (show 0≤z^2-1 by linarith) (sq_nonneg p),mul_nonneg (sq_nonneg z) hp.le] + have he : (Real.exp p)^4=Real.exp (4*p) := by + rw [show (Real.exp p)^4=((Real.exp p)^2)^2 by ring, + pow_two, pow_two,←Real.exp_add,←Real.exp_add] + congr 1 + ring + calc + _ ≤ (z^2*(p+1)^2)^2 := pow_le_pow_left₀ (by positivity) hbase 2 + _ = z^4*(p+1)^4 := by ring + _ ≤ z^4*(Real.exp p)^4 := by + gcongr + exact Real.add_one_le_exp p + _ = _ := by rw [he] +/-- Parameter-uniform pole comparison needed in strip-asymptotics:107. +The constants do not depend on the pole z, which may grow with N. -/ +lemma growing_squaredPole_lower : + ∃ c a : ℝ, 0squaredPoleDensity_pos hz0 hp) + (squaredPoleDensity_moments hz0) (one_ne_zero : (1:Polynomial ℝ)≠0) + have hk := weightedPolynomial_ratio_bound n x (squaredPoleDensity z) + (fun p hp=>squaredPoleDensity_pos hz0 hp) (squaredPoleDensity_moments hz0) 1 (by simp) + simp only [Polynomial.eval_one,one_pow] at hk + exact (div_le_div_of_nonneg_left (by norm_num) hpole hnorm).trans hk +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real Polynomial MeasureTheory +/-- Growing-argument square-product bound for the literal strip measure. No +fixed-parameter asymptotic is applied to a moving evaluation point. -/ +theorem strip_polynomial_square_product_uniform : + ∃ c C : ℝ, 0characteristicRatio y z p^2*stripDensity p)).det / + (monomialGram n stripDensity).det ≤ + C*z^4*((n:ℝ)+1)^3*(4*((n:ℝ)+1))^(2*c*y/Real.pi+1) := by + obtain ⟨c,a,hc,ha,hweight⟩:=growing_squaredPole_lower + let B : ℝ := weightedPolynomialNorm stripDensity 1 + have hB : 0stripDensity_pos hp) + stripDensity_moments (one_ne_zero : (1:Polynomial ℝ)≠0) + refine ⟨c,B/a,hc,by positivity,?_⟩ + intro y z hz hs n + have hz0 : 0sechWeight_pos hc p) (fun p hp=>squaredPoleDensity_pos hz0 hp) + (sechWeight_moments hc) (squaredPoleDensity_moments hz0) (hweight z hz) + have he : weightedPolynomialChristoffel (sechWeight c) n (-(y^2))= + evenCoefficientKernel (c*y/Real.pi) n := by + rw [weightedKernel_sech,scaledPolynomialChristoffel_eq hc, + show (c/Real.pi)^2*-(y^2)=-((c*y/Real.pi)^2) by ring,polynomialChristoffel_negative] + rw [he] at hu + have hkernel := evenCoefficientKernel_uniform hs n + have hnum : weightedPolynomialChristoffel (squaredPoleDensity z) n (-(y^2)) ≤ + (((n:ℝ)+1)^3*(4*((n:ℝ)+1))^(2*(c*y/Real.pi)+1))/(a/z^4) := + hu.trans (div_le_div_of_nonneg_right hkernel (div_pos ha hz4).le) + rw [strip_polynomial_square_product n hz0] + have hb : 0 ≤ (((n:ℝ)+1)^3*(4*((n:ℝ)+1))^(2*(c*y/Real.pi)+1))/(a/z^4) := by positivity + calc + _ ≤ ((((n:ℝ)+1)^3*(4*((n:ℝ)+1))^(2*(c*y/Real.pi)+1))/(a/z^4)) / + weightedPolynomialChristoffel (squaredPoleDensity z) n (-(z^2)) := + div_le_div_of_nonneg_right hnum hkpos.le + _ ≤ ((((n:ℝ)+1)^3*(4*((n:ℝ)+1))^(2*(c*y/Real.pi)+1))/(a/z^4))/(1/B) := + div_le_div_of_nonneg_left hb (by positivity) hlow + _ = _ := by rw [show 2*(c*y/Real.pi)+1=2*c*y/Real.pi+1 by ring];field_simp +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/StripProjection.lean b/lean/OAI/Combinatorics/HoneycombChords/StripProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5d7723cbbdbb92d6b15f6ad85ce51d8d84496a7 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/StripProjection.lean @@ -0,0 +1,278 @@ +import OAI.Combinatorics.HoneycombChords.BoundaryExpansion +import OAI.Combinatorics.HoneycombChords.SpectralCommutation + +namespace OAI + +/-! Strip projection for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet Filter Topology +open scoped Matrix +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +local instance : IsScalarTower Jet Jet Jet where + smul_assoc a b c := mul_assoc a b c +local instance : SMulCommClass Jet Jet Jet where + smul_comm a b c := by simp only [smul_eq_mul]; ring +local instance {ι : Type*} [Fintype ι] : + IsScalarTower Jet (Matrix ι ι Jet) (Matrix ι ι Jet) where + smul_assoc a b c := Matrix.smul_mul a b c +local instance {ι : Type*} [Fintype ι] : + SMulCommClass Jet (Matrix ι ι Jet) (Matrix ι ι Jet) where + smul_comm a b c := (Matrix.mul_smul b a c).symm +noncomputable def inverseAtOne (a : Jet) : Jet := + form 1 (-left a) (-right a) (2*left a*right a-both a) +lemma inverseAtOne_mul (a : Jet) (ha : base a=1) : inverseAtOne a*a=1 := by + apply jet_ext <;> simp [inverseAtOne,ha] <;> try rfl + all_goals change _=0;ring +noncomputable def eigenPair (W : ℕ) : Jet := dualEigenvector W ⬝ᵥ markedEigenvector W +lemma eigenPair_base (W : ℕ) : base (eigenPair W)=1 := by + simp only [eigenPair,dotProduct,base_sum,base_mul,dualEigenvector,markedEigenvector,base_form] + exact arch_pairing W +noncomputable def normalizedDual (W : ℕ) : Column (W+1)→Jet := + fun s=>inverseAtOne (eigenPair W)*dualEigenvector W s +lemma normalized_pair (W : ℕ) : normalizedDual W ⬝ᵥ markedEigenvector W=1 := by + simp only [normalizedDual,dotProduct,mul_assoc,←Finset.mul_sum] + exact inverseAtOne_mul _ (eigenPair_base W) +lemma normalized_dual_eigen (W : ℕ) : + normalizedDual W ᵥ* markedDoubleMatrix (W+1)= + fun s=>form 1 0 0 (eigenCoefficient W)*normalizedDual W s := by + funext s + have hh:=congrFun (source_dual_eigenvector W) s + simp only [normalizedDual,Matrix.vecMul,dotProduct,mul_assoc,←Finset.mul_sum] + change inverseAtOne (eigenPair W)*(dualEigenvector W ᵥ* markedDoubleMatrix (W+1)) s=_ + rw [hh] + ring +noncomputable def markedProjection (W : ℕ) : Matrix (Column (W+1)) (Column (W+1)) Jet := + fun w e=>markedEigenvector W w*normalizedDual W e +noncomputable def markedEigenvalue (W : ℕ) : Jet := form 1 0 0 (eigenCoefficient W) +lemma markedProjection_base (W : ℕ) : + (fun w e=>base (markedProjection W w e))=archProjection W := by + funext w e + simp [markedProjection,normalizedDual,inverseAtOne,markedEigenvector,dualEigenvector,archProjection] +lemma markedProjection_idempotent (W : ℕ) : markedProjection W*markedProjection W=markedProjection W := by + funext w e + simp only [Matrix.mul_apply,markedProjection] + calc + (∑ s,markedEigenvector W w*normalizedDual W s*(markedEigenvector W s*normalizedDual W e))= + markedEigenvector W w*(normalizedDual W ⬝ᵥ markedEigenvector W)*normalizedDual W e := by + simp only [dotProduct,Finset.mul_sum,Finset.sum_mul] + apply Finset.sum_congr rfl + intro s hs + ring + _=markedEigenvector W w*normalizedDual W e := by rw [normalized_pair,mul_one] +lemma markedProjection_mul (W : ℕ) : + markedProjection W*markedDoubleMatrix (W+1)=markedEigenvalue W•markedProjection W := by + funext w e + simp only [Matrix.mul_apply,markedProjection,mul_assoc,←Finset.mul_sum] + change markedEigenvector W w*(normalizedDual W ᵥ* markedDoubleMatrix (W+1)) e=_ + rw [normalized_dual_eigen] + simp only [markedEigenvalue,Matrix.smul_apply,smul_eq_mul,markedProjection] + ring +lemma mul_markedProjection (W : ℕ) : + markedDoubleMatrix (W+1)*markedProjection W=markedEigenvalue W•markedProjection W := by + funext w e + simp only [Matrix.mul_apply,markedProjection,←mul_assoc,←Finset.sum_mul] + change (markedDoubleMatrix (W+1)).mulVec (markedEigenvector W) w*normalizedDual W e=_ + rw [source_marked_eigenvector] + simp only [markedEigenvalue,Matrix.smul_apply,smul_eq_mul,markedProjection] + ring +noncomputable def markedRemainder (W : ℕ) : Matrix (Column (W+1)) (Column (W+1)) Jet := + markedDoubleMatrix (W+1)-markedEigenvalue W•markedProjection W +lemma marked_remainder_orthogonal (W : ℕ) : + markedProjection W*markedRemainder W=0 ∧ markedRemainder W*markedProjection W=0 := by + constructor + · rw [markedRemainder,mul_sub,Matrix.mul_smul (markedProjection W) (markedEigenvalue W),markedProjection_idempotent,markedProjection_mul,sub_self] + · rw [markedRemainder,sub_mul,Matrix.smul_mul (markedEigenvalue W) (markedProjection W),markedProjection_idempotent,mul_markedProjection,sub_self] +lemma double_pow_projection (W m : ℕ) : + physicalDoubleMatrix (W+1)^m*archProjection W=archProjection W := by + induction m with + | zero => simp + | succ m ih => rw [pow_succ,mul_assoc,double_mul_projection,ih] +lemma double_remainder_power (W m : ℕ) : + (physicalDoubleMatrix (W+1)-archProjection W)^(m+1)= + physicalDoubleMatrix (W+1)^(m+1)-archProjection W := by + induction m with + | zero => simp + | succ m ih => + rw [pow_succ,ih,sub_mul,mul_sub,mul_sub,double_pow_projection,projection_mul_double,projection_idempotent] + rw [←pow_succ] + abel +lemma double_remainder_limit (W : ℕ) : + Tendsto (fun m : ℕ=>(physicalDoubleMatrix (W+1)-archProjection W)^m) atTop (𝓝 0) := by + apply (tendsto_add_atTop_iff_nat 1).mp + have hh:=(physical_double_rank_one W).comp (tendsto_add_atTop_nat 1) |>.sub_const (archProjection W) + simpa [Function.comp_def,sub_self,double_remainder_power] using hh +noncomputable def jetBaseHom : Jet→+*ℂ where + toFun:=base + map_one':=rfl + map_zero':=rfl + map_add':=base_add + map_mul':=base_mul +lemma markedRemainder_base (W : ℕ) : + (markedRemainder W).map jetBaseHom=physicalDoubleMatrix (W+1)-archProjection W := by + funext w e + change base (markedDoubleMatrix (W+1) w e-markedEigenvalue W*markedProjection W w e)=_ + rw [show base (markedDoubleMatrix (W+1) w e-markedEigenvalue W*markedProjection W w e)= + base (markedDoubleMatrix (W+1) w e)-base (markedEigenvalue W*markedProjection W w e) from + map_sub baseAdd _ _] + simp only [markedEigenvalue,base_mul,base_form,one_mul] + exact congrFun (congrFun (congrArg₂ (·-·) (marked_base (W+1)) (markedProjection_base W)) w) e + +theorem marked_remainder_limit (W : ℕ) : + Tendsto (fun m : ℕ=>markedRemainder W^m) atTop (𝓝 0) := by + apply stable_jet_powers + have he (m : ℕ) : (fun w e=>base ((markedRemainder W^m) w e))= + (physicalDoubleMatrix (W+1)-archProjection W)^m := by + change (jetBaseHom.mapMatrix) (markedRemainder W^m)=_ + rw [map_pow] + congr 1 + exact markedRemainder_base W + exact (double_remainder_limit W).congr (fun m=>(he m).symm) +lemma orthogonal_pow_add {R : Type*} [Ring R] (a b : R) (hab : a*b=0) (hba : b*a=0) (m : ℕ) : + (a+b)^(m+1)=a^(m+1)+b^(m+1) := by + induction m with + | zero => simp + | succ m ih => + rw [pow_succ,ih,add_mul,mul_add,mul_add] + have h1 : a^(m+1)*b=0 := by rw [pow_succ,mul_assoc,hab,mul_zero] + have h2 : b^(m+1)*a=0 := by rw [pow_succ,mul_assoc,hba,mul_zero] + rw [h1,h2,add_zero,zero_add,←pow_succ,←pow_succ] +lemma markedProjection_pow (W m : ℕ) : markedProjection W^(m+1)=markedProjection W := by + induction m with + | zero => simp + | succ m ih => rw [pow_succ,ih,markedProjection_idempotent] +lemma marked_power_split (W m : ℕ) : + markedDoubleMatrix (W+1)^(m+1)= + markedEigenvalue W^(m+1)•markedProjection W+markedRemainder W^(m+1) := by + have hde : markedDoubleMatrix (W+1)=markedEigenvalue W•markedProjection W+markedRemainder W := by + unfold markedRemainder + abel + rw [hde,orthogonal_pow_add] + · rw [smul_pow,markedProjection_pow] + · rw [Matrix.smul_mul (markedEigenvalue W) (markedProjection W),(marked_remainder_orthogonal W).1,smul_zero] + · rw [Matrix.mul_smul (markedRemainder W) (markedEigenvalue W),(marked_remainder_orthogonal W).2,smul_zero] +lemma markedEigenvalue_pow (W m : ℕ) : + markedEigenvalue W^m=form 1 0 0 ((m:ℂ)*eigenCoefficient W) := by + induction m with + | zero => + apply jet_ext <;> simp [markedEigenvalue] <;> rfl + | succ m ih => + rw [pow_succ,ih] + apply jet_ext <;> simp [markedEigenvalue,Nat.cast_add,Nat.cast_one]; ring +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section + +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet +open scoped Matrix +attribute [local instance 2000] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +attribute [default_instance 101] Matrix.instHMulOfFintypeOfMulOfAddCommMonoid +local instance : IsScalarTower Jet Jet Jet where + smul_assoc a b c := mul_assoc a b c +local instance : SMulCommClass Jet Jet Jet where + smul_comm a b c := by simp only [smul_eq_mul];ring +lemma jetBaseHom_apply (a : Jet) : jetBaseHom a=base a := rfl +lemma jet_kernel_lift {ι : Type*} [Fintype ι] + (M : Matrix ι ι Jet) + (hb : ∀ x : ι→ℂ, (M.map jetBaseHom)*ᵥx=0 → x=0) + (x : ι→Jet) (hx : M*ᵥx=0) : x=0 := by + have h₀ : (fun s=>base (x s))=0 := by + apply hb + funext s + have h:=congrArg base (congrFun hx s) + simpa only [Matrix.mulVec,dotProduct,base_sum,base_mul,Pi.zero_apply, + Matrix.map_apply,jetBaseHom_apply,show base (0:Jet)=0 from rfl] using h + have h₁ : (fun s=>left (x s))=0 := by + apply hb + funext s + have h:=congrArg left (congrFun hx s) + simpa only [Matrix.mulVec,dotProduct,left_sum,left_mul,Pi.zero_apply, + Matrix.map_apply,jetBaseHom_apply,show left (0:Jet)=0 from rfl,congrFun h₀,mul_zero,add_zero] using h + have h₂ : (fun s=>right (x s))=0 := by + apply hb + funext s + have h:=congrArg right (congrFun hx s) + simpa only [Matrix.mulVec,dotProduct,right_sum,right_mul,Pi.zero_apply, + Matrix.map_apply,jetBaseHom_apply,show right (0:Jet)=0 from rfl,congrFun h₀,mul_zero,add_zero] using h + have h₃ : (fun s=>both (x s))=0 := by + apply hb + funext s + have h:=congrArg both (congrFun hx s) + simpa only [Matrix.mulVec,dotProduct,both_sum,both_mul,Pi.zero_apply, + Matrix.map_apply,jetBaseHom_apply,show both (0:Jet)=0 from rfl,congrFun h₀,congrFun h₁,congrFun h₂, + mul_zero,add_zero] using h + funext s + exact jet_ext _ 0 (congrFun h₀ s) (congrFun h₁ s) (congrFun h₂ s) (congrFun h₃ s) +noncomputable def markedGap (W : ℕ) : Matrix (Column (W+1)) (Column (W+1)) Jet := + markedEigenvalue W•(1 : Matrix _ _ Jet)-markedDoubleMatrix (W+1)+markedProjection W +lemma markedGap_base (W : ℕ) : (markedGap W).map jetBaseHom=gapMatrix W := by + funext s t + change base (markedEigenvalue W*(1 : Matrix _ _ Jet) s t- + markedDoubleMatrix (W+1) s t+markedProjection W s t)=_ + rw [base_add,show base (markedEigenvalue W*(1 : Matrix _ _ Jet) s t- + markedDoubleMatrix (W+1) s t)= + base (markedEigenvalue W*(1 : Matrix _ _ Jet) s t)-base (markedDoubleMatrix (W+1) s t) + from map_sub baseAdd _ _] + simp only [base_mul,markedEigenvalue,base_form,one_mul] + rw [congrFun (congrFun (marked_base (W+1)) s) t, + congrFun (congrFun (markedProjection_base W) s) t] + simp only [gapMatrix,Matrix.one_apply,Matrix.add_apply,Matrix.sub_apply] + split_ifs <;> rfl +lemma markedGap_kernel (W : ℕ) (x : Column (W+1)→Jet) + (hx : markedGap W*ᵥx=0) : x=0 := by + apply jet_kernel_lift (markedGap W) _ x hx + intro y hy + rw [markedGap_base] at hy + exact gap_kernel W y hy +lemma marked_fixed_projected (W : ℕ) (x : Column (W+1)→Jet) + (hx : markedDoubleMatrix (W+1)*ᵥx=markedEigenvalue W•x) : + markedProjection W*ᵥx=x := by + have hp : markedGap W*ᵥ(markedProjection W*ᵥx)=markedProjection W*ᵥx := by + rw [Matrix.mulVec_mulVec] + have hg : markedGap W*markedProjection W=markedProjection W := by + rw [markedGap,add_mul,sub_mul,markedProjection_idempotent,mul_markedProjection, + Matrix.smul_mul (markedEigenvalue W) (1 : Matrix _ _ Jet),one_mul,sub_self,zero_add] + rw [hg] + have hg : markedGap W*ᵥx=markedProjection W*ᵥx := by + rw [markedGap,Matrix.add_mulVec,Matrix.sub_mulVec,Matrix.smul_mulVec, + Matrix.one_mulVec,hx,sub_self,zero_add] + apply sub_eq_zero.mp + apply markedGap_kernel W + rw [Matrix.mulVec_sub,hp,hg,sub_self] +noncomputable def commonScalar (W : ℕ) + (M : Matrix (Column (W+1)) (Column (W+1)) Jet) : Jet := + normalizedDual W ⬝ᵥ (M*ᵥmarkedEigenvector W) +lemma markedProjection_mulVec (W : ℕ) (x : Column (W+1)→Jet) : + markedProjection W*ᵥx=(normalizedDual W ⬝ᵥ x)•markedEigenvector W := by + funext s + simp only [markedProjection,Matrix.mulVec,dotProduct,Pi.smul_apply,smul_eq_mul, + Finset.sum_mul] + apply Finset.sum_congr rfl + intro t ht + ring + +lemma commuting_common_line (W : ℕ) + (M : Matrix (Column (W+1)) (Column (W+1)) Jet) + (hM : Commute (markedDoubleMatrix (W+1)) M) : + M*ᵥmarkedEigenvector W=commonScalar W M•markedEigenvector W := by + have hx : markedDoubleMatrix (W+1)*ᵥ(M*ᵥmarkedEigenvector W)= + markedEigenvalue W•(M*ᵥmarkedEigenvector W) := by + rw [Matrix.mulVec_mulVec,hM.eq,←Matrix.mulVec_mulVec,source_marked_eigenvector] + change M*ᵥ(markedEigenvalue W•markedEigenvector W)=_ + rw [Matrix.mulVec_smul] + have hp:=marked_fixed_projected W (M*ᵥmarkedEigenvector W) hx + rw [markedProjection_mulVec] at hp + exact hp.symm +end CriticalHoneycomb.Transfer.RasterGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/TaylorInterpolation.lean b/lean/OAI/Combinatorics/HoneycombChords/TaylorInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..de439df5cc7e9de0838a6d2682384e9a73fcec3a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/TaylorInterpolation.lean @@ -0,0 +1,648 @@ +import OAI.Combinatorics.HoneycombChords.TranslatedJets + +namespace OAI + +/-! Translated Taylor minors and physical interpolation residual bounds. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset + +lemma polynomialJet_X_pow_above {k j : ℕ} (h : k < j) (x : ℝ) : + polynomialJet ((X:Polynomial ℝ)^k) x j=0 := by + simp [polynomialJet_X_pow,Nat.choose_eq_zero_of_lt h] + +lemma polynomialJet_X_pow_sum (k : ℕ) (x y : ℝ) : + ∑ j∈range (k+1),polynomialJet ((X:Polynomial ℝ)^k) x j*y^j=(x+y)^k := by + have h := (taylor x ((X:Polynomial ℝ)^k)).eval_eq_sum_range y + rw [natDegree_taylor,natDegree_X_pow] at h + simpa only [polynomialJet,taylor_eval,eval_pow,eval_X,add_comm] using h.symm + +noncomputable def kernelTaylorTerm (r : ℕ) (b x y : ℝ) (k j : ℕ) : ℝ := + kernelJetTerm r j b x k*y^j + +lemma kernelTaylorTerm_above (r : ℕ) (b x y : ℝ) {k j : ℕ} (h : k < j) : + kernelTaylorTerm r b x y k j=0 := by + simp only [kernelTaylorTerm,kernelJetTerm,polynomialJet_X_pow_above h,mul_zero,zero_div,zero_mul] + +lemma kernelTaylorTerm_bound (r k j : ℕ) {b x y B X Y : ℝ} + (hB : 1 ≤ B) (hX : 1 ≤ X) (hY : 1 ≤ Y) + (hb : |b| ≤ B) (hx : |x| ≤ X) (hy : |y| ≤ Y) : + ‖kernelTaylorTerm r b x y k j‖ ≤ (4*B*X*Y)^k/(2*k).factorial := by + by_cases hj : j ≤ k + · rw [kernelTaylorTerm,norm_mul,norm_pow,Real.norm_eq_abs y] + calc + ‖kernelJetTerm r j b x k‖*|y|^j ≤ ((4*B*X)^k/(2*k).factorial)*Y^k := + mul_le_mul (kernelJetTerm_bound r j k hB hX hb hx) + ((pow_le_pow_left₀ (abs_nonneg _) hy j).trans (pow_le_pow_right₀ hY hj)) + (by positivity) (by positivity) + _=(4*B*X*Y)^k/(2*k).factorial := by rw [mul_pow];ring + · rw [kernelTaylorTerm_above r b x y (lt_of_not_ge hj),norm_zero] + positivity + +lemma kernelTaylorTerm_norm_row_bound (r k : ℕ) {b x y B X Y : ℝ} + (hB : 1 ≤ B) (hX : 1 ≤ X) (hY : 1 ≤ Y) + (hb : |b| ≤ B) (hx : |x| ≤ X) (hy : |y| ≤ Y) : + ∑' j,‖kernelTaylorTerm r b x y k j‖ ≤ (8*B*X*Y)^k/(2*k).factorial := by + rw [tsum_eq_sum (s:=range (k+1)) (fun j hj => by + rw [kernelTaylorTerm_above r b x y (by simp only [mem_range,not_lt] at hj;omega),norm_zero])] + have hn : ((k+1:ℕ):ℝ) ≤ (2:ℝ)^k := by exact_mod_cast Nat.succ_le_of_lt k.lt_two_pow_self + calc + ∑ j∈range (k+1),‖kernelTaylorTerm r b x y k j‖ ≤ + ∑ j∈range (k+1),(4*B*X*Y)^k/(2*k).factorial := sum_le_sum (fun j _ => kernelTaylorTerm_bound r k j hB hX hY hb hx hy) + _=((k+1:ℕ):ℝ)*((4*B*X*Y)^k/(2*k).factorial) := by simp + _ ≤ (2:ℝ)^k*((4*B*X*Y)^k/(2*k).factorial) := mul_le_mul_of_nonneg_right hn (by positivity) + _=(8*B*X*Y)^k/(2*k).factorial := by rw [←mul_div_assoc,←mul_pow];ring_nf + +lemma kernelTaylorTerm_summable (r : ℕ) (b x y : ℝ) : + Summable (Function.uncurry (kernelTaylorTerm r b x y)) := by + have hn : Summable (fun p : ℕ×ℕ => ‖kernelTaylorTerm r b x y p.1 p.2‖) := by + apply (summable_prod_of_nonneg (fun p => norm_nonneg _)).mpr + constructor + · intro k + apply summable_of_ne_finset_zero (s:=range (k+1)) + intro j hj + rw [kernelTaylorTerm_above r b x y (by simp only [mem_range,not_lt] at hj;omega),norm_zero] + · exact (summable_evenFactorial (show 0 ≤ 8*(|b|+1)*(|x|+1)*(|y|+1) by positivity)).of_nonneg_of_le + (fun k => tsum_nonneg (fun j => norm_nonneg _)) + (fun k => kernelTaylorTerm_norm_row_bound r k (by linarith [abs_nonneg b]) + (by linarith [abs_nonneg x]) (by linarith [abs_nonneg y]) (by linarith) (by linarith) (by linarith)) + exact hn.of_norm + +lemma kernelTaylorTerm_row_sum (r k : ℕ) (b x y : ℝ) : + ∑' j,kernelTaylorTerm r b x y k j=kernelJetTerm r 0 b (x+y) k := by + rw [tsum_eq_sum (s:=range (k+1)) (fun j hj => kernelTaylorTerm_above r b x y (by simp only [mem_range,not_lt] at hj;omega))] + simp only [kernelTaylorTerm,kernelJetTerm,polynomialJet_zero,eval_pow,eval_X] + have hm : (∑ j∈range (k+1),polynomialJet (X^k) b r*polynomialJet (X^k) x j/(2*k).factorial*y^j)= + polynomialJet (X^k) b r/(2*k).factorial*(∑ j∈range (k+1),polynomialJet (X^k) x j*y^j) := by + rw [mul_sum] + apply sum_congr rfl + intro j hj + ring + rw [hm,polynomialJet_X_pow_sum] + ring + +lemma cosineKernelJet_translation_summable (r : ℕ) (b x y : ℝ) : + Summable (fun j => cosineKernelJet r j b x*y^j) := by + have h := (kernelTaylorTerm_summable r b x y).prod_symm.prod + simpa only [Function.uncurry,kernelTaylorTerm,Prod.swap_prod_mk,tsum_mul_right,cosineKernelJet] using h + +lemma cosineKernelJet_translation (r : ℕ) (b x y : ℝ) : + cosineKernelJet r 0 b (x+y)=∑' j,cosineKernelJet r j b x*y^j := by + have h := (kernelTaylorTerm_summable r b x y).tsum_comm + calc + cosineKernelJet r 0 b (x+y)=∑' k,∑' j,kernelTaylorTerm r b x y k j := by + simp only [kernelTaylorTerm_row_sum,cosineKernelJet] + _=∑' j,∑' k,kernelTaylorTerm r b x y k j := h.symm + _=∑' j,cosineKernelJet r j b x*y^j := by + simp only [kernelTaylorTerm,tsum_mul_right,cosineKernelJet] + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Matrix + +lemma cosineKernelJet_at_zero_all (r j : ℕ) (x : ℝ) : + cosineKernelJet r j 0 x=polynomialJet (X^r) x j/(2*r).factorial := by + unfold cosineKernelJet kernelJetTerm + simp only [polynomialJet_at_zero_X_pow] + rw [tsum_eq_single r] + · simp + · intro k hk + simp [hk] + +lemma nodalOrder_initial_zero {b : ℕ → ℝ} {i : ℕ} + (hb : ∀ j,j ≤ i → b j=0) : nodalOrder b i=i := by + unfold nodalOrder + have he : (range i).filter (fun j=>b j=b i)=range i := by + apply filter_eq_self.mpr + intro j hj + rw [hb j (Nat.le_of_lt (mem_range.mp hj)),hb i le_rfl] + rw [he,card_range] + +lemma polynomialJet_sum_coeff (P : Polynomial ℝ) {n : ℕ} (hn : P.natDegree < n) (x : ℝ) (j : ℕ) : + polynomialJet P x j=∑ i : Fin n,P.coeff i*polynomialJet (X^i.val) x j := by + conv_lhs => rw [P.as_sum_range_C_mul_X_pow' hn] + simp only [polynomialJet,map_sum,finsetSum_coeff] + rw [Fin.sum_univ_eq_sum_range (fun i : ℕ=>P.coeff i*((taylor x) (X^i)).coeff j) n] + apply sum_congr rfl + intro i hi + simp [taylor_mul,taylor_C] + +lemma polynomialJet_shifted_power (a : ℝ) (k j : ℕ) : + polynomialJet ((X+Polynomial.C a)^k) (-a) j=if k=j then 1 else 0 := by + simp [polynomialJet,map_add,taylor_X,taylor_C,coeff_X_pow,eq_comm] + + +lemma kernel_coeff_det_zero_missing {n q : ℕ} (b : ℕ → ℝ) (a : ℝ) + (hq : q < n) (hb : ∀ i,i ≤ q → b i=0) (e : Fin n → ℕ) + (hmiss : ∃ k,k ≤ q ∧ ∀ i,e i≠k) : + Matrix.det (fun i j : Fin n=>cosineKernelJet (nodalOrder b j) (e i) (b j) (-a))=0 := by + classical + obtain ⟨k,hk,hmiss⟩ := hmiss + let P : Polynomial ℝ := (X+Polynomial.C a)^k + have hdeg : P.natDegree=k := by simp [P,natDegree_pow] + let v : Fin n → ℝ := fun i=>((2*i.val).factorial:ℝ)*P.coeff i + let A : Matrix (Fin n) (Fin n) ℝ := fun i j=>cosineKernelJet (nodalOrder b j) (e i) (b j) (-a) + have he (i j : Fin n) : A i j*v j=P.coeff j*polynomialJet (X^j.val) (-a) (e i) := by + by_cases hj : j.val ≤ q + · have hb' : b j=0 := hb j hj + have hn : nodalOrder b j=j.val := nodalOrder_initial_zero (fun l hl=>hb l (hl.trans hj)) + dsimp [A,v] + rw [hb',hn,cosineKernelJet_at_zero_all] + field_simp + · have hz : P.coeff j=0 := coeff_eq_zero_of_natDegree_lt (by rw [hdeg];omega) + simp [v,hz] + have hav : A*ᵥ v=0 := by + ext i + simp only [Matrix.mulVec,dotProduct,Pi.zero_apply] + simp_rw [he] + rw [←polynomialJet_sum_coeff P (by rw [hdeg];omega)] + simp [P,polynomialJet_shifted_power,Ne.symm (hmiss i)] + have hv : v≠0 := by + intro h + have hi := congrFun h (⟨k,by omega⟩ : Fin n) + have hc : P.coeff k=1 := by simp [P,coeff_X_add_C_pow] + have hn : (2*k).factorial ≠ 0 := Nat.factorial_ne_zero _ + simp [v,hc,hn] at hi + by_contra hd + have hu : Function.Injective (A.mulVec) := Matrix.mulVec_injective_iff_isUnit.mpr + ((Matrix.isUnit_iff_isUnit_det A).mpr (isUnit_iff_ne_zero.mpr hd)) + exact hv (hu (by rw [hav,Matrix.mulVec_zero])) + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Matrix Finset Filter Topology + +noncomputable def translatedKernelMatrix {n : ℕ} (b : ℕ → ℝ) (a : ℝ) (v : ℕ → ℝ) : + Matrix (Fin n) (Fin n) ℝ := fun i j=>cosineKernelJet (nodalOrder b i) 0 (b i) (-a+v j) +noncomputable def kernelComplementMatrix {n : ℕ} (b : ℕ → ℝ) (a : ℝ) (v : ℕ → ℝ) + (g : ℝ → ℝ) : Matrix (Fin n) (Fin n) ℝ := fun i j=> + cosineKernelJet (nodalOrder b i) 0 (b i) (-a+v j)+ + cosineKernelJet (nodalOrder b i) 0 (b i) (-a)*(g (v j)-1) +noncomputable def kernelOriginFunctional {n : ℕ} (b : ℕ → ℝ) (a : ℝ) (v : ℕ → ℝ) + (g : ℝ → ℝ) : ℝ := + (kernelComplementMatrix (n:=n) b a v g).det/(translatedKernelMatrix (n:=n) b a v).det + +lemma kernel_origin_modified_hasSum {n : ℕ} (r : ℕ) (b a : ℝ) (v : ℕ → ℝ) + (g : ℝ → ℝ) (j : Fin (n+1)) : + HasSum (fun k=>cosineKernelJet r k b (-a)*originPowerData v g k j) + (cosineKernelJet r 0 b (-a+v j)+cosineKernelJet r 0 b (-a)*(g (v j)-1)) := by + have hk : HasSum (fun k=>cosineKernelJet r k b (-a)*(v j)^k) + (cosineKernelJet r 0 b (-a+v j)) := by + rw [cosineKernelJet_translation] + exact (cosineKernelJet_translation_summable r b (-a) (v j)).hasSum + have hs : HasSum (fun k : ℕ=>if k=0 then cosineKernelJet r 0 b (-a)*(g (v j)-1) else 0) + (cosineKernelJet r 0 b (-a)*(g (v j)-1)) := hasSum_ite_eq 0 _ + convert hk.add hs using 1 + funext k + by_cases h:k=0 + · subst k + simp only [originPowerData,ite_true,pow_zero,mul_one] + ring + · simp [originPowerData,h] + +/-- Infinite Cauchy--Binet bound for the exact translated kernel. The only +input on g is the previously proved sparse polynomial-functional inequality. -/ +lemma kernel_origin_det_bounds {n q : ℕ} {a R : ℝ} + (ha : 0 ≤ a) (hR : 0 < R) (hphase : Real.sqrt R*Real.sqrt a < Real.pi/2) + (b v : ℕ → ℝ) (g : ℝ → ℝ) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (hq : q ≤ n) (hbzero : ∀ i,i ≤ q → b i=0) + (hv : ∀ i : Fin (n+1),0 < v i) (hord : StrictMono (fun i : Fin (n+1)=>v i)) + {L U : ℝ} + (hbound : ∀ e : Fin n → ℕ,StrictMono e → + (∀ k,1 ≤ k → k ≤ q → ∃ i,e i+1=k) → L ≤ sparseEval v e g ∧ sparseEval v e g ≤ U) : + L*(translatedKernelMatrix (n:=n+1) b a v).det ≤ (kernelComplementMatrix (n:=n+1) b a v g).det ∧ + (kernelComplementMatrix (n:=n+1) b a v g).det ≤ U*(translatedKernelMatrix (n:=n+1) b a v).det := by + let C : Fin (n+1) → ℕ → ℝ := fun i k=>cosineKernelJet (nodalOrder b i) k (b i) (-a) + let A (m : ℕ) : Matrix (Fin (n+1)) (Fin m) ℝ := fun i k=>C i k + let B (m : ℕ) : Matrix (Fin m) (Fin (n+1)) ℝ := fun k j=>(v j)^k.val + let D (m : ℕ) : Matrix (Fin m) (Fin (n+1)) ℝ := fun k j=>originPowerData v g k j + have hfin (m : ℕ) : L*(A m*B m).det ≤ (A m*D m).det ∧ (A m*D m).det ≤ U*(A m*B m).det := by + apply positive_mixture_finite_bounds C v g hv hord + · intro d hd + exact translated_beta_jet_det_nonneg ha hR hphase b hb hball d hd + · intro d hd hm + exact kernel_coeff_det_zero_missing b a (by omega) hbzero d hm + · exact hbound + have htB : Tendsto (fun m=>A m*B m) atTop (𝓝 (translatedKernelMatrix (n:=n+1) b a v)) := by + apply tendsto_pi_nhds.mpr + intro i + apply tendsto_pi_nhds.mpr + intro j + have h := (cosineKernelJet_translation_summable (nodalOrder b i) (b i) (-a) (v j)).hasSum.tendsto_sum_nat + rw [←cosineKernelJet_translation] at h + convert h using 1 + · funext m + change (∑ k : Fin m,cosineKernelJet (nodalOrder b i) k (b i) (-a)*(v j)^k.val)=_ + exact Fin.sum_univ_eq_sum_range (fun k=>cosineKernelJet (nodalOrder b i) k (b i) (-a)*(v j)^k) m + · rfl + have htD : Tendsto (fun m=>A m*D m) atTop (𝓝 (kernelComplementMatrix (n:=n+1) b a v g)) := by + apply tendsto_pi_nhds.mpr + intro i + apply tendsto_pi_nhds.mpr + intro j + have h := (kernel_origin_modified_hasSum (nodalOrder b i) (b i) a v g j).tendsto_sum_nat + convert h using 1 + · funext m + change (∑ k : Fin m,cosineKernelJet (nodalOrder b i) k (b i) (-a)*originPowerData v g k j)=_ + exact Fin.sum_univ_eq_sum_range (fun k=>cosineKernelJet (nodalOrder b i) k (b i) (-a)*originPowerData v g k j) m + · rfl + have hdet : Continuous (Matrix.det : Matrix (Fin (n+1)) (Fin (n+1)) ℝ → ℝ) := continuous_id.matrix_det + have hB := hdet.continuousAt.tendsto.comp htB + have hD := hdet.continuousAt.tendsto.comp htD + exact ⟨le_of_tendsto_of_tendsto (hB.const_mul L) hD (Eventually.of_forall (fun m=>(hfin m).1)), + le_of_tendsto_of_tendsto hD (hB.const_mul U) (Eventually.of_forall (fun m=>(hfin m).2))⟩ + +lemma translatedKernelMatrix_det_pos {n : ℕ} (b v : ℕ → ℝ) (a : ℝ) + (hb : Monotone (fun i : Fin n=>b i)) (hb0 : ∀ i : Fin n,0 ≤ b i) + (hv : ∀ i : Fin n,a ≤ v i) (hord : StrictMono (fun i : Fin n=>v i)) : + 0 < (translatedKernelMatrix (n:=n) b a v).det := by + apply jetEvaluation_det_pos b (fun i : Fin n=>-a+v i) hb + · intro i j hij + linarith [hord hij] + · exact hb0 + · intro i + linarith [hv i] + +lemma kernel_origin_bounds {n q : ℕ} {a R : ℝ} + (ha : 0 ≤ a) (hR : 0 < R) (hphase : Real.sqrt R*Real.sqrt a < Real.pi/2) + (b v : ℕ → ℝ) (g : ℝ → ℝ) + (hb : Monotone (fun i : Fin (n+1)=>b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (hq : q ≤ n) (hbzero : ∀ i,i ≤ q → b i=0) + (hv : ∀ i : Fin (n+1),0 < v i) (hx : ∀ i : Fin (n+1),a ≤ v i) + (hord : StrictMono (fun i : Fin (n+1)=>v i)) {L U : ℝ} + (hbound : ∀ e : Fin n → ℕ,StrictMono e → + (∀ k,1 ≤ k → k ≤ q → ∃ i,e i+1=k) → L ≤ sparseEval v e g ∧ sparseEval v e g ≤ U) : + L ≤ kernelOriginFunctional (n:=n+1) b a v g ∧ kernelOriginFunctional (n:=n+1) b a v g ≤ U := by + have hd := translatedKernelMatrix_det_pos b v a hb (fun i=>(hball i).1) hx hord + have h := kernel_origin_det_bounds ha hR hphase b v g hb hball hq hbzero hv hord hbound + exact ⟨(le_div_iff₀ hd).mpr h.1,(div_le_iff₀ hd).mpr h.2⟩ + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset + +noncomputable def zeroShiftProduct (u : ℝ) (m : ℕ) (y : ℝ) : ℝ := + (shiftedPole u 0)/(shiftedPole u 0+y)* + (ReciprocalExpr.normalizedPole (shiftedPole u 2)).eval y*(physicalPairTail u m).eval y +noncomputable def oneShiftProduct (u : ℝ) (m : ℕ) (y : ℝ) : ℝ := + (physicalTripleExpr u 0).eval y*(physicalTripleTail u m).eval y + +lemma normalizedFast_tail_poles (u : ℝ) {A : ReciprocalExpr} (hA : A.PolesAbove (shiftedPole u 0)) : + (ReciprocalExpr.mulExpr (ReciprocalExpr.normalizedPole (shiftedPole u 2)) A).PolesAbove (shiftedPole u 0) := + ReciprocalExpr.mulExpr_poles (ReciprocalExpr.normalizedPole_poles (shiftedPole_strictMono u (by omega))) hA +lemma normalizedFast_tail_coeff {u : ℝ} (hu4 : u ≤ 4) {A : ReciprocalExpr} (hA : A.CoeffNonneg) : + (ReciprocalExpr.mulExpr (ReciprocalExpr.normalizedPole (shiftedPole u 2)) A).CoeffNonneg := + ReciprocalExpr.mulExpr_coeff (ReciprocalExpr.normalizedPole_coeff (shiftedPole_pos hu4 _).le) hA +lemma normalizedFast_tail_zero {u : ℝ} (hu4 : u ≤ 4) {A : ReciprocalExpr} (hA : A.eval 0=1) : + (ReciprocalExpr.mulExpr (ReciprocalExpr.normalizedPole (shiftedPole u 2)) A).eval 0=1 := by + rw [ReciprocalExpr.mulExpr_eval,ReciprocalExpr.normalizedPole_zero (shiftedPole_pos hu4 _),hA,mul_one] + +lemma sparse_zero_shift_bounds {n q : ℕ} {u : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (v : ℕ → ℝ) (e : Fin n → ℕ) + (hv : ∀ i,0 < v i) (hord : StrictMono (fun i : Fin (n+1)=>v i)) (he : StrictMono e) + (hq : ∀ k,1 ≤ k → k ≤ q → ∃ i,e i+1=k) (m : ℕ) : + poleProduct v (shiftedPole u 0) (n+1) ≤ sparseEval v e (fun y=>1-zeroShiftProduct u m y) ∧ + sparseEval v e (fun y=>1-zeroShiftProduct u m y) ≤ 2*poleProduct v (shiftedPole u 0) (q+1) := by + let A:=ReciprocalExpr.mulExpr (ReciprocalExpr.normalizedPole (shiftedPole u 2)) (physicalPairTail u m) + have hA:=normalizedFast_tail_poles u (physicalPairTail_poles u m) + have hAp:=normalizedFast_tail_coeff hu4 (physicalPairTail_coeff hu4 m) + have hAz:=normalizedFast_tail_zero hu4 (physicalPairTail_zero hu4 m) + have hAC : A.eval (-shiftedPole u 0) ≤ 2 := by + rw [ReciprocalExpr.mulExpr_eval,slowPole_eval] + exact physicalPairTail_uniform hu hu4 m + have hfunc : (fun y=>1-zeroShiftProduct u m y)=(fun y=>1-(shiftedPole u 0)/(shiftedPole u 0+y)*A.eval y) := by + funext y + simp only [zeroShiftProduct,A,ReciprocalExpr.mulExpr_eval] + ring + rw [hfunc] + exact ⟨sparse_product_lower v e hv hord he (shiftedPole_pos hu4 0) + (ReciprocalExpr.poles_mono (shiftedPole_pos hu4 0).le hA) hAp hAz, + (sparse_product_upper v e hv hord he hq (shiftedPole_pos hu4 0) hA hAp hAz).trans + (mul_le_mul_of_nonneg_right hAC (poleProduct_pos v hv (shiftedPole_pos hu4 0) _).le)⟩ + +lemma sparse_one_shift_bounds {n q : ℕ} {u : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (v : ℕ → ℝ) (e : Fin n → ℕ) + (hv : ∀ i,0 < v i) (hord : StrictMono (fun i : Fin (n+1)=>v i)) (he : StrictMono e) + (hq : ∀ k,1 ≤ k → k ≤ q → ∃ i,e i+1=k) (m : ℕ) : + (1/2:ℝ)*poleProduct v (shiftedPole u 0) (n+1) ≤ sparseEval v e (fun y=>1-oneShiftProduct u m y) ∧ + sparseEval v e (fun y=>1-oneShiftProduct u m y) ≤ 2*poleProduct v (shiftedPole u 0) (q+1) := by + let A:=physicalTripleTail u m + let B:=ReciprocalExpr.mulExpr (ReciprocalExpr.normalizedPole (shiftedPole u 2)) A + let p:=ReciprocalExpr.tripleWeight (shiftedPole u 0) (shiftedPole u 1) (shiftedPole u 2) + have hp:=ReciprocalExpr.tripleWeight_pos (shiftedPole_pos hu4 0) + (shiftedPole_strictMono u (by omega : 0<1)) (shiftedPole_strictMono u (by omega : 1<2)) + have hp1:=ReciprocalExpr.tripleWeight_lt_one (shiftedPole_pos hu4 0) + (shiftedPole_strictMono u (by omega : 0<1)) (shiftedPole_strictMono u (by omega : 1<2)) + have hA:=physicalTripleTail_poles u m + have hAp:=physicalTripleTail_coeff hu4 m + have hAz:=physicalTripleTail_zero hu4 m + have hBC : B.eval (-shiftedPole u 0) ≤ 2 := by + rw [ReciprocalExpr.mulExpr_eval,slowPole_eval] + exact physicalTripleTail_uniform hu hu4 m + have hAC : A.eval (-shiftedPole u 0) ≤ 2 := by + apply le_trans _ hBC + rw [ReciprocalExpr.mulExpr_eval,slowPole_eval] + exact le_mul_of_one_le_left (ReciprocalExpr.eval_nonneg hA hAp le_rfl) + (poleTailRatio_ge_one hu4 (by omega)) + have h:=sparse_mixture_bounds v e hv hord he hq (shiftedPole_pos hu4 0) hp.le hp1.le + hA hAp hAz (normalizedFast_tail_poles u hA) (normalizedFast_tail_coeff hu4 hAp) + (normalizedFast_tail_zero hu4 hAz) hAC hBC + have hfunc : (fun y=>1-oneShiftProduct u m y)= + (fun y=>1-(p*((shiftedPole u 0)/(shiftedPole u 0+y)*A.eval y)+(1-p)*B.eval y)) := by + funext y + simp only [oneShiftProduct,physicalTripleExpr,Nat.mul_zero,Nat.zero_add, + ReciprocalExpr.tripleFactor,ReciprocalExpr.eval,ReciprocalExpr.normalizedPole_eval, + B,ReciprocalExpr.mulExpr_eval] + change 1-(p*((shiftedPole u 0)/(shiftedPole u 0+y))+(1-p)*((shiftedPole u 2)/(shiftedPole u 2+y)))*A.eval y=_ + ring + rw [hfunc] + exact ⟨(mul_le_mul_of_nonneg_right (physical_first_weight_half hu hu4) + (poleProduct_pos v hv (shiftedPole_pos hu4 0) _).le).trans h.1,h.2⟩ + +lemma kernel_zero_shift_bounds {n q : ℕ} {u R : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hR : 0 < R) (hphase : Real.sqrt R*Real.sqrt u < Real.pi/2) + (b v : ℕ → ℝ) (hb : Monotone (fun i : Fin (n+1)=>b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (hq : q ≤ n) (hbzero : ∀ i,i ≤ q → b i=0) (hv : ∀ i,0 < v i) + (hx : ∀ i : Fin (n+1),u ≤ v i) (hord : StrictMono (fun i : Fin (n+1)=>v i)) (m : ℕ) : + poleProduct v (shiftedPole u 0) (n+1) ≤ kernelOriginFunctional (n:=n+1) b u v (fun y=>1-zeroShiftProduct u m y) ∧ + kernelOriginFunctional (n:=n+1) b u v (fun y=>1-zeroShiftProduct u m y) ≤ 2*poleProduct v (shiftedPole u 0) (q+1) := by + apply kernel_origin_bounds hu hR hphase b v _ hb hball hq hbzero (fun i=>hv i) hx hord + intro e he heq + exact sparse_zero_shift_bounds hu hu4 v e hv hord he heq m + +lemma kernel_one_shift_bounds {n q : ℕ} {u R : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hR : 0 < R) (hphase : Real.sqrt R*Real.sqrt u < Real.pi/2) + (b v : ℕ → ℝ) (hb : Monotone (fun i : Fin (n+1)=>b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (hq : q ≤ n) (hbzero : ∀ i,i ≤ q → b i=0) (hv : ∀ i,0 < v i) + (hx : ∀ i : Fin (n+1),u ≤ v i) (hord : StrictMono (fun i : Fin (n+1)=>v i)) (m : ℕ) : + (1/2:ℝ)*poleProduct v (shiftedPole u 0) (n+1) ≤ kernelOriginFunctional (n:=n+1) b u v (fun y=>1-oneShiftProduct u m y) ∧ + kernelOriginFunctional (n:=n+1) b u v (fun y=>1-oneShiftProduct u m y) ≤ 2*poleProduct v (shiftedPole u 0) (q+1) := by + apply kernel_origin_bounds hu hR hphase b v _ hb hball hq hbzero (fun i=>hv i) hx hord + intro e he heq + exact sparse_one_shift_bounds hu hu4 v e hv hord he heq m + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional +open Finset Filter Topology + +lemma C_ofReal_re (t x : ℝ) : ((C t x).re:ℂ)=C t x := by + unfold C + split_ifs + · rfl + · rfl +lemma hZero_ofReal_re (x : ℝ) : ((hZero x).re:ℂ)=hZero x := by + have h : D x=(((D x).re):ℂ) := by + unfold D + rw [←C_ofReal_re angle x] + norm_num [Complex.mul_re,Complex.sub_re] + unfold hZero + rw [h] + simp +lemma hOne_ofReal_re (x : ℝ) : ((hOne x).re:ℂ)=hOne x := by + change (((C (angle/2) x*hZero x).re):ℂ)=C (angle/2) x*hZero x + rw [←C_ofReal_re (angle/2) x,←hZero_ofReal_re x] + simp +lemma hZero_re_pos {x : ℝ} (hx : -4 ≤ x) : 0 < (hZero x).re := by + rw [hZero_cosh_ratio hx,←C_ofReal_re (angle/2) x,←C_ofReal_re (3*angle/2) x, + ←Complex.ofReal_div,Complex.ofReal_re] + exact div_pos (C_re_pos (by linarith [angle_pos]) (half_angle_pole_condition hx)) + (C_re_pos (by linarith [angle_pos]) (three_half_angle_pole_condition hx)) +lemma hOne_re_pos {x : ℝ} (hx : -4 ≤ x) : 0 < (hOne x).re := by + rw [hOne_cosh_ratio hx,←C_ofReal_re (angle/2) x,←C_ofReal_re (3*angle/2) x, + ←Complex.ofReal_pow,←Complex.ofReal_div,Complex.ofReal_re] + exact div_pos (sq_pos_of_pos (C_re_pos (by linarith [angle_pos]) (half_angle_pole_condition hx))) + (C_re_pos (by linarith [angle_pos]) (three_half_angle_pole_condition hx)) + +namespace StripAsymptotic + +lemma shiftedPole_normalization {u y : ℝ} {n : ℕ} (hu4 : u ≤ 4) (hy : 0 ≤ y) : + ((shiftedPole u n/(shiftedPole u n+y):ℝ):ℂ)=poleFactor n (-u)/poleFactor n (y-u) := by + have hn : (physicalPole n:ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (physicalPole_pos n).ne' + have hd : ((physicalPole n-u+y:ℝ):ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (ne_of_gt (by linarith [physicalPole_ge n])) + unfold shiftedPole poleFactor + push_cast at hd ⊢ + have hd2 : (physicalPole n:ℂ)+((y:ℂ)-u) ≠ 0 := by convert hd using 1 ; ring + field_simp [hn,hd,hd2] + ; ring + +lemma shiftedNumerator_normalization {u y : ℝ} (hu4 : u ≤ 4) (n : ℕ) : + ((1+y/(shiftedPole u n):ℝ):ℂ)=poleFactor n (y-u)/poleFactor n (-u) := by + have hn : (physicalPole n:ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (physicalPole_pos n).ne' + have hd : ((physicalPole n-u:ℝ):ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (shiftedPole_pos hu4 n).ne' + unfold shiftedPole poleFactor + push_cast at hd ⊢ + have hd2 : (physicalPole n:ℂ)+ -(u:ℂ) ≠ 0 := by simpa only [sub_eq_add_neg] using hd + field_simp [hn,hd,hd2] + ; ring + +lemma pair_shift_ratio {u y : ℝ} (hu4 : u ≤ 4) (hy : 0 ≤ y) (n : ℕ) : + (((physicalPairExpr u n).eval y):ℂ)= + (poleFactor (3*n) (y-u)*poleFactor (3*n+2) (y-u))⁻¹ / + (poleFactor (3*n) (-u)*poleFactor (3*n+2) (-u))⁻¹ := by + rw [physicalPairExpr,ReciprocalExpr.mulExpr_eval,ReciprocalExpr.normalizedPole_eval, + ReciprocalExpr.normalizedPole_eval,Complex.ofReal_mul,shiftedPole_normalization hu4 hy, + shiftedPole_normalization hu4 hy] + simp only [inv_div_inv,mul_div_mul_comm] +lemma triple_shift_ratio {u y : ℝ} (hu4 : u ≤ 4) (hy : 0 ≤ y) (n : ℕ) : + (((physicalTripleExpr u n).eval y):ℂ)= + (poleFactor (3*n+1) (y-u)/(poleFactor (3*n) (y-u)*poleFactor (3*n+2) (y-u))) / + (poleFactor (3*n+1) (-u)/(poleFactor (3*n) (-u)*poleFactor (3*n+2) (-u))) := by + rw [physicalTripleExpr,ReciprocalExpr.tripleFactor_eval (shiftedPole_pos hu4 _) + (shiftedPole_strictMono u (by omega)) (shiftedPole_strictMono u (by omega)) + (ne_of_gt (add_pos_of_pos_of_nonneg (shiftedPole_pos hu4 _) hy)) + (ne_of_gt (add_pos_of_pos_of_nonneg (shiftedPole_pos hu4 _) hy))] + rw [Complex.ofReal_mul,Complex.ofReal_mul,shiftedNumerator_normalization hu4, + shiftedPole_normalization hu4 hy,shiftedPole_normalization hu4 hy] + field_simp + + +lemma zeroShiftProduct_eq_prod (u y : ℝ) (m : ℕ) : + zeroShiftProduct u m y=∏ j ∈ range (m+1),(physicalPairExpr u j).eval y := by + rw [prod_range_succ'] + simp only [zeroShiftProduct,physicalPairTail,ReciprocalExpr.rangeProduct_eval, + physicalPairExpr,Nat.mul_zero,Nat.zero_add,ReciprocalExpr.mulExpr_eval, + ReciprocalExpr.normalizedPole_eval] + ring +lemma oneShiftProduct_eq_prod (u y : ℝ) (m : ℕ) : + oneShiftProduct u m y=∏ j ∈ range (m+1),(physicalTripleExpr u j).eval y := by + rw [prod_range_succ'] + simp only [oneShiftProduct,physicalTripleTail,ReciprocalExpr.rangeProduct_eval] + ring + +lemma zeroShiftProduct_ratio {u y : ℝ} (hu4 : u ≤ 4) (hy : 0 ≤ y) (m : ℕ) : + ((zeroShiftProduct u m y):ℂ)=hZeroProduct (m+1) (y-u)/hZeroProduct (m+1) (-u) := by + rw [zeroShiftProduct_eq_prod,Complex.ofReal_prod] + simp only [pair_shift_ratio hu4 hy,prod_div_distrib,hZeroProduct] +lemma oneShiftProduct_ratio {u y : ℝ} (hu4 : u ≤ 4) (hy : 0 ≤ y) (m : ℕ) : + ((oneShiftProduct u m y):ℂ)=hOneProduct (m+1) (y-u)/hOneProduct (m+1) (-u) := by + rw [oneShiftProduct_eq_prod,Complex.ofReal_prod] + simp only [triple_shift_ratio hu4 hy,prod_div_distrib,hOneProduct] + +lemma tendsto_zeroShiftProduct {u y : ℝ} (hu4 : u ≤ 4) (hy : 0 ≤ y) : + Tendsto (fun m=>zeroShiftProduct u m y) atTop (𝓝 ((hZero (y-u)).re/(hZero (-u)).re)) := by + have h:=((tendsto_hZeroProduct (by linarith : -4 ≤ y-u)).div + (tendsto_hZeroProduct (by linarith : -4 ≤ -u)) + (by rw [←hZero_ofReal_re (-u)];exact Complex.ofReal_ne_zero.mpr (hZero_re_pos (by linarith)).ne')).comp + (tendsto_add_atTop_nat 1) + simp only [Function.comp_def,Pi.div_apply,←zeroShiftProduct_ratio hu4 hy] at h + have hr:=Complex.continuous_re.continuousAt.tendsto.comp h + have he : (hZero (y-u)/hZero (-u)).re=(hZero (y-u)).re/(hZero (-u)).re := by + conv_lhs => rw [←hZero_ofReal_re (y-u),←hZero_ofReal_re (-u),←Complex.ofReal_div,Complex.ofReal_re] + simpa only [Function.comp_def,Complex.ofReal_re,he] using hr +lemma tendsto_oneShiftProduct {u y : ℝ} (hu4 : u ≤ 4) (hy : 0 ≤ y) : + Tendsto (fun m=>oneShiftProduct u m y) atTop (𝓝 ((hOne (y-u)).re/(hOne (-u)).re)) := by + have h:=((tendsto_hOneProduct (by linarith : -4 ≤ y-u)).div + (tendsto_hOneProduct (by linarith : -4 ≤ -u)) + (by rw [←hOne_ofReal_re (-u)];exact Complex.ofReal_ne_zero.mpr (hOne_re_pos (by linarith)).ne')).comp + (tendsto_add_atTop_nat 1) + simp only [Function.comp_def,Pi.div_apply,←oneShiftProduct_ratio hu4 hy] at h + have hr:=Complex.continuous_re.continuousAt.tendsto.comp h + have he : (hOne (y-u)/hOne (-u)).re=(hOne (y-u)).re/(hOne (-u)).re := by + conv_lhs => rw [←hOne_ofReal_re (y-u),←hOne_ofReal_re (-u),←Complex.ofReal_div,Complex.ofReal_re] + simpa only [Function.comp_def,Complex.ofReal_re,he] using hr + +end StripAsymptotic +end CriticalHoneycomb.FiniteFunctional + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Finset Filter Topology Matrix + +lemma kernelOriginFunctional_tendsto {n : ℕ} (b v : ℕ → ℝ) (a : ℝ) + (f : ℕ → ℝ → ℝ) (g : ℝ → ℝ) + (hf : ∀ i : Fin n,Tendsto (fun m=>f m (v i)) atTop (𝓝 (g (v i)))) : + Tendsto (fun m=>kernelOriginFunctional (n:=n) b a v (f m)) atTop + (𝓝 (kernelOriginFunctional (n:=n) b a v g)) := by + have ht : Tendsto (fun m=>kernelComplementMatrix (n:=n) b a v (f m)) atTop + (𝓝 (kernelComplementMatrix (n:=n) b a v g)) := by + apply tendsto_pi_nhds.mpr + intro i + apply tendsto_pi_nhds.mpr + intro j + exact tendsto_const_nhds.add ((hf j |>.sub_const 1).const_mul _) + have hd : Continuous (Matrix.det : Matrix (Fin n) (Fin n) ℝ → ℝ) := continuous_id.matrix_det + exact (hd.continuousAt.tendsto.comp ht).div_const _ + + +lemma kernel_hZero_bounds {n q : ℕ} {u R : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hR : 0 < R) (hphase : Real.sqrt R*Real.sqrt u < Real.pi/2) + (b v : ℕ → ℝ) (hb : Monotone (fun i : Fin (n+1)=>b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (hq : q ≤ n) (hbzero : ∀ i,i ≤ q → b i=0) (hv : ∀ i,0 < v i) + (hx : ∀ i : Fin (n+1),u ≤ v i) (hord : StrictMono (fun i : Fin (n+1)=>v i)) : + poleProduct v (shiftedPole u 0) (n+1) ≤ + kernelOriginFunctional (n:=n+1) b u v (fun y=>1-(hZero (y-u)).re/(hZero (-u)).re) ∧ + kernelOriginFunctional (n:=n+1) b u v (fun y=>1-(hZero (y-u)).re/(hZero (-u)).re) ≤ + 2*poleProduct v (shiftedPole u 0) (q+1) := by + have ht := kernelOriginFunctional_tendsto (n:=n+1) b v u + (fun m y=>1-zeroShiftProduct u m y) (fun y=>1-(hZero (y-u)).re/(hZero (-u)).re) + (fun i=>tendsto_const_nhds.sub (tendsto_zeroShiftProduct hu4 (hv i).le)) + have h m := kernel_zero_shift_bounds hu hu4 hR hphase b v hb hball hq hbzero hv hx hord m + exact ⟨le_of_tendsto_of_tendsto tendsto_const_nhds ht (Eventually.of_forall (fun m=>(h m).1)), + le_of_tendsto_of_tendsto ht tendsto_const_nhds (Eventually.of_forall (fun m=>(h m).2))⟩ + +lemma kernel_hOne_bounds {n q : ℕ} {u R : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) (hR : 0 < R) (hphase : Real.sqrt R*Real.sqrt u < Real.pi/2) + (b v : ℕ → ℝ) (hb : Monotone (fun i : Fin (n+1)=>b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (hq : q ≤ n) (hbzero : ∀ i,i ≤ q → b i=0) (hv : ∀ i,0 < v i) + (hx : ∀ i : Fin (n+1),u ≤ v i) (hord : StrictMono (fun i : Fin (n+1)=>v i)) : + (1/2:ℝ)*poleProduct v (shiftedPole u 0) (n+1) ≤ + kernelOriginFunctional (n:=n+1) b u v (fun y=>1-(hOne (y-u)).re/(hOne (-u)).re) ∧ + kernelOriginFunctional (n:=n+1) b u v (fun y=>1-(hOne (y-u)).re/(hOne (-u)).re) ≤ + 2*poleProduct v (shiftedPole u 0) (q+1) := by + have ht := kernelOriginFunctional_tendsto (n:=n+1) b v u + (fun m y=>1-oneShiftProduct u m y) (fun y=>1-(hOne (y-u)).re/(hOne (-u)).re) + (fun i=>tendsto_const_nhds.sub (tendsto_oneShiftProduct hu4 (hv i).le)) + have h m := kernel_one_shift_bounds hu hu4 hR hphase b v hb hball hq hbzero hv hx hord m + exact ⟨le_of_tendsto_of_tendsto tendsto_const_nhds ht (Eventually.of_forall (fun m=>(h m).1)), + le_of_tendsto_of_tendsto ht tendsto_const_nhds (Eventually.of_forall (fun m=>(h m).2))⟩ + +lemma source_translation_phase {u : ℝ} (hu4 : u ≤ 4) : + Real.sqrt (angle^2)*Real.sqrt u < Real.pi/2 := by + rw [Real.sqrt_sq angle_pos.le] + have hu : Real.sqrt u ≤ 2 := by + have h := Real.sqrt_le_sqrt hu4 + norm_num at h + exact h + have hp:=Real.pi_pos + calc + angle*Real.sqrt u ≤ angle*2 := mul_le_mul_of_nonneg_left hu angle_pos.le + _ < Real.pi/2 := by unfold angle; linarith + +/-- Physical sorted flag specialization; all original confluent nodes remain. -/ +lemma source_hZero_kernel_bounds {N : ℕ} (hN : 1 ≤ N) {u : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) {t : ℝ} (ht : 0x i)) : + poleProduct (fun j=>x j+u) (shiftedPole u 0) (2*N+1) ≤ + kernelOriginFunctional (n:=2*N+1) (interiorKnotLabels N t) u (fun j=>x j+u) + (fun y=>1-(hZero (y-u)).re/(hZero (-u)).re) ∧ + kernelOriginFunctional (n:=2*N+1) (interiorKnotLabels N t) u (fun j=>x j+u) + (fun y=>1-(hZero (y-u)).re/(hZero (-u)).re) ≤ + 2*poleProduct (fun j=>x j+u) (shiftedPole u 0) N := by + have h := kernel_hZero_bounds (n:=2*N) (q:=N-1) hu hu4 (sq_pos_of_pos angle_pos) + (source_translation_phase hu4) (interiorKnotLabels N t) (fun j=>x j+u) + (fun _ _ hij=>interiorKnot_monotone N ht htL hij) + (fun i=>⟨interiorKnot_nonneg N i t,interiorKnot_le N i ht htL⟩) + (by omega) (by intro i hi; simp [interiorKnotLabels,show iadd_pos_of_pos_of_nonneg (hx i) hu) + (fun i=>by linarith [hx i]) (fun i j hij=>by linarith [hord hij]) + have he : N-1+1=N := by omega + simpa only [he] using h + +lemma source_hOne_kernel_bounds {N : ℕ} (hN : 1 ≤ N) {u : ℝ} + (hu : 0 ≤ u) (hu4 : u ≤ 4) {t : ℝ} (ht : 0x i)) : + (1/2:ℝ)*poleProduct (fun j=>x j+u) (shiftedPole u 0) (2*N+1) ≤ + kernelOriginFunctional (n:=2*N+1) (interiorKnotLabels N t) u (fun j=>x j+u) + (fun y=>1-(hOne (y-u)).re/(hOne (-u)).re) ∧ + kernelOriginFunctional (n:=2*N+1) (interiorKnotLabels N t) u (fun j=>x j+u) + (fun y=>1-(hOne (y-u)).re/(hOne (-u)).re) ≤ + 2*poleProduct (fun j=>x j+u) (shiftedPole u 0) N := by + have h := kernel_hOne_bounds (n:=2*N) (q:=N-1) hu hu4 (sq_pos_of_pos angle_pos) + (source_translation_phase hu4) (interiorKnotLabels N t) (fun j=>x j+u) + (fun _ _ hij=>interiorKnot_monotone N ht htL hij) + (fun i=>⟨interiorKnot_nonneg N i t,interiorKnot_le N i ht htL⟩) + (by omega) (by intro i hi; simp [interiorKnotLabels,show iadd_pos_of_pos_of_nonneg (hx i) hu) + (fun i=>by linarith [hx i]) (fun i j hij=>by linarith [hord hij]) + have he : N-1+1=N := by omega + simpa only [he] using h + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/TransferProjection.lean b/lean/OAI/Combinatorics/HoneycombChords/TransferProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..f654477881ca6c71f58635f75b4ef40c74180c14 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/TransferProjection.lean @@ -0,0 +1,457 @@ +import OAI.Combinatorics.HoneycombChords.ColumnPositivity +import OAI.Combinatorics.HoneycombChords.PlanarRows +import OAI.Combinatorics.HoneycombChords.SpectralRows + +namespace OAI + +/-! Transfer projection for critical honeycomb strips. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization PhysicalTiles Filter Topology +open scoped Matrix +noncomputable def columnDelta {n : ℕ} (east : Column n) : DiluteState := + fun xs=>if xs=List.ofFn (fun j=>spinEquiv.symm (east j)) then 1 else 0 +lemma columnDelta_vector {n : ℕ} (east : Column n) : + columnVector n (columnDelta east)=(fun west=>if west=east then 1 else 0) := by + classical + funext west + have he : List.ofFn (fun j=>spinEquiv.symm (west j))= + List.ofFn (fun j=>spinEquiv.symm (east j)) ↔ west=east := by + rw [List.ofFn_injective.eq_iff] + constructor + · intro h + funext j + exact spinEquiv.symm.injective (congrFun h j) + · rintro rfl + rfl + simp [columnVector,columnDelta,he] + +noncomputable def physicalDoubleMatrix (n : ℕ) : Matrix (Column n) (Column n) ℂ := + fun west east=>hardDoubleRow physicalWeights n (columnDelta east) + (List.ofFn (fun j=>spinEquiv.symm (west j))) +lemma physicalDoubleMatrix_eq (n : ℕ) : physicalDoubleMatrix n=rowTransfer n^2 := by + classical + ext west east + have hh:=congrFun (column_pow_mulVec n 2 (columnDelta east)) west + rw [columnDelta_vector] at hh + simp only [Matrix.mulVec,dotProduct,mul_ite,mul_one,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] at hh + change _ = (columnKernel n 1 1^2) west east + rw [hh] + unfold physicalDoubleMatrix columnVector + rw [hardDoubleRow_eq_columns physicalWeights n _ _ (by simp)] + rfl + +theorem physical_double_rank_one (W : ℕ) : + Tendsto (fun m=>physicalDoubleMatrix (W+1)^m) atTop (𝓝 (archProjection W)) := by + rw [physicalDoubleMatrix_eq] + have ht : Tendsto (fun m : ℕ=>2*m) atTop atTop := by + apply tendsto_atTop_mono _ tendsto_id + intro m + dsimp + omega + simpa only [Function.comp_def,pow_mul] using (physical_matrix_limit W).comp ht +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PhysicalTiles Filter Topology +open scoped Matrix +lemma projection_mul_double (W : ℕ) : + archProjection W*physicalDoubleMatrix (W+1)=archProjection W := by + rw [physicalDoubleMatrix_eq,pow_two,←mul_assoc,projection_mul_transfer,projection_mul_transfer] +lemma double_mul_projection (W : ℕ) : + physicalDoubleMatrix (W+1)*archProjection W=archProjection W := by + rw [physicalDoubleMatrix_eq,pow_two,mul_assoc,transfer_mul_projection,transfer_mul_projection] +lemma double_vector_limit (W : ℕ) (v : Column (W+1)→ℂ) : + Tendsto (fun H=>(physicalDoubleMatrix (W+1)^H).mulVec v) atTop + (𝓝 ((archProjection W).mulVec v)) := by + apply tendsto_pi_nhds.mpr + intro s + apply tendsto_finsetSum + intro n hn + exact ((tendsto_pi_nhds.mp ((tendsto_pi_nhds.mp (physical_double_rank_one W)) s)) n).mul_const (v n) +lemma double_fixed_projected (W : ℕ) (v : Column (W+1)→ℂ) + (hv : (physicalDoubleMatrix (W+1)).mulVec v=v) : (archProjection W).mulVec v=v := by + have hi : ∀ H,(physicalDoubleMatrix (W+1)^H).mulVec v=v := by + intro H + induction H with + | zero => simp + | succ H ih => rw [pow_succ',←Matrix.mulVec_mulVec,ih,hv] + have hl:=double_vector_limit W v + simp_rw [hi] at hl + exact tendsto_nhds_unique hl tendsto_const_nhds +noncomputable def gapMatrix (W : ℕ) : Matrix (Column (W+1)) (Column (W+1)) ℂ := + 1-physicalDoubleMatrix (W+1)+archProjection W +lemma projection_mul_gap (W : ℕ) : archProjection W*gapMatrix W=archProjection W := by + simp [gapMatrix,mul_add,mul_sub,projection_mul_double,projection_idempotent] +lemma gap_kernel (W : ℕ) (v : Column (W+1)→ℂ) + (hv : (gapMatrix W).mulVec v=0) : v=0 := by + have hp : (archProjection W).mulVec v=0 := by + rw [←projection_mul_gap W,←Matrix.mulVec_mulVec,hv,Matrix.mulVec_zero] + have hc : (physicalDoubleMatrix (W+1)).mulVec v=v := by + simp only [gapMatrix,Matrix.add_mulVec,Matrix.sub_mulVec,Matrix.one_mulVec,hp,add_zero] at hv + exact (sub_eq_zero.mp hv).symm + rw [←double_fixed_projected W v hc,hp] + +theorem physical_gap_det_ne_zero (W : ℕ) : (gapMatrix W).det≠0 := by + apply IsUnit.ne_zero + apply (Matrix.isUnit_iff_isUnit_det _).mp + apply Matrix.mulVec_injective_iff_isUnit.mp + intro v w h + apply sub_eq_zero.mp + apply gap_kernel W + rw [Matrix.mulVec_sub,h,sub_self] +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.PlanarNormalization +open scoped Matrix +lemma planarRow_smul (i : ℕ) (ts : List TileWeights) (z : ℂ) (f : DiluteState) : + planarRow i ts (fun xs=>z*f xs)=(fun xs=>z*planarRow i ts f xs) := by + induction ts generalizing i f with + | nil => rfl + | cons t ts ih => simp only [planarRow,act_smul,ih] +lemma planarRow_add (i : ℕ) (ts : List TileWeights) (f g : DiluteState) : + planarRow i ts (fun xs=>f xs+g xs)=(fun xs=>planarRow i ts f xs+planarRow i ts g xs) := by + induction ts generalizing i f g with + | nil => rfl + | cons t ts ih => simp only [planarRow,act_add,ih] +noncomputable def fixedSeed (a : Spin) (f : DiluteState) : DiluteState + | b::xs => if b=a then f xs else 0 + | [] => 0 +noncomputable def fixedColumn (t : TileWeights) (n : ℕ) (s z : Spin) (f : DiluteState) : DiluteState := + fun xs=>planarRow 0 (List.replicate n t) (fixedSeed s f) (xs++[z]) +lemma fixedColumn_eq_kernel (t : TileWeights) (n : ℕ) (south north : Spin) + (f : DiluteState) (west : Fin n→Spin) : + fixedColumn t n south north f (List.ofFn west)= + ∑ east : Fin n→Spin,columnKernelSpin t n south north west east*f (List.ofFn east) := by + classical + unfold fixedColumn + rw [planarRow_eq_columnContraction] + unfold columnContraction columnKernelSpin + apply Finset.sum_congr rfl + intro east heast + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro vertical hvertical + simp only [fixedSeed] + split_ifs <;> simp_all +lemma fixedColumn_none (t : TileWeights) (n : ℕ) (f : DiluteState) : + fixedColumn t n none none f=vacuumColumn t n f := by + have he : fixedSeed none f=addOne f := by + funext xs + cases xs with + | nil => rfl + | cons a xs => cases a <;> rfl + unfold fixedColumn vacuumColumn removeOne + rw [he] + +lemma fixed_double_columns (t : TileWeights) (n : ℕ) (f : DiluteState) + (s₁ s₂ z₁ z₂ : Spin) (xs : List Spin) (hx : xs.length=n) : + sourceTwoRows (List.replicate n t) (List.replicate n t) + (fixedSeed s₁ (fixedSeed s₂ f)) (z₁::z₂::xs)= + fixedColumn t n s₁ z₁ (fixedColumn t n s₂ z₂ f) xs := by + rw [←two_rows_eq (List.replicate n t) (List.replicate n t) (by simp) (by simp) _ xs hx z₁ z₂] + rw [show xs++[z₁,z₂]=(xs++[z₁])++[z₂] by simp] + rw [planarRow_suffix 0 _ _ (xs++[z₁]) [z₂] (by simp [hx])] + unfold fixedColumn + apply planarRow_congr_of_length 0 (n+1) _ _ _ _ _ (by simp [hx]) + intro ys hy + cases ys with + | nil => simp at hy + | cons a ys => + simp only [List.cons_append,planarRow_under,fixedSeed] + by_cases ha : a=s₁ + · subst a + simp only [ite_true] + rfl + · simp only [ha,ite_false] + exact congrFun (planarRow_zero 0 (List.replicate n t)) (ys++[z₂]) +end CriticalHoneycomb.Transfer.PlanarNormalization +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization +open scoped Matrix +lemma fixed_column_mulVec (H : ℕ) (south north : PlanarNormalization.Spin) (f : DiluteState) : + (columnKernel H (spinEquiv south) (spinEquiv north)).mulVec (columnVector H f)= + columnVector H (fixedColumn physicalWeights H south north f) := by + classical + funext w + obtain ⟨west,rfl⟩ := (columnSpinEquiv H).surjective w + simp only [columnVector,columnSpinEquiv_apply,Equiv.symm_apply_apply] + rw [fixedColumn_eq_kernel] + unfold Matrix.mulVec dotProduct + rw [←(columnSpinEquiv H).sum_comp] + apply Finset.sum_congr rfl + intro east heast + change columnKernel H (spinEquiv south) (spinEquiv north) + (columnSpinEquiv H west) (columnSpinEquiv H east) * _ = _ + rw [columnKernel_eq_spin] + change _ * f (List.ofFn (fun j => spinEquiv.symm (spinEquiv (east j)))) = _ + simp only [Equiv.symm_apply_apply] +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open BoundaryJet +open scoped Matrix +noncomputable def markedColumn (H : ℕ) : Matrix (Column H) (Column H) Jet := + fun w e=>form (columnKernel H 1 1 w e) (columnKernel H 2 1 w e) + (columnKernel H 1 2 w e) (columnKernel H 2 2 w e) +noncomputable def boundaryProduct (H m : ℕ) (south north : Column m) : Matrix (Column H) (Column H) ℂ := + (List.ofFn (fun i=>columnKernel H (south i) (north i))).prod +lemma boundaryProduct_zero (H : ℕ) (s n : Column 0) : boundaryProduct H 0 s n=1 := rfl +lemma boundaryProduct_cons (H m : ℕ) (a b : Fin 3) (s n : Column m) : + boundaryProduct H (m+1) (Fin.cons a s) (Fin.cons b n)= + columnKernel H a b*boundaryProduct H m s n := by + simp [boundaryProduct,List.ofFn_succ] +lemma vacuum_cons (m : ℕ) : (fun _ : Fin (m+1)=> (1:Fin 3))=Fin.cons 1 (fun _ : Fin m=>1) := by + ext i + cases i using Fin.cases <;> rfl +lemma singleColumn_zero (m : ℕ) : singleColumn (0:Fin (m+1))=Fin.cons 2 (fun _ : Fin m=>1) := by + ext i + cases i using Fin.cases <;> simp [singleColumn] +lemma singleColumn_succ {m : ℕ} (j : Fin m) : singleColumn j.succ=Fin.cons 1 (singleColumn j) := by + funext i + cases i using Fin.cases with + | zero => simp [singleColumn,Ne.symm (Fin.succ_ne_zero j)] + | succ i => simp [singleColumn] +noncomputable def portSumLeft (H m : ℕ) : Matrix (Column H) (Column H) ℂ := + ∑ j : Fin m,boundaryProduct H m (singleColumn j) (fun _=>1) +noncomputable def portSumRight (H m : ℕ) : Matrix (Column H) (Column H) ℂ := + ∑ j : Fin m,boundaryProduct H m (fun _=>1) (singleColumn j) +noncomputable def portSumBoth (H m : ℕ) : Matrix (Column H) (Column H) ℂ := + ∑ j : Fin m,∑ k : Fin m,boundaryProduct H m (singleColumn j) (singleColumn k) +lemma boundaryProduct_vacuum (H m : ℕ) : boundaryProduct H m (fun _=>1) (fun _=>1)=rowTransfer H^m := by + simp [boundaryProduct,rowTransfer,List.ofFn_const,List.prod_replicate] +lemma portSumLeft_succ (H m : ℕ) : portSumLeft H (m+1)= + columnKernel H 2 1*rowTransfer H^m+rowTransfer H*portSumLeft H m := by + simp only [portSumLeft,Fin.sum_univ_succ,singleColumn_zero,singleColumn_succ,vacuum_cons m, + boundaryProduct_cons,boundaryProduct_vacuum,←Finset.mul_sum,rowTransfer] +lemma portSumRight_succ (H m : ℕ) : portSumRight H (m+1)= + columnKernel H 1 2*rowTransfer H^m+rowTransfer H*portSumRight H m := by + simp only [portSumRight,Fin.sum_univ_succ,singleColumn_zero,singleColumn_succ,vacuum_cons m, + boundaryProduct_cons,boundaryProduct_vacuum,←Finset.mul_sum,rowTransfer] +lemma portSumBoth_succ (H m : ℕ) : portSumBoth H (m+1)= + columnKernel H 2 2*rowTransfer H^m+columnKernel H 2 1*portSumRight H m+ + columnKernel H 1 2*portSumLeft H m+rowTransfer H*portSumBoth H m := by + simp only [portSumBoth,Fin.sum_univ_succ,singleColumn_zero,singleColumn_succ, + boundaryProduct_cons,boundaryProduct_vacuum,Finset.sum_add_distrib,←Finset.mul_sum, + portSumLeft,portSumRight,rowTransfer] + abel +lemma marked_power_coords (H m : ℕ) : + (fun w e=>base ((markedColumn H^m) w e))=rowTransfer H^m ∧ + (fun w e=>left ((markedColumn H^m) w e))=portSumLeft H m ∧ + (fun w e=>right ((markedColumn H^m) w e))=portSumRight H m ∧ + (fun w e=>both ((markedColumn H^m) w e))=portSumBoth H m := by + classical + induction m with + | zero => + simp only [pow_zero,portSumLeft,portSumRight,portSumBoth,Fin.sum_univ_zero] + constructor + · ext w e + by_cases h:w=e <;> simp [Matrix.one_apply,h,base] + constructor + · ext w e + by_cases h:w=e <;> simp [Matrix.one_apply,h,left] + constructor + · ext w e + by_cases h:w=e <;> simp [Matrix.one_apply,h,right] + · ext w e + by_cases h:w=e <;> simp [Matrix.one_apply,h,both] + | succ m ih => + rcases ih with ⟨h₀,h₁,h₂,h₃⟩ + have e₀ w e : base ((markedColumn H^m) w e)=(rowTransfer H^m) w e := congrFun (congrFun h₀ w) e + have e₁ w e : left ((markedColumn H^m) w e)=portSumLeft H m w e := congrFun (congrFun h₁ w) e + have e₂ w e : right ((markedColumn H^m) w e)=portSumRight H m w e := congrFun (congrFun h₂ w) e + have e₃ w e : both ((markedColumn H^m) w e)=portSumBoth H m w e := congrFun (congrFun h₃ w) e + simp only [pow_succ',portSumLeft_succ,portSumRight_succ,portSumBoth_succ] + refine ⟨?_,?_,?_,?_⟩ <;> ext w e + · simp only [Matrix.mul_apply,base_sum,base_mul,markedColumn,base_form,e₀,rowTransfer] + · simp only [Matrix.mul_apply,left_sum,left_mul,markedColumn,base_form,left_form,e₀,e₁, + Finset.sum_add_distrib,Matrix.add_apply,rowTransfer] + ac_rfl + · simp only [Matrix.mul_apply,right_sum,right_mul,markedColumn,base_form,right_form,e₀,e₂, + Finset.sum_add_distrib,Matrix.add_apply,rowTransfer] + ac_rfl + · simp only [Matrix.mul_apply,both_sum,both_mul,markedColumn,base_form,left_form,right_form, + both_form,e₀,e₁,e₂,e₃,Finset.sum_add_distrib,Matrix.add_apply,rowTransfer] + ac_rfl + +theorem marked_power_mixed (H m : ℕ) (w e : Column H) : + both ((markedColumn H^m) w e)=∑ j : Fin m,∑ k : Fin m, + prescribedPartition m H w e (singleColumn j) (singleColumn k) := by + have hh:=congrFun (congrFun (marked_power_coords H m).2.2.2 w) e + simpa only [portSumBoth,Matrix.sum_apply,prescribedPartition_eq_transfer,boundaryProduct] using hh +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open PlanarNormalization BoundaryJet +open scoped Matrix + +noncomputable def fixedDoubleMatrix (H : ℕ) (s₁ s₂ z₁ z₂ : Spin) : + Matrix (Column H) (Column H) ℂ := fun west east=> + sourceTwoRows (List.replicate H physicalWeights) (List.replicate H physicalWeights) + (fixedSeed s₁ (fixedSeed s₂ (columnDelta east))) + (z₁::z₂::List.ofFn (fun j=>spinEquiv.symm (west j))) +lemma fixedDoubleMatrix_eq (H : ℕ) (s₁ s₂ z₁ z₂ : Spin) : + fixedDoubleMatrix H s₁ s₂ z₁ z₂= + columnKernel H (spinEquiv s₁) (spinEquiv z₁)* + columnKernel H (spinEquiv s₂) (spinEquiv z₂) := by + classical + funext west east + have hh:=congrFun (fixed_column_mulVec H s₁ z₁ + (fixedColumn physicalWeights H s₂ z₂ (columnDelta east))) west + rw [←fixed_column_mulVec H s₂ z₂,columnDelta_vector,Matrix.mulVec_mulVec] at hh + simp only [Matrix.mulVec,dotProduct,mul_ite,mul_one,mul_zero,Finset.sum_ite_eq', + Finset.mem_univ,ite_true] at hh + rw [hh] + unfold fixedDoubleMatrix columnVector + exact fixed_double_columns _ _ _ _ _ _ _ _ (by simp) + +noncomputable def physicalMarkedK (e : Jet) : Spin→Spin→Jet + | none,none => 1 + | some true,none => e + | none,some true => e + | _,_ => 0 + +noncomputable def markedDoubleMatrix (H : ℕ) : Matrix (Column H) (Column H) Jet := + fun west east=>∑ s₁ : Spin,∑ s₂ : Spin,∑ z₁ : Spin,∑ z₂ : Spin, + physicalMarkedK eL s₁ s₂*physicalMarkedK eR z₁ z₂* + C (fixedDoubleMatrix H s₁ s₂ z₁ z₂ west east) +lemma markedDoubleMatrix_eq (H : ℕ) : markedDoubleMatrix H=markedColumn H^2 := by + classical + funext west east + simp only [markedDoubleMatrix,Fintype.sum_option,Fintype.sum_bool,physicalMarkedK, + zero_mul,mul_zero,one_mul,add_zero,fixedDoubleMatrix_eq,spinEquiv_apply,spinIndex, + Matrix.mul_apply,map_sum,pow_two] + have bL : base eL=0 := rfl + have lL : left eL=1 := rfl + have rL : right eL=0 := rfl + have xL : both eL=0 := rfl + have bR : base eR=0 := rfl + have lR : left eR=0 := rfl + have rR : right eR=1 := rfl + have xR : both eR=0 := rfl + apply jet_ext <;> + simp only [base_add,left_add,right_add,both_add,base_mul,left_mul,right_mul,both_mul, + base_sum,left_sum,right_sum,both_sum,base_C,left_C,right_C,both_C, + markedColumn,base_form,left_form,right_form,both_form, + bL,lL,rL,xL,bR,lR,rR,xR,zero_mul,mul_zero,one_mul,mul_one,zero_add,add_zero, + Finset.sum_add_distrib] <;> + try simp only [zero_add,add_zero,Finset.sum_const_zero] + all_goals abel +end CriticalHoneycomb.Transfer.RasterGrid + +end + +section +namespace CriticalHoneycomb.Transfer.RasterGrid +open Filter Topology +open scoped Matrix + +def spinCharge (i : Fin 3) : ℤ := (i.val:ℤ)-1 +def columnCharge {H : ℕ} (s : Column H) : ℤ := ∑ j,spinCharge (s j) +lemma sourceR_charge (a h v c d : ℂ) (w n s e : Fin 3) + (hz : Planar.sourceR a h v c d (n,w) (s,e)≠0) : + spinCharge w+spinCharge n=spinCharge s+spinCharge e := by + fin_cases w <;> fin_cases n <;> fin_cases s <;> fin_cases e <;> + simp_all [Planar.sourceR,spinCharge] +lemma columnKernel_charge {H : ℕ} (s n : Fin 3) (w e : Column H) + (hz : columnKernel H s n w e≠0) : + columnCharge w+spinCharge n=columnCharge e+spinCharge s := by + classical + obtain ⟨vertical,_,hv⟩:=Finset.exists_ne_zero_of_sum_ne_zero hz + have hs : (Fin.snoc (α:=fun _=>Fin 3) vertical n) 0=s := by + by_contra hn + simp [hn] at hv + have hp : columnProduct w e vertical n≠0 := by simpa [hs] using hv + have hl : ∀ j : Fin H,spinCharge (w j)+spinCharge ((Fin.snoc (α:=fun _=>Fin 3) vertical n) j.succ)= + spinCharge (vertical j)+spinCharge (e j) := by + intro j + apply sourceR_charge + exact (Finset.prod_ne_zero_iff.mp hp) j (Finset.mem_univ j) + have hadd:=congrArg (fun f : Fin H→ℤ=>∑ j,f j) (funext hl) + simp only [Finset.sum_add_distrib] at hadd + have ha:=Fin.sum_univ_succ (fun j : Fin (H+1)=>spinCharge ((Fin.snoc (α:=fun _=>Fin 3) vertical n) j)) + have hb:=Fin.sum_univ_castSucc (fun j : Fin (H+1)=>spinCharge ((Fin.snoc (α:=fun _=>Fin 3) vertical n) j)) + simp only [Fin.snoc_castSucc,Fin.snoc_last] at hb + rw [hs] at ha + unfold columnCharge + omega + +def HasShift {H : ℕ} (M : Matrix (Column H) (Column H) ℂ) (q : ℤ) : Prop := + ∀ w e,M w e≠0→columnCharge w=columnCharge e+q +lemma kernel_hasShift (H : ℕ) (s n : Fin 3) : + HasShift (columnKernel H s n) (spinCharge s-spinCharge n) := by + intro w e hz + have hh:=columnKernel_charge s n w e hz + omega +lemma shift_mul {H : ℕ} {M N : Matrix (Column H) (Column H) ℂ} {q r : ℤ} + (hM : HasShift M q) (hN : HasShift N r) : HasShift (M*N) (q+r) := by + classical + intro w e hz + obtain ⟨s,_,hs⟩:=Finset.exists_ne_zero_of_sum_ne_zero hz + have hm:=hM w s (mul_ne_zero_iff.mp hs).1 + have hn:=hN s e (mul_ne_zero_iff.mp hs).2 + omega +lemma shift_add {H : ℕ} {M N : Matrix (Column H) (Column H) ℂ} {q : ℤ} + (hM : HasShift M q) (hN : HasShift N q) : HasShift (M+N) q := by + intro w e hz + by_cases hm : M w e=0 + · apply hN + intro hn + exact hz (by simp [Matrix.add_apply,hm,hn]) + · exact hM w e hm +lemma transfer_power_shift (H m : ℕ) : HasShift (rowTransfer H^m) 0 := by + classical + induction m with + | zero => + intro w e hz + have he : w=e := by + by_contra hn + simp [pow_zero,hn] at hz + subst e + simp + | succ m ih => + rw [pow_succ'] + simpa [rowTransfer,spinCharge] using shift_mul (kernel_hasShift H 1 1) ih +@[simp] lemma charge_vacuum (H : ℕ) : columnCharge (fun _ : Fin H=>1)=0 := by + simp [columnCharge,spinCharge] +lemma archColumn_charge {W : ℕ} (s : Column (W+1)) (hs : columnCharge s≠0) : archColumn W s=0 := by + have hz : ∀ m,(rowTransfer (W+1)^m) s (fun _=>1)=0 := by + intro m + by_contra hn + have hh:=transfer_power_shift (W+1) m s (fun _=>1) hn + simp only [charge_vacuum,add_zero] at hh + exact hs hh + have hl:=archColumn_limit W s + simp only [hz] at hl + exact tendsto_nhds_unique hl tendsto_const_nhds +lemma archRow_charge {W : ℕ} (s : Column (W+1)) (hs : columnCharge s≠0) : archRow W s=0 := by + have hz : ∀ m,(rowTransfer (W+1)^m) (fun _=>1) s=0 := by + intro m + by_contra hn + have hh:=transfer_power_shift (W+1) m (fun _=>1) s hn + simp only [charge_vacuum,add_zero] at hh + exact hs hh.symm + have hl:=archRow_limit W s + simp only [hz] at hl + exact tendsto_nhds_unique hl tendsto_const_nhds +end CriticalHoneycomb.Transfer.RasterGrid + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/TransformSurjectivity.lean b/lean/OAI/Combinatorics/HoneycombChords/TransformSurjectivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1774aa56105dc37e70ca7277d1e9ef103b84093 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/TransformSurjectivity.lean @@ -0,0 +1,805 @@ +import OAI.Combinatorics.HoneycombChords.HyperbolicTransform + +namespace OAI + +/-! Polynomial and proper rational transforms and surjectivity onto finite interpolation data. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Filter Topology MeasureTheory + +noncomputable def integralJet (u : ℝ) (j : ℕ) (m : ℝ) : ℝ := + ∫ z in Set.Ioi (0 : ℝ), transformJet u j m z + +lemma integralJet_hasDerivAt {u m : ℝ} (j : ℕ) + (h : |m| + |u| < Real.pi / 2) : + HasDerivAt (integralJet u j) (integralJet u (j+1) m) m := by + let a := (Real.pi / 2 + (|u| + |m|)) / 2 + have ha0 : 0 ≤ a := by dsimp [a]; positivity + have ha : |u| + |m| < a := by dsimp [a]; linarith + have hA : a < Real.pi / 2 := by dsimp [a]; linarith + let s := {t : ℝ | |u| + |t| < a} + have hs : s ∈ 𝓝 m := + (isOpen_lt (continuous_const.add continuous_abs) continuous_const).mem_nhds ha + have hmeas : ∀ j t, AEStronglyMeasurable (transformJet u j t) + (volume.restrict (Set.Ioi (0 : ℝ))) := by + intro j t + exact (by unfold transformJet hypJet; fun_prop : Measurable (transformJet u j t)).aestronglyMeasurable + exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le hs + (Filter.Eventually.of_forall (fun t => hmeas j t)) (transformJet_integrable j h) (hmeas (j+1) m) + (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + intro t ht + exact transformJet_norm_le (j+1) hz.le (le_of_lt ht)) + (polynomial_kernel_integrable j ha0 hA) + (ae_of_all _ (fun z t _ => transformJet_hasDerivAt u j t z))).2 + +lemma integralJet_zero_eq {u m : ℝ} (h : |m| + |u| < Real.pi / 2) : + integralJet u 0 m = Real.sin (2*m) / (Real.cos (2*u) + Real.cos (2*m)) := by + simpa only [integralJet, transformJet_zero] using cosh_sinh_kernel_integral h + +lemma integralJet_eq_iteratedDeriv {u m : ℝ} (j : ℕ) + (h : |m| + |u| < Real.pi / 2) : + integralJet u j m = + iteratedDeriv j (fun t => Real.sin (2*t) / (Real.cos (2*u) + Real.cos (2*t))) m := by + induction j generalizing m with + | zero => exact integralJet_zero_eq h + | succ j ih => + have hs : ∀ᶠ t in 𝓝 m, |t| + |u| < Real.pi / 2 := + (isOpen_lt (continuous_abs.add continuous_const) continuous_const).mem_nhds h + have he : integralJet u j =ᶠ[𝓝 m] + iteratedDeriv j (fun t => Real.sin (2*t) / (Real.cos (2*u) + Real.cos (2*t))) := + hs.mono (fun t ht => ih ht) + rw [iteratedDeriv_succ, ← he.deriv_eq] + exact (integralJet_hasDerivAt j h).deriv.symm + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real MeasureTheory Filter Topology Polynomial Finset + +lemma hypJet_odd (j : ℕ) (t : ℝ) : hypJet (2*j+1) t = Real.cosh t := by + simp [hypJet, pow_add, pow_mul, Real.cosh_eq] + +noncomputable def polynomialTransformJet (p : Polynomial ℝ) (k : ℕ) (u : ℝ) : ℝ := + p.sum (fun j a => a * integralJet 0 (2*j+1+k) u) + +lemma polynomialTransformJet_hasDerivAt (p : Polynomial ℝ) (k : ℕ) {u : ℝ} + (hu : |u| < Real.pi/2) : + HasDerivAt (polynomialTransformJet p k) (polynomialTransformJet p (k+1) u) u := by + unfold polynomialTransformJet Polynomial.sum + have hd (j : ℕ) := (integralJet_hasDerivAt (2*j+1+k) + (by simpa using hu : |u| + |(0:ℝ)| < Real.pi/2)).const_mul (p.coeff j) + simpa only [Nat.add_assoc] using HasDerivAt.fun_sum (fun j (_ : j ∈ p.support) => hd j) + +lemma polynomialTransformJet_add (p q : Polynomial ℝ) (k : ℕ) (u : ℝ) : + polynomialTransformJet (p+q) k u = polynomialTransformJet p k u + polynomialTransformJet q k u := by + unfold polynomialTransformJet + exact Polynomial.sum_add_index p q _ (by intros; simp) (by intros; ring) + +lemma polynomialTransformJet_smul (a : ℝ) (p : Polynomial ℝ) (k : ℕ) (u : ℝ) : + polynomialTransformJet (a • p) k u = a * polynomialTransformJet p k u := by + unfold polynomialTransformJet + rw [Polynomial.sum_smul_index p a _ (by intros; simp)] + simp only [Polynomial.sum, Finset.mul_sum] + apply sum_congr rfl + intro i hi + ring + +lemma polynomialTransformJet_X_mul (p : Polynomial ℝ) (k : ℕ) (u : ℝ) : + polynomialTransformJet (X*p) k u = polynomialTransformJet p (k+2) u := by + induction p using Polynomial.induction_on' with + | add p q hp hq => + rw [mul_add, polynomialTransformJet_add, polynomialTransformJet_add, hp, hq] + | monomial n a => + rw [Polynomial.X_mul_monomial] + simp only [polynomialTransformJet, Polynomial.sum_monomial_index, zero_mul] + congr 2 + omega + +lemma polynomialTransformJet_C (a : ℝ) (k : ℕ) (u : ℝ) : + polynomialTransformJet (Polynomial.C a) k u = a * integralJet 0 (1+k) u := by + simp [polynomialTransformJet, Polynomial.sum_C_index] + +lemma polynomialTransformJet_two {p : Polynomial ℝ} {u : ℝ} (hu : |u| < Real.pi/2) : + iteratedDeriv 2 (polynomialTransformJet p 0) u = polynomialTransformJet (X*p) 0 u := by + have hn : ∀ᶠ t in 𝓝 u, |t| < Real.pi/2 := + (isOpen_lt continuous_abs continuous_const).mem_nhds hu + have he : deriv (polynomialTransformJet p 0) =ᶠ[𝓝 u] polynomialTransformJet p 1 := + hn.mono (fun t ht => (polynomialTransformJet_hasDerivAt p 0 ht).deriv) + rw [show iteratedDeriv 2 (polynomialTransformJet p 0) = deriv (deriv (polynomialTransformJet p 0)) by rw [iteratedDeriv_succ, iteratedDeriv_one], + he.deriv_eq, (polynomialTransformJet_hasDerivAt p 1 hu).deriv, polynomialTransformJet_X_mul] + +noncomputable def polynomialKernel (p : Polynomial ℝ) (u z : ℝ) : ℝ := + p.eval (z^2) * Real.cosh (u*z) * z / Real.sinh (Real.pi*z/2) + +lemma polynomialKernel_eq_sum (p : Polynomial ℝ) (u z : ℝ) : + polynomialKernel p u z = + ∑ j ∈ p.support, p.coeff j * transformJet 0 (2*j+1) u z := by + simp only [polynomialKernel, Polynomial.eval_eq_sum, Polynomial.sum, Finset.sum_mul, Finset.sum_div] + apply Finset.sum_congr rfl + intro j hj + simp only [transformJet, zero_mul, Real.cosh_zero, one_mul, hypJet_odd] + rw [pow_add, pow_one, pow_mul] + ring + +lemma polynomialKernel_integrable (p : Polynomial ℝ) {u : ℝ} (hu : |u| < Real.pi/2) : + IntegrableOn (polynomialKernel p u) (Set.Ioi 0) := by + have h : ∀ j, IntegrableOn (fun z => p.coeff j * transformJet 0 (2*j+1) u z) (Set.Ioi 0) := + fun j => (transformJet_integrable (2*j+1) (by simpa using hu)).const_mul (p.coeff j) + simpa only [IntegrableOn, ← polynomialKernel_eq_sum] using integrable_finsetSum p.support (fun j _ => h j) + +lemma polynomialTransform_eq_integral (p : Polynomial ℝ) {u : ℝ} (hu : |u| < Real.pi/2) : + polynomialTransformJet p 0 u = ∫ z in Set.Ioi (0:ℝ), polynomialKernel p u z := by + simp only [polynomialKernel_eq_sum] + rw [integral_finsetSum p.support (fun j _ => + (transformJet_integrable (2*j+1) (by simpa using hu)).const_mul (p.coeff j))] + simp only [integral_const_mul, polynomialTransformJet, Polynomial.sum, Nat.add_zero, integralJet] + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Finset +lemma triangular_span {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + (v w : ℕ → V) (c : ℕ → ℕ → K) + (hw : ∀ k,w k=∑ j ∈ range (k+1),c k j • v j) + (hc : ∀ k,c k k ≠ 0) (N : ℕ) : + Submodule.span K (v '' Set.Iio N) = Submodule.span K (w '' Set.Iio N) := by + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨k,hk,rfl⟩ + induction k using Nat.strong_induction_on with + | h k ih => + have hwk : w k ∈ Submodule.span K (w '' Set.Iio N) := Submodule.subset_span ⟨k,hk,rfl⟩ + have hsum : (∑ j ∈ range k,c k j • v j) ∈ Submodule.span K (w '' Set.Iio N) := by + apply Submodule.sum_mem + intro j hj + exact Submodule.smul_mem _ _ (ih j (mem_range.mp hj) (lt_trans (mem_range.mp hj) hk)) + rw [hw, sum_range_succ] at hwk + have hmem := Submodule.sub_mem _ hwk hsum + simp only [add_sub_cancel_left] at hmem + have hmem' := Submodule.smul_mem (Submodule.span K (w '' Set.Iio N)) (c k k)⁻¹ hmem + rw [smul_smul,inv_mul_cancel₀ (hc k),one_smul] at hmem' + exact hmem' + · apply Submodule.span_le.mpr + rintro _ ⟨k,hk,rfl⟩ + rw [hw] + apply Submodule.sum_mem + intro j hj + apply Submodule.smul_mem + exact Submodule.subset_span ⟨j,lt_of_le_of_lt (Nat.lt_succ_iff.mp (mem_range.mp hj)) hk,rfl⟩ +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Finset Filter Topology + +noncomputable def poleCoeff (a b : ℝ → ℝ) : ℕ → ℕ → ℝ → ℝ + | 0, 0 => a + | 0, _+1 => 0 + | n+1, 0 => deriv (poleCoeff a b n 0) + | n+1, k+1 => fun m => deriv (poleCoeff a b n (k+1)) m - + (k+1 : ℕ) * deriv b m * poleCoeff a b n k m + +lemma poleCoeff_smooth {a b : ℝ → ℝ} (ha : ContDiff ℝ ⊤ a) + (hb : ContDiff ℝ ⊤ b) (n k : ℕ) : ContDiff ℝ ⊤ (poleCoeff a b n k) := by + induction n generalizing k with + | zero => cases k <;> simp only [poleCoeff]; exact ha; exact contDiff_const + | succ n ih => + cases k with + | zero => exact (ih 0).deriv' + | succ k => + exact (ih (k+1)).deriv'.sub ((contDiff_const.mul hb.deriv').mul (ih k)) + +lemma poleCoeff_eq_zero {a b : ℝ → ℝ} {n k : ℕ} (h : n < k) : + poleCoeff a b n k = 0 := by + induction n generalizing k with + | zero => cases k <;> first | omega | rfl + | succ n ih => + cases k with + | zero => omega + | succ k => + have h1 := ih (show n < k+1 by omega) + have h2 := ih (show n < k by omega) + ext m + simp [poleCoeff, h1, h2] + +lemma poleCoeff_diagonal_ne_zero {a b : ℝ → ℝ} {m : ℝ} + (ha : a m ≠ 0) (hb : deriv b m ≠ 0) (n : ℕ) : poleCoeff a b n n m ≠ 0 := by + induction n with + | zero => exact ha + | succ n ih => + have hz := poleCoeff_eq_zero (a:=a) (b:=b) (show n < n+1 by omega) + change deriv (poleCoeff a b n (n+1)) m - + (n+1 : ℕ) * deriv b m * poleCoeff a b n n m ≠ 0 + rw [hz, show deriv (0 : ℝ → ℝ) m = 0 from deriv_const m 0, zero_sub] + exact neg_ne_zero.mpr (mul_ne_zero (mul_ne_zero + (Nat.cast_ne_zero.mpr (Nat.succ_ne_zero n)) hb) ih) + +lemma reciprocal_power_hasDerivAt {b : ℝ → ℝ} {m X : ℝ} (k : ℕ) + (hb : DifferentiableAt ℝ b m) (hXm : X + b m ≠ 0) : + HasDerivAt (fun t => (X + b t)⁻¹ ^ (k+1)) + (-(k+1:ℕ) * deriv b m * (X + b m)⁻¹ ^ (k+2)) m := by + have h := ((hb.hasDerivAt.const_add X).inv hXm).pow (k+1) + convert h using 1; try rfl + simp only [Pi.inv_apply, Nat.add_sub_cancel, Nat.cast_add, Nat.cast_one, div_eq_mul_inv, ← inv_pow] + ring + + +lemma poleJet_expansion {a b : ℝ → ℝ} (ha : ContDiff ℝ ⊤ a) + (hb : ContDiff ℝ ⊤ b) (n : ℕ) {m X : ℝ} (hXm : X + b m ≠ 0) : + iteratedDeriv n (fun t => a t / (X + b t)) m = + ∑ k ∈ range (n+1), poleCoeff a b n k m * (X+b m)⁻¹ ^ (k+1) := by + induction n generalizing m with + | zero => simp [poleCoeff, div_eq_mul_inv] + | succ n ih => + have he : iteratedDeriv n (fun t => a t / (X+b t)) =ᶠ[𝓝 m] + (fun t => ∑ k ∈ range (n+1), poleCoeff a b n k t * (X+b t)⁻¹ ^ (k+1)) := by + filter_upwards [(continuous_const.add hb.continuous).continuousAt.eventually_ne hXm] with t ht + exact ih ht + rw [iteratedDeriv_succ, he.deriv_eq] + have hd (k : ℕ) := ((poleCoeff_smooth ha hb n k).differentiable (by simp)).differentiableAt.hasDerivAt.mul + (reciprocal_power_hasDerivAt k (hb.differentiable (by simp)).differentiableAt hXm) + have hds := HasDerivAt.fun_sum (fun k (_ : k ∈ range (n+1)) => hd k) + simp only [Pi.mul_apply] at hds + rw [hds.deriv] + have hz : deriv (poleCoeff a b n (n+1)) m = 0 := by + rw [poleCoeff_eq_zero (by omega)] + exact deriv_const m 0 + let A := fun k => deriv (poleCoeff a b n k) m * (X+b m)⁻¹ ^ (k+1) + have hshift : (∑ k ∈ range (n+1), A k) = + A 0 + ∑ k ∈ range (n+1), A (k+1) := by + have h1 := sum_range_succ A (n+1) + have h2 := sum_range_succ' A (n+1) + have hzero : A (n+1) = 0 := by simp only [A, hz, zero_mul] + rw [hzero, add_zero] at h1 + rw [h1] at h2 + exact h2.trans (add_comm _ _) + calc + (∑ k ∈ range (n+1), + (deriv (poleCoeff a b n k) m * (X+b m)⁻¹ ^ (k+1) + + poleCoeff a b n k m * (-(k+1:ℕ) * deriv b m * (X+b m)⁻¹ ^ (k+2)))) + = (∑ k ∈ range (n+1), A k) - + ∑ k ∈ range (n+1), (k+1:ℕ) * deriv b m * poleCoeff a b n k m * (X+b m)⁻¹ ^ (k+2) := by + rw [← sum_sub_distrib] + apply sum_congr rfl + intro k hk + dsimp [A] + ring + _ = A 0 + ∑ k ∈ range (n+1), + (deriv (poleCoeff a b n (k+1)) m - (k+1:ℕ) * deriv b m * poleCoeff a b n k m) * + (X+b m)⁻¹ ^ (k+2) := by + rw [hshift, add_sub_assoc, ← sum_sub_distrib] + congr 1 + apply sum_congr rfl + intro k hk + dsimp [A] + ring + _ = ∑ k ∈ range (n+1+1), poleCoeff a b (n+1) k m * (X+b m)⁻¹ ^ (k+1) := by + conv_rhs => rw [sum_range_succ'] + simp only [poleCoeff, A, Nat.zero_add, pow_one] + rw [add_comm] + +lemma poleJet_span {ι : Type*} (X : ι → ℝ) {a b : ℝ → ℝ} + (ha : ContDiff ℝ ⊤ a) (hb : ContDiff ℝ ⊤ b) {m : ℝ} + (ham : a m ≠ 0) (hbm : deriv b m ≠ 0) (hden : ∀ i, X i + b m ≠ 0) (N : ℕ) : + Submodule.span ℂ ((fun k : ℕ => fun i => (((X i+b m)⁻¹ ^ (k+1) : ℝ) : ℂ)) '' Set.Iio N) = + Submodule.span ℂ ((fun k : ℕ => fun i => ((iteratedDeriv k (fun t => a t / (X i+b t)) m : ℝ) : ℂ)) '' Set.Iio N) := by + apply triangular_span _ _ (fun n k => (poleCoeff a b n k m : ℂ)) + · intro k + ext i + simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + rw [poleJet_expansion ha hb k (hden i)] + simp only [Complex.ofReal_sum, Complex.ofReal_mul] + · intro k + exact Complex.ofReal_ne_zero.mpr (poleCoeff_diagonal_ne_zero ham hbm k) + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Filter Topology + +noncomputable def reciprocalCosinePower (n : ℕ) (u : ℝ) : ℝ := + (1+Real.cos (2*u))⁻¹ ^ n + +lemma cosineDouble_hasDerivAt (u : ℝ) : + HasDerivAt (fun t => Real.cos (2*t)) (-2*Real.sin (2*u)) u := by + convert ((hasDerivAt_id u).const_mul 2).cos using 1 <;> simp only [id_eq, mul_one] + ring + +lemma sineDouble_hasDerivAt (u : ℝ) : + HasDerivAt (fun t => Real.sin (2*t)) (2*Real.cos (2*u)) u := by + convert ((hasDerivAt_id u).const_mul 2).sin using 1 <;> simp only [id_eq, mul_one] + ring + +lemma reciprocalCosinePower_hasDerivAt (n : ℕ) {u : ℝ} + (hu : 1+Real.cos (2*u) ≠ 0) : + HasDerivAt (reciprocalCosinePower (n+1)) + (2*(n+1:ℕ)*Real.sin (2*u)*reciprocalCosinePower (n+2) u) u := by + have h := reciprocal_power_hasDerivAt (m:=u) (X:=1) n + (cosineDouble_hasDerivAt u).differentiableAt hu + rw [(cosineDouble_hasDerivAt u).deriv] at h + convert h using 1; try rfl + dsimp [reciprocalCosinePower] + ring + +lemma reciprocalCosinePower_two (n : ℕ) {u : ℝ} + (hu : 1+Real.cos (2*u) ≠ 0) : + iteratedDeriv 2 (reciprocalCosinePower (n+1)) u = + 4*(n+1:ℕ)*(2*(n+1:ℕ)+1)*reciprocalCosinePower (n+2) u - + 4*(n+1:ℕ)^2*reciprocalCosinePower (n+1) u := by + have hn : ∀ᶠ t in 𝓝 u, 1+Real.cos (2*t) ≠ 0 := + (show Continuous (fun t : ℝ => 1+Real.cos (2*t)) by fun_prop).continuousAt.eventually_ne hu + have he : deriv (reciprocalCosinePower (n+1)) =ᶠ[𝓝 u] + (fun t => 2*(n+1:ℕ)*Real.sin (2*t)*reciprocalCosinePower (n+2) t) := + hn.mono (fun t ht => (reciprocalCosinePower_hasDerivAt n ht).deriv) + rw [iteratedDeriv_succ, iteratedDeriv_one, he.deriv_eq] + have hd := ((sineDouble_hasDerivAt u).const_mul (2*((n+1:ℕ):ℝ))).mul + (reciprocalCosinePower_hasDerivAt (n+1) hu) + change HasDerivAt (fun t => 2*(n+1:ℕ)*Real.sin (2*t)*reciprocalCosinePower (n+2) t) _ u at hd + rw [hd.deriv] + dsimp [reciprocalCosinePower] + have hid := Real.sin_sq_add_cos_sq (2*u) + simp only [Nat.cast_add, Nat.cast_one, pow_succ] + field_simp + nlinarith [hid] + +lemma reciprocalCosine_den_ne_zero {u : ℝ} (hu : |u| < Real.pi/2) : + 1+Real.cos (2*u) ≠ 0 := by + have hc := Real.cos_pos_of_mem_Ioo (show u ∈ Set.Ioo (-(Real.pi/2)) (Real.pi/2) from abs_lt.mp hu) + rw [Real.cos_two_mul] + nlinarith [sq_pos_of_pos hc] + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real MeasureTheory Filter Topology Polynomial + +lemma integralJet_one {u : ℝ} (hu : |u| < Real.pi/2) : + integralJet 0 1 u = 2 / (1+Real.cos (2*u)) := by + have hn := reciprocalCosine_den_ne_zero hu + have hd := (sineDouble_hasDerivAt u).div + ((cosineDouble_hasDerivAt u).const_add 1) hn + rw [integralJet_eq_iteratedDeriv 1 (by simpa using hu), iteratedDeriv_one] + simp only [mul_zero, Real.cos_zero] + change HasDerivAt (fun t => Real.sin (2*t) / (1+Real.cos (2*t))) _ u at hd + rw [hd.deriv] + have hid := Real.sin_sq_add_cos_sq (2*u) + field_simp + nlinarith [hid] + +noncomputable def inverseCosinePolynomial : ℕ → Polynomial ℝ + | 0 => Polynomial.C (1/2) + | n+1 => (4*(n+1:ℕ)*(2*(n+1:ℕ)+1) : ℝ)⁻¹ • + (X * inverseCosinePolynomial n + (4*(n+1:ℕ)^2 : ℝ) • inverseCosinePolynomial n) + +lemma inverseCosinePolynomial_degree (n : ℕ) : + (inverseCosinePolynomial n).natDegree ≤ n := by + induction n with + | zero => simp [inverseCosinePolynomial] + | succ n ih => + apply (natDegree_smul_le _ _).trans + apply (natDegree_add_le _ _).trans + apply max_le + · exact natDegree_mul_le.trans (by simpa [Nat.add_comm] using Nat.add_le_add_left ih 1) + · exact (natDegree_smul_le _ _).trans (ih.trans (Nat.le_succ n)) + +lemma inverseCosinePolynomial_transform (n : ℕ) {u : ℝ} (hu : |u| < Real.pi/2) : + polynomialTransformJet (inverseCosinePolynomial n) 0 u = reciprocalCosinePower (n+1) u := by + induction n generalizing u with + | zero => + rw [inverseCosinePolynomial, polynomialTransformJet_C] + simp only [Nat.add_zero] + rw [integralJet_one hu] + simp [reciprocalCosinePower, div_eq_mul_inv] + | succ n ih => + have hn : ∀ᶠ t in 𝓝 u, |t| < Real.pi/2 := + (isOpen_lt continuous_abs continuous_const).mem_nhds hu + have he : polynomialTransformJet (inverseCosinePolynomial n) 0 =ᶠ[𝓝 u] + reciprocalCosinePower (n+1) := + hn.mono (fun _ ht => ih ht) + have htwo := he.iteratedDeriv_eq 2 + rw [polynomialTransformJet_two hu, + reciprocalCosinePower_two n (reciprocalCosine_den_ne_zero hu)] at htwo + rw [inverseCosinePolynomial, polynomialTransformJet_smul, polynomialTransformJet_add, + polynomialTransformJet_smul, htwo, ih hu] + have hnonzero : (4*(n+1:ℕ)*(2*(n+1:ℕ)+1) : ℝ) ≠ 0 := by positivity + field_simp + ring + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real MeasureTheory Filter Topology Polynomial Finset + +noncomputable def zMonomial (j : ℕ) (z : ℝ) : ℂ := ((z^2)^j : ℝ) +noncomputable def zCoshJet (m : ℝ) (j : ℕ) (z : ℝ) : ℂ := + (z^j*hypJet (j+1) (m*z) : ℝ) +noncomputable def zG (m z : ℝ) : ℂ := (Real.sinh (m*z)/z : ℝ) +noncomputable def zDensity (m : ℝ) (N : ℕ) : Submodule ℂ (ℝ → ℂ) := + Submodule.span ℂ + (Set.range (fun j : Fin N => zMonomial j.val) ∪ + Set.range (fun j : Fin N => zCoshJet m j.val) ∪ {zG m}) + +noncomputable def zKernel (f : ℝ → ℂ) (u z : ℝ) : ℂ := + f z * (Real.cosh (u*z) : ℂ) * z / (Real.sinh (Real.pi*z/2) : ℂ) +noncomputable def zTransform (f : ℝ → ℂ) (u : ℝ) : ℂ := + ∫ z in Set.Ioi (0:ℝ), zKernel f u z + +def TransformDomain (m : ℝ) := {u : ℝ // |u|+|m| < Real.pi/2} + +lemma zKernel_add (f g : ℝ → ℂ) (u : ℝ) : + zKernel (f+g) u = zKernel f u + zKernel g u := by + ext z + simp only [zKernel, Pi.add_apply] + ring +lemma zKernel_smul (c : ℂ) (f : ℝ → ℂ) (u : ℝ) : + zKernel (c • f) u = c • zKernel f u := by + ext z + simp only [zKernel, Pi.smul_apply, smul_eq_mul] + ring +lemma zKernel_zero (u : ℝ) : zKernel 0 u = 0 := by ext z; simp [zKernel] + +lemma zKernel_monomial (j : ℕ) (u z : ℝ) : + zKernel (zMonomial j) u z = (transformJet 0 (2*j+1) u z : ℝ) := by + simp only [zKernel, zMonomial, transformJet, zero_mul, Real.cosh_zero, one_mul, + hypJet_odd, pow_add, pow_one, pow_mul] + push_cast + ring +lemma zKernel_coshJet (m : ℝ) (j : ℕ) (u z : ℝ) : + zKernel (zCoshJet m j) u z = (transformJet u (j+1) m z : ℝ) := by + simp only [zKernel, zCoshJet, transformJet, pow_succ] + push_cast + ring +lemma zKernel_g (m u : ℝ) {z : ℝ} (hz : 0 < z) : + zKernel (zG m) u z = (transformJet u 0 m z : ℝ) := by + have hz0 : (z:ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hz.ne' + simp only [zKernel, zG, transformJet_zero] + push_cast + field_simp + +lemma zKernel_monomial_integrable {u : ℝ} (hu : |u| < Real.pi/2) (j : ℕ) : + IntegrableOn (zKernel (zMonomial j) u) (Set.Ioi 0) := by + change Integrable (fun z => zKernel (zMonomial j) u z) _ + simp_rw [zKernel_monomial] + exact (transformJet_integrable (u:=0) (m:=u) (2*j+1) (by simpa using hu)).ofReal (𝕜:=ℂ) +lemma zKernel_coshJet_integrable {m u : ℝ} (hu : |u|+|m| < Real.pi/2) (j : ℕ) : + IntegrableOn (zKernel (zCoshJet m j) u) (Set.Ioi 0) := by + change Integrable (fun z => zKernel (zCoshJet m j) u z) _ + simp_rw [zKernel_coshJet] + exact (transformJet_integrable (u:=u) (m:=m) (j+1) (by linarith : |m|+|u| < Real.pi/2)).ofReal (𝕜:=ℂ) +lemma zKernel_g_integrable {m u : ℝ} (hu : |u|+|m| < Real.pi/2) : + IntegrableOn (zKernel (zG m) u) (Set.Ioi 0) := by + apply ((transformJet_integrable 0 (by linarith : |m|+|u| < Real.pi/2)).ofReal (𝕜:=ℂ)).congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with z hz + exact (zKernel_g m u hz).symm + +lemma zDensity_integrable {m u : ℝ} {N : ℕ} {f : ℝ → ℂ} + (hf : f ∈ zDensity m N) (hu : |u|+|m| < Real.pi/2) : + IntegrableOn (zKernel f u) (Set.Ioi 0) := by + induction hf using Submodule.span_induction with + | mem f hf => + rcases hf with ((⟨j,rfl⟩ | ⟨j,rfl⟩) | rfl) + · exact zKernel_monomial_integrable (by linarith [abs_nonneg m]) j.val + · exact zKernel_coshJet_integrable hu j.val + · exact zKernel_g_integrable hu + | zero => rw [zKernel_zero]; exact integrable_zero _ _ _ + | add f g hf hg hfi hgi => rw [zKernel_add]; exact hfi.add hgi + | smul c f hf hfi => rw [zKernel_smul]; exact hfi.smul c + +lemma zTransform_add {f g : ℝ → ℂ} {u : ℝ} + (hf : IntegrableOn (zKernel f u) (Set.Ioi 0)) + (hg : IntegrableOn (zKernel g u) (Set.Ioi 0)) : + zTransform (f+g) u = zTransform f u + zTransform g u := by + unfold zTransform + rw [zKernel_add] + simp only [Pi.add_apply] + exact integral_add hf hg +lemma zTransform_smul (c : ℂ) (f : ℝ → ℂ) (u : ℝ) : + zTransform (c • f) u = c * zTransform f u := by + unfold zTransform + rw [zKernel_smul] + simp only [Pi.smul_apply, smul_eq_mul] + exact integral_const_mul c _ +lemma zTransform_zero (u : ℝ) : zTransform 0 u = 0 := by simp [zTransform, zKernel_zero] + +noncomputable def zTransformLinear (m : ℝ) (N : ℕ) : + zDensity m N →ₗ[ℂ] (TransformDomain m → ℂ) where + toFun f u := zTransform f.val u.val + map_add' f g := funext (fun u => zTransform_add + (zDensity_integrable f.property u.property) (zDensity_integrable g.property u.property)) + map_smul' c f := funext (fun u => zTransform_smul c f.val u.val) + +lemma zTransform_monomial (j : ℕ) (u : ℝ) : + zTransform (zMonomial j) u = (integralJet 0 (2*j+1) u : ℝ) := by + simp only [zTransform, zKernel_monomial, _root_.integral_complex_ofReal, integralJet] +lemma zTransform_coshJet (m : ℝ) (j : ℕ) (u : ℝ) : + zTransform (zCoshJet m j) u = (integralJet u (j+1) m : ℝ) := by + simp only [zTransform, zKernel_coshJet, _root_.integral_complex_ofReal, integralJet] +lemma zTransform_g (m u : ℝ) : + zTransform (zG m) u = (integralJet u 0 m : ℝ) := by + unfold zTransform integralJet + rw [← _root_.integral_complex_ofReal] + apply setIntegral_congr_fun measurableSet_Ioi + intro z hz + exact zKernel_g m u hz + +lemma zPolynomial_mem {m : ℝ} {N : ℕ} (p : Polynomial ℝ) (hp : p.natDegree < N) : + (fun z => ((p.eval ((z:ℝ)^2) : ℝ) : ℂ)) ∈ zDensity m N := by + have hs : (∑ j ∈ p.support, (p.coeff j : ℂ) • zMonomial j) ∈ zDensity m N := by + apply Submodule.sum_mem + intro j hj + apply Submodule.smul_mem + apply Submodule.subset_span + exact Or.inl (Or.inl ⟨⟨j,(Polynomial.le_natDegree_of_mem_supp j hj).trans_lt hp⟩,rfl⟩) + convert hs using 1 + ext z + simp only [Polynomial.eval_eq_sum, Polynomial.sum, Complex.ofReal_sum, Complex.ofReal_mul, + Complex.ofReal_pow, Finset.sum_apply, Pi.smul_apply, smul_eq_mul, zMonomial] + +lemma zTransform_polynomial (p : Polynomial ℝ) {u : ℝ} (hu : |u| < Real.pi/2) : + zTransform (fun z => ((p.eval ((z:ℝ)^2) : ℝ) : ℂ)) u = (polynomialTransformJet p 0 u : ℝ) := by + rw [polynomialTransform_eq_integral p hu] + unfold zTransform + rw [← _root_.integral_complex_ofReal] + apply setIntegral_congr_fun measurableSet_Ioi + intro z hz + simp only [zKernel, polynomialKernel] + push_cast + rfl + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Polynomial Finset + +lemma mixed_inverse_step {x a b : ℂ} (ha : x+a ≠ 0) (hb : x+b ≠ 0) (hab : b-a ≠ 0) + (n m : ℕ) : + (x+a)⁻¹^(n+1) * (x+b)⁻¹^(m+1) = + (b-a)⁻¹ * ((x+a)⁻¹^(n+1) * (x+b)⁻¹^m - (x+a)⁻¹^n * (x+b)⁻¹^(m+1)) := by + simp only [pow_succ] + field_simp + ring + +lemma reciprocalProduct_mem {ι : Type*} (x : ι → ℂ) (a b : ℂ) + (ha : ∀ i, x i+a ≠ 0) (hb : ∀ i, x i+b ≠ 0) (hab : b-a ≠ 0) + (S : Submodule ℂ (ι → ℂ)) (N M : ℕ) + (haS : ∀ k, 0 (x i+a)⁻¹^k) ∈ S) + (hbS : ∀ k, 0 (x i+b)⁻¹^k) ∈ S) + (n m : ℕ) (hn : n≤N) (hm : m≤M) (hpos : 0 (x i+a)⁻¹^n * (x i+b)⁻¹^m) ∈ S := by + induction n generalizing m with + | zero => simpa only [pow_zero, one_mul] using hbS m (by omega) hm + | succ n ih => + induction m with + | zero => simpa only [pow_zero, mul_one] using haS (n+1) (by omega) hn + | succ m ihm => + have h1 := ihm (by omega) (by omega) + have h2 := ih (m+1) (by omega) hm (by omega) + have hs := S.smul_mem (b-a)⁻¹ (S.sub_mem h1 h2) + convert hs using 1 + ext i + simp only [Pi.smul_apply, Pi.sub_apply, smul_eq_mul] + exact mixed_inverse_step (ha i) (hb i) hab n m + +lemma monomial_inverse_step {x a b : ℂ} (ha : x+a ≠ 0) (j n m : ℕ) : + x^(j+1) * (x+a)⁻¹^(n+1) * (x+b)⁻¹^m = + x^j * (x+a)⁻¹^n * (x+b)⁻¹^m - a * (x^j * (x+a)⁻¹^(n+1) * (x+b)⁻¹^m) := by + simp only [pow_succ] + field_simp + ring + +lemma properMonomial_mem {ι : Type*} (x : ι → ℂ) (a b : ℂ) + (ha : ∀ i, x i+a ≠ 0) (hb : ∀ i, x i+b ≠ 0) (hab : b-a ≠ 0) + (S : Submodule ℂ (ι → ℂ)) (N M : ℕ) + (haS : ∀ k, 0 (x i+a)⁻¹^k) ∈ S) + (hbS : ∀ k, 0 (x i+b)⁻¹^k) ∈ S) + (j n m : ℕ) (hn : n≤N) (hm : m≤M) (hj : j x i^j * (x i+a)⁻¹^n * (x i+b)⁻¹^m) ∈ S := by + induction j generalizing n m with + | zero => simpa only [pow_zero, one_mul] using + reciprocalProduct_mem x a b ha hb hab S N M haS hbS n m hn hm hj + | succ j ih => + cases n with + | succ n => + have h1 := ih n m (by omega) hm (by omega) + have h2 := ih (n+1) m hn hm (by omega) + have hs := S.sub_mem h1 (S.smul_mem a h2) + convert hs using 1 + ext i + simp only [Pi.smul_apply, Pi.sub_apply, smul_eq_mul] + exact monomial_inverse_step (ha i) j n m + | zero => + have hm0 : 0 < m := by omega + obtain ⟨m,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (ne_of_gt hm0) + have h1 := ih 0 m hn (by omega) (by omega) + have h2 := ih 0 (m+1) hn hm (by omega) + have hs := S.sub_mem h1 (S.smul_mem b h2) + convert hs using 1 + ext i + simp only [Pi.smul_apply, Pi.sub_apply, smul_eq_mul, pow_zero, mul_one] + simpa only [pow_zero, mul_one] using + monomial_inverse_step (b:=a) (hb i) j m 0 + +lemma properPolynomial_mem {ι : Type*} (x : ι → ℂ) (a b : ℂ) + (ha : ∀ i, x i+a ≠ 0) (hb : ∀ i, x i+b ≠ 0) (hab : b-a ≠ 0) + (S : Submodule ℂ (ι → ℂ)) (N M : ℕ) + (haS : ∀ k, 0 (x i+a)⁻¹^k) ∈ S) + (hbS : ∀ k, 0 (x i+b)⁻¹^k) ∈ S) + (p : Polynomial ℂ) (hp : p.natDegree < N+M) : + (fun i => p.eval (x i) / ((x i+a)^N * (x i+b)^M)) ∈ S := by + have hs : (∑ j ∈ p.support, p.coeff j • (fun i => x i^j * (x i+a)⁻¹^N * (x i+b)⁻¹^M)) ∈ S := by + apply S.sum_mem + intro j hj + apply S.smul_mem + exact properMonomial_mem x a b ha hb hab S N M haS hbS j N M le_rfl le_rfl + ((le_natDegree_of_mem_supp j hj).trans_lt hp) + convert hs using 1 + ext i + simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul, + Polynomial.eval_eq_sum, Polynomial.sum, Finset.sum_div] + apply sum_congr rfl + intro j hj + simp only [div_eq_mul_inv, mul_inv_rev, ← inv_pow] + ring + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.Analytic +open Real Filter Topology Polynomial Finset + +lemma cosine_sum_pos {u m : ℝ} (hu : |u|+|m| < Real.pi/2) : + 0 < Real.cos (2*u) + Real.cos (2*m) := by + have hp : |u+m| < Real.pi/2 := (abs_add_le u m).trans_lt hu + have hm : |u-m| < Real.pi/2 := (abs_sub u m).trans_lt hu + have hcp := Real.cos_pos_of_mem_Ioo (abs_lt.mp hp) + have hcm := Real.cos_pos_of_mem_Ioo (abs_lt.mp hm) + rw [Real.cos_add_cos, show (2*u+2*m)/2 = u+m by ring, show (2*u-2*m)/2 = u-m by ring] + exact mul_pos (mul_pos (by norm_num : (0:ℝ)<2) hcp) hcm + +lemma zMonomial_mem (m : ℝ) {N j : ℕ} (hj : j + ((Real.cos (2*u.val):ℂ)+1)⁻¹^k) ∈ (zTransformLinear m N).range := by + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (ne_of_gt hk) + let p := inverseCosinePolynomial n + have hp : p.natDegree < N := (inverseCosinePolynomial_degree n).trans_lt (by omega) + refine ⟨⟨fun z => ((p.eval ((z:ℝ)^2) : ℝ) : ℂ), zPolynomial_mem p hp⟩,?_⟩ + ext u + have hu : |u.val| < Real.pi/2 := by linarith [u.property,abs_nonneg m] + change zTransform (fun z => ((p.eval ((z:ℝ)^2) : ℝ) : ℂ)) u.val = _ + rw [zTransform_polynomial p hu, inverseCosinePolynomial_transform n hu] + simp only [reciprocalCosinePower, Complex.ofReal_pow, Complex.ofReal_inv, Complex.ofReal_add, Complex.ofReal_one] + rw [add_comm] + +lemma poleJet_mem_range (m : ℝ) (N : ℕ) (j : ℕ) (hj : j < N+1) : + (fun u : TransformDomain m => + ((iteratedDeriv j (fun t => Real.sin (2*t) / (Real.cos (2*u.val)+Real.cos (2*t))) m : ℝ) : ℂ)) + ∈ (zTransformLinear m N).range := by + cases j with + | zero => + refine ⟨⟨zG m,zG_mem m N⟩,?_⟩ + ext u + change zTransform (zG m) u.val = _ + rw [zTransform_g, integralJet_eq_iteratedDeriv 0 (by linarith [u.property])] + | succ j => + refine ⟨⟨zCoshJet m j,zCoshJet_mem m (by omega)⟩,?_⟩ + ext u + change zTransform (zCoshJet m j) u.val = _ + rw [zTransform_coshJet, integralJet_eq_iteratedDeriv (j+1) (by linarith [u.property])] + +lemma secondPole_mem_range {m : ℝ} (hm : 0 < m) (hm' : m < Real.pi/2) + (N : ℕ) (k : ℕ) (hk : 0 + ((Real.cos (2*u.val):ℂ)+(Real.cos (2*m):ℂ))⁻¹^k) ∈ (zTransformLinear m N).range := by + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (ne_of_gt hk) + have hsm : Real.sin (2*m) ≠ 0 := + (Real.sin_pos_of_pos_of_lt_pi (by linarith) (by linarith)).ne' + have hbm : deriv (fun t => Real.cos (2*t)) m ≠ 0 := by + rw [(cosineDouble_hasDerivAt m).deriv] + exact mul_ne_zero (by norm_num) hsm + have he := poleJet_span (fun u : TransformDomain m => Real.cos (2*u.val)) + (show ContDiff ℝ ⊤ (fun t => Real.sin (2*t)) by fun_prop) + (show ContDiff ℝ ⊤ (fun t => Real.cos (2*t)) by fun_prop) + hsm hbm (fun u => (cosine_sum_pos u.property).ne') (N+1) + have hs : Submodule.span ℂ + ((fun j : ℕ => fun u : TransformDomain m => + ((iteratedDeriv j (fun t => Real.sin (2*t) / (Real.cos (2*u.val)+Real.cos (2*t))) m : ℝ) : ℂ)) + '' Set.Iio (N+1)) ≤ (zTransformLinear m N).range := by + apply Submodule.span_le.mpr + rintro _ ⟨j,hj,rfl⟩ + exact poleJet_mem_range m N j hj + rw [← he] at hs + have hv := hs (Submodule.subset_span ⟨n,(by change n < N+1; omega),rfl⟩) + simpa only [Complex.ofReal_pow, Complex.ofReal_inv, Complex.ofReal_add] using hv + +lemma zTransform_surjective {m : ℝ} (hm : 0 < m) (hm' : m < Real.pi/2) + (N : ℕ) (p : Polynomial ℂ) (hp : p.natDegree < 2*N+1) : + ∃ f ∈ zDensity m N, ∀ u : TransformDomain m, + zTransform f u.val = p.eval (Real.cos (2*u.val):ℂ) / + (((Real.cos (2*u.val):ℂ)+1)^N * + ((Real.cos (2*u.val):ℂ)+(Real.cos (2*m):ℂ))^(N+1)) := by + have hsin := Real.sin_pos_of_pos_of_lt_pi (by linarith : 0<2*m) (by linarith : 2*m (Real.cos (2*u.val):ℂ)) 1 (Real.cos (2*m):ℂ) + (fun u => by + have hu : |u.val| < Real.pi/2 := by linarith [u.property,abs_nonneg m] + simpa only [Complex.ofReal_add,Complex.ofReal_one,add_comm] using + Complex.ofReal_ne_zero.mpr (reciprocalCosine_den_ne_zero hu)) + (fun u => by simpa only [Complex.ofReal_add] using + Complex.ofReal_ne_zero.mpr (cosine_sum_pos u.property).ne') + (by simpa only [Complex.ofReal_sub,Complex.ofReal_one] using Complex.ofReal_ne_zero.mpr hcos) + (zTransformLinear m N).range N (N+1) + (firstPole_mem_range m N) (secondPole_mem_range hm hm' N) p (by omega) + obtain ⟨f,hf⟩ := hmem + refine ⟨f.val,f.property,?_⟩ + intro u + exact congrFun hf u + +end CriticalHoneycomb.FiniteFunctional.Analytic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/TranslatedJets.lean b/lean/OAI/Combinatorics/HoneycombChords/TranslatedJets.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b54fd08c9b123d5b6c56515e433cdd96540b965 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/TranslatedJets.lean @@ -0,0 +1,624 @@ +import OAI.Combinatorics.HoneycombChords.PhysicalFactors + +namespace OAI + +/-! Translated differential equations, Rolle estimates, and confluent positivity. + +The development follows OpenAI, *Uniform marked-polygon estimates and sharp finite bridge moments* +(2026), Sections 6 and 7. -/ + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Real + +lemma cosineKernelJet_square_cos (t p : ℝ) : + cosineKernelJet 0 0 (t^2) (-(p^2))=Real.cos (t*p) := by + rw [cosineKernelJet_zero_zero_cos (sq_nonneg _) (neg_nonpos.mpr (sq_nonneg p)), + neg_neg,Real.sqrt_sq_eq_abs,Real.sqrt_sq_eq_abs,←abs_mul,Real.cos_abs] + +lemma cosineKernelJet_first_negative (t p : ℝ) : + 2*t*cosineKernelJet 1 0 (t^2) (-(p^2))= -p*Real.sin (t*p) := by + have h := (cosineKernelJet_hasDerivAt_left 0 0 (t^2) (-(p^2))).comp t ((hasDerivAt_id t).pow 2) + have he : (fun y => cosineKernelJet 0 0 (y^2) (-(p^2)))=(fun y => Real.cos (y*p)) := + funext (fun y => cosineKernelJet_square_cos y p) + have h' : HasDerivAt (fun y => cosineKernelJet 0 0 (y^2) (-(p^2))) + (2*t*cosineKernelJet 1 0 (t^2) (-(p^2))) t := by + convert! h using 1 ; simp only [id_eq,pow_one,Nat.cast_ofNat,mul_one, + Nat.cast_zero,zero_add,show 2-1=1 by omega] ; ring + rw [he] at h' + have hc := (Real.hasDerivAt_cos (t*p)).comp t ((hasDerivAt_id t).mul_const p) + have heq := h'.unique hc + simp only [one_mul] at heq + linarith + +lemma cosineKernelJet_ode_at_square (t x : ℝ) : + 2*cosineKernelJet 1 0 (t^2) x+8*t^2*cosineKernelJet 2 0 (t^2) x= + x*cosineKernelJet 0 0 (t^2) x := by + by_cases hx : 0 ≤ x + · let p := Real.sqrt x + have hp : p^2=x := Real.sq_sqrt hx + have hJ := (cosineKernelJet_hasDerivAt_left 1 0 (t^2) (p^2)).comp t ((hasDerivAt_id t).pow 2) + have h : HasDerivAt (fun s => 2*s*cosineKernelJet 1 0 (s^2) (p^2)) + (2*cosineKernelJet 1 0 (t^2) (p^2)+8*t^2*cosineKernelJet 2 0 (t^2) (p^2)) t := by + convert! (((hasDerivAt_id t).const_mul 2).mul hJ) using 1 ; + simp only [Function.comp_def,Pi.pow_apply,id_eq,pow_one,Nat.cast_ofNat,mul_one, + show 2-1=1 by omega] ; ring + have he : (fun s => 2*s*cosineKernelJet 1 0 (s^2) (p^2))=(fun s => p*Real.sinh (s*p)) := + funext (fun s => cosineKernelJet_first_square s p) + rw [he] at h + have hc := ((Real.hasDerivAt_sinh (t*p)).comp t ((hasDerivAt_id t).mul_const p)).const_mul p + have hd := h.unique hc + rw [←cosineKernelJet_square_cosh t p,hp] at hd + simp only [one_mul] at hd + calc + _=p^2*cosineKernelJet 0 0 (t^2) x := by rw [hd];ring + _=_ := by rw [hp] + · let p := Real.sqrt (-x) + have hp : p^2= -x := Real.sq_sqrt (by linarith) + have hpx : -(p^2)=x := by linarith + have hJ := (cosineKernelJet_hasDerivAt_left 1 0 (t^2) (-(p^2))).comp t ((hasDerivAt_id t).pow 2) + have h : HasDerivAt (fun s => 2*s*cosineKernelJet 1 0 (s^2) (-(p^2))) + (2*cosineKernelJet 1 0 (t^2) (-(p^2))+8*t^2*cosineKernelJet 2 0 (t^2) (-(p^2))) t := by + convert! (((hasDerivAt_id t).const_mul 2).mul hJ) using 1 ; + simp only [Function.comp_def,Pi.pow_apply,id_eq,pow_one,Nat.cast_ofNat,mul_one, + show 2-1=1 by omega] ; ring + have he : (fun s => 2*s*cosineKernelJet 1 0 (s^2) (-(p^2)))=(fun s => -p*Real.sin (s*p)) := + funext (fun s => cosineKernelJet_first_negative s p) + rw [he] at h + have hc := ((Real.hasDerivAt_sin (t*p)).comp t ((hasDerivAt_id t).mul_const p)).const_mul (-p) + have hd := h.unique hc + rw [←cosineKernelJet_square_cos t p,hpx] at hd + simp only [one_mul] at hd + calc + _= -(p^2)*cosineKernelJet 0 0 (t^2) x := by rw [hd];ring + _=_ := by rw [hpx] + +lemma cosineKernelJet_shifted_ode (j : ℕ) (t x : ℝ) : + 2*cosineKernelJet 1 (j+1) (t^2) x+8*t^2*cosineKernelJet 2 (j+1) (t^2) x= + x*cosineKernelJet 0 (j+1) (t^2) x+cosineKernelJet 0 j (t^2) x := by + induction j generalizing x with + | zero => + have hL := ((cosineKernelJet_hasDerivAt_right 1 0 (t^2) x).const_mul 2).add + ((cosineKernelJet_hasDerivAt_right 2 0 (t^2) x).const_mul (8*t^2)) + have hR := (hasDerivAt_id x).mul (cosineKernelJet_hasDerivAt_right 0 0 (t^2) x) + have he : (fun y => 2*cosineKernelJet 1 0 (t^2) y+8*t^2*cosineKernelJet 2 0 (t^2) y)= + (fun y => y*cosineKernelJet 0 0 (t^2) y) := funext (cosineKernelJet_ode_at_square t) + change HasDerivAt (fun y => 2*cosineKernelJet 1 0 (t^2) y+ + 8*t^2*cosineKernelJet 2 0 (t^2) y) _ x at hL + rw [he] at hL + have hd := hL.unique hR + simp only [Nat.cast_zero,zero_add,one_mul,id_eq] at hd + linarith + | succ j ih => + have hL := ((cosineKernelJet_hasDerivAt_right 1 (j+1) (t^2) x).const_mul 2).add + ((cosineKernelJet_hasDerivAt_right 2 (j+1) (t^2) x).const_mul (8*t^2)) + have hR := ((hasDerivAt_id x).mul (cosineKernelJet_hasDerivAt_right 0 (j+1) (t^2) x)).add + (cosineKernelJet_hasDerivAt_right 0 j (t^2) x) + have he : (fun y => 2*cosineKernelJet 1 (j+1) (t^2) y+8*t^2*cosineKernelJet 2 (j+1) (t^2) y)= + (fun y => y*cosineKernelJet 0 (j+1) (t^2) y+cosineKernelJet 0 j (t^2) y) := by + funext y + exact ih y + change HasDerivAt (fun y => 2*cosineKernelJet 1 (j+1) (t^2) y+ + 8*t^2*cosineKernelJet 2 (j+1) (t^2) y) _ x at hL + rw [he] at hL + have hd := hL.unique hR + simp only [Nat.cast_add,Nat.cast_one,one_mul,id_eq] at hd + have hn : (j:ℝ)+1+1 ≠ 0 := by positivity + apply mul_left_cancel₀ hn + linear_combination hd + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Set + +lemma ordered_rolle {n : ℕ} {T : ℝ} {f f' : ℝ → ℝ} + (x : Fin (n+1) → ℝ) (hx : StrictMono x) + (hx0 : ∀ i,0 ≤ x i) (hxT : ∀ i,x i ≤ T) + (hc : ContinuousOn f (Icc 0 T)) + (hd : ∀ t ∈ Ioo 0 T,HasDerivAt f (f' t) t) + (hz : ∀ i,f (x i)=0) : + ∃ y : Fin n → ℝ,StrictMono y ∧ (∀ i,0 < y i) ∧ + (∀ i,y i < T) ∧ ∀ i,f' (y i)=0 := by + have h (i : Fin n) : ∃ u ∈ Ioo (x i.castSucc) (x i.succ),f' u=0 := by + apply exists_hasDerivAt_eq_zero (hx (Fin.castSucc_lt_succ)) + (hc.mono (fun t ht => ⟨(hx0 _).trans ht.1,ht.2.trans (hxT _)⟩)) + (by rw [hz,hz]) + intro t ht + exact hd t ⟨(hx0 _).trans_lt ht.1,ht.2.trans_le (hxT _)⟩ + choose y hy hz using h + refine ⟨y,?_,fun i => (hx0 _).trans_lt (hy i).1, + fun i => (hy i).2.trans_le (hxT _),hz⟩ + intro i j hij + have hij' : i.succ ≤ j.castSucc := by exact_mod_cast (show i.val+1 ≤ j.val by omega) + exact (hy i).2.trans_le (hx.monotone hij') |>.trans (hy j).1 + +lemma ordered_rolle_from_zero {n : ℕ} {T : ℝ} {f f' : ℝ → ℝ} + (x : Fin n → ℝ) (hx : StrictMono x) + (hx0 : ∀ i,0 < x i) (hxT : ∀ i,x i < T) + (hc : ContinuousOn f (Icc 0 T)) + (hd : ∀ t ∈ Ioo 0 T,HasDerivAt f (f' t) t) + (hf0 : f 0=0) (hz : ∀ i,f (x i)=0) : + ∃ y : Fin n → ℝ,StrictMono y ∧ (∀ i,0 < y i) ∧ + (∀ i,y i < T) ∧ ∀ i,f' (y i)=0 := by + cases n with + | zero => exact ⟨x,hx,hx0,hxT,fun i => Fin.elim0 i⟩ + | succ n => + have hT : 0 ≤ T := le_trans (hx0 0).le (hxT _).le + apply ordered_rolle (Fin.cons 0 x) + · rw [Fin.strictMono_iff_lt_succ] + intro i + refine Fin.cases ?_ (fun j => ?_) i + · simpa using hx0 0 + · simpa using hx (Fin.castSucc_lt_succ (i:=j)) + · intro i + exact Fin.cases (by simp) (fun j => by simpa using (hx0 j).le) i + · intro i + exact Fin.cases (by simpa using hT) (fun j => by simpa using (hxT j).le) i + · exact hc + · exact hd + · intro i + exact Fin.cases (by simpa using hf0) (fun j => by simpa using hz j) i + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Set Finset + +/-- The exact two-step positive differential system supplied by translating the +cosine kernel below its first zero. It does not assume any determinant sign. -/ +structure SturmPowerFamily (T : ℝ) where + F : ℕ → ℝ → ℝ + H : ℕ → ℝ → ℝ + w : ℝ → ℝ + wpos : ∀ t ∈ Ioo 0 T,0 < w t + Fcontinuous : ∀ j,ContinuousOn (F j) (Icc 0 T) + Hcontinuous : ∀ j,ContinuousOn (H j) (Icc 0 T) + Fderiv : ∀ j t,t ∈ Ioo 0 T → HasDerivAt (F j) (H j t/w t) t + Hderiv : ∀ j t,t ∈ Ioo 0 T → HasDerivAt (H (j+1)) (w t*F j t) t + Fzero : ∀ t ∈ Icc 0 T,F 0 t=1 + Hzero : ∀ t ∈ Icc 0 T,H 0 t=0 + Finit : ∀ j,0 < j → F j 0=0 + Hinit : ∀ j,H j 0=0 + +namespace SturmPowerFamily +variable {T : ℝ} (S : SturmPowerFamily T) + +noncomputable def combination {n : ℕ} (G : ℕ → ℝ → ℝ) (e : Fin n → ℕ) + (c : Fin n → ℝ) (t : ℝ) : ℝ := ∑ i,c i*G (e i) t + +lemma combination_continuous {n : ℕ} (G : ℕ → ℝ → ℝ) + (hG : ∀ j,ContinuousOn (G j) (Icc 0 T)) (e : Fin n → ℕ) (c : Fin n → ℝ) : + ContinuousOn (combination G e c) (Icc 0 T) := by + exact continuousOn_finsetSum _ (fun i _ => continuousOn_const.mul (hG (e i))) + +lemma combination_Fderiv {n : ℕ} (e : Fin n → ℕ) (c : Fin n → ℝ) + {t : ℝ} (ht : t ∈ Ioo 0 T) : + HasDerivAt (combination S.F e c) (combination S.H e c t/S.w t) t := by + have h := HasDerivAt.sum (fun i (_ : i ∈ (univ : Finset (Fin n))) => (S.Fderiv (e i) t ht).const_mul (c i)) + convert! h using 1 + · funext y;simp [combination] + · simp only [combination,sum_div] + apply sum_congr rfl + intro i hi + ring + +lemma combination_Hderiv {n : ℕ} (e : Fin n → ℕ) (c : Fin n → ℝ) + (he : ∀ i,0 < e i) {t : ℝ} (ht : t ∈ Ioo 0 T) : + HasDerivAt (combination S.H e c) + (S.w t*combination S.F (fun i => e i-1) c t) t := by + have h := HasDerivAt.sum (fun i (_ : i ∈ (univ : Finset (Fin n))) => + (show HasDerivAt (S.H (e i)) (S.w t*S.F (e i-1) t) t from + by simpa only [Nat.sub_add_cancel (he i)] using S.Hderiv (e i-1) t ht).const_mul (c i)) + convert! h using 1 + · funext y;simp [combination] + · simp only [combination,mul_sum] + apply sum_congr rfl + intro i hi + ring + +lemma lower_H_roots {n : ℕ} (e : Fin n → ℕ) (c : Fin n → ℝ) + (he : ∀ i,0 < e i) (x : Fin n → ℝ) (hx : StrictMono x) + (hx0 : ∀ i,0 < x i) (hxT : ∀ i,x i < T) + (hz : ∀ i,combination S.H e c (x i)=0) : + ∃ y : Fin n → ℝ,StrictMono y ∧ (∀ i,0 < y i) ∧ + (∀ i,y i < T) ∧ ∀ i,combination S.F (fun i => e i-1) c (y i)=0 := by + obtain ⟨y,hy,hy0,hyT,hyz⟩ := ordered_rolle_from_zero x hx hx0 hxT + (combination_continuous S.H S.Hcontinuous e c) + (fun t ht => S.combination_Hderiv e c he ht) + (by simp [combination,S.Hinit]) hz + refine ⟨y,hy,hy0,hyT,fun i => ?_⟩ + exact (mul_eq_zero.mp (hyz i)).resolve_left (ne_of_gt (S.wpos _ ⟨hy0 i,hyT i⟩)) + +lemma sparse_unique_bounded (d : ℕ) : + ∀ {n : ℕ} (e : Fin n → ℕ),StrictMono e → (∀ i,e i < d) → + ∀ (c : Fin n → ℝ) (x : Fin n → ℝ),StrictMono x → + (∀ i,0 < x i) → (∀ i,x i < T) → + (∀ i,combination S.F e c (x i)=0) → c=0 := by + induction d with + | zero => + intro n e he hd c x hx hx0 hxT hz + funext i + exact False.elim (Nat.not_lt_zero _ (hd i)) + | succ d ih => + intro n e he hd c x hx hx0 hxT hz + cases n with + | zero => exact Subsingleton.elim _ _ + | succ n => + by_cases he0 : e 0=0 + · obtain ⟨y,hy,hy0,hyT,hyz⟩ := ordered_rolle x hx + (fun i => (hx0 i).le) (fun i => (hxT i).le) + (combination_continuous S.F S.Fcontinuous e c) + (fun t ht => S.combination_Fderiv e c ht) hz + let e' : Fin n → ℕ := fun i => e i.succ + let c' : Fin n → ℝ := fun i => c i.succ + have he' : ∀ i,0 < e' i := by + intro i + have h := he (show (0 : Fin (n+1)) < i.succ by change 0 < i.val+1;omega) + simpa [he0,e'] using h + have hyz' : ∀ i,combination S.H e' c' (y i)=0 := by + intro i + have h := (div_eq_zero_iff.mp (hyz i)).resolve_right + (ne_of_gt (S.wpos _ ⟨hy0 i,hyT i⟩)) + simpa [combination,Fin.sum_univ_succ,he0,S.Hzero _ ⟨(hy0 i).le,(hyT i).le⟩,e',c'] using h + obtain ⟨z,hzmono,hz0,hzT,hzz⟩ := S.lower_H_roots e' c' he' y hy hy0 hyT hyz' + have hcm : c'=0 := ih (fun i => e' i-1) + (by intro i j hij;have h := he (Fin.succ_lt_succ_iff.mpr hij);have h0:=he' i;dsimp [e'] at *;omega) + (by intro i;have h:=hd i.succ;have h0:=he' i;dsimp [e'] at *;omega) + c' z hzmono hz0 hzT hzz + have hcS (i : Fin n) : c i.succ=0 := congrFun hcm i + have hc0 : c 0=0 := by + have h:=hz 0 + simpa [combination,Fin.sum_univ_succ,he0,S.Fzero _ ⟨(hx0 0).le,(hxT 0).le⟩,hcS] using h + funext i + exact Fin.cases hc0 hcS i + · have hep : ∀ i,0 < e i := by + intro i + have h := he.monotone (Fin.zero_le i) + omega + have hinit : combination S.F e c 0=0 := by + simp [combination,fun i => S.Finit (e i) (hep i)] + obtain ⟨y,hy,hy0,hyT,hyz⟩ := ordered_rolle_from_zero x hx hx0 hxT + (combination_continuous S.F S.Fcontinuous e c) + (fun t ht => S.combination_Fderiv e c ht) hinit hz + have hyz' : ∀ i,combination S.H e c (y i)=0 := fun i => + (div_eq_zero_iff.mp (hyz i)).resolve_right (ne_of_gt (S.wpos _ ⟨hy0 i,hyT i⟩)) + obtain ⟨z,hzmono,hz0,hzT,hzz⟩ := S.lower_H_roots e c hep y hy hy0 hyT hyz' + exact ih (fun i => e i-1) + (by intro i j hij;have h:=he hij;have h0:=hep i;change e i-1 < e j-1;omega) + (by intro i;have h:=hd i;have h0:=hep i;omega) + c z hzmono hz0 hzT hzz + +lemma sparse_unique {n : ℕ} (e : Fin n → ℕ) (he : StrictMono e) + (c : Fin n → ℝ) (x : Fin n → ℝ) (hx : StrictMono x) + (hx0 : ∀ i,0 < x i) (hxT : ∀ i,x i < T) + (hz : ∀ i,combination S.F e c (x i)=0) : c=0 := by + classical + exact S.sparse_unique_bounded (univ.sup e+1) e he + (fun i => Nat.lt_succ_of_le (le_sup (f:=e) (mem_univ i))) c x hx hx0 hxT hz + +end SturmPowerFamily +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Set + +noncomputable def translatedU (a : ℝ) (j : ℕ) (t : ℝ) : ℝ := + cosineKernelJet 0 j (t^2) (-a) +noncomputable def translatedUPrime (a : ℝ) (j : ℕ) (t : ℝ) : ℝ := + 2*t*cosineKernelJet 1 j (t^2) (-a) +noncomputable def translatedF (a : ℝ) (j : ℕ) (t : ℝ) : ℝ := + translatedU a j t/translatedU a 0 t +noncomputable def translatedH (a : ℝ) (j : ℕ) (t : ℝ) : ℝ := + translatedUPrime a j t*translatedU a 0 t-translatedU a j t*translatedUPrime a 0 t + +lemma translatedU_hasDerivAt (a : ℝ) (j : ℕ) (t : ℝ) : + HasDerivAt (translatedU a j) (translatedUPrime a j t) t := by + have h := (cosineKernelJet_hasDerivAt_left 0 j (t^2) (-a)).comp t ((hasDerivAt_id t).pow 2) + convert! h using 1 ; simp only [translatedUPrime,id_eq, + pow_one,Nat.cast_ofNat,mul_one,Nat.cast_zero,zero_add,show 2-1=1 by omega] ; ring + +lemma translatedUPrime_hasDerivAt (a : ℝ) (j : ℕ) (t : ℝ) : + HasDerivAt (translatedUPrime a j) + (2*cosineKernelJet 1 j (t^2) (-a)+8*t^2*cosineKernelJet 2 j (t^2) (-a)) t := by + have hJ := (cosineKernelJet_hasDerivAt_left 1 j (t^2) (-a)).comp t ((hasDerivAt_id t).pow 2) + convert! (((hasDerivAt_id t).const_mul 2).mul hJ) using 1 ; + simp only [Function.comp_def,Pi.pow_apply,id_eq,pow_one, + Nat.cast_ofNat,mul_one,show 2-1=1 by omega] ; ring + +lemma translatedUPrime_zero_deriv (a t : ℝ) : + HasDerivAt (translatedUPrime a 0) (-a*translatedU a 0 t) t := by + simpa only [cosineKernelJet_ode_at_square,translatedU] using translatedUPrime_hasDerivAt a 0 t +lemma translatedUPrime_succ_deriv (a t : ℝ) (j : ℕ) : + HasDerivAt (translatedUPrime a (j+1)) (-a*translatedU a (j+1) t+translatedU a j t) t := by + simpa only [cosineKernelJet_shifted_ode,translatedU] using translatedUPrime_hasDerivAt a (j+1) t + +lemma translatedU_zero_eq_cos {a : ℝ} (ha : 0 ≤ a) (t : ℝ) : + translatedU a 0 t=Real.cos (t*Real.sqrt a) := by + simpa only [Real.sq_sqrt ha,translatedU] using cosineKernelJet_square_cos t (Real.sqrt a) + +lemma translatedU_zero_pos {a T : ℝ} (ha : 0 ≤ a) (hT : T*Real.sqrt a < Real.pi/2) + {t : ℝ} (ht : t ∈ Icc 0 T) : 0 < translatedU a 0 t := by + rw [translatedU_zero_eq_cos ha] + apply Real.cos_pos_of_mem_Ioo + constructor + · have hp : 0 < Real.pi/2 := by positivity + have hx : 0 ≤ t*Real.sqrt a := mul_nonneg ht.1 (Real.sqrt_nonneg a) + linarith + · exact (mul_le_mul_of_nonneg_right ht.2 (Real.sqrt_nonneg a)).trans_lt hT + +lemma translatedF_hasDerivAt {a t : ℝ} (j : ℕ) (hc : translatedU a 0 t ≠ 0) : + HasDerivAt (translatedF a j) (translatedH a j t/(translatedU a 0 t)^2) t := by + exact (translatedU_hasDerivAt a j t).div (translatedU_hasDerivAt a 0 t) hc + +lemma translatedH_succ_deriv (a t : ℝ) (j : ℕ) : + HasDerivAt (translatedH a (j+1)) (translatedU a 0 t*translatedU a j t) t := by + have h := ((translatedUPrime_succ_deriv a t j).mul (translatedU_hasDerivAt a 0 t)).sub + ((translatedU_hasDerivAt a (j+1) t).mul (translatedUPrime_zero_deriv a t)) + convert! h using 1 ; first | rfl | ring + +lemma translatedU_initial (a : ℝ) (j : ℕ) : + translatedU a j 0=if j=0 then 1 else 0 := by + simp only [translatedU,zero_pow (by omega : 2 ≠ 0),cosineKernelJet,kernelJetTerm, + polynomialJet_at_zero_X_pow] + rw [tsum_eq_single 0] + · simp [polynomialJet,Polynomial.coeff_one] + · intro k hk + simp [hk] + +lemma translatedH_initial (a : ℝ) (j : ℕ) : translatedH a j 0=0 := by + simp [translatedH,translatedUPrime] + +noncomputable def translatedSturmFamily {a T : ℝ} (ha : 0 ≤ a) + (hT : T*Real.sqrt a < Real.pi/2) : SturmPowerFamily T where + F := translatedF a + H := translatedH a + w := fun t => (translatedU a 0 t)^2 + wpos := fun t ht => sq_pos_of_pos (translatedU_zero_pos ha hT ⟨ht.1.le,ht.2.le⟩) + Fcontinuous := fun j => by + intro t ht + exact (translatedF_hasDerivAt j (ne_of_gt (translatedU_zero_pos ha hT ht))).continuousAt.continuousWithinAt + Hcontinuous := fun j => by + intro t ht + exact (((translatedUPrime_hasDerivAt a j t).continuousAt.mul (translatedU_hasDerivAt a 0 t).continuousAt).sub + ((translatedU_hasDerivAt a j t).continuousAt.mul (translatedUPrime_hasDerivAt a 0 t).continuousAt)).continuousWithinAt + Fderiv := fun j t ht => translatedF_hasDerivAt j (ne_of_gt (translatedU_zero_pos ha hT ⟨ht.1.le,ht.2.le⟩)) + Hderiv := fun j t ht => by + have hc := ne_of_gt (translatedU_zero_pos ha hT ⟨ht.1.le,ht.2.le⟩) + convert translatedH_succ_deriv a t j using 1 + simp only [translatedF] + field_simp + + Fzero := fun t ht => div_self (ne_of_gt (translatedU_zero_pos ha hT ht)) + Hzero := fun t ht => by unfold translatedH;ring + Finit := fun j hj => by simp [translatedF,translatedU_initial,Nat.ne_of_gt hj] + Hinit := translatedH_initial a + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Set Finset + +lemma translatedU_parameter_continuous (j : ℕ) (t : ℝ) : + Continuous (fun a => translatedU a j t) := by + exact (cosineKernelJet_contDiff_right 0 j (t^2) 0).continuous.comp continuous_neg + +lemma translatedU_parameter_zero (j : ℕ) (t : ℝ) : + translatedU 0 j t=(t^2)^j/(2*j).factorial := by + simp only [translatedU,neg_zero,cosineKernelJet_symm 0 j] + exact cosineKernelJet_at_zero j (t^2) + +lemma translatedU_det_ne_zero {n : ℕ} {a T : ℝ} (ha : 0 ≤ a) + (hT : T*Real.sqrt a < Real.pi/2) (e : Fin n → ℕ) (he : StrictMono e) + (t : Fin n → ℝ) (ht : StrictMono t) (ht0 : ∀ i,0 < t i) (htT : ∀ i,t i < T) : + Matrix.det (fun i j => translatedU a (e i) (t j)) ≠ 0 := by + classical + apply isUnit_iff_ne_zero.mp + apply (Matrix.isUnit_iff_isUnit_det _).mp + apply Matrix.linearIndependent_rows_iff_isUnit.mp + rw [Fintype.linearIndependent_iff] + intro c hc i + have hz : ∀ j,SturmPowerFamily.combination (translatedSturmFamily ha hT).F e c (t j)=0 := by + intro j + have h := congrFun hc j + simp only [Matrix.row,Finset.sum_apply,Pi.smul_apply,smul_eq_mul,Pi.zero_apply] at h + change ∑ k,c k*(translatedU a (e k) (t j)/translatedU a 0 (t j))=0 + simp_rw [←mul_div_assoc,←sum_div] + rw [h,zero_div] + have hz' := (translatedSturmFamily ha hT).sparse_unique e he c t ht ht0 htT hz + exact congrFun hz' i + +lemma translatedU_det_pos_zero {n : ℕ} (e : Fin n → ℕ) (he : StrictMono e) + (t : Fin n → ℝ) (ht : StrictMono t) (ht0 : ∀ i,0 < t i) : + 0 < Matrix.det (fun i j => translatedU 0 (e i) (t j)) := by + simp_rw [translatedU_parameter_zero,div_eq_inv_mul] + change 0 < (Matrix.of (fun i j => ((2*e i).factorial:ℝ)⁻¹*(t j^2)^e i)).det + have hd := Matrix.det_mul_column (fun i => ((2*e i).factorial:ℝ)⁻¹) (Matrix.of (fun i j => (t j^2)^e i)) + simp only [Matrix.of_apply] at hd + rw [hd] + apply mul_pos (prod_pos (fun i _ => by positivity)) + apply power_det_pos e (fun i => (t i)^2) he + · intro i j hij + exact pow_lt_pow_left₀ (ht hij) (ht0 i).le (by omega : 2 ≠ 0) + · intro i + exact sq_pos_of_pos (ht0 i) + +lemma translatedU_det_pos {n : ℕ} {a T : ℝ} (ha : 0 ≤ a) (hT0 : 0 ≤ T) + (hT : T*Real.sqrt a < Real.pi/2) (e : Fin n → ℕ) (he : StrictMono e) + (t : Fin n → ℝ) (ht : StrictMono t) (ht0 : ∀ i,0 < t i) (htT : ∀ i,t i < T) : + 0 < Matrix.det (fun i j => translatedU a (e i) (t j)) := by + let f : ℝ → ℝ := fun b => Matrix.det (fun i j => translatedU b (e i) (t j)) + have hf : Continuous f := by + apply Continuous.matrix_det + exact continuous_pi (fun i => continuous_pi (fun j => translatedU_parameter_continuous (e i) (t j))) + have h0 : 0 < f 0 := translatedU_det_pos_zero e he t ht ht0 + have hne : ∀ b ∈ Icc 0 a,f b ≠ 0 := by + intro b hb + apply translatedU_det_ne_zero hb.1 _ e he t ht ht0 htT + exact (mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt hb.2) hT0).trans_lt hT + by_contra hneg + have hh : f a ≤ 0 := le_of_not_gt hneg + obtain ⟨b,hb,hbz⟩ := intermediate_value_Icc' ha hf.continuousOn ⟨hh,h0.le⟩ + exact hne b hb hbz + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section + +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Set Filter Topology + +lemma translated_beta_eval_det_pos {n : ℕ} {a R : ℝ} (ha : 0 ≤ a) + (hphase : Real.sqrt R*Real.sqrt a < Real.pi/2) + (b : Fin n → ℝ) (hb : StrictMono b) (hb0 : ∀ i,0 < b i) (hbR : ∀ i,b i < R) + (e : Fin n → ℕ) (he : StrictMono e) : + 0 < Matrix.det (fun i j => cosineKernelJet 0 (e i) (b j) (-a)) := by + have hp := translatedU_det_pos ha (Real.sqrt_nonneg R) hphase e he + (fun i => Real.sqrt (b i)) + (fun i j hij => Real.sqrt_lt_sqrt (hb0 i).le (hb hij)) + (fun i => Real.sqrt_pos.mpr (hb0 i)) + (fun i => Real.sqrt_lt_sqrt (hb0 i).le (hbR i)) + simpa only [translatedU,Real.sq_sqrt (hb0 _).le] using hp + +lemma newtonKernel_det_pos_strict {n : ℕ} {a R : ℝ} (ha : 0 ≤ a) (hR : 0 < R) + (hphase : Real.sqrt R*Real.sqrt a < Real.pi/2) + (b : ℕ → ℝ) (hb : StrictMono (fun i : Fin n => b i)) + (hb0 : ∀ i : Fin n,0 < b i) (hbR : ∀ i : Fin n,b i < R) + (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) (e : Fin n → ℕ) (he : StrictMono e) : + 0 < Matrix.det (fun i j : Fin n => newtonKernel b (-a) (e i) j) := by + have hp := translated_beta_eval_det_pos ha hphase (fun i : Fin n => b i) hb hb0 hbR e he + have hd := cosineKernelJet_det_newton (show 1 ≤ R+1 by linarith) + (fun i => (abs_le.mpr ⟨by linarith [(hball i).1],by linarith [(hball i).2]⟩ : |b i| ≤ R+1)) (-a) e + simp only [nodalOrder_eq_zero_strict hb] at hd + rw [hd] at hp + exact (mul_pos_iff_of_pos_right (newtonJetMatrix_det_pos b hb.monotone)).mp hp + +noncomputable def inwardNodes (n : ℕ) (R : ℝ) (j : ℕ) : ℝ := + R*((min j n : ℕ)+1:ℝ)/((n:ℝ)+1) + +lemma inwardNodes_pos {R : ℝ} (hR : 0 < R) (n j : ℕ) : 0 < inwardNodes n R j := by + unfold inwardNodes + positivity +lemma inwardNodes_le {R : ℝ} (hR : 0 ≤ R) (n j : ℕ) : inwardNodes n R j ≤ R := by + unfold inwardNodes + rw [div_le_iff₀ (by positivity)] + have hm : ((min j n : ℕ):ℝ) ≤ n := by exact_mod_cast min_le_right j n + nlinarith +lemma inwardNodes_lt {R : ℝ} (hR : 0 < R) {n : ℕ} (j : Fin n) : inwardNodes n R j < R := by + unfold inwardNodes + rw [div_lt_iff₀ (by positivity)] + have hm : ((min j.val n : ℕ):ℝ) < n := by exact_mod_cast (min_le_left j.val n).trans_lt j.isLt + nlinarith +lemma inwardNodes_strictMono {R : ℝ} (hR : 0 < R) (n : ℕ) : + StrictMono (fun j : Fin n => inwardNodes n R j) := by + intro i j hij + dsimp only [inwardNodes] + rw [min_eq_left (Nat.le_of_lt i.isLt),min_eq_left (Nat.le_of_lt j.isLt)] + apply div_lt_div_of_pos_right _ (by positivity) + apply mul_lt_mul_of_pos_left _ hR + exact_mod_cast Nat.add_lt_add_right hij 1 + +noncomputable def inwardPerturb (n : ℕ) (R : ℝ) (b : ℕ → ℝ) (s : ℝ) (j : ℕ) : ℝ := + (1-s)*b j+s*inwardNodes n R j + +lemma inwardPerturb_range {n : ℕ} {R : ℝ} {b : ℕ → ℝ} (hR : 0 < R) + (hb : ∀ j,0 ≤ b j ∧ b j ≤ R) {s : ℝ} (hs : s ∈ Icc 0 1) (j : ℕ) : + 0 ≤ inwardPerturb n R b s j ∧ inwardPerturb n R b s j ≤ R := by + have hv0 := (inwardNodes_pos hR n j).le + have hvR := inwardNodes_le hR.le n j + dsimp [inwardPerturb] + constructor + · exact add_nonneg (mul_nonneg (sub_nonneg.mpr hs.2) (hb j).1) (mul_nonneg hs.1 hv0) + · nlinarith [mul_nonneg (sub_nonneg.mpr hs.2) (sub_nonneg.mpr (hb j).2), + mul_nonneg hs.1 (sub_nonneg.mpr hvR)] + +lemma inwardPerturb_strict {n : ℕ} {R : ℝ} {b : ℕ → ℝ} (hR : 0 < R) + (hb : ∀ j,0 ≤ b j ∧ b j ≤ R) (hbmono : Monotone (fun j : Fin n => b j)) + {s : ℝ} (hs : s ∈ Ioc 0 1) : + StrictMono (fun j : Fin n => inwardPerturb n R b s j) ∧ + (∀ j : Fin n,0 < inwardPerturb n R b s j) ∧ + (∀ j : Fin n,inwardPerturb n R b s j < R) := by + refine ⟨?_,?_,?_⟩ + · intro i j hij + have hv := inwardNodes_strictMono hR n hij + have hb' := hbmono hij.le + dsimp [inwardPerturb] + nlinarith [mul_nonneg (sub_nonneg.mpr hs.2) (sub_nonneg.mpr hb'),mul_pos hs.1 (sub_pos.mpr hv)] + · intro j + exact add_pos_of_nonneg_of_pos (mul_nonneg (sub_nonneg.mpr hs.2) (hb j).1) + (mul_pos hs.1 (inwardNodes_pos hR n j)) + · intro j + have hv := inwardNodes_lt hR j + dsimp [inwardPerturb] + nlinarith [mul_nonneg (sub_nonneg.mpr hs.2) (sub_nonneg.mpr (hb j).2),mul_pos hs.1 (sub_pos.mpr hv)] + +lemma translated_newton_det_nonneg {n : ℕ} {a R : ℝ} (ha : 0 ≤ a) (hR : 0 < R) + (hphase : Real.sqrt R*Real.sqrt a < Real.pi/2) (b : ℕ → ℝ) + (hb : Monotone (fun i : Fin n => b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (e : Fin n → ℕ) (he : StrictMono e) : + 0 ≤ Matrix.det (fun i j : Fin n => newtonKernel b (-a) (e i) j) := by + let f : ℝ → ℝ := fun s => Matrix.det (fun i j : Fin n => newtonKernel (inwardPerturb n R b s) (-a) (e i) j) + have hc : ContinuousOn f (Icc 0 1) := by + apply (continuous_id.matrix_det).comp_continuousOn + apply continuousOn_pi.mpr + intro i + apply continuousOn_pi.mpr + intro j + apply continuousOn_newtonKernel (show 1 ≤ R+1 by linarith) + · exact (show Continuous (inwardPerturb n R b) by unfold inwardPerturb;fun_prop).continuousOn + · intro s hs k + have hh := inwardPerturb_range hR hball hs k (n:=n) + rw [abs_of_nonneg hh.1] + linarith + have ht : Tendsto f (𝓝[>] (0:ℝ)) (𝓝 (f 0)) := by + have hh := (hc 0 (show (0:ℝ) ∈ Icc 0 1 by norm_num)).mono (show Ioc (0:ℝ) 1 ⊆ Icc 0 1 from fun _ h => ⟨h.1.le,h.2⟩) + simpa only [ContinuousWithinAt,nhdsWithin_Ioc_eq_nhdsGT (show (0:ℝ) < 1 by norm_num)] using hh + have hp : ∀ᶠ s in 𝓝[>] (0:ℝ),0 ≤ f s := by + filter_upwards [self_mem_nhdsWithin,(eventually_lt_nhds (show (0:ℝ) < 1 by norm_num)).filter_mono nhdsWithin_le_nhds] with s hs hs1 + have hh := inwardPerturb_strict hR hball hb ⟨hs,hs1.le⟩ + exact (newtonKernel_det_pos_strict ha hR hphase _ hh.1 hh.2.1 hh.2.2 + (inwardPerturb_range hR hball ⟨hs.le,hs1.le⟩) e he).le + have hh := ge_of_tendsto ht hp + have hzero : inwardPerturb n R b 0=b := by funext j;simp [inwardPerturb] + simpa only [f,hzero] using hh + +lemma translated_beta_jet_det_nonneg {n : ℕ} {a R : ℝ} (ha : 0 ≤ a) (hR : 0 < R) + (hphase : Real.sqrt R*Real.sqrt a < Real.pi/2) (b : ℕ → ℝ) + (hb : Monotone (fun i : Fin n => b i)) (hball : ∀ i,0 ≤ b i ∧ b i ≤ R) + (e : Fin n → ℕ) (he : StrictMono e) : + 0 ≤ Matrix.det (fun i j : Fin n => cosineKernelJet (nodalOrder b j) (e i) (b j) (-a)) := by + rw [cosineKernelJet_det_newton (show 1 ≤ R+1 by linarith) + (fun i => (abs_le.mpr ⟨by linarith [(hball i).1],by linarith [(hball i).2]⟩ : |b i| ≤ R+1))] + exact mul_nonneg (translated_newton_det_nonneg ha hR hphase b hb hball e he) + (newtonJetMatrix_det_pos b hb).le + +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxter.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxter.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbc1e656ab6ee11031752fb45c58b702aaf27d1d --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxter.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterPositive +import OAI.Combinatorics.HoneycombChords.YangBaxterZero +import OAI.Combinatorics.HoneycombChords.YangBaxterNegative +import OAI.Combinatorics.HoneycombChords.YangBaxterWeights + +namespace OAI + +/-! The honeycomb Yang–Baxter identity in the sine parametrization. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +section Algebra +variable (C A S x y z w ii : ℂ) +variable (hC : C = (2*S+1)*A) (hA : A^2 = (1-S)/2) + (hS : S^2 = 1/2) (hy : y^2+x^2=1) (hw : w^2+z^2=1) (hi : ii^2+1=0) + +include hC hA hS hy hw hi in +theorem numerator_yang_baxter (a b c d e f : Fin 3) : + leftComponent C A S x y z w ii a b c d e f = + rightComponent C A S x y z w ii a b c d e f := by + fin_cases a <;> fin_cases b <;> fin_cases c + · exact block_000 C A S x y z w ii d e f + · exact block_001 C A S x y z w ii hC hA hS hy hw d e f + · exact block_002 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_010 C A S x y z w ii hy d e f + · exact block_011 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_012 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_020 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_021 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_022 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_100 C A S x y z w ii hC hA hS hy hw d e f + · exact block_101 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_102 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_110 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_111 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_112 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_120 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_121 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_122 C A S x y z w ii hC hA hS hy hw d e f + · exact block_200 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_201 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_202 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_210 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_211 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_212 C A S x y z w ii hy d e f + · exact block_220 C A S x y z w ii hC hA hS hy hw hi d e f + · exact block_221 C A S x y z w ii hC hA hS hy hw d e f + · exact block_222 C A S x y z w ii d e f + +end Algebra + +theorem source_yang_baxter (u v : ℝ) + (hu : denominator u ≠ 0) (hv : denominator v ≠ 0) + (hd : denominator (u-v) ≠ 0) (a b c d e f : Fin 3) : + (∑ j : Fin 3, ∑ k : Fin 3, ∑ l : Fin 3, + sourceR (u-v) (a,b) (j,k) * sourceR u (j,c) (d,l) * + sourceR v (k,l) (e,f)) = + (∑ j : Fin 3, ∑ k : Fin 3, ∑ l : Fin 3, + sourceR v (b,c) (k,l) * sourceR u (a,l) (j,f) * + sourceR (u-v) (j,k) (d,e)) := by + rw [physical_left_sum _ _ hu hv hd, physical_right_sum _ _ hu hv hd] + obtain ⟨hC,hA,hS,hy,hw,hi⟩ := trig_constraints u v + rw [numerator_yang_baxter _ _ _ _ _ _ _ _ hC hA hS hy hw hi] + +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterDefinitions.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterDefinitions.lean new file mode 100644 index 0000000000000000000000000000000000000000..8aae943829f7332fb93a6137bb56c14b5431203c --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterDefinitions.lean @@ -0,0 +1,63 @@ +import Mathlib.Basic.Complex.Basic +import Mathlib.Algebra.BigOperators.Fin + +namespace OAI + +/-! Local numerator matrices for the honeycomb Yang–Baxter identity. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +noncomputable def numerator (C A S x y ii : ℂ) (p q : Fin 3 × Fin 3) : ℂ := + let cc := (C*y-A*x)*S*(y-x) + let aa := S*(C*y-A*x) + let vv := (C*y-A*x)*x + let dd := x*(C*x-A*y) + let qq := S*(y+x)*(C*y+A*x) + match p.1.val, p.2.val, q.1.val, q.2.val with + | 0, 0, 0, 0 => cc + | 2, 2, 2, 2 => cc + | 0, 1, 0, 1 => vv + | 1, 0, 1, 0 => vv + | 2, 1, 2, 1 => vv + | 1, 2, 1, 2 => vv + | 0, 1, 1, 0 => aa + | 1, 0, 0, 1 => aa + | 2, 1, 1, 2 => aa + | 1, 2, 2, 1 => aa + | 0, 2, 0, 2 => dd + | 0, 2, 1, 1 => x/2*(1-ii) + | 0, 2, 2, 0 => cc-ii*dd + | 1, 1, 0, 2 => x/2*(1+ii) + | 1, 1, 1, 1 => qq + | 1, 1, 2, 0 => x/2*(1-ii) + | 2, 0, 0, 2 => cc+ii*dd + | 2, 0, 1, 1 => x/2*(1+ii) + | 2, 0, 2, 0 => dd + | _, _, _, _ => 0 + +noncomputable def leftComponent (C A S x y z w ii : ℂ) + (a b c d e f : Fin 3) : ℂ := + ∑ j : Fin 3, ∑ k : Fin 3, ∑ l : Fin 3, + numerator C A S (x*w-y*z) (y*w+x*z) ii (a,b) (j,k) * + numerator C A S x y ii (j,c) (d,l) * + numerator C A S z w ii (k,l) (e,f) + +noncomputable def rightComponent (C A S x y z w ii : ℂ) + (a b c d e f : Fin 3) : ℂ := + ∑ j : Fin 3, ∑ k : Fin 3, ∑ l : Fin 3, + numerator C A S z w ii (b,c) (k,l) * + numerator C A S x y ii (a,l) (j,f) * + numerator C A S (x*w-y*z) (y*w+x*z) ii (j,k) (d,e) + +abbrev complexAdd (a b : ℂ) : ℂ := a+b +abbrev complexMul (a b : ℂ) : ℂ := a*b +abbrev complexPow (a : ℂ) (n : ℕ) : ℂ := a^n +lemma finThreeTwo : (2:Fin 3).val = 2 := rfl + +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterNegative.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterNegative.lean new file mode 100644 index 0000000000000000000000000000000000000000..38aa7c5e102afa56506bcaac0eba68cfd50d56dc --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterNegative.lean @@ -0,0 +1,1882 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterPolynomialsPositive +import OAI.Combinatorics.HoneycombChords.YangBaxterPolynomialsZero +import OAI.Combinatorics.HoneycombChords.YangBaxterPolynomialsNegative +import OAI.Combinatorics.HoneycombChords.YangBaxterSupport +import Mathlib.Tactic.FinCases + +namespace OAI + +/-! Yang–Baxter components with first spin negative. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +section Algebra +variable (C A S x y z w ii : ℂ) +variable (hC : C = (2*S+1)*A) (hA : A^2 = (1-S)/2) + (hS : S^2 = 1/2) (hy : y^2+x^2=1) (hw : w^2+z^2=1) (hi : ii^2+1=0) + +include hC hA hS hy hw hi in +lemma component_200002 : + leftComponent C A S x y z w ii 2 0 0 0 0 2 = + rightComponent C A S x y z w ii 2 0 0 0 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_200002 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_200002_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_200011 : + leftComponent C A S x y z w ii 2 0 0 0 1 1 = + rightComponent C A S x y z w ii 2 0 0 0 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_200011 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_200011_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_201012 : + leftComponent C A S x y z w ii 2 0 1 0 1 2 = + rightComponent C A S x y z w ii 2 0 1 0 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_201012 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_201012_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_200020 : + leftComponent C A S x y z w ii 2 0 0 0 2 0 = + rightComponent C A S x y z w ii 2 0 0 0 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_200101 : + leftComponent C A S x y z w ii 2 0 0 1 0 1 = + rightComponent C A S x y z w ii 2 0 0 1 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_121022 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_121022_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_200110 : + leftComponent C A S x y z w ii 2 0 0 1 1 0 = + rightComponent C A S x y z w ii 2 0 0 1 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_112022 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_112022_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_201102 : + leftComponent C A S x y z w ii 2 0 1 1 0 2 = + rightComponent C A S x y z w ii 2 0 1 1 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_120021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_120021_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_201111 : + leftComponent C A S x y z w ii 2 0 1 1 1 1 = + rightComponent C A S x y z w ii 2 0 1 1 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_111021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_111021_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_201120 : + leftComponent C A S x y z w ii 2 0 1 1 2 0 = + rightComponent C A S x y z w ii 2 0 1 1 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021102_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_201210 : + leftComponent C A S x y z w ii 2 0 1 2 1 0 = + rightComponent C A S x y z w ii 2 0 1 2 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012021_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_202022 : + leftComponent C A S x y z w ii 2 0 2 0 2 2 = + rightComponent C A S x y z w ii 2 0 2 0 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_202112 : + leftComponent C A S x y z w ii 2 0 2 1 1 2 = + rightComponent C A S x y z w ii 2 0 2 1 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_110020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_110020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_202121 : + leftComponent C A S x y z w ii 2 0 2 1 2 1 = + rightComponent C A S x y z w ii 2 0 2 1 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_101020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_202202 : + leftComponent C A S x y z w ii 2 0 2 2 0 2 = + rightComponent C A S x y z w ii 2 0 2 2 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_202211 : + leftComponent C A S x y z w ii 2 0 2 2 1 1 = + rightComponent C A S x y z w ii 2 0 2 2 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_202220 : + leftComponent C A S x y z w ii 2 0 2 2 2 0 = + rightComponent C A S x y z w ii 2 0 2 2 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_210021 : + leftComponent C A S x y z w ii 2 1 0 0 2 1 = + rightComponent C A S x y z w ii 2 1 0 0 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_201012 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_201012_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_210102 : + leftComponent C A S x y z w ii 2 1 0 1 0 2 = + rightComponent C A S x y z w ii 2 1 0 1 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_120012 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_120012_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_210111 : + leftComponent C A S x y z w ii 2 1 0 1 1 1 = + rightComponent C A S x y z w ii 2 1 0 1 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_111012 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_111012_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_210120 : + leftComponent C A S x y z w ii 2 1 0 1 2 0 = + rightComponent C A S x y z w ii 2 1 0 1 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012102_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_210201 : + leftComponent C A S x y z w ii 2 1 0 2 0 1 = + rightComponent C A S x y z w ii 2 1 0 2 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012021_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_211022 : + leftComponent C A S x y z w ii 2 1 1 0 2 2 = + rightComponent C A S x y z w ii 2 1 1 0 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_200011 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_200011_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_211112 : + leftComponent C A S x y z w ii 2 1 1 1 1 2 = + rightComponent C A S x y z w ii 2 1 1 1 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_110011 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_110011_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_211121 : + leftComponent C A S x y z w ii 2 1 1 1 2 1 = + rightComponent C A S x y z w ii 2 1 1 1 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011101 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011101_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_211202 : + leftComponent C A S x y z w ii 2 1 1 2 0 2 = + rightComponent C A S x y z w ii 2 1 1 2 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020011 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020011_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_211220 : + leftComponent C A S x y z w ii 2 1 1 2 2 0 = + rightComponent C A S x y z w ii 2 1 1 2 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002011 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_002011_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hy in +lemma component_212221 : + leftComponent C A S x y z w ii 2 1 2 2 2 1 = + rightComponent C A S x y z w ii 2 1 2 2 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001010 C A S x y z w ii hy + dsimp only [poly_001010_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_220022 : + leftComponent C A S x y z w ii 2 2 0 0 2 2 = + rightComponent C A S x y z w ii 2 2 0 0 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_200002 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_200002_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_220112 : + leftComponent C A S x y z w ii 2 2 0 1 1 2 = + rightComponent C A S x y z w ii 2 2 0 1 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_110002 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_110002_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_220121 : + leftComponent C A S x y z w ii 2 2 0 1 2 1 = + rightComponent C A S x y z w ii 2 2 0 1 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101002 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_101002_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_220202 : + leftComponent C A S x y z w ii 2 2 0 2 0 2 = + rightComponent C A S x y z w ii 2 2 0 2 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_220211 : + leftComponent C A S x y z w ii 2 2 0 2 1 1 = + rightComponent C A S x y z w ii 2 2 0 2 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011002 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_011002_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_221122 : + leftComponent C A S x y z w ii 2 2 1 1 2 2 = + rightComponent C A S x y z w ii 2 2 1 1 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001100 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_001100_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hy in +lemma component_221212 : + leftComponent C A S x y z w ii 2 2 1 2 1 2 = + rightComponent C A S x y z w ii 2 2 1 2 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001010 C A S x y z w ii hy + dsimp only [poly_001010_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +lemma component_200000 : + leftComponent C A S x y z w ii 2 0 0 0 0 0 = + rightComponent C A S x y z w ii 2 0 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 0 0 (by decide)] + +lemma component_200001 : + leftComponent C A S x y z w ii 2 0 0 0 0 1 = + rightComponent C A S x y z w ii 2 0 0 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 0 1 (by decide)] + +lemma component_200010 : + leftComponent C A S x y z w ii 2 0 0 0 1 0 = + rightComponent C A S x y z w ii 2 0 0 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 1 0 (by decide)] + +lemma component_200012 : + leftComponent C A S x y z w ii 2 0 0 0 1 2 = + rightComponent C A S x y z w ii 2 0 0 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 1 2 (by decide)] + +lemma component_200021 : + leftComponent C A S x y z w ii 2 0 0 0 2 1 = + rightComponent C A S x y z w ii 2 0 0 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 2 1 (by decide)] + +lemma component_200022 : + leftComponent C A S x y z w ii 2 0 0 0 2 2 = + rightComponent C A S x y z w ii 2 0 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 0 2 2 (by decide)] + +lemma component_200100 : + leftComponent C A S x y z w ii 2 0 0 1 0 0 = + rightComponent C A S x y z w ii 2 0 0 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 0 0 (by decide)] + +lemma component_200102 : + leftComponent C A S x y z w ii 2 0 0 1 0 2 = + rightComponent C A S x y z w ii 2 0 0 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 0 2 (by decide)] + +lemma component_200111 : + leftComponent C A S x y z w ii 2 0 0 1 1 1 = + rightComponent C A S x y z w ii 2 0 0 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 1 1 (by decide)] + +lemma component_200112 : + leftComponent C A S x y z w ii 2 0 0 1 1 2 = + rightComponent C A S x y z w ii 2 0 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 1 2 (by decide)] + +lemma component_200120 : + leftComponent C A S x y z w ii 2 0 0 1 2 0 = + rightComponent C A S x y z w ii 2 0 0 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 2 0 (by decide)] + +lemma component_200121 : + leftComponent C A S x y z w ii 2 0 0 1 2 1 = + rightComponent C A S x y z w ii 2 0 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 2 1 (by decide)] + +lemma component_200122 : + leftComponent C A S x y z w ii 2 0 0 1 2 2 = + rightComponent C A S x y z w ii 2 0 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 1 2 2 (by decide)] + +lemma component_200200 : + leftComponent C A S x y z w ii 2 0 0 2 0 0 = + rightComponent C A S x y z w ii 2 0 0 2 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_200201 : + leftComponent C A S x y z w ii 2 0 0 2 0 1 = + rightComponent C A S x y z w ii 2 0 0 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 0 1 (by decide)] + +lemma component_200202 : + leftComponent C A S x y z w ii 2 0 0 2 0 2 = + rightComponent C A S x y z w ii 2 0 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 0 2 (by decide)] + +lemma component_200210 : + leftComponent C A S x y z w ii 2 0 0 2 1 0 = + rightComponent C A S x y z w ii 2 0 0 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 1 0 (by decide)] + +lemma component_200211 : + leftComponent C A S x y z w ii 2 0 0 2 1 1 = + rightComponent C A S x y z w ii 2 0 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 1 1 (by decide)] + +lemma component_200212 : + leftComponent C A S x y z w ii 2 0 0 2 1 2 = + rightComponent C A S x y z w ii 2 0 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 1 2 (by decide)] + +lemma component_200220 : + leftComponent C A S x y z w ii 2 0 0 2 2 0 = + rightComponent C A S x y z w ii 2 0 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 2 0 (by decide)] + +lemma component_200221 : + leftComponent C A S x y z w ii 2 0 0 2 2 1 = + rightComponent C A S x y z w ii 2 0 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 2 1 (by decide)] + +lemma component_200222 : + leftComponent C A S x y z w ii 2 0 0 2 2 2 = + rightComponent C A S x y z w ii 2 0 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 0 2 2 2 (by decide)] + +lemma component_201000 : + leftComponent C A S x y z w ii 2 0 1 0 0 0 = + rightComponent C A S x y z w ii 2 0 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 0 0 (by decide)] + +lemma component_201001 : + leftComponent C A S x y z w ii 2 0 1 0 0 1 = + rightComponent C A S x y z w ii 2 0 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 0 1 (by decide)] + +lemma component_201002 : + leftComponent C A S x y z w ii 2 0 1 0 0 2 = + rightComponent C A S x y z w ii 2 0 1 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 0 2 (by decide)] + +lemma component_201010 : + leftComponent C A S x y z w ii 2 0 1 0 1 0 = + rightComponent C A S x y z w ii 2 0 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 1 0 (by decide)] + +lemma component_201011 : + leftComponent C A S x y z w ii 2 0 1 0 1 1 = + rightComponent C A S x y z w ii 2 0 1 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 1 1 (by decide)] + +lemma component_201020 : + leftComponent C A S x y z w ii 2 0 1 0 2 0 = + rightComponent C A S x y z w ii 2 0 1 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 2 0 (by decide)] + +lemma component_201021 : + leftComponent C A S x y z w ii 2 0 1 0 2 1 = + rightComponent C A S x y z w ii 2 0 1 0 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_201022 : + leftComponent C A S x y z w ii 2 0 1 0 2 2 = + rightComponent C A S x y z w ii 2 0 1 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 0 2 2 (by decide)] + +lemma component_201100 : + leftComponent C A S x y z w ii 2 0 1 1 0 0 = + rightComponent C A S x y z w ii 2 0 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 0 0 (by decide)] + +lemma component_201101 : + leftComponent C A S x y z w ii 2 0 1 1 0 1 = + rightComponent C A S x y z w ii 2 0 1 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 0 1 (by decide)] + +lemma component_201110 : + leftComponent C A S x y z w ii 2 0 1 1 1 0 = + rightComponent C A S x y z w ii 2 0 1 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 1 0 (by decide)] + +lemma component_201112 : + leftComponent C A S x y z w ii 2 0 1 1 1 2 = + rightComponent C A S x y z w ii 2 0 1 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 1 2 (by decide)] + +lemma component_201121 : + leftComponent C A S x y z w ii 2 0 1 1 2 1 = + rightComponent C A S x y z w ii 2 0 1 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 2 1 (by decide)] + +lemma component_201122 : + leftComponent C A S x y z w ii 2 0 1 1 2 2 = + rightComponent C A S x y z w ii 2 0 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 1 2 2 (by decide)] + +lemma component_201200 : + leftComponent C A S x y z w ii 2 0 1 2 0 0 = + rightComponent C A S x y z w ii 2 0 1 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 0 0 (by decide)] + +lemma component_201201 : + leftComponent C A S x y z w ii 2 0 1 2 0 1 = + rightComponent C A S x y z w ii 2 0 1 2 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_201202 : + leftComponent C A S x y z w ii 2 0 1 2 0 2 = + rightComponent C A S x y z w ii 2 0 1 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 0 2 (by decide)] + +lemma component_201211 : + leftComponent C A S x y z w ii 2 0 1 2 1 1 = + rightComponent C A S x y z w ii 2 0 1 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 1 1 (by decide)] + +lemma component_201212 : + leftComponent C A S x y z w ii 2 0 1 2 1 2 = + rightComponent C A S x y z w ii 2 0 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 1 2 (by decide)] + +lemma component_201220 : + leftComponent C A S x y z w ii 2 0 1 2 2 0 = + rightComponent C A S x y z w ii 2 0 1 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 2 0 (by decide)] + +lemma component_201221 : + leftComponent C A S x y z w ii 2 0 1 2 2 1 = + rightComponent C A S x y z w ii 2 0 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 2 1 (by decide)] + +lemma component_201222 : + leftComponent C A S x y z w ii 2 0 1 2 2 2 = + rightComponent C A S x y z w ii 2 0 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 1 2 2 2 (by decide)] + +lemma component_202000 : + leftComponent C A S x y z w ii 2 0 2 0 0 0 = + rightComponent C A S x y z w ii 2 0 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 0 0 (by decide)] + +lemma component_202001 : + leftComponent C A S x y z w ii 2 0 2 0 0 1 = + rightComponent C A S x y z w ii 2 0 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 0 1 (by decide)] + +lemma component_202002 : + leftComponent C A S x y z w ii 2 0 2 0 0 2 = + rightComponent C A S x y z w ii 2 0 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 0 2 (by decide)] + +lemma component_202010 : + leftComponent C A S x y z w ii 2 0 2 0 1 0 = + rightComponent C A S x y z w ii 2 0 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 1 0 (by decide)] + +lemma component_202011 : + leftComponent C A S x y z w ii 2 0 2 0 1 1 = + rightComponent C A S x y z w ii 2 0 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 1 1 (by decide)] + +lemma component_202012 : + leftComponent C A S x y z w ii 2 0 2 0 1 2 = + rightComponent C A S x y z w ii 2 0 2 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 1 2 (by decide)] + +lemma component_202020 : + leftComponent C A S x y z w ii 2 0 2 0 2 0 = + rightComponent C A S x y z w ii 2 0 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 2 0 (by decide)] + +lemma component_202021 : + leftComponent C A S x y z w ii 2 0 2 0 2 1 = + rightComponent C A S x y z w ii 2 0 2 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 0 2 1 (by decide)] + +lemma component_202100 : + leftComponent C A S x y z w ii 2 0 2 1 0 0 = + rightComponent C A S x y z w ii 2 0 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 0 0 (by decide)] + +lemma component_202101 : + leftComponent C A S x y z w ii 2 0 2 1 0 1 = + rightComponent C A S x y z w ii 2 0 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 0 1 (by decide)] + +lemma component_202102 : + leftComponent C A S x y z w ii 2 0 2 1 0 2 = + rightComponent C A S x y z w ii 2 0 2 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 0 2 (by decide)] + +lemma component_202110 : + leftComponent C A S x y z w ii 2 0 2 1 1 0 = + rightComponent C A S x y z w ii 2 0 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 1 0 (by decide)] + +lemma component_202111 : + leftComponent C A S x y z w ii 2 0 2 1 1 1 = + rightComponent C A S x y z w ii 2 0 2 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 1 1 (by decide)] + +lemma component_202120 : + leftComponent C A S x y z w ii 2 0 2 1 2 0 = + rightComponent C A S x y z w ii 2 0 2 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 2 0 (by decide)] + +lemma component_202122 : + leftComponent C A S x y z w ii 2 0 2 1 2 2 = + rightComponent C A S x y z w ii 2 0 2 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 1 2 2 (by decide)] + +lemma component_202200 : + leftComponent C A S x y z w ii 2 0 2 2 0 0 = + rightComponent C A S x y z w ii 2 0 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 0 0 (by decide)] + +lemma component_202201 : + leftComponent C A S x y z w ii 2 0 2 2 0 1 = + rightComponent C A S x y z w ii 2 0 2 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 0 1 (by decide)] + +lemma component_202210 : + leftComponent C A S x y z w ii 2 0 2 2 1 0 = + rightComponent C A S x y z w ii 2 0 2 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 1 0 (by decide)] + +lemma component_202212 : + leftComponent C A S x y z w ii 2 0 2 2 1 2 = + rightComponent C A S x y z w ii 2 0 2 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 1 2 (by decide)] + +lemma component_202221 : + leftComponent C A S x y z w ii 2 0 2 2 2 1 = + rightComponent C A S x y z w ii 2 0 2 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 2 1 (by decide)] + +lemma component_202222 : + leftComponent C A S x y z w ii 2 0 2 2 2 2 = + rightComponent C A S x y z w ii 2 0 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 0 2 2 2 2 (by decide)] + +lemma component_210000 : + leftComponent C A S x y z w ii 2 1 0 0 0 0 = + rightComponent C A S x y z w ii 2 1 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 0 0 (by decide)] + +lemma component_210001 : + leftComponent C A S x y z w ii 2 1 0 0 0 1 = + rightComponent C A S x y z w ii 2 1 0 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 0 1 (by decide)] + +lemma component_210002 : + leftComponent C A S x y z w ii 2 1 0 0 0 2 = + rightComponent C A S x y z w ii 2 1 0 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 0 2 (by decide)] + +lemma component_210010 : + leftComponent C A S x y z w ii 2 1 0 0 1 0 = + rightComponent C A S x y z w ii 2 1 0 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 1 0 (by decide)] + +lemma component_210011 : + leftComponent C A S x y z w ii 2 1 0 0 1 1 = + rightComponent C A S x y z w ii 2 1 0 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 1 1 (by decide)] + +lemma component_210012 : + leftComponent C A S x y z w ii 2 1 0 0 1 2 = + rightComponent C A S x y z w ii 2 1 0 0 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_210020 : + leftComponent C A S x y z w ii 2 1 0 0 2 0 = + rightComponent C A S x y z w ii 2 1 0 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 2 0 (by decide)] + +lemma component_210022 : + leftComponent C A S x y z w ii 2 1 0 0 2 2 = + rightComponent C A S x y z w ii 2 1 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 0 2 2 (by decide)] + +lemma component_210100 : + leftComponent C A S x y z w ii 2 1 0 1 0 0 = + rightComponent C A S x y z w ii 2 1 0 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 0 0 (by decide)] + +lemma component_210101 : + leftComponent C A S x y z w ii 2 1 0 1 0 1 = + rightComponent C A S x y z w ii 2 1 0 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 0 1 (by decide)] + +lemma component_210110 : + leftComponent C A S x y z w ii 2 1 0 1 1 0 = + rightComponent C A S x y z w ii 2 1 0 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 1 0 (by decide)] + +lemma component_210112 : + leftComponent C A S x y z w ii 2 1 0 1 1 2 = + rightComponent C A S x y z w ii 2 1 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 1 2 (by decide)] + +lemma component_210121 : + leftComponent C A S x y z w ii 2 1 0 1 2 1 = + rightComponent C A S x y z w ii 2 1 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 2 1 (by decide)] + +lemma component_210122 : + leftComponent C A S x y z w ii 2 1 0 1 2 2 = + rightComponent C A S x y z w ii 2 1 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 1 2 2 (by decide)] + +lemma component_210200 : + leftComponent C A S x y z w ii 2 1 0 2 0 0 = + rightComponent C A S x y z w ii 2 1 0 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 0 0 (by decide)] + +lemma component_210202 : + leftComponent C A S x y z w ii 2 1 0 2 0 2 = + rightComponent C A S x y z w ii 2 1 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 0 2 (by decide)] + +lemma component_210210 : + leftComponent C A S x y z w ii 2 1 0 2 1 0 = + rightComponent C A S x y z w ii 2 1 0 2 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_210211 : + leftComponent C A S x y z w ii 2 1 0 2 1 1 = + rightComponent C A S x y z w ii 2 1 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 1 1 (by decide)] + +lemma component_210212 : + leftComponent C A S x y z w ii 2 1 0 2 1 2 = + rightComponent C A S x y z w ii 2 1 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 1 2 (by decide)] + +lemma component_210220 : + leftComponent C A S x y z w ii 2 1 0 2 2 0 = + rightComponent C A S x y z w ii 2 1 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 2 0 (by decide)] + +lemma component_210221 : + leftComponent C A S x y z w ii 2 1 0 2 2 1 = + rightComponent C A S x y z w ii 2 1 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 2 1 (by decide)] + +lemma component_210222 : + leftComponent C A S x y z w ii 2 1 0 2 2 2 = + rightComponent C A S x y z w ii 2 1 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 0 2 2 2 (by decide)] + +lemma component_211000 : + leftComponent C A S x y z w ii 2 1 1 0 0 0 = + rightComponent C A S x y z w ii 2 1 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 0 0 (by decide)] + +lemma component_211001 : + leftComponent C A S x y z w ii 2 1 1 0 0 1 = + rightComponent C A S x y z w ii 2 1 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 0 1 (by decide)] + +lemma component_211002 : + leftComponent C A S x y z w ii 2 1 1 0 0 2 = + rightComponent C A S x y z w ii 2 1 1 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 0 2 (by decide)] + +lemma component_211010 : + leftComponent C A S x y z w ii 2 1 1 0 1 0 = + rightComponent C A S x y z w ii 2 1 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 1 0 (by decide)] + +lemma component_211011 : + leftComponent C A S x y z w ii 2 1 1 0 1 1 = + rightComponent C A S x y z w ii 2 1 1 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 1 1 (by decide)] + +lemma component_211012 : + leftComponent C A S x y z w ii 2 1 1 0 1 2 = + rightComponent C A S x y z w ii 2 1 1 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 1 2 (by decide)] + +lemma component_211020 : + leftComponent C A S x y z w ii 2 1 1 0 2 0 = + rightComponent C A S x y z w ii 2 1 1 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 2 0 (by decide)] + +lemma component_211021 : + leftComponent C A S x y z w ii 2 1 1 0 2 1 = + rightComponent C A S x y z w ii 2 1 1 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 0 2 1 (by decide)] + +lemma component_211100 : + leftComponent C A S x y z w ii 2 1 1 1 0 0 = + rightComponent C A S x y z w ii 2 1 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 0 0 (by decide)] + +lemma component_211101 : + leftComponent C A S x y z w ii 2 1 1 1 0 1 = + rightComponent C A S x y z w ii 2 1 1 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 0 1 (by decide)] + +lemma component_211102 : + leftComponent C A S x y z w ii 2 1 1 1 0 2 = + rightComponent C A S x y z w ii 2 1 1 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 0 2 (by decide)] + +lemma component_211110 : + leftComponent C A S x y z w ii 2 1 1 1 1 0 = + rightComponent C A S x y z w ii 2 1 1 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 1 0 (by decide)] + +lemma component_211111 : + leftComponent C A S x y z w ii 2 1 1 1 1 1 = + rightComponent C A S x y z w ii 2 1 1 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 1 1 (by decide)] + +lemma component_211120 : + leftComponent C A S x y z w ii 2 1 1 1 2 0 = + rightComponent C A S x y z w ii 2 1 1 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 2 0 (by decide)] + +lemma component_211122 : + leftComponent C A S x y z w ii 2 1 1 1 2 2 = + rightComponent C A S x y z w ii 2 1 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 1 2 2 (by decide)] + +lemma component_211200 : + leftComponent C A S x y z w ii 2 1 1 2 0 0 = + rightComponent C A S x y z w ii 2 1 1 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 0 0 (by decide)] + +lemma component_211201 : + leftComponent C A S x y z w ii 2 1 1 2 0 1 = + rightComponent C A S x y z w ii 2 1 1 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 0 1 (by decide)] + +lemma component_211210 : + leftComponent C A S x y z w ii 2 1 1 2 1 0 = + rightComponent C A S x y z w ii 2 1 1 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 1 0 (by decide)] + +lemma component_211211 : + leftComponent C A S x y z w ii 2 1 1 2 1 1 = + rightComponent C A S x y z w ii 2 1 1 2 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_211212 : + leftComponent C A S x y z w ii 2 1 1 2 1 2 = + rightComponent C A S x y z w ii 2 1 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 1 2 (by decide)] + +lemma component_211221 : + leftComponent C A S x y z w ii 2 1 1 2 2 1 = + rightComponent C A S x y z w ii 2 1 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 2 1 (by decide)] + +lemma component_211222 : + leftComponent C A S x y z w ii 2 1 1 2 2 2 = + rightComponent C A S x y z w ii 2 1 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 1 2 2 2 (by decide)] + +lemma component_212000 : + leftComponent C A S x y z w ii 2 1 2 0 0 0 = + rightComponent C A S x y z w ii 2 1 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 0 0 (by decide)] + +lemma component_212001 : + leftComponent C A S x y z w ii 2 1 2 0 0 1 = + rightComponent C A S x y z w ii 2 1 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 0 1 (by decide)] + +lemma component_212002 : + leftComponent C A S x y z w ii 2 1 2 0 0 2 = + rightComponent C A S x y z w ii 2 1 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 0 2 (by decide)] + +lemma component_212010 : + leftComponent C A S x y z w ii 2 1 2 0 1 0 = + rightComponent C A S x y z w ii 2 1 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 1 0 (by decide)] + +lemma component_212011 : + leftComponent C A S x y z w ii 2 1 2 0 1 1 = + rightComponent C A S x y z w ii 2 1 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 1 1 (by decide)] + +lemma component_212012 : + leftComponent C A S x y z w ii 2 1 2 0 1 2 = + rightComponent C A S x y z w ii 2 1 2 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 1 2 (by decide)] + +lemma component_212020 : + leftComponent C A S x y z w ii 2 1 2 0 2 0 = + rightComponent C A S x y z w ii 2 1 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 2 0 (by decide)] + +lemma component_212021 : + leftComponent C A S x y z w ii 2 1 2 0 2 1 = + rightComponent C A S x y z w ii 2 1 2 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 2 1 (by decide)] + +lemma component_212022 : + leftComponent C A S x y z w ii 2 1 2 0 2 2 = + rightComponent C A S x y z w ii 2 1 2 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 0 2 2 (by decide)] + +lemma component_212100 : + leftComponent C A S x y z w ii 2 1 2 1 0 0 = + rightComponent C A S x y z w ii 2 1 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 0 0 (by decide)] + +lemma component_212101 : + leftComponent C A S x y z w ii 2 1 2 1 0 1 = + rightComponent C A S x y z w ii 2 1 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 0 1 (by decide)] + +lemma component_212102 : + leftComponent C A S x y z w ii 2 1 2 1 0 2 = + rightComponent C A S x y z w ii 2 1 2 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 0 2 (by decide)] + +lemma component_212110 : + leftComponent C A S x y z w ii 2 1 2 1 1 0 = + rightComponent C A S x y z w ii 2 1 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 1 0 (by decide)] + +lemma component_212111 : + leftComponent C A S x y z w ii 2 1 2 1 1 1 = + rightComponent C A S x y z w ii 2 1 2 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 1 1 (by decide)] + +lemma component_212112 : + leftComponent C A S x y z w ii 2 1 2 1 1 2 = + rightComponent C A S x y z w ii 2 1 2 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 1 2 (by decide)] + +lemma component_212120 : + leftComponent C A S x y z w ii 2 1 2 1 2 0 = + rightComponent C A S x y z w ii 2 1 2 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 2 0 (by decide)] + +lemma component_212121 : + leftComponent C A S x y z w ii 2 1 2 1 2 1 = + rightComponent C A S x y z w ii 2 1 2 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 1 2 1 (by decide)] + +lemma component_212122 : + leftComponent C A S x y z w ii 2 1 2 1 2 2 = + rightComponent C A S x y z w ii 2 1 2 1 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_212200 : + leftComponent C A S x y z w ii 2 1 2 2 0 0 = + rightComponent C A S x y z w ii 2 1 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 0 0 (by decide)] + +lemma component_212201 : + leftComponent C A S x y z w ii 2 1 2 2 0 1 = + rightComponent C A S x y z w ii 2 1 2 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 0 1 (by decide)] + +lemma component_212202 : + leftComponent C A S x y z w ii 2 1 2 2 0 2 = + rightComponent C A S x y z w ii 2 1 2 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 0 2 (by decide)] + +lemma component_212210 : + leftComponent C A S x y z w ii 2 1 2 2 1 0 = + rightComponent C A S x y z w ii 2 1 2 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 1 0 (by decide)] + +lemma component_212211 : + leftComponent C A S x y z w ii 2 1 2 2 1 1 = + rightComponent C A S x y z w ii 2 1 2 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 1 1 (by decide)] + +lemma component_212212 : + leftComponent C A S x y z w ii 2 1 2 2 1 2 = + rightComponent C A S x y z w ii 2 1 2 2 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_212220 : + leftComponent C A S x y z w ii 2 1 2 2 2 0 = + rightComponent C A S x y z w ii 2 1 2 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 2 0 (by decide)] + +lemma component_212222 : + leftComponent C A S x y z w ii 2 1 2 2 2 2 = + rightComponent C A S x y z w ii 2 1 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 1 2 2 2 2 (by decide)] + +lemma component_220000 : + leftComponent C A S x y z w ii 2 2 0 0 0 0 = + rightComponent C A S x y z w ii 2 2 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 0 0 (by decide)] + +lemma component_220001 : + leftComponent C A S x y z w ii 2 2 0 0 0 1 = + rightComponent C A S x y z w ii 2 2 0 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 0 1 (by decide)] + +lemma component_220002 : + leftComponent C A S x y z w ii 2 2 0 0 0 2 = + rightComponent C A S x y z w ii 2 2 0 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 0 2 (by decide)] + +lemma component_220010 : + leftComponent C A S x y z w ii 2 2 0 0 1 0 = + rightComponent C A S x y z w ii 2 2 0 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 1 0 (by decide)] + +lemma component_220011 : + leftComponent C A S x y z w ii 2 2 0 0 1 1 = + rightComponent C A S x y z w ii 2 2 0 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 1 1 (by decide)] + +lemma component_220012 : + leftComponent C A S x y z w ii 2 2 0 0 1 2 = + rightComponent C A S x y z w ii 2 2 0 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 1 2 (by decide)] + +lemma component_220020 : + leftComponent C A S x y z w ii 2 2 0 0 2 0 = + rightComponent C A S x y z w ii 2 2 0 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 2 0 (by decide)] + +lemma component_220021 : + leftComponent C A S x y z w ii 2 2 0 0 2 1 = + rightComponent C A S x y z w ii 2 2 0 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 0 2 1 (by decide)] + +lemma component_220100 : + leftComponent C A S x y z w ii 2 2 0 1 0 0 = + rightComponent C A S x y z w ii 2 2 0 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 0 0 (by decide)] + +lemma component_220101 : + leftComponent C A S x y z w ii 2 2 0 1 0 1 = + rightComponent C A S x y z w ii 2 2 0 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 0 1 (by decide)] + +lemma component_220102 : + leftComponent C A S x y z w ii 2 2 0 1 0 2 = + rightComponent C A S x y z w ii 2 2 0 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 0 2 (by decide)] + +lemma component_220110 : + leftComponent C A S x y z w ii 2 2 0 1 1 0 = + rightComponent C A S x y z w ii 2 2 0 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 1 0 (by decide)] + +lemma component_220111 : + leftComponent C A S x y z w ii 2 2 0 1 1 1 = + rightComponent C A S x y z w ii 2 2 0 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 1 1 (by decide)] + +lemma component_220120 : + leftComponent C A S x y z w ii 2 2 0 1 2 0 = + rightComponent C A S x y z w ii 2 2 0 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 2 0 (by decide)] + +lemma component_220122 : + leftComponent C A S x y z w ii 2 2 0 1 2 2 = + rightComponent C A S x y z w ii 2 2 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 1 2 2 (by decide)] + +lemma component_220200 : + leftComponent C A S x y z w ii 2 2 0 2 0 0 = + rightComponent C A S x y z w ii 2 2 0 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 0 0 (by decide)] + +lemma component_220201 : + leftComponent C A S x y z w ii 2 2 0 2 0 1 = + rightComponent C A S x y z w ii 2 2 0 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 0 1 (by decide)] + +lemma component_220210 : + leftComponent C A S x y z w ii 2 2 0 2 1 0 = + rightComponent C A S x y z w ii 2 2 0 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 1 0 (by decide)] + +lemma component_220212 : + leftComponent C A S x y z w ii 2 2 0 2 1 2 = + rightComponent C A S x y z w ii 2 2 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 1 2 (by decide)] + +lemma component_220220 : + leftComponent C A S x y z w ii 2 2 0 2 2 0 = + rightComponent C A S x y z w ii 2 2 0 2 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_220221 : + leftComponent C A S x y z w ii 2 2 0 2 2 1 = + rightComponent C A S x y z w ii 2 2 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 2 1 (by decide)] + +lemma component_220222 : + leftComponent C A S x y z w ii 2 2 0 2 2 2 = + rightComponent C A S x y z w ii 2 2 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 0 2 2 2 (by decide)] + +lemma component_221000 : + leftComponent C A S x y z w ii 2 2 1 0 0 0 = + rightComponent C A S x y z w ii 2 2 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 0 0 (by decide)] + +lemma component_221001 : + leftComponent C A S x y z w ii 2 2 1 0 0 1 = + rightComponent C A S x y z w ii 2 2 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 0 1 (by decide)] + +lemma component_221002 : + leftComponent C A S x y z w ii 2 2 1 0 0 2 = + rightComponent C A S x y z w ii 2 2 1 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 0 2 (by decide)] + +lemma component_221010 : + leftComponent C A S x y z w ii 2 2 1 0 1 0 = + rightComponent C A S x y z w ii 2 2 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 1 0 (by decide)] + +lemma component_221011 : + leftComponent C A S x y z w ii 2 2 1 0 1 1 = + rightComponent C A S x y z w ii 2 2 1 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 1 1 (by decide)] + +lemma component_221012 : + leftComponent C A S x y z w ii 2 2 1 0 1 2 = + rightComponent C A S x y z w ii 2 2 1 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 1 2 (by decide)] + +lemma component_221020 : + leftComponent C A S x y z w ii 2 2 1 0 2 0 = + rightComponent C A S x y z w ii 2 2 1 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 2 0 (by decide)] + +lemma component_221021 : + leftComponent C A S x y z w ii 2 2 1 0 2 1 = + rightComponent C A S x y z w ii 2 2 1 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 2 1 (by decide)] + +lemma component_221022 : + leftComponent C A S x y z w ii 2 2 1 0 2 2 = + rightComponent C A S x y z w ii 2 2 1 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 0 2 2 (by decide)] + +lemma component_221100 : + leftComponent C A S x y z w ii 2 2 1 1 0 0 = + rightComponent C A S x y z w ii 2 2 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 0 0 (by decide)] + +lemma component_221101 : + leftComponent C A S x y z w ii 2 2 1 1 0 1 = + rightComponent C A S x y z w ii 2 2 1 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 0 1 (by decide)] + +lemma component_221102 : + leftComponent C A S x y z w ii 2 2 1 1 0 2 = + rightComponent C A S x y z w ii 2 2 1 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 0 2 (by decide)] + +lemma component_221110 : + leftComponent C A S x y z w ii 2 2 1 1 1 0 = + rightComponent C A S x y z w ii 2 2 1 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 1 0 (by decide)] + +lemma component_221111 : + leftComponent C A S x y z w ii 2 2 1 1 1 1 = + rightComponent C A S x y z w ii 2 2 1 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 1 1 (by decide)] + +lemma component_221112 : + leftComponent C A S x y z w ii 2 2 1 1 1 2 = + rightComponent C A S x y z w ii 2 2 1 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 1 2 (by decide)] + +lemma component_221120 : + leftComponent C A S x y z w ii 2 2 1 1 2 0 = + rightComponent C A S x y z w ii 2 2 1 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 2 0 (by decide)] + +lemma component_221121 : + leftComponent C A S x y z w ii 2 2 1 1 2 1 = + rightComponent C A S x y z w ii 2 2 1 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 1 2 1 (by decide)] + +lemma component_221200 : + leftComponent C A S x y z w ii 2 2 1 2 0 0 = + rightComponent C A S x y z w ii 2 2 1 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 0 0 (by decide)] + +lemma component_221201 : + leftComponent C A S x y z w ii 2 2 1 2 0 1 = + rightComponent C A S x y z w ii 2 2 1 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 0 1 (by decide)] + +lemma component_221202 : + leftComponent C A S x y z w ii 2 2 1 2 0 2 = + rightComponent C A S x y z w ii 2 2 1 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 0 2 (by decide)] + +lemma component_221210 : + leftComponent C A S x y z w ii 2 2 1 2 1 0 = + rightComponent C A S x y z w ii 2 2 1 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 1 0 (by decide)] + +lemma component_221211 : + leftComponent C A S x y z w ii 2 2 1 2 1 1 = + rightComponent C A S x y z w ii 2 2 1 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 1 1 (by decide)] + +lemma component_221220 : + leftComponent C A S x y z w ii 2 2 1 2 2 0 = + rightComponent C A S x y z w ii 2 2 1 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 2 0 (by decide)] + +lemma component_221221 : + leftComponent C A S x y z w ii 2 2 1 2 2 1 = + rightComponent C A S x y z w ii 2 2 1 2 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_221222 : + leftComponent C A S x y z w ii 2 2 1 2 2 2 = + rightComponent C A S x y z w ii 2 2 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 1 2 2 2 (by decide)] + +lemma component_222000 : + leftComponent C A S x y z w ii 2 2 2 0 0 0 = + rightComponent C A S x y z w ii 2 2 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 0 0 (by decide)] + +lemma component_222001 : + leftComponent C A S x y z w ii 2 2 2 0 0 1 = + rightComponent C A S x y z w ii 2 2 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 0 1 (by decide)] + +lemma component_222002 : + leftComponent C A S x y z w ii 2 2 2 0 0 2 = + rightComponent C A S x y z w ii 2 2 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 0 2 (by decide)] + +lemma component_222010 : + leftComponent C A S x y z w ii 2 2 2 0 1 0 = + rightComponent C A S x y z w ii 2 2 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 1 0 (by decide)] + +lemma component_222011 : + leftComponent C A S x y z w ii 2 2 2 0 1 1 = + rightComponent C A S x y z w ii 2 2 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 1 1 (by decide)] + +lemma component_222012 : + leftComponent C A S x y z w ii 2 2 2 0 1 2 = + rightComponent C A S x y z w ii 2 2 2 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 1 2 (by decide)] + +lemma component_222020 : + leftComponent C A S x y z w ii 2 2 2 0 2 0 = + rightComponent C A S x y z w ii 2 2 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 2 0 (by decide)] + +lemma component_222021 : + leftComponent C A S x y z w ii 2 2 2 0 2 1 = + rightComponent C A S x y z w ii 2 2 2 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 2 1 (by decide)] + +lemma component_222022 : + leftComponent C A S x y z w ii 2 2 2 0 2 2 = + rightComponent C A S x y z w ii 2 2 2 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 0 2 2 (by decide)] + +lemma component_222100 : + leftComponent C A S x y z w ii 2 2 2 1 0 0 = + rightComponent C A S x y z w ii 2 2 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 0 0 (by decide)] + +lemma component_222101 : + leftComponent C A S x y z w ii 2 2 2 1 0 1 = + rightComponent C A S x y z w ii 2 2 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 0 1 (by decide)] + +lemma component_222102 : + leftComponent C A S x y z w ii 2 2 2 1 0 2 = + rightComponent C A S x y z w ii 2 2 2 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 0 2 (by decide)] + +lemma component_222110 : + leftComponent C A S x y z w ii 2 2 2 1 1 0 = + rightComponent C A S x y z w ii 2 2 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 1 0 (by decide)] + +lemma component_222111 : + leftComponent C A S x y z w ii 2 2 2 1 1 1 = + rightComponent C A S x y z w ii 2 2 2 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 1 1 (by decide)] + +lemma component_222112 : + leftComponent C A S x y z w ii 2 2 2 1 1 2 = + rightComponent C A S x y z w ii 2 2 2 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 1 2 (by decide)] + +lemma component_222120 : + leftComponent C A S x y z w ii 2 2 2 1 2 0 = + rightComponent C A S x y z w ii 2 2 2 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 2 0 (by decide)] + +lemma component_222121 : + leftComponent C A S x y z w ii 2 2 2 1 2 1 = + rightComponent C A S x y z w ii 2 2 2 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 2 1 (by decide)] + +lemma component_222122 : + leftComponent C A S x y z w ii 2 2 2 1 2 2 = + rightComponent C A S x y z w ii 2 2 2 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 1 2 2 (by decide)] + +lemma component_222200 : + leftComponent C A S x y z w ii 2 2 2 2 0 0 = + rightComponent C A S x y z w ii 2 2 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 0 0 (by decide)] + +lemma component_222201 : + leftComponent C A S x y z w ii 2 2 2 2 0 1 = + rightComponent C A S x y z w ii 2 2 2 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 0 1 (by decide)] + +lemma component_222202 : + leftComponent C A S x y z w ii 2 2 2 2 0 2 = + rightComponent C A S x y z w ii 2 2 2 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 0 2 (by decide)] + +lemma component_222210 : + leftComponent C A S x y z w ii 2 2 2 2 1 0 = + rightComponent C A S x y z w ii 2 2 2 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 1 0 (by decide)] + +lemma component_222211 : + leftComponent C A S x y z w ii 2 2 2 2 1 1 = + rightComponent C A S x y z w ii 2 2 2 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 1 1 (by decide)] + +lemma component_222212 : + leftComponent C A S x y z w ii 2 2 2 2 1 2 = + rightComponent C A S x y z w ii 2 2 2 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 1 2 (by decide)] + +lemma component_222220 : + leftComponent C A S x y z w ii 2 2 2 2 2 0 = + rightComponent C A S x y z w ii 2 2 2 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 2 0 (by decide)] + +lemma component_222221 : + leftComponent C A S x y z w ii 2 2 2 2 2 1 = + rightComponent C A S x y z w ii 2 2 2 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 2 2 2 2 2 1 (by decide)] + +lemma component_222222 : + leftComponent C A S x y z w ii 2 2 2 2 2 2 = + rightComponent C A S x y z w ii 2 2 2 2 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +include hC hA hS hy hw hi in +lemma block_200 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 0 0 d e f = + rightComponent C A S x y z w ii 2 0 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_200000 C A S x y z w ii + · exact component_200001 C A S x y z w ii + · exact component_200002 C A S x y z w ii hC hA hS hy hw hi + · exact component_200010 C A S x y z w ii + · exact component_200011 C A S x y z w ii hC hA hS hy hw hi + · exact component_200012 C A S x y z w ii + · exact component_200020 C A S x y z w ii hC hA hS hy hw hi + · exact component_200021 C A S x y z w ii + · exact component_200022 C A S x y z w ii + · exact component_200100 C A S x y z w ii + · exact component_200101 C A S x y z w ii hC hA hS hy hw + · exact component_200102 C A S x y z w ii + · exact component_200110 C A S x y z w ii hC hA hS hy hw + · exact component_200111 C A S x y z w ii + · exact component_200112 C A S x y z w ii + · exact component_200120 C A S x y z w ii + · exact component_200121 C A S x y z w ii + · exact component_200122 C A S x y z w ii + · exact component_200200 C A S x y z w ii + · exact component_200201 C A S x y z w ii + · exact component_200202 C A S x y z w ii + · exact component_200210 C A S x y z w ii + · exact component_200211 C A S x y z w ii + · exact component_200212 C A S x y z w ii + · exact component_200220 C A S x y z w ii + · exact component_200221 C A S x y z w ii + · exact component_200222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_201 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 0 1 d e f = + rightComponent C A S x y z w ii 2 0 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_201000 C A S x y z w ii + · exact component_201001 C A S x y z w ii + · exact component_201002 C A S x y z w ii + · exact component_201010 C A S x y z w ii + · exact component_201011 C A S x y z w ii + · exact component_201012 C A S x y z w ii hC hA hS hy hw hi + · exact component_201020 C A S x y z w ii + · exact component_201021 C A S x y z w ii + · exact component_201022 C A S x y z w ii + · exact component_201100 C A S x y z w ii + · exact component_201101 C A S x y z w ii + · exact component_201102 C A S x y z w ii hC hA hS hy hw hi + · exact component_201110 C A S x y z w ii + · exact component_201111 C A S x y z w ii hC hA hS hy hw hi + · exact component_201112 C A S x y z w ii + · exact component_201120 C A S x y z w ii hC hA hS hy hw hi + · exact component_201121 C A S x y z w ii + · exact component_201122 C A S x y z w ii + · exact component_201200 C A S x y z w ii + · exact component_201201 C A S x y z w ii + · exact component_201202 C A S x y z w ii + · exact component_201210 C A S x y z w ii hC hA hS hy hw hi + · exact component_201211 C A S x y z w ii + · exact component_201212 C A S x y z w ii + · exact component_201220 C A S x y z w ii + · exact component_201221 C A S x y z w ii + · exact component_201222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_202 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 0 2 d e f = + rightComponent C A S x y z w ii 2 0 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_202000 C A S x y z w ii + · exact component_202001 C A S x y z w ii + · exact component_202002 C A S x y z w ii + · exact component_202010 C A S x y z w ii + · exact component_202011 C A S x y z w ii + · exact component_202012 C A S x y z w ii + · exact component_202020 C A S x y z w ii + · exact component_202021 C A S x y z w ii + · exact component_202022 C A S x y z w ii hC hA hS hy hw hi + · exact component_202100 C A S x y z w ii + · exact component_202101 C A S x y z w ii + · exact component_202102 C A S x y z w ii + · exact component_202110 C A S x y z w ii + · exact component_202111 C A S x y z w ii + · exact component_202112 C A S x y z w ii hC hA hS hy hw hi + · exact component_202120 C A S x y z w ii + · exact component_202121 C A S x y z w ii hC hA hS hy hw hi + · exact component_202122 C A S x y z w ii + · exact component_202200 C A S x y z w ii + · exact component_202201 C A S x y z w ii + · exact component_202202 C A S x y z w ii hC hA hS hy hw hi + · exact component_202210 C A S x y z w ii + · exact component_202211 C A S x y z w ii hC hA hS hy hw hi + · exact component_202212 C A S x y z w ii + · exact component_202220 C A S x y z w ii hC hA hS hy hw hi + · exact component_202221 C A S x y z w ii + · exact component_202222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_210 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 1 0 d e f = + rightComponent C A S x y z w ii 2 1 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_210000 C A S x y z w ii + · exact component_210001 C A S x y z w ii + · exact component_210002 C A S x y z w ii + · exact component_210010 C A S x y z w ii + · exact component_210011 C A S x y z w ii + · exact component_210012 C A S x y z w ii + · exact component_210020 C A S x y z w ii + · exact component_210021 C A S x y z w ii hC hA hS hy hw hi + · exact component_210022 C A S x y z w ii + · exact component_210100 C A S x y z w ii + · exact component_210101 C A S x y z w ii + · exact component_210102 C A S x y z w ii hC hA hS hy hw hi + · exact component_210110 C A S x y z w ii + · exact component_210111 C A S x y z w ii hC hA hS hy hw + · exact component_210112 C A S x y z w ii + · exact component_210120 C A S x y z w ii hC hA hS hy hw hi + · exact component_210121 C A S x y z w ii + · exact component_210122 C A S x y z w ii + · exact component_210200 C A S x y z w ii + · exact component_210201 C A S x y z w ii hC hA hS hy hw hi + · exact component_210202 C A S x y z w ii + · exact component_210210 C A S x y z w ii + · exact component_210211 C A S x y z w ii + · exact component_210212 C A S x y z w ii + · exact component_210220 C A S x y z w ii + · exact component_210221 C A S x y z w ii + · exact component_210222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_211 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 1 1 d e f = + rightComponent C A S x y z w ii 2 1 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_211000 C A S x y z w ii + · exact component_211001 C A S x y z w ii + · exact component_211002 C A S x y z w ii + · exact component_211010 C A S x y z w ii + · exact component_211011 C A S x y z w ii + · exact component_211012 C A S x y z w ii + · exact component_211020 C A S x y z w ii + · exact component_211021 C A S x y z w ii + · exact component_211022 C A S x y z w ii hC hA hS hy hw hi + · exact component_211100 C A S x y z w ii + · exact component_211101 C A S x y z w ii + · exact component_211102 C A S x y z w ii + · exact component_211110 C A S x y z w ii + · exact component_211111 C A S x y z w ii + · exact component_211112 C A S x y z w ii hC hA hS hy hw hi + · exact component_211120 C A S x y z w ii + · exact component_211121 C A S x y z w ii hC hA hS hy hw hi + · exact component_211122 C A S x y z w ii + · exact component_211200 C A S x y z w ii + · exact component_211201 C A S x y z w ii + · exact component_211202 C A S x y z w ii hC hA hS hy hw hi + · exact component_211210 C A S x y z w ii + · exact component_211211 C A S x y z w ii + · exact component_211212 C A S x y z w ii + · exact component_211220 C A S x y z w ii hC hA hS hy hw + · exact component_211221 C A S x y z w ii + · exact component_211222 C A S x y z w ii + +include hy in +lemma block_212 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 1 2 d e f = + rightComponent C A S x y z w ii 2 1 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_212000 C A S x y z w ii + · exact component_212001 C A S x y z w ii + · exact component_212002 C A S x y z w ii + · exact component_212010 C A S x y z w ii + · exact component_212011 C A S x y z w ii + · exact component_212012 C A S x y z w ii + · exact component_212020 C A S x y z w ii + · exact component_212021 C A S x y z w ii + · exact component_212022 C A S x y z w ii + · exact component_212100 C A S x y z w ii + · exact component_212101 C A S x y z w ii + · exact component_212102 C A S x y z w ii + · exact component_212110 C A S x y z w ii + · exact component_212111 C A S x y z w ii + · exact component_212112 C A S x y z w ii + · exact component_212120 C A S x y z w ii + · exact component_212121 C A S x y z w ii + · exact component_212122 C A S x y z w ii + · exact component_212200 C A S x y z w ii + · exact component_212201 C A S x y z w ii + · exact component_212202 C A S x y z w ii + · exact component_212210 C A S x y z w ii + · exact component_212211 C A S x y z w ii + · exact component_212212 C A S x y z w ii + · exact component_212220 C A S x y z w ii + · exact component_212221 C A S x y z w ii hy + · exact component_212222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_220 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 2 0 d e f = + rightComponent C A S x y z w ii 2 2 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_220000 C A S x y z w ii + · exact component_220001 C A S x y z w ii + · exact component_220002 C A S x y z w ii + · exact component_220010 C A S x y z w ii + · exact component_220011 C A S x y z w ii + · exact component_220012 C A S x y z w ii + · exact component_220020 C A S x y z w ii + · exact component_220021 C A S x y z w ii + · exact component_220022 C A S x y z w ii hC hA hS hy hw hi + · exact component_220100 C A S x y z w ii + · exact component_220101 C A S x y z w ii + · exact component_220102 C A S x y z w ii + · exact component_220110 C A S x y z w ii + · exact component_220111 C A S x y z w ii + · exact component_220112 C A S x y z w ii hC hA hS hy hw hi + · exact component_220120 C A S x y z w ii + · exact component_220121 C A S x y z w ii hC hA hS hy hw + · exact component_220122 C A S x y z w ii + · exact component_220200 C A S x y z w ii + · exact component_220201 C A S x y z w ii + · exact component_220202 C A S x y z w ii hC hA hS hy hw hi + · exact component_220210 C A S x y z w ii + · exact component_220211 C A S x y z w ii hC hA hS hy hw + · exact component_220212 C A S x y z w ii + · exact component_220220 C A S x y z w ii + · exact component_220221 C A S x y z w ii + · exact component_220222 C A S x y z w ii + +include hC hA hS hy hw in +lemma block_221 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 2 1 d e f = + rightComponent C A S x y z w ii 2 2 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_221000 C A S x y z w ii + · exact component_221001 C A S x y z w ii + · exact component_221002 C A S x y z w ii + · exact component_221010 C A S x y z w ii + · exact component_221011 C A S x y z w ii + · exact component_221012 C A S x y z w ii + · exact component_221020 C A S x y z w ii + · exact component_221021 C A S x y z w ii + · exact component_221022 C A S x y z w ii + · exact component_221100 C A S x y z w ii + · exact component_221101 C A S x y z w ii + · exact component_221102 C A S x y z w ii + · exact component_221110 C A S x y z w ii + · exact component_221111 C A S x y z w ii + · exact component_221112 C A S x y z w ii + · exact component_221120 C A S x y z w ii + · exact component_221121 C A S x y z w ii + · exact component_221122 C A S x y z w ii hC hA hS hy hw + · exact component_221200 C A S x y z w ii + · exact component_221201 C A S x y z w ii + · exact component_221202 C A S x y z w ii + · exact component_221210 C A S x y z w ii + · exact component_221211 C A S x y z w ii + · exact component_221212 C A S x y z w ii hy + · exact component_221220 C A S x y z w ii + · exact component_221221 C A S x y z w ii + · exact component_221222 C A S x y z w ii + +lemma block_222 (d e f : Fin 3) : + leftComponent C A S x y z w ii 2 2 2 d e f = + rightComponent C A S x y z w ii 2 2 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_222000 C A S x y z w ii + · exact component_222001 C A S x y z w ii + · exact component_222002 C A S x y z w ii + · exact component_222010 C A S x y z w ii + · exact component_222011 C A S x y z w ii + · exact component_222012 C A S x y z w ii + · exact component_222020 C A S x y z w ii + · exact component_222021 C A S x y z w ii + · exact component_222022 C A S x y z w ii + · exact component_222100 C A S x y z w ii + · exact component_222101 C A S x y z w ii + · exact component_222102 C A S x y z w ii + · exact component_222110 C A S x y z w ii + · exact component_222111 C A S x y z w ii + · exact component_222112 C A S x y z w ii + · exact component_222120 C A S x y z w ii + · exact component_222121 C A S x y z w ii + · exact component_222122 C A S x y z w ii + · exact component_222200 C A S x y z w ii + · exact component_222201 C A S x y z w ii + · exact component_222202 C A S x y z w ii + · exact component_222210 C A S x y z w ii + · exact component_222211 C A S x y z w ii + · exact component_222212 C A S x y z w ii + · exact component_222220 C A S x y z w ii + · exact component_222221 C A S x y z w ii + · exact component_222222 C A S x y z w ii + +end Algebra +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsNegative.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsNegative.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd562eda00425f6fadd09a6fc1b9c22a369c6b7c --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsNegative.lean @@ -0,0 +1,304 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterDefinitions +import Mathlib.Tactic.LinearCombination + +namespace OAI + +/-! Yang–Baxter polynomial reductions with first spin negative. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +section Algebra +variable (C A S x y z w ii : ℂ) +variable (hC : C = (2*S+1)*A) (hA : A^2 = (1-S)/2) + (hS : S^2 = 1/2) (hy : y^2+x^2=1) (hw : w^2+z^2=1) (hi : ii^2+1=0) + +noncomputable def poly_200002_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 4)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 4)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 4)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexPow y 4) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow y 4) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul (complexMul (complexPow y 3) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((5:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-6:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow y 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((7:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))))) + +noncomputable def poly_200002_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexPow w 3) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((7:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2)))))))))) + +noncomputable def poly_200002_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (complexPow y 2) (complexPow C 3)) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((7:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))))))) + +include hy in +lemma reduce_200002_3 : + poly_200002_0 C A S x y z w ii = + poly_200002_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200002_2 C A S x y z w ii) * t) hy + dsimp only [poly_200002_0, poly_200002_1, poly_200002_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200002_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-14:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))))))) + +noncomputable def poly_200002_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +include hw in +lemma reduce_200002_4 : + poly_200002_1 C A S x y z w ii = + poly_200002_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200002_4 C A S x y z w ii) * t) hw + dsimp only [poly_200002_1, poly_200002_3, poly_200002_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200002_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-14:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_200002_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))))) + +include hi in +lemma reduce_200002_5 : + poly_200002_3 C A S x y z w ii = + poly_200002_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200002_6 C A S x y z w ii) * t) hi + dsimp only [poly_200002_3, poly_200002_5, poly_200002_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200002_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (S) (complexPow z 2)))))))))) + +noncomputable def poly_200002_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-10:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexPow z 2))))))))) + +include hC in +lemma reduce_200002_0 : + poly_200002_5 C A S x y z w ii = + poly_200002_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200002_8 C A S x y z w ii) * t) hC + dsimp only [poly_200002_5, poly_200002_7, poly_200002_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200002_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((5:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_200002_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +include hA in +lemma reduce_200002_1 : + poly_200002_7 C A S x y z w ii = + poly_200002_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200002_10 C A S x y z w ii) * t) hA + dsimp only [poly_200002_7, poly_200002_9, poly_200002_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200002_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +include hS in +lemma reduce_200002_2 : + poly_200002_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_200002_11 C A S x y z w ii) * t) hS + dsimp only [poly_200002_9, poly_200002_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_200002 : poly_200002_0 C A S x y z w ii = 0 := by + calc + poly_200002_0 C A S x y z w ii = poly_200002_1 C A S x y z w ii := reduce_200002_3 C A S x y z w ii hy + _ = poly_200002_3 C A S x y z w ii := reduce_200002_4 C A S x y z w ii hw + _ = poly_200002_5 C A S x y z w ii := reduce_200002_5 C A S x y z w ii hi + _ = poly_200002_7 C A S x y z w ii := reduce_200002_0 C A S x y z w ii hC + _ = poly_200002_9 C A S x y z w ii := reduce_200002_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_200002_2 C A S x y z w ii hS + +noncomputable def poly_200011_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))))) + +noncomputable def poly_200011_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_200011_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +include hy in +lemma reduce_200011_3 : + poly_200011_0 C A S x y z w ii = + poly_200011_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200011_2 C A S x y z w ii) * t) hy + dsimp only [poly_200011_0, poly_200011_1, poly_200011_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200011_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))))))) + +noncomputable def poly_200011_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) + +include hw in +lemma reduce_200011_4 : + poly_200011_1 C A S x y z w ii = + poly_200011_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200011_4 C A S x y z w ii) * t) hw + dsimp only [poly_200011_1, poly_200011_3, poly_200011_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200011_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_200011_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z)))))))) + +include hi in +lemma reduce_200011_5 : + poly_200011_3 C A S x y z w ii = + poly_200011_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200011_6 C A S x y z w ii) * t) hi + dsimp only [poly_200011_3, poly_200011_5, poly_200011_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200011_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_200011_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (C) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +include hC in +lemma reduce_200011_0 : + poly_200011_5 C A S x y z w ii = + poly_200011_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200011_8 C A S x y z w ii) * t) hC + dsimp only [poly_200011_5, poly_200011_7, poly_200011_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200011_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (y) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((5:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((3:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_200011_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_200011_1 : + poly_200011_7 C A S x y z w ii = + poly_200011_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_200011_10 C A S x y z w ii) * t) hA + dsimp only [poly_200011_7, poly_200011_9, poly_200011_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_200011_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (y) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hS in +lemma reduce_200011_2 : + poly_200011_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_200011_11 C A S x y z w ii) * t) hS + dsimp only [poly_200011_9, poly_200011_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_200011 : poly_200011_0 C A S x y z w ii = 0 := by + calc + poly_200011_0 C A S x y z w ii = poly_200011_1 C A S x y z w ii := reduce_200011_3 C A S x y z w ii hy + _ = poly_200011_3 C A S x y z w ii := reduce_200011_4 C A S x y z w ii hw + _ = poly_200011_5 C A S x y z w ii := reduce_200011_5 C A S x y z w ii hi + _ = poly_200011_7 C A S x y z w ii := reduce_200011_0 C A S x y z w ii hC + _ = poly_200011_9 C A S x y z w ii := reduce_200011_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_200011_2 C A S x y z w ii hS + +noncomputable def poly_201012_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 4) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_201012_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) + +noncomputable def poly_201012_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) + +include hy in +lemma reduce_201012_3 : + poly_201012_0 C A S x y z w ii = + poly_201012_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_201012_2 C A S x y z w ii) * t) hy + dsimp only [poly_201012_0, poly_201012_1, poly_201012_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_201012_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_201012_4 (C A S x _y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))) + +include hw in +lemma reduce_201012_4 : + poly_201012_1 C A S x y z w ii = + poly_201012_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_201012_4 C A S x y z w ii) * t) hw + dsimp only [poly_201012_1, poly_201012_3, poly_201012_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_201012_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_201012_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))) + +include hi in +lemma reduce_201012_5 : + poly_201012_3 C A S x y z w ii = + poly_201012_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_201012_6 C A S x y z w ii) * t) hi + dsimp only [poly_201012_3, poly_201012_5, poly_201012_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_201012_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))))))) + +noncomputable def poly_201012_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))))))) + +include hC in +lemma reduce_201012_0 : + poly_201012_5 C A S x y z w ii = + poly_201012_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_201012_8 C A S x y z w ii) * t) hC + dsimp only [poly_201012_5, poly_201012_7, poly_201012_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_201012_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))))))) + +noncomputable def poly_201012_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) + +include hA in +lemma reduce_201012_1 : + poly_201012_7 C A S x y z w ii = + poly_201012_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_201012_10 C A S x y z w ii) * t) hA + dsimp only [poly_201012_7, poly_201012_9, poly_201012_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_201012_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z))))))) + +include hS in +lemma reduce_201012_2 : + poly_201012_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_201012_11 C A S x y z w ii) * t) hS + dsimp only [poly_201012_9, poly_201012_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_201012 : poly_201012_0 C A S x y z w ii = 0 := by + calc + poly_201012_0 C A S x y z w ii = poly_201012_1 C A S x y z w ii := reduce_201012_3 C A S x y z w ii hy + _ = poly_201012_3 C A S x y z w ii := reduce_201012_4 C A S x y z w ii hw + _ = poly_201012_5 C A S x y z w ii := reduce_201012_5 C A S x y z w ii hi + _ = poly_201012_7 C A S x y z w ii := reduce_201012_0 C A S x y z w ii hC + _ = poly_201012_9 C A S x y z w ii := reduce_201012_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_201012_2 C A S x y z w ii hS + +end Algebra +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsPositive.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsPositive.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee9a735c529bd526f0cddaa9b55a0fcebe1da76d --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsPositive.lean @@ -0,0 +1,2286 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterDefinitions +import Mathlib.Tactic.LinearCombination + +namespace OAI + +/-! Yang–Baxter polynomial reductions with first spin positive. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +section Algebra +variable (C A S x y z w ii : ℂ) +variable (hC : C = (2*S+1)*A) (hA : A^2 = (1-S)/2) + (hS : S^2 = 1/2) (hy : y^2+x^2=1) (hw : w^2+z^2=1) (hi : ii^2+1=0) + +noncomputable def poly_001010_0 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 4) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) + +noncomputable def poly_001010_1 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) + +include hy in +lemma reduce_001010_3 : + poly_001010_0 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_001010_1 C A S x y z w ii) * t) hy + dsimp only [poly_001010_0, poly_001010_1, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hy in +lemma polynomial_001010 : poly_001010_0 C A S x y z w ii = 0 := by + calc + poly_001010_0 C A S x y z w ii = (0:ℂ) := reduce_001010_3 C A S x y z w ii hy + +noncomputable def poly_001100_0 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 4))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (x)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (x))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow y 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_001100_1 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow w 4) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3)))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((5:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4))))))))) + +noncomputable def poly_001100_2 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))))))) + +include hy in +lemma reduce_001100_3 : + poly_001100_0 C A S x y z w ii = + poly_001100_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_001100_2 C A S x y z w ii) * t) hy + dsimp only [poly_001100_0, poly_001100_1, poly_001100_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_001100_3 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))))))) + +noncomputable def poly_001100_4 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-5:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +include hw in +lemma reduce_001100_4 : + poly_001100_1 C A S x y z w ii = + poly_001100_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_001100_4 C A S x y z w ii) * t) hw + dsimp only [poly_001100_1, poly_001100_3, poly_001100_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_001100_5 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-20:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (z)))) (complexMul (complexMul ((48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +noncomputable def poly_001100_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hC in +lemma reduce_001100_0 : + poly_001100_3 C A S x y z w ii = + poly_001100_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_001100_6 C A S x y z w ii) * t) hC + dsimp only [poly_001100_3, poly_001100_5, poly_001100_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_001100_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((20:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((14:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-7:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((7:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-14:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((10:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +noncomputable def poly_001100_8 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-20:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z)))) (complexMul (complexMul ((48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hA in +lemma reduce_001100_1 : + poly_001100_5 C A S x y z w ii = + poly_001100_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_001100_8 C A S x y z w ii) * t) hA + dsimp only [poly_001100_5, poly_001100_7, poly_001100_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_001100_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((5:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +include hS in +lemma reduce_001100_2 : + poly_001100_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_001100_9 C A S x y z w ii) * t) hS + dsimp only [poly_001100_7, poly_001100_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_001100 : poly_001100_0 C A S x y z w ii = 0 := by + calc + poly_001100_0 C A S x y z w ii = poly_001100_1 C A S x y z w ii := reduce_001100_3 C A S x y z w ii hy + _ = poly_001100_3 C A S x y z w ii := reduce_001100_4 C A S x y z w ii hw + _ = poly_001100_5 C A S x y z w ii := reduce_001100_0 C A S x y z w ii hC + _ = poly_001100_7 C A S x y z w ii := reduce_001100_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_001100_2 C A S x y z w ii hS + +noncomputable def poly_002011_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_002011_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_002011_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))) + +include hy in +lemma reduce_002011_3 : + poly_002011_0 C A S x y z w ii = + poly_002011_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002011_2 C A S x y z w ii) * t) hy + dsimp only [poly_002011_0, poly_002011_1, poly_002011_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002011_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_002011_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))))))) + +include hw in +lemma reduce_002011_4 : + poly_002011_1 C A S x y z w ii = + poly_002011_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002011_4 C A S x y z w ii) * t) hw + dsimp only [poly_002011_1, poly_002011_3, poly_002011_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002011_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_002011_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 4) (z))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))))) + +include hC in +lemma reduce_002011_0 : + poly_002011_3 C A S x y z w ii = + poly_002011_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002011_6 C A S x y z w ii) * t) hC + dsimp only [poly_002011_3, poly_002011_5, poly_002011_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002011_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 4)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (w) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_002011_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (y) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (S) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_002011_1 : + poly_002011_5 C A S x y z w ii = + poly_002011_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002011_8 C A S x y z w ii) * t) hA + dsimp only [poly_002011_5, poly_002011_7, poly_002011_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002011_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z)))))))) + +include hS in +lemma reduce_002011_2 : + poly_002011_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_002011_9 C A S x y z w ii) * t) hS + dsimp only [poly_002011_7, poly_002011_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_002011 : poly_002011_0 C A S x y z w ii = 0 := by + calc + poly_002011_0 C A S x y z w ii = poly_002011_1 C A S x y z w ii := reduce_002011_3 C A S x y z w ii hy + _ = poly_002011_3 C A S x y z w ii := reduce_002011_4 C A S x y z w ii hw + _ = poly_002011_5 C A S x y z w ii := reduce_002011_0 C A S x y z w ii hC + _ = poly_002011_7 C A S x y z w ii := reduce_002011_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_002011_2 C A S x y z w ii hS + +noncomputable def poly_002020_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 3) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (complexPow y 3)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-7:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))))) + +noncomputable def poly_002020_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow ii 2)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((5:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-7:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))))))) + +noncomputable def poly_002020_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((5:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-7:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2)))))))) + +include hy in +lemma reduce_002020_3 : + poly_002020_0 C A S x y z w ii = + poly_002020_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002020_2 C A S x y z w ii) * t) hy + dsimp only [poly_002020_0, poly_002020_1, poly_002020_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002020_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-12:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow ii 2)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2))) (complexMul (complexMul ((-12:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((14:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_002020_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow ii 2)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((10:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((5:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))))) + +include hw in +lemma reduce_002020_4 : + poly_002020_1 C A S x y z w ii = + poly_002020_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002020_4 C A S x y z w ii) * t) hw + dsimp only [poly_002020_1, poly_002020_3, poly_002020_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002020_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-12:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (A) (complexMul (complexPow x 4) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-12:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((14:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_002020_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 4))) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))))) + +include hi in +lemma reduce_002020_5 : + poly_002020_3 C A S x y z w ii = + poly_002020_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002020_6 C A S x y z w ii) * t) hi + dsimp only [poly_002020_3, poly_002020_5, poly_002020_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002020_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexPow z 4))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexPow z 4))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((24:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexPow z 4))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexPow z 2))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow x 4) (complexPow z 4))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexPow z 2))))))))) + +noncomputable def poly_002020_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-12:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (C)) (complexMul (A) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (C)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (C)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexPow z 2))) (complexMul (complexMul ((-24:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((12:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((10:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 4))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (S) (complexPow z 2))))))))) + +include hC in +lemma reduce_002020_0 : + poly_002020_5 C A S x y z w ii = + poly_002020_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002020_8 C A S x y z w ii) * t) hC + dsimp only [poly_002020_5, poly_002020_7, poly_002020_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002020_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (z)))) (complexMul (complexMul ((24:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (y) (A)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 6) (complexPow z 4))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 6) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-20:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 5) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-5:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 3) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexPow z 4))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))))) + +noncomputable def poly_002020_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 5) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 5) (complexPow z 2))) (complexMul (complexMul ((-48:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexPow z 4))) (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexPow z 4))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 2))))))))) + +include hA in +lemma reduce_002020_1 : + poly_002020_7 C A S x y z w ii = + poly_002020_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002020_10 C A S x y z w ii) * t) hA + dsimp only [poly_002020_7, poly_002020_9, poly_002020_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002020_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((24:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-20:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexPow z 4))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexPow z 4))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 2))))))))) + +include hS in +lemma reduce_002020_2 : + poly_002020_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_002020_11 C A S x y z w ii) * t) hS + dsimp only [poly_002020_9, poly_002020_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_002020 : poly_002020_0 C A S x y z w ii = 0 := by + calc + poly_002020_0 C A S x y z w ii = poly_002020_1 C A S x y z w ii := reduce_002020_3 C A S x y z w ii hy + _ = poly_002020_3 C A S x y z w ii := reduce_002020_4 C A S x y z w ii hw + _ = poly_002020_5 C A S x y z w ii := reduce_002020_5 C A S x y z w ii hi + _ = poly_002020_7 C A S x y z w ii := reduce_002020_0 C A S x y z w ii hC + _ = poly_002020_9 C A S x y z w ii := reduce_002020_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_002020_2 C A S x y z w ii hS + +noncomputable def poly_002101_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_002101_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_002101_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) + +include hy in +lemma reduce_002101_3 : + poly_002101_0 C A S x y z w ii = + poly_002101_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002101_2 C A S x y z w ii) * t) hy + dsimp only [poly_002101_0, poly_002101_1, poly_002101_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002101_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_002101_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +include hw in +lemma reduce_002101_4 : + poly_002101_1 C A S x y z w ii = + poly_002101_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002101_4 C A S x y z w ii) * t) hw + dsimp only [poly_002101_1, poly_002101_3, poly_002101_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002101_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_002101_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow x 2) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (A) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +include hC in +lemma reduce_002101_0 : + poly_002101_3 C A S x y z w ii = + poly_002101_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002101_6 C A S x y z w ii) * t) hC + dsimp only [poly_002101_3, poly_002101_5, poly_002101_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002101_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 2))) (complexMul ((-1:ℂ)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 4))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_002101_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 2))) (complexMul ((-2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (x) (complexPow z 4)) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +include hA in +lemma reduce_002101_1 : + poly_002101_5 C A S x y z w ii = + poly_002101_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002101_8 C A S x y z w ii) * t) hA + dsimp only [poly_002101_5, poly_002101_7, poly_002101_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002101_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (ii) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul ((2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul ((-1:ℂ)) (complexMul (x) (complexPow z 4))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2)))))))) + +include hS in +lemma reduce_002101_2 : + poly_002101_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_002101_9 C A S x y z w ii) * t) hS + dsimp only [poly_002101_7, poly_002101_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_002101 : poly_002101_0 C A S x y z w ii = 0 := by + calc + poly_002101_0 C A S x y z w ii = poly_002101_1 C A S x y z w ii := reduce_002101_3 C A S x y z w ii hy + _ = poly_002101_3 C A S x y z w ii := reduce_002101_4 C A S x y z w ii hw + _ = poly_002101_5 C A S x y z w ii := reduce_002101_0 C A S x y z w ii hC + _ = poly_002101_7 C A S x y z w ii := reduce_002101_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_002101_2 C A S x y z w ii hS + +noncomputable def poly_002110_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_002110_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_002110_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hy in +lemma reduce_002110_3 : + poly_002110_0 C A S x y z w ii = + poly_002110_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002110_2 C A S x y z w ii) * t) hy + dsimp only [poly_002110_0, poly_002110_1, poly_002110_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002110_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))))) + +noncomputable def poly_002110_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) + +include hw in +lemma reduce_002110_4 : + poly_002110_1 C A S x y z w ii = + poly_002110_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002110_4 C A S x y z w ii) * t) hw + dsimp only [poly_002110_1, poly_002110_3, poly_002110_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002110_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_002110_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) + +include hi in +lemma reduce_002110_5 : + poly_002110_3 C A S x y z w ii = + poly_002110_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002110_6 C A S x y z w ii) * t) hi + dsimp only [poly_002110_3, poly_002110_5, poly_002110_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002110_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_002110_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_002110_0 : + poly_002110_5 C A S x y z w ii = + poly_002110_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002110_8 C A S x y z w ii) * t) hC + dsimp only [poly_002110_5, poly_002110_7, poly_002110_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002110_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 5)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_002110_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (y) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_002110_1 : + poly_002110_7 C A S x y z w ii = + poly_002110_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002110_10 C A S x y z w ii) * t) hA + dsimp only [poly_002110_7, poly_002110_9, poly_002110_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002110_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (w) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_002110_2 : + poly_002110_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_002110_11 C A S x y z w ii) * t) hS + dsimp only [poly_002110_9, poly_002110_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_002110 : poly_002110_0 C A S x y z w ii = 0 := by + calc + poly_002110_0 C A S x y z w ii = poly_002110_1 C A S x y z w ii := reduce_002110_3 C A S x y z w ii hy + _ = poly_002110_3 C A S x y z w ii := reduce_002110_4 C A S x y z w ii hw + _ = poly_002110_5 C A S x y z w ii := reduce_002110_5 C A S x y z w ii hi + _ = poly_002110_7 C A S x y z w ii := reduce_002110_0 C A S x y z w ii hC + _ = poly_002110_9 C A S x y z w ii := reduce_002110_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_002110_2 C A S x y z w ii hS + +noncomputable def poly_002200_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 4) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 4)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 4)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 4) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 4) (complexPow ii 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow y 4)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((5:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 3) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-6:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow y 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow y 3) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((7:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))))) + +noncomputable def poly_002200_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexPow w 3) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((7:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2)))))))))) + +noncomputable def poly_002200_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((7:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))))))) + +include hy in +lemma reduce_002200_3 : + poly_002200_0 C A S x y z w ii = + poly_002200_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002200_2 C A S x y z w ii) * t) hy + dsimp only [poly_002200_0, poly_002200_1, poly_002200_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002200_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexPow ii 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-14:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_002200_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow ii 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow ii 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) + +include hw in +lemma reduce_002200_4 : + poly_002200_1 C A S x y z w ii = + poly_002200_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002200_4 C A S x y z w ii) * t) hw + dsimp only [poly_002200_1, poly_002200_3, poly_002200_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002200_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((12:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-14:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_002200_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul ((3:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) + +include hi in +lemma reduce_002200_5 : + poly_002200_3 C A S x y z w ii = + poly_002200_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002200_6 C A S x y z w ii) * t) hi + dsimp only [poly_002200_3, poly_002200_5, poly_002200_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002200_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (S) (complexPow z 2)))))))))) + +noncomputable def poly_002200_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-10:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexPow z 2))))))))) + +include hC in +lemma reduce_002200_0 : + poly_002200_5 C A S x y z w ii = + poly_002200_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002200_8 C A S x y z w ii) * t) hC + dsimp only [poly_002200_5, poly_002200_7, poly_002200_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002200_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((5:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_002200_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +include hA in +lemma reduce_002200_1 : + poly_002200_7 C A S x y z w ii = + poly_002200_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_002200_10 C A S x y z w ii) * t) hA + dsimp only [poly_002200_7, poly_002200_9, poly_002200_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_002200_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +include hS in +lemma reduce_002200_2 : + poly_002200_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_002200_11 C A S x y z w ii) * t) hS + dsimp only [poly_002200_9, poly_002200_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_002200 : poly_002200_0 C A S x y z w ii = 0 := by + calc + poly_002200_0 C A S x y z w ii = poly_002200_1 C A S x y z w ii := reduce_002200_3 C A S x y z w ii hy + _ = poly_002200_3 C A S x y z w ii := reduce_002200_4 C A S x y z w ii hw + _ = poly_002200_5 C A S x y z w ii := reduce_002200_5 C A S x y z w ii hi + _ = poly_002200_7 C A S x y z w ii := reduce_002200_0 C A S x y z w ii hC + _ = poly_002200_9 C A S x y z w ii := reduce_002200_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_002200_2 C A S x y z w ii hS + +noncomputable def poly_011002_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_011002_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_011002_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))) + +include hy in +lemma reduce_011002_3 : + poly_011002_0 C A S x y z w ii = + poly_011002_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011002_2 C A S x y z w ii) * t) hy + dsimp only [poly_011002_0, poly_011002_1, poly_011002_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011002_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_011002_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))))))) + +include hw in +lemma reduce_011002_4 : + poly_011002_1 C A S x y z w ii = + poly_011002_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011002_4 C A S x y z w ii) * t) hw + dsimp only [poly_011002_1, poly_011002_3, poly_011002_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011002_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011002_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (C)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (C) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))))) + +include hC in +lemma reduce_011002_0 : + poly_011002_3 C A S x y z w ii = + poly_011002_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011002_6 C A S x y z w ii) * t) hC + dsimp only [poly_011002_3, poly_011002_5, poly_011002_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011002_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (y) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011002_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (S) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_011002_1 : + poly_011002_5 C A S x y z w ii = + poly_011002_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011002_8 C A S x y z w ii) * t) hA + dsimp only [poly_011002_5, poly_011002_7, poly_011002_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011002_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (y) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z)))))))) + +include hS in +lemma reduce_011002_2 : + poly_011002_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_011002_9 C A S x y z w ii) * t) hS + dsimp only [poly_011002_7, poly_011002_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_011002 : poly_011002_0 C A S x y z w ii = 0 := by + calc + poly_011002_0 C A S x y z w ii = poly_011002_1 C A S x y z w ii := reduce_011002_3 C A S x y z w ii hy + _ = poly_011002_3 C A S x y z w ii := reduce_011002_4 C A S x y z w ii hw + _ = poly_011002_5 C A S x y z w ii := reduce_011002_0 C A S x y z w ii hC + _ = poly_011002_7 C A S x y z w ii := reduce_011002_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_011002_2 C A S x y z w ii hS + +noncomputable def poly_011020_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))))) + +noncomputable def poly_011020_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_011020_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +include hy in +lemma reduce_011020_3 : + poly_011020_0 C A S x y z w ii = + poly_011020_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011020_2 C A S x y z w ii) * t) hy + dsimp only [poly_011020_0, poly_011020_1, poly_011020_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011020_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_011020_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z)))))))) + +include hw in +lemma reduce_011020_4 : + poly_011020_1 C A S x y z w ii = + poly_011020_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011020_4 C A S x y z w ii) * t) hw + dsimp only [poly_011020_1, poly_011020_3, poly_011020_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011020_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011020_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z)))))))) + +include hi in +lemma reduce_011020_5 : + poly_011020_3 C A S x y z w ii = + poly_011020_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011020_6 C A S x y z w ii) * t) hi + dsimp only [poly_011020_3, poly_011020_5, poly_011020_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011020_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-12:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((6:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011020_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (C)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((9:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))))) + +include hC in +lemma reduce_011020_0 : + poly_011020_5 C A S x y z w ii = + poly_011020_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011020_8 C A S x y z w ii) * t) hC + dsimp only [poly_011020_5, poly_011020_7, poly_011020_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011020_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((5:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 5)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((7:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((7:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((6:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-5:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((3:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((7:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011020_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (y) (S)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-12:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((6:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_011020_1 : + poly_011020_7 C A S x y z w ii = + poly_011020_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011020_10 C A S x y z w ii) * t) hA + dsimp only [poly_011020_7, poly_011020_9, poly_011020_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011020_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((3:ℂ)) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 2) (z)))))))) + +include hS in +lemma reduce_011020_2 : + poly_011020_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_011020_11 C A S x y z w ii) * t) hS + dsimp only [poly_011020_9, poly_011020_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_011020 : poly_011020_0 C A S x y z w ii = 0 := by + calc + poly_011020_0 C A S x y z w ii = poly_011020_1 C A S x y z w ii := reduce_011020_3 C A S x y z w ii hy + _ = poly_011020_3 C A S x y z w ii := reduce_011020_4 C A S x y z w ii hw + _ = poly_011020_5 C A S x y z w ii := reduce_011020_5 C A S x y z w ii hi + _ = poly_011020_7 C A S x y z w ii := reduce_011020_0 C A S x y z w ii hC + _ = poly_011020_9 C A S x y z w ii := reduce_011020_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_011020_2 C A S x y z w ii hS + +noncomputable def poly_011101_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +noncomputable def poly_011101_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_011101_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))) + +include hy in +lemma reduce_011101_3 : + poly_011101_0 C A S x y z w ii = + poly_011101_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011101_2 C A S x y z w ii) * t) hy + dsimp only [poly_011101_0, poly_011101_1, poly_011101_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011101_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_011101_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))))) + +include hw in +lemma reduce_011101_4 : + poly_011101_1 C A S x y z w ii = + poly_011101_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011101_4 C A S x y z w ii) * t) hw + dsimp only [poly_011101_1, poly_011101_3, poly_011101_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011101_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_011101_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))) + +include hi in +lemma reduce_011101_5 : + poly_011101_3 C A S x y z w ii = + poly_011101_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011101_6 C A S x y z w ii) * t) hi + dsimp only [poly_011101_3, poly_011101_5, poly_011101_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011101_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_011101_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (y) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_011101_0 : + poly_011101_5 C A S x y z w ii = + poly_011101_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011101_8 C A S x y z w ii) * t) hC + dsimp only [poly_011101_5, poly_011101_7, poly_011101_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011101_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_011101_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_011101_1 : + poly_011101_7 C A S x y z w ii = + poly_011101_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011101_10 C A S x y z w ii) * t) hA + dsimp only [poly_011101_7, poly_011101_9, poly_011101_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011101_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (x) (complexPow z 3))))))) + +include hS in +lemma reduce_011101_2 : + poly_011101_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_011101_11 C A S x y z w ii) * t) hS + dsimp only [poly_011101_9, poly_011101_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_011101 : poly_011101_0 C A S x y z w ii = 0 := by + calc + poly_011101_0 C A S x y z w ii = poly_011101_1 C A S x y z w ii := reduce_011101_3 C A S x y z w ii hy + _ = poly_011101_3 C A S x y z w ii := reduce_011101_4 C A S x y z w ii hw + _ = poly_011101_5 C A S x y z w ii := reduce_011101_5 C A S x y z w ii hi + _ = poly_011101_7 C A S x y z w ii := reduce_011101_0 C A S x y z w ii hC + _ = poly_011101_9 C A S x y z w ii := reduce_011101_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_011101_2 C A S x y z w ii hS + +noncomputable def poly_011110_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 4) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 4))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow y 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow w 4) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_011110_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (complexMul (complexPow C 3) (complexPow S 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2))))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 4) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x))))) (complexAdd (complexMul (complexMul (complexPow w 4) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_011110_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (complexMul (complexPow C 3) (complexPow S 3)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +include hy in +lemma reduce_011110_3 : + poly_011110_0 C A S x y z w ii = + poly_011110_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011110_2 C A S x y z w ii) * t) hy + dsimp only [poly_011110_0, poly_011110_1, poly_011110_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011110_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +noncomputable def poly_011110_4 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +include hw in +lemma reduce_011110_4 : + poly_011110_1 C A S x y z w ii = + poly_011110_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011110_4 C A S x y z w ii) * t) hw + dsimp only [poly_011110_1, poly_011110_3, poly_011110_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011110_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2)))))))) + +noncomputable def poly_011110_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))) + +include hi in +lemma reduce_011110_5 : + poly_011110_3 C A S x y z w ii = + poly_011110_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011110_6 C A S x y z w ii) * t) hi + dsimp only [poly_011110_3, poly_011110_5, poly_011110_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011110_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 2)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-56:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((10:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_011110_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-20:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hC in +lemma reduce_011110_0 : + poly_011110_5 C A S x y z w ii = + poly_011110_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011110_8 C A S x y z w ii) * t) hC + dsimp only [poly_011110_5, poly_011110_7, poly_011110_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011110_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-18:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((7:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-7:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((10:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_011110_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-56:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hA in +lemma reduce_011110_1 : + poly_011110_7 C A S x y z w ii = + poly_011110_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011110_10 C A S x y z w ii) * t) hA + dsimp only [poly_011110_7, poly_011110_9, poly_011110_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011110_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) + +include hS in +lemma reduce_011110_2 : + poly_011110_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_011110_11 C A S x y z w ii) * t) hS + dsimp only [poly_011110_9, poly_011110_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_011110 : poly_011110_0 C A S x y z w ii = 0 := by + calc + poly_011110_0 C A S x y z w ii = poly_011110_1 C A S x y z w ii := reduce_011110_3 C A S x y z w ii hy + _ = poly_011110_3 C A S x y z w ii := reduce_011110_4 C A S x y z w ii hw + _ = poly_011110_5 C A S x y z w ii := reduce_011110_5 C A S x y z w ii hi + _ = poly_011110_7 C A S x y z w ii := reduce_011110_0 C A S x y z w ii hC + _ = poly_011110_9 C A S x y z w ii := reduce_011110_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_011110_2 C A S x y z w ii hS + +noncomputable def poly_011200_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 3) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))))) + +noncomputable def poly_011200_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_011200_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +include hy in +lemma reduce_011200_3 : + poly_011200_0 C A S x y z w ii = + poly_011200_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011200_2 C A S x y z w ii) * t) hy + dsimp only [poly_011200_0, poly_011200_1, poly_011200_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011200_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))))))) + +noncomputable def poly_011200_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) + +include hw in +lemma reduce_011200_4 : + poly_011200_1 C A S x y z w ii = + poly_011200_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011200_4 C A S x y z w ii) * t) hw + dsimp only [poly_011200_1, poly_011200_3, poly_011200_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011200_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011200_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z)))))))) + +include hi in +lemma reduce_011200_5 : + poly_011200_3 C A S x y z w ii = + poly_011200_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011200_6 C A S x y z w ii) * t) hi + dsimp only [poly_011200_3, poly_011200_5, poly_011200_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011200_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011200_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (C) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (C) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +include hC in +lemma reduce_011200_0 : + poly_011200_5 C A S x y z w ii = + poly_011200_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011200_8 C A S x y z w ii) * t) hC + dsimp only [poly_011200_5, poly_011200_7, poly_011200_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011200_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow S 5)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (w) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((5:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_011200_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (y) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_011200_1 : + poly_011200_7 C A S x y z w ii = + poly_011200_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_011200_10 C A S x y z w ii) * t) hA + dsimp only [poly_011200_7, poly_011200_9, poly_011200_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_011200_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hS in +lemma reduce_011200_2 : + poly_011200_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_011200_11 C A S x y z w ii) * t) hS + dsimp only [poly_011200_9, poly_011200_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_011200 : poly_011200_0 C A S x y z w ii = 0 := by + calc + poly_011200_0 C A S x y z w ii = poly_011200_1 C A S x y z w ii := reduce_011200_3 C A S x y z w ii hy + _ = poly_011200_3 C A S x y z w ii := reduce_011200_4 C A S x y z w ii hw + _ = poly_011200_5 C A S x y z w ii := reduce_011200_5 C A S x y z w ii hi + _ = poly_011200_7 C A S x y z w ii := reduce_011200_0 C A S x y z w ii hC + _ = poly_011200_9 C A S x y z w ii := reduce_011200_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_011200_2 C A S x y z w ii hS + +noncomputable def poly_012021_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) + +noncomputable def poly_012021_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) + +noncomputable def poly_012021_2 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) + +include hy in +lemma reduce_012021_3 : + poly_012021_0 C A S x y z w ii = + poly_012021_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012021_2 C A S x y z w ii) * t) hy + dsimp only [poly_012021_0, poly_012021_1, poly_012021_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012021_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_012021_4 (C A S x _y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z)))) + +include hw in +lemma reduce_012021_4 : + poly_012021_1 C A S x y z w ii = + poly_012021_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012021_4 C A S x y z w ii) * t) hw + dsimp only [poly_012021_1, poly_012021_3, poly_012021_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012021_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z)))))) + +noncomputable def poly_012021_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))) + +include hi in +lemma reduce_012021_5 : + poly_012021_3 C A S x y z w ii = + poly_012021_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012021_6 C A S x y z w ii) * t) hi + dsimp only [poly_012021_3, poly_012021_5, poly_012021_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012021_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_012021_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))) + +include hC in +lemma reduce_012021_0 : + poly_012021_5 C A S x y z w ii = + poly_012021_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012021_8 C A S x y z w ii) * t) hC + dsimp only [poly_012021_5, poly_012021_7, poly_012021_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012021_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_012021_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) + +include hA in +lemma reduce_012021_1 : + poly_012021_7 C A S x y z w ii = + poly_012021_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012021_10 C A S x y z w ii) * t) hA + dsimp only [poly_012021_7, poly_012021_9, poly_012021_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012021_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (A) (complexMul (complexPow x 2) (z)))))) + +include hS in +lemma reduce_012021_2 : + poly_012021_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_012021_11 C A S x y z w ii) * t) hS + dsimp only [poly_012021_9, poly_012021_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_012021 : poly_012021_0 C A S x y z w ii = 0 := by + calc + poly_012021_0 C A S x y z w ii = poly_012021_1 C A S x y z w ii := reduce_012021_3 C A S x y z w ii hy + _ = poly_012021_3 C A S x y z w ii := reduce_012021_4 C A S x y z w ii hw + _ = poly_012021_5 C A S x y z w ii := reduce_012021_5 C A S x y z w ii hi + _ = poly_012021_7 C A S x y z w ii := reduce_012021_0 C A S x y z w ii hC + _ = poly_012021_9 C A S x y z w ii := reduce_012021_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_012021_2 C A S x y z w ii hS + +noncomputable def poly_012102_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +noncomputable def poly_012102_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_012102_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))) + +include hy in +lemma reduce_012102_3 : + poly_012102_0 C A S x y z w ii = + poly_012102_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012102_2 C A S x y z w ii) * t) hy + dsimp only [poly_012102_0, poly_012102_1, poly_012102_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012102_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_012102_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))))) + +include hw in +lemma reduce_012102_4 : + poly_012102_1 C A S x y z w ii = + poly_012102_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012102_4 C A S x y z w ii) * t) hw + dsimp only [poly_012102_1, poly_012102_3, poly_012102_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012102_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (C)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_012102_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))) + +include hi in +lemma reduce_012102_5 : + poly_012102_3 C A S x y z w ii = + poly_012102_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012102_6 C A S x y z w ii) * t) hi + dsimp only [poly_012102_3, poly_012102_5, poly_012102_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012102_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((24:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3))))))) + +noncomputable def poly_012102_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (w) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_012102_0 : + poly_012102_5 C A S x y z w ii = + poly_012102_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012102_8 C A S x y z w ii) * t) hC + dsimp only [poly_012102_5, poly_012102_7, poly_012102_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012102_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_012102_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_012102_1 : + poly_012102_7 C A S x y z w ii = + poly_012102_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012102_10 C A S x y z w ii) * t) hA + dsimp only [poly_012102_7, poly_012102_9, poly_012102_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012102_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (A) (complexMul (complexPow x 3) (z))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) + +include hS in +lemma reduce_012102_2 : + poly_012102_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_012102_11 C A S x y z w ii) * t) hS + dsimp only [poly_012102_9, poly_012102_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_012102 : poly_012102_0 C A S x y z w ii = 0 := by + calc + poly_012102_0 C A S x y z w ii = poly_012102_1 C A S x y z w ii := reduce_012102_3 C A S x y z w ii hy + _ = poly_012102_3 C A S x y z w ii := reduce_012102_4 C A S x y z w ii hw + _ = poly_012102_5 C A S x y z w ii := reduce_012102_5 C A S x y z w ii hi + _ = poly_012102_7 C A S x y z w ii := reduce_012102_0 C A S x y z w ii hC + _ = poly_012102_9 C A S x y z w ii := reduce_012102_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_012102_2 C A S x y z w ii hS + +noncomputable def poly_012111_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_012111_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_012111_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) + +include hy in +lemma reduce_012111_3 : + poly_012111_0 C A S x y z w ii = + poly_012111_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012111_2 C A S x y z w ii) * t) hy + dsimp only [poly_012111_0, poly_012111_1, poly_012111_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012111_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_012111_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +include hw in +lemma reduce_012111_4 : + poly_012111_1 C A S x y z w ii = + poly_012111_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012111_4 C A S x y z w ii) * t) hw + dsimp only [poly_012111_1, poly_012111_3, poly_012111_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012111_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_012111_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (C)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_012111_0 : + poly_012111_3 C A S x y z w ii = + poly_012111_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012111_6 C A S x y z w ii) * t) hC + dsimp only [poly_012111_3, poly_012111_5, poly_012111_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012111_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_012111_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_012111_1 : + poly_012111_5 C A S x y z w ii = + poly_012111_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012111_8 C A S x y z w ii) * t) hA + dsimp only [poly_012111_5, poly_012111_7, poly_012111_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012111_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_012111_2 : + poly_012111_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_012111_9 C A S x y z w ii) * t) hS + dsimp only [poly_012111_7, poly_012111_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_012111 : poly_012111_0 C A S x y z w ii = 0 := by + calc + poly_012111_0 C A S x y z w ii = poly_012111_1 C A S x y z w ii := reduce_012111_3 C A S x y z w ii hy + _ = poly_012111_3 C A S x y z w ii := reduce_012111_4 C A S x y z w ii hw + _ = poly_012111_5 C A S x y z w ii := reduce_012111_0 C A S x y z w ii hC + _ = poly_012111_7 C A S x y z w ii := reduce_012111_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_012111_2 C A S x y z w ii hS + +noncomputable def poly_012120_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_012120_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_012120_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))) + +include hy in +lemma reduce_012120_3 : + poly_012120_0 C A S x y z w ii = + poly_012120_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012120_2 C A S x y z w ii) * t) hy + dsimp only [poly_012120_0, poly_012120_1, poly_012120_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012120_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_012120_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z)))))) + +include hw in +lemma reduce_012120_4 : + poly_012120_1 C A S x y z w ii = + poly_012120_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012120_4 C A S x y z w ii) * t) hw + dsimp only [poly_012120_1, poly_012120_3, poly_012120_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012120_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_012120_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))) + +include hi in +lemma reduce_012120_5 : + poly_012120_3 C A S x y z w ii = + poly_012120_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012120_6 C A S x y z w ii) * t) hi + dsimp only [poly_012120_3, poly_012120_5, poly_012120_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012120_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_012120_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +include hC in +lemma reduce_012120_0 : + poly_012120_5 C A S x y z w ii = + poly_012120_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012120_8 C A S x y z w ii) * t) hC + dsimp only [poly_012120_5, poly_012120_7, poly_012120_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012120_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_012120_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_012120_1 : + poly_012120_7 C A S x y z w ii = + poly_012120_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012120_10 C A S x y z w ii) * t) hA + dsimp only [poly_012120_7, poly_012120_9, poly_012120_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012120_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_012120_2 : + poly_012120_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_012120_11 C A S x y z w ii) * t) hS + dsimp only [poly_012120_9, poly_012120_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_012120 : poly_012120_0 C A S x y z w ii = 0 := by + calc + poly_012120_0 C A S x y z w ii = poly_012120_1 C A S x y z w ii := reduce_012120_3 C A S x y z w ii hy + _ = poly_012120_3 C A S x y z w ii := reduce_012120_4 C A S x y z w ii hw + _ = poly_012120_5 C A S x y z w ii := reduce_012120_5 C A S x y z w ii hi + _ = poly_012120_7 C A S x y z w ii := reduce_012120_0 C A S x y z w ii hC + _ = poly_012120_9 C A S x y z w ii := reduce_012120_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_012120_2 C A S x y z w ii hS + +noncomputable def poly_012201_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (complexPow y 4) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_012201_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) + +noncomputable def poly_012201_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexPow y 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) + +include hy in +lemma reduce_012201_3 : + poly_012201_0 C A S x y z w ii = + poly_012201_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012201_2 C A S x y z w ii) * t) hy + dsimp only [poly_012201_0, poly_012201_1, poly_012201_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012201_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_012201_4 (C A S x _y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))) + +include hw in +lemma reduce_012201_4 : + poly_012201_1 C A S x y z w ii = + poly_012201_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012201_4 C A S x y z w ii) * t) hw + dsimp only [poly_012201_1, poly_012201_3, poly_012201_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012201_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_012201_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))) + +include hi in +lemma reduce_012201_5 : + poly_012201_3 C A S x y z w ii = + poly_012201_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012201_6 C A S x y z w ii) * t) hi + dsimp only [poly_012201_3, poly_012201_5, poly_012201_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012201_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))))))) + +noncomputable def poly_012201_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))))))) + +include hC in +lemma reduce_012201_0 : + poly_012201_5 C A S x y z w ii = + poly_012201_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012201_8 C A S x y z w ii) * t) hC + dsimp only [poly_012201_5, poly_012201_7, poly_012201_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012201_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))))))) + +noncomputable def poly_012201_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) + +include hA in +lemma reduce_012201_1 : + poly_012201_7 C A S x y z w ii = + poly_012201_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_012201_10 C A S x y z w ii) * t) hA + dsimp only [poly_012201_7, poly_012201_9, poly_012201_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_012201_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z))))))) + +include hS in +lemma reduce_012201_2 : + poly_012201_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_012201_11 C A S x y z w ii) * t) hS + dsimp only [poly_012201_9, poly_012201_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_012201 : poly_012201_0 C A S x y z w ii = 0 := by + calc + poly_012201_0 C A S x y z w ii = poly_012201_1 C A S x y z w ii := reduce_012201_3 C A S x y z w ii hy + _ = poly_012201_3 C A S x y z w ii := reduce_012201_4 C A S x y z w ii hw + _ = poly_012201_5 C A S x y z w ii := reduce_012201_5 C A S x y z w ii hi + _ = poly_012201_7 C A S x y z w ii := reduce_012201_0 C A S x y z w ii hC + _ = poly_012201_9 C A S x y z w ii := reduce_012201_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_012201_2 C A S x y z w ii hS + +noncomputable def poly_020011_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))))) + +noncomputable def poly_020011_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_020011_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +include hy in +lemma reduce_020011_3 : + poly_020011_0 C A S x y z w ii = + poly_020011_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020011_2 C A S x y z w ii) * t) hy + dsimp only [poly_020011_0, poly_020011_1, poly_020011_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020011_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_020011_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z)))))))) + +include hw in +lemma reduce_020011_4 : + poly_020011_1 C A S x y z w ii = + poly_020011_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020011_4 C A S x y z w ii) * t) hw + dsimp only [poly_020011_1, poly_020011_3, poly_020011_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020011_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_020011_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z)))))))) + +include hi in +lemma reduce_020011_5 : + poly_020011_3 C A S x y z w ii = + poly_020011_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020011_6 C A S x y z w ii) * t) hi + dsimp only [poly_020011_3, poly_020011_5, poly_020011_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020011_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((12:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-6:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))))))) + +noncomputable def poly_020011_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (C) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-9:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (A) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))))) + +include hC in +lemma reduce_020011_0 : + poly_020011_5 C A S x y z w ii = + poly_020011_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020011_8 C A S x y z w ii) * t) hC + dsimp only [poly_020011_5, poly_020011_7, poly_020011_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020011_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((5:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((7:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-7:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-6:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((5:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-7:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_020011_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((12:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-6:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((4:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_020011_1 : + poly_020011_7 C A S x y z w ii = + poly_020011_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020011_10 C A S x y z w ii) * t) hA + dsimp only [poly_020011_7, poly_020011_9, poly_020011_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020011_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (y) (S)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-3:ℂ)) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) + +include hS in +lemma reduce_020011_2 : + poly_020011_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_020011_11 C A S x y z w ii) * t) hS + dsimp only [poly_020011_9, poly_020011_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_020011 : poly_020011_0 C A S x y z w ii = 0 := by + calc + poly_020011_0 C A S x y z w ii = poly_020011_1 C A S x y z w ii := reduce_020011_3 C A S x y z w ii hy + _ = poly_020011_3 C A S x y z w ii := reduce_020011_4 C A S x y z w ii hw + _ = poly_020011_5 C A S x y z w ii := reduce_020011_5 C A S x y z w ii hi + _ = poly_020011_7 C A S x y z w ii := reduce_020011_0 C A S x y z w ii hC + _ = poly_020011_9 C A S x y z w ii := reduce_020011_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_020011_2 C A S x y z w ii hS + +noncomputable def poly_020020_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 4)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 4)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (complexPow y 3)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-10:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((12:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow ii 3) (complexPow A 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((10:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-14:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexPow y 2) (ii)) (complexMul (C) (complexMul (S) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))))) + +noncomputable def poly_020020_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 3)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((20:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-20:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((10:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((16:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-14:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexPow z 2))))))))) + +noncomputable def poly_020020_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((10:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-12:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-14:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexPow z 2)))))))) + +include hy in +lemma reduce_020020_3 : + poly_020020_0 C A S x y z w ii = + poly_020020_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020020_2 C A S x y z w ii) * t) hy + dsimp only [poly_020020_0, poly_020020_1, poly_020020_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020020_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((20:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((24:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-24:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((10:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((28:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_020020_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((20:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((10:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow ii 3)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow ii 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))))) + +include hw in +lemma reduce_020020_4 : + poly_020020_1 C A S x y z w ii = + poly_020020_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020020_4 C A S x y z w ii) * t) hw + dsimp only [poly_020020_1, poly_020020_3, poly_020020_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020020_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((20:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((24:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-24:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((10:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((28:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_020020_6 (C A _S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow C 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) + +include hi in +lemma reduce_020020_5 : + poly_020020_3 C A S x y z w ii = + poly_020020_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020020_6 C A S x y z w ii) * t) hi + dsimp only [poly_020020_3, poly_020020_5, poly_020020_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020020_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-64:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-96:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-64:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((96:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-64:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((64:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-96:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((96:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-64:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-96:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-64:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexPow z 2))))))))) + +noncomputable def poly_020020_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((20:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (ii) (complexMul (S) (complexPow z 2))))))))) + +include hC in +lemma reduce_020020_0 : + poly_020020_5 C A S x y z w ii = + poly_020020_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020020_8 C A S x y z w ii) * t) hC + dsimp only [poly_020020_5, poly_020020_7, poly_020020_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020020_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((12:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((48:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-40:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-10:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +noncomputable def poly_020020_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-64:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-96:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-64:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((96:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-64:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-96:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((96:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-64:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-96:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((64:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-64:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((64:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +include hA in +lemma reduce_020020_1 : + poly_020020_7 C A S x y z w ii = + poly_020020_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020020_10 C A S x y z w ii) * t) hA + dsimp only [poly_020020_7, poly_020020_9, poly_020020_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020020_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((32:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((48:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-40:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))))) + +include hS in +lemma reduce_020020_2 : + poly_020020_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_020020_11 C A S x y z w ii) * t) hS + dsimp only [poly_020020_9, poly_020020_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_020020 : poly_020020_0 C A S x y z w ii = 0 := by + calc + poly_020020_0 C A S x y z w ii = poly_020020_1 C A S x y z w ii := reduce_020020_3 C A S x y z w ii hy + _ = poly_020020_3 C A S x y z w ii := reduce_020020_4 C A S x y z w ii hw + _ = poly_020020_5 C A S x y z w ii := reduce_020020_5 C A S x y z w ii hi + _ = poly_020020_7 C A S x y z w ii := reduce_020020_0 C A S x y z w ii hC + _ = poly_020020_9 C A S x y z w ii := reduce_020020_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_020020_2 C A S x y z w ii hS + +noncomputable def poly_020101_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_020101_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_020101_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))) + +include hy in +lemma reduce_020101_3 : + poly_020101_0 C A S x y z w ii = + poly_020101_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020101_2 C A S x y z w ii) * t) hy + dsimp only [poly_020101_0, poly_020101_1, poly_020101_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020101_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) + +noncomputable def poly_020101_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +include hw in +lemma reduce_020101_4 : + poly_020101_1 C A S x y z w ii = + poly_020101_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020101_4 C A S x y z w ii) * t) hw + dsimp only [poly_020101_1, poly_020101_3, poly_020101_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020101_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) + +noncomputable def poly_020101_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))) + +include hi in +lemma reduce_020101_5 : + poly_020101_3 C A S x y z w ii = + poly_020101_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020101_6 C A S x y z w ii) * t) hi + dsimp only [poly_020101_3, poly_020101_5, poly_020101_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020101_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_020101_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (C)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (A)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2))))))))) + +include hC in +lemma reduce_020101_0 : + poly_020101_5 C A S x y z w ii = + poly_020101_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020101_8 C A S x y z w ii) * t) hC + dsimp only [poly_020101_5, poly_020101_7, poly_020101_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020101_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (ii) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2)))))))) + +noncomputable def poly_020101_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 2)))))))) + +include hA in +lemma reduce_020101_1 : + poly_020101_7 C A S x y z w ii = + poly_020101_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020101_10 C A S x y z w ii) * t) hA + dsimp only [poly_020101_7, poly_020101_9, poly_020101_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020101_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (x) (complexPow z 4))) (complexMul (ii) (complexMul (x) (complexPow z 2))))))) + +include hS in +lemma reduce_020101_2 : + poly_020101_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_020101_11 C A S x y z w ii) * t) hS + dsimp only [poly_020101_9, poly_020101_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_020101 : poly_020101_0 C A S x y z w ii = 0 := by + calc + poly_020101_0 C A S x y z w ii = poly_020101_1 C A S x y z w ii := reduce_020101_3 C A S x y z w ii hy + _ = poly_020101_3 C A S x y z w ii := reduce_020101_4 C A S x y z w ii hw + _ = poly_020101_5 C A S x y z w ii := reduce_020101_5 C A S x y z w ii hi + _ = poly_020101_7 C A S x y z w ii := reduce_020101_0 C A S x y z w ii hC + _ = poly_020101_9 C A S x y z w ii := reduce_020101_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_020101_2 C A S x y z w ii hS + +noncomputable def poly_020110_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_020110_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_020110_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) + +include hy in +lemma reduce_020110_3 : + poly_020110_0 C A S x y z w ii = + poly_020110_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020110_2 C A S x y z w ii) * t) hy + dsimp only [poly_020110_0, poly_020110_1, poly_020110_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020110_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))))) + +noncomputable def poly_020110_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) + +include hw in +lemma reduce_020110_4 : + poly_020110_1 C A S x y z w ii = + poly_020110_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020110_4 C A S x y z w ii) * t) hw + dsimp only [poly_020110_1, poly_020110_3, poly_020110_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020110_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_020110_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +include hi in +lemma reduce_020110_5 : + poly_020110_3 C A S x y z w ii = + poly_020110_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020110_6 C A S x y z w ii) * t) hi + dsimp only [poly_020110_3, poly_020110_5, poly_020110_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020110_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_020110_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) + +include hC in +lemma reduce_020110_0 : + poly_020110_5 C A S x y z w ii = + poly_020110_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020110_8 C A S x y z w ii) * t) hC + dsimp only [poly_020110_5, poly_020110_7, poly_020110_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020110_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 5)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (x) (complexPow z 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_020110_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (ii) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_020110_1 : + poly_020110_7 C A S x y z w ii = + poly_020110_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_020110_10 C A S x y z w ii) * t) hA + dsimp only [poly_020110_7, poly_020110_9, poly_020110_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_020110_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (ii) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_020110_2 : + poly_020110_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_020110_11 C A S x y z w ii) * t) hS + dsimp only [poly_020110_9, poly_020110_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_020110 : poly_020110_0 C A S x y z w ii = 0 := by + calc + poly_020110_0 C A S x y z w ii = poly_020110_1 C A S x y z w ii := reduce_020110_3 C A S x y z w ii hy + _ = poly_020110_3 C A S x y z w ii := reduce_020110_4 C A S x y z w ii hw + _ = poly_020110_5 C A S x y z w ii := reduce_020110_5 C A S x y z w ii hi + _ = poly_020110_7 C A S x y z w ii := reduce_020110_0 C A S x y z w ii hC + _ = poly_020110_9 C A S x y z w ii := reduce_020110_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_020110_2 C A S x y z w ii hS + +noncomputable def poly_021102_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow y 3)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-6:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow x 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow x 3)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (complexPow x 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_021102_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul ((-7:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((7:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +noncomputable def poly_021102_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 2)) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) + +include hy in +lemma reduce_021102_3 : + poly_021102_0 C A S x y z w ii = + poly_021102_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021102_2 C A S x y z w ii) * t) hy + dsimp only [poly_021102_0, poly_021102_1, poly_021102_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021102_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-7:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +noncomputable def poly_021102_4 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-7:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) + +include hw in +lemma reduce_021102_4 : + poly_021102_1 C A S x y z w ii = + poly_021102_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021102_4 C A S x y z w ii) * t) hw + dsimp only [poly_021102_1, poly_021102_3, poly_021102_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021102_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-7:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_021102_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) + +include hi in +lemma reduce_021102_5 : + poly_021102_3 C A S x y z w ii = + poly_021102_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021102_6 C A S x y z w ii) * t) hi + dsimp only [poly_021102_3, poly_021102_5, poly_021102_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021102_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_021102_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 2))))))))) + +include hC in +lemma reduce_021102_0 : + poly_021102_5 C A S x y z w ii = + poly_021102_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021102_8 C A S x y z w ii) * t) hC + dsimp only [poly_021102_5, poly_021102_7, poly_021102_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021102_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow S 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_021102_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) + +include hA in +lemma reduce_021102_1 : + poly_021102_7 C A S x y z w ii = + poly_021102_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021102_10 C A S x y z w ii) * t) hA + dsimp only [poly_021102_7, poly_021102_9, poly_021102_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021102_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 2))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +include hS in +lemma reduce_021102_2 : + poly_021102_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_021102_11 C A S x y z w ii) * t) hS + dsimp only [poly_021102_9, poly_021102_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_021102 : poly_021102_0 C A S x y z w ii = 0 := by + calc + poly_021102_0 C A S x y z w ii = poly_021102_1 C A S x y z w ii := reduce_021102_3 C A S x y z w ii hy + _ = poly_021102_3 C A S x y z w ii := reduce_021102_4 C A S x y z w ii hw + _ = poly_021102_5 C A S x y z w ii := reduce_021102_5 C A S x y z w ii hi + _ = poly_021102_7 C A S x y z w ii := reduce_021102_0 C A S x y z w ii hC + _ = poly_021102_9 C A S x y z w ii := reduce_021102_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_021102_2 C A S x y z w ii hS + +noncomputable def poly_021111_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_021111_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_021111_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hy in +lemma reduce_021111_3 : + poly_021111_0 C A S x y z w ii = + poly_021111_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021111_2 C A S x y z w ii) * t) hy + dsimp only [poly_021111_0, poly_021111_1, poly_021111_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021111_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_021111_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) + +include hw in +lemma reduce_021111_4 : + poly_021111_1 C A S x y z w ii = + poly_021111_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021111_4 C A S x y z w ii) * t) hw + dsimp only [poly_021111_1, poly_021111_3, poly_021111_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021111_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_021111_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z))))))) + +include hi in +lemma reduce_021111_5 : + poly_021111_3 C A S x y z w ii = + poly_021111_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021111_6 C A S x y z w ii) * t) hi + dsimp only [poly_021111_3, poly_021111_5, poly_021111_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021111_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_021111_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_021111_0 : + poly_021111_5 C A S x y z w ii = + poly_021111_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021111_8 C A S x y z w ii) * t) hC + dsimp only [poly_021111_5, poly_021111_7, poly_021111_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021111_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_021111_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (y) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (S) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_021111_1 : + poly_021111_7 C A S x y z w ii = + poly_021111_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021111_10 C A S x y z w ii) * t) hA + dsimp only [poly_021111_7, poly_021111_9, poly_021111_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021111_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (w) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_021111_2 : + poly_021111_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_021111_11 C A S x y z w ii) * t) hS + dsimp only [poly_021111_9, poly_021111_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_021111 : poly_021111_0 C A S x y z w ii = 0 := by + calc + poly_021111_0 C A S x y z w ii = poly_021111_1 C A S x y z w ii := reduce_021111_3 C A S x y z w ii hy + _ = poly_021111_3 C A S x y z w ii := reduce_021111_4 C A S x y z w ii hw + _ = poly_021111_5 C A S x y z w ii := reduce_021111_5 C A S x y z w ii hi + _ = poly_021111_7 C A S x y z w ii := reduce_021111_0 C A S x y z w ii hC + _ = poly_021111_9 C A S x y z w ii := reduce_021111_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_021111_2 C A S x y z w ii hS + +noncomputable def poly_021120_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))) (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexPow y 3) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow y 3)) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 4))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (x))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (x)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow y 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 4) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow x 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow x 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))))))) + +noncomputable def poly_021120_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 4) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul (complexPow w 4) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul (complexMul ((7:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-7:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_021120_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 4) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul (complexPow w 3) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hy in +lemma reduce_021120_3 : + poly_021120_0 C A S x y z w ii = + poly_021120_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021120_2 C A S x y z w ii) * t) hy + dsimp only [poly_021120_0, poly_021120_1, poly_021120_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021120_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow ii 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow ii 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((7:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_021120_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((7:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-5:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2))))))))) + +include hw in +lemma reduce_021120_4 : + poly_021120_1 C A S x y z w ii = + poly_021120_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021120_4 C A S x y z w ii) * t) hw + dsimp only [poly_021120_1, poly_021120_3, poly_021120_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021120_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((7:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4))))))))) + +noncomputable def poly_021120_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +include hi in +lemma reduce_021120_5 : + poly_021120_3 C A S x y z w ii = + poly_021120_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021120_6 C A S x y z w ii) * t) hi + dsimp only [poly_021120_3, poly_021120_5, poly_021120_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021120_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 2)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-20:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_021120_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +include hC in +lemma reduce_021120_0 : + poly_021120_5 C A S x y z w ii = + poly_021120_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021120_8 C A S x y z w ii) * t) hC + dsimp only [poly_021120_5, poly_021120_7, poly_021120_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021120_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((14:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-7:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((7:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-14:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((10:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_021120_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-20:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-24:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hA in +lemma reduce_021120_1 : + poly_021120_7 C A S x y z w ii = + poly_021120_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_021120_10 C A S x y z w ii) * t) hA + dsimp only [poly_021120_7, poly_021120_9, poly_021120_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_021120_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hS in +lemma reduce_021120_2 : + poly_021120_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_021120_11 C A S x y z w ii) * t) hS + dsimp only [poly_021120_9, poly_021120_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_021120 : poly_021120_0 C A S x y z w ii = 0 := by + calc + poly_021120_0 C A S x y z w ii = poly_021120_1 C A S x y z w ii := reduce_021120_3 C A S x y z w ii hy + _ = poly_021120_3 C A S x y z w ii := reduce_021120_4 C A S x y z w ii hw + _ = poly_021120_5 C A S x y z w ii := reduce_021120_5 C A S x y z w ii hi + _ = poly_021120_7 C A S x y z w ii := reduce_021120_0 C A S x y z w ii hC + _ = poly_021120_9 C A S x y z w ii := reduce_021120_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_021120_2 C A S x y z w ii hS + +noncomputable def poly_022112_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_022112_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_022112_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) + +include hy in +lemma reduce_022112_3 : + poly_022112_0 C A S x y z w ii = + poly_022112_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022112_2 C A S x y z w ii) * t) hy + dsimp only [poly_022112_0, poly_022112_1, poly_022112_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022112_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_022112_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) + +include hw in +lemma reduce_022112_4 : + poly_022112_1 C A S x y z w ii = + poly_022112_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022112_4 C A S x y z w ii) * t) hw + dsimp only [poly_022112_1, poly_022112_3, poly_022112_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022112_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_022112_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_022112_0 : + poly_022112_3 C A S x y z w ii = + poly_022112_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022112_6 C A S x y z w ii) * t) hC + dsimp only [poly_022112_3, poly_022112_5, poly_022112_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022112_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_022112_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (w) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_022112_1 : + poly_022112_5 C A S x y z w ii = + poly_022112_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022112_8 C A S x y z w ii) * t) hA + dsimp only [poly_022112_5, poly_022112_7, poly_022112_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022112_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (y) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_022112_2 : + poly_022112_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_022112_9 C A S x y z w ii) * t) hS + dsimp only [poly_022112_7, poly_022112_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_022112 : poly_022112_0 C A S x y z w ii = 0 := by + calc + poly_022112_0 C A S x y z w ii = poly_022112_1 C A S x y z w ii := reduce_022112_3 C A S x y z w ii hy + _ = poly_022112_3 C A S x y z w ii := reduce_022112_4 C A S x y z w ii hw + _ = poly_022112_5 C A S x y z w ii := reduce_022112_0 C A S x y z w ii hC + _ = poly_022112_7 C A S x y z w ii := reduce_022112_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_022112_2 C A S x y z w ii hS + +noncomputable def poly_022121_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))))))) + +noncomputable def poly_022121_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_022121_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) + +include hy in +lemma reduce_022121_3 : + poly_022121_0 C A S x y z w ii = + poly_022121_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022121_2 C A S x y z w ii) * t) hy + dsimp only [poly_022121_0, poly_022121_1, poly_022121_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022121_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_022121_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +include hw in +lemma reduce_022121_4 : + poly_022121_1 C A S x y z w ii = + poly_022121_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022121_4 C A S x y z w ii) * t) hw + dsimp only [poly_022121_1, poly_022121_3, poly_022121_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022121_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_022121_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +include hC in +lemma reduce_022121_0 : + poly_022121_3 C A S x y z w ii = + poly_022121_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022121_6 C A S x y z w ii) * t) hC + dsimp only [poly_022121_3, poly_022121_5, poly_022121_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022121_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 4))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 2))) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (((-3:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 4))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_022121_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (ii) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (S) (complexMul (x) (complexPow z 2))) (complexMul ((2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul ((-1:ℂ)) (complexMul (x) (complexPow z 4))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +include hA in +lemma reduce_022121_1 : + poly_022121_5 C A S x y z w ii = + poly_022121_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_022121_8 C A S x y z w ii) * t) hA + dsimp only [poly_022121_5, poly_022121_7, poly_022121_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_022121_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul ((-2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (x) (complexPow z 4)) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2)))))))) + +include hS in +lemma reduce_022121_2 : + poly_022121_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_022121_9 C A S x y z w ii) * t) hS + dsimp only [poly_022121_7, poly_022121_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_022121 : poly_022121_0 C A S x y z w ii = 0 := by + calc + poly_022121_0 C A S x y z w ii = poly_022121_1 C A S x y z w ii := reduce_022121_3 C A S x y z w ii hy + _ = poly_022121_3 C A S x y z w ii := reduce_022121_4 C A S x y z w ii hw + _ = poly_022121_5 C A S x y z w ii := reduce_022121_0 C A S x y z w ii hC + _ = poly_022121_7 C A S x y z w ii := reduce_022121_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_022121_2 C A S x y z w ii hS + +end Algebra +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsZero.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a61dc7bcb791e86f1503a4960ea135dd2a3abf2 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPolynomialsZero.lean @@ -0,0 +1,1278 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterDefinitions +import Mathlib.Tactic.LinearCombination + +namespace OAI + +/-! Yang–Baxter polynomial reductions with first spin zero. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +section Algebra +variable (C A S x y z w ii : ℂ) +variable (hC : C = (2*S+1)*A) (hA : A^2 = (1-S)/2) + (hS : S^2 = 1/2) (hy : y^2+x^2=1) (hw : w^2+z^2=1) (hi : ii^2+1=0) + +noncomputable def poly_101002_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_101002_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_101002_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) + +include hy in +lemma reduce_101002_3 : + poly_101002_0 C A S x y z w ii = + poly_101002_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101002_2 C A S x y z w ii) * t) hy + dsimp only [poly_101002_0, poly_101002_1, poly_101002_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101002_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_101002_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +include hw in +lemma reduce_101002_4 : + poly_101002_1 C A S x y z w ii = + poly_101002_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101002_4 C A S x y z w ii) * t) hw + dsimp only [poly_101002_1, poly_101002_3, poly_101002_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101002_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_101002_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (C)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +include hC in +lemma reduce_101002_0 : + poly_101002_3 C A S x y z w ii = + poly_101002_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101002_6 C A S x y z w ii) * t) hC + dsimp only [poly_101002_3, poly_101002_5, poly_101002_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101002_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 2))) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (((-3:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 4))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_101002_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (S) (complexMul (x) (complexPow z 2))) (complexMul ((2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul ((-1:ℂ)) (complexMul (x) (complexPow z 4))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +include hA in +lemma reduce_101002_1 : + poly_101002_5 C A S x y z w ii = + poly_101002_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101002_8 C A S x y z w ii) * t) hA + dsimp only [poly_101002_5, poly_101002_7, poly_101002_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101002_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (ii) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul ((-2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (x) (complexPow z 4)) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2)))))))) + +include hS in +lemma reduce_101002_2 : + poly_101002_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_101002_9 C A S x y z w ii) * t) hS + dsimp only [poly_101002_7, poly_101002_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_101002 : poly_101002_0 C A S x y z w ii = 0 := by + calc + poly_101002_0 C A S x y z w ii = poly_101002_1 C A S x y z w ii := reduce_101002_3 C A S x y z w ii hy + _ = poly_101002_3 C A S x y z w ii := reduce_101002_4 C A S x y z w ii hw + _ = poly_101002_5 C A S x y z w ii := reduce_101002_0 C A S x y z w ii hC + _ = poly_101002_7 C A S x y z w ii := reduce_101002_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_101002_2 C A S x y z w ii hS + +noncomputable def poly_101020_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_101020_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_101020_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))) + +include hy in +lemma reduce_101020_3 : + poly_101020_0 C A S x y z w ii = + poly_101020_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101020_2 C A S x y z w ii) * t) hy + dsimp only [poly_101020_0, poly_101020_1, poly_101020_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101020_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (w) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) + +noncomputable def poly_101020_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +include hw in +lemma reduce_101020_4 : + poly_101020_1 C A S x y z w ii = + poly_101020_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101020_4 C A S x y z w ii) * t) hw + dsimp only [poly_101020_1, poly_101020_3, poly_101020_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101020_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) + +noncomputable def poly_101020_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))))) + +include hi in +lemma reduce_101020_5 : + poly_101020_3 C A S x y z w ii = + poly_101020_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101020_6 C A S x y z w ii) * t) hi + dsimp only [poly_101020_3, poly_101020_5, poly_101020_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101020_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_101020_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (C)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (C) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2))))))))) + +include hC in +lemma reduce_101020_0 : + poly_101020_5 C A S x y z w ii = + poly_101020_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101020_8 C A S x y z w ii) * t) hC + dsimp only [poly_101020_5, poly_101020_7, poly_101020_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101020_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (ii) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2)))))))) + +noncomputable def poly_101020_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 2)))))))) + +include hA in +lemma reduce_101020_1 : + poly_101020_7 C A S x y z w ii = + poly_101020_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101020_10 C A S x y z w ii) * t) hA + dsimp only [poly_101020_7, poly_101020_9, poly_101020_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101020_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (x) (complexPow z 4))) (complexMul (ii) (complexMul (x) (complexPow z 2))))))) + +include hS in +lemma reduce_101020_2 : + poly_101020_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_101020_11 C A S x y z w ii) * t) hS + dsimp only [poly_101020_9, poly_101020_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_101020 : poly_101020_0 C A S x y z w ii = 0 := by + calc + poly_101020_0 C A S x y z w ii = poly_101020_1 C A S x y z w ii := reduce_101020_3 C A S x y z w ii hy + _ = poly_101020_3 C A S x y z w ii := reduce_101020_4 C A S x y z w ii hw + _ = poly_101020_5 C A S x y z w ii := reduce_101020_5 C A S x y z w ii hi + _ = poly_101020_7 C A S x y z w ii := reduce_101020_0 C A S x y z w ii hC + _ = poly_101020_9 C A S x y z w ii := reduce_101020_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_101020_2 C A S x y z w ii hS + +noncomputable def poly_101110_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (complexPow y 4) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_101110_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) + +noncomputable def poly_101110_2 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (complexPow y 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) + +include hy in +lemma reduce_101110_3 : + poly_101110_0 C A S x y z w ii = + poly_101110_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101110_2 C A S x y z w ii) * t) hy + dsimp only [poly_101110_0, poly_101110_1, poly_101110_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101110_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_101110_4 (C A S x _y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z)))) + +include hw in +lemma reduce_101110_4 : + poly_101110_1 C A S x y z w ii = + poly_101110_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101110_4 C A S x y z w ii) * t) hw + dsimp only [poly_101110_1, poly_101110_3, poly_101110_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101110_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z)))))) + +noncomputable def poly_101110_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (complexPow x 2) (z))))) + +include hi in +lemma reduce_101110_5 : + poly_101110_3 C A S x y z w ii = + poly_101110_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101110_6 C A S x y z w ii) * t) hi + dsimp only [poly_101110_3, poly_101110_5, poly_101110_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101110_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_101110_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z)))))) + +include hC in +lemma reduce_101110_0 : + poly_101110_5 C A S x y z w ii = + poly_101110_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101110_8 C A S x y z w ii) * t) hC + dsimp only [poly_101110_5, poly_101110_7, poly_101110_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101110_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))) + +noncomputable def poly_101110_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) + +include hA in +lemma reduce_101110_1 : + poly_101110_7 C A S x y z w ii = + poly_101110_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_101110_10 C A S x y z w ii) * t) hA + dsimp only [poly_101110_7, poly_101110_9, poly_101110_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_101110_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (A) (complexMul (complexPow x 2) (z)))))) + +include hS in +lemma reduce_101110_2 : + poly_101110_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_101110_11 C A S x y z w ii) * t) hS + dsimp only [poly_101110_9, poly_101110_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_101110 : poly_101110_0 C A S x y z w ii = 0 := by + calc + poly_101110_0 C A S x y z w ii = poly_101110_1 C A S x y z w ii := reduce_101110_3 C A S x y z w ii hy + _ = poly_101110_3 C A S x y z w ii := reduce_101110_4 C A S x y z w ii hw + _ = poly_101110_5 C A S x y z w ii := reduce_101110_5 C A S x y z w ii hi + _ = poly_101110_7 C A S x y z w ii := reduce_101110_0 C A S x y z w ii hC + _ = poly_101110_9 C A S x y z w ii := reduce_101110_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_101110_2 C A S x y z w ii hS + +noncomputable def poly_102111_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_102111_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_102111_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))) + +include hy in +lemma reduce_102111_3 : + poly_102111_0 C A S x y z w ii = + poly_102111_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_102111_2 C A S x y z w ii) * t) hy + dsimp only [poly_102111_0, poly_102111_1, poly_102111_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_102111_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_102111_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))))))) + +include hw in +lemma reduce_102111_4 : + poly_102111_1 C A S x y z w ii = + poly_102111_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_102111_4 C A S x y z w ii) * t) hw + dsimp only [poly_102111_1, poly_102111_3, poly_102111_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_102111_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_102111_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) + +include hi in +lemma reduce_102111_5 : + poly_102111_3 C A S x y z w ii = + poly_102111_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_102111_6 C A S x y z w ii) * t) hi + dsimp only [poly_102111_3, poly_102111_5, poly_102111_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_102111_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_102111_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (C) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-9:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (C) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((9:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))))) + +include hC in +lemma reduce_102111_0 : + poly_102111_5 C A S x y z w ii = + poly_102111_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_102111_8 C A S x y z w ii) * t) hC + dsimp only [poly_102111_5, poly_102111_7, poly_102111_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_102111_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (y) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((5:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((7:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((3:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((3:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((-7:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_102111_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((-6:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-4:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_102111_1 : + poly_102111_7 C A S x y z w ii = + poly_102111_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_102111_10 C A S x y z w ii) * t) hA + dsimp only [poly_102111_7, poly_102111_9, poly_102111_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_102111_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (y) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((5:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-7:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-5:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((7:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hS in +lemma reduce_102111_2 : + poly_102111_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_102111_11 C A S x y z w ii) * t) hS + dsimp only [poly_102111_9, poly_102111_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_102111 : poly_102111_0 C A S x y z w ii = 0 := by + calc + poly_102111_0 C A S x y z w ii = poly_102111_1 C A S x y z w ii := reduce_102111_3 C A S x y z w ii hy + _ = poly_102111_3 C A S x y z w ii := reduce_102111_4 C A S x y z w ii hw + _ = poly_102111_5 C A S x y z w ii := reduce_102111_5 C A S x y z w ii hi + _ = poly_102111_7 C A S x y z w ii := reduce_102111_0 C A S x y z w ii hC + _ = poly_102111_9 C A S x y z w ii := reduce_102111_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_102111_2 C A S x y z w ii hS + +noncomputable def poly_110002_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_110002_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_110002_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hy in +lemma reduce_110002_3 : + poly_110002_0 C A S x y z w ii = + poly_110002_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110002_2 C A S x y z w ii) * t) hy + dsimp only [poly_110002_0, poly_110002_1, poly_110002_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110002_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow ii 2) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))))) + +noncomputable def poly_110002_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) + +include hw in +lemma reduce_110002_4 : + poly_110002_1 C A S x y z w ii = + poly_110002_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110002_4 C A S x y z w ii) * t) hw + dsimp only [poly_110002_1, poly_110002_3, poly_110002_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110002_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_110002_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) + +include hi in +lemma reduce_110002_5 : + poly_110002_3 C A S x y z w ii = + poly_110002_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110002_6 C A S x y z w ii) * t) hi + dsimp only [poly_110002_3, poly_110002_5, poly_110002_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110002_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_110002_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_110002_0 : + poly_110002_5 C A S x y z w ii = + poly_110002_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110002_8 C A S x y z w ii) * t) hC + dsimp only [poly_110002_5, poly_110002_7, poly_110002_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110002_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_110002_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (w) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (S) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_110002_1 : + poly_110002_7 C A S x y z w ii = + poly_110002_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110002_10 C A S x y z w ii) * t) hA + dsimp only [poly_110002_7, poly_110002_9, poly_110002_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110002_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (y) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_110002_2 : + poly_110002_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_110002_11 C A S x y z w ii) * t) hS + dsimp only [poly_110002_9, poly_110002_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_110002 : poly_110002_0 C A S x y z w ii = 0 := by + calc + poly_110002_0 C A S x y z w ii = poly_110002_1 C A S x y z w ii := reduce_110002_3 C A S x y z w ii hy + _ = poly_110002_3 C A S x y z w ii := reduce_110002_4 C A S x y z w ii hw + _ = poly_110002_5 C A S x y z w ii := reduce_110002_5 C A S x y z w ii hi + _ = poly_110002_7 C A S x y z w ii := reduce_110002_0 C A S x y z w ii hC + _ = poly_110002_9 C A S x y z w ii := reduce_110002_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_110002_2 C A S x y z w ii hS + +noncomputable def poly_110011_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_110011_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul (complexPow w 4) (complexPow C 3)) (complexMul (complexPow S 3) (x)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 4) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_110011_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 4) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +include hy in +lemma reduce_110011_3 : + poly_110011_0 C A S x y z w ii = + poly_110011_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110011_2 C A S x y z w ii) * t) hy + dsimp only [poly_110011_0, poly_110011_1, poly_110011_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110011_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 3) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 3)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +noncomputable def poly_110011_4 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +include hw in +lemma reduce_110011_4 : + poly_110011_1 C A S x y z w ii = + poly_110011_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110011_4 C A S x y z w ii) * t) hw + dsimp only [poly_110011_1, poly_110011_3, poly_110011_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110011_5 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2)))))))) + +noncomputable def poly_110011_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))) + +include hi in +lemma reduce_110011_5 : + poly_110011_3 C A S x y z w ii = + poly_110011_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110011_6 C A S x y z w ii) * t) hi + dsimp only [poly_110011_3, poly_110011_5, poly_110011_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110011_7 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 2)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((56:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((24:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_110011_8 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hC in +lemma reduce_110011_0 : + poly_110011_5 C A S x y z w ii = + poly_110011_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110011_8 C A S x y z w ii) * t) hC + dsimp only [poly_110011_5, poly_110011_7, poly_110011_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110011_9 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((18:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-7:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((7:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-10:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_110011_10 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((56:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 2))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((12:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hA in +lemma reduce_110011_1 : + poly_110011_7 C A S x y z w ii = + poly_110011_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110011_10 C A S x y z w ii) * t) hA + dsimp only [poly_110011_7, poly_110011_9, poly_110011_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110011_11 (_C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (w)) (complexMul (A) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (x) (complexPow z 2)))))))) + +include hS in +lemma reduce_110011_2 : + poly_110011_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_110011_11 C A S x y z w ii) * t) hS + dsimp only [poly_110011_9, poly_110011_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_110011 : poly_110011_0 C A S x y z w ii = 0 := by + calc + poly_110011_0 C A S x y z w ii = poly_110011_1 C A S x y z w ii := reduce_110011_3 C A S x y z w ii hy + _ = poly_110011_3 C A S x y z w ii := reduce_110011_4 C A S x y z w ii hw + _ = poly_110011_5 C A S x y z w ii := reduce_110011_5 C A S x y z w ii hi + _ = poly_110011_7 C A S x y z w ii := reduce_110011_0 C A S x y z w ii hC + _ = poly_110011_9 C A S x y z w ii := reduce_110011_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_110011_2 C A S x y z w ii hS + +noncomputable def poly_110020_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_110020_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 3) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_110020_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) + +include hy in +lemma reduce_110020_3 : + poly_110020_0 C A S x y z w ii = + poly_110020_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110020_2 C A S x y z w ii) * t) hy + dsimp only [poly_110020_0, poly_110020_1, poly_110020_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110020_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))))) + +noncomputable def poly_110020_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 3))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 3) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) + +include hw in +lemma reduce_110020_4 : + poly_110020_1 C A S x y z w ii = + poly_110020_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110020_4 C A S x y z w ii) * t) hw + dsimp only [poly_110020_1, poly_110020_3, poly_110020_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110020_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_110020_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +include hi in +lemma reduce_110020_5 : + poly_110020_3 C A S x y z w ii = + poly_110020_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110020_6 C A S x y z w ii) * t) hi + dsimp only [poly_110020_3, poly_110020_5, poly_110020_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110020_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_110020_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) + +include hC in +lemma reduce_110020_0 : + poly_110020_5 C A S x y z w ii = + poly_110020_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110020_8 C A S x y z w ii) * t) hC + dsimp only [poly_110020_5, poly_110020_7, poly_110020_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110020_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_110020_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (ii) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_110020_1 : + poly_110020_7 C A S x y z w ii = + poly_110020_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_110020_10 C A S x y z w ii) * t) hA + dsimp only [poly_110020_7, poly_110020_9, poly_110020_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_110020_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (ii) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_110020_2 : + poly_110020_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_110020_11 C A S x y z w ii) * t) hS + dsimp only [poly_110020_9, poly_110020_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_110020 : poly_110020_0 C A S x y z w ii = 0 := by + calc + poly_110020_0 C A S x y z w ii = poly_110020_1 C A S x y z w ii := reduce_110020_3 C A S x y z w ii hy + _ = poly_110020_3 C A S x y z w ii := reduce_110020_4 C A S x y z w ii hw + _ = poly_110020_5 C A S x y z w ii := reduce_110020_5 C A S x y z w ii hi + _ = poly_110020_7 C A S x y z w ii := reduce_110020_0 C A S x y z w ii hC + _ = poly_110020_9 C A S x y z w ii := reduce_110020_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_110020_2 C A S x y z w ii hS + +noncomputable def poly_111012_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_111012_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (y) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_111012_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow C 2)) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) + +include hy in +lemma reduce_111012_3 : + poly_111012_0 C A S x y z w ii = + poly_111012_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111012_2 C A S x y z w ii) * t) hy + dsimp only [poly_111012_0, poly_111012_1, poly_111012_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111012_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_111012_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) + +include hw in +lemma reduce_111012_4 : + poly_111012_1 C A S x y z w ii = + poly_111012_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111012_4 C A S x y z w ii) * t) hw + dsimp only [poly_111012_1, poly_111012_3, poly_111012_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111012_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_111012_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_111012_0 : + poly_111012_3 C A S x y z w ii = + poly_111012_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111012_6 C A S x y z w ii) * t) hC + dsimp only [poly_111012_3, poly_111012_5, poly_111012_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111012_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow S 4)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_111012_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_111012_1 : + poly_111012_5 C A S x y z w ii = + poly_111012_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111012_8 C A S x y z w ii) * t) hA + dsimp only [poly_111012_5, poly_111012_7, poly_111012_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111012_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_111012_2 : + poly_111012_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_111012_9 C A S x y z w ii) * t) hS + dsimp only [poly_111012_7, poly_111012_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_111012 : poly_111012_0 C A S x y z w ii = 0 := by + calc + poly_111012_0 C A S x y z w ii = poly_111012_1 C A S x y z w ii := reduce_111012_3 C A S x y z w ii hy + _ = poly_111012_3 C A S x y z w ii := reduce_111012_4 C A S x y z w ii hw + _ = poly_111012_5 C A S x y z w ii := reduce_111012_0 C A S x y z w ii hC + _ = poly_111012_7 C A S x y z w ii := reduce_111012_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_111012_2 C A S x y z w ii hS + +noncomputable def poly_111021_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))))) + +noncomputable def poly_111021_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_111021_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hy in +lemma reduce_111021_3 : + poly_111021_0 C A S x y z w ii = + poly_111021_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111021_2 C A S x y z w ii) * t) hy + dsimp only [poly_111021_0, poly_111021_1, poly_111021_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111021_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))))) + +noncomputable def poly_111021_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) + +include hw in +lemma reduce_111021_4 : + poly_111021_1 C A S x y z w ii = + poly_111021_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111021_4 C A S x y z w ii) * t) hw + dsimp only [poly_111021_1, poly_111021_3, poly_111021_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111021_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_111021_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z))))))) + +include hi in +lemma reduce_111021_5 : + poly_111021_3 C A S x y z w ii = + poly_111021_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111021_6 C A S x y z w ii) * t) hi + dsimp only [poly_111021_3, poly_111021_5, poly_111021_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111021_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_111021_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_111021_0 : + poly_111021_5 C A S x y z w ii = + poly_111021_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111021_8 C A S x y z w ii) * t) hC + dsimp only [poly_111021_5, poly_111021_7, poly_111021_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111021_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexPow S 5)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 3) (z))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_111021_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (w) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 3) (z))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_111021_1 : + poly_111021_7 C A S x y z w ii = + poly_111021_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111021_10 C A S x y z w ii) * t) hA + dsimp only [poly_111021_7, poly_111021_9, poly_111021_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111021_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (y) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_111021_2 : + poly_111021_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_111021_11 C A S x y z w ii) * t) hS + dsimp only [poly_111021_9, poly_111021_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_111021 : poly_111021_0 C A S x y z w ii = 0 := by + calc + poly_111021_0 C A S x y z w ii = poly_111021_1 C A S x y z w ii := reduce_111021_3 C A S x y z w ii hy + _ = poly_111021_3 C A S x y z w ii := reduce_111021_4 C A S x y z w ii hw + _ = poly_111021_5 C A S x y z w ii := reduce_111021_5 C A S x y z w ii hi + _ = poly_111021_7 C A S x y z w ii := reduce_111021_0 C A S x y z w ii hC + _ = poly_111021_9 C A S x y z w ii := reduce_111021_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_111021_2 C A S x y z w ii hS + +noncomputable def poly_111102_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 4)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 4) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 3)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 3)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexPow w 2) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))))) + +noncomputable def poly_111102_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_111102_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))))) + +include hy in +lemma reduce_111102_3 : + poly_111102_0 C A S x y z w ii = + poly_111102_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111102_2 C A S x y z w ii) * t) hy + dsimp only [poly_111102_0, poly_111102_1, poly_111102_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111102_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_111102_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow ii 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))))))) + +include hw in +lemma reduce_111102_4 : + poly_111102_1 C A S x y z w ii = + poly_111102_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111102_4 C A S x y z w ii) * t) hw + dsimp only [poly_111102_1, poly_111102_3, poly_111102_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111102_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((3:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))))))))) + +noncomputable def poly_111102_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) + +include hi in +lemma reduce_111102_5 : + poly_111102_3 C A S x y z w ii = + poly_111102_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111102_6 C A S x y z w ii) * t) hi + dsimp only [poly_111102_3, poly_111102_5, poly_111102_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111102_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_111102_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (C) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-9:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexMul (complexMul (((-9:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (A) (S)) (complexMul (complexPow x 4) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 2) (z))))))))) + +include hC in +lemma reduce_111102_0 : + poly_111102_5 C A S x y z w ii = + poly_111102_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111102_8 C A S x y z w ii) * t) hC + dsimp only [poly_111102_5, poly_111102_7, poly_111102_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111102_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 5)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 4) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (complexPow x 4) (complexPow z 2))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (w) (complexMul (complexPow x 4) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 5)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((5:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((7:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (z))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexMul (S) (complexMul (complexPow x 4) (z))))) (complexAdd (complexAdd (complexMul (complexMul (((7:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-3:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +noncomputable def poly_111102_10 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (y) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 4) (complexPow z 2)))) (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((-8:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((4:ℂ)) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hA in +lemma reduce_111102_1 : + poly_111102_7 C A S x y z w ii = + poly_111102_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_111102_10 C A S x y z w ii) * t) hA + dsimp only [poly_111102_7, poly_111102_9, poly_111102_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_111102_11 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (y) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow x 4) (complexPow z 2)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul ((5:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 4) (z)))) (complexMul (complexMul (((-7:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((-4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (complexPow z 3)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul ((5:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul ((4:ℂ)) (S)) (complexMul (complexPow x 4) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 4) (z))) (complexMul (complexMul (((-7:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 2) (z))))))))) + +include hS in +lemma reduce_111102_2 : + poly_111102_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_111102_11 C A S x y z w ii) * t) hS + dsimp only [poly_111102_9, poly_111102_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_111102 : poly_111102_0 C A S x y z w ii = 0 := by + calc + poly_111102_0 C A S x y z w ii = poly_111102_1 C A S x y z w ii := reduce_111102_3 C A S x y z w ii hy + _ = poly_111102_3 C A S x y z w ii := reduce_111102_4 C A S x y z w ii hw + _ = poly_111102_5 C A S x y z w ii := reduce_111102_5 C A S x y z w ii hi + _ = poly_111102_7 C A S x y z w ii := reduce_111102_0 C A S x y z w ii hC + _ = poly_111102_9 C A S x y z w ii := reduce_111102_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_111102_2 C A S x y z w ii hS + +noncomputable def poly_112022_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_112022_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_112022_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))) + +include hy in +lemma reduce_112022_3 : + poly_112022_0 C A S x y z w ii = + poly_112022_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_112022_2 C A S x y z w ii) * t) hy + dsimp only [poly_112022_0, poly_112022_1, poly_112022_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_112022_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_112022_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (z))))))) + +include hw in +lemma reduce_112022_4 : + poly_112022_1 C A S x y z w ii = + poly_112022_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_112022_4 C A S x y z w ii) * t) hw + dsimp only [poly_112022_1, poly_112022_3, poly_112022_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_112022_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_112022_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +include hC in +lemma reduce_112022_0 : + poly_112022_3 C A S x y z w ii = + poly_112022_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_112022_6 C A S x y z w ii) * t) hC + dsimp only [poly_112022_3, poly_112022_5, poly_112022_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_112022_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow S 4)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_112022_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (S)) (complexMul (complexPow x 2) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (y) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_112022_1 : + poly_112022_5 C A S x y z w ii = + poly_112022_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_112022_8 C A S x y z w ii) * t) hA + dsimp only [poly_112022_5, poly_112022_7, poly_112022_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_112022_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (w) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 3))) (complexAdd (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (z))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_112022_2 : + poly_112022_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_112022_9 C A S x y z w ii) * t) hS + dsimp only [poly_112022_7, poly_112022_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_112022 : poly_112022_0 C A S x y z w ii = 0 := by + calc + poly_112022_0 C A S x y z w ii = poly_112022_1 C A S x y z w ii := reduce_112022_3 C A S x y z w ii hy + _ = poly_112022_3 C A S x y z w ii := reduce_112022_4 C A S x y z w ii hw + _ = poly_112022_5 C A S x y z w ii := reduce_112022_0 C A S x y z w ii hC + _ = poly_112022_7 C A S x y z w ii := reduce_112022_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_112022_2 C A S x y z w ii hS + +noncomputable def poly_120012_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (C)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +noncomputable def poly_120012_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow ii 2) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (C)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow w 2)) (complexMul (A) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_120012_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))) + +include hy in +lemma reduce_120012_3 : + poly_120012_0 C A S x y z w ii = + poly_120012_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120012_2 C A S x y z w ii) * t) hy + dsimp only [poly_120012_0, poly_120012_1, poly_120012_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120012_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow ii 2) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (C) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_120012_4 (C A S x y z _w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow ii 2)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z)))))) + +include hw in +lemma reduce_120012_4 : + poly_120012_1 C A S x y z w ii = + poly_120012_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120012_4 C A S x y z w ii) * t) hw + dsimp only [poly_120012_1, poly_120012_3, poly_120012_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120012_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_120012_6 (C A _S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (complexPow x 3) (z))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (x) (complexPow z 3))))) + +include hi in +lemma reduce_120012_5 : + poly_120012_3 C A S x y z w ii = + poly_120012_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120012_6 C A S x y z w ii) * t) hi + dsimp only [poly_120012_3, poly_120012_5, poly_120012_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120012_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) + +noncomputable def poly_120012_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow x 2) (complexPow z 3))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) + +include hC in +lemma reduce_120012_0 : + poly_120012_5 C A S x y z w ii = + poly_120012_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120012_8 C A S x y z w ii) * t) hC + dsimp only [poly_120012_5, poly_120012_7, poly_120012_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120012_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3))))))))) + +noncomputable def poly_120012_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) + +include hA in +lemma reduce_120012_1 : + poly_120012_7 C A S x y z w ii = + poly_120012_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120012_10 C A S x y z w ii) * t) hA + dsimp only [poly_120012_7, poly_120012_9, poly_120012_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120012_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (A) (complexMul (x) (complexPow z 3)))))))) + +include hS in +lemma reduce_120012_2 : + poly_120012_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_120012_11 C A S x y z w ii) * t) hS + dsimp only [poly_120012_9, poly_120012_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_120012 : poly_120012_0 C A S x y z w ii = 0 := by + calc + poly_120012_0 C A S x y z w ii = poly_120012_1 C A S x y z w ii := reduce_120012_3 C A S x y z w ii hy + _ = poly_120012_3 C A S x y z w ii := reduce_120012_4 C A S x y z w ii hw + _ = poly_120012_5 C A S x y z w ii := reduce_120012_5 C A S x y z w ii hi + _ = poly_120012_7 C A S x y z w ii := reduce_120012_0 C A S x y z w ii hC + _ = poly_120012_9 C A S x y z w ii := reduce_120012_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_120012_2 C A S x y z w ii hS + +noncomputable def poly_120021_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow w 4) (complexMul (complexPow C 3) (complexPow S 3)))) (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 3)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 3) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 3) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow y 3)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 3) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 3) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexPow y 3)) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow y 2) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (x))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (x) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (x)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (complexPow y 2) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexPow y 2)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexPow y 2) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow y 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow y 2) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow y 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (complexPow y 2) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow y 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow y 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul (y) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 4) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (complexPow x 3)))) (complexMul (complexMul (complexPow w 4) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow x 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))))))) + +noncomputable def poly_120021_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (y) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (complexMul (complexPow C 3) (complexPow S 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul (y) (complexPow w 3)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow w 4) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul ((-1:ℂ)) (complexPow w 4)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 4) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 4) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul (complexMul ((7:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexPow x 3))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-7:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_120021_2 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 4) (complexMul (complexPow C 3) (complexPow S 3)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexPow S 3))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexPow w 4) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))) (complexMul (complexMul (complexPow w 4) (complexPow C 3)) (complexMul (complexPow S 3) (x)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 4) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 3)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow w 3) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul (complexPow w 3) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (complexPow w 2)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (x))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul (complexPow w 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((6:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 3)) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hy in +lemma reduce_120021_3 : + poly_120021_0 C A S x y z w ii = + poly_120021_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120021_2 C A S x y z w ii) * t) hy + dsimp only [poly_120021_0, poly_120021_1, poly_120021_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120021_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow ii 2) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (C))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow ii 2) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (complexPow ii 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((7:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_120021_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexPow x 2)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow x 2))))) (complexAdd (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (complexMul (complexPow C 3) (complexPow S 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 3) (complexPow x 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 3) (complexPow x 2)))) (complexMul (complexMul (complexMul (y) (w)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow ii 2))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow ii 2))) (complexMul (complexMul (complexPow C 3) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (complexPow ii 2) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexPow w 2) (complexMul (ii) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 2) (x)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow w 2)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow x 3)))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexPow C 3)) (complexMul (complexPow S 3) (x))) (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (complexPow x 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (A) (complexMul (complexPow S 3) (x)))) (complexMul (complexMul (complexPow w 2) (C)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow x 3))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow ii 2) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow ii 2) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((7:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((5:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((3:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hw in +lemma reduce_120021_4 : + poly_120021_1 C A S x y z w ii = + poly_120021_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120021_4 C A S x y z w ii) * t) hw + dsimp only [poly_120021_1, poly_120021_3, poly_120021_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120021_5 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 3) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (complexMul ((-5:ℂ)) (y)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexMul ((-3:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (complexPow A 2)) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (C) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (complexPow S 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 3)) (complexMul (S) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow C 3)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (C) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow C 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((7:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_120021_6 (C A S x y z w _ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 3) (complexMul (S) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (C) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 3))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow C 2) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow C 2) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) + +include hi in +lemma reduce_120021_5 : + poly_120021_3 C A S x y z w ii = + poly_120021_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120021_6 C A S x y z w ii) * t) hi + dsimp only [poly_120021_3, poly_120021_5, poly_120021_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120021_7 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 3) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 6) (complexPow z 2)))) (complexMul (complexMul ((48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((20:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 3) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 5)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 3) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 6) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 3))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 3)) (complexMul (S) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 3))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((24:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexPow A 3)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexPow A 3)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 3)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +noncomputable def poly_120021_8 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow S 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (S) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (C)) (complexMul (A) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 5) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow A 2) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (complexPow S 2)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 4)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexPow A 2)) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((5:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (C) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((12:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexPow A 2)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-6:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))))))))) + +include hC in +lemma reduce_120021_0 : + poly_120021_5 C A S x y z w ii = + poly_120021_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120021_8 C A S x y z w ii) * t) hC + dsimp only [poly_120021_5, poly_120021_7, poly_120021_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120021_9 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((10:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (A) (complexMul (S) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 7) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-20:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-14:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((7:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((5:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 6)) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z))))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 7) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-7:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((5:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((14:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-10:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))))))))) + +noncomputable def poly_120021_10 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((24:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 4)))) (complexMul (complexMul ((16:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 6) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-48:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((24:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((20:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-10:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 5)) (complexMul (x) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((32:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 6) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((-48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((48:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-24:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((10:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((24:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((24:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-16:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hA in +lemma reduce_120021_1 : + poly_120021_7 C A S x y z w ii = + poly_120021_9 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_120021_10 C A S x y z w ii) * t) hA + dsimp only [poly_120021_7, poly_120021_9, poly_120021_10, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_120021_11 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((6:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((16:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (S) (complexPow z 2)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 4)))) (complexMul (complexMul ((-8:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 5) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 4) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 3) (complexPow z 2)))) (complexMul (complexMul ((12:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-10:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 4)))) (complexMul (complexMul ((5:ℂ)) (y)) (complexMul (A) (complexMul (complexPow S 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (A) (complexMul (S) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (A)) (complexMul (S) (complexPow z 2))) (complexAdd (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 4)) (complexMul (x) (z)))) (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-16:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 5) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 4) (complexMul (x) (z)))) (complexMul (complexMul ((-8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-6:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 3) (complexMul (x) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((12:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-5:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((4:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-12:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((8:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-6:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))))) + +include hS in +lemma reduce_120021_2 : + poly_120021_9 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_120021_11 C A S x y z w ii) * t) hS + dsimp only [poly_120021_9, poly_120021_11, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw hi in +lemma polynomial_120021 : poly_120021_0 C A S x y z w ii = 0 := by + calc + poly_120021_0 C A S x y z w ii = poly_120021_1 C A S x y z w ii := reduce_120021_3 C A S x y z w ii hy + _ = poly_120021_3 C A S x y z w ii := reduce_120021_4 C A S x y z w ii hw + _ = poly_120021_5 C A S x y z w ii := reduce_120021_5 C A S x y z w ii hi + _ = poly_120021_7 C A S x y z w ii := reduce_120021_0 C A S x y z w ii hC + _ = poly_120021_9 C A S x y z w ii := reduce_120021_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_120021_2 C A S x y z w ii hS + +noncomputable def poly_121022_0 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow w 2))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (w))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow y 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow y 2) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul (complexPow w 2) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))) (complexAdd (complexMul (complexMul (complexPow w 2) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))))))))) + +noncomputable def poly_121022_1 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 4))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 3))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (y) (complexMul (complexPow w 2) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (y) (complexPow w 2)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))) (complexMul (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 4) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (complexPow w 3) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexPow w 3) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 3)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow w 2)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_121022_2 (C A S x _y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 3) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) + +include hy in +lemma reduce_121022_3 : + poly_121022_0 C A S x y z w ii = + poly_121022_1 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_121022_2 C A S x y z w ii) * t) hy + dsimp only [poly_121022_0, poly_121022_1, poly_121022_2, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_121022_3 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (y) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow C 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (C)) (complexMul (A) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (C) (A))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul (C) (A)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))))) + +noncomputable def poly_121022_4 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexMul (ii) (complexPow C 2)) (complexMul (S) (complexPow x 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (complexPow w 2))) (complexMul (complexPow C 2) (complexMul (S) (complexPow x 2))))) (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (A)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (ii)) (complexMul (complexPow C 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (complexPow C 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (ii))) (complexMul (complexMul (C) (A)) (complexMul (S) (complexPow x 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (complexPow w 2) (C))) (complexMul (A) (complexMul (S) (complexPow x 3))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow C 2) (S)) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow C 2))) (complexMul (S) (complexMul (x) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow C 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow C 2))) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow C 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow C 2)) (complexMul (S) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (A) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))))))) + +include hw in +lemma reduce_121022_4 : + poly_121022_1 C A S x y z w ii = + poly_121022_3 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_121022_4 C A S x y z w ii) * t) hw + dsimp only [poly_121022_1, poly_121022_3, poly_121022_4, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_121022_5 (_C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow A 2) (complexMul (complexPow x 2) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (complexPow S 3)) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (complexPow A 2))) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow A 2)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow A 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-3:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (complexPow A 2) (complexPow S 2)) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (complexPow A 2) (S)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow A 2)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexPow A 2) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow A 2)) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_121022_6 (C A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (A)) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (y) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (complexMul (w) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (A) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul (y) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (y) (C)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (C))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (C) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (C)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (A))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (A) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (y) (A)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (C) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (C) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (C) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexMul (A) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexMul (A) (S)) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (A) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (C))) (complexMul (S) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (w) (C)) (complexMul (complexPow x 3) (complexPow z 3))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (C) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (w) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (A))) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (A)) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (A) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (ii) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (C))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (ii) (C))) (complexMul (S) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (ii) (A))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul (ii) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (ii) (A))) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (ii) (A)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (A) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (C) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (C)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (C)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (A)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (A) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (A) (S)) (complexMul (complexPow x 3) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (S) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul ((-2:ℂ)) (A)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (A)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (A) (complexMul (x) (complexPow z 4))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (A)) (complexMul (x) (complexPow z 2))))))))) + +include hC in +lemma reduce_121022_0 : + poly_121022_3 C A S x y z w ii = + poly_121022_5 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_121022_6 C A S x y z w ii) * t) hC + dsimp only [poly_121022_3, poly_121022_5, poly_121022_6, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_121022_7 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((3:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul (y) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 4) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4))))))) (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (y) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 4))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (w) (complexPow S 3)) (complexMul (x) (complexPow z 3))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))))) (complexAdd (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (S)) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (w)) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (ii) (complexPow S 4)) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 4) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexMul (complexMul ((3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul (((3:ℂ)/(4:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 4)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexPow S 4) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (complexPow S 4)) (complexMul (x) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-5:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(4:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(4:ℂ))) (S)) (complexMul (x) (complexPow z 2))) (complexMul ((-1:ℂ)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (((3:ℂ)/(4:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 4))) (complexMul (((-1:ℂ)/(4:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +noncomputable def poly_121022_8 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 3)) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 3)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((4:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (y) (w)) (complexMul (S) (complexMul (complexPow x 2) (z))))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z))))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (y)) (complexMul (complexPow S 3) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-1:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (x) (complexPow z 3))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (z)))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (w) (complexPow S 2)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z)))) (complexAdd (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((-4:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 3) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((4:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((-3:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2))))) (complexAdd (complexMul (complexMul (ii) (S)) (complexMul (x) (complexPow z 4))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (ii) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul ((-4:ℂ)) (complexPow S 3)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 3)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul ((4:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (complexMul ((-3:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2)))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul ((2:ℂ)) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (S) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (S)) (complexMul (x) (complexPow z 2))) (complexMul ((-2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (((3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2))) (complexAdd (complexMul (x) (complexPow z 4)) (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2))))))))) + +include hA in +lemma reduce_121022_1 : + poly_121022_5 C A S x y z w ii = + poly_121022_7 C A S x y z w ii := by + have hq := congrArg (fun t : ℂ => (poly_121022_8 C A S x y z w ii) * t) hA + dsimp only [poly_121022_5, poly_121022_7, poly_121022_8, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +noncomputable def poly_121022_9 (_C _A S x y z w ii : ℂ) : ℂ := + complexAdd (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (y) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (complexMul (ii) (S)) (complexMul (complexPow x 2) (z)))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (ii) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (w))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 3))))))) (complexAdd (complexAdd (complexMul (complexMul (y) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (z)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (complexMul (y) (w))) (complexMul (S) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (w) (complexMul (complexPow x 2) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (w) (complexMul (complexPow x 2) (z)))) (complexMul (complexMul ((-2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (y) (ii))) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (ii) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((-2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (complexPow S 2) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul ((2:ℂ)) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 4))))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (y)) (complexMul (S) (complexMul (complexPow x 2) (complexPow z 2)))) (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (y)) (complexMul (complexPow x 2) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (complexMul (w) (ii))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul ((-2:ℂ)) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (w) (ii))) (complexMul (S) (complexMul (complexPow x 3) (z))))) (complexAdd (complexMul (complexMul (w) (ii)) (complexMul (S) (complexMul (x) (complexPow z 3)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (ii) (complexMul (complexPow x 3) (z))))))))) (complexAdd (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul ((-1:ℂ)) (w)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (w)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 3)))) (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (S) (complexMul (complexPow x 3) (z)))) (complexMul (complexMul (w) (S)) (complexMul (x) (complexPow z 3)))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (w)) (complexMul (complexPow x 3) (z))) (complexAdd (complexMul (complexMul ((-2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 4)))) (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (complexPow x 3) (complexPow z 2)))))) (complexAdd (complexAdd (complexMul (complexMul (ii) (complexPow S 2)) (complexMul (x) (complexPow z 4))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 2))))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (complexPow x 3) (complexPow z 2)))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (S) (complexMul (x) (complexPow z 2)))))))) (complexAdd (complexAdd (complexAdd (complexMul (complexMul ((2:ℂ)) (ii)) (complexMul (complexPow x 3) (complexPow z 4))) (complexAdd (complexMul (complexMul (((-3:ℂ)/(2:ℂ))) (ii)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul ((-1:ℂ)) (ii)) (complexMul (x) (complexPow z 4))))) (complexAdd (complexAdd (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (ii)) (complexMul (x) (complexPow z 2))) (complexMul (complexMul ((-2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 4)))) (complexAdd (complexMul (complexMul ((2:ℂ)) (complexPow S 2)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexPow S 2) (complexMul (x) (complexPow z 4)))))) (complexAdd (complexAdd (complexMul (complexMul ((-1:ℂ)) (complexPow S 2)) (complexMul (x) (complexPow z 2))) (complexAdd (complexMul (complexMul (((-1:ℂ)/(2:ℂ))) (S)) (complexMul (complexPow x 3) (complexPow z 2))) (complexMul (complexMul (((1:ℂ)/(2:ℂ))) (S)) (complexMul (x) (complexPow z 2))))) (complexAdd (complexAdd (complexMul ((2:ℂ)) (complexMul (complexPow x 3) (complexPow z 4))) (complexMul (((-3:ℂ)/(2:ℂ))) (complexMul (complexPow x 3) (complexPow z 2)))) (complexAdd (complexMul ((-1:ℂ)) (complexMul (x) (complexPow z 4))) (complexMul (((1:ℂ)/(2:ℂ))) (complexMul (x) (complexPow z 2)))))))) + +include hS in +lemma reduce_121022_2 : + poly_121022_7 C A S x y z w ii = + (0:ℂ) := by + have hq := congrArg (fun t : ℂ => (poly_121022_9 C A S x y z w ii) * t) hS + dsimp only [poly_121022_7, poly_121022_9, complexAdd, complexMul, complexPow] at hq ⊢ + linear_combination hq + +include hC hA hS hy hw in +lemma polynomial_121022 : poly_121022_0 C A S x y z w ii = 0 := by + calc + poly_121022_0 C A S x y z w ii = poly_121022_1 C A S x y z w ii := reduce_121022_3 C A S x y z w ii hy + _ = poly_121022_3 C A S x y z w ii := reduce_121022_4 C A S x y z w ii hw + _ = poly_121022_5 C A S x y z w ii := reduce_121022_0 C A S x y z w ii hC + _ = poly_121022_7 C A S x y z w ii := reduce_121022_1 C A S x y z w ii hA + _ = (0:ℂ) := reduce_121022_2 C A S x y z w ii hS + +end Algebra +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPositive.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPositive.lean new file mode 100644 index 0000000000000000000000000000000000000000..507e81434f134666620137634246f1eb23c6e7c6 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterPositive.lean @@ -0,0 +1,1880 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterPolynomialsPositive +import OAI.Combinatorics.HoneycombChords.YangBaxterSupport +import Mathlib.Tactic.FinCases + +namespace OAI + +/-! Yang–Baxter components with first spin positive. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +section Algebra +variable (C A S x y z w ii : ℂ) +variable (hC : C = (2*S+1)*A) (hA : A^2 = (1-S)/2) + (hS : S^2 = 1/2) (hy : y^2+x^2=1) (hw : w^2+z^2=1) (hi : ii^2+1=0) + +include hy in +lemma component_001010 : + leftComponent C A S x y z w ii 0 0 1 0 1 0 = + rightComponent C A S x y z w ii 0 0 1 0 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001010 C A S x y z w ii hy + dsimp only [poly_001010_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_001100 : + leftComponent C A S x y z w ii 0 0 1 1 0 0 = + rightComponent C A S x y z w ii 0 0 1 1 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001100 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_001100_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_002011 : + leftComponent C A S x y z w ii 0 0 2 0 1 1 = + rightComponent C A S x y z w ii 0 0 2 0 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002011 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_002011_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_002020 : + leftComponent C A S x y z w ii 0 0 2 0 2 0 = + rightComponent C A S x y z w ii 0 0 2 0 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_002101 : + leftComponent C A S x y z w ii 0 0 2 1 0 1 = + rightComponent C A S x y z w ii 0 0 2 1 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002101 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_002101_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_002110 : + leftComponent C A S x y z w ii 0 0 2 1 1 0 = + rightComponent C A S x y z w ii 0 0 2 1 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002110_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_002200 : + leftComponent C A S x y z w ii 0 0 2 2 0 0 = + rightComponent C A S x y z w ii 0 0 2 2 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002200 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002200_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_011002 : + leftComponent C A S x y z w ii 0 1 1 0 0 2 = + rightComponent C A S x y z w ii 0 1 1 0 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011002 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_011002_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_011020 : + leftComponent C A S x y z w ii 0 1 1 0 2 0 = + rightComponent C A S x y z w ii 0 1 1 0 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011020_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_011101 : + leftComponent C A S x y z w ii 0 1 1 1 0 1 = + rightComponent C A S x y z w ii 0 1 1 1 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011101 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011101_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_011110 : + leftComponent C A S x y z w ii 0 1 1 1 1 0 = + rightComponent C A S x y z w ii 0 1 1 1 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011110_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_011200 : + leftComponent C A S x y z w ii 0 1 1 2 0 0 = + rightComponent C A S x y z w ii 0 1 1 2 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011200 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011200_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_012021 : + leftComponent C A S x y z w ii 0 1 2 0 2 1 = + rightComponent C A S x y z w ii 0 1 2 0 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012021_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_012102 : + leftComponent C A S x y z w ii 0 1 2 1 0 2 = + rightComponent C A S x y z w ii 0 1 2 1 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012102_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_012111 : + leftComponent C A S x y z w ii 0 1 2 1 1 1 = + rightComponent C A S x y z w ii 0 1 2 1 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012111 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_012111_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_012120 : + leftComponent C A S x y z w ii 0 1 2 1 2 0 = + rightComponent C A S x y z w ii 0 1 2 1 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012120 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012120_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_012201 : + leftComponent C A S x y z w ii 0 1 2 2 0 1 = + rightComponent C A S x y z w ii 0 1 2 2 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012201 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012201_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_020011 : + leftComponent C A S x y z w ii 0 2 0 0 1 1 = + rightComponent C A S x y z w ii 0 2 0 0 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020011 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020011_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_020020 : + leftComponent C A S x y z w ii 0 2 0 0 2 0 = + rightComponent C A S x y z w ii 0 2 0 0 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020020_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_020101 : + leftComponent C A S x y z w ii 0 2 0 1 0 1 = + rightComponent C A S x y z w ii 0 2 0 1 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020101 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020101_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_020110 : + leftComponent C A S x y z w ii 0 2 0 1 1 0 = + rightComponent C A S x y z w ii 0 2 0 1 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020110_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_021102 : + leftComponent C A S x y z w ii 0 2 1 1 0 2 = + rightComponent C A S x y z w ii 0 2 1 1 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021102_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_021111 : + leftComponent C A S x y z w ii 0 2 1 1 1 1 = + rightComponent C A S x y z w ii 0 2 1 1 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021111 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021111_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_021120 : + leftComponent C A S x y z w ii 0 2 1 1 2 0 = + rightComponent C A S x y z w ii 0 2 1 1 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021120 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021120_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_022112 : + leftComponent C A S x y z w ii 0 2 2 1 1 2 = + rightComponent C A S x y z w ii 0 2 2 1 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_022112 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_022112_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_022121 : + leftComponent C A S x y z w ii 0 2 2 1 2 1 = + rightComponent C A S x y z w ii 0 2 2 1 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_022121 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_022121_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hy in +lemma component_010001 : + leftComponent C A S x y z w ii 0 1 0 0 0 1 = + rightComponent C A S x y z w ii 0 1 0 0 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001010 C A S x y z w ii hy + dsimp only [poly_001010_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_020002 : + leftComponent C A S x y z w ii 0 2 0 0 0 2 = + rightComponent C A S x y z w ii 0 2 0 0 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_020200 : + leftComponent C A S x y z w ii 0 2 0 2 0 0 = + rightComponent C A S x y z w ii 0 2 0 2 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_021012 : + leftComponent C A S x y z w ii 0 2 1 0 1 2 = + rightComponent C A S x y z w ii 0 2 1 0 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012021_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_021210 : + leftComponent C A S x y z w ii 0 2 1 2 1 0 = + rightComponent C A S x y z w ii 0 2 1 2 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012201 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012201_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_022202 : + leftComponent C A S x y z w ii 0 2 2 2 0 2 = + rightComponent C A S x y z w ii 0 2 2 2 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002020_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_022211 : + leftComponent C A S x y z w ii 0 2 2 2 1 1 = + rightComponent C A S x y z w ii 0 2 2 2 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011200 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011200_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_022220 : + leftComponent C A S x y z w ii 0 2 2 2 2 0 = + rightComponent C A S x y z w ii 0 2 2 2 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002200 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002200_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +lemma component_000000 : + leftComponent C A S x y z w ii 0 0 0 0 0 0 = + rightComponent C A S x y z w ii 0 0 0 0 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, add_zero] + ; ring + +lemma component_000001 : + leftComponent C A S x y z w ii 0 0 0 0 0 1 = + rightComponent C A S x y z w ii 0 0 0 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 0 1 (by decide)] + +lemma component_000002 : + leftComponent C A S x y z w ii 0 0 0 0 0 2 = + rightComponent C A S x y z w ii 0 0 0 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 0 2 (by decide)] + +lemma component_000010 : + leftComponent C A S x y z w ii 0 0 0 0 1 0 = + rightComponent C A S x y z w ii 0 0 0 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 1 0 (by decide)] + +lemma component_000011 : + leftComponent C A S x y z w ii 0 0 0 0 1 1 = + rightComponent C A S x y z w ii 0 0 0 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 1 1 (by decide)] + +lemma component_000012 : + leftComponent C A S x y z w ii 0 0 0 0 1 2 = + rightComponent C A S x y z w ii 0 0 0 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 1 2 (by decide)] + +lemma component_000020 : + leftComponent C A S x y z w ii 0 0 0 0 2 0 = + rightComponent C A S x y z w ii 0 0 0 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 2 0 (by decide)] + +lemma component_000021 : + leftComponent C A S x y z w ii 0 0 0 0 2 1 = + rightComponent C A S x y z w ii 0 0 0 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 2 1 (by decide)] + +lemma component_000022 : + leftComponent C A S x y z w ii 0 0 0 0 2 2 = + rightComponent C A S x y z w ii 0 0 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 0 2 2 (by decide)] + +lemma component_000100 : + leftComponent C A S x y z w ii 0 0 0 1 0 0 = + rightComponent C A S x y z w ii 0 0 0 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 0 0 (by decide)] + +lemma component_000101 : + leftComponent C A S x y z w ii 0 0 0 1 0 1 = + rightComponent C A S x y z w ii 0 0 0 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 0 1 (by decide)] + +lemma component_000102 : + leftComponent C A S x y z w ii 0 0 0 1 0 2 = + rightComponent C A S x y z w ii 0 0 0 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 0 2 (by decide)] + +lemma component_000110 : + leftComponent C A S x y z w ii 0 0 0 1 1 0 = + rightComponent C A S x y z w ii 0 0 0 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 1 0 (by decide)] + +lemma component_000111 : + leftComponent C A S x y z w ii 0 0 0 1 1 1 = + rightComponent C A S x y z w ii 0 0 0 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 1 1 (by decide)] + +lemma component_000112 : + leftComponent C A S x y z w ii 0 0 0 1 1 2 = + rightComponent C A S x y z w ii 0 0 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 1 2 (by decide)] + +lemma component_000120 : + leftComponent C A S x y z w ii 0 0 0 1 2 0 = + rightComponent C A S x y z w ii 0 0 0 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 2 0 (by decide)] + +lemma component_000121 : + leftComponent C A S x y z w ii 0 0 0 1 2 1 = + rightComponent C A S x y z w ii 0 0 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 2 1 (by decide)] + +lemma component_000122 : + leftComponent C A S x y z w ii 0 0 0 1 2 2 = + rightComponent C A S x y z w ii 0 0 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 1 2 2 (by decide)] + +lemma component_000200 : + leftComponent C A S x y z w ii 0 0 0 2 0 0 = + rightComponent C A S x y z w ii 0 0 0 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 0 0 (by decide)] + +lemma component_000201 : + leftComponent C A S x y z w ii 0 0 0 2 0 1 = + rightComponent C A S x y z w ii 0 0 0 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 0 1 (by decide)] + +lemma component_000202 : + leftComponent C A S x y z w ii 0 0 0 2 0 2 = + rightComponent C A S x y z w ii 0 0 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 0 2 (by decide)] + +lemma component_000210 : + leftComponent C A S x y z w ii 0 0 0 2 1 0 = + rightComponent C A S x y z w ii 0 0 0 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 1 0 (by decide)] + +lemma component_000211 : + leftComponent C A S x y z w ii 0 0 0 2 1 1 = + rightComponent C A S x y z w ii 0 0 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 1 1 (by decide)] + +lemma component_000212 : + leftComponent C A S x y z w ii 0 0 0 2 1 2 = + rightComponent C A S x y z w ii 0 0 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 1 2 (by decide)] + +lemma component_000220 : + leftComponent C A S x y z w ii 0 0 0 2 2 0 = + rightComponent C A S x y z w ii 0 0 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 2 0 (by decide)] + +lemma component_000221 : + leftComponent C A S x y z w ii 0 0 0 2 2 1 = + rightComponent C A S x y z w ii 0 0 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 2 1 (by decide)] + +lemma component_000222 : + leftComponent C A S x y z w ii 0 0 0 2 2 2 = + rightComponent C A S x y z w ii 0 0 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 0 2 2 2 (by decide)] + +lemma component_001000 : + leftComponent C A S x y z w ii 0 0 1 0 0 0 = + rightComponent C A S x y z w ii 0 0 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 0 0 (by decide)] + +lemma component_001001 : + leftComponent C A S x y z w ii 0 0 1 0 0 1 = + rightComponent C A S x y z w ii 0 0 1 0 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_001002 : + leftComponent C A S x y z w ii 0 0 1 0 0 2 = + rightComponent C A S x y z w ii 0 0 1 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 0 2 (by decide)] + +lemma component_001011 : + leftComponent C A S x y z w ii 0 0 1 0 1 1 = + rightComponent C A S x y z w ii 0 0 1 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 1 1 (by decide)] + +lemma component_001012 : + leftComponent C A S x y z w ii 0 0 1 0 1 2 = + rightComponent C A S x y z w ii 0 0 1 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 1 2 (by decide)] + +lemma component_001020 : + leftComponent C A S x y z w ii 0 0 1 0 2 0 = + rightComponent C A S x y z w ii 0 0 1 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 2 0 (by decide)] + +lemma component_001021 : + leftComponent C A S x y z w ii 0 0 1 0 2 1 = + rightComponent C A S x y z w ii 0 0 1 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 2 1 (by decide)] + +lemma component_001022 : + leftComponent C A S x y z w ii 0 0 1 0 2 2 = + rightComponent C A S x y z w ii 0 0 1 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 0 2 2 (by decide)] + +lemma component_001101 : + leftComponent C A S x y z w ii 0 0 1 1 0 1 = + rightComponent C A S x y z w ii 0 0 1 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 0 1 (by decide)] + +lemma component_001102 : + leftComponent C A S x y z w ii 0 0 1 1 0 2 = + rightComponent C A S x y z w ii 0 0 1 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 0 2 (by decide)] + +lemma component_001110 : + leftComponent C A S x y z w ii 0 0 1 1 1 0 = + rightComponent C A S x y z w ii 0 0 1 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 1 0 (by decide)] + +lemma component_001111 : + leftComponent C A S x y z w ii 0 0 1 1 1 1 = + rightComponent C A S x y z w ii 0 0 1 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 1 1 (by decide)] + +lemma component_001112 : + leftComponent C A S x y z w ii 0 0 1 1 1 2 = + rightComponent C A S x y z w ii 0 0 1 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 1 2 (by decide)] + +lemma component_001120 : + leftComponent C A S x y z w ii 0 0 1 1 2 0 = + rightComponent C A S x y z w ii 0 0 1 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 2 0 (by decide)] + +lemma component_001121 : + leftComponent C A S x y z w ii 0 0 1 1 2 1 = + rightComponent C A S x y z w ii 0 0 1 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 2 1 (by decide)] + +lemma component_001122 : + leftComponent C A S x y z w ii 0 0 1 1 2 2 = + rightComponent C A S x y z w ii 0 0 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 1 2 2 (by decide)] + +lemma component_001200 : + leftComponent C A S x y z w ii 0 0 1 2 0 0 = + rightComponent C A S x y z w ii 0 0 1 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 0 0 (by decide)] + +lemma component_001201 : + leftComponent C A S x y z w ii 0 0 1 2 0 1 = + rightComponent C A S x y z w ii 0 0 1 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 0 1 (by decide)] + +lemma component_001202 : + leftComponent C A S x y z w ii 0 0 1 2 0 2 = + rightComponent C A S x y z w ii 0 0 1 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 0 2 (by decide)] + +lemma component_001210 : + leftComponent C A S x y z w ii 0 0 1 2 1 0 = + rightComponent C A S x y z w ii 0 0 1 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 1 0 (by decide)] + +lemma component_001211 : + leftComponent C A S x y z w ii 0 0 1 2 1 1 = + rightComponent C A S x y z w ii 0 0 1 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 1 1 (by decide)] + +lemma component_001212 : + leftComponent C A S x y z w ii 0 0 1 2 1 2 = + rightComponent C A S x y z w ii 0 0 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 1 2 (by decide)] + +lemma component_001220 : + leftComponent C A S x y z w ii 0 0 1 2 2 0 = + rightComponent C A S x y z w ii 0 0 1 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 2 0 (by decide)] + +lemma component_001221 : + leftComponent C A S x y z w ii 0 0 1 2 2 1 = + rightComponent C A S x y z w ii 0 0 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 2 1 (by decide)] + +lemma component_001222 : + leftComponent C A S x y z w ii 0 0 1 2 2 2 = + rightComponent C A S x y z w ii 0 0 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 1 2 2 2 (by decide)] + +lemma component_002000 : + leftComponent C A S x y z w ii 0 0 2 0 0 0 = + rightComponent C A S x y z w ii 0 0 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 0 0 (by decide)] + +lemma component_002001 : + leftComponent C A S x y z w ii 0 0 2 0 0 1 = + rightComponent C A S x y z w ii 0 0 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 0 1 (by decide)] + +lemma component_002002 : + leftComponent C A S x y z w ii 0 0 2 0 0 2 = + rightComponent C A S x y z w ii 0 0 2 0 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_002010 : + leftComponent C A S x y z w ii 0 0 2 0 1 0 = + rightComponent C A S x y z w ii 0 0 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 1 0 (by decide)] + +lemma component_002012 : + leftComponent C A S x y z w ii 0 0 2 0 1 2 = + rightComponent C A S x y z w ii 0 0 2 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 1 2 (by decide)] + +lemma component_002021 : + leftComponent C A S x y z w ii 0 0 2 0 2 1 = + rightComponent C A S x y z w ii 0 0 2 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 2 1 (by decide)] + +lemma component_002022 : + leftComponent C A S x y z w ii 0 0 2 0 2 2 = + rightComponent C A S x y z w ii 0 0 2 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 0 2 2 (by decide)] + +lemma component_002100 : + leftComponent C A S x y z w ii 0 0 2 1 0 0 = + rightComponent C A S x y z w ii 0 0 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 0 0 (by decide)] + +lemma component_002102 : + leftComponent C A S x y z w ii 0 0 2 1 0 2 = + rightComponent C A S x y z w ii 0 0 2 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 0 2 (by decide)] + +lemma component_002111 : + leftComponent C A S x y z w ii 0 0 2 1 1 1 = + rightComponent C A S x y z w ii 0 0 2 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 1 1 (by decide)] + +lemma component_002112 : + leftComponent C A S x y z w ii 0 0 2 1 1 2 = + rightComponent C A S x y z w ii 0 0 2 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 1 2 (by decide)] + +lemma component_002120 : + leftComponent C A S x y z w ii 0 0 2 1 2 0 = + rightComponent C A S x y z w ii 0 0 2 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 2 0 (by decide)] + +lemma component_002121 : + leftComponent C A S x y z w ii 0 0 2 1 2 1 = + rightComponent C A S x y z w ii 0 0 2 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 2 1 (by decide)] + +lemma component_002122 : + leftComponent C A S x y z w ii 0 0 2 1 2 2 = + rightComponent C A S x y z w ii 0 0 2 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 1 2 2 (by decide)] + +lemma component_002201 : + leftComponent C A S x y z w ii 0 0 2 2 0 1 = + rightComponent C A S x y z w ii 0 0 2 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 0 1 (by decide)] + +lemma component_002202 : + leftComponent C A S x y z w ii 0 0 2 2 0 2 = + rightComponent C A S x y z w ii 0 0 2 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 0 2 (by decide)] + +lemma component_002210 : + leftComponent C A S x y z w ii 0 0 2 2 1 0 = + rightComponent C A S x y z w ii 0 0 2 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 1 0 (by decide)] + +lemma component_002211 : + leftComponent C A S x y z w ii 0 0 2 2 1 1 = + rightComponent C A S x y z w ii 0 0 2 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 1 1 (by decide)] + +lemma component_002212 : + leftComponent C A S x y z w ii 0 0 2 2 1 2 = + rightComponent C A S x y z w ii 0 0 2 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 1 2 (by decide)] + +lemma component_002220 : + leftComponent C A S x y z w ii 0 0 2 2 2 0 = + rightComponent C A S x y z w ii 0 0 2 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 2 0 (by decide)] + +lemma component_002221 : + leftComponent C A S x y z w ii 0 0 2 2 2 1 = + rightComponent C A S x y z w ii 0 0 2 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 2 1 (by decide)] + +lemma component_002222 : + leftComponent C A S x y z w ii 0 0 2 2 2 2 = + rightComponent C A S x y z w ii 0 0 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 0 2 2 2 2 (by decide)] + +lemma component_010000 : + leftComponent C A S x y z w ii 0 1 0 0 0 0 = + rightComponent C A S x y z w ii 0 1 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 0 0 (by decide)] + +lemma component_010002 : + leftComponent C A S x y z w ii 0 1 0 0 0 2 = + rightComponent C A S x y z w ii 0 1 0 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 0 2 (by decide)] + +lemma component_010010 : + leftComponent C A S x y z w ii 0 1 0 0 1 0 = + rightComponent C A S x y z w ii 0 1 0 0 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_010011 : + leftComponent C A S x y z w ii 0 1 0 0 1 1 = + rightComponent C A S x y z w ii 0 1 0 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 1 1 (by decide)] + +lemma component_010012 : + leftComponent C A S x y z w ii 0 1 0 0 1 2 = + rightComponent C A S x y z w ii 0 1 0 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 1 2 (by decide)] + +lemma component_010020 : + leftComponent C A S x y z w ii 0 1 0 0 2 0 = + rightComponent C A S x y z w ii 0 1 0 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 2 0 (by decide)] + +lemma component_010021 : + leftComponent C A S x y z w ii 0 1 0 0 2 1 = + rightComponent C A S x y z w ii 0 1 0 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 2 1 (by decide)] + +lemma component_010022 : + leftComponent C A S x y z w ii 0 1 0 0 2 2 = + rightComponent C A S x y z w ii 0 1 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 0 2 2 (by decide)] + +lemma component_010100 : + leftComponent C A S x y z w ii 0 1 0 1 0 0 = + rightComponent C A S x y z w ii 0 1 0 1 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_010101 : + leftComponent C A S x y z w ii 0 1 0 1 0 1 = + rightComponent C A S x y z w ii 0 1 0 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 0 1 (by decide)] + +lemma component_010102 : + leftComponent C A S x y z w ii 0 1 0 1 0 2 = + rightComponent C A S x y z w ii 0 1 0 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 0 2 (by decide)] + +lemma component_010110 : + leftComponent C A S x y z w ii 0 1 0 1 1 0 = + rightComponent C A S x y z w ii 0 1 0 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 1 0 (by decide)] + +lemma component_010111 : + leftComponent C A S x y z w ii 0 1 0 1 1 1 = + rightComponent C A S x y z w ii 0 1 0 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 1 1 (by decide)] + +lemma component_010112 : + leftComponent C A S x y z w ii 0 1 0 1 1 2 = + rightComponent C A S x y z w ii 0 1 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 1 2 (by decide)] + +lemma component_010120 : + leftComponent C A S x y z w ii 0 1 0 1 2 0 = + rightComponent C A S x y z w ii 0 1 0 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 2 0 (by decide)] + +lemma component_010121 : + leftComponent C A S x y z w ii 0 1 0 1 2 1 = + rightComponent C A S x y z w ii 0 1 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 2 1 (by decide)] + +lemma component_010122 : + leftComponent C A S x y z w ii 0 1 0 1 2 2 = + rightComponent C A S x y z w ii 0 1 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 1 2 2 (by decide)] + +lemma component_010200 : + leftComponent C A S x y z w ii 0 1 0 2 0 0 = + rightComponent C A S x y z w ii 0 1 0 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 0 0 (by decide)] + +lemma component_010201 : + leftComponent C A S x y z w ii 0 1 0 2 0 1 = + rightComponent C A S x y z w ii 0 1 0 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 0 1 (by decide)] + +lemma component_010202 : + leftComponent C A S x y z w ii 0 1 0 2 0 2 = + rightComponent C A S x y z w ii 0 1 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 0 2 (by decide)] + +lemma component_010210 : + leftComponent C A S x y z w ii 0 1 0 2 1 0 = + rightComponent C A S x y z w ii 0 1 0 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 1 0 (by decide)] + +lemma component_010211 : + leftComponent C A S x y z w ii 0 1 0 2 1 1 = + rightComponent C A S x y z w ii 0 1 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 1 1 (by decide)] + +lemma component_010212 : + leftComponent C A S x y z w ii 0 1 0 2 1 2 = + rightComponent C A S x y z w ii 0 1 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 1 2 (by decide)] + +lemma component_010220 : + leftComponent C A S x y z w ii 0 1 0 2 2 0 = + rightComponent C A S x y z w ii 0 1 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 2 0 (by decide)] + +lemma component_010221 : + leftComponent C A S x y z w ii 0 1 0 2 2 1 = + rightComponent C A S x y z w ii 0 1 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 2 1 (by decide)] + +lemma component_010222 : + leftComponent C A S x y z w ii 0 1 0 2 2 2 = + rightComponent C A S x y z w ii 0 1 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 0 2 2 2 (by decide)] + +lemma component_011000 : + leftComponent C A S x y z w ii 0 1 1 0 0 0 = + rightComponent C A S x y z w ii 0 1 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 0 0 (by decide)] + +lemma component_011001 : + leftComponent C A S x y z w ii 0 1 1 0 0 1 = + rightComponent C A S x y z w ii 0 1 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 0 1 (by decide)] + +lemma component_011010 : + leftComponent C A S x y z w ii 0 1 1 0 1 0 = + rightComponent C A S x y z w ii 0 1 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 1 0 (by decide)] + +lemma component_011011 : + leftComponent C A S x y z w ii 0 1 1 0 1 1 = + rightComponent C A S x y z w ii 0 1 1 0 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_011012 : + leftComponent C A S x y z w ii 0 1 1 0 1 2 = + rightComponent C A S x y z w ii 0 1 1 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 1 2 (by decide)] + +lemma component_011021 : + leftComponent C A S x y z w ii 0 1 1 0 2 1 = + rightComponent C A S x y z w ii 0 1 1 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 2 1 (by decide)] + +lemma component_011022 : + leftComponent C A S x y z w ii 0 1 1 0 2 2 = + rightComponent C A S x y z w ii 0 1 1 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 0 2 2 (by decide)] + +lemma component_011100 : + leftComponent C A S x y z w ii 0 1 1 1 0 0 = + rightComponent C A S x y z w ii 0 1 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 0 0 (by decide)] + +lemma component_011102 : + leftComponent C A S x y z w ii 0 1 1 1 0 2 = + rightComponent C A S x y z w ii 0 1 1 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 0 2 (by decide)] + +lemma component_011111 : + leftComponent C A S x y z w ii 0 1 1 1 1 1 = + rightComponent C A S x y z w ii 0 1 1 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 1 1 (by decide)] + +lemma component_011112 : + leftComponent C A S x y z w ii 0 1 1 1 1 2 = + rightComponent C A S x y z w ii 0 1 1 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 1 2 (by decide)] + +lemma component_011120 : + leftComponent C A S x y z w ii 0 1 1 1 2 0 = + rightComponent C A S x y z w ii 0 1 1 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 2 0 (by decide)] + +lemma component_011121 : + leftComponent C A S x y z w ii 0 1 1 1 2 1 = + rightComponent C A S x y z w ii 0 1 1 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 2 1 (by decide)] + +lemma component_011122 : + leftComponent C A S x y z w ii 0 1 1 1 2 2 = + rightComponent C A S x y z w ii 0 1 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 1 2 2 (by decide)] + +lemma component_011201 : + leftComponent C A S x y z w ii 0 1 1 2 0 1 = + rightComponent C A S x y z w ii 0 1 1 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 0 1 (by decide)] + +lemma component_011202 : + leftComponent C A S x y z w ii 0 1 1 2 0 2 = + rightComponent C A S x y z w ii 0 1 1 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 0 2 (by decide)] + +lemma component_011210 : + leftComponent C A S x y z w ii 0 1 1 2 1 0 = + rightComponent C A S x y z w ii 0 1 1 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 1 0 (by decide)] + +lemma component_011211 : + leftComponent C A S x y z w ii 0 1 1 2 1 1 = + rightComponent C A S x y z w ii 0 1 1 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 1 1 (by decide)] + +lemma component_011212 : + leftComponent C A S x y z w ii 0 1 1 2 1 2 = + rightComponent C A S x y z w ii 0 1 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 1 2 (by decide)] + +lemma component_011220 : + leftComponent C A S x y z w ii 0 1 1 2 2 0 = + rightComponent C A S x y z w ii 0 1 1 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 2 0 (by decide)] + +lemma component_011221 : + leftComponent C A S x y z w ii 0 1 1 2 2 1 = + rightComponent C A S x y z w ii 0 1 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 2 1 (by decide)] + +lemma component_011222 : + leftComponent C A S x y z w ii 0 1 1 2 2 2 = + rightComponent C A S x y z w ii 0 1 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 1 2 2 2 (by decide)] + +lemma component_012000 : + leftComponent C A S x y z w ii 0 1 2 0 0 0 = + rightComponent C A S x y z w ii 0 1 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 0 0 (by decide)] + +lemma component_012001 : + leftComponent C A S x y z w ii 0 1 2 0 0 1 = + rightComponent C A S x y z w ii 0 1 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 0 1 (by decide)] + +lemma component_012002 : + leftComponent C A S x y z w ii 0 1 2 0 0 2 = + rightComponent C A S x y z w ii 0 1 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 0 2 (by decide)] + +lemma component_012010 : + leftComponent C A S x y z w ii 0 1 2 0 1 0 = + rightComponent C A S x y z w ii 0 1 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 1 0 (by decide)] + +lemma component_012011 : + leftComponent C A S x y z w ii 0 1 2 0 1 1 = + rightComponent C A S x y z w ii 0 1 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 1 1 (by decide)] + +lemma component_012012 : + leftComponent C A S x y z w ii 0 1 2 0 1 2 = + rightComponent C A S x y z w ii 0 1 2 0 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_012020 : + leftComponent C A S x y z w ii 0 1 2 0 2 0 = + rightComponent C A S x y z w ii 0 1 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 2 0 (by decide)] + +lemma component_012022 : + leftComponent C A S x y z w ii 0 1 2 0 2 2 = + rightComponent C A S x y z w ii 0 1 2 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 0 2 2 (by decide)] + +lemma component_012100 : + leftComponent C A S x y z w ii 0 1 2 1 0 0 = + rightComponent C A S x y z w ii 0 1 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 0 0 (by decide)] + +lemma component_012101 : + leftComponent C A S x y z w ii 0 1 2 1 0 1 = + rightComponent C A S x y z w ii 0 1 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 0 1 (by decide)] + +lemma component_012110 : + leftComponent C A S x y z w ii 0 1 2 1 1 0 = + rightComponent C A S x y z w ii 0 1 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 1 0 (by decide)] + +lemma component_012112 : + leftComponent C A S x y z w ii 0 1 2 1 1 2 = + rightComponent C A S x y z w ii 0 1 2 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 1 2 (by decide)] + +lemma component_012121 : + leftComponent C A S x y z w ii 0 1 2 1 2 1 = + rightComponent C A S x y z w ii 0 1 2 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 2 1 (by decide)] + +lemma component_012122 : + leftComponent C A S x y z w ii 0 1 2 1 2 2 = + rightComponent C A S x y z w ii 0 1 2 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 1 2 2 (by decide)] + +lemma component_012200 : + leftComponent C A S x y z w ii 0 1 2 2 0 0 = + rightComponent C A S x y z w ii 0 1 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 0 0 (by decide)] + +lemma component_012202 : + leftComponent C A S x y z w ii 0 1 2 2 0 2 = + rightComponent C A S x y z w ii 0 1 2 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 0 2 (by decide)] + +lemma component_012210 : + leftComponent C A S x y z w ii 0 1 2 2 1 0 = + rightComponent C A S x y z w ii 0 1 2 2 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_012211 : + leftComponent C A S x y z w ii 0 1 2 2 1 1 = + rightComponent C A S x y z w ii 0 1 2 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 1 1 (by decide)] + +lemma component_012212 : + leftComponent C A S x y z w ii 0 1 2 2 1 2 = + rightComponent C A S x y z w ii 0 1 2 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 1 2 (by decide)] + +lemma component_012220 : + leftComponent C A S x y z w ii 0 1 2 2 2 0 = + rightComponent C A S x y z w ii 0 1 2 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 2 0 (by decide)] + +lemma component_012221 : + leftComponent C A S x y z w ii 0 1 2 2 2 1 = + rightComponent C A S x y z w ii 0 1 2 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 2 1 (by decide)] + +lemma component_012222 : + leftComponent C A S x y z w ii 0 1 2 2 2 2 = + rightComponent C A S x y z w ii 0 1 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 1 2 2 2 2 (by decide)] + +lemma component_020000 : + leftComponent C A S x y z w ii 0 2 0 0 0 0 = + rightComponent C A S x y z w ii 0 2 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 0 0 (by decide)] + +lemma component_020001 : + leftComponent C A S x y z w ii 0 2 0 0 0 1 = + rightComponent C A S x y z w ii 0 2 0 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 0 1 (by decide)] + +lemma component_020010 : + leftComponent C A S x y z w ii 0 2 0 0 1 0 = + rightComponent C A S x y z w ii 0 2 0 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 1 0 (by decide)] + +lemma component_020012 : + leftComponent C A S x y z w ii 0 2 0 0 1 2 = + rightComponent C A S x y z w ii 0 2 0 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 1 2 (by decide)] + +lemma component_020021 : + leftComponent C A S x y z w ii 0 2 0 0 2 1 = + rightComponent C A S x y z w ii 0 2 0 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 2 1 (by decide)] + +lemma component_020022 : + leftComponent C A S x y z w ii 0 2 0 0 2 2 = + rightComponent C A S x y z w ii 0 2 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 0 2 2 (by decide)] + +lemma component_020100 : + leftComponent C A S x y z w ii 0 2 0 1 0 0 = + rightComponent C A S x y z w ii 0 2 0 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 0 0 (by decide)] + +lemma component_020102 : + leftComponent C A S x y z w ii 0 2 0 1 0 2 = + rightComponent C A S x y z w ii 0 2 0 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 0 2 (by decide)] + +lemma component_020111 : + leftComponent C A S x y z w ii 0 2 0 1 1 1 = + rightComponent C A S x y z w ii 0 2 0 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 1 1 (by decide)] + +lemma component_020112 : + leftComponent C A S x y z w ii 0 2 0 1 1 2 = + rightComponent C A S x y z w ii 0 2 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 1 2 (by decide)] + +lemma component_020120 : + leftComponent C A S x y z w ii 0 2 0 1 2 0 = + rightComponent C A S x y z w ii 0 2 0 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 2 0 (by decide)] + +lemma component_020121 : + leftComponent C A S x y z w ii 0 2 0 1 2 1 = + rightComponent C A S x y z w ii 0 2 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 2 1 (by decide)] + +lemma component_020122 : + leftComponent C A S x y z w ii 0 2 0 1 2 2 = + rightComponent C A S x y z w ii 0 2 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 1 2 2 (by decide)] + +lemma component_020201 : + leftComponent C A S x y z w ii 0 2 0 2 0 1 = + rightComponent C A S x y z w ii 0 2 0 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 0 1 (by decide)] + +lemma component_020202 : + leftComponent C A S x y z w ii 0 2 0 2 0 2 = + rightComponent C A S x y z w ii 0 2 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 0 2 (by decide)] + +lemma component_020210 : + leftComponent C A S x y z w ii 0 2 0 2 1 0 = + rightComponent C A S x y z w ii 0 2 0 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 1 0 (by decide)] + +lemma component_020211 : + leftComponent C A S x y z w ii 0 2 0 2 1 1 = + rightComponent C A S x y z w ii 0 2 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 1 1 (by decide)] + +lemma component_020212 : + leftComponent C A S x y z w ii 0 2 0 2 1 2 = + rightComponent C A S x y z w ii 0 2 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 1 2 (by decide)] + +lemma component_020220 : + leftComponent C A S x y z w ii 0 2 0 2 2 0 = + rightComponent C A S x y z w ii 0 2 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 2 0 (by decide)] + +lemma component_020221 : + leftComponent C A S x y z w ii 0 2 0 2 2 1 = + rightComponent C A S x y z w ii 0 2 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 2 1 (by decide)] + +lemma component_020222 : + leftComponent C A S x y z w ii 0 2 0 2 2 2 = + rightComponent C A S x y z w ii 0 2 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 0 2 2 2 (by decide)] + +lemma component_021000 : + leftComponent C A S x y z w ii 0 2 1 0 0 0 = + rightComponent C A S x y z w ii 0 2 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 0 0 (by decide)] + +lemma component_021001 : + leftComponent C A S x y z w ii 0 2 1 0 0 1 = + rightComponent C A S x y z w ii 0 2 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 0 1 (by decide)] + +lemma component_021002 : + leftComponent C A S x y z w ii 0 2 1 0 0 2 = + rightComponent C A S x y z w ii 0 2 1 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 0 2 (by decide)] + +lemma component_021010 : + leftComponent C A S x y z w ii 0 2 1 0 1 0 = + rightComponent C A S x y z w ii 0 2 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 1 0 (by decide)] + +lemma component_021011 : + leftComponent C A S x y z w ii 0 2 1 0 1 1 = + rightComponent C A S x y z w ii 0 2 1 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 1 1 (by decide)] + +lemma component_021020 : + leftComponent C A S x y z w ii 0 2 1 0 2 0 = + rightComponent C A S x y z w ii 0 2 1 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 2 0 (by decide)] + +lemma component_021021 : + leftComponent C A S x y z w ii 0 2 1 0 2 1 = + rightComponent C A S x y z w ii 0 2 1 0 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_021022 : + leftComponent C A S x y z w ii 0 2 1 0 2 2 = + rightComponent C A S x y z w ii 0 2 1 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 0 2 2 (by decide)] + +lemma component_021100 : + leftComponent C A S x y z w ii 0 2 1 1 0 0 = + rightComponent C A S x y z w ii 0 2 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 0 0 (by decide)] + +lemma component_021101 : + leftComponent C A S x y z w ii 0 2 1 1 0 1 = + rightComponent C A S x y z w ii 0 2 1 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 0 1 (by decide)] + +lemma component_021110 : + leftComponent C A S x y z w ii 0 2 1 1 1 0 = + rightComponent C A S x y z w ii 0 2 1 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 1 0 (by decide)] + +lemma component_021112 : + leftComponent C A S x y z w ii 0 2 1 1 1 2 = + rightComponent C A S x y z w ii 0 2 1 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 1 2 (by decide)] + +lemma component_021121 : + leftComponent C A S x y z w ii 0 2 1 1 2 1 = + rightComponent C A S x y z w ii 0 2 1 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 2 1 (by decide)] + +lemma component_021122 : + leftComponent C A S x y z w ii 0 2 1 1 2 2 = + rightComponent C A S x y z w ii 0 2 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 1 2 2 (by decide)] + +lemma component_021200 : + leftComponent C A S x y z w ii 0 2 1 2 0 0 = + rightComponent C A S x y z w ii 0 2 1 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 0 0 (by decide)] + +lemma component_021201 : + leftComponent C A S x y z w ii 0 2 1 2 0 1 = + rightComponent C A S x y z w ii 0 2 1 2 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_021202 : + leftComponent C A S x y z w ii 0 2 1 2 0 2 = + rightComponent C A S x y z w ii 0 2 1 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 0 2 (by decide)] + +lemma component_021211 : + leftComponent C A S x y z w ii 0 2 1 2 1 1 = + rightComponent C A S x y z w ii 0 2 1 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 1 1 (by decide)] + +lemma component_021212 : + leftComponent C A S x y z w ii 0 2 1 2 1 2 = + rightComponent C A S x y z w ii 0 2 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 1 2 (by decide)] + +lemma component_021220 : + leftComponent C A S x y z w ii 0 2 1 2 2 0 = + rightComponent C A S x y z w ii 0 2 1 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 2 0 (by decide)] + +lemma component_021221 : + leftComponent C A S x y z w ii 0 2 1 2 2 1 = + rightComponent C A S x y z w ii 0 2 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 2 1 (by decide)] + +lemma component_021222 : + leftComponent C A S x y z w ii 0 2 1 2 2 2 = + rightComponent C A S x y z w ii 0 2 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 1 2 2 2 (by decide)] + +lemma component_022000 : + leftComponent C A S x y z w ii 0 2 2 0 0 0 = + rightComponent C A S x y z w ii 0 2 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 0 0 (by decide)] + +lemma component_022001 : + leftComponent C A S x y z w ii 0 2 2 0 0 1 = + rightComponent C A S x y z w ii 0 2 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 0 1 (by decide)] + +lemma component_022002 : + leftComponent C A S x y z w ii 0 2 2 0 0 2 = + rightComponent C A S x y z w ii 0 2 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 0 2 (by decide)] + +lemma component_022010 : + leftComponent C A S x y z w ii 0 2 2 0 1 0 = + rightComponent C A S x y z w ii 0 2 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 1 0 (by decide)] + +lemma component_022011 : + leftComponent C A S x y z w ii 0 2 2 0 1 1 = + rightComponent C A S x y z w ii 0 2 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 1 1 (by decide)] + +lemma component_022012 : + leftComponent C A S x y z w ii 0 2 2 0 1 2 = + rightComponent C A S x y z w ii 0 2 2 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 1 2 (by decide)] + +lemma component_022020 : + leftComponent C A S x y z w ii 0 2 2 0 2 0 = + rightComponent C A S x y z w ii 0 2 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 2 0 (by decide)] + +lemma component_022021 : + leftComponent C A S x y z w ii 0 2 2 0 2 1 = + rightComponent C A S x y z w ii 0 2 2 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 0 2 1 (by decide)] + +lemma component_022022 : + leftComponent C A S x y z w ii 0 2 2 0 2 2 = + rightComponent C A S x y z w ii 0 2 2 0 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_022100 : + leftComponent C A S x y z w ii 0 2 2 1 0 0 = + rightComponent C A S x y z w ii 0 2 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 0 0 (by decide)] + +lemma component_022101 : + leftComponent C A S x y z w ii 0 2 2 1 0 1 = + rightComponent C A S x y z w ii 0 2 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 0 1 (by decide)] + +lemma component_022102 : + leftComponent C A S x y z w ii 0 2 2 1 0 2 = + rightComponent C A S x y z w ii 0 2 2 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 0 2 (by decide)] + +lemma component_022110 : + leftComponent C A S x y z w ii 0 2 2 1 1 0 = + rightComponent C A S x y z w ii 0 2 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 1 0 (by decide)] + +lemma component_022111 : + leftComponent C A S x y z w ii 0 2 2 1 1 1 = + rightComponent C A S x y z w ii 0 2 2 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 1 1 (by decide)] + +lemma component_022120 : + leftComponent C A S x y z w ii 0 2 2 1 2 0 = + rightComponent C A S x y z w ii 0 2 2 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 2 0 (by decide)] + +lemma component_022122 : + leftComponent C A S x y z w ii 0 2 2 1 2 2 = + rightComponent C A S x y z w ii 0 2 2 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 1 2 2 (by decide)] + +lemma component_022200 : + leftComponent C A S x y z w ii 0 2 2 2 0 0 = + rightComponent C A S x y z w ii 0 2 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 0 0 (by decide)] + +lemma component_022201 : + leftComponent C A S x y z w ii 0 2 2 2 0 1 = + rightComponent C A S x y z w ii 0 2 2 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 0 1 (by decide)] + +lemma component_022210 : + leftComponent C A S x y z w ii 0 2 2 2 1 0 = + rightComponent C A S x y z w ii 0 2 2 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 1 0 (by decide)] + +lemma component_022212 : + leftComponent C A S x y z w ii 0 2 2 2 1 2 = + rightComponent C A S x y z w ii 0 2 2 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 1 2 (by decide)] + +lemma component_022221 : + leftComponent C A S x y z w ii 0 2 2 2 2 1 = + rightComponent C A S x y z w ii 0 2 2 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 2 1 (by decide)] + +lemma component_022222 : + leftComponent C A S x y z w ii 0 2 2 2 2 2 = + rightComponent C A S x y z w ii 0 2 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 0 2 2 2 2 2 (by decide)] + +lemma block_000 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 0 0 d e f = + rightComponent C A S x y z w ii 0 0 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_000000 C A S x y z w ii + · exact component_000001 C A S x y z w ii + · exact component_000002 C A S x y z w ii + · exact component_000010 C A S x y z w ii + · exact component_000011 C A S x y z w ii + · exact component_000012 C A S x y z w ii + · exact component_000020 C A S x y z w ii + · exact component_000021 C A S x y z w ii + · exact component_000022 C A S x y z w ii + · exact component_000100 C A S x y z w ii + · exact component_000101 C A S x y z w ii + · exact component_000102 C A S x y z w ii + · exact component_000110 C A S x y z w ii + · exact component_000111 C A S x y z w ii + · exact component_000112 C A S x y z w ii + · exact component_000120 C A S x y z w ii + · exact component_000121 C A S x y z w ii + · exact component_000122 C A S x y z w ii + · exact component_000200 C A S x y z w ii + · exact component_000201 C A S x y z w ii + · exact component_000202 C A S x y z w ii + · exact component_000210 C A S x y z w ii + · exact component_000211 C A S x y z w ii + · exact component_000212 C A S x y z w ii + · exact component_000220 C A S x y z w ii + · exact component_000221 C A S x y z w ii + · exact component_000222 C A S x y z w ii + +include hC hA hS hy hw in +lemma block_001 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 0 1 d e f = + rightComponent C A S x y z w ii 0 0 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_001000 C A S x y z w ii + · exact component_001001 C A S x y z w ii + · exact component_001002 C A S x y z w ii + · exact component_001010 C A S x y z w ii hy + · exact component_001011 C A S x y z w ii + · exact component_001012 C A S x y z w ii + · exact component_001020 C A S x y z w ii + · exact component_001021 C A S x y z w ii + · exact component_001022 C A S x y z w ii + · exact component_001100 C A S x y z w ii hC hA hS hy hw + · exact component_001101 C A S x y z w ii + · exact component_001102 C A S x y z w ii + · exact component_001110 C A S x y z w ii + · exact component_001111 C A S x y z w ii + · exact component_001112 C A S x y z w ii + · exact component_001120 C A S x y z w ii + · exact component_001121 C A S x y z w ii + · exact component_001122 C A S x y z w ii + · exact component_001200 C A S x y z w ii + · exact component_001201 C A S x y z w ii + · exact component_001202 C A S x y z w ii + · exact component_001210 C A S x y z w ii + · exact component_001211 C A S x y z w ii + · exact component_001212 C A S x y z w ii + · exact component_001220 C A S x y z w ii + · exact component_001221 C A S x y z w ii + · exact component_001222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_002 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 0 2 d e f = + rightComponent C A S x y z w ii 0 0 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_002000 C A S x y z w ii + · exact component_002001 C A S x y z w ii + · exact component_002002 C A S x y z w ii + · exact component_002010 C A S x y z w ii + · exact component_002011 C A S x y z w ii hC hA hS hy hw + · exact component_002012 C A S x y z w ii + · exact component_002020 C A S x y z w ii hC hA hS hy hw hi + · exact component_002021 C A S x y z w ii + · exact component_002022 C A S x y z w ii + · exact component_002100 C A S x y z w ii + · exact component_002101 C A S x y z w ii hC hA hS hy hw + · exact component_002102 C A S x y z w ii + · exact component_002110 C A S x y z w ii hC hA hS hy hw hi + · exact component_002111 C A S x y z w ii + · exact component_002112 C A S x y z w ii + · exact component_002120 C A S x y z w ii + · exact component_002121 C A S x y z w ii + · exact component_002122 C A S x y z w ii + · exact component_002200 C A S x y z w ii hC hA hS hy hw hi + · exact component_002201 C A S x y z w ii + · exact component_002202 C A S x y z w ii + · exact component_002210 C A S x y z w ii + · exact component_002211 C A S x y z w ii + · exact component_002212 C A S x y z w ii + · exact component_002220 C A S x y z w ii + · exact component_002221 C A S x y z w ii + · exact component_002222 C A S x y z w ii + +include hy in +lemma block_010 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 1 0 d e f = + rightComponent C A S x y z w ii 0 1 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_010000 C A S x y z w ii + · exact component_010001 C A S x y z w ii hy + · exact component_010002 C A S x y z w ii + · exact component_010010 C A S x y z w ii + · exact component_010011 C A S x y z w ii + · exact component_010012 C A S x y z w ii + · exact component_010020 C A S x y z w ii + · exact component_010021 C A S x y z w ii + · exact component_010022 C A S x y z w ii + · exact component_010100 C A S x y z w ii + · exact component_010101 C A S x y z w ii + · exact component_010102 C A S x y z w ii + · exact component_010110 C A S x y z w ii + · exact component_010111 C A S x y z w ii + · exact component_010112 C A S x y z w ii + · exact component_010120 C A S x y z w ii + · exact component_010121 C A S x y z w ii + · exact component_010122 C A S x y z w ii + · exact component_010200 C A S x y z w ii + · exact component_010201 C A S x y z w ii + · exact component_010202 C A S x y z w ii + · exact component_010210 C A S x y z w ii + · exact component_010211 C A S x y z w ii + · exact component_010212 C A S x y z w ii + · exact component_010220 C A S x y z w ii + · exact component_010221 C A S x y z w ii + · exact component_010222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_011 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 1 1 d e f = + rightComponent C A S x y z w ii 0 1 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_011000 C A S x y z w ii + · exact component_011001 C A S x y z w ii + · exact component_011002 C A S x y z w ii hC hA hS hy hw + · exact component_011010 C A S x y z w ii + · exact component_011011 C A S x y z w ii + · exact component_011012 C A S x y z w ii + · exact component_011020 C A S x y z w ii hC hA hS hy hw hi + · exact component_011021 C A S x y z w ii + · exact component_011022 C A S x y z w ii + · exact component_011100 C A S x y z w ii + · exact component_011101 C A S x y z w ii hC hA hS hy hw hi + · exact component_011102 C A S x y z w ii + · exact component_011110 C A S x y z w ii hC hA hS hy hw hi + · exact component_011111 C A S x y z w ii + · exact component_011112 C A S x y z w ii + · exact component_011120 C A S x y z w ii + · exact component_011121 C A S x y z w ii + · exact component_011122 C A S x y z w ii + · exact component_011200 C A S x y z w ii hC hA hS hy hw hi + · exact component_011201 C A S x y z w ii + · exact component_011202 C A S x y z w ii + · exact component_011210 C A S x y z w ii + · exact component_011211 C A S x y z w ii + · exact component_011212 C A S x y z w ii + · exact component_011220 C A S x y z w ii + · exact component_011221 C A S x y z w ii + · exact component_011222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_012 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 1 2 d e f = + rightComponent C A S x y z w ii 0 1 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_012000 C A S x y z w ii + · exact component_012001 C A S x y z w ii + · exact component_012002 C A S x y z w ii + · exact component_012010 C A S x y z w ii + · exact component_012011 C A S x y z w ii + · exact component_012012 C A S x y z w ii + · exact component_012020 C A S x y z w ii + · exact component_012021 C A S x y z w ii hC hA hS hy hw hi + · exact component_012022 C A S x y z w ii + · exact component_012100 C A S x y z w ii + · exact component_012101 C A S x y z w ii + · exact component_012102 C A S x y z w ii hC hA hS hy hw hi + · exact component_012110 C A S x y z w ii + · exact component_012111 C A S x y z w ii hC hA hS hy hw + · exact component_012112 C A S x y z w ii + · exact component_012120 C A S x y z w ii hC hA hS hy hw hi + · exact component_012121 C A S x y z w ii + · exact component_012122 C A S x y z w ii + · exact component_012200 C A S x y z w ii + · exact component_012201 C A S x y z w ii hC hA hS hy hw hi + · exact component_012202 C A S x y z w ii + · exact component_012210 C A S x y z w ii + · exact component_012211 C A S x y z w ii + · exact component_012212 C A S x y z w ii + · exact component_012220 C A S x y z w ii + · exact component_012221 C A S x y z w ii + · exact component_012222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_020 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 2 0 d e f = + rightComponent C A S x y z w ii 0 2 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_020000 C A S x y z w ii + · exact component_020001 C A S x y z w ii + · exact component_020002 C A S x y z w ii hC hA hS hy hw hi + · exact component_020010 C A S x y z w ii + · exact component_020011 C A S x y z w ii hC hA hS hy hw hi + · exact component_020012 C A S x y z w ii + · exact component_020020 C A S x y z w ii hC hA hS hy hw hi + · exact component_020021 C A S x y z w ii + · exact component_020022 C A S x y z w ii + · exact component_020100 C A S x y z w ii + · exact component_020101 C A S x y z w ii hC hA hS hy hw hi + · exact component_020102 C A S x y z w ii + · exact component_020110 C A S x y z w ii hC hA hS hy hw hi + · exact component_020111 C A S x y z w ii + · exact component_020112 C A S x y z w ii + · exact component_020120 C A S x y z w ii + · exact component_020121 C A S x y z w ii + · exact component_020122 C A S x y z w ii + · exact component_020200 C A S x y z w ii hC hA hS hy hw hi + · exact component_020201 C A S x y z w ii + · exact component_020202 C A S x y z w ii + · exact component_020210 C A S x y z w ii + · exact component_020211 C A S x y z w ii + · exact component_020212 C A S x y z w ii + · exact component_020220 C A S x y z w ii + · exact component_020221 C A S x y z w ii + · exact component_020222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_021 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 2 1 d e f = + rightComponent C A S x y z w ii 0 2 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_021000 C A S x y z w ii + · exact component_021001 C A S x y z w ii + · exact component_021002 C A S x y z w ii + · exact component_021010 C A S x y z w ii + · exact component_021011 C A S x y z w ii + · exact component_021012 C A S x y z w ii hC hA hS hy hw hi + · exact component_021020 C A S x y z w ii + · exact component_021021 C A S x y z w ii + · exact component_021022 C A S x y z w ii + · exact component_021100 C A S x y z w ii + · exact component_021101 C A S x y z w ii + · exact component_021102 C A S x y z w ii hC hA hS hy hw hi + · exact component_021110 C A S x y z w ii + · exact component_021111 C A S x y z w ii hC hA hS hy hw hi + · exact component_021112 C A S x y z w ii + · exact component_021120 C A S x y z w ii hC hA hS hy hw hi + · exact component_021121 C A S x y z w ii + · exact component_021122 C A S x y z w ii + · exact component_021200 C A S x y z w ii + · exact component_021201 C A S x y z w ii + · exact component_021202 C A S x y z w ii + · exact component_021210 C A S x y z w ii hC hA hS hy hw hi + · exact component_021211 C A S x y z w ii + · exact component_021212 C A S x y z w ii + · exact component_021220 C A S x y z w ii + · exact component_021221 C A S x y z w ii + · exact component_021222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_022 (d e f : Fin 3) : + leftComponent C A S x y z w ii 0 2 2 d e f = + rightComponent C A S x y z w ii 0 2 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_022000 C A S x y z w ii + · exact component_022001 C A S x y z w ii + · exact component_022002 C A S x y z w ii + · exact component_022010 C A S x y z w ii + · exact component_022011 C A S x y z w ii + · exact component_022012 C A S x y z w ii + · exact component_022020 C A S x y z w ii + · exact component_022021 C A S x y z w ii + · exact component_022022 C A S x y z w ii + · exact component_022100 C A S x y z w ii + · exact component_022101 C A S x y z w ii + · exact component_022102 C A S x y z w ii + · exact component_022110 C A S x y z w ii + · exact component_022111 C A S x y z w ii + · exact component_022112 C A S x y z w ii hC hA hS hy hw + · exact component_022120 C A S x y z w ii + · exact component_022121 C A S x y z w ii hC hA hS hy hw + · exact component_022122 C A S x y z w ii + · exact component_022200 C A S x y z w ii + · exact component_022201 C A S x y z w ii + · exact component_022202 C A S x y z w ii hC hA hS hy hw hi + · exact component_022210 C A S x y z w ii + · exact component_022211 C A S x y z w ii hC hA hS hy hw hi + · exact component_022212 C A S x y z w ii + · exact component_022220 C A S x y z w ii hC hA hS hy hw hi + · exact component_022221 C A S x y z w ii + · exact component_022222 C A S x y z w ii + +end Algebra +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterSupport.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee71b17ef1c07869b268ce642df533ee2105400c --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterSupport.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterDefinitions +import Lean.Elab.Tactic.Omega + +namespace OAI + +/-! Spin conservation for the honeycomb Yang–Baxter numerator and its triple products. -/ + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +lemma numerator_eq_zero_of_sum_ne (C A S x y ii : ℂ) (p q : Fin 3 × Fin 3) + (h : p.1.val + p.2.val ≠ q.1.val + q.2.val) : + numerator C A S x y ii p q = 0 := by + unfold numerator + split <;> simp_all + +lemma leftComponent_eq_zero_of_sum_ne (C A S x y z w ii : ℂ) + (a b c d e f : Fin 3) (h : a.val + b.val + c.val ≠ d.val + e.val + f.val) : + leftComponent C A S x y z w ii a b c d e f = 0 := by + classical + unfold leftComponent + apply Finset.sum_eq_zero + intro j _ + apply Finset.sum_eq_zero + intro k _ + apply Finset.sum_eq_zero + intro l _ + by_cases h₁ : a.val + b.val = j.val + k.val + · by_cases h₂ : j.val + c.val = d.val + l.val + · have h₃ : k.val + l.val ≠ e.val + f.val := by omega + rw [numerator_eq_zero_of_sum_ne C A S z w ii (k, l) (e, f) h₃, mul_zero] + · rw [numerator_eq_zero_of_sum_ne C A S x y ii (j, c) (d, l) h₂, mul_zero, zero_mul] + · rw [numerator_eq_zero_of_sum_ne C A S (x*w-y*z) (y*w+x*z) ii (a, b) (j, k) h₁, zero_mul, zero_mul] + +lemma rightComponent_eq_zero_of_sum_ne (C A S x y z w ii : ℂ) + (a b c d e f : Fin 3) (h : a.val + b.val + c.val ≠ d.val + e.val + f.val) : + rightComponent C A S x y z w ii a b c d e f = 0 := by + classical + unfold rightComponent + apply Finset.sum_eq_zero + intro j _ + apply Finset.sum_eq_zero + intro k _ + apply Finset.sum_eq_zero + intro l _ + by_cases h₁ : b.val + c.val = k.val + l.val + · by_cases h₂ : a.val + l.val = j.val + f.val + · have h₃ : j.val + k.val ≠ d.val + e.val := by omega + rw [numerator_eq_zero_of_sum_ne C A S (x*w-y*z) (y*w+x*z) ii (j, k) (d, e) h₃, mul_zero] + · rw [numerator_eq_zero_of_sum_ne C A S x y ii (a, l) (j, f) h₂, mul_zero, zero_mul] + · rw [numerator_eq_zero_of_sum_ne C A S z w ii (b, c) (k, l) h₁, zero_mul, zero_mul] + +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterWeights.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cdda9cf3e866305904776e5af996209f1d2b30a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterWeights.lean @@ -0,0 +1,214 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterDefinitions +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex +import Mathlib.Tactic.LinearCombination +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Algebra.BigOperators.Field + +namespace OAI + +/-! Sine parametrization and phase normalization of the honeycomb transfer weights. + +The formulas follow the finite strip transfer calculation in the companion paper +on uniform marked polygon estimates. -/ + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +noncomputable def angle : ℝ := Real.pi/8 +noncomputable def sine2 : ℝ := Real.sin (2*angle) + +lemma cos_two_angle : Real.cos (2*angle) = sine2 := by + unfold sine2 + rw [show 2*angle = Real.pi/4 by unfold angle; ring, + Real.cos_pi_div_four, Real.sin_pi_div_four] + +lemma sine2_sq : sine2^2 = (1:ℝ)/2 := by + have h := Real.sin_sq_add_cos_sq (2*angle) + rw [cos_two_angle] at h + change sine2^2+sine2^2=1 at h + linarith + +lemma sin_angle_sq : (Real.sin angle)^2 = (1-sine2)/2 := by + have h := Real.cos_two_mul angle + rw [cos_two_angle] at h + nlinarith only [h, Real.sin_sq_add_cos_sq angle] + +lemma cos_angle_eq : Real.cos angle = (2*sine2+1)*Real.sin angle := by + have h : Real.sin angle = sine2*(Real.cos angle-Real.sin angle) := by + calc + Real.sin angle = Real.cos (3*angle) := by + rw [show 3*angle=Real.pi/2-angle by unfold angle; ring, Real.cos_pi_div_two_sub] + _ = sine2*(Real.cos angle-Real.sin angle) := by + rw [show 3*angle=2*angle+angle by ring, Real.cos_add, cos_two_angle] + unfold sine2 + ring + linear_combination -2*sine2*h - 2*(Real.cos angle-Real.sin angle)*sine2_sq + +lemma trig_constraints (u v : ℝ) : + (Real.cos angle : ℂ) = (2*(sine2:ℂ)+1)*(Real.sin angle:ℂ) ∧ + (Real.sin angle : ℂ)^2 = (1-(sine2:ℂ))/2 ∧ + (sine2 : ℂ)^2 = 1/2 ∧ + (Real.cos u : ℂ)^2 + (Real.sin u : ℂ)^2 = 1 ∧ + (Real.cos v : ℂ)^2 + (Real.sin v : ℂ)^2 = 1 ∧ + Complex.I^2+1=0 := by + refine ⟨?_, ?_, ?_, ?_, ?_, by simp⟩ + · exact_mod_cast cos_angle_eq + · exact_mod_cast sin_angle_sq + · have h := congrArg Complex.ofReal sine2_sq + push_cast at h + exact h + · exact_mod_cast Real.cos_sq_add_sin_sq u + · exact_mod_cast Real.cos_sq_add_sin_sq v + +noncomputable def denominator (u : ℝ) : ℂ := + (Real.sin (2*angle+u) * Real.sin (3*angle+u) : ℝ) +noncomputable def phase : ℂ := Complex.exp ((2*angle : ℝ) * Complex.I) + +lemma sin_three_angle : Real.sin (3*angle)=Real.cos angle := by + rw [show 3*angle = Real.pi/2-angle by unfold angle; ring, Real.sin_pi_div_two_sub] +lemma cos_three_angle : Real.cos (3*angle)=Real.sin angle := by + rw [show 3*angle = Real.pi/2-angle by unfold angle; ring, Real.cos_pi_div_two_sub] + +lemma denominator_eq (u : ℝ) : denominator u = + (sine2:ℂ)*((Real.cos u:ℂ)+(Real.sin u:ℂ))* + ((Real.cos angle:ℂ)*(Real.cos u:ℂ)+(Real.sin angle:ℂ)*(Real.sin u:ℂ)) := by + unfold denominator + rw [Real.sin_add, Real.sin_add, cos_two_angle, sin_three_angle, cos_three_angle] + simp only [Complex.ofReal_mul, Complex.ofReal_add] + change ((sine2:ℂ)*(Real.cos u:ℂ)+(sine2:ℂ)*(Real.sin u:ℂ))* + ((Real.cos angle:ℂ)*(Real.cos u:ℂ)+(Real.sin angle:ℂ)*(Real.sin u:ℂ)) = _ + ring + +lemma phase_eq : phase = (sine2:ℂ)*(1+Complex.I) := by + unfold phase + rw [Complex.exp_ofReal_mul_I, cos_two_angle] + change (sine2:ℂ)+(sine2:ℂ)*Complex.I=_ + ring + +lemma phase_sq : phase^2 = Complex.I := by + unfold phase + rw [← Complex.exp_nat_mul] + convert Complex.exp_pi_div_two_mul_I using 1 + push_cast + unfold angle + push_cast + ring_nf + +lemma phase_ne_zero : phase ≠ 0 := Complex.exp_ne_zero _ + +lemma phase_inverse : phase⁻¹ = (sine2:ℂ)*(1-Complex.I) := by + apply mul_left_cancel₀ phase_ne_zero + rw [mul_inv_cancel₀ phase_ne_zero, phase_eq] + have hs := (trig_constraints 0 0).2.2.1 + have hi : Complex.I^2+1=0 := by simp + linear_combination -2*hs + (sine2:ℂ)^2*hi + +noncomputable def sourceR (u : ℝ) (p q : Fin 3 × Fin 3) : ℂ := + let a := (sine2 * Real.sin (3*angle-u) : ℝ) / denominator u + let h := (sine2 * Real.sin u : ℝ) / denominator u + let v := (Real.sin (3*angle-u) * Real.sin u : ℝ) / denominator u + let c := (Real.sin (3*angle-u) * Real.sin (2*angle-u) : ℝ) / denominator u + let d := (Real.sin u * Real.sin (u-angle) : ℝ) / denominator u + match p.1.val, p.2.val, q.1.val, q.2.val with + | 0, 0, 0, 0 => c + | 2, 2, 2, 2 => c + | 0, 1, 0, 1 => v + | 1, 0, 1, 0 => v + | 2, 1, 2, 1 => v + | 1, 2, 1, 2 => v + | 0, 1, 1, 0 => a + | 1, 0, 0, 1 => a + | 2, 1, 1, 2 => a + | 1, 2, 2, 1 => a + | 0, 2, 0, 2 => d + | 0, 2, 1, 1 => h/phase + | 0, 2, 2, 0 => c+d/phase^2 + | 1, 1, 0, 2 => h*phase + | 1, 1, 1, 1 => 1 + | 1, 1, 2, 0 => h/phase + | 2, 0, 0, 2 => c+d*phase^2 + | 2, 0, 1, 1 => h*phase + | 2, 0, 2, 0 => d + | _, _, _, _ => 0 + +lemma h_plus (x q : ℂ) : ((sine2:ℂ)*x/q)*phase=(x/2*(1+Complex.I))/q := by + rw [phase_eq] + have hs : (sine2:ℂ)^2=1/2 := (trig_constraints 0 0).2.2.1 + simp only [div_eq_mul_inv] + linear_combination x*(1+Complex.I)*q⁻¹*hs + +lemma h_minus (x q : ℂ) : ((sine2:ℂ)*x/q)/phase=(x/2*(1-Complex.I))/q := by + simp only [div_eq_mul_inv, phase_inverse] + have hs : (sine2:ℂ)^2=1/2 := (trig_constraints 0 0).2.2.1 + linear_combination x*(1-Complex.I)*q⁻¹*hs + +lemma c_minus (c d q : ℂ) : c/q+(d/q)/phase^2=(c-Complex.I*d)/q := by + rw [phase_sq] + simp only [div_eq_mul_inv, Complex.inv_I] + ring + +lemma c_plus (c d q : ℂ) : c/q+(d/q)*phase^2=(c+Complex.I*d)/q := by + rw [phase_sq] + ring + +lemma sourceR_eq_numerator (u : ℝ) (hd : denominator u ≠ 0) + (p q : Fin 3 × Fin 3) : + sourceR u p q = numerator (Real.cos angle) (Real.sin angle) sine2 + (Real.sin u) (Real.cos u) Complex.I p q / denominator u := by + dsimp only [sourceR, numerator] + split + all_goals try simp_all only [Real.sin_sub, sin_three_angle, cos_three_angle, cos_two_angle, + Complex.ofReal_mul, Complex.ofReal_sub, h_plus, h_minus, c_minus, c_plus] + all_goals try (rw [← denominator_eq, div_self hd]) + all_goals try dsimp only [sine2] + all_goals first | rfl | ring + +lemma physical_left_sum (u v : ℝ) + (hu : denominator u ≠ 0) (hv : denominator v ≠ 0) + (hd : denominator (u-v) ≠ 0) (a b c d e f : Fin 3) : + (∑ j : Fin 3, ∑ k : Fin 3, ∑ l : Fin 3, + sourceR (u-v) (a,b) (j,k) * sourceR u (j,c) (d,l) * + sourceR v (k,l) (e,f)) = + leftComponent (Real.cos angle) (Real.sin angle) sine2 + (Real.sin u) (Real.cos u) (Real.sin v) (Real.cos v) Complex.I + a b c d e f / (denominator (u-v) * denominator u * denominator v) := by + simp only [leftComponent, Finset.sum_div] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + apply Finset.sum_congr rfl + intro l hl + rw [sourceR_eq_numerator _ hd, sourceR_eq_numerator _ hu, + sourceR_eq_numerator _ hv] + simp only [Real.sin_sub, Real.cos_sub, Complex.ofReal_sub, + Complex.ofReal_add, Complex.ofReal_mul] + ring + +lemma physical_right_sum (u v : ℝ) + (hu : denominator u ≠ 0) (hv : denominator v ≠ 0) + (hd : denominator (u-v) ≠ 0) (a b c d e f : Fin 3) : + (∑ j : Fin 3, ∑ k : Fin 3, ∑ l : Fin 3, + sourceR v (b,c) (k,l) * sourceR u (a,l) (j,f) * + sourceR (u-v) (j,k) (d,e)) = + rightComponent (Real.cos angle) (Real.sin angle) sine2 + (Real.sin u) (Real.cos u) (Real.sin v) (Real.cos v) Complex.I + a b c d e f / (denominator (u-v) * denominator u * denominator v) := by + simp only [rightComponent, Finset.sum_div] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + apply Finset.sum_congr rfl + intro l hl + rw [sourceR_eq_numerator _ hv, sourceR_eq_numerator _ hu, + sourceR_eq_numerator _ hd] + simp only [Real.sin_sub, Real.cos_sub, Complex.ofReal_sub, + Complex.ofReal_add, Complex.ofReal_mul] + ring + +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombChords/YangBaxterZero.lean b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd6958707ebc68fa6308c9303385825d07e2910a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombChords/YangBaxterZero.lean @@ -0,0 +1,1894 @@ +import OAI.Combinatorics.HoneycombChords.YangBaxterPolynomialsPositive +import OAI.Combinatorics.HoneycombChords.YangBaxterPolynomialsZero +import OAI.Combinatorics.HoneycombChords.YangBaxterSupport +import Mathlib.Tactic.FinCases + +namespace OAI + +/-! Yang–Baxter components with first spin zero. + +This development follows the finite strip transfer calculation for critical honeycomb +walks in the companion paper on uniform marked polygon estimates. -/ + + +namespace CriticalHoneycomb.Transfer.YangBaxter +open scoped BigOperators + +section Algebra +variable (C A S x y z w ii : ℂ) +variable (hC : C = (2*S+1)*A) (hA : A^2 = (1-S)/2) + (hS : S^2 = 1/2) (hy : y^2+x^2=1) (hw : w^2+z^2=1) (hi : ii^2+1=0) + +include hC hA hS hy hw in +lemma component_101002 : + leftComponent C A S x y z w ii 1 0 1 0 0 2 = + rightComponent C A S x y z w ii 1 0 1 0 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101002 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_101002_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_101020 : + leftComponent C A S x y z w ii 1 0 1 0 2 0 = + rightComponent C A S x y z w ii 1 0 1 0 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_101020_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_101110 : + leftComponent C A S x y z w ii 1 0 1 1 1 0 = + rightComponent C A S x y z w ii 1 0 1 1 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_101110_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_102111 : + leftComponent C A S x y z w ii 1 0 2 1 1 1 = + rightComponent C A S x y z w ii 1 0 2 1 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_102111 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_102111_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_110002 : + leftComponent C A S x y z w ii 1 1 0 0 0 2 = + rightComponent C A S x y z w ii 1 1 0 0 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_110002 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_110002_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_110011 : + leftComponent C A S x y z w ii 1 1 0 0 1 1 = + rightComponent C A S x y z w ii 1 1 0 0 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_110011 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_110011_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_110020 : + leftComponent C A S x y z w ii 1 1 0 0 2 0 = + rightComponent C A S x y z w ii 1 1 0 0 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_110020 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_110020_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_111012 : + leftComponent C A S x y z w ii 1 1 1 0 1 2 = + rightComponent C A S x y z w ii 1 1 1 0 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_111012 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_111012_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_111021 : + leftComponent C A S x y z w ii 1 1 1 0 2 1 = + rightComponent C A S x y z w ii 1 1 1 0 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_111021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_111021_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_111102 : + leftComponent C A S x y z w ii 1 1 1 1 0 2 = + rightComponent C A S x y z w ii 1 1 1 1 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_111102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_111102_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_112022 : + leftComponent C A S x y z w ii 1 1 2 0 2 2 = + rightComponent C A S x y z w ii 1 1 2 0 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_112022 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_112022_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_120012 : + leftComponent C A S x y z w ii 1 2 0 0 1 2 = + rightComponent C A S x y z w ii 1 2 0 0 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_120012 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_120012_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw hi in +lemma component_120021 : + leftComponent C A S x y z w ii 1 2 0 0 2 1 = + rightComponent C A S x y z w ii 1 2 0 0 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_120021 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_120021_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_121022 : + leftComponent C A S x y z w ii 1 2 1 0 2 2 = + rightComponent C A S x y z w ii 1 2 1 0 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_121022 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_121022_0, complexAdd, complexMul, complexPow] at hp + linear_combination hp + +include hC hA hS hy hw in +lemma component_100001 : + leftComponent C A S x y z w ii 1 0 0 0 0 1 = + rightComponent C A S x y z w ii 1 0 0 0 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001100 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_001100_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_101011 : + leftComponent C A S x y z w ii 1 0 1 0 1 1 = + rightComponent C A S x y z w ii 1 0 1 0 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011101 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011101_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_101200 : + leftComponent C A S x y z w ii 1 0 1 2 0 0 = + rightComponent C A S x y z w ii 1 0 1 2 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_022121 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_022121_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_102012 : + leftComponent C A S x y z w ii 1 0 2 0 1 2 = + rightComponent C A S x y z w ii 1 0 2 0 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012102_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_102021 : + leftComponent C A S x y z w ii 1 0 2 0 2 1 = + rightComponent C A S x y z w ii 1 0 2 0 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021102_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_102201 : + leftComponent C A S x y z w ii 1 0 2 2 0 1 = + rightComponent C A S x y z w ii 1 0 2 2 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021120 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021120_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_102210 : + leftComponent C A S x y z w ii 1 0 2 2 1 0 = + rightComponent C A S x y z w ii 1 0 2 2 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012120 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012120_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_110101 : + leftComponent C A S x y z w ii 1 1 0 1 0 1 = + rightComponent C A S x y z w ii 1 1 0 1 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_101110_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_110200 : + leftComponent C A S x y z w ii 1 1 0 2 0 0 = + rightComponent C A S x y z w ii 1 1 0 2 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_022112 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_022112_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_111120 : + leftComponent C A S x y z w ii 1 1 1 1 2 0 = + rightComponent C A S x y z w ii 1 1 1 1 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_102111 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_102111_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_111201 : + leftComponent C A S x y z w ii 1 1 1 2 0 1 = + rightComponent C A S x y z w ii 1 1 1 2 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021111 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021111_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_111210 : + leftComponent C A S x y z w ii 1 1 1 2 1 0 = + rightComponent C A S x y z w ii 1 1 1 2 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012111 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_012111_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_112121 : + leftComponent C A S x y z w ii 1 1 2 1 2 1 = + rightComponent C A S x y z w ii 1 1 2 1 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_101110_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_112202 : + leftComponent C A S x y z w ii 1 1 2 2 0 2 = + rightComponent C A S x y z w ii 1 1 2 2 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020110_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_112211 : + leftComponent C A S x y z w ii 1 1 2 2 1 1 = + rightComponent C A S x y z w ii 1 1 2 2 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011110_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_112220 : + leftComponent C A S x y z w ii 1 1 2 2 2 0 = + rightComponent C A S x y z w ii 1 1 2 2 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_002110_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_120111 : + leftComponent C A S x y z w ii 1 2 0 1 1 1 = + rightComponent C A S x y z w ii 1 2 0 1 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_111102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_111102_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_120201 : + leftComponent C A S x y z w ii 1 2 0 2 0 1 = + rightComponent C A S x y z w ii 1 2 0 2 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_021102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_021102_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_120210 : + leftComponent C A S x y z w ii 1 2 0 2 1 0 = + rightComponent C A S x y z w ii 1 2 0 2 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_012102 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_012102_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_121112 : + leftComponent C A S x y z w ii 1 2 1 1 1 2 = + rightComponent C A S x y z w ii 1 2 1 1 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_101110 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_101110_0, complexAdd, complexMul, complexPow] at hp + linear_combination (1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_121202 : + leftComponent C A S x y z w ii 1 2 1 2 0 2 = + rightComponent C A S x y z w ii 1 2 1 2 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_020101 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_020101_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw hi in +lemma component_121211 : + leftComponent C A S x y z w ii 1 2 1 2 1 1 = + rightComponent C A S x y z w ii 1 2 1 2 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_011101 C A S x y z w ii hC hA hS hy hw hi + dsimp only [poly_011101_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_121220 : + leftComponent C A S x y z w ii 1 2 1 2 2 0 = + rightComponent C A S x y z w ii 1 2 1 2 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_002101 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_002101_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +include hC hA hS hy hw in +lemma component_122221 : + leftComponent C A S x y z w ii 1 2 2 2 2 1 = + rightComponent C A S x y z w ii 1 2 2 2 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + have hp := polynomial_001100 C A S x y z w ii hC hA hS hy hw + dsimp only [poly_001100_0, complexAdd, complexMul, complexPow] at hp + linear_combination (-1:ℂ)/1*hp + +lemma component_100000 : + leftComponent C A S x y z w ii 1 0 0 0 0 0 = + rightComponent C A S x y z w ii 1 0 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 0 0 (by decide)] + +lemma component_100002 : + leftComponent C A S x y z w ii 1 0 0 0 0 2 = + rightComponent C A S x y z w ii 1 0 0 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 0 2 (by decide)] + +lemma component_100010 : + leftComponent C A S x y z w ii 1 0 0 0 1 0 = + rightComponent C A S x y z w ii 1 0 0 0 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_100011 : + leftComponent C A S x y z w ii 1 0 0 0 1 1 = + rightComponent C A S x y z w ii 1 0 0 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 1 1 (by decide)] + +lemma component_100012 : + leftComponent C A S x y z w ii 1 0 0 0 1 2 = + rightComponent C A S x y z w ii 1 0 0 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 1 2 (by decide)] + +lemma component_100020 : + leftComponent C A S x y z w ii 1 0 0 0 2 0 = + rightComponent C A S x y z w ii 1 0 0 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 2 0 (by decide)] + +lemma component_100021 : + leftComponent C A S x y z w ii 1 0 0 0 2 1 = + rightComponent C A S x y z w ii 1 0 0 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 2 1 (by decide)] + +lemma component_100022 : + leftComponent C A S x y z w ii 1 0 0 0 2 2 = + rightComponent C A S x y z w ii 1 0 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 0 2 2 (by decide)] + +lemma component_100100 : + leftComponent C A S x y z w ii 1 0 0 1 0 0 = + rightComponent C A S x y z w ii 1 0 0 1 0 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_100101 : + leftComponent C A S x y z w ii 1 0 0 1 0 1 = + rightComponent C A S x y z w ii 1 0 0 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 0 1 (by decide)] + +lemma component_100102 : + leftComponent C A S x y z w ii 1 0 0 1 0 2 = + rightComponent C A S x y z w ii 1 0 0 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 0 2 (by decide)] + +lemma component_100110 : + leftComponent C A S x y z w ii 1 0 0 1 1 0 = + rightComponent C A S x y z w ii 1 0 0 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 1 0 (by decide)] + +lemma component_100111 : + leftComponent C A S x y z w ii 1 0 0 1 1 1 = + rightComponent C A S x y z w ii 1 0 0 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 1 1 (by decide)] + +lemma component_100112 : + leftComponent C A S x y z w ii 1 0 0 1 1 2 = + rightComponent C A S x y z w ii 1 0 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 1 2 (by decide)] + +lemma component_100120 : + leftComponent C A S x y z w ii 1 0 0 1 2 0 = + rightComponent C A S x y z w ii 1 0 0 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 2 0 (by decide)] + +lemma component_100121 : + leftComponent C A S x y z w ii 1 0 0 1 2 1 = + rightComponent C A S x y z w ii 1 0 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 2 1 (by decide)] + +lemma component_100122 : + leftComponent C A S x y z w ii 1 0 0 1 2 2 = + rightComponent C A S x y z w ii 1 0 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 1 2 2 (by decide)] + +lemma component_100200 : + leftComponent C A S x y z w ii 1 0 0 2 0 0 = + rightComponent C A S x y z w ii 1 0 0 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 0 0 (by decide)] + +lemma component_100201 : + leftComponent C A S x y z w ii 1 0 0 2 0 1 = + rightComponent C A S x y z w ii 1 0 0 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 0 1 (by decide)] + +lemma component_100202 : + leftComponent C A S x y z w ii 1 0 0 2 0 2 = + rightComponent C A S x y z w ii 1 0 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 0 2 (by decide)] + +lemma component_100210 : + leftComponent C A S x y z w ii 1 0 0 2 1 0 = + rightComponent C A S x y z w ii 1 0 0 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 1 0 (by decide)] + +lemma component_100211 : + leftComponent C A S x y z w ii 1 0 0 2 1 1 = + rightComponent C A S x y z w ii 1 0 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 1 1 (by decide)] + +lemma component_100212 : + leftComponent C A S x y z w ii 1 0 0 2 1 2 = + rightComponent C A S x y z w ii 1 0 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 1 2 (by decide)] + +lemma component_100220 : + leftComponent C A S x y z w ii 1 0 0 2 2 0 = + rightComponent C A S x y z w ii 1 0 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 2 0 (by decide)] + +lemma component_100221 : + leftComponent C A S x y z w ii 1 0 0 2 2 1 = + rightComponent C A S x y z w ii 1 0 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 2 1 (by decide)] + +lemma component_100222 : + leftComponent C A S x y z w ii 1 0 0 2 2 2 = + rightComponent C A S x y z w ii 1 0 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 0 2 2 2 (by decide)] + +lemma component_101000 : + leftComponent C A S x y z w ii 1 0 1 0 0 0 = + rightComponent C A S x y z w ii 1 0 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 0 0 (by decide)] + +lemma component_101001 : + leftComponent C A S x y z w ii 1 0 1 0 0 1 = + rightComponent C A S x y z w ii 1 0 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 0 1 (by decide)] + +lemma component_101010 : + leftComponent C A S x y z w ii 1 0 1 0 1 0 = + rightComponent C A S x y z w ii 1 0 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 1 0 (by decide)] + +lemma component_101012 : + leftComponent C A S x y z w ii 1 0 1 0 1 2 = + rightComponent C A S x y z w ii 1 0 1 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 1 2 (by decide)] + +lemma component_101021 : + leftComponent C A S x y z w ii 1 0 1 0 2 1 = + rightComponent C A S x y z w ii 1 0 1 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 2 1 (by decide)] + +lemma component_101022 : + leftComponent C A S x y z w ii 1 0 1 0 2 2 = + rightComponent C A S x y z w ii 1 0 1 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 0 2 2 (by decide)] + +lemma component_101100 : + leftComponent C A S x y z w ii 1 0 1 1 0 0 = + rightComponent C A S x y z w ii 1 0 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 0 0 (by decide)] + +lemma component_101101 : + leftComponent C A S x y z w ii 1 0 1 1 0 1 = + rightComponent C A S x y z w ii 1 0 1 1 0 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_101102 : + leftComponent C A S x y z w ii 1 0 1 1 0 2 = + rightComponent C A S x y z w ii 1 0 1 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 0 2 (by decide)] + +lemma component_101111 : + leftComponent C A S x y z w ii 1 0 1 1 1 1 = + rightComponent C A S x y z w ii 1 0 1 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 1 1 (by decide)] + +lemma component_101112 : + leftComponent C A S x y z w ii 1 0 1 1 1 2 = + rightComponent C A S x y z w ii 1 0 1 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 1 2 (by decide)] + +lemma component_101120 : + leftComponent C A S x y z w ii 1 0 1 1 2 0 = + rightComponent C A S x y z w ii 1 0 1 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 2 0 (by decide)] + +lemma component_101121 : + leftComponent C A S x y z w ii 1 0 1 1 2 1 = + rightComponent C A S x y z w ii 1 0 1 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 2 1 (by decide)] + +lemma component_101122 : + leftComponent C A S x y z w ii 1 0 1 1 2 2 = + rightComponent C A S x y z w ii 1 0 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 1 2 2 (by decide)] + +lemma component_101201 : + leftComponent C A S x y z w ii 1 0 1 2 0 1 = + rightComponent C A S x y z w ii 1 0 1 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 0 1 (by decide)] + +lemma component_101202 : + leftComponent C A S x y z w ii 1 0 1 2 0 2 = + rightComponent C A S x y z w ii 1 0 1 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 0 2 (by decide)] + +lemma component_101210 : + leftComponent C A S x y z w ii 1 0 1 2 1 0 = + rightComponent C A S x y z w ii 1 0 1 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 1 0 (by decide)] + +lemma component_101211 : + leftComponent C A S x y z w ii 1 0 1 2 1 1 = + rightComponent C A S x y z w ii 1 0 1 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 1 1 (by decide)] + +lemma component_101212 : + leftComponent C A S x y z w ii 1 0 1 2 1 2 = + rightComponent C A S x y z w ii 1 0 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 1 2 (by decide)] + +lemma component_101220 : + leftComponent C A S x y z w ii 1 0 1 2 2 0 = + rightComponent C A S x y z w ii 1 0 1 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 2 0 (by decide)] + +lemma component_101221 : + leftComponent C A S x y z w ii 1 0 1 2 2 1 = + rightComponent C A S x y z w ii 1 0 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 2 1 (by decide)] + +lemma component_101222 : + leftComponent C A S x y z w ii 1 0 1 2 2 2 = + rightComponent C A S x y z w ii 1 0 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 1 2 2 2 (by decide)] + +lemma component_102000 : + leftComponent C A S x y z w ii 1 0 2 0 0 0 = + rightComponent C A S x y z w ii 1 0 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 0 0 (by decide)] + +lemma component_102001 : + leftComponent C A S x y z w ii 1 0 2 0 0 1 = + rightComponent C A S x y z w ii 1 0 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 0 1 (by decide)] + +lemma component_102002 : + leftComponent C A S x y z w ii 1 0 2 0 0 2 = + rightComponent C A S x y z w ii 1 0 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 0 2 (by decide)] + +lemma component_102010 : + leftComponent C A S x y z w ii 1 0 2 0 1 0 = + rightComponent C A S x y z w ii 1 0 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 1 0 (by decide)] + +lemma component_102011 : + leftComponent C A S x y z w ii 1 0 2 0 1 1 = + rightComponent C A S x y z w ii 1 0 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 1 1 (by decide)] + +lemma component_102020 : + leftComponent C A S x y z w ii 1 0 2 0 2 0 = + rightComponent C A S x y z w ii 1 0 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 2 0 (by decide)] + +lemma component_102022 : + leftComponent C A S x y z w ii 1 0 2 0 2 2 = + rightComponent C A S x y z w ii 1 0 2 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 0 2 2 (by decide)] + +lemma component_102100 : + leftComponent C A S x y z w ii 1 0 2 1 0 0 = + rightComponent C A S x y z w ii 1 0 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 0 0 (by decide)] + +lemma component_102101 : + leftComponent C A S x y z w ii 1 0 2 1 0 1 = + rightComponent C A S x y z w ii 1 0 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 0 1 (by decide)] + +lemma component_102102 : + leftComponent C A S x y z w ii 1 0 2 1 0 2 = + rightComponent C A S x y z w ii 1 0 2 1 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_102110 : + leftComponent C A S x y z w ii 1 0 2 1 1 0 = + rightComponent C A S x y z w ii 1 0 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 1 0 (by decide)] + +lemma component_102112 : + leftComponent C A S x y z w ii 1 0 2 1 1 2 = + rightComponent C A S x y z w ii 1 0 2 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 1 2 (by decide)] + +lemma component_102120 : + leftComponent C A S x y z w ii 1 0 2 1 2 0 = + rightComponent C A S x y z w ii 1 0 2 1 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_102121 : + leftComponent C A S x y z w ii 1 0 2 1 2 1 = + rightComponent C A S x y z w ii 1 0 2 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 2 1 (by decide)] + +lemma component_102122 : + leftComponent C A S x y z w ii 1 0 2 1 2 2 = + rightComponent C A S x y z w ii 1 0 2 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 1 2 2 (by decide)] + +lemma component_102200 : + leftComponent C A S x y z w ii 1 0 2 2 0 0 = + rightComponent C A S x y z w ii 1 0 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 0 0 (by decide)] + +lemma component_102202 : + leftComponent C A S x y z w ii 1 0 2 2 0 2 = + rightComponent C A S x y z w ii 1 0 2 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 0 2 (by decide)] + +lemma component_102211 : + leftComponent C A S x y z w ii 1 0 2 2 1 1 = + rightComponent C A S x y z w ii 1 0 2 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 1 1 (by decide)] + +lemma component_102212 : + leftComponent C A S x y z w ii 1 0 2 2 1 2 = + rightComponent C A S x y z w ii 1 0 2 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 1 2 (by decide)] + +lemma component_102220 : + leftComponent C A S x y z w ii 1 0 2 2 2 0 = + rightComponent C A S x y z w ii 1 0 2 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 2 0 (by decide)] + +lemma component_102221 : + leftComponent C A S x y z w ii 1 0 2 2 2 1 = + rightComponent C A S x y z w ii 1 0 2 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 2 1 (by decide)] + +lemma component_102222 : + leftComponent C A S x y z w ii 1 0 2 2 2 2 = + rightComponent C A S x y z w ii 1 0 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 0 2 2 2 2 (by decide)] + +lemma component_110000 : + leftComponent C A S x y z w ii 1 1 0 0 0 0 = + rightComponent C A S x y z w ii 1 1 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 0 0 (by decide)] + +lemma component_110001 : + leftComponent C A S x y z w ii 1 1 0 0 0 1 = + rightComponent C A S x y z w ii 1 1 0 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 0 1 (by decide)] + +lemma component_110010 : + leftComponent C A S x y z w ii 1 1 0 0 1 0 = + rightComponent C A S x y z w ii 1 1 0 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 1 0 (by decide)] + +lemma component_110012 : + leftComponent C A S x y z w ii 1 1 0 0 1 2 = + rightComponent C A S x y z w ii 1 1 0 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 1 2 (by decide)] + +lemma component_110021 : + leftComponent C A S x y z w ii 1 1 0 0 2 1 = + rightComponent C A S x y z w ii 1 1 0 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 2 1 (by decide)] + +lemma component_110022 : + leftComponent C A S x y z w ii 1 1 0 0 2 2 = + rightComponent C A S x y z w ii 1 1 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 0 2 2 (by decide)] + +lemma component_110100 : + leftComponent C A S x y z w ii 1 1 0 1 0 0 = + rightComponent C A S x y z w ii 1 1 0 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 0 0 (by decide)] + +lemma component_110102 : + leftComponent C A S x y z w ii 1 1 0 1 0 2 = + rightComponent C A S x y z w ii 1 1 0 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 0 2 (by decide)] + +lemma component_110110 : + leftComponent C A S x y z w ii 1 1 0 1 1 0 = + rightComponent C A S x y z w ii 1 1 0 1 1 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_110111 : + leftComponent C A S x y z w ii 1 1 0 1 1 1 = + rightComponent C A S x y z w ii 1 1 0 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 1 1 (by decide)] + +lemma component_110112 : + leftComponent C A S x y z w ii 1 1 0 1 1 2 = + rightComponent C A S x y z w ii 1 1 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 1 2 (by decide)] + +lemma component_110120 : + leftComponent C A S x y z w ii 1 1 0 1 2 0 = + rightComponent C A S x y z w ii 1 1 0 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 2 0 (by decide)] + +lemma component_110121 : + leftComponent C A S x y z w ii 1 1 0 1 2 1 = + rightComponent C A S x y z w ii 1 1 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 2 1 (by decide)] + +lemma component_110122 : + leftComponent C A S x y z w ii 1 1 0 1 2 2 = + rightComponent C A S x y z w ii 1 1 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 1 2 2 (by decide)] + +lemma component_110201 : + leftComponent C A S x y z w ii 1 1 0 2 0 1 = + rightComponent C A S x y z w ii 1 1 0 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 0 1 (by decide)] + +lemma component_110202 : + leftComponent C A S x y z w ii 1 1 0 2 0 2 = + rightComponent C A S x y z w ii 1 1 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 0 2 (by decide)] + +lemma component_110210 : + leftComponent C A S x y z w ii 1 1 0 2 1 0 = + rightComponent C A S x y z w ii 1 1 0 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 1 0 (by decide)] + +lemma component_110211 : + leftComponent C A S x y z w ii 1 1 0 2 1 1 = + rightComponent C A S x y z w ii 1 1 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 1 1 (by decide)] + +lemma component_110212 : + leftComponent C A S x y z w ii 1 1 0 2 1 2 = + rightComponent C A S x y z w ii 1 1 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 1 2 (by decide)] + +lemma component_110220 : + leftComponent C A S x y z w ii 1 1 0 2 2 0 = + rightComponent C A S x y z w ii 1 1 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 2 0 (by decide)] + +lemma component_110221 : + leftComponent C A S x y z w ii 1 1 0 2 2 1 = + rightComponent C A S x y z w ii 1 1 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 2 1 (by decide)] + +lemma component_110222 : + leftComponent C A S x y z w ii 1 1 0 2 2 2 = + rightComponent C A S x y z w ii 1 1 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 0 2 2 2 (by decide)] + +lemma component_111000 : + leftComponent C A S x y z w ii 1 1 1 0 0 0 = + rightComponent C A S x y z w ii 1 1 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 0 0 (by decide)] + +lemma component_111001 : + leftComponent C A S x y z w ii 1 1 1 0 0 1 = + rightComponent C A S x y z w ii 1 1 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 0 1 (by decide)] + +lemma component_111002 : + leftComponent C A S x y z w ii 1 1 1 0 0 2 = + rightComponent C A S x y z w ii 1 1 1 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 0 2 (by decide)] + +lemma component_111010 : + leftComponent C A S x y z w ii 1 1 1 0 1 0 = + rightComponent C A S x y z w ii 1 1 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 1 0 (by decide)] + +lemma component_111011 : + leftComponent C A S x y z w ii 1 1 1 0 1 1 = + rightComponent C A S x y z w ii 1 1 1 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 1 1 (by decide)] + +lemma component_111020 : + leftComponent C A S x y z w ii 1 1 1 0 2 0 = + rightComponent C A S x y z w ii 1 1 1 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 2 0 (by decide)] + +lemma component_111022 : + leftComponent C A S x y z w ii 1 1 1 0 2 2 = + rightComponent C A S x y z w ii 1 1 1 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 0 2 2 (by decide)] + +lemma component_111100 : + leftComponent C A S x y z w ii 1 1 1 1 0 0 = + rightComponent C A S x y z w ii 1 1 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 0 0 (by decide)] + +lemma component_111101 : + leftComponent C A S x y z w ii 1 1 1 1 0 1 = + rightComponent C A S x y z w ii 1 1 1 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 0 1 (by decide)] + +lemma component_111110 : + leftComponent C A S x y z w ii 1 1 1 1 1 0 = + rightComponent C A S x y z w ii 1 1 1 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 1 0 (by decide)] + +lemma component_111111 : + leftComponent C A S x y z w ii 1 1 1 1 1 1 = + rightComponent C A S x y z w ii 1 1 1 1 1 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_111112 : + leftComponent C A S x y z w ii 1 1 1 1 1 2 = + rightComponent C A S x y z w ii 1 1 1 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 1 2 (by decide)] + +lemma component_111121 : + leftComponent C A S x y z w ii 1 1 1 1 2 1 = + rightComponent C A S x y z w ii 1 1 1 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 2 1 (by decide)] + +lemma component_111122 : + leftComponent C A S x y z w ii 1 1 1 1 2 2 = + rightComponent C A S x y z w ii 1 1 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 1 2 2 (by decide)] + +lemma component_111200 : + leftComponent C A S x y z w ii 1 1 1 2 0 0 = + rightComponent C A S x y z w ii 1 1 1 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 0 0 (by decide)] + +lemma component_111202 : + leftComponent C A S x y z w ii 1 1 1 2 0 2 = + rightComponent C A S x y z w ii 1 1 1 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 0 2 (by decide)] + +lemma component_111211 : + leftComponent C A S x y z w ii 1 1 1 2 1 1 = + rightComponent C A S x y z w ii 1 1 1 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 1 1 (by decide)] + +lemma component_111212 : + leftComponent C A S x y z w ii 1 1 1 2 1 2 = + rightComponent C A S x y z w ii 1 1 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 1 2 (by decide)] + +lemma component_111220 : + leftComponent C A S x y z w ii 1 1 1 2 2 0 = + rightComponent C A S x y z w ii 1 1 1 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 2 0 (by decide)] + +lemma component_111221 : + leftComponent C A S x y z w ii 1 1 1 2 2 1 = + rightComponent C A S x y z w ii 1 1 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 2 1 (by decide)] + +lemma component_111222 : + leftComponent C A S x y z w ii 1 1 1 2 2 2 = + rightComponent C A S x y z w ii 1 1 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 1 2 2 2 (by decide)] + +lemma component_112000 : + leftComponent C A S x y z w ii 1 1 2 0 0 0 = + rightComponent C A S x y z w ii 1 1 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 0 0 (by decide)] + +lemma component_112001 : + leftComponent C A S x y z w ii 1 1 2 0 0 1 = + rightComponent C A S x y z w ii 1 1 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 0 1 (by decide)] + +lemma component_112002 : + leftComponent C A S x y z w ii 1 1 2 0 0 2 = + rightComponent C A S x y z w ii 1 1 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 0 2 (by decide)] + +lemma component_112010 : + leftComponent C A S x y z w ii 1 1 2 0 1 0 = + rightComponent C A S x y z w ii 1 1 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 1 0 (by decide)] + +lemma component_112011 : + leftComponent C A S x y z w ii 1 1 2 0 1 1 = + rightComponent C A S x y z w ii 1 1 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 1 1 (by decide)] + +lemma component_112012 : + leftComponent C A S x y z w ii 1 1 2 0 1 2 = + rightComponent C A S x y z w ii 1 1 2 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 1 2 (by decide)] + +lemma component_112020 : + leftComponent C A S x y z w ii 1 1 2 0 2 0 = + rightComponent C A S x y z w ii 1 1 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 2 0 (by decide)] + +lemma component_112021 : + leftComponent C A S x y z w ii 1 1 2 0 2 1 = + rightComponent C A S x y z w ii 1 1 2 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 0 2 1 (by decide)] + +lemma component_112100 : + leftComponent C A S x y z w ii 1 1 2 1 0 0 = + rightComponent C A S x y z w ii 1 1 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 0 0 (by decide)] + +lemma component_112101 : + leftComponent C A S x y z w ii 1 1 2 1 0 1 = + rightComponent C A S x y z w ii 1 1 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 0 1 (by decide)] + +lemma component_112102 : + leftComponent C A S x y z w ii 1 1 2 1 0 2 = + rightComponent C A S x y z w ii 1 1 2 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 0 2 (by decide)] + +lemma component_112110 : + leftComponent C A S x y z w ii 1 1 2 1 1 0 = + rightComponent C A S x y z w ii 1 1 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 1 0 (by decide)] + +lemma component_112111 : + leftComponent C A S x y z w ii 1 1 2 1 1 1 = + rightComponent C A S x y z w ii 1 1 2 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 1 1 (by decide)] + +lemma component_112112 : + leftComponent C A S x y z w ii 1 1 2 1 1 2 = + rightComponent C A S x y z w ii 1 1 2 1 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_112120 : + leftComponent C A S x y z w ii 1 1 2 1 2 0 = + rightComponent C A S x y z w ii 1 1 2 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 2 0 (by decide)] + +lemma component_112122 : + leftComponent C A S x y z w ii 1 1 2 1 2 2 = + rightComponent C A S x y z w ii 1 1 2 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 1 2 2 (by decide)] + +lemma component_112200 : + leftComponent C A S x y z w ii 1 1 2 2 0 0 = + rightComponent C A S x y z w ii 1 1 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 0 0 (by decide)] + +lemma component_112201 : + leftComponent C A S x y z w ii 1 1 2 2 0 1 = + rightComponent C A S x y z w ii 1 1 2 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 0 1 (by decide)] + +lemma component_112210 : + leftComponent C A S x y z w ii 1 1 2 2 1 0 = + rightComponent C A S x y z w ii 1 1 2 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 1 0 (by decide)] + +lemma component_112212 : + leftComponent C A S x y z w ii 1 1 2 2 1 2 = + rightComponent C A S x y z w ii 1 1 2 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 1 2 (by decide)] + +lemma component_112221 : + leftComponent C A S x y z w ii 1 1 2 2 2 1 = + rightComponent C A S x y z w ii 1 1 2 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 2 1 (by decide)] + +lemma component_112222 : + leftComponent C A S x y z w ii 1 1 2 2 2 2 = + rightComponent C A S x y z w ii 1 1 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 1 2 2 2 2 (by decide)] + +lemma component_120000 : + leftComponent C A S x y z w ii 1 2 0 0 0 0 = + rightComponent C A S x y z w ii 1 2 0 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 0 0 (by decide)] + +lemma component_120001 : + leftComponent C A S x y z w ii 1 2 0 0 0 1 = + rightComponent C A S x y z w ii 1 2 0 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 0 1 (by decide)] + +lemma component_120002 : + leftComponent C A S x y z w ii 1 2 0 0 0 2 = + rightComponent C A S x y z w ii 1 2 0 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 0 2 (by decide)] + +lemma component_120010 : + leftComponent C A S x y z w ii 1 2 0 0 1 0 = + rightComponent C A S x y z w ii 1 2 0 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 1 0 (by decide)] + +lemma component_120011 : + leftComponent C A S x y z w ii 1 2 0 0 1 1 = + rightComponent C A S x y z w ii 1 2 0 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 1 1 (by decide)] + +lemma component_120020 : + leftComponent C A S x y z w ii 1 2 0 0 2 0 = + rightComponent C A S x y z w ii 1 2 0 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 2 0 (by decide)] + +lemma component_120022 : + leftComponent C A S x y z w ii 1 2 0 0 2 2 = + rightComponent C A S x y z w ii 1 2 0 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 0 2 2 (by decide)] + +lemma component_120100 : + leftComponent C A S x y z w ii 1 2 0 1 0 0 = + rightComponent C A S x y z w ii 1 2 0 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 0 0 (by decide)] + +lemma component_120101 : + leftComponent C A S x y z w ii 1 2 0 1 0 1 = + rightComponent C A S x y z w ii 1 2 0 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 0 1 (by decide)] + +lemma component_120102 : + leftComponent C A S x y z w ii 1 2 0 1 0 2 = + rightComponent C A S x y z w ii 1 2 0 1 0 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_120110 : + leftComponent C A S x y z w ii 1 2 0 1 1 0 = + rightComponent C A S x y z w ii 1 2 0 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 1 0 (by decide)] + +lemma component_120112 : + leftComponent C A S x y z w ii 1 2 0 1 1 2 = + rightComponent C A S x y z w ii 1 2 0 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 1 2 (by decide)] + +lemma component_120120 : + leftComponent C A S x y z w ii 1 2 0 1 2 0 = + rightComponent C A S x y z w ii 1 2 0 1 2 0 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_120121 : + leftComponent C A S x y z w ii 1 2 0 1 2 1 = + rightComponent C A S x y z w ii 1 2 0 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 2 1 (by decide)] + +lemma component_120122 : + leftComponent C A S x y z w ii 1 2 0 1 2 2 = + rightComponent C A S x y z w ii 1 2 0 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 1 2 2 (by decide)] + +lemma component_120200 : + leftComponent C A S x y z w ii 1 2 0 2 0 0 = + rightComponent C A S x y z w ii 1 2 0 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 0 0 (by decide)] + +lemma component_120202 : + leftComponent C A S x y z w ii 1 2 0 2 0 2 = + rightComponent C A S x y z w ii 1 2 0 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 0 2 (by decide)] + +lemma component_120211 : + leftComponent C A S x y z w ii 1 2 0 2 1 1 = + rightComponent C A S x y z w ii 1 2 0 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 1 1 (by decide)] + +lemma component_120212 : + leftComponent C A S x y z w ii 1 2 0 2 1 2 = + rightComponent C A S x y z w ii 1 2 0 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 1 2 (by decide)] + +lemma component_120220 : + leftComponent C A S x y z w ii 1 2 0 2 2 0 = + rightComponent C A S x y z w ii 1 2 0 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 2 0 (by decide)] + +lemma component_120221 : + leftComponent C A S x y z w ii 1 2 0 2 2 1 = + rightComponent C A S x y z w ii 1 2 0 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 2 1 (by decide)] + +lemma component_120222 : + leftComponent C A S x y z w ii 1 2 0 2 2 2 = + rightComponent C A S x y z w ii 1 2 0 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 0 2 2 2 (by decide)] + +lemma component_121000 : + leftComponent C A S x y z w ii 1 2 1 0 0 0 = + rightComponent C A S x y z w ii 1 2 1 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 0 0 (by decide)] + +lemma component_121001 : + leftComponent C A S x y z w ii 1 2 1 0 0 1 = + rightComponent C A S x y z w ii 1 2 1 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 0 1 (by decide)] + +lemma component_121002 : + leftComponent C A S x y z w ii 1 2 1 0 0 2 = + rightComponent C A S x y z w ii 1 2 1 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 0 2 (by decide)] + +lemma component_121010 : + leftComponent C A S x y z w ii 1 2 1 0 1 0 = + rightComponent C A S x y z w ii 1 2 1 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 1 0 (by decide)] + +lemma component_121011 : + leftComponent C A S x y z w ii 1 2 1 0 1 1 = + rightComponent C A S x y z w ii 1 2 1 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 1 1 (by decide)] + +lemma component_121012 : + leftComponent C A S x y z w ii 1 2 1 0 1 2 = + rightComponent C A S x y z w ii 1 2 1 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 1 2 (by decide)] + +lemma component_121020 : + leftComponent C A S x y z w ii 1 2 1 0 2 0 = + rightComponent C A S x y z w ii 1 2 1 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 2 0 (by decide)] + +lemma component_121021 : + leftComponent C A S x y z w ii 1 2 1 0 2 1 = + rightComponent C A S x y z w ii 1 2 1 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 0 2 1 (by decide)] + +lemma component_121100 : + leftComponent C A S x y z w ii 1 2 1 1 0 0 = + rightComponent C A S x y z w ii 1 2 1 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 0 0 (by decide)] + +lemma component_121101 : + leftComponent C A S x y z w ii 1 2 1 1 0 1 = + rightComponent C A S x y z w ii 1 2 1 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 0 1 (by decide)] + +lemma component_121102 : + leftComponent C A S x y z w ii 1 2 1 1 0 2 = + rightComponent C A S x y z w ii 1 2 1 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 0 2 (by decide)] + +lemma component_121110 : + leftComponent C A S x y z w ii 1 2 1 1 1 0 = + rightComponent C A S x y z w ii 1 2 1 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 1 0 (by decide)] + +lemma component_121111 : + leftComponent C A S x y z w ii 1 2 1 1 1 1 = + rightComponent C A S x y z w ii 1 2 1 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 1 1 (by decide)] + +lemma component_121120 : + leftComponent C A S x y z w ii 1 2 1 1 2 0 = + rightComponent C A S x y z w ii 1 2 1 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 2 0 (by decide)] + +lemma component_121121 : + leftComponent C A S x y z w ii 1 2 1 1 2 1 = + rightComponent C A S x y z w ii 1 2 1 1 2 1 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_121122 : + leftComponent C A S x y z w ii 1 2 1 1 2 2 = + rightComponent C A S x y z w ii 1 2 1 1 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 1 2 2 (by decide)] + +lemma component_121200 : + leftComponent C A S x y z w ii 1 2 1 2 0 0 = + rightComponent C A S x y z w ii 1 2 1 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 0 0 (by decide)] + +lemma component_121201 : + leftComponent C A S x y z w ii 1 2 1 2 0 1 = + rightComponent C A S x y z w ii 1 2 1 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 0 1 (by decide)] + +lemma component_121210 : + leftComponent C A S x y z w ii 1 2 1 2 1 0 = + rightComponent C A S x y z w ii 1 2 1 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 1 0 (by decide)] + +lemma component_121212 : + leftComponent C A S x y z w ii 1 2 1 2 1 2 = + rightComponent C A S x y z w ii 1 2 1 2 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 1 2 (by decide)] + +lemma component_121221 : + leftComponent C A S x y z w ii 1 2 1 2 2 1 = + rightComponent C A S x y z w ii 1 2 1 2 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 2 1 (by decide)] + +lemma component_121222 : + leftComponent C A S x y z w ii 1 2 1 2 2 2 = + rightComponent C A S x y z w ii 1 2 1 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 1 2 2 2 (by decide)] + +lemma component_122000 : + leftComponent C A S x y z w ii 1 2 2 0 0 0 = + rightComponent C A S x y z w ii 1 2 2 0 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 0 0 (by decide)] + +lemma component_122001 : + leftComponent C A S x y z w ii 1 2 2 0 0 1 = + rightComponent C A S x y z w ii 1 2 2 0 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 0 1 (by decide)] + +lemma component_122002 : + leftComponent C A S x y z w ii 1 2 2 0 0 2 = + rightComponent C A S x y z w ii 1 2 2 0 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 0 2 (by decide)] + +lemma component_122010 : + leftComponent C A S x y z w ii 1 2 2 0 1 0 = + rightComponent C A S x y z w ii 1 2 2 0 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 1 0 (by decide)] + +lemma component_122011 : + leftComponent C A S x y z w ii 1 2 2 0 1 1 = + rightComponent C A S x y z w ii 1 2 2 0 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 1 1 (by decide)] + +lemma component_122012 : + leftComponent C A S x y z w ii 1 2 2 0 1 2 = + rightComponent C A S x y z w ii 1 2 2 0 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 1 2 (by decide)] + +lemma component_122020 : + leftComponent C A S x y z w ii 1 2 2 0 2 0 = + rightComponent C A S x y z w ii 1 2 2 0 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 2 0 (by decide)] + +lemma component_122021 : + leftComponent C A S x y z w ii 1 2 2 0 2 1 = + rightComponent C A S x y z w ii 1 2 2 0 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 2 1 (by decide)] + +lemma component_122022 : + leftComponent C A S x y z w ii 1 2 2 0 2 2 = + rightComponent C A S x y z w ii 1 2 2 0 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 0 2 2 (by decide)] + +lemma component_122100 : + leftComponent C A S x y z w ii 1 2 2 1 0 0 = + rightComponent C A S x y z w ii 1 2 2 1 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 0 0 (by decide)] + +lemma component_122101 : + leftComponent C A S x y z w ii 1 2 2 1 0 1 = + rightComponent C A S x y z w ii 1 2 2 1 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 0 1 (by decide)] + +lemma component_122102 : + leftComponent C A S x y z w ii 1 2 2 1 0 2 = + rightComponent C A S x y z w ii 1 2 2 1 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 0 2 (by decide)] + +lemma component_122110 : + leftComponent C A S x y z w ii 1 2 2 1 1 0 = + rightComponent C A S x y z w ii 1 2 2 1 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 1 0 (by decide)] + +lemma component_122111 : + leftComponent C A S x y z w ii 1 2 2 1 1 1 = + rightComponent C A S x y z w ii 1 2 2 1 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 1 1 (by decide)] + +lemma component_122112 : + leftComponent C A S x y z w ii 1 2 2 1 1 2 = + rightComponent C A S x y z w ii 1 2 2 1 1 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 1 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 1 2 (by decide)] + +lemma component_122120 : + leftComponent C A S x y z w ii 1 2 2 1 2 0 = + rightComponent C A S x y z w ii 1 2 2 1 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 2 0 (by decide)] + +lemma component_122121 : + leftComponent C A S x y z w ii 1 2 2 1 2 1 = + rightComponent C A S x y z w ii 1 2 2 1 2 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 2 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 1 2 1 (by decide)] + +lemma component_122122 : + leftComponent C A S x y z w ii 1 2 2 1 2 2 = + rightComponent C A S x y z w ii 1 2 2 1 2 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_122200 : + leftComponent C A S x y z w ii 1 2 2 2 0 0 = + rightComponent C A S x y z w ii 1 2 2 2 0 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 0 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 0 0 (by decide)] + +lemma component_122201 : + leftComponent C A S x y z w ii 1 2 2 2 0 1 = + rightComponent C A S x y z w ii 1 2 2 2 0 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 0 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 0 1 (by decide)] + +lemma component_122202 : + leftComponent C A S x y z w ii 1 2 2 2 0 2 = + rightComponent C A S x y z w ii 1 2 2 2 0 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 0 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 0 2 (by decide)] + +lemma component_122210 : + leftComponent C A S x y z w ii 1 2 2 2 1 0 = + rightComponent C A S x y z w ii 1 2 2 2 1 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 1 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 1 0 (by decide)] + +lemma component_122211 : + leftComponent C A S x y z w ii 1 2 2 2 1 1 = + rightComponent C A S x y z w ii 1 2 2 2 1 1 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 1 1 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 1 1 (by decide)] + +lemma component_122212 : + leftComponent C A S x y z w ii 1 2 2 2 1 2 = + rightComponent C A S x y z w ii 1 2 2 2 1 2 := by + simp only [leftComponent, rightComponent, Fin.sum_univ_three, numerator, Fin.val_zero, Fin.val_one, finThreeTwo, mul_zero, zero_mul, zero_add, add_zero] + ; ring + +lemma component_122220 : + leftComponent C A S x y z w ii 1 2 2 2 2 0 = + rightComponent C A S x y z w ii 1 2 2 2 2 0 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 2 0 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 2 0 (by decide)] + +lemma component_122222 : + leftComponent C A S x y z w ii 1 2 2 2 2 2 = + rightComponent C A S x y z w ii 1 2 2 2 2 2 := by + rw [leftComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 2 2 (by decide), + rightComponent_eq_zero_of_sum_ne C A S x y z w ii 1 2 2 2 2 2 (by decide)] + +include hC hA hS hy hw in +lemma block_100 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 0 0 d e f = + rightComponent C A S x y z w ii 1 0 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_100000 C A S x y z w ii + · exact component_100001 C A S x y z w ii hC hA hS hy hw + · exact component_100002 C A S x y z w ii + · exact component_100010 C A S x y z w ii + · exact component_100011 C A S x y z w ii + · exact component_100012 C A S x y z w ii + · exact component_100020 C A S x y z w ii + · exact component_100021 C A S x y z w ii + · exact component_100022 C A S x y z w ii + · exact component_100100 C A S x y z w ii + · exact component_100101 C A S x y z w ii + · exact component_100102 C A S x y z w ii + · exact component_100110 C A S x y z w ii + · exact component_100111 C A S x y z w ii + · exact component_100112 C A S x y z w ii + · exact component_100120 C A S x y z w ii + · exact component_100121 C A S x y z w ii + · exact component_100122 C A S x y z w ii + · exact component_100200 C A S x y z w ii + · exact component_100201 C A S x y z w ii + · exact component_100202 C A S x y z w ii + · exact component_100210 C A S x y z w ii + · exact component_100211 C A S x y z w ii + · exact component_100212 C A S x y z w ii + · exact component_100220 C A S x y z w ii + · exact component_100221 C A S x y z w ii + · exact component_100222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_101 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 0 1 d e f = + rightComponent C A S x y z w ii 1 0 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_101000 C A S x y z w ii + · exact component_101001 C A S x y z w ii + · exact component_101002 C A S x y z w ii hC hA hS hy hw + · exact component_101010 C A S x y z w ii + · exact component_101011 C A S x y z w ii hC hA hS hy hw hi + · exact component_101012 C A S x y z w ii + · exact component_101020 C A S x y z w ii hC hA hS hy hw hi + · exact component_101021 C A S x y z w ii + · exact component_101022 C A S x y z w ii + · exact component_101100 C A S x y z w ii + · exact component_101101 C A S x y z w ii + · exact component_101102 C A S x y z w ii + · exact component_101110 C A S x y z w ii hC hA hS hy hw hi + · exact component_101111 C A S x y z w ii + · exact component_101112 C A S x y z w ii + · exact component_101120 C A S x y z w ii + · exact component_101121 C A S x y z w ii + · exact component_101122 C A S x y z w ii + · exact component_101200 C A S x y z w ii hC hA hS hy hw + · exact component_101201 C A S x y z w ii + · exact component_101202 C A S x y z w ii + · exact component_101210 C A S x y z w ii + · exact component_101211 C A S x y z w ii + · exact component_101212 C A S x y z w ii + · exact component_101220 C A S x y z w ii + · exact component_101221 C A S x y z w ii + · exact component_101222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_102 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 0 2 d e f = + rightComponent C A S x y z w ii 1 0 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_102000 C A S x y z w ii + · exact component_102001 C A S x y z w ii + · exact component_102002 C A S x y z w ii + · exact component_102010 C A S x y z w ii + · exact component_102011 C A S x y z w ii + · exact component_102012 C A S x y z w ii hC hA hS hy hw hi + · exact component_102020 C A S x y z w ii + · exact component_102021 C A S x y z w ii hC hA hS hy hw hi + · exact component_102022 C A S x y z w ii + · exact component_102100 C A S x y z w ii + · exact component_102101 C A S x y z w ii + · exact component_102102 C A S x y z w ii + · exact component_102110 C A S x y z w ii + · exact component_102111 C A S x y z w ii hC hA hS hy hw hi + · exact component_102112 C A S x y z w ii + · exact component_102120 C A S x y z w ii + · exact component_102121 C A S x y z w ii + · exact component_102122 C A S x y z w ii + · exact component_102200 C A S x y z w ii + · exact component_102201 C A S x y z w ii hC hA hS hy hw hi + · exact component_102202 C A S x y z w ii + · exact component_102210 C A S x y z w ii hC hA hS hy hw hi + · exact component_102211 C A S x y z w ii + · exact component_102212 C A S x y z w ii + · exact component_102220 C A S x y z w ii + · exact component_102221 C A S x y z w ii + · exact component_102222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_110 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 1 0 d e f = + rightComponent C A S x y z w ii 1 1 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_110000 C A S x y z w ii + · exact component_110001 C A S x y z w ii + · exact component_110002 C A S x y z w ii hC hA hS hy hw hi + · exact component_110010 C A S x y z w ii + · exact component_110011 C A S x y z w ii hC hA hS hy hw hi + · exact component_110012 C A S x y z w ii + · exact component_110020 C A S x y z w ii hC hA hS hy hw hi + · exact component_110021 C A S x y z w ii + · exact component_110022 C A S x y z w ii + · exact component_110100 C A S x y z w ii + · exact component_110101 C A S x y z w ii hC hA hS hy hw hi + · exact component_110102 C A S x y z w ii + · exact component_110110 C A S x y z w ii + · exact component_110111 C A S x y z w ii + · exact component_110112 C A S x y z w ii + · exact component_110120 C A S x y z w ii + · exact component_110121 C A S x y z w ii + · exact component_110122 C A S x y z w ii + · exact component_110200 C A S x y z w ii hC hA hS hy hw + · exact component_110201 C A S x y z w ii + · exact component_110202 C A S x y z w ii + · exact component_110210 C A S x y z w ii + · exact component_110211 C A S x y z w ii + · exact component_110212 C A S x y z w ii + · exact component_110220 C A S x y z w ii + · exact component_110221 C A S x y z w ii + · exact component_110222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_111 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 1 1 d e f = + rightComponent C A S x y z w ii 1 1 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_111000 C A S x y z w ii + · exact component_111001 C A S x y z w ii + · exact component_111002 C A S x y z w ii + · exact component_111010 C A S x y z w ii + · exact component_111011 C A S x y z w ii + · exact component_111012 C A S x y z w ii hC hA hS hy hw + · exact component_111020 C A S x y z w ii + · exact component_111021 C A S x y z w ii hC hA hS hy hw hi + · exact component_111022 C A S x y z w ii + · exact component_111100 C A S x y z w ii + · exact component_111101 C A S x y z w ii + · exact component_111102 C A S x y z w ii hC hA hS hy hw hi + · exact component_111110 C A S x y z w ii + · exact component_111111 C A S x y z w ii + · exact component_111112 C A S x y z w ii + · exact component_111120 C A S x y z w ii hC hA hS hy hw hi + · exact component_111121 C A S x y z w ii + · exact component_111122 C A S x y z w ii + · exact component_111200 C A S x y z w ii + · exact component_111201 C A S x y z w ii hC hA hS hy hw hi + · exact component_111202 C A S x y z w ii + · exact component_111210 C A S x y z w ii hC hA hS hy hw + · exact component_111211 C A S x y z w ii + · exact component_111212 C A S x y z w ii + · exact component_111220 C A S x y z w ii + · exact component_111221 C A S x y z w ii + · exact component_111222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_112 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 1 2 d e f = + rightComponent C A S x y z w ii 1 1 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_112000 C A S x y z w ii + · exact component_112001 C A S x y z w ii + · exact component_112002 C A S x y z w ii + · exact component_112010 C A S x y z w ii + · exact component_112011 C A S x y z w ii + · exact component_112012 C A S x y z w ii + · exact component_112020 C A S x y z w ii + · exact component_112021 C A S x y z w ii + · exact component_112022 C A S x y z w ii hC hA hS hy hw + · exact component_112100 C A S x y z w ii + · exact component_112101 C A S x y z w ii + · exact component_112102 C A S x y z w ii + · exact component_112110 C A S x y z w ii + · exact component_112111 C A S x y z w ii + · exact component_112112 C A S x y z w ii + · exact component_112120 C A S x y z w ii + · exact component_112121 C A S x y z w ii hC hA hS hy hw hi + · exact component_112122 C A S x y z w ii + · exact component_112200 C A S x y z w ii + · exact component_112201 C A S x y z w ii + · exact component_112202 C A S x y z w ii hC hA hS hy hw hi + · exact component_112210 C A S x y z w ii + · exact component_112211 C A S x y z w ii hC hA hS hy hw hi + · exact component_112212 C A S x y z w ii + · exact component_112220 C A S x y z w ii hC hA hS hy hw hi + · exact component_112221 C A S x y z w ii + · exact component_112222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_120 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 2 0 d e f = + rightComponent C A S x y z w ii 1 2 0 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_120000 C A S x y z w ii + · exact component_120001 C A S x y z w ii + · exact component_120002 C A S x y z w ii + · exact component_120010 C A S x y z w ii + · exact component_120011 C A S x y z w ii + · exact component_120012 C A S x y z w ii hC hA hS hy hw hi + · exact component_120020 C A S x y z w ii + · exact component_120021 C A S x y z w ii hC hA hS hy hw hi + · exact component_120022 C A S x y z w ii + · exact component_120100 C A S x y z w ii + · exact component_120101 C A S x y z w ii + · exact component_120102 C A S x y z w ii + · exact component_120110 C A S x y z w ii + · exact component_120111 C A S x y z w ii hC hA hS hy hw hi + · exact component_120112 C A S x y z w ii + · exact component_120120 C A S x y z w ii + · exact component_120121 C A S x y z w ii + · exact component_120122 C A S x y z w ii + · exact component_120200 C A S x y z w ii + · exact component_120201 C A S x y z w ii hC hA hS hy hw hi + · exact component_120202 C A S x y z w ii + · exact component_120210 C A S x y z w ii hC hA hS hy hw hi + · exact component_120211 C A S x y z w ii + · exact component_120212 C A S x y z w ii + · exact component_120220 C A S x y z w ii + · exact component_120221 C A S x y z w ii + · exact component_120222 C A S x y z w ii + +include hC hA hS hy hw hi in +lemma block_121 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 2 1 d e f = + rightComponent C A S x y z w ii 1 2 1 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_121000 C A S x y z w ii + · exact component_121001 C A S x y z w ii + · exact component_121002 C A S x y z w ii + · exact component_121010 C A S x y z w ii + · exact component_121011 C A S x y z w ii + · exact component_121012 C A S x y z w ii + · exact component_121020 C A S x y z w ii + · exact component_121021 C A S x y z w ii + · exact component_121022 C A S x y z w ii hC hA hS hy hw + · exact component_121100 C A S x y z w ii + · exact component_121101 C A S x y z w ii + · exact component_121102 C A S x y z w ii + · exact component_121110 C A S x y z w ii + · exact component_121111 C A S x y z w ii + · exact component_121112 C A S x y z w ii hC hA hS hy hw hi + · exact component_121120 C A S x y z w ii + · exact component_121121 C A S x y z w ii + · exact component_121122 C A S x y z w ii + · exact component_121200 C A S x y z w ii + · exact component_121201 C A S x y z w ii + · exact component_121202 C A S x y z w ii hC hA hS hy hw hi + · exact component_121210 C A S x y z w ii + · exact component_121211 C A S x y z w ii hC hA hS hy hw hi + · exact component_121212 C A S x y z w ii + · exact component_121220 C A S x y z w ii hC hA hS hy hw + · exact component_121221 C A S x y z w ii + · exact component_121222 C A S x y z w ii + +include hC hA hS hy hw in +lemma block_122 (d e f : Fin 3) : + leftComponent C A S x y z w ii 1 2 2 d e f = + rightComponent C A S x y z w ii 1 2 2 d e f := by + fin_cases d <;> fin_cases e <;> fin_cases f + · exact component_122000 C A S x y z w ii + · exact component_122001 C A S x y z w ii + · exact component_122002 C A S x y z w ii + · exact component_122010 C A S x y z w ii + · exact component_122011 C A S x y z w ii + · exact component_122012 C A S x y z w ii + · exact component_122020 C A S x y z w ii + · exact component_122021 C A S x y z w ii + · exact component_122022 C A S x y z w ii + · exact component_122100 C A S x y z w ii + · exact component_122101 C A S x y z w ii + · exact component_122102 C A S x y z w ii + · exact component_122110 C A S x y z w ii + · exact component_122111 C A S x y z w ii + · exact component_122112 C A S x y z w ii + · exact component_122120 C A S x y z w ii + · exact component_122121 C A S x y z w ii + · exact component_122122 C A S x y z w ii + · exact component_122200 C A S x y z w ii + · exact component_122201 C A S x y z w ii + · exact component_122202 C A S x y z w ii + · exact component_122210 C A S x y z w ii + · exact component_122211 C A S x y z w ii + · exact component_122212 C A S x y z w ii + · exact component_122220 C A S x y z w ii + · exact component_122221 C A S x y z w ii hC hA hS hy hw + · exact component_122222 C A S x y z w ii + +end Algebra +end CriticalHoneycomb.Transfer.YangBaxter + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Basic.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ca3a9519b02c6ecd52a62a7d2a7c0448772310f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Basic.lean @@ -0,0 +1,239 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +inductive Vertex where + | up (i j : ℤ) + | down (i j : ℤ) + deriving DecidableEq + +noncomputable def position : Vertex → ℝ × ℝ + | .up i j => ((i : ℝ) + (j : ℝ) / 2, + ((j : ℝ) + 1 / 3) * (Real.sqrt 3 / 2)) + | .down i j => ((i : ℝ) + (j : ℝ) / 2 + 1 / 2, + ((j : ℝ) + 2 / 3) * (Real.sqrt 3 / 2)) + +def adjacent : Vertex → Vertex → Prop + | .up i j, .down k l => + (k = i ∧ l = j - 1) ∨ (k = i ∧ l = j) ∨ (k = i - 1 ∧ l = j) + | .down k l, .up i j => + (k = i ∧ l = j - 1) ∨ (k = i ∧ l = j) ∨ (k = i - 1 ∧ l = j) + | _, _ => False + +noncomputable def criticalActivity : ℝ := (2 * Real.cos (Real.pi / 8))⁻¹ + +def neighbor (v : Vertex) (k : Fin 3) : Vertex := + match v with + | .up i j => if k = 0 then .down i (j - 1) + else if k = 1 then .down i j else .down (i - 1) j + | .down i j => if k = 0 then .up i (j + 1) + else if k = 1 then .up i j else .up (i + 1) j + +abbrev Germ := Vertex × Fin 3 + +def outgoingSlot (g : Germ) (b : Bool) : Fin 3 := + g.2 + (if b then 2 else 1) + +def advance (g : Germ) (b : Bool) : Germ := + (neighbor g.1 (outgoingSlot g b), outgoingSlot g b) + +def Stopped : Finset Vertex → Germ → List Bool → Prop + | D, g, [] => g.1 ∉ D + | D, g, b :: w => g.1 ∈ D ∧ Stopped (D.erase g.1) (advance g b) w + +def leaves (D : Finset Vertex) (g : Germ) : Finset (List Bool) := + if g.1 ∈ D then + ((leaves (D.erase g.1) (advance g true)).image (List.cons true)) ∪ + ((leaves (D.erase g.1) (advance g false)).image (List.cons false)) + else {[]} +termination_by D.card +decreasing_by all_goals exact Finset.card_erase_lt_of_mem (by assumption) + +noncomputable def turnAngle (b : Bool) : ℝ := + if b then Real.pi / 3 else -(Real.pi / 3) + +noncomputable def stepWeight (b : Bool) : ℂ := + (criticalActivity : ℂ) * Complex.exp (((3 / 8 : ℝ) * turnAngle b : ℝ) * Complex.I) + +noncomputable def wordWeight (w : List Bool) : ℂ := (w.map stepWeight).prod + +def traced : Germ → List Bool → List Vertex + | _, [] => [] + | g, b :: w => g.1 :: traced (advance g b) w + +def terminalGerm : Germ → List Bool → Germ + | g, [] => g + | g, b :: w => terminalGerm (advance g b) w + +noncomputable def explorationTotal (D : Finset Vertex) (v : Vertex) : ℂ := + ∑ k : Fin 3, ∑ w ∈ leaves (D.erase v) (neighbor v k, k), wordWeight w + +@[simp] theorem neighbor_neighbor (v : Vertex) (k : Fin 3) : + neighbor (neighbor v k) k = v := by + cases v <;> fin_cases k <;> simp [neighbor] + +theorem adjacent_neighbor (v : Vertex) (k : Fin 3) : adjacent v (neighbor v k) := by + cases v <;> fin_cases k <;> simp [neighbor, adjacent] + +theorem neighbor_injective (v : Vertex) : Function.Injective (neighbor v) := by + intro a b hab + cases v <;> fin_cases a <;> fin_cases b <;> simp_all [neighbor] <;> omega + +@[simp] theorem advance_adjacent (g : Germ) (b : Bool) : + adjacent g.1 (advance g b).1 := adjacent_neighbor _ _ + +theorem advance_not_backtracking (g : Germ) (b : Bool) : + (advance g b).1 ≠ neighbor g.1 g.2 := by + intro heq + have hk := neighbor_injective g.1 heq + obtain ⟨v, k⟩ := g + fin_cases k <;> cases b <;> simp [outgoingSlot] at hk + +@[simp] theorem wordWeight_nil : wordWeight [] = 1 := rfl +@[simp] theorem wordWeight_cons (b : Bool) (w : List Bool) : + wordWeight (b :: w) = stepWeight b * wordWeight w := rfl + +theorem critical_cos_pos : 0 < Real.cos (Real.pi / 8) := by + apply Real.cos_pos_of_mem_Ioo + constructor <;> linarith [Real.pi_pos] + +theorem stepWeight_sum : stepWeight true + stepWeight false = 1 := by + have hc : Real.cos (Real.pi / 8) ≠ 0 := ne_of_gt critical_cos_pos + simp only [stepWeight, turnAngle, Bool.false_eq_true, ite_false, ite_true] + have ht : (3 / 8 : ℝ) * (Real.pi / 3) = Real.pi / 8 := by ring + have hf : (3 / 8 : ℝ) * -(Real.pi / 3) = -(Real.pi / 8) := by ring + rw [ht, hf, Complex.exp_ofReal_mul_I, Complex.exp_ofReal_mul_I] + simp only [Real.cos_neg, Real.sin_neg, Complex.ofReal_neg] + calc + _ = ((criticalActivity * (2 * Real.cos (Real.pi / 8)) : ℝ) : ℂ) := by + push_cast + ring + _ = 1 := by + have hw : criticalActivity * (2 * Real.cos (Real.pi / 8)) = 1 := + inv_mul_cancel₀ (mul_ne_zero (by norm_num) hc) + rw [hw] + norm_num + +theorem mem_leaves_iff (D : Finset Vertex) (g : Germ) (w : List Bool) : + w ∈ leaves D g ↔ Stopped D g w := by + induction w generalizing D g with + | nil => + rw [leaves] + by_cases h : g.1 ∈ D <;> simp [h, Stopped] + | cons b w ih => + rw [leaves] + by_cases h : g.1 ∈ D + · cases b <;> simp [h, Stopped, ih] + · simp [h, Stopped] + +theorem stopped_traced (D : Finset Vertex) (g : Germ) (w : List Bool) + (hw : Stopped D g w) : + (traced g w).Nodup ∧ ∀ v ∈ traced g w, v ∈ D := by + induction w generalizing D g with + | nil => simp [traced] + | cons b w ih => + obtain ⟨hg, hw⟩ := hw + obtain ⟨hn, hD⟩ := ih (D.erase g.1) (advance g b) hw + constructor + · simp only [traced, List.nodup_cons] + refine ⟨?_, hn⟩ + intro hmem + exact (Finset.mem_erase.mp (hD g.1 hmem)).1 rfl + · intro v hv + simp only [traced, List.mem_cons] at hv + rcases hv with rfl | hv + · exact hg + · exact (Finset.mem_erase.mp (hD v hv)).2 + +theorem traced_length (g : Germ) (w : List Bool) : (traced g w).length = w.length := by + induction w generalizing g with + | nil => rfl + | cons b w ih => simp only [traced, List.length_cons, ih] + +theorem trace_chain (g : Germ) (w : List Bool) : + (traced g w ++ [(terminalGerm g w).1]).IsChain adjacent := by + induction w generalizing g with + | nil => simp [traced, terminalGerm] + | cons b w ih => + simp only [traced, List.cons_append, terminalGerm] + apply List.IsChain.cons (ih (advance g b)) + cases w with + | nil => simp [traced, terminalGerm, advance_adjacent] + | cons c w => simp [traced, terminalGerm, advance_adjacent] + +theorem wordWeight_physical (w : List Bool) : + wordWeight w = (criticalActivity : ℂ) ^ w.length * + Complex.exp (((3 / 8 : ℝ) * (w.map turnAngle).sum : ℝ) * Complex.I) := by + induction w with + | nil => simp [wordWeight] + | cons b w ih => + simp only [wordWeight_cons, ih, List.length_cons, List.map_cons, List.sum_cons] + simp only [stepWeight, mul_add, Complex.ofReal_add, Complex.ofReal_mul] + rw [add_mul, Complex.exp_add, pow_succ] + ring + +theorem sum_cons_image (s : Finset (List Bool)) (b : Bool) : + ∑ w ∈ s.image (List.cons b), wordWeight w = + stepWeight b * ∑ w ∈ s, wordWeight w := by + rw [Finset.sum_image] + · simp only [wordWeight_cons, Finset.mul_sum] + · intro a ha c hc hac + exact List.cons.inj hac |>.2 + +theorem disjoint_cons_images (s t : Finset (List Bool)) : + Disjoint (s.image (List.cons true)) (t.image (List.cons false)) := by + apply Finset.disjoint_left.mpr + intro w hs ht + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hs + obtain ⟨b, hb, heq⟩ := Finset.mem_image.mp ht + exact Bool.false_ne_true (List.cons.inj heq).1 + +theorem leaf_balance (D : Finset Vertex) (g : Germ) : + ∑ w ∈ leaves D g, wordWeight w = 1 := by + induction D using Finset.strongInductionOn generalizing g with + | _ D ih => + rw [leaves] + by_cases hg : g.1 ∈ D + · simp only [hg, ite_true] + rw [Finset.sum_union (disjoint_cons_images _ _), sum_cons_image, sum_cons_image] + have hers : D.erase g.1 ⊂ D := Finset.erase_ssubset hg + rw [ih _ hers _, ih _ hers _] + simpa only [mul_one] using stepWeight_sum + · simp [hg] + +theorem visit_exploration_balance (D : Finset Vertex) (v : Vertex) (_hv : v ∈ D) : + explorationTotal D v = 3 := by + simp [explorationTotal, leaf_balance] + +noncomputable def complexPosition (v : Vertex) : ℂ := + (position v).1 + (position v).2 * Complex.I + +theorem exp_turnAngle (b : Bool) : + Complex.exp ((turnAngle b : ℝ) * Complex.I) = + (1 / 2 : ℂ) + (if b then 1 else -1) * (Real.sqrt 3 : ℂ) / 2 * Complex.I := by + cases b <;> simp only [turnAngle, Bool.false_eq_true, ite_false, ite_true] <;> + rw [Complex.exp_ofReal_mul_I] <;> + simp [Real.cos_pi_div_three, Real.sin_pi_div_three] + ring + +theorem advance_rotation (g : Germ) (b : Bool) : + complexPosition (advance g b).1 - complexPosition g.1 = + Complex.exp ((turnAngle b : ℝ) * Complex.I) * + (complexPosition g.1 - complexPosition (neighbor g.1 g.2)) := by + rw [exp_turnAngle] + obtain ⟨v, k⟩ := g + have hsq : ((Real.sqrt 3 : ℝ) : ℂ) ^ 2 = 3 := by + exact_mod_cast Real.sq_sqrt (show (0 : ℝ) ≤ 3 by norm_num) + cases v <;> fin_cases k <;> cases b <;> + simp [advance, outgoingSlot, neighbor, complexPosition, position] <;> + ring_nf <;> simp [hsq] <;> ring + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryArcs.lean b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryArcs.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c9de648ac0704e34cfad26cc4298889bb012851 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryArcs.lean @@ -0,0 +1,253 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.BoundaryContainment +import OAI.Combinatorics.HoneycombCorridor.CycleSplice + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +@[simp] theorem turnUnits_append (u w : List Bool) : + turnUnits (u ++ w) = turnUnits u + turnUnits w := by + simp [turnUnits] + +@[simp] theorem reverse_stem_false (g : Germ) : + reverseGerm (stemGerm g false) = advance g true := rfl + +@[simp] theorem reverse_advance_true (g : Germ) : + reverseGerm (advance g true) = stemGerm g false := by + rw [← reverse_stem_false,reverseGerm_reverseGerm] + +theorem chord_close_trace (g h e : Germ) (B w : List Bool) + (hb : terminalGerm h (false :: B) = g) + (he : terminalGerm e w = stemGerm h false) : + traced e (w ++ (true :: B) ++ [true]) = + traced e w ++ (traced h (false :: B) ++ [g.1]) := by + simp only [traced_append,terminalGerm_append,he] + have htr := stem_forward_trace h false B + have htm := stem_forward_terminal h false B + simp only [Bool.not_false] at htr htm + rw [htr,htm,hb] + simp [traced,List.append_assoc] + +theorem chord_close_terminal (g h e : Germ) (B w : List Bool) + (hb : terminalGerm h (false :: B) = g) + (he : terminalGerm e w = stemGerm h false) (he' : e = advance g true) : + terminalGerm e (w ++ (true :: B) ++ [true]) = e := by + simp only [terminalGerm_append,he] + have htm := stem_forward_terminal h false B + simp only [Bool.not_false] at htm + rw [htm,hb] + simpa only [terminalGerm] using he'.symm + +theorem chord_close_turn (g : Germ) (A B : List Bool) (e : Germ) (w : List Bool) + (hN : (traced g ((false :: A) ++ (false :: B))).Nodup) + (hc : terminalGerm g ((false :: A) ++ (false :: B)) = g) + (he : e = advance g true) + (ht : terminalGerm e w = stemGerm (terminalGerm g (false :: A)) false) + (hwN : (traced e w).Nodup) + (hd : ∀ v ∈ traced e w, v ∉ traced g ((false :: A) ++ (false :: B))) : + turnUnits w + turnUnits (false :: B) + 3 = 6 ∨ + turnUnits w + turnUnits (false :: B) + 3 = -6 := by + let h := terminalGerm g (false :: A) + have hb : terminalGerm h (false :: B) = g := by + exact (terminalGerm_append g (false :: A) (false :: B)).symm.trans hc + have hN' : (g.1 :: (traced (advance g false) A ++ traced h (false :: B))).Nodup := by + simpa only [h,traced_append,traced,terminalGerm,List.cons_append] using hN + have hgnot : g.1 ∉ traced h (false :: B) := by + intro hm + exact (List.nodup_cons.mp hN').1 (List.mem_append_right _ hm) + have hBN : (traced h (false :: B)).Nodup := + (List.nodup_append.mp (List.nodup_cons.mp hN').2).2.1 + have hBN' : (traced h (false :: B) ++ [g.1]).Nodup := by + apply List.nodup_append.mpr + refine ⟨hBN,by simp,?_⟩ + intro a ha b hb hab + have hb' := List.mem_singleton.mp hb + exact hgnot ((hab.trans hb') ▸ ha) + have hsub : ∀ v ∈ traced h (false :: B) ++ [g.1], + v ∈ traced g ((false :: A) ++ (false :: B)) := by + intro v hv + rcases List.mem_append.mp hv with hv | hv + · rw [traced_append] + exact List.mem_append_right _ hv + · have heq := List.mem_singleton.mp hv + subst v + simp [traced_append,traced] + have hjoinN : (traced e (w ++ (true :: B) ++ [true])).Nodup := by + rw [chord_close_trace g h e B w hb ht] + apply List.nodup_append.mpr + refine ⟨hwN,hBN',?_⟩ + intro a ha b hb hab + subst b + exact hd a ha (hsub a hb) + have hjoinC := chord_close_terminal g h e B w hb ht he + have hn : w ++ (true :: B) ++ [true] ≠ [] := by simp + have h := simple_polygon_turning e _ hn hjoinN hjoinC + have heq : turnUnits (w ++ (true :: B) ++ [true]) = + turnUnits w + turnUnits (false :: B) + 3 := by + simp [turnUnit,turnUnits] + ring + rwa [heq] at h + +theorem cycle_chord_turn_bound (g : Germ) (A B : List Bool) (e : Germ) (w : List Bool) + (hN : (traced g ((false :: A) ++ (false :: B))).Nodup) + (hc : terminalGerm g ((false :: A) ++ (false :: B)) = g) + (he : e = advance g true) + (ht : terminalGerm e w = stemGerm (terminalGerm g (false :: A)) false) + (hwN : (traced e w).Nodup) + (hd : ∀ v ∈ traced e w, v ∉ traced g ((false :: A) ++ (false :: B))) + (hturn : turnUnits ((false :: A) ++ (false :: B)) = 6) + (hA : 0 ≤ turnUnits (false :: A)) (hB : 0 ≤ turnUnits (false :: B)) : + -3 ≤ turnUnits w ∧ turnUnits w ≤ 3 := by + have h₁ := chord_close_turn g A B e w hN hc he ht hwN hd + let h := terminalGerm g (false :: A) + let e' := reverseGerm (terminalGerm e w) + have hrot := closed_word_rotate g (false :: A) (false :: B) hN hc + have hback : terminalGerm h (false :: B) = g := by + exact (terminalGerm_append g (false :: A) (false :: B)).symm.trans hc + have he' : e' = advance h true := by simp only [e',ht,reverse_stem_false]; rfl + have ht' : terminalGerm e' (reverseTurns w) = + stemGerm (terminalGerm h (false :: B)) false := by + rw [hback] + simp only [e',terminalGerm_reverse,he,reverse_advance_true] + have hwN' : (traced e' (reverseTurns w)).Nodup := by + simpa only [e',traced_reverse,List.nodup_reverse] using hwN + have hd' : ∀ v ∈ traced e' (reverseTurns w), + v ∉ traced h ((false :: B) ++ (false :: A)) := by + intro v hv hmem + have hv' : v ∈ traced e w := by simpa only [e',traced_reverse,List.mem_reverse] using hv + apply hd v hv' + rw [traced_append,hback] at hmem + rw [traced_append] + exact List.mem_append.mpr (List.mem_append.mp hmem |>.symm) + have h₂ := chord_close_turn h B A e' (reverseTurns w) hrot.1 hrot.2.1 + he' ht' hwN' hd' + rw [turnUnits_reverse] at h₂ + rw [turnUnits_append] at hturn + omega + + + +theorem faceBoundaryWord_append (S : Finset FaceIndex) (g : FaceBoundary S) (m n : ℕ) : + faceBoundaryWord S g (m+n) = faceBoundaryWord S g m ++ + faceBoundaryWord S ((faceBoundaryNext S)^[m] g) n := by + induction m generalizing g with + | zero => simp [faceBoundaryWord] + | succ m ih => + simp only [Nat.succ_add,faceBoundaryWord,List.cons_append,Function.iterate_succ_apply] + rw [ih] + +@[simp] theorem boundary_stem_port (v : Vertex) (k : Fin 3) : + stemGerm (v,k+1) false = (v,k) := by + fin_cases k <;> simp [stemGerm,unusedSlot,outgoingSlot] + +@[simp] theorem boundary_inward_port (v : Vertex) (k : Fin 3) : + advance (v,k+1) true = reverseGerm (v,k) := by + rw [← reverse_stem_false,boundary_stem_port] + +theorem convex_distinct_outer_vertices (D : Finset Vertex) (hD : AdmissiblyConvex D) + (e : Germ × List Bool) (he : IsExcursion D e) : + (terminalGerm e.1 e.2).1 ≠ (reverseGerm e.1).1 := by + intro hv + have hstart := (outside_boundary_germ D hD (reverseGerm e.1).1 e.1.2 he.2.1 + (by simpa only [reverseGerm,neighbor_neighbor] using he.1)).1 + have hend := (outside_boundary_germ D hD (terminalGerm e.1 e.2).1 + (terminalGerm e.1 e.2).2 he.2.2.2 he.reverse.1).1 + rw [hv] at hend + have hk := faceBoundary_germ_unique (starFaces D) (reverseGerm e.1).1 + ((terminalGerm e.1 e.2).2+1) (e.1.2+1) hend hstart + have hk' : (terminalGerm e.1 e.2).2 = e.1.2 := add_right_cancel hk + have heq : terminalGerm e.1 e.2 = reverseGerm e.1 := Prod.ext hv hk' + apply he.distinct_ports + rw [heq,reverseGerm_reverseGerm] + +theorem boundary_chord_turn_bound (D : Finset Vertex) (hD : AdmissiblyConvex D) + (g : FaceBoundary (starFaces D)) (n : ℕ) + (hN : (traced g.val (faceBoundaryWord (starFaces D) g n)).Nodup) + (hc : terminalGerm g.val (faceBoundaryWord (starFaces D) g n) = g.val) + (hg : faceBoundaryTurn (starFaces D) g.val = false) + (i : ℕ) (hi : 0 < i) (hin : i < n) + (hgi : faceBoundaryTurn (starFaces D) ((faceBoundaryNext (starFaces D))^[i] g).val = false) + (e : Germ) (w : List Bool) (he : e = advance g.val true) + (ht : terminalGerm e w = stemGerm ((faceBoundaryNext (starFaces D))^[i] g).val false) + (hwN : (traced e w).Nodup) (hd : ∀ v ∈ traced e w, v ∈ D) : + -3 ≤ turnUnits w ∧ turnUnits w ≤ 3 := by + let G := (faceBoundaryNext (starFaces D))^[i] g + have hn : 0 < n := lt_trans hi hin + have hperiod : (faceBoundaryNext (starFaces D))^[n] g = g := by + apply Subtype.ext + rwa [faceBoundaryWord_terminal] at hc + have hend : (faceBoundaryNext (starFaces D))^[n-i] G = g := by + simp only [G,← Function.iterate_add_apply] + rw [Nat.sub_add_cancel (Nat.le_of_lt hin),hperiod] + have hAi := star_boundary_word_charge D hD g i + have hBi := star_boundary_word_charge D hD G (n-i) + simp only [G,hgi,hg,hend,boundaryCharge,Bool.false_eq_true,ite_false,sub_self] at hAi hBi + obtain ⟨a,hai⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hi) + obtain ⟨b,hbi⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt (Nat.sub_pos_of_lt hin)) + let A := faceBoundaryWord (starFaces D) (faceBoundaryNext (starFaces D) g) a + let B := faceBoundaryWord (starFaces D) (faceBoundaryNext (starFaces D) G) b + have hA : faceBoundaryWord (starFaces D) g i = false :: A := by + rw [hai,faceBoundaryWord,hg] + have hB : faceBoundaryWord (starFaces D) G (n-i) = false :: B := by + rw [hbi,faceBoundaryWord,hgi] + have hW : faceBoundaryWord (starFaces D) g n = (false :: A) ++ (false :: B) := by + conv_lhs => rw [← Nat.add_sub_cancel' (Nat.le_of_lt hin)] + rw [faceBoundaryWord_append,hA,hB] + have hterminal : terminalGerm g.val (false :: A) = G.val := by + rw [← hA,faceBoundaryWord_terminal] + apply cycle_chord_turn_bound g.val A B e w (by rwa [← hW]) (by rwa [← hW]) he + (by rwa [hterminal]) hwN + · intro v hv hm + rw [← hW] at hm + exact star_boundary_trace_outside D g n v hm (hd v hv) + · rw [← hW] + exact star_boundary_cycle_turn D hD g n hn hN hc + · rwa [← hA] + · rwa [← hB] + + + +theorem convex_excursion_turn_bound (D : Finset Vertex) (hD : AdmissiblyConvex D) + (e : Germ × List Bool) (he : IsExcursion D e) : + -3 ≤ turnUnits e.2 ∧ turnUnits e.2 ≤ 3 := by + classical + have hs := outside_boundary_germ D hD (reverseGerm e.1).1 e.1.2 he.2.1 + (by simpa only [reverseGerm,neighbor_neighbor] using he.1) + let g : FaceBoundary (starFaces D) := ⟨((reverseGerm e.1).1,e.1.2+1),hs.1⟩ + have hge : e.1 = advance g.val true := by + change e.1 = advance ((reverseGerm e.1).1,e.1.2+1) true + rw [boundary_inward_port] + exact (reverseGerm_reverseGerm e.1).symm + obtain ⟨n,hn,hN,hc⟩ := faceBoundary_closed_word (starFaces D) g + obtain ⟨hwN,hwD⟩ := stopped_traced D e.1 e.2 he.2.2.1 + have hm := star_boundary_endpoint D hD g n hn hN hc hs.2 e.1 e.2 hge hwD + he.2.2.2 he.reverse.1 + rw [faceBoundaryWord_traced,List.mem_ofFn] at hm + obtain ⟨i,hi⟩ := hm + have hi0 : 0 < i.val := by + by_contra hn + have hz : i.val = 0 := by omega + have hv : (terminalGerm e.1 e.2).1 = (reverseGerm e.1).1 := by + simpa only [hz,Function.iterate_zero,id_eq,g] using hi.symm + exact convex_distinct_outer_vertices D hD e he hv + have hu := outside_boundary_germ D hD (terminalGerm e.1 e.2).1 + (terminalGerm e.1 e.2).2 he.2.2.2 he.reverse.1 + let u : FaceBoundary (starFaces D) := + ⟨((terminalGerm e.1 e.2).1,(terminalGerm e.1 e.2).2+1),hu.1⟩ + have hiu : (faceBoundaryNext (starFaces D))^[i.val] g = u := + faceBoundary_vertex_injective (starFaces D) hi + apply boundary_chord_turn_bound D hD g n hN hc hs.2 i.val hi0 i.isLt + (by rw [hiu]; exact hu.2) e.1 e.2 hge _ hwN hwD + rw [hiu] + change terminalGerm e.1 e.2 = stemGerm + ((terminalGerm e.1 e.2).1,(terminalGerm e.1 e.2).2+1) false + exact (boundary_stem_port _ _).symm + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryCharge.lean b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryCharge.lean new file mode 100644 index 0000000000000000000000000000000000000000..4636db9377de892dd1b6374bef879e742d48e74b --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryCharge.lean @@ -0,0 +1,187 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.FaceBoundary + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +@[simp] theorem faceBoundaryTurn_false (S : Finset FaceIndex) (g : Germ) : + faceBoundaryTurn S g = false ↔ leftFace (g.1,g.2+1) ∈ S := by + classical + simp [faceBoundaryTurn] + +theorem star_boundary_outside (D : Finset Vertex) (g : FaceBoundary (starFaces D)) : + g.val.1 ∉ D := by + intro hv + exact g.property.1 (incident_mem_starFaces hv g.val.2) + +theorem outside_boundary_germ (D : Finset Vertex) (hD : AdmissiblyConvex D) + (v : Vertex) (k : Fin 3) (hv : v ∉ D) (hn : neighbor v k ∈ D) : + OnFaceBoundary (starFaces D) (v,k+1) ∧ + faceBoundaryTurn (starFaces D) (v,k+1) = false := by + have hR : rightFace (v,k) ∈ starFaces D := incident_mem_starFaces hn k + have hL : leftFace (v,k) ∈ starFaces D := by + have h := incident_mem_starFaces hn (k+2) + simpa only [← rightFace_prev,rightFace,reverseGerm,neighbor_neighbor] using h + have hO := outside_opposite_face D hD v k hv hn + constructor + · refine ⟨hO,?_⟩ + rw [rightFace_prev] + convert hL using 1 + congr 2 + fin_cases k <;> decide + · rw [faceBoundaryTurn_false] + simpa only [rightFace_prev,add_assoc,Fin.reduceAdd] using hR + +theorem star_boundary_no_double_negative (D : Finset Vertex) (hD : AdmissiblyConvex D) + (g : FaceBoundary (starFaces D)) (hg : faceBoundaryTurn (starFaces D) g.val = false) : + faceBoundaryTurn (starFaces D) (faceBoundaryNext (starFaces D) g).val = true := by + classical + by_contra hn + have hn' : faceBoundaryTurn (starFaces D) (faceBoundaryNext (starFaces D) g).val = + false := by + cases he : (faceBoundaryTurn (starFaces D) + (faceBoundaryNext (starFaces D) g).val) <;> simp_all + obtain ⟨lo,hi,hbox⟩ := admissiblyConvex_box D hD + obtain ⟨r,hr,hr'⟩ := (mem_starFaces D _).mp g.property.2 + have hs_mem := (faceBoundaryTurn_false _ _).mp hn' + have hs_mem' : leftFace (neighbor g.val.1 (g.val.2+1),g.val.2+2) ∈ starFaces D := by + simpa [faceBoundaryNext,hg,advance,outgoingSlot,add_assoc] using hs_mem + obtain ⟨s,hs,hs'⟩ := (mem_starFaces D _).mp hs_mem' + rcases box_two_faces lo hi g.val.1 r s g.val.2 hr hs ((hbox _).mp hr') + ((hbox _).mp hs') with h | h + · exact star_boundary_outside D g ((hbox _).mpr h) + · apply star_boundary_outside D (faceBoundaryNext (starFaces D) g) + simpa only [faceBoundaryNext,advance,hg,outgoingSlot,Bool.false_eq_true,ite_false] + using (hbox _).mpr h + +noncomputable def boundaryCharge (S : Finset FaceIndex) (g : FaceBoundary S) : ℤ := + if faceBoundaryTurn S g.val then 0 else 1 + +theorem star_boundary_turn_charge (D : Finset Vertex) (hD : AdmissiblyConvex D) + (g : FaceBoundary (starFaces D)) : + boundaryCharge (starFaces D) (faceBoundaryNext (starFaces D) g) - + boundaryCharge (starFaces D) g ≤ turnUnit (faceBoundaryTurn (starFaces D) g.val) := by + cases hg : faceBoundaryTurn (starFaces D) g.val + · have hn := star_boundary_no_double_negative D hD g hg + simp [boundaryCharge,hg,hn,turnUnit] + · cases hn : faceBoundaryTurn (starFaces D) (faceBoundaryNext (starFaces D) g).val <;> + simp [boundaryCharge,hg,hn,turnUnit] + +theorem star_boundary_word_charge (D : Finset Vertex) (hD : AdmissiblyConvex D) + (g : FaceBoundary (starFaces D)) (n : ℕ) : + boundaryCharge (starFaces D) ((faceBoundaryNext (starFaces D))^[n] g) - + boundaryCharge (starFaces D) g ≤ turnUnits (faceBoundaryWord (starFaces D) g n) := by + induction n generalizing g with + | zero => simp [faceBoundaryWord,turnUnits] + | succ n ih => + have h₁ := star_boundary_turn_charge D hD g + have h₂ := ih (faceBoundaryNext (starFaces D) g) + simp only [faceBoundaryWord,turnUnits,List.map_cons,List.sum_cons, + Function.iterate_succ_apply] at * + omega + +theorem star_boundary_cycle_turn (D : Finset Vertex) (hD : AdmissiblyConvex D) + (g : FaceBoundary (starFaces D)) (n : ℕ) (hn : 0 < n) + (hN : (traced g.val (faceBoundaryWord (starFaces D) g n)).Nodup) + (hc : terminalGerm g.val (faceBoundaryWord (starFaces D) g n) = g.val) : + turnUnits (faceBoundaryWord (starFaces D) g n) = 6 := by + have hne : faceBoundaryWord (starFaces D) g n ≠ [] := by + intro he + have hl := faceBoundaryWord_length (starFaces D) g n + rw [he] at hl + simp only [List.length_nil] at hl + omega + have h := star_boundary_word_charge D hD g n + have he : ((faceBoundaryNext (starFaces D))^[n] g) = g := by + apply Subtype.ext + rwa [faceBoundaryWord_terminal] at hc + rw [he,sub_self] at h + rcases simple_polygon_turning g.val _ hne hN hc with h' | h' <;> omega + +theorem box_face_row_interval_0 (lo hi : Fin 3 → ℤ) (i₁ i i₂ j : ℤ) + (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) (s : Vertex) + (hs : s ∈ faceVertices (i₂,j)) + (hr' : BoxMem lo hi (.up i₁ j)) (hs' : BoxMem lo hi s) : + ∃ v ∈ faceVertices (i,j), BoxMem lo hi v := by + simp only [faceVertices,Finset.mem_insert,Finset.mem_singleton] at hs + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [faceVertices,BoxMem,Fin.forall_fin_succ,boxIndex] <;> omega + +theorem box_face_row_interval_1 (lo hi : Fin 3 → ℤ) (i₁ i i₂ j : ℤ) + (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) (s : Vertex) + (hs : s ∈ faceVertices (i₂,j)) + (hr' : BoxMem lo hi (.down i₁ (j-1))) (hs' : BoxMem lo hi s) : + ∃ v ∈ faceVertices (i,j), BoxMem lo hi v := by + simp only [faceVertices,Finset.mem_insert,Finset.mem_singleton] at hs + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [faceVertices,BoxMem,Fin.forall_fin_succ,boxIndex] <;> omega + +theorem box_face_row_interval_2 (lo hi : Fin 3 → ℤ) (i₁ i i₂ j : ℤ) + (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) (s : Vertex) + (hs : s ∈ faceVertices (i₂,j)) + (hr' : BoxMem lo hi (.up (i₁+1) (j-1))) (hs' : BoxMem lo hi s) : + ∃ v ∈ faceVertices (i,j), BoxMem lo hi v := by + simp only [faceVertices,Finset.mem_insert,Finset.mem_singleton] at hs + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [faceVertices,BoxMem,Fin.forall_fin_succ,boxIndex] <;> omega + +theorem box_face_row_interval_3 (lo hi : Fin 3 → ℤ) (i₁ i i₂ j : ℤ) + (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) (s : Vertex) + (hs : s ∈ faceVertices (i₂,j)) + (hr' : BoxMem lo hi (.down i₁ j)) (hs' : BoxMem lo hi s) : + ∃ v ∈ faceVertices (i,j), BoxMem lo hi v := by + simp only [faceVertices,Finset.mem_insert,Finset.mem_singleton] at hs + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [faceVertices,BoxMem,Fin.forall_fin_succ,boxIndex] <;> omega + +theorem box_face_row_interval_4 (lo hi : Fin 3 → ℤ) (i₁ i i₂ j : ℤ) + (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) (s : Vertex) + (hs : s ∈ faceVertices (i₂,j)) + (hr' : BoxMem lo hi (.up (i₁+1) j)) (hs' : BoxMem lo hi s) : + ∃ v ∈ faceVertices (i,j), BoxMem lo hi v := by + simp only [faceVertices,Finset.mem_insert,Finset.mem_singleton] at hs + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [faceVertices,BoxMem,Fin.forall_fin_succ,boxIndex] <;> omega + +theorem box_face_row_interval_5 (lo hi : Fin 3 → ℤ) (i₁ i i₂ j : ℤ) + (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) (s : Vertex) + (hs : s ∈ faceVertices (i₂,j)) + (hr' : BoxMem lo hi (.down (i₁+1) (j-1))) (hs' : BoxMem lo hi s) : + ∃ v ∈ faceVertices (i,j), BoxMem lo hi v := by + simp only [faceVertices,Finset.mem_insert,Finset.mem_singleton] at hs + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [faceVertices,BoxMem,Fin.forall_fin_succ,boxIndex] <;> omega + +theorem box_face_row_interval (lo hi : Fin 3 → ℤ) (i₁ i i₂ j : ℤ) + (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) (r s : Vertex) + (hr : r ∈ faceVertices (i₁,j)) (hs : s ∈ faceVertices (i₂,j)) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + ∃ v ∈ faceVertices (i,j), BoxMem lo hi v := by + simp only [faceVertices,Finset.mem_insert,Finset.mem_singleton] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl + · exact box_face_row_interval_0 lo hi i₁ i i₂ j h₁ h₂ s hs hr' hs' + · exact box_face_row_interval_1 lo hi i₁ i i₂ j h₁ h₂ s hs hr' hs' + · exact box_face_row_interval_2 lo hi i₁ i i₂ j h₁ h₂ s hs hr' hs' + · exact box_face_row_interval_3 lo hi i₁ i i₂ j h₁ h₂ s hs hr' hs' + · exact box_face_row_interval_4 lo hi i₁ i i₂ j h₁ h₂ s hs hr' hs' + · exact box_face_row_interval_5 lo hi i₁ i i₂ j h₁ h₂ s hs hr' hs' + +theorem star_face_row_interval (D : Finset Vertex) (hD : AdmissiblyConvex D) + (i₁ i i₂ j : ℤ) (h₁ : i₁ ≤ i) (h₂ : i ≤ i₂) + (hf₁ : (i₁,j) ∈ starFaces D) (hf₂ : (i₂,j) ∈ starFaces D) : + (i,j) ∈ starFaces D := by + obtain ⟨lo,hi,hbox⟩ := admissiblyConvex_box D hD + obtain ⟨r,hr,hr'⟩ := (mem_starFaces D _).mp hf₁ + obtain ⟨s,hs,hs'⟩ := (mem_starFaces D _).mp hf₂ + obtain ⟨v,hv,hv'⟩ := box_face_row_interval lo hi i₁ i i₂ j h₁ h₂ r s hr hs + ((hbox _).mp hr') ((hbox _).mp hs') + exact (mem_starFaces D _).mpr ⟨v,hv,(hbox _).mpr hv'⟩ + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryContainment.lean b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryContainment.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b97bd48b42c21d7af486421a43f5c614d298cc7 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryContainment.lean @@ -0,0 +1,217 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.PolygonGeometry +import OAI.Combinatorics.HoneycombCorridor.BoundaryCharge +import OAI.Combinatorics.HoneycombCorridor.CollisionPhase + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def faceIndicator (S : Finset FaceIndex) (a : FaceIndex) : ℤ := if a ∈ S then 1 else 0 + +theorem faceBoundary_local (S : Finset FaceIndex) (g : FaceBoundary S) (k : Fin 3) : + faceIndicator S (leftFace (g.val.1,k)) - faceIndicator S (rightFace (g.val.1,k)) = + (if k = outgoingSlot g.val (faceBoundaryTurn S g.val) then 1 else 0) - + (if k = g.val.2 then 1 else 0) := by + classical + rcases g with ⟨⟨v,l⟩,h⟩ + simp only [OnFaceBoundary,rightFace_prev] at h + by_cases ht : leftFace (v,l+1) ∈ S + · simp only [faceBoundaryTurn,ht,not_true_eq_false,decide_false] + fin_cases l <;> fin_cases k <;> + simp_all [faceIndicator,rightFace_prev,outgoingSlot] + · simp only [faceBoundaryTurn,ht,not_false_eq_true,decide_true] + fin_cases l <;> fin_cases k <;> + simp_all [faceIndicator,rightFace_prev,outgoingSlot] + +theorem faceBoundaryWord_local (S : Finset FaceIndex) (g : FaceBoundary S) + (n : ℕ) (q : EdgeIndex →₀ ℤ) + (hq : WordContour q g.val (faceBoundaryWord S g n)) : + ∀ v ∈ traced g.val (faceBoundaryWord S g n), ∀ k : Fin 3, + orientedFlow q (v,k) = faceIndicator S (leftFace (v,k)) - + faceIndicator S (rightFace (v,k)) := by + induction n generalizing g with + | zero => simp [faceBoundaryWord,traced] + | succ n ih => + intro v hv k + simp only [faceBoundaryWord,traced,List.mem_cons] at hv + rcases hv with rfl | hv + · exact (hq.1 k).trans (faceBoundary_local S g k).symm + · exact ih (faceBoundaryNext S g) hq.2 v hv k + +theorem faceBoundaryWord_gradient (S : Finset FaceIndex) (g : FaceBoundary S) + (n : ℕ) (hN : (traced g.val (faceBoundaryWord S g n)).Nodup) + (hc : terminalGerm g.val (faceBoundaryWord S g n) = g.val) + (e : EdgeIndex) (he : wordFlow g.val (faceBoundaryWord S g n) e ≠ 0) : + wordFlow g.val (faceBoundaryWord S g n) e = + faceIndicator S (leftFace (canonicalDart e)) - + faceIndicator S (rightFace (canonicalDart e)) := by + have hv : upEnd e ∈ traced g.val (faceBoundaryWord S g n) := by + have hm : upEnd e ∈ edgeVertices (wordFlow g.val (faceBoundaryWord S g n)).support := by + apply Finset.mem_biUnion.mpr + exact ⟨e,Finsupp.mem_support_iff.mpr he,by simp⟩ + rwa [wordFlow_edgeVertices _ _ hN hc,List.mem_toFinset] at hm + have h := faceBoundaryWord_local S g n _ (simple_closed_word_contour _ _ hN hc) + _ hv e.2 + rcases e with ⟨⟨i,j⟩,k⟩ + simpa only [upEnd,canonicalDart,orientedFlow_up] using h + +theorem finite_indicator_row_containment (p : FaceIndex →₀ ℤ) (S : Finset FaceIndex) + (hval : ∀ a, p a = 0 ∨ p a = 1) + (hgrad : ∀ i j : ℤ, p (i,j) ≠ p (i-1,j) → + p (i,j) - p (i-1,j) = faceIndicator S (i,j) - faceIndicator S (i-1,j)) + (hrow : ∀ i₁ i i₂ j : ℤ, i₁ ≤ i → i ≤ i₂ → (i₁,j) ∈ S → (i₂,j) ∈ S → + (i,j) ∈ S) : p.support ⊆ S := by + classical + rintro ⟨i,j⟩ ha + let R := (p.support.filter fun a => a.2 = j).image Prod.fst + have hRmem (x : ℤ) : x ∈ R ↔ p (x,j) ≠ 0 := by + simp only [R,Finset.mem_image,Finset.mem_filter,Finsupp.mem_support_iff] + constructor + · rintro ⟨⟨u,v⟩,⟨hp,hj⟩,hi⟩ + dsimp at hj hi + subst v; subst u + exact hp + · intro hx + exact ⟨(x,j),⟨hx,rfl⟩,rfl⟩ + have hi : i ∈ R := (hRmem i).mpr (Finsupp.mem_support_iff.mp ha) + have hne : R.Nonempty := ⟨i,hi⟩ + let a := R.min' hne + let b := R.max' hne + have haR : a ∈ R := R.min'_mem hne + have hbR : b ∈ R := R.max'_mem hne + have hpa : p (a,j) = 1 := (hval _).resolve_left ((hRmem a).mp haR) + have hpb : p (b,j) = 1 := (hval _).resolve_left ((hRmem b).mp hbR) + have hpa' : p (a-1,j) = 0 := by + by_contra hz + have hm := R.min'_le (a-1) ((hRmem _).mpr hz) + change a ≤ a-1 at hm + omega + have hpb' : p (b+1,j) = 0 := by + by_contra hz + have hm := R.le_max' (b+1) ((hRmem _).mpr hz) + change b+1 ≤ b at hm + omega + have haS : (a,j) ∈ S := by + have h := hgrad a j (by omega) + rw [hpa,hpa'] at h + by_contra hn + simp only [faceIndicator,ite_eq_right hn] at h + split_ifs at h <;> omega + have hbS : (b,j) ∈ S := by + have he : b+1-1 = b := by omega + have h := hgrad (b+1) j (by rw [he,hpb,hpb']; norm_num) + rw [he,hpb,hpb'] at h + by_contra hn + simp only [faceIndicator,ite_eq_right hn] at h + split_ifs at h <;> omega + exact hrow a i b j (R.min'_le _ hi) (R.le_max' _ hi) haS hbS + +theorem star_boundary_potential_contained (D : Finset Vertex) (hD : AdmissiblyConvex D) + (g : FaceBoundary (starFaces D)) (n : ℕ) + (hN : (traced g.val (faceBoundaryWord (starFaces D) g n)).Nodup) + (hc : terminalGerm g.val (faceBoundaryWord (starFaces D) g n) = g.val) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p + (wordFlow g.val (faceBoundaryWord (starFaces D) g n))) + (hval : ∀ a, p a = 0 ∨ p a = 1) : p.support ⊆ starFaces D := by + apply finite_indicator_row_containment p (starFaces D) hval + · intro i j he + have h : wordFlow g.val (faceBoundaryWord (starFaces D) g n) ((i,j),0) ≠ 0 := by + rw [hp.horizontal] + exact sub_ne_zero.mpr he + have he' := faceBoundaryWord_gradient (starFaces D) g n hN hc ((i,j),0) h + rw [hp.horizontal] at he' + simpa [canonicalDart,upEnd,leftFace,rightFace,reverseGerm,neighbor] using he' + · exact star_face_row_interval D hD + + + +theorem contour_unused_advance (p : FaceIndex →₀ ℤ) (q : EdgeIndex →₀ ℤ) + (hp : RepresentsFlow p q) (g : Germ) (hl : LocalContour q g false) : + p (leftFace (advance g true)) = p (leftFace (g.1,unusedSlot g false)) := by + have h := (hp (g.1,unusedSlot g false)).symm.trans (hl (unusedSlot g false)) + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> + simp [advance,outgoingSlot,unusedSlot,leftFace,rightFace,reverseGerm,neighbor] at * <;> omega + +theorem star_boundary_trace_outside (D : Finset Vertex) + (g : FaceBoundary (starFaces D)) (n : ℕ) : + ∀ v ∈ traced g.val (faceBoundaryWord (starFaces D) g n), v ∉ D := by + intro v hv + rw [faceBoundaryWord_traced,List.mem_ofFn] at hv + obtain ⟨i,rfl⟩ := hv + exact star_boundary_outside D _ + +theorem star_boundary_endpoint (D : Finset Vertex) (hD : AdmissiblyConvex D) + (g : FaceBoundary (starFaces D)) (n : ℕ) (hn : 0 < n) + (hN : (traced g.val (faceBoundaryWord (starFaces D) g n)).Nodup) + (hc : terminalGerm g.val (faceBoundaryWord (starFaces D) g n) = g.val) + (hg : faceBoundaryTurn (starFaces D) g.val = false) + (e : Germ) (w : List Bool) (he : e = advance g.val true) + (hd : ∀ v ∈ traced e w, v ∈ D) + (hu : (terminalGerm e w).1 ∉ D) + (hu' : (reverseGerm (terminalGerm e w)).1 ∈ D) : + (terminalGerm e w).1 ∈ traced g.val (faceBoundaryWord (starFaces D) g n) := by + classical + let W := faceBoundaryWord (starFaces D) g n + have hne : W ≠ [] := by + intro hx + have hl := faceBoundaryWord_length (starFaces D) g n + change W.length = n at hl + rw [hx] at hl + simp only [List.length_nil] at hl + omega + obtain ⟨p,ε,hp,hpne,hε,hvals⟩ := simple_closed_word_indicator g.val W hne hN hc + have ht := simple_polygon_signed_turn g.val W hne hN hc p ε hp hpne hε hvals + have ht' := star_boundary_cycle_turn D hD g n hn hN hc + have heps : ε = 1 := by change turnUnits W = 6 at ht'; rw [ht'] at ht; omega + subst ε + have hpS := star_boundary_potential_contained D hD g n hN hc p hp hvals + let P : Polygon := ⟨(wordFlow g.val W).support,⟨g.val,W,hne,hN,hc,rfl⟩⟩ + have hPv : P.vertices = (traced g.val W).toFinset := + wordFlow_edgeVertices g.val W hN hc + have hPf : P.interiorFaces = p.support := + P.interiorFaces_of_traversal g.val W hN hc rfl p hp + have hdis : ∀ v ∈ traced e w, v ∉ P.vertices := by + intro v hv hm + rw [hPv,List.mem_toFinset] at hm + exact star_boundary_trace_outside D g n v hm (hd v hv) + have hlocal : LocalContour (wordFlow g.val W) g.val false := by + have hh := simple_closed_word_contour g.val W hN hc + obtain ⟨m,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hn) + simpa only [W,faceBoundaryWord,hg,WordContour] using hh.1 + have hused := contour_unused_face p 1 (Or.inl rfl) hvals _ hp g.val false hlocal + have hpone : p (leftFace e) = 1 := by + rw [he,contour_unused_advance p _ hp g.val hlocal] + norm_num [turnUnit] at hused + omega + have hstart : P.potential (leftFace e) ≠ 0 := by + apply Finsupp.mem_support_iff.mp + change leftFace e ∈ P.interiorFaces + rw [hPf,Finsupp.mem_support_iff,hpone] + norm_num + have hend : P.potential (leftFace (terminalGerm e w)) ≠ 0 := by + rw [P.trace_left_potential e w hdis] + exact hstart + by_contra hout + have hnot : (terminalGerm e w).1 ∉ P.vertices := by + simpa only [hPv,List.mem_toFinset] using hout + have hmiss := (outside_boundary_germ D hD (terminalGerm e w).1 + (terminalGerm e w).2 hu hu').1.1 + have hzero : P.potential (leftFace ((terminalGerm e w).1,(terminalGerm e w).2+1)) = 0 := by + by_contra hz + have hm : leftFace ((terminalGerm e w).1,(terminalGerm e w).2+1) ∈ P.interiorFaces := + Finsupp.mem_support_iff.mpr hz + rw [hPf] at hm + exact hmiss (hpS hm) + rw [(P.off_boundary_faces _ hnot _).1] at hzero + apply hend + exact (P.off_boundary_faces _ hnot _).1.trans hzero + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryFlux.lean b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryFlux.lean new file mode 100644 index 0000000000000000000000000000000000000000..89583e5dae0a17abdb100a6707408e4357325ddf --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/BoundaryFlux.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.VisitRecursion + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +@[simp] theorem mem_sourceExits (D : Finset Vertex) (g : Germ) (w : List Bool) : + w ∈ sourceExits D g ↔ Stopped D g w ∧ (terminalGerm g w).1 ∉ D := by + classical + simp [sourceExits,mem_leaves_iff] + +theorem boundary_source_flux (D : Finset Vertex) (g : Germ) + (hD : Filled D) (hg : (reverseGerm g).1 ∉ D) : + (∑ w ∈ sourceExits D g, wordWeight w) = 1 := by + have h := exit_add_collision D g + rw [(boundary_collision_cancellation D g hD hg).1,add_zero] at h + simpa only [sourceExits,Finset.sum_filter,exitSum] using h + +theorem boundary_source_weight_bound (D : Finset Vertex) (g : Germ) + (hD : AdmissiblyConvex D) (hg : g.1 ∈ D) (hg' : (reverseGerm g).1 ∉ D) : + (∑ w ∈ sourceExits D g, criticalActivity ^ w.length) ≤ + (Real.cos (3 * Real.pi / 8))⁻¹ := by + have hflux := boundary_source_flux D g (admissiblyConvex_filled D hD) hg' + have hreal := congrArg Complex.re hflux + rw [Complex.re_sum,Complex.one_re] at hreal + have hlower : Real.cos (3 * Real.pi / 8) * + (∑ w ∈ sourceExits D g, criticalActivity ^ w.length) ≤ 1 := by + rw [← hreal,Finset.mul_sum] + apply Finset.sum_le_sum + intro w hw + obtain ⟨hs,ht⟩ := (mem_sourceExits D g w).mp hw + exact convex_wordWeight_re_lower D hD (g,w) ⟨hg,hg',hs,ht⟩ + have hpos : 0 < Real.cos (3 * Real.pi / 8) := by + apply Real.cos_pos_of_mem_Ioo + constructor <;> linarith [Real.pi_pos] + rw [inv_eq_one_div] + apply (le_div_iff₀ hpos).mpr + rwa [mul_comm] + +theorem convex_boundary_flux : ConvexBoundaryFlux := by + intro D g hD hg hg' + exact ⟨boundary_source_flux D g (admissiblyConvex_filled D hD) hg', + boundary_source_weight_bound D g hD hg hg'⟩ + + +def bottomSource : Germ := (.up 0 0,0) + +def InStrip (h : ℕ) (v : Vertex) : Prop := 0 ≤ boxIndex v 0 ∧ boxIndex v 0 < (h : ℤ) + +noncomputable def reachesDistance (t : ℝ) (w : List Bool) : Prop := + ∃ v ∈ traced bottomSource w, t ≤ |(position v).1| + +noncomputable def lateralMass (D : Finset Vertex) (t : ℝ) : ℝ := by + classical + exact ∑ w ∈ sourceExits D bottomSource, + if reachesDistance t w then criticalActivity ^ w.length else 0 + +noncomputable def lateralLengthMass (D : Finset Vertex) (t : ℝ) : ℝ := by + classical + exact ∑ w ∈ sourceExits D bottomSource, + if reachesDistance t w then (w.length : ℝ) * criticalActivity ^ w.length else 0 + +def FiniteLateralTail : Prop := ∃ C c : ℝ, 0 < C ∧ 0 < c ∧ + ∀ (h : ℕ) (D : Finset Vertex), 1 ≤ h → AdmissiblyConvex D → + bottomSource.1 ∈ D → (∀ v ∈ D, InStrip h v) → ∀ t : ℝ, 0 ≤ t → + lateralMass D t ≤ C * Real.exp (-c * t / (h+1)) ∧ + lateralLengthMass D t ≤ C * (h+1) * (h+t+1) * Real.exp (-c * t / (h+1)) + + + +def directionCode (g : Germ) : ℤ := match g.1 with + | .up _ _ => if g.2 = 0 then 0 else if g.2 = 1 then 2 else 4 + | .down _ _ => if g.2 = 0 then 3 else if g.2 = 1 then 5 else 1 + +theorem advance_direction (g : Germ) (b : Bool) : + (directionCode (advance g b) - directionCode g - turnUnit b) % 6 = 0 := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> cases b <;> + rfl + +theorem terminal_direction (g : Germ) (w : List Bool) : + (directionCode (terminalGerm g w) - directionCode g - turnUnits w) % 6 = 0 := by + induction w generalizing g with + | nil => simp [terminalGerm,turnUnits] + | cons b w ih => + have ha := advance_direction g b + have ht := ih (advance g b) + simp only [terminalGerm,turnUnits_cons] + omega + +theorem right_cut_direction_one (v : Vertex) (k : Fin 3) (A : ℤ) + (hv : boxIndex v 1 < A) (hu : A ≤ boxIndex (neighbor v k) 1) : + directionCode (neighbor v k,k) = 4 := by + cases v <;> fin_cases k <;> + simp [boxIndex,neighbor,directionCode] at * <;> omega + +theorem right_cut_direction_two (v : Vertex) (k : Fin 3) (A : ℤ) + (hv : boxIndex v 2 < A) (hu : A ≤ boxIndex (neighbor v k) 2) : + directionCode (neighbor v k,k) = 5 := by + cases v <;> fin_cases k <;> + simp [boxIndex,neighbor,directionCode] at * <;> omega + +theorem convex_source_direction_turn (D : Finset Vertex) (hD : AdmissiblyConvex D) + (hg : bottomSource.1 ∈ D) (hg' : (reverseGerm bottomSource).1 ∉ D) + (w : List Bool) (hw : w ∈ sourceExits D bottomSource) : + (directionCode (terminalGerm bottomSource w) = 4 → turnUnits w = -2) ∧ + (directionCode (terminalGerm bottomSource w) = 5 → turnUnits w = -1) := by + have hb := convex_excursion_turn_bound D hD (bottomSource,w) + ⟨hg,hg',(mem_sourceExits D bottomSource w).mp hw⟩ + change -3 ≤ turnUnits w ∧ turnUnits w ≤ 3 at hb + have hm := terminal_direction bottomSource w + rw [show directionCode bottomSource = 0 from rfl,sub_zero] at hm + constructor <;> intro h <;> rw [h] at hm <;> omega + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/BridgeFiniteness.lean b/lean/OAI/Combinatorics/HoneycombCorridor/BridgeFiniteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..90fb403969511a05c57c405eb7f1ff29349ac00c --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/BridgeFiniteness.lean @@ -0,0 +1,103 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.LateralLength +import OAI.Combinatorics.HoneycombCorridor.Bridges + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +theorem finite_bridges_window (h : ℕ) (S : Finset (BridgePath h)) : + ∃ M : ℕ, ∀ p ∈ S, ∀ v ∈ p.vertices, v ∈ vertexWindow h M := by + classical + let V := S.biUnion (fun p => p.vertices.toFinset) + have hV : ∀ v ∈ V, InStrip h v := by + intro v hv + obtain ⟨p,hp,hv⟩ := Finset.mem_biUnion.mp hv + have hi := p.inStrip v (List.mem_toFinset.mp hv) + simpa only [InStrip,layer_boxIndex] using hi + obtain ⟨M,hM⟩ := finite_vertices_in_window h V hV + refine ⟨M,?_⟩ + intro p hp v hv + exact hM (Finset.mem_biUnion.mpr ⟨p,hp,List.mem_toFinset.mpr hv⟩) + +theorem bridge_finite_sum_word_bound (h : ℕ) (hh : 1 ≤ h) (S : Finset (BridgePath h)) + (f : List Bool → ℝ) (hf : ∀ w, 0 ≤ f w) : + ∃ M : ℕ, (∑ p ∈ S, f (bridgeWord h hh p)) ≤ + ∑ w ∈ sourceExits (vertexWindow h M) bottomSource, f w := by + classical + obtain ⟨M,hM⟩ := finite_bridges_window h S + refine ⟨M,?_⟩ + rw [← Finset.sum_image (fun p _ q _ he => bridgeWord_injective h hh he)] + apply Finset.sum_le_sum_of_subset_of_nonneg _ (fun w _ _ => hf w) + intro w hw + obtain ⟨p,hp,rfl⟩ := Finset.mem_image.mp hw + exact bridgeWord_mem_sourceExits h hh p _ (vertexWindow_strip h M) (hM p hp) + +theorem bridge_weight_finite_sum_bound (h : ℕ) (hh : 1 ≤ h) (S : Finset (BridgePath h)) : + (∑ p ∈ S, weight p) ≤ (Real.cos (3*Real.pi/8))⁻¹ := by + obtain ⟨M,hM⟩ := bridge_finite_sum_word_bound h hh S (fun w => criticalActivity^w.length) + (fun w => pow_nonneg criticalActivity_pos.le _) + simp only [bridgeWord_length] at hM + apply hM.trans + exact boundary_source_weight_bound _ bottomSource (vertexWindow_convex h M) + (bottomSource_mem_window h M hh) + (bottomSource_outside_of_strip h _ (vertexWindow_strip h M)) + +theorem sourceExit_reaches_zero (D : Finset Vertex) (hg : bottomSource.1 ∈ D) + (w : List Bool) (hw : w ∈ sourceExits D bottomSource) : reachesDistance 0 w := by + cases w with + | nil => + have hn := ((mem_sourceExits _ _ _).mp hw).1 + exact False.elim (hn hg) + | cons b w => exact ⟨bottomSource.1,by simp [traced],abs_nonneg _⟩ + +theorem lateralLengthMass_zero (D : Finset Vertex) (hg : bottomSource.1 ∈ D) : + lateralLengthMass D 0 = ∑ w ∈ sourceExits D bottomSource, + (w.length : ℝ)*criticalActivity^w.length := by + classical + unfold lateralLengthMass + apply Finset.sum_congr rfl + intro w hw + simp only [sourceExit_reaches_zero D hg w hw,ite_true] + +theorem bridge_length_finite_sum_bound (h : ℕ) (hh : 1 ≤ h) (S : Finset (BridgePath h)) : + (∑ p ∈ S, firstLengthWeight p) ≤ tailConstant*spatialConstant*((h : ℝ)+1)^2 := by + obtain ⟨M,hM⟩ := bridge_finite_sum_word_bound h hh S + (fun w => (w.length : ℝ)*criticalActivity^w.length) + (fun w => mul_nonneg (Nat.cast_nonneg _) (pow_nonneg criticalActivity_pos.le _)) + simp only [bridgeWord_length] at hM + rw [← lateralLengthMass_zero _ (bottomSource_mem_window h M hh)] at hM + apply hM.trans + have ht := lateralLengthMass_exp h hh _ (vertexWindow_convex h M) + (bottomSource_mem_window h M hh) (vertexWindow_strip h M) 0 le_rfl + simpa only [mul_zero,zero_div,Real.exp_zero,mul_one] using ht + +theorem bridge_weight_summable (h : ℕ) (hh : 1 ≤ h) : Summable (weight (h := h)) := by + refine summable_of_sum_le (f := weight (h := h)) + (c := (Real.cos (3*Real.pi/8))⁻¹) ?_ (bridge_weight_finite_sum_bound h hh) + intro p + exact pow_nonneg criticalActivity_pos.le p.vertices.length + +theorem bridge_length_summable (h : ℕ) (hh : 1 ≤ h) : Summable (firstLengthWeight (h := h)) := by + refine summable_of_sum_le (f := firstLengthWeight (h := h)) + (c := tailConstant*spatialConstant*((h : ℝ)+1)^2) ?_ + (bridge_length_finite_sum_bound h hh) + intro p + exact mul_nonneg (Nat.cast_nonneg p.vertices.length) + (pow_nonneg criticalActivity_pos.le p.vertices.length) + +theorem finite_bridge_sums : FiniteBridgeSums := by + intro h hh + have hm := bridge_weight_summable h hh + have hl := bridge_length_summable h hh + have hmc : Summable (fun p : ConfinedBridgePath h => weight p.val) := hm.subtype InLogCorridor + have hlc : Summable (fun p : ConfinedBridgePath h => firstLengthWeight p.val) := hl.subtype InLogCorridor + exact ⟨hm,hl,hl.div_const _,hmc,hlc,hlc.div_const _⟩ + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Bridges.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Bridges.lean new file mode 100644 index 0000000000000000000000000000000000000000..27c6b8a2a19292dd5526885c6216b4a3412b9619 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Bridges.lean @@ -0,0 +1,214 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.StripWindows + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + + theorem adjacent_exists_slot (v u : Vertex) (h : adjacent v u) : + ∃ k : Fin 3, neighbor v k = u := by + cases v <;> cases u <;> simp only [adjacent] at h + · rcases h with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact ⟨0,by simp [neighbor]⟩ + · exact ⟨1,by simp [neighbor]⟩ + · exact ⟨2,by simp [neighbor]⟩ + · rcases h with ⟨rfl,hl⟩ | ⟨rfl,rfl⟩ | ⟨hk,rfl⟩ + · exact ⟨0,by simp [neighbor]; omega⟩ + · exact ⟨1,by simp [neighbor]⟩ + · exact ⟨2,by simp [neighbor]; omega⟩ + +theorem exists_advance_of_adjacent (g : Germ) (v : Vertex) (ha : adjacent g.1 v) + (hb : v ≠ neighbor g.1 g.2) : ∃ b : Bool, (advance g b).1 = v := by + obtain ⟨k,hk⟩ := adjacent_exists_slot g.1 v ha + have hkg : k ≠ g.2 := by + intro he + exact hb (he ▸ hk.symm) + have ho : ∃ b : Bool, outgoingSlot g b = k := by + obtain ⟨u,j⟩ := g + fin_cases j <;> fin_cases k <;> simp_all [outgoingSlot] + obtain ⟨b,hb⟩ := ho + exact ⟨b,by simpa only [advance,hb] using hk⟩ + +theorem exists_word_of_chain (g : Germ) (l : List Vertex) + (hc : (g.1 :: l).IsChain adjacent) (hn : (g.1 :: l).Nodup) + (hp : neighbor g.1 g.2 ∉ l) : + ∃ w : List Bool, traced g w ++ [(terminalGerm g w).1] = g.1 :: l := by + induction l generalizing g with + | nil => exact ⟨[],rfl⟩ + | cons v l ih => + obtain ⟨ha,hc⟩ := List.isChain_cons_cons.mp hc + obtain ⟨hg,hn⟩ := List.nodup_cons.mp hn + have hb : v ≠ neighbor g.1 g.2 := by + intro he + exact hp (by simp [he]) + obtain ⟨b,hb⟩ := exists_advance_of_adjacent g v ha hb + have hg' : neighbor (advance g b).1 (advance g b).2 = g.1 := by + simp only [advance,neighbor_neighbor] + have hc' : ((advance g b).1 :: l).IsChain adjacent := by simpa only [hb] using hc + have hn' : ((advance g b).1 :: l).Nodup := by simpa only [hb] using hn + have hp' : neighbor (advance g b).1 (advance g b).2 ∉ l := by + rw [hg'] + exact fun hm => hg (List.mem_cons_of_mem _ hm) + obtain ⟨w,hw⟩ := ih (advance g b) hc' hn' hp' + refine ⟨b::w,?_⟩ + simp only [traced,terminalGerm,List.cons_append,hw,hb] + + + +def layer (vertex : Vertex) : ℤ := + Vertex.rec (fun _ vertical => vertical) (fun _ vertical => vertical) vertex + +structure BridgePath (h : ℕ) where + vertices : List Vertex + distinct : vertices.Nodup + connected : vertices.IsChain adjacent + source : vertices.head? = some (.up 0 0) + terminal : ∃ i : ℤ, vertices.getLast? = some (.down i ((h : ℤ) - 1)) + inStrip : ∀ v ∈ vertices, 0 ≤ layer v ∧ layer v < (h : ℤ) + +noncomputable def weight {h : ℕ} (p : BridgePath h) : ℝ := + criticalActivity ^ p.vertices.length + +noncomputable def firstLengthWeight {h : ℕ} (p : BridgePath h) : ℝ := + (p.vertices.length : ℝ) * weight p + +noncomputable def bridgeMass (h : ℕ) : ℝ := ∑' p : BridgePath h, weight p +noncomputable def bridgeLengthMass (h : ℕ) : ℝ := + ∑' p : BridgePath h, firstLengthWeight p +noncomputable def bridgeMean (h : ℕ) : ℝ := bridgeLengthMass h / bridgeMass h + +noncomputable def InLogCorridor {h : ℕ} (p : BridgePath h) : Prop := + ∀ v ∈ p.vertices, |(position v).1| ≤ (h : ℝ) * (Real.log (h : ℝ)) ^ 2 + +def ConfinedBridgePath (h : ℕ) := {p : BridgePath h // InLogCorridor p} + +noncomputable def confinedMass (h : ℕ) : ℝ := + ∑' p : ConfinedBridgePath h, weight p.val +noncomputable def confinedLengthMass (h : ℕ) : ℝ := + ∑' p : ConfinedBridgePath h, firstLengthWeight p.val +noncomputable def confinedMean (h : ℕ) : ℝ := confinedLengthMass h / confinedMass h + +def Subpower (f : ℕ → ℝ) (a : ℝ) : Prop := + (∀ᶠ h in Filter.atTop, 0 < f h) ∧ + Filter.Tendsto (fun h : ℕ => Real.log (f h) / Real.log (h : ℝ)) + Filter.atTop (nhds a) + +def FiniteBridgeSums : Prop := + ∀ h : ℕ, 1 ≤ h → + Summable (weight (h := h)) ∧ Summable (firstLengthWeight (h := h)) ∧ + Summable (fun p : BridgePath h => firstLengthWeight p / bridgeMass h) ∧ + Summable (fun p : ConfinedBridgePath h => weight p.val) ∧ + Summable (fun p : ConfinedBridgePath h => firstLengthWeight p.val) ∧ + Summable (fun p : ConfinedBridgePath h => firstLengthWeight p.val / confinedMass h) + +def StripMassAndBridgeLength : Prop := + FiniteBridgeSums ∧ + Subpower bridgeMass (-(1 : ℝ) / 4) ∧ + Subpower bridgeLengthMass ((13 : ℝ) / 12) ∧ + Subpower bridgeMean ((4 : ℝ) / 3) ∧ + Subpower confinedMass (-(1 : ℝ) / 4) ∧ + Subpower confinedLengthMass ((13 : ℝ) / 12) ∧ + Subpower confinedMean ((4 : ℝ) / 3) + + + +@[simp] theorem layer_boxIndex (v : Vertex) : layer v = boxIndex v 0 := by + cases v <;> simp [layer,boxIndex] + +theorem bridge_exists_word (h : ℕ) (hh : 1 ≤ h) (p : BridgePath h) : + ∃ w : List Bool, traced bottomSource w = p.vertices ∧ + layer (terminalGerm bottomSource w).1 = (h : ℤ) := by + obtain ⟨i,hi⟩ := p.terminal + let u : Vertex := .up i h + have hu : layer u = (h : ℤ) := by rfl + have hnu : u ∉ p.vertices := by + intro hm + have h := (p.inStrip u hm).2 + rw [hu] at h + omega + have hc : (p.vertices ++ [u]).IsChain adjacent := by + apply p.connected.append (by simp) + intro v hv a ha + have hv' : v = .down i ((h : ℤ)-1) := by symm; simpa only [hi,Option.mem_some_iff] using hv + have ha' : a = u := by symm; simpa using ha + subst v; subst a + simp [u,adjacent] + have hn : (p.vertices ++ [u]).Nodup := by + apply List.nodup_append.mpr + refine ⟨p.distinct,by simp,?_⟩ + intro v hv a ha + have ha' : a = u := by simpa using ha + subst a + exact fun he => hnu (he ▸ hv) + have hp : neighbor bottomSource.1 bottomSource.2 ∉ p.vertices ++ [u] := by + intro hm + simp only [List.mem_append,List.mem_singleton] at hm + rcases hm with hm | hm + · have hi := (p.inStrip _ hm).1 + norm_num [bottomSource,neighbor,layer,boxIndex] at hi + · have hidx := congrArg layer hm + change (-1 : ℤ) = (h : ℤ) at hidx + have hheight : (1 : ℤ) ≤ h := by exact_mod_cast hh + exact (ne_of_lt (lt_of_lt_of_le (by norm_num : (-1 : ℤ) < 1) hheight)) hidx + obtain ⟨l,hl⟩ := List.head?_eq_some_iff.mp p.source + have hc' : (bottomSource.1 :: (l ++ [u])).IsChain adjacent := by + simpa only [hl,List.cons_append,bottomSource] using hc + have hn' : (bottomSource.1 :: (l ++ [u])).Nodup := by + simpa only [hl,List.cons_append,bottomSource] using hn + have hp' : neighbor bottomSource.1 bottomSource.2 ∉ l ++ [u] := by + intro hm + apply hp + rw [hl,List.cons_append] + exact List.mem_cons_of_mem _ hm + obtain ⟨w,hw⟩ := exists_word_of_chain bottomSource _ hc' hn' hp' + have heq : traced bottomSource w ++ [(terminalGerm bottomSource w).1] = p.vertices ++ [u] := by + simpa only [hl,List.cons_append,bottomSource] using hw + have ht : (terminalGerm bottomSource w).1 = u := by + have ht := congrArg List.getLast? heq + simpa using ht + rw [ht] at heq + exact ⟨w,List.append_cancel_right heq,ht ▸ hu⟩ + +noncomputable def bridgeWord (h : ℕ) (hh : 1 ≤ h) (p : BridgePath h) : List Bool := + (bridge_exists_word h hh p).choose + +@[simp] theorem bridgeWord_trace (h : ℕ) (hh : 1 ≤ h) (p : BridgePath h) : + traced bottomSource (bridgeWord h hh p) = p.vertices := + (bridge_exists_word h hh p).choose_spec.1 + +theorem bridgeWord_terminal_layer (h : ℕ) (hh : 1 ≤ h) (p : BridgePath h) : + layer (terminalGerm bottomSource (bridgeWord h hh p)).1 = (h : ℤ) := + (bridge_exists_word h hh p).choose_spec.2 + +@[simp] theorem bridgeWord_length (h : ℕ) (hh : 1 ≤ h) (p : BridgePath h) : + (bridgeWord h hh p).length = p.vertices.length := by + rw [← traced_length bottomSource,bridgeWord_trace] + +theorem bridgeWord_injective (h : ℕ) (hh : 1 ≤ h) : Function.Injective (bridgeWord h hh) := by + intro p q hpq + have hv := congrArg (traced bottomSource) hpq + simp only [bridgeWord_trace] at hv + cases p; cases q + cases hv + rfl + +theorem bridgeWord_mem_sourceExits (h : ℕ) (hh : 1 ≤ h) (p : BridgePath h) + (D : Finset Vertex) (hstrip : ∀ v ∈ D, InStrip h v) + (hp : ∀ v ∈ p.vertices, v ∈ D) : bridgeWord h hh p ∈ sourceExits D bottomSource := by + have ht : (terminalGerm bottomSource (bridgeWord h hh p)).1 ∉ D := by + intro hm + have hhi := (hstrip _ hm).2 + rw [← layer_boxIndex,bridgeWord_terminal_layer] at hhi + omega + apply (mem_sourceExits _ _ _).mpr + refine ⟨stopped_of_trace D bottomSource _ ?_ ?_ ht,ht⟩ + · simpa only [bridgeWord_trace] using p.distinct + · simpa only [bridgeWord_trace] using hp + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Cells.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Cells.lean new file mode 100644 index 0000000000000000000000000000000000000000..efd758df6d5332e470e458b73de8dca7248f3c6e --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Cells.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Contours + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def faceEdges (a : FaceIndex) : Finset EdgeIndex := + {((a.1,a.2),0), ((a.1+1,a.2),0), + ((a.1+1,a.2-1),1), ((a.1,a.2),1), + ((a.1+1,a.2),2), ((a.1+1,a.2-1),2)} + +def faceVertices (a : FaceIndex) : Finset Vertex := + {.up a.1 a.2, .down a.1 (a.2-1), .up (a.1+1) (a.2-1), + .down a.1 a.2, .up (a.1+1) a.2, .down (a.1+1) (a.2-1)} + +def cellEdges (S : Finset FaceIndex) : Finset EdgeIndex := S.biUnion faceEdges + +def cellVertices (S : Finset FaceIndex) : Finset Vertex := S.biUnion faceVertices + +theorem mem_faceEdges (e : EdgeIndex) (a : FaceIndex) : + e ∈ faceEdges a ↔ leftFace (canonicalDart e) = a ∨ rightFace (canonicalDart e) = a := by + rcases e with ⟨⟨i,j⟩,k⟩ + rcases a with ⟨x,y⟩ + fin_cases k <;> + simp [faceEdges,canonicalDart,upEnd,leftFace,rightFace,reverseGerm,neighbor] <;> omega + +theorem mem_faceVertices (v : Vertex) (a : FaceIndex) : + v ∈ faceVertices a ↔ ∃ k : Fin 3, leftFace (v,k) = a := by + rcases a with ⟨x,y⟩ + cases v <;> + simp [faceVertices,Fin.exists_fin_succ,leftFace] <;> omega + +theorem mem_cellEdges (S : Finset FaceIndex) (e : EdgeIndex) : + e ∈ cellEdges S ↔ leftFace (canonicalDart e) ∈ S ∨ rightFace (canonicalDart e) ∈ S := by + simp only [cellEdges,Finset.mem_biUnion,mem_faceEdges] + constructor + · rintro ⟨a,ha,h | h⟩ + · exact Or.inl (h ▸ ha) + · exact Or.inr (h ▸ ha) + · rintro (h | h) + · exact ⟨_,h,Or.inl rfl⟩ + · exact ⟨_,h,Or.inr rfl⟩ + +theorem mem_cellVertices (S : Finset FaceIndex) (v : Vertex) : + v ∈ cellVertices S ↔ ∃ k : Fin 3, leftFace (v,k) ∈ S := by + simp only [cellVertices,Finset.mem_biUnion,mem_faceVertices] + constructor + · rintro ⟨a,ha,k,hk⟩ + exact ⟨k,hk ▸ ha⟩ + · rintro ⟨k,hk⟩ + exact ⟨_,hk,k,rfl⟩ + +theorem edge_mem_vertex (S : Finset FaceIndex) (g : Germ) + (h : edgeOf g ∈ cellEdges S) : g.1 ∈ cellVertices S := by + rw [mem_cellEdges] at h + rcases canonicalDart_edgeOf g with hg | hg + · rw [hg] at h + rcases h with h | h + · exact (mem_cellVertices S g.1).mpr ⟨g.2,h⟩ + · rcases g with ⟨v,k⟩ + rw [mem_cellVertices] + cases v <;> fin_cases k <;> + simp [rightFace,reverseGerm,neighbor] at h <;> + simp_all [Fin.exists_fin_succ,leftFace] + · rw [hg,rightFace_reverse] at h + rcases h with h | h + · rcases g with ⟨v,k⟩ + rw [mem_cellVertices] + cases v <;> fin_cases k <;> + simp [reverseGerm,neighbor] at h <;> + simp_all [Fin.exists_fin_succ,leftFace] + · exact (mem_cellVertices S g.1).mpr ⟨g.2,h⟩ + +@[simp] theorem edgeOf_reverse (g : Germ) : edgeOf (reverseGerm g) = edgeOf g := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> simp [edgeOf,reverseGerm,neighbor] + +theorem edge_mem_neighbor (S : Finset FaceIndex) (g : Germ) + (h : edgeOf g ∈ cellEdges S) : neighbor g.1 g.2 ∈ cellVertices S := by + exact edge_mem_vertex S (reverseGerm g) (by simpa using h) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CollisionCancellation.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionCancellation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddb409055da27063c765dd48f650add46ef06953 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionCancellation.lean @@ -0,0 +1,175 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.CollisionHistories +import OAI.Combinatorics.HoneycombCorridor.PolygonGeometry + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def polygonOfClosed (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) : Polygon := + ⟨(wordFlow g w).support,⟨g,w,hne,hN,hc,rfl⟩⟩ + +theorem polygonOfClosed_vertices (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) : + (polygonOfClosed g w hne hN hc).vertices = (traced g w).toFinset := + wordFlow_edgeVertices g w hN hc + +theorem mem_traced_split (g : Germ) (w : List Bool) (v : Vertex) (hv : v ∈ traced g w) : + ∃ u b t, w = u ++ (b :: t) ∧ (terminalGerm g u).1 = v := by + induction w generalizing g with + | nil => simp [traced] at hv + | cons b w ih => + simp only [traced,List.mem_cons] at hv + rcases hv with hv | hv + · exact ⟨[],b,w,rfl,hv.symm⟩ + · obtain ⟨u,c,t,he,ht⟩ := ih (advance g b) hv + exact ⟨b::u,c,t,by simp [he],ht⟩ + +theorem reverseAt_append (g : Germ) (v : Vertex) (u w : List Bool) + (hv : v ∉ traced g u) : + reverseAt g v (u ++ w) = u ++ reverseAt (terminalGerm g u) v w := by + induction u generalizing g with + | nil => rfl + | cons b u ih => + have hg : g.1 ≠ v := fun h => hv (by simp [traced,h]) + have ht : v ∉ traced (advance g b) u := fun h => hv (List.mem_cons_of_mem _ h) + simp only [List.cons_append,reverseAt,ite_eq_right hg,terminalGerm,ih _ ht] + +theorem split_back_not_mem (g : Germ) (u : List Bool) (b : Bool) (w : List Bool) + (hN : (traced g (u ++ b :: w)).Nodup) + (hg : (reverseGerm g).1 ∉ traced g (u ++ b :: w)) : + (reverseGerm (terminalGerm g u)).1 ∉ traced (terminalGerm g u) (b :: w) := by + cases u with + | nil => simpa only [List.nil_append,terminalGerm] using hg + | cons c u => + have hm := terminal_previous_mem g (c :: u) (by simp) + rw [traced_append] at hN + have hd := (List.nodup_append.mp hN).2.2 + exact fun ht => hd _ hm _ ht rfl + +theorem root_collision_cancels (g : Germ) (b : Bool) (w : List Bool) + (hN : (traced g (b :: w)).Nodup) + (hc : (terminalGerm g (b :: w)).1 = g.1) + (hback : (reverseGerm g).1 ∉ traced g (b :: w)) + (hz : ∀ (P : Polygon), P.vertices = (traced g (b :: w)).toFinset → + P.potential (leftFace g) = 0) : + wordWeight (b :: w) + wordWeight ((!b) :: reverseTurns w) = 0 := by + let t := terminalGerm g (b :: w) + obtain ⟨hs,ha⟩ := collision_root_slots g b w hN hc hback + have htr : traced t ((!b) :: w) = traced g (b :: w) := by + change t.1 :: traced (advance t (!b)) w = _ + rw [ha,hc] + rfl + have hNt : (traced t ((!b) :: w)).Nodup := htr ▸ hN + have hct : terminalGerm t ((!b) :: w) = t := by + change terminalGerm (advance t (!b)) w = _ + rw [ha] + rfl + let P := polygonOfClosed t ((!b) :: w) (by simp) hNt hct + have hPv : P.vertices = (traced g (b :: w)).toFinset := by + rw [polygonOfClosed_vertices,htr] + have hPz := hz P hPv + obtain ⟨p,ε,hp,hpne,hε,hvals⟩ := + simple_closed_word_indicator t ((!b) :: w) (by simp) hNt hct + have hPs := P.interiorFaces_of_traversal t ((!b) :: w) hNt hct rfl p hp + have hpz : p (leftFace g) = 0 := by + apply Finsupp.notMem_support_iff.mp + rw [← hPs] + exact Finsupp.notMem_support_iff.mpr hPz + have hr := collision_phase t (!b) w p ε hNt hct hp hpne hε hvals + have he : (t.1,unusedSlot t (!b)) = g := hs + simp only [Bool.not_not,he,hpz,ite_eq_left] at hr + exact hr + +theorem boundary_collision_pair (D : Finset Vertex) (g : Germ) (w : List Bool) + (hD : Filled D) (hg : (reverseGerm g).1 ∉ D) + (hw : w ∈ leaves D g) (ht : (terminalGerm g w).1 ∈ D) : + wordWeight w + wordWeight (collisionReverse g w) = 0 := by + have hstop := (stopped_iff_trace D g w).mp ((mem_leaves_iff D g w).mp hw) + have hmem : (terminalGerm g w).1 ∈ traced g w := + hstop.2.2.resolve_left (not_not.mpr ht) + obtain ⟨u,b,t,rfl,hroot⟩ := mem_traced_split g w (terminalGerm g w).1 hmem + have hN := hstop.1 + rw [traced_append] at hN + have hna := List.nodup_append.mp hN + have hb : (reverseGerm (terminalGerm g u)).1 ∉ traced (terminalGerm g u) (b :: t) := + split_back_not_mem g u b t hstop.1 (fun h => hg (hstop.2.1 _ h)) + have hct : (terminalGerm (terminalGerm g u) (b :: t)).1 = (terminalGerm g u).1 := by + rw [← terminalGerm_append] + exact hroot.symm + have hzero : wordWeight (b :: t) + wordWeight ((!b) :: reverseTurns t) = 0 := by + apply root_collision_cancels (terminalGerm g u) b t hna.2.1 hct hb + intro P hPv + have hPD : P ∈ polygons D := by + apply (mem_polygons D P).mpr + rw [hPv] + intro v hv + exact hstop.2.1 v (by rw [traced_append]; exact List.mem_append_right _ (List.mem_toFinset.mp hv)) + have hdis : ∀ v ∈ traced g u, v ∉ P.vertices := by + intro v hv hm + rw [hPv,List.mem_toFinset] at hm + exact hna.2.2 _ hv _ hm rfl + rw [P.trace_left_potential g u hdis] + exact P.outside_port_potential D hD hPD g hg + have hnot : (terminalGerm g (u ++ b :: t)).1 ∉ traced g u := by + intro hm + apply hna.2.2 _ hm _ _ rfl + rw [← hroot] + simp [traced] + unfold collisionReverse + rw [reverseAt_append g _ u (b :: t) hnot] + have he : (terminalGerm g u).1 = (terminalGerm g (u ++ b :: t)).1 := hroot + simp only [reverseAt,ite_eq_left he,wordWeight_append] + rw [← mul_add,hzero,mul_zero] + +private theorem collision_subsum_zero (D : Finset Vertex) (g : Germ) + (hD : Filled D) (hg : (reverseGerm g).1 ∉ D) (S : Finset (List Bool)) + (hS : ∀ w ∈ S, w ∈ leaves D g ∧ (terminalGerm g w).1 ∈ D) + (hrev : ∀ w ∈ S, collisionReverse g w ∈ S) : + (∑ w ∈ S, wordWeight w) = 0 := by + apply Finset.sum_involution (fun w _ => collisionReverse g w) + · intro w hw + exact boundary_collision_pair D g w hD hg (hS w hw).1 (hS w hw).2 + · intro w hw hn he + apply hn + have h := boundary_collision_pair D g w hD hg (hS w hw).1 (hS w hw).2 + rw [he] at h + linear_combination (1 / 2 : ℂ) * h + · exact hrev + · intro w hw + exact (collisionReverse_leaf D g w (hS w hw).1 hg (hS w hw).2).2.2.2 + +theorem boundary_collision_cancellation (D : Finset Vertex) (g : Germ) + (hD : Filled D) (hg : (reverseGerm g).1 ∉ D) : + collisionSum D g = 0 ∧ ∀ v : Vertex, + (∑ w ∈ leaves D g, if (terminalGerm g w).1 ∈ D ∧ v ∈ traced g w + then wordWeight w else 0) = 0 := by + classical + constructor + · unfold collisionSum + rw [← Finset.sum_filter] + apply collision_subsum_zero D g hD hg + · intro w hw + exact Finset.mem_filter.mp hw + · intro w hw + obtain ⟨hw,ht⟩ := Finset.mem_filter.mp hw + have h := collisionReverse_leaf D g w hw hg ht + exact Finset.mem_filter.mpr ⟨h.1,h.2.1⟩ + · intro v + rw [← Finset.sum_filter] + apply collision_subsum_zero D g hD hg + · intro w hw + have h := Finset.mem_filter.mp hw + exact ⟨h.1,h.2.1⟩ + · intro w hw + obtain ⟨hw,ht,hv⟩ := Finset.mem_filter.mp hw + have h := collisionReverse_leaf D g w hw hg ht + exact Finset.mem_filter.mpr ⟨h.1,h.2.1,(h.2.2.1 v).mpr hv⟩ +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CollisionGrouping.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionGrouping.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fe29f6b54cd098207208b1b96c79d6de9850117 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionGrouping.lean @@ -0,0 +1,201 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.CollisionStems + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +theorem sum_record_three {α β γ : Type*} [DecidableEq α] [DecidableEq β] [DecidableEq γ] + (s : Finset α) (t : α → Finset β) (u : α → β → Finset γ) (F : α × β × γ → ℂ) : + (∑ z ∈ s.biUnion (fun a => ((t a).biUnion (fun b => + (u a b).image (fun c => (b,c)))).image (fun bc => (a,bc))), F z) = + ∑ a ∈ s, ∑ b ∈ t a, ∑ c ∈ u a b, F (a,b,c) := by + have h := sum_record_fibers s (fun a => (t a).biUnion (fun b => + (u a b).image (fun c => (b,c)))) F + apply h.trans + apply Finset.sum_congr rfl + intro a ha + exact sum_record_fibers (t a) (u a) (fun bc => F (a,bc)) + + + +theorem collision_splice_surjective (D : Finset Vertex) (v : Vertex) + (e : RayRecord) (he : e ∈ rayCollisions D v) : + ∃ (P : Polygon) (s c : RayRecord), P ∈ polygons D ∧ s ∈ polygonStems D v P ∧ + c ∈ cyclesAt P (stemEnd v s).1 ∧ spliceRecord v s c = e := by + classical + rcases e with ⟨k,w⟩ + have hs := (mem_rayCollisions D v (k,w)).mp he + let g := rayGerm v k + have hn := (stopped_iff_trace _ _ _).mp hs.1 + have hm : (terminalGerm g w).1 ∈ traced g w := + hn.2.2.resolve_left (not_not.mpr hs.2) + obtain ⟨u,b,r,hw,hroot⟩ := mem_traced_split g w (terminalGerm g w).1 hm + have hN : (traced g (u ++ b :: r)).Nodup := hw ▸ hn.1 + have hd : ∀ a ∈ traced g (u ++ b :: r), a ∈ D.erase v := hw ▸ hn.2.1 + have hna := List.nodup_append.mp (show (traced g u ++ traced (terminalGerm g u) (b :: r)).Nodup by + rwa [← traced_append]) + let f := terminalGerm g u + have hf : (terminalGerm f (b :: r)).1 = f.1 := by + change (terminalGerm (terminalGerm g u) (b :: r)).1 = _ + rw [← terminalGerm_append,← hw] + exact hroot.symm + have hback : (reverseGerm f).1 ∉ traced f (b :: r) := by + apply split_back_not_mem g u b r hN + intro hm + have hv := (Finset.mem_erase.mp (hd _ hm)).1 + apply hv + simp [g,rayGerm,reverseGerm] + obtain ⟨hslot,ha⟩ := collision_root_slots f b r hna.2.1 hf hback + let t := terminalGerm f (b :: r) + have ht : t.1 = f.1 := hf + have htr : traced t ((!b) :: r) = traced f (b :: r) := by + change t.1 :: traced (advance t (!b)) r = _ + rw [ha,ht] + rfl + have hNt : (traced t ((!b) :: r)).Nodup := htr ▸ hna.2.1 + have hct : terminalGerm t ((!b) :: r) = t := by + change terminalGerm (advance t (!b)) r = _ + rw [ha] + rfl + let P := polygonOfClosed t ((!b) :: r) (by simp) hNt hct + have hPv : P.vertices = (traced f (b :: r)).toFinset := by + rw [polygonOfClosed_vertices,htr] + have hPD : P ∈ polygons D := by + apply (mem_polygons D P).mpr + rw [hPv] + intro a ha + exact Finset.mem_of_mem_erase (hd a (by rw [traced_append]; exact List.mem_append_right _ (List.mem_toFinset.mp ha))) + have hnv : v ∉ P.vertices := by + rw [hPv] + intro hv + exact (Finset.mem_erase.mp (hd v (by rw [traced_append]; exact List.mem_append_right _ (List.mem_toFinset.mp hv)))).1 rfl + have hsf : (k,u) ∈ polygonStems D v P := by + rw [mem_polygonStems] + refine ⟨hnv,(stopped_iff_trace _ _ _).mpr ⟨hna.1,?_,Or.inl ?_⟩,?_⟩ + · intro a ha + have hDa := hd a (by rw [traced_append]; exact List.mem_append_left _ ha) + refine Finset.mem_erase.mpr ⟨(Finset.mem_erase.mp hDa).1,Finset.mem_sdiff.mpr ⟨Finset.mem_of_mem_erase hDa,?_⟩⟩ + rw [hPv] + intro hPa + exact hna.2.2 a ha a (List.mem_toFinset.mp hPa) rfl + · intro ha + have hnot := (Finset.mem_sdiff.mp (Finset.mem_of_mem_erase ha)).2 + apply hnot + rw [hPv] + simp only [List.mem_toFinset,traced,List.mem_cons] + exact Or.inl rfl + · change f.1 ∈ P.vertices + rw [hPv] + simp [traced] + have het : (f.1,t.2) = t := Prod.ext ht.symm rfl + refine ⟨P,(k,u),(t.2,(!b) :: r),hPD,hsf,?_,?_⟩ + · rw [mem_cyclesAt] + change P.Traverses (f.1,t.2) ((!b) :: r) + rw [het] + exact ⟨by simp,hNt,hct,rfl⟩ + · simp only [spliceRecord,attachWord,Bool.not_not] + exact Prod.ext rfl hw.symm + +theorem spliceRecord_terminal {D : Finset Vertex} (v : Vertex) (P : Polygon) (s c : RayRecord) + (hs : IsPolygonStem D v P s) (hc : c ∈ cyclesAt P (stemEnd v s).1) : + stemEnd v (spliceRecord v s c) = ((stemEnd v s).1,c.1) := by + change terminalGerm (rayGerm v s.1) (s.2 ++ attachWord c) = _ + rw [terminalGerm_append] + exact (attached_trace P (stemEnd v s) c hc hs.back_outside).2 + +theorem collision_splice_injective (D : Finset Vertex) (v : Vertex) + (P Q : Polygon) (s t c d : RayRecord) + (hs : s ∈ polygonStems D v P) (ht : t ∈ polygonStems D v Q) + (hc : c ∈ cyclesAt P (stemEnd v s).1) (hd : d ∈ cyclesAt Q (stemEnd v t).1) + (he : spliceRecord v s c = spliceRecord v t d) : P = Q ∧ s = t ∧ c = d := by + have hs' := (mem_polygonStems D v P s).mp hs + have ht' := (mem_polygonStems D v Q t).mp ht + have hends := congrArg (stemEnd v) he + rw [spliceRecord_terminal v P s c hs' hc,spliceRecord_terminal v Q t d ht' hd] at hends + have hends := Prod.mk.inj hends + have hwords : s.1 = t.1 ∧ + s.2 ++ attachWord c = t.2 ++ attachWord d := Prod.mk.inj he + have hst : s.2 = t.2 := by + apply first_cut_unique (rayGerm v s.1) (stemEnd v s).1 s.2 (attachWord c) t.2 (attachWord d) hwords.2 rfl + · rw [hwords.1] + exact hends.1.symm + · exact fun h => hs'.trace_disjoint _ h hs'.2.2 + · rw [hwords.1] + exact fun h => ht'.trace_disjoint _ h (hends.1.symm ▸ ht'.2.2) + have hst' : s = t := Prod.ext hwords.1 hst + subst t + have hcdw := attachWord_injective_on_words c d (List.append_cancel_left hwords.2) + have hcd : c = d := Prod.ext hends.2 hcdw + subst d + have hp := (mem_cyclesAt _ _ _).mp hc + have hq := (mem_cyclesAt _ _ _).mp hd + exact ⟨Subtype.ext (hp.2.2.2.symm.trans hq.2.2.2),rfl,rfl⟩ + +noncomputable def collisionData (D : Finset Vertex) (v : Vertex) : Finset (Polygon × RayRecord × RayRecord) := by + classical + exact (polygons D).biUnion fun P => + ((polygonStems D v P).biUnion fun s => + (cyclesAt P (stemEnd v s).1).image fun c => (s,c)).image fun sc => (P,sc) + +@[simp] theorem mem_collisionData (D : Finset Vertex) (v : Vertex) (P : Polygon) (s c : RayRecord) : + (P,s,c) ∈ collisionData D v ↔ P ∈ polygons D ∧ s ∈ polygonStems D v P ∧ + c ∈ cyclesAt P (stemEnd v s).1 := by + classical + simp only [collisionData,Finset.mem_biUnion,Finset.mem_image] + constructor + · rintro ⟨Q,hQ,⟨t,d⟩,⟨z,hz,a,ha,hza⟩,hQz⟩ + have he := Prod.mk.inj hQz + have he' := Prod.mk.inj hza + rcases he with ⟨rfl,he⟩ + have hzs : z = s := he'.1.trans (congrArg Prod.fst he) + have hac : a = c := he'.2.trans (congrArg Prod.snd he) + subst z + subst a + exact ⟨hQ,hz,ha⟩ + · rintro ⟨hP,hs,hc⟩ + exact ⟨P,hP,(s,c),⟨s,hs,c,hc,rfl⟩,rfl⟩ + +theorem collisionData_sum (D : Finset Vertex) (v : Vertex) : + (∑ z ∈ collisionData D v, wordWeight (spliceRecord v z.2.1 z.2.2).2) = + ∑ P ∈ polygons D, ∑ s ∈ polygonStems D v P, + ∑ c ∈ cyclesAt P (stemEnd v s).1, wordWeight (spliceRecord v s c).2 := by + classical + unfold collisionData + convert sum_record_three (polygons D) (polygonStems D v) + (fun P s => cyclesAt P (stemEnd v s).1) + (fun z : Polygon × RayRecord × RayRecord => wordWeight (spliceRecord v z.2.1 z.2.2).2) using 1 + apply Finset.sum_congr ?_ (fun _ _ => rfl) + ext z + simp only [Finset.mem_biUnion,Finset.mem_image] + +theorem collision_sum_grouped (D : Finset Vertex) (v : Vertex) : + (∑ e ∈ rayCollisions D v, wordWeight e.2) = + ∑ P ∈ polygons D, ∑ s ∈ polygonStems D v P, + ∑ c ∈ cyclesAt P (stemEnd v s).1, wordWeight (spliceRecord v s c).2 := by + classical + have hsum : (∑ z ∈ collisionData D v, wordWeight (spliceRecord v z.2.1 z.2.2).2) = + ∑ e ∈ rayCollisions D v, wordWeight e.2 := by + apply Finset.sum_bij (fun z _ => spliceRecord v z.2.1 z.2.2) + · intro z hz + have h := (mem_collisionData D v z.1 z.2.1 z.2.2).mp hz + exact spliceRecord_mem D v z.1 h.1 z.2.1 h.2.1 z.2.2 h.2.2 + · intro z hz y hy he + have h := (mem_collisionData D v z.1 z.2.1 z.2.2).mp hz + have h' := (mem_collisionData D v y.1 y.2.1 y.2.2).mp hy + have heq := collision_splice_injective D v z.1 y.1 z.2.1 y.2.1 z.2.2 y.2.2 h.2.1 h'.2.1 h.2.2 h'.2.2 he + exact Prod.ext heq.1 (Prod.ext heq.2.1 heq.2.2) + · intro e he + obtain ⟨P,s,c,hP,hs,hc,rfl⟩ := collision_splice_surjective D v e he + exact ⟨(P,s,c),(mem_collisionData D v P s c).mpr ⟨hP,hs,hc⟩,rfl⟩ + · intro z hz + rfl + exact hsum.symm.trans (collisionData_sum D v) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CollisionHistories.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionHistories.lean new file mode 100644 index 0000000000000000000000000000000000000000..aca57593071d3a2156eaa004643d85ae123107ca --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionHistories.lean @@ -0,0 +1,236 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.CycleSplice + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +@[simp] theorem neighbor_ne_self (v : Vertex) (k : Fin 3) : neighbor v k ≠ v := by + cases v <;> fin_cases k <;> simp [neighbor] + +@[simp] theorem outgoingSlot_ne (g : Germ) (b : Bool) : outgoingSlot g b ≠ g.2 := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [outgoingSlot] + +theorem terminal_previous_mem (g : Germ) (w : List Bool) (hw : w ≠ []) : + (reverseGerm (terminalGerm g w)).1 ∈ traced g w := by + induction w generalizing g with + | nil => contradiction + | cons b w ih => + cases w with + | nil => simp [terminalGerm,reverseGerm,advance,traced] + | cons c w => + exact List.mem_cons_of_mem _ (ih (advance g b) (by simp)) + +theorem terminal_previous_suffix (g : Germ) (b : Bool) (w : List Bool) (hw : w ≠ []) : + (reverseGerm (terminalGerm g (b :: w))).1 ∈ traced (advance g b) w := + terminal_previous_mem (advance g b) w hw + +theorem return_slot_ne_outgoing (g : Germ) (b : Bool) (w : List Bool) + (hN : (traced g (b :: w)).Nodup) + (hc : (terminalGerm g (b :: w)).1 = g.1) : + (terminalGerm g (b :: w)).2 ≠ outgoingSlot g b := by + cases w with + | nil => + have h : neighbor g.1 (outgoingSlot g b) = g.1 := hc + exact (neighbor_ne_self _ _ h).elim + | cons c w => + intro hs + cases w with + | nil => + exact outgoingSlot_ne (advance g b) c hs + | cons d w => + have hm := terminal_previous_mem (advance (advance g b) c) (d :: w) (by simp) + have he : (reverseGerm (terminalGerm (advance (advance g b) c) (d :: w))).1 = + (advance g b).1 := by + change neighbor (terminalGerm g (b :: c :: d :: w)).1 + (terminalGerm g (b :: c :: d :: w)).2 = _ + rw [hc,hs] + rfl + rw [he] at hm + exact (List.nodup_cons.mp (List.nodup_cons.mp hN).2).1 hm + +theorem return_slot_ne_incoming (g : Germ) (w : List Bool) (hw : w ≠ []) + (hc : (terminalGerm g w).1 = g.1) + (hback : (reverseGerm g).1 ∉ traced g w) : + (terminalGerm g w).2 ≠ g.2 := by + intro hs + have hm := terminal_previous_mem g w hw + have he : reverseGerm (terminalGerm g w) = reverseGerm g := by + congr 1 + exact Prod.ext hc hs + rw [he] at hm + exact hback hm + +theorem collision_root_slots (g : Germ) (b : Bool) (w : List Bool) + (hN : (traced g (b :: w)).Nodup) + (hc : (terminalGerm g (b :: w)).1 = g.1) + (hback : (reverseGerm g).1 ∉ traced g (b :: w)) : + stemGerm (terminalGerm g (b :: w)) (!b) = g ∧ + advance (terminalGerm g (b :: w)) (!b) = advance g b := by + have h1 := return_slot_ne_outgoing g b w hN hc + have h2 := return_slot_ne_incoming g (b :: w) (by simp) hc hback + let t := terminalGerm g (b :: w) + have ht : t.1 = g.1 := hc + change stemGerm t (!b) = g ∧ advance t (!b) = advance g b + change t.2 ≠ outgoingSlot g b at h1 + change t.2 ≠ g.2 at h2 + rcases g with ⟨v,k⟩ + rcases t with ⟨v',l⟩ + simp only at ht + subst v' + fin_cases k <;> fin_cases l <;> cases b <;> + simp [outgoingSlot] at h1 h2 ⊢ <;> + simp [stemGerm,unusedSlot,advance,outgoingSlot] + +def reverseAt (g : Germ) (v : Vertex) : List Bool → List Bool + | [] => [] + | b :: w => if g.1 = v then (!b) :: reverseTurns w + else b :: reverseAt (advance g b) v w + +@[simp] theorem reverseAt_involutive (g : Germ) (v : Vertex) (w : List Bool) : + reverseAt g v (reverseAt g v w) = w := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + by_cases h : g.1 = v + · simp [reverseAt,h] + · simp [reverseAt,h,ih] + +@[simp] theorem reverseAt_length (g : Germ) (v : Vertex) (w : List Bool) : + (reverseAt g v w).length = w.length := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + by_cases h : g.1 = v <;> simp [reverseAt,h,reverseTurns,ih] + +theorem stopped_iff_trace (D : Finset Vertex) (g : Germ) (w : List Bool) : + Stopped D g w ↔ (traced g w).Nodup ∧ (∀ v ∈ traced g w, v ∈ D) ∧ + ((terminalGerm g w).1 ∉ D ∨ (terminalGerm g w).1 ∈ traced g w) := by + induction w generalizing D g with + | nil => simp [Stopped,traced,terminalGerm] + | cons b w ih => + simp only [Stopped,ih,traced,List.nodup_cons,List.mem_cons,terminalGerm] + constructor + · rintro ⟨hg,hN,hD,ht⟩ + refine ⟨⟨?_,hN⟩,?_,?_⟩ + · intro hm + exact (Finset.mem_erase.mp (hD _ hm)).1 rfl + · intro v hv + rcases hv with rfl | hv + · exact hg + · exact Finset.mem_of_mem_erase (hD _ hv) + · rcases ht with ht | ht + · by_cases hm : (terminalGerm (advance g b) w).1 ∈ D + · right; left + by_contra hn + exact ht (Finset.mem_erase.mpr ⟨hn,hm⟩) + · exact Or.inl hm + · exact Or.inr (Or.inr ht) + · rintro ⟨⟨hn,hN⟩,hD,ht⟩ + refine ⟨hD _ (Or.inl rfl),hN,?_,?_⟩ + · intro v hv + exact Finset.mem_erase.mpr ⟨fun he => hn (he ▸ hv),hD _ (Or.inr hv)⟩ + · rcases ht with ht | ht | ht + · exact Or.inl (fun h => ht (Finset.mem_of_mem_erase h)) + · exact Or.inl (by simp [ht]) + · exact Or.inr ht + +theorem reverse_return_trace (g : Germ) (b : Bool) (w : List Bool) + (hN : (traced g (b :: w)).Nodup) + (hc : (terminalGerm g (b :: w)).1 = g.1) + (hback : (reverseGerm g).1 ∉ traced g (b :: w)) : + traced g ((!b) :: reverseTurns w) = + g.1 :: (traced (advance g b) w).reverse ∧ + (terminalGerm g ((!b) :: reverseTurns w)).1 = g.1 := by + let t := terminalGerm g (b :: w) + obtain ⟨hs,ha⟩ := collision_root_slots g b w hN hc hback + have ht : terminalGerm t ((!b) :: w) = t := by + change terminalGerm (advance t (!b)) w = t + rw [ha] + rfl + have hr := stem_reverse_trace t (!b) w ht + have he := reverse_loop_terminal t (!b) w ht + simp only [Bool.not_not] at hr he + rw [hs,ha,hc] at hr + constructor + · exact hr + · have hrev : advance g (!b) = advance (reverseLoopGerm t (!b)) b := by + have h1 := stem_reverse t (!b) + rw [hs] at h1 + exact h1.trans (by simpa using (reverseLoop_advance t (!b)).symm) + change (terminalGerm (advance g (!b)) (reverseTurns w)).1 = _ + rw [hrev] + change (terminalGerm (reverseLoopGerm t (!b)) (b :: reverseTurns w)).1 = _ + rw [he] + exact hc + +@[simp] theorem reverse_advance_vertex (g : Germ) (b : Bool) : + (reverseGerm (advance g b)).1 = g.1 := by + simp [reverseGerm, advance] + +theorem reverseAt_collision (g : Germ) (v : Vertex) (w : List Bool) + (hN : (traced g w).Nodup) (hv : v ∈ traced g w) + (ht : (terminalGerm g w).1 = v) + (hback : (reverseGerm g).1 ∉ traced g w) : + (traced g (reverseAt g v w)).Perm (traced g w) ∧ + (terminalGerm g (reverseAt g v w)).1 = v := by + induction w generalizing g with + | nil => simp [traced] at hv + | cons b w ih => + by_cases hg : g.1 = v + · have hc : (terminalGerm g (b :: w)).1 = g.1 := ht.trans hg.symm + obtain ⟨hr,he⟩ := reverse_return_trace g b w hN hc hback + simp only [reverseAt,ite_eq_left hg] + rw [hr] + exact ⟨List.Perm.cons _ (List.reverse_perm _),he.trans hg⟩ + · have hnt := (List.nodup_cons.mp hN) + have hvt : v ∈ traced (advance g b) w := by + simpa only [traced,List.mem_cons,eq_comm (a := v),hg,false_or] using hv + have hbt : (reverseGerm (advance g b)).1 ∉ traced (advance g b) w := by + simpa only [reverse_advance_vertex] using hnt.1 + obtain ⟨hp,he⟩ := ih (advance g b) hnt.2 hvt ht hbt + simp only [reverseAt,ite_eq_right hg,traced,terminalGerm] + exact ⟨List.Perm.cons _ hp,he⟩ + +def collisionReverse (g : Germ) (w : List Bool) : List Bool := + reverseAt g (terminalGerm g w).1 w + +theorem collisionReverse_properties (g : Germ) (w : List Bool) + (hN : (traced g w).Nodup) (ht : (terminalGerm g w).1 ∈ traced g w) + (hback : (reverseGerm g).1 ∉ traced g w) : + (traced g (collisionReverse g w)).Perm (traced g w) ∧ + (terminalGerm g (collisionReverse g w)).1 = (terminalGerm g w).1 ∧ + collisionReverse g (collisionReverse g w) = w := by + obtain ⟨hp,he⟩ := reverseAt_collision g (terminalGerm g w).1 w hN ht rfl hback + refine ⟨hp,he,?_⟩ + unfold collisionReverse + rw [he] + exact reverseAt_involutive _ _ _ + +theorem collisionReverse_leaf (D : Finset Vertex) (g : Germ) (w : List Bool) + (hw : w ∈ leaves D g) (hg : (reverseGerm g).1 ∉ D) + (ht : (terminalGerm g w).1 ∈ D) : + collisionReverse g w ∈ leaves D g ∧ + (terminalGerm g (collisionReverse g w)).1 ∈ D ∧ + (∀ v, v ∈ traced g (collisionReverse g w) ↔ v ∈ traced g w) ∧ + collisionReverse g (collisionReverse g w) = w := by + have hs := (stopped_iff_trace D g w).mp ((mem_leaves_iff D g w).mp hw) + have hm : (terminalGerm g w).1 ∈ traced g w := hs.2.2.resolve_left (not_not.mpr ht) + have hb : (reverseGerm g).1 ∉ traced g w := fun h => hg (hs.2.1 _ h) + obtain ⟨hp,he,hinv⟩ := collisionReverse_properties g w hs.1 hm hb + refine ⟨(mem_leaves_iff _ _ _).mpr ((stopped_iff_trace _ _ _).mpr ?_),he ▸ ht, + fun v => hp.mem_iff,hinv⟩ + refine ⟨hp.nodup_iff.mpr hs.1,?_,Or.inr ?_⟩ + · intro v hv + exact hs.2.1 v (hp.mem_iff.mp hv) + · rw [he] + exact hp.mem_iff.mpr hm + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CollisionPhase.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionPhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..e28a2c573c07bac7c7c6eac5ed8dcc6a428971d8 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionPhase.lean @@ -0,0 +1,133 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Polygons + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def unusedSlot (g : Germ) (b : Bool) : Fin 3 := outgoingSlot g (!b) + +@[simp] theorem turnUnit_not (b : Bool) : turnUnit (!b) = -turnUnit b := by + cases b <;> simp [turnUnit] + +@[simp] theorem turnUnits_cons (b : Bool) (w : List Bool) : + turnUnits (b :: w) = turnUnit b + turnUnits w := by + simp [turnUnits] + +@[simp] theorem turnUnits_reverse (w : List Bool) : + turnUnits (reverseTurns w) = -turnUnits w := by + simp [turnUnits,reverseTurns,List.map_map,Function.comp_def,List.sum_neg] + +@[simp] theorem wordWeight_append (u w : List Bool) : + wordWeight (u ++ w) = wordWeight u * wordWeight w := by + simp [wordWeight] + +theorem turnAngle_sum (w : List Bool) : + (w.map turnAngle).sum = (Real.pi / 3) * (turnUnits w : ℝ) := by + induction w with + | nil => simp [turnUnits] + | cons b w ih => + simp only [List.map_cons,List.sum_cons,ih,turnUnits_cons,Int.cast_add] + cases b <;> simp [turnAngle,turnUnit] <;> ring + +theorem wordWeight_turnUnits (w : List Bool) : + wordWeight w = (criticalActivity : ℂ) ^ w.length * + Complex.exp (((Real.pi / 8) * (turnUnits w : ℝ) : ℝ) * Complex.I) := by + rw [wordWeight_physical,turnAngle_sum] + congr 2 + push_cast + ring + +theorem collision_weights_conjugate (b : Bool) (w : List Bool) : + wordWeight (b :: reverseTurns w) = starRingEnd ℂ (wordWeight ((!b) :: w)) := by + rw [← wordWeight_reverse,reverseTurns_cons,Bool.not_not,wordWeight_append] + simp [wordWeight,mul_comm] + +theorem collision_weights_cos (b : Bool) (w : List Bool) : + wordWeight ((!b) :: w) + wordWeight (b :: reverseTurns w) = + (2 : ℂ) * (criticalActivity : ℂ) ^ (b :: w).length * + (Real.cos (Real.pi / 8 * ((turnUnits (b :: w) - 2 * turnUnit b : ℤ) : ℝ)) : ℂ) := by + rw [collision_weights_conjugate,wordWeight_turnUnits] + have ht : turnUnits ((!b) :: w) = turnUnits (b :: w) - 2 * turnUnit b := by + simp only [turnUnits_cons,turnUnit_not] + ring + rw [ht,Complex.exp_ofReal_mul_I] + simp only [List.length_cons,map_mul,map_add,map_pow,Complex.conj_ofReal, + map_mul,Complex.conj_I] + ring + +theorem numeric_unused_face (f : Fin 3 → ℤ) (ε : ℤ) + (hε : ε = 1 ∨ ε = -1) (hf : ∀ l, f l = 0 ∨ f l = ε) + (k : Fin 3) (b : Bool) + (h : ∀ l : Fin 3, f l - f (l+2) = + (if l = k + (if b then 2 else 1) then 1 else 0) - (if l = k then 1 else 0)) : + 2 * f (k + (if !b then 2 else 1)) = ε - turnUnit b := by + have h0 := h 0 + have h1 := h 1 + have h2 := h 2 + have hf0 := hf 0 + have hf1 := hf 1 + have hf2 := hf 2 + clear h hf + rcases hε with rfl | rfl <;> fin_cases k <;> cases b <;> + simp [turnUnit] at * <;> omega + +theorem contour_unused_face (p : FaceIndex →₀ ℤ) (ε : ℤ) + (hε : ε = 1 ∨ ε = -1) (hvals : ∀ a, p a = 0 ∨ p a = ε) + (q : EdgeIndex →₀ ℤ) (hp : RepresentsFlow p q) + (g : Germ) (b : Bool) (hw : LocalContour q g b) : + 2 * p (leftFace (g.1,unusedSlot g b)) = ε - turnUnit b := by + let f : Fin 3 → ℤ := fun l => p (leftFace (g.1,l)) + have hl (l : Fin 3) : f l - f (l+2) = + (if l = g.2 + (if b then 2 else 1) then 1 else 0) - (if l = g.2 then 1 else 0) := by + have h := (hp (g.1,l)).symm.trans (hw l) + simp only [f,rightFace_prev,outgoingSlot] at h ⊢ + exact h + exact numeric_unused_face f ε hε (fun l => hvals _) g.2 b hl + +def CollisionPhase : Prop := ∀ (g : Germ) (b : Bool) (w : List Bool) + (p : FaceIndex →₀ ℤ) (ε : ℤ), + (traced g (b :: w)).Nodup → terminalGerm g (b :: w) = g → + RepresentsFlow p (wordFlow g (b :: w)) → p ≠ 0 → + (ε = 1 ∨ ε = -1) → (∀ a, p a = 0 ∨ p a = ε) → + wordWeight ((!b) :: w) + wordWeight (b :: reverseTurns w) = + if p (leftFace (g.1,unusedSlot g b)) = 0 then 0 + else -2 * (criticalActivity : ℂ) ^ (b :: w).length + +theorem collision_phase : CollisionPhase := by + intro g b w p ε hN hc hp hpne hε hvals + have ht := simple_polygon_signed_turn g (b :: w) (by simp) hN hc p ε hp hpne hε hvals + have hf := contour_unused_face p ε hε hvals (wordFlow g (b :: w)) hp g b + (simple_closed_word_contour g (b :: w) hN hc).1 + rw [collision_weights_cos] + have hhalf : (Real.pi : ℂ) / 8 * 4 = (Real.pi : ℂ) / 2 := by ring + rcases hε with rfl | rfl <;> cases b + · have htw : turnUnits (false :: w) = 6 := by simpa using ht + have hpv : p (leftFace (g.1,unusedSlot g false)) = 1 := by + norm_num [turnUnit] at hf + omega + norm_num [htw,hpv,turnUnit,hhalf,Complex.cos_pi_div_two] + · have htw : turnUnits (true :: w) = 6 := by simpa using ht + have hpv : p (leftFace (g.1,unusedSlot g true)) = 0 := by + norm_num [turnUnit] at hf + omega + norm_num [htw,hpv,turnUnit,hhalf,Complex.cos_pi_div_two] + · have htw : turnUnits (false :: w) = -6 := by + simpa only [neg_one_mul,neg_eq_iff_eq_neg] using ht + have hpv : p (leftFace (g.1,unusedSlot g false)) = 0 := by + norm_num [turnUnit] at hf + omega + norm_num [htw,hpv,turnUnit,hhalf,Complex.cos_pi_div_two] + · have htw : turnUnits (true :: w) = -6 := by + simpa only [neg_one_mul,neg_eq_iff_eq_neg] using ht + have hpv : p (leftFace (g.1,unusedSlot g true)) = -1 := by + norm_num [turnUnit] at hf + omega + norm_num [htw,hpv,turnUnit,hhalf,Complex.cos_pi_div_two] +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CollisionStems.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionStems.lean new file mode 100644 index 0000000000000000000000000000000000000000..8990a85a5e3250e5ab9220f32032e6a388c80e8a --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionStems.lean @@ -0,0 +1,176 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.ReturnCycles +import OAI.Combinatorics.HoneycombCorridor.PolygonNesting + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def stemEnd (v : Vertex) (s : RayRecord) : Germ := terminalGerm (rayGerm v s.1) s.2 + +def IsPolygonStem (D : Finset Vertex) (v : Vertex) (P : Polygon) (s : RayRecord) : Prop := + v ∉ P.vertices ∧ Stopped ((D \ P.vertices).erase v) (rayGerm v s.1) s.2 ∧ + (stemEnd v s).1 ∈ P.vertices + +noncomputable def polygonStems (D : Finset Vertex) (v : Vertex) (P : Polygon) : + Finset RayRecord := by + classical + exact (rayLeaves (D \ P.vertices) v).filter (IsPolygonStem D v P) + +@[simp] theorem mem_polygonStems (D : Finset Vertex) (v : Vertex) (P : Polygon) (s : RayRecord) : + s ∈ polygonStems D v P ↔ IsPolygonStem D v P s := by + classical + simp only [polygonStems,Finset.mem_filter,mem_rayLeaves] + exact ⟨And.right,fun h => ⟨h.2.1,h⟩⟩ + +theorem IsPolygonStem.trace_disjoint {D : Finset Vertex} {v : Vertex} {P : Polygon} + {s : RayRecord} (hs : IsPolygonStem D v P s) : + ∀ a ∈ traced (rayGerm v s.1) s.2, a ∉ P.vertices := by + intro a ha + exact (Finset.mem_sdiff.mp (Finset.mem_of_mem_erase + (((stopped_iff_trace _ _ _).mp hs.2.1).2.1 a ha))).2 + +theorem IsPolygonStem.back_outside {D : Finset Vertex} {v : Vertex} {P : Polygon} + {s : RayRecord} (hs : IsPolygonStem D v P s) : + (reverseGerm (stemEnd v s)).1 ∉ P.vertices := by + by_cases hn : s.2 = [] + · simpa only [stemEnd,hn,terminalGerm,rayGerm,reverseGerm,neighbor_neighbor] using hs.1 + · exact hs.trace_disjoint _ (terminal_previous_mem _ _ hn) + +theorem Polygon.neighbor_mem_of_edge (P : Polygon) (g : Germ) + (hg : edgeOf g ∈ P.val) : (reverseGerm g).1 ∈ P.vertices := by + apply (mem_edgeVertices P.val _).mpr + exact ⟨g.2,by change edgeOf (reverseGerm g) ∈ P.val; simpa using hg⟩ + +theorem thirdSlot_unique (g : Germ) (b : Bool) (k : Fin 3) + (hi : k ≠ g.2) (ho : k ≠ outgoingSlot g b) : k = unusedSlot g b := by + rcases g with ⟨v,l⟩ + fin_cases k <;> fin_cases l <;> cases b <;> + simp [outgoingSlot,unusedSlot] at hi ho ⊢ + +theorem stemGerm_eq_of_back_outside (P : Polygon) (t : Germ) (k : Fin 3) + (b : Bool) (w : List Bool) (hc : P.Traverses (t.1,k) (b :: w)) + (hb : (reverseGerm t).1 ∉ P.vertices) : stemGerm (t.1,k) b = t := by + have hn : edgeOf t ∉ P.val := fun h => hb (P.neighbor_mem_of_edge t h) + have hloc := (simple_closed_word_contour _ _ hc.2.1 hc.2.2.1).1 + have hslots : ¬ (t.2 = k ∨ t.2 = outgoingSlot (t.1,k) b) := by + intro hh + apply hn + rw [← hc.2.2.2] + exact (local_contour_support _ (t.1,k) b hloc t.2).mpr hh + have h := thirdSlot_unique (t.1,k) b t.2 + (fun he => hslots (Or.inl he)) (fun he => hslots (Or.inr he)) + exact Prod.ext rfl h.symm + +def attachWord (c : RayRecord) : List Bool := + match c.2 with + | [] => [] + | b :: w => (!b) :: w + +theorem attachWord_injective_on_words (c d : RayRecord) (h : attachWord c = attachWord d) : + c.2 = d.2 := by + cases hc : c.2 with + | nil => cases hd : d.2 <;> simp_all [attachWord] + | cons b w => + cases hd : d.2 with + | nil => simp_all [attachWord] + | cons e u => + have hp : (!b) = (!e) ∧ w = u := by simpa only [attachWord,hc,hd,List.cons.injEq] using h + have hbe : b = e := by simpa using congrArg Bool.not hp.1 + simp only [hbe,hp.2] + +theorem attached_trace (P : Polygon) (t : Germ) (c : RayRecord) + (hc : c ∈ cyclesAt P t.1) (hb : (reverseGerm t).1 ∉ P.vertices) : + traced t (attachWord c) = traced (t.1,c.1) c.2 ∧ + terminalGerm t (attachWord c) = (t.1,c.1) := by + have h := (mem_cyclesAt P t.1 c).mp hc + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil h.1 + have htr : P.Traverses (t.1,c.1) (b :: w) := hw ▸ h + have he := stemGerm_eq_of_back_outside P t c.1 b w htr hb + simp only [attachWord,hw] + constructor + · rw [← he,stem_forward_trace] + rfl + · rw [← he,stem_forward_terminal] + exact htr.2.2.1 + +theorem first_cut_unique (g : Germ) (a : Vertex) (u r u' r' : List Bool) + (he : u ++ r = u' ++ r') + (hu : (terminalGerm g u).1 = a) (hu' : (terminalGerm g u').1 = a) + (hn : a ∉ traced g u) (hn' : a ∉ traced g u') : u = u' := by + induction u generalizing g u' with + | nil => + cases u' with + | nil => rfl + | cons b u' => exact (hn' (by simp [traced,← hu,terminalGerm])).elim + | cons b u ih => + cases u' with + | nil => exact (hn (by simp [traced,← hu',terminalGerm])).elim + | cons c u' => + simp only [List.cons_append,List.cons.injEq] at he + rcases he with ⟨rfl,he⟩ + apply congrArg (List.cons b) + exact ih (advance g b) u' he hu hu' + (fun h => hn (List.mem_cons_of_mem _ h)) + (fun h => hn' (List.mem_cons_of_mem _ h)) + +def spliceRecord (v : Vertex) (s c : RayRecord) : RayRecord := + ((rayGerm v s.1).2,s.2 ++ attachWord c) + +noncomputable def rayCollisions (D : Finset Vertex) (v : Vertex) : Finset RayRecord := by + classical + exact (rayLeaves D v).filter fun e => (stemEnd v e).1 ∈ D.erase v + +@[simp] theorem mem_rayCollisions (D : Finset Vertex) (v : Vertex) (e : RayRecord) : + e ∈ rayCollisions D v ↔ Stopped (D.erase v) (rayGerm v e.1) e.2 ∧ + (stemEnd v e).1 ∈ D.erase v := by + classical + simp [rayCollisions] + +theorem spliceRecord_mem (D : Finset Vertex) (v : Vertex) (P : Polygon) + (hP : P ∈ polygons D) (s : RayRecord) (hs : s ∈ polygonStems D v P) + (c : RayRecord) (hc : c ∈ cyclesAt P (stemEnd v s).1) : + spliceRecord v s c ∈ rayCollisions D v := by + have hs := (mem_polygonStems D v P s).mp hs + have htr := (mem_cyclesAt P _ c).mp hc + have hat := attached_trace P (stemEnd v s) c hc hs.back_outside + have hN := (stopped_iff_trace _ _ _).mp hs.2.1 + have hct : (stemEnd v (spliceRecord v s c)).1 = (stemEnd v s).1 := by + simp only [stemEnd,spliceRecord,terminalGerm_append] + have hh := congrArg (fun g : Germ => g.1) hat.2 + exact hh + have htmem : (stemEnd v s).1 ∈ D.erase v := + Finset.mem_erase.mpr ⟨fun h => hs.1 (h ▸ hs.2.2),(mem_polygons D P).mp hP hs.2.2⟩ + rw [mem_rayCollisions] + refine ⟨?_,by rw [hct]; exact htmem⟩ + apply (stopped_iff_trace _ _ _).mpr + have htrace : traced (rayGerm v (spliceRecord v s c).1) (spliceRecord v s c).2 = + traced (rayGerm v s.1) s.2 ++ traced ((stemEnd v s).1,c.1) c.2 := by + change traced (rayGerm v s.1) (s.2 ++ attachWord c) = _ + rw [traced_append] + change traced (rayGerm v s.1) s.2 ++ traced (stemEnd v s) (attachWord c) = _ + rw [hat.1] + rw [htrace] + refine ⟨List.nodup_append.mpr ⟨hN.1,htr.2.1,?_⟩,?_,Or.inr ?_⟩ + · intro a ha b hb hab + subst b + exact hs.trace_disjoint a ha (by rw [htr.vertices]; exact List.mem_toFinset.mpr hb) + · intro a ha + rcases List.mem_append.mp ha with ha | ha + · exact Finset.mem_erase.mpr ⟨(Finset.mem_erase.mp (hN.2.1 a ha)).1, + (Finset.mem_sdiff.mp (Finset.mem_of_mem_erase (hN.2.1 a ha))).1⟩ + · have haP : a ∈ P.vertices := by rw [htr.vertices]; exact List.mem_toFinset.mpr ha + exact Finset.mem_erase.mpr ⟨fun h => hs.1 (h ▸ haP),(mem_polygons D P).mp hP haP⟩ + · change (stemEnd v (spliceRecord v s c)).1 ∈ _ + rw [hct] + apply List.mem_append_right + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil htr.1 + simp [hw,traced] + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CollisionWeights.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..eca9742a3e77a4862f339b122847ee895287322e --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CollisionWeights.lean @@ -0,0 +1,152 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.CollisionGrouping + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +theorem IsPolygonStem.left_potential {D : Finset Vertex} {v : Vertex} {P : Polygon} + {s : RayRecord} (hs : IsPolygonStem D v P s) : + P.potential (leftFace (stemEnd v s)) = vertexLevel P.potential v := by + rw [stemEnd,P.trace_left_potential _ _ hs.trace_disjoint] + change P.potential (rightFace (v,s.1)) = _ + exact (P.off_boundary_faces v hs.1 s.1).2 + +theorem collision_cycle_weight (D : Finset Vertex) (v : Vertex) (P : Polygon) + (s c : RayRecord) (hs : s ∈ polygonStems D v P) + (hc : c ∈ cyclesAt P (stemEnd v s).1) : + wordWeight (attachWord c) + wordWeight (attachWord (reverseCycle (stemEnd v s).1 c)) = + if v ∈ P.interior then -2 * (criticalActivity : ℂ) ^ P.length else 0 := by + classical + have hs' := (mem_polygonStems D v P s).mp hs + have h := (mem_cyclesAt P _ c).mp hc + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil h.1 + let g : Germ := ((stemEnd v s).1,c.1) + have htr : P.Traverses g (b :: w) := hw ▸ h + have he := stemGerm_eq_of_back_outside P (stemEnd v s) c.1 b w htr hs'.back_outside + obtain ⟨p,ε,hp,hpne,hε,hvals⟩ := simple_closed_word_indicator g (b :: w) + (by simp) htr.2.1 htr.2.2.1 + have hfaces := P.interiorFaces_of_traversal g (b :: w) htr.2.1 htr.2.2.1 htr.2.2.2 p hp + have hz : p (leftFace (stemEnd v s)) = 0 ↔ v ∉ P.interior := by + rw [P.interior_iff_level] + simp only [hs'.1,not_false_eq_true,true_and,not_not] + rw [← hs'.left_potential] + constructor + · intro h + apply Finsupp.notMem_support_iff.mp + change leftFace (stemEnd v s) ∉ P.interiorFaces + rw [hfaces] + exact Finsupp.notMem_support_iff.mpr h + · intro h + apply Finsupp.notMem_support_iff.mp + rw [← hfaces] + exact Finsupp.notMem_support_iff.mpr h + + have hphase := collision_phase g b w p ε htr.2.1 htr.2.2.1 hp hpne hε hvals + change stemGerm g b = stemEnd v s at he + change wordWeight ((!b) :: w) + wordWeight (b :: reverseTurns w) = + if p (leftFace (stemGerm g b)) = 0 then 0 else _ at hphase + rw [he,← htr.length] at hphase + simp only [attachWord,hw,reverseCycle,Bool.not_not] + rw [hphase] + by_cases hv : v ∈ P.interior + · rw [ite_eq_left hv,ite_eq_right (fun h => hz.mp h hv)] + · rw [ite_eq_right hv,ite_eq_left (hz.mpr hv)] + +theorem collision_cycle_sum (D : Finset Vertex) (v : Vertex) (P : Polygon) + (s : RayRecord) (hs : s ∈ polygonStems D v P) : + (∑ c ∈ cyclesAt P (stemEnd v s).1, wordWeight (spliceRecord v s c).2) = + if v ∈ P.interior then -2 * (criticalActivity : ℂ) ^ P.length * wordWeight s.2 else 0 := by + classical + have hs' := (mem_polygonStems D v P s).mp hs + obtain ⟨k,w,hw⟩ := P.exists_rooted (stemEnd v s).1 hs'.2.2 + have he := (mem_cyclesAt P _ (k,w)).mpr hw + rw [cyclesAt_eq_pair P _ (k,w) he,Finset.sum_pair (Ne.symm (reverseCycle_ne P _ (k,w) he))] + simp only [spliceRecord,wordWeight_append] + rw [← mul_add,collision_cycle_weight D v P s (k,w) hs he] + split_ifs <;> ring + +theorem Polygon.trace_interior_of_back (P : Polygon) (g : Germ) (w : List Bool) + (hb : (reverseGerm g).1 ∈ P.interior) + (hd : ∀ a ∈ traced g w, a ∉ P.vertices) : + (∀ a ∈ traced g w, a ∈ P.interior) ∧ (reverseGerm (terminalGerm g w)).1 ∈ P.interior := by + induction w generalizing g with + | nil => exact ⟨by simp [traced],hb⟩ + | cons b w ih => + have hg : g.1 ∈ P.interior := by + by_contra hn + have he := P.interior_exit_on_boundary (reverseGerm g).1 g.2 hb + (by simpa [reverseGerm] using hn) + apply hd g.1 (by simp [traced]) + simpa [reverseGerm] using he + have ha : (reverseGerm (advance g b)).1 ∈ P.interior := by + simpa [advance,reverseGerm] using hg + have hi := ih (advance g b) ha (fun a hm => hd a (List.mem_cons_of_mem _ hm)) + refine ⟨?_,hi.2⟩ + intro a ha + rcases List.mem_cons.mp ha with rfl | ha + · exact hg + · exact hi.1 a ha + +theorem polygonStems_eq_rayExits (D : Finset Vertex) (v : Vertex) (P : Polygon) + (hD : Filled D) (hP : P ∈ polygons D) (hv : v ∈ P.interior) : + polygonStems D v P = rayExits P.interior v := by + classical + ext s + rw [mem_polygonStems,mem_rayExits] + have hb : (reverseGerm (rayGerm v s.1)).1 ∈ P.interior := by simpa [rayGerm,reverseGerm] using hv + constructor + · intro hs + have hn := (stopped_iff_trace _ _ _).mp hs.2.1 + have hi := P.trace_interior_of_back (rayGerm v s.1) s.2 hb hs.trace_disjoint + have ht : (stemEnd v s).1 ∉ P.interior := fun h => ((P.mem_interior _).mp h).2 hs.2.2 + refine ⟨(stopped_iff_trace _ _ _).mpr ⟨hn.1,?_,Or.inl ?_⟩,ht⟩ + · intro a ha + exact Finset.mem_erase.mpr ⟨(Finset.mem_erase.mp (hn.2.1 a ha)).1,hi.1 a ha⟩ + · exact fun h => ht (Finset.mem_of_mem_erase h) + · rintro ⟨hs,he⟩ + have hn := (stopped_iff_trace _ _ _).mp hs + have hd : ∀ a ∈ traced (rayGerm v s.1) s.2, a ∉ P.vertices := by + intro a ha + exact ((P.mem_interior a).mp (Finset.mem_of_mem_erase (hn.2.1 a ha))).2 + have hi := P.trace_interior_of_back (rayGerm v s.1) s.2 hb hd + have ht : (stemEnd v s).1 ∈ P.vertices := by + have h := P.interior_exit_on_boundary (reverseGerm (stemEnd v s)).1 (stemEnd v s).2 hi.2 + (by simpa only [reverseGerm,neighbor_neighbor,stemEnd,rayGerm] using he) + simpa [reverseGerm] using h + refine ⟨((P.mem_interior v).mp hv).2,(stopped_iff_trace _ _ _).mpr ⟨hn.1,?_,Or.inl ?_⟩,ht⟩ + · intro a ha + have hpa := hn.2.1 a ha + exact Finset.mem_erase.mpr ⟨(Finset.mem_erase.mp hpa).1, + Finset.mem_sdiff.mpr ⟨hD P hP (Finset.mem_of_mem_erase hpa),hd a ha⟩⟩ + · exact fun h => (Finset.mem_sdiff.mp (Finset.mem_of_mem_erase h)).2 ht + +theorem collision_sum_polygons (D : Finset Vertex) (v : Vertex) (hD : Filled D) : + (∑ e ∈ rayCollisions D v, wordWeight e.2) = + ∑ P ∈ polygons D, if v ∈ P.interior then + -2 * (criticalActivity : ℂ) ^ P.length * visitSum P.interior v else 0 := by + classical + rw [collision_sum_grouped] + apply Finset.sum_congr rfl + intro P hP + have hsum : (∑ s ∈ polygonStems D v P, ∑ c ∈ cyclesAt P (stemEnd v s).1, + wordWeight (spliceRecord v s c).2) = + ∑ s ∈ polygonStems D v P, if v ∈ P.interior then + -2 * (criticalActivity : ℂ) ^ P.length * wordWeight s.2 else 0 := by + apply Finset.sum_congr rfl + intro s hs + exact collision_cycle_sum D v P s hs + rw [hsum] + by_cases hv : v ∈ P.interior + · simp only [ite_eq_left hv] + rw [← Finset.mul_sum,polygonStems_eq_rayExits D v P hD hP hv, + rayExits_eq_visitSum P.interior v P.interior_filled hv] + · simp [hv] + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Contours.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Contours.lean new file mode 100644 index 0000000000000000000000000000000000000000..f72bd06fef889c857b5c35fde9005e2af31d6fd8 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Contours.lean @@ -0,0 +1,331 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Excursions +import OAI.Combinatorics.HoneycombCorridor.EdgeFlow + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def orientedFlow : (EdgeIndex →₀ ℤ) →+ (Germ →₀ ℤ) := + Finsupp.liftAddHom fun e => + Finsupp.singleAddHom (upEnd e,e.2) - Finsupp.singleAddHom (downEnd e,e.2) + +@[simp] theorem orientedFlow_single (e : EdgeIndex) (a : ℤ) : + orientedFlow (Finsupp.single e a) = + Finsupp.single (upEnd e,e.2) a - Finsupp.single (downEnd e,e.2) a := by + simp [orientedFlow] + +@[simp] theorem orientedFlow_dartFlow (g : Germ) : + orientedFlow (dartFlow g) = Finsupp.single g 1 - Finsupp.single (reverseGerm g) 1 := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> + simp [dartFlow,edgeOf,dartSign,upEnd,downEnd,neighbor,reverseGerm] + +noncomputable def turnVisit : Germ → List Bool → (Germ →₀ ℤ) + | _, [] => 0 + | g, b :: w => + Finsupp.single (g.1,outgoingSlot g b) 1 - Finsupp.single g 1 + + turnVisit (advance g b) w + +theorem orientedFlow_wordFlow (g : Germ) (w : List Bool) : + orientedFlow (wordFlow g w) = + turnVisit g w + Finsupp.single g 1 - Finsupp.single (terminalGerm g w) 1 := by + induction w generalizing g with + | nil => simp [wordFlow,turnVisit,terminalGerm] + | cons b w ih => + simp only [wordFlow,map_add,orientedFlow_dartFlow,turnVisit,terminalGerm,ih] + have h : reverseGerm (g.1,outgoingSlot g b) = advance g b := rfl + rw [h] + abel + +theorem turnVisit_eq_zero_of_not_mem (g : Germ) (w : List Bool) (v : Vertex) + (k : Fin 3) (hv : v ∉ traced g w) : turnVisit g w (v,k) = 0 := by + classical + induction w generalizing g with + | nil => simp [turnVisit] + | cons b w ih => + simp only [traced,List.mem_cons,not_or] at hv + have hne : (v,k) ≠ g := by intro h; exact hv.1 (congrArg Prod.fst h) + have hne' : (g.1,outgoingSlot g b) ≠ (v,k) := by + intro h; exact hv.1 (congrArg Prod.fst h).symm + simp [turnVisit,ih _ hv.2,hne,hne'] + +theorem simple_closed_word_local (g : Germ) (b : Bool) (w : List Bool) + (hN : (traced g (b :: w)).Nodup) (hc : terminalGerm g (b :: w) = g) + (k : Fin 3) : + orientedFlow (wordFlow g (b :: w)) (g.1,k) = + (if k = outgoingSlot g b then 1 else 0) - (if k = g.2 then 1 else 0) := by + classical + rw [orientedFlow_wordFlow,hc,add_sub_cancel_right] + simp only [traced,List.nodup_cons] at hN + have ht := turnVisit_eq_zero_of_not_mem (advance g b) w g.1 k hN.1 + rcases g with ⟨v,j⟩ + simp [turnVisit,ht,Finsupp.single_apply,eq_comm] + +theorem orientedFlow_up (q : EdgeIndex →₀ ℤ) (i j : ℤ) (k : Fin 3) : + orientedFlow q (.up i j,k) = q ((i,j),k) := by + classical + induction q using Finsupp.induction_linear with + | zero => simp + | add q r hq hr => simp only [map_add,Finsupp.add_apply,hq,hr] + | single e a => + rcases e with ⟨⟨x,y⟩,l⟩ + fin_cases l <;> fin_cases k <;> + simp [orientedFlow_single,upEnd,downEnd,neighbor,Finsupp.single_apply,eq_comm] + +theorem orientedFlow_down (q : EdgeIndex →₀ ℤ) (i j : ℤ) (k : Fin 3) : + orientedFlow q (.down i j,k) = -q (edgeOf (.down i j,k)) := by + classical + induction q using Finsupp.induction_linear with + | zero => simp + | add q r hq hr => simp only [map_add,Finsupp.add_apply,hq,hr]; ring + | single e a => + rcases e with ⟨⟨x,y⟩,l⟩ + have hy : j = y - 1 ↔ y = j + 1 := by omega + have hx : i = x - 1 ↔ x = i + 1 := by omega + fin_cases l <;> fin_cases k <;> + simp [orientedFlow_single,edgeOf,upEnd,downEnd,neighbor,Finsupp.single_apply,eq_comm,hy,hx] + +def leftFace : Germ → FaceIndex + | (.up i j,k) => if k = 0 then (i,j) else if k = 1 then (i-1,j+1) else (i-1,j) + | (.down i j,k) => if k = 0 then (i-1,j+1) else if k = 1 then (i,j) else (i,j+1) + +def rightFace (g : Germ) : FaceIndex := leftFace (reverseGerm g) + +def RepresentsFlow (p : FaceIndex →₀ ℤ) (q : EdgeIndex →₀ ℤ) : Prop := + ∀ g : Germ, orientedFlow q g = p (leftFace g) - p (rightFace g) + +theorem closed_word_has_potential (g : Germ) (w : List Bool) + (hc : terminalGerm g w = g) : + ∃ p : FaceIndex →₀ ℤ, RepresentsFlow p (wordFlow g w) := by + obtain ⟨p,hp⟩ := closed_word_has_finite_potential g w hc + refine ⟨p, ?_⟩ + intro d + rcases d with ⟨v,k⟩ + cases v with + | up i j => + have h := hp i j + fin_cases k <;> + simp [orientedFlow_up,leftFace,rightFace,reverseGerm,neighbor] <;> omega + | down i j => + have h0 := (hp i (j+1)).1 + have h1 := (hp i j).2.1 + have h2 := (hp (i+1) j).2.2 + fin_cases k <;> + simp [orientedFlow_down,edgeOf,leftFace,rightFace,reverseGerm,neighbor] at * <;> omega + + + +@[simp] theorem wordFlow_append (g : Germ) (u w : List Bool) : + wordFlow g (u ++ w) = wordFlow g u + wordFlow (terminalGerm g u) w := by + induction u generalizing g with + | nil => simp [wordFlow,terminalGerm] + | cons b u ih => simp [wordFlow,terminalGerm,ih,add_assoc] + +theorem closed_word_rotate (g : Germ) (u w : List Bool) + (hN : (traced g (u ++ w)).Nodup) (hc : terminalGerm g (u ++ w) = g) : + let g' := terminalGerm g u + (traced g' (w ++ u)).Nodup ∧ + terminalGerm g' (w ++ u) = g' ∧ wordFlow g' (w ++ u) = wordFlow g (u ++ w) := by + dsimp only + have ht : terminalGerm (terminalGerm g u) w = g := by simpa using hc + rw [traced_append] at hN + simp only [traced_append,terminalGerm_append,wordFlow_append,ht] + exact ⟨List.nodup_append_comm.mp hN,trivial,add_comm _ _⟩ + +def LocalContour (q : EdgeIndex →₀ ℤ) (g : Germ) (b : Bool) : Prop := + ∀ k : Fin 3, orientedFlow q (g.1,k) = + (if k = outgoingSlot g b then 1 else 0) - (if k = g.2 then 1 else 0) + +def WordContour (q : EdgeIndex →₀ ℤ) : Germ → List Bool → Prop + | _, [] => True + | g, b :: w => LocalContour q g b ∧ WordContour q (advance g b) w + +theorem wordContour_of_splits (q : EdgeIndex →₀ ℤ) (g : Germ) (w : List Bool) + (hs : ∀ u b v, w = u ++ b :: v → LocalContour q (terminalGerm g u) b) : + WordContour q g w := by + induction w generalizing g with + | nil => trivial + | cons b w ih => + refine ⟨by simpa only [terminalGerm] using hs [] b w rfl, ih (advance g b) ?_⟩ + intro u c v hv + simpa only [terminalGerm] using hs (b :: u) c v (by simp [hv]) + +theorem simple_closed_word_contour (g : Germ) (w : List Bool) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) : + WordContour (wordFlow g w) g w := by + apply wordContour_of_splits + intro u b v h + subst w + obtain ⟨hN',hc',hq⟩ := closed_word_rotate g u (b :: v) hN hc + rw [← hq] + intro k + exact simple_closed_word_local (terminalGerm g u) b (v ++ u) hN' hc' k + +theorem localContour_sides (p : FaceIndex →₀ ℤ) (q : EdgeIndex →₀ ℤ) + (hp : RepresentsFlow p q) (g : Germ) (b : Bool) (hl : LocalContour q g b) : + p (rightFace (advance g b)) = p (rightFace g) ∧ + p (leftFace (advance g b)) = p (leftFace g) ∧ + p (rightFace g) - p (leftFace g) = 1 := by + have h0 := (hp (g.1,0)).symm.trans (hl 0) + have h1 := (hp (g.1,1)).symm.trans (hl 1) + have h2 := (hp (g.1,2)).symm.trans (hl 2) + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> cases b <;> + simp [advance,outgoingSlot,leftFace,rightFace,reverseGerm,neighbor] at * <;> omega + +theorem wordContour_sides (p : FaceIndex →₀ ℤ) (q : EdgeIndex →₀ ℤ) + (hp : RepresentsFlow p q) (g : Germ) (w : List Bool) (hw : WordContour q g w) : + p (rightFace (terminalGerm g w)) = p (rightFace g) ∧ + p (leftFace (terminalGerm g w)) = p (leftFace g) := by + induction w generalizing g with + | nil => exact ⟨rfl,rfl⟩ + | cons b w ih => + obtain ⟨hr,hl,_⟩ := localContour_sides p q hp g b hw.1 + obtain ⟨hr',hl'⟩ := ih (advance g b) hw.2 + exact ⟨hr'.trans hr,hl'.trans hl⟩ + + + +@[simp] theorem rightFace_reverse (g : Germ) : + rightFace (reverseGerm g) = leftFace g := by simp [rightFace] + +@[simp] theorem reverseGerm_advance (g : Germ) (b : Bool) : + reverseGerm (advance g b) = (g.1,outgoingSlot g b) := by + simp [reverseGerm,advance] + +def canonicalDart (e : EdgeIndex) : Germ := (upEnd e,e.2) + +theorem canonicalDart_edgeOf (g : Germ) : + canonicalDart (edgeOf g) = g ∨ canonicalDart (edgeOf g) = reverseGerm g := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> + simp [canonicalDart,edgeOf,upEnd,reverseGerm,neighbor] + +def SideValues (p : FaceIndex →₀ ℤ) (L R : ℤ) (g : Germ) : Prop := + (p (leftFace g) = L ∨ p (leftFace g) = R) ∧ + (p (rightFace g) = L ∨ p (rightFace g) = R) + +theorem SideValues.reverse {p : FaceIndex →₀ ℤ} {L R : ℤ} {g : Germ} + (h : SideValues p L R g) : SideValues p L R (reverseGerm g) := by + exact ⟨h.2,by simpa only [rightFace_reverse] using h.1⟩ + +theorem SideValues.canonical {p : FaceIndex →₀ ℤ} {L R : ℤ} {g : Germ} + (h : SideValues p L R g) : SideValues p L R (canonicalDart (edgeOf g)) := by + rcases canonicalDart_edgeOf g with he | he + · exact he ▸ h + · exact he ▸ h.reverse + +theorem wordFlow_edge_sides (p : FaceIndex →₀ ℤ) (q : EdgeIndex →₀ ℤ) + (hp : RepresentsFlow p q) (g : Germ) (w : List Bool) (hw : WordContour q g w) + (e : EdgeIndex) (he : wordFlow g w e ≠ 0) : + SideValues p (p (rightFace g)) (p (leftFace g)) (canonicalDart e) := by + classical + induction w generalizing g with + | nil => simp [wordFlow] at he + | cons b w ih => + obtain ⟨hr,hl,_⟩ := localContour_sides p q hp g b hw.1 + by_cases hz : dartFlow (g.1,outgoingSlot g b) e = 0 + · have ht : wordFlow (advance g b) w e ≠ 0 := by + simpa only [wordFlow,Finsupp.add_apply,hz,zero_add] using he + have hs := ih (advance g b) hw.2 ht + rw [hr,hl] at hs + exact hs + · have heq : edgeOf (g.1,outgoingSlot g b) = e := by + by_contra h + exact hz (by simp [dartFlow,h]) + have hs : SideValues p (p (rightFace g)) (p (leftFace g)) (advance g b) := + ⟨Or.inr hl,Or.inl hr⟩ + have hs' := hs.reverse.canonical + simpa only [reverseGerm_advance,heq] using hs' + +theorem RepresentsFlow.horizontal {p : FaceIndex →₀ ℤ} {q : EdgeIndex →₀ ℤ} + (hp : RepresentsFlow p q) (i j : ℤ) : + q ((i,j),0) = p (i,j) - p (i-1,j) := by + simpa [orientedFlow_up,leftFace,rightFace,reverseGerm,neighbor] using hp (.up i j,0) + + + +theorem finite_potential_has_zero_side (p : FaceIndex →₀ ℤ) (hp : p ≠ 0) : + ∃ i j : ℤ, p (i,j) ≠ 0 ∧ p (i-1,j) = 0 := by + classical + let S : Finset ℤ := p.support.image Prod.fst + have hS : S.Nonempty := (Finsupp.support_nonempty_iff.mpr hp).image Prod.fst + obtain ⟨a,ha,hmin⟩ := Finset.mem_image.mp (Finset.min'_mem S hS) + refine ⟨a.1,a.2,Finsupp.mem_support_iff.mp ha,?_⟩ + by_contra hne + have hm : a.1 - 1 ∈ S := Finset.mem_image.mpr + ⟨(a.1-1,a.2),Finsupp.mem_support_iff.mpr hne,rfl⟩ + have h := Finset.min'_le S (a.1-1) hm + omega + +theorem finite_potential_two_values (p : FaceIndex →₀ ℤ) (L R : ℤ) (hp : p ≠ 0) + (hgrad : ∀ i j : ℤ, p (i,j) - p (i-1,j) ≠ 0 → + (p (i,j) = L ∨ p (i,j) = R) ∧ (p (i-1,j) = L ∨ p (i-1,j) = R)) : + (L = 0 ∨ R = 0) ∧ ∀ a : FaceIndex, p a = L ∨ p a = R := by + obtain ⟨i,j,hne,hzero⟩ := finite_potential_has_zero_side p hp + have hz : L = 0 ∨ R = 0 := by + have h := (hgrad i j (by simpa [hzero] using hne)).2 + rw [hzero] at h + exact h.imp Eq.symm Eq.symm + refine ⟨hz,?_⟩ + rintro ⟨i,j⟩ + let m : ℤ := -(faceRadius p : ℤ) - 1 + have hleft (k : ℤ) (hk : k ≤ m) : p (k,j) = 0 := by + by_contra hne + have hb := (mem_support_in_box p (k,j) (Finsupp.mem_support_iff.mpr hne)).1 + dsimp [m] at hk + omega + have hbase : p (m,j) = L ∨ p (m,j) = R := by + rw [hleft m le_rfl] + exact hz.imp Eq.symm Eq.symm + by_cases him : i ≤ m + · rw [hleft i him] + exact hz.imp Eq.symm Eq.symm + · have hmi : m ≤ i := by omega + apply Int.leInduction (motive := fun k _ => p (k,j) = L ∨ p (k,j) = R) hbase ?_ i hmi + intro k _ hk + by_cases hg : p (k+1,j) - p (k,j) = 0 + · have heq : p (k+1,j) = p (k,j) := by omega + exact heq ▸ hk + · simpa only [add_sub_cancel_right] using (hgrad (k+1) j (by simpa using hg)).1 + +theorem simple_closed_word_indicator (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) : + ∃ (p : FaceIndex →₀ ℤ) (ε : ℤ), RepresentsFlow p (wordFlow g w) ∧ p ≠ 0 ∧ + (ε = 1 ∨ ε = -1) ∧ ∀ a : FaceIndex, p a = 0 ∨ p a = ε := by + obtain ⟨p,hp⟩ := closed_word_has_potential g w hc + have hw := simple_closed_word_contour g w hN hc + obtain ⟨b,u,rfl⟩ := List.exists_cons_of_ne_nil hne + have hs := localContour_sides p (wordFlow g (b :: u)) hp g b hw.1 + let L := p (rightFace g) + let R := p (leftFace g) + have hLR : L - R = 1 := hs.2.2 + have hpne : p ≠ 0 := by + intro hz + simp only [L,R,hz,Finsupp.zero_apply,sub_zero] at hLR + omega + have ht : (L = 0 ∨ R = 0) ∧ ∀ a : FaceIndex, p a = L ∨ p a = R := by + apply finite_potential_two_values p L R hpne + intro i j hij + have hq : wordFlow g (b :: u) ((i,j),0) ≠ 0 := by + simpa only [hp.horizontal i j] using hij + have h := wordFlow_edge_sides p _ hp g (b :: u) hw ((i,j),0) hq + simpa [SideValues,canonicalDart,upEnd,leftFace,rightFace,reverseGerm,neighbor,L,R] using h + rcases ht.1 with hL | hR + · have hRm : R = -1 := by omega + refine ⟨p,-1,hp,hpne,Or.inr rfl,?_⟩ + intro a + simpa only [hL,hRm] using ht.2 a + · have hLp : L = 1 := by omega + refine ⟨p,1,hp,hpne,Or.inl rfl,?_⟩ + intro a + simpa only [hLp,hR,or_comm] using ht.2 a + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/ConvexCuts.lean b/lean/OAI/Combinatorics/HoneycombCorridor/ConvexCuts.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4f5983752961a8463afd4fd19a00ac4fea88e8f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/ConvexCuts.lean @@ -0,0 +1,158 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.BoundaryFlux + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def upperCut (D : Finset Vertex) (k : Fin 3) (A : ℤ) : Finset Vertex := + D.filter fun v => boxIndex v k < A + +@[simp] theorem mem_upperCut (D : Finset Vertex) (k : Fin 3) (A : ℤ) (v : Vertex) : + v ∈ upperCut D k A ↔ v ∈ D ∧ boxIndex v k < A := by + simp [upperCut] + +theorem upperCut_subset (D : Finset Vertex) (k : Fin 3) (A : ℤ) : upperCut D k A ⊆ D := + Finset.filter_subset _ _ + +theorem admissiblyConvex_of_box (D : Finset Vertex) (lo hi : Fin 3 → ℤ) + (h : ∀ v, v ∈ D ↔ BoxMem lo hi v) : AdmissiblyConvex D := by + refine ⟨lo,hi,fun v => ?_⟩ + rw [h] + apply forall_congr' + intro k + obtain ⟨a,ha,ha',he⟩ := tilingCoordinate_index v k + rw [he] + exact (integer_bounds_fraction _ _ _ _ ha ha').symm + +theorem upperCut_convex (D : Finset Vertex) (hD : AdmissiblyConvex D) + (k : Fin 3) (A : ℤ) : AdmissiblyConvex (upperCut D k A) := by + obtain ⟨lo,hi,hbox⟩ := admissiblyConvex_box D hD + apply admissiblyConvex_of_box _ lo (fun l => if l = k then min (hi l) A else hi l) + intro v + simp only [mem_upperCut,hbox,BoxMem] + constructor + · rintro ⟨hv,hA⟩ l + by_cases hl : l = k + · subst l; simpa only [ite_true,lt_min_iff] using ⟨(hv k).1,(hv k).2,hA⟩ + · simpa only [hl,ite_false] using hv l + · intro hv + constructor + · intro l + by_cases hl : l = k + · subst l + have hh := hv k + simp only [ite_true,lt_min_iff] at hh + exact ⟨hh.1,hh.2.1⟩ + · simpa only [hl,ite_false] using hv l + · have hh := hv k + simp only [ite_true,lt_min_iff] at hh + exact hh.2.2 + +theorem sourceExits_restrict_iff (D E : Finset Vertex) (hED : E ⊆ D) + (g : Germ) (w : List Bool) (hw : w ∈ sourceExits D g) : + w ∈ sourceExits E g ↔ ∀ v ∈ traced g w, v ∈ E := by + obtain ⟨hs,ht⟩ := (mem_sourceExits D g w).mp hw + constructor + · intro he + exact (stopped_traced E g w ((mem_sourceExits E g w).mp he).1).2 + · intro he + have hn := (stopped_traced D g w hs).1 + have hout : (terminalGerm g w).1 ∉ E := fun hm => ht (hED hm) + exact (mem_sourceExits E g w).mpr ⟨stopped_of_trace E g w hn he hout,hout⟩ + +theorem new_exit_terminal_inside (D E : Finset Vertex) (hED : E ⊆ D) + (g : Germ) (w : List Bool) (hw : w ∈ sourceExits E g \ sourceExits D g) : + (terminalGerm g w).1 ∈ D := by + classical + obtain ⟨he,hd⟩ := Finset.mem_sdiff.mp hw + obtain ⟨hs,ht⟩ := (mem_sourceExits E g w).mp he + obtain ⟨hn,hm⟩ := stopped_traced E g w hs + by_contra hout + apply hd + exact (mem_sourceExits D g w).mpr + ⟨stopped_of_trace D g w hn (fun v hv => hED (hm v hv)) hout,hout⟩ + +theorem flux_subtraction (D E : Finset Vertex) (g : Germ) + (hD : Filled D) (hE : Filled E) + (hgD : (reverseGerm g).1 ∉ D) (hgE : (reverseGerm g).1 ∉ E) : + (∑ w ∈ sourceExits D g \ sourceExits E g, wordWeight w) = + ∑ w ∈ sourceExits E g \ sourceExits D g, wordWeight w := by + apply sub_eq_zero.mp + rw [Finset.sum_sdiff_sub_sum_sdiff,boundary_source_flux D g hD hgD, + boundary_source_flux E g hE hgE,sub_self] + +theorem mem_lost_upperCut (D : Finset Vertex) (g : Germ) (k : Fin 3) (A : ℤ) + (w : List Bool) : w ∈ sourceExits D g \ sourceExits (upperCut D k A) g ↔ + w ∈ sourceExits D g ∧ ∃ v ∈ traced g w, A ≤ boxIndex v k := by + classical + simp only [Finset.mem_sdiff] + by_cases hw : w ∈ sourceExits D g + · simp only [hw,true_and,sourceExits_restrict_iff D _ (upperCut_subset D k A) g w hw] + have hm := (stopped_traced D g w ((mem_sourceExits D g w).mp hw).1).2 + simp only [mem_upperCut,not_forall,not_and,not_lt] + constructor + · rintro ⟨v,hv,hnot⟩ + exact ⟨v,hv,hnot (hm v hv)⟩ + · rintro ⟨v,hv,hA⟩ + exact ⟨v,hv,fun _ => hA⟩ + · simp [hw] + +theorem bottomSource_outside_of_strip (h : ℕ) (D : Finset Vertex) + (hstrip : ∀ v ∈ D, InStrip h v) : (reverseGerm bottomSource).1 ∉ D := by + intro hv + have hh := (hstrip _ hv).1 + norm_num [bottomSource,reverseGerm,neighbor,boxIndex] at hh + +theorem bottomSource_mem_upperCut (D : Finset Vertex) (hg : bottomSource.1 ∈ D) + (k : Fin 3) (A : ℤ) (hA : 0 < A) : bottomSource.1 ∈ upperCut D k A := by + apply (mem_upperCut _ _ _ _).mpr + refine ⟨hg,?_⟩ + fin_cases k <;> simpa [bottomSource,boxIndex] using hA + +theorem new_upperCut_direction (D : Finset Vertex) (k : Fin 3) (A : ℤ) + (hg : bottomSource.1 ∈ upperCut D k A) (w : List Bool) + (hw : w ∈ sourceExits (upperCut D k A) bottomSource \ sourceExits D bottomSource) : + boxIndex (reverseGerm (terminalGerm bottomSource w)).1 k < A ∧ + A ≤ boxIndex (terminalGerm bottomSource w).1 k := by + classical + have he := (mem_sourceExits _ _ _).mp (Finset.mem_sdiff.mp hw).1 + have hn : w ≠ [] := by + intro h + exact he.2 (by simpa [h,terminalGerm] using hg) + have hpred := (stopped_traced _ _ _ he.1).2 _ (reverse_first_mem bottomSource w hn) + have hu := new_exit_terminal_inside D _ (upperCut_subset D k A) _ _ hw + exact ⟨((mem_upperCut _ _ _ _).mp hpred).2,by + by_contra hx + exact he.2 ((mem_upperCut _ _ _ _).mpr ⟨hu,by omega⟩)⟩ + +theorem new_upperCut_turn (D : Finset Vertex) (hD : AdmissiblyConvex D) + (hg : bottomSource.1 ∈ D) (hg' : (reverseGerm bottomSource).1 ∉ D) + (A : ℤ) (hA : 0 < A) (k : Fin 3) (w : List Bool) + (hw : w ∈ sourceExits (upperCut D k A) bottomSource \ sourceExits D bottomSource) : + (k = 1 → turnUnits w = -2) ∧ (k = 2 → turnUnits w = -1) := by + have hmem := bottomSource_mem_upperCut D hg k A hA + obtain ⟨hl,hu⟩ := new_upperCut_direction D k A hmem w hw + have ht := convex_source_direction_turn _ (upperCut_convex D hD k A) hmem + (fun hm => hg' (upperCut_subset D k A hm)) w (Finset.mem_sdiff.mp hw).1 + constructor + · intro hk; subst k + apply ht.1 + have hd := right_cut_direction_one (reverseGerm (terminalGerm bottomSource w)).1 + (terminalGerm bottomSource w).2 A hl + (by simpa only [reverseGerm,neighbor_neighbor] using hu) + simpa only [reverseGerm,neighbor_neighbor] using hd + · intro hk; subst k + apply ht.2 + have hd := right_cut_direction_two (reverseGerm (terminalGerm bottomSource w)).1 + (terminalGerm bottomSource w).2 A hl + (by simpa only [reverseGerm,neighbor_neighbor] using hu) + simpa only [reverseGerm,neighbor_neighbor] using hd + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/ConvexDomains.lean b/lean/OAI/Combinatorics/HoneycombCorridor/ConvexDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..18bd287eeb619af40ce5c692bf08ae6e109975da --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/ConvexDomains.lean @@ -0,0 +1,93 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.BoundaryArcs + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def sourceExits (D : Finset Vertex) (g : Germ) : Finset (List Bool) := by + classical + exact (leaves D g).filter fun w => (terminalGerm g w).1 ∉ D + +def ConvexBoundaryFlux : Prop := ∀ (D : Finset Vertex) (g : Germ), + AdmissiblyConvex D → g.1 ∈ D → (reverseGerm g).1 ∉ D → + (∑ w ∈ sourceExits D g, wordWeight w) = 1 ∧ + (∑ w ∈ sourceExits D g, criticalActivity ^ w.length) ≤ + (Real.cos (3 * Real.pi / 8))⁻¹ + + + +def coordinateIndex (v : Vertex) (k : Fin 3) : ℤ := + match v with + | .up i j => if k = 0 then 3*j+1 else if k = 1 then 3*i+1 else 3*(i+j)+2 + | .down i j => if k = 0 then 3*j+2 else if k = 1 then 3*i+2 else 3*(i+j+1)+1 + +theorem coordinateIndex_box_iff (lo hi : Fin 3 → ℤ) (v : Vertex) (k : Fin 3) : + (3*lo k < coordinateIndex v k ∧ coordinateIndex v k < 3*hi k) ↔ + lo k ≤ boxIndex v k ∧ boxIndex v k < hi k := by + cases v <;> fin_cases k <;> simp [coordinateIndex,boxIndex] <;> omega + +theorem coordinateIndex_increase (v : Vertex) (k : Fin 3) : + ∃ l : Fin 3, coordinateIndex v k < coordinateIndex (neighbor v l) k := by + cases v <;> fin_cases k + all_goals first + | (refine ⟨0,?_⟩; simp [coordinateIndex,neighbor] <;> omega) + | (refine ⟨1,?_⟩; simp [coordinateIndex,neighbor] <;> omega) + | (refine ⟨2,?_⟩; simp [coordinateIndex,neighbor]; omega) + +theorem coordinateIndex_decrease (v : Vertex) (k : Fin 3) : + ∃ l : Fin 3, coordinateIndex (neighbor v l) k < coordinateIndex v k := by + cases v <;> fin_cases k + all_goals first + | (refine ⟨0,?_⟩; simp [coordinateIndex,neighbor] <;> omega) + | (refine ⟨1,?_⟩; simp [coordinateIndex,neighbor] <;> omega) + | (refine ⟨2,?_⟩; simp [coordinateIndex,neighbor]; omega) + +theorem Polygon.interior_maximum_principle (P : Polygon) (f : Vertex → ℤ) + (hf : ∀ v, ∃ k : Fin 3, f v < f (neighbor v k)) (M : ℤ) + (hbd : ∀ v ∈ P.vertices, f v < M) : ∀ v ∈ P.interior, f v < M := by + classical + intro v hv + let R := P.interior.image f + have hvR : f v ∈ R := Finset.mem_image.mpr ⟨v,hv,rfl⟩ + have hne : R.Nonempty := ⟨f v,hvR⟩ + let m := R.max' hne + obtain ⟨u,hu,hum⟩ := Finset.mem_image.mp (R.max'_mem hne) + obtain ⟨k,hk⟩ := hf u + have hn : neighbor u k ∉ P.interior := by + intro hn + have hle := R.le_max' _ (Finset.mem_image.mpr ⟨neighbor u k,hn,rfl⟩) + change f (neighbor u k) ≤ m at hle + change f u = m at hum + omega + have hb := P.interior_exit_on_boundary u k hu hn + have hbound := hbd _ hb + have hle := R.le_max' (f v) hvR + change f v ≤ m at hle + change f u = m at hum + omega + +theorem admissiblyConvex_filled (D : Finset Vertex) (hD : AdmissiblyConvex D) : Filled D := by + obtain ⟨lo,hi,hbox⟩ := admissiblyConvex_box D hD + intro P hP v hv + apply (hbox v).mpr + intro k + apply (coordinateIndex_box_iff lo hi v k).mp + have hp : P.vertices ⊆ D := (mem_polygons D P).mp hP + have hbd (u : Vertex) (hu : u ∈ P.vertices) : + 3*lo k < coordinateIndex u k ∧ coordinateIndex u k < 3*hi k := + (coordinateIndex_box_iff lo hi u k).mpr ((hbox u).mp (hp hu) k) + have hh := P.interior_maximum_principle (fun u => coordinateIndex u k) + (fun u => coordinateIndex_increase u k) (3*hi k) (fun u hu => (hbd u hu).2) v hv + have hl := P.interior_maximum_principle (fun u => -coordinateIndex u k) + (fun u => by obtain ⟨l,hl⟩ := coordinateIndex_decrease u k; exact ⟨l,by omega⟩) + (-3*lo k) (fun u hu => by have := (hbd u hu).1; omega) v hv + omega + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Convexity.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Convexity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4dfe99f9538d8f696d4d0d9e0797edd8ec6b018 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Convexity.lean @@ -0,0 +1,212 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Polygons + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def boxIndex : Vertex → Fin 3 → ℤ + | .up i j, k => if k = 0 then j else if k = 1 then i else i+j + | .down i j, k => if k = 0 then j else if k = 1 then i else i+j+1 + +def BoxMem (lo hi : Fin 3 → ℤ) (v : Vertex) : Prop := + ∀ k, lo k ≤ boxIndex v k ∧ boxIndex v k < hi k + +theorem tilingCoordinate_index (v : Vertex) (k : Fin 3) : + ∃ a : ℝ, 0 < a ∧ a < 1 ∧ + tilingCoordinate k (position v) = (boxIndex v k : ℝ) + a := by + have hs : Real.sqrt 3 ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (by norm_num)) + cases v with + | up i j => + fin_cases k + · refine ⟨1/3,by norm_num,by norm_num,?_⟩ + simp [tilingCoordinate,position,boxIndex] + field_simp + · refine ⟨1/3,by norm_num,by norm_num,?_⟩ + simp [tilingCoordinate,position,boxIndex] + field_simp + ring + · refine ⟨2/3,by norm_num,by norm_num,?_⟩ + simp [tilingCoordinate,position,boxIndex] + field_simp + ring + | down i j => + fin_cases k + · refine ⟨2/3,by norm_num,by norm_num,?_⟩ + simp [tilingCoordinate,position,boxIndex] + field_simp + · refine ⟨2/3,by norm_num,by norm_num,?_⟩ + simp [tilingCoordinate,position,boxIndex] + field_simp + ring + · refine ⟨1/3,by norm_num,by norm_num,?_⟩ + simp [tilingCoordinate,position,boxIndex] + field_simp + ring + +theorem integer_bounds_fraction (lo hi n : ℤ) (a : ℝ) (ha : 0 < a) (ha' : a < 1) : + ((lo : ℝ) < (n : ℝ)+a ∧ (n : ℝ)+a < (hi : ℝ)) ↔ lo ≤ n ∧ n < hi := by + constructor + · rintro ⟨hl,hh⟩ + constructor + · by_contra h + have h' : n+1 ≤ lo := by omega + have : (n : ℝ)+1 ≤ (lo : ℝ) := by exact_mod_cast h' + linarith + · by_contra h + have h' : hi ≤ n := by omega + have : (hi : ℝ) ≤ (n : ℝ) := by exact_mod_cast h' + linarith + · rintro ⟨hl,hh⟩ + have hl' : (lo : ℝ) ≤ (n : ℝ) := by exact_mod_cast hl + have hh' : (n : ℝ)+1 ≤ (hi : ℝ) := by exact_mod_cast (show n+1 ≤ hi by omega) + constructor <;> linarith + +theorem admissiblyConvex_box (D : Finset Vertex) (hD : AdmissiblyConvex D) : + ∃ lo hi : Fin 3 → ℤ, ∀ v, v ∈ D ↔ BoxMem lo hi v := by + obtain ⟨lo,hi,h⟩ := hD + refine ⟨lo,hi,fun v => ?_⟩ + rw [h] + apply forall_congr' + intro k + obtain ⟨a,ha,ha',he⟩ := tilingCoordinate_index v k + rw [he] + exact integer_bounds_fraction _ _ _ _ ha ha' + +def starFaces (D : Finset Vertex) : Finset FaceIndex := + D.biUnion fun v => Finset.univ.image fun k : Fin 3 => leftFace (v,k) + +theorem mem_starFaces (D : Finset Vertex) (a : FaceIndex) : + a ∈ starFaces D ↔ ∃ v ∈ faceVertices a, v ∈ D := by + simp only [starFaces,Finset.mem_biUnion,Finset.mem_image,Finset.mem_univ,true_and, + mem_faceVertices] + aesop + +theorem incident_mem_starFaces {D : Finset Vertex} {v : Vertex} (hv : v ∈ D) + (k : Fin 3) : leftFace (v,k) ∈ starFaces D := by + apply (mem_starFaces D _).mpr + exact ⟨v,(mem_faceVertices _ _).mpr ⟨k,rfl⟩,hv⟩ + + + +theorem box_opposite_face (lo hi : Fin 3 → ℤ) (v r : Vertex) (k : Fin 3) + (hv : BoxMem lo hi (neighbor v k)) + (hr : r ∈ faceVertices (leftFace (v,k+1))) + (hr' : BoxMem lo hi r) : BoxMem lo hi v := by + cases v <;> fin_cases k <;> + simp only [leftFace,Fin.reduceAdd,Fin.zero_eta,Fin.isValue,Fin.reduceEq,ite_true, + ite_false,faceVertices,Finset.mem_insert,Finset.mem_singleton] at hr <;> + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [BoxMem,Fin.forall_fin_succ,boxIndex,neighbor] <;> omega + +theorem outside_opposite_face (D : Finset Vertex) (hD : AdmissiblyConvex D) + (v : Vertex) (k : Fin 3) (hv : v ∉ D) (hn : neighbor v k ∈ D) : + leftFace (v,k+1) ∉ starFaces D := by + obtain ⟨lo,hi,hbox⟩ := admissiblyConvex_box D hD + intro hf + obtain ⟨r,hr,hr'⟩ := (mem_starFaces D _).mp hf + exact hv ((hbox v).mpr (box_opposite_face lo hi v r k ((hbox _).mp hn) hr + ((hbox _).mp hr'))) + +theorem box_two_faces_up0 (lo hi : Fin 3 → ℤ) (i j : ℤ) (r s : Vertex) + (hr : r ∈ faceVertices (rightFace (.up i j,0))) + (hs : s ∈ faceVertices (leftFace + (neighbor (.up i j) ((0 : Fin 3)+1),(0 : Fin 3)+2))) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + BoxMem lo hi (.up i j) ∨ BoxMem lo hi (neighbor (.up i j) ((0 : Fin 3)+1)) := by + simp only [rightFace,reverseGerm,neighbor,leftFace,Fin.reduceAdd, + Fin.isValue,Fin.reduceEq,ite_true,ite_false,faceVertices,Finset.mem_insert, + Finset.mem_singleton] at hr hs + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [BoxMem,Fin.forall_fin_succ,boxIndex,neighbor] <;> omega + +theorem box_two_faces_up1 (lo hi : Fin 3 → ℤ) (i j : ℤ) (r s : Vertex) + (hr : r ∈ faceVertices (rightFace (.up i j,1))) + (hs : s ∈ faceVertices (leftFace + (neighbor (.up i j) ((1 : Fin 3)+1),(1 : Fin 3)+2))) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + BoxMem lo hi (.up i j) ∨ BoxMem lo hi (neighbor (.up i j) ((1 : Fin 3)+1)) := by + simp only [rightFace,reverseGerm,neighbor,leftFace,Fin.reduceAdd, + Fin.isValue,Fin.reduceEq,ite_true,ite_false,faceVertices,Finset.mem_insert, + Finset.mem_singleton] at hr hs + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [BoxMem,Fin.forall_fin_succ,boxIndex,neighbor] <;> omega + +theorem box_two_faces_up2 (lo hi : Fin 3 → ℤ) (i j : ℤ) (r s : Vertex) + (hr : r ∈ faceVertices (rightFace (.up i j,2))) + (hs : s ∈ faceVertices (leftFace + (neighbor (.up i j) ((2 : Fin 3)+1),(2 : Fin 3)+2))) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + BoxMem lo hi (.up i j) ∨ BoxMem lo hi (neighbor (.up i j) ((2 : Fin 3)+1)) := by + simp only [rightFace,reverseGerm,neighbor,leftFace,Fin.reduceAdd, + Fin.isValue,Fin.reduceEq,ite_true,ite_false,faceVertices,Finset.mem_insert, + Finset.mem_singleton] at hr hs + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [BoxMem,Fin.forall_fin_succ,boxIndex,neighbor] <;> omega + +theorem box_two_faces_down0 (lo hi : Fin 3 → ℤ) (i j : ℤ) (r s : Vertex) + (hr : r ∈ faceVertices (rightFace (.down i j,0))) + (hs : s ∈ faceVertices (leftFace + (neighbor (.down i j) ((0 : Fin 3)+1),(0 : Fin 3)+2))) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + BoxMem lo hi (.down i j) ∨ BoxMem lo hi (neighbor (.down i j) ((0 : Fin 3)+1)) := by + simp only [rightFace,reverseGerm,neighbor,leftFace,Fin.reduceAdd, + Fin.isValue,Fin.reduceEq,ite_true,ite_false,faceVertices,Finset.mem_insert, + Finset.mem_singleton] at hr hs + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [BoxMem,Fin.forall_fin_succ,boxIndex,neighbor] <;> omega + +theorem box_two_faces_down1 (lo hi : Fin 3 → ℤ) (i j : ℤ) (r s : Vertex) + (hr : r ∈ faceVertices (rightFace (.down i j,1))) + (hs : s ∈ faceVertices (leftFace + (neighbor (.down i j) ((1 : Fin 3)+1),(1 : Fin 3)+2))) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + BoxMem lo hi (.down i j) ∨ BoxMem lo hi (neighbor (.down i j) ((1 : Fin 3)+1)) := by + simp only [rightFace,reverseGerm,neighbor,leftFace,Fin.reduceAdd, + Fin.isValue,Fin.reduceEq,ite_true,ite_false,faceVertices,Finset.mem_insert, + Finset.mem_singleton] at hr hs + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [BoxMem,Fin.forall_fin_succ,boxIndex,neighbor] <;> omega + +theorem box_two_faces_down2 (lo hi : Fin 3 → ℤ) (i j : ℤ) (r s : Vertex) + (hr : r ∈ faceVertices (rightFace (.down i j,2))) + (hs : s ∈ faceVertices (leftFace + (neighbor (.down i j) ((2 : Fin 3)+1),(2 : Fin 3)+2))) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + BoxMem lo hi (.down i j) ∨ BoxMem lo hi (neighbor (.down i j) ((2 : Fin 3)+1)) := by + simp only [rightFace,reverseGerm,neighbor,leftFace,Fin.reduceAdd, + Fin.isValue,Fin.reduceEq,ite_true,ite_false,faceVertices,Finset.mem_insert, + Finset.mem_singleton] at hr hs + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + rcases hs with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp_all [BoxMem,Fin.forall_fin_succ,boxIndex,neighbor] <;> omega + +theorem box_two_faces (lo hi : Fin 3 → ℤ) (v r s : Vertex) (k : Fin 3) + (hr : r ∈ faceVertices (rightFace (v,k))) + (hs : s ∈ faceVertices (leftFace (neighbor v (k+1),k+2))) + (hr' : BoxMem lo hi r) (hs' : BoxMem lo hi s) : + BoxMem lo hi v ∨ BoxMem lo hi (neighbor v (k+1)) := by + cases v with + | up i j => + fin_cases k + · exact box_two_faces_up0 lo hi i j r s hr hs hr' hs' + · exact box_two_faces_up1 lo hi i j r s hr hs hr' hs' + · exact box_two_faces_up2 lo hi i j r s hr hs hr' hs' + | down i j => + fin_cases k + · exact box_two_faces_down0 lo hi i j r s hr hs hr' hs' + · exact box_two_faces_down1 lo hi i j r s hr hs hr' hs' + · exact box_two_faces_down2 lo hi i j r s hr hs hr' hs' + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CorridorTransfer.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CorridorTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..57050731791788951114a4f3294908ca7e58a1a4 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CorridorTransfer.lean @@ -0,0 +1,328 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.BridgeFiniteness + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +theorem bridgeMean_eq_tsum (h : ℕ) : + bridgeMean h = ∑' p : BridgePath h, firstLengthWeight p / bridgeMass h := by + simp only [bridgeMean, bridgeLengthMass, tsum_div_const] + +theorem confinedMean_eq_tsum (h : ℕ) : + confinedMean h = ∑' p : ConfinedBridgePath h, + firstLengthWeight p.val / confinedMass h := by + simp only [confinedMean, confinedLengthMass, tsum_div_const] + +theorem Subpower.div {f g : ℕ → ℝ} {a b : ℝ} + (hf : Subpower f a) (hg : Subpower g b) : + Subpower (fun h => f h / g h) (a - b) := by + refine ⟨?_, ?_⟩ + · filter_upwards [hf.1, hg.1] with h hfh hgh using div_pos hfh hgh + · apply (hf.2.sub hg.2).congr' + filter_upwards [hf.1, hg.1] with h hfh hgh + rw [Real.log_div (ne_of_gt hfh) (ne_of_gt hgh), sub_div] + +theorem bridgeMean_subpower_of_masses + (hm : Subpower bridgeMass (-(1 : ℝ) / 4)) + (hl : Subpower bridgeLengthMass ((13 : ℝ) / 12)) : + Subpower bridgeMean ((4 : ℝ) / 3) := by + have h := hl.div hm + norm_num at h + exact h + +theorem confinedMean_subpower_of_masses + (hm : Subpower confinedMass (-(1 : ℝ) / 4)) + (hl : Subpower confinedLengthMass ((13 : ℝ) / 12)) : + Subpower confinedMean ((4 : ℝ) / 3) := by + have h := hl.div hm + norm_num at h + exact h + +noncomputable def BridgeReachesDistance {h : ℕ} (t : ℝ) (p : BridgePath h) : Prop := + ∃ v ∈ p.vertices, t ≤ |(position v).1| + +noncomputable def bridgeTailMass (h : ℕ) (t : ℝ) : ℝ := by + classical + exact ∑' p : BridgePath h, if BridgeReachesDistance t p then weight p else 0 + +noncomputable def bridgeTailLengthMass (h : ℕ) (t : ℝ) : ℝ := by + classical + exact ∑' p : BridgePath h, + if BridgeReachesDistance t p then firstLengthWeight p else 0 + +@[simp] theorem reachesDistance_bridgeWord (h : ℕ) (hh : 1 ≤ h) + (t : ℝ) (p : BridgePath h) : + reachesDistance t (bridgeWord h hh p) ↔ BridgeReachesDistance t p := by + simp only [reachesDistance, BridgeReachesDistance, bridgeWord_trace] + +theorem weight_nonneg {h : ℕ} (p : BridgePath h) : 0 ≤ weight p := + pow_nonneg criticalActivity_pos.le _ + +theorem firstLengthWeight_nonneg {h : ℕ} (p : BridgePath h) : + 0 ≤ firstLengthWeight p := + mul_nonneg (Nat.cast_nonneg _) (weight_nonneg p) + +theorem bridgeTailMass_le (h : ℕ) (hh : 1 ≤ h) (t : ℝ) (ht : 0 ≤ t) : + bridgeTailMass h t ≤ tailConstant * Real.exp (-tailRate * t / (h + 1)) := by + classical + apply Real.tsum_le_of_sum_le + · intro p + exact ite_nonneg (weight_nonneg p) le_rfl + · intro S + obtain ⟨M, hM⟩ := bridge_finite_sum_word_bound h hh S + (fun w => if reachesDistance t w then criticalActivity ^ w.length else 0) + (fun w => ite_nonneg (pow_nonneg criticalActivity_pos.le _) le_rfl) + simp only [reachesDistance_bridgeWord, bridgeWord_length] at hM + exact hM.trans (lateralMass_exp h hh _ (vertexWindow_convex h M) + (bottomSource_mem_window h M hh) (vertexWindow_strip h M) t ht) + +theorem bridgeTailLengthMass_le (h : ℕ) (hh : 1 ≤ h) (t : ℝ) (ht : 0 ≤ t) : + bridgeTailLengthMass h t ≤ tailConstant * spatialConstant * ((h : ℝ) + 1)^2 * + Real.exp (-(tailRate / 2) * t / (h + 1)) := by + classical + apply Real.tsum_le_of_sum_le + · intro p + exact ite_nonneg (firstLengthWeight_nonneg p) le_rfl + · intro S + obtain ⟨M, hM⟩ := bridge_finite_sum_word_bound h hh S + (fun w => if reachesDistance t w then + (w.length : ℝ) * criticalActivity ^ w.length else 0) + (fun w => ite_nonneg + (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg criticalActivity_pos.le _)) le_rfl) + simp only [reachesDistance_bridgeWord, bridgeWord_length] at hM + exact hM.trans (lateralLengthMass_exp h hh _ (vertexWindow_convex h M) + (bottomSource_mem_window h M hh) (vertexWindow_strip h M) t ht) + +theorem not_InLogCorridor_reaches {h : ℕ} (p : BridgePath h) + (hp : ¬InLogCorridor p) : + BridgeReachesDistance ((h : ℝ) * (Real.log (h : ℝ))^2) p := by + classical + by_contra hn + apply hp + intro v hv + exact (lt_of_not_ge (fun hn' => hn ⟨v, hv, hn'⟩)).le + +open scoped Classical + +theorem logCorridor_loss_le {h : ℕ} (f : BridgePath h → ℝ) + (hf : Summable f) (hf0 : ∀ p, 0 ≤ f p) : + 0 ≤ (∑' p, f p) - (∑' p : ConfinedBridgePath h, f p.val) ∧ + (∑' p, f p) - (∑' p : ConfinedBridgePath h, f p.val) ≤ + ∑' p, if BridgeReachesDistance ((h : ℝ) * (Real.log (h : ℝ))^2) p + then f p else 0 := by + classical + let s : Set (BridgePath h) := {p | InLogCorridor p} + let t : Set (BridgePath h) := + {p | BridgeReachesDistance ((h : ℝ) * (Real.log (h : ℝ))^2) p} + change 0 ≤ (∑' p, f p) - (∑' p : s, f p.val) ∧ + (∑' p, f p) - (∑' p : s, f p.val) ≤ ∑' p, t.indicator f p + rw [tsum_subtype, ← hf.tsum_sub (hf.indicator s)] + have hnonneg : ∀ p, 0 ≤ f p - s.indicator f p := by + intro p + by_cases hp : InLogCorridor p + · simp [s, hp] + · simpa [s, hp] using hf0 p + refine ⟨tsum_nonneg hnonneg, ?_⟩ + apply Summable.tsum_le_tsum _ (hf.sub (hf.indicator s)) (hf.indicator t) + intro p + by_cases hp : InLogCorridor p + · simp only [Set.indicator_apply, Set.mem_ofPred_eq, s, hp, ite_true, sub_self] + exact ite_nonneg (hf0 p) le_rfl + · have ht := not_InLogCorridor_reaches p hp + simp [s, t, hp, ht] + +theorem logCorridor_mass_error (h : ℕ) (hh : 1 ≤ h) : + 0 ≤ bridgeMass h - confinedMass h ∧ + bridgeMass h - confinedMass h ≤ tailConstant * + Real.exp (-tailRate * ((h : ℝ) * (Real.log (h : ℝ))^2) / (h + 1)) := by + have he := logCorridor_loss_le (weight (h := h)) + (bridge_weight_summable h hh) weight_nonneg + exact ⟨he.1, he.2.trans (bridgeTailMass_le h hh _ (by positivity))⟩ + +theorem logCorridor_length_error (h : ℕ) (hh : 1 ≤ h) : + 0 ≤ bridgeLengthMass h - confinedLengthMass h ∧ + bridgeLengthMass h - confinedLengthMass h ≤ + tailConstant * spatialConstant * ((h : ℝ) + 1)^2 * + Real.exp (-(tailRate / 2) * ((h : ℝ) * (Real.log (h : ℝ))^2) / (h + 1)) := by + have he := logCorridor_loss_le (firstLengthWeight (h := h)) + (bridge_length_summable h hh) firstLengthWeight_nonneg + exact ⟨he.1, he.2.trans (bridgeTailLengthMass_le h hh _ (by positivity))⟩ + +theorem tendsto_rpow_mul_logGaussian {c : ℝ} (hc : 0 < c) (a : ℝ) : + Filter.Tendsto (fun h : ℕ => (h : ℝ)^a * + Real.exp (-c * (Real.log (h : ℝ))^2)) Filter.atTop (nhds 0) := by + have hlog : Filter.Tendsto (fun h : ℕ => Real.log (h : ℝ)) + Filter.atTop Filter.atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hneg := Filter.tendsto_neg_atTop_atBot.comp (hlog.const_mul_atTop hc) + have hdiff : Filter.Tendsto (fun h : ℕ => a - c * Real.log (h : ℝ)) + Filter.atTop Filter.atBot := by + simpa only [sub_eq_add_neg, Function.comp_apply] using + (Filter.Tendsto.add_atBot (tendsto_const_nhds (x := a)) hneg) + have hprod := hlog.atTop_mul_atBot₀ hdiff + apply (Real.tendsto_exp_atBot.comp hprod).congr' + filter_upwards [Filter.eventually_ge_atTop 1] with h hh + have hp : 0 < (h : ℝ) := by exact_mod_cast (show 0 < h by omega) + change Real.exp (Real.log (h : ℝ) * (a - c * Real.log (h : ℝ))) = _ + rw [Real.rpow_def_of_pos hp, ← Real.exp_add] + apply congrArg Real.exp + ring + +theorem tendsto_rpow_mul_logTailExp {c : ℝ} (hc : 0 < c) (a : ℝ) : + Filter.Tendsto (fun h : ℕ => (h : ℝ)^a * + Real.exp (-c * ((h : ℝ) * (Real.log (h : ℝ))^2) / (h + 1))) + Filter.atTop (nhds 0) := by + apply squeeze_zero' _ _ (tendsto_rpow_mul_logGaussian (half_pos hc) a) + · exact Filter.Eventually.of_forall (fun h => + mul_nonneg (Real.rpow_nonneg (Nat.cast_nonneg h) a) (Real.exp_pos _).le) + · filter_upwards [Filter.eventually_ge_atTop 1] with h hh + have hh' : (1 : ℝ) ≤ h := by exact_mod_cast hh + have hH : 0 < (h : ℝ) + 1 := by positivity + have hfrac : (1 / 2 : ℝ) ≤ (h : ℝ) / (h + 1) := by + apply (le_div_iff₀ hH).mpr + linarith + apply mul_le_mul_of_nonneg_left _ (Real.rpow_nonneg (Nat.cast_nonneg h) a) + apply Real.exp_le_exp.mpr + have hi := mul_le_mul_of_nonpos_left hfrac + (neg_nonpos.mpr (mul_nonneg hc.le (sq_nonneg (Real.log (h : ℝ))))) + convert hi using 1 <;> first | rfl | ring + +theorem logCorridor_mass_error_superpolynomial (a : ℝ) : + Filter.Tendsto (fun h : ℕ => + (bridgeMass h - confinedMass h) * (h : ℝ)^a) + Filter.atTop (nhds 0) := by + have ht := (tendsto_rpow_mul_logTailExp tailRate_pos a).const_mul tailConstant + rw [mul_zero] at ht + apply squeeze_zero' _ _ ht + · filter_upwards [Filter.eventually_ge_atTop 1] with h hh + exact mul_nonneg (logCorridor_mass_error h hh).1 + (Real.rpow_nonneg (Nat.cast_nonneg h) a) + · filter_upwards [Filter.eventually_ge_atTop 1] with h hh + have he := mul_le_mul_of_nonneg_right (logCorridor_mass_error h hh).2 + (Real.rpow_nonneg (Nat.cast_nonneg h) a) + simpa only [mul_comm, mul_left_comm, mul_assoc] using he + +theorem logCorridor_length_error_superpolynomial (a : ℝ) : + Filter.Tendsto (fun h : ℕ => + (bridgeLengthMass h - confinedLengthMass h) * (h : ℝ)^a) + Filter.atTop (nhds 0) := by + have ht := (tendsto_rpow_mul_logTailExp (half_pos tailRate_pos) (a + 2)).const_mul + (4 * tailConstant * spatialConstant) + rw [mul_zero] at ht + apply squeeze_zero' _ _ ht + · filter_upwards [Filter.eventually_ge_atTop 1] with h hh + exact mul_nonneg (logCorridor_length_error h hh).1 + (Real.rpow_nonneg (Nat.cast_nonneg h) a) + · filter_upwards [Filter.eventually_ge_atTop 1] with h hh + have hh' : (1 : ℝ) ≤ h := by exact_mod_cast hh + have hp : 0 < (h : ℝ) := by linarith + have hsq : ((h : ℝ) + 1)^2 ≤ 4 * (h : ℝ)^2 := by nlinarith + have he := mul_le_mul_of_nonneg_right (logCorridor_length_error h hh).2 + (Real.rpow_nonneg (Nat.cast_nonneg h) a) + apply he.trans + rw [Real.rpow_add hp, Real.rpow_two] + calc + _ ≤ tailConstant * spatialConstant * (4 * (h : ℝ)^2) * + Real.exp (-(tailRate / 2) * ((h : ℝ) * (Real.log (h : ℝ))^2) / (h + 1)) * + (h : ℝ)^a := by + gcongr + exact mul_nonneg tailConstant_pos.le spatialConstant_pos.le + _ = _ := by ring + +theorem Subpower.eventually_rpow_le {f : ℕ → ℝ} {a b : ℝ} + (hf : Subpower f a) (hb : b < a) : + ∀ᶠ h : ℕ in Filter.atTop, (h : ℝ)^b ≤ f h := by + have he := hf.2.eventually (lt_mem_nhds hb) + filter_upwards [hf.1, he, Filter.eventually_ge_atTop 2] with h hp he hh + have hh' : (1 : ℝ) < h := by exact_mod_cast (show 1 < h by omega) + have hpos : 0 < (h : ℝ) := lt_trans zero_lt_one hh' + apply (Real.log_le_log_iff (Real.rpow_pos_of_pos hpos b) hp).mp + rw [Real.log_rpow hpos] + exact ((le_div_iff₀ (Real.log_pos hh')).mp he.le) + +theorem Subpower.error_div_tendsto_zero {f e : ℕ → ℝ} {a : ℝ} + (hf : Subpower f a) (he0 : ∀ᶠ h in Filter.atTop, 0 ≤ e h) + (he : ∀ b : ℝ, Filter.Tendsto (fun h : ℕ => e h * (h : ℝ)^b) + Filter.atTop (nhds 0)) : + Filter.Tendsto (fun h => e h / f h) Filter.atTop (nhds 0) := by + apply squeeze_zero' _ _ (he (1 - a)) + · filter_upwards [hf.1, he0] with h hf he using div_nonneg he hf.le + · filter_upwards [hf.eventually_rpow_le (show a - 1 < a by linarith), + he0, Filter.eventually_ge_atTop 1] with h hb he0 hh + have hp : 0 < (h : ℝ) := by exact_mod_cast (show 0 < h by omega) + calc + e h / f h ≤ e h / (h : ℝ)^(a - 1) := + div_le_div_of_nonneg_left he0 (Real.rpow_pos_of_pos hp _) hb + _ = e h * (h : ℝ)^(1 - a) := by + rw [div_eq_mul_inv, ← Real.rpow_neg hp.le] + congr 2 + ring + +theorem Subpower.of_ratio {f g : ℕ → ℝ} {a : ℝ} (hg : Subpower g a) + (hr : Filter.Tendsto (fun h => f h / g h) Filter.atTop (nhds 1)) : + Subpower f a := by + have hf : ∀ᶠ h in Filter.atTop, 0 < f h := by + filter_upwards [hg.1, hr.eventually (lt_mem_nhds zero_lt_one)] with h hg hr + exact (div_pos_iff_of_pos_right hg).mp hr + refine ⟨hf, ?_⟩ + have hlog : Filter.Tendsto (fun h : ℕ => Real.log (h : ℝ)) + Filter.atTop Filter.atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hratio : Filter.Tendsto (fun h => Real.log (f h / g h) / Real.log (h : ℝ)) + Filter.atTop (nhds 0) := (hr.log one_ne_zero).div_atTop hlog + have hsum := hg.2.add hratio + rw [add_zero] at hsum + apply hsum.congr' + filter_upwards [hf, hg.1] with h hf hg + rw [Real.log_div (ne_of_gt hf) (ne_of_gt hg)] + ring + +theorem subpower_iff_of_superpolynomial_error {f g : ℕ → ℝ} {a : ℝ} + (he0 : ∀ᶠ h in Filter.atTop, 0 ≤ f h - g h) + (he : ∀ b : ℝ, Filter.Tendsto (fun h : ℕ => (f h - g h) * (h : ℝ)^b) + Filter.atTop (nhds 0)) : + Subpower f a ↔ Subpower g a := by + constructor + · intro hf + have hd := hf.error_div_tendsto_zero he0 he + apply hf.of_ratio + have ht := (tendsto_const_nhds (x := (1 : ℝ))).sub hd + rw [sub_zero] at ht + apply ht.congr' + filter_upwards [hf.1] with h hh + field_simp + ring + · intro hg + have hd := hg.error_div_tendsto_zero he0 he + apply hg.of_ratio + have ht := (tendsto_const_nhds (x := (1 : ℝ))).add hd + rw [add_zero] at ht + apply ht.congr' + filter_upwards [hg.1] with h hh + field_simp + ring + +theorem confinedMass_subpower_iff (a : ℝ) : + Subpower confinedMass a ↔ Subpower bridgeMass a := by + symm + apply subpower_iff_of_superpolynomial_error + _ logCorridor_mass_error_superpolynomial + filter_upwards [Filter.eventually_ge_atTop 1] with h hh + exact (logCorridor_mass_error h hh).1 + +theorem confinedLengthMass_subpower_iff (a : ℝ) : + Subpower confinedLengthMass a ↔ Subpower bridgeLengthMass a := by + symm + apply subpower_iff_of_superpolynomial_error + _ logCorridor_length_error_superpolynomial + filter_upwards [Filter.eventually_ge_atTop 1] with h hh + exact (logCorridor_length_error h hh).1 + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Currents.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Currents.lean new file mode 100644 index 0000000000000000000000000000000000000000..2326616465ac1968eb713c33f5b60e7b1e9e7b61 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Currents.lean @@ -0,0 +1,151 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Cells +import OAI.Combinatorics.HoneycombCorridor.RationalPotential + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def directedCurrent (q : EdgeIndex → ℚ) (g : Germ) : ℚ := + (dartSign g : ℚ) * q (edgeOf g) + +def ConservedCurrent (q : EdgeIndex → ℚ) : Prop := + ∀ v : Vertex, ∑ k : Fin 3, directedCurrent q (v,k) = 0 + +@[simp] theorem directedCurrent_reverse (q : EdgeIndex → ℚ) (g : Germ) : + directedCurrent q (reverseGerm g) = -directedCurrent q g := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> simp [directedCurrent,dartSign,edgeOf,reverseGerm,neighbor] + +@[simp] theorem directedCurrent_advance (q : EdgeIndex → ℚ) (g : Germ) (b : Bool) : + directedCurrent q (advance g b) = -directedCurrent q (g.1,outgoingSlot g b) := by + have h := directedCurrent_reverse q (advance g b) + rw [reverseGerm_advance] at h + linarith + +theorem orientedFlow_zero_iff (q : EdgeIndex →₀ ℤ) (g : Germ) : + orientedFlow q g = 0 ↔ q (edgeOf g) = 0 := by + rcases g with ⟨v,k⟩ + cases v <;> simp [orientedFlow_up,orientedFlow_down,edgeOf] + +theorem directedCurrent_cast (q : EdgeIndex →₀ ℤ) (g : Germ) : + directedCurrent (fun e => (q e : ℚ)) g = (orientedFlow q g : ℚ) := by + rcases g with ⟨v,k⟩ + cases v <;> simp [directedCurrent,dartSign,orientedFlow_up,orientedFlow_down,edgeOf] + +theorem local_contour_current (p : EdgeIndex →₀ ℤ) (q : EdgeIndex → ℚ) + (hq : ConservedCurrent q) (hs : ∀ e, p e = 0 → q e = 0) + (g : Germ) (b : Bool) (hl : LocalContour p g b) : + directedCurrent q (advance g b) = directedCurrent q g ∧ + ∀ k : Fin 3, directedCurrent q (g.1,k) = + -directedCurrent q g * (orientedFlow p (g.1,k) : ℚ) := by + have hz (k : Fin 3) : + (if k = outgoingSlot g b then (1 : ℤ) else 0) - + (if k = g.2 then 1 else 0) = 0 → directedCurrent q (g.1,k) = 0 := by + intro h + have h0 : orientedFlow p (g.1,k) = 0 := (hl k).trans h + have he := hs (edgeOf (g.1,k)) ((orientedFlow_zero_iff p _).mp h0) + simp [directedCurrent,he] + have hsum := hq g.1 + rw [directedCurrent_advance] + constructor + · rcases g with ⟨v,k⟩ + have hz0 := hz 0 + have hz1 := hz 1 + have hz2 := hz 2 + fin_cases k <;> cases b <;> + simp [outgoingSlot,Fin.sum_univ_succ] at hz0 hz1 hz2 hsum ⊢ <;> linarith + · intro k + rw [hl k] + rcases g with ⟨v,l⟩ + have hz0 := hz 0 + have hz1 := hz 1 + have hz2 := hz 2 + fin_cases l <;> cases b <;> fin_cases k <;> + simp [outgoingSlot,Fin.sum_univ_succ] at hz0 hz1 hz2 hsum ⊢ <;> linarith + +theorem word_contour_current (p : EdgeIndex →₀ ℤ) (q : EdgeIndex → ℚ) + (hq : ConservedCurrent q) (hs : ∀ e, p e = 0 → q e = 0) + (g : Germ) (w : List Bool) (hw : WordContour p g w) : + directedCurrent q (terminalGerm g w) = directedCurrent q g ∧ + ∀ e : EdgeIndex, wordFlow g w e ≠ 0 → + q e = -directedCurrent q g * (p e : ℚ) := by + induction w generalizing g with + | nil => simp [terminalGerm,wordFlow] + | cons b w ih => + obtain ⟨hstep,hlocal⟩ := local_contour_current p q hq hs g b hw.1 + obtain ⟨hend,hedge⟩ := ih (advance g b) hw.2 + constructor + · exact hend.trans hstep + · intro e he + by_cases ht : wordFlow (advance g b) w e ≠ 0 + · simpa only [hstep] using hedge e ht + · have hd : dartFlow (g.1,outgoingSlot g b) e ≠ 0 := by + simpa only [wordFlow,Finsupp.add_apply,not_not.mp ht,add_zero] using he + have heq : e = edgeOf (g.1,outgoingSlot g b) := by + by_contra h + exact hd (by simp [dartFlow,h]) + subst e + have h := hlocal (outgoingSlot g b) + rcases g with ⟨v,k⟩ + cases v <;> + simp [directedCurrent,dartSign,edgeOf,orientedFlow_up,orientedFlow_down] at h ⊢ <;> + linarith + +theorem simple_cycle_current_scalar (g : Germ) (w : List Bool) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (q : EdgeIndex → ℚ) (hq : ConservedCurrent q) + (hs : ∀ e, wordFlow g w e = 0 → q e = 0) : + ∃ c : ℚ, ∀ e, q e = c * (wordFlow g w e : ℚ) := by + refine ⟨-directedCurrent q g,?_⟩ + intro e + by_cases he : wordFlow g w e = 0 + · simp [hs e he,he] + · exact (word_contour_current _ q hq hs g w + (simple_closed_word_contour g w hN hc)).2 e he + +def faceGradient (r : FaceIndex → ℚ) (e : EdgeIndex) : ℚ := + r (leftFace (canonicalDart e)) - r (rightFace (canonicalDart e)) + +theorem directedCurrent_gradient (r : FaceIndex → ℚ) (g : Germ) : + directedCurrent (faceGradient r) g = r (leftFace g) - r (rightFace g) := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> + simp [directedCurrent,faceGradient,dartSign,edgeOf,canonicalDart,upEnd, + leftFace,rightFace,reverseGerm,neighbor] + +theorem gradient_conserved (r : FaceIndex → ℚ) : ConservedCurrent (faceGradient r) := by + intro v + simp only [directedCurrent_gradient] + cases v <;> simp [Fin.sum_univ_succ,leftFace,rightFace,reverseGerm,neighbor] <;> ring + +theorem finite_gradient_injective (r s : FaceIndex →₀ ℚ) + (h : faceGradient r = faceGradient s) : r = s := by + have hh (i j : ℤ) : r (i+1,j) - s (i+1,j) = r (i,j) - s (i,j) := by + have he := congrFun h ((i+1,j),0) + simp [faceGradient,canonicalDart,upEnd,leftFace,rightFace,reverseGerm,neighbor] at he + linarith + ext a + rcases a with ⟨i,j⟩ + let k : ℤ := -(QFlow.faceRadius r : ℤ) - QFlow.faceRadius s - 1 + have hr : r (k,j) = 0 := by + by_contra hz + have hb := (QFlow.mem_support_in_box r (k,j) (Finsupp.mem_support_iff.mpr hz)).1 + dsimp [k] at hb + omega + have hs : s (k,j) = 0 := by + by_contra hz + have hb := (QFlow.mem_support_in_box s (k,j) (Finsupp.mem_support_iff.mpr hz)).1 + dsimp [k] at hb + omega + have he := QFlow.int_function_constant (f := fun i => r (i,j) - s (i,j)) (fun i => hh i j) i k + rw [hr,hs] at he + linarith + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Curvature.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Curvature.lean new file mode 100644 index 0000000000000000000000000000000000000000..849ff1d75769fd8e631fe867b912f68e80f0184b --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Curvature.lean @@ -0,0 +1,229 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.PotentialSupport + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def turnUnit (b : Bool) : ℤ := if b then 1 else -1 + +def turnUnits (w : List Bool) : ℤ := (w.map turnUnit).sum + +def faceCount (S : Finset FaceIndex) (v : Vertex) : ℤ := + ∑ k : Fin 3, if leftFace (v,k) ∈ S then 1 else 0 + +def edgeCount (S : Finset FaceIndex) (v : Vertex) : ℤ := + ∑ k : Fin 3, if edgeOf (v,k) ∈ cellEdges S then 1 else 0 + +def cellCurvature (S : Finset FaceIndex) (v : Vertex) : ℤ := + 6 - 3 * edgeCount S v + faceCount S v + +@[simp] theorem rightFace_prev (v : Vertex) (k : Fin 3) : + rightFace (v,k) = leftFace (v,k+2) := by + cases v <;> fin_cases k <;> simp [rightFace,reverseGerm,neighbor,leftFace] + +theorem leftFace_injective (v : Vertex) : Function.Injective (fun k : Fin 3 => leftFace (v,k)) := by + intro k l h + cases v <;> fin_cases k <;> fin_cases l <;> simp [leftFace] at h ⊢ <;> omega + +theorem faceCount_incidence (S : Finset FaceIndex) (v : Vertex) : + faceCount S v = ∑ a ∈ S, if v ∈ faceVertices a then (1 : ℤ) else 0 := by + classical + have hpair (a : FaceIndex) : (∑ k : Fin 3, if leftFace (v,k) = a then (1 : ℤ) else 0) = + if v ∈ faceVertices a then 1 else 0 := by + by_cases hv : v ∈ faceVertices a + · obtain ⟨k,hk⟩ := (mem_faceVertices v a).mp hv + rw [ite_eq_left hv,Finset.sum_eq_single k] + · simp [hk] + · intro l _ hl + have hn : leftFace (v,l) ≠ a := fun h => hl (leftFace_injective v (h.trans hk.symm)) + simp [hn] + · simp + · rw [ite_eq_right hv] + apply Finset.sum_eq_zero + intro k _ + have hn : leftFace (v,k) ≠ a := fun h => hv ((mem_faceVertices v a).mpr ⟨k,h⟩) + simp [hn] + simp_rw [← hpair] + rw [Finset.sum_comm] + unfold faceCount + apply Finset.sum_congr rfl + intro k _ + simp + +@[simp] theorem edgeOf_slot (g : Germ) : (edgeOf g).2 = g.2 := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> simp [edgeOf] + +@[simp] theorem edgeOf_canonical (e : EdgeIndex) : edgeOf (canonicalDart e) = e := by + rcases e with ⟨⟨i,j⟩,k⟩ + rfl + +@[simp] theorem edgeOf_downEnd (e : EdgeIndex) : edgeOf (downEnd e,e.2) = e := by + change edgeOf (reverseGerm (canonicalDart e)) = e + rw [edgeOf_reverse,edgeOf_canonical] + +theorem edgeOf_eq_iff (v : Vertex) (e : EdgeIndex) : + edgeOf (v,e.2) = e ↔ v = upEnd e ∨ v = downEnd e := by + constructor + · intro h + rcases canonicalDart_edgeOf (v,e.2) with h' | h' + · rw [h] at h' + exact Or.inl (congrArg Prod.fst h').symm + · rw [h] at h' + have he := congrArg (fun x : Germ => (reverseGerm x).1) h' + simp only [reverseGerm_reverseGerm] at he + exact Or.inr he.symm + · rintro (rfl | rfl) + · exact edgeOf_canonical e + · exact edgeOf_downEnd e + +theorem upEnd_ne_downEnd (e : EdgeIndex) : upEnd e ≠ downEnd e := by + rcases e with ⟨⟨i,j⟩,k⟩ + fin_cases k <;> simp [upEnd,downEnd,neighbor] + +theorem edgeCount_incidence (S : Finset FaceIndex) (v : Vertex) : + edgeCount S v = ∑ e ∈ cellEdges S, + ((if v = upEnd e then 1 else 0) + (if v = downEnd e then 1 else 0) : ℤ) := by + classical + have hpair (e : EdgeIndex) : (∑ k : Fin 3, if edgeOf (v,k) = e then (1 : ℤ) else 0) = + (if v = upEnd e then 1 else 0) + (if v = downEnd e then 1 else 0) := by + rw [Finset.sum_eq_single e.2] + · simp only [edgeOf_eq_iff] + by_cases hu : v = upEnd e + · simp [hu,upEnd_ne_downEnd] + · by_cases hd : v = downEnd e + · simp [hd, Ne.symm (upEnd_ne_downEnd e)] + · simp [hu,hd] + · intro k _ hk + have hn : edgeOf (v,k) ≠ e := fun h => hk (by simpa using congrArg Prod.snd h) + simp [hn] + · simp + simp_rw [← hpair] + rw [Finset.sum_comm] + unfold edgeCount + apply Finset.sum_congr rfl + intro k _ + simp + +theorem faceVertices_card (a : FaceIndex) : (faceVertices a).card = 6 := by + rcases a with ⟨i,j⟩ + simp [faceVertices] + +theorem sum_faceCount (S : Finset FaceIndex) : + ∑ v ∈ cellVertices S, faceCount S v = 6 * (S.card : ℤ) := by + classical + simp_rw [faceCount_incidence] + rw [Finset.sum_comm] + have ha (a : FaceIndex) (hma : a ∈ S) : + (∑ v ∈ cellVertices S, if v ∈ faceVertices a then (1 : ℤ) else 0) = 6 := by + rw [← Finset.sum_filter] + have hF : (cellVertices S).filter (fun v => v ∈ faceVertices a) = faceVertices a := by + ext v + simp only [Finset.mem_filter,and_iff_right_iff_imp] + intro hv + exact Finset.mem_biUnion.mpr ⟨a,hma,hv⟩ + rw [hF] + simp [faceVertices_card] + simp_rw [Finset.sum_congr rfl ha] + simp [mul_comm] + +theorem sum_edgeCount (S : Finset FaceIndex) : + ∑ v ∈ cellVertices S, edgeCount S v = 2 * ((cellEdges S).card : ℤ) := by + classical + simp_rw [edgeCount_incidence] + rw [Finset.sum_comm] + have he (e : EdgeIndex) (hme : e ∈ cellEdges S) : + (∑ v ∈ cellVertices S, + ((if v = upEnd e then 1 else 0) + (if v = downEnd e then 1 else 0) : ℤ)) = 2 := by + have hu : upEnd e ∈ cellVertices S := + edge_mem_vertex S (canonicalDart e) (by simpa using hme) + have hd : downEnd e ∈ cellVertices S := + edge_mem_neighbor S (canonicalDart e) (by simpa using hme) + rw [Finset.sum_add_distrib] + simp [hu,hd] + simp_rw [Finset.sum_congr rfl he] + simp [mul_comm] + +theorem sum_cellCurvature (S : Finset FaceIndex) : + ∑ v ∈ cellVertices S, cellCurvature S v = + 6 * ((cellVertices S).card - (cellEdges S).card + (S.card : ℤ)) := by + simp only [cellCurvature,Finset.sum_add_distrib,Finset.sum_sub_distrib, + ← Finset.mul_sum,sum_faceCount,sum_edgeCount] + simp + ring + +theorem numeric_contour_curvature (f : Fin 3 → ℤ) (ε : ℤ) + (hε : ε = 1 ∨ ε = -1) (hf : ∀ l, f l = 0 ∨ f l = ε) + (k : Fin 3) (b : Bool) + (h : ∀ l : Fin 3, f l - f (l+2) = + (if l = k + (if b then 2 else 1) then 1 else 0) - (if l = k then 1 else 0)) : + 6 - 3 * (∑ l : Fin 3, if f l ≠ 0 ∨ f (l+2) ≠ 0 then (1 : ℤ) else 0) + + (∑ l : Fin 3, if f l ≠ 0 then (1 : ℤ) else 0) = ε * turnUnit b := by + have h0 := h 0 + have h1 := h 1 + have h2 := h 2 + have hf0 := hf 0 + have hf1 := hf 1 + have hf2 := hf 2 + clear h hf + rcases hε with rfl | rfl <;> fin_cases k <;> cases b <;> + rcases hf0 with hf0 | hf0 <;> rcases hf1 with hf1 | hf1 <;> + rcases hf2 with hf2 | hf2 <;> + simp only [Fin.sum_univ_succ] at * <;> simp_all [turnUnit] + +theorem contour_cellCurvature (p : FaceIndex →₀ ℤ) (ε : ℤ) + (hε : ε = 1 ∨ ε = -1) (hvals : ∀ a, p a = 0 ∨ p a = ε) + (q : EdgeIndex →₀ ℤ) (hp : RepresentsFlow p q) + (g : Germ) (b : Bool) (hw : LocalContour q g b) : + cellCurvature p.support g.1 = ε * turnUnit b := by + let f : Fin 3 → ℤ := fun l => p (leftFace (g.1,l)) + have hlocal (l : Fin 3) : f l - f (l+2) = + (if l = g.2 + (if b then 2 else 1) then 1 else 0) - (if l = g.2 then 1 else 0) := by + have h := (hp (g.1,l)).symm.trans (hw l) + simp only [f,rightFace_prev,outgoingSlot] at h ⊢ + exact h + have he := numeric_contour_curvature f ε hε (fun l => hvals _) g.2 b hlocal + unfold cellCurvature edgeCount faceCount + simp_rw [edge_mem_around,Finsupp.mem_support_iff,rightFace_prev] + exact he + +theorem nonboundary_cellCurvature (g : Germ) (w : List Bool) + (hc : terminalGerm g w = g) (p : FaceIndex →₀ ℤ) + (hp : RepresentsFlow p (wordFlow g w)) (v : Vertex) + (hv : v ∈ cellVertices p.support) (hnot : v ∉ traced g w) : + cellCurvature p.support v = 0 := by + have hE := nonboundary_vertex_all_edges g w hc p hp v hv hnot + have hz (l : Fin 3) : orientedFlow (wordFlow g w) (v,l) = 0 := by + rw [orientedFlow_wordFlow,hc,add_sub_cancel_right] + exact turnVisit_eq_zero_of_not_mem g w v l hnot + have he (l : Fin 3) : p (leftFace (v,l)) = p (rightFace (v,l)) := by + have h := hp (v,l) + rw [hz l] at h + omega + obtain ⟨l,hl⟩ := (mem_cellVertices _ v).mp hv + have hF (k : Fin 3) : leftFace (v,k) ∈ p.support := by + rw [Finsupp.mem_support_iff] at hl ⊢ + rwa [incident_faces_equal p v he k l] + simp [cellCurvature,edgeCount,faceCount,hE,hF] + +theorem contour_curvature_sum (p : FaceIndex →₀ ℤ) (ε : ℤ) + (hε : ε = 1 ∨ ε = -1) (hvals : ∀ a, p a = 0 ∨ p a = ε) + (q : EdgeIndex →₀ ℤ) (hp : RepresentsFlow p q) + (g : Germ) (w : List Bool) (hw : WordContour q g w) : + ((traced g w).map (cellCurvature p.support)).sum = ε * turnUnits w := by + induction w generalizing g with + | nil => simp [traced,turnUnits] + | cons b w ih => + simp only [traced,List.map_cons,List.sum_cons,turnUnits,List.map_cons,List.sum_cons] + rw [contour_cellCurvature p ε hε hvals q hp g b hw.1,ih _ hw.2] + simp only [turnUnits] + ring + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/CycleSplice.lean b/lean/OAI/Combinatorics/HoneycombCorridor/CycleSplice.lean new file mode 100644 index 0000000000000000000000000000000000000000..05a179e1d0e0a2fe7fd892847686c08bfb2f91d6 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/CycleSplice.lean @@ -0,0 +1,124 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.CollisionPhase + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def stemGerm (g : Germ) (b : Bool) : Germ := (g.1,unusedSlot g b) + +def reverseLoopGerm (g : Germ) (b : Bool) : Germ := (g.1,outgoingSlot g b) + +@[simp] theorem stem_forward (g : Germ) (b : Bool) : + advance (stemGerm g b) (!b) = advance g b := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [stemGerm,unusedSlot,advance,outgoingSlot] + +@[simp] theorem stem_reverse (g : Germ) (b : Bool) : + advance (stemGerm g b) b = reverseGerm g := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [stemGerm,unusedSlot,advance,outgoingSlot,reverseGerm] + +@[simp] theorem reverseLoop_advance (g : Germ) (b : Bool) : + advance (reverseLoopGerm g b) (!b) = reverseGerm g := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [reverseLoopGerm,advance,outgoingSlot,reverseGerm] + +@[simp] theorem reverseLoop_reverseLoop (g : Germ) (b : Bool) : + reverseLoopGerm (reverseLoopGerm g b) (!b) = g := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [reverseLoopGerm,outgoingSlot] + +@[simp] theorem reverseLoop_stem (g : Germ) (b : Bool) : + stemGerm (reverseLoopGerm g b) (!b) = stemGerm g b := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [reverseLoopGerm,stemGerm,unusedSlot,outgoingSlot] + +@[simp] theorem reverseGerm_advance_eq (g : Germ) (b : Bool) : + reverseGerm (advance g b) = reverseLoopGerm g b := by + simp [reverseGerm,advance,reverseLoopGerm] + +@[simp] theorem stem_forward_trace (g : Germ) (b : Bool) (w : List Bool) : + traced (stemGerm g b) ((!b) :: w) = traced g (b :: w) := by + change g.1 :: traced (advance (stemGerm g b) (!b)) w = _ + rw [stem_forward] + rfl + +@[simp] theorem stem_forward_terminal (g : Germ) (b : Bool) (w : List Bool) : + terminalGerm (stemGerm g b) ((!b) :: w) = terminalGerm g (b :: w) := by + simp [terminalGerm] + +theorem stem_reverse_trace (g : Germ) (b : Bool) (w : List Bool) + (hc : terminalGerm g (b :: w) = g) : + traced (stemGerm g b) (b :: reverseTurns w) = + g.1 :: (traced (advance g b) w).reverse := by + have hr := traced_reverse (advance g b) w + rw [show terminalGerm (advance g b) w = g from hc] at hr + change g.1 :: traced (advance (stemGerm g b) b) (reverseTurns w) = _ + rw [stem_reverse,hr] + +theorem reverse_loop_terminal (g : Germ) (b : Bool) (w : List Bool) + (hc : terminalGerm g (b :: w) = g) : + terminalGerm (reverseLoopGerm g b) ((!b) :: reverseTurns w) = + reverseLoopGerm g b := by + have hr := terminalGerm_reverse (advance g b) w + rw [show terminalGerm (advance g b) w = g from hc] at hr + simpa only [terminalGerm, reverseLoop_advance, reverseGerm_advance_eq] using hr + +theorem reverse_loop_trace (g : Germ) (b : Bool) (w : List Bool) + (hc : terminalGerm g (b :: w) = g) : + traced (reverseLoopGerm g b) ((!b) :: reverseTurns w) = + g.1 :: (traced (advance g b) w).reverse := by + have hr := traced_reverse (advance g b) w + rw [show terminalGerm (advance g b) w = g from hc] at hr + change g.1 :: traced (advance (reverseLoopGerm g b) (!b)) (reverseTurns w) = _ + rw [reverseLoop_advance,hr] + +theorem reverse_loop_nodup (g : Germ) (b : Bool) (w : List Bool) + (hc : terminalGerm g (b :: w) = g) (hN : (traced g (b :: w)).Nodup) : + (traced (reverseLoopGerm g b) ((!b) :: reverseTurns w)).Nodup := by + rw [reverse_loop_trace g b w hc] + simpa [traced] using hN + +@[simp] theorem dartFlow_reverse (g : Germ) : dartFlow (reverseGerm g) = -dartFlow g := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> simp [dartFlow,edgeOf,dartSign,reverseGerm,neighbor] + +@[simp] theorem reverseLoop_outgoing (g : Germ) (b : Bool) : + ((reverseLoopGerm g b).1,outgoingSlot (reverseLoopGerm g b) (!b)) = g := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [reverseLoopGerm,outgoingSlot] + +theorem wordFlow_reverse (g : Germ) (w : List Bool) : + wordFlow (reverseGerm (terminalGerm g w)) (reverseTurns w) = + -wordFlow g w + dartFlow g - dartFlow (terminalGerm g w) := by + induction w generalizing g with + | nil => simp [wordFlow,terminalGerm] + | cons b w ih => + simp only [terminalGerm,reverseTurns_cons,wordFlow_append,wordFlow,ih] + rw [terminalGerm_reverse] + simp only [reverseGerm_advance_eq,reverseLoop_outgoing,add_zero] + have hd : dartFlow (advance g b) = -dartFlow (g.1,outgoingSlot g b) := by + exact dartFlow_reverse (g.1,outgoingSlot g b) + rw [hd] + abel + +theorem reverse_loop_flow (g : Germ) (b : Bool) (w : List Bool) + (hc : terminalGerm g (b :: w) = g) : + wordFlow (reverseLoopGerm g b) ((!b) :: reverseTurns w) = -wordFlow g (b :: w) := by + have hr := wordFlow_reverse (advance g b) w + rw [show terminalGerm (advance g b) w = g from hc] at hr + simp only [wordFlow,reverseLoop_outgoing,reverseLoop_advance] + rw [hr] + have hd : dartFlow (advance g b) = -dartFlow (g.1,outgoingSlot g b) := + dartFlow_reverse (g.1,outgoingSlot g b) + rw [hd] + abel + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/EdgeFlow.lean b/lean/OAI/Combinatorics/HoneycombCorridor/EdgeFlow.lean new file mode 100644 index 0000000000000000000000000000000000000000..b52bb68019f75339cff61190036d5c4302659f9e --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/EdgeFlow.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Basic +import OAI.Combinatorics.HoneycombCorridor.IntegerPotential + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor +abbrev EdgeIndex := FaceIndex × Fin 3 + +def upEnd (e : EdgeIndex) : Vertex := .up e.1.1 e.1.2 + +def downEnd (e : EdgeIndex) : Vertex := neighbor (upEnd e) e.2 + +noncomputable def edgeBoundary : (EdgeIndex →₀ ℤ) →+ (Vertex →₀ ℤ) := + Finsupp.liftAddHom fun e => Finsupp.singleAddHom (upEnd e) - Finsupp.singleAddHom (downEnd e) + +@[simp] theorem edgeBoundary_single (e : EdgeIndex) (a : ℤ) : + edgeBoundary (Finsupp.single e a) = + Finsupp.single (upEnd e) a - Finsupp.single (downEnd e) a := by + simp [edgeBoundary] + +def edgeOf : Germ → EdgeIndex + | (.up i j, k) => ((i,j),k) + | (.down i j, k) => + if k = 0 then ((i,j+1),k) else if k = 1 then ((i,j),k) else ((i+1,j),k) + +def dartSign : Germ → ℤ + | (.up _ _, _) => 1 + | (.down _ _, _) => -1 + +noncomputable def dartFlow (g : Germ) : EdgeIndex →₀ ℤ := + Finsupp.single (edgeOf g) (dartSign g) + +@[simp] theorem edgeBoundary_dartFlow (g : Germ) : + edgeBoundary (dartFlow g) = + Finsupp.single g.1 1 - Finsupp.single (neighbor g.1 g.2) 1 := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> + simp [dartFlow,edgeOf,dartSign,upEnd,downEnd,neighbor] + +noncomputable def wordFlow : Germ → List Bool → (EdgeIndex →₀ ℤ) + | _, [] => 0 + | g, b :: w => dartFlow (g.1,outgoingSlot g b) + wordFlow (advance g b) w + +theorem boundary_wordFlow (g : Germ) (w : List Bool) : + edgeBoundary (wordFlow g w) = + Finsupp.single g.1 1 - Finsupp.single (terminalGerm g w).1 1 := by + induction w generalizing g with + | nil => simp [wordFlow,terminalGerm] + | cons b w ih => + simp only [wordFlow,map_add,edgeBoundary_dartFlow,ih,terminalGerm] + simp only [advance] + abel + +noncomputable def flowComponent (q : EdgeIndex →₀ ℤ) (k : Fin 3) : FaceIndex →₀ ℤ := + Finsupp.comapDomain (fun a => (a,k)) q (by intro a _ b _ h; exact Prod.mk.inj h |>.1) + +@[simp] theorem flowComponent_apply (q : EdgeIndex →₀ ℤ) (k : Fin 3) (a : FaceIndex) : + flowComponent q k a = q (a,k) := rfl + +theorem boundary_up (q : EdgeIndex →₀ ℤ) (i j : ℤ) : + edgeBoundary q (.up i j) = q ((i,j),0) + q ((i,j),1) + q ((i,j),2) := by + classical + induction q using Finsupp.induction_linear with + | zero => simp + | add q r hq hr => simp only [map_add,Finsupp.add_apply,hq,hr]; ring + | single e a => + rcases e with ⟨⟨x,y⟩,k⟩ + fin_cases k <;> + simp [edgeBoundary_single,upEnd,downEnd,neighbor,Finsupp.single_apply,eq_comm] + +theorem boundary_down (q : EdgeIndex →₀ ℤ) (i j : ℤ) : + edgeBoundary q (.down i j) = + -(q ((i,j+1),0) + q ((i,j),1) + q ((i+1,j),2)) := by + classical + induction q using Finsupp.induction_linear with + | zero => simp + | add q r hq hr => simp only [map_add,Finsupp.add_apply,hq,hr]; ring + | single e a => + rcases e with ⟨⟨x,y⟩,k⟩ + have hy : j = y - 1 ↔ y = j + 1 := by omega + have hx : i = x - 1 ↔ x = i + 1 := by omega + fin_cases k <;> + simp [edgeBoundary_single,upEnd,downEnd,neighbor,Finsupp.single_apply,eq_comm,hy,hx] + +noncomputable def closedWordFlow (g : Germ) (w : List Bool) + (hc : terminalGerm g w = g) : FiniteHoneycombFlow where + q0 := flowComponent (wordFlow g w) 0 + q1 := flowComponent (wordFlow g w) 1 + q2 := flowComponent (wordFlow g w) 2 + up_conservation := by + intro i j + simp only [flowComponent_apply] + rw [← boundary_up,boundary_wordFlow,hc,sub_self] + rfl + down_conservation := by + intro i j + simp only [flowComponent_apply] + have h := boundary_down (wordFlow g w) i j + rw [boundary_wordFlow,hc,sub_self] at h + simp only [Finsupp.zero_apply] at h + omega + +theorem closed_word_has_finite_potential (g : Germ) (w : List Bool) + (hc : terminalGerm g w = g) : + ∃ p : FaceIndex →₀ ℤ, ∀ i j, + wordFlow g w ((i,j),0) = p (i,j) - p (i-1,j) ∧ + wordFlow g w ((i,j),1) = p (i-1,j+1) - p (i,j) ∧ + wordFlow g w ((i,j),2) = p (i-1,j) - p (i-1,j+1) := by + exact finite_flow_is_face_boundary (closedWordFlow g w hc) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/EulerRank.lean b/lean/OAI/Combinatorics/HoneycombCorridor/EulerRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..caf942c6350aeb0b007a269a167676a52d9be352 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/EulerRank.lean @@ -0,0 +1,37 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +theorem cell_euler_of_exact {V E F : Type*} [Fintype V] [Fintype E] [Fintype F] + [DecidableEq V] [DecidableEq E] [Nonempty V] + (A : Matrix V E ℚ) (B : (F → ℚ) →ₗ[ℚ] (E → ℚ)) + (hB : Function.Injective B) (hex : B.range = A.mulVecLin.ker) + (hconst : A.transpose.mulVecLin.ker = Submodule.span ℚ {(1 : V → ℚ)}) : + (Fintype.card V : ℤ) - Fintype.card E + Fintype.card F = 1 := by + have hF : Module.finrank ℚ A.mulVecLin.ker = Fintype.card F := by + rw [← hex,LinearMap.finrank_range_of_inj hB,Module.finrank_fintype_fun_eq_card] + have hV : Module.finrank ℚ A.transpose.mulVecLin.ker = 1 := by + rw [hconst] + exact finrank_span_singleton (by + obtain ⟨v⟩ := ‹Nonempty V› + intro h + have := congrFun h v + norm_num at this) + have hrE := A.mulVecLin.finrank_range_add_finrank_ker + have hrV := A.transpose.mulVecLin.finrank_range_add_finrank_ker + have hr := A.rank_transpose + change Module.finrank ℚ A.transpose.mulVecLin.range = + Module.finrank ℚ A.mulVecLin.range at hr + rw [hF,Module.finrank_fintype_fun_eq_card] at hrE + rw [hV,Module.finrank_fintype_fun_eq_card] at hrV + omega + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Excursions.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Excursions.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab3898e665368cdfde8b8776f1bf9a7f5aeec543 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Excursions.lean @@ -0,0 +1,422 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Basic + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def reverseGerm (g : Germ) : Germ := (neighbor g.1 g.2, g.2) + +def reverseTurns (w : List Bool) : List Bool := w.reverse.map Bool.not + +@[simp] theorem reverseGerm_reverseGerm (g : Germ) : + reverseGerm (reverseGerm g) = g := by + rcases g with ⟨v,k⟩ + simp [reverseGerm] + +@[simp] theorem reverseTurns_reverseTurns (w : List Bool) : + reverseTurns (reverseTurns w) = w := by + simp [reverseTurns, List.map_reverse, List.map_map, Function.comp_def] + +@[simp] theorem reverseTurns_nil : reverseTurns [] = [] := rfl + +@[simp] theorem reverseTurns_cons (b : Bool) (w : List Bool) : + reverseTurns (b :: w) = reverseTurns w ++ [!b] := by + simp [reverseTurns] + +@[simp] theorem terminalGerm_append (g : Germ) (u w : List Bool) : + terminalGerm g (u ++ w) = terminalGerm (terminalGerm g u) w := by + induction u generalizing g with + | nil => rfl + | cons b u ih => simpa [terminalGerm] using ih (advance g b) + +@[simp] theorem traced_append (g : Germ) (u w : List Bool) : + traced g (u ++ w) = traced g u ++ traced (terminalGerm g u) w := by + induction u generalizing g with + | nil => rfl + | cons b u ih => simp [traced, terminalGerm, ih] + +@[simp] theorem advance_reverse (g : Germ) (b : Bool) : + advance (reverseGerm (advance g b)) (!b) = reverseGerm g := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [advance, outgoingSlot, reverseGerm] + +@[simp] theorem terminalGerm_reverse (g : Germ) (w : List Bool) : + terminalGerm (reverseGerm (terminalGerm g w)) (reverseTurns w) = reverseGerm g := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + rw [reverseTurns_cons, terminalGerm_append] + simp only [terminalGerm, ih, advance_reverse] + +@[simp] theorem traced_reverse (g : Germ) (w : List Bool) : + traced (reverseGerm (terminalGerm g w)) (reverseTurns w) = (traced g w).reverse := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + rw [reverseTurns_cons, traced_append] + simp only [terminalGerm, ih, terminalGerm_reverse, traced, List.reverse_cons] + simp [reverseGerm, advance] + +@[simp] theorem stepWeight_not (b : Bool) : + stepWeight (!b) = (starRingEnd ℂ) (stepWeight b) := by + have ha : turnAngle (!b) = -turnAngle b := by cases b <;> simp [turnAngle] + rw [stepWeight, ha, stepWeight, map_mul, ← Complex.exp_conj] + simp only [Complex.conj_ofReal, map_mul, Complex.conj_I] + congr 1 + push_cast + ring_nf + +@[simp] theorem wordWeight_reverse (w : List Bool) : + wordWeight (reverseTurns w) = (starRingEnd ℂ) (wordWeight w) := by + unfold wordWeight reverseTurns + rw [List.map_map] + simp only [Function.comp_def, stepWeight_not] + rw [show (fun b => (starRingEnd ℂ) (stepWeight b)) = + (starRingEnd ℂ) ∘ stepWeight from rfl, ← List.map_map, map_list_prod] + simp only [List.map_reverse, List.prod_reverse] + +theorem stopped_of_trace (D : Finset Vertex) (g : Germ) (w : List Bool) + (hN : (traced g w).Nodup) (hD : ∀ v ∈ traced g w, v ∈ D) + (ht : (terminalGerm g w).1 ∉ D) : Stopped D g w := by + induction w generalizing D g with + | nil => exact ht + | cons b w ih => + simp only [traced, List.nodup_cons] at hN + refine ⟨hD _ (by simp [traced]), ih _ _ hN.2 ?_ ?_⟩ + · intro v hv + exact Finset.mem_erase.mpr ⟨fun he => hN.1 (he ▸ hv), + hD _ (by simp [traced, hv])⟩ + · exact fun hm => ht (Finset.mem_of_mem_erase hm) + +def IsExcursion (D : Finset Vertex) (e : Germ × List Bool) : Prop := + e.1.1 ∈ D ∧ (reverseGerm e.1).1 ∉ D ∧ Stopped D e.1 e.2 ∧ + (terminalGerm e.1 e.2).1 ∉ D + +noncomputable def excursions (D : Finset Vertex) : Finset (Germ × List Bool) := by + classical + exact ((D.product Finset.univ).biUnion fun g => + (leaves D g).image fun w => (g, w)).filter (IsExcursion D) + +@[simp] theorem mem_excursions (D : Finset Vertex) (e : Germ × List Bool) : + e ∈ excursions D ↔ IsExcursion D e := by + classical + rw [excursions, Finset.mem_filter] + constructor + · exact And.right + · intro he + refine ⟨?_, he⟩ + apply Finset.mem_biUnion.mpr + refine ⟨e.1, Finset.mem_product.mpr ⟨he.1, Finset.mem_univ _⟩, ?_⟩ + exact Finset.mem_image.mpr ⟨e.2, (mem_leaves_iff _ _ _).mpr he.2.2.1, rfl⟩ + +def reverseExcursion (e : Germ × List Bool) : Germ × List Bool := + (reverseGerm (terminalGerm e.1 e.2), reverseTurns e.2) + +@[simp] theorem reverseExcursion_reverseExcursion (e : Germ × List Bool) : + reverseExcursion (reverseExcursion e) = e := by + rcases e with ⟨g,w⟩ + simp [reverseExcursion] + +theorem IsExcursion.nonempty {D : Finset Vertex} {e : Germ × List Bool} + (he : IsExcursion D e) : e.2 ≠ [] := by + intro hw + exact he.2.2.2 (by simpa [hw, terminalGerm] using he.1) + +theorem reverse_first_mem (g : Germ) (w : List Bool) (hw : w ≠ []) : + (reverseGerm (terminalGerm g w)).1 ∈ traced g w := by + have hr : reverseTurns w ≠ [] := by + intro he + have := congrArg reverseTurns he + exact hw (by simpa using this) + obtain ⟨b,u,hu⟩ := List.exists_cons_of_ne_nil hr + have hm : (reverseGerm (terminalGerm g w)).1 ∈ + traced (reverseGerm (terminalGerm g w)) (reverseTurns w) := by + simp [hu, traced] + simpa using hm + +theorem IsExcursion.reverse {D : Finset Vertex} {e : Germ × List Bool} + (he : IsExcursion D e) : IsExcursion D (reverseExcursion e) := by + obtain ⟨hN,hD⟩ := stopped_traced D e.1 e.2 he.2.2.1 + refine ⟨hD _ (reverse_first_mem _ _ he.nonempty), ?_, ?_, ?_⟩ + · simpa [reverseExcursion] using he.2.2.2 + · apply stopped_of_trace + · simpa [reverseExcursion] using hN + · intro v hv + apply hD v + simpa [reverseExcursion] using hv + · simpa [reverseExcursion] using he.2.1 + · simpa [reverseExcursion] using he.2.1 + +@[simp] theorem reverseExcursion_mem (D : Finset Vertex) (e : Germ × List Bool) : + reverseExcursion e ∈ excursions D ↔ e ∈ excursions D := by + rw [mem_excursions, mem_excursions] + exact ⟨fun he => by simpa using he.reverse, IsExcursion.reverse⟩ + +noncomputable def visitSum (D : Finset Vertex) (v : Vertex) : ℂ := by + classical + exact ∑ e ∈ excursions D, if v ∈ traced e.1 e.2 then wordWeight e.2 else 0 + +theorem visitSum_conj (D : Finset Vertex) (v : Vertex) : + (starRingEnd ℂ) (visitSum D v) = visitSum D v := by + classical + simp only [visitSum, map_sum] + simp_rw [apply_ite (starRingEnd ℂ), map_zero] + apply Finset.sum_bij (fun e _ => reverseExcursion e) + · intro e he + exact (reverseExcursion_mem D e).mpr he + · intro e he f hf hef + have := congrArg reverseExcursion hef + simpa using this + · intro e he + exact ⟨reverseExcursion e, (reverseExcursion_mem D e).mpr he, by simp⟩ + · intro e he + simp [reverseExcursion] + +theorem visitSum_im (D : Finset Vertex) (v : Vertex) : (visitSum D v).im = 0 := + Complex.conj_eq_iff_im.mp (visitSum_conj D v) + +noncomputable def markedLeaves (D : Finset Vertex) (g : Germ) (v : Vertex) : ℂ := by + classical + exact ∑ w ∈ leaves D g, if v ∈ traced g w then wordWeight w else 0 + +noncomputable def firstArrival (D : Finset Vertex) (g : Germ) (v : Vertex) : ℂ := by + classical + exact ∑ w ∈ leaves (D.erase v) g, + if (terminalGerm g w).1 = v then wordWeight w else 0 + +theorem sum_leaves_of_mem (D : Finset Vertex) (g : Germ) (hg : g.1 ∈ D) + (f : List Bool → ℂ) : + ∑ w ∈ leaves D g, f w = + (∑ w ∈ leaves (D.erase g.1) (advance g true), f (true :: w)) + + (∑ w ∈ leaves (D.erase g.1) (advance g false), f (false :: w)) := by + rw [leaves, ite_eq_left hg, Finset.sum_union (disjoint_cons_images _ _)] + congr 1 <;> apply Finset.sum_image <;> intro a ha b hb hab <;> + exact (List.cons.inj hab).2 + +theorem leaves_of_not_mem (D : Finset Vertex) (g : Germ) (hg : g.1 ∉ D) : + leaves D g = {[]} := by rw [leaves, ite_eq_right hg] + +theorem markedLeaves_eq_firstArrival (D : Finset Vertex) (g : Germ) (v : Vertex) + (hv : v ∈ D) : markedLeaves D g v = firstArrival D g v := by + classical + induction D using Finset.strongInductionOn generalizing g with + | _ D ih => + by_cases hgv : g.1 = v + · have hg : g.1 ∈ D := hgv ▸ hv + have hm : markedLeaves D g v = 1 := by + unfold markedLeaves + convert leaf_balance D g using 1 + apply Finset.sum_congr rfl + intro w hw + have hne : w ≠ [] := by + intro he + subst w + have := (mem_leaves_iff D g []).mp hw + exact this hg + obtain ⟨b,u,rfl⟩ := List.exists_cons_of_ne_nil hne + simp [traced, hgv] + rw [hm] + simp [firstArrival, leaves_of_not_mem (D.erase v) g (by simp [hgv]), terminalGerm, hgv] + · by_cases hg : g.1 ∈ D + · have hers : D.erase g.1 ⊂ D := Finset.erase_ssubset hg + have hve : v ∈ D.erase g.1 := Finset.mem_erase.mpr ⟨Ne.symm hgv, hv⟩ + have hge : g.1 ∈ D.erase v := Finset.mem_erase.mpr ⟨hgv,hg⟩ + unfold markedLeaves firstArrival + rw [sum_leaves_of_mem _ _ hg, sum_leaves_of_mem _ _ hge] + simp +instances only [traced, List.mem_cons, eq_comm (a := v), hgv, false_or, + terminalGerm, wordWeight_cons, ← mul_ite_zero, ← Finset.mul_sum] + rw [Finset.erase_right_comm (a := v) (b := g.1)] + change _ = + (∑ w ∈ leaves ((D.erase g.1).erase v) (advance g true), + if (terminalGerm (advance g true) w).1 = v then + stepWeight true * wordWeight w else 0) + + (∑ w ∈ leaves ((D.erase g.1).erase v) (advance g false), + if (terminalGerm (advance g false) w).1 = v then + stepWeight false * wordWeight w else 0) + simp_rw [← mul_ite_zero, ← Finset.mul_sum] + change stepWeight true * markedLeaves (D.erase g.1) (advance g true) v + + stepWeight false * markedLeaves (D.erase g.1) (advance g false) v = + stepWeight true * firstArrival (D.erase g.1) (advance g true) v + + stepWeight false * firstArrival (D.erase g.1) (advance g false) v + rw [ih _ hers _ hve, ih _ hers _ hve] + · have hge : g.1 ∉ D.erase v := fun h => hg (Finset.mem_of_mem_erase h) + simp [markedLeaves, firstArrival, leaves_of_not_mem _ _ hg, + leaves_of_not_mem _ _ hge, traced, terminalGerm, hgv] + +noncomputable def exitSum (D : Finset Vertex) (g : Germ) : ℂ := by + classical + exact ∑ w ∈ leaves D g, if (terminalGerm g w).1 ∉ D then wordWeight w else 0 + +noncomputable def collisionSum (D : Finset Vertex) (g : Germ) : ℂ := by + classical + exact ∑ w ∈ leaves D g, if (terminalGerm g w).1 ∈ D then wordWeight w else 0 + +theorem exit_add_collision (D : Finset Vertex) (g : Germ) : + exitSum D g + collisionSum D g = 1 := by + classical + unfold exitSum collisionSum + rw [← Finset.sum_add_distrib] + convert leaf_balance D g using 1 + apply Finset.sum_congr rfl + intro w hw + by_cases ht : (terminalGerm g w).1 ∈ D <;> simp [ht] + +noncomputable def boundaryGerms (D : Finset Vertex) : Finset Germ := by + classical + exact (D.product Finset.univ).filter fun g => (reverseGerm g).1 ∉ D + +@[simp] theorem mem_boundaryGerms (D : Finset Vertex) (g : Germ) : + g ∈ boundaryGerms D ↔ g.1 ∈ D ∧ (reverseGerm g).1 ∉ D := by + classical + simp [boundaryGerms] + +noncomputable def firstArrivals (D : Finset Vertex) (v : Vertex) : + Finset (Germ × List Bool) := by + classical + exact ((boundaryGerms D).biUnion fun g => + (leaves (D.erase v) g).image fun w => (g,w)).filter fun e => + (terminalGerm e.1 e.2).1 = v + +@[simp] theorem mem_firstArrivals (D : Finset Vertex) (v : Vertex) + (e : Germ × List Bool) : e ∈ firstArrivals D v ↔ + e.1 ∈ boundaryGerms D ∧ Stopped (D.erase v) e.1 e.2 ∧ + (terminalGerm e.1 e.2).1 = v := by + classical + simp only [firstArrivals, Finset.mem_filter, Finset.mem_biUnion, Finset.mem_image] + constructor + · rintro ⟨⟨g,hg,w,hw,he⟩,ht⟩ + subst e + exact ⟨hg, (mem_leaves_iff _ _ _).mp hw,ht⟩ + · rintro ⟨hg,hw,ht⟩ + exact ⟨⟨e.1,hg,e.2,(mem_leaves_iff _ _ _).mpr hw,rfl⟩,ht⟩ + +noncomputable def rayExits (D : Finset Vertex) (v : Vertex) : + Finset (Fin 3 × List Bool) := by + classical + exact (Finset.univ.biUnion fun k : Fin 3 => + (leaves (D.erase v) (neighbor v k,k)).image fun w => (k,w)).filter fun e => + (terminalGerm (neighbor v e.1,e.1) e.2).1 ∉ D + +@[simp] theorem mem_rayExits (D : Finset Vertex) (v : Vertex) + (e : Fin 3 × List Bool) : e ∈ rayExits D v ↔ + Stopped (D.erase v) (neighbor v e.1,e.1) e.2 ∧ + (terminalGerm (neighbor v e.1,e.1) e.2).1 ∉ D := by + classical + simp only [rayExits, Finset.mem_filter, Finset.mem_biUnion, Finset.mem_image] + constructor + · rintro ⟨⟨k,hk,w,hw,he⟩,ht⟩ + subst e + exact ⟨(mem_leaves_iff _ _ _).mp hw,ht⟩ + · rintro ⟨hw,ht⟩ + exact ⟨⟨e.1,Finset.mem_univ _,e.2,(mem_leaves_iff _ _ _).mpr hw,rfl⟩,ht⟩ + +def reversePrefix (e : Germ × List Bool) : Fin 3 × List Bool := + ((terminalGerm e.1 e.2).2, reverseTurns e.2) + +def reverseRay (v : Vertex) (e : Fin 3 × List Bool) : Germ × List Bool := + (reverseGerm (terminalGerm (neighbor v e.1,e.1) e.2), reverseTurns e.2) + +theorem reversePrefix_initial {v : Vertex} {e : Germ × List Bool} + (ht : (terminalGerm e.1 e.2).1 = v) : + (neighbor v (reversePrefix e).1,(reversePrefix e).1) = + reverseGerm (terminalGerm e.1 e.2) := by + simp [reversePrefix,reverseGerm,ht] + +theorem reversePrefix_mem {D : Finset Vertex} {v : Vertex} + {e : Germ × List Bool} (he : e ∈ firstArrivals D v) : + reversePrefix e ∈ rayExits D v := by + classical + obtain ⟨hg,hs,ht⟩ := (mem_firstArrivals D v e).mp he + obtain ⟨hgD,hgb⟩ := (mem_boundaryGerms D e.1).mp hg + obtain ⟨hN,hD⟩ := stopped_traced _ _ _ hs + rw [mem_rayExits,reversePrefix_initial ht] + constructor + · apply stopped_of_trace + · simpa [reversePrefix] using hN + · intro u hu + apply hD u + simpa [reversePrefix] using hu + · simpa [reversePrefix] using + (fun hu => hgb (Finset.mem_of_mem_erase hu) : (reverseGerm e.1).1 ∉ D.erase v) + · simpa [reversePrefix] using hgb + +theorem reverseRay_mem {D : Finset Vertex} {v : Vertex} (hv : v ∈ D) + {e : Fin 3 × List Bool} (he : e ∈ rayExits D v) : + reverseRay v e ∈ firstArrivals D v := by + classical + obtain ⟨hs,ht⟩ := (mem_rayExits D v e).mp he + obtain ⟨hN,hD⟩ := stopped_traced _ _ _ hs + rw [mem_firstArrivals,mem_boundaryGerms] + refine ⟨⟨?_,?_⟩,?_,?_⟩ + · by_cases hw : e.2 = [] + · simpa [reverseRay,hw,terminalGerm,reverseGerm] using hv + · exact Finset.mem_of_mem_erase + (hD _ (reverse_first_mem (neighbor v e.1,e.1) e.2 hw)) + · simpa [reverseRay] using ht + · apply stopped_of_trace + · simpa [reverseRay] using hN + · intro u hu + apply hD u + simpa [reverseRay] using hu + · simp only [reverseRay, terminalGerm_reverse] + simp [reverseGerm] + · simp only [reverseRay, terminalGerm_reverse] + simp [reverseGerm] + +@[simp] theorem reversePrefix_reverseRay (v : Vertex) (e : Fin 3 × List Bool) : + reversePrefix (reverseRay v e) = e := by + simp only [reversePrefix,reverseRay, terminalGerm_reverse, + reverseTurns_reverseTurns] + rfl + +theorem reverseRay_reversePrefix (v : Vertex) (e : Germ × List Bool) + (ht : (terminalGerm e.1 e.2).1 = v) : reverseRay v (reversePrefix e) = e := by + unfold reverseRay + rw [reversePrefix_initial ht] + simp [reversePrefix] + +theorem prefix_ray_reversal (D : Finset Vertex) (v : Vertex) (hv : v ∈ D) : + (∑ e ∈ firstArrivals D v, wordWeight e.2) = + (starRingEnd ℂ) (∑ e ∈ rayExits D v, wordWeight e.2) := by + classical + rw [map_sum] + apply Finset.sum_bij (fun e _ => reversePrefix e) + · intro e he + exact reversePrefix_mem he + · intro e he f hf hef + have het := ((mem_firstArrivals D v e).mp he).2.2 + have hft := ((mem_firstArrivals D v f).mp hf).2.2 + have h := congrArg (reverseRay v) hef + simpa [reverseRay_reversePrefix _ _ het,reverseRay_reversePrefix _ _ hft] using h + · intro e he + exact ⟨reverseRay v e,reverseRay_mem hv he,reversePrefix_reverseRay _ _⟩ + · intro e he + simp [reversePrefix] + +theorem IsExcursion.distinct_ports {D : Finset Vertex} {e : Germ × List Bool} + (he : IsExcursion D e) : reverseGerm (terminalGerm e.1 e.2) ≠ e.1 := by + intro hp + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil he.nonempty + have hN := (stopped_traced D e.1 e.2 he.2.2.1).1 + rw [hw,traced,List.nodup_cons] at hN + cases w with + | nil => + have hk := congrArg Prod.snd hp + simp only [hw,terminalGerm,reverseGerm,advance] at hk + rcases e.1 with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [outgoingSlot] at hk + | cons c w => + apply hN.1 + have hm := reverse_first_mem (advance e.1 b) (c :: w) (by simp) + have hx : (reverseGerm (terminalGerm (advance e.1 b) (c :: w))).1 = e.1.1 := + congrArg Prod.fst (by simpa only [hw,terminalGerm] using hp) + exact hx ▸ hm + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/FaceBoundary.lean b/lean/OAI/Combinatorics/HoneycombCorridor/FaceBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..8328a94e959fc450af5bf9dc4a8a43b35fb6534f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/FaceBoundary.lean @@ -0,0 +1,120 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Convexity + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def OnFaceBoundary (S : Finset FaceIndex) (g : Germ) : Prop := + leftFace g ∉ S ∧ rightFace g ∈ S + +noncomputable def faceBoundaryTurn (S : Finset FaceIndex) (g : Germ) : Bool := + decide (leftFace (g.1,g.2+1) ∉ S) + +theorem faceBoundary_advance (S : Finset FaceIndex) (g : Germ) + (hg : OnFaceBoundary S g) : + OnFaceBoundary S (advance g (faceBoundaryTurn S g)) := by + classical + rcases g with ⟨v,k⟩ + have h := hg + simp only [OnFaceBoundary,rightFace_prev] at h + unfold faceBoundaryTurn + by_cases ht : leftFace (v,k+1) ∈ S + · simp only [ht,not_true_eq_false,decide_false] + cases v <;> fin_cases k <;> + simp_all [OnFaceBoundary,advance,outgoingSlot,leftFace,rightFace,reverseGerm,neighbor] + · simp only [ht,not_false_eq_true,decide_true] + cases v <;> fin_cases k <;> + simp_all [OnFaceBoundary,advance,outgoingSlot,leftFace,rightFace,reverseGerm,neighbor] + +theorem faceBoundary_germ_unique (S : Finset FaceIndex) (v : Vertex) (k l : Fin 3) + (hk : OnFaceBoundary S (v,k)) (hl : OnFaceBoundary S (v,l)) : k = l := by + simp only [OnFaceBoundary,rightFace_prev] at hk hl + fin_cases k <;> fin_cases l <;> norm_num at hk hl ⊢ <;> tauto + +theorem faceBoundary_vertex_mem (S : Finset FaceIndex) (g : Germ) + (hg : OnFaceBoundary S g) : g.1 ∈ cellVertices S := by + apply (mem_cellVertices _ _).mpr + exact ⟨g.2+2,by simpa only [rightFace_prev] using + (show rightFace (g.1,g.2) ∈ S from hg.2)⟩ + +abbrev FaceBoundary (S : Finset FaceIndex) := {g : Germ // OnFaceBoundary S g} + +noncomputable instance faceBoundaryFinite (S : Finset FaceIndex) : Finite (FaceBoundary S) := by + let f : FaceBoundary S → (cellVertices S) × Fin 3 := + fun g => (⟨g.val.1,faceBoundary_vertex_mem S g.val g.property⟩,g.val.2) + apply Finite.of_injective f + intro g h he + apply Subtype.ext + have hv := congrArg (fun x : (cellVertices S) × Fin 3 => (x.1.val,x.2)) he + exact hv + +noncomputable def faceBoundaryNext (S : Finset FaceIndex) (g : FaceBoundary S) : FaceBoundary S := + ⟨advance g.val (faceBoundaryTurn S g.val),faceBoundary_advance S _ g.property⟩ + +theorem faceBoundary_vertex_injective (S : Finset FaceIndex) : + Function.Injective (fun g : FaceBoundary S => g.val.1) := by + intro ⟨⟨v,k⟩,hk⟩ ⟨⟨u,l⟩,hl⟩ he + dsimp at he + subst u + have := faceBoundary_germ_unique S v k l hk hl + subst l + rfl + +theorem faceBoundaryNext_injective (S : Finset FaceIndex) : + Function.Injective (faceBoundaryNext S) := by + intro g h he + apply faceBoundary_vertex_injective S + have hval := congrArg Subtype.val he + have hv := congrArg (fun d : Germ => neighbor d.1 d.2) hval + simpa only [faceBoundaryNext,advance,neighbor_neighbor] using hv + +noncomputable def faceBoundaryWord (S : Finset FaceIndex) (g : FaceBoundary S) : ℕ → List Bool + | 0 => [] + | n+1 => faceBoundaryTurn S g.val :: faceBoundaryWord S (faceBoundaryNext S g) n + +theorem faceBoundaryWord_length (S : Finset FaceIndex) (g : FaceBoundary S) (n : ℕ) : + (faceBoundaryWord S g n).length = n := by + induction n generalizing g with + | zero => rfl + | succ n ih => simp [faceBoundaryWord,ih] + +theorem faceBoundaryWord_terminal (S : Finset FaceIndex) (g : FaceBoundary S) (n : ℕ) : + terminalGerm g.val (faceBoundaryWord S g n) = ((faceBoundaryNext S)^[n] g).val := by + induction n generalizing g with + | zero => rfl + | succ n ih => + simp only [faceBoundaryWord,terminalGerm,Function.iterate_succ_apply] + exact ih (faceBoundaryNext S g) + +theorem faceBoundaryWord_traced (S : Finset FaceIndex) (g : FaceBoundary S) (n : ℕ) : + traced g.val (faceBoundaryWord S g n) = + List.ofFn (fun i : Fin n => ((faceBoundaryNext S)^[i.val] g).val.1) := by + induction n generalizing g with + | zero => simp [faceBoundaryWord,traced] + | succ n ih => + simp only [faceBoundaryWord,traced,List.ofFn_succ,Fin.val_zero,Function.iterate_zero, + id_eq,Fin.val_succ,Function.iterate_succ_apply] + congr 1 + exact ih (faceBoundaryNext S g) + +theorem faceBoundary_closed_word (S : Finset FaceIndex) (g : FaceBoundary S) : + ∃ n : ℕ, 0 < n ∧ (traced g.val (faceBoundaryWord S g n)).Nodup ∧ + terminalGerm g.val (faceBoundaryWord S g n) = g.val := by + let n := Function.minimalPeriod (faceBoundaryNext S) g + refine ⟨n,Function.minimalPeriod_pos_of_mem_periodicPts + ((faceBoundaryNext_injective S).mem_periodicPts g),?_,?_⟩ + · rw [faceBoundaryWord_traced,List.nodup_ofFn] + intro i j he + apply Fin.ext + apply Function.iterate_injOn_Iio_minimalPeriod i.isLt j.isLt + exact faceBoundary_vertex_injective S he + · rw [faceBoundaryWord_terminal,Function.iterate_minimalPeriod] + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Incidence.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Incidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f1dc5224727126bd72f135cd3dc76620509c36c --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Incidence.lean @@ -0,0 +1,375 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.PotentialSupport +import OAI.Combinatorics.HoneycombCorridor.EulerRank + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def extendOn {α : Type*} [DecidableEq α] (S : Finset α) (f : S → ℚ) : α →₀ ℚ := + Finsupp.onFinset S (fun a => if ha : a ∈ S then f ⟨a,ha⟩ else 0) + (by intro a h; by_contra ha; simp [ha] at h) + +@[simp] theorem extendOn_apply_mem {α : Type*} [DecidableEq α] + (S : Finset α) (f : S → ℚ) (a : S) : extendOn S f a = f a := by + simp [extendOn] + +@[simp] theorem extendOn_apply_not_mem {α : Type*} [DecidableEq α] + (S : Finset α) (f : S → ℚ) (a : α) (ha : a ∉ S) : extendOn S f a = 0 := by + simp [extendOn,ha] + +theorem extendOn_support {α : Type*} [DecidableEq α] + (S : Finset α) (f : S → ℚ) : (extendOn S f).support ⊆ S := by + intro a ha + by_contra h + exact (Finsupp.mem_support_iff.mp ha) (extendOn_apply_not_mem S f a h) + +theorem extendOn_injective {α : Type*} [DecidableEq α] (S : Finset α) : + Function.Injective (extendOn S) := by + intro f g h + funext a + have he := congrArg (fun t : α →₀ ℚ => t a) h + simpa using he + +theorem extendOn_restrict {α : Type*} [DecidableEq α] (S : Finset α) + (f : α →₀ ℚ) (h : f.support ⊆ S) : extendOn S (fun a => f a) = f := by + ext a + by_cases ha : a ∈ S + · exact extendOn_apply_mem S (fun a => f a) ⟨a,ha⟩ + · rw [extendOn_apply_not_mem S _ a ha] + by_contra hf + exact ha (h (Finsupp.mem_support_iff.mpr (Ne.symm hf))) + +noncomputable def rationalBoundary : (EdgeIndex →₀ ℚ) →+ (Vertex →₀ ℚ) := + Finsupp.liftAddHom fun e => Finsupp.singleAddHom (upEnd e) - Finsupp.singleAddHom (downEnd e) + +@[simp] theorem rationalBoundary_single (e : EdgeIndex) (a : ℚ) : + rationalBoundary (Finsupp.single e a) = + Finsupp.single (upEnd e) a - Finsupp.single (downEnd e) a := by + simp [rationalBoundary] + +theorem rationalBoundary_up (q : EdgeIndex →₀ ℚ) (i j : ℤ) : + rationalBoundary q (.up i j) = q ((i,j),0) + q ((i,j),1) + q ((i,j),2) := by + classical + induction q using Finsupp.induction_linear with + | zero => simp + | add q r hq hr => simp only [map_add,Finsupp.add_apply,hq,hr]; ring + | single e a => + rcases e with ⟨⟨x,y⟩,k⟩ + fin_cases k <;> + simp [rationalBoundary_single,upEnd,downEnd,neighbor,Finsupp.single_apply,eq_comm] + +theorem rationalBoundary_down (q : EdgeIndex →₀ ℚ) (i j : ℤ) : + rationalBoundary q (.down i j) = + -(q ((i,j+1),0) + q ((i,j),1) + q ((i+1,j),2)) := by + classical + induction q using Finsupp.induction_linear with + | zero => simp + | add q r hq hr => simp only [map_add,Finsupp.add_apply,hq,hr]; ring + | single e a => + rcases e with ⟨⟨x,y⟩,k⟩ + have hy : j = y - 1 ↔ y = j + 1 := by omega + have hx : i = x - 1 ↔ x = i + 1 := by omega + fin_cases k <;> + simp [rationalBoundary_single,upEnd,downEnd,neighbor,Finsupp.single_apply,eq_comm,hy,hx] + +theorem rationalBoundary_apply (q : EdgeIndex →₀ ℚ) (v : Vertex) : + rationalBoundary q v = ∑ k : Fin 3, directedCurrent q (v,k) := by + cases v <;> simp [rationalBoundary_up,rationalBoundary_down,Fin.sum_univ_succ, + directedCurrent,dartSign,edgeOf] <;> ring + +theorem rationalBoundary_eq_zero (q : EdgeIndex →₀ ℚ) : + rationalBoundary q = 0 ↔ ConservedCurrent q := by + simp only [ConservedCurrent,← rationalBoundary_apply,DFunLike.ext_iff,Finsupp.zero_apply] + +noncomputable def incidenceMatrix (S : Finset FaceIndex) : + Matrix (cellVertices S) (cellEdges S) ℚ := + fun v e => (if v.1 = upEnd e then 1 else 0) - (if v.1 = downEnd e then 1 else 0) + +theorem cell_upEnd (S : Finset FaceIndex) (e : cellEdges S) : upEnd e ∈ cellVertices S := by + apply edge_mem_vertex S (canonicalDart e) + have h : edgeOf (canonicalDart e) = e := by + rcases e with ⟨⟨⟨i,j⟩,k⟩,he⟩ + rfl + rw [h] + exact e.property + +theorem cell_downEnd (S : Finset FaceIndex) (e : cellEdges S) : downEnd e ∈ cellVertices S := by + apply edge_mem_neighbor S (canonicalDart e) + have h : edgeOf (canonicalDart e) = e := by + rcases e with ⟨⟨⟨i,j⟩,k⟩,he⟩ + rfl + rw [h] + exact e.property + +theorem transpose_incidence_apply (S : Finset FaceIndex) (f : cellVertices S → ℚ) + (e : cellEdges S) : + (incidenceMatrix S).transpose.mulVec f e = + f ⟨upEnd e,cell_upEnd S e⟩ - f ⟨downEnd e,cell_downEnd S e⟩ := by + classical + simp only [Matrix.mulVec, dotProduct, Matrix.transpose_apply, incidenceMatrix, sub_mul, + ite_mul, one_mul, zero_mul, Finset.sum_sub_distrib] + congr 1 + · rw [Finset.sum_eq_single ⟨upEnd e,cell_upEnd S e⟩] + · simp + · intro b _ hb + have h : b.1 ≠ upEnd e := fun h => hb (Subtype.ext h) + simp [h] + · simp + · rw [Finset.sum_eq_single ⟨downEnd e,cell_downEnd S e⟩] + · simp + · intro b _ hb + have h : b.1 ≠ downEnd e := fun h => hb (Subtype.ext h) + simp [h] + · simp + +@[simp] theorem extendOn_add {α : Type*} [DecidableEq α] (S : Finset α) + (f g : S → ℚ) : extendOn S (f + g) = extendOn S f + extendOn S g := by + ext a + by_cases ha : a ∈ S <;> simp [extendOn,ha] + +@[simp] theorem extendOn_smul {α : Type*} [DecidableEq α] (S : Finset α) + (c : ℚ) (f : S → ℚ) : extendOn S (c • f) = c • extendOn S f := by + ext a + by_cases ha : a ∈ S <;> simp [extendOn,ha] + +theorem extendOn_eq_sum {α : Type*} [DecidableEq α] (S : Finset α) (f : S → ℚ) : + extendOn S f = ∑ a : S, Finsupp.single a.1 (f a) := by + ext a + by_cases ha : a ∈ S + · change extendOn S f (⟨a,ha⟩ : S) = _ + rw [extendOn_apply_mem,Finsupp.finsetSum_apply,Finset.sum_eq_single (⟨a,ha⟩ : S)] + · simp + · intro b _ hb + have h : b.1 ≠ a := fun h => hb (Subtype.ext h) + simp [h] + · simp + · rw [extendOn_apply_not_mem S f a ha,Finsupp.finsetSum_apply] + symm + apply Finset.sum_eq_zero + intro b _ + have hb : b.1 ≠ a := fun h => ha (h ▸ b.property) + simp [hb] + +theorem incidence_apply (S : Finset FaceIndex) (q : cellEdges S → ℚ) + (v : cellVertices S) : + (incidenceMatrix S).mulVec q v = rationalBoundary (extendOn (cellEdges S) q) v := by + rw [extendOn_eq_sum,map_sum,Finsupp.finsetSum_apply] + simp only [Matrix.mulVec,dotProduct,incidenceMatrix,rationalBoundary_single, + Finsupp.sub_apply,Finsupp.single_apply] + apply Finset.sum_congr rfl + intro e _ + simp only [sub_mul,ite_mul,one_mul,zero_mul,eq_comm] + +theorem rationalBoundary_support_cells (S : Finset FaceIndex) (q : EdgeIndex →₀ ℚ) + (hS : q.support ⊆ cellEdges S) : (rationalBoundary q).support ⊆ cellVertices S := by + intro v hv + by_contra hV + apply (Finsupp.mem_support_iff.mp hv) + rw [rationalBoundary_apply] + apply Finset.sum_eq_zero + intro k _ + have hz : q (edgeOf (v,k)) = 0 := by + by_contra he + exact hV (edge_mem_vertex S (v,k) (hS (Finsupp.mem_support_iff.mpr he))) + simp [directedCurrent,hz] + +theorem incidence_zero_iff (S : Finset FaceIndex) (q : cellEdges S → ℚ) : + (incidenceMatrix S).mulVec q = 0 ↔ ConservedCurrent (extendOn (cellEdges S) q) := by + rw [← rationalBoundary_eq_zero] + constructor + · intro h + ext v + by_cases hv : v ∈ cellVertices S + · have he := congrFun h ⟨v,hv⟩ + simpa only [incidence_apply,Pi.zero_apply,Finsupp.zero_apply] using he + · change rationalBoundary _ v = 0 + by_contra he + exact hv (rationalBoundary_support_cells S _ (extendOn_support _ _) + (Finsupp.mem_support_iff.mpr he)) + · intro h + funext v + rw [incidence_apply,h] + rfl + +theorem gradient_zero_off_cells (S : Finset FaceIndex) (r : FaceIndex →₀ ℚ) + (hr : r.support ⊆ S) (e : EdgeIndex) (he : e ∉ cellEdges S) : + faceGradient r e = 0 := by + rw [mem_cellEdges,not_or] at he + have hz (a : FaceIndex) (ha : a ∉ S) : r a = 0 := by + by_contra h + exact ha (hr (Finsupp.mem_support_iff.mpr h)) + simp [faceGradient,hz _ he.1,hz _ he.2] + +noncomputable def cellFaceBoundary (S : Finset FaceIndex) : + (S → ℚ) →ₗ[ℚ] (cellEdges S → ℚ) where + toFun f e := faceGradient (extendOn S f) e + map_add' f g := by + funext e + simp [extendOn_add,faceGradient] + ring + map_smul' c f := by + funext e + simp [extendOn_smul,faceGradient] + ring + +theorem extend_faceBoundary (S : Finset FaceIndex) (f : S → ℚ) : + (extendOn (cellEdges S) (cellFaceBoundary S f) : EdgeIndex → ℚ) = + faceGradient (extendOn S f) := by + funext e + by_cases he : e ∈ cellEdges S + · exact extendOn_apply_mem _ _ ⟨e,he⟩ + · rw [extendOn_apply_not_mem _ _ _ he, + gradient_zero_off_cells S _ (extendOn_support _ _) e he] + +theorem cellFaceBoundary_injective (S : Finset FaceIndex) : + Function.Injective (cellFaceBoundary S) := by + intro f g h + apply extendOn_injective S + apply finite_gradient_injective + rw [← extend_faceBoundary,← extend_faceBoundary,h] + +theorem cellFaceBoundary_range (g : Germ) (w : List Bool) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) (hpne : p ≠ 0) : + (cellFaceBoundary p.support).range = (incidenceMatrix p.support).mulVecLin.ker := by + ext q + change (∃ f,cellFaceBoundary p.support f = q) ↔ (incidenceMatrix p.support).mulVec q = 0 + rw [incidence_zero_iff] + constructor + · rintro ⟨f,rfl⟩ + rw [extend_faceBoundary] + exact gradient_conserved _ + · intro hq + obtain ⟨r,hr⟩ := conserved_finite_potential _ hq + have hS : r.support ⊆ p.support := by + apply potential_supported_on_cycle_cells g w hN hc p hp hpne r + intro e he + rw [hr] + exact extendOn_apply_not_mem _ _ _ he + refine ⟨fun a => r a,?_⟩ + funext e + change faceGradient (extendOn p.support (fun a => r a)) e = q e + rw [extendOn_restrict _ r hS,hr] + exact extendOn_apply_mem _ _ e + +theorem represented_nonzero_edge_mem (S : Finset FaceIndex) (p : FaceIndex →₀ ℤ) + (hS : p.support ⊆ S) (q : EdgeIndex →₀ ℤ) (hp : RepresentsFlow p q) + (g : Germ) (hg : orientedFlow q g ≠ 0) : edgeOf g ∈ cellEdges S := by + rw [edge_mem_around] + have h := hp g + by_contra hn + simp only [not_or] at hn + have hz (a : FaceIndex) (ha : a ∉ S) : p a = 0 := by + by_contra h + exact ha (hS (Finsupp.mem_support_iff.mpr h)) + rw [hz _ hn.1,hz _ hn.2,sub_self] at h + exact hg h + +theorem contour_outgoing_nonzero (q : EdgeIndex →₀ ℤ) (g : Germ) (b : Bool) + (h : LocalContour q g b) : orientedFlow q (g.1,outgoingSlot g b) ≠ 0 := by + have hk : outgoingSlot g b ≠ g.2 := by + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> simp [outgoingSlot] + rw [h (outgoingSlot g b)] + simp [hk] + +theorem contour_step_mem (p : FaceIndex →₀ ℤ) (q : EdgeIndex →₀ ℤ) + (hp : RepresentsFlow p q) (g : Germ) (b : Bool) (h : LocalContour q g b) : + edgeOf (g.1,outgoingSlot g b) ∈ cellEdges p.support := by + exact represented_nonzero_edge_mem _ p (Finset.Subset.refl _) q hp _ + (contour_outgoing_nonzero q g b h) + +theorem contour_flat_trace (p : FaceIndex →₀ ℤ) (q : EdgeIndex →₀ ℤ) + (hp : RepresentsFlow p q) (f : Vertex → ℚ) + (hf : ∀ e ∈ cellEdges p.support, f (upEnd e) = f (downEnd e)) + (g : Germ) (w : List Bool) (hw : WordContour q g w) : + ∀ v ∈ traced g w, v ∈ cellVertices p.support ∧ f v = f g.1 := by + induction w generalizing g with + | nil => simp [traced] + | cons b w ih => + have hE := contour_step_mem p q hp g b hw.1 + have hV := edge_mem_vertex _ _ hE + have hs : f (advance g b).1 = f g.1 := + flat_along_dart _ f hf (g.1,outgoingSlot g b) hE + simp only [traced,List.mem_cons] + intro v hv + rcases hv with rfl | hv + · exact ⟨hV,rfl⟩ + · obtain ⟨hv',hf'⟩ := ih (advance g b) hw.2 v hv + exact ⟨hv',hf'.trans hs⟩ + +theorem cycle_vertices_nonempty (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) : + g.1 ∈ cellVertices p.support := by + obtain ⟨b,w,rfl⟩ := List.exists_cons_of_ne_nil hne + have h := (simple_closed_word_contour g (b::w) hN hc).1 + exact edge_mem_vertex _ (g.1,outgoingSlot g b) (contour_step_mem p _ hp g b h) + +theorem transpose_incidence_kernel (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) : + (incidenceMatrix p.support).transpose.mulVecLin.ker = + Submodule.span ℚ {(1 : cellVertices p.support → ℚ)} := by + have hg : g.1 ∈ cellVertices p.support := cycle_vertices_nonempty g w hne hN hc p hp + ext f + change (incidenceMatrix p.support).transpose.mulVec f = 0 ↔ _ + rw [Submodule.mem_span_singleton] + constructor + · intro h + let fhat := extendOn (cellVertices p.support) f + have hflat : ∀ e ∈ cellEdges p.support, fhat (upEnd e) = fhat (downEnd e) := by + intro e he + have heq := congrFun h ⟨e,he⟩ + rw [transpose_incidence_apply] at heq + have h1 := cell_upEnd p.support (⟨e,he⟩ : cellEdges p.support) + have h2 := cell_downEnd p.support (⟨e,he⟩ : cellEdges p.support) + simpa only [fhat,extendOn,Finsupp.onFinset_apply,dite_eq_left h1,dite_eq_left h2] using + sub_eq_zero.mp heq + have htrace := contour_flat_trace p (wordFlow g w) hp fhat hflat g w + (simple_closed_word_contour g w hN hc) + let c : ℚ := fhat g.1 + let diff : Vertex →₀ ℚ := extendOn (cellVertices p.support) (fun a => f a - c) + have hdiff (a : cellVertices p.support) : diff a = f a - c := + extendOn_apply_mem _ _ a + have hd : diff = 0 := by + apply cell_flat_zero_boundary g w hc p hp diff (extendOn_support _ _) + · intro e he + have h1 := cell_upEnd p.support (⟨e,he⟩ : cellEdges p.support) + have h2 := cell_downEnd p.support (⟨e,he⟩ : cellEdges p.support) + have he' := congrArg (fun x : ℚ => x-c) (hflat e he) + simpa only [diff,fhat,extendOn,Finsupp.onFinset_apply,dite_eq_left h1,dite_eq_left h2] using he' + · intro v hv + obtain ⟨hv',he⟩ := htrace v hv + change fhat v = c at he + have he' : f ⟨v,hv'⟩ = c := by + simpa only [fhat,extendOn,Finsupp.onFinset_apply,dite_eq_left hv'] using he + simp only [diff,extendOn,Finsupp.onFinset_apply,dite_eq_left hv',he',sub_self] + refine ⟨c,?_⟩ + funext a + have he := congrArg (fun z : Vertex →₀ ℚ => z a) hd + simp only [diff,extendOn,Finsupp.onFinset_apply,dite_eq_left a.property,Finsupp.zero_apply] at he + simpa only [Pi.smul_apply,Pi.one_apply,smul_eq_mul,mul_one] using (sub_eq_zero.mp he).symm + · rintro ⟨c,rfl⟩ + funext e + rw [transpose_incidence_apply] + simp + +theorem simple_cycle_cell_euler (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) (hpne : p ≠ 0) : + ((cellVertices p.support).card : ℤ) - (cellEdges p.support).card + p.support.card = 1 := by + have : Nonempty (cellVertices p.support) := + ⟨⟨g.1,cycle_vertices_nonempty g w hne hN hc p hp⟩⟩ + simpa using cell_euler_of_exact (incidenceMatrix p.support) (cellFaceBoundary p.support) + (cellFaceBoundary_injective _) (cellFaceBoundary_range g w hN hc p hp hpne) + (transpose_incidence_kernel g w hne hN hc p hp) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/IntegerPotential.lean b/lean/OAI/Combinatorics/HoneycombCorridor/IntegerPotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..f80ab5118e9dff5650b248de43096fdf9ed1b535 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/IntegerPotential.lean @@ -0,0 +1,189 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +abbrev FaceIndex := ℤ × ℤ + +noncomputable def facePrefix (f : FaceIndex →₀ ℤ) (i j : ℤ) : ℤ := + ∑ a ∈ f.support, if a.2 = j ∧ a.1 ≤ i then f a else 0 + +theorem facePrefix_difference (f : FaceIndex →₀ ℤ) (i j : ℤ) : + facePrefix f i j - facePrefix f (i - 1) j = f (i,j) := by + classical + unfold facePrefix + rw [← Finset.sum_sub_distrib] + have ht (a : FaceIndex) : + (if a.2 = j ∧ a.1 ≤ i then f a else 0) - + (if a.2 = j ∧ a.1 ≤ i - 1 then f a else 0) = + if a = (i,j) then f a else 0 := by + rcases a with ⟨x,y⟩ + by_cases hy : y = j + · subst y + by_cases hx : x = i + · subst x + simp + · have hh : x ≤ i ↔ x ≤ i - 1 := by omega + simp [hx,hh] + · simp [hy] + simp_rw [ht] + by_cases hm : (i,j) ∈ f.support + · simp [hm] + · have hz : f (i,j) = 0 := by simpa only [Finsupp.mem_support_iff, not_not] using hm + simp [hm, hz] + +def InFaceBox (M : ℕ) (a : FaceIndex) : Prop := + -(M : ℤ) ≤ a.1 ∧ a.1 ≤ M ∧ -(M : ℤ) ≤ a.2 ∧ a.2 ≤ M + +noncomputable def faceRadius (f : FaceIndex →₀ ℤ) : ℕ := + f.support.sup fun a => a.1.natAbs + a.2.natAbs + +theorem mem_support_in_box (f : FaceIndex →₀ ℤ) (a : FaceIndex) + (ha : a ∈ f.support) : InFaceBox (faceRadius f) a := by + have h : a.1.natAbs + a.2.natAbs ≤ faceRadius f := Finset.le_sup (f := fun a : FaceIndex => a.1.natAbs + a.2.natAbs) ha + have hx : a.1.natAbs ≤ faceRadius f := le_trans (Nat.le_add_right _ _) h + have hy : a.2.natAbs ≤ faceRadius f := le_trans (Nat.le_add_left _ _) h + have hxi : |a.1| ≤ (faceRadius f : ℤ) := by simpa only [Int.natCast_natAbs] using (Int.ofNat_le.mpr hx) + have hyi : |a.2| ≤ (faceRadius f : ℤ) := by simpa only [Int.natCast_natAbs] using (Int.ofNat_le.mpr hy) + exact ⟨(abs_le.mp hxi).1,(abs_le.mp hxi).2,(abs_le.mp hyi).1,(abs_le.mp hyi).2⟩ + +theorem facePrefix_left_zero (f : FaceIndex →₀ ℤ) (i j : ℤ) + (hi : i < -(faceRadius f : ℤ)) : facePrefix f i j = 0 := by + classical + apply Finset.sum_eq_zero + intro a ha + have hb := (mem_support_in_box f a ha).1 + have hx : ¬a.1 ≤ i := by omega + simp [hx] + +theorem facePrefix_row_zero (f : FaceIndex →₀ ℤ) (i j : ℤ) + (hj : j < -(faceRadius f : ℤ) ∨ (faceRadius f : ℤ) < j) : + facePrefix f i j = 0 := by + classical + apply Finset.sum_eq_zero + intro a ha + have hb := mem_support_in_box f a ha + have hy : a.2 ≠ j := by intro h; rcases hb with ⟨h1,h2,h3,h4⟩; omega + simp [hy] + +theorem int_function_constant {f : ℤ → ℤ} (hf : ∀ i, f (i + 1) = f i) + (i j : ℤ) : f i = f j := by + have hzero (n : ℤ) : f n = f 0 := by + induction n using Int.induction_on with + | zero => rfl + | succ n hn => exact (hf n).trans hn + | pred n hn => + calc f (-(n : ℤ) - 1) = f (-n) := by simpa using (hf (-(n : ℤ) - 1)).symm + _ = f 0 := hn + exact (hzero i).trans (hzero j).symm + +structure FiniteHoneycombFlow where + q0 : FaceIndex →₀ ℤ + q1 : FaceIndex →₀ ℤ + q2 : FaceIndex →₀ ℤ + up_conservation : ∀ i j, q0 (i,j) + q1 (i,j) + q2 (i,j) = 0 + down_conservation : ∀ i j, q0 (i,j+1) + q1 (i,j) + q2 (i+1,j) = 0 + +noncomputable def flowPotential (q : FiniteHoneycombFlow) (i j : ℤ) : ℤ := + facePrefix q.q0 i j + +theorem flow_difference (q : FiniteHoneycombFlow) (i j : ℤ) : + q.q0 (i,j+1) - q.q0 (i,j) = q.q2 (i,j) - q.q2 (i+1,j) := by + have hu := q.up_conservation i j + have hd := q.down_conservation i j + omega + +theorem flowPotential_vertical (q : FiniteHoneycombFlow) (i j : ℤ) : + flowPotential q i (j+1) - flowPotential q i j = -q.q2 (i+1,j) := by + let H : ℤ → ℤ := fun k => + flowPotential q k (j+1) - flowPotential q k j + q.q2 (k+1,j) + have hH : ∀ k, H (k+1) = H k := by + intro k + have h1 := facePrefix_difference q.q0 (k+1) (j+1) + have h2 := facePrefix_difference q.q0 (k+1) j + have hd := flow_difference q (k+1) j + simp only [add_sub_cancel_right] at h1 h2 + dsimp [H,flowPotential] + omega + let k : ℤ := -(faceRadius q.q0 : ℤ) - (faceRadius q.q2 : ℤ) - 2 + have hk0 : k < -(faceRadius q.q0 : ℤ) := by dsimp [k]; omega + have hk2 : q.q2 (k+1,j) = 0 := by + by_contra hne + have hm := Finsupp.mem_support_iff.mpr hne + have hb := (mem_support_in_box q.q2 (k+1,j) hm).1 + dsimp [k] at hb + omega + have hHz : H k = 0 := by + dsimp [H,flowPotential] + rw [facePrefix_left_zero _ _ _ hk0,facePrefix_left_zero _ _ _ hk0,hk2] + norm_num + have h := (int_function_constant hH i k).trans hHz + dsimp [H] at h + omega + +theorem flowPotential_right_zero (q : FiniteHoneycombFlow) (i j : ℤ) + (hi : (faceRadius q.q2 : ℤ) ≤ i) : flowPotential q i j = 0 := by + have hconstant : ∀ k, flowPotential q i (k+1) = flowPotential q i k := by + intro k + have hq : q.q2 (i+1,k) = 0 := by + by_contra hne + have hb := (mem_support_in_box q.q2 (i+1,k) + (Finsupp.mem_support_iff.mpr hne)).2.1 + omega + have h := flowPotential_vertical q i k + rw [hq] at h + omega + let k : ℤ := (faceRadius q.q0 : ℤ) + 1 + have hz : flowPotential q i k = 0 := + facePrefix_row_zero q.q0 i k (Or.inr (by dsimp [k]; omega)) + exact (int_function_constant hconstant j k).trans hz + +theorem flowPotential_finite_support (q : FiniteHoneycombFlow) : + Set.Finite {a : FaceIndex | flowPotential q a.1 a.2 ≠ 0} := by + let M : ℤ := (faceRadius q.q0 : ℤ) + faceRadius q.q2 + 1 + apply (Set.finite_Icc (-M, -M) (M, M)).subset + intro a ha + change flowPotential q a.1 a.2 ≠ 0 at ha + have hleft : -(faceRadius q.q0 : ℤ) ≤ a.1 := by + by_contra h + exact ha (facePrefix_left_zero q.q0 a.1 a.2 (by omega)) + have hright : a.1 < (faceRadius q.q2 : ℤ) := by + by_contra h + exact ha (flowPotential_right_zero q a.1 a.2 (by omega)) + have hbottom : -(faceRadius q.q0 : ℤ) ≤ a.2 := by + by_contra h + exact ha (facePrefix_row_zero q.q0 a.1 a.2 (Or.inl (by omega))) + have htop : a.2 ≤ (faceRadius q.q0 : ℤ) := by + by_contra h + exact ha (facePrefix_row_zero q.q0 a.1 a.2 (Or.inr (by omega))) + change (-M ≤ a.1 ∧ -M ≤ a.2) ∧ a.1 ≤ M ∧ a.2 ≤ M + dsimp [M] + omega + +noncomputable def finiteFlowPotential (q : FiniteHoneycombFlow) : FaceIndex →₀ ℤ := + Finsupp.ofSupportFinite (fun a => flowPotential q a.1 a.2) + (flowPotential_finite_support q) + +theorem finite_flow_is_face_boundary (q : FiniteHoneycombFlow) : + ∃ p : FaceIndex →₀ ℤ, ∀ i j, + q.q0 (i,j) = p (i,j) - p (i-1,j) ∧ + q.q1 (i,j) = p (i-1,j+1) - p (i,j) ∧ + q.q2 (i,j) = p (i-1,j) - p (i-1,j+1) := by + refine ⟨finiteFlowPotential q, ?_⟩ + intro i j + have h0 := facePrefix_difference q.q0 i j + have h2 := flowPotential_vertical q (i-1) j + have hu := q.up_conservation i j + simp only [sub_add_cancel] at h2 + simp only [finiteFlowPotential,Finsupp.ofSupportFinite_coe,flowPotential] + dsimp [flowPotential] at h2 + omega + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/LateralLength.lean b/lean/OAI/Combinatorics/HoneycombCorridor/LateralLength.lean new file mode 100644 index 0000000000000000000000000000000000000000..f192a339c83758afc7806aeb56a173e967a3337d --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/LateralLength.lean @@ -0,0 +1,143 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.SpatialDecay + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def eventVisitMass (D : Finset Vertex) (t : ℝ) (v : Vertex) : ℝ := by + classical + exact ∑ w ∈ sourceExits D bottomSource, + if reachesDistance t w ∧ v ∈ traced bottomSource w then criticalActivity^w.length else 0 + +theorem sourceExit_visit_sum (D : Finset Vertex) (w : List Bool) + (hw : w ∈ sourceExits D bottomSource) : + (∑ v ∈ D, if v ∈ traced bottomSource w then criticalActivity^w.length else 0) = + (w.length : ℝ)*criticalActivity^w.length := by + classical + have hs := stopped_traced D bottomSource w ((mem_sourceExits _ _ _).mp hw).1 + have hset : D.filter (fun v => v ∈ traced bottomSource w) = (traced bottomSource w).toFinset := by + ext v + simp only [Finset.mem_filter,List.mem_toFinset] + exact ⟨And.right,fun hv => ⟨hs.2 v hv,hv⟩⟩ + rw [← Finset.sum_filter,hset] + simp only [Finset.sum_const, nsmul_eq_mul, List.toFinset_card_of_nodup hs.1,traced_length] + +theorem lateralLengthMass_fubini (D : Finset Vertex) (t : ℝ) : + lateralLengthMass D t = ∑ v ∈ D, eventVisitMass D t v := by + classical + unfold eventVisitMass + rw [Finset.sum_comm] + unfold lateralLengthMass + apply Finset.sum_congr rfl + intro w hw + by_cases ht : reachesDistance t w + · simp only [ht,true_and,ite_true] + exact (sourceExit_visit_sum D w hw).symm + · simp only [ht,false_and,ite_false,Finset.sum_const_zero] + +theorem eventVisitMass_le_lateral (D : Finset Vertex) (t : ℝ) (v : Vertex) : + eventVisitMass D t v ≤ lateralMass D (max t |(position v).1|) := by + classical + unfold eventVisitMass lateralMass + apply Finset.sum_le_sum + intro w hw + by_cases he : reachesDistance t w ∧ v ∈ traced bottomSource w + · have hm : reachesDistance (max t |(position v).1|) w := by + rcases le_total t |(position v).1| with h | h + · exact ⟨v,he.2,by rw [max_eq_right h]⟩ + · rw [max_eq_left h] + exact he.1 + simp [he,hm] + · simp only [he,ite_false] + split_ifs <;> first | exact le_rfl | exact pow_nonneg criticalActivity_pos.le _ + +theorem eventVisitMass_exp (h : ℕ) (hh : 1 ≤ h) (D : Finset Vertex) + (hD : AdmissiblyConvex D) (hg : bottomSource.1 ∈ D) + (hstrip : ∀ v ∈ D, InStrip h v) (t : ℝ) (ht : 0 ≤ t) (v : Vertex) : + eventVisitMass D t v ≤ tailConstant * Real.exp (-tailRate*t/(2*(h+1))) * + Real.exp (-tailRate*|(position v).1|/(2*(h+1))) := by + have hm := lateralMass_exp h hh D hD hg hstrip (max t |(position v).1|) + (ht.trans (le_max_left _ _)) + have he : Real.exp (-tailRate*max t |(position v).1|/(h+1)) ≤ + Real.exp (-tailRate*t/(2*(h+1))) * + Real.exp (-tailRate*|(position v).1|/(2*(h+1))) := by + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have ha := le_max_left t |(position v).1| + have hb := le_max_right t |(position v).1| + have hH : (0 : ℝ) < (h : ℝ)+1 := by positivity + have hf : -tailRate*max t |(position v).1| ≤ + -tailRate*(t + |(position v).1|)/2 := by + nlinarith [mul_nonneg tailRate_pos.le (show 0 ≤ 2*max t |(position v).1| - t - |(position v).1| by linarith)] + have hd := div_le_div_of_nonneg_right hf hH.le + have heq : -tailRate*t/(2*(h+1)) + -tailRate*|(position v).1|/(2*(h+1)) = + (-tailRate*(t + |(position v).1|)/2)/(h+1) := by + field_simp + ring + rw [heq] + exact hd + calc + _ ≤ lateralMass D (max t |(position v).1|) := eventVisitMass_le_lateral D t v + _ ≤ tailConstant * Real.exp (-tailRate*max t |(position v).1|/(h+1)) := hm + _ ≤ _ := by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left he tailConstant_pos.le + +theorem lateralLengthMass_exp (h : ℕ) (hh : 1 ≤ h) (D : Finset Vertex) + (hD : AdmissiblyConvex D) (hg : bottomSource.1 ∈ D) + (hstrip : ∀ v ∈ D, InStrip h v) (t : ℝ) (ht : 0 ≤ t) : + lateralLengthMass D t ≤ tailConstant*spatialConstant*((h : ℝ)+1)^2 * + Real.exp (-(tailRate/2)*t/(h+1)) := by + rw [lateralLengthMass_fubini] + calc + _ ≤ ∑ v ∈ D, tailConstant * Real.exp (-tailRate*t/(2*(h+1))) * + Real.exp (-tailRate*|(position v).1|/(2*(h+1))) := + Finset.sum_le_sum (fun v _ => eventVisitMass_exp h hh D hD hg hstrip t ht v) + _ = tailConstant * Real.exp (-tailRate*t/(2*(h+1))) * + ∑ v ∈ D, Real.exp (-tailRate*|(position v).1|/(2*(h+1))) := by rw [Finset.mul_sum] + _ ≤ tailConstant * Real.exp (-tailRate*t/(2*(h+1))) * + (spatialConstant*((h : ℝ)+1)^2) := + mul_le_mul_of_nonneg_left (spatial_sum_exp_bound h D hstrip) + (mul_nonneg tailConstant_pos.le (Real.exp_pos _).le) + _ = _ := by + have he : -tailRate*t/(2*(h+1)) = -(tailRate/2)*t/(h+1) := by + field_simp + rw [he] + ring + + + +theorem finite_lateral_tail : FiniteLateralTail := by + let C := tailConstant*(1+spatialConstant) + have hCp : 0 < C := mul_pos tailConstant_pos (by linarith [spatialConstant_pos]) + have hC : tailConstant ≤ C := by + dsimp [C] + nlinarith [mul_nonneg tailConstant_pos.le spatialConstant_pos.le] + have hC' : tailConstant*spatialConstant ≤ C := by + dsimp [C] + linarith [tailConstant_pos] + refine ⟨C,tailRate/2,hCp,div_pos tailRate_pos (by norm_num),?_⟩ + intro h D hh hD hg hstrip t ht + have hH : (0 : ℝ) < (h : ℝ)+1 := by positivity + constructor + · have he : Real.exp (-tailRate*t/(h+1)) ≤ Real.exp (-(tailRate/2)*t/(h+1)) := by + apply Real.exp_le_exp.mpr + apply div_le_div_of_nonneg_right _ hH.le + nlinarith [mul_nonneg tailRate_pos.le ht] + exact (lateralMass_exp h hh D hD hg hstrip t ht).trans + (mul_le_mul hC he (Real.exp_pos _).le hCp.le) + · apply (lateralLengthMass_exp h hh D hD hg hstrip t ht).trans + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + have hhh : ((h : ℝ)+1)^2 ≤ ((h : ℝ)+1)*(h+t+1) := by + nlinarith [mul_nonneg hH.le ht] + calc + _ ≤ C*((h : ℝ)+1)^2 := mul_le_mul_of_nonneg_right hC' (sq_nonneg _) + _ ≤ C*(((h : ℝ)+1)*(h+t+1)) := mul_le_mul_of_nonneg_left hhh hCp.le + _ = _ := by ring + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/LateralMass.lean b/lean/OAI/Combinatorics/HoneycombCorridor/LateralMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..af7263704fee3f695f910df6609e5c90f80d3d2c --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/LateralMass.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.StripDecay +import OAI.Combinatorics.HoneycombCorridor.Reflection + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def reachesRight (t : ℝ) (w : List Bool) : Prop := + ∃ v ∈ traced bottomSource w, t ≤ (position v).1 + +noncomputable def rightDistanceMass (D : Finset Vertex) (t : ℝ) : ℝ := by + classical + exact positiveWordMass ((sourceExits D bottomSource).filter (reachesRight t)) + +noncomputable def tailRate : ℝ := -Real.log rayContraction / 2 +noncomputable def tailConstant : ℝ := + 2 * (Real.cos (3*Real.pi/8))⁻¹ * Real.exp (-Real.log rayContraction) + +theorem tailRate_pos : 0 < tailRate := by + have h := Real.log_neg rayContraction_range.1 rayContraction_range.2 + exact div_pos (neg_pos.mpr h) (by norm_num) + +theorem tailConstant_pos : 0 < tailConstant := by + have hc : 0 < Real.cos (3*Real.pi/8) := by + apply Real.cos_pos_of_mem_Ioo + constructor <;> linarith [Real.pi_pos] + exact mul_pos (mul_pos (by norm_num) (inv_pos.mpr hc)) (Real.exp_pos _) + +theorem rightDistanceMass_mono (D : Finset Vertex) (s t : ℝ) (hst : s ≤ t) : + rightDistanceMass D t ≤ rightDistanceMass D s := by + classical + apply positiveWordMass_mono + intro w hw + obtain ⟨he,v,hv,ht⟩ := Finset.mem_filter.mp hw + exact Finset.mem_filter.mpr ⟨he,v,hv,hst.trans ht⟩ + +theorem rightDistanceMass_geometric (h : ℕ) (hh : 1 ≤ h) (D : Finset Vertex) + (hD : AdmissiblyConvex D) (hg : bottomSource.1 ∈ D) + (hstrip : ∀ v ∈ D, InStrip h v) (n : ℕ) : + rightDistanceMass D (2 * n * (h+1)) ≤ + (Real.cos (3*Real.pi/8))⁻¹ * rayContraction ^ n := by + classical + by_cases hn : n = 0 + · subst n + simp only [Nat.cast_zero,mul_zero,zero_mul,pow_zero,mul_one] + apply (positiveWordMass_mono (Finset.filter_subset _ _)).trans + exact boundary_source_weight_bound D bottomSource hD hg (bottomSource_outside_of_strip h D hstrip) + · have hn' : (1 : ℝ) ≤ n := by exact_mod_cast (show 1 ≤ n by omega) + apply le_trans (positiveWordMass_mono ?_) (rightIndexMass_geometric h hh D hD hg hstrip n) + intro w hw + obtain ⟨he,v,hv,ht⟩ := Finset.mem_filter.mp hw + have hvm := (stopped_traced D bottomSource w ((mem_sourceExits _ _ _).mp he).1).2 v hv + have hi := (strip_index_bounds h v (hstrip v hvm)).2 + have hi' : (boxIndex v 2 : ℝ) ≤ (boxIndex v 1 : ℝ) + h := by exact_mod_cast hi + have hh' : (0 : ℝ) ≤ h := Nat.cast_nonneg _ + have hbound : (n : ℝ)*h ≤ (boxIndex v 1 : ℝ) := by + rw [position_index] at ht + nlinarith + exact (mem_lost_upperCut D bottomSource 1 ((n : ℤ)*h) w).mpr + ⟨he,v,hv,by exact_mod_cast hbound⟩ + +theorem rightDistanceMass_exp (h : ℕ) (hh : 1 ≤ h) (D : Finset Vertex) + (hD : AdmissiblyConvex D) (hg : bottomSource.1 ∈ D) + (hstrip : ∀ v ∈ D, InStrip h v) (t : ℝ) (ht : 0 ≤ t) : + rightDistanceMass D t ≤ tailConstant / 2 * Real.exp (-tailRate*t/(h+1)) := by + let n : ℕ := ⌊t / (2 * (h+1 : ℝ))⌋₊ + have hH : (0 : ℝ) < (h : ℝ)+1 := by positivity + have hd : (0 : ℝ) < 2*((h : ℝ)+1) := by positivity + have hnlo : (n : ℝ) ≤ t/(2*(h+1)) := Nat.floor_le (div_nonneg ht hd.le) + have hnhi : t/(2*(h+1)) < (n : ℝ)+1 := Nat.lt_floor_add_one _ + have hthreshold : 2*(n : ℝ)*(h+1) ≤ t := by + have := (le_div_iff₀ hd).mp hnlo + nlinarith + have hgeo := (rightDistanceMass_mono D _ _ hthreshold).trans + (rightDistanceMass_geometric h hh D hD hg hstrip n) + have hlog := Real.log_neg rayContraction_range.1 rayContraction_range.2 + have he : (n : ℝ)*Real.log rayContraction ≤ + -Real.log rayContraction + -tailRate*t/(h+1) := by + have hm := mul_le_mul_of_nonpos_right (le_of_lt hnhi) hlog.le + have heq : -tailRate*t/(h+1) = + t/(2*(h+1))*Real.log rayContraction := by + dsimp [tailRate] + field_simp + rw [heq] + nlinarith [hm] + have hp : rayContraction ^ n ≤ + Real.exp (-Real.log rayContraction) * Real.exp (-tailRate*t/(h+1)) := by + rw [← Real.exp_add] + conv_lhs => rw [← Real.exp_log rayContraction_range.1,← Real.exp_nat_mul] + exact Real.exp_le_exp.mpr he + have hc : 0 ≤ (Real.cos (3*Real.pi/8))⁻¹ := by + apply inv_nonneg.mpr + apply Real.cos_nonneg_of_mem_Icc + constructor <;> linarith [Real.pi_pos] + calc + _ ≤ (Real.cos (3*Real.pi/8))⁻¹ * rayContraction ^ n := hgeo + _ ≤ (Real.cos (3*Real.pi/8))⁻¹ * + (Real.exp (-Real.log rayContraction) * Real.exp (-tailRate*t/(h+1))) := + mul_le_mul_of_nonneg_left hp hc + _ = _ := by dsimp [tailConstant]; ring + +@[simp] theorem reachesRight_mirror (t : ℝ) (w : List Bool) : + reachesRight t (mirrorWord w) ↔ ∃ v ∈ traced bottomSource w, t ≤ -(position v).1 := by + have hm := mirror_traced bottomSource w + rw [mirror_bottomSource] at hm + simp only [reachesRight,hm,List.mem_map] + constructor + · rintro ⟨v,⟨u,hu,rfl⟩,ht⟩ + exact ⟨u,hu,by simpa using ht⟩ + · rintro ⟨v,hv,ht⟩ + exact ⟨mirrorVertex v,⟨v,hv,rfl⟩,by simpa using ht⟩ + +theorem lateralMass_le_sides (D : Finset Vertex) (t : ℝ) : + lateralMass D t ≤ rightDistanceMass D t + rightDistanceMass (mirrorDomain D) t := by + classical + simp only [rightDistanceMass,positiveWordMass,Finset.sum_filter,mirror_sourceExits_eq] + rw [Finset.sum_image (fun a _ b _ hab => mirrorWord_injective hab),← Finset.sum_add_distrib] + unfold lateralMass + apply Finset.sum_le_sum + intro w hw + simp only [mirrorWord_length] + by_cases hr : reachesRight t w + · simp only [hr,ite_true] + split_ifs <;> nlinarith [pow_nonneg criticalActivity_pos.le w.length] + · by_cases hl : reachesRight t (mirrorWord w) + · simp only [hr,hl,ite_false,ite_true,zero_add] + split_ifs <;> first | exact le_rfl | exact pow_nonneg criticalActivity_pos.le _ + · have hnone : ¬ reachesDistance t w := by + rintro ⟨v,hv,hv'⟩ + have hab := le_abs.mp hv' + rcases hab with h | h + · exact hr ⟨v,hv,h⟩ + · exact hl ((reachesRight_mirror t w).mpr ⟨v,hv,h⟩) + simp only [hr,hl,hnone,ite_false,zero_add,le_refl] + +theorem lateralMass_exp (h : ℕ) (hh : 1 ≤ h) (D : Finset Vertex) + (hD : AdmissiblyConvex D) (hg : bottomSource.1 ∈ D) + (hstrip : ∀ v ∈ D, InStrip h v) (t : ℝ) (ht : 0 ≤ t) : + lateralMass D t ≤ tailConstant * Real.exp (-tailRate*t/(h+1)) := by + have h1 := rightDistanceMass_exp h hh D hD hg hstrip t ht + have h2 := rightDistanceMass_exp h hh (mirrorDomain D) (mirrorDomain_convex D hD) + (by simpa only [mem_mirrorDomain,show mirrorVertex bottomSource.1 = bottomSource.1 from rfl] using hg) + (mirrorDomain_strip h D hstrip) t ht + have hs := lateralMass_le_sides D t + linarith + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/PolygonGeometry.lean b/lean/OAI/Combinatorics/HoneycombCorridor/PolygonGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..3443ab7cdface5bc762823cc47ffb259a306a9bd --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/PolygonGeometry.lean @@ -0,0 +1,287 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Polygons + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def toRatFinsupp {α : Type*} (p : α →₀ ℤ) : α →₀ ℚ := + p.mapRange (fun x : ℤ => (x : ℚ)) (by norm_num) + +@[simp] theorem toRatFinsupp_apply {α : Type*} (p : α →₀ ℤ) (a : α) : + toRatFinsupp p a = (p a : ℚ) := rfl + +@[simp] theorem toRatFinsupp_support {α : Type*} (p : α →₀ ℤ) : + (toRatFinsupp p).support = p.support := by + ext a + simp [Finsupp.mem_support_iff] + +theorem RepresentsFlow.rational {p : FaceIndex →₀ ℤ} {q : EdgeIndex →₀ ℤ} + (hp : RepresentsFlow p q) : faceGradient (toRatFinsupp p) = toRatFinsupp q := by + funext e + have h := hp (canonicalDart e) + rcases e with ⟨⟨i,j⟩,k⟩ + simp only [canonicalDart,upEnd,orientedFlow_up] at h + simp only [faceGradient,toRatFinsupp_apply] + exact_mod_cast h.symm + +theorem cycle_potential_support_subset (g : Germ) (w : List Bool) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (p r : FaceIndex →₀ ℤ) (s : EdgeIndex →₀ ℤ) + (hp : RepresentsFlow p (wordFlow g w)) (hr : RepresentsFlow r s) + (hs : s.support ⊆ (wordFlow g w).support) : r.support ⊆ p.support := by + have hq : ConservedCurrent (toRatFinsupp s) := by + rw [← hr.rational] + exact gradient_conserved _ + obtain ⟨c,hc'⟩ := simple_cycle_current_scalar g w hN hc (toRatFinsupp s) hq (by + intro e he + have haz : s e = 0 := by + by_contra hz + have hm := hs (Finsupp.mem_support_iff.mpr hz) + exact (Finsupp.mem_support_iff.mp hm) he + simp [haz]) + have he : toRatFinsupp r = c • toRatFinsupp p := by + apply finite_gradient_injective + funext e + have hz := congrFun hp.rational e + have hy := congrFun hr.rational e + change faceGradient (toRatFinsupp r) e = _ + rw [hy,hc' e] + simp only [faceGradient,Finsupp.coe_smul,Pi.smul_apply,smul_eq_mul] + rw [← mul_sub] + exact congrArg (c * ·) hz.symm + intro a ha + rw [Finsupp.mem_support_iff] at ha ⊢ + intro hpz + have h := congrArg (fun t : FaceIndex →₀ ℚ => t a) he + simp [hpz] at h + exact ha h + +theorem cycle_potential_support_eq (g h : Germ) (w u : List Bool) + (hw : (traced g w).Nodup) (hc : terminalGerm g w = g) + (hu : (traced h u).Nodup) (hd : terminalGerm h u = h) + (p r : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) + (hr : RepresentsFlow r (wordFlow h u)) + (hs : (wordFlow g w).support = (wordFlow h u).support) : + p.support = r.support := by + apply Finset.Subset.antisymm + · exact cycle_potential_support_subset h u hu hd r p (wordFlow g w) hr hp hs.le + · exact cycle_potential_support_subset g w hw hc p r (wordFlow h u) hp hr hs.ge + +def edgeVertices (E : Finset EdgeIndex) : Finset Vertex := E.biUnion fun e => {upEnd e,downEnd e} + +@[simp] theorem mem_edgeVertices (E : Finset EdgeIndex) (v : Vertex) : + v ∈ edgeVertices E ↔ ∃ k : Fin 3, edgeOf (v,k) ∈ E := by + classical + constructor + · intro h + obtain ⟨e,he,hv⟩ := Finset.mem_biUnion.mp h + simp only [Finset.mem_insert,Finset.mem_singleton] at hv + rcases hv with rfl | rfl + · refine ⟨e.2,?_⟩ + change edgeOf (canonicalDart e) ∈ E + simpa using he + · exact ⟨e.2,by simpa using he⟩ + · rintro ⟨k,hk⟩ + apply Finset.mem_biUnion.mpr + refine ⟨edgeOf (v,k),hk,?_⟩ + simp only [Finset.mem_insert,Finset.mem_singleton] + exact (edgeOf_eq_iff v (edgeOf (v,k))).mp (by simp) + +theorem wordContour_has_edge (q : EdgeIndex →₀ ℤ) (g : Germ) (w : List Bool) + (hw : WordContour q g w) (v : Vertex) (hv : v ∈ traced g w) : + ∃ k : Fin 3, q (edgeOf (v,k)) ≠ 0 := by + induction w generalizing g with + | nil => simp [traced] at hv + | cons b w ih => + simp only [traced,List.mem_cons] at hv + rcases hv with rfl | hv + · exact ⟨outgoingSlot g b, fun hz => contour_outgoing_nonzero q g b hw.1 + ((orientedFlow_zero_iff q _).mpr hz)⟩ + · exact ih _ hw.2 hv + +theorem wordFlow_edgeVertices (g : Germ) (w : List Bool) + (hw : (traced g w).Nodup) (hc : terminalGerm g w = g) : + edgeVertices (wordFlow g w).support = (traced g w).toFinset := by + classical + ext v + simp only [mem_edgeVertices,Finsupp.mem_support_iff,List.mem_toFinset] + constructor + · rintro ⟨k,hk⟩ + by_contra hn + have h := turnVisit_eq_zero_of_not_mem g w v k hn + have hz : orientedFlow (wordFlow g w) (v,k) = 0 := by + rw [orientedFlow_wordFlow,hc,add_sub_cancel_right] + exact h + exact hk ((orientedFlow_zero_iff _ _).mp hz) + · exact wordContour_has_edge _ g w (simple_closed_word_contour g w hw hc) v + +namespace Polygon + +theorem vertices_traversal (P : Polygon) : P.vertices = (traced P.germ P.turns).toFinset := by + change edgeVertices P.val = _ + rw [← P.traversal.2.2.2] + exact wordFlow_edgeVertices _ _ P.traversal.2.1 P.traversal.2.2.1 + +theorem interiorFaces_of_traversal (P : Polygon) (g : Germ) (w : List Bool) + (hw : (traced g w).Nodup) (hc : terminalGerm g w = g) + (hE : (wordFlow g w).support = P.val) (p : FaceIndex →₀ ℤ) + (hp : RepresentsFlow p (wordFlow g w)) : P.interiorFaces = p.support := by + apply cycle_potential_support_eq P.germ g P.turns w P.traversal.2.1 + P.traversal.2.2.1 hw hc P.potential p P.potential_spec.1 hp + exact P.traversal.2.2.2.trans hE.symm + +@[simp] theorem mem_interior (P : Polygon) (v : Vertex) : + v ∈ P.interior ↔ v ∈ cellVertices P.interiorFaces ∧ v ∉ P.vertices := by + simp [interior] + +end Polygon + + +@[simp] theorem mem_inducedEdges (D : Finset Vertex) (e : EdgeIndex) : + e ∈ inducedEdges D ↔ upEnd e ∈ D ∧ downEnd e ∈ D := by + classical + constructor + · intro h + exact (Finset.mem_filter.mp h).2 + · intro h + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_image.mpr ⟨canonicalDart e,?_,edgeOf_canonical e⟩,h⟩ + exact Finset.mem_product.mpr ⟨h.1,Finset.mem_univ _⟩ + +@[simp] theorem mem_polygons (D : Finset Vertex) (P : Polygon) : + P ∈ polygons D ↔ P.vertices ⊆ D := by + classical + have hm : P ∈ polygons D ↔ P.val ⊆ inducedEdges D := by + simp [polygons] + rw [hm] + constructor + · intro h v hv + obtain ⟨e,he,hv⟩ := Finset.mem_biUnion.mp hv + have he' := (mem_inducedEdges D e).mp (h he) + simp only [Finset.mem_insert,Finset.mem_singleton] at hv + rcases hv with rfl | rfl + · exact he'.1 + · exact he'.2 + · intro h e he + apply (mem_inducedEdges D e).mpr + constructor + · exact h (Finset.mem_biUnion.mpr ⟨e,he,by simp⟩) + · exact h (Finset.mem_biUnion.mpr ⟨e,he,by simp⟩) + +noncomputable def vertexLevel (p : FaceIndex →₀ ℤ) (v : Vertex) : ℤ := + p (leftFace (v,0)) + +namespace Polygon + +theorem represents (P : Polygon) : RepresentsFlow P.potential (wordFlow P.germ P.turns) := + P.potential_spec.1 + +theorem off_boundary_zero (P : Polygon) (v : Vertex) (hv : v ∉ P.vertices) (k : Fin 3) : + orientedFlow (wordFlow P.germ P.turns) (v,k) = 0 := by + apply (orientedFlow_zero_iff _ _).mpr + by_contra hn + apply hv + change v ∈ edgeVertices P.val + apply (mem_edgeVertices _ _).mpr + exact ⟨k,by rw [← P.traversal.2.2.2]; exact Finsupp.mem_support_iff.mpr hn⟩ + +theorem off_boundary_faces (P : Polygon) (v : Vertex) (hv : v ∉ P.vertices) (k : Fin 3) : + P.potential (leftFace (v,k)) = vertexLevel P.potential v ∧ + P.potential (rightFace (v,k)) = vertexLevel P.potential v := by + have he (l : Fin 3) : P.potential (leftFace (v,l)) = P.potential (rightFace (v,l)) := by + have h := P.represents (v,l) + rw [P.off_boundary_zero v hv l] at h + omega + have hl := incident_faces_equal P.potential v he k 0 + exact ⟨hl,(he k).symm.trans hl⟩ + +theorem interior_iff_level (P : Polygon) (v : Vertex) : + v ∈ P.interior ↔ v ∉ P.vertices ∧ vertexLevel P.potential v ≠ 0 := by + rw [P.mem_interior,mem_cellVertices] + constructor + · rintro ⟨⟨k,hk⟩,hv⟩ + refine ⟨hv,?_⟩ + change leftFace (v,k) ∈ P.potential.support at hk + rw [Finsupp.mem_support_iff] at hk + rwa [(P.off_boundary_faces v hv k).1] at hk + · rintro ⟨hv,hl⟩ + exact ⟨⟨0,Finsupp.mem_support_iff.mpr hl⟩,hv⟩ + +theorem step_level (P : Polygon) (v : Vertex) (k : Fin 3) + (hv : v ∉ P.vertices) (hu : neighbor v k ∉ P.vertices) : + vertexLevel P.potential (neighbor v k) = vertexLevel P.potential v := by + rw [← (P.off_boundary_faces (neighbor v k) hu k).1] + change P.potential (leftFace (reverseGerm (v,k))) = _ + exact (P.off_boundary_faces v hv k).2 + +theorem interior_exit_on_boundary (P : Polygon) (v : Vertex) (k : Fin 3) + (hv : v ∈ P.interior) (hu : neighbor v k ∉ P.interior) : + neighbor v k ∈ P.vertices := by + by_contra hn + apply hu + rw [P.interior_iff_level] + have h := (P.interior_iff_level v).mp hv + exact ⟨hn,by rw [P.step_level v k h.1 hn]; exact h.2⟩ + +theorem trace_level (P : Polygon) (g : Germ) (w : List Bool) + (hdis : ∀ v ∈ traced g w, v ∉ P.vertices) + (ht : (terminalGerm g w).1 ∉ P.vertices) : + vertexLevel P.potential (terminalGerm g w).1 = vertexLevel P.potential g.1 := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + have hg : g.1 ∉ P.vertices := hdis _ (by simp [traced]) + have ha : (advance g b).1 ∉ P.vertices := by + cases w with + | nil => exact ht + | cons c w => exact hdis _ (by simp [traced]) + have htail : ∀ v ∈ traced (advance g b) w, v ∉ P.vertices := by + intro v hv + exact hdis v (List.mem_cons_of_mem _ hv) + exact (ih (advance g b) htail ht).trans (P.step_level g.1 (outgoingSlot g b) hg ha) + +theorem trace_left_potential (P : Polygon) (g : Germ) (w : List Bool) + (hdis : ∀ v ∈ traced g w, v ∉ P.vertices) : + P.potential (leftFace (terminalGerm g w)) = P.potential (leftFace g) := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + have hg : g.1 ∉ P.vertices := hdis _ (by simp [traced]) + have htail : ∀ v ∈ traced (advance g b) w, v ∉ P.vertices := by + intro v hv + exact hdis v (List.mem_cons_of_mem _ hv) + change P.potential (leftFace (terminalGerm (advance g b) w)) = _ + rw [ih (advance g b) htail] + change P.potential (rightFace (g.1,outgoingSlot g b)) = _ + rw [(P.off_boundary_faces g.1 hg (outgoingSlot g b)).2] + exact (P.off_boundary_faces g.1 hg g.2).1.symm + +theorem outside_level_zero (P : Polygon) (D : Finset Vertex) (hD : Filled D) + (hP : P ∈ polygons D) (v : Vertex) (hv : v ∉ D) : + vertexLevel P.potential v = 0 := by + by_contra hn + have hb : v ∉ P.vertices := fun h => hv ((mem_polygons D P).mp hP h) + have hi := (P.interior_iff_level v).mpr ⟨hb,hn⟩ + exact hv (hD P hP hi) + +theorem outside_port_potential (P : Polygon) (D : Finset Vertex) (hD : Filled D) + (hP : P ∈ polygons D) (g : Germ) (hg : (reverseGerm g).1 ∉ D) : + P.potential (leftFace g) = 0 := by + have hb : (reverseGerm g).1 ∉ P.vertices := + fun h => hg ((mem_polygons D P).mp hP h) + have he := (P.off_boundary_faces (reverseGerm g).1 hb g.2).2 + have hr : rightFace ((reverseGerm g).1,g.2) = leftFace g := by + change leftFace (reverseGerm (reverseGerm g)) = _ + rw [reverseGerm_reverseGerm] + rw [hr] at he + exact he.trans (P.outside_level_zero D hD hP _ hg) + +end Polygon +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/PolygonNesting.lean b/lean/OAI/Combinatorics/HoneycombCorridor/PolygonNesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..28111398e62a12327bd82e068693f96c274fe0c1 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/PolygonNesting.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Traversals + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor +namespace Polygon + +theorem boundary_zero_face (P : Polygon) (v : Vertex) (hv : v ∈ P.vertices) : + ∃ k : Fin 3, P.potential (leftFace (v,k)) = 0 := by + obtain ⟨k,w,hw⟩ := P.exists_rooted v hv + obtain ⟨b,u,rfl⟩ := List.exists_cons_of_ne_nil hw.1 + have hloc := (simple_closed_word_contour _ _ hw.2.1 hw.2.2.1).1 + by_contra hn + push Not at hn + have hzero (l : Fin 3) : orientedFlow (wordFlow P.germ P.turns) (v,l) = 0 := by + rw [P.represents (v,l),rightFace_prev] + have h1 := (P.potential_spec.2.2.2 (leftFace (v,l))).resolve_left (hn l) + have h2 := (P.potential_spec.2.2.2 (leftFace (v,l+2))).resolve_left (hn (l+2)) + rw [h1,h2,sub_self] + have hs : edgeOf (v,k) ∈ (wordFlow (v,k) (b :: u)).support := + (local_contour_support _ (v,k) b hloc k).mpr (Or.inl rfl) + rw [hw.2.2.2,← P.traversal.2.2.2,Finsupp.mem_support_iff] at hs + exact hs ((orientedFlow_zero_iff _ _).mp (hzero k)) + +theorem interiorFaces_subset (P Q : Polygon) (hQ : Q.vertices ⊆ P.interior) : + Q.interiorFaces ⊆ P.interiorFaces := by + have hedge (e : EdgeIndex) (he : e ∈ Q.val) : e ∈ cellEdges P.interiorFaces := by + have hvQ : upEnd e ∈ Q.vertices := Finset.mem_biUnion.mpr ⟨e,he,by simp⟩ + have hv := (P.interior_iff_level _).mp (hQ hvQ) + have hl : P.potential (leftFace (canonicalDart e)) ≠ 0 := by + rw [show canonicalDart e = (upEnd e,e.2) from rfl, + (P.off_boundary_faces _ hv.1 e.2).1] + exact hv.2 + exact (mem_cellEdges _ e).mpr (Or.inl (Finsupp.mem_support_iff.mpr hl)) + have h := potential_supported_on_cycle_cells P.germ P.turns + P.traversal.2.1 P.traversal.2.2.1 P.potential P.represents P.potential_spec.2.1 + (toRatFinsupp Q.potential) (by + intro e he + rw [Q.represents.rational,toRatFinsupp_apply] + have hz : wordFlow Q.germ Q.turns e = 0 := by + by_contra hn + exact he (hedge e (by rw [← Q.traversal.2.2.2]; exact Finsupp.mem_support_iff.mpr hn)) + simp [hz]) + simpa only [toRatFinsupp_support,interiorFaces] using h + +theorem interior_subset (P Q : Polygon) (hQ : Q.vertices ⊆ P.interior) : + Q.interior ⊆ P.interior := by + have hfaces := P.interiorFaces_subset Q hQ + intro v hv + have hq := (Q.interior_iff_level v).mp hv + have hall (k : Fin 3) : P.potential (leftFace (v,k)) ≠ 0 := by + apply Finsupp.mem_support_iff.mp + apply hfaces + apply Finsupp.mem_support_iff.mpr + rw [(Q.off_boundary_faces v hq.1 k).1] + exact hq.2 + apply (P.interior_iff_level v).mpr + constructor + · intro hb + obtain ⟨k,hk⟩ := P.boundary_zero_face v hb + exact hall k hk + · exact hall 0 + +theorem interior_filled (P : Polygon) : Filled P.interior := by + intro Q hQ + exact P.interior_subset Q ((mem_polygons _ _).mp hQ) + +theorem vertices_nonempty (P : Polygon) : P.vertices.Nonempty := by + rw [P.vertices_traversal] + obtain ⟨head,tail,hturns⟩ := List.exists_cons_of_ne_nil P.traversal.1 + exact ⟨P.germ.1,by simp [hturns,traced]⟩ + +theorem interior_card_lt (P : Polygon) (D : Finset Vertex) (hD : Filled D) + (hP : P ∈ polygons D) : P.interior.card < D.card := by + obtain ⟨v,hv⟩ := P.vertices_nonempty + apply Finset.card_lt_card + apply Finset.ssubset_iff_subset_ne.mpr + refine ⟨hD P hP,?_⟩ + intro he + have hvD := (mem_polygons D P).mp hP hv + rw [← he] at hvD + exact ((P.mem_interior v).mp hvD).2 hv + +end Polygon +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/PolygonSize.lean b/lean/OAI/Combinatorics/HoneycombCorridor/PolygonSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..458dfa13171421d07753180181ca16a37b2d8a1f --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/PolygonSize.lean @@ -0,0 +1,175 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Traversals + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def graphDegree (E : Finset EdgeIndex) (v : Vertex) : ℤ := + ∑ k : Fin 3, if edgeOf (v,k) ∈ E then 1 else 0 + +theorem graphDegree_incidence (E : Finset EdgeIndex) (v : Vertex) : + graphDegree E v = ∑ e ∈ E, + ((if v = upEnd e then 1 else 0) + (if v = downEnd e then 1 else 0) : ℤ) := by + classical + have hpair (e : EdgeIndex) : (∑ k : Fin 3, if edgeOf (v,k) = e then (1 : ℤ) else 0) = + (if v = upEnd e then 1 else 0) + (if v = downEnd e then 1 else 0) := by + rw [Finset.sum_eq_single e.2] + · simp only [edgeOf_eq_iff] + by_cases hu : v = upEnd e + · simp [hu,upEnd_ne_downEnd] + · by_cases hd : v = downEnd e + · simp [hd, Ne.symm (upEnd_ne_downEnd e)] + · simp [hu,hd] + · intro k _ hk + have hn : edgeOf (v,k) ≠ e := fun h => hk (by simpa using congrArg Prod.snd h) + simp [hn] + · simp + simp_rw [← hpair] + rw [Finset.sum_comm] + unfold graphDegree + apply Finset.sum_congr rfl + intro k _ + simp + +theorem graphDegree_sum (E : Finset EdgeIndex) : + ∑ v ∈ edgeVertices E, graphDegree E v = 2 * (E.card : ℤ) := by + classical + simp_rw [graphDegree_incidence] + rw [Finset.sum_comm] + have he (e : EdgeIndex) (hme : e ∈ E) : + (∑ v ∈ edgeVertices E, + ((if v = upEnd e then 1 else 0) + (if v = downEnd e then 1 else 0) : ℤ)) = 2 := by + have hu : upEnd e ∈ edgeVertices E := Finset.mem_biUnion.mpr ⟨e,hme,by simp⟩ + have hd : downEnd e ∈ edgeVertices E := Finset.mem_biUnion.mpr ⟨e,hme,by simp⟩ + rw [Finset.sum_add_distrib] + simp [hu,hd] + simp_rw [Finset.sum_congr rfl he] + simp [mul_comm] + +namespace Polygon + +theorem degree_two (P : Polygon) (v : Vertex) (hv : v ∈ P.vertices) : + graphDegree P.val v = 2 := by + classical + obtain ⟨k,w,hw⟩ := P.exists_rooted v hv + obtain ⟨b,u,rfl⟩ := List.exists_cons_of_ne_nil hw.1 + have hlocal := (simple_closed_word_contour _ _ hw.2.1 hw.2.2.1).1 + unfold graphDegree + rw [← hw.2.2.2] + simp_rw [local_contour_support _ (v,k) b hlocal] + have hne := outgoingSlot_ne (v,k) b + simp only [Fin.sum_univ_succ] + fin_cases k <;> cases b <;> norm_num [outgoingSlot] + +theorem length_eq_card_vertices (P : Polygon) : P.length = P.vertices.card := by + have h := graphDegree_sum P.val + change (∑ v ∈ P.vertices, graphDegree P.val v) = _ at h + have hsum : (∑ v ∈ P.vertices, graphDegree P.val v) = 2 * (P.vertices.card : ℤ) := by + rw [Finset.sum_congr rfl (fun v hv => P.degree_two v hv)] + simp [mul_comm] + rw [hsum] at h + unfold length + omega + +theorem Traverses.length {P : Polygon} {g : Germ} {w : List Bool} + (h : P.Traverses g w) : P.length = w.length := by + rw [P.length_eq_card_vertices,h.vertices,List.toFinset_card_of_nodup h.2.1,traced_length] + +theorem length_pos (P : Polygon) : 0 < P.length := by + rw [P.traverses_chosen.length] + exact List.length_pos_iff.mpr P.traversal.1 + +end Polygon + + +theorem sum_record_fibers {α β : Type*} [DecidableEq α] [DecidableEq β] + (s : Finset α) (t : α → Finset β) (F : α × β → ℂ) : + (∑ e ∈ s.biUnion (fun a => (t a).image (fun b => (a,b))), F e) = + ∑ a ∈ s, ∑ b ∈ t a, F (a,b) := by + rw [Finset.sum_biUnion] + · apply Finset.sum_congr rfl + intro a ha + rw [Finset.sum_image] + intro b hb c hc he + exact (Prod.mk.inj he).2 + · intro a ha b hb hab + apply Finset.disjoint_left.mpr + intro e he hf + obtain ⟨x,hx,hxe⟩ := Finset.mem_image.mp he + obtain ⟨y,hy,hye⟩ := Finset.mem_image.mp hf + exact hab ((Prod.mk.inj (hxe.trans hye.symm)).1) + +theorem excursions_fibers (D : Finset Vertex) : + excursions D = (boundaryGerms D).biUnion fun g => + ((leaves D g).filter fun w => (terminalGerm g w).1 ∉ D).image fun w => (g,w) := by + classical + ext e + simp only [mem_excursions,Finset.mem_biUnion,Finset.mem_image,Finset.mem_filter] + constructor + · intro h + exact ⟨e.1,(mem_boundaryGerms D e.1).mpr ⟨h.1,h.2.1⟩,e.2, + ⟨(mem_leaves_iff D e.1 e.2).mpr h.2.2.1,h.2.2.2⟩,rfl⟩ + · rintro ⟨g,hg,w,⟨hw,ht⟩,rfl⟩ + have h := (mem_boundaryGerms D g).mp hg + exact ⟨h.1,h.2,(mem_leaves_iff _ _ _).mp hw,ht⟩ + +theorem firstArrivals_fibers (D : Finset Vertex) (v : Vertex) : + firstArrivals D v = (boundaryGerms D).biUnion fun g => + ((leaves (D.erase v) g).filter fun w => (terminalGerm g w).1 = v).image fun w => (g,w) := by + classical + ext e + simp only [mem_firstArrivals,Finset.mem_biUnion,Finset.mem_image,Finset.mem_filter] + constructor + · intro h + exact ⟨e.1,h.1,e.2,⟨(mem_leaves_iff _ _ _).mpr h.2.1,h.2.2⟩,rfl⟩ + · rintro ⟨g,hg,w,⟨hw,ht⟩,rfl⟩ + exact ⟨hg,(mem_leaves_iff _ _ _).mp hw,ht⟩ + +theorem boundary_marked_eq_exits (D : Finset Vertex) (g : Germ) (v : Vertex) + (hD : Filled D) (hg : (reverseGerm g).1 ∉ D) : + markedLeaves D g v = + ∑ w ∈ (leaves D g).filter (fun w => (terminalGerm g w).1 ∉ D), + if v ∈ traced g w then wordWeight w else 0 := by + classical + have hz := (boundary_collision_cancellation D g hD hg).2 v + unfold markedLeaves + rw [Finset.sum_filter] + have he : (∑ w ∈ leaves D g, if v ∈ traced g w then wordWeight w else 0) = + (∑ w ∈ leaves D g, if (terminalGerm g w).1 ∉ D then + (if v ∈ traced g w then wordWeight w else 0) else 0) + + (∑ w ∈ leaves D g, if (terminalGerm g w).1 ∈ D ∧ v ∈ traced g w + then wordWeight w else 0) := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro w hw + by_cases ht : (terminalGerm g w).1 ∈ D <;> + by_cases hv : v ∈ traced g w <;> simp [ht,hv] + rw [he,hz,add_zero] + +theorem visitSum_eq_firstArrivals (D : Finset Vertex) (v : Vertex) + (hD : Filled D) (hv : v ∈ D) : + visitSum D v = ∑ e ∈ firstArrivals D v, wordWeight e.2 := by + classical + unfold visitSum + rw [excursions_fibers,firstArrivals_fibers,sum_record_fibers,sum_record_fibers] + apply Finset.sum_congr rfl + intro g hg + rw [← boundary_marked_eq_exits D g v hD ((mem_boundaryGerms _ _).mp hg).2, + markedLeaves_eq_firstArrival D g v hv] + simp only [firstArrival,Finset.sum_filter] + +theorem rayExits_eq_visitSum (D : Finset Vertex) (v : Vertex) + (hD : Filled D) (hv : v ∈ D) : + (∑ e ∈ rayExits D v, wordWeight e.2) = visitSum D v := by + have h := prefix_ray_reversal D v hv + rw [← visitSum_eq_firstArrivals D v hD hv] at h + have hc := congrArg (starRingEnd ℂ) h + simpa only [visitSum_conj,Complex.conj_conj] using hc.symm +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Polygons.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Polygons.lean new file mode 100644 index 0000000000000000000000000000000000000000..e51b0c880c5865cbea2d3362a816ca47389c493e --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Polygons.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Incidence +import OAI.Combinatorics.HoneycombCorridor.Curvature + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def SimplePolygonTurning : Prop := ∀ (g : Germ) (w : List Bool), + w ≠ [] → (traced g w).Nodup → terminalGerm g w = g → + turnUnits w = 6 ∨ turnUnits w = -6 + +theorem simple_polygon_signed_turn (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (ε : ℤ) (hp : RepresentsFlow p (wordFlow g w)) + (hpne : p ≠ 0) (hε : ε = 1 ∨ ε = -1) + (hvals : ∀ a, p a = 0 ∨ p a = ε) : ε * turnUnits w = 6 := by + have hEuler := simple_cycle_cell_euler g w hne hN hc p hp hpne + have hw := simple_closed_word_contour g w hN hc + have hsub : (traced g w).toFinset ⊆ cellVertices p.support := by + intro v hv + exact (contour_flat_trace p (wordFlow g w) hp (fun _ => 0) + (by intros; rfl) g w hw v (List.mem_toFinset.mp hv)).1 + have hsum : (∑ v ∈ cellVertices p.support,cellCurvature p.support v) = ε * turnUnits w := by + calc + _ = ∑ v ∈ (traced g w).toFinset,cellCurvature p.support v := by + symm + apply Finset.sum_subset hsub + intro v hv hnot + exact nonboundary_cellCurvature g w hc p hp v hv + (by simpa only [List.mem_toFinset] using hnot) + _ = ((traced g w).map (cellCurvature p.support)).sum := List.sum_toFinset _ hN + _ = _ := contour_curvature_sum p ε hε hvals (wordFlow g w) hp g w hw + rw [sum_cellCurvature,hEuler,mul_one] at hsum + exact hsum.symm + +theorem simple_polygon_turning : SimplePolygonTurning := by + intro g w hne hN hc + obtain ⟨p,ε,hp,hpne,hε,hvals⟩ := simple_closed_word_indicator g w hne hN hc + have hsum := simple_polygon_signed_turn g w hne hN hc p ε hp hpne hε hvals + rcases hε with rfl | rfl + · exact Or.inl (by omega) + · exact Or.inr (by omega) + + +def IsPolygon (E : Finset EdgeIndex) : Prop := ∃ (g : Germ) (w : List Bool), + w ≠ [] ∧ (traced g w).Nodup ∧ terminalGerm g w = g ∧ (wordFlow g w).support = E + +abbrev Polygon := { E : Finset EdgeIndex // IsPolygon E } + +namespace Polygon +noncomputable def germ (P : Polygon) : Germ := P.property.choose +noncomputable def turns (P : Polygon) : List Bool := P.property.choose_spec.choose + +theorem traversal (P : Polygon) : + P.turns ≠ [] ∧ (traced P.germ P.turns).Nodup ∧ + terminalGerm P.germ P.turns = P.germ ∧ (wordFlow P.germ P.turns).support = P.val := + P.property.choose_spec.choose_spec + +theorem has_indicator (P : Polygon) : + ∃ (p : FaceIndex →₀ ℤ) (ε : ℤ), RepresentsFlow p (wordFlow P.germ P.turns) ∧ + p ≠ 0 ∧ (ε = 1 ∨ ε = -1) ∧ ∀ a, p a = 0 ∨ p a = ε := + simple_closed_word_indicator P.germ P.turns P.traversal.1 P.traversal.2.1 P.traversal.2.2.1 + +noncomputable def potential (P : Polygon) : FaceIndex →₀ ℤ := P.has_indicator.choose +noncomputable def orientation (P : Polygon) : ℤ := P.has_indicator.choose_spec.choose + +theorem potential_spec (P : Polygon) : + RepresentsFlow P.potential (wordFlow P.germ P.turns) ∧ P.potential ≠ 0 ∧ + (P.orientation = 1 ∨ P.orientation = -1) ∧ + ∀ a, P.potential a = 0 ∨ P.potential a = P.orientation := + P.has_indicator.choose_spec.choose_spec + +noncomputable def interiorFaces (P : Polygon) : Finset FaceIndex := P.potential.support + +def vertices (P : Polygon) : Finset Vertex := P.val.biUnion fun e => {upEnd e,downEnd e} + +noncomputable def interior (P : Polygon) : Finset Vertex := + cellVertices P.interiorFaces \ P.vertices + +def length (P : Polygon) : ℕ := P.val.card + +noncomputable def ccwTurn (P : Polygon) (v : Vertex) : ℝ := + Real.pi / 3 * (3 - 2 * (faceCount P.interiorFaces v : ℝ)) +end Polygon + +noncomputable def inducedEdges (D : Finset Vertex) : Finset EdgeIndex := by + classical + exact ((D.product Finset.univ).image edgeOf).filter fun e => upEnd e ∈ D ∧ downEnd e ∈ D + +noncomputable def polygons (D : Finset Vertex) : Finset Polygon := by + classical + exact (inducedEdges D).powerset.subtype IsPolygon + +def Filled (D : Finset Vertex) : Prop := ∀ P ∈ polygons D, P.interior ⊆ D + +noncomputable def visitMass (D : Finset Vertex) (v : Vertex) : ℝ := (visitSum D v).re + +noncomputable def excursionMass (D : Finset Vertex) (v : Vertex) : ℝ := by + classical + exact ∑ e ∈ excursions D, if v ∈ traced e.1 e.2 then criticalActivity ^ e.2.length else 0 + +noncomputable def polygonSystems (D : Finset Vertex) (f : FaceIndex) : + Finset (Finset Polygon) := by + classical + exact (polygons D).powerset.filter fun S => + (S : Set Polygon).Pairwise (fun P Q => Disjoint P.vertices Q.vertices) ∧ + ∀ P ∈ S, f ∈ P.interiorFaces + +noncomputable def faceNestingMass (D : Finset Vertex) (f : FaceIndex) : ℝ := + ∑ S ∈ polygonSystems D f, ∏ P ∈ S, 2 * criticalActivity ^ P.length + +noncomputable def tilingCoordinate (k : Fin 3) (z : ℝ × ℝ) : ℝ := + if k = 0 then 2 * z.2 / Real.sqrt 3 + else if k = 1 then z.1 - z.2 / Real.sqrt 3 + 1 / 2 + else z.1 + z.2 / Real.sqrt 3 + 1 / 2 + +def AdmissiblyConvex (D : Finset Vertex) : Prop := + ∃ lo hi : Fin 3 → ℤ, ∀ v : Vertex, v ∈ D ↔ ∀ k : Fin 3, + (lo k : ℝ) < tilingCoordinate k (position v) ∧ + tilingCoordinate k (position v) < (hi k : ℝ) + +def FiniteVisitRecursion : Prop := ∀ (D : Finset Vertex) (v : Vertex), Filled D → v ∈ D → + visitMass D v = 3 + + (∑ P ∈ polygons D, if v ∈ P.vertices then + 2 * criticalActivity ^ (P.length - 1) * + (-Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v))) else 0) + + (∑ P ∈ polygons D, if v ∈ P.interior then + 2 * criticalActivity ^ P.length * visitMass P.interior v else 0) + +def FiniteVisitsTheorem : Prop := FiniteVisitRecursion ∧ + (∀ P : Polygon, 0 < 2 * criticalActivity ^ P.length ∧ + ∀ v ∈ P.vertices, 0 < 2 * criticalActivity ^ (P.length - 1) * + (-Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v)))) ∧ + (∀ D v, Filled D → v ∈ D → 3 ≤ visitMass D v) ∧ + (∀ D E v, Filled D → Filled E → D ⊆ E → v ∈ D → visitMass D v ≤ visitMass E v) ∧ + (∃ c C : ℝ, 0 < c ∧ 0 < C ∧ ∀ D v, Filled D → v ∈ D → + c * (∑ k : Fin 3, faceNestingMass D (leftFace (v,k))) ≤ visitMass D v ∧ + visitMass D v ≤ C * (∑ k : Fin 3, faceNestingMass D (leftFace (v,k)))) ∧ + (∀ D v, AdmissiblyConvex D → v ∈ D → + Real.cos (3 * Real.pi / 8) * excursionMass D v ≤ visitMass D v ∧ + visitMass D v ≤ excursionMass D v) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/PotentialSupport.lean b/lean/OAI/Combinatorics/HoneycombCorridor/PotentialSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..6902190a892d5bdcfc9425d36b3495d16ebd37c2 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/PotentialSupport.lean @@ -0,0 +1,189 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.Currents + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def rationalFlowComponent (q : EdgeIndex →₀ ℚ) (k : Fin 3) : FaceIndex →₀ ℚ := + Finsupp.comapDomain (fun a => (a,k)) q (by intro a _ b _ h; exact (Prod.mk.inj h).1) + +theorem conserved_finite_potential (q : EdgeIndex →₀ ℚ) (hq : ConservedCurrent q) : + ∃ r : FaceIndex →₀ ℚ, faceGradient r = q := by + let q' : QFlow.FiniteHoneycombFlow := { + q0 := rationalFlowComponent q 0 + q1 := rationalFlowComponent q 1 + q2 := rationalFlowComponent q 2 + up_conservation := by + intro i j + change q ((i,j),0) + q ((i,j),1) + q ((i,j),2) = 0 + simpa [directedCurrent,dartSign,edgeOf,Fin.sum_univ_succ,add_assoc] using hq (.up i j) + down_conservation := by + intro i j + have h := hq (.down i j) + simp [directedCurrent,dartSign,edgeOf,Fin.sum_univ_succ] at h + change q ((i,j+1),0) + q ((i,j),1) + q ((i+1,j),2) = 0 + linarith } + obtain ⟨r,hr⟩ := QFlow.finite_flow_is_face_boundary q' + refine ⟨r,?_⟩ + funext e + rcases e with ⟨⟨i,j⟩,k⟩ + have h := hr i j + change q ((i,j),0) = _ ∧ q ((i,j),1) = _ ∧ q ((i,j),2) = _ at h + fin_cases k <;> + simp [faceGradient,canonicalDart,upEnd,leftFace,rightFace,reverseGerm,neighbor] <;> + tauto + +theorem potential_supported_on_cycle_cells (g : Germ) (w : List Bool) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) (hpne : p ≠ 0) + (r : FaceIndex →₀ ℚ) + (hr : ∀ e, e ∉ cellEdges p.support → faceGradient r e = 0) : + r.support ⊆ p.support := by + classical + let pQ : FaceIndex →₀ ℚ := p.mapRange (fun x : ℤ => (x : ℚ)) (by norm_num) + let rOut : FaceIndex →₀ ℚ := r.filter (fun a => p a = 0) + have hpQ (e : EdgeIndex) : faceGradient pQ e = (wordFlow g w e : ℚ) := by + have h := hp (canonicalDart e) + rcases e with ⟨⟨i,j⟩,k⟩ + simp only [canonicalDart,upEnd,orientedFlow_up] at h + simp only [faceGradient,pQ,Finsupp.mapRange_apply] + exact_mod_cast h.symm + have hOut : ∀ e, wordFlow g w e = 0 → faceGradient rOut e = 0 := by + intro e he + have hpE := hp (canonicalDart e) + have hz : p (leftFace (canonicalDart e)) = p (rightFace (canonicalDart e)) := by + rcases e with ⟨⟨i,j⟩,k⟩ + simp only [canonicalDart,upEnd,orientedFlow_up,he] at hpE + simp only [canonicalDart,upEnd] + omega + by_cases hl : p (leftFace (canonicalDart e)) = 0 + · have hrz : p (rightFace (canonicalDart e)) = 0 := hz ▸ hl + have hout : e ∉ cellEdges p.support := by + simp [mem_cellEdges,Finsupp.mem_support_iff,hl,hrz] + simpa [faceGradient,rOut,Finsupp.filter_apply,hl,hrz] using hr e hout + · have hrz : p (rightFace (canonicalDart e)) ≠ 0 := hz ▸ hl + simp [faceGradient,rOut,hl,hrz] + obtain ⟨c,hc'⟩ := simple_cycle_current_scalar g w hN hc + (faceGradient rOut) (gradient_conserved rOut) hOut + have hEq : rOut = c • pQ := by + apply finite_gradient_injective + funext e + rw [hc' e,← hpQ e] + simp only [faceGradient,Finsupp.smul_apply,smul_eq_mul] + ring + obtain ⟨a,ha⟩ := Finsupp.support_nonempty_iff.mpr hpne + have hpa : p a ≠ 0 := Finsupp.mem_support_iff.mp ha + have hpQa : pQ a ≠ 0 := by + simpa only [pQ,Finsupp.mapRange_apply,ne_eq,Int.cast_eq_zero] using hpa + have hval := congrArg (fun f : FaceIndex →₀ ℚ => f a) hEq + simp only [rOut,Finsupp.filter_apply,ite_eq_right hpa,Finsupp.smul_apply,smul_eq_mul] at hval + have hcz : c = 0 := (mul_eq_zero.mp hval.symm).resolve_right hpQa + have hR : rOut = 0 := by simpa [hcz] using hEq + intro a ha + by_contra hnot + have hpz : p a = 0 := by simpa only [Finsupp.mem_support_iff,not_not] using hnot + have hz := congrArg (fun f : FaceIndex →₀ ℚ => f a) hR + simp only [rOut,Finsupp.filter_apply,ite_eq_left hpz,Finsupp.zero_apply] at hz + exact (Finsupp.mem_support_iff.mp ha) hz + + + +theorem edge_mem_around (S : Finset FaceIndex) (g : Germ) : + edgeOf g ∈ cellEdges S ↔ leftFace g ∈ S ∨ rightFace g ∈ S := by + rw [mem_cellEdges] + rcases canonicalDart_edgeOf g with h | h + · rw [h] + · rw [h,rightFace_reverse] + change rightFace g ∈ S ∨ leftFace g ∈ S ↔ _ + exact or_comm + +theorem incident_faces_equal (p : FaceIndex →₀ ℤ) (v : Vertex) + (hp : ∀ k : Fin 3, p (leftFace (v,k)) = p (rightFace (v,k))) + (k l : Fin 3) : p (leftFace (v,k)) = p (leftFace (v,l)) := by + have h0 := hp 0 + have h1 := hp 1 + have h2 := hp 2 + cases v <;> fin_cases k <;> fin_cases l <;> + simp [leftFace,rightFace,reverseGerm,neighbor] at * <;> omega + +theorem nonboundary_vertex_all_edges (g : Germ) (w : List Bool) + (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) + (v : Vertex) (hv : v ∈ cellVertices p.support) (hnot : v ∉ traced g w) + (k : Fin 3) : edgeOf (v,k) ∈ cellEdges p.support := by + have hzero (l : Fin 3) : orientedFlow (wordFlow g w) (v,l) = 0 := by + rw [orientedFlow_wordFlow,hc,add_sub_cancel_right] + exact turnVisit_eq_zero_of_not_mem g w v l hnot + have he (l : Fin 3) : p (leftFace (v,l)) = p (rightFace (v,l)) := by + have hh := hp (v,l) + rw [hzero l] at hh + omega + obtain ⟨l,hl⟩ := (mem_cellVertices p.support v).mp hv + rw [edge_mem_around] + apply Or.inl + rw [Finsupp.mem_support_iff] at hl ⊢ + rwa [incident_faces_equal p v he k l] + +theorem finite_vertex_flat_zero (f : Vertex →₀ ℚ) + (hf : ∀ v k, f (neighbor v k) = f v) : f = 0 := by + classical + let row : Vertex → ℤ := fun v => match v with | .up _ j => j | .down _ j => j + let M : ℕ := f.support.sup fun v => (row v).natAbs + have hu (i j : ℤ) : f (.up i j) = 0 := by + have hh (k : ℤ) : f (.up i (k+1)) = f (.up i k) := by + have h0 := hf (.down i k) 0 + have h1 := hf (.down i k) 1 + simp only [neighbor,↓reduceIte,Fin.isValue] at h0 h1 + exact h0.trans h1.symm + let k : ℤ := (M : ℤ) + 1 + have he := QFlow.int_function_constant (f := fun j => f (.up i j)) hh j k + rw [he] + by_contra hk + have hb : (row (.up i k)).natAbs ≤ M := + Finset.le_sup (f := fun v : Vertex => (row v).natAbs) + (Finsupp.mem_support_iff.mpr hk) + dsimp [row,k] at hb + omega + ext v + cases v with + | up i j => exact hu i j + | down i j => + have h := hf (.down i j) 1 + simpa [neighbor,hu] using h.symm + +theorem flat_along_dart (S : Finset FaceIndex) (f : Vertex → ℚ) + (hf : ∀ e ∈ cellEdges S, f (upEnd e) = f (downEnd e)) + (g : Germ) (h : edgeOf g ∈ cellEdges S) : f (neighbor g.1 g.2) = f g.1 := by + have he := hf (edgeOf g) h + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> + simp [edgeOf,upEnd,downEnd,neighbor] at he ⊢ <;> first | exact he.symm | exact he + +theorem cell_flat_zero_boundary (g : Germ) (w : List Bool) + (hc : terminalGerm g w = g) + (p : FaceIndex →₀ ℤ) (hp : RepresentsFlow p (wordFlow g w)) + (f : Vertex →₀ ℚ) (hS : f.support ⊆ cellVertices p.support) + (hflat : ∀ e ∈ cellEdges p.support, f (upEnd e) = f (downEnd e)) + (hbd : ∀ v ∈ traced g w, f v = 0) : f = 0 := by + apply finite_vertex_flat_zero + intro v k + by_cases he : edgeOf (v,k) ∈ cellEdges p.support + · exact flat_along_dart _ f hflat (v,k) he + · have hz (d : Germ) (h : edgeOf d ∉ cellEdges p.support) : f d.1 = 0 := by + by_cases hV : d.1 ∈ cellVertices p.support + · apply hbd + by_contra hnot + exact h (nonboundary_vertex_all_edges g w hc p hp d.1 hV hnot d.2) + · by_contra hne + exact hV (hS (Finsupp.mem_support_iff.mpr hne)) + rw [hz (v,k) he] + exact hz (reverseGerm (v,k)) (by simpa using he) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/RationalPotential.lean b/lean/OAI/Combinatorics/HoneycombCorridor/RationalPotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..14166949b6400960fb9dab27d402ee37dac18df5 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/RationalPotential.lean @@ -0,0 +1,191 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor.QFlow + +abbrev FaceIndex := ℤ × ℤ + +noncomputable def facePrefix (f : FaceIndex →₀ ℚ) (i j : ℤ) : ℚ := + ∑ a ∈ f.support, if a.2 = j ∧ a.1 ≤ i then f a else 0 + +theorem facePrefix_difference (f : FaceIndex →₀ ℚ) (i j : ℤ) : + facePrefix f i j - facePrefix f (i - 1) j = f (i,j) := by + classical + unfold facePrefix + rw [← Finset.sum_sub_distrib] + have ht (a : FaceIndex) : + (if a.2 = j ∧ a.1 ≤ i then f a else 0) - + (if a.2 = j ∧ a.1 ≤ i - 1 then f a else 0) = + if a = (i,j) then f a else 0 := by + rcases a with ⟨x,y⟩ + by_cases hy : y = j + · subst y + by_cases hx : x = i + · subst x + simp + · have hh : x ≤ i ↔ x ≤ i - 1 := by omega + simp [hx,hh] + · simp [hy] + simp_rw [ht] + by_cases hm : (i,j) ∈ f.support + · simp [hm] + · have hz : f (i,j) = 0 := by simpa only [Finsupp.mem_support_iff, not_not] using hm + simp [hm, hz] + +def InFaceBox (M : ℕ) (a : FaceIndex) : Prop := + -(M : ℤ) ≤ a.1 ∧ a.1 ≤ M ∧ -(M : ℤ) ≤ a.2 ∧ a.2 ≤ M + +noncomputable def faceRadius (f : FaceIndex →₀ ℚ) : ℕ := + f.support.sup fun a => a.1.natAbs + a.2.natAbs + +theorem mem_support_in_box (f : FaceIndex →₀ ℚ) (a : FaceIndex) + (ha : a ∈ f.support) : InFaceBox (faceRadius f) a := by + have h : a.1.natAbs + a.2.natAbs ≤ faceRadius f := Finset.le_sup (f := fun a : FaceIndex => a.1.natAbs + a.2.natAbs) ha + have hx : a.1.natAbs ≤ faceRadius f := le_trans (Nat.le_add_right _ _) h + have hy : a.2.natAbs ≤ faceRadius f := le_trans (Nat.le_add_left _ _) h + have hxi : |a.1| ≤ (faceRadius f : ℤ) := by simpa only [Int.natCast_natAbs] using (Int.ofNat_le.mpr hx) + have hyi : |a.2| ≤ (faceRadius f : ℤ) := by simpa only [Int.natCast_natAbs] using (Int.ofNat_le.mpr hy) + exact ⟨(abs_le.mp hxi).1,(abs_le.mp hxi).2,(abs_le.mp hyi).1,(abs_le.mp hyi).2⟩ + +theorem facePrefix_left_zero (f : FaceIndex →₀ ℚ) (i j : ℤ) + (hi : i < -(faceRadius f : ℤ)) : facePrefix f i j = 0 := by + classical + apply Finset.sum_eq_zero + intro a ha + have hb := (mem_support_in_box f a ha).1 + have hx : ¬a.1 ≤ i := by omega + simp [hx] + +theorem facePrefix_row_zero (f : FaceIndex →₀ ℚ) (i j : ℤ) + (hj : j < -(faceRadius f : ℤ) ∨ (faceRadius f : ℤ) < j) : + facePrefix f i j = 0 := by + classical + apply Finset.sum_eq_zero + intro a ha + have hb := mem_support_in_box f a ha + have hy : a.2 ≠ j := by intro h; rcases hb with ⟨h1,h2,h3,h4⟩; omega + simp [hy] + +theorem int_function_constant {f : ℤ → ℚ} (hf : ∀ i, f (i + 1) = f i) + (i j : ℤ) : f i = f j := by + have hzero (n : ℤ) : f n = f 0 := by + induction n using Int.induction_on with + | zero => rfl + | succ n hn => exact (hf n).trans hn + | pred n hn => + calc f (-(n : ℤ) - 1) = f (-n) := by simpa using (hf (-(n : ℤ) - 1)).symm + _ = f 0 := hn + exact (hzero i).trans (hzero j).symm + +structure FiniteHoneycombFlow where + q0 : FaceIndex →₀ ℚ + q1 : FaceIndex →₀ ℚ + q2 : FaceIndex →₀ ℚ + up_conservation : ∀ i j, q0 (i,j) + q1 (i,j) + q2 (i,j) = 0 + down_conservation : ∀ i j, q0 (i,j+1) + q1 (i,j) + q2 (i+1,j) = 0 + +noncomputable def flowPotential (q : FiniteHoneycombFlow) (i j : ℤ) : ℚ := + facePrefix q.q0 i j + +theorem flow_difference (q : FiniteHoneycombFlow) (i j : ℤ) : + q.q0 (i,j+1) - q.q0 (i,j) = q.q2 (i,j) - q.q2 (i+1,j) := by + have hu := q.up_conservation i j + have hd := q.down_conservation i j + linarith + +theorem flowPotential_vertical (q : FiniteHoneycombFlow) (i j : ℤ) : + flowPotential q i (j+1) - flowPotential q i j = -q.q2 (i+1,j) := by + let H : ℤ → ℚ := fun k => + flowPotential q k (j+1) - flowPotential q k j + q.q2 (k+1,j) + have hH : ∀ k, H (k+1) = H k := by + intro k + have h1 := facePrefix_difference q.q0 (k+1) (j+1) + have h2 := facePrefix_difference q.q0 (k+1) j + have hd := flow_difference q (k+1) j + simp only [add_sub_cancel_right] at h1 h2 + dsimp [H,flowPotential] + linarith + let k : ℤ := -(faceRadius q.q0 : ℤ) - (faceRadius q.q2 : ℤ) - 2 + have hk0 : k < -(faceRadius q.q0 : ℤ) := by dsimp [k]; omega + have hk2 : q.q2 (k+1,j) = 0 := by + by_contra hne + have hm := Finsupp.mem_support_iff.mpr hne + have hb := (mem_support_in_box q.q2 (k+1,j) hm).1 + dsimp [k] at hb + omega + have hHz : H k = 0 := by + dsimp [H,flowPotential] + rw [facePrefix_left_zero _ _ _ hk0,facePrefix_left_zero _ _ _ hk0,hk2] + norm_num + have h := (int_function_constant hH i k).trans hHz + dsimp [H] at h + linarith + +theorem flowPotential_right_zero (q : FiniteHoneycombFlow) (i j : ℤ) + (hi : (faceRadius q.q2 : ℤ) ≤ i) : flowPotential q i j = 0 := by + have hconstant : ∀ k, flowPotential q i (k+1) = flowPotential q i k := by + intro k + have hq : q.q2 (i+1,k) = 0 := by + by_contra hne + have hb := (mem_support_in_box q.q2 (i+1,k) + (Finsupp.mem_support_iff.mpr hne)).2.1 + omega + have h := flowPotential_vertical q i k + rw [hq] at h + linarith + let k : ℤ := (faceRadius q.q0 : ℤ) + 1 + have hz : flowPotential q i k = 0 := + facePrefix_row_zero q.q0 i k (Or.inr (by dsimp [k]; omega)) + exact (int_function_constant hconstant j k).trans hz + +theorem flowPotential_finite_support (q : FiniteHoneycombFlow) : + Set.Finite {a : FaceIndex | flowPotential q a.1 a.2 ≠ 0} := by + let M : ℤ := (faceRadius q.q0 : ℤ) + faceRadius q.q2 + 1 + apply (Set.finite_Icc (-M, -M) (M, M)).subset + intro a ha + change flowPotential q a.1 a.2 ≠ 0 at ha + have hleft : -(faceRadius q.q0 : ℤ) ≤ a.1 := by + by_contra h + exact ha (facePrefix_left_zero q.q0 a.1 a.2 (by omega)) + have hright : a.1 < (faceRadius q.q2 : ℤ) := by + by_contra h + exact ha (flowPotential_right_zero q a.1 a.2 (by omega)) + have hbottom : -(faceRadius q.q0 : ℤ) ≤ a.2 := by + by_contra h + exact ha (facePrefix_row_zero q.q0 a.1 a.2 (Or.inl (by omega))) + have htop : a.2 ≤ (faceRadius q.q0 : ℤ) := by + by_contra h + exact ha (facePrefix_row_zero q.q0 a.1 a.2 (Or.inr (by omega))) + change (-M ≤ a.1 ∧ -M ≤ a.2) ∧ a.1 ≤ M ∧ a.2 ≤ M + dsimp [M] + omega + +noncomputable def finiteFlowPotential (q : FiniteHoneycombFlow) : FaceIndex →₀ ℚ := + Finsupp.ofSupportFinite (fun a => flowPotential q a.1 a.2) + (flowPotential_finite_support q) + +theorem finite_flow_is_face_boundary (q : FiniteHoneycombFlow) : + ∃ p : FaceIndex →₀ ℚ, ∀ i j, + q.q0 (i,j) = p (i,j) - p (i-1,j) ∧ + q.q1 (i,j) = p (i-1,j+1) - p (i,j) ∧ + q.q2 (i,j) = p (i-1,j) - p (i-1,j+1) := by + refine ⟨finiteFlowPotential q, ?_⟩ + intro i j + have h0 := facePrefix_difference q.q0 i j + have h2 := flowPotential_vertical q (i-1) j + have hu := q.up_conservation i j + simp only [sub_add_cancel] at h2 + simp only [finiteFlowPotential,Finsupp.ofSupportFinite_coe,flowPotential] + dsimp [flowPotential] at h2 + constructor + · linarith + constructor <;> linarith + +end PolynomialVacuumBridge.Corridor.QFlow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/RaySeparation.lean b/lean/OAI/Combinatorics/HoneycombCorridor/RaySeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..29d78a51a1200e44ca7578850961cc6734459193 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/RaySeparation.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.VisitRecursion + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def positiveWordMass (S : Finset (List Bool)) : ℝ := + ∑ w ∈ S, criticalActivity ^ w.length +noncomputable def phasedWordMass (S : Finset (List Bool)) : ℂ := + ∑ w ∈ S, wordWeight w +noncomputable def phase (a : ℝ) : ℂ := Complex.exp ((a : ℂ) * Complex.I) + +@[simp] theorem phase_norm (a : ℝ) : ‖phase a‖ = 1 := + Complex.norm_exp_ofReal_mul_I a + +theorem phase_add (a b : ℝ) : phase (a+b) = phase a * phase b := by + simp only [phase,Complex.ofReal_add,add_mul,Complex.exp_add] + +@[simp] theorem phase_zero : phase 0 = 1 := by simp [phase] + +@[simp] theorem wordWeight_norm (w : List Bool) : + ‖wordWeight w‖ = criticalActivity ^ w.length := by + rw [wordWeight_turnUnits,norm_mul,Complex.norm_exp_ofReal_mul_I,mul_one,norm_pow, + Complex.norm_real,Real.norm_eq_abs,abs_of_pos criticalActivity_pos] + +theorem positiveWordMass_nonneg (S : Finset (List Bool)) : 0 ≤ positiveWordMass S := + Finset.sum_nonneg fun _ _ => pow_nonneg criticalActivity_pos.le _ + +theorem phasedWordMass_norm_le (S : Finset (List Bool)) : + ‖phasedWordMass S‖ ≤ positiveWordMass S := by + simpa only [phasedWordMass,positiveWordMass,wordWeight_norm] using norm_sum_le S wordWeight + +theorem positiveWordMass_mono {S T : Finset (List Bool)} (h : S ⊆ T) : + positiveWordMass S ≤ positiveWordMass T := by + exact Finset.sum_le_sum_of_subset_of_nonneg h (fun _ _ _ => pow_nonneg criticalActivity_pos.le _) + +noncomputable def rayContraction : ℝ := + (1 + Real.cos (3*Real.pi/8) * Real.sin (Real.pi/8))⁻¹ + +theorem rayContraction_range : 0 < rayContraction ∧ rayContraction < 1 := by + have hc : 0 < Real.cos (3*Real.pi/8) := by + apply Real.cos_pos_of_mem_Ioo + constructor <;> linarith [Real.pi_pos] + have hs : 0 < Real.sin (Real.pi/8) := + Real.sin_pos_of_pos_of_lt_pi (by linarith [Real.pi_pos]) (by linarith [Real.pi_pos]) + have hd := mul_pos hc hs + constructor + · exact inv_pos.mpr (by linarith) + · apply (inv_lt_one₀ (by linarith : 0 < 1+Real.cos (3*Real.pi/8)*Real.sin (Real.pi/8))).mpr + linarith + +theorem separated_rays_contract (S T : Finset (List Bool)) (hTS : T ⊆ S) + (hlower : Real.cos (3*Real.pi/8) * positiveWordMass T ≤ (phasedWordMass T).re) + (a b : ℝ) (hb : 0 ≤ b) + (hS : phasedWordMass S = (a : ℂ) * phase (-Real.pi/8)) + (hT : phasedWordMass T = (b : ℂ) * phase (-Real.pi/4)) : + positiveWordMass T ≤ rayContraction * positiveWordMass S := by + have halpha : Real.pi/8 + -Real.pi/4 = -Real.pi/8 := by ring + have hzero : Real.pi/8 + -Real.pi/8 = 0 := by ring + have hrotate : phase (Real.pi/8) * (phasedWordMass S - phasedWordMass T) = + (a : ℂ) - (b : ℂ) * phase (-Real.pi/8) := by + rw [hS,hT,mul_sub] + have h1 := phase_add (Real.pi/8) (-Real.pi/8) + have h2 := phase_add (Real.pi/8) (-Real.pi/4) + rw [hzero,phase_zero] at h1 + rw [halpha] at h2 + calc + _ = (a : ℂ) * (phase (Real.pi/8)*phase (-Real.pi/8)) - + (b : ℂ) * (phase (Real.pi/8)*phase (-Real.pi/4)) := by ring + _ = _ := by rw [← h1,← h2,mul_one] + have him : (phase (Real.pi/8) * (phasedWordMass S - phasedWordMass T)).im = + b * Real.sin (Real.pi/8) := by + rw [hrotate] + have hp : (phase (-Real.pi/8)).im = -Real.sin (Real.pi/8) := by + unfold phase + rw [Complex.exp_ofReal_mul_I_im,neg_div,Real.sin_neg] + simp only [Complex.sub_im,Complex.ofReal_im,Complex.mul_im, + Complex.ofReal_re,hp,zero_sub,zero_mul,add_zero,mul_neg,neg_neg] + have hnorm : b * Real.sin (Real.pi/8) ≤ ‖phasedWordMass S - phasedWordMass T‖ := by + calc + _ ≤ |(phase (Real.pi/8) * (phasedWordMass S - phasedWordMass T)).im| := by + rw [him]; exact le_abs_self _ + _ ≤ ‖phase (Real.pi/8) * (phasedWordMass S - phasedWordMass T)‖ := + Complex.abs_im_le_norm _ + _ = _ := by rw [norm_mul,phase_norm,one_mul] + have hbnd : Real.cos (3*Real.pi/8) * positiveWordMass T ≤ b := by + calc + _ ≤ (phasedWordMass T).re := hlower + _ ≤ ‖phasedWordMass T‖ := (le_abs_self _).trans (Complex.abs_re_le_norm _) + _ = b := by rw [hT,norm_mul,phase_norm,mul_one,Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg hb] + have hmass : positiveWordMass (S \ T) + positiveWordMass T = positiveWordMass S := + Finset.sum_sdiff hTS + have hdiff : phasedWordMass S - phasedWordMass T = phasedWordMass (S \ T) := + (Finset.sum_sdiff_eq_sub hTS).symm + rw [hdiff] at hnorm + have hnorm' := phasedWordMass_norm_le (S \ T) + have hs : 0 ≤ Real.sin (Real.pi/8) := (Real.sin_pos_of_pos_of_lt_pi + (by linarith [Real.pi_pos]) (by linarith [Real.pi_pos])).le + have hprod := mul_le_mul_of_nonneg_right hbnd hs + have hfinal : (1+Real.cos (3*Real.pi/8)*Real.sin (Real.pi/8))*positiveWordMass T ≤ + positiveWordMass S := by nlinarith + change _ ≤ (1+Real.cos (3*Real.pi/8)*Real.sin (Real.pi/8))⁻¹ * _ + have hd : 0 < 1+Real.cos (3*Real.pi/8)*Real.sin (Real.pi/8) := by + have hc : 0 ≤ Real.cos (3*Real.pi/8) := by + apply Real.cos_nonneg_of_mem_Icc + constructor <;> linarith [Real.pi_pos] + nlinarith [mul_nonneg hc hs] + rw [← div_eq_inv_mul] + exact (le_div_iff₀ hd).mpr (by simpa only [mul_comm] using hfinal) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Reflection.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Reflection.lean new file mode 100644 index 0000000000000000000000000000000000000000..c47a0ef0bb64a527619e9e4056be9e324fc46061 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Reflection.lean @@ -0,0 +1,165 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.ConvexCuts + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +def mirrorVertex : Vertex → Vertex + | .up i j => .up (-i-j) j + | .down i j => .down (-i-j-1) j + +def mirrorSlot (k : Fin 3) : Fin 3 := if k = 0 then 0 else if k = 1 then 2 else 1 + +def mirrorGerm (g : Germ) : Germ := (mirrorVertex g.1,mirrorSlot g.2) +def mirrorWord (w : List Bool) : List Bool := w.map Bool.not + +@[simp] theorem mirrorVertex_invol (v : Vertex) : mirrorVertex (mirrorVertex v) = v := by + cases v <;> simp [mirrorVertex] + omega + +@[simp] theorem mirrorSlot_invol (k : Fin 3) : mirrorSlot (mirrorSlot k) = k := by + fin_cases k <;> rfl + +@[simp] theorem mirrorGerm_invol (g : Germ) : mirrorGerm (mirrorGerm g) = g := by + simp [mirrorGerm] + +@[simp] theorem mirrorWord_invol (w : List Bool) : mirrorWord (mirrorWord w) = w := by + simp [mirrorWord,List.map_map,Function.comp_def] + +theorem mirrorVertex_injective : Function.Injective mirrorVertex := + Function.Involutive.injective mirrorVertex_invol + +theorem mirrorWord_injective : Function.Injective mirrorWord := + Function.Involutive.injective mirrorWord_invol + +@[simp] theorem mirrorWord_length (w : List Bool) : (mirrorWord w).length = w.length := by + simp [mirrorWord] + +@[simp] theorem mirror_position (v : Vertex) : (position (mirrorVertex v)).1 = -(position v).1 := by + cases v <;> simp [mirrorVertex,position] <;> ring + +@[simp] theorem mirror_neighbor (v : Vertex) (k : Fin 3) : + mirrorVertex (neighbor v k) = neighbor (mirrorVertex v) (mirrorSlot k) := by + cases v <;> fin_cases k <;> simp [mirrorVertex,mirrorSlot,neighbor] <;> omega + +@[simp] theorem mirror_advance (g : Germ) (b : Bool) : + mirrorGerm (advance g b) = advance (mirrorGerm g) (!b) := by + rcases g with ⟨v,k⟩ + cases v <;> fin_cases k <;> cases b <;> + simp [mirrorGerm,mirrorVertex,mirrorSlot,advance,outgoingSlot,neighbor, + Fin.reduceAdd,Fin.reduceEq,Fin.isValue] <;> omega + +@[simp] theorem mirror_terminal (g : Germ) (w : List Bool) : + terminalGerm (mirrorGerm g) (mirrorWord w) = mirrorGerm (terminalGerm g w) := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + simp only [mirrorWord,List.map_cons,terminalGerm,← mirror_advance] + exact ih _ + +@[simp] theorem mirror_traced (g : Germ) (w : List Bool) : + traced (mirrorGerm g) (mirrorWord w) = (traced g w).map mirrorVertex := by + induction w generalizing g with + | nil => rfl + | cons b w ih => + change mirrorVertex g.1 :: traced (advance (mirrorGerm g) (!b)) (mirrorWord w) = + mirrorVertex g.1 :: (traced (advance g b) w).map mirrorVertex + rw [← mirror_advance,ih] + +@[simp] theorem mirror_bottomSource : mirrorGerm bottomSource = bottomSource := by rfl + +noncomputable def mirrorDomain (D : Finset Vertex) : Finset Vertex := D.image mirrorVertex + +@[simp] theorem mem_mirrorDomain (D : Finset Vertex) (v : Vertex) : + v ∈ mirrorDomain D ↔ mirrorVertex v ∈ D := by + constructor + · intro hv + obtain ⟨u,hu,rfl⟩ := Finset.mem_image.mp hv + simpa using hu + · intro hv + exact Finset.mem_image.mpr ⟨mirrorVertex v,hv,mirrorVertex_invol v⟩ + +@[simp] theorem mirrorDomain_invol (D : Finset Vertex) : mirrorDomain (mirrorDomain D) = D := by + ext v + simp + +@[simp] theorem mirror_indices (v : Vertex) : + boxIndex (mirrorVertex v) 0 = boxIndex v 0 ∧ + boxIndex (mirrorVertex v) 1 = -boxIndex v 2 ∧ + boxIndex (mirrorVertex v) 2 = -boxIndex v 1 := by + cases v <;> simp [mirrorVertex,boxIndex] <;> omega + +theorem mirrorDomain_convex (D : Finset Vertex) (hD : AdmissiblyConvex D) : + AdmissiblyConvex (mirrorDomain D) := by + obtain ⟨lo,hi,hbox⟩ := admissiblyConvex_box D hD + let lo' : Fin 3 → ℤ := fun k => if k = 0 then lo 0 else if k = 1 then 1-hi 2 else 1-hi 1 + let hi' : Fin 3 → ℤ := fun k => if k = 0 then hi 0 else if k = 1 then 1-lo 2 else 1-lo 1 + apply admissiblyConvex_of_box _ lo' hi' + intro v + rw [mem_mirrorDomain,hbox] + have hm := mirror_indices v + constructor + · intro hv k + have h0 := hv 0 + have h1 := hv 1 + have h2 := hv 2 + rw [hm.1] at h0 + rw [hm.2.1] at h1 + rw [hm.2.2] at h2 + fin_cases k <;> simp [lo',hi'] <;> omega + · intro hv k + have h0 := hv 0 + have h1 := hv 1 + have h2 := hv 2 + simp only [lo',hi',Fin.isValue,Fin.reduceEq,ite_true,ite_false] at h0 h1 h2 + fin_cases k + · change lo 0 ≤ boxIndex (mirrorVertex v) 0 ∧ boxIndex (mirrorVertex v) 0 < hi 0 + rw [hm.1]; omega + · change lo 1 ≤ boxIndex (mirrorVertex v) 1 ∧ boxIndex (mirrorVertex v) 1 < hi 1 + rw [hm.2.1]; omega + · change lo 2 ≤ boxIndex (mirrorVertex v) 2 ∧ boxIndex (mirrorVertex v) 2 < hi 2 + rw [hm.2.2]; omega + +theorem mirrorDomain_strip (h : ℕ) (D : Finset Vertex) (hstrip : ∀ v ∈ D, InStrip h v) : + ∀ v ∈ mirrorDomain D, InStrip h v := by + intro v hv + have hh := hstrip _ ((mem_mirrorDomain D v).mp hv) + simpa only [InStrip,(mirror_indices v).1] using hh + +theorem mirror_sourceExits (D : Finset Vertex) (g : Germ) (w : List Bool) + (hw : w ∈ sourceExits D g) : mirrorWord w ∈ sourceExits (mirrorDomain D) (mirrorGerm g) := by + obtain ⟨hs,ht⟩ := (mem_sourceExits D g w).mp hw + obtain ⟨hn,hm⟩ := stopped_traced D g w hs + have ht' : (terminalGerm (mirrorGerm g) (mirrorWord w)).1 ∉ mirrorDomain D := by + rw [mirror_terminal] + change mirrorVertex (terminalGerm g w).1 ∉ mirrorDomain D + rwa [mem_mirrorDomain,mirrorVertex_invol] + apply (mem_sourceExits _ _ _).mpr + refine ⟨stopped_of_trace _ _ _ ?_ ?_ ht',ht'⟩ + · rw [mirror_traced] + exact hn.map mirrorVertex_injective + · intro v hv + rw [mirror_traced,List.mem_map] at hv + obtain ⟨u,hu,rfl⟩ := hv + simpa only [mem_mirrorDomain,mirrorVertex_invol] using hm u hu + +theorem mirror_sourceExits_eq (D : Finset Vertex) : + sourceExits (mirrorDomain D) bottomSource = (sourceExits D bottomSource).image mirrorWord := by + ext w + constructor + · intro hw + refine Finset.mem_image.mpr ⟨mirrorWord w,?_,mirrorWord_invol w⟩ + simpa only [mirrorDomain_invol,mirror_bottomSource] using + mirror_sourceExits (mirrorDomain D) bottomSource w hw + · intro hw + obtain ⟨u,hu,rfl⟩ := Finset.mem_image.mp hw + simpa only [mirror_bottomSource] using mirror_sourceExits D bottomSource u hu + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/ReturnCycles.lean b/lean/OAI/Combinatorics/HoneycombCorridor/ReturnCycles.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2b95951d4fabf15983e7d927c4669da6b0d7175 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/ReturnCycles.lean @@ -0,0 +1,300 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.PolygonSize + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +abbrev RayRecord := Fin 3 × List Bool + +def rayGerm (v : Vertex) (k : Fin 3) : Germ := (neighbor v k,k) + +noncomputable def rayLeaves (D : Finset Vertex) (v : Vertex) : Finset RayRecord := + Finset.univ.biUnion fun k : Fin 3 => + (leaves (D.erase v) (rayGerm v k)).image fun w => (k,w) + +@[simp] theorem mem_rayLeaves (D : Finset Vertex) (v : Vertex) (e : RayRecord) : + e ∈ rayLeaves D v ↔ Stopped (D.erase v) (rayGerm v e.1) e.2 := by + classical + simp only [rayLeaves,Finset.mem_biUnion,Finset.mem_image,Finset.mem_univ,true_and] + constructor + · rintro ⟨k,w,hw,he⟩ + subst e + exact (mem_leaves_iff _ _ _).mp hw + · intro h + exact ⟨e.1,e.2,(mem_leaves_iff _ _ _).mpr h,rfl⟩ + +noncomputable def rayReturns (D : Finset Vertex) (v : Vertex) : Finset RayRecord := by + classical + exact (rayLeaves D v).filter fun e => (terminalGerm (rayGerm v e.1) e.2).1 = v + +@[simp] theorem mem_rayReturns (D : Finset Vertex) (v : Vertex) (e : RayRecord) : + e ∈ rayReturns D v ↔ Stopped (D.erase v) (rayGerm v e.1) e.2 ∧ + (terminalGerm (rayGerm v e.1) e.2).1 = v := by + classical + simp [rayReturns] + +def omitRoot (v : Vertex) (e : RayRecord) : RayRecord := + match e.2 with + | [] => e + | b :: w => (outgoingSlot (v,e.1) b,w) + +theorem cycle_omitRoot_mem (D : Finset Vertex) (v : Vertex) (P : Polygon) + (hP : P ∈ polygons D) (e : RayRecord) (he : e ∈ cyclesAt P v) : + omitRoot v e ∈ rayReturns D v := by + have h := (mem_cyclesAt P v e).mp he + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil h.1 + have htr : P.Traverses (v,e.1) (b :: w) := hw ▸ h + have hN := List.nodup_cons.mp htr.2.1 + have hd : ∀ u ∈ traced (advance (v,e.1) b) w, u ∈ D.erase v := by + intro u hu + refine Finset.mem_erase.mpr ⟨?_,?_⟩ + · intro heq + subst u + exact hN.1 hu + · apply (mem_polygons _ _).mp hP + rw [htr.vertices] + simp only [traced,List.mem_toFinset,List.mem_cons] + exact Or.inr hu + have hc : (terminalGerm (advance (v,e.1) b) w).1 = v := congrArg Prod.fst htr.2.2.1 + rw [mem_rayReturns] + simp only [omitRoot,hw] + change Stopped (D.erase v) (advance (v,e.1) b) w ∧ _ + refine ⟨(stopped_iff_trace _ _ _).mpr ⟨hN.2,hd,Or.inl ?_⟩,hc⟩ + simp [hc] + +theorem outgoingSlot_exists (g : Germ) (k : Fin 3) (hk : k ≠ g.2) : + ∃ b : Bool, outgoingSlot g b = k := by + rcases g with ⟨v,l⟩ + fin_cases k <;> fin_cases l <;> simp_all [outgoingSlot] + +theorem rayReturn_closes (D : Finset Vertex) (v : Vertex) (hv : v ∈ D) + (e : RayRecord) (he : e ∈ rayReturns D v) : + ∃ (P : Polygon) (c : RayRecord), P ∈ polygons D ∧ c ∈ cyclesAt P v ∧ omitRoot v c = e := by + have hs := (mem_rayReturns D v e).mp he + let g := rayGerm v e.1 + have hne : e.2 ≠ [] := by + intro hn + have h := hs.2 + simp only [hn,terminalGerm,rayGerm] at h + exact neighbor_ne_self _ _ h + have hstart : g.1 ∈ D.erase v := by + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil hne + exact (show Stopped (D.erase v) g (b :: w) from hw ▸ hs.1).1 + have hexc : IsExcursion (D.erase v) (g,e.2) := by + refine ⟨hstart,?_,hs.1,?_⟩ + · simp [g,rayGerm,reverseGerm] + · change (terminalGerm (rayGerm v e.1) e.2).1 ∉ D.erase v + simp [hs.2] + let t := terminalGerm g e.2 + have ht : t.1 = v := hs.2 + have hslot : e.1 ≠ t.2 := by + intro hh + apply hexc.distinct_ports + apply Prod.ext + · change neighbor t.1 t.2 = neighbor v e.1 + rw [ht,hh] + · exact hh.symm + obtain ⟨b,hb⟩ := outgoingSlot_exists (v,t.2) e.1 hslot + have ha : advance (v,t.2) b = g := by + unfold advance + rw [hb] + rfl + have hfresh := (stopped_iff_trace _ _ _).mp hs.1 + have hN : (traced (v,t.2) (b :: e.2)).Nodup := by + simp only [traced,ha,List.nodup_cons] + exact ⟨fun hm => (Finset.mem_erase.mp (hfresh.2.1 v hm)).1 rfl,hfresh.1⟩ + have hc : terminalGerm (v,t.2) (b :: e.2) = (v,t.2) := by + change terminalGerm (advance (v,t.2) b) e.2 = _ + rw [ha] + exact Prod.ext ht rfl + let P := polygonOfClosed (v,t.2) (b :: e.2) (by simp) hN hc + refine ⟨P,(t.2,b :: e.2),?_,?_,?_⟩ + · apply (mem_polygons D P).mpr + rw [polygonOfClosed_vertices] + intro u hu + simp only [traced,ha,List.mem_toFinset,List.mem_cons] at hu + rcases hu with rfl | hu + · exact hv + · exact Finset.mem_of_mem_erase (hfresh.2.1 u hu) + · exact (mem_cyclesAt _ _ _).mpr ⟨by simp,hN,hc,rfl⟩ + · simp only [omitRoot,hb] + +noncomputable def cyclesIn (D : Finset Vertex) (v : Vertex) : Finset RayRecord := + (polygons D).biUnion fun P => cyclesAt P v + +theorem cycles_disjoint (v : Vertex) {P Q : Polygon} (hPQ : P ≠ Q) : + Disjoint (cyclesAt P v) (cyclesAt Q v) := by + classical + apply Finset.disjoint_left.mpr + intro e he hf + have h := (mem_cyclesAt _ _ _).mp he + have h' := (mem_cyclesAt _ _ _).mp hf + exact hPQ (Subtype.ext (h.2.2.2.symm.trans h'.2.2.2)) + +theorem omitRoot_injOn (D : Finset Vertex) (v : Vertex) : + Set.InjOn (omitRoot v) (cyclesIn D v) := by + intro e he f hf hef + obtain ⟨P,hP,he⟩ := Finset.mem_biUnion.mp he + obtain ⟨Q,hQ,hf⟩ := Finset.mem_biUnion.mp hf + have h := (mem_cyclesAt _ _ _).mp he + have h' := (mem_cyclesAt _ _ _).mp hf + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil h.1 + obtain ⟨c,u,hu⟩ := List.exists_cons_of_ne_nil h'.1 + have hp := Prod.mk.inj (show (outgoingSlot (v,e.1) b,w) = + (outgoingSlot (v,f.1) c,u) from by simpa only [omitRoot,hw,hu] using hef) + have ha : advance (v,e.1) b = advance (v,f.1) c := by simp only [advance,hp.1] + have ht : (v,e.1) = (v,f.1) := by + rw [← h.2.2.1,← h'.2.2.1,hw,hu] + simp only [terminalGerm,ha,hp.2] + have hes : e.1 = f.1 := congrArg Prod.snd ht + have heturn : b = c := outgoingSlot_injective (v,f.1) (by simpa only [hes] using hp.1) + exact Prod.ext hes (by rw [hw,hu,heturn,hp.2]) + +theorem return_sum_cycles (D : Finset Vertex) (v : Vertex) (hv : v ∈ D) : + (∑ e ∈ rayReturns D v, wordWeight e.2) = + ∑ P ∈ polygons D, ∑ e ∈ cyclesAt P v, wordWeight (omitRoot v e).2 := by + classical + have hsum : (∑ e ∈ cyclesIn D v, wordWeight (omitRoot v e).2) = + ∑ e ∈ rayReturns D v, wordWeight e.2 := by + apply Finset.sum_bij (fun e _ => omitRoot v e) + · intro e he + obtain ⟨P,hP,he⟩ := Finset.mem_biUnion.mp he + exact cycle_omitRoot_mem D v P hP e he + · intro e he f hf heq + exact omitRoot_injOn D v he hf heq + · intro e he + obtain ⟨P,c,hP,hc,heq⟩ := rayReturn_closes D v hv e he + exact ⟨c,Finset.mem_biUnion.mpr ⟨P,hP,hc⟩,heq⟩ + · intro e he + rfl + rw [← hsum,cyclesIn,Finset.sum_biUnion] + intro P hP Q hQ hPQ + exact cycles_disjoint v hPQ + + + +theorem numeric_faceCount_turn (f : Fin 3 → ℤ) (ε : ℤ) + (hε : ε = 1 ∨ ε = -1) (hf : ∀ l, f l = 0 ∨ f l = ε) + (k : Fin 3) (b : Bool) + (h : ∀ l : Fin 3, f l - f (l+2) = + (if l = k + (if b then 2 else 1) then 1 else 0) - (if l = k then 1 else 0)) : + 3 - 2 * (∑ l : Fin 3, if f l ≠ 0 then (1 : ℤ) else 0) = ε * turnUnit b := by + have h0 := h 0 + have h1 := h 1 + have h2 := h 2 + have hf0 := hf 0 + have hf1 := hf 1 + have hf2 := hf 2 + clear h hf + rcases hε with rfl | rfl <;> fin_cases k <;> cases b <;> + rcases hf0 with hf0 | hf0 <;> rcases hf1 with hf1 | hf1 <;> + rcases hf2 with hf2 | hf2 <;> + simp only [Fin.sum_univ_succ] at * <;> simp_all [turnUnit] + +theorem contour_faceCount_turn (p : FaceIndex →₀ ℤ) (ε : ℤ) + (hε : ε = 1 ∨ ε = -1) (hvals : ∀ a, p a = 0 ∨ p a = ε) + (q : EdgeIndex →₀ ℤ) (hp : RepresentsFlow p q) + (g : Germ) (b : Bool) (hw : LocalContour q g b) : + 3 - 2 * faceCount p.support g.1 = ε * turnUnit b := by + let f : Fin 3 → ℤ := fun l => p (leftFace (g.1,l)) + have hl (l : Fin 3) : f l - f (l+2) = + (if l = g.2 + (if b then 2 else 1) then 1 else 0) - (if l = g.2 then 1 else 0) := by + have h := (hp (g.1,l)).symm.trans (hw l) + simp only [f,rightFace_prev,outgoingSlot] at h ⊢ + exact h + simpa only [faceCount,Finsupp.mem_support_iff] using + numeric_faceCount_turn f ε hε (fun l => hvals _) g.2 b hl + +theorem Polygon.ccwTurn_traversal (P : Polygon) (g : Germ) (b : Bool) (w : List Bool) + (h : P.Traverses g (b :: w)) (p : FaceIndex →₀ ℤ) (ε : ℤ) + (hp : RepresentsFlow p (wordFlow g (b :: w))) + (hε : ε = 1 ∨ ε = -1) (hvals : ∀ a, p a = 0 ∨ p a = ε) : + P.ccwTurn g.1 = Real.pi / 3 * (ε * turnUnit b : ℤ) := by + have ht := contour_faceCount_turn p ε hε hvals _ hp g b + (simple_closed_word_contour _ _ h.2.1 h.2.2.1).1 + unfold Polygon.ccwTurn + rw [P.interiorFaces_of_traversal g (b :: w) h.2.1 h.2.2.1 h.2.2.2 p hp] + congr 1 + exact_mod_cast ht + +theorem wordWeight_add_reverse (w : List Bool) : + wordWeight w + wordWeight (reverseTurns w) = + (2 : ℂ) * (criticalActivity : ℂ) ^ w.length * + (Real.cos (Real.pi / 8 * (turnUnits w : ℝ)) : ℂ) := by + rw [wordWeight_reverse,wordWeight_turnUnits,Complex.exp_ofReal_mul_I] + simp only [map_mul,map_add,map_pow,Complex.conj_ofReal,Complex.conj_I] + ring + +theorem cycle_return_weight (P : Polygon) (v : Vertex) (e : RayRecord) + (he : e ∈ cyclesAt P v) : + wordWeight (omitRoot v e).2 + wordWeight (omitRoot v (reverseCycle v e)).2 = + (2 : ℂ) * (criticalActivity : ℂ) ^ (P.length - 1) * + (Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v)) : ℂ) := by + have h := (mem_cyclesAt P v e).mp he + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil h.1 + have htr : P.Traverses (v,e.1) (b :: w) := hw ▸ h + obtain ⟨p,ε,hp,hpne,hε,hvals⟩ := simple_closed_word_indicator (v,e.1) (b :: w) + (by simp) htr.2.1 htr.2.2.1 + have ht := simple_polygon_signed_turn (v,e.1) (b :: w) (by simp) + htr.2.1 htr.2.2.1 p ε hp hpne hε hvals + have hccw := P.ccwTurn_traversal (v,e.1) b w htr p ε hp hε hvals + simp only [omitRoot,hw,reverseCycle] + rw [wordWeight_add_reverse] + have hlen : P.length - 1 = w.length := by rw [htr.length]; simp + rw [hlen,hccw] + congr 2 + have htu : turnUnits w = 6 * ε - turnUnit b := by + rw [turnUnits_cons] at ht + rcases hε with he | he <;> rw [he] at ht ⊢ <;> nlinarith + rw [htu] + push_cast + rcases hε with rfl | rfl + · congr 1 + ring + · norm_num only [Int.cast_neg,Int.cast_one] + rw [show Real.pi / 8 * ((-6 : ℝ) - (turnUnit b : ℝ)) = + -((3 / 8 : ℝ) * (2 * Real.pi - Real.pi / 3 * ((-1 : ℝ) * turnUnit b))) by ring] + exact Real.cos_neg _ + +theorem cycle_return_sum (P : Polygon) (v : Vertex) : + (∑ e ∈ cyclesAt P v, wordWeight (omitRoot v e).2) = + if v ∈ P.vertices then + (2 : ℂ) * (criticalActivity : ℂ) ^ (P.length - 1) * + (Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v)) : ℂ) + else 0 := by + classical + by_cases hv : v ∈ P.vertices + · obtain ⟨k,w,hw⟩ := P.exists_rooted v hv + have he := (mem_cyclesAt P v (k,w)).mpr hw + rw [ite_eq_left hv,cyclesAt_eq_pair P v (k,w) he,Finset.sum_pair + (Ne.symm (reverseCycle_ne P v (k,w) he))] + exact cycle_return_weight P v (k,w) he + · rw [ite_eq_right hv] + apply Finset.sum_eq_zero + intro e he + have h := (mem_cyclesAt P v e).mp he + obtain ⟨b,w,hw⟩ := List.exists_cons_of_ne_nil h.1 + apply False.elim + apply hv + rw [h.vertices,hw] + simp [traced] + +theorem return_sum_polygons (D : Finset Vertex) (v : Vertex) (hv : v ∈ D) : + (∑ e ∈ rayReturns D v, wordWeight e.2) = + ∑ P ∈ polygons D, if v ∈ P.vertices then + (2 : ℂ) * (criticalActivity : ℂ) ^ (P.length - 1) * + (Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v)) : ℂ) + else 0 := by + rw [return_sum_cycles D v hv] + apply Finset.sum_congr rfl + intro P hP + exact cycle_return_sum P v + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/SpatialDecay.lean b/lean/OAI/Combinatorics/HoneycombCorridor/SpatialDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..059c962150b89c8cc9fb7e2cbbfa9efad670eb58 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/SpatialDecay.lean @@ -0,0 +1,104 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.LateralMass +import OAI.Combinatorics.HoneycombCorridor.StripWindows + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def shellRatio : ℝ := Real.exp (-tailRate) +noncomputable def spatialConstant : ℝ := + 20 * (1 + ∑' n : ℕ, ((n : ℝ)+1)*shellRatio^n) + + theorem shellRatio_range : 0 < shellRatio ∧ shellRatio < 1 := by + constructor + · exact Real.exp_pos _ + · exact Real.exp_lt_one_iff.mpr (neg_neg_of_pos tailRate_pos) + +theorem shellSeries_summable : Summable (fun n : ℕ => ((n : ℝ)+1)*shellRatio^n) := by + have hn : ‖shellRatio‖ < 1 := by + rw [Real.norm_eq_abs,abs_of_pos shellRatio_range.1] + exact shellRatio_range.2 + have h1 := summable_pow_mul_geometric_of_norm_lt_one 1 hn + have h0 := summable_geometric_of_norm_lt_one hn + simpa only [pow_one,add_mul,one_mul] using h1.add h0 + +theorem spatialConstant_pos : 0 < spatialConstant := by + have h : 0 ≤ ∑' n : ℕ, ((n : ℝ)+1)*shellRatio^n := + tsum_nonneg (fun n => mul_nonneg (by positivity) (pow_nonneg shellRatio_range.1.le _)) + dsimp [spatialConstant] + linarith + +noncomputable def shellIndex (h : ℕ) (v : Vertex) : ℕ := + ⌊|(position v).1|/(2*((h : ℝ)+1))⌋₊ + +theorem shellIndex_bounds (h : ℕ) (v : Vertex) : + (shellIndex h v : ℝ) ≤ |(position v).1|/(2*((h : ℝ)+1)) ∧ + |(position v).1| < 2*((shellIndex h v : ℝ)+1)*((h : ℝ)+1) := by + have hd : (0 : ℝ) < 2*((h : ℝ)+1) := by positivity + refine ⟨Nat.floor_le (div_nonneg (abs_nonneg _) hd.le),?_⟩ + have hh := Nat.lt_floor_add_one (|(position v).1|/(2*((h : ℝ)+1))) + have hi := (div_lt_iff₀ hd).mp hh + dsimp [shellIndex] + nlinarith + +theorem spatial_sum_exp_bound (h : ℕ) (D : Finset Vertex) + (hstrip : ∀ v ∈ D, InStrip h v) : + (∑ v ∈ D, Real.exp (-tailRate*|(position v).1|/(2*(h+1)))) ≤ + spatialConstant*((h : ℝ)+1)^2 := by + classical + let S := D.image (shellIndex h) + have hsplit := Finset.sum_fiberwise_of_maps_to + (fun v hv => Finset.mem_image.mpr ⟨v,hv,rfl⟩ : ∀ v ∈ D, shellIndex h v ∈ S) + (fun v => Real.exp (-tailRate*|(position v).1|/(2*(h+1)))) + rw [← hsplit] + have hs : ∀ n ∈ S, + (∑ v ∈ D with shellIndex h v = n, + Real.exp (-tailRate*|(position v).1|/(2*(h+1)))) ≤ + 20*((n : ℝ)+1)*((h : ℝ)+1)^2 * shellRatio^n := by + intro n hn + have hc := strip_shell_card_le h n D hstrip (D.filter (fun v => shellIndex h v = n)) + (Finset.filter_subset _ _) (by + intro v hv + obtain ⟨hv,he⟩ := Finset.mem_filter.mp hv + simpa only [he] using (shellIndex_bounds h v).2) + calc + _ ≤ ∑ v ∈ D with shellIndex h v = n, shellRatio^n := by + apply Finset.sum_le_sum + intro v hv + obtain ⟨hv,he⟩ := Finset.mem_filter.mp hv + rw [shellRatio,← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + have hl := (shellIndex_bounds h v).1 + rw [he] at hl + have hm := mul_le_mul_of_nonpos_left hl (neg_nonpos.mpr tailRate_pos.le) + calc + -tailRate*|(position v).1|/(2*(h+1)) = + -tailRate*(|(position v).1|/(2*(h+1))) := by ring + _ ≤ -tailRate*(n : ℝ) := hm + _ = (n : ℝ)*-tailRate := by ring + _ = ((D.filter (fun v => shellIndex h v = n)).card : ℝ) * shellRatio^n := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right hc (pow_nonneg shellRatio_range.1.le _) + calc + _ ≤ ∑ n ∈ S, 20*((n : ℝ)+1)*((h : ℝ)+1)^2 * shellRatio^n := + Finset.sum_le_sum hs + _ = 20*((h : ℝ)+1)^2 * ∑ n ∈ S, ((n : ℝ)+1)*shellRatio^n := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro n hn + ring + _ ≤ 20*((h : ℝ)+1)^2 * (∑' n : ℕ, ((n : ℝ)+1)*shellRatio^n) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact shellSeries_summable.sum_le_tsum S + (fun n _ => mul_nonneg (by positivity) (pow_nonneg shellRatio_range.1.le _)) + _ ≤ spatialConstant*((h : ℝ)+1)^2 := by + dsimp [spatialConstant] + nlinarith [sq_nonneg ((h : ℝ)+1)] + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/StripDecay.lean b/lean/OAI/Combinatorics/HoneycombCorridor/StripDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..19df899602a6846eb61f39e7d36c9a1bbeba8001 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/StripDecay.lean @@ -0,0 +1,128 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.ConvexCuts +import OAI.Combinatorics.HoneycombCorridor.RaySeparation + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def lostCut (D : Finset Vertex) (k : Fin 3) (A : ℤ) : Finset (List Bool) := + sourceExits D bottomSource \ sourceExits (upperCut D k A) bottomSource + +noncomputable def rightIndexMass (D : Finset Vertex) (A : ℤ) : ℝ := + positiveWordMass (lostCut D 1 A) + +theorem phasedMass_constant_turn (S : Finset (List Bool)) (m : ℤ) + (h : ∀ w ∈ S, turnUnits w = m) : + phasedWordMass S = (positiveWordMass S : ℂ) * phase (Real.pi/8 * (m : ℝ)) := by + simp only [phasedWordMass,positiveWordMass,Complex.ofReal_sum,Finset.sum_mul] + apply Finset.sum_congr rfl + intro w hw + rw [wordWeight_turnUnits,h w hw,Complex.ofReal_pow] + rfl + +theorem lostCut_phases (D : Finset Vertex) (hD : AdmissiblyConvex D) + (hg : bottomSource.1 ∈ D) (hg' : (reverseGerm bottomSource).1 ∉ D) + (A : ℤ) (hA : 0 < A) : + (∃ b : ℝ, 0 ≤ b ∧ phasedWordMass (lostCut D 1 A) = (b : ℂ)*phase (-Real.pi/4)) ∧ + (∃ a : ℝ, 0 ≤ a ∧ phasedWordMass (lostCut D 2 A) = (a : ℂ)*phase (-Real.pi/8)) := by + have hflux (k : Fin 3) : phasedWordMass (lostCut D k A) = + phasedWordMass (sourceExits (upperCut D k A) bottomSource \ sourceExits D bottomSource) := + flux_subtraction D _ bottomSource (admissiblyConvex_filled D hD) + (admissiblyConvex_filled _ (upperCut_convex D hD k A)) hg' + (fun hm => hg' (upperCut_subset D k A hm)) + constructor + · refine ⟨positiveWordMass (sourceExits (upperCut D 1 A) bottomSource \ sourceExits D bottomSource), + positiveWordMass_nonneg _,?_⟩ + rw [hflux 1,phasedMass_constant_turn _ (-2) (fun w hw => + (new_upperCut_turn D hD hg hg' A hA 1 w hw).1 rfl)] + congr 2 + push_cast + ring + · refine ⟨positiveWordMass (sourceExits (upperCut D 2 A) bottomSource \ sourceExits D bottomSource), + positiveWordMass_nonneg _,?_⟩ + rw [hflux 2,phasedMass_constant_turn _ (-1) (fun w hw => + (new_upperCut_turn D hD hg hg' A hA 2 w hw).2 rfl)] + congr 2 + push_cast + ring + +theorem strip_index_bounds (h : ℕ) (v : Vertex) (hv : InStrip h v) : + boxIndex v 1 ≤ boxIndex v 2 ∧ boxIndex v 2 ≤ boxIndex v 1 + (h : ℤ) := by + cases v <;> simp [InStrip,boxIndex] at * <;> omega + +theorem position_index (v : Vertex) : + (position v).1 = ((boxIndex v 1 : ℝ) + (boxIndex v 2 : ℝ)) / 2 := by + cases v <;> simp [position,boxIndex] <;> ring + +theorem lostCut_nested (h : ℕ) (D : Finset Vertex) (hstrip : ∀ v ∈ D, InStrip h v) + (A : ℤ) : lostCut D 1 A ⊆ lostCut D 2 A ∧ lostCut D 2 A ⊆ lostCut D 1 (A-h) := by + have hm (k : Fin 3) (B : ℤ) (w : List Bool) : w ∈ lostCut D k B ↔ + w ∈ sourceExits D bottomSource ∧ ∃ v ∈ traced bottomSource w, B ≤ boxIndex v k := + mem_lost_upperCut D bottomSource k B w + constructor + · intro w hw + obtain ⟨he,v,hv,hA⟩ := (hm 1 A w).mp hw + have hd := (stopped_traced D bottomSource w ((mem_sourceExits _ _ _).mp he).1).2 v hv + have hi := strip_index_bounds h v (hstrip v hd) + exact (hm 2 A w).mpr ⟨he,v,hv,by omega⟩ + · intro w hw + obtain ⟨he,v,hv,hA⟩ := (hm 2 A w).mp hw + have hd := (stopped_traced D bottomSource w ((mem_sourceExits _ _ _).mp he).1).2 v hv + have hi := strip_index_bounds h v (hstrip v hd) + exact (hm 1 (A-h) w).mpr ⟨he,v,hv,by omega⟩ + +theorem lostCut_real_lower (D : Finset Vertex) (hD : AdmissiblyConvex D) + (hg : bottomSource.1 ∈ D) (hg' : (reverseGerm bottomSource).1 ∉ D) + (k : Fin 3) (A : ℤ) : + Real.cos (3*Real.pi/8)*positiveWordMass (lostCut D k A) ≤ + (phasedWordMass (lostCut D k A)).re := by + rw [phasedWordMass,Complex.re_sum,positiveWordMass,Finset.mul_sum] + apply Finset.sum_le_sum + intro w hw + have he := (Finset.mem_sdiff.mp hw).1 + exact convex_wordWeight_re_lower D hD (bottomSource,w) + ⟨hg,hg',(mem_sourceExits _ _ _).mp he⟩ + +theorem rightIndexMass_step (h : ℕ) (D : Finset Vertex) (hD : AdmissiblyConvex D) + (hg : bottomSource.1 ∈ D) (hstrip : ∀ v ∈ D, InStrip h v) + (A : ℤ) (hA : 0 < A) : + rightIndexMass D A ≤ rayContraction * rightIndexMass D (A-h) := by + have hout := bottomSource_outside_of_strip h D hstrip + obtain ⟨⟨b,hb,hb'⟩,⟨a,_,ha'⟩⟩ := lostCut_phases D hD hg hout A hA + have hn := lostCut_nested h D hstrip A + have hc := separated_rays_contract (lostCut D 2 A) (lostCut D 1 A) hn.1 + (lostCut_real_lower D hD hg hout 1 A) a b hb ha' hb' + exact hc.trans (mul_le_mul_of_nonneg_left (positiveWordMass_mono hn.2) rayContraction_range.1.le) + +theorem rightIndexMass_total_bound (h : ℕ) (D : Finset Vertex) (hD : AdmissiblyConvex D) + (hg : bottomSource.1 ∈ D) (hstrip : ∀ v ∈ D, InStrip h v) (A : ℤ) : + rightIndexMass D A ≤ (Real.cos (3*Real.pi/8))⁻¹ := by + apply (positiveWordMass_mono (show lostCut D 1 A ⊆ sourceExits D bottomSource from + Finset.sdiff_subset)).trans + exact boundary_source_weight_bound D bottomSource hD hg (bottomSource_outside_of_strip h D hstrip) + +theorem rightIndexMass_geometric (h : ℕ) (hh : 1 ≤ h) (D : Finset Vertex) + (hD : AdmissiblyConvex D) (hg : bottomSource.1 ∈ D) + (hstrip : ∀ v ∈ D, InStrip h v) (n : ℕ) : + rightIndexMass D ((n : ℤ)*h) ≤ (Real.cos (3*Real.pi/8))⁻¹ * rayContraction ^ n := by + induction n with + | zero => simpa using rightIndexMass_total_bound h D hD hg hstrip 0 + | succ n ih => + have hA : 0 < ((n+1 : ℕ) : ℤ)*(h : ℤ) := by positivity + have hs := rightIndexMass_step h D hD hg hstrip _ hA + have hi : ((n+1 : ℕ) : ℤ)*(h : ℤ) - h = (n : ℤ)*h := by push_cast; ring + rw [hi] at hs + calc + _ ≤ rayContraction * rightIndexMass D ((n : ℤ)*h) := hs + _ ≤ rayContraction * ((Real.cos (3*Real.pi/8))⁻¹ * rayContraction ^ n) := + mul_le_mul_of_nonneg_left ih rayContraction_range.1.le + _ = _ := by rw [pow_succ]; ring + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/StripWindows.lean b/lean/OAI/Combinatorics/HoneycombCorridor/StripWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..c50df9c535e1729bf4ffa2324da6f36665148fa5 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/StripWindows.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.StripDecay + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +noncomputable def vertexWindow (h M : ℕ) : Finset Vertex := + ((Finset.Icc (-(M : ℤ)) M).product (Finset.Ico (0 : ℤ) h)).biUnion + fun p => {Vertex.up p.1 p.2,Vertex.down p.1 p.2} + +theorem mem_vertexWindow (h M : ℕ) (v : Vertex) : v ∈ vertexWindow h M ↔ + -(M : ℤ) ≤ boxIndex v 1 ∧ boxIndex v 1 ≤ M ∧ InStrip h v := by + cases v <;> + simp [vertexWindow,Finset.mem_biUnion,Finset.mem_Icc, + Finset.mem_Ico,Finset.mem_insert,Finset.mem_singleton,InStrip,boxIndex, + Vertex.up.injEq,Vertex.down.injEq] <;> aesop + +theorem vertexWindow_card_le (h M : ℕ) : (vertexWindow h M).card ≤ 2*(2*M+1)*h := by + have hc := Finset.card_biUnion_le (s := (Finset.Icc (-(M : ℤ)) M).product (Finset.Ico (0 : ℤ) h)) + (t := fun p => {Vertex.up p.1 p.2,Vertex.down p.1 p.2}) + change (vertexWindow h M).card ≤ _ at hc + have hs : (∑ p ∈ (Finset.Icc (-(M : ℤ)) M).product (Finset.Ico (0 : ℤ) h), + ({Vertex.up p.1 p.2,Vertex.down p.1 p.2} : Finset Vertex).card) = 2*(2*M+1)*h := by + have hcast : ((M : ℤ) + 1 + M).toNat = 2*M+1 := by omega + simp [Finset.card_product,Int.card_Icc,Int.card_Ico,hcast] + ring + exact hc.trans_eq hs + +theorem bounded_position_mem_window (h n : ℕ) (v : Vertex) (hv : InStrip h v) + (hx : |(position v).1| < 2*((n : ℝ)+1)*(h+1)) : + v ∈ vertexWindow h ((2*(n+1)+1)*(h+1)) := by + have hi := strip_index_bounds h v hv + have hi0 : (boxIndex v 1 : ℝ) ≤ (boxIndex v 2 : ℝ) := by exact_mod_cast hi.1 + have hi1 : (boxIndex v 2 : ℝ) ≤ (boxIndex v 1 : ℝ) + h := by exact_mod_cast hi.2 + have hab := abs_lt.mp hx + rw [position_index] at hab + apply (mem_vertexWindow _ _ _).mpr + refine ⟨?_,?_,hv⟩ + · have : -(((2*(n+1)+1)*(h+1) : ℕ) : ℝ) ≤ (boxIndex v 1 : ℝ) := by + push_cast + nlinarith [Nat.cast_nonneg (α := ℝ) h] + exact_mod_cast this + · have : (boxIndex v 1 : ℝ) ≤ (((2*(n+1)+1)*(h+1) : ℕ) : ℝ) := by + push_cast + nlinarith [Nat.cast_nonneg (α := ℝ) h] + exact_mod_cast this + +theorem strip_shell_card_le (h n : ℕ) (D : Finset Vertex) + (hstrip : ∀ v ∈ D, InStrip h v) (S : Finset Vertex) (hSD : S ⊆ D) + (hS : ∀ v ∈ S, |(position v).1| < 2*((n : ℝ)+1)*(h+1)) : + (S.card : ℝ) ≤ 20*((n : ℝ)+1)*((h : ℝ)+1)^2 := by + have hsub : S ⊆ vertexWindow h ((2*(n+1)+1)*(h+1)) := by + intro v hv + exact bounded_position_mem_window h n v (hstrip v (hSD hv)) (hS v hv) + have hc := (Finset.card_le_card hsub).trans (vertexWindow_card_le h _) + have hc' : (S.card : ℝ) ≤ (2*(2*((2*(n+1)+1)*(h+1))+1)*h : ℕ) := by exact_mod_cast hc + push_cast at hc' + nlinarith [Nat.cast_nonneg (α := ℝ) h,Nat.cast_nonneg (α := ℝ) n, + sq_nonneg ((h : ℝ)+1),mul_nonneg (Nat.cast_nonneg (α := ℝ) n) (sq_nonneg (h : ℝ))] + + + +theorem vertexWindow_convex (h M : ℕ) : AdmissiblyConvex (vertexWindow h M) := by + apply admissiblyConvex_of_box _ + (fun k => if k = 0 then 0 else -(M : ℤ)) + (fun k => if k = 0 then h else if k = 1 then M+1 else M+h+1) + intro v + rw [mem_vertexWindow] + constructor + · rintro ⟨hlo,hhi,hstrip⟩ k + have hb := strip_index_bounds h v hstrip + fin_cases k <;> simp only [Fin.zero_eta,ite_true,Fin.reduceEq,ite_false] + · exact hstrip + · change -(M : ℤ) ≤ boxIndex v 1 ∧ boxIndex v 1 < (M : ℤ)+1 + omega + · change -(M : ℤ) ≤ boxIndex v 2 ∧ boxIndex v 2 < (M : ℤ)+h+1 + omega + · intro hv + have h0 := hv 0 + have h1 := hv 1 + simp only [Fin.reduceEq,ite_false,ite_true] at h0 h1 + exact ⟨h1.1,by omega,h0⟩ + +theorem bottomSource_mem_window (h M : ℕ) (hh : 1 ≤ h) : + bottomSource.1 ∈ vertexWindow h M := by + rw [mem_vertexWindow] + simp only [bottomSource,boxIndex,Fin.reduceEq,ite_false,ite_true,InStrip] + omega + +theorem vertexWindow_strip (h M : ℕ) : ∀ v ∈ vertexWindow h M, InStrip h v := by + intro v hv + exact ((mem_vertexWindow _ _ _).mp hv).2.2 + +theorem finite_vertices_in_window (h : ℕ) (S : Finset Vertex) + (hs : ∀ v ∈ S, InStrip h v) : ∃ M : ℕ, S ⊆ vertexWindow h M := by + let M := S.sup (fun v => (boxIndex v 1).natAbs) + refine ⟨M,?_⟩ + intro v hv + have ha : (boxIndex v 1).natAbs ≤ M := Finset.le_sup (f := fun v => (boxIndex v 1).natAbs) hv + have ha' : (|(boxIndex v 1)| : ℤ) ≤ (M : ℤ) := by + rw [← Int.natCast_natAbs] + exact_mod_cast ha + have hab := abs_le.mp ha' + exact (mem_vertexWindow _ _ _).mpr ⟨hab.1,hab.2,hs v hv⟩ + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/Traversals.lean b/lean/OAI/Combinatorics/HoneycombCorridor/Traversals.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5ace7060bf55b3cc371679ced76080b233fbfc2 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/Traversals.lean @@ -0,0 +1,203 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.CollisionCancellation + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +theorem outgoingSlot_injective (g : Germ) : Function.Injective (outgoingSlot g) := by + intro b c h + rcases g with ⟨v,k⟩ + fin_cases k <;> cases b <;> cases c <;> simp [outgoingSlot] at h ⊢ + +theorem local_contour_support (q : EdgeIndex →₀ ℤ) (g : Germ) (b : Bool) + (hq : LocalContour q g b) (k : Fin 3) : + edgeOf (g.1,k) ∈ q.support ↔ k = g.2 ∨ k = outgoingSlot g b := by + rw [Finsupp.mem_support_iff] + change (¬ q (edgeOf (g.1,k)) = 0) ↔ _ + rw [← orientedFlow_zero_iff q (g.1,k),hq k] + have hn := outgoingSlot_ne g b + by_cases hi : k = g.2 + · subst k + simp [Ne.symm hn] + · by_cases ho : k = outgoingSlot g b + · subst k + simp [hn] + · simp [hi,ho] + +theorem local_contour_unique (q r : EdgeIndex →₀ ℤ) (hs : q.support = r.support) + (g : Germ) (b c : Bool) (hq : LocalContour q g b) (hr : LocalContour r g c) : b = c := by + apply outgoingSlot_injective g + have hm : edgeOf (g.1,outgoingSlot g b) ∈ r.support := by + rw [← hs] + exact (local_contour_support q g b hq _).mpr (Or.inr rfl) + have h := (local_contour_support r g c hr _).mp hm + exact h.resolve_left (outgoingSlot_ne g b) + +theorem stopped_contour_unique (D : Finset Vertex) (g : Germ) (w u : List Bool) + (q r : EdgeIndex →₀ ℤ) (hs : q.support = r.support) + (hw : Stopped D g w) (hu : Stopped D g u) + (hqw : WordContour q g w) (hru : WordContour r g u) : w = u := by + induction w generalizing D g u with + | nil => + cases u with + | nil => rfl + | cons c u => exact (hw hu.1).elim + | cons b w ih => + cases u with + | nil => exact (hu hw.1).elim + | cons c u => + have he := local_contour_unique q r hs g b c hqw.1 hru.1 + subst c + exact congrArg (List.cons b) (ih (D.erase g.1) (advance g b) u hw.2 hu.2 hqw.2 hru.2) + +theorem closed_stopped (g : Germ) (w : List Bool) (hne : w ≠ []) + (hN : (traced g w).Nodup) (hc : terminalGerm g w = g) : + Stopped (traced g w).toFinset g w := by + apply (stopped_iff_trace _ _ _).mpr + refine ⟨hN,by simp,Or.inr ?_⟩ + rw [hc] + obtain ⟨b,u,rfl⟩ := List.exists_cons_of_ne_nil hne + simp [traced] + +theorem closed_traversal_unique (g : Germ) (w u : List Bool) + (hwne : w ≠ []) (hwN : (traced g w).Nodup) (hwc : terminalGerm g w = g) + (hune : u ≠ []) (huN : (traced g u).Nodup) (huc : terminalGerm g u = g) + (hs : (wordFlow g w).support = (wordFlow g u).support) : w = u := by + have hD : (traced g w).toFinset = (traced g u).toFinset := by + rw [← wordFlow_edgeVertices g w hwN hwc,← wordFlow_edgeVertices g u huN huc,hs] + have hu := closed_stopped g u hune huN huc + rw [← hD] at hu + exact stopped_contour_unique (traced g w).toFinset g w u _ _ hs + (closed_stopped g w hwne hwN hwc) hu + (simple_closed_word_contour g w hwN hwc) (simple_closed_word_contour g u huN huc) + +namespace Polygon + +def Traverses (P : Polygon) (g : Germ) (w : List Bool) : Prop := + w ≠ [] ∧ (traced g w).Nodup ∧ terminalGerm g w = g ∧ (wordFlow g w).support = P.val + +theorem traverses_chosen (P : Polygon) : P.Traverses P.germ P.turns := P.traversal + +theorem Traverses.vertices {P : Polygon} {g : Germ} {w : List Bool} + (h : P.Traverses g w) : P.vertices = (traced g w).toFinset := by + change edgeVertices P.val = _ + rw [← h.2.2.2] + exact wordFlow_edgeVertices g w h.2.1 h.2.2.1 + +theorem Traverses.unique {P : Polygon} {g : Germ} {w u : List Bool} + (h : P.Traverses g w) (h' : P.Traverses g u) : w = u := + closed_traversal_unique g w u h.1 h.2.1 h.2.2.1 h'.1 h'.2.1 h'.2.2.1 + (h.2.2.2.trans h'.2.2.2.symm) + +theorem Traverses.reverse {P : Polygon} {g : Germ} {b : Bool} {w : List Bool} + (h : P.Traverses g (b :: w)) : + P.Traverses (reverseLoopGerm g b) ((!b) :: reverseTurns w) := by + refine ⟨by simp,reverse_loop_nodup g b w h.2.2.1 h.2.1, + reverse_loop_terminal g b w h.2.2.1,?_⟩ + rw [reverse_loop_flow g b w h.2.2.1,Finsupp.support_neg,h.2.2.2] + +theorem exists_rooted (P : Polygon) (v : Vertex) (hv : v ∈ P.vertices) : + ∃ (k : Fin 3) (w : List Bool), P.Traverses (v,k) w := by + rw [P.vertices_traversal,List.mem_toFinset] at hv + obtain ⟨u,b,t,he,hv⟩ := mem_traced_split P.germ P.turns v hv + have hN : (traced P.germ (u ++ b :: t)).Nodup := he ▸ P.traversal.2.1 + have hc : terminalGerm P.germ (u ++ b :: t) = P.germ := he ▸ P.traversal.2.2.1 + obtain ⟨hN',hc',hq'⟩ := closed_word_rotate P.germ u (b :: t) hN hc + have hq : (wordFlow (terminalGerm P.germ u) ((b :: t) ++ u)).support = P.val := by + rw [hq',← he,P.traversal.2.2.2] + have ht : terminalGerm P.germ u = (v,(terminalGerm P.germ u).2) := Prod.ext hv rfl + rw [ht] at hN' hc' hq + exact ⟨(terminalGerm P.germ u).2,(b :: t) ++ u,by simp,hN',hc',hq⟩ + +end Polygon + +def IsCycleAt (P : Polygon) (v : Vertex) (e : Fin 3 × List Bool) : Prop := + P.Traverses (v,e.1) e.2 + +noncomputable def cyclesAt (P : Polygon) (v : Vertex) : Finset (Fin 3 × List Bool) := by + classical + exact (Finset.univ.biUnion fun k : Fin 3 => + (leaves P.vertices (v,k)).image fun w => (k,w)).filter (IsCycleAt P v) + +@[simp] theorem mem_cyclesAt (P : Polygon) (v : Vertex) (e : Fin 3 × List Bool) : + e ∈ cyclesAt P v ↔ IsCycleAt P v e := by + classical + rw [cyclesAt,Finset.mem_filter] + constructor + · exact And.right + · intro he + refine ⟨Finset.mem_biUnion.mpr ⟨e.1,Finset.mem_univ _,Finset.mem_image.mpr + ⟨e.2,?_,rfl⟩⟩,he⟩ + apply (mem_leaves_iff _ _ _).mpr + rw [he.vertices] + exact closed_stopped _ _ he.1 he.2.1 he.2.2.1 + +def reverseCycle (v : Vertex) (e : Fin 3 × List Bool) : Fin 3 × List Bool := + match e.2 with + | [] => e + | b :: w => (outgoingSlot (v,e.1) b,(!b) :: reverseTurns w) + +theorem cycle_reverse_mem (P : Polygon) (v : Vertex) (e : Fin 3 × List Bool) + (he : e ∈ cyclesAt P v) : reverseCycle v e ∈ cyclesAt P v := by + rw [mem_cyclesAt] at he ⊢ + obtain ⟨b,w,hbw⟩ := List.exists_cons_of_ne_nil he.1 + have hr : P.Traverses (v,e.1) (b :: w) := hbw ▸ he + have hrev := hr.reverse + simpa only [IsCycleAt,reverseCycle,hbw,reverseLoopGerm] using hrev + +theorem cyclesAt_eq_pair (P : Polygon) (v : Vertex) (e : Fin 3 × List Bool) + (he : e ∈ cyclesAt P v) : cyclesAt P v = {e,reverseCycle v e} := by + classical + have htr := (mem_cyclesAt P v e).mp he + obtain ⟨b,w,hbw⟩ := List.exists_cons_of_ne_nil htr.1 + have hw : P.Traverses (v,e.1) (b :: w) := hbw ▸ htr + have hr := hw.reverse + ext f + constructor + · intro hf + have hftr := (mem_cyclesAt P v f).mp hf + obtain ⟨c,u,hcu⟩ := List.exists_cons_of_ne_nil hftr.1 + have hf' : P.Traverses (v,f.1) (c :: u) := hcu ▸ hftr + have hm : edgeOf (v,f.1) ∈ (wordFlow (v,e.1) (b :: w)).support := by + rw [hw.2.2.2,← hf'.2.2.2] + apply (local_contour_support _ (v,f.1) c + (simple_closed_word_contour _ _ hf'.2.1 hf'.2.2.1).1 _).mpr + exact Or.inl rfl + have hslots := (local_contour_support _ (v,e.1) b + (simple_closed_word_contour _ _ hw.2.1 hw.2.2.1).1 f.1).mp hm + simp only [Finset.mem_insert,Finset.mem_singleton] + rcases hslots with hs | hs + · left + apply Prod.ext hs + have hst : P.Traverses (v,e.1) f.2 := by + simpa only [IsCycleAt,hs] using hftr + exact hst.unique htr + · right + have hst : P.Traverses (reverseLoopGerm (v,e.1) b) f.2 := by + simpa only [IsCycleAt,hs,reverseLoopGerm] using hftr + have heq := hst.unique hr + apply Prod.ext + · simpa only [reverseCycle,hbw] using hs + · simpa only [reverseCycle,hbw] using heq + · intro hf + simp only [Finset.mem_insert,Finset.mem_singleton] at hf + rcases hf with rfl | rfl + · exact he + · exact cycle_reverse_mem P v e he + +theorem reverseCycle_ne (P : Polygon) (v : Vertex) (e : Fin 3 × List Bool) + (he : e ∈ cyclesAt P v) : reverseCycle v e ≠ e := by + obtain ⟨b,w,hbw⟩ := List.exists_cons_of_ne_nil ((mem_cyclesAt P v e).mp he).1 + intro hh + have hs := congrArg Prod.fst hh + simp only [reverseCycle,hbw] at hs + exact outgoingSlot_ne (v,e.1) b hs + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/HoneycombCorridor/VisitRecursion.lean b/lean/OAI/Combinatorics/HoneycombCorridor/VisitRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..f83778b31af39482789ec4ba4c546be36a20fdd0 --- /dev/null +++ b/lean/OAI/Combinatorics/HoneycombCorridor/VisitRecursion.lean @@ -0,0 +1,222 @@ +import Mathlib +import OAI.Combinatorics.HoneycombCorridor.CollisionWeights +import OAI.Combinatorics.HoneycombCorridor.ConvexDomains + +namespace OAI + +noncomputable section + +namespace PolynomialVacuumBridge.Corridor + +theorem rayLeaves_balance (D : Finset Vertex) (v : Vertex) : + (∑ e ∈ rayLeaves D v, wordWeight e.2) = 3 := by + rw [rayLeaves,sum_record_fibers] + simp only [leaf_balance,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + norm_num + +theorem rayExits_filter (D : Finset Vertex) (v : Vertex) : + rayExits D v = (rayLeaves D v).filter (fun e => (stemEnd v e).1 ∉ D) := rfl + +theorem rayLeaves_split (D : Finset Vertex) (v : Vertex) (hv : v ∈ D) : + (∑ e ∈ rayLeaves D v, wordWeight e.2) = + (∑ e ∈ rayExits D v, wordWeight e.2) + + (∑ e ∈ rayReturns D v, wordWeight e.2) + + (∑ e ∈ rayCollisions D v, wordWeight e.2) := by + classical + rw [rayExits_filter,rayReturns,rayCollisions] + simp only [Finset.sum_filter] + rw [← Finset.sum_add_distrib,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro e he + change wordWeight e.2 = (if (stemEnd v e).1 ∉ D then _ else _) + + (if (stemEnd v e).1 = v then _ else _) + _ + by_cases hD : (stemEnd v e).1 ∈ D + · by_cases hEq : (stemEnd v e).1 = v <;> simp [hD,hEq,hv] + · have hEq : (stemEnd v e).1 ≠ v := fun h => hD (h.symm ▸ hv) + simp [hD,hEq] + +theorem complex_visit_balance (D : Finset Vertex) (v : Vertex) (hD : Filled D) (hv : v ∈ D) : + (3 : ℂ) = visitSum D v + + (∑ P ∈ polygons D, if v ∈ P.vertices then + (2 : ℂ) * (criticalActivity : ℂ) ^ (P.length - 1) * + (Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v)) : ℂ) else 0) + + (∑ P ∈ polygons D, if v ∈ P.interior then + -2 * (criticalActivity : ℂ) ^ P.length * visitSum P.interior v else 0) := by + have h := rayLeaves_split D v hv + rw [rayLeaves_balance,rayExits_eq_visitSum D v hD hv, + return_sum_polygons D v hv,collision_sum_polygons D v hD] at h + exact h + +theorem finite_visit_recursion : FiniteVisitRecursion := by + classical + intro D v hD hv + have h := congrArg Complex.reAddGroupHom (complex_visit_balance D v hD hv) + simp only [map_add,map_sum,Complex.coe_reAddGroupHom,← Complex.ofReal_pow] at h + have hr : (∑ P ∈ polygons D, (if v ∈ P.vertices then + (2 : ℂ) * (criticalActivity ^ (P.length - 1) : ℝ) * + (Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v)) : ℂ) else 0).re) = + -(∑ P ∈ polygons D, if v ∈ P.vertices then + 2 * criticalActivity ^ (P.length - 1) * + (-Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v))) else 0) := by + rw [← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro P hP + split_ifs <;> simp only [Complex.ofReal_re,Complex.ofReal_im,Complex.zero_re, + Complex.mul_re,Complex.mul_im,show (2 : ℂ).re = 2 from rfl, show (2 : ℂ).im = 0 from rfl,mul_zero,zero_mul,sub_zero,add_zero] + all_goals ring + have hc : (∑ P ∈ polygons D, (if v ∈ P.interior then + -(2 : ℂ) * (criticalActivity ^ P.length : ℝ) * visitSum P.interior v else 0).re) = + -(∑ P ∈ polygons D, if v ∈ P.interior then + 2 * criticalActivity ^ P.length * visitMass P.interior v else 0) := by + rw [← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro P hP + split_ifs <;> simp only [visitMass,Complex.mul_re,Complex.mul_im,Complex.neg_re, + Complex.neg_im,show (2 : ℂ).re = 2 from rfl, show (2 : ℂ).im = 0 from rfl, + Complex.ofReal_re,Complex.ofReal_im,Complex.zero_re,mul_zero,zero_mul, + neg_zero,sub_zero,add_zero] + all_goals ring + rw [hr,hc] at h + change _ = visitMass D v + _ + _ at h + norm_num only [show (3 : ℂ).re = 3 from rfl] at h + linarith + + +theorem criticalActivity_pos : 0 < criticalActivity := by + unfold criticalActivity + exact inv_pos.mpr (mul_pos (by norm_num) critical_cos_pos) + +theorem Polygon.ccwTurn_cases (P : Polygon) (v : Vertex) (hv : v ∈ P.vertices) : + P.ccwTurn v = Real.pi / 3 ∨ P.ccwTurn v = -(Real.pi / 3) := by + obtain ⟨k,w,hw⟩ := P.exists_rooted v hv + obtain ⟨b,u,rfl⟩ := List.exists_cons_of_ne_nil hw.1 + obtain ⟨p,ε,hp,hpne,hε,hvals⟩ := simple_closed_word_indicator (v,k) (b :: u) + (by simp) hw.2.1 hw.2.2.1 + have he := P.ccwTurn_traversal (v,k) b u hw p ε hp hε hvals + rcases hε with rfl | rfl <;> cases b <;> simp [turnUnit] at he <;> simp [he] + +theorem through_cos_pos (P : Polygon) (v : Vertex) (hv : v ∈ P.vertices) : + 0 < -Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v)) := by + have hpi := Real.pi_pos + rcases P.ccwTurn_cases v hv with h | h + · rw [h,show (3 / 8 : ℝ) * (2 * Real.pi - Real.pi / 3) = Real.pi - 3 * Real.pi / 8 by ring, + Real.cos_pi_sub,neg_neg] + apply Real.cos_pos_of_mem_Ioo + constructor <;> linarith + · rw [h,show (3 / 8 : ℝ) * (2 * Real.pi - -(Real.pi / 3)) = Real.pi - Real.pi / 8 by ring, + Real.cos_pi_sub,neg_neg] + exact critical_cos_pos + +theorem recursion_coefficients_positive (P : Polygon) : + 0 < 2 * criticalActivity ^ P.length ∧ ∀ v ∈ P.vertices, + 0 < 2 * criticalActivity ^ (P.length - 1) * + (-Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v))) := by + constructor + · exact mul_pos (by norm_num) (pow_pos criticalActivity_pos _) + · intro v hv + exact mul_pos (mul_pos (by norm_num) (pow_pos criticalActivity_pos _)) (through_cos_pos P v hv) + +theorem visitMass_ge_three (D : Finset Vertex) (v : Vertex) (hD : Filled D) (hv : v ∈ D) : + 3 ≤ visitMass D v := by + classical + induction hn : D.card using Nat.strong_induction_on generalizing D with + | h n ih => + rw [finite_visit_recursion D v hD hv] + have hp : 0 ≤ ∑ P ∈ polygons D, if v ∈ P.vertices then + 2 * criticalActivity ^ (P.length - 1) * + (-Real.cos ((3 / 8 : ℝ) * (2 * Real.pi - P.ccwTurn v))) else 0 := by + apply Finset.sum_nonneg + intro P hP + split_ifs with hvP + · exact (recursion_coefficients_positive P).2 v hvP |>.le + · exact le_rfl + have hi : 0 ≤ ∑ P ∈ polygons D, if v ∈ P.interior then + 2 * criticalActivity ^ P.length * visitMass P.interior v else 0 := by + apply Finset.sum_nonneg + intro P hP + split_ifs with hvP + · have hl : P.interior.card < n := hn ▸ P.interior_card_lt D hD hP + have hmass := ih P.interior.card hl P.interior P.interior_filled hvP rfl + exact mul_nonneg (recursion_coefficients_positive P).1.le (by linarith) + · exact le_rfl + linarith + +theorem polygons_mono {D E : Finset Vertex} (hDE : D ⊆ E) : polygons D ⊆ polygons E := by + intro P hP + exact (mem_polygons E P).mpr ((mem_polygons D P).mp hP |>.trans hDE) + +theorem visitMass_mono (D E : Finset Vertex) (v : Vertex) + (hD : Filled D) (hE : Filled E) (hDE : D ⊆ E) (hv : v ∈ D) : + visitMass D v ≤ visitMass E v := by + classical + rw [finite_visit_recursion D v hD hv,finite_visit_recursion E v hE (hDE hv)] + apply add_le_add + · apply add_le_add le_rfl + apply Finset.sum_le_sum_of_subset_of_nonneg (polygons_mono hDE) + intro P hP hn + split_ifs with hvP + · exact (recursion_coefficients_positive P).2 v hvP |>.le + · exact le_rfl + · apply Finset.sum_le_sum_of_subset_of_nonneg (polygons_mono hDE) + intro P hP hn + split_ifs with hvP + · have hmass := visitMass_ge_three P.interior v P.interior_filled hvP + exact mul_nonneg (recursion_coefficients_positive P).1.le (by linarith) + · exact le_rfl + + + +theorem wordWeight_re (w : List Bool) : (wordWeight w).re = + criticalActivity ^ w.length * Real.cos (Real.pi / 8 * (turnUnits w : ℝ)) := by + rw [wordWeight_turnUnits] + simp only [← Complex.ofReal_pow,Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im, + zero_mul,sub_zero,Complex.exp_ofReal_mul_I_re] + +theorem wordWeight_re_le (w : List Bool) : + (wordWeight w).re ≤ criticalActivity ^ w.length := by + rw [wordWeight_re] + exact mul_le_of_le_one_right (pow_nonneg criticalActivity_pos.le _) (Real.cos_le_one _) + +theorem bounded_turn_cos (m : ℤ) (hm : -3 ≤ m ∧ m ≤ 3) : + Real.cos (3 * Real.pi / 8) ≤ Real.cos (Real.pi / 8 * (m : ℝ)) := by + have hlow : -(3 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm.1 + have hhigh : (m : ℝ) ≤ 3 := by exact_mod_cast hm.2 + have habs : |Real.pi / 8 * (m : ℝ)| ≤ 3 * Real.pi / 8 := by + apply abs_le.mpr + constructor <;> nlinarith [Real.pi_pos] + have h := Real.cos_le_cos_of_nonneg_of_le_pi (abs_nonneg (Real.pi / 8 * (m : ℝ))) + (show 3 * Real.pi / 8 ≤ Real.pi by linarith [Real.pi_pos]) habs + simpa only [Real.cos_abs] using h + +theorem convex_wordWeight_re_lower (D : Finset Vertex) (hD : AdmissiblyConvex D) + (e : Germ × List Bool) (he : IsExcursion D e) : + Real.cos (3 * Real.pi / 8) * criticalActivity ^ e.2.length ≤ (wordWeight e.2).re := by + rw [wordWeight_re,mul_comm (Real.cos _)] + exact mul_le_mul_of_nonneg_left + (bounded_turn_cos (turnUnits e.2) (convex_excursion_turn_bound D hD e he)) + (pow_nonneg criticalActivity_pos.le _) + +theorem visitMass_excursion_upper (D : Finset Vertex) (v : Vertex) : + visitMass D v ≤ excursionMass D v := by + classical + simp only [visitMass,visitSum,excursionMass,Complex.re_sum] + apply Finset.sum_le_sum + intro e he + split_ifs <;> try simp only [Complex.zero_re,le_refl] + exact wordWeight_re_le _ + +theorem visitMass_excursion_lower (D : Finset Vertex) (hD : AdmissiblyConvex D) + (v : Vertex) : + Real.cos (3 * Real.pi / 8) * excursionMass D v ≤ visitMass D v := by + classical + simp only [visitMass,visitSum,excursionMass,Complex.re_sum,Finset.mul_sum] + apply Finset.sum_le_sum + intro e he + split_ifs <;> try simp only [mul_zero,Complex.zero_re,le_refl] + exact convex_wordWeight_re_lower D hD e ((mem_excursions D e).mp he) + +end PolynomialVacuumBridge.Corridor + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryCoordinates.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..f25426a4800cda8bc82663650dd68dfac5fb3455 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryCoordinates.lean @@ -0,0 +1,64 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Integration.BinaryCoordinates + +abbrev Coordinates (n : Nat) := Fin n → Bool + +def pack : {n : Nat} → Coordinates n → BitVec n + | 0, _ => 0 + | _ + 1, f => BitVec.concat (pack (fun i => f i.succ)) (f 0) + +def unpack {n : Nat} (v : BitVec n) : Coordinates n := + fun i => v.getLsbD i.val + +theorem pack_get {n : Nat} (f : Coordinates n) (i : Fin n) : + (pack f).getLsbD i.val = f i := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + refine Fin.cases ?_ (fun j => ?_) i + · exact BitVec.getLsbD_concat_zero + · exact (BitVec.getLsbD_concat_succ).trans (ih (fun j => f j.succ) j) + +theorem unpack_pack {n : Nat} (f : Coordinates n) : unpack (pack f) = f := by + funext i + exact pack_get f i + +theorem pack_unpack {n : Nat} (v : BitVec n) : pack (unpack v) = v := by + apply BitVec.eq_of_getLsbD_eq + intro i hi + exact pack_get (unpack v) ⟨i, hi⟩ + +theorem unpack_injective {n : Nat} : Function.Injective (@unpack n) := by + intro u v h + have h' := congrArg pack h + simpa only [pack_unpack] using h' + +theorem pack_injective {n : Nat} : Function.Injective (@pack n) := by + intro u v h + have h' := congrArg unpack h + simpa only [unpack_pack] using h' + +theorem unpack_xor {n : Nat} (u v : BitVec n) : + unpack (u ^^^ v) = fun i => (unpack u i ^^ unpack v i) := by + funext i + exact BitVec.getLsbD_xor + +theorem pack_xor {n : Nat} (u v : Coordinates n) : + pack (fun i => (u i ^^ v i)) = pack u ^^^ pack v := by + apply unpack_injective + rw [unpack_pack, unpack_xor, unpack_pack, unpack_pack] + +theorem unpack_zero {n : Nat} : unpack (0 : BitVec n) = fun _ => false := by + funext i + simp [unpack] + +theorem pack_zero {n : Nat} : pack (fun _ : Fin n => false) = 0 := by + apply unpack_injective + rw [unpack_pack, unpack_zero] + +end IndependentSetsGames.Integration.BinaryCoordinates + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryEvents.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryEvents.lean new file mode 100644 index 0000000000000000000000000000000000000000..22083cd0cfef00c9e756160ade6df911694523ab --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryEvents.lean @@ -0,0 +1,199 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.BinarySyntax + +namespace OAI + +namespace LargeIndependentSets.BinarySyntax + +inductive Mark where + | first (r : Fin 3) + | empty + deriving DecidableEq + +def event : Phase → Bool → Option Mark + | .sign r true, _ => some (.first r) + | .widthStart, false => some .empty + | _, _ => none + +def shift (k : ℕ) (xs : List (ℕ × Mark)) : List (ℕ × Mark) := + xs.map (fun x => (k+x.1,x.2)) + +@[simp] lemma shift_nil (k : ℕ) : shift k []=[] := rfl +@[simp] lemma shift_cons (k : ℕ) (p : ℕ) (e : Mark) (xs : List (ℕ × Mark)) : + shift k ((p,e)::xs)=(k+p,e)::shift k xs := rfl +@[simp] lemma shift_append (k : ℕ) (a b : List (ℕ × Mark)) : + shift k (a++b)=shift k a++shift k b := List.map_append +@[simp] lemma shift_shift (j k : ℕ) (xs : List (ℕ × Mark)) : + shift j (shift k xs)=shift (j+k) xs := by simp [shift,List.map_map,Function.comp_def,Nat.add_assoc] +@[simp] lemma shift_zero (xs : List (ℕ × Mark)) : shift 0 xs=xs := by simp [shift] + +def events (q : Phase) : List Bool → List (ℕ × Mark) + | [] => [] + | b::s => ((event q b).toList.map (fun e => (0,e))) ++ shift 1 (events (transition q b) s) + +lemma events_append (q : Phase) (a b : List Bool) : + events q (a++b)=events q a++shift a.length (events (run q a) b) := by + induction a generalizing q with + | nil => simp [events] + | cons x a ih => + simp only [List.cons_append,events,ih,shift_append,shift_shift,List.length_cons,run_cons, + List.append_assoc,Nat.add_comm 1] + +lemma events_header (s : List Bool) : events .headerMark (frame s)=[] := by + induction s with + | nil => rfl + | cons b s ih => simp [frame,events,transition,event,ih] + +lemma events_name (r : Fin 3) (s : List Bool) : events (.mark r) (frame s)=[] := by + induction s with + | nil => rfl + | cons b s ih => simp [frame,events,transition,event,ih] + +lemma events_literal (r : Fin 3) (first : Bool) (l : Literal) : + events (.sign r first) (literalBits l)=if first then [(0,.first r)] else [] := by + cases first <;> simp [literalBits,nameBits,events,event,transition,events_name] + +def clauseMark (C : List Literal) : ℕ × Mark := + if C=[] then (0,.empty) else ((nameBits C.length).length,.first ⟨(C.length-1)%3,Nat.mod_lt _ (by decide)⟩) + +lemma events_clause (C : List Literal) (hw : C.length ≤ 3) : + events .widthStart (clauseBits C)=[clauseMark C] := by + cases C with + | nil => rfl + | cons a C => + cases C with + | nil => + simp only [clauseMark,clauseBits,List.cons_ne_nil,ite_false,List.length_cons,List.length_nil, + List.flatMap_cons,List.flatMap_nil] + change events .widthStart ([true,true,false]++(literalBits a++[])) = [(3,.first 0)] + rw [events_append,events_append] + simp [events,event,transition,run,events_literal] + | cons b C => + cases C with + | nil => + simp only [clauseMark,clauseBits,List.cons_ne_nil,ite_false,List.length_cons,List.length_nil, + List.flatMap_cons,List.flatMap_nil] + change events .widthStart ([true,false,true,true,false]++(literalBits a++(literalBits b++[]))) = [(5,.first 1)] + rw [events_append] + change [] ++ shift 5 (events (.sign 1 true) (literalBits a++(literalBits b++[]))) = _ + rw [events_append,events_append,run_literal] + simp [events_literal,events,after] + | cons c C => + have hc : C=[] := by apply List.length_eq_zero_iff.mp; simp only [List.length_cons] at hw; omega + subst C + simp only [clauseMark,clauseBits,List.cons_ne_nil,ite_false,List.length_cons,List.length_nil, + List.flatMap_cons,List.flatMap_nil] + change events .widthStart ([true,true,true,true,false]++(literalBits a++(literalBits b++(literalBits c++[])))) = [(5,.first 2)] + rw [events_append] + change [] ++ shift 5 (events (.sign 2 true) (literalBits a++(literalBits b++(literalBits c++[])))) = _ + rw [events_append,run_literal] + change shift 5 (events (.sign 2 true) (literalBits a) ++ + shift (literalBits a).length (events (.sign 1 false) (literalBits b++(literalBits c++[])))) = _ + rw [events_append,events_append,run_literal] + simp [events_literal,events,after] + +lemma mem_shift (k p : ℕ) (e : Mark) (xs : List (ℕ × Mark)) : + (p,e) ∈ shift k xs ↔ ∃ j, (j,e) ∈ xs ∧ p=k+j := by + simp only [shift,List.mem_map,Prod.exists,Prod.mk.injEq] + constructor + · rintro ⟨j,d,h,he,hd⟩; subst d; exact ⟨j,h,he.symm⟩ + · rintro ⟨j,h,rfl⟩; exact ⟨j,e,h,rfl,rfl⟩ + +lemma events_complete (q : Phase) (s : List Bool) (p : ℕ) (hp : p < s.length) (e : Mark) : + (p,e) ∈ events q s ↔ event (run q (s.take p)) s[p]=some e := by + induction s generalizing q p with + | nil => simp at hp + | cons b s ih => + cases p with + | zero => + simp only [events,List.mem_append,List.mem_map,Option.mem_toList,Prod.mk.injEq, + true_and,mem_shift,List.take_zero,run_nil,List.getElem_cons_zero] + constructor + · rintro (⟨e',he',rfl⟩|⟨j,hj,he⟩) + · exact he' + · omega + · intro h; exact Or.inl ⟨e,h,rfl⟩ + | succ p => + have hp' : p < s.length := by simpa using hp + simp only [events,List.mem_append,List.mem_map,Option.mem_toList,Prod.mk.injEq, + show ¬(0=p+1) by omega,false_and,and_false,exists_false, false_or,mem_shift, + List.take_succ_cons,run_cons,List.getElem_cons_succ] + rw [← ih (transition q b) p hp'] + constructor + · rintro ⟨j,hj,he⟩ + have : j=p := by omega + subst j + exact hj + · intro h; exact ⟨p,h,by omega⟩ + +lemma event_clause_location (Cs : List (List Literal)) (hw : ∀ C ∈ Cs, C.length ≤ 3) + (p : ℕ) (e : Mark) (he : (p,e) ∈ events .widthStart (Cs.flatMap clauseBits)) : + ∃ pre C post, Cs=pre++C::post ∧ + p=(pre.flatMap clauseBits).length+(clauseMark C).1 ∧ e=(clauseMark C).2 := by + induction Cs generalizing p with + | nil => simp [events] at he + | cons C Cs ih => + rw [List.flatMap_cons,events_append,events_clause C (hw C (by simp)), + run_clause C (hw C (by simp))] at he + rcases List.mem_append.mp he with h | h + · have hh : (p,e)=clauseMark C := List.mem_singleton.mp h + refine ⟨[],C,Cs,rfl,?_,?_⟩ + · simpa using congrArg Prod.fst hh + · exact congrArg Prod.snd hh + · obtain ⟨j,hj,hp⟩ := (mem_shift _ _ _ _).mp h + obtain ⟨pre,D,post,hs,hj',he'⟩ := ih (fun D hD => hw D (by simp [hD])) j hj + refine ⟨C::pre,D,post,by simp [hs],?_,he'⟩ + simp [hp,hj',List.flatMap_cons,Nat.add_assoc] + +lemma events_bound (q : Phase) (s : List Bool) (p : ℕ) (e : Mark) + (hp : (p,e) ∈ events q s) : p < s.length := by + induction s generalizing q p with + | nil => simp [events] at hp + | cons b s ih => + rw [events,List.mem_append] at hp + rcases hp with h | h + · obtain ⟨e',_he,he'⟩ := List.mem_map.mp h + have : p=0 := (congrArg Prod.fst he').symm + simp [this] + · obtain ⟨j,hj,hp⟩ := (mem_shift _ _ _ _).mp h + have := ih (transition q b) j hj + simp only [List.length_cons] + omega + +lemma clause_event_location (pre : List (List Literal)) (C : List Literal) (post : List (List Literal)) + (hw : ∀ D ∈ pre++C::post, D.length ≤ 3) : + ((pre.flatMap clauseBits).length+(clauseMark C).1,(clauseMark C).2) ∈ + events .widthStart ((pre++C::post).flatMap clauseBits) := by + rw [List.flatMap_append,events_append,run_clauses pre (fun D hD => hw D (by simp [hD]))] + apply List.mem_append_right + apply (mem_shift _ _ _ _).mpr + refine ⟨(clauseMark C).1,?_,rfl⟩ + rw [List.flatMap_cons,events_append,events_clause C (hw C (by simp))] + apply List.mem_append_left + simp + +lemma event_formula_location (F : Formula) (p : ℕ) (e : Mark) + (he : (p,e) ∈ events .headerMark (formulaBits F)) : + ∃ pre C post, F.clauses=pre++C::post ∧ + p=(nameBits F.clauses.length).length+(pre.flatMap clauseBits).length+(clauseMark C).1 ∧ + e=(clauseMark C).2 := by + rw [formulaBits,events_append] at he + simp only [nameBits,events_header,run_header,List.nil_append] at he + obtain ⟨j,hj,hp⟩ := (mem_shift _ _ _ _).mp he + obtain ⟨pre,C,post,hs,hj',he'⟩ := event_clause_location F.clauses F.width j e hj + exact ⟨pre,C,post,hs,by dsimp [nameBits]; omega,he'⟩ + +lemma formula_clause_event (F : Formula) (pre : List (List Literal)) (C : List Literal) + (post : List (List Literal)) (hF : F.clauses=pre++C::post) : + ((nameBits F.clauses.length).length+(pre.flatMap clauseBits).length+(clauseMark C).1, + (clauseMark C).2) ∈ events .headerMark (formulaBits F) := by + rw [formulaBits,events_append] + simp only [nameBits,events_header,run_header,List.nil_append] + apply (mem_shift _ _ _ _).mpr + refine ⟨(pre.flatMap clauseBits).length+(clauseMark C).1,?_,by omega⟩ + rw [hF] + exact clause_event_location pre C post (fun D hD => F.width D (hF ▸ hD)) + +end LargeIndependentSets.BinarySyntax + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryNameTables.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryNameTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..137dd0b6a3f0f8e4edaf30645ce478291f400f51 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryNameTables.lean @@ -0,0 +1,205 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.FiniteScan + +namespace OAI + +namespace LargeIndependentSets.BinaryNames +open IndependentSetsCut.CounterMachine +open scoped BigOperators + +def raw (s : List Bool) (i : ℕ) : Bool := (s[i]?).getD false + +lemma raw_out (s : List Bool) (i : ℕ) (hi : s.length ≤ i) : raw s i = false := by + simp [raw,List.getElem?_eq_none hi] + +lemma end_exists (s : List Bool) (p : ℕ) : ∃ t, raw s (p+1+2*t) = false := + ⟨s.length,raw_out s _ (by omega)⟩ + +def nameLength (s : List Bool) (p : ℕ) : ℕ := Nat.find (end_exists s p) + +lemma nameLength_le (s : List Bool) (p : ℕ) : nameLength s p ≤ s.length := + Nat.find_min' _ (raw_out s _ (by omega)) +lemma nameLength_end (s : List Bool) (p : ℕ) : raw s (p+1+2*nameLength s p) = false := + Nat.find_spec (end_exists s p) +lemma nameLength_before (s : List Bool) (p j : ℕ) (hj : j simp_all + +def payload (s : List Bool) (p : ℕ) : List Bool := + (List.range (nameLength s p)).map (fun j => raw s (p+2+2*j)) + +lemma payload_eq_iff (s : List Bool) (p q : ℕ) : + payload s p = payload s q ↔ nameLength s p = nameLength s q ∧ + ∀ j l[j]?) h + simpa [payload,List.getElem?_range,hl,hl ▸ hj] using he + · rintro ⟨hl,he⟩ + unfold payload + rw [← hl] + apply List.map_congr_left + intro j hj + exact he j (List.mem_range.mp hj) + +lemma key_exists (s : List Bool) (p : ℕ) : + ∃ q, q ≤ s.length ∧ payload s q = payload s (min p s.length) := + ⟨min p s.length,Nat.min_le_right _ _,rfl⟩ + +def key (s : List Bool) (p : ℕ) : ℕ := Nat.find (key_exists s p) +lemma key_le (s : List Bool) (p : ℕ) : key s p ≤ s.length := (Nat.find_spec (key_exists s p)).1 +lemma key_payload (s : List Bool) (p : ℕ) (hp : p ≤ s.length) : + payload s (key s p) = payload s p := by + simpa only [key,Nat.min_eq_left hp] using (Nat.find_spec (key_exists s p)).2 +lemma key_eq (s : List Bool) (p q : ℕ) (hp : p ≤ s.length) (hq : q ≤ s.length) + (he : payload s p = payload s q) : key s p = key s q := by + apply le_antisymm + · apply Nat.find_min' + exact ⟨key_le s q,by rw [Nat.min_eq_left hp,key_payload s q hq,he]⟩ + · apply Nat.find_min' + exact ⟨key_le s p,by rw [Nat.min_eq_left hq,key_payload s p hp,he]⟩ + +def next (s : List Bool) (p : ℕ) : ℕ := p+2+2*nameLength s p + +lemma raw_middle (pre mid post : List Bool) (i : ℕ) (hi : i < mid.length) : + raw (pre++mid++post) (pre.length+i) = raw mid i := by + rw [show pre++mid++post=pre++(mid++post) by rw [List.append_assoc]] + unfold raw + rw [List.getElem?_append_right (by omega)] + simp only [Nat.add_sub_cancel_left] + rw [List.getElem?_append_left hi] + +lemma frame_eq (s : List Bool) : LargeIndependentSets.frame s = IndependentSetsCut.CounterMachine.frame s := by + induction s with + | nil => rfl + | cons b s ih => simp only [LargeIndependentSets.frame,IndependentSetsCut.CounterMachine.frame,ih] + +lemma literal_marker (l : Literal) (j : ℕ) (hj : j ≤ l.name.bits.length) : + raw (literalBits l) (1+2*j) = decide (j cases y <;> decide + simp only [payloadEqExpr,Expr.eval,Expr.equal_eval,nameLengthExpr_eval,rawExpr_eval, + Expr.rename_eval,Expr.bind,hb] + have hz : (∑ j ∈ Finset.range (nameLength s.input (p.eval s.bits a)), + if raw s.input (p.eval s.bits a+2+2*j)=raw s.input (q.eval s.bits a+2+2*j) then 0 else 1)=0 ↔ + ∀ j Nat.zero_le _)] + simp only [show ∀ b : Prop, ∀ _ : Decidable b, (if (if b then (1:ℕ) else 0)=0 then 1 else 0) = + if b then 0 else 1 by intros; split_ifs <;> simp_all] + simp only [hz,payload_eq_iff] + by_cases h : nameLength s.input (p.eval s.bits a)=nameLength s.input (q.eval s.bits a) + · simp [h] + · simp [h] + +def minExpr (a b : Expr) : Expr := Expr.cond (Expr.le a b) a b +@[simp] lemma minExpr_eval (x y : Expr) (s : List Bool) (a : ℕ → ℕ) : + (minExpr x y).eval s a = min (x.eval s a) (y.eval s a) := by + by_cases h : x.eval s a ≤ y.eval s a <;> simp [minExpr,h, min_def] + +def keyExpr (p : Expr) : Expr := Expr.least (.add FiniteScan.nExpr (.const 1)) + (payloadEqExpr (.arg 0) ((minExpr p FiniteScan.nExpr).rename Nat.succ)) + +lemma keyExpr_eval {m : ℕ} (s : FiniteScan.State m) (p : Expr) (a : ℕ → ℕ) : + (keyExpr p).eval s.bits a = key s.input (p.eval s.bits a) := by + unfold keyExpr + apply Expr.least_eq + · simpa [Expr.eval] using Nat.lt_succ_of_le (key_le s.input _) + · simp only [payloadEqExpr_eval,Expr.eval,Expr.bind,Expr.rename_eval,minExpr_eval,FiniteScan.nExpr_eval] + have hk : payload s.input (key s.input (p.eval s.bits a)) = + payload s.input (min (p.eval s.bits a) s.input.length) := + (Nat.find_spec (key_exists s.input (p.eval s.bits a))).2 + simpa only [hk,ite_true] using (show (1:ℕ)≠0 by decide) + · intro j hj + have hjn : j ≤ s.input.length := (Nat.le_of_lt hj).trans (key_le s.input _) + have hne : payload s.input j ≠ payload s.input (min (p.eval s.bits a) s.input.length) := by + intro he + exact Nat.find_min (key_exists s.input (p.eval s.bits a)) hj ⟨hjn,he⟩ + simp [payloadEqExpr_eval,Expr.eval,Expr.bind,hne] + +def nextExpr (p : Expr) : Expr := .add (.add p (.const 2)) (.mul (.const 2) (nameLengthExpr p)) +lemma nextExpr_eval {m : ℕ} (s : FiniteScan.State m) (p : Expr) (a : ℕ → ℕ) : + (nextExpr p).eval s.bits a = next s.input (p.eval s.bits a) := by + simp [nextExpr,Expr.eval,nameLengthExpr_eval,next] + +end LargeIndependentSets.BinaryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryNormalize.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryNormalize.lean new file mode 100644 index 0000000000000000000000000000000000000000..4467563ca2e623bfd855b66d9f012672fd1dfb4d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinaryNormalize.lean @@ -0,0 +1,280 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.BinaryEvents +import OAI.Combinatorics.IndependentSets.Encoding.BinaryNameTables + +namespace OAI + +namespace LargeIndependentSets.BinaryNormalize +open BinarySyntax BinaryNames +open IndependentSetsGames.Foundations + +abbrev varCount (s : List Bool) : ℕ := s.length+1 + +def dense (s : List Bool) (p : ℕ) : Target.Literal (varCount s) := + ⟨⟨key s p,Nat.lt_succ_of_le (key_le s p)⟩,raw s p⟩ + +def constant (s : List Bool) (b : Bool) : Target.Literal (varCount s) := ⟨0,b⟩ + +def triple {n : ℕ} (a b c : Target.Literal n) : Target.Clause n := ⟨#[a,b,c],rfl⟩ + +def tautology (s : List Bool) : Target.Clause (varCount s) := + triple (constant s true) (constant s false) (constant s true) + +def unitClause (s : List Bool) (b : Bool) : Target.Clause (varCount s) := + triple (constant s b) (constant s b) (constant s b) + +def sourceClause (s : List Bool) (p : ℕ) (r : Fin 3) : Target.Clause (varCount s) := + triple (dense s p) (dense s (if 1 ≤ r.val then next s p else p)) + (dense s (if 2 ≤ r.val then next s (next s p) else p)) + +def eventAt (s : List Bool) (p : ℕ) : Option Mark := + event (run .headerMark (s.take p)) (raw s p) + +def row (s : List Bool) (p : ℕ) (side : Bool) : Target.Clause (varCount s) := + match eventAt s p with + | none => tautology s + | some .empty => unitClause s side + | some (.first r) => if side then tautology s else sourceClause s p r + +def normalize (s : List Bool) : Target.Formula := + ⟨varCount s,(List.range s.length).flatMap (fun p => [row s p false,row s p true])⟩ + +@[simp] lemma literal_eval_iff {n : ℕ} (l : Target.Literal n) (σ : Fin n → Bool) : + l.eval σ = true ↔ σ l.variableIndex = l.positive := by + cases h : l.positive <;> simp [Target.Literal.eval,h] + +@[simp] lemma triple_eval {n : ℕ} (a b c : Target.Literal n) (σ : Fin n → Bool) : + (triple a b c).eval σ = true ↔ a.eval σ = true ∨ b.eval σ = true ∨ c.eval σ = true := by + simp [triple,Target.Clause.eval,or_assoc] + +lemma foldr_bits (n : ℕ) : n.bits.foldr Nat.bit 0 = n := by + induction n using Nat.binaryRec' with + | zero => simp + | bit b n h ih => simp [Nat.bits_append_bit n b h,ih] + +@[simp] lemma tautology_eval (s : List Bool) (σ : Fin (varCount s) → Bool) : + (tautology s).eval σ = true := by + simp [tautology,constant] + +@[simp] lemma unitClause_eval (s : List Bool) (b : Bool) (σ : Fin (varCount s) → Bool) : + (unitClause s b).eval σ = true ↔ σ 0 = b := by + simp [unitClause,constant] + +lemma eventAt_iff (s : List Bool) (p : ℕ) (hp : p θ ((payload s x.val).foldr Nat.bit 0),?_⟩ + intro pre l post hs + have hp : pre.length ≤ s.length := by simp only [hs,List.length_append]; omega + change θ ((payload s (key s pre.length)).foldr Nat.bit 0)=θ l.name + rw [key_payload s pre.length hp,hs,payload_literal,foldr_bits] + +lemma exists_realizes_backward (s : List Bool) (σ : Fin (varCount s) → Bool) : + ∃ θ, Realizes s σ θ := by + classical + let occurs (v : ℕ) := ∃ p, p ≤ s.length ∧ payload s p=v.bits + let pos (v : ℕ) (h : occurs v) : ℕ := Classical.choose h + let θ : ℕ → Bool := fun v => if h : occurs v then + σ ⟨key s (pos v h),Nat.lt_succ_of_le (key_le s _)⟩ else false + refine ⟨θ,?_⟩ + intro pre l post hs + have hp : pre.length ≤ s.length := by simp only [hs,List.length_append]; omega + have hv : payload s pre.length=l.name.bits := by rw [hs,payload_literal] + have ho : occurs l.name := ⟨pre.length,hp,hv⟩ + dsimp only [θ] + rw [dite_eq_left ho] + have hpos := Classical.choose_spec ho + have hkey : key s pre.length=key s (pos l.name ho) := + key_eq s _ _ hp hpos.1 (hv.trans hpos.2.symm) + congr 1 + exact Fin.ext hkey + +lemma sourceClause_one {s : List Bool} {σ : Fin (varCount s) → Bool} {θ : ℕ → Bool} + (h : Realizes s σ θ) (pre post : List Bool) (a : Literal) + (hs : s=pre++literalBits a++post) : + (sourceClause s pre.length 0).eval σ=true ↔ θ a.name=a.positive := by + simp only [sourceClause,Fin.val_zero,show ¬1≤0 by omega,show ¬2≤0 by omega,ite_false, + triple_eval,or_self] + exact dense_eval_iff h pre post a hs + +lemma sourceClause_two {s : List Bool} {σ : Fin (varCount s) → Bool} {θ : ℕ → Bool} + (h : Realizes s σ θ) (pre post : List Bool) (a b : Literal) + (hs : s=pre++literalBits a++literalBits b++post) : + (sourceClause s pre.length 1).eval σ=true ↔ + θ a.name=a.positive ∨ θ b.name=b.positive := by + have ha : s=pre++literalBits a++(literalBits b++post) := by simpa [List.append_assoc] using hs + have hb : s=(pre++literalBits a)++literalBits b++post := hs + have hn : next s pre.length=(pre++literalBits a).length := by rw [ha,next_literal] + simp only [sourceClause,show (1 : Fin 3).val=1 from rfl,le_refl,show ¬2≤1 by omega, + ite_true,ite_false,triple_eval,hn,dense_eval_iff h pre _ a ha, + dense_eval_iff h _ post b hb] + tauto + +lemma sourceClause_three {s : List Bool} {σ : Fin (varCount s) → Bool} {θ : ℕ → Bool} + (h : Realizes s σ θ) (pre post : List Bool) (a b c : Literal) + (hs : s=pre++literalBits a++literalBits b++literalBits c++post) : + (sourceClause s pre.length 2).eval σ=true ↔ + θ a.name=a.positive ∨ θ b.name=b.positive ∨ θ c.name=c.positive := by + have ha : s=pre++literalBits a++(literalBits b++literalBits c++post) := by + simpa [List.append_assoc] using hs + have hb : s=(pre++literalBits a)++literalBits b++(literalBits c++post) := by + simpa [List.append_assoc] using hs + have hc : s=(pre++literalBits a++literalBits b)++literalBits c++post := hs + have hn : next s pre.length=(pre++literalBits a).length := by rw [ha,next_literal] + have hn' : next s (pre++literalBits a).length=(pre++literalBits a++literalBits b).length := by + rw [hb,next_literal] + simp only [sourceClause,show (2 : Fin 3).val=2 from rfl,show 1≤2 by omega,le_refl,ite_true, + triple_eval,hn,hn',dense_eval_iff h pre _ a ha,dense_eval_iff h _ _ b hb, + dense_eval_iff h _ post c hc] + +def PairSatisfied (s : List Bool) (p : ℕ) (σ : Fin (varCount s) → Bool) : Prop := + (row s p false).eval σ=true ∧ (row s p true).eval σ=true + +lemma pair_first (s : List Bool) (p : ℕ) (σ : Fin (varCount s) → Bool) (r : Fin 3) + (he : eventAt s p=some (.first r)) : + PairSatisfied s p σ ↔ (sourceClause s p r).eval σ=true := by + simp [PairSatisfied,row,he] + +lemma pair_empty (s : List Bool) (p : ℕ) (σ : Fin (varCount s) → Bool) + (he : eventAt s p=some .empty) : ¬ PairSatisfied s p σ := by + simp [PairSatisfied,row,he] + +lemma pair_none (s : List Bool) (p : ℕ) (σ : Fin (varCount s) → Bool) + (he : eventAt s p=none) : PairSatisfied s p σ := by + simp [PairSatisfied,row,he] + +lemma atClause {s : List Bool} {σ : Fin (varCount s) → Bool} {θ : ℕ → Bool} + (h : Realizes s σ θ) (pre post : List Bool) (C : List Literal) (hw : C.length ≤ 3) + (hs : s=pre++clauseBits C++post) + (he : eventAt s (pre.length+(clauseMark C).1)=some (clauseMark C).2) : + PairSatisfied s (pre.length+(clauseMark C).1) σ ↔ + ∃ l ∈ C, θ l.name=l.positive := by + cases C with + | nil => + have hn := pair_empty s _ σ he + simp only [List.not_mem_nil,false_and,exists_false,iff_false] + exact hn + | cons a C => + cases C with + | nil => + have hp : pre.length+(clauseMark [a]).1=(pre++nameBits 1).length := by + simp [clauseMark] + have he' : eventAt s (pre.length+(clauseMark [a]).1)=some (.first 0) := he + rw [pair_first _ _ _ _ he',hp] + have hs' : s=(pre++nameBits 1)++literalBits a++post := by + simpa [clauseBits,List.append_assoc] using hs + simpa using sourceClause_one h (pre++nameBits 1) post a hs' + | cons b C => + cases C with + | nil => + have hp : pre.length+(clauseMark [a,b]).1=(pre++nameBits 2).length := by + simp [clauseMark] + have he' : eventAt s (pre.length+(clauseMark [a,b]).1)=some (.first 1) := he + rw [pair_first _ _ _ _ he',hp] + have hs' : s=(pre++nameBits 2)++literalBits a++literalBits b++post := by + simpa [clauseBits,List.append_assoc] using hs + simpa [List.mem_cons,or_and_right,exists_or] using + sourceClause_two h (pre++nameBits 2) post a b hs' + | cons c C => + have hc : C=[] := by + apply List.length_eq_zero_iff.mp + simp only [List.length_cons] at hw + omega + subst C + have hp : pre.length+(clauseMark [a,b,c]).1=(pre++nameBits 3).length := by + simp [clauseMark] + have he' : eventAt s (pre.length+(clauseMark [a,b,c]).1)=some (.first 2) := he + rw [pair_first _ _ _ _ he',hp] + have hs' : s=(pre++nameBits 3)++literalBits a++literalBits b++literalBits c++post := by + simpa [clauseBits,List.append_assoc] using hs + simpa [List.mem_cons,or_and_right,exists_or,or_assoc] using + sourceClause_three h (pre++nameBits 3) post a b c hs' + +lemma pairs_iff (s : List Bool) (σ : Fin (varCount s) → Bool) : + (∀ C ∈ (normalize s).clauses, C.eval σ=true) ↔ + ∀ p [row s p false,row s p true]), + C.eval σ=true) ↔ _ + constructor + · intro h p hp + have hm (b : Bool) : row s p b ∈ (normalize s).clauses := by + apply List.mem_flatMap.mpr + refine ⟨p,List.mem_range.mpr hp,?_⟩ + cases b <;> simp + exact ⟨h _ (hm false),h _ (hm true)⟩ + · intro h C hC + obtain ⟨p,hp,hC⟩ := List.mem_flatMap.mp hC + have hh := h p (List.mem_range.mp hp) + simp only [List.mem_cons,List.not_mem_nil,or_false] at hC + rcases hC with rfl | rfl + · exact hh.1 + · exact hh.2 + +lemma formula_atClause (F : Formula) {σ : Fin (varCount (formulaBits F)) → Bool} + {θ : ℕ → Bool} (h : Realizes (formulaBits F) σ θ) + (pre : List (List Literal)) (C : List Literal) (post : List (List Literal)) + (hF : F.clauses=pre++C::post) : + let p := (nameBits F.clauses.length).length+(pre.flatMap clauseBits).length+(clauseMark C).1 + p < (formulaBits F).length ∧ + (PairSatisfied (formulaBits F) p σ ↔ ∃ l ∈ C, θ l.name=l.positive) := by + dsimp only + have hm := formula_clause_event F pre C post hF + have hp := events_bound .headerMark (formulaBits F) _ _ hm + refine ⟨hp,?_⟩ + have he := (eventAt_iff _ _ hp _).mpr hm + have hh : F.clauses.length=(pre++C::post).length := congrArg List.length hF + have hs : formulaBits F=(nameBits F.clauses.length++pre.flatMap clauseBits)++ + clauseBits C++post.flatMap clauseBits := by + simp only [formulaBits,hF,List.flatMap_append,List.flatMap_cons,List.append_assoc] + have hc : C ∈ F.clauses := by rw [hF]; simp + simpa only [List.length_append] using atClause h + (nameBits F.clauses.length++pre.flatMap clauseBits) (post.flatMap clauseBits) C + (F.width C hc) hs (by simpa only [List.length_append] using he) + +theorem satisfiable_iff (F : Formula) : + (normalize (formulaBits F)).Satisfiable ↔ F.Satisfiable := by + constructor + · rintro ⟨σ,hσ⟩ + obtain ⟨θ,hθ⟩ := exists_realizes_backward (formulaBits F) σ + refine ⟨θ,?_⟩ + intro C hC + obtain ⟨pre,post,hF⟩ := List.mem_iff_append.mp hC + have hp := formula_atClause F hθ pre C post hF + exact hp.2.mp ((pairs_iff _ σ).mp hσ _ hp.1) + · rintro ⟨θ,hθ⟩ + obtain ⟨σ,hσ⟩ := exists_realizes_forward (formulaBits F) θ + refine ⟨σ,(pairs_iff _ σ).mpr ?_⟩ + intro p hp + cases he : eventAt (formulaBits F) p with + | none => exact pair_none _ _ _ he + | some e => + obtain ⟨pre,C,post,hF,hp',he'⟩ := event_formula_location F p e + ((eventAt_iff _ _ hp _).mp he) + rw [hp'] + exact (formula_atClause F hσ pre C post hF).2.mpr + (hθ C (by rw [hF]; simp)) + +end LargeIndependentSets.BinaryNormalize + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/BinarySyntax.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinarySyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e3c23864dad728b72412f1ef8b432e94d949bfb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/BinarySyntax.lean @@ -0,0 +1,141 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.FiniteScan + +namespace OAI + +namespace LargeIndependentSets.BinarySyntax + +inductive Phase where + | headerMark | headerPayload + | widthStart | widthBit0 + | widthMark1 (b : Bool) | widthBit1 (b : Bool) + | widthMark2 (b c : Bool) + | sign (remaining : Fin 3) (first : Bool) + | mark (remaining : Fin 3) + | payload (remaining : Fin 3) + | bad + deriving DecidableEq, Fintype + +def after (r : Fin 3) : Phase := + if h : r.val=0 then .widthStart else .sign ⟨r.val-1,by omega⟩ false + +def width (n : Fin 4) : Phase := + if h : n.val=0 then .widthStart else .sign ⟨n.val-1,by omega⟩ true + +def transition : Phase → Bool → Phase + | .headerMark, true => .headerPayload + | .headerMark, false => .widthStart + | .headerPayload, _ => .headerMark + | .widthStart, true => .widthBit0 + | .widthStart, false => .widthStart + | .widthBit0, b => .widthMark1 b + | .widthMark1 b, true => .widthBit1 b + | .widthMark1 b, false => if b then .sign 0 true else .widthStart + | .widthBit1 b, c => .widthMark2 b c + | .widthMark2 b c, false => if c then .sign (if b then 2 else 1) true + else if b then .sign 0 true else .widthStart + | .widthMark2 _ _, true => .bad + | .sign r _, _ => .mark r + | .mark r, true => .payload r + | .mark r, false => after r + | .payload r, _ => .mark r + | .bad, _ => .bad + +def run (q : Phase) (s : List Bool) : Phase := s.foldl transition q + +@[simp] lemma run_nil (q : Phase) : run q [] = q := rfl +@[simp] lemma run_cons (q : Phase) (b : Bool) (s : List Bool) : + run q (b::s) = run (transition q b) s := rfl +lemma run_append (q : Phase) (a b : List Bool) : run q (a++b) = run (run q a) b := + List.foldl_append + +lemma run_header (s : List Bool) : run .headerMark (frame s) = .widthStart := by + induction s with + | nil => rfl + | cons b bs ih => simpa only [frame,run_cons,transition] using ih + +lemma run_name (r : Fin 3) (s : List Bool) : run (.mark r) (frame s) = after r := by + induction s with + | nil => rfl + | cons b bs ih => simpa only [frame,run_cons,transition] using ih + +lemma run_literal (r : Fin 3) (first : Bool) (l : Literal) : + run (.sign r first) (literalBits l) = after r := by + simpa only [literalBits,nameBits,run_cons,transition] using run_name r l.name.bits + +lemma run_width (n : Fin 4) : run .widthStart (nameBits n.val) = width n := by + fin_cases n <;> rfl + +lemma run_clause (C : List Literal) (hw : C.length ≤ 3) : + run .widthStart (clauseBits C) = .widthStart := by + unfold clauseBits + rw [run_append,run_width ⟨C.length,by omega⟩] + cases C with + | nil => rfl + | cons a C => + cases C with + | nil => + change run (.sign 0 true) (literalBits a ++ []) = .widthStart + simpa [after] using run_literal 0 true a + | cons b C => + cases C with + | nil => + simp only [List.length_cons,List.length_nil,List.flatMap_cons,List.flatMap_nil, + List.append_nil] + change run (.sign 1 true) (literalBits a ++ literalBits b) = _ + rw [run_append,run_literal] + exact run_literal 0 false b + | cons c C => + have hc : C=[] := by + apply List.length_eq_zero_iff.mp + simp only [List.length_cons] at hw + omega + subst C + simp only [List.length_cons,List.length_nil,List.flatMap_cons,List.flatMap_nil, + List.append_nil] + change run (.sign 2 true) (literalBits a ++ (literalBits b ++ literalBits c)) = _ + rw [run_append,run_literal] + change run (.sign 1 false) (literalBits b ++ literalBits c) = _ + rw [run_append,run_literal] + exact run_literal 0 false c + +lemma run_clauses (Cs : List (List Literal)) (hw : ∀ C ∈ Cs, C.length ≤ 3) : + run .widthStart (Cs.flatMap clauseBits) = .widthStart := by + induction Cs with + | nil => rfl + | cons C Cs ih => + rw [List.flatMap_cons,run_append,run_clause C (hw C (by simp))] + exact ih (fun D hD => hw D (by simp [hD])) + +lemma run_formula (F : Formula) : run .headerMark (formulaBits F) = .widthStart := by + rw [formulaBits,run_append] + simp only [nameBits,run_header] + exact run_clauses F.clauses F.width + +noncomputable def phaseEquiv : Phase ≃ Fin (Fintype.card Phase) := Fintype.equivFin Phase +noncomputable def finiteTransition (q : Fin (Fintype.card Phase)) (b : Bool) := + phaseEquiv (transition (phaseEquiv.symm q) b) + +lemma finite_run (q : Phase) (s : List Bool) : + s.foldl finiteTransition (phaseEquiv q) = phaseEquiv (run q s) := by + induction s generalizing q with + | nil => rfl + | cons b s ih => simpa [List.foldl_cons,finiteTransition,run,transition] using ih (transition q b) + +noncomputable def annotated (s : List Bool) := + FiniteScan.output finiteTransition (phaseEquiv .headerMark) s + +lemma annotated_history (s : List Bool) (j : ℕ) (hj : j ≤ s.length) : + (annotated s).history j = phaseEquiv (run .headerMark (s.take j)) := by + rw [annotated,FiniteScan.output_history _ _ _ j hj,finite_run] + +noncomputable def certificate : Turing.TM2ComputableInPolyTime + (id : List Bool → List Bool) FiniteScan.State.bits annotated := + FiniteScan.certificate finiteTransition (phaseEquiv .headerMark) + +lemma finiteAlphabet : IndependentSetsGames.Foundations.Complexity.MachineFiniteAlphabet.FiniteAlphabet + certificate.tm := FiniteScan.finiteAlphabet _ _ + +end LargeIndependentSets.BinarySyntax + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/BitsValue.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/BitsValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..a56868b10d394f33204e33b332941508c2416f63 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/BitsValue.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Model + +namespace OAI + +namespace LargeIndependentSets +namespace BinaryParser + +def bitsValue : List Bool → ℕ + | [] => 0 + | b::bs => Nat.bit b (bitsValue bs) + +@[simp] lemma bitsValue_bits (n : ℕ) : bitsValue n.bits = n := by + induction n using Nat.binaryRec' with + | zero => simp [bitsValue] + | bit b n hn ih => rw [Nat.bits_append_bit n b hn]; simp only [bitsValue,ih] + +def parseFrame : List Bool → Option (List Bool × List Bool) + | false::rest => some ([],rest) + | true::b::rest => do + let (bs,tail) ← parseFrame rest + return (b::bs,tail) + | _ => none + +@[simp] lemma parseFrame_encoded (bs tail : List Bool) : + parseFrame (frame bs ++ tail) = some (bs,tail) := by + induction bs with + | nil => rfl + | cons b bs ih => simp [frame,parseFrame,ih] + +def parseName (b : List Bool) : Option (ℕ × List Bool) := do + let (digits,tail) ← parseFrame b + let n := bitsValue digits + if digits = n.bits then some (n,tail) else none + +@[simp] lemma parseName_encoded (n : ℕ) (tail : List Bool) : + parseName (nameBits n ++ tail) = some (n,tail) := by + simp [parseName,nameBits] + +def parseLiteral : List Bool → Option (Literal × List Bool) + | sign::b => do + let (name,tail) ← parseName b + return (⟨name,sign⟩,tail) + | [] => none + +@[simp] lemma parseLiteral_encoded (l : Literal) (tail : List Bool) : + parseLiteral (literalBits l ++ tail) = some (l,tail) := by + cases l + simp [parseLiteral,literalBits] + +def parseMany {α : Type} (parse : List Bool → Option (α × List Bool)) : + ℕ → List Bool → Option (List α × List Bool) + | 0,b => some ([],b) + | n+1,b => do + let (a,b) ← parse b + let (as,tail) ← parseMany parse n b + return (a::as,tail) + +lemma parseMany_encoded {α : Type} (parse : List Bool → Option (α × List Bool)) + (encode : α → List Bool) (P : α → Prop) + (h : ∀ a, P a → ∀ tail, parse (encode a ++ tail) = some (a,tail)) + (as : List α) (has : ∀ a ∈ as, P a) (tail : List Bool) : + parseMany parse as.length (as.flatMap encode ++ tail) = some (as,tail) := by + induction as with + | nil => rfl + | cons a as ih => + simp only [List.length_cons,List.flatMap_cons,List.append_assoc,parseMany, + h a (has a (by simp)),bind,Option.bind] + rw [ih (fun x hx => has x (by simp [hx]))] + rfl + +def parseClause (b : List Bool) : Option (List Literal × List Bool) := do + let (n,b) ← parseName b + if n ≤ 3 then parseMany parseLiteral n b else none + +lemma parseClause_encoded (C : List Literal) (hC : C.length ≤ 3) (tail : List Bool) : + parseClause (clauseBits C ++ tail) = some (C,tail) := by + simp only [clauseBits,List.append_assoc,parseClause,parseName_encoded,bind,Option.bind,hC,ite_true] + exact parseMany_encoded parseLiteral literalBits (fun _ => True) + (fun l _ => parseLiteral_encoded l) C (by simp) tail + +lemma clauses_length_le_bits (Cs : List (List Literal)) : + Cs.length ≤ (Cs.flatMap clauseBits).length := by + have hp (C : List Literal) : 1 ≤ (clauseBits C).length := by + unfold clauseBits nameBits + have h : ∀ b : List Bool, 1 ≤ (frame b).length := by + intro b + cases b <;> simp [frame] + simpa only [List.length_append] using (h C.length.bits).trans (Nat.le_add_right _ _) + induction Cs with + | nil => simp + | cons C Cs ih => simp only [List.length_cons,List.flatMap_cons,List.length_append]; have := hp C; omega + +def core (input : List Bool) : Option Formula := do + let (n,b) ← parseName input + if n ≤ b.length then + let (Cs,tail) ← parseMany parseClause n b + if tail = [] then + if h : ∀ C ∈ Cs, C.length ≤ 3 then some ⟨Cs,h⟩ else none + else none + else none + +lemma core_encoded (F : Formula) : core (formulaBits F) = some F := by + unfold core formulaBits + rw [parseName_encoded] + simp only [bind,Option.bind,clauses_length_le_bits,ite_true] + have hm := parseMany_encoded parseClause clauseBits (fun C => C.length ≤ 3) + parseClause_encoded F.clauses F.width [] + simp only [List.append_nil] at hm + rw [hm] + simp + exact F.width + +def decode (input : List Bool) : Formula := + match core input with + | none => ⟨[],by simp⟩ + | some F => if formulaBits F = input then F else ⟨[],by simp⟩ + +@[simp] theorem decode_encoded (F : Formula) : decode (formulaBits F) = F := by + simp [decode,core_encoded] + +theorem decode_bits_bound (input : List Bool) : + (formulaBits (decode input)).length ≤ input.length+1 := by + unfold decode + cases h : core input with + | none => simp [formulaBits,nameBits,frame] + | some F => + dsimp only + split_ifs with he + · simp only [he]; omega + · simp [formulaBits,nameBits,frame] + +end BinaryParser +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/Bounds.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/Bounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..9862ba3a883adb6e9792772b116821d124486e9b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/Bounds.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.Concrete + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceBounds + +open Target +open IndependentSetsGames.Reduction + +theorem formulaBits_length (F : Formula) : + (Complexity.formulaBits F).length = F.«variables» + F.clauses.length + 2 + + (Complexity.encodeWords (F.clauses.flatMap Complexity.clauseWords)).length := by + simp only [Complexity.formulaBits, Complexity.formulaWords, + Complexity.encodeWords_append, List.length_append, Complexity.encodeWords, + Complexity.encodeWord_length, List.length_nil] + omega + +theorem formulaBits_length_ge_variables (F : Formula) : + F.«variables» ≤ (Complexity.formulaBits F).length := by + rw [formulaBits_length] + omega + +theorem formulaBits_length_ge_clauses (F : Formula) : + F.clauses.length ≤ (Complexity.formulaBits F).length := by + rw [formulaBits_length] + omega + +theorem formulaBits_length_ge_two (F : Formula) : + 2 ≤ (Complexity.formulaBits F).length := by + rw [formulaBits_length] + omega + +def bitCountFormula (n m u : ℕ) : ℕ := + n ^ u * 2 ^ (2 ^ u) + m ^ u * 2 ^ (8 ^ u) + 1 + +def bitCoefficient (u : ℕ) : ℕ := 2 ^ (2 ^ u) + 2 ^ (8 ^ u) + 1 + +def testCoefficient (u D : ℕ) : ℕ := + 3 ^ u * 2 ^ (2 ^ u) * D ^ (8 ^ u) * 2 ^ (8 ^ u) + +def occurrenceCoefficient (u D : ℕ) : ℕ := testCoefficient u D + 1 + +theorem one_le_input_power (F : Formula) (u : ℕ) : + 1 ≤ (Complexity.formulaBits F).length ^ u := by + apply Nat.one_le_pow + have h := formulaBits_length_ge_two F + omega + +theorem bitCountFormula_le_input (F : Formula) (u : ℕ) : + bitCountFormula F.«variables» F.clauses.length u ≤ + bitCoefficient u * (Complexity.formulaBits F).length ^ u := by + have hn := Nat.pow_le_pow_left (formulaBits_length_ge_variables F) u + have hm := Nat.pow_le_pow_left (formulaBits_length_ge_clauses F) u + have hpos := one_le_input_power F u + unfold bitCountFormula bitCoefficient + calc + _ ≤ (Complexity.formulaBits F).length ^ u * 2 ^ (2 ^ u) + + (Complexity.formulaBits F).length ^ u * 2 ^ (8 ^ u) + + (Complexity.formulaBits F).length ^ u := + Nat.add_le_add + (Nat.add_le_add (Nat.mul_le_mul_right _ hn) (Nat.mul_le_mul_right _ hm)) hpos + _ = _ := by ring + +theorem testCountFormula_le_input (F : Formula) (u D : ℕ) : + (F.clauses.length * 3) ^ u * 2 ^ (2 ^ u) * D ^ (8 ^ u) * 2 ^ (8 ^ u) ≤ + testCoefficient u D * (Complexity.formulaBits F).length ^ u := by + have hm := Nat.pow_le_pow_left (formulaBits_length_ge_clauses F) u + calc + _ = testCoefficient u D * F.clauses.length ^ u := by + simp only [testCoefficient, Nat.mul_pow] + ring + _ ≤ _ := Nat.mul_le_mul_left _ hm + +theorem testCountFormula_add_one_le_input (F : Formula) (u D : ℕ) : + (F.clauses.length * 3) ^ u * 2 ^ (2 ^ u) * D ^ (8 ^ u) * 2 ^ (8 ^ u) + 1 ≤ + occurrenceCoefficient u D * (Complexity.formulaBits F).length ^ u := by + calc + _ ≤ testCoefficient u D * (Complexity.formulaBits F).length ^ u + + (Complexity.formulaBits F).length ^ u := + Nat.add_le_add (testCountFormula_le_input F u D) (one_le_input_power F u) + _ = _ := by simp only [occurrenceCoefficient, Nat.add_mul, Nat.one_mul] + +def sourceSizeBound (V E u L : ℕ) : ℕ := + V * L ^ u + E * L ^ u + 2 + E * L ^ u * (3 * (V * L ^ u) + 2) + +theorem sourceBits_length_le (input : SourceEncoding.Input) (V E u L : ℕ) + (hv : input.«variables» ≤ V * L ^ u) + (he : input.equations.length ≤ E * L ^ u) : + (SourceEncoding.inputBits input).length ≤ sourceSizeBound V E u L := by + apply (SourceEncoding.inputBits_length_le input).trans + unfold sourceSizeBound + exact Nat.add_le_add + (Nat.add_le_add_right (Nat.add_le_add hv he) 2) + (Nat.mul_le_mul he (Nat.add_le_add_right (Nat.mul_le_mul_left 3 hv) 2)) + +noncomputable def sourcePolynomial (u D : ℕ) : Polynomial ℕ := + let V := Polynomial.C (bitCoefficient u) * Polynomial.X ^ u + let E := Polynomial.C (occurrenceCoefficient u D) * Polynomial.X ^ u + V + E + Polynomial.C 2 + E * (Polynomial.C 3 * V + Polynomial.C 2) + +theorem sourcePolynomial_eval (u D L : ℕ) : + (sourcePolynomial u D).eval L = + sourceSizeBound (bitCoefficient u) (occurrenceCoefficient u D) u L := by + simp [sourcePolynomial, sourceSizeBound] + +open SourceOccurrences SourceContexts + +theorem card_testTape (u D : ℕ) : + Fintype.card (SourceTape.TestTape (I u) (J u) D) = + 2 ^ (2 ^ u) * (D ^ (8 ^ u) * 2 ^ (8 ^ u)) := by + rw [SourceTape.card_testTape, card_I, card_J] + +theorem testTapeEncoding_size (u D : ℕ) : + (SourceOccurrences.testTapeEncoding u D).size = + 2 ^ (2 ^ u) * (D ^ (8 ^ u) * 2 ^ (8 ^ u)) := rfl + +theorem card_sourceIndex (F : Formula) (u D : ℕ) : + Fintype.card (SourceIndex F u D) = + (F.clauses.length ^ u * 3 ^ u) * + (2 ^ (2 ^ u) * (D ^ (8 ^ u) * 2 ^ (8 ^ u))) := by + rw [(sourceIndexEncoding F u D).card_eq_size] + rfl + +theorem nBits_le_input (F : Formula) (u : ℕ) : + nBits F u ≤ bitCoefficient u * (Complexity.formulaBits F).length ^ u := by + have h := bitCountFormula_le_input F u + simpa only [nBits_eq, bitCountFormula, Nat.add_assoc] using h + +theorem rawSourceList_length_eq (F : Formula) (u D : ℕ) : + (rawSourceList F u D).length = testCoefficient u D * F.clauses.length ^ u := by + rw [rawSourceList_length] + unfold testCoefficient + ac_rfl + +theorem rawSourceList_length_le_input (F : Formula) (u D : ℕ) : + (rawSourceList F u D).length ≤ + testCoefficient u D * (Complexity.formulaBits F).length ^ u := by + rw [rawSourceList_length_eq] + exact Nat.mul_le_mul_left _ + (Nat.pow_le_pow_left (formulaBits_length_ge_clauses F) u) + +theorem sourceList_length_le_input (F : Formula) (u D : ℕ) : + (sourceList F u D).length ≤ + occurrenceCoefficient u D * (Complexity.formulaBits F).length ^ u := by + calc + _ ≤ (rawSourceList F u D).length + 1 := sourceList_length_le_raw_add_one F u D + _ ≤ testCoefficient u D * (Complexity.formulaBits F).length ^ u + + (Complexity.formulaBits F).length ^ u := + Nat.add_le_add (rawSourceList_length_le_input F u D) (one_le_input_power F u) + _ = _ := by simp only [occurrenceCoefficient, Nat.add_mul, Nat.one_mul] + +theorem sourceInput_bits_polynomial (F : Formula) (u D : ℕ) (hD : 0 < D) : + (SourceEncoding.inputBits (sourceInput F u D hD)).length ≤ + (sourcePolynomial u D).eval (Complexity.formulaBits F).length := by + rw [sourcePolynomial_eval] + exact sourceBits_length_le (sourceInput F u D hD) + (bitCoefficient u) (occurrenceCoefficient u D) u (Complexity.formulaBits F).length + (nBits_le_input F u) (sourceList_length_le_input F u D) + +theorem fixed_parameters_source_size (u D : ℕ) (hD : 0 < D) : + ∃ p : Polynomial ℕ, ∀ F : Formula, + (SourceEncoding.inputBits (sourceInput F u D hD)).length ≤ + p.eval (Complexity.formulaBits F).length := + ⟨sourcePolynomial u D, fun F => sourceInput_bits_polynomial F u D hD⟩ + +end IndependentSetsGames.Foundations.Hastad.SourceBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/Completion.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/Completion.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a01acfde28ab8537dcccd324606d2724ccf4fc8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/Completion.lean @@ -0,0 +1,70 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Repetition.Basic +import OAI.Combinatorics.IndependentSets.Repetition.ProfileCorrection +import OAI.Combinatorics.IndependentSets.Repetition.Value + +namespace OAI + +namespace IndependentSetsGames.Foundations.Repetition + +open scoped BigOperators +open Games +noncomputable section + +variable {X Y : Type*} [Fintype X] [Fintype Y] + +def normalizeOr (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (fallback : FiniteDistribution X) : FiniteDistribution X := + if h : 0 < ∑ x, w x then + { weight := normalizedWeight w + nonnegative := (normalizedWeight_isProbability w hw h).1 + normalized := (normalizedWeight_isProbability w hw h).2 } + else fallback + +theorem sum_mul_normalizeOr (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (fallback : FiniteDistribution X) (x : X) : + (∑ z, w z) * (normalizeOr w hw fallback).weight x = w x := by + classical + have hs : 0 ≤ ∑ z, w z := Finset.sum_nonneg (fun z _ => hw z) + by_cases h : 0 < ∑ z, w z + · simp only [normalizeOr, dite_eq_left h, normalizedWeight] + field_simp + · have hz : ∑ z, w z = 0 := le_antisymm (le_of_not_gt h) hs + have hx : w x = 0 := by + apply le_antisymm _ (hw x) + have hl := Finset.single_le_sum (fun z _ => hw z) (Finset.mem_univ x) + simpa only [hz] using hl + simp [normalizeOr, hz, hx] + +theorem local_completion_recombination + (left : X → ℝ) (right : Y → ℝ) + (hl : ∀ x, 0 ≤ left x) (hr : ∀ y, 0 ≤ right y) + (defaultLeft : FiniteDistribution X) (defaultRight : FiniteDistribution Y) + (c : ℝ) (x : X) (y : Y) : + (c * (∑ z, left z) * (∑ z, right z)) * + ((normalizeOr left hl defaultLeft).weight x * + (normalizeOr right hr defaultRight).weight y) = c * left x * right y := by + calc + _ = c * ((∑ z, left z) * (normalizeOr left hl defaultLeft).weight x) * + ((∑ z, right z) * (normalizeOr right hr defaultRight).weight y) := by ring + _ = _ := by rw [sum_mul_normalizeOr, sum_mul_normalizeOr] + +theorem factorized_completion_row + (left : X → ℝ) (right : Y → ℝ) + (hl : ∀ x, 0 ≤ left x) (hr : ∀ y, 0 ≤ right y) + (defaultLeft : FiniteDistribution X) (defaultRight : FiniteDistribution Y) + (c : ℝ) (xy : X × Y) : + (∑ z : X × Y, c * left z.1 * right z.2) * + ((normalizeOr left hl defaultLeft).product + (normalizeOr right hr defaultRight)).weight xy = c * left xy.1 * right xy.2 := by + have hm : (∑ z : X × Y, c * left z.1 * right z.2) = + c * (∑ z, left z) * (∑ z, right z) := by + simp_rw [mul_assoc, ← Finset.mul_sum] + rw [productWeight_mass] + rw [hm] + exact local_completion_recombination left right hl hr defaultLeft defaultRight c xy.1 xy.2 + +end +end IndependentSetsGames.Foundations.Repetition + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/Concrete.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/Concrete.lean new file mode 100644 index 0000000000000000000000000000000000000000..43b60ef1b8fdb84e746f746a466d4eec2b9c6f68 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/Concrete.lean @@ -0,0 +1,239 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Contexts +import OAI.Combinatorics.IndependentSets.Machines.Tape +import OAI.Combinatorics.IndependentSets.Encoding.Encoding +import OAI.Combinatorics.IndependentSets.Fourier.LocalEquations + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceOccurrences +open IndependentSetsGames.Reduction.CloneGap +open scoped BigOperators + +open SourceContexts +open IndependentSetsGames.Reduction.FiniteNoise + +def clauseAnswerEncoding : Encoding PCP.ClauseAnswer := ⟨8, clauseAnswerFinEquiv⟩ + +def slotEncoding : Encoding PCP.Slot where + size := 3 + code := + { toFun := fun s => match s with | .first => 0 | .second => 1 | .third => 2 + invFun := fun i => if i.val = 0 then .first else if i.val = 1 then .second else .third + left_inv := by intro s; cases s <;> rfl + right_inv := by decide } + +def iEncoding (u : ℕ) : Encoding (I u) := (Encoding.fin u).function Encoding.bool +def jEncoding (u : ℕ) : Encoding (J u) := (Encoding.fin u).function clauseAnswerEncoding +def variableEncoding (F : Target.Formula) (u : ℕ) : Encoding (VariableContext F u) := + (Encoding.fin u).function (Encoding.fin F.«variables») +def clauseEncoding (F : Target.Formula) (u : ℕ) : Encoding (ClauseContext F u) := + (Encoding.fin u).function (Encoding.fin F.clauses.length) +def slotContextEncoding (u : ℕ) : Encoding (SlotContext u) := + (Encoding.fin u).function slotEncoding + +def proofEncoding (F : Target.Formula) (u : ℕ) : + Encoding (GlobalKey (VariableContext F u) (ClauseContext F u) (I u) (J u)) := + globalEncoding (variableEncoding F u) (clauseEncoding F u) (iEncoding u) (jEncoding u) + +def nBits (F : Target.Formula) (u : ℕ) : ℕ := (proofEncoding F u).size + +@[simp] theorem nBits_eq (F : Target.Formula) (u : ℕ) : + nBits F u = F.«variables» ^ u * 2 ^ (2 ^ u) + + (F.clauses.length ^ u * 2 ^ (8 ^ u) + 1) := rfl + +def dummyIndex (F : Target.Formula) (u : ℕ) : Fin (nBits F u) := + (proofEncoding F u).code (.inr (.inr ())) + +def leftAnchor (u : ℕ) : I u := fun _ => false + +def rightAnchor (F : Target.Formula) {u : ℕ} (c : ClauseContext F u) : + Option {j : J u // validJ F c j = true} := firstValid (jEncoding u) (validJ F c) + +theorem rightAnchor_none_iff (F : Target.Formula) {u : ℕ} (c : ClauseContext F u) : + rightAnchor F c = none ↔ ∀ j : J u, validJ F c j = false := + firstValid_none_iff _ _ + +def halfTableKeyAssignment (F : Target.Formula) (u : ℕ) + (a : VariableContext F u → HalfCube (leftAnchor u) → Bool) + (b : ∀ c : ClauseContext F u, ∀ j₀ : {j : J u // validJ F c j = true}, + HalfCube j₀ → Bool) : + GlobalKey (VariableContext F u) (ClauseContext F u) (I u) (J u) → Bool + | .inl (v, f) => a v (canonicalInput (leftAnchor u) f) + | .inr (.inl (c, g)) => + match rightAnchor F c with + | none => false + | some j₀ => b c j₀ (canonicalInput j₀ (restrictQuery (validJ F c) g)) + | .inr (.inr _) => false + +def extendHalfTables (F : Target.Formula) (u : ℕ) + (a : VariableContext F u → HalfCube (leftAnchor u) → Bool) + (b : ∀ c : ClauseContext F u, ∀ j₀ : {j : J u // validJ F c j = true}, + HalfCube j₀ → Bool) : Fin (nBits F u) → Bool := + assignmentOfKey (variableEncoding F u) (clauseEncoding F u) (iEncoding u) (jEncoding u) + (halfTableKeyAssignment F u a b) + +@[simp] theorem extendHalfTables_left (F : Target.Formula) (u : ℕ) + (a : VariableContext F u → HalfCube (leftAnchor u) → Bool) + (b : ∀ c : ClauseContext F u, ∀ j₀ : {j : J u // validJ F c j = true}, + HalfCube j₀ → Bool) (v : VariableContext F u) (h : HalfCube (leftAnchor u)) : + extendHalfTables F u a b ((proofEncoding F u).code (.inl (v, h.val))) = a v h := by + calc + _ = halfTableKeyAssignment F u a b (.inl (v, h.val)) := + assignmentOfKey_code (variableEncoding F u) (clauseEncoding F u) (iEncoding u) + (jEncoding u) (halfTableKeyAssignment F u a b) (.inl (v, h.val)) + _ = a v h := congrArg (a v) (canonicalInput_half (leftAnchor u) h) + +theorem extendHalfTables_right (F : Target.Formula) (u : ℕ) + (a : VariableContext F u → HalfCube (leftAnchor u) → Bool) + (b : ∀ c : ClauseContext F u, ∀ j₀ : {j : J u // validJ F c j = true}, + HalfCube j₀ → Bool) (c : ClauseContext F u) + (j₀ : {j : J u // validJ F c j = true}) (hanchor : rightAnchor F c = some j₀) + (h : HalfCube j₀) : + extendHalfTables F u a b ((proofEncoding F u).code + (.inr (.inl (c, extendRestricted (validJ F c) h.val)))) = b c j₀ h := by + calc + _ = halfTableKeyAssignment F u a b + (.inr (.inl (c, extendRestricted (validJ F c) h.val))) := + assignmentOfKey_code (variableEncoding F u) (clauseEncoding F u) (iEncoding u) + (jEncoding u) (halfTableKeyAssignment F u a b) _ + _ = b c j₀ h := by + simp only [halfTableKeyAssignment, hanchor] + rw [restrictQuery_extendRestricted, canonicalInput_half] + +def emptyAddress (F : Target.Formula) (u : ℕ) (v : VariableContext F u) : + EmptyContext.Address (leftAnchor u) → Fin (nBits F u) + | .inl h => (proofEncoding F u).code (.inl (v, h.val)) + | .inr _ => dummyIndex F u + +def contextEquation (F : Target.Formula) (u D : ℕ) + (c : ClauseContext F u) (v : VariableContext F u) + (t : SourceTape.TestTape (I u) (J u) D) : Equation (Fin (nBits F u)) := + match rightAnchor F c with + | none => mapEquation (emptyAddress F u v) (EmptyContext.equation (leftAnchor u) t.1) + | some j₀ => conditionedOccurrence (variableEncoding F u) (clauseEncoding F u) + (iEncoding u) (jEncoding u) v c (validJ F c) (pi F c v) (leftAnchor u) j₀ + t.1 t.2.2 (realizedNoise t.2.1) + +def leftResponse (F : Target.Formula) (u : ℕ) (bits : Fin (nBits F u) → Bool) + (v : VariableContext F u) : Cube (I u) → Bool := + foldedAnswer (leftAnchor u) (fun h => bits ((proofEncoding F u).code (.inl (v, h.val)))) + +def rightResponse (F : Target.Formula) (u : ℕ) (bits : Fin (nBits F u) → Bool) + (c : ClauseContext F u) : Cube (J u) → Bool := + match rightAnchor F c with + | none => fun _ => false + | some j₀ => conditionedFoldedAnswer (validJ F c) j₀ + (fun h => bits ((proofEncoding F u).code (.inr (.inl (c, extendRestricted (validJ F c) h.val))))) + +theorem contextEquation_satisfied (F : Target.Formula) (u D : ℕ) + (c : ClauseContext F u) (v : VariableContext F u) + (t : SourceTape.TestTape (I u) (J u) D) (bits : Fin (nBits F u) → Bool) : + satisfied (contextEquation F u D c v t) bits = + !(leftResponse F u bits v t.1 ^^ rightResponse F u bits c t.2.2 ^^ + rightResponse F u bits c (thirdQuery (pi F c v) t.1 t.2.2 (realizedNoise t.2.1))) := by + cases ha : rightAnchor F c with + | none => + simp only [contextEquation, ha, satisfied_mapEquation, EmptyContext.equation_satisfied, + rightResponse, Bool.xor_false] + rfl + | some j₀ => + simp only [contextEquation, ha, rightResponse] + exact conditionedOccurrence_satisfied (variableEncoding F u) (clauseEncoding F u) + (iEncoding u) (jEncoding u) v c (validJ F c) (pi F c v) (leftAnchor u) j₀ + bits t.1 t.2.2 (realizedNoise t.2.1) + +def testTapeEncoding (u D : ℕ) : Encoding (SourceTape.TestTape (I u) (J u) D) := + ((iEncoding u).function Encoding.bool).prod + (((jEncoding u).function (Encoding.fin D)).prod ((jEncoding u).function Encoding.bool)) + +abbrev SourceIndex (F : Target.Formula) (u D : ℕ) := + (ClauseContext F u × SlotContext u) × SourceTape.TestTape (I u) (J u) D + +def sourceIndexEncoding (F : Target.Formula) (u D : ℕ) : Encoding (SourceIndex F u D) := + ((clauseEncoding F u).prod (slotContextEncoding u)).prod (testTapeEncoding u D) + +def sourceEquation (F : Target.Formula) (u D : ℕ) (p : SourceIndex F u D) : + Equation (Fin (nBits F u)) := + contextEquation F u D p.1.1 (sampledVariables F p.1.1 p.1.2) p.2 + +def rawSourceList (F : Target.Formula) (u D : ℕ) : List (Equation (Fin (nBits F u))) := + occurrenceList (sourceIndexEncoding F u D) (sourceEquation F u D) + +@[simp] theorem rawSourceList_length (F : Target.Formula) (u D : ℕ) : + (rawSourceList F u D).length = + (F.clauses.length ^ u * 3 ^ u) * + (2 ^ (2 ^ u) * (D ^ (8 ^ u) * 2 ^ (8 ^ u))) := by + rw [rawSourceList, occurrenceList_length] + rfl + +theorem rawSourceList_acceptance (F : Target.Formula) (u D : ℕ) + (hD : 0 < D) (bits : Fin (nBits F u) → Bool) : + ((rawSourceList F u D).countP (fun e => satisfied e bits) : ℝ) / + (rawSourceList F u D).length = + 𝔼 c : ClauseContext F u, 𝔼 s : SlotContext u, + testAcceptance ((D : ℝ)⁻¹) (pi F c (sampledVariables F c s)) + (leftResponse F u bits (sampledVariables F c s)) (rightResponse F u bits c) := by + rw [rawSourceList, occurrenceList_acceptance, SourceTape.expect_prod] + rw [SourceTape.expect_prod] + apply Finset.expect_congr rfl + intro c _ + apply Finset.expect_congr rfl + intro s _ + rw [← SourceTape.tapeAcceptance_eq_testAcceptance hD] + unfold SourceTape.tapeAcceptance + apply Finset.expect_congr rfl + intro t _ + rw [sourceEquation, contextEquation_satisfied] + cases h : leftResponse F u bits (sampledVariables F c s) t.1 ^^ + rightResponse F u bits c t.2.2 ^^ + rightResponse F u bits c + (thirdQuery (pi F c (sampledVariables F c s)) t.1 t.2.2 (realizedNoise t.2.1)) <;> rfl + +def emptyFormulaEquation (F : Target.Formula) (u : ℕ) : Equation (Fin (nBits F u)) := + ⟨dummyIndex F u, dummyIndex F u, dummyIndex F u, false⟩ + +def sourceList (F : Target.Formula) (u D : ℕ) : List (Equation (Fin (nBits F u))) := + if F.clauses.isEmpty then [emptyFormulaEquation F u] else rawSourceList F u D + +theorem sourceList_empty (F : Target.Formula) (u D : ℕ) (h : F.clauses = []) : + sourceList F u D = [emptyFormulaEquation F u] := by simp [sourceList, h] + +theorem sourceList_nonempty (F : Target.Formula) (u D : ℕ) (h : F.clauses ≠ []) : + sourceList F u D = rawSourceList F u D := by + unfold sourceList + rw [List.isEmpty_eq_false_iff.mpr h] + rfl + +theorem sourceList_length_le_raw_add_one (F : Target.Formula) (u D : ℕ) : + (sourceList F u D).length ≤ (rawSourceList F u D).length + 1 := by + by_cases h : F.clauses = [] + · rw [sourceList_empty F u D h] + rw [List.length_singleton] + omega + · rw [sourceList_nonempty F u D h] + omega + +theorem sourceList_ne_nil (F : Target.Formula) (u D : ℕ) (hD : 0 < D) : + sourceList F u D ≠ [] := by + by_cases h : F.clauses = [] + · rw [sourceList_empty F u D h] + simp + · rw [sourceList_nonempty F u D h] + apply List.length_pos_iff.mp + rw [rawSourceList_length] + have hc : 0 < F.clauses.length := List.length_pos_iff.mpr h + positivity + +def sourceInput (F : Target.Formula) (u D : ℕ) (hD : 0 < D) : + IndependentSetsGames.Reduction.SourceEncoding.Input := + ⟨nBits F u, sourceList F u D, sourceList_ne_nil F u D hD⟩ + +theorem emptyFormulaEquation_satisfied (F : Target.Formula) (u : ℕ) + (bits : Fin (nBits F u) → Bool) : + satisfied (emptyFormulaEquation F u) bits = !(bits (dummyIndex F u)) := by + cases h : bits (dummyIndex F u) <;> simp [emptyFormulaEquation, satisfied, h] + +end IndependentSetsGames.Foundations.Hastad.SourceOccurrences + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/Encoding.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/Encoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..18dc01b5f0fac0da1e8321d7257cbc289055cbfe --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/Encoding.lean @@ -0,0 +1,158 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.Target +import OAI.Combinatorics.IndependentSets.PCP.CloneGap + +namespace OAI + +namespace IndependentSetsGames.Reduction.SourceEncoding + +open IndependentSetsGames.Foundations.Complexity + +structure Input where + «variables» : Nat + equations : List (CloneGap.Equation (Fin «variables»)) + nonempty : equations ≠ [] + +abbrev Table := Input + +def equationWords {n : Nat} (e : CloneGap.Equation (Fin n)) : List Nat := + [e.first.val, e.second.val, e.third.val, if e.rhs then 1 else 0] + +def inputWords (input : Input) : List Nat := + [input.«variables», input.equations.length] ++ input.equations.flatMap equationWords + +def inputBits (input : Input) : List Bool := encodeWords (inputWords input) + +def parseEquation («variables» : Nat) : + List Nat → Option (CloneGap.Equation (Fin «variables») × List Nat) + | first :: second :: third :: rhs :: rest => + if hfirst : first < «variables» then + if hsecond : second < «variables» then + if hthird : third < «variables» then + if rhs = 0 then + some (⟨⟨first, hfirst⟩, ⟨second, hsecond⟩, ⟨third, hthird⟩, false⟩, rest) + else if rhs = 1 then + some (⟨⟨first, hfirst⟩, ⟨second, hsecond⟩, ⟨third, hthird⟩, true⟩, rest) + else none + else none + else none + else none + | _ => none + +@[simp] theorem parseEquation_encoded {n : Nat} (e : CloneGap.Equation (Fin n)) + (rest : List Nat) : + parseEquation n (equationWords e ++ rest) = some (e, rest) := by + cases e with + | mk first second third rhs => + cases rhs <;> simp [equationWords, parseEquation, first.isLt, second.isLt, third.isLt] + +def parseEquations («variables» : Nat) : + Nat → List Nat → Option (List (CloneGap.Equation (Fin «variables»)) × List Nat) + | 0, words => some ([], words) + | count + 1, words => do + let (equation, words) ← parseEquation «variables» words + let (equations, words) ← parseEquations «variables» count words + return (equation :: equations, words) + +@[simp] theorem parseEquations_encoded {n : Nat} + (equations : List (CloneGap.Equation (Fin n))) (rest : List Nat) : + parseEquations n equations.length (equations.flatMap equationWords ++ rest) = + some (equations, rest) := by + induction equations with + | nil => rfl + | cons e equations ih => + simp [List.append_assoc, parseEquations, parseEquation_encoded, ih] + +def decodeInputWords : List Nat → Option Input + | «variables» :: count :: words => do + let (equations, trailing) ← parseEquations «variables» count words + if trailing = [] then + if nonempty : 0 < equations.length then + some ⟨«variables», equations, List.length_pos_iff.mp nonempty⟩ + else none + else none + | _ => none + +@[simp] theorem decodeInputWords_encoded (input : Input) : + decodeInputWords (inputWords input) = some input := by + cases input with + | mk «variables» equations nonempty => + have parsed := parseEquations_encoded equations [] + have positive := List.length_pos_iff.mpr nonempty + simp only [List.append_nil] at parsed + simp [decodeInputWords, inputWords, parsed, positive] + +def decodeInputBits (bits : List Bool) : Option Input := + decodeWords bits >>= decodeInputWords + +@[simp] theorem decodeInputBits_encoded (input : Input) : + decodeInputBits (inputBits input) = some input := by + simp [decodeInputBits, inputBits] + +theorem inputWords_injective {first second : Input} + (same : inputWords first = inputWords second) : first = second := by + have parsed := congrArg decodeInputWords same + simpa only [decodeInputWords_encoded, Option.some.injEq] using parsed + +theorem inputBits_injective {first second : Input} + (same : inputBits first = inputBits second) : first = second := by + have parsed := congrArg decodeInputBits same + simpa only [decodeInputBits_encoded, Option.some.injEq] using parsed + +@[simp] theorem equationWords_length {n : Nat} (e : CloneGap.Equation (Fin n)) : + (equationWords e).length = 4 := by simp [equationWords] + +theorem equationsWords_length {n : Nat} (equations : List (CloneGap.Equation (Fin n))) : + (equations.flatMap equationWords).length = 4 * equations.length := by + induction equations with + | nil => rfl + | cons e equations ih => + simp only [List.flatMap_cons, List.length_append, equationWords_length, + List.length_cons, ih, Nat.mul_add, Nat.mul_one] + omega + +@[simp] theorem inputWords_length (input : Input) : + (inputWords input).length = 2 + 4 * input.equations.length := by + simp only [inputWords, List.length_append, List.length_cons, List.length_nil, + equationsWords_length] + +theorem equationBits_length_le {n : Nat} (e : CloneGap.Equation (Fin n)) : + (encodeWords (equationWords e)).length ≤ 3 * n + 2 := by + have hfirst := e.first.isLt + have hsecond := e.second.isLt + have hthird := e.third.isLt + cases hrhs : e.rhs <;> simp [equationWords, hrhs] <;> omega + +theorem equationsBits_length_le {n : Nat} (equations : List (CloneGap.Equation (Fin n))) : + (encodeWords (equations.flatMap equationWords)).length ≤ + equations.length * (3 * n + 2) := by + induction equations with + | nil => simp [encodeWords] + | cons e equations ih => + have he := equationBits_length_le e + simp only [List.flatMap_cons, encodeWords_append, List.length_append, + List.length_cons, Nat.add_mul, Nat.one_mul] + omega + +theorem inputBits_length (input : Input) : + (inputBits input).length = input.«variables» + input.equations.length + 2 + + (encodeWords (input.equations.flatMap equationWords)).length := by + simp only [inputBits, inputWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +theorem inputBits_length_le (input : Input) : + (inputBits input).length ≤ input.«variables» + input.equations.length + 2 + + input.equations.length * (3 * input.«variables» + 2) := by + rw [inputBits_length] + exact Nat.add_le_add_left (equationsBits_length_le input.equations) _ + +theorem inputBits_length_ge_variables (input : Input) : + input.«variables» ≤ (inputBits input).length := by rw [inputBits_length]; omega + +theorem inputBits_length_ge_equations (input : Input) : + input.equations.length ≤ (inputBits input).length := by rw [inputBits_length]; omega + +end IndependentSetsGames.Reduction.SourceEncoding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/FinalTableFormula.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/FinalTableFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..02124b140199dec5278a74c5c61f70847ab30a07 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/FinalTableFormula.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.FinalCNFPattern +import OAI.Combinatorics.IndependentSets.Encoding.GraphTableComplexity +import OAI.Combinatorics.IndependentSets.Fourier.Gap +import OAI.Combinatorics.IndependentSets.PCP.PCPIteration + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.FinalTableFormula + +open Target Complexity + +def output (table : GraphTables.Table) : Formula := + FinalBooleanVerifier.cnf (FinalCNFPattern.tableGraph table) (Equiv.refl _) (Equiv.refl _) + +theorem satisfiable_iff (table : GraphTables.Table) : + (output table).Satisfiable ↔ (GraphTables.semantics table).Satisfiable := + (FinalBooleanVerifier.cnf_satisfiable_iff (FinalCNFPattern.tableGraph table) + (Equiv.refl _) (Equiv.refl _)).trans + ((GraphTables.semantics table).satisfiable_reindex (Equiv.refl _) (Equiv.refl _) + FinalCNFPattern.labelEquiv.symm) + +@[simp] theorem variable_count (table : GraphTables.Table) : + (output table).«variables» = table.vertices * 6 + table.darts * 36864 := + FinalBooleanVerifier.cnf_variable_count _ (Equiv.refl _) (Equiv.refl _) + +@[simp] theorem clause_count (table : GraphTables.Table) : + (output table).clauses.length = table.darts * 40960 := + FinalBooleanVerifier.cnf_clause_count _ (Equiv.refl _) (Equiv.refl _) + +theorem nonempty (table : GraphTables.Table) (hd : 0 < table.darts) : + (output table).clauses ≠ [] := + FinalBooleanVerifier.cnf_nonempty _ (Equiv.refl _) (Equiv.refl _) hd + +theorem tableGraph_rejectionCount (table : GraphTables.Table) + (labeling : Fin table.vertices → FinalBooleanVerifier.Label) : + (FinalCNFPattern.tableGraph table).rejectionCount labeling = + (GraphTables.semantics table).rejectionCount + (fun v => FinalCNFPattern.labelEquiv (labeling v)) := by + have h := (GraphTables.semantics table).reindex_rejectionCount + (Equiv.refl _) (Equiv.refl _) FinalCNFPattern.labelEquiv.symm + (fun v => FinalCNFPattern.labelEquiv (labeling v)) + simpa [FinalCNFPattern.tableGraph, ConstraintGraph.labelingEquiv] using h + +theorem tableGraph_count_lower (table : GraphTables.Table) (walkLength : Nat) + (hgap : ∀ labeling : Fin table.vertices → GraphTables.Label, + table.darts ≤ walkLength * (GraphTables.semantics table).rejectionCount labeling) + (labeling : Fin table.vertices → FinalBooleanVerifier.Label) : + Fintype.card (Fin table.darts) ≤ + walkLength * (FinalCNFPattern.tableGraph table).rejectionCount labeling := by + rw [Fintype.card_fin, tableGraph_rejectionCount] + exact hgap _ + +theorem clauseGap (table : GraphTables.Table) (hd : 0 < table.darts) + (hgap : ∀ labeling : Fin table.vertices → GraphTables.Label, + table.darts ≤ FinalConstants.walkLength * + (GraphTables.semantics table).rejectionCount labeling) : + Hastad.SourceGap.ClauseGap (output table) PCPIteration.finalClauseGap := by + let : Nonempty (Fin table.darts) := ⟨⟨0, hd⟩⟩ + exact Hastad.SourceNonempty.cnf_clauseGap_unit (FinalCNFPattern.tableGraph table) + (Equiv.refl _) (Equiv.refl _) FinalConstants.walkLength + FinalConstants.walkLength_positive (tableGraph_count_lower table _ hgap) + +theorem total_size_le (table : GraphTables.Table) : + (output table).«variables» + (output table).clauses.length ≤ + 77824 * (table.vertices + table.darts) := by + have hv := variable_count table + have hc := clause_count table + omega + +noncomputable def sizePolynomial : Polynomial Nat := + Polynomial.C 77824 * Polynomial.X + Polynomial.C 2 + + (Polynomial.C 40960 * Polynomial.X) * + (Polynomial.C 3 * (Polynomial.C 36864 * Polynomial.X + Polynomial.C 2)) + +theorem sizePolynomial_eval (N : Nat) : + sizePolynomial.eval N = 77824 * N + 2 + (40960 * N) * (3 * (36864 * N + 2)) := by + simp [sizePolynomial] + +theorem formulaBits_length_le_polynomial (table : GraphTables.Table) : + (formulaBits (output table)).length ≤ + sizePolynomial.eval (GraphTables.tableBits table).length := by + have hinput := GraphTableComplexity.size_add_two_le_bits table + have hv : (output table).«variables» ≤ 36864 * (GraphTables.tableBits table).length := by + rw [variable_count] + omega + have hc : (output table).clauses.length ≤ 40960 * (GraphTables.tableBits table).length := by + rw [clause_count] + omega + have hsum : (output table).«variables» + (output table).clauses.length + 2 ≤ + 77824 * (GraphTables.tableBits table).length + 2 := by omega + have hproduct := Nat.mul_le_mul hc (Nat.mul_le_mul_left 3 (Nat.add_le_add_right hv 2)) + rw [sizePolynomial_eval] + exact (formulaBits_length_le (output table)).trans (Nat.add_le_add hsum hproduct) + +end IndependentSetsGames.Foundations.PCP.FinalTableFormula + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/FormulaEncoding.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/FormulaEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..a23ad8663d2fdf60441833a6d59aa02f840349c8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/FormulaEncoding.lean @@ -0,0 +1,85 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.Target + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity + +open Target + +def parseLiteral («variables» : Nat) : List Nat → Option (Literal «variables» × List Nat) + | index :: sign :: rest => + if bounded : index < «variables» then + if sign = 0 then some (⟨⟨index, bounded⟩, false⟩, rest) + else if sign = 1 then some (⟨⟨index, bounded⟩, true⟩, rest) + else none + else none + | _ => none + +@[simp] theorem parseLiteral_encoded {n : Nat} (literal : Literal n) (rest : List Nat) : + parseLiteral n (literalWords literal ++ rest) = some (literal, rest) := by + cases literal with + | mk index positive => + cases positive <;> simp [literalWords, parseLiteral, index.isLt] + +def parseClause («variables» : Nat) (words : List Nat) : Option (Clause «variables» × List Nat) := do + let (a, words) ← parseLiteral «variables» words + let (b, words) ← parseLiteral «variables» words + let (c, words) ← parseLiteral «variables» words + return (⟨#[a, b, c], rfl⟩, words) + +theorem clause_three_entries {n : Nat} (clause : Clause n) : + (⟨#[clause[0], clause[1], clause[2]], rfl⟩ : Clause n) = clause := by + apply Vector.ext + intro i hi + have cases_i : i = 0 ∨ i = 1 ∨ i = 2 := by omega + rcases cases_i with rfl | rfl | rfl <;> rfl + +@[simp] theorem parseClause_encoded {n : Nat} (clause : Clause n) (rest : List Nat) : + parseClause n (clauseWords clause ++ rest) = some (clause, rest) := by + simp [clauseWords, List.append_assoc, parseClause, parseLiteral_encoded, + clause_three_entries] + +def parseClauses («variables» : Nat) : Nat → List Nat → Option (List (Clause «variables») × List Nat) + | 0, words => some ([], words) + | count + 1, words => do + let (clause, words) ← parseClause «variables» words + let (clauses, words) ← parseClauses «variables» count words + return (clause :: clauses, words) + +@[simp] theorem parseClauses_encoded {n : Nat} (clauses : List (Clause n)) (rest : List Nat) : + parseClauses n clauses.length (clauses.flatMap clauseWords ++ rest) = some (clauses, rest) := by + induction clauses with + | nil => rfl + | cons clause clauses ih => + simp [List.append_assoc, parseClauses, parseClause_encoded, ih] + +def decodeFormulaWords : List Nat → Option Formula + | «variables» :: count :: words => do + let (clauses, trailing) ← parseClauses «variables» count words + if trailing = [] then some ⟨«variables», clauses⟩ else none + | _ => none + +@[simp] theorem decodeFormulaWords_encoded (formula : Formula) : + decodeFormulaWords (formulaWords formula) = some formula := by + cases formula with + | mk «variables» clauses => + have parsed := parseClauses_encoded clauses [] + simp only [List.append_nil] at parsed + simp [decodeFormulaWords, formulaWords, parsed] + +def decodeFormulaBits (bits : List Bool) : Option Formula := + decodeWords bits >>= decodeFormulaWords + +@[simp] theorem decodeFormulaBits_encoded (formula : Formula) : + decodeFormulaBits (formulaBits formula) = some formula := by + simp [decodeFormulaBits, formulaBits] + +theorem formulaBits_injective {first second : Formula} + (same : formulaBits first = formulaBits second) : first = second := by + have parsed := congrArg decodeFormulaBits same + simpa only [decodeFormulaBits_encoded, Option.some.injEq] using parsed + +end IndependentSetsGames.Foundations.Complexity + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/GameEncoding.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/GameEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..226e3d4b272a74b42dfa717f620fc1f3e93a3713 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/GameEncoding.lean @@ -0,0 +1,180 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.Target + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity + +open Target + +def parseLabel (alphabet value : Nat) : Option (Fin alphabet) := + if bounded : value < alphabet then some ⟨value, bounded⟩ else none + +@[simp] theorem parseLabel_value {q : Nat} (label : Fin q) : + parseLabel q label.val = some label := by simp [parseLabel, label.isLt] + +@[simp] theorem parseLabels_values {q : Nat} (labels : List (Fin q)) : + (labels.map Fin.val).mapM (parseLabel q) = some labels := by + induction labels with + | nil => rfl + | cons label labels ih => simp [ih] + +def parseImages (alphabet : Nat) (words : List Nat) : Option (Vector (Fin alphabet) alphabet) := do + let labels ← words.mapM (parseLabel alphabet) + if length_ok : labels.length = alphabet then + some ⟨labels.toArray, by simpa using length_ok⟩ + else none + +@[simp] theorem parseImages_values {q : Nat} (images : Vector (Fin q) q) : + parseImages q (images.toList.map Fin.val) = some images := by + unfold parseImages + rw [parseLabels_values] + simp + exact Vector.toArray_toList + +def findPreimage {q : Nat} (images : Vector (Fin q) q) (label : Fin q) : Fin q := + ((List.finRange q).find? (fun x => decide (images[x] = label))).getD label + +theorem findPreimage_permutation {q : Nat} (table : PermutationTable q) (label : Fin q) : + findPreimage table.images label = table.inverseImages[label] := by + have exists_preimage : + ((List.finRange q).find? (fun x => decide (table.images[x] = label))).isSome := by + apply List.find?_isSome.mpr + exact ⟨table.inverseImages[label], List.mem_finRange _, by + simpa only [decide_eq_true_eq] using table.rightInverse label⟩ + cases found : (List.finRange q).find? (fun x => decide (table.images[x] = label)) with + | none => + rw [found] at exists_preimage + contradiction + | some x => + have image_eq : table.images[x] = label := by + simpa using List.find?_some found + have x_eq := table.images_injective (image_eq.trans (table.rightInverse label).symm) + unfold findPreimage + rw [found] + exact x_eq + +def searchedInverse {q : Nat} (images : Vector (Fin q) q) : Vector (Fin q) q := + Vector.ofFn (findPreimage images) + +theorem searchedInverse_permutation {q : Nat} (table : PermutationTable q) : + searchedInverse table.images = table.inverseImages := by + apply Vector.ext + intro i hi + simpa [searchedInverse] using findPreimage_permutation table ⟨i, hi⟩ + +def tableWords {q : Nat} (table : PermutationTable q) : List Nat := + table.images.toList.map Fin.val + +def parsePermutation (alphabet : Nat) (words : List Nat) : Option (PermutationTable alphabet) := do + let images ← parseImages alphabet words + let inverseImages := searchedInverse images + if left : ∀ label : Fin alphabet, inverseImages[images[label]] = label then + if right : ∀ label : Fin alphabet, images[inverseImages[label]] = label then + some ⟨images, inverseImages, left, right⟩ + else none + else none + +@[simp] theorem parsePermutation_encoded {q : Nat} (table : PermutationTable q) : + parsePermutation q (tableWords table) = some table := by + simp only [parsePermutation, tableWords, parseImages_values] + dsimp only [Bind.bind, Option.bind] + simp only [searchedInverse_permutation] + simp only [table.leftInverse, table.rightInverse, implies_true, dite_true] + +@[simp] theorem tableWords_length {q : Nat} (table : PermutationTable q) : + (tableWords table).length = q := by simp [tableWords] + +def constraintWords {n q : Nat} (constraint : Constraint n q) : List Nat := + [constraint.source.val, constraint.target.val] ++ tableWords constraint.permutation + +def parseConstraint (vertices alphabet : Nat) : + List Nat → Option (Constraint vertices alphabet × List Nat) + | source :: target :: words => do + let source ← parseLabel vertices source + let target ← parseLabel vertices target + let permutation ← parsePermutation alphabet (words.take alphabet) + return (⟨source, target, permutation⟩, words.drop alphabet) + | _ => none + +@[simp] theorem parseConstraint_encoded {n q : Nat} + (constraint : Constraint n q) (rest : List Nat) : + parseConstraint n q (constraintWords constraint ++ rest) = some (constraint, rest) := by + cases constraint with + | mk source target permutation => + have taken := List.take_left' (l₂ := rest) (tableWords_length permutation) + have dropped := List.drop_left' (l₂ := rest) (tableWords_length permutation) + simp [constraintWords, parseConstraint, taken, dropped] + +def parseConstraints (vertices alphabet : Nat) : + Nat → List Nat → Option (List (Constraint vertices alphabet) × List Nat) + | 0, words => some ([], words) + | count + 1, words => do + let (constraint, words) ← parseConstraint vertices alphabet words + let (constraints, words) ← parseConstraints vertices alphabet count words + return (constraint :: constraints, words) + +@[simp] theorem parseConstraints_encoded {n q : Nat} + (constraints : List (Constraint n q)) (rest : List Nat) : + parseConstraints n q constraints.length (constraints.flatMap constraintWords ++ rest) = + some (constraints, rest) := by + induction constraints with + | nil => rfl + | cons constraint constraints ih => + simp [parseConstraints, List.append_assoc, ih] + +def gameWords {q : Nat} (game : Instance q) : List Nat := + [game.vertices, q, game.constraints.length] ++ game.constraints.flatMap constraintWords + +def gameBits {q : Nat} (game : Instance q) : List Bool := encodeWords (gameWords game) + +def decodeGameWords (alphabet : Nat) : List Nat → Option (Instance alphabet) + | vertices :: encodedAlphabet :: count :: words => do + if encodedAlphabet = alphabet then + let (constraints, trailing) ← parseConstraints vertices alphabet count words + if trailing = [] then + if nonempty : constraints ≠ [] then some ⟨vertices, constraints, nonempty⟩ else none + else none + else none + | _ => none + +@[simp] theorem decodeGameWords_encoded {q : Nat} (game : Instance q) : + decodeGameWords q (gameWords game) = some game := by + cases game with + | mk vertices constraints nonempty => + have parsed := parseConstraints_encoded constraints [] + simp only [List.append_nil] at parsed + simp [decodeGameWords, gameWords, parsed, nonempty] + +def decodeGameBits (alphabet : Nat) (bits : List Bool) : Option (Instance alphabet) := + decodeWords bits >>= decodeGameWords alphabet + +@[simp] theorem decodeGameBits_encoded {q : Nat} (game : Instance q) : + decodeGameBits q (gameBits game) = some game := by + simp [decodeGameBits, gameBits] + +theorem gameBits_injective {q : Nat} {first second : Instance q} + (same : gameBits first = gameBits second) : first = second := by + have parsed := congrArg (decodeGameBits q) same + simpa only [decodeGameBits_encoded, Option.some.injEq] using parsed + +@[simp] theorem constraintWords_length {n q : Nat} (constraint : Constraint n q) : + (constraintWords constraint).length = q + 2 := by simp [constraintWords] + +theorem constraintsWords_length {n q : Nat} (constraints : List (Constraint n q)) : + (constraints.flatMap constraintWords).length = constraints.length * (q + 2) := by + induction constraints with + | nil => simp + | cons constraint constraints ih => + simp only [List.flatMap_cons, List.length_append, constraintWords_length, + List.length_cons, Nat.add_mul, Nat.one_mul, ih] + omega + +@[simp] theorem gameWords_length {q : Nat} (game : Instance q) : + (gameWords game).length = 3 + game.constraints.length * (q + 2) := by + simp only [gameWords, List.length_append, List.length_cons, List.length_nil, + constraintsWords_length] + +end IndependentSetsGames.Foundations.Complexity + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/GapFormula.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/GapFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..63eefceaffd496f2255869ddbcae4a33cce87884 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/GapFormula.lean @@ -0,0 +1,66 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Simple +import OAI.Combinatorics.IndependentSets.PCP.RoundTableGap +import OAI.Combinatorics.IndependentSets.Reduction.FrameNonempty + +namespace OAI + +namespace LargeIndependentSets +open IndependentSetsGames.Foundations +open scoped Classical +noncomputable section + +namespace SemanticReduction +open Target PCP Hastad.SourceContexts Hastad.SourceGame + +def gapFormula (H : RoundTables.BaseTable) (F : LargeIndependentSets.Formula) : Target.Formula := + TableIteration.gapMap H (Normalization.normalize F) + +instance eventsNonempty (H : RoundTables.BaseTable) (F : LargeIndependentSets.Formula) : + Nonempty (RandomEvent (gapFormula H F)) := + event_nonempty _ (TableIteration.gapMap_nonempty H _) + +def reduce (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 < q) + (F : LargeIndependentSets.Formula) : Graph := + p.output q hq (LCInput.labelCover (gapFormula H F) u) + +lemma complete (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 < q) + (F : LargeIndependentSets.Formula) (hs : F.Satisfiable) : + (reduce H p u q hq F).ThreeColorable := by + obtain ⟨l,r,hr⟩ := LCInput.complete (gapFormula H F) u + (TableIteration.gapMap_completeness H _ ((Normalization.normalize_satisfiable_iff F).mpr hs)) + exact p.output_complete q hq _ l r hr + +lemma vertex_bound (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 < q) + (F : LargeIndependentSets.Formula) : + (reduce H p u q hq F).vertices ≤ + max q ((((gapFormula H F).clauses.length * 3)^u)^p.n * (p.law (J u) (I u)).denominator) := by + simpa only [reduce, RandomEvent, Hastad.SourceContexts.card_slot, Fintype.card_fun, Fintype.card_prod, + Fintype.card_fin] using p.output_size q hq (LCInput.labelCover (gapFormula H F) u) + +end SemanticReduction + +theorem semantic_reduction {δ : ℚ} (hδ : 0 < δ) : + ∃ H : PCP.RoundTables.BaseTable, ∃ p : SamplerParameters, ∃ u q : ℕ, ∃ hq : 0 < q, + (∀ F : Formula, F.Satisfiable → (SemanticReduction.reduce H p u q hq F).ThreeColorable) ∧ + (∀ F : Formula, ¬F.Satisfiable → + ((SemanticReduction.reduce H p u q hq F).independenceNumber : ℚ) < + δ*(SemanticReduction.reduce H p u q hq F).vertices) := by + obtain ⟨H,hH⟩ := PCP.ExpanderTables.exists_base_table + obtain ⟨p,σ,q,hq,hσ,hσ1,hp⟩ := finite_graph_reduction (show (0:ℝ) < δ by exact_mod_cast hδ) + obtain ⟨u,hu,hrep⟩ := LCInput.uniform_repetition + PCP.PCPIteration.finalClauseGap_positive PCP.TableGapReduction.finalClauseGap_le_one hσ + refine ⟨H,p,u,q,hq,SemanticReduction.complete H p u q hq,?_⟩ + intro F hF + have hg : Hastad.SourceGap.ClauseGap (SemanticReduction.gapFormula H F) + PCP.PCPIteration.finalClauseGap := + PCP.TableGapReduction.gapMap_clauseGap H hH _ + (fun hs => hF ((Normalization.normalize_satisfiable_iff F).mp hs)) + have hs := (hp _ _ _ _ _ (LCInput.labelCover (SemanticReduction.gapFormula H F) u)).2 + (hrep _ hg) + exact_mod_cast hs + +end +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/GeometryExpr.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/GeometryExpr.lean new file mode 100644 index 0000000000000000000000000000000000000000..29ed2b0cc648e9261f60344ad60e675db4bd98e8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/GeometryExpr.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.LCTable +import OAI.Combinatorics.IndependentSets.Geometry.GeometryNaming + +namespace OAI + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC +open scoped Classical BigOperators +noncomputable section + +variable (L R : Type) [Fintype L] [Fintype R] (n D : ℕ) [NeZero D] + +abbrev staticCount := Fintype.card (StaticPoint L R n D) +abbrev size (t : Table L R) := (t.nu^n*t.nv^n)*staticCount L R n D + +lemma staticCount_pos : 0 0⟩⟩ + exact Fintype.card_pos +lemma size_pos (t : Table L R) : 0 simpa [mixed_val,hl] using hk + · intro h + have hij : i=j := congrArg Sigma.fst h + subst j + refine ⟨rfl,?_⟩ + have hq : mixed u v i.val=mixed u' v' i.val := Sigma.mk.inj_iff.mp h |>.2 |> eq_of_heq + intro k + have hh := congrFun (congrArg Subtype.val hq) k + by_cases hl : k.val < i.val <;> simpa [mixed_val,hl] using hh + +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/GraphPrinter.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/GraphPrinter.lean new file mode 100644 index 0000000000000000000000000000000000000000..37c53cb5fa30f542b5072d82136079e525b69797 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/GraphPrinter.lean @@ -0,0 +1,105 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.BinaryNameTables + +namespace OAI + +namespace LargeIndependentSets.GraphPrinter +open IndependentSetsCut.CounterMachine +open IndependentSetsGames.Foundations.Complexity +open scoped Classical +noncomputable section + +lemma matrix_eq (G : Graph) : + (List.finRange G.vertices).flatMap (fun i => (List.finRange G.vertices).map (G.adj i)) = + List.ofFn (fun i : Fin (G.vertices*G.vertices) => G.adj i.divNat i.modNat) := by + rw [List.ofFn_mul] + simp only [List.ofFn_eq_map,List.flatMap_def] + congr 1 + apply List.map_congr_left + intro i _ + apply List.map_congr_left + intro j _ + congr 1 + · apply Fin.ext + simp only [Fin.divNat] + rw [Nat.add_comm (i.val * G.vertices),Nat.add_mul_div_right _ _ G.nonempty,Nat.div_eq_of_lt j.isLt,Nat.zero_add] + · apply Fin.ext + simp [Fin.modNat,Nat.mod_eq_of_lt j.isLt] + +lemma bits_get (G : Graph) (w : ℕ) (hw : w<(graphBits G).length) : + ((graphBits G)[w]?).getD false= + if h : w<(nameBits G.vertices).length then ((nameBits G.vertices)[w]?).getD false + else G.adj + (⟨w-(nameBits G.vertices).length,by + apply Nat.sub_lt_left_of_lt_add (Nat.le_of_not_gt h) + simpa only [graphBits,List.length_append,matrix_eq,List.length_ofFn] using hw⟩ : Fin (G.vertices*G.vertices)).divNat + (⟨w-(nameBits G.vertices).length,by + apply Nat.sub_lt_left_of_lt_add (Nat.le_of_not_gt h) + simpa only [graphBits,List.length_append,matrix_eq,List.length_ofFn] using hw⟩ : Fin (G.vertices*G.vertices)).modNat := by + simp only [graphBits,matrix_eq] + split_ifs with h + · rw [List.getElem?_append_left h] + · rw [List.getElem?_append_right (Nat.le_of_not_gt h),List.getElem?_ofFn] + have hb : w-(nameBits G.vertices).length .sub (.arg 0) (Expr.framedLen n))) + +lemma printer_spec (n adj : Expr) (s : List Bool) (G : Graph) + (hn : ∀ a, n.eval s a=G.vertices) + (ha : ∀ i : Fin (G.vertices*G.vertices), + decide (adj.eval s (fun _ => i.val)≠0)=G.adj i.divNat i.modNat) : + table (lengthExpr n) (bitExpr n adj) s=graphBits G := by + have hlen : (lengthExpr n).eval s (fun _ => 0)=(graphBits G).length := by + simp only [lengthExpr,Expr.eval,Expr.framedLen_eval,hn,graphBits,List.length_append, + matrix_eq,List.length_ofFn,nameBits,frame_length,Nat.size_eq_bits_len] + apply List.ext_getElem + · simpa only [table,List.length_ofFn] using hlen + · intro w hw hg + simp only [table,List.getElem_ofFn] + have hget : ((graphBits G)[w]?).getD false=(graphBits G)[w] := by + rw [List.getElem?_eq_getElem hg]; rfl + rw [← hget] + rw [bits_get G w hg] + have hheader : (nameBits G.vertices).length=2*G.vertices.size+1 := by + simp [nameBits,frame_length,Nat.size_eq_bits_len] + simp only [bitExpr,Expr.cond_eval,Expr.lt_eval,Expr.eval,Expr.framedLen_eval,hn, + Expr.subst_eval,Expr.framedBit_eval] + by_cases h : w<2*G.vertices.size+1 + · simp only [hheader,h,ite_true,dite_eq_left] + rw [ite_eq_left (show (1:ℕ)≠0 by decide)] + simpa only [nameBits,BinaryNames.frame_eq,Nat.one_ne_zero,ite_true] using (frame_bits_get G.vertices w).symm + · simp only [hheader,h,ite_false,ne_eq,not_true_eq_false] + have hb : w-(2*G.vertices.size+1) i.val)≠0)=(f x).adj i.divNat i.modNat) : + Turing.TM2ComputableInPolyTime ea graphBits f where + tm := (tableComputer (lengthExpr n) (bitExpr n adj)).tm + inputAlphabet := (tableComputer (lengthExpr n) (bitExpr n adj)).inputAlphabet + outputAlphabet := (tableComputer (lengthExpr n) (bitExpr n adj)).outputAlphabet + time := (tableComputer (lengthExpr n) (bitExpr n adj)).time + outputsFun x := by + simpa only [id_eq,printer_spec n adj (ea x) (f x) (hn x) (ha x)] using + (tableComputer (lengthExpr n) (bitExpr n adj)).outputsFun (ea x) + +lemma encodedComputer_finiteAlphabet {α : Type} (ea : α → List Bool) (f : α → Graph) + (n adj : Expr) (hn) (ha) : + MachineFiniteAlphabet.FiniteAlphabet (encodedComputer ea f n adj hn ha).tm := + tableComputer_finiteAlphabet _ _ + +end +end LargeIndependentSets.GraphPrinter + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/GraphTableComplexity.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/GraphTableComplexity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1dc4731042158f49f0c515762475ffa21de1e6bd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/GraphTableComplexity.lean @@ -0,0 +1,71 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GraphTables +import OAI.Combinatorics.IndependentSets.PCP.GenericGraphTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.GraphTableComplexity + +open IndependentSetsGames.Foundations.Complexity +open Polynomial + +noncomputable def encodingPolynomial (q : Nat) : Polynomial Nat := + X ^ 2 + C (2 * (q * q) + 1) * X + C 2 + +theorem encodingPolynomial_eval (q n : Nat) : + (encodingPolynomial q).eval n = n ^ 2 + (2 * (q * q) + 1) * n + 2 := by + simp [encodingPolynomial] + +theorem encodingPolynomial_mono (q : Nat) {n m : Nat} (hnm : n ≤ m) : + (encodingPolynomial q).eval n ≤ (encodingPolynomial q).eval m := by + rw [encodingPolynomial_eval, encodingPolynomial_eval] + exact Nat.add_le_add_right + (Nat.add_le_add (Nat.pow_le_pow_left hnm 2) (Nat.mul_le_mul_left _ hnm)) 2 + +theorem rowBound_le_polynomial (q vertices darts : Nat) : + vertices + darts + 2 + darts * (vertices + darts + 2 * (q * q)) ≤ + (encodingPolynomial q).eval (vertices + darts) := by + have hd : darts ≤ vertices + darts := Nat.le_add_left darts vertices + calc + _ ≤ vertices + darts + 2 + + (vertices + darts) * (vertices + darts + 2 * (q * q)) := + Nat.add_le_add_left (Nat.mul_le_mul_right _ hd) _ + _ = _ := by rw [encodingPolynomial_eval]; ring + +theorem generic_size_add_two_le_bits {q : Nat} (table : GenericGraphTables.Table q) : + table.vertices + table.darts + 2 ≤ (GenericGraphTables.tableBits table).length := by + simp only [GenericGraphTables.tableBits, GenericGraphTables.tableWords, + encodeWords_append, List.length_append, encodeWords, encodeWord_length, List.length_nil] + omega + +theorem generic_bits_le_polynomial {q : Nat} (table : GenericGraphTables.Table q) : + (GenericGraphTables.tableBits table).length ≤ + (encodingPolynomial q).eval (table.vertices + table.darts) := + (GenericGraphTables.tableBits_length_le table).trans + (rowBound_le_polynomial q table.vertices table.darts) + +theorem generic_bits_le_of_size_le {q N : Nat} (table : GenericGraphTables.Table q) + (hsize : table.vertices + table.darts ≤ N) : + (GenericGraphTables.tableBits table).length ≤ (encodingPolynomial q).eval N := + (generic_bits_le_polynomial table).trans (encodingPolynomial_mono q hsize) + +theorem size_add_two_le_bits (table : GraphTables.Table) : + table.vertices + table.darts + 2 ≤ (GraphTables.tableBits table).length := by + simp only [GraphTables.tableBits, GraphTables.tableWords, + encodeWords_append, List.length_append, encodeWords, encodeWord_length, List.length_nil] + omega + +theorem bits_le_polynomial (table : GraphTables.Table) : + (GraphTables.tableBits table).length ≤ + (encodingPolynomial 64).eval (table.vertices + table.darts) := + (GraphTables.tableBits_length_le table).trans + (rowBound_le_polynomial 64 table.vertices table.darts) + +theorem bits_le_of_size_le {N : Nat} (table : GraphTables.Table) + (hsize : table.vertices + table.darts ≤ N) : + (GraphTables.tableBits table).length ≤ (encodingPolynomial 64).eval N := + (bits_le_polynomial table).trans (encodingPolynomial_mono 64 hsize) + +end IndependentSetsGames.Foundations.PCP.GraphTableComplexity + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/LogSum.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/LogSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fcbc2123fab7dde081e4f6caf62afe6188c4c5f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/LogSum.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Repetition.Finite + +namespace OAI + +namespace IndependentSetsGames.Foundations.Information + +open scoped BigOperators + +variable {α : Type*} [Fintype α] + +theorem normalize_isProbability (b : α → ℝ) (hb : ∀ a, 0 ≤ b a) + {B : ℝ} (hB : 0 < B) (hmass : ∑ a, b a = B) : + IsProbability (fun a => b a / B) := by + constructor + · intro a + exact div_nonneg (hb a) hB.le + · simp only [div_eq_mul_inv, ← Finset.sum_mul, hmass, mul_inv_cancel₀ hB.ne'] + +theorem relativeEntropy_normalize_right (p b : α → ℝ) (hp : IsProbability p) + (hs : SupportedBy p b) {B : ℝ} (hB : 0 < B) : + relativeEntropy p (fun a => b a / B) = relativeEntropy p b + Real.log B := by + have hpoint : ∀ a, p a * Real.log (p a / (b a / B)) = + p a * Real.log (p a / b a) + p a * Real.log B := by + intro a + by_cases hpa : p a = 0 + · simp [hpa] + have hbne := hs a hpa + rw [Real.log_div hpa (div_ne_zero hbne hB.ne'), Real.log_div hbne hB.ne', + Real.log_div hpa hbne] + ring + simp only [relativeEntropy, hpoint, Finset.sum_add_distrib, ← Finset.sum_mul, hp.2, one_mul] + +theorem neg_relativeEntropy_le_log_mass (p b : α → ℝ) (hp : IsProbability p) + (hb : ∀ a, 0 ≤ b a) (hs : SupportedBy p b) {B : ℝ} (hB : 0 < B) + (hmass : ∑ a, b a = B) : -relativeEntropy p b ≤ Real.log B := by + have hs' : SupportedBy p (fun a => b a / B) := + fun a ha => div_ne_zero (hs a ha) hB.ne' + have hnonneg := relativeEntropy_nonneg p (fun a => b a / B) hp + (normalize_isProbability b hb hB hmass) hs' + rw [relativeEntropy_normalize_right p b hp hs hB] at hnonneg + linarith + +theorem posterior_weighted_log_inverse_le (p b c : α → ℝ) (hp : IsProbability p) + (hb : ∀ a, 0 ≤ b a) {z B : ℝ} (hz : 0 < z) (hB : 0 < B) + (hmass : ∑ a, b a = B) (hpost : ∀ a, p a = b a * c a / z) : + (∑ a, p a * Real.log (1 / c a)) ≤ Real.log (B / z) := by + have hs : SupportedBy p b := by + intro a ha hba + apply ha + rw [hpost, hba, zero_mul, zero_div] + have hpoint : ∀ a, p a * Real.log (1 / c a) = + p a * Real.log (1 / z) - p a * Real.log (p a / b a) := by + intro a + by_cases hpa : p a = 0 + · simp [hpa] + have hbne := hs a hpa + have hcne : c a ≠ 0 := by + intro hca + apply hpa + rw [hpost, hca, mul_zero, zero_div] + have hratio : p a / b a = c a / z := by + rw [hpost] + field_simp [hbne, hz.ne'] + rw [hratio, Real.log_div hcne hz.ne', Real.log_div one_ne_zero hcne, + Real.log_div one_ne_zero hz.ne', Real.log_one] + ring + have hid : (∑ a, p a * Real.log (1 / c a)) = + Real.log (1 / z) - relativeEntropy p b := by + simp only [hpoint, Finset.sum_sub_distrib, ← Finset.sum_mul, hp.2, one_mul, + relativeEntropy] + have hkl := neg_relativeEntropy_le_log_mass p b hp hb hs hB hmass + rw [hid, Real.log_div hB.ne' hz.ne', Real.log_div one_ne_zero hz.ne', Real.log_one] + linarith + +end IndependentSetsGames.Foundations.Information + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/Normalizer.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/Normalizer.lean new file mode 100644 index 0000000000000000000000000000000000000000..000d30b8e87a1b3d038dcd2713940e8381842e57 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/Normalizer.lean @@ -0,0 +1,159 @@ +import Mathlib + +namespace OAI + +namespace LargeIndependentSets.Coefficient +open scoped BigOperators Classical + +noncomputable def normalizer (m : ℕ) (ρ : ℝ) : ℝ := ∑ k : Fin (m+1), ρ^k.val +noncomputable def levelMass (m : ℕ) (ρ : ℝ) (k : Fin (m+1)) : ℝ := + ρ^k.val / normalizer m ρ +noncomputable def mass {ι : Type*} [Fintype ι] (m : ℕ) (ρ : ℝ) + (t : ι → Fin (m+1)) : ℝ := ∏ i, levelMass m ρ (t i) + +lemma normalizer_pos (m : ℕ) {ρ : ℝ} (hρ : 0 ≤ ρ) : 0 < normalizer m ρ := by + apply Finset.sum_pos' + · intro i _ + exact pow_nonneg hρ _ + · exact ⟨0, Finset.mem_univ _, by simp⟩ + +lemma levelMass_pos (m : ℕ) {ρ : ℝ} (hρ : 0 < ρ) (k : Fin (m+1)) : + 0 < levelMass m ρ k := div_pos (pow_pos hρ _) (normalizer_pos m hρ.le) + +lemma levelMass_nonneg (m : ℕ) {ρ : ℝ} (hρ : 0 ≤ ρ) (k : Fin (m+1)) : + 0 ≤ levelMass m ρ k := div_nonneg (pow_nonneg hρ _) (normalizer_pos m hρ).le + +lemma levelMass_total (m : ℕ) {ρ : ℝ} (hρ : 0 ≤ ρ) : + ∑ k, levelMass m ρ k = 1 := by + simp only [levelMass, ← Finset.sum_div] + exact div_self (normalizer_pos m hρ).ne' + +lemma mass_nonneg {ι : Type*} [Fintype ι] (m : ℕ) {ρ : ℝ} (hρ : 0 ≤ ρ) + (t : ι → Fin (m+1)) : 0 ≤ mass m ρ t := + Finset.prod_nonneg (fun _ _ => levelMass_nonneg m hρ _) + +lemma mass_total {ι : Type*} [Fintype ι] [DecidableEq ι] (m : ℕ) {ρ : ℝ} (hρ : 0 ≤ ρ) : + ∑ t : ι → Fin (m+1), mass m ρ t = 1 := by + simp only [mass] + rw [← Fintype.prod_sum] + simp [levelMass_total m hρ] + +noncomputable def lower {ι : Type*} [DecidableEq ι] {m : ℕ} + (i : ι) (t : ι → Fin (m+1)) : ι → Fin (m+1) := + Function.update t i ⟨(t i).val - 1, by omega⟩ + +lemma lower_injective_on_positive {ι : Type*} [DecidableEq ι] {m : ℕ} (i : ι) + {t u : ι → Fin (m+1)} (ht : 0 < (t i).val) (hu : 0 < (u i).val) + (he : lower i t = lower i u) : t = u := by + funext j + by_cases hji : j = i + · subst j + have h := congrArg (fun v => (v i).val) he + simp only [lower, Function.update_self] at h + exact Fin.ext (by omega) + · simpa only [lower, Function.update_of_ne hji] using congrFun he j + +lemma levelMass_lower {m : ℕ} {ρ : ℝ} (k : Fin (m+1)) (hk : 0 < k.val) : + levelMass m ρ k = ρ * levelMass m ρ ⟨k.val-1, by omega⟩ := by + dsimp [levelMass] + have he : k.val = (k.val-1)+1 := by omega + conv_lhs => rw [he] + rw [pow_succ] + ring + +lemma mass_lower {ι : Type*} [Fintype ι] [DecidableEq ι] {m : ℕ} {ρ : ℝ} + (i : ι) (t : ι → Fin (m+1)) (ht : 0 < (t i).val) : + mass m ρ t = ρ * mass m ρ (lower i t) := by + have he : (fun j => levelMass m ρ (lower i t j)) = + Function.update (fun j => levelMass m ρ (t j)) i + (levelMass m ρ ⟨(t i).val - 1, by omega⟩) := by + funext j + by_cases hj : j = i <;> simp [lower, hj] + change ∏ j, levelMass m ρ (t j) = ρ * ∏ j, levelMass m ρ (lower i t j) + rw [he, Finset.prod_update_of_mem (Finset.mem_univ i)] + rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ i), levelMass_lower (t i) ht] + simp only [Finset.sdiff_singleton_eq_erase] + ring + +theorem one_level_event_bound {ι : Type*} [Fintype ι] [DecidableEq ι] + {m : ℕ} {ρ : ℝ} (hρ : 0 ≤ ρ) (i : ι) + (high low : (ι → Fin (m+1)) → Prop) + (hstep : ∀ t, 0 < (t i).val → high t → low (lower i t)) : + (∑ t ∈ Finset.univ.filter (fun t => 0 < (t i).val ∧ high t), mass m ρ t) ≤ + ρ * ∑ t ∈ Finset.univ.filter low, mass m ρ t := by + let A := Finset.univ.filter (fun t => 0 < (t i).val ∧ high t) + have himage : A.image (lower i) ⊆ Finset.univ.filter low := by + intro u hu + obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hu + have ht' := (Finset.mem_filter.mp ht).2 + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hstep t ht'.1 ht'.2⟩ + have hinj : Set.InjOn (lower (m:=m) i) (A : Set (ι → Fin (m+1))) := by + intro t ht u hu he + exact lower_injective_on_positive i (Finset.mem_filter.mp ht).2.1 + (Finset.mem_filter.mp hu).2.1 he + calc + _ = ρ * ∑ t ∈ A, mass m ρ (lower i t) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro t ht + exact mass_lower i t (Finset.mem_filter.mp ht).2.1 + _ = ρ * ∑ u ∈ A.image (lower i), mass m ρ u := by rw [Finset.sum_image hinj] + _ ≤ _ := mul_le_mul_of_nonneg_left + (Finset.sum_le_sum_of_subset_of_nonneg himage (fun u _ _ => mass_nonneg m hρ u)) hρ + +theorem positive_coefficient_bound {ι : Type*} [Fintype ι] [DecidableEq ι] + {m : ℕ} {ρ β K : ℝ} (hρ : 0 ≤ ρ) + (D : (ι → Fin (m+1)) → ι → ℝ) + (hstep : ∀ t i, 0 < (t i).val → |D t i - D (lower i t) i| < β/2) + (hcount : ∀ t, ((Finset.univ.filter (fun i => β/2 ≤ D t i)).card : ℝ) ≤ K) : + (∑ t ∈ Finset.univ.filter (fun t => ∃ i, 0 < (t i).val ∧ β ≤ D t i), mass m ρ t) ≤ + ρ*K := by + let A : ι → Finset (ι → Fin (m+1)) := fun i => + Finset.univ.filter (fun t => 0 < (t i).val ∧ β ≤ D t i) + have hpoint (t : ι → Fin (m+1)) : + (if ∃ i, 0 < (t i).val ∧ β ≤ D t i then mass m ρ t else 0) ≤ + ∑ i, if 0 < (t i).val ∧ β ≤ D t i then mass m ρ t else 0 := by + split_ifs with ht + · obtain ⟨i, hi⟩ := ht + calc + _ = if 0 < (t i).val ∧ β ≤ D t i then mass m ρ t else 0 := by rw [ite_eq_left hi] + _ ≤ _ := Finset.single_le_sum (f := fun j : ι => + if 0 < (t j).val ∧ β ≤ D t j then mass m ρ t else 0) + (fun j _ => by split_ifs <;> first | exact mass_nonneg m hρ t | exact le_rfl) + (Finset.mem_univ i) + · exact Finset.sum_nonneg (fun i _ => by + split_ifs <;> first | exact mass_nonneg m hρ t | exact le_rfl) + calc + _ ≤ ∑ i, ∑ t ∈ A i, mass m ρ t := by + simp only [Finset.sum_filter, A] + rw [Finset.sum_comm] + exact Finset.sum_le_sum (fun t _ => hpoint t) + _ ≤ ∑ i, ρ * ∑ t ∈ Finset.univ.filter (fun t => β/2 ≤ D t i), mass m ρ t := by + apply Finset.sum_le_sum + intro i _ + apply one_level_event_bound hρ i + intro t ht hd + have hs := (abs_lt.mp (hstep t i ht)).2 + linarith + _ = ρ * ∑ t, mass m ρ t * ((Finset.univ.filter (fun i => β/2 ≤ D t i)).card : ℝ) := by + rw [← Finset.mul_sum] + congr 1 + simp only [Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro t _ + rw [← Finset.sum_filter] + simp [Finset.sum_const, nsmul_eq_mul, mul_comm] + _ ≤ ρ * ∑ t : ι → Fin (m+1), mass m ρ t * K := by + apply mul_le_mul_of_nonneg_left _ hρ + apply Finset.sum_le_sum + intro t _ + exact mul_le_mul_of_nonneg_left (hcount t) (mass_nonneg m hρ t) + _ = ρ*K := by + rw [← Finset.sum_mul] + have hm : (∑ t : ι → Fin (m+1), mass m ρ t) = 1 := mass_total (ι:=ι) m hρ + rw [hm, one_mul] + +end LargeIndependentSets.Coefficient + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/Occurrences.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/Occurrences.lean new file mode 100644 index 0000000000000000000000000000000000000000..76715e1e94dd12883cf139e5ebc19e6def303c90 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/Occurrences.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Folding + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceOccurrences + +open scoped BigOperators + +structure Encoding (α : Type) where + size : ℕ + code : α ≃ Fin size + +namespace Encoding + +def fin (n : ℕ) : Encoding (Fin n) := ⟨n, Equiv.refl _⟩ +def bool : Encoding Bool := ⟨2, finTwoEquiv.symm⟩ +def unit : Encoding Unit := ⟨1, finOneEquiv.symm⟩ + +def prod {α β : Type} (a : Encoding α) (b : Encoding β) : Encoding (α × β) := + ⟨a.size * b.size, (Equiv.prodCongr a.code b.code).trans finProdFinEquiv⟩ + +def sum {α β : Type} (a : Encoding α) (b : Encoding β) : Encoding (α ⊕ β) := + ⟨a.size + b.size, (Equiv.sumCongr a.code b.code).trans finSumFinEquiv⟩ + +def function {α β : Type} (a : Encoding α) (b : Encoding β) : Encoding (α → β) where + size := b.size ^ a.size + code := (show (α → β) ≃ (Fin a.size → Fin b.size) from + { toFun := fun f i => b.code (f (a.code.symm i)) + invFun := fun f x => b.code.symm (f (a.code x)) + left_inv := by intro f; funext x; simp + right_inv := by intro f; funext i; simp }).trans finFunctionFinEquiv + +def enumerate {α : Type} (a : Encoding α) : List α := List.ofFn a.code.symm + +@[simp] theorem length_enumerate {α : Type} (a : Encoding α) : + a.enumerate.length = a.size := by simp [enumerate] + +theorem mem_enumerate {α : Type} (a : Encoding α) (x : α) : x ∈ a.enumerate := by + rw [enumerate, List.mem_ofFn'] + exact ⟨a.code x, a.code.symm_apply_apply x⟩ + +theorem nodup_enumerate {α : Type} (a : Encoding α) : a.enumerate.Nodup := + List.nodup_ofFn_ofInjective a.code.symm.injective + +theorem card_eq_size {α : Type} [Fintype α] (a : Encoding α) : + Fintype.card α = a.size := by + simpa only [Fintype.card_fin] using Fintype.card_congr a.code + +end Encoding + +abbrev GlobalKey (V C I J : Type) := (V × Cube I) ⊕ ((C × Cube J) ⊕ Unit) + +def globalEncoding {V C I J : Type} + (v : Encoding V) (c : Encoding C) (i : Encoding I) (j : Encoding J) : + Encoding (GlobalKey V C I J) := + (v.prod (i.function Encoding.bool)).sum + ((c.prod (j.function Encoding.bool)).sum Encoding.unit) + +@[simp] theorem globalEncoding_size {V C I J : Type} + (v : Encoding V) (c : Encoding C) (i : Encoding I) (j : Encoding J) : + (globalEncoding v c i j).size = + v.size * 2 ^ i.size + (c.size * 2 ^ j.size + 1) := rfl + +def extendRestricted {J : Type} (valid : J → Bool) + (f : Cube {j : J // valid j = true}) : Cube J := + fun j => if h : valid j = true then f ⟨j, h⟩ else false + +@[simp] theorem extendRestricted_valid {J : Type} (valid : J → Bool) + (f : Cube {j : J // valid j = true}) (j : {j : J // valid j = true}) : + extendRestricted valid f j.val = f j := by simp [extendRestricted, j.property] + +theorem extendRestricted_injective {J : Type} (valid : J → Bool) : + Function.Injective (extendRestricted valid) := by + intro f g h + funext j + have := congrFun h j.val + simpa only [extendRestricted_valid] using this + +@[simp] theorem restrictQuery_extendRestricted {J : Type} (valid : J → Bool) + (f : Cube {j : J // valid j = true}) : + restrictQuery valid (extendRestricted valid f) = f := by + funext j + exact extendRestricted_valid valid f j + +@[simp] theorem canonicalInput_half {I : Type} [Fintype I] [DecidableEq I] + (i₀ : I) (f : HalfCube i₀) : + canonicalInput i₀ f.val = f := by + apply Subtype.ext + simp [canonicalInput, representative, f.property] + +def assignmentOfKey {V C I J : Type} + (v : Encoding V) (c : Encoding C) (i : Encoding I) (j : Encoding J) + (bits : GlobalKey V C I J → Bool) : Fin (globalEncoding v c i j).size → Bool := + fun q => bits ((globalEncoding v c i j).code.symm q) + +@[simp] theorem assignmentOfKey_code {V C I J : Type} + (v : Encoding V) (c : Encoding C) (i : Encoding I) (j : Encoding J) + (bits : GlobalKey V C I J → Bool) (key : GlobalKey V C I J) : + assignmentOfKey v c i j bits ((globalEncoding v c i j).code key) = bits key := by + exact congrArg bits ((globalEncoding v c i j).code.symm_apply_apply key) + +theorem assignmentOfKey_surjective {V C I J : Type} + (v : Encoding V) (c : Encoding C) (i : Encoding I) (j : Encoding J) : + Function.Surjective (assignmentOfKey v c i j) := by + intro bits + refine ⟨fun key => bits ((globalEncoding v c i j).code key), ?_⟩ + funext q + exact congrArg bits ((globalEncoding v c i j).code.apply_symm_apply q) + +end IndependentSetsGames.Foundations.Hastad.SourceOccurrences + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/PortTableEncoding.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/PortTableEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..f80d5a07f16ff18dcc2ba2bb3f60f9de01772dc3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/PortTableEncoding.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PortTables +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLabels + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PortTables + +variable {n d : Nat} + +def HasPortTails (rows : GraphTables.Rows n (n * d)) : Prop := + ∀ i : Fin (n * d), rows[i].tail = ((rowIndex n d).symm i).1 + +instance (rows : GraphTables.Rows n (n * d)) : Decidable (HasPortTails rows) := by + unfold HasPortTails + infer_instance + +@[simp] theorem flatRows_hasPortTails (table : Table n d) : HasPortTails (flatRows table) := by + intro i + simp [flatRows] + +def ofRows (rows : GraphTables.Rows n (n * d)) (valid : GraphTables.Valid rows) : Table n d where + reverseIndex := Vector.ofFn (fun i => rows[i].reverseIndex) + relations := Vector.ofFn (fun i => rows[i].relation) + involutive := by + intro i + simp only [Fin.getElem_fin, Vector.getElem_ofFn] + exact valid.1 i + transpose := by + intro i a b + simp only [Fin.getElem_fin, Vector.getElem_ofFn] + exact valid.2 i a b + +private theorem table_ext {table table' : Table n d} + (hr : table.reverseIndex = table'.reverseIndex) + (hp : table.relations = table'.relations) : table = table' := by + cases table + cases table' + cases hr + cases hp + rfl + +@[simp] theorem ofRows_flatRows (table : Table n d) : + ofRows (flatRows table) (flatRows_valid table) = table := by + apply table_ext + · apply Vector.ext + intro i hi + simp [ofRows, flatRows] + · apply Vector.ext + intro i hi + simp [ofRows, flatRows] + +def extractInput (ports : Nat) : GraphTables.Table → Option (Input ports) + | ⟨vertices, darts, rows, valid⟩ => + if count_ok : darts = vertices * ports then + let rows' : GraphTables.Rows vertices (vertices * ports) := count_ok ▸ rows + let valid' : GraphTables.Valid rows' := by + cases count_ok + exact valid + if HasPortTails rows' then + some ⟨vertices, ofRows rows' valid'⟩ + else none + else none + +@[simp] theorem extractInput_graphTable (table : Table n d) : + extractInput d (graphTable table) = some (⟨n, table⟩ : Input d) := by + simp [extractInput, graphTable] + +def decodeInputBits (ports : Nat) (bits : List Bool) : Option (Input ports) := + GraphTables.decodeTableBits bits >>= extractInput ports + +@[simp] theorem decodeInputBits_inputBits {ports : Nat} (input : Input ports) : + decodeInputBits ports (inputBits input) = some input := by + rcases input with ⟨vertices, table⟩ + simp [decodeInputBits, inputBits, tableBits] + +def encoding (ports : Nat) : Computability.Encoding (Input ports) Bool where + encode := inputBits + decode := decodeInputBits ports + decode_encode := decodeInputBits_inputBits + +theorem inputBits_injective (ports : Nat) : Function.Injective (@inputBits ports) := + (encoding ports).encode_injective + +end IndependentSetsGames.Foundations.PCP.PortTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/Target.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/Target.lean new file mode 100644 index 0000000000000000000000000000000000000000..4bc67274a9e00e6175ccbdbcd39a8c5c78516005 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/Target.lean @@ -0,0 +1,240 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.Target + +structure Literal («variables» : Nat) where + variableIndex : Fin «variables» + positive : Bool + deriving DecidableEq + +def Literal.eval {n : Nat} (literal : Literal n) (assignment : Fin n → Bool) : Bool := + if literal.positive then assignment literal.variableIndex else !(assignment literal.variableIndex) + +abbrev Clause («variables» : Nat) := Vector (Literal «variables») 3 + +def Clause.eval {n : Nat} (clause : Clause n) (assignment : Fin n → Bool) : Bool := + (clause[0].eval assignment || clause[1].eval assignment) || clause[2].eval assignment + +structure Formula where + «variables» : Nat + clauses : List (Clause «variables») + +def Formula.Satisfiable (formula : Formula) : Prop := + ∃ assignment : Fin formula.«variables» → Bool, + ∀ clause ∈ formula.clauses, clause.eval assignment = true + +structure PermutationTable (alphabet : Nat) where + images : Vector (Fin alphabet) alphabet + inverseImages : Vector (Fin alphabet) alphabet + leftInverse : ∀ label : Fin alphabet, inverseImages[images[label]] = label + rightInverse : ∀ label : Fin alphabet, images[inverseImages[label]] = label + +theorem PermutationTable.images_injective {q : Nat} (table : PermutationTable q) + {x y : Fin q} (h : table.images[x] = table.images[y]) : x = y := by + have inverseEquality := congrArg (fun label : Fin q => table.inverseImages[label]) h + simpa only [table.leftInverse] using inverseEquality + +theorem PermutationTable.images_surjective {q : Nat} (table : PermutationTable q) + (label : Fin q) : ∃ preimage : Fin q, table.images[preimage] = label := + ⟨table.inverseImages[label], table.rightInverse label⟩ + +structure Constraint (vertices alphabet : Nat) where + source : Fin vertices + target : Fin vertices + permutation : PermutationTable alphabet + +def Constraint.satisfied {n q : Nat} (constraint : Constraint n q) + (labeling : Fin n → Fin q) : Bool := + decide (constraint.permutation.images[labeling constraint.source] = labeling constraint.target) + +structure Instance (alphabet : Nat) where + vertices : Nat + constraints : List (Constraint vertices alphabet) + nonempty : constraints ≠ [] + +def countSatisfied {n q : Nat} (labeling : Fin n → Fin q) : + List (Constraint n q) → Nat + | [] => 0 + | constraint :: rest => + (if constraint.satisfied labeling then 1 else 0) + countSatisfied labeling rest + +theorem countSatisfied_le_length {n q : Nat} (labeling : Fin n → Fin q) + (constraints : List (Constraint n q)) : + countSatisfied labeling constraints ≤ constraints.length := by + induction constraints with + | nil => simp [countSatisfied] + | cons constraint rest ih => + simp only [countSatisfied, List.length_cons] + split <;> omega + +theorem Instance.constraintCount_positive {q : Nat} (game : Instance q) : + 0 < game.constraints.length := by + cases h : game.constraints with + | nil => exact False.elim (game.nonempty h) + | cons constraint rest => simp + +structure RationalError where + numerator : Nat + denominator : Nat + numeratorPositive : 0 < numerator + denominatorPositive : 0 < denominator + belowHalf : 2 * numerator < denominator + +def CompleteAt {q : Nat} (error : RationalError) (game : Instance q) : Prop := + ∃ labeling : Fin game.vertices → Fin q, + error.denominator * game.constraints.length ≤ + error.denominator * countSatisfied labeling game.constraints + + error.numerator * game.constraints.length + +def SoundAt {q : Nat} (error : RationalError) (game : Instance q) : Prop := + ∀ labeling : Fin game.vertices → Fin q, + error.denominator * countSatisfied labeling game.constraints ≤ + error.numerator * game.constraints.length + +structure SemanticGapReduction (completenessError soundnessError : RationalError) where + alphabet : Nat + alphabetAtLeastTwo : 2 ≤ alphabet + reduce : Formula → Instance alphabet + completeness : ∀ formula : Formula, + formula.Satisfiable → CompleteAt completenessError (reduce formula) + soundness : ∀ formula : Formula, + ¬ formula.Satisfiable → SoundAt soundnessError (reduce formula) + +end IndependentSetsGames.Foundations.Target + +namespace IndependentSetsGames.Foundations.Complexity + +def encodeWord (n : Nat) : List Bool := List.replicate n true ++ [false] + +def encodeWords : List Nat → List Bool + | [] => [] + | n :: ns => encodeWord n ++ encodeWords ns + +def decodeWordsAux : List Bool → Nat → Option (List Nat) + | [], 0 => some [] + | [], _ + 1 => none + | true :: bs, n => decodeWordsAux bs (n + 1) + | false :: bs, n => (decodeWordsAux bs 0).map (n :: ·) + +def decodeWords (bs : List Bool) : Option (List Nat) := decodeWordsAux bs 0 + +theorem decodeWordsAux_word (n k : Nat) (bs : List Bool) : + decodeWordsAux (encodeWord n ++ bs) k = + (decodeWordsAux bs 0).map ((k + n) :: ·) := by + induction n generalizing k with + | zero => simp [encodeWord, decodeWordsAux] + | succ n ih => + simp only [encodeWord, List.replicate_succ, List.cons_append, List.append_assoc, + decodeWordsAux] + simpa [encodeWord, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using ih (k + 1) + +@[simp] theorem decodeWords_encodeWords (ns : List Nat) : + decodeWords (encodeWords ns) = some ns := by + induction ns with + | nil => rfl + | cons n ns ih => + simp only [decodeWords, encodeWords, decodeWordsAux_word, Nat.zero_add] + simpa [decodeWords] using congrArg (Option.map (n :: ·)) ih + +theorem encodeWords_injective {xs ys : List Nat} (h : encodeWords xs = encodeWords ys) : + xs = ys := by + have decoded := congrArg decodeWords h + simpa only [decodeWords_encodeWords, Option.some.injEq] using decoded + +@[simp] theorem encodeWord_length (n : Nat) : (encodeWord n).length = n + 1 := by + simp [encodeWord] + +@[simp] theorem encodeWords_append (xs ys : List Nat) : + encodeWords (xs ++ ys) = encodeWords xs ++ encodeWords ys := by + induction xs with + | nil => rfl + | cons x xs ih => simp [encodeWords, ih, List.append_assoc] + +@[simp] theorem encodeWords_length (ns : List Nat) : + (encodeWords ns).length = ns.sum + ns.length := by + induction ns with + | nil => rfl + | cons n ns ih => simp [encodeWords, ih]; omega + +theorem encodeWords_length_le (ns : List Nat) (bound : Nat) + (bounded : ∀ n ∈ ns, n ≤ bound) : + (encodeWords ns).length ≤ ns.length * (bound + 1) := by + induction ns with + | nil => simp [encodeWords] + | cons n ns ih => + have hn := bounded n (by simp) + have hns := ih (fun x hx => bounded x (by simp [hx])) + simp only [encodeWords, List.length_append, encodeWord_length, List.length_cons, + Nat.add_mul, Nat.one_mul] + omega + +open Target + +def literalWords {n : Nat} (literal : Literal n) : List Nat := + [literal.variableIndex.val, if literal.positive then 1 else 0] + +def clauseWords {n : Nat} (clause : Clause n) : List Nat := + literalWords clause[0] ++ literalWords clause[1] ++ literalWords clause[2] + +def formulaWords (formula : Formula) : List Nat := + [formula.«variables», formula.clauses.length] ++ formula.clauses.flatMap clauseWords + +def formulaBits (formula : Formula) : List Bool := encodeWords (formulaWords formula) + +@[simp] theorem literalWords_length {n : Nat} (literal : Literal n) : + (literalWords literal).length = 2 := by simp [literalWords] + +@[simp] theorem clauseWords_length {n : Nat} (clause : Clause n) : + (clauseWords clause).length = 6 := by simp [clauseWords] + +theorem clausesWords_length {n : Nat} (clauses : List (Clause n)) : + (clauses.flatMap clauseWords).length = 6 * clauses.length := by + induction clauses with + | nil => rfl + | cons clause clauses ih => + simp only [List.flatMap_cons, List.length_append, clauseWords_length, + List.length_cons, ih, Nat.mul_add, Nat.mul_one] + omega + +@[simp] theorem formulaWords_length (formula : Formula) : + (formulaWords formula).length = 2 + 6 * formula.clauses.length := by + simp only [formulaWords, List.length_append, List.length_cons, List.length_nil, + clausesWords_length] + +theorem literalBits_length_le {n : Nat} (literal : Literal n) : + (encodeWords (literalWords literal)).length ≤ n + 2 := by + have hindex := literal.variableIndex.isLt + cases hp : literal.positive <;> simp [literalWords, hp] + +theorem clauseBits_length_le {n : Nat} (clause : Clause n) : + (encodeWords (clauseWords clause)).length ≤ 3 * (n + 2) := by + have h0 := literalBits_length_le clause[0] + have h1 := literalBits_length_le clause[1] + have h2 := literalBits_length_le clause[2] + simp only [clauseWords, encodeWords_append, List.length_append] + omega + +theorem clausesBits_length_le {n : Nat} (clauses : List (Clause n)) : + (encodeWords (clauses.flatMap clauseWords)).length ≤ clauses.length * (3 * (n + 2)) := by + induction clauses with + | nil => simp [encodeWords] + | cons clause clauses ih => + have hc := clauseBits_length_le clause + simp only [List.flatMap_cons, encodeWords_append, List.length_append, + List.length_cons, Nat.add_mul, Nat.one_mul] + omega + +theorem formulaBits_length_le (formula : Formula) : + (formulaBits formula).length ≤ + formula.«variables» + formula.clauses.length + 2 + + formula.clauses.length * (3 * (formula.«variables» + 2)) := by + have h := clausesBits_length_le formula.clauses + simp only [formulaBits, formulaWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +end IndependentSetsGames.Foundations.Complexity + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/TargetFormula.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/TargetFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..471e819a456591c8ceca29f1905db818c807b357 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/TargetFormula.lean @@ -0,0 +1,110 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Model +import OAI.Combinatorics.IndependentSets.Encoding.Target + +namespace OAI + +namespace LargeIndependentSets +open scoped BigOperators +namespace Normalization + +abbrev TargetFormula := IndependentSetsGames.Foundations.Target.Formula +abbrev TargetClause := IndependentSetsGames.Foundations.Target.Clause +abbrev TargetLiteral := IndependentSetsGames.Foundations.Target.Literal + +def names (F : Formula) : List ℕ := F.clauses.flatten.map Literal.name + +def nameIndex (F : Formula) (v : ℕ) : Fin ((names F).length + 1) := + ⟨(names F).idxOf v, Nat.lt_succ_of_le List.idxOf_le_length⟩ + +def literal (F : Formula) (l : Literal) : TargetLiteral ((names F).length + 1) := + ⟨nameIndex F l.name, l.positive⟩ + +def pad (C : List Literal) (i : Fin 3) : Literal := + C[i.val]?.getD (C.headD ⟨0,true⟩) + +def clause (F : Formula) (C : List Literal) : TargetClause ((names F).length + 1) := + Vector.ofFn (fun i => literal F (pad C i)) + +lemma literal_eval_true (F : Formula) (l : Literal) (a : Fin ((names F).length+1) → Bool) : + (literal F l).eval a = true ↔ a (nameIndex F l.name) = l.positive := by + simp only [literal, IndependentSetsGames.Foundations.Target.Literal.eval] + have H : ∀ p x : Bool, (if p then x else !x) = true ↔ x = p := by + intro p x; cases p <;> cases x <;> decide + exact H _ _ + +lemma clause_eval_true (F : Formula) (C : List Literal) (hne : C ≠ []) (hw : C.length ≤ 3) + (a : Fin ((names F).length+1) → Bool) : + (clause F C).eval a = true ↔ ∃ l ∈ C, a (nameIndex F l.name) = l.positive := by + cases C with + | nil => exact False.elim (hne rfl) + | cons x tail => + cases tail with + | nil => simp [clause, pad, IndependentSetsGames.Foundations.Target.Clause.eval, literal_eval_true] + | cons y tail => + cases tail with + | nil => simp [clause, pad, IndependentSetsGames.Foundations.Target.Clause.eval, literal_eval_true, or_comm] + | cons z tail => + have ht : tail = [] := by + apply List.length_eq_zero_iff.mp + simp only [List.length_cons] at hw + omega + subst tail + simp [clause, pad, IndependentSetsGames.Foundations.Target.Clause.eval, literal_eval_true, or_assoc] + +lemma name_mem (F : Formula) (C : List Literal) (hC : C ∈ F.clauses) (l : Literal) (hl : l ∈ C) : + l.name ∈ names F := by + exact List.mem_map.mpr ⟨l, List.mem_flatten.mpr ⟨C,hC,hl⟩,rfl⟩ + +lemma lookup_variable (F : Formula) {v : ℕ} (hv : v ∈ names F) : + (names F)[(nameIndex F v).val]?.getD 0 = v := by + simp only [nameIndex] + rw [List.getElem?_eq_getElem (List.idxOf_lt_length_iff.mpr hv), List.getElem_idxOf] + rfl + +def contradiction : TargetFormula where + «variables» := 1 + clauses := [Vector.replicate 3 ⟨0,true⟩, Vector.replicate 3 ⟨0,false⟩] + +lemma contradiction_unsat : ¬contradiction.Satisfiable := by + unfold contradiction IndependentSetsGames.Foundations.Target.Formula.Satisfiable + rintro ⟨a,ha⟩ + have hp := ha (Vector.replicate 3 ⟨0,true⟩) (by simp) + have hn := ha (Vector.replicate 3 ⟨0,false⟩) (by simp) + simp only [IndependentSetsGames.Foundations.Target.Clause.eval, Vector.getElem_replicate, + IndependentSetsGames.Foundations.Target.Literal.eval, Bool.or_self] at hp hn + cases h : a 0 <;> simp [h] at hp hn + +def normalize (F : Formula) : TargetFormula := + if [] ∈ F.clauses then contradiction + else ⟨(names F).length+1,F.clauses.map (clause F)⟩ + +lemma normalize_satisfiable_iff (F : Formula) : (normalize F).Satisfiable ↔ F.Satisfiable := by + by_cases hempty : [] ∈ F.clauses + · rw [normalize,ite_eq_left hempty] + constructor + · intro h; exact False.elim (contradiction_unsat h) + · rintro ⟨a,ha⟩ + obtain ⟨l,hl,_⟩ := ha [] hempty + simp at hl + · rw [normalize,ite_eq_right hempty] + constructor + · rintro ⟨a,ha⟩ + refine ⟨fun v => a (nameIndex F v),?_⟩ + intro C hC + exact (clause_eval_true F C (fun h => hempty (h ▸ hC)) (F.width C hC) a).mp + (ha _ (List.mem_map.mpr ⟨C,hC,rfl⟩)) + · rintro ⟨a,ha⟩ + refine ⟨fun i => a ((names F)[i.val]?.getD 0),?_⟩ + intro C hC + obtain ⟨D,hD,rfl⟩ := List.mem_map.mp hC + apply (clause_eval_true F D (fun h => hempty (h ▸ hD)) (F.width D hD) _).mpr + obtain ⟨l,hl,hs⟩ := ha D hD + refine ⟨l,hl,?_⟩ + rw [lookup_variable F (name_mem F D hD l hl)] + exact hs + +end Normalization +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Encoding/TargetLCExpr.lean b/lean/OAI/Combinatorics/IndependentSets/Encoding/TargetLCExpr.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bb31c36177342910a523759e06ad86668f61250 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Encoding/TargetLCExpr.lean @@ -0,0 +1,108 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.TargetLC +import OAI.Combinatorics.IndependentSets.Reduction.TargetRead + +namespace OAI + +namespace LargeIndependentSets.TargetLC +open IndependentSetsGames.Foundations IndependentSetsGames.Foundations.Complexity +open IndependentSetsCut.CounterMachine +open Target PCP Hastad.SourceContexts Hastad.SourceGame UniformLC +open TargetRead TargetRepair +open scoped Classical BigOperators +noncomputable section +variable (u : ℕ) + +def eventExpr (x : Expr) (k : Fin u) : Expr := + Expr.remainder (Expr.quotient x (Expr.power (.mul clausesExpr (.const 3)) k.val)) + (.mul clausesExpr (.const 3)) +def clauseExpr (x : Expr) (k : Fin u) : Expr := Expr.quotient (eventExpr u x k) (.const 3) +def slotExpr (x : Expr) (k : Fin u) : Expr := Expr.remainder (eventExpr u x k) (.const 3) + +lemma clauseExpr_eval (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) (k : Fin u) : + (clauseExpr u x k).eval (Complexity.formulaBits F.val) a= + (((eventEquiv u F.val).symm i k).1).val := by + simp only [clauseExpr,eventExpr,Expr.remainder_eval,Expr.quotient_eval,Expr.power_eval, + Expr.eval,clausesExpr_eval,hi] + rfl + +lemma slotExpr_eval (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) (k : Fin u) : + (slotExpr u x k).eval (Complexity.formulaBits F.val) a= + (RawInitialTables.slotOrder (((eventEquiv u F.val).symm i k).2)).val := by + simp only [slotExpr,eventExpr,Expr.remainder_eval,Expr.quotient_eval,Expr.power_eval, + Expr.eval,clausesExpr_eval,hi] + change _=(RawInitialTables.slotOrder (RawInitialTables.slotOrder.symm _)).val + rw [Equiv.apply_symm_apply] + rfl + +def sampledNameExpr (x : Expr) (k : Fin u) : Expr := + selectSlot (slotExpr u x k) (nameExpr (clauseExpr u x k)) +def projectedBitExpr (x : Expr) (j : J u) (k : Fin u) : Expr := + selectSlot (slotExpr u x k) (repairExpr (clauseExpr u x k) (j k)) + +lemma sampledNameExpr_eval (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) (k : Fin u) : + (sampledNameExpr u x k).eval (Complexity.formulaBits F.val) a= + (nameAt (clauseAt F.val (((eventEquiv u F.val).symm i k).1)) + (((eventEquiv u F.val).symm i k).2)).val := by + rw [sampledNameExpr,selectSlot_eval _ _ _ _ _ (slotExpr_eval u F x a i hi k)] + exact nameExpr_eval F.val _ a _ (clauseExpr_eval u F x a i hi k) _ + +lemma projectedBitExpr_eval (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) (j : J u) (k : Fin u) : + (projectedBitExpr u x j k).eval (Complexity.formulaBits F.val) a= + bit ((table u F).project i j k) := by + rw [projectedBitExpr,selectSlot_eval _ _ _ _ _ (slotExpr_eval u F x a i hi k)] + rw [repairExpr_eval _ _ _ _ (clauseExpr_eval u F x a i hi k)] + congr 1 + exact (project_apply u F.val _ j k).symm + +def rankExpr (base : Expr) (f : Fin u → Expr) : Expr := + Expr.listSum (List.finRange u) (fun k => .mul (f k) (Expr.power base k.val)) +lemma rankExpr_eval (s : List Bool) (a : ℕ → ℕ) (base : Expr) (f : Fin u → Expr) + {m : ℕ} (v : Fin u → Fin m) (hb : base.eval s a=m) (hf : ∀ k, (f k).eval s a=(v k).val) : + (rankExpr u base f).eval s a=(finFunctionFinEquiv v).val := by + simp only [rankExpr,Expr.listSum_eval,Expr.eval,Expr.power_eval,hb,hf,finFunctionFinEquiv_apply] + rw [← List.ofFn_eq_map,List.sum_ofFn] + +def leftExpr (x : Expr) : Expr := rankExpr u clausesExpr (clauseExpr u x) +def rightExpr (x : Expr) : Expr := rankExpr u varsExpr (sampledNameExpr u x) +lemma leftExpr_eval (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) : + (leftExpr u x).eval (Complexity.formulaBits F.val) a=((table u F).left i).val := by + exact rankExpr_eval u _ _ _ _ _ (clausesExpr_eval F.val a) (clauseExpr_eval u F x a i hi) +lemma rightExpr_eval (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) : + (rightExpr u x).eval (Complexity.formulaBits F.val) a=((table u F).right i).val := by + exact rankExpr_eval u _ _ _ _ _ (varsExpr_eval F.val a) (sampledNameExpr_eval u F x a i hi) + +def projectionTest (x : Expr) (f : J u → I u) : Expr := + Expr.listAll (List.finRange (Fintype.card (J u))) fun i => + Expr.listAll (List.finRange u) fun k => + Expr.equal (projectedBitExpr u x ((Fintype.equivFin (J u)).symm i) k) + (.const (bit (f ((Fintype.equivFin (J u)).symm i) k))) +lemma projectionTest_nonzero (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) (f : J u → I u) : + (projectionTest u x f).eval (Complexity.formulaBits F.val) a≠0 ↔ f=(table u F).project i := by + simp only [projectionTest,Expr.listAll_eval,List.mem_finRange,forall_true_left, + Expr.equal_eval,projectedBitExpr_eval u F x a i hi,Expr.eval,indicator_ne,bit_eq] + constructor + · intro h + funext j k + simpa using (h (Fintype.equivFin (J u) j) k).symm + · rintro rfl + exact fun _ _ => rfl + +def projectExpr (x : Expr) : Expr := Expr.pick projectCode (projectionTest u x) +lemma projectExpr_eval (F : Input) (x : Expr) (a : ℕ → ℕ) (i : Fin (table u F).ne) + (hi : x.eval (Complexity.formulaBits F.val) a=i.val) : + (projectExpr u x).eval (Complexity.formulaBits F.val) a=projectCode ((table u F).project i) := by + apply Expr.pick_eval + exact projectionTest_nonzero u F x a i hi + +end +end LargeIndependentSets.TargetLC + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Capped.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Capped.lean new file mode 100644 index 0000000000000000000000000000000000000000..857a09b6fc1c21304c4e6d5b72ef8fb30e852a3c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Capped.lean @@ -0,0 +1,125 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Total + +namespace OAI + +namespace LargeIndependentSets.ShortestPaths + +structure Capped (B : ℕ) where + val : ℕ + bound : val ≤ B+1 + deriving DecidableEq + +namespace Capped + +@[ext] lemma ext {B : ℕ} {a b : Capped B} (h : a.val=b.val) : a=b := by + cases a; cases b; simp_all + +def finEquiv (B : ℕ) : Fin (B+2) ≃ Capped B where + toFun a := ⟨a.val,by omega⟩ + invFun a := ⟨a.val,by have := a.bound; omega⟩ + left_inv a := by rfl + right_inv a := by rfl + +instance (B : ℕ) : Fintype (Capped B) := Fintype.ofEquiv _ (finEquiv B) + +instance (B : ℕ) : Min (Capped B) := ⟨fun a b => if a.val ≤ b.val then a else b⟩ +instance (B : ℕ) : Add (Capped B) := ⟨fun a b => ⟨min (a.val+b.val) (B+1),min_le_right _ _⟩⟩ + +lemma min_val {B : ℕ} (a b : Capped B) : (min a b).val = min a.val b.val := by + change (if a.val ≤ b.val then a else b).val = _ + split <;> simp_all [le_of_not_ge] + +lemma add_val {B : ℕ} (a b : Capped B) : (a+b).val = min (a.val+b.val) (B+1) := rfl + +def clip (B : ℕ) (c : ℕ∞) : Capped B := + ⟨if c=⊤ then B+1 else min c.toNat (B+1),by split <;> simp⟩ + +@[simp] lemma clip_top (B : ℕ) : (clip B ⊤).val = B+1 := by simp [clip] +@[simp] lemma clip_nat (B n : ℕ) : (clip B (n:ℕ∞)).val = min n (B+1) := by simp [clip] + +lemma clip_min (B : ℕ) (a b : ℕ∞) : clip B (min a b) = min (clip B a) (clip B b) := by + apply ext + rw [min_val] + induction a using ENat.recTopCoe with + | top => simp [min_eq_right (clip B b).bound] + | coe a => + induction b using ENat.recTopCoe with + | top => simp + | coe b => + have he : min (a:ℕ∞) (b:ℕ∞) = ((min a b : ℕ):ℕ∞) := by exact_mod_cast rfl + rw [he] + simp only [clip_nat] + omega + +lemma clip_add (B : ℕ) (a b : ℕ∞) : clip B (a+b) = clip B a + clip B b := by + apply ext + rw [add_val] + induction a using ENat.recTopCoe with + | top => simp [clip_top] + | coe a => + induction b using ENat.recTopCoe with + | top => simp [clip_top] + | coe b => + rw [← ENat.natCast_add] + simp only [clip_nat] + omega + +lemma clip_le_iff (B : ℕ) (c : ℕ∞) {t : ℕ} (ht : t≤B) : + (clip B c).val ≤ t ↔ c ≤ (t:ℕ∞) := by + induction c using ENat.recTopCoe with + | top => simp; omega + | coe c => simp only [clip_nat,ENat.natCast_le_natCast]; omega + +lemma closure_exact {X : Type*} (B : ℕ) (a : X→X→ℕ∞) (ks : List X) (i j : X) : + closure (fun x y => clip B (a x y)) ks i j = clip B (closure a ks i j) := by + exact (congrFun (congrFun (closure_map (clip B) (clip_min B) (clip_add B) a ks) i) j).symm + +end Capped +end LargeIndependentSets.ShortestPaths + +namespace LargeIndependentSets.ShortestPaths.Capped + +abbrev Matrix (B n : ℕ) := Vector (Vector (Capped B) n) n + +def Matrix.get {B n : ℕ} (a : Matrix B n) (i j : Fin n) : Capped B := a[i.val][j.val] + +def Matrix.pivot {B n : ℕ} (a : Matrix B n) (k : Fin n) : Matrix B n := + Vector.ofFn (fun i => Vector.ofFn (fun j => ShortestPaths.pivot a.get k i j)) + +def Matrix.run {B n : ℕ} (a : Matrix B n) : List (Fin n) → Matrix B n + | [] => a + | k::ks => (a.pivot k).run ks + +lemma Matrix.run_get {B n : ℕ} (a : Matrix B n) (ks : List (Fin n)) : + (a.run ks).get = closure a.get ks := by + induction ks generalizing a with + | nil => rfl + | cons k ks ih => + rw [Matrix.run,ih] + simp only [closure] + congr 1 + funext i j + simp [Matrix.pivot,Matrix.get] + +def Matrix.allPairs {B n : ℕ} (a : Matrix B n) : Matrix B n := a.run (List.finRange n) + +def Matrix.ofInteger (B : ℕ) {n : ℕ} (a : ShortestPaths.Matrix n) : Matrix B n := + Vector.ofFn (fun i => Vector.ofFn (fun j => clip B (a.get i j))) + +theorem Matrix.allPairs_exact (B : ℕ) {n : ℕ} (a : ShortestPaths.Matrix n) (i j : Fin n) : + ((Matrix.ofInteger B a).allPairs).get i j = clip B (a.allPairs.get i j) := by + rw [Matrix.allPairs,Matrix.run_get,ShortestPaths.Matrix.allPairs,ShortestPaths.Matrix.run_get] + have he : (Matrix.ofInteger B a).get = fun x y => clip B (a.get x y) := by + funext x y + simp [Matrix.ofInteger,Matrix.get] + rw [he,closure_exact] + +theorem Matrix.threshold_exact (B : ℕ) {n : ℕ} (a : ShortestPaths.Matrix n) (i j : Fin n) + {t : ℕ} (ht : t≤B) : + (((Matrix.ofInteger B a).allPairs).get i j).val ≤ t ↔ a.allPairs.get i j ≤ (t:ℕ∞) := by + rw [Matrix.allPairs_exact,clip_le_iff B _ ht] + +end LargeIndependentSets.ShortestPaths.Capped + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/CayleySpectral.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/CayleySpectral.lean new file mode 100644 index 0000000000000000000000000000000000000000..36513e6344b7ec7a4fbb63bcf76ae6cf5edea040 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/CayleySpectral.lean @@ -0,0 +1,246 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Walsh +import OAI.Combinatorics.IndependentSets.Expansion.SpectralReturn + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.CayleySpectral + +open scoped BigOperators +open Finset +open IndependentSetsGames.Foundations.Hastad +open PoweringWalks + +variable {I D : Type*} + +def zeroFrequency : Cube I := fun _ => false + +theorem cubeXor_cancel_right (x y : Cube I) : + cubeXor (cubeXor x y) y = x := by + funext i + cases hx : x i <;> cases hy : y i <;> simp [cubeXor, hx, hy] + +theorem cubeXor_assoc (x y z : Cube I) : + cubeXor (cubeXor x y) z = cubeXor x (cubeXor y z) := by + funext i + cases hx : x i <;> cases hy : y i <;> cases hz : z i <;> + simp [cubeXor, hx, hy, hz] + +@[simp] theorem cubeXor_zeroFrequency (x : Cube I) : + cubeXor x zeroFrequency = x := by + funext i + cases hx : x i <;> simp [cubeXor, zeroFrequency, hx] + +def xorTranslation (y : Cube I) : Cube I ≃ Cube I where + toFun x := cubeXor x y + invFun x := cubeXor x y + left_inv x := cubeXor_cancel_right x y + right_inv x := cubeXor_cancel_right x y + +def rotate (g : D → Cube I) (p : Cube I × D) : Cube I × D := + (cubeXor p.1 (g p.2), p.2) + +theorem rotate_involutive (g : D → Cube I) : Function.Involutive (rotate g) := by + rintro ⟨x, d⟩ + change (cubeXor (cubeXor x (g d)) (g d), d) = (x, d) + rw [cubeXor_cancel_right] + +def cayleyGraph (g : D → Cube I) : PortGraph (Cube I) D where + rot := + { toFun := rotate g + invFun := rotate g + left_inv := rotate_involutive g + right_inv := rotate_involutive g } + rot_involutive := rotate_involutive g + +@[simp] theorem cayleyGraph_rot (g : D → Cube I) (x : Cube I) (d : D) : + (cayleyGraph g).rot (x, d) = (cubeXor x (g d), d) := rfl + +def splitPortWord (n : Nat) : (Fin (n + 1) → D) ≃ D × (Fin n → D) where + toFun p := (p 0, fun j => p j.succ) + invFun z := Fin.cases z.1 z.2 + left_inv p := by + funext j + exact Fin.cases rfl (fun _ => rfl) j + right_inv z := rfl + +def powerGenerators (g : D → Cube I) : (n : Nat) → (Fin n → D) → Cube I + | 0, _ => zeroFrequency + | n + 1, p => cubeXor (g (p 0)) (powerGenerators g n (fun j => p j.succ)) + +theorem wordEnd_eq_powerGenerators (g : D → Cube I) (n : Nat) + (x : Cube I) (p : Fin n → D) : + wordEnd (cayleyGraph g) n x p = cubeXor x (powerGenerators g n p) := by + induction n generalizing x with + | zero => simp [wordEnd, powerGenerators] + | succ n ih => + change wordEnd (cayleyGraph g) n (cubeXor x (g (p 0))) (fun j => p j.succ) = + cubeXor x (cubeXor (g (p 0)) (powerGenerators g n (fun j => p j.succ))) + rw [ih, cubeXor_assoc] + +variable [Fintype I] [DecidableEq I] [Fintype D] + +def cayleyAverage (g : D → Cube I) (f : Cube I → ℝ) (x : Cube I) : ℝ := + 𝔼 d, f ((cayleyGraph g).rot (x, d)).1 + +def eigenvalue (g : D → Cube I) (s : Cube I) : ℝ := + 𝔼 d, walsh s (g d) + +omit [Fintype I] [DecidableEq I] in +@[simp] theorem averagingOperator_cayleyGraph (g : D → Cube I) (f : Cube I → ℝ) : + SpectralReturn.averagingOperator (cayleyGraph g) f = cayleyAverage g f := rfl + +@[simp] theorem coefficient_zeroFrequency (f : Cube I → ℝ) : + coefficient f zeroFrequency = 𝔼 x, f x := by + simp [coefficient, zeroFrequency, walsh, bitSign] + +theorem coefficient_xorTranslation (f : Cube I → ℝ) (s v : Cube I) : + coefficient (fun x => f (cubeXor x v)) s = walsh s v * coefficient f s := by + calc + coefficient (fun x => f (cubeXor x v)) s = + 𝔼 x, f x * walsh s (cubeXor x v) := by + unfold coefficient + apply Fintype.expect_equiv (xorTranslation v) + intro x + change f (cubeXor x v) * walsh s x = + f (cubeXor x v) * walsh s (cubeXor (cubeXor x v) v) + rw [cubeXor_cancel_right] + _ = 𝔼 x, (f x * walsh s x) * walsh s v := by + apply Finset.expect_congr rfl + intro x _ + rw [walsh_xor] + ring + _ = coefficient f s * walsh s v := by + rw [← Finset.expect_mul] + rfl + _ = walsh s v * coefficient f s := mul_comm _ _ + +theorem cayleyAverage_walsh (g : D → Cube I) (s x : Cube I) : + cayleyAverage g (walsh s) x = eigenvalue g s * walsh s x := by + unfold cayleyAverage + simp only [cayleyGraph_rot, walsh_xor] + rw [← Finset.mul_expect] + rw [mul_comm] + rfl + +theorem coefficient_cayleyAverage (g : D → Cube I) (f : Cube I → ℝ) (s : Cube I) : + coefficient (cayleyAverage g f) s = eigenvalue g s * coefficient f s := by + calc + coefficient (cayleyAverage g f) s = + 𝔼 x, 𝔼 d, f (cubeXor x (g d)) * walsh s x := by + unfold coefficient cayleyAverage + simp only [cayleyGraph_rot, Finset.expect_mul] + _ = 𝔼 d, 𝔼 x, f (cubeXor x (g d)) * walsh s x := by + rw [Finset.expect_comm] + _ = 𝔼 d, walsh s (g d) * coefficient f s := by + apply Finset.expect_congr rfl + intro d _ + exact coefficient_xorTranslation f s (g d) + _ = eigenvalue g s * coefficient f s := by + rw [← Finset.expect_mul] + rfl + +theorem eigenvalue_powerGenerators (g : D → Cube I) (n : Nat) (s : Cube I) : + eigenvalue (powerGenerators g n) s = eigenvalue g s ^ n := by + induction n with + | zero => + let : Nonempty (Fin 0 → D) := ⟨fun i => Fin.elim0 i⟩ + simp [eigenvalue, powerGenerators, zeroFrequency, walsh, bitSign] + | succ n ih => + calc + eigenvalue (powerGenerators g (n + 1)) s = + 𝔼 z : D × (Fin n → D), + walsh s (cubeXor (g z.1) (powerGenerators g n z.2)) := by + unfold eigenvalue + apply Fintype.expect_equiv (splitPortWord n) + intro p + rfl + _ = 𝔼 d, 𝔼 p : Fin n → D, + walsh s (cubeXor (g d) (powerGenerators g n p)) := by + exact SpectralReturn.mean_prod _ + _ = eigenvalue g s * eigenvalue (powerGenerators g n) s := by + simp_rw [walsh_xor, ← Finset.mul_expect] + rw [← Finset.expect_mul] + rfl + _ = eigenvalue g s ^ (n + 1) := by + rw [ih, pow_succ, mul_comm] + +theorem power_port_card (n : Nat) : + Fintype.card (Fin n → D) = Fintype.card D ^ n := by + simp only [Fintype.card_fun, Fintype.card_fin] + +theorem seven_power_port_card : + Fintype.card (Fin 7 → Fin (2 ^ 16)) = (2 ^ 16) ^ 7 := by + simp only [Fintype.card_fun, Fintype.card_fin] + +theorem cayley_energy_contraction (g : D → Cube I) (lambda : ℝ) (_hlambda : 0 ≤ lambda) + (hbias : ∀ s : Cube I, s ≠ zeroFrequency → |eigenvalue g s| ≤ lambda) + (f : Cube I → ℝ) (hmean : (𝔼 x, f x) = 0) : + (𝔼 x, cayleyAverage g f x ^ 2) ≤ lambda ^ 2 * (𝔼 x, f x ^ 2) := by + classical + have hzero : coefficient f zeroFrequency = 0 := by + rw [coefficient_zeroFrequency] + exact hmean + calc + (𝔼 x, cayleyAverage g f x ^ 2) = + ∑ s, coefficient (cayleyAverage g f) s ^ 2 := (walsh_parseval _).symm + _ = ∑ s, (eigenvalue g s * coefficient f s) ^ 2 := by + simp only [coefficient_cayleyAverage] + _ ≤ ∑ s, lambda ^ 2 * coefficient f s ^ 2 := by + apply Finset.sum_le_sum + intro s _ + by_cases hs : s = zeroFrequency + · subst s + simp [hzero] + · have hb := hbias s hs + have hlo : -lambda ≤ eigenvalue g s := (abs_le.mp hb).1 + have hhi : eigenvalue g s ≤ lambda := (abs_le.mp hb).2 + have hprod : 0 ≤ (lambda - eigenvalue g s) * (lambda + eigenvalue g s) := + mul_nonneg (sub_nonneg.mpr hhi) (by linarith) + have hsq : eigenvalue g s ^ 2 ≤ lambda ^ 2 := by nlinarith + calc + (eigenvalue g s * coefficient f s) ^ 2 = + eigenvalue g s ^ 2 * coefficient f s ^ 2 := by rw [mul_pow] + _ ≤ lambda ^ 2 * coefficient f s ^ 2 := + mul_le_mul_of_nonneg_right hsq (sq_nonneg _) + _ = lambda ^ 2 * (𝔼 x, f x ^ 2) := by + rw [← Finset.mul_sum, walsh_parseval] + +theorem cayley_spectralCertificate (g : D → Cube I) (lambda : ℝ) + (hlambda : 0 ≤ lambda) (hlambdaone : lambda < 1) + (hbias : ∀ s : Cube I, s ≠ zeroFrequency → |eigenvalue g s| ≤ lambda) : + SpectralReturn.SpectralCertificate (cayleyGraph g) lambda where + nonnegative := hlambda + lt_one := hlambdaone + contraction := by + intro f hf + change (𝔼 x, cayleyAverage g f x ^ 2) ≤ lambda ^ 2 * (𝔼 x, f x ^ 2) + exact cayley_energy_contraction g lambda hlambda hbias f hf + +theorem power_eigenvalue_bound (g : D → Cube I) (lambda : ℝ) (hlambda : 0 ≤ lambda) + (hbias : ∀ s : Cube I, s ≠ zeroFrequency → |eigenvalue g s| ≤ lambda) + (n : Nat) (s : Cube I) (hs : s ≠ zeroFrequency) : + |eigenvalue (powerGenerators g n) s| ≤ lambda ^ n := by + rw [eigenvalue_powerGenerators, abs_pow] + induction n with + | zero => simp + | succ n ih => + rw [pow_succ, pow_succ] + exact mul_le_mul ih (hbias s hs) (abs_nonneg _) (pow_nonneg hlambda _) + +theorem sevenStep_halfCertificate (g : D → Cube I) + (hbias : ∀ s : Cube I, s ≠ zeroFrequency → |eigenvalue g s| ≤ (1 / 2 : ℝ)) : + SpectralReturn.SpectralCertificate (cayleyGraph (powerGenerators g 7)) + ((1 / 2 : ℝ) ^ 7) := by + apply cayley_spectralCertificate + · norm_num + · norm_num + · intro s hs + exact power_eigenvalue_bound g (1 / 2) (by norm_num) hbias 7 s hs + +end IndependentSetsGames.Foundations.PCP.CayleySpectral +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/CayleyTailCount.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/CayleyTailCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..880ac455baa0eac2a0919b319c8df7571cb1f8c5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/CayleyTailCount.lean @@ -0,0 +1,241 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Bits +import OAI.Combinatorics.IndependentSets.Fourier.Walsh + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.CayleyTailCount + +open scoped BigOperators +open IndependentSetsGames.Foundations.Hastad (bitSign) + +variable {α : Type*} [DecidableEq α] + +def upperMasks (s : Finset α) (m : ℕ) : Finset (Finset α) := + s.powerset.filter fun t => 3 * m ≤ t.card + +def lowerMasks (s : Finset α) (m : ℕ) : Finset (Finset α) := + s.powerset.filter fun t => t.card ≤ m + +def badMasks (s : Finset α) (m : ℕ) : Finset (Finset α) := + lowerMasks s m ∪ upperMasks s m + +omit [DecidableEq α] in + +theorem upperMasks_weight (s : Finset α) (m : ℕ) (hcard : s.card = 4 * m) : + (upperMasks s m).card * 3 ^ (3 * m) ≤ 4 ^ (4 * m) := by + calc + _ = ∑ _t ∈ upperMasks s m, 3 ^ (3 * m) := by simp + _ ≤ ∑ t ∈ upperMasks s m, 3 ^ t.card := by + apply Finset.sum_le_sum + intro t ht + exact Nat.pow_le_pow_right (by decide) (Finset.mem_filter.mp ht).2 + _ ≤ ∑ t ∈ s.powerset, 3 ^ t.card := by + apply Finset.sum_le_sum_of_subset_of_nonneg + · exact Finset.filter_subset _ _ + · intro t _ _ + exact Nat.zero_le _ + _ = 4 ^ s.card := by + simpa using Finset.sum_pow_mul_eq_add_pow (3 : ℕ) 1 s + _ = 4 ^ (4 * m) := by rw [hcard] + +theorem lowerMasks_complement_image (s : Finset α) (m : ℕ) + (hcard : s.card = 4 * m) : + (lowerMasks s m).image (fun t => s \ t) = upperMasks s m := by + ext u + constructor + · intro hu + obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hu + obtain ⟨hts, htlo⟩ := Finset.mem_filter.mp ht + have hsub := Finset.mem_powerset.mp hts + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_powerset.mpr Finset.sdiff_subset, ?_⟩ + rw [Finset.card_sdiff_of_subset hsub, hcard] + omega + · intro hu + obtain ⟨hus, huhi⟩ := Finset.mem_filter.mp hu + have hsub := Finset.mem_powerset.mp hus + apply Finset.mem_image.mpr + refine ⟨s \ u, ?_, Finset.sdiff_sdiff_eq_self hsub⟩ + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_powerset.mpr Finset.sdiff_subset, ?_⟩ + rw [Finset.card_sdiff_of_subset hsub, hcard] + omega + +theorem lowerMasks_card_eq_upperMasks (s : Finset α) (m : ℕ) + (hcard : s.card = 4 * m) : + (lowerMasks s m).card = (upperMasks s m).card := by + have hinj : Set.InjOn (fun t : Finset α => s \ t) (lowerMasks s m) := by + intro a ha b hb hab + have has := Finset.mem_powerset.mp (Finset.mem_filter.mp ha).1 + have hbs := Finset.mem_powerset.mp (Finset.mem_filter.mp hb).1 + have h := congrArg (fun t : Finset α => s \ t) hab + simpa only [Finset.sdiff_sdiff_eq_self has, Finset.sdiff_sdiff_eq_self hbs] using h + calc + _ = ((lowerMasks s m).image (fun t => s \ t)).card := + (Finset.card_image_of_injOn hinj).symm + _ = _ := congrArg Finset.card (lowerMasks_complement_image s m hcard) + +private theorem ratio_le_of_weight (c m : ℕ) + (h : c * 3 ^ (3 * m) ≤ 4 ^ (4 * m)) : + (c : ℝ) / 2 ^ (4 * m) ≤ (16 / 27 : ℝ) ^ m := by + have hc : (c : ℝ) * 3 ^ (3 * m) ≤ 4 ^ (4 * m) := by exact_mod_cast h + have h3 : 0 < (3 : ℝ) ^ (3 * m) := by positivity + have h2 : 0 < (2 : ℝ) ^ (4 * m) := by positivity + calc + _ ≤ ((4 : ℝ) ^ (4 * m) / 3 ^ (3 * m)) / 2 ^ (4 * m) := + div_le_div_of_nonneg_right ((le_div_iff₀ h3).mpr hc) h2.le + _ = _ := by + rw [pow_mul, pow_mul, pow_mul, ← div_pow, ← div_pow] + norm_num + +omit [DecidableEq α] in +theorem upperMasks_ratio_le (s : Finset α) (m : ℕ) (hcard : s.card = 4 * m) : + ((upperMasks s m).card : ℝ) / 2 ^ s.card ≤ (16 / 27 : ℝ) ^ m := by + rw [hcard] + exact ratio_le_of_weight _ m (upperMasks_weight s m hcard) + +theorem lowerMasks_ratio_le (s : Finset α) (m : ℕ) (hcard : s.card = 4 * m) : + ((lowerMasks s m).card : ℝ) / 2 ^ s.card ≤ (16 / 27 : ℝ) ^ m := by + rw [lowerMasks_card_eq_upperMasks s m hcard] + exact upperMasks_ratio_le s m hcard + +theorem badMasks_ratio_le_sharp (s : Finset α) (m : ℕ) (hcard : s.card = 4 * m) : + ((badMasks s m).card : ℝ) / 2 ^ s.card ≤ 2 * (16 / 27 : ℝ) ^ m := by + have hc : ((badMasks s m).card : ℝ) ≤ + (lowerMasks s m).card + (upperMasks s m).card := by + exact_mod_cast (Finset.card_union_le (lowerMasks s m) (upperMasks s m)) + have hpos : 0 < (2 : ℝ) ^ s.card := by positivity + calc + _ ≤ ((lowerMasks s m).card + (upperMasks s m).card : ℝ) / 2 ^ s.card := + div_le_div_of_nonneg_right hc hpos.le + _ = ((lowerMasks s m).card : ℝ) / 2 ^ s.card + + ((upperMasks s m).card : ℝ) / 2 ^ s.card := add_div _ _ _ + _ ≤ (16 / 27 : ℝ) ^ m + (16 / 27 : ℝ) ^ m := + add_le_add (lowerMasks_ratio_le s m hcard) (upperMasks_ratio_le s m hcard) + _ = _ := by ring + +theorem badMasks_ratio_le (s : Finset α) (m : ℕ) (hcard : s.card = 4 * m) : + ((badMasks s m).card : ℝ) / 2 ^ s.card ≤ 2 * (2 / 3 : ℝ) ^ m := by + apply (badMasks_ratio_le_sharp s m hcard).trans + exact mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (by norm_num) (by norm_num) m) (by norm_num) + +section Words + +variable {D : Type*} [Fintype D] + +def trueMask (word : D → Bool) : Finset D := + Finset.univ.filter fun i => word i = true + +def countTrue (word : D → Bool) : ℕ := (trueMask word).card + +def badWord (m : ℕ) (word : D → Bool) : Prop := + countTrue word ≤ m ∨ 3 * m ≤ countTrue word + +instance (m : ℕ) (word : D → Bool) : Decidable (badWord m word) := + inferInstanceAs (Decidable (countTrue word ≤ m ∨ 3 * m ≤ countTrue word)) + +theorem bitSign_mean_eq [Nonempty D] (word : D → Bool) : + (𝔼 i, bitSign (word i)) = + 1 - 2 * ((countTrue word : ℝ) / Fintype.card D) := by + have hsign (b : Bool) : bitSign b = 1 - 2 * (if b = true then (1 : ℝ) else 0) := by + cases b <;> norm_num [bitSign] + calc + _ = (𝔼 i : D, (1 - 2 * (if word i = true then (1 : ℝ) else 0))) := by + apply Finset.expect_congr rfl + intro i _ + exact hsign (word i) + _ = 1 - 2 * (𝔼 i, if word i = true then (1 : ℝ) else 0) := by + rw [Finset.expect_sub_distrib, ← Finset.mul_expect, Fintype.expect_const] + _ = _ := by + rw [Fintype.expect_eq_sum_div_card, Finset.sum_boole] + rfl + +theorem not_badWord_bias (m : ℕ) (hcard : Fintype.card D = 4 * m) (hm : 0 < m) + (word : D → Bool) (hword : ¬ badWord m word) : + |𝔼 i, bitSign (word i)| ≤ (1 / 2 : ℝ) := by + have hD : 0 < Fintype.card D := by rw [hcard]; omega + let : Nonempty D := Fintype.card_pos_iff.mp hD + have hlo : m < countTrue word := lt_of_not_ge (not_or.mp hword).1 + have hhi : countTrue word < 3 * m := lt_of_not_ge (not_or.mp hword).2 + have hmr : 0 < (m : ℝ) := by exact_mod_cast hm + have hlor : (m : ℝ) ≤ countTrue word := by exact_mod_cast hlo.le + have hhir : (countTrue word : ℝ) ≤ 3 * m := by exact_mod_cast hhi.le + have hden : 0 < 4 * (m : ℝ) := by positivity + have hratioLo : (1 / 4 : ℝ) ≤ (countTrue word : ℝ) / (4 * m) := + (le_div_iff₀ hden).mpr (by nlinarith) + have hratioHi : (countTrue word : ℝ) / (4 * m) ≤ (3 / 4 : ℝ) := + (div_le_iff₀ hden).mpr (by nlinarith) + rw [bitSign_mean_eq word, hcard] + simp only [Nat.cast_mul, Nat.cast_ofNat] + apply abs_le.mpr + constructor <;> linarith + +def wordMaskEquiv [DecidableEq D] : (D → Bool) ≃ Finset D where + toFun := trueMask + invFun s i := decide (i ∈ s) + left_inv word := by + funext i + cases h : word i <;> simp [trueMask, h] + right_inv s := by + ext i + simp [trueMask] + +theorem twoTail_probability [DecidableEq D] (m : ℕ) (hcard : Fintype.card D = 4 * m) : + (𝔼 word : D → Bool, if badWord m word then (1 : ℝ) else 0) ≤ + 2 * (2 / 3 : ℝ) ^ m := by + classical + have he : (𝔼 word : D → Bool, if badWord m word then (1 : ℝ) else 0) = + (𝔼 s : Finset D, if s.card ≤ m ∨ 3 * m ≤ s.card then (1 : ℝ) else 0) := by + apply Finset.expect_equiv (wordMaskEquiv (D := D)) + · intro word + simp + · intro word _ + rfl + have hs : (Finset.univ.filter fun s : Finset D => s.card ≤ m ∨ 3 * m ≤ s.card) = + badMasks (Finset.univ : Finset D) m := by + ext s + simp [badMasks, lowerMasks, upperMasks] + rw [he, Fintype.expect_eq_sum_div_card, Finset.sum_boole, hs, Fintype.card_finset] + simpa only [Nat.cast_pow, Nat.cast_ofNat, Finset.card_univ] using + badMasks_ratio_le (Finset.univ : Finset D) m (by simpa using hcard) + +end Words + +theorem union_bound_le_half (n m : ℕ) (hm : 3 * (n + 2) ≤ m) : + (2 : ℝ) ^ n * (2 * (2 / 3 : ℝ) ^ m) ≤ 1 / 2 := by + have hpow : (2 / 3 : ℝ) ^ m ≤ (2 / 3 : ℝ) ^ (3 * (n + 2)) := + pow_le_pow_of_le_one (by norm_num) (by norm_num) hm + have hbase : (2 / 3 : ℝ) ^ (3 * (n + 2)) ≤ (1 / 2 : ℝ) ^ (n + 2) := by + rw [pow_mul] + exact pow_le_pow_left₀ (by positivity) (by norm_num) (n + 2) + calc + _ ≤ (2 : ℝ) ^ n * (2 * (1 / 2 : ℝ) ^ (n + 2)) := by + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (hpow.trans hbase) (by norm_num)) (by positivity) + _ = 1 / 2 := by + rw [pow_add, div_pow] + norm_num + field_simp + norm_num + +theorem fixed_parameters : 3 * (448 + 2) ≤ 16384 ∧ 4 * 16384 = 2 ^ 16 := by + norm_num + +theorem fixed_union_bound : + (2 : ℝ) ^ 448 * (2 * (2 / 3 : ℝ) ^ 16384) ≤ 1 / 2 := + union_bound_le_half 448 16384 fixed_parameters.1 + +theorem seventh_power_size : (2 : ℕ) ^ 448 = (((2 : ℕ) ^ 16) ^ 7) ^ 4 := by + rw [← pow_mul, ← pow_mul] + +theorem seventh_power_abs_le {a : ℝ} (ha : |a| ≤ 1 / 2) : |a ^ 7| ≤ 1 / 128 := by + rw [abs_pow] + calc + |a| ^ 7 ≤ (1 / 2 : ℝ) ^ 7 := pow_le_pow_left₀ (abs_nonneg a) ha 7 + _ = 1 / 128 := by norm_num + +end IndependentSetsGames.Foundations.PCP.CayleyTailCount + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/CloudRounding.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/CloudRounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..60da33993027c81ed5cdfd15c3e51af9612dbb78 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/CloudRounding.lean @@ -0,0 +1,184 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.CloudRounding + +open scoped BigOperators + +theorem dart_rejection_count_le + {E V A : Type*} [Fintype E] [DecidableEq A] + (tail : E → V) (reverse : E ≃ E) (accepts : E → A → A → Bool) + (ell : E → A) (rounded : V → A) : + (Finset.univ.filter (fun e => + accepts e (rounded (tail e)) (rounded (tail (reverse e))) = false)).card ≤ + (Finset.univ.filter (fun e => accepts e (ell e) (ell (reverse e)) = false)).card + + 2 * (Finset.univ.filter (fun e => ell e ≠ rounded (tail e))).card := by + classical + let R : Finset E := Finset.univ.filter (fun e => + accepts e (rounded (tail e)) (rounded (tail (reverse e))) = false) + let B : Finset E := Finset.univ.filter (fun e => + accepts e (ell e) (ell (reverse e)) = false) + let M : Finset E := Finset.univ.filter (fun e => ell e ≠ rounded (tail e)) + let MR : Finset E := Finset.univ.filter (fun e => + ell (reverse e) ≠ rounded (tail (reverse e))) + have hrev : MR.card = M.card := by + have hsets : MR = M.map reverse.symm.toEmbedding := by + ext e + constructor + · intro he + apply Finset.mem_map.mpr + refine ⟨reverse e, ?_, reverse.symm_apply_apply e⟩ + simpa [MR, M] using he + · intro he + obtain ⟨d, hd, rfl⟩ := Finset.mem_map.mp he + simpa [MR, M] using hd + rw [hsets, Finset.card_map] + have hsub : R ⊆ (B ∪ M) ∪ MR := by + intro e he + by_cases hl : ell e = rounded (tail e) + · by_cases hr : ell (reverse e) = rounded (tail (reverse e)) + · have hb : e ∈ B := by simpa [B, R, hl, hr] using he + exact Finset.mem_union_left _ (Finset.mem_union_left _ hb) + · exact Finset.mem_union_right _ (by simp [MR, hr]) + · exact Finset.mem_union_left _ (Finset.mem_union_right _ (by simp [M, hl])) + change R.card ≤ B.card + 2 * M.card + calc + R.card ≤ ((B ∪ M) ∪ MR).card := Finset.card_le_card hsub + _ ≤ (B ∪ M).card + MR.card := Finset.card_union_le _ _ + _ ≤ (B.card + M.card) + MR.card := + Nat.add_le_add_right (Finset.card_union_le B M) _ + _ = B.card + 2 * M.card := by rw [hrev]; omega + +variable {X A D : Type*} [Fintype X] [Fintype A] [Fintype D] +variable [DecidableEq X] [DecidableEq A] + +def colorSet (ell : X → A) (a : A) : Finset X := + Finset.univ.filter (fun x => ell x = a) + +def minoritySet (ell : X → A) (m : A) : Finset X := + Finset.univ.filter (fun x => ell x ≠ m) + +def directedCut (next : X × D → X) (S : Finset X) : Finset (X × D) := + Finset.univ.filter (fun xd => xd.1 ∈ S ∧ next xd ∉ S) + +def disagreementSet (ell : X → A) (next : X × D → X) : Finset (X × D) := + Finset.univ.filter (fun xd => ell xd.1 ≠ ell (next xd)) + +abbrev Nonmajor (m : A) := {a : A // a ≠ m} + +omit [DecidableEq X] in +theorem exists_max_color (ell : X → A) [Nonempty A] : + ∃ m : A, ∀ a, (colorSet ell a).card ≤ (colorSet ell m).card := by + classical + obtain ⟨m, _, hm⟩ := Finset.exists_max_image Finset.univ + (fun a : A => (colorSet ell a).card) Finset.univ_nonempty + exact ⟨m, fun a => hm a (Finset.mem_univ a)⟩ + +noncomputable def majority (ell : X → A) [Nonempty A] : A := + Classical.choose (exists_max_color ell) + +omit [DecidableEq X] in +theorem majority_maximal (ell : X → A) [Nonempty A] (a : A) : + (colorSet ell a).card ≤ (colorSet ell (majority ell)).card := + Classical.choose_spec (exists_max_color ell) a + +omit [Fintype A] in +theorem nonchosen_color_twice_le (ell : X → A) (m : A) + (maximal : ∀ a, (colorSet ell a).card ≤ (colorSet ell m).card) + (a : A) (ha : a ≠ m) : + 2 * (colorSet ell a).card ≤ Fintype.card X := by + have hd : Disjoint (colorSet ell a) (colorSet ell m) := by + apply Finset.disjoint_left.mpr + intro x hx hm + have hxa : ell x = a := by simpa [colorSet] using hx + have hxm : ell x = m := by simpa [colorSet] using hm + exact ha (hxa.symm.trans hxm) + have hu : (colorSet ell a).card + (colorSet ell m).card ≤ Fintype.card X := by + calc + _ = (colorSet ell a ∪ colorSet ell m).card := + (Finset.card_union_of_disjoint hd).symm + _ ≤ Finset.univ.card := Finset.card_le_card (Finset.subset_univ _) + _ = Fintype.card X := Finset.card_univ + have hm := maximal a + omega + +def minorityEquiv (ell : X → A) (m : A) : + (Σ a : Nonmajor m, ↥(colorSet ell a.val)) ≃ ↥(minoritySet ell m) where + toFun t := ⟨t.2.val, by + have hc : ell t.2.val = t.1.val := (Finset.mem_filter.mp t.2.property).2 + have hn : ell t.2.val ≠ m := fun h => t.1.property (hc.symm.trans h) + simpa [minoritySet] using hn⟩ + invFun x := + ⟨⟨ell x.val, by simpa [minoritySet] using x.property⟩, + ⟨x.val, by simp [colorSet]⟩⟩ + left_inv t := by + rcases t with ⟨⟨a, ha⟩, ⟨x, hx⟩⟩ + have hxa : ell x = a := by simpa [colorSet] using hx + cases hxa + rfl + right_inv x := by apply Subtype.ext; rfl + +omit [DecidableEq X] in +theorem minority_card_eq_sum (ell : X → A) (m : A) : + (minoritySet ell m).card = ∑ a : Nonmajor m, (colorSet ell a.val).card := by + have h := Fintype.card_congr (minorityEquiv ell m) + simpa only [Fintype.card_sigma, Fintype.card_coe] using h.symm + +def minorityCutEmbedding (ell : X → A) (next : X × D → X) (m : A) : + (Σ a : Nonmajor m, ↥(directedCut next (colorSet ell a.val))) ↪ + ↥(disagreementSet ell next) where + toFun t := ⟨t.2.val, by + have hc : ell t.2.val.1 = t.1.val ∧ ell (next t.2.val) ≠ t.1.val := by + simpa [directedCut, colorSet] using t.2.property + have hn : ell t.2.val.1 ≠ ell (next t.2.val) := + fun h => hc.2 (h.symm.trans hc.1) + simpa [disagreementSet] using hn⟩ + inj' p q h := by + rcases p with ⟨⟨a, ha⟩, ⟨x, hx⟩⟩ + rcases q with ⟨⟨b, hb⟩, ⟨y, hy⟩⟩ + have hxy : x = y := congrArg Subtype.val h + cases hxy + have hxa : ell x.1 = a := by + have hc : ell x.1 = a ∧ ell (next x) ≠ a := by + simpa [directedCut, colorSet] using hx + exact hc.1 + have hxb : ell x.1 = b := by + have hc : ell x.1 = b ∧ ell (next x) ≠ b := by + simpa [directedCut, colorSet] using hy + exact hc.1 + have hab : a = b := hxa.symm.trans hxb + cases hab + rfl + +theorem minority_cut_sum_le (ell : X → A) (next : X × D → X) (m : A) : + (∑ a : Nonmajor m, (directedCut next (colorSet ell a.val)).card) ≤ + (disagreementSet ell next).card := by + have h := Fintype.card_le_of_injective + (minorityCutEmbedding ell next m) (minorityCutEmbedding ell next m).injective + simpa only [Fintype.card_sigma, Fintype.card_coe] using h + +theorem minority_expansion_bound (ell : X → A) (next : X × D → X) (m : A) + (h : ℚ) + (maximal : ∀ a, (colorSet ell a).card ≤ (colorSet ell m).card) + (expansion : ∀ S : Finset X, S.card ≤ Fintype.card X / 2 → + h * (S.card : ℚ) ≤ ((directedCut next S).card : ℚ)) : + h * ((minoritySet ell m).card : ℚ) ≤ ((disagreementSet ell next).card : ℚ) := by + have each (a : Nonmajor m) : + h * ((colorSet ell a.val).card : ℚ) ≤ + ((directedCut next (colorSet ell a.val)).card : ℚ) := by + apply expansion + have ha := nonchosen_color_twice_le ell m maximal a.val a.property + omega + calc + h * ((minoritySet ell m).card : ℚ) = + ∑ a : Nonmajor m, h * ((colorSet ell a.val).card : ℚ) := by + rw [minority_card_eq_sum, Nat.cast_sum, Finset.mul_sum] + _ ≤ ∑ a : Nonmajor m, ((directedCut next (colorSet ell a.val)).card : ℚ) := + Finset.sum_le_sum (fun a _ => each a) + _ ≤ ((disagreementSet ell next).card : ℚ) := by + exact_mod_cast minority_cut_sum_le ell next m + +end IndependentSetsGames.Foundations.PCP.CloudRounding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/DegreeReplacement.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/DegreeReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..777a1f0f50ed14d1cd722788ac19af2781bb5353 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/DegreeReplacement.lean @@ -0,0 +1,263 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ConstraintGraph +import OAI.Combinatorics.IndependentSets.Expansion.PoweringWalks + +namespace OAI + +open scoped BigOperators + +namespace IndependentSetsGames.Foundations.PCP.DegreeReplacement + +open PoweringWalks + +variable {V E A D : Type*} + +abbrev Cloud (G : ConstraintGraph V E A) (v : V) := {e : E // G.tail e = v} + +def cloudIndexEquiv (G : ConstraintGraph V E A) : + (E × D) ≃ (Σ v : V, Cloud G v × D) where + toFun p := ⟨G.tail p.1, (⟨p.1, rfl⟩, p.2)⟩ + invFun p := (p.2.1.val, p.2.2) + left_inv _ := rfl + right_inv := by + rintro ⟨v, ⟨⟨e, he⟩, d⟩⟩ + cases he + rfl + +def cloudRotation (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : + (Σ v : V, Cloud G v × D) ≃ (Σ v : V, Cloud G v × D) := + Equiv.sigmaCongrRight (fun v => (H v).rot) + +theorem cloudRotation_involutive (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : + Function.Involutive (cloudRotation G H) := by + rintro ⟨v, p⟩ + change (⟨v, (H v).rot ((H v).rot p)⟩ : Σ v : V, Cloud G v × D) = ⟨v, p⟩ + rw [(H v).rot_involutive p] + +def innerRotation (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : (E × D) ≃ (E × D) := + ((cloudIndexEquiv G).trans (cloudRotation G H)).trans (cloudIndexEquiv G).symm + +theorem innerRotation_involutive (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : + Function.Involutive (innerRotation G H) := by + intro p + apply (cloudIndexEquiv G).injective + simp only [innerRotation, Equiv.trans_apply, Equiv.apply_symm_apply] + exact cloudRotation_involutive G H _ + +theorem innerRotation_tail (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) (e : E) (d : D) : + G.tail (innerRotation G H (e, d)).1 = G.tail e := by + change G.tail (((H (G.tail e)).rot (⟨e, rfl⟩, d)).1.val) = G.tail e + exact ((H (G.tail e)).rot (⟨e, rfl⟩, d)).1.property + +def replacementStep (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : E × (D ⊕ Unit) → E × (D ⊕ Unit) + | (e, Sum.inl d) => + let p := innerRotation G H (e, d) + (p.1, Sum.inl p.2) + | (e, Sum.inr u) => (G.reverse e, Sum.inr u) + +theorem replacementStep_involutive (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : + Function.Involutive (replacementStep G H) := by + rintro ⟨e, p⟩ + rcases p with d | u + · change ((innerRotation G H (innerRotation G H (e, d))).1, + (Sum.inl ((innerRotation G H (innerRotation G H (e, d))).2) : D ⊕ Unit)) = + (e, Sum.inl d) + rw [innerRotation_involutive G H (e, d)] + · change (G.reverse (G.reverse e), (Sum.inr u : D ⊕ Unit)) = (e, Sum.inr u) + rw [G.reverse_involutive e] + +def replacementPortGraph (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : PortGraph E (D ⊕ Unit) where + rot := + { toFun := replacementStep G H + invFun := replacementStep G H + left_inv := replacementStep_involutive G H + right_inv := replacementStep_involutive G H } + rot_involutive := replacementStep_involutive G H + +def replacementGraph [DecidableEq A] (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) : + ConstraintGraph E (E × (D ⊕ Unit)) A where + reverse := (replacementPortGraph G H).rot + reverse_involutive := (replacementPortGraph G H).rot_involutive + tail := Prod.fst + accepts p a b := match p.2 with + | Sum.inl _ => decide (a = b) + | Sum.inr _ => G.accepts p.1 a b + reverse_accepts := by + rintro ⟨e, p⟩ a b + rcases p with d | u + · change decide (b = a) = decide (a = b) + simp [eq_comm] + · exact G.reverse_accepts e a b + +def liftLabel (G : ConstraintGraph V E A) (labeling : V → A) : E → A := + fun e => labeling (G.tail e) + +@[simp] theorem replacement_satisfied_inl [DecidableEq A] + (G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D) + (labeling : V → A) (e : E) (d : D) : + (replacementGraph G H).edgeSatisfied (liftLabel G labeling) (e, Sum.inl d) = + true := by + change decide (labeling (G.tail e) = + labeling (G.tail (innerRotation G H (e, d)).1)) = true + rw [innerRotation_tail G H e d] + simp + +@[simp] theorem replacement_satisfied_inr [DecidableEq A] + (G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D) + (labeling : V → A) (e : E) (u : Unit) : + (replacementGraph G H).edgeSatisfied (liftLabel G labeling) (e, Sum.inr u) = + G.edgeSatisfied labeling e := rfl + +theorem replacement_complete [DecidableEq A] + (G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D) + (labeling : V → A) (h : ∀ e, G.edgeSatisfied labeling e = true) : + ∀ p, (replacementGraph G H).edgeSatisfied (liftLabel G labeling) p = true := by + rintro ⟨e, p⟩ + rcases p with d | u + · exact replacement_satisfied_inl G H labeling e d + · rw [replacement_satisfied_inr] + exact h e + +theorem replacement_satisfiable [DecidableEq A] + (G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D) + (h : G.Satisfiable) : (replacementGraph G H).Satisfiable := by + obtain ⟨labeling, hlabeling⟩ := h + exact ⟨liftLabel G labeling, replacement_complete G H labeling hlabeling⟩ + +theorem rejectionCount_eq_sum [Fintype E] (G : ConstraintGraph V E A) + (labeling : V → A) : + G.rejectionCount labeling = + ∑ e, if G.edgeSatisfied labeling e = false then 1 else 0 := by + classical + simp only [ConstraintGraph.rejectionCount, ConstraintGraph.rejectedDarts, + Finset.card_eq_sum_ones, Finset.sum_filter] + +theorem replacement_rejectionCount [Fintype E] [Fintype D] [DecidableEq A] + (G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D) + (labeling : V → A) : + (replacementGraph G H).rejectionCount (liftLabel G labeling) = + G.rejectionCount labeling := by + classical + simp only [rejectionCount_eq_sum, Fintype.sum_prod_type, Fintype.sum_sum_type] + simp only [replacement_satisfied_inl, replacement_satisfied_inr, + Bool.true_eq_false, ite_false, Fintype.sum_unique, Finset.sum_const_zero, zero_add] + rfl + +abbrev PaddedDart (_G : ConstraintGraph V E A) (dummy : V → Type*) := + E ⊕ (Σ v : V, dummy v) + +def paddedOwner (G : ConstraintGraph V E A) (dummy : V → Type*) : + PaddedDart G dummy → V + | Sum.inl e => G.tail e + | Sum.inr z => z.1 + +def paddedReverse (G : ConstraintGraph V E A) (dummy : V → Type*) : + PaddedDart G dummy ≃ PaddedDart G dummy := + Equiv.sumCongr G.reverse (Equiv.refl (Σ v : V, dummy v)) + +theorem paddedReverse_involutive (G : ConstraintGraph V E A) (dummy : V → Type*) : + Function.Involutive (paddedReverse G dummy) := by + intro z + cases z with + | inl e => + change (Sum.inl (G.reverse (G.reverse e)) : PaddedDart G dummy) = Sum.inl e + rw [G.reverse_involutive e] + | inr z => rfl + +def paddedGraph (G : ConstraintGraph V E A) (dummy : V → Type*) : + ConstraintGraph V (PaddedDart G dummy) A where + reverse := paddedReverse G dummy + reverse_involutive := paddedReverse_involutive G dummy + tail := paddedOwner G dummy + accepts e a b := match e with + | Sum.inl e => G.accepts e a b + | Sum.inr _ => true + reverse_accepts := by + intro e a b + cases e with + | inl e => exact G.reverse_accepts e a b + | inr z => rfl + +@[simp] theorem padded_satisfied_inl (G : ConstraintGraph V E A) + (dummy : V → Type*) (labeling : V → A) (e : E) : + (paddedGraph G dummy).edgeSatisfied labeling (Sum.inl e) = + G.edgeSatisfied labeling e := rfl + +@[simp] theorem padded_satisfied_inr (G : ConstraintGraph V E A) + (dummy : V → Type*) (labeling : V → A) (z : Σ v : V, dummy v) : + (paddedGraph G dummy).edgeSatisfied labeling (Sum.inr z) = true := rfl + +theorem padded_complete (G : ConstraintGraph V E A) (dummy : V → Type*) + (labeling : V → A) (h : ∀ e, G.edgeSatisfied labeling e = true) : + ∀ c, (paddedGraph G dummy).edgeSatisfied labeling c = true := by + intro c + cases c with + | inl e => exact h e + | inr z => rfl + +theorem padded_satisfiable (G : ConstraintGraph V E A) (dummy : V → Type*) + (h : G.Satisfiable) : (paddedGraph G dummy).Satisfiable := by + obtain ⟨labeling, hlabeling⟩ := h + exact ⟨labeling, padded_complete G dummy labeling hlabeling⟩ + +theorem card_paddedDart [Fintype V] [Fintype E] (G : ConstraintGraph V E A) + (dummy : V → Type*) [∀ v, Fintype (dummy v)] : + Fintype.card (PaddedDart G dummy) = + Fintype.card E + ∑ v, Fintype.card (dummy v) := by + rw [Fintype.card_sum, Fintype.card_sigma] + +theorem padded_rejectionCount [Fintype V] [Fintype E] + (G : ConstraintGraph V E A) (dummy : V → Type*) [∀ v, Fintype (dummy v)] + (labeling : V → A) : + (paddedGraph G dummy).rejectionCount labeling = G.rejectionCount labeling := by + classical + simp only [rejectionCount_eq_sum, Fintype.sum_sum_type] + simp only [padded_satisfied_inl, padded_satisfied_inr, + Bool.true_eq_false, ite_false, Finset.sum_const_zero, add_zero] + rfl + +def paddedReplacementPortGraph (G : ConstraintGraph V E A) (dummy : V → Type*) + (H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) : + PortGraph (PaddedDart G dummy) (D ⊕ Unit) := + replacementPortGraph (paddedGraph G dummy) H + +def paddedReplacementGraph [DecidableEq A] + (G : ConstraintGraph V E A) (dummy : V → Type*) + (H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) : + ConstraintGraph (PaddedDart G dummy) (PaddedDart G dummy × (D ⊕ Unit)) A := + replacementGraph (paddedGraph G dummy) H + +theorem paddedReplacement_rejectionCount + [Fintype V] [Fintype E] [Fintype D] [DecidableEq A] + (G : ConstraintGraph V E A) (dummy : V → Type*) [∀ v, Fintype (dummy v)] + (H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) (labeling : V → A) : + (paddedReplacementGraph G dummy H).rejectionCount + (liftLabel (paddedGraph G dummy) labeling) = G.rejectionCount labeling := + (replacement_rejectionCount (paddedGraph G dummy) H labeling).trans + (padded_rejectionCount G dummy labeling) + +def noDummyEquiv (G : ConstraintGraph V E A) : + PaddedDart G (fun _ : V => Empty) ≃ E where + toFun z := match z with + | Sum.inl e => e + | Sum.inr z => Empty.elim z.2 + invFun := Sum.inl + left_inv := by + intro z + cases z with + | inl e => rfl + | inr z => exact Empty.elim z.2 + right_inv _ := rfl + +end IndependentSetsGames.Foundations.PCP.DegreeReplacement + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderFamily.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..0958d8ae6181624763509012c17cd12cc4481139 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderFamily.lean @@ -0,0 +1,193 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.DegreeReplacement +import OAI.Combinatorics.IndependentSets.Expansion.ZigzagSpectral + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.ExpanderFamily + +open PoweringWalks SpectralReturn Expanders + +abbrev Port := BasePort × BasePort +abbrev CloudPort := Port × Port +def growth : Nat := baseDegree ^ 4 + +theorem card_port : Fintype.card Port = baseDegree ^ 2 := by + change Fintype.card (BasePort × BasePort) = baseDegree ^ 2 + rw [Fintype.card_prod, card_basePort, pow_two] + +theorem card_cloudPort : Fintype.card CloudPort = growth := by + change Fintype.card (Port × Port) = growth + rw [Fintype.card_prod, card_port] + unfold growth + ring + +theorem growth_gt_one : 1 < growth := by + norm_num [growth, baseDegree, initialDegree, basePower] + +theorem port_degree_ge_eight : 8 ≤ Fintype.card Port := by + rw [card_port] + norm_num [baseDegree, initialDegree, basePower] + +noncomputable def baseVertexEquiv : BaseVertex ≃ CloudPort := + Fintype.equivOfCardEq (card_baseVertex.trans card_cloudPort.symm) + +noncomputable def baseOnCloud : PortGraph CloudPort BasePort := + GraphTransport.reindex (Classical.choose exists_baseGraph) baseVertexEquiv (Equiv.refl _) + +theorem baseOnCloud_certificate : SpectralCertificate baseOnCloud (1 / 100 : ℝ) := + GraphTransport.reindex_spectralCertificate _ _ _ _ (Classical.choose_spec exists_baseGraph) + +def Vertex : Nat → Type + | 0 => Unit + | n + 1 => Vertex n × CloudPort + +instance vertexFintype (n : Nat) : Fintype (Vertex n) := by + induction n with + | zero => exact inferInstanceAs (Fintype Unit) + | succ n ih => + letI : Fintype (Vertex n) := ih + change Fintype (Vertex n × CloudPort) + infer_instance + +instance basePortNonempty : Nonempty BasePort := + ⟨fun _ => ⟨0, by norm_num [initialQuarterDegree]⟩⟩ + +instance vertexNonempty (n : Nat) : Nonempty (Vertex n) := by + induction n with + | zero => exact inferInstanceAs (Nonempty Unit) + | succ n ih => + let : Nonempty (Vertex n) := ih + change Nonempty (Vertex n × CloudPort) + infer_instance + +def graph (H : PortGraph CloudPort BasePort) : (n : Nat) → PortGraph (Vertex n) Port + | 0 => { rot := Equiv.refl _, rot_involutive := fun _ => rfl } + | n + 1 => ZigzagGraphs.zigzag (ZigzagGraphs.square (graph H n)) H + +theorem graph_certificate (H : PortGraph CloudPort BasePort) + (hH : SpectralCertificate H (1 / 100 : ℝ)) (n : Nat) : + SpectralCertificate (graph H n) (1 / 2 : ℝ) := by + induction n with + | zero => + refine ⟨by norm_num, by norm_num, ?_⟩ + intro f hf + have hm : mean f = f () := by + change mean (fun x : Unit => f x) = f () + have hfun : (fun x : Unit => f x) = fun _ : Unit => f () := by + funext x + cases x + rfl + rw [hfun, mean_const] + have hz : f = fun _ => 0 := by + funext x + cases x + exact hm.symm.trans hf + rw [hz] + simp [energy, mean, averagingOperator] + | succ n ih => + exact ZigzagSpectral.square_zigzag_halfCertificate (graph H n) H ih hH + +noncomputable def family (n : Nat) : PortGraph (Vertex n) Port := graph baseOnCloud n + +theorem family_certificate (n : Nat) : SpectralCertificate (family n) (1 / 2 : ℝ) := + graph_certificate baseOnCloud baseOnCloud_certificate n + +theorem card_vertex (n : Nat) : Fintype.card (Vertex n) = growth ^ n := by + induction n with + | zero => rfl + | succ n ih => + change Fintype.card (Vertex n × CloudPort) = growth ^ (n + 1) + rw [Fintype.card_prod, ih, card_cloudPort, pow_succ] + +def level (k : Nat) : Nat := Nat.clog growth k + +def size (k : Nat) : Nat := growth ^ level k + +theorem le_size (k : Nat) : k ≤ size k := Nat.le_pow_clog growth_gt_one k + +theorem size_le_mul {k : Nat} (hk : 0 < k) : size k ≤ growth * k := by + by_cases hk1 : k = 1 + · subst k + simpa [size, level] using growth_gt_one.le + · have hk2 : 1 < k := by omega + have hl : 0 < level k := Nat.clog_pos growth_gt_one hk2 + have hp : growth ^ (level k).pred < k := + Nat.pow_pred_clog_lt_self growth_gt_one hk2 + have he : (level k).pred + 1 = level k := Nat.succ_pred_eq_of_pos hl + calc + size k = growth ^ ((level k).pred + 1) := by rw [he]; rfl + _ = growth * growth ^ (level k).pred := by rw [pow_succ, Nat.mul_comm] + _ ≤ growth * k := Nat.mul_le_mul_left growth hp.le + +theorem padded_family_size {k : Nat} (hk : 0 < k) : + k ≤ Fintype.card (Vertex (level k)) ∧ + Fintype.card (Vertex (level k)) ≤ growth * k := by + rw [card_vertex] + exact ⟨le_size k, size_le_mul hk⟩ + +end IndependentSetsGames.Foundations.PCP.ExpanderFamily +namespace IndependentSetsGames.Foundations.PCP.CloudPadding + +open scoped BigOperators +open DegreeReplacement + +variable {V E A : Type*} + +def paddedSize (k : Nat) : Nat := if k = 0 then 0 else ExpanderFamily.size k + +@[simp] theorem paddedSize_zero : paddedSize 0 = 0 := rfl + +theorem paddedSize_of_pos {k : Nat} (hk : 0 < k) : + paddedSize k = ExpanderFamily.size k := by + simp only [paddedSize, ite_eq_right (Nat.ne_of_gt hk)] + +theorem le_paddedSize (k : Nat) : k ≤ paddedSize k := by + by_cases hk : k = 0 + · subst k + simp + · rw [paddedSize, ite_eq_right hk] + exact ExpanderFamily.le_size k + +theorem paddedSize_le_mul (k : Nat) : paddedSize k ≤ ExpanderFamily.growth * k := by + by_cases hk : k = 0 + · subst k + simp + · rw [paddedSize, ite_eq_right hk] + exact ExpanderFamily.size_le_mul (Nat.pos_of_ne_zero hk) + +def paddedCloudEquiv (G : ConstraintGraph V E A) (dummy : V → Type*) (v : V) : + Cloud (paddedGraph G dummy) v ≃ Cloud G v ⊕ dummy v where + toFun := by + rintro ⟨e, he⟩ + rcases e with e | ⟨w, d⟩ + · exact Sum.inl ⟨e, he⟩ + · change w = v at he + cases he + exact Sum.inr d + invFun := fun z => match z with + | Sum.inl e => ⟨Sum.inl e.val, e.property⟩ + | Sum.inr d => ⟨Sum.inr ⟨v, d⟩, rfl⟩ + left_inv := by + rintro ⟨e, he⟩ + rcases e with e | ⟨w, d⟩ + · rfl + · change w = v at he + cases he + rfl + right_inv := by + intro z + cases z <;> rfl + +def dartCloudEquiv (G : ConstraintGraph V E A) : E ≃ Σ v : V, Cloud G v where + toFun e := ⟨G.tail e, ⟨e, rfl⟩⟩ + invFun z := z.2.val + left_inv _ := rfl + right_inv := by + rintro ⟨v, ⟨e, he⟩⟩ + cases he + rfl + +end IndependentSetsGames.Foundations.PCP.CloudPadding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderRowControl.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderRowControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc3af84c94807c78bd5817386854cd7971cf59e1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderRowControl.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.ExpanderRowControl + +open ExpanderTables + +abbrev degree (d : Nat) : Nat := d * d +abbrev cloudSize (d : Nat) : Nat := degree d * degree d +abbrev rowFactor (d : Nat) : Nat := cloudSize d * degree d + +structure Control (d : Nat) where + firstH : Fin (cloudSize d) × Fin d + lastInput : Fin d + firstG : Fin (degree d) + secondG : Fin (degree d) + lastH : Fin (cloudSize d) × Fin d + deriving DecidableEq, Fintype + +def squarePorts {d : Nat} (s : Control d) : Fin (degree d) × Fin (degree d) := + (rowIndex (degree d) (degree d)).symm s.firstH.1 + +def start {d : Nat} (H : Table (cloudSize d) d) + (cloud : Fin (cloudSize d)) (port : Fin (degree d)) : Control d := + let ports := (rowIndex d d).symm port + let first := lookup H (cloud, ports.1) + let square := (rowIndex (degree d) (degree d)).symm first.1 + { firstH := first + lastInput := ports.2 + firstG := square.1 + secondG := square.2 + lastH := first } + +def receiveFirst {d : Nat} (s : Control d) (returnedPort : Fin (degree d)) : Control d := + { s with firstG := returnedPort } + +def receiveSecond {d : Nat} (H : Table (cloudSize d) d) + (s : Control d) (returnedPort : Fin (degree d)) : Control d := + { s with + secondG := returnedPort + lastH := lookup H + (rowIndex (degree d) (degree d) (returnedPort,s.firstG),s.lastInput) } + +def firstOffset {d : Nat} (s : Control d) : Fin (degree d) := (squarePorts s).1 +def secondOffset {d : Nat} (s : Control d) : Fin (degree d) := (squarePorts s).2 + +def outputPort {d : Nat} (s : Control d) : Fin (degree d) := + rowIndex d d (s.lastH.2,s.firstH.2) + +def outputOffset {d : Nat} (s : Control d) : Fin (rowFactor d) := + rowIndex (cloudSize d) (degree d) (s.lastH.1,outputPort s) + +def firstAddress {d : Nat} (vertex : Nat) (s : Control d) : Nat := + degree d * vertex + (firstOffset s).val + +def secondAddress {d : Nat} (vertex : Nat) (s : Control d) : Nat := + degree d * vertex + (secondOffset s).val + +def outputAddress {d : Nat} (vertex : Nat) (s : Control d) : Nat := + rowFactor d * vertex + (outputOffset s).val + +@[simp] theorem firstOffset_receiveFirst {d : Nat} (s : Control d) (r : Fin (degree d)) : + firstOffset (receiveFirst s r) = firstOffset s := rfl + +@[simp] theorem secondOffset_receiveFirst {d : Nat} (s : Control d) (r : Fin (degree d)) : + secondOffset (receiveFirst s r) = secondOffset s := rfl + +@[simp] theorem receiveFirst_port {d : Nat} (s : Control d) (r : Fin (degree d)) : + (receiveFirst s r).firstG = r := rfl + +@[simp] theorem receiveSecond_port {d : Nat} (H : Table (cloudSize d) d) + (s : Control d) (r : Fin (degree d)) : (receiveSecond H s r).secondG = r := rfl + +theorem firstAddress_eq_rowIndex {v d : Nat} (vertex : Fin v) (s : Control d) : + firstAddress vertex.val s = + (rowIndex v (degree d) (vertex,firstOffset s)).val := by + rw [rowIndex_val] + exact Nat.add_comm _ _ + +theorem secondAddress_eq_rowIndex {v d : Nat} (vertex : Fin v) (s : Control d) : + secondAddress vertex.val s = + (rowIndex v (degree d) (vertex,secondOffset s)).val := by + rw [rowIndex_val] + exact Nat.add_comm _ _ + +theorem firstAddress_lt {v d : Nat} (vertex : Fin v) (s : Control d) : + firstAddress vertex.val s < v * degree d := by + rw [firstAddress_eq_rowIndex] + exact (rowIndex v (degree d) (vertex,firstOffset s)).isLt + +theorem secondAddress_lt {v d : Nat} (vertex : Fin v) (s : Control d) : + secondAddress vertex.val s < v * degree d := by + rw [secondAddress_eq_rowIndex] + exact (rowIndex v (degree d) (vertex,secondOffset s)).isLt + +theorem lookup_vertex_div {v q : Nat} (G : Table v q) (x : Fin v × Fin q) : + (lookup G x).1.val = (reverseIndex G (rowIndex v q x)).val / q := rfl + +theorem lookup_port_mod {v q : Nat} (G : Table v q) (x : Fin v × Fin q) : + (lookup G x).2.val = (reverseIndex G (rowIndex v q x)).val % q := rfl + +theorem lookup_port_eq_remainder {v q : Nat} (G : Table v q) (x : Fin v × Fin q) + (r : Fin q) (hr : r.val = (reverseIndex G (rowIndex v q x)).val % q) : + (lookup G x).2 = r := Fin.ext ((lookup_port_mod G x).trans hr.symm) + +theorem rowIndex_lookup {v q : Nat} (G : Table v q) (x : Fin v × Fin q) : + rowIndex v q (lookup G x) = reverseIndex G (rowIndex v q x) := by + simp only [lookup, Equiv.apply_symm_apply] + +def outputPair {v d : Nat} (vertex : Fin v) (s : Control d) : + Fin (v * cloudSize d) × Fin (degree d) := + (rowIndex v (cloudSize d) (vertex,s.lastH.1),outputPort s) + +theorem outputAddress_eq_rowIndex {v d : Nat} (vertex : Fin v) (s : Control d) : + outputAddress vertex.val s = + (rowIndex (v * cloudSize d) (degree d) (outputPair vertex s)).val := by + simp only [outputAddress, outputOffset, outputPair, rowIndex_val, rowFactor] + ring + +theorem outputAddress_lt {v d : Nat} (vertex : Fin v) (s : Control d) : + outputAddress vertex.val s < (v * cloudSize d) * degree d := by + rw [outputAddress_eq_rowIndex] + exact (rowIndex (v * cloudSize d) (degree d) (outputPair vertex s)).isLt + +def evaluateRow {v d : Nat} (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (cloud : Fin (cloudSize d)) (port : Fin (degree d)) : + Fin v × Control d := + let s₀ := start H cloud port + let g₁ := lookup G (vertex,firstOffset s₀) + let s₁ := receiveFirst s₀ g₁.2 + let g₂ := lookup G (g₁.1,secondOffset s₁) + (g₂.1, receiveSecond H s₁ g₂.2) + +theorem evaluateRow_eq_lookup_step {v d : Nat} + (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (cloud : Fin (cloudSize d)) (port : Fin (degree d)) : + outputPair (evaluateRow G H vertex cloud port).1 (evaluateRow G H vertex cloud port).2 = + lookup (step G H) (rowIndex v (cloudSize d) (vertex,cloud),port) := by + rw [lookup_step] + simp only [evaluateRow, start, receiveFirst, receiveSecond, firstOffset, secondOffset, + squarePorts, outputPair, outputPort, stepLookup, Equiv.symm_apply_apply] + +theorem outputAddress_eq_step_row {v d : Nat} + (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (cloud : Fin (cloudSize d)) (port : Fin (degree d)) : + outputAddress (evaluateRow G H vertex cloud port).1.val (evaluateRow G H vertex cloud port).2 = + (rowIndex (v * cloudSize d) (degree d) + (lookup (step G H) (rowIndex v (cloudSize d) (vertex,cloud),port))).val := by + rw [outputAddress_eq_rowIndex, evaluateRow_eq_lookup_step] + +theorem outputAddress_eq_step_reverseIndex {v d : Nat} + (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (cloud : Fin (cloudSize d)) (port : Fin (degree d)) : + outputAddress (evaluateRow G H vertex cloud port).1.val (evaluateRow G H vertex cloud port).2 = + (reverseIndex (step G H) (rowIndex (v * cloudSize d) (degree d) + (rowIndex v (cloudSize d) (vertex,cloud),port))).val := by + rw [outputAddress_eq_step_row, rowIndex_lookup] + +end IndependentSetsGames.Foundations.PCP.ExpanderRowControl + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableEnumeration.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..29c767be8e42407849c5a8df7b21255c770dfe80 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableEnumeration.lean @@ -0,0 +1,204 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderRowControl +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.ExpanderTableEnumeration + +open ExpanderTables ExpanderRowControl ExpanderTableWords +open IndependentSetsGames.Foundations.Complexity + +variable {v d : Nat} + +def globalIndex (vertex : Fin v) (position : Fin (rowFactor d)) : + Fin ((v * cloudSize d) * degree d) := + let pair := (rowIndex (cloudSize d) (degree d)).symm position + rowIndex (v * cloudSize d) (degree d) + (rowIndex v (cloudSize d) (vertex, pair.1), pair.2) + +theorem globalIndex_val (vertex : Fin v) (position : Fin (rowFactor d)) : + (globalIndex vertex position).val = position.val + rowFactor d * vertex.val := by + let pair := (rowIndex (cloudSize d) (degree d)).symm position + have hp := congrArg Fin.val + ((rowIndex (cloudSize d) (degree d)).apply_symm_apply position) + change pair.2.val + degree d * pair.1.val = position.val at hp + change pair.2.val + degree d * (pair.1.val + cloudSize d * vertex.val) = _ + calc + _ = (pair.2.val + degree d * pair.1.val) + rowFactor d * vertex.val := by + dsimp only [rowFactor] + ring + _ = position.val + rowFactor d * vertex.val := by rw [hp] + +def rowValue (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (position : Fin (rowFactor d)) : Nat := + let pair := (rowIndex (cloudSize d) (degree d)).symm position + let result := evaluateRow G H vertex pair.1 pair.2 + outputAddress result.1.val result.2 + +theorem rowValue_eq_reverseIndex (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (position : Fin (rowFactor d)) : + rowValue G H vertex position = (reverseIndex (step G H) (globalIndex vertex position)).val := by + exact outputAddress_eq_step_reverseIndex G H vertex + ((rowIndex (cloudSize d) (degree d)).symm position).1 + ((rowIndex (cloudSize d) (degree d)).symm position).2 + +def vertexWords (G : Table v (degree d)) (H : Table (cloudSize d) d) (vertex : Fin v) : + List Nat := List.ofFn (rowValue G H vertex) + +def generatedWords (G : Table v (degree d)) (H : Table (cloudSize d) d) : List Nat := + (List.ofFn (vertexWords G H)).flatten + +@[simp] theorem vertexWords_length (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) : (vertexWords G H vertex).length = rowFactor d := by + simp [vertexWords] + +theorem vertexWords_drop_succ (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (position : Fin (rowFactor d)) : + (vertexWords G H vertex).drop position.val = + rowValue G H vertex position :: (vertexWords G H vertex).drop (position.val + 1) := by + rw [List.drop_eq_getElem_cons (by simp)] + simp [vertexWords] + +@[simp] theorem vertexWords_drop_full (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) : (vertexWords G H vertex).drop (rowFactor d) = [] := by + apply List.drop_eq_nil_of_le + simp + +theorem vertexWords_drop_last (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (position : Fin (rowFactor d)) + (last : position.val + 1 = rowFactor d) : + (vertexWords G H vertex).drop position.val = [rowValue G H vertex position] := by + rw [vertexWords_drop_succ, last, vertexWords_drop_full] + +private theorem ofFn_cast {α : Type*} {n m : Nat} (h : n = m) (f : Fin m → α) : + List.ofFn (fun i : Fin n => f (Fin.cast h i)) = List.ofFn f := by + cases h + rfl + +theorem rotationWords_eq_ofFn {n q : Nat} (G : Table n q) : + rotationWords G = List.ofFn (fun i : Fin (n * q) => (reverseIndex G i).val) := by + apply List.ext_getElem + · simp + · intro i hi hj + rw [List.getElem_ofFn] + exact rotationWords_getElem G i (by simpa only [rotationWords_length] using hi) + +theorem rowCount_eq : v * rowFactor d = (v * cloudSize d) * degree d := + (Nat.mul_assoc v (cloudSize d) (degree d)).symm + +theorem generatedWords_eq_flat_ofFn (G : Table v (degree d)) (H : Table (cloudSize d) d) : + generatedWords G H = List.ofFn (fun i : Fin (v * rowFactor d) => + (reverseIndex (step G H) (Fin.cast rowCount_eq i)).val) := by + rw [List.ofFn_mul] + unfold generatedWords vertexWords + apply congrArg List.flatten + apply congrArg List.ofFn + funext vertex + apply congrArg List.ofFn + funext position + rw [rowValue_eq_reverseIndex] + apply congrArg (fun i : Fin ((v * cloudSize d) * degree d) => + (reverseIndex (step G H) i).val) + apply Fin.ext + rw [globalIndex_val] + change position.val + rowFactor d * vertex.val = vertex.val * rowFactor d + position.val + ac_rfl + +theorem generatedWords_eq_rotationWords (G : Table v (degree d)) (H : Table (cloudSize d) d) : + generatedWords G H = rotationWords (step G H) := by + rw [generatedWords_eq_flat_ofFn] + exact (ofFn_cast (rowCount_eq (v := v) (d := d)) + (fun i => (reverseIndex (step G H) i).val)).trans + (rotationWords_eq_ofFn (step G H)).symm + +@[simp] theorem generatedWords_length (G : Table v (degree d)) (H : Table (cloudSize d) d) : + (generatedWords G H).length = v * rowFactor d := by + rw [generatedWords_eq_rotationWords, rotationWords_length] + exact rowCount_eq.symm + +def priorVertices (G : Table v (degree d)) (H : Table (cloudSize d) d) (count : Nat) : + List Nat := ((List.ofFn (vertexWords G H)).take count).flatten + +def prefixRows (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (completedPositions : Nat) : List Nat := + priorVertices G H vertex.val ++ (vertexWords G H vertex).take completedPositions + +@[simp] theorem priorVertices_zero (G : Table v (degree d)) (H : Table (cloudSize d) d) : + priorVertices G H 0 = [] := by simp [priorVertices] + +@[simp] theorem priorVertices_full (G : Table v (degree d)) (H : Table (cloudSize d) d) : + priorVertices G H v = generatedWords G H := by + unfold priorVertices generatedWords + rw [List.take_of_length_le (by simp)] + +theorem priorVertices_succ (G : Table v (degree d)) (H : Table (cloudSize d) d) + (k : Nat) (hk : k < v) : + priorVertices G H (k + 1) = priorVertices G H k ++ vertexWords G H ⟨k, hk⟩ := by + unfold priorVertices + rw [List.take_succ_eq_append_getElem (by simpa using hk), List.flatten_append] + simp + +@[simp] theorem prefixRows_zero (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) : prefixRows G H vertex 0 = priorVertices G H vertex.val := by + simp [prefixRows] + +theorem prefixRows_succ (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (r : Nat) (hr : r < rowFactor d) : + prefixRows G H vertex (r + 1) = + prefixRows G H vertex r ++ [rowValue G H vertex ⟨r, hr⟩] := by + unfold prefixRows + rw [List.take_succ_eq_append_getElem (by simpa using hr)] + simp [vertexWords, List.append_assoc] + +theorem prefixRows_complete (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) : + prefixRows G H vertex (rowFactor d) = priorVertices G H (vertex.val + 1) := by + rw [prefixRows, List.take_of_length_le (by simp)] + simpa using (priorVertices_succ G H vertex.val vertex.isLt).symm + +def accumulate (values : List Nat) (initial : List Bool) : List Bool := + values.foldl (fun accumulator value => (encodeWord value).reverse ++ accumulator) initial + +theorem accumulate_eq (values : List Nat) (initial : List Bool) : + accumulate values initial = (encodeWords values).reverse ++ initial := by + induction values generalizing initial with + | nil => simp [accumulate, encodeWords] + | cons value values ih => + simpa only [accumulate, List.foldl_cons, encodeWords, List.reverse_append, + List.append_assoc] using ih ((encodeWord value).reverse ++ initial) + +theorem accumulate_append (first second : List Nat) (initial : List Bool) : + accumulate (first ++ second) initial = accumulate second (accumulate first initial) := by + simp only [accumulate, List.foldl_append] + +theorem accumulate_prefixRows_succ (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (r : Nat) (hr : r < rowFactor d) (initial : List Bool) : + accumulate (prefixRows G H vertex (r + 1)) initial = + (encodeWord (rowValue G H vertex ⟨r, hr⟩)).reverse ++ + accumulate (prefixRows G H vertex r) initial := by + rw [prefixRows_succ G H vertex r hr, accumulate_append] + rfl + +theorem accumulate_generatedWords (G : Table v (degree d)) (H : Table (cloudSize d) d) + (initial : List Bool) : + accumulate (generatedWords G H) initial = + (encodeWords (rotationWords (step G H))).reverse ++ initial := by + rw [accumulate_eq, generatedWords_eq_rotationWords] + +theorem encode_generatedWords_length_le (G : Table v (degree d)) (H : Table (cloudSize d) d) : + (encodeWords (generatedWords G H)).length ≤ + (v * rowFactor d) * (v * rowFactor d + 1) := by + rw [generatedWords_eq_rotationWords, rowCount_eq] + exact encode_rotationWords_length_le (step G H) + +theorem accumulate_generatedWords_length_le (G : Table v (degree d)) + (H : Table (cloudSize d) d) (initial : List Bool) : + (accumulate (generatedWords G H) initial).length ≤ + (v * rowFactor d) * (v * rowFactor d + 1) + initial.length := by + rw [accumulate_eq, List.length_append, List.length_reverse] + exact Nat.add_le_add_right (encode_generatedWords_length_le G H) initial.length + +end IndependentSetsGames.Foundations.PCP.ExpanderTableEnumeration + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableWords.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a636abc08eebbecf97e0acb5ba9975e5104a2ea --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableWords.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.Target +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.ExpanderTableWords + +open ExpanderTables +open IndependentSetsGames.Foundations.Complexity (encodeWords decodeWords) + +variable {v d : ℕ} + +def rotationWords (table : Table v d) : List Nat := table.rows.toList.map Fin.val + +@[simp] theorem rotationWords_length (table : Table v d) : + (rotationWords table).length = v * d := by + simp [rotationWords] + +theorem rotationWords_getElem (table : Table v d) (i : ℕ) (hi : i < v * d) : + (rotationWords table)[i]'(by simpa only [rotationWords_length] using hi) = + (reverseIndex table ⟨i, hi⟩).val := by + simp only [rotationWords, List.getElem_map, Vector.getElem_toList, + reverseIndex, Fin.getElem_fin] + +theorem rotationWords_get (table : Table v d) (i : Fin (v * d)) : + (rotationWords table).get + ⟨i.val, by simpa only [rotationWords_length] using i.isLt⟩ = + (reverseIndex table i).val := by + simpa only [List.get_eq_getElem] using rotationWords_getElem table i.val i.isLt + +theorem rotationWords_getElem? (table : Table v d) (i : Fin (v * d)) : + (rotationWords table)[i.val]? = some (reverseIndex table i).val := by + apply List.getElem?_eq_some_iff.mpr + exact ⟨by simpa only [rotationWords_length] using i.isLt, + rotationWords_getElem table i.val i.isLt⟩ + +theorem rotationWords_getElem?_none (table : Table v d) (i : ℕ) (hi : v * d ≤ i) : + (rotationWords table)[i]? = none := + List.getElem?_eq_none (by simpa only [rotationWords_length] using hi) + +theorem rotationWords_entry_lt (table : Table v d) (n : ℕ) + (hn : n ∈ rotationWords table) : n < v * d := by + obtain ⟨a, _, rfl⟩ := List.mem_map.mp hn + exact a.isLt + +theorem rotationWords_lookup (table : Table v d) (x : Fin v × Fin d) : + (rotationWords table)[(rowIndex v d x).val]? = + some (rowIndex v d (lookup table x)).val := by + simpa only [lookup, Equiv.apply_symm_apply] using + rotationWords_getElem? table (rowIndex v d x) + +theorem rotationWords_row_order (table : Table v d) (x : Fin v × Fin d) : + (rotationWords table)[x.2.val + d * x.1.val]? = + some ((lookup table x).2.val + d * (lookup table x).1.val) := by + simpa only [rowIndex_val] using rotationWords_lookup table x + +@[simp] theorem decode_rotationWords (table : Table v d) : + decodeWords (encodeWords (rotationWords table)) = some (rotationWords table) := + Complexity.decodeWords_encodeWords _ + +theorem decoded_lookup (table : Table v d) (i : Fin (v * d)) : + (decodeWords (encodeWords (rotationWords table))).bind (fun words => words[i.val]?) = + some (reverseIndex table i).val := by + rw [decode_rotationWords] + exact rotationWords_getElem? table i + +theorem decoded_coordinate_lookup (table : Table v d) (x : Fin v × Fin d) : + (decodeWords (encodeWords (rotationWords table))).bind + (fun words => words[x.2.val + d * x.1.val]?) = + some ((lookup table x).2.val + d * (lookup table x).1.val) := by + rw [decode_rotationWords] + exact rotationWords_row_order table x + +theorem encode_rotationWords_length_eq (table : Table v d) : + (encodeWords (rotationWords table)).length = (rotationWords table).sum + v * d := by + rw [Complexity.encodeWords_length, rotationWords_length] + +theorem encode_rotationWords_length_le (table : Table v d) : + (encodeWords (rotationWords table)).length ≤ (v * d) * (v * d + 1) := by + calc + _ ≤ (rotationWords table).length * (v * d + 1) := + Complexity.encodeWords_length_le _ _ + (fun n hn => (rotationWords_entry_lt table n hn).le) + _ = _ := by rw [rotationWords_length] + +end IndependentSetsGames.Foundations.PCP.ExpanderTableWords + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab6cb6b3737df4ca647bb023ca3cebf2471f00de --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTables.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderFamily + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.ExpanderTables + +open PoweringWalks SpectralReturn + +def rowIndex (v d : Nat) : Fin v × Fin d ≃ Fin (v * d) := finProdFinEquiv + +theorem rowIndex_val (v d : Nat) (x : Fin v × Fin d) : + (rowIndex v d x).val = x.2.val + d * x.1.val := rfl + +structure Table (v d : Nat) where + rows : Vector (Fin (v * d)) (v * d) + involutive : Function.Involutive (fun i : Fin (v * d) => rows[i]) + +def reverseIndex {v d : Nat} (table : Table v d) (i : Fin (v * d)) : Fin (v * d) := + table.rows[i] + +def lookup {v d : Nat} (table : Table v d) (x : Fin v × Fin d) : Fin v × Fin d := + (rowIndex v d).symm (reverseIndex table (rowIndex v d x)) + +theorem lookup_involutive {v d : Nat} (table : Table v d) : + Function.Involutive (lookup table) := by + intro x + simp only [lookup, Equiv.apply_symm_apply] + exact (congrArg (rowIndex v d).symm (table.involutive (rowIndex v d x))).trans + ((rowIndex v d).symm_apply_apply x) + +def graph {v d : Nat} (table : Table v d) : PortGraph (Fin v) (Fin d) where + rot := ZigzagGraphs.involutionEquiv (lookup table) (lookup_involutive table) + rot_involutive := lookup_involutive table + +@[simp] theorem graph_rot {v d : Nat} (table : Table v d) (x : Fin v × Fin d) : + (graph table).rot x = lookup table x := rfl + +def ofGraph {v d : Nat} (G : PortGraph (Fin v) (Fin d)) : Table v d where + rows := Vector.ofFn (fun i => rowIndex v d (G.rot ((rowIndex v d).symm i))) + involutive := by + intro i + simp only [Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, Equiv.symm_apply_apply] + exact (congrArg (rowIndex v d) (G.rot_involutive ((rowIndex v d).symm i))).trans + ((rowIndex v d).apply_symm_apply i) + +@[simp] theorem lookup_ofGraph {v d : Nat} (G : PortGraph (Fin v) (Fin d)) + (x : Fin v × Fin d) : lookup (ofGraph G) x = G.rot x := by + simp only [lookup, reverseIndex, ofGraph, Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, + Equiv.symm_apply_apply] + +private theorem graph_ext {V D : Type*} {G H : PortGraph V D} + (h : ∀ x, G.rot x = H.rot x) : G = H := by + have hr : G.rot = H.rot := Equiv.ext h + cases G + cases H + cases hr + rfl + +@[simp] theorem graph_ofGraph {v d : Nat} (G : PortGraph (Fin v) (Fin d)) : + graph (ofGraph G) = G := graph_ext (lookup_ofGraph G) + +theorem row_count {v d : Nat} (table : Table v d) : table.rows.toList.length = v * d := by + simp + +def vertexIndex (v q : Nat) : Fin v × (Fin q × Fin q) ≃ Fin (v * (q * q)) := + (Equiv.prodCongr (Equiv.refl _) (rowIndex q q)).trans (rowIndex v (q * q)) + +def stepGraph {v d : Nat} (G : Table v (d * d)) + (H : Table ((d * d) * (d * d)) d) : + PortGraph (Fin (v * ((d * d) * (d * d)))) (Fin (d * d)) := + GraphTransport.reindex + (ZigzagGraphs.zigzag (ZigzagGraphs.square (graph G)) + (GraphTransport.reindex (graph H) (rowIndex (d * d) (d * d)).symm (Equiv.refl _))) + (vertexIndex v (d * d)) (rowIndex d d) + +def step {v d : Nat} (G : Table v (d * d)) + (H : Table ((d * d) * (d * d)) d) : + Table (v * ((d * d) * (d * d))) (d * d) := ofGraph (stepGraph G H) + +def stepLookup {v d : Nat} (G : Table v (d * d)) + (H : Table ((d * d) * (d * d)) d) + (x : Fin (v * ((d * d) * (d * d))) × Fin (d * d)) : + Fin (v * ((d * d) * (d * d))) × Fin (d * d) := + let vc := (rowIndex v ((d * d) * (d * d))).symm x.1 + let ports := (rowIndex d d).symm x.2 + let first := lookup H (vc.2, ports.1) + let squarePorts := (rowIndex (d * d) (d * d)).symm first.1 + let outerFirst := lookup G (vc.1, squarePorts.1) + let outerSecond := lookup G (outerFirst.1, squarePorts.2) + let last := lookup H (rowIndex (d * d) (d * d) (outerSecond.2, outerFirst.2), ports.2) + (rowIndex v ((d * d) * (d * d)) (outerSecond.1, last.1), + rowIndex d d (last.2, first.2)) + +theorem lookup_step {v d : Nat} (G : Table v (d * d)) + (H : Table ((d * d) * (d * d)) d) + (x : Fin (v * ((d * d) * (d * d))) × Fin (d * d)) : + lookup (step G H) x = stepLookup G H x := by + simp [step, stepGraph, GraphTransport.reindex, + Equiv.trans_apply, Equiv.prodCongr_apply, + Equiv.prodCongr_symm, Equiv.refl_apply, vertexIndex, Equiv.apply_symm_apply, + ZigzagGraphs.zigzag, ZigzagGraphs.square, ZigzagGraphs.involutionEquiv, + ZigzagGraphs.cloudFirst, ZigzagGraphs.crossCloud, graph_rot, + stepLookup, Prod.map, Equiv.symm_symm] + all_goals repeat' constructor + +theorem step_certificate {v d : Nat} [NeZero v] [NeZero d] + (G : Table v (d * d)) (H : Table ((d * d) * (d * d)) d) + (hG : SpectralCertificate (graph G) (1 / 2 : ℝ)) + (hH : SpectralCertificate (graph H) (1 / 100 : ℝ)) : + SpectralCertificate (graph (step G H)) (1 / 2 : ℝ) := by + rw [step, graph_ofGraph] + apply GraphTransport.reindex_spectralCertificate + apply ZigzagSpectral.square_zigzag_halfCertificate + · exact hG + · exact GraphTransport.reindex_spectralCertificate _ _ _ _ hH + +def initial (d : Nat) : Table 1 (d * d) := + ofGraph { rot := Equiv.refl _, rot_involutive := fun _ => rfl } + +theorem initial_certificate (d : Nat) : + SpectralCertificate (graph (initial d)) (1 / 2 : ℝ) := by + refine ⟨by norm_num, by norm_num, ?_⟩ + intro f hf + have hfun : f = fun _ => f 0 := funext (fun x => congrArg f (Subsingleton.elim x 0)) + have hm : mean f = f 0 := (congrArg mean hfun).trans (mean_const _) + have hz : f 0 = 0 := hm.symm.trans hf + rw [hfun, hz] + simp [energy, mean, averagingOperator] + +def vertexCount (q : Nat) : Nat → Nat + | 0 => 1 + | n + 1 => vertexCount q n * (q * q) + +theorem vertexCount_eq (q n : Nat) : vertexCount q n = (q * q) ^ n := by + induction n with + | zero => rfl + | succ n ih => simp only [vertexCount, ih, pow_succ] + +theorem vertexCount_positive {q : Nat} (hq : 0 < q) (n : Nat) : + 0 < vertexCount q n := by + rw [vertexCount_eq] + exact Nat.pow_pos (Nat.mul_pos hq hq) + +def family {d : Nat} (H : Table ((d * d) * (d * d)) d) : + (n : Nat) → Table (vertexCount (d * d) n) (d * d) + | 0 => initial d + | n + 1 => step (family H n) H + +theorem family_certificate {d : Nat} [NeZero d] + (H : Table ((d * d) * (d * d)) d) + (hH : SpectralCertificate (graph H) (1 / 100 : ℝ)) (n : Nat) : + SpectralCertificate (graph (family H n)) (1 / 2 : ℝ) := by + induction n with + | zero => exact initial_certificate d + | succ n ih => + let : NeZero (vertexCount (d * d) n) := + ⟨Nat.ne_of_gt (vertexCount_positive (Nat.mul_pos (NeZero.pos d) (NeZero.pos d)) n)⟩ + exact step_certificate _ _ ih hH + +theorem family_row_count {d : Nat} (H : Table ((d * d) * (d * d)) d) (n : Nat) : + (family H n).rows.toList.length = ((d * d) * (d * d)) ^ n * (d * d) := by + rw [row_count, vertexCount_eq] + +theorem exists_base_table : ∃ H : Table + ((Expanders.baseDegree * Expanders.baseDegree) * + (Expanders.baseDegree * Expanders.baseDegree)) Expanders.baseDegree, + SpectralCertificate (graph H) (1 / 100 : ℝ) := by + classical + have hv : Fintype.card ExpanderFamily.CloudPort = + (Expanders.baseDegree * Expanders.baseDegree) * + (Expanders.baseDegree * Expanders.baseDegree) := by + rw [ExpanderFamily.card_cloudPort] + unfold ExpanderFamily.growth + ring + let vertices := Fintype.equivFinOfCardEq hv + let ports := Fintype.equivFinOfCardEq Expanders.card_basePort + let G := GraphTransport.reindex ExpanderFamily.baseOnCloud vertices ports + refine ⟨ofGraph G, ?_⟩ + rw [graph_ofGraph] + exact GraphTransport.reindex_spectralCertificate _ _ _ _ + ExpanderFamily.baseOnCloud_certificate + +end IndependentSetsGames.Foundations.PCP.ExpanderTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Expanders.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Expanders.lean new file mode 100644 index 0000000000000000000000000000000000000000..d159dcf537e06e6733afd45bb62db9d2414f8cd5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Expanders.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Walsh2 +import OAI.Combinatorics.IndependentSets.Expansion.CayleyTailCount +import OAI.Combinatorics.IndependentSets.Expansion.CayleySpectral + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.Expanders + +open scoped BigOperators +open IndependentSetsGames.Foundations.Hastad +open CayleySpectral + +abbrev Generators (n m : Nat) := Fin (4 * m) → Cube (Fin n) + +def badFrequency {n m : Nat} (g : Generators n m) (s : Cube (Fin n)) : ℝ := + if s = zeroFrequency then 0 else + if CayleyTailCount.badWord m (fun d => AssignmentTester.parity s (g d)) then 1 else 0 + +def badMass {n m : Nat} (g : Generators n m) : ℝ := + ∑ s : Cube (Fin n), badFrequency g s + +theorem badFrequency_nonnegative {n m : Nat} + (g : Generators n m) (s : Cube (Fin n)) : 0 ≤ badFrequency g s := by + unfold badFrequency + split_ifs <;> norm_num + +theorem mean_badFrequency_le {n m : Nat} (s : Cube (Fin n)) : + (𝔼 g : Generators n m, badFrequency g s) ≤ 2 * (2 / 3 : ℝ) ^ m := by + classical + by_cases hs : s = zeroFrequency + · simp only [badFrequency, ite_eq_left hs, Finset.expect_const_zero] + positivity + · have hs' : s ≠ (fun _ => false) := hs + simp only [badFrequency, ite_eq_right hs] + rw [CayleySampling.expect_parity_samples s hs' + (fun w : Fin (4 * m) → Bool => if CayleyTailCount.badWord m w then (1 : ℝ) else 0)] + exact CayleyTailCount.twoTail_probability m (by simp) + +theorem mean_badMass_le (n m : Nat) (hm : 3 * (n + 2) ≤ m) : + (𝔼 g : Generators n m, badMass g) ≤ 1 / 2 := by + calc + _ = ∑ s : Cube (Fin n), 𝔼 g : Generators n m, badFrequency g s := by + unfold badMass + rw [Finset.expect_sum_comm] + _ ≤ ∑ _s : Cube (Fin n), 2 * (2 / 3 : ℝ) ^ m := + Finset.sum_le_sum (fun s _ => mean_badFrequency_le s) + _ = (2 : ℝ) ^ n * (2 * (2 / 3 : ℝ) ^ m) := by + simp [Cube] + _ ≤ 1 / 2 := CayleyTailCount.union_bound_le_half n m hm + +theorem exists_generators (n m : Nat) (hm : 3 * (n + 2) ≤ m) : + ∃ g : Generators n m, ∀ s : Cube (Fin n), + s ≠ zeroFrequency → |eigenvalue g s| ≤ (1 / 2 : ℝ) := by + classical + have hmpos : 0 < m := by omega + let : Nonempty (Fin (4 * m)) := ⟨⟨0, by omega⟩⟩ + have havg : (𝔼 g : Generators n m, badMass g) < (1 : ℝ) := + lt_of_le_of_lt (mean_badMass_le n m hm) (by norm_num) + obtain ⟨g, _, hg⟩ := Finset.exists_lt_of_expect_lt Finset.univ_nonempty havg + refine ⟨g, fun s hs => ?_⟩ + have hgood : ¬ CayleyTailCount.badWord m + (fun d => AssignmentTester.parity s (g d)) := by + intro hbad + have hsingle : badFrequency g s ≤ badMass g := + Finset.single_le_sum (fun t _ => badFrequency_nonnegative g t) (Finset.mem_univ s) + simp only [badFrequency, ite_eq_right hs, ite_eq_left hbad] at hsingle + exact (not_le_of_gt hg) hsingle + unfold eigenvalue + simp_rw [← AssignmentTester.bitSign_parity] + exact CayleyTailCount.not_badWord_bias m (by simp) hmpos _ hgood + +def baseDimension : Nat := 448 +def initialDegree : Nat := 2 ^ 16 +def initialQuarterDegree : Nat := 2 ^ 14 +def basePower : Nat := 7 + +theorem base_arithmetic : + 4 * initialQuarterDegree = initialDegree ∧ + 3 * (baseDimension + 2) ≤ initialQuarterDegree ∧ + (2 : Nat) ^ baseDimension = (initialDegree ^ basePower) ^ 4 ∧ + (1 / 2 : ℝ) ^ basePower ≤ 1 / 100 := by + refine ⟨?_, ?_, ?_, ?_⟩ + · norm_num [initialDegree, initialQuarterDegree] + · norm_num [baseDimension, initialQuarterDegree] + · simpa only [baseDimension, initialDegree, basePower] using CayleyTailCount.seventh_power_size + · norm_num [basePower] + +theorem exists_initial_generators : + ∃ g : Generators baseDimension initialQuarterDegree, + ∀ s : Cube (Fin baseDimension), s ≠ zeroFrequency → + |eigenvalue g s| ≤ (1 / 2 : ℝ) := + exists_generators _ _ base_arithmetic.2.1 + +abbrev BaseVertex := Cube (Fin baseDimension) +abbrev BasePort := Fin basePower → Fin (4 * initialQuarterDegree) +def baseDegree : Nat := initialDegree ^ basePower + +theorem card_basePort : Fintype.card BasePort = baseDegree := by + simp only [BasePort, Fintype.card_fun, Fintype.card_fin] + rw [base_arithmetic.1] + rfl + +theorem card_baseVertex : Fintype.card BaseVertex = baseDegree ^ 4 := by + simpa only [BaseVertex, Cube, Fintype.card_fun, Fintype.card_bool, + Fintype.card_fin, baseDegree] using base_arithmetic.2.2.1 + +theorem exists_baseGraph : + ∃ H : PoweringWalks.PortGraph BaseVertex BasePort, + SpectralReturn.SpectralCertificate H (1 / 100 : ℝ) := by + obtain ⟨g, hg⟩ := exists_initial_generators + refine ⟨cayleyGraph (powerGenerators g basePower), ?_⟩ + apply cayley_spectralCertificate + · norm_num + · norm_num + · intro s hs + exact (power_eigenvalue_bound g (1 / 2) (by norm_num) hg basePower s hs).trans + base_arithmetic.2.2.2 + +end IndependentSetsGames.Foundations.PCP.Expanders +end +namespace IndependentSetsGames.Foundations.PCP.GraphTransport + +open PoweringWalks SpectralReturn + +variable {V W D E : Type*} + +def reindex (G : PortGraph V D) (vertices : V ≃ W) (ports : D ≃ E) : + PortGraph W E where + rot := (Equiv.prodCongr vertices ports).symm.trans + (G.rot.trans (Equiv.prodCongr vertices ports)) + rot_involutive := by + intro x + change (Equiv.prodCongr vertices ports) + (G.rot ((Equiv.prodCongr vertices ports).symm + ((Equiv.prodCongr vertices ports) + (G.rot ((Equiv.prodCongr vertices ports).symm x))))) = x + rw [Equiv.symm_apply_apply, G.rot_involutive, Equiv.apply_symm_apply] + +@[simp] theorem reindex_rot (G : PortGraph V D) (vertices : V ≃ W) + (ports : D ≃ E) (v : V) (d : D) : + (reindex G vertices ports).rot (vertices v, ports d) = + (vertices (G.rot (v, d)).1, ports (G.rot (v, d)).2) := by + simp [reindex, Equiv.trans_apply, Prod.map] + +end IndependentSetsGames.Foundations.PCP.GraphTransport + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Finite.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Finite.lean new file mode 100644 index 0000000000000000000000000000000000000000..37d51daa8c3262061d9b355f796e29a3bf617297 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Finite.lean @@ -0,0 +1,189 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.Expanders + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.GraphTransport +open PoweringWalks SpectralReturn +variable {V W D E : Type*} + +variable [Fintype V] [Fintype W] [Fintype D] [Fintype E] + +omit [Fintype V] [Fintype W] in +theorem operator_reindex (G : PortGraph V D) (vertices : V ≃ W) + (ports : D ≃ E) (f : W → ℝ) (w : W) : + averagingOperator (reindex G vertices ports) f w = + averagingOperator G (fun v => f (vertices v)) (vertices.symm w) := by + unfold averagingOperator + apply Fintype.expect_equiv ports.symm + intro e + rfl + +theorem energy_reindex (vertices : V ≃ W) (f : W → ℝ) : + energy (fun v => f (vertices v)) = energy f := + mean_equiv vertices (fun w => f w ^ 2) + +theorem reindex_spectralCertificate (G : PortGraph V D) (vertices : V ≃ W) + (ports : D ≃ E) (lambda : ℝ) (certificate : SpectralCertificate G lambda) : + SpectralCertificate (reindex G vertices ports) lambda where + nonnegative := certificate.nonnegative + lt_one := certificate.lt_one + contraction := by + intro f hf + have hf' : mean (fun v => f (vertices v)) = 0 := + (mean_equiv vertices f).trans hf + have h := certificate.contraction (fun v => f (vertices v)) hf' + have hout : energy (averagingOperator (reindex G vertices ports) f) = + energy (averagingOperator G (fun v => f (vertices v))) := by + rw [← energy_reindex vertices] + congr 1 + funext v + rw [operator_reindex, vertices.symm_apply_apply] + rw [hout, ← energy_reindex vertices f] + exact h + +end IndependentSetsGames.Foundations.PCP.GraphTransport +namespace IndependentSetsGames.Foundations.PCP.ZigzagGraphs + +open PoweringWalks + +variable {V D E : Type*} + +def involutionEquiv {A : Type*} (f : A → A) (hf : Function.Involutive f) : A ≃ A where + toFun := f + invFun := f + left_inv := hf + right_inv := hf + +theorem palindrome_involutive {A : Type*} (B P : A ≃ A) + (hB : Function.Involutive B) (hP : Function.Involutive P) : + Function.Involutive (B.trans (P.trans B)) := by + intro x + change B (P (B (B (P (B x))))) = x + rw [hB, hP, hB] + +def squareFirst (G : PortGraph V D) (s : V × (D × D)) : V × (D × D) := + let step := G.rot (s.1, s.2.1) + (step.1, (step.2, s.2.2)) + +theorem squareFirst_involutive (G : PortGraph V D) : Function.Involutive (squareFirst G) := by + rintro ⟨v, d₁, d₂⟩ + change ((G.rot (G.rot (v, d₁))).1, ((G.rot (G.rot (v, d₁))).2, d₂)) = + (v, (d₁, d₂)) + rw [G.rot_involutive] + +def squareSwap (s : V × (D × D)) : V × (D × D) := (s.1, (s.2.2, s.2.1)) + +theorem squareSwap_involutive : Function.Involutive (squareSwap (V := V) (D := D)) := by + rintro ⟨v, d₁, d₂⟩ + rfl + +def square (G : PortGraph V D) : PortGraph V (D × D) := by + let B := involutionEquiv (squareFirst G) (squareFirst_involutive G) + let P := involutionEquiv (squareSwap (V := V) (D := D)) squareSwap_involutive + exact + { rot := B.trans (P.trans B) + rot_involutive := palindrome_involutive B P + (squareFirst_involutive G) squareSwap_involutive } + +@[simp] theorem square_rot_apply (G : PortGraph V D) (v : V) (d₁ d₂ : D) : + (square G).rot (v, (d₁, d₂)) = + let first := G.rot (v, d₁) + let second := G.rot (first.1, d₂) + (second.1, (second.2, first.2)) := rfl + +@[simp] theorem square_next (G : PortGraph V D) (v : V) (d₁ d₂ : D) : + next (square G) v (d₁, d₂) = next G (next G v d₁) d₂ := rfl + +def cloudFirst (H : PortGraph D E) (s : (V × D) × (E × E)) : + (V × D) × (E × E) := + let step := H.rot (s.1.2, s.2.1) + ((s.1.1, step.1), (step.2, s.2.2)) + +theorem cloudFirst_involutive (H : PortGraph D E) : + Function.Involutive (cloudFirst (V := V) H) := by + rintro ⟨⟨v, d⟩, ⟨e₁, e₂⟩⟩ + change ((v, (H.rot (H.rot (d, e₁))).1), ((H.rot (H.rot (d, e₁))).2, e₂)) = + ((v, d), (e₁, e₂)) + rw [H.rot_involutive] + +def crossCloud (G : PortGraph V D) (s : (V × D) × (E × E)) : + (V × D) × (E × E) := (G.rot s.1, (s.2.2, s.2.1)) + +theorem crossCloud_involutive (G : PortGraph V D) : + Function.Involutive (crossCloud (E := E) G) := by + rintro ⟨x, e₁, e₂⟩ + change (G.rot (G.rot x), (e₁, e₂)) = (x, (e₁, e₂)) + rw [G.rot_involutive] + +def zigzag (G : PortGraph V D) (H : PortGraph D E) : PortGraph (V × D) (E × E) := by + let B := involutionEquiv (cloudFirst (V := V) H) (cloudFirst_involutive H) + let P := involutionEquiv (crossCloud (E := E) G) (crossCloud_involutive G) + exact + { rot := B.trans (P.trans B) + rot_involutive := palindrome_involutive B P + (cloudFirst_involutive H) (crossCloud_involutive G) } + +@[simp] theorem zigzag_rot_apply (G : PortGraph V D) (H : PortGraph D E) + (v : V) (d : D) (e₁ e₂ : E) : + (zigzag G H).rot ((v, d), (e₁, e₂)) = + let first := H.rot (d, e₁) + let middle := G.rot (v, first.1) + let last := H.rot (middle.2, e₂) + ((middle.1, last.1), (last.2, first.2)) := rfl + +theorem natCard_square_ports : Nat.card (D × D) = Nat.card D ^ 2 := by + simp [Nat.card_prod, pow_two] + +theorem natCard_square_edges : + Nat.card (Edge V (D × D)) = Nat.card V * Nat.card D ^ 2 := by + simp [Edge, Nat.card_prod, pow_two] + +theorem natCard_zigzag_vertices : + Nat.card (V × D) = Nat.card V * Nat.card D := Nat.card_prod V D + +theorem natCard_zigzag_ports : Nat.card (E × E) = Nat.card E ^ 2 := by + simp [Nat.card_prod, pow_two] + +theorem natCard_zigzag_edges : + Nat.card (Edge (V × D) (E × E)) = + Nat.card V * Nat.card D * Nat.card E ^ 2 := by + simp [Edge, Nat.card_prod, pow_two] + +noncomputable section + +def cloudOperator [Fintype E] (H : PortGraph D E) (f : V × D → ℝ) (x : V × D) : ℝ := + SpectralReturn.mean (fun e => f (x.1, (H.rot (x.2, e)).1)) + +def graphPermutation (G : PortGraph V D) (f : V × D → ℝ) (x : V × D) : ℝ := + f (G.rot x) + +theorem averagingOperator_square [Fintype D] (G : PortGraph V D) (f : V → ℝ) : + SpectralReturn.averagingOperator (square G) f = + SpectralReturn.averagingOperator G (SpectralReturn.averagingOperator G f) := by + funext v + let w : D × D → ℝ := fun ds => f (G.rot ((G.rot (v, ds.1)).1, ds.2)).1 + change SpectralReturn.mean w = + SpectralReturn.mean (fun d₁ => SpectralReturn.mean (fun d₂ => w (d₁, d₂))) + exact SpectralReturn.mean_prod w + +theorem averagingOperator_zigzag [Fintype E] (G : PortGraph V D) + (H : PortGraph D E) (f : V × D → ℝ) : + SpectralReturn.averagingOperator (zigzag G H) f = + cloudOperator H (graphPermutation G (cloudOperator H f)) := by + funext x + rcases x with ⟨v, d⟩ + let w : E × E → ℝ := fun es => + let first := H.rot (d, es.1) + let middle := G.rot (v, first.1) + let last := H.rot (middle.2, es.2) + f (middle.1, last.1) + change SpectralReturn.mean w = + SpectralReturn.mean (fun e₁ => SpectralReturn.mean (fun e₂ => w (e₁, e₂))) + exact SpectralReturn.mean_prod w + +end + +end IndependentSetsGames.Foundations.PCP.ZigzagGraphs + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Finite2.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Finite2.lean new file mode 100644 index 0000000000000000000000000000000000000000..965b50ef9bee3230e2a6109b8e4541e0b1ea0ac0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Finite2.lean @@ -0,0 +1,264 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GraphTables +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderFamily + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.CloudPadding +open scoped BigOperators +open DegreeReplacement +variable {V E A : Type*} + +variable [Fintype V] [DecidableEq V] [Fintype E] + +theorem sum_card_cloud (G : ConstraintGraph V E A) : + (∑ v, Fintype.card (Cloud G v)) = Fintype.card E := by + simpa only [Fintype.card_sigma] using (Fintype.card_congr (dartCloudEquiv G)).symm + +theorem card_padded_cloud (G : ConstraintGraph V E A) (dummy : V → Type*) + [∀ v, Fintype (dummy v)] (v : V) : + Fintype.card (Cloud (paddedGraph G dummy) v) = + Fintype.card (Cloud G v) + Fintype.card (dummy v) := by + simpa only [Fintype.card_sum] using Fintype.card_congr (paddedCloudEquiv G dummy v) + +abbrev dummy (G : ConstraintGraph V E A) (v : V) := + Fin (paddedSize (Fintype.card (Cloud G v)) - Fintype.card (Cloud G v)) + +theorem card_cloud (G : ConstraintGraph V E A) (v : V) : + Fintype.card (Cloud (paddedGraph G (dummy G)) v) = + paddedSize (Fintype.card (Cloud G v)) := by + rw [card_padded_cloud] + simp only [dummy, Fintype.card_fin] + exact Nat.add_sub_of_le (le_paddedSize _) + +omit [Fintype V] in +theorem card_dummy_of_empty (G : ConstraintGraph V E A) (v : V) + (hk : Fintype.card (Cloud G v) = 0) : Fintype.card (dummy G v) = 0 := by + simp [dummy, hk] + +theorem card_cloud_of_empty (G : ConstraintGraph V E A) (v : V) + (hk : Fintype.card (Cloud G v) = 0) : + Fintype.card (Cloud (paddedGraph G (dummy G)) v) = 0 := by + rw [card_cloud, hk, paddedSize_zero] + +theorem card_cloud_eq_family (G : ConstraintGraph V E A) (v : V) + (hk : 0 < Fintype.card (Cloud G v)) : + Fintype.card (Cloud (paddedGraph G (dummy G)) v) = + Fintype.card (ExpanderFamily.Vertex + (ExpanderFamily.level (Fintype.card (Cloud G v)))) := by + rw [card_cloud, paddedSize_of_pos hk, ExpanderFamily.card_vertex] + rfl + +theorem card_paddedDart_eq_sum (G : ConstraintGraph V E A) : + Fintype.card (PaddedDart G (dummy G)) = + ∑ v, paddedSize (Fintype.card (Cloud G v)) := by + calc + Fintype.card (PaddedDart G (dummy G)) = + ∑ v, Fintype.card (Cloud (paddedGraph G (dummy G)) v) := + (sum_card_cloud (paddedGraph G (dummy G))).symm + _ = ∑ v, paddedSize (Fintype.card (Cloud G v)) := by + apply Finset.sum_congr rfl + intro v _ + exact card_cloud G v + +theorem card_paddedDart_le (G : ConstraintGraph V E A) : + Fintype.card (PaddedDart G (dummy G)) ≤ ExpanderFamily.growth * Fintype.card E := by + rw [card_paddedDart_eq_sum] + calc + (∑ v, paddedSize (Fintype.card (Cloud G v))) ≤ + ∑ v, ExpanderFamily.growth * Fintype.card (Cloud G v) := by + apply Finset.sum_le_sum + intro v _ + exact paddedSize_le_mul _ + _ = ExpanderFamily.growth * Fintype.card E := by + rw [← Finset.mul_sum, sum_card_cloud] + +end IndependentSetsGames.Foundations.PCP.CloudPadding + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingCloudIndex + +open scoped BigOperators +open GraphTables DegreeReplacement + +def listEquiv {α : Type*} [BEq α] [LawfulBEq α] (xs : List α) + (nodup : xs.Nodup) (complete : ∀ a, a ∈ xs) : α ≃ Fin xs.length where + toFun a := ⟨xs.idxOf a, List.idxOf_lt_length_of_mem (complete a)⟩ + invFun i := xs.get i + left_inv a := List.idxOf_get _ + right_inv i := by + apply Fin.ext + exact List.get_idxOf nodup i + +@[simp] theorem listEquiv_val {α : Type*} [BEq α] [LawfulBEq α] + (xs : List α) (nodup : xs.Nodup) (complete : ∀ a, a ∈ xs) (a : α) : + (listEquiv xs nodup complete a).val = xs.idxOf a := rfl + +@[simp] theorem listEquiv_symm_apply {α : Type*} [BEq α] [LawfulBEq α] + (xs : List α) (nodup : xs.Nodup) (complete : ∀ a, a ∈ xs) + (i : Fin xs.length) : (listEquiv xs nodup complete).symm i = xs.get i := rfl + +def cloudDarts (t : Table) (v : Fin t.vertices) : List (Fin t.darts) := + (List.finRange t.darts).filter (fun e => decide (t.rows[e].tail = v)) + +@[simp] theorem mem_cloudDarts (t : Table) (v : Fin t.vertices) (e : Fin t.darts) : + e ∈ cloudDarts t v ↔ t.rows[e].tail = v := by + simp [cloudDarts] + +theorem cloudDarts_nodup (t : Table) (v : Fin t.vertices) : + (cloudDarts t v).Nodup := + List.Nodup.filter _ (List.nodup_finRange t.darts) + +theorem cloudDarts_sublist (t : Table) (v : Fin t.vertices) : + (cloudDarts t v).Sublist (List.finRange t.darts) := List.filter_sublist + +def cloudSize (t : Table) (v : Fin t.vertices) : Nat := (cloudDarts t v).length + +theorem cloudSize_le_darts (t : Table) (v : Fin t.vertices) : + cloudSize t v ≤ t.darts := by + simpa only [cloudSize, List.length_finRange] using (cloudDarts_sublist t v).length_le + +def cloudSelect (t : Table) (v : Fin t.vertices) (i : Fin (cloudSize t v)) : + Cloud (semantics t) v := + ⟨(cloudDarts t v).get i, + (mem_cloudDarts t v _).1 (List.get_mem (cloudDarts t v) i)⟩ + +def cloudRank (t : Table) (v : Fin t.vertices) (e : Cloud (semantics t) v) : + Fin (cloudSize t v) := + ⟨(cloudDarts t v).idxOf e.val, + List.idxOf_lt_length_of_mem ((mem_cloudDarts t v e.val).2 e.property)⟩ + +@[simp] theorem cloudSelect_val (t : Table) (v : Fin t.vertices) + (i : Fin (cloudSize t v)) : + (cloudSelect t v i).val = (cloudDarts t v).get i := rfl + +@[simp] theorem cloudRank_val (t : Table) (v : Fin t.vertices) + (e : Cloud (semantics t) v) : + (cloudRank t v e).val = (cloudDarts t v).idxOf e.val := rfl + +@[simp] theorem cloudSelect_cloudRank (t : Table) (v : Fin t.vertices) + (e : Cloud (semantics t) v) : cloudSelect t v (cloudRank t v e) = e := by + apply Subtype.ext + exact List.idxOf_get (cloudRank t v e).isLt + +@[simp] theorem cloudRank_cloudSelect (t : Table) (v : Fin t.vertices) + (i : Fin (cloudSize t v)) : cloudRank t v (cloudSelect t v i) = i := by + apply Fin.ext + exact List.get_idxOf (cloudDarts_nodup t v) i + +def cloudEquiv (t : Table) (v : Fin t.vertices) : + Cloud (semantics t) v ≃ Fin (cloudSize t v) where + toFun := cloudRank t v + invFun := cloudSelect t v + left_inv := cloudSelect_cloudRank t v + right_inv := cloudRank_cloudSelect t v + +theorem cloudSize_eq_card_cloud (t : Table) (v : Fin t.vertices) : + cloudSize t v = Fintype.card (Cloud (semantics t) v) := by + simpa only [Fintype.card_fin] using (Fintype.card_congr (cloudEquiv t v)).symm + +theorem cloudDarts_eq_nil_iff (t : Table) (v : Fin t.vertices) : + cloudDarts t v = [] ↔ ∀ e : Fin t.darts, t.rows[e].tail ≠ v := by + simp only [List.eq_nil_iff_forall_not_mem, mem_cloudDarts] + +theorem cloudSize_eq_zero_iff (t : Table) (v : Fin t.vertices) : + cloudSize t v = 0 ↔ ∀ e : Fin t.darts, t.rows[e].tail ≠ v := by + rw [cloudSize, List.length_eq_zero_iff, cloudDarts_eq_nil_iff] + +theorem sum_cloudSize (t : Table) : (∑ v, cloudSize t v) = t.darts := by + calc + _ = ∑ v, Fintype.card (Cloud (semantics t) v) := by + apply Finset.sum_congr rfl + intro v _ + exact cloudSize_eq_card_cloud t v + _ = Fintype.card (Fin t.darts) := CloudPadding.sum_card_cloud (semantics t) + _ = t.darts := Fintype.card_fin t.darts + +def oldCloudIndex (t : Table) (e : Fin t.darts) : + Fin (cloudSize t t.rows[e].tail) := cloudRank t t.rows[e].tail ⟨e, rfl⟩ + +@[simp] theorem cloudSelect_oldCloudIndex (t : Table) (e : Fin t.darts) : + (cloudSelect t t.rows[e].tail (oldCloudIndex t e)).val = e := + congrArg Subtype.val (cloudSelect_cloudRank t t.rows[e].tail ⟨e, rfl⟩) + +abbrev PaddedCloud (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) := + Cloud (paddedGraph (semantics t) (fun u => Fin (padding u))) v + +def paddedOld (t : Table) (padding : Fin t.vertices → Nat) (v : Fin t.vertices) + (e : Cloud (semantics t) v) : PaddedCloud t padding v := + ⟨Sum.inl e.val, e.property⟩ + +def paddedNew (t : Table) (padding : Fin t.vertices → Nat) (v : Fin t.vertices) + (i : Fin (padding v)) : PaddedCloud t padding v := + ⟨Sum.inr ⟨v, i⟩, rfl⟩ + +def paddedCloudEquiv (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) : PaddedCloud t padding v ≃ Fin (cloudSize t v + padding v) := + (CloudPadding.paddedCloudEquiv (semantics t) (fun u => Fin (padding u)) v).trans + ((Equiv.sumCongr (cloudEquiv t v) (Equiv.refl (Fin (padding v)))).trans + finSumFinEquiv) + +def paddedCloudRank (t : Table) (padding : Fin t.vertices → Nat) (v : Fin t.vertices) : + PaddedCloud t padding v → Fin (cloudSize t v + padding v) := + paddedCloudEquiv t padding v + +def paddedCloudSelect (t : Table) (padding : Fin t.vertices → Nat) (v : Fin t.vertices) : + Fin (cloudSize t v + padding v) → PaddedCloud t padding v := + (paddedCloudEquiv t padding v).symm + +@[simp] theorem paddedCloudSelect_rank (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (e : PaddedCloud t padding v) : + paddedCloudSelect t padding v (paddedCloudRank t padding v e) = e := + (paddedCloudEquiv t padding v).symm_apply_apply e + +@[simp] theorem paddedCloudRank_select (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v)) : + paddedCloudRank t padding v (paddedCloudSelect t padding v i) = i := + (paddedCloudEquiv t padding v).apply_symm_apply i + +@[simp] theorem paddedCloudRank_old (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (e : Cloud (semantics t) v) : + paddedCloudRank t padding v (paddedOld t padding v e) = + Fin.castAdd (padding v) (cloudRank t v e) := rfl + +@[simp] theorem paddedCloudRank_new (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (padding v)) : + paddedCloudRank t padding v (paddedNew t padding v i) = + Fin.natAdd (cloudSize t v) i := rfl + +@[simp] theorem paddedCloudRank_old_val (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (e : Cloud (semantics t) v) : + (paddedCloudRank t padding v (paddedOld t padding v e)).val = + (cloudRank t v e).val := rfl + +@[simp] theorem paddedCloudRank_new_val (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (padding v)) : + (paddedCloudRank t padding v (paddedNew t padding v i)).val = + cloudSize t v + i.val := rfl + +@[simp] theorem paddedCloudSelect_castAdd (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (cloudSize t v)) : + paddedCloudSelect t padding v (Fin.castAdd (padding v) i) = + paddedOld t padding v (cloudSelect t v i) := by + apply (paddedCloudEquiv t padding v).injective + change (paddedCloudEquiv t padding v) + ((paddedCloudEquiv t padding v).symm (Fin.castAdd (padding v) i)) = _ + rw [Equiv.apply_symm_apply] + change Fin.castAdd (padding v) i = + Fin.castAdd (padding v) (cloudRank t v (cloudSelect t v i)) + rw [cloudRank_cloudSelect] + +@[simp] theorem paddedCloudSelect_natAdd (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (padding v)) : + paddedCloudSelect t padding v (Fin.natAdd (cloudSize t v) i) = + paddedNew t padding v i := + (paddedCloudEquiv t padding v).symm_apply_apply (paddedNew t padding v i) + +theorem card_paddedCloud (t : Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) : + Fintype.card (PaddedCloud t padding v) = cloudSize t v + padding v := by + simpa only [Fintype.card_fin] using Fintype.card_congr (paddedCloudEquiv t padding v) + +end IndependentSetsGames.Foundations.PCP.PreprocessingCloudIndex + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/GraphRounding.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/GraphRounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea163fc77c98f05960dbc99fb6c545728c7b3dbc --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/GraphRounding.lean @@ -0,0 +1,185 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.DegreeReplacement +import OAI.Combinatorics.IndependentSets.Expansion.CloudRounding + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.CloudRounding +open scoped BigOperators +section GraphRounding + +open DegreeReplacement PoweringWalks + +variable {V E A D : Type*} [Fintype V] [Fintype E] [Fintype A] [Fintype D] +variable [DecidableEq V] [DecidableEq E] [DecidableEq A] + +def mismatchSet (G : ConstraintGraph V E A) (ell : E → A) (rounded : V → A) : + Finset E := + Finset.univ.filter (fun e => ell e ≠ rounded (G.tail e)) + +def copiedRejectionCount (G : ConstraintGraph V E A) (ell : E → A) : Nat := + (Finset.univ.filter (fun e => G.accepts e (ell e) (ell (G.reverse e)) = false)).card + +def innerDisagreementSet (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) (ell : E → A) : Finset (E × D) := + Finset.univ.filter (fun ed => ell ed.1 ≠ ell (innerRotation G H ed).1) + +noncomputable def roundLabels [Nonempty A] + (G : ConstraintGraph V E A) (ell : E → A) : V → A := + fun v => majority (fun e : Cloud G v => ell e.val) + +def mismatchFiberEquiv (G : ConstraintGraph V E A) (ell : E → A) + (rounded : V → A) : + (Σ v, ↥(minoritySet (fun e : Cloud G v => ell e.val) (rounded v))) ≃ + ↥(mismatchSet G ell rounded) where + toFun := by + rintro ⟨v, ⟨⟨e, he⟩, hbad⟩⟩ + cases he + exact ⟨e, by simpa [mismatchSet, minoritySet] using hbad⟩ + invFun e := + ⟨G.tail e.val, ⟨⟨e.val, rfl⟩, by + simpa [mismatchSet, minoritySet] using e.property⟩⟩ + left_inv := by + rintro ⟨v, ⟨⟨e, he⟩, hbad⟩⟩ + cases he + rfl + right_inv := by intro e; apply Subtype.ext; rfl + +omit [Fintype A] [DecidableEq E] in +theorem mismatch_card_eq_sum (G : ConstraintGraph V E A) (ell : E → A) + (rounded : V → A) : + (mismatchSet G ell rounded).card = + ∑ v, (minoritySet (fun e : Cloud G v => ell e.val) (rounded v)).card := by + have h := Fintype.card_congr (mismatchFiberEquiv G ell rounded) + simpa only [Fintype.card_sigma, Fintype.card_coe] using h.symm + +def disagreementFiberEquiv (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) (ell : E → A) : + (Σ v, ↥(disagreementSet (fun e : Cloud G v => ell e.val) + (fun ed => ((H v).rot ed).1))) ≃ ↥(innerDisagreementSet G H ell) where + toFun := by + rintro ⟨v, ⟨⟨⟨e, he⟩, d⟩, hbad⟩⟩ + cases he + refine ⟨(e, d), ?_⟩ + simpa [disagreementSet, innerDisagreementSet, innerRotation, + cloudIndexEquiv, cloudRotation] using hbad + invFun := by + rintro ⟨⟨e, d⟩, hbad⟩ + refine ⟨G.tail e, ⟨(⟨e, rfl⟩, d), ?_⟩⟩ + simpa [disagreementSet, innerDisagreementSet, innerRotation, + cloudIndexEquiv, cloudRotation] using hbad + left_inv := by + rintro ⟨v, ⟨⟨⟨e, he⟩, d⟩, hbad⟩⟩ + cases he + rfl + right_inv := by intro ed; apply Subtype.ext; rfl + +omit [Fintype A] [DecidableEq E] in +theorem disagreement_card_eq_sum (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) (ell : E → A) : + (innerDisagreementSet G H ell).card = + ∑ v, (disagreementSet (fun e : Cloud G v => ell e.val) + (fun ed => ((H v).rot ed).1)).card := by + have h := Fintype.card_congr (disagreementFiberEquiv G H ell) + simpa only [Fintype.card_sigma, Fintype.card_coe] using h.symm + +theorem rounded_mismatch_expansion [Nonempty A] + (G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D) + (ell : E → A) (h : ℚ) + (expansion : ∀ v (S : Finset (Cloud G v)), + S.card ≤ Fintype.card (Cloud G v) / 2 → + h * (S.card : ℚ) ≤ ((directedCut (fun ed => ((H v).rot ed).1) S).card : ℚ)) : + h * ((mismatchSet G ell (roundLabels G ell)).card : ℚ) ≤ + ((innerDisagreementSet G H ell).card : ℚ) := by + rw [mismatch_card_eq_sum, disagreement_card_eq_sum, Nat.cast_sum, Nat.cast_sum, + Finset.mul_sum] + apply Finset.sum_le_sum + intro v _ + exact minority_expansion_bound (fun e : Cloud G v => ell e.val) + (fun ed => ((H v).rot ed).1) (roundLabels G ell v) h + (majority_maximal (fun e : Cloud G v => ell e.val)) (expansion v) + +omit [Fintype V] [Fintype A] [DecidableEq V] [DecidableEq E] in +theorem rounded_endpoint_bound (G : ConstraintGraph V E A) + (ell : E → A) (rounded : V → A) : + G.rejectionCount rounded ≤ copiedRejectionCount G ell + + 2 * (mismatchSet G ell rounded).card := + dart_rejection_count_le G.tail G.reverse G.accepts ell rounded + +omit [Fintype V] [Fintype E] [Fintype A] [Fintype D] [DecidableEq V] [DecidableEq E] in +@[simp] theorem copied_satisfied_inl (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) (ell : E → A) (e : E) (d : D) : + (replacementGraph G H).edgeSatisfied ell (e, Sum.inl d) = + decide (ell e = ell (innerRotation G H (e, d)).1) := rfl + +omit [Fintype V] [Fintype E] [Fintype A] [Fintype D] [DecidableEq V] [DecidableEq E] in +@[simp] theorem copied_satisfied_inr (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) (ell : E → A) (e : E) (u : Unit) : + (replacementGraph G H).edgeSatisfied ell (e, Sum.inr u) = + G.accepts e (ell e) (ell (G.reverse e)) := rfl + +omit [Fintype V] [Fintype A] [DecidableEq V] [DecidableEq E] in +theorem replacement_rejection_split (G : ConstraintGraph V E A) + (H : ∀ v, PortGraph (Cloud G v) D) (ell : E → A) : + (replacementGraph G H).rejectionCount ell = + copiedRejectionCount G ell + (innerDisagreementSet G H ell).card := by + classical + simp only [rejectionCount_eq_sum, Fintype.sum_prod_type, Fintype.sum_sum_type, + copied_satisfied_inl, copied_satisfied_inr, decide_eq_false_iff_not, + Fintype.sum_unique, Finset.sum_add_distrib] + simp only [copiedRejectionCount, innerDisagreementSet, Finset.card_eq_sum_ones, + Finset.sum_filter, Fintype.sum_prod_type] + exact Nat.add_comm _ _ + +theorem replacement_soundness [Nonempty A] + (G : ConstraintGraph V E A) (H : ∀ v, PortGraph (Cloud G v) D) + (expansion : ∀ v (S : Finset (Cloud G v)), + S.card ≤ Fintype.card (Cloud G v) / 2 → + 2 * S.card ≤ (directedCut (fun ed => ((H v).rot ed).1) S).card) + (ell : E → A) : + G.rejectionCount (roundLabels G ell) ≤ (replacementGraph G H).rejectionCount ell := by + have hc := rounded_mismatch_expansion G H ell 2 (by + intro v S hS + exact_mod_cast expansion v S hS) + have hcNat : 2 * (mismatchSet G ell (roundLabels G ell)).card ≤ + (innerDisagreementSet G H ell).card := by exact_mod_cast hc + rw [replacement_rejection_split] + exact (rounded_endpoint_bound G ell (roundLabels G ell)).trans + (Nat.add_le_add_left hcNat _) + +theorem padded_replacement_soundness [Nonempty A] + (G : ConstraintGraph V E A) (dummy : V → Type*) [∀ v, Fintype (dummy v)] + [∀ v, DecidableEq (dummy v)] + (H : ∀ v, PortGraph (Cloud (paddedGraph G dummy) v) D) + (expansion : ∀ v (S : Finset (Cloud (paddedGraph G dummy) v)), + S.card ≤ Fintype.card (Cloud (paddedGraph G dummy) v) / 2 → + 2 * S.card ≤ (directedCut (fun ed => ((H v).rot ed).1) S).card) + (ell : PaddedDart G dummy → A) : + G.rejectionCount (roundLabels (paddedGraph G dummy) ell) ≤ + (paddedReplacementGraph G dummy H).rejectionCount ell := by + simpa only [paddedReplacementGraph, padded_rejectionCount] using + replacement_soundness (paddedGraph G dummy) H expansion ell + +end GraphRounding + +theorem combine_counts (R b M c : Nat) (h : ℚ) (hh : 0 < h) + (endpoint : R ≤ b + 2 * M) (cloud : h * (M : ℚ) ≤ (c : ℚ)) : + (R : ℚ) ≤ max 1 (2 / h) * ((b : ℚ) + (c : ℚ)) := by + let K : ℚ := max 1 (2 / h) + have hK : 1 ≤ K := le_max_left _ _ + have hK0 : 0 ≤ K := le_trans zero_le_one hK + have hcoef : 2 ≤ K * h := (div_le_iff₀ hh).mp (le_max_right _ _) + have hm : (2 : ℚ) * M ≤ K * c := by + calc + (2 : ℚ) * M ≤ (K * h) * M := + mul_le_mul_of_nonneg_right hcoef (Nat.cast_nonneg M) + _ = K * (h * M) := mul_assoc _ _ _ + _ ≤ K * c := mul_le_mul_of_nonneg_left cloud hK0 + have hb : (b : ℚ) ≤ K * b := by + simpa only [one_mul] using mul_le_mul_of_nonneg_right hK (Nat.cast_nonneg b) + have hr : (R : ℚ) ≤ (b : ℚ) + 2 * (M : ℚ) := by exact_mod_cast endpoint + exact hr.trans ((add_le_add hb hm).trans_eq (mul_add K (b : ℚ) (c : ℚ)).symm) + +end IndependentSetsGames.Foundations.PCP.CloudRounding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Indicators.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Indicators.lean new file mode 100644 index 0000000000000000000000000000000000000000..efc201ec5c6336c46d4b097cf3e6aa841cd9c831 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Indicators.lean @@ -0,0 +1,155 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.SpectralReturn + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.PCP.SpectralCut + +open scoped BigOperators +open PoweringWalks SpectralReturn + +section Indicators +variable {V : Type*} [Fintype V] [DecidableEq V] + +def indicator (S : Finset V) (v : V) : ℝ := if v ∈ S then 1 else 0 + +theorem mean_indicator (S : Finset V) : + mean (indicator S) = (S.card : ℝ) / (Fintype.card V : ℝ) := by + have hf : Finset.univ.filter (fun v : V => v ∈ S) = S := by + ext v + simp + rw [mean_eq_sum_div_card] + simp only [indicator, Finset.sum_boole, hf] + +theorem energy_indicator (S : Finset V) : energy (indicator S) = mean (indicator S) := by + unfold energy + congr 1 + funext v + unfold indicator + split_ifs <;> norm_num + +omit [Fintype V] in +theorem indicator_nonnegative (S : Finset V) (v : V) : 0 ≤ indicator S v := by + unfold indicator + split_ifs <;> norm_num +end Indicators + +variable {V D : Type*} [Fintype V] [Fintype D] [DecidableEq V] + +def cut (G : PortGraph V D) (S : Finset V) : Finset (V × D) := + Finset.univ.filter (fun e => e.1 ∈ S ∧ (G.rot e).1 ∉ S) + +section Nonempty +variable [Nonempty V] [Nonempty D] (G : PortGraph V D) + +omit [Nonempty V] in +theorem cut_density_eq (S : Finset V) : + ((cut G S).card : ℝ) / (Fintype.card (V × D) : ℝ) = + mean (indicator S) - correlation (indicator S) (averagingOperator G (indicator S)) := by + classical + calc + _ = mean (indicator (cut G S)) := (mean_indicator (cut G S)).symm + _ = mean (fun e : V × D => indicator S e.1 - + indicator S e.1 * indicator S (G.rot e).1) := by + congr 1 + funext e + by_cases hv : e.1 ∈ S <;> by_cases hw : (G.rot e).1 ∈ S <;> + simp [indicator, cut, hv, hw] + _ = mean (fun v => mean (fun d : D => indicator S v - + indicator S v * indicator S (G.rot (v,d)).1)) := mean_prod _ + _ = mean (fun v => indicator S v - + indicator S v * averagingOperator G (indicator S) v) := by + congr 1 + funext v + rw [mean_sub, mean_const, mean_mul_left] + rfl + _ = _ := mean_sub _ _ + +theorem cut_density_ge_variance + (certificate : SpectralCertificate G (1/2)) (S : Finset V) : + (1/2:ℝ) * mean (indicator S) * (1 - mean (indicator S)) ≤ + ((cut G S).card : ℝ) / (Fintype.card (V × D) : ℝ) := by + let f := indicator S + have hz : mean (fun v => f v - mean f) = 0 := by + rw [mean_sub, mean_const, sub_self] + have he : energy (fun v => f v - mean f) = mean f - mean f ^ 2 := by + rw [energy_sub_const, energy_indicator] + ring + have hb := zero_mean_correlation_bound G (1/2) certificate + (fun v => f v - mean f) hz 1 + have hc := correlation_centered G f 1 + simp only [iterateOperator, pow_one, he] at hb hc + rw [cut_density_eq] + change (1/2:ℝ) * mean f * (1 - mean f) ≤ + mean f - correlation f (averagingOperator G f) + nlinarith + +theorem cut_density_ge_quarter + (certificate : SpectralCertificate G (1/2)) (S : Finset V) + (hsmall : 2 * S.card ≤ Fintype.card V) : + mean (indicator S) / 4 ≤ + ((cut G S).card : ℝ) / (Fintype.card (V × D) : ℝ) := by + have hN : (0:ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos + have hp0 : 0 ≤ mean (indicator S) := mean_nonnegative _ (indicator_nonnegative S) + have hp : mean (indicator S) ≤ (1/2:ℝ) := by + rw [mean_indicator] + apply (div_le_iff₀ hN).mpr + have hs : (2:ℝ) * (S.card : ℝ) ≤ (Fintype.card V : ℝ) := by exact_mod_cast hsmall + nlinarith + have hv := cut_density_ge_variance G certificate S + have hprod := mul_nonneg hp0 (sub_nonneg.mpr hp) + nlinarith + +theorem cut_card_ge_quarter_degree + (certificate : SpectralCertificate G (1/2)) (S : Finset V) + (hsmall : 2 * S.card ≤ Fintype.card V) : + (Fintype.card D : ℝ) * (S.card : ℝ) / 4 ≤ ((cut G S).card : ℝ) := by + have hN : (0:ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos + have hD : (0:ℝ) < Fintype.card D := by exact_mod_cast Fintype.card_pos + have h := cut_density_ge_quarter G certificate S hsmall + rw [Fintype.card_prod, Nat.cast_mul] at h + have hh := (le_div_iff₀ (mul_pos hN hD)).mp h + have he : mean (indicator S) / 4 * + ((Fintype.card V : ℝ) * (Fintype.card D : ℝ)) = + (Fintype.card D : ℝ) * (S.card : ℝ) / 4 := by + rw [mean_indicator] + field_simp [ne_of_gt hN] + rw [he] at hh + exact hh + +theorem degree_mul_card_le_four_cut + (certificate : SpectralCertificate G (1/2)) (S : Finset V) + (hsmall : 2 * S.card ≤ Fintype.card V) : + Fintype.card D * S.card ≤ 4 * (cut G S).card := by + have h := cut_card_ge_quarter_degree G certificate S hsmall + have hr : (Fintype.card D : ℝ) * (S.card : ℝ) ≤ 4 * ((cut G S).card : ℝ) := by + linarith + exact_mod_cast hr + +theorem cut_card_ge_quarter_degree_of_card_le_half + (certificate : SpectralCertificate G (1/2)) (S : Finset V) + (hsmall : S.card ≤ Fintype.card V / 2) : + (Fintype.card D : ℝ) * (S.card : ℝ) / 4 ≤ ((cut G S).card : ℝ) := + cut_card_ge_quarter_degree G certificate S (by omega) +end Nonempty + +theorem cut_card_ge_twice (G : PortGraph V D) + (certificate : SpectralCertificate G (1/2)) (hdegree : 8 ≤ Fintype.card D) + (S : Finset V) (hsmall : 2 * S.card ≤ Fintype.card V) : + 2 * S.card ≤ (cut G S).card := by + let : Nonempty D := Fintype.card_pos_iff.mp (by omega) + rcases isEmpty_or_nonempty V with hV | hV + · let := hV + have hzero : Fintype.card V = 0 := Fintype.card_eq_zero + have hs : S.card = 0 := by omega + simp only [hs, mul_zero, Nat.zero_le] + · let := hV + have h := degree_mul_card_le_four_cut G certificate S hsmall + have hdeg := Nat.mul_le_mul_right S.card hdegree + omega + +end IndependentSetsGames.Foundations.PCP.SpectralCut +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/LazySmoothing.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/LazySmoothing.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9e27187026a2785e6232fb9f8912b3bdb256010 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/LazySmoothing.lean @@ -0,0 +1,272 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Bits + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.LazySmoothing + +open scoped BigOperators + +def bitCount {n : ℕ} (tape : Fin n → Bool) : ℕ := + ∑ i, if tape i then 1 else 0 + +noncomputable def binomialMean (n : ℕ) (g : ℕ → ℝ) : ℝ := + Finset.univ.expect (fun tape : Fin n → Bool => g (bitCount tape)) + +def splitTape (n : ℕ) : (Fin (n + 1) → Bool) ≃ (Bool × (Fin n → Bool)) where + toFun x := (x 0, fun i => x i.succ) + invFun x := Fin.cases x.1 x.2 + left_inv x := by + funext i + exact Fin.cases rfl (fun _ => rfl) i + right_inv _ := rfl + +theorem bitCount_succ {n : ℕ} (x : Fin (n + 1) → Bool) : + bitCount x = (if x 0 then 1 else 0) + bitCount (fun i => x i.succ) := by + exact Fin.sum_univ_succ _ + +theorem mean_congr {n : ℕ} {f g : ℕ → ℝ} (h : ∀ k, f k = g k) : + binomialMean n f = binomialMean n g := by + unfold binomialMean + exact Finset.expect_congr rfl (fun x _ => h (bitCount x)) + +@[simp] theorem mean_const (n : ℕ) (c : ℝ) : + binomialMean n (fun _ => c) = c := Fintype.expect_const c + +theorem mean_add (n : ℕ) (f g : ℕ → ℝ) : + binomialMean n (fun k => f k + g k) = binomialMean n f + binomialMean n g := + Finset.expect_add_distrib _ _ _ + +theorem mean_sub (n : ℕ) (f g : ℕ → ℝ) : + binomialMean n (fun k => f k - g k) = binomialMean n f - binomialMean n g := + Finset.expect_sub_distrib _ _ _ + +theorem mean_mul (n : ℕ) (c : ℝ) (f : ℕ → ℝ) : + binomialMean n (fun k => c * f k) = c * binomialMean n f := by + exact (Finset.mul_expect Finset.univ (fun x : Fin n → Bool => f (bitCount x)) c).symm + +@[simp] theorem mean_zero (g : ℕ → ℝ) : binomialMean 0 g = g 0 := by + simp [binomialMean, bitCount] + +theorem expect_bool (f : Bool → ℝ) : Finset.univ.expect f = (f false + f true) / 2 := by + rw [Finset.expect_eq_sum_div_card] + simp [Fintype.univ_bool, add_comm] + +theorem mean_succ (n : ℕ) (g : ℕ → ℝ) : + binomialMean (n + 1) g = + (binomialMean n g + binomialMean n (fun k => g (k + 1))) / 2 := by + unfold binomialMean + rw [Fintype.expect_equiv (splitTape n) + (fun x => g (bitCount x)) + (fun x => g ((if x.1 then 1 else 0) + bitCount x.2)) + (fun x => congrArg g (bitCount_succ x))] + rw [← Finset.univ_product_univ, Finset.expect_product, expect_bool] + simp [Nat.add_comm] + +def score (n k : ℕ) : ℝ := (n : ℝ) - 2 * (k : ℝ) + +noncomputable def scoreMean (n : ℕ) (g : ℕ → ℝ) : ℝ := + binomialMean n (fun k => score n k * g k) + +@[simp] theorem scoreMean_zero (g : ℕ → ℝ) : scoreMean 0 g = 0 := by + simp [scoreMean, score] + +theorem scoreMean_succ (n : ℕ) (g : ℕ → ℝ) : + scoreMean (n + 1) g = + ((scoreMean n g + binomialMean n g) + + (scoreMean n (fun k => g (k + 1)) - + binomialMean n (fun k => g (k + 1)))) / 2 := by + unfold scoreMean + rw [mean_succ] + have h₁ : (fun k => score (n + 1) k * g k) = + (fun k => score n k * g k + g k) := by + funext k + simp only [score, Nat.cast_add, Nat.cast_one] + ring + have h₂ : (fun k => score (n + 1) (k + 1) * g (k + 1)) = + (fun k => score n k * g (k + 1) - g (k + 1)) := by + funext k + simp only [score, Nat.cast_add, Nat.cast_one] + ring + rw [h₁, h₂, mean_add, mean_sub] + +theorem score_identity (n : ℕ) (g : ℕ → ℝ) : + scoreMean (n + 1) g = ((n : ℝ) + 1) / 2 * + (binomialMean n g - binomialMean n (fun k => g (k + 1))) := by + induction n generalizing g with + | zero => simp [scoreMean_succ]; ring + | succ n ih => + rw [scoreMean_succ, ih g, ih (fun k => g (k + 1))] + simp only [mean_succ, Nat.cast_add, Nat.cast_one] + ring + +theorem score_mean_zero (n : ℕ) : binomialMean n (score n) = 0 := by + cases n with + | zero => simp [score] + | succ n => + have h := score_identity n (fun _ => 1) + simpa [scoreMean] using h + +theorem score_second_moment (n : ℕ) : + binomialMean n (fun k => score n k ^ 2) = (n : ℝ) := by + cases n with + | zero => simp [score] + | succ n => + have h := score_identity n (score (n + 1)) + have hd : binomialMean n (score (n + 1)) - + binomialMean n (fun k => score (n + 1) (k + 1)) = 2 := by + rw [← mean_sub] + calc + _ = binomialMean n (fun _ => 2) := by + apply mean_congr + intro k + simp only [score, Nat.cast_add, Nat.cast_one] + ring + _ = 2 := mean_const _ _ + rw [hd] at h + simpa [scoreMean, pow_two] using h + +theorem score_difference (n : ℕ) (g : ℕ → ℝ) : + scoreMean (n + 1) g = ((n : ℝ) + 1) * + (binomialMean n g - binomialMean (n + 1) g) := by + rw [score_identity, mean_succ] + ring + +theorem adjacent_difference_sq (n : ℕ) (g : ℕ → ℝ) + (hg : ∀ k, 0 ≤ g k ∧ g k ≤ 1) : + 4 * ((n : ℝ) + 1) * + (binomialMean n g - binomialMean (n + 1) g) ^ 2 ≤ 1 := by + have hc : binomialMean (n + 1) + (fun k => score (n + 1) k * (g k - 1 / 2)) = scoreMean (n + 1) g := by + calc + _ = binomialMean (n + 1) (fun k => + score (n + 1) k * g k - (1 / 2) * score (n + 1) k) := by + apply mean_congr + intro k + ring + _ = scoreMean (n + 1) g := by + rw [mean_sub, mean_mul, score_mean_zero] + simp [scoreMean] + have hv : binomialMean (n + 1) (fun k => (g k - 1 / 2) ^ 2) ≤ 1 / 4 := by + apply Finset.expect_le Finset.univ_nonempty + intro tape _ + have h₀ := (hg (bitCount tape)).1 + have h₁ := (hg (bitCount tape)).2 + have hp := mul_nonneg h₀ (sub_nonneg.mpr h₁) + nlinarith + have hcs : (binomialMean (n + 1) + (fun k => score (n + 1) k * (g k - 1 / 2))) ^ 2 ≤ + binomialMean (n + 1) (fun k => score (n + 1) k ^ 2) * + binomialMean (n + 1) (fun k => (g k - 1 / 2) ^ 2) := + Finset.expect_mul_sq_le_sq_mul_sq Finset.univ _ _ + rw [hc, score_difference, score_second_moment] at hcs + have hn : 0 < (n : ℝ) + 1 := by positivity + have hm := mul_le_mul_of_nonneg_left hv (le_of_lt hn) + simp only [Nat.cast_add, Nat.cast_one] at hcs + apply (mul_le_mul_iff_left₀ hn).mp + nlinarith + +theorem adjacent_difference_le (n : ℕ) (g : ℕ → ℝ) + (hg : ∀ k, 0 ≤ g k ∧ g k ≤ 1) (r : ℝ) (hr : 0 < r) + (hrn : r ^ 2 ≤ 4 * ((n : ℝ) + 1)) : + |binomialMean n g - binomialMean (n + 1) g| ≤ 1 / r := by + have hs := adjacent_difference_sq n g hg + have hd := sq_nonneg (binomialMean n g - binomialMean (n + 1) g) + have hh := mul_le_mul_of_nonneg_right hrn hd + rw [le_div_iff₀ hr] + have ha := sq_abs (binomialMean n g - binomialMean (n + 1) g) + have hp : 0 ≤ |binomialMean n g - binomialMean (n + 1) g| * r := + mul_nonneg (abs_nonneg _) (le_of_lt hr) + nlinarith [sq_nonneg (|binomialMean n g - binomialMean (n + 1) g| * r - 1)] + +theorem mean_shift_le (n d : ℕ) (g : ℕ → ℝ) + (hg : ∀ k, 0 ≤ g k ∧ g k ≤ 1) (r : ℝ) (hr : 0 < r) + (hrn : r ^ 2 ≤ 4 * ((n : ℝ) + 1)) : + |binomialMean (n + d) g - binomialMean n g| ≤ (d : ℝ) / r := by + induction d with + | zero => simp + | succ d ih => + have hrnd : r ^ 2 ≤ 4 * ((n + d : ℕ) + 1 : ℝ) := by + push_cast + have : (0 : ℝ) ≤ d := Nat.cast_nonneg _ + linarith + have ha := adjacent_difference_le (n + d) g hg r hr hrnd + rw [abs_sub_comm] at ha + calc + _ ≤ |binomialMean (n + d + 1) g - binomialMean (n + d) g| + + |binomialMean (n + d) g - binomialMean n g| := abs_sub_le _ _ _ + _ ≤ 1 / r + (d : ℝ) / r := add_le_add ha ih + _ = ((d + 1 : ℕ) : ℝ) / r := by push_cast; ring + +theorem mean_ordered_difference_le (m n : ℕ) (hmn : m ≤ n) (g : ℕ → ℝ) + (hg : ∀ k, 0 ≤ g k ∧ g k ≤ 1) (r : ℝ) (hr : 0 < r) + (hrm : r ^ 2 ≤ 4 * ((m : ℝ) + 1)) : + |binomialMean n g - binomialMean m g| ≤ ((n - m : ℕ) : ℝ) / r := by + simpa [Nat.add_sub_of_le hmn] using mean_shift_le m (n - m) g hg r hr hrm + +theorem mean_window_le (N M m : ℕ) (hlo : N - M ≤ m) (hhi : m ≤ N + M) + (g : ℕ → ℝ) (hg : ∀ k, 0 ≤ g k ∧ g k ≤ 1) + (r : ℝ) (hr : 0 < r) (hbase : r ^ 2 ≤ 4 * (((N - M : ℕ) : ℝ) + 1)) : + |binomialMean m g - binomialMean N g| ≤ (M : ℝ) / r := by + by_cases hmN : m ≤ N + · have hrm : r ^ 2 ≤ 4 * ((m : ℝ) + 1) := by + have : ((N - M : ℕ) : ℝ) ≤ (m : ℝ) := by exact_mod_cast hlo + linarith + have h := mean_ordered_difference_le m N hmN g hg r hr hrm + rw [abs_sub_comm] at h + refine h.trans (div_le_div_of_nonneg_right ?_ (le_of_lt hr)) + have : N - m ≤ M := by omega + exact_mod_cast this + · have hNm : N ≤ m := Nat.le_of_lt (Nat.lt_of_not_ge hmN) + have hrN : r ^ 2 ≤ 4 * ((N : ℝ) + 1) := by + have : ((N - M : ℕ) : ℝ) ≤ (N : ℝ) := by exact_mod_cast Nat.sub_le N M + linarith + have h := mean_ordered_difference_le N m hNm g hg r hr hrN + refine h.trans (div_le_div_of_nonneg_right ?_ (le_of_lt hr)) + have : m - N ≤ M := by omega + exact_mod_cast this + +theorem square_window_le (q M m : ℕ) (hq : 1 ≤ q) (hM : 1 ≤ M) + (hlo : (4 * q * M) ^ 2 - M ≤ m) (hhi : m ≤ (4 * q * M) ^ 2 + M) + (g : ℕ → ℝ) (hg : ∀ k, 0 ≤ g k ∧ g k ≤ 1) : + |binomialMean m g - binomialMean ((4 * q * M) ^ 2) g| ≤ 1 / (4 * (q : ℝ)) := by + have hqR : (1 : ℝ) ≤ q := by exact_mod_cast hq + have hMR : (1 : ℝ) ≤ M := by exact_mod_cast hM + have hR : (4 : ℝ) * M ≤ ((4 * q * M : ℕ) : ℝ) := by + push_cast + nlinarith + have hRM : (M : ℝ) ≤ (((4 * q * M : ℕ) : ℝ)) ^ 2 := by nlinarith + have hMN : M ≤ (4 * q * M) ^ 2 := by exact_mod_cast hRM + have hr : (0 : ℝ) < ((4 * q * M : ℕ) : ℝ) := by linarith + have hb : (((4 * q * M : ℕ) : ℝ)) ^ 2 ≤ + 4 * (((((4 * q * M) ^ 2 - M : ℕ)) : ℝ) + 1) := by + rw [Nat.cast_sub hMN, Nat.cast_pow] + nlinarith + have h := mean_window_le ((4 * q * M) ^ 2) M m hlo hhi g hg + ((4 * q * M : ℕ) : ℝ) hr hb + have he : (M : ℝ) / ((4 * q * M : ℕ) : ℝ) = 1 / (4 * (q : ℝ)) := by + push_cast + have hq0 : (q : ℝ) ≠ 0 := by linarith + have hM0 : (M : ℝ) ≠ 0 := by linarith + field_simp + rw [he] at h + exact h + +theorem modal_transfer (q M m : ℕ) (hq : 1 ≤ q) (hM : 1 ≤ M) + (hlo : (4 * q * M) ^ 2 - M ≤ m) (hhi : m ≤ (4 * q * M) ^ 2 + M) + (g : ℕ → ℝ) (hg : ∀ k, 0 ≤ g k ∧ g k ≤ 1) + (hmodal : 1 / (q : ℝ) ≤ binomialMean ((4 * q * M) ^ 2) g) : + 1 / (2 * (q : ℝ)) ≤ binomialMean m g := by + have h := square_window_le q M m hq hM hlo hhi g hg + have hqR : (0 : ℝ) < q := by exact_mod_cast (Nat.zero_lt_of_lt hq) + have hrec : 0 < 1 / (q : ℝ) := one_div_pos.mpr hqR + have he₁ : 1 / (4 * (q : ℝ)) = (1 / (q : ℝ)) / 4 := by ring + have he₂ : 1 / (2 * (q : ℝ)) = (1 / (q : ℝ)) / 2 := by ring + rw [he₁] at h + rw [he₂] + have hl := (abs_le.mp h).1 + linarith + +end IndependentSetsGames.Foundations.PCP.LazySmoothing + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/LazySpectral.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/LazySpectral.lean new file mode 100644 index 0000000000000000000000000000000000000000..61d1c6b9c2886d7b306164482d145266aaf03f1e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/LazySpectral.lean @@ -0,0 +1,273 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.VertexPadding +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLazy +import OAI.Combinatorics.IndependentSets.Expansion.Regularization + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.LazySpectral + +open PoweringWalks SpectralReturn + +variable {V D : Type*} + +theorem half_sum_sq_le (a b : ℝ) : ((a + b) / 2) ^ 2 ≤ (a ^ 2 + b ^ 2) / 2 := by + nlinarith [sq_nonneg (a - b)] + +theorem lazy_energy_le_average [Fintype V] [Fintype D] [Nonempty D] + (G : PortGraph V D) (f : V → ℝ) : + energy (averagingOperator (lazyGraph G) f) ≤ + (energy f + energy (averagingOperator G f)) / 2 := by + calc + energy (averagingOperator (lazyGraph G) f) = + mean (fun v => ((f v + averagingOperator G f v) / 2) ^ 2) := by + unfold energy + congr 1 + funext v + rw [PoweringLazy.averagingOperator_lazy] + _ ≤ mean (fun v => (f v ^ 2 + averagingOperator G f v ^ 2) / 2) := + mean_mono (fun v => half_sum_sq_le _ _) + _ = mean (fun v => (1 / 2 : ℝ) * (f v ^ 2 + averagingOperator G f v ^ 2)) := by + congr 1 + funext v + ring + _ = (1 / 2 : ℝ) * (energy f + energy (averagingOperator G f)) := by + rw [mean_mul_left, mean_add] + rfl + _ = (energy f + energy (averagingOperator G f)) / 2 := by ring + +theorem lazy_energy_bound [Fintype V] [Fintype D] [Nonempty D] + (G : PortGraph V D) (lambda : ℝ) (hG : SpectralCertificate G lambda) + (f : V → ℝ) (hf : mean f = 0) : + energy (averagingOperator (lazyGraph G) f) ≤ + ((1 + lambda ^ 2) / 2) * energy f := by + calc + energy (averagingOperator (lazyGraph G) f) ≤ + (energy f + energy (averagingOperator G f)) / 2 := lazy_energy_le_average G f + _ ≤ (energy f + lambda ^ 2 * energy f) / 2 := by + have h := hG.contraction f hf + linarith + _ = ((1 + lambda ^ 2) / 2) * energy f := by ring + +theorem lazy_certificate_31_32 [Fintype V] [Fintype D] [Nonempty D] + (G : PortGraph V D) (hG : SpectralCertificate G (7 / 8)) : + SpectralCertificate (lazyGraph G) (31 / 32) where + nonnegative := by norm_num + lt_one := by norm_num + contraction f hf := by + have h := lazy_energy_bound G (7 / 8) hG f hf + have hcoef : ((1 + (7 / 8 : ℝ) ^ 2) / 2) ≤ (31 / 32 : ℝ) ^ 2 := by norm_num + exact h.trans (mul_le_mul_of_nonneg_right hcoef (energy_nonnegative f)) + +end IndependentSetsGames.Foundations.PCP.LazySpectral + +namespace IndependentSetsGames.Foundations.PCP.Preprocessing + +open PoweringWalks SpectralReturn + +variable {V E A : Type*} [Fintype V] [Fintype E] [Fintype A] + [DecidableEq V] [DecidableEq E] [DecidableEq A] [Nonempty E] [Nonempty A] + +abbrev Vertex (G : ConstraintGraph V E A) := VertexPadding.Vertex (Regularization.Vertex G) +abbrev OverlayPort := Regularization.Port ⊕ ExpanderFamily.Port +abbrev Port := Bool × OverlayPort + +def degree : Nat := 2 * (2 * Expanders.baseDegree ^ 2 + 1) +def sizeFactor : Nat := ExpanderFamily.growth ^ 2 * degree + +private theorem card_lazy_sum {X Y : Type*} [Fintype X] [Fintype Y] + (a b : Nat) (hX : Fintype.card X = a) (hY : Fintype.card Y = b) : + Fintype.card (Bool × (X ⊕ Y)) = 2 * (a + b) := by + rw [Fintype.card_prod, Fintype.card_bool, Fintype.card_sum, hX, hY] + +private theorem doubled_add (a : Nat) : 2 * (2 * a + 1) = 2 * ((a + 1) + a) := by omega + +theorem degree_eq_card : degree = Fintype.card Port := by + have hr : Fintype.card Regularization.Port = Expanders.baseDegree ^ 2 + 1 := + Regularization.degree_eq.trans + (congrArg (fun n : Nat => n + 1) ExpanderFamily.card_port) + have hp : Fintype.card Port = + 2 * ((Expanders.baseDegree ^ 2 + 1) + Expanders.baseDegree ^ 2) := + card_lazy_sum _ _ hr ExpanderFamily.card_port + exact (doubled_add _).trans hp.symm + +theorem degree_positive : 0 < degree := by + unfold degree + omega + +theorem sizeFactor_positive : 0 < sizeFactor := by + have hg : 0 < ExpanderFamily.growth := + Nat.zero_lt_one.trans ExpanderFamily.growth_gt_one + exact Nat.mul_pos (Nat.pow_pos hg) degree_positive + +def paddedGraph (G : ConstraintGraph V E A) : + ConstraintGraph (Vertex G) (Vertex G × Regularization.Port) A := + VertexPadding.paddedG (Regularization.graph G) + +def overlayExpander (G : ConstraintGraph V E A) : + PortGraph (Vertex G) ExpanderFamily.Port := + GraphTransport.reindex + (ExpanderFamily.family (ExpanderFamily.level (Fintype.card (Regularization.Vertex G)))) + (VertexPadding.familyVertexEquiv (Regularization.Vertex G)).symm (Equiv.refl _) + +omit [Fintype A] [DecidableEq E] [DecidableEq A] [Nonempty E] [Nonempty A] in +theorem overlayExpander_certificate (G : ConstraintGraph V E A) : + SpectralCertificate (overlayExpander G) (1 / 2 : ℝ) := + GraphTransport.reindex_spectralCertificate _ _ _ _ (ExpanderFamily.family_certificate _) + +def overlayGraph (G : ConstraintGraph V E A) : + ConstraintGraph (Vertex G) (Vertex G × OverlayPort) A := + Overlay.constraintGraph (paddedGraph G) (overlayExpander G) + +def graph (G : ConstraintGraph V E A) : + ConstraintGraph (Vertex G) (Vertex G × Port) A := + LazyConstraint.constraintGraph (overlayGraph G) + +def portGraph (G : ConstraintGraph V E A) : PortGraph (Vertex G) Port := + Overlay.originalPortGraph (graph G) + +omit [Fintype A] [DecidableEq E] [Nonempty E] [Nonempty A] in +@[simp] theorem graph_tail (G : ConstraintGraph V E A) : (graph G).tail = Prod.fst := rfl + +omit [Fintype A] [DecidableEq E] [Nonempty E] [Nonempty A] in +@[simp] theorem graph_reverse (G : ConstraintGraph V E A) : + (graph G).reverse = (portGraph G).rot := rfl + +omit [Fintype A] [DecidableEq E] [Nonempty E] [Nonempty A] in +theorem accepts_reverse (G : ConstraintGraph V E A) (e : Vertex G × Port) (a b : A) : + (graph G).accepts ((portGraph G).rot e) b a = (graph G).accepts e a b := + (graph G).reverse_accepts e a b + +omit [Fintype A] [DecidableEq E] [Nonempty E] [Nonempty A] in +theorem portGraph_eq_lazyGraph (G : ConstraintGraph V E A) : + portGraph G = lazyGraph (Overlay.originalPortGraph (overlayGraph G)) := rfl + +omit [Fintype A] [DecidableEq E] [Nonempty A] in +theorem overlayGraph_certificate (G : ConstraintGraph V E A) : + SpectralCertificate (Overlay.originalPortGraph (overlayGraph G)) (7 / 8 : ℝ) := by + apply Overlay.constraintGraph_spectralCertificate + · exact Regularization.degree_eq + · have h := ExpanderFamily.port_degree_ge_eight + omega + · exact overlayExpander_certificate G + +omit [Fintype A] [DecidableEq E] [Nonempty A] in +theorem spectral_certificate (G : ConstraintGraph V E A) : + SpectralCertificate (portGraph G) (31 / 32 : ℝ) := by + rw [portGraph_eq_lazyGraph] + exact LazySpectral.lazy_certificate_31_32 _ (overlayGraph_certificate G) + +omit [Fintype A] [DecidableEq E] [DecidableEq A] [Nonempty A] in +theorem vertex_count_le (G : ConstraintGraph V E A) : + Fintype.card (Vertex G) ≤ ExpanderFamily.growth ^ 2 * Fintype.card E := by + calc + _ ≤ ExpanderFamily.growth * Fintype.card (Regularization.Vertex G) := + VertexPadding.card_vertex_le _ + _ ≤ ExpanderFamily.growth * (ExpanderFamily.growth * Fintype.card E) := + Nat.mul_le_mul_left _ (Regularization.vertex_count_le G) + _ = _ := by ring + +omit [Fintype A] [DecidableEq E] [DecidableEq A] [Nonempty E] [Nonempty A] in +theorem dart_count (G : ConstraintGraph V E A) : + Fintype.card (Vertex G × Port) = Fintype.card (Vertex G) * degree := by + rw [Fintype.card_prod, ← degree_eq_card] + +omit [Fintype A] [DecidableEq E] [DecidableEq A] [Nonempty A] in +theorem dart_count_le (G : ConstraintGraph V E A) : + Fintype.card (Vertex G × Port) ≤ sizeFactor * Fintype.card E := by + rw [dart_count] + calc + _ ≤ (ExpanderFamily.growth ^ 2 * Fintype.card E) * degree := + Nat.mul_le_mul_right degree (vertex_count_le G) + _ = _ := Nat.mul_right_comm _ _ _ + +def liftLabel (G : ConstraintGraph V E A) (labeling : V → A) : Vertex G → A := + VertexPadding.liftLabel (Classical.choice ‹Nonempty A›) (Regularization.liftLabel G labeling) + +omit [Fintype A] [DecidableEq E] [Nonempty E] in +theorem lift_rejectionCount (G : ConstraintGraph V E A) (labeling : V → A) : + (graph G).rejectionCount (liftLabel G labeling) = G.rejectionCount labeling := by + unfold graph + rw [LazyConstraint.rejectionCount_eq _ rfl] + unfold overlayGraph + rw [Overlay.rejectionCount_eq _ _ rfl] + unfold paddedGraph liftLabel + rw [VertexPadding.rejectionCount_liftLabel _ rfl] + exact Regularization.lift_rejectionCount G labeling + +omit [Fintype A] [DecidableEq E] [Nonempty E] in +theorem completeness (G : ConstraintGraph V E A) (hG : G.Satisfiable) : + (graph G).Satisfiable := by + apply (LazyConstraint.satisfiable_iff _ rfl).mpr + apply (Overlay.satisfiable_iff _ _ rfl).mpr + exact VertexPadding.paddedG_satisfiable (Regularization.graph G) rfl + (Classical.choice ‹Nonempty A›) (Regularization.completeness G hG) + +def roundLabels (G : ConstraintGraph V E A) (labeling : Vertex G → A) : V → A := + Regularization.roundLabels G (fun v => labeling (Sum.inl v)) + +omit [Nonempty E] in +theorem soundness (G : ConstraintGraph V E A) (labeling : Vertex G → A) : + G.rejectionCount (roundLabels G labeling) ≤ (graph G).rejectionCount labeling := by + calc + _ ≤ (Regularization.graph G).rejectionCount (fun v => labeling (Sum.inl v)) := + Regularization.soundness G _ + _ = (paddedGraph G).rejectionCount labeling := + (VertexPadding.paddedG_rejectionCount (Regularization.graph G) rfl labeling).symm + _ = (overlayGraph G).rejectionCount labeling := + (Overlay.rejectionCount_eq (paddedGraph G) (overlayExpander G) rfl labeling).symm + _ = (graph G).rejectionCount labeling := + (LazyConstraint.rejectionCount_eq (overlayGraph G) rfl labeling).symm + +omit [Nonempty E] in +theorem satisfiable_iff (G : ConstraintGraph V E A) : + (graph G).Satisfiable ↔ G.Satisfiable := by + constructor + · rintro ⟨labeling, hlabel⟩ + by_contra hG + have hpositive := G.rejectionCount_positive hG (roundLabels G labeling) + have hzero : (graph G).rejectionCount labeling = 0 := by + simp [ConstraintGraph.rejectionCount, ConstraintGraph.rejectedDarts, hlabel] + have hsound := soundness G labeling + omega + · exact completeness G + +theorem gap_transfer (G : ConstraintGraph V E A) (epsilon : ℚ) (he : 0 ≤ epsilon) + (lower : ∀ labeling : V → A, + epsilon * Fintype.card E ≤ (G.rejectionCount labeling : ℚ)) + (labeling : Vertex G → A) : + (epsilon / sizeFactor) * Fintype.card (Vertex G × Port) ≤ + ((graph G).rejectionCount labeling : ℚ) := by + have hfactor : (0 : ℚ) < sizeFactor := by exact_mod_cast sizeFactor_positive + have hcard : (Fintype.card (Vertex G × Port) : ℚ) ≤ + sizeFactor * Fintype.card E := by exact_mod_cast dart_count_le G + calc + _ ≤ (epsilon / sizeFactor) * (sizeFactor * Fintype.card E) := + mul_le_mul_of_nonneg_left hcard (div_nonneg he hfactor.le) + _ = epsilon * Fintype.card E := by field_simp + _ ≤ (G.rejectionCount (roundLabels G labeling) : ℚ) := lower _ + _ ≤ ((graph G).rejectionCount labeling : ℚ) := by exact_mod_cast soundness G labeling + +theorem gap_transfer_real (G : ConstraintGraph V E A) (epsilon : ℝ) (he : 0 ≤ epsilon) + (lower : ∀ labeling : V → A, + epsilon * Fintype.card E ≤ (G.rejectionCount labeling : ℝ)) + (labeling : Vertex G → A) : + (epsilon / sizeFactor) * Fintype.card (Vertex G × Port) ≤ + ((graph G).rejectionCount labeling : ℝ) := by + have hfactor : (0 : ℝ) < sizeFactor := by exact_mod_cast sizeFactor_positive + have hcard : (Fintype.card (Vertex G × Port) : ℝ) ≤ + sizeFactor * Fintype.card E := by exact_mod_cast dart_count_le G + calc + _ ≤ (epsilon / sizeFactor) * (sizeFactor * Fintype.card E) := + mul_le_mul_of_nonneg_left hcard (div_nonneg he hfactor.le) + _ = epsilon * Fintype.card E := by field_simp + _ ≤ (G.rejectionCount (roundLabels G labeling) : ℝ) := lower _ + _ ≤ ((graph G).rejectionCount labeling : ℝ) := by exact_mod_cast soundness G labeling + +end IndependentSetsGames.Foundations.PCP.Preprocessing + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Overlay.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Overlay.lean new file mode 100644 index 0000000000000000000000000000000000000000..618b3dac4eb170cab997a70124953ea42f8a7c4a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Overlay.lean @@ -0,0 +1,241 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.DegreeReplacement +import OAI.Combinatorics.IndependentSets.Expansion.ZigzagSpectral + +namespace OAI + +open scoped BigOperators + +namespace IndependentSetsGames.Foundations.PCP.Overlay + +open PoweringWalks SpectralReturn + +variable {V D E A : Type*} + +def originalPortGraph (G : ConstraintGraph V (V × D) A) : PortGraph V D where + rot := G.reverse + rot_involutive := G.reverse_involutive + +def rotate (G : PortGraph V D) (H : PortGraph V E) : + V × (D ⊕ E) → V × (D ⊕ E) + | (v, Sum.inl d) => ((G.rot (v, d)).1, Sum.inl (G.rot (v, d)).2) + | (v, Sum.inr e) => ((H.rot (v, e)).1, Sum.inr (H.rot (v, e)).2) + +theorem rotate_involutive (G : PortGraph V D) (H : PortGraph V E) : + Function.Involutive (rotate G H) := by + rintro ⟨v, p⟩ + rcases p with d | e + · exact congrArg (fun a : V × D => (a.1, (Sum.inl a.2 : D ⊕ E))) + (G.rot_involutive (v, d)) + · exact congrArg (fun a : V × E => (a.1, (Sum.inr a.2 : D ⊕ E))) + (H.rot_involutive (v, e)) + +def portGraph (G : PortGraph V D) (H : PortGraph V E) : PortGraph V (D ⊕ E) where + rot := + { toFun := rotate G H + invFun := rotate G H + left_inv := rotate_involutive G H + right_inv := rotate_involutive G H } + rot_involutive := rotate_involutive G H + +@[simp] theorem portGraph_rot_inl (G : PortGraph V D) (H : PortGraph V E) + (v : V) (d : D) : + (portGraph G H).rot (v, Sum.inl d) = + ((G.rot (v, d)).1, Sum.inl (G.rot (v, d)).2) := rfl + +@[simp] theorem portGraph_rot_inr (G : PortGraph V D) (H : PortGraph V E) + (v : V) (e : E) : + (portGraph G H).rot (v, Sum.inr e) = + ((H.rot (v, e)).1, Sum.inr (H.rot (v, e)).2) := rfl + +def constraintGraph (G : ConstraintGraph V (V × D) A) (H : PortGraph V E) : + ConstraintGraph V (V × (D ⊕ E)) A where + reverse := (portGraph (originalPortGraph G) H).rot + reverse_involutive := (portGraph (originalPortGraph G) H).rot_involutive + tail := Prod.fst + accepts p a b := match p.2 with + | Sum.inl d => G.accepts (p.1, d) a b + | Sum.inr _ => true + reverse_accepts := by + rintro ⟨v, p⟩ a b + rcases p with d | e + · exact G.reverse_accepts (v, d) a b + · rfl + +@[simp] theorem constraintGraph_tail (G : ConstraintGraph V (V × D) A) + (H : PortGraph V E) : (constraintGraph G H).tail = Prod.fst := rfl + +@[simp] theorem constraintGraph_portGraph (G : ConstraintGraph V (V × D) A) + (H : PortGraph V E) : + originalPortGraph (constraintGraph G H) = portGraph (originalPortGraph G) H := rfl + +@[simp] theorem edgeSatisfied_inl (G : ConstraintGraph V (V × D) A) + (H : PortGraph V E) (htail : G.tail = Prod.fst) + (labeling : V → A) (v : V) (d : D) : + (constraintGraph G H).edgeSatisfied labeling (v, Sum.inl d) = + G.edgeSatisfied labeling (v, d) := by + change G.accepts (v, d) (labeling v) (labeling (G.reverse (v, d)).1) = + G.accepts (v, d) (labeling (G.tail (v, d))) + (labeling (G.tail (G.reverse (v, d)))) + rw [htail] + +@[simp] theorem edgeSatisfied_inr (G : ConstraintGraph V (V × D) A) + (H : PortGraph V E) (labeling : V → A) (v : V) (e : E) : + (constraintGraph G H).edgeSatisfied labeling (v, Sum.inr e) = true := rfl + +theorem complete (G : ConstraintGraph V (V × D) A) (H : PortGraph V E) + (htail : G.tail = Prod.fst) (labeling : V → A) + (h : ∀ a, G.edgeSatisfied labeling a = true) : + ∀ a, (constraintGraph G H).edgeSatisfied labeling a = true := by + rintro ⟨v, p⟩ + rcases p with d | e + · rw [edgeSatisfied_inl G H htail] + exact h (v, d) + · rfl + +theorem satisfiable_iff (G : ConstraintGraph V (V × D) A) (H : PortGraph V E) + (htail : G.tail = Prod.fst) : + (constraintGraph G H).Satisfiable ↔ G.Satisfiable := by + constructor + · rintro ⟨labeling, h⟩ + refine ⟨labeling, ?_⟩ + rintro ⟨v, d⟩ + rw [← edgeSatisfied_inl G H htail] + exact h (v, Sum.inl d) + · rintro ⟨labeling, h⟩ + exact ⟨labeling, complete G H htail labeling h⟩ + +theorem rejectionCount_eq [Fintype V] [Fintype D] [Fintype E] + (G : ConstraintGraph V (V × D) A) (H : PortGraph V E) + (htail : G.tail = Prod.fst) (labeling : V → A) : + (constraintGraph G H).rejectionCount labeling = G.rejectionCount labeling := by + classical + simp only [DegreeReplacement.rejectionCount_eq_sum, Fintype.sum_prod_type, + Fintype.sum_sum_type] + simp [edgeSatisfied_inl G H htail] + +theorem card_ports [Fintype D] [Fintype E] : + Fintype.card (D ⊕ E) = Fintype.card D + Fintype.card E := Fintype.card_sum + +theorem card_darts [Fintype V] [Fintype D] [Fintype E] : + Fintype.card (V × (D ⊕ E)) = + Fintype.card (V × D) + Fintype.card (V × E) := by + simp only [Fintype.card_prod, Fintype.card_sum, Nat.mul_add] + +variable [Fintype V] [Fintype D] [Fintype E] + +omit [Fintype V] in + +theorem operator_mix [Nonempty D] [Nonempty E] + (G : PortGraph V D) (H : PortGraph V E) (f : V → ℝ) (v : V) : + averagingOperator (portGraph G H) f v = + (Fintype.card D : ℝ) / ((Fintype.card D : ℝ) + Fintype.card E) * + averagingOperator G f v + + (Fintype.card E : ℝ) / ((Fintype.card D : ℝ) + Fintype.card E) * + averagingOperator H f v := by + have hd : (0 : ℝ) < Fintype.card D := by + exact_mod_cast (Fintype.card_pos : 0 < Fintype.card D) + have he : (0 : ℝ) < Fintype.card E := by + exact_mod_cast (Fintype.card_pos : 0 < Fintype.card E) + change mean (fun p : D ⊕ E => f ((portGraph G H).rot (v, p)).1) = _ + rw [mean_eq_sum_div_card] + simp only [Fintype.sum_sum_type, Fintype.card_sum, Nat.cast_add, + portGraph_rot_inl, portGraph_rot_inr] + unfold averagingOperator + rw [Fintype.expect_eq_sum_div_card, Fintype.expect_eq_sum_div_card] + field_simp [hd.ne', he.ne', (add_pos hd he).ne'] + +theorem energy_convex_mix (a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) + (f g : V → ℝ) : + energy (fun v => a * f v + b * g v) ≤ a * energy f + b * energy g := by + calc + energy (fun v => a * f v + b * g v) ≤ + mean (fun v => a * (f v) ^ 2 + b * (g v) ^ 2) := by + apply mean_mono + intro v + have hnormalize := congrArg (fun t : ℝ => t * (a * (f v) ^ 2 + b * (g v) ^ 2)) hab + have hnonneg := mul_nonneg (mul_nonneg ha hb) (sq_nonneg (f v - g v)) + nlinarith + _ = a * energy f + b * energy g := by + rw [mean_add, mean_mul_left, mean_mul_left] + rfl + +theorem energy_bound [Nonempty V] [Nonempty D] [Nonempty E] + (G : PortGraph V D) (H : PortGraph V E) (lambda : ℝ) + (certificate : SpectralCertificate H lambda) (f : V → ℝ) (hf : mean f = 0) : + energy (averagingOperator (portGraph G H) f) ≤ + ((Fintype.card D : ℝ) + (Fintype.card E : ℝ) * lambda ^ 2) / + ((Fintype.card D : ℝ) + Fintype.card E) * energy f := by + let a : ℝ := (Fintype.card D : ℝ) / ((Fintype.card D : ℝ) + Fintype.card E) + let b : ℝ := (Fintype.card E : ℝ) / ((Fintype.card D : ℝ) + Fintype.card E) + have hd : (0 : ℝ) < Fintype.card D := by + exact_mod_cast (Fintype.card_pos : 0 < Fintype.card D) + have he : (0 : ℝ) < Fintype.card E := by + exact_mod_cast (Fintype.card_pos : 0 < Fintype.card E) + have hden : (0 : ℝ) < (Fintype.card D : ℝ) + Fintype.card E := add_pos hd he + have ha : 0 ≤ a := div_nonneg hd.le hden.le + have hb : 0 ≤ b := div_nonneg he.le hden.le + have hab : a + b = 1 := by + dsimp [a, b] + rw [← add_div, div_self hden.ne'] + have hop : averagingOperator (portGraph G H) f = + fun v => a * averagingOperator G f v + b * averagingOperator H f v := by + funext v + exact operator_mix G H f v + calc + energy (averagingOperator (portGraph G H) f) ≤ + a * energy (averagingOperator G f) + b * energy (averagingOperator H f) := by + rw [hop] + exact energy_convex_mix a b ha hb hab _ _ + _ ≤ a * energy f + b * (lambda ^ 2 * energy f) := + add_le_add + (mul_le_mul_of_nonneg_left (ZigzagSpectral.averaging_energy_le G f) ha) + (mul_le_mul_of_nonneg_left (certificate.contraction f hf) hb) + _ = _ := by + dsimp [a, b] + ring + +theorem energy_bound_three_quarters [Nonempty V] + (G : PortGraph V D) (H : PortGraph V E) + (hdegree : Fintype.card D = Fintype.card E + 1) (hpositive : 1 ≤ Fintype.card E) + (certificate : SpectralCertificate H (1 / 2 : ℝ)) + (f : V → ℝ) (hf : mean f = 0) : + energy (averagingOperator (portGraph G H) f) ≤ (3 / 4 : ℝ) * energy f := by + let _ : Nonempty E := Fintype.card_pos_iff.mp (lt_of_lt_of_le Nat.zero_lt_one hpositive) + let _ : Nonempty D := Fintype.card_pos_iff.mp (by omega) + have he : (1 : ℝ) ≤ Fintype.card E := by exact_mod_cast hpositive + have hd : (Fintype.card D : ℝ) = (Fintype.card E : ℝ) + 1 := by exact_mod_cast hdegree + have hden : (0 : ℝ) < (Fintype.card D : ℝ) + Fintype.card E := by linarith + have hcoefficient : + ((Fintype.card D : ℝ) + (Fintype.card E : ℝ) * (1 / 2 : ℝ) ^ 2) / + ((Fintype.card D : ℝ) + Fintype.card E) ≤ (3 / 4 : ℝ) := by + apply (div_le_iff₀ hden).mpr + nlinarith + exact (energy_bound G H (1 / 2) certificate f hf).trans + (mul_le_mul_of_nonneg_right hcoefficient (energy_nonnegative f)) + +theorem spectralCertificate_seven_eighths [Nonempty V] + (G : PortGraph V D) (H : PortGraph V E) + (hdegree : Fintype.card D = Fintype.card E + 1) (hpositive : 1 ≤ Fintype.card E) + (certificate : SpectralCertificate H (1 / 2 : ℝ)) : + SpectralCertificate (portGraph G H) (7 / 8 : ℝ) where + nonnegative := by norm_num + lt_one := by norm_num + contraction := by + intro f hf + exact (energy_bound_three_quarters G H hdegree hpositive certificate f hf).trans + (mul_le_mul_of_nonneg_right (by norm_num : (3 / 4 : ℝ) ≤ (7 / 8 : ℝ) ^ 2) + (energy_nonnegative f)) + +theorem constraintGraph_spectralCertificate [Nonempty V] + (G : ConstraintGraph V (V × D) A) (H : PortGraph V E) + (hdegree : Fintype.card D = Fintype.card E + 1) (hpositive : 1 ≤ Fintype.card E) + (certificate : SpectralCertificate H (1 / 2 : ℝ)) : + SpectralCertificate (originalPortGraph (constraintGraph G H)) (7 / 8 : ℝ) := by + rw [constraintGraph_portGraph] + exact spectralCertificate_seven_eighths (originalPortGraph G) H + hdegree hpositive certificate + +end IndependentSetsGames.Foundations.PCP.Overlay + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PortTableLookup.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PortTableLookup.lean new file mode 100644 index 0000000000000000000000000000000000000000..5111bcd08b1b8b599fbdd2f2b6bf741a8f36f311 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PortTableLookup.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PortTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PortTableLookup + +private theorem flatMap_word {α β : Type*} (f : α → List β) + (width j : Nat) (hj : j < width) : + ∀ (rows : List α), (∀ a ∈ rows, (f a).length = width) → + ∀ (i : Nat) (row : α), rows[i]? = some row → + (rows.flatMap f)[width * i + j]? = (f row)[j]? := by + intro rows + induction rows with + | nil => + intro _ i row selected + simp at selected + | cons a rows ih => + intro hwidth i row selected + have ha : (f a).length = width := hwidth a (by simp) + cases i with + | zero => + have heq : a = row := by simpa using selected + subst row + simp only [Nat.mul_zero, Nat.zero_add, List.flatMap_cons] + exact List.getElem?_append_left (by omega) + | succ i => + have selected' : rows[i]? = some row := by simpa using selected + have hskip : (f a).length ≤ width * (i + 1) + j := by + rw [ha, Nat.mul_add, Nat.mul_one] + omega + have hoff : width * (i + 1) + j - (f a).length = width * i + j := by + rw [ha, Nat.mul_add, Nat.mul_one] + omega + rw [List.flatMap_cons, List.getElem?_append_right hskip, hoff] + exact ih (fun b hb => hwidth b (by simp [hb])) i row selected' + +variable {n d : Nat} + +theorem vertices_word (table : PortTables.Table n d) : + (PortTables.tableWords table)[0]? = some n := rfl + +theorem darts_word (table : PortTables.Table n d) : + (PortTables.tableWords table)[1]? = some (n * d) := rfl + +private theorem row_word (table : PortTables.Table n d) (i : Fin (n * d)) + (j : Nat) (hj : j < 4098) : + (PortTables.tableWords table)[2 + 4098 * i.val + j]? = + (GraphTables.rowWords (PortTables.flatRows table)[i])[j]? := by + rw [PortTables.tableWords_eq] + change (n :: n * d :: (PortTables.flatRows table).toList.flatMap + GraphTables.rowWords)[2 + 4098 * i.val + j]? = _ + rw [show 2 + 4098 * i.val + j = (4098 * i.val + j + 1) + 1 by omega, + List.getElem?_cons_succ, List.getElem?_cons_succ] + apply flatMap_word GraphTables.rowWords 4098 j hj + (PortTables.flatRows table).toList + (fun row _ => GraphTables.rowWords_length row) i.val + ((PortTables.flatRows table)[i]) + simp only [Vector.getElem?_toList, Vector.getElem?_eq_getElem i.isLt, + Fin.getElem_fin] + +theorem tail_word (table : PortTables.Table n d) (i : Fin (n * d)) : + (PortTables.tableWords table)[2 + 4098 * i.val]? = + some (((PortTables.rowIndex n d).symm i).1.val) := by + have h := row_word table i 0 (by decide) + simpa only [Nat.add_zero, GraphTables.rowWords, PortTables.flatRows, + Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, List.cons_append, + List.nil_append, List.getElem?_cons_zero] using h + +theorem reverse_word (table : PortTables.Table n d) (i : Fin (n * d)) : + (PortTables.tableWords table)[3 + 4098 * i.val]? = + some (table.reverseIndex[i].val) := by + have h := row_word table i 1 (by decide) + rw [show 2 + 4098 * i.val + 1 = 3 + 4098 * i.val by omega] at h + simpa only [GraphTables.rowWords, PortTables.flatRows, Fin.getElem_fin, + Vector.getElem_ofFn, Fin.eta, List.cons_append, List.nil_append, + List.getElem?_cons_succ, List.getElem?_cons_zero] using h + +theorem relation_word (table : PortTables.Table n d) (i : Fin (n * d)) + (j : Fin 4096) : + (PortTables.tableWords table)[4 + 4098 * i.val + j.val]? = + some (GraphTables.bitWord table.relations[i][j]) := by + have h := row_word table i (j.val + 2) (by omega) + rw [show 2 + 4098 * i.val + (j.val + 2) = 4 + 4098 * i.val + j.val by omega] at h + simpa only [GraphTables.rowWords, GraphTables.relationWords, + PortTables.flatRows, Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, + List.cons_append, List.nil_append, List.getElem?_cons_succ, + List.getElem?_map, Vector.getElem?_toList, + Vector.getElem?_eq_getElem j.isLt, Option.map_some] using h + +theorem accepts_word (table : PortTables.Table n d) (e : Fin n × Fin d) + (a b : PortTables.Label) : + (PortTables.tableWords table)[4 + 4098 * (PortTables.rowIndex n d e).val + + (GraphTables.relationIndex (a, b)).val]? = + some (GraphTables.bitWord (PortTables.accepts table e a b)) := + relation_word table (PortTables.rowIndex n d e) (GraphTables.relationIndex (a, b)) + +theorem rotation_head_word (table : PortTables.Table n d) (e : Fin n × Fin d) : + (PortTables.tableWords table)[2 + 4098 * (table.reverseIndex[PortTables.rowIndex n d e]).val]? = + some ((PortTables.rotation table e).1.val) := + tail_word table (table.reverseIndex[PortTables.rowIndex n d e]) + +theorem rotor_lookups (table : PortTables.Table n d) (e : Fin n × Fin d) : + (PortTables.tableWords table)[3 + 4098 * (PortTables.rowIndex n d e).val]? = + some (table.reverseIndex[PortTables.rowIndex n d e].val) ∧ + (PortTables.tableWords table)[2 + 4098 * (table.reverseIndex[PortTables.rowIndex n d e]).val]? = + some ((PortTables.rotation table e).1.val) := + ⟨reverse_word table (PortTables.rowIndex n d e), rotation_head_word table e⟩ + +end IndependentSetsGames.Foundations.PCP.PortTableLookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PortTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PortTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..0777d4a1602eb8fabe5e548009507e54b2f155b3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PortTables.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GraphTables +import OAI.Combinatorics.IndependentSets.Expansion.PoweringWalks + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PortTables + +open PoweringWalks + +abbrev Label := GraphTables.Label + +def rowIndex (vertices ports : Nat) : + Fin vertices × Fin ports ≃ Fin (vertices * ports) := finProdFinEquiv + +@[simp] theorem rowIndex_val (n d : Nat) (e : Fin n × Fin d) : + (rowIndex n d e).val = e.2.val + d * e.1.val := rfl + +structure Table (vertices ports : Nat) where + reverseIndex : Vector (Fin (vertices * ports)) (vertices * ports) + relations : Vector GraphTables.RelationTable (vertices * ports) + involutive : Function.Involutive + (fun i : Fin (vertices * ports) => reverseIndex[i]) + transpose : ∀ (i : Fin (vertices * ports)) (a b : Label), + GraphTables.relationAt relations[reverseIndex[i]] b a = + GraphTables.relationAt relations[i] a b + +variable {n d : Nat} + +def rotation (table : Table n d) (e : Fin n × Fin d) : Fin n × Fin d := + (rowIndex n d).symm table.reverseIndex[rowIndex n d e] + +def accepts (table : Table n d) (e : Fin n × Fin d) (a b : Label) : Bool := + GraphTables.relationAt table.relations[rowIndex n d e] a b + +@[simp] theorem rowIndex_rotation (table : Table n d) (e : Fin n × Fin d) : + rowIndex n d (rotation table e) = table.reverseIndex[rowIndex n d e] := by + exact (rowIndex n d).apply_symm_apply _ + +theorem rotation_involutive (table : Table n d) : Function.Involutive (rotation table) := by + intro e + simp only [rotation, Equiv.apply_symm_apply] + exact (congrArg (rowIndex n d).symm (table.involutive (rowIndex n d e))).trans + ((rowIndex n d).symm_apply_apply e) + +theorem accepts_rotation (table : Table n d) (e : Fin n × Fin d) (a b : Label) : + accepts table (rotation table e) b a = accepts table e a b := by + simpa only [accepts, rowIndex_rotation] using table.transpose (rowIndex n d e) a b + +def portGraph (table : Table n d) : PortGraph (Fin n) (Fin d) where + rot := + { toFun := rotation table + invFun := rotation table + left_inv := rotation_involutive table + right_inv := rotation_involutive table } + rot_involutive := rotation_involutive table + +@[simp] theorem portGraph_rot (table : Table n d) (e : Fin n × Fin d) : + (portGraph table).rot e = rotation table e := rfl + +def baseGraph (table : Table n d) : ConstraintGraph (Fin n) (Fin n × Fin d) Label where + reverse := (portGraph table).rot + reverse_involutive := rotation_involutive table + tail := Prod.fst + accepts := accepts table + reverse_accepts := accepts_rotation table + +@[simp] theorem baseGraph_reverse (table : Table n d) (e : Fin n × Fin d) : + (baseGraph table).reverse e = rotation table e := rfl + +@[simp] theorem baseGraph_tail (table : Table n d) (e : Fin n × Fin d) : + (baseGraph table).tail e = e.1 := rfl + +@[simp] theorem baseGraph_head (table : Table n d) (e : Fin n × Fin d) : + (baseGraph table).head e = (rotation table e).1 := rfl + +@[simp] theorem baseGraph_accepts (table : Table n d) (e : Fin n × Fin d) (a b : Label) : + (baseGraph table).accepts e a b = accepts table e a b := rfl + +def ofPortGraph (G : PortGraph (Fin n) (Fin d)) + (predicate : (Fin n × Fin d) → Label → Label → Bool) + (htranspose : ∀ e a b, predicate (G.rot e) b a = predicate e a b) : Table n d where + reverseIndex := Vector.ofFn (fun i => rowIndex n d (G.rot ((rowIndex n d).symm i))) + relations := Vector.ofFn (fun i => GraphTables.relationOf (predicate ((rowIndex n d).symm i))) + involutive := by + intro i + simp only [Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, + Equiv.symm_apply_apply] + exact (congrArg (rowIndex n d) (G.rot_involutive ((rowIndex n d).symm i))).trans + ((rowIndex n d).apply_symm_apply i) + transpose := by + intro i a b + simp only [Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, + Equiv.symm_apply_apply, GraphTables.relationAt_relationOf] + exact htranspose ((rowIndex n d).symm i) a b + +@[simp] theorem rotation_ofPortGraph (G : PortGraph (Fin n) (Fin d)) + (predicate : (Fin n × Fin d) → Label → Label → Bool) + (htranspose : ∀ e a b, predicate (G.rot e) b a = predicate e a b) + (e : Fin n × Fin d) : rotation (ofPortGraph G predicate htranspose) e = G.rot e := by + simp only [rotation, ofPortGraph, Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, + Equiv.symm_apply_apply] + +@[simp] theorem accepts_ofPortGraph (G : PortGraph (Fin n) (Fin d)) + (predicate : (Fin n × Fin d) → Label → Label → Bool) + (htranspose : ∀ e a b, predicate (G.rot e) b a = predicate e a b) + (e : Fin n × Fin d) (a b : Label) : + accepts (ofPortGraph G predicate htranspose) e a b = predicate e a b := by + simp only [accepts, ofPortGraph, Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, + Equiv.symm_apply_apply, GraphTables.relationAt_relationOf] + +def flatRows (table : Table n d) : GraphTables.Rows n (n * d) := + Vector.ofFn (fun i => + ⟨((rowIndex n d).symm i).1, table.reverseIndex[i], table.relations[i]⟩) + +@[simp] theorem reverseAt_flatRows (table : Table n d) (i : Fin (n * d)) : + GraphTables.reverseAt (flatRows table) i = table.reverseIndex[i] := by + simp [GraphTables.reverseAt, flatRows] + +@[simp] theorem acceptsAt_flatRows (table : Table n d) (i : Fin (n * d)) (a b : Label) : + GraphTables.acceptsAt (flatRows table) i a b = GraphTables.relationAt table.relations[i] a b := by + simp [GraphTables.acceptsAt, flatRows] + +theorem flatRows_valid (table : Table n d) : GraphTables.Valid (flatRows table) := by + constructor + · intro i + simpa only [reverseAt_flatRows] using table.involutive i + · intro i a b + simpa only [reverseAt_flatRows, acceptsAt_flatRows] using table.transpose i a b + +def graphTable (table : Table n d) : GraphTables.Table := + ⟨n, n * d, flatRows table, flatRows_valid table⟩ + +def tableWords (table : Table n d) : List Nat := GraphTables.tableWords (graphTable table) + +def tableBits (table : Table n d) : List Bool := GraphTables.tableBits (graphTable table) + +abbrev Input (ports : Nat) := (vertices : Nat) × Table vertices ports + +def inputBits {ports : Nat} (input : Input ports) : List Bool := tableBits input.2 + +theorem tableWords_eq (table : Table n d) : + tableWords table = [n, n * d] ++ (flatRows table).toList.flatMap GraphTables.rowWords := rfl + +theorem tableWords_length (table : Table n d) : + (tableWords table).length = 2 + 4098 * (n * d) := + GraphTables.tableWords_length (graphTable table) + +theorem vertices_le_tableBits_length (table : Table n d) : n ≤ (tableBits table).length := + GraphTables.vertices_le_tableBits_length (graphTable table) + +end IndependentSetsGames.Foundations.PCP.PortTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringDecoding.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..3224b6aa44563d8677c92f7337966997fb62dfb1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringDecoding.lean @@ -0,0 +1,165 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringDecoding + +open scoped BigOperators + +variable {Ω A : Type*} [Fintype Ω] [Nonempty Ω] [Fintype A] [Nonempty A] + +noncomputable def mass (opinion : Ω → A) (a : A) : ℝ := by + classical + exact Finset.univ.expect (fun ω => if opinion ω = a then 1 else 0) + +omit [Nonempty A] in +theorem mass_sum (opinion : Ω → A) : (∑ a, mass opinion a) = 1 := by + classical + calc + (∑ a, mass opinion a) = + (Finset.univ : Finset Ω).expect + (fun ω => ∑ a : A, if opinion ω = a then (1 : ℝ) else 0) := + (Finset.expect_sum_comm (Finset.univ : Finset Ω) (Finset.univ : Finset A) + (fun ω a => if opinion ω = a then (1 : ℝ) else 0)).symm + _ = (Finset.univ : Finset Ω).expect (fun _ => (1 : ℝ)) := by + apply Finset.expect_congr rfl + intro ω _ + simp + _ = 1 := Finset.expect_const Finset.univ_nonempty 1 + +omit [Nonempty Ω] in +theorem exists_mode (opinion : Ω → A) : + ∃ a : A, ∀ b : A, mass opinion b ≤ mass opinion a := by + obtain ⟨a, _, ha⟩ := Finset.exists_max_image (Finset.univ : Finset A) + (mass opinion) Finset.univ_nonempty + exact ⟨a, fun b => ha b (Finset.mem_univ b)⟩ + +noncomputable def mode (opinion : Ω → A) : A := Classical.choose (exists_mode opinion) + +omit [Nonempty Ω] in +theorem mode_max (opinion : Ω → A) (b : A) : + mass opinion b ≤ mass opinion (mode opinion) := + Classical.choose_spec (exists_mode opinion) b + +theorem mode_mass_lower (opinion : Ω → A) : + 1 / (Fintype.card A : ℝ) ≤ mass opinion (mode opinion) := by + have hk : 0 < (Fintype.card A : ℝ) := Nat.cast_pos.mpr Fintype.card_pos + have hsum : (1 : ℝ) ≤ mass opinion (mode opinion) * (Fintype.card A : ℝ) := by + calc + (1 : ℝ) = ∑ a : A, mass opinion a := (mass_sum opinion).symm + _ ≤ ∑ _a : A, mass opinion (mode opinion) := + Finset.sum_le_sum (fun a _ => mode_max opinion a) + _ = mass opinion (mode opinion) * (Fintype.card A : ℝ) := by simp [mul_comm] + exact (div_le_iff₀ hk).2 hsum + +theorem exists_letter_mass_lower (opinion : Ω → A) : + ∃ a : A, 1 / (Fintype.card A : ℝ) ≤ mass opinion a := + ⟨mode opinion, mode_mass_lower opinion⟩ + +end IndependentSetsGames.Foundations.PCP.PoweringDecoding +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.PoweringMoment + +open scoped BigOperators + +def bit (p : Prop) : ℝ := by + classical + exact if p then 1 else 0 + +def hits {I Ω : Type*} [Fintype I] (E : I → Ω → Prop) (ω : Ω) : ℝ := + ∑ i, bit (E i ω) + +def mean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := Finset.univ.expect f + +theorem bit_nonneg (p : Prop) : 0 ≤ bit p := by + classical + by_cases hp : p <;> simp [bit, hp] + +theorem bit_sq (p : Prop) : bit p ^ 2 = bit p := by + classical + by_cases hp : p <;> simp [bit, hp] + +theorem bit_mul (p q : Prop) : bit p * bit q = bit (p ∧ q) := by + classical + by_cases hp : p <;> by_cases hq : q <;> simp [bit, hp, hq] + +theorem bit_mono {p q : Prop} (hpq : p → q) : bit p ≤ bit q := by + classical + by_cases hp : p + · simp [bit, hp, hpq hp] + · have hz : bit p = 0 := by simp [bit, hp] + rw [hz] + exact bit_nonneg q + +theorem hits_nonneg {I Ω : Type*} [Fintype I] (E : I → Ω → Prop) (ω : Ω) : + 0 ≤ hits E ω := Finset.sum_nonneg (fun i _ => bit_nonneg (E i ω)) + +theorem mean_nonneg {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) (hf : ∀ ω, 0 ≤ f ω) : + 0 ≤ mean f := Finset.expect_nonneg (fun ω _ => hf ω) + +theorem mean_hits {I Ω : Type*} [Fintype I] [Fintype Ω] (E : I → Ω → Prop) : + mean (hits E) = ∑ i, mean (fun ω => bit (E i ω)) := by + exact Finset.expect_sum_comm _ _ _ + +theorem second_moment_eq {I Ω : Type*} [Fintype I] [Fintype Ω] + (E : I → Ω → Prop) : + mean (fun ω => hits E ω ^ 2) = + ∑ i, ∑ j, mean (fun ω => bit (E i ω ∧ E j ω)) := by + simp only [hits, pow_two, Finset.sum_mul, Finset.mul_sum, bit_mul, + mean, Finset.expect_sum_comm] + exact Finset.sum_comm + +theorem mean_witness_sq_le {I Ω : Type*} [Fintype I] [Fintype Ω] + (E W : I → Ω → Prop) (reject : Ω → Prop) + (hWE : ∀ i ω, W i ω → E i ω) + (hWR : ∀ i ω, W i ω → reject ω) : + mean (hits W) ^ 2 ≤ + mean (fun ω => bit (reject ω)) * mean (fun ω => hits E ω ^ 2) := by + classical + have hNH (ω : Ω) : hits W ω ≤ hits E ω := + Finset.sum_le_sum (fun i _ => bit_mono (hWE i ω)) + have hzero (ω : Ω) (hr : ¬ reject ω) : hits W ω = 0 := by + apply Finset.sum_eq_zero + intro i _ + have hw : ¬ W i ω := fun h => hr (hWR i ω h) + simp [bit, hw] + have hsupport (ω : Ω) : bit (reject ω) * hits W ω = hits W ω := by + by_cases hr : reject ω + · simp [bit, hr] + · rw [hzero ω hr] + simp + have hCS := Finset.expect_mul_sq_le_sq_mul_sq Finset.univ + (fun ω => bit (reject ω)) (hits W) + have hsquares : mean (fun ω => hits W ω ^ 2) ≤ mean (fun ω => hits E ω ^ 2) := by + apply Finset.expect_le_expect + intro ω _ + simpa only [pow_two] using + (mul_le_mul (hNH ω) (hNH ω) (hits_nonneg W ω) (hits_nonneg E ω)) + calc + _ ≤ mean (fun ω => bit (reject ω)) * mean (fun ω => hits W ω ^ 2) := by + simpa only [mean, hsupport, bit_sq] using hCS + _ ≤ _ := mul_le_mul_of_nonneg_left hsquares + (mean_nonneg _ (fun ω => bit_nonneg (reject ω))) + +theorem rejection_lower_bound {I Ω : Type*} [Fintype I] [Fintype Ω] + (E W : I → Ω → Prop) (reject : Ω → Prop) + (hWE : ∀ i ω, W i ω → E i ω) + (hWR : ∀ i ω, W i ω → reject ω) + (a b : ℝ) (ha : 0 < a) (hb : 0 < b) + (hfirst : a ≤ mean (hits W)) + (hsecond : mean (fun ω => hits E ω ^ 2) ≤ b) : + a ^ 2 / b ≤ mean (fun ω => bit (reject ω)) := by + have hN : 0 ≤ mean (hits W) := mean_nonneg _ (hits_nonneg W) + have hρ : 0 ≤ mean (fun ω => bit (reject ω)) := + mean_nonneg _ (fun ω => bit_nonneg (reject ω)) + have haSq : a ^ 2 ≤ mean (hits W) ^ 2 := by + simpa only [pow_two] using mul_le_mul hfirst hfirst ha.le hN + have hCS := mean_witness_sq_le E W reject hWE hWR + apply (div_le_iff₀ hb).2 + exact haSq.trans (hCS.trans (mul_le_mul_of_nonneg_left hsecond hρ)) + +end IndependentSetsGames.Foundations.PCP.PoweringMoment +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringEnumeration.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef80ea82789ff423331cf7f95ad7ce7146155578 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringEnumeration.lean @@ -0,0 +1,174 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLabels + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringEnumeration + +open PoweringLabels +open scoped BigOperators + +def addressCount (d t : Nat) : Nat := ∑ i : Fin (t + 1), d ^ i.val + +def reverseWordEquiv (d n : Nat) : (Fin n → Fin d) ≃ (Fin n → Fin d) where + toFun p i := p i.rev + invFun p i := p i.rev + left_inv p := by funext i; simp only [Fin.rev_rev] + right_inv p := by funext i; simp only [Fin.rev_rev] + +def wordEquiv (d n : Nat) : (Fin n → Fin d) ≃ Fin (d ^ n) := + (reverseWordEquiv d n).trans finFunctionFinEquiv + +theorem wordEquiv_val (d n : Nat) (p : Fin n → Fin d) : + (wordEquiv d n p).val = ∑ i : Fin n, (p i.rev).val * d ^ i.val := rfl + +def addressEquiv (d t : Nat) : PortWords (Fin d) t ≃ Fin (addressCount d t) := + (Equiv.sigmaCongrRight (fun i : Fin (t + 1) => wordEquiv d i.val)).trans + finSigmaFinEquiv + +theorem addressEquiv_val (d t : Nat) (w : PortWords (Fin d) t) : + (addressEquiv d t w).val = + (∑ i : Fin w.1.val, d ^ i.val) + (wordEquiv d w.1.val w.2).val := by + change (finSigmaFinEquiv + (⟨w.1, wordEquiv d w.1.val w.2⟩ : (i : Fin (t + 1)) × Fin (d ^ i.val))).val = _ + rw [finSigmaFinEquiv_apply] + rfl + +def paddedLabelEquiv (d t q : Nat) : + PaddedLabel (Fin d) t (Fin q) ≃ Fin (q ^ addressCount d t) := + ((addressEquiv d t).arrowCongr (Equiv.refl (Fin q))).trans + (wordEquiv q (addressCount d t)) + +theorem paddedLabelEquiv_val (d t q : Nat) (a : PaddedLabel (Fin d) t (Fin q)) : + (paddedLabelEquiv d t q a).val = + ∑ i : Fin (addressCount d t), + (a ((addressEquiv d t).symm i.rev)).val * q ^ i.val := rfl + +def orientationEquiv : Bool ≃ Fin 2 := finTwoEquiv.symm + +@[simp] theorem orientationEquiv_false : orientationEquiv false = 0 := rfl +@[simp] theorem orientationEquiv_true : orientationEquiv true = 1 := rfl + +def dartBlockEquiv (d n : Nat) : + ((Fin (n + 1) → Fin d) × Bool) ≃ Fin (2 * d ^ (n + 1)) := + ((wordEquiv d (n + 1)).prodCongr orientationEquiv).trans + (finProdFinEquiv.trans (finCongr (Nat.mul_comm (d ^ (n + 1)) 2))) + +theorem dartBlockEquiv_val (d n : Nat) (p : Fin (n + 1) → Fin d) (b : Bool) : + (dartBlockEquiv d n (p, b)).val = + 2 * (wordEquiv d (n + 1) p).val + (orientationEquiv b).val := by + change (orientationEquiv b).val + 2 * (wordEquiv d (n + 1) p).val = _ + exact Nat.add_comm _ _ + +def dartVertexEquiv (vertices d n : Nat) : + (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) ≃ + (Fin vertices × ((Fin (n + 1) → Fin d) × Bool)) where + toFun x := (x.2.1, (x.2.2, x.1)) + invFun x := (x.2.2, (x.1, x.2.1)) + left_inv x := by rcases x with ⟨b, v, p⟩; rfl + right_inv x := by rcases x with ⟨v, p, b⟩; rfl + +def dartEquiv (vertices d n : Nat) : + (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) ≃ + Fin (2 * vertices * d ^ (n + 1)) := + (dartVertexEquiv vertices d n).trans + (((Equiv.refl (Fin vertices)).prodCongr (dartBlockEquiv d n)).trans + (finProdFinEquiv.trans + (finCongr (show vertices * (2 * d ^ (n + 1)) = + 2 * vertices * d ^ (n + 1) by ac_rfl)))) + +theorem dartEquiv_val (vertices d n : Nat) (b : Bool) (v : Fin vertices) + (p : Fin (n + 1) → Fin d) : + (dartEquiv vertices d n (b, (v, p))).val = + (2 * d ^ (n + 1)) * v.val + + 2 * (wordEquiv d (n + 1) p).val + (orientationEquiv b).val := by + change (dartBlockEquiv d n (p, b)).val + (2 * d ^ (n + 1)) * v.val = _ + rw [dartBlockEquiv_val] + omega + +theorem dartEquiv_true_eq_false_add_one (vertices d n : Nat) (v : Fin vertices) + (p : Fin (n + 1) → Fin d) : + (dartEquiv vertices d n (true, (v, p))).val = + (dartEquiv vertices d n (false, (v, p))).val + 1 := by + rw [dartEquiv_val, dartEquiv_val, orientationEquiv_true, orientationEquiv_false] + rfl + +def encodeWord (d n : Nat) : (Fin n → Fin d) → Fin (d ^ n) := wordEquiv d n +def decodeWord (d n : Nat) : Fin (d ^ n) → (Fin n → Fin d) := (wordEquiv d n).symm + +@[simp] theorem decodeWord_encodeWord (d n : Nat) (p : Fin n → Fin d) : + decodeWord d n (encodeWord d n p) = p := (wordEquiv d n).symm_apply_apply p + +@[simp] theorem encodeWord_decodeWord (d n : Nat) (i : Fin (d ^ n)) : + encodeWord d n (decodeWord d n i) = i := (wordEquiv d n).apply_symm_apply i + +def encodeAddress (d t : Nat) : PortWords (Fin d) t → Fin (addressCount d t) := + addressEquiv d t + +def decodeAddress (d t : Nat) : Fin (addressCount d t) → PortWords (Fin d) t := + (addressEquiv d t).symm + +@[simp] theorem decodeAddress_encodeAddress (d t : Nat) (w : PortWords (Fin d) t) : + decodeAddress d t (encodeAddress d t w) = w := (addressEquiv d t).symm_apply_apply w + +@[simp] theorem encodeAddress_decodeAddress (d t : Nat) (i : Fin (addressCount d t)) : + encodeAddress d t (decodeAddress d t i) = i := (addressEquiv d t).apply_symm_apply i + +def encodeLabel (d t q : Nat) : + PaddedLabel (Fin d) t (Fin q) → Fin (q ^ addressCount d t) := paddedLabelEquiv d t q + +def decodeLabel (d t q : Nat) : + Fin (q ^ addressCount d t) → PaddedLabel (Fin d) t (Fin q) := + (paddedLabelEquiv d t q).symm + +@[simp] theorem decodeLabel_encodeLabel (d t q : Nat) (a : PaddedLabel (Fin d) t (Fin q)) : + decodeLabel d t q (encodeLabel d t q a) = a := (paddedLabelEquiv d t q).symm_apply_apply a + +@[simp] theorem encodeLabel_decodeLabel (d t q : Nat) (i : Fin (q ^ addressCount d t)) : + encodeLabel d t q (decodeLabel d t q i) = i := (paddedLabelEquiv d t q).apply_symm_apply i + +@[simp] theorem decodeLabel_apply (d t q : Nat) (i : Fin (q ^ addressCount d t)) + (w : PortWords (Fin d) t) : + decodeLabel d t q i w = decodeWord q (addressCount d t) i (encodeAddress d t w) := rfl + +def encodeDart (vertices d n : Nat) : + (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) → + Fin (2 * vertices * d ^ (n + 1)) := dartEquiv vertices d n + +def decodeDart (vertices d n : Nat) : + Fin (2 * vertices * d ^ (n + 1)) → + (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) := (dartEquiv vertices d n).symm + +@[simp] theorem decodeDart_encodeDart (vertices d n : Nat) + (e : Bool × (Fin vertices × (Fin (n + 1) → Fin d))) : + decodeDart vertices d n (encodeDart vertices d n e) = e := + (dartEquiv vertices d n).symm_apply_apply e + +@[simp] theorem encodeDart_decodeDart (vertices d n : Nat) + (i : Fin (2 * vertices * d ^ (n + 1))) : + encodeDart vertices d n (decodeDart vertices d n i) = i := + (dartEquiv vertices d n).apply_symm_apply i + +theorem card_words (d n : Nat) : Nat.card (Fin n → Fin d) = d ^ n := by + simpa only [Nat.card_fin] using Nat.card_congr (wordEquiv d n) + +theorem card_addresses (d t : Nat) : + Nat.card (PortWords (Fin d) t) = addressCount d t := by + simpa only [Nat.card_fin] using Nat.card_congr (addressEquiv d t) + +theorem card_labels (d t q : Nat) : + Nat.card (PaddedLabel (Fin d) t (Fin q)) = q ^ addressCount d t := by + simpa only [Nat.card_fin] using Nat.card_congr (paddedLabelEquiv d t q) + +theorem card_darts (vertices d n : Nat) : + Nat.card (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) = + 2 * vertices * d ^ (n + 1) := by + simpa only [Nat.card_fin] using Nat.card_congr (dartEquiv vertices d n) + +theorem length_allAddresses (d t : Nat) : + (PoweringAddresses.allAddresses d t).length = addressCount d t := + PoweringAddresses.length_allAddresses d t + +end IndependentSetsGames.Foundations.PCP.PoweringEnumeration + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringFieldPlan.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringFieldPlan.lean new file mode 100644 index 0000000000000000000000000000000000000000..97cdf5a64804131e4b1781dc204041a82470296b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringFieldPlan.lean @@ -0,0 +1,160 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringRowData + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringFieldPlan + +open PoweringWalks PoweringLabels PoweringAddresses PoweringReach PoweringRowData +open IndependentSetsGames.Foundations.Complexity PoweringMachineRow + +variable {V D : Type*} + +def tailPorts : (n : Nat) → (Fin (n + 1) → D) → Fin (n + 1) → List D + | 0, _, _ => [] + | n + 1, p, k => Fin.cases [] (fun j => p 0 :: tailPorts n (fun i => p i.succ) j) k + +theorem tailPorts_length : ∀ (n : Nat) (p : Fin (n + 1) → D) (k : Fin (n + 1)), + (tailPorts n p k).length = k.val := by + intro n + induction n with + | zero => intro p k; have hk := Fin.eq_zero k; subst k; rfl + | succ n ih => + intro p k + refine Fin.cases rfl (fun j => ?_) k + simp only [tailPorts, Fin.cases_succ, List.length_cons, ih, Fin.val_succ] + +theorem walkEnd_tailPorts (G : PortGraph V D) : + ∀ (n : Nat) (v : V) (p : Fin (n + 1) → D) (k : Fin (n + 1)), + walkEnd G v (tailPorts n p k) = (edgeAt G n (v, p) k).1 := by + intro n + induction n with + | zero => intro v p k; rfl + | succ n ih => + intro v p k + refine Fin.cases rfl (fun j => ?_) k + exact ih (next G v (p 0)) (fun i => p i.succ) j + +def headPorts (n : Nat) (p : Fin (n + 1) → D) (k : Fin (n + 1)) : List D := + tailPorts n p k ++ [p k] + +theorem walkEnd_headPorts (G : PortGraph V D) (n : Nat) (v : V) + (p : Fin (n + 1) → D) (k : Fin (n + 1)) : + walkEnd G v (headPorts n p k) = (G.rot (edgeAt G n (v, p) k)).1 := by + rw [headPorts, walkEnd_append, walkEnd_tailPorts] + change (G.rot ((edgeAt G n (v, p) k).1, p k)).1 = _ + have hp : (edgeAt G n (v, p) k).2 = p k := edgeAt_port G n (v, p) k + rw [← hp] + +def addressPorts {d t : Nat} (i : PoweringOpinionTables.AddressIndex d t) : List (Fin d) := + List.ofFn ((allAddresses d t).get i).2 + +theorem walkEnd_addressPorts {d t : Nat} (G : PortGraph V (Fin d)) (v : V) + (i : PoweringOpinionTables.AddressIndex d t) : + walkEnd G v (addressPorts i) = (wordToBall G t v ((allAddresses d t).get i)).val := + (wordEnd_eq_walkEnd_ofFn G _ _ _).symm + +inductive Instruction (d : Nat) where + | relation (ports : List (Fin d)) (port : Fin d) (left right : Fin 64) + | equal (left right : List (Fin d)) + +def Instruction.radius {d : Nat} : Instruction d → Nat + | .relation ports _ _ _ => ports.length + | .equal left right => max left.length right.length + +theorem addressPorts_length_le {d t : Nat} (i : PoweringOpinionTables.AddressIndex d t) : + (addressPorts i).length ≤ t := by + simp only [addressPorts, List.length_ofFn] + exact Nat.le_of_lt_succ ((allAddresses d t).get i).1.isLt + +def evaluate {vertices d : Nat} (input : PortTables.Table vertices d) + (start : Fin vertices) : Instruction d → Bool + | .relation ports port a b => PortTables.accepts input + (walkEnd (PortTables.portGraph input) start ports, port) a b + | .equal left right => decide + (walkEnd (PortTables.portGraph input) start left = + walkEnd (PortTables.portGraph input) start right) + +def fieldPlan {d : Nat} (n : Nat) (ports : Fin (n + 1) → Fin d) + (k : Fin (n + 1)) : Field (slotCount d n) → Instruction d + | .inl (a, b) => .relation (tailPorts n ports k) (ports k) a b + | .inr (.inl i) => .equal (addressPorts i) (tailPorts n ports k) + | .inr (.inr i) => .equal (List.ofFn ports ++ addressPorts i) (headPorts n ports k) + +theorem evaluate_fieldPlan {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (start : Fin vertices) (ports : Fin (n + 1) → Fin d) + (k : Fin (n + 1)) (field : Field (slotCount d n)) : + evaluate input start (fieldPlan n ports k field) = walkData input n (start, ports) k field := by + rcases field with ⟨a,b⟩ | i | i + · simp only [evaluate, fieldPlan, walkData, walkEnd_tailPorts] + have hp : (edgeAt (PortTables.portGraph input) n (start, ports) k).2 = ports k := + edgeAt_port (PortTables.portGraph input) n (start, ports) k + rw [← hp] + · simp only [evaluate, fieldPlan, walkData, endpointMask, walkEnd_tailPorts] + have ha := walkEnd_addressPorts (t := n + 1) (PortTables.portGraph input) start i + rw [ha] + · simp only [evaluate, fieldPlan, walkData, endpointMask, walkEnd_append, + walkEnd_headPorts] + rw [← wordEnd_eq_walkEnd_ofFn] + have ha := walkEnd_addressPorts (t := n + 1) (PortTables.portGraph input) + (wordEnd (PortTables.portGraph input) (n + 1) start ports) i + rw [ha] + rfl + +def directedFieldPlan {d : Nat} (n : Nat) (ports : Fin (n + 1) → Fin d) + (direction : Bool) (k : Fin (n + 1)) (field : Field (slotCount d n)) : Instruction d := + fieldPlan n ports k (if direction then transposeField field else field) + +theorem fieldPlan_radius {d : Nat} (n : Nat) (ports : Fin (n + 1) → Fin d) + (k : Fin (n + 1)) (field : Field (slotCount d n)) : + (fieldPlan n ports k field).radius ≤ 2 * (n + 1) := by + have hk := k.isLt + rcases field with ⟨a,b⟩ | i | i + · simp only [fieldPlan, Instruction.radius, tailPorts_length] + omega + · have hi := addressPorts_length_le i + simp only [fieldPlan, Instruction.radius, tailPorts_length] + exact max_le (by omega) (by omega) + · have hi := addressPorts_length_le i + simp only [fieldPlan, Instruction.radius, headPorts, List.length_append, + List.length_ofFn, List.length_singleton, tailPorts_length] + exact max_le (by omega) (by omega) + +theorem directedFieldPlan_radius {d : Nat} (n : Nat) (ports : Fin (n + 1) → Fin d) + (direction : Bool) (k : Fin (n + 1)) (field : Field (slotCount d n)) : + (directedFieldPlan n ports direction k field).radius ≤ 2 * (n + 1) := + fieldPlan_radius n ports k _ + +theorem evaluate_directedFieldPlan {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (start : Fin vertices) (ports : Fin (n + 1) → Fin d) + (direction : Bool) (k : Fin (n + 1)) (field : Field (slotCount d n)) : + evaluate input start (directedFieldPlan n ports direction k field) = + rowData input n (direction, start, ports) k field := + evaluate_fieldPlan input n start ports k _ + +def rowPlan {d : Nat} (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + List (Instruction d) := + List.ofFn fun i : Fin (inputSize (n + 1) (slotCount d n)) => + let pair := (inputEquiv (n + 1) (slotCount d n)).symm i + directedFieldPlan n ports direction pair.1 pair.2 + +theorem evaluate_rowPlan {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (start : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + (rowPlan n ports direction).map (evaluate input start) = + List.ofFn (rowBits input n (direction, start, ports)) := by + rw [rowPlan, List.map_ofFn] + apply congrArg List.ofFn + funext i + dsimp only [Function.comp_apply] + rw [evaluate_directedFieldPlan, rowBits_packData] + rfl + +theorem dataTape_eq_plan {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (start : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + dataTape input n (direction, start, ports) = + encodeBits ((rowPlan n ports direction).map (evaluate input start)) := by + rw [evaluate_rowPlan, dataTape_eq] + +end IndependentSetsGames.Foundations.PCP.PoweringFieldPlan + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringGap.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a08d35951764baa28d76dacebc106240d0cf486 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringGap.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Gap +import OAI.Combinatorics.IndependentSets.Expansion.PoweringNumeric + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringGap + +open PoweringWalks PoweringLabels PoweringOpinions PoweringTest +open SpectralReturn PoweringSoundness PoweringCounting + +variable {V D A : Type*} + +theorem gain_nonneg (q M : Nat) (lambda : ℝ) (hlambda : lambda < 1) : + 0 ≤ gain q M lambda := by + have hden : 0 < 1 - lambda := sub_pos.mpr hlambda + unfold gain + positivity + +variable [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + [Fintype A] [Nonempty A] + +theorem uniform_count_gap (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate (lazyGraph G) lambda) + (accepts : Edge V (Bool × D) → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts ((lazyGraph G).rot e) b a = accepts e a b) + (M : Nat) (hM : 1 ≤ M) + (selectors : ∀ v, AddressSelector (lazyGraph G) + (2 * center (Fintype.card A) M + 1) v) + (epsilon : ℝ) (hepsilon : 0 ≤ epsilon) + (hgap : ∀ assignment : V → A, + epsilon * (Fintype.card (Edge V (Bool × D)) : ℝ) ≤ + ((baseGraph (lazyGraph G) accepts reverse_accepts).rejectionCount assignment : ℝ)) + (labels : V → PaddedLabel (Bool × D) (2 * center (Fintype.card A) M + 1) A) : + (gain (Fintype.card A) M lambda * + min epsilon (1 / ((2 * center (Fintype.card A) M + 1 : Nat) : ℝ))) * + (Fintype.card (Dart V (Bool × D) (2 * center (Fintype.card A) M)) : ℝ) ≤ + ((poweredGraph (lazyGraph G) accepts (2 * center (Fintype.card A) M) + selectors).rejectionCount labels : ℝ) := by + classical + let L := lazyGraph G + let N := center (Fintype.card A) M + let n := 2 * N + let H := poweredGraph L accepts n selectors + change (gain (Fintype.card A) M lambda * + min epsilon (1 / ((n + 1 : Nat) : ℝ))) * + (Fintype.card (Dart V (Bool × D) n) : ℝ) ≤ + (H.rejectionCount labels : ℝ) + rcases eq_or_lt_of_le hepsilon with hzero | hpositive + · rw [← hzero] + have hcap : (0 : ℝ) ≤ 1 / ((n + 1 : Nat) : ℝ) := by positivity + rw [min_eq_left hcap, mul_zero, zero_mul] + exact Nat.cast_nonneg _ + · let fallback : A := Classical.choice (inferInstance : Nonempty A) + let assignment := decoded L (n + 1) N selectors labels fallback + have hdecoded : epsilon ≤ decodedError L accepts n N selectors labels fallback := by + change epsilon ≤ edgeDensity (decodedBad L accepts assignment) + exact base_count_lower_to_density L accepts reverse_accepts assignment + Fintype.card_pos epsilon (hgap assignment) + have herror : 0 < decodedError L accepts n N selectors labels fallback := + hpositive.trans_le hdecoded + have hsound := PoweringSoundness.rejection_lower_bound G lambda certificate + accepts reverse_accepts M hM selectors labels fallback herror + have hgain : 0 ≤ gain (Fintype.card A) M lambda := + gain_nonneg (Fintype.card A) M lambda certificate.lt_one + have hmin : min epsilon (1 / ((n + 1 : Nat) : ℝ)) ≤ + min (decodedError L accepts n N selectors labels fallback) + (1 / ((n + 1 : Nat) : ℝ)) := + min_le_min hdecoded (le_refl _) + have hlower : gain (Fintype.card A) M lambda * + min epsilon (1 / ((n + 1 : Nat) : ℝ)) ≤ + poweredRejection L accepts n selectors labels := + (mul_le_mul_of_nonneg_left hmin hgain).trans hsound + exact (constraint_rejection_lower_iff H labels Fintype.card_pos + (gain (Fintype.card A) M lambda * + min epsilon (1 / ((n + 1 : Nat) : ℝ)))).mp hlower + +end IndependentSetsGames.Foundations.PCP.PoweringGap +namespace IndependentSetsGames.Foundations.PCP.PoweringFinalConstants + +abbrev Alphabet := Fin 6 → Bool + +@[simp] theorem card_alphabet : Fintype.card Alphabet = 64 := by + norm_num [Alphabet, Fintype.card_fun] + +theorem card_alphabet_eq_final : Fintype.card Alphabet = FinalConstants.alphabet := by + exact card_alphabet + +theorem center_eq : + PoweringSoundness.center (Fintype.card Alphabet) FinalConstants.windowHalf = + FinalConstants.endpointLength := by + rw [card_alphabet] + rfl + +theorem walkLength_eq : + 2 * PoweringSoundness.center (Fintype.card Alphabet) FinalConstants.windowHalf + 1 = + FinalConstants.walkLength := by + rw [center_eq] + rfl + +theorem spectral_denominator_eq : + (1 + 2 / (1 - (31 / 32 : ℝ))) + 1 = 66 := by + norm_num + +theorem gain_eq : + PoweringSoundness.gain 64 FinalConstants.windowHalf (31 / 32) / 12288 = + FinalConstants.gain := by + change + (1 / (2 * (FinalConstants.alphabet : ℝ))) ^ 4 * + (FinalConstants.windowSize : ℝ) / + ((1 + 2 / (1 - (31 / 32 : ℝ))) + 1) / + (FinalConstants.compositionLoss : ℝ) = + (FinalConstants.windowSize : ℝ) / (FinalConstants.denominator : ℝ) + rw [spectral_denominator_eq] + have hden : (FinalConstants.denominator : ℝ) = + 16 * (FinalConstants.alphabet : ℝ) ^ 4 * 66 * + (FinalConstants.compositionLoss : ℝ) := by + simp only [FinalConstants.denominator, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] + rw [hden] + simp only [div_eq_mul_inv, mul_inv_rev] + ring + +theorem gain_card_eq : + PoweringSoundness.gain (Fintype.card Alphabet) FinalConstants.windowHalf (31 / 32) / + 12288 = FinalConstants.gain := by + rw [card_alphabet] + exact gain_eq + +theorem scaled_bound_eq (ε : ℝ) : + (PoweringSoundness.gain (Fintype.card Alphabet) FinalConstants.windowHalf (31 / 32) * + min ε + (1 / ((2 * PoweringSoundness.center (Fintype.card Alphabet) + FinalConstants.windowHalf + 1 : Nat) : ℝ))) / 12288 = + FinalConstants.gain * min ε FinalConstants.cap := by + rw [walkLength_eq] + rw [mul_div_right_comm, gain_card_eq] + rfl + +theorem composed_scaled_gap (ε : ℝ) (hε : 0 ≤ ε) : + min (2 * ε) FinalConstants.cap ≤ + (PoweringSoundness.gain (Fintype.card Alphabet) FinalConstants.windowHalf (31 / 32) * + min (ε / (Preprocessing.sizeFactor : ℝ)) + (1 / ((2 * PoweringSoundness.center (Fintype.card Alphabet) + FinalConstants.windowHalf + 1 : Nat) : ℝ))) / 12288 := by + rw [scaled_bound_eq] + exact FinalConstants.composed_gap ε hε + +end IndependentSetsGames.Foundations.PCP.PoweringFinalConstants + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringGlobalConfiguration.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringGlobalConfiguration.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1afac597c3909fa644ad5d0d76718d0f477755d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringGlobalConfiguration.lean @@ -0,0 +1,91 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineGlobal + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringGlobalConfiguration + +open Turing PoweringMachineGlobal + +theorem placement_injective (n : Nat) : Function.Injective (placement n) := + PoweringMachineInitialize.commonPlacement_injective (PoweringMachineRowBody.capacity n) + +theorem placement_ne_output (n : Nat) + (tape : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n)) : + placement n tape ≠ outputTape n := + PoweringMachineInitialize.commonPlacement_ne_finalOutput + (PoweringMachineRowBody.capacity n) tape + +theorem output_ne_placement (n : Nat) + (tape : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n)) : + outputTape n ≠ placement n tape := Ne.symm (placement_ne_output n tape) + +theorem headerVertices_ne_placement (n : Nat) + (tape : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n)) : + headerVertices n ≠ placement n tape := + Ne.symm (PoweringMachineInitialize.commonPlacement_ne_header + (PoweringMachineRowBody.capacity n) tape .vertices (by decide)) + +theorem headerDarts_ne_placement (n : Nat) + (tape : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n)) : + headerDarts n ≠ placement n tape := + Ne.symm (PoweringMachineInitialize.commonPlacement_ne_header + (PoweringMachineRowBody.capacity n) tape .darts (by decide)) + +theorem placement_ne_headerVertices (n : Nat) + (tape : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n)) : + placement n tape ≠ headerVertices n := Ne.symm (headerVertices_ne_placement n tape) + +theorem placement_ne_headerDarts (n : Nat) + (tape : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n)) : + placement n tape ≠ headerDarts n := Ne.symm (headerDarts_ne_placement n tape) + +theorem headerVertices_ne_headerDarts (n : Nat) : headerVertices n ≠ headerDarts n := by + simp [headerVertices, headerDarts] + +theorem headerVertices_ne_output (n : Nat) : headerVertices n ≠ outputTape n := by + simp [headerVertices, outputTape, PoweringMachineInitialize.finalOutput] + +theorem headerDarts_ne_output (n : Nat) : headerDarts n ≠ outputTape n := by + simp [headerDarts, outputTape, PoweringMachineInitialize.finalOutput] + +theorem headerVertices_ne_scratch (n : Nat) : + headerVertices n ≠ + placement n (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n)) := + headerVertices_ne_placement n _ + +theorem headerDarts_ne_scratch (n : Nat) : + headerDarts n ≠ + placement n (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n)) := + headerDarts_ne_placement n _ + +theorem scratch_ne_output (n : Nat) : + placement n (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n)) ≠ + outputTape n := + placement_ne_output n _ + +@[simp] theorem boolList_mpr_eq (h : List Bool = List Bool) (bits : List Bool) : + h.mpr bits = bits := rfl + +theorem haltList_tapes (d n : Nat) (output : List Bool) : + (Turing.haltList (machine d n) output).stk = + MachineDrainMany.haltTapes (outputTape n) output := by + funext tape + change Tape n at tape + change (if tape = outputTape n then output else []) = + (if tape = outputTape n then output else []) + rfl + +theorem haltList_eq (d n : Nat) (output : List Bool) : + Turing.haltList (machine d n) output = + (⟨none, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + MachineDrainMany.haltTapes (outputTape n) output⟩ : (machine d n).Cfg) := by + change (⟨none, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + (Turing.haltList (machine d n) output).stk⟩ : (machine d n).Cfg) = _ + exact congrArg + (fun tapes => (⟨none, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + tapes⟩ : (machine d n).Cfg)) (haltList_tapes d n output) + +end IndependentSetsGames.Foundations.Complexity.PoweringGlobalConfiguration + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringInitializeFrame.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringInitializeFrame.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff8833b9f6519b5dbd9092d2f39ccf6a03d499fb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringInitializeFrame.lean @@ -0,0 +1,137 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineGlobal + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringInitializeFrame + +open Turing PCP + +variable {vertices d : Nat} + +def initialExtra (graph : PortTables.Table vertices d) (n : Nat) : + PoweringMachineInitialize.ExtraTape (PoweringMachineRowBody.capacity n) → List Bool := + fun tape => if tape = .inl (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n)) + then PortTables.tableBits graph else [] + +@[simp] theorem initialExtra_table (graph : PortTables.Table vertices d) (n : Nat) : + initialExtra graph n (.inl (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n))) = + PortTables.tableBits graph := by simp [initialExtra] + +theorem initialExtra_other (graph : PortTables.Table vertices d) (n : Nat) + (tape : PoweringMachineInitialize.ExtraTape (PoweringMachineRowBody.capacity n)) + (hne : tape ≠ .inl (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n))) : + initialExtra graph n tape = [] := by simp [initialExtra, hne] + +@[simp] theorem initialExtra_scratch (graph : PortTables.Table vertices d) (n : Nat) : + initialExtra graph n + (.inl (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n))) = [] := by + simp [initialExtra, PoweringMachineTapes.table, PoweringMachineTapes.scratch] + +def preparedTapes (graph : PortTables.Table vertices d) (n : Nat) : + PoweringMachineGlobal.Tape n → List Bool := + PoweringMachineInitialize.mergeTapes + (PoweringMachineLoop.finalTapes (PoweringTableLayout.blockSize d n) vertices []) + (initialExtra graph n) + +theorem prepared_commonRole (graph : PortTables.Table vertices d) (n : Nat) + (j : Fin 11) (hne : j ≠ 1) : + preparedTapes graph n (PoweringMachineGlobal.placement n (.inl j)) = + if j = 0 then PortTables.tableBits graph else [] := by + simp [preparedTapes, PoweringMachineGlobal.placement, + PoweringMachineInitialize.commonPlacement, PoweringMachineTapes.start, + PoweringMachineInitialize.mergeTapes, initialExtra, PoweringMachineTapes.table, hne] + +theorem prepared_ready (graph : PortTables.Table vertices d) (n : Nat) : + PoweringMachineOuterLoop.Ready graph n (PoweringMachineGlobal.placement n) + (preparedTapes graph n) := by + constructor + · simpa using prepared_commonRole graph n 0 (by decide) + · simpa using prepared_commonRole graph n 5 (by decide) + · simpa using prepared_commonRole graph n 8 (by decide) + · simpa using prepared_commonRole graph n 9 (by decide) + · simpa using prepared_commonRole graph n 10 (by decide) + +@[simp] theorem prepared_start (graph : PortTables.Table vertices d) (n : Nat) : + preparedTapes graph n (PoweringMachineGlobal.placement n (.inl 1)) = + encodeWord vertices := by + simpa only [preparedTapes, PoweringMachineGlobal.placement, PoweringMachineTapes.start] using + PoweringMachineInitialize.final_counter (PoweringMachineRowBody.capacity n) + (PoweringTableLayout.blockSize d n) vertices (initialExtra graph n) + +theorem prepared_counter (graph : PortTables.Table vertices d) (n : Nat) : + PoweringMachineOuterLoop.counter (PoweringMachineGlobal.placement n) + (preparedTapes graph n) vertices = preparedTapes graph n := by + unfold PoweringMachineOuterLoop.counter MachineUnaryCounter.counterTapes + rw [List.append_nil, ← prepared_start graph n] + simp only [Function.update_eq_self] + +@[simp] theorem prepared_output (graph : PortTables.Table vertices d) (n : Nat) : + preparedTapes graph n (PoweringMachineGlobal.outputTape n) = [] := by + simp [preparedTapes, PoweringMachineGlobal.outputTape, PoweringMachineInitialize.finalOutput, + PoweringMachineInitialize.mergeTapes, initialExtra] + +@[simp] theorem prepared_vertices (graph : PortTables.Table vertices d) (n : Nat) : + preparedTapes graph n (PoweringMachineGlobal.headerVertices n) = encodeWord vertices := rfl + +@[simp] theorem prepared_darts (graph : PortTables.Table vertices d) (n : Nat) : + preparedTapes graph n (PoweringMachineGlobal.headerDarts n) = + encodeWord (PoweringTableLayout.blockSize d n * vertices) := rfl + +@[simp] theorem prepared_source (graph : PortTables.Table vertices d) (n : Nat) : + preparedTapes graph n (.inl PoweringMachineLoop.HeaderTape.source) = [] := rfl + +def preparedCfg (graph : PortTables.Table vertices d) (n : Nat) : + (PoweringMachineGlobal.machine d n).Cfg := + ⟨some (PoweringMachineGlobal.guardLabel d n), + PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), preparedTapes graph n⟩ + +theorem initialGlobalTapes_eq (graph : PortTables.Table vertices d) (n : Nat) : + PoweringMachineInitialize.initialGlobalTapes (initialExtra graph n) = + fun tape => if tape = PoweringMachineGlobal.inputTape n + then PortTables.tableBits graph else [] := by + funext tape + cases tape with + | inl field => + simp [PoweringMachineInitialize.initialGlobalTapes, PoweringMachineInitialize.mergeTapes, + PoweringMachineGlobal.inputTape, PoweringMachineGlobal.placement, + PoweringMachineInitialize.commonPlacement_table] + | inr field => + simp [PoweringMachineInitialize.initialGlobalTapes, PoweringMachineInitialize.mergeTapes, + PoweringMachineGlobal.inputTape, PoweringMachineGlobal.placement, + PoweringMachineInitialize.commonPlacement_table, initialExtra] + +private theorem machine_initialStacks (d n : Nat) (input : List Bool) : + (initList (PoweringMachineGlobal.machine d n) input).stk = + fun tape => if tape = PoweringMachineGlobal.inputTape n then input else [] := rfl + +theorem initList_eq (graph : PortTables.Table vertices d) (n : Nat) : + initList (PoweringMachineGlobal.machine d n) (PortTables.tableBits graph) = + ⟨some (PoweringMachineGlobal.main d n), + PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + PoweringMachineInitialize.initialGlobalTapes (initialExtra graph n)⟩ := by + have ht := (machine_initialStacks d n (PortTables.tableBits graph)).trans + (initialGlobalTapes_eq graph n).symm + exact congrArg (TM2.Cfg.mk _ _) ht + +theorem tableBits_head (graph : PortTables.Table vertices d) : + PortTables.tableBits graph = encodeWord vertices ++ + encodeWords (PortTables.tableWords graph).tail := rfl + +def initializeInTime (graph : PortTables.Table vertices d) (n : Nat) : + StateTransition.EvalsToInTime (PoweringMachineGlobal.machine d n).step + (initList (PoweringMachineGlobal.machine d n) (PortTables.tableBits graph)) + (some (preparedCfg graph n)) (3 * vertices + 5) := by + rw [initList_eq] + exact PoweringMachineInitialize.initializeAtInTime + (PoweringMachineRowBody.capacity n) (PoweringMachineRowBody.bufferSize d n) + (PoweringTableLayout.blockSize d n) vertices + (PoweringMachineGlobal.initLabels d n) (some (PoweringMachineGlobal.guardLabel d n)) + (PoweringMachineGlobal.program d n) (PoweringMachineGlobal.atInit d n) + (initialExtra graph n) (encodeWords (PortTables.tableWords graph).tail) + (by rw [initialExtra_table, tableBits_head]) (initialExtra_scratch graph n) + (PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n)) + +end IndependentSetsGames.Foundations.Complexity.PoweringInitializeFrame + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringLabels.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cf2cb17e18cc12c889cb0fceb59156d2e4da0ae --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringLabels.lean @@ -0,0 +1,178 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringWalks + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringLabels + +open PoweringWalks +open scoped BigOperators + +variable {V D A : Type*} + +abbrev PortWords (D : Type*) (t : Nat) := (n : Fin (t + 1)) × (Fin n.val → D) + +instance finitePortWords [Finite D] (t : Nat) : Finite (PortWords D t) := by + let := Fintype.ofFinite D + exact Finite.of_fintype _ + +def Ball (G : PortGraph V D) (t : Nat) (v : V) := + {u : V // ∃ n, n ≤ t ∧ ∃ p : Fin n → D, wordEnd G n v p = u} + +def wordToBall (G : PortGraph V D) (t : Nat) (v : V) (w : PortWords D t) : Ball G t v := + ⟨wordEnd G w.1.val v w.2, w.1.val, Nat.le_of_lt_succ w.1.isLt, w.2, rfl⟩ + +theorem wordToBall_surjective (G : PortGraph V D) (t : Nat) (v : V) : + Function.Surjective (wordToBall G t v) := by + intro u + obtain ⟨n, hn, p, hp⟩ := u.property + refine ⟨⟨⟨n, Nat.lt_succ_of_le hn⟩, p⟩, ?_⟩ + exact Subtype.ext hp + +instance finiteBall [Finite D] (G : PortGraph V D) (t : Nat) (v : V) : + Finite (Ball G t v) := + Finite.of_surjective (wordToBall G t v) (wordToBall_surjective G t v) + +theorem card_portWords [Finite D] (t : Nat) : + Nat.card (PortWords D t) = ∑ n : Fin (t + 1), Nat.card D ^ n.val := by + simp [PortWords, Nat.card_sigma, Nat.card_fun] + +theorem card_ball_le [Finite D] (G : PortGraph V D) (t : Nat) (v : V) : + Nat.card (Ball G t v) ≤ ∑ n : Fin (t + 1), Nat.card D ^ n.val := by + calc + _ ≤ Nat.card (PortWords D t) := Nat.card_le_card_of_surjective + (wordToBall G t v) (wordToBall_surjective G t v) + _ = _ := card_portWords t + +structure AddressSelector (G : PortGraph V D) (t : Nat) (v : V) where + address : Ball G t v → PortWords D t + correct : ∀ u, wordToBall G t v (address u) = u + +noncomputable def classicalSelector (G : PortGraph V D) (t : Nat) (v : V) : + AddressSelector G t v where + address u := Classical.choose (wordToBall_surjective G t v u) + correct u := Classical.choose_spec (wordToBall_surjective G t v u) + +def scanWitness {A : Type*} (p : A → Prop) [DecidablePred p] : + (xs : List A) → (∃ a ∈ xs, p a) → {a // p a} + | [], h => False.elim (by simp at h) + | a :: xs, h => + if ha : p a then ⟨a, ha⟩ else + scanWitness p xs (by + obtain ⟨b, hb, hp⟩ := h + rcases List.mem_cons.mp hb with he | hm + · exact False.elim (ha (he ▸ hp)) + · exact ⟨b, hm, hp⟩) + +def listSelector [DecidableEq V] (G : PortGraph V D) (t : Nat) (v : V) + (addresses : List (PortWords D t)) (complete : ∀ w, w ∈ addresses) : + AddressSelector G t v where + address u := (scanWitness (fun w => (wordToBall G t v w).val = u.val) addresses (by + obtain ⟨w, hw⟩ := wordToBall_surjective G t v u + exact ⟨w, complete w, congrArg Subtype.val hw⟩)).val + correct u := Subtype.ext (scanWitness + (fun w => (wordToBall G t v w).val = u.val) addresses (by + obtain ⟨w, hw⟩ := wordToBall_surjective G t v u + exact ⟨w, complete w, congrArg Subtype.val hw⟩)).property + +abbrev PaddedLabel (D : Type*) (t : Nat) (A : Type*) := PortWords D t → A + +def encode (G : PortGraph V D) (t : Nat) (v : V) (ℓ : Ball G t v → A) : + PaddedLabel D t A := fun w => ℓ (wordToBall G t v w) + +def decode {G : PortGraph V D} {t : Nat} {v : V} (S : AddressSelector G t v) + (a : PaddedLabel D t A) : Ball G t v → A := fun u => a (S.address u) + +theorem decode_encode {G : PortGraph V D} {t : Nat} {v : V} + (S : AddressSelector G t v) (ℓ : Ball G t v → A) : + decode S (encode G t v ℓ) = ℓ := by + funext u + change ℓ (wordToBall G t v (S.address u)) = ℓ u + rw [S.correct] + +theorem decode_surjective {G : PortGraph V D} {t : Nat} {v : V} + (S : AddressSelector G t v) : Function.Surjective (decode (A := A) S) := + fun ℓ => ⟨encode G t v ℓ, decode_encode S ℓ⟩ + +theorem encode_injective (G : PortGraph V D) (t : Nat) (v : V) : + Function.Injective (encode (A := A) G t v) := by + intro a b h + funext u + obtain ⟨w, rfl⟩ := wordToBall_surjective G t v u + exact congrFun h w + +theorem decoded_word_collision {G : PortGraph V D} {t : Nat} {v : V} + (S : AddressSelector G t v) (a : PaddedLabel D t A) (w z : PortWords D t) + (h : (wordToBall G t v w).val = (wordToBall G t v z).val) : + decode S a (wordToBall G t v w) = decode S a (wordToBall G t v z) := + congrArg (decode S a) (Subtype.ext h) + +theorem card_paddedLabel [Finite D] [Finite A] (t : Nat) : + Nat.card (PaddedLabel D t A) = + Nat.card A ^ (∑ n : Fin (t + 1), Nat.card D ^ n.val) := by + rw [Nat.card_fun, card_portWords] + +end IndependentSetsGames.Foundations.PCP.PoweringLabels +namespace IndependentSetsGames.Foundations.PCP.PoweringAddresses + +open PoweringWalks PoweringLabels +open scoped BigOperators + +variable {V : Type*} + +def allWords (d : Nat) : (n : Nat) → List (Fin n → Fin d) + | 0 => [Fin.elim0] + | n + 1 => (List.finRange d).flatMap fun a => + (allWords d n).map fun p => Fin.cases a p + +theorem mem_allWords (d : Nat) : + ∀ n (p : Fin n → Fin d), p ∈ allWords d n := by + intro n + induction n with + | zero => + intro p + simp only [allWords, List.mem_singleton] + funext i + exact Fin.elim0 i + | succ n ih => + intro p + simp only [allWords, List.mem_flatMap, List.mem_map] + refine ⟨p 0, List.mem_finRange (p 0), (fun j => p j.succ), ih _, ?_⟩ + funext j + exact Fin.cases rfl (fun _ => rfl) j + +def allAddresses (d t : Nat) : List (PortWords (Fin d) t) := + (List.finRange (t + 1)).flatMap fun n => + (allWords d n.val).map fun p => Sigma.mk n p + +theorem mem_allAddresses (d t : Nat) (w : PortWords (Fin d) t) : + w ∈ allAddresses d t := by + rcases w with ⟨n, p⟩ + unfold allAddresses + apply List.mem_flatMap.mpr + refine ⟨n, List.mem_finRange n, ?_⟩ + exact List.mem_map.mpr ⟨p, mem_allWords d n.val p, rfl⟩ + +theorem length_allWords (d : Nat) : + ∀ n, (allWords d n).length = d ^ n := by + intro n + induction n with + | zero => rfl + | succ n ih => + simp only [allWords, List.length_flatMap, List.length_map, ih, + List.map_const', List.length_finRange, List.sum_replicate_nat] + exact (Nat.mul_comm d (d ^ n)).trans (Nat.pow_succ d n).symm + +theorem length_allAddresses (d t : Nat) : + (allAddresses d t).length = ∑ n : Fin (t + 1), d ^ n.val := by + unfold allAddresses + simp only [List.length_flatMap, List.length_map, length_allWords] + exact (Fin.sum_univ_def (fun n : Fin (t + 1) => d ^ n.val)).symm + +def finitePortSelector {d : Nat} [DecidableEq V] (G : PortGraph V (Fin d)) + (t : Nat) (v : V) : AddressSelector G t v := + listSelector G t v (allAddresses d t) (mem_allAddresses d t) + +end IndependentSetsGames.Foundations.PCP.PoweringAddresses + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringLazy.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringLazy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9c69d9b7819f01359991deb7fb993184252c862 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringLazy.lean @@ -0,0 +1,207 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.Overlay +import OAI.Combinatorics.IndependentSets.Expansion.LazySmoothing + +namespace OAI + +section +namespace IndependentSetsGames.Foundations.PCP.PoweringWalks + +variable {V D : Type*} + +def lazyRotate (G : PortGraph V D) : Edge V (Bool × D) → Edge V (Bool × D) + | (v, (false, d)) => (v, (false, d)) + | (v, (true, d)) => ((G.rot (v, d)).1, (true, (G.rot (v, d)).2)) + +theorem lazyRotate_involutive (G : PortGraph V D) : + Function.Involutive (lazyRotate G) := by + rintro ⟨v, b, d⟩ + cases b with + | false => rfl + | true => + exact congrArg (fun e : V × D => (e.1, (true, e.2))) (rot_rot G (v, d)) + +def lazyGraph (G : PortGraph V D) : PortGraph V (Bool × D) where + rot := { + toFun := lazyRotate G + invFun := lazyRotate G + left_inv := lazyRotate_involutive G + right_inv := lazyRotate_involutive G } + rot_involutive := lazyRotate_involutive G + +@[simp] theorem lazyGraph_rot_false (G : PortGraph V D) (v : V) (d : D) : + (lazyGraph G).rot (v, (false, d)) = (v, (false, d)) := rfl + +@[simp] theorem lazyGraph_rot_true (G : PortGraph V D) (v : V) (d : D) : + (lazyGraph G).rot (v, (true, d)) = ((G.rot (v, d)).1, (true, (G.rot (v, d)).2)) := rfl + +end IndependentSetsGames.Foundations.PCP.PoweringWalks + +namespace IndependentSetsGames.Foundations.PCP.PoweringLazy + +open PoweringWalks SpectralReturn + +variable {V D : Type*} + +theorem operator_binomialMean [Fintype D] (G : PortGraph V D) + (n : Nat) (g : Nat → V → ℝ) (v : V) : + averagingOperator G (fun w => LazySmoothing.binomialMean n (fun k => g k w)) v = + LazySmoothing.binomialMean n (fun k => averagingOperator G (g k) v) := by + unfold averagingOperator LazySmoothing.binomialMean + exact Finset.expect_comm Finset.univ Finset.univ + (fun d tape => g (LazySmoothing.bitCount tape) (G.rot (v, d)).1) + +theorem averagingOperator_lazy [Fintype D] [Nonempty D] + (G : PortGraph V D) (f : V → ℝ) (v : V) : + averagingOperator (lazyGraph G) f v = (f v + averagingOperator G f v) / 2 := by + change mean (fun bd : Bool × D => f ((lazyGraph G).rot (v, bd)).1) = _ + rw [mean_prod] + change Finset.univ.expect (fun b : Bool => + mean (fun d : D => f ((lazyGraph G).rot (v, (b, d))).1)) = _ + rw [LazySmoothing.expect_bool] + simp only [lazyGraph_rot_false, lazyGraph_rot_true] + rw [mean_const] + rfl + +theorem iterate_lazy_eq_binomialMean [Fintype D] [Nonempty D] + (G : PortGraph V D) (n : Nat) (f : V → ℝ) : + iterateOperator (lazyGraph G) n f = + fun v => LazySmoothing.binomialMean n (fun k => iterateOperator G k f v) := by + induction n with + | zero => + funext v + simp [iterateOperator] + | succ n ih => + funext v + change averagingOperator (lazyGraph G) (iterateOperator (lazyGraph G) n f) v = _ + rw [ih, averagingOperator_lazy, operator_binomialMean, LazySmoothing.mean_succ] + rfl + +theorem iterate_mem_Icc [Fintype D] [Nonempty D] + (G : PortGraph V D) (f : V → ℝ) (hf : ∀ w, f w ∈ Set.Icc (0 : ℝ) 1) + (n : Nat) (v : V) : iterateOperator G n f v ∈ Set.Icc (0 : ℝ) 1 := by + induction n generalizing v with + | zero => exact hf v + | succ n ih => + change mean (fun d : D => iterateOperator G n f (G.rot (v, d)).1) ∈ Set.Icc (0 : ℝ) 1 + constructor + · exact mean_nonnegative _ (fun d => (ih ((G.rot (v, d)).1)).1) + · calc + mean (fun d : D => iterateOperator G n f (G.rot (v, d)).1) ≤ + mean (fun _ : D => (1 : ℝ)) := + mean_mono (fun d => (ih ((G.rot (v, d)).1)).2) + _ = 1 := mean_const _ + +theorem lazy_endpoint_modal_transfer [Fintype D] [Nonempty D] + (G : PortGraph V D) (q M m : Nat) (hq : 1 ≤ q) (hM : 1 ≤ M) + (hlo : (4 * q * M) ^ 2 - M ≤ m) (hhi : m ≤ (4 * q * M) ^ 2 + M) + (f : V → ℝ) (hf : ∀ w, f w ∈ Set.Icc (0 : ℝ) 1) (v : V) + (hmodal : 1 / (q : ℝ) ≤ iterateOperator (lazyGraph G) ((4 * q * M) ^ 2) f v) : + 1 / (2 * (q : ℝ)) ≤ iterateOperator (lazyGraph G) m f v := by + rw [iterate_lazy_eq_binomialMean] at hmodal ⊢ + exact LazySmoothing.modal_transfer q M m hq hM hlo hhi + (fun k => iterateOperator G k f v) (fun k => iterate_mem_Icc G f hf k v) hmodal + +end IndependentSetsGames.Foundations.PCP.PoweringLazy +end +namespace IndependentSetsGames.Foundations.PCP.LazyConstraint + +open scoped BigOperators +open PoweringWalks + +variable {V D A : Type*} + +def constraintGraph (G : ConstraintGraph V (V × D) A) : + ConstraintGraph V (V × (Bool × D)) A where + reverse := (lazyGraph (Overlay.originalPortGraph G)).rot + reverse_involutive := (lazyGraph (Overlay.originalPortGraph G)).rot_involutive + tail := Prod.fst + accepts e a b := if e.2.1 then G.accepts (e.1,e.2.2) a b else true + reverse_accepts := by + rintro ⟨v,b,d⟩ a c + cases b with + | false => rfl + | true => exact G.reverse_accepts (v,d) a c + +@[simp] theorem constraintGraph_tail (G : ConstraintGraph V (V × D) A) : + (constraintGraph G).tail = Prod.fst := rfl + +@[simp] theorem constraintGraph_reverse (G : ConstraintGraph V (V × D) A) : + (constraintGraph G).reverse = (lazyGraph (Overlay.originalPortGraph G)).rot := rfl + +@[simp] theorem constraintGraph_portGraph (G : ConstraintGraph V (V × D) A) : + Overlay.originalPortGraph (constraintGraph G) = + lazyGraph (Overlay.originalPortGraph G) := rfl + +@[simp] theorem edgeSatisfied_false (G : ConstraintGraph V (V × D) A) + (labeling : V → A) (v : V) (d : D) : + (constraintGraph G).edgeSatisfied labeling (v,(false,d)) = true := rfl + +@[simp] theorem edgeSatisfied_true (G : ConstraintGraph V (V × D) A) + (htail : G.tail = Prod.fst) (labeling : V → A) (v : V) (d : D) : + (constraintGraph G).edgeSatisfied labeling (v,(true,d)) = + G.edgeSatisfied labeling (v,d) := by + change G.accepts (v,d) (labeling v) (labeling (G.reverse (v,d)).1) = + G.accepts (v,d) (labeling (G.tail (v,d))) + (labeling (G.tail (G.reverse (v,d)))) + rw [htail] + +theorem complete (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (labeling : V → A) (h : ∀ e, G.edgeSatisfied labeling e = true) : + ∀ e, (constraintGraph G).edgeSatisfied labeling e = true := by + rintro ⟨v,b,d⟩ + cases b with + | false => rfl + | true => + rw [edgeSatisfied_true G htail] + exact h (v,d) + +theorem complete_iff (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (labeling : V → A) : + (∀ e, (constraintGraph G).edgeSatisfied labeling e = true) ↔ + ∀ e, G.edgeSatisfied labeling e = true := by + constructor + · intro h + rintro ⟨v,d⟩ + rw [← edgeSatisfied_true G htail] + exact h (v,(true,d)) + · exact complete G htail labeling + +theorem satisfiable_iff (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) : + (constraintGraph G).Satisfiable ↔ G.Satisfiable := by + constructor + · rintro ⟨labeling,h⟩ + exact ⟨labeling, (complete_iff G htail labeling).mp h⟩ + · rintro ⟨labeling,h⟩ + exact ⟨labeling, complete G htail labeling h⟩ + +theorem rejectionCount_eq [Fintype V] [Fintype D] + (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (labeling : V → A) : + (constraintGraph G).rejectionCount labeling = G.rejectionCount labeling := by + classical + simp only [DegreeReplacement.rejectionCount_eq_sum, Fintype.sum_prod_type, + Fintype.sum_bool] + simp [edgeSatisfied_true G htail] + +theorem card_ports [Fintype D] : + Fintype.card (Bool × D) = 2 * Fintype.card D := by + simp + +theorem card_darts [Fintype V] [Fintype D] : + Fintype.card (V × (Bool × D)) = 2 * Fintype.card (V × D) := by + simp [Fintype.card_prod, Nat.mul_left_comm] + +theorem rejection_density_eq_half [Fintype V] [Fintype D] + (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (labeling : V → A) : + ((constraintGraph G).rejectionCount labeling : ℝ) / + (Fintype.card (V × (Bool × D)) : ℝ) = + ((G.rejectionCount labeling : ℝ) / (Fintype.card (V × D) : ℝ)) / 2 := by + rw [rejectionCount_eq G htail, card_darts] + simp only [Nat.cast_mul, Nat.cast_ofNat, div_eq_mul_inv, mul_inv_rev] + ring + +end IndependentSetsGames.Foundations.PCP.LazyConstraint + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringNumeric.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringNumeric.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7652c26008e10d6ee24884c5ab191e863d21f9f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringNumeric.lean @@ -0,0 +1,232 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringTest +import OAI.Combinatorics.IndependentSets.PCP.ClauseVerifier +import OAI.Combinatorics.IndependentSets.Expansion.PoweringWitness + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringNumeric + +theorem min_density_ratio (ε C k t : ℝ) + (hε : 0 < ε) (hC : 0 < C) (hk : 0 ≤ k) + (ht : 0 < t) (hkt : k ≤ t) : + min ε (1 / t) / (C + 1) ≤ ε / (C + k * ε) := by + have hx : 0 ≤ min ε (1 / t) := + le_min hε.le (one_div_nonneg.mpr ht.le) + have hxt : min ε (1 / t) * t ≤ 1 := + (le_div_iff₀ ht).mp (min_le_right ε (1 / t)) + have hkx : k * min ε (1 / t) ≤ 1 := by + calc + k * min ε (1 / t) ≤ t * min ε (1 / t) := + mul_le_mul_of_nonneg_right hkt hx + _ ≤ 1 := by simpa only [mul_comm] using hxt + have hC1 : 0 < C + 1 := by positivity + have hden : 0 < C + k * ε := + add_pos_of_pos_of_nonneg hC (mul_nonneg hk hε.le) + apply (div_le_div_iff₀ hC1 hden).2 + calc + min ε (1 / t) * (C + k * ε) = + C * min ε (1 / t) + ε * (k * min ε (1 / t)) := by ring + _ ≤ C * ε + ε * 1 := + add_le_add + (mul_le_mul_of_nonneg_left (min_le_left ε (1 / t)) hC.le) + (mul_le_mul_of_nonneg_left hkx hε.le) + _ = ε * (C + 1) := by ring + +theorem count_moment_ratio_lower (α ε C t : ℝ) (m : ℕ) + (hm : 0 < m) (hε : 0 < ε) (hC : 0 < C) (ht : 0 < t) + (hmt : (m : ℝ) - 1 ≤ t) : + (α ^ 4 * (m : ℝ) / (C + 1)) * min ε (1 / t) ≤ + (α ^ 2 * (m : ℝ) * ε) ^ 2 / + ((m : ℝ) * ε * (C + ((m : ℝ) - 1) * ε)) := by + have hm0 : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr hm + have hm1 : (1 : ℝ) ≤ (m : ℝ) := by + exact_mod_cast (Nat.succ_le_iff.mpr hm) + have hk : 0 ≤ (m : ℝ) - 1 := sub_nonneg.mpr hm1 + have hden : 0 < C + ((m : ℝ) - 1) * ε := + add_pos_of_pos_of_nonneg hC (mul_nonneg hk hε.le) + have hαm : 0 ≤ α ^ 4 * (m : ℝ) := by positivity + have hratio := min_density_ratio ε C ((m : ℝ) - 1) t hε hC hk ht hmt + calc + (α ^ 4 * (m : ℝ) / (C + 1)) * min ε (1 / t) = + (α ^ 4 * (m : ℝ)) * (min ε (1 / t) / (C + 1)) := by ring + _ ≤ (α ^ 4 * (m : ℝ)) * (ε / (C + ((m : ℝ) - 1) * ε)) := + mul_le_mul_of_nonneg_left hratio hαm + _ = (α ^ 2 * (m : ℝ) * ε) ^ 2 / + ((m : ℝ) * ε * (C + ((m : ℝ) - 1) * ε)) := by + field_simp [ne_of_gt hm0, ne_of_gt hε, ne_of_gt hden] + +end IndependentSetsGames.Foundations.PCP.PoweringNumeric +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.PoweringSoundness + +open scoped BigOperators +open PoweringWalks PoweringLabels PoweringOpinions PoweringTest +open SpectralReturn PoweringWitness PoweringMomentBound +open PoweringMoment (bit hits) + +variable {V D A : Type*} + +def center (q M : Nat) : Nat := (4 * q * M) ^ 2 + +theorem le_center (q M : Nat) (hq : 1 ≤ q) (hM : 1 ≤ M) : M ≤ center q M := by + have hfour : 1 ≤ 4 * q := by omega + have hx : M ≤ 4 * q * M := by simpa only [Nat.one_mul] using Nat.mul_le_mul_right M hfour + have hone : 1 ≤ 4 * q * M := hM.trans hx + have hsquare : 4 * q * M ≤ (4 * q * M) * (4 * q * M) := by + simpa only [Nat.mul_one] using Nat.mul_le_mul_left (4 * q * M) hone + exact hx.trans (by simpa only [center, pow_two] using hsquare) + +def gain (q M : Nat) (lambda : ℝ) : ℝ := + (1 / (2 * (q : ℝ))) ^ 4 * ((2 * M + 1 : Nat) : ℝ) / + ((1 + 2 / (1 - lambda)) + 1) + +variable [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + [Fintype A] [Nonempty A] + +def decodedError (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (n N : Nat) (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) (fallback : A) : ℝ := + edgeDensity (decodedBad G accepts (decoded G (n + 1) N selectors labels fallback)) + +def poweredRejection (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (n : Nat) (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) : ℝ := + mean (fun d : Dart V D n => bit ((poweredGraph G accepts n selectors).edgeSatisfied labels d = false)) + +omit [Fintype V] [Nonempty V] [Nonempty D] in +theorem witness_bit_eq (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (n N : Nat) (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) (fallback : A) + (w : Walk V D (n + 1)) (k : Fin (n + 1)) : + bit (witness G accepts n selectors labels fallback + (decoded G (n + 1) N selectors labels fallback) w k) = + vertexWitness G + (decodedBad G accepts (decoded G (n + 1) N selectors labels fallback)) + (matchFn G (n + 1) N selectors labels fallback) n k w := by + simp only [witness, vertexWitness, endpointWitness, matchFn, + PoweringMoment.bit_mul, next, and_assoc] + +omit [Nonempty V] in +theorem modal_witness_mean (G : PortGraph V D) (M : Nat) (hM : 1 ≤ M) + (accepts : Edge V (Bool × D) → A → A → Bool) + (selectors : ∀ v, AddressSelector (lazyGraph G) (2 * center (Fintype.card A) M + 1) v) + (labels : V → PaddedLabel (Bool × D) (2 * center (Fintype.card A) M + 1) A) + (fallback : A) (k : Fin (2 * center (Fintype.card A) M + 1)) + (hlo : center (Fintype.card A) M - M ≤ k.val) + (hhi : k.val ≤ center (Fintype.card A) M + M) : + decodedError (lazyGraph G) accepts (2 * center (Fintype.card A) M) + (center (Fintype.card A) M) selectors labels fallback / (4 * (Fintype.card A : ℝ) ^ 2) ≤ + mean (fun w => bit (witness (lazyGraph G) accepts (2 * center (Fintype.card A) M) + selectors labels fallback (decoded (lazyGraph G) (2 * center (Fintype.card A) M + 1) + (center (Fintype.card A) M) selectors labels fallback) w k)) := by + have h := lazy_middle_witness_mean G (Fintype.card A) M Fintype.card_pos hM k hlo hhi + (decodedBad (lazyGraph G) accepts + (decoded (lazyGraph G) (2 * center (Fintype.card A) M + 1) + (center (Fintype.card A) M) selectors labels fallback)) + (matchFn (lazyGraph G) (2 * center (Fintype.card A) M + 1) + (center (Fintype.card A) M) selectors labels fallback) + (matchFn_mem_Icc (lazyGraph G) (2 * center (Fintype.card A) M + 1) + (center (Fintype.card A) M) selectors labels fallback) + (decoded_modal_baseline (lazyGraph G) (2 * center (Fintype.card A) M + 1) + (center (Fintype.card A) M) selectors labels fallback) + simp_rw [witness_bit_eq] + convert h using 1 <;> rfl + +theorem rejection_lower_bound (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate (lazyGraph G) lambda) + (accepts : Edge V (Bool × D) → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts ((lazyGraph G).rot e) b a = accepts e a b) + (M : Nat) (hM : 1 ≤ M) + (selectors : ∀ v, AddressSelector (lazyGraph G) (2 * center (Fintype.card A) M + 1) v) + (labels : V → PaddedLabel (Bool × D) (2 * center (Fintype.card A) M + 1) A) + (fallback : A) + (hε : 0 < decodedError (lazyGraph G) accepts (2 * center (Fintype.card A) M) + (center (Fintype.card A) M) selectors labels fallback) : + gain (Fintype.card A) M lambda * + min (decodedError (lazyGraph G) accepts (2 * center (Fintype.card A) M) + (center (Fintype.card A) M) selectors labels fallback) + (1 / ((2 * center (Fintype.card A) M + 1 : Nat) : ℝ)) ≤ + poweredRejection (lazyGraph G) accepts (2 * center (Fintype.card A) M) selectors labels := by + let q := Fintype.card A + let N := center q M + let n := 2 * N + let m := 2 * M + 1 + let start := N - M + let L := lazyGraph G + let assignment := decoded L (n + 1) N selectors labels fallback + let bad := decodedBad L accepts assignment + let ε := edgeDensity bad + let α : ℝ := 1 / (2 * (q : ℝ)) + let C : ℝ := 1 + 2 / (1 - lambda) + have hNM : M ≤ N := le_center q M Fintype.card_pos hM + have hw : start + m ≤ n + 1 := by dsimp [start, m, n]; omega + let E := windowEvent L bad n start m hw + let W : Fin m → Walk V (Bool × D) (n + 1) → Prop := fun i w => + witness L accepts n selectors labels fallback assignment w (windowIndex n start m hw i) + let R : Walk V (Bool × D) (n + 1) → Prop := fun w => + pathAccepts L accepts n selectors w (labels w.1) (labels (endpoint L w)) = false + have hWE : ∀ i w, W i w → E i w := by + intro i w h + exact h.1 + have hWR : ∀ i w, W i w → R w := by + intro i w h + exact witness_implies_path_rejection L accepts n selectors labels fallback assignment w + (windowIndex n start m hw i) h + have hpoint (i : Fin m) : ε / (4 * (q : ℝ) ^ 2) ≤ mean (fun w => bit (W i w)) := by + have hlo : N - M ≤ (windowIndex n start m hw i).val := by + dsimp [windowIndex, start] + omega + have hhi : (windowIndex n start m hw i).val ≤ N + M := by + have hi := i.isLt + dsimp [windowIndex, start] + dsimp [m] at hi + omega + exact modal_witness_mean G M hM accepts selectors labels fallback + (windowIndex n start m hw i) hlo hhi + have hfirst : α ^ 2 * (m : ℝ) * ε ≤ mean (hits W) := by + change α ^ 2 * (m : ℝ) * ε ≤ PoweringMoment.mean (hits W) + rw [PoweringMoment.mean_hits] + calc + _ = ∑ _i : Fin m, ε / (4 * (q : ℝ) ^ 2) := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + dsimp [α] + ring + _ ≤ _ := Finset.sum_le_sum (fun i _ => hpoint i) + have hsecond : mean (fun w => hits E w ^ 2) ≤ + (m : ℝ) * ε * (C + ((m : ℝ) - 1) * ε) := + window_second_moment_le L lambda certificate bad + (decodedBad_rot L accepts reverse_accepts assignment) n start m hw + have hε' : 0 < ε := hε + have hm : 0 < m := by dsimp [m]; omega + have hmReal : (0 : ℝ) < m := Nat.cast_pos.mpr hm + have hqReal : (0 : ℝ) < q := Nat.cast_pos.mpr Fintype.card_pos + have hden : 0 < 1 - lambda := sub_pos.mpr certificate.lt_one + have hC : 0 < C := by dsimp [C]; positivity + have hmOne : (1 : ℝ) ≤ m := by exact_mod_cast hm + have hα : 0 < α := by dsimp [α]; positivity + have ha : 0 < α ^ 2 * (m : ℝ) * ε := by positivity + have hb : 0 < (m : ℝ) * ε * (C + ((m : ℝ) - 1) * ε) := by + have hdiff : 0 ≤ (m : ℝ) - 1 := sub_nonneg.mpr hmOne + positivity + have hCS := PoweringMoment.rejection_lower_bound E W R hWE hWR + (α ^ 2 * (m : ℝ) * ε) ((m : ℝ) * ε * (C + ((m : ℝ) - 1) * ε)) + ha hb hfirst hsecond + have ht : (0 : ℝ) < ((n + 1 : Nat) : ℝ) := Nat.cast_pos.mpr (Nat.succ_pos n) + have hmn : m ≤ n + 1 := by dsimp [m, n]; omega + have hmt : (m : ℝ) - 1 ≤ ((n + 1 : Nat) : ℝ) := by + have hmnReal : (m : ℝ) ≤ ((n + 1 : Nat) : ℝ) := by exact_mod_cast hmn + linarith + have hratio := PoweringNumeric.count_moment_ratio_lower α ε C ((n + 1 : Nat) : ℝ) + m hm hε' hC ht hmt + change (α ^ 4 * (m : ℝ) / (C + 1)) * min ε (1 / ((n + 1 : Nat) : ℝ)) ≤ _ + change _ ≤ mean (fun d : Dart V (Bool × D) n => + bit ((poweredGraph L accepts n selectors).edgeSatisfied labels d = false)) + rw [rejection_mean_eq_path_mean] + exact hratio.trans hCS + +end IndependentSetsGames.Foundations.PCP.PoweringSoundness +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringOpinionTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringOpinionTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..4958f16e21c947adc0a221ab406953a84206f635 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringOpinionTables.lean @@ -0,0 +1,173 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringTest + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringOpinionTables + +open PoweringWalks PoweringLabels PoweringAddresses PoweringReach +open scoped BigOperators + +variable {X A : Type*} + +private theorem match_in_tail (p : X → Prop) {a : X} {xs : List X} + (h : ∃ b ∈ a :: xs, p b) (ha : ¬p a) : ∃ b ∈ xs, p b := by + obtain ⟨b, hb, hp⟩ := h + rcases List.mem_cons.mp hb with he | hm + · exact False.elim (ha (he ▸ hp)) + · exact ⟨b, hm, hp⟩ + +def firstIndex (p : X → Prop) [DecidablePred p] : + (xs : List X) → (∃ a ∈ xs, p a) → Fin xs.length + | [], h => False.elim (by simp at h) + | a :: xs, h => + if ha : p a then ⟨0, Nat.zero_lt_succ xs.length⟩ else + (firstIndex p xs (match_in_tail p h ha)).succ + +theorem get_firstIndex (p : X → Prop) [DecidablePred p] : + ∀ (xs : List X) (h : ∃ a ∈ xs, p a), + xs.get (firstIndex p xs h) = (scanWitness p xs h).val := by + intro xs + induction xs with + | nil => intro h; simp at h + | cons a xs ih => + intro h + by_cases ha : p a + · simp [firstIndex, scanWitness, ha] + · simpa only [firstIndex, scanWitness, ha, dite_false, List.get_cons_succ'] using + ih (match_in_tail p h ha) + +theorem firstIndex_matches (p : X → Prop) [DecidablePred p] + (xs : List X) (h : ∃ a ∈ xs, p a) : p (xs.get (firstIndex p xs h)) := by + rw [get_firstIndex] + exact (scanWitness p xs h).property + +theorem firstIndex_is_first (p : X → Prop) [DecidablePred p] : + ∀ (xs : List X) (h : ∃ a ∈ xs, p a) (j : Fin xs.length), + j.val < (firstIndex p xs h).val → ¬p (xs.get j) := by + intro xs + induction xs with + | nil => intro h; simp at h + | cons a xs ih => + intro h j + by_cases ha : p a + · simp [firstIndex, ha] + · refine Fin.cases (by intro _; exact ha) (fun i => ?_) j + intro hi + apply ih (match_in_tail p h ha) i + exact Nat.lt_of_succ_lt_succ (by + simpa only [firstIndex, ha, dite_false, Fin.val_succ] using hi) + +abbrev AddressIndex (d t : Nat) := Fin (allAddresses d t).length + +variable {vertices d : Nat} + +def addressIndex (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center : Fin vertices) (u : Ball G t center) : AddressIndex d t := + firstIndex (fun w => (wordToBall G t center w).val = u.val) + (allAddresses d t) (by + obtain ⟨w, hw⟩ := wordToBall_surjective G t center u + exact ⟨w, mem_allAddresses d t w, congrArg Subtype.val hw⟩) + +theorem addressIndex_get (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center : Fin vertices) (u : Ball G t center) : + (allAddresses d t).get (addressIndex G t center u) = + (finitePortSelector G t center).address u := by + change (allAddresses d t).get (firstIndex + (fun w => (wordToBall G t center w).val = u.val) (allAddresses d t) _) = + (scanWitness _ _ _).val + exact get_firstIndex _ _ _ + +theorem addressIndex_matches (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center : Fin vertices) (u : Ball G t center) : + wordToBall G t center ((allAddresses d t).get (addressIndex G t center u)) = u := by + rw [addressIndex_get] + exact (finitePortSelector G t center).correct u + +theorem addressIndex_is_first (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center : Fin vertices) (u : Ball G t center) (j : AddressIndex d t) + (hj : j.val < (addressIndex G t center u).val) : + (wordToBall G t center ((allAddresses d t).get j)).val ≠ u.val := by + exact firstIndex_is_first _ _ _ j hj + +theorem addressIndex_lt (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center : Fin vertices) (u : Ball G t center) : + (addressIndex G t center u).val < ∑ n : Fin (t + 1), d ^ n.val := by + rw [← length_allAddresses] + exact (addressIndex G t center u).isLt + +abbrev LabelTable (d t : Nat) (A : Type*) := Vector A (allAddresses d t).length + +def labelTable {t : Nat} (a : PaddedLabel (Fin d) t A) : LabelTable d t A := + Vector.ofFn fun i => a ((allAddresses d t).get i) + +@[simp] theorem labelTable_get {t : Nat} (a : PaddedLabel (Fin d) t A) + (i : AddressIndex d t) : + (labelTable a)[i] = a ((allAddresses d t).get i) := by + simp [labelTable] + +theorem labelTable_addressIndex (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center : Fin vertices) (u : Ball G t center) (a : PaddedLabel (Fin d) t A) : + (labelTable a)[addressIndex G t center u] = + decode (finitePortSelector G t center) a u := by + rw [labelTable_get, addressIndex_get] + rfl + +structure WalkOpinionRow (vertices d t : Nat) where + edge : Edge (Fin vertices) (Fin d) + tailIndex : AddressIndex d t + headIndex : AddressIndex d t + +abbrev WalkRows (vertices d n : Nat) := Vector (WalkOpinionRow vertices d (n + 1)) (n + 1) + +def walkRows (G : PortGraph (Fin vertices) (Fin d)) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) : WalkRows vertices d n := + Vector.ofFn fun k => + { edge := edgeAt G n w k + tailIndex := addressIndex G (n + 1) w.1 (tailFromStart G n w k) + headIndex := addressIndex G (n + 1) (endpoint G w) (headFromEnd G n w k) } + +@[simp] theorem walkRows_edge (G : PortGraph (Fin vertices) (Fin d)) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) : + (walkRows G n w)[k].edge = edgeAt G n w k := by + simp [walkRows] + +@[simp] theorem walkRows_tail_value (G : PortGraph (Fin vertices) (Fin d)) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) + (a : PaddedLabel (Fin d) (n + 1) A) : + (labelTable a)[(walkRows G n w)[k].tailIndex] = + decode (finitePortSelector G (n + 1) w.1) a (tailFromStart G n w k) := by + simpa only [walkRows, Fin.getElem_fin, Vector.getElem_ofFn] using + labelTable_addressIndex G (n + 1) w.1 (tailFromStart G n w k) a + +@[simp] theorem walkRows_head_value (G : PortGraph (Fin vertices) (Fin d)) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) + (b : PaddedLabel (Fin d) (n + 1) A) : + (labelTable b)[(walkRows G n w)[k].headIndex] = + decode (finitePortSelector G (n + 1) (endpoint G w)) b (headFromEnd G n w k) := by + simpa only [walkRows, Fin.getElem_fin, Vector.getElem_ofFn] using + labelTable_addressIndex G (n + 1) (endpoint G w) (headFromEnd G n w k) b + +theorem walkRows_length (G : PortGraph (Fin vertices) (Fin d)) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) : + (walkRows G n w).toList.length = n + 1 := by + simp + +def rowsAccepts {n : Nat} (accepts : Edge (Fin vertices) (Fin d) → A → A → Bool) + (rows : WalkRows vertices d n) (a b : LabelTable d (n + 1) A) : Bool := + decide (∀ k : Fin (n + 1), accepts rows[k].edge a[rows[k].tailIndex] + b[rows[k].headIndex] = true) + +theorem rowsAccepts_walkRows (G : PortGraph (Fin vertices) (Fin d)) + (accepts : Edge (Fin vertices) (Fin d) → A → A → Bool) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) + (a b : PaddedLabel (Fin d) (n + 1) A) : + rowsAccepts accepts (walkRows G n w) (labelTable a) (labelTable b) = + PoweringTest.pathAccepts G accepts n (finitePortSelector G (n + 1)) w a b := by + apply Bool.eq_iff_iff.mpr + simp only [rowsAccepts, decide_eq_true_iff, PoweringTest.pathAccepts_eq_true_iff, + walkRows_edge, walkRows_tail_value, walkRows_head_value] + +end IndependentSetsGames.Foundations.PCP.PoweringOpinionTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringOpinions.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringOpinions.lean new file mode 100644 index 0000000000000000000000000000000000000000..315912552c6ae758ec8dabb2ff4afa3d29a9cea2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringOpinions.lean @@ -0,0 +1,213 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLazy +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLabels +import OAI.Combinatorics.IndependentSets.Expansion.PoweringReturn + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.PoweringOpinions + +open PoweringWalks PoweringLabels SpectralReturn +open PoweringMoment (bit) + +variable {V D A : Type*} + +def opinionAt (G : PortGraph V D) (t : Nat) + (selectors : ∀ v, AddressSelector G t v) (labels : V → PaddedLabel D t A) + (fallback : A) (u v : V) : A := by + classical + exact if h : ∃ n, n ≤ t ∧ ∃ p : Fin n → D, wordEnd G n v p = u then + decode (selectors v) (labels v) ⟨u, h⟩ else fallback + +theorem opinionAt_eq_decode (G : PortGraph V D) (t : Nat) + (selectors : ∀ v, AddressSelector G t v) (labels : V → PaddedLabel D t A) + (fallback : A) (v : V) (u : Ball G t v) : + opinionAt G t selectors labels fallback u.val v = decode (selectors v) (labels v) u := by + classical + simp [opinionAt, u.property] + rfl + +def honestLabels (G : PortGraph V D) (t : Nat) (assignment : V → A) : + V → PaddedLabel D t A := fun v => encode G t v (fun u => assignment u.val) + +theorem opinionAt_honest (G : PortGraph V D) (t : Nat) + (selectors : ∀ v, AddressSelector G t v) (assignment : V → A) + (fallback : A) (v : V) (u : Ball G t v) : + opinionAt G t selectors (honestLabels G t assignment) fallback u.val v = + assignment u.val := by + rw [opinionAt_eq_decode] + exact congrFun (decode_encode (selectors v) (fun u => assignment u.val)) u + +variable [Fintype D] [Nonempty D] [Fintype A] [Nonempty A] + +def sampleOpinion (G : PortGraph V D) (t N : Nat) + (selectors : ∀ v, AddressSelector G t v) (labels : V → PaddedLabel D t A) + (fallback : A) (u : V) (p : Fin N → D) : A := + opinionAt G t selectors labels fallback u (wordEnd G N u p) + +def decoded (G : PortGraph V D) (t N : Nat) + (selectors : ∀ v, AddressSelector G t v) (labels : V → PaddedLabel D t A) + (fallback : A) (u : V) : A := + PoweringDecoding.mode (sampleOpinion G t N selectors labels fallback u) + +def matchFn (G : PortGraph V D) (t N : Nat) + (selectors : ∀ v, AddressSelector G t v) (labels : V → PaddedLabel D t A) + (fallback : A) (u v : V) : ℝ := + bit (opinionAt G t selectors labels fallback u v = decoded G t N selectors labels fallback u) + +omit [Nonempty D] in +theorem matchFn_mem_Icc (G : PortGraph V D) (t N : Nat) + (selectors : ∀ v, AddressSelector G t v) (labels : V → PaddedLabel D t A) + (fallback : A) (u v : V) : + matchFn G t N selectors labels fallback u v ∈ Set.Icc (0 : ℝ) 1 := by + classical + constructor + · exact PoweringMoment.bit_nonneg _ + · unfold matchFn bit + split <;> simp + +theorem decoded_modal_baseline (G : PortGraph V D) (t N : Nat) + (selectors : ∀ v, AddressSelector G t v) (labels : V → PaddedLabel D t A) + (fallback : A) (u : V) : + 1 / (Fintype.card A : ℝ) ≤ + iterateOperator G N (matchFn G t N selectors labels fallback u) u := by + have h := PoweringDecoding.mode_mass_lower (sampleOpinion G t N selectors labels fallback u) + change 1 / (Fintype.card A : ℝ) ≤ mean (fun p : Fin N → D => + matchFn G t N selectors labels fallback u (wordEnd G N u p)) at h + rwa [PoweringReturn.mean_wordEnd] at h + +theorem decoded_modal_near (G : PortGraph V D) (t M m : Nat) + (selectors : ∀ v, AddressSelector (lazyGraph G) t v) + (labels : V → PaddedLabel (Bool × D) t A) (fallback : A) + (hM : 1 ≤ M) + (hlo : (4 * Fintype.card A * M) ^ 2 - M ≤ m) + (hhi : m ≤ (4 * Fintype.card A * M) ^ 2 + M) (u : V) : + 1 / (2 * (Fintype.card A : ℝ)) ≤ + iterateOperator (lazyGraph G) m + (matchFn (lazyGraph G) t ((4 * Fintype.card A * M) ^ 2) + selectors labels fallback u) u := by + exact PoweringLazy.lazy_endpoint_modal_transfer G (Fintype.card A) M m + Fintype.card_pos hM hlo hhi _ + (matchFn_mem_Icc (lazyGraph G) t ((4 * Fintype.card A * M) ^ 2) + selectors labels fallback u) u + (decoded_modal_baseline (lazyGraph G) t ((4 * Fintype.card A * M) ^ 2) + selectors labels fallback u) + +end IndependentSetsGames.Foundations.PCP.PoweringOpinions +end +namespace IndependentSetsGames.Foundations.PCP.PoweringReach + +open PoweringWalks PoweringLabels + +variable {V D : Type*} + +def ReachLE (G : PortGraph V D) (t : Nat) (u v : V) : Prop := + ∃ l, l ≤ t ∧ ∃ p : Fin l → D, wordEnd G l u p = v + +theorem reach_refl (G : PortGraph V D) (t : Nat) (u : V) : ReachLE G t u u := + ⟨0, Nat.zero_le t, Fin.elim0, rfl⟩ + +theorem reach_mono {G : PortGraph V D} {s t : Nat} {u v : V} + (hst : s ≤ t) (h : ReachLE G s u v) : ReachLE G t u v := by + obtain ⟨l, hl, p, hp⟩ := h + exact ⟨l, hl.trans hst, p, hp⟩ + +theorem reach_prepend (G : PortGraph V D) {t : Nat} (u : V) (d : D) {v : V} + (h : ReachLE G t (next G u d) v) : ReachLE G (t + 1) u v := by + obtain ⟨l, hl, p, hp⟩ := h + refine ⟨l + 1, Nat.succ_le_succ hl, + (fun i : Fin (l + 1) => Fin.cases d p i), ?_⟩ + simpa only [wordEnd, Fin.cases_zero, Fin.cases_succ] using hp + +def reversePorts (G : PortGraph V D) : V → List D → List D + | _, [] => [] + | v, d :: ds => reversePorts G (next G v d) ds ++ [(G.rot (v, d)).2] + +theorem reversePorts_length (G : PortGraph V D) (v : V) (ds : List D) : + (reversePorts G v ds).length = ds.length := by + induction ds generalizing v with + | nil => rfl + | cons d ds ih => simp [reversePorts, ih] + +theorem walkEnd_reversePorts (G : PortGraph V D) (v : V) (ds : List D) : + walkEnd G (walkEnd G v ds) (reversePorts G v ds) = v := by + induction ds generalizing v with + | nil => rfl + | cons d ds ih => + change walkEnd G (walkEnd G (next G v d) ds) + (reversePorts G (next G v d) ds ++ [(G.rot (v, d)).2]) = v + rw [walkEnd_append, ih] + change (G.rot (G.rot (v, d))).1 = v + exact congrArg Prod.fst (G.rot_involutive (v, d)) + +theorem wordEnd_eq_walkEnd_ofFn (G : PortGraph V D) : + ∀ n v (p : Fin n → D), wordEnd G n v p = walkEnd G v (List.ofFn p) := by + intro n + induction n with + | zero => intro v p; rfl + | succ n ih => + intro v p + rw [List.ofFn_succ, walkEnd_cons] + exact ih (next G v (p 0)) (fun j => p j.succ) + +theorem reach_reverse {G : PortGraph V D} {t : Nat} {u v : V} + (h : ReachLE G t u v) : ReachLE G t v u := by + obtain ⟨l, hl, p, hp⟩ := h + refine ⟨(reversePorts G u (List.ofFn p)).length, ?_, + (reversePorts G u (List.ofFn p)).get, ?_⟩ + · simpa only [reversePorts_length, List.length_ofFn] using hl + · rw [wordEnd_eq_walkEnd_ofFn, List.ofFn_get] + have hlist : walkEnd G u (List.ofFn p) = v := by + rw [← wordEnd_eq_walkEnd_ofFn] + exact hp + rw [← hlist, walkEnd_reversePorts] + +theorem tail_reach (G : PortGraph V D) : + ∀ (n : Nat) (w : Walk V D (n + 1)) (k : Fin (n + 1)), + ReachLE G (n + 1) w.1 (edgeAt G n w k).1 := by + intro n + induction n with + | zero => + intro w k + exact reach_refl G 1 w.1 + | succ n ih => + intro w k + refine Fin.cases ?_ (fun j => ?_) k + · exact reach_refl G (n + 2) w.1 + · exact reach_prepend G w.1 (w.2 0) (ih (advanceTail G w) j) + +theorem head_reach_endpoint (G : PortGraph V D) : + ∀ (n : Nat) (w : Walk V D (n + 1)) (k : Fin (n + 1)), + ReachLE G (n + 1) (G.rot (edgeAt G n w k)).1 (endpoint G w) := by + intro n + induction n with + | zero => + intro w k + exact reach_refl G 1 (G.rot (w.1, w.2 0)).1 + | succ n ih => + intro w k + refine Fin.cases ?_ (fun j => ?_) k + · exact ⟨n + 1, Nat.le_succ (n + 1), (fun j => w.2 j.succ), rfl⟩ + · exact reach_mono (Nat.le_succ (n + 1)) (ih (advanceTail G w) j) + +def tailFromStart (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1)) + (k : Fin (n + 1)) : Ball G (n + 1) w.1 := + ⟨(edgeAt G n w k).1, tail_reach G n w k⟩ + +def headFromEnd (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1)) + (k : Fin (n + 1)) : Ball G (n + 1) (endpoint G w) := + ⟨(G.rot (edgeAt G n w k)).1, reach_reverse (head_reach_endpoint G n w k)⟩ + +@[simp] theorem tailFromStart_val (G : PortGraph V D) (n : Nat) + (w : Walk V D (n + 1)) (k : Fin (n + 1)) : + (tailFromStart G n w k).val = (edgeAt G n w k).1 := rfl + +@[simp] theorem headFromEnd_val (G : PortGraph V D) (n : Nat) + (w : Walk V D (n + 1)) (k : Fin (n + 1)) : + (headFromEnd G n w k).val = (G.rot (edgeAt G n w k)).1 := rfl + +end IndependentSetsGames.Foundations.PCP.PoweringReach + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPlanBudget.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPlanBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..5cb226aaadb3ba3939392eb7f5e895d35d22d92f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPlanBudget.lean @@ -0,0 +1,197 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFiniteSequence + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringPlanBudget + +open Turing MachineComposition PCP PoweringFieldPlan + +variable {K Λ A : Type} [DecidableEq K] {vertices d max : Nat} + +def fieldBudget (max inputLength : Nat) : Nat := + (28 * max + 10) * inputLength + 24 * max + 15 + +theorem field_steps_le (graph : PortTables.Table vertices d) (vertex : Fin vertices) + (op : Instruction d) (bounded : op.radius ≤ max) : + PoweringMachineField.steps graph vertex op ≤ + fieldBudget max (PortTables.tableBits graph).length := by + cases op with + | relation path port left right => + change path.length ≤ max at bounded + have h := PoweringMachineRelationField.steps_le path port left right graph vertex + have coefficient : 14 * path.length + 9 ≤ 28 * max + 10 := by omega + have product := Nat.mul_le_mul_right (PortTables.tableBits graph).length coefficient + change PoweringMachineRelationField.steps path port left right graph vertex ≤ _ + unfold fieldBudget + omega + | equal left right => + change Nat.max left.length right.length ≤ max at bounded + have hl : left.length ≤ max := (le_max_left _ _).trans bounded + have hr : right.length ≤ max := (le_max_right _ _).trans bounded + have h := PoweringMachineEqualityField.steps_le graph vertex left.get right.get + have coefficient : 14 * (left.length + right.length) + 10 ≤ 28 * max + 10 := by + omega + have product := Nat.mul_le_mul_right (PortTables.tableBits graph).length coefficient + change PoweringMachineEqualityField.steps graph vertex left.get right.get ≤ _ + unfold fieldBudget + omega + +theorem plan_steps_le (graph : PortTables.Table vertices d) + (placement : PoweringMachineTapes.Tape max → K) (vertex : Fin vertices) + (commands : List (PoweringMachinePlan.Command d max)) (base : K → List Bool) : + PoweringMachinePlan.steps graph placement vertex commands base ≤ + commands.length * fieldBudget max (PortTables.tableBits graph).length := by + induction commands generalizing base with + | nil => simp only [PoweringMachinePlan.steps, MachineFiniteSequence.steps, + List.length_nil, Nat.zero_mul, Nat.le_refl] + | cons op commands ih => + have first := field_steps_le graph vertex op.val op.property + have rest := ih (PoweringMachinePlan.result graph placement vertex op base) + change PoweringMachineField.steps graph vertex op.val + + PoweringMachinePlan.steps graph placement vertex commands + (PoweringMachinePlan.result graph placement vertex op base) ≤ _ + simpa only [List.length_cons, Nat.add_mul, Nat.one_mul, Nat.add_comm] using + Nat.add_le_add first rest + +@[simp] theorem boundedRowPlan_length (n : Nat) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : + (PoweringMachinePlan.boundedRowPlan n ports direction).length = + PoweringMachineRow.inputSize (n + 1) (PoweringRowData.slotCount d n) := by + simp only [PoweringMachinePlan.boundedRowPlan, List.length_ofFn] + +def rowBudget (d n inputLength : Nat) : Nat := + PoweringMachineRow.inputSize (n + 1) (PoweringRowData.slotCount d n) * + fieldBudget (2 * (n + 1)) inputLength + +theorem rowPlan_steps_le (graph : PortTables.Table vertices d) (n : Nat) + (ports : Fin (n + 1) → Fin d) (direction : Bool) + (placement : PoweringMachineTapes.Tape (2 * (n + 1)) → K) + (vertex : Fin vertices) (base : K → List Bool) : + PoweringMachinePlan.steps graph placement vertex + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse base ≤ + PoweringMachineRow.inputSize (n + 1) (PoweringRowData.slotCount d n) * + ((28 * (2 * (n + 1)) + 10) * (PortTables.tableBits graph).length + + 24 * (2 * (n + 1)) + 15) := by + have h := plan_steps_le graph placement vertex + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse base + simpa only [List.length_reverse, boundedRowPlan_length, fieldBudget] using h + +def planInTime (graph : PortTables.Table vertices d) + (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin vertices) (commands : List (PoweringMachinePlan.Command d max)) + (labels : PoweringMachinePlan.Label commands → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (MachineUnaryEqualityBit.State A)) + (atLabels : ∀ l, program (labels l) = + PoweringMachinePlan.instruction placement commands labels exit l) + (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineField.Ready graph placement vertex suffix base) (ambient : A) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨PoweringMachinePlan.entry commands labels exit, MachineUnaryEqualityBit.clean ambient, base⟩ + (some ⟨exit, MachineUnaryEqualityBit.clean ambient, + PoweringMachinePlan.finalTapes graph placement vertex commands base⟩) + (commands.length * fieldBudget max (PortTables.tableBits graph).length) where + steps := PoweringMachinePlan.steps graph placement vertex commands base + evals_in_steps := PoweringMachinePlan.planTrace graph placement distinct vertex commands + labels exit program atLabels base suffix ready ambient + steps_le_m := plan_steps_le graph placement vertex commands base + +def rowPlanInTime (graph : PortTables.Table vertices d) (n : Nat) + (ports : Fin (n + 1) → Fin d) (direction : Bool) + (placement : PoweringMachineTapes.Tape (2 * (n + 1)) → K) + (distinct : Function.Injective placement) (vertex : Fin vertices) + (labels : PoweringMachinePlan.Label + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse → Λ) + (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (MachineUnaryEqualityBit.State A)) + (atLabels : ∀ l, program (labels l) = PoweringMachinePlan.instruction placement + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse labels exit l) + (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineField.Ready graph placement vertex suffix base) (ambient : A) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨PoweringMachinePlan.entry (PoweringMachinePlan.boundedRowPlan n ports direction).reverse + labels exit, MachineUnaryEqualityBit.clean ambient, base⟩ + (some ⟨exit, MachineUnaryEqualityBit.clean ambient, + PoweringMachinePlan.finalTapes graph placement vertex + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse base⟩) + (rowBudget d n (PortTables.tableBits graph).length) where + steps := PoweringMachinePlan.steps graph placement vertex + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse base + evals_in_steps := PoweringMachinePlan.planTrace graph placement distinct vertex + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse + labels exit program atLabels base suffix ready ambient + steps_le_m := rowPlan_steps_le graph n ports direction placement vertex base + +end IndependentSetsGames.Foundations.Complexity.PoweringPlanBudget +namespace IndependentSetsGames.Foundations.PCP.PoweringRowHeaderSemantics + +open PoweringWalks PoweringEnumeration +open IndependentSetsGames.Foundations.Complexity + +variable {vertices d : Nat} + +def blockSize (d n : Nat) : Nat := 2 * d ^ (n + 1) + +def reverseOffset (d n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : Nat := + 2 * (wordEquiv d (n + 1) ports).val + (if direction then 0 else 1) + +def reverseValue (d n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : Nat := + blockSize d n * vertex.val + reverseOffset d n ports direction + +def tailVertex (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : Fin vertices := + if direction then wordEnd (PortTables.portGraph input) (n + 1) vertex ports else vertex + +def headerWords (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : List Nat := + [(tailVertex input n vertex ports direction).val, reverseValue d n vertex ports direction] + +theorem table_tail (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : + (PoweringTables.table input n).rows[encodeDart vertices d n (direction, vertex, ports)].tail = + tailVertex input n vertex ports direction := by + change (GenericGraphTables.semantics (PoweringTables.table input n)).tail + (encodeDart vertices d n (direction, vertex, ports)) = _ + rw [PoweringTables.semantics_table] + change (PoweringTables.mathematicalGraph input n).tail + ((dartEquiv vertices d n).symm (dartEquiv vertices d n (direction, vertex, ports))) = _ + rw [Equiv.symm_apply_apply] + rfl + +theorem table_reverseValue (input : PortTables.Table vertices d) (n : Nat) + (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + (PoweringTables.table input n).rows[encodeDart vertices d n + (direction, vertex, ports)].reverseIndex.val = reverseValue d n vertex ports direction := by + change (GenericGraphTables.reverseAt (PoweringTables.table input n).rows + (encodeDart vertices d n (direction, vertex, ports))).val = _ + rw [PoweringTables.table_reverse, encodeDart, dartEquiv_val] + cases direction <;> + simp [reverseValue, blockSize, reverseOffset, orientationEquiv, Nat.add_assoc] <;> decide + +theorem headerWords_eq (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : + headerWords input n vertex ports direction = + [(PoweringTables.table input n).rows[encodeDart vertices d n + (direction, vertex, ports)].tail.val, + (PoweringTables.table input n).rows[encodeDart vertices d n + (direction, vertex, ports)].reverseIndex.val] := by + rw [table_tail, table_reverseValue] + rfl + +theorem header_relation_bits (input : PortTables.Table vertices d) (n : Nat) + (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) + (suffix : List Bool) : + encodeWords (headerWords input n vertex ports direction) ++ + (encodeWords (GenericGraphTables.relationWords + (PoweringTables.table input n).rows[encodeDart vertices d n + (direction, vertex, ports)].relation) ++ suffix) = + encodeWords (GenericGraphTables.rowWords + (PoweringTables.table input n).rows[encodeDart vertices d n + (direction, vertex, ports)]) ++ suffix := by + rw [headerWords_eq, ← List.append_assoc, ← encodeWords_append] + rfl + +end IndependentSetsGames.Foundations.PCP.PoweringRowHeaderSemantics + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPolynomialBudget.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPolynomialBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..150f6243a39cfe58c6b3ab6c9cd802d362cced86 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPolynomialBudget.lean @@ -0,0 +1,141 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineVertex + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringPolynomialBudget + +open PCP + +def preBudget (d n vertices inputLength : Nat) : Nat := + (3 * vertices + 5) + + (vertices * (PoweringMachineVertex.budget d n inputLength + 2) + 1) + +def finishBudget (d n pushBound tapeCount vertices inputLength prior : Nat) : Nat := + 2 * (vertices + PoweringTableLayout.blockSize d n * vertices) + 6 + + tapeCount * (inputLength + prior * pushBound + vertices + + PoweringTableLayout.blockSize d n * vertices + 3) + +def totalBudget (d n pushBound tapeCount vertices inputLength : Nat) : Nat := + preBudget d n vertices inputLength + + finishBudget d n pushBound tapeCount vertices inputLength + (preBudget d n vertices inputLength) + +theorem preBudget_mono_vertices (d n inputLength : Nat) {v w : Nat} (h : v ≤ w) : + preBudget d n v inputLength ≤ preBudget d n w inputLength := by + have hthree := Nat.mul_le_mul_left 3 h + have hloop := Nat.mul_le_mul_right (PoweringMachineVertex.budget d n inputLength + 2) h + unfold preBudget + omega + +theorem finishBudget_mono (d n pushBound tapeCount inputLength : Nat) + {v w prior later : Nat} (hvertices : v ≤ w) (hprior : prior ≤ later) : + finishBudget d n pushBound tapeCount v inputLength prior ≤ + finishBudget d n pushBound tapeCount w inputLength later := by + have hdarts := Nat.mul_le_mul_left (PoweringTableLayout.blockSize d n) hvertices + have hheader := Nat.mul_le_mul_left 2 (Nat.add_le_add hvertices hdarts) + have hgrowth := Nat.mul_le_mul_right pushBound hprior + have hinside : inputLength + prior * pushBound + v + + PoweringTableLayout.blockSize d n * v + 3 ≤ + inputLength + later * pushBound + w + PoweringTableLayout.blockSize d n * w + 3 := by + omega + have hclear := Nat.mul_le_mul_left tapeCount hinside + unfold finishBudget + omega + +theorem totalBudget_mono_vertices (d n pushBound tapeCount inputLength : Nat) + {v w : Nat} (hvertices : v ≤ w) : + totalBudget d n pushBound tapeCount v inputLength ≤ + totalBudget d n pushBound tapeCount w inputLength := by + have hpre := preBudget_mono_vertices d n inputLength hvertices + unfold totalBudget + exact Nat.add_le_add hpre + (finishBudget_mono d n pushBound tapeCount inputLength hvertices hpre) + +noncomputable def rowTime (d n : Nat) : Polynomial Nat := + Polynomial.C (PoweringMachineRowBody.bufferSize d n) * + (Polynomial.C (28 * (2 * (n + 1)) + 10) * Polynomial.X + + Polynomial.C (24 * (2 * (n + 1)) + 15)) + Polynomial.C 1 + + (Polynomial.C (14 * (n + 1) + 4) * Polynomial.X + + Polynomial.C (12 * (n + 1)) + Polynomial.C 6) + +@[simp] theorem rowTime_eval (d n inputLength : Nat) : + (rowTime d n).eval inputLength = PoweringMachineRowBody.budget d n inputLength := by + simp only [rowTime, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_X, PoweringMachineRowBody.budget, PoweringPlanBudget.rowBudget, + PoweringPlanBudget.fieldBudget, PoweringMachineRowBody.bufferSize, Nat.add_assoc] + +noncomputable def vertexTime (d n : Nat) : Polynomial Nat := + Polynomial.C (PoweringTableLayout.blockSize d n) * rowTime d n + +@[simp] theorem vertexTime_eval (d n inputLength : Nat) : + (vertexTime d n).eval inputLength = PoweringMachineVertex.budget d n inputLength := by + simp only [vertexTime, Polynomial.eval_mul, Polynomial.eval_C, rowTime_eval, + PoweringMachineVertex.budget] + +noncomputable def preTime (d n : Nat) : Polynomial Nat := + (Polynomial.C 3 * Polynomial.X + Polynomial.C 5) + + (Polynomial.X * (vertexTime d n + Polynomial.C 2) + Polynomial.C 1) + +@[simp] theorem preTime_eval (d n inputLength : Nat) : + (preTime d n).eval inputLength = preBudget d n inputLength inputLength := by + simp only [preTime, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_X, vertexTime_eval, preBudget] + +noncomputable def time (d n pushBound tapeCount : Nat) : Polynomial Nat := + preTime d n + + (Polynomial.C 2 * + (Polynomial.X + Polynomial.C (PoweringTableLayout.blockSize d n) * Polynomial.X) + + Polynomial.C 6 + Polynomial.C tapeCount * + (Polynomial.X + preTime d n * Polynomial.C pushBound + Polynomial.X + + Polynomial.C (PoweringTableLayout.blockSize d n) * Polynomial.X + Polynomial.C 3)) + +@[simp] theorem time_eval (d n pushBound tapeCount inputLength : Nat) : + (time d n pushBound tapeCount).eval inputLength = + totalBudget d n pushBound tapeCount inputLength inputLength := by + simp only [time, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_X, preTime_eval, totalBudget, finishBudget] + +theorem totalBudget_le_time (d n pushBound tapeCount vertices inputLength : Nat) + (hvertices : vertices ≤ inputLength) : + totalBudget d n pushBound tapeCount vertices inputLength ≤ + (time d n pushBound tapeCount).eval inputLength := by + rw [time_eval] + exact totalBudget_mono_vertices d n pushBound tapeCount inputLength hvertices + +theorem setup_loop_finish_le_time (d n pushBound tapeCount vertices inputLength : Nat) + (hvertices : vertices ≤ inputLength) : + ((3 * vertices + 5) + + (vertices * (PoweringMachineVertex.budget d n inputLength + 2) + 1)) + + (2 * (vertices + (2 * d ^ (n + 1)) * vertices) + 6 + + tapeCount * (inputLength + + ((3 * vertices + 5) + + (vertices * (PoweringMachineVertex.budget d n inputLength + 2) + 1)) * pushBound + + vertices + (2 * d ^ (n + 1)) * vertices + 3)) ≤ + (time d n pushBound tapeCount).eval inputLength := by + simpa only [totalBudget, preBudget, finishBudget, PoweringTableLayout.blockSize] using + totalBudget_le_time d n pushBound tapeCount vertices inputLength hvertices + +theorem execution_budget_le_time (d n pushBound tapeCount vertices inputLength : Nat) + (hvertices : vertices ≤ inputLength) {preSteps finishSteps : Nat} + (hpre : preSteps ≤ preBudget d n vertices inputLength) + (hfinish : finishSteps ≤ finishBudget d n pushBound tapeCount vertices inputLength + (preBudget d n vertices inputLength)) : + preSteps + finishSteps ≤ (time d n pushBound tapeCount).eval inputLength := by + calc + preSteps + finishSteps ≤ totalBudget d n pushBound tapeCount vertices inputLength := by + unfold totalBudget + exact Nat.add_le_add hpre hfinish + _ ≤ (time d n pushBound tapeCount).eval inputLength := + totalBudget_le_time d n pushBound tapeCount vertices inputLength hvertices + +theorem graph_totalBudget_le_time {vertices d : Nat} (graph : PortTables.Table vertices d) + (n pushBound tapeCount : Nat) : + totalBudget d n pushBound tapeCount vertices (PortTables.tableBits graph).length ≤ + (time d n pushBound tapeCount).eval (PortTables.tableBits graph).length := + totalBudget_le_time d n pushBound tapeCount vertices (PortTables.tableBits graph).length + (PortTables.vertices_le_tableBits_length graph) + +end IndependentSetsGames.Foundations.Complexity.PoweringPolynomialBudget + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPortReindex.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPortReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1d23549fc14d7f06518bf785f4bb95ffd59d2b5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringPortReindex.lean @@ -0,0 +1,364 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringGap + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.PCP.PoweringPortReindex +open PoweringWalks PoweringLabels PoweringReach PoweringTest +open SpectralReturn PoweringSoundness + +variable {V D E A : Type*} + +def wordEquiv (ports : D ≃ E) (n : Nat) : (Fin n → D) ≃ (Fin n → E) where + toFun p := fun i => ports (p i) + invFun p := fun i => ports.symm (p i) + left_inv p := by funext i; exact ports.symm_apply_apply (p i) + right_inv p := by funext i; exact ports.apply_symm_apply (p i) + +def walkEquiv (ports : D ≃ E) (n : Nat) : Walk V D n ≃ Walk V E n := + Equiv.prodCongr (Equiv.refl V) (wordEquiv ports n) + +def addressEquiv (ports : D ≃ E) (t : Nat) : PortWords D t ≃ PortWords E t where + toFun w := ⟨w.1, wordEquiv ports w.1.val w.2⟩ + invFun w := ⟨w.1, (wordEquiv ports w.1.val).symm w.2⟩ + left_inv w := by rcases w with ⟨n,p⟩; simp + right_inv w := by rcases w with ⟨n,p⟩; simp + +def labelEquiv (ports : D ≃ E) (t : Nat) : PaddedLabel E t A ≃ PaddedLabel D t A where + toFun a := fun w => a (addressEquiv ports t w) + invFun a := fun w => a ((addressEquiv ports t).symm w) + left_inv a := by funext w; simp + right_inv a := by funext w; simp + +variable (G : PortGraph V D) (H : PortGraph V E) (ports : D ≃ E) +variable (rotation : ∀ v d, H.rot (v, ports d) = + ((G.rot (v,d)).1, ports (G.rot (v,d)).2)) + +include rotation + +theorem wordEnd_map (n : Nat) (v : V) (p : Fin n → D) : + wordEnd H n v (wordEquiv ports n p) = wordEnd G n v p := by + induction n generalizing v with + | zero => rfl + | succ n ih => + simp only [wordEnd, next, wordEquiv, Equiv.coe_fn_mk, rotation] + exact ih _ _ + +theorem endpoint_map (n : Nat) (w : Walk V D n) : + endpoint H (walkEquiv ports n w) = endpoint G w := + wordEnd_map G H ports rotation n w.1 w.2 + +theorem reach_iff (t : Nat) (v u : V) : + (∃ n, n ≤ t ∧ ∃ p : Fin n → D, wordEnd G n v p = u) ↔ + (∃ n, n ≤ t ∧ ∃ p : Fin n → E, wordEnd H n v p = u) := by + constructor + · rintro ⟨n,hn,p,hp⟩ + exact ⟨n,hn,wordEquiv ports n p,(wordEnd_map G H ports rotation n v p).trans hp⟩ + · rintro ⟨n,hn,p,hp⟩ + refine ⟨n,hn,(wordEquiv ports n).symm p,?_⟩ + rw [← wordEnd_map G H ports rotation, Equiv.apply_symm_apply] + exact hp + +def ballEquiv (t : Nat) (v : V) : Ball G t v ≃ Ball H t v where + toFun u := ⟨u.val,(reach_iff G H ports rotation t v u.val).mp u.property⟩ + invFun u := ⟨u.val,(reach_iff G H ports rotation t v u.val).mpr u.property⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem wordToBall_map (t : Nat) (v : V) (w : PortWords D t) : + wordToBall H t v (addressEquiv ports t w) = + ballEquiv G H ports rotation t v (wordToBall G t v w) := by + apply Subtype.ext + exact wordEnd_map G H ports rotation w.1.val v w.2 + +def pullSelector {t : Nat} {v : V} (S : AddressSelector H t v) : + AddressSelector G t v where + address u := (addressEquiv ports t).symm + (S.address (ballEquiv G H ports rotation t v u)) + correct u := by + apply (ballEquiv G H ports rotation t v).injective + rw [← wordToBall_map, Equiv.apply_symm_apply, S.correct] + +theorem decode_pullSelector {t : Nat} {v : V} (S : AddressSelector H t v) + (a : PaddedLabel E t A) (u : Ball G t v) : + decode (pullSelector G H ports rotation S) (labelEquiv ports t a) u = + decode S a (ballEquiv G H ports rotation t v u) := by + simp [decode, pullSelector, labelEquiv] + +theorem decode_transport {t : Nat} (selectors : ∀v, AddressSelector H t v) + (a : PaddedLabel E t A) {v w : V} (hvw : v = w) + (u : Ball G t v) (u' : Ball H t w) (hu : u.val = u'.val) : + decode (pullSelector G H ports rotation (selectors v)) (labelEquiv ports t a) u = + decode (selectors w) a u' := by + subst w + rw [decode_pullSelector] + congr 1 + exact Subtype.ext hu + +theorem opinionAt_pullSelector (t : Nat) (selectors : ∀v, AddressSelector H t v) + (labels : V → PaddedLabel E t A) (fallback : A) (u v : V) : + PoweringOpinions.opinionAt G t (fun v => pullSelector G H ports rotation (selectors v)) + (fun v => labelEquiv ports t (labels v)) fallback u v = + PoweringOpinions.opinionAt H t selectors labels fallback u v := by + classical + unfold PoweringOpinions.opinionAt + split_ifs with hG hH hH + · exact decode_pullSelector G H ports rotation (selectors v) (labels v) ⟨u,hG⟩ + · exact False.elim (hH ((reach_iff G H ports rotation t v u).mp hG)) + · exact False.elim (hG ((reach_iff G H ports rotation t v u).mpr hH)) + · rfl + +theorem advanceTail_map (n : Nat) (w : Walk V D (n+1)) : + advanceTail H (walkEquiv ports (n+1) w) = + walkEquiv ports n (advanceTail G w) := by + apply Prod.ext + · change (H.rot (w.1, ports (w.2 0))).1 = (G.rot (w.1,w.2 0)).1 + rw [rotation] + · rfl + +theorem edgeAt_map (n : Nat) (w : Walk V D (n+1)) (k : Fin (n+1)) : + edgeAt H n (walkEquiv ports (n+1) w) k = + ((edgeAt G n w k).1, ports (edgeAt G n w k).2) := by + induction n with + | zero => rfl + | succ n ih => + induction k using Fin.cases with + | zero => rfl + | succ k => + simp only [edgeAt, Fin.cases_succ] + rw [advanceTail_map G H ports rotation] + exact ih _ _ + +variable (accepts : Edge V E → A → A → Bool) + +def pullAccepts : Edge V D → A → A → Bool := + fun e => accepts (e.1, ports e.2) + +theorem pathAccepts_map (n : Nat) (selectors : ∀v, AddressSelector H (n+1) v) + (w : Walk V D (n+1)) (a b : PaddedLabel E (n+1) A) : + pathAccepts G (pullAccepts ports accepts) n + (fun v => pullSelector G H ports rotation (selectors v)) w + (labelEquiv ports (n+1) a) (labelEquiv ports (n+1) b) = + pathAccepts H accepts n selectors (walkEquiv ports (n+1) w) a b := by + classical + unfold pathAccepts + congr 1 + apply propext + apply forall_congr' + intro k + have ht := decode_transport G H ports rotation selectors a rfl + (tailFromStart G n w k) (tailFromStart H n (walkEquiv ports (n+1) w) k) + (congrArg Prod.fst (edgeAt_map G H ports rotation n w k)).symm + have hh := decode_transport G H ports rotation selectors b + (endpoint_map G H ports rotation (n+1) w).symm + (headFromEnd G n w k) (headFromEnd H n (walkEquiv ports (n+1) w) k) + (by + change (G.rot (edgeAt G n w k)).1 = + (H.rot (edgeAt H n (walkEquiv ports (n+1) w) k)).1 + rw [edgeAt_map G H ports rotation, rotation]) + rw [ht, hh] + simp only [pullAccepts, edgeAt_map G H ports rotation] + rfl + +def dartEquiv (n : Nat) : Dart V D n ≃ Dart V E n := + Equiv.prodCongr (Equiv.refl Bool) (walkEquiv ports (n+1)) + +theorem edgeSatisfied_map (n : Nat) (selectors : ∀v, AddressSelector H (n+1) v) + (labels : V → PaddedLabel E (n+1) A) (e : Dart V D n) : + (poweredGraph G (pullAccepts ports accepts) n + (fun v => pullSelector G H ports rotation (selectors v))).edgeSatisfied + (fun v => labelEquiv ports (n+1) (labels v)) e = + (poweredGraph H accepts n selectors).edgeSatisfied labels (dartEquiv ports n e) := by + rcases e with ⟨direction,w⟩ + rw [poweredGraph_edgeSatisfied] + change _ = (poweredGraph H accepts n selectors).edgeSatisfied labels + (direction, walkEquiv ports (n+1) w) + rw [poweredGraph_edgeSatisfied, endpoint_map G H ports rotation] + exact pathAccepts_map G H ports rotation accepts n selectors w _ _ + +theorem rejectionCount_map [Fintype V] [Fintype D] [Fintype E] + (n : Nat) (selectors : ∀v, AddressSelector H (n+1) v) + (labels : V → PaddedLabel E (n+1) A) : + (poweredGraph G (pullAccepts ports accepts) n + (fun v => pullSelector G H ports rotation (selectors v))).rejectionCount + (fun v => labelEquiv ports (n+1) (labels v)) = + (poweredGraph H accepts n selectors).rejectionCount labels := by + classical + unfold ConstraintGraph.rejectionCount + apply Finset.card_bij (fun e _ => dartEquiv ports n e) + · intro e he + rw [ConstraintGraph.mem_rejectedDarts, ← edgeSatisfied_map G H ports rotation] + exact (ConstraintGraph.mem_rejectedDarts _ _ _).mp he + · intro e _ f _ h + exact (dartEquiv ports n).injective h + · intro e he + refine ⟨(dartEquiv ports n).symm e, ?_, (dartEquiv ports n).apply_symm_apply e⟩ + rw [ConstraintGraph.mem_rejectedDarts, edgeSatisfied_map G H ports rotation, + Equiv.apply_symm_apply] + exact (ConstraintGraph.mem_rejectedDarts _ _ _).mp he + +theorem satisfiable_iff (n : Nat) (selectors : ∀v, AddressSelector H (n+1) v) : + (poweredGraph G (pullAccepts ports accepts) n + (fun v => pullSelector G H ports rotation (selectors v))).Satisfiable ↔ + (poweredGraph H accepts n selectors).Satisfiable := by + constructor + · rintro ⟨labels,hlabels⟩ + refine ⟨fun v => (labelEquiv ports (n+1)).symm (labels v), ?_⟩ + intro e + obtain ⟨e,rfl⟩ := (dartEquiv ports n).surjective e + rw [← edgeSatisfied_map G H ports rotation] + simpa only [Equiv.apply_symm_apply] using hlabels e + · rintro ⟨labels,hlabels⟩ + refine ⟨fun v => labelEquiv ports (n+1) (labels v), ?_⟩ + intro e + rw [edgeSatisfied_map G H ports rotation] + exact hlabels _ + +theorem pullReverse + (reverse_accepts : ∀ e a b, accepts (H.rot e) b a = accepts e a b) + (e : Edge V D) (a b : A) : + pullAccepts ports accepts (G.rot e) b a = pullAccepts ports accepts e a b := by + simpa only [pullAccepts, rotation] using reverse_accepts (e.1,ports e.2) a b + +theorem base_edgeSatisfied_map + (reverse_accepts : ∀ e a b, accepts (H.rot e) b a = accepts e a b) + (assignment : V → A) (e : Edge V D) : + (baseGraph G (pullAccepts ports accepts) + (pullReverse G H ports rotation accepts reverse_accepts)).edgeSatisfied assignment e = + (baseGraph H accepts reverse_accepts).edgeSatisfied assignment (e.1,ports e.2) := by + change accepts (e.1,ports e.2) (assignment e.1) (assignment (G.rot e).1) = + accepts (e.1,ports e.2) (assignment e.1) (assignment (H.rot (e.1,ports e.2)).1) + rw [rotation] + +theorem base_rejectionCount_map [Fintype V] [Fintype D] [Fintype E] + (reverse_accepts : ∀ e a b, accepts (H.rot e) b a = accepts e a b) + (assignment : V → A) : + (baseGraph G (pullAccepts ports accepts) + (pullReverse G H ports rotation accepts reverse_accepts)).rejectionCount assignment = + (baseGraph H accepts reverse_accepts).rejectionCount assignment := by + classical + let e : Edge V D ≃ Edge V E := Equiv.prodCongr (Equiv.refl V) ports + have edgeEq (x : Edge V D) := + base_edgeSatisfied_map G H ports rotation accepts reverse_accepts assignment x + unfold ConstraintGraph.rejectionCount + apply Finset.card_bij (fun x _ => e x) + · intro x hx + rw [ConstraintGraph.mem_rejectedDarts] + change (baseGraph H accepts reverse_accepts).edgeSatisfied assignment (x.1,ports x.2) = false + rw [← edgeEq] + exact (ConstraintGraph.mem_rejectedDarts _ _ _).mp hx + · intro x _ y _ h + exact e.injective h + · intro y hy + refine ⟨e.symm y, ?_, e.apply_symm_apply y⟩ + rw [ConstraintGraph.mem_rejectedDarts, edgeEq] + change (baseGraph H accepts reverse_accepts).edgeSatisfied assignment (e (e.symm y)) = false + rw [e.apply_symm_apply] + exact (ConstraintGraph.mem_rejectedDarts _ _ _).mp hy + +omit rotation in + +theorem uniform_count_gap + [Fintype V] [Fintype D] [Fintype E] [Nonempty V] [Nonempty D] + [Fintype A] [Nonempty A] + (G : PortGraph V D) (H : PortGraph V E) (ports : (Bool × D) ≃ E) + (rotation : ∀ v d, H.rot (v, ports d) = + (((lazyGraph G).rot (v,d)).1, ports ((lazyGraph G).rot (v,d)).2)) + (lambda : ℝ) (certificate : SpectralCertificate (lazyGraph G) lambda) + (accepts : Edge V E → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts (H.rot e) b a = accepts e a b) + (M : Nat) (hM : 1 ≤ M) + (selectors : ∀v, AddressSelector H (2*center (Fintype.card A) M+1) v) + (epsilon : ℝ) (hepsilon : 0 ≤ epsilon) + (hgap : ∀ assignment : V → A, + epsilon * (Fintype.card (Edge V E) : ℝ) ≤ + ((baseGraph H accepts reverse_accepts).rejectionCount assignment : ℝ)) + (labels : V → PaddedLabel E (2*center (Fintype.card A) M+1) A) : + (gain (Fintype.card A) M lambda * + min epsilon (1 / ((2*center (Fintype.card A) M+1 : Nat) : ℝ))) * + (Fintype.card (Dart V E (2*center (Fintype.card A) M)) : ℝ) ≤ + ((poweredGraph H accepts (2*center (Fintype.card A) M) selectors).rejectionCount labels : ℝ) := by + have hbase : ∀ assignment : V → A, + epsilon * (Fintype.card (Edge V (Bool × D)) : ℝ) ≤ + ((baseGraph (lazyGraph G) (pullAccepts ports accepts) + (pullReverse (lazyGraph G) H ports rotation accepts reverse_accepts)).rejectionCount assignment : ℝ) := by + intro assignment + rw [base_rejectionCount_map (lazyGraph G) H ports rotation, + Fintype.card_congr (Equiv.prodCongr (Equiv.refl V) ports)] + exact hgap assignment + have bound := PoweringGap.uniform_count_gap G lambda certificate + (pullAccepts ports accepts) + (pullReverse (lazyGraph G) H ports rotation accepts reverse_accepts) M hM + (fun v => pullSelector (lazyGraph G) H ports rotation (selectors v)) + epsilon hepsilon hbase (fun v => labelEquiv ports _ (labels v)) + rw [rejectionCount_map (lazyGraph G) H ports rotation, + Fintype.card_congr (dartEquiv (V := V) ports (2*center (Fintype.card A) M))] at bound + exact bound + +omit rotation in + +theorem lazy_table_uniform_count_gap {vertices d : Nat} + (input : PortTables.Table vertices d) (hv : 0 < vertices) (hd : 0 < d) + (lambda : ℝ) + (certificate : SpectralCertificate (lazyGraph (PortTables.portGraph input)) lambda) + (M : Nat) (hM : 1 ≤ M) (epsilon : ℝ) (hepsilon : 0 ≤ epsilon) + (hgap : ∀ assignment : Fin vertices → Fin 64, + epsilon * (Fintype.card (Fin vertices × Fin (2*d)) : ℝ) ≤ + ((PortTables.baseGraph (PreprocessingOverlayTables.lazy input)).rejectionCount assignment : ℝ)) : + ∀ labels : PoweringTableSemantics.EncodedLabeling vertices (2*d) (2*center 64 M), + (gain 64 M lambda * min epsilon (1 / ((2*center 64 M+1 : Nat) : ℝ))) * + ((PoweringTables.table (PreprocessingOverlayTables.lazy input) (2*center 64 M)).darts : ℝ) ≤ + ((GenericGraphTables.semantics + (PoweringTables.table (PreprocessingOverlayTables.lazy input) (2*center 64 M))).rejectionCount labels : ℝ) := by + let : Nonempty (Fin vertices) := ⟨⟨0,hv⟩⟩ + let : Nonempty (Fin d) := ⟨⟨0,hd⟩⟩ + apply PoweringTableSemantics.uniform_count_gap + intro labels + have hrot : ∀ v p, + (PortTables.portGraph (PreprocessingOverlayTables.lazy input)).rot + (v, PreprocessingOverlayTables.lazyPorts d p) = + (((lazyGraph (PortTables.portGraph input)).rot (v,p)).1, + PreprocessingOverlayTables.lazyPorts d + ((lazyGraph (PortTables.portGraph input)).rot (v,p)).2) := by + intro v p + rw [PreprocessingTableSpectral.lazy_portGraph] + exact GraphTransport.reindex_rot _ (Equiv.refl _) _ v p + have bound := uniform_count_gap (PortTables.portGraph input) + (PortTables.portGraph (PreprocessingOverlayTables.lazy input)) + (PreprocessingOverlayTables.lazyPorts d) hrot lambda certificate + (PortTables.accepts (PreprocessingOverlayTables.lazy input)) + (PortTables.accepts_rotation (PreprocessingOverlayTables.lazy input)) M hM + (PoweringAddresses.finitePortSelector + (PortTables.portGraph (PreprocessingOverlayTables.lazy input)) _) epsilon hepsilon + hgap + simp only [PortTables.Label, GraphTables.Label, Fintype.card_fin] at bound + exact bound labels + +omit rotation in + +theorem lazy_table_uniform_count_gap_at {vertices d : Nat} + (input : PortTables.Table vertices d) (hv : 0 < vertices) (hd : 0 < d) + (lambda : ℝ) + (certificate : SpectralCertificate (lazyGraph (PortTables.portGraph input)) lambda) + (M : Nat) (hM : 1 ≤ M) (n : Nat) (hn : n = 2*center 64 M) + (epsilon : ℝ) (hepsilon : 0 ≤ epsilon) + (hgap : ∀ assignment : Fin vertices → Fin 64, + epsilon * (Fintype.card (Fin vertices × Fin (2*d)) : ℝ) ≤ + ((PortTables.baseGraph (PreprocessingOverlayTables.lazy input)).rejectionCount + assignment : ℝ)) : + ∀ labels : PoweringTableSemantics.EncodedLabeling vertices (2*d) n, + (gain 64 M lambda * min epsilon (1 / ((n+1 : Nat) : ℝ))) * + ((PoweringTables.table (PreprocessingOverlayTables.lazy input) n).darts : ℝ) ≤ + ((GenericGraphTables.semantics + (PoweringTables.table (PreprocessingOverlayTables.lazy input) n)).rejectionCount + labels : ℝ) := by + subst n + exact lazy_table_uniform_count_gap input hv hd lambda certificate M hM + epsilon hepsilon hgap + +end IndependentSetsGames.Foundations.PCP.PoweringPortReindex + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringReturn.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringReturn.lean new file mode 100644 index 0000000000000000000000000000000000000000..96697391a1dc91237e8249d2e361d3a08a49a6c6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringReturn.lean @@ -0,0 +1,301 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.SpectralReturn +import OAI.Combinatorics.IndependentSets.Expansion.PoweringDecoding + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringReturn + +open PoweringWalks SpectralReturn +open PoweringMoment (bit) + +variable {V D : Type*} + +def portConsEquiv (D : Type*) (n : Nat) : + (D × (Fin n → D)) ≃ (Fin (n + 1) → D) where + toFun z := Fin.cases z.1 z.2 + invFun r := (r 0, fun j => r j.succ) + left_inv z := by + apply Prod.ext + · rfl + · funext j + rfl + right_inv r := by + funext j + exact Fin.cases rfl (fun _ => rfl) j + +theorem mean_word_cons_head [Fintype D] (n : Nat) + (F : (Fin (n + 1) → D) → ℝ) : + mean F = mean (fun d : D => mean (fun r : Fin n → D => F (Fin.cases d r))) := by + calc + mean F = mean (fun z : D × (Fin n → D) => F (Fin.cases z.1 z.2)) := + (mean_equiv (portConsEquiv D n) F).symm + _ = _ := mean_prod _ + +theorem mean_word_cons_tail [Fintype D] (n : Nat) + (F : (Fin (n + 1) → D) → ℝ) : + mean F = mean (fun r : Fin n → D => mean (fun d : D => F (Fin.cases d r))) := by + calc + mean F = mean (fun z : (Fin n → D) × D => F (Fin.cases z.2 z.1)) := + (mean_equiv ((Equiv.prodComm (Fin n → D) D).trans (portConsEquiv D n)) F).symm + _ = _ := mean_prod _ + +theorem iterateOperator_succ_right [Fintype D] (G : PortGraph V D) + (n : Nat) (f : V → ℝ) : + iterateOperator G n (averagingOperator G f) = iterateOperator G (n + 1) f := by + induction n with + | zero => rfl + | succ n ih => exact congrArg (averagingOperator G) ih + +theorem mean_wordEnd [Fintype D] [Nonempty D] (G : PortGraph V D) : + ∀ (n : Nat) (v : V) (f : V → ℝ), + mean (fun r : Fin n → D => f (wordEnd G n v r)) = iterateOperator G n f v := by + intro n + induction n with + | zero => + intro v f + change mean (fun _ : Fin 0 → D => f v) = f v + exact mean_const _ + | succ n ih => + intro v f + rw [mean_word_cons_head] + change mean (fun d : D => mean (fun r : Fin n → D => + f (wordEnd G n (next G v d) r))) = _ + calc + _ = mean (fun d : D => iterateOperator G n f (next G v d)) := by + congr 1 + funext d + exact ih (next G v d) f + _ = iterateOperator G (n + 1) f v := rfl + +theorem mean_pivot_endpoints [Fintype D] [Nonempty D] (G : PortGraph V D) : + ∀ (n : Nat) (k : Fin (n + 1)) (e : Edge V D) (φ ψ : V → ℝ), + mean (fun r : Fin n → D => + φ (leftFromPivot G n k e.1 r) * ψ (rightFromPivot G n k e r)) = + iterateOperator G k.val φ e.1 * + iterateOperator G (n - k.val) ψ (next G e.1 e.2) := by + intro n + induction n with + | zero => + intro k e φ ψ + have hk : k = 0 := Fin.eq_zero k + subst k + change mean (fun _ : Fin 0 → D => φ e.1 * ψ (next G e.1 e.2)) = + φ e.1 * ψ (next G e.1 e.2) + exact mean_const _ + | succ n ih => + intro k e φ ψ + refine Fin.cases ?_ (fun j => ?_) k + · change mean (fun r : Fin (n + 1) → D => + φ e.1 * ψ (wordEnd G (n + 1) (next G e.1 e.2) r)) = + φ e.1 * iterateOperator G (n + 1) ψ (next G e.1 e.2) + rw [mean_mul_left, mean_wordEnd] + · simp only [Fin.val_succ, Nat.add_sub_add_right] + rw [mean_word_cons_tail] + change mean (fun r : Fin n → D => mean (fun d : D => + φ (next G (leftFromPivot G n j e.1 r) d) * + ψ (rightFromPivot G n j e r))) = + iterateOperator G (j.val + 1) φ e.1 * + iterateOperator G (n - j.val) ψ (next G e.1 e.2) + calc + _ = mean (fun r : Fin n → D => + averagingOperator G φ (leftFromPivot G n j e.1 r) * + ψ (rightFromPivot G n j e r)) := by + congr 1 + funext r + rw [mean_mul_right] + rfl + _ = iterateOperator G j.val (averagingOperator G φ) e.1 * + iterateOperator G (n - j.val) ψ (next G e.1 e.2) := + ih j e (averagingOperator G φ) ψ + _ = _ := by rw [iterateOperator_succ_right] + +theorem mean_edge_endpoints [Fintype V] [Fintype D] [Nonempty D] + (G : PortGraph V D) (n : Nat) (k : Fin (n + 1)) (φ ψ : Edge V D → V → ℝ) : + mean (fun w : Walk V D (n + 1) => + φ (edgeAt G n w k) w.1 * ψ (edgeAt G n w k) (endpoint G w)) = + mean (fun e : Edge V D => + iterateOperator G k.val (φ e) e.1 * + iterateOperator G (n - k.val) (ψ e) (next G e.1 e.2)) := by + let F : Edge V D × (Fin n → D) → ℝ := fun z => + φ z.1 (leftFromPivot G n k z.1.1 z.2) * + ψ z.1 (rightFromPivot G n k z.1 z.2) + calc + _ = mean (fun w => F (pivotEquiv G n k w)) := by + congr 1 + funext w + dsimp [F] + rw [leftFromPivot_actual, rightFromPivot_actual, pivotEquiv_fst] + _ = mean F := mean_equiv (pivotEquiv G n k) F + _ = mean (fun e : Edge V D => mean (fun r : Fin n → D => + φ e (leftFromPivot G n k e.1 r) * ψ e (rightFromPivot G n k e r))) := mean_prod F + _ = _ := by + congr 1 + funext e + exact mean_pivot_endpoints G n k e (φ e) (ψ e) + +theorem bit_bool (b : Bool) : bit (b = true) = (if b then 1 else 0 : ℝ) := by + cases b <;> simp [bit] + +theorem mean_edge_bit [Fintype D] (bad : V × D → Bool) (v : V) : + mean (fun d : D => bit (bad (v, d) = true)) = edgeProfile bad v := by + simp only [bit_bool, mean, edgeProfile] + +theorem mean_marked_bit [Fintype D] (G : PortGraph V D) + (bad : V × D → Bool) (f : V → ℝ) (v : V) : + mean (fun d : D => bit (bad (v, d) = true) * f (next G v d)) = + markedStep G bad f v := by + change mean (fun d : D => bit (bad (v, d) = true) * f (next G v d)) = + mean (fun d : D => if bad (v, d) then f (next G v d) else 0) + congr 1 + funext d + cases bad (v, d) <;> simp [bit] + +theorem edgeAt_zero (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1)) : + edgeAt G n w 0 = (w.1, w.2 0) := by + cases n <;> rfl + +theorem word_first_hit_mean [Fintype D] [Nonempty D] + (G : PortGraph V D) (bad : V × D → Bool) (n : Nat) (v : V) : + mean (fun p : Fin (n + 1) → D => bit (bad (edgeAt G n (v, p) 0) = true)) = + edgeProfile bad v := by + rw [mean_word_cons_head] + simp_rw [edgeAt_zero] + change mean (fun d : D => mean (fun _ : Fin n → D => bit (bad (v, d) = true))) = _ + calc + _ = mean (fun d : D => bit (bad (v, d) = true)) := by simp only [mean_const] + _ = edgeProfile bad v := mean_edge_bit bad v + +theorem word_hit_mean [Fintype D] [Nonempty D] + (G : PortGraph V D) (bad : V × D → Bool) : + ∀ (n : Nat) (v : V) (k : Fin (n + 1)), + mean (fun p : Fin (n + 1) → D => bit (bad (edgeAt G n (v, p) k) = true)) = + iterateOperator G k.val (edgeProfile bad) v := by + intro n + induction n with + | zero => + intro v k + have hk : k = 0 := Fin.eq_zero k + subst k + exact word_first_hit_mean G bad 0 v + | succ n ih => + intro v k + refine Fin.cases ?_ (fun j => ?_) k + · exact word_first_hit_mean G bad (n + 1) v + · rw [mean_word_cons_head] + change mean (fun d : D => mean (fun p : Fin (n + 1) → D => + bit (bad (edgeAt G n (next G v d, p) j) = true))) = + averagingOperator G (iterateOperator G j.val (edgeProfile bad)) v + calc + _ = mean (fun d : D => iterateOperator G j.val (edgeProfile bad) (next G v d)) := by + congr 1 + funext d + exact ih (next G v d) j + _ = _ := rfl + +theorem word_pair_hit_mean [Fintype D] [Nonempty D] + (G : PortGraph V D) (bad : V × D → Bool) : + ∀ (n : Nat) (v : V) (i j : Fin (n + 1)), i < j → + mean (fun p : Fin (n + 1) → D => + bit (bad (edgeAt G n (v, p) i) = true) * + bit (bad (edgeAt G n (v, p) j) = true)) = + iterateOperator G i.val (markedStep G bad + (iterateOperator G (j.val - i.val - 1) (edgeProfile bad))) v := by + intro n + induction n with + | zero => + intro v i j hij + have hi : i = 0 := Fin.eq_zero i + have hj : j = 0 := Fin.eq_zero j + subst i + subst j + exact ((lt_irrefl _) hij).elim + | succ n ih => + intro v i + refine Fin.cases ?_ (fun a => ?_) i + · intro j + refine Fin.cases ?_ (fun b => ?_) j + · intro hij + exact ((lt_irrefl _) hij).elim + · intro _hij + simp only [Fin.val_zero, Fin.val_succ, Nat.sub_zero, Nat.add_sub_cancel] + rw [mean_word_cons_head] + change mean (fun d : D => mean (fun p : Fin (n + 1) → D => + bit (bad (v, d) = true) * bit (bad (edgeAt G n (next G v d, p) b) = true))) = + markedStep G bad (iterateOperator G b.val (edgeProfile bad)) v + calc + _ = mean (fun d : D => bit (bad (v, d) = true) * + iterateOperator G b.val (edgeProfile bad) (next G v d)) := by + congr 1 + funext d + rw [mean_mul_left, word_hit_mean] + _ = _ := mean_marked_bit G bad _ v + · intro j + refine Fin.cases ?_ (fun b => ?_) j + · intro hij + exact (Nat.not_lt_zero _ hij).elim + · intro hij + have hab : a < b := Nat.lt_of_succ_lt_succ hij + simp only [Fin.val_succ, Nat.add_sub_add_right] + rw [mean_word_cons_head] + change mean (fun d : D => mean (fun p : Fin (n + 1) → D => + bit (bad (edgeAt G n (next G v d, p) a) = true) * + bit (bad (edgeAt G n (next G v d, p) b) = true))) = + averagingOperator G (iterateOperator G a.val (markedStep G bad + (iterateOperator G (b.val - a.val - 1) (edgeProfile bad)))) v + calc + _ = mean (fun d : D => iterateOperator G a.val (markedStep G bad + (iterateOperator G (b.val - a.val - 1) (edgeProfile bad))) (next G v d)) := by + congr 1 + funext d + exact ih (next G v d) a b hab + _ = _ := rfl + +theorem hit_mean [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + (G : PortGraph V D) (bad : V × D → Bool) (n : Nat) (k : Fin (n + 1)) : + mean (fun w : Walk V D (n + 1) => bit (bad (edgeAt G n w k) = true)) = + edgeDensity bad := by + calc + _ = mean (fun v : V => mean (fun p : Fin (n + 1) → D => + bit (bad (edgeAt G n (v, p) k) = true))) := + mean_prod (A := V) (B := Fin (n + 1) → D) + (fun w => bit (bad (edgeAt G n w k) = true)) + _ = mean (iterateOperator G k.val (edgeProfile bad)) := by + congr 1 + funext v + exact word_hit_mean G bad n v k + _ = mean (edgeProfile bad) := mean_iterate G k.val _ + _ = _ := rfl + +theorem pair_hit_mean [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + (G : PortGraph V D) (bad : V × D → Bool) (n : Nat) + (i j : Fin (n + 1)) (hij : i < j) : + mean (fun w : Walk V D (n + 1) => bit (bad (edgeAt G n w i) = true) * + bit (bad (edgeAt G n w j) = true)) = returnMass G bad (j.val - i.val - 1) := by + calc + _ = mean (fun v : V => mean (fun p : Fin (n + 1) → D => + bit (bad (edgeAt G n (v, p) i) = true) * + bit (bad (edgeAt G n (v, p) j) = true))) := + mean_prod (A := V) (B := Fin (n + 1) → D) + (fun w => bit (bad (edgeAt G n w i) = true) * + bit (bad (edgeAt G n w j) = true)) + _ = mean (iterateOperator G i.val (markedStep G bad + (iterateOperator G (j.val - i.val - 1) (edgeProfile bad)))) := by + congr 1 + funext v + exact word_pair_hit_mean G bad n v i j hij + _ = mean (markedStep G bad + (iterateOperator G (j.val - i.val - 1) (edgeProfile bad))) := mean_iterate G i.val _ + _ = _ := rfl + +theorem pair_event_mean [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + (G : PortGraph V D) (bad : V × D → Bool) (n : Nat) + (i j : Fin (n + 1)) (hij : i < j) : + mean (fun w : Walk V D (n + 1) => + bit (bad (edgeAt G n w i) = true ∧ bad (edgeAt G n w j) = true)) = + returnMass G bad (j.val - i.val - 1) := by + simpa only [PoweringMoment.bit_mul] using pair_hit_mean G bad n i j hij + +end IndependentSetsGames.Foundations.PCP.PoweringReturn + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringRowData.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringRowData.lean new file mode 100644 index 0000000000000000000000000000000000000000..70a5224a71401540f76c7a21895e24b451454f41 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringRowData.lean @@ -0,0 +1,332 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringTables +import OAI.Combinatorics.IndependentSets.Machines.Block + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringRowData + +open IndependentSetsGames.Foundations.Complexity +open Turing +open PoweringMachineRow MachineFixedBlockMap +open PoweringWalks PoweringLabels PoweringAddresses PoweringReach +open PoweringOpinionTables PoweringEnumeration + +variable {vertices d : Nat} + +theorem firstMatch_of_first {S : Nat} (mask : Fin S → Bool) (i : Fin S) + (hi : mask i = true) (hfirst : ∀ j : Fin S, j.val < i.val → mask j = false) : + firstMatch mask = some i := by + unfold firstMatch + apply List.find?_ofFn_eq_some.mpr + refine ⟨hi, i, rfl, ?_⟩ + intro j hj + change ¬mask j = true + simp [hfirst j hj] + +theorem firstMatch_firstIndex {X : Type*} (p : X → Prop) [DecidablePred p] + (xs : List X) (h : ∃ a ∈ xs, p a) : + firstMatch (fun i : Fin xs.length => decide (p (xs.get i))) = + some (firstIndex p xs h) := by + apply firstMatch_of_first + · exact decide_eq_true (firstIndex_matches p xs h) + · intro j hj + exact decide_eq_false (firstIndex_is_first p xs h j hj) + +def endpointMask (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center target : Fin vertices) (i : AddressIndex d t) : Bool := + decide ((wordToBall G t center ((allAddresses d t).get i)).val = target) + +theorem firstMatch_endpointMask (G : PortGraph (Fin vertices) (Fin d)) (t : Nat) + (center : Fin vertices) (u : Ball G t center) : + firstMatch (endpointMask G t center u.val) = some (addressIndex G t center u) := by + unfold endpointMask addressIndex + exact firstMatch_firstIndex + (fun w : PortWords (Fin d) t => (wordToBall G t center w).val = u.val) + (allAddresses d t) (by + obtain ⟨w, hw⟩ := wordToBall_surjective G t center u + exact ⟨w, mem_allAddresses d t w, congrArg Subtype.val hw⟩) + +def slotCount (d n : Nat) : Nat := (allAddresses d (n + 1)).length + +abbrev RowBuffer (d n : Nat) := Buffer (inputSize (n + 1) (slotCount d n)) + +def fixedLabelAt (d n : Nat) (a : Fin (PoweringTables.labelCount d n)) + (i : Fin (slotCount d n)) : GraphTables.Label := + decodeLabel d (n + 1) 64 a ((allAddresses d (n + 1)).get i) + +theorem fixedLabelAt_addressIndex (G : PortGraph (Fin vertices) (Fin d)) (n : Nat) + (center : Fin vertices) (u : Ball G (n + 1) center) + (a : Fin (PoweringTables.labelCount d n)) : + fixedLabelAt d n a (addressIndex G (n + 1) center u) = + decode (finitePortSelector G (n + 1) center) (decodeLabel d (n + 1) 64 a) u := by + simpa only [fixedLabelAt, labelTable_get] using + labelTable_addressIndex G (n + 1) center u (decodeLabel d (n + 1) 64 a) + +def walkData (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) + (k : Fin (n + 1)) : Field (slotCount d n) → Bool + | .inl (a, b) => PortTables.accepts input (edgeAt (PortTables.portGraph input) n w k) a b + | .inr (.inl i) => endpointMask (PortTables.portGraph input) (n + 1) w.1 + (edgeAt (PortTables.portGraph input) n w k).1 i + | .inr (.inr i) => endpointMask (PortTables.portGraph input) (n + 1) + (endpoint (PortTables.portGraph input) w) + ((PortTables.portGraph input).rot (edgeAt (PortTables.portGraph input) n w k)).1 i + +def walkBits (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) : RowBuffer d n := + packData (walkData input n w) + +@[simp] theorem basePredicate_walkBits (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) + (a b : GraphTables.Label) : + basePredicate (walkBits input n w) k a b = + PortTables.accepts input (edgeAt (PortTables.portGraph input) n w k) a b := by + simp [basePredicate, walkBits, walkData] + +@[simp] theorem leftMatches_walkBits (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) : + leftMatches (walkBits input n w) k = endpointMask (PortTables.portGraph input) + (n + 1) w.1 (edgeAt (PortTables.portGraph input) n w k).1 := by + funext i + simp [leftMatches, walkBits, walkData] + +@[simp] theorem rightMatches_walkBits (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) : + rightMatches (walkBits input n w) k = endpointMask (PortTables.portGraph input) + (n + 1) (endpoint (PortTables.portGraph input) w) + ((PortTables.portGraph input).rot (edgeAt (PortTables.portGraph input) n w k)).1 := by + funext i + simp [rightMatches, walkBits, walkData] + +theorem firstMatch_walkBits_left (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) : + firstMatch (leftMatches (walkBits input n w) k) = some + (addressIndex (PortTables.portGraph input) (n + 1) w.1 + (tailFromStart (PortTables.portGraph input) n w k)) := by + rw [leftMatches_walkBits] + simpa only [tailFromStart_val, slotCount] using + firstMatch_endpointMask (PortTables.portGraph input) (n + 1) w.1 + (tailFromStart (PortTables.portGraph input) n w k) + +theorem firstMatch_walkBits_right (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) : + firstMatch (rightMatches (walkBits input n w) k) = some + (addressIndex (PortTables.portGraph input) (n + 1) + (endpoint (PortTables.portGraph input) w) + (headFromEnd (PortTables.portGraph input) n w k)) := by + rw [rightMatches_walkBits] + simpa only [headFromEnd_val, slotCount] using + firstMatch_endpointMask (PortTables.portGraph input) (n + 1) + (endpoint (PortTables.portGraph input) w) (headFromEnd (PortTables.portGraph input) n w k) + +theorem edgeAccept_walkBits (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) + (a b : Fin (PoweringTables.labelCount d n)) : + edgeAccept (fixedLabelAt d n) (walkBits input n w) k a b = + PortTables.accepts input (edgeAt (PortTables.portGraph input) n w k) + (decode (finitePortSelector (PortTables.portGraph input) (n + 1) w.1) + (decodeLabel d (n + 1) 64 a) (tailFromStart (PortTables.portGraph input) n w k)) + (decode (finitePortSelector (PortTables.portGraph input) (n + 1) + (endpoint (PortTables.portGraph input) w)) + (decodeLabel d (n + 1) 64 b) (headFromEnd (PortTables.portGraph input) n w k)) := by + simp only [edgeAccept, firstMatch_walkBits_left, firstMatch_walkBits_right, + basePredicate_walkBits, fixedLabelAt_addressIndex] + +theorem rowAccept_walkBits (input : PortTables.Table vertices d) (n : Nat) + (w : Walk (Fin vertices) (Fin d) (n + 1)) + (a b : Fin (PoweringTables.labelCount d n)) : + rowAccept (fixedLabelAt d n) (walkBits input n w) a b = + rowsAccepts (PortTables.accepts input) (walkRows (PortTables.portGraph input) n w) + (labelTable (decodeLabel d (n + 1) 64 a)) + (labelTable (decodeLabel d (n + 1) 64 b)) := by + rw [rowsAccepts_walkRows] + apply Bool.eq_iff_iff.mpr + simp only [rowAccept_eq_true, PoweringTest.pathAccepts_eq_true_iff, edgeAccept_walkBits] + +def transposeField {S : Nat} : Field S → Field S + | .inl (a, b) => .inl (b, a) + | .inr (.inl i) => .inr (.inr i) + | .inr (.inr i) => .inr (.inl i) + +def transposeBits {t S : Nat} (bits : Buffer (inputSize t S)) : Buffer (inputSize t S) := + packData fun k field => bits (inputEquiv t S (k, transposeField field)) + +@[simp] theorem basePredicate_transposeBits {t S : Nat} + (bits : Buffer (inputSize t S)) (k : Fin t) (a b : GraphTables.Label) : + basePredicate (transposeBits bits) k a b = basePredicate bits k b a := by + simp [basePredicate, transposeBits, transposeField] + +@[simp] theorem leftMatches_transposeBits {t S : Nat} + (bits : Buffer (inputSize t S)) (k : Fin t) : + leftMatches (transposeBits bits) k = rightMatches bits k := by + funext i + simp [leftMatches, rightMatches, transposeBits, transposeField] + +@[simp] theorem rightMatches_transposeBits {t S : Nat} + (bits : Buffer (inputSize t S)) (k : Fin t) : + rightMatches (transposeBits bits) k = leftMatches bits k := by + funext i + simp [leftMatches, rightMatches, transposeBits, transposeField] + +theorem edgeAccept_transposeBits {t S q : Nat} + (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (k : Fin t) (a b : Fin q) : + edgeAccept labelAt (transposeBits bits) k a b = edgeAccept labelAt bits k b a := by + simp only [edgeAccept, leftMatches_transposeBits, rightMatches_transposeBits] + cases firstMatch (leftMatches bits k) <;> + cases firstMatch (rightMatches bits k) <;> + simp + +theorem rowAccept_transposeBits {t S q : Nat} + (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (a b : Fin q) : + rowAccept labelAt (transposeBits bits) a b = rowAccept labelAt bits b a := by + apply Bool.eq_iff_iff.mpr + simp only [rowAccept_eq_true, edgeAccept_transposeBits] + +def rowBits (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : RowBuffer d n := + if e.1 then transposeBits (walkBits input n e.2) else walkBits input n e.2 + +def rowData (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) + (k : Fin (n + 1)) (field : Field (slotCount d n)) : Bool := + walkData input n e.2 k (if e.1 then transposeField field else field) + +theorem rowBits_packData (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + rowBits input n e = packData (rowData input n e) := by + rcases e with ⟨direction, w⟩ + cases direction <;> funext i <;> + simp [rowBits, rowData, transposeBits, walkBits, packData] + +@[simp] theorem rowBits_field (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) + (k : Fin (n + 1)) (field : Field (slotCount d n)) : + rowBits input n e (inputEquiv (n + 1) (slotCount d n) (k, field)) = + rowData input n e k field := by + rw [rowBits_packData, packData_inputEquiv] + +theorem rowAccept_rowBits (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) + (a b : Fin (PoweringTables.labelCount d n)) : + rowAccept (fixedLabelAt d n) (rowBits input n e) a b = + PoweringTables.rowAccepts input n e a b := by + rcases e with ⟨direction, w⟩ + cases direction <;> + simp only [rowBits, Bool.false_eq_true, ite_false, ite_true, + rowAccept_transposeBits, rowAccept_walkBits, PoweringTables.rowAccepts] + +theorem rowBlock_at_rowBits (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) + (a b : Fin (PoweringTables.labelCount d n)) : + rowBlock (fixedLabelAt d n) (rowBits input n e) + (GenericGraphTables.relationIndex (PoweringTables.labelCount d n) (a, b)) = + PoweringTables.rowAccepts input n e a b := by + rw [rowBlock_at, rowAccept_rowBits] + +def dataWords (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : List Nat := + (List.ofFn (rowBits input n e)).map GraphTables.bitWord + +def dataTape (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : List Bool := + encodeWords (dataWords input n e) + +theorem dataTape_eq (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + dataTape input n e = encodeBits (List.ofFn (rowBits input n e)) := + (encodeBits_graphWords _).symm + +theorem dataWords_length (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + (dataWords input n e).length = (n + 1) * (4096 + (slotCount d n + slotCount d n)) := by + rw [dataWords, List.length_map] + simpa only [inputSize] using (List.length_ofFn (f := rowBits input n e)) + +theorem dataTape_length_le (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + (dataTape input n e).length ≤ 2 * inputSize (n + 1) (slotCount d n) := by + rw [dataTape_eq] + simpa only [List.length_ofFn] using encodeBits_length_le (List.ofFn (rowBits input n e)) + +def emittedRelation (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + GenericGraphTables.RelationTable (PoweringTables.labelCount d n) := + Vector.ofFn (rowBlock (fixedLabelAt d n) (rowBits input n e)) + +theorem emittedRelation_eq (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + emittedRelation input n e = GenericGraphTables.relationOf (PoweringTables.rowAccepts input n e) := by + unfold emittedRelation GenericGraphTables.relationOf + apply congrArg Vector.ofFn + funext i + exact rowAccept_rowBits input n e _ _ + +theorem rowBlock_unary (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + encodeBits (List.ofFn (rowBlock (fixedLabelAt d n) (rowBits input n e))) = + encodeWords (GenericGraphTables.relationWords (emittedRelation input n e)) := by + have hbit : GraphTables.bitWord = GenericGraphTables.bitWord := by + funext b + cases b <;> rfl + have h := encodeBits_graphWords + (List.ofFn (rowBlock (fixedLabelAt d n) (rowBits input n e))) + rw [hbit] at h + simpa only [emittedRelation, GenericGraphTables.relationWords, Vector.toList_ofFn] using h + +theorem emittedRelation_table (input : PortTables.Table vertices d) (n : Nat) + (i : Fin (PoweringTables.dartCount vertices d n)) : + emittedRelation input n (decodeDart vertices d n i) = + (PoweringTables.table input n).rows[i].relation := by + apply Vector.ext + intro j hj + have h := PoweringTables.table_accepts input n i + ((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).1 + ((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).2 + have hindex : GenericGraphTables.relationIndex (PoweringTables.labelCount d n) + (((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).1, + ((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).2) = + ⟨j, hj⟩ := by + change GenericGraphTables.relationIndex (PoweringTables.labelCount d n) + ((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩) = _ + exact Equiv.apply_symm_apply _ _ + simp only [GenericGraphTables.acceptsAt, GenericGraphTables.relationAt, hindex, + Fin.getElem_fin] at h + simp only [emittedRelation, Vector.getElem_ofFn] + change rowBlock (fixedLabelAt d n) (rowBits input n (decodeDart vertices d n i)) ⟨j, hj⟩ = + (PoweringTables.table input n).rows[i].relation[j] + change rowAccept (fixedLabelAt d n) (rowBits input n (decodeDart vertices d n i)) + ((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).1 + ((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).2 = _ + rw [rowAccept_rowBits] + exact h.symm + +theorem rowBlock_unary_table (input : PortTables.Table vertices d) (n : Nat) + (i : Fin (PoweringTables.dartCount vertices d n)) : + encodeBits (List.ofFn (rowBlock (fixedLabelAt d n) + (rowBits input n (decodeDart vertices d n i)))) = + encodeWords (GenericGraphTables.relationWords (PoweringTables.table input n).rows[i].relation) := by + rw [rowBlock_unary, emittedRelation_table] + +def tableRowMachineInTime (input : PortTables.Table vertices d) (n : Nat) + (i : Fin (PoweringTables.dartCount vertices d n)) (suffix : List Bool) + (register : RowBuffer d n) (tapes : Bool → List Bool) + (hinput : tapes false = dataTape input n (decodeDart vertices d n i) ++ suffix) : + StateTransition.EvalsToInTime (PoweringMachineRow.machine (t := n + 1) (fixedLabelAt d n)).step + ⟨some (), ((), register), tapes⟩ + (some ⟨none, ((), emptyBuffer (inputSize (n + 1) (slotCount d n))), + Function.update (Function.update tapes false suffix) true + (encodeWords (GenericGraphTables.relationWords + (PoweringTables.table input n).rows[i].relation) ++ tapes true)⟩) 1 := by + have hinput' : tapes false = + encodeBits (List.ofFn (rowBits input n (decodeDart vertices d n i))) ++ suffix := by + simpa only [dataTape_eq] using hinput + have h := PoweringMachineRow.machineInTime (fixedLabelAt d n) + (rowBits input n (decodeDart vertices d n i)) suffix register tapes hinput' + simpa only [rowBlock_unary_table] using h + +end IndependentSetsGames.Foundations.PCP.PoweringRowData + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTableLayout.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTableLayout.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3a3cc269d657bb83f3ab8ac7b4ca45da2ff214e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTableLayout.lean @@ -0,0 +1,145 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringTableLayout + +open IndependentSetsGames.Foundations.Complexity +open PoweringTables PoweringEnumeration + +def blockSize (d n : Nat) : Nat := 2 * d ^ (n + 1) + +theorem dartCount_eq_vertex_blocks (vertices d n : Nat) : + dartCount vertices d n = vertices * blockSize d n := by + unfold dartCount blockSize + ac_rfl + +def blockIndex {vertices : Nat} (d n : Nat) (v : Fin vertices) + (j : Fin (blockSize d n)) : Fin (dartCount vertices d n) := + Fin.cast (dartCount_eq_vertex_blocks vertices d n).symm + (finProdFinEquiv (v, j)) + +@[simp] theorem blockIndex_val {vertices : Nat} (d n : Nat) (v : Fin vertices) + (j : Fin (blockSize d n)) : + (blockIndex d n v j).val = blockSize d n * v.val + j.val := by + change j.val + blockSize d n * v.val = blockSize d n * v.val + j.val + exact Nat.add_comm _ _ + +theorem blockIndex_eq_encodeDart {vertices : Nat} (d n : Nat) (v : Fin vertices) + (p : Fin (n + 1) → Fin d) (direction : Bool) : + blockIndex d n v (dartBlockEquiv d n (p, direction)) = + encodeDart vertices d n (direction, (v, p)) := by + apply Fin.ext + change (dartBlockEquiv d n (p, direction)).val + blockSize d n * v.val = + (dartEquiv vertices d n (direction, (v, p))).val + rw [dartEquiv_val, dartBlockEquiv_val] + unfold blockSize + omega + +def vertexRows {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) + (v : Fin vertices) : + List (GenericGraphTables.DartRow (labelCount d n) vertices (dartCount vertices d n)) := + List.ofFn (fun j : Fin (blockSize d n) => (table input n).rows[blockIndex d n v j]) + +def vertexRowWords {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) + (v : Fin vertices) : List Nat := + (vertexRows input n v).flatMap GenericGraphTables.rowWords + +def vertexRowBits {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) + (v : Fin vertices) : List Bool := + encodeWords (vertexRowWords input n v) + +@[simp] theorem vertexRows_length {vertices d : Nat} + (input : PortTables.Table vertices d) (n : Nat) (v : Fin vertices) : + (vertexRows input n v).length = blockSize d n := by + exact List.length_ofFn + +private theorem vector_toList_ofFn {α : Type*} {m : Nat} (rows : Vector α m) : + rows.toList = List.ofFn (fun i : Fin m => rows[i]) := by + apply List.ext_getElem + · simp + · intro i hi₁ hi₂ + simp + +private theorem vector_blocks {α : Type*} {m vertices width : Nat} + (sameCount : m = vertices * width) (rows : Vector α m) : + rows.toList = (List.finRange vertices).flatMap (fun v => + List.ofFn (fun j : Fin width => + rows[Fin.cast sameCount.symm (finProdFinEquiv (v, j))])) := by + have atIndex (v : Fin vertices) (j : Fin width) + (h : v.val * width + j.val < vertices * width) : + (⟨v.val * width + j.val, h⟩ : Fin (vertices * width)) = + finProdFinEquiv (v, j) := by + apply Fin.ext + simp [finProdFinEquiv, Nat.add_comm, Nat.mul_comm] + rw [vector_toList_ofFn rows, + List.ofFn_congr sameCount (fun i : Fin m => rows[i]), List.ofFn_mul] + simp only [atIndex, List.finRange, List.flatMap_def, List.map_ofFn] + rfl + +theorem rowList_eq_vertexRows {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) : + GenericGraphTables.rowList (table input n) = + (List.finRange vertices).flatMap (vertexRows input n) := by + exact vector_blocks (dartCount_eq_vertex_blocks vertices d n) (table input n).rows + +theorem outputWords_vertexRows {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) : + GenericGraphTables.tableWords (table input n) = + [vertices, dartCount vertices d n] ++ + (List.finRange vertices).flatMap (vertexRowWords input n) := by + change [vertices, dartCount vertices d n] ++ + (GenericGraphTables.rowList (table input n)).flatMap GenericGraphTables.rowWords = _ + rw [rowList_eq_vertexRows] + exact congrArg ([vertices, dartCount vertices d n] ++ ·) List.flatMap_assoc + +theorem encodeWords_flatMap {α : Type*} (items : List α) + (words : α → List Nat) : + encodeWords (items.flatMap words) = + items.flatMap (fun item => encodeWords (words item)) := by + induction items with + | nil => rfl + | cons item rest ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem outputBits_vertexRows {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) : + outputBits input n = encodeWords [vertices, dartCount vertices d n] ++ + (List.finRange vertices).flatMap (vertexRowBits input n) := by + unfold outputBits GenericGraphTables.tableBits + rw [outputWords_vertexRows, encodeWords_append, encodeWords_flatMap] + rfl + +theorem vertexRowWords_length {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (v : Fin vertices) : + (vertexRowWords input n v).length = + (labelCount d n * labelCount d n + 2) * blockSize d n := by + unfold vertexRowWords + rw [GenericGraphTables.rowsWords_length, vertexRows_length] + +theorem vertexRowBits_length_ge {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (v : Fin vertices) : + (labelCount d n * labelCount d n + 2) * blockSize d n ≤ + (vertexRowBits input n v).length := by + unfold vertexRowBits + rw [encodeWords_length, vertexRowWords_length] + omega + +theorem vertexRowBits_length_le {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (v : Fin vertices) : + (vertexRowBits input n v).length ≤ + blockSize d n * + (vertices + dartCount vertices d n + 2 * (labelCount d n * labelCount d n)) := by + have h := GenericGraphTables.rowsBits_length_le (vertexRows input n v) + rw [vertexRows_length] at h + exact h + +theorem outputHeader_length (vertices d n : Nat) : + (encodeWords [vertices, dartCount vertices d n]).length = + vertices + dartCount vertices d n + 2 := by + simp only [encodeWords, List.length_append, encodeWord_length, List.length_nil] + omega + +end IndependentSetsGames.Foundations.PCP.PoweringTableLayout + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTableSemantics.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTableSemantics.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c3e2ba59a65bc8dca553254eae5300df7a3e8da --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTableSemantics.lean @@ -0,0 +1,168 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringTableSemantics + +open PoweringWalks PoweringLabels PoweringAddresses PoweringEnumeration PoweringTables + +abbrev RawLabeling (vertices d n : Nat) := + Fin vertices → PaddedLabel (Fin d) (n + 1) (Fin 64) + +abbrev EncodedLabeling (vertices d n : Nat) := + Fin vertices → Fin (labelCount d n) + +def encodeLabeling {vertices : Nat} (d n : Nat) (labels : RawLabeling vertices d n) : + EncodedLabeling vertices d n := + fun v => encodeLabel d (n + 1) 64 (labels v) + +def decodeLabeling {vertices : Nat} (d n : Nat) (labels : EncodedLabeling vertices d n) : + RawLabeling vertices d n := + fun v => decodeLabel d (n + 1) 64 (labels v) + +@[simp] theorem decodeLabeling_encodeLabeling {vertices : Nat} (d n : Nat) + (labels : RawLabeling vertices d n) : + decodeLabeling d n (encodeLabeling d n labels) = labels := by + funext v + exact decodeLabel_encodeLabel d (n + 1) 64 (labels v) + +@[simp] theorem encodeLabeling_decodeLabeling {vertices : Nat} (d n : Nat) + (labels : EncodedLabeling vertices d n) : + encodeLabeling d n (decodeLabeling d n labels) = labels := by + funext v + exact encodeLabel_decodeLabel d (n + 1) 64 (labels v) + +theorem edgeSatisfied_encoded {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (labels : RawLabeling vertices d n) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) : + (GenericGraphTables.semantics (table input n)).edgeSatisfied + (encodeLabeling (vertices := vertices) d n labels) (encodeDart vertices d n e) = + (mathematicalGraph input n).edgeSatisfied labels e := by + rw [semantics_table] + unfold encodeLabeling encodeLabel encodeDart + exact + GenericGraphTables.enumeratedGraph_edgeSatisfied (mathematicalGraph input n) + (Equiv.refl _) (dartEquiv vertices d n) (paddedLabelEquiv d (n + 1) 64) labels e + +theorem edgeSatisfied_decoded {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (labels : EncodedLabeling vertices d n) (i : Fin (dartCount vertices d n)) : + (GenericGraphTables.semantics (table input n)).edgeSatisfied labels i = + (mathematicalGraph input n).edgeSatisfied (decodeLabeling d n labels) + (decodeDart vertices d n i) := by + simpa only [encodeLabeling_decodeLabeling d n labels, + encodeDart_decodeDart vertices d n i] using + edgeSatisfied_encoded input n (decodeLabeling d n labels) (decodeDart vertices d n i) + +theorem edgeSatisfied_eq_path {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (labels : EncodedLabeling vertices d n) (direction : Bool) + (w : Walk (Fin vertices) (Fin d) (n + 1)) : + (GenericGraphTables.semantics (table input n)).edgeSatisfied labels + (encodeDart vertices d n (direction, w)) = + PoweringTest.pathAccepts (PortTables.portGraph input) (PortTables.accepts input) n + (finitePortSelector (PortTables.portGraph input) (n + 1)) w + (decodeLabeling d n labels w.1) + (decodeLabeling d n labels (endpoint (PortTables.portGraph input) w)) := by + rw [edgeSatisfied_decoded input n labels (encodeDart vertices d n (direction, w)), + decodeDart_encodeDart vertices d n (direction, w)] + exact PoweringTest.poweredGraph_edgeSatisfied (PortTables.portGraph input) + (PortTables.accepts input) n (finitePortSelector (PortTables.portGraph input) (n + 1)) + (decodeLabeling d n labels) direction w + +theorem rejectionCount_encoded {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (labels : RawLabeling vertices d n) : + (GenericGraphTables.semantics (table input n)).rejectionCount + (encodeLabeling (vertices := vertices) d n labels) = + (mathematicalGraph input n).rejectionCount labels := by + rw [semantics_table] + unfold encodeLabeling encodeLabel + exact + GenericGraphTables.enumeratedGraph_rejectionCount (mathematicalGraph input n) + (Equiv.refl _) (dartEquiv vertices d n) (paddedLabelEquiv d (n + 1) 64) labels + +theorem rejectionCount_decoded {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (labels : EncodedLabeling vertices d n) : + (GenericGraphTables.semantics (table input n)).rejectionCount labels = + (mathematicalGraph input n).rejectionCount (decodeLabeling d n labels) := by + simpa only [encodeLabeling_decodeLabeling d n labels] using + rejectionCount_encoded input n (decodeLabeling d n labels) + +theorem card_darts_eq_table {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) : + Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) = (table input n).darts := by + change Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) = + 2 * vertices * d ^ (n + 1) + simpa only [Fintype.card_fin] using Fintype.card_congr (dartEquiv vertices d n) + +theorem satisfiable_iff {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) : + (GenericGraphTables.semantics (table input n)).Satisfiable ↔ + (mathematicalGraph input n).Satisfiable := by + constructor + · rintro ⟨labels, satisfies⟩ + refine ⟨decodeLabeling d n labels, ?_⟩ + intro e + have h := edgeSatisfied_encoded input n (decodeLabeling d n labels) e + rw [encodeLabeling_decodeLabeling (vertices := vertices) d n labels] at h + exact h.symm.trans (satisfies (encodeDart vertices d n e)) + · rintro ⟨labels, satisfies⟩ + refine ⟨encodeLabeling d n labels, ?_⟩ + intro i + have h := edgeSatisfied_encoded input n labels (decodeDart vertices d n i) + rw [encodeDart_decodeDart vertices d n i] at h + exact h.trans (satisfies (decodeDart vertices d n i)) + +theorem preserves_satisfiability {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (h : (PortTables.baseGraph input).Satisfiable) : + (GenericGraphTables.semantics (table input n)).Satisfiable := by + apply (satisfiable_iff input n).mpr + exact PoweringTest.preserves_satisfiability (PortTables.portGraph input) + (PortTables.accepts input) (PortTables.accepts_rotation input) n + (finitePortSelector (PortTables.portGraph input) (n + 1)) h + +theorem path_rejection_mean_eq_table_fraction {vertices d : Nat} + (input : PortTables.Table vertices d) (n : Nat) (labels : EncodedLabeling vertices d n) : + SpectralReturn.mean (fun w : Walk (Fin vertices) (Fin d) (n + 1) => + PoweringMoment.bit + (PoweringTest.pathAccepts (PortTables.portGraph input) (PortTables.accepts input) n + (finitePortSelector (PortTables.portGraph input) (n + 1)) w + (decodeLabeling d n labels w.1) + (decodeLabeling d n labels (endpoint (PortTables.portGraph input) w)) = false)) = + ((GenericGraphTables.semantics (table input n)).rejectionCount labels : ℝ) / + ((table input n).darts : ℝ) := by + rw [rejectionCount_decoded input n labels, ← card_darts_eq_table input n] + exact PoweringCounting.path_rejection_mean_eq_count (PortTables.portGraph input) + (PortTables.accepts input) n (finitePortSelector (PortTables.portGraph input) (n + 1)) + (decodeLabeling d n labels) + +theorem uniform_count_gap_iff {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (epsilon : ℝ) : + (∀ labels : EncodedLabeling vertices d n, + epsilon * ((table input n).darts : ℝ) ≤ + ((GenericGraphTables.semantics (table input n)).rejectionCount labels : ℝ)) ↔ + (∀ labels : RawLabeling vertices d n, + epsilon * (Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) : ℝ) ≤ + ((mathematicalGraph input n).rejectionCount labels : ℝ)) := by + constructor + · intro h labels + have hlabels := h (encodeLabeling d n labels) + rw [rejectionCount_encoded input n labels, ← card_darts_eq_table input n] at hlabels + exact hlabels + · intro h labels + rw [rejectionCount_decoded input n labels] + have hlabels := h (decodeLabeling d n labels) + rw [card_darts_eq_table input n] at hlabels + exact hlabels + +theorem uniform_count_gap {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) (epsilon : ℝ) + (hgap : ∀ labels : RawLabeling vertices d n, + epsilon * (Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) : ℝ) ≤ + ((mathematicalGraph input n).rejectionCount labels : ℝ)) : + ∀ labels : EncodedLabeling vertices d n, + epsilon * ((table input n).darts : ℝ) ≤ + ((GenericGraphTables.semantics (table input n)).rejectionCount labels : ℝ) := + (uniform_count_gap_iff input n epsilon).mpr hgap + +end IndependentSetsGames.Foundations.PCP.PoweringTableSemantics + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e2e4aeb2e7129336ac1822e2908501c0fafa0bd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTables.lean @@ -0,0 +1,216 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PortTables +import OAI.Combinatorics.IndependentSets.Expansion.PoweringEnumeration +import OAI.Combinatorics.IndependentSets.Expansion.PoweringOpinionTables +import OAI.Combinatorics.IndependentSets.PCP.GenericGraphTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringTables + +open PoweringWalks PoweringLabels PoweringAddresses PoweringEnumeration + +def labelCount (d n : Nat) : Nat := 64 ^ addressCount d (n + 1) + +def dartCount (vertices d n : Nat) : Nat := 2 * vertices * d ^ (n + 1) + +def mathematicalGraph {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) : + ConstraintGraph (Fin vertices) (PoweringTest.Dart (Fin vertices) (Fin d) n) + (PaddedLabel (Fin d) (n + 1) (Fin 64)) := + PoweringTest.poweredGraph (PortTables.portGraph input) (PortTables.accepts input) n + (finitePortSelector (PortTables.portGraph input) (n + 1)) + +def rowAccepts {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) + (a b : Fin (labelCount d n)) : Bool := + let rows := PoweringOpinionTables.walkRows (PortTables.portGraph input) n e.2 + let left := PoweringOpinionTables.labelTable (decodeLabel d (n + 1) 64 a) + let right := PoweringOpinionTables.labelTable (decodeLabel d (n + 1) 64 b) + if e.1 then PoweringOpinionTables.rowsAccepts (PortTables.accepts input) rows right left + else PoweringOpinionTables.rowsAccepts (PortTables.accepts input) rows left right + +theorem rowAccepts_eq {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) + (e : PoweringTest.Dart (Fin vertices) (Fin d) n) + (a b : Fin (labelCount d n)) : + rowAccepts input n e a b = (mathematicalGraph input n).accepts e + (decodeLabel d (n + 1) 64 a) (decodeLabel d (n + 1) 64 b) := by + rcases e with ⟨direction, w⟩ + cases direction <;> + simp only [rowAccepts, mathematicalGraph, PoweringTest.poweredGraph, Bool.false_eq_true, + ite_false, ite_true, PoweringOpinionTables.rowsAccepts_walkRows] + +def table {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) : + GenericGraphTables.Table (labelCount d n) := + GenericGraphTables.ofEnumeratedGraph (mathematicalGraph input n) (Equiv.refl _) + (dartEquiv vertices d n) (paddedLabelEquiv d (n + 1) 64) + +@[simp] theorem table_vertices {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) : (table input n).vertices = vertices := rfl + +@[simp] theorem table_darts {vertices d : Nat} (input : PortTables.Table vertices d) + (n : Nat) : (table input n).darts = dartCount vertices d n := rfl + +theorem semantics_table {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) : + GenericGraphTables.semantics (table input n) = + GenericGraphTables.enumeratedGraph (mathematicalGraph input n) (Equiv.refl _) + (dartEquiv vertices d n) (paddedLabelEquiv d (n + 1) 64) := + GenericGraphTables.semantics_ofGraph _ + +theorem table_accepts {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) + (i : Fin (dartCount vertices d n)) (a b : Fin (labelCount d n)) : + GenericGraphTables.acceptsAt (table input n).rows i a b = + rowAccepts input n (decodeDart vertices d n i) a b := by + change (GenericGraphTables.semantics (table input n)).accepts i a b = _ + rw [semantics_table] + exact (rowAccepts_eq input n (decodeDart vertices d n i) a b).symm + +theorem table_reverse {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) + (direction : Bool) (w : Walk (Fin vertices) (Fin d) (n + 1)) : + GenericGraphTables.reverseAt (table input n).rows (encodeDart vertices d n (direction, w)) = + encodeDart vertices d n (!direction, w) := by + change (GenericGraphTables.semantics (table input n)).reverse _ = _ + rw [semantics_table] + change dartEquiv vertices d n ((mathematicalGraph input n).reverse + ((dartEquiv vertices d n).symm (dartEquiv vertices d n (direction, w)))) = + dartEquiv vertices d n (!direction, w) + rw [(dartEquiv vertices d n).symm_apply_apply] + rfl + +def outputBits {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) : List Bool := + GenericGraphTables.tableBits (table input n) + +def transform (d n : Nat) (input : PortTables.Input d) : GenericGraphTables.Table (labelCount d n) := + table input.2 n + +end IndependentSetsGames.Foundations.PCP.PoweringTables +namespace IndependentSetsGames.Foundations.PCP.PoweringCounting + +open PoweringWalks PoweringLabels PoweringTest +open scoped BigOperators + +variable {V D A E : Type*} + +theorem constraint_rejection_mean_eq_count [Fintype E] + (H : ConstraintGraph V E A) (labels : V → A) : + SpectralReturn.mean (fun e : E => PoweringMoment.bit + (H.edgeSatisfied labels e = false)) = + (H.rejectionCount labels : ℝ) / (Fintype.card E : ℝ) := by + classical + rw [SpectralReturn.mean_eq_sum_div_card] + simp only [PoweringMoment.bit, ConstraintGraph.rejectionCount, ConstraintGraph.rejectedDarts] + apply congrArg (fun x : ℝ => x / (Fintype.card E : ℝ)) + convert (Finset.sum_boole (R := ℝ) + (fun e => H.edgeSatisfied labels e = false) Finset.univ) using 1 + try rfl + apply Finset.sum_congr rfl + intro e _ + by_cases h : H.edgeSatisfied labels e = false <;> simp [h] + +theorem constraint_rejection_lower_iff [Fintype E] + (H : ConstraintGraph V E A) (labels : V → A) + (hcard : 0 < Fintype.card E) (ε : ℝ) : + ε ≤ SpectralReturn.mean (fun e : E => PoweringMoment.bit + (H.edgeSatisfied labels e = false)) ↔ + ε * (Fintype.card E : ℝ) ≤ (H.rejectionCount labels : ℝ) := by + rw [constraint_rejection_mean_eq_count] + exact le_div_iff₀ (Nat.cast_pos.mpr hcard) + +theorem edgeDensity_eq_bit_mean [Fintype V] [Fintype D] + (bad : Edge V D → Bool) : + SpectralReturn.edgeDensity bad = + SpectralReturn.mean (fun e : Edge V D => PoweringMoment.bit (bad e = true)) := by + convert (SpectralReturn.mean_prod + (fun e : Edge V D => PoweringMoment.bit (bad e = true))).symm using 1 + try rfl + change SpectralReturn.mean (fun v => SpectralReturn.mean + (fun d => if bad (v, d) then (1 : ℝ) else 0)) = _ + apply congrArg SpectralReturn.mean + funext v + apply congrArg SpectralReturn.mean + funext d + cases bad (v, d) <;> simp [PoweringMoment.bit] + +theorem base_edgeDensity_eq_rejection_count [Fintype V] [Fintype D] + (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b) + (assignment : V → A) : + SpectralReturn.edgeDensity (decodedBad G accepts assignment) = + ((baseGraph G accepts reverse_accepts).rejectionCount assignment : ℝ) / + (Fintype.card (Edge V D) : ℝ) := by + calc + _ = SpectralReturn.mean (fun e : Edge V D => PoweringMoment.bit + (decodedBad G accepts assignment e = true)) := edgeDensity_eq_bit_mean _ + _ = SpectralReturn.mean (fun e : Edge V D => PoweringMoment.bit + ((baseGraph G accepts reverse_accepts).edgeSatisfied assignment e = false)) := by + apply congrArg SpectralReturn.mean + funext e + exact congrArg PoweringMoment.bit + (propext (decodedBad_eq_true_iff G accepts assignment e)) + _ = _ := constraint_rejection_mean_eq_count _ _ + +theorem base_count_lower_to_density [Fintype V] [Fintype D] + (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b) + (assignment : V → A) (hcard : 0 < Fintype.card (Edge V D)) (ε : ℝ) + (hcount : ε * (Fintype.card (Edge V D) : ℝ) ≤ + ((baseGraph G accepts reverse_accepts).rejectionCount assignment : ℝ)) : + ε ≤ SpectralReturn.edgeDensity (decodedBad G accepts assignment) := by + rw [base_edgeDensity_eq_rejection_count G accepts reverse_accepts assignment] + exact (le_div_iff₀ (Nat.cast_pos.mpr hcard)).2 hcount + +theorem powered_rejection_mean_eq_count [Fintype V] [Fintype D] + (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) : + SpectralReturn.mean (fun d : Dart V D n => PoweringMoment.bit + ((poweredGraph G accepts n selectors).edgeSatisfied labels d = false)) = + ((poweredGraph G accepts n selectors).rejectionCount labels : ℝ) / + (Fintype.card (Dart V D n) : ℝ) := + constraint_rejection_mean_eq_count _ _ + +theorem path_rejection_mean_eq_count [Fintype V] [Fintype D] + (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) : + SpectralReturn.mean (fun w : Walk V D (n + 1) => PoweringMoment.bit + (pathAccepts G accepts n selectors w (labels w.1) (labels (endpoint G w)) = false)) = + ((poweredGraph G accepts n selectors).rejectionCount labels : ℝ) / + (Fintype.card (Dart V D n) : ℝ) := by + rw [← rejection_mean_eq_path_mean G accepts n selectors labels] + exact powered_rejection_mean_eq_count G accepts n selectors labels + +theorem powered_density_lower_to_count [Fintype V] [Fintype D] + (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) + (hcard : 0 < Fintype.card (Dart V D n)) (ε : ℝ) + (hlower : ε ≤ SpectralReturn.mean (fun w : Walk V D (n + 1) => PoweringMoment.bit + (pathAccepts G accepts n selectors w (labels w.1) (labels (endpoint G w)) = false))) : + ε * (Fintype.card (Dart V D n) : ℝ) ≤ + ((poweredGraph G accepts n selectors).rejectionCount labels : ℝ) := by + rw [path_rejection_mean_eq_count G accepts n selectors labels] at hlower + exact (le_div_iff₀ (Nat.cast_pos.mpr hcard)).1 hlower + +theorem natCard_dart [Finite V] [Finite D] (n : Nat) : + Nat.card (Dart V D n) = 2 * Nat.card V * Nat.card D ^ (n + 1) := by + simp [Dart, Walk, Nat.card_prod, Nat.card_fun, Nat.mul_assoc] + +theorem fintypeCard_dart [Fintype V] [Fintype D] (n : Nat) : + Fintype.card (Dart V D n) = + 2 * Fintype.card V * Fintype.card D ^ (n + 1) := by + simpa only [Nat.card_eq_fintype_card] using (natCard_dart (V := V) (D := D) n) + +theorem natCard_poweredAlphabet [Finite D] [Finite A] (n : Nat) : + Nat.card (PaddedLabel D (n + 1) A) = + Nat.card A ^ (∑ j : Fin (n + 2), Nat.card D ^ j.val) := + PoweringLabels.card_paddedLabel (n + 1) + +theorem natCard_finitePortAlphabet [Finite A] (d n : Nat) : + Nat.card (PaddedLabel (Fin d) (n + 1) A) = + Nat.card A ^ (PoweringAddresses.allAddresses d (n + 1)).length := by + rw [PoweringLabels.card_paddedLabel, PoweringAddresses.length_allAddresses] + simp only [Nat.card_fin] + +end IndependentSetsGames.Foundations.PCP.PoweringCounting + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTest.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..1495700d71c66d1f35179207255b0045e991def7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringTest.lean @@ -0,0 +1,215 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringOpinions + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringTest + +open PoweringWalks PoweringLabels PoweringReach PoweringOpinions + +variable {V D A : Type*} + +def baseGraph (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b) : + ConstraintGraph V (Edge V D) A where + reverse := G.rot + reverse_involutive := G.rot_involutive + tail := Prod.fst + accepts := accepts + reverse_accepts := reverse_accepts + +def pathAccepts (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (n : Nat) (selectors : ∀ v, AddressSelector G (n + 1) v) + (w : Walk V D (n + 1)) (a b : PaddedLabel D (n + 1) A) : Bool := + decide (∀ k : Fin (n + 1), + accepts (edgeAt G n w k) + (decode (selectors w.1) a (tailFromStart G n w k)) + (decode (selectors (endpoint G w)) b (headFromEnd G n w k)) = true) + +theorem pathAccepts_eq_true_iff (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) + (n : Nat) (selectors : ∀ v, AddressSelector G (n + 1) v) + (w : Walk V D (n + 1)) (a b : PaddedLabel D (n + 1) A) : + pathAccepts G accepts n selectors w a b = true ↔ + ∀ k : Fin (n + 1), + accepts (edgeAt G n w k) + (decode (selectors w.1) a (tailFromStart G n w k)) + (decode (selectors (endpoint G w)) b (headFromEnd G n w k)) = true := by + simp [pathAccepts] + +abbrev Dart (V D : Type*) (n : Nat) := Bool × Walk V D (n + 1) + +def reverseDart (V D : Type*) (n : Nat) : Dart V D n ≃ Dart V D n where + toFun d := (!d.1, d.2) + invFun d := (!d.1, d.2) + left_inv := by + rintro ⟨b, w⟩ + cases b <;> rfl + right_inv := by + rintro ⟨b, w⟩ + cases b <;> rfl + +theorem reverseDart_involutive (V D : Type*) (n : Nat) : + Function.Involutive (reverseDart V D n) := by + rintro ⟨b, w⟩ + cases b <;> rfl + +def poweredGraph (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (n : Nat) (selectors : ∀ v, AddressSelector G (n + 1) v) : + ConstraintGraph V (Dart V D n) (PaddedLabel D (n + 1) A) where + reverse := reverseDart V D n + reverse_involutive := reverseDart_involutive V D n + tail d := if d.1 then endpoint G d.2 else d.2.1 + accepts d a b := if d.1 then pathAccepts G accepts n selectors d.2 b a + else pathAccepts G accepts n selectors d.2 a b + reverse_accepts := by + rintro ⟨direction, w⟩ a b + cases direction <;> rfl + +@[simp] theorem poweredGraph_tail_false (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) (w : Walk V D (n + 1)) : + (poweredGraph G accepts n selectors).tail (false, w) = w.1 := rfl + +@[simp] theorem poweredGraph_tail_true (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) (w : Walk V D (n + 1)) : + (poweredGraph G accepts n selectors).tail (true, w) = endpoint G w := rfl + +theorem poweredGraph_edgeSatisfied (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) + (direction : Bool) (w : Walk V D (n + 1)) : + (poweredGraph G accepts n selectors).edgeSatisfied labels (direction, w) = + pathAccepts G accepts n selectors w (labels w.1) (labels (endpoint G w)) := by + cases direction <;> rfl + +theorem rejection_mean_eq_path_mean [Fintype V] [Fintype D] + (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) : + SpectralReturn.mean (fun d : Dart V D n => PoweringMoment.bit + ((poweredGraph G accepts n selectors).edgeSatisfied labels d = false)) = + SpectralReturn.mean (fun w : Walk V D (n + 1) => PoweringMoment.bit + (pathAccepts G accepts n selectors w (labels w.1) (labels (endpoint G w)) = false)) := by + rw [SpectralReturn.mean_prod] + simp only [poweredGraph_edgeSatisfied, SpectralReturn.mean_const] + +theorem pathAccepts_honest (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (assignment : V → A) + (satisfies : ∀ e, accepts e (assignment e.1) (assignment (G.rot e).1) = true) + (w : Walk V D (n + 1)) : + pathAccepts G accepts n selectors w + (honestLabels G (n + 1) assignment w.1) + (honestLabels G (n + 1) assignment (endpoint G w)) = true := by + apply (pathAccepts_eq_true_iff G accepts n selectors w _ _).2 + intro k + simpa only [honestLabels, decode_encode, tailFromStart_val, headFromEnd_val] using + satisfies (edgeAt G n w k) + +theorem perfect_completeness (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (assignment : V → A) + (satisfies : ∀ e, accepts e (assignment e.1) (assignment (G.rot e).1) = true) : + ∀ d, (poweredGraph G accepts n selectors).edgeSatisfied + (honestLabels G (n + 1) assignment) d = true := by + rintro ⟨direction, w⟩ + rw [poweredGraph_edgeSatisfied] + exact pathAccepts_honest G accepts n selectors assignment satisfies w + +theorem preserves_satisfiability (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b) + (n : Nat) (selectors : ∀ v, AddressSelector G (n + 1) v) + (h : (baseGraph G accepts reverse_accepts).Satisfiable) : + (poweredGraph G accepts n selectors).Satisfiable := by + obtain ⟨assignment, satisfies⟩ := h + refine ⟨honestLabels G (n + 1) assignment, ?_⟩ + apply perfect_completeness G accepts n selectors assignment + intro e + exact satisfies e + +def decodedBad (G : PortGraph V D) (accepts : Edge V D → A → A → Bool) + (assignment : V → A) (e : Edge V D) : Bool := + !(accepts e (assignment e.1) (assignment (G.rot e).1)) + +theorem decodedBad_eq_true_iff (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (assignment : V → A) (e : Edge V D) : + decodedBad G accepts assignment e = true ↔ + accepts e (assignment e.1) (assignment (G.rot e).1) = false := by + simp [decodedBad] + +theorem decodedBad_rot (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) + (reverse_accepts : ∀ e a b, accepts (G.rot e) b a = accepts e a b) + (assignment : V → A) (e : Edge V D) : + decodedBad G accepts assignment (G.rot e) = decodedBad G accepts assignment e := by + have h := congrArg Bool.not + (reverse_accepts e (assignment e.1) (assignment (G.rot e).1)) + simpa only [decodedBad, G.rot_involutive e] using h + +noncomputable def witness (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) (fallback : A) + (assignment : V → A) (w : Walk V D (n + 1)) (k : Fin (n + 1)) : Prop := + decodedBad G accepts assignment (edgeAt G n w k) = true ∧ + opinionAt G (n + 1) selectors labels fallback (edgeAt G n w k).1 w.1 = + assignment (edgeAt G n w k).1 ∧ + opinionAt G (n + 1) selectors labels fallback + (G.rot (edgeAt G n w k)).1 (endpoint G w) = + assignment (G.rot (edgeAt G n w k)).1 + +theorem witness_bad (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) (fallback : A) + (assignment : V → A) (w : Walk V D (n + 1)) (k : Fin (n + 1)) + (h : witness G accepts n selectors labels fallback assignment w k) : + decodedBad G accepts assignment (edgeAt G n w k) = true := h.1 + +theorem witness_implies_path_rejection (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) (fallback : A) + (assignment : V → A) (w : Walk V D (n + 1)) (k : Fin (n + 1)) + (h : witness G accepts n selectors labels fallback assignment w k) : + pathAccepts G accepts n selectors w (labels w.1) (labels (endpoint G w)) = false := by + obtain ⟨hBad, hTail, hHead⟩ := h + have hTailDecode : + decode (selectors w.1) (labels w.1) (tailFromStart G n w k) = + assignment (edgeAt G n w k).1 := + (opinionAt_eq_decode G (n + 1) selectors labels fallback w.1 + (tailFromStart G n w k)).symm.trans hTail + have hHeadDecode : + decode (selectors (endpoint G w)) (labels (endpoint G w)) + (headFromEnd G n w k) = assignment (G.rot (edgeAt G n w k)).1 := + (opinionAt_eq_decode G (n + 1) selectors labels fallback (endpoint G w) + (headFromEnd G n w k)).symm.trans hHead + have hFalse := (decodedBad_eq_true_iff G accepts assignment (edgeAt G n w k)).1 hBad + cases hPath : pathAccepts G accepts n selectors w + (labels w.1) (labels (endpoint G w)) with + | false => rfl + | true => + have hChecked := (pathAccepts_eq_true_iff G accepts n selectors w _ _).1 hPath k + rw [hTailDecode, hHeadDecode, hFalse] at hChecked + exact False.elim (Bool.noConfusion hChecked) + +theorem witness_implies_rejection (G : PortGraph V D) + (accepts : Edge V D → A → A → Bool) (n : Nat) + (selectors : ∀ v, AddressSelector G (n + 1) v) + (labels : V → PaddedLabel D (n + 1) A) (fallback : A) + (assignment : V → A) (w : Walk V D (n + 1)) (k : Fin (n + 1)) + (h : witness G accepts n selectors labels fallback assignment w k) + (direction : Bool) : + (poweredGraph G accepts n selectors).edgeSatisfied labels (direction, w) = false := by + rw [poweredGraph_edgeSatisfied] + exact witness_implies_path_rejection G accepts n selectors labels fallback assignment w k h + +end IndependentSetsGames.Foundations.PCP.PoweringTest + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringWalks.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringWalks.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b17b832cdf55c4279c6bb3fe6d03e56b8505335 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringWalks.lean @@ -0,0 +1,266 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringWalks + +structure PortGraph (V D : Type*) where + rot : (V × D) ≃ (V × D) + rot_involutive : Function.Involutive rot + +abbrev Edge (V D : Type*) := V × D +abbrev Walk (V D : Type*) (t : Nat) := V × (Fin t → D) + +variable {V D : Type*} + +def next (G : PortGraph V D) (v : V) (d : D) : V := (G.rot (v, d)).1 + +@[simp] theorem rot_rot (G : PortGraph V D) (e : Edge V D) : + G.rot (G.rot e) = e := G.rot_involutive e + +def walkEnd (G : PortGraph V D) : V → List D → V + | v, [] => v + | v, d :: ds => walkEnd G (next G v d) ds + +@[simp] theorem walkEnd_nil (G : PortGraph V D) (v : V) : walkEnd G v [] = v := rfl + +@[simp] theorem walkEnd_cons (G : PortGraph V D) (v : V) (d : D) (ds : List D) : + walkEnd G v (d :: ds) = walkEnd G (next G v d) ds := rfl + +theorem walkEnd_append (G : PortGraph V D) (v : V) (as bs : List D) : + walkEnd G v (as ++ bs) = walkEnd G (walkEnd G v as) bs := by + induction as generalizing v with + | nil => rfl + | cons d ds ih => exact ih (next G v d) + +def splitHead (V D : Type*) (n : Nat) : + Walk V D (n + 1) ≃ ((V × D) × (Fin n → D)) where + toFun w := ((w.1, w.2 0), fun j => w.2 j.succ) + invFun z := (z.1.1, Fin.cases z.1.2 z.2) + left_inv w := by + apply Prod.ext + · rfl + funext j + exact Fin.cases rfl (fun _ => rfl) j + right_inv z := rfl + +def rotateHead (G : PortGraph V D) (n : Nat) : Walk V D (n + 1) ≃ Walk V D (n + 1) := + (splitHead V D n).trans + ((Equiv.prodCongr G.rot (Equiv.refl (Fin n → D))).trans (splitHead V D n).symm) + +@[simp] theorem rotateHead_vertex (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1)) : + (rotateHead G n w).1 = next G w.1 (w.2 0) := rfl + +@[simp] theorem rotateHead_zero (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1)) : + (rotateHead G n w).2 0 = (G.rot (w.1, w.2 0)).2 := rfl + +@[simp] theorem rotateHead_succ (G : PortGraph V D) (n : Nat) + (w : Walk V D (n + 1)) (j : Fin n) : + (rotateHead G n w).2 j.succ = w.2 j.succ := rfl + +def permutePorts {t : Nat} (σ : Fin t ≃ Fin t) : Walk V D t ≃ Walk V D t where + toFun w := (w.1, fun j => w.2 (σ j)) + invFun w := (w.1, fun j => w.2 (σ.symm j)) + left_inv w := by + apply Prod.ext + · rfl + funext j + exact congrArg w.2 (σ.apply_symm_apply j) + right_inv w := by + apply Prod.ext + · rfl + funext j + exact congrArg w.2 (σ.symm_apply_apply j) + +def wordEnd (G : PortGraph V D) : (n : Nat) → V → (Fin n → D) → V + | 0, v, _ => v + | n + 1, v, p => wordEnd G n (next G v (p 0)) (fun j => p j.succ) + +def endpoint (G : PortGraph V D) {n : Nat} (w : Walk V D n) : V := + wordEnd G n w.1 w.2 + +theorem natCard_walk [Finite V] [Finite D] (n : Nat) : + Nat.card (Walk V D n) = Nat.card V * Nat.card D ^ n := by + simp [Walk, Nat.card_prod, Nat.card_fun] + +def headTailEquiv (V D : Type*) (n : Nat) : + Walk V D (n + 1) ≃ (Walk V D n × D) where + toFun w := ((w.1, fun j => w.2 j.succ), w.2 0) + invFun z := (z.1.1, Fin.cases z.2 z.1.2) + left_inv w := by + apply Prod.ext + · rfl + · funext j + exact Fin.cases rfl (fun _ => rfl) j + right_inv z := rfl + +def advanceTail {n : Nat} (G : PortGraph V D) (w : Walk V D (n + 1)) : Walk V D n := + ((G.rot (w.1, w.2 0)).1, fun j => w.2 j.succ) + +def edgeAt (G : PortGraph V D) : + (n : Nat) → Walk V D (n + 1) → Fin (n + 1) → Edge V D + | 0, w, _ => (w.1, w.2 0) + | n + 1, w, k => Fin.cases (w.1, w.2 0) + (fun j => edgeAt G n (advanceTail G w) j) k + +def pivotEquiv (G : PortGraph V D) : + (n : Nat) → Fin (n + 1) → + (Walk V D (n + 1) ≃ (Edge V D × (Fin n → D))) + | 0, _ => splitHead V D 0 + | n + 1, k => Fin.cases (splitHead V D (n + 1)) + (fun j => (rotateHead G (n + 1)).trans + ((headTailEquiv V D (n + 1)).trans + ((Equiv.prodCongr (pivotEquiv G n j) (Equiv.refl D)).trans + (headTailEquiv (Edge V D) D n).symm))) k + +theorem pivotEquiv_fst (G : PortGraph V D) : + ∀ (n : Nat) (k : Fin (n + 1)) (w : Walk V D (n + 1)), + (pivotEquiv G n k w).1 = edgeAt G n w k := by + intro n + induction n with + | zero => intro k w; rfl + | succ n ih => + intro k w + refine Fin.cases ?_ (fun j => ?_) k + · rfl + · change (pivotEquiv G n j (advanceTail G w)).1 = + edgeAt G n (advanceTail G w) j + exact ih j (advanceTail G w) + +theorem edgeAt_port (G : PortGraph V D) : + ∀ (n : Nat) (w : Walk V D (n + 1)) (k : Fin (n + 1)), + (edgeAt G n w k).2 = w.2 k := by + intro n + induction n with + | zero => + intro w k + have hk : k = 0 := Fin.eq_zero k + subst k + rfl + | succ n ih => + intro w k + refine Fin.cases ?_ (fun j => ?_) k + · rfl + · exact ih (advanceTail G w) j + +theorem pivotEquiv_zero_apply (G : PortGraph V D) (n : Nat) (w : Walk V D (n + 1)) : + pivotEquiv G n 0 w = ((w.1, w.2 0), fun j => w.2 j.succ) := by + cases n <;> rfl + +theorem pivotEquiv_succ_apply (G : PortGraph V D) + (n : Nat) (k : Fin (n + 1)) (w : Walk V D (n + 2)) : + pivotEquiv G (n + 1) k.succ w = + ((pivotEquiv G n k (advanceTail G w)).1, + Fin.cases (G.rot (w.1, w.2 0)).2 + (pivotEquiv G n k (advanceTail G w)).2) := rfl + +def projectedFiberEquiv {X E R : Type*} (e : X ≃ E × R) (f : X → E) + (he : ∀ x, (e x).1 = f x) (a : E) : {x // f x = a} ≃ R where + toFun x := (e x.val).2 + invFun r := ⟨e.symm (a, r), by + exact (he _).symm.trans (congrArg Prod.fst (e.apply_symm_apply (a, r)))⟩ + left_inv x := by + apply Subtype.ext + apply e.injective + rw [e.apply_symm_apply] + exact Prod.ext ((he x.val).trans x.property).symm rfl + right_inv r := congrArg Prod.snd (e.apply_symm_apply (a, r)) + +def projectedEventEquiv {X E R : Type*} (e : X ≃ E × R) (f : X → E) + (he : ∀ x, (e x).1 = f x) (P : E → Prop) : + {x // P (f x)} ≃ ({a // P a} × R) where + toFun x := (⟨(e x.val).1, by rw [he]; exact x.property⟩, (e x.val).2) + invFun ar := ⟨e.symm (ar.1.val, ar.2), by + have h : f (e.symm (ar.1.val, ar.2)) = ar.1.val := + (he _).symm.trans (congrArg Prod.fst (e.apply_symm_apply (ar.1.val, ar.2))) + simpa only [h] using ar.1.property⟩ + left_inv x := by + apply Subtype.ext + exact e.symm_apply_apply x.val + right_inv ar := by + apply Prod.ext + · apply Subtype.ext + exact congrArg Prod.fst (e.apply_symm_apply (ar.1.val, ar.2)) + · change (e (e.symm (ar.1.val, ar.2))).2 = ar.2 + exact congrArg Prod.snd (e.apply_symm_apply (ar.1.val, ar.2)) + +theorem natCard_edgeAt_fiber (G : PortGraph V D) (n : Nat) (k : Fin (n + 1)) + (a : Edge V D) : + Nat.card {w : Walk V D (n + 1) // edgeAt G n w k = a} = Nat.card D ^ n := by + calc + _ = Nat.card (Fin n → D) := Nat.card_congr + (projectedFiberEquiv (pivotEquiv G n k) (fun w => edgeAt G n w k) + (pivotEquiv_fst G n k) a) + _ = _ := by simp [Nat.card_fun] + +theorem natCard_edgeAt_event (G : PortGraph V D) (n : Nat) (k : Fin (n + 1)) + (P : Edge V D → Prop) : + Nat.card {w : Walk V D (n + 1) // P (edgeAt G n w k)} = + Nat.card {a : Edge V D // P a} * Nat.card D ^ n := by + calc + _ = Nat.card ({a : Edge V D // P a} × (Fin n → D)) := Nat.card_congr + (projectedEventEquiv (pivotEquiv G n k) (fun w => edgeAt G n w k) + (pivotEquiv_fst G n k) P) + _ = _ := by simp [Nat.card_prod, Nat.card_fun] + +def leftFromPivot (G : PortGraph V D) : + (n : Nat) → Fin (n + 1) → V → (Fin n → D) → V + | 0, _, v, _ => v + | n + 1, k, v, r => Fin.cases v + (fun j => next G (leftFromPivot G n j v (fun m => r m.succ)) (r 0)) k + +def rightFromPivot (G : PortGraph V D) : + (n : Nat) → Fin (n + 1) → Edge V D → (Fin n → D) → V + | 0, _, e, _ => next G e.1 e.2 + | n + 1, k, e, r => Fin.cases + (wordEnd G (n + 1) (next G e.1 e.2) r) + (fun j => rightFromPivot G n j e (fun m => r m.succ)) k + +theorem leftFromPivot_zero (G : PortGraph V D) (n : Nat) + (v : V) (r : Fin n → D) : leftFromPivot G n 0 v r = v := by + cases n <;> rfl + +theorem rightFromPivot_zero (G : PortGraph V D) (n : Nat) + (e : Edge V D) (r : Fin n → D) : + rightFromPivot G n 0 e r = wordEnd G n (next G e.1 e.2) r := by + cases n <;> rfl + +theorem leftFromPivot_actual (G : PortGraph V D) : + ∀ (n : Nat) (k : Fin (n + 1)) (w : Walk V D (n + 1)), + leftFromPivot G n k (pivotEquiv G n k w).1.1 (pivotEquiv G n k w).2 = w.1 := by + intro n + induction n with + | zero => intro k w; rfl + | succ n ih => + intro k w + refine Fin.cases ?_ (fun j => ?_) k + · rfl + · rw [pivotEquiv_succ_apply] + change next G + (leftFromPivot G n j (pivotEquiv G n j (advanceTail G w)).1.1 + (pivotEquiv G n j (advanceTail G w)).2) + (G.rot (w.1, w.2 0)).2 = w.1 + rw [ih j (advanceTail G w)] + change (G.rot ((G.rot (w.1, w.2 0)).1, (G.rot (w.1, w.2 0)).2)).1 = w.1 + exact congrArg Prod.fst (rot_rot G (w.1, w.2 0)) + +theorem rightFromPivot_actual (G : PortGraph V D) : + ∀ (n : Nat) (k : Fin (n + 1)) (w : Walk V D (n + 1)), + rightFromPivot G n k (pivotEquiv G n k w).1 (pivotEquiv G n k w).2 = + endpoint G w := by + intro n + induction n with + | zero => intro k w; rfl + | succ n ih => + intro k w + refine Fin.cases ?_ (fun j => ?_) k + · rfl + · rw [pivotEquiv_succ_apply] + change rightFromPivot G n j (pivotEquiv G n j (advanceTail G w)).1 + (pivotEquiv G n j (advanceTail G w)).2 = endpoint G w + rw [ih j (advanceTail G w)] + rfl + +end IndependentSetsGames.Foundations.PCP.PoweringWalks + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringWitness.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdb4d3129dc3e4f95b95a03eb1784b957420df06 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringWitness.lean @@ -0,0 +1,213 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.Profiles +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLazy +import OAI.Combinatorics.IndependentSets.Expansion.PoweringReturn + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PoweringWitness + +open PoweringWalks SpectralReturn PoweringReturn PoweringLazy +open PoweringMoment (bit) + +variable {V D : Type*} + +theorem iterate_mul_const [Fintype D] (G : PortGraph V D) + (n : Nat) (c : ℝ) (h : V → ℝ) : + iterateOperator G n (fun x => c * h x) = + fun x => c * iterateOperator G n h x := by + induction n with + | zero => rfl + | succ n ih => + change averagingOperator G (iterateOperator G n (fun x => c * h x)) = + fun x => c * averagingOperator G (iterateOperator G n h) x + rw [ih] + funext v + exact mean_mul_left c (fun d => iterateOperator G n h (G.rot (v, d)).1) + +noncomputable def endpointWitness (G : PortGraph V D) (bad : Edge V D → Bool) + (φ ψ : Edge V D → V → ℝ) (n : Nat) (k : Fin (n + 1)) + (w : Walk V D (n + 1)) : ℝ := + bit (bad (edgeAt G n w k) = true) * + φ (edgeAt G n w k) w.1 * ψ (edgeAt G n w k) (endpoint G w) + +noncomputable def vertexWitness (G : PortGraph V D) (bad : Edge V D → Bool) + (f : V → V → ℝ) (n : Nat) (k : Fin (n + 1)) : + Walk V D (n + 1) → ℝ := + endpointWitness G bad (fun e => f e.1) (fun e => f (next G e.1 e.2)) n k + +theorem endpoint_lower_bound [Fintype V] [Fintype D] [Nonempty D] + (G : PortGraph V D) (n : Nat) (k : Fin (n + 1)) (bad : Edge V D → Bool) + (φ ψ : Edge V D → V → ℝ) (a : ℝ) (ha : 0 ≤ a) + (hL : ∀ e, bad e = true → a ≤ iterateOperator G k.val (φ e) e.1) + (hR : ∀ e, bad e = true → + a ≤ iterateOperator G (n - k.val) (ψ e) (next G e.1 e.2)) : + edgeDensity bad * a ^ 2 ≤ mean (endpointWitness G bad φ ψ n k) := by + have hfactor : mean (endpointWitness G bad φ ψ n k) = + mean (fun e : Edge V D => + (bit (bad e = true) * iterateOperator G k.val (φ e) e.1) * + iterateOperator G (n - k.val) (ψ e) (next G e.1 e.2)) := by + unfold endpointWitness + rw [mean_edge_endpoints G n k (fun e x => bit (bad e = true) * φ e x) ψ] + simp_rw [iterate_mul_const] + have hbitMean : mean (fun e : Edge V D => bit (bad e = true)) = edgeDensity bad := by + calc + _ = mean (fun v : V => mean (fun d : D => bit (bad (v, d) = true))) := + mean_prod (A := V) (B := D) (fun e => bit (bad e = true)) + _ = edgeDensity bad := by simp only [mean_edge_bit, edgeDensity] + calc + edgeDensity bad * a ^ 2 = + mean (fun e : Edge V D => bit (bad e = true) * a ^ 2) := by + rw [mean_mul_right, hbitMean] + _ ≤ mean (fun e : Edge V D => + (bit (bad e = true) * iterateOperator G k.val (φ e) e.1) * + iterateOperator G (n - k.val) (ψ e) (next G e.1 e.2)) := by + apply mean_mono + intro e + cases hb : bad e with + | false => simp [bit] + | true => + have hprod := mul_le_mul (hL e hb) (hR e hb) ha (ha.trans (hL e hb)) + simpa [bit, hb, pow_two] using hprod + _ = mean (endpointWitness G bad φ ψ n k) := hfactor.symm + +theorem lazy_middle_witness_mean [Fintype V] [Fintype D] [Nonempty D] + (G : PortGraph V D) (q M : Nat) (hq : 1 ≤ q) (hM : 1 ≤ M) + (k : Fin (2 * (4 * q * M) ^ 2 + 1)) + (hlo : (4 * q * M) ^ 2 - M ≤ k.val) + (hhi : k.val ≤ (4 * q * M) ^ 2 + M) + (bad : Edge V (Bool × D) → Bool) (f : V → V → ℝ) + (hf : ∀ u w, f u w ∈ Set.Icc (0 : ℝ) 1) + (hmodal : ∀ u, 1 / (q : ℝ) ≤ + iterateOperator (lazyGraph G) ((4 * q * M) ^ 2) (f u) u) : + edgeDensity bad / (4 * (q : ℝ) ^ 2) ≤ + mean (vertexWitness (lazyGraph G) bad f (2 * (4 * q * M) ^ 2) k) := by + have hk : k.val ≤ 2 * (4 * q * M) ^ 2 := Nat.le_of_lt_succ k.isLt + have hslo : (4 * q * M) ^ 2 - M ≤ 2 * (4 * q * M) ^ 2 - k.val := by omega + have hshi : 2 * (4 * q * M) ^ 2 - k.val ≤ (4 * q * M) ^ 2 + M := by omega + have ha : (0 : ℝ) ≤ 1 / (2 * (q : ℝ)) := by positivity + have hbound := endpoint_lower_bound (lazyGraph G) (2 * (4 * q * M) ^ 2) k bad + (fun e => f e.1) (fun e => f (next (lazyGraph G) e.1 e.2)) + (1 / (2 * (q : ℝ))) ha + (by + intro e _ + exact lazy_endpoint_modal_transfer G q M k.val hq hM hlo hhi + (f e.1) (hf e.1) e.1 (hmodal e.1)) + (by + intro e _ + exact lazy_endpoint_modal_transfer G q M (2 * (4 * q * M) ^ 2 - k.val) + hq hM hslo hshi (f (next (lazyGraph G) e.1 e.2)) + (hf (next (lazyGraph G) e.1 e.2)) (next (lazyGraph G) e.1 e.2) + (hmodal (next (lazyGraph G) e.1 e.2))) + have hscale : edgeDensity bad * (1 / (2 * (q : ℝ))) ^ 2 = + edgeDensity bad / (4 * (q : ℝ) ^ 2) := by ring + simpa only [vertexWitness, hscale] using hbound + +end IndependentSetsGames.Foundations.PCP.PoweringWitness +namespace IndependentSetsGames.Foundations.PCP.PoweringMomentBound + +open scoped BigOperators +open PoweringWalks SpectralReturn PoweringReturn +open PoweringMoment (bit hits) + +theorem symmetric_gap_matrix_sum (ε : ℝ) (r : Nat → ℝ) : + ∀ (m : Nat) (f : Fin m → Fin m → ℝ), + (∀ i j, f i j = f j i) → (∀ i, f i i = ε) → + (∀ i j, i.val < j.val → f i j = r (j.val - i.val - 1)) → + (∑ i, ∑ j, f i j) = (m : ℝ) * ε + + 2 * ∑ j ∈ Finset.range m, ∑ gap ∈ Finset.range j, r gap := by + intro m + induction m with + | zero => intro f _hSym _hDiag _hUpper; simp + | succ m ih => + intro f hSym hDiag hUpper + have hOld : (∑ i : Fin m, ∑ j : Fin m, f i.castSucc j.castSucc) = + (m : ℝ) * ε + 2 * ∑ j ∈ Finset.range m, ∑ gap ∈ Finset.range j, r gap := by + apply ih (fun i j => f i.castSucc j.castSucc) + · intro i j; exact hSym i.castSucc j.castSucc + · intro i; exact hDiag i.castSucc + · intro i j hij; exact hUpper i.castSucc j.castSucc hij + have hLast : (∑ i : Fin m, f i.castSucc (Fin.last m)) = + ∑ gap ∈ Finset.range m, r gap := by + calc + _ = ∑ i : Fin m, r (m - 1 - i.val) := by + apply Finset.sum_congr rfl + intro i _ + rw [hUpper i.castSucc (Fin.last m) i.isLt] + simp only [Fin.val_last, Fin.val_castSucc] + congr 1 + omega + _ = ∑ i ∈ Finset.range m, r (m - 1 - i) := + Fin.sum_univ_eq_sum_range (fun i => r (m - 1 - i)) m + _ = _ := Finset.sum_range_reflect r m + have hLastRow : (∑ j : Fin m, f (Fin.last m) j.castSucc) = + ∑ gap ∈ Finset.range m, r gap := by + calc + _ = ∑ j : Fin m, f j.castSucc (Fin.last m) := by + apply Finset.sum_congr rfl + intro j _ + exact hSym (Fin.last m) j.castSucc + _ = _ := hLast + calc + (∑ i, ∑ j, f i j) = + (∑ i : Fin m, ∑ j : Fin m, f i.castSucc j.castSucc) + + (∑ i : Fin m, f i.castSucc (Fin.last m)) + + (∑ j : Fin m, f (Fin.last m) j.castSucc) + f (Fin.last m) (Fin.last m) := by + simp only [Fin.sum_univ_castSucc, Finset.sum_add_distrib] + ring + _ = (m : ℝ) * ε + + 2 * (∑ j ∈ Finset.range m, ∑ gap ∈ Finset.range j, r gap) + + (∑ gap ∈ Finset.range m, r gap) + (∑ gap ∈ Finset.range m, r gap) + ε := by + rw [hOld, hLast, hLastRow, hDiag] + _ = ((m + 1 : Nat) : ℝ) * ε + + 2 * ∑ j ∈ Finset.range (m + 1), ∑ gap ∈ Finset.range j, r gap := by + rw [Finset.sum_range_succ] + simp only [Nat.cast_add, Nat.cast_one] + ring + +def windowIndex (n start m : Nat) (h : start + m ≤ n + 1) (i : Fin m) : Fin (n + 1) := + ⟨start + i.val, (Nat.add_lt_add_left i.isLt start).trans_le h⟩ + +variable {V D : Type*} [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + +def windowEvent (G : PortGraph V D) (bad : V × D → Bool) + (n start m : Nat) (h : start + m ≤ n + 1) (i : Fin m) (w : Walk V D (n + 1)) : Prop := + bad (edgeAt G n w (windowIndex n start m h i)) = true + +theorem window_second_moment_eq (G : PortGraph V D) (bad : V × D → Bool) + (n start m : Nat) (h : start + m ≤ n + 1) : + mean (fun w => hits (windowEvent G bad n start m h) w ^ 2) = + (m : ℝ) * edgeDensity bad + + 2 * ∑ j ∈ Finset.range m, ∑ gap ∈ Finset.range j, returnMass G bad gap := by + rw [show mean (fun w => hits (windowEvent G bad n start m h) w ^ 2) = + ∑ i, ∑ j, mean (fun w => bit (windowEvent G bad n start m h i w ∧ + windowEvent G bad n start m h j w)) from + PoweringMoment.second_moment_eq (windowEvent G bad n start m h)] + apply symmetric_gap_matrix_sum + · intro i j + congr 1 + funext w + simp only [and_comm] + · intro i + simp only [and_self] + exact hit_mean G bad n (windowIndex n start m h i) + · intro i j hij + have hwin : windowIndex n start m h i < windowIndex n start m h j := + Nat.add_lt_add_left hij start + have hp := pair_event_mean G bad n (windowIndex n start m h i) + (windowIndex n start m h j) hwin + simpa only [windowEvent, windowIndex, Nat.add_sub_add_left] using hp + +theorem window_second_moment_le (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) + (n start m : Nat) (h : start + m ≤ n + 1) : + mean (fun w => hits (windowEvent G bad n start m h) w ^ 2) ≤ + (m : ℝ) * edgeDensity bad * + (1 + 2 / (1 - lambda) + ((m : ℝ) - 1) * edgeDensity bad) := by + rw [window_second_moment_eq] + exact secondMoment_return_envelope G lambda certificate bad reversal m + +end IndependentSetsGames.Foundations.PCP.PoweringMomentBound + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingFamilyBridge.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingFamilyBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..989a35b886719d0d91e01abcc7e1cbbe040dbe43 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingFamilyBridge.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularTables +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingFamilyBridge + +open PreprocessingCloudIndex PreprocessingRegularTables ExpanderTableWords +open IndependentSetsGames.Foundations.Complexity (encodeWords) + +theorem rotationWords_resizeTable {n m q : Nat} (h : n = m) + (table : ExpanderTables.Table n q) : + rotationWords (resizeTable h table) = rotationWords table := by + cases h + rfl + +theorem familyRotor_eq_familyCloudTable (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (hk : 0 < cloudSize t v) : + encodeWords (rotationWords (ExpanderTables.family H + (PreprocessingLevels.boundedLevel (cloudSize t v)))) = + encodeWords (rotationWords (familyCloudTable H t v)) := by + unfold familyCloudTable + rw [dite_eq_right (Nat.ne_of_gt hk)] + exact congrArg encodeWords (rotationWords_resizeTable _ _).symm + +theorem cloudSize_pos_of_dart (t : GraphTables.Table) (e : Fin t.darts) : + 0 < cloudSize t t.rows[e].tail := by + have h := (oldCloudIndex t e).isLt + omega + +theorem padding_zero_of_cloudSize_zero (t : GraphTables.Table) (v : Fin t.vertices) + (hk : cloudSize t v = 0) : padding t v = 0 := by + simp only [padding, hk, PreprocessingLevels.cloudPaddedSize_zero, Nat.sub_zero] + +theorem cloudSize_pos_of_dummy (t : GraphTables.Table) (v : Fin t.vertices) + (j : Fin (padding t v)) : 0 < cloudSize t v := by + by_contra h + have hk := Nat.eq_zero_of_not_pos h + have hp := padding_zero_of_cloudSize_zero t v hk + have hj := j.isLt + omega + +theorem cloudSize_pos_of_paddedCloud (t : GraphTables.Table) (v : Fin t.vertices) + (x : PaddedCloud t (padding t) v) : 0 < cloudSize t v := by + by_contra h + have hk := Nat.eq_zero_of_not_pos h + have hp := padding_zero_of_cloudSize_zero t v hk + have hx := (paddedCloudRank t (padding t) v x).isLt + omega + +theorem familyCloudWords_of_zero (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (hk : cloudSize t v = 0) : + encodeWords (rotationWords (familyCloudTable H t v)) = [] := by + have hl : (rotationWords (familyCloudTable H t v)).length = 0 := by + rw [rotationWords_length, cloudSize_add_padding, hk, + PreprocessingLevels.cloudPaddedSize_zero, Nat.zero_mul] + rw [List.length_eq_zero_iff.mp hl] + rfl + +end IndependentSetsGames.Foundations.PCP.PreprocessingFamilyBridge + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingInternalRows.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingInternalRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..4aa337aa901dd644476248dd177d094b329c3431 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingInternalRows.lean @@ -0,0 +1,188 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingPaddingOffsets + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingInternalRows + +open DegreeReplacement PreprocessingCloudIndex PreprocessingRegularTables + +variable (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} +variable (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + +def localStep (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + Fin (cloudSize t v + padding v) × Fin q := + ExpanderTables.lookup (tables v) (paddedCloudRank t padding v x, p) + +def destination (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + PaddedCloud t padding v := + paddedCloudSelect t padding v (localStep t padding tables v x p).1 + +def rowIndex (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + Fin (vertexCount t padding * (q + 1)) := + PortTables.rowIndex (vertexCount t padding) (q + 1) + (vertexOrder t padding x.val, portOrder q (.inl p)) + +def row (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + GraphTables.DartRow (vertexCount t padding) (vertexCount t padding * (q + 1)) := + (PortTables.flatRows (ofCloudTables t padding tables))[rowIndex t padding v x p] + +def equalityRelation : GraphTables.RelationTable := + GraphTables.relationOf (fun a b => decide (a = b)) + +@[simp] theorem equalityRelation_apply (a b : GraphTables.Label) : + GraphTables.relationAt equalityRelation a b = decide (a = b) := + GraphTables.relationAt_relationOf _ a b + +theorem cloud_rotation (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (cloudGraphs t padding tables v).rot (x, p) = + (destination t padding tables v x p, (localStep t padding tables v x p).2) := by + have h := GraphTransport.reindex_rot (ExpanderTables.graph (tables v)) + (paddedCloudEquiv t padding v).symm (Equiv.refl _) + (paddedCloudRank t padding v x) p + simpa only [cloudGraphs, ExpanderTables.graph_rot, Equiv.refl_apply, + paddedCloudRank, paddedCloudSelect, Equiv.symm_apply_apply, destination, localStep] using h + +theorem source_rotation (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (sourcePortGraph t padding tables).rot (x.val, .inl p) = + ((destination t padding tables v x p).val, + .inl (localStep t padding tables v x p).2) := by + rcases x with ⟨x, hx⟩ + subst v + exact congrArg + (fun z : PaddedCloud t padding + ((paddedGraph (GraphTables.semantics t) (fun v => Fin (padding v))).tail x) × Fin q => + (z.1.val, (Sum.inl z.2 : Fin q ⊕ Unit))) + (cloud_rotation t padding tables _ ⟨x, rfl⟩ p) + +theorem rotation_internal (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + PortTables.rotation (ofCloudTables t padding tables) + (vertexOrder t padding x.val, portOrder q (.inl p)) = + (vertexOrder t padding (destination t padding tables v x p).val, + portOrder q (.inl (localStep t padding tables v x p).2)) := by + rw [rotation_ofCloudTables, source_rotation t padding tables v x p] + +theorem reverseIndex_internal (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + ((ofCloudTables t padding tables).reverseIndex[rowIndex t padding v x p]).val = + (q + 1) * (vertexOrder t padding (destination t padding tables v x p).val).val + + (localStep t padding tables v x p).2.val := by + unfold rowIndex + rw [← PortTables.rowIndex_rotation, rotation_internal t padding tables v x p, + PortTables.rowIndex_val, portOrder_internal] + dsimp only + omega + +theorem relation_ext {r s : GraphTables.RelationTable} + (h : ∀ a b, GraphTables.relationAt r a b = GraphTables.relationAt s a b) : r = s := by + apply Vector.ext + intro i hi + simpa only [GraphTables.relationAt, Prod.eta, Equiv.apply_symm_apply, + Fin.getElem_fin] using + h (GraphTables.relationIndex.symm ⟨i, hi⟩).1 + (GraphTables.relationIndex.symm ⟨i, hi⟩).2 + +theorem relations_internal (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (ofCloudTables t padding tables).relations[rowIndex t padding v x p] = equalityRelation := by + apply relation_ext + intro a b + rw [equalityRelation_apply] + exact accepts_internal t padding tables x.val p a b + +@[simp] theorem row_tail (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (row t padding tables v x p).tail.val = (vertexOrder t padding x.val).val := by + simp only [row, rowIndex, PortTables.flatRows, Vector.getElem_ofFn, + Fin.getElem_fin, Fin.eta, Equiv.symm_apply_apply] + +theorem row_reverse (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (row t padding tables v x p).reverseIndex.val = + (q + 1) * (vertexOrder t padding (destination t padding tables v x p).val).val + + (localStep t padding tables v x p).2.val := by + simpa only [row, PortTables.flatRows, Vector.getElem_ofFn, Fin.getElem_fin] using + reverseIndex_internal t padding tables v x p + +@[simp] theorem row_relation (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (row t padding tables v x p).relation = equalityRelation := by + simpa only [row, PortTables.flatRows, Vector.getElem_ofFn, Fin.getElem_fin] using + relations_internal t padding tables v x p + +@[simp] theorem localStep_original (v : Fin t.vertices) (x : Cloud (GraphTables.semantics t) v) + (p : Fin q) : + localStep t padding tables v (paddedOld t padding v x) p = + ExpanderTables.lookup (tables v) (Fin.castAdd (padding v) (cloudRank t v x), p) := rfl + +@[simp] theorem localStep_dummy (v : Fin t.vertices) (j : Fin (padding v)) (p : Fin q) : + localStep t padding tables v (paddedNew t padding v j) p = + ExpanderTables.lookup (tables v) (Fin.natAdd (cloudSize t v) j, p) := rfl + +@[simp] theorem row_tail_original (v : Fin t.vertices) (x : Cloud (GraphTables.semantics t) v) + (p : Fin q) : + (row t padding tables v (paddedOld t padding v x) p).tail.val = x.val.val := by + rw [row_tail] + rfl + +@[simp] theorem row_tail_dummy (v : Fin t.vertices) (j : Fin (padding v)) (p : Fin q) : + (row t padding tables v (paddedNew t padding v j) p).tail.val = + t.darts + PreprocessingPaddingOffsets.offset padding v.val + j.val := by + rw [row_tail] + exact PreprocessingPaddingOffsets.vertexOrder_dummy_val t padding v j + +def selectedIndex (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v)) : Nat := + if hi : i.val < cloudSize t v then + (cloudSelect t v ⟨i.val, hi⟩).val.val + else t.darts + PreprocessingPaddingOffsets.offset padding v.val + (i.val - cloudSize t v) + +theorem selectedIndex_eq (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v)) : + (vertexOrder t padding (paddedCloudSelect t padding v i).val).val = + selectedIndex t padding v i := by + unfold selectedIndex + split + · rename_i hi + have he : i = Fin.castAdd (padding v) (⟨i.val, hi⟩ : Fin (cloudSize t v)) := Fin.ext rfl + refine (congrArg (fun j => + (vertexOrder t padding (paddedCloudSelect t padding v j).val).val) he).trans ?_ + rw [paddedCloudSelect_castAdd] + rfl + · rename_i hi + have hj : i.val - cloudSize t v < padding v := by have h := i.isLt; omega + have he : i = Fin.natAdd (cloudSize t v) (⟨i.val - cloudSize t v, hj⟩ : Fin (padding v)) := by + apply Fin.ext + dsimp only [Fin.val_natAdd] + omega + refine (congrArg (fun j => + (vertexOrder t padding (paddedCloudSelect t padding v j).val).val) he).trans ?_ + rw [paddedCloudSelect_natAdd] + change (vertexOrder t padding + (Sum.inr ⟨v, (⟨i.val - cloudSize t v, hj⟩ : Fin (padding v))⟩)).val = _ + exact PreprocessingPaddingOffsets.vertexOrder_dummy_val t padding v _ + +theorem selectedIndex_old (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v)) + (hi : i.val < cloudSize t v) : + selectedIndex t padding v i = (cloudSelect t v ⟨i.val, hi⟩).val.val := by + simp only [selectedIndex, dite_eq_left hi] + +theorem selectedIndex_dummy (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v)) + (hi : cloudSize t v ≤ i.val) : + selectedIndex t padding v i = + t.darts + PreprocessingPaddingOffsets.offset padding v.val + (i.val - cloudSize t v) := by + simp only [selectedIndex, dite_eq_right (Nat.not_lt_of_ge hi)] + +theorem row_reverse_selectedIndex (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (row t padding tables v x p).reverseIndex.val = + (q + 1) * selectedIndex t padding v (localStep t padding tables v x p).1 + + (localStep t padding tables v x p).2.val := by + rw [row_reverse] + unfold destination + rw [selectedIndex_eq] + +theorem rowWords_eq (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + GraphTables.rowWords (row t padding tables v x p) = + [(vertexOrder t padding x.val).val, + (q + 1) * selectedIndex t padding v (localStep t padding tables v x p).1 + + (localStep t padding tables v x p).2.val] ++ + GraphTables.relationWords equalityRelation := by + unfold GraphTables.rowWords + rw [row_tail, row_reverse_selectedIndex, row_relation] + +end IndependentSetsGames.Foundations.PCP.PreprocessingInternalRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingLazyWords.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingLazyWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..231a4c190abf01efa51df104f2723e72ebdeffc0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingLazyWords.lean @@ -0,0 +1,180 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingOverlayTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingLazyWords + +open PortTables GraphTables PreprocessingOverlayTables +open IndependentSetsGames.Foundations.Complexity + +variable {n d : Nat} + +def row (table : PortTables.Table n d) (v : Fin n) (p : Fin d) : + DartRow n (n * d) := + ⟨v, table.reverseIndex[rowIndex n d (v, p)], table.relations[rowIndex n d (v, p)]⟩ + +def trueRelation : RelationTable := Vector.replicate 4096 true + +def stayRow (d : Nat) (v : Fin n) (p : Fin d) : DartRow n (n * (2 * d)) := + ⟨v, rowIndex n (2 * d) (v, lazyPorts d (false, p)), trueRelation⟩ + +def moveRow (table : PortTables.Table n d) (v : Fin n) (p : Fin d) : + DartRow n (n * (2 * d)) := + ⟨v, rowIndex n (2 * d) ((rotation table (v, p)).1, + lazyPorts d (true, (rotation table (v, p)).2)), + table.relations[rowIndex n d (v, p)]⟩ + +def reverseMap (d j : Nat) : Nat := 2 * d * (j / d) + d + j % d + +theorem relation_ext {r s : RelationTable} + (h : ∀ a b, relationAt r a b = relationAt s a b) : r = s := by + apply Vector.ext + intro i hi + simpa only [relationAt, Prod.eta, Equiv.apply_symm_apply, Fin.getElem_fin] using + h (relationIndex.symm ⟨i, hi⟩).1 (relationIndex.symm ⟨i, hi⟩).2 + +theorem row_lazy_stay (table : PortTables.Table n d) (v : Fin n) (p : Fin d) : + row (lazy table) v (lazyPorts d (false, p)) = stayRow d v p := by + have hr : (lazy table).reverseIndex[rowIndex n (2 * d) (v, lazyPorts d (false, p))] = + rowIndex n (2 * d) (v, lazyPorts d (false, p)) := by + rw [← rowIndex_rotation, lazy_rotation_false] + have hp : (lazy table).relations[rowIndex n (2 * d) (v, lazyPorts d (false, p))] = + trueRelation := by + apply relation_ext + intro a b + simpa only [PortTables.accepts, relationAt, trueRelation, Fin.getElem_fin, + Vector.getElem_replicate] using lazy_accepts_false table v p a b + exact congrArg₂ (DartRow.mk v) hr hp + +theorem row_lazy_move (table : PortTables.Table n d) (v : Fin n) (p : Fin d) : + row (lazy table) v (lazyPorts d (true, p)) = moveRow table v p := by + have hr : (lazy table).reverseIndex[rowIndex n (2 * d) (v, lazyPorts d (true, p))] = + rowIndex n (2 * d) ((rotation table (v, p)).1, + lazyPorts d (true, (rotation table (v, p)).2)) := by + rw [← rowIndex_rotation, lazy_rotation_true] + have hp : (lazy table).relations[rowIndex n (2 * d) (v, lazyPorts d (true, p))] = + table.relations[rowIndex n d (v, p)] := by + apply relation_ext + intro a b + exact lazy_accepts_true table v p a b + exact congrArg₂ (DartRow.mk v) hr hp + +theorem stayRow_reverse_val (v : Fin n) (p : Fin d) : + (stayRow d v p).reverseIndex.val = 2 * d * v.val + p.val := by + simp only [stayRow, rowIndex_val, lazyPorts_false_val] + omega + +theorem moveRow_reverse_val (table : PortTables.Table n d) (v : Fin n) (p : Fin d) : + (moveRow table v p).reverseIndex.val = + reverseMap d (row table v p).reverseIndex.val := by + simp only [moveRow, rowIndex_val, lazyPorts_true_val, reverseMap, row] + change (table.reverseIndex[rowIndex n d (v, p)]).val % d + d + + (2 * d) * ((table.reverseIndex[rowIndex n d (v, p)]).val / d) = _ + omega + +theorem relationWords_true : relationWords trueRelation = List.replicate 4096 1 := by + simp only [relationWords, trueRelation, Vector.toList_replicate, + List.map_replicate, bitWord, ite_true] + +theorem stayRow_words (v : Fin n) (p : Fin d) : + rowWords (stayRow d v p) = + [v.val, 2 * d * v.val + p.val] ++ List.replicate 4096 1 := by + rw [rowWords, stayRow_reverse_val] + exact congrArg (fun words => [v.val, 2 * d * v.val + p.val] ++ words) relationWords_true + +theorem moveRow_words (table : PortTables.Table n d) (v : Fin n) (p : Fin d) : + rowWords (moveRow table v p) = + [v.val, reverseMap d (row table v p).reverseIndex.val] ++ + relationWords (row table v p).relation := by + rw [rowWords, moveRow_reverse_val] + rfl + +theorem ofFn_rowIndex {α : Type*} (f : Fin (n * d) → α) : + List.ofFn f = (List.ofFn fun v : Fin n => + List.ofFn fun p : Fin d => f (rowIndex n d (v, p))).flatten := by + rw [List.ofFn_mul] + apply congrArg List.flatten + congr 1 + funext v + congr 1 + funext p + apply congrArg f + apply Fin.ext + simp only [rowIndex_val] + ac_rfl + +theorem flatRows_list (table : PortTables.Table n d) : + (flatRows table).toList = + (List.ofFn fun v : Fin n => List.ofFn (row table v)).flatten := by + rw [flatRows, Vector.toList_ofFn, ofFn_rowIndex] + simp only [Equiv.symm_apply_apply] + rfl + +theorem ofFn_lazyPorts {α : Type*} (f : Fin (2 * d) → α) : + List.ofFn f = List.ofFn (fun p => f (lazyPorts d (false, p))) ++ + List.ofFn (fun p => f (lazyPorts d (true, p))) := by + have hf (p : Fin d) : rowIndex 2 d (0, p) = lazyPorts d (false, p) := by + apply Fin.ext + simp only [rowIndex_val, Fin.val_zero, Nat.mul_zero, Nat.add_zero, lazyPorts_false_val] + have ht (p : Fin d) : rowIndex 2 d ((0 : Fin 1).succ, p) = lazyPorts d (true, p) := by + apply Fin.ext + simp only [rowIndex_val, Fin.val_succ, Fin.val_zero, Nat.zero_add, + Nat.mul_one, lazyPorts_true_val] + simpa only [List.ofFn_succ, List.ofFn_zero, List.flatten_cons, List.flatten_nil, + List.append_nil, hf, ht] using (ofFn_rowIndex (n := 2) (d := d) f) + +def vertexRows (table : PortTables.Table n d) (v : Fin n) : + List (DartRow n (n * (2 * d))) := + List.ofFn (stayRow d v) ++ List.ofFn (moveRow table v) + +theorem vertexRows_length (table : PortTables.Table n d) (v : Fin n) : + (vertexRows table v).length = 2 * d := by + simp only [vertexRows, List.length_append, List.length_ofFn] + omega + +theorem flatRows_lazy (table : PortTables.Table n d) : + (flatRows (lazy table)).toList = (List.ofFn (vertexRows table)).flatten := by + rw [flatRows_list] + apply congrArg List.flatten + congr 1 + funext v + rw [ofFn_lazyPorts] + simp only [row_lazy_stay, row_lazy_move] + rfl + +theorem vertexRows_words (table : PortTables.Table n d) (v : Fin n) : + (vertexRows table v).flatMap rowWords = + (List.ofFn fun p : Fin d => + [v.val, 2 * d * v.val + p.val] ++ List.replicate 4096 1).flatten ++ + (List.ofFn fun p : Fin d => + [v.val, reverseMap d (row table v p).reverseIndex.val] ++ + relationWords (row table v p).relation).flatten := by + have hs : rowWords ∘ stayRow d v = fun p : Fin d => + [v.val, 2 * d * v.val + p.val] ++ List.replicate 4096 1 := by + funext p + exact stayRow_words v p + have hm : rowWords ∘ moveRow table v = fun p : Fin d => + [v.val, reverseMap d (row table v p).reverseIndex.val] ++ + relationWords (row table v p).relation := by + funext p + exact moveRow_words table v p + simp only [vertexRows, List.flatMap_def, List.map_append, List.map_ofFn, + List.flatten_append] + rw [hs, hm] + +theorem tableWords_lazy (table : PortTables.Table n d) : + PortTables.tableWords (lazy table) = + [n, n * (2 * d)] ++ (List.ofFn (vertexRows table)).flatten.flatMap rowWords := by + rw [PortTables.tableWords_eq, flatRows_lazy] + +theorem tableBits_lazy (table : PortTables.Table n d) : + PortTables.tableBits (lazy table) = + encodeWords ([n, n * (2 * d)] ++ + (List.ofFn (vertexRows table)).flatten.flatMap rowWords) := by + change encodeWords (PortTables.tableWords (lazy table)) = _ + rw [tableWords_lazy] + +end IndependentSetsGames.Foundations.PCP.PreprocessingLazyWords + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingLevels.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ea311b15d261904a012953296e6d6347bf751e6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingLevels.lean @@ -0,0 +1,158 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingLevels + +def levelLoop (g k : Nat) : Nat → Nat → Nat → Nat × Nat + | 0, e, s => (e, s) + | fuel + 1, e, s => + if k ≤ s then (e, s) + else levelLoop g k fuel (e + 1) (s * g) + +theorem levelLoop_level_le (g k fuel e s : Nat) : + (levelLoop g k fuel e s).1 ≤ e + fuel := by + induction fuel generalizing e s with + | zero => simp only [levelLoop, Nat.add_zero, le_refl] + | succ fuel ih => + simp only [levelLoop] + split + · omega + · have h := ih (e + 1) (s * g) + omega + +theorem levelLoop_power (g k fuel e : Nat) : + (levelLoop g k fuel e (g ^ e)).2 = + g ^ (levelLoop g k fuel e (g ^ e)).1 := by + induction fuel generalizing e with + | zero => rfl + | succ fuel ih => + simp only [levelLoop] + split + · rfl + · simpa only [pow_succ] using ih (e + 1) + +theorem levelLoop_covers (g k fuel e s : Nat) (hg : 1 < g) + (hs : 0 < s) (hbudget : k ≤ s + fuel) : + k ≤ (levelLoop g k fuel e s).2 := by + induction fuel generalizing e s with + | zero => simpa only [levelLoop, Nat.add_zero] using hbudget + | succ fuel ih => + simp only [levelLoop] + split + · assumption + · apply ih + · exact Nat.mul_pos hs (by omega) + · have htwo : 2 ≤ g := by omega + have hmul : s * 2 ≤ s * g := Nat.mul_le_mul_left s htwo + omega + +theorem levelLoop_le_of_covering_power (g k fuel e j : Nat) + (he : e ≤ j) (hj : k ≤ g ^ j) : + (levelLoop g k fuel e (g ^ e)).1 ≤ j := by + induction fuel generalizing e with + | zero => exact he + | succ fuel ih => + simp only [levelLoop] + split + · exact he + · rename_i hnot + have hne : e ≠ j := by + intro h + subst e + exact hnot hj + have hnext : e + 1 ≤ j := by omega + simpa only [pow_succ] using ih (e + 1) hnext + +def searchResult (k : Nat) : Nat × Nat := + levelLoop ExpanderFamily.growth k k 0 1 + +def boundedLevel (k : Nat) : Nat := (searchResult k).1 + +def paddedSize (k : Nat) : Nat := (searchResult k).2 + +@[simp] theorem boundedLevel_zero : boundedLevel 0 = 0 := rfl + +@[simp] theorem paddedSize_zero : paddedSize 0 = 1 := rfl + +theorem boundedLevel_le_input (k : Nat) : boundedLevel k ≤ k := by + simpa only [boundedLevel, searchResult, Nat.zero_add] using + levelLoop_level_le ExpanderFamily.growth k k 0 1 + +theorem paddedSize_power (k : Nat) : + paddedSize k = ExpanderFamily.growth ^ boundedLevel k := by + simpa only [paddedSize, boundedLevel, searchResult, pow_zero] using + levelLoop_power ExpanderFamily.growth k k 0 + +theorem le_paddedSize (k : Nat) : k ≤ paddedSize k := by + exact levelLoop_covers ExpanderFamily.growth k k 0 1 + ExpanderFamily.growth_gt_one (by omega) (by omega) + +theorem boundedLevel_eq_level (k : Nat) : + boundedLevel k = ExpanderFamily.level k := by + apply Nat.le_antisymm + · simpa only [boundedLevel, searchResult, pow_zero] using + levelLoop_le_of_covering_power ExpanderFamily.growth k k 0 + (ExpanderFamily.level k) (Nat.zero_le _) (ExpanderFamily.le_size k) + · apply (Nat.clog_le_iff_le_pow ExpanderFamily.growth_gt_one).2 + rw [← paddedSize_power] + exact le_paddedSize k + +theorem paddedSize_eq_size (k : Nat) : paddedSize k = ExpanderFamily.size k := by + rw [paddedSize_power, boundedLevel_eq_level] + rfl + +theorem boundedLevel_le_of_le_power {k j : Nat} + (h : k ≤ ExpanderFamily.growth ^ j) : boundedLevel k ≤ j := by + rw [boundedLevel_eq_level] + exact (Nat.clog_le_iff_le_pow ExpanderFamily.growth_gt_one).2 h + +theorem paddedSize_positive (k : Nat) : 0 < paddedSize k := by + rw [paddedSize_power] + exact Nat.pow_pos (by have h := ExpanderFamily.growth_gt_one; omega) + +theorem paddedSize_bounds {k : Nat} (hk : 0 < k) : + k ≤ paddedSize k ∧ paddedSize k ≤ ExpanderFamily.growth * k := by + rw [paddedSize_eq_size] + exact ⟨ExpanderFamily.le_size k, ExpanderFamily.size_le_mul hk⟩ + +def cloudPaddedSize (k : Nat) : Nat := if k = 0 then 0 else paddedSize k + +@[simp] theorem cloudPaddedSize_zero : cloudPaddedSize 0 = 0 := rfl + +theorem cloudPaddedSize_of_pos {k : Nat} (hk : 0 < k) : + cloudPaddedSize k = paddedSize k := by + simp only [cloudPaddedSize, Nat.ne_of_gt hk, ite_false] + +theorem cloudPaddedSize_bounds (k : Nat) : + k ≤ cloudPaddedSize k ∧ cloudPaddedSize k ≤ ExpanderFamily.growth * k := by + by_cases hk : k = 0 + · subst k + simp only [cloudPaddedSize_zero, Nat.mul_zero, le_refl, and_self] + · rw [cloudPaddedSize_of_pos (Nat.pos_of_ne_zero hk)] + exact paddedSize_bounds (Nat.pos_of_ne_zero hk) + +theorem table_vertexCount_eq_paddedSize (k : Nat) : + ExpanderTables.vertexCount (Expanders.baseDegree * Expanders.baseDegree) + (boundedLevel k) = paddedSize k := by + rw [ExpanderTables.vertexCount_eq] + have hg : (Expanders.baseDegree * Expanders.baseDegree) * + (Expanders.baseDegree * Expanders.baseDegree) = ExpanderFamily.growth := by + unfold ExpanderFamily.growth + ring + rw [hg] + exact (paddedSize_power k).symm + +theorem family_row_count_at_size + (H : ExpanderTables.Table + ((Expanders.baseDegree * Expanders.baseDegree) * + (Expanders.baseDegree * Expanders.baseDegree)) Expanders.baseDegree) + (k : Nat) : + (ExpanderTables.family H (boundedLevel k)).rows.toList.length = + paddedSize k * (Expanders.baseDegree * Expanders.baseDegree) := by + rw [ExpanderTables.row_count, table_vertexCount_eq_paddedSize] + +end IndependentSetsGames.Foundations.PCP.PreprocessingLevels + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingOverlayTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingOverlayTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..84a97688331343ee84dc4fcb1672af867de3bd1e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingOverlayTables.lean @@ -0,0 +1,178 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PortTables +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTables +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLazy +import OAI.Combinatorics.IndependentSets.PCP.Minimum + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingOverlayTables + +open PoweringWalks + +def overlayPorts (d e : Nat) : (Fin d ⊕ Fin e) ≃ Fin (d + e) := finSumFinEquiv + +@[simp] theorem overlayPorts_inl_val (d e : Nat) (i : Fin d) : + (overlayPorts d e (Sum.inl i)).val = i.val := rfl + +@[simp] theorem overlayPorts_inr_val (d e : Nat) (i : Fin e) : + (overlayPorts d e (Sum.inr i)).val = d + i.val := rfl + +def lazyPorts (d : Nat) : (Bool × Fin d) ≃ Fin (2 * d) := + (Equiv.prodCongr finTwoEquiv.symm (Equiv.refl (Fin d))).trans finProdFinEquiv + +@[simp] theorem lazyPorts_false_val (d : Nat) (i : Fin d) : + (lazyPorts d (false, i)).val = i.val := by + simp [lazyPorts, finTwoEquiv, finProdFinEquiv] + +@[simp] theorem lazyPorts_true_val (d : Nat) (i : Fin d) : + (lazyPorts d (true, i)).val = i.val + d := by + simp [lazyPorts, finTwoEquiv, finProdFinEquiv] + +def materialize {n d : Nat} {D : Type*} + (G : ConstraintGraph (Fin n) (Fin n × D) PortTables.Label) + (ports : D ≃ Fin d) : PortTables.Table n d := + PortTables.ofPortGraph + (GraphTransport.reindex (Overlay.originalPortGraph G) (Equiv.refl _) ports) + (fun x a b => G.accepts (x.1, ports.symm x.2) a b) + (by + intro x a b + simp only [GraphTransport.reindex, Overlay.originalPortGraph, + Equiv.trans_apply, Equiv.prodCongr_apply, Equiv.prodCongr_symm, + Equiv.refl_apply, Equiv.symm_apply_apply, Prod.map] + convert G.reverse_accepts (x.1, ports.symm x.2) a b using 1 + rfl) + +theorem rotation_materialize {n d : Nat} {D : Type*} + (G : ConstraintGraph (Fin n) (Fin n × D) PortTables.Label) + (ports : D ≃ Fin d) (x : Fin n × Fin d) : + PortTables.rotation (materialize G ports) x = + ((G.reverse (x.1, ports.symm x.2)).1, + ports (G.reverse (x.1, ports.symm x.2)).2) := by + simp only [materialize, PortTables.rotation_ofPortGraph, GraphTransport.reindex, + Overlay.originalPortGraph, Equiv.trans_apply, Equiv.prodCongr_apply, + Equiv.prodCongr_symm, Equiv.refl_apply, Prod.map] + rfl + +theorem rotation_materialize_image {n d : Nat} {D : Type*} + (G : ConstraintGraph (Fin n) (Fin n × D) PortTables.Label) + (ports : D ≃ Fin d) (v : Fin n) (i : D) : + PortTables.rotation (materialize G ports) (v, ports i) = + ((G.reverse (v, i)).1, ports (G.reverse (v, i)).2) := by + rw [rotation_materialize, Equiv.symm_apply_apply] + +@[simp] theorem accepts_materialize {n d : Nat} {D : Type*} + (G : ConstraintGraph (Fin n) (Fin n × D) PortTables.Label) + (ports : D ≃ Fin d) (x : Fin n × Fin d) (a b : PortTables.Label) : + PortTables.accepts (materialize G ports) x a b = + G.accepts (x.1, ports.symm x.2) a b := by + exact PortTables.accepts_ofPortGraph _ _ _ x a b + +theorem constraintGraph_ext {V E A : Type*} {G H : ConstraintGraph V E A} + (hreverse : ∀ e, G.reverse e = H.reverse e) + (htail : ∀ e, G.tail e = H.tail e) + (haccepts : ∀ e a b, G.accepts e a b = H.accepts e a b) : G = H := by + rcases G with ⟨r, hi, t, p, hp⟩ + rcases H with ⟨r', hi', t', p', hp'⟩ + have hr : r = r' := Equiv.ext hreverse + cases hr + have ht : t = t' := funext htail + cases ht + have ha : p = p' := funext fun e => funext fun a => funext fun b => haccepts e a b + cases ha + rfl + +theorem baseGraph_materialize {n d : Nat} {D : Type*} + (G : ConstraintGraph (Fin n) (Fin n × D) PortTables.Label) + (ports : D ≃ Fin d) (htail : G.tail = Prod.fst) : + PortTables.baseGraph (materialize G ports) = + G.reindex (Equiv.refl _) (Equiv.prodCongr (Equiv.refl _) ports) (Equiv.refl _) := by + apply constraintGraph_ext + · intro x + rw [PortTables.baseGraph_reverse, rotation_materialize] + rfl + · intro x + change x.1 = G.tail (x.1, ports.symm x.2) + rw [htail] + · intro x a b + rw [PortTables.baseGraph_accepts, accepts_materialize] + rfl + +def overlay {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) : + PortTables.Table n (d + e) := + materialize (Overlay.constraintGraph (PortTables.baseGraph G) (ExpanderTables.graph H)) + (overlayPorts d e) + +theorem overlay_rotation_old {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) (i : Fin d) : + PortTables.rotation (overlay G H) (v, overlayPorts d e (Sum.inl i)) = + ((PortTables.rotation G (v, i)).1, + overlayPorts d e (Sum.inl (PortTables.rotation G (v, i)).2)) := by + exact rotation_materialize_image _ _ v (Sum.inl i) + +theorem overlay_rotation_expander {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) (i : Fin e) : + PortTables.rotation (overlay G H) (v, overlayPorts d e (Sum.inr i)) = + ((ExpanderTables.lookup H (v, i)).1, + overlayPorts d e (Sum.inr (ExpanderTables.lookup H (v, i)).2)) := by + exact rotation_materialize_image _ _ v (Sum.inr i) + +@[simp] theorem overlay_accepts_old {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) (i : Fin d) (a b : PortTables.Label) : + PortTables.accepts (overlay G H) (v, overlayPorts d e (Sum.inl i)) a b = + PortTables.accepts G (v, i) a b := by + simp only [overlay, accepts_materialize, Equiv.symm_apply_apply] + rfl + +@[simp] theorem overlay_accepts_expander {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) (i : Fin e) (a b : PortTables.Label) : + PortTables.accepts (overlay G H) (v, overlayPorts d e (Sum.inr i)) a b = true := by + simp only [overlay, accepts_materialize, Equiv.symm_apply_apply] + rfl + +theorem overlay_semantics {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) : + PortTables.baseGraph (overlay G H) = + (Overlay.constraintGraph (PortTables.baseGraph G) (ExpanderTables.graph H)).reindex + (Equiv.refl _) (Equiv.prodCongr (Equiv.refl _) (overlayPorts d e)) + (Equiv.refl _) := + baseGraph_materialize _ _ rfl + +def lazy {n d : Nat} (G : PortTables.Table n d) : PortTables.Table n (2 * d) := + materialize (LazyConstraint.constraintGraph (PortTables.baseGraph G)) (lazyPorts d) + +theorem lazy_rotation_false {n d : Nat} (G : PortTables.Table n d) + (v : Fin n) (i : Fin d) : + PortTables.rotation (lazy G) (v, lazyPorts d (false, i)) = + (v, lazyPorts d (false, i)) := by + exact rotation_materialize_image _ _ v (false, i) + +theorem lazy_rotation_true {n d : Nat} (G : PortTables.Table n d) + (v : Fin n) (i : Fin d) : + PortTables.rotation (lazy G) (v, lazyPorts d (true, i)) = + ((PortTables.rotation G (v, i)).1, + lazyPorts d (true, (PortTables.rotation G (v, i)).2)) := by + exact rotation_materialize_image _ _ v (true, i) + +@[simp] theorem lazy_accepts_false {n d : Nat} (G : PortTables.Table n d) + (v : Fin n) (i : Fin d) (a b : PortTables.Label) : + PortTables.accepts (lazy G) (v, lazyPorts d (false, i)) a b = true := by + simp only [lazy, accepts_materialize, Equiv.symm_apply_apply] + rfl + +@[simp] theorem lazy_accepts_true {n d : Nat} (G : PortTables.Table n d) + (v : Fin n) (i : Fin d) (a b : PortTables.Label) : + PortTables.accepts (lazy G) (v, lazyPorts d (true, i)) a b = + PortTables.accepts G (v, i) a b := by + simp only [lazy, accepts_materialize, Equiv.symm_apply_apply] + rfl + +theorem lazy_semantics {n d : Nat} (G : PortTables.Table n d) : + PortTables.baseGraph (lazy G) = + (LazyConstraint.constraintGraph (PortTables.baseGraph G)).reindex + (Equiv.refl _) (Equiv.prodCongr (Equiv.refl _) (lazyPorts d)) (Equiv.refl _) := + baseGraph_materialize _ _ rfl + +end IndependentSetsGames.Foundations.PCP.PreprocessingOverlayTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingOverlayWords.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingOverlayWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..01f8c834190f9be145018e63d3bc78440220d138 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingOverlayWords.lean @@ -0,0 +1,174 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableWords +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingLazyWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingOverlayWords + +open PortTables GraphTables PreprocessingOverlayTables +open Complexity + +variable {n d e : Nat} + +abbrev row := @PreprocessingLazyWords.row +abbrev trueRelation := PreprocessingLazyWords.trueRelation + +def oldReverseMap (d e j : Nat) : Nat := (d + e) * (j / d) + j % d +def expanderReverseMap (d e j : Nat) : Nat := (d + e) * (j / e) + d + j % e + +def oldRow (G : PortTables.Table n d) (e : Nat) (v : Fin n) (p : Fin d) : + DartRow n (n * (d + e)) := + ⟨v, rowIndex n (d + e) ((rotation G (v, p)).1, + overlayPorts d e (.inl (rotation G (v, p)).2)), + G.relations[rowIndex n d (v, p)]⟩ + +def expanderRow (d : Nat) (H : ExpanderTables.Table n e) (v : Fin n) (p : Fin e) : + DartRow n (n * (d + e)) := + ⟨v, rowIndex n (d + e) ((ExpanderTables.lookup H (v, p)).1, + overlayPorts d e (.inr (ExpanderTables.lookup H (v, p)).2)), trueRelation⟩ + +private theorem relation_ext {r s : RelationTable} + (h : ∀ a b, relationAt r a b = relationAt s a b) : r = s := by + apply Vector.ext + intro i hi + simpa only [relationAt, Prod.eta, Equiv.apply_symm_apply, Fin.getElem_fin] using + h (relationIndex.symm ⟨i, hi⟩).1 (relationIndex.symm ⟨i, hi⟩).2 + +theorem row_overlay_old (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (v : Fin n) (p : Fin d) : + row (overlay G H) v (overlayPorts d e (.inl p)) = oldRow G e v p := by + have hr : (overlay G H).reverseIndex[rowIndex n (d + e) (v, overlayPorts d e (.inl p))] = + rowIndex n (d + e) ((rotation G (v, p)).1, + overlayPorts d e (.inl (rotation G (v, p)).2)) := by + rw [← rowIndex_rotation, overlay_rotation_old] + have hp : (overlay G H).relations[rowIndex n (d + e) (v, overlayPorts d e (.inl p))] = + G.relations[rowIndex n d (v, p)] := by + apply relation_ext + exact overlay_accepts_old G H v p + exact congrArg₂ (DartRow.mk v) hr hp + +theorem row_overlay_expander (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (v : Fin n) (p : Fin e) : + row (overlay G H) v (overlayPorts d e (.inr p)) = expanderRow d H v p := by + have hr : (overlay G H).reverseIndex[rowIndex n (d + e) (v, overlayPorts d e (.inr p))] = + rowIndex n (d + e) ((ExpanderTables.lookup H (v, p)).1, + overlayPorts d e (.inr (ExpanderTables.lookup H (v, p)).2)) := by + rw [← rowIndex_rotation, overlay_rotation_expander] + have hp : (overlay G H).relations[rowIndex n (d + e) (v, overlayPorts d e (.inr p))] = + trueRelation := by + apply relation_ext + intro a b + simpa only [PortTables.accepts, relationAt, trueRelation, + PreprocessingLazyWords.trueRelation, Fin.getElem_fin, Vector.getElem_replicate] using + overlay_accepts_expander G H v p a b + exact congrArg₂ (DartRow.mk v) hr hp + +theorem oldRow_reverse_val (G : PortTables.Table n d) (v : Fin n) (p : Fin d) : + (oldRow G e v p).reverseIndex.val = oldReverseMap d e (row G v p).reverseIndex.val := by + simp only [oldRow, rowIndex_val, overlayPorts_inl_val, oldReverseMap, row, + PreprocessingLazyWords.row] + change (G.reverseIndex[rowIndex n d (v, p)]).val % d + + (d + e) * ((G.reverseIndex[rowIndex n d (v, p)]).val / d) = _ + omega + +theorem expanderRow_reverse_val (H : ExpanderTables.Table n e) (v : Fin n) (p : Fin e) : + (expanderRow d H v p).reverseIndex.val = + expanderReverseMap d e (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val := by + simp only [expanderRow, rowIndex_val, overlayPorts_inr_val, expanderReverseMap] + change d + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val % e + + (d + e) * ((ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val / e) = _ + omega + +theorem oldRow_words (G : PortTables.Table n d) (v : Fin n) (p : Fin d) : + rowWords (oldRow G e v p) = + [v.val, oldReverseMap d e (row G v p).reverseIndex.val] ++ + relationWords (row G v p).relation := by + rw [rowWords, oldRow_reverse_val] + rfl + +theorem expanderRow_words (H : ExpanderTables.Table n e) (v : Fin n) (p : Fin e) : + rowWords (expanderRow d H v p) = + [v.val, expanderReverseMap d e + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++ + List.replicate 4096 1 := by + rw [rowWords, expanderRow_reverse_val] + exact congrArg (fun rs => [v.val, expanderReverseMap d e + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++ rs) + PreprocessingLazyWords.relationWords_true + +theorem ofFn_overlayPorts {α : Type*} (f : Fin (d + e) → α) : + List.ofFn f = List.ofFn (fun p => f (overlayPorts d e (.inl p))) ++ + List.ofFn (fun p => f (overlayPorts d e (.inr p))) := by + rw [List.ofFn_add] + rfl + +def vertexRows (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (v : Fin n) : + List (DartRow n (n * (d + e))) := + List.ofFn (oldRow G e v) ++ List.ofFn (expanderRow d H v) + +theorem vertexRows_length (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (v : Fin n) : + (vertexRows G H v).length = d + e := by + simp only [vertexRows, List.length_append, List.length_ofFn] + +theorem flatRows_overlay (G : PortTables.Table n d) (H : ExpanderTables.Table n e) : + (flatRows (overlay G H)).toList = (List.ofFn (vertexRows G H)).flatten := by + rw [PreprocessingLazyWords.flatRows_list] + apply congrArg List.flatten + congr 1 + funext v + rw [ofFn_overlayPorts] + simp only [row_overlay_old, row_overlay_expander] + rfl + +theorem vertexRows_words (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (v : Fin n) : + (vertexRows G H v).flatMap rowWords = + (List.ofFn fun p : Fin d => + [v.val, oldReverseMap d e (row G v p).reverseIndex.val] ++ + relationWords (row G v p).relation).flatten ++ + (List.ofFn fun p : Fin e => + [v.val, expanderReverseMap d e + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++ + List.replicate 4096 1).flatten := by + have ho : rowWords ∘ oldRow G e v = fun p : Fin d => + [v.val, oldReverseMap d e (row G v p).reverseIndex.val] ++ + relationWords (row G v p).relation := by + funext p + exact oldRow_words G v p + have he : rowWords ∘ expanderRow d H v = fun p : Fin e => + [v.val, expanderReverseMap d e + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++ + List.replicate 4096 1 := by + funext p + exact expanderRow_words H v p + simp only [vertexRows, List.flatMap_def, List.map_append, List.map_ofFn, List.flatten_append] + rw [ho, he] + +theorem tableWords_overlay (G : PortTables.Table n d) (H : ExpanderTables.Table n e) : + PortTables.tableWords (overlay G H) = + [n, n * (d + e)] ++ (List.ofFn (vertexRows G H)).flatten.flatMap rowWords := by + rw [PortTables.tableWords_eq, flatRows_overlay] + +theorem tableBits_overlay (G : PortTables.Table n d) (H : ExpanderTables.Table n e) : + PortTables.tableBits (overlay G H) = encodeWords + ([n, n * (d + e)] ++ (List.ofFn (vertexRows G H)).flatten.flatMap rowWords) := by + change encodeWords (PortTables.tableWords (overlay G H)) = _ + rw [tableWords_overlay] + +theorem rotationWords_vertices (H : ExpanderTables.Table n e) : + ExpanderTableWords.rotationWords H = + (List.ofFn fun v : Fin n => List.ofFn fun p : Fin e => + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val).flatten := by + have hflat : ExpanderTableWords.rotationWords H = + List.ofFn (fun i : Fin (n * e) => (ExpanderTables.reverseIndex H i).val) := by + apply List.ext_getElem + · simp [ExpanderTableWords.rotationWords_length] + · intro i hi hj + rw [ExpanderTableWords.rotationWords_getElem H i (by simpa using hi)] + simp only [List.getElem_ofFn] + rw [hflat, PreprocessingLazyWords.ofFn_rowIndex] + rfl + +end IndependentSetsGames.Foundations.PCP.PreprocessingOverlayWords + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingOffsets.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingOffsets.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a23788e3cbea60f1b40b8dd3b9c8510845c661e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingOffsets.lean @@ -0,0 +1,84 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingPaddingOffsets + +open PreprocessingRegularTables +open scoped BigOperators + +private theorem idxOf_map_injective {A B : Type*} [DecidableEq A] [DecidableEq B] + (f : A → B) (hf : Function.Injective f) (xs : List A) (a : A) : + (xs.map f).idxOf (f a) = xs.idxOf a := by + induction xs with + | nil => rfl + | cons x xs ih => + by_cases h : x = a + · subst x; simp + · simp [List.idxOf_cons_ne, h, hf.ne h, ih] + +theorem sigma_idxOf {A : Type*} [DecidableEq A] (sizes : A → Nat) + (xs : List A) (a : A) (ha : a ∈ xs) (j : Fin (sizes a)) : + (xs.sigma (fun x => List.finRange (sizes x))).idxOf ⟨a, j⟩ = + ((xs.take (xs.idxOf a)).map sizes).sum + j.val := by + induction xs with + | nil => simp at ha + | cons x xs ih => + rw [List.sigma_cons] + by_cases h : x = a + · subst x + have hm : (⟨a, j⟩ : Σ x, Fin (sizes x)) ∈ + (List.finRange (sizes a)).map (Sigma.mk a) := by + exact List.mem_map.mpr ⟨j, List.mem_finRange j, rfl⟩ + rw [List.idxOf_append_of_mem hm, + idxOf_map_injective (Sigma.mk a) (fun x y h => by cases h; rfl), + List.idxOf_finRange] + simp + · have hm : (⟨a, j⟩ : Σ x, Fin (sizes x)) ∉ + (List.finRange (sizes x)).map (Sigma.mk x) := by + intro hm + rcases List.mem_map.mp hm with ⟨k, _, hk⟩ + exact h (congrArg Sigma.fst hk) + rw [List.idxOf_append_of_notMem hm, List.length_map, List.length_finRange, + ih (List.mem_of_ne_of_mem (Ne.symm h) ha), List.idxOf_cons_ne xs h] + simp only [List.take_succ_cons, List.map_cons, List.sum_cons] + omega + +def offset {n : Nat} (padding : Fin n → Nat) (k : Nat) : Nat := + (((List.finRange n).take k).map padding).sum + +theorem sigma_length {A : Type*} (sizes : A → Nat) (xs : List A) : + (xs.sigma (fun x => List.finRange (sizes x))).length = (xs.map sizes).sum := by + induction xs with + | nil => rfl + | cons x xs ih => simp [List.sigma_cons, ih] + +theorem paddingOrder_val {n : Nat} (padding : Fin n → Nat) + (v : Fin n) (j : Fin (padding v)) : + (PreprocessingRegularTables.paddingOrder padding ⟨v, j⟩).val = + offset padding v.val + j.val := by + change (paddingList padding).idxOf ⟨v, j⟩ = _ + have h := sigma_idxOf padding (List.finRange n) v (List.mem_finRange v) j + simpa only [List.idxOf_finRange, paddingList, offset] using h + +theorem vertexOrder_dummy_val (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) (v : Fin t.vertices) (j : Fin (padding v)) : + (vertexOrder t padding (Sum.inr ⟨v, j⟩)).val = + t.darts + offset padding v.val + j.val := by + rw [vertexOrder_dummy, paddingOrder_val] + omega + +@[simp] theorem offset_zero {n : Nat} (padding : Fin n → Nat) : offset padding 0 = 0 := by + simp [offset] + +theorem offset_all {n : Nat} (padding : Fin n → Nat) : + offset padding n = ∑ v, padding v := by + have ht : (List.finRange n).take n = List.finRange n := by simp + unfold offset + rw [ht, ← sigma_length padding (List.finRange n)] + exact paddingList_length padding + +end IndependentSetsGames.Foundations.PCP.PreprocessingPaddingOffsets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..01cfcf5501fccd902f6d97728eafd48d7d08db98 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingTables.lean @@ -0,0 +1,272 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PortTables +import OAI.Combinatorics.IndependentSets.PCP.VertexPadding + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingPaddingTables + +open PoweringWalks PortTables + +variable {n m d : Nat} + +def vertexEquiv (h : n ≤ m) : Fin n ⊕ Fin (m - n) ≃ Fin m := + finSumFinEquiv.trans (finCongr (Nat.add_sub_of_le h)) + +@[simp] theorem vertexEquiv_inl (h : n ≤ m) (v : Fin n) : + vertexEquiv h (Sum.inl v) = v.castLE h := rfl + +@[simp] theorem vertexEquiv_inr_val (h : n ≤ m) (v : Fin (m - n)) : + (vertexEquiv h (Sum.inr v)).val = n + v.val := rfl + +@[simp] theorem vertexEquiv_symm_old (h : n ≤ m) (v : Fin n) : + (vertexEquiv h).symm (v.castLE h) = Sum.inl v := + (vertexEquiv h).symm_apply_apply (Sum.inl v) + +def dartEquiv (h : n ≤ m) : + (Fin n ⊕ Fin (m - n)) × Fin d ≃ Fin m × Fin d := + Equiv.prodCongr (vertexEquiv h) (Equiv.refl _) + +@[simp] theorem dartEquiv_apply (h : n ≤ m) + (v : Fin n ⊕ Fin (m - n)) (p : Fin d) : + dartEquiv h (v, p) = (vertexEquiv h v, p) := rfl + +def sumGraph (table : Table n d) (m : Nat) : + ConstraintGraph (Fin n ⊕ Fin (m - n)) + ((Fin n ⊕ Fin (m - n)) × Fin d) Label := + VertexPadding.pad (baseGraph table) (m - n) + +def paddedGraph (table : Table n d) (h : n ≤ m) : + ConstraintGraph (Fin m) (Fin m × Fin d) Label where + reverse := ((dartEquiv h).symm.trans (sumGraph table m).reverse).trans (dartEquiv h) + reverse_involutive e := by + change dartEquiv h ((sumGraph table m).reverse + ((dartEquiv h).symm (dartEquiv h ((sumGraph table m).reverse + ((dartEquiv h).symm e))))) = e + rw [Equiv.symm_apply_apply, (sumGraph table m).reverse_involutive, + Equiv.apply_symm_apply] + tail := Prod.fst + accepts e a b := (sumGraph table m).accepts ((dartEquiv h).symm e) a b + reverse_accepts e a b := by + change (sumGraph table m).accepts ((dartEquiv h).symm + (dartEquiv h ((sumGraph table m).reverse ((dartEquiv h).symm e)))) b a = _ + rw [Equiv.symm_apply_apply] + exact (sumGraph table m).reverse_accepts _ _ _ + +theorem paddedGraph_reverse_equiv (table : Table n d) (h : n ≤ m) + (e : (Fin n ⊕ Fin (m - n)) × Fin d) : + (paddedGraph table h).reverse (dartEquiv h e) = + dartEquiv h ((sumGraph table m).reverse e) := by + change dartEquiv h ((sumGraph table m).reverse + ((dartEquiv h).symm (dartEquiv h e))) = _ + rw [Equiv.symm_apply_apply] + +theorem paddedGraph_accepts_equiv (table : Table n d) (h : n ≤ m) + (e : (Fin n ⊕ Fin (m - n)) × Fin d) (a b : Label) : + (paddedGraph table h).accepts (dartEquiv h e) a b = + (sumGraph table m).accepts e a b := by + change (sumGraph table m).accepts ((dartEquiv h).symm (dartEquiv h e)) a b = _ + rw [Equiv.symm_apply_apply] + +def pad (table : Table n d) (h : n ≤ m) : Table m d := + ofPortGraph + { rot := (paddedGraph table h).reverse + rot_involutive := (paddedGraph table h).reverse_involutive } + (paddedGraph table h).accepts (paddedGraph table h).reverse_accepts + +@[simp] theorem rotation_pad (table : Table n d) (h : n ≤ m) (e : Fin m × Fin d) : + rotation (pad table h) e = (paddedGraph table h).reverse e := by + exact rotation_ofPortGraph _ _ _ e + +@[simp] theorem accepts_pad (table : Table n d) (h : n ≤ m) + (e : Fin m × Fin d) (a b : Label) : + accepts (pad table h) e a b = (paddedGraph table h).accepts e a b := by + exact accepts_ofPortGraph _ _ _ e a b + +theorem pad_valid (table : Table n d) (h : n ≤ m) : + Function.Involutive (rotation (pad table h)) ∧ + ∀ e a b, accepts (pad table h) (rotation (pad table h) e) b a = + accepts (pad table h) e a b := + ⟨rotation_involutive (pad table h), accepts_rotation (pad table h)⟩ + +theorem constraintGraph_ext {V E A : Type*} {G H : ConstraintGraph V E A} + (hr : ∀ e, G.reverse e = H.reverse e) (ht : G.tail = H.tail) + (hp : G.accepts = H.accepts) : G = H := by + cases G with + | mk reverse hinv tail accepts htranspose => + cases H with + | mk reverse' hinv' tail' accepts' htranspose' => + dsimp only at hr ht hp + have he : reverse = reverse' := Equiv.ext hr + cases he + cases ht + cases hp + rfl + +@[simp] theorem baseGraph_pad (table : Table n d) (h : n ≤ m) : + baseGraph (pad table h) = paddedGraph table h := by + apply constraintGraph_ext + · exact rotation_pad table h + · rfl + · funext e a b + exact accepts_pad table h e a b + +theorem rotation_pad_equiv (table : Table n d) (h : n ≤ m) + (v : Fin n ⊕ Fin (m - n)) (p : Fin d) : + rotation (pad table h) (vertexEquiv h v, p) = + (vertexEquiv h ((sumGraph table m).reverse (v, p)).1, + ((sumGraph table m).reverse (v, p)).2) := by + rw [rotation_pad] + exact paddedGraph_reverse_equiv table h (v, p) + +@[simp] theorem rotation_pad_old (table : Table n d) (h : n ≤ m) + (v : Fin n) (p : Fin d) : + rotation (pad table h) (v.castLE h, p) = + ((rotation table (v, p)).1.castLE h, (rotation table (v, p)).2) := by + simpa only [sumGraph, VertexPadding.pad_reverse_inl, baseGraph_reverse, + vertexEquiv_inl] using rotation_pad_equiv table h (Sum.inl v) p + +@[simp] theorem rotation_pad_new (table : Table n d) (h : n ≤ m) + (v : Fin (m - n)) (p : Fin d) : + rotation (pad table h) (vertexEquiv h (Sum.inr v), p) = + (vertexEquiv h (Sum.inr v), p) := by + simpa only [sumGraph, VertexPadding.pad_reverse_inr] using + rotation_pad_equiv table h (Sum.inr v) p + +@[simp] theorem accepts_pad_old (table : Table n d) (h : n ≤ m) + (v : Fin n) (p : Fin d) (a b : Label) : + accepts (pad table h) (v.castLE h, p) a b = accepts table (v, p) a b := by + rw [accepts_pad] + exact paddedGraph_accepts_equiv table h (Sum.inl v, p) a b + +@[simp] theorem accepts_pad_new (table : Table n d) (h : n ≤ m) + (v : Fin (m - n)) (p : Fin d) (a b : Label) : + accepts (pad table h) (vertexEquiv h (Sum.inr v), p) a b = true := by + rw [accepts_pad] + exact paddedGraph_accepts_equiv table h (Sum.inr v, p) a b + +theorem reverseIndex_pad_old (table : Table n d) (h : n ≤ m) + (v : Fin n) (p : Fin d) : + (pad table h).reverseIndex[rowIndex m d (v.castLE h, p)] = + rowIndex m d ((rotation table (v, p)).1.castLE h, (rotation table (v, p)).2) := by + rw [← rowIndex_rotation, rotation_pad_old] + +theorem reverseIndex_pad_new (table : Table n d) (h : n ≤ m) + (v : Fin (m - n)) (p : Fin d) : + (pad table h).reverseIndex[rowIndex m d (vertexEquiv h (Sum.inr v), p)] = + rowIndex m d (vertexEquiv h (Sum.inr v), p) := by + rw [← rowIndex_rotation, rotation_pad_new] + +theorem relation_ext {r s : GraphTables.RelationTable} + (h : ∀ a b, GraphTables.relationAt r a b = GraphTables.relationAt s a b) : r = s := by + apply Vector.ext + intro i hi + simpa only [GraphTables.relationAt, Prod.eta, Equiv.apply_symm_apply, + Fin.getElem_fin] using + h (GraphTables.relationIndex.symm ⟨i, hi⟩).1 + (GraphTables.relationIndex.symm ⟨i, hi⟩).2 + +theorem relations_pad_old (table : Table n d) (h : n ≤ m) + (v : Fin n) (p : Fin d) : + (pad table h).relations[rowIndex m d (v.castLE h, p)] = + table.relations[rowIndex n d (v, p)] := by + apply relation_ext + intro a b + exact accepts_pad_old table h v p a b + +theorem relations_pad_new (table : Table n d) (h : n ≤ m) + (v : Fin (m - n)) (p : Fin d) : + (pad table h).relations[rowIndex m d (vertexEquiv h (Sum.inr v), p)] = + Vector.replicate 4096 true := by + apply relation_ext + intro a b + simpa only [PortTables.accepts, GraphTables.relationAt, Fin.getElem_fin, + Vector.getElem_replicate] using + accepts_pad_new table h v p a b + +theorem paddedGraph_edgeSatisfied_equiv (table : Table n d) (h : n ≤ m) + (labeling : Fin m → Label) (e : (Fin n ⊕ Fin (m - n)) × Fin d) : + (paddedGraph table h).edgeSatisfied labeling (dartEquiv h e) = + (sumGraph table m).edgeSatisfied (fun v => labeling (vertexEquiv h v)) e := by + change (sumGraph table m).accepts ((dartEquiv h).symm (dartEquiv h e)) + (labeling (dartEquiv h e).1) + (labeling (dartEquiv h ((sumGraph table m).reverse + ((dartEquiv h).symm (dartEquiv h e)))).1) = + (sumGraph table m).accepts e (labeling (vertexEquiv h e.1)) + (labeling (vertexEquiv h ((sumGraph table m).reverse e).1)) + simp only [Equiv.symm_apply_apply] + rfl + +theorem edgeSatisfied_pad_equiv (table : Table n d) (h : n ≤ m) + (labeling : Fin m → Label) (e : (Fin n ⊕ Fin (m - n)) × Fin d) : + (baseGraph (pad table h)).edgeSatisfied labeling (dartEquiv h e) = + (sumGraph table m).edgeSatisfied (fun v => labeling (vertexEquiv h v)) e := by + rw [baseGraph_pad] + exact paddedGraph_edgeSatisfied_equiv table h labeling e + +@[simp] theorem edgeSatisfied_pad_old (table : Table n d) (h : n ≤ m) + (labeling : Fin m → Label) (v : Fin n) (p : Fin d) : + (baseGraph (pad table h)).edgeSatisfied labeling (v.castLE h, p) = + (baseGraph table).edgeSatisfied (fun v => labeling (v.castLE h)) (v, p) := by + simpa only [dartEquiv_apply, vertexEquiv_inl, sumGraph, + VertexPadding.edgeSatisfied_inl (baseGraph table) rfl] using + edgeSatisfied_pad_equiv table h labeling (Sum.inl v, p) + +@[simp] theorem edgeSatisfied_pad_new (table : Table n d) (h : n ≤ m) + (labeling : Fin m → Label) (v : Fin (m - n)) (p : Fin d) : + (baseGraph (pad table h)).edgeSatisfied labeling (vertexEquiv h (Sum.inr v), p) = true := by + simpa only [dartEquiv_apply, sumGraph, VertexPadding.edgeSatisfied_inr] using + edgeSatisfied_pad_equiv table h labeling (Sum.inr v, p) + +theorem pad_rejectionCount (table : Table n d) (h : n ≤ m) + (labeling : Fin m → Label) : + (baseGraph (pad table h)).rejectionCount labeling = + (baseGraph table).rejectionCount (fun v => labeling (v.castLE h)) := by + classical + calc + (baseGraph (pad table h)).rejectionCount labeling = + (sumGraph table m).rejectionCount (fun v => labeling (vertexEquiv h v)) := by + unfold ConstraintGraph.rejectionCount + symm + apply Finset.card_equiv (dartEquiv h) + intro e + simp only [ConstraintGraph.mem_rejectedDarts, edgeSatisfied_pad_equiv] + _ = (baseGraph table).rejectionCount (fun v => labeling (v.castLE h)) := by + simpa only [sumGraph, vertexEquiv_inl] using + VertexPadding.pad_rejectionCount (baseGraph table) rfl (m - n) + (fun v => labeling (vertexEquiv h v)) + +theorem pad_labeling_satisfies_iff (table : Table n d) (h : n ≤ m) + (labeling : Fin m → Label) : + (∀ e, (baseGraph (pad table h)).edgeSatisfied labeling e = true) ↔ + ∀ e, (baseGraph table).edgeSatisfied (fun v => labeling (v.castLE h)) e = true := by + constructor + · intro hs e + simpa only [edgeSatisfied_pad_old] using hs (e.1.castLE h, e.2) + · intro hs e + obtain ⟨v, hv⟩ := (vertexEquiv h).surjective e.1 + have he : e = (vertexEquiv h v, e.2) := Prod.ext hv.symm rfl + rw [he] + cases v with + | inl v => simpa only [vertexEquiv_inl, edgeSatisfied_pad_old] using hs (v, e.2) + | inr v => exact edgeSatisfied_pad_new table h labeling v e.2 + +def extendLabeling (h : n ≤ m) (labeling : Fin n → Label) : Fin m → Label := + fun v => Sum.elim labeling (fun _ => 0) ((vertexEquiv h).symm v) + +@[simp] theorem extendLabeling_old (h : n ≤ m) (labeling : Fin n → Label) (v : Fin n) : + extendLabeling h labeling (v.castLE h) = labeling v := by + simp only [extendLabeling, vertexEquiv_symm_old, Sum.elim_inl] + +theorem pad_satisfiable_iff (table : Table n d) (h : n ≤ m) : + (baseGraph (pad table h)).Satisfiable ↔ (baseGraph table).Satisfiable := by + constructor + · rintro ⟨labeling, hs⟩ + exact ⟨fun v => labeling (v.castLE h), (pad_labeling_satisfies_iff table h labeling).1 hs⟩ + · rintro ⟨labeling, hs⟩ + refine ⟨extendLabeling h labeling, (pad_labeling_satisfies_iff table h _).2 ?_⟩ + simpa only [extendLabeling_old] using hs + +end IndependentSetsGames.Foundations.PCP.PreprocessingPaddingTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingWords.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..730e0118937ea230b30d886a0d1307ef038be2d6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingPaddingWords.lean @@ -0,0 +1,158 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingPaddingTables +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddingRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingPaddingWords + +open Complexity PortTables + +variable {n m d : Nat} + +theorem encodeWords_flatMap {α : Type*} (xs : List α) (words : α → List Nat) : + encodeWords (xs.flatMap words) = xs.flatMap (fun x => encodeWords (words x)) := by + induction xs with + | nil => rfl + | cons x xs ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem ofFn_split {α : Type*} (h : n ≤ m) (f : Fin m → α) : + List.ofFn f = + List.ofFn (fun v : Fin n => f (v.castLE h)) ++ + List.ofFn (fun v : Fin (m - n) => f (PreprocessingPaddingTables.vertexEquiv h (.inr v))) := by + calc + List.ofFn f = List.ofFn + (fun v : Fin (n + (m - n)) => f (Fin.cast (Nat.add_sub_of_le h) v)) := + List.ofFn_congr (Nat.add_sub_of_le h).symm f + _ = _ := by rw [List.ofFn_add]; rfl + +theorem flatten_ofFn_rowIndex {α : Type*} (f : Fin (n * d) → List α) : + (List.ofFn f).flatten = + (List.ofFn (fun v : Fin n => + (List.ofFn (fun p : Fin d => f (rowIndex n d (v, p)))).flatten)).flatten := by + rw [List.ofFn_mul, List.flatten_flatten, List.map_ofFn] + apply congrArg List.flatten + apply congrArg List.ofFn + funext v + apply congrArg List.flatten + apply congrArg List.ofFn + funext p + apply congrArg f + apply Fin.ext + simp only [rowIndex_val, Nat.mul_comm, Nat.add_comm] + +def rowBits (table : Table n d) (v : Fin n) (p : Fin d) : List Bool := + encodeWord v.val ++ encodeWord (table.reverseIndex[rowIndex n d (v, p)]).val ++ + encodeWords (GraphTables.relationWords table.relations[rowIndex n d (v, p)]) + +def vertexBits (table : Table n d) (v : Fin n) : List Bool := + (List.ofFn (fun p : Fin d => rowBits table v p)).flatten + +def rowsBits (table : Table n d) : List Bool := + encodeWords ((flatRows table).toList.flatMap GraphTables.rowWords) + +theorem rowBits_flat (table : Table n d) (i : Fin (n * d)) : + encodeWords (GraphTables.rowWords ((flatRows table)[i])) = + rowBits table ((rowIndex n d).symm i).1 ((rowIndex n d).symm i).2 := by + simp only [flatRows, Vector.getElem_ofFn, Fin.getElem_fin, + MachineTableRows.rowBits_eq, rowBits, Prod.eta, Equiv.apply_symm_apply] + +theorem rowsBits_eq_vertices (table : Table n d) : + rowsBits table = (List.ofFn (fun v : Fin n => vertexBits table v)).flatten := by + have hflat : (flatRows table).toList = + List.ofFn (fun i : Fin (n * d) => (flatRows table)[i]) := by + simp only [flatRows, Vector.toList_ofFn, Vector.getElem_ofFn, Fin.getElem_fin] + unfold rowsBits + rw [hflat, encodeWords_flatMap, List.flatMap_def, List.map_ofFn] + change (List.ofFn (fun i : Fin (n * d) => + encodeWords (GraphTables.rowWords ((flatRows table)[i])))).flatten = _ + simp_rw [rowBits_flat] + simpa only [Equiv.symm_apply_apply, vertexBits] using + flatten_ofFn_rowIndex (fun i : Fin (n * d) => + rowBits table ((rowIndex n d).symm i).1 ((rowIndex n d).symm i).2) + +theorem rowBits_pad_old (table : Table n d) (h : n ≤ m) (v : Fin n) (p : Fin d) : + rowBits (PreprocessingPaddingTables.pad table h) (v.castLE h) p = rowBits table v p := by + unfold rowBits + rw [PreprocessingPaddingTables.reverseIndex_pad_old, + PreprocessingPaddingTables.relations_pad_old] + have he : (rowIndex m d ((rotation table (v, p)).1.castLE h, + (rotation table (v, p)).2)).val = (table.reverseIndex[rowIndex n d (v, p)]).val := by + rw [← rowIndex_rotation] + rfl + rw [he] + rfl + +theorem rowBits_pad_new (table : Table n d) (h : n ≤ m) + (v : Fin (m - n)) (p : Fin d) : + rowBits (PreprocessingPaddingTables.pad table h) + (PreprocessingPaddingTables.vertexEquiv h (.inr v)) p = + MachineDummyRows.rowBits (n + v.val) (p.val + d * (n + v.val)) := by + unfold rowBits + rw [PreprocessingPaddingTables.reverseIndex_pad_new, + PreprocessingPaddingTables.relations_pad_new] + rfl + +theorem dummy_rowsBits_eq_ofFn (v e count : Nat) : + MachineDummyRows.rowsBits v e count = + (List.ofFn (fun p : Fin count => MachineDummyRows.rowBits v (e + p.val))).flatten := by + induction count generalizing e with + | zero => rfl + | succ count ih => + rw [MachineDummyRows.rowsBits, List.ofFn_succ, List.flatten_cons, ih] + simp only [Fin.val_zero, Nat.add_zero, Fin.val_succ] + congr 1 + apply congrArg (fun f : Fin count → List Bool => (List.ofFn f).flatten) + funext p + congr 1 + omega + +theorem paddingBits_eq_ofFn (d v e count : Nat) : + MachinePaddingRows.paddingBits d v e count = + (List.ofFn (fun k : Fin count => + MachineDummyRows.rowsBits (v + k.val) (e + k.val * d) d)).flatten := by + induction count generalizing v e with + | zero => rfl + | succ count ih => + rw [MachinePaddingRows.paddingBits, List.ofFn_succ, List.flatten_cons, ih] + simp only [Fin.val_zero, Nat.zero_mul, Nat.add_zero, Fin.val_succ, Nat.add_mul, Nat.one_mul] + congr 1 + apply congrArg (fun f : Fin count → List Bool => (List.ofFn f).flatten) + funext k + congr 1 <;> omega + +@[simp] theorem vertexBits_pad_old (table : Table n d) (h : n ≤ m) (v : Fin n) : + vertexBits (PreprocessingPaddingTables.pad table h) (v.castLE h) = vertexBits table v := by + simp only [vertexBits, rowBits_pad_old] + +theorem vertexBits_pad_new (table : Table n d) (h : n ≤ m) (v : Fin (m - n)) : + vertexBits (PreprocessingPaddingTables.pad table h) + (PreprocessingPaddingTables.vertexEquiv h (.inr v)) = + MachineDummyRows.rowsBits (n + v.val) (n * d + v.val * d) d := by + unfold vertexBits + simp_rw [rowBits_pad_new] + rw [dummy_rowsBits_eq_ofFn] + apply congrArg (fun f : Fin d → List Bool => (List.ofFn f).flatten) + funext p + congr 1 + ring + +theorem rowsBits_pad (table : Table n d) (h : n ≤ m) : + rowsBits (PreprocessingPaddingTables.pad table h) = + rowsBits table ++ MachinePaddingRows.paddingBits d n (n * d) (m - n) := by + rw [rowsBits_eq_vertices, ofFn_split h, List.flatten_append] + simp_rw [vertexBits_pad_old, vertexBits_pad_new] + rw [← rowsBits_eq_vertices, ← paddingBits_eq_ofFn] + +theorem tableBits_pad (table : Table n d) (h : n ≤ m) : + tableBits (PreprocessingPaddingTables.pad table h) = + encodeWords [m, m * d] ++ rowsBits table ++ + MachinePaddingRows.paddingBits d n (n * d) (m - n) := by + change encodeWords (PortTables.tableWords (PreprocessingPaddingTables.pad table h)) = _ + rw [tableWords_eq, encodeWords_append] + change encodeWords [m, m * d] ++ rowsBits (PreprocessingPaddingTables.pad table h) = _ + rw [rowsBits_pad, List.append_assoc] + +end IndependentSetsGames.Foundations.PCP.PreprocessingPaddingWords + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularBounds.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a2f5bdeabbbd9e836016ad059a82814c24bb485 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularBounds.lean @@ -0,0 +1,144 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularWords +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularLoopWords +import OAI.Combinatorics.IndependentSets.Machines.Machine2 + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingRegularBounds + +open PreprocessingRegularTables PreprocessingRegularWords PreprocessingRegularLoopWords +open IndependentSetsGames.Foundations.Complexity +open scoped BigOperators + +theorem offset_succ {n : Nat} (p : Fin n → Nat) (k : Nat) (h : k < n) : + PreprocessingPaddingOffsets.offset p (k + 1) = + PreprocessingPaddingOffsets.offset p k + p ⟨k, h⟩ := by + unfold PreprocessingPaddingOffsets.offset + rw [List.take_succ_eq_append_getElem (show k < (List.finRange n).length by simpa using h)] + simp only [List.map_append, List.sum_append, List.map_cons, List.map_nil, + List.sum_cons, List.sum_nil, Nat.add_zero, List.finRange, List.getElem_ofFn] + +theorem blocksPrefix_length_le {n : Nat} (f : Fin n → List Bool) (k : Nat) : + (blocksPrefix f k).length ≤ (List.ofFn f).flatten.length := by + have h := congrArg List.length (blocksPrefix_append_suffix f k) + simp only [List.length_append] at h + omega + +def header (t : GraphTables.Table) (p : Fin t.vertices → Nat) (q : Nat) : List Bool := + encodeWords [vertexCount t p, vertexCount t p * (q + 1)] + +def ownerBits (t : GraphTables.Table) (p : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + p v) q) + (v : Fin t.vertices) : List Bool := + (List.ofFn (dummyVertexBits t p tables v)).flatten + +def originalPrefix (t : GraphTables.Table) (p : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + p v) q) + (k : Nat) : List Bool := + header t p q ++ blocksPrefix (originalVertexBits t p tables) k + +def ownerPrefix (t : GraphTables.Table) (p : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + p v) q) + (k : Nat) : List Bool := + header t p q ++ (List.ofFn (originalVertexBits t p tables)).flatten ++ + blocksPrefix (ownerBits t p tables) k + +def dummyPrefix (t : GraphTables.Table) (p : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + p v) q) + (v : Fin t.vertices) (k : Nat) : List Bool := + ownerPrefix t p tables v.val ++ blocksPrefix (dummyVertexBits t p tables v) k + +variable (t : GraphTables.Table) (p : Fin t.vertices → Nat) {q : Nat} +variable (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + p v) q) + +theorem originalPrefix_length_le (k : Nat) : + (originalPrefix t p tables k).length ≤ + (PortTables.tableBits (ofCloudTables t p tables)).length := by + have h := blocksPrefix_length_le (originalVertexBits t p tables) k + rw [tableBits_ofCloudTables] + simp only [originalPrefix, header, List.length_append] + omega + +theorem ownerPrefix_length_le (k : Nat) : + (ownerPrefix t p tables k).length ≤ + (PortTables.tableBits (ofCloudTables t p tables)).length := by + have h := blocksPrefix_length_le (ownerBits t p tables) k + have he : ownerBits t p tables = + (fun v => (List.ofFn (dummyVertexBits t p tables v)).flatten) := rfl + rw [tableBits_ofCloudTables] + simp only [ownerPrefix, header, List.length_append] at * + simp only [he] at * + omega + +theorem dummyPrefix_length_le (v : Fin t.vertices) (k : Nat) : + (dummyPrefix t p tables v k).length ≤ + (PortTables.tableBits (ofCloudTables t p tables)).length := by + have hi := blocksPrefix_length_le (dummyVertexBits t p tables v) k + have ho := blocksPrefix_length_le (ownerBits t p tables) (v.val + 1) + rw [blocksPrefix_succ _ _ v.isLt] at ho + have he : ownerBits t p tables = + (fun v => (List.ofFn (dummyVertexBits t p tables v)).flatten) := rfl + simp only [Fin.eta] at ho + rw [tableBits_ofCloudTables] + simp only [dummyPrefix, ownerPrefix, header, ownerBits, List.length_append] at * + simp only [he] at * + omega + +theorem regular_originalPrefix_le (H : BaseTable) (k : Nat) : + (originalPrefix t (padding t) (familyCloudTable H t) k).length ≤ + PreprocessingMachineBounds.regularPolynomial.eval + (PreprocessingMachineBounds.inputLength t) := + (originalPrefix_length_le t (padding t) (familyCloudTable H t) k).trans + (PreprocessingMachineBounds.regularBits_le H t) + +theorem regular_ownerPrefix_le (H : BaseTable) (k : Nat) : + (ownerPrefix t (padding t) (familyCloudTable H t) k).length ≤ + PreprocessingMachineBounds.regularPolynomial.eval + (PreprocessingMachineBounds.inputLength t) := + (ownerPrefix_length_le t (padding t) (familyCloudTable H t) k).trans + (PreprocessingMachineBounds.regularBits_le H t) + +theorem regular_dummyPrefix_le (H : BaseTable) (v : Fin t.vertices) (k : Nat) : + (dummyPrefix t (padding t) (familyCloudTable H t) v k).length ≤ + PreprocessingMachineBounds.regularPolynomial.eval + (PreprocessingMachineBounds.inputLength t) := + (dummyPrefix_length_le t (padding t) (familyCloudTable H t) v k).trans + (PreprocessingMachineBounds.regularBits_le H t) + +theorem visits_le_input : + t.darts + t.vertices + (∑ v, padding t v) + 1 ≤ + (ExpanderFamily.growth + 1) * PreprocessingMachineBounds.inputLength t + 1 := by + have hv := PreprocessingMachineBounds.regularVertices_le_input t + have hn := GraphTables.vertices_le_tableBits_length t + change t.vertices ≤ PreprocessingMachineBounds.inputLength t at hn + unfold vertexCount at hv + rw [Nat.add_mul, one_mul] + omega + +theorem sum_body_costs_le (old : Fin t.darts → Nat) (owners : Fin t.vertices → Nat) + (dummy : ∀ v : Fin t.vertices, Fin (padding t v) → Nat) (setup cap : Nat) + (hs : setup ≤ cap) (ho : ∀ e, old e ≤ cap) (hv : ∀ v, owners v ≤ cap) + (hd : ∀ v j, dummy v j ≤ cap) : + setup + (∑ e, old e) + (∑ v, owners v) + (∑ v, ∑ j, dummy v j) ≤ + ((ExpanderFamily.growth + 1) * PreprocessingMachineBounds.inputLength t + 1) * cap := by + have hOld : (∑ e, old e) ≤ t.darts * cap := by + simpa using Finset.sum_le_sum (fun e (_ : e ∈ Finset.univ) => ho e) + have hOwners : (∑ v, owners v) ≤ t.vertices * cap := by + simpa using Finset.sum_le_sum (fun v (_ : v ∈ Finset.univ) => hv v) + have hDummy : (∑ v, ∑ j, dummy v j) ≤ (∑ v, padding t v) * cap := by + calc + _ ≤ ∑ v, padding t v * cap := by + apply Finset.sum_le_sum + intro v _ + simpa using Finset.sum_le_sum (fun j (_ : j ∈ Finset.univ) => hd v j) + _ = _ := (Finset.sum_mul ..).symm + calc + _ ≤ (t.darts + t.vertices + (∑ v, padding t v) + 1) * cap := by + rw [Nat.add_mul, Nat.add_mul, Nat.add_mul, one_mul] + omega + _ ≤ _ := Nat.mul_le_mul_right cap (visits_le_input t) + +end IndependentSetsGames.Foundations.PCP.PreprocessingRegularBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularLoopWords.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularLoopWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..863d60816ecf77e27bcfbd191b39db8bcb668fb3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularLoopWords.lean @@ -0,0 +1,55 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingRegularLoopWords + +def blocksPrefix {n : Nat} (f : Fin n → List Bool) (k : Nat) : List Bool := + ((List.ofFn f).take k).flatten + +def blocksSuffix {n : Nat} (f : Fin n → List Bool) (k : Nat) : List Bool := + ((List.ofFn f).drop k).flatten + +@[simp] theorem blocksPrefix_zero {n : Nat} (f : Fin n → List Bool) : + blocksPrefix f 0 = [] := by + simp only [blocksPrefix, List.take_zero, List.flatten_nil] + +@[simp] theorem blocksPrefix_all {n : Nat} (f : Fin n → List Bool) : + blocksPrefix f n = (List.ofFn f).flatten := by + have h : (List.ofFn f).take n = List.ofFn f := by + simpa only [List.length_ofFn] using (List.take_length (l := List.ofFn f)) + exact congrArg List.flatten h + +theorem blocksPrefix_succ {n : Nat} (f : Fin n → List Bool) (k : Nat) (h : k < n) : + blocksPrefix f (k + 1) = blocksPrefix f k ++ f ⟨k, h⟩ := by + unfold blocksPrefix + rw [List.take_succ_eq_append_getElem + (show k < (List.ofFn f).length by simpa only [List.length_ofFn] using h)] + simp only [List.flatten_append, List.flatten_cons, List.flatten_nil, + List.append_nil, List.getElem_ofFn] + +@[simp] theorem blocksSuffix_zero {n : Nat} (f : Fin n → List Bool) : + blocksSuffix f 0 = (List.ofFn f).flatten := by + simp only [blocksSuffix, List.drop_zero] + +@[simp] theorem blocksSuffix_all {n : Nat} (f : Fin n → List Bool) : + blocksSuffix f n = [] := by + have h : (List.ofFn f).drop n = [] := by + simpa only [List.length_ofFn] using (List.drop_length (l := List.ofFn f)) + exact congrArg List.flatten h + +theorem blocksSuffix_succ {n : Nat} (f : Fin n → List Bool) (k : Nat) (h : k < n) : + blocksSuffix f k = f ⟨k, h⟩ ++ blocksSuffix f (k + 1) := by + unfold blocksSuffix + rw [List.drop_eq_getElem_cons + (show k < (List.ofFn f).length by simpa only [List.length_ofFn] using h)] + simp only [List.flatten_cons, List.getElem_ofFn] + +theorem blocksPrefix_append_suffix {n : Nat} (f : Fin n → List Bool) (k : Nat) : + blocksPrefix f k ++ blocksSuffix f k = (List.ofFn f).flatten := by + unfold blocksPrefix blocksSuffix + rw [← List.flatten_append, List.take_append_drop] + +end IndependentSetsGames.Foundations.PCP.PreprocessingRegularLoopWords + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..78b64edc132e9ce99d0866bcaf4af781403576d4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularTables.lean @@ -0,0 +1,301 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PortTables +import OAI.Combinatorics.IndependentSets.Expansion.Finite2 +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingLevels + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingRegularTables + +open scoped BigOperators +open PoweringWalks DegreeReplacement + +def paddingList {n : Nat} (padding : Fin n → Nat) : + List (Σ v : Fin n, Fin (padding v)) := + (List.finRange n).sigma (fun v => List.finRange (padding v)) + +theorem paddingList_nodup {n : Nat} (padding : Fin n → Nat) : + (paddingList padding).Nodup := + (List.nodup_finRange n).sigma (fun v => List.nodup_finRange (padding v)) + +theorem mem_paddingList {n : Nat} (padding : Fin n → Nat) + (z : Σ v : Fin n, Fin (padding v)) : z ∈ paddingList padding := by + rcases z with ⟨v, k⟩ + simp only [paddingList, List.mem_sigma, List.mem_finRange, and_self] + +def paddingListOrder {n : Nat} (padding : Fin n → Nat) : + (Σ v : Fin n, Fin (padding v)) ≃ Fin (paddingList padding).length := + PreprocessingCloudIndex.listEquiv (paddingList padding) + (paddingList_nodup padding) (mem_paddingList padding) + +theorem paddingList_length {n : Nat} (padding : Fin n → Nat) : + (paddingList padding).length = ∑ v, padding v := by + simpa only [Fintype.card_sigma, Fintype.card_fin] using + (Fintype.card_congr (paddingListOrder padding)).symm + +def paddingOrder {n : Nat} (padding : Fin n → Nat) : + (Σ v : Fin n, Fin (padding v)) ≃ Fin (∑ v, padding v) := + (paddingListOrder padding).trans (finCongr (paddingList_length padding)) + +abbrev Vertex (t : GraphTables.Table) (padding : Fin t.vertices → Nat) := + PaddedDart (GraphTables.semantics t) (fun v => Fin (padding v)) + +def vertexCount (t : GraphTables.Table) (padding : Fin t.vertices → Nat) : Nat := + t.darts + ∑ v, padding v + +def vertexOrder (t : GraphTables.Table) (padding : Fin t.vertices → Nat) : + Vertex t padding ≃ Fin (vertexCount t padding) := + (Equiv.sumCongr (Equiv.refl _) (paddingOrder padding)).trans finSumFinEquiv + +@[simp] theorem vertexOrder_original (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) (e : Fin t.darts) : + (vertexOrder t padding (Sum.inl e)).val = e.val := rfl + +@[simp] theorem vertexOrder_dummy (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) (z : Σ v, Fin (padding v)) : + (vertexOrder t padding (Sum.inr z)).val = + t.darts + (paddingOrder padding z).val := rfl + +def unitOrder : Unit ≃ Fin 1 where + toFun _ := ⟨0, Nat.zero_lt_one⟩ + invFun _ := () + left_inv u := by cases u; rfl + right_inv k := Subsingleton.elim _ _ + +def portOrder (q : Nat) : (Fin q ⊕ Unit) ≃ Fin (q + 1) := + (Equiv.sumCongr (Equiv.refl _) unitOrder).trans finSumFinEquiv + +@[simp] theorem portOrder_internal (q : Nat) (p : Fin q) : + (portOrder q (Sum.inl p)).val = p.val := rfl + +@[simp] theorem portOrder_inherited (q : Nat) : + (portOrder q (Sum.inr ())).val = q := rfl + +def cloudGraphs (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + {q : Nat} (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) (v : Fin t.vertices) : + PortGraph (Cloud (paddedGraph (GraphTables.semantics t) + (fun w => Fin (padding w))) v) (Fin q) := + GraphTransport.reindex (ExpanderTables.graph (tables v)) + (PreprocessingCloudIndex.paddedCloudEquiv t padding v).symm (Equiv.refl _) + +def sourcePortGraph (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + {q : Nat} (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) : + PortGraph (Vertex t padding) (Fin q ⊕ Unit) := + paddedReplacementPortGraph (GraphTables.semantics t) (fun v => Fin (padding v)) + (cloudGraphs t padding tables) + +def sourceGraph (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + {q : Nat} (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) : + ConstraintGraph (Vertex t padding) (Vertex t padding × (Fin q ⊕ Unit)) + GraphTables.Label := + paddedReplacementGraph (GraphTables.semantics t) (fun v => Fin (padding v)) + (cloudGraphs t padding tables) + +def numberedPortGraph (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + {q : Nat} (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) : + PortGraph (Fin (vertexCount t padding)) (Fin (q + 1)) := + GraphTransport.reindex (sourcePortGraph t padding tables) + (vertexOrder t padding) (portOrder q) + +def numberedAccepts (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + {q : Nat} (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (e : Fin (vertexCount t padding) × Fin (q + 1)) + (a b : GraphTables.Label) : Bool := + (sourceGraph t padding tables).accepts + ((vertexOrder t padding).symm e.1, (portOrder q).symm e.2) a b + +theorem numberedAccepts_transpose (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (e : Fin (vertexCount t padding) × Fin (q + 1)) (a b : GraphTables.Label) : + numberedAccepts t padding tables ((numberedPortGraph t padding tables).rot e) b a = + numberedAccepts t padding tables e a b := by + obtain ⟨z, rfl⟩ := (Equiv.prodCongr (vertexOrder t padding) (portOrder q)).surjective e + rcases z with ⟨v, p⟩ + simp only [numberedPortGraph, Equiv.prodCongr_apply, Prod.map_apply, + GraphTransport.reindex_rot, numberedAccepts, Equiv.symm_apply_apply] + exact (sourceGraph t padding tables).reverse_accepts (v, p) a b + +def ofCloudTables (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + {q : Nat} (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) : + PortTables.Table (vertexCount t padding) (q + 1) := + PortTables.ofPortGraph (numberedPortGraph t padding tables) + (numberedAccepts t padding tables) (numberedAccepts_transpose t padding tables) + +@[simp] theorem rotation_ofCloudTables (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Vertex t padding) (p : Fin q ⊕ Unit) : + PortTables.rotation (ofCloudTables t padding tables) + (vertexOrder t padding v, portOrder q p) = + (vertexOrder t padding ((sourcePortGraph t padding tables).rot (v, p)).1, + portOrder q ((sourcePortGraph t padding tables).rot (v, p)).2) := by + rw [ofCloudTables, PortTables.rotation_ofPortGraph] + exact GraphTransport.reindex_rot _ _ _ _ _ + +@[simp] theorem accepts_ofCloudTables (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Vertex t padding) (p : Fin q ⊕ Unit) (a b : GraphTables.Label) : + PortTables.accepts (ofCloudTables t padding tables) + (vertexOrder t padding v, portOrder q p) a b = + (sourceGraph t padding tables).accepts (v, p) a b := by + simp only [ofCloudTables, PortTables.accepts_ofPortGraph, + numberedAccepts, Equiv.symm_apply_apply] + +@[simp] theorem accepts_internal (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Vertex t padding) (p : Fin q) (a b : GraphTables.Label) : + PortTables.accepts (ofCloudTables t padding tables) + (vertexOrder t padding v, portOrder q (Sum.inl p)) a b = decide (a = b) := by + rw [accepts_ofCloudTables] + rfl + +@[simp] theorem accepts_original (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (e : Fin t.darts) (a b : GraphTables.Label) : + PortTables.accepts (ofCloudTables t padding tables) + (vertexOrder t padding (Sum.inl e), portOrder q (Sum.inr ())) a b = + GraphTables.acceptsAt t.rows e a b := by + rw [accepts_ofCloudTables] + rfl + +@[simp] theorem accepts_dummy (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (z : Σ v, Fin (padding v)) (a b : GraphTables.Label) : + PortTables.accepts (ofCloudTables t padding tables) + (vertexOrder t padding (Sum.inr z), portOrder q (Sum.inr ())) a b = true := by + rw [accepts_ofCloudTables] + rfl + +theorem edgeSatisfied_ofCloudTables (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (labels : Fin (vertexCount t padding) → GraphTables.Label) + (v : Vertex t padding) (p : Fin q ⊕ Unit) : + (PortTables.baseGraph (ofCloudTables t padding tables)).edgeSatisfied labels + (vertexOrder t padding v, portOrder q p) = + (sourceGraph t padding tables).edgeSatisfied + (fun z => labels (vertexOrder t padding z)) (v, p) := by + change PortTables.accepts (ofCloudTables t padding tables) + (vertexOrder t padding v, portOrder q p) (labels (vertexOrder t padding v)) + (labels (PortTables.rotation (ofCloudTables t padding tables) + (vertexOrder t padding v, portOrder q p)).1) = _ + rw [rotation_ofCloudTables, accepts_ofCloudTables] + rfl + +theorem rejectionCount_ofCloudTables (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (labels : Fin (vertexCount t padding) → GraphTables.Label) : + (PortTables.baseGraph (ofCloudTables t padding tables)).rejectionCount labels = + (sourceGraph t padding tables).rejectionCount + (fun z => labels (vertexOrder t padding z)) := by + classical + unfold ConstraintGraph.rejectionCount + symm + apply Finset.card_equiv (Equiv.prodCongr (vertexOrder t padding) (portOrder q)) + rintro ⟨v, p⟩ + simp only [ConstraintGraph.mem_rejectedDarts, Equiv.prodCongr_apply, + Prod.map_apply, edgeSatisfied_ofCloudTables] + +def liftedLabel (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (labels : Fin t.vertices → GraphTables.Label) : + Fin (vertexCount t padding) → GraphTables.Label := + fun z => labels (paddedOwner (GraphTables.semantics t) (fun v => Fin (padding v)) + ((vertexOrder t padding).symm z)) + +theorem rejectionCount_liftedLabel (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (labels : Fin t.vertices → GraphTables.Label) : + (PortTables.baseGraph (ofCloudTables t padding tables)).rejectionCount + (liftedLabel t padding labels) = (GraphTables.semantics t).rejectionCount labels := by + rw [rejectionCount_ofCloudTables] + simp only [liftedLabel, Equiv.symm_apply_apply] + convert paddedReplacement_rejectionCount (GraphTables.semantics t) + (fun v => Fin (padding v)) (cloudGraphs t padding tables) labels using 1 + rfl + +def emptyTable (q : Nat) : ExpanderTables.Table 0 q := + ExpanderTables.ofGraph { rot := Equiv.refl _, rot_involutive := fun _ => rfl } + +def resizeTable {n m q : Nat} (h : n = m) (table : ExpanderTables.Table n q) : + ExpanderTables.Table m q := h ▸ table + +abbrev BaseTable := ExpanderTables.Table + ((Expanders.baseDegree * Expanders.baseDegree) * + (Expanders.baseDegree * Expanders.baseDegree)) Expanders.baseDegree + +def internalDegree : Nat := Expanders.baseDegree * Expanders.baseDegree + +def padding (t : GraphTables.Table) (v : Fin t.vertices) : Nat := + PreprocessingLevels.cloudPaddedSize (PreprocessingCloudIndex.cloudSize t v) - + PreprocessingCloudIndex.cloudSize t v + +theorem cloudSize_add_padding (t : GraphTables.Table) (v : Fin t.vertices) : + PreprocessingCloudIndex.cloudSize t v + padding t v = + PreprocessingLevels.cloudPaddedSize (PreprocessingCloudIndex.cloudSize t v) := + Nat.add_sub_of_le (PreprocessingLevels.cloudPaddedSize_bounds _).1 + +theorem vertexCount_eq_sum_cloudPaddedSize (t : GraphTables.Table) : + vertexCount t (padding t) = ∑ v, + PreprocessingLevels.cloudPaddedSize (PreprocessingCloudIndex.cloudSize t v) := by + unfold vertexCount + rw [← PreprocessingCloudIndex.sum_cloudSize t, ← Finset.sum_add_distrib] + exact Finset.sum_congr rfl (fun v _ => cloudSize_add_padding t v) + +theorem vertexCount_le (t : GraphTables.Table) : + vertexCount t (padding t) ≤ ExpanderFamily.growth * t.darts := by + rw [vertexCount_eq_sum_cloudPaddedSize, ← PreprocessingCloudIndex.sum_cloudSize t, + Finset.mul_sum] + exact Finset.sum_le_sum (fun v _ => (PreprocessingLevels.cloudPaddedSize_bounds _).2) + +theorem vertexCount_eq_zero_of_no_darts (t : GraphTables.Table) (h : t.darts = 0) : + vertexCount t (padding t) = 0 := by + have hle := vertexCount_le t + rw [h, Nat.mul_zero] at hle + exact Nat.eq_zero_of_le_zero hle + +def familyCloudTable (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) : + ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + padding t v) + internalDegree := + if hk : PreprocessingCloudIndex.cloudSize t v = 0 then + resizeTable (by rw [cloudSize_add_padding, hk]; rfl) (emptyTable internalDegree) + else + resizeTable (by + rw [cloudSize_add_padding, + PreprocessingLevels.cloudPaddedSize_of_pos (Nat.pos_of_ne_zero hk)] + exact PreprocessingLevels.table_vertexCount_eq_paddedSize _) + (ExpanderTables.family H + (PreprocessingLevels.boundedLevel (PreprocessingCloudIndex.cloudSize t v))) + +def regularize (H : BaseTable) (t : GraphTables.Table) : + PortTables.Table (vertexCount t (padding t)) (internalDegree + 1) := + ofCloudTables t (padding t) (familyCloudTable H t) + +def regularizeInput (H : BaseTable) (t : GraphTables.Table) : + PortTables.Input (internalDegree + 1) := + ⟨vertexCount t (padding t), regularize H t⟩ + +end IndependentSetsGames.Foundations.PCP.PreprocessingRegularTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularWords.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..87bce853d31f77abdd9db05274079dde2cb62b23 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingRegularWords.lean @@ -0,0 +1,228 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingInternalRows +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingPaddingWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingRegularWords + +open DegreeReplacement PreprocessingCloudIndex PreprocessingRegularTables Complexity +open scoped BigOperators + +variable (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} +variable (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + +def actualRow (x : Vertex t padding) (p : Fin q ⊕ Unit) : + GraphTables.DartRow (vertexCount t padding) (vertexCount t padding * (q + 1)) := + (PortTables.flatRows (ofCloudTables t padding tables))[ + PortTables.rowIndex _ _ (vertexOrder t padding x, portOrder q p)] + +def vertexRows (x : Vertex t padding) : + List (GraphTables.DartRow (vertexCount t padding) (vertexCount t padding * (q + 1))) := + List.ofFn (fun p : Fin q => actualRow t padding tables x (.inl p)) ++ + [actualRow t padding tables x (.inr ())] + +def originalVertexRows (e : Fin t.darts) := vertexRows t padding tables (.inl e) +def dummyVertexRows (v : Fin t.vertices) (j : Fin (padding v)) := + vertexRows t padding tables (.inr ⟨v, j⟩) + +def vertexBits (x : Vertex t padding) : List Bool := + encodeWords ((vertexRows t padding tables x).flatMap GraphTables.rowWords) + +def originalVertexBits (e : Fin t.darts) : List Bool := vertexBits t padding tables (.inl e) +def dummyVertexBits (v : Fin t.vertices) (j : Fin (padding v)) : List Bool := + vertexBits t padding tables (.inr ⟨v, j⟩) + +theorem actualRow_internal (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + actualRow t padding tables x.val (.inl p) = + PreprocessingInternalRows.row t padding tables v x p := rfl + +theorem actualRow_eq (x : Vertex t padding) (p : Fin q ⊕ Unit) : + actualRow t padding tables x p = + ⟨vertexOrder t padding x, + (ofCloudTables t padding tables).reverseIndex[ + PortTables.rowIndex _ _ (vertexOrder t padding x, portOrder q p)], + (ofCloudTables t padding tables).relations[ + PortTables.rowIndex _ _ (vertexOrder t padding x, portOrder q p)]⟩ := by + simp only [actualRow, PortTables.flatRows, Vector.getElem_ofFn, + Fin.getElem_fin, Fin.eta, Equiv.symm_apply_apply] + +@[simp] theorem actualRow_tail (x : Vertex t padding) (p : Fin q ⊕ Unit) : + (actualRow t padding tables x p).tail.val = (vertexOrder t padding x).val := by + rw [actualRow_eq] + +@[simp] theorem inherited_original_reverse (e : Fin t.darts) : + (actualRow t padding tables (.inl e) (.inr ())).reverseIndex.val = + (q + 1) * t.rows[e].reverseIndex.val + q := by + rw [actualRow_eq] + change ((ofCloudTables t padding tables).reverseIndex[PortTables.rowIndex _ _ + (vertexOrder t padding (.inl e), portOrder q (.inr ()))]).val = _ + rw [← PortTables.rowIndex_rotation, rotation_ofCloudTables] + change (PortTables.rowIndex _ _ + (vertexOrder t padding (.inl (GraphTables.reverseAt t.rows e)), portOrder q (.inr ()))).val = _ + rw [PortTables.rowIndex_val, vertexOrder_original, portOrder_inherited] + exact Nat.add_comm _ _ + +@[simp] theorem inherited_dummy_reverse (v : Fin t.vertices) (j : Fin (padding v)) : + (actualRow t padding tables (.inr ⟨v, j⟩) (.inr ())).reverseIndex.val = + (q + 1) * (t.darts + PreprocessingPaddingOffsets.offset padding v.val + j.val) + q := by + rw [actualRow_eq] + change ((ofCloudTables t padding tables).reverseIndex[PortTables.rowIndex _ _ + (vertexOrder t padding (.inr ⟨v, j⟩), portOrder q (.inr ()))]).val = _ + rw [← PortTables.rowIndex_rotation, rotation_ofCloudTables] + change (PortTables.rowIndex _ _ + (vertexOrder t padding (.inr ⟨v, j⟩), portOrder q (.inr ()))).val = _ + rw [PortTables.rowIndex_val, PreprocessingPaddingOffsets.vertexOrder_dummy_val, + portOrder_inherited] + exact Nat.add_comm _ _ + +theorem relation_ext {r s : GraphTables.RelationTable} + (h : ∀ a b, GraphTables.relationAt r a b = GraphTables.relationAt s a b) : r = s := by + apply Vector.ext + intro i hi + simpa only [GraphTables.relationAt, Prod.eta, Equiv.apply_symm_apply, + Fin.getElem_fin] using h (GraphTables.relationIndex.symm ⟨i, hi⟩).1 + (GraphTables.relationIndex.symm ⟨i, hi⟩).2 + +@[simp] theorem inherited_original_relation (e : Fin t.darts) : + (actualRow t padding tables (.inl e) (.inr ())).relation = t.rows[e].relation := by + rw [actualRow_eq] + apply relation_ext + intro a b + exact accepts_original t padding tables e a b + +@[simp] theorem inherited_dummy_relation (v : Fin t.vertices) (j : Fin (padding v)) : + (actualRow t padding tables (.inr ⟨v, j⟩) (.inr ())).relation = + MachineDummyRows.trueRelation := by + rw [actualRow_eq] + apply relation_ext + intro a b + have h := accepts_dummy t padding tables ⟨v, j⟩ a b + simpa only [PortTables.accepts, MachineDummyRows.trueRelation, + GraphTables.relationAt, Fin.getElem_fin, Vector.getElem_replicate] using h + +theorem inherited_original_words (e : Fin t.darts) : + GraphTables.rowWords (actualRow t padding tables (.inl e) (.inr ())) = + [e.val, (q + 1) * t.rows[e].reverseIndex.val + q] ++ + GraphTables.relationWords t.rows[e].relation := by + simp only [GraphTables.rowWords, actualRow_tail, vertexOrder_original, + inherited_original_reverse, inherited_original_relation] + +theorem inherited_dummy_words (v : Fin t.vertices) (j : Fin (padding v)) : + GraphTables.rowWords (actualRow t padding tables (.inr ⟨v, j⟩) (.inr ())) = + [t.darts + PreprocessingPaddingOffsets.offset padding v.val + j.val, + (q + 1) * (t.darts + PreprocessingPaddingOffsets.offset padding v.val + j.val) + q] ++ + GraphTables.relationWords MachineDummyRows.trueRelation := by + simp only [GraphTables.rowWords, actualRow_tail, + PreprocessingPaddingOffsets.vertexOrder_dummy_val, + inherited_dummy_reverse, inherited_dummy_relation] + +theorem encodeWords_flatMap {α : Type*} (xs : List α) (words : α → List Nat) : + encodeWords (xs.flatMap words) = xs.flatMap (fun x => encodeWords (words x)) := by + induction xs with + | nil => rfl + | cons x xs ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem actualRow_bits (x : Vertex t padding) (p : Fin q ⊕ Unit) : + encodeWords (GraphTables.rowWords (actualRow t padding tables x p)) = + PreprocessingPaddingWords.rowBits (ofCloudTables t padding tables) + (vertexOrder t padding x) (portOrder q p) := by + simpa only [actualRow, Equiv.symm_apply_apply] using + PreprocessingPaddingWords.rowBits_flat (ofCloudTables t padding tables) + (PortTables.rowIndex _ _ (vertexOrder t padding x, portOrder q p)) + +theorem vertexBits_eq (x : Vertex t padding) : + vertexBits t padding tables x = + PreprocessingPaddingWords.vertexBits (ofCloudTables t padding tables) + (vertexOrder t padding x) := by + unfold vertexBits vertexRows + rw [List.flatMap_append, encodeWords_append] + simp only [List.flatMap_cons, List.flatMap_nil, List.append_nil] + rw [encodeWords_flatMap, List.flatMap_def, List.map_ofFn] + change (List.ofFn (fun p : Fin q => + encodeWords (GraphTables.rowWords (actualRow t padding tables x (.inl p))))).flatten ++ + encodeWords (GraphTables.rowWords (actualRow t padding tables x (.inr ()))) = _ + simp_rw [actualRow_bits] + unfold PreprocessingPaddingWords.vertexBits + rw [List.ofFn_succ_last, List.flatten_append] + simp only [List.flatten_cons, List.flatten_nil, List.append_nil] + rfl + +theorem paddingOrder_ofFn : + List.ofFn (paddingOrder padding).symm = paddingList padding := by + calc + List.ofFn (paddingOrder padding).symm = + List.ofFn (fun i : Fin (paddingList padding).length => + (paddingOrder padding).symm (Fin.cast (paddingList_length padding) i)) := + List.ofFn_congr (paddingList_length padding).symm (paddingOrder padding).symm + _ = paddingList padding := by + change List.ofFn (fun i => (paddingList padding).get i) = _ + exact List.ofFn_get _ + +theorem vertexOrder_ofFn {α : Type*} (f : Vertex t padding → α) : + List.ofFn (fun i : Fin (vertexCount t padding) => f ((vertexOrder t padding).symm i)) = + List.ofFn (fun e : Fin t.darts => f (.inl e)) ++ + (paddingList padding).map (fun z => f (.inr z)) := by + change List.ofFn (fun i : Fin (t.darts + ∑ v, padding v) => + f ((vertexOrder t padding).symm i)) = _ + rw [List.ofFn_add] + have hold (e : Fin t.darts) : + (vertexOrder t padding).symm (e.castLE (Nat.le_add_right t.darts (∑ v, padding v))) = + Sum.inl e := (vertexOrder t padding).symm_apply_apply (Sum.inl e) + have hnew (i : Fin (∑ v, padding v)) : + (vertexOrder t padding).symm (i.natAdd t.darts) = + Sum.inr ((paddingOrder padding).symm i) := by + apply (vertexOrder t padding).injective + exact ((vertexOrder t padding).apply_symm_apply _).trans + (congrArg (Fin.natAdd t.darts) ((paddingOrder padding).apply_symm_apply i)).symm + refine (congrArg₂ List.append + (congrArg List.ofFn (funext fun dart => congrArg f (hold dart))) + (congrArg List.ofFn (funext fun index => congrArg f (hnew index)))).trans ?_ + congr 1 + calc + List.ofFn (fun i => f (.inr ((paddingOrder padding).symm i))) = + (List.ofFn (paddingOrder padding).symm).map (fun z => f (.inr z)) := + (List.map_ofFn (f := (paddingOrder padding).symm) (g := fun z => f (.inr z))).symm + _ = _ := by rw [paddingOrder_ofFn] + +theorem paddingList_flatMap {α : Type*} (f : (Σ v : Fin t.vertices, Fin (padding v)) → List α) : + (paddingList padding).flatMap f = + (List.ofFn (fun v : Fin t.vertices => + (List.ofFn (fun j : Fin (padding v) => f ⟨v, j⟩)).flatten)).flatten := by + simp only [paddingList, List.sigma, List.finRange, List.flatMap_def, + List.map_flatten, List.flatten_flatten, List.map_ofFn, Function.comp_def] + +theorem rowsBits_ofCloudTables : + PreprocessingPaddingWords.rowsBits (ofCloudTables t padding tables) = + (List.ofFn (originalVertexBits t padding tables)).flatten ++ + (List.ofFn (fun v : Fin t.vertices => + (List.ofFn (dummyVertexBits t padding tables v)).flatten)).flatten := by + rw [PreprocessingPaddingWords.rowsBits_eq_vertices] + have hblocks : + List.ofFn (fun i : Fin (vertexCount t padding) => + PreprocessingPaddingWords.vertexBits (ofCloudTables t padding tables) i) = + List.ofFn (fun i : Fin (vertexCount t padding) => + vertexBits t padding tables ((vertexOrder t padding).symm i)) := by + apply congrArg List.ofFn + funext i + rw [vertexBits_eq, Equiv.apply_symm_apply] + rw [hblocks, vertexOrder_ofFn, List.flatten_append] + change (List.ofFn (originalVertexBits t padding tables)).flatten ++ + ((paddingList padding).map (fun z => dummyVertexBits t padding tables z.1 z.2)).flatten = _ + rw [← List.flatMap_def, paddingList_flatMap] + +theorem tableBits_ofCloudTables : + PortTables.tableBits (ofCloudTables t padding tables) = + encodeWords [vertexCount t padding, vertexCount t padding * (q + 1)] ++ + (List.ofFn (originalVertexBits t padding tables)).flatten ++ + (List.ofFn (fun v : Fin t.vertices => + (List.ofFn (dummyVertexBits t padding tables v)).flatten)).flatten := by + change encodeWords (PortTables.tableWords (ofCloudTables t padding tables)) = _ + rw [PortTables.tableWords_eq, encodeWords_append] + change encodeWords [vertexCount t padding, vertexCount t padding * (q + 1)] ++ + PreprocessingPaddingWords.rowsBits (ofCloudTables t padding tables) = _ + rw [rowsBits_ofCloudTables, List.append_assoc] + +end IndependentSetsGames.Foundations.PCP.PreprocessingRegularWords + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingStageMaps.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingStageMaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ff9830675afed8202f8eda77c794b9bc0de99a9 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingStageMaps.lean @@ -0,0 +1,38 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingStageMaps +open PreprocessingRegularTables + +abbrev BaseTable := PreprocessingTables.BaseTable + +def regular (H : BaseTable) (t : GraphTables.Table) : PortTables.Input (internalDegree + 1) := + ⟨vertexCount t (PreprocessingRegularTables.padding t), regularize H t⟩ + +def padding (d : Nat) (input : PortTables.Input d) : PortTables.Input d := + ⟨PreprocessingLevels.paddedSize input.1, + PreprocessingPaddingTables.pad input.2 (PreprocessingLevels.le_paddedSize input.1)⟩ + +def familyAt (H : BaseTable) (n : Nat) : + ExpanderTables.Table (PreprocessingLevels.paddedSize n) internalDegree := + resizeTable (PreprocessingLevels.table_vertexCount_eq_paddedSize n) + (ExpanderTables.family H (PreprocessingLevels.boundedLevel n)) + +def paddedOverlay (H : BaseTable) (d : Nat) (input : PortTables.Input d) : + PortTables.Input (d + internalDegree) := + ⟨PreprocessingLevels.paddedSize input.1, + PreprocessingOverlayTables.overlay (padding d input).2 (familyAt H input.1)⟩ + +def lazy (d : Nat) (input : PortTables.Input d) : PortTables.Input (2 * d) := + ⟨input.1, PreprocessingOverlayTables.lazy input.2⟩ + +theorem output_eq (H : BaseTable) (t : GraphTables.Table) : + PreprocessingTables.output H t = + lazy ((internalDegree + 1) + internalDegree) + (paddedOverlay H (internalDegree + 1) (regular H t)) := rfl + +end IndependentSetsGames.Foundations.PCP.PreprocessingStageMaps + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingTableSpectral.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingTableSpectral.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5d4982f20e9b71e345f945178065db570765951 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingTableSpectral.lean @@ -0,0 +1,223 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Minimum +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingTableSpectral + +open PoweringWalks SpectralReturn + +private theorem portGraph_ext {V D : Type*} {G H : PortGraph V D} + (h : ∀ x, G.rot x = H.rot x) : G = H := by + have hr : G.rot = H.rot := Equiv.ext h + cases G + cases H + cases hr + rfl + +theorem materialize_portGraph {n d : Nat} {D : Type*} + (G : ConstraintGraph (Fin n) (Fin n × D) PortTables.Label) + (ports : D ≃ Fin d) : + PortTables.portGraph (PreprocessingOverlayTables.materialize G ports) = + GraphTransport.reindex (Overlay.originalPortGraph G) (Equiv.refl _) ports := by + apply portGraph_ext + intro x + rw [PortTables.portGraph_rot, PreprocessingOverlayTables.rotation_materialize] + rfl + +theorem overlay_portGraph {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) : + PortTables.portGraph (PreprocessingOverlayTables.overlay G H) = + GraphTransport.reindex + (Overlay.portGraph (PortTables.portGraph G) (ExpanderTables.graph H)) + (Equiv.refl _) (PreprocessingOverlayTables.overlayPorts d e) := by + unfold PreprocessingOverlayTables.overlay + rw [materialize_portGraph] + rfl + +theorem overlay_rotation_eq {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (x : Fin n × Fin (d + e)) : + PortTables.rotation (PreprocessingOverlayTables.overlay G H) x = + (GraphTransport.reindex + (Overlay.portGraph (PortTables.portGraph G) (ExpanderTables.graph H)) + (Equiv.refl _) (PreprocessingOverlayTables.overlayPorts d e)).rot x := by + change (PortTables.portGraph (PreprocessingOverlayTables.overlay G H)).rot x = _ + rw [overlay_portGraph] + +theorem lazy_portGraph {n d : Nat} (G : PortTables.Table n d) : + PortTables.portGraph (PreprocessingOverlayTables.lazy G) = + GraphTransport.reindex (lazyGraph (PortTables.portGraph G)) + (Equiv.refl _) (PreprocessingOverlayTables.lazyPorts d) := by + unfold PreprocessingOverlayTables.lazy + rw [materialize_portGraph] + rfl + +theorem lazy_rotation_eq {n d : Nat} (G : PortTables.Table n d) + (x : Fin n × Fin (2 * d)) : + PortTables.rotation (PreprocessingOverlayTables.lazy G) x = + (GraphTransport.reindex (lazyGraph (PortTables.portGraph G)) + (Equiv.refl _) (PreprocessingOverlayTables.lazyPorts d)).rot x := by + change (PortTables.portGraph (PreprocessingOverlayTables.lazy G)).rot x = _ + rw [lazy_portGraph] + +theorem overlay_certificate_seven_eighths {n d e : Nat} + (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (hn : 0 < n) (hdegree : d = e + 1) (he : 8 ≤ e) + (hH : SpectralCertificate (ExpanderTables.graph H) (1 / 2 : ℝ)) : + SpectralCertificate (PortTables.portGraph (PreprocessingOverlayTables.overlay G H)) + (7 / 8 : ℝ) := by + let : Nonempty (Fin n) := ⟨⟨0, hn⟩⟩ + rw [overlay_portGraph] + apply GraphTransport.reindex_spectralCertificate + apply Overlay.spectralCertificate_seven_eighths + (PortTables.portGraph G) (ExpanderTables.graph H) + · simpa only [Fintype.card_fin] using hdegree + · simp only [Fintype.card_fin] + omega + · exact hH + +theorem lazy_certificate_31_32 {n d : Nat} (G : PortTables.Table n d) + (hd : 0 < d) (hG : SpectralCertificate (PortTables.portGraph G) (7 / 8 : ℝ)) : + SpectralCertificate (PortTables.portGraph (PreprocessingOverlayTables.lazy G)) + (31 / 32 : ℝ) := by + let : Nonempty (Fin d) := ⟨⟨0, hd⟩⟩ + rw [lazy_portGraph] + exact GraphTransport.reindex_spectralCertificate _ _ _ _ + (LazySpectral.lazy_certificate_31_32 (PortTables.portGraph G) hG) + +end IndependentSetsGames.Foundations.PCP.PreprocessingTableSpectral + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingGuarantees + +open PoweringWalks SpectralReturn PreprocessingTables +open PreprocessingRegularTables (internalDegree regularize) + +variable {n d e : Nat} + +theorem overlay_rejectionCount (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (labels : Fin n → GraphTables.Label) : + (PortTables.baseGraph (PreprocessingOverlayTables.overlay G H)).rejectionCount labels = + (PortTables.baseGraph G).rejectionCount labels := by + rw [PreprocessingOverlayTables.overlay_semantics] + calc + _ = (Overlay.constraintGraph (PortTables.baseGraph G) (ExpanderTables.graph H)).rejectionCount labels := by + convert ConstraintGraph.reindex_rejectionCount + (Overlay.constraintGraph (PortTables.baseGraph G) (ExpanderTables.graph H)) + (Equiv.refl _) (Equiv.prodCongr (Equiv.refl _) + (PreprocessingOverlayTables.overlayPorts d e)) (Equiv.refl _) labels using 1 + rfl + _ = _ := Overlay.rejectionCount_eq _ _ rfl labels + +theorem lazy_rejectionCount (G : PortTables.Table n d) + (labels : Fin n → GraphTables.Label) : + (PortTables.baseGraph (PreprocessingOverlayTables.lazy G)).rejectionCount labels = + (PortTables.baseGraph G).rejectionCount labels := by + rw [PreprocessingOverlayTables.lazy_semantics] + calc + _ = (LazyConstraint.constraintGraph (PortTables.baseGraph G)).rejectionCount labels := by + convert ConstraintGraph.reindex_rejectionCount + (LazyConstraint.constraintGraph (PortTables.baseGraph G)) + (Equiv.refl _) (Equiv.prodCongr (Equiv.refl _) + (PreprocessingOverlayTables.lazyPorts d)) (Equiv.refl _) labels using 1 + rfl + _ = _ := LazyConstraint.rejectionCount_eq _ rfl labels + +theorem overlayFamily_certificate (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) : + SpectralCertificate (ExpanderTables.graph (overlayFamily H t)) (1 / 2 : ℝ) := by + let : NeZero Expanders.baseDegree := ⟨PreprocessingRegularSoundness.baseDegree_ne_zero⟩ + apply PreprocessingRegularSoundness.resizeTable_certificate + exact ExpanderTables.family_certificate H certificate _ + +theorem overlay_certificate (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) : + SpectralCertificate (PortTables.portGraph + (PreprocessingOverlayTables.overlay (padded H t) (overlayFamily H t))) (7 / 8 : ℝ) := + PreprocessingTableSpectral.overlay_certificate_seven_eighths _ _ + (vertices_positive t) rfl PreprocessingRegularSoundness.internalDegree_ge_eight + (overlayFamily_certificate H certificate t) + +theorem spectral_certificate (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) : + SpectralCertificate (PortTables.portGraph (preprocess H t)) (31 / 32 : ℝ) := by + apply PreprocessingTableSpectral.lazy_certificate_31_32 + · omega + · exact overlay_certificate H certificate t + +def restrictedLabel (t : GraphTables.Table) + (labels : Fin (vertices t) → GraphTables.Label) : + Fin (regularVertices t) → GraphTables.Label := + fun v => labels (v.castLE (PreprocessingLevels.le_paddedSize (regularVertices t))) + +theorem rejectionCount_eq_regularized (H : BaseTable) (t : GraphTables.Table) + (labels : Fin (vertices t) → GraphTables.Label) : + (PortTables.baseGraph (preprocess H t)).rejectionCount labels = + (PortTables.baseGraph (regularize H t)).rejectionCount (restrictedLabel t labels) := by + unfold preprocess PreprocessingTables.degree + rw [lazy_rejectionCount, overlay_rejectionCount] + exact PreprocessingPaddingTables.pad_rejectionCount _ _ labels + +def roundLabels (t : GraphTables.Table) + (labels : Fin (vertices t) → GraphTables.Label) : Fin t.vertices → GraphTables.Label := + PreprocessingRegularSoundness.roundLabels t (restrictedLabel t labels) + +theorem soundness (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) (labels : Fin (vertices t) → GraphTables.Label) : + (GraphTables.semantics t).rejectionCount (roundLabels t labels) ≤ + (PortTables.baseGraph (preprocess H t)).rejectionCount labels := by + rw [rejectionCount_eq_regularized] + exact PreprocessingRegularSoundness.soundness H certificate t (restrictedLabel t labels) + +theorem completeness (H : BaseTable) (t : GraphTables.Table) + (h : (GraphTables.semantics t).Satisfiable) : + (PortTables.baseGraph (preprocess H t)).Satisfiable := by + have hp : (PortTables.baseGraph (padded H t)).Satisfiable := + (PreprocessingPaddingTables.pad_satisfiable_iff _ _).mpr + (PreprocessingRegularSoundness.completeness H t h) + obtain ⟨labels, hlabels⟩ := hp + refine ⟨labels, ?_⟩ + apply (ConstraintGraph.rejectionCount_eq_zero_iff _ labels).mp + unfold preprocess PreprocessingTables.degree + rw [lazy_rejectionCount, overlay_rejectionCount] + exact (ConstraintGraph.rejectionCount_eq_zero_iff _ labels).mpr hlabels + +theorem gap_transfer_real (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) (ht : 0 < t.darts) + (epsilon : ℝ) (he : 0 ≤ epsilon) + (lower : ∀ labels : Fin t.vertices → GraphTables.Label, + epsilon * t.darts ≤ ((GraphTables.semantics t).rejectionCount labels : ℝ)) + (labels : Fin (vertices t) → GraphTables.Label) : + (epsilon / Preprocessing.sizeFactor) * + Fintype.card (Fin (vertices t) × Fin PreprocessingTables.degree) ≤ + ((PortTables.baseGraph (preprocess H t)).rejectionCount labels : ℝ) := by + have hs : (0 : ℝ) < Preprocessing.sizeFactor := + Nat.cast_pos.mpr Preprocessing.sizeFactor_positive + have hcount : Fintype.card (Fin (vertices t) × Fin PreprocessingTables.degree) ≤ + Preprocessing.sizeFactor * t.darts := by + simp only [Fintype.card_prod, Fintype.card_fin] + calc + _ ≤ (ExpanderFamily.growth ^ 2 * t.darts) * PreprocessingTables.degree := + Nat.mul_le_mul_right _ (vertices_le_of_positive t ht) + _ = _ := by rw [PreprocessingTables.degree_eq]; unfold Preprocessing.sizeFactor; ring + have hcountR : (Fintype.card (Fin (vertices t) × Fin PreprocessingTables.degree) : ℝ) ≤ + (Preprocessing.sizeFactor : ℝ) * t.darts := by exact_mod_cast hcount + calc + _ ≤ (epsilon / Preprocessing.sizeFactor) * + ((Preprocessing.sizeFactor : ℝ) * t.darts) := + mul_le_mul_of_nonneg_left hcountR (div_nonneg he hs.le) + _ = epsilon * t.darts := by field_simp + _ ≤ ((GraphTables.semantics t).rejectionCount (roundLabels t labels) : ℝ) := lower _ + _ ≤ _ := Nat.cast_le.mpr (soundness H certificate t labels) + +end IndependentSetsGames.Foundations.PCP.PreprocessingGuarantees +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingTables.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d2c4ac9a63cd3e69ef17196d02eaa911b8c6d0c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingTables.lean @@ -0,0 +1,245 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularTables +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingPaddingTables +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingOverlayTables +import OAI.Combinatorics.IndependentSets.Expansion.LazySpectral + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingTables + +open PreprocessingRegularTables + +abbrev BaseTable := PreprocessingRegularTables.BaseTable + +def degree : Nat := 2 * ((internalDegree + 1) + internalDegree) + +theorem degree_eq : degree = Preprocessing.degree := by + unfold degree internalDegree Preprocessing.degree + rw [pow_two] + omega + +def regularVertices (t : GraphTables.Table) : Nat := vertexCount t (padding t) +def vertices (t : GraphTables.Table) : Nat := PreprocessingLevels.paddedSize (regularVertices t) + +def padded (H : BaseTable) (t : GraphTables.Table) : + PortTables.Table (vertices t) (internalDegree + 1) := + PreprocessingPaddingTables.pad (regularize H t) + (PreprocessingLevels.le_paddedSize (regularVertices t)) + +def overlayFamily (H : BaseTable) (t : GraphTables.Table) : + ExpanderTables.Table (vertices t) internalDegree := + resizeTable (PreprocessingLevels.table_vertexCount_eq_paddedSize (regularVertices t)) + (ExpanderTables.family H (PreprocessingLevels.boundedLevel (regularVertices t))) + +def preprocess (H : BaseTable) (t : GraphTables.Table) : + PortTables.Table (vertices t) degree := + PreprocessingOverlayTables.lazy + (PreprocessingOverlayTables.overlay (padded H t) (overlayFamily H t)) + +def output (H : BaseTable) (t : GraphTables.Table) : PortTables.Input degree := + ⟨vertices t, preprocess H t⟩ + +def graphTable (H : BaseTable) (t : GraphTables.Table) : GraphTables.Table := + PortTables.graphTable (preprocess H t) + +def outputBits (H : BaseTable) (t : GraphTables.Table) : List Bool := + PortTables.tableBits (preprocess H t) + +theorem regularVertices_ge_darts (t : GraphTables.Table) : t.darts ≤ regularVertices t := by + change t.darts ≤ t.darts + _ + omega + +theorem regularVertices_le (t : GraphTables.Table) : + regularVertices t ≤ ExpanderFamily.growth * t.darts := vertexCount_le t + +theorem vertices_positive (t : GraphTables.Table) : 0 < vertices t := + PreprocessingLevels.paddedSize_positive _ + +theorem vertices_le_of_positive (t : GraphTables.Table) (ht : 0 < t.darts) : + vertices t ≤ ExpanderFamily.growth ^ 2 * t.darts := by + have hr : 0 < regularVertices t := ht.trans_le (regularVertices_ge_darts t) + calc + _ ≤ ExpanderFamily.growth * regularVertices t := + (PreprocessingLevels.paddedSize_bounds hr).2 + _ ≤ ExpanderFamily.growth * (ExpanderFamily.growth * t.darts) := + Nat.mul_le_mul_left _ (regularVertices_le t) + _ = _ := by ring + +theorem vertices_eq_one_of_no_darts (t : GraphTables.Table) (ht : t.darts = 0) : + vertices t = 1 := by + unfold vertices regularVertices + rw [vertexCount_eq_zero_of_no_darts t ht, PreprocessingLevels.paddedSize_zero] + +theorem vertices_le (t : GraphTables.Table) : + vertices t ≤ ExpanderFamily.growth ^ 2 * (t.darts + 1) := by + by_cases ht : t.darts = 0 + · rw [vertices_eq_one_of_no_darts t ht, ht] + have hg : 0 < ExpanderFamily.growth := Nat.zero_lt_one.trans ExpanderFamily.growth_gt_one + have hp : 0 < ExpanderFamily.growth ^ 2 := Nat.pow_pos hg + simpa using Nat.succ_le_of_lt hp + · exact (vertices_le_of_positive t (Nat.pos_of_ne_zero ht)).trans + (Nat.mul_le_mul_left _ (Nat.le_succ _)) + +theorem darts_eq (H : BaseTable) (t : GraphTables.Table) : + (graphTable H t).darts = vertices t * degree := rfl + +theorem darts_le (H : BaseTable) (t : GraphTables.Table) : + (graphTable H t).darts ≤ Preprocessing.sizeFactor * (t.darts + 1) := by + rw [darts_eq] + calc + _ ≤ (ExpanderFamily.growth ^ 2 * (t.darts + 1)) * degree := + Nat.mul_le_mul_right _ (vertices_le t) + _ = _ := by rw [degree_eq]; unfold Preprocessing.sizeFactor; ring + +theorem vertices_le_inputBits (t : GraphTables.Table) : + vertices t ≤ ExpanderFamily.growth ^ 2 * ((GraphTables.tableBits t).length + 1) := + (vertices_le t).trans (Nat.mul_le_mul_left _ + (Nat.add_le_add_right (GraphTables.darts_le_tableBits_length t) 1)) + +theorem darts_le_inputBits (H : BaseTable) (t : GraphTables.Table) : + (graphTable H t).darts ≤ + Preprocessing.sizeFactor * ((GraphTables.tableBits t).length + 1) := + (darts_le H t).trans (Nat.mul_le_mul_left _ + (Nat.add_le_add_right (GraphTables.darts_le_tableBits_length t) 1)) + +end IndependentSetsGames.Foundations.PCP.PreprocessingTables +namespace IndependentSetsGames.Foundations.PCP.PreprocessingRegularSoundness + +open PoweringWalks DegreeReplacement SpectralReturn PreprocessingRegularTables + +theorem internalDegree_ge_eight : 8 ≤ internalDegree := by + simpa only [ExpanderFamily.card_port, internalDegree, pow_two] using + ExpanderFamily.port_degree_ge_eight + +theorem baseDegree_ne_zero : Expanders.baseDegree ≠ 0 := by + intro h + have hdegree := internalDegree_ge_eight + simp only [internalDegree, h, Nat.zero_mul] at hdegree + omega + +theorem resizeTable_certificate {n m q : Nat} (h : n = m) + (table : ExpanderTables.Table n q) (lambda : ℝ) + (certificate : SpectralCertificate (ExpanderTables.graph table) lambda) : + SpectralCertificate (ExpanderTables.graph (resizeTable h table)) lambda := by + cases h + exact certificate + +theorem familyCloudTable_certificate_of_pos (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) (v : Fin t.vertices) + (hk : 0 < PreprocessingCloudIndex.cloudSize t v) : + SpectralCertificate (ExpanderTables.graph (familyCloudTable H t v)) (1 / 2 : ℝ) := by + let : NeZero Expanders.baseDegree := ⟨baseDegree_ne_zero⟩ + unfold familyCloudTable + rw [dite_eq_right (Nat.ne_of_gt hk)] + apply resizeTable_certificate + exact ExpanderTables.family_certificate H certificate _ + +theorem cloudGraphs_certificate_of_pos (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) (v : Fin t.vertices) + (hk : 0 < PreprocessingCloudIndex.cloudSize t v) : + SpectralCertificate (cloudGraphs t (padding t) (familyCloudTable H t) v) + (1 / 2 : ℝ) := by + exact GraphTransport.reindex_spectralCertificate _ _ _ _ + (familyCloudTable_certificate_of_pos H certificate t v hk) + +theorem cloud_expansion (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) (v : Fin t.vertices) + (S : Finset (PreprocessingCloudIndex.PaddedCloud t (padding t) v)) + (hsmall : S.card ≤ + Fintype.card (PreprocessingCloudIndex.PaddedCloud t (padding t) v) / 2) : + 2 * S.card ≤ (CloudRounding.directedCut + (fun ed => ((cloudGraphs t (padding t) (familyCloudTable H t) v).rot ed).1) S).card := by + by_cases hk : PreprocessingCloudIndex.cloudSize t v = 0 + · have hzero : Fintype.card (PreprocessingCloudIndex.PaddedCloud t (padding t) v) = 0 := by + rw [PreprocessingCloudIndex.card_paddedCloud, cloudSize_add_padding, hk] + rfl + have hs : S.card = 0 := by omega + simp only [hs, mul_zero, Nat.zero_le] + · exact SpectralCut.cut_card_ge_twice + (cloudGraphs t (padding t) (familyCloudTable H t) v) + (cloudGraphs_certificate_of_pos H certificate t v (Nat.pos_of_ne_zero hk)) + (by simpa only [Fintype.card_fin] using internalDegree_ge_eight) S (by + change 2 * S.card ≤ + Fintype.card (PreprocessingCloudIndex.PaddedCloud t (padding t) v) + omega) + +noncomputable def roundLabels (t : GraphTables.Table) + (labels : Fin (vertexCount t (padding t)) → GraphTables.Label) : + Fin t.vertices → GraphTables.Label := + CloudRounding.roundLabels + (paddedGraph (GraphTables.semantics t) (fun v => Fin (padding t v))) + (fun z => labels (vertexOrder t (padding t) z)) + +theorem soundness (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) + (labels : Fin (vertexCount t (padding t)) → GraphTables.Label) : + (GraphTables.semantics t).rejectionCount (roundLabels t labels) ≤ + (PortTables.baseGraph (regularize H t)).rejectionCount labels := by + rw [regularize, rejectionCount_ofCloudTables] + exact CloudRounding.padded_replacement_soundness (GraphTables.semantics t) + (fun v => Fin (padding t v)) (cloudGraphs t (padding t) (familyCloudTable H t)) + (cloud_expansion H certificate t) (fun z => labels (vertexOrder t (padding t) z)) + +theorem exists_rounding (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) + (labels : Fin (vertexCount t (padding t)) → GraphTables.Label) : + ∃ original : Fin t.vertices → GraphTables.Label, + (GraphTables.semantics t).rejectionCount original ≤ + (PortTables.baseGraph (regularize H t)).rejectionCount labels := + ⟨roundLabels t labels, soundness H certificate t labels⟩ + +theorem lift_rejectionCount (H : BaseTable) (t : GraphTables.Table) + (labels : Fin t.vertices → GraphTables.Label) : + (PortTables.baseGraph (regularize H t)).rejectionCount + (liftedLabel t (padding t) labels) = (GraphTables.semantics t).rejectionCount labels := + rejectionCount_liftedLabel t (padding t) (familyCloudTable H t) labels + +theorem completeness (H : BaseTable) (t : GraphTables.Table) + (h : (GraphTables.semantics t).Satisfiable) : + (PortTables.baseGraph (regularize H t)).Satisfiable := by + obtain ⟨labels, hlabels⟩ := h + refine ⟨liftedLabel t (padding t) labels, ?_⟩ + intro e + obtain ⟨z, rfl⟩ := + (Equiv.prodCongr (vertexOrder t (padding t)) (portOrder internalDegree)).surjective e + rcases z with ⟨v, p⟩ + change (PortTables.baseGraph (regularize H t)).edgeSatisfied + (liftedLabel t (padding t) labels) + (vertexOrder t (padding t) v, portOrder internalDegree p) = true + rw [regularize, edgeSatisfied_ofCloudTables] + simp only [liftedLabel, Equiv.symm_apply_apply] + have hcomplete := replacement_complete + (paddedGraph (GraphTables.semantics t) (fun v => Fin (padding t v))) + (cloudGraphs t (padding t) (familyCloudTable H t)) labels + (padded_complete (GraphTables.semantics t) (fun v => Fin (padding t v)) labels hlabels) + (v, p) + convert hcomplete using 1 + rfl + +theorem soundness_of_uniform_lower_bound (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) (k : Nat) + (lower : ∀ original : Fin t.vertices → GraphTables.Label, + k ≤ (GraphTables.semantics t).rejectionCount original) + (labels : Fin (vertexCount t (padding t)) → GraphTables.Label) : + k ≤ (PortTables.baseGraph (regularize H t)).rejectionCount labels := + (lower (roundLabels t labels)).trans (soundness H certificate t labels) + +theorem soundness_of_uniform_real_lower_bound (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + (t : GraphTables.Table) (k : ℝ) + (lower : ∀ original : Fin t.vertices → GraphTables.Label, + k ≤ ((GraphTables.semantics t).rejectionCount original : ℝ)) + (labels : Fin (vertexCount t (padding t)) → GraphTables.Label) : + k ≤ ((PortTables.baseGraph (regularize H t)).rejectionCount labels : ℝ) := + (lower (roundLabels t labels)).trans (Nat.cast_le.mpr (soundness H certificate t labels)) + +end IndependentSetsGames.Foundations.PCP.PreprocessingRegularSoundness + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Profiles.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Profiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..4370a8947fb4265cb7d0d345c8333f6a8e1aca88 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Profiles.lean @@ -0,0 +1,172 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.SpectralReturn + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.SpectralReturn +open PoweringWalks +open scoped BigOperators +noncomputable section +section Profiles + +variable {V D : Type*} [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + +omit [Nonempty V] [Nonempty D] in +theorem edgeDensity_eq_edge_mean (bad : V × D → Bool) : + edgeDensity bad = mean (fun e => if bad e then (1 : ℝ) else 0) := + (mean_prod (fun e : V × D => if bad e then (1 : ℝ) else 0)).symm + +omit [Nonempty V] [Nonempty D] in +theorem edgeDensity_eq_card (bad : V × D → Bool) : + edgeDensity bad = + ((Finset.univ.filter (fun e => bad e = true)).card : ℝ) / + (Fintype.card (V × D) : ℝ) := by + rw [edgeDensity_eq_edge_mean, mean_eq_sum_div_card] + simp only [Finset.sum_boole] + +omit [Fintype V] [Nonempty V] [Nonempty D] in +theorem edgeProfile_nonnegative (bad : V × D → Bool) (v : V) : 0 ≤ edgeProfile bad v := + mean_nonnegative _ (fun d => by cases bad (v, d) <;> norm_num) + +omit [Fintype V] [Nonempty V] in +theorem edgeProfile_le_one (bad : V × D → Bool) (v : V) : edgeProfile bad v ≤ 1 := by + change mean (fun d => if bad (v, d) then (1 : ℝ) else 0) ≤ 1 + calc + _ ≤ mean (fun _ : D => (1 : ℝ)) := mean_mono (fun d => by + cases bad (v, d) <;> norm_num) + _ = 1 := mean_const _ + +omit [Nonempty V] [Nonempty D] in +theorem edgeDensity_nonnegative (bad : V × D → Bool) : 0 ≤ edgeDensity bad := + mean_nonnegative _ (edgeProfile_nonnegative bad) + +theorem edgeDensity_le_one (bad : V × D → Bool) : edgeDensity bad ≤ 1 := by + calc + _ ≤ mean (fun _ : V => (1 : ℝ)) := mean_mono (edgeProfile_le_one bad) + _ = 1 := mean_const _ + +omit [Nonempty V] in +theorem edgeProfile_energy_le_density (bad : V × D → Bool) : + energy (edgeProfile bad) ≤ edgeDensity bad := + mean_mono (fun v => by + have h0 := edgeProfile_nonnegative bad v + have h1 := edgeProfile_le_one bad v + nlinarith) + +theorem edgeProfile_centered_energy (bad : V × D → Bool) : + energy (fun v => edgeProfile bad v - edgeDensity bad) ≤ + edgeDensity bad * (1 - edgeDensity bad) := by + rw [energy_sub_const] + have h := edgeProfile_energy_le_density bad + change energy (edgeProfile bad) - 2 * edgeDensity bad * edgeDensity bad + + edgeDensity bad ^ 2 ≤ _ + nlinarith + +theorem returnMass_le_sharp (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) (gap : Nat) : + returnMass G bad gap ≤ edgeDensity bad ^ 2 + + lambda ^ gap * (edgeDensity bad * (1 - edgeDensity bad)) := by + rw [returnMass_eq_correlation G bad reversal, correlation_centered] + have hzero : mean (fun v => edgeProfile bad v - edgeDensity bad) = 0 := by + rw [mean_sub, mean_const] + simp only [edgeDensity, sub_self] + have hc := zero_mean_correlation_bound G lambda certificate + (fun v => edgeProfile bad v - edgeDensity bad) hzero gap + have hv := mul_le_mul_of_nonneg_left (edgeProfile_centered_energy bad) + (pow_nonneg certificate.nonnegative gap) + change edgeDensity bad ^ 2 + _ ≤ _ + exact add_le_add (le_refl _) (hc.trans hv) + +theorem returnMass_le (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) (gap : Nat) : + returnMass G bad gap ≤ edgeDensity bad ^ 2 + edgeDensity bad * lambda ^ gap := by + have h := returnMass_le_sharp G lambda certificate bad reversal gap + have hvar : edgeDensity bad * (1 - edgeDensity bad) ≤ edgeDensity bad := by + nlinarith [sq_nonneg (edgeDensity bad)] + have hm := mul_le_mul_of_nonneg_left hvar (pow_nonneg certificate.nonnegative gap) + nlinarith + +theorem adjacent_returnMass_le (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) : + returnMass G bad 0 ≤ edgeDensity bad := by + have h := returnMass_le_sharp G lambda certificate bad reversal 0 + norm_num at h + nlinarith + +end Profiles + +theorem geometric_sum_le (lambda : ℝ) (h0 : 0 ≤ lambda) (h1 : lambda < 1) (n : Nat) : + (∑ k ∈ Finset.range n, lambda ^ k) ≤ 1 / (1 - lambda) := by + have hsum : (∑ k ∈ Finset.range n, lambda ^ k) * (1 - lambda) = 1 - lambda ^ n := by + induction n with + | zero => simp + | succ n ih => rw [Finset.sum_range_succ, pow_succ]; nlinarith + have hden : 0 < 1 - lambda := by linarith + apply (le_div_iff₀ hden).2 + rw [hsum] + linarith [pow_nonneg h0 n] + +variable {V D : Type*} [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + +theorem sum_returnMass_le (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) (n : Nat) : + (∑ gap ∈ Finset.range n, returnMass G bad gap) ≤ + (n : ℝ) * edgeDensity bad ^ 2 + edgeDensity bad / (1 - lambda) := by + calc + _ ≤ ∑ gap ∈ Finset.range n, + (edgeDensity bad ^ 2 + edgeDensity bad * lambda ^ gap) := + Finset.sum_le_sum (fun gap _ => returnMass_le G lambda certificate bad reversal gap) + _ = (n : ℝ) * edgeDensity bad ^ 2 + + edgeDensity bad * (∑ gap ∈ Finset.range n, lambda ^ gap) := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum] + simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul] + _ ≤ (n : ℝ) * edgeDensity bad ^ 2 + edgeDensity bad * (1 / (1 - lambda)) := + add_le_add (le_refl _) + (mul_le_mul_of_nonneg_left + (geometric_sum_le lambda certificate.nonnegative certificate.lt_one n) + (edgeDensity_nonnegative bad)) + _ = _ := by ring + +theorem triangular_returnMass_sum_le (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) (n : Nat) : + (∑ j ∈ Finset.range n, ∑ gap ∈ Finset.range j, returnMass G bad gap) ≤ + ((n : ℝ) * ((n : ℝ) - 1) / 2) * edgeDensity bad ^ 2 + + (n : ℝ) * (edgeDensity bad / (1 - lambda)) := by + induction n with + | zero => simp + | succ n ih => + rw [Finset.sum_range_succ] + have hrow := sum_returnMass_le G lambda certificate bad reversal n + have h := add_le_add ih hrow + calc + _ ≤ ((n : ℝ) * ((n : ℝ) - 1) / 2) * edgeDensity bad ^ 2 + + (n : ℝ) * (edgeDensity bad / (1 - lambda)) + + ((n : ℝ) * edgeDensity bad ^ 2 + edgeDensity bad / (1 - lambda)) := h + _ = _ := by simp only [Nat.cast_add, Nat.cast_one]; ring + +theorem secondMoment_return_envelope (G : PortGraph V D) (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) (n : Nat) : + (n : ℝ) * edgeDensity bad + + 2 * (∑ j ∈ Finset.range n, ∑ gap ∈ Finset.range j, returnMass G bad gap) ≤ + (n : ℝ) * edgeDensity bad * + (1 + 2 / (1 - lambda) + ((n : ℝ) - 1) * edgeDensity bad) := by + calc + _ ≤ (n : ℝ) * edgeDensity bad + + 2 * (((n : ℝ) * ((n : ℝ) - 1) / 2) * edgeDensity bad ^ 2 + + (n : ℝ) * (edgeDensity bad / (1 - lambda))) := + add_le_add (le_refl _) + (mul_le_mul_of_nonneg_left + (triangular_returnMass_sum_le G lambda certificate bad reversal n) (by norm_num)) + _ = _ := by ring + +end + +end IndependentSetsGames.Foundations.PCP.SpectralReturn + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Regularization.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Regularization.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcd1f395ccaf4683245e76ca3bad3b1dffb19d7f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Regularization.lean @@ -0,0 +1,162 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.Finite2 +import OAI.Combinatorics.IndependentSets.Expansion.GraphRounding +import OAI.Combinatorics.IndependentSets.Expansion.Indicators + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.Regularization + +open PoweringWalks DegreeReplacement + +variable {V E A : Type*} [Fintype V] [Fintype E] [Fintype A] +variable [DecidableEq V] [DecidableEq E] [DecidableEq A] + +abbrev Vertex (G : ConstraintGraph V E A) := PaddedDart G (CloudPadding.dummy G) +abbrev Port := ExpanderFamily.Port ⊕ Unit + +def degree : Nat := Fintype.card Port + +theorem degree_eq : degree = Fintype.card ExpanderFamily.Port + 1 := by + simp [degree, Port] + +theorem degree_positive : 0 < degree := by rw [degree_eq]; omega + +def cloudEquiv (G : ConstraintGraph V E A) (v : V) + (hk : 0 < Fintype.card (Cloud G v)) : + ExpanderFamily.Vertex (ExpanderFamily.level (Fintype.card (Cloud G v))) ≃ + Cloud (paddedGraph G (CloudPadding.dummy G)) v := + Fintype.equivOfCardEq (CloudPadding.card_cloud_eq_family G v hk).symm + +def cloudGraph (G : ConstraintGraph V E A) (v : V) : + PortGraph (Cloud (paddedGraph G (CloudPadding.dummy G)) v) ExpanderFamily.Port := + if hk : Fintype.card (Cloud G v) = 0 then + { rot := Equiv.refl _ + rot_involutive := fun _ => rfl } + else + GraphTransport.reindex + (ExpanderFamily.family (ExpanderFamily.level (Fintype.card (Cloud G v)))) + (cloudEquiv G v (Nat.pos_of_ne_zero hk)) (Equiv.refl _) + +omit [Fintype A] [DecidableEq E] [DecidableEq A] in +theorem cloudGraph_of_pos (G : ConstraintGraph V E A) (v : V) + (hk : 0 < Fintype.card (Cloud G v)) : + cloudGraph G v = GraphTransport.reindex + (ExpanderFamily.family (ExpanderFamily.level (Fintype.card (Cloud G v)))) + (cloudEquiv G v hk) (Equiv.refl _) := by + simp only [cloudGraph, dite_eq_right (Nat.ne_of_gt hk)] + +omit [Fintype A] [DecidableEq E] [DecidableEq A] in +theorem cloudGraph_certificate_of_pos (G : ConstraintGraph V E A) (v : V) + (hk : 0 < Fintype.card (Cloud G v)) : + SpectralReturn.SpectralCertificate (cloudGraph G v) (1 / 2 : ℝ) := by + rw [cloudGraph_of_pos G v hk] + exact GraphTransport.reindex_spectralCertificate _ _ _ _ + (ExpanderFamily.family_certificate _) + +omit [Fintype A] [DecidableEq A] in +theorem cloud_expansion (G : ConstraintGraph V E A) (v : V) + (S : Finset (Cloud (paddedGraph G (CloudPadding.dummy G)) v)) + (hsmall : S.card ≤ + Fintype.card (Cloud (paddedGraph G (CloudPadding.dummy G)) v) / 2) : + 2 * S.card ≤ + (CloudRounding.directedCut (fun ed => ((cloudGraph G v).rot ed).1) S).card := by + by_cases hk : Fintype.card (Cloud G v) = 0 + · have hzero : Fintype.card (Cloud (paddedGraph G (CloudPadding.dummy G)) v) = 0 := by + rw [CloudPadding.card_cloud, hk, CloudPadding.paddedSize_zero] + have hs : S.card = 0 := by omega + simp only [hs, mul_zero, Nat.zero_le] + · exact SpectralCut.cut_card_ge_twice (cloudGraph G v) + (cloudGraph_certificate_of_pos G v (Nat.pos_of_ne_zero hk)) + ExpanderFamily.port_degree_ge_eight S (by omega) + +def portGraph (G : ConstraintGraph V E A) : PortGraph (Vertex G) Port := + paddedReplacementPortGraph G (CloudPadding.dummy G) (cloudGraph G) + +def graph (G : ConstraintGraph V E A) : + ConstraintGraph (Vertex G) (Vertex G × Port) A := + paddedReplacementGraph G (CloudPadding.dummy G) (cloudGraph G) + +omit [Fintype A] [DecidableEq E] in +@[simp] theorem graph_tail (G : ConstraintGraph V E A) (e : Vertex G × Port) : + (graph G).tail e = e.1 := rfl + +omit [Fintype A] [DecidableEq E] in +theorem graph_reverse (G : ConstraintGraph V E A) : + (graph G).reverse = (portGraph G).rot := rfl + +def degreeEquiv (G : ConstraintGraph V E A) (v : Vertex G) : + Cloud (graph G) v ≃ Port where + toFun e := e.val.2 + invFun d := ⟨(v, d), rfl⟩ + left_inv := by + rintro ⟨⟨w, d⟩, hw⟩ + change w = v at hw + cases hw + rfl + right_inv _ := rfl + +omit [Fintype A] in +theorem fixed_degree (G : ConstraintGraph V E A) (v : Vertex G) : + Fintype.card (Cloud (graph G) v) = degree := + Fintype.card_congr (degreeEquiv G v) + +omit [Fintype A] [DecidableEq E] [DecidableEq A] in +theorem vertex_count_le (G : ConstraintGraph V E A) : + Fintype.card (Vertex G) ≤ ExpanderFamily.growth * Fintype.card E := + CloudPadding.card_paddedDart_le G + +omit [Fintype A] [DecidableEq E] [DecidableEq A] in +theorem dart_count (G : ConstraintGraph V E A) : + Fintype.card (Vertex G × Port) = Fintype.card (Vertex G) * degree := + Fintype.card_prod _ _ + +omit [Fintype A] [DecidableEq E] [DecidableEq A] in +theorem dart_count_le (G : ConstraintGraph V E A) : + Fintype.card (Vertex G × Port) ≤ + (ExpanderFamily.growth * degree) * Fintype.card E := by + rw [dart_count] + calc + Fintype.card (Vertex G) * degree ≤ + (ExpanderFamily.growth * Fintype.card E) * degree := + Nat.mul_le_mul_right degree (vertex_count_le G) + _ = (ExpanderFamily.growth * degree) * Fintype.card E := Nat.mul_right_comm _ _ _ + +def liftLabel (G : ConstraintGraph V E A) (labeling : V → A) : Vertex G → A := + DegreeReplacement.liftLabel (paddedGraph G (CloudPadding.dummy G)) labeling + +omit [Fintype A] [DecidableEq E] in +theorem lift_rejectionCount (G : ConstraintGraph V E A) (labeling : V → A) : + (graph G).rejectionCount (liftLabel G labeling) = G.rejectionCount labeling := + paddedReplacement_rejectionCount G (CloudPadding.dummy G) (cloudGraph G) labeling + +omit [Fintype A] [DecidableEq E] in +theorem completeness (G : ConstraintGraph V E A) (h : G.Satisfiable) : + (graph G).Satisfiable := + replacement_satisfiable (paddedGraph G (CloudPadding.dummy G)) (cloudGraph G) + (padded_satisfiable G (CloudPadding.dummy G) h) + +def roundLabels [Nonempty A] (G : ConstraintGraph V E A) (ell : Vertex G → A) : V → A := + CloudRounding.roundLabels (paddedGraph G (CloudPadding.dummy G)) ell + +theorem soundness [Nonempty A] (G : ConstraintGraph V E A) (ell : Vertex G → A) : + G.rejectionCount (roundLabels G ell) ≤ (graph G).rejectionCount ell := + CloudRounding.padded_replacement_soundness G (CloudPadding.dummy G) + (cloudGraph G) (cloud_expansion G) ell + +theorem exists_rounding [Nonempty A] (G : ConstraintGraph V E A) (ell : Vertex G → A) : + ∃ labeling : V → A, G.rejectionCount labeling ≤ (graph G).rejectionCount ell := + ⟨roundLabels G ell, soundness G ell⟩ + +theorem soundness_of_uniform_lower_bound [Nonempty A] (G : ConstraintGraph V E A) + (k : Nat) (lower : ∀ labeling : V → A, k ≤ G.rejectionCount labeling) + (ell : Vertex G → A) : k ≤ (graph G).rejectionCount ell := + (lower (roundLabels G ell)).trans (soundness G ell) + +end IndependentSetsGames.Foundations.PCP.Regularization + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/RoundComputation.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/RoundComputation.lean new file mode 100644 index 0000000000000000000000000000000000000000..11ef7c5af461c654e8c86a800dad16094cd43e08 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/RoundComputation.lean @@ -0,0 +1,90 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Gap +import OAI.Combinatorics.IndependentSets.Machines.MachineFiniteAlphabet +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineRuntime + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RoundComputation + +open Turing +open IndependentSetsGames.Foundations.Complexity + +abbrev PreprocessingCertificate (H : RoundTables.BaseTable) := + TM2ComputableInPolyTime GraphTables.tableBits + (PortTables.inputBits (ports := PreprocessingTables.degree)) + (PreprocessingTables.output H) + +abbrev PoweringCertificate := + TM2ComputableInPolyTime + (PortTables.inputBits (ports := PreprocessingTables.degree)) + (GenericGraphTables.tableBits (q := RoundTables.alphabet)) + (PoweringTables.transform PreprocessingTables.degree RoundTables.walkParameter) + +theorem powered_eq_transform (H : RoundTables.BaseTable) (table : GraphTables.Table) : + RoundTables.powered H table = + PoweringTables.transform PreprocessingTables.degree RoundTables.walkParameter + (PreprocessingTables.output H table) := rfl + +noncomputable def poweredPolynomialTimeOfCertificates (H : RoundTables.BaseTable) + (preprocessing : PreprocessingCertificate H) (powering : PoweringCertificate) : + TM2ComputableInPolyTime GraphTables.tableBits + (GenericGraphTables.tableBits (q := RoundTables.alphabet)) + (RoundTables.powered H) := by + change TM2ComputableInPolyTime GraphTables.tableBits _ + (fun table => PoweringTables.transform PreprocessingTables.degree + RoundTables.walkParameter (PreprocessingTables.output H table)) + exact MachineSequential.composeBits preprocessing powering + +noncomputable def tablePolynomialTimeOfCertificates (H : RoundTables.BaseTable) + (preprocessing : PreprocessingCertificate H) (powering : PoweringCertificate) : + TM2ComputableInPolyTime GraphTables.tableBits GraphTables.tableBits + (RoundTables.build H) := by + change TM2ComputableInPolyTime GraphTables.tableBits GraphTables.tableBits + (fun table => AlphabetTable.Table.build (RoundTables.powered H table)) + exact MachineSequential.composeBits + (poweredPolynomialTimeOfCertificates H preprocessing powering) + (AlphabetTable.Runtime.tablePolynomialTime RoundTables.alphabet) + +theorem powered_finiteAlphabet (H : RoundTables.BaseTable) + (preprocessing : PreprocessingCertificate H) (powering : PoweringCertificate) + (hpreprocessing : MachineFiniteAlphabet.FiniteAlphabet preprocessing.tm) + (hpowering : MachineFiniteAlphabet.FiniteAlphabet powering.tm) : + MachineFiniteAlphabet.FiniteAlphabet + (poweredPolynomialTimeOfCertificates H preprocessing powering).tm := + MachineFiniteAlphabet.composeBits preprocessing powering hpreprocessing hpowering + +theorem finiteAlphabet (H : RoundTables.BaseTable) + (preprocessing : PreprocessingCertificate H) (powering : PoweringCertificate) + (hpreprocessing : MachineFiniteAlphabet.FiniteAlphabet preprocessing.tm) + (hpowering : MachineFiniteAlphabet.FiniteAlphabet powering.tm) : + MachineFiniteAlphabet.FiniteAlphabet + (tablePolynomialTimeOfCertificates H preprocessing powering).tm := + MachineFiniteAlphabet.composeBits + (poweredPolynomialTimeOfCertificates H preprocessing powering) + (AlphabetTable.Runtime.tablePolynomialTime RoundTables.alphabet) + (powered_finiteAlphabet H preprocessing powering hpreprocessing hpowering) + (AlphabetTable.Runtime.finiteAlphabet RoundTables.alphabet) + +noncomputable def tablePolynomialTime (H : RoundTables.BaseTable) + (preprocessing : PreprocessingCertificate H) : + TM2ComputableInPolyTime GraphTables.tableBits GraphTables.tableBits + (RoundTables.build H) := + tablePolynomialTimeOfCertificates H preprocessing + (PoweringMachineRuntime.computableInPolyTime PreprocessingTables.degree + RoundTables.walkParameter) + +theorem tablePolynomialTime_finite_alphabet (H : RoundTables.BaseTable) + (preprocessing : PreprocessingCertificate H) + (hpreprocessing : MachineFiniteAlphabet.FiniteAlphabet preprocessing.tm) : + MachineFiniteAlphabet.FiniteAlphabet + (tablePolynomialTime H preprocessing).tm := + finiteAlphabet H preprocessing + (PoweringMachineRuntime.computableInPolyTime PreprocessingTables.degree + RoundTables.walkParameter) hpreprocessing + (PoweringMachineRuntime.computableInPolyTime_finite_alphabet + PreprocessingTables.degree RoundTables.walkParameter) + +end IndependentSetsGames.Foundations.PCP.RoundComputation + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Row.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Row.lean new file mode 100644 index 0000000000000000000000000000000000000000..09e9e3800ee2b57ac54be5afe3c184d9cc57c684 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Row.lean @@ -0,0 +1,96 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Enumeration + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMasterState +open Turing +open MachineFixedBlockMap +section Row + +variable {K Λ : Type} [DecidableEq K] {N M : Nat} + +def encodedBlockAt (src dst : K) (F : Buffer N → Buffer M) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (Master N) := + MachineStateEquiv.statement (rowEquiv N).symm + (PoweringMachineRow.encodedBlockAt src dst F exit) + +theorem stepAux_encodedBlockAt (src dst : K) (F : Buffer N → Buffer M) + (exit : Option Λ) (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : Master N) (tapes : K → List Bool) + (hinput : tapes src = PoweringMachineRow.encodeBits (List.ofFn bits) ++ suffix) : + TM2.stepAux (encodedBlockAt src dst F exit) state tapes = + { l := exit, var := clearBuffer state, + stk := Function.update (Function.update tapes src suffix) dst + (PoweringMachineRow.encodeBits (List.ofFn (F bits)) ++ tapes dst) } := by + rw [encodedBlockAt, MachineStateEquiv.stepAux_transport_symm, Equiv.symm_symm] + rw [PoweringMachineRow.stepAux_encodedBlockAt src dst F exit hne bits suffix + (rowEquiv N state) tapes hinput] + rfl + +theorem step_encodedBlockAt (src dst : K) (F : Buffer N → Buffer M) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (Master N)) + (label : Λ) (atLabel : program label = encodedBlockAt src dst F exit) + (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : Master N) (tapes : K → List Bool) + (hinput : tapes src = PoweringMachineRow.encodeBits (List.ofFn bits) ++ suffix) : + TM2.step program ⟨some label, state, tapes⟩ = + some ⟨exit, clearBuffer state, + Function.update (Function.update tapes src suffix) dst + (PoweringMachineRow.encodeBits (List.ofFn (F bits)) ++ tapes dst)⟩ := by + simp only [TM2.step, atLabel, stepAux_encodedBlockAt src dst F exit hne bits suffix state tapes hinput] + +def rowAt {t S q : Nat} (src dst : K) + (labelAt : Fin q → Fin S → PCP.GraphTables.Label) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (Master (PoweringMachineRow.inputSize t S)) := + encodedBlockAt src dst (PoweringMachineRow.rowBlock labelAt) exit + +theorem step_rowAt_clean {t S q : Nat} (src dst : K) + (labelAt : Fin q → Fin S → PCP.GraphTables.Label) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ + (Master (PoweringMachineRow.inputSize t S))) + (label : Λ) (atLabel : program label = rowAt (t := t) src dst labelAt exit) + (hne : src ≠ dst) (bits register : Buffer (PoweringMachineRow.inputSize t S)) + (suffix : List Bool) (tapes : K → List Bool) + (hinput : tapes src = PoweringMachineRow.encodeBits (List.ofFn bits) ++ suffix) : + TM2.step program ⟨some label, withBuffer register, tapes⟩ = + some ⟨exit, clean (PoweringMachineRow.inputSize t S), + Function.update (Function.update tapes src suffix) dst + (PoweringMachineRow.encodeBits (List.ofFn (PoweringMachineRow.rowBlock labelAt bits)) ++ + tapes dst)⟩ := by + simpa only [rowAt, clearBuffer_withBuffer] using + step_encodedBlockAt src dst (PoweringMachineRow.rowBlock labelAt) exit + program label atLabel hne bits suffix (withBuffer register) tapes hinput + +def rowInTime {t S q : Nat} (src dst : K) + (labelAt : Fin q → Fin S → PCP.GraphTables.Label) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ + (Master (PoweringMachineRow.inputSize t S))) + (label : Λ) (atLabel : program label = rowAt (t := t) src dst labelAt exit) + (hne : src ≠ dst) (bits register : Buffer (PoweringMachineRow.inputSize t S)) + (suffix : List Bool) (tapes : K → List Bool) + (hinput : tapes src = PoweringMachineRow.encodeBits (List.ofFn bits) ++ suffix) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some label, withBuffer register, tapes⟩ + (some ⟨exit, clean (PoweringMachineRow.inputSize t S), + Function.update (Function.update tapes src suffix) dst + (PoweringMachineRow.encodeBits (List.ofFn (PoweringMachineRow.rowBlock labelAt bits)) ++ + tapes dst)⟩) 1 where + steps := 1 + evals_in_steps := by + simpa only [Function.iterate_one, flip, bind, Option.bind] using + step_rowAt_clean src dst labelAt exit program label atLabel hne bits register suffix tapes hinput + steps_le_m := le_rfl + +end Row + +def headerInTime (N B n : Nat) (suffix : List Bool) (state : Master N) : + StateTransition.EvalsToInTime + (TM2.step (PoweringMachineLoop.headerProgram (σ := OtherRegisters N) B)) + ⟨some .initialize, state, PoweringMachineLoop.initialTapes n suffix⟩ + (some (PoweringMachineLoop.finalConfiguration B n suffix state.1)) (n + 2) := + PoweringMachineLoop.headerInTime B n suffix state.1 state.2 + +end IndependentSetsGames.Foundations.Complexity.PoweringMasterState + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/SpectralReturn.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/SpectralReturn.lean new file mode 100644 index 0000000000000000000000000000000000000000..99c262a4cf6fd626a807a39891f04609156fd33e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/SpectralReturn.lean @@ -0,0 +1,230 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Bits +import OAI.Combinatorics.IndependentSets.Expansion.PoweringWalks + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.SpectralReturn + +open PoweringWalks +open scoped BigOperators + +noncomputable section + +def mean {A : Type*} [Fintype A] (f : A → ℝ) : ℝ := Finset.univ.expect f + +def energy {A : Type*} [Fintype A] (f : A → ℝ) : ℝ := mean (fun x => (f x) ^ 2) + +def correlation {A : Type*} [Fintype A] (f g : A → ℝ) : ℝ := + mean (fun x => f x * g x) + +def averagingOperator {V D : Type*} [Fintype D] (G : PortGraph V D) + (f : V → ℝ) (v : V) : ℝ := Finset.univ.expect (fun d => f (G.rot (v, d)).1) + +def iterateOperator {V D : Type*} [Fintype D] (G : PortGraph V D) : + Nat → (V → ℝ) → (V → ℝ) + | 0, f => f + | n + 1, f => averagingOperator G (iterateOperator G n f) + +def edgeProfile {V D : Type*} [Fintype D] (bad : V × D → Bool) (v : V) : ℝ := + Finset.univ.expect (fun d => if bad (v, d) then 1 else 0) + +def edgeDensity {V D : Type*} [Fintype V] [Fintype D] (bad : V × D → Bool) : ℝ := + mean (edgeProfile bad) + +def markedStep {V D : Type*} [Fintype D] (G : PortGraph V D) + (bad : V × D → Bool) (f : V → ℝ) (v : V) : ℝ := + Finset.univ.expect (fun d => if bad (v, d) then f (G.rot (v, d)).1 else 0) + +def returnMass {V D : Type*} [Fintype V] [Fintype D] + (G : PortGraph V D) (bad : V × D → Bool) (gap : Nat) : ℝ := + mean (markedStep G bad (iterateOperator G gap (edgeProfile bad))) + +structure SpectralCertificate {V D : Type*} [Fintype V] [Fintype D] + (G : PortGraph V D) (lambda : ℝ) : Prop where + nonnegative : 0 ≤ lambda + lt_one : lambda < 1 + contraction : ∀ f : V → ℝ, mean f = 0 → + energy (averagingOperator G f) ≤ lambda ^ 2 * energy f + +section Averages + +variable {A B : Type*} [Fintype A] [Fintype B] + +theorem mean_eq_sum_div_card (f : A → ℝ) : + mean f = (∑ x, f x) / (Fintype.card A : ℝ) := + Fintype.expect_eq_sum_div_card f + +theorem mean_equiv (e : A ≃ B) (f : B → ℝ) : + mean (fun x => f (e x)) = mean f := + Fintype.expect_equiv e _ _ (fun _ => rfl) + +theorem mean_prod (f : A × B → ℝ) : + mean f = mean (fun a => mean (fun b => f (a, b))) := by + simpa only [mean, Finset.univ_product_univ] using + Finset.expect_product (Finset.univ : Finset A) (Finset.univ : Finset B) f + +@[simp] theorem mean_const [Nonempty A] (c : ℝ) : mean (fun _ : A => c) = c := + Fintype.expect_const c + +theorem mean_add (f g : A → ℝ) : + mean (fun x => f x + g x) = mean f + mean g := + Finset.expect_add_distrib _ f g + +theorem mean_sub (f g : A → ℝ) : + mean (fun x => f x - g x) = mean f - mean g := + Finset.expect_sub_distrib _ f g + +theorem mean_mul_left (c : ℝ) (f : A → ℝ) : + mean (fun x => c * f x) = c * mean f := + (Finset.mul_expect _ f c).symm + +theorem mean_mul_right (f : A → ℝ) (c : ℝ) : + mean (fun x => f x * c) = mean f * c := + (Finset.expect_mul _ f c).symm + +theorem mean_nonnegative (f : A → ℝ) (hf : ∀ x, 0 ≤ f x) : 0 ≤ mean f := + Finset.expect_nonneg (fun x _ => hf x) + +theorem mean_mono {f g : A → ℝ} (h : ∀ x, f x ≤ g x) : mean f ≤ mean g := + Finset.expect_le_expect (fun x _ => h x) + +theorem energy_nonnegative (f : A → ℝ) : 0 ≤ energy f := + mean_nonnegative _ (fun x => sq_nonneg (f x)) + +theorem correlation_sq_le (f g : A → ℝ) : + correlation f g ^ 2 ≤ energy f * energy g := + Finset.expect_mul_sq_le_sq_mul_sq Finset.univ f g + +theorem energy_sub_const [Nonempty A] (f : A → ℝ) (c : ℝ) : + energy (fun x => f x - c) = energy f - 2 * c * mean f + c ^ 2 := by + have h : (fun x => (f x - c) ^ 2) = + (fun x => (f x) ^ 2 - (2 * c) * f x + c ^ 2) := by + funext x + ring + unfold energy + rw [h, mean_add, mean_sub, mean_mul_left, mean_const] + +theorem correlation_sub_const [Nonempty A] (f g : A → ℝ) (c d : ℝ) : + correlation (fun x => f x - c) (fun x => g x - d) = + correlation f g - d * mean f - c * mean g + c * d := by + have h : (fun x => (f x - c) * (g x - d)) = + (fun x => f x * g x - d * f x - c * g x + c * d) := by + funext x + ring + unfold correlation + rw [h, mean_add, mean_sub, mean_sub, mean_mul_left, mean_mul_left, mean_const] + +end Averages + +variable {V D : Type*} [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + (G : PortGraph V D) + +omit [Nonempty V] in +theorem mean_operator (f : V → ℝ) : mean (averagingOperator G f) = mean f := by + calc + mean (averagingOperator G f) = mean (fun e : V × D => f (G.rot e).1) := + (mean_prod (fun e : V × D => f (G.rot e).1)).symm + _ = mean (fun e : V × D => f e.1) := mean_equiv G.rot (fun e => f e.1) + _ = mean (fun v : V => mean (fun _ : D => f v)) := + mean_prod (fun e : V × D => f e.1) + _ = mean f := by simp only [mean_const] + +omit [Fintype V] [Nonempty V] in +theorem operator_sub_const (f : V → ℝ) (c : ℝ) : + averagingOperator G (fun v => f v - c) = fun v => averagingOperator G f v - c := by + funext v + change mean (fun d => f (G.rot (v, d)).1 - c) = _ + rw [mean_sub, mean_const] + rfl + +omit [Nonempty V] in +theorem mean_iterate (n : Nat) (f : V → ℝ) : mean (iterateOperator G n f) = mean f := by + induction n with + | zero => rfl + | succ n ih => rw [iterateOperator, mean_operator, ih] + +omit [Fintype V] [Nonempty V] in +theorem iterate_sub_const (n : Nat) (f : V → ℝ) (c : ℝ) : + iterateOperator G n (fun v => f v - c) = fun v => iterateOperator G n f v - c := by + induction n with + | zero => rfl + | succ n ih => rw [iterateOperator, ih, operator_sub_const]; rfl + +omit [Nonempty V] [Nonempty D] in +theorem mean_markedStep (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) (f : V → ℝ) : + mean (markedStep G bad f) = correlation (edgeProfile bad) f := by + calc + mean (markedStep G bad f) = + mean (fun e : V × D => if bad e then f (G.rot e).1 else 0) := by + exact (mean_prod (fun e : V × D => if bad e then f (G.rot e).1 else 0)).symm + _ = mean (fun e : V × D => if bad (G.rot e) + then f (G.rot (G.rot e)).1 else 0) := + (mean_equiv G.rot (fun e : V × D => if bad e then f (G.rot e).1 else 0)).symm + _ = mean (fun e : V × D => if bad e then f e.1 else 0) := by + congr 1 + funext e + rw [reversal e, G.rot_involutive e] + _ = mean (fun v => mean (fun d => if bad (v, d) then f v else 0)) := + mean_prod (fun e : V × D => if bad e then f e.1 else 0) + _ = correlation (edgeProfile bad) f := by + unfold correlation + congr 1 + funext v + have h : (fun d => if bad (v, d) then f v else 0) = + (fun d => (if bad (v, d) then (1 : ℝ) else 0) * f v) := by + funext d + cases bad (v, d) <;> simp + rw [h, mean_mul_right] + rfl + +omit [Nonempty V] [Nonempty D] in +theorem returnMass_eq_correlation (bad : V × D → Bool) + (reversal : ∀ e, bad (G.rot e) = bad e) (gap : Nat) : + returnMass G bad gap = correlation (edgeProfile bad) + (iterateOperator G gap (edgeProfile bad)) := + mean_markedStep G bad reversal _ + +omit [Nonempty V] in +theorem iterate_energy_bound (lambda : ℝ) (certificate : SpectralCertificate G lambda) + (f : V → ℝ) (hf : mean f = 0) (n : Nat) : + energy (iterateOperator G n f) ≤ (lambda ^ n) ^ 2 * energy f := by + induction n with + | zero => simp [iterateOperator] + | succ n ih => + calc + energy (iterateOperator G (n + 1) f) ≤ + lambda ^ 2 * energy (iterateOperator G n f) := + certificate.contraction _ ((mean_iterate G n f).trans hf) + _ ≤ lambda ^ 2 * ((lambda ^ n) ^ 2 * energy f) := + mul_le_mul_of_nonneg_left ih (sq_nonneg lambda) + _ = (lambda ^ (n + 1)) ^ 2 * energy f := by rw [pow_succ]; ring + +omit [Nonempty V] in +theorem zero_mean_correlation_bound (lambda : ℝ) + (certificate : SpectralCertificate G lambda) (f : V → ℝ) + (hf : mean f = 0) (n : Nat) : + correlation f (iterateOperator G n f) ≤ lambda ^ n * energy f := by + have hsq : correlation f (iterateOperator G n f) ^ 2 ≤ + (lambda ^ n * energy f) ^ 2 := by + calc + _ ≤ energy f * energy (iterateOperator G n f) := correlation_sq_le _ _ + _ ≤ energy f * ((lambda ^ n) ^ 2 * energy f) := + mul_le_mul_of_nonneg_left (iterate_energy_bound G lambda certificate f hf n) + (energy_nonnegative f) + _ = _ := by ring + exact le_of_sq_le_sq hsq + (mul_nonneg (pow_nonneg certificate.nonnegative n) (energy_nonnegative f)) + +theorem correlation_centered (f : V → ℝ) (n : Nat) : + correlation f (iterateOperator G n f) = mean f ^ 2 + + correlation (fun v => f v - mean f) + (iterateOperator G n (fun v => f v - mean f)) := by + rw [iterate_sub_const, correlation_sub_const, mean_iterate] + ring + +end +end IndependentSetsGames.Foundations.PCP.SpectralReturn + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Supported.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Supported.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e4eba04ab8bb78a74386fd8fc492c40073a140c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Supported.lean @@ -0,0 +1,142 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Fourier + +namespace OAI + +namespace LargeIndependentSets.BooleanJunta +open scoped BigOperators +open scoped Classical + +lemma degree_eq_sum {n : ℕ} (s : Cube n) : + (degree s : ℝ) = ∑ i : Fin n, if bit s i then (1:ℝ) else 0 := by + induction n with + | zero => simp [degree] + | succ n ih => + obtain ⟨b,s⟩ := s + rw [Fin.sum_univ_succ] + cases b <;> simp only [degree, bit, Bool.false_eq_true, ↓reduceIte, + Fin.cases_zero, Fin.cases_succ, Nat.cast_add, Nat.cast_one, + zero_add, ih] <;> rfl + +def Supported {n : ℕ} (S : Finset (Fin n)) (s : Cube n) : Prop := + ∀ i, bit s i = true → i ∈ S + +noncomputable def walsh : {n : ℕ} → Cube n → Cube n → ℝ + | 0, _, _ => 1 + | _+1, (b,s), (c,x) => (if b && c then -1 else 1) * walsh s x + +lemma synth_eq_sum {n : ℕ} (a : Cube n → ℝ) (x : Cube n) : + synth a x = ∑ s, a s * walsh s x := by + induction n with + | zero => simp [synth, walsh] + | succ n ih => + obtain ⟨b,x⟩ := x + rw [sum_succ] + simp only [synth, walsh, Bool.false_and, Bool.true_and, Bool.false_eq_true, + ↓reduceIte, one_mul, ih] + rw [Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro s _ + ring + +lemma walsh_depends {n : ℕ} (s x y : Cube n) + (h : ∀ i, bit s i = true → bit x i = bit y i) : walsh s x = walsh s y := by + induction n with + | zero => rfl + | succ n ih => + obtain ⟨b,s⟩ := s + obtain ⟨c,x⟩ := x + obtain ⟨d,y⟩ := y + have ht : walsh s x = walsh s y := ih s x y (fun i hi => h i.succ hi) + have hh : b = true → c = d := fun hb => h 0 hb + cases b + · simp [walsh, ht] + · have he := hh rfl + subst d + simp [walsh, ht] + +noncomputable def truncate {n : ℕ} (S : Finset (Fin n)) (f : Cube n → ℝ) : Cube n → ℝ := + synth (fun s => if Supported S s then fourier f s else 0) + +lemma truncate_depends {n : ℕ} (S : Finset (Fin n)) (f : Cube n → ℝ) (x y : Cube n) + (h : ∀ i ∈ S, bit x i = bit y i) : truncate S f x = truncate S f y := by + rw [truncate, synth_eq_sum, synth_eq_sum] + apply Finset.sum_congr rfl + intro s _ + by_cases hs : Supported S s + · simp only [ite_eq_left hs] + rw [walsh_depends s x y (fun i hi => h i (hs i hi))] + · simp only [ite_eq_right hs, zero_mul] + +lemma truncate_error {n : ℕ} (S : Finset (Fin n)) (f : Cube n → ℝ) : + mean (fun x => (f x - truncate S f x)^2) = + ∑ s, if Supported S s then 0 else (fourier f s)^2 := by + rw [← fourier_parseval, fourier_sub] + simp only [truncate, fourier_synth] + apply Finset.sum_congr rfl + intro s _ + split_ifs <;> simp + +noncomputable def influence {n : ℕ} (f : Cube n → ℝ) (i : Fin n) : ℝ := + mean (fun x => |diff i f x|) + +lemma influence_nonneg {n : ℕ} (f : Cube n → ℝ) (i : Fin n) : 0 ≤ influence f i := + mean_nonneg (fun _ => abs_nonneg _) + +lemma diff_bounded {n : ℕ} (f : Cube n → ℝ) (hf : ∀ x, |f x| ≤ 1) (i : Fin n) : + ∀ x, |diff i f x| ≤ 1 := by + intro x + dsimp [diff] + rw [abs_div, abs_of_pos (by norm_num : (0:ℝ)<2)] + apply (div_le_iff₀ (by norm_num : (0:ℝ)<2)).mpr + have h := abs_sub (f x) (f (flip i x)) + linarith [hf x, hf (flip i x)] + +lemma diff_square_le_influence {n : ℕ} (f : Cube n → ℝ) (hf : ∀ x, |f x| ≤ 1) + (i : Fin n) : mean (fun x => diff i f x^2) ≤ influence f i := by + apply mean_mono + intro x + have h := diff_bounded f hf i x + nlinarith [abs_nonneg (diff i f x), sq_abs (diff i f x)] + +lemma weighted_fourier_energy {n : ℕ} (f : Cube n → ℝ) : + (∑ s, (degree s : ℝ) * (fourier f s)^2) = + ∑ i : Fin n, mean (fun x => diff i f x^2) := by + simp_rw [degree_eq_sum, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + rw [← fourier_parseval, fourier_diff] + apply Finset.sum_congr rfl + intro s _ + cases h : bit s i <;> simp [h] + +lemma noise_small_influence {n : ℕ} (f : Cube n → ℝ) (hf : ∀ x, |f x| ≤ 1) + (i : Fin n) {θ : ℝ} (hθ : 0 ≤ θ) (hi : influence f i ≤ θ^2) : + mean (fun x => noise (1/2) (diff i f) x^2) ≤ θ * influence f i := by + have h := noise_small_l1 (diff i f) (diff_bounded f hf i) + have hI := influence_nonneg f i + have hN : 0 ≤ mean (fun x => noise (1/2) (diff i f) x^2) := mean_nonneg (fun _ => sq_nonneg _) + change _ ≤ influence f i ^ 3 at h + have hm := mul_le_mul_of_nonneg_right hi (sq_nonneg (influence f i)) + nlinarith [mul_nonneg hθ hI] + +lemma noise_weight_cancel (d : ℕ) : (4:ℝ)^d * ((1/2:ℝ)^d)^2 = 1 := by + calc + _ = ((4:ℝ) * (1/2:ℝ)^2)^d := by rw [mul_pow, pow_right_comm] + _ = 1 := by norm_num + +lemma low_degree_coefficient {n : ℕ} (g : Cube n → ℝ) (s : Cube n) {k : ℕ} + (hk : degree s ≤ k) : + (fourier g s)^2 ≤ (4:ℝ)^k * (fourier (noise (1/2) g) s)^2 := by + rw [fourier_noise] + have hp : (4:ℝ)^(degree s) ≤ (4:ℝ)^k := pow_le_pow_right₀ (by norm_num) hk + have hm := mul_le_mul_of_nonneg_right hp (sq_nonneg ((1/2:ℝ)^(degree s))) + rw [noise_weight_cancel] at hm + have hm' := mul_le_mul_of_nonneg_right hm (sq_nonneg (fourier g s)) + nlinarith + +end LargeIndependentSets.BooleanJunta + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/Supported2.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/Supported2.lean new file mode 100644 index 0000000000000000000000000000000000000000..cdc41def7f3b634721383506b1d46b6b0cd54adf --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/Supported2.lean @@ -0,0 +1,139 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.FiniteParameterSelection +import OAI.Combinatorics.IndependentSets.Reduction.DeletedProjection +import OAI.Combinatorics.IndependentSets.Reduction.Law + +namespace OAI + +namespace LargeIndependentSets +open scoped BigOperators Classical +open BooleanJunta PhaseTest Coefficient + +lemma LayerLaw.sum_supported {r s : ℕ} (μ : LayerLaw r s) (f : Finset (Fin r) → ℚ) : + (∑ B : {B : Finset (Fin r) // B.card = s}, μ.weight B.val * f B.val) = + ∑ B, μ.weight B * f B := by + rw [← Finset.sum_subtype (Finset.univ.filter (fun B : Finset (Fin r) => B.card = s)) + (by simp) (fun B => μ.weight B * f B)] + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro B _ + by_cases h : B.card = s + · rw [ite_eq_left h] + · rw [ite_eq_right h, μ.support B h, zero_mul] + +noncomputable def LayerLaw.supported {r s : ℕ} (μ : LayerLaw r s) : + RationalLaw {B : Finset (Fin r) // B.card = s} where + weight B := μ.weight B.val + nonneg B := μ.nonneg B.val + total := by + simpa using (μ.sum_supported (fun _ => 1)).trans (by simpa using μ.total) + +lemma LayerLaw.expect_supported {r s : ℕ} (μ : LayerLaw r s) (f : Finset (Fin r) → ℝ) : + (∑ B : {B : Finset (Fin r) // B.card = s}, (μ.supported.weight B : ℝ) * f B.val) = + ∑ B, (μ.weight B : ℝ) * f B := by + change (∑ B : {B : Finset (Fin r) // B.card = s}, (μ.weight B.val : ℝ) * f B.val) = _ + rw [← Finset.sum_subtype (Finset.univ.filter (fun B : Finset (Fin r) => B.card = s)) + (by simp) (fun B => (μ.weight B : ℝ) * f B)] + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro B _ + by_cases h : B.card = s + · rw [ite_eq_left h] + · rw [ite_eq_right h, μ.support B h, Rat.cast_zero, zero_mul] + +lemma LayerLaw.bad_supported {r s : ℕ} (μ : LayerLaw r s) + {M : Type} (A : Finset (Fin r) → Finset M) : + (∑ B : {B : Finset (Fin r) // B.card = s}, (μ.supported.weight B : ℝ) * + (if ¬Aligned A B.val then 1 else 0)) = (μ.badMass A : ℝ) := by + rw [μ.expect_supported (fun B => if ¬Aligned A B then 1 else 0)] + simp only [LayerLaw.badMass, Rat.cast_sum] + apply Finset.sum_congr rfl + intro B _ + by_cases h : Aligned A B <;> simp [h] + +abbrev SamplerOutcome (L R : Type) (n s m k : ℕ) := + Σ B : {B : Finset (Fin (n+1)) // B.card = s}, + Σ _t : B.val → Fin (m+1), SubchainCoord L R n B.val → Cube k + +noncomputable def samplerLaw {L R : Type} [Fintype L] [Fintype R] + {n s : ℕ} (μ : LayerLaw (n+1) s) (m k : ℕ) {ρ : ℚ} (hρ : 0 ≤ ρ) : + RationalLaw (SamplerOutcome L R n s m k) := + μ.supported.bind (fun B => + (RationalLaw.pi (fun _ : B.val => Coefficient.law m hρ)).bind (fun _ => + RationalLaw.uniform (SubchainCoord L R n B.val → Cube k))) + +lemma supported_nonempty {n s : ℕ} (hs : 0 < s) + (B : {B : Finset (Fin (n+1)) // B.card = s}) : B.val.Nonempty := + Finset.card_pos.mp (by omega) + +noncomputable def sampleLocation {U V L R C : Type} [Fintype L] [Fintype R] + {n s m k : ℕ} (lc : LabelCoverData U V L R C) (chain : Fin n → C) (hs : 0 < s) + (o : SamplerOutcome L R n s m k) : + GridLocation (LayerAnswer L R (U:=U) (V:=V) (n:=n)) (m*2^k) := + let b := subchainBase o.1.val (supported_nonempty hs o.1) + ⟨occurrenceQuestion lc chain b.val, + gridLocation (fun j : o.1.val => + chainComposite lc chain b.val.val j.val.val (subchainBase_le _ _ j)) + o.2.1 (fun c => gridEquiv k (o.2.2 c))⟩ + +lemma sampleLocation_phase {U V L R C : Type} [Fintype L] [Fintype R] + {n s m k : ℕ} (lc : LabelCoverData U V L R C) (chain : Fin n → C) + (hs : 0 < s) (hm : 0 < m) + (F : ∀ q : LayerQuestion U V n, (LayerAnswer L R q → Circle) → ℝ) + (o : SamplerOutcome L R n s m k) : + letI : NeZero (m*2^k) := ⟨Nat.ne_of_gt (Nat.mul_pos hm (by positivity))⟩ + F (sampleLocation lc chain hs o).1 (torusGrid (sampleLocation lc chain hs o).2) = + viewFunction F (supported_nonempty hs o.1) (chainView lc chain o.1.val) o.2.1 + (fun c => scalarCell (o.2.2 c) 0) := by + let : NeZero (m*2^k) := ⟨Nat.ne_of_gt (Nat.mul_pos hm (by positivity))⟩ + let b := subchainBase o.1.val (supported_nonempty hs o.1) + exact congrArg (F (occurrenceQuestion lc chain b.val)) + (gridLocation_cube (fun j : o.1.val => + chainComposite lc chain b.val.val j.val.val (subchainBase_le _ _ j)) hm k o.2.1 o.2.2) + +theorem sampler_expectation {U V L R C : Type} [Fintype L] [Fintype R] + {n s m k : ℕ} (lc : LabelCoverData U V L R C) (chain : Fin n → C) + (μ : LayerLaw (n+1) s) {ρ : ℚ} (hρ : 0 ≤ ρ) (hs : 0 < s) (hm : 0 < m) + (F : ∀ q : LayerQuestion U V n, (LayerAnswer L R q → Circle) → ℝ) : + letI : NeZero (m*2^k) := ⟨Nat.ne_of_gt (Nat.mul_pos hm (by positivity))⟩ + (∑ o, ((samplerLaw (L:=L) (R:=R) μ m k hρ).weight o : ℝ) * + (F (sampleLocation lc chain hs o).1 (torusGrid (sampleLocation lc chain hs o).2))^2) = + ∑ B, (μ.supported.weight B : ℝ) * + fiberSquare lc chain F B.val (supported_nonempty hs B) m ρ k := by + let : NeZero (m*2^k) := ⟨Nat.ne_of_gt (Nat.mul_pos hm (by positivity))⟩ + unfold samplerLaw + rw [RationalLaw.expect_bind] + apply Finset.sum_congr rfl + intro B _ + congr 1 + rw [RationalLaw.expect_bind] + unfold fiberSquare + apply Finset.sum_congr rfl + intro t _ + rw [Coefficient.pi_law_real] + congr 1 + rw [RationalLaw.expect_uniform] + apply Finset.expect_congr rfl + intro v _ + rw [sampleLocation_phase lc chain hs hm F] + +lemma fiberSquare_le_one {U V L R C : Type} [Fintype L] [Fintype R] + {n : ℕ} (lc : LabelCoverData U V L R C) (chain : Fin n → C) + (F : ∀ q : LayerQuestion U V n, (LayerAnswer L R q → Circle) → ℝ) + (hb : ∀ q x, |F q x| ≤ 1) (B : Finset (Fin (n+1))) (hB : B.Nonempty) + (m k : ℕ) {ρ : ℝ} (hρ : 0 ≤ ρ) : fiberSquare lc chain F B hB m ρ k ≤ 1 := by + unfold fiberSquare + calc + _ ≤ ∑ t : B → Fin (m+1), mass m ρ t * 1 := by + apply Finset.sum_le_sum + intro t _ + apply mul_le_mul_of_nonneg_left _ (mass_nonneg m hρ t) + apply Finset.expect_le Finset.univ_nonempty + intro v _ + change (F _ _)^2 ≤ 1 + exact (sq_le_one_iff_abs_le_one _).mpr (hb _ _) + _ = 1 := by simpa using (mass_total (ι:=B) m hρ) + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Expansion/ZigzagSpectral.lean b/lean/OAI/Combinatorics/IndependentSets/Expansion/ZigzagSpectral.lean new file mode 100644 index 0000000000000000000000000000000000000000..406ded2712a87e2106be1811d789e7bead82c2e3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Expansion/ZigzagSpectral.lean @@ -0,0 +1,276 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.Finite + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.ZigzagSpectral + +open PoweringWalks SpectralReturn ZigzagGraphs + +noncomputable section + +variable {V D E : Type*} + +def cloudMean [Fintype D] (f : V × D → ℝ) (v : V) : ℝ := + mean (fun d => f (v, d)) + +def liftCloud (f : V → ℝ) (x : V × D) : ℝ := f x.1 + +def projection [Fintype D] (f : V × D → ℝ) : V × D → ℝ := + liftCloud (cloudMean f) + +def centered [Fintype D] (f : V × D → ℝ) : V × D → ℝ := f - projection f + +theorem mean_liftCloud [Fintype V] [Fintype D] [Nonempty D] (f : V → ℝ) : + mean (liftCloud (D := D) f) = mean f := by + change mean (fun x : V × D => f x.1) = mean f + rw [mean_prod] + simp only [mean_const] + +theorem energy_liftCloud [Fintype V] [Fintype D] [Nonempty D] (f : V → ℝ) : + energy (liftCloud (D := D) f) = energy f := + mean_liftCloud (D := D) (fun v => f v ^ 2) + +theorem mean_cloudMean [Fintype V] [Fintype D] (f : V × D → ℝ) : + mean (cloudMean f) = mean f := (mean_prod f).symm + +theorem energy_prod [Fintype V] [Fintype D] (f : V × D → ℝ) : + energy f = mean (fun v => energy (fun d => f (v, d))) := + mean_prod (fun x => f x ^ 2) + +theorem cloudMean_centered_zero [Fintype D] [Nonempty D] + (f : V × D → ℝ) (v : V) : cloudMean (centered f) v = 0 := by + change mean (fun d => f (v, d) - cloudMean f v) = 0 + rw [mean_sub, mean_const] + exact sub_self _ + +theorem energy_centered_eq_sub [Fintype V] [Fintype D] [Nonempty D] + (f : V × D → ℝ) : energy (centered f) = energy f - energy (projection f) := by + have hpoint (v : V) : energy (fun d => centered f (v, d)) = + energy (fun d => f (v, d)) - (cloudMean f v) ^ 2 := by + change energy (fun d => f (v, d) - cloudMean f v) = _ + rw [energy_sub_const] + change energy (fun d => f (v, d)) - 2 * cloudMean f v * cloudMean f v + + (cloudMean f v) ^ 2 = _ + ring + have hproj : energy (projection f) = energy (cloudMean f) := energy_liftCloud _ + calc + energy (centered f) = mean (fun v => energy (fun d => centered f (v, d))) := + energy_prod _ + _ = mean (fun v => energy (fun d => f (v, d)) - (cloudMean f v) ^ 2) := by + congr 1 + funext v + exact hpoint v + _ = mean (fun v => energy (fun d => f (v, d))) - + mean (fun v => (cloudMean f v) ^ 2) := mean_sub _ _ + _ = energy f - energy (projection f) := by + rw [← energy_prod f, hproj] + rfl + +theorem projection_energy_decomposition [Fintype V] [Fintype D] [Nonempty D] + (f : V × D → ℝ) : energy f = energy (projection f) + energy (centered f) := by + rw [energy_centered_eq_sub] + ring + +theorem energy_projection_le [Fintype V] [Fintype D] [Nonempty D] + (f : V × D → ℝ) : energy (projection f) ≤ energy f := by + have h := projection_energy_decomposition f + have hn := energy_nonnegative (centered f) + linarith + +theorem energy_centered_le [Fintype V] [Fintype D] [Nonempty D] + (f : V × D → ℝ) : energy (centered f) ≤ energy f := by + rw [energy_centered_eq_sub] + exact sub_le_self _ (energy_nonnegative _) + +theorem mean_sq_le_energy {A : Type*} [Fintype A] [Nonempty A] (f : A → ℝ) : + mean f ^ 2 ≤ energy f := by + have h := correlation_sq_le f (fun _ => 1) + simpa [correlation, energy] using h + +theorem averaging_energy_le [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + (G : PortGraph V D) (f : V → ℝ) : energy (averagingOperator G f) ≤ energy f := by + calc + energy (averagingOperator G f) ≤ mean (averagingOperator G (fun v => f v ^ 2)) := by + apply mean_mono + intro v + exact mean_sq_le_energy (fun d => f (G.rot (v, d)).1) + _ = energy f := mean_operator G _ + +theorem cloudOperator_add [Fintype E] (H : PortGraph D E) (f g : V × D → ℝ) : + cloudOperator H (f + g) = cloudOperator H f + cloudOperator H g := by + funext x + exact mean_add _ _ + +theorem cloudOperator_sub [Fintype E] (H : PortGraph D E) (f g : V × D → ℝ) : + cloudOperator H (f - g) = cloudOperator H f - cloudOperator H g := by + funext x + exact mean_sub _ _ + +theorem cloudOperator_projection [Fintype D] [Fintype E] [Nonempty E] + (H : PortGraph D E) (f : V × D → ℝ) : cloudOperator H (projection f) = projection f := by + funext x + change mean (fun _ : E => cloudMean f x.1) = cloudMean f x.1 + exact mean_const _ + +theorem cloudOperator_centered [Fintype D] [Fintype E] [Nonempty E] + (H : PortGraph D E) (f : V × D → ℝ) : + cloudOperator H (centered f) = cloudOperator H f - projection f := by + unfold centered + rw [cloudOperator_sub, cloudOperator_projection] + +theorem graphPermutation_energy [Fintype V] [Fintype D] (G : PortGraph V D) + (f : V × D → ℝ) : energy (graphPermutation G f) = energy f := + mean_equiv G.rot (fun x => f x ^ 2) + +theorem cloud_energy_le [Fintype V] [Fintype D] [Fintype E] + [Nonempty D] [Nonempty E] (H : PortGraph D E) (f : V × D → ℝ) : + energy (cloudOperator H f) ≤ energy f := by + calc + energy (cloudOperator H f) = + mean (fun v => energy (averagingOperator H (fun d => f (v, d)))) := energy_prod _ + _ ≤ mean (fun v => energy (fun d => f (v, d))) := + mean_mono (fun v => averaging_energy_le H _) + _ = energy f := (energy_prod f).symm + +theorem cloud_centered_contraction [Fintype V] [Fintype D] [Fintype E] + (H : PortGraph D E) (lambda : ℝ) (hH : SpectralCertificate H lambda) + (f : V × D → ℝ) (hzero : ∀ v, cloudMean f v = 0) : + energy (cloudOperator H f) ≤ lambda ^ 2 * energy f := by + calc + energy (cloudOperator H f) = + mean (fun v => energy (averagingOperator H (fun d => f (v, d)))) := energy_prod _ + _ ≤ mean (fun v => lambda ^ 2 * energy (fun d => f (v, d))) := + mean_mono (fun v => hH.contraction _ (hzero v)) + _ = lambda ^ 2 * mean (fun v => energy (fun d => f (v, d))) := mean_mul_left _ _ + _ = lambda ^ 2 * energy f := by rw [← energy_prod f] + +theorem cloud_residual_bound [Fintype V] [Fintype D] [Fintype E] + [Nonempty D] [Nonempty E] (H : PortGraph D E) (lambda : ℝ) + (hH : SpectralCertificate H lambda) (f : V × D → ℝ) : + energy (cloudOperator H f - projection f) ≤ lambda ^ 2 * energy f := by + rw [← cloudOperator_centered H f] + exact (cloud_centered_contraction H lambda hH (centered f) + (cloudMean_centered_zero f)).trans + (mul_le_mul_of_nonneg_left (energy_centered_le f) (sq_nonneg lambda)) + +theorem projection_graphPermutation_projection [Fintype D] (G : PortGraph V D) + (f : V × D → ℝ) : + projection (graphPermutation G (projection f)) = + liftCloud (averagingOperator G (cloudMean f)) := rfl + +theorem projected_outer_bound [Fintype V] [Fintype D] [Nonempty D] + (G : PortGraph V D) (lambda : ℝ) (hG : SpectralCertificate G lambda) + (f : V × D → ℝ) (hf : mean f = 0) : + energy (projection (graphPermutation G (projection f))) ≤ + lambda ^ 2 * energy (projection f) := by + have hzero : mean (cloudMean f) = 0 := (mean_cloudMean f).trans hf + have hleft : energy (projection (graphPermutation G (projection f))) = + energy (averagingOperator G (cloudMean f)) := by + rw [projection_graphPermutation_projection] + exact energy_liftCloud _ + have hright : energy (projection f) = energy (cloudMean f) := energy_liftCloud _ + rw [hleft, hright] + exact hG.contraction _ hzero + +theorem energy_add_three_le {A : Type*} [Fintype A] (a b c : A → ℝ) : + energy (a + b + c) ≤ 3 * (energy a + energy b + energy c) := by + calc + energy (a + b + c) ≤ mean (fun x => 3 * (a x ^ 2 + b x ^ 2 + c x ^ 2)) := by + apply mean_mono + intro x + change (a x + b x + c x) ^ 2 ≤ 3 * (a x ^ 2 + b x ^ 2 + c x ^ 2) + nlinarith [sq_nonneg (a x - b x), sq_nonneg (a x - c x), sq_nonneg (b x - c x)] + _ = 3 * (energy a + energy b + energy c) := by + rw [mean_mul_left, mean_add, mean_add] + rfl + +theorem zigzag_energy_bound [Fintype V] [Fintype D] [Fintype E] + [Nonempty D] [Nonempty E] + (G : PortGraph V D) (H : PortGraph D E) (lambdaG lambdaH : ℝ) + (hG : SpectralCertificate G lambdaG) (hH : SpectralCertificate H lambdaH) + (f : V × D → ℝ) (hf : mean f = 0) : + energy (averagingOperator (zigzag G H) f) ≤ + 3 * (lambdaG ^ 2 + lambdaH ^ 2) * energy f := by + let u := projection f + let v := centered f + let a := projection (graphPermutation G u) + let b := cloudOperator H (graphPermutation G u) - a + let c := cloudOperator H (graphPermutation G (cloudOperator H v)) + have hfactor : averagingOperator (zigzag G H) f = a + b + c := by + rw [averagingOperator_zigzag] + have hf' : f = u + v := by + funext x + change f x = projection f x + (f x - projection f x) + ring + have hbu : cloudOperator H u = u := cloudOperator_projection H f + have hbf : cloudOperator H f = u + cloudOperator H v := by + rw [hf', cloudOperator_add, hbu] + rw [hbf] + have hp : graphPermutation G (u + cloudOperator H v) = + graphPermutation G u + graphPermutation G (cloudOperator H v) := rfl + rw [hp, cloudOperator_add] + change cloudOperator H (graphPermutation G u) + c = + a + (cloudOperator H (graphPermutation G u) - a) + c + funext x + change cloudOperator H (graphPermutation G u) x + c x = + a x + (cloudOperator H (graphPermutation G u) x - a x) + c x + ring + have ha : energy a ≤ lambdaG ^ 2 * energy u := projected_outer_bound G lambdaG hG f hf + have hb : energy b ≤ lambdaH ^ 2 * energy u := by + have h := cloud_residual_bound H lambdaH hH (graphPermutation G u) + simpa only [graphPermutation_energy] using h + have hc : energy c ≤ lambdaH ^ 2 * energy v := by + calc + energy c ≤ energy (graphPermutation G (cloudOperator H v)) := cloud_energy_le H _ + _ = energy (cloudOperator H v) := graphPermutation_energy G _ + _ ≤ lambdaH ^ 2 * energy v := + cloud_centered_contraction H lambdaH hH v (cloudMean_centered_zero f) + rw [hfactor] + calc + energy (a + b + c) ≤ 3 * (energy a + energy b + energy c) := energy_add_three_le _ _ _ + _ ≤ 3 * (lambdaG ^ 2 * energy u + lambdaH ^ 2 * energy u + lambdaH ^ 2 * energy v) := + mul_le_mul_of_nonneg_left (add_le_add (add_le_add ha hb) hc) (by norm_num) + _ ≤ 3 * (lambdaG ^ 2 + lambdaH ^ 2) * energy f := by + have hdecomp : energy f = energy u + energy v := projection_energy_decomposition f + rw [hdecomp] + have hn := mul_nonneg (sq_nonneg lambdaG) (energy_nonnegative v) + nlinarith + +theorem square_certificate [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] + (G : PortGraph V D) (lambda : ℝ) (hG : SpectralCertificate G lambda) : + SpectralCertificate (square G) (lambda ^ 2) where + nonnegative := sq_nonneg lambda + lt_one := by + have hprod := mul_pos (sub_pos.mpr hG.lt_one) + (show 0 < 1 + lambda by linarith [hG.nonnegative]) + nlinarith + contraction f hf := by + rw [averagingOperator_square] + calc + energy (averagingOperator G (averagingOperator G f)) ≤ + lambda ^ 2 * energy (averagingOperator G f) := + hG.contraction _ ((mean_operator G f).trans hf) + _ ≤ lambda ^ 2 * (lambda ^ 2 * energy f) := + mul_le_mul_of_nonneg_left (hG.contraction f hf) (sq_nonneg lambda) + _ = (lambda ^ 2) ^ 2 * energy f := by ring + +theorem square_zigzag_halfCertificate [Fintype V] [Fintype D] [Fintype E] + [Nonempty V] [Nonempty D] [Nonempty E] + (G : PortGraph V D) (H : PortGraph (D × D) E) + (hG : SpectralCertificate G (1 / 2)) (hH : SpectralCertificate H (1 / 100)) : + SpectralCertificate (zigzag (square G) H) (1 / 2) where + nonnegative := by norm_num + lt_one := by norm_num + contraction f hf := by + have h := zigzag_energy_bound (square G) H ((1 / 2 : ℝ) ^ 2) (1 / 100) + (square_certificate G (1 / 2) hG) hH f hf + have hcoef : 3 * (((1 / 2 : ℝ) ^ 2) ^ 2 + (1 / 100) ^ 2) ≤ (1 / 2 : ℝ) ^ 2 := by + norm_num + exact h.trans (mul_le_mul_of_nonneg_right hcoef (energy_nonnegative f)) + +end + +end IndependentSetsGames.Foundations.PCP.ZigzagSpectral + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Contexts.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Contexts.lean new file mode 100644 index 0000000000000000000000000000000000000000..f909f4d5330aaee68b3015b1d03e56629ee2ccc4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Contexts.lean @@ -0,0 +1,218 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ClauseVerifier + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceContexts + +open Target PCP + +def clauseAnswerEquiv : ClauseAnswer ≃ Bool × Bool × Bool where + toFun a := (a.first, a.second, a.third) + invFun a := ⟨a.1, a.2.1, a.2.2⟩ + left_inv a := by cases a; rfl + right_inv a := by rcases a with ⟨a, b, c⟩; rfl + +def clauseAnswerFinEquiv : ClauseAnswer ≃ Fin 8 := + clauseAnswerEquiv.trans + ((Equiv.prodCongr finTwoEquiv.symm + (Equiv.prodCongr finTwoEquiv.symm finTwoEquiv.symm)).trans + ((Equiv.prodCongr (Equiv.refl (Fin 2)) finProdFinEquiv).trans finProdFinEquiv)) + +instance clauseAnswerFintype : Fintype ClauseAnswer := + Fintype.ofEquiv (Bool × Bool × Bool) clauseAnswerEquiv.symm + +instance clauseAnswerInhabited : Inhabited ClauseAnswer := ⟨⟨false, false, false⟩⟩ + +instance slotFintype : Fintype Slot where + elems := {.first, .second, .third} + complete s := by cases s <;> simp + +instance slotInhabited : Inhabited Slot := ⟨.first⟩ + +@[simp] theorem card_clauseAnswer : Fintype.card ClauseAnswer = 8 := by + rw [Fintype.card_congr clauseAnswerFinEquiv] + rfl + +@[simp] theorem card_slot : Fintype.card Slot = 3 := by decide + +abbrev I (u : ℕ) := Fin u → Bool +abbrev J (u : ℕ) := Fin u → ClauseAnswer +abbrev ClauseContext (F : Formula) (u : ℕ) := Fin u → Fin F.clauses.length +abbrev VariableContext (F : Formula) (u : ℕ) := Fin u → Fin F.«variables» +abbrev SlotContext (u : ℕ) := Fin u → Slot + +@[simp] theorem card_I (u : ℕ) : Fintype.card (I u) = 2 ^ u := by simp [I] +@[simp] theorem card_J (u : ℕ) : Fintype.card (J u) = 8 ^ u := by simp [J] +@[simp] theorem card_ClauseContext (F : Formula) (u : ℕ) : + Fintype.card (ClauseContext F u) = F.clauses.length ^ u := by simp [ClauseContext] +@[simp] theorem card_VariableContext (F : Formula) (u : ℕ) : + Fintype.card (VariableContext F u) = F.«variables» ^ u := by simp [VariableContext] +@[simp] theorem card_SlotContext (u : ℕ) : + Fintype.card (SlotContext u) = 3 ^ u := by simp [SlotContext] + +def localConsistent {n : ℕ} (clause : Clause n) (answer : ClauseAnswer) : Bool := + decide (∀ s s' : Slot, nameAt clause s = nameAt clause s' → + answerAt answer s = answerAt answer s') + +@[simp] theorem localConsistent_eq_true_iff {n : ℕ} + (clause : Clause n) (answer : ClauseAnswer) : + localConsistent clause answer = true ↔ + ∀ s s' : Slot, nameAt clause s = nameAt clause s' → + answerAt answer s = answerAt answer s' := by + simp [localConsistent] + +def validJ (F : Formula) {u : ℕ} (c : ClauseContext F u) (j : J u) : Bool := + decide ((∀ t, localSatisfies (clauseAt F (c t)) (j t) = true) ∧ + ∀ t t' s s', nameAt (clauseAt F (c t)) s = nameAt (clauseAt F (c t')) s' → + answerAt (j t) s = answerAt (j t') s') + +@[simp] theorem validJ_eq_true_iff (F : Formula) {u : ℕ} + (c : ClauseContext F u) (j : J u) : + validJ F c j = true ↔ + (∀ t, localSatisfies (clauseAt F (c t)) (j t) = true) ∧ + ∀ t t' s s', nameAt (clauseAt F (c t)) s = nameAt (clauseAt F (c t')) s' → + answerAt (j t) s = answerAt (j t') s' := by + simp [validJ] + +theorem validJ_satisfies (F : Formula) {u : ℕ} (c : ClauseContext F u) + (j : J u) (hj : validJ F c j = true) (t : Fin u) : + localSatisfies (clauseAt F (c t)) (j t) = true := + ((validJ_eq_true_iff F c j).mp hj).1 t + +theorem validJ_consistent (F : Formula) {u : ℕ} (c : ClauseContext F u) + (j : J u) (hj : validJ F c j = true) (t : Fin u) (s : Slot) + (t' : Fin u) (s' : Slot) + (hname : nameAt (clauseAt F (c t)) s = nameAt (clauseAt F (c t')) s') : + answerAt (j t) s = answerAt (j t') s' := + ((validJ_eq_true_iff F c j).mp hj).2 t t' s s' hname + +theorem validJ_localConsistent (F : Formula) {u : ℕ} (c : ClauseContext F u) + (j : J u) (hj : validJ F c j = true) (t : Fin u) : + localConsistent (clauseAt F (c t)) (j t) = true := by + apply (localConsistent_eq_true_iff _ _).mpr + intro s s' hs + exact validJ_consistent F c j hj t s t s' hs + +def canonicalSlot {n : ℕ} (clause : Clause n) (v : Fin n) : Slot := + if nameAt clause .first = v then .first + else if nameAt clause .second = v then .second else .third + +theorem canonicalSlot_name {n : ℕ} (clause : Clause n) (v : Fin n) + (hv : ∃ s, nameAt clause s = v) : nameAt clause (canonicalSlot clause v) = v := by + by_cases hfirst : nameAt clause .first = v + · simp [canonicalSlot, hfirst] + by_cases hsecond : nameAt clause .second = v + · simp [canonicalSlot, hfirst, hsecond] + obtain ⟨s, hs⟩ := hv + cases s with + | first => exact False.elim (hfirst hs) + | second => exact False.elim (hsecond hs) + | third => simpa [canonicalSlot, hfirst, hsecond] using hs + +def pi (F : Formula) {u : ℕ} (c : ClauseContext F u) (v : VariableContext F u) + (j : J u) : I u := + fun t => answerAt (j t) (canonicalSlot (clauseAt F (c t)) (v t)) + +def sampledVariables (F : Formula) {u : ℕ} (c : ClauseContext F u) + (s : SlotContext u) : VariableContext F u := + fun t => nameAt (clauseAt F (c t)) (s t) + +theorem sampledVariables_supported (F : Formula) {u : ℕ} + (c : ClauseContext F u) (s : SlotContext u) : + ∀ t, ∃ slot, nameAt (clauseAt F (c t)) slot = sampledVariables F c s t := + fun t => ⟨s t, rfl⟩ + +theorem sampled_eq_pi (F : Formula) {u : ℕ} (c : ClauseContext F u) + (v : VariableContext F u) (j : J u) (hj : validJ F c j = true) + (t : Fin u) (s : Slot) (hs : nameAt (clauseAt F (c t)) s = v t) : + answerAt (j t) s = pi F c v j t := by + exact validJ_consistent F c j hj t s t + (canonicalSlot (clauseAt F (c t)) (v t)) + (hs.trans (canonicalSlot_name _ _ ⟨s, hs⟩).symm) + +theorem sampled_answers_eq_of_visible_eq (F : Formula) {u : ℕ} + (c : ClauseContext F u) (s s' : SlotContext u) (j : J u) + (hj : validJ F c j = true) + (hvisible : sampledVariables F c s = sampledVariables F c s') : + (fun t => answerAt (j t) (s t)) = fun t => answerAt (j t) (s' t) := by + funext t + exact validJ_consistent F c j hj t (s t) t (s' t) (congrFun hvisible t) + +def honestJ (F : Formula) {u : ℕ} (c : ClauseContext F u) + (assignment : Fin F.«variables» → Bool) : J u := + fun t => honestAnswer (clauseAt F (c t)) assignment + +def honestI (F : Formula) {u : ℕ} (v : VariableContext F u) + (assignment : Fin F.«variables» → Bool) : I u := + fun t => assignment (v t) + +theorem honestJ_valid (F : Formula) {u : ℕ} (c : ClauseContext F u) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + validJ F c (honestJ F c assignment) = true := by + apply (validJ_eq_true_iff F c _).mpr + constructor + · intro t + exact (honest_satisfies _ assignment).trans (hs _ (List.getElem_mem _)) + · intro t t' s s' hname + simp only [honestJ, honest_answerAt] + exact congrArg assignment hname + +theorem pi_honest (F : Formula) {u : ℕ} (c : ClauseContext F u) + (v : VariableContext F u) (assignment : Fin F.«variables» → Bool) + (hsupport : ∀ t, ∃ s, nameAt (clauseAt F (c t)) s = v t) : + pi F c v (honestJ F c assignment) = honestI F v assignment := by + funext t + exact (honest_answerAt _ assignment _).trans + (congrArg assignment (canonicalSlot_name _ _ (hsupport t))) + +theorem pi_honest_sampled (F : Formula) {u : ℕ} (c : ClauseContext F u) + (s : SlotContext u) (assignment : Fin F.«variables» → Bool) : + pi F c (sampledVariables F c s) (honestJ F c assignment) = + honestI F (sampledVariables F c s) assignment := + pi_honest F c _ assignment (sampledVariables_supported F c s) + +def baseAccepts (F : Formula) (v : Fin F.«variables») (c : Fin F.clauses.length) + (i : Bool) (j : ClauseAnswer) : Bool := + decide (localSatisfies (clauseAt F c) j = true ∧ + localConsistent (clauseAt F c) j = true ∧ + answerAt j (canonicalSlot (clauseAt F c) v) = i) + +@[simp] theorem baseAccepts_eq_true_iff (F : Formula) (v : Fin F.«variables») + (c : Fin F.clauses.length) (i : Bool) (j : ClauseAnswer) : + baseAccepts F v c i j = true ↔ + localSatisfies (clauseAt F c) j = true ∧ + localConsistent (clauseAt F c) j = true ∧ + answerAt j (canonicalSlot (clauseAt F c) v) = i := by + simp [baseAccepts] + +theorem projection_implies_coordinate_accepts (F : Formula) {u : ℕ} + (c : ClauseContext F u) (v : VariableContext F u) (i : I u) (j : J u) + (hj : validJ F c j = true) (hpi : pi F c v j = i) (t : Fin u) : + baseAccepts F (v t) (c t) (i t) (j t) = true := by + exact (baseAccepts_eq_true_iff F _ _ _ _).mpr + ⟨validJ_satisfies F c j hj t, validJ_localConsistent F c j hj t, congrFun hpi t⟩ + +theorem baseAccepts_implies_sampled (F : Formula) (c : Fin F.clauses.length) + (s : Slot) (i : Bool) (j : ClauseAnswer) + (h : baseAccepts F (nameAt (clauseAt F c) s) c i j = true) : + (localSatisfies (clauseAt F c) j && decide (answerAt j s = i)) = true := by + obtain ⟨hsat, hcons, heq⟩ := (baseAccepts_eq_true_iff F _ _ _ _).mp h + have hname := canonicalSlot_name (clauseAt F c) (nameAt (clauseAt F c) s) ⟨s, rfl⟩ + have hans := (localConsistent_eq_true_iff _ _).mp hcons s + (canonicalSlot (clauseAt F c) (nameAt (clauseAt F c) s)) hname.symm + simp [hsat, hans.trans heq] + +theorem projection_implies_sampled_accepts (F : Formula) {u : ℕ} + (c : ClauseContext F u) (s : SlotContext u) (i : I u) (j : J u) + (hj : validJ F c j = true) (hpi : pi F c (sampledVariables F c s) j = i) : + ∀ t, (localSatisfies (clauseAt F (c t)) (j t) && + decide (answerAt (j t) (s t) = i t)) = true := by + intro t + exact baseAccepts_implies_sampled F (c t) (s t) (i t) (j t) + (projection_implies_coordinate_accepts F c _ i j hj hpi t) + +end IndependentSetsGames.Foundations.Hastad.SourceContexts + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Decoder.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Decoder.lean new file mode 100644 index 0000000000000000000000000000000000000000..4366ee5bf0808abdef802417151a9f632d294cdb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Decoder.lean @@ -0,0 +1,300 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Folding + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.Hastad + +open scoped BigOperators +open Finset + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +def parityProjection (π : J → I) (s : Cube J) : Cube I := fun i => + decide (Odd ((support s).filter fun y => π y = i).card) + +theorem walsh_support (s x : Cube I) : + walsh s x = ∏ i ∈ support s, bitSign (x i) := by + unfold walsh support + rw [Finset.prod_filter] + apply Finset.prod_congr rfl + intro i _ + cases s i <;> simp [bitSign] + +theorem sign_power_parity (b : Bool) (n : Nat) : + bitSign b ^ n = bitSign (decide (Odd n) && b) := by + cases b + · simp [bitSign] + · simp only [Bool.and_true, bitSign, ite_true, decide_eq_true_eq] + rw [neg_one_pow_eq_ite] + by_cases h : Even n + · simp [h, Nat.not_odd_iff_even.mpr h] + · simp [h, Nat.not_even_iff_odd.mp h] + +theorem walsh_pullback (π : J → I) (s : Cube J) (f : Cube I) : + walsh s (fun y => f (π y)) = walsh (parityProjection π s) f := by + rw [walsh_support] + rw [← Finset.prod_fiberwise' (support s) π (fun i => bitSign (f i))] + unfold walsh parityProjection + apply Finset.prod_congr rfl + intro i _ + simp only [Finset.prod_const] + exact sign_power_parity (f i) _ + +theorem projectedCoefficient_eq (π : J → I) (A : Cube I → ℝ) (s : Cube J) : + projectedCoefficient π A s = coefficient A (parityProjection π s) := by + simp only [projectedCoefficient, coefficient, walsh_pullback] + +omit [DecidableEq J] in +theorem projection_has_preimage (π : J → I) (s : Cube J) (i : I) + (hi : i ∈ support (parityProjection π s)) : + ∃ y ∈ support s, π y = i := by + have hodd : Odd ((support s).filter fun y => π y = i).card := by + have hbit := (Finset.mem_filter.mp hi).2 + simpa only [parityProjection, decide_eq_true_eq] using hbit + have hp : 0 < ((support s).filter fun y => π y = i).card := by + obtain ⟨n, hn⟩ := hodd + omega + obtain ⟨y, hy⟩ := Finset.card_pos.mp hp + exact ⟨y, (Finset.mem_filter.mp hy).1, (Finset.mem_filter.mp hy).2⟩ + +theorem scaled_geometric_power_le_one {t : ℝ} (ht : 0 ≤ t) (ht' : t ≤ 1) (n : Nat) : + (n : ℝ) * (1 - t) * t ^ n ≤ 1 := by + have hsum : (n : ℝ) * t ^ n ≤ ∑ j ∈ Finset.range n, t ^ j := by + calc + (n : ℝ) * t ^ n = ∑ _j ∈ Finset.range n, t ^ n := by simp + _ ≤ ∑ j ∈ Finset.range n, t ^ j := by + apply Finset.sum_le_sum + intro j hj + exact pow_le_pow_of_le_one ht ht' (Nat.le_of_lt (Finset.mem_range.mp hj)) + have hm := mul_le_mul_of_nonneg_right hsum (sub_nonneg.mpr ht') + rw [geom_sum_mul_neg] at hm + have hp : 0 ≤ t ^ n := pow_nonneg ht _ + nlinarith + +theorem noise_decay_bound {ε : ℝ} (hε : 0 < ε) (hε' : ε ≤ 1 / 2) + {k : Nat} (hk : 0 < k) : + 4 * ε * ((1 - 2 * ε) ^ k) ^ 2 ≤ 1 / (k : ℝ) := by + have h := scaled_geometric_power_le_one (t := 1 - 2 * ε) + (by linarith) (by linarith) (2 * k) + have hkp : (0 : ℝ) < k := Nat.cast_pos.mpr hk + apply (le_div_iff₀ hkp).mpr + have hpow : (1 - 2 * ε) ^ (2 * k) = ((1 - 2 * ε) ^ k) ^ 2 := by + rw [Nat.mul_comm, pow_mul] + rw [hpow] at h + norm_num only [Nat.cast_mul, Nat.cast_ofNat] at h + nlinarith + +def zeroMask : Cube I := fun _ => false + +omit [DecidableEq I] in +theorem support_eq_empty_iff (s : Cube I) : support s = ∅ ↔ s = zeroMask := by + constructor + · intro h + funext i + have hi : i ∉ support s := by rw [h]; simp + have : s i ≠ true := by simpa [support] using hi + cases hs : s i <;> simp_all [zeroMask] + · intro h + subst s + simp [zeroMask, support] + +omit [Fintype I] [DecidableEq J] in +theorem parityProjection_zero (π : J → I) : + parityProjection π (zeroMask : Cube J) = zeroMask := by + funext i + simp [parityProjection, support, zeroMask] + +def agreementProbability (π : J → I) (a : Cube I) (b : Cube J) : ℝ := + (∑ i ∈ support a, (((support b).filter fun y => π y = i).card : ℝ)) / + ((support a).card * (support b).card : ℝ) + +omit [DecidableEq J] in +theorem agreementProbability_nonneg (π : J → I) (a : Cube I) (b : Cube J) : + 0 ≤ agreementProbability π a b := by + unfold agreementProbability + apply div_nonneg + · exact Finset.sum_nonneg (fun _ _ => Nat.cast_nonneg _) + · exact mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + +omit [DecidableEq J] in +theorem agreementProbability_projection (π : J → I) (b : Cube J) + (ha : (support (parityProjection π b)).Nonempty) : + 1 / ((support b).card : ℝ) ≤ agreementProbability π (parityProjection π b) b := by + have hca : (0 : ℝ) < (support (parityProjection π b)).card := + Nat.cast_pos.mpr (Finset.card_pos.mpr ha) + have hb : (support b).Nonempty := by + obtain ⟨i, hi⟩ := ha + obtain ⟨y, hy, _⟩ := projection_has_preimage π b i hi + exact ⟨y, hy⟩ + have hcb : (0 : ℝ) < (support b).card := Nat.cast_pos.mpr (Finset.card_pos.mpr hb) + have hsum : ((support (parityProjection π b)).card : ℝ) ≤ + ∑ i ∈ support (parityProjection π b), + (((support b).filter fun y => π y = i).card : ℝ) := by + calc + _ = ∑ _i ∈ support (parityProjection π b), (1 : ℝ) := by simp + _ ≤ _ := by + apply Finset.sum_le_sum + intro i hi + obtain ⟨y, hy, hπ⟩ := projection_has_preimage π b i hi + have hp : 0 < ((support b).filter fun y => π y = i).card := + Finset.card_pos.mpr ⟨y, Finset.mem_filter.mpr ⟨hy, hπ⟩⟩ + exact_mod_cast hp + unfold agreementProbability + apply (div_le_div_iff₀ hcb (mul_pos hca hcb)).mpr + nlinarith + +def decoderSuccess (π : J → I) (A : Cube I → Bool) (B : Cube J → Bool) : ℝ := + ∑ b, coefficient (fun g => bitSign (B g)) b ^ 2 * + (∑ a, coefficient (fun f => bitSign (A f)) a ^ 2 * agreementProbability π a b) + +def decodingEnergy (π : J → I) (A : Cube I → ℝ) (B : Cube J → ℝ) : ℝ := + ∑ b, projectedCoefficient π A b ^ 2 * coefficient B b ^ 2 / (support b).card + +theorem decodingEnergy_le_success (π : J → I) (A : Cube I → Bool) (B : Cube J → Bool) + (hzero : coefficient (fun f => bitSign (A f)) zeroMask = 0) : + decodingEnergy π (fun f => bitSign (A f)) (fun g => bitSign (B g)) ≤ + decoderSuccess π A B := by + unfold decodingEnergy decoderSuccess + apply Finset.sum_le_sum + intro b _ + rw [projectedCoefficient_eq] + have hsum : + coefficient (fun f => bitSign (A f)) (parityProjection π b) ^ 2 * + agreementProbability π (parityProjection π b) b ≤ + ∑ a, coefficient (fun f => bitSign (A f)) a ^ 2 * agreementProbability π a b := by + apply Finset.single_le_sum (s := Finset.univ) + (f := fun a => coefficient (fun f => bitSign (A f)) a ^ 2 * agreementProbability π a b) + · intro a _ + exact mul_nonneg (sq_nonneg _) (agreementProbability_nonneg π a b) + · exact Finset.mem_univ _ + have hm := mul_le_mul_of_nonneg_left hsum + (sq_nonneg (coefficient (fun g => bitSign (B g)) b)) + by_cases ha : (support (parityProjection π b)).Nonempty + · have hagree := agreementProbability_projection π b ha + have ht := mul_le_mul_of_nonneg_left hagree + (mul_nonneg (sq_nonneg (coefficient (fun f => bitSign (A f)) + (parityProjection π b))) (sq_nonneg (coefficient (fun g => bitSign (B g)) b))) + have heq : coefficient (fun f => bitSign (A f)) (parityProjection π b) ^ 2 * + coefficient (fun g => bitSign (B g)) b ^ 2 / (support b).card = + (coefficient (fun f => bitSign (A f)) (parityProjection π b) ^ 2 * + coefficient (fun g => bitSign (B g)) b ^ 2) * (1 / (support b).card) := by ring + rw [heq] + exact ht.trans (by convert hm using 1; ring) + · have hempty : support (parityProjection π b) = ∅ := Finset.not_nonempty_iff_eq_empty.mp ha + have hz := (support_eq_empty_iff _).mp hempty + simpa [hz, hzero] using hm + +theorem bias_sq_le_weighted_energy (ε : ℝ) (π : J → I) + (A : Cube I → ℝ) (B : Cube J → Bool) : + testBias ε π A (fun g => bitSign (B g)) ^ 2 ≤ + ∑ b, (projectedCoefficient π A b * coefficient (fun g => bitSign (B g)) b * + (1 - 2 * ε) ^ (support b).card) ^ 2 := by + rw [testBias_fourier] + have h := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ + (fun b => projectedCoefficient π A b * coefficient (fun g => bitSign (B g)) b * + (1 - 2 * ε) ^ (support b).card) + (fun b => coefficient (fun g => bitSign (B g)) b) + rw [sign_parseval, mul_one] at h + convert h using 1 + congr 1 + apply Finset.sum_congr rfl + intro b _ + ring + +theorem decoder_four_epsilon_bias_sq (ε : ℝ) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) + (hzero : coefficient (fun f => bitSign (A f)) zeroMask = 0) : + 4 * ε * testBias ε π (fun f => bitSign (A f)) (fun g => bitSign (B g)) ^ 2 ≤ + decoderSuccess π A B := by + apply le_trans _ (decodingEnergy_le_success π A B hzero) + have hcs := mul_le_mul_of_nonneg_left + (bias_sq_le_weighted_energy ε π (fun f => bitSign (A f)) B) + (by linarith : 0 ≤ 4 * ε) + apply hcs.trans + rw [Finset.mul_sum] + unfold decodingEnergy + apply Finset.sum_le_sum + intro b _ + by_cases hk : 0 < (support b).card + · have hd := noise_decay_bound hε hε' hk + have hm := mul_le_mul_of_nonneg_left hd + (mul_nonneg (sq_nonneg (projectedCoefficient π (fun f => bitSign (A f)) b)) + (sq_nonneg (coefficient (fun g => bitSign (B g)) b))) + convert hm using 1 <;> ring + · have hb : support b = ∅ := Finset.card_eq_zero.mp (by omega) + have hbzero := (support_eq_empty_iff b).mp hb + subst b + simp [projectedCoefficient_eq, parityProjection_zero, hzero, support, zeroMask] + +theorem folded_decoder_bound (ε : ℝ) (π : J → I) + (i₀ : I) (table : HalfCube i₀ → Bool) (B : Cube J → Bool) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) : + 4 * ε * testBias ε π (fun f => bitSign (foldedAnswer i₀ table f)) + (fun g => bitSign (B g)) ^ 2 ≤ decoderSuccess π (foldedAnswer i₀ table) B := by + exact decoder_four_epsilon_bias_sq ε π (foldedAnswer i₀ table) B hε hε' + (foldedAnswer_zero_coefficient i₀ table) + +def validAgreementProbability (valid : J → Bool) (π : J → I) + (a : Cube I) (b : Cube J) : ℝ := + (∑ i ∈ support a, + (((support b).filter fun y => π y = i ∧ valid y = true).card : ℝ)) / + ((support a).card * (support b).card : ℝ) + +omit [DecidableEq J] in +theorem validAgreementProbability_eq (valid : J → Bool) (π : J → I) + (a : Cube I) (b : Cube J) (hb : ∀ y ∈ support b, valid y = true) : + validAgreementProbability valid π a b = agreementProbability π a b := by + unfold validAgreementProbability agreementProbability + congr 1 + apply Finset.sum_congr rfl + intro i _ + congr 1 + apply congrArg Finset.card + apply Finset.filter_congr + intro y hy + simp [hb y hy] + +def validDecoderSuccess (valid : J → Bool) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : ℝ := + ∑ b, coefficient (fun g => bitSign (B g)) b ^ 2 * + (∑ a, coefficient (fun f => bitSign (A f)) a ^ 2 * + validAgreementProbability valid π a b) + +theorem conditioned_validDecoderSuccess (valid : J → Bool) (π : J → I) + (A : Cube I → Bool) (j₀ : {j : J // valid j = true}) + (table : HalfCube j₀ → Bool) : + validDecoderSuccess valid π A (conditionedFoldedAnswer valid j₀ table) = + decoderSuccess π A (conditionedFoldedAnswer valid j₀ table) := by + unfold validDecoderSuccess decoderSuccess + apply Finset.sum_congr rfl + intro b _ + by_cases hc : coefficient (fun g => bitSign (conditionedFoldedAnswer valid j₀ table g)) b = 0 + · simp [hc] + · have hb : ∀ y ∈ support b, valid y = true := by + apply conditioned_coefficient_support valid (fun g => bitSign (foldedAnswer j₀ table g)) b + exact hc + congr 1 + apply Finset.sum_congr rfl + intro a _ + rw [validAgreementProbability_eq valid π a b hb] + +theorem conditioned_folded_decoder_bound (ε : ℝ) (π : J → I) (valid : J → Bool) + (i₀ : I) (tableA : HalfCube i₀ → Bool) + (j₀ : {j : J // valid j = true}) (tableB : HalfCube j₀ → Bool) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) : + 4 * ε * testBias ε π (fun f => bitSign (foldedAnswer i₀ tableA f)) + (fun g => bitSign (conditionedFoldedAnswer valid j₀ tableB g)) ^ 2 ≤ + validDecoderSuccess valid π (foldedAnswer i₀ tableA) + (conditionedFoldedAnswer valid j₀ tableB) := by + rw [conditioned_validDecoderSuccess] + exact folded_decoder_bound ε π i₀ tableA + (conditionedFoldedAnswer valid j₀ tableB) hε hε' + +end IndependentSetsGames.Foundations.Hastad +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/EmptyContext.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/EmptyContext.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd4f58592b43b736ed72b855a582191546c4e8cb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/EmptyContext.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.FoldedEquation + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad + +open IndependentSetsGames.Reduction.CloneGap +open scoped BigOperators + +def mapEquation {Name Name' : Type} (rename : Name → Name') + (e : Equation Name) : Equation Name' where + first := rename e.first + second := rename e.second + third := rename e.third + rhs := e.rhs + +theorem satisfied_mapEquation {Name Name' : Type} (rename : Name → Name') + (e : Equation Name) (assignment : Name' → Bool) : + satisfied (mapEquation rename e) assignment = satisfied e (assignment ∘ rename) := rfl + +namespace EmptyContext + +variable {I : Type} + +abbrev Address (i₀ : I) := HalfCube i₀ ⊕ Unit + +def storedAssignment {i₀ : I} (table : HalfCube i₀ → Bool) (dummy : Bool) : + Address i₀ → Bool := Sum.elim table (fun _ => dummy) + +def equation (i₀ : I) (f : Cube I) : Equation (Address i₀) where + first := .inl (canonicalInput i₀ f) + second := .inr () + third := .inr () + rhs := f i₀ + +@[simp] theorem equation_second_eq_third (i₀ : I) (f : Cube I) : + (equation i₀ f).second = (equation i₀ f).third := rfl + +theorem equation_satisfied (i₀ : I) (assignment : Address i₀ → Bool) (f : Cube I) : + satisfied (equation i₀ f) assignment = + !(foldedAnswer i₀ (fun h => assignment (.inl h)) f) := by + rw [FoldedEquation.satisfied_repeated_right (equation i₀ f) assignment rfl] + change (assignment (.inl (canonicalInput i₀ f)) == f i₀) = + !(assignment (.inl (canonicalInput i₀ f)) ^^ f i₀) + cases assignment (.inl (canonicalInput i₀ f)) <;> cases f i₀ <;> rfl + +theorem equation_storedAssignment_satisfied (i₀ : I) (table : HalfCube i₀ → Bool) + (dummy : Bool) (f : Cube I) : + satisfied (equation i₀ f) (storedAssignment table dummy) = + !(foldedAnswer i₀ table f) := equation_satisfied i₀ _ f + +theorem equation_flip_first (i₀ : I) (f : Cube I) : + (equation i₀ (cubeFlip f)).first = (equation i₀ f).first := by + change Sum.inl (canonicalInput i₀ (cubeFlip f)) = Sum.inl (canonicalInput i₀ f) + rw [canonicalInput_flip] + +theorem equation_flip_rhs (i₀ : I) (f : Cube I) : + (equation i₀ (cubeFlip f)).rhs = !(equation i₀ f).rhs := rfl + +theorem equation_satisfied_flip (i₀ : I) (assignment : Address i₀ → Bool) + (f : Cube I) : + satisfied (equation i₀ (cubeFlip f)) assignment = + !(satisfied (equation i₀ f) assignment) := by + rw [equation_satisfied, foldedAnswer_flip, equation_satisfied] + +def pairedEquations (i₀ : I) (f : Cube I) : List (Equation (Address i₀)) := + [equation i₀ f, equation i₀ (cubeFlip f)] + +@[simp] theorem pairedEquations_length (i₀ : I) (f : Cube I) : + (pairedEquations i₀ f).length = 2 := rfl + +theorem pairedEquations_ne_nil (i₀ : I) (f : Cube I) : + pairedEquations i₀ f ≠ [] := by simp [pairedEquations] + +theorem pairedEquations_acceptedCount (i₀ : I) (assignment : Address i₀ → Bool) + (f : Cube I) : + (pairedEquations i₀ f).countP (fun e => satisfied e assignment) = 1 := by + simp only [pairedEquations, List.countP_cons, List.countP_nil, equation_satisfied_flip] + cases satisfied (equation i₀ f) assignment <;> rfl + +theorem pairedEquations_failureCount (i₀ : I) (assignment : Address i₀ → Bool) + (f : Cube I) : + (pairedEquations i₀ f).countP (fun e => !(satisfied e assignment)) = 1 := by + simp only [pairedEquations, List.countP_cons, List.countP_nil, equation_satisfied_flip] + cases satisfied (equation i₀ f) assignment <;> rfl + +noncomputable section + +variable [Fintype I] [DecidableEq I] + +def equationAcceptance (i₀ : I) (assignment : Address i₀ → Bool) : ℝ := + 𝔼 f : Cube I, if satisfied (equation i₀ f) assignment then (1 : ℝ) else 0 + +def equationBias (i₀ : I) (assignment : Address i₀ → Bool) : ℝ := + 𝔼 f : Cube I, if satisfied (equation i₀ f) assignment then (1 : ℝ) else -1 + +theorem foldedMean_eq_zero (i₀ : I) (table : HalfCube i₀ → Bool) : + (𝔼 f : Cube I, bitSign (foldedAnswer i₀ table f)) = 0 := by + simpa [coefficient, walsh, bitSign] using foldedAnswer_zero_coefficient i₀ table + +omit [Fintype I] [DecidableEq I] in +theorem equation_indicator (i₀ : I) (assignment : Address i₀ → Bool) (f : Cube I) : + (if satisfied (equation i₀ f) assignment then (1 : ℝ) else 0) = + (1 + bitSign (foldedAnswer i₀ (fun h => assignment (.inl h)) f)) / 2 := by + rw [equation_satisfied] + cases foldedAnswer i₀ (fun h => assignment (.inl h)) f <;> norm_num [bitSign] + +theorem equationAcceptance_eq_half (i₀ : I) (assignment : Address i₀ → Bool) : + equationAcceptance i₀ assignment = 1 / 2 := by + unfold equationAcceptance + simp_rw [equation_indicator, div_eq_mul_inv, ← Finset.expect_mul, + Finset.expect_add_distrib, Fintype.expect_const, foldedMean_eq_zero] + norm_num + +theorem equationBias_eq_zero (i₀ : I) (assignment : Address i₀ → Bool) : + equationBias i₀ assignment = 0 := by + unfold equationBias + have hi (f : Cube I) : + (if satisfied (equation i₀ f) assignment then (1 : ℝ) else -1) = + bitSign (foldedAnswer i₀ (fun h => assignment (.inl h)) f) := by + rw [equation_satisfied] + cases foldedAnswer i₀ (fun h => assignment (.inl h)) f <;> norm_num [bitSign] + simp_rw [hi] + exact foldedMean_eq_zero i₀ _ + +theorem mapped_equationAcceptance_eq_half {Name : Type} (i₀ : I) + (rename : Address i₀ → Name) (assignment : Name → Bool) : + (𝔼 f : Cube I, if satisfied (mapEquation rename (equation i₀ f)) assignment + then (1 : ℝ) else 0) = 1 / 2 := by + simp only [satisfied_mapEquation] + exact equationAcceptance_eq_half i₀ (assignment ∘ rename) + +end +end EmptyContext +end IndependentSetsGames.Foundations.Hastad + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/FoldedEquation.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/FoldedEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..514d2b710a17a5f53eb63565a5da3b142c1b8c20 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/FoldedEquation.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Folding +import OAI.Combinatorics.IndependentSets.PCP.CloneGap + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.FoldedEquation + +open IndependentSetsGames.Reduction.CloneGap +open scoped BigOperators + +variable {I J : Type} + +abbrev Address (i₀ : I) (j₀ : J) := HalfCube i₀ ⊕ HalfCube j₀ + +def storedAssignment {i₀ : I} {j₀ : J} + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) : + Address i₀ j₀ → Bool := Sum.elim tableA tableB + +def rhsCorrection (π : J → I) (i₀ : I) (j₀ : J) + (f : Cube I) (μ : Cube J) : Bool := f i₀ ^^ f (π j₀) ^^ μ j₀ + +theorem correction_eq (π : J → I) (i₀ : I) (j₀ : J) + (f : Cube I) (g μ : Cube J) : + (f i₀ ^^ g j₀ ^^ thirdQuery π f g μ j₀) = rhsCorrection π i₀ j₀ f μ := by + change (f i₀ ^^ g j₀ ^^ (g j₀ ^^ (f (π j₀) ^^ μ j₀))) = + (f i₀ ^^ f (π j₀) ^^ μ j₀) + cases f i₀ <;> cases g j₀ <;> cases f (π j₀) <;> cases μ j₀ <;> rfl + +def equation (π : J → I) (i₀ : I) (j₀ : J) + (f : Cube I) (g μ : Cube J) : Equation (Address i₀ j₀) where + first := .inl (canonicalInput i₀ f) + second := .inr (canonicalInput j₀ g) + third := .inr (canonicalInput j₀ (thirdQuery π f g μ)) + rhs := rhsCorrection π i₀ j₀ f μ + +theorem xor_corrections (a b c u v w : Bool) : + ((a ^^ b ^^ c) == (u ^^ v ^^ w)) = + !((a ^^ u) ^^ (b ^^ v) ^^ (c ^^ w)) := by + cases a <;> cases b <;> cases c <;> cases u <;> cases v <;> cases w <;> rfl + +theorem equation_satisfied (π : J → I) (i₀ : I) (j₀ : J) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) : + satisfied (equation π i₀ j₀ f g μ) (storedAssignment tableA tableB) = + !(foldedAnswer i₀ tableA f ^^ foldedAnswer j₀ tableB g ^^ + foldedAnswer j₀ tableB (thirdQuery π f g μ)) := by + change ((tableA (canonicalInput i₀ f) ^^ tableB (canonicalInput j₀ g) ^^ + tableB (canonicalInput j₀ (thirdQuery π f g μ))) == rhsCorrection π i₀ j₀ f μ) = _ + rw [← correction_eq π i₀ j₀ f g μ] + exact xor_corrections _ _ _ _ _ _ + +theorem equation_satisfied_iff (π : J → I) (i₀ : I) (j₀ : J) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) : + satisfied (equation π i₀ j₀ f g μ) (storedAssignment tableA tableB) = true ↔ + (foldedAnswer i₀ tableA f ^^ foldedAnswer j₀ tableB g ^^ + foldedAnswer j₀ tableB (thirdQuery π f g μ)) = false := by + rw [equation_satisfied] + simp + +theorem equation_indicator (π : J → I) (i₀ : I) (j₀ : J) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) : + (if satisfied (equation π i₀ j₀ f g μ) (storedAssignment tableA tableB) + then (1 : ℝ) else 0) = + (if foldedAnswer i₀ tableA f ^^ foldedAnswer j₀ tableB g ^^ + foldedAnswer j₀ tableB (thirdQuery π f g μ) then 0 else 1) := by + rw [equation_satisfied] + cases foldedAnswer i₀ tableA f ^^ foldedAnswer j₀ tableB g ^^ + foldedAnswer j₀ tableB (thirdQuery π f g μ) <;> rfl + +theorem satisfied_repeated_right {Name : Type} (e : Equation Name) + (assignment : Name → Bool) (h : e.second = e.third) : + satisfied e assignment = (assignment e.first == e.rhs) := by + unfold satisfied + rw [← h] + cases assignment e.first <;> cases assignment e.second <;> cases e.rhs <;> rfl + +theorem equation_repeated_right (π : J → I) (i₀ : I) (j₀ : J) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) + (h : canonicalInput j₀ g = canonicalInput j₀ (thirdQuery π f g μ)) : + satisfied (equation π i₀ j₀ f g μ) (storedAssignment tableA tableB) = + (tableA (canonicalInput i₀ f) == rhsCorrection π i₀ j₀ f μ) := by + apply satisfied_repeated_right + exact congrArg Sum.inr h + +theorem restrict_thirdQuery (valid : J → Bool) (π : J → I) + (f : Cube I) (g μ : Cube J) : + restrictQuery valid (thirdQuery π f g μ) = + thirdQuery (fun j : {j : J // valid j = true} => π j.val) f + (restrictQuery valid g) (restrictQuery valid μ) := rfl + +def conditionedEquation (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (f : Cube I) (g μ : Cube J) : Equation (Address i₀ j₀) := + equation (fun j => π j.val) i₀ j₀ f (restrictQuery valid g) (restrictQuery valid μ) + +theorem conditionedEquation_rhs (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) (f : Cube I) (g μ : Cube J) : + (conditionedEquation valid π i₀ j₀ f g μ).rhs = + (f i₀ ^^ f (π j₀.val) ^^ μ j₀.val) := rfl + +theorem conditionedEquation_satisfied (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) : + satisfied (conditionedEquation valid π i₀ j₀ f g μ) (storedAssignment tableA tableB) = + !(foldedAnswer i₀ tableA f ^^ conditionedFoldedAnswer valid j₀ tableB g ^^ + conditionedFoldedAnswer valid j₀ tableB (thirdQuery π f g μ)) := by + unfold conditionedEquation + rw [equation_satisfied] + simp only [conditionedFoldedAnswer, restrict_thirdQuery] + +theorem conditionedEquation_satisfied_iff (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) : + satisfied (conditionedEquation valid π i₀ j₀ f g μ) (storedAssignment tableA tableB) = true ↔ + (foldedAnswer i₀ tableA f ^^ conditionedFoldedAnswer valid j₀ tableB g ^^ + conditionedFoldedAnswer valid j₀ tableB (thirdQuery π f g μ)) = false := by + rw [conditionedEquation_satisfied] + simp + +theorem conditionedEquation_indicator (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) : + (if satisfied (conditionedEquation valid π i₀ j₀ f g μ) (storedAssignment tableA tableB) + then (1 : ℝ) else 0) = + (if foldedAnswer i₀ tableA f ^^ conditionedFoldedAnswer valid j₀ tableB g ^^ + conditionedFoldedAnswer valid j₀ tableB (thirdQuery π f g μ) then 0 else 1) := by + rw [conditionedEquation_satisfied] + cases foldedAnswer i₀ tableA f ^^ conditionedFoldedAnswer valid j₀ tableB g ^^ + conditionedFoldedAnswer valid j₀ tableB (thirdQuery π f g μ) <;> rfl + +theorem conditionedEquation_repeated_right (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) + (f : Cube I) (g μ : Cube J) + (h : canonicalInput j₀ (restrictQuery valid g) = + canonicalInput j₀ (restrictQuery valid (thirdQuery π f g μ))) : + satisfied (conditionedEquation valid π i₀ j₀ f g μ) (storedAssignment tableA tableB) = + (tableA (canonicalInput i₀ f) == (f i₀ ^^ f (π j₀.val) ^^ μ j₀.val)) := by + apply satisfied_repeated_right + exact congrArg Sum.inr h + +noncomputable section + +variable [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +def equationAcceptance (ε : ℝ) (π : J → I) (i₀ : I) (j₀ : J) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) : ℝ := + 𝔼 f, ∑ μ, noiseWeight ε μ * + (𝔼 g, if satisfied (equation π i₀ j₀ f g μ) (storedAssignment tableA tableB) + then (1 : ℝ) else 0) + +theorem equationAcceptance_eq (ε : ℝ) (π : J → I) (i₀ : I) (j₀ : J) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) : + equationAcceptance ε π i₀ j₀ tableA tableB = + testAcceptance ε π (foldedAnswer i₀ tableA) (foldedAnswer j₀ tableB) := by + unfold equationAcceptance testAcceptance + simp_rw [equation_indicator] + +def conditionedEquationAcceptance (ε : ℝ) (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) : ℝ := + 𝔼 f, ∑ μ, noiseWeight ε μ * + (𝔼 g, if satisfied (conditionedEquation valid π i₀ j₀ f g μ) + (storedAssignment tableA tableB) then (1 : ℝ) else 0) + +theorem conditionedEquationAcceptance_eq (ε : ℝ) (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (tableA : HalfCube i₀ → Bool) (tableB : HalfCube j₀ → Bool) : + conditionedEquationAcceptance ε valid π i₀ j₀ tableA tableB = + testAcceptance ε π (foldedAnswer i₀ tableA) + (conditionedFoldedAnswer valid j₀ tableB) := by + unfold conditionedEquationAcceptance testAcceptance + simp_rw [conditionedEquation_indicator] + +end + +end IndependentSetsGames.Foundations.Hastad.FoldedEquation + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Folding.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Folding.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8e69ad126855907d5f966ffe836fc801ceb937c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Folding.lean @@ -0,0 +1,201 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Walsh + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.Hastad + +open scoped BigOperators +open Finset + +variable {I : Type*} [Fintype I] [DecidableEq I] + +def cubeFlip (f : Cube I) : Cube I := fun i => !(f i) + +omit [Fintype I] [DecidableEq I] in +@[simp] theorem cubeFlip_cubeFlip (f : Cube I) : cubeFlip (cubeFlip f) = f := by + funext i + simp [cubeFlip] + +@[simp] theorem bitSign_not (b : Bool) : bitSign (!b) = -bitSign b := by + cases b <;> norm_num [bitSign] + +theorem sum_cubeFlip (F : Cube I → ℝ) : (∑ f, F (cubeFlip f)) = ∑ f, F f := by + refine Finset.sum_bij (fun f _ => cubeFlip f) ?_ ?_ ?_ ?_ + · intro f _ + exact Finset.mem_univ _ + · intro f _ g _ h + have h' := congrArg cubeFlip h + simpa only [cubeFlip_cubeFlip] using h' + · intro g _ + exact ⟨cubeFlip g, Finset.mem_univ _, cubeFlip_cubeFlip g⟩ + · intro f _ + rfl + +theorem coefficient_zero_of_odd (F : Cube I → ℝ) + (hF : ∀ f, F (cubeFlip f) = -F f) : + coefficient F (fun _ => false) = 0 := by + have hs : (∑ f, F f) = 0 := by + have h := sum_cubeFlip F + simp_rw [hF, Finset.sum_neg_distrib] at h + linarith + simp [coefficient, walsh, bitSign, Fintype.expect_eq_sum_div_card, hs] + +theorem coefficient_sign_zero_of_folded (A : Cube I → Bool) + (hA : ∀ f, A (cubeFlip f) = !(A f)) : + coefficient (fun f => bitSign (A f)) (fun _ => false) = 0 := by + apply coefficient_zero_of_odd + intro f + rw [hA, bitSign_not] + +def representative (i₀ : I) (f : Cube I) : Cube I := + if f i₀ then cubeFlip f else f + +omit [Fintype I] [DecidableEq I] in +theorem representative_at (i₀ : I) (f : Cube I) : + representative i₀ f i₀ = false := by + cases hf : f i₀ <;> simp [representative, cubeFlip, hf] + +omit [Fintype I] [DecidableEq I] in +theorem representative_flip (i₀ : I) (f : Cube I) : + representative i₀ (cubeFlip f) = representative i₀ f := by + cases hf : f i₀ <;> simp [representative, cubeFlip, hf] + +abbrev HalfCube (i₀ : I) := {f : Cube I // f i₀ = false} + +def canonicalInput (i₀ : I) (f : Cube I) : HalfCube i₀ := + ⟨representative i₀ f, representative_at i₀ f⟩ + +omit [Fintype I] [DecidableEq I] in +theorem canonicalInput_flip (i₀ : I) (f : Cube I) : + canonicalInput i₀ (cubeFlip f) = canonicalInput i₀ f := by + apply Subtype.ext + exact representative_flip i₀ f + +def foldedAnswer (i₀ : I) (table : HalfCube i₀ → Bool) (f : Cube I) : Bool := + table (canonicalInput i₀ f) ^^ f i₀ + +omit [Fintype I] [DecidableEq I] in +theorem foldedAnswer_flip (i₀ : I) (table : HalfCube i₀ → Bool) (f : Cube I) : + foldedAnswer i₀ table (cubeFlip f) = !(foldedAnswer i₀ table f) := by + unfold foldedAnswer + rw [canonicalInput_flip] + change (table (canonicalInput i₀ f) ^^ !(f i₀)) = + !(table (canonicalInput i₀ f) ^^ f i₀) + cases table (canonicalInput i₀ f) <;> cases f i₀ <;> rfl + +theorem foldedAnswer_zero_coefficient (i₀ : I) (table : HalfCube i₀ → Bool) : + coefficient (fun f => bitSign (foldedAnswer i₀ table f)) (fun _ => false) = 0 := + coefficient_sign_zero_of_folded _ (foldedAnswer_flip i₀ table) + +omit [Fintype I] [DecidableEq I] in +theorem foldedAnswer_dictator (i₀ i : I) (f : Cube I) : + foldedAnswer i₀ (fun h => h.val i) f = f i := by + cases hf : f i₀ <;> cases hi : f i <;> + simp [foldedAnswer, canonicalInput, representative, cubeFlip, hf, hi] + +def coordinateMask (i : I) : Cube I := fun j => decide (j = i) + +def cubeToggle (i : I) (f : Cube I) : Cube I := + cubeXor f (coordinateMask i) + +omit [Fintype I] in +@[simp] theorem cubeToggle_twice (i : I) (f : Cube I) : + cubeToggle i (cubeToggle i f) = f := by + funext j + change ((f j ^^ coordinateMask i j) ^^ coordinateMask i j) = f j + cases f j <;> cases coordinateMask i j <;> rfl + +theorem walsh_coordinateMask (s : Cube I) (i : I) : + walsh s (coordinateMask i) = bitSign (s i) := by + unfold walsh + rw [Finset.prod_eq_single i] + · simp [coordinateMask] + · intro j _ hj + simp [coordinateMask, hj, bitSign] + · intro h + exact False.elim (h (Finset.mem_univ _)) + +theorem walsh_cubeToggle (s : Cube I) (i : I) (f : Cube I) (hs : s i = true) : + walsh s (cubeToggle i f) = -walsh s f := by + rw [cubeToggle, walsh_xor, walsh_coordinateMask, hs] + simp [bitSign] + +theorem sum_cubeToggle (i : I) (F : Cube I → ℝ) : + (∑ f, F (cubeToggle i f)) = ∑ f, F f := by + refine Finset.sum_bij (fun f _ => cubeToggle i f) ?_ ?_ ?_ ?_ + · intro f _ + exact Finset.mem_univ _ + · intro f _ g _ h + have h' := congrArg (cubeToggle i) h + simpa only [cubeToggle_twice] using h' + · intro g _ + exact ⟨cubeToggle i g, Finset.mem_univ _, cubeToggle_twice i g⟩ + · intro f _ + rfl + +def restrictQuery (valid : I → Bool) (f : Cube I) : + Cube {i : I // valid i = true} := fun i => f i.val + +omit [Fintype I] in +theorem restrictQuery_cubeToggle (valid : I → Bool) (i : I) + (hi : valid i = false) (f : Cube I) : + restrictQuery valid (cubeToggle i f) = restrictQuery valid f := by + funext j + have hj : j.val ≠ i := by + intro heq + have hp := j.property + rw [heq, hi] at hp + contradiction + simp [restrictQuery, cubeToggle, cubeXor, coordinateMask, hj] + +theorem conditioned_coefficient_zero_invalid (valid : I → Bool) + (B : Cube {i : I // valid i = true} → ℝ) (s : Cube I) (i : I) + (hi : valid i = false) (hs : s i = true) : + coefficient (fun f => B (restrictQuery valid f)) s = 0 := by + have hsum := sum_cubeToggle i (fun f => B (restrictQuery valid f) * walsh s f) + simp_rw [restrictQuery_cubeToggle valid i hi, walsh_cubeToggle s i _ hs, + mul_neg, Finset.sum_neg_distrib] at hsum + have hz : (∑ f, B (restrictQuery valid f) * walsh s f) = 0 := by linarith + simp [coefficient, Fintype.expect_eq_sum_div_card, hz] + +theorem conditioned_coefficient_support (valid : I → Bool) + (B : Cube {i : I // valid i = true} → ℝ) (s : Cube I) + (hne : coefficient (fun f => B (restrictQuery valid f)) s ≠ 0) : + ∀ i ∈ support s, valid i = true := by + intro i hi + have hs := (Finset.mem_filter.mp hi).2 + cases hv : valid i + · exact False.elim (hne (conditioned_coefficient_zero_invalid valid B s i hv hs)) + · rfl + +def conditionedFoldedAnswer (valid : I → Bool) (i₀ : {i : I // valid i = true}) + (table : HalfCube i₀ → Bool) (f : Cube I) : Bool := + foldedAnswer i₀ table (restrictQuery valid f) + +omit [Fintype I] [DecidableEq I] in +theorem conditionedFoldedAnswer_flip (valid : I → Bool) + (i₀ : {i : I // valid i = true}) (table : HalfCube i₀ → Bool) (f : Cube I) : + conditionedFoldedAnswer valid i₀ table (cubeFlip f) = + !(conditionedFoldedAnswer valid i₀ table f) := by + change foldedAnswer i₀ table (cubeFlip (restrictQuery valid f)) = _ + exact foldedAnswer_flip i₀ table (restrictQuery valid f) + +theorem conditionedFoldedAnswer_zero_coefficient (valid : I → Bool) + (i₀ : {i : I // valid i = true}) (table : HalfCube i₀ → Bool) : + coefficient (fun f => bitSign (conditionedFoldedAnswer valid i₀ table f)) + (fun _ => false) = 0 := + coefficient_sign_zero_of_folded _ (conditionedFoldedAnswer_flip valid i₀ table) + +omit [Fintype I] [DecidableEq I] in +theorem conditionedFoldedAnswer_dictator (valid : I → Bool) + (i₀ i : {i : I // valid i = true}) (f : Cube I) : + conditionedFoldedAnswer valid i₀ (fun h => h.val i) f = f i.val := by + exact foldedAnswer_dictator i₀ i (restrictQuery valid f) + +end IndependentSetsGames.Foundations.Hastad +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Fourier.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Fourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ef24c0be37b5f2149e28ecadc0bd76d6fb7eede --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Fourier.lean @@ -0,0 +1,171 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Cube + +namespace OAI + +namespace LargeIndependentSets.BooleanJunta +open scoped BigOperators + +lemma mean_congr {n : ℕ} {f g : Cube n → ℝ} (h : ∀ x, f x = g x) : mean f = mean g := + congrArg mean (funext h) + +lemma sum_succ {n : ℕ} (f : Cube (n+1) → ℝ) : + ∑ x, f x = (∑ x : Cube n, f (false,x)) + ∑ x : Cube n, f (true,x) := by + change (∑ x : Bool × Cube n, f x) = _ + rw [Fintype.sum_prod_type] + simp [add_comm] + +noncomputable def fourier : {n : ℕ} → (Cube n → ℝ) → Cube n → ℝ + | 0, f, x => f x + | _+1, f, (b,x) => if b then fourier (oddPart f) x else fourier (evenPart f) x + +noncomputable def synth : {n : ℕ} → (Cube n → ℝ) → Cube n → ℝ + | 0, f, x => f x + | _+1, f, (b,x) => synth (fun s => f (false,s)) x + + (if b then -1 else 1) * synth (fun s => f (true,s)) x + +lemma evenPart_add {n : ℕ} (f g : Cube (n+1) → ℝ) : + evenPart (fun x => f x + g x) = fun x => evenPart f x + evenPart g x := by + funext x; dsimp [evenPart]; ring + +lemma oddPart_add {n : ℕ} (f g : Cube (n+1) → ℝ) : + oddPart (fun x => f x + g x) = fun x => oddPart f x + oddPart g x := by + funext x; dsimp [oddPart]; ring + +lemma evenPart_mul {n : ℕ} (c : ℝ) (f : Cube (n+1) → ℝ) : + evenPart (fun x => c * f x) = fun x => c * evenPart f x := by + funext x; dsimp [evenPart]; ring + +lemma oddPart_mul {n : ℕ} (c : ℝ) (f : Cube (n+1) → ℝ) : + oddPart (fun x => c * f x) = fun x => c * oddPart f x := by + funext x; dsimp [oddPart]; ring + +lemma fourier_add {n : ℕ} (f g : Cube n → ℝ) : + fourier (fun x => f x + g x) = fun s => fourier f s + fourier g s := by + induction n with + | zero => rfl + | succ n ih => + funext ⟨b,s⟩ + cases b <;> simp [fourier, evenPart_add, oddPart_add, ih] + +lemma fourier_mul {n : ℕ} (c : ℝ) (f : Cube n → ℝ) : + fourier (fun x => c * f x) = fun s => c * fourier f s := by + induction n with + | zero => rfl + | succ n ih => + funext ⟨b,s⟩ + cases b <;> simp [fourier, evenPart_mul, oddPart_mul, ih] + +lemma fourier_sub {n : ℕ} (f g : Cube n → ℝ) : + fourier (fun x => f x - g x) = fun s => fourier f s - fourier g s := by + have he : (fun x => f x - g x) = (fun x => f x + -1 * g x) := by + funext x; ring + rw [he, fourier_add, fourier_mul] + funext s; ring + +lemma fourier_parseval {n : ℕ} (f : Cube n → ℝ) : + (∑ s, (fourier f s)^2) = mean (fun x => f x^2) := by + induction n with + | zero => simp [fourier, mean_zero] + | succ n ih => + rw [sum_succ, mean_square_split] + simp only [fourier, Bool.false_eq_true, ↓reduceIte] + rw [ih, ih] + +lemma fourier_inner {n : ℕ} (f g : Cube n → ℝ) : + (∑ s, fourier f s * fourier g s) = mean (fun x => f x*g x) := by + induction n with + | zero => simp [fourier, mean_zero] + | succ n ih => + rw [sum_succ, mean_product_split] + simp only [fourier, Bool.false_eq_true, ↓reduceIte] + rw [ih, ih] + +lemma synth_fourier {n : ℕ} (f : Cube n → ℝ) : synth (fourier f) = f := by + induction n with + | zero => rfl + | succ n ih => + funext ⟨b,x⟩ + simp only [synth, fourier, Bool.false_eq_true, ↓reduceIte] + rw [ih, ih] + cases b <;> dsimp [evenPart, oddPart] <;> ring + +lemma evenPart_synth {n : ℕ} (f : Cube (n+1) → ℝ) : + evenPart (synth f) = synth (fun s => f (false,s)) := by + funext x; dsimp [evenPart, synth]; ring + +lemma oddPart_synth {n : ℕ} (f : Cube (n+1) → ℝ) : + oddPart (synth f) = synth (fun s => f (true,s)) := by + funext x; dsimp [oddPart, synth]; ring + +lemma fourier_synth {n : ℕ} (f : Cube n → ℝ) : fourier (synth f) = f := by + induction n with + | zero => rfl + | succ n ih => + funext ⟨b,s⟩ + cases b <;> simp only [fourier, Bool.false_eq_true, ↓reduceIte, + evenPart_synth, oddPart_synth, ih] + +def bit : {n : ℕ} → Cube n → Fin n → Bool + | _+1, (b,x), i => Fin.cases b (bit x) i + +def degree : {n : ℕ} → Cube n → ℕ + | 0, _ => 0 + | _+1, (b,x) => (if b then 1 else 0) + degree x + +lemma fourier_noise {n : ℕ} (ρ : ℝ) (f : Cube n → ℝ) : + fourier (noise ρ f) = fun s => ρ^(degree s) * fourier f s := by + induction n with + | zero => funext s; simp [noise, fourier, degree] + | succ n ih => + funext ⟨b,s⟩ + cases b <;> simp [fourier, evenPart_noise, oddPart_noise, fourier_mul, + ih, degree, pow_add, mul_assoc] + +def flip : {n : ℕ} → Fin n → Cube n → Cube n + | _+1, i, (b,x) => Fin.cases (!b,x) (fun j => (b,flip j x)) i + +noncomputable def diff {n : ℕ} (i : Fin n) (f : Cube n → ℝ) (x : Cube n) : ℝ := + (f x - f (flip i x))/2 + +lemma evenPart_diff_zero {n : ℕ} (f : Cube (n+1) → ℝ) : + evenPart (diff 0 f) = fun _ => 0 := by + funext x + simp only [evenPart, diff, flip, Fin.cases_zero, Bool.not_false, Bool.not_true] + ring + +lemma oddPart_diff_zero {n : ℕ} (f : Cube (n+1) → ℝ) : + oddPart (diff 0 f) = oddPart f := by + funext x + simp only [oddPart, diff, flip, Fin.cases_zero, Bool.not_false, Bool.not_true] + ring + +lemma evenPart_diff_succ {n : ℕ} (i : Fin n) (f : Cube (n+1) → ℝ) : + evenPart (diff i.succ f) = diff i (evenPart f) := by + funext x + dsimp [evenPart, diff, flip] + ring + +lemma oddPart_diff_succ {n : ℕ} (i : Fin n) (f : Cube (n+1) → ℝ) : + oddPart (diff i.succ f) = diff i (oddPart f) := by + funext x + dsimp [oddPart, diff, flip] + ring + +lemma fourier_zero {n : ℕ} : fourier (fun _ : Cube n => (0:ℝ)) = fun _ => 0 := by + have h := fourier_mul (n := n) 0 (fun _ => 0) + simpa only [zero_mul] using h + +lemma fourier_diff {n : ℕ} (i : Fin n) (f : Cube n → ℝ) : + fourier (diff i f) = fun s => if bit s i then fourier f s else 0 := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + funext ⟨b,s⟩ + refine Fin.cases ?_ (fun j => ?_) i + · cases b <;> simp [fourier, bit, evenPart_diff_zero, oddPart_diff_zero, fourier_zero] + · cases b <;> simp [fourier, bit, evenPart_diff_succ, oddPart_diff_succ, ih] + +end LargeIndependentSets.BooleanJunta + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/FourierResponse.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/FourierResponse.lean new file mode 100644 index 0000000000000000000000000000000000000000..e37c1444eb3110d9bee528eff16e80d2a190ebc7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/FourierResponse.lean @@ -0,0 +1,155 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Decoder +import OAI.Combinatorics.IndependentSets.Repetition.Value + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.Hastad + +open scoped BigOperators +open Finset +open IndependentSetsGames.Foundations.Games + +variable {I J : Type*} [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] + +def supportResponse (fallback : I) (s : Cube I) : FiniteDistribution I where + weight i := if (support s).Nonempty then + if i ∈ support s then 1 / ((support s).card : ℝ) else 0 + else if i = fallback then 1 else 0 + nonnegative i := by + split_ifs <;> positivity + normalized := by + by_cases hs : (support s).Nonempty + · have hc : ((support s).card : ℝ) ≠ 0 := + ne_of_gt (Nat.cast_pos.mpr (Finset.card_pos.mpr hs)) + simp [hs, hc] + · simp [hs] + +theorem supportResponse_expectation (fallback : I) (s : Cube I) (H : I → ℝ) + (hs : (support s).Nonempty) : + (supportResponse fallback s).expectation H = + (∑ i ∈ support s, H i) / ((support s).card : ℝ) := by + simp only [FiniteDistribution.expectation, supportResponse, hs, ite_true] + simp_rw [ite_mul, zero_mul] + rw [Finset.sum_ite_mem] + simp only [div_eq_mul_inv, one_mul, Finset.univ_inter] + rw [← Finset.mul_sum] + ring + +def fourierResponse (fallback : I) (F : Cube I → Bool) : FiniteDistribution I where + weight i := ∑ s, coefficient (fun f => bitSign (F f)) s ^ 2 * + (supportResponse fallback s).weight i + nonnegative i := Finset.sum_nonneg fun s _ => + mul_nonneg (sq_nonneg _) ((supportResponse fallback s).nonnegative i) + normalized := by + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum, FiniteDistribution.normalized, mul_one] + exact sign_parseval F + +theorem fourierResponse_expectation (fallback : I) (F : Cube I → Bool) + (H : I → ℝ) : + (fourierResponse fallback F).expectation H = + ∑ s, coefficient (fun f => bitSign (F f)) s ^ 2 * + (supportResponse fallback s).expectation H := by + unfold FiniteDistribution.expectation fourierResponse + simp_rw [Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + +theorem response_expectation_nonnegative {K : Type*} [Fintype K] + (law : FiniteDistribution K) (H : K → ℝ) (hH : ∀ k, 0 ≤ H k) : + 0 ≤ law.expectation H := + Finset.sum_nonneg fun k _ => mul_nonneg (law.nonnegative k) (hH k) + +def responseAgreement (π : J → I) (fallbackI : I) (fallbackJ : J) + (A : Cube I → Bool) (B : Cube J → Bool) : ℝ := + (fourierResponse fallbackI A).expectation fun i => + (fourierResponse fallbackJ B).expectation fun j => if π j = i then 1 else 0 + +def validResponseAgreement (valid : J → Bool) (π : J → I) + (fallbackI : I) (fallbackJ : J) + (A : Cube I → Bool) (B : Cube J → Bool) : ℝ := + (fourierResponse fallbackI A).expectation fun i => + (fourierResponse fallbackJ B).expectation fun j => + if π j = i ∧ valid j = true then 1 else 0 + +theorem supportResponse_validAgreement (valid : J → Bool) (π : J → I) + (fallbackI : I) (fallbackJ : J) (a : Cube I) (b : Cube J) + (ha : (support a).Nonempty) (hb : (support b).Nonempty) : + (supportResponse fallbackI a).expectation (fun i => + (supportResponse fallbackJ b).expectation (fun j => + if π j = i ∧ valid j = true then 1 else 0)) = + validAgreementProbability valid π a b := by + rw [supportResponse_expectation fallbackI a _ ha] + simp_rw [supportResponse_expectation fallbackJ b _ hb, Finset.sum_boole] + unfold validAgreementProbability + simp only [div_eq_mul_inv] + rw [← Finset.sum_mul] + ring + +theorem validAgreement_le_supportResponses (valid : J → Bool) (π : J → I) + (fallbackI : I) (fallbackJ : J) (a : Cube I) (b : Cube J) : + validAgreementProbability valid π a b ≤ + (supportResponse fallbackI a).expectation (fun i => + (supportResponse fallbackJ b).expectation (fun j => + if π j = i ∧ valid j = true then 1 else 0)) := by + by_cases ha : (support a).Nonempty + · by_cases hb : (support b).Nonempty + · exact le_of_eq (supportResponse_validAgreement valid π fallbackI fallbackJ a b ha hb).symm + · have he : support b = ∅ := Finset.not_nonempty_iff_eq_empty.mp hb + simp only [validAgreementProbability, he, Finset.card_empty, Nat.cast_zero, + mul_zero, div_zero] + apply response_expectation_nonnegative + intro i + apply response_expectation_nonnegative + intro j + split_ifs <;> norm_num + · have he : support a = ∅ := Finset.not_nonempty_iff_eq_empty.mp ha + simp only [validAgreementProbability, he, Finset.sum_empty, Finset.card_empty, + Nat.cast_zero, zero_mul, div_zero] + apply response_expectation_nonnegative + intro i + apply response_expectation_nonnegative + intro j + split_ifs <;> norm_num + +theorem validDecoderSuccess_le_response (valid : J → Bool) (π : J → I) + (fallbackI : I) (fallbackJ : J) (A : Cube I → Bool) (B : Cube J → Bool) : + validDecoderSuccess valid π A B ≤ + validResponseAgreement valid π fallbackI fallbackJ A B := by + unfold validDecoderSuccess validResponseAgreement + rw [FiniteDistribution.expectation_comm] + rw [fourierResponse_expectation fallbackJ B] + apply Finset.sum_le_sum + intro b _ + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + rw [FiniteDistribution.expectation_comm] + rw [fourierResponse_expectation fallbackI A] + apply Finset.sum_le_sum + intro a _ + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + exact validAgreement_le_supportResponses valid π fallbackI fallbackJ a b + +theorem conditioned_folded_response_bound (ε : ℝ) (π : J → I) (valid : J → Bool) + (i₀ : I) (tableA : HalfCube i₀ → Bool) + (j₀ : {j : J // valid j = true}) (tableB : HalfCube j₀ → Bool) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) : + 4 * ε * testBias ε π (fun f => bitSign (foldedAnswer i₀ tableA f)) + (fun g => bitSign (conditionedFoldedAnswer valid j₀ tableB g)) ^ 2 ≤ + validResponseAgreement valid π i₀ j₀.val (foldedAnswer i₀ tableA) + (conditionedFoldedAnswer valid j₀ tableB) := + (conditioned_folded_decoder_bound ε π valid i₀ tableA j₀ tableB hε hε').trans + (validDecoderSuccess_le_response valid π i₀ j₀.val _ _) + +end IndependentSetsGames.Foundations.Hastad +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Game.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Game.lean new file mode 100644 index 0000000000000000000000000000000000000000..522e74f2597b020698f17a34dbde4c27d4dbe603 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Game.lean @@ -0,0 +1,265 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Contexts +import OAI.Combinatorics.IndependentSets.Fourier.GameDecoder +import OAI.Combinatorics.IndependentSets.Machines.Tape +import OAI.Combinatorics.IndependentSets.Repetition.Reindexing + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.Hastad.SourceGame + +open scoped BigOperators +open Target PCP Games SourceContexts + +theorem event_nonempty (F : Formula) (hne : F.clauses ≠ []) : + Nonempty (RandomEvent F) := + ⟨(⟨0, List.length_pos_iff.mpr hne⟩, .first)⟩ + +def eventLaw (F : Formula) (hne : F.clauses ≠ []) : + FiniteDistribution (RandomEvent F) := by + let : Nonempty (RandomEvent F) := event_nonempty F hne + exact FiniteDistribution.uniform _ + +def visibleQuestion (F : Formula) (e : RandomEvent F) : + Fin F.«variables» × Fin F.clauses.length := + (nameAt (clauseAt F e.1) e.2, e.1) + +def baseGame (F : Formula) (hne : F.clauses ≠ []) : + Game (Fin F.«variables») (Fin F.clauses.length) Bool ClauseAnswer where + questions := (eventLaw F hne).pushforward (visibleQuestion F) + accepts := baseAccepts F + +@[simp] theorem baseGame_accepts (F : Formula) (hne : F.clauses ≠ []) + (v : Fin F.«variables») (c : Fin F.clauses.length) (i : Bool) (j : ClauseAnswer) : + (baseGame F hne).accepts v c i j = baseAccepts F v c i j := rfl + +theorem eventLaw_probability (F : Formula) (hne : F.clauses ≠ []) + (P : RandomEvent F → Bool) : + (eventLaw F hne).probability P = + (∑ e : RandomEvent F, if P e then (1 : ℝ) else 0) / + (3 * F.clauses.length : ℕ) := by + classical + simp only [eventLaw, FiniteDistribution.uniform, FiniteDistribution.probability] + simp_rw [div_eq_mul_inv] + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro e _ + cases P e <;> simp [RandomEvent, Fintype.card_prod, card_slot, Nat.mul_comm] + +theorem sum_slots (H : Slot → ℝ) : + (∑ s : Slot, H s) = H .first + H .second + H .third := by + have hu : (Finset.univ : Finset Slot) = {.first, .second, .third} := by + ext s + cases s <;> simp + rw [hu] + simp only [Finset.sum_insert, Finset.mem_insert, Finset.mem_singleton, + reduceCtorEq, or_self, not_false_eq_true, Finset.sum_singleton] + ring + +theorem sum_slot_accepts (F : Formula) (alice : AliceStrategy F) + (bob : BobStrategy F) (c : Fin F.clauses.length) : + (∑ s : Slot, if accepts F alice bob (c,s) then (1 : ℝ) else 0) = + (acceptedSlots (clauseAt F c) (alice c) + (honestAnswer (clauseAt F c) bob) : ℕ) := by + rw [sum_slots] + by_cases hs : localSatisfies (clauseAt F c) (alice c) = true + · by_cases h₁ : (alice c).first = bob (clauseAt F c)[0].variableIndex <;> + by_cases h₂ : (alice c).second = bob (clauseAt F c)[1].variableIndex <;> + by_cases h₃ : (alice c).third = bob (clauseAt F c)[2].variableIndex <;> + norm_num [accepts, hs, acceptedSlots, matchingSlots, honestAnswer, answerAt, nameAt, + h₁, h₂, h₃] + · simp [accepts, acceptedSlots, hs] + +theorem failureCount_eq_sum_map (F : Formula) (bob : BobStrategy F) + (cs : List (Fin F.clauses.length)) : + failureCount F bob cs = + (cs.map (fun c => clauseFailure (clauseAt F c) bob)).sum := by + induction cs with + | nil => rfl + | cons c cs ih => simp only [failureCount, List.map_cons, List.sum_cons, ih] + +theorem failureCount_allIndices (F : Formula) (bob : BobStrategy F) : + failureCount F bob (allIndices F) = + ∑ c : Fin F.clauses.length, clauseFailure (clauseAt F c) bob := by + rw [failureCount_eq_sum_map] + unfold allIndices + rw [← List.sum_toFinset _ (List.nodup_finRange _), List.toFinset_finRange] + +theorem verifier_probability_plus_failure (F : Formula) (hne : F.clauses ≠ []) + (alice : AliceStrategy F) (bob : BobStrategy F) : + (eventLaw F hne).probability (accepts F alice bob) + + (failureCount F bob (allIndices F) : ℝ) / (3 * F.clauses.length : ℕ) ≤ 1 := by + have hm : (0 : ℝ) < (3 * F.clauses.length : ℕ) := by + exact_mod_cast Nat.mul_pos (by decide : 0 < 3) (List.length_pos_iff.mpr hne) + have hlocal (c : Fin F.clauses.length) : + (∑ s : Slot, if accepts F alice bob (c,s) then (1 : ℝ) else 0) + + (clauseFailure (clauseAt F c) bob : ℝ) ≤ 3 := by + rw [sum_slot_accepts] + exact_mod_cast local_rejection_bound (clauseAt F c) (alice c) bob + have hsum := Finset.sum_le_sum (fun c (_ : c ∈ (Finset.univ : Finset _)) => hlocal c) + simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, + Fintype.card_fin, nsmul_eq_mul] at hsum + rw [eventLaw_probability, failureCount_allIndices] + push_cast + push_cast at hm + rw [Fintype.sum_prod_type, ← add_div] + apply (div_le_one hm).mpr + simpa only [Nat.cast_mul, Nat.cast_ofNat, mul_comm] using hsum + +theorem base_success_le_verifier (F : Formula) (hne : F.clauses ≠ []) + (strategy : Strategy (Fin F.«variables») (Fin F.clauses.length) Bool ClauseAnswer) : + (baseGame F hne).success strategy ≤ + (eventLaw F hne).probability (accepts F strategy.2 strategy.1) := by + unfold Game.success baseGame + rw [FiniteDistribution.probability_pushforward] + apply FiniteDistribution.probability_mono + intro e he + exact baseAccepts_implies_sampled F e.1 e.2 _ _ he + +theorem base_value_le_of_clause_gap (F : Formula) (hne : F.clauses ≠ []) + (δ : ℝ) (hgap : ∀ bob : BobStrategy F, + δ * F.clauses.length ≤ (failureCount F bob (allIndices F) : ℝ)) : + (baseGame F hne).value ≤ 1 - δ / 3 := by + apply (Game.value_le_iff _ _).mpr + intro strategy + have hbase := base_success_le_verifier F hne strategy + have hprob := verifier_probability_plus_failure F hne strategy.2 strategy.1 + have hm : (0 : ℝ) < F.clauses.length := + Nat.cast_pos.mpr (List.length_pos_iff.mpr hne) + have hg : δ / 3 ≤ (failureCount F strategy.1 (allIndices F) : ℝ) / + (3 * F.clauses.length : ℕ) := by + have hden : (0 : ℝ) < (3 * F.clauses.length : ℕ) := by + exact_mod_cast Nat.mul_pos (by decide : 0 < 3) (List.length_pos_iff.mpr hne) + apply (le_div_iff₀ hden).mpr + calc + δ / 3 * (3 * F.clauses.length : ℕ) = δ * F.clauses.length := by push_cast; ring + _ ≤ _ := hgap strategy.1 + linarith + +theorem pushforward_comp {X Y Z : Type*} [Fintype X] [Fintype Y] [Fintype Z] + (μ : FiniteDistribution X) (f : X → Y) (g : Y → Z) : + (μ.pushforward f).pushforward g = μ.pushforward (g ∘ f) := by + classical + apply FiniteDistribution.eq_of_weight_eq + intro z + simp only [FiniteDistribution.pushforward] + calc + _ = ∑ y : Y, ∑ x : X, if f x = y then + (if g y = z then μ.weight x else 0) else 0 := by + apply Finset.sum_congr rfl + intro y _ + by_cases h : g y = z <;> simp [h] + _ = _ := by rw [Finset.sum_comm]; simp + +theorem expectation_pushforward {X Y : Type*} [Fintype X] [Fintype Y] + (μ : FiniteDistribution X) (f : X → Y) (H : Y → ℝ) : + (μ.pushforward f).expectation H = μ.expectation (H ∘ f) := by + classical + simp only [FiniteDistribution.expectation, FiniteDistribution.pushforward, + Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + simp [ite_mul] + +def repeatedVisible (F : Formula) (u : ℕ) (events : Fin u → RandomEvent F) : + VariableContext F u × ClauseContext F u := + (fun t => nameAt (clauseAt F (events t).1) (events t).2, + fun t => (events t).1) + +theorem repeated_questions (F : Formula) (hne : F.clauses ≠ []) (u : ℕ) : + ((baseGame F hne).repetition u).questions = + ((eventLaw F hne).iid u).pushforward (repeatedVisible F u) := by + change (((eventLaw F hne).pushforward (visibleQuestion F)).iid u).transport + (Game.tupleQuestionEquiv u) = _ + rw [FiniteDistribution.iid_pushforward, ← FiniteDistribution.pushforward_equiv, + pushforward_comp] + rfl + +theorem repeated_expectation (F : Formula) (hne : F.clauses ≠ []) (u : ℕ) + (H : VariableContext F u × ClauseContext F u → ℝ) : + ((baseGame F hne).repetition u).questions.expectation H = + 𝔼 events : Fin u → RandomEvent F, H (repeatedVisible F u events) := by + let : Nonempty (RandomEvent F) := event_nonempty F hne + rw [repeated_questions, expectation_pushforward] + change ((FiniteDistribution.uniform (RandomEvent F)).iid u).expectation _ = _ + rw [FiniteDistribution.iid_uniform, FiniteDistribution.expectation_uniform, + Fintype.expect_eq_sum_div_card] + rfl + +theorem repeated_expectation_split (F : Formula) (hne : F.clauses ≠ []) (u : ℕ) + (H : VariableContext F u × ClauseContext F u → ℝ) : + ((baseGame F hne).repetition u).questions.expectation H = + 𝔼 c : ClauseContext F u, 𝔼 s : SlotContext u, + H (sampledVariables F c s, c) := by + rw [repeated_expectation] + calc + _ = 𝔼 p : ClauseContext F u × SlotContext u, + H (sampledVariables F p.1 p.2, p.1) := + Fintype.expect_equiv + (Game.tupleQuestionEquiv (Q₁ := Fin F.clauses.length) (Q₂ := Slot) u) + _ _ (fun _ => rfl) + _ = _ := SourceTape.expect_prod _ + +def sourceProjectionGame (F : Formula) (hne : F.clauses ≠ []) (u : ℕ) : + Game (VariableContext F u) (ClauseContext F u) (I u) (J u) := + projectionGame ((baseGame F hne).repetition u).questions + (fun v c => pi F c v) (validJ F) + +theorem projection_value_le_repetition (F : Formula) (hne : F.clauses ≠ []) + (u : ℕ) : + (sourceProjectionGame F hne u).value ≤ ((baseGame F hne).repetition u).value := by + apply (Game.value_le_iff _ _).mpr + intro strategy + have h : (sourceProjectionGame F hne u).success strategy ≤ + ((baseGame F hne).repetition u).success strategy := by + apply FiniteDistribution.probability_mono + intro q hq + have hlegal : pi F q.2 q.1 (strategy.2 q.2) = strategy.1 q.1 ∧ + validJ F q.2 (strategy.2 q.2) = true := by + simpa only [Game.wins, sourceProjectionGame, projectionGame, + decide_eq_true_eq] using hq + apply (Game.repetition_accepts_iff _ _ _ _ _ _).mpr + intro t + exact projection_implies_coordinate_accepts F q.2 q.1 + (strategy.1 q.1) (strategy.2 q.2) hlegal.2 hlegal.1 t + exact h.trans (Game.success_le_value _ strategy) + +theorem source_acceptance_le (F : Formula) (hne : F.clauses ≠ []) (u : ℕ) + (ε δ : ℝ) (i₀ : VariableContext F u → I u) + (tableA : ∀ v, HalfCube (i₀ v) → Bool) + (right : ∀ c : ClauseContext F u, ConditionedOracle (validJ F c)) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) (hδ : 0 ≤ δ) + (hvalue : ((baseGame F hne).repetition u).value ≤ 4 * ε * δ ^ 2) : + (𝔼 events : Fin u → RandomEvent F, + questionAcceptance ε (fun v c => pi F c v) + (fun v => foldedAnswer (i₀ v) (tableA v)) (fun c => (right c).answer) + (repeatedVisible F u events)) ≤ (1 + δ) / 2 := by + rw [← repeated_expectation F hne u] + exact conditionedOracle_acceptance_bound _ ε δ _ (validJ F) i₀ tableA + (fun _ => default) right hε hε' hδ + ((projection_value_le_repetition F hne u).trans hvalue) + +theorem source_acceptance_le_split (F : Formula) (hne : F.clauses ≠ []) (u : ℕ) + (ε δ : ℝ) (i₀ : VariableContext F u → I u) + (tableA : ∀ v, HalfCube (i₀ v) → Bool) + (right : ∀ c : ClauseContext F u, ConditionedOracle (validJ F c)) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) (hδ : 0 ≤ δ) + (hvalue : ((baseGame F hne).repetition u).value ≤ 4 * ε * δ ^ 2) : + (𝔼 c : ClauseContext F u, 𝔼 s : SlotContext u, + testAcceptance ε (pi F c (sampledVariables F c s)) + (foldedAnswer (i₀ (sampledVariables F c s)) (tableA (sampledVariables F c s))) + (right c).answer) ≤ (1 + δ) / 2 := by + have h := conditionedOracle_acceptance_bound + ((baseGame F hne).repetition u).questions ε δ (fun v c => pi F c v) + (validJ F) i₀ tableA (fun _ => default) right hε hε' hδ + ((projection_value_le_repetition F hne u).trans hvalue) + rw [repeated_expectation_split] at h + exact h + +end IndependentSetsGames.Foundations.Hastad.SourceGame + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/GameDecoder.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/GameDecoder.lean new file mode 100644 index 0000000000000000000000000000000000000000..078f910d7ea03000ac5b07f6dcf304555783b31a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/GameDecoder.lean @@ -0,0 +1,212 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.FourierResponse + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.Hastad + +open scoped BigOperators +open Finset +open IndependentSetsGames.Foundations.Games + +theorem distribution_sq_expectation_le {Ω : Type*} [Fintype Ω] + (law : FiniteDistribution Ω) (F : Ω → ℝ) : + law.expectation F ^ 2 ≤ law.expectation (fun x => F x ^ 2) := by + let m := law.expectation F + have h := response_expectation_nonnegative law (fun x => (F x - m) ^ 2) + (fun x => sq_nonneg _) + have he : law.expectation (fun x => (F x - m) ^ 2) = + law.expectation (fun x => F x ^ 2) - m ^ 2 := by + unfold FiniteDistribution.expectation + calc + _ = ∑ x, ((law.weight x * F x ^ 2 - 2 * m * (law.weight x * F x)) + + law.weight x * m ^ 2) := by + apply Finset.sum_congr rfl + intro x _ + ring + _ = _ := by + rw [Finset.sum_add_distrib, Finset.sum_sub_distrib, + ← Finset.mul_sum, ← Finset.sum_mul, law.normalized] + change (law.expectation (fun x => F x ^ 2) - 2 * m * m) + 1 * m ^ 2 = _ + simp only [FiniteDistribution.expectation] + ring + rw [he] at h + dsimp [m] at h + linarith + +variable {Q₁ Q₂ I J : Type*} + [Fintype Q₁] [DecidableEq Q₁] [Fintype Q₂] [DecidableEq Q₂] + [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] + +def projectionGame (questions : FiniteDistribution (Q₁ × Q₂)) + (π : Q₁ → Q₂ → J → I) (valid : Q₂ → J → Bool) : Game Q₁ Q₂ I J where + questions := questions + accepts q₁ q₂ i j := decide (π q₁ q₂ j = i ∧ valid q₂ j = true) + +def questionBias (ε : ℝ) (π : Q₁ → Q₂ → J → I) + (A : Q₁ → Cube I → Bool) (B : Q₂ → Cube J → Bool) (q : Q₁ × Q₂) : ℝ := + testBias ε (π q.1 q.2) (fun f => bitSign (A q.1 f)) (fun g => bitSign (B q.2 g)) + +def questionAcceptance (ε : ℝ) (π : Q₁ → Q₂ → J → I) + (A : Q₁ → Cube I → Bool) (B : Q₂ → Cube J → Bool) (q : Q₁ × Q₂) : ℝ := + testAcceptance ε (π q.1 q.2) (A q.1) (B q.2) + +omit [DecidableEq Q₁] [DecidableEq Q₂] in +theorem questionAcceptance_eq (questions : FiniteDistribution (Q₁ × Q₂)) + (ε : ℝ) (π : Q₁ → Q₂ → J → I) + (A : Q₁ → Cube I → Bool) (B : Q₂ → Cube J → Bool) : + questions.expectation (questionAcceptance ε π A B) = + (1 + questions.expectation (questionBias ε π A B)) / 2 := by + unfold questionAcceptance + simp_rw [testAcceptance_eq] + unfold questionBias FiniteDistribution.expectation + simp only [div_eq_mul_inv, mul_add, mul_one, ← mul_assoc, + Finset.sum_add_distrib, ← Finset.sum_mul, questions.normalized] + +inductive ConditionedOracle (valid : J → Bool) where + | empty (noLegal : ∀ j, valid j = false) + | stored (j₀ : {j : J // valid j = true}) (table : HalfCube j₀ → Bool) + +def ConditionedOracle.answer {valid : J → Bool} : ConditionedOracle valid → Cube J → Bool + | .empty _ => fun _ => false + | .stored j₀ table => conditionedFoldedAnswer valid j₀ table + +def ConditionedOracle.fallback {valid : J → Bool} (default : J) : + ConditionedOracle valid → J + | .empty _ => default + | .stored j₀ _ => j₀.val + +theorem testBias_constant_right (ε : ℝ) (π : J → I) (A : Cube I → ℝ) : + testBias ε π A (fun _ => 1) = 𝔼 f, A f := by + unfold testBias + simp only [mul_one, Fintype.expect_const] + simp_rw [← Finset.sum_mul, noiseWeight_sum, one_mul] + +theorem empty_conditioned_bias (ε : ℝ) (π : J → I) + (i₀ : I) (tableA : HalfCube i₀ → Bool) : + testBias ε π (fun f => bitSign (foldedAnswer i₀ tableA f)) + (fun _ => bitSign false) = 0 := by + simp only [bitSign, Bool.false_eq_true, ite_false] + rw [testBias_constant_right] + have hz := foldedAnswer_zero_coefficient i₀ tableA + simpa [coefficient, walsh, bitSign] using hz + +theorem conditionedOracle_response_bound (ε : ℝ) (π : J → I) (valid : J → Bool) + (i₀ : I) (tableA : HalfCube i₀ → Bool) (default : J) + (right : ConditionedOracle valid) (hε : 0 < ε) (hε' : ε ≤ 1 / 2) : + 4 * ε * testBias ε π (fun f => bitSign (foldedAnswer i₀ tableA f)) + (fun g => bitSign (right.answer g)) ^ 2 ≤ + validResponseAgreement valid π i₀ (right.fallback default) + (foldedAnswer i₀ tableA) right.answer := by + cases right with + | empty noLegal => + simp only [ConditionedOracle.answer, ConditionedOracle.fallback, + empty_conditioned_bias, pow_two, mul_zero] + unfold validResponseAgreement + apply response_expectation_nonnegative + intro i + apply response_expectation_nonnegative + intro j + split_ifs <;> norm_num + | stored j₀ table => + exact conditioned_folded_response_bound ε π valid i₀ tableA j₀ table hε hε' + +variable [Nonempty I] [Nonempty J] + +theorem folded_game_decoder_bound + (questions : FiniteDistribution (Q₁ × Q₂)) + (ε : ℝ) (π : Q₁ → Q₂ → J → I) (valid : Q₂ → J → Bool) + (i₀ : Q₁ → I) (tableA : ∀ q, HalfCube (i₀ q) → Bool) + (j₀ : ∀ q, {j : J // valid q j = true}) + (tableB : ∀ q, HalfCube (j₀ q) → Bool) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) : + 4 * ε * questions.expectation (questionBias ε π + (fun q => foldedAnswer (i₀ q) (tableA q)) + (fun q => conditionedFoldedAnswer (valid q) (j₀ q) (tableB q))) ^ 2 ≤ + (projectionGame questions π valid).value := by + let A := fun q => foldedAnswer (i₀ q) (tableA q) + let B := fun q => conditionedFoldedAnswer (valid q) (j₀ q) (tableB q) + let bias := questionBias ε π A B + calc + _ ≤ 4 * ε * questions.expectation (fun q => bias q ^ 2) := + mul_le_mul_of_nonneg_left (distribution_sq_expectation_le questions bias) (by linarith) + _ = questions.expectation (fun q => 4 * ε * bias q ^ 2) := by + unfold FiniteDistribution.expectation + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro q _ + ring + _ ≤ questions.expectation (fun q => + validResponseAgreement (valid q.2) (π q.1 q.2) (i₀ q.1) (j₀ q.2).val + (A q.1) (B q.2)) := by + unfold FiniteDistribution.expectation + apply Finset.sum_le_sum + intro q _ + apply mul_le_mul_of_nonneg_left _ (questions.nonnegative q) + exact conditioned_folded_response_bound ε (π q.1 q.2) (valid q.2) + (i₀ q.1) (tableA q.1) (j₀ q.2) (tableB q.2) hε hε' + _ = (projectionGame questions π valid).stochasticSuccess + (fun q => fourierResponse (i₀ q) (A q)) + (fun q => fourierResponse (j₀ q).val (B q)) := by + simp [Game.stochasticSuccess, projectionGame, validResponseAgreement] + _ ≤ _ := Game.stochasticSuccess_le_value _ _ _ + +theorem conditionedOracle_game_decoder_bound + (questions : FiniteDistribution (Q₁ × Q₂)) + (ε : ℝ) (π : Q₁ → Q₂ → J → I) (valid : Q₂ → J → Bool) + (i₀ : Q₁ → I) (tableA : ∀ q, HalfCube (i₀ q) → Bool) + (default : J) (right : ∀ q, ConditionedOracle (valid q)) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) : + 4 * ε * questions.expectation (questionBias ε π + (fun q => foldedAnswer (i₀ q) (tableA q)) (fun q => (right q).answer)) ^ 2 ≤ + (projectionGame questions π valid).value := by + let A := fun q => foldedAnswer (i₀ q) (tableA q) + let B := fun q => (right q).answer + let bias := questionBias ε π A B + calc + _ ≤ 4 * ε * questions.expectation (fun q => bias q ^ 2) := + mul_le_mul_of_nonneg_left (distribution_sq_expectation_le questions bias) (by linarith) + _ = questions.expectation (fun q => 4 * ε * bias q ^ 2) := by + unfold FiniteDistribution.expectation + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro q _ + ring + _ ≤ questions.expectation (fun q => + validResponseAgreement (valid q.2) (π q.1 q.2) (i₀ q.1) + ((right q.2).fallback default) (A q.1) (B q.2)) := by + unfold FiniteDistribution.expectation + apply Finset.sum_le_sum + intro q _ + apply mul_le_mul_of_nonneg_left _ (questions.nonnegative q) + exact conditionedOracle_response_bound ε (π q.1 q.2) (valid q.2) + (i₀ q.1) (tableA q.1) default (right q.2) hε hε' + _ = (projectionGame questions π valid).stochasticSuccess + (fun q => fourierResponse (i₀ q) (A q)) + (fun q => fourierResponse ((right q).fallback default) (B q)) := by + simp [Game.stochasticSuccess, projectionGame, validResponseAgreement] + _ ≤ _ := Game.stochasticSuccess_le_value _ _ _ + +theorem conditionedOracle_acceptance_bound + (questions : FiniteDistribution (Q₁ × Q₂)) + (ε δ : ℝ) (π : Q₁ → Q₂ → J → I) (valid : Q₂ → J → Bool) + (i₀ : Q₁ → I) (tableA : ∀ q, HalfCube (i₀ q) → Bool) + (default : J) (right : ∀ q, ConditionedOracle (valid q)) + (hε : 0 < ε) (hε' : ε ≤ 1 / 2) (hδ : 0 ≤ δ) + (hvalue : (projectionGame questions π valid).value ≤ 4 * ε * δ ^ 2) : + questions.expectation (questionAcceptance ε π + (fun q => foldedAnswer (i₀ q) (tableA q)) (fun q => (right q).answer)) ≤ + (1 + δ) / 2 := by + have hd := conditionedOracle_game_decoder_bound questions ε π valid i₀ tableA + default right hε hε' + have hpos : 0 < 4 * ε := by positivity + have hs := le_of_mul_le_mul_left (hd.trans hvalue) hpos + rw [questionAcceptance_eq] + nlinarith + +end IndependentSetsGames.Foundations.Hastad +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Gap.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Gap.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa4174667c35bd209767e604cc1cb46daa525759 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Gap.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.FinalBooleanVerifier +import OAI.Combinatorics.IndependentSets.Fourier.NumberedStorage +import OAI.Combinatorics.IndependentSets.Encoding.Bounds +import OAI.Combinatorics.IndependentSets.Reduction.Parameters + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceGap + +open Target SourceContexts SourceOccurrences SourceGame +open IndependentSetsGames.Integration.SourceParameters +open IndependentSetsGames.Reduction + +def ClauseGap (F : Formula) (η : ℚ) : Prop := + F.clauses ≠ [] ∧ ∀ assignment : Fin F.«variables» → Bool, + (η : ℝ) * F.clauses.length ≤ + (PCP.failureCount F assignment (PCP.allIndices F) : ℝ) + +theorem third_pos {η : ℚ} (hη : 0 < η) : 0 < η / 3 := by positivity + +theorem third_le_one {η : ℚ} (hη : η ≤ 1) : η / 3 ≤ 1 := by linarith + +def repetitionCount (η ξ : ℚ) (hη : 0 < η) (hη1 : η ≤ 1) (hξ : 0 < ξ) + (D : ℕ) (hD : 0 < D) : ℕ := + repetitionLength (η / 3) ξ (third_pos hη) (third_le_one hη1) hξ D hD + +theorem repetitionCount_pos (η ξ : ℚ) (hη : 0 < η) (hη1 : η ≤ 1) + (hξ : 0 < ξ) (D : ℕ) (hD : 0 < D) : + 0 < repetitionCount η ξ hη hη1 hξ D hD := + (repetitionLength_spec (η / 3) ξ (third_pos hη) (third_le_one hη1) hξ D hD).1 + +theorem repeated_game_bound (F : Formula) (η ξ : ℚ) + (hη : 0 < η) (hη1 : η ≤ 1) (hξ : 0 < ξ) (D : ℕ) (hD : 0 < D) + (hgap : ClauseGap F η) : + ((baseGame F hgap.1).repetition + (repetitionCount η ξ hη hη1 hξ D hD)).value ≤ + 4 * (D : ℝ)⁻¹ * (ξ : ℝ)^2 := by + have hb : (baseGame F hgap.1).value ≤ 1 - ((η / 3 : ℚ) : ℝ) := by + simpa only [Rat.cast_div, Rat.cast_ofNat] using + base_value_le_of_clause_gap F hgap.1 (η : ℝ) hgap.2 + have hc : Fintype.card Bool * Fintype.card PCP.ClauseAnswer = 16 := by + simp + exact (game_repetition_rate (baseGame F hgap.1) (third_pos hη) + (third_le_one hη1) hc hb _).trans + (repetitionLength_real_bound (η / 3) ξ (third_pos hη) + (third_le_one hη1) hξ D hD) + +def source (η ξ : ℚ) (hη : 0 < η) (hη1 : η ≤ 1) (hξ : 0 < ξ) + (D : ℕ) (hD : 0 < D) (F : Formula) : SourceEncoding.Input := + sourceInput F (repetitionCount η ξ hη hη1 hξ D hD) D hD + +theorem source_complete (η ξ : ℚ) (hη : 0 < η) (hη1 : η ≤ 1) (hξ : 0 < ξ) + (D : ℕ) (hD : 0 < D) (hnoise : (D : ℚ)⁻¹ ≤ ξ) + (F : Formula) (hF : F.Satisfiable) : + ∃ bits : Fin (source η ξ hη hη1 hξ D hD F).«variables» → Bool, + 1 - ξ ≤ (((source η ξ hη hη1 hξ D hD F).equations.countP + (fun e => CloneGap.satisfied e bits) : ℚ) / + (source η ξ hη hη1 hξ D hD F).equations.length) := by + obtain ⟨assignment, hs⟩ := hF + refine ⟨SourceHonest.honestBits F _ assignment, ?_⟩ + have h := SourceHonest.sourceList_honest_acceptance_rat F + (repetitionCount η ξ hη hη1 hξ D hD) D hD assignment hs + exact (sub_le_sub_left hnoise 1).trans h + +theorem source_sound (η ξ : ℚ) (hη : 0 < η) (hη1 : η ≤ 1) (hξ : 0 < ξ) + (D : ℕ) (hD : 0 < D) (hDtwo : 2 ≤ D) + (F : Formula) (hgap : ClauseGap F η) + (bits : Fin (source η ξ hη hη1 hξ D hD F).«variables» → Bool) : + ((source η ξ hη hη1 hξ D hD F).equations.countP + (fun e => CloneGap.satisfied e bits) : ℚ) / + (source η ξ hη hη1 hξ D hD F).equations.length ≤ (1 + ξ) / 2 := + SourceSoundness.sourceList_sound_rat F hgap.1 + (repetitionCount η ξ hη hη1 hξ D hD) D hD hDtwo ξ hξ.le + (repeated_game_bound F η ξ hη hη1 hξ D hD hgap) bits + +theorem source_size (η ξ : ℚ) (hη : 0 < η) (hη1 : η ≤ 1) (hξ : 0 < ξ) + (D : ℕ) (hD : 0 < D) : + ∃ p : Polynomial ℕ, ∀ F : Formula, + (SourceEncoding.inputBits (source η ξ hη hη1 hξ D hD F)).length ≤ + p.eval (Complexity.formulaBits F).length := + SourceBounds.fixed_parameters_source_size (repetitionCount η ξ hη hη1 hξ D hD) D hD + +end IndependentSetsGames.Foundations.Hastad.SourceGap + +namespace IndependentSetsGames.Foundations.Hastad.SourceNonempty + +open Target PCP + +theorem real_clause_gap_of_count (F : Formula) (a b : ℕ) (hb : 0 < b) + (hgap : ∀ assignment : Fin F.«variables» → Bool, + a * F.clauses.length ≤ b * NameCompaction.failedCount F assignment) + (assignment : Fin F.«variables» → Bool) : + (a : ℝ) / (b : ℝ) * F.clauses.length ≤ + (failureCount F assignment (allIndices F) : ℝ) := by + rw [NameCompaction.verifier_failureCount] + have hreal : (a : ℝ) * F.clauses.length ≤ + (b : ℝ) * (NameCompaction.failedCount F assignment : ℝ) := by + exact_mod_cast hgap assignment + rw [div_mul_eq_mul_div] + apply (div_le_iff₀ (Nat.cast_pos.mpr hb)).mpr + simpa only [mul_comm] using hreal + +theorem clauseGap_of_count (F : Formula) (a b : ℕ) (hne : F.clauses ≠ []) + (hb : 0 < b) + (hgap : ∀ assignment : Fin F.«variables» → Bool, + a * F.clauses.length ≤ b * NameCompaction.failedCount F assignment) : + SourceGap.ClauseGap F ((a : ℚ) / (b : ℚ)) := by + refine ⟨hne, fun assignment => ?_⟩ + simpa only [Rat.cast_div, Rat.cast_natCast] using + real_clause_gap_of_count F a b hb hgap assignment + +variable {V E : Type*} {n m : ℕ} + +theorem cnf_nonempty_of_nonempty_darts [Fintype E] [Nonempty E] + (G : ConstraintGraph V E FinalBooleanVerifier.Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) : + (FinalBooleanVerifier.cnf G vertices edges).clauses ≠ [] := by + have hcard : Fintype.card E = m := by + simpa only [Fintype.card_fin] using Fintype.card_congr edges + have hm : 0 < m := hcard ▸ Fintype.card_pos + exact FinalBooleanVerifier.cnf_nonempty G vertices edges hm + +theorem cnf_clauseGap [Fintype E] [Nonempty E] + (G : ConstraintGraph V E FinalBooleanVerifier.Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) (a b : ℕ) (hb : 0 < b) + (hgap : ∀ labeling : V → FinalBooleanVerifier.Label, + a * Fintype.card E ≤ b * G.rejectionCount labeling) : + SourceGap.ClauseGap (FinalBooleanVerifier.cnf G vertices edges) + ((a : ℚ) / ((b : ℚ) * 40960)) := by + have h := clauseGap_of_count (FinalBooleanVerifier.cnf G vertices edges) a (b * 40960) + (cnf_nonempty_of_nonempty_darts G vertices edges) + (Nat.mul_pos hb (by decide)) (FinalBooleanVerifier.cnf_gap G vertices edges a b hgap) + simpa only [Nat.cast_mul, Nat.cast_ofNat] using h + +theorem cnf_clauseGap_unit [Fintype E] [Nonempty E] + (G : ConstraintGraph V E FinalBooleanVerifier.Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) (walkLength : ℕ) + (hwalk : 0 < walkLength) + (hgap : ∀ labeling : V → FinalBooleanVerifier.Label, + Fintype.card E ≤ walkLength * G.rejectionCount labeling) : + SourceGap.ClauseGap (FinalBooleanVerifier.cnf G vertices edges) + (1 / (40960 * (walkLength : ℚ))) := by + have h := cnf_clauseGap G vertices edges 1 walkLength hwalk + (by simpa only [one_mul] using hgap) + simpa only [Nat.cast_one, mul_comm] using h + +end IndependentSetsGames.Foundations.Hastad.SourceNonempty + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/HonestTest.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/HonestTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..c395d07b15f833c769309bb7e9b56c4a77c81492 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/HonestTest.lean @@ -0,0 +1,152 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Folding +import OAI.Combinatorics.IndependentSets.Reduction.FiniteNoise + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.Hastad + +open scoped BigOperators +open IndependentSetsGames.Reduction.FiniteNoise + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in + +theorem dictator_test_parity (π : J → I) (i : I) (j : J) (hπ : π j = i) + (f : Cube I) (g μ : Cube J) : + (f i ^^ g j ^^ (thirdQuery π f g μ) j) = μ j := by + simp only [thirdQuery, cubeXor, hπ] + cases f i <;> cases g j <;> cases μ j <;> rfl + +theorem noise_coordinate_sign (ε : ℝ) (j : J) : + (∑ μ : Cube J, noiseWeight ε μ * bitSign (μ j)) = 1 - 2 * ε := by + have hs : support (coordinateMask j) = {j} := by + ext k + simp [support, coordinateMask] + have h := noise_walsh ε (coordinateMask j) + simp_rw [walsh_symm (coordinateMask j), walsh_coordinateMask] at h + simpa only [hs, Finset.card_singleton, pow_one] using h + +theorem noise_coordinate_false (ε : ℝ) (j : J) : + (∑ μ : Cube J, noiseWeight ε μ * if μ j then (0 : ℝ) else 1) = 1 - ε := by + have hind (b : Bool) : (if b then (0 : ℝ) else 1) = + (1 + bitSign b) * (2 : ℝ)⁻¹ := by + cases b <;> norm_num [bitSign] + have ht (μ : Cube J) : noiseWeight ε μ * (if μ j then (0 : ℝ) else 1) = + (noiseWeight ε μ + noiseWeight ε μ * bitSign (μ j)) * (2 : ℝ)⁻¹ := by + rw [hind] + ring + simp_rw [ht] + rw [← Finset.sum_mul, Finset.sum_add_distrib, noiseWeight_sum, noise_coordinate_sign] + ring + +theorem testAcceptance_dictator (ε : ℝ) (π : J → I) + (i : I) (j : J) (hπ : π j = i) : + testAcceptance ε π (fun f => f i) (fun g => g j) = 1 - ε := by + have hg (f : Cube I) (μ : Cube J) : + (𝔼 g : Cube J, if f i ^^ g j ^^ (thirdQuery π f g μ) j then (0 : ℝ) else 1) = + if μ j then 0 else 1 := by + calc + _ = 𝔼 _g : Cube J, if μ j then (0 : ℝ) else 1 := by + apply Finset.expect_congr rfl + intro g _ + rw [dictator_test_parity π i j hπ f g μ] + _ = _ := Fintype.expect_const _ + change (𝔼 f : Cube I, ∑ μ : Cube J, noiseWeight ε μ * + (𝔼 g : Cube J, if f i ^^ g j ^^ (thirdQuery π f g μ) j then (0 : ℝ) else 1)) = _ + simp_rw [hg] + rw [Fintype.expect_const] + exact noise_coordinate_false ε j + +theorem testAcceptance_folded_dictators (ε : ℝ) (π : J → I) + (i₀ i : I) (j₀ j : J) (hπ : π j = i) : + testAcceptance ε π (foldedAnswer i₀ (fun h => h.val i)) + (foldedAnswer j₀ (fun h => h.val j)) = 1 - ε := by + have hA : foldedAnswer i₀ (fun h => h.val i) = (fun f : Cube I => f i) := + funext (foldedAnswer_dictator i₀ i) + have hB : foldedAnswer j₀ (fun h => h.val j) = (fun g : Cube J => g j) := + funext (foldedAnswer_dictator j₀ j) + rw [hA, hB] + exact testAcceptance_dictator ε π i j hπ + +theorem testAcceptance_conditioned_dictators (ε : ℝ) (π : J → I) + (validI : I → Bool) (validJ : J → Bool) + (i₀ i : {i : I // validI i = true}) (j₀ j : {j : J // validJ j = true}) + (hπ : π j.val = i.val) : + testAcceptance ε π + (conditionedFoldedAnswer validI i₀ (fun h => h.val i)) + (conditionedFoldedAnswer validJ j₀ (fun h => h.val j)) = 1 - ε := by + have hA : conditionedFoldedAnswer validI i₀ (fun h => h.val i) = + (fun f : Cube I => f i.val) := + funext (conditionedFoldedAnswer_dictator validI i₀ i) + have hB : conditionedFoldedAnswer validJ j₀ (fun h => h.val j) = + (fun g : Cube J => g j.val) := + funext (conditionedFoldedAnswer_dictator validJ j₀ j) + rw [hA, hB] + exact testAcceptance_dictator ε π i.val j.val hπ + +theorem testAcceptance_folded_conditioned_dictators (ε : ℝ) (π : J → I) + (i₀ i : I) (valid : J → Bool) + (j₀ j : {j : J // valid j = true}) (hπ : π j.val = i) : + testAcceptance ε π (foldedAnswer i₀ (fun h => h.val i)) + (conditionedFoldedAnswer valid j₀ (fun h => h.val j)) = 1 - ε := by + have hA : foldedAnswer i₀ (fun h => h.val i) = (fun f : Cube I => f i) := + funext (foldedAnswer_dictator i₀ i) + have hB : conditionedFoldedAnswer valid j₀ (fun h => h.val j) = + (fun g : Cube J => g j.val) := + funext (conditionedFoldedAnswer_dictator valid j₀ j) + rw [hA, hB] + exact testAcceptance_dictator ε π i j.val hπ + +def realizedTestAcceptance (D : Nat) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : ℝ := + 𝔼 f : Cube I, 𝔼 z : J → Fin D, 𝔼 g : Cube J, + if A f ^^ B g ^^ B (thirdQuery π f g (realizedNoise z)) then 0 else 1 + +theorem realizedTestAcceptance_eq_testAcceptance {D : Nat} (positive : 0 < D) + (π : J → I) (A : Cube I → Bool) (B : Cube J → Bool) : + realizedTestAcceptance D π A B = testAcceptance ((D : ℝ)⁻¹) π A B := by + unfold realizedTestAcceptance testAcceptance + apply Finset.expect_congr rfl + intro f _ + exact expect_realizedNoise positive + (fun μ => 𝔼 g : Cube J, if A f ^^ B g ^^ B (thirdQuery π f g μ) then 0 else 1) + +theorem realizedTestAcceptance_dictator {D : Nat} (positive : 0 < D) + (π : J → I) (i : I) (j : J) (hπ : π j = i) : + realizedTestAcceptance D π (fun f => f i) (fun g => g j) = 1 - (D : ℝ)⁻¹ := by + rw [realizedTestAcceptance_eq_testAcceptance positive] + exact testAcceptance_dictator _ π i j hπ + +theorem realizedTestAcceptance_folded_dictators {D : Nat} (positive : 0 < D) + (π : J → I) (i₀ i : I) (j₀ j : J) (hπ : π j = i) : + realizedTestAcceptance D π (foldedAnswer i₀ (fun h => h.val i)) + (foldedAnswer j₀ (fun h => h.val j)) = 1 - (D : ℝ)⁻¹ := by + rw [realizedTestAcceptance_eq_testAcceptance positive] + exact testAcceptance_folded_dictators _ π i₀ i j₀ j hπ + +theorem realizedTestAcceptance_conditioned_dictators {D : Nat} (positive : 0 < D) + (π : J → I) (validI : I → Bool) (validJ : J → Bool) + (i₀ i : {i : I // validI i = true}) (j₀ j : {j : J // validJ j = true}) + (hπ : π j.val = i.val) : + realizedTestAcceptance D π + (conditionedFoldedAnswer validI i₀ (fun h => h.val i)) + (conditionedFoldedAnswer validJ j₀ (fun h => h.val j)) = 1 - (D : ℝ)⁻¹ := by + rw [realizedTestAcceptance_eq_testAcceptance positive] + exact testAcceptance_conditioned_dictators _ π validI validJ i₀ i j₀ j hπ + +theorem realizedTestAcceptance_folded_conditioned_dictators {D : Nat} (positive : 0 < D) + (π : J → I) (i₀ i : I) (valid : J → Bool) + (j₀ j : {j : J // valid j = true}) (hπ : π j.val = i) : + realizedTestAcceptance D π (foldedAnswer i₀ (fun h => h.val i)) + (conditionedFoldedAnswer valid j₀ (fun h => h.val j)) = 1 - (D : ℝ)⁻¹ := by + rw [realizedTestAcceptance_eq_testAcceptance positive] + exact testAcceptance_folded_conditioned_dictators _ π i₀ i valid j₀ j hπ + +end IndependentSetsGames.Foundations.Hastad +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/LocalEquations.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/LocalEquations.lean new file mode 100644 index 0000000000000000000000000000000000000000..d95204f4704d606937d78b2b7de918b6d16ae196 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/LocalEquations.lean @@ -0,0 +1,137 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.EmptyContext +import OAI.Combinatorics.IndependentSets.Encoding.Occurrences + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceOccurrences +open IndependentSetsGames.Reduction.CloneGap +open scoped BigOperators +section LocalEquations + +variable {V C I J : Type} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +def localAddress (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J) + (v : V) (c : C) (valid : J → Bool) (i₀ : I) (j₀ : {j : J // valid j = true}) : + FoldedEquation.Address i₀ j₀ → Fin (globalEncoding vE cE iE jE).size + | .inl f => (globalEncoding vE cE iE jE).code (.inl (v, f.val)) + | .inr g => (globalEncoding vE cE iE jE).code (.inr (.inl (c, extendRestricted valid g.val))) + +omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in +theorem localAddress_injective + (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J) + (v : V) (c : C) (valid : J → Bool) (i₀ : I) (j₀ : {j : J // valid j = true}) : + Function.Injective (localAddress vE cE iE jE v c valid i₀ j₀) := by + intro a b h + cases a with + | inl a => + cases b with + | inl b => + have h' := (globalEncoding vE cE iE jE).code.injective h + have hval : a.val = b.val := congrArg Prod.snd (Sum.inl.inj h') + exact congrArg Sum.inl (Subtype.ext hval) + | inr b => + have h' := (globalEncoding vE cE iE jE).code.injective h + cases h' + | inr a => + cases b with + | inl b => + have h' := (globalEncoding vE cE iE jE).code.injective h + cases h' + | inr b => + have h' := (globalEncoding vE cE iE jE).code.injective h + have hext := congrArg Prod.snd (Sum.inl.inj (Sum.inr.inj h')) + exact congrArg Sum.inr (Subtype.ext (extendRestricted_injective valid hext)) + +def conditionedOccurrence + (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J) + (v : V) (c : C) (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) (f : Cube I) (g μ : Cube J) : + Equation (Fin (globalEncoding vE cE iE jE).size) := + mapEquation (localAddress vE cE iE jE v c valid i₀ j₀) + (FoldedEquation.conditionedEquation valid π i₀ j₀ f g μ) + +omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in +theorem conditionedOccurrence_satisfied + (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J) + (v : V) (c : C) (valid : J → Bool) (π : J → I) + (i₀ : I) (j₀ : {j : J // valid j = true}) + (bits : Fin (globalEncoding vE cE iE jE).size → Bool) + (f : Cube I) (g μ : Cube J) : + satisfied (conditionedOccurrence vE cE iE jE v c valid π i₀ j₀ f g μ) bits = + !(foldedAnswer i₀ (fun h => bits ((globalEncoding vE cE iE jE).code (.inl (v, h.val)))) f ^^ + conditionedFoldedAnswer valid j₀ + (fun h => bits ((globalEncoding vE cE iE jE).code + (.inr (.inl (c, extendRestricted valid h.val))))) g ^^ + conditionedFoldedAnswer valid j₀ + (fun h => bits ((globalEncoding vE cE iE jE).code + (.inr (.inl (c, extendRestricted valid h.val))))) (thirdQuery π f g μ)) := by + rw [conditionedOccurrence, satisfied_mapEquation] + let tableA : HalfCube i₀ → Bool := + fun h => bits ((globalEncoding vE cE iE jE).code (.inl (v, h.val))) + let tableB : HalfCube j₀ → Bool := + fun h => bits ((globalEncoding vE cE iE jE).code + (.inr (.inl (c, extendRestricted valid h.val)))) + have hbits : bits ∘ localAddress vE cE iE jE v c valid i₀ j₀ = + FoldedEquation.storedAssignment tableA tableB := by + funext a + cases a <;> rfl + rw [hbits] + exact FoldedEquation.conditionedEquation_satisfied valid π i₀ j₀ tableA tableB f g μ + +end LocalEquations + +def findValid {J : Type} (valid : J → Bool) : List J → Option {j : J // valid j = true} + | [] => none + | j :: rest => if h : valid j = true then some ⟨j, h⟩ else findValid valid rest + +theorem findValid_none_iff {J : Type} (valid : J → Bool) (xs : List J) : + findValid valid xs = none ↔ ∀ j ∈ xs, valid j = false := by + induction xs with + | nil => simp [findValid] + | cons j xs ih => + by_cases hj : valid j = true + · simp [findValid, hj] + · simp [findValid, hj, ih] + +def firstValid {J : Type} (e : Encoding J) (valid : J → Bool) : + Option {j : J // valid j = true} := findValid valid e.enumerate + +theorem firstValid_none_iff {J : Type} (e : Encoding J) (valid : J → Bool) : + firstValid e valid = none ↔ ∀ j, valid j = false := by + rw [firstValid, findValid_none_iff] + exact ⟨fun h j => h j (e.mem_enumerate j), fun h j _ => h j⟩ + +def occurrenceList {Tape Name : Type} (tape : Encoding Tape) + (emit : Tape → Equation Name) : List (Equation Name) := tape.enumerate.map emit + +@[simp] theorem occurrenceList_length {Tape Name : Type} (tape : Encoding Tape) + (emit : Tape → Equation Name) : (occurrenceList tape emit).length = tape.size := by + simp [occurrenceList] + +private theorem countP_cast_eq_sum {α : Type} (xs : List α) (p : α → Bool) : + (xs.countP p : ℝ) = (xs.map (fun x => if p x then (1 : ℝ) else 0)).sum := by + induction xs with + | nil => simp + | cons x xs ih => cases hp : p x <;> simp [hp, ih, add_comm] + +theorem countP_enumerate {Tape : Type} [Fintype Tape] + (tape : Encoding Tape) (p : Tape → Bool) : + (tape.enumerate.countP p : ℝ) = ∑ x, if p x then (1 : ℝ) else 0 := by + rw [countP_cast_eq_sum] + simp only [Encoding.enumerate, List.map_ofFn, List.sum_ofFn] + exact Fintype.sum_equiv tape.code.symm _ _ (fun _ => rfl) + +theorem occurrenceList_acceptance {Tape Name : Type} [Fintype Tape] + (tape : Encoding Tape) (emit : Tape → Equation Name) (bits : Name → Bool) : + ((occurrenceList tape emit).countP (fun e => satisfied e bits) : ℝ) / + (occurrenceList tape emit).length = + 𝔼 x, if satisfied (emit x) bits then (1 : ℝ) else 0 := by + rw [occurrenceList_length, Fintype.expect_eq_sum_div_card, tape.card_eq_size] + congr 1 + simpa only [occurrenceList, List.countP_map, Function.comp_def] using + countP_enumerate tape (fun x => satisfied (emit x) bits) + +end IndependentSetsGames.Foundations.Hastad.SourceOccurrences + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/NumberedStorage.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/NumberedStorage.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9504c64b684c095e7cf28b3a96473eaeedcfec3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/NumberedStorage.lean @@ -0,0 +1,239 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Soundness + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceHonest +open IndependentSetsGames.Reduction.CloneGap +open IndependentSetsGames.Reduction.FiniteNoise +open scoped BigOperators +section NumberedStorage + +open SourceOccurrences + +variable {V C I J : Type} + +theorem numbered_assignment_restriction + (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J) + (left : V → I) (right : C → J) (v : V) (c : C) + (valid : J → Bool) (i₀ : I) (j₀ j : {j : J // valid j = true}) + (hright : right c = j.val) : + assignmentOfKey vE cE iE jE (taggedAssignment left right) ∘ + localAddress vE cE iE jE v c valid i₀ j₀ = + FoldedEquation.storedAssignment (fun h => h.val (left v)) (fun h => h.val j) := by + funext a + cases a with + | inl h => + simp only [Function.comp_apply, localAddress, assignmentOfKey_code, + taggedAssignment_left, FoldedEquation.storedAssignment, Sum.elim_inl] + | inr h => + simp only [Function.comp_apply, localAddress, assignmentOfKey_code, + taggedAssignment_right, hright, extendRestricted_valid, + FoldedEquation.storedAssignment, Sum.elim_inr] + +theorem conditionedOccurrence_honest_satisfied + (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J) + (left : V → I) (right : C → J) (v : V) (c : C) + (valid : J → Bool) (π : J → I) (i₀ : I) + (j₀ j : {j : J // valid j = true}) + (hright : right c = j.val) (hπ : π j.val = left v) + (f : Cube I) (g μ : Cube J) : + satisfied (conditionedOccurrence vE cE iE jE v c valid π i₀ j₀ f g μ) + (assignmentOfKey vE cE iE jE (taggedAssignment left right)) = !(μ j.val) := by + rw [conditionedOccurrence, satisfied_mapEquation, + numbered_assignment_restriction vE cE iE jE left right v c valid i₀ j₀ j hright] + exact conditioned_equation_honest_satisfied valid π i₀ (left v) j₀ j hπ f g μ + +variable [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +theorem conditionedOccurrenceList_honest_acceptance {D : ℕ} (positive : 0 < D) + (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J) + (left : V → I) (right : C → J) (v : V) (c : C) + (valid : J → Bool) (π : J → I) (i₀ : I) + (j₀ j : {j : J // valid j = true}) + (hright : right c = j.val) (hπ : π j.val = left v) + (tape : Encoding (SourceTape.TestTape I J D)) : + let equations := occurrenceList tape (fun t => + conditionedOccurrence vE cE iE jE v c valid π i₀ j₀ + t.1 t.2.2 (realizedNoise t.2.1)) + ((equations.countP (fun e => satisfied e + (assignmentOfKey vE cE iE jE (taggedAssignment left right)))) : ℝ) / + equations.length = 1 - (D : ℝ)⁻¹ := by + dsimp only + rw [occurrenceList_acceptance] + calc + _ = SourceTape.tapeAcceptance D π (fun f => f (left v)) (fun g => g j.val) := by + unfold SourceTape.tapeAcceptance + apply Finset.expect_congr rfl + intro t _ + rw [conditionedOccurrence_honest_satisfied vE cE iE jE left right v c + valid π i₀ j₀ j hright hπ, dictator_test_parity π (left v) j.val hπ] + cases realizedNoise t.2.1 j.val <;> rfl + _ = _ := by + rw [SourceTape.tapeAcceptance_eq_realizedTestAcceptance] + exact realizedTestAcceptance_dictator positive π (left v) j.val hπ + +end NumberedStorage + +open SourceContexts +open SourceOccurrences + +def honestGlobal (F : Target.Formula) (u : ℕ) + (assignment : Fin F.«variables» → Bool) : + (VariableContext F u × Cube (I u)) ⊕ + ((ClauseContext F u × Cube (J u)) ⊕ Unit) → Bool := + taggedAssignment (fun v => honestI F v assignment) (fun c => honestJ F c assignment) + +def honestBits (F : Target.Formula) (u : ℕ) + (assignment : Fin F.«variables» → Bool) : Fin (nBits F u) → Bool := + assignmentOfKey (variableEncoding F u) (clauseEncoding F u) (iEncoding u) + (jEncoding u) (honestGlobal F u assignment) + +@[simp] theorem honestBits_code (F : Target.Formula) (u : ℕ) + (assignment : Fin F.«variables» → Bool) + (key : GlobalKey (VariableContext F u) (ClauseContext F u) (I u) (J u)) : + honestBits F u assignment ((proofEncoding F u).code key) = + honestGlobal F u assignment key := + assignmentOfKey_code (variableEncoding F u) (clauseEncoding F u) + (iEncoding u) (jEncoding u) (honestGlobal F u assignment) key + +@[simp] theorem honestBits_dummy (F : Target.Formula) (u : ℕ) + (assignment : Fin F.«variables» → Bool) : + honestBits F u assignment (dummyIndex F u) = false := by + rw [dummyIndex, honestBits_code] + rfl + +def honestValidJ (F : Target.Formula) {u : ℕ} (c : ClauseContext F u) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + {j : J u // validJ F c j = true} := + ⟨honestJ F c assignment, honestJ_valid F c assignment hs⟩ + +theorem validJ_nonempty_of_satisfying (F : Target.Formula) {u : ℕ} + (c : ClauseContext F u) (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + Nonempty {j : J u // validJ F c j = true} := + ⟨honestValidJ F c assignment hs⟩ + +theorem leftResponse_honest (F : Target.Formula) (u : ℕ) + (assignment : Fin F.«variables» → Bool) (v : VariableContext F u) : + leftResponse F u (honestBits F u assignment) v = + fun f => f (honestI F v assignment) := by + funext f + simp only [leftResponse, honestBits_code, honestGlobal, taggedAssignment, + foldedAnswer_dictator] + +theorem rightResponse_honest (F : Target.Formula) (u : ℕ) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) + (c : ClauseContext F u) : + rightResponse F u (honestBits F u assignment) c = + fun g => g (honestJ F c assignment) := by + funext g + cases ha : rightAnchor F c with + | none => + have hf := (rightAnchor_none_iff F c).mp ha (honestJ F c assignment) + rw [honestJ_valid F c assignment hs] at hf + cases hf + | some j₀ => + simp only [rightResponse, ha, honestBits_code, honestGlobal, taggedAssignment] + have ht : (fun h : HalfCube j₀ => + extendRestricted (validJ F c) h.val (honestJ F c assignment)) = + fun h => h.val (honestValidJ F c assignment hs) := by + funext h + exact extendRestricted_valid (validJ F c) h.val (honestValidJ F c assignment hs) + rw [ht] + exact conditionedFoldedAnswer_dictator (validJ F c) j₀ + (honestValidJ F c assignment hs) g + +theorem context_tapeAcceptance {D : ℕ} (positive : 0 < D) + (F : Target.Formula) {u : ℕ} (c : ClauseContext F u) (s : SlotContext u) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) + (i₀ : I u) (j₀ : {j : J u // validJ F c j = true}) : + SourceTape.tapeAcceptance D (pi F c (sampledVariables F c s)) + (foldedAnswer i₀ (fun h => h.val (honestI F (sampledVariables F c s) assignment))) + (conditionedFoldedAnswer (validJ F c) j₀ + (fun h => h.val (honestValidJ F c assignment hs))) = + 1 - (D : ℝ)⁻¹ := by + exact tapeAcceptance_conditioned_dictators positive (validJ F c) + (pi F c (sampledVariables F c s)) i₀ _ j₀ _ + (pi_honest_sampled F c s assignment) + +theorem sourceEquation_honest_satisfied (F : Target.Formula) (u D : ℕ) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) + (p : SourceIndex F u D) : + satisfied (sourceEquation F u D p) (honestBits F u assignment) = + !(realizedNoise p.2.2.1 (honestJ F p.1.1 assignment)) := by + simp only [sourceEquation, contextEquation_satisfied, leftResponse_honest, + rightResponse_honest F u assignment hs] + rw [dictator_test_parity _ _ _ (pi_honest_sampled F p.1.1 p.1.2 assignment)] + +theorem rawSourceList_honest_acceptance (F : Target.Formula) (u D : ℕ) + (hD : 0 < D) (hF : F.clauses ≠ []) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + ((rawSourceList F u D).countP + (fun e => satisfied e (honestBits F u assignment)) : ℝ) / + (rawSourceList F u D).length = 1 - (D : ℝ)⁻¹ := by + have hc : 0 < F.clauses.length := List.length_pos_iff.mpr hF + let : Nonempty (Fin F.clauses.length) := ⟨⟨0, hc⟩⟩ + rw [rawSourceList_acceptance F u D hD] + have heq (c : ClauseContext F u) (s : SlotContext u) : + testAcceptance ((D : ℝ)⁻¹) (pi F c (sampledVariables F c s)) + (leftResponse F u (honestBits F u assignment) (sampledVariables F c s)) + (rightResponse F u (honestBits F u assignment) c) = 1 - (D : ℝ)⁻¹ := by + rw [leftResponse_honest, rightResponse_honest F u assignment hs] + exact testAcceptance_dictator _ _ _ _ (pi_honest_sampled F c s assignment) + simp_rw [heq] + simp only [Fintype.expect_const] + +theorem sourceList_honest_acceptance_nonempty (F : Target.Formula) (u D : ℕ) + (hD : 0 < D) (hF : F.clauses ≠ []) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + ((sourceList F u D).countP + (fun e => satisfied e (honestBits F u assignment)) : ℝ) / + (sourceList F u D).length = 1 - (D : ℝ)⁻¹ := by + rw [sourceList_nonempty F u D hF] + exact rawSourceList_honest_acceptance F u D hD hF assignment hs + +theorem sourceList_honest_acceptance (F : Target.Formula) (u D : ℕ) + (hD : 0 < D) (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + 1 - (D : ℝ)⁻¹ ≤ ((sourceList F u D).countP + (fun e => satisfied e (honestBits F u assignment)) : ℝ) / + (sourceList F u D).length := by + by_cases hF : F.clauses = [] + · rw [sourceList_empty F u D hF] + simp only [List.countP_cons, List.countP_nil, emptyFormulaEquation_satisfied, + honestBits_dummy, Bool.not_false, ↓reduceIte, + Nat.zero_add, Nat.cast_one, List.length_cons, List.length_nil, div_one] + exact sub_le_self _ (inv_nonneg.mpr (Nat.cast_nonneg D)) + · exact (sourceList_honest_acceptance_nonempty F u D hD hF assignment hs).ge + +theorem sourceList_honest_acceptance_rat (F : Target.Formula) (u D : ℕ) + (hD : 0 < D) (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + 1 - (D : ℚ)⁻¹ ≤ ((sourceList F u D).countP + (fun e => satisfied e (honestBits F u assignment)) : ℚ) / + (sourceList F u D).length := by + apply (Rat.cast_le (K := ℝ)).mp + simpa only [Rat.cast_sub, Rat.cast_one, Rat.cast_inv, Rat.cast_natCast, Rat.cast_div] using + sourceList_honest_acceptance F u D hD assignment hs + +theorem sourceList_honest_acceptance_nonempty_rat (F : Target.Formula) (u D : ℕ) + (hD : 0 < D) (hF : F.clauses ≠ []) + (assignment : Fin F.«variables» → Bool) + (hs : ∀ clause ∈ F.clauses, clause.eval assignment = true) : + ((sourceList F u D).countP + (fun e => satisfied e (honestBits F u assignment)) : ℚ) / + (sourceList F u D).length = 1 - (D : ℚ)⁻¹ := by + apply Rat.cast_injective (α := ℝ) + simpa only [Rat.cast_sub, Rat.cast_one, Rat.cast_inv, Rat.cast_natCast, Rat.cast_div] using + sourceList_honest_acceptance_nonempty F u D hD hF assignment hs + +end IndependentSetsGames.Foundations.Hastad.SourceHonest + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Soundness.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Soundness.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0f7871df74a2c3efc370b90da83770857b99539 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Soundness.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Game +import OAI.Combinatorics.IndependentSets.Encoding.Concrete + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.Hastad.SourceSoundness + +open scoped BigOperators +open Target SourceContexts SourceOccurrences SourceGame + +def leftTable (F : Formula) (u : ℕ) (bits : Fin (nBits F u) → Bool) + (v : VariableContext F u) : HalfCube (leftAnchor u) → Bool := + fun h => bits ((proofEncoding F u).code (.inl (v, h.val))) + +def rightOracle (F : Formula) (u : ℕ) (bits : Fin (nBits F u) → Bool) + (c : ClauseContext F u) : ConditionedOracle (validJ F c) := + match h : rightAnchor F c with + | none => .empty ((rightAnchor_none_iff F c).mp h) + | some j₀ => .stored j₀ + (fun h => bits ((proofEncoding F u).code + (.inr (.inl (c, extendRestricted (validJ F c) h.val))))) + +@[simp] theorem rightOracle_answer (F : Formula) (u : ℕ) + (bits : Fin (nBits F u) → Bool) (c : ClauseContext F u) : + (rightOracle F u bits c).answer = rightResponse F u bits c := by + unfold rightOracle + split <;> simp_all [rightResponse, ConditionedOracle.answer] + +@[simp] theorem leftTable_answer (F : Formula) (u : ℕ) + (bits : Fin (nBits F u) → Bool) (v : VariableContext F u) : + foldedAnswer (leftAnchor u) (leftTable F u bits v) = leftResponse F u bits v := rfl + +theorem sourceList_sound (F : Formula) (hne : F.clauses ≠ []) (u D : ℕ) + (hD : 0 < D) (hDtwo : 2 ≤ D) (δ : ℝ) (hδ : 0 ≤ δ) + (hvalue : ((baseGame F hne).repetition u).value ≤ + 4 * (D : ℝ)⁻¹ * δ ^ 2) + (bits : Fin (nBits F u) → Bool) : + ((sourceList F u D).countP (fun e => IndependentSetsGames.Reduction.CloneGap.satisfied e bits) : ℝ) / + (sourceList F u D).length ≤ (1 + δ) / 2 := by + rw [sourceList_nonempty F u D hne, rawSourceList_acceptance F u D hD] + have hε : (0 : ℝ) < (D : ℝ)⁻¹ := inv_pos.mpr (Nat.cast_pos.mpr hD) + have hε' : (D : ℝ)⁻¹ ≤ (1 : ℝ) / 2 := by + have hd : (2 : ℝ) ≤ D := by exact_mod_cast hDtwo + simpa only [one_div] using + (inv_le_inv₀ (Nat.cast_pos.mpr hD) (by norm_num : (0 : ℝ) < 2)).mpr hd + have h := source_acceptance_le_split F hne u ((D : ℝ)⁻¹) δ + (fun _ => leftAnchor u) (leftTable F u bits) (rightOracle F u bits) + hε hε' hδ hvalue + simpa only [leftTable_answer, rightOracle_answer] using h + +theorem sourceList_sound_rat (F : Formula) (hne : F.clauses ≠ []) (u D : ℕ) + (hD : 0 < D) (hDtwo : 2 ≤ D) (δ : ℚ) (hδ : 0 ≤ δ) + (hvalue : ((baseGame F hne).repetition u).value ≤ + 4 * (D : ℝ)⁻¹ * (δ : ℝ) ^ 2) + (bits : Fin (nBits F u) → Bool) : + ((sourceList F u D).countP (fun e => IndependentSetsGames.Reduction.CloneGap.satisfied e bits) : ℚ) / + (sourceList F u D).length ≤ (1 + δ) / 2 := by + have h := sourceList_sound F hne u D hD hDtwo (δ : ℝ) + (by exact_mod_cast hδ) hvalue bits + apply (Rat.cast_le (K := ℝ)).mp + push_cast + exact h + +end IndependentSetsGames.Foundations.Hastad.SourceSoundness + +end +namespace IndependentSetsGames.Foundations.Hastad.SourceHonest + +open IndependentSetsGames.Reduction.CloneGap +open IndependentSetsGames.Reduction.FiniteNoise +open scoped BigOperators + +def taggedAssignment {V C I J : Type} (left : V → I) (right : C → J) : + (V × Cube I) ⊕ ((C × Cube J) ⊕ Unit) → Bool + | .inl (v, f) => f (left v) + | .inr (.inl (c, g)) => g (right c) + | .inr (.inr _) => false + +@[simp] theorem taggedAssignment_left {V C I J : Type} + (left : V → I) (right : C → J) (v : V) (f : Cube I) : + taggedAssignment left right (.inl (v, f)) = f (left v) := rfl + +@[simp] theorem taggedAssignment_right {V C I J : Type} + (left : V → I) (right : C → J) (c : C) (g : Cube J) : + taggedAssignment left right (.inr (.inl (c, g))) = g (right c) := rfl + +theorem taggedAssignment_right_restriction {V C I J : Type} + (left : V → I) (right : C → J) (c : C) (valid : J → Bool) + (honest : {j : J // valid j = true}) (hright : right c = honest.val) + (extend : Cube {j : J // valid j = true} → Cube J) + (hextend : ∀ (g : Cube {j : J // valid j = true}) + (j : {j : J // valid j = true}), extend g j.val = g j) + (j₀ : {j : J // valid j = true}) (h : HalfCube j₀) : + taggedAssignment left right (.inr (.inl (c, extend h.val))) = h.val honest := by + change extend h.val (right c) = h.val honest + rw [hright] + exact hextend h.val honest + +variable {I J : Type} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in +theorem conditioned_equation_honest_satisfied + (valid : J → Bool) (π : J → I) (i₀ i : I) + (j₀ j : {j : J // valid j = true}) (hπ : π j.val = i) + (f : Cube I) (g μ : Cube J) : + satisfied (FoldedEquation.conditionedEquation valid π i₀ j₀ f g μ) + (FoldedEquation.storedAssignment (fun h => h.val i) (fun h => h.val j)) = + !(μ j.val) := by + rw [FoldedEquation.conditionedEquation_satisfied, foldedAnswer_dictator, + conditionedFoldedAnswer_dictator, conditionedFoldedAnswer_dictator, + dictator_test_parity π i j.val hπ] + +omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in +theorem mapped_conditioned_equation_honest_satisfied {Name : Type} + (valid : J → Bool) (π : J → I) (i₀ i : I) + (j₀ j : {j : J // valid j = true}) (hπ : π j.val = i) + (rename : FoldedEquation.Address i₀ j₀ → Name) (assignment : Name → Bool) + (hleft : ∀ h, assignment (rename (.inl h)) = h.val i) + (hright : ∀ h, assignment (rename (.inr h)) = h.val j) + (f : Cube I) (g μ : Cube J) : + satisfied (mapEquation rename + (FoldedEquation.conditionedEquation valid π i₀ j₀ f g μ)) assignment = + !(μ j.val) := by + have hlocal : assignment ∘ rename = + FoldedEquation.storedAssignment (fun h => h.val i) (fun h => h.val j) := by + funext a + cases a with + | inl h => exact hleft h + | inr h => exact hright h + rw [satisfied_mapEquation, hlocal] + exact conditioned_equation_honest_satisfied valid π i₀ i j₀ j hπ f g μ + +theorem tapeAcceptance_conditioned_dictators {D : ℕ} (positive : 0 < D) + (valid : J → Bool) (π : J → I) (i₀ i : I) + (j₀ j : {j : J // valid j = true}) (hπ : π j.val = i) : + SourceTape.tapeAcceptance D π + (foldedAnswer i₀ (fun h => h.val i)) + (conditionedFoldedAnswer valid j₀ (fun h => h.val j)) = + 1 - (D : ℝ)⁻¹ := by + rw [SourceTape.tapeAcceptance_eq_realizedTestAcceptance] + exact realizedTestAcceptance_folded_conditioned_dictators positive π i₀ i valid j₀ j hπ + +end IndependentSetsGames.Foundations.Hastad.SourceHonest + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Walsh.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Walsh.lean new file mode 100644 index 0000000000000000000000000000000000000000..d237c5a7b1be2ba5cdda82ed0b046ded47ff97a8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Walsh.lean @@ -0,0 +1,241 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.Hastad + +open scoped BigOperators +open Finset + +abbrev Cube (I : Type*) := I → Bool + +def bitSign (b : Bool) : ℝ := if b then -1 else 1 + +@[simp] theorem bitSign_sq (b : Bool) : bitSign b ^ 2 = 1 := by + cases b <;> norm_num [bitSign] + +theorem bitSign_xor (b c : Bool) : + bitSign (b ^^ c) = bitSign b * bitSign c := by + cases b <;> cases c <;> norm_num [bitSign] + +def cubeXor {I : Type*} (x y : Cube I) : Cube I := fun i => x i ^^ y i + +def walsh {I : Type*} [Fintype I] [DecidableEq I] (s x : Cube I) : ℝ := + ∏ i, bitSign (s i && x i) + +theorem walsh_symm {I : Type*} [Fintype I] [DecidableEq I] (s x : Cube I) : + walsh s x = walsh x s := by + simp [walsh, Bool.and_comm] + +@[simp] theorem walsh_sq {I : Type*} [Fintype I] [DecidableEq I] (s x : Cube I) : + walsh s x ^ 2 = 1 := by + simp [walsh, ← Finset.prod_pow] + +theorem walsh_xor {I : Type*} [Fintype I] [DecidableEq I] (s x y : Cube I) : + walsh s (cubeXor x y) = walsh s x * walsh s y := by + simp only [walsh, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + simp only [cubeXor] + cases s i <;> cases x i <;> cases y i <;> norm_num [bitSign] + +theorem coordinate_orthogonality (s t : Bool) : + (∑ x : Bool, bitSign (s && x) * bitSign (t && x)) = + if s = t then 2 else 0 := by + cases s <;> cases t <;> norm_num [bitSign, Fintype.sum_bool] + +theorem walsh_sum_orthogonality {I : Type*} [Fintype I] [DecidableEq I] + (s t : Cube I) : + (∑ x, walsh s x * walsh t x) = + if s = t then (Fintype.card (Cube I) : ℝ) else 0 := by + classical + simp only [walsh, ← Finset.prod_mul_distrib] + rw [← Fintype.prod_sum (fun (i : I) (b : Bool) => + bitSign (s i && b) * bitSign (t i && b))] + simp only [coordinate_orthogonality] + by_cases h : s = t + · subst t + simp + · rw [ite_eq_right h] + obtain ⟨i, hi⟩ := Function.ne_iff.mp h + apply Finset.prod_eq_zero (Finset.mem_univ i) + exact ite_eq_right hi + +theorem walsh_orthogonality {I : Type*} [Fintype I] [DecidableEq I] + (s t : Cube I) : + (𝔼 x, walsh s x * walsh t x) = if s = t then 1 else 0 := by + classical + rw [Fintype.expect_eq_sum_div_card, walsh_sum_orthogonality] + split_ifs <;> simp + +def coefficient {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → ℝ) (s : Cube I) : ℝ := + 𝔼 x, f x * walsh s x + +theorem walsh_inversion {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → ℝ) (x : Cube I) : + (∑ s, coefficient f s * walsh s x) = f x := by + classical + unfold coefficient + simp_rw [Finset.expect_mul] + rw [← Finset.expect_sum_comm] + have h (y : Cube I) : + (∑ s, (f y * walsh s y) * walsh s x) = + f y * (if y = x then (Fintype.card (Cube I) : ℝ) else 0) := by + simp only [mul_assoc, ← Finset.mul_sum] + congr 1 + simp_rw [walsh_symm (x := y), walsh_symm (x := x)] + exact walsh_sum_orthogonality y x + simp_rw [h] + rw [Fintype.expect_eq_sum_div_card] + simp + +theorem walsh_inner {I : Type*} [Fintype I] [DecidableEq I] (f g : Cube I → ℝ) : + (∑ s, coefficient f s * coefficient g s) = 𝔼 x, f x * g x := by + classical + unfold coefficient + simp_rw [Finset.mul_expect] + rw [← Finset.expect_sum_comm] + apply Finset.expect_congr rfl + intro x _ + have h : (∑ s, (𝔼 y, f y * walsh s y) * (g x * walsh s x)) = + g x * (∑ s, coefficient f s * walsh s x) := by + simp only [Finset.mul_sum, coefficient] + apply Finset.sum_congr rfl + intro s _ + ring + rw [h, walsh_inversion] + ring + +theorem walsh_parseval {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → ℝ) : + (∑ s, coefficient f s ^ 2) = 𝔼 x, f x ^ 2 := by + simpa [pow_two] using walsh_inner f f + +theorem sign_parseval {I : Type*} [Fintype I] [DecidableEq I] (f : Cube I → Bool) : + (∑ s, coefficient (fun x => bitSign (f x)) s ^ 2) = 1 := by + rw [walsh_parseval] + simp + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +def support (s : Cube I) : Finset I := Finset.univ.filter fun i => s i = true + +def noiseWeight (ε : ℝ) (μ : Cube I) : ℝ := + ∏ i, if μ i then ε else 1 - ε + +omit [DecidableEq I] in +theorem noiseWeight_nonneg {ε : ℝ} (hε : 0 ≤ ε) (hε' : ε ≤ 1) (μ : Cube I) : + 0 ≤ noiseWeight ε μ := by + apply Finset.prod_nonneg + intro i _ + split <;> linarith + +theorem noiseWeight_sum (ε : ℝ) : (∑ μ : Cube I, noiseWeight ε μ) = 1 := by + unfold noiseWeight + rw [← Fintype.prod_sum (fun (_ : I) (b : Bool) => if b then ε else 1 - ε)] + simp + +theorem noise_walsh (ε : ℝ) (s : Cube I) : + (∑ μ, noiseWeight ε μ * walsh s μ) = (1 - 2 * ε) ^ (support s).card := by + unfold noiseWeight walsh + simp only [← Finset.prod_mul_distrib] + rw [← Fintype.prod_sum (fun i b => + (if b then ε else 1 - ε) * bitSign (s i && b))] + have hc (i : I) : (∑ b : Bool, + (if b then ε else 1 - ε) * bitSign (s i && b)) = + if s i then 1 - 2 * ε else 1 := by + cases s i <;> simp [bitSign] + ring + simp_rw [hc] + simp [support, Finset.prod_ite] + +def thirdQuery (π : J → I) (f : Cube I) (g μ : Cube J) : Cube J := + cubeXor g (cubeXor (fun y => f (π y)) μ) + +theorem walsh_autocorrelation (B : Cube J → ℝ) (h : Cube J) : + (𝔼 g, B g * B (cubeXor g h)) = + ∑ s, coefficient B s ^ 2 * walsh s h := by + conv_lhs => + enter [2, g, 2] + rw [← walsh_inversion B (cubeXor g h)] + simp_rw [Finset.mul_sum, walsh_xor] + rw [Finset.expect_sum_comm] + apply Finset.sum_congr rfl + intro s _ + have hterm : (fun g => B g * (coefficient B s * (walsh s g * walsh s h))) = + (fun g => (coefficient B s * walsh s h) * (B g * walsh s g)) := by + funext g + ring + rw [hterm, ← Finset.mul_expect] + change (coefficient B s * walsh s h) * coefficient B s = _ + ring + +def projectedCoefficient (π : J → I) (A : Cube I → ℝ) (s : Cube J) : ℝ := + 𝔼 f, A f * walsh s (fun y => f (π y)) + +def testBias (ε : ℝ) (π : J → I) (A : Cube I → ℝ) (B : Cube J → ℝ) : ℝ := + 𝔼 f, ∑ μ, noiseWeight ε μ * A f * + (𝔼 g, B g * B (thirdQuery π f g μ)) + +theorem testBias_fourier (ε : ℝ) (π : J → I) + (A : Cube I → ℝ) (B : Cube J → ℝ) : + testBias ε π A B = ∑ s, + projectedCoefficient π A s * coefficient B s ^ 2 * + (1 - 2 * ε) ^ (support s).card := by + unfold testBias thirdQuery + simp_rw [walsh_autocorrelation, Finset.mul_sum] + conv_lhs => + enter [2, f] + rw [Finset.sum_comm] + rw [Finset.expect_sum_comm] + apply Finset.sum_congr rfl + intro s _ + have hterm (f : Cube I) : + (∑ μ, noiseWeight ε μ * A f * + (coefficient B s ^ 2 * walsh s (cubeXor (fun y => f (π y)) μ))) = + (A f * walsh s (fun y => f (π y))) * coefficient B s ^ 2 * + (1 - 2 * ε) ^ (support s).card := by + simp_rw [walsh_xor] + have heq (μ : Cube J) : noiseWeight ε μ * A f * + (coefficient B s ^ 2 * (walsh s (fun y => f (π y)) * walsh s μ)) = + ((A f * walsh s (fun y => f (π y))) * coefficient B s ^ 2) * + (noiseWeight ε μ * walsh s μ) := by ring + simp_rw [heq] + rw [← Finset.mul_sum, noise_walsh] + simp_rw [hterm, ← Finset.expect_mul] + rfl + +def testAcceptance (ε : ℝ) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : ℝ := + 𝔼 f, ∑ μ, noiseWeight ε μ * + (𝔼 g, if A f ^^ B g ^^ B (thirdQuery π f g μ) then 0 else 1) + +theorem threeBit_indicator (a b c : Bool) : + (if a ^^ b ^^ c then (0 : ℝ) else 1) = + (1 + bitSign a * bitSign b * bitSign c) / 2 := by + cases a <;> cases b <;> cases c <;> norm_num [bitSign] + +theorem testAcceptance_eq (ε : ℝ) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : + testAcceptance ε π A B = + (1 + testBias ε π (fun f => bitSign (A f)) (fun g => bitSign (B g))) / 2 := by + unfold testAcceptance testBias + simp_rw [threeBit_indicator, div_eq_mul_inv, + ← Finset.expect_mul, Finset.expect_add_distrib] + simp only [Fintype.expect_const] + have hterm (f : Cube I) (μ : Cube J) : + noiseWeight ε μ * ((1 + 𝔼 g, + bitSign (A f) * bitSign (B g) * bitSign (B (thirdQuery π f g μ))) * 2⁻¹) = + (noiseWeight ε μ + noiseWeight ε μ * bitSign (A f) * + (𝔼 g, bitSign (B g) * bitSign (B (thirdQuery π f g μ)))) * 2⁻¹ := by + simp_rw [mul_assoc (bitSign (A f)), ← Finset.mul_expect] + ring + simp_rw [hterm, ← Finset.sum_mul, Finset.sum_add_distrib, noiseWeight_sum, + ← Finset.expect_mul, Finset.expect_add_distrib] + simp + +end IndependentSetsGames.Foundations.Hastad + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Fourier/Walsh2.lean b/lean/OAI/Combinatorics/IndependentSets/Fourier/Walsh2.lean new file mode 100644 index 0000000000000000000000000000000000000000..81be4dabc0f0731ee77130612912d834b356bb3e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Fourier/Walsh2.lean @@ -0,0 +1,51 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.AssignmentTester +import OAI.Combinatorics.IndependentSets.Repetition.CayleySampling + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.PCP.CayleySampling +open scoped BigOperators +open Finset +open IndependentSetsGames.Foundations.Hastad +variable {V D : Type*} + +variable {I : Type*} [Fintype I] [DecidableEq I] [Fintype D] [DecidableEq D] + +omit [DecidableEq I] in +theorem exists_true_of_ne_zero (s : Cube I) (hs : s ≠ fun _ => false) : + ∃ i, s i = true := by + by_contra h + apply hs + funext i + cases hi : s i + · rfl + · exact False.elim (h ⟨i, hi⟩) + +theorem expect_parity_samples (s : Cube I) (hs : s ≠ fun _ => false) + (F : (D → Bool) → ℝ) : + (𝔼 g : D → Cube I, F (fun d => AssignmentTester.parity s (g d))) = + 𝔼 b : D → Bool, F b := by + obtain ⟨i, hi⟩ := exists_true_of_ne_zero s hs + exact expect_boolean_samples (AssignmentTester.parity s) (AssignmentTester.flipAt i) + (AssignmentTester.flipAt_twice i) + (fun x => AssignmentTester.parity_flipAt s i x hi) F + +theorem expect_walsh_samples (s : Cube I) (hs : s ≠ fun _ => false) + (F : (D → ℝ) → ℝ) : + (𝔼 g : D → Cube I, F (fun d => walsh s (g d))) = + 𝔼 b : D → Bool, F (fun d => bitSign (b d)) := by + simpa only [AssignmentTester.bitSign_parity] using + expect_parity_samples s hs (fun b => F (fun d => bitSign (b d))) + +theorem expect_walsh_mean (s : Cube I) (hs : s ≠ fun _ => false) (F : ℝ → ℝ) : + (𝔼 g : D → Cube I, F (𝔼 d, walsh s (g d))) = + 𝔼 b : D → Bool, F (𝔼 d, bitSign (b d)) := + expect_walsh_samples s hs (fun z => F (𝔼 d, z d)) + +end IndependentSetsGames.Foundations.PCP.CayleySampling + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateAverage.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..0edaf405f7a3a81ebd4afcf5c8643f5ea00825ba --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateAverage.lean @@ -0,0 +1,24 @@ +import Mathlib + +namespace OAI + +namespace LargeIndependentSets +open MeasureTheory +open scoped BigOperators unitInterval NNReal + +noncomputable def coordinateAverage {n : ℕ} (S : Finset (Fin n)) + (f : (Fin n → I) → ℝ) (x : Fin n → I) : ℝ := by + classical + exact ∫ y : Fin n → I, f (fun i => if i ∈ S then x i else y i) + +def CubeJuntaStatement : Prop := + ∀ L : ℝ≥0, ∀ τ : ℝ, 0 < τ → ∃ J : ℕ, 1 ≤ J ∧ + ∀ n : ℕ, 0 < n → ∀ f : (Fin n → I) → ℝ, + LipschitzWith L f → (∀ x, |f x| ≤ 1) → + ∃ S : Finset (Fin n), S.card ≤ J ∧ + Integrable (fun x => (f x - coordinateAverage S f x)^2) ∧ + (∫ x, (f x - coordinateAverage S f x)^2) < τ^2 + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateDerivative.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..3caa6a064678c0c4cfde6656416f1ce36d0a5072 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateDerivative.lean @@ -0,0 +1,52 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.SumCoordinateNorm + +namespace OAI + +namespace LargeIndependentSets.CubeGradient +open MeasureTheory Set +open scoped BigOperators NNReal Classical + +noncomputable def coordinateDerivative {n : ℕ} (f : (Fin n → ℝ) → ℝ) + (i : Fin n) (x : Fin n → ℝ) : ℝ := deriv (f ∘ Function.update x i) (x i) + +lemma coordinateDerivative_eq {n : ℕ} {f : (Fin n → ℝ) → ℝ} (i : Fin n) + {x : Fin n → ℝ} (hx : DifferentiableAt ℝ f x) : + coordinateDerivative f i x = fderiv ℝ f x (Pi.single i 1) := by + unfold coordinateDerivative + rw [fderiv_comp_deriv _ (by simpa using hx) (hasDerivAt_update x i (x i)).differentiableAt] + simp [deriv_update] + +lemma fderiv_coordinate_integrable {n : ℕ} {L : ℝ≥0} {f : (Fin n → ℝ) → ℝ} + (hf : LipschitzWith L f) (i : Fin n) (μ : Measure (Fin n → ℝ)) [IsFiniteMeasure μ] : + Integrable (fun x => |fderiv ℝ f x (Pi.single i 1)|) μ := by + apply (integrable_const (L:ℝ)).mono' + ((measurable_fderiv_apply_const ℝ f (Pi.single i 1)).abs.stronglyMeasurable.aestronglyMeasurable) + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_abs] + exact (Finset.single_le_sum (fun j _ => abs_nonneg (fderiv ℝ f x (Pi.single j 1))) + (Finset.mem_univ i)).trans (lipschitz_sum_partials hf x) + +theorem integral_total_coordinate_variation {n : ℕ} {L : ℝ≥0} {f : (Fin n → ℝ) → ℝ} + (hf : LipschitzWith L f) (μ : Measure (Fin n → ℝ)) [IsProbabilityMeasure μ] + (hμ : μ ≪ (volume : Measure (Fin n → ℝ))) : + (∀ i, Integrable (fun x => |coordinateDerivative f i x|) μ) ∧ + (∑ i, ∫ x, |coordinateDerivative f i x| ∂μ) ≤ L := by + have he (i : Fin n) : (fun x => |coordinateDerivative f i x|) =ᵐ[μ] + (fun x => |fderiv ℝ f x (Pi.single i 1)|) := by + filter_upwards [hμ.ae_le hf.ae_differentiableAt] with x hx + rw [coordinateDerivative_eq i hx] + have hi (i : Fin n) : Integrable (fun x => |coordinateDerivative f i x|) μ := + (fderiv_coordinate_integrable hf i μ).congr (he i).symm + refine ⟨hi, ?_⟩ + simp_rw [integral_congr_ae (he _)] + rw [← integral_finsetSum _ (fun i _ => fderiv_coordinate_integrable hf i μ)] + have hs : Integrable (fun x => ∑ i, |fderiv ℝ f x (Pi.single i 1)|) μ := + integrable_finsetSum _ (fun i _ => fderiv_coordinate_integrable hf i μ) + have h := integral_mono_ae hs (integrable_const (L:ℝ)) + (Filter.Eventually.of_forall (fun x => lipschitz_sum_partials hf x)) + simpa using h + +end LargeIndependentSets.CubeGradient + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateMean.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..b28624ad04d4caaf67344a50c0429c1358ac65c2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/CoordinateMean.lean @@ -0,0 +1,116 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.RowBitsEquiv + +namespace OAI + +namespace LargeIndependentSets.ProductAveraging +open MeasureTheory Set +open scoped BigOperators Classical + +noncomputable def coordinateMean {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) (i : ι) (f : (ι → α) → ℝ) (x : ι → α) : ℝ := + ∫ t, f (Function.update x i t) ∂μ + +noncomputable def influenceSq {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) (i : ι) (f : (ι → α) → ℝ) : ℝ := + ∫ x, (f x-coordinateMean μ i f x)^2 ∂Measure.pi (fun _ : ι => μ) + +lemma coordinateMean_measurable {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (i : ι) {f : (ι → α) → ℝ} (hf : Measurable f) : + Measurable (coordinateMean μ i f) := + (hf.comp (update_measurable i)).stronglyMeasurable.integral_prod_right'.measurable + +lemma coordinateMean_bound {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (i : ι) {f : (ι → α) → ℝ} {B : ℝ} + (hb : ∀ x, |f x| ≤ B) (x : ι → α) : |coordinateMean μ i f x| ≤ B := by + have h := norm_integral_le_of_norm_le_const (μ:=μ) (f:=fun t => f (Function.update x i t)) + (C:=B) (Filter.Eventually.of_forall (fun t => by simpa only [Real.norm_eq_abs] using hb _)) + simpa only [Real.norm_eq_abs, measureReal_def, measure_univ, ENNReal.toReal_one, + mul_one, coordinateMean] using h + +lemma coordinateMean_update {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) (i : ι) (f : (ι → α) → ℝ) (x : ι → α) (t : α) : + coordinateMean μ i f (Function.update x i t) = coordinateMean μ i f x := by + simp only [coordinateMean, Function.update_idem] + +lemma integral_mul_coordinateMean {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (i : ι) {f : (ι → α) → ℝ} {B : ℝ} + (hf : Measurable f) (hb : ∀ x, |f x| ≤ B) : + (∫ x, f x * coordinateMean μ i f x ∂Measure.pi (fun _ : ι => μ)) = + ∫ x, (coordinateMean μ i f x)^2 ∂Measure.pi (fun _ : ι => μ) := by + have hm := coordinateMean_measurable μ i hf + have hi : Integrable (fun x => f x*coordinateMean μ i f x) (Measure.pi (fun _ : ι => μ)) := + bounded_integrable (hf.mul hm) (fun x => by + rw [abs_mul] + exact mul_le_mul (hb x) (coordinateMean_bound μ i hb x) (abs_nonneg _) ((abs_nonneg _).trans (hb x))) + rw [← integral_update μ i hi] + apply integral_congr_ae + filter_upwards [] with x + simp only [coordinateMean_update, integral_mul_const] + simp only [coordinateMean, sq] + +theorem influenceSq_identity {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (i : ι) {f : (ι → α) → ℝ} {B : ℝ} + (hf : Measurable f) (hb : ∀ x, |f x| ≤ B) : + influenceSq μ i f = (∫ x, (f x)^2 ∂Measure.pi (fun _ : ι => μ)) - + ∫ x, (coordinateMean μ i f x)^2 ∂Measure.pi (fun _ : ι => μ) := by + have hm := coordinateMean_measurable μ i hf + have hmb := coordinateMean_bound μ i hb + have hf2 := bounded_sq_integrable (μ:=Measure.pi (fun _ : ι => μ)) hf hb + have hm2 := bounded_sq_integrable (μ:=Measure.pi (fun _ : ι => μ)) hm hmb + have hprod : Integrable (fun x => f x*coordinateMean μ i f x) (Measure.pi (fun _ : ι => μ)) := + bounded_integrable (hf.mul hm) (fun x => by + rw [abs_mul] + exact mul_le_mul (hb x) (hmb x) (abs_nonneg _) ((abs_nonneg _).trans (hb x))) + unfold influenceSq + have he (x : ι → α) : (f x-coordinateMean μ i f x)^2 = + (f x)^2 - 2*(f x*coordinateMean μ i f x) + (coordinateMean μ i f x)^2 := by ring + simp_rw [he] + have hi2 : Integrable (fun x => (f x)^2 - 2*(f x*coordinateMean μ i f x)) (Measure.pi (fun _ : ι => μ)) := hf2.sub (hprod.const_mul 2) + rw [integral_add hi2 hm2, + integral_sub hf2 (hprod.const_mul 2), integral_const_mul, + integral_mul_coordinateMean μ i hf hb] + ring + +lemma influenceSq_nonneg {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) (i : ι) (f : (ι → α) → ℝ) : 0 ≤ influenceSq μ i f := + integral_nonneg (fun _ => sq_nonneg _) + +lemma influenceSq_le {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (i : ι) {f : (ι → α) → ℝ} {B : ℝ} + (hf : Measurable f) (hb : ∀ x, |f x| ≤ B) : + influenceSq μ i f ≤ ∫ x, (f x)^2 ∂Measure.pi (fun _ : ι => μ) := by + rw [influenceSq_identity μ i hf hb] + have hn : 0 ≤ ∫ x : ι → α, (coordinateMean μ i f x)^2 ∂Measure.pi (fun _ : ι => μ) := + integral_nonneg (fun x => sq_nonneg _) + linarith + +lemma coordinateMean_sub {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (i : ι) {f g : (ι → α) → ℝ} {B C : ℝ} + (hf : Measurable f) (hg : Measurable g) (hb : ∀ x, |f x| ≤ B) (hc : ∀ x, |g x| ≤ C) + (x : ι → α) : coordinateMean μ i (f-g) x = coordinateMean μ i f x-coordinateMean μ i g x := by + apply integral_sub + · exact bounded_integrable (hf.comp (by fun_prop)) (fun t => hb _) + · exact bounded_integrable (hg.comp (by fun_prop)) (fun t => hc _) + +lemma influenceSq_of_independent {ι α : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (i : ι) {f g : (ι → α) → ℝ} {B C : ℝ} + (hf : Measurable f) (hg : Measurable g) (hb : ∀ x, |f x| ≤ B) (hc : ∀ x, |g x| ≤ C) + (hgind : ∀ x t, g (Function.update x i t) = g x) : + influenceSq μ i f ≤ ∫ x, (f x-g x)^2 ∂Measure.pi (fun _ : ι => μ) := by + have hgm (x : ι → α) : coordinateMean μ i g x = g x := by + simp [coordinateMean, hgind] + have hq : influenceSq μ i f = influenceSq μ i (f-g) := by + unfold influenceSq + apply integral_congr_ae + filter_upwards [] with x + rw [coordinateMean_sub μ i hf hg hb hc, hgm, Pi.sub_apply] + congr 1 + ring + rw [hq] + exact influenceSq_le μ i (hf.sub hg) + (fun x => (abs_sub _ _).trans (add_le_add (hb x) (hc x))) + +end LargeIndependentSets.ProductAveraging + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/DeletedLayerEquiv.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/DeletedLayerEquiv.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b6f684ebac01c9150696e43a55f5c3ab6a966ad --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/DeletedLayerEquiv.lean @@ -0,0 +1,53 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Small +import OAI.Combinatorics.IndependentSets.Reduction.SubchainView +import OAI.Combinatorics.IndependentSets.Reduction.ArbitraryRealJunta + +namespace OAI + +namespace LargeIndependentSets +open MeasureTheory ProductAveraging PhaseTest +open scoped BigOperators Classical NNReal + +def deletedLayerEquiv {n : ℕ} {B : Finset (Fin (n+1))} (i : B) : + {j : B // j ≠ i} ≃ (B.erase i.val) where + toFun j := ⟨j.val.val, Finset.mem_erase.mpr ⟨fun h => j.property (Subtype.ext h), j.val.property⟩⟩ + invFun j := ⟨⟨j.val, (Finset.mem_erase.mp j.property).2⟩, + fun h => (Finset.mem_erase.mp j.property).1 (congrArg Subtype.val h)⟩ + left_inv j := by cases j; rfl + right_inv j := by cases j; rfl + +def deletedCoordEquiv {L R : Type} {n : ℕ} {B : Finset (Fin (n+1))} (i : B) : + (Sigma fun j : {j : B // j ≠ i} => MixedTuple L R n j.val.val.val) ≃ + SubchainCoord L R n (B.erase i.val) where + toFun d := ⟨deletedLayerEquiv i d.1, d.2⟩ + invFun d := ⟨(deletedLayerEquiv i).symm d.1, d.2⟩ + left_inv d := by cases d; rfl + right_inv d := by cases d; rfl + +lemma deletion_nonempty {n : ℕ} {B : Finset (Fin (n+1))} (hB : 2 ≤ B.card) (i : B) : + (B.erase i.val).Nonempty := by + apply Finset.card_pos.mp + rw [Finset.card_erase_of_mem i.property] + omega + +lemma deletion_small {n s : ℕ} {B : Finset (Fin (n+1))} (hB : 2 ≤ B.card) (hBs : B.card ≤ s) + (i : B) : Small s (B.erase i.val) := + ⟨deletion_nonempty hB i, (Finset.card_le_card (Finset.erase_subset _ _)).trans hBs⟩ + +lemma junta_error_reindex {α β : Type} [Fintype α] [Fintype β] + [DecidableEq α] [DecidableEq β] (e : α ≃ β) (S : Finset β) + (f : (β → ℝ) → ℝ) (hf : Measurable f) : + (∫ θ, (f (reindex e θ) - + average rotationLaw (S.image e.symm) (f ∘ reindex e) θ)^2 + ∂Measure.pi (fun _ : α => rotationLaw)) = + ∫ θ, (f θ - average rotationLaw S f θ)^2 + ∂Measure.pi (fun _ : β => rotationLaw) := by + have hS : (S.image e.symm).image e = S := by simp [Finset.image_image] + simp_rw [average_reindex rotationLaw e _ hf, hS] + exact integral_preserving (reindex_preserving rotationLaw e) + ((hf.sub (average_measurable rotationLaw S hf)).pow_const 2).aestronglyMeasurable + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/EmbeddingLayerLaw.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/EmbeddingLayerLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..56015bc730b1dafe77eef01d777df54705813cae --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/EmbeddingLayerLaw.lean @@ -0,0 +1,99 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.SimplexLaw +import OAI.Combinatorics.IndependentSets.Geometry.RationalSimplexApproximation +import OAI.Combinatorics.IndependentSets.Reduction.Small + +namespace OAI + +namespace LargeIndependentSets +open scoped Classical BigOperators + +theorem rational_pattern_alignment (s d : ℕ) (η : ℝ) (hη : 0 < η) : + ∃ r ≥ s, ∃ p : (Fin s ↪o Fin r) → ℚ, ((∀ coordinate, 0 ≤ p coordinate) ∧ + ∑ coordinate, p coordinate = 1) ∧ + ∀ C : ListPattern s d (Fin r), + ∑ e, (p e : ℝ) * (if ¬GoodPatternOn (C.restrict e) Finset.univ then 1 else 0) ≤ η := by + obtain ⟨r, hr, q, hq, hqbound⟩ := real_pattern_alignment s d (η / 2) (half_pos hη) + have : Nonempty (Fin s ↪o Fin r) := ⟨Fin.castLEOrderEmb hr⟩ + obtain ⟨p, hp, happ⟩ := rational_simplex_approximation q hq (η / 2) (half_pos hη) + refine ⟨r, hr, p, hp, ?_⟩ + intro C + have ha := happ (fun e => if ¬GoodPatternOn (C.restrict e) Finset.univ then 1 else 0) + (fun e => by split_ifs <;> norm_num) + have hb := hqbound C + linarith + +noncomputable def embeddingLayerLaw {r s : ℕ} + (p : (Fin s ↪o Fin r) → ℚ) + (hp : (∀ coordinate, 0 ≤ p coordinate) ∧ ∑ coordinate, p coordinate = 1) : LayerLaw r s where + weight B := ∑ e, if B = Finset.univ.map e.toEmbedding then p e else 0 + nonneg B := Finset.sum_nonneg (fun e _ => by split_ifs; exact hp.1 e; rfl) + total := by + rw [Finset.sum_comm] + simpa using hp.2 + support B hB := by + apply Finset.sum_eq_zero + intro e _ + apply ite_eq_right + intro h + apply hB + rw [h] + simp + +lemma embeddingLayerLaw_badMass {r s : ℕ} {M : Type} + (p : (Fin s ↪o Fin r) → ℚ) + (hp : (∀ coordinate, 0 ≤ p coordinate) ∧ ∑ coordinate, p coordinate = 1) + (A : Finset (Fin r) → Finset M) : + (embeddingLayerLaw p hp).badMass A = + ∑ e, if Aligned A (Finset.univ.map e.toEmbedding) then 0 else p e := by + classical + unfold LayerLaw.badMass + change (∑ B, if Aligned A B then 0 else + ∑ e, if B = Finset.univ.map e.toEmbedding then p e else 0) = _ + have h (B : Finset (Fin r)) : + (if Aligned A B then 0 else ∑ e, if B = Finset.univ.map e.toEmbedding then p e else 0) = + ∑ e, if B = Finset.univ.map e.toEmbedding then + (if Aligned A (Finset.univ.map e.toEmbedding) then 0 else p e) else 0 := by + by_cases ha : Aligned A B + · rw [ite_eq_left ha] + symm + apply Finset.sum_eq_zero + intro e _ + by_cases he : B = Finset.univ.map e.toEmbedding + · simp [← he, ha] + · simp [he] + · rw [ite_eq_right ha] + apply Finset.sum_congr rfl + intro e _ + by_cases he : B = Finset.univ.map e.toEmbedding + · simp [← he, ha] + · simp [he] + simp_rw [h] + rw [Finset.sum_comm] + simp + +theorem distributional_alignment : DistributionalAlignment := by + classical + intro s d hs hd η hη + obtain ⟨r, hr, p, hp, hbound⟩ := rational_pattern_alignment s d η hη + refine ⟨r, hr, embeddingLayerLaw p hp, ?_⟩ + intro M _ A hcard hsep + rw [embeddingLayerLaw_badMass, Rat.cast_sum] + apply le_trans ?_ (hbound (actualPattern (d := d) A hsep)) + apply Finset.sum_le_sum + intro e _ + have hnonneg : (0 : ℝ) ≤ p e := by exact_mod_cast hp.1 e + by_cases hg : GoodPatternOn ((actualPattern (d := d) A hsep).restrict e) Finset.univ + · have hBcard : (Finset.univ.map e.toEmbedding).card = s := by simp + have hB : (Finset.univ.map e.toEmbedding).Nonempty := + Finset.card_pos.mp (by omega) + have ha : Aligned A (Finset.univ.map e.toEmbedding) := + actualPattern_good_aligned A hcard hsep _ hB hBcard.le + (good_embedding_restrict_goodOn _ e hg) + simp [ha, hg] + · simp only [hg, not_false_eq_true, ite_true, mul_one] + split_ifs <;> simp_all + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryAntipodes.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryAntipodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..32dc91032574f57236ed5dcc72201f50b7503200 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryAntipodes.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.GeometryDistance +import OAI.Combinatorics.IndependentSets.PCP.GeometryPointTable + +namespace OAI + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC ShortestPaths +open scoped Classical BigOperators ENNReal +noncomputable section + +variable (L R : Type) [Fintype L] [Fintype R] (n D : ℕ) [NeZero D] + +def antiPoint (s : StaticPoint L R n D) : StaticPoint L R n D := + ⟨s.1,fun k => s.2 k + ((D/2:ℕ):ZMod D)⟩ + +def antiName (t : Table L R) (i : Fin (size L R n D t)) : Fin (size L R n D t) := + nodeEquiv L R n D t.nu t.nv + (((nodeEquiv L R n D t.nu t.nv).symm i).1,antiPoint L R n D ((nodeEquiv L R n D t.nu t.nv).symm i).2) + +lemma antiName_exact (t : Table L R) (i : Fin (size L R n D t)) : + names L R n D t.nu t.nv (antiName L R n D t i)=gridAntipode (names L R n D t.nu t.nv i) := by + rw [names,antiName,Equiv.symm_apply_apply] + rfl + +def antiExpr (x : Expr) : Expr := + .add (.mul (Expr.quotient x (.const (staticCount L R n D))) (.const (staticCount L R n D))) + (pointLookup L R n D (fun a : StaticPoint L R n D => (pointEquiv L R n D (antiPoint L R n D a)).val) + (pointExpr L R n D x)) + +lemma antiExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (size L R n D t)) + (hi : x.eval t.bits a=i.val) : + (antiExpr L R n D x).eval t.bits a=(antiName L R n D t i).val := by + simp only [antiExpr,Expr.eval,Expr.quotient_eval,hi] + rw [pointLookup_eval L R n D _ _ _ _ ((nodeEquiv L R n D t.nu t.nv).symm i).2 + (pointExpr_code L R n D t x a i hi)] + have he : (finFunctionFinEquiv (((nodeEquiv L R n D t.nu t.nv).symm i).1.1)).val= + ((finProdFinEquiv.symm (finProdFinEquiv.symm i).1).1).val := by + change (finFunctionFinEquiv (finFunctionFinEquiv.symm _)).val = _ + rw [Equiv.apply_symm_apply] + rfl + have he' : (finFunctionFinEquiv (((nodeEquiv L R n D t.nu t.nv).symm i).1.2)).val= + ((finProdFinEquiv.symm (finProdFinEquiv.symm i).1).2).val := by + change (finFunctionFinEquiv (finFunctionFinEquiv.symm _)).val = _ + rw [Equiv.apply_symm_apply] + rfl + rw [antiName,nodeEquiv_val,he,he'] + simp only [finProdFinEquiv,Equiv.coe_fn_symm_mk,Fin.divNat,Fin.modNat] + have h := Nat.mod_add_div (i.val/staticCount L R n D) (t.nv^n) + rw [h] + ring + +def payloadApply (e x : Expr) : Expr := (fromTable e).subst (fun _ => x) + +lemma payloadApply_eval (t : Table L R) (e x : Expr) (a : ℕ → ℕ) : + (payloadApply e x).eval (distances L R n D t).bits a= + e.eval t.bits (fun _ => x.eval (distances L R n D t).bits a) := by + rw [payloadApply,Expr.subst_eval,fromTable_eval] + +def antiDistanceExpr (x : Expr) : Expr := payloadApply (antiExpr L R n D (.arg 0)) x + +lemma antiDistanceExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (size L R n D t)) + (hi : x.eval (distances L R n D t).bits a=i.val) : + (antiDistanceExpr L R n D x).eval (distances L R n D t).bits a=(antiName L R n D t i).val := by + rw [antiDistanceExpr,payloadApply_eval] + apply antiExpr_eval L R n D t (.arg 0) _ i + exact hi + +def cliqueExpr : Expr := .sum StoredFloyd.sizeExpr + (closeExpr D (.arg 0) (antiDistanceExpr L R n D (.arg 0))) + +lemma cliqueExpr_nonzero (p : SamplerParameters) (t : Table L R) (a : ℕ → ℕ) : + (cliqueExpr L R p.n (p.m*2^p.k)).eval (distances L R p.n (p.m*2^p.k) t).bits a≠0 ↔ p.CliqueTest t.lc := by + rw [cliqueExpr,Expr.sum_ne_zero,FloydCarry.sizeExpr_eval] + constructor + · rintro ⟨w,hw,h⟩ + let i : Fin (size L R p.n (p.m*2^p.k) t) := ⟨w,hw⟩ + have hi : Expr.eval (distances L R p.n (p.m*2^p.k) t).bits (Expr.bind a w) (.arg 0)=i.val := rfl + rw [closeExpr_nonzero L R p.n (p.m*2^p.k) t _ _ _ i + (antiName L R p.n (p.m*2^p.k) t i) hi + (antiDistanceExpr_eval L R p.n (p.m*2^p.k) t _ _ i hi),antiName_exact] at h + exact ⟨_,h⟩ + · rintro ⟨z,hz⟩ + obtain ⟨i,rfl⟩ := names_surjective L R p.n (p.m*2^p.k) t.nu t.nv t.hu t.hv z + refine ⟨i.val,i.isLt,?_⟩ + have hi : Expr.eval (distances L R p.n (p.m*2^p.k) t).bits (Expr.bind a i.val) (.arg 0)=i.val := rfl + rw [closeExpr_nonzero L R p.n (p.m*2^p.k) t _ _ _ i + (antiName L R p.n (p.m*2^p.k) t i) hi + (antiDistanceExpr_eval L R p.n (p.m*2^p.k) t _ _ i hi),antiName_exact] + exact hz + +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryDistance.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryDistance.lean new file mode 100644 index 0000000000000000000000000000000000000000..23f293de31bf74d5cec14b82380028e2a4a25ef3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryDistance.lean @@ -0,0 +1,110 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.IntegerEdgeTest +import OAI.Combinatorics.IndependentSets.Geometry.GeometryInitialize +import OAI.Combinatorics.IndependentSets.Machines.ExprDrop + +namespace OAI + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC ShortestPaths +open IndependentSetsGames.Foundations.Complexity Turing +open scoped Classical BigOperators ENNReal +noncomputable section + +variable (L R : Type) [Fintype L] [Fintype R] (n D : ℕ) [NeZero D] + +def distances (t : Table L R) := (input L R n D t).output + +noncomputable def distanceComputer : TM2ComputableInPolyTime Table.bits FloydCarry.State.bits (distances L R n D) := + MachineSequential.composeBits (f:=input L R n D) (g:=@FloydCarry.Input.output D) + (initializer L R n D) (FloydCarry.certificate D) +lemma distanceComputer_finiteAlphabet : MachineFiniteAlphabet.FiniteAlphabet (distanceComputer L R n D).tm := + MachineFiniteAlphabet.composeBits _ _ (initializer_finiteAlphabet L R n D) (FloydCarry.certificate_finiteAlphabet D) + +omit [NeZero D] in +lemma enat_eighth (c : ℕ∞) : 8*c≤(D:ℕ∞) ↔ c≤((D/8:ℕ):ℕ∞) := by + induction c using ENat.recTopCoe with + | top => simp + | coe c => + have hh : (8:ℕ∞)*(c:ℕ∞)=((8*c:ℕ):ℕ∞) := by norm_cast + rw [hh,ENat.natCast_le_natCast,ENat.natCast_le_natCast] + omega + +lemma distance_threshold (t : Table L R) (i j : Fin (size L R n D t)) : + ((distances L R n D t).core.matrix.get i j).val≤D/8 ↔ + pathDistance (layeredSystem t.lc n).linkLength + (names L R n D t.nu t.nv i) (names L R n D t.nu t.nv j)≤ENNReal.ofReal (1/8) := by + change (((Capped.Matrix.ofInteger D (integerMatrix L R n D t)).allPairs).get i j).val≤D/8 ↔ _ + rw [Capped.Matrix.threshold_exact D _ i j (Nat.div_le_self _ _)] + rw [← cover_allPairs_exact (layeredSystem t.lc n) (names L R n D t.nu t.nv) + (names_surjective L R n D t.nu t.nv t.hu t.hv) i j,integer_edge_test] + exact (enat_eighth D _).symm + +abbrev prefixCount (t : Table L R) := 3+size L R n D t*size L R n D t + +def payloadOffsetExpr : Expr := + .sum (.add (.const 3) (.mul StoredFloyd.sizeExpr StoredFloyd.sizeExpr)) + (.add (Expr.word (.arg 0)) (.const 1)) + +def fromTable (e : Expr) : Expr := Expr.dropInput payloadOffsetExpr e + +lemma distances_suffix (t : Table L R) : + (distances L R n D t).bits = + UnaryTables.words (distances L R n D t).value (prefixCount L R n D t) ++ t.bits := by + have hc : (distances L R n D t).count=prefixCount L R n D t+(3+3*t.ne) := by + simp [distances,FloydCarry.Input.output,FloydCarry.State.count,StoredFloyd.Input.output,input,prefixCount] + rw [FloydCarry.State.bits,hc,UnaryTables.words_add] + congr 1 + apply UnaryTables.words_congr + intro w hw + have hprefix : (distances L R n D t).core.n=size L R n D t := rfl + simp only [FloydCarry.State.value,hprefix] + have hn : ¬prefixCount L R n D t+w<2+size L R n D t*size L R n D t := by unfold prefixCount; omega + have he : prefixCount L R n D t+w≠2+size L R n D t*size L R n D t := by unfold prefixCount; omega + rw [ite_eq_right hn,ite_eq_right he] + have hs : prefixCount L R n D t+w-(3+size L R n D t*size L R n D t)=w := by unfold prefixCount; omega + rw [hs] + exact payload_get L R n D t w hw + +lemma payloadOffsetExpr_eval (t : Table L R) (a : ℕ → ℕ) : + payloadOffsetExpr.eval (distances L R n D t).bits a= + (UnaryTables.words (distances L R n D t).value (prefixCount L R n D t)).length := by + simp only [payloadOffsetExpr,Expr.eval,FloydCarry.sizeExpr_eval,UnaryTables.words_length,UnaryTables.offset] + apply Finset.sum_congr rfl + intro w hw + rw [Expr.word_eval,Expr.eval] + rw [FloydCarry.State.bits,UnaryTables.wordValue_words] + · rfl + · change w < 3+(size L R n D t)*(size L R n D t)+(input L R n D t).payload.length + exact lt_of_lt_of_le (Finset.mem_range.mp hw) (Nat.le_add_right _ _) + +lemma fromTable_eval (e : Expr) (t : Table L R) (a : ℕ → ℕ) : + (fromTable e).eval (distances L R n D t).bits a=e.eval t.bits a := by + rw [fromTable,Expr.dropInput_eval,payloadOffsetExpr_eval,distances_suffix,List.drop_left] + +lemma cellExpr_eval (t : Table L R) (i j : Expr) (a : ℕ → ℕ) + (x y : Fin (size L R n D t)) + (hi : i.eval (distances L R n D t).bits a=x.val) + (hj : j.eval (distances L R n D t).bits a=y.val) : + (StoredFloyd.cellExpr i j).eval (distances L R n D t).bits a= + ((distances L R n D t).core.matrix.get x y).val := by + rw [StoredFloyd.cellExpr_eval,hi,hj,FloydCarry.sizeExpr_eval] + exact FloydCarry.read_cell (distances L R n D t) x y + +def closeExpr (i j : Expr) : Expr := Expr.le (StoredFloyd.cellExpr i j) (.const (D/8)) + +lemma closeExpr_nonzero (t : Table L R) (i j : Expr) (a : ℕ → ℕ) + (x y : Fin (size L R n D t)) + (hi : i.eval (distances L R n D t).bits a=x.val) + (hj : j.eval (distances L R n D t).bits a=y.val) : + (closeExpr D i j).eval (distances L R n D t).bits a≠0 ↔ + pathDistance (layeredSystem t.lc n).linkLength (names L R n D t.nu t.nv x) + (names L R n D t.nu t.nv y)≤ENNReal.ofReal (1/8) := by + rw [closeExpr,Expr.le_eval,cellExpr_eval L R n D t i j a x y hi hj,Expr.eval] + rw [← distance_threshold L R n D t x y] + split_ifs <;> simp_all + +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryInitialize.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryInitialize.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed7715dda42a86c92cf5b466549ef07927c88e23 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryInitialize.lean @@ -0,0 +1,125 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.GeometryLink +import OAI.Combinatorics.IndependentSets.Reduction.FloydLoop + +namespace OAI + +namespace IndependentSetsCut.CounterMachine.UnaryTables +lemma words_cons (f : ℕ → ℕ) (n : ℕ) : + words f (n+1)=IndependentSetsGames.Foundations.Complexity.encodeWord (f 0) ++ words (fun w => f (w+1)) n := by + simp [words,List.range_succ_eq_map,List.map_map,IndependentSetsGames.Foundations.Complexity.encodeWord,Function.comp_def] +end IndependentSetsCut.CounterMachine.UnaryTables + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC ShortestPaths +open IndependentSetsGames.Foundations.Complexity Turing +open scoped Classical BigOperators ENNReal +noncomputable section + +variable (L R : Type) [Fintype L] [Fintype R] (n D : ℕ) [NeZero D] + +def integerMatrix (t : Table L R) : ShortestPaths.Matrix (size L R n D t) := + Vector.ofFn (fun i => Vector.ofFn (fun j => + linkCost (layeredSystem t.lc n) (names L R n D t.nu t.nv i) (names L R n D t.nu t.nv j))) + +def input (t : Table L R) : FloydCarry.Input D := + ⟨⟨size L R n D t,Capped.Matrix.ofInteger D (integerMatrix L R n D t)⟩, + (List.range (3+3*t.ne)).map t.value⟩ + +lemma payload_length (t : Table L R) : (input L R n D t).payload.length=3+3*t.ne := by simp [input] +lemma payload_get (t : Table L R) (w : ℕ) (hw : w<3+3*t.ne) : + (input L R n D t).payload[w]?.getD 0=t.value w := by simp [input,hw] + +abbrev inputCount (t : Table L R) := 4+(size L R n D t)*(size L R n D t)+(3+3*t.ne) +def inputValue (t : Table L R) (w : ℕ) : ℕ := + if w=0 then size L R n D t else (input L R n D t).initial.value (w-1) + +lemma input_bits (t : Table L R) : + FloydCarry.Input.bits (input L R n D t)=UnaryTables.words (inputValue L R n D t) (inputCount L R n D t) := by + have hc : inputCount L R n D t=(input L R n D t).initial.count+1 := by + simp [inputCount,FloydCarry.State.count,FloydCarry.Input.initial,StoredFloyd.Input.initial,input]; omega + rw [hc,UnaryTables.words_cons] + simp only [inputValue,↓reduceIte,Nat.add_eq_zero_iff,one_ne_zero,and_false,Nat.add_sub_cancel] + rfl + +def inputCountExpr : Expr := .add (.add (.const 4) (.mul (sizeExpr L R n D) (sizeExpr L R n D))) + (.add (.const 3) (.mul (.const 3) neExpr)) + +def inputValueExpr : Expr := + Expr.cond (Expr.lt (.arg 0) (.const 2)) (sizeExpr L R n D) + (Expr.cond (Expr.equal (.arg 0) (.const 2)) (.const 0) + (Expr.cond (Expr.lt (.arg 0) (.add (.const 3) (.mul (sizeExpr L R n D) (sizeExpr L R n D)))) + (costExpr L R n D (Expr.quotient (.sub (.arg 0) (.const 3)) (sizeExpr L R n D)) + (Expr.remainder (.sub (.arg 0) (.const 3)) (sizeExpr L R n D))) + (Expr.cond (Expr.equal (.arg 0) (.add (.const 3) (.mul (sizeExpr L R n D) (sizeExpr L R n D)))) + (.add (.const 3) (.mul (.const 3) neExpr)) + (Expr.word (.sub (.arg 0) (.add (.const 4) (.mul (sizeExpr L R n D) (sizeExpr L R n D)))))))) + +@[simp] lemma inputCountExpr_eval (t : Table L R) (a : ℕ → ℕ) : + (inputCountExpr L R n D).eval t.bits a=inputCount L R n D t := by + simp [inputCountExpr,Expr.eval,inputCount] + +lemma inputValueExpr_eval (t : Table L R) (w : ℕ) (hw : w < inputCount L R n D t) : + (inputValueExpr L R n D).eval t.bits (fun _ => w)=inputValue L R n D t w := by + let N := size L R n D t + have hN : 0 simp_all + simp only [inputValueExpr,Expr.cond_eval,Expr.lt_eval,Expr.equal_eval,Expr.eval,sizeExpr_eval,neExpr_eval,indicator] + have hsize : N=size L R n D t := rfl + simp only [← hsize] + by_cases hsmall : w<2 + · have hw' : w=0 ∨ w=1 := by omega + rcases hw' with rfl | rfl <;> + simp [inputValue,FloydCarry.State.value,StoredFloyd.State.value,hc,N] + · simp only [hsmall,ite_false,ne_eq,not_true_eq_false] + by_cases hw2 : w=2 + · subst w + simp [inputValue,FloydCarry.State.value,StoredFloyd.State.value,hc,hk,N,show (1:ℕ)<2+N*N by omega] + · have hw3 : 3≤w := by omega + simp only [hw2,ite_false,not_true_eq_false] + by_cases hmat : w<3+N*N + · have hi : (w-3)/N w)=i.val := by + simp [Expr.quotient_eval,Expr.eval,i,N] + have hej : (Expr.remainder (.sub (.arg 0) (.const 3)) (sizeExpr L R n D)).eval t.bits (fun _ => w)=j.val := by + simp [Expr.remainder_eval,Expr.eval,j,N] + simp only [hmat,ite_true] + rw [costExpr_eval L R n D t _ _ _ i j hei hej] + simp [inputValue,FloydCarry.State.value,show w≠0 by omega, + show w-1<2+N*N by omega,StoredFloyd.State.value,show w-1≠0 by omega, + show w-1≠1 by omega,show w-1-2=w-3 by omega, + input,FloydCarry.Input.initial,StoredFloyd.Input.initial,StoredFloyd.entry,hi,hj, + Capped.Matrix.ofInteger,Capped.Matrix.get,integerMatrix,ShortestPaths.Matrix.get,i,j,N] + · simp only [hmat,ite_false] + by_cases hend : w=3+N*N + · simp only [hend,ite_true] + simp [inputValue,FloydCarry.State.value,hc,hp,payload_length,N] + · simp only [hend,ite_false,Expr.word_eval,Expr.eval,sizeExpr_eval] + have hoff : w-(4+N*N)<3+3*t.ne := by change w < 4+N*N+(3+3*t.ne) at hw; omega + rw [Table.bits,UnaryTables.wordValue_words _ _ _ hoff] + simp [inputValue,FloydCarry.State.value,hc,hp,show w≠0 by omega, + show ¬w-1<2+N*N by omega,show w-1≠2+N*N by omega, + show w-1-(3+N*N)=w-(4+N*N) by omega,payload_get L R n D t _ hoff,N] + +lemma input_spec (t : Table L R) : + UnaryTables.words (fun w => (inputValueExpr L R n D).eval t.bits (fun _ => w)) + ((inputCountExpr L R n D).eval t.bits (fun _ => 0))=FloydCarry.Input.bits (input L R n D t) := by + rw [inputCountExpr_eval,input_bits] + exact UnaryTables.words_congr (inputValueExpr_eval L R n D t) + +noncomputable def initializer : TM2ComputableInPolyTime Table.bits FloydCarry.Input.bits (input L R n D) := + UnaryTables.encodedComputer _ _ _ (inputCountExpr L R n D) (inputValueExpr L R n D) (input_spec L R n D) +lemma initializer_finiteAlphabet : MachineFiniteAlphabet.FiniteAlphabet (initializer L R n D).tm := + UnaryTables.encodedComputer_finiteAlphabet _ _ _ _ _ _ + +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryLink.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryLink.lean new file mode 100644 index 0000000000000000000000000000000000000000..26bcd2866f520caf397b807a4a438503dbdc79f0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryLink.lean @@ -0,0 +1,199 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.ExprTables +import OAI.Combinatorics.IndependentSets.Encoding.GeometryExpr + +namespace OAI + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC ShortestPaths +open scoped Classical BigOperators +noncomputable section + +variable (L R : Type) [Fintype L] [Fintype R] (n D : ℕ) [NeZero D] + +def pointCost (a b : StaticPoint L R n D) : ℕ := + (Capped.clip D (copyCost (decode (fun _ => ()) (fun _ => ()) a) + (decode (fun _ => ()) (fun _ => ()) b))).val + +omit [NeZero D] in +lemma copyCost_same {U V : Type} [DecidableEq U] [DecidableEq V] + (u u' : Fin n → U) (v v' : Fin n → V) (a b : StaticPoint L R n D) : + (Capped.clip D (copyCost (decode u v a) (decode u' v' b))).val = + if sameQuestion L R n D u u' v v' a b then pointCost L R n D a b else D+1 := by + by_cases hq : sameQuestion L R n D u u' v v' a b + · rw [ite_eq_left hq] + have hh := (sameQuestion_iff L R n D u u' v v' a b).mp hq + rcases a with ⟨i,a⟩ + rcases b with ⟨j,b⟩ + have hij : i=j := congrArg (fun w => w.1) hh + subst j + have hq' : mixed u v i.val=mixed u' v' i.val := + eq_of_heq (Sigma.mk.inj_iff.mp hh).2 + have hcopy (q q' : MixedTuple U V n i.val) (he : q=q') : + copyCost (M:=LayerAnswer L R) (⟨⟨i,q⟩,a⟩ : GridLocation _ D) ⟨⟨i,q'⟩,b⟩ = + (Finset.univ.sup (fun k => circleCost (a k) (b k)) : ℕ) := by + subst q' + simp [copyCost] + rw [show copyCost (decode u v ⟨i,a⟩) (decode u' v' ⟨i,b⟩)= + (Finset.univ.sup (fun k => circleCost (a k) (b k)) : ℕ) from hcopy _ _ hq'] + simp [pointCost,copyCost,decode] + rfl + · have hh := (sameQuestion_iff L R n D u u' v v' a b).not.mp hq + simp [hq,copyCost,hh] + +def questionExpr (x y c : Expr) (h : Fin n) : Expr := + .mul (Expr.equal (uExpr L R n D x h) (fieldExpr c 0)) + (.mul (Expr.equal (vExpr L R n D y h) (fieldExpr c 1)) + (Expr.listAll (List.finRange n) (fun k => if k=h then .const 1 else + if k.val simp_all + simp only [↓reduceIte,Nat.one_ne_zero,mul_ne_zero_iff,indicator,Fin.val_inj] + unfold QuestionStep Table.lc + apply and_congr_right + intro _ + apply and_congr_right + intro _ + simp only [List.mem_finRange,forall_true_left] + apply forall_congr' + intro k + by_cases hk : k=h + · simp [hk,Expr.eval] + · by_cases hl : k.val simp [hk,hl,Expr.equal_eval, + uExpr_eval L R n D t x a i hi,uExpr_eval L R n D t y a j hj, + vExpr_eval L R n D t x a i hi,vExpr_eval L R n D t y a j hj,Fin.val_inj] + +def pointStepExpr (x y c : Expr) (h : Fin n) : Expr := + Expr.static3 (fun (a b : StaticPoint L R n D) (f : L → R) => if PointStep h f a b then 1 else 0) + (pointExpr L R n D x) (pointExpr L R n D y) (fieldExpr c 2) + +lemma pointStepExpr_eval (t : Table L R) (x y c : Expr) (a : ℕ → ℕ) + (i j : Fin (size L R n D t)) (e : Fin t.ne) + (hi : x.eval t.bits a=i.val) (hj : y.eval t.bits a=j.val) (he : c.eval t.bits a=e.val) (h : Fin n) : + (pointStepExpr L R n D x y c h).eval t.bits a = + if PointStep h (t.project e) ((nodeEquiv L R n D t.nu t.nv).symm i).2 + ((nodeEquiv L R n D t.nu t.nv).symm j).2 then 1 else 0 := by + apply Expr.static3_eval + · exact pointExpr_eval L R n D t x a i hi + · exact pointExpr_eval L R n D t y a j hj + · exact fieldExpr_eval t a c e he ⟨2,by omega⟩ + +def forwardExpr (x y : Expr) : Expr := + .sum neExpr (Expr.listSum (List.finRange n) (fun h => + .mul (pointStepExpr L R n D (x.rename Nat.succ) (y.rename Nat.succ) (.arg 0) h) + (questionExpr L R n D (x.rename Nat.succ) (y.rename Nat.succ) (.arg 0) h))) + +lemma forwardExpr_nonzero (t : Table L R) (x y : Expr) (a : ℕ → ℕ) + (i j : Fin (size L R n D t)) (hi : x.eval t.bits a=i.val) (hj : y.eval t.bits a=j.val) : + (forwardExpr L R n D x y).eval t.bits a≠0 ↔ + (layeredSystem t.lc n).ForwardZero D (names L R n D t.nu t.nv i) (names L R n D t.nu t.nv j) := by + dsimp only [names,nodeDecode] + rw [forward_iff] + change _ ↔ ∃ h e, PointStep h (t.project e) ((nodeEquiv L R n D t.nu t.nv).symm i).2 + ((nodeEquiv L R n D t.nu t.nv).symm j).2 ∧ QuestionStep t.lc h e _ _ _ _ + simp only [forwardExpr,Expr.sum_ne_zero,neExpr_eval,Expr.listSum_ne_zero,List.mem_finRange,true_and] + have each (c : ℕ) (hc : c simp_all + constructor + · rintro ⟨c,hc,h,hh⟩; exact ⟨h,⟨c,hc⟩,(each c hc h).mp hh⟩ + · rintro ⟨h,e,hh⟩; exact ⟨e.val,e.isLt,h,(each e.val e.isLt h).mpr hh⟩ + +def levelExpr (x : Expr) : Expr := + Expr.staticLookup (fun a : StaticPoint L R n D => a.1.val) (pointExpr L R n D x) + +lemma levelExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (size L R n D t)) + (hi : x.eval t.bits a=i.val) : + (levelExpr L R n D x).eval t.bits a=((nodeEquiv L R n D t.nu t.nv).symm i).2.1.val := by + exact Expr.staticLookup_eval _ _ _ _ _ (pointExpr_eval L R n D t x a i hi) + +def sameQuestionExpr (x y : Expr) : Expr := + .mul (Expr.equal (levelExpr L R n D x) (levelExpr L R n D y)) + (Expr.listAll (List.finRange n) (fun k => + Expr.cond (Expr.lt (.const k.val) (levelExpr L R n D x)) + (Expr.equal (vExpr L R n D x k) (vExpr L R n D y k)) + (Expr.equal (uExpr L R n D x k) (uExpr L R n D y k)))) + +lemma sameQuestionExpr_nonzero (t : Table L R) (x y : Expr) (a : ℕ → ℕ) + (i j : Fin (size L R n D t)) (hi : x.eval t.bits a=i.val) (hj : y.eval t.bits a=j.val) : + (sameQuestionExpr L R n D x y).eval t.bits a≠0 ↔ + sameQuestion L R n D ((nodeEquiv L R n D t.nu t.nv).symm i).1.1 + ((nodeEquiv L R n D t.nu t.nv).symm j).1.1 + ((nodeEquiv L R n D t.nu t.nv).symm i).1.2 + ((nodeEquiv L R n D t.nu t.nv).symm j).1.2 + ((nodeEquiv L R n D t.nu t.nv).symm i).2 + ((nodeEquiv L R n D t.nu t.nv).symm j).2 := by + have indicator (P : Prop) [Decidable P] : (if P then (1:ℕ) else 0)≠0 ↔ P := by + split_ifs <;> simp_all + simp only [sameQuestionExpr,Expr.eval,mul_ne_zero_iff,Expr.equal_eval,Expr.listAll_eval, + levelExpr_eval L R n D t x a i hi,levelExpr_eval L R n D t y a j hj, + indicator,Fin.val_inj,List.mem_finRange,forall_true_left,sameQuestion] + apply and_congr_right + intro _ + apply forall_congr' + intro k + simp only [Expr.cond_eval,Expr.lt_eval,Expr.eval,levelExpr_eval L R n D t x a i hi, + indicator,Expr.equal_eval,vExpr_eval L R n D t x a i hi,vExpr_eval L R n D t y a j hj, + uExpr_eval L R n D t x a i hi,uExpr_eval L R n D t y a j hj] + split_ifs <;> simp_all [Fin.val_inj] + +def copyCostExpr (x y : Expr) : Expr := + Expr.cond (sameQuestionExpr L R n D x y) + (Expr.static2 (pointCost L R n D) (pointExpr L R n D x) (pointExpr L R n D y)) + (.const (D+1)) + +lemma copyCostExpr_eval (t : Table L R) (x y : Expr) (a : ℕ → ℕ) + (i j : Fin (size L R n D t)) (hi : x.eval t.bits a=i.val) (hj : y.eval t.bits a=j.val) : + (copyCostExpr L R n D x y).eval t.bits a= + (Capped.clip D (copyCost (names L R n D t.nu t.nv i) (names L R n D t.nu t.nv j))).val := by + dsimp only [names,nodeDecode] + rw [copyCost_same] + simp only [copyCostExpr,Expr.cond_eval,sameQuestionExpr_nonzero L R n D t x y a i j hi hj, + Expr.static2_eval _ _ _ _ _ _ _ (pointExpr_eval L R n D t x a i hi) + (pointExpr_eval L R n D t y a j hj),Expr.eval] + +def costExpr (x y : Expr) : Expr := + Expr.cond (.add (forwardExpr L R n D x y) (forwardExpr L R n D y x)) + (.const 0) (copyCostExpr L R n D x y) + +lemma costExpr_eval (t : Table L R) (x y : Expr) (a : ℕ → ℕ) + (i j : Fin (size L R n D t)) (hi : x.eval t.bits a=i.val) (hj : y.eval t.bits a=j.val) : + (costExpr L R n D x y).eval t.bits a= + (Capped.clip D (linkCost (layeredSystem t.lc n) + (names L R n D t.nu t.nv i) (names L R n D t.nu t.nv j))).val := by + have add_ne (a b : ℕ) : a+b≠0 ↔ a≠0 ∨ b≠0 := by omega + simp only [costExpr,Expr.cond_eval,Expr.eval,add_ne, + forwardExpr_nonzero L R n D t x y a i j hi hj, + forwardExpr_nonzero L R n D t y x a j i hj hi, + copyCostExpr_eval L R n D t x y a i j hi hj,linkCost,ProjectionSystem.ZeroLink] + split_ifs <;> simp_all [Capped.clip] + +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryLocations.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryLocations.lean new file mode 100644 index 0000000000000000000000000000000000000000..79e81b72bc64554f7a4aa78a5fb24bef2289e260 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryLocations.lean @@ -0,0 +1,164 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.Witness +import OAI.Combinatorics.IndependentSets.Machines.ExprTables +import OAI.Combinatorics.IndependentSets.PCP.GeometryPointTable + +namespace OAI + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC PhaseTest Coefficient +open scoped Classical BigOperators +noncomputable section +attribute [-instance] mixedTupleComputableFintype mixedTupleDecidableEq + +variable (L R : Type) [Fintype L] [Fintype R] (p : SamplerParameters) + +abbrev Outcome := (p.law L R).Expanded +abbrev outcomeCount := Fintype.card (Outcome L R p) +abbrev vertexCount (t : Table L R) := t.ne^p.n*outcomeCount L R p + +lemma vertexCount_pos (t : Table L R) : 0 (),fun _ => (),f⟩ + +def samplePoint (f : Fin p.n → L → R) (o : Outcome L R p) : StaticPoint L R p.n (p.m*2^p.k) := + ⟨(p.location (scheduleLC L R p f) (id,o)).1.1, + (p.location (scheduleLC L R p f) (id,o)).2⟩ + +lemma samplePoint_decode (t : Table L R) (v : p.Vertices L R (Fin t.ne)) : + decode (fun k => t.left (v.1 k)) (fun k => t.right (v.1 k)) + (samplePoint L R p (fun k => t.project (v.1 k)) v.2)=p.location t.lc v := by + rfl + +def locationName (t : Table L R) (v : p.Vertices L R (Fin t.ne)) : Fin (size L R p.n (p.m*2^p.k) t) := + nodeEquiv L R p.n (p.m*2^p.k) t.nu t.nv + ((fun k => t.left (v.1 k),fun k => t.right (v.1 k)), + samplePoint L R p (fun k => t.project (v.1 k)) v.2) + +lemma locationName_exact (t : Table L R) (v : p.Vertices L R (Fin t.ne)) : + names L R p.n (p.m*2^p.k) t.nu t.nv (locationName L R p t v)=p.location t.lc v := by + rw [names,locationName,Equiv.symm_apply_apply] + exact samplePoint_decode L R p t v + +def vertexCountExpr : Expr := .mul (Expr.power neExpr p.n) (.const (outcomeCount L R p)) +def outcomeExpr (x : Expr) : Expr := Expr.remainder x (.const (outcomeCount L R p)) +def chainExpr (x : Expr) (k : Fin p.n) : Expr := + Expr.remainder (Expr.quotient (Expr.quotient x (.const (outcomeCount L R p))) + (Expr.power neExpr k.val)) neExpr + +@[simp] lemma vertexCountExpr_eval (t : Table L R) (a : ℕ → ℕ) : + (vertexCountExpr L R p).eval t.bits a=vertexCount L R p t := by + simp [vertexCountExpr,Expr.eval,vertexCount] + +lemma chainExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (vertexCount L R p t)) + (hi : x.eval t.bits a=i.val) (k : Fin p.n) : + (chainExpr L R p x k).eval t.bits a=(((vertexEquiv L R p t).symm i).1 k).val := by + simp only [chainExpr,Expr.remainder_eval,Expr.quotient_eval,Expr.power_eval,neExpr_eval,Expr.eval,hi] + rfl + +lemma outcomeExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (vertexCount L R p t)) + (hi : x.eval t.bits a=i.val) : + (outcomeExpr L R p x).eval t.bits a= + (Fintype.equivFin (Outcome L R p) ((vertexEquiv L R p t).symm i).2).val := by + simp only [outcomeExpr,Expr.remainder_eval,Expr.eval,hi] + change _=(Fintype.equivFin _ ((Fintype.equivFin _).symm _)).val + rw [Equiv.apply_symm_apply] + rfl + +def scheduleTest (x : Expr) (f : Fin p.n → L → R) : Expr := + Expr.listAll (List.finRange p.n) fun k => + Expr.equal (fieldExpr (chainExpr L R p x k) 2) (.const (projectCode (f k))) + +lemma scheduleTest_nonzero (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (vertexCount L R p t)) + (hi : x.eval t.bits a=i.val) (f : Fin p.n → L → R) : + (scheduleTest L R p x f).eval t.bits a≠0 ↔ + f=fun k => t.project (((vertexEquiv L R p t).symm i).1 k) := by + have hh (k : Fin p.n) : (fieldExpr (chainExpr L R p x k) 2).eval t.bits a= + projectCode (t.project (((vertexEquiv L R p t).symm i).1 k)) := by + simpa using fieldExpr_eval t a (chainExpr L R p x k) + (((vertexEquiv L R p t).symm i).1 k) (chainExpr_eval L R p t x a i hi k) (2:Fin 3) + simp only [scheduleTest,Expr.listAll_eval,List.mem_finRange,forall_true_left] + split_ifs with h + · simp only [ne_eq,one_ne_zero,not_false_eq_true,true_iff] + funext k + have hk := h k + rw [Expr.equal_eval,hh,Expr.eval] at hk + have hc : projectCode (t.project (((vertexEquiv L R p t).symm i).1 k))=projectCode (f k) := by + split_ifs at hk with he + · exact he + · exact False.elim (hk rfl) + exact ((Fintype.equivFin (L → R)).injective (Fin.ext hc)).symm + · simp only [ne_eq,not_true_eq_false,false_iff] + intro he + apply h + intro k + rw [Expr.equal_eval,hh,Expr.eval,he] + simp + +def scheduleCodeExpr (x : Expr) : Expr := + Expr.pick (fun f : Fin p.n → L → R => (Fintype.equivFin _ f).val) (scheduleTest L R p x) + +lemma scheduleCodeExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (vertexCount L R p t)) + (hi : x.eval t.bits a=i.val) : + (scheduleCodeExpr L R p x).eval t.bits a= + (Fintype.equivFin (Fin p.n → L → R) (fun k => t.project (((vertexEquiv L R p t).symm i).1 k))).val := by + apply Expr.pick_eval + exact scheduleTest_nonzero L R p t x a i hi + +def samplePointExpr (x : Expr) : Expr := + Expr.static2 (fun f o => (pointEquiv L R p.n (p.m*2^p.k) (samplePoint L R p f o)).val) + (scheduleCodeExpr L R p x) (outcomeExpr L R p x) + +lemma samplePointExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (vertexCount L R p t)) + (hi : x.eval t.bits a=i.val) : + (samplePointExpr L R p x).eval t.bits a= + (pointEquiv L R p.n (p.m*2^p.k) (samplePoint L R p + (fun k => t.project (((vertexEquiv L R p t).symm i).1 k)) ((vertexEquiv L R p t).symm i).2)).val := by + apply Expr.static2_eval + · exact scheduleCodeExpr_eval L R p t x a i hi + · exact outcomeExpr_eval L R p t x a i hi + +def tupleCodeExpr (base : Expr) (f : Fin p.n → Expr) : Expr := + Expr.listSum (List.finRange p.n) (fun k => .mul (f k) (Expr.power base k.val)) + +lemma tupleCodeExpr_eval (s : List Bool) (a : ℕ → ℕ) (base : Expr) (f : Fin p.n → Expr) + {m : ℕ} (v : Fin p.n → Fin m) (hb : base.eval s a=m) (hf : ∀ k, (f k).eval s a=(v k).val) : + (tupleCodeExpr p base f).eval s a=(finFunctionFinEquiv v).val := by + simp only [tupleCodeExpr,Expr.listSum_eval,Expr.eval,Expr.power_eval,hb,hf,finFunctionFinEquiv_apply] + rw [← List.ofFn_eq_map,List.sum_ofFn] + +def locationExpr (x : Expr) : Expr := + .add (.mul (.add (.mul (tupleCodeExpr p nuExpr (fun k => fieldExpr (chainExpr L R p x k) 0)) + (Expr.power nvExpr p.n)) + (tupleCodeExpr p nvExpr (fun k => fieldExpr (chainExpr L R p x k) 1))) + (.const (staticCount L R p.n (p.m*2^p.k)))) (samplePointExpr L R p x) + +lemma locationExpr_eval (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (vertexCount L R p t)) + (hi : x.eval t.bits a=i.val) : + (locationExpr L R p x).eval t.bits a= + (locationName L R p t ((vertexEquiv L R p t).symm i)).val := by + have hf (k : Fin p.n) (j : Fin 3) := fieldExpr_eval t a (chainExpr L R p x k) + (((vertexEquiv L R p t).symm i).1 k) (chainExpr_eval L R p t x a i hi k) j + have hu : ∀ k, (fieldExpr (chainExpr L R p x k) 0).eval t.bits a= + (t.left (((vertexEquiv L R p t).symm i).1 k)).val := by + intro k; simpa using hf k 0 + have hv : ∀ k, (fieldExpr (chainExpr L R p x k) 1).eval t.bits a= + (t.right (((vertexEquiv L R p t).symm i).1 k)).val := by + intro k; simpa using hf k 1 + simp only [locationExpr,Expr.eval,Expr.power_eval,nvExpr_eval, + tupleCodeExpr_eval p _ _ _ _ _ (nuExpr_eval t a) hu, + tupleCodeExpr_eval p _ _ _ _ _ (nvExpr_eval t a) hv,samplePointExpr_eval L R p t x a i hi] + rw [locationName,nodeEquiv_val] + ring + +attribute [instance 1100] mixedTupleComputableFintype +attribute [instance] mixedTupleDecidableEq +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryNaming.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryNaming.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9dc2ba11bc60f852ac51d705da54b81742558d1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryNaming.lean @@ -0,0 +1,177 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.CircleCost + +namespace OAI + +noncomputable section + +namespace LargeIndependentSets.ShortestPaths + +open scoped ENNReal + +lemma pathDistance_surjective {X Y : Type*} (e : X → Y) (he : Function.Surjective e) + (w : Y → Y → ℝ≥0∞) (x y : X) : + pathDistance (fun a b => w (e a) (e b)) x y = pathDistance w (e x) (e y) := by + unfold pathDistance + apply le_antisymm + · apply le_iInf + intro zs + obtain ⟨ws,hws⟩ := List.map_surjective_iff.mpr he zs + apply iInf_le_of_le ws + rw [walkLength_reindex,hws] + · apply le_iInf + intro zs + rw [walkLength_reindex] + exact iInf_le_of_le (zs.map e) le_rfl + +theorem cover_allPairs_exact {Q : Type*} [DecidableEq Q] {M : Q → Type*} + [∀ q, Fintype (M q)] [∀ q, DecidableEq (M q)] + (S : ProjectionSystem Q M) [∀ q q' π, Decidable (S.imposed q q' π)] + {D : ℕ} [NeZero D] {n : ℕ} (e : Fin n → GridLocation M D) + (he : Function.Surjective e) (i j : Fin n) : + let a : Matrix n := Vector.ofFn (fun x => Vector.ofFn (fun y => linkCost S (e x) (e y))) + (a.allPairs.get i j : ℝ≥0∞)/(D : ℝ≥0∞) = pathDistance S.linkLength (e i) (e j) := by + dsimp only + rw [Matrix.scaled_allPairs_exact] + have hh : (fun x y : Fin n => + ((Matrix.get (Vector.ofFn (fun x => Vector.ofFn (fun y => linkCost S (e x) (e y)))) x y : ℝ≥0∞) / + (D : ℝ≥0∞))) = (fun x y => S.linkLength (e x) (e y)) := by + funext x y + simpa only [Matrix.get,Vector.getElem_ofFn] using linkCost_exact S (e x) (e y) + rw [hh,pathDistance_surjective e he] + +end LargeIndependentSets.ShortestPaths + +namespace LargeIndependentSets.GeometryNames + +section +open scoped ENNReal Classical BigOperators + +def mixed {U V : Type*} {n : ℕ} (u : Fin n → U) (v : Fin n → V) (i : ℕ) : + MixedTuple U V n i := + ⟨fun k => if k.val < i then Sum.inl (v k) else Sum.inr (u k),by + intro k; by_cases hk : k.val < i <;> simp [hk]⟩ + +@[simp] lemma mixed_val {U V : Type*} {n : ℕ} (u : Fin n → U) (v : Fin n → V) + (i : ℕ) (k : Fin n) : (mixed u v i).val k = + if k.val < i then Sum.inl (v k) else Sum.inr (u k) := rfl + +lemma mixed_surjective {U V : Type*} [Nonempty U] [Nonempty V] {n i : ℕ} + (q : MixedTuple U V n i) : ∃ u v, mixed u v i=q := by + let u : Fin n → U := fun k => (q.val k).elim (fun _ => Classical.choice inferInstance) id + let v : Fin n → V := fun k => (q.val k).elim id (fun _ => Classical.choice inferInstance) + refine ⟨u,v,Subtype.ext ?_⟩ + funext k + have h := q.property k + cases he : q.val k with + | inl a => + have hk : k.val < i := by simpa [he] using h.symm + simp [mixed,u,v,he,hk] + | inr a => + have hk : ¬k.val < i := by simpa [he] using h.symm + simp [mixed,u,v,he,hk] + +abbrev StaticPoint (L R : Type) (n D : ℕ) := + Σ i : Fin (n+1), MixedTuple L R n i.val → ZMod D + +def decode {U V L R : Type} {n D : ℕ} + (u : Fin n → U) (v : Fin n → V) (a : StaticPoint L R n D) : + GridLocation (LayerAnswer L R (U:=U) (V:=V) (n:=n)) D := + ⟨⟨a.1,mixed u v a.1.val⟩,a.2⟩ + +lemma decode_surjective {U V L R : Type} [Nonempty U] [Nonempty V] {n D : ℕ} + (x : GridLocation (LayerAnswer L R (U:=U) (V:=V) (n:=n)) D) : + ∃ u v a, decode u v a=x := by + rcases x with ⟨⟨i,q⟩,x⟩ + obtain ⟨u,v,h⟩ := mixed_surjective q + refine ⟨u,v,⟨i,x⟩,?_⟩ + cases h + rfl + +abbrev Node (L R : Type) (n D nu nv : ℕ) := + ((Fin n → Fin nu) × (Fin n → Fin nv)) × StaticPoint L R n D + +def nodeDecode {L R : Type} {n D nu nv : ℕ} (x : Node L R n D nu nv) := + decode x.1.1 x.1.2 x.2 + +lemma nodeDecode_surjective {L R : Type} {n D nu nv : ℕ} (hu : 0 nodeDecode ((nodeEquiv L R n D nu nv).symm i) + +lemma names_surjective (L R : Type) [Fintype L] [Fintype R] (n D nu nv : ℕ) [NeZero D] + (hu : 0 hk (Fin.ext e) + by_cases hl : k.val + refine ⟨h,c,?_,?_⟩ + · exact ⟨a,b,rfl,rfl,hcoord⟩ + · exact (questionStep_iff lc h c u u' v v').mpr ⟨hl,hr,ho⟩ + · rintro ⟨h,c,⟨x,y,rfl,rfl,hxy⟩,hq⟩ + rw [ShortestPaths.forwardZero_iff] + obtain ⟨hl,hr,ho⟩ := (questionStep_iff lc h c u u' v v').mp hq + exact ⟨mixedProject h (lc.project c),.adjacent h _ _ c hl hr ho,hxy⟩ + +end LargeIndependentSets.GeometryNames + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryOutput.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..326c8a904021af13ec75402dca0b12356a0b6d32 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/GeometryOutput.lean @@ -0,0 +1,142 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.EnumerationSimple +import OAI.Combinatorics.IndependentSets.Geometry.GeometryLocations +import OAI.Combinatorics.IndependentSets.Geometry.GeometryAntipodes +import OAI.Combinatorics.IndependentSets.Encoding.GraphPrinter + +namespace OAI + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC ShortestPaths +open IndependentSetsGames.Foundations.Complexity Turing +open scoped Classical BigOperators ENNReal +noncomputable section +attribute [-instance] mixedTupleComputableFintype mixedTupleDecidableEq + +variable (L R : Type) [Fintype L] [Fintype R] (p : SamplerParameters) (q : ℕ) (hq : 0 rfl + +def adjacencyExpr (x y : Expr) : Expr := + .mul (.zero (Expr.equal x y)) (Expr.cond (cliqueExpr L R p.n (p.m*2^p.k)) (.const 1) + (closeExpr (p.m*2^p.k) (locationDistanceExpr L R p x) + (antiDistanceExpr L R p.n (p.m*2^p.k) (locationDistanceExpr L R p y)))) + +lemma equal_adj {G H : Graph} (h : G=H) (i j : Fin G.vertices) : + G.adj i j=H.adj (Fin.cast (congrArg Graph.vertices h) i) (Fin.cast (congrArg Graph.vertices h) j) := by + subst H + rfl + +lemma clique_adj {G : Graph} (h : G=Graph.clique q hq) (i j : Fin G.vertices) : + G.adj i j=decide (i≠j) := by + subst G + rfl + +lemma adjacencyExpr_eval (t : Table L R) (x y : Expr) (a : ℕ → ℕ) + (i j : Fin (output L R p q hq t).vertices) + (hi : x.eval (distances L R p.n (p.m*2^p.k) t).bits a=i.val) + (hj : y.eval (distances L R p.n (p.m*2^p.k) t).bits a=j.val) : + decide ((adjacencyExpr L R p x y).eval (distances L R p.n (p.m*2^p.k) t).bits a≠0)= + (output L R p q hq t).adj i j := by + have hind (P : Prop) [Decidable P] : (if P then (1:ℕ) else 0)=0 ↔ ¬P := by + split_ifs <;> simp_all + apply Bool.eq_iff_iff.mpr + simp only [decide_eq_true_eq] + have hnon (P : Prop) [Decidable P] : (if P then (1:ℕ) else 0)≠0 ↔ P := by + split_ifs <;> simp_all + simp only [adjacencyExpr,Expr.eval,Expr.equal_eval,hi,hj,Expr.cond_eval,cliqueExpr_nonzero, + mul_ne_zero_iff,hind,hnon] + by_cases hc : p.CliqueTest t.lc + · simp only [hc,ite_true] + rw [clique_adj q hq (by rw [output,ite_eq_left hc]) i j,decide_eq_true_eq] + constructor + · rintro ⟨h,_⟩; exact fun he => h (congrArg Fin.val he) + · intro h; exact ⟨fun he => h (Fin.ext he),by decide⟩ + · have hv : (output L R p q hq t).vertices=vertexCount L R p t := by rw [output,ite_eq_right hc]; rfl + let ii : Fin (vertexCount L R p t) := ⟨i.val,hv ▸ i.isLt⟩ + let jj : Fin (vertexCount L R p t) := ⟨j.val,hv ▸ j.isLt⟩ + have hli := locationDistanceExpr_eval L R p t x a ii hi + have hlj := locationDistanceExpr_eval L R p t y a jj hj + simp only [hc,ite_false] + rw [closeExpr_nonzero L R p.n (p.m*2^p.k) t _ _ _ + (locationName L R p t ((vertexEquiv L R p t).symm ii)) + (antiName L R p.n (p.m*2^p.k) t (locationName L R p t ((vertexEquiv L R p t).symm jj))) + hli (antiDistanceExpr_eval L R p.n (p.m*2^p.k) t _ _ _ hlj),antiName_exact, + locationName_exact,locationName_exact] + have he : (output L R p q hq t).adj i j= + decide ((p.graph t.lc).Adj ((vertexEquiv L R p t).symm ii) ((vertexEquiv L R p t).symm jj)) := by + have hh : output L R p q hq t=Graph.ofEnumeration (p.graph t.lc) + (vertexCount_pos L R p t) (vertexEquiv L R p t).symm := by rw [output,ite_eq_right hc] + exact equal_adj hh i j + rw [he,decide_eq_true_eq] + change (_ ∧ _) ↔ (_ ∧ _) + apply and_congr_left + intro _ + simp only [ne_eq,Equiv.apply_eq_iff_eq,Fin.ext_iff,ii,jj] + +def flatAdjacencyExpr : Expr := adjacencyExpr L R p + (Expr.quotient (.arg 0) (outputCountExpr L R p q)) + (Expr.remainder (.arg 0) (outputCountExpr L R p q)) + +lemma flatAdjacencyExpr_eval (t : Table L R) + (i : Fin ((output L R p q hq t).vertices*(output L R p q hq t).vertices)) : + decide ((flatAdjacencyExpr L R p q).eval (distances L R p.n (p.m*2^p.k) t).bits (fun _ => i.val)≠0)= + (output L R p q hq t).adj i.divNat i.modNat := by + apply adjacencyExpr_eval L R p q hq t _ _ _ i.divNat i.modNat + · simp only [Expr.quotient_eval,Expr.eval,outputCountExpr_eval L R p q hq,Fin.divNat] + · simp only [Expr.remainder_eval,Expr.eval,outputCountExpr_eval L R p q hq,Fin.modNat] + +def graphSerializer : TM2ComputableInPolyTime (fun t => (distances L R p.n (p.m*2^p.k) t).bits) + graphBits (output L R p q hq) := + GraphPrinter.encodedComputer _ _ (outputCountExpr L R p q) (flatAdjacencyExpr L R p q) + (outputCountExpr_eval L R p q hq) (flatAdjacencyExpr_eval L R p q hq) + +lemma graphSerializer_finiteAlphabet : MachineFiniteAlphabet.FiniteAlphabet (graphSerializer L R p q hq).tm := + GraphPrinter.encodedComputer_finiteAlphabet _ _ _ _ _ _ + +def distanceView : TM2ComputableInPolyTime Table.bits + (fun t => (distances L R p.n (p.m*2^p.k) t).bits) id where + tm := (distanceComputer L R p.n (p.m*2^p.k)).tm + inputAlphabet := (distanceComputer L R p.n (p.m*2^p.k)).inputAlphabet + outputAlphabet := (distanceComputer L R p.n (p.m*2^p.k)).outputAlphabet + time := (distanceComputer L R p.n (p.m*2^p.k)).time + outputsFun := (distanceComputer L R p.n (p.m*2^p.k)).outputsFun + +def graphComputer : TM2ComputableInPolyTime Table.bits graphBits (output L R p q hq) := + MachineSequential.composeBits (distanceView L R p) (graphSerializer L R p q hq) + +lemma graphComputer_finiteAlphabet : MachineFiniteAlphabet.FiniteAlphabet (graphComputer L R p q hq).tm := + MachineFiniteAlphabet.composeBits (distanceView L R p) (graphSerializer L R p q hq) + (distanceComputer_finiteAlphabet L R p.n (p.m*2^p.k)) (graphSerializer_finiteAlphabet L R p q hq) + +attribute [instance 1100] mixedTupleComputableFintype +attribute [instance] mixedTupleDecidableEq +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/NoUniformlyBadFinitePatterns.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/NoUniformlyBadFinitePatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..12b5a71d17a993c77aa424d9fcdd41191e7446a4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/NoUniformlyBadFinitePatterns.lean @@ -0,0 +1,39 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.RestrictionLawBad + +namespace OAI + +namespace LargeIndependentSets +open MeasureTheory Filter +open scoped Topology + +theorem no_uniformly_bad_finite_patterns {s d : ℕ} {ξ : ℝ} (hξ : 0 < ξ) + (hcounter : ∀ r, s ≤ r → ∃ μ : ProbabilityMeasure (ListPattern s d (Fin r)), + ∀ e : Fin s ↪o Fin r, + ξ ≤ (μ {C | ¬GoodPatternOn (C.restrict e) Finset.univ} : ℝ)) : False := by + classical + have hex (k : ℕ) := homogeneous_bad_finite_law hcounter k + (1 / ((k : ℝ) + 1)) (by positivity) + choose μ hhom hbad using hex + let seq (k : ℕ) := extensionLaw (rationalExhaustion k) (rationalExhaustion_card k) (μ k) + let natRat : ℕ ↪o ℚ := ⟨⟨Nat.cast, Nat.cast_injective⟩, by simp⟩ + let e₀ : Fin s ↪o ℚ := (Fin.valOrderEmb s).trans natRat + apply no_asymptotically_invariant_bad_sequence hξ seq _ e₀ + · filter_upwards [eventually_range_rationalExhaustion e₀] with k hk + rw [← restrictionLaw_bad] + change ξ ≤ ((restrictionLaw e₀ (extensionLaw (rationalExhaustion k) + (rationalExhaustion_card k) (μ k))) {D | ¬GoodPatternOn D Finset.univ} : ℝ) + rw [restriction_extensionLaw_inside _ _ _ hk, restrictionLaw_bad] + exact hbad k _ + · intro n e f + filter_upwards [eventually_ge_atTop n, + eventually_range_rationalExhaustion e, eventually_range_rationalExhaustion f] + with k hnk he hf + change dist (restrictionLaw e (extensionLaw (rationalExhaustion k) _ (μ k))) + (restrictionLaw f (extensionLaw (rationalExhaustion k) _ (μ k))) ≤ _ + rw [restriction_extensionLaw_inside _ _ _ he, restriction_extensionLaw_inside _ _ _ hf] + exact (hhom k n hnk _ _).le + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/PatternInvariant.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/PatternInvariant.lean new file mode 100644 index 0000000000000000000000000000000000000000..642605df7b7ed3de3df460c15f49f6420eb54a76 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/PatternInvariant.lean @@ -0,0 +1,424 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.ListIndex +import OAI.Combinatorics.IndependentSets.Reduction.ExtendPartialIso + +namespace OAI + +namespace LargeIndependentSets +open MeasureTheory Set + +def PatternInvariant {s d : ℕ} (μ : Measure (ListPattern s d ℚ)) : Prop := + ∀ e : ℚ ≃o ℚ, Measure.map (ListPattern.restrict e.toOrderEmbedding) μ = μ + +lemma occupied_measurable {s d : ℕ} (a : ListSlot s d ℚ) : + MeasurableSet {C : ListPattern s d ℚ | C.val a a = true} := + (isClosed_eq (patternEval_continuous a a) continuous_const).measurableSet + +theorem invariant_pattern_cut_in_list {s d : ℕ} (μ : Measure (ListPattern s d ℚ)) + [IsFiniteMeasure μ] (hinv : PatternInvariant μ) (a : ListSlot s d ℚ) : + μ {C | C.val a a = true ∧ + patternCut C a ∉ ((↑a.1.val : Set ℚ).image ((↑) : ℚ → ℝ))} = 0 := by + classical + let E : Set (ListPattern s d ℚ) := {C | C.val a a = true} + let ν : Measure ℝ := Measure.map (fun C => patternCut C a) (μ.restrict E) + have hCDF (x y : ℚ) (hxy : x < y) (hx : x ∉ a.1.val) (hy : y ∉ a.1.val) + (hcut : ∀ i ∈ a.1.val, i < x ↔ i < y) : ν (Iic (x : ℝ)) = ν (Iic (y : ℝ)) := by + obtain ⟨e, hexy, hefix⟩ := rational_automorphism_fixing a.1.val x y hx hy hcut + have hea := ListSlot.map_eq_self e a hefix + let F : Set (ListPattern s d ℚ) := + (fun C => patternCut C a) ⁻¹' Iic (x : ℝ) ∩ E + have hF : MeasurableSet F := + ((patternCut_measurable a) measurableSet_Iic).inter (occupied_measurable a) + have hh := congrArg (fun τ : Measure (ListPattern s d ℚ) => τ F) (hinv e) + rw [Measure.map_apply (ListPattern.continuous_restrict e.toOrderEmbedding).measurable hF] at hh + have hfpre : (ListPattern.restrict e.toOrderEmbedding) ⁻¹' F = + (fun C => patternCut C a) ⁻¹' Iic (y : ℝ) ∩ E := by + ext C + change (patternCut (ListPattern.restrict e.toOrderEmbedding C) a ≤ (x : ℝ) ∧ + C.val (ListSlot.map e.toEmbedding a) (ListSlot.map e.toEmbedding a) = true) ↔ + (patternCut C a ≤ (y : ℝ) ∧ C.val a a = true) + rw [patternCut_restrict_CDF, hea, hexy] + rw [hfpre] at hh + dsimp only [ν] + rw [Measure.map_apply (patternCut_measurable a) measurableSet_Iic, + Measure.map_apply (patternCut_measurable a) measurableSet_Iic, + Measure.restrict_apply ((patternCut_measurable a) measurableSet_Iic), + Measure.restrict_apply ((patternCut_measurable a) measurableSet_Iic)] + exact hh.symm + have hz := invariant_cut_support_open a.1.val ν hCDF + have hcomp : MeasurableSet (((↑a.1.val : Set ℚ).image ((↑) : ℚ → ℝ))ᶜ) := + (a.1.val.finite_toSet.image _).measurableSet.compl + dsimp only [ν] at hz + rw [Measure.map_apply (patternCut_measurable a) hcomp, + Measure.restrict_apply ((patternCut_measurable a) hcomp)] at hz + convert hz using 2 + ext C + change (_ ∧ _) ↔ (_ ∧ _) + tauto + +def GloballyAligned {s d : ℕ} (C : ListPattern s d ℚ) : Prop := + ∀ a, C.val a a = true → ∃ i : ℚ, ∀ b, C.val a b = true → i ∈ b.1.val + +theorem invariant_pattern_globally_aligned {s d : ℕ} + (μ : Measure (ListPattern s d ℚ)) [IsFiniteMeasure μ] (hinv : PatternInvariant μ) : + ∀ᵐ C ∂μ, GloballyAligned C := by + have ha (a : ListSlot s d ℚ) : ∀ᵐ C ∂μ, C.val a a = true → + patternCut C a ∈ ((↑a.1.val : Set ℚ).image ((↑) : ℚ → ℝ)) := by + apply ae_iff.mpr + convert invariant_pattern_cut_in_list μ hinv a using 2 + ext C + exact Classical.not_imp + have hall : ∀ᵐ C ∂μ, ∀ a : ListSlot s d ℚ, C.val a a = true → + patternCut C a ∈ ((↑a.1.val : Set ℚ).image ((↑) : ℚ → ℝ)) := + ae_all_iff.mpr ha + filter_upwards [hall] with C hC + intro a haa + obtain ⟨i, hi, hic⟩ := hC a haa + refine ⟨i, ?_⟩ + intro b hab + have hbb : C.val b b = true := C.occupied_of_eq (C.property.1 a b hab) + obtain ⟨j, hj, hjc⟩ := hC b hbb + have hij : (i : ℝ) = (j : ℝ) := hic.trans ((patternCut_eq_of_eq C a b hab).trans hjc.symm) + have hij' : i = j := by exact_mod_cast hij + exact hij' ▸ hj + +def GoodPatternOn {s d : ℕ} {X : Type*} [LinearOrder X] + (C : ListPattern s d X) (B : Finset X) : Prop := + ∀ a, a.1.val ⊆ B → C.val a a = true → ∃ i ∈ B, + ∀ b, b.1.val ⊆ B → C.val a b = true → i ∈ b.1.val + +lemma GloballyAligned.goodOn {s d : ℕ} (C : ListPattern s d ℚ) + (h : GloballyAligned C) (B : Finset ℚ) : GoodPatternOn C B := by + intro a ha haa + obtain ⟨i, hi⟩ := h a haa + exact ⟨i, ha (hi a haa), fun b _ hab => hi b hab⟩ + +theorem invariant_pattern_no_bad_sets {s d : ℕ} + (μ : Measure (ListPattern s d ℚ)) [IsFiniteMeasure μ] (hinv : PatternInvariant μ) + (B : Finset ℚ) : μ {C | ¬GoodPatternOn C B} = 0 := by + have h : ∀ᵐ C ∂μ, GoodPatternOn C B := + (invariant_pattern_globally_aligned μ hinv).mono (fun C h => h.goodOn C B) + exact ae_iff.mp h + +noncomputable def ListIndex.inside {s : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (I : ListIndex s X) (h : I.val ⊆ B) : ListIndex s B := by + classical + refine ⟨I.val.subtype (· ∈ B), ?_, ?_⟩ + · obtain ⟨x, hx⟩ := I.property.1 + exact ⟨⟨x, h hx⟩, Finset.mem_subtype.mpr hx⟩ + · exact (Finset.card_subtype _ _).trans_le + ((Finset.card_filter_le _ _).trans I.property.2) + +lemma ListIndex.map_inside {s : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (I : ListIndex s X) (h : I.val ⊆ B) : + ListIndex.map (Function.Embedding.subtype (· ∈ B)) (I.inside B h) = I := by + classical + apply Subtype.ext + exact Finset.subtype_map_of_mem (fun x hx => h hx) + +noncomputable def ListSlot.inside {s d : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (a : ListSlot s d X) (h : a.1.val ⊆ B) : ListSlot s d B := + (a.1.inside B h, a.2) + +lemma ListSlot.map_inside {s d : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (a : ListSlot s d X) (h : a.1.val ⊆ B) : + ListSlot.map (Function.Embedding.subtype (· ∈ B)) (a.inside B h) = a := by + exact Prod.ext (ListIndex.map_inside B a.1 h) rfl + +noncomputable def liftData {s d : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (C : ListPattern s d B) : EqualityData s d X := by + classical + exact fun a b => if ha : a.1.val ⊆ B then + if hb : b.1.val ⊆ B then C.val (a.inside B ha) (b.inside B hb) else false else false + +lemma liftData_true_iff {s d : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (C : ListPattern s d B) (a b : ListSlot s d X) : + liftData B C a b = true ↔ ∃ ha : a.1.val ⊆ B, ∃ hb : b.1.val ⊆ B, + C.val (a.inside B ha) (b.inside B hb) = true := by + classical + simp only [liftData] + split_ifs <;> simp_all + +noncomputable def ListPattern.lift {s d : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (C : ListPattern s d B) : ListPattern s d X := by + classical + refine ⟨liftData B C, ?_, ?_, ?_, ?_⟩ + · intro a b h + obtain ⟨ha, hb, hab⟩ := (liftData_true_iff B C a b).mp h + exact (liftData_true_iff B C b a).mpr ⟨hb, ha, C.property.1 _ _ hab⟩ + · intro a b c hab hbc + obtain ⟨ha, hb, hab⟩ := (liftData_true_iff B C a b).mp hab + obtain ⟨_, hc, hbc⟩ := (liftData_true_iff B C b c).mp hbc + exact (liftData_true_iff B C a c).mpr ⟨ha, hc, C.property.2.1 _ _ _ hab hbc⟩ + · intro a b hab habI + obtain ⟨ha, hb, hab⟩ := (liftData_true_iff B C a b).mp hab + apply C.property.2.2.1 _ _ hab + change ListIndex.inside B a.1 ha = ListIndex.inside B b.1 hb + apply Subtype.ext + change a.1.val.subtype (· ∈ B) = b.1.val.subtype (· ∈ B) + rw [congrArg Subtype.val habI] + · intro a b hsep + apply Bool.eq_false_iff.mpr + intro hab + obtain ⟨ha, hb, hab⟩ := (liftData_true_iff B C a b).mp hab + have hf := C.property.2.2.2 (a.inside B ha) (b.inside B hb) (by + intro x hx y hy + exact hsep x.val (Finset.mem_subtype.mp hx) y.val (Finset.mem_subtype.mp hy)) + exact Bool.false_ne_true (hf.symm.trans hab) + +lemma ListSlot.inside_map {s d : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (a : ListSlot s d B) + (h : (ListSlot.map (Function.Embedding.subtype (· ∈ B)) a).1.val ⊆ B) : + (ListSlot.map (Function.Embedding.subtype (· ∈ B)) a).inside B h = a := by + apply ListSlot.map_injective (Function.Embedding.subtype (· ∈ B)) + exact ListSlot.map_inside B _ h + +lemma ListPattern.restrict_lift {s d : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (C : ListPattern s d B) : + ListPattern.restrict (OrderEmbedding.subtype (· ∈ B)) (C.lift B) = C := by + classical + apply Subtype.ext + funext a b + have h (a : ListSlot s d B) : + (ListSlot.map (Function.Embedding.subtype (· ∈ B)) a).1.val ⊆ B := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Finset.mem_map.mp hx + exact y.property + change liftData B C (ListSlot.map (Function.Embedding.subtype (· ∈ B)) a) + (ListSlot.map (Function.Embedding.subtype (· ∈ B)) b) = _ + simp only [liftData, dite_eq_left (h a), dite_eq_left (h b), ListSlot.inside_map] + +lemma ListIndex.map_id {s : ℕ} {X : Type*} (I : ListIndex s X) : + ListIndex.map (Function.Embedding.refl X) I = I := by + apply Subtype.ext + exact Finset.map_refl + +lemma ListSlot.map_id {s d : ℕ} {X : Type*} (a : ListSlot s d X) : + ListSlot.map (Function.Embedding.refl X) a = a := + Prod.ext (ListIndex.map_id a.1) rfl + +lemma ListSlot.map_comp {s d : ℕ} {X Y Z : Type*} (e : X ↪ Y) (f : Y ↪ Z) + (a : ListSlot s d X) : + ListSlot.map f (ListSlot.map e a) = ListSlot.map (e.trans f) a := by + apply Prod.ext + · apply Subtype.ext + exact Finset.map_map _ _ _ + · rfl + +lemma ListPattern.restrict_id {s d : ℕ} {X : Type*} [LinearOrder X] + (C : ListPattern s d X) : ListPattern.restrict ((OrderIso.refl X).toOrderEmbedding) C = C := by + apply Subtype.ext + funext a b + change C.val (ListSlot.map (Function.Embedding.refl X) a) + (ListSlot.map (Function.Embedding.refl X) b) = C.val a b + rw [ListSlot.map_id, ListSlot.map_id] + +lemma ListPattern.restrict_comp {s d : ℕ} {X Y Z : Type*} + [LinearOrder X] [LinearOrder Y] [LinearOrder Z] (e : X ↪o Y) (f : Y ↪o Z) + (C : ListPattern s d Z) : + (C.restrict f).restrict e = C.restrict (e.trans f) := by + apply Subtype.ext + funext a b + change C.val (ListSlot.map f.toEmbedding (ListSlot.map e.toEmbedding a)) + (ListSlot.map f.toEmbedding (ListSlot.map e.toEmbedding b)) = _ + rw [ListSlot.map_comp, ListSlot.map_comp] + rfl + +noncomputable def ListPattern.extendFin {s d n : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (h : B.card = n) (C : ListPattern s d (Fin n)) : ListPattern s d X := + (C.restrict (B.orderIsoOfFin h).symm.toOrderEmbedding).lift B + +lemma ListPattern.restrict_extendFin {s d n : ℕ} {X : Type*} [LinearOrder X] + (B : Finset X) (h : B.card = n) (C : ListPattern s d (Fin n)) : + (C.extendFin B h).restrict (B.orderEmbOfFin h) = C := by + change ((C.restrict (B.orderIsoOfFin h).symm.toOrderEmbedding).lift B).restrict + ((B.orderIsoOfFin h).toOrderEmbedding.trans (OrderEmbedding.subtype (· ∈ B))) = C + rw [← ListPattern.restrict_comp, ListPattern.restrict_lift, ListPattern.restrict_comp] + have he : (B.orderIsoOfFin h).toOrderEmbedding.trans + (B.orderIsoOfFin h).symm.toOrderEmbedding = (OrderIso.refl (Fin n)).toOrderEmbedding := by + apply DFunLike.ext; intro x; exact (B.orderIsoOfFin h).symm_apply_apply x + rw [he, ListPattern.restrict_id] + +lemma GloballyAligned.good_full_restrict {s d n : ℕ} (C : ListPattern s d ℚ) + (hC : GloballyAligned C) (e : Fin n ↪o ℚ) : + GoodPatternOn (C.restrict e) Finset.univ := by + classical + intro a ha haa + obtain ⟨i, hi⟩ := hC (ListSlot.map e.toEmbedding a) haa + obtain ⟨j, hj, hji⟩ := Finset.mem_map.mp (hi (ListSlot.map e.toEmbedding a) haa) + refine ⟨j, Finset.mem_univ _, ?_⟩ + intro b _ hab + obtain ⟨k, hk, hki⟩ := Finset.mem_map.mp (hi (ListSlot.map e.toEmbedding b) hab) + have hjk : j = k := e.injective (hji.trans hki.symm) + exact hjk ▸ hk + +lemma isClopen_finite_pattern_event {s d n : ℕ} (E : Set (ListPattern s d (Fin n))) : + IsClopen E := isClopen_discrete E + +lemma isClopen_bad_restrict {s d n : ℕ} {X : Type*} [LinearOrder X] + (e : Fin n ↪o X) : + IsClopen {C : ListPattern s d X | ¬GoodPatternOn (C.restrict e) Finset.univ} := + (isClopen_finite_pattern_event {D | ¬GoodPatternOn D Finset.univ}).preimage + (ListPattern.continuous_restrict e) + +lemma ListPattern.measurable_restrict {s d : ℕ} {X Y : Type*} + [LinearOrder X] [LinearOrder Y] (e : X ↪o Y) : + Measurable (ListPattern.restrict (s := s) (d := d) e) := by + apply Measurable.subtype_mk + apply Measurable.of_eval; intro a + apply Measurable.of_eval; intro b + exact (measurable_pi_apply (ListSlot.map e.toEmbedding b)).comp + ((measurable_pi_apply (ListSlot.map e.toEmbedding a) : + Measurable (fun C : EqualityData s d Y => C (ListSlot.map e.toEmbedding a))).comp + measurable_subtype_coe) + +noncomputable def restrictionLaw {s d : ℕ} {X Y : Type*} + [LinearOrder X] [LinearOrder Y] (e : X ↪o Y) + (μ : ProbabilityMeasure (ListPattern s d Y)) : ProbabilityMeasure (ListPattern s d X) := + μ.map (ListPattern.restrict e) + +lemma restrictionLaw_comp {s d : ℕ} {X Y Z : Type*} + [LinearOrder X] [LinearOrder Y] [LinearOrder Z] (e : X ↪o Y) (f : Y ↪o Z) + (μ : ProbabilityMeasure (ListPattern s d Z)) : + restrictionLaw e (restrictionLaw f μ) = restrictionLaw (e.trans f) μ := by + apply ProbabilityMeasure.toMeasure_injective + change Measure.map (ListPattern.restrict e) (Measure.map (ListPattern.restrict f) (μ : Measure (ListPattern s d Z))) = _ + rw [Measure.map_map (ListPattern.measurable_restrict e) (ListPattern.measurable_restrict f)] + congr 1 + funext C + exact ListPattern.restrict_comp e f C + +lemma restrictionLaw_id {s d : ℕ} {X : Type*} [LinearOrder X] + (μ : ProbabilityMeasure (ListPattern s d X)) : + restrictionLaw (OrderIso.refl X).toOrderEmbedding μ = μ := by + apply ProbabilityMeasure.toMeasure_injective + change Measure.map _ _ = _ + have he : ListPattern.restrict (s := s) (d := d) (OrderIso.refl X).toOrderEmbedding = id := by + funext C; exact ListPattern.restrict_id C + rw [he, Measure.map_id] + +lemma finite_laws_invariant {s d : ℕ} + (μ : ProbabilityMeasure (ListPattern s d ℚ)) + (h : ∀ n (e f : Fin n ↪o ℚ), restrictionLaw e μ = restrictionLaw f μ) : + PatternInvariant (μ : Measure (ListPattern s d ℚ)) := by + classical + intro g + let encode : ListPattern s d ℚ → (ListSlot s d ℚ × ListSlot s d ℚ → Bool) := + fun C ab => C.val ab.1 ab.2 + have hm : MeasurableEmbedding encode := + (MeasurableEquiv.curry (ListSlot s d ℚ) (ListSlot s d ℚ) Bool).symm.measurableEmbedding.comp + (MeasurableEmbedding.subtype_coe (isClosed_isPattern s d ℚ).measurableSet) + apply hm.map_injective + rw [Measure.map_map hm.measurable (ListPattern.measurable_restrict g.toOrderEmbedding)] + apply (ProbabilityTheory.map_eq_iff_forall_finset_map_restrict_eq + (hm.measurable.comp (ListPattern.measurable_restrict g.toOrderEmbedding)).aemeasurable + hm.measurable.aemeasurable).mpr + intro J + let B : Finset ℚ := J.biUnion (fun ab => ab.1.1.val ∪ ab.2.1.val) + have hB (ab : J) : ab.val.1.1.val ⊆ B ∧ ab.val.2.1.val ⊆ B := by + constructor + · intro x hx + exact Finset.mem_biUnion.mpr ⟨ab.val, ab.property, Finset.mem_union_left _ hx⟩ + · intro x hx + exact Finset.mem_biUnion.mpr ⟨ab.val, ab.property, Finset.mem_union_right _ hx⟩ + let e : B ↪o ℚ := OrderEmbedding.subtype (· ∈ B) + let u : Fin B.card ≃o B := B.orderIsoOfFin rfl + have hfin := h B.card (u.toOrderEmbedding.trans (e.trans g.toOrderEmbedding)) + (u.toOrderEmbedding.trans e) + have hsub := congrArg (restrictionLaw u.symm.toOrderEmbedding) hfin + simp only [restrictionLaw_comp] at hsub + have he1 : u.symm.toOrderEmbedding.trans (u.toOrderEmbedding.trans (e.trans g.toOrderEmbedding)) = + e.trans g.toOrderEmbedding := by + apply DFunLike.ext; intro x; exact congrArg (e.trans g.toOrderEmbedding) (u.apply_symm_apply x) + have he2 : u.symm.toOrderEmbedding.trans (u.toOrderEmbedding.trans e) = e := by + apply DFunLike.ext; intro x; exact congrArg e (u.apply_symm_apply x) + rw [he1, he2] at hsub + let F : ListPattern s d B → (J → Bool) := fun C ab => + C.val (ab.val.1.inside B (hB ab).1) (ab.val.2.inside B (hB ab).2) + have hFm : Measurable F := (continuous_of_discreteTopology : Continuous F).measurable + have hmap := congrArg (fun ν : ProbabilityMeasure (ListPattern s d B) => + Measure.map F (ν : Measure (ListPattern s d B))) hsub + change Measure.map F (Measure.map _ _) = Measure.map F (Measure.map _ _) at hmap + rw [Measure.map_map hFm (ListPattern.measurable_restrict _), + Measure.map_map hFm (ListPattern.measurable_restrict _)] at hmap + convert hmap using 1 <;> congr 1 <;> funext C ab + · change C.val (ListSlot.map g.toEmbedding ab.val.1) (ListSlot.map g.toEmbedding ab.val.2) = + C.val (ListSlot.map (e.trans g.toOrderEmbedding).toEmbedding + (ab.val.1.inside B (hB ab).1)) + (ListSlot.map (e.trans g.toOrderEmbedding).toEmbedding (ab.val.2.inside B (hB ab).2)) + change C.val (ListSlot.map g.toEmbedding ab.val.1) (ListSlot.map g.toEmbedding ab.val.2) = + C.val (ListSlot.map ((Function.Embedding.subtype (· ∈ B)).trans g.toEmbedding) + (ab.val.1.inside B (hB ab).1)) + (ListSlot.map ((Function.Embedding.subtype (· ∈ B)).trans g.toEmbedding) + (ab.val.2.inside B (hB ab).2)) + rw [← ListSlot.map_comp, ← ListSlot.map_comp, ListSlot.map_inside, ListSlot.map_inside] + · change C.val ab.val.1 ab.val.2 = + C.val (ListSlot.map (Function.Embedding.subtype (· ∈ B)) + (ab.val.1.inside B (hB ab).1)) + (ListSlot.map (Function.Embedding.subtype (· ∈ B)) (ab.val.2.inside B (hB ab).2)) + rw [ListSlot.map_inside, ListSlot.map_inside] + +open Filter +open scoped Topology + +instance patternMetrizable (s d : ℕ) (X : Type*) [LinearOrder X] [Countable X] : + TopologicalSpace.MetrizableSpace (ListPattern s d X) := by + have : TopologicalSpace.MetrizableSpace (EqualityData s d X) := inferInstance + exact TopologicalSpace.MetrizableSpace.subtype {C : EqualityData s d X | IsPattern C} + +instance patternSecondCountable (s d : ℕ) (X : Type*) [LinearOrder X] [Countable X] : + SecondCountableTopology (ListPattern s d X) := by + have : SecondCountableTopology (EqualityData s d X) := inferInstance + infer_instance + +noncomputable instance finitePatternLawMetric (s d n : ℕ) : + MetricSpace (ProbabilityMeasure (ListPattern s d (Fin n))) := + by + have := MeasureTheory.instMetrizableSpaceProbabilityMeasure (ListPattern s d (Fin n)) + exact TopologicalSpace.metrizableSpaceMetric _ + +lemma continuous_restrictionLaw {s d n : ℕ} (e : Fin n ↪o ℚ) : + Continuous (restrictionLaw (s := s) (d := d) e) := + ProbabilityMeasure.continuous_map (ListPattern.continuous_restrict e) + +theorem no_asymptotically_invariant_bad_sequence {s d : ℕ} {ξ : ℝ} (hξ : 0 < ξ) + (seq : ℕ → ProbabilityMeasure (ListPattern s d ℚ)) + (hhom : ∀ n (e f : Fin n ↪o ℚ), ∀ᶠ k in atTop, + dist (restrictionLaw e (seq k)) (restrictionLaw f (seq k)) ≤ 1 / ((k : ℝ) + 1)) + (e₀ : Fin s ↪o ℚ) + (hbad : ∀ᶠ k in atTop, + ξ ≤ ((seq k) {C | ¬GoodPatternOn (C.restrict e₀) Finset.univ} : ℝ)) : False := by + obtain ⟨μ, φ, hφ, hlim⟩ := CompactSpace.tendsto_subseq seq + have hinv : PatternInvariant (μ : Measure (ListPattern s d ℚ)) := by + apply finite_laws_invariant μ + intro n e f + have he := (continuous_restrictionLaw e).tendsto μ |>.comp hlim + have hf := (continuous_restrictionLaw f).tendsto μ |>.comp hlim + have hd := he.dist hf + have hz : Tendsto (fun k : ℕ => 1 / ((k : ℝ) + 1)) atTop (𝓝 0) := by + exact tendsto_one_div_add_atTop_nhds_zero_nat + have hzero : Tendsto (fun k => + dist (restrictionLaw e (seq (φ k))) (restrictionLaw f (seq (φ k)))) atTop (𝓝 0) := + squeeze_zero' (Eventually.of_forall (fun _ => dist_nonneg)) + (hφ.tendsto_atTop.eventually (hhom n e f)) (hz.comp hφ.tendsto_atTop) + have hdz : dist (restrictionLaw e μ) (restrictionLaw f μ) = 0 := + tendsto_nhds_unique hd hzero + exact dist_eq_zero.mp hdz + let E : Set (ListPattern s d ℚ) := {C | ¬GoodPatternOn (C.restrict e₀) Finset.univ} + have hzero : (μ : Measure (ListPattern s d ℚ)) E = 0 := by + apply ae_iff.mp + exact (invariant_pattern_globally_aligned _ hinv).mono (fun C hC => + hC.good_full_restrict C e₀) + have hzero' : μ E = 0 := (μ.null_iff_toMeasure_null E).mpr hzero + have hprob := ProbabilityMeasure.tendsto_measure_of_isClopen_of_tendsto hlim + (isClopen_bad_restrict e₀) + have hreal : Tendsto (fun k => ((seq (φ k)) E : ℝ)) atTop (𝓝 0) := by + have hp : Tendsto (fun k => (seq (φ k)) E) atTop (𝓝 (μ E)) := hprob + have hh := (NNReal.continuous_coe.tendsto (μ E)).comp hp + simpa only [Function.comp_def, hzero', NNReal.coe_zero] using hh + have hle : ξ ≤ 0 := ge_of_tendsto hreal (hφ.tendsto_atTop.eventually hbad) + exact (not_le_of_gt hξ) hle + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/RationalLaw.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/RationalLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..259383158e0b4f841d8c5bc014209cc9bcee1ec4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/RationalLaw.lean @@ -0,0 +1,124 @@ +import Mathlib + +namespace OAI + +namespace LargeIndependentSets +open scoped Classical BigOperators + +structure RationalLaw (O : Type*) [Fintype O] where + weight : O → ℚ + nonneg : ∀ o, 0 ≤ weight o + total : ∑ o, weight o = 1 + +namespace RationalLaw +variable {O : Type*} [Fintype O] + +def denominator (p : RationalLaw O) : ℕ := ∏ o, (p.weight o).den + +def copies (p : RationalLaw O) (o : O) : ℕ := + (p.denominator / (p.weight o).den) * (p.weight o).num.toNat + +lemma denominator_pos (p : RationalLaw O) : 0 < p.denominator := by + apply Finset.prod_pos + intro o _; exact Rat.den_pos _ + +lemma denominator_dvd (p : RationalLaw O) (o : O) : + (p.weight o).den ∣ p.denominator := Finset.dvd_prod_of_mem _ (Finset.mem_univ o) + +lemma copies_eq (p : RationalLaw O) (o : O) : + (p.copies o : ℚ) = p.denominator * p.weight o := by + have hnum : 0 ≤ (p.weight o).num := Rat.num_nonneg.mpr (p.nonneg o) + have hden : ((p.weight o).den : ℚ) ≠ 0 := by + exact_mod_cast (Rat.den_pos (p.weight o)).ne' + have hdiv : (p.denominator / (p.weight o).den : ℕ) * (p.weight o).den = p.denominator := + Nat.div_mul_cancel (p.denominator_dvd o) + have hdiv' : ((p.denominator / (p.weight o).den : ℕ) : ℚ) * (p.weight o).den = p.denominator := by + exact_mod_cast hdiv + have hnum' : ((p.weight o).num.toNat : ℚ) = (p.weight o).num := by + exact_mod_cast Int.toNat_of_nonneg hnum + rw [copies, Nat.cast_mul, hnum'] + rw [← Rat.mul_den_eq_num] + calc + _ = (((p.denominator / (p.weight o).den : ℕ) : ℚ) * (p.weight o).den) * p.weight o := by ring + _ = _ := by rw [hdiv'] + +lemma total_copies (p : RationalLaw O) : ∑ o, p.copies o = p.denominator := by + have h : (∑ o, (p.copies o : ℚ)) = p.denominator := by + simp_rw [p.copies_eq] + rw [← Finset.mul_sum, p.total, mul_one] + exact_mod_cast h + +abbrev Expanded (p : RationalLaw O) := Σ o : O, Fin (p.copies o) + +lemma card_expanded (p : RationalLaw O) : Fintype.card p.Expanded = p.denominator := by + simp only [Expanded, Fintype.card_sigma, Fintype.card_fin, p.total_copies] + +noncomputable instance expandedNonempty (p : RationalLaw O) : Nonempty p.Expanded := + Fintype.card_pos_iff.mp (by rw [p.card_expanded]; exact p.denominator_pos) + +lemma copies_real (p : RationalLaw O) (o : O) : + (p.copies o : ℝ) = p.denominator * (p.weight o : ℝ) := by + exact_mod_cast p.copies_eq o + +theorem expect_expanded (p : RationalLaw O) (f : O → ℝ) : + (𝔼 v : p.Expanded, f v.1) = ∑ o, (p.weight o : ℝ) * f o := by + rw [Finset.expect_eq_sum_div_card, Finset.card_univ, p.card_expanded] + simp only [Fintype.sum_sigma, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + nsmul_eq_mul, p.copies_real, mul_assoc, ← Finset.mul_sum] + have h : (p.denominator : ℝ) ≠ 0 := by exact_mod_cast p.denominator_pos.ne' + field_simp + +abbrev Vertices (p : RationalLaw O) (C : Type*) (n : ℕ) := (Fin n → C) × p.Expanded + +lemma card_vertices (p : RationalLaw O) (C : Type*) [Fintype C] (n : ℕ) : + Fintype.card (p.Vertices C n) = Fintype.card C ^ n * p.denominator := by + simp only [Vertices, Fintype.card_prod, Fintype.card_fun, Fintype.card_fin, p.card_expanded] + +lemma expect_vertices (p : RationalLaw O) {C : Type*} [Fintype C] (n : ℕ) + (f : (Fin n → C) → O → ℝ) : + (𝔼 v : p.Vertices C n, f v.1 v.2.1) = + 𝔼 c : Fin n → C, ∑ o, (p.weight o : ℝ) * f c o := by + rw [← Finset.univ_product_univ, Finset.expect_product] + congr 1; funext c + exact p.expect_expanded (f c) + +end RationalLaw + +theorem density_le_location_square {V X : Type*} [Fintype V] (A : Finset V) + (location : V → X) (f : X → ℝ) (hA : ∀ v ∈ A, f (location v) = 1) : + (A.card : ℝ) / Fintype.card V ≤ 𝔼 v, (f (location v))^2 := by + have hp (v : V) : (if v ∈ A then (1:ℝ) else 0) ≤ (f (location v))^2 := by + by_cases hv : v ∈ A + · simp [hv,hA v hv] + · simp only [ite_eq_right hv]; positivity + have h := Finset.expect_le_expect (fun v (_ : v ∈ Finset.univ) => hp v) + simpa only [Finset.expect_eq_sum_div_card, Finset.sum_boole, Finset.card_univ, + Finset.filter_mem_eq_inter, Finset.univ_inter] using h + +theorem density_from_good_fibers {C B V : Type*} [Fintype C] [Nonempty C] + [Fintype B] [Fintype V] + (p : RationalLaw B) (bad : C → B → Prop) (density : C → B → ℝ) + {ε δ : ℝ} (hε : 0 ≤ ε) (hδ : 8*ε < δ) + (hbad : (𝔼 c, ∑ b, (p.weight b : ℝ) * (if bad c b then 1 else 0)) ≤ 2*ε) + (hgood : ∀ c b, ¬bad c b → density c b ≤ 6*ε) + (hone : ∀ c b, density c b ≤ 1) (A : Finset V) + (haverage : (A.card : ℝ) / Fintype.card V ≤ + 𝔼 c, ∑ b, (p.weight b : ℝ) * density c b) : + (A.card : ℝ) / Fintype.card V < δ := by + have hp (c : C) (b : B) : density c b ≤ 6*ε + (if bad c b then 1 else 0) := by + by_cases h : bad c b + · simp only [ite_eq_left h]; linarith [hone c b] + · simpa only [ite_eq_right h,add_zero] using hgood c b h + have ht : (∑ b, (p.weight b : ℝ)) = 1 := by exact_mod_cast p.total + have hsum (c : C) : (∑ b, (p.weight b : ℝ) * density c b) ≤ + 6*ε + ∑ b, (p.weight b : ℝ) * (if bad c b then 1 else 0) := by + have h := Finset.sum_le_sum (s:=Finset.univ) (fun b _ => + mul_le_mul_of_nonneg_left (hp c b) (by exact_mod_cast p.nonneg b : (0:ℝ) ≤ p.weight b)) + simpa only [mul_add, Finset.sum_add_distrib, ← Finset.sum_mul, ht, one_mul] using h + have hmean := Finset.expect_le_expect (fun c (_ : c ∈ Finset.univ) => hsum c) + rw [Finset.expect_add_distrib, Fintype.expect_const] at hmean + linarith + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/RationalSimplexApproximation.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/RationalSimplexApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..31779d2c5edc0adf5d9c67716e49b0b37740f577 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/RationalSimplexApproximation.lean @@ -0,0 +1,69 @@ +import Mathlib + +namespace OAI + +namespace LargeIndependentSets +open scoped BigOperators + +theorem rational_simplex_approximation {J : Type*} [Fintype J] [Nonempty J] + (q : J → ℝ) (hq : (∀ coordinate, 0 ≤ q coordinate) ∧ ∑ coordinate, q coordinate = 1) + (ε : ℝ) (hε : 0 < ε) : + ∃ p : J → ℚ, ((∀ coordinate, 0 ≤ p coordinate) ∧ ∑ coordinate, p coordinate = 1) ∧ + ∀ b : J → ℝ, (∀ j, 0 ≤ b j ∧ b j ≤ 1) → + ∑ j, (p j : ℝ) * b j ≤ ∑ j, q j * b j + ε := by + classical + let t := ε / ((Fintype.card J : ℝ) + 1) + have ht : 0 < t := by dsimp [t]; positivity + have ha (j : J) : ∃ a : ℚ, 0 ≤ a ∧ (a : ℝ) ≤ q j ∧ q j - a < t := by + by_cases hz : q j = 0 + · exact ⟨0, le_rfl, by simp [hz], by simpa [hz] using ht⟩ + · have hp : 0 < q j := lt_of_le_of_ne (hq.1 j) (Ne.symm hz) + obtain ⟨a, hal, har⟩ := exists_rat_btwn (show max 0 (q j - t) < q j from + max_lt hp (sub_lt_self _ ht)) + refine ⟨a, ?_, har.le, ?_⟩ + · exact_mod_cast (le_max_left 0 (q j - t)).trans hal.le + · have h := (le_max_right 0 (q j - t)).trans_lt hal + linarith + choose a ha0 haq hae using ha + have hsum : ∑ j, (a j : ℝ) ≤ 1 := + (Finset.sum_le_sum (fun j _ => haq j)).trans_eq hq.2 + have hsumQ : ∑ j, a j ≤ 1 := by exact_mod_cast hsum + let i₀ : J := Classical.arbitrary J + let p : J → ℚ := fun j => a j + if j = i₀ then 1 - ∑ i, a i else 0 + have hp : (∀ coordinate, 0 ≤ p coordinate) ∧ ∑ coordinate, p coordinate = 1 := by + constructor + · intro j + apply add_nonneg (ha0 j) + split_ifs <;> linarith + · simp [p, Finset.sum_add_distrib] + have hdef : 1 - ∑ j, (a j : ℝ) < ε := by + have he := Finset.sum_le_sum (s := Finset.univ) (fun j _ => (hae j).le) + rw [Finset.sum_sub_distrib, hq.2, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] at he + have hden : (0 : ℝ) < (Fintype.card J : ℝ) + 1 := by positivity + have hid : t * ((Fintype.card J : ℝ) + 1) = ε := by + exact div_mul_cancel₀ ε (ne_of_gt hden) + have hlt : (Fintype.card J : ℝ) * t < ε := by nlinarith + exact he.trans_lt hlt + refine ⟨p, hp, ?_⟩ + intro b hb + have hmain : ∑ j, (a j : ℝ) * b j ≤ ∑ j, q j * b j := + Finset.sum_le_sum (fun j _ => mul_le_mul_of_nonneg_right (haq j) (hb j).1) + have hformula : ∑ j, (p j : ℝ) * b j = + (∑ j, (a j : ℝ) * b j) + (1 - ∑ j, (a j : ℝ)) * b i₀ := by + have he (j : J) : (p j : ℝ) * b j = (a j : ℝ) * b j + + if j = i₀ then (1 - ∑ i, (a i : ℝ)) * b i₀ else 0 := by + by_cases h : j = i₀ + · subst j; simp only [p, ite_true, Rat.cast_add, Rat.cast_sub, + Rat.cast_one, Rat.cast_sum]; ring + · simp [p, h] + simp_rw [he] + rw [Finset.sum_add_distrib] + simp + rw [hformula] + have hextra := mul_le_mul_of_nonneg_left (hb i₀).2 (sub_nonneg.mpr hsum) + simp only [mul_one] at hextra + linarith + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/SumCoordinateNorm.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/SumCoordinateNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc873e457d4db06b2b1dd60ba1f7bb9c6de62ef0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/SumCoordinateNorm.lean @@ -0,0 +1,43 @@ +import Mathlib + +namespace OAI + +namespace LargeIndependentSets.CubeGradient +open scoped BigOperators NNReal +open MeasureTheory + +theorem sum_coordinate_norm_le {ι : Type*} [Fintype ι] [DecidableEq ι] + (A : (ι → ℝ) →L[ℝ] ℝ) : + (∑ i, |A (Pi.single i 1)|) ≤ ‖A‖ := by + let v : ι → ℝ := fun i => if 0 ≤ A (Pi.single i 1) then 1 else -1 + have hv : ‖v‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg (by norm_num : (0:ℝ) ≤ 1)).mpr + intro i + dsimp [v] + split_ifs <;> norm_num + have hvsum : (∑ i, |A (Pi.single i 1)|) = A v := by + conv_rhs => rw [← Finset.univ_sum_single v] + rw [map_sum] + apply Finset.sum_congr rfl + intro i _ + have he : Pi.single i (v i) = v i • (Pi.single i (1:ℝ)) := by + ext j + by_cases hj : j = i + · subst j; simp + · simp [hj] + rw [he, map_smul, smul_eq_mul] + dsimp [v] + split_ifs with hi + · simp [abs_of_nonneg hi] + · simp [abs_of_neg (lt_of_not_ge hi)] + rw [hvsum] + exact (le_abs_self (A v)).trans (by simpa only [Real.norm_eq_abs] using A.unit_le_opNorm v hv) + +theorem lipschitz_sum_partials {n : ℕ} {L : ℝ≥0} {f : (Fin n → ℝ) → ℝ} + (hf : LipschitzWith L f) (x : Fin n → ℝ) : + (∑ i, |fderiv ℝ f x (Pi.single i 1)|) ≤ L := + (sum_coordinate_norm_le (fderiv ℝ f x)).trans (norm_fderiv_le_of_lipschitz ℝ hf) + +end LargeIndependentSets.CubeGradient + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/Uniform.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/Uniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbf777deeafd850dca756eeaa8696265aa32ce92 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/Uniform.lean @@ -0,0 +1,48 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.RationalLaw + +namespace OAI + +namespace LargeIndependentSets.RationalLaw +open scoped BigOperators Classical +variable {I : Type*} [Fintype I] + +noncomputable def uniform (I : Type*) [Fintype I] [Nonempty I] : RationalLaw I where + weight _ := 1 / Fintype.card I + nonneg _ := by positivity + total := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + have h : (Fintype.card I : ℚ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + field_simp + +noncomputable def bind (p : RationalLaw I) {J : I → Type*} [∀ i, Fintype (J i)] + (q : ∀ i, RationalLaw (J i)) : RationalLaw (Sigma J) where + weight o := p.weight o.1 * (q o.1).weight o.2 + nonneg o := mul_nonneg (p.nonneg _) ((q _).nonneg _) + total := by + simp only [Fintype.sum_sigma, ← Finset.mul_sum, fun i => (q i).total, mul_one] + exact p.total + +noncomputable def pi [DecidableEq I] {J : I → Type*} [∀ i, Fintype (J i)] + (q : ∀ i, RationalLaw (J i)) : RationalLaw (∀ i, J i) where + weight x := ∏ i, (q i).weight (x i) + nonneg x := Finset.prod_nonneg (fun i _ => (q i).nonneg _) + total := by + rw [← Fintype.prod_sum] + simp only [fun i => (q i).total, Finset.prod_const_one] + +lemma expect_uniform (f : I → ℝ) [Nonempty I] : + (∑ i, ((uniform I).weight i : ℝ) * f i) = 𝔼 i, f i := by + simp only [uniform, Rat.cast_div, Rat.cast_one, Rat.cast_natCast, + Finset.expect_eq_sum_div_card, Finset.card_univ, ← Finset.mul_sum] + ring + +lemma expect_bind (p : RationalLaw I) {J : I → Type*} [∀ i, Fintype (J i)] + (q : ∀ i, RationalLaw (J i)) (f : Sigma J → ℝ) : + (∑ o, ((p.bind q).weight o : ℝ) * f o) = + ∑ i, (p.weight i : ℝ) * ∑ j, ((q i).weight j : ℝ) * f ⟨i,j⟩ := by + simp only [bind, Fintype.sum_sigma, Rat.cast_mul, mul_assoc, Finset.mul_sum] + +end LargeIndependentSets.RationalLaw + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Geometry/Witness.lean b/lean/OAI/Combinatorics/IndependentSets/Geometry/Witness.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a8b1756e09cd6e220a77df9fe10b35d1b8db908 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Geometry/Witness.lean @@ -0,0 +1,66 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.LabelCoverData + +namespace OAI + +namespace LargeIndependentSets + +instance (priority := 1100) mixedTupleComputableFintype {A B : Type*} [Fintype A] [Fintype B] + (n i : ℕ) : Fintype (MixedTuple A B n i) := + inferInstanceAs (Fintype {x : Fin n → B ⊕ A // ∀ h, (x h).isLeft = decide (h.val < i)}) + +instance mixedTupleDecidableEq {A B : Type*} [DecidableEq A] [DecidableEq B] + (n i : ℕ) : DecidableEq (MixedTuple A B n i) := + inferInstanceAs (DecidableEq {x : Fin n → B ⊕ A // ∀ h, (x h).isLeft = decide (h.val < i)}) + +namespace LayerImposed + +abbrev Witness (U V C : Type) (n : ℕ) := + Σ h : Fin n, MixedTuple U V n h.val × MixedTuple U V n (h.val+1) × C + +abbrev Arrow (U V L R : Type) (n : ℕ) := + Σ q : LayerQuestion U V n, Σ q' : LayerQuestion U V n, LayerAnswer L R q → LayerAnswer L R q' + +def valid {U V L R C : Type} (lc : LabelCoverData U V L R C) {n : ℕ} + (w : Witness U V C n) : Prop := + w.2.1.val w.1 = Sum.inr (lc.left w.2.2.2) ∧ + w.2.2.1.val w.1 = Sum.inl (lc.right w.2.2.2) ∧ + ∀ k, k ≠ w.1 → w.2.1.val k = w.2.2.1.val k + +instance valid_decidable {U V L R C : Type} [DecidableEq U] [DecidableEq V] + (lc : LabelCoverData U V L R C) {n : ℕ} (w : Witness U V C n) : Decidable (valid lc w) := + inferInstanceAs (Decidable (_ ∧ _ ∧ ∀ _, _ → _)) + +def arrow {U V L R C : Type} (lc : LabelCoverData U V L R C) {n : ℕ} + (w : Witness U V C n) : Arrow U V L R n := + ⟨⟨w.1.castSucc,w.2.1⟩,⟨w.1.succ,w.2.2.1⟩, mixedProject w.1 (lc.project w.2.2.2)⟩ + +def arrowImposed {U V L R C : Type} (lc : LabelCoverData U V L R C) {n : ℕ} + (a : Arrow U V L R n) : Prop := LayerImposed lc n a.1 a.2.1 a.2.2 + +lemma iff_witness {U V L R C : Type} (lc : LabelCoverData U V L R C) {n : ℕ} + (q q' : LayerQuestion U V n) (π : LayerAnswer L R q → LayerAnswer L R q') : + LayerImposed lc n q q' π ↔ + ∃ w : Witness U V C n, valid lc w ∧ arrow lc w = ⟨q,q',π⟩ := by + constructor + · intro h + cases h with + | adjacent k x y c hl hr ho => exact ⟨⟨k,x,y,c⟩,⟨hl,hr,ho⟩,rfl⟩ + · rintro ⟨w,hw,he⟩ + have h : arrowImposed lc (arrow lc w) := + .adjacent w.1 w.2.1 w.2.2.1 w.2.2.2 hw.1 hw.2.1 hw.2.2 + rw [he] at h + exact h + +instance imposed_decidable {U V L R C : Type} [Fintype U] [Fintype V] [Fintype C] + [Fintype L] [Fintype R] [DecidableEq U] [DecidableEq V] [DecidableEq L] [DecidableEq R] + (lc : LabelCoverData U V L R C) (n : ℕ) (q q' : LayerQuestion U V n) + (π : LayerAnswer L R q → LayerAnswer L R q') : Decidable (LayerImposed lc n q q' π) := by + letI : Fintype (Witness U V C n) := inferInstance + letI : DecidableEq (Arrow U V L R n) := inferInstance + exact decidable_of_iff _ (iff_witness lc q q' π).symm + +end LayerImposed +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Alphabet.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Alphabet.lean new file mode 100644 index 0000000000000000000000000000000000000000..da02b306e516a4b00d703ebba8ab661065c1671b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Alphabet.lean @@ -0,0 +1,417 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineAffineLookup +import OAI.Combinatorics.IndependentSets.Machines.MachineTableRows +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableWords +import OAI.Combinatorics.IndependentSets.Machines.MachineFixedDivMod +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudSelect +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingInternalRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow + +open Turing MachineComposition +open PCP +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def equalityBits : List Bool := + encodeWords (GraphTables.relationWords PreprocessingInternalRows.equalityRelation) + +theorem equalityBits_length_le : equalityBits.length ≤ 8192 := + GraphTables.relationBits_length_le _ + +def emittedBits (q x z r : Nat) : List Bool := + encodeWord x ++ encodeWord ((q + 1) * z + r) ++ equalityBits + +theorem emittedBits_length (q x z r : Nat) : + (emittedBits q x z r).length = x + ((q + 1) * z + r) + equalityBits.length + 2 := by + simp only [emittedBits, List.length_append, encodeWord_length] + omega + +theorem emittedBits_eq_row (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + {q : Nat} (tables : ∀ v, ExpanderTables.Table + (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PreprocessingCloudIndex.PaddedCloud t padding v) (p : Fin q) : + emittedBits q (PreprocessingRegularTables.vertexOrder t padding x.val).val + (PreprocessingInternalRows.selectedIndex t padding v + (PreprocessingInternalRows.localStep t padding tables v x p).1) + (PreprocessingInternalRows.localStep t padding tables v x p).2.val = + encodeWords (GraphTables.rowWords + (PreprocessingInternalRows.row t padding tables v x p)) := by + rw [MachineTableRows.rowBits_eq, PreprocessingInternalRows.row_tail, + PreprocessingInternalRows.row_reverse_selectedIndex, PreprocessingInternalRows.row_relation] + rfl + +theorem selected_rotation {n q : Nat} (table : ExpanderTables.Table n q) + (i : Fin n) (p : Fin q) : + (ExpanderTableWords.rotationWords table)[q * i.val + p.val]? = + some (q * (ExpanderTables.lookup table (i, p)).1.val + + (ExpanderTables.lookup table (i, p)).2.val) := by + simpa only [Nat.add_comm] using ExpanderTableWords.rotationWords_row_order table (i, p) + +theorem selected_rotation_div {n q : Nat} (positive : 0 < q) + (table : ExpanderTables.Table n q) (i : Fin n) (p : Fin q) : + (q * (ExpanderTables.lookup table (i, p)).1.val + + (ExpanderTables.lookup table (i, p)).2.val) / q = + (ExpanderTables.lookup table (i, p)).1.val := by + rw [Nat.add_comm, Nat.add_mul_div_left _ _ positive, + Nat.div_eq_of_lt (ExpanderTables.lookup table (i, p)).2.isLt, Nat.zero_add] + +theorem selected_rotation_mod {n q : Nat} (positive : 0 < q) + (table : ExpanderTables.Table n q) (i : Fin n) (p : Fin q) : + (q * (ExpanderTables.lookup table (i, p)).1.val + + (ExpanderTables.lookup table (i, p)).2.val) % q = + (ExpanderTables.lookup table (i, p)).2.val := by + obtain ⟨degree, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt positive) + rw [Nat.mul_add_mod_self_left, + Nat.mod_eq_of_lt (ExpanderTables.lookup table (i, p)).2.isLt] + +theorem rotationLookupTrace {n q : Nat} (table : ExpanderTables.Table n q) + (i : Fin n) (p : Fin q) (source : K) (tape : Fin 5 → K) + (distinct : Function.Injective tape) (outside : ∀ a, source ≠ tape a) + (labels : MachineAffineLookup.Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (code : ∀ l, program (labels l) = + MachineAffineLookup.instruction source tape q p.val labels exit l) + (base : K → List Bool) + (tableWord : base (tape 0) = encodeWords (ExpanderTableWords.rotationWords table)) + (scratchEmpty : base (tape 4) = []) (suffix : List Bool) + (sourceWord : base source = encodeWord i.val ++ suffix) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[MachineAffineLookup.steps + (ExpanderTableWords.rotationWords table) i.val q p.val] + (some ⟨some (labels .seed), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), MachineAffineLookup.finalTapes tape base + (ExpanderTableWords.rotationWords table) (q * i.val + p.val) + (q * (ExpanderTables.lookup table (i, p)).1.val + + (ExpanderTables.lookup table (i, p)).2.val)⟩ := + MachineAffineLookup.affineLookupTrace source tape distinct outside q p.val labels exit + program code base _ tableWord scratchEmpty i.val suffix sourceWord _ + (selected_rotation table i p) ambient register + +inductive FinishLabel + | seedReturn | copyReturn | restoreReturn | affine | restoreTarget | equality + | row (stage : MachineTableRows.Label) + | clearReverse | clearEquality + deriving DecidableEq, Fintype + +def finishFields (tape : Fin 8 → K) : Fin 3 → K := fun i => + if i = 0 then tape 0 else if i = 1 then tape 4 else tape 5 + +omit [DecidableEq K] in +@[simp] theorem finishFields_zero (tape : Fin 8 → K) : finishFields tape 0 = tape 0 := rfl +omit [DecidableEq K] in +@[simp] theorem finishFields_one (tape : Fin 8 → K) : finishFields tape 1 = tape 4 := rfl +omit [DecidableEq K] in +@[simp] theorem finishFields_two (tape : Fin 8 → K) : finishFields tape 2 = tape 5 := rfl + +def finishInstruction (q : Nat) (tape : Fin 8 → K) (labels : FinishLabel → Λ) + (exit : Option Λ) : FinishLabel → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .seedReturn => MachineUnaryAffineAt.seed (tape 4) 0 (labels .copyReturn) + | .copyReturn => MachineUnaryAffineAt.scan (tape 2) (tape 3) (tape 4) 1 + (labels .copyReturn) (labels .restoreReturn) + | .restoreReturn => Reduction.MachineTransfer.loopAt (tape 3) (tape 2) id false + (labels .restoreReturn) (some (labels .affine)) + | .affine => MachineUnaryAffineAt.scan (tape 1) (tape 3) (tape 4) (q + 1) + (labels .affine) (labels .restoreTarget) + | .restoreTarget => Reduction.MachineTransfer.loopAt (tape 3) (tape 1) id false + (labels .restoreTarget) (some (labels .equality)) + | .equality => pushWord (tape 5) equalityBits.reverse + (.goto fun _ => labels (.row .relationRead)) + | .row stage => MachineTableRows.routine (finishFields tape) (tape 6) (tape 7) (tape 3) + (fun l => labels (.row l)) (some (labels .clearReverse)) stage + | .clearReverse => MachineDrain.drain (tape 4) (labels .clearReverse) + (some (labels .clearEquality)) + | .clearEquality => MachineDrain.drain (tape 5) (labels .clearEquality) exit + +def finishSteps (q x z r outputLength : Nat) : Nat := + (2 * (r + 1) + 1) + 2 * (z + 1) + 1 + + (4 * (x + ((q + 1) * z + r) + equalityBits.length + 2) + 2 * outputLength + 9) + + (((q + 1) * z + r) + 2) + (equalityBits.length + 1) + +theorem finishSteps_le (q x z r outputLength : Nat) : + finishSteps q x z r outputLength ≤ + (5 * q + 7) * z + 7 * r + 4 * x + 2 * outputLength + 40986 := by + have h := equalityBits_length_le + unfold finishSteps + nlinarith + +theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {n m : Nat} + (first : f^[n] a = b) (second : f^[m] b = c) : f^[n + m] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem finishTrace (q : Nat) (tape : Fin 8 → K) (distinct : Function.Injective tape) + (labels : FinishLabel → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (code : ∀ l, program (labels l) = finishInstruction q tape labels exit l) + (base : K → List Bool) (x z r : Nat) + (tailWord : base (tape 0) = encodeWord x) + (targetWord : base (tape 1) = encodeWord z) + (returnWord : base (tape 2) = encodeWord r) + (scratchEmpty : base (tape 3) = []) (reverseEmpty : base (tape 4) = []) + (equalityEmpty : base (tape 5) = []) (rowEmpty : base (tape 6) = []) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[finishSteps q x z r (base (tape 7)).length] + (some ⟨some (labels .seedReturn), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), + Function.update base (tape 7) (base (tape 7) ++ emittedBits q x z r)⟩ := by + have hd (i j : Fin 8) (h : i ≠ j) : tape i ≠ tape j := fun e => h (distinct e) + let w := (q + 1) * z + r + let copied := Function.update base (tape 4) (encodeWord r) + let computed := Function.update base (tape 4) (encodeWord w) + let initialized := Function.update computed (tape 5) equalityBits + let appended := Function.update initialized (tape 7) + (base (tape 7) ++ emittedBits q x z r) + let drained := Function.update appended (tape 4) [] + have copyRun : (advance (TM2.step program))^[2 * (r + 1) + 1] + (some ⟨some (labels .seedReturn), (ambient, register), base⟩) = + some ⟨some (labels .affine), (ambient, none), copied⟩ := by + simpa only [copied, Nat.one_mul, Nat.add_zero, reverseEmpty, List.append_nil] using + MachineUnaryAffineAt.seededAffineTrace (tape 2) (tape 3) (tape 4) + (hd 2 3 (by decide)) (hd 2 4 (by decide)) (hd 3 4 (by decide)) 1 0 + (labels .seedReturn) (labels .copyReturn) (labels .restoreReturn) + (some (labels .affine)) program (code .seedReturn) (code .copyReturn) + (code .restoreReturn) base r [] (by simpa using returnWord) scratchEmpty ambient register + have affineFrame (u : Nat) : + MachineUnaryAffineAt.tapes (tape 1) (tape 3) (tape 4) base + (encodeWord z ++ []) [] (encodeWord u ++ []) = + Function.update base (tape 4) (encodeWord u) := by + simp only [List.append_nil] + rw [← targetWord, ← scratchEmpty] + simp only [MachineUnaryAffineAt.tapes, MachineCopy.forkTapes, Function.update_eq_self] + have affineRun : (advance (TM2.step program))^[2 * (z + 1)] + (some ⟨some (labels .affine), (ambient, none), copied⟩) = + some ⟨some (labels .equality), (ambient, none), computed⟩ := by + simpa only [affineFrame, copied, computed, w] using + MachineUnaryAffineAt.affineTrace (tape 1) (tape 3) (tape 4) + (hd 1 3 (by decide)) (hd 1 4 (by decide)) (hd 3 4 (by decide)) (q + 1) + (labels .affine) (labels .restoreTarget) (some (labels .equality)) program + (code .affine) (code .restoreTarget) base z r [] [] ambient none + have initRun : (advance (TM2.step program))^[1] + (some ⟨some (labels .equality), (ambient, none), computed⟩) = + some ⟨some (labels (.row .relationRead)), (ambient, none), initialized⟩ := by + change some (TM2.stepAux (program (labels .equality)) _ _) = _ + rw [code] + simp [finishInstruction, stepAux_pushWord, TM2.stepAux, computed, initialized, + hd 5 4 (by decide), equalityEmpty] + have hfields : ∀ i, finishFields tape i ≠ tape 6 ∧ finishFields tape i ≠ tape 3 := by + intro i + fin_cases i + all_goals exact ⟨hd _ _ (by decide), hd _ _ (by decide)⟩ + have hbits : MachineTableRows.fieldBits (finishFields tape) initialized = + emittedBits q x z r := by + simp [MachineTableRows.fieldBits, initialized, computed, finishFields, tailWord, + hd 0 4 (by decide), hd 0 5 (by decide), hd 4 5 (by decide), emittedBits, w] + have hsize : MachineTableRows.fieldSize (finishFields tape) initialized = + x + w + equalityBits.length + 2 := by + rw [← MachineTableRows.fieldBits_length, hbits, emittedBits_length] + have hout : initialized (tape 7) = base (tape 7) := by + simp [initialized, computed, hd 7 4 (by decide), hd 7 5 (by decide)] + have rowRun : (advance (TM2.step program))^[ + 4 * (x + w + equalityBits.length + 2) + 2 * (base (tape 7)).length + 9] + (some ⟨some (labels (.row .relationRead)), (ambient, none), initialized⟩) = + some ⟨some (labels .clearReverse), (ambient, none), appended⟩ := by + simpa only [hbits, hsize, hout, appended] using + MachineTableRows.appendTrace (finishFields tape) (tape 6) (tape 7) (tape 3) + hfields (hd 6 7 (by decide)) (hd 6 3 (by decide)) (hd 7 3 (by decide)) + (fun l => labels (.row l)) (some (labels .clearReverse)) program + (fun l => code (.row l)) initialized + (by simp [initialized, computed, hd 6 4 (by decide), hd 6 5 (by decide), rowEmpty]) + (by simp [initialized, computed, hd 3 4 (by decide), hd 3 5 (by decide), scratchEmpty]) + ambient none + have hreverse : appended (tape 4) = encodeWord w := by + simp [appended, initialized, computed, hd 4 7 (by decide), hd 4 5 (by decide)] + have reverseRun : (advance (TM2.step program))^[w + 2] + (some ⟨some (labels .clearReverse), (ambient, none), appended⟩) = + some ⟨some (labels .clearEquality), (ambient, none), drained⟩ := by + have h := MachineDrain.drainTrace (tape 4) (labels .clearReverse) + (some (labels .clearEquality)) program (code .clearReverse) + appended (appended (tape 4)) ambient none + rw [Function.update_eq_self, hreverse, encodeWord_length] at h + exact h + have hequality : drained (tape 5) = equalityBits := by + simp [drained, appended, initialized, hd 5 4 (by decide), hd 5 7 (by decide)] + have finalFrame : Function.update drained (tape 5) [] = + Function.update base (tape 7) (base (tape 7) ++ emittedBits q x z r) := by + funext k + by_cases h4 : k = tape 4 + · subst k + simp [drained, hd 4 5 (by decide), hd 4 7 (by decide), reverseEmpty] + · by_cases h5 : k = tape 5 + · subst k + simp [hd 5 7 (by decide), equalityEmpty] + · by_cases h7 : k = tape 7 + · subst k + simp [drained, appended, h4, h5] + · simp [drained, appended, initialized, computed, h4, h5, h7] + have equalityRun : (advance (TM2.step program))^[equalityBits.length + 1] + (some ⟨some (labels .clearEquality), (ambient, none), drained⟩) = + some ⟨exit, (ambient, none), + Function.update base (tape 7) (base (tape 7) ++ emittedBits q x z r)⟩ := by + have h := MachineDrain.drainTrace (tape 5) (labels .clearEquality) exit program + (code .clearEquality) drained (drained (tape 5)) ambient none + rw [Function.update_eq_self, hequality, finalFrame] at h + exact h + exact joinTrace (joinTrace (joinTrace (joinTrace (joinTrace + copyRun affineRun) initRun) rowRun) reverseRun) equalityRun + +inductive RotorLabel (q : Nat) + | lookup (stage : MachineAffineLookup.Label) + | initialize | divide | emit (r : Fin q) + deriving DecidableEq, Fintype + +def rotorLookupTapes (tape : Fin 8 → K) (j : Fin 5) : K := + tape ⟨j.val + 1, by omega⟩ + +omit [DecidableEq K] in +theorem rotorLookupTapes_injective (tape : Fin 8 → K) (h : Function.Injective tape) : + Function.Injective (rotorLookupTapes tape) := by + intro i j hij + have hv := congrArg Fin.val (h hij) + apply Fin.ext + simpa only [Fin.val_mk, Nat.add_left_inj] using hv + +omit [DecidableEq K] in +theorem rotorLookupTapes_outside (tape : Fin 8 → K) (h : Function.Injective tape) + (i : Fin 5) : tape 0 ≠ rotorLookupTapes tape i := by + intro he + have hv := congrArg Fin.val (h he) + change 0 = i.val + 1 at hv + omega + +def rotorInstruction (q : Nat) (positive : 0 < q) (p : Fin q) + (tape : Fin 8 → K) (labels : RotorLabel q → Λ) (exit : Option Λ) : + RotorLabel q → TM2.Stmt (Alphabet (K := K)) Λ (MachineFixedDivMod.State σ q) + | .lookup stage => MachineAffineLookup.instruction (tape 0) (rotorLookupTapes tape) + q p.val (fun l => labels (.lookup l)) (some (labels .initialize)) stage + | .initialize => .push (tape 6) (fun _ => false) + (.push (tape 7) (fun _ => false) (.goto fun _ => labels .divide)) + | .divide => MachineFixedDivMod.scanLoop q positive (tape 4) (tape 6) + (labels .divide) (fun r => labels (.emit r)) + | .emit r => MachineFixedDivMod.emitter q positive (tape 7) exit r + +def rotorFinalTapes {n q : Nat} (table : ExpanderTables.Table n q) (i : Fin n) (p : Fin q) + (tape : Fin 8 → K) (base : K → List Bool) : K → List Bool := + MachineFixedDivMod.unaryTapes (tape 4) (tape 6) (tape 7) + (MachineAffineLookup.finalTapes (rotorLookupTapes tape) base + (ExpanderTableWords.rotationWords table) (q * i.val + p.val) + (q * (ExpanderTables.lookup table (i, p)).1.val + + (ExpanderTables.lookup table (i, p)).2.val)) + 0 (ExpanderTables.lookup table (i, p)).1.val + (ExpanderTables.lookup table (i, p)).2.val [] [] [] + +def rotorSteps {n q : Nat} (table : ExpanderTables.Table n q) (i : Fin n) (p : Fin q) : Nat := + MachineAffineLookup.steps (ExpanderTableWords.rotationWords table) i.val q p.val + + 1 + (q * (ExpanderTables.lookup table (i, p)).1.val + + (ExpanderTables.lookup table (i, p)).2.val + 2) + +theorem rotorTrace {n q : Nat} (positive : 0 < q) (table : ExpanderTables.Table n q) + (i : Fin n) (p : Fin q) (tape : Fin 8 → K) (distinct : Function.Injective tape) + (labels : RotorLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (MachineFixedDivMod.State σ q)) + (code : ∀ l, program (labels l) = rotorInstruction q positive p tape labels exit l) + (base : K → List Bool) + (sourceWord : base (tape 0) = encodeWord i.val) + (tableWord : base (tape 1) = encodeWords (ExpanderTableWords.rotationWords table)) + (flatEmpty : base (tape 4) = []) (scratchEmpty : base (tape 5) = []) + (localEmpty : base (tape 6) = []) (returnEmpty : base (tape 7) = []) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[rotorSteps table i p] + (some ⟨some (labels (.lookup .seed)), + ((ambient, MachineFixedDivMod.residue q positive 0), register), base⟩) = + some ⟨exit, ((ambient, MachineFixedDivMod.residue q positive 0), none), + rotorFinalTapes table i p tape base⟩ := by + have hd (a b : Fin 8) (h : a ≠ b) : tape a ≠ tape b := fun e => h (distinct e) + let a := q * (ExpanderTables.lookup table (i, p)).1.val + + (ExpanderTables.lookup table (i, p)).2.val + let looked := MachineAffineLookup.finalTapes (rotorLookupTapes tape) base + (ExpanderTableWords.rotationWords table) (q * i.val + p.val) a + let initialized := Function.update (Function.update looked (tape 6) (encodeWord 0)) + (tape 7) (encodeWord 0) + have lookupRun : (advance (TM2.step program))^[MachineAffineLookup.steps + (ExpanderTableWords.rotationWords table) i.val q p.val] + (some ⟨some (labels (.lookup .seed)), + ((ambient, MachineFixedDivMod.residue q positive 0), register), base⟩) = + some ⟨some (labels .initialize), + ((ambient, MachineFixedDivMod.residue q positive 0), none), looked⟩ := by + exact rotationLookupTrace table i p (tape 0) (rotorLookupTapes tape) + (rotorLookupTapes_injective tape distinct) (rotorLookupTapes_outside tape distinct) + (fun l => labels (.lookup l)) (some (labels .initialize)) program + (fun l => code (.lookup l)) base tableWord scratchEmpty [] + (by simpa using sourceWord) (ambient, MachineFixedDivMod.residue q positive 0) register + have lookedOther (k : Fin 8) (h2 : k ≠ 2) (h3 : k ≠ 3) (h4 : k ≠ 4) : + looked (tape k) = base (tape k) := by + exact MachineAffineLookup.finalTapes_other (rotorLookupTapes tape) base + (ExpanderTableWords.rotationWords table) (q * i.val + p.val) a (tape k) + (hd k 2 h2) (hd k 3 h3) (hd k 4 h4) + have lookedFlat : looked (tape 4) = encodeWord a := by + change MachineAffineLookup.finalTapes (rotorLookupTapes tape) base + (ExpanderTableWords.rotationWords table) (q * i.val + p.val) a + (rotorLookupTapes tape 3) = _ + rw [MachineAffineLookup.finalTapes_output] + change encodeWord a ++ base (tape 4) = _ + rw [flatEmpty, List.append_nil] + have initRun : (advance (TM2.step program))^[1] + (some ⟨some (labels .initialize), + ((ambient, MachineFixedDivMod.residue q positive 0), none), looked⟩) = + some ⟨some (labels .divide), + ((ambient, MachineFixedDivMod.residue q positive 0), none), initialized⟩ := by + change some (TM2.stepAux (program (labels .initialize)) _ _) = _ + rw [code] + simp [rotorInstruction, TM2.stepAux, initialized, encodeWord, + lookedOther 6 (by decide) (by decide) (by decide), + lookedOther 7 (by decide) (by decide) (by decide), + hd 7 6 (by decide), localEmpty, returnEmpty] + have initialFrame : MachineFixedDivMod.unaryTapes (tape 4) (tape 6) (tape 7) + looked a 0 0 [] [] [] = initialized := by + simp only [MachineFixedDivMod.unaryTapes, MachineFixedDivMod.tapes, + MachineCopy.forkTapes, List.append_nil, ← lookedFlat, Function.update_eq_self, + initialized] + have finalFrame : MachineFixedDivMod.unaryTapes (tape 4) (tape 6) (tape 7) + looked 0 (a / q) (a % q) [] [] [] = rotorFinalTapes table i p tape base := by + dsimp only [a] + rw [selected_rotation_div positive, selected_rotation_mod positive] + rfl + have divideRun : (advance (TM2.step program))^[a + 2] + (some ⟨some (labels .divide), + ((ambient, MachineFixedDivMod.residue q positive 0), none), initialized⟩) = + some ⟨exit, ((ambient, MachineFixedDivMod.residue q positive 0), none), + rotorFinalTapes table i p tape base⟩ := by + simpa only [initialFrame, finalFrame] using + MachineFixedDivMod.divModTrace q positive (tape 4) (tape 6) (tape 7) + (hd 4 6 (by decide)) (hd 4 7 (by decide)) (hd 6 7 (by decide)) + (labels .divide) (fun r => labels (.emit r)) exit program (code .divide) + (fun r => code (.emit r)) looked a [] [] [] ambient none + exact joinTrace (joinTrace lookupRun initRun) divideRun + +theorem rotorSteps_le {n q : Nat} (table : ExpanderTables.Table n q) (i : Fin n) (p : Fin q) : + rotorSteps table i p ≤ 2 * i.val + + 5 * (encodeWords (ExpanderTableWords.rotationWords table)).length + n * q + 8 := by + have hl := MachineAffineLookup.steps_le (ExpanderTableWords.rotationWords table) + i.val q p.val _ (selected_rotation table i p) + have hb := (ExpanderTables.rowIndex n q (ExpanderTables.lookup table (i, p))).isLt + rw [ExpanderTables.rowIndex_val] at hb + unfold rotorSteps + omega + +inductive SelectExtraTape + | localIndex | owner | cloudSize | prefixOffset | darts + | savedLeft | savedRight | localWork | sizeWork + deriving DecidableEq + +instance : Fintype SelectExtraTape where + elems := {.localIndex, .owner, .cloudSize, .prefixOffset, .darts, .savedLeft, .savedRight, + .localWork, .sizeWork} + complete value := by cases value <;> simp + +abbrev SelectTape := MachineCloudSelect.Tape ⊕ SelectExtraTape +abbrev RawSelectAlphabet : SelectTape → Type := + MachineEmbedding.Alphabet MachineCloudSelect.Alphabet (fun _ : SelectExtraTape => Bool) + +end IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/AmbientRelation.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/AmbientRelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..16c074fcafb2b334ebddac7c1728a25eb304f7ef --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/AmbientRelation.lean @@ -0,0 +1,246 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupCore +import OAI.Combinatorics.IndependentSets.PCP.Emitter +import OAI.Combinatorics.IndependentSets.PCP.Ambient +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFMachine + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine +open Turing +open PCP +section AmbientRelation + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev State (σ : Type) := ((σ × Buffer 4096) × Unit) × Option Bool + +def readRelationAt (source : K) (exit : Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (State σ) := + MachineControl.statement id (readerStateEquiv σ 4096) + (readUnarySlots source (List.ofFn id) (.goto fun _ => exit)) + +theorem stepAux_readRelationAt (source : K) (exit : Λ) (ambient : σ) + (buffer : Buffer 4096) (unitState : Unit) (register : Option Bool) + (relation : GraphTables.RelationTable) (tapes : K → List Bool) (suffix : List Bool) + (hinput : tapes source = encodeWords (GraphTables.relationWords relation) ++ suffix) : + TM2.stepAux (readRelationAt source exit) (((ambient, buffer), unitState), register) tapes = + ⟨some exit, (((ambient, fun i => relation[i]), unitState), register), + Function.update tapes source suffix⟩ := by + change TM2.stepAux (MachineControl.statement id (readerStateEquiv σ 4096) + (readUnarySlots source (List.ofFn id) (.goto fun _ => exit))) + ((readerStateEquiv σ 4096) (((ambient, unitState), register), buffer)) tapes = _ + rw [MachineControl.stepAux_simulation] + rw [stepAux_readUnaryAll source _ _ (fun i => relation[i]) tapes suffix + (by simpa only [unaryBits_relation] using hinput)] + rfl + +end AmbientRelation + +namespace Program + +open PCP.AlphabetTable + +inductive Tape + | input | output | accumulator | scratch | vertices | darts | tail | head | rowIndex + | archive | reverseIndex | scanWork | indexWork + deriving DecidableEq + +instance : Fintype Tape where + elems := {.input, .output, .accumulator, .scratch, .vertices, .darts, .tail, .head, .rowIndex, + .archive, .reverseIndex, .scanWork, .indexWork} + complete value := by cases value <;> simp + +abbrev Ambient := Unit × Buffer 4096 +abbrev Plan := List (Emitter.Command 5 Ambient 36864) + +def values (vertices darts tail head row : Nat) : Fin 5 → Nat := + Fin.cases vertices (Fin.cases darts (Fin.cases tail (Fin.cases head (fun _ => row)))) + +def headerPlan : Plan := + Emitter.affineCommands [(0, 6), (1, 36864)] (fun _ => 0) ++ + Emitter.affineCommands [(1, 40960)] (fun _ => 0) + +theorem headerPlan_length : headerPlan.length = 7 := by + simp [headerPlan] + +theorem headerPlan_bits (vertices darts tail head row : Nat) (ambient : Ambient) : + headerPlan.flatMap (Emitter.commandBits (values vertices darts tail head row) ambient) = + encodeWords [6 * vertices + 36864 * darts, 40960 * darts] := by + rw [headerPlan, List.flatMap_append, Emitter.affineCommands_bits, + Emitter.affineCommands_bits] + simp [Emitter.affineValue, values, encodeWords] + rfl + +def source : Fin 5 → Tape := + Fin.cases .vertices (Fin.cases .darts (Fin.cases .tail (Fin.cases .head (fun _ => .rowIndex)))) + +inductive Label (headerCount rowCount : Nat) + | copyFirst | copySecond | startVertices | readVertices | startDarts | readDarts | seedIndex + | header (label : Emitter.Label headerCount 36864) + | headerClearTail | headerClearHead + | guard | startTail | readTail | startReverse | readReverse + | headTableFirst | headTableSecond | headIndexFirst | headIndexSecond + | headHeaderVertices | headHeaderDarts | headLookup (label : Lookup.Label) + | readRelation + | row (label : Emitter.Label rowCount 36864) + | clearTail | clearHead | clearReverse | nextRow | reverseOutput + deriving DecidableEq + +deriving instance Fintype for Label + +def guard {hc rc : Nat} (again finish : Label hc rc) : + TM2.Stmt (fun _ : Tape => Bool) (Label hc rc) (State Unit) := + .peek .input (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.load (fun state => (state.1, none)) (.goto fun _ => again)) + (.load (fun state => (state.1, none)) (.goto fun _ => finish))) + +def program (headerPlan rowPlan : Plan) : + Label headerPlan.length rowPlan.length → + TM2.Stmt (fun _ : Tape => Bool) (Label headerPlan.length rowPlan.length) (State Unit) + | .copyFirst => Reduction.MachineTransfer.loopAt .input .scratch id false .copyFirst + (some .copySecond) + | .copySecond => MachineCopy.forkLoop .scratch .input .archive false .copySecond + (some .startVertices) + | .startVertices => Hastad.SourceMachine.fieldStart .vertices .readVertices + | .readVertices => Hastad.SourceMachine.fieldLoop .input .vertices .readVertices (some .startDarts) + | .startDarts => Hastad.SourceMachine.fieldStart .darts .readDarts + | .readDarts => Hastad.SourceMachine.fieldLoop .input .darts .readDarts (some .seedIndex) + | .seedIndex => .push .rowIndex (fun _ => false) + (.push .tail (fun _ => false) (.push .head (fun _ => false) + (.goto fun _ => .header (Emitter.labelAt headerPlan.length 36864 0 .entry)))) + | .header label => Emitter.statement (Emitter.listCommands headerPlan) + source .scratch .accumulator Label.header (some .headerClearTail) label + | .headerClearTail => MachineLookup.discard .tail .headerClearTail .headerClearHead + | .headerClearHead => MachineLookup.discard .head .headerClearHead .guard + | .guard => guard .startTail .reverseOutput + | .startTail => Hastad.SourceMachine.fieldStart .tail .readTail + | .readTail => Hastad.SourceMachine.fieldLoop .input .tail .readTail (some .startReverse) + | .startReverse => Hastad.SourceMachine.fieldStart .reverseIndex .readReverse + | .readReverse => Hastad.SourceMachine.fieldLoop .input .reverseIndex .readReverse + (some .headTableFirst) + | .headTableFirst => Reduction.MachineTransfer.loopAt .archive .scratch id false + .headTableFirst (some .headTableSecond) + | .headTableSecond => MachineCopy.forkLoop .scratch .archive .scanWork false + .headTableSecond (some .headIndexFirst) + | .headIndexFirst => Reduction.MachineTransfer.loopAt .reverseIndex .scratch id false + .headIndexFirst (some .headIndexSecond) + | .headIndexSecond => MachineCopy.forkLoop .scratch .reverseIndex .indexWork false + .headIndexSecond (some .headHeaderVertices) + | .headHeaderVertices => MachineLookup.discard .scanWork .headHeaderVertices .headHeaderDarts + | .headHeaderDarts => MachineLookup.discard .scanWork .headHeaderDarts (.headLookup .guard) + | .headLookup label => Lookup.statement 64 .indexWork .scanWork .head Label.headLookup + (some .readRelation) label + | .readRelation => readRelationAt .input + (.row (Emitter.labelAt rowPlan.length 36864 0 .entry)) + | .row label => Emitter.statement (Emitter.listCommands rowPlan) + source .scratch .accumulator Label.row (some .clearTail) label + | .clearTail => MachineLookup.discard .tail .clearTail .clearHead + | .clearHead => MachineLookup.discard .head .clearHead .clearReverse + | .clearReverse => MachineLookup.discard .reverseIndex .clearReverse .nextRow + | .nextRow => .push .rowIndex (fun _ => true) (.goto fun _ => .guard) + | .reverseOutput => Reduction.MachineTransfer.loopAt .accumulator .output id false + .reverseOutput none + +def machine (headerPlan rowPlan : Plan) : FinTM2 where + K := Tape + k₀ := .input + k₁ := .output + Γ _ := Bool + Λ := Label headerPlan.length rowPlan.length + main := .copyFirst + σ := State Unit + initialState := ((((), fun _ => false), ()), none) + m := program headerPlan rowPlan + +def headRoles : Fin 6 → Tape := + Fin.cases .archive (Fin.cases .reverseIndex (Fin.cases .scanWork + (Fin.cases .indexWork (Fin.cases .head (fun _ => .scratch))))) + +theorem headRoles_injective : Function.Injective headRoles := by + decide + +def headPhaseInTime (headerPlan rowPlan : Plan) (base : Tape → List Bool) + (table : GenericGraphTables.Table 64) (e : Fin table.darts) + (hTable : base .archive = GenericGraphTables.tableBits table) + (hReverse : base .reverseIndex = encodeWord (Lookup.headIndex table e).val) + (hHead : base .head = []) (hScratch : base .scratch = []) (ambient : Ambient) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .headTableFirst, ((ambient, ()), none), base⟩ + (some ⟨some .readRelation, ((ambient, ()), none), + Lookup.headLookupTapes headRoles base table e⟩) + (Lookup.headTimePolynomial.eval (GenericGraphTables.tableBits table).length) := + Lookup.headLookupInTime headRoles headRoles_injective + .headTableFirst .headTableSecond .headIndexFirst .headIndexSecond + .headHeaderVertices .headHeaderDarts Label.headLookup (some .readRelation) + (program headerPlan rowPlan) rfl rfl rfl rfl rfl rfl (fun _ => rfl) + base table e hTable hReverse hHead hScratch (ambient, ()) none + +def workingTapes (vertices darts row : Nat) (input tail head accumulator : List Bool) : + Tape → List Bool + | .input => input + | .output => [] + | .accumulator => accumulator + | .scratch => [] + | .vertices => encodeWord vertices + | .darts => encodeWord darts + | .tail => tail + | .head => head + | .rowIndex => encodeWord row + | .archive | .reverseIndex | .scanWork | .indexWork => [] + +theorem workingTapes_operands (vertices darts row tail head : Nat) + (input accumulator : List Bool) : + ∀ i, workingTapes vertices darts row input (encodeWord tail) (encodeWord head) + accumulator (source i) = encodeWord (values vertices darts tail head row i) := by + intro i + fin_cases i <;> rfl + +theorem update_working_input (vertices darts row : Nat) + (input tail head accumulator replacement : List Bool) : + Function.update (workingTapes vertices darts row input tail head accumulator) Tape.input + replacement = workingTapes vertices darts row replacement tail head accumulator := by + funext tape + cases tape <;> simp [workingTapes, Function.update] + +theorem update_working_tail (vertices darts row : Nat) + (input tail head accumulator replacement : List Bool) : + Function.update (workingTapes vertices darts row input tail head accumulator) Tape.tail + replacement = workingTapes vertices darts row input replacement head accumulator := by + funext tape + cases tape <;> simp [workingTapes, Function.update] + +theorem update_working_head (vertices darts row : Nat) + (input tail head accumulator replacement : List Bool) : + Function.update (workingTapes vertices darts row input tail head accumulator) Tape.head + replacement = workingTapes vertices darts row input tail replacement accumulator := by + funext tape + cases tape <;> simp [workingTapes, Function.update] + +theorem update_working_accumulator (vertices darts row : Nat) + (input tail head accumulator replacement : List Bool) : + Function.update (workingTapes vertices darts row input tail head accumulator) Tape.accumulator + replacement = workingTapes vertices darts row input tail head replacement := by + funext tape + cases tape <;> simp [workingTapes, Function.update] + +theorem update_working_rowIndex (vertices darts row : Nat) + (input tail head accumulator : List Bool) : + Function.update (workingTapes vertices darts row input tail head accumulator) Tape.rowIndex + (true :: encodeWord row) = + workingTapes vertices darts (row + 1) input tail head accumulator := by + funext tape + cases tape <;> simp [workingTapes, Function.update, encodeWord, List.replicate_succ] + +theorem source_ne_scratch (i : Fin 5) : source i ≠ Tape.scratch := by + fin_cases i <;> decide + +theorem source_ne_accumulator (i : Fin 5) : source i ≠ Tape.accumulator := by + fin_cases i <;> decide + +end Program + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Basic.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..3912b6bc9c06546be3b59a1282128d4173a9b963 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Basic.lean @@ -0,0 +1,457 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAffine +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudPrefix +import OAI.Combinatorics.IndependentSets.Machines.MachinePreservingLookupClean + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTable + +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP + +namespace Header + +inductive Extra + | m | index | work | scratch | vertices | darts | emit | output + deriving DecidableEq + +instance : Fintype Extra where + elems := {.m, .index, .work, .scratch, .vertices, .darts, .emit, .output} + complete value := by cases value <;> simp + +abbrev Tape := MachineCloudPrefix.Tape ⊕ Extra +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := MachineCloudPrefix.State σ + +def tableTape : Tape := .inl (.inner .table) +def nTape : Tape := .inl .bound +def queryTape : Tape := .inl (.inner .query) +def fuelTape : Tape := .inl .remaining +def sumTape : Tape := .inl .total +def mTape : Tape := .inr .m +def indexTape : Tape := .inr .index +def workTape : Tape := .inr .work +def scratchTape : Tape := .inr .scratch +def verticesTape : Tape := .inr .vertices +def dartsTape : Tape := .inr .darts +def emitTape : Tape := .inr .emit +def outputTape : Tape := .inr .output + +def memory (inner : MachineCloudPrefix.Tape → List Bool) + (m index work scratch vertices darts emit output : List Bool) : Tape → List Bool + | .inl k => inner k + | .inr .m => m + | .inr .index => index + | .inr .work => work + | .inr .scratch => scratch + | .inr .vertices => vertices + | .inr .darts => darts + | .inr .emit => emit + | .inr .output => output + +def frame (t n v f s m i w a N R e o : List Bool) : Tape → List Bool := + memory (MachineCloudPrefix.frame t v [] [] [] n f s) m i w a N R e o + +@[simp] theorem frame_table (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o tableTape = t := rfl +@[simp] theorem frame_n (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o nTape = n := rfl +@[simp] theorem frame_query (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o queryTape = v := rfl +@[simp] theorem frame_fuel (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o fuelTape = f := rfl +@[simp] theorem frame_sum (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o sumTape = s := rfl +@[simp] theorem frame_m (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o mTape = m := rfl +@[simp] theorem frame_index (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o indexTape = i := rfl +@[simp] theorem frame_work (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o workTape = w := rfl +@[simp] theorem frame_scratch (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o scratchTape = a := rfl +@[simp] theorem frame_vertices (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o verticesTape = N := rfl +@[simp] theorem frame_darts (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o dartsTape = R := rfl +@[simp] theorem frame_emit (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o emitTape = e := rfl +@[simp] theorem frame_output (t n v f s m i w a N R e o : List Bool) : + frame t n v f s m i w a N R e o outputTape = o := rfl + +@[simp] theorem update_frame_table (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) tableTape x = + frame x n v f s m i w a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_n (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) nTape x = + frame t x v f s m i w a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_query (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) queryTape x = + frame t n x f s m i w a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_fuel (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) fuelTape x = + frame t n v x s m i w a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_sum (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) sumTape x = + frame t n v f x m i w a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_m (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) mTape x = + frame t n v f s x i w a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_index (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) indexTape x = + frame t n v f s m x w a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_work (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) workTape x = + frame t n v f s m i x a N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_scratch (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) scratchTape x = + frame t n v f s m i w x N R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_vertices (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) verticesTape x = + frame t n v f s m i w a x R e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_darts (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) dartsTape x = + frame t n v f s m i w a N x e o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_emit (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) emitTape x = + frame t n v f s m i w a N R x o := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_output (t n v f s m i w a N R e o x : List Bool) : + Function.update (frame t n v f s m i w a N R e o) outputTape x = + frame t n v f s m i w a N R e x := by + funext k + cases k with + | inl k => + cases k with + | inner j => cases j <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr j => cases j <;> rfl + +inductive Field + | vertices | darts + deriving DecidableEq + +instance : Fintype Field where + elems := {.vertices, .darts} + complete value := by cases value <;> simp + +inductive CopyPhase + | count | rEmit | nEmit + deriving DecidableEq + +instance : Fintype CopyPhase where + elems := {.count, .rEmit, .nEmit} + complete value := by cases value <;> simp + +inductive Label + | init | seedM | clearIndex + | lookup (field : Field) (label : MachinePreservingLookupClean.Label) + | prefix (label : MachineCloudPrefix.Label) + | copyFirst (phase : CopyPhase) | copySecond (phase : CopyPhase) + | add | scaleSeed | scaleScan | scaleRestore + | appendFirst | appendSecond | appendThird + | cleanupZeros | clearQuery | done + deriving DecidableEq, Fintype + +def fieldTape : Field → Tape + | .vertices => nTape + | .darts => mTape + +def fieldExit : Field → Label + | .vertices => .seedM + | .darts => .clearIndex + +def lookupSlots (field : Field) : Fin 5 → Tape := + ![tableTape, indexTape, workTape, fieldTape field, scratchTape] + +theorem lookupSlots_injective (field : Field) : Function.Injective (lookupSlots field) := by + intro i j h + cases field <;> fin_cases i <;> fin_cases j <;> + simp_all [lookupSlots, fieldTape, tableTape, indexTape, workTape, nTape, mTape, scratchTape] + +def copySource : CopyPhase → Tape + | .count => mTape + | .rEmit => dartsTape + | .nEmit => verticesTape + +def copyDestination : CopyPhase → Tape + | .count => verticesTape + | .rEmit | .nEmit => emitTape + +def copyExit : CopyPhase → Label + | .count => .add + | .rEmit => .copyFirst .nEmit + | .nEmit => .appendFirst + +def prefixView : Tape → Option MachineCloudPrefix.Tape + | .inl k => some k + | .inr _ => none + +theorem prefixView_left (k : MachineCloudPrefix.Tape) : prefixView (.inl k) = some k := rfl + +theorem prefixView_right (j : Tape) (k : MachineCloudPrefix.Tape) + (h : prefixView j = some k) : Sum.inl k = j := by + cases j <;> simp_all [prefixView] + +theorem prefixTapes (inner : MachineCloudPrefix.Tape → List Bool) (extra : Tape → List Bool) : + MachineCloudPadding.Placement.tapes prefixView inner extra = + memory inner (extra mTape) (extra indexTape) (extra workTape) (extra scratchTape) + (extra verticesTape) (extra dartsTape) (extra emitTape) (extra outputTape) := by + funext j + cases j with + | inl k => rfl + | inr k => cases k <;> rfl + +variable {σ : Type} + +def program (q : Nat) : Label → TM2.Stmt Alphabet Label (State σ) + | .init => .push indexTape (fun _ => false) (.goto fun _ => .lookup .vertices (.run .copyFirst)) + | .seedM => .push indexTape (fun _ => true) (.goto fun _ => .lookup .darts (.run .copyFirst)) + | .clearIndex => .pop indexTape (fun state _ => (state.1, none)) + (.goto fun _ => .prefix .init) + | .lookup field l => MachinePreservingLookupClean.statement (lookupSlots field) + (Label.lookup field) (some (fieldExit field)) l + | .prefix l => MachineCloudPadding.Placement.statement Sum.inl Label.prefix + (some (.copyFirst .count)) (MachineCloudPrefix.program l) + | .copyFirst phase => Reduction.MachineTransfer.loopAt (copySource phase) scratchTape + id false (.copyFirst phase) (some (.copySecond phase)) + | .copySecond phase => MachineCopy.forkLoop scratchTape (copySource phase) (copyDestination phase) + false (.copySecond phase) (some (copyExit phase)) + | .add => MachineUnaryAddAt.loop sumTape verticesTape .add (some .scaleSeed) + | .scaleSeed => MachineUnaryAffineAt.seed dartsTape 0 .scaleScan + | .scaleScan => MachineUnaryAffineAt.scan verticesTape scratchTape dartsTape (q + 1) + .scaleScan .scaleRestore + | .scaleRestore => Reduction.MachineTransfer.loopAt scratchTape verticesTape id false + .scaleRestore (some (.copyFirst .rEmit)) + | .appendFirst => Reduction.MachineTransfer.loopAt outputTape scratchTape id false + .appendFirst (some .appendSecond) + | .appendSecond => Reduction.MachineTransfer.loopAt emitTape scratchTape id false + .appendSecond (some .appendThird) + | .appendThird => Reduction.MachineTransfer.loopAt scratchTape outputTape id false + .appendThird (some .cleanupZeros) + | .cleanupZeros => .pop sumTape (fun state _ => (state.1, none)) + (.pop fuelTape (fun state _ => (state.1, none)) (.goto fun _ => .clearQuery)) + | .clearQuery => MachineLookup.discard queryTape .clearQuery .done + | .done => .halt + +theorem appendTrace {α : Type} (f : α → α) {a b : Nat} {x y z : α} + (hs : f^[a] x = y) (ht : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm a b, Function.iterate_add_apply, hs, ht] + +def paddingTotal (t : GraphTables.Table) : Nat := + PreprocessingPaddingOffsets.offset (PreprocessingRegularTables.padding t) t.vertices + +def vertexTotal (t : GraphTables.Table) : Nat := + PreprocessingRegularTables.vertexCount t (PreprocessingRegularTables.padding t) + +def dartTotal (q : Nat) (t : GraphTables.Table) : Nat := vertexTotal t * (q + 1) + +theorem vertexTotal_eq (t : GraphTables.Table) : + vertexTotal t = t.darts + paddingTotal t := by + unfold vertexTotal PreprocessingRegularTables.vertexCount paddingTotal + rw [PreprocessingPaddingOffsets.offset_all] + +theorem initStep (q : Nat) (table output : List Bool) (ambient : σ) + (register : Option Bool) : + TM2.step (program q) + ⟨some .init, ((ambient, false), register), + frame table [] [] [] [] [] [] [] [] [] [] [] output⟩ = + some ⟨some (.lookup .vertices (.run .copyFirst)), ((ambient, false), register), + frame table [] [] [] [] [] (encodeWord 0) [] [] [] [] [] output⟩ := by + simp [TM2.step, program, TM2.stepAux, encodeWord] + +theorem seedMStep (q : Nat) (table n output : List Bool) (ambient : σ) + (register : Option Bool) : + TM2.step (program q) + ⟨some .seedM, ((ambient, false), register), + frame table n [] [] [] [] (encodeWord 0) [] [] [] [] [] output⟩ = + some ⟨some (.lookup .darts (.run .copyFirst)), ((ambient, false), register), + frame table n [] [] [] [] (encodeWord 1) [] [] [] [] [] output⟩ := by + simp [TM2.step, program, TM2.stepAux, encodeWord] + +theorem clearIndexStep (q : Nat) (table n m output : List Bool) (ambient : σ) + (register : Option Bool) : + TM2.step (program q) + ⟨some .clearIndex, ((ambient, false), register), + frame table n [] [] [] m (encodeWord 0) [] [] [] [] [] output⟩ = + some ⟨some (.prefix .init), ((ambient, false), none), + frame table n [] [] [] m [] [] [] [] [] [] output⟩ := by + simp [TM2.step, program, TM2.stepAux, encodeWord] + +def readTime (t : GraphTables.Table) : Nat := + 1 + MachinePreservingLookupClean.steps (GraphTables.tableWords t) 0 + 1 + + MachinePreservingLookupClean.steps (GraphTables.tableWords t) 1 + 1 + +theorem readTrace (q : Nat) (t : GraphTables.Table) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program q)))^[readTime t] + (some ⟨some .init, ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] [] [] [] [] [] [] [] output⟩) = + some ⟨some (.prefix .init), ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] + (encodeWord t.darts) [] [] [] [] [] [] output⟩ := by + have hi : (advance (TM2.step (program q)))^[1] + (some ⟨some .init, ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] [] [] [] [] [] [] [] output⟩) = + some ⟨some (.lookup .vertices (.run .copyFirst)), ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] [] (encodeWord 0) [] [] [] [] [] output⟩ := + initStep q _ _ ambient register + have hn := MachinePreservingLookupClean.traceAt_fromTapes (lookupSlots .vertices) + (lookupSlots_injective .vertices) (Label.lookup .vertices) (some Label.seedM) + (program q) (fun _ => rfl) + (frame (GraphTables.tableBits t) [] [] [] [] [] (encodeWord 0) [] [] [] [] [] output) + (GraphTables.tableWords t) rfl rfl 0 t.vertices (by simp [GraphTables.tableWords]) [] + (by simp [lookupSlots]) (by simp [lookupSlots]) (ambient, false) register + simp [MachinePreservingLookup.initialTapes, MachineLookup.tapes, lookupSlots, fieldTape] at hn + have hs : (advance (TM2.step (program q)))^[1] + (some ⟨some .seedM, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] [] + (encodeWord 0) [] [] [] [] [] output⟩) = + some ⟨some (.lookup .darts (.run .copyFirst)), ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] [] + (encodeWord 1) [] [] [] [] [] output⟩ := + seedMStep q _ _ _ ambient none + have hm := MachinePreservingLookupClean.traceAt_fromTapes (lookupSlots .darts) + (lookupSlots_injective .darts) (Label.lookup .darts) (some Label.clearIndex) + (program q) (fun _ => rfl) + (frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] [] + (encodeWord 1) [] [] [] [] [] output) + (GraphTables.tableWords t) rfl rfl 1 t.darts (by simp [GraphTables.tableWords]) [] + (by simp [lookupSlots]) (by simp [lookupSlots]) (ambient, false) none + simp [MachinePreservingLookup.initialTapes, MachineLookup.tapes, lookupSlots, fieldTape] at hm + have hc : (advance (TM2.step (program q)))^[1] + (some ⟨some .clearIndex, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] + (encodeWord t.darts) (encodeWord 0) [] [] [] [] [] output⟩) = + some ⟨some (.prefix .init), ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] + (encodeWord t.darts) [] [] [] [] [] [] output⟩ := + clearIndexStep q _ _ _ _ ambient none + exact appendTrace _ (appendTrace _ (appendTrace _ (appendTrace _ hi hn) hs) hm) hc + +end Header +end IndependentSetsGames.Foundations.Complexity.MachineRegularTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/BitValue.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/BitValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a360d4a82851c7ad4b0fbc87f5d1b6a42333d94 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/BitValue.lean @@ -0,0 +1,215 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Printer + +namespace OAI + +namespace IndependentSetsCut.CounterMachine.Expr +open scoped BigOperators +open Finset + +def bitValue (input : List Bool) (i : ℕ) : ℕ := if (input[i]?).getD false then 1 else 0 + +def zeroPrefix (input : List Bool) (i : ℕ) : ℕ := + ∑ j ∈ range i, (1-bitValue input j) + +def wordValue (input : List Bool) (k : ℕ) : ℕ := + ∑ i ∈ range input.length, bitValue input i * (if zeroPrefix input i = k then 1 else 0) + +def prefixZeros (i : Expr) : Expr := .sum i (.zero (.bit (.arg 0))) +def word (k : Expr) : Expr := .sum .length + (.mul (.bit (.arg 0)) (equal (prefixZeros (.arg 0)) (k.rename Nat.succ))) + +@[simp] theorem prefixZeros_eval (i : Expr) (input : List Bool) (args : ℕ → ℕ) : + (prefixZeros i).eval input args = zeroPrefix input (i.eval input args) := by + simp only [prefixZeros, eval, bind, zeroPrefix, bitValue] + apply sum_congr rfl + intro j hj + by_cases h : (input[j]?).getD false = true <;> simp [h] + +@[simp] theorem word_eval (k : Expr) (input : List Bool) (args : ℕ → ℕ) : + (word k).eval input args = wordValue input (k.eval input args) := by + simp [word, eval, prefixZeros_eval, equal_eval, wordValue, bitValue, bind] + rfl + +@[simp] theorem bitValue_cons_zero (a : Bool) (s : List Bool) : + bitValue (a::s) 0 = if a then 1 else 0 := by simp [bitValue] +@[simp] theorem bitValue_cons_succ (a : Bool) (s : List Bool) (i : ℕ) : + bitValue (a::s) (i+1) = bitValue s i := by simp [bitValue] +@[simp] theorem zeroPrefix_zero (input : List Bool) : zeroPrefix input 0 = 0 := by simp [zeroPrefix] +@[simp] theorem zeroPrefix_cons_succ (a : Bool) (s : List Bool) (i : ℕ) : + zeroPrefix (a::s) (i+1) = (if a then 0 else 1)+zeroPrefix s i := by + rw [zeroPrefix, sum_range_succ'] + simp only [bitValue_cons_zero, bitValue_cons_succ, zeroPrefix] + cases a <;> simp [add_comm] + +@[simp] theorem wordValue_nil (k : ℕ) : wordValue [] k = 0 := by simp [wordValue] + + theorem wordValue_true (s : List Bool) (k : ℕ) : + wordValue (true::s) k = (if k=0 then 1 else 0)+wordValue s k := by + rw [wordValue, List.length_cons, sum_range_succ'] + simp [wordValue, eq_comm, add_comm] + +@[simp] theorem wordValue_false_zero (s : List Bool) : wordValue (false::s) 0 = 0 := by + rw [wordValue, List.length_cons, sum_range_succ'] + simp + + theorem wordValue_false_succ (s : List Bool) (k : ℕ) : + wordValue (false::s) (k+1) = wordValue s k := by + rw [wordValue, List.length_cons, sum_range_succ'] + simp [wordValue, Nat.add_comm 1] + + theorem wordValue_block_zero (n : ℕ) (s : List Bool) : + wordValue (List.replicate n true ++ false::s) 0 = n := by + induction n with + | zero => simp + | succ n ih => simp only [List.replicate_succ, List.cons_append, wordValue_true, ↓reduceIte, ih]; omega + + theorem wordValue_block_succ (n k : ℕ) (s : List Bool) : + wordValue (List.replicate n true ++ false::s) (k+1) = wordValue s k := by + induction n with + | zero => simpa using wordValue_false_succ s k + | succ n ih => simp [List.replicate_succ, wordValue_true, ih] + +def unaryWords (words : List ℕ) : List Bool := words.flatMap (fun n => List.replicate n true ++ [false]) + + theorem wordValue_encoded (words : List ℕ) (k : ℕ) : + wordValue (unaryWords words) k = (words[k]?).getD 0 := by + induction words generalizing k with + | nil => simp [unaryWords] + | cons n words ih => + cases k with + | zero => simpa [unaryWords, List.append_assoc] using wordValue_block_zero n (unaryWords words) + | succ k => + simp only [unaryWords, List.flatMap_cons, List.append_assoc, List.singleton_append] + change wordValue (List.replicate n true ++ false :: unaryWords words) (k+1) = _ + rw [wordValue_block_succ, ih] + simp + +attribute [local instance] Classical.propDecidable + +theorem indicator_and (P Q : Prop) [Decidable P] [Decidable Q] : + (if P then (1:ℕ) else 0)*(if Q then 1 else 0) = if P ∧ Q then 1 else 0 := by + by_cases hP : P <;> by_cases hQ : Q <;> simp [hP,hQ] + +def divides (a b : Expr) : Expr := .zero (remainder b a) +@[simp] theorem divides_eval (a b : Expr) (input : List Bool) (args : ℕ → ℕ) : + (divides a b).eval input args = if a.eval input args ∣ b.eval input args then 1 else 0 := by + simp [divides, eval, Nat.dvd_iff_mod_eq_zero] + +def prime (n : Expr) : Expr := .mul (le (.const 2) n) + (.zero (.sum n (.mul (le (.const 2) (.arg 0)) (divides (.arg 0) (n.rename Nat.succ))))) + +@[simp] theorem prime_eval (n : Expr) (input : List Bool) (args : ℕ → ℕ) : + (prime n).eval input args = if (n.eval input args).Prime then 1 else 0 := by + simp only [prime, eval, le_eval, divides_eval, rename_eval, bind] + have h : (∑ i ∈ range (n.eval input args), + (if 2 ≤ i then 1 else 0) * (if i ∣ n.eval input args then 1 else 0) : ℕ) = 0 ↔ + ∀ i, 2 ≤ i → i < n.eval input args → ¬ i ∣ n.eval input args := by + rw [sum_eq_zero_iff_of_nonneg (fun _ _ => Nat.zero_le _)] + constructor + · intro h i hi hn hd + have hh := h i (mem_range.mpr hn) + simp [hi, hd] at hh + · intro h i hi + by_cases h2 : 2 ≤ i + · simp [h2, h i h2 (mem_range.mp hi)] + · simp [h2] + have hx : (if 2 ≤ n.eval input args then 1 else 0) * + (if (∑ i ∈ range (n.eval input args), + (if 2 ≤ i then 1 else 0)*(if i ∣ n.eval input args then 1 else 0) : ℕ)=0 then 1 else 0) = + (if (n.eval input args).Prime then 1 else 0) := by + simp only [h] + exact (indicator_and _ _).trans (by simp only [Nat.prime_def_lt']) + exact hx + +def powTwo (n : Expr) : Expr := .mul (positive n) + (.zero (.sum (.add n (.const 1)) + (.mul (prime (.arg 0)) (.mul (divides (.arg 0) (n.rename Nat.succ)) + (.zero (equal (.arg 0) (.const 2))))))) + +@[simp] theorem powTwo_eval (n : Expr) (input : List Bool) (args : ℕ → ℕ) : + (powTwo n).eval input args = if ∃ k : ℕ, n.eval input args = 2^k then 1 else 0 := by + let N := n.eval input args + have h : (∑ i ∈ range (N+1), (if i.Prime then 1 else 0)* + ((if i ∣ N then 1 else 0)*(if (if i=2 then 1 else 0)=0 then 1 else 0)) : ℕ) = 0 ↔ + ∀ i ≤ N, i.Prime → i ∣ N → i=2 := by + rw [sum_eq_zero_iff_of_nonneg (fun _ _ => Nat.zero_le _)] + constructor + · intro h i hi hp hd + have hh := h i (mem_range.mpr (by omega)) + by_contra hn + simp [hp,hd,hn] at hh + · intro h i hi + by_cases hp : i.Prime <;> by_cases hd : i ∣ N <;> simp_all + exact h i (by omega) hp hd + have hh : (N ≠ 0 ∧ ∀ i ≤ N, i.Prime → i ∣ N → i=2) ↔ ∃ k : ℕ, N=2^k := by + constructor + · rintro ⟨hn,hp⟩ + exact ⟨_, Nat.eq_prime_pow_of_unique_prime_dvd hn (fun {d} hd hdn => hp d (Nat.le_of_dvd (by omega) hdn) hd hdn)⟩ + · rintro ⟨k,hk⟩ + rw [hk] + refine ⟨by positivity, ?_⟩ + intro i hi hp hd + exact (Nat.prime_dvd_prime_iff_eq hp Nat.prime_two).mp (hp.dvd_of_dvd_pow hd) + simp only [powTwo, eval, positive_eval, prime_eval, divides_eval, equal_eval, rename_eval, bind] + change (if N ≠ 0 then 1 else 0)*(if _=0 then 1 else 0) = if ∃ k, N=2^k then 1 else 0 + have hx : (if N ≠ 0 then 1 else 0)*(if + (∑ i ∈ range (N+1), (if i.Prime then 1 else 0)* + ((if i ∣ N then 1 else 0)*(if (if i=2 then 1 else 0)=0 then 1 else 0)) : ℕ) = 0 + then 1 else 0) = (if ∃ k, N=2^k then 1 else 0) := by + simp only [h] + exact (indicator_and _ _).trans (by simp only [hh]) + exact hx + +def size (n : Expr) : Expr := .sum (.add n (.const 1)) (powTwo (.arg 0)) + + theorem count_powers (N : ℕ) : + (∑ i ∈ range (N+1), if ∃ k : ℕ, i=2^k then (1:ℕ) else 0) = N.size := by + rw [sum_boole] + have hb : {i ∈ range (N+1) | ∃ k : ℕ, i=2^k} = (range N.size).image (fun k => 2^k) := by + ext i + simp only [mem_filter, mem_range, mem_image] + constructor + · rintro ⟨hi,k,rfl⟩ + exact ⟨k, Nat.lt_size.mpr (by omega), rfl⟩ + · rintro ⟨k,hk,rfl⟩ + exact ⟨by have := Nat.lt_size.mp hk; omega, k, rfl⟩ + rw [hb, card_image_of_injective _ (by intro a b h; exact (Nat.pow_right_injective (by omega : 2 ≤ 2)) h), card_range, Nat.cast_id] + +@[simp] theorem size_eval (n : Expr) (input : List Bool) (args : ℕ → ℕ) : + (size n).eval input args = (n.eval input args).size := by + simp only [size, eval, powTwo_eval, bind] + exact count_powers (n.eval input args) + +def digitPower (n i : Expr) : Expr := .sum (.add n (.const 1)) + (.mul (.arg 0) (.mul (powTwo (.arg 0)) + (equal (size (.arg 0)) (.add (i.rename Nat.succ) (.const 1))))) + + theorem digitPower_eval (n i : Expr) (input : List Bool) (args : ℕ → ℕ) + (hi : i.eval input args < (n.eval input args).size) : + (digitPower n i).eval input args = 2^(i.eval input args) := by + simp only [digitPower, eval, powTwo_eval, size_eval, equal_eval, rename_eval, bind] + let N := n.eval input args + let I := i.eval input args + have hpow : 2^I ∈ range (N+1) := mem_range.mpr (by have hh := Nat.lt_size.mp hi; change 2^I ≤ N at hh; omega) + rw [sum_eq_single_of_mem (2^I) hpow] + · simp [Nat.size_pow, I] + · intro b hb hne + by_cases hp : ∃ k : ℕ, b=2^k + · obtain ⟨k,rfl⟩ := hp + have hk : k ≠ I := by rintro rfl; exact hne rfl + simp only [Nat.size_pow, Nat.add_right_cancel_iff] + have hk' : k ≠ i.eval input (fun j => args j) := hk + simp [hk'] + · simp [hp] + +def digit (n i : Expr) : Expr := remainder (quotient n (digitPower n i)) (.const 2) + + theorem digit_eval (n i : Expr) (input : List Bool) (args : ℕ → ℕ) + (hi : i.eval input args < (n.eval input args).size) : + (digit n i).eval input args = n.eval input args / 2^(i.eval input args) % 2 := by + simp [digit, eval, digitPower_eval n i input args hi] + +end IndependentSetsCut.CounterMachine.Expr + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Block.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Block.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0afa1d5ab4f83d8aa7741b7768b42e0d509c642 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Block.lean @@ -0,0 +1,274 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryCounter +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineRow + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRow +open Turing +open MachineFixedBlockMap +open IndependentSetsGames.Foundations.PCP +section Block + +variable {K Λ σ : Type} {N M : Nat} + +def encodedBlockStmt (src dst : K) (F : Buffer N → Buffer M) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) : + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) := + readEncodedSlots src (List.ofFn id) + (writeEncodedSlots dst (fun state => F state.2) (List.ofFn id).reverse + (.load (fun state => (state.1, emptyBuffer N)) next)) + +def encodedBlockAt (src dst : K) (F : Buffer N → Buffer M) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) := + encodedBlockStmt src dst F (finishAt exit) + +theorem statementPushBound_encodedBlockAt (src dst : K) + (F : Buffer N → Buffer M) (exit : Option Λ) : + Runtime.statementPushBound (encodedBlockAt (σ := σ) src dst F exit) = 2 * M := by + cases exit <;> simp [encodedBlockAt, encodedBlockStmt, + statementPushBound_readEncodedSlots, statementPushBound_writeEncodedSlots, + finishAt, Runtime.statementPushBound] + +variable [DecidableEq K] + +theorem stepAux_encodedBlockStmt (src dst : K) (F : Buffer N → Buffer M) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : σ × Buffer N) (tapes : K → List Bool) + (hinput : tapes src = encodeBits (List.ofFn bits) ++ suffix) : + TM2.stepAux (encodedBlockStmt src dst F next) state tapes = + TM2.stepAux next (state.1, emptyBuffer N) + (Function.update (Function.update tapes src suffix) dst + (encodeBits (List.ofFn (F bits)) ++ tapes dst)) := by + unfold encodedBlockStmt + rw [stepAux_readEncodedAll src _ state bits tapes suffix hinput, + stepAux_writeEncodedSlots] + simp only [List.map_reverse, List.map_ofFn, Function.comp_id, List.reverse_reverse, + Function.update_of_ne (Ne.symm hne), TM2.stepAux] + +theorem stepAux_encodedBlockAt (src dst : K) (F : Buffer N → Buffer M) + (exit : Option Λ) (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : σ × Buffer N) (tapes : K → List Bool) + (hinput : tapes src = encodeBits (List.ofFn bits) ++ suffix) : + TM2.stepAux (encodedBlockAt src dst F exit) state tapes = + { l := exit, var := (state.1, emptyBuffer N), + stk := Function.update (Function.update tapes src suffix) dst + (encodeBits (List.ofFn (F bits)) ++ tapes dst) } := by + rw [encodedBlockAt, stepAux_encodedBlockStmt src dst F _ hne bits suffix state tapes hinput] + cases exit <;> rfl + +theorem step_encodedBlockAt (src dst : K) (F : Buffer N → Buffer M) + (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (label : Λ) (hprogram : program label = encodedBlockAt src dst F exit) + (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : σ × Buffer N) (tapes : K → List Bool) + (hinput : tapes src = encodeBits (List.ofFn bits) ++ suffix) : + TM2.step program { l := some label, var := state, stk := tapes } = + some { l := exit + var := (state.1, emptyBuffer N) + stk := Function.update (Function.update tapes src suffix) dst + (encodeBits (List.ofFn (F bits)) ++ tapes dst) } := by + simp only [TM2.step, hprogram, + stepAux_encodedBlockAt src dst F exit hne bits suffix state tapes hinput] + +end Block + +def rowAt {K Λ σ : Type} {t S q : Nat} (src dst : K) + (labelAt : Fin q → Fin S → GraphTables.Label) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer (inputSize t S)) := + encodedBlockAt src dst (rowBlock labelAt) exit + +def machine {t S q : Nat} (labelAt : Fin q → Fin S → GraphTables.Label) : FinTM2 where + K := Bool + k₀ := false + k₁ := true + Γ _ := Bool + Λ := Unit + main := () + σ := Unit × Buffer (inputSize t S) + initialState := ((), emptyBuffer (inputSize t S)) + m _ := rowAt false true labelAt none + +theorem machine_statementPushBound {t S q : Nat} + (labelAt : Fin q → Fin S → GraphTables.Label) : + Runtime.statementPushBound ((machine (t := t) labelAt).m ()) = 2 * (q * q) := + statementPushBound_encodedBlockAt false true (rowBlock labelAt) none + +def machineInTime {t S q : Nat} (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (suffix : List Bool) + (register : Buffer (inputSize t S)) (tapes : Bool → List Bool) + (hinput : tapes false = encodeBits (List.ofFn bits) ++ suffix) : + StateTransition.EvalsToInTime (machine (t := t) labelAt).step + ⟨some (), ((), register), tapes⟩ + (some ⟨none, ((), emptyBuffer (inputSize t S)), + Function.update (Function.update tapes false suffix) true + (encodeBits (List.ofFn (rowBlock labelAt bits)) ++ tapes true)⟩) 1 where + steps := 1 + evals_in_steps := by + change TM2.step (fun _ : Unit => rowAt false true labelAt none) + { l := some (), var := ((), register), stk := tapes } = + some { l := none + var := ((), emptyBuffer (inputSize t S)) + stk := Function.update (Function.update tapes false suffix) true + (encodeBits (List.ofFn (rowBlock labelAt bits)) ++ tapes true) } + exact step_encodedBlockAt false true (rowBlock labelAt) (none : Option Unit) + (fun _ => rowAt false true labelAt none) () rfl (by decide) + bits suffix ((), register) tapes hinput + steps_le_m := le_rfl + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRow +namespace IndependentSetsGames.Foundations.Complexity.MachineCountedLoop + +open Turing +open scoped BigOperators +open MachineUnaryCounter + +variable {K Λ σ : Type} [DecidableEq K] + +def guardConfiguration (counter : K) (guardLabel : Λ) (suffix : List Bool) + (ambient : Nat → σ) (register : Nat → Option Bool) + (base : Nat → K → List Bool) (n : Nat) : + TM2.Cfg (Alphabet (K := K)) Λ (σ × Option Bool) := + ⟨some guardLabel, (ambient n, register n), counterTapes counter (base n) n suffix⟩ + +def bodyConfiguration (counter : K) (bodyLabel : Λ) (suffix : List Bool) + (ambient : Nat → σ) (base : Nat → K → List Bool) (n : Nat) : + TM2.Cfg (Alphabet (K := K)) Λ (σ × Option Bool) := + ⟨some bodyLabel, (ambient (n + 1), none), counterTapes counter (base (n + 1)) n suffix⟩ + +def exitConfiguration (counter : K) (exitLabel : Λ) (suffix : List Bool) + (ambient : Nat → σ) (base : Nat → K → List Bool) : + TM2.Cfg (Alphabet (K := K)) Λ (σ × Option Bool) := + ⟨some exitLabel, (ambient 0, none), counterTapes counter (base 0) 0 suffix⟩ + +def BodyTraces (counter : K) (guardLabel bodyLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (suffix : List Bool) (ambient : Nat → σ) (register : Nat → Option Bool) + (base : Nat → K → List Bool) (cost : Nat → Nat) (n : Nat) : Prop := + ∀ r, r < n → + (MachineComposition.advance (TM2.step program))^[cost r] + (some (bodyConfiguration counter bodyLabel suffix ambient base r)) = + some (guardConfiguration counter guardLabel suffix ambient register base r) + +def totalSteps (cost : Nat → Nat) (n : Nat) : Nat := + (∑ r ∈ Finset.range n, cost r) + n + 1 + +@[simp] theorem totalSteps_zero (cost : Nat → Nat) : totalSteps cost 0 = 1 := by + simp [totalSteps] + +theorem totalSteps_succ (cost : Nat → Nat) (n : Nat) : + totalSteps cost (n + 1) = (totalSteps cost n + cost n) + 1 := by + simp only [totalSteps, Finset.sum_range_succ] + omega + +theorem loopTrace (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (suffix : List Bool) (ambient : Nat → σ) (register : Nat → Option Bool) + (base : Nat → K → List Bool) (cost : Nat → Nat) (n : Nat) + (bodyTraces : BodyTraces counter guardLabel bodyLabel program suffix + ambient register base cost n) : + (MachineComposition.advance (TM2.step program))^[totalSteps cost n] + (some (guardConfiguration counter guardLabel suffix ambient register base n)) = + some (exitConfiguration counter exitLabel suffix ambient base) := by + revert bodyTraces + induction n with + | zero => + intro _ + simpa only [totalSteps_zero, guardConfiguration, exitConfiguration] using + guardTrace_zero counter guardLabel bodyLabel exitLabel program atGuard + (base 0) suffix (ambient 0) (register 0) + | succ n ih => + intro bodyTraces + rw [totalSteps_succ, Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[totalSteps cost n + cost n] + (TM2.step program + ⟨some guardLabel, (ambient (n + 1), register (n + 1)), + counterTapes counter (base (n + 1)) (n + 1) suffix⟩) = _ + rw [guardStep_succ counter guardLabel bodyLabel exitLabel program atGuard + (base (n + 1)) n suffix (ambient (n + 1)) (register (n + 1)), + Function.iterate_add_apply] + change (MachineComposition.advance (TM2.step program))^[totalSteps cost n] + ((MachineComposition.advance (TM2.step program))^[cost n] + (some (bodyConfiguration counter bodyLabel suffix ambient base n))) = _ + rw [bodyTraces n (Nat.lt_succ_self n)] + exact ih (fun r hr => bodyTraces r (Nat.lt_trans hr (Nat.lt_succ_self n))) + +theorem totalSteps_le (cost : Nat → Nat) (n B : Nat) + (bodyBound : ∀ r, r < n → cost r ≤ B) : + totalSteps cost n ≤ n * (B + 1) + 1 := by + have hsum : (∑ r ∈ Finset.range n, cost r) ≤ n * B := by + calc + (∑ r ∈ Finset.range n, cost r) ≤ ∑ _r ∈ Finset.range n, B := + Finset.sum_le_sum (fun r hr => bodyBound r (Finset.mem_range.mp hr)) + _ = n * B := by simp + simpa only [totalSteps, Nat.mul_add, Nat.mul_one] using + Nat.add_le_add_right (Nat.add_le_add_right hsum n) 1 + +def loopInTime (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (suffix : List Bool) (ambient : Nat → σ) (register : Nat → Option Bool) + (base : Nat → K → List Bool) (cost : Nat → Nat) (n B : Nat) + (bodyTraces : BodyTraces counter guardLabel bodyLabel program suffix + ambient register base cost n) + (bodyBound : ∀ r, r < n → cost r ≤ B) : + StateTransition.EvalsToInTime (TM2.step program) + (guardConfiguration counter guardLabel suffix ambient register base n) + (some (exitConfiguration counter exitLabel suffix ambient base)) + (n * (B + 1) + 1) where + steps := totalSteps cost n + evals_in_steps := by + change (MachineComposition.advance (TM2.step program))^[totalSteps cost n] _ = _ + exact loopTrace counter guardLabel bodyLabel exitLabel program atGuard suffix + ambient register base cost n bodyTraces + steps_le_m := totalSteps_le cost n B bodyBound + +omit [DecidableEq K] in + +theorem baseFrame (base : Nat → K → List Bool) (frame : K → Prop) (n : Nat) + (bodyFrame : ∀ r, r < n → ∀ k, frame k → base (r + 1) k = base r k) : + ∀ k, frame k → base n k = base 0 k := by + revert bodyFrame + induction n with + | zero => intro _ k _; rfl + | succ n ih => + intro bodyFrame k hk + exact (bodyFrame n (Nat.lt_succ_self n) k hk).trans + (ih (fun r hr => bodyFrame r (Nat.lt_trans hr (Nat.lt_succ_self n))) k hk) + +theorem counterFrame (counter : K) (suffix : List Bool) + (base : Nat → K → List Bool) (frame : K → Prop) (n : Nat) + (counterOutside : ∀ k, frame k → k ≠ counter) + (bodyFrame : ∀ r, r < n → ∀ k, frame k → base (r + 1) k = base r k) : + ∀ k, frame k → + counterTapes counter (base n) n suffix k = counterTapes counter (base 0) 0 suffix k := by + intro k hk + rw [counterTapes_other counter k (counterOutside k hk), + counterTapes_other counter k (counterOutside k hk)] + exact baseFrame base frame n bodyFrame k hk + +theorem loopTrace_framed (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (suffix : List Bool) (ambient : Nat → σ) (register : Nat → Option Bool) + (base : Nat → K → List Bool) (cost : Nat → Nat) (n : Nat) + (bodyTraces : BodyTraces counter guardLabel bodyLabel program suffix + ambient register base cost n) + (frame : K → Prop) (counterOutside : ∀ k, frame k → k ≠ counter) + (bodyFrame : ∀ r, r < n → ∀ k, frame k → base (r + 1) k = base r k) : + ((MachineComposition.advance (TM2.step program))^[totalSteps cost n] + (some (guardConfiguration counter guardLabel suffix ambient register base n)) = + some (exitConfiguration counter exitLabel suffix ambient base)) ∧ + (∀ k, frame k → + (guardConfiguration counter guardLabel suffix ambient register base n).stk k = + (exitConfiguration counter exitLabel suffix ambient base).stk k) := + ⟨loopTrace counter guardLabel bodyLabel exitLabel program atGuard suffix + ambient register base cost n bodyTraces, + counterFrame counter suffix base frame n counterOutside bodyFrame⟩ + +end IndependentSetsGames.Foundations.Complexity.MachineCountedLoop + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Command.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Command.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5977afac64328e8639b0a5381bd6da6f17f0aa8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Command.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.TableIterationFiniteAlphabet + +namespace OAI + +namespace IndependentSetsCut.CounterMachine +variable {R L : Type} [DecidableEq R] + +inductive Command (R : Type) where + | skip + | inc (r : R) + | dec (r : R) + | write (b : Bool) + | discard + | rewind + | seq (first second : Command R) + | test (r : R) (zero positive : Command R) + | read (one zero empty : Command R) + | loop (r : R) (body : Command R) + +namespace Command + +def Label : Command R → Type + | .skip | .inc _ | .dec _ | .write _ | .discard | .rewind => Unit + | .seq a b => Label a ⊕ Label b + | .test _ a b => Unit ⊕ Label a ⊕ Label b + | .read a b c => Unit ⊕ Label a ⊕ Label b ⊕ Label c + | .loop _ b => Unit ⊕ Label b + +noncomputable instance labelFintype (c : Command R) : Fintype (Label c) := by + induction c with + | skip | inc | dec | write | discard | rewind => exact inferInstanceAs (Fintype Unit) + | seq a b ia ib => exact inferInstanceAs (Fintype (Label a ⊕ Label b)) + | test r a b ia ib => exact inferInstanceAs (Fintype (Unit ⊕ Label a ⊕ Label b)) + | read a b c ia ib ic => exact inferInstanceAs (Fintype (Unit ⊕ Label a ⊕ Label b ⊕ Label c)) + | loop r b ib => exact inferInstanceAs (Fintype (Unit ⊕ Label b)) + +def entry : (c : Command R) → Label c + | .skip | .inc _ | .dec _ | .write _ | .discard | .rewind => () + | .seq a _ => .inl a.entry + | .test _ _ _ | .read _ _ _ | .loop _ _ => .inl () + +def code : (c : Command R) → (Label c → L) → L → Label c → Instruction R L + | .skip, _, exit, _ => .jump exit + | .inc r, _, exit, _ => .inc r exit + | .dec r, _, exit, _ => .dec r exit exit + | .write b, _, exit, _ => .write b exit + | .discard, _, exit, _ => .discard exit + | .rewind, labels, exit, _ => .back (labels ()) exit + | .seq a b, labels, _exit, .inl l => + a.code (fun l => labels (.inl l)) (labels (.inr b.entry)) l + | .seq _a b, labels, exit, .inr l => b.code (fun l => labels (.inr l)) exit l + | .test r a b, labels, _, .inl _ => + .test r (labels (.inr (.inl a.entry))) (labels (.inr (.inr b.entry))) + | .test _ a _, labels, exit, .inr (.inl l) => + a.code (fun l => labels (.inr (.inl l))) exit l + | .test _ _ b, labels, exit, .inr (.inr l) => + b.code (fun l => labels (.inr (.inr l))) exit l + | .read a b c, labels, _, .inl _ => + .read (labels (.inr (.inl a.entry))) (labels (.inr (.inr (.inl b.entry)))) + (labels (.inr (.inr (.inr c.entry)))) + | .read a _ _, labels, exit, .inr (.inl l) => + a.code (fun l => labels (.inr (.inl l))) exit l + | .read _ b _, labels, exit, .inr (.inr (.inl l)) => + b.code (fun l => labels (.inr (.inr (.inl l)))) exit l + | .read _ _ c, labels, exit, .inr (.inr (.inr l)) => + c.code (fun l => labels (.inr (.inr (.inr l)))) exit l + | .loop r b, labels, exit, .inl _ => .dec r (labels (.inr b.entry)) exit + | .loop _ b, labels, _, .inr l => b.code (fun l => labels (.inr l)) (labels (.inl ())) l + +def incData (d : Data R) (r : R) : Data R := + { d with reg := Function.update d.reg r (d.reg r + 1) } +def decData (d : Data R) (r : R) : Data R := + { d with reg := Function.update d.reg r (d.reg r - 1) } +def readData (d : Data R) : Data R := + { d with input := d.input.tail, backup := d.input.take 1 ++ d.backup } +def backData (d : Data R) : Data R := + { d with input := d.backup.take 1 ++ d.input, backup := d.backup.tail } +def discardData (d : Data R) : Data R := {d with input := d.input.tail} +def writeData (d : Data R) (b : Bool) : Data R := { d with output := b :: d.output } + +inductive Evaluates : Command R → Data R → Data R → ℕ → Prop + | skip (d) : Evaluates .skip d d 1 + | inc (d r) : Evaluates (.inc r) d (incData d r) 1 + | dec (d r) : Evaluates (.dec r) d (decData d r) 1 + | write (d b) : Evaluates (.write b) d (writeData d b) 1 + | discard (d) : Evaluates .discard d (discardData d) 1 + | rewind_empty {d} : d.backup = [] → Evaluates .rewind d d 1 + | rewind_cons {d e n b rest} : d.backup = b :: rest → + Evaluates .rewind (backData d) e n → Evaluates .rewind d e (1 + n) + | seq {a b d e f n m} : Evaluates a d e n → Evaluates b e f m → + Evaluates (.seq a b) d f (n + m) + | test_zero {r a b d e n} : d.reg r = 0 → Evaluates a d e n → + Evaluates (.test r a b) d e (1 + n) + | test_pos {r a b d e n} : d.reg r ≠ 0 → Evaluates b d e n → + Evaluates (.test r a b) d e (1 + n) + | read_one {a b c d e n rest} : d.input = true :: rest → + Evaluates a (readData d) e n → Evaluates (.read a b c) d e (1 + n) + | read_zero {a b c d e n rest} : d.input = false :: rest → + Evaluates b (readData d) e n → Evaluates (.read a b c) d e (1 + n) + | read_empty {a b c d e n} : d.input = [] → + Evaluates c (readData d) e n → Evaluates (.read a b c) d e (1 + n) + | loop_zero {r b d} : d.reg r = 0 → Evaluates (.loop r b) d d 1 + | loop_pos {r b d e f n m} : d.reg r ≠ 0 → + Evaluates b (decData d r) e n → Evaluates (.loop r b) e f m → + Evaluates (.loop r b) d f (1 + n + m) + +end Command + +def advance (p : L → Instruction R L) : Option (Configuration R L) → Option (Configuration R L) := + fun c => c.bind (step p) + +def atCfg (l : L) (d : Data R) : Option (Configuration R L) := some ⟨d, some l⟩ + +def Runs (p : L → Instruction R L) (n : ℕ) (l : L) (d : Data R) (l' : L) (d' : Data R) : Prop := + (advance p)^[n] (atCfg l d) = atCfg l' d' + + theorem runs_one (p : L → Instruction R L) (l : L) (d : Data R) (l' : L) (d' : Data R) + (h : (p l).execute d = ⟨d', some l'⟩) : Runs p 1 l d l' d' := by + simpa [Runs, advance, atCfg, step] using congrArg some h + + theorem Runs.trans {p : L → Instruction R L} {n m : ℕ} {l l' l'' : L} {d e f : Data R} + (h : Runs p n l d l' e) (h' : Runs p m l' e l'' f) : Runs p (n + m) l d l'' f := by + unfold Runs at * + rw [Nat.add_comm n m, Function.iterate_add_apply, h, h'] + +namespace Command + theorem trace {c : Command R} {d d' : Data R} {n : ℕ} (h : Evaluates c d d' n) + (p : L → Instruction R L) (labels : c.Label → L) (exit : L) + (atLabels : ∀ l, p (labels l) = c.code labels exit l) : + Runs p n (labels c.entry) d exit d' := by + induction h generalizing L with + | skip d => + apply runs_one + rw [atLabels]; rfl + | inc d r => + apply runs_one + rw [atLabels]; rfl + | dec d r => + apply runs_one + rw [atLabels] + simp [code, Instruction.execute, decData] + | write d b => + apply runs_one + rw [atLabels]; rfl + | discard d => + apply runs_one + rw [atLabels]; rfl + | @rewind_empty d hd => + apply runs_one + rw [atLabels] + simp [code, Instruction.execute, hd] + cases d; simp_all + | @rewind_cons d e n b rest hd he ih => + refine Runs.trans (runs_one p _ _ _ _ ?_) (ih p labels exit atLabels) + rw [atLabels] + simp [code, entry, Instruction.execute, backData, hd] + | @seq a b d e f n m h h' ih ih' => + exact Runs.trans + (ih p (fun l => labels (.inl l)) (labels (.inr b.entry)) (fun l => atLabels (.inl l))) + (ih' p (fun l => labels (.inr l)) exit (fun l => atLabels (.inr l))) + | @test_zero r a b d e n hr h ih => + refine Runs.trans (runs_one p _ _ _ _ ?_) (ih p _ exit (fun l => atLabels (.inr (.inl l)))) + rw [atLabels] + simp [code, entry, Instruction.execute, hr] + | @test_pos r a b d e n hr h ih => + refine Runs.trans (runs_one p _ _ _ _ ?_) (ih p _ exit (fun l => atLabels (.inr (.inr l)))) + rw [atLabels] + simp [code, entry, Instruction.execute, hr] + | @read_one a b c d e n rest hin h ih => + refine Runs.trans (runs_one p _ _ _ _ ?_) (ih p _ exit (fun l => atLabels (.inr (.inl l)))) + rw [atLabels] + simp [code, entry, Instruction.execute, readData, hin] + | @read_zero a b c d e n rest hin h ih => + refine Runs.trans (runs_one p _ _ _ _ ?_) (ih p _ exit (fun l => atLabels (.inr (.inr (.inl l))))) + rw [atLabels] + simp [code, entry, Instruction.execute, readData, hin] + | @read_empty a b c d e n hin h ih => + refine Runs.trans (runs_one p _ _ _ _ ?_) (ih p _ exit (fun l => atLabels (.inr (.inr (.inr l))))) + rw [atLabels] + simp [code, entry, Instruction.execute, readData, hin] + | @loop_zero r b d hr => + apply runs_one + rw [atLabels] + simp [code, entry, Instruction.execute, hr] + rw [← hr, Function.update_eq_self] + | @loop_pos r b d e f n m hr h h' ih ih' => + refine Runs.trans (Runs.trans (runs_one p _ _ _ _ ?_) + (ih p (fun l => labels (.inr l)) (labels (.inl ())) (fun l => atLabels (.inr l)))) + (ih' p labels exit atLabels) + rw [atLabels] + simp [code, entry, Instruction.execute, decData, hr] +end Command +end IndependentSetsCut.CounterMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/ComputeTime.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/ComputeTime.lean new file mode 100644 index 0000000000000000000000000000000000000000..50404d0f4ffdf55a722d4b929b39c68c0382dcbd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/ComputeTime.lean @@ -0,0 +1,427 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOwnerProgram +import OAI.Combinatorics.IndependentSets.Machines.Machine2 +import OAI.Combinatorics.IndependentSets.Machines.Basic + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTable +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP +namespace Header +variable {σ : Type} + +theorem prefixTrace (q : Nat) (t : GraphTables.Table) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program q)))^[MachineCloudPrefix.totalTime t t.vertices []] + (some ⟨some (.prefix .init), ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] + (encodeWord t.darts) [] [] [] [] [] [] output⟩) = + some ⟨some (.copyFirst .count), ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord (paddingTotal t)) (encodeWord t.darts) + [] [] [] [] [] [] output⟩ := by + have h := MachineCloudPadding.Placement.trace Sum.inl prefixView prefixView_left prefixView_right + Label.prefix (some (Label.copyFirst .count)) + (frame [] [] [] [] [] (encodeWord t.darts) [] [] [] [] [] [] output) + (MachineCloudPrefix.program (σ := σ)) (program q) (fun _ => rfl) _ _ _ + (MachineCloudPrefix.prefixTrace t t.vertices (Nat.le_refl _) [] ambient register) + simpa only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, + prefixTapes, frame_m, frame_index, frame_work, frame_scratch, frame_vertices, frame_darts, + frame_emit, frame_output, List.append_nil, paddingTotal, frame, memory, + mTape, indexTape, workTape, scratchTape, verticesTape, dartsTape, emitTape, outputTape] using h + +def computeTime (t : GraphTables.Table) : Nat := + (2 * (t.darts + 2) + (paddingTotal t + 1)) + (2 * (vertexTotal t + 1) + 1) + +theorem computeTrace (q : Nat) (t : GraphTables.Table) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program q)))^[computeTime t] + (some ⟨some (.copyFirst .count), ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord (paddingTotal t)) (encodeWord t.darts) + [] [] [] [] [] [] output⟩) = + some ⟨some (.copyFirst .rEmit), ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord 0) (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] output⟩ := by + have hc := MachineCopy.copyTrace mTape verticesTape scratchTape (by decide) (by decide) + (by decide) false (Label.copyFirst .count) (Label.copySecond .count) (some Label.add) + (program q) rfl rfl + (frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord (paddingTotal t)) (encodeWord t.darts) + [] [] [] [] [] [] output) rfl (ambient, false) register + simp only [frame_m, frame_vertices, encodeWord_length, List.append_nil, update_frame_vertices] at hc + have ha := MachineUnaryAddAt.addFromTapes sumTape verticesTape (by decide) + Label.add (some Label.scaleSeed) (program q) rfl + (frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord (paddingTotal t)) (encodeWord t.darts) + [] [] [] (encodeWord t.darts) [] [] output) + (paddingTotal t) t.darts [] [] (by simp) (by simp) (ambient, false) none + simp only [MachineUnaryAddAt.unaryTapes, Reduction.MachineTransfer.tapesAt, + List.append_nil, update_frame_sum, update_frame_vertices] at ha + rw [show paddingTotal t + t.darts = vertexTotal t by rw [vertexTotal_eq]; omega] at ha + have hm := MachineUnaryAffineAt.seededAffineTrace verticesTape scratchTape dartsTape + (by decide) (by decide) (by decide) (q + 1) 0 Label.scaleSeed Label.scaleScan + Label.scaleRestore (some (Label.copyFirst .rEmit)) (program q) rfl rfl rfl + (frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord 0) (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) [] [] output) + (vertexTotal t) [] (by simp) rfl (ambient, false) none + simp only [frame_darts, List.append_nil, Nat.add_zero, update_frame_darts] at hm + rw [show (q + 1) * vertexTotal t = dartTotal q t by unfold dartTotal; ac_rfl] at hm + exact appendTrace _ (appendTrace _ hc ha) hm + +def headerBits (q : Nat) (t : GraphTables.Table) : List Bool := + encodeWords [vertexTotal t, dartTotal q t] + +theorem headerBits_eq (q : Nat) (t : GraphTables.Table) : + headerBits q t = encodeWord (vertexTotal t) ++ encodeWord (dartTotal q t) := by + simp only [headerBits, encodeWords, List.append_nil] + +theorem headerBits_length (q : Nat) (t : GraphTables.Table) : + (headerBits q t).length = vertexTotal t + dartTotal q t + 2 := by + rw [headerBits_eq] + simp only [List.length_append, encodeWord_length] + omega + +theorem cleanupZerosStep (q : Nat) (table n m N R output : List Bool) (ambient : σ) + (register : Option Bool) : + TM2.step (program q) + ⟨some .cleanupZeros, ((ambient, false), register), + frame table n n (encodeWord 0) (encodeWord 0) m [] [] [] N R [] output⟩ = + some ⟨some .clearQuery, ((ambient, false), none), + frame table n n [] [] m [] [] [] N R [] output⟩ := by + simp [TM2.step, program, TM2.stepAux, encodeWord] + +def emitTime (q : Nat) (t : GraphTables.Table) (output : List Bool) : Nat := + (((2 * (dartTotal q t + 2) + 2 * (vertexTotal t + 2)) + + (2 * ((headerBits q t).length + output.length) + 3)) + 1) + (t.vertices + 1) + 1 + +theorem emitTrace (q : Nat) (t : GraphTables.Table) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program q)))^[emitTime q t output] + (some ⟨some (.copyFirst .rEmit), ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord 0) (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] output⟩) = + some ⟨none, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] + (output ++ headerBits q t)⟩ := by + have hr := MachineCopy.copyTrace dartsTape emitTape scratchTape (by decide) (by decide) + (by decide) false (Label.copyFirst .rEmit) (Label.copySecond .rEmit) + (some (Label.copyFirst .nEmit)) (program q) rfl rfl + (frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord 0) (encodeWord t.darts) [] [] [] + (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] output) + rfl (ambient, false) register + simp only [frame_darts, frame_emit, encodeWord_length, List.append_nil, update_frame_emit] at hr + have hn := MachineCopy.copyTrace verticesTape emitTape scratchTape (by decide) (by decide) + (by decide) false (Label.copyFirst .nEmit) (Label.copySecond .nEmit) + (some Label.appendFirst) (program q) rfl rfl + (frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord 0) (encodeWord t.darts) [] [] [] + (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) (encodeWord (dartTotal q t)) output) + rfl (ambient, false) none + simp only [frame_vertices, frame_emit, encodeWord_length, update_frame_emit, ← headerBits_eq] at hn + have ha := MachineAppendAt.appendTrace emitTape outputTape scratchTape + (by decide) (by decide) (by decide) false Label.appendFirst Label.appendSecond Label.appendThird + (some Label.cleanupZeros) (program q) rfl rfl rfl + (frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord 0) (encodeWord t.darts) [] [] [] + (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) (headerBits q t) output) + rfl (ambient, false) none + simp only [frame_emit, frame_output, MachineAppendAt.appendTapes, + Reduction.MachineTransfer.tapesAt, update_frame_emit, update_frame_output] at ha + have hz : (advance (TM2.step (program q)))^[1] + (some ⟨some .cleanupZeros, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + (encodeWord 0) (encodeWord 0) (encodeWord t.darts) [] [] [] + (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] (output ++ headerBits q t)⟩) = + some ⟨some .clearQuery, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + [] [] (encodeWord t.darts) [] [] [] (encodeWord (vertexTotal t)) + (encodeWord (dartTotal q t)) [] (output ++ headerBits q t)⟩ := + cleanupZerosStep q _ _ _ _ _ _ ambient none + have hc := MachineLookup.discardTrace queryTape Label.clearQuery Label.done (program q) rfl + (frame (GraphTables.tableBits t) (encodeWord t.vertices) (encodeWord t.vertices) + [] [] (encodeWord t.darts) [] [] [] (encodeWord (vertexTotal t)) + (encodeWord (dartTotal q t)) [] (output ++ headerBits q t)) + t.vertices [] (by simp) (ambient, false) none + simp only [update_frame_query] at hc + have hd : (advance (TM2.step (program q)))^[1] + (some ⟨some .done, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] + (output ++ headerBits q t)⟩) = + some ⟨none, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] + (output ++ headerBits q t)⟩ := rfl + exact appendTrace _ (appendTrace _ (appendTrace _ (appendTrace _ (appendTrace _ hr hn) ha) hz) hc) hd + +def totalTime (q : Nat) (t : GraphTables.Table) (output : List Bool) : Nat := + ((readTime t + MachineCloudPrefix.totalTime t t.vertices []) + computeTime t) + emitTime q t output + +theorem trace (q : Nat) (t : GraphTables.Table) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program q)))^[totalTime q t output] + (some ⟨some .init, ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] [] [] [] [] [] [] [] output⟩) = + some ⟨none, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] + (output ++ headerBits q t)⟩ := + appendTrace _ (appendTrace _ (appendTrace _ (readTrace q t output ambient register) + (prefixTrace q t output ambient none)) (computeTrace q t output ambient none)) + (emitTrace q t output ambient none) + +noncomputable def arithmeticPolynomial (q : Nat) : Polynomial Nat := + let X : Polynomial Nat := Polynomial.X + let G : Polynomial Nat := Polynomial.C ExpanderFamily.growth * X + let D : Polynomial Nat := Polynomial.C (ExpanderFamily.growth * (q + 1)) * X + (12 * X + 11) + ((2 * (X + 2) + (G + 1)) + (2 * (G + 1) + 1)) + + (((2 * (D + 2) + 2 * (G + 2)) + (2 * ((G + D + 2) + X) + 3)) + 1 + (X + 1) + 1) + +noncomputable def timePolynomial (q : Nat) : Polynomial Nat := + MachineCloudPrefix.timePolynomial.comp (2 * Polynomial.X + 1) + arithmeticPolynomial q + +theorem totalTime_le (q : Nat) (t : GraphTables.Table) (output : List Bool) : + totalTime q t output ≤ (timePolynomial q).eval ((GraphTables.tableBits t).length + output.length) := by + let L := (GraphTables.tableBits t).length + output.length + have hT : (GraphTables.tableBits t).length ≤ L := by unfold L; omega + have hO : output.length ≤ L := by unfold L; omega + have hn := (GraphTables.vertices_le_tableBits_length t).trans hT + have hm := (GraphTables.darts_le_tableBits_length t).trans hT + have hN : vertexTotal t ≤ ExpanderFamily.growth * L := + (PreprocessingMachineBounds.regularVertices_le_input t).trans + (Nat.mul_le_mul_left ExpanderFamily.growth hT) + have hS : paddingTotal t ≤ ExpanderFamily.growth * L := + (PreprocessingMachineBounds.prefix_le_input t t.vertices).trans + (Nat.mul_le_mul_left ExpanderFamily.growth hT) + have hR : dartTotal q t ≤ (ExpanderFamily.growth * (q + 1)) * L := by + calc + _ ≤ (ExpanderFamily.growth * L) * (q + 1) := Nat.mul_le_mul_right (q + 1) hN + _ = _ := by ac_rfl + have hr0 := MachinePreservingLookupClean.steps_le (GraphTables.tableWords t) 0 t.vertices + (by simp [GraphTables.tableWords]) + have hr1 := MachinePreservingLookupClean.steps_le (GraphTables.tableWords t) 1 t.darts + (by simp [GraphTables.tableWords]) + have hread : readTime t ≤ 12 * L + 11 := by + change _ ≤ 6 * (GraphTables.tableBits t).length + 4 at hr0 hr1 + unfold readTime + omega + have hprefixInput : MachineCloudPrefix.inputLength t t.vertices [] ≤ 2 * L + 1 := by + simp only [MachineCloudPrefix.inputLength, List.append_nil, encodeWord_length] + omega + have hp := (MachineCloudPrefix.totalTime_le t t.vertices (Nat.le_refl _) []).trans + (natPolynomial_eval_mono MachineCloudPrefix.timePolynomial hprefixInput) + have harith : readTime t + computeTime t + emitTime q t output ≤ + (arithmeticPolynomial q).eval L := by + simp only [arithmeticPolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat, Polynomial.eval_one] + unfold computeTime emitTime + rw [headerBits_length] + omega + have htotal := Nat.add_le_add hp harith + simpa only [totalTime, timePolynomial, Polynomial.eval_add, Polynomial.eval_comp, + Polynomial.eval_mul, Polynomial.eval_ofNat, Polynomial.eval_X, Polynomial.eval_one, + L, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using htotal + +def inTime (q : Nat) (t : GraphTables.Table) (output : List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program q)) + ⟨some .init, ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] [] [] [] [] [] [] [] output⟩ + (some ⟨none, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord t.vertices) [] [] [] (encodeWord t.darts) + [] [] [] (encodeWord (vertexTotal t)) (encodeWord (dartTotal q t)) [] + (output ++ headerBits q t)⟩) + ((timePolynomial q).eval ((GraphTables.tableBits t).length + output.length)) where + steps := totalTime q t output + evals_in_steps := trace q t output ambient register + steps_le_m := totalTime_le q t output + +end Header + +namespace Fuel + +variable {K Λ σ : Type} [DecidableEq K] + +def guard (fuel : K) (body : Λ) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool) := + .pop fuel (fun s bit => (s.1, bit)) + (.branch (fun s => s.2.getD false) + (.load (fun s => (s.1, none)) (.goto fun _ => body)) + (.load (fun s => (s.1, none)) + (match exit with | some label => .goto fun _ => label | none => .halt))) + +theorem guard_succ (fuel : K) (body : Λ) (exit : Option Λ) + (base : K → List Bool) (n : Nat) (ambient : σ) (register : Option Bool) : + TM2.stepAux (guard fuel body exit) (ambient, register) + (Function.update base fuel (encodeWord (n + 1))) = + ⟨some body, (ambient, none), Function.update base fuel (encodeWord n)⟩ := by + simp [guard, TM2.stepAux, encodeWord, List.replicate_succ] + +theorem guard_zero (fuel : K) (body : Λ) (exit : Option Λ) + (base : K → List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (guard fuel body exit) (ambient, register) + (Function.update base fuel (encodeWord 0)) = + ⟨exit, (ambient, none), Function.update base fuel []⟩ := by + cases exit <;> simp [guard, TM2.stepAux, encodeWord] + +def increment (counter : K) (next : Λ) : TM2.Stmt (fun _ : K => Bool) Λ σ := + .push counter (fun _ => true) (.goto fun _ => next) + +theorem increment_step (counter : K) (next : Λ) (base : K → List Bool) + (n : Nat) (state : σ) : + TM2.stepAux (increment counter next) state (Function.update base counter (encodeWord n)) = + ⟨some next, state, Function.update base counter (encodeWord (n + 1))⟩ := by + simp [increment, TM2.stepAux, encodeWord, List.replicate_succ] + +end Fuel + +namespace Top + +abbrev Body := MachineRegularOriginalBody.Tape +abbrev Tape := Body ⊕ (Header.Tape ⊕ Fin 4) +abbrev Alphabet (_ : Tape) := Bool +abbrev State := MachineRegularOriginalBody.State × Option Bool +abbrev Data := MachineRegularMetadata.Data +abbrev BaseTable := PreprocessingRegularTables.BaseTable + +private def sumDecidableEq {A B : Type} (left : DecidableEq A) (right : DecidableEq B) : + DecidableEq (A ⊕ B) + | .inl a, .inl b => match left a b with + | .isTrue h => .isTrue (congrArg (Sum.inl : A → A ⊕ B) h) + | .isFalse h => .isFalse (fun e => h (Sum.inl.inj e)) + | .inr a, .inr b => match right a b with + | .isTrue h => .isTrue (congrArg (Sum.inr : B → A ⊕ B) h) + | .isFalse h => .isFalse (fun e => h (Sum.inr.inj e)) + | .inl _, .inr _ => .isFalse (by intro h; cases h) + | .inr _, .inl _ => .isFalse (by intro h; cases h) + +instance tapeDecidableEq : DecidableEq Tape := + sumDecidableEq + (sumDecidableEq (inferInstanceAs (DecidableEq (Fin 27))) + (sumDecidableEq (inferInstanceAs (DecidableEq MachineRegularMetadata.Extra)) + (sumDecidableEq + (sumDecidableEq + (sumDecidableEq (inferInstanceAs (DecidableEq MachineExpanderRow.Tape)) + (inferInstanceAs (DecidableEq MachineExpanderTable.ExtraTape))) + (inferInstanceAs (DecidableEq MachineExpanderFamily.ExtraTape))) + (inferInstanceAs (DecidableEq MachineCeilingPower.Tape))))) + (sumDecidableEq + (sumDecidableEq (inferInstanceAs (DecidableEq MachineCloudPrefix.Tape)) + (inferInstanceAs (DecidableEq Header.Extra))) + (inferInstanceAs (DecidableEq (Fin 4)))) + +instance tapeBEq : BEq Tape where + beq a b := decide (a = b) + +instance tapeLawfulBEq : LawfulBEq Tape where + eq_of_beq := of_decide_eq_true + rfl := of_decide_eq_self_eq_true _ + +instance tapeFintype : Fintype Tape := by + change Fintype + ((Fin 27 ⊕ (MachineRegularMetadata.Extra ⊕ + (((MachineExpanderRow.Tape ⊕ MachineExpanderTable.ExtraTape) ⊕ + MachineExpanderFamily.ExtraTape) ⊕ MachineCeilingPower.Tape))) ⊕ + ((MachineCloudPrefix.Tape ⊕ Header.Extra) ⊕ Fin 4)) + infer_instance + +def coreTape (i : Fin 27) : Tape := .inl (.inl i) +def oldFuel : Tape := .inr (.inr 0) +def ownerFuel : Tape := .inr (.inr 1) +def dummyFuel : Tape := .inr (.inr 2) +def scratch : Tape := .inr (.inr 3) + +def headerTape (k : Header.Tape) : Tape := + if k = Header.tableTape then coreTape 0 + else if k = Header.mTape then coreTape 6 + else if k = Header.outputTape then coreTape 8 + else .inr (.inl k) + +def headerView : Tape → Option Header.Tape + | .inl (.inl i) => match i.val with + | 0 => some Header.tableTape + | 6 => some Header.mTape + | 8 => some Header.outputTape + | _ => none + | .inl (.inr _) => none + | .inr (.inl k) => + if k = Header.tableTape ∨ k = Header.mTape ∨ k = Header.outputTape then none else some k + | .inr (.inr _) => none + +theorem headerView_left (k : Header.Tape) : headerView (headerTape k) = some k := by + by_cases ht : k = Header.tableTape + · subst k; rfl + by_cases hm : k = Header.mTape + · subst k; rfl + by_cases ho : k = Header.outputTape + · subst k; rfl + simp [headerTape, headerView, ht, hm, ho] + +theorem headerView_right (j : Tape) (k : Header.Tape) + (h : headerView j = some k) : headerTape k = j := by + cases j with + | inl j => + cases j with + | inl i => + fin_cases i <;> simp_all [headerView] <;> subst k <;> rfl + | inr e => cases h + | inr j => + cases j with + | inl i => + by_cases hi : i = Header.tableTape ∨ i = Header.mTape ∨ i = Header.outputTape + · simp [headerView, hi] at h + · have hik : i = k := by simpa [headerView, hi] using h + subst k + simp only [not_or] at hi + simp [headerTape, hi.1, hi.2.1, hi.2.2] + | inr i => cases h + +def bodyView : Tape → Option Body + | .inl k => some k + | .inr _ => none + +theorem bodyView_left (k : Body) : bodyView (.inl k) = some k := rfl +theorem bodyView_right (j : Tape) (k : Body) + (h : bodyView j = some k) : Sum.inl k = j := by + cases j with + | inl j => cases h; rfl + | inr j => cases h + +def ownerTape : MachineRegularOwnerBody.Tape → Tape + | .inl k => .inl k + | .inr i => if i.val = 0 then dummyFuel else scratch + +def ownerView : Tape → Option MachineRegularOwnerBody.Tape + | .inl k => some (.inl k) + | .inr (.inl _) => none + | .inr (.inr i) => match i.val with + | 2 => some (.inr 0) + | 3 => some (.inr 1) + | _ => none + +theorem ownerView_left (k : MachineRegularOwnerBody.Tape) : + ownerView (ownerTape k) = some k := by + cases k with + | inl k => rfl + | inr i => fin_cases i <;> rfl + +theorem ownerView_right (j : Tape) (k : MachineRegularOwnerBody.Tape) + (h : ownerView j = some k) : ownerTape k = j := by + cases j with + | inl j => cases h; rfl + | inr j => + cases j with + | inl j => cases h + | inr i => fin_cases i <;> simp_all [ownerView] <;> subst k <;> rfl + +end Top +end IndependentSetsGames.Foundations.Complexity.MachineRegularTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Copy.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Copy.lean new file mode 100644 index 0000000000000000000000000000000000000000..44e089ed6338c2fa973997dbaad437685e8f4d26 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Copy.lean @@ -0,0 +1,256 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.FinalLabel + +namespace OAI + +namespace IndependentSetsCut.CounterMachine + +section +open scoped BigOperators +variable {R : Type} [DecidableEq R] + +omit [DecidableEq R] in +@[ext] theorem Data.ext {d e : Data R} (hr : d.reg = e.reg) + (hi : d.input = e.input) (hb : d.backup = e.backup) (ho : d.output = e.output) : d = e := by + cases d; cases e; simp_all + +namespace Command + +theorem Within.loop (r : R) (b : Command R) (state : ℕ → Data R) (n B : ℕ) + (hr : ∀ i ≤ n, (state i).reg r = i) + (hb : ∀ i < n, Within b (decData (state (i+1)) r) (state i) B) : + Within (.loop r b) (state n) (state 0) (n * (B + 1) + 1) := by + induction n with + | zero => exact ⟨1, by omega, Evaluates.loop_zero (hr 0 le_rfl)⟩ + | succ n ih => + obtain ⟨a, ha, ea⟩ := hb n (by omega) + obtain ⟨b', hb', eb⟩ := ih (fun i hi => hr i (by omega)) (fun i hi => hb i (by omega)) + refine ⟨1 + a + b', ?_, Evaluates.loop_pos (by rw [hr (n+1) le_rfl]; omega) ea eb⟩ + nlinarith + + theorem Within.inc (d : Data R) (r : R) : Within (.inc r) d (incData d r) 1 := + ⟨1, le_rfl, Evaluates.inc d r⟩ + theorem Within.dec (d : Data R) (r : R) : Within (.dec r) d (decData d r) 1 := + ⟨1, le_rfl, Evaluates.dec d r⟩ + theorem Within.skip (d : Data R) : Within (.skip : Command R) d d 1 := + ⟨1, le_rfl, Evaluates.skip d⟩ + theorem Within.clear (d : Data R) (r : R) : + Within (clear r) d (d.set r 0) (2*d.reg r+1) := + ⟨_, le_rfl, clear_evaluates d r⟩ + theorem Within.move (d : Data R) (r s : R) (h : r ≠ s) : + Within (move r s) d ((d.set r 0).set s (d.reg s+d.reg r)) (2*d.reg r+1) := + ⟨_, le_rfl, move_evaluates d r s h⟩ + +def copy (r s t : R) : Command R := + .seq (.loop r (.seq (.inc s) (.inc t))) (move t r) + + theorem copy_evaluates (d : Data R) (r s t : R) + (hrs : r ≠ s) (hrt : r ≠ t) (hst : s ≠ t) (ht : d.reg t = 0) : + Within (copy r s t) d (d.set s (d.reg s + d.reg r)) (5*d.reg r+2) := by + let n := d.reg r + let state : ℕ → Data R := fun i => ((d.set r i).set s (d.reg s+n-i)).set t (n-i) + have hn : state n = d := by + ext u <;> simp [state, Data.set, n] + by_cases hu : u = r <;> by_cases hs : u = s <;> by_cases ht' : u = t <;> simp_all + have hloop : Within (.loop r (.seq (.inc s) (.inc t))) (state n) (state 0) (n*3+1) := by + apply Within.loop r _ state n 2 + · intro i hi; simp [state, Data.set, hrs, hrt] + · intro i hi + have he := (Within.inc (decData (state (i+1)) r) s).seq + (Within.inc (incData (decData (state (i+1)) r) s) t) + have hout : incData (incData (decData (state (i+1)) r) s) t = state i := by + ext u <;> simp only [incData, decData, state, Data.set] + by_cases hu : u = r <;> by_cases hs : u = s <;> by_cases ht' : u = t <;> + simp [hu, hs, ht', hrs, hrt, hst, Ne.symm hrs, Ne.symm hrt, Ne.symm hst] <;> omega + simpa only [hout] using he + rw [hn] at hloop + have hm := Within.move (state 0) t r (Ne.symm hrt) + have hout : ((state 0).set t 0).set r ((state 0).reg r + (state 0).reg t) = + d.set s (d.reg s + d.reg r) := by + ext u <;> simp only [state, Data.set] + by_cases hu : u = r <;> by_cases hs : u = s <;> by_cases ht' : u = t <;> + simp [hu, hs, ht', hrs, hrt, hst, Ne.symm hrs, Ne.symm hrt, Ne.symm hst, ht, n] + have ht' : (state 0).reg t = n := by simp [state, Data.set] + have h := hloop.seq hm + rw [hout, ht'] at h + convert h using 1 <;> dsimp [copy, n] ; omega + +def mulAdd (count source target backup : R) : Command R := + .loop count (copy source target backup) + + theorem mulAdd_evaluates (d : Data R) (c r s t : R) + (hcr : c ≠ r) (hcs : c ≠ s) (hct : c ≠ t) + (hrs : r ≠ s) (hrt : r ≠ t) (hst : s ≠ t) (ht : d.reg t = 0) : + Within (mulAdd c r s t) d ((d.set c 0).set s (d.reg s+d.reg c*d.reg r)) + (d.reg c*(5*d.reg r+3)+1) := by + let n := d.reg c + let state : ℕ → Data R := fun i => (d.set c i).set s (d.reg s+(n-i)*d.reg r) + have hn : state n = d := by + simp [state, n] + have hloop : Within (.loop c (copy r s t)) (state n) (state 0) + (n*(5*d.reg r+3)+1) := by + apply Within.loop c _ state n (5*d.reg r+2) + · intro i hi; simp [state, Data.set, hcs] + · intro i hi + have hr' : (decData (state (i+1)) c).reg r = d.reg r := by + simp [state, decData, Data.set, Ne.symm hcr, hrs] + have ht' : (decData (state (i+1)) c).reg t = 0 := by + simp [state, decData, Data.set, Ne.symm hct, Ne.symm hst, ht] + have h := copy_evaluates (decData (state (i+1)) c) r s t hrs hrt hst ht' + rw [hr'] at h + have hout : (decData (state (i+1)) c).set s + ((decData (state (i+1)) c).reg s + d.reg r) = state i := by + have hh : (n-(i+1))*d.reg r+d.reg r = (n-i)*d.reg r := by + have : n-i = n-(i+1)+1 := by omega + rw [this, Nat.add_mul, Nat.one_mul] + ext u <;> simp only [decData, state, Data.set] + by_cases hu : u = c <;> by_cases hs : u = s <;> + simp [hu, hs, hcs, Ne.symm hcs, Nat.add_assoc] ; omega + simpa only [hout] using h + simpa [mulAdd, hn, state, n] using hloop + +end Command +end + +variable {R : Type} [DecidableEq R] +namespace Command + +def put (r : R) : ℕ → Command R + | 0 => .skip + | n+1 => .seq (.inc r) (put r n) + + theorem put_evaluates (d : Data R) (r : R) (n : ℕ) : + Within (put r n) d (d.set r (d.reg r+n)) (n+1) := by + induction n generalizing d with + | zero => simpa [put] using Within.skip d + | succ n ih => + have h := (Within.inc d r).seq (ih (incData d r)) + have he : (incData d r).set r ((incData d r).reg r+n) = d.set r (d.reg r+(n+1)) := by + simp [incData, Data.set, Nat.add_assoc, Nat.add_comm] + rw [he] at h + simpa only [put, show 1+(n+1) = n+1+1 by omega] using h + + def subFrom (r s : R) : Command R := .loop r (.dec s) + + theorem subFrom_evaluates (d : Data R) (r s : R) (h : r ≠ s) : + Within (subFrom r s) d ((d.set r 0).set s (d.reg s-d.reg r)) (2*d.reg r+1) := by + let n := d.reg r + let state : ℕ → Data R := fun i => (d.set r i).set s (d.reg s-(n-i)) + have hn : state n = d := by simp [state, n] + have hl : Within (.loop r (.dec s)) (state n) (state 0) (n*2+1) := by + apply Within.loop r _ state n 1 + · intro i hi; simp [state, Data.set, h] + · intro i hi + have he : decData (decData (state (i+1)) r) s = state i := by + ext u <;> simp only [decData, state, Data.set] + by_cases hu : u = r <;> by_cases hs : u = s <;> + simp [hu, hs, h, Ne.symm h] ; omega + simpa only [he] using Within.dec (decData (state (i+1)) r) s + simpa [subFrom, state, n, hn, Nat.mul_comm] using hl + + theorem rewind_evaluates (d : Data R) : + Within (.rewind : Command R) d {d with input := d.backup.reverse++d.input, backup := []} + (d.backup.length+1) := by + generalize he : d.backup = xs + induction xs generalizing d with + | nil => + have hd : {d with input := [].reverse++d.input, backup := []} = d := by + cases d; simp_all + exact ⟨1, by simp, by rw [hd]; exact Evaluates.rewind_empty he⟩ + | cons b rest ih => + have hb : (backData d).backup = rest := by simp [backData, he] + obtain ⟨n, hn, h⟩ := ih (backData d) hb + have hout : {backData d with input := rest.reverse++(backData d).input, backup := []} = + {d with input := (b::rest).reverse++d.input, backup := []} := by + simp [backData, he, List.reverse_cons, List.append_assoc] + rw [hout] at h + exact ⟨1+n, by simp; omega, Evaluates.rewind_cons he h⟩ + +def skipInput (r : R) : Command R := .loop r (.read .skip .skip .skip) + + theorem skipInput_evaluates (d : Data R) (r : R) : + Within (skipInput r) d + {(d.set r 0) with input := d.input.drop (d.reg r), backup := (d.input.take (d.reg r)).reverse++d.backup} + (3*d.reg r+1) := by + generalize hn : d.reg r = n + induction n generalizing d with + | zero => + have he : {d.set r 0 with input := d.input.drop 0, backup := (d.input.take 0).reverse++d.backup} = d := by + simp only [List.drop_zero, List.take_zero, List.reverse_nil, List.nil_append] + rw [← hn, Data.set_self] + rw [he] + exact ⟨1, by omega, Evaluates.loop_zero hn⟩ + | succ n ih => + let e := readData (decData d r) + have he : e.reg r = n := by simp [e, readData, decData, hn] + obtain ⟨a, ha, hr⟩ := ih e he + have hb : Evaluates (.read .skip .skip .skip) (decData d r) e 2 := by + cases hinput : d.input with + | nil => exact Evaluates.read_empty (d := decData d r) hinput (Evaluates.skip _) + | cons b rest => + cases b + · exact Evaluates.read_zero (d := decData d r) hinput (Evaluates.skip _) + · exact Evaluates.read_one (d := decData d r) hinput (Evaluates.skip _) + have hout : {e.set r 0 with input := e.input.drop n, backup := (e.input.take n).reverse++e.backup} = + {d.set r 0 with input := d.input.drop (n+1), backup := (d.input.take (n+1)).reverse++d.backup} := by + cases hi : d.input with + | nil => simp [e, readData, decData, Data.set, hi] + | cons b rest => simp [e, readData, decData, Data.set, hi, List.reverse_cons, List.append_assoc] + rw [hout] at hr + refine ⟨1+2+a, by omega, Evaluates.loop_pos (by omega) hb hr⟩ + +def inputBit (index result : R) : Command R := + .seq (skipInput index) (.seq (.read (.inc result) .skip .skip) .rewind) + + theorem inputBit_evaluates (d : Data R) (i r : R) (hir : i ≠ r) + (hb : d.backup = []) (hr : d.reg r = 0) : + Within (inputBit i r) d ((d.set i 0).set r (if d.input[d.reg i]?.getD false then 1 else 0)) + (3*d.reg i+d.input.length+4) := by + let e : Data R := {d.set i 0 with input := d.input.drop (d.reg i), backup := (d.input.take (d.reg i)).reverse++d.backup} + have he := skipInput_evaluates d i + let bit := (d.input[d.reg i]?).getD false + let f : Data R := (readData e).set r (if bit then 1 else 0) + have hread : Within (.read (.inc r) .skip .skip) e f 2 := by + have er : e.reg r = 0 := by simp [e, Data.set, Ne.symm hir, hr] + have bit_head : (e.input.head?).getD false = bit := by + simp [e, bit, List.head?_drop] + cases hi : e.input with + | nil => + have hbit : bit = false := by simpa [hi] using bit_head.symm + have hf : f = readData e := by simp [f, hbit, readData, ← er] + exact ⟨2, le_rfl, by rw [hf]; exact Evaluates.read_empty hi (Evaluates.skip _)⟩ + | cons b rest => + cases b + · have hbit : bit = false := by simpa [hi] using bit_head.symm + have hf : f = readData e := by simp [f, hbit, readData, ← er] + exact ⟨2, le_rfl, by rw [hf]; exact Evaluates.read_zero hi (Evaluates.skip _)⟩ + · have hbit : bit = true := by simpa [hi] using bit_head.symm + have hf : f = incData (readData e) r := by simp [f, hbit, incData, Data.set, readData, er] + exact ⟨2, le_rfl, by rw [hf]; exact Evaluates.read_one hi (Evaluates.inc _ _)⟩ + have hrew := rewind_evaluates f + have restored : {f with input := f.backup.reverse++f.input, backup := []} = + (d.set i 0).set r (if bit then 1 else 0) := by + have heq : e.backup.reverse ++ e.input = d.input := by + simp [e, hb] + have heq' : (readData e).backup.reverse ++ (readData e).input = d.input := by + rw [readData] + simp only [List.reverse_append, List.reverse_take] + cases hi : e.input <;> simpa [hi, List.append_assoc] using heq + apply Data.ext + · rfl + · exact heq' + · exact hb.symm + · rfl + have size : f.backup.length ≤ d.input.length := by + dsimp [f, Data.set, readData, e] + simp only [List.length_append, List.length_take, List.length_reverse, hb, List.length_nil, + add_zero, List.length_drop] + omega + have hh := he.seq (hread.seq hrew) + rw [restored] at hh + exact hh.mono (by omega) + +end Command +end IndependentSetsCut.CounterMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/CoreInputTapes.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/CoreInputTapes.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad795909773d4ca02ca2cc58de5621f7eaefea33 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/CoreInputTapes.lean @@ -0,0 +1,357 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.OldSelectSteps + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow +open Turing MachineComposition +open PCP +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) +variable {K Λ σ : Type} [DecidableEq K] + +theorem coreCleaned_memory (graph : List Bool) (x v i k o m : Nat) + (rotor output query scan flat localIndex returnPort selected : List Bool) : + coreCleaned (coreMemory graph x v i k o m rotor output query scan flat + localIndex returnPort selected) = + coreMemory graph x v i k o m rotor output [] [] [] [] [] [] := by + funext z + fin_cases z <;> rfl + +theorem coreCleanupSteps_memory (graph : List Bool) (x v i k o m : Nat) + (rotor output scan : List Bool) (j r z : Nat) : + coreCleanupSteps (coreMemory graph x v i k o m rotor output + (encodeWord 0) scan (encodeWord 0) (encodeWord j) (encodeWord r) (encodeWord z)) = + scan.length + j + r + z + 15 := by + change (encodeWord 0).length + scan.length + (encodeWord 0).length + + (encodeWord j).length + (encodeWord r).length + (encodeWord z).length + + ([] : List Bool).length + ([] : List Bool).length + ([] : List Bool).length + + ([] : List Bool).length + 10 = _ + simp only [encodeWord_length, List.length_nil] + omega + +theorem coreRotorFinalFrame {n q : Nat} (table : ExpanderTables.Table n q) (i : Fin n) (p : Fin q) + (graph : List Bool) (x v k o m : Nat) (output : List Bool) : + rotorFinalTapes table i p coreRotorTapes + (coreMemory graph x v i.val k o m + (encodeWords (ExpanderTableWords.rotationWords table)) output [] [] [] [] [] []) = + coreMemory graph x v i.val k o m + (encodeWords (ExpanderTableWords.rotationWords table)) output (encodeWord 0) + (encodeWords ((ExpanderTableWords.rotationWords table).drop (q * i.val + p.val + 1))) + (encodeWord 0) (encodeWord (ExpanderTables.lookup table (i, p)).1.val) + (encodeWord (ExpanderTables.lookup table (i, p)).2.val) [] := by + funext z + fin_cases z <;> + simp [rotorFinalTapes, coreRotorTapes, rotorLookupTapes, coreMemory, + MachineFixedDivMod.unaryTapes, MachineFixedDivMod.tapes, MachineCopy.forkTapes, + MachineAffineLookup.finalTapes, MachinePreservingLookup.finalTapes, MachineLookup.tapes] + +theorem coreRotorTrace {n q : Nat} (positive : 0 < q) (table : ExpanderTables.Table n q) + (i : Fin n) (p : Fin q) (labels : CoreLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = coreInstruction q positive p labels exit l) + (graph : List Bool) (x v k o m : Nat) (output : List Bool) (ambient : σ) : + (advance (TM2.step program))^[rotorSteps table i p] + (some ⟨some (labels (coreEntry q)), coreInitialState q positive ambient, + coreMemory graph x v i.val k o m + (encodeWords (ExpanderTableWords.rotationWords table)) output [] [] [] [] [] []⟩) = + some ⟨some (labels (.select (.inr (.compare .scan)))), coreInitialState q positive ambient, + coreMemory graph x v i.val k o m + (encodeWords (ExpanderTableWords.rotationWords table)) output (encodeWord 0) + (encodeWords ((ExpanderTableWords.rotationWords table).drop (q * i.val + p.val + 1))) + (encodeWord 0) (encodeWord (ExpanderTables.lookup table (i, p)).1.val) + (encodeWord (ExpanderTables.lookup table (i, p)).2.val) []⟩ := by + let e := coreRotorStateEquiv σ q + let backwards := MachineStateEquiv.program e.symm program + have atRotor (l : RotorLabel q) : + backwards (labels (.rotor l)) = rotorInstruction q positive p coreRotorTapes + (fun l => labels (.rotor l)) (some (labels (.select (.inr (.compare .scan))))) l := by + change MachineStateEquiv.statement e.symm (program (labels (.rotor l))) = _ + rw [code] + exact MachineStateEquiv.statement_symm_statement e _ + have run := rotorTrace positive table i p coreRotorTapes coreRotorTapes_injective + (fun l => labels (.rotor l)) (some (labels (.select (.inr (.compare .scan))))) + backwards atRotor + (coreMemory graph x v i.val k o m + (encodeWords (ExpanderTableWords.rotationWords table)) output [] [] [] [] [] []) + rfl rfl rfl rfl rfl rfl + ((ambient, MachineFixedBlockMap.emptyBuffer 4096), (false, MachineCloudSelect.Phase.checking)) none + have h := MachineStateEquiv.trace e backwards _ _ _ run + have backForward : MachineStateEquiv.program e backwards = program := by + have hp := MachineStateEquiv.program_symm_program e.symm program + simpa only [Equiv.symm_symm, backwards] using hp + rw [backForward] at h + change (advance (TM2.step program))^[rotorSteps table i p] + (some ⟨some (labels (coreEntry q)), coreInitialState q positive ambient, + coreMemory graph x v i.val k o m + (encodeWords (ExpanderTableWords.rotationWords table)) output [] [] [] [] [] []⟩) = + some ⟨some (labels (.select (.inr (.compare .scan)))), coreInitialState q positive ambient, + rotorFinalTapes table i p coreRotorTapes + (coreMemory graph x v i.val k o m + (encodeWords (ExpanderTableWords.rotationWords table)) output [] [] [] [] [] [])⟩ at h + rw [coreRotorFinalFrame] at h + exact h + +theorem coreSelectFrame (graph : List Bool) (x v i k o m j : Nat) + (rotor output query scan flat returnPort selected : List Bool) : + MachineCloudPadding.Placement.tapes coreSelectView + (selectMemory graph j v k o m [] selected [] [] [] []) + (coreMemory graph x v i k o m rotor output query scan flat (encodeWord j) returnPort []) = + coreMemory graph x v i k o m rotor output query scan flat (encodeWord j) returnPort selected := by + funext z + fin_cases z <;> rfl + +theorem coreSelectionTrace (q : Nat) (positive : 0 < q) (p : Fin q) + (labels : CoreLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = coreInstruction q positive p labels exit l) + (t : GraphTables.Table) (padding : Fin t.vertices → Nat) (v : Fin t.vertices) + (j : Fin (PreprocessingCloudIndex.cloudSize t v + padding v)) + (x i : Nat) (rotor output query scan flat returnPort : List Bool) (ambient : σ) : + (advance (TM2.step program))^[selectionSteps t padding v j] + (some ⟨some (labels (.select (.inr (.compare .scan)))), coreInitialState q positive ambient, + coreMemory (GraphTables.tableBits t) x v.val i (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts rotor output query scan flat + (encodeWord j.val) returnPort []⟩) = + some ⟨some (labels (.finish .seedReturn)), coreInitialState q positive ambient, + coreMemory (GraphTables.tableBits t) x v.val i (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts rotor output query scan flat + (encodeWord j.val) returnPort + (encodeWord (PreprocessingInternalRows.selectedIndex t padding v j))⟩ := by + let e := coreSelectStateEquiv σ q + let state := (ambient, (MachineFixedBlockMap.emptyBuffer 4096, + MachineFixedDivMod.residue q positive 0)) + have sourceRun := selectionTrace t padding v j state none + have moved := MachineStateEquiv.trace e selectProgram _ _ _ sourceRun + let base := coreMemory (GraphTables.tableBits t) x v.val i + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts rotor output query scan flat + (encodeWord j.val) returnPort [] + have placed := MachineCloudPadding.Placement.trace coreSelectTape coreSelectView + coreSelectView_left coreSelectView_right (fun l => labels (.select l)) + (some (labels (.finish .seedReturn))) base + (MachineStateEquiv.program e selectProgram) program (fun l => code (.select l)) + _ _ _ moved + simp only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, + MachineStateEquiv.configuration, base, coreSelectFrame] at placed + convert placed using 1 <;> rfl + +theorem coreFinishTrace (q : Nat) (positive : 0 < q) (p : Fin q) + (labels : CoreLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = coreInstruction q positive p labels exit l) + (graph : List Bool) (x v i k o m j r z : Nat) + (rotor output query scan flat : List Bool) (ambient : σ) : + (advance (TM2.step program))^[finishSteps q x z r output.length] + (some ⟨some (labels (.finish .seedReturn)), coreInitialState q positive ambient, + coreMemory graph x v i k o m rotor output query scan flat + (encodeWord j) (encodeWord r) (encodeWord z)⟩) = + some ⟨some (labels (.cleanup 0)), coreInitialState q positive ambient, + coreMemory graph x v i k o m rotor (output ++ emittedBits q x z r) query scan flat + (encodeWord j) (encodeWord r) (encodeWord z)⟩ := by + have h := finishTrace q coreFinishTapes coreFinishTapes_injective + (fun l => labels (.finish l)) (some (labels (.cleanup 0))) program + (fun l => code (.finish l)) + (coreMemory graph x v i k o m rotor output query scan flat + (encodeWord j) (encodeWord r) (encodeWord z)) + x z r rfl rfl rfl rfl rfl rfl rfl + (ambient, (MachineFixedBlockMap.emptyBuffer 4096, + (MachineFixedDivMod.residue q positive 0, (false, MachineCloudSelect.Phase.checking)))) none + change (advance (TM2.step program))^[finishSteps q x z r output.length] + (some ⟨some (labels (.finish .seedReturn)), coreInitialState q positive ambient, + coreMemory graph x v i k o m rotor output query scan flat + (encodeWord j) (encodeWord r) (encodeWord z)⟩) = + some ⟨some (labels (.cleanup 0)), coreInitialState q positive ambient, + Function.update (coreMemory graph x v i k o m rotor output query scan flat + (encodeWord j) (encodeWord r) (encodeWord z)) (8 : CoreTape) + (output ++ emittedBits q x z r)⟩ at h + rw [coreMemory_update_output] at h + exact h + +def coreInputTapes (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PreprocessingCloudIndex.PaddedCloud t padding v) + (output : List Bool) : CoreTape → List Bool := + coreMemory (GraphTables.tableBits t) + (PreprocessingRegularTables.vertexOrder t padding x.val).val v.val + (PreprocessingCloudIndex.paddedCloudRank t padding v x).val + (PreprocessingCloudIndex.cloudSize t v) (PreprocessingPaddingOffsets.offset padding v.val) t.darts + (encodeWords (ExpanderTableWords.rotationWords (tables v))) output [] [] [] [] [] [] + +def coreSteps (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PreprocessingCloudIndex.PaddedCloud t padding v) + (p : Fin q) (outputLength : Nat) : Nat := + let rank := PreprocessingCloudIndex.paddedCloudRank t padding v x + let step := ExpanderTables.lookup (tables v) (rank, p) + let selected := PreprocessingInternalRows.selectedIndex t padding v step.1 + let suffixBits := encodeWords ((ExpanderTableWords.rotationWords (tables v)).drop + (q * rank.val + p.val + 1)) + rotorSteps (tables v) rank p + selectionSteps t padding v step.1 + + finishSteps q (PreprocessingRegularTables.vertexOrder t padding x.val).val + selected step.2.val outputLength + + (suffixBits.length + step.1.val + step.2.val + selected + 15) + +theorem coreTrace (q : Nat) (positive : 0 < q) (p : Fin q) + (labels : CoreLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = coreInstruction q positive p labels exit l) + (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PreprocessingCloudIndex.PaddedCloud t padding v) + (output : List Bool) (ambient : σ) : + (advance (TM2.step program))^[coreSteps t padding tables v x p output.length] + (some ⟨some (labels (coreEntry q)), coreInitialState q positive ambient, + coreInputTapes t padding tables v x output⟩) = + some ⟨exit, coreInitialState q positive ambient, + coreInputTapes t padding tables v x + (output ++ encodeWords (GraphTables.rowWords + (PreprocessingInternalRows.row t padding tables v x p)))⟩ := by + let rank := PreprocessingCloudIndex.paddedCloudRank t padding v x + let step := ExpanderTables.lookup (tables v) (rank, p) + let z := PreprocessingInternalRows.selectedIndex t padding v step.1 + let X := (PreprocessingRegularTables.vertexOrder t padding x.val).val + let o := PreprocessingPaddingOffsets.offset padding v.val + let bits := encodeWords (ExpanderTableWords.rotationWords (tables v)) + let tailBits := encodeWords ((ExpanderTableWords.rotationWords (tables v)).drop + (q * rank.val + p.val + 1)) + let graph := GraphTables.tableBits t + let k := PreprocessingCloudIndex.cloudSize t v + have hr := coreRotorTrace positive (tables v) rank p labels exit program code + graph X v.val k o t.darts output ambient + have hs := coreSelectionTrace q positive p labels exit program code t padding v step.1 + X rank.val bits output (encodeWord 0) tailBits (encodeWord 0) (encodeWord step.2.val) ambient + have hf := coreFinishTrace q positive p labels exit program code + graph X v.val rank.val k o t.darts step.1.val step.2.val z bits output + (encodeWord 0) tailBits (encodeWord 0) ambient + have hc := coreCleanupTrace q positive p labels exit program code + (coreMemory graph X v.val rank.val k o t.darts bits + (output ++ emittedBits q X z step.2.val) + (encodeWord 0) tailBits (encodeWord 0) (encodeWord step.1.val) + (encodeWord step.2.val) (encodeWord z)) + (ambient, (MachineFixedBlockMap.emptyBuffer 4096, + (MachineFixedDivMod.residue q positive 0, (false, MachineCloudSelect.Phase.checking)))) + rw [coreCleanupSteps_memory, coreCleaned_memory] at hc + have h := joinTrace (joinTrace (joinTrace hr hs) hf) hc + have hbits : emittedBits q X z step.2.val = + encodeWords (GraphTables.rowWords (PreprocessingInternalRows.row t padding tables v x p)) := + emittedBits_eq_row t padding tables v x p + rw [hbits] at h + exact h + +theorem selectedIndex_le (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (PreprocessingCloudIndex.cloudSize t v + padding v)) : + PreprocessingInternalRows.selectedIndex t padding v i ≤ + t.darts + PreprocessingPaddingOffsets.offset padding v.val + i.val := by + unfold PreprocessingInternalRows.selectedIndex + split + · rename_i hi + have h := (PreprocessingCloudIndex.cloudSelect t v ⟨i.val, hi⟩).val.isLt + omega + · omega + +theorem encodedDrop_length_le (values : List Nat) (n : Nat) : + (encodeWords (values.drop n)).length ≤ (encodeWords values).length := by + have h : (encodeWords (values.take n)).length + (encodeWords (values.drop n)).length = + (encodeWords values).length := by + rw [← List.length_append, ← encodeWords_append, List.take_append_drop] + omega + +theorem rotorSize_le_encodedLength {n q : Nat} (positive : 0 < q) + (table : ExpanderTables.Table n q) : + n ≤ (encodeWords (ExpanderTableWords.rotationWords table)).length := by + have h : n * q ≤ (encodeWords (ExpanderTableWords.rotationWords table)).length := by + rw [encodeWords_length, ExpanderTableWords.rotationWords_length] + omega + exact (Nat.le_mul_of_pos_right n positive).trans h + +def coreTimeBound (q graphLength rotorLength x v i k o m outputLength : Nat) : Nat := + (5 * q + 32) * rotorLength + 10 * graphLength + 2 * i + 13 * v + 5 * k + + (5 * q + 10) * (m + o) + 4 * x + 2 * outputLength + 8 * q + 41066 + +theorem coreSteps_le (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PreprocessingCloudIndex.PaddedCloud t padding v) + (p : Fin q) (outputLength : Nat) : + coreSteps t padding tables v x p outputLength ≤ + coreTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + (PreprocessingRegularTables.vertexOrder t padding x.val).val v.val + (PreprocessingCloudIndex.paddedCloudRank t padding v x).val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts outputLength := by + let rank := PreprocessingCloudIndex.paddedCloudRank t padding v x + let step := ExpanderTables.lookup (tables v) (rank, p) + let z := PreprocessingInternalRows.selectedIndex t padding v step.1 + let X := (PreprocessingRegularTables.vertexOrder t padding x.val).val + let o := PreprocessingPaddingOffsets.offset padding v.val + let L := (GraphTables.tableBits t).length + let R := (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + let k := PreprocessingCloudIndex.cloudSize t v + let tailBits := encodeWords ((ExpanderTableWords.rotationWords (tables v)).drop + (q * rank.val + p.val + 1)) + have hN : k + padding v ≤ R := rotorSize_le_encodedLength positive (tables v) + have hj : step.1.val ≤ R := step.1.isLt.le.trans hN + have hr : step.2.val ≤ q := step.2.isLt.le + have hz : z ≤ t.darts + o + R := by + have h := selectedIndex_le t padding v step.1 + change z ≤ t.darts + o + step.1.val at h + omega + have hsize : (k + padding v) * q ≤ R := by + dsimp only [R, k] + rw [encodeWords_length, ExpanderTableWords.rotationWords_length] + omega + have hrotor : rotorSteps (tables v) rank p ≤ 2 * rank.val + 6 * R + 8 := by + have h := rotorSteps_le (tables v) rank p + change rotorSteps (tables v) rank p ≤ 2 * rank.val + 5 * R + (k + padding v) * q + 8 at h + omega + have hselect : selectionSteps t padding v step.1 ≤ + 10 * L + 16 * R + 13 * v.val + 5 * k + 2 * o + 2 * t.darts + 57 := by + have h := selectionSteps_le t padding v step.1 + change selectionSteps t padding v step.1 ≤ + 10 * L + 16 * step.1.val + 13 * v.val + 5 * k + 2 * o + 2 * t.darts + 57 at h + omega + have hfinish : finishSteps q X z step.2.val outputLength ≤ + (5 * q + 7) * (t.darts + o + R) + 7 * q + 4 * X + 2 * outputLength + 40986 := by + have h := finishSteps_le q X z step.2.val outputLength + have hm := Nat.mul_le_mul_left (5 * q + 7) hz + omega + have htail : tailBits.length ≤ R := encodedDrop_length_le + (ExpanderTableWords.rotationWords (tables v)) (q * rank.val + p.val + 1) + have hcleanup : tailBits.length + step.1.val + step.2.val + z + 15 ≤ + R + R + q + (t.darts + o + R) + 15 := by omega + calc + coreSteps t padding tables v x p outputLength + ≤ (2 * rank.val + 6 * R + 8) + + (10 * L + 16 * R + 13 * v.val + 5 * k + 2 * o + 2 * t.darts + 57) + + ((5 * q + 7) * (t.darts + o + R) + 7 * q + 4 * X + 2 * outputLength + 40986) + + (R + R + q + (t.darts + o + R) + 15) := + Nat.add_le_add (Nat.add_le_add (Nat.add_le_add hrotor hselect) hfinish) hcleanup + _ = _ := by + change _ = coreTimeBound q L R X v.val rank.val k o t.darts outputLength + unfold coreTimeBound + ring + +def coreMachineInTime (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (PreprocessingCloudIndex.cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PreprocessingCloudIndex.PaddedCloud t padding v) + (p : Fin q) (output : List Bool) : + StateTransition.EvalsToInTime (coreMachine q positive p).step + ⟨some (coreEntry q), coreInitialState q positive (), coreInputTapes t padding tables v x output⟩ + (some ⟨none, coreInitialState q positive (), coreInputTapes t padding tables v x + (output ++ encodeWords (GraphTables.rowWords (PreprocessingInternalRows.row t padding tables v x p)))⟩) + (coreTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + (PreprocessingRegularTables.vertexOrder t padding x.val).val v.val + (PreprocessingCloudIndex.paddedCloudRank t padding v x).val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts output.length) where + steps := coreSteps t padding tables v x p output.length + evals_in_steps := coreTrace q positive p id none (coreMachine q positive p).m + (fun _ => rfl) t padding tables v x output () + steps_le_m := coreSteps_le q positive t padding tables v x p output.length + +end IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Correct.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Correct.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6e7363903275a543ad7d86630d52101b410f4f9 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Correct.lean @@ -0,0 +1,207 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.LengthLoop + +namespace OAI + +namespace IndependentSetsCut.CounterMachine.Expr +open scoped BigOperators +open Finset Command + +def Correct (e : Expr) : Prop := ∀ (vars : ℕ → ℕ) (k : ℕ) (d : Data ℕ) (M : ℕ), + (∀ i, vars i < k) → d.Clean k → d.backup = [] → d.input.length ≤ M → + (∀ i, d.reg (vars i) ≤ M) → + Within (e.compile vars k) d (d.set k (e.eval d.input (fun i => d.reg (vars i)))) (e.timeBudget M) + + theorem correct_const (n : ℕ) : Correct (.const n) := by + intro vars k d M hv hc hb hi ha + simpa [compile, eval, timeBudget, hc k le_rfl] using put_evaluates d k n + + theorem correct_arg (i : ℕ) : Correct (.arg i) := by + intro vars k d M hv hc hb hi ha + have he := copy_evaluates d (vars i) k (k+1) (by have := hv i; omega) + (by have := hv i; omega) (by omega) (hc _ (by omega)) + simp only [hc k le_rfl, zero_add] at he + exact he.mono (by dsimp [timeBudget]; have := ha i; omega) + + theorem correct_length : Correct .length := by + intro vars k d M hv hc hb hi ha + exact (inputLength_evaluates d (k+1) k (by omega) (hc _ (by omega)) (hc _ le_rfl) hb).mono + (by dsimp [timeBudget]; omega) + + theorem binary_start {a b : Expr} (hca : Correct a) (hcb : Correct b) + (vars : ℕ → ℕ) (k : ℕ) (d : Data ℕ) (M : ℕ) + (hv : ∀ i, vars i < k) (hc : d.Clean k) (hb : d.backup = []) (hi : d.input.length ≤ M) + (ha : ∀ i, d.reg (vars i) ≤ M) : + Within (.seq (a.compile vars k) (b.compile vars (k+1))) d + ((d.set k (a.eval d.input (fun i => d.reg (vars i)))).set (k+1) + (b.eval d.input (fun i => d.reg (vars i)))) + (a.timeBudget M+b.timeBudget M) := by + have h1 := hca vars k d M hv hc hb hi ha + let A := a.eval d.input (fun i => d.reg (vars i)) + have h2 := hcb vars (k+1) (d.set k A) M (fun i => by have := hv i; omega) + (hc.set_succ A) hb hi (fun i => by + rw [Data.set_reg_ne d k (vars i) A (Nat.ne_of_lt (hv i))] + exact ha i) + rw [Data.set_args d vars k A hv] at h2 + exact h1.seq h2 + + theorem correct_add {a b : Expr} (hca : Correct a) (hcb : Correct b) : Correct (.add a b) := by + intro vars k d M hv hc hb hi ha + let A := a.eval d.input (fun i => d.reg (vars i)) + let B := b.eval d.input (fun i => d.reg (vars i)) + let e := (d.set k A).set (k+1) B + have hs := binary_start hca hcb vars k d M hv hc hb hi ha + have hm := Within.move e (k+1) k (by omega) + have hout : (e.set (k+1) 0).set k (e.reg k+e.reg (k+1)) = d.set k (A+B) := by + have hz := hc (k+1) (by omega) + apply Data.ext + · ext u + by_cases hu : u = k <;> by_cases hu' : u = k+1 <;> + simp [e, Data.set, hu, hu', hz] + all_goals rfl + have hm' : Within (move (k+1) k) e (d.set k (A+B)) (2*B+1) := by + rw [hout] at hm + simpa only [show e.reg (k+1) = B by simp [e]] using hm + obtain ⟨s, hsb, hse⟩ := hs + cases hse with + | seq h1 h2 => + have hh := (show Within _ _ _ _ from ⟨_,le_rfl,h1⟩).seq + ((show Within _ _ _ _ from ⟨_,le_rfl,h2⟩).seq hm') + exact hh.mono (by have hB := b.eval_le d.input _ M hi ha; dsimp [timeBudget, B] at *; omega) + + theorem correct_sub {a b : Expr} (hca : Correct a) (hcb : Correct b) : Correct (.sub a b) := by + intro vars k d M hv hc hb hi ha + let A := a.eval d.input (fun i => d.reg (vars i)) + let B := b.eval d.input (fun i => d.reg (vars i)) + let e := (d.set k A).set (k+1) B + have hs := binary_start hca hcb vars k d M hv hc hb hi ha + have hm := subFrom_evaluates e (k+1) k (by omega) + have hout : (e.set (k+1) 0).set k (e.reg k-e.reg (k+1)) = d.set k (A-B) := by + have hz := hc (k+1) (by omega) + apply Data.ext + · ext u + by_cases hu : u = k <;> by_cases hu' : u = k+1 <;> + simp [e, Data.set, hu, hu', hz] + all_goals rfl + have hm' : Within (subFrom (k+1) k) e (d.set k (A-B)) (2*B+1) := by + rw [hout] at hm + simpa only [show e.reg (k+1) = B by simp [e]] using hm + obtain ⟨s, hsb, hse⟩ := hs + cases hse with + | seq h1 h2 => + have hh := (show Within _ _ _ _ from ⟨_,le_rfl,h1⟩).seq + ((show Within _ _ _ _ from ⟨_,le_rfl,h2⟩).seq hm') + exact hh.mono (by have hB := b.eval_le d.input _ M hi ha; dsimp [timeBudget, B] at *; omega) + + theorem correct_zero {a : Expr} (hca : Correct a) : Correct (.zero a) := by + intro vars k d M hv hc hb hi ha + let A := a.eval d.input (fun i => d.reg (vars i)) + have h1 := hca vars k d M hv hc hb hi ha + have h2 : Within (.test k (.inc k) (clear k)) (d.set k A) + (d.set k (if A=0 then 1 else 0)) (2*A+2) := by + by_cases hA : A=0 + · refine ⟨2, by omega, Evaluates.test_zero (r := k) (n := 1) (d := d.set k A) (by simp [hA]) ?_⟩ + simpa [hA, incData, Data.set] using Evaluates.inc (d.set k A) k + · refine ⟨1+(2*A+1), by omega, Evaluates.test_pos (r := k) (d := d.set k A) (by simpa using hA) ?_⟩ + simpa [hA] using clear_evaluates (d.set k A) k + have h := h1.seq h2 + exact h.mono (by dsimp [timeBudget]; have := a.eval_le d.input _ M hi ha; dsimp [A] at *; omega) + + theorem correct_bit {a : Expr} (hca : Correct a) : Correct (.bit a) := by + intro vars k d M hv hc hb hi ha + let A := a.eval d.input (fun i => d.reg (vars i)) + let B := if (d.input[A]?).getD false then 1 else 0 + have h1 := hca vars k d M hv hc hb hi ha + have h2 := inputBit_evaluates (d.set k A) k (k+1) (by omega) hb + (by rw [Data.set_reg_ne _ _ _ _ (by omega)]; exact hc _ (by omega)) + have hout2 : ((d.set k A).set k 0).set (k+1) B = d.set (k+1) B := by + rw [Data.set_set, Data.set_clean_zero hc le_rfl] + simp only [Data.set_reg_same] at h2 + change Within (inputBit k (k+1)) (d.set k A) + (((d.set k A).set k 0).set (k+1) B) (3*A+d.input.length+4) at h2 + rw [hout2] at h2 + have h3 := Within.move (d.set (k+1) B) (k+1) k (by omega) + have hout3 : ((d.set (k+1) B).set (k+1) 0).set k + ((d.set (k+1) B).reg k+(d.set (k+1) B).reg (k+1)) = d.set k B := by + simp only [Data.set_set] + rw [Data.set_clean_zero hc (by omega)] + simp [Data.set, hc k le_rfl] + have h3' : Within (move (k+1) k) (d.set (k+1) B) (d.set k B) (2*B+1) := by + rw [hout3] at h3 + simpa only [Data.set_reg_same] using h3 + have h := h1.seq (h2.seq h3') + have hB : B ≤ 1 := by dsimp [B]; split_ifs <;> omega + exact h.mono (by have hA := a.eval_le d.input _ M hi ha; dsimp [timeBudget, A] at *; omega) + +end IndependentSetsCut.CounterMachine.Expr + +namespace IndependentSetsCut.CounterMachine.Command +variable {R : Type} [DecidableEq R] + theorem Within.assoc {a b c : Command R} {d e : Data R} {B : ℕ} + (h : Within (.seq (.seq a b) c) d e B) : Within (.seq a (.seq b c)) d e B := by + obtain ⟨n, hn, he⟩ := h + cases he with + | seq hab hc => + cases hab with + | seq ha hb => + exact ⟨_, by omega, Evaluates.seq ha (Evaluates.seq hb hc)⟩ +end IndependentSetsCut.CounterMachine.Command +namespace IndependentSetsCut.CounterMachine.Expr +open Command + + theorem correct_mul {a b : Expr} (hca : Correct a) (hcb : Correct b) : Correct (.mul a b) := by + intro vars k d M hv hc hb hi ha + let A := a.eval d.input (fun i => d.reg (vars i)) + let B := b.eval d.input (fun i => d.reg (vars i)) + let e := (d.set k A).set (k+1) B + have hs := binary_start hca hcb vars k d M hv hc hb hi ha + have hz1 := hc (k+1) (by omega) + have hz2 := hc (k+2) (by omega) + have hz3 := hc (k+3) (by omega) + have hm := mulAdd_evaluates e (k+1) k (k+2) (k+3) (by omega) (by omega) (by omega) + (by omega) (by omega) (by omega) (by simp [e, hz3, Data.set]) + have hout : (e.set (k+1) 0).set (k+2) (e.reg (k+2)+e.reg (k+1)*e.reg k) = + (d.set k A).set (k+2) (A*B) := by + apply Data.ext + · ext u + by_cases h0 : u = k <;> by_cases h1 : u = k+1 <;> by_cases h2 : u = k+2 <;> + simp [e, Data.set, h0, h1, h2, hz1, hz2, Nat.mul_comm] + all_goals rfl + rw [hout] at hm + have hm' : Within (mulAdd (k+1) k (k+2) (k+3)) e ((d.set k A).set (k+2) (A*B)) + (B*(5*A+3)+1) := by simpa [e, Data.set] using hm + let f := (d.set k A).set (k+2) (A*B) + have hf := Within.clear f k + have houtf : f.set k 0 = d.set (k+2) (A*B) := by + change (((d.set k A).set (k+2) (A*B)).set k 0) = _ + rw [Data.set_comm _ k (k+2) _ _ (by omega)] + rw [Data.set_set] + rw [Data.set_comm _ (k+2) k _ _ (by omega), Data.set_clean_zero hc le_rfl] + rw [houtf] at hf + have hf' : Within (clear k) f (d.set (k+2) (A*B)) (2*A+1) := by + simpa [f, Data.set] using hf + have hg := Within.move (d.set (k+2) (A*B)) (k+2) k (by omega) + have houtg : ((d.set (k+2) (A*B)).set (k+2) 0).set k + ((d.set (k+2) (A*B)).reg k+(d.set (k+2) (A*B)).reg (k+2)) = d.set k (A*B) := by + rw [Data.set_set, Data.set_clean_zero hc (by omega)] + simp [Data.set, hc k le_rfl] + rw [houtg] at hg + have hg' : Within (move (k+2) k) (d.set (k+2) (A*B)) (d.set k (A*B)) (2*(A*B)+1) := by + simpa only [Data.set_reg_same] using hg + have hh := (hs.seq (hm'.seq (hf'.seq hg'))).assoc + apply hh.mono + have hA := a.eval_le d.input _ M hi ha + have hB := b.eval_le d.input _ M hi ha + change a.timeBudget M+b.timeBudget M+(B*(5*A+3)+1+(2*A+1+(2*(A*B)+1))) ≤ _ + change A ≤ a.valueBudget M at hA + change B ≤ b.valueBudget M at hB + dsimp only [timeBudget] + calc + _ ≤ a.timeBudget M+b.timeBudget M+ + (b.valueBudget M*(5*a.valueBudget M+3)+1+ + (2*a.valueBudget M+1+(2*(a.valueBudget M*b.valueBudget M)+1))) := by gcongr + _ = _ := by omega + +end IndependentSetsCut.CounterMachine.Expr + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Enumeration.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Enumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..d57fe7f6dacaa8efe016ba2b3a899b091cac480b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Enumeration.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryEqualityBit +import OAI.Combinatorics.IndependentSets.Machines.Block +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineLoop + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineLoop +open Turing + +variable {K Λ σ : Type} [DecidableEq K] + +def rowBase (output : K) (base : K → List Bool) + (rowBlock : Nat → List Bool) (n r : Nat) : K → List Bool := + Function.update base output (remainingRows rowBlock n r ++ base output) + +def VertexBodyTraces (counter output : K) (guardLabel bodyLabel : Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) + (rowBlock : Nat → List Bool) (cost : Nat → Nat) (n : Nat) : Prop := + ∀ r, r < n → ∀ accumulator : List Bool, + (MachineComposition.advance (TM2.step program))^[cost r] + (some ⟨some bodyLabel, (ambient, none), + MachineUnaryCounter.counterTapes counter + (Function.update base output accumulator) r suffix⟩) = + some ⟨some guardLabel, (ambient, none), + MachineUnaryCounter.counterTapes counter + (Function.update base output (rowBlock r ++ accumulator)) r suffix⟩ + +theorem vertexBodyTraces_to_counted (counter output : K) (guardLabel bodyLabel : Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) + (rowBlock : Nat → List Bool) (cost : Nat → Nat) (n : Nat) + (bodies : VertexBodyTraces counter output guardLabel bodyLabel program + base suffix ambient rowBlock cost n) : + MachineCountedLoop.BodyTraces counter guardLabel bodyLabel program suffix + (fun _ => ambient) (fun _ => none) (rowBase output base rowBlock n) cost n := by + intro r hr + have h := bodies r hr (remainingRows rowBlock n (r + 1) ++ base output) + simpa only [MachineCountedLoop.bodyConfiguration, MachineCountedLoop.guardConfiguration, + rowBase, remainingRows_step rowBlock n r hr, List.append_assoc] using h + +def vertexLoopInTime (counter output : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) + (atGuard : program guardLabel = MachineUnaryCounter.guard counter bodyLabel exitLabel) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) + (rowBlock : Nat → List Bool) (cost : Nat → Nat) (n bodyBound : Nat) + (bodies : VertexBodyTraces counter output guardLabel bodyLabel program + base suffix ambient rowBlock cost n) + (bounded : ∀ r, r < n → cost r ≤ bodyBound) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some guardLabel, (ambient, none), + MachineUnaryCounter.counterTapes counter base n suffix⟩ + (some ⟨some exitLabel, (ambient, none), + MachineUnaryCounter.counterTapes counter + (rowBase output base rowBlock n 0) 0 suffix⟩) + (n * (bodyBound + 1) + 1) := by + have h := MachineCountedLoop.loopInTime counter guardLabel bodyLabel exitLabel + program atGuard suffix (fun _ => ambient) (fun _ => none) + (rowBase output base rowBlock n) cost n bodyBound + (vertexBodyTraces_to_counted counter output guardLabel bodyLabel program + base suffix ambient rowBlock cost n bodies) bounded + simpa [MachineCountedLoop.guardConfiguration, MachineCountedLoop.exitConfiguration, + rowBase] using h + +theorem vertexLoop_output (counter output : K) (different : output ≠ counter) + (base : K → List Bool) (suffix : List Bool) (rowBlock : Nat → List Bool) (n : Nat) : + MachineUnaryCounter.counterTapes counter (rowBase output base rowBlock n 0) 0 suffix output = + remainingRows rowBlock n 0 ++ base output := by + simp [MachineUnaryCounter.counterTapes, rowBase, different] + +def varyingRowBase (output : K) (base : Nat → K → List Bool) + (rowBlock : Nat → List Bool) (n r : Nat) : K → List Bool := + Function.update (base r) output (remainingRows rowBlock n r ++ base n output) + +def VaryingVertexBodyTraces (counter output : K) (guardLabel bodyLabel : Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) + (base : Nat → K → List Bool) (suffix : List Bool) (ambient : Nat → σ) + (rowBlock : Nat → List Bool) (cost : Nat → Nat) (n : Nat) : Prop := + ∀ r, r < n → ∀ accumulator : List Bool, + (MachineComposition.advance (TM2.step program))^[cost r] + (some ⟨some bodyLabel, (ambient (r + 1), none), + MachineUnaryCounter.counterTapes counter + (Function.update (base (r + 1)) output accumulator) r suffix⟩) = + some ⟨some guardLabel, (ambient r, none), + MachineUnaryCounter.counterTapes counter + (Function.update (base r) output (rowBlock r ++ accumulator)) r suffix⟩ + +theorem varyingVertexBodyTraces_to_counted (counter output : K) (guardLabel bodyLabel : Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) + (base : Nat → K → List Bool) (suffix : List Bool) (ambient : Nat → σ) + (rowBlock : Nat → List Bool) (cost : Nat → Nat) (n : Nat) + (bodies : VaryingVertexBodyTraces counter output guardLabel bodyLabel program + base suffix ambient rowBlock cost n) : + MachineCountedLoop.BodyTraces counter guardLabel bodyLabel program suffix + ambient (fun _ => none) (varyingRowBase output base rowBlock n) cost n := by + intro r hr + have h := bodies r hr (remainingRows rowBlock n (r + 1) ++ base n output) + simpa only [MachineCountedLoop.bodyConfiguration, MachineCountedLoop.guardConfiguration, + varyingRowBase, remainingRows_step rowBlock n r hr, List.append_assoc] using h + +def vertexLoopInTime_varying (counter output : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) + (atGuard : program guardLabel = MachineUnaryCounter.guard counter bodyLabel exitLabel) + (base : Nat → K → List Bool) (suffix : List Bool) (ambient : Nat → σ) + (rowBlock : Nat → List Bool) (cost : Nat → Nat) (n bodyBound : Nat) + (bodies : VaryingVertexBodyTraces counter output guardLabel bodyLabel program + base suffix ambient rowBlock cost n) + (bounded : ∀ r, r < n → cost r ≤ bodyBound) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some guardLabel, (ambient n, none), + MachineUnaryCounter.counterTapes counter (base n) n suffix⟩ + (some ⟨some exitLabel, (ambient 0, none), + MachineUnaryCounter.counterTapes counter + (varyingRowBase output base rowBlock n 0) 0 suffix⟩) + (n * (bodyBound + 1) + 1) := by + have h := MachineCountedLoop.loopInTime counter guardLabel bodyLabel exitLabel + program atGuard suffix ambient (fun _ => none) + (varyingRowBase output base rowBlock n) cost n bodyBound + (varyingVertexBodyTraces_to_counted counter output guardLabel bodyLabel program + base suffix ambient rowBlock cost n bodies) bounded + simpa [MachineCountedLoop.guardConfiguration, MachineCountedLoop.exitConfiguration, + varyingRowBase] using h + +theorem vertexLoop_varying_output (counter output : K) (different : output ≠ counter) + (base : Nat → K → List Bool) (suffix : List Bool) + (rowBlock : Nat → List Bool) (n : Nat) : + MachineUnaryCounter.counterTapes counter + (varyingRowBase output base rowBlock n 0) 0 suffix output = + remainingRows rowBlock n 0 ++ base n output := by + simp [MachineUnaryCounter.counterTapes, varyingRowBase, different] + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineLoop +namespace IndependentSetsGames.Foundations.Complexity.PoweringMasterState + +open Turing +open MachineFixedBlockMap + +abbrev OtherRegisters (N : Nat) := Buffer N × (Bool × Option Bool) +abbrev Master (N : Nat) := OtherRegisters N × Option Bool +abbrev CompareState (N : Nat) := Buffer N × (Bool × (Option Bool × Option Bool)) +abbrev RowState (N : Nat) := (Bool × (Option Bool × Option Bool)) × Buffer N + +def compareEquiv (N : Nat) : Master N ≃ CompareState N := + (MachineUnaryEqualityBit.compareStateEquiv (Buffer N)).symm + +def rowEquiv (N : Nat) : Master N ≃ RowState N where + toFun state := ((state.1.2.1, (state.1.2.2, state.2)), state.1.1) + invFun state := ((state.2, (state.1.1, state.1.2.1)), state.1.2.2) + left_inv := by rintro ⟨⟨buffer, ⟨flag, left⟩⟩, right⟩; rfl + right_inv := by rintro ⟨⟨flag, ⟨left, right⟩⟩, buffer⟩; rfl + +@[simp] theorem compareEquiv_apply (N : Nat) (buffer : Buffer N) + (flag : Bool) (left right : Option Bool) : + compareEquiv N ((buffer, (flag, left)), right) = (buffer, (flag, (left, right))) := rfl + +@[simp] theorem compareEquiv_symm_apply (N : Nat) (buffer : Buffer N) + (flag : Bool) (left right : Option Bool) : + (compareEquiv N).symm (buffer, (flag, (left, right))) = ((buffer, (flag, left)), right) := rfl + +@[simp] theorem rowEquiv_apply (N : Nat) (buffer : Buffer N) + (flag : Bool) (left right : Option Bool) : + rowEquiv N ((buffer, (flag, left)), right) = ((flag, (left, right)), buffer) := rfl + +@[simp] theorem rowEquiv_symm_apply (N : Nat) (buffer : Buffer N) + (flag : Bool) (left right : Option Bool) : + (rowEquiv N).symm ((flag, (left, right)), buffer) = ((buffer, (flag, left)), right) := rfl + +def withBuffer {N : Nat} (buffer : Buffer N) : Master N := + ((buffer, (false, none)), none) + +def clean (N : Nat) : Master N := withBuffer (emptyBuffer N) + +@[simp] theorem equalityBit_clean {N : Nat} (buffer : Buffer N) : + MachineUnaryEqualityBit.clean buffer = withBuffer buffer := rfl + +@[simp] theorem rowEquiv_withBuffer {N : Nat} (buffer : Buffer N) : + rowEquiv N (withBuffer buffer) = ((false, (none, none)), buffer) := rfl + +@[simp] theorem compareEquiv_withBuffer {N : Nat} (buffer : Buffer N) : + compareEquiv N (withBuffer buffer) = (buffer, (false, (none, none))) := rfl + +def clearBuffer {N : Nat} (state : Master N) : Master N := + (rowEquiv N).symm ((rowEquiv N state).1, emptyBuffer N) + +@[simp] theorem clearBuffer_apply {N : Nat} (buffer : Buffer N) + (flag : Bool) (left right : Option Bool) : + clearBuffer ((buffer, (flag, left)), right) = + ((emptyBuffer N, (flag, left)), right) := rfl + +@[simp] theorem clearBuffer_withBuffer {N : Nat} (buffer : Buffer N) : + clearBuffer (withBuffer buffer) = clean N := rfl + +end IndependentSetsGames.Foundations.Complexity.PoweringMasterState + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Execution.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Execution.lean new file mode 100644 index 0000000000000000000000000000000000000000..054d00081c6ec4899e277b564ef0795dc419fd6d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Execution.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalRow + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalRow +open Turing MachineComposition +open PCP PCP.GraphTables PCP.PreprocessingRegularTables +section Execution + +variable {Λ σ : Type} + +theorem join_trace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +theorem lookupTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 3] + (some ⟨some (labels (.lookup .seed)), ((ambient, zeroBuffer), register), base⟩) = + some ⟨some (labels .copyRelation), ((ambient, zeroBuffer), none), looked t e base⟩ := by + exact MachineAffineLookup.affineLookupTrace 0 lookupTape lookupTape_injective source_outside + 4098 3 (fun l => labels (.lookup l)) (some (labels .copyRelation)) program + (fun l => code (.lookup l)) base (GraphTables.tableWords t) input.tableWord input.scratchEmpty + e.val [] (by simpa only [List.append_nil] using input.indexWord) + t.rows[e].reverseIndex.val (selected_reverse t e) (ambient, zeroBuffer) register + +theorem copyTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (ambient : σ) : + (advance (TM2.step program))^[1] + (some ⟨some (labels .copyRelation), ((ambient, zeroBuffer), none), looked t e base⟩) = + some ⟨some (labels .reverseSeed), ((ambient, zeroBuffer), none), copied t e base⟩ := by + simp only [Function.iterate_one, advance_some] + have run := relationCopy_step (3 : Tape) 7 (by decide) (labels .copyRelation) + (some (labels .reverseSeed)) program (code .copyRelation) t.rows[e].relation + (encodeWords (suffixWords t e) ++ base 3) (looked t e base) (looked_relation t e base) + ambient zeroBuffer none + rw [looked_other t e base 7 (by decide) (by decide) (by decide)] at run + exact run + +theorem affineTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) + (ambient : σ) : + (advance (TM2.step program))^[2 * (t.rows[e].reverseIndex.val + 1) + 1] + (some ⟨some (labels .reverseSeed), ((ambient, zeroBuffer), none), copied t e base⟩) = + some ⟨some (labels (.emit .relationRead)), ((ambient, zeroBuffer), none), + affined q t e base⟩ := by + have hsource : copied t e base 4 = encodeWord t.rows[e].reverseIndex.val ++ [] := by + rw [copied_reverse, input.reverseEmpty] + have hscratch : copied t e base 5 = [] := by + rw [copied_other t e base 5 (by decide) (by decide) (by decide) (by decide), input.scratchEmpty] + have run := MachineUnaryAffineAt.seededAffineTrace (4 : Tape) 5 6 (by decide) (by decide) + (by decide) (q + 1) q (labels .reverseSeed) (labels .reverseScan) (labels .reverseRestore) + (some (labels (.emit .relationRead))) program (code .reverseSeed) (code .reverseScan) + (code .reverseRestore) (copied t e base) t.rows[e].reverseIndex.val [] hsource hscratch + (ambient, zeroBuffer) none + rw [copied_other t e base 6 (by decide) (by decide) (by decide) (by decide)] at run + exact run + +theorem emitTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) + (ambient : σ) : + (advance (TM2.step program))^[rowSteps q t e base] + (some ⟨some (labels (.emit .relationRead)), ((ambient, zeroBuffer), none), affined q t e base⟩) = + some ⟨exit, ((ambient, zeroBuffer), none), finalTapes q t e base⟩ := by + have hrow : affined q t e base 8 = [] := by + rw [affined_other q t e base 8 (by decide) (by decide) (by decide) (by decide) + (by decide), input.rowEmpty] + have hscratch : affined q t e base 5 = [] := by + rw [affined_other q t e base 5 (by decide) (by decide) (by decide) (by decide) + (by decide), input.scratchEmpty] + have hout := affined_other q t e base 9 (by decide) (by decide) (by decide) + (by decide) (by decide) + have hfields := affined_fields q t e base input + have hsize : MachineTableRows.fieldSize fields (affined q t e base) = + (encodeWords (emittedWords q t e)).length := by + rw [← MachineTableRows.fieldBits_length, hfields] + have run := MachineTableRows.appendTrace fields (8 : Tape) 9 5 fields_separate + (by decide) (by decide) (by decide) (fun l => labels (.emit l)) exit program + (fun l => code (.emit l)) (affined q t e base) hrow hscratch (ambient, zeroBuffer) none + rw [hsize, hout, hfields] at run + exact run + +theorem traceAt (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps q t e base] + (some ⟨some (labels (.lookup .seed)), ((ambient, zeroBuffer), register), base⟩) = + some ⟨exit, ((ambient, zeroBuffer), none), finalTapes q t e base⟩ := by + have hlookup := lookupTrace q labels exit program code t e base input ambient register + have hcopy := copyTrace q labels exit program code t e base ambient + have haffine := affineTrace q labels exit program code t e base input ambient + have hemit := emitTrace q labels exit program code t e base input ambient + exact join_trace (join_trace (join_trace hlookup hcopy) haffine) hemit + +end Execution + +def timeBound (q inputLength outputLength : Nat) : Nat := + (4 * q + 17) * inputLength + 2 * outputLength + 4 * q + 32795 + +theorem steps_le (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + steps q t e base ≤ timeBound q (tableBits t).length (base 9).length := by + have hl := MachineAffineLookup.steps_le (GraphTables.tableWords t) e.val 4098 3 + t.rows[e].reverseIndex.val (selected_reverse t e) + have htable := tableWords_length_le_bits t + have he : e.val ≤ (tableBits t).length := by have he := e.isLt; omega + have hr : t.rows[e].reverseIndex.val ≤ (tableBits t).length := by + have hrlt := t.rows[e].reverseIndex.isLt + omega + have hrel := relationBits_length_le t.rows[e].relation + have hmul := Nat.mul_le_mul_left (4 * (q + 1) + 2) hr + change MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 3 ≤ + 2 * e.val + 5 * (tableBits t).length + 6 at hl + unfold steps rowSteps timeBound emittedWords + simp only [encodeWords, List.length_append, encodeWord_length] + nlinarith + +def machineInTime (H : BaseTable) (t : Table) (e : Fin t.darts) + (base : Tape → List Bool) (input : Input t e base) (register : Option Bool) : + StateTransition.EvalsToInTime (machine internalDegree).step + ⟨some (.lookup .seed), (((), zeroBuffer), register), base⟩ + (some ⟨none, (((), zeroBuffer), none), + Function.update (affined internalDegree t e base) (9 : Tape) + (base (9 : Tape) ++ encodeWords (rowWords (inheritedRow H t e)))⟩) + (timeBound internalDegree (tableBits t).length (base (9 : Tape)).length) where + steps := steps internalDegree t e base + evals_in_steps := by + change (advance (TM2.step (instruction internalDegree id none)))^[_] _ = _ + rw [inheritedRow_words] + exact traceAt internalDegree id none (instruction internalDegree id none) + (fun _ => rfl) t e base input () register + steps_le_m := steps_le internalDegree t e base + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/ExprDrop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/ExprDrop.lean new file mode 100644 index 0000000000000000000000000000000000000000..7971c63cda83a3da5f9818299de78dc2a7a1e20c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/ExprDrop.lean @@ -0,0 +1,45 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Represented + +namespace OAI + +namespace IndependentSetsCut.CounterMachine.Expr +open scoped BigOperators + +def dropInput (offset : Expr) : Expr → Expr + | .const n => .const n + | .arg i => .arg i + | .length => .sub .length (UnaryTables.closed offset) + | .bit x => .bit (.add (UnaryTables.closed offset) (dropInput offset x)) + | .add x y => .add (dropInput offset x) (dropInput offset y) + | .sub x y => .sub (dropInput offset x) (dropInput offset y) + | .mul x y => .mul (dropInput offset x) (dropInput offset y) + | .zero x => .zero (dropInput offset x) + | .sum b f => .sum (dropInput offset b) (dropInput offset f) + +lemma dropInput_eval (offset e : Expr) (s : List Bool) (a : ℕ → ℕ) : + (dropInput offset e).eval s a=e.eval (s.drop (offset.eval s (fun _ => 0))) a := by + have hc (a : ℕ → ℕ) : (UnaryTables.closed offset).eval s a=offset.eval s (fun _ => 0) := by + simp [UnaryTables.closed,UnaryTables.atIndex,eval] + induction e generalizing a with + | const n => rfl + | arg n => rfl + | length => simp [dropInput,eval,hc] + | bit e ih => simp [dropInput,eval,hc,ih,List.getElem?_drop] + | add x y ix iy => simp [dropInput,eval,ix,iy] + | sub x y ix iy => simp [dropInput,eval,ix,iy] + | mul x y ix iy => simp [dropInput,eval,ix,iy] + | zero x ix => simp [dropInput,eval,ix] + | sum b f ib iF => simp only [dropInput,eval,ib,iF] + +end IndependentSetsCut.CounterMachine.Expr + +namespace IndependentSetsCut.CounterMachine.UnaryTables +lemma words_add (f : ℕ → ℕ) (a b : ℕ) : + words f (a+b)=words f a ++ words (fun w => f (a+w)) b := by + induction b with + | zero => simp [words] + | succ b ih => rw [Nat.add_succ,words_succ,ih,words_succ,List.append_assoc] +end IndependentSetsCut.CounterMachine.UnaryTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/ExprTables.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/ExprTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..11e68010abe31b918f0bf781a8f25de42044c96f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/ExprTables.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.LCTable + +namespace OAI + +namespace IndependentSetsCut.CounterMachine.Expr + +section +open scoped BigOperators + +def finTable2 {m n : ℕ} (f : Fin m → Fin n → ℕ) (x y : Expr) : Expr := + finLookup (fun k => f (finProdFinEquiv.symm k).1 (finProdFinEquiv.symm k).2) + (.add y (.mul (.const n) x)) +lemma finTable2_eval {m n : ℕ} (f : Fin m → Fin n → ℕ) (x y : Expr) (s : List Bool) + (a : ℕ → ℕ) (i : Fin m) (j : Fin n) (hi : x.eval s a=i.val) (hj : y.eval s a=j.val) : + (finTable2 f x y).eval s a=f i j := by + unfold finTable2 + rw [finLookup_eval _ _ _ _ (finProdFinEquiv (i,j)) (by simp [eval,hi,hj])] + rw [Equiv.symm_apply_apply] + +def finTable3 {l m n : ℕ} (f : Fin l → Fin m → Fin n → ℕ) (x y z : Expr) : Expr := + finTable2 (fun k => f (finProdFinEquiv.symm k).1 (finProdFinEquiv.symm k).2) + (.add y (.mul (.const m) x)) z +lemma finTable3_eval {l m n : ℕ} (f : Fin l → Fin m → Fin n → ℕ) (x y z : Expr) (s : List Bool) + (a : ℕ → ℕ) (i : Fin l) (j : Fin m) (k : Fin n) + (hi : x.eval s a=i.val) (hj : y.eval s a=j.val) (hk : z.eval s a=k.val) : + (finTable3 f x y z).eval s a=f i j k := by + unfold finTable3 + rw [finTable2_eval _ _ _ _ _ (finProdFinEquiv (i,j)) k (by simp [eval,hi,hj]) hk] + rw [Equiv.symm_apply_apply] + +noncomputable def static2 {α β : Type} [Fintype α] [Fintype β] + (f : α → β → ℕ) (x y : Expr) : Expr := + finTable2 (fun i j => f ((Fintype.equivFin α).symm i) ((Fintype.equivFin β).symm j)) x y +lemma static2_eval {α β : Type} [Fintype α] [Fintype β] + (f : α → β → ℕ) (x y : Expr) (s : List Bool) (a : ℕ → ℕ) (i : α) (j : β) + (hi : x.eval s a=(Fintype.equivFin α i).val) (hj : y.eval s a=(Fintype.equivFin β j).val) : + (static2 f x y).eval s a=f i j := by + rw [static2,finTable2_eval _ _ _ _ _ _ _ hi hj] + simp + +noncomputable def static3 {α β γ : Type} [Fintype α] [Fintype β] [Fintype γ] + (f : α → β → γ → ℕ) (x y z : Expr) : Expr := + finTable3 (fun i j k => f ((Fintype.equivFin α).symm i) ((Fintype.equivFin β).symm j) + ((Fintype.equivFin γ).symm k)) x y z +lemma static3_eval {α β γ : Type} [Fintype α] [Fintype β] [Fintype γ] + (f : α → β → γ → ℕ) (x y z : Expr) (s : List Bool) (a : ℕ → ℕ) (i : α) (j : β) (k : γ) + (hi : x.eval s a=(Fintype.equivFin α i).val) (hj : y.eval s a=(Fintype.equivFin β j).val) + (hk : z.eval s a=(Fintype.equivFin γ k).val) : + (static3 f x y z).eval s a=f i j k := by + rw [static3,finTable3_eval _ _ _ _ _ _ _ _ _ hi hj hk] + simp + +lemma sum_ne_zero (bound body : Expr) (s : List Bool) (a : ℕ → ℕ) : + (Expr.sum bound body).eval s a≠0 ↔ + ∃ i + .mul (positive (pred ((Fintype.equivFin α).symm i))) (.const (f ((Fintype.equivFin α).symm i))) + +lemma pick_eval {α : Type} [Fintype α] (f : α → ℕ) (pred : α → Expr) + (s : List Bool) (a : ℕ → ℕ) (v : α) + (hv : ∀ x, (pred x).eval s a ≠ 0 ↔ x=v) : + (pick f pred).eval s a=f v := by + have hp : ∀ x, (positive (pred x)).eval s a=if x=v then 1 else 0 := by + intro x + rw [positive_eval] + by_cases h : x=v + · simp [h,(hv v).mpr rfl] + · have hz : (pred x).eval s a=0 := by by_contra hh; exact h ((hv x).mp hh) + simp [h,hz] + simp only [pick,listSum_eval,eval,hp,ite_mul,one_mul,zero_mul] + rw [← List.ofFn_eq_map,List.sum_ofFn] + have he : ∀ i : Fin (Fintype.card α), (Fintype.equivFin α).symm i=v ↔ i=Fintype.equivFin α v := by + intro i + exact Equiv.symm_apply_eq (Fintype.equivFin α) + simp only [he] + simp + +end +end IndependentSetsCut.CounterMachine.Expr + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFComputation.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFComputation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3436522edb48a5c25780dfc32a946406d6395fb1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFComputation.lean @@ -0,0 +1,134 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRepeat +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineLoop +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFLoop +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFOutput +import OAI.Combinatorics.IndependentSets.PCP.Redirect + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +open Turing PCP + +theorem emittedBytes_eq_formulaBits (table : GraphTables.Table) : + emittedBytes rowPlan table = formulaBits (FinalTableFormula.output table) := + header_append_outputStream table + +theorem rawBudget_le_phaseTime (table : GraphTables.Table) : + rawBudget rowPlan table ≤ phaseTimePolynomial.eval (GraphTables.tableBits table).length := by + unfold rawBudget + rw [emittedBytes_eq_formulaBits] + simpa only [Nat.add_assoc] using table_phaseTime_le table + +noncomputable def computableInPolyTime : + TM2ComputableInPolyTime GraphTables.tableBits formulaBits FinalTableFormula.output where + tm := FinalCNFCleanup.completedMachine headerPlan rowPlan + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := finalTimePolynomial (Runtime.programPushBound (machine headerPlan rowPlan)) + outputsFun table := by + let outputs (input output : List Bool) (budget : Nat) := + TM2OutputsInTime (FinalCNFCleanup.completedMachine headerPlan rowPlan) + input (some output) budget + change outputs + ((GraphTables.tableBits table).map id) + ((formulaBits (FinalTableFormula.output table)).map id) + ((finalTimePolynomial (Runtime.programPushBound (machine headerPlan rowPlan))).eval + (GraphTables.tableBits table).length) + rw [List.map_id, List.map_id, finalTimePolynomial_eval] + let raw := rawRun rowPlan table + let bounded : StateTransition.EvalsToInTime (machine headerPlan rowPlan).step + (initList (machine headerPlan rowPlan) (GraphTables.tableBits table)) + (some ⟨none, ((raw.finalAmbient, ()), none), raw.finalTapes⟩) + (phaseTimePolynomial.eval (GraphTables.tableBits table).length) := { + toEvalsTo := raw.execution.toEvalsTo + steps_le_m := raw.execution.steps_le_m.trans (rawBudget_le_phaseTime table) } + have correct : raw.finalTapes .output = formulaBits (FinalTableFormula.output table) := + raw.output.trans (emittedBytes_eq_formulaBits table) + have run := FinalCNFCleanup.outputsInTime headerPlan rowPlan + (GraphTables.tableBits table) (formulaBits (FinalTableFormula.output table)) + ((raw.finalAmbient, ()), none) raw.finalTapes + (phaseTimePolynomial.eval (GraphTables.tableBits table).length) bounded correct + exact run + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +namespace IndependentSetsGames.Foundations.Complexity.MachineTableIteration + +open Turing PCP RoundTables GraphIterationBounds + +def finalTable (H : BaseTable) (input : Input) : GraphTables.Table := + TableIteration.runTables H (count input) input.val + +noncomputable def counterCertificate : TM2ComputableInPolyTime inputBits countedBits (id : Input → Input) where + toTM2ComputableAux := GraphCounterPrefix.computableInPolyTime.toTM2ComputableAux + time := GraphCounterPrefix.computableInPolyTime.time + outputsFun input := GraphCounterPrefix.computableInPolyTime.outputsFun input.val + +variable (H : BaseTable) + (body : TM2ComputableInPolyTime GraphTables.tableBits GraphTables.tableBits (build H)) + +noncomputable def countedCertificate : + TM2ComputableInPolyTime countedBits GraphTables.tableBits (finalTable H) where + tm := MachineRepeat.machine body.tm body.inputAlphabet body.outputAlphabet + inputAlphabet := body.inputAlphabet + outputAlphabet := body.inputAlphabet + time := runtimePolynomial body.time + outputsFun input := by + let budgets := fun i => body.time.eval (words H input i).length + have runs (i : Nat) (_hi : i < count input) : + TM2OutputsInTime body.tm ((words H input i).map body.inputAlphabet.symm) + (some ((words H input (i + 1)).map body.outputAlphabet.symm)) (budgets i) := by + exact body.outputsFun (TableIteration.runTables H i input.val) + let run := MachineRepeat.executeSequence body.tm body.inputAlphabet body.outputAlphabet + (count input) (words H input) budgets runs + have start : encodeWord (count input) ++ words H input 0 = countedBits input := rfl + have finish : words H input (count input) = GraphTables.tableBits (finalTable H input) := rfl + rw [start, finish] at run + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + let N := (countedBits input).length + let L := lengthPolynomial.eval N + let B := body.time.eval L + have hl (i : Nat) (hi : i ≤ count input) : (words H input i).length ≤ L := + intermediate_bits H input i hi + have hb (i : Nat) (hi : i < count input) : budgets i ≤ B := + MachineComposition.natPolynomial_eval_mono body.time (hl i hi.le) + have hloop := MachineRepeat.loopBudget_le (count input) (words H input) budgets B L hb hl + have hc : count input ≤ N + 1 := count_le input + rw [runtimePolynomial_eval] + calc + run.steps ≤ count input + 1 + MachineRepeat.loopBudget (count input) (words H input) budgets := + run.steps_le_m + _ ≤ count input + 1 + (count input * (B + 2 * L + 3) + 2 * L + 3) := + Nat.add_le_add_left hloop _ + _ = count input * (B + 2 * L + 4) + 2 * L + 4 := by ring + _ ≤ (N + 1) * (B + 2 * L + 4) + 2 * L + 4 := + Nat.add_le_add_right (Nat.add_le_add_right (Nat.mul_le_mul_right _ hc) _) _ + +noncomputable def computableInPolyTime : + TM2ComputableInPolyTime inputBits GraphTables.tableBits (finalTable H) := + MachineSequential.composeBits counterCertificate (countedCertificate H body) + +noncomputable def initialCertificate : + TM2ComputableInPolyTime formulaBits inputBits initial where + toTM2ComputableAux := MachineRawInitialTable.computableInPolyTime.toTM2ComputableAux + time := MachineRawInitialTable.computableInPolyTime.time + outputsFun F := MachineRawInitialTable.computableInPolyTime.outputsFun F + +noncomputable def tableCertificate : + TM2ComputableInPolyTime formulaBits GraphTables.tableBits (TableIteration.outputTable H) := by + change TM2ComputableInPolyTime formulaBits GraphTables.tableBits + (fun F => finalTable H (initial F)) + exact MachineSequential.composeBits (f := initial) (g := finalTable H) + initialCertificate (computableInPolyTime H body) + +noncomputable def gapMapCertificate : + TM2ComputableInPolyTime formulaBits formulaBits (TableIteration.gapMap H) := + MachineSequential.composeBits (f := TableIteration.outputTable H) (g := FinalTableFormula.output) + (tableCertificate H body) + FinalCNFMachine.Program.computableInPolyTime + +end IndependentSetsGames.Foundations.Complexity.MachineTableIteration + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFHeader.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFHeader.lean new file mode 100644 index 0000000000000000000000000000000000000000..6101d9dd1be3a4084529e9a3c71c0ff0f92053eb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFHeader.lean @@ -0,0 +1,221 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupDiscard +import OAI.Combinatorics.IndependentSets.Machines.AmbientRelation + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +open Turing +open PCP.AlphabetTable + +def headerFrame (input archive vertices darts rowIndex tail head accumulator : List Bool) : + Tape → List Bool + | .input => input + | .archive => archive + | .vertices => vertices + | .darts => darts + | .rowIndex => rowIndex + | .tail => tail + | .head => head + | .accumulator => accumulator + | _ => [] + +def headerInputTapes (input : List Bool) : Tape → List Bool := + headerFrame input [] [] [] [] [] [] [] + +def headerResultTapes (n m : Nat) (rowsBits : List Bool) : Tape → List Bool := + headerFrame rowsBits (encodeWords [n, m] ++ rowsBits) + (encodeWord n) (encodeWord m) (encodeWord 0) [] [] + (encodeWords [6 * n + 36864 * m, 40960 * m]).reverse + +@[simp] theorem headerResultTapes_input (n m : Nat) (rowsBits : List Bool) : + headerResultTapes n m rowsBits .input = rowsBits := rfl + +@[simp] theorem headerResultTapes_archive (n m : Nat) (rowsBits : List Bool) : + headerResultTapes n m rowsBits .archive = encodeWords [n, m] ++ rowsBits := rfl + +@[simp] theorem headerResultTapes_accumulator (n m : Nat) (rowsBits : List Bool) : + headerResultTapes n m rowsBits .accumulator = + (encodeWords [6 * n + 36864 * m, 40960 * m]).reverse := rfl + +@[simp] theorem headerResultTapes_rowIndex (n m : Nat) (rowsBits : List Bool) : + headerResultTapes n m rowsBits .rowIndex = encodeWord 0 := rfl + +noncomputable def headerTimePolynomial : Polynomial Nat := + Polynomial.C 25 * Polynomial.X + Polynomial.C 52 + +@[simp] theorem headerTimePolynomial_eval (length : Nat) : + headerTimePolynomial.eval length = 25 * length + 52 := by + simp [headerTimePolynomial] + +def headerInTime (rowPlan : Plan) (n m : Nat) (rowsBits : List Bool) (ambient : Ambient) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .copyFirst, ((ambient, ()), none), + headerInputTapes (encodeWords [n, m] ++ rowsBits)⟩ + (some ⟨some .guard, ((ambient, ()), none), headerResultTapes n m rowsBits⟩) + (headerTimePolynomial.eval (encodeWords [n, m] ++ rowsBits).length) := by + let word := encodeWords [n, m] ++ rowsBits + let bits := encodeWords [6 * n + 36864 * m, 40960 * m] + let b₀ := headerInputTapes word + let b₁ := headerFrame word word [] [] [] [] [] [] + let b₂ := headerFrame (encodeWord m ++ rowsBits) word (encodeWord n) [] [] [] [] [] + let b₃ := headerFrame rowsBits word (encodeWord n) (encodeWord m) [] [] [] [] + let b₄ := headerFrame rowsBits word (encodeWord n) (encodeWord m) + (encodeWord 0) (encodeWord 0) (encodeWord 0) [] + let b₅ := headerFrame rowsBits word (encodeWord n) (encodeWord m) + (encodeWord 0) (encodeWord 0) (encodeWord 0) bits.reverse + let b₆ := headerFrame rowsBits word (encodeWord n) (encodeWord m) + (encodeWord 0) [] (encodeWord 0) bits.reverse + let b₇ := headerResultTapes n m rowsBits + have h₀ : Function.update b₀ Tape.archive (b₀ .input ++ b₀ .archive) = b₁ := by + funext tape; cases tape <;> simp [b₀, b₁, headerInputTapes, headerFrame] + have h₁ : Hastad.SourceMachine.fieldTapes Tape.input Tape.vertices b₁ + (encodeWord m ++ rowsBits) (encodeWord n ++ b₁ .vertices) = b₂ := by + funext tape; cases tape <;> simp [Hastad.SourceMachine.fieldTapes, b₁, b₂, headerFrame] + have h₂ : Hastad.SourceMachine.fieldTapes Tape.input Tape.darts b₂ + rowsBits (encodeWord m ++ b₂ .darts) = b₃ := by + funext tape; cases tape <;> simp [Hastad.SourceMachine.fieldTapes, b₂, b₃, headerFrame] + have h₄ : Emitter.resultTapes Tape.accumulator b₄ + (Emitter.prefixBits (Emitter.listCommands headerPlan) (values n m 0 0 0) + ambient headerPlan.length) = b₅ := by + rw [Emitter.bits_listCommands, headerPlan_bits] + funext tape; cases tape <;> simp [Emitter.resultTapes, b₄, b₅, bits, headerFrame] + have h₅ : Function.update b₅ Tape.tail [] = b₆ := by + funext tape; cases tape <;> simp [b₅, b₆, headerFrame] + have h₆ : Function.update b₆ Tape.head [] = b₇ := by + funext tape; cases tape <;> simp [b₆, b₇, headerResultTapes, bits, word, headerFrame] + have hn : n ≤ word.length := by + simp only [word, List.length_append, encodeWords_length, List.sum_cons, + List.sum_nil, List.length_cons, List.length_nil] ; omega + have hm : m ≤ word.length := by + simp only [word, List.length_append, encodeWords_length, List.sum_cons, + List.sum_nil, List.length_cons, List.length_nil] ; omega + let p₀ := MachineCopy.copyInTime Tape.input Tape.archive Tape.scratch + (by decide) (by decide) (by decide) false .copyFirst .copySecond (some .startVertices) + (program headerPlan rowPlan) rfl rfl b₀ (by rfl) (ambient, ()) none + have p₀' : StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .copyFirst, ((ambient, ()), none), b₀⟩ + (some ⟨some .startVertices, ((ambient, ()), none), b₁⟩) (2 * (word.length + 1)) := by + have h := p₀ + rw [h₀] at h + simpa only [show b₀ .input = word from rfl] using h + let p₁ := Hastad.SourceMachine.fieldInTime Tape.input Tape.vertices (by decide) + .startVertices .readVertices (some .startDarts) (program headerPlan rowPlan) + rfl rfl b₁ n (encodeWord m ++ rowsBits) + (by simp [b₁, headerFrame, word, encodeWords, List.append_assoc]) (ambient, ()) none + have p₁' : StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .startVertices, ((ambient, ()), none), b₁⟩ + (some ⟨some .startDarts, ((ambient, ()), none), b₂⟩) (n + 2) := by + simpa only [h₁] using p₁ + let p₂ := Hastad.SourceMachine.fieldInTime Tape.input Tape.darts (by decide) + .startDarts .readDarts (some .seedIndex) (program headerPlan rowPlan) + rfl rfl b₂ m rowsBits rfl (ambient, ()) none + have p₂' : StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .startDarts, ((ambient, ()), none), b₂⟩ + (some ⟨some .seedIndex, ((ambient, ()), none), b₃⟩) (m + 2) := by + simpa only [h₂] using p₂ + let p₃ : StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .seedIndex, ((ambient, ()), none), b₃⟩ + (some ⟨some (.header (Emitter.labelAt headerPlan.length 36864 0 .entry)), + ((ambient, ()), none), b₄⟩) 1 := { + steps := 1 + evals_in_steps := by + simp only [Function.iterate_one] + change TM2.step (program headerPlan rowPlan) + ⟨some .seedIndex, ((ambient, ()), none), b₃⟩ = _ + have ht : Function.update (Function.update (Function.update b₃ Tape.rowIndex [false]) + Tape.tail [false]) Tape.head [false] = b₄ := by + funext tape; cases tape <;> simp [b₃, b₄, headerFrame, encodeWord] + simp only [TM2.step, program, TM2.stepAux] + apply congrArg some + exact congrArg (TM2.Cfg.mk _ _) ht + steps_le_m := Nat.le_refl _ } + let p₄ := Emitter.planInTime (Emitter.listCommands headerPlan) source Tape.scratch + Tape.accumulator source_ne_scratch source_ne_accumulator (by decide) + Label.header (some .headerClearTail) (program headerPlan rowPlan) (fun _ => rfl) + (values n m 0 0 0) b₄ + (by intro i; fin_cases i <;> rfl) rfl ambient word.length + (by + intro i + fin_cases i + · exact hn + · exact hm + · exact Nat.zero_le _ + · exact Nat.zero_le _ + · exact Nat.zero_le _) + have p₄' : StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some (.header (Emitter.labelAt headerPlan.length 36864 0 .entry)), + ((ambient, ()), none), b₄⟩ + (some ⟨some .headerClearTail, ((ambient, ()), none), b₅⟩) + (7 * (3 * (word.length + 1) + 3) + 1) := by + have h := p₄ + rw [h₄] at h + simpa only [headerPlan_length] using h + let p₅ := MachineLookup.discardInTime Tape.tail .headerClearTail .headerClearHead + (program headerPlan rowPlan) rfl b₅ 0 [] (by simp [b₅, headerFrame]) (ambient, ()) none + have p₅' : StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .headerClearTail, ((ambient, ()), none), b₅⟩ + (some ⟨some .headerClearHead, ((ambient, ()), none), b₆⟩) 1 := by + simpa only [h₅] using p₅ + let p₆ := MachineLookup.discardInTime Tape.head .headerClearHead .guard + (program headerPlan rowPlan) rfl b₆ 0 [] (by simp [b₆, headerFrame]) (ambient, ()) none + have p₆' : StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .headerClearHead, ((ambient, ()), none), b₆⟩ + (some ⟨some .guard, ((ambient, ()), none), b₇⟩) 1 := by + simpa only [h₆] using p₆ + let p₀₁ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀' p₁' + let p₀₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀₁ p₂' + let p₀₁₂₃ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀₁₂ p₃ + let p₀₁₂₃₄ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀₁₂₃ p₄' + let p₀₁₂₃₄₅ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀₁₂₃₄ p₅' + let p := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀₁₂₃₄₅ p₆' + exact { + toEvalsTo := p.toEvalsTo + steps_le_m := by + have h := p.steps_le_m + change _ ≤ headerTimePolynomial.eval word.length + rw [headerTimePolynomial_eval] + omega } + +def tableRowsBits (table : PCP.GenericGraphTables.Table 64) : List Bool := + encodeWords ((PCP.GenericGraphTables.rowList table).flatMap PCP.GenericGraphTables.rowWords) + +theorem tableBits_header_rows (table : PCP.GenericGraphTables.Table 64) : + PCP.GenericGraphTables.tableBits table = + encodeWords [table.vertices, table.darts] ++ tableRowsBits table := by + simp only [PCP.GenericGraphTables.tableBits, PCP.GenericGraphTables.tableWords, + encodeWords_append, tableRowsBits] + +def tableHeaderInTime (rowPlan : Plan) (table : PCP.GenericGraphTables.Table 64) + (ambient : Ambient) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan rowPlan)) + ⟨some .copyFirst, ((ambient, ()), none), + headerInputTapes (PCP.GenericGraphTables.tableBits table)⟩ + (some ⟨some .guard, ((ambient, ()), none), + headerResultTapes table.vertices table.darts (tableRowsBits table)⟩) + (headerTimePolynomial.eval (PCP.GenericGraphTables.tableBits table).length) := by + rw [tableBits_header_rows] + exact headerInTime rowPlan table.vertices table.darts (tableRowsBits table) ambient + +theorem headerInput_configuration (rowPlan : Plan) (input : List Bool) : + initList (machine headerPlan rowPlan) input = + ⟨some .copyFirst, ((((), fun _ => false), ()), none), headerInputTapes input⟩ := by + have ht : (initList (machine headerPlan rowPlan) input).stk = headerInputTapes input := by + funext tape + cases tape <;> simp [initList, machine, headerInputTapes, headerFrame] + rfl + exact congrArg (TM2.Cfg.mk _ _) ht + +def initializedTableHeaderInTime (rowPlan : Plan) (table : PCP.GenericGraphTables.Table 64) : + StateTransition.EvalsToInTime (machine headerPlan rowPlan).step + (initList (machine headerPlan rowPlan) (PCP.GenericGraphTables.tableBits table)) + (some ⟨some .guard, ((((), fun _ => false), ()), none), + headerResultTapes table.vertices table.darts (tableRowsBits table)⟩) + (headerTimePolynomial.eval (PCP.GenericGraphTables.tableBits table).length) := by + rw [headerInput_configuration] + exact tableHeaderInTime rowPlan table ((), fun _ => false) + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFLoop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9dccf3e06fa307e491ab8b574120bd0480d3621 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFLoop.lean @@ -0,0 +1,195 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFStream + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +section + +open Turing PCP PCP.AlphabetTable + +structure LoopInvariant (table : GraphTables.Table) (r : Nat) (base : Tape → List Bool) : Prop where + input : base .input = inputStream table (remainingEvents table r) + archive : base .archive = GraphTables.tableBits table + vertices : base .vertices = encodeWord table.vertices + darts : base .darts = encodeWord table.darts + index : base .rowIndex = encodeWord r + tail : base .tail = [] + head : base .head = [] + reverse : base .reverseIndex = [] + scratch : base .scratch = [] + +structure LoopRun (headerPlan plan : Plan) (table : GraphTables.Table) (r remaining : Nat) + (base : Tape → List Bool) (ambient : Ambient) where + finalAmbient : Ambient + finalTapes : Tape → List Bool + execution : StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .guard, ((ambient, ()), none), base⟩ + (some ⟨some .reverseOutput, ((finalAmbient, ()), none), finalTapes⟩) + (remaining * (rowTime plan (GraphTables.tableBits table).length + 1) + 1) + accumulator : finalTapes .accumulator = + (outputStream plan table (remainingEvents table r)).reverse ++ base .accumulator + output : finalTapes .output = base .output + +theorem rowInvariant_succ (plan : Plan) (table : GraphTables.Table) (r : Nat) + (hr : r < table.darts) (base : Tape → List Bool) (invariant : LoopInvariant table r base) : + LoopInvariant table (r + 1) + (rowResultTapes plan base table ⟨r, hr⟩ + (inputStream table (remainingEvents table (r + 1)))) := by + constructor + · exact rowResult_input _ _ _ _ _ + · exact (rowResult_frame _ _ _ _ _ .archive (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) (by decide)).trans invariant.archive + · exact (rowResult_frame _ _ _ _ _ .vertices (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) (by decide)).trans invariant.vertices + · exact (rowResult_frame _ _ _ _ _ .darts (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) (by decide)).trans invariant.darts + · exact rowResult_index _ _ _ _ _ + · exact rowResult_tail _ _ _ _ _ + · exact rowResult_head _ _ _ _ _ + · exact rowResult_reverse _ _ _ _ _ + · exact (rowResult_frame _ _ _ _ _ .scratch (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) (by decide)).trans invariant.scratch + +theorem rowWords_nonempty (table : GraphTables.Table) (e : Fin table.darts) : + encodeWords (GraphTables.rowWords table.rows[e]) ≠ [] := by + simp [GraphTables.rowWords, encodeWords, encodeWord] + +noncomputable def loopInTime (headerPlan plan : Plan) (table : GraphTables.Table) + (remaining : Nat) : + ∀ (r : Nat), r + remaining = table.darts → ∀ (base : Tape → List Bool) + (ambient : Ambient), LoopInvariant table r base → + LoopRun headerPlan plan table r remaining base ambient := by + induction remaining with + | zero => + intro r hcount base ambient invariant + have hr : r = table.darts := by omega + have hinput : base .input = [] := by + simpa only [hr, remainingEvents_done, inputStream_nil] using invariant.input + refine { + finalAmbient := ambient + finalTapes := base + execution := ?_ + accumulator := ?_ + output := rfl } + · simpa only [Nat.zero_mul, Nat.zero_add] using + guardEndInTime headerPlan plan base ambient hinput + · simp only [hr, remainingEvents_done, outputStream_nil, List.reverse_nil, List.nil_append] + | succ remaining ih => + intro r hcount base ambient invariant + have hr : r < table.darts := by omega + let e : Fin table.darts := ⟨r, hr⟩ + let rest := inputStream table (remainingEvents table (r + 1)) + let next := rowResultTapes plan base table e rest + have hinput : base .input = encodeWords (GraphTables.rowWords table.rows[e]) ++ rest := by + rw [invariant.input, inputStream_remaining_cons table r hr] + have hnonempty : base .input ≠ [] := by + rw [hinput] + exact List.append_ne_nil_of_left_ne_nil (rowWords_nonempty table e) rest + let guardRun := guardRowInTime headerPlan plan base ambient hnonempty + let rowRun := rowInTime headerPlan plan base table e rest hinput invariant.archive + invariant.vertices invariant.darts invariant.index invariant.tail invariant.head + invariant.reverse invariant.scratch ambient + let first := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ guardRun rowRun + let later := ih (r + 1) (by omega) next (rowRelation table e) + (rowInvariant_succ plan table r hr base invariant) + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first later.execution + refine { + finalAmbient := later.finalAmbient + finalTapes := later.finalTapes + execution := { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + accumulator := ?_ + output := ?_ } + · have hb := run.steps_le_m + rw [Nat.succ_mul] + omega + · rw [later.accumulator, outputStream_remaining_cons plan table r hr] + simp only [next, rowResult_accumulator, List.reverse_append, List.append_assoc] + rfl + · rw [later.output] + exact rowResult_frame _ _ _ _ _ .output (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) (by decide) + +end + +open Turing PCP PCP.AlphabetTable FinalCNFTableAdapter + +def emittedBytes (plan : Plan) (table : GraphTables.Table) : List Bool := + encodeWords [6 * table.vertices + 36864 * table.darts, 40960 * table.darts] ++ + outputStream plan table (List.finRange table.darts) + +noncomputable def rawBudget (plan : Plan) (table : GraphTables.Table) : Nat := + headerTimePolynomial.eval (GraphTables.tableBits table).length + + table.darts * (rowTime plan (GraphTables.tableBits table).length + 1) + 1 + + (emittedBytes plan table).length + 1 + +structure RawRun (plan : Plan) (table : GraphTables.Table) where + finalAmbient : Ambient + finalTapes : Tape → List Bool + execution : StateTransition.EvalsToInTime (machine headerPlan plan).step + (initList (machine headerPlan plan) (GraphTables.tableBits table)) + (some ⟨none, ((finalAmbient, ()), none), finalTapes⟩) (rawBudget plan table) + output : finalTapes .output = emittedBytes plan table + +theorem header_loopInvariant (_ : Plan) (table : GraphTables.Table) : + LoopInvariant table 0 (headerResultTapes table.vertices table.darts + (tableRowsBits (genericTable table))) := by + constructor + · rw [headerResultTapes_input, inputStream_remaining_zero] + · rw [headerResultTapes_archive] + exact (tableBits_header_rows (genericTable table)).symm.trans (genericTable_tableBits table) + · rfl + · rfl + · exact headerResultTapes_rowIndex _ _ _ + · rfl + · rfl + · rfl + · rfl + +noncomputable def rawRun (plan : Plan) (table : GraphTables.Table) : RawRun plan table := by + let base := headerResultTapes table.vertices table.darts (tableRowsBits (genericTable table)) + let ambient : Ambient := ((), fun _ => false) + have headerRun : StateTransition.EvalsToInTime (machine headerPlan plan).step + (initList (machine headerPlan plan) (GraphTables.tableBits table)) + (some ⟨some .guard, ((ambient, ()), none), base⟩) + (headerTimePolynomial.eval (GraphTables.tableBits table).length) := by + simpa only [genericTable_tableBits, genericTable_vertices, genericTable_darts, base, ambient] + using initializedTableHeaderInTime plan (genericTable table) + let loop := loopInTime headerPlan plan table table.darts 0 (by omega) + base ambient (header_loopInvariant plan table) + have acc : loop.finalTapes .accumulator = (emittedBytes plan table).reverse := by + rw [loop.accumulator] + simp only [remainingEvents_zero, base, headerResultTapes_accumulator, emittedBytes, + List.reverse_append] + have out : loop.finalTapes .output = [] := by + rw [loop.output] + rfl + let finalTapes := Reduction.MachineTransfer.tapesAt Tape.accumulator Tape.output + loop.finalTapes [] (emittedBytes plan table) + have finish : StateTransition.EvalsToInTime (machine headerPlan plan).step + ⟨some .reverseOutput, ((loop.finalAmbient, ()), none), loop.finalTapes⟩ + (some ⟨none, ((loop.finalAmbient, ()), none), finalTapes⟩) + ((emittedBytes plan table).length + 1) := by + have run := Reduction.MachineTransfer.transferAtInTime Tape.accumulator Tape.output + (by decide) id false .reverseOutput none (program headerPlan plan) rfl + loop.finalTapes (loop.finalAmbient, ()) none + simp only [acc, out, List.reverse_reverse, List.length_reverse, List.map_id, + List.append_nil] at run + exact run + let first := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ headerRun loop.execution + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first finish + exact { + finalAmbient := loop.finalAmbient + finalTapes := finalTapes + execution := { + toEvalsTo := run.toEvalsTo + steps_le_m := by + have hb := run.steps_le_m + unfold rawBudget + omega } + output := by simp [finalTapes, Reduction.MachineTransfer.tapesAt] } + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFMachine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d75c5b2ae09f6f9f7dc942ca522faaf7abef4be --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFMachine.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFixedBlockMap + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine + +open Turing +open PCP + +abbrev Buffer (N : Nat) := MachineFixedBlockMap.Buffer N + +section RelationReader + +variable {K Λ σ : Type} {N : Nat} + +def readUnarySlots (source : K) : List (Fin N) → + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) → + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) + | [], next => next + | i :: slots, next => + .pop source (fun state head => + (state.1, Function.update state.2 i (head.getD false))) + (.branch (fun state => state.2 i) + (.pop source (fun state _ => state) (readUnarySlots source slots next)) + (readUnarySlots source slots next)) + +def unaryBits (slots : List (Fin N)) (bits : Buffer N) : List Bool := + slots.flatMap fun i => encodeWord (GraphTables.bitWord (bits i)) + +theorem unaryBits_eq_encodeWords (slots : List (Fin N)) (bits : Buffer N) : + unaryBits slots bits = encodeWords (slots.map fun i => GraphTables.bitWord (bits i)) := by + induction slots with + | nil => rfl + | cons i slots ih => simpa only [unaryBits, List.flatMap_cons, List.map_cons, + encodeWords] using congrArg (encodeWord (GraphTables.bitWord (bits i)) ++ ·) ih + +theorem unaryBits_length_le (slots : List (Fin N)) (bits : Buffer N) : + (unaryBits slots bits).length ≤ 2 * slots.length := by + induction slots with + | nil => simp [unaryBits] + | cons i slots ih => + have hi : (encodeWord (GraphTables.bitWord (bits i))).length ≤ 2 := by + cases bits i <;> simp [GraphTables.bitWord, encodeWord_length] + simp only [unaryBits, List.flatMap_cons, List.length_append, List.length_cons] at * + omega + +theorem statementPushBound_readUnarySlots (source : K) (slots : List (Fin N)) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) : + Runtime.statementPushBound (readUnarySlots source slots next) = + Runtime.statementPushBound next := by + induction slots with + | nil => rfl + | cons i slots ih => + simp only [readUnarySlots, Runtime.statementPushBound, ih, max_self] + +variable [DecidableEq K] + +theorem stepAux_readUnarySlots (source : K) (slots : List (Fin N)) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (ambient : σ) (bits buffer : Buffer N) (tapes : K → List Bool) + (suffix : List Bool) : + TM2.stepAux (readUnarySlots source slots next) (ambient, buffer) + (Function.update tapes source (unaryBits slots bits ++ suffix)) = + TM2.stepAux next (ambient, MachineFixedBlockMap.fill slots bits buffer) + (Function.update tapes source suffix) := by + induction slots generalizing buffer tapes with + | nil => simp [readUnarySlots, unaryBits, MachineFixedBlockMap.fill] + | cons i slots ih => + cases hi : bits i <;> + simp only [readUnarySlots, unaryBits, List.flatMap_cons, hi, + GraphTables.bitWord, Bool.false_eq_true, ite_false, ite_true, encodeWord, + List.replicate_zero, List.replicate_succ, List.nil_append, + List.cons_append, + TM2.stepAux, Function.update_self, List.head?_cons, Option.getD_some, + List.tail_cons, Function.update_idem, MachineFixedBlockMap.fill, + List.foldl_cons] + · simpa [unaryBits, MachineFixedBlockMap.fill, hi, encodeWord, GraphTables.bitWord] using + ih (Function.update buffer i false) tapes + · simpa [unaryBits, MachineFixedBlockMap.fill, hi, encodeWord, GraphTables.bitWord] using + ih (Function.update buffer i true) tapes + +theorem stepAux_readUnaryAll (source : K) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (state : σ × Buffer N) (bits : Buffer N) (tapes : K → List Bool) + (suffix : List Bool) + (hinput : tapes source = unaryBits (List.ofFn id) bits ++ suffix) : + TM2.stepAux (readUnarySlots source (List.ofFn id) next) state tapes = + TM2.stepAux next (state.1, bits) (Function.update tapes source suffix) := by + have h := stepAux_readUnarySlots source (List.ofFn id) next state.1 bits state.2 tapes suffix + have hin : Function.update tapes source (unaryBits (List.ofFn id) bits ++ suffix) = tapes := by + simpa only [← hinput] using Function.update_eq_self source tapes + rw [hin, MachineFixedBlockMap.fill_all] at h + exact h + +def unaryBlockMapAt {M : Nat} (source destination : K) (F : Buffer N → Buffer M) + (exit : Option Λ) : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) := + readUnarySlots source (List.ofFn id) + (MachineFixedBlockMap.writeSlots destination (fun state => F state.2) + (List.ofFn id).reverse + (.load (fun state => (state.1, MachineFixedBlockMap.emptyBuffer N)) + (MachineFixedBlockMap.finishAt exit))) + +theorem stepAux_unaryBlockMapAt {M : Nat} (source destination : K) + (F : Buffer N → Buffer M) (exit : Option Λ) (hne : source ≠ destination) + (state : σ × Buffer N) (bits : Buffer N) (tapes : K → List Bool) (suffix : List Bool) + (hinput : tapes source = unaryBits (List.ofFn id) bits ++ suffix) : + TM2.stepAux (unaryBlockMapAt source destination F exit) state tapes = + { l := exit, var := (state.1, MachineFixedBlockMap.emptyBuffer N), + stk := Function.update (Function.update tapes source suffix) destination + (List.ofFn (F bits) ++ tapes destination) } := by + unfold unaryBlockMapAt + rw [stepAux_readUnaryAll source _ state bits tapes suffix hinput, + MachineFixedBlockMap.stepAux_writeSlots] + simp only [List.map_reverse, List.map_ofFn, Function.comp_id, List.reverse_reverse, + Function.update_of_ne (Ne.symm hne), TM2.stepAux] + cases exit <;> rfl + +theorem step_unaryBlockMapAt {M : Nat} (source destination : K) + (F : Buffer N → Buffer M) (exit : Option Λ) (hne : source ≠ destination) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (label : Λ) (atLabel : program label = unaryBlockMapAt source destination F exit) + (state : σ × Buffer N) (bits : Buffer N) (tapes : K → List Bool) (suffix : List Bool) + (hinput : tapes source = unaryBits (List.ofFn id) bits ++ suffix) : + TM2.step program ⟨some label, state, tapes⟩ = + some ⟨exit, (state.1, MachineFixedBlockMap.emptyBuffer N), + Function.update (Function.update tapes source suffix) destination + (List.ofFn (F bits) ++ tapes destination)⟩ := by + simp only [TM2.step, atLabel, + stepAux_unaryBlockMapAt source destination F exit hne state bits tapes suffix hinput] + +def unaryBlockInTime {M : Nat} (source destination : K) + (F : Buffer N → Buffer M) (exit : Option Λ) (hne : source ≠ destination) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (label : Λ) (atLabel : program label = unaryBlockMapAt source destination F exit) + (state : σ × Buffer N) (bits : Buffer N) (tapes : K → List Bool) (suffix : List Bool) + (hinput : tapes source = unaryBits (List.ofFn id) bits ++ suffix) : + StateTransition.EvalsToInTime (TM2.step program) ⟨some label, state, tapes⟩ + (some ⟨exit, (state.1, MachineFixedBlockMap.emptyBuffer N), + Function.update (Function.update tapes source suffix) destination + (List.ofFn (F bits) ++ tapes destination)⟩) 1 where + steps := 1 + evals_in_steps := step_unaryBlockMapAt source destination F exit hne program label + atLabel state bits tapes suffix hinput + steps_le_m := Nat.le_refl _ + +end RelationReader + +theorem unaryBits_relation (relation : GraphTables.RelationTable) : + unaryBits (List.ofFn id) (fun i => relation[i]) = + encodeWords (GraphTables.relationWords relation) := by + have h : List.ofFn (fun i : Fin 4096 => relation[i]) = relation.toList := by + change List.ofFn (fun i : Fin 4096 => relation[i.val]) = relation.toList + rw [← Vector.toList_ofFn, Vector.ofFn_getElem] + rw [unaryBits_eq_encodeWords] + unfold GraphTables.relationWords + rw [← h] + simp only [List.map_ofFn, Function.comp_def, id_eq] + +def readerStateEquiv (σ : Type) (N : Nat) : + (((σ × Unit) × Option Bool) × Buffer N) ≃ (((σ × Buffer N) × Unit) × Option Bool) where + toFun state := (((state.1.1.1, state.2), state.1.1.2), state.1.2) + invFun state := (((state.1.1.1, state.1.2), state.2), state.1.1.2) + left_inv _ := rfl + right_inv _ := rfl + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFOutput.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..29e4dc75297388ec35e95ee2415b58fb6f09045a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFOutput.lean @@ -0,0 +1,145 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.FinalTableFormula +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFStream +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFRowPlan + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +section + +open PCP PCP.AlphabetTable + +def formulaHeader (table : GraphTables.Table) : List Bool := + encodeWords [6 * table.vertices + 36864 * table.darts, 40960 * table.darts] + +theorem formulaHeader_eq (table : GraphTables.Table) : + formulaHeader table = encodeWords [(FinalTableFormula.output table).«variables», + (FinalTableFormula.output table).clauses.length] := by + simp only [formulaHeader, FinalTableFormula.variable_count, FinalTableFormula.clause_count, + Nat.mul_comm] + +theorem headerPlan_eq_formulaHeader (table : GraphTables.Table) (tail head row : Nat) + (ambient : Ambient) : + headerPlan.flatMap (Emitter.commandBits + (values table.vertices table.darts tail head row) ambient) = formulaHeader table := + headerPlan_bits table.vertices table.darts tail head row ambient + +theorem outputStream_eq_clauseBits (table : GraphTables.Table) : + outputStream rowPlan table (List.finRange table.darts) = + encodeWords ((FinalTableFormula.output table).clauses.flatMap Complexity.clauseWords) := by + calc + _ = (List.finRange table.darts).flatMap (fun e => + encodeWords ((VerifierToCNF.eventBlock (FinalCNFPattern.tableVerifier table) + (by decide) e).flatMap Complexity.clauseWords)) := by + apply List.flatMap_congr + intro e he + exact rowPlan_bits table e + _ = encodeWords ((List.finRange table.darts).flatMap (fun e => + (VerifierToCNF.eventBlock (FinalCNFPattern.tableVerifier table) + (by decide) e).flatMap Complexity.clauseWords)) := + (encodeWords_flatMap _ _).symm + _ = _ := by + congr 1 + rw [← List.flatMap_assoc] + rfl + +theorem header_append_outputStream (table : GraphTables.Table) : + formulaHeader table ++ outputStream rowPlan table (List.finRange table.darts) = + formulaBits (FinalTableFormula.output table) := by + rw [formulaHeader_eq, outputStream_eq_clauseBits] + exact (encodeWords_append _ _).symm + +theorem emitted_output_eq (table : GraphTables.Table) (tail head row : Nat) + (ambient : Ambient) : + headerPlan.flatMap (Emitter.commandBits + (values table.vertices table.darts tail head row) ambient) ++ + outputStream rowPlan table (List.finRange table.darts) = + formulaBits (FinalTableFormula.output table) := by + rw [headerPlan_eq_formulaHeader] + exact header_append_outputStream table + +theorem reversed_accumulator_output (table : GraphTables.Table) : + (formulaHeader table ++ outputStream rowPlan table (List.finRange table.darts)).reverse.reverse = + formulaBits (FinalTableFormula.output table) := by + rw [List.reverse_reverse, header_append_outputStream] + +theorem accumulator_length_bound (table : GraphTables.Table) : + (formulaHeader table ++ outputStream rowPlan table (List.finRange table.darts)).reverse.length ≤ + FinalTableFormula.sizePolynomial.eval (GraphTables.tableBits table).length := by + rw [List.length_reverse, header_append_outputStream] + exact FinalTableFormula.formulaBits_length_le_polynomial table + +end + +open PCP + +noncomputable def rowTimePolynomial : Polynomial Nat := + Polynomial.C 860160 * (Polynomial.C 3 * (Polynomial.X + Polynomial.C 1) + Polynomial.C 3) + + Polynomial.C 12 * Polynomial.X + Polynomial.C 15 + +theorem rowTimePolynomial_eval (N : Nat) : + rowTimePolynomial.eval N = rowTime rowPlan N := by + simp only [rowTimePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, rowTime, rowPlan_length] + +theorem rowTime_expanded (N : Nat) : rowTime rowPlan N = 2580492 * N + 5160975 := by + rw [rowTime, rowPlan_length] + omega + +noncomputable def phaseTimePolynomial : Polynomial Nat := + headerTimePolynomial + + (Polynomial.X * (rowTimePolynomial + Polynomial.C 1) + Polynomial.C 1) + + (FinalTableFormula.sizePolynomial + Polynomial.C 1) + +theorem phaseTimePolynomial_eval (N : Nat) : + phaseTimePolynomial.eval N = + headerTimePolynomial.eval N + (N * (rowTime rowPlan N + 1) + 1) + + (FinalTableFormula.sizePolynomial.eval N + 1) := by + simp only [phaseTimePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, rowTimePolynomial_eval] + +theorem phaseTimePolynomial_eval_expanded (N : Nat) : + phaseTimePolynomial.eval N = 4532428812 * N ^ 2 + 5484585 * N + 56 := by + rw [phaseTimePolynomial_eval, headerTimePolynomial_eval, rowTime_expanded, + FinalTableFormula.sizePolynomial_eval] + ring + +theorem phaseTime_le {N rows outputLength : Nat} (rowBound : rows ≤ N) + (outputBound : outputLength ≤ FinalTableFormula.sizePolynomial.eval N) : + headerTimePolynomial.eval N + (rows * (rowTime rowPlan N + 1) + 1) + + (outputLength + 1) ≤ phaseTimePolynomial.eval N := by + have hrows := Nat.mul_le_mul_right (rowTime rowPlan N + 1) rowBound + rw [phaseTimePolynomial_eval] + omega + +theorem table_phaseTime_le (table : GraphTables.Table) : + headerTimePolynomial.eval (GraphTables.tableBits table).length + + (table.darts * (rowTime rowPlan (GraphTables.tableBits table).length + 1) + 1) + + ((formulaBits (FinalTableFormula.output table)).length + 1) ≤ + phaseTimePolynomial.eval (GraphTables.tableBits table).length := + phaseTime_le (GraphTables.darts_le_tableBits_length table) + (FinalTableFormula.formulaBits_length_le_polynomial table) + +noncomputable def finalTimePolynomial (C : Nat) : Polynomial Nat := + phaseTimePolynomial + Polynomial.C 12 * + (Polynomial.X + phaseTimePolynomial * Polynomial.C C + Polynomial.C 1) + Polynomial.C 1 + +theorem finalTimePolynomial_eval (C N : Nat) : + (finalTimePolynomial C).eval N = phaseTimePolynomial.eval N + + 12 * (N + phaseTimePolynomial.eval N * C + 1) + 1 := by + simp only [finalTimePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X] + +theorem finalTime_le (C N workLength : Nat) + (workBound : workLength ≤ N + phaseTimePolynomial.eval N * C) : + phaseTimePolynomial.eval N + 12 * (workLength + 1) + 1 ≤ + (finalTimePolynomial C).eval N := by + have h := Nat.mul_le_mul_left 12 (Nat.add_le_add_right workBound 1) + rw [finalTimePolynomial_eval] + omega + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRow.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..92c6d19bb7864d6f4ae2a427d853704a320dfce8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRow.lean @@ -0,0 +1,275 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFRowTrace +import OAI.Combinatorics.IndependentSets.PCP.FinalCNFTableAdapter + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +open Turing PCP PCP.AlphabetTable FinalCNFTableAdapter + +@[simp] theorem headRoles_zero : headRoles 0 = Tape.archive := rfl +@[simp] theorem headRoles_one : headRoles 1 = Tape.reverseIndex := rfl +@[simp] theorem headRoles_two : headRoles 2 = Tape.scanWork := rfl +@[simp] theorem headRoles_three : headRoles 3 = Tape.indexWork := rfl +@[simp] theorem headRoles_four : headRoles 4 = Tape.head := rfl +@[simp] theorem headRoles_five : headRoles 5 = Tape.scratch := rfl + +def rowOperands (table : GraphTables.Table) (e : Fin table.darts) : Fin 5 → Nat := + values table.vertices table.darts table.rows[e].tail.val + table.rows[table.rows[e].reverseIndex].tail.val e.val + +def rowRelation (table : GraphTables.Table) (e : Fin table.darts) : Ambient := + ((), fun i => table.rows[e].relation[i]) + +def rowRest (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) : List Bool := + encodeWords (GraphTables.relationWords table.rows[e].relation) ++ rest + +def preparedTapes (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) : Tape → List Bool := + Lookup.headLookupTapes headRoles + (endpointTapes base table.rows[e].tail.val table.rows[e].reverseIndex.val + (rowRest table e rest)) (genericTable table) e + +theorem prepared_input (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) : + preparedTapes base table e rest .input = rowRest table e rest := by + simp [preparedTapes, Lookup.headLookupTapes, MachineLookup.tapes, endpointTapes, + Hastad.SourceMachine.fieldTapes] + +theorem prepared_head (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) : + preparedTapes base table e rest .head = + encodeWord table.rows[table.rows[e].reverseIndex].tail.val := by + simp [preparedTapes, Lookup.headLookupTapes, MachineLookup.tapes, + genericTable_headValue, GraphTables.semantics, ConstraintGraph.head, + GraphTables.reverseAt] + +theorem prepared_tail (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) : + preparedTapes base table e rest .tail = encodeWord table.rows[e].tail.val ++ base .tail := by + simp [preparedTapes, Lookup.headLookupTapes, MachineLookup.tapes, endpointTapes, + Hastad.SourceMachine.fieldTapes] + +theorem prepared_reverse (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) : + preparedTapes base table e rest .reverseIndex = + encodeWord table.rows[e].reverseIndex.val ++ base .reverseIndex := by + simp [preparedTapes, Lookup.headLookupTapes, MachineLookup.tapes, endpointTapes, + Hastad.SourceMachine.fieldTapes] + +theorem prepared_frame (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) (tape : Tape) + (hi : tape ≠ .input) (ht : tape ≠ .tail) (hr : tape ≠ .reverseIndex) + (hh : tape ≠ .head) (hs : tape ≠ .scanWork) (hx : tape ≠ .indexWork) : + preparedTapes base table e rest tape = base tape := by + simp [preparedTapes, Lookup.headLookupTapes, MachineLookup.tapes, endpointTapes, + Hastad.SourceMachine.fieldTapes, hi, ht, hr, hh, hs, hx] + +def emittedTapes (plan : Plan) (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) : Tape → List Bool := + Function.update (Function.update (preparedTapes base table e rest) Tape.input rest) + Tape.accumulator ((plan.flatMap (Emitter.commandBits (rowOperands table e) + (rowRelation table e))).reverse ++ base .accumulator) + +def rowResultTapes (plan : Plan) (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) : Tape → List Bool := + finishTapes (emittedTapes plan base table e rest) e.val + +@[simp] theorem rowResult_input (plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) : + rowResultTapes plan base table e rest .input = rest := by + simp [rowResultTapes, finishTapes, emittedTapes] + +@[simp] theorem rowResult_tail (plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) : + rowResultTapes plan base table e rest .tail = [] := by + simp [rowResultTapes, finishTapes] + +@[simp] theorem rowResult_head (plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) : + rowResultTapes plan base table e rest .head = [] := by + simp [rowResultTapes, finishTapes] + +@[simp] theorem rowResult_reverse (plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) : + rowResultTapes plan base table e rest .reverseIndex = [] := by + simp [rowResultTapes, finishTapes] + +@[simp] theorem rowResult_index (plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) : + rowResultTapes plan base table e rest .rowIndex = encodeWord (e.val + 1) := by + simp [rowResultTapes, finishTapes] + +@[simp] theorem rowResult_accumulator (plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) : + rowResultTapes plan base table e rest .accumulator = + (plan.flatMap (Emitter.commandBits (rowOperands table e) (rowRelation table e))).reverse ++ + base .accumulator := by + simp [rowResultTapes, finishTapes, emittedTapes] + +theorem rowResult_frame (plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) (tape : Tape) + (hi : tape ≠ .input) (ht : tape ≠ .tail) (hr : tape ≠ .reverseIndex) + (hh : tape ≠ .head) (hs : tape ≠ .scanWork) (hx : tape ≠ .indexWork) + (ha : tape ≠ .accumulator) (hc : tape ≠ .rowIndex) : + rowResultTapes plan base table e rest tape = base tape := by + simp only [rowResultTapes, finishTapes, emittedTapes, Function.update_of_ne hi, + Function.update_of_ne ht, Function.update_of_ne hr, Function.update_of_ne hh, + Function.update_of_ne ha, Function.update_of_ne hc] + exact prepared_frame base table e rest tape hi ht hr hh hs hx + +def guardRowInTime (headerPlan plan : Plan) (base : Tape → List Bool) + (ambient : Ambient) (hinput : base .input ≠ []) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .guard, ((ambient, ()), none), base⟩ + (some ⟨some .startTail, ((ambient, ()), none), base⟩) 1 where + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (program headerPlan plan .guard) _ _) = _ + cases hb : base .input with + | nil => exact False.elim (hinput hb) + | cons b bs => simp [program, guard, TM2.stepAux, hb] + steps_le_m := Nat.le_refl _ + +def guardEndInTime (headerPlan plan : Plan) (base : Tape → List Bool) + (ambient : Ambient) (hinput : base .input = []) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .guard, ((ambient, ()), none), base⟩ + (some ⟨some .reverseOutput, ((ambient, ()), none), base⟩) 1 where + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (program headerPlan plan .guard) _ _) = _ + simp [program, guard, TM2.stepAux, hinput] + steps_le_m := Nat.le_refl _ + +theorem prepared_operands (base : Tape → List Bool) (table : GraphTables.Table) + (e : Fin table.darts) (rest : List Bool) + (hn : base .vertices = encodeWord table.vertices) + (hm : base .darts = encodeWord table.darts) + (hr : base .rowIndex = encodeWord e.val) + (ht : base .tail = []) : + ∀ i, (Function.update (preparedTapes base table e rest) Tape.input rest) (source i) = + encodeWord (rowOperands table e i) := by + intro i + fin_cases i + · simpa [source, rowOperands, values] using + prepared_frame base table e rest .vertices (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) |>.trans hn + · change (Function.update (preparedTapes base table e rest) Tape.input rest) Tape.darts = _ + simp only [Function.update_of_ne (show Tape.darts ≠ Tape.input by decide)] + exact (prepared_frame base table e rest .darts (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide)).trans hm + · change (Function.update (preparedTapes base table e rest) Tape.input rest) Tape.tail = _ + simp only [Function.update_of_ne (show Tape.tail ≠ Tape.input by decide), prepared_tail, + ht, List.append_nil] + rfl + · change (Function.update (preparedTapes base table e rest) Tape.input rest) Tape.head = _ + simp only [Function.update_of_ne (show Tape.head ≠ Tape.input by decide), prepared_head] + rfl + · change (Function.update (preparedTapes base table e rest) Tape.input rest) Tape.rowIndex = _ + simp only [Function.update_of_ne (show Tape.rowIndex ≠ Tape.input by decide)] + exact (prepared_frame base table e rest .rowIndex (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide)).trans hr + +theorem rowOperands_bounded (table : GraphTables.Table) (e : Fin table.darts) : + ∀ i, rowOperands table e i ≤ (GraphTables.tableBits table).length := by + intro i + fin_cases i + · exact GraphTables.vertices_le_tableBits_length table + · exact GraphTables.darts_le_tableBits_length table + · exact table.rows[e].tail.isLt.le.trans (GraphTables.vertices_le_tableBits_length table) + · exact table.rows[table.rows[e].reverseIndex].tail.isLt.le.trans + (GraphTables.vertices_le_tableBits_length table) + · exact e.isLt.le.trans (GraphTables.darts_le_tableBits_length table) + +def rowTime (plan : Plan) (N : Nat) : Nat := + plan.length * (3 * (N + 1) + 3) + 12 * N + 15 + +noncomputable def rowInTime (headerPlan plan : Plan) (base : Tape → List Bool) + (table : GraphTables.Table) (e : Fin table.darts) (rest : List Bool) + (hinput : base .input = encodeWords (GraphTables.rowWords table.rows[e]) ++ rest) + (harchive : base .archive = GraphTables.tableBits table) + (hn : base .vertices = encodeWord table.vertices) + (hm : base .darts = encodeWord table.darts) + (hrow : base .rowIndex = encodeWord e.val) + (ht : base .tail = []) (hh : base .head = []) (hr : base .reverseIndex = []) + (hscratch : base .scratch = []) (ambient : Ambient) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .startTail, ((ambient, ()), none), base⟩ + (some ⟨some .guard, ((rowRelation table e, ()), none), + rowResultTapes plan base table e rest⟩) + (rowTime plan (GraphTables.tableBits table).length) := by + let parsed := endpointTapes base table.rows[e].tail.val table.rows[e].reverseIndex.val + (rowRest table e rest) + let ready := preparedTapes base table e rest + let read := Function.update ready Tape.input rest + let output := emittedTapes plan base table e rest + let run₁ := endpointsInTime headerPlan plan base table.rows[e].tail.val + table.rows[e].reverseIndex.val (rowRest table e rest) + (by simpa [GraphTables.rowWords, encodeWords, List.append_assoc, rowRest] using hinput) ambient + have parsed_archive : parsed .archive = GenericGraphTables.tableBits (genericTable table) := by + simpa [parsed, endpointTapes, Hastad.SourceMachine.fieldTapes] using harchive + have parsed_reverse : parsed .reverseIndex = + encodeWord (Lookup.headIndex (genericTable table) e).val := by + simp [parsed, endpointTapes, Hastad.SourceMachine.fieldTapes, hr] + have parsed_head : parsed .head = [] := by + simp [parsed, endpointTapes, Hastad.SourceMachine.fieldTapes, hh] + have parsed_scratch : parsed .scratch = [] := by + simp [parsed, endpointTapes, Hastad.SourceMachine.fieldTapes, hscratch] + let run₂ := headPhaseInTime headerPlan plan parsed (genericTable table) e + parsed_archive parsed_reverse parsed_head parsed_scratch ambient + let run₃ := relationInTime headerPlan plan ready table.rows[e].relation rest + (prepared_input base table e rest) ambient + have read_operands : ∀ i, read (source i) = encodeWord (rowOperands table e i) := + prepared_operands base table e rest hn hm hrow ht + have read_scratch : read .scratch = [] := by + simp only [read, Function.update_of_ne (show Tape.scratch ≠ Tape.input by decide)] + exact (prepared_frame base table e rest .scratch (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide)).trans hscratch + have read_acc : read .accumulator = base .accumulator := by + simp only [read, Function.update_of_ne (show Tape.accumulator ≠ Tape.input by decide)] + exact prepared_frame base table e rest .accumulator (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) + have run₄ : StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some (.row (Emitter.labelAt plan.length 36864 0 .entry)), + ((rowRelation table e, ()), none), read⟩ + (some ⟨some .clearTail, ((rowRelation table e, ()), none), output⟩) + (plan.length * (3 * ((GraphTables.tableBits table).length + 1) + 3) + 1) := by + simpa only [read_acc, output, emittedTapes, read, ready] using + emitInTime headerPlan plan read (rowOperands table e) read_operands read_scratch + (rowRelation table e) (GraphTables.tableBits table).length (rowOperands_bounded table e) + have output_tail : output .tail = encodeWord table.rows[e].tail.val := by + simp [output, emittedTapes, prepared_tail, ht] + have output_head : output .head = encodeWord table.rows[table.rows[e].reverseIndex].tail.val := by + simp [output, emittedTapes, prepared_head] + have output_reverse : output .reverseIndex = encodeWord table.rows[e].reverseIndex.val := by + simp [output, emittedTapes, prepared_reverse, hr] + have output_row : output .rowIndex = encodeWord e.val := by + simp only [output, emittedTapes, + Function.update_of_ne (show Tape.rowIndex ≠ Tape.accumulator by decide), + Function.update_of_ne (show Tape.rowIndex ≠ Tape.input by decide)] + exact (prepared_frame base table e rest .rowIndex (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide)).trans hrow + let run₅ := finishInTime headerPlan plan output table.rows[e].tail.val + table.rows[table.rows[e].reverseIndex].tail.val table.rows[e].reverseIndex.val e.val + output_tail output_head output_reverse output_row (rowRelation table e) + let r₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁ run₂ + let r₁₂₃ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₁₂ run₃ + let r₁₂₃₄ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₁₂₃ run₄ + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₁₂₃₄ run₅ + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have hb := run.steps_le_m + have htbound := rowOperands_bounded table e 2 + have hhbound := rowOperands_bounded table e 3 + have hrbound := table.rows[e].reverseIndex.isLt.le.trans (GraphTables.darts_le_tableBits_length table) + change table.rows[e].tail.val ≤ _ at htbound + change table.rows[table.rows[e].reverseIndex].tail.val ≤ _ at hhbound + simp only [Lookup.headTimePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, genericTable_tableBits] at hb + unfold rowTime + omega + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRowPlan.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRowPlan.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a8c5cefd5e72902f85546c3d0a38f6992296cb5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRowPlan.lean @@ -0,0 +1,191 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.FinalCNFPattern +import OAI.Combinatorics.IndependentSets.Machines.AmbientRelation +import OAI.Combinatorics.IndependentSets.PCP.FinalCNFTemplate + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +open PCP PCP.AlphabetTable FinalCNFTemplate + +def referenceValue (vertices tail head row pattern : Nat) : Reference → Nat + | .query i => if i.val < 6 then 6 * tail + i.val else 6 * head + (i.val - 6) + | .auxiliary j => 6 * vertices + 36864 * row + (9 * pattern + j.val) + +def auxiliaryFlag : Reference → Bool + | .query _ => false + | .auxiliary _ => true + +def tailFlag : Reference → Bool + | .query i => decide (i.val < 6) + | .auxiliary _ => false + +def headFlag : Reference → Bool + | .query i => decide (6 ≤ i.val) + | .auxiliary _ => false + +theorem pattern_lt (p : VerifierToCNF.PatternIndex 12) : p.val < 4096 := by + have hlen : (VerifierToCNF.patterns 12).length = 4096 := VerifierToCNF.patterns_length 12 + exact lt_of_lt_of_eq p.isLt hlen + +def referenceOffset (p : VerifierToCNF.PatternIndex 12) : Reference → Fin 36864 + | .query i => ⟨if i.val < 6 then i.val else i.val - 6, by split <;> omega⟩ + | .auxiliary j => ⟨9 * p.val + j.val, by have hp := pattern_lt p; omega⟩ + +def literalPlan (p : VerifierToCNF.PatternIndex 12) (literal : Ambient → LiteralTemplate) : Plan := + [.scaledIf 0 6 (fun state => auxiliaryFlag (literal state).reference), + .scaledIf 2 6 (fun state => tailFlag (literal state).reference), + .scaledIf 3 6 (fun state => headFlag (literal state).reference), + .scaledIf 4 36864 (fun state => auxiliaryFlag (literal state).reference), + .bounded (fun state => referenceOffset p (literal state).reference), + .literal [false], + .bit (fun state => (literal state).positive)] + +theorem literalPlan_length (p : VerifierToCNF.PatternIndex 12) + (literal : Ambient → LiteralTemplate) : (literalPlan p literal).length = 7 := rfl + +theorem literalPlan_bits (p : VerifierToCNF.PatternIndex 12) + (literal : Ambient → LiteralTemplate) (vertices darts tail head row : Nat) + (ambient : Ambient) : + (literalPlan p literal).flatMap + (Emitter.commandBits (values vertices darts tail head row) ambient) = + encodeWords (FinalCNFTemplate.literalWords + (referenceValue vertices tail head row p.val) (literal ambient)) := by + rcases h : literal ambient with ⟨reference, positive⟩ + cases reference with + | query i => + by_cases hi : i.val < 6 + · simp [literalPlan, Emitter.commandBits, h, auxiliaryFlag, tailFlag, headFlag, + referenceOffset, referenceValue, FinalCNFTemplate.literalWords, values, + hi, show ¬ 6 ≤ i.val by omega, encodeWords, encodeWord, List.replicate_add, + List.append_assoc, -List.replicate_append_replicate] + rfl + · simp [literalPlan, Emitter.commandBits, h, auxiliaryFlag, tailFlag, headFlag, + referenceOffset, referenceValue, FinalCNFTemplate.literalWords, values, + hi, show 6 ≤ i.val by omega, encodeWords, encodeWord, List.replicate_add, + List.append_assoc, -List.replicate_append_replicate] + rfl + | auxiliary j => + simp [literalPlan, Emitter.commandBits, h, auxiliaryFlag, tailFlag, headFlag, + referenceOffset, referenceValue, FinalCNFTemplate.literalWords, values, + encodeWords, encodeWord, List.replicate_add, List.append_assoc, + -List.replicate_append_replicate] + rfl + +def patternLiteral (p : VerifierToCNF.PatternIndex 12) (clause : Fin 10) (slot : Fin 3) + (ambient : Ambient) : LiteralTemplate := + literalAt (ambient.2 (FinalCNFPattern.patternRelationIndex p)) + (VerifierToCNF.patternAt 12 p) clause slot + +def patternPlan (p : VerifierToCNF.PatternIndex 12) : Plan := + (List.finRange 10).flatMap fun clause => + (List.finRange 3).flatMap fun slot => literalPlan p (patternLiteral p clause slot) + +def rowPlan : Plan := + (List.finRange (VerifierToCNF.patterns 12).length).flatMap patternPlan + +theorem patternPlan_length (p : VerifierToCNF.PatternIndex 12) : + (patternPlan p).length = 210 := by + unfold patternPlan + rw [VerifierToCNF.length_flatMap_constant _ _ 21] + · simp + · intro clause hclause + rw [VerifierToCNF.length_flatMap_constant _ _ 7] + · simp + · intro slot hslot + exact literalPlan_length _ _ + +theorem rowPlan_length : rowPlan.length = 860160 := by + unfold rowPlan + rw [VerifierToCNF.length_flatMap_constant _ _ 210] + · rw [List.length_finRange, VerifierToCNF.patterns_length] + norm_num + · intro p hp + exact patternPlan_length p + +theorem encodeWords_flatMap {α : Type*} (xs : List α) (words : α → List Nat) : + encodeWords (xs.flatMap words) = xs.flatMap (fun x => encodeWords (words x)) := by + induction xs with + | nil => rfl + | cons x xs ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem patternPlan_bits (p : VerifierToCNF.PatternIndex 12) + (vertices darts tail head row : Nat) (ambient : Ambient) : + (patternPlan p).flatMap + (Emitter.commandBits (values vertices darts tail head row) ambient) = + encodeWords (FinalCNFTemplate.words + (ambient.2 (FinalCNFPattern.patternRelationIndex p)) + (VerifierToCNF.patternAt 12 p) (referenceValue vertices tail head row p.val)) := by + unfold patternPlan + simp only [List.flatMap_assoc] + simp_rw [literalPlan_bits] + have hclauses : + (List.finRange 10).map + (fun c => (blockTemplates (ambient.2 (FinalCNFPattern.patternRelationIndex p)) + (VerifierToCNF.patternAt 12 p))[c]) = + templates (ambient.2 (FinalCNFPattern.patternRelationIndex p)) + (VerifierToCNF.patternAt 12 p) := by + rw [← List.ofFn_eq_map] + change List.ofFn (fun c : Fin 10 => + (blockTemplates (ambient.2 (FinalCNFPattern.patternRelationIndex p)) + (VerifierToCNF.patternAt 12 p))[c.val]) = _ + rw [← Vector.toList_ofFn, Vector.ofFn_getElem] + rfl + unfold FinalCNFTemplate.words + rw [← hclauses, List.flatMap_map, encodeWords_flatMap] + apply List.flatMap_congr + intro clause hclause + simp only [List.finRange, List.ofFn_succ, List.ofFn_zero, List.flatMap_cons, + List.flatMap_nil, patternLiteral, literalAt, FinalCNFTemplate.clauseWords, + encodeWords_append, List.append_nil, List.append_assoc] + rfl + +theorem referenceValue_eq_resolve (table : GraphTables.Table) (e : Fin table.darts) + (p : VerifierToCNF.PatternIndex 12) (reference : Reference) : + referenceValue table.vertices table.rows[e].tail.val + table.rows[table.rows[e].reverseIndex].tail.val e.val p.val reference = + (resolve (FinalCNFPattern.tableVerifier table) e p reference).val := by + cases reference with + | query i => + rw [resolve_query_value] + refine Fin.addCases (m := 6) (n := 6) (fun j => ?_) (fun j => ?_) i + · rw [FinalBooleanVerifier.query_tail] + simp only [referenceValue, Fin.val_castAdd, j.isLt, ite_true] + change 6 * table.rows[e].tail.val + j.val = j.val + 6 * table.rows[e].tail.val + omega + · rw [FinalBooleanVerifier.query_head] + simp only [referenceValue, Fin.val_natAdd] + split + · omega + · change 6 * table.rows[table.rows[e].reverseIndex].tail.val + + (6 + j.val - 6) = j.val + 6 * table.rows[table.rows[e].reverseIndex].tail.val + omega + | auxiliary j => + rw [resolve_auxiliary_value] + change 6 * table.vertices + 36864 * e.val + (9 * p.val + j.val) = + table.vertices * 6 + ((e.val * 4096 + p.val) * 9 + j.val) + omega + +theorem rowPlan_bits (table : GraphTables.Table) (e : Fin table.darts) : + rowPlan.flatMap (Emitter.commandBits + (values table.vertices table.darts table.rows[e].tail.val + table.rows[table.rows[e].reverseIndex].tail.val e.val) + ((), fun i => table.rows[e].relation[i])) = + encodeWords ((VerifierToCNF.eventBlock (FinalCNFPattern.tableVerifier table) + (by decide) e).flatMap Complexity.clauseWords) := by + unfold rowPlan VerifierToCNF.eventBlock + simp only [List.flatMap_assoc] + rw [encodeWords_flatMap] + apply List.flatMap_congr + intro p hp + rw [patternPlan_bits] + dsimp only + rw [FinalCNFPattern.pattern_lookup_eq_verifier_accepts] + have href := funext (referenceValue_eq_resolve table e p) + rw [href] + exact congrArg encodeWords (words_eq_block (FinalCNFPattern.tableVerifier table) e p) + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRowTrace.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRowTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..34070b6474203cc877c801d5b2f9773e512196a6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFRowTrace.lean @@ -0,0 +1,115 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupDiscard +import OAI.Combinatorics.IndependentSets.Machines.AmbientRelation + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +open Turing PCP PCP.AlphabetTable + +def endpointTapes (base : Tape → List Bool) (tail reverse : Nat) (rest : List Bool) := + Hastad.SourceMachine.fieldTapes Tape.input Tape.reverseIndex + (Hastad.SourceMachine.fieldTapes Tape.input Tape.tail base + (encodeWord reverse ++ rest) (encodeWord tail ++ base .tail)) + rest (encodeWord reverse ++ base .reverseIndex) + +def endpointsInTime (headerPlan plan : Plan) (base : Tape → List Bool) + (tail reverse : Nat) (rest : List Bool) + (hinput : base .input = encodeWord tail ++ encodeWord reverse ++ rest) + (ambient : Ambient) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .startTail, ((ambient, ()), none), base⟩ + (some ⟨some .headTableFirst, ((ambient, ()), none), + endpointTapes base tail reverse rest⟩) (tail + reverse + 4) := by + let first := Hastad.SourceMachine.fieldTapes Tape.input Tape.tail base + (encodeWord reverse ++ rest) (encodeWord tail ++ base .tail) + let run₁ := Hastad.SourceMachine.fieldInTime Tape.input Tape.tail (by decide) + .startTail .readTail (some .startReverse) (program headerPlan plan) rfl rfl + base tail (encodeWord reverse ++ rest) (by simpa only [List.append_assoc] using hinput) + (ambient, ()) none + have input₁ : first .input = encodeWord reverse ++ rest := by + simp [first, Hastad.SourceMachine.fieldTapes] + have reverse₁ : first .reverseIndex = base .reverseIndex := by + simp [first, Hastad.SourceMachine.fieldTapes] + let run₂ := Hastad.SourceMachine.fieldInTime Tape.input Tape.reverseIndex (by decide) + .startReverse .readReverse (some .headTableFirst) (program headerPlan plan) rfl rfl + first reverse rest input₁ (ambient, ()) none + have joined := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁ run₂ + simpa only [first, reverse₁, endpointTapes, Nat.add_assoc, + Nat.add_left_comm, Nat.add_comm] using joined + +def relationInTime (headerPlan plan : Plan) (base : Tape → List Bool) + (relation : GraphTables.RelationTable) (rest : List Bool) + (hinput : base .input = encodeWords (GraphTables.relationWords relation) ++ rest) + (ambient : Ambient) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .readRelation, ((ambient, ()), none), base⟩ + (some ⟨some (.row (Emitter.labelAt plan.length 36864 0 .entry)), + ((((), fun i => relation[i]), ()), none), Function.update base .input rest⟩) 1 where + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (program headerPlan plan .readRelation) _ _) = _ + rw [program, stepAux_readRelationAt _ _ _ _ _ _ _ _ _ hinput] + steps_le_m := Nat.le_refl _ + +def emitInTime (headerPlan plan : Plan) (base : Tape → List Bool) + (operands : Fin 5 → Nat) (hoperands : ∀ i, base (source i) = encodeWord (operands i)) + (hscratch : base .scratch = []) (ambient : Ambient) + (N : Nat) (hbounded : ∀ i, operands i ≤ N) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some (.row (Emitter.labelAt plan.length 36864 0 .entry)), + ((ambient, ()), none), base⟩ + (some ⟨some .clearTail, ((ambient, ()), none), + Function.update base .accumulator + ((plan.flatMap (Emitter.commandBits operands ambient)).reverse ++ base .accumulator)⟩) + (plan.length * (3 * (N + 1) + 3) + 1) := by + have run := Emitter.planInTime (Emitter.listCommands plan) + source Tape.scratch Tape.accumulator source_ne_scratch source_ne_accumulator (by decide) + Label.row (some .clearTail) (program headerPlan plan) (fun _ => rfl) + operands base hoperands hscratch ambient N hbounded + simpa only [Emitter.bits_listCommands, Emitter.resultTapes] using run + +def finishTapes (base : Tape → List Bool) (row : Nat) : Tape → List Bool := + Function.update + (Function.update (Function.update (Function.update base Tape.tail []) Tape.head []) + Tape.reverseIndex []) Tape.rowIndex (encodeWord (row + 1)) + +def finishInTime (headerPlan plan : Plan) (base : Tape → List Bool) + (tail head reverse row : Nat) + (htail : base .tail = encodeWord tail) (hhead : base .head = encodeWord head) + (hreverse : base .reverseIndex = encodeWord reverse) + (hrow : base .rowIndex = encodeWord row) (ambient : Ambient) : + StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .clearTail, ((ambient, ()), none), base⟩ + (some ⟨some .guard, ((ambient, ()), none), finishTapes base row⟩) + (tail + head + reverse + 4) := by + let t₁ := Function.update base Tape.tail [] + let t₂ := Function.update t₁ Tape.head [] + let t₃ := Function.update t₂ Tape.reverseIndex [] + let run₁ := MachineLookup.discardInTime Tape.tail .clearTail .clearHead + (program headerPlan plan) rfl base tail [] (by simpa using htail) (ambient, ()) none + have hhead₁ : t₁ .head = encodeWord head := by simp [t₁, hhead] + let run₂ := MachineLookup.discardInTime Tape.head .clearHead .clearReverse + (program headerPlan plan) rfl t₁ head [] (by simpa using hhead₁) (ambient, ()) none + have hreverse₂ : t₂ .reverseIndex = encodeWord reverse := by simp [t₂, t₁, hreverse] + let run₃ := MachineLookup.discardInTime Tape.reverseIndex .clearReverse .nextRow + (program headerPlan plan) rfl t₂ reverse [] (by simpa using hreverse₂) (ambient, ()) none + let run₄ : StateTransition.EvalsToInTime (TM2.step (program headerPlan plan)) + ⟨some .nextRow, ((ambient, ()), none), t₃⟩ + (some ⟨some .guard, ((ambient, ()), none), finishTapes base row⟩) 1 := { + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (program headerPlan plan .nextRow) _ _) = _ + simp only [program, TM2.stepAux] + congr 2 + simp [t₃, t₂, t₁, finishTapes, hrow, encodeWord, List.replicate_succ] + steps_le_m := Nat.le_refl _ } + let r₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁ run₂ + let r₁₂₃ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₁₂ run₃ + have run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₁₂₃ run₄ + simpa only [Nat.add_assoc, Nat.add_left_comm, Nat.add_comm] using run + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFStream.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFStream.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9a2a90a944e309ff48910ac9fda2233ad9ab732 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalCNFStream.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFHeader +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFRow + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +open PCP PCP.AlphabetTable FinalCNFTableAdapter + +def remainingEvents (table : GraphTables.Table) (r : Nat) : List (Fin table.darts) := + (List.finRange table.darts).drop r + +def processedEvents (table : GraphTables.Table) (r : Nat) : List (Fin table.darts) := + (List.finRange table.darts).take r + +def inputStream (table : GraphTables.Table) (events : List (Fin table.darts)) : List Bool := + events.flatMap (fun e => encodeWords (GraphTables.rowWords table.rows[e])) + +def outputStream (plan : Plan) (table : GraphTables.Table) + (events : List (Fin table.darts)) : List Bool := + events.flatMap (fun e => plan.flatMap (Emitter.commandBits (rowOperands table e) + (rowRelation table e))) + +@[simp] theorem remainingEvents_zero (table : GraphTables.Table) : + remainingEvents table 0 = List.finRange table.darts := by + simp [remainingEvents] + +@[simp] theorem remainingEvents_length (table : GraphTables.Table) (r : Nat) : + (remainingEvents table r).length = table.darts - r := by + simp [remainingEvents] + +@[simp] theorem remainingEvents_done (table : GraphTables.Table) : + remainingEvents table table.darts = [] := by + simp [remainingEvents] + +theorem remainingEvents_cons (table : GraphTables.Table) (r : Nat) (h : r < table.darts) : + remainingEvents table r = ⟨r, h⟩ :: remainingEvents table (r + 1) := by + unfold remainingEvents + rw [List.drop_eq_getElem_cons (l := List.finRange table.darts) (i := r) + (by simpa using h)] + simp + +@[simp] theorem processedEvents_zero (table : GraphTables.Table) : + processedEvents table 0 = [] := by simp [processedEvents] + +@[simp] theorem processedEvents_done (table : GraphTables.Table) : + processedEvents table table.darts = List.finRange table.darts := by + simp [processedEvents] + +theorem processedEvents_succ (table : GraphTables.Table) (r : Nat) (h : r < table.darts) : + processedEvents table (r + 1) = processedEvents table r ++ [⟨r, h⟩] := by + unfold processedEvents + rw [List.take_succ_eq_append_getElem (l := List.finRange table.darts) (i := r) + (by simpa using h)] + simp + +theorem processed_append_remaining (table : GraphTables.Table) (r : Nat) : + processedEvents table r ++ remainingEvents table r = List.finRange table.darts := by + exact List.take_append_drop r (List.finRange table.darts) + +@[simp] theorem inputStream_nil (table : GraphTables.Table) : inputStream table [] = [] := rfl + +@[simp] theorem inputStream_cons (table : GraphTables.Table) (e : Fin table.darts) + (events : List (Fin table.darts)) : + inputStream table (e :: events) = + encodeWords (GraphTables.rowWords table.rows[e]) ++ inputStream table events := rfl + +@[simp] theorem inputStream_append (table : GraphTables.Table) + (first rest : List (Fin table.darts)) : + inputStream table (first ++ rest) = inputStream table first ++ inputStream table rest := by + simp only [inputStream, List.flatMap_append] + +@[simp] theorem outputStream_nil (plan : Plan) (table : GraphTables.Table) : + outputStream plan table [] = [] := rfl + +@[simp] theorem outputStream_cons (plan : Plan) (table : GraphTables.Table) + (e : Fin table.darts) (events : List (Fin table.darts)) : + outputStream plan table (e :: events) = + plan.flatMap (Emitter.commandBits (rowOperands table e) (rowRelation table e)) ++ + outputStream plan table events := rfl + +@[simp] theorem outputStream_append (plan : Plan) (table : GraphTables.Table) + (first rest : List (Fin table.darts)) : + outputStream plan table (first ++ rest) = + outputStream plan table first ++ outputStream plan table rest := by + simp only [outputStream, List.flatMap_append] + +theorem inputStream_remaining_cons (table : GraphTables.Table) (r : Nat) + (h : r < table.darts) : + inputStream table (remainingEvents table r) = + encodeWords (GraphTables.rowWords table.rows[(⟨r, h⟩ : Fin table.darts)]) ++ + inputStream table (remainingEvents table (r + 1)) := by + rw [remainingEvents_cons table r h, inputStream_cons] + +theorem outputStream_remaining_cons (plan : Plan) (table : GraphTables.Table) (r : Nat) + (h : r < table.darts) : + outputStream plan table (remainingEvents table r) = + plan.flatMap (Emitter.commandBits (rowOperands table ⟨r, h⟩) + (rowRelation table ⟨r, h⟩)) ++ + outputStream plan table (remainingEvents table (r + 1)) := by + rw [remainingEvents_cons table r h, outputStream_cons] + +theorem outputStream_processed_succ (plan : Plan) (table : GraphTables.Table) (r : Nat) + (h : r < table.darts) : + outputStream plan table (processedEvents table (r + 1)) = + outputStream plan table (processedEvents table r) ++ + plan.flatMap (Emitter.commandBits (rowOperands table ⟨r, h⟩) + (rowRelation table ⟨r, h⟩)) := by + rw [processedEvents_succ table r h, outputStream_append] + simp + +theorem inputStream_split (table : GraphTables.Table) (r : Nat) : + inputStream table (List.finRange table.darts) = + inputStream table (processedEvents table r) ++ + inputStream table (remainingEvents table r) := by + rw [← inputStream_append, processed_append_remaining] + +theorem outputStream_split (plan : Plan) (table : GraphTables.Table) (r : Nat) : + outputStream plan table (List.finRange table.darts) = + outputStream plan table (processedEvents table r) ++ + outputStream plan table (remainingEvents table r) := by + rw [← outputStream_append, processed_append_remaining] + +private theorem encodeWords_flatMap_rows {α : Type} (rows : List α) (words : α → List Nat) : + encodeWords (rows.flatMap words) = rows.flatMap (fun row => encodeWords (words row)) := by + induction rows with + | nil => rfl + | cons row rows ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem rowList_eq_finRange_map (table : GraphTables.Table) : + GraphTables.rowList table = (List.finRange table.darts).map (fun e => table.rows[e]) := by + rw [← List.ofFn_eq_map, ← Vector.toList_ofFn] + change table.rows.toList = (Vector.ofFn (fun i => table.rows[i.val])).toList + rw [Vector.ofFn_getElem] + +theorem inputStream_all (table : GraphTables.Table) : + inputStream table (List.finRange table.darts) = tableRowsBits (genericTable table) := by + rw [tableRowsBits, genericTable_rowList] + erw [List.flatMap_map] + change inputStream table (List.finRange table.darts) = + encodeWords ((GraphTables.rowList table).flatMap + (fun row => GenericGraphTables.rowWords (genericRow row))) + simp only [genericRow_words] + rw [rowList_eq_finRange_map, List.flatMap_map, encodeWords_flatMap_rows] + rfl + +theorem inputStream_remaining_zero (table : GraphTables.Table) : + inputStream table (remainingEvents table 0) = tableRowsBits (genericTable table) := by + rw [remainingEvents_zero, inputStream_all] + +theorem outputStream_accumulator_succ (plan : Plan) (table : GraphTables.Table) + (r : Nat) (h : r < table.darts) (header : List Bool) : + (plan.flatMap (Emitter.commandBits (rowOperands table ⟨r, h⟩) + (rowRelation table ⟨r, h⟩))).reverse ++ + (header ++ outputStream plan table (processedEvents table r)).reverse = + (header ++ outputStream plan table (processedEvents table (r + 1))).reverse := by + rw [outputStream_processed_succ plan table r h] + simp only [List.reverse_append, List.append_assoc] + +end IndependentSetsGames.Foundations.Complexity.FinalCNFMachine.Program + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FinalLabel.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalLabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..20135cfe797c7aa2a45670c7a78de008f28b0aae --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FinalLabel.lean @@ -0,0 +1,167 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Command + +namespace OAI + +namespace IndependentSetsCut.CounterMachine + +section +open Turing +variable {R L : Type} [DecidableEq R] + + theorem advance_simulation (p : L → Instruction R L) (a : Option (Configuration R L)) : + (a.map embed).bind (TM2.step (fun l => (p l).code)) = (advance p a).map embed := by + cases a with + | none => rfl + | some c => exact step_simulation p c + + theorem iterate_simulation (p : L → Instruction R L) (n : ℕ) + (a : Option (Configuration R L)) : + (fun a => a.bind (TM2.step (fun l => (p l).code)))^[n] (a.map embed) = + ((advance p)^[n] a).map embed := by + induction n with + | zero => rfl + | succ n ih => + rw [Function.iterate_succ_apply', ih, advance_simulation, Function.iterate_succ_apply'] + +namespace Command + +abbrev FinalLabel (c : Command R) := c.Label ⊕ Unit + +def finalCode (c : Command R) : c.FinalLabel → Instruction R c.FinalLabel + | .inl l => c.code Sum.inl (.inr ()) l + | .inr _ => .halt + +def initial (input : List Bool) : Data R := + ⟨fun _ => 0, input, [], []⟩ + +noncomputable def finiteMachine [Fintype R] (c : Command R) : FinTM2 := + machine c.finalCode (.inl c.entry) + + theorem finiteMachine_initial [Fintype R] (c : Command R) (input : List Bool) : + initList c.finiteMachine input = embed ⟨initial input, some (.inl c.entry)⟩ := by + unfold initList + congr 1 + funext k + cases k <;> simp [finiteMachine, machine, tapes, initial] + rfl + + noncomputable def machine_run [Fintype R] {c : Command R} {input : List Bool} {out : Data R} {n : ℕ} + (h : Evaluates c (initial input) out n) : + StateTransition.EvalsToInTime c.finiteMachine.step (initList c.finiteMachine input) + (some (embed ⟨out, none⟩)) (n + 1) := by + have hr := trace h c.finalCode Sum.inl (.inr ()) (fun _ => rfl) + have hi := iterate_simulation c.finalCode n (atCfg (.inl c.entry) (initial input)) + have hit : (fun a : Option (Configuration R c.FinalLabel) => advance c.finalCode a)^[n + 1] + (atCfg (.inl c.entry) (initial input)) = some ⟨out, none⟩ := by + rw [Function.iterate_succ_apply', hr] + rfl + refine ⟨⟨n + 1, ?_⟩, le_rfl⟩ + rw [finiteMachine_initial] + change (fun a => a.bind (TM2.step (fun l => (c.finalCode l).code)))^[n + 1] + ((atCfg (.inl c.entry) (initial input)).map embed) = _ + rw [iterate_simulation, hit] + rfl + + theorem finiteMachine_finite_alphabet [Fintype R] (c : Command R) + (k : c.finiteMachine.K) : Finite (c.finiteMachine.Γ k) := inferInstanceAs (Finite Bool) + +end Command +end + +open scoped BigOperators +variable {R : Type} [DecidableEq R] + +namespace Data + +def set (d : Data R) (r : R) (v : ℕ) : Data R := + { d with reg := Function.update d.reg r v } + +@[simp] theorem set_self (d : Data R) (r : R) : d.set r (d.reg r) = d := by + simp [set] + +@[simp] theorem set_set (d : Data R) (r : R) (v w : ℕ) : + (d.set r v).set r w = d.set r w := by simp [set] + +@[simp] theorem set_reg_same (d : Data R) (r : R) (v : ℕ) : + (d.set r v).reg r = v := by simp [set] + +@[simp] theorem set_reg_ne (d : Data R) (r s : R) (v : ℕ) (h : s ≠ r) : + (d.set r v).reg s = d.reg s := by simp [set, h] + + theorem set_comm (d : Data R) (r s : R) (v w : ℕ) (h : r ≠ s) : + (d.set r v).set s w = (d.set s w).set r v := by + simp only [set] + congr 1 + exact Function.update_comm h v w d.reg + +end Data + +namespace Command + +def clear (r : R) : Command R := .loop r .skip + +def move (r s : R) : Command R := .loop r (.inc s) + + theorem clear_evaluates (d : Data R) (r : R) : + Evaluates (clear r) d (d.set r 0) (2 * d.reg r + 1) := by + generalize hn : d.reg r = n + induction n generalizing d with + | zero => + have hs : d.set r 0 = d := by rw [← hn, Data.set_self] + simpa [clear, hs] using (Evaluates.loop_zero (b := .skip) hn) + | succ n ih => + have hr : d.reg r ≠ 0 := by omega + have hd : (decData d r).reg r = n := by simp [decData, hn] + have he := ih (decData d r) hd + have hf : (decData d r).set r 0 = d.set r 0 := by simp [decData, Data.set] + have ht : 1 + 1 + (2 * n + 1) = 2 * (n + 1) + 1 := by omega + simpa only [clear, hf, ht] using + (Evaluates.loop_pos hr (Evaluates.skip (decData d r)) he) + + theorem move_evaluates (d : Data R) (r s : R) (hrs : r ≠ s) : + Evaluates (move r s) d ((d.set r 0).set s (d.reg s + d.reg r)) + (2 * d.reg r + 1) := by + generalize hn : d.reg r = n + induction n generalizing d with + | zero => + have hz : d.set r 0 = d := by rw [← hn, Data.set_self] + simpa [move, hz] using (Evaluates.loop_zero (b := .inc s) hn) + | succ n ih => + have hr : d.reg r ≠ 0 := by omega + let e := incData (decData d r) s + have er : e.reg r = n := by simp [e, incData, decData, hrs, hn] + have es : e.reg s = d.reg s + 1 := by simp [e, incData, decData, Ne.symm hrs] + have he := ih e er + have hf : (e.set r 0).set s (e.reg s + n) = + (d.set r 0).set s (d.reg s + (n + 1)) := by + simp only [es] + have hc : e.set r 0 = (d.set r 0).set s (d.reg s + 1) := by + dsimp [e, incData, decData, Data.set] + congr 1 + ext t + by_cases ht : t = r <;> by_cases hs : t = s <;> simp_all + rw [hc, Data.set_set] + congr 1 + omega + have ht : 1 + 1 + (2 * n + 1) = 2 * (n + 1) + 1 := by omega + simpa only [move, hf, ht] using (Evaluates.loop_pos hr (Evaluates.inc (decData d r) s) he) + +def Within (c : Command R) (d e : Data R) (B : ℕ) : Prop := + ∃ n ≤ B, Evaluates c d e n + + theorem Within.seq {a b : Command R} {d e f : Data R} {B C : ℕ} + (h : Within a d e B) (h' : Within b e f C) : Within (.seq a b) d f (B + C) := by + obtain ⟨n, hn, he⟩ := h + obtain ⟨m, hm, hf⟩ := h' + exact ⟨n + m, Nat.add_le_add hn hm, Evaluates.seq he hf⟩ + + theorem Within.mono {c : Command R} {d e : Data R} {B C : ℕ} + (h : Within c d e B) (hBC : B ≤ C) : Within c d e C := by + obtain ⟨n, hn, he⟩ := h + exact ⟨n, hn.trans hBC, he⟩ + +end Command +end IndependentSetsCut.CounterMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/FramedLen.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/FramedLen.lean new file mode 100644 index 0000000000000000000000000000000000000000..a28dcabb7c46795293c261881f4a6a5231bb26f6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/FramedLen.lean @@ -0,0 +1,151 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.BitValue + +namespace OAI + +namespace IndependentSetsCut.CounterMachine +open scoped BigOperators +namespace Expr + +def framedLen (n : Expr) : Expr := .add (.mul (.const 2) (size n)) (.const 1) +def framedBit (n i : Expr) : Expr := cond (lt i (.mul (.const 2) (size n))) + (cond (equal (remainder i (.const 2)) (.const 0)) (.const 1) + (digit n (quotient i (.const 2)))) (.const 0) + +@[simp] theorem framedLen_eval (n : Expr) (input : List Bool) (args : ℕ → ℕ) : + (framedLen n).eval input args = 2*(n.eval input args).size+1 := by + simp [framedLen, eval] + + theorem framedBit_eval (n i : Expr) (input : List Bool) (args : ℕ → ℕ) : + (framedBit n i).eval input args = + if i.eval input args < 2*(n.eval input args).size then + if i.eval input args % 2 = 0 then 1 else n.eval input args / 2^(i.eval input args/2) % 2 + else 0 := by + simp only [framedBit, cond_eval, lt_eval, eval, equal_eval, remainder_eval, size_eval] + by_cases hi : i.eval input args < 2*(n.eval input args).size + · simp only [hi, ↓reduceIte] + by_cases h2 : i.eval input args % 2 = 0 + · simp [h2] + · simp only [h2, ↓reduceIte] + have hsmall : (quotient i (.const 2)).eval input args < (n.eval input args).size := by + simp only [quotient_eval, eval]; omega + simpa [quotient_eval, eval] using digit_eval n (quotient i (.const 2)) input args hsmall + · simp [hi] +end Expr + +def frame : List Bool → List Bool + | [] => [false] + | b::s => true::b::frame s + +@[simp] theorem frame_length (s : List Bool) : (frame s).length = 2*s.length+1 := by + induction s with + | nil => rfl + | cons b s ih => simp [frame, ih]; omega + + theorem frame_get (s : List Bool) (i : ℕ) : + ((frame s)[i]?).getD false = + if i<2*s.length then if i%2=0 then true else (s[i/2]?).getD false else false := by + induction s generalizing i with + | nil => simp [frame] + | cons b s ih => + rcases i with _|_ | i + · simp [frame] + · simp [frame]; omega + · simp only [frame, List.getElem?_cons_succ, ih, List.length_cons] + have hdiv : (i+1+1)/2 = i/2+1 := by omega + have hmod : (i+1+1)%2 = i%2 := by omega + have hlt : i+1+1 < 2*(s.length+1) ↔ i<2*s.length := by omega + simp only [hdiv,hmod,hlt,List.getElem?_cons_succ] + + theorem frame_bits_get (n i : ℕ) : + ((frame n.bits)[i]?).getD false = + decide ((if i<2*n.size then if i%2=0 then 1 else n/2^(i/2)%2 else 0 : ℕ) ≠ 0) := by + rw [frame_get, Nat.size_eq_bits_len] + by_cases hi : i<2*n.size <;> by_cases h2 : i%2=0 <;> simp only [hi,h2,↓reduceIte] + · rfl + · change n.bits.getI (i/2) = _ + rw [← Nat.testBit_eq_inth, Nat.testBit_eq_decide_div_mod_eq] + simp only [Nat.mod_two_ne_zero] + · rfl + · rfl + +end IndependentSetsCut.CounterMachine + +namespace IndependentSetsCut.CounterMachine.Expr + +section +open scoped BigOperators +open Finset +attribute [local instance] Classical.propDecidable + +def listSum {I : Type} (l : List I) (f : I → Expr) : Expr := + l.foldr (fun i s => .add (f i) s) (.const 0) +@[simp] theorem listSum_eval {I : Type} (l : List I) (f : I → Expr) + (input : List Bool) (args : ℕ → ℕ) : + (listSum l f).eval input args = (l.map (fun i => (f i).eval input args)).sum := by + induction l with + | nil => rfl + | cons i l ih => + change (f i).eval input args + (listSum l f).eval input args = _ + simp [ih] + +noncomputable def finiteSum {I : Type} [Fintype I] (f : I → Expr) : Expr := + listSum Finset.univ.toList f +@[simp] theorem finiteSum_eval {I : Type} [Fintype I] (f : I → Expr) + (input : List Bool) (args : ℕ → ℕ) : + (finiteSum f).eval input args = ∑ i, (f i).eval input args := by + simp [finiteSum] + +def least (bound predicate : Expr) : Expr := + .sum bound (.mul (.arg 0) (.mul (positive predicate) + (.zero (.sum (.arg 0) (positive (predicate.rename (fun + | 0 => 0 + | j+1 => j+2))))))) + + theorem least_eval (bound predicate : Expr) (input : List Bool) (args : ℕ → ℕ) : + (least bound predicate).eval input args = + ∑ i ∈ range (bound.eval input args), + if predicate.eval input (bind args i) ≠ 0 ∧ + ∀ j < i, predicate.eval input (bind args j) = 0 then i else 0 := by + have hb (i j : ℕ) : (fun k => bind (bind args i) j (match k with + | 0 => 0 + | k+1 => k+2)) = bind args j := by + funext k; cases k <;> rfl + simp only [least, eval, positive_eval, rename_eval, hb] + apply sum_congr rfl + intro i hi + have hz : (∑ j ∈ range i, + if predicate.eval input (bind args j) ≠ 0 then (1:ℕ) else 0) = 0 ↔ + ∀ j < i, predicate.eval input (bind args j)=0 := by + simp only [sum_eq_zero_iff_of_nonneg (fun _ _ => Nat.zero_le _), mem_range] + simp + change i * ((if predicate.eval input (bind args i) ≠ 0 then 1 else 0) * + (if (∑ j ∈ range i, if predicate.eval input (bind args j) ≠ 0 then (1:ℕ) else 0)=0 then 1 else 0)) = _ + simp only [hz] + rw [indicator_and] + split_ifs <;> simp + +end + +open scoped BigOperators +open Finset +attribute [local instance] Classical.propDecidable + +theorem least_eq (bound predicate : Expr) (input : List Bool) (args : ℕ → ℕ) (k : ℕ) + (hk : k < bound.eval input args) + (hp : predicate.eval input (bind args k) ≠ 0) + (he : ∀ j < k, predicate.eval input (bind args j) = 0) : + (least bound predicate).eval input args = k := by + rw [least_eval, sum_eq_single_of_mem k (mem_range.mpr hk)] + · exact ite_eq_left ⟨hp, he⟩ + · intro j hj hne + by_cases h : j < k + · simp [he j h] + · have hkj : k < j := by omega + split_ifs with hgood + · exact False.elim (hp (hgood.2 k hkj)) + · rfl + +end IndependentSetsCut.CounterMachine.Expr + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterFinish.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterFinish.lean new file mode 100644 index 0000000000000000000000000000000000000000..2034add2d4a36ef1483a262675affcc63e8d7d3c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterFinish.lean @@ -0,0 +1,164 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.GraphCounterModel + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.GraphCounterFinish + +open Turing GraphCounterModel + +def extraTapes (rest original : List Bool) : ExtraTape → List Bool + | .input => rest + | .archive => original + | _ => [] + +def frame (input archive counter reversed output : List Bool) : Tape → List Bool + | .inl i => if i = 2 then counter else [] + | .inr .input => input + | .inr .archive => archive + | .inr .scratch => reversed + | .inr .output => output + +theorem trace_trans {α : Type*} (f : α → α) {a b : Nat} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem start_eq (counter rest original : List Bool) : + clockConfiguration (extraTapes rest original) none + (haltList MachineLogCounter.machine counter) = + ⟨some (.inr .clearInput), initialState, frame rest original counter [] []⟩ := by + rw [MachineLogCounter.haltList_eq] + unfold clockConfiguration + congr 1 + funext tape + cases tape with + | inl i => fin_cases i <;> simp [clockTapes, frame, MachineLogCounter.configuration, + MachineLogCounter.rawTapes] + | inr k => cases k <;> rfl + +theorem finish_eq (word : List Bool) : + (⟨none, initialState, frame [] [] [] [] word⟩ : TM2.Cfg Alphabet Label State) = + haltList machine word := by + unfold haltList + congr 1 + funext tape + cases tape with + | inl i => simp [machine, frame] + | inr k => + cases k <;> simp [machine, frame] + rfl + +theorem drainTrace (rest original counter : List Bool) : + (MachineComposition.advance (TM2.step program))^[rest.length + 1] + (some ⟨some (.inr .clearInput), initialState, frame rest original counter [] []⟩) = + some ⟨some (.inr .clockCopy), initialState, frame [] original counter [] []⟩ := by + have h := (MachineDrain.drainInTime (Sum.inr ExtraTape.input) (Sum.inr ExtraLabel.clearInput) + (some (.inr .clockCopy)) program rfl (frame rest original counter [] []) + MachineLogCounter.initialState none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[rest.length + 1] + (some ⟨some (.inr .clearInput), initialState, frame rest original counter [] []⟩) = _ at h + have update : Function.update (frame rest original counter [] []) (.inr .input) [] = + frame [] original counter [] [] := by + funext tape + cases tape with + | inl i => simp [frame] + | inr k => cases k <;> simp [frame] + simpa only [update, initialState] using h + +theorem clockCopyTrace (original counter : List Bool) : + (MachineComposition.advance (TM2.step program))^[counter.length + 1] + (some ⟨some (.inr .clockCopy), initialState, frame [] original counter [] []⟩) = + some ⟨some (.inr .archiveCopy), initialState, frame [] original [] counter.reverse []⟩ := by + have h := (Reduction.MachineTransfer.transferAtInTime (Sum.inl (2 : Fin 3)) + (Sum.inr ExtraTape.scratch) (by decide) id false (.inr .clockCopy) + (some (.inr .archiveCopy)) program rfl (frame [] original counter [] []) + MachineLogCounter.initialState none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[counter.length + 1] + (some ⟨some (.inr .clockCopy), initialState, frame [] original counter [] []⟩) = _ at h + have update : Reduction.MachineTransfer.tapesAt (Sum.inl (2 : Fin 3)) + (Sum.inr ExtraTape.scratch) (frame [] original counter [] []) [] + ((frame [] original counter [] [] (.inl 2)).reverse.map id ++ + frame [] original counter [] [] (.inr .scratch)) = + frame [] original [] counter.reverse [] := by + funext tape + cases tape with + | inl i => fin_cases i <;> simp [Reduction.MachineTransfer.tapesAt, frame] + | inr k => cases k <;> simp [Reduction.MachineTransfer.tapesAt, frame] + simpa only [update, initialState] using h + +theorem archiveCopyTrace (original counter : List Bool) : + (MachineComposition.advance (TM2.step program))^[original.length + 1] + (some ⟨some (.inr .archiveCopy), initialState, frame [] original [] counter.reverse []⟩) = + some ⟨some (.inr .finalReverse), initialState, + frame [] [] [] (original.reverse ++ counter.reverse) []⟩ := by + have h := (Reduction.MachineTransfer.transferAtInTime (Sum.inr ExtraTape.archive) + (Sum.inr ExtraTape.scratch) (by decide) id false (.inr .archiveCopy) + (some (.inr .finalReverse)) program rfl (frame [] original [] counter.reverse []) + MachineLogCounter.initialState none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[original.length + 1] + (some ⟨some (.inr .archiveCopy), initialState, frame [] original [] counter.reverse []⟩) = _ at h + have update : Reduction.MachineTransfer.tapesAt (Sum.inr ExtraTape.archive) + (Sum.inr ExtraTape.scratch) (frame [] original [] counter.reverse []) [] + ((frame [] original [] counter.reverse [] (.inr .archive)).reverse.map id ++ + frame [] original [] counter.reverse [] (.inr .scratch)) = + frame [] [] [] (original.reverse ++ counter.reverse) [] := by + funext tape + cases tape with + | inl i => simp [Reduction.MachineTransfer.tapesAt, frame] + | inr k => cases k <;> simp [Reduction.MachineTransfer.tapesAt, frame] + simpa only [update, initialState] using h + +theorem reverseTrace (original counter : List Bool) : + (MachineComposition.advance (TM2.step program))^[original.length + counter.length + 1] + (some ⟨some (.inr .finalReverse), initialState, + frame [] [] [] (original.reverse ++ counter.reverse) []⟩) = + some (haltList machine (counter ++ original)) := by + have h := (Reduction.MachineTransfer.transferAtInTime (Sum.inr ExtraTape.scratch) + (Sum.inr ExtraTape.output) (by decide) id false (.inr .finalReverse) none program rfl + (frame [] [] [] (original.reverse ++ counter.reverse) []) MachineLogCounter.initialState none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[ + (original.reverse ++ counter.reverse).length + 1] + (some ⟨some (.inr .finalReverse), initialState, + frame [] [] [] (original.reverse ++ counter.reverse) []⟩) = _ at h + have update : Reduction.MachineTransfer.tapesAt (Sum.inr ExtraTape.scratch) + (Sum.inr ExtraTape.output) (frame [] [] [] (original.reverse ++ counter.reverse) []) [] + ((frame [] [] [] (original.reverse ++ counter.reverse) [] (.inr .scratch)).reverse.map id ++ + frame [] [] [] (original.reverse ++ counter.reverse) [] (.inr .output)) = + frame [] [] [] [] (counter ++ original) := by + funext tape + cases tape with + | inl i => simp [Reduction.MachineTransfer.tapesAt, frame] + | inr k => cases k <;> simp [Reduction.MachineTransfer.tapesAt, frame] + rw [update] at h + rw [← finish_eq] + convert h using 1 + simp only [List.length_append, List.length_reverse, initialState] + rfl + +theorem finishTrace (counter rest original : List Bool) : + (MachineComposition.advance (TM2.step program))^[ + rest.length + 2 * counter.length + 2 * original.length + 4] + (some (clockConfiguration (extraTapes rest original) none + (haltList MachineLogCounter.machine counter))) = + some (haltList machine (counter ++ original)) := by + rw [start_eq] + have total := trace_trans _ + (trace_trans _ (trace_trans _ (drainTrace rest original counter) + (clockCopyTrace original counter)) (archiveCopyTrace original counter)) + (reverseTrace original counter) + simpa only [show rest.length + 1 + (counter.length + 1) + (original.length + 1) + + (original.length + counter.length + 1) = + rest.length + 2 * counter.length + 2 * original.length + 4 by omega] using total + +def finishInTime (counter rest original : List Bool) : + StateTransition.EvalsToInTime (TM2.step program) + (clockConfiguration (extraTapes rest original) none (haltList MachineLogCounter.machine counter)) + (some (haltList machine (counter ++ original))) + (rest.length + 2 * counter.length + 2 * original.length + 4) where + steps := rest.length + 2 * counter.length + 2 * original.length + 4 + evals_in_steps := finishTrace counter rest original + steps_le_m := le_rfl + +end IndependentSetsGames.Foundations.Complexity.GraphCounterFinish + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterModel.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..7681a185521537d3120ac0b9837ef04ea5871159 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterModel.lean @@ -0,0 +1,151 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain +import OAI.Combinatorics.IndependentSets.Machines.MachineLogCounter + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.GraphCounterModel + +open Turing + +inductive ExtraTape where + | input | archive | scratch | output + deriving DecidableEq + +instance : Fintype ExtraTape where + elems := {.input, .archive, .scratch, .output} + complete tape := by cases tape <;> simp + +inductive ExtraLabel where + | copyFirst | copySecond | seed | headerFirst | headerSecond + | clearInput | clockCopy | archiveCopy | finalReverse + deriving DecidableEq + +instance : Fintype ExtraLabel where + elems := {.copyFirst, .copySecond, .seed, .headerFirst, .headerSecond, + .clearInput, .clockCopy, .archiveCopy, .finalReverse} + complete label := by cases label <;> simp + +abbrev Tape := Fin 3 ⊕ ExtraTape +abbrev Label := Fin 5 ⊕ ExtraLabel +abbrev Alphabet (_ : Tape) := Bool +abbrev State := MachineLogCounter.State × Option Bool + +def initialState : State := (MachineLogCounter.initialState, none) + +def clockLabel : Option (Fin 5) → Option Label + | none => some (.inr .clearInput) + | some l => some (.inl l) + +def clockStatement : TM2.Stmt MachineLogCounter.Alphabet (Fin 5) MachineLogCounter.State → + TM2.Stmt Alphabet Label State + | .push k f next => .push (.inl k) (fun state => f state.1) (clockStatement next) + | .peek k f next => .peek (.inl k) (fun state x => (f state.1 x, state.2)) (clockStatement next) + | .pop k f next => .pop (.inl k) (fun state x => (f state.1 x, state.2)) (clockStatement next) + | .load f next => .load (fun state => (f state.1, state.2)) (clockStatement next) + | .branch f yes no => .branch (fun state => f state.1) (clockStatement yes) (clockStatement no) + | .goto f => .goto (fun state => .inl (f state.1)) + | .halt => .goto (fun _ => .inr .clearInput) + +def readHeader (again next : Label) : TM2.Stmt Alphabet Label State := + .pop (.inr .input) (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.push (.inl 0) (fun _ => true) (.goto fun _ => again)) + (.load (fun state => (state.1, none)) (.goto fun _ => next))) + +def program : Label → TM2.Stmt Alphabet Label State + | .inl l => clockStatement (MachineLogCounter.program l) + | .inr .copyFirst => Reduction.MachineTransfer.loopAt (.inr .input) (.inr .scratch) + id false (.inr .copyFirst) (some (.inr .copySecond)) + | .inr .copySecond => MachineCopy.forkLoop (.inr .scratch) (.inr .input) (.inr .archive) + false (.inr .copySecond) (some (.inr .seed)) + | .inr .seed => .push (.inl 0) (fun _ => false) (.goto fun _ => .inr .headerFirst) + | .inr .headerFirst => readHeader (.inr .headerFirst) (.inr .headerSecond) + | .inr .headerSecond => readHeader (.inr .headerSecond) (.inl 0) + | .inr .clearInput => MachineDrain.drain (.inr .input) (.inr .clearInput) + (some (.inr .clockCopy)) + | .inr .clockCopy => Reduction.MachineTransfer.loopAt (.inl 2) (.inr .scratch) + id false (.inr .clockCopy) (some (.inr .archiveCopy)) + | .inr .archiveCopy => Reduction.MachineTransfer.loopAt (.inr .archive) (.inr .scratch) + id false (.inr .archiveCopy) (some (.inr .finalReverse)) + | .inr .finalReverse => Reduction.MachineTransfer.loopAt (.inr .scratch) (.inr .output) + id false (.inr .finalReverse) none + +def machine : FinTM2 where + K := Tape + k₀ := .inr .input + k₁ := .inr .output + Γ := Alphabet + Λ := Label + main := .inr .copyFirst + σ := State + initialState := initialState + m := program + +def clockTapes (tapes : Fin 3 → List Bool) (extra : ExtraTape → List Bool) : Tape → List Bool + | .inl k => tapes k + | .inr k => extra k + +def clockConfiguration (extra : ExtraTape → List Bool) (register : Option Bool) + (c : TM2.Cfg MachineLogCounter.Alphabet (Fin 5) MachineLogCounter.State) : + TM2.Cfg Alphabet Label State := ⟨clockLabel c.l, (c.var, register), clockTapes c.stk extra⟩ + +theorem clockTapes_update (tapes : Fin 3 → List Bool) (extra : ExtraTape → List Bool) + (k : Fin 3) (word : List Bool) : + clockTapes (Function.update tapes k word) extra = + Function.update (clockTapes tapes extra) (.inl k) word := by + funext tape + cases tape <;> simp [clockTapes, Function.comp_def] + +theorem clockStatement_simulation (extra : ExtraTape → List Bool) (register : Option Bool) + (statement : TM2.Stmt MachineLogCounter.Alphabet (Fin 5) MachineLogCounter.State) + (state : MachineLogCounter.State) (tapes : Fin 3 → List Bool) : + TM2.stepAux (clockStatement statement) (state, register) (clockTapes tapes extra) = + clockConfiguration extra register (TM2.stepAux statement state tapes) := by + induction statement generalizing state tapes with + | push k f next ih => + simp only [clockStatement, TM2.stepAux, clockTapes] + rw [← clockTapes_update] + exact ih state (Function.update tapes k (f state :: tapes k)) + | peek k f next ih => + simpa only [clockStatement, TM2.stepAux, clockTapes] using ih (f state (tapes k).head?) tapes + | pop k f next ih => + simp only [clockStatement, TM2.stepAux, clockTapes] + rw [← clockTapes_update] + exact ih (f state (tapes k).head?) (Function.update tapes k (tapes k).tail) + | load f next ih => + simpa only [clockStatement, TM2.stepAux] using ih (f state) tapes + | branch f yes no ihYes ihNo => + cases h : f state with + | false => simpa only [clockStatement, TM2.stepAux, h, Bool.cond_false] using ihNo state tapes + | true => simpa only [clockStatement, TM2.stepAux, h, Bool.cond_true] using ihYes state tapes + | goto f => rfl + | halt => rfl + +theorem clockStep (extra : ExtraTape → List Bool) (register : Option Bool) + (a b : MachineLogCounter.machine.Cfg) + (h : MachineLogCounter.machine.step a = some b) : + TM2.step program (clockConfiguration extra register a) = + some (clockConfiguration extra register b) := by + cases a with + | mk label state tapes => + cases label with + | none => cases h + | some label => + have hb := Option.some.inj h + subst b + exact congrArg some (clockStatement_simulation extra register + (MachineLogCounter.program label) state tapes) + +def clockInTime (extra : ExtraTape → List Bool) (register : Option Bool) (n : Nat) : + StateTransition.EvalsToInTime (TM2.step program) + (clockConfiguration extra register (initList MachineLogCounter.machine (encodeWord n))) + (some (clockConfiguration extra register + (haltList MachineLogCounter.machine (encodeWord (n.log2 + 1))))) (8 * n + 4) := + MachineComposition.liftExecutionInTime _ _ (clockConfiguration extra register) + (clockStep extra register) (MachineLogCounter.outputsInTime n) + +end IndependentSetsGames.Foundations.Complexity.GraphCounterModel + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterPrefix.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d887f88d8422892d31b1fe8f66f15ab5a5771d3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterPrefix.lean @@ -0,0 +1,258 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Block +import OAI.Combinatorics.IndependentSets.Machines.GraphCounterStart +import OAI.Combinatorics.IndependentSets.Machines.GraphCounterFinish + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.GraphCounterPrefix + +open Turing PCP GraphCounterModel GraphCounterFinish + +def rawOutput (n m : Nat) (rest : List Bool) : List Bool := + encodeWord ((n + m).log2 + 1) ++ (encodeWords [n, m] ++ rest) + +def rawInTime (n m : Nat) (rest : List Bool) : + TM2OutputsInTime machine (encodeWords [n, m] ++ rest) (some (rawOutput n m rest)) + (20 * (encodeWords [n, m] ++ rest).length + 30) := by + let original := encodeWords [n, m] ++ rest + let start := startInTime n m rest + let clock := clockInTime (extraTapes rest original) none (n + m) + let finish := finishInTime (encodeWord ((n + m).log2 + 1)) rest original + have start' : StateTransition.EvalsToInTime (TM2.step program) + (initList machine original) + (some (clockConfiguration (extraTapes rest original) none + (initList MachineLogCounter.machine (encodeWord (n + m))))) + (2 * (original.length + 1) + 1 + (n + 1) + (m + 1)) := start + let first := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ start' clock + let total := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first finish + refine { toEvalsTo := total.toEvalsTo, steps_le_m := ?_ } + have bound := total.steps_le_m + have hlog := Nat.log2_le_self (n + m) + have hlength : original.length = n + m + 2 + rest.length := by + simp only [original, List.length_append, encodeWords, encodeWord_length, List.length_nil] + omega + simp only [encodeWord_length] at bound + change total.steps ≤ 20 * original.length + 30 + omega + +def count (table : GraphTables.Table) : Nat := (table.vertices + table.darts).log2 + 1 + +def output (table : GraphTables.Table) : List Bool := + encodeWord (count table) ++ GraphTables.tableBits table + +def rowsBits (table : GraphTables.Table) : List Bool := + encodeWords ((GraphTables.rowList table).flatMap GraphTables.rowWords) + +theorem tableBits_decomposition (table : GraphTables.Table) : + GraphTables.tableBits table = encodeWords [table.vertices, table.darts] ++ rowsBits table := + encodeWords_append _ _ + +def outputsInTime (table : GraphTables.Table) : + TM2OutputsInTime machine (GraphTables.tableBits table) (some (output table)) + (20 * (GraphTables.tableBits table).length + 30) := by + have run := rawInTime table.vertices table.darts (rowsBits table) + simpa only [rawOutput, output, count, tableBits_decomposition] using run + +noncomputable def computableInPolyTime : + TM2ComputableInPolyTime GraphTables.tableBits id output where + tm := machine + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := 20 * Polynomial.X + 30 + outputsFun table := by + change TM2OutputsInTime machine ((GraphTables.tableBits table).map id) + (some ((output table).map id)) + ((20 * Polynomial.X + 30 : Polynomial Nat).eval (GraphTables.tableBits table).length) + dsimp only [machine, Alphabet] + rw [List.map_id, List.map_id] + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, + Polynomial.eval_X] + exact outputsInTime table + +end IndependentSetsGames.Foundations.Complexity.GraphCounterPrefix + +namespace IndependentSetsGames.Foundations.Complexity.PCPIterationMachine + +open Turing +open MachineCountedLoop + +def rounds (n : Nat) : Nat := n.log2 + 1 + +theorem rounds_le (n : Nat) : rounds n ≤ n + 1 := + Nat.add_le_add_right (Nat.log2_le_self n) 1 + +theorem two_pow_rounds_le (n : Nat) : 2 ^ rounds n ≤ 2 * (n + 1) := by + by_cases hn : n = 0 + · subst n; decide + · have h := Nat.log2_self_le hn + simp only [rounds, pow_succ] + omega + +theorem growth_pow_rounds_le (growth n : Nat) : + growth ^ rounds n ≤ (2 * (n + 1)) ^ growth := by + calc + growth ^ rounds n ≤ (2 ^ growth) ^ rounds n := + Nat.pow_le_pow_left (Nat.le_of_lt (Nat.lt_two_pow_self (n := growth))) _ + _ = (2 ^ rounds n) ^ growth := by simp only [← pow_mul, Nat.mul_comm] + _ ≤ (2 * (n + 1)) ^ growth := Nat.pow_le_pow_left (two_pow_rounds_le n) growth + +def sizeEnvelope (growth n : Nat) : Nat := (n + 1) * (2 * (n + 1)) ^ growth + +theorem semanticSize_geometric (sizes : Nat → Nat) (growth n : Nat) + (initialBound : sizes 0 ≤ n + 1) + (growthBound : ∀ i, i < rounds n → sizes (i + 1) ≤ growth * sizes i) + (i : Nat) (hi : i ≤ rounds n) : sizes i ≤ (n + 1) * growth ^ i := by + induction i with + | zero => simpa only [pow_zero, Nat.mul_one] using initialBound + | succ i ih => + have ilt : i < rounds n := by omega + calc + sizes (i + 1) ≤ growth * sizes i := growthBound i ilt + _ ≤ growth * ((n + 1) * growth ^ i) := + Nat.mul_le_mul_left growth (ih (by omega)) + _ = (n + 1) * growth ^ (i + 1) := by rw [pow_succ]; ac_rfl + +theorem semanticSize_bound (sizes : Nat → Nat) (growth n : Nat) + (growthPositive : 0 < growth) + (initialBound : sizes 0 ≤ n + 1) + (growthBound : ∀ i, i < rounds n → sizes (i + 1) ≤ growth * sizes i) + (i : Nat) (hi : i ≤ rounds n) : sizes i ≤ sizeEnvelope growth n := by + calc + sizes i ≤ (n + 1) * growth ^ i := + semanticSize_geometric sizes growth n initialBound growthBound i hi + _ ≤ (n + 1) * growth ^ rounds n := + Nat.mul_le_mul_left _ (Nat.pow_le_pow_right growthPositive hi) + _ ≤ sizeEnvelope growth n := + Nat.mul_le_mul_left _ (growth_pow_rounds_le growth n) + +noncomputable def sizePolynomial (growth : Nat) : Polynomial Nat := + (Polynomial.X + 1) * (2 * (Polynomial.X + 1)) ^ growth + +@[simp] theorem sizePolynomial_eval (growth n : Nat) : + (sizePolynomial growth).eval n = sizeEnvelope growth n := by + simp [sizePolynomial, sizeEnvelope] + +noncomputable def timePolynomial (growth : Nat) + (encodingSize bodyTime : Polynomial Nat) : Polynomial Nat := + (Polynomial.X + 1) * + ((bodyTime.comp encodingSize).comp (sizePolynomial growth) + 1) + 2 + +@[simp] theorem timePolynomial_eval (growth n : Nat) + (encodingSize bodyTime : Polynomial Nat) : + (timePolynomial growth encodingSize bodyTime).eval n = + (n + 1) * (bodyTime.eval (encodingSize.eval (sizeEnvelope growth n)) + 1) + 2 := by + simp [timePolynomial] + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool +abbrev State (σ : Type) := σ × Option Bool +abbrev Labels (Λ : Type) := Bool ⊕ Λ + +def program (counter : K) (entry : Λ) + (body : Λ → TM2.Stmt (Alphabet (K := K)) (Labels Λ) (State σ)) : + Labels Λ → TM2.Stmt (Alphabet (K := K)) (Labels Λ) (State σ) + | .inl false => MachineUnaryCounter.guard counter (.inr entry) (.inl true) + | .inl true => .pop counter (fun state _ => (state.1, none)) .halt + | .inr label => body label + +omit [DecidableEq K] in +@[simp] theorem program_guard (counter : K) (entry : Λ) + (body : Λ → TM2.Stmt (Alphabet (K := K)) (Labels Λ) (State σ)) : + program counter entry body (.inl false) = + MachineUnaryCounter.guard counter (.inr entry) (.inl true) := rfl + +def machine [Fintype K] [Fintype Λ] [Fintype σ] + (counter output : K) (entry : Λ) (initial : σ) + (body : Λ → TM2.Stmt (Alphabet (K := K)) (Labels Λ) (State σ)) : FinTM2 where + K := K + k₀ := counter + k₁ := output + Γ := Alphabet + Λ := Labels Λ + main := .inl false + σ := State σ + initialState := (initial, none) + m := program counter entry body + +def haltedConfiguration (counter : K) (suffix : List Bool) + (ambient : Nat → σ) (base : Nat → K → List Bool) : + TM2.Cfg (Alphabet (K := K)) (Labels Λ) (State σ) := + ⟨none, (ambient 0, none), Function.update (base 0) counter suffix⟩ + +theorem haltStep (counter : K) (entry : Λ) + (body : Λ → TM2.Stmt (Alphabet (K := K)) (Labels Λ) (State σ)) + (suffix : List Bool) (ambient : Nat → σ) (base : Nat → K → List Bool) : + TM2.step (program counter entry body) + (exitConfiguration counter (.inl true) suffix ambient base) = + some (haltedConfiguration counter suffix ambient base) := by + change some (TM2.stepAux (.pop counter (fun state _ => (state.1, none)) .halt) + (ambient 0, none) (MachineUnaryCounter.counterTapes counter (base 0) 0 suffix)) = _ + simp [TM2.stepAux, MachineUnaryCounter.counterTapes, encodeWord, haltedConfiguration] + +theorem iterationTrace (counter : K) (entry : Λ) + (body : Λ → TM2.Stmt (Alphabet (K := K)) (Labels Λ) (State σ)) + (suffix : List Bool) (ambient : Nat → σ) (register : Nat → Option Bool) + (base : Nat → K → List Bool) (cost : Nat → Nat) (n : Nat) + (bodyTraces : BodyTraces counter (.inl false) (.inr entry) + (program counter entry body) suffix ambient register base cost (rounds n)) : + (MachineComposition.advance (TM2.step (program counter entry body)))^[ + totalSteps cost (rounds n) + 1] + (some (guardConfiguration counter (.inl false) suffix ambient register base (rounds n))) = + some (haltedConfiguration counter suffix ambient base) := by + rw [Function.iterate_succ_apply'] + rw [loopTrace counter (.inl false) (.inr entry) (.inl true) + (program counter entry body) (program_guard counter entry body) suffix + ambient register base cost (rounds n) bodyTraces] + exact haltStep counter entry body suffix ambient base + +theorem bodyCosts_bound (growth n : Nat) (growthPositive : 0 < growth) + (sizes encodedSizes cost : Nat → Nat) (encodingSize bodyTime : Polynomial Nat) + (initialBound : sizes 0 ≤ n + 1) + (growthBound : ∀ i, i < rounds n → sizes (i + 1) ≤ growth * sizes i) + (encodingBound : ∀ r, r < rounds n → + encodedSizes r ≤ encodingSize.eval (sizes (rounds n - (r + 1)))) + (bodyCost : ∀ r, r < rounds n → cost r ≤ bodyTime.eval (encodedSizes r)) : + ∀ r, r < rounds n → + cost r ≤ bodyTime.eval (encodingSize.eval (sizeEnvelope growth n)) := by + intro r hr + have hs := semanticSize_bound sizes growth n growthPositive initialBound growthBound + (rounds n - (r + 1)) (Nat.sub_le _ _) + exact (bodyCost r hr).trans + (MachineComposition.natPolynomial_eval_mono bodyTime + ((encodingBound r hr).trans + (MachineComposition.natPolynomial_eval_mono encodingSize hs))) + +def iterationInTime (counter : K) (entry : Λ) + (body : Λ → TM2.Stmt (Alphabet (K := K)) (Labels Λ) (State σ)) + (suffix : List Bool) (ambient : Nat → σ) (register : Nat → Option Bool) + (base : Nat → K → List Bool) (cost : Nat → Nat) (growth n : Nat) + (growthPositive : 0 < growth) + (bodyTraces : BodyTraces counter (.inl false) (.inr entry) + (program counter entry body) suffix ambient register base cost (rounds n)) + (sizes encodedSizes : Nat → Nat) (encodingSize bodyTime : Polynomial Nat) + (initialBound : sizes 0 ≤ n + 1) + (growthBound : ∀ i, i < rounds n → sizes (i + 1) ≤ growth * sizes i) + (encodingBound : ∀ r, r < rounds n → + encodedSizes r ≤ encodingSize.eval (sizes (rounds n - (r + 1)))) + (bodyCost : ∀ r, r < rounds n → cost r ≤ bodyTime.eval (encodedSizes r)) : + StateTransition.EvalsToInTime (TM2.step (program counter entry body)) + (guardConfiguration counter (.inl false) suffix ambient register base (rounds n)) + (some (haltedConfiguration counter suffix ambient base)) + ((timePolynomial growth encodingSize bodyTime).eval n) where + steps := totalSteps cost (rounds n) + 1 + evals_in_steps := iterationTrace counter entry body suffix ambient register base cost n bodyTraces + steps_le_m := by + rw [timePolynomial_eval] + have h := totalSteps_le cost (rounds n) + (bodyTime.eval (encodingSize.eval (sizeEnvelope growth n))) + (bodyCosts_bound growth n growthPositive sizes encodedSizes cost encodingSize bodyTime + initialBound growthBound encodingBound bodyCost) + have hm := Nat.mul_le_mul_right + (bodyTime.eval (encodingSize.eval (sizeEnvelope growth n)) + 1) (rounds_le n) + omega + +end IndependentSetsGames.Foundations.Complexity.PCPIterationMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterStart.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterStart.lean new file mode 100644 index 0000000000000000000000000000000000000000..841eae090021694507b7dc4fa7cfcbe0db3bfe65 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/GraphCounterStart.lean @@ -0,0 +1,179 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.GraphCounterModel + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.GraphCounterModel + +open Turing + +def startExtra (input archive : List Bool) : ExtraTape → List Bool + | .input => input + | .archive => archive + | _ => [] + +def startMemory (input archive sum : List Bool) : Tape → List Bool + | .inl k => if k = 0 then sum else [] + | .inr k => startExtra input archive k + +theorem startMemory_input_update (input archive sum replacement : List Bool) : + Function.update (startMemory input archive sum) (.inr .input) replacement = + startMemory replacement archive sum := by + funext tape + cases tape with + | inl k => simp [startMemory] + | inr k => cases k <;> simp [startMemory, startExtra] + +theorem startMemory_sum_update (input archive sum replacement : List Bool) : + Function.update (startMemory input archive sum) (.inl 0) replacement = + startMemory input archive replacement := by + funext tape + cases tape with + | inl k => by_cases h : k = 0 <;> simp [startMemory, h] + | inr k => simp [startMemory] + +theorem headerStep_zero (again next : Label) + (atHeader : program again = readHeader again next) + (suffix archive : List Bool) (sum : Nat) + (state : MachineLogCounter.State) (register : Option Bool) : + TM2.step program + ⟨some again, (state, register), startMemory (encodeWord 0 ++ suffix) archive (encodeWord sum)⟩ = + some ⟨some next, (state, none), startMemory suffix archive (encodeWord sum)⟩ := by + change some (TM2.stepAux (program again) _ _) = _ + rw [atHeader] + simp only [readHeader, TM2.stepAux, startMemory, startExtra, encodeWord, + List.replicate_zero, List.nil_append, List.singleton_append, List.head?_cons, + List.tail_cons, Option.getD_some, Bool.cond_false] + rw [startMemory_input_update] + +theorem headerStep_succ (again next : Label) + (atHeader : program again = readHeader again next) + (n sum : Nat) (suffix archive : List Bool) + (state : MachineLogCounter.State) (register : Option Bool) : + TM2.step program + ⟨some again, (state, register), + startMemory (encodeWord (n + 1) ++ suffix) archive (encodeWord sum)⟩ = + some ⟨some again, (state, some true), + startMemory (encodeWord n ++ suffix) archive (encodeWord (sum + 1))⟩ := by + change some (TM2.stepAux (program again) _ _) = _ + rw [atHeader] + simp only [readHeader, TM2.stepAux, startMemory, startExtra, encodeWord, + List.replicate_succ, List.cons_append, List.head?_cons, List.tail_cons, + Option.getD_some, Bool.cond_true] + rw [startMemory_input_update, startMemory_sum_update] + rfl + +theorem headerTrace (again next : Label) + (atHeader : program again = readHeader again next) + (n sum : Nat) (suffix archive : List Bool) + (state : MachineLogCounter.State) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 1] + (some ⟨some again, (state, register), + startMemory (encodeWord n ++ suffix) archive (encodeWord sum)⟩) = + some ⟨some next, (state, none), startMemory suffix archive (encodeWord (n + sum))⟩ := by + induction n generalizing sum register with + | zero => + simpa only [Nat.zero_add, Function.iterate_one, MachineComposition.advance_some] using + headerStep_zero again next atHeader suffix archive sum state register + | succ n ih => + rw [Function.iterate_succ_apply, MachineComposition.advance_some] + rw [headerStep_succ again next atHeader n sum suffix archive state register] + simpa only [Nat.add_assoc, Nat.add_comm 1 sum] using ih (sum + 1) (some true) + +def headerInTime (again next : Label) + (atHeader : program again = readHeader again next) + (n sum : Nat) (suffix archive : List Bool) + (state : MachineLogCounter.State) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some again, (state, register), startMemory (encodeWord n ++ suffix) archive (encodeWord sum)⟩ + (some ⟨some next, (state, none), startMemory suffix archive (encodeWord (n + sum))⟩) + (n + 1) where + steps := n + 1 + evals_in_steps := headerTrace again next atHeader n sum suffix archive state register + steps_le_m := le_rfl + +theorem initialMemory (word : List Bool) : + initList machine word = + ⟨some (.inr .copyFirst), initialState, startMemory word [] []⟩ := by + have ht : (initList machine word).stk = startMemory word [] [] := by + funext tape + cases tape with + | inl k => simp [initList, machine, startMemory] + | inr extra => cases extra <;> rfl + exact congrArg (TM2.Cfg.mk _ _) ht + +theorem clockInitialMemory (word rest : List Bool) (sum : Nat) : + clockConfiguration (startExtra rest word) none + (initList MachineLogCounter.machine (encodeWord sum)) = + ⟨some (.inl 0), initialState, startMemory rest word (encodeWord sum)⟩ := by + have ht : clockTapes (initList MachineLogCounter.machine (encodeWord sum)).stk + (startExtra rest word) = startMemory rest word (encodeWord sum) := by + funext tape + cases tape with + | inl index => fin_cases index <;> rfl + | inr k => rfl + exact congrArg (TM2.Cfg.mk _ _) ht + +def startInTime (n m : Nat) (rest : List Bool) : + StateTransition.EvalsToInTime machine.step + (initList machine (encodeWords [n, m] ++ rest)) + (some (clockConfiguration (startExtra rest (encodeWords [n, m] ++ rest)) none + (initList MachineLogCounter.machine (encodeWord (n + m))))) + (2 * ((encodeWords [n, m] ++ rest).length + 1) + 1 + (n + 1) + (m + 1)) := by + let word := encodeWords [n, m] ++ rest + let b₀ := startMemory word [] [] + let b₁ := startMemory word word [] + let b₂ := startMemory word word (encodeWord 0) + have hc : Function.update b₀ (.inr .archive) (b₀ (.inr .input) ++ b₀ (.inr .archive)) = b₁ := by + funext tape + cases tape with + | inl k => simp [b₀, b₁, startMemory] + | inr k => cases k <;> simp [b₀, b₁, startMemory, startExtra] + let copy := MachineCopy.copyInTime (.inr ExtraTape.input) (.inr ExtraTape.archive) + (.inr ExtraTape.scratch) (by decide) (by decide) (by decide) false + (.inr ExtraLabel.copyFirst) (.inr ExtraLabel.copySecond) (some (.inr ExtraLabel.seed)) + program rfl rfl b₀ rfl MachineLogCounter.initialState none + have copy' : StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.inr .copyFirst), initialState, b₀⟩ + (some ⟨some (.inr .seed), initialState, b₁⟩) (2 * (word.length + 1)) := by + have h := copy + rw [hc] at h + simpa only [initialState, show b₀ (.inr .input) = word from rfl] using h + have seed : StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.inr .seed), initialState, b₁⟩ + (some ⟨some (.inr .headerFirst), initialState, b₂⟩) 1 := by + refine ⟨⟨1, ?_⟩, le_rfl⟩ + change some (TM2.stepAux (program (.inr .seed)) initialState b₁) = _ + simp only [program, TM2.stepAux, b₁, startMemory] + rw [startMemory_sum_update] + rfl + have first := headerInTime (.inr .headerFirst) (.inr .headerSecond) rfl + n 0 (encodeWord m ++ rest) word MachineLogCounter.initialState none + have first' : StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.inr .headerFirst), initialState, b₂⟩ + (some ⟨some (.inr .headerSecond), initialState, + startMemory (encodeWord m ++ rest) word (encodeWord n)⟩) (n + 1) := by + simpa only [b₂, initialState, word, encodeWords, List.append_nil, List.append_assoc, + Nat.add_zero] using first + have second := headerInTime (.inr .headerSecond) (.inl 0) rfl + m n rest word MachineLogCounter.initialState none + have second' : StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.inr .headerSecond), initialState, + startMemory (encodeWord m ++ rest) word (encodeWord n)⟩ + (some ⟨some (.inl 0), initialState, startMemory rest word (encodeWord (n + m))⟩) + (m + 1) := by simpa only [initialState, Nat.add_comm m n] using second + let p₀ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ copy' seed + let p₁ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀ first' + let p := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₁ second' + rw [initialMemory, clockInitialMemory] + exact { + toEvalsTo := p.toEvalsTo + steps_le_m := by + have h := p.steps_le_m + change p.steps ≤ 2 * (word.length + 1) + 1 + (n + 1) + (m + 1) + omega + } + +end IndependentSetsGames.Foundations.Complexity.GraphCounterModel + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/HeaderStates.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/HeaderStates.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c4ae44e32337111b5e848c0ce21f1ea0069ccfe --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/HeaderStates.lean @@ -0,0 +1,435 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularLift +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularLoopWords +import OAI.Combinatorics.IndependentSets.Machines.ComputeTime + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTable +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP +namespace Top + +def headerStates : + (Header.State Unit × (MachineRegularOriginalBody.CoreState × + (MachineRegularOriginalBody.FamilyState × Option Bool))) ≃ State where + toFun p := (((p.2.1, p.1), p.2.2.1), p.2.2.2) + invFun p := (p.1.1.2, (p.1.1.1, (p.1.2, p.2))) + left_inv _ := rfl + right_inv _ := rfl + +def readyState (H : BaseTable) : State := (MachineRegularOriginalBody.readyState H, none) + +inductive CopyPhase | old | owner + deriving DecidableEq + +instance : Fintype CopyPhase where + elems := {.old, .owner} + complete phase := by cases phase <;> simp + +def copySource : CopyPhase → Tape + | .old => coreTape 6 + | .owner => headerTape Header.nTape +def copyTarget : CopyPhase → Tape + | .old => oldFuel + | .owner => ownerFuel + +inductive Label + | header (l : Header.Label) + | oldSeed + | copyFirst (phase : CopyPhase) + | copySecond (phase : CopyPhase) + | oldGuard + | oldBody (l : MachineRegularOriginalBody.Label) + | oldIncrement + | ownerSeed + | ownerGuard + | ownerBody (l : MachineRegularOwnerBody.Label) + | ownerIncrement + | clear (i : Fin 7) + deriving DecidableEq, Fintype + +def copyExit : CopyPhase → Label + | .old => .oldGuard + | .owner => .ownerGuard + +def clearTape : Fin 7 → Tape := + ![coreTape 1, coreTape 2, coreTape 5, coreTape 6, + headerTape Header.nTape, headerTape Header.verticesTape, headerTape Header.dartsTape] + +def clearEntry (k : Nat) : Option Label := + if h : k < 7 then some (.clear ⟨k, h⟩) else none + +def program (H : BaseTable) : Label → TM2.Stmt Alphabet Label State + | .header l => Lift.statement headerTape Label.header (some .oldSeed) headerStates + (Header.program PreprocessingRegularTables.internalDegree l) + | .oldSeed => .push (coreTape 1) (fun _ => false) (.goto fun _ => Label.copyFirst CopyPhase.old) + | .copyFirst phase => Reduction.MachineTransfer.loopAt (copySource phase) scratch id false + (.copyFirst phase) (some (.copySecond phase)) + | .copySecond phase => MachineCopy.forkLoop scratch (copySource phase) (copyTarget phase) false + (.copySecond phase) (some (copyExit phase)) + | .oldGuard => Fuel.guard oldFuel (Label.oldBody MachineRegularOriginalBody.entry) (some Label.ownerSeed) + | .oldBody l => Lift.statement Sum.inl Label.oldBody (some .oldIncrement) (Equiv.refl _) + (MachineRegularOriginalBody.program H l) + | .oldIncrement => Fuel.increment (coreTape 1) Label.oldGuard + | .ownerSeed => .push (coreTape 2) (fun _ => false) + (.push (coreTape 5) (fun _ => false) (.goto fun _ => Label.copyFirst CopyPhase.owner)) + | .ownerGuard => Fuel.guard ownerFuel (.ownerBody MachineRegularOwnerBody.entry) (clearEntry 0) + | .ownerBody l => MachineCloudPadding.Placement.statement ownerTape Label.ownerBody + (some .ownerIncrement) (MachineRegularOwnerBody.program H l) + | .ownerIncrement => Fuel.increment (coreTape 2) Label.ownerGuard + | .clear i => MachineDrain.drain (clearTape i) (.clear i) (clearEntry (i.val + 1)) + +def machine (H : BaseTable) : FinTM2 where + K := Tape + k₀ := coreTape 0 + k₁ := coreTape 8 + Γ _ := Bool + Λ := Label + main := .header .init + σ := State + initialState := readyState H + m := program H + +def frame (data : Data) (header : Header.Tape → List Bool) (counters : Fin 4 → List Bool) : + Tape → List Bool + | .inl k => MachineRegularOriginalBody.frame data k + | .inr (.inl k) => header k + | .inr (.inr i) => counters i + +def cfg (H : BaseTable) (label : Option Label) (data : Data) + (header : Header.Tape → List Bool) (counters : Fin 4 → List Bool) : + TM2.Cfg Alphabet Label State := + ⟨label, readyState H, frame data header counters⟩ + +@[simp] theorem frame_core (data : Data) (header : Header.Tape → List Bool) + (counters : Fin 4 → List Bool) (i : Fin 27) : + frame data header counters (coreTape i) = MachineRegularMetadata.frame data (.inl i) := rfl + +theorem bodyPlacement (data extra : Data) (header : Header.Tape → List Bool) + (counters : Fin 4 → List Bool) : + MachineCloudPadding.Placement.tapes bodyView (MachineRegularOriginalBody.frame data) + (frame extra header counters) = frame data header counters := by + funext j + cases j with + | inl j => rfl + | inr j => cases j <;> rfl + +def headerAux (n N R : List Bool) : Header.Tape → List Bool := fun k => + if k = Header.nTape then n + else if k = Header.verticesTape then N + else if k = Header.dartsTape then R + else [] + +@[simp] theorem headerAux_empty : headerAux [] [] [] = (fun _ => []) := by + funext k + simp [headerAux] + +theorem headerPlacement (data : Data) (t n m N R output : List Bool) + (counters : Fin 4 → List Bool) : + MachineCloudPadding.Placement.tapes headerView + (Header.frame t n [] [] [] m [] [] [] N R [] output) + (frame data (fun _ => []) counters) = + frame { data with table := t, darts := m, output := output } (headerAux n N R) counters := by + funext j + cases j with + | inl j => + cases j with + | inl i => fin_cases i <;> rfl + | inr e => cases e with + | inl e => cases e <;> rfl + | inr e => rfl + | inr j => + cases j with + | inl k => + cases k with + | inl k => + cases k with + | inner k => cases k <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr k => cases k <;> rfl + | inr i => rfl + +def inputData (t : GraphTables.Table) (output : List Bool) : Data where + table := GraphTables.tableBits t + globalIndex := [] + owner := [] + localRank := [] + count := [] + offset := [] + darts := [] + rotor := [] + output := output + padding := [] + level := [] + +def headerData (t : GraphTables.Table) (output : List Bool) : Data := + { inputData t output with darts := encodeWord t.darts } + +def headerStacks (t : GraphTables.Table) : Header.Tape → List Bool := + headerAux (encodeWord t.vertices) (encodeWord (Header.vertexTotal t)) + (encodeWord (Header.dartTotal PreprocessingRegularTables.internalDegree t)) + +theorem headerTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (counters : Fin 4 → List Bool) : + (advance (TM2.step (program H)))^[Header.totalTime PreprocessingRegularTables.internalDegree t output] + (some (cfg H (some (.header .init)) (inputData t output) (fun _ => []) counters)) = + some (cfg H (some .oldSeed) + (headerData t (output ++ Header.headerBits PreprocessingRegularTables.internalDegree t)) + (headerStacks t) counters) := by + have raw := Header.trace PreprocessingRegularTables.internalDegree t output () none + have placed := Lift.trace headerTape headerView headerView_left headerView_right + Label.header (some .oldSeed) headerStates + (MachineRegularInternalRow.coreInitialState PreprocessingRegularTables.internalDegree + MachineRegularOriginalBody.degree_positive (), (MachineRegularFamily.readyState H, none)) + (frame (inputData t output) (fun _ => []) counters) + (Header.program PreprocessingRegularTables.internalDegree) (program H) (fun _ => rfl) + _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, headerPlacement, + headerAux_empty, cfg, readyState, MachineRegularOriginalBody.readyState, headerStates, + Equiv.coe_fn_mk, headerData, inputData, headerStacks] using placed + +def oldData (t : GraphTables.Table) (index : Nat) (output : List Bool) : Data := + { headerData t output with globalIndex := encodeWord index } + +theorem originalData_eq (t : GraphTables.Table) (e : Fin t.darts) (output : List Bool) : + MachineRegularOriginalBody.initialData t e output = oldData t e.val output := rfl + +theorem oldBodyTrace (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) (header : Header.Tape → List Bool) (counters : Fin 4 → List Bool) : + (advance (TM2.step (program H)))^[MachineRegularOriginalBody.totalSteps H t e output] + (some (cfg H (some (Label.oldBody MachineRegularOriginalBody.entry)) + (oldData t e.val output) header counters)) = + some (cfg H (some .oldIncrement) + (oldData t e.val (output ++ MachineRegularOriginalBody.emittedBits H t e)) header counters) := by + have raw := MachineRegularOriginalBody.originalTrace H t e output + have placed := Lift.trace Sum.inl bodyView bodyView_left bodyView_right Label.oldBody + (some .oldIncrement) (Equiv.refl _) none + (frame (oldData t e.val output) header counters) + (MachineRegularOriginalBody.program H) (program H) (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, bodyPlacement, + MachineRegularOriginalBody.cfg, originalData_eq, cfg, readyState, Equiv.refl_apply] using placed + +def counterStacks (old owners dummy work : List Bool) : Fin 4 → List Bool := + ![old, owners, dummy, work] + +@[simp] theorem frame_oldFuel (data : Data) (header : Header.Tape → List Bool) + (old owners dummy work : List Bool) : + frame data header (counterStacks old owners dummy work) oldFuel = old := rfl + +@[simp] theorem frame_ownerFuel (data : Data) (header : Header.Tape → List Bool) + (old owners dummy work : List Bool) : + frame data header (counterStacks old owners dummy work) ownerFuel = owners := rfl + +@[simp] theorem update_frame_oldFuel (data : Data) (header : Header.Tape → List Bool) + (old owners dummy work replacement : List Bool) : + Function.update (frame data header (counterStacks old owners dummy work)) oldFuel replacement = + frame data header (counterStacks replacement owners dummy work) := by + funext j + cases j with + | inl j => rfl + | inr j => cases j with + | inl j => rfl + | inr i => fin_cases i <;> rfl + +@[simp] theorem update_frame_ownerFuel (data : Data) (header : Header.Tape → List Bool) + (old owners dummy work replacement : List Bool) : + Function.update (frame data header (counterStacks old owners dummy work)) ownerFuel replacement = + frame data header (counterStacks old replacement dummy work) := by + funext j + cases j with + | inl j => rfl + | inr j => cases j with + | inl j => rfl + | inr i => fin_cases i <;> rfl + +@[simp] theorem update_frame_global (data : Data) (header : Header.Tape → List Bool) + (counters : Fin 4 → List Bool) (replacement : List Bool) : + Function.update (frame data header counters) (coreTape 1) replacement = + frame { data with globalIndex := replacement } header counters := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> rfl + | inr e => cases e with + | inl e => cases e <;> rfl + | inr e => rfl + | inr j => cases j <;> rfl + +@[simp] theorem update_frame_owner (data : Data) (header : Header.Tape → List Bool) + (counters : Fin 4 → List Bool) (replacement : List Bool) : + Function.update (frame data header counters) (coreTape 2) replacement = + frame { data with owner := replacement } header counters := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> rfl + | inr e => cases e with + | inl e => cases e <;> rfl + | inr e => rfl + | inr j => cases j <;> rfl + +theorem oldGuardStep (H : BaseTable) (data : Data) (header : Header.Tape → List Bool) + (remaining : Nat) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some .oldGuard) data header + (counterStacks (encodeWord (remaining + 1)) [] [] []))) = + some (cfg H (some (Label.oldBody MachineRegularOriginalBody.entry)) data header + (counterStacks (encodeWord remaining) [] [] [])) := by + change some (TM2.stepAux (Fuel.guard oldFuel (Label.oldBody MachineRegularOriginalBody.entry) + (some Label.ownerSeed)) (readyState H) _) = _ + simp only [Fuel.guard, TM2.stepAux, frame_oldFuel, encodeWord, List.replicate_succ, + List.cons_append, List.head?_cons, List.tail_cons, Option.getD_some, + Bool.cond_true, update_frame_oldFuel] + rfl + +theorem oldGuardExit (H : BaseTable) (data : Data) (header : Header.Tape → List Bool) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some .oldGuard) data header (counterStacks (encodeWord 0) [] [] []))) = + some (cfg H (some Label.ownerSeed) data header (counterStacks [] [] [] [])) := by + change some (TM2.stepAux (Fuel.guard oldFuel (Label.oldBody MachineRegularOriginalBody.entry) + (some Label.ownerSeed)) (readyState H) _) = _ + simp only [Fuel.guard, TM2.stepAux, frame_oldFuel, encodeWord, List.replicate_zero, + List.nil_append, List.head?_cons, List.tail_cons, Option.getD_some, + Bool.cond_false, update_frame_oldFuel] + rfl + +theorem oldIncrementStep (H : BaseTable) (t : GraphTables.Table) (index : Nat) + (output : List Bool) (header : Header.Tape → List Bool) (counters : Fin 4 → List Bool) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some .oldIncrement) (oldData t index output) header counters)) = + some (cfg H (some .oldGuard) (oldData t (index + 1) output) header counters) := by + change some (TM2.stepAux (Fuel.increment (coreTape 1) Label.oldGuard) + (readyState H) (frame (oldData t index output) header counters)) = _ + simp only [Fuel.increment, TM2.stepAux, frame_core] + change some (⟨some Label.oldGuard, readyState H, + Function.update (frame (oldData t index output) header counters) (coreTape 1) + (true :: encodeWord index)⟩ : TM2.Cfg (fun _ : Tape => Bool) Label State) = _ + rw [update_frame_global] + simp only [cfg, oldData, encodeWord, List.replicate_succ, List.cons_append] + +def oldPrefix (H : BaseTable) (t : GraphTables.Table) (k : Nat) : List Bool := + PreprocessingRegularLoopWords.blocksPrefix (MachineRegularOriginalBody.emittedBits H t) k + +noncomputable def oldElapsed (H : BaseTable) (t : GraphTables.Table) (output : List Bool) : Nat → Nat + | 0 => 0 + | k + 1 => oldElapsed H t output k + + if h : k < t.darts then + 1 + MachineRegularOriginalBody.totalSteps H t ⟨k,h⟩ (output ++ oldPrefix H t k) + 1 + else 0 + +theorem joinTrace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +theorem oldPrefixTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) (k : Nat) : k ≤ t.darts → + (advance (TM2.step (program H)))^[oldElapsed H t output k] + (some (cfg H (some .oldGuard) (oldData t 0 output) header + (counterStacks (encodeWord t.darts) [] [] []))) = + some (cfg H (some .oldGuard) (oldData t k (output ++ oldPrefix H t k)) header + (counterStacks (encodeWord (t.darts-k)) [] [] [])) := by + induction k with + | zero => + intro _ + simp [oldElapsed, oldPrefix] + | succ k ih => + intro hk + have hlt : k < t.darts := by omega + have hremaining : t.darts-k = (t.darts-(k+1))+1 := by omega + have previous := ih (by omega) + have guard := oldGuardStep H (oldData t k (output ++ oldPrefix H t k)) header + (t.darts-(k+1)) + rw [← hremaining] at guard + have body := oldBodyTrace H t ⟨k,hlt⟩ (output ++ oldPrefix H t k) header + (counterStacks (encodeWord (t.darts-(k+1))) [] [] []) + have increment := oldIncrementStep H t k + ((output ++ oldPrefix H t k) ++ MachineRegularOriginalBody.emittedBits H t ⟨k,hlt⟩) + header (counterStacks (encodeWord (t.darts-(k+1))) [] [] []) + have combined := joinTrace (joinTrace (joinTrace previous guard) body) increment + have bits := PreprocessingRegularLoopWords.blocksPrefix_succ + (MachineRegularOriginalBody.emittedBits H t) k hlt + change oldPrefix H t (k+1) = oldPrefix H t k ++ + MachineRegularOriginalBody.emittedBits H t ⟨k,hlt⟩ at bits + simpa only [oldElapsed, dite_eq_left hlt, bits, List.append_assoc, Nat.add_assoc] using combined + +theorem oldLoopTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) : + (advance (TM2.step (program H)))^[oldElapsed H t output t.darts + 1] + (some (cfg H (some .oldGuard) (oldData t 0 output) header + (counterStacks (encodeWord t.darts) [] [] []))) = + some (cfg H (some Label.ownerSeed) + (oldData t t.darts (output ++ oldPrefix H t t.darts)) header + (counterStacks [] [] [] [])) := by + have prefixRun := oldPrefixTrace H t output header t.darts (Nat.le_refl _) + simp only [Nat.sub_self] at prefixRun + exact joinTrace prefixRun (oldGuardExit H _ header) + +@[simp] theorem frame_scratch (data : Data) (header : Header.Tape → List Bool) + (old owners dummy work : List Bool) : + frame data header (counterStacks old owners dummy work) scratch = work := rfl + +@[simp] theorem frame_darts (data : Data) (header : Header.Tape → List Bool) + (counters : Fin 4 → List Bool) : frame data header counters (coreTape 6) = data.darts := rfl + +@[simp] theorem frame_header_n (data : Data) (n N R : List Bool) + (counters : Fin 4 → List Bool) : + frame data (headerAux n N R) counters (headerTape Header.nTape) = n := rfl + +theorem oldSeedStep (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) (counters : Fin 4 → List Bool) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some .oldSeed) (headerData t output) header counters)) = + some (cfg H (some (.copyFirst .old)) (oldData t 0 output) header counters) := by + change some (TM2.stepAux (.push (coreTape 1) (fun _ => false) + (.goto fun _ => Label.copyFirst CopyPhase.old)) (readyState H) (frame (headerData t output) header counters)) = _ + change some (⟨some (Label.copyFirst CopyPhase.old), readyState H, + Function.update (frame (headerData t output) header counters) (coreTape 1) [false]⟩ : + TM2.Cfg (fun _ : Tape => Bool) Label State) = _ + rw [update_frame_global] + rfl + +theorem copyOldTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) : + (advance (TM2.step (program H)))^[2*(t.darts+2)] + (some (cfg H (some (.copyFirst .old)) (oldData t 0 output) header + (counterStacks [] [] [] []))) = + some (cfg H (some .oldGuard) (oldData t 0 output) header + (counterStacks (encodeWord t.darts) [] [] [])) := by + have h := MachineCopy.copyTrace (coreTape 6) oldFuel scratch + (by decide) (by decide) (by decide) false (.copyFirst .old) (.copySecond .old) + (some .oldGuard) (program H) rfl rfl + (frame (oldData t 0 output) header (counterStacks [] [] [] [])) rfl + (MachineRegularOriginalBody.readyState H) none + simpa only [frame_darts, oldData, headerData, inputData, encodeWord_length, + frame_oldFuel, List.append_nil, update_frame_oldFuel, cfg, readyState, Nat.add_assoc] using h + +theorem oldStageTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) : + (advance (TM2.step (program H)))^[1+2*(t.darts+2)+(oldElapsed H t output t.darts+1)] + (some (cfg H (some .oldSeed) (headerData t output) header (counterStacks [] [] [] []))) = + some (cfg H (some Label.ownerSeed) + (oldData t t.darts (output ++ oldPrefix H t t.darts)) header + (counterStacks [] [] [] [])) := + joinTrace (joinTrace (oldSeedStep H t output header _) (copyOldTrace H t output header)) + (oldLoopTrace H t output header) + +@[simp] theorem update_frame_offset (data : Data) (header : Header.Tape → List Bool) + (counters : Fin 4 → List Bool) (replacement : List Bool) : + Function.update (frame data header counters) (coreTape 5) replacement = + frame { data with offset := replacement } header counters := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> rfl + | inr e => cases e with + | inl e => cases e <;> rfl + | inr e => rfl + | inr j => cases j <;> rfl + +end Top +end IndependentSetsGames.Foundations.Complexity.MachineRegularTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Initialization.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Initialization.lean new file mode 100644 index 0000000000000000000000000000000000000000..ead126666fda28e33725cf25c920452ed2478814 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Initialization.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Driver + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Initialization + +open Turing +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel + +variable {q : Nat} + +def inputTapes (input : GenericGraphTables.Table q) : Tape → List Bool + | .original => GenericGraphTables.tableBits input + | _ => [] + +def rowsBits (input : GenericGraphTables.Table q) : List Bool := + encodeWords ((GenericGraphTables.rowList input).flatMap GenericGraphTables.rowWords) + +def headerBits (input : GenericGraphTables.Table q) : List Bool := + encodeWords [Enumeration.vertexCount input.vertices input.darts q, + Enumeration.dartCount input.darts q] + +def setupTapes (input : GenericGraphTables.Table q) : Tape → List Bool + | .original => GenericGraphTables.tableBits input + | .cursor => rowsBits input + | .vertices => encodeWord input.vertices + | .darts | .counter => encodeWord input.darts + | .edge => encodeWord 0 + | _ => [] + +def loopTapes (input : GenericGraphTables.Table q) : Tape → List Bool + | .original => GenericGraphTables.tableBits input + | .cursor => rowsBits input + | .vertices => encodeWord input.vertices + | .darts | .counter => encodeWord input.darts + | .edge => encodeWord 0 + | .reversed => (headerBits input).reverse + | _ => [] + +def loopStart (input : GenericGraphTables.Table q) : + TM2.Cfg Alphabet (Driver.Label q) (State q) := + ⟨some .guard, initial q, loopTapes input⟩ + +theorem setupResult_eq (input : GenericGraphTables.Table q) : + Setup.resultTapes setupPorts (inputTapes input) input.vertices input.darts (rowsBits input) = + setupTapes input := by + funext tape + cases tape <;> simp [Setup.resultTapes, setupPorts, inputTapes, setupTapes] + +theorem headerResult_eq (input : GenericGraphTables.Table q) : + Emitter.resultTapes Tape.reversed (setupTapes input) (headerBits input) = loopTapes input := by + funext tape + cases tape <;> simp [Emitter.resultTapes, setupTapes, loopTapes] + +theorem machineInitial_eq (input : GenericGraphTables.Table q) : + initList (Driver.machine q) (GenericGraphTables.tableBits input) = + (⟨some (.setup .copyFirst), initial q, inputTapes input⟩ : + TM2.Cfg Alphabet (Driver.Label q) (State q)) := by + change (⟨some (.setup .copyFirst), initial q, _⟩ : + TM2.Cfg Alphabet (Driver.Label q) (State q)) = _ + congr 1 + funext tape + cases tape <;> rfl + +def setupInTime (input : GenericGraphTables.Table q) : + StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + (initList (Driver.machine q) (GenericGraphTables.tableBits input)) + (some ⟨some (Driver.headerEntry q), initial q, setupTapes input⟩) + (6 * (GenericGraphTables.tableBits input).length + 11) := by + have initialized : ∀ i : Fin 7, inputTapes input (setupPorts i) = + if i = 0 then GenericGraphTables.tableBits input else [] := by + intro i + fin_cases i <;> rfl + have run := Setup.tableSetupInTime setupPorts setupPorts_injective Driver.Label.setup + (some (Driver.headerEntry q)) (Driver.program q) (Driver.program_setup q) + (inputTapes input) input initialized (initial q).1 none + have initialState : ((initial q).1, (none : Option Bool)) = initial q := rfl + have result := setupResult_eq input + unfold rowsBits at result + rw [initialState, result] at run + rw [machineInitial_eq] + exact run + +private theorem headerView_at (label : Emitter.Label (Driver.headerPlan q).length + (Addresses.fieldBound q)) : + (MachineControl.program (Equiv.refl (Driver.Label q)) (emitterEquiv q).symm + (Driver.program q)) (.header label) = + Emitter.statement (Emitter.listCommands (Driver.headerPlan q)) headerSources + Tape.scratch Tape.reversed Driver.Label.header (some .guard) label := by + change MachineControl.statement id (emitterEquiv q).symm + (MachineControl.statement id (emitterEquiv q) _) = _ + exact MachineFieldProfile.statement_roundtrip (emitterEquiv q).symm _ + +def headerInTime (input : GenericGraphTables.Table q) : + StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some (Driver.headerEntry q), initial q, setupTapes input⟩ + (some (loopStart input)) + (7 * (3 * ((GenericGraphTables.tableBits input).length + 1) + 3) + 1) := by + let view := MachineControl.program (Equiv.refl (Driver.Label q)) (emitterEquiv q).symm + (Driver.program q) + have sourceScratch : ∀ i : Fin 2, headerSources i ≠ Tape.scratch := by + intro i + fin_cases i <;> decide + have sourceOutput : ∀ i : Fin 2, headerSources i ≠ Tape.reversed := by + intro i + fin_cases i <;> decide + have operands : ∀ i : Fin 2, setupTapes input (headerSources i) = + encodeWord (![input.vertices, input.darts] i) := by + intro i + fin_cases i <;> rfl + have run := EmitRows.headerInTime q input.vertices input.darts headerSources + Tape.scratch Tape.reversed sourceScratch sourceOutput (by decide) + Driver.Label.header (some .guard) view headerView_at + (setupTapes input) operands (by rfl) (initial q).1 + (GenericGraphTables.tableBits input).length + (GenericGraphTables.vertices_le_tableBits_length input) + (GenericGraphTables.darts_le_tableBits_length input) + have restored : MachineControl.program (Equiv.refl (Driver.Label q)) (emitterEquiv q) view = + Driver.program q := by + funext label + exact MachineFieldProfile.statement_roundtrip (emitterEquiv q) (Driver.program q label) + have transported := transportInTime (emitterEquiv q) view run + rw [restored] at transported + change StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some (Driver.headerEntry q), initial q, setupTapes input⟩ + (some ⟨some .guard, initial q, + Emitter.resultTapes Tape.reversed (setupTapes input) (headerBits input)⟩) + (7 * (3 * ((GenericGraphTables.tableBits input).length + 1) + 3) + 1) at transported + rw [headerResult_eq] at transported + exact transported + +def time (N : Nat) : Nat := (6 * N + 11) + (7 * (3 * (N + 1) + 3) + 1) + +theorem time_eq (N : Nat) : time N = 27 * N + 54 := by + unfold time + omega + +def initializeInTime (input : GenericGraphTables.Table q) : + StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + (initList (Driver.machine q) (GenericGraphTables.tableBits input)) + (some (loopStart input)) (time (GenericGraphTables.tableBits input).length) := by + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ + (setupInTime input) (headerInTime input) + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have bound := run.steps_le_m + unfold time + omega + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Initialization + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Label.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Label.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d079791c7ecbd43e95694cf65ba561d9debe2d2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Label.lean @@ -0,0 +1,455 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalRow +import OAI.Combinatorics.IndependentSets.Machines.MachinePortReindex +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingLazyWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLazyRows + +open Turing MachineComposition PCP.GraphTables +open PCP.PreprocessingLazyWords (reverseMap moveRow moveRow_words) + +variable {K Λ A : Type} [DecidableEq K] + +abbrev Label (d : Nat) := MachinePortReindex.Label d ⊕ MachineTableRows.Label +abbrev State (A : Type) (d : Nat) := MachinePortReindex.State A d + +def addressIndex : Fin 5 → Fin 9 := ![1, 3, 4, 5, 6] + +theorem addressIndex_injective : Function.Injective addressIndex := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [addressIndex] + +def fields (tape : Fin 9 → K) : Fin 3 → K := ![tape 0, tape 6, tape 2] + +def reindexInstruction (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 9 → K) + (labels : Label d → Λ) (exit : Option Λ) : + Label d → TM2.Stmt (fun _ : K => Bool) Λ (State A d) + | .inl stage => MachinePortReindex.instruction d positive c b + (tape ∘ addressIndex) (fun stage => labels (.inl stage)) + (some (labels (.inr .relationRead))) stage + | .inr stage => MachineTableRows.routine (fields tape) (tape 8) (tape 7) (tape 3) + (fun stage => labels (.inr stage)) exit stage + +def instruction (d : Nat) (positive : 0 < d) (tape : Fin 9 → K) + (labels : Label d → Λ) (exit : Option Λ) : + Label d → TM2.Stmt (fun _ : K => Bool) Λ (State A d) := + reindexInstruction d positive (2 * d) d tape labels exit + +def reindexRowBits (d c b v j : Nat) (relation : RelationTable) : List Bool := + encodeWord v ++ encodeWord (MachinePortReindex.value d c b j) ++ + encodeWords (relationWords relation) + +def reindexMappedTapes (d c b j : Nat) (tape : Fin 9 → K) + (base : K → List Bool) : K → List Bool := + Function.update base (tape 6) (encodeWord (MachinePortReindex.value d c b j)) + +def reindexResultTapes (d c b v j : Nat) (relation : RelationTable) + (tape : Fin 9 → K) (base : K → List Bool) : K → List Bool := + Function.update (reindexMappedTapes d c b j tape base) (tape 7) + (base (tape 7) ++ reindexRowBits d c b v j relation) + +def reindexSteps (d c b v j : Nat) (relation : RelationTable) (output : List Bool) : Nat := + MachinePortReindex.steps d j + 4 * (reindexRowBits d c b v j relation).length + + 2 * output.length + 9 + +def rowBits (d v j : Nat) (relation : RelationTable) : List Bool := + encodeWord v ++ encodeWord (reverseMap d j) ++ encodeWords (relationWords relation) + +def mappedTapes (d j : Nat) (tape : Fin 9 → K) (base : K → List Bool) : K → List Bool := + Function.update base (tape 6) (encodeWord (reverseMap d j)) + +def resultTapes (d v j : Nat) (relation : RelationTable) + (tape : Fin 9 → K) (base : K → List Bool) : K → List Bool := + Function.update (mappedTapes d j tape base) (tape 7) + (base (tape 7) ++ rowBits d v j relation) + +def steps (d v j : Nat) (relation : RelationTable) (output : List Bool) : Nat := + MachinePortReindex.steps d j + 4 * (rowBits d v j relation).length + 2 * output.length + 9 + +theorem reindexRowTrace (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 9 → K) + (distinct : Function.Injective tape) (labels : Label d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A d)) + (atLabels : ∀ l, program (labels l) = reindexInstruction d positive c b tape labels exit l) + (base : K → List Bool) (v j : Nat) (relation : RelationTable) + (tailWord : base (tape 0) = encodeWord v) + (reverseWord : base (tape 1) = encodeWord j) + (relationWord : base (tape 2) = encodeWords (relationWords relation)) + (scratchEmpty : base (tape 3) = []) (workEmpty : base (tape 4) = []) + (quotientEmpty : base (tape 5) = []) (newReverseEmpty : base (tape 6) = []) + (rowEmpty : base (tape 8) = []) (ambient : A) : + (advance (TM2.step program))^[reindexSteps d c b v j relation (base (tape 7))] + (some ⟨some (labels (.inl .copySeed)), MachinePortReindex.clean d positive ambient, base⟩) = + some ⟨exit, MachinePortReindex.clean d positive ambient, + reindexResultTapes d c b v j relation tape base⟩ := by + have hd (i k : Fin 9) (h : i ≠ k) : tape i ≠ tape k := fun e => h (distinct e) + have ha0 : addressIndex 0 = 1 := rfl + have ha4 : addressIndex 4 = 6 := rfl + have mapRun := MachinePortReindex.reindexTrace d positive c b + (tape ∘ addressIndex) (distinct.comp addressIndex_injective) + (fun stage => labels (.inl stage)) (some (labels (.inr .relationRead))) + program (fun stage => atLabels (.inl stage)) base j [] + (by simpa only [Function.comp_apply, ha0, List.append_nil] using reverseWord) + scratchEmpty workEmpty quotientEmpty ambient + simp only [Function.comp_apply, ha4, newReverseEmpty, + List.append_nil] at mapRun + change (advance (TM2.step program))^[MachinePortReindex.steps d j] + (some ⟨some (labels (.inl .copySeed)), MachinePortReindex.clean d positive ambient, base⟩) = + some ⟨some (labels (.inr .relationRead)), MachinePortReindex.clean d positive ambient, + reindexMappedTapes d c b j tape base⟩ at mapRun + have hfields (i : Fin 3) : fields tape i ≠ tape 8 ∧ fields tape i ≠ tape 3 := by + fin_cases i + · exact ⟨hd 0 8 (by decide), hd 0 3 (by decide)⟩ + · exact ⟨hd 6 8 (by decide), hd 6 3 (by decide)⟩ + · exact ⟨hd 2 8 (by decide), hd 2 3 (by decide)⟩ + have hbits : MachineTableRows.fieldBits (fields tape) (reindexMappedTapes d c b j tape base) = + reindexRowBits d c b v j relation := by + simp [MachineTableRows.fieldBits, fields, reindexMappedTapes, hd 0 6 (by decide), + hd 2 6 (by decide), tailWord, relationWord, reindexRowBits] + have hsize : MachineTableRows.fieldSize (fields tape) (reindexMappedTapes d c b j tape base) = + (reindexRowBits d c b v j relation).length := by + rw [← MachineTableRows.fieldBits_length, hbits] + have hout : reindexMappedTapes d c b j tape base (tape 7) = base (tape 7) := by + simp [reindexMappedTapes, hd 7 6 (by decide)] + have appendRun := MachineTableRows.appendTrace (fields tape) (tape 8) (tape 7) (tape 3) + hfields (hd 8 7 (by decide)) (hd 8 3 (by decide)) (hd 7 3 (by decide)) + (fun stage => labels (.inr stage)) exit program + (fun stage => atLabels (.inr stage)) (reindexMappedTapes d c b j tape base) + (by simp [reindexMappedTapes, hd 8 6 (by decide), rowEmpty]) + (by simp [reindexMappedTapes, hd 3 6 (by decide), scratchEmpty]) + (ambient, MachineFixedDivMod.residue d positive 0) none + rw [hsize, hout, hbits] at appendRun + change (advance (TM2.step program))^[4 * (reindexRowBits d c b v j relation).length + + 2 * (base (tape 7)).length + 9] + (some ⟨some (labels (.inr .relationRead)), MachinePortReindex.clean d positive ambient, + reindexMappedTapes d c b j tape base⟩) = + some ⟨exit, MachinePortReindex.clean d positive ambient, + reindexResultTapes d c b v j relation tape base⟩ at appendRun + rw [show reindexSteps d c b v j relation (base (tape 7)) = + (4 * (reindexRowBits d c b v j relation).length + 2 * (base (tape 7)).length + 9) + + MachinePortReindex.steps d j by unfold reindexSteps; omega, + Function.iterate_add_apply, mapRun, appendRun] + +theorem rowTrace (d : Nat) (positive : 0 < d) (tape : Fin 9 → K) + (distinct : Function.Injective tape) (labels : Label d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A d)) + (atLabels : ∀ l, program (labels l) = instruction d positive tape labels exit l) + (base : K → List Bool) (v j : Nat) (relation : RelationTable) + (tailWord : base (tape 0) = encodeWord v) + (reverseWord : base (tape 1) = encodeWord j) + (relationWord : base (tape 2) = encodeWords (relationWords relation)) + (scratchEmpty : base (tape 3) = []) (workEmpty : base (tape 4) = []) + (quotientEmpty : base (tape 5) = []) (newReverseEmpty : base (tape 6) = []) + (rowEmpty : base (tape 8) = []) (ambient : A) : + (advance (TM2.step program))^[steps d v j relation (base (tape 7))] + (some ⟨some (labels (.inl .copySeed)), MachinePortReindex.clean d positive ambient, base⟩) = + some ⟨exit, MachinePortReindex.clean d positive ambient, + resultTapes d v j relation tape base⟩ := by + simpa only [reindexSteps, reindexResultTapes, reindexMappedTapes, reindexRowBits, + MachinePortReindex.lazy_value, reverseMap, steps, resultTapes, mappedTapes, rowBits] using + reindexRowTrace d positive (2 * d) d tape distinct labels exit program atLabels + base v j relation tailWord reverseWord relationWord scratchEmpty workEmpty + quotientEmpty newReverseEmpty rowEmpty ambient + +theorem rowBits_eq_moveRow {n d : Nat} (table : PCP.PortTables.Table n d) + (v : Fin n) (p : Fin d) : + rowBits d v.val (PCP.PreprocessingLazyWords.row table v p).reverseIndex.val + (PCP.PreprocessingLazyWords.row table v p).relation = + encodeWords (rowWords (moveRow table v p)) := by + rw [moveRow_words] + simp [rowBits, encodeWords] + +def machine (d : Nat) (positive : 0 < d) : FinTM2 where + K := Fin 9 + k₀ := 1 + k₁ := 7 + Γ _ := Bool + Λ := Label d + main := .inl .copySeed + σ := State Unit d + initialState := MachinePortReindex.clean d positive () + m := instruction d positive id id none + +abbrev Buffer := MachineRegularOriginalRow.Buffer +abbrev StreamState (A : Type) (d : Nat) := State (A × Buffer) d + +def streamClean (d : Nat) (positive : 0 < d) (ambient : A) : StreamState A d := + MachinePortReindex.clean d positive (ambient, MachineRegularOriginalRow.zeroBuffer) + +def relationStateEquiv (A : Type) (d : Nat) : + MachineRegularOriginalRow.State (A × Fin d) ≃ StreamState A d where + toFun s := (((s.1.1.1, s.1.2), s.1.1.2), s.2) + invFun s := (((s.1.1.1, s.1.2), s.1.1.2), s.2) + left_inv _ := rfl + right_inv _ := rfl + +def streamRelationCopy (d : Nat) (source destination : K) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d) := + MachineStateEquiv.statement (relationStateEquiv A d) + (MachineRegularOriginalRow.relationCopyAt source destination exit) + +theorem streamRelationCopy_step (d : Nat) (positive : 0 < d) + (source destination : K) (different : source ≠ destination) + (label : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d)) + (code : program label = streamRelationCopy d source destination exit) + (relation : RelationTable) (suffix : List Bool) (base : K → List Bool) + (input : base source = encodeWords (relationWords relation) ++ suffix) (ambient : A) : + TM2.step program ⟨some label, streamClean d positive ambient, base⟩ = + some ⟨exit, streamClean d positive ambient, + Function.update (Function.update base source suffix) destination + (encodeWords (relationWords relation) ++ base destination)⟩ := by + have hraw := MachineRegularOriginalRow.relationCopy_step source destination different label exit + (fun _ => MachineRegularOriginalRow.relationCopyAt source destination exit) rfl + relation suffix base input (ambient, MachineFixedDivMod.residue d positive 0) + MachineRegularOriginalRow.zeroBuffer none + have haux := Option.some.inj hraw + change some (TM2.stepAux (program label) (streamClean d positive ambient) base) = _ + rw [code, streamRelationCopy, MachineStateEquiv.stepAux_transport_symm] + change some (MachineStateEquiv.configuration (relationStateEquiv A d) + (TM2.stepAux (MachineRegularOriginalRow.relationCopyAt source destination exit) + (((ambient, MachineFixedDivMod.residue d positive 0), + MachineRegularOriginalRow.zeroBuffer), none) base)) = _ + rw [haux] + rfl + +def bodyIndex (i : Fin 9) : Fin 10 := i.castSucc + +theorem bodyIndex_injective : Function.Injective bodyIndex := by + intro i j h + apply Fin.ext + exact congrArg (fun k : Fin 10 => k.val) h + +inductive StreamLabel (d : Nat) + | tailStart | tailRead | reverseStart | reverseRead | copyRelation + | row (stage : Label d) + | clearTail | clearOld | clearRelation | clearNew + deriving DecidableEq, Fintype + +def streamInstruction (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 10 → K) + (labels : StreamLabel d → Λ) (exit : Option Λ) : + StreamLabel d → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d) + | .tailStart => Hastad.SourceMachine.fieldStart (tape 0) (labels .tailRead) + | .tailRead => Hastad.SourceMachine.fieldLoop (tape 9) (tape 0) (labels .tailRead) + (some (labels .reverseStart)) + | .reverseStart => Hastad.SourceMachine.fieldStart (tape 1) (labels .reverseRead) + | .reverseRead => Hastad.SourceMachine.fieldLoop (tape 9) (tape 1) (labels .reverseRead) + (some (labels .copyRelation)) + | .copyRelation => streamRelationCopy d (tape 9) (tape 2) + (some (labels (.row (.inl .copySeed)))) + | .row stage => reindexInstruction d positive c b (tape ∘ bodyIndex) + (fun stage => labels (.row stage)) (some (labels .clearTail)) stage + | .clearTail => MachineDrain.drain (tape 0) (labels .clearTail) (some (labels .clearOld)) + | .clearOld => MachineDrain.drain (tape 1) (labels .clearOld) (some (labels .clearRelation)) + | .clearRelation => MachineDrain.drain (tape 2) (labels .clearRelation) (some (labels .clearNew)) + | .clearNew => MachineDrain.drain (tape 6) (labels .clearNew) exit + +def inputRowBits (v j : Nat) (relation : RelationTable) : List Bool := + encodeWord v ++ encodeWord j ++ encodeWords (relationWords relation) + +def streamRowSteps (d c b v j : Nat) (relation : RelationTable) (output : List Bool) : Nat := + (v + 2) + (j + 2) + 1 + reindexSteps d c b v j relation output + + (v + 2) + (j + 2) + ((encodeWords (relationWords relation)).length + 1) + + (MachinePortReindex.value d c b j + 2) + +def streamResultTapes (d c b v j : Nat) (relation : RelationTable) + (tape : Fin 10 → K) (base : K → List Bool) (suffix : List Bool) : K → List Bool := + Function.update (Function.update base (tape 9) suffix) (tape 7) + (base (tape 7) ++ reindexRowBits d c b v j relation) + +theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {n m : Nat} + (first : f^[n] a = b) (second : f^[m] b = c) : f^[n + m] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem streamRowTrace (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 10 → K) + (distinct : Function.Injective tape) (labels : StreamLabel d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d)) + (atLabels : ∀ l, program (labels l) = streamInstruction d positive c b tape labels exit l) + (base : K → List Bool) (v j : Nat) (relation : RelationTable) (suffix : List Bool) + (input : base (tape 9) = inputRowBits v j relation ++ suffix) + (empty : ∀ i : Fin 10, i ≠ 7 → i ≠ 9 → base (tape i) = []) (ambient : A) : + (advance (TM2.step program))^[streamRowSteps d c b v j relation (base (tape 7))] + (some ⟨some (labels .tailStart), streamClean d positive ambient, base⟩) = + some ⟨exit, streamClean d positive ambient, + streamResultTapes d c b v j relation tape base suffix⟩ := by + have hd (i k : Fin 10) (h : i ≠ k) : tape i ≠ tape k := fun x => h (distinct x) + have hb6 : bodyIndex 6 = 6 := rfl + have hb7 : bodyIndex 7 = 7 := rfl + have h₀ := empty 0 (by decide) (by decide) + have h₁ := empty 1 (by decide) (by decide) + have h₂ := empty 2 (by decide) (by decide) + have h₃ := empty 3 (by decide) (by decide) + have h₄ := empty 4 (by decide) (by decide) + have h₅ := empty 5 (by decide) (by decide) + have h₆ := empty 6 (by decide) (by decide) + have h₈ := empty 8 (by decide) (by decide) + let relationBits := encodeWords (relationWords relation) + let tailLoaded := Function.update (Function.update base (tape 9) + (encodeWord j ++ (relationBits ++ suffix))) (tape 0) (encodeWord v) + let reverseLoaded := Function.update (Function.update tailLoaded (tape 9) + (relationBits ++ suffix)) (tape 1) (encodeWord j) + let loaded := Function.update (Function.update reverseLoaded (tape 9) suffix) (tape 2) relationBits + let rowed := reindexResultTapes d c b v j relation (tape ∘ bodyIndex) loaded + let tailCleared := Function.update rowed (tape 0) [] + let oldCleared := Function.update tailCleared (tape 1) [] + let relationCleared := Function.update oldCleared (tape 2) [] + have tailRun : (advance (TM2.step program))^[v + 2] + (some ⟨some (labels .tailStart), streamClean d positive ambient, base⟩) = + some ⟨some (labels .reverseStart), streamClean d positive ambient, tailLoaded⟩ := by + have h := (Hastad.SourceMachine.fieldInTime (tape 9) (tape 0) (hd 9 0 (by decide)) + (labels .tailStart) (labels .tailRead) (some (labels .reverseStart)) program + (atLabels .tailStart) (atLabels .tailRead) base v + (encodeWord j ++ (relationBits ++ suffix)) + (by simpa only [inputRowBits, List.append_assoc] using input) + ((ambient, MachineRegularOriginalRow.zeroBuffer), + MachineFixedDivMod.residue d positive 0) none).evals_in_steps + simp only [Hastad.SourceMachine.fieldInTime, Hastad.SourceMachine.fieldTapes, + h₀, List.append_nil] at h + convert h using 1 <;> rfl + have reverseRun : (advance (TM2.step program))^[j + 2] + (some ⟨some (labels .reverseStart), streamClean d positive ambient, tailLoaded⟩) = + some ⟨some (labels .copyRelation), streamClean d positive ambient, reverseLoaded⟩ := by + have hstart : tailLoaded (tape 1) = [] := by + simp [tailLoaded, hd 1 0 (by decide), hd 1 9 (by decide), h₁] + have h := (Hastad.SourceMachine.fieldInTime (tape 9) (tape 1) (hd 9 1 (by decide)) + (labels .reverseStart) (labels .reverseRead) (some (labels .copyRelation)) program + (atLabels .reverseStart) (atLabels .reverseRead) tailLoaded j (relationBits ++ suffix) + (by simp [tailLoaded, hd 9 0 (by decide)]) + ((ambient, MachineRegularOriginalRow.zeroBuffer), + MachineFixedDivMod.residue d positive 0) none).evals_in_steps + simp only [Hastad.SourceMachine.fieldInTime, Hastad.SourceMachine.fieldTapes, + hstart, List.append_nil] at h + convert h using 1 <;> rfl + have copyRun : (advance (TM2.step program))^[1] + (some ⟨some (labels .copyRelation), streamClean d positive ambient, reverseLoaded⟩) = + some ⟨some (labels (.row (.inl .copySeed))), streamClean d positive ambient, loaded⟩ := by + have hempty : reverseLoaded (tape 2) = [] := by + simp [reverseLoaded, tailLoaded, hd 2 1 (by decide), hd 2 9 (by decide), + hd 2 0 (by decide), h₂] + have h := streamRelationCopy_step d positive (tape 9) (tape 2) (hd 9 2 (by decide)) + (labels .copyRelation) (some (labels (.row (.inl .copySeed)))) program + (atLabels .copyRelation) relation suffix reverseLoaded + (by simp [reverseLoaded, relationBits, hd 9 1 (by decide)]) ambient + simpa only [Function.iterate_one, advance_some, hempty, List.append_nil, loaded] using h + have hs (i : Fin 10) (hi : i ≠ 0) (hi' : i ≠ 1) (hi'' : i ≠ 2) (hi''' : i ≠ 9) : + loaded (tape i) = base (tape i) := by + simp [loaded, reverseLoaded, tailLoaded, hd i 0 hi, hd i 1 hi', + hd i 2 hi'', hd i 9 hi'''] + have loadedTail : loaded (tape 0) = encodeWord v := by + simp [loaded, reverseLoaded, tailLoaded, hd 0 2 (by decide), hd 0 9 (by decide), + hd 0 1 (by decide)] + have loadedReverse : loaded (tape 1) = encodeWord j := by + simp [loaded, reverseLoaded, hd 1 2 (by decide), hd 1 9 (by decide)] + have loadedRelation : loaded (tape 2) = relationBits := by simp [loaded] + have bodyRun := reindexRowTrace d positive c b (tape ∘ bodyIndex) + (distinct.comp bodyIndex_injective) (fun stage => labels (.row stage)) + (some (labels .clearTail)) program (fun stage => atLabels (.row stage)) loaded v j relation + loadedTail loadedReverse loadedRelation + ((hs 3 (by decide) (by decide) (by decide) (by decide)).trans h₃) + ((hs 4 (by decide) (by decide) (by decide) (by decide)).trans h₄) + ((hs 5 (by decide) (by decide) (by decide) (by decide)).trans h₅) + ((hs 6 (by decide) (by decide) (by decide) (by decide)).trans h₆) + ((hs 8 (by decide) (by decide) (by decide) (by decide)).trans h₈) + (ambient, MachineRegularOriginalRow.zeroBuffer) + have hout : loaded ((tape ∘ bodyIndex) 7) = base (tape 7) := + hs 7 (by decide) (by decide) (by decide) (by decide) + rw [hout] at bodyRun + change (advance (TM2.step program))^[reindexSteps d c b v j relation (base (tape 7))] + (some ⟨some (labels (.row (.inl .copySeed))), streamClean d positive ambient, loaded⟩) = + some ⟨some (labels .clearTail), streamClean d positive ambient, rowed⟩ at bodyRun + have rowedTail : rowed (tape 0) = encodeWord v := by + simp only [rowed, reindexResultTapes, reindexMappedTapes, Function.comp_apply, hb6, hb7] + simpa only [Function.update_of_ne (hd 0 7 (by decide)), + Function.update_of_ne (hd 0 6 (by decide))] using loadedTail + have rowedOld : tailCleared (tape 1) = encodeWord j := by + simp only [tailCleared, rowed, reindexResultTapes, reindexMappedTapes, + Function.comp_apply, hb6, hb7] + simpa only [Function.update_of_ne (hd 1 0 (by decide)), + Function.update_of_ne (hd 1 7 (by decide)), Function.update_of_ne (hd 1 6 (by decide))] + using loadedReverse + have rowedRelation : oldCleared (tape 2) = relationBits := by + simp only [oldCleared, tailCleared, rowed, reindexResultTapes, reindexMappedTapes, + Function.comp_apply, hb6, hb7] + simpa only [Function.update_of_ne (hd 2 1 (by decide)), + Function.update_of_ne (hd 2 0 (by decide)), Function.update_of_ne (hd 2 7 (by decide)), + Function.update_of_ne (hd 2 6 (by decide))] using loadedRelation + have rowedNew : relationCleared (tape 6) = encodeWord (MachinePortReindex.value d c b j) := by + simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, + reindexMappedTapes, Function.comp_apply, bodyIndex, hd 6 2 (by decide), + hd 6 1 (by decide), hd 6 0 (by decide), hd 6 7 (by decide)] + have clearTail := (MachineDrain.drainInTime (tape 0) (labels .clearTail) + (some (labels .clearOld)) program (atLabels .clearTail) rowed + ((ambient, MachineRegularOriginalRow.zeroBuffer), + MachineFixedDivMod.residue d positive 0) none).evals_in_steps + change (advance (TM2.step program))^[(rowed (tape 0)).length + 1] + (some ⟨some (labels .clearTail), streamClean d positive ambient, rowed⟩) = + some ⟨some (labels .clearOld), streamClean d positive ambient, tailCleared⟩ at clearTail + rw [rowedTail, encodeWord_length] at clearTail + have clearOld := (MachineDrain.drainInTime (tape 1) (labels .clearOld) + (some (labels .clearRelation)) program (atLabels .clearOld) tailCleared + ((ambient, MachineRegularOriginalRow.zeroBuffer), + MachineFixedDivMod.residue d positive 0) none).evals_in_steps + change (advance (TM2.step program))^[(tailCleared (tape 1)).length + 1] + (some ⟨some (labels .clearOld), streamClean d positive ambient, tailCleared⟩) = + some ⟨some (labels .clearRelation), streamClean d positive ambient, oldCleared⟩ at clearOld + rw [rowedOld, encodeWord_length] at clearOld + have clearRelation := (MachineDrain.drainInTime (tape 2) (labels .clearRelation) + (some (labels .clearNew)) program (atLabels .clearRelation) oldCleared + ((ambient, MachineRegularOriginalRow.zeroBuffer), + MachineFixedDivMod.residue d positive 0) none).evals_in_steps + change (advance (TM2.step program))^[(oldCleared (tape 2)).length + 1] + (some ⟨some (labels .clearRelation), streamClean d positive ambient, oldCleared⟩) = + some ⟨some (labels .clearNew), streamClean d positive ambient, relationCleared⟩ at clearRelation + rw [rowedRelation] at clearRelation + have clearNew := (MachineDrain.drainInTime (tape 6) (labels .clearNew) + exit program (atLabels .clearNew) relationCleared + ((ambient, MachineRegularOriginalRow.zeroBuffer), + MachineFixedDivMod.residue d positive 0) none).evals_in_steps + change (advance (TM2.step program))^[(relationCleared (tape 6)).length + 1] + (some ⟨some (labels .clearNew), streamClean d positive ambient, relationCleared⟩) = + some ⟨exit, streamClean d positive ambient, + Function.update relationCleared (tape 6) []⟩ at clearNew + rw [rowedNew, encodeWord_length] at clearNew + have finalFrame : Function.update relationCleared (tape 6) [] = + streamResultTapes d c b v j relation tape base suffix := by + funext k + by_cases h6 : k = tape 6 + · subst k + simp [streamResultTapes, hd 6 7 (by decide), hd 6 9 (by decide), h₆] + · by_cases h2 : k = tape 2 + · subst k + simp [relationCleared, streamResultTapes, hd 2 6 (by decide), + hd 2 7 (by decide), hd 2 9 (by decide), h₂] + · by_cases h1 : k = tape 1 + · subst k + simp [relationCleared, oldCleared, streamResultTapes, + hd 1 6 (by decide), hd 1 2 (by decide), hd 1 7 (by decide), + hd 1 9 (by decide), h₁] + · by_cases h0 : k = tape 0 + · subst k + simp [relationCleared, oldCleared, tailCleared, streamResultTapes, + hd 0 6 (by decide), hd 0 2 (by decide), hd 0 1 (by decide), + hd 0 7 (by decide), hd 0 9 (by decide), h₀] + · by_cases h7 : k = tape 7 + · subst k + simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, + reindexMappedTapes, Function.comp_apply, bodyIndex, streamResultTapes, + loaded, reverseLoaded, tailLoaded, hd 7 6 (by decide), hd 7 2 (by decide), + hd 7 1 (by decide), hd 7 0 (by decide), hd 7 9 (by decide)] + · by_cases h9 : k = tape 9 + · subst k + simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, + reindexMappedTapes, Function.comp_apply, bodyIndex, loaded, reverseLoaded, + tailLoaded, streamResultTapes, hd 9 6 (by decide), hd 9 2 (by decide), + hd 9 1 (by decide), hd 9 0 (by decide), hd 9 7 (by decide)] + · simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, + reindexMappedTapes, Function.comp_apply, bodyIndex, loaded, reverseLoaded, + tailLoaded, streamResultTapes, h6, h2, h1, h0, h7, h9] + rw [finalFrame] at clearNew + exact joinTrace (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace + (joinTrace tailRun reverseRun) copyRun) bodyRun) clearTail) clearOld) clearRelation) clearNew + +end IndependentSetsGames.Foundations.Complexity.MachineLazyRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/LengthLoop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/LengthLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..149cb03b141b869ab5efabdcea6fa6dbb068b253 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/LengthLoop.lean @@ -0,0 +1,212 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Copy + +namespace OAI + +namespace IndependentSetsCut.CounterMachine + +section +variable {R : Type} [DecidableEq R] +namespace Command + +def lengthLoop (guard result : R) : Command R := + .loop guard (.read (.seq (.inc guard) (.inc result)) (.seq (.inc guard) (.inc result)) .skip) + + theorem lengthLoop_evaluates (d : Data R) (g r : R) (hgr : g ≠ r) (hg : d.reg g = 1) : + Within (lengthLoop g r) d + {((d.set g 0).set r (d.reg r+d.input.length)) with + input := [], backup := d.input.reverse++d.backup} + (4*d.input.length+4) := by + generalize hx : d.input = xs + induction xs generalizing d with + | nil => + have he : readData (decData d g) = d.set g 0 := by + simp [readData, decData, Data.set, hx, hg] + have hread : Evaluates (.read (.seq (.inc g) (.inc r)) (.seq (.inc g) (.inc r)) .skip) + (decData d g) (d.set g 0) 2 := by + rw [← he] + exact Evaluates.read_empty (d := decData d g) hx (Evaluates.skip _) + have hloop : Evaluates (lengthLoop g r) d (d.set g 0) 4 := + Evaluates.loop_pos (by omega) hread (Evaluates.loop_zero (by simp)) + have hf : {((d.set g 0).set r (d.reg r + ([] : List Bool).length)) with input := [], backup := [].reverse++d.backup} = d.set g 0 := by + apply Data.ext + · simp [Data.set, Ne.symm hgr] + · exact hx.symm + · simp [Data.set] + · rfl + exact ⟨4, by simp, by rw [hf]; exact hloop⟩ + | cons b xs ih => + let e := incData (incData (readData (decData d g)) g) r + have eg : e.reg g = 1 := by simp [e, incData, decData, readData, hgr, hg] + have ei : e.input = xs := by simp [e, incData, decData, readData, hx] + obtain ⟨n, hn, he⟩ := ih e eg ei + have hread : Evaluates (.read (.seq (.inc g) (.inc r)) (.seq (.inc g) (.inc r)) .skip) + (decData d g) e 3 := by + have hi := Evaluates.seq (Evaluates.inc (readData (decData d g)) g) + (Evaluates.inc (incData (readData (decData d g)) g) r) + cases b + · exact Evaluates.read_zero (d := decData d g) hx hi + · exact Evaluates.read_one (d := decData d g) hx hi + have heq : {((e.set g 0).set r (e.reg r+xs.length)) with input := [], backup := xs.reverse++e.backup} = + {((d.set g 0).set r (d.reg r+(b::xs).length)) with input := [], backup := (b::xs).reverse++d.backup} := by + apply Data.ext + · ext u + by_cases hu : u = g <;> by_cases hr : u = r <;> + simp [e, incData, decData, readData, Data.set, hu, hr, + hgr, Ne.symm hgr, hg, Nat.add_assoc, Nat.add_comm] + · rfl + · simp [e, incData, decData, readData, hx, List.reverse_cons, List.append_assoc] + · rfl + rw [heq] at he + exact ⟨1+3+n, by simp; omega, Evaluates.loop_pos (by omega) hread he⟩ + + def inputLength (g r : R) : Command R := .seq (.inc g) (.seq (lengthLoop g r) .rewind) + + theorem inputLength_evaluates (d : Data R) (g r : R) (hgr : g ≠ r) + (hg : d.reg g = 0) (hr : d.reg r = 0) (hb : d.backup = []) : + Within (inputLength g r) d (d.set r d.input.length) (5*d.input.length+6) := by + have he := lengthLoop_evaluates (incData d g) g r hgr (by simp [incData, hg]) + obtain ⟨n,hn,h⟩ := he + let e : Data R := {((incData d g).set g 0).set r ((incData d g).reg r+d.input.length) + with input := [], backup := d.input.reverse++d.backup} + have he' : Within (lengthLoop g r) (incData d g) e (4*d.input.length+4) := ⟨n,hn,h⟩ + have hw := rewind_evaluates e + have hout : {e with input := e.backup.reverse++e.input, backup := []} = d.set r d.input.length := by + apply Data.ext + · ext u + by_cases hu : u = g <;> by_cases hu' : u = r <;> + simp [e, incData, Data.set, hu, hu', hgr, Ne.symm hgr, hg, hr] + · simp [e, hb, Data.set] + · exact hb.symm + · rfl + have size : e.backup.length = d.input.length := by simp [e, hb] + have hfull := (Within.inc d g).seq (he'.seq hw) + rw [hout, size] at hfull + exact hfull.mono (by omega) + +end Command +end + +open scoped BigOperators +open Finset + +inductive Expr where + | const (n : ℕ) + | arg (i : ℕ) + | length + | bit (index : Expr) + | add (a b : Expr) + | sub (a b : Expr) + | mul (a b : Expr) + | zero (a : Expr) + | sum (bound body : Expr) + +namespace Expr + +def bind (v : ℕ → ℕ) (a : ℕ) : ℕ → ℕ + | 0 => a + | n+1 => v n + + def eval (input : List Bool) (args : ℕ → ℕ) : Expr → ℕ + | .const n => n + | .arg i => args i + | .length => input.length + | .bit e => if (input[eval input args e]?).getD false then 1 else 0 + | .add a b => eval input args a + eval input args b + | .sub a b => eval input args a - eval input args b + | .mul a b => eval input args a * eval input args b + | .zero a => if eval input args a = 0 then 1 else 0 + | .sum b f => ∑ i ∈ range (eval input args b), eval input (bind args i) f + + def valueBudget : Expr → ℕ → ℕ + | .const n, _ => n + | .arg _, M => M + | .length, M => M + | .bit _, _ => 1 + | .add a b, M => valueBudget a M + valueBudget b M + | .sub a _, M => valueBudget a M + | .mul a b, M => valueBudget a M * valueBudget b M + | .zero _, _ => 1 + | .sum b f, M => valueBudget b M * valueBudget f (M+valueBudget b M) + + theorem eval_le (e : Expr) (input : List Bool) (args : ℕ → ℕ) (M : ℕ) + (hi : input.length ≤ M) (ha : ∀ i, args i ≤ M) : + e.eval input args ≤ e.valueBudget M := by + induction e generalizing args M with + | const n => exact le_rfl + | arg i => exact ha i + | length => exact hi + | bit e ih => simp only [eval, valueBudget]; split_ifs <;> omega + | zero e ih => simp only [eval, valueBudget]; split_ifs <;> omega + | add a b ia ib => exact Nat.add_le_add (ia _ _ hi ha) (ib _ _ hi ha) + | sub a b ia ib => exact (Nat.sub_le _ _).trans (ia _ _ hi ha) + | mul a b ia ib => exact Nat.mul_le_mul (ia _ _ hi ha) (ib _ _ hi ha) + | sum b f ib iF => + have hb := ib args M hi ha + calc + _ ≤ ∑ _ ∈ range (eval input args b), f.valueBudget (M+b.valueBudget M) := by + apply sum_le_sum; intro i hi' + apply iF + · omega + · intro j + cases j with + | zero => dsimp [bind]; have := mem_range.mp hi'; omega + | succ j => exact (ha j).trans (by omega) + _ = eval input args b * f.valueBudget (M+b.valueBudget M) := by simp + _ ≤ b.valueBudget M * f.valueBudget (M+b.valueBudget M) := Nat.mul_le_mul_right _ hb + + def timeBudget : Expr → ℕ → ℕ + | .const n, _ => n+1 + | .arg _, M => 5*M+2 + | .length, M => 5*M+6 + | .bit e, M => timeBudget e M+3*valueBudget e M+M+7 + | .add a b, M | .sub a b, M => timeBudget a M+timeBudget b M+2*valueBudget b M+1 + | .mul a b, M => timeBudget a M+timeBudget b M+ + valueBudget b M*(5*valueBudget a M+3)+1+2*valueBudget a M+1+ + 2*(valueBudget a M*valueBudget b M)+1 + | .zero a, M => timeBudget a M+2*valueBudget a M+2 + | .sum b f, M => timeBudget b M+valueBudget b M* + (timeBudget f (M+valueBudget b M)+2*valueBudget f (M+valueBudget b M)+3)+2*valueBudget b M+2 + + def compile (vars : ℕ → ℕ) (k : ℕ) : Expr → Command ℕ + | .const n => Command.put k n + | .arg i => Command.copy (vars i) k (k+1) + | .length => Command.inputLength (k+1) k + | .bit e => .seq (compile vars k e) + (.seq (Command.inputBit k (k+1)) (Command.move (k+1) k)) + | .add a b => .seq (compile vars k a) (.seq (compile vars (k+1) b) (Command.move (k+1) k)) + | .sub a b => .seq (compile vars k a) (.seq (compile vars (k+1) b) (Command.subFrom (k+1) k)) + | .mul a b => .seq (compile vars k a) (.seq (compile vars (k+1) b) + (.seq (Command.mulAdd (k+1) k (k+2) (k+3)) + (.seq (Command.clear k) (Command.move (k+2) k)))) + | .zero a => .seq (compile vars k a) (.test k (.inc k) (Command.clear k)) + | .sum b f => .seq (compile vars (k+1) b) + (.seq (.loop (k+1) (.seq (compile (bind vars (k+2)) (k+3) f) + (.seq (Command.move (k+3) k) (.inc (k+2))))) (Command.clear (k+2))) + +end Expr +namespace Data + +def Clean (d : Data ℕ) (k : ℕ) : Prop := ∀ r, k ≤ r → d.reg r = 0 + + theorem Clean.mono {d : Data ℕ} {k l : ℕ} (hc : d.Clean k) (h : k ≤ l) : d.Clean l := + fun r hr => hc r (h.trans hr) + + theorem Clean.set_succ {d : Data ℕ} {k : ℕ} (hc : d.Clean k) (v : ℕ) : + (d.set k v).Clean (k+1) := by + intro r hr + rw [set_reg_ne _ _ _ _ (by omega)] + exact hc r (by omega) + + theorem set_args (d : Data ℕ) (vars : ℕ → ℕ) (k v : ℕ) (h : ∀ i, vars i < k) : + (fun i => (d.set k v).reg (vars i)) = (fun i => d.reg (vars i)) := by + funext i + exact set_reg_ne _ _ _ _ (by have := h i; omega) + + theorem set_clean_zero {d : Data ℕ} {k r : ℕ} (hc : d.Clean k) (h : k ≤ r) : + d.set r 0 = d := by rw [← hc r h, set_self] + +end Data +end IndependentSetsCut.CounterMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Machine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Machine.lean new file mode 100644 index 0000000000000000000000000000000000000000..73cc02d0801c9abe72bde12299495994ca5abf23 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Machine.lean @@ -0,0 +1,302 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.Target +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Hastad.SourceMachine + +open Turing +open IndependentSetsGames.Foundations.Complexity + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def fieldLoop (source destination : K) (loopLabel : Λ) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.push destination (fun _ => true) (.goto fun _ => loopLabel)) + (.load (fun state => (state.1, none)) + (Reduction.MachineTransfer.exitAt destination exit))) + +def fieldStart (destination : K) (loopLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .push destination (fun _ => false) (.goto fun _ => loopLabel) + +def fieldTapes (source destination : K) (base : K → List Bool) + (input output : List Bool) : K → List Bool := + Function.update (Function.update base source input) destination output + +@[simp] theorem fieldTapes_source (source destination : K) (hne : source ≠ destination) + (base : K → List Bool) (input output : List Bool) : + fieldTapes source destination base input output source = input := by + simp [fieldTapes, hne] + +@[simp] theorem fieldTapes_destination (source destination : K) + (base : K → List Bool) (input output : List Bool) : + fieldTapes source destination base input output destination = output := by + simp [fieldTapes] + +@[simp] theorem fieldTapes_self (source destination : K) (base : K → List Bool) : + fieldTapes source destination base (base source) (base destination) = base := by + simp [fieldTapes] + +theorem fieldTapes_other (source destination p : K) + (hpS : p ≠ source) (hpD : p ≠ destination) + (base : K → List Bool) (input output : List Bool) : + fieldTapes source destination base input output p = base p := by + simp [fieldTapes, hpS, hpD] + +private theorem update_field_source (source destination : K) (hne : source ≠ destination) + (base : K → List Bool) (input output replacement : List Bool) : + Function.update (fieldTapes source destination base input output) source replacement = + fieldTapes source destination base replacement output := by + funext p + by_cases hs : p = source + · subst p; simp [fieldTapes, hne] + · by_cases hd : p = destination + · subst p; simp [fieldTapes, Ne.symm hne] + · simp [fieldTapes, hs, hd] + +private theorem update_field_destination (source destination : K) + (base : K → List Bool) (input output replacement : List Bool) : + Function.update (fieldTapes source destination base input output) destination replacement = + fieldTapes source destination base input replacement := by + simp [fieldTapes] + +theorem fieldStep_delimiter (source destination : K) (hne : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = fieldLoop source destination loopLabel exit) + (base : K → List Bool) (suffix output : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, register), fieldTapes source destination base (false :: suffix) output⟩ = + some ⟨exit, (ambient, none), fieldTapes source destination base suffix output⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (fieldTapes source destination base (false :: suffix) output)) = _ + rw [atLoop] + cases exit <;> + simp [fieldLoop, Reduction.MachineTransfer.exitAt, TM2.stepAux, hne, update_field_source] + +theorem fieldStep_true (source destination : K) (hne : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = fieldLoop source destination loopLabel exit) + (base : K → List Bool) (input output : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, register), fieldTapes source destination base (true :: input) output⟩ = + some ⟨some loopLabel, (ambient, some true), + fieldTapes source destination base input (true :: output)⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (fieldTapes source destination base (true :: input) output)) = _ + rw [atLoop] + simp [fieldLoop, TM2.stepAux, hne, update_field_source, update_field_destination] + +theorem fieldLoopTrace (source destination : K) (hne : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = fieldLoop source destination loopLabel exit) + (base : K → List Bool) (n : Nat) (suffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 1] + (some ⟨some loopLabel, (ambient, register), + fieldTapes source destination base (encodeWord n ++ suffix) output⟩) = + some ⟨exit, (ambient, none), + fieldTapes source destination base suffix (List.replicate n true ++ output)⟩ := by + induction n generalizing output register with + | zero => + simpa only [Nat.zero_add, Function.iterate_one, MachineComposition.advance_some, + encodeWord, List.replicate_zero, List.nil_append, List.singleton_append] using + fieldStep_delimiter source destination hne loopLabel exit program atLoop + base suffix output ambient register + | succ n ih => + rw [Function.iterate_succ_apply] + simp only [encodeWord, List.replicate_succ, List.cons_append] + change (MachineComposition.advance (TM2.step program))^[n + 1] + (TM2.step program ⟨some loopLabel, (ambient, register), + fieldTapes source destination base (true :: (encodeWord n ++ suffix)) output⟩) = _ + rw [fieldStep_true source destination hne loopLabel exit program atLoop, ih] + have hrotate : List.replicate n true ++ true :: output = + true :: (List.replicate n true ++ output) := by + calc + _ = (List.replicate n true ++ [true]) ++ output := by simp + _ = List.replicate (n + 1) true ++ output := by rw [List.replicate_succ'] + _ = _ := by rw [List.replicate_succ, List.cons_append] + rw [hrotate] + +theorem fieldStartStep (source destination : K) + (startLabel loopLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atStart : program startLabel = fieldStart destination loopLabel) + (base : K → List Bool) (input output : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some startLabel, (ambient, register), fieldTapes source destination base input output⟩ = + some ⟨some loopLabel, (ambient, register), + fieldTapes source destination base input (false :: output)⟩ := by + change some (TM2.stepAux (program startLabel) (ambient, register) + (fieldTapes source destination base input output)) = _ + rw [atStart] + simp [fieldStart, TM2.stepAux, update_field_destination] + +def fieldInTime (source destination : K) (hne : source ≠ destination) + (startLabel loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atStart : program startLabel = fieldStart destination loopLabel) + (atLoop : program loopLabel = fieldLoop source destination loopLabel exit) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (hinput : base source = encodeWord n ++ suffix) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some startLabel, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), + fieldTapes source destination base suffix (encodeWord n ++ base destination)⟩) + (n + 2) where + steps := n + 2 + evals_in_steps := by + have hbase : fieldTapes source destination base (encodeWord n ++ suffix) + (base destination) = base := by rw [← hinput, fieldTapes_self] + conv_lhs => rw [← hbase] + change (MachineComposition.advance (TM2.step program))^[(n + 1) + 1] + (some ⟨some startLabel, (ambient, register), + fieldTapes source destination base (encodeWord n ++ suffix) (base destination)⟩) = _ + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[n + 1] + (TM2.step program ⟨some startLabel, (ambient, register), + fieldTapes source destination base (encodeWord n ++ suffix) (base destination)⟩) = _ + rw [fieldStartStep source destination startLabel loopLabel program atStart, + fieldLoopTrace source destination hne loopLabel exit program atLoop] + simp [encodeWord, List.append_assoc] + steps_le_m := Nat.le_refl _ + +def afterField (source destination : K) (base : K → List Bool) + (n : Nat) (suffix : List Bool) : K → List Bool := + fieldTapes source destination base suffix (encodeWord n ++ base destination) + +def fieldNext (start : Fin 4 → Λ) (exit : Option Λ) (j : Fin 4) : Option Λ := + match j.val with + | 0 => some (start 1) + | 1 => some (start 2) + | 2 => some (start 3) + | _ => exit + +def fourTapes (source : K) (destination : Fin 4 → K) (base : K → List Bool) + (a b c d : Nat) (suffix : List Bool) : K → List Bool := + let t₀ := afterField source (destination 0) base a (encodeWords [b, c, d] ++ suffix) + let t₁ := afterField source (destination 1) t₀ b (encodeWords [c, d] ++ suffix) + let t₂ := afterField source (destination 2) t₁ c (encodeWords [d] ++ suffix) + afterField source (destination 3) t₂ d suffix + +theorem fourTapes_source (source : K) (destination : Fin 4 → K) + (hsep : ∀ j, source ≠ destination j) (base : K → List Bool) + (a b c d : Nat) (suffix : List Bool) : + fourTapes source destination base a b c d suffix source = suffix := by + simp [fourTapes, afterField, hsep] + +theorem fourTapes_other (source : K) (destination : Fin 4 → K) + (p : K) (hpS : p ≠ source) (hpD : ∀ j, p ≠ destination j) + (base : K → List Bool) (a b c d : Nat) (suffix : List Bool) : + fourTapes source destination base a b c d suffix p = base p := by + simp [fourTapes, afterField, fieldTapes_other, hpS, hpD] + +theorem fourField_time_eq_length (a b c d : Nat) : + a + b + c + d + 8 = (encodeWords [a, b, c, d]).length + 4 := by + simp [encodeWords, encodeWord] + omega + +def fourFieldsInTime (source : K) (destination : Fin 4 → K) + (hsep : ∀ j, source ≠ destination j) + (start loopLabel : Fin 4 → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atStart : ∀ j, program (start j) = fieldStart (destination j) (loopLabel j)) + (atLoop : ∀ j, program (loopLabel j) = + fieldLoop source (destination j) (loopLabel j) (fieldNext start exit j)) + (base : K → List Bool) (a b c d : Nat) (suffix : List Bool) + (hinput : base source = encodeWords [a, b, c, d] ++ suffix) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (start 0), (ambient, register), base⟩ + (some ⟨exit, (ambient, none), fourTapes source destination base a b c d suffix⟩) + (a + b + c + d + 8) := by + let t₀ := afterField source (destination 0) base a (encodeWords [b, c, d] ++ suffix) + let t₁ := afterField source (destination 1) t₀ b (encodeWords [c, d] ++ suffix) + let t₂ := afterField source (destination 2) t₁ c (encodeWords [d] ++ suffix) + have h₀ : base source = encodeWord a ++ (encodeWords [b, c, d] ++ suffix) := by + simpa only [encodeWords, List.append_assoc] using hinput + have h₁ : t₀ source = encodeWord b ++ (encodeWords [c, d] ++ suffix) := by + simp [t₀, afterField, hsep, encodeWords, List.append_assoc] + have h₂ : t₁ source = encodeWord c ++ (encodeWords [d] ++ suffix) := by + simp [t₁, afterField, hsep, encodeWords, List.append_assoc] + have h₃ : t₂ source = encodeWord d ++ suffix := by + simp [t₂, afterField, hsep, encodeWords] + have p₀ := fieldInTime source (destination 0) (hsep 0) (start 0) (loopLabel 0) + (some (start 1)) program (atStart 0) (atLoop 0) base a + (encodeWords [b, c, d] ++ suffix) h₀ ambient register + have p₁ := fieldInTime source (destination 1) (hsep 1) (start 1) (loopLabel 1) + (some (start 2)) program (atStart 1) (atLoop 1) t₀ b + (encodeWords [c, d] ++ suffix) h₁ ambient none + have p₂ := fieldInTime source (destination 2) (hsep 2) (start 2) (loopLabel 2) + (some (start 3)) program (atStart 2) (atLoop 2) t₁ c + (encodeWords [d] ++ suffix) h₂ ambient none + have p₃ := fieldInTime source (destination 3) (hsep 3) (start 3) (loopLabel 3) + exit program (atStart 3) (atLoop 3) t₂ d suffix h₃ ambient none + let p₀₁ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀ p₁ + let p₀₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀₁ p₂ + let p := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ p₀₁₂ p₃ + exact { + toEvalsTo := p.toEvalsTo + steps_le_m := by have h := p.steps_le_m; omega + } + +def fieldDestination (j : Fin 4) : Fin 5 := ⟨j.val + 1, by omega⟩ + +theorem fourTapes_concrete (base : Fin 5 → List Bool) (a b c d : Nat) (suffix : List Bool) : + fourTapes 0 fieldDestination base a b c d suffix = + fun p : Fin 5 => if p = 0 then suffix + else if p = 1 then encodeWord a ++ base 1 + else if p = 2 then encodeWord b ++ base 2 + else if p = 3 then encodeWord c ++ base 3 + else encodeWord d ++ base 4 := by + funext p + have hp : p = 0 ∨ p = 1 ∨ p = 2 ∨ p = 3 ∨ p = 4 := by omega + rcases hp with rfl | rfl | rfl | rfl | rfl <;> + simp [fourTapes, afterField, fieldTapes, fieldDestination] + +def groupingProgram (label : Fin 4 × Bool) : + TM2.Stmt (fun _ : Fin 5 => Bool) (Fin 4 × Bool) (Unit × Option Bool) := + if label.2 then + fieldLoop 0 (fieldDestination label.1) (label.1, true) + (fieldNext (fun j => (j, false)) none label.1) + else fieldStart (fieldDestination label.1) (label.1, true) + +def groupingMachine : FinTM2 where + K := Fin 5 + k₀ := 0 + k₁ := 1 + Γ _ := Bool + Λ := Fin 4 × Bool + main := (0, false) + σ := Unit × Option Bool + initialState := ((), none) + m := groupingProgram + +def groupingMachineInTime (base : Fin 5 → List Bool) (a b c d : Nat) (suffix : List Bool) + (hinput : base 0 = encodeWords [a, b, c, d] ++ suffix) (register : Option Bool) : + StateTransition.EvalsToInTime groupingMachine.step + ⟨some (0, false), ((), register), base⟩ + (some ⟨none, ((), none), fourTapes (0 : Fin 5) fieldDestination base a b c d suffix⟩) + (a + b + c + d + 8) := + fourFieldsInTime (0 : Fin 5) fieldDestination (by + intro j h + have hh := congrArg Fin.val h + change 0 = j.val + 1 at hh + omega) + (fun j => (j, false)) (fun j => (j, true)) none groupingProgram + (by intro j; simp [groupingProgram]) (by intro j; simp [groupingProgram]) + base a b c d suffix hinput () register + +end IndependentSetsGames.Foundations.Hastad.SourceMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Machine2.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Machine2.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0e2c86d317020424fdba6bb70ce87da4d8b39a0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Machine2.lean @@ -0,0 +1,187 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLabels +import OAI.Combinatorics.IndependentSets.Encoding.FormulaEncoding +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingPaddingOffsets +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity + +def naturalWordsEncoding : Computability.Encoding (List Nat) Bool where + encode := encodeWords + decode := decodeWords + decode_encode := decodeWords_encodeWords + +def formulaEncoding : Computability.Encoding Target.Formula Bool where + encode := formulaBits + decode := decodeFormulaBits + decode_encode := decodeFormulaBits_encoded + +def gameEncoding (alphabet : Nat) : Computability.Encoding (Target.Instance alphabet) Bool where + encode := gameBits + decode := decodeGameBits alphabet + decode_encode := decodeGameBits_encoded + +def prefixBitMachine (bit : Bool) : Turing.FinTM2 where + K := Unit + k₀ := () + k₁ := () + Γ _ := Bool + Λ := Unit + main := () + σ := Unit + initialState := () + m _ := .push () (fun _ => bit) .halt + +noncomputable def prefixBitPolyTime (bit : Bool) : + Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) id (bit :: ·) where + tm := prefixBitMachine bit + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := 1 + outputsFun bs := { + steps := 1 + evals_in_steps := by + change some (Turing.TM2.stepAux (.push () (fun _ => bit) .halt) () + (fun _ : Unit => bs.map id)) = + some { l := none, var := (), stk := fun _ : Unit => (bit :: bs).map id } + simp [Turing.TM2.stepAux] + funext k + cases k + rfl + steps_le_m := by simp + } + +def enlargePolynomialBound {α β αΓ βΓ : Type} + {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β} + (certificate : Turing.TM2ComputableInPolyTime ea eb f) + (bound : Polynomial Nat) + (larger : ∀ n, certificate.time.eval n ≤ bound.eval n) : + Turing.TM2ComputableInPolyTime ea eb f where + toTM2ComputableAux := certificate.toTM2ComputableAux + time := bound + outputsFun a := { + toEvalsTo := (certificate.outputsFun a).toEvalsTo + steps_le_m := Nat.le_trans (certificate.outputsFun a).steps_le_m (larger _) + } + +def composeMachinePhases {σ : Type} (step : σ → Option σ) + (start intermediate : σ) (finish : Option σ) + (p q : Polynomial Nat) (inputLength : Nat) + (first : StateTransition.EvalsToInTime step start (some intermediate) (p.eval inputLength)) + (second : StateTransition.EvalsToInTime step intermediate finish (q.eval inputLength)) : + StateTransition.EvalsToInTime step start finish ((p + q).eval inputLength) := by + have composed := StateTransition.EvalsToInTime.trans step (p.eval inputLength) + (q.eval inputLength) start intermediate finish first second + simpa only [Polynomial.eval_add, Nat.add_comm] using composed + +open Target + +structure PolynomialGapReduction + (completenessError soundnessError : RationalError) + extends SemanticGapReduction completenessError soundnessError where + computation : Turing.TM2ComputableInPolyTime formulaEncoding.encode + (gameEncoding alphabet).encode reduce + +end IndependentSetsGames.Foundations.Complexity + +namespace IndependentSetsGames.Foundations.PCP.PreprocessingMachineBounds +open PreprocessingRegularTables PreprocessingCloudIndex +open IndependentSetsGames.Foundations.Complexity +open scoped BigOperators + +def inputLength (t : GraphTables.Table) : Nat := (GraphTables.tableBits t).length + +theorem cloudSize_le_input (t : GraphTables.Table) (v : Fin t.vertices) : + cloudSize t v ≤ inputLength t := + (cloudSize_le_darts t v).trans (GraphTables.darts_le_tableBits_length t) + +theorem cloudTotal_le_input (t : GraphTables.Table) (v : Fin t.vertices) : + cloudSize t v + padding t v ≤ ExpanderFamily.growth * inputLength t := by + rw [cloudSize_add_padding] + exact (PreprocessingLevels.cloudPaddedSize_bounds _).2.trans + (Nat.mul_le_mul_left _ (cloudSize_le_input t v)) + +theorem level_le_input (t : GraphTables.Table) (v : Fin t.vertices) : + PreprocessingLevels.boundedLevel (cloudSize t v) ≤ inputLength t := + (PreprocessingLevels.boundedLevel_le_input _).trans (cloudSize_le_input t v) + +theorem regularVertices_le_input (t : GraphTables.Table) : + vertexCount t (padding t) ≤ ExpanderFamily.growth * inputLength t := + (vertexCount_le t).trans + (Nat.mul_le_mul_left _ (GraphTables.darts_le_tableBits_length t)) + +theorem offset_le_sum {n : Nat} (p : Fin n → Nat) (k : Nat) : + PreprocessingPaddingOffsets.offset p k ≤ ∑ v, p v := by + have hfull : (List.finRange n).take n = List.finRange n := by simp + have hsplit : PreprocessingPaddingOffsets.offset p k + + (((List.finRange n).drop k).map p).sum = + PreprocessingPaddingOffsets.offset p n := by + simp only [PreprocessingPaddingOffsets.offset, hfull] + rw [← List.sum_append, ← List.map_append, List.take_append_drop] + rw [PreprocessingPaddingOffsets.offset_all] at hsplit + omega + +theorem prefix_le_input (t : GraphTables.Table) (k : Nat) : + PreprocessingPaddingOffsets.offset (padding t) k ≤ + ExpanderFamily.growth * inputLength t := by + have hsum : (∑ v, padding t v) ≤ vertexCount t (padding t) := by + unfold vertexCount + omega + exact (offset_le_sum (padding t) k).trans (hsum.trans (regularVertices_le_input t)) + +noncomputable def tablePolynomial (a b : Nat) : Polynomial Nat := + Polynomial.C a * Polynomial.X + Polynomial.C b * Polynomial.X + 2 + + (Polynomial.C b * Polynomial.X) * + (Polynomial.C a * Polynomial.X + Polynomial.C b * Polynomial.X + 8192) + +theorem tableBits_le_of_counts (t : GraphTables.Table) (a b L : Nat) + (hv : t.vertices ≤ a * L) (he : t.darts ≤ b * L) : + (GraphTables.tableBits t).length ≤ (tablePolynomial a b).eval L := by + have hsum := Nat.add_le_add hv he + have hprod := Nat.mul_le_mul he (Nat.add_le_add_right hsum 8192) + have h := (GraphTables.tableBits_length_le t).trans + (Nat.add_le_add (Nat.add_le_add_right hsum 2) hprod) + simpa only [tablePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat] using h + +noncomputable def regularPolynomial : Polynomial Nat := + tablePolynomial ExpanderFamily.growth (ExpanderFamily.growth * (internalDegree + 1)) + +theorem regularBits_le (H : BaseTable) (t : GraphTables.Table) : + (PortTables.tableBits (regularize H t)).length ≤ + regularPolynomial.eval (inputLength t) := by + have hv : (PortTables.graphTable (regularize H t)).vertices ≤ + ExpanderFamily.growth * inputLength t := regularVertices_le_input t + have he : (PortTables.graphTable (regularize H t)).darts ≤ + (ExpanderFamily.growth * (internalDegree + 1)) * inputLength t := by + change vertexCount t (padding t) * (internalDegree + 1) ≤ _ + calc + _ ≤ (ExpanderFamily.growth * inputLength t) * (internalDegree + 1) := + Nat.mul_le_mul_right _ hv + _ = _ := by ac_rfl + exact tableBits_le_of_counts (PortTables.graphTable (regularize H t)) _ _ _ hv he + +noncomputable def rotorPolynomial (q : Nat) : Polynomial Nat := + (Polynomial.C (ExpanderFamily.growth * q) * Polynomial.X) * + (Polynomial.C (ExpanderFamily.growth * q) * Polynomial.X + 1) + +theorem cloudRotorBits_le (t : GraphTables.Table) (v : Fin t.vertices) {q : Nat} + (table : ExpanderTables.Table (cloudSize t v + padding t v) q) : + (encodeWords (ExpanderTableWords.rotationWords table)).length ≤ + (rotorPolynomial q).eval (inputLength t) := by + have hd : (cloudSize t v + padding t v) * q ≤ + (ExpanderFamily.growth * q) * inputLength t := by + calc + _ ≤ (ExpanderFamily.growth * inputLength t) * q := + Nat.mul_le_mul_right _ (cloudTotal_le_input t v) + _ = _ := by ac_rfl + have h := (ExpanderTableWords.encode_rotationWords_length_le table).trans + (Nat.mul_le_mul hd (Nat.add_le_add_right hd 1)) + simpa only [rotorPolynomial, Polynomial.eval_mul, Polynomial.eval_add, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_one] using h + +end IndependentSetsGames.Foundations.PCP.PreprocessingMachineBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAffineLookup.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAffineLookup.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3d81d59245ce37527525a39c0275ff452acf0f7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAffineLookup.lean @@ -0,0 +1,133 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAffine +import OAI.Combinatorics.IndependentSets.Machines.MachineSubroutine + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineAffineLookup + +open Turing +open MachineComposition + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +inductive Label + | seed | scan | restore | copyFirst | copySecond + | lookup (l : MachineLookup.Label) + deriving DecidableEq, Fintype + +def instruction (source : K) (tape : Fin 5 → K) (coefficient offset : Nat) + (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .seed => MachineUnaryAffineAt.seed (tape 1) offset (labels .scan) + | .scan => MachineUnaryAffineAt.scan source (tape 4) (tape 1) + coefficient (labels .scan) (labels .restore) + | .restore => Reduction.MachineTransfer.loopAt (tape 4) source id false + (labels .restore) (some (labels .copyFirst)) + | .copyFirst => Reduction.MachineTransfer.loopAt (tape 0) (tape 4) id false + (labels .copyFirst) (some (labels .copySecond)) + | .copySecond => MachineCopy.forkLoop (tape 4) (tape 0) (tape 2) false + (labels .copySecond) (some (labels (.lookup .guard))) + | .lookup l => MachineSubroutine.statement (fun q => labels (.lookup q)) exit + (MachineLookup.program (tape 1) (tape 2) (tape 3) l) + +def steps (values : List Nat) (a coefficient offset : Nat) : Nat := + (2 * (a + 1) + 1) + + (2 * ((encodeWords values).length + 1) + + MachineLookupSpec.steps values (coefficient * a + offset) + 1) + +def finalTapes (tape : Fin 5 → K) (base : K → List Bool) + (values : List Nat) (index value : Nat) : K → List Bool := + MachinePreservingLookup.finalTapes tape base values index value + (base (tape 1)) (base (tape 2)) (base (tape 3)) + +theorem initialTapes_eq_update (tape : Fin 5 → K) (distinct : Function.Injective tape) + (base : K → List Bool) (i : Nat) : + MachinePreservingLookup.initialTapes tape base i + (base (tape 1)) (base (tape 2)) (base (tape 3)) = + Function.update base (tape 1) (encodeWord i ++ base (tape 1)) := by + have hd (a b : Fin 5) (hne : a ≠ b) : tape a ≠ tape b := fun h => hne (distinct h) + funext k + by_cases h₁ : k = tape 1 + · subst k + simp [MachinePreservingLookup.initialTapes, MachineLookup.tapes, + hd 1 2 (by decide), hd 1 3 (by decide)] + · by_cases h₂ : k = tape 2 + · subst k + simp [MachinePreservingLookup.initialTapes, MachineLookup.tapes, h₁, + hd 2 3 (by decide)] + · by_cases h₃ : k = tape 3 + · subst k + simp [MachinePreservingLookup.initialTapes, MachineLookup.tapes, h₁] + · simp [MachinePreservingLookup.initialTapes, MachineLookup.tapes, h₁, h₂, h₃] + +theorem affineLookupTrace (source : K) (tape : Fin 5 → K) + (distinct : Function.Injective tape) (outside : ∀ i, source ≠ tape i) + (coefficient offset : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ l, program (labels l) = instruction source tape coefficient offset labels exit l) + (base : K → List Bool) (values : List Nat) + (tableWord : base (tape 0) = encodeWords values) (scratchEmpty : base (tape 4) = []) + (a : Nat) (suffix : List Bool) (sourceWord : base source = encodeWord a ++ suffix) + (value : Nat) (selected : values[coefficient * a + offset]? = some value) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps values a coefficient offset] + (some ⟨some (labels .seed), (ambient,register), base⟩) = + some ⟨exit, (ambient,none), finalTapes tape base values (coefficient * a + offset) value⟩ := by + have hd (i j : Fin 5) (hne : i ≠ j) : tape i ≠ tape j := fun h => hne (distinct h) + have haffine := MachineUnaryAffineAt.seededAffineTrace source (tape 4) (tape 1) + (outside 4) (outside 1) (hd 4 1 (by decide)) coefficient offset + (labels .seed) (labels .scan) (labels .restore) (some (labels .copyFirst)) + program (atLabels .seed) (atLabels .scan) (atLabels .restore) + base a suffix sourceWord scratchEmpty ambient register + have hlookup := MachinePreservingLookup.preservingLookupTrace tape distinct + (labels .copyFirst) (labels .copySecond) (fun q => labels (.lookup q)) exit + program (atLabels .copyFirst) (atLabels .copySecond) (fun q => atLabels (.lookup q)) + base values tableWord scratchEmpty (coefficient * a + offset) value selected + (base (tape 1)) (base (tape 2)) (base (tape 3)) ambient none + rw [initialTapes_eq_update tape distinct] at hlookup + rw [steps, Nat.add_comm, Function.iterate_add_apply, haffine] + exact hlookup + +theorem steps_le (values : List Nat) (a coefficient offset value : Nat) + (selected : values[coefficient * a + offset]? = some value) : + steps values a coefficient offset ≤ 2 * a + 5 * (encodeWords values).length + 6 := by + have h := MachinePreservingLookup.preservingLookup_steps_le values + (coefficient * a + offset) value selected + unfold steps + omega + +theorem steps_le_table (values : List Nat) (a coefficient offset value : Nat) + (selected : values[coefficient * a + offset]? = some value) + (ha : a ≤ (encodeWords values).length) : + steps values a coefficient offset ≤ 7 * (encodeWords values).length + 6 := by + have h := steps_le values a coefficient offset value selected + omega + +theorem finalTapes_other (tape : Fin 5 → K) (base : K → List Bool) + (values : List Nat) (index value : Nat) (k : K) + (h₁ : k ≠ tape 1) (h₂ : k ≠ tape 2) (h₃ : k ≠ tape 3) : + finalTapes tape base values index value k = base k := + MachineLookup.tapes_other _ _ _ _ h₁ h₂ h₃ _ _ _ _ + +theorem finalTapes_output (tape : Fin 5 → K) (base : K → List Bool) + (values : List Nat) (index value : Nat) : + finalTapes tape base values index value (tape 3) = encodeWord value ++ base (tape 3) := + MachineLookup.tapes_destination _ _ _ _ _ _ _ + +def machine (coefficient offset : Nat) : FinTM2 where + K := Fin 6 + k₀ := 0 + k₁ := 4 + Γ _ := Bool + Λ := Label + main := .seed + σ := Unit × Option Bool + initialState := ((),none) + m := instruction 0 Fin.succ coefficient offset id none + +end IndependentSetsGames.Foundations.Complexity.MachineAffineLookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAlphabetTransport.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAlphabetTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4266c50646ed1479812343932c563f4ced3dfcc --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAlphabetTransport.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineAlphabetTransport + +open Turing.TM2 + +variable {K Λ σ : Type} {Γ Δ : K → Type} + +def tapes (h : Γ = Δ) (source : ∀ k, List (Γ k)) : ∀ k, List (Δ k) := h ▸ source + +def statement (h : Γ = Δ) (source : Stmt Γ Λ σ) : Stmt Δ Λ σ := h ▸ source + +def configuration (h : Γ = Δ) (source : Cfg Γ Λ σ) : Cfg Δ Λ σ := h ▸ source + +def program (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) : Λ → Stmt Δ Λ σ := + fun label => statement h (source label) + +abbrev castStatement (h : Γ = Δ) (source : Stmt Γ Λ σ) : Stmt Δ Λ σ := statement h source +abbrev castConfiguration (h : Γ = Δ) (source : Cfg Γ Λ σ) : Cfg Δ Λ σ := configuration h source +abbrev castProgram (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) : Λ → Stmt Δ Λ σ := program h source + +@[simp] theorem tapes_rfl (source : ∀ k, List (Γ k)) : tapes rfl source = source := rfl +@[simp] theorem statement_rfl (source : Stmt Γ Λ σ) : statement rfl source = source := rfl +@[simp] theorem configuration_rfl (source : Cfg Γ Λ σ) : configuration rfl source = source := rfl +@[simp] theorem program_rfl (source : Λ → Stmt Γ Λ σ) : program rfl source = source := rfl + +@[simp] theorem program_apply (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) (label : Λ) : + program h source label = statement h (source label) := rfl + +@[simp] theorem statement_roundtrip (h : Γ = Δ) (source : Stmt Δ Λ σ) : + statement h (statement h.symm source) = source := by cases h; rfl + +@[simp] theorem statement_symm_roundtrip (h : Γ = Δ) (source : Stmt Γ Λ σ) : + statement h.symm (statement h source) = source := by cases h; rfl + +@[simp] theorem configuration_roundtrip (h : Γ = Δ) (source : Cfg Δ Λ σ) : + configuration h (configuration h.symm source) = source := by cases h; rfl + +@[simp] theorem configuration_symm_roundtrip (h : Γ = Δ) (source : Cfg Γ Λ σ) : + configuration h.symm (configuration h source) = source := by cases h; rfl + +@[simp] theorem program_roundtrip (h : Γ = Δ) (source : Λ → Stmt Δ Λ σ) : + program h (program h.symm source) = source := by cases h; rfl + +@[simp] theorem program_symm_roundtrip (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) : + program h.symm (program h source) = source := by cases h; rfl + +@[simp] theorem tapes_roundtrip (h : Γ = Δ) (source : ∀ k, List (Δ k)) : + tapes h (tapes h.symm source) = source := by cases h; rfl + +@[simp] theorem tapes_symm_roundtrip (h : Γ = Δ) (source : ∀ k, List (Γ k)) : + tapes h.symm (tapes h source) = source := by cases h; rfl + +@[simp] theorem configuration_label (h : Γ = Δ) (source : Cfg Γ Λ σ) : + (configuration h source).l = source.l := by cases h; rfl + +@[simp] theorem configuration_state (h : Γ = Δ) (source : Cfg Γ Λ σ) : + (configuration h source).var = source.var := by cases h; rfl + +@[simp] theorem configuration_tapes (h : Γ = Δ) (source : Cfg Γ Λ σ) : + (configuration h source).stk = tapes h source.stk := by cases h; rfl + +@[simp] theorem configuration_mk (h : Γ = Δ) (label : Option Λ) (state : σ) + (source : ∀ k, List (Γ k)) : + configuration h ⟨label, state, source⟩ = ⟨label, state, tapes h source⟩ := by cases h; rfl + +@[simp] theorem map_configuration_rfl (source : Option (Cfg Γ Λ σ)) : + source.map (configuration (rfl : Γ = Γ)) = source := by cases source <;> rfl + +variable [DecidableEq K] + +theorem stepAux_simulation (h : Γ = Δ) (source : Stmt Γ Λ σ) (state : σ) + (sourceTapes : ∀ k, List (Γ k)) : + stepAux (statement h source) state (tapes h sourceTapes) = + configuration h (stepAux source state sourceTapes) := by cases h; rfl + +theorem step_simulation (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) (start : Cfg Γ Λ σ) : + step (program h source) (configuration h start) = + (step source start).map (configuration h) := by + cases h + simp only [program_rfl, configuration_rfl, map_configuration_rfl] + +theorem trace_transport (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) + (n : Nat) (start : Option (Cfg Γ Λ σ)) : + (MachineComposition.advance (step (program h source)))^[n] + (start.map (configuration h)) = + ((MachineComposition.advance (step source))^[n] start).map (configuration h) := by + cases h + simp only [program_rfl, map_configuration_rfl] + +theorem successfulTrace (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) + (n : Nat) (start finish : Cfg Γ Λ σ) + (trace : (MachineComposition.advance (step source))^[n] (some start) = some finish) : + (MachineComposition.advance (step (program h source)))^[n] + (some (configuration h start)) = some (configuration h finish) := by + have transported := trace_transport h source n (some start) + simpa only [Option.map_some, trace] using transported + +def executionInTime (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) + {start : Cfg Γ Λ σ} {finish : Option (Cfg Γ Λ σ)} {budget : Nat} + (execution : StateTransition.EvalsToInTime (step source) start finish budget) : + StateTransition.EvalsToInTime (step (program h source)) (configuration h start) + (finish.map (configuration h)) budget where + steps := execution.steps + evals_in_steps := by + cases h + simpa only [program_rfl, configuration_rfl, map_configuration_rfl] + using execution.evals_in_steps + steps_le_m := execution.steps_le_m + +@[simp] theorem executionInTime_steps (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) + {start : Cfg Γ Λ σ} {finish : Option (Cfg Γ Λ σ)} {budget : Nat} + (execution : StateTransition.EvalsToInTime (step source) start finish budget) : + (executionInTime h source execution).steps = execution.steps := rfl + +def successfulExecutionInTime (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) + {start finish : Cfg Γ Λ σ} {budget : Nat} + (execution : StateTransition.EvalsToInTime (step source) start (some finish) budget) : + StateTransition.EvalsToInTime (step (program h source)) (configuration h start) + (some (configuration h finish)) budget := executionInTime h source execution + +@[simp] theorem successfulExecutionInTime_steps (h : Γ = Δ) (source : Λ → Stmt Γ Λ σ) + {start finish : Cfg Γ Λ σ} {budget : Nat} + (execution : StateTransition.EvalsToInTime (step source) start (some finish) budget) : + (successfulExecutionInTime h source execution).steps = execution.steps := rfl + +end IndependentSetsGames.Foundations.Complexity.MachineAlphabetTransport + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAppend.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAppend.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eff119a91b5ccb4a9348207b89b532fd7322393 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineAppend.lean @@ -0,0 +1,165 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.PatternInvariant +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineAppendAt + +open Turing + +variable {K Λ σ β : Type} [DecidableEq K] + +abbrev Alphabet (β : Type) (_ : K) := β + +def appendTapes (source destination : K) (base : K → List β) : K → List β := + Reduction.MachineTransfer.tapesAt source destination base [] + (base destination ++ base source) + +@[simp] theorem appendTapes_source (source destination : K) + (distinct : source ≠ destination) (base : K → List β) : + appendTapes source destination base source = [] := by + simp [appendTapes, distinct] + +@[simp] theorem appendTapes_destination (source destination : K) (base : K → List β) : + appendTapes source destination base destination = base destination ++ base source := by + simp [appendTapes] + +theorem appendTapes_other (source destination k : K) + (notSource : k ≠ source) (notDestination : k ≠ destination) (base : K → List β) : + appendTapes source destination base k = base k := by + simp [appendTapes, Reduction.MachineTransfer.tapesAt, notSource, notDestination] + +theorem appendTapes_scratch (source destination scratch : K) + (sourceScratch : source ≠ scratch) (destinationScratch : destination ≠ scratch) + (base : K → List β) (scratchEmpty : base scratch = []) : + appendTapes source destination base scratch = [] := by + rw [appendTapes_other source destination scratch (Ne.symm sourceScratch) + (Ne.symm destinationScratch) base, scratchEmpty] + +def firstTapes (destination scratch : K) (base : K → List β) : K → List β := + Reduction.MachineTransfer.tapesAt destination scratch base [] (base destination).reverse + +private def secondTapes (source destination scratch : K) (base : K → List β) : K → List β := + Reduction.MachineTransfer.tapesAt source scratch (firstTapes destination scratch base) [] + ((base source).reverse ++ (base destination).reverse) + +theorem finalTapes_eq (source destination scratch : K) + (sourceDestination : source ≠ destination) (sourceScratch : source ≠ scratch) + (destinationScratch : destination ≠ scratch) (base : K → List β) + (scratchEmpty : base scratch = []) : + Reduction.MachineTransfer.tapesAt scratch destination + (secondTapes source destination scratch base) [] (base destination ++ base source) = + appendTapes source destination base := by + funext k + by_cases hs : k = source + · subst k + simp [appendTapes, secondTapes, firstTapes, Reduction.MachineTransfer.tapesAt, + sourceDestination, sourceScratch] + · by_cases hd : k = destination + · subst k + simp [appendTapes, Reduction.MachineTransfer.tapesAt] + · by_cases ht : k = scratch + · subst k + simp [appendTapes, Reduction.MachineTransfer.tapesAt, Ne.symm sourceScratch, + Ne.symm destinationScratch, scratchEmpty] + · simp [appendTapes, secondTapes, firstTapes, Reduction.MachineTransfer.tapesAt, + hs, hd, ht] + +theorem appendTrace (source destination scratch : K) + (sourceDestination : source ≠ destination) (sourceScratch : source ≠ scratch) + (destinationScratch : destination ≠ scratch) + (fallback : β) (firstLabel secondLabel thirdLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atFirst : program firstLabel = Reduction.MachineTransfer.loopAt destination scratch + id fallback firstLabel (some secondLabel)) + (atSecond : program secondLabel = Reduction.MachineTransfer.loopAt source scratch + id fallback secondLabel (some thirdLabel)) + (atThird : program thirdLabel = Reduction.MachineTransfer.loopAt scratch destination + id fallback thirdLabel exit) + (base : K → List β) (scratchEmpty : base scratch = []) + (ambient : σ) (register : Option β) : + (MachineComposition.advance (TM2.step program))^[ + 2 * ((base source).length + (base destination).length) + 3] + (some ⟨some firstLabel, (ambient, register), base⟩) = + some ⟨exit, (ambient, none), appendTapes source destination base⟩ := by + have first := Reduction.MachineTransfer.transferAt_fromTapes destination scratch + destinationScratch id fallback firstLabel (some secondLabel) program atFirst + base ambient register + change (MachineComposition.advance (TM2.step program))^[(base destination).length + 1] + (some ⟨some firstLabel, (ambient, register), base⟩) = _ at first + simp only [List.map_id, scratchEmpty, List.append_nil] at first + change (MachineComposition.advance (TM2.step program))^[(base destination).length + 1] + (some ⟨some firstLabel, (ambient, register), base⟩) = + some ⟨some secondLabel, (ambient, none), firstTapes destination scratch base⟩ at first + have firstSource : firstTapes destination scratch base source = base source := by + simp [firstTapes, Reduction.MachineTransfer.tapesAt, sourceDestination, sourceScratch] + have firstScratch : firstTapes destination scratch base scratch = + (base destination).reverse := by + simp [firstTapes] + have second := Reduction.MachineTransfer.transferAt_fromTapes source scratch + sourceScratch id fallback secondLabel (some thirdLabel) program atSecond + (firstTapes destination scratch base) ambient none + change (MachineComposition.advance (TM2.step program))^[ + (firstTapes destination scratch base source).length + 1] + (some ⟨some secondLabel, (ambient, none), firstTapes destination scratch base⟩) = _ + at second + rw [firstSource, firstScratch] at second + simp only [List.map_id] at second + change (MachineComposition.advance (TM2.step program))^[(base source).length + 1] + (some ⟨some secondLabel, (ambient, none), firstTapes destination scratch base⟩) = + some ⟨some thirdLabel, (ambient, none), secondTapes source destination scratch base⟩ + at second + have secondScratch : secondTapes source destination scratch base scratch = + (base source).reverse ++ (base destination).reverse := by + simp [secondTapes] + have secondDestination : secondTapes source destination scratch base destination = [] := by + simp [secondTapes, firstTapes, Reduction.MachineTransfer.tapesAt, + Ne.symm sourceDestination, destinationScratch] + have third := Reduction.MachineTransfer.transferAt_fromTapes scratch destination + (Ne.symm destinationScratch) id fallback thirdLabel exit program atThird + (secondTapes source destination scratch base) ambient none + change (MachineComposition.advance (TM2.step program))^[ + (secondTapes source destination scratch base scratch).length + 1] + (some ⟨some thirdLabel, (ambient, none), secondTapes source destination scratch base⟩) = _ + at third + rw [secondScratch, secondDestination] at third + simp only [List.map_id, List.reverse_append, List.reverse_reverse, List.append_nil, + List.length_append, List.length_reverse] at third + rw [finalTapes_eq source destination scratch sourceDestination sourceScratch + destinationScratch base scratchEmpty] at third + rw [show 2 * ((base source).length + (base destination).length) + 3 = + ((base source).length + (base destination).length + 1) + + (((base source).length + 1) + ((base destination).length + 1)) by omega] + rw [Function.iterate_add_apply] + rw [Function.iterate_add_apply (m := (base source).length + 1) + (n := (base destination).length + 1), first, second] + exact third + +def appendInTime (source destination scratch : K) + (sourceDestination : source ≠ destination) (sourceScratch : source ≠ scratch) + (destinationScratch : destination ≠ scratch) + (fallback : β) (firstLabel secondLabel thirdLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atFirst : program firstLabel = Reduction.MachineTransfer.loopAt destination scratch + id fallback firstLabel (some secondLabel)) + (atSecond : program secondLabel = Reduction.MachineTransfer.loopAt source scratch + id fallback secondLabel (some thirdLabel)) + (atThird : program thirdLabel = Reduction.MachineTransfer.loopAt scratch destination + id fallback thirdLabel exit) + (base : K → List β) (scratchEmpty : base scratch = []) + (ambient : σ) (register : Option β) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some firstLabel, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), appendTapes source destination base⟩) + (2 * ((base source).length + (base destination).length) + 3) where + steps := 2 * ((base source).length + (base destination).length) + 3 + evals_in_steps := appendTrace source destination scratch sourceDestination sourceScratch + destinationScratch fallback firstLabel secondLabel thirdLabel exit program atFirst + atSecond atThird base scratchEmpty ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineAppendAt + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCeilingPower.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCeilingPower.lean new file mode 100644 index 0000000000000000000000000000000000000000..b78aa4b4fd93082c65b5935279c9e85dcfb397b2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCeilingPower.lean @@ -0,0 +1,488 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingLevels +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryCounter +import OAI.Combinatorics.IndependentSets.Machines.PushWord +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCeilingPower + +open Turing +open MachineComposition +open IndependentSetsGames.Foundations.PCP + +inductive Tape + | input | work | power | saved | level | fuel | spare | product + deriving DecidableEq + +instance : Fintype Tape where + elems := {.input, .work, .power, .saved, .level, .fuel, .spare, .product} + complete value := by cases value <;> simp + +inductive Label + | init | fuelFirst | fuelSecond | guard | copyFirst | copySecond + | compare | restore | decide | scale | transfer | cleanup + deriving DecidableEq + +instance : Fintype Label where + elems := {.init, .fuelFirst, .fuelSecond, .guard, .copyFirst, .copySecond, .compare, .restore, + .decide, .scale, .transfer, .cleanup} + complete value := by cases value <;> simp + +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := (σ × Bool) × Option Bool + +def memory (input work power saved level fuel spare product : List Bool) : Tape → List Bool + | .input => input + | .work => work + | .power => power + | .saved => saved + | .level => level + | .fuel => fuel + | .spare => spare + | .product => product + +@[simp] theorem update_work (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .work x = memory a x c d e f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_power (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .power x = memory a b x d e f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_saved (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .saved x = memory a b c x e f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_level (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .level x = memory a b c d x f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_fuel (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .fuel x = memory a b c d e x g h := by + funext k; cases k <;> rfl +@[simp] theorem update_product (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .product x = memory a b c d e f g x := by + funext k; cases k <;> rfl + +variable {σ : Type} + +def compareLoop : TM2.Stmt Alphabet Label (State σ) := + .pop .work (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.peek .power (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.pop .power (fun state _ => (state.1, none)) + (.push .saved (fun _ => true) (.goto fun _ => .compare))) + (.load (fun state => ((state.1.1, true), none)) (.goto fun _ => .compare)))) + (.load (fun state => (state.1, none)) (.goto fun _ => .restore))) + +def scaleLoop (g : Nat) : TM2.Stmt Alphabet Label (State σ) := + .pop .power (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (Reduction.MachineSubstitution.pushWord .product (List.replicate g true) + (.goto fun _ => .scale)) + (.push .power (fun _ => false) + (.push .level (fun _ => true) + (.load (fun state => (state.1, none)) (.goto fun _ => .transfer))))) + +def program (g : Nat) : Label → TM2.Stmt Alphabet Label (State σ) + | .init => .push .power (fun _ => false) (.push .power (fun _ => true) + (.push .level (fun _ => false) (.goto fun _ => .fuelFirst))) + | .fuelFirst => Reduction.MachineTransfer.loopAt + .input .spare id false .fuelFirst (some .fuelSecond) + | .fuelSecond => MachineCopy.forkLoop + .spare .input .fuel false .fuelSecond (some .guard) + | .guard => MachineUnaryCounter.guard .fuel .copyFirst .cleanup + | .copyFirst => Reduction.MachineTransfer.loopAt + .input .spare id false .copyFirst (some .copySecond) + | .copySecond => MachineCopy.forkLoop + .spare .input .work false .copySecond (some .compare) + | .compare => compareLoop + | .restore => Reduction.MachineTransfer.loopAt + .saved .power id false .restore (some .decide) + | .decide => .branch (fun state => state.1.2) + (.load (fun state => ((state.1.1, false), none)) (.goto fun _ => .scale)) + (.load (fun state => ((state.1.1, false), none)) (.goto fun _ => .cleanup)) + | .scale => scaleLoop g + | .transfer => Reduction.MachineTransfer.loopAt + .product .power id false .transfer (some .guard) + | .cleanup => MachineDrain.drain .fuel .cleanup none + +def overflow (flag : Bool) (x p : Nat) : Bool := flag || decide (p < x) + +theorem compareStep_zero (g p : Nat) (input saved level fuel spare product : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step (program g) + ⟨some .compare, ((ambient, flag), register), + memory input (encodeWord 0) (encodeWord p) saved level fuel spare product⟩ = + some ⟨some .restore, ((ambient, flag), none), + memory input [] (encodeWord p) saved level fuel spare product⟩ := by + change some (TM2.stepAux compareLoop _ _) = _ + simp [compareLoop, TM2.stepAux, memory, encodeWord] + +theorem compareStep_succ_zero (g x : Nat) (input saved level fuel spare product : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step (program g) + ⟨some .compare, ((ambient, flag), register), + memory input (encodeWord (x + 1)) (encodeWord 0) saved level fuel spare product⟩ = + some ⟨some .compare, ((ambient, true), none), + memory input (encodeWord x) (encodeWord 0) saved level fuel spare product⟩ := by + change some (TM2.stepAux compareLoop _ _) = _ + simp [compareLoop, TM2.stepAux, memory, encodeWord, List.replicate_succ] + +theorem compareStep_succ_succ (g x p : Nat) (input saved level fuel spare product : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step (program g) + ⟨some .compare, ((ambient, flag), register), + memory input (encodeWord (x + 1)) (encodeWord (p + 1)) saved level fuel spare product⟩ = + some ⟨some .compare, ((ambient, flag), none), + memory input (encodeWord x) (encodeWord p) (true :: saved) level fuel spare product⟩ := by + change some (TM2.stepAux compareLoop _ _) = _ + simp [compareLoop, TM2.stepAux, memory, encodeWord, List.replicate_succ] + +theorem compareTrace (g x p : Nat) (input saved level fuel spare product : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step (program g)))^[x + 1] + (some ⟨some .compare, ((ambient, flag), register), + memory input (encodeWord x) (encodeWord p) saved level fuel spare product⟩) = + some ⟨some .restore, ((ambient, overflow flag x p), none), + memory input [] (encodeWord (p - x)) + (List.replicate (min x p) true ++ saved) level fuel spare product⟩ := by + induction x generalizing p saved flag register with + | zero => + simpa [overflow] using compareStep_zero g p input saved level fuel spare product ambient flag register + | succ x ih => + rw [Function.iterate_succ_apply] + change (advance (TM2.step (program g)))^[x + 1] + (TM2.step (program g) ⟨some .compare, ((ambient, flag), register), + memory input (encodeWord (x + 1)) (encodeWord p) saved level fuel spare product⟩) = _ + cases p with + | zero => + rw [compareStep_succ_zero] + simpa [overflow] using ih 0 saved true none + | succ p => + rw [compareStep_succ_succ] + simpa [overflow, Nat.succ_min_succ, List.replicate_succ', List.append_assoc] using + ih p (true :: saved) flag none + +theorem replicate_encodeWord (a b : Nat) : + List.replicate a true ++ encodeWord b = encodeWord (a + b) := by + simp only [encodeWord, ← List.append_assoc, List.replicate_append_replicate] + +theorem compareRestoredTrace (g k p : Nat) (level fuel : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program g)))^[k + min k p + 2] + (some ⟨some .compare, ((ambient, false), register), + memory (encodeWord k) (encodeWord k) (encodeWord p) [] level fuel [] []⟩) = + some ⟨some .decide, ((ambient, decide (p < k)), none), + memory (encodeWord k) [] (encodeWord p) [] level fuel [] []⟩ := by + have hc := compareTrace g k p (encodeWord k) [] level fuel [] [] ambient false register + simp only [overflow, Bool.false_or, List.append_nil] at hc + let mid := memory (encodeWord k) [] (encodeWord (p - k)) + (List.replicate (min k p) true) level fuel [] [] + have hr := Reduction.MachineTransfer.transferAt_fromTapes Tape.saved Tape.power (by decide) + id false Label.restore (some Label.decide) (program g) rfl mid (ambient, decide (p < k)) none + have hsum : min k p + (p - k) = p := by omega + simp only [mid, memory, List.length_replicate, List.reverse_replicate, List.map_id, + Reduction.MachineTransfer.tapesAt, update_saved, update_power] at hr + rw [replicate_encodeWord, hsum] at hr + rw [show k + min k p + 2 = (min k p + 1) + (k + 1) by omega, + Function.iterate_add_apply, hc] + exact hr + +theorem appendTrace {α : Type*} (f : α → α) {a b c : α} {s t : Nat} + (hs : f^[s] a = b) (ht : f^[t] b = c) : f^[s + t] a = c := by + rw [Nat.add_comm s t, Function.iterate_add_apply, hs, ht] + +theorem scaleStep_succ (g p b : Nat) (input level fuel : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (program g) + ⟨some .scale, ((ambient, false), register), + memory input [] (encodeWord (p + 1)) [] level fuel [] (List.replicate b true)⟩ = + some ⟨some .scale, ((ambient, false), some true), + memory input [] (encodeWord p) [] level fuel [] (List.replicate (g + b) true)⟩ := by + change some (TM2.stepAux (scaleLoop g) _ _) = _ + simp [scaleLoop, TM2.stepAux, memory, encodeWord, List.replicate_succ, + Reduction.MachineSubstitution.stepAux_pushWord] + +theorem scaleStep_zero (g b : Nat) (input level fuel : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (program g) + ⟨some .scale, ((ambient, false), register), + memory input [] (encodeWord 0) [] level fuel [] (List.replicate b true)⟩ = + some ⟨some .transfer, ((ambient, false), none), + memory input [] (encodeWord 0) [] (true :: level) fuel [] (List.replicate b true)⟩ := by + change some (TM2.stepAux (scaleLoop g) _ _) = _ + simp [scaleLoop, TM2.stepAux, memory, encodeWord] + +theorem scaleScanTrace (g p b : Nat) (input level fuel : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program g)))^[p + 1] + (some ⟨some .scale, ((ambient, false), register), + memory input [] (encodeWord p) [] level fuel [] (List.replicate b true)⟩) = + some ⟨some .transfer, ((ambient, false), none), + memory input [] (encodeWord 0) [] (true :: level) fuel [] (List.replicate (g * p + b) true)⟩ := by + induction p generalizing b register with + | zero => simpa using scaleStep_zero g b input level fuel ambient register + | succ p ih => + rw [Function.iterate_succ_apply] + change (advance (TM2.step (program g)))^[p + 1] + (TM2.step (program g) ⟨some .scale, ((ambient, false), register), + memory input [] (encodeWord (p + 1)) [] level fuel [] (List.replicate b true)⟩) = _ + rw [scaleStep_succ, ih] + have h : g * p + (g + b) = g * (p + 1) + b := by rw [Nat.mul_succ]; omega + rw [h] + +theorem scaleTrace (g k p e : Nat) (fuel : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program g)))^[p + g * p + 2] + (some ⟨some .scale, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) fuel [] []⟩) = + some ⟨some .guard, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord (p * g)) [] (encodeWord (e + 1)) fuel [] []⟩ := by + have hs := scaleScanTrace g p 0 (encodeWord k) (encodeWord e) fuel ambient register + simp only [List.replicate_zero, Nat.add_zero] at hs + let mid := memory (encodeWord k) [] (encodeWord 0) [] (true :: encodeWord e) fuel [] + (List.replicate (g * p) true) + have ht := Reduction.MachineTransfer.transferAt_fromTapes Tape.product Tape.power (by decide) + id false Label.transfer (some Label.guard) (program g) rfl mid (ambient, false) none + simp only [mid, memory, List.length_replicate, List.reverse_replicate, List.map_id, + Reduction.MachineTransfer.tapesAt, update_product, update_power, + replicate_encodeWord, Nat.add_zero] at ht + have he : true :: encodeWord e = encodeWord (e + 1) := by simp [encodeWord, List.replicate_succ] + rw [he, Nat.mul_comm g p] at ht + rw [he, Nat.mul_comm g p] at hs + have h := appendTrace (advance (TM2.step (program g))) hs ht + simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm, Nat.mul_comm] using h + +theorem cleanupTrace (g k p e f : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program g)))^[f + 2] + (some ⟨some .cleanup, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩) = + some ⟨none, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) [] [] []⟩ := by + have h := MachineDrain.drainTrace Tape.fuel Label.cleanup none (program g) rfl + (memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) [] [] []) + (encodeWord f) (ambient, false) register + simpa only [encodeWord_length, update_fuel, Nat.add_assoc] using h + +theorem guardStep_succ (g k p e f : Nat) (ambient : σ) (register : Option Bool) : + TM2.step (program g) + ⟨some .guard, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord (f + 1)) [] []⟩ = + some ⟨some .copyFirst, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩ := by + have h := MachineUnaryCounter.guardStep_succ Tape.fuel Label.guard Label.copyFirst Label.cleanup + (program g) rfl (memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) [] [] []) + f [] (ambient, false) register + simpa only [MachineUnaryCounter.counterTapes, List.append_nil, update_fuel] using h + +theorem guardStep_zero (g k p e : Nat) (ambient : σ) (register : Option Bool) : + TM2.step (program g) + ⟨some .guard, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord 0) [] []⟩ = + some ⟨some .cleanup, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord 0) [] []⟩ := by + have h := MachineUnaryCounter.guardStep_zero Tape.fuel Label.guard Label.copyFirst Label.cleanup + (program g) rfl (memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) [] [] []) + [] (ambient, false) register + simpa only [MachineUnaryCounter.counterTapes, List.append_nil, update_fuel] using h + +theorem decideStep (g k p e f : Nat) (ambient : σ) : + TM2.step (program g) + ⟨some .decide, ((ambient, decide (p < k)), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩ = + some ⟨some (if k ≤ p then Label.cleanup else Label.scale), ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩ := by + by_cases h : k ≤ p + · have hn : ¬p < k := by omega + simp [TM2.step, program, TM2.stepAux, h, hn] + · have hn : p < k := by omega + simp [TM2.step, program, TM2.stepAux, h, hn] + +def prefixTime (k p : Nat) : Nat := (1 + 2 * (k + 2)) + (k + min k p + 2) + 1 + +theorem prefixTrace (g k p e f : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program g)))^[prefixTime k p] + (some ⟨some .guard, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord (f + 1)) [] []⟩) = + some ⟨some (if k ≤ p then Label.cleanup else Label.scale), ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩ := by + have hg : (advance (TM2.step (program g)))^[1] + (some ⟨some .guard, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord (f + 1)) [] []⟩) = + some ⟨some .copyFirst, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩ := + guardStep_succ g k p e f ambient register + have hc := MachineCopy.copyTrace Tape.input Tape.work Tape.spare + (by decide) (by decide) (by decide) false Label.copyFirst Label.copySecond + (some Label.compare) (program g) rfl rfl + (memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []) + rfl (ambient, false) none + simp only [memory, encodeWord_length, List.append_nil, update_work] at hc + have hcmp := compareRestoredTrace g k p (encodeWord e) (encodeWord f) ambient none + have hd : (advance (TM2.step (program g)))^[1] + (some ⟨some .decide, ((ambient, decide (p < k)), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩) = + some ⟨some (if k ≤ p then Label.cleanup else Label.scale), ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩ := + decideStep g k p e f ambient + exact appendTrace _ (appendTrace _ (appendTrace _ hg hc) hcmp) hd + +def coreTime (g k : Nat) : Nat → Nat → Nat + | 0, _ => 3 + | f + 1, p => prefixTime k p + + if k ≤ p then f + 2 else (p + g * p + 2) + coreTime g k f (p * g) + +theorem coreTrace (g k f e p : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program g)))^[coreTime g k f p] + (some ⟨some .guard, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord f) [] []⟩) = + some ⟨none, ((ambient, false), none), + memory (encodeWord k) [] + (encodeWord (PreprocessingLevels.levelLoop g k f e p).2) [] + (encodeWord (PreprocessingLevels.levelLoop g k f e p).1) [] [] []⟩ := by + induction f generalizing e p register with + | zero => + have hg : (advance (TM2.step (program g)))^[1] + (some ⟨some .guard, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord 0) [] []⟩) = + some ⟨some .cleanup, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord p) [] (encodeWord e) (encodeWord 0) [] []⟩ := + guardStep_zero g k p e ambient register + exact appendTrace _ hg (cleanupTrace g k p e 0 ambient none) + | succ f ih => + have hpref := prefixTrace g k p e f ambient register + by_cases h : k ≤ p + · simp only [h, ite_true] at hpref + have hrun := appendTrace _ hpref (cleanupTrace g k p e f ambient none) + simpa only [coreTime, PreprocessingLevels.levelLoop, h, ite_true] using hrun + · simp only [h, ite_false] at hpref + have hscale := scaleTrace g k p e (encodeWord f) ambient none + have hrun := appendTrace _ hpref (appendTrace _ hscale (ih (e + 1) (p * g) none)) + simpa only [coreTime, PreprocessingLevels.levelLoop, h, ite_false] using hrun + +def roundBudget (g k : Nat) : Nat := (g + 8) * (k + 1) + 16 + +theorem prefixTime_le (k p : Nat) : prefixTime k p ≤ 4 * k + 8 := by + have h := Nat.min_le_left k p + unfold prefixTime + omega + +theorem prefixTime_le_roundBudget (g k p : Nat) : prefixTime k p ≤ roundBudget g k := by + have h := prefixTime_le k p + unfold roundBudget + simp only [Nat.add_mul, Nat.mul_add, Nat.mul_one] + omega + +theorem continuingTime_le (g k p : Nat) (h : p < k) : + prefixTime k p + (p + g * p + 2) ≤ roundBudget g k := by + have hprefix := prefixTime_le k p + have hmul := Nat.mul_le_mul_left g h.le + unfold roundBudget + simp only [Nat.add_mul, Nat.mul_add, Nat.mul_one] + omega + +theorem coreTime_le (g k f p : Nat) : + coreTime g k f p ≤ (f + 1) * roundBudget g k := by + have hB : 3 ≤ roundBudget g k := by unfold roundBudget; omega + induction f generalizing p with + | zero => simpa only [coreTime, Nat.zero_add, Nat.one_mul] using hB + | succ f ih => + rw [coreTime] + by_cases h : k ≤ p + · rw [ite_eq_left h] + have hp := prefixTime_le_roundBudget g k p + have hm := Nat.mul_le_mul_left (f + 1) hB + have hc : f + 2 ≤ (f + 1) * roundBudget g k := by omega + calc + prefixTime k p + (f + 2) ≤ roundBudget g k + (f + 1) * roundBudget g k := + Nat.add_le_add hp hc + _ = (f + 1 + 1) * roundBudget g k := by ring + · rw [ite_eq_right h] + have hb := continuingTime_le g k p (by omega) + have hr := ih (p * g) + calc + prefixTime k p + ((p + g * p + 2) + coreTime g k f (p * g)) = + (prefixTime k p + (p + g * p + 2)) + coreTime g k f (p * g) := by omega + _ ≤ roundBudget g k + (f + 1) * roundBudget g k := Nat.add_le_add hb hr + _ = (f + 1 + 1) * roundBudget g k := by ring + +theorem initStep (g k : Nat) (ambient : σ) (register : Option Bool) : + TM2.step (program g) + ⟨some .init, ((ambient, false), register), memory (encodeWord k) [] [] [] [] [] [] []⟩ = + some ⟨some .fuelFirst, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord 1) [] (encodeWord 0) [] [] []⟩ := by + change some (TM2.stepAux (program g .init) _ _) = _ + simp [program, TM2.stepAux, memory, encodeWord] + +def totalTime (g k : Nat) : Nat := 1 + 2 * (k + 2) + coreTime g k k 1 + +theorem searchTrace (g k : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program g)))^[totalTime g k] + (some ⟨some .init, ((ambient, false), register), memory (encodeWord k) [] [] [] [] [] [] []⟩) = + some ⟨none, ((ambient, false), none), + memory (encodeWord k) [] + (encodeWord (PreprocessingLevels.levelLoop g k k 0 1).2) [] + (encodeWord (PreprocessingLevels.levelLoop g k k 0 1).1) [] [] []⟩ := by + have hi : (advance (TM2.step (program g)))^[1] + (some ⟨some .init, ((ambient, false), register), memory (encodeWord k) [] [] [] [] [] [] []⟩) = + some ⟨some .fuelFirst, ((ambient, false), register), + memory (encodeWord k) [] (encodeWord 1) [] (encodeWord 0) [] [] []⟩ := + initStep g k ambient register + have hc := MachineCopy.copyTrace Tape.input Tape.fuel Tape.spare + (by decide) (by decide) (by decide) false Label.fuelFirst Label.fuelSecond + (some Label.guard) (program g) rfl rfl + (memory (encodeWord k) [] (encodeWord 1) [] (encodeWord 0) [] [] []) + rfl (ambient, false) register + simp only [memory, encodeWord_length, List.append_nil, update_fuel] at hc + exact appendTrace _ (appendTrace _ hi hc) (coreTrace g k k 0 1 ambient none) + +def timeBound (g k : Nat) : Nat := (g + 8) * (k + 1) ^ 2 + 18 * (k + 1) + 3 + +theorem totalTime_le (g k : Nat) : totalTime g k ≤ timeBound g k := by + have h := coreTime_le g k k 1 + calc + totalTime g k ≤ 1 + 2 * (k + 2) + (k + 1) * roundBudget g k := + Nat.add_le_add_left h _ + _ = timeBound g k := by unfold roundBudget timeBound; ring + +noncomputable def timePolynomial (g : Nat) : Polynomial Nat := + Polynomial.C (g + 8) * Polynomial.X ^ 2 + 18 * Polynomial.X + 3 + +theorem timePolynomial_encoding (g k : Nat) : + (timePolynomial g).eval (encodeWord k).length = timeBound g k := by + simp [timePolynomial, timeBound, encodeWord_length] + +theorem paddingTrace (k : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program ExpanderFamily.growth)))^[totalTime ExpanderFamily.growth k] + (some ⟨some .init, ((ambient, false), register), memory (encodeWord k) [] [] [] [] [] [] []⟩) = + some ⟨none, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord (PreprocessingLevels.paddedSize k)) [] + (encodeWord (PreprocessingLevels.boundedLevel k)) [] [] []⟩ := by + exact searchTrace ExpanderFamily.growth k ambient register + +def paddingInTime (k : Nat) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program ExpanderFamily.growth)) + ⟨some .init, ((ambient, false), register), memory (encodeWord k) [] [] [] [] [] [] []⟩ + (some ⟨none, ((ambient, false), none), + memory (encodeWord k) [] (encodeWord (PreprocessingLevels.paddedSize k)) [] + (encodeWord (PreprocessingLevels.boundedLevel k)) [] [] []⟩) + ((timePolynomial ExpanderFamily.growth).eval (encodeWord k).length) where + steps := totalTime ExpanderFamily.growth k + evals_in_steps := paddingTrace k ambient register + steps_le_m := by rw [timePolynomial_encoding]; exact totalTime_le _ _ + +theorem paddingOutput_bounds (k : Nat) : + PreprocessingLevels.boundedLevel k ≤ k ∧ + k ≤ PreprocessingLevels.paddedSize k ∧ + PreprocessingLevels.paddedSize k ≤ ExpanderFamily.growth * (k + 1) := by + refine ⟨PreprocessingLevels.boundedLevel_le_input k, PreprocessingLevels.le_paddedSize k, ?_⟩ + by_cases hk : k = 0 + · subst k + simpa using ExpanderFamily.growth_gt_one.le + · exact (PreprocessingLevels.paddedSize_bounds (Nat.pos_of_ne_zero hk)).2.trans + (Nat.mul_le_mul_left ExpanderFamily.growth (Nat.le_succ k)) + +end IndependentSetsGames.Foundations.Complexity.MachineCeilingPower + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudCount.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..552d0ee6986a20648cba0c1c065b6657d7611755 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudCount.lean @@ -0,0 +1,537 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.Finite2 +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupDiscard + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCloudCount + +open Turing +open MachineComposition + +inductive Tape + | original | work | target | scratch | count | spare + deriving DecidableEq + +instance : Fintype Tape where + elems := {.original, .work, .target, .scratch, .count, .spare} + complete tape := by cases tape <;> simp + +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := (σ × Bool) × Option Bool + +def memory (original work target scratch count spare : List Bool) : Tape → List Bool + | .original => original + | .work => work + | .target => target + | .scratch => scratch + | .count => count + | .spare => spare + +@[simp] theorem memory_original (a b c d e f : List Bool) : + memory a b c d e f .original = a := rfl +@[simp] theorem memory_work (a b c d e f : List Bool) : + memory a b c d e f .work = b := rfl +@[simp] theorem memory_target (a b c d e f : List Bool) : + memory a b c d e f .target = c := rfl +@[simp] theorem memory_scratch (a b c d e f : List Bool) : + memory a b c d e f .scratch = d := rfl +@[simp] theorem memory_count (a b c d e f : List Bool) : + memory a b c d e f .count = e := rfl +@[simp] theorem memory_spare (a b c d e f : List Bool) : + memory a b c d e f .spare = f := rfl + +@[simp] theorem update_memory_work (a b c d e f x : List Bool) : + Function.update (memory a b c d e f) .work x = memory a x c d e f := by + funext k + cases k <;> rfl +@[simp] theorem update_memory_target (a b c d e f x : List Bool) : + Function.update (memory a b c d e f) .target x = memory a b x d e f := by + funext k + cases k <;> rfl +@[simp] theorem update_memory_scratch (a b c d e f x : List Bool) : + Function.update (memory a b c d e f) .scratch x = memory a b c x e f := by + funext k + cases k <;> rfl +@[simp] theorem update_memory_count (a b c d e f x : List Bool) : + Function.update (memory a b c d e f) .count x = memory a b c d x f := by + funext k + cases k <;> rfl + +variable {Λ σ : Type} + +def finishField (restore : Λ) : TM2.Stmt Alphabet Λ (State σ) := + .load (fun state => ((state.1.1, false), none)) (.goto fun _ => restore) + +def fieldLoop (again restore : Λ) : TM2.Stmt Alphabet Λ (State σ) := + .pop .work (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.peek .target (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.pop .target (fun state _ => (state.1, none)) + (.push .scratch (fun _ => true) (.goto fun _ => again))) + (.load (fun state => ((state.1.1, true), none)) (.goto fun _ => again)))) + (.peek .target (fun state head => (state.1, head)) + (.branch (fun state => !state.1.2 && !(state.2.getD false)) + (.push .count (fun _ => true) (finishField restore)) + (finishField restore)))) + +def hit (flag : Bool) (x v : Nat) : Nat := if flag = false ∧ x = v then 1 else 0 + +theorem fieldStep_zero (again restore : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (atField : program again = fieldLoop again restore) + (original suffix targetSuffix spare : List Bool) (v : Nat) + (scratch count : List Bool) (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step program + ⟨some again, ((ambient, flag), register), + memory original (encodeWord 0 ++ suffix) (encodeWord v ++ targetSuffix) + scratch count spare⟩ = + some ⟨some restore, ((ambient, false), none), + memory original suffix (encodeWord v ++ targetSuffix) scratch + (List.replicate (hit flag 0 v) true ++ count) spare⟩ := by + change some (TM2.stepAux (program again) _ _) = _ + rw [atField] + cases v <;> cases flag <;> + simp [fieldLoop, finishField, TM2.stepAux, encodeWord, hit, List.replicate_succ] + +theorem fieldStep_succ_zero (again restore : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (atField : program again = fieldLoop again restore) + (original suffix targetSuffix spare : List Bool) (x : Nat) + (scratch count : List Bool) (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step program + ⟨some again, ((ambient, flag), register), + memory original (encodeWord (x + 1) ++ suffix) (encodeWord 0 ++ targetSuffix) + scratch count spare⟩ = + some ⟨some again, ((ambient, true), none), + memory original (encodeWord x ++ suffix) (encodeWord 0 ++ targetSuffix) + scratch count spare⟩ := by + change some (TM2.stepAux (program again) _ _) = _ + rw [atField] + simp [fieldLoop, TM2.stepAux, encodeWord, List.replicate_succ] + +theorem fieldStep_succ_succ (again restore : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (atField : program again = fieldLoop again restore) + (original suffix targetSuffix spare : List Bool) (x v : Nat) + (scratch count : List Bool) (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step program + ⟨some again, ((ambient, flag), register), + memory original (encodeWord (x + 1) ++ suffix) + (encodeWord (v + 1) ++ targetSuffix) scratch count spare⟩ = + some ⟨some again, ((ambient, flag), none), + memory original (encodeWord x ++ suffix) (encodeWord v ++ targetSuffix) + (true :: scratch) count spare⟩ := by + change some (TM2.stepAux (program again) _ _) = _ + rw [atField] + simp [fieldLoop, TM2.stepAux, encodeWord, List.replicate_succ] + +theorem fieldTrace (again restore : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (atField : program again = fieldLoop again restore) + (original suffix targetSuffix spare : List Bool) (x v : Nat) + (scratch count : List Bool) (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step program))^[x + 1] + (some ⟨some again, ((ambient, flag), register), + memory original (encodeWord x ++ suffix) (encodeWord v ++ targetSuffix) + scratch count spare⟩) = + some ⟨some restore, ((ambient, false), none), + memory original suffix (encodeWord (v - x) ++ targetSuffix) + (List.replicate (min x v) true ++ scratch) + (List.replicate (hit flag x v) true ++ count) spare⟩ := by + induction x generalizing v scratch flag register with + | zero => + simpa only [Nat.zero_add, Function.iterate_one, advance_some, Nat.sub_zero, + Nat.zero_min, List.replicate_zero, List.nil_append] using + fieldStep_zero again restore program atField original suffix targetSuffix spare v + scratch count ambient flag register + | succ x ih => + rw [Function.iterate_succ_apply] + change (advance (TM2.step program))^[x + 1] + (TM2.step program ⟨some again, ((ambient, flag), register), + memory original (encodeWord (x + 1) ++ suffix) (encodeWord v ++ targetSuffix) + scratch count spare⟩) = _ + cases v with + | zero => + rw [fieldStep_succ_zero again restore program atField] + simpa [hit] using ih 0 scratch true none + | succ v => + rw [fieldStep_succ_succ again restore program atField] + simpa [hit, Nat.succ_min_succ, List.replicate_succ', List.append_assoc] using + ih v (true :: scratch) flag none + +theorem replicate_encodeWord (a b : Nat) : + List.replicate a true ++ encodeWord b = encodeWord (a + b) := by + simp only [encodeWord, ← List.append_assoc, List.replicate_append_replicate] + +theorem preservingFieldTrace (again restore next : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (atField : program again = fieldLoop again restore) + (atRestore : program restore = Reduction.MachineTransfer.loopAt + .scratch .target id false restore (some next)) + (original suffix targetSuffix count spare : List Bool) (x v : Nat) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[x + min x v + 2] + (some ⟨some again, ((ambient, false), register), + memory original (encodeWord x ++ suffix) (encodeWord v ++ targetSuffix) + [] count spare⟩) = + some ⟨some next, ((ambient, false), none), + memory original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (if x = v then 1 else 0) true ++ count) spare⟩ := by + have hfield := fieldTrace again restore program atField original suffix targetSuffix spare + x v [] count ambient false register + simp only [List.append_nil, hit, true_and] at hfield + let after := memory original suffix (encodeWord (v - x) ++ targetSuffix) + (List.replicate (min x v) true) + (List.replicate (if x = v then 1 else 0) true ++ count) spare + have hrestore := Reduction.MachineTransfer.transferAt_fromTapes + Tape.scratch Tape.target (by decide) id false restore (some next) program atRestore + after (ambient, false) none + have hsum : min x v + (v - x) = v := by omega + simp only [after, memory_scratch, memory_target, List.length_replicate, + List.reverse_replicate, List.map_id, Reduction.MachineTransfer.tapesAt, + update_memory_scratch, update_memory_target] at hrestore + rw [← List.append_assoc, replicate_encodeWord, hsum] at hrestore + rw [show x + min x v + 2 = (min x v + 1) + (x + 1) by omega, + Function.iterate_add_apply, hfield] + exact hrestore + +def preservingFieldInTime (again restore next : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (atField : program again = fieldLoop again restore) + (atRestore : program restore = Reduction.MachineTransfer.loopAt + .scratch .target id false restore (some next)) + (original suffix targetSuffix count spare : List Bool) (x v : Nat) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some again, ((ambient, false), register), + memory original (encodeWord x ++ suffix) (encodeWord v ++ targetSuffix) + [] count spare⟩ + (some ⟨some next, ((ambient, false), none), + memory original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (if x = v then 1 else 0) true ++ count) spare⟩) + (2 * x + 2) where + steps := x + min x v + 2 + evals_in_steps := preservingFieldTrace again restore next program atField atRestore + original suffix targetSuffix count spare x v ambient register + steps_le_m := by have h := Nat.min_le_left x v; omega + +theorem discardFieldsTrace (labels : Nat → Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (fields : List Nat) (offset : Nat) + (atField : ∀ i, i < fields.length → program (labels (offset + i)) = + MachineLookup.discard .work (labels (offset + i)) (labels (offset + i + 1))) + (original suffix target scratch count spare : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step program))^[(encodeWords fields).length] + (some ⟨some (labels offset), ((ambient, flag), register), + memory original (encodeWords fields ++ suffix) target scratch count spare⟩) = + some ⟨some (labels (offset + fields.length)), + ((ambient, flag), if fields = [] then register else none), + memory original suffix target scratch count spare⟩ := by + induction fields generalizing offset register with + | nil => simp only [encodeWords, List.length_nil, Function.iterate_zero_apply, + List.nil_append, Nat.add_zero, ↓reduceIte] + | cons x fields ih => + have hfirst := MachineLookup.discardTrace Tape.work (labels offset) (labels (offset + 1)) + program (by simpa only [Nat.add_zero] using atField 0 (by simp)) + (memory original (encodeWords (x :: fields) ++ suffix) target scratch count spare) + x (encodeWords fields ++ suffix) (by simp only [memory_work, encodeWords, List.append_assoc]) + (ambient, flag) register + simp only [update_memory_work] at hfirst + have hrest := ih (offset + 1) (by + intro i hi + have h := atField (i + 1) (by simpa only [List.length_cons] using Nat.succ_lt_succ hi) + simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using h) none + rw [show (encodeWords (x :: fields)).length = + (encodeWords fields).length + (x + 1) by + simp only [encodeWords, List.length_append, encodeWord_length] + omega, + Function.iterate_add_apply, hfirst] + simpa only [List.length_cons, List.cons_ne_nil, + ite_false, ite_self, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hrest + +inductive Label + | copyFirst | copySecond | headerFirst | headerSecond | row | field | restore + | skip (i : Fin 4097) + deriving DecidableEq, Fintype + +def skipLabel (i : Nat) : Label := + if h : i < 4097 then .skip ⟨i, h⟩ else .row + +def rowEntry : TM2.Stmt Alphabet Label (State σ) := + .peek .work (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.load (fun state => ((state.1.1, false), none)) (.goto fun _ => .field)) + (.load (fun state => ((state.1.1, false), none)) .halt)) + +def program : Label → TM2.Stmt Alphabet Label (State σ) + | .copyFirst => Reduction.MachineTransfer.loopAt + .original .spare id false .copyFirst (some .copySecond) + | .copySecond => MachineCopy.forkLoop + .spare .original .work false .copySecond (some .headerFirst) + | .headerFirst => MachineLookup.discard .work .headerFirst .headerSecond + | .headerSecond => MachineLookup.discard .work .headerSecond .row + | .row => rowEntry + | .field => fieldLoop .field .restore + | .restore => Reduction.MachineTransfer.loopAt + .scratch .target id false .restore (some (skipLabel 0)) + | .skip i => MachineLookup.discard .work (.skip i) (skipLabel (i.val + 1)) + +theorem program_skip {i : Nat} (hi : i < 4097) : + program (σ := σ) (skipLabel i) = + MachineLookup.discard .work (skipLabel i) (skipLabel (i + 1)) := by + simp only [skipLabel, dite_eq_left hi, program] + +theorem rowStep_nonempty (original work target scratch count spare : List Bool) + (hwork : work ≠ []) (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step (program (σ := σ)) + ⟨some .row, ((ambient, flag), register), memory original work target scratch count spare⟩ = + some ⟨some .field, ((ambient, false), none), + memory original work target scratch count spare⟩ := by + cases work with + | nil => exact (hwork rfl).elim + | cons x xs => rfl + +theorem rowStep_empty (original target scratch count spare : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step (program (σ := σ)) + ⟨some .row, ((ambient, flag), register), memory original [] target scratch count spare⟩ = + some ⟨none, ((ambient, false), none), memory original [] target scratch count spare⟩ := rfl + +abbrev Row := Nat × List Nat + +def rowWords (r : Row) : List Nat := r.1 :: r.2 + +def rowTime (v : Nat) (r : Row) : Nat := + (encodeWords (rowWords r)).length + min r.1 v + 2 + +theorem rowTrace (r : Row) (hwidth : r.2.length = 4097) (v : Nat) + (original suffix targetSuffix count spare : List Bool) (ambient : σ) + (register : Option Bool) : + (advance (TM2.step (program (σ := σ))))^[rowTime v r] + (some ⟨some .row, ((ambient, false), register), + memory original (encodeWords (rowWords r) ++ suffix) (encodeWord v ++ targetSuffix) + [] count spare⟩) = + some ⟨some .row, ((ambient, false), none), + memory original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (if r.1 = v then 1 else 0) true ++ count) spare⟩ := by + have hfield := preservingFieldTrace Label.field Label.restore (skipLabel 0) + program rfl rfl original (encodeWords r.2 ++ suffix) targetSuffix count spare r.1 v ambient none + have hskip := discardFieldsTrace skipLabel (program (σ := σ)) r.2 0 + (by intro i hi; simpa only [Nat.zero_add] using program_skip (hwidth ▸ hi)) + original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (if r.1 = v then 1 else 0) true ++ count) spare ambient false none + have hnonempty : r.2 ≠ [] := by intro h; simp [h] at hwidth + simp only [Nat.zero_add, hwidth, skipLabel, lt_self_iff_false, ↓reduceDIte, + hnonempty, ite_false] at hskip + have htime : rowTime v r = (encodeWords r.2).length + (r.1 + min r.1 v + 2) + 1 := by + simp only [rowTime, rowWords, encodeWords, List.length_append, encodeWord_length] + omega + rw [htime, Function.iterate_succ_apply] + change (advance (TM2.step (program (σ := σ))))^[ + (encodeWords r.2).length + (r.1 + min r.1 v + 2)] + (TM2.step program ⟨some .row, ((ambient, false), register), + memory original (encodeWords (rowWords r) ++ suffix) (encodeWord v ++ targetSuffix) + [] count spare⟩) = _ + rw [rowStep_nonempty original _ _ [] count spare + (by simp [rowWords, encodeWords, encodeWord]) ambient false register, + Function.iterate_add_apply] + simp only [rowWords, encodeWords, List.append_assoc] + rw [hfield] + exact hskip + +def rowsHits (v : Nat) : List Row → Nat + | [] => 0 + | r :: rs => (if r.1 = v then 1 else 0) + rowsHits v rs + +def rowsTime (v : Nat) : List Row → Nat + | [] => 1 + | r :: rs => rowsTime v rs + rowTime v r + +theorem rowsTrace (rs : List Row) (hwidth : ∀ r ∈ rs, r.2.length = 4097) (v : Nat) + (original targetSuffix count spare : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program (σ := σ))))^[rowsTime v rs] + (some ⟨some .row, ((ambient, false), register), + memory original (encodeWords (rs.flatMap rowWords)) (encodeWord v ++ targetSuffix) + [] count spare⟩) = + some ⟨none, ((ambient, false), none), + memory original [] (encodeWord v ++ targetSuffix) [] + (List.replicate (rowsHits v rs) true ++ count) spare⟩ := by + induction rs generalizing count register with + | nil => + simpa only [rowsTime, List.flatMap_nil, encodeWords, Function.iterate_one, advance_some, + rowsHits, List.replicate_zero, List.nil_append] using + rowStep_empty original (encodeWord v ++ targetSuffix) [] count spare ambient false register + | cons r rs ih => + have hrow := rowTrace r (hwidth r (by simp)) v original + (encodeWords (rs.flatMap rowWords)) targetSuffix count spare ambient register + have hrest := ih (by intro x hx; exact hwidth x (by simp [hx])) + (List.replicate (if r.1 = v then 1 else 0) true ++ count) none + simp only [rowsTime, List.flatMap_cons, encodeWords_append] + rw [Function.iterate_add_apply, hrow] + simpa only [rowsHits, ← List.append_assoc, List.replicate_append_replicate, + Nat.add_comm] using hrest + +theorem rowTime_le (v : Nat) (r : Row) : + rowTime v r ≤ 3 * (encodeWords (rowWords r)).length := by + have hmin := Nat.min_le_left r.1 v + have hlen : r.1 + 1 ≤ (encodeWords (rowWords r)).length := by + simp only [rowWords, encodeWords, List.length_append, encodeWord_length] + omega + unfold rowTime + omega + +theorem rowsTime_le (v : Nat) (rs : List Row) : + rowsTime v rs ≤ 3 * (encodeWords (rs.flatMap rowWords)).length + 1 := by + induction rs with + | nil => simp only [rowsTime, List.flatMap_nil, encodeWords, List.length_nil, + Nat.mul_zero, Nat.zero_add, le_refl] + | cons r rs ih => + have hr := rowTime_le v r + simp only [rowsTime, List.flatMap_cons, encodeWords_append, List.length_append] + omega + +def inputWord (n m : Nat) (rs : List Row) : List Bool := + encodeWords ([n, m] ++ rs.flatMap rowWords) + +theorem inputWord_eq (n m : Nat) (rs : List Row) : + inputWord n m rs = encodeWord n ++ (encodeWord m ++ encodeWords (rs.flatMap rowWords)) := by + simp only [inputWord, encodeWords_append, encodeWords, List.append_nil, List.append_assoc] + +theorem inputWord_length (n m : Nat) (rs : List Row) : + (inputWord n m rs).length = n + 1 + (m + 1) + + (encodeWords (rs.flatMap rowWords)).length := by + rw [inputWord_eq] + simp only [List.length_append, encodeWord_length] + omega + +def totalSteps (n m v : Nat) (rs : List Row) : Nat := + 2 * ((inputWord n m rs).length + 1) + (n + 1) + (m + 1) + rowsTime v rs + +theorem countTrace (n m v : Nat) (rs : List Row) + (hwidth : ∀ r ∈ rs, r.2.length = 4097) + (targetSuffix count : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program (σ := σ))))^[totalSteps n m v rs] + (some ⟨some .copyFirst, ((ambient, false), register), + memory (inputWord n m rs) [] (encodeWord v ++ targetSuffix) [] count []⟩) = + some ⟨none, ((ambient, false), none), + memory (inputWord n m rs) [] (encodeWord v ++ targetSuffix) [] + (List.replicate (rowsHits v rs) true ++ count) []⟩ := by + have hcopy := MachineCopy.copyTrace Tape.original Tape.work Tape.spare + (by decide) (by decide) (by decide) false Label.copyFirst Label.copySecond + (some Label.headerFirst) program rfl rfl + (memory (inputWord n m rs) [] (encodeWord v ++ targetSuffix) [] count []) + rfl (ambient, false) register + simp only [memory_original, memory_work, List.append_nil, update_memory_work] at hcopy + have hfirst := MachineLookup.discardTrace Tape.work Label.headerFirst Label.headerSecond + program rfl + (memory (inputWord n m rs) (inputWord n m rs) (encodeWord v ++ targetSuffix) [] count []) + n (encodeWord m ++ encodeWords (rs.flatMap rowWords)) + (by exact inputWord_eq n m rs) (ambient, false) none + simp only [update_memory_work] at hfirst + have hsecond := MachineLookup.discardTrace Tape.work Label.headerSecond Label.row + program rfl + (memory (inputWord n m rs) (encodeWord m ++ encodeWords (rs.flatMap rowWords)) + (encodeWord v ++ targetSuffix) [] count []) + m (encodeWords (rs.flatMap rowWords)) rfl (ambient, false) none + simp only [update_memory_work] at hsecond + have hrows := rowsTrace rs hwidth v (inputWord n m rs) targetSuffix count [] ambient none + rw [show totalSteps n m v rs = rowsTime v rs + ((m + 1) + ((n + 1) + + 2 * ((inputWord n m rs).length + 1))) by unfold totalSteps; omega, + Function.iterate_add_apply _ (rowsTime v rs), + Function.iterate_add_apply _ (m + 1), Function.iterate_add_apply _ (n + 1), + hcopy, hfirst, hsecond] + exact hrows + +theorem totalSteps_le (n m v : Nat) (rs : List Row) : + totalSteps n m v rs ≤ 5 * (inputWord n m rs).length + 3 := by + have hrows := rowsTime_le v rs + have hlen := inputWord_length n m rs + unfold totalSteps + omega + +open IndependentSetsGames.Foundations.PCP + +def tableRows (t : GraphTables.Table) : List Row := + (GraphTables.rowList t).map (fun r => + (r.tail.val, r.reverseIndex.val :: GraphTables.relationWords r.relation)) + +theorem tableRows_width (t : GraphTables.Table) : + ∀ r ∈ tableRows t, r.2.length = 4097 := by + intro r hr + obtain ⟨a, ha, rfl⟩ := List.mem_map.mp hr + simp [GraphTables.relationWords] + +theorem tableRows_words (t : GraphTables.Table) : + (tableRows t).flatMap rowWords = (GraphTables.rowList t).flatMap GraphTables.rowWords := by + simp only [tableRows, List.flatMap_map] + apply congrArg (fun f => (GraphTables.rowList t).flatMap f) + funext r + rfl + +theorem tableRows_input (t : GraphTables.Table) : + inputWord t.vertices t.darts (tableRows t) = GraphTables.tableBits t := by + rw [inputWord, tableRows_words] + rfl + +theorem rowsHits_eq_filter (v : Nat) (rs : List Row) : + rowsHits v rs = (rs.filter (fun r => decide (r.1 = v))).length := by + induction rs with + | nil => rfl + | cons r rs ih => + by_cases h : r.1 = v <;> simp [rowsHits, h, ih, Nat.add_comm] + +theorem rowList_eq_finRange_map (t : GraphTables.Table) : + GraphTables.rowList t = (List.finRange t.darts).map (fun e => t.rows[e]) := by + apply List.ext_getElem + · simp [GraphTables.rowList] + · intro i hi hj + simp [GraphTables.rowList] + +theorem rowList_cloud_count (t : GraphTables.Table) (v : Fin t.vertices) : + ((GraphTables.rowList t).filter (fun r => decide (r.tail = v))).length = + PreprocessingCloudIndex.cloudSize t v := by + rw [rowList_eq_finRange_map, List.filter_map, List.length_map] + rfl + +theorem tableRows_hits (t : GraphTables.Table) (v : Fin t.vertices) : + rowsHits v.val (tableRows t) = PreprocessingCloudIndex.cloudSize t v := by + rw [rowsHits_eq_filter] + simp only [tableRows, List.filter_map, List.length_map] + simpa only [Function.comp_def, Fin.val_inj] using rowList_cloud_count t v + +theorem cloudCountTrace (t : GraphTables.Table) (v : Fin t.vertices) + (targetSuffix countSuffix : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program (σ := σ))))^[totalSteps t.vertices t.darts v.val (tableRows t)] + (some ⟨some .copyFirst, ((ambient, false), register), + memory (GraphTables.tableBits t) [] (encodeWord v.val ++ targetSuffix) [] + (encodeWord 0 ++ countSuffix) []⟩) = + some ⟨none, ((ambient, false), none), + memory (GraphTables.tableBits t) [] (encodeWord v.val ++ targetSuffix) [] + (encodeWord (PreprocessingCloudIndex.cloudSize t v) ++ countSuffix) []⟩ := by + have h := countTrace t.vertices t.darts v.val (tableRows t) (tableRows_width t) + targetSuffix (encodeWord 0 ++ countSuffix) ambient register + rw [tableRows_input, tableRows_hits, ← List.append_assoc, replicate_encodeWord, Nat.add_zero] at h + exact h + +def cloudCountInTime (t : GraphTables.Table) (v : Fin t.vertices) + (targetSuffix countSuffix : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program (σ := σ))) + ⟨some .copyFirst, ((ambient, false), register), + memory (GraphTables.tableBits t) [] (encodeWord v.val ++ targetSuffix) [] + (encodeWord 0 ++ countSuffix) []⟩ + (some ⟨none, ((ambient, false), none), + memory (GraphTables.tableBits t) [] (encodeWord v.val ++ targetSuffix) [] + (encodeWord (PreprocessingCloudIndex.cloudSize t v) ++ countSuffix) []⟩) + (5 * (GraphTables.tableBits t).length + 3) where + steps := totalSteps t.vertices t.darts v.val (tableRows t) + evals_in_steps := cloudCountTrace t v targetSuffix countSuffix ambient register + steps_le_m := by + simpa only [tableRows_input] using totalSteps_le t.vertices t.darts v.val (tableRows t) + +end IndependentSetsGames.Foundations.Complexity.MachineCloudCount + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudPadding.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..f255fd3d22de0ccfe9b489ca95130703deb0f336 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudPadding.lean @@ -0,0 +1,517 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudCount +import OAI.Combinatorics.IndependentSets.Machines.MachineCeilingPower + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCloudPadding + +open Turing +open MachineComposition +open IndependentSetsGames.Foundations.PCP + +namespace Placement + +variable {K K' Λ Λ' σ : Type} + +def tapes (view : K' → Option K) (source : K → List Bool) + (extra : K' → List Bool) : K' → List Bool := + fun j => match view j with + | some k => source k + | none => extra j + +def label (labels : Λ → Λ') (exit : Option Λ') : Option Λ → Option Λ' + | some l => some (labels l) + | none => exit + +def configuration (view : K' → Option K) (labels : Λ → Λ') (exit : Option Λ') + (extra : K' → List Bool) (c : TM2.Cfg (fun _ : K => Bool) Λ σ) : + TM2.Cfg (fun _ : K' => Bool) Λ' σ := + ⟨label labels exit c.l, c.var, tapes view c.stk extra⟩ + +def statement (tape : K → K') (labels : Λ → Λ') (exit : Option Λ') : + TM2.Stmt (fun _ : K => Bool) Λ σ → TM2.Stmt (fun _ : K' => Bool) Λ' σ + | .push k f next => .push (tape k) f (statement tape labels exit next) + | .peek k f next => .peek (tape k) f (statement tape labels exit next) + | .pop k f next => .pop (tape k) f (statement tape labels exit next) + | .load f next => .load f (statement tape labels exit next) + | .branch f yes no => .branch f (statement tape labels exit yes) (statement tape labels exit no) + | .goto f => .goto (fun state => labels (f state)) + | .halt => match exit with + | some l => .goto (fun _ => l) + | none => .halt + +variable [DecidableEq K] [DecidableEq K'] + +omit [DecidableEq K] [DecidableEq K'] in +theorem tapes_apply (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (source : K → List Bool) (extra : K' → List Bool) (k : K) : + tapes view source extra (tape k) = source k := by + simp only [tapes, left] + +theorem tapes_update (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (source : K → List Bool) (extra : K' → List Bool) (k : K) (w : List Bool) : + tapes view (Function.update source k w) extra = + Function.update (tapes view source extra) (tape k) w := by + funext j + by_cases h : j = tape k + · subst j + simp [tapes, left] + · cases hv : view j with + | none => simp [tapes, hv, h] + | some i => + have hi : i ≠ k := by + intro hi + subst i + exact h (right j k hv).symm + simp [tapes, hv, h, hi] + +theorem stepAux_simulation (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (labels : Λ → Λ') (exit : Option Λ') (extra : K' → List Bool) + (q : TM2.Stmt (fun _ : K => Bool) Λ σ) (state : σ) (source : K → List Bool) : + TM2.stepAux (statement tape labels exit q) state (tapes view source extra) = + configuration view labels exit extra (TM2.stepAux q state source) := by + induction q generalizing state source with + | push k f next ih => + simp only [statement, TM2.stepAux, tapes_apply tape view left] + rw [← tapes_update tape view left right] + exact ih state (Function.update source k (f state :: source k)) + | peek k f next ih => + simpa only [statement, TM2.stepAux, tapes_apply tape view left] using + ih (f state (source k).head?) source + | pop k f next ih => + simp only [statement, TM2.stepAux, tapes_apply tape view left] + rw [← tapes_update tape view left right] + exact ih (f state (source k).head?) (Function.update source k (source k).tail) + | load f next ih => simpa only [statement, TM2.stepAux] using ih (f state) source + | branch f yes no ihYes ihNo => + cases h : f state with + | false => simpa only [statement, TM2.stepAux, h, Bool.cond_false] using ihNo state source + | true => simpa only [statement, TM2.stepAux, h, Bool.cond_true] using ihYes state source + | goto f => rfl + | halt => cases exit <;> rfl + +theorem step_simulation (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (labels : Λ → Λ') (exit : Option Λ') (extra : K' → List Bool) + (source : Λ → TM2.Stmt (fun _ : K => Bool) Λ σ) + (target : Λ' → TM2.Stmt (fun _ : K' => Bool) Λ' σ) + (atLabels : ∀ l, target (labels l) = statement tape labels exit (source l)) + (a b : TM2.Cfg (fun _ : K => Bool) Λ σ) (h : TM2.step source a = some b) : + TM2.step target (configuration view labels exit extra a) = + some (configuration view labels exit extra b) := by + cases a with + | mk l state sourceTapes => + cases l with + | none => simp [TM2.step] at h + | some l => + have hb : TM2.stepAux (source l) state sourceTapes = b := Option.some.inj h + rw [← hb] + change some (TM2.stepAux (target (labels l)) state (tapes view sourceTapes extra)) = _ + rw [atLabels, stepAux_simulation tape view left right] + +theorem trace (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (labels : Λ → Λ') (exit : Option Λ') (extra : K' → List Bool) + (source : Λ → TM2.Stmt (fun _ : K => Bool) Λ σ) + (target : Λ' → TM2.Stmt (fun _ : K' => Bool) Λ' σ) + (atLabels : ∀ l, target (labels l) = statement tape labels exit (source l)) + (n : Nat) (a b : TM2.Cfg (fun _ : K => Bool) Λ σ) + (run : (advance (TM2.step source))^[n] (some a) = some b) : + (advance (TM2.step target))^[n] + (some (configuration view labels exit extra a)) = + some (configuration view labels exit extra b) := + liftSuccessfulTrace _ _ _ + (step_simulation tape view left right labels exit extra source target atLabels) n a b run + +end Placement + +inductive Tape + | table | query | count | work | scratch | spare | power | level | fuel | product + deriving DecidableEq + +instance : Fintype Tape where + elems := {.table, .query, .count, .work, .scratch, .spare, .power, .level, .fuel, .product} + complete value := by cases value <;> simp + +inductive Label + | init | countCode (l : MachineCloudCount.Label) + | branch | powerCode (l : MachineCeilingPower.Label) + | subtract | restore + deriving DecidableEq, Fintype + +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := (σ × Bool) × Option Bool + +def memory (table query count work scratch spare power level fuel product : List Bool) : + Tape → List Bool + | .table => table + | .query => query + | .count => count + | .work => work + | .scratch => scratch + | .spare => spare + | .power => power + | .level => level + | .fuel => fuel + | .product => product + +@[simp] theorem update_count (a b c d e f g h i j x : List Bool) : + Function.update (memory a b c d e f g h i j) .count x = memory a b x d e f g h i j := by + funext k; cases k <;> rfl +@[simp] theorem update_scratch (a b c d e f g h i j x : List Bool) : + Function.update (memory a b c d e f g h i j) .scratch x = memory a b c d x f g h i j := by + funext k; cases k <;> rfl +@[simp] theorem update_power (a b c d e f g h i j x : List Bool) : + Function.update (memory a b c d e f g h i j) .power x = memory a b c d e f x h i j := by + funext k; cases k <;> rfl + +@[simp] theorem update_level (a b c d e f g h i j x : List Bool) : + Function.update (memory a b c d e f g h i j) .level x = memory a b c d e f g x i j := by + funext k; cases k <;> rfl + +def countTape : MachineCloudCount.Tape → Tape + | .original => .table + | .target => .query + | .count => .count + | .work => .work + | .scratch => .scratch + | .spare => .spare + +def countView : Tape → Option MachineCloudCount.Tape + | .table => some .original + | .query => some .target + | .count => some .count + | .work => some .work + | .scratch => some .scratch + | .spare => some .spare + | _ => none + +theorem countView_left (k : MachineCloudCount.Tape) : countView (countTape k) = some k := by + cases k <;> rfl +theorem countView_right (j : Tape) (k : MachineCloudCount.Tape) + (h : countView j = some k) : countTape k = j := by + cases j <;> cases k <;> simp_all [countView, countTape] + +def powerTape : MachineCeilingPower.Tape → Tape + | .input => .count + | .work => .work + | .power => .power + | .saved => .scratch + | .level => .level + | .fuel => .fuel + | .spare => .spare + | .product => .product + +def powerView : Tape → Option MachineCeilingPower.Tape + | .count => some .input + | .work => some .work + | .power => some .power + | .scratch => some .saved + | .level => some .level + | .fuel => some .fuel + | .spare => some .spare + | .product => some .product + | _ => none + +theorem powerView_left (k : MachineCeilingPower.Tape) : powerView (powerTape k) = some k := by + cases k <;> rfl +theorem powerView_right (j : Tape) (k : MachineCeilingPower.Tape) + (h : powerView j = some k) : powerTape k = j := by + cases j <;> cases k <;> simp_all [powerView, powerTape] + +@[simp] theorem countMemory (a b c d e f g h i j : List Bool) : + Placement.tapes countView (MachineCloudCount.memory a d b e c f) + (memory a b c d e f g h i j) = memory a b c d e f g h i j := by + funext k; cases k <;> rfl + +@[simp] theorem powerMemory (a b c d e f g h i j : List Bool) : + Placement.tapes powerView (MachineCeilingPower.memory c d g e h i f j) + (memory a b c d e f g h i j) = memory a b c d e f g h i j := by + funext k; cases k <;> rfl + +theorem countTapes (a b c d e f : List Bool) (extra : Tape → List Bool) : + Placement.tapes countView (MachineCloudCount.memory a d b e c f) extra = + memory a b c d e f (extra .power) (extra .level) (extra .fuel) (extra .product) := by + funext k; cases k <;> rfl + +theorem powerTapes (c d g e h i f j : List Bool) (extra : Tape → List Bool) : + Placement.tapes powerView (MachineCeilingPower.memory c d g e h i f j) extra = + memory (extra .table) (extra .query) c d e f g h i j := by + funext k; cases k <;> rfl + +variable {σ : Type} + +def subtractLoop : TM2.Stmt Alphabet Label (State σ) := + .pop .count (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.pop .power (fun state _ => (state.1, none)) + (.push .scratch (fun _ => true) (.goto fun _ => .subtract))) + (.push .count (fun _ => false) + (.load (fun state => (state.1, none)) (.goto fun _ => .restore)))) + +def program : Label → TM2.Stmt Alphabet Label (State σ) + | .init => .push .count (fun _ => false) (.goto fun _ => .countCode .copyFirst) + | .countCode l => Placement.statement countTape Label.countCode (some .branch) + (MachineCloudCount.program l) + | .branch => .peek .count (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.load (fun state => (state.1, none)) (.goto fun _ => .powerCode .init)) + (.push .power (fun _ => false) (.push .level (fun _ => false) + (.load (fun state => (state.1, none)) .halt)))) + | .powerCode l => Placement.statement powerTape Label.powerCode (some .subtract) + (MachineCeilingPower.program ExpanderFamily.growth l) + | .subtract => subtractLoop + | .restore => Reduction.MachineTransfer.loopAt + .scratch .count id false .restore none + +theorem appendTrace {α : Type} (f : α → α) {a b : Nat} {x y z : α} + (hs : f^[a] x = y) (ht : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm a b, Function.iterate_add_apply, hs, ht] + +theorem countTrace (t : GraphTables.Table) (v : Fin t.vertices) + (suffix : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[MachineCloudCount.totalSteps t.vertices t.darts v.val + (MachineCloudCount.tableRows t)] + (some ⟨some (.countCode .copyFirst), ((ambient, false), register), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) + (encodeWord 0) [] [] [] [] [] [] []⟩) = + some ⟨some .branch, ((ambient, false), none), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) + (encodeWord (PreprocessingCloudIndex.cloudSize t v)) [] [] [] [] [] [] []⟩ := by + have h := Placement.trace countTape countView countView_left countView_right + Label.countCode (some Label.branch) (fun _ => []) + (MachineCloudCount.program (σ := σ)) program (fun _ => rfl) _ _ _ + (MachineCloudCount.cloudCountTrace t v suffix [] ambient register) + simpa only [Placement.configuration, Placement.label, countTapes, List.append_nil] using h + +theorem powerTrace (table query : List Bool) (k : Nat) (ambient : σ) + (register : Option Bool) : + (advance (TM2.step program))^[MachineCeilingPower.totalTime ExpanderFamily.growth k] + (some ⟨some (.powerCode .init), ((ambient, false), register), + memory table query (encodeWord k) [] [] [] [] [] [] []⟩) = + some ⟨some .subtract, ((ambient, false), none), + memory table query (encodeWord k) [] [] [] + (encodeWord (PreprocessingLevels.paddedSize k)) + (encodeWord (PreprocessingLevels.boundedLevel k)) [] []⟩ := by + have h := Placement.trace powerTape powerView powerView_left powerView_right + Label.powerCode (some Label.subtract) (memory table query [] [] [] [] [] [] [] []) + (MachineCeilingPower.program ExpanderFamily.growth (σ := σ)) program (fun _ => rfl) + _ _ _ (MachineCeilingPower.paddingTrace k ambient register) + simpa only [Placement.configuration, Placement.label, powerTapes, memory] using h + +theorem subtractStep_zero (table query level saved : List Bool) (p : Nat) + (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some .subtract, ((ambient, false), register), + memory table query (encodeWord 0) [] saved [] (encodeWord p) level [] []⟩ = + some ⟨some .restore, ((ambient, false), none), + memory table query (encodeWord 0) [] saved [] (encodeWord p) level [] []⟩ := by + change some (TM2.stepAux subtractLoop _ _) = _ + simp [subtractLoop, TM2.stepAux, memory, encodeWord] + +theorem subtractStep_succ (table query level saved : List Bool) (k p : Nat) + (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some .subtract, ((ambient, false), register), + memory table query (encodeWord (k + 1)) [] saved [] (encodeWord (p + 1)) level [] []⟩ = + some ⟨some .subtract, ((ambient, false), none), + memory table query (encodeWord k) [] (true :: saved) [] (encodeWord p) level [] []⟩ := by + change some (TM2.stepAux subtractLoop _ _) = _ + simp [subtractLoop, TM2.stepAux, memory, encodeWord, List.replicate_succ] + +theorem subtractScanTrace (table query level : List Bool) (k p : Nat) + (saved : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[k + 1] + (some ⟨some .subtract, ((ambient, false), register), + memory table query (encodeWord k) [] saved [] (encodeWord (k + p)) level [] []⟩) = + some ⟨some .restore, ((ambient, false), none), + memory table query (encodeWord 0) [] (List.replicate k true ++ saved) [] + (encodeWord p) level [] []⟩ := by + induction k generalizing saved register with + | zero => simpa only [Nat.zero_add, Function.iterate_one, advance_some, + List.replicate_zero, List.nil_append] using + subtractStep_zero table query level saved p ambient register + | succ k ih => + rw [Function.iterate_succ_apply] + simp only [Nat.succ_add] + change (advance (TM2.step program))^[k + 1] + (TM2.step program ⟨some .subtract, ((ambient, false), register), + memory table query (encodeWord (k + 1)) [] saved [] + (encodeWord ((k + p) + 1)) level [] []⟩) = _ + rw [subtractStep_succ] + simpa only [List.replicate_succ', List.append_assoc, List.singleton_append] using + ih (true :: saved) none + +theorem subtractTrace (table query level : List Bool) (k p : Nat) (hkp : k ≤ p) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[2 * k + 2] + (some ⟨some .subtract, ((ambient, false), register), + memory table query (encodeWord k) [] [] [] (encodeWord p) level [] []⟩) = + some ⟨none, ((ambient, false), none), + memory table query (encodeWord k) [] [] [] (encodeWord (p - k)) level [] []⟩ := by + have hs := subtractScanTrace table query level k (p - k) [] ambient register + rw [show k + (p - k) = p by omega] at hs + simp only [List.append_nil] at hs + let mid := memory table query (encodeWord 0) [] (List.replicate k true) [] + (encodeWord (p - k)) level [] [] + have hr := Reduction.MachineTransfer.transferAt_fromTapes Tape.scratch Tape.count (by decide) + id false Label.restore none program rfl mid (ambient, false) none + simp only [mid, memory, List.length_replicate, List.reverse_replicate, List.map_id, + Reduction.MachineTransfer.tapesAt, update_scratch, update_count] at hr + rw [MachineCeilingPower.replicate_encodeWord, Nat.add_zero] at hr + have h := appendTrace _ hs hr + simpa only [show (k + 1) + (k + 1) = 2 * k + 2 by omega, Nat.add_zero] using h + +theorem branchStep_zero (table query : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some .branch, ((ambient, false), register), + memory table query (encodeWord 0) [] [] [] [] [] [] []⟩ = + some ⟨none, ((ambient, false), none), + memory table query (encodeWord 0) [] [] [] (encodeWord 0) (encodeWord 0) [] []⟩ := by + simp [TM2.step, program, TM2.stepAux, memory, encodeWord] + +theorem branchStep_succ (table query : List Bool) (k : Nat) (ambient : σ) + (register : Option Bool) : + TM2.step program + ⟨some .branch, ((ambient, false), register), + memory table query (encodeWord (k + 1)) [] [] [] [] [] [] []⟩ = + some ⟨some (.powerCode .init), ((ambient, false), none), + memory table query (encodeWord (k + 1)) [] [] [] [] [] [] []⟩ := by + simp [TM2.step, program, TM2.stepAux, memory, encodeWord, List.replicate_succ] + +def padding (k : Nat) : Nat := PreprocessingLevels.cloudPaddedSize k - k + +def postTime (k : Nat) : Nat := + 1 + if k = 0 then 0 else MachineCeilingPower.totalTime ExpanderFamily.growth k + (2 * k + 2) + +theorem postTrace (table query : List Bool) (k : Nat) (ambient : σ) + (register : Option Bool) : + (advance (TM2.step program))^[postTime k] + (some ⟨some .branch, ((ambient, false), register), + memory table query (encodeWord k) [] [] [] [] [] [] []⟩) = + some ⟨none, ((ambient, false), none), + memory table query (encodeWord k) [] [] [] (encodeWord (padding k)) + (encodeWord (PreprocessingLevels.boundedLevel k)) [] []⟩ := by + cases k with + | zero => + simpa only [postTime, ite_eq_left rfl, ite_true, Nat.add_zero, Function.iterate_one, advance_some, + padding, PreprocessingLevels.cloudPaddedSize_zero, Nat.sub_zero, + PreprocessingLevels.boundedLevel_zero] using branchStep_zero table query ambient register + | succ k => + have hb : (advance (TM2.step program))^[1] + (some ⟨some .branch, ((ambient, false), register), + memory table query (encodeWord (k + 1)) [] [] [] [] [] [] []⟩) = + some ⟨some (.powerCode .init), ((ambient, false), none), + memory table query (encodeWord (k + 1)) [] [] [] [] [] [] []⟩ := + branchStep_succ table query k ambient register + have hp := powerTrace table query (k + 1) ambient none + have hs := subtractTrace table query (encodeWord (PreprocessingLevels.boundedLevel (k + 1))) + (k + 1) (PreprocessingLevels.paddedSize (k + 1)) + (PreprocessingLevels.le_paddedSize (k + 1)) ambient none + have h := appendTrace _ hb (appendTrace _ hp hs) + simpa only [postTime, Nat.succ_ne_zero, ite_false, padding, + PreprocessingLevels.cloudPaddedSize_of_pos (Nat.succ_pos k)] using h + +theorem initStep (table query : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some .init, ((ambient, false), register), memory table query [] [] [] [] [] [] [] []⟩ = + some ⟨some (.countCode .copyFirst), ((ambient, false), register), + memory table query (encodeWord 0) [] [] [] [] [] [] []⟩ := by + simp [TM2.step, program, TM2.stepAux, memory, encodeWord] + +def totalTime (t : GraphTables.Table) (v : Fin t.vertices) : Nat := + (1 + MachineCloudCount.totalSteps t.vertices t.darts v.val (MachineCloudCount.tableRows t)) + + postTime (PreprocessingCloudIndex.cloudSize t v) + +theorem cloudPaddingTrace (t : GraphTables.Table) (v : Fin t.vertices) + (suffix : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[totalTime t v] + (some ⟨some .init, ((ambient, false), register), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) [] [] [] [] [] [] [] []⟩) = + some ⟨none, ((ambient, false), none), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) + (encodeWord (PreprocessingCloudIndex.cloudSize t v)) [] [] [] + (encodeWord (padding (PreprocessingCloudIndex.cloudSize t v))) + (encodeWord (PreprocessingLevels.boundedLevel (PreprocessingCloudIndex.cloudSize t v))) + [] []⟩ := by + have hi : (advance (TM2.step program))^[1] + (some ⟨some .init, ((ambient, false), register), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) [] [] [] [] [] [] [] []⟩) = + some ⟨some (.countCode .copyFirst), ((ambient, false), register), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) + (encodeWord 0) [] [] [] [] [] [] []⟩ := + initStep _ _ ambient register + exact appendTrace _ (appendTrace _ hi (countTrace t v suffix ambient register)) + (postTrace _ _ (PreprocessingCloudIndex.cloudSize t v) ambient none) + +def inputLength (t : GraphTables.Table) (v : Fin t.vertices) (suffix : List Bool) : Nat := + (GraphTables.tableBits t).length + (encodeWord v.val ++ suffix).length + +theorem count_length_le (t : GraphTables.Table) (v : Fin t.vertices) (suffix : List Bool) : + PreprocessingCloudIndex.cloudSize t v + 1 ≤ inputLength t v suffix := by + have h := (PreprocessingCloudIndex.cloudSize_le_darts t v).trans + (GraphTables.darts_le_tableBits_length t) + simp only [inputLength, List.length_append, encodeWord_length] + omega + +theorem table_length_le (t : GraphTables.Table) (v : Fin t.vertices) (suffix : List Bool) : + (GraphTables.tableBits t).length ≤ inputLength t v suffix := by + unfold inputLength + omega + +theorem postTime_le (k : Nat) : + postTime k ≤ 1 + MachineCeilingPower.timeBound ExpanderFamily.growth k + (2 * k + 2) := by + have h := MachineCeilingPower.totalTime_le ExpanderFamily.growth k + unfold postTime + split_ifs <;> omega + +noncomputable def timePolynomial : Polynomial Nat := + Polynomial.C (ExpanderFamily.growth + 8) * Polynomial.X ^ 2 + 25 * Polynomial.X + 10 + +theorem totalTime_le (t : GraphTables.Table) (v : Fin t.vertices) (suffix : List Bool) : + totalTime t v ≤ timePolynomial.eval (inputLength t v suffix) := by + have hc := MachineCloudCount.totalSteps_le t.vertices t.darts v.val (MachineCloudCount.tableRows t) + rw [MachineCloudCount.tableRows_input] at hc + have hp := postTime_le (PreprocessingCloudIndex.cloudSize t v) + have hk := count_length_le t v suffix + have ht := table_length_le t v suffix + have hsq := Nat.mul_le_mul_left (ExpanderFamily.growth + 8) + (Nat.pow_le_pow_left hk 2) + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_ofNat] + unfold MachineCeilingPower.timeBound at hp + unfold totalTime + omega + +def cloudPaddingInTime (t : GraphTables.Table) (v : Fin t.vertices) + (suffix : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some .init, ((ambient, false), register), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) [] [] [] [] [] [] [] []⟩ + (some ⟨none, ((ambient, false), none), + memory (GraphTables.tableBits t) (encodeWord v.val ++ suffix) + (encodeWord (PreprocessingCloudIndex.cloudSize t v)) [] [] [] + (encodeWord (padding (PreprocessingCloudIndex.cloudSize t v))) + (encodeWord (PreprocessingLevels.boundedLevel (PreprocessingCloudIndex.cloudSize t v))) + [] []⟩) + (timePolynomial.eval (inputLength t v suffix)) where + steps := totalTime t v + evals_in_steps := cloudPaddingTrace t v suffix ambient register + steps_le_m := totalTime_le t v suffix + +theorem count_add_padding (k : Nat) : k + padding k = PreprocessingLevels.cloudPaddedSize k := by + have h := (PreprocessingLevels.cloudPaddedSize_bounds k).1 + unfold padding + omega + +end IndependentSetsGames.Foundations.Complexity.MachineCloudPadding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudPrefix.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe3663209cbd21077f1e21d6aacc4129cf7e4087 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudPrefix.lean @@ -0,0 +1,451 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudPadding +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAdd +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingPaddingOffsets + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCloudPrefix + +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP +open scoped BigOperators + +inductive Tape + | inner (k : MachineCloudPadding.Tape) + | bound | remaining | total + deriving DecidableEq, Fintype + +inductive Label + | init | copyFirst | copySecond | guard | done + | padding (l : MachineCloudPadding.Label) + | add | clearCount | clearLevel | increment + deriving DecidableEq, Fintype + +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := (σ × Bool) × Option Bool + +def memory (inner : MachineCloudPadding.Tape → List Bool) (bound remaining total : List Bool) : + Tape → List Bool + | .inner k => inner k + | .bound => bound + | .remaining => remaining + | .total => total + +def frame (table query count power level bound remaining total : List Bool) : Tape → List Bool := + memory (MachineCloudPadding.memory table query count [] [] [] power level [] []) bound remaining total + +@[simp] theorem frame_query (a b c d e f g h : List Bool) : + frame a b c d e f g h (.inner .query) = b := rfl +@[simp] theorem frame_count (a b c d e f g h : List Bool) : + frame a b c d e f g h (.inner .count) = c := rfl +@[simp] theorem frame_power (a b c d e f g h : List Bool) : + frame a b c d e f g h (.inner .power) = d := rfl +@[simp] theorem frame_level (a b c d e f g h : List Bool) : + frame a b c d e f g h (.inner .level) = e := rfl +@[simp] theorem frame_bound (a b c d e f g h : List Bool) : + frame a b c d e f g h .bound = f := rfl +@[simp] theorem frame_remaining (a b c d e f g h : List Bool) : + frame a b c d e f g h .remaining = g := rfl +@[simp] theorem frame_total (a b c d e f g h : List Bool) : + frame a b c d e f g h .total = h := rfl + +@[simp] theorem update_frame_query (a b c d e f g h x : List Bool) : + Function.update (frame a b c d e f g h) (.inner .query) x = + frame a x c d e f g h := by + funext k; cases k with + | inner k => cases k <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl +@[simp] theorem update_frame_count (a b c d e f g h x : List Bool) : + Function.update (frame a b c d e f g h) (.inner .count) x = + frame a b x d e f g h := by + funext k; cases k with + | inner k => cases k <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl +@[simp] theorem update_frame_power (a b c d e f g h x : List Bool) : + Function.update (frame a b c d e f g h) (.inner .power) x = + frame a b c x e f g h := by + funext k; cases k with + | inner k => cases k <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl +@[simp] theorem update_frame_level (a b c d e f g h x : List Bool) : + Function.update (frame a b c d e f g h) (.inner .level) x = + frame a b c d x f g h := by + funext k; cases k with + | inner k => cases k <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl +@[simp] theorem update_frame_remaining (a b c d e f g h x : List Bool) : + Function.update (frame a b c d e f g h) .remaining x = + frame a b c d e f x h := by + funext k; cases k <;> rfl +@[simp] theorem update_frame_total (a b c d e f g h x : List Bool) : + Function.update (frame a b c d e f g h) .total x = + frame a b c d e f g x := by + funext k; cases k <;> rfl + +def paddingView : Tape → Option MachineCloudPadding.Tape + | .inner k => some k + | _ => none + +theorem paddingView_left (k : MachineCloudPadding.Tape) : paddingView (.inner k) = some k := rfl + +theorem paddingView_right (j : Tape) (k : MachineCloudPadding.Tape) + (h : paddingView j = some k) : Tape.inner k = j := by + cases j <;> simp_all [paddingView] + +theorem placedTapes (inner : MachineCloudPadding.Tape → List Bool) (extra : Tape → List Bool) : + MachineCloudPadding.Placement.tapes paddingView inner extra = + memory inner (extra .bound) (extra .remaining) (extra .total) := by + funext j; cases j <;> rfl + +variable {σ : Type} + +def program : Label → TM2.Stmt Alphabet Label (State σ) + | .init => .push (.inner .query) (fun _ => false) + (.push .total (fun _ => false) (.goto fun _ => .copyFirst)) + | .copyFirst => Reduction.MachineTransfer.loopAt + .bound (.inner .scratch) id false .copyFirst (some .copySecond) + | .copySecond => MachineCopy.forkLoop + (.inner .scratch) .bound .remaining false .copySecond (some .guard) + | .guard => MachineUnaryCounter.guard .remaining (.padding .init) .done + | .done => .halt + | .padding l => MachineCloudPadding.Placement.statement Tape.inner Label.padding (some .add) (MachineCloudPadding.program l) + | .add => MachineUnaryAddAt.loop (.inner .power) .total .add (some .clearCount) + | .clearCount => MachineLookup.discard (.inner .count) .clearCount .clearLevel + | .clearLevel => MachineLookup.discard (.inner .level) .clearLevel .increment + | .increment => .pop (.inner .power) (fun state _ => (state.1, none)) + (.push (.inner .query) (fun _ => true) (.goto fun _ => .guard)) + +theorem appendTrace {α : Type} (f : α → α) {a b : Nat} {x y z : α} + (hs : f^[a] x = y) (ht : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm a b, Function.iterate_add_apply, hs, ht] + +theorem paddingTrace (t : GraphTables.Table) (v : Fin t.vertices) + (bound remaining total : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[MachineCloudPadding.totalTime t v] + (some ⟨some (.padding .init), ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord v.val) [] [] [] bound remaining total⟩) = + some ⟨some .add, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord v.val) + (encodeWord (PreprocessingCloudIndex.cloudSize t v)) + (encodeWord (MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t v))) + (encodeWord (PreprocessingLevels.boundedLevel (PreprocessingCloudIndex.cloudSize t v))) + bound remaining total⟩ := by + have h := MachineCloudPadding.Placement.trace Tape.inner paddingView paddingView_left paddingView_right + Label.padding (some Label.add) (frame [] [] [] [] [] bound remaining total) + (MachineCloudPadding.program (σ := σ)) program (fun _ => rfl) _ _ _ + (MachineCloudPadding.cloudPaddingTrace t v [] ambient register) + simpa only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, placedTapes, + frame_bound, frame_remaining, frame_total, List.append_nil, frame, memory] using h + +theorem incrementStep (table bound remaining total : List Bool) (v : Nat) + (ambient : σ) (register : Option Bool) : + TM2.step (program (σ := σ)) + ⟨some .increment, ((ambient, false), register), + frame table (encodeWord v) [] (encodeWord 0) [] bound remaining total⟩ = + some ⟨some .guard, ((ambient, false), none), + frame table (encodeWord (v + 1)) [] [] [] bound remaining total⟩ := by + simp [TM2.step, program, TM2.stepAux, encodeWord, List.replicate_succ] + +def bodyTime (t : GraphTables.Table) (v : Fin t.vertices) : Nat := + MachineCloudPadding.totalTime t v + (MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t v) + 1) + + (PreprocessingCloudIndex.cloudSize t v + 1) + + (PreprocessingLevels.boundedLevel (PreprocessingCloudIndex.cloudSize t v) + 1) + 1 + +theorem bodyTrace (t : GraphTables.Table) (v : Fin t.vertices) + (bound remaining : List Bool) (acc : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[bodyTime t v] + (some ⟨some (.padding .init), ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord v.val) [] [] [] + bound remaining (encodeWord acc)⟩) = + some ⟨some .guard, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord (v.val + 1)) [] [] [] + bound remaining (encodeWord (MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t v) + acc))⟩ := by + let k := PreprocessingCloudIndex.cloudSize t v + let p := MachineCloudPadding.padding k + let l := PreprocessingLevels.boundedLevel k + have hp := paddingTrace t v bound remaining (encodeWord acc) ambient register + have ha := MachineUnaryAddAt.addFromTapes (Tape.inner .power) Tape.total (by decide) + Label.add (some Label.clearCount) program rfl + (frame (GraphTables.tableBits t) (encodeWord v.val) (encodeWord k) + (encodeWord p) (encodeWord l) bound remaining (encodeWord acc)) + p acc [] [] (by simp) (by simp) (ambient, false) none + simp only [MachineUnaryAddAt.unaryTapes, Reduction.MachineTransfer.tapesAt, + List.append_nil, update_frame_power, update_frame_total] at ha + have hc := MachineLookup.discardTrace (Tape.inner .count) Label.clearCount Label.clearLevel + program rfl + (frame (GraphTables.tableBits t) (encodeWord v.val) (encodeWord k) + (encodeWord 0) (encodeWord l) bound remaining (encodeWord (p + acc))) + k [] (by simp) (ambient, false) none + simp only [update_frame_count] at hc + have hl := MachineLookup.discardTrace (Tape.inner .level) Label.clearLevel Label.increment + program rfl + (frame (GraphTables.tableBits t) (encodeWord v.val) [] + (encodeWord 0) (encodeWord l) bound remaining (encodeWord (p + acc))) + l [] (by simp) (ambient, false) none + simp only [update_frame_level] at hl + have hi : (advance (TM2.step program))^[1] + (some ⟨some .increment, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord v.val) [] (encodeWord 0) [] + bound remaining (encodeWord (p + acc))⟩) = + some ⟨some .guard, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord (v.val + 1)) [] [] [] + bound remaining (encodeWord (p + acc))⟩ := + incrementStep _ _ _ _ _ ambient none + exact appendTrace _ (appendTrace _ (appendTrace _ (appendTrace _ hp ha) hc) hl) hi + +theorem guardStep_succ (table bound suffix total : List Bool) (v n : Nat) + (ambient : σ) (register : Option Bool) : + TM2.step (program (σ := σ)) + ⟨some .guard, ((ambient, false), register), + frame table (encodeWord v) [] [] [] bound (encodeWord (n + 1) ++ suffix) total⟩ = + some ⟨some (.padding .init), ((ambient, false), none), + frame table (encodeWord v) [] [] [] bound (encodeWord n ++ suffix) total⟩ := by + simp [TM2.step, program, MachineUnaryCounter.guard, TM2.stepAux, encodeWord, + List.replicate_succ] + +theorem guardStep_zero (table bound suffix total : List Bool) (v : Nat) + (ambient : σ) (register : Option Bool) : + TM2.step (program (σ := σ)) + ⟨some .guard, ((ambient, false), register), + frame table (encodeWord v) [] [] [] bound (encodeWord 0 ++ suffix) total⟩ = + some ⟨some .done, ((ambient, false), none), + frame table (encodeWord v) [] [] [] bound (encodeWord 0 ++ suffix) total⟩ := rfl + +theorem zeroTrace (table bound suffix total : List Bool) (v : Nat) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program (σ := σ))))^[2] + (some ⟨some .guard, ((ambient, false), register), + frame table (encodeWord v) [] [] [] bound (encodeWord 0 ++ suffix) total⟩) = + some ⟨none, ((ambient, false), none), + frame table (encodeWord v) [] [] [] bound (encodeWord 0 ++ suffix) total⟩ := by + rw [Function.iterate_succ_apply] + change advance (TM2.step (program (σ := σ))) + (TM2.step program ⟨some .guard, ((ambient, false), register), + frame table (encodeWord v) [] [] [] bound (encodeWord 0 ++ suffix) total⟩) = _ + rw [guardStep_zero] + rfl + +def amount (t : GraphTables.Table) (v : Nat) : Nat := + if h : v < t.vertices then MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t ⟨v, h⟩) else 0 + +def cycleTime (t : GraphTables.Table) (v : Nat) : Nat := + if h : v < t.vertices then 1 + bodyTime t ⟨v, h⟩ else 0 + +def sumFrom (t : GraphTables.Table) (v : Nat) : Nat → Nat + | 0 => 0 + | n + 1 => amount t v + sumFrom t (v + 1) n + +def loopTime (t : GraphTables.Table) (v : Nat) : Nat → Nat + | 0 => 2 + | n + 1 => cycleTime t v + loopTime t (v + 1) n + +theorem loopTrace (t : GraphTables.Table) (n v : Nat) (hvn : v + n ≤ t.vertices) + (bound suffix : List Bool) (acc : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[loopTime t v n] + (some ⟨some .guard, ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord v) [] [] [] + bound (encodeWord n ++ suffix) (encodeWord acc)⟩) = + some ⟨none, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord (v + n)) [] [] [] + bound (encodeWord 0 ++ suffix) (encodeWord (sumFrom t v n + acc))⟩ := by + induction n generalizing v acc register with + | zero => + simpa only [loopTime, sumFrom, Nat.add_zero, Nat.zero_add] using + zeroTrace _ bound suffix (encodeWord acc) v ambient register + | succ n ih => + have hv : v < t.vertices := by omega + have hnext : v + 1 + n ≤ t.vertices := by omega + have hg : (advance (TM2.step program))^[1] + (some ⟨some .guard, ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord v) [] [] [] + bound (encodeWord (n + 1) ++ suffix) (encodeWord acc)⟩) = + some ⟨some (.padding .init), ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord v) [] [] [] + bound (encodeWord n ++ suffix) (encodeWord acc)⟩ := + guardStep_succ _ bound suffix (encodeWord acc) v n ambient register + have hb := bodyTrace t ⟨v, hv⟩ bound (encodeWord n ++ suffix) acc ambient none + have ht := ih (v + 1) hnext + (MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t ⟨v, hv⟩) + acc) none + have hall := appendTrace _ (appendTrace _ hg hb) ht + simpa only [loopTime, cycleTime, dite_eq_left hv, sumFrom, amount, + Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hall + +theorem sumFrom_list (t : GraphTables.Table) (xs : List (Fin t.vertices)) (v : Nat) + (hseq : ∀ i (hi : i < xs.length), (xs[i]).val = v + i) : + sumFrom t v xs.length = (xs.map (PreprocessingRegularTables.padding t)).sum := by + induction xs generalizing v with + | nil => simp [sumFrom] + | cons x xs ih => + have hx : x.val = v := (hseq 0 (by simp)).trans (Nat.add_zero v) + have hv : v < t.vertices := by simpa only [hx] using x.isLt + have he : (⟨v, hv⟩ : Fin t.vertices) = x := Fin.ext hx.symm + have hnext : ∀ i (hi : i < xs.length), (xs[i]).val = v + 1 + i := by + intro i hi + have h := hseq (i + 1) (by simpa using Nat.succ_lt_succ hi) + simpa only [List.getElem_cons_succ, Nat.add_assoc, Nat.add_comm, + Nat.add_left_comm] using h + simp only [List.length_cons, sumFrom, amount, dite_eq_left hv, he, + List.map_cons, List.sum_cons] + rw [ih (v + 1) hnext] + rfl + +theorem sumFrom_eq_offset (t : GraphTables.Table) (b : Nat) (hb : b ≤ t.vertices) : + sumFrom t 0 b = + PreprocessingPaddingOffsets.offset (PreprocessingRegularTables.padding t) b := by + have h := sumFrom_list t ((List.finRange t.vertices).take b) 0 + (by intro i hi; simp only [List.getElem_take, List.getElem_finRange, Fin.val_cast, + Nat.zero_add]) + simpa only [List.length_take, List.length_finRange, Nat.min_eq_left hb, + PreprocessingPaddingOffsets.offset] using h + +theorem initStep (table bound : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step (program (σ := σ)) + ⟨some .init, ((ambient, false), register), frame table [] [] [] [] bound [] []⟩ = + some ⟨some .copyFirst, ((ambient, false), register), + frame table (encodeWord 0) [] [] [] bound [] (encodeWord 0)⟩ := by + simp [TM2.step, program, TM2.stepAux, encodeWord] + +def totalTime (t : GraphTables.Table) (b : Nat) (suffix : List Bool) : Nat := + (1 + 2 * ((encodeWord b ++ suffix).length + 1)) + loopTime t 0 b + +theorem prefixTrace (t : GraphTables.Table) (b : Nat) (hb : b ≤ t.vertices) + (suffix : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[totalTime t b suffix] + (some ⟨some .init, ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] (encodeWord b ++ suffix) [] []⟩) = + some ⟨none, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord b) [] [] [] + (encodeWord b ++ suffix) (encodeWord 0 ++ suffix) + (encodeWord (PreprocessingPaddingOffsets.offset + (PreprocessingRegularTables.padding t) b))⟩ := by + have hi : (advance (TM2.step program))^[1] + (some ⟨some .init, ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] (encodeWord b ++ suffix) [] []⟩) = + some ⟨some .copyFirst, ((ambient, false), register), + frame (GraphTables.tableBits t) (encodeWord 0) [] [] [] + (encodeWord b ++ suffix) [] (encodeWord 0)⟩ := + initStep _ _ ambient register + have hc := MachineCopy.copyTrace Tape.bound Tape.remaining (Tape.inner .scratch) + (by decide) (by decide) (by decide) false Label.copyFirst Label.copySecond + (some Label.guard) program rfl rfl + (frame (GraphTables.tableBits t) (encodeWord 0) [] [] [] + (encodeWord b ++ suffix) [] (encodeWord 0)) rfl (ambient, false) register + simp only [frame_bound, frame_remaining, List.append_nil, update_frame_remaining] at hc + have hl := loopTrace t b 0 (by simpa only [Nat.zero_add] using hb) + (encodeWord b ++ suffix) suffix 0 ambient none + simp only [Nat.zero_add, Nat.add_zero, sumFrom_eq_offset t b hb] at hl + exact appendTrace _ (appendTrace _ hi hc) hl + +def cycleBudget (L : Nat) : Nat := + (ExpanderFamily.growth + 8) * (2 * L) ^ 2 + 25 * (2 * L) + 10 + + (ExpanderFamily.growth + 2) * L + 5 + +theorem bodyTime_le (t : GraphTables.Table) (v : Fin t.vertices) (L : Nat) + (hL : (GraphTables.tableBits t).length ≤ L) : + 1 + bodyTime t v ≤ cycleBudget L := by + have hn := GraphTables.vertices_le_tableBits_length t + have hv := v.isLt + have hinput : MachineCloudPadding.inputLength t v [] ≤ 2 * L := by + simp only [MachineCloudPadding.inputLength, List.append_nil, encodeWord_length] + omega + have hp := (MachineCloudPadding.totalTime_le t v []).trans + (natPolynomial_eval_mono MachineCloudPadding.timePolynomial hinput) + simp only [MachineCloudPadding.timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_ofNat] at hp + have hk : PreprocessingCloudIndex.cloudSize t v ≤ L := + (PreprocessingCloudIndex.cloudSize_le_darts t v).trans + ((GraphTables.darts_le_tableBits_length t).trans hL) + have hl := (PreprocessingLevels.boundedLevel_le_input + (PreprocessingCloudIndex.cloudSize t v)).trans hk + have hpad : MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t v) ≤ + ExpanderFamily.growth * L := by + have hsize := (PreprocessingLevels.cloudPaddedSize_bounds + (PreprocessingCloudIndex.cloudSize t v)).2 + have hmul := Nat.mul_le_mul_left ExpanderFamily.growth hk + unfold MachineCloudPadding.padding + omega + unfold bodyTime cycleBudget + simp only [Nat.add_mul] at hp ⊢ + omega + +theorem loopTime_le (t : GraphTables.Table) (n v : Nat) (hvn : v + n ≤ t.vertices) + (L : Nat) (hL : (GraphTables.tableBits t).length ≤ L) : + loopTime t v n ≤ n * cycleBudget L + 2 := by + induction n generalizing v with + | zero => simp only [loopTime, Nat.zero_mul, Nat.zero_add, le_refl] + | succ n ih => + have hv : v < t.vertices := by omega + have hnext : v + 1 + n ≤ t.vertices := by omega + have hbody := bodyTime_le t ⟨v, hv⟩ L hL + have htail := ih (v + 1) hnext + simp only [loopTime, cycleTime, dite_eq_left hv, Nat.succ_mul] + omega + +def inputLength (t : GraphTables.Table) (b : Nat) (suffix : List Bool) : Nat := + (GraphTables.tableBits t).length + (encodeWord b ++ suffix).length + +noncomputable def timePolynomial : Polynomial Nat := + Polynomial.X * + (Polynomial.C (ExpanderFamily.growth + 8) * (2 * Polynomial.X) ^ 2 + + 25 * (2 * Polynomial.X) + 10 + + Polynomial.C (ExpanderFamily.growth + 2) * Polynomial.X + 5) + + 2 * (Polynomial.X + 1) + 3 + +theorem totalTime_le (t : GraphTables.Table) (b : Nat) (hb : b ≤ t.vertices) + (suffix : List Bool) : + totalTime t b suffix ≤ timePolynomial.eval (inputLength t b suffix) := by + let L := inputLength t b suffix + have htable : (GraphTables.tableBits t).length ≤ L := by + unfold L inputLength + omega + have hbound : (encodeWord b ++ suffix).length ≤ L := by + unfold L inputLength + omega + have hbL : b ≤ L := hb.trans ((GraphTables.vertices_le_tableBits_length t).trans htable) + have hloop := loopTime_le t b 0 (by simpa only [Nat.zero_add] using hb) L htable + have hmul := Nat.mul_le_mul_right (cycleBudget L) hbL + have htotal : totalTime t b suffix ≤ L * cycleBudget L + 2 * (L + 1) + 3 := by + unfold totalTime + omega + simpa only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_ofNat, + Polynomial.eval_one, cycleBudget, L] using htotal + +def prefixInTime (t : GraphTables.Table) (b : Nat) (hb : b ≤ t.vertices) + (suffix : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some .init, ((ambient, false), register), + frame (GraphTables.tableBits t) [] [] [] [] (encodeWord b ++ suffix) [] []⟩ + (some ⟨none, ((ambient, false), none), + frame (GraphTables.tableBits t) (encodeWord b) [] [] [] + (encodeWord b ++ suffix) (encodeWord 0 ++ suffix) + (encodeWord (PreprocessingPaddingOffsets.offset + (PreprocessingRegularTables.padding t) b))⟩) + (timePolynomial.eval (inputLength t b suffix)) where + steps := totalTime t b suffix + evals_in_steps := prefixTrace t b hb suffix ambient register + steps_le_m := totalTime_le t b hb suffix + +theorem all_padding_sum (t : GraphTables.Table) : + sumFrom t 0 t.vertices = ∑ v, PreprocessingRegularTables.padding t v := by + rw [sumFrom_eq_offset t t.vertices (Nat.le_refl _), PreprocessingPaddingOffsets.offset_all] + +theorem paddingOrder_eq_prefix (t : GraphTables.Table) (v : Fin t.vertices) + (j : Fin (PreprocessingRegularTables.padding t v)) : + (PreprocessingRegularTables.paddingOrder (PreprocessingRegularTables.padding t) ⟨v, j⟩).val = + sumFrom t 0 v.val + j.val := by + rw [PreprocessingPaddingOffsets.paddingOrder_val, + sumFrom_eq_offset t v.val v.isLt.le] + +end IndependentSetsGames.Foundations.Complexity.MachineCloudPrefix + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudRank.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..07e9c389b525b8be8e8e15eea7d8a4252b6bc3ae --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudRank.lean @@ -0,0 +1,328 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudCount + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCloudRank + +open Turing MachineComposition MachineCloudCount + +variable {σ : Type} + +@[simp] theorem update_memory_spare (a b c d e f x : List Bool) : + Function.update (memory a b c d e f) .spare x = memory a b c d e x := by + funext k + cases k <;> rfl + +inductive RankLabel + | queryFirst | querySecond | querySkip | tableFirst | tableSecond + | headerFirst | headerSecond | row | field | restore | done + | skip (i : Fin 4097) + deriving DecidableEq, Fintype + +def rankSkip (i : Nat) : RankLabel := + if h : i < 4097 then .skip ⟨i, h⟩ else .row + +def rankProgram : RankLabel → TM2.Stmt Alphabet RankLabel (State σ) + | .queryFirst => Reduction.MachineTransfer.loopAt + .target .scratch id false .queryFirst (some .querySecond) + | .querySecond => MachineCopy.forkLoop + .scratch .target .spare false .querySecond (some .querySkip) + | .querySkip => MachineLookup.discard .spare .querySkip .tableFirst + | .tableFirst => Reduction.MachineTransfer.loopAt + .original .scratch id false .tableFirst (some .tableSecond) + | .tableSecond => MachineCopy.forkLoop + .scratch .original .work false .tableSecond (some .headerFirst) + | .headerFirst => MachineLookup.discard .work .headerFirst .headerSecond + | .headerSecond => MachineLookup.discard .work .headerSecond .row + | .row => MachineUnaryCounter.guard .spare .field .done + | .field => fieldLoop .field .restore + | .restore => Reduction.MachineTransfer.loopAt + .scratch .target id false .restore (some (rankSkip 0)) + | .skip i => MachineLookup.discard .work (.skip i) (rankSkip (i.val + 1)) + | .done => .halt + +theorem rankProgram_skip {i : Nat} (hi : i < 4097) : + rankProgram (σ := σ) (rankSkip i) = + MachineLookup.discard .work (rankSkip i) (rankSkip (i + 1)) := by + simp only [rankSkip, dite_eq_left hi, rankProgram] + +theorem rowGuard_succ (original work target scratch count fuelSuffix : List Bool) + (k : Nat) (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step (rankProgram (σ := σ)) + ⟨some .row, ((ambient, flag), register), + memory original work target scratch count (encodeWord (k + 1) ++ fuelSuffix)⟩ = + some ⟨some .field, ((ambient, flag), none), + memory original work target scratch count (encodeWord k ++ fuelSuffix)⟩ := by + change some (TM2.stepAux (rankProgram .row) _ _) = _ + simp [rankProgram, MachineUnaryCounter.guard, TM2.stepAux, encodeWord, + List.replicate_succ] + +theorem rowGuard_zero (original work target scratch count fuelSuffix : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step (rankProgram (σ := σ)) + ⟨some .row, ((ambient, flag), register), + memory original work target scratch count (encodeWord 0 ++ fuelSuffix)⟩ = + some ⟨some .done, ((ambient, flag), none), + memory original work target scratch count (encodeWord 0 ++ fuelSuffix)⟩ := rfl + +theorem zeroRowsTrace (original work target scratch count fuelSuffix : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step (rankProgram (σ := σ))))^[2] + (some ⟨some .row, ((ambient, flag), register), + memory original work target scratch count (encodeWord 0 ++ fuelSuffix)⟩) = + some ⟨none, ((ambient, flag), none), + memory original work target scratch count (encodeWord 0 ++ fuelSuffix)⟩ := by + rw [Function.iterate_succ_apply] + change advance (TM2.step (rankProgram (σ := σ))) + (TM2.step rankProgram ⟨some .row, ((ambient, flag), register), + memory original work target scratch count (encodeWord 0 ++ fuelSuffix)⟩) = _ + rw [rowGuard_zero] + rfl + +theorem rankRowTrace (r : Row) (hwidth : r.2.length = 4097) (v k : Nat) + (original suffix targetSuffix fuelSuffix count : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (rankProgram (σ := σ))))^[rowTime v r] + (some ⟨some .row, ((ambient, false), register), + memory original (encodeWords (rowWords r) ++ suffix) (encodeWord v ++ targetSuffix) + [] count (encodeWord (k + 1) ++ fuelSuffix)⟩) = + some ⟨some .row, ((ambient, false), none), + memory original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (if r.1 = v then 1 else 0) true ++ count) + (encodeWord k ++ fuelSuffix)⟩ := by + have hfield := preservingFieldTrace RankLabel.field RankLabel.restore (rankSkip 0) + rankProgram rfl rfl original (encodeWords r.2 ++ suffix) targetSuffix count + (encodeWord k ++ fuelSuffix) r.1 v ambient none + have hskip := discardFieldsTrace rankSkip (rankProgram (σ := σ)) r.2 0 + (by intro i hi; simpa only [Nat.zero_add] using rankProgram_skip (hwidth ▸ hi)) + original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (if r.1 = v then 1 else 0) true ++ count) + (encodeWord k ++ fuelSuffix) ambient false none + have hnonempty : r.2 ≠ [] := by intro h; simp [h] at hwidth + simp only [Nat.zero_add, hwidth, rankSkip, lt_self_iff_false, ↓reduceDIte, + hnonempty, ite_false] at hskip + have htime : rowTime v r = (encodeWords r.2).length + (r.1 + min r.1 v + 2) + 1 := by + simp only [rowTime, rowWords, encodeWords, List.length_append, encodeWord_length] + omega + rw [htime, Function.iterate_succ_apply] + change (advance (TM2.step (rankProgram (σ := σ))))^[ + (encodeWords r.2).length + (r.1 + min r.1 v + 2)] + (TM2.step rankProgram ⟨some .row, ((ambient, false), register), + memory original (encodeWords (rowWords r) ++ suffix) (encodeWord v ++ targetSuffix) + [] count (encodeWord (k + 1) ++ fuelSuffix)⟩) = _ + rw [rowGuard_succ, Function.iterate_add_apply] + simp only [rowWords, encodeWords, List.append_assoc] + rw [hfield] + exact hskip + +def prefixTime (v : Nat) : List Row → Nat + | [] => 2 + | r :: rs => prefixTime v rs + rowTime v r + +theorem prefixTrace (rs : List Row) (hwidth : ∀ r ∈ rs, r.2.length = 4097) (v : Nat) + (original suffix targetSuffix fuelSuffix count : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (rankProgram (σ := σ))))^[prefixTime v rs] + (some ⟨some .row, ((ambient, false), register), + memory original (encodeWords (rs.flatMap rowWords) ++ suffix) + (encodeWord v ++ targetSuffix) [] count (encodeWord rs.length ++ fuelSuffix)⟩) = + some ⟨none, ((ambient, false), none), + memory original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (rowsHits v rs) true ++ count) (encodeWord 0 ++ fuelSuffix)⟩ := by + induction rs generalizing count register with + | nil => + simpa only [prefixTime, List.flatMap_nil, encodeWords, List.nil_append, + List.length_nil, rowsHits, List.replicate_zero] using + zeroRowsTrace original suffix (encodeWord v ++ targetSuffix) [] count fuelSuffix + ambient false register + | cons r rs ih => + have hrow := rankRowTrace r (hwidth r (by simp)) v rs.length original + (encodeWords (rs.flatMap rowWords) ++ suffix) targetSuffix fuelSuffix count ambient register + have hrest := ih (by intro x hx; exact hwidth x (by simp [hx])) + (List.replicate (if r.1 = v then 1 else 0) true ++ count) none + simp only [prefixTime, List.flatMap_cons, encodeWords_append, List.append_assoc, + List.length_cons] + rw [Function.iterate_add_apply, hrow] + simpa only [rowsHits, ← List.append_assoc, List.replicate_append_replicate, + Nat.add_comm] using hrest + +theorem prefixTime_le (v : Nat) (rs : List Row) : + prefixTime v rs ≤ 3 * (encodeWords (rs.flatMap rowWords)).length + 2 := by + induction rs with + | nil => simp only [prefixTime, List.flatMap_nil, encodeWords, List.length_nil, + Nat.mul_zero, Nat.zero_add, le_refl] + | cons r rs ih => + have hr := rowTime_le v r + simp only [prefixTime, List.flatMap_cons, encodeWords_append, List.length_append] + omega + +def queryWord (v k : Nat) (suffix : List Bool) : List Bool := + encodeWord v ++ (encodeWord k ++ suffix) + +theorem encoded_rows_split (rs : List Row) (k : Nat) : + encodeWords (rs.flatMap rowWords) = + encodeWords ((rs.take k).flatMap rowWords) ++ + encodeWords ((rs.drop k).flatMap rowWords) := by + have h := congrArg (fun xs : List Row => encodeWords (xs.flatMap rowWords)) + (List.take_append_drop k rs) + simpa only [List.flatMap_append, encodeWords_append] using h.symm + +def rankSteps (n m v k : Nat) (rs : List Row) (querySuffix : List Bool) : Nat := + 2 * ((queryWord v k querySuffix).length + 1) + (v + 1) + + 2 * ((inputWord n m rs).length + 1) + (n + 1) + (m + 1) + + prefixTime v (rs.take k) + +theorem rankTrace (n m v k : Nat) (rs : List Row) (hk : k ≤ rs.length) + (hwidth : ∀ r ∈ rs, r.2.length = 4097) (querySuffix count : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (rankProgram (σ := σ))))^[rankSteps n m v k rs querySuffix] + (some ⟨some .queryFirst, ((ambient, false), register), + memory (inputWord n m rs) [] (queryWord v k querySuffix) [] count []⟩) = + some ⟨none, ((ambient, false), none), + memory (inputWord n m rs) (encodeWords ((rs.drop k).flatMap rowWords)) + (queryWord v k querySuffix) [] + (List.replicate (rowsHits v (rs.take k)) true ++ count) + (encodeWord 0 ++ querySuffix)⟩ := by + have hquery := MachineCopy.copyTrace Tape.target Tape.spare Tape.scratch + (by decide) (by decide) (by decide) false RankLabel.queryFirst RankLabel.querySecond + (some RankLabel.querySkip) rankProgram rfl rfl + (memory (inputWord n m rs) [] (queryWord v k querySuffix) [] count []) + rfl (ambient, false) register + simp only [memory_target, memory_spare, List.append_nil, update_memory_spare] at hquery + have hquerySkip := MachineLookup.discardTrace Tape.spare RankLabel.querySkip RankLabel.tableFirst + rankProgram rfl + (memory (inputWord n m rs) [] (queryWord v k querySuffix) [] count (queryWord v k querySuffix)) + v (encodeWord k ++ querySuffix) rfl (ambient, false) none + simp only [update_memory_spare] at hquerySkip + have hcopy := MachineCopy.copyTrace Tape.original Tape.work Tape.scratch + (by decide) (by decide) (by decide) false RankLabel.tableFirst RankLabel.tableSecond + (some RankLabel.headerFirst) rankProgram rfl rfl + (memory (inputWord n m rs) [] (queryWord v k querySuffix) [] count + (encodeWord k ++ querySuffix)) rfl (ambient, false) none + simp only [memory_original, memory_work, List.append_nil, update_memory_work] at hcopy + have hfirst := MachineLookup.discardTrace Tape.work RankLabel.headerFirst RankLabel.headerSecond + rankProgram rfl + (memory (inputWord n m rs) (inputWord n m rs) (queryWord v k querySuffix) [] count + (encodeWord k ++ querySuffix)) + n (encodeWord m ++ encodeWords (rs.flatMap rowWords)) + (inputWord_eq n m rs) (ambient, false) none + simp only [update_memory_work] at hfirst + have hsecond := MachineLookup.discardTrace Tape.work RankLabel.headerSecond RankLabel.row + rankProgram rfl + (memory (inputWord n m rs) (encodeWord m ++ encodeWords (rs.flatMap rowWords)) + (queryWord v k querySuffix) [] count (encodeWord k ++ querySuffix)) + m (encodeWords (rs.flatMap rowWords)) rfl (ambient, false) none + simp only [update_memory_work] at hsecond + have hprefix := prefixTrace (rs.take k) + (by intro r hr; exact hwidth r (List.mem_of_mem_take hr)) v + (inputWord n m rs) (encodeWords ((rs.drop k).flatMap rowWords)) + (encodeWord k ++ querySuffix) querySuffix count ambient none + have htake : (rs.take k).length = k := by + simp only [List.length_take, Nat.min_eq_left hk] + rw [htake, ← encoded_rows_split rs k] at hprefix + rw [show rankSteps n m v k rs querySuffix = prefixTime v (rs.take k) + + ((m + 1) + ((n + 1) + (2 * ((inputWord n m rs).length + 1) + + ((v + 1) + 2 * ((queryWord v k querySuffix).length + 1))))) by + unfold rankSteps; omega, + Function.iterate_add_apply _ (prefixTime v (rs.take k)), + Function.iterate_add_apply _ (m + 1), Function.iterate_add_apply _ (n + 1), + Function.iterate_add_apply _ (2 * ((inputWord n m rs).length + 1)), + Function.iterate_add_apply _ (v + 1), hquery, hquerySkip, hcopy, hfirst, hsecond] + exact hprefix + +theorem rankSteps_le (n m v k : Nat) (rs : List Row) (querySuffix : List Bool) : + rankSteps n m v k rs querySuffix ≤ + 5 * (inputWord n m rs).length + 3 * (queryWord v k querySuffix).length + 6 := by + have hprefix := prefixTime_le v (rs.take k) + have hsplit := congrArg List.length (encoded_rows_split rs k) + simp only [List.length_append] at hsplit + have hinput := inputWord_length n m rs + have hquery : v + 1 ≤ (queryWord v k querySuffix).length := by + simp only [queryWord, List.length_append, encodeWord_length] + omega + unfold rankSteps + omega + +theorem idxOf_filter_prefix {α : Type*} [BEq α] [LawfulBEq α] + (p : α → Bool) (a : α) (hp : p a = true) : + ∀ xs : List α, a ∈ xs → + (xs.filter p).idxOf a = ((xs.take (xs.idxOf a)).filter p).length := by + classical + intro xs + induction xs with + | nil => intro ha; simp at ha + | cons b xs ih => + intro ha + by_cases hba : b = a + · subst b + simp [hp] + · have ha' : a ∈ xs := by simpa [hba, Ne.symm hba] using ha + cases hb : p b <;> + simp [hba, hb, ih ha'] + +open IndependentSetsGames.Foundations.PCP + +theorem tableRows_length (t : GraphTables.Table) : (tableRows t).length = t.darts := by + simp only [tableRows, List.length_map, GraphTables.rowList_length] + +theorem cloudRank_eq_prefix_count (t : GraphTables.Table) (v : Fin t.vertices) + (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) : + (PreprocessingCloudIndex.cloudRank t v e).val = + rowsHits v.val ((tableRows t).take e.val.val) := by + have hindex := idxOf_filter_prefix (fun x : Fin t.darts => decide (t.rows[x].tail = v)) + e.val (by simpa using e.property) (List.finRange t.darts) (List.mem_finRange e.val) + simp only [List.idxOf_finRange] at hindex + change (PreprocessingCloudIndex.cloudDarts t v).idxOf e.val = _ + unfold PreprocessingCloudIndex.cloudDarts + rw [hindex, rowsHits_eq_filter] + simp only [tableRows, rowList_eq_finRange_map, ← List.map_take, List.filter_map, + List.length_map, Function.comp_def, Fin.val_inj] + +theorem cloudRankTrace (t : GraphTables.Table) (v : Fin t.vertices) + (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) + (querySuffix countSuffix : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (rankProgram (σ := σ))))^[ + rankSteps t.vertices t.darts v.val e.val.val (tableRows t) querySuffix] + (some ⟨some .queryFirst, ((ambient, false), register), + memory (GraphTables.tableBits t) [] (queryWord v.val e.val.val querySuffix) [] + (encodeWord 0 ++ countSuffix) []⟩) = + some ⟨none, ((ambient, false), none), + memory (GraphTables.tableBits t) + (encodeWords (((tableRows t).drop e.val.val).flatMap rowWords)) + (queryWord v.val e.val.val querySuffix) [] + (encodeWord (PreprocessingCloudIndex.cloudRank t v e).val ++ countSuffix) + (encodeWord 0 ++ querySuffix)⟩ := by + have hk : e.val.val ≤ (tableRows t).length := by + rw [tableRows_length] + exact e.val.isLt.le + have h := rankTrace t.vertices t.darts v.val e.val.val (tableRows t) hk + (tableRows_width t) querySuffix (encodeWord 0 ++ countSuffix) ambient register + rw [tableRows_input, ← cloudRank_eq_prefix_count t v e, ← List.append_assoc, + replicate_encodeWord, Nat.add_zero] at h + exact h + +def cloudRankInTime (t : GraphTables.Table) (v : Fin t.vertices) + (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) + (querySuffix countSuffix : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (rankProgram (σ := σ))) + ⟨some .queryFirst, ((ambient, false), register), + memory (GraphTables.tableBits t) [] (queryWord v.val e.val.val querySuffix) [] + (encodeWord 0 ++ countSuffix) []⟩ + (some ⟨none, ((ambient, false), none), + memory (GraphTables.tableBits t) + (encodeWords (((tableRows t).drop e.val.val).flatMap rowWords)) + (queryWord v.val e.val.val querySuffix) [] + (encodeWord (PreprocessingCloudIndex.cloudRank t v e).val ++ countSuffix) + (encodeWord 0 ++ querySuffix)⟩) + (5 * (GraphTables.tableBits t).length + + 3 * (queryWord v.val e.val.val querySuffix).length + 6) where + steps := rankSteps t.vertices t.darts v.val e.val.val (tableRows t) querySuffix + evals_in_steps := cloudRankTrace t v e querySuffix countSuffix ambient register + steps_le_m := by + simpa only [tableRows_input] using + rankSteps_le t.vertices t.darts v.val e.val.val (tableRows t) querySuffix + +end IndependentSetsGames.Foundations.Complexity.MachineCloudRank + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudSelect.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudSelect.lean new file mode 100644 index 0000000000000000000000000000000000000000..72eef828bb82999e6f52261a5b400f6934ebbe35 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCloudSelect.lean @@ -0,0 +1,624 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudRank + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCloudSelect + +open Turing MachineComposition +open MachineCloudCount (Row rowWords rowTime rowsHits tableRows) + +abbrev BaseTape := MachineCloudCount.Tape +abbrev BaseAlphabet := MachineCloudCount.Alphabet +abbrev BaseState (σ : Type) := MachineCloudCount.State σ + +inductive BaseLabel + | queryFirst | querySecond | querySkip | tableFirst | tableSecond + | headerFirst | headerSecond | field | restore | done | clearWork | clearRank + | skip (i : Fin 4097) + deriving DecidableEq, Fintype + +def skipLabel (i : Nat) : BaseLabel := + if h : i < 4097 then .skip ⟨i, h⟩ else .done + +variable {σ : Type} + +def baseProgram : BaseLabel → TM2.Stmt BaseAlphabet BaseLabel (BaseState σ) + | .queryFirst => Reduction.MachineTransfer.loopAt .target .scratch id false + .queryFirst (some .querySecond) + | .querySecond => MachineCopy.forkLoop .scratch .target .spare false + .querySecond (some .querySkip) + | .querySkip => MachineLookup.discard .spare .querySkip .tableFirst + | .tableFirst => Reduction.MachineTransfer.loopAt .original .scratch id false + .tableFirst (some .tableSecond) + | .tableSecond => MachineCopy.forkLoop .scratch .original .work false + .tableSecond (some .headerFirst) + | .headerFirst => MachineLookup.discard .work .headerFirst .headerSecond + | .headerSecond => MachineLookup.discard .work .headerSecond .field + | .field => MachineCloudCount.fieldLoop .field .restore + | .restore => Reduction.MachineTransfer.loopAt .scratch .target id false + .restore (some .done) + | .skip i => MachineLookup.discard .work (.skip i) (skipLabel (i.val + 1)) + | .clearWork => MachineDrain.drain .work .clearWork (some .clearRank) + | .clearRank => MachineDrain.drain .spare .clearRank (some .done) + | .done => .halt + +theorem baseProgram_skip {i : Nat} (hi : i < 4097) : + baseProgram (σ := σ) (skipLabel i) = + MachineLookup.discard .work (skipLabel i) (skipLabel (i + 1)) := by + simp only [skipLabel, dite_eq_left hi, baseProgram] + +inductive Phase | checking | advancing | finishing + deriving DecidableEq + +instance : Fintype Phase where + elems := {.checking, .advancing, .finishing} + complete phase := by cases phase <;> simp + +inductive Control | initialize | dispatch + deriving DecidableEq + +instance : Fintype Control where + elems := {.initialize, .dispatch} + complete control := by cases control <;> simp + +abbrev Tape := BaseTape ⊕ Unit +abbrev Alphabet : Tape → Type := MachineEmbedding.Alphabet BaseAlphabet (fun _ : Unit => Bool) +abbrev Label := BaseLabel ⊕ Control +abbrev State (σ : Type) := BaseState σ × Phase + +def go (phase : Phase) (label : Label) : TM2.Stmt Alphabet Label (State σ) := + .load (fun s => ((s.1.1, none), phase)) (.goto fun _ => label) + +def dispatcher : TM2.Stmt Alphabet Label (State σ) := + .branch (fun s => decide (s.2 = .checking)) + (.pop (.inl .count) (fun s bit => ((s.1.1, bit), s.2)) + (.branch (fun s => s.1.2.getD false) + (.pop (.inl .spare) (fun s bit => ((s.1.1, bit), s.2)) + (.branch (fun s => s.1.2.getD false) + (go .advancing (.inl (skipLabel 0))) + (go .finishing (.inl .clearWork)))) + (go .advancing (.inl (skipLabel 0))))) + (.branch (fun s => decide (s.2 = .advancing)) + (.push (.inr ()) (fun _ => true) (go .checking (.inl .field))) + (.load (fun s => ((s.1.1, none), Phase.checking)) .halt)) + +def extra : Control → TM2.Stmt Alphabet Label (State σ) + | .initialize => .push (.inr ()) (fun _ => false) (go .checking (.inl .queryFirst)) + | .dispatch => dispatcher + +def program : Label → TM2.Stmt Alphabet Label (State σ) := + MachineEmbedding.program (some (.inr .dispatch)) baseProgram extra + +def memory (original work target scratch hit rank position : List Bool) : + ∀ k, List (Alphabet k) := + MachineEmbedding.tapes (MachineCloudCount.memory original work target scratch hit rank) + (fun _ : Unit => position) + +@[simp] theorem memory_inl (a b c d e f g : List Bool) (k : BaseTape) : + memory a b c d e f g (.inl k) = MachineCloudCount.memory a b c d e f k := rfl +@[simp] theorem memory_position (a b c d e f g : List Bool) : + memory a b c d e f g (.inr ()) = g := rfl + +@[simp] theorem update_memory_hit (a b c d e f g x : List Bool) : + Function.update (memory a b c d e f g) (.inl .count) x = memory a b c d x f g := by + funext k + cases k with + | inl k => cases k <;> rfl + | inr k => cases k; rfl +@[simp] theorem update_memory_rank (a b c d e f g x : List Bool) : + Function.update (memory a b c d e f g) (.inl .spare) x = memory a b c d e x g := by + funext k + cases k with + | inl k => cases k <;> rfl + | inr k => cases k; rfl +@[simp] theorem update_memory_position (a b c d e f g x : List Bool) : + Function.update (memory a b c d e f g) (.inr ()) x = memory a b c d e f x := by + funext k + cases k with + | inl k => cases k <;> rfl + | inr k => cases k; rfl + +def cfg (label : Option Label) (phase : Phase) + (original work target hit rank position : List Bool) + (ambient : σ) (register : Option Bool) : TM2.Cfg Alphabet Label (State σ) := + ⟨label, (((ambient, false), register), phase), memory original work target [] hit rank position⟩ + +theorem liftTrace (phase : Phase) (position : List Bool) (n : Nat) + (a b : TM2.Cfg BaseAlphabet BaseLabel (BaseState σ)) + (h : (advance (TM2.step baseProgram))^[n] (some a) = some b) : + (advance (TM2.step (program (σ := σ))))^[n] + (some (MachineEmbedding.configuration (some (.inr .dispatch)) phase + (fun _ : Unit => position) a)) = + some (MachineEmbedding.configuration (some (.inr .dispatch)) phase + (fun _ : Unit => position) b) := + liftSuccessfulTrace (TM2.step baseProgram) (TM2.step program) + (MachineEmbedding.configuration (some (.inr .dispatch)) phase (fun _ : Unit => position)) + (MachineEmbedding.step_simulation (some (.inr .dispatch)) phase + (fun _ : Unit => position) baseProgram extra) n a b h + +theorem compareTrace (original suffix targetSuffix rank position : List Bool) + (x v : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[x + min x v + 3] + (some (cfg (some (.inl .field)) .checking original (encodeWord x ++ suffix) + (encodeWord v ++ targetSuffix) [] rank position ambient register)) = + some (cfg (some (.inr .dispatch)) .checking original suffix + (encodeWord v ++ targetSuffix) (List.replicate (if x = v then 1 else 0) true) + rank position ambient none) := by + have h := MachineCloudCount.preservingFieldTrace BaseLabel.field BaseLabel.restore BaseLabel.done + baseProgram rfl rfl original suffix targetSuffix [] rank x v ambient register + simp only [List.append_nil] at h + have hhalt : (advance (TM2.step baseProgram))^[x + min x v + 3] + (some ⟨some .field, ((ambient, false), register), + MachineCloudCount.memory original (encodeWord x ++ suffix) + (encodeWord v ++ targetSuffix) [] [] rank⟩) = + some ⟨none, ((ambient, false), none), + MachineCloudCount.memory original suffix (encodeWord v ++ targetSuffix) [] + (List.replicate (if x = v then 1 else 0) true) rank⟩ := by + rw [show x + min x v + 3 = (x + min x v + 2) + 1 by omega, + Function.iterate_succ_apply', h, advance_some] + rfl + convert liftTrace Phase.checking position _ _ _ hhalt using 1 <;> rfl + +theorem dispatch_miss (original work target rank position : List Bool) (ambient : σ) : + TM2.step program (cfg (some (.inr .dispatch)) .checking + original work target [] rank position ambient none) = + some (cfg (some (.inl (skipLabel 0))) .advancing + original work target [] rank position ambient none) := by + simp [program, MachineEmbedding.program, extra, dispatcher, go, TM2.stepAux, TM2.step, cfg] + +theorem dispatch_hit_succ (original work target rankSuffix position : List Bool) + (rank : Nat) (ambient : σ) : + TM2.step program (cfg (some (.inr .dispatch)) .checking + original work target [true] (encodeWord (rank + 1) ++ rankSuffix) position ambient none) = + some (cfg (some (.inl (skipLabel 0))) .advancing original work target [] + (encodeWord rank ++ rankSuffix) position ambient none) := by + simp [program, MachineEmbedding.program, extra, dispatcher, go, TM2.stepAux, TM2.step, + cfg, encodeWord, List.replicate_succ] + +theorem dispatch_hit_zero (original work target rankSuffix position : List Bool) (ambient : σ) : + TM2.step program (cfg (some (.inr .dispatch)) .checking + original work target [true] (encodeWord 0 ++ rankSuffix) position ambient none) = + some (cfg (some (.inl .clearWork)) .finishing + original work target [] rankSuffix position ambient none) := by + simp [program, MachineEmbedding.program, extra, dispatcher, go, TM2.stepAux, TM2.step, + cfg, encodeWord] + +theorem advanceStep (original work target rank positionSuffix : List Bool) + (position : Nat) (ambient : σ) : + TM2.step program (cfg (some (.inr .dispatch)) .advancing original work target [] + rank (encodeWord position ++ positionSuffix) ambient none) = + some (cfg (some (.inl .field)) .checking original work target [] + rank (encodeWord (position + 1) ++ positionSuffix) ambient none) := by + simp [program, MachineEmbedding.program, extra, dispatcher, go, TM2.stepAux, TM2.step, + cfg, encodeWord, List.replicate_succ] + +theorem finishStep (original target position : List Bool) (ambient : σ) : + TM2.step program (cfg (some (.inr .dispatch)) .finishing + original [] target [] [] position ambient none) = + some (cfg none .checking original [] target [] [] position ambient none) := by + simp [program, MachineEmbedding.program, extra, dispatcher, go, TM2.stepAux, TM2.step, cfg] + +theorem initializeStep (original target output : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step program (cfg (some (.inr .initialize)) .checking + original [] target [] [] output ambient register) = + some (cfg (some (.inl .queryFirst)) .checking + original [] target [] [] (encodeWord 0 ++ output) ambient none) := by + simp [program, MachineEmbedding.program, extra, go, TM2.stepAux, TM2.step, cfg, encodeWord] + +theorem skipTrace (fields : List Nat) (hwidth : fields.length = 4097) + (original suffix target rank position : List Bool) (ambient : σ) : + (advance (TM2.step program))^[(encodeWords fields).length + 1] + (some (cfg (some (.inl (skipLabel 0))) .advancing original + (encodeWords fields ++ suffix) target [] rank position ambient none)) = + some (cfg (some (.inr .dispatch)) .advancing + original suffix target [] rank position ambient none) := by + have h := MachineCloudCount.discardFieldsTrace skipLabel (baseProgram (σ := σ)) fields 0 + (by intro i hi; simpa only [Nat.zero_add] using baseProgram_skip (hwidth ▸ hi)) + original suffix target [] [] rank ambient false none + have hnonempty : fields ≠ [] := by intro h; simp [h] at hwidth + simp only [Nat.zero_add, hwidth, skipLabel, lt_self_iff_false, ↓reduceDIte, + hnonempty, ite_false] at h + have raw : (advance (TM2.step baseProgram))^[(encodeWords fields).length + 1] + (some ⟨some (skipLabel 0), ((ambient, false), none), + MachineCloudCount.memory original (encodeWords fields ++ suffix) target [] [] rank⟩) = + some ⟨none, ((ambient, false), none), + MachineCloudCount.memory original suffix target [] [] rank⟩ := by + rw [Function.iterate_succ_apply'] + simp only [skipLabel, dite_eq_left (by decide : 0 < 4097)] at h ⊢ + rw [h, advance_some] + rfl + convert liftTrace Phase.advancing position _ _ _ raw using 1 <;> rfl + +theorem rowSkipTrace (r : Row) (hwidth : r.2.length = 4097) (v rank position : Nat) + (original suffix targetSuffix rankSuffix outputSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[rowTime v r + 3] + (some (cfg (some (.inl .field)) .checking original + (encodeWords (rowWords r) ++ suffix) (encodeWord v ++ targetSuffix) [] + (encodeWord (rank + if r.1 = v then 1 else 0) ++ rankSuffix) + (encodeWord position ++ outputSuffix) ambient register)) = + some (cfg (some (.inl .field)) .checking original suffix + (encodeWord v ++ targetSuffix) [] (encodeWord rank ++ rankSuffix) + (encodeWord (position + 1) ++ outputSuffix) ambient none) := by + have hcompare := compareTrace original (encodeWords r.2 ++ suffix) targetSuffix + (encodeWord (rank + if r.1 = v then 1 else 0) ++ rankSuffix) + (encodeWord position ++ outputSuffix) r.1 v ambient register + have hdispatch : TM2.step program + (cfg (some (.inr .dispatch)) .checking original (encodeWords r.2 ++ suffix) + (encodeWord v ++ targetSuffix) (List.replicate (if r.1 = v then 1 else 0) true) + (encodeWord (rank + if r.1 = v then 1 else 0) ++ rankSuffix) + (encodeWord position ++ outputSuffix) ambient none) = + some (cfg (some (.inl (skipLabel 0))) .advancing original (encodeWords r.2 ++ suffix) + (encodeWord v ++ targetSuffix) [] (encodeWord rank ++ rankSuffix) + (encodeWord position ++ outputSuffix) ambient none) := by + by_cases hit : r.1 = v + · simpa only [ite_eq_left hit, List.replicate_succ, List.replicate_zero] using + dispatch_hit_succ original (encodeWords r.2 ++ suffix) (encodeWord v ++ targetSuffix) + rankSuffix (encodeWord position ++ outputSuffix) rank ambient + · simpa only [ite_eq_right hit, Nat.add_zero, List.replicate_zero] using + dispatch_miss original (encodeWords r.2 ++ suffix) (encodeWord v ++ targetSuffix) + (encodeWord rank ++ rankSuffix) (encodeWord position ++ outputSuffix) ambient + have hskip := skipTrace r.2 hwidth original suffix (encodeWord v ++ targetSuffix) + (encodeWord rank ++ rankSuffix) (encodeWord position ++ outputSuffix) ambient + have ht : rowTime v r + 3 = + 1 + (((encodeWords r.2).length + 1) + (1 + (r.1 + min r.1 v + 3))) := by + simp only [rowTime, rowWords, encodeWords, List.length_append, encodeWord_length] + omega + rw [ht, Function.iterate_add_apply _ 1, + Function.iterate_add_apply _ ((encodeWords r.2).length + 1), + Function.iterate_add_apply _ 1] + simp only [rowWords, encodeWords, List.append_assoc] + rw [hcompare, Function.iterate_one, advance_some, hdispatch, hskip, + advance_some] + exact advanceStep original suffix (encodeWord v ++ targetSuffix) + (encodeWord rank ++ rankSuffix) outputSuffix position ambient + +def prefixTime (v : Nat) : List Row → Nat + | [] => 0 + | r :: rs => prefixTime v rs + (rowTime v r + 3) + +theorem prefixTrace (rs : List Row) (hwidth : ∀ r ∈ rs, r.2.length = 4097) + (v rank position : Nat) (original suffix targetSuffix rankSuffix outputSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[prefixTime v rs] + (some (cfg (some (.inl .field)) .checking original + (encodeWords (rs.flatMap rowWords) ++ suffix) (encodeWord v ++ targetSuffix) [] + (encodeWord (rowsHits v rs + rank) ++ rankSuffix) + (encodeWord position ++ outputSuffix) ambient register)) = + some (cfg (some (.inl .field)) .checking original suffix + (encodeWord v ++ targetSuffix) [] (encodeWord rank ++ rankSuffix) + (encodeWord (position + rs.length) ++ outputSuffix) ambient + (if rs = [] then register else none)) := by + induction rs generalizing position register with + | nil => simp [prefixTime, rowsHits, encodeWords] + | cons r rs ih => + have hrow := rowSkipTrace r (hwidth r (by simp)) v (rowsHits v rs + rank) position + original (encodeWords (rs.flatMap rowWords) ++ suffix) targetSuffix rankSuffix + outputSuffix ambient register + have hrest := ih (by intro x hx; exact hwidth x (by simp [hx])) (position + 1) none + simp only [prefixTime, List.flatMap_cons, encodeWords_append, List.append_assoc] + rw [Function.iterate_add_apply] + have hi : (if r.1 = v then 1 else 0) + rowsHits v rs + rank = + (rowsHits v rs + rank) + (if r.1 = v then 1 else 0) := by omega + simp only [rowsHits, hi] + rw [hrow] + simpa only [ite_self, List.cons_ne_nil, ite_false, List.length_cons, + Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hrest + +theorem cleanupTrace (original work target rank position : List Bool) (ambient : σ) : + (advance (TM2.step program))^[work.length + rank.length + 4] + (some (cfg (some (.inl .clearWork)) .finishing + original work target [] rank position ambient none)) = + some (cfg none .checking original [] target [] [] position ambient none) := by + have hwork := MachineDrain.drainTrace MachineCloudCount.Tape.work BaseLabel.clearWork (some BaseLabel.clearRank) + baseProgram rfl (MachineCloudCount.memory original work target [] [] rank) work + (ambient, false) none + simp only [MachineCloudCount.update_memory_work] at hwork + have hrank := MachineDrain.drainTrace MachineCloudCount.Tape.spare BaseLabel.clearRank (some BaseLabel.done) + baseProgram rfl (MachineCloudCount.memory original [] target [] [] rank) rank + (ambient, false) none + simp only [MachineCloudRank.update_memory_spare] at hrank + have raw : (advance (TM2.step baseProgram))^[work.length + rank.length + 3] + (some ⟨some .clearWork, ((ambient, false), none), + MachineCloudCount.memory original work target [] [] rank⟩) = + some ⟨none, ((ambient, false), none), + MachineCloudCount.memory original [] target [] [] []⟩ := by + rw [show work.length + rank.length + 3 = + 1 + ((rank.length + 1) + (work.length + 1)) by omega, + Function.iterate_add_apply _ 1, Function.iterate_add_apply _ (rank.length + 1), + hwork, hrank, Function.iterate_one, advance_some] + rfl + have lifted := liftTrace Phase.finishing position _ _ _ raw + have h : (advance (TM2.step program))^[work.length + rank.length + 3] + (some (cfg (some (.inl .clearWork)) .finishing + original work target [] rank position ambient none)) = + some (cfg (some (.inr .dispatch)) .finishing + original [] target [] [] position ambient none) := by + convert lifted using 1 <;> rfl + rw [show work.length + rank.length + 4 = (work.length + rank.length + 3) + 1 by omega, + Function.iterate_succ_apply', h, advance_some] + exact finishStep original target position ambient + +theorem selectedTrace (v : Nat) (original work targetSuffix rankSuffix position : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[2 * v + work.length + rankSuffix.length + 8] + (some (cfg (some (.inl .field)) .checking original (encodeWord v ++ work) + (encodeWord v ++ targetSuffix) [] (encodeWord 0 ++ rankSuffix) position ambient register)) = + some (cfg none .checking original [] (encodeWord v ++ targetSuffix) [] [] position ambient none) := by + have hcompare := compareTrace original work targetSuffix (encodeWord 0 ++ rankSuffix) + position v v ambient register + simp only [ite_true, List.replicate_succ, List.replicate_zero] at hcompare + rw [show 2 * v + work.length + rankSuffix.length + 8 = + (work.length + rankSuffix.length + 4) + (1 + (v + min v v + 3)) by + simp only [Nat.min_self]; omega, + Function.iterate_add_apply _ (work.length + rankSuffix.length + 4), + Function.iterate_add_apply _ 1, hcompare, Function.iterate_one, advance_some, + dispatch_hit_zero] + exact cleanupTrace original work (encodeWord v ++ targetSuffix) rankSuffix position ambient + +abbrev queryWord := MachineCloudRank.queryWord + +def prepareSteps (n m v rank : Nat) (rs : List Row) (querySuffix : List Bool) : Nat := + 2 * ((queryWord v rank querySuffix).length + 1) + (v + 1) + + 2 * ((MachineCloudCount.inputWord n m rs).length + 1) + (n + 1) + (m + 1) + +theorem prepareTrace (n m v rank : Nat) (rs : List Row) + (querySuffix position : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[prepareSteps n m v rank rs querySuffix] + (some (cfg (some (.inl .queryFirst)) .checking (MachineCloudCount.inputWord n m rs) + [] (queryWord v rank querySuffix) [] [] position ambient register)) = + some (cfg (some (.inl .field)) .checking (MachineCloudCount.inputWord n m rs) + (encodeWords (rs.flatMap rowWords)) (queryWord v rank querySuffix) [] + (encodeWord rank ++ querySuffix) position ambient none) := by + have hquery := MachineCopy.copyTrace MachineCloudCount.Tape.target MachineCloudCount.Tape.spare MachineCloudCount.Tape.scratch + (by decide) (by decide) (by decide) false BaseLabel.queryFirst BaseLabel.querySecond + (some BaseLabel.querySkip) baseProgram rfl rfl + (MachineCloudCount.memory (MachineCloudCount.inputWord n m rs) [] + (queryWord v rank querySuffix) [] [] []) rfl (ambient, false) register + simp only [MachineCloudCount.memory_target, MachineCloudCount.memory_spare, + List.append_nil, MachineCloudRank.update_memory_spare] at hquery + have hquerySkip := MachineLookup.discardTrace MachineCloudCount.Tape.spare BaseLabel.querySkip BaseLabel.tableFirst + baseProgram rfl (MachineCloudCount.memory (MachineCloudCount.inputWord n m rs) [] + (queryWord v rank querySuffix) [] [] (queryWord v rank querySuffix)) + v (encodeWord rank ++ querySuffix) rfl (ambient, false) none + simp only [MachineCloudRank.update_memory_spare] at hquerySkip + have hcopy := MachineCopy.copyTrace MachineCloudCount.Tape.original MachineCloudCount.Tape.work MachineCloudCount.Tape.scratch + (by decide) (by decide) (by decide) false BaseLabel.tableFirst BaseLabel.tableSecond + (some BaseLabel.headerFirst) baseProgram rfl rfl + (MachineCloudCount.memory (MachineCloudCount.inputWord n m rs) [] + (queryWord v rank querySuffix) [] [] (encodeWord rank ++ querySuffix)) + rfl (ambient, false) none + simp only [MachineCloudCount.memory_original, MachineCloudCount.memory_work, + List.append_nil, MachineCloudCount.update_memory_work] at hcopy + have hfirst := MachineLookup.discardTrace MachineCloudCount.Tape.work BaseLabel.headerFirst BaseLabel.headerSecond + baseProgram rfl (MachineCloudCount.memory (MachineCloudCount.inputWord n m rs) + (MachineCloudCount.inputWord n m rs) (queryWord v rank querySuffix) [] [] + (encodeWord rank ++ querySuffix)) + n (encodeWord m ++ encodeWords (rs.flatMap rowWords)) + (MachineCloudCount.inputWord_eq n m rs) (ambient, false) none + simp only [MachineCloudCount.update_memory_work] at hfirst + have hsecond := MachineLookup.discardTrace MachineCloudCount.Tape.work BaseLabel.headerSecond BaseLabel.field + baseProgram rfl (MachineCloudCount.memory (MachineCloudCount.inputWord n m rs) + (encodeWord m ++ encodeWords (rs.flatMap rowWords)) (queryWord v rank querySuffix) + [] [] (encodeWord rank ++ querySuffix)) + m (encodeWords (rs.flatMap rowWords)) rfl (ambient, false) none + simp only [MachineCloudCount.update_memory_work] at hsecond + have raw : (advance (TM2.step baseProgram))^[prepareSteps n m v rank rs querySuffix] + (some ⟨some .queryFirst, ((ambient, false), register), + MachineCloudCount.memory (MachineCloudCount.inputWord n m rs) [] + (queryWord v rank querySuffix) [] [] []⟩) = + some ⟨some .field, ((ambient, false), none), + MachineCloudCount.memory (MachineCloudCount.inputWord n m rs) + (encodeWords (rs.flatMap rowWords)) (queryWord v rank querySuffix) [] [] + (encodeWord rank ++ querySuffix)⟩ := by + rw [show prepareSteps n m v rank rs querySuffix = + (m + 1) + ((n + 1) + (2 * ((MachineCloudCount.inputWord n m rs).length + 1) + + ((v + 1) + 2 * ((queryWord v rank querySuffix).length + 1)))) by + unfold prepareSteps; omega, + Function.iterate_add_apply _ (m + 1), Function.iterate_add_apply _ (n + 1), + Function.iterate_add_apply _ (2 * ((MachineCloudCount.inputWord n m rs).length + 1)), + Function.iterate_add_apply _ (v + 1), hquery, hquerySkip, hcopy, hfirst] + exact hsecond + convert liftTrace Phase.checking position _ _ _ raw using 1 <;> rfl + +theorem prefixSelectedTrace (preceding : List Row) + (hwidth : ∀ r ∈ preceding, r.2.length = 4097) (v position : Nat) + (original work targetSuffix rankSuffix outputSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[prefixTime v preceding + 2 * v + work.length + rankSuffix.length + 8] + (some (cfg (some (.inl .field)) .checking original + (encodeWords (preceding.flatMap rowWords) ++ (encodeWord v ++ work)) + (encodeWord v ++ targetSuffix) [] (encodeWord (rowsHits v preceding) ++ rankSuffix) + (encodeWord position ++ outputSuffix) ambient register)) = + some (cfg none .checking original [] (encodeWord v ++ targetSuffix) [] [] + (encodeWord (position + preceding.length) ++ outputSuffix) ambient none) := by + have hp := prefixTrace preceding hwidth v 0 position original (encodeWord v ++ work) + targetSuffix rankSuffix outputSuffix ambient register + simp only [Nat.add_zero] at hp + have hs := selectedTrace v original work targetSuffix rankSuffix + (encodeWord (position + preceding.length) ++ outputSuffix) ambient + (if preceding = [] then register else none) + rw [show prefixTime v preceding + 2 * v + work.length + rankSuffix.length + 8 = + (2 * v + work.length + rankSuffix.length + 8) + prefixTime v preceding by omega, + Function.iterate_add_apply, hp] + exact hs + +def totalSteps (n m v rank : Nat) (rs preceding : List Row) + (work querySuffix : List Bool) : Nat := + prepareSteps n m v rank rs querySuffix + prefixTime v preceding + + 2 * v + work.length + querySuffix.length + 9 + +theorem fullTrace (n m v rank : Nat) (rs preceding : List Row) (work : List Bool) + (hwidth : ∀ r ∈ preceding, r.2.length = 4097) + (hword : encodeWords (rs.flatMap rowWords) = + encodeWords (preceding.flatMap rowWords) ++ (encodeWord v ++ work)) + (hrank : rank = rowsHits v preceding) (querySuffix outputSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[totalSteps n m v rank rs preceding work querySuffix] + (some (cfg (some (.inr .initialize)) .checking (MachineCloudCount.inputWord n m rs) + [] (queryWord v rank querySuffix) [] [] outputSuffix ambient register)) = + some (cfg none .checking (MachineCloudCount.inputWord n m rs) [] + (queryWord v rank querySuffix) [] [] (encodeWord preceding.length ++ outputSuffix) ambient none) := by + have hp := prepareTrace n m v rank rs querySuffix (encodeWord 0 ++ outputSuffix) ambient none + have hs := prefixSelectedTrace preceding hwidth v 0 (MachineCloudCount.inputWord n m rs) work + (encodeWord rank ++ querySuffix) querySuffix outputSuffix ambient none + simp only [Nat.zero_add] at hs + rw [← hrank, ← hword] at hs + rw [show totalSteps n m v rank rs preceding work querySuffix = + (prefixTime v preceding + 2 * v + work.length + querySuffix.length + 8) + + (prepareSteps n m v rank rs querySuffix + 1) by unfold totalSteps; omega, + Function.iterate_add_apply _ (prefixTime v preceding + 2 * v + work.length + querySuffix.length + 8), + Function.iterate_succ_apply _ (prepareSteps n m v rank rs querySuffix), + advance_some, initializeStep, hp] + exact hs + +theorem prefixTime_le (v : Nat) (rs : List Row) : + prefixTime v rs ≤ 6 * (encodeWords (rs.flatMap rowWords)).length := by + induction rs with + | nil => simp [prefixTime, encodeWords] + | cons r rs ih => + have hr := MachineCloudCount.rowTime_le v r + have hpos : 1 ≤ (encodeWords (rowWords r)).length := by + simp only [rowWords, encodeWords, List.length_append, encodeWord_length] + omega + simp only [prefixTime, List.flatMap_cons, encodeWords_append, List.length_append] + omega + +theorem totalSteps_le (n m v rank : Nat) (rs preceding : List Row) (work querySuffix : List Bool) + (hword : encodeWords (rs.flatMap rowWords) = + encodeWords (preceding.flatMap rowWords) ++ (encodeWord v ++ work)) : + totalSteps n m v rank rs preceding work querySuffix ≤ + 10 * ((MachineCloudCount.inputWord n m rs).length + (queryWord v rank querySuffix).length) + 20 := by + have hp := prefixTime_le v preceding + have hw := congrArg List.length hword + simp only [List.length_append, encodeWord_length] at hw + have ht := MachineCloudCount.inputWord_length n m rs + have hq : (queryWord v rank querySuffix).length = + v + 1 + (rank + 1) + querySuffix.length := by + simp only [queryWord, MachineCloudRank.queryWord, List.length_append, encodeWord_length] + omega + unfold totalSteps prepareSteps + omega + +open IndependentSetsGames.Foundations.PCP + +def remainder (t : GraphTables.Table) (e : Fin t.darts) : List Bool := + encodeWords (t.rows[e].reverseIndex.val :: GraphTables.relationWords t.rows[e].relation) ++ + encodeWords (((tableRows t).drop (e.val + 1)).flatMap rowWords) + +theorem tableRows_getElem (t : GraphTables.Table) (e : Fin t.darts) : + (tableRows t)[e.val]'(by rw [MachineCloudRank.tableRows_length]; exact e.isLt) = + (t.rows[e].tail.val, t.rows[e].reverseIndex.val :: GraphTables.relationWords t.rows[e].relation) := by + simp only [MachineCloudCount.tableRows, MachineCloudCount.rowList_eq_finRange_map, + List.getElem_map, List.getElem_finRange] + apply congrArg (fun j : Fin t.darts => + (t.rows[j].tail.val, t.rows[j].reverseIndex.val :: GraphTables.relationWords t.rows[j].relation)) + apply Fin.ext + rfl + +theorem tableWord_split (t : GraphTables.Table) (v : Fin t.vertices) (e : Fin t.darts) + (owner : t.rows[e].tail = v) : + encodeWords ((tableRows t).flatMap rowWords) = + encodeWords (((tableRows t).take e.val).flatMap rowWords) ++ + (encodeWord v.val ++ remainder t e) := by + have he : e.val < (tableRows t).length := by + rw [MachineCloudRank.tableRows_length] + exact e.isLt + rw [MachineCloudRank.encoded_rows_split (tableRows t) e.val, List.drop_eq_getElem_cons he] + simp only [List.flatMap_cons, encodeWords_append] + rw [tableRows_getElem] + simp only [rowWords, encodeWords, owner, remainder, List.append_assoc] + +def cloudSelectSteps (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) (querySuffix : List Bool) : Nat := + let e := (PreprocessingCloudIndex.cloudSelect t v i).val + totalSteps t.vertices t.darts v.val i.val (tableRows t) ((tableRows t).take e.val) + (remainder t e) querySuffix + +theorem cloudSelectTrace (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) (querySuffix outputSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[cloudSelectSteps t v i querySuffix] + (some (cfg (some (.inr .initialize)) .checking (GraphTables.tableBits t) + [] (queryWord v.val i.val querySuffix) [] [] outputSuffix ambient register)) = + some (cfg none .checking (GraphTables.tableBits t) [] (queryWord v.val i.val querySuffix) + [] [] (encodeWord (PreprocessingCloudIndex.cloudSelect t v i).val.val ++ outputSuffix) + ambient none) := by + let e := PreprocessingCloudIndex.cloudSelect t v i + have hword := tableWord_split t v e.val e.property + have hrank : i.val = rowsHits v.val ((tableRows t).take e.val.val) := by + simpa only [PreprocessingCloudIndex.cloudRank_cloudSelect] using + MachineCloudRank.cloudRank_eq_prefix_count t v (PreprocessingCloudIndex.cloudSelect t v i) + have h := fullTrace t.vertices t.darts v.val i.val (tableRows t) + ((tableRows t).take e.val.val) (remainder t e.val) + (by intro r hr; exact MachineCloudCount.tableRows_width t r (List.mem_of_mem_take hr)) + hword hrank querySuffix outputSuffix ambient register + have htake : ((tableRows t).take e.val.val).length = e.val.val := by + rw [List.length_take, MachineCloudRank.tableRows_length, + Nat.min_eq_left e.val.isLt.le] + rw [MachineCloudCount.tableRows_input, htake] at h + exact h + +theorem cloudSelectSteps_le (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) (querySuffix : List Bool) : + cloudSelectSteps t v i querySuffix ≤ + 10 * ((GraphTables.tableBits t).length + (queryWord v.val i.val querySuffix).length) + 20 := by + let e := PreprocessingCloudIndex.cloudSelect t v i + have h := totalSteps_le t.vertices t.darts v.val i.val (tableRows t) + ((tableRows t).take e.val.val) (remainder t e.val) querySuffix + (tableWord_split t v e.val e.property) + simpa only [cloudSelectSteps, e, MachineCloudCount.tableRows_input] using h + +noncomputable def timePolynomial : Polynomial Nat := + Polynomial.C 10 * Polynomial.X + Polynomial.C 20 + +def cloudSelectInTime (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) (querySuffix outputSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + (cfg (some (.inr .initialize)) .checking (GraphTables.tableBits t) + [] (queryWord v.val i.val querySuffix) [] [] outputSuffix ambient register) + (some (cfg none .checking (GraphTables.tableBits t) [] (queryWord v.val i.val querySuffix) + [] [] (encodeWord (PreprocessingCloudIndex.cloudSelect t v i).val.val ++ outputSuffix) + ambient none)) + (timePolynomial.eval ((GraphTables.tableBits t).length + (queryWord v.val i.val querySuffix).length)) where + steps := cloudSelectSteps t v i querySuffix + evals_in_steps := cloudSelectTrace t v i querySuffix outputSuffix ambient register + steps_le_m := by + simpa only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X] using cloudSelectSteps_le t v i querySuffix + +def machine : FinTM2 where + K := Tape + k₀ := .inl .original + k₁ := .inr () + Γ := Alphabet + Λ := Label + main := .inr .initialize + σ := State Unit + initialState := ((((), false), none), .checking) + m := program + +def machineInTime (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) (querySuffix outputSuffix : List Bool) + (register : Option Bool) : + StateTransition.EvalsToInTime machine.step + (cfg (some (.inr .initialize)) .checking (GraphTables.tableBits t) + [] (queryWord v.val i.val querySuffix) [] [] outputSuffix () register) + (some (cfg none .checking (GraphTables.tableBits t) [] (queryWord v.val i.val querySuffix) + [] [] (encodeWord (PreprocessingCloudIndex.cloudSelect t v i).val.val ++ outputSuffix) + () none)) + (timePolynomial.eval ((GraphTables.tableBits t).length + (queryWord v.val i.val querySuffix).length)) where + steps := cloudSelectSteps t v i querySuffix + evals_in_steps := by + convert cloudSelectTrace t v i querySuffix outputSuffix () register using 1 + rfl + steps_le_m := by + simpa only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X] using cloudSelectSteps_le t v i querySuffix + +end IndependentSetsGames.Foundations.Complexity.MachineCloudSelect + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCompare.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCompare.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e5dd93ef88141fe5c738e7ad52a6b024ee7716b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCompare.lean @@ -0,0 +1,268 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.MachineTransfer +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCompare + +open Turing +open IndependentSetsGames.Reduction.MachineTransfer + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (K : Type) : K → Type := fun _ => Bool +abbrev State (σ : Type) := σ × Bool × Option Bool × Option Bool + +def exitAt (exit : Option Λ) : TM2.Stmt (Alphabet K) Λ (State σ) := + match exit with + | none => .halt + | some label => .goto fun _ => label + +def finish (exit : Option Λ) : TM2.Stmt (Alphabet K) Λ (State σ) := + .load (fun state => (state.1, false, none, none)) (exitAt exit) + +def loop (left right : K) (loopLabel : Λ) (equalExit differentExit : Option Λ) : + TM2.Stmt (Alphabet K) Λ (State σ) := + .pop left (fun state head => (state.1, state.2.1, head, state.2.2.2)) + (.pop right (fun state head => (state.1, state.2.1, state.2.2.1, head)) + (.branch (fun state => state.2.2.1.isNone && state.2.2.2.isNone) + (.branch (fun state => state.2.1) (finish differentExit) (finish equalExit)) + (.load (fun state => + (state.1, state.2.1 || decide (state.2.2.1 ≠ state.2.2.2), none, none)) + (.goto fun _ => loopLabel)))) + +def mismatch (flag : Bool) (leftWord rightWord : List Bool) : Bool := + flag || decide (leftWord ≠ rightWord) + +@[simp] theorem mismatch_nil_nil (flag : Bool) : mismatch flag [] [] = flag := by + simp [mismatch] + +@[simp] theorem mismatch_nil_cons (flag head : Bool) (tail : List Bool) : + mismatch flag [] (head :: tail) = true := by simp [mismatch] + +@[simp] theorem mismatch_cons_nil (flag head : Bool) (tail : List Bool) : + mismatch flag (head :: tail) [] = true := by simp [mismatch] + +@[simp] theorem mismatch_true (leftWord rightWord : List Bool) : + mismatch true leftWord rightWord = true := by simp [mismatch] + +theorem mismatch_cons (flag leftHead rightHead : Bool) (leftTail rightTail : List Bool) : + mismatch (flag || decide (leftHead ≠ rightHead)) leftTail rightTail = + mismatch flag (leftHead :: leftTail) (rightHead :: rightTail) := by + cases flag <;> cases leftHead <;> cases rightHead <;> simp [mismatch] + +@[simp] theorem stepAux_exitAt (exit : Option Λ) (state : State σ) + (tapes : K → List Bool) : + TM2.stepAux (exitAt exit) state tapes = ⟨exit, state, tapes⟩ := by + cases exit <;> rfl + +@[simp] theorem stepAux_finish (exit : Option Λ) (state : State σ) + (tapes : K → List Bool) : + TM2.stepAux (finish exit) state tapes = + ⟨exit, (state.1, false, none, none), tapes⟩ := by + simp [finish, TM2.stepAux] + +private theorem update_left (left right : K) (distinct : left ≠ right) + (base : K → List Bool) (leftWord rightWord replacement : List Bool) : + Function.update (tapesAt left right base leftWord rightWord) left replacement = + tapesAt left right base replacement rightWord := by + funext k + by_cases hl : k = left + · subst k + simp [tapesAt, distinct] + · by_cases hr : k = right + · subst k + simp [tapesAt, Ne.symm distinct] + · simp [tapesAt, hl, hr] + +private theorem update_right (left right : K) (base : K → List Bool) + (leftWord rightWord replacement : List Bool) : + Function.update (tapesAt left right base leftWord rightWord) right replacement = + tapesAt left right base leftWord replacement := by + simp [tapesAt] + +theorem step_empty (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (ambient : σ) (flag : Bool) + (leftRegister rightRegister : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base [] []⟩ = + some ⟨if flag then differentExit else equalExit, (ambient, false, none, none), + tapesAt left right base [] []⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, flag, leftRegister, rightRegister) + (tapesAt left right base [] [])) = _ + rw [atLoop] + cases flag <;> + simp [loop, TM2.stepAux, distinct, update_left, update_right] + +theorem step_nil_cons (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (head : Bool) (tail : List Bool) (ambient : σ) (flag : Bool) + (leftRegister rightRegister : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base [] (head :: tail)⟩ = + some ⟨some loopLabel, (ambient, true, none, none), tapesAt left right base [] tail⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, flag, leftRegister, rightRegister) + (tapesAt left right base [] (head :: tail))) = _ + rw [atLoop] + simp [loop, TM2.stepAux, distinct, update_left, update_right] + +theorem step_cons_nil (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (head : Bool) (tail : List Bool) (ambient : σ) (flag : Bool) + (leftRegister rightRegister : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base (head :: tail) []⟩ = + some ⟨some loopLabel, (ambient, true, none, none), tapesAt left right base tail []⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, flag, leftRegister, rightRegister) + (tapesAt left right base (head :: tail) [])) = _ + rw [atLoop] + simp [loop, TM2.stepAux, distinct, update_left, update_right] + +theorem step_cons_cons (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (leftHead rightHead : Bool) (leftTail rightTail : List Bool) + (ambient : σ) (flag : Bool) (leftRegister rightRegister : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base (leftHead :: leftTail) (rightHead :: rightTail)⟩ = + some ⟨some loopLabel, + (ambient, flag || decide (leftHead ≠ rightHead), none, none), + tapesAt left right base leftTail rightTail⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, flag, leftRegister, rightRegister) + (tapesAt left right base (leftHead :: leftTail) (rightHead :: rightTail))) = _ + rw [atLoop] + simp [loop, TM2.stepAux, distinct, update_left, update_right] + +private theorem trace_left_empty (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (rightWord : List Bool) (ambient : σ) (flag : Bool) + (leftRegister rightRegister : Option Bool) : + (MachineComposition.advance (TM2.step program))^[rightWord.length + 1] + (some ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base [] rightWord⟩) = + some ⟨if mismatch flag [] rightWord then differentExit else equalExit, + (ambient, false, none, none), tapesAt left right base [] []⟩ := by + induction rightWord generalizing flag leftRegister rightRegister with + | nil => + simpa only [List.length_nil, Nat.zero_add, Function.iterate_one, + MachineComposition.advance_some, mismatch_nil_nil] using + step_empty left right distinct loopLabel equalExit differentExit program atLoop base + ambient flag leftRegister rightRegister + | cons head tail ih => + rw [List.length_cons, Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[tail.length + 1] + (TM2.step program ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base [] (head :: tail)⟩) = _ + rw [step_nil_cons left right distinct loopLabel equalExit differentExit program atLoop] + simpa only [mismatch_true, mismatch_nil_cons] using ih true none none + +theorem compareTrace_flag (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (leftWord rightWord : List Bool) (ambient : σ) (flag : Bool) + (leftRegister rightRegister : Option Bool) : + (MachineComposition.advance (TM2.step program))^[max leftWord.length rightWord.length + 1] + (some ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base leftWord rightWord⟩) = + some ⟨if mismatch flag leftWord rightWord then differentExit else equalExit, + (ambient, false, none, none), tapesAt left right base [] []⟩ := by + induction leftWord generalizing rightWord flag leftRegister rightRegister with + | nil => + simpa only [List.length_nil, Nat.zero_max] using + trace_left_empty left right distinct loopLabel equalExit differentExit program atLoop + base rightWord ambient flag leftRegister rightRegister + | cons head tail ih => + cases rightWord with + | nil => + rw [List.length_cons, List.length_nil, Nat.max_zero, Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[tail.length + 1] + (TM2.step program ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base (head :: tail) []⟩) = _ + rw [step_cons_nil left right distinct loopLabel equalExit differentExit program atLoop] + simpa only [List.length_nil, Nat.max_zero, mismatch_true, mismatch_cons_nil] using + ih [] true none none + | cons rightHead rightTail => + rw [List.length_cons, List.length_cons, Nat.succ_max_succ, Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[max tail.length rightTail.length + 1] + (TM2.step program ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), + tapesAt left right base (head :: tail) (rightHead :: rightTail)⟩) = _ + rw [step_cons_cons left right distinct loopLabel equalExit differentExit program atLoop] + simpa only [mismatch_cons] using + ih rightTail (flag || decide (head ≠ rightHead)) none none + +theorem compareTrace (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (leftWord rightWord : List Bool) (ambient : σ) + (leftRegister rightRegister : Option Bool) : + (MachineComposition.advance (TM2.step program))^[max leftWord.length rightWord.length + 1] + (some ⟨some loopLabel, (ambient, false, leftRegister, rightRegister), + tapesAt left right base leftWord rightWord⟩) = + some ⟨if leftWord = rightWord then equalExit else differentExit, + (ambient, false, none, none), tapesAt left right base [] []⟩ := by + have h := compareTrace_flag left right distinct loopLabel equalExit differentExit program + atLoop base leftWord rightWord ambient false leftRegister rightRegister + by_cases heq : leftWord = rightWord <;> simpa [mismatch, heq] using h + +theorem compareTrace_fromTapes (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (ambient : σ) (leftRegister rightRegister : Option Bool) : + (MachineComposition.advance (TM2.step program))^[max (base left).length (base right).length + 1] + (some ⟨some loopLabel, (ambient, false, leftRegister, rightRegister), base⟩) = + some ⟨if base left = base right then equalExit else differentExit, + (ambient, false, none, none), tapesAt left right base [] []⟩ := by + simpa only [tapesAt_self] using + compareTrace left right distinct loopLabel equalExit differentExit program atLoop base + (base left) (base right) ambient leftRegister rightRegister + +theorem drained_other (left right k : K) (notLeft : k ≠ left) (notRight : k ≠ right) + (base : K → List Bool) : tapesAt left right base [] [] k = base k := + tapesAt_other left right k notLeft notRight base [] [] + +def compareInTime (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (ambient : σ) (leftRegister rightRegister : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some loopLabel, (ambient, false, leftRegister, rightRegister), base⟩ + (some ⟨if base left = base right then equalExit else differentExit, + (ambient, false, none, none), tapesAt left right base [] []⟩) + (max (base left).length (base right).length + 1) where + steps := max (base left).length (base right).length + 1 + evals_in_steps := compareTrace_fromTapes left right distinct loopLabel equalExit differentExit + program atLoop base ambient leftRegister rightRegister + steps_le_m := Nat.le_refl _ + +@[simp] theorem compareInTime_steps (left right : K) (distinct : left ≠ right) + (loopLabel : Λ) (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) + (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) + (base : K → List Bool) (ambient : σ) (leftRegister rightRegister : Option Bool) : + (compareInTime left right distinct loopLabel equalExit differentExit program atLoop base + ambient leftRegister rightRegister).steps = + max (base left).length (base right).length + 1 := rfl + +end IndependentSetsGames.Foundations.Complexity.MachineCompare + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineComposition.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..8dd9fda580cbee5b6ca8f2da3decdb0b7f213a59 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineComposition.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineEmbedding + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineComposition + +def advance {σ : Type} (step : σ → Option σ) (state : Option σ) : Option σ := + state.bind step + +@[simp] theorem advance_none {σ : Type} (step : σ → Option σ) : + advance step none = none := rfl + +@[simp] theorem advance_some {σ : Type} (step : σ → Option σ) (state : σ) : + advance step (some state) = step state := rfl + +@[simp] theorem advance_iterate_none {σ : Type} (step : σ → Option σ) (n : Nat) : + (advance step)^[n] none = none := by + induction n with + | zero => rfl + | succ n ih => rw [Function.iterate_succ_apply', ih, advance_none] + +theorem liftSuccessfulTrace {σ τ : Type} (source : σ → Option σ) + (target : τ → Option τ) (embed : σ → τ) + (simulation : ∀ a b, source a = some b → target (embed a) = some (embed b)) + (n : Nat) (start finish : σ) + (trace : (advance source)^[n] (some start) = some finish) : + (advance target)^[n] (some (embed start)) = some (embed finish) := by + induction n generalizing start with + | zero => + have same := Option.some.inj trace + cases same + rfl + | succ n ih => + rw [Function.iterate_succ_apply] at trace ⊢ + change (advance source)^[n] (source start) = some finish at trace + change (advance target)^[n] (target (embed start)) = some (embed finish) + cases firstStep : source start with + | none => + rw [firstStep, advance_iterate_none] at trace + contradiction + | some intermediate => + rw [firstStep] at trace + rw [simulation start intermediate firstStep] + exact ih intermediate trace + +def liftExecutionInTime {σ τ : Type} (source : σ → Option σ) + (target : τ → Option τ) (embed : σ → τ) + (simulation : ∀ a b, source a = some b → target (embed a) = some (embed b)) + {start finish : σ} {budget : Nat} + (execution : StateTransition.EvalsToInTime source start (some finish) budget) : + StateTransition.EvalsToInTime target (embed start) (some (embed finish)) budget where + steps := execution.steps + evals_in_steps := by + have sourceTrace := execution.evals_in_steps + change (advance source)^[execution.steps] (some start) = some finish at sourceTrace + change (advance target)^[execution.steps] (some (embed start)) = some (embed finish) + exact liftSuccessfulTrace source target embed simulation execution.steps start finish sourceTrace + steps_le_m := execution.steps_le_m + +@[simp] theorem liftExecutionInTime_steps {σ τ : Type} (source : σ → Option σ) + (target : τ → Option τ) (embed : σ → τ) + (simulation : ∀ a b, source a = some b → target (embed a) = some (embed b)) + {start finish : σ} {budget : Nat} + (execution : StateTransition.EvalsToInTime source start (some finish) budget) : + (liftExecutionInTime source target embed simulation execution).steps = execution.steps := rfl + +def embeddedExecution {K E Λ Λextra σ τ : Type} {Γ : K → Type} {Δ : E → Type} + [DecidableEq K] [DecidableEq E] + (haltTarget : Option (Λ ⊕ Λextra)) (extraState : τ) + (extraTapes : ∀ e, List (Δ e)) + (source : Λ → Turing.TM2.Stmt Γ Λ σ) + (extra : Λextra → Turing.TM2.Stmt (MachineEmbedding.Alphabet Γ Δ) + (Λ ⊕ Λextra) (σ × τ)) + {start finish : Turing.TM2.Cfg Γ Λ σ} {budget : Nat} + (execution : StateTransition.EvalsToInTime (Turing.TM2.step source) + start (some finish) budget) : + StateTransition.EvalsToInTime (Turing.TM2.step (MachineEmbedding.program haltTarget source extra)) + (MachineEmbedding.configuration haltTarget extraState extraTapes start) + (some (MachineEmbedding.configuration haltTarget extraState extraTapes finish)) budget := + liftExecutionInTime (Turing.TM2.step source) + (Turing.TM2.step (MachineEmbedding.program haltTarget source extra)) + (MachineEmbedding.configuration haltTarget extraState extraTapes) + (MachineEmbedding.step_simulation haltTarget extraState extraTapes source extra) execution + +theorem natPolynomial_eval_mono (p : Polynomial Nat) {a b : Nat} (h : a ≤ b) : + p.eval a ≤ p.eval b := by + induction p using Polynomial.induction_on' with + | add p q hp hq => + simpa only [Polynomial.eval_add] using Nat.add_le_add hp hq + | monomial degree coefficient => + simp only [Polynomial.eval_monomial] + exact Nat.mul_le_mul_left coefficient (Nat.pow_le_pow_left h degree) + +noncomputable def compositionPolynomial (first second intermediate : Polynomial Nat) : Polynomial Nat := + first + Polynomial.C 2 * (intermediate + 1) + second.comp intermediate + +theorem compositionBudget_le (first second intermediate : Polynomial Nat) + (inputLength intermediateLength : Nat) + (intermediateBound : intermediateLength ≤ intermediate.eval inputLength) : + first.eval inputLength + 2 * (intermediateLength + 1) + second.eval intermediateLength ≤ + (compositionPolynomial first second intermediate).eval inputLength := by + have secondBound := natPolynomial_eval_mono second intermediateBound + have transferBound := Nat.mul_le_mul_left 2 (Nat.add_le_add_right intermediateBound 1) + simp only [compositionPolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_one, Polynomial.eval_comp] + omega + +def fourPhaseExecution {σ : Type} (step : σ → Option σ) + (start afterFirst afterTransfer₁ afterTransfer₂ : σ) (finish : Option σ) + (first second intermediate : Polynomial Nat) (inputLength intermediateLength : Nat) + (intermediateBound : intermediateLength ≤ intermediate.eval inputLength) + (runFirst : StateTransition.EvalsToInTime step start (some afterFirst) (first.eval inputLength)) + (transfer₁ : StateTransition.EvalsToInTime step afterFirst (some afterTransfer₁) + (intermediateLength + 1)) + (transfer₂ : StateTransition.EvalsToInTime step afterTransfer₁ (some afterTransfer₂) + (intermediateLength + 1)) + (runSecond : StateTransition.EvalsToInTime step afterTransfer₂ finish + (second.eval intermediateLength)) : + StateTransition.EvalsToInTime step start finish + ((compositionPolynomial first second intermediate).eval inputLength) := by + let firstTwo := StateTransition.EvalsToInTime.trans step _ _ start afterFirst + (some afterTransfer₁) runFirst transfer₁ + let firstThree := StateTransition.EvalsToInTime.trans step _ _ start afterTransfer₁ + (some afterTransfer₂) firstTwo transfer₂ + let allFour := StateTransition.EvalsToInTime.trans step _ _ start afterTransfer₂ + finish firstThree runSecond + refine { + toEvalsTo := allFour.toEvalsTo + steps_le_m := Nat.le_trans allFour.steps_le_m ?_ + } + have bounded := compositionBudget_le first second intermediate inputLength intermediateLength + intermediateBound + omega + +end IndependentSetsGames.Foundations.Complexity.MachineComposition + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineControl.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..4214a02a66aa5ea72aa79d29078fcae9123cf940 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineControl.lean @@ -0,0 +1,219 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GenericGraphTables +import OAI.Combinatorics.IndependentSets.Machines.MachineCompare + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineControl + +open Turing.TM2 + +variable {K Λ Λ' σ σ' : Type} {Γ : K → Type} + +def configuration (labels : Λ → Λ') (states : σ ≃ σ') (c : Cfg Γ Λ σ) : + Cfg Γ Λ' σ' where + l := c.l.map labels + var := states c.var + stk := c.stk + +def statement (labels : Λ → Λ') (states : σ ≃ σ') : Stmt Γ Λ σ → Stmt Γ Λ' σ' + | .push k f next => .push k (fun st => f (states.symm st)) (statement labels states next) + | .peek k f next => .peek k (fun st v => states (f (states.symm st) v)) + (statement labels states next) + | .pop k f next => .pop k (fun st v => states (f (states.symm st) v)) + (statement labels states next) + | .load f next => .load (fun st => states (f (states.symm st))) + (statement labels states next) + | .branch f yes no => .branch (fun st => f (states.symm st)) + (statement labels states yes) (statement labels states no) + | .goto f => .goto (fun st => labels (f (states.symm st))) + | .halt => .halt + +variable [DecidableEq K] + +theorem stepAux_simulation (labels : Λ → Λ') (states : σ ≃ σ') + (q : Stmt Γ Λ σ) (state : σ) (tapes : ∀ k, List (Γ k)) : + stepAux (statement labels states q) (states state) tapes = + configuration labels states (stepAux q state tapes) := by + induction q generalizing state tapes with + | push k f next ih => + simpa only [statement, stepAux, Equiv.symm_apply_apply] using + ih state (Function.update tapes k (f state :: tapes k)) + | peek k f next ih => + simpa only [statement, stepAux, Equiv.symm_apply_apply] using + ih (f state (tapes k).head?) tapes + | pop k f next ih => + simpa only [statement, stepAux, Equiv.symm_apply_apply] using + ih (f state (tapes k).head?) (Function.update tapes k (tapes k).tail) + | load f next ih => + simpa only [statement, stepAux, Equiv.symm_apply_apply] using ih (f state) tapes + | branch f yes no ihYes ihNo => + cases h : f state with + | false => + simpa only [statement, stepAux, Equiv.symm_apply_apply, h, Bool.cond_false] using + ihNo state tapes + | true => + simpa only [statement, stepAux, Equiv.symm_apply_apply, h, Bool.cond_true] using + ihYes state tapes + | goto f => simp [statement, stepAux, configuration] + | halt => rfl + +def program (labels : Λ ≃ Λ') (states : σ ≃ σ') (source : Λ → Stmt Γ Λ σ) : + Λ' → Stmt Γ Λ' σ' := fun l => statement labels states (source (labels.symm l)) + +theorem step_simulation (labels : Λ ≃ Λ') (states : σ ≃ σ') + (source : Λ → Stmt Γ Λ σ) (c : Cfg Γ Λ σ) : + step (program labels states source) (configuration labels states c) = + (step source c).map (configuration labels states) := by + cases c with + | mk l state tapes => + cases l with + | none => rfl + | some l => + change some (stepAux (statement labels states (source (labels.symm (labels l)))) + (states state) tapes) = _ + rw [Equiv.symm_apply_apply, stepAux_simulation] + rfl + +end IndependentSetsGames.Foundations.Complexity.MachineControl +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.RuntimeModel + +open Turing +open IndependentSetsGames.Foundations.Complexity + +inductive Tape + | original | cursor | scan | vertices | darts | counter | edge + | tail | reverseIndex | head | scratch | indexScan + | compareLeft | compareRight | reversed | output + deriving DecidableEq + +instance : Fintype Tape where + elems := {.original, .cursor, .scan, .vertices, .darts, .counter, .edge, + .tail, .reverseIndex, .head, .scratch, .indexScan, + .compareLeft, .compareRight, .reversed, .output} + complete tape := by cases tape <;> simp + +abbrev Alphabet (_ : Tape) := Bool + +abbrev Flags := Bool × Bool × Option Bool +abbrev Ambient (q : Nat) := Flags × GenericGraphTables.RelationTable q +abbrev State (q : Nat) := Ambient q × Option Bool + +def normal {q : Nat} (relation : GenericGraphTables.RelationTable q) (selfLoop : Bool) : State q := + (((selfLoop, false, none), relation), none) + +def initial (q : Nat) : State q := normal (Vector.replicate (q * q) false) false + +def context {q : Nat} (ambient : Ambient q) : GenericGraphTables.RelationTable q × Bool := + (ambient.2, ambient.1.1) + +def compareEquiv (q : Nat) : State q ≃ + MachineCompare.State (GenericGraphTables.RelationTable q × Bool) where + toFun s := ((s.1.2, s.1.1.1), s.1.1.2.1, s.1.1.2.2, s.2) + invFun s := (((s.1.2, s.2.1, s.2.2.1), s.1.1), s.2.2.2) + left_inv _ := rfl + right_inv _ := rfl + +@[simp] theorem compareEquiv_normal {q : Nat} + (relation : GenericGraphTables.RelationTable q) (selfLoop : Bool) : + compareEquiv q (normal relation selfLoop) = + ((relation, selfLoop), false, none, none) := rfl + +def emitterEquiv (q : Nat) : ((Ambient q × Unit) × Option Bool) ≃ State q where + toFun s := (s.1.1, s.2) + invFun s := ((s.1, ()), s.2) + left_inv s := by rcases s with ⟨⟨s, u⟩, r⟩; cases u; rfl + right_inv _ := rfl + +def setupPorts : Fin 7 → Tape := + ![.original, .cursor, .vertices, .darts, .counter, .scratch, .edge] + +theorem setupPorts_injective : Function.Injective setupPorts := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [setupPorts] + +def headPorts : Fin 6 → Tape := + ![.original, .reverseIndex, .scan, .indexScan, .head, .scratch] + +theorem headPorts_injective : Function.Injective headPorts := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [headPorts] + +def rowSources : Fin 5 → Tape := ![.vertices, .darts, .edge, .tail, .head] +def headerSources : Fin 2 → Tape := ![.vertices, .darts] +def fieldPorts : Fin 3 → Tape := ![.tail, .reverseIndex, .head] + +def cleanupPorts : Fin 15 → Tape := + ![.original, .cursor, .scan, .vertices, .darts, .counter, .edge, + .tail, .reverseIndex, .head, .scratch, .indexScan, .compareLeft, .compareRight, .reversed] + +theorem cleanupPorts_ne_output (i : Fin 15) : cleanupPorts i ≠ .output := by + fin_cases i <;> simp [cleanupPorts] + +theorem cleanupPorts_cover (tape : Tape) (h : tape ≠ .output) : + ∃ i, cleanupPorts i = tape := by + cases tape + · exact ⟨0, rfl⟩ + · exact ⟨1, rfl⟩ + · exact ⟨2, rfl⟩ + · exact ⟨3, rfl⟩ + · exact ⟨4, rfl⟩ + · exact ⟨5, rfl⟩ + · exact ⟨6, rfl⟩ + · exact ⟨7, rfl⟩ + · exact ⟨8, rfl⟩ + · exact ⟨9, rfl⟩ + · exact ⟨10, rfl⟩ + · exact ⟨11, rfl⟩ + · exact ⟨12, rfl⟩ + · exact ⟨13, rfl⟩ + · exact ⟨14, rfl⟩ + · exact (h rfl).elim + +variable {Λ : Type} {q : Nat} + +def compareStatement (stmt : TM2.Stmt Alphabet Λ + (MachineCompare.State (GenericGraphTables.RelationTable q × Bool))) : + TM2.Stmt Alphabet Λ (State q) := + MachineControl.statement id (compareEquiv q).symm stmt + +def emitterStatement (stmt : TM2.Stmt Alphabet Λ ((Ambient q × Unit) × Option Bool)) : + TM2.Stmt Alphabet Λ (State q) := + MachineControl.statement id (emitterEquiv q) stmt + +def storeLoop (value : Bool) (next : Λ) : TM2.Stmt Alphabet Λ (State q) := + .load (fun state => (((value, false, none), state.1.2), none)) (.goto fun _ => next) + +theorem stepAux_storeLoop (value : Bool) (next : Λ) (state : State q) + (base : Tape → List Bool) : + TM2.stepAux (storeLoop value next) state base = + ⟨some next, normal state.1.2 value, base⟩ := rfl + +def nextRow (next : Λ) : TM2.Stmt Alphabet Λ (State q) := + .push .edge (fun _ => true) + (.load (fun state => (state.1, none)) (.goto fun _ => next)) + +theorem stepAux_nextRow (next : Λ) (state : State q) + (base : Tape → List Bool) (edge : Nat) (suffix : List Bool) + (he : base .edge = encodeWord edge ++ suffix) : + TM2.stepAux (nextRow next) state base = + ⟨some next, (state.1, none), + Function.update base .edge (encodeWord (edge + 1) ++ suffix)⟩ := by + simp [nextRow, TM2.stepAux, he, encodeWord, List.replicate_succ] + +def transportInTime {K τ υ : Type} [DecidableEq K] {Γ : K → Type} + (e : τ ≃ υ) (p : Λ → TM2.Stmt Γ Λ τ) + {start finish : TM2.Cfg Γ Λ τ} {budget : Nat} + (run : StateTransition.EvalsToInTime (TM2.step p) start (some finish) budget) : + StateTransition.EvalsToInTime (TM2.step (MachineControl.program (Equiv.refl Λ) e p)) + (MachineControl.configuration id e start) + (some (MachineControl.configuration id e finish)) budget := by + apply MachineComposition.liftExecutionInTime _ _ (MachineControl.configuration id e) _ run + intro a b hab + have h := MachineControl.step_simulation (Equiv.refl Λ) e p a + rw [hab] at h + exact h + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.RuntimeModel + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCopy.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCopy.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a07ba89e8b1593c6d7932cbc7ed1982294730dd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineCopy.lean @@ -0,0 +1,246 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.PatternInvariant +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCopy + +open Turing + +variable {K Λ σ β : Type} [DecidableEq K] + +abbrev Alphabet (β : Type) (_ : K) := β + +def forkLoop (source left right : K) (fallback : β) (loopLabel : Λ) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.push left (fun state => state.2.getD fallback) + (.push right (fun state => state.2.getD fallback) (.goto fun _ => loopLabel))) + (Reduction.MachineTransfer.exitAt right exit)) + +def forkTapes (source left right : K) (base : K → List β) + (input leftOutput rightOutput : List β) : K → List β := + Function.update (Function.update (Function.update base source input) left leftOutput) + right rightOutput + +@[simp] theorem forkTapes_source (source left right : K) + (sourceLeft : source ≠ left) (sourceRight : source ≠ right) + (base : K → List β) (input leftOutput rightOutput : List β) : + forkTapes source left right base input leftOutput rightOutput source = input := by + simp [forkTapes, sourceLeft, sourceRight] + +@[simp] theorem forkTapes_left (source left right : K) (leftRight : left ≠ right) + (base : K → List β) (input leftOutput rightOutput : List β) : + forkTapes source left right base input leftOutput rightOutput left = leftOutput := by + simp [forkTapes, leftRight] + +@[simp] theorem forkTapes_right (source left right : K) + (base : K → List β) (input leftOutput rightOutput : List β) : + forkTapes source left right base input leftOutput rightOutput right = rightOutput := by + simp [forkTapes] + +@[simp] theorem forkTapes_self (source left right : K) (base : K → List β) : + forkTapes source left right base (base source) (base left) (base right) = base := by + simp [forkTapes] + +private theorem update_fork_source (source left right : K) + (sourceLeft : source ≠ left) (sourceRight : source ≠ right) (leftRight : left ≠ right) + (base : K → List β) (input leftOutput rightOutput replacement : List β) : + Function.update (forkTapes source left right base input leftOutput rightOutput) + source replacement = forkTapes source left right base replacement leftOutput rightOutput := by + funext k + by_cases hs : k = source + · subst k; simp [forkTapes, sourceLeft, sourceRight] + · by_cases hl : k = left + · subst k; simp [forkTapes, Ne.symm sourceLeft, leftRight] + · by_cases hr : k = right + · subst k; simp [forkTapes, Ne.symm sourceRight] + · simp [forkTapes, hs, hl, hr] + +private theorem update_fork_left (source left right : K) (leftRight : left ≠ right) + (base : K → List β) (input leftOutput rightOutput replacement : List β) : + Function.update (forkTapes source left right base input leftOutput rightOutput) + left replacement = forkTapes source left right base input replacement rightOutput := by + funext k + by_cases hl : k = left + · subst k; simp [forkTapes, leftRight] + · by_cases hr : k = right + · subst k; simp [forkTapes, Ne.symm leftRight] + · simp [forkTapes, hl, hr] + +private theorem update_fork_right (source left right : K) + (base : K → List β) (input leftOutput rightOutput replacement : List β) : + Function.update (forkTapes source left right base input leftOutput rightOutput) + right replacement = forkTapes source left right base input leftOutput replacement := by + simp [forkTapes] + +theorem forkStep_empty (source left right : K) + (sourceLeft : source ≠ left) (sourceRight : source ≠ right) (leftRight : left ≠ right) + (fallback : β) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atLoop : program loopLabel = forkLoop source left right fallback loopLabel exit) + (base : K → List β) (leftOutput rightOutput : List β) (ambient : σ) (register : Option β) : + TM2.step program + ⟨some loopLabel, (ambient, register), forkTapes source left right base [] leftOutput rightOutput⟩ = + some ⟨exit, (ambient, none), forkTapes source left right base [] leftOutput rightOutput⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (forkTapes source left right base [] leftOutput rightOutput)) = _ + rw [atLoop] + cases exit <;> + simp [forkLoop, Reduction.MachineTransfer.exitAt, TM2.stepAux, sourceLeft, sourceRight, + leftRight, update_fork_source] + +theorem forkStep_cons (source left right : K) + (sourceLeft : source ≠ left) (sourceRight : source ≠ right) (leftRight : left ≠ right) + (fallback : β) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atLoop : program loopLabel = forkLoop source left right fallback loopLabel exit) + (base : K → List β) (head : β) (input leftOutput rightOutput : List β) + (ambient : σ) (register : Option β) : + TM2.step program + ⟨some loopLabel, (ambient, register), + forkTapes source left right base (head :: input) leftOutput rightOutput⟩ = + some ⟨some loopLabel, (ambient, some head), + forkTapes source left right base input (head :: leftOutput) (head :: rightOutput)⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (forkTapes source left right base (head :: input) leftOutput rightOutput)) = _ + rw [atLoop] + simp [forkLoop, TM2.stepAux, sourceLeft, sourceRight, leftRight, + update_fork_source, update_fork_left, update_fork_right] + +theorem forkTrace (source left right : K) + (sourceLeft : source ≠ left) (sourceRight : source ≠ right) (leftRight : left ≠ right) + (fallback : β) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atLoop : program loopLabel = forkLoop source left right fallback loopLabel exit) + (base : K → List β) (input leftOutput rightOutput : List β) + (ambient : σ) (register : Option β) : + (MachineComposition.advance (TM2.step program))^[input.length + 1] + (some ⟨some loopLabel, (ambient, register), + forkTapes source left right base input leftOutput rightOutput⟩) = + some ⟨exit, (ambient, none), forkTapes source left right base [] + (input.reverse ++ leftOutput) (input.reverse ++ rightOutput)⟩ := by + induction input generalizing leftOutput rightOutput register with + | nil => + simpa only [List.length_nil, Nat.zero_add, Function.iterate_one, + MachineComposition.advance_some, List.reverse_nil, List.nil_append] using + forkStep_empty source left right sourceLeft sourceRight leftRight fallback loopLabel exit + program atLoop base leftOutput rightOutput ambient register + | cons head input ih => + rw [List.length_cons, Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[input.length + 1] + (TM2.step program ⟨some loopLabel, (ambient, register), + forkTapes source left right base (head :: input) leftOutput rightOutput⟩) = _ + rw [forkStep_cons source left right sourceLeft sourceRight leftRight fallback loopLabel exit + program atLoop base head input leftOutput rightOutput ambient register, ih] + simp only [List.reverse_cons, List.append_assoc, List.singleton_append] + +def forkInTime (source left right : K) + (sourceLeft : source ≠ left) (sourceRight : source ≠ right) (leftRight : left ≠ right) + (fallback : β) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atLoop : program loopLabel = forkLoop source left right fallback loopLabel exit) + (base : K → List β) (ambient : σ) (register : Option β) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some loopLabel, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), forkTapes source left right base [] + ((base source).reverse ++ base left) ((base source).reverse ++ base right)⟩) + ((base source).length + 1) where + steps := (base source).length + 1 + evals_in_steps := by + change (MachineComposition.advance (TM2.step program))^[(base source).length + 1] + (some ⟨some loopLabel, (ambient, register), base⟩) = _ + simpa only [forkTapes_self] using + forkTrace source left right sourceLeft sourceRight leftRight fallback loopLabel exit + program atLoop base (base source) (base left) (base right) ambient register + steps_le_m := Nat.le_refl _ + +def drainedTapes (source scratch : K) (base : K → List β) : K → List β := + Reduction.MachineTransfer.tapesAt source scratch base [] (base source).reverse + +theorem restoredTapes (source destination scratch : K) + (sourceDestination : source ≠ destination) (sourceScratch : source ≠ scratch) + (destinationScratch : destination ≠ scratch) (base : K → List β) + (scratchEmpty : base scratch = []) : + forkTapes scratch source destination (drainedTapes source scratch base) [] + (base source) (base source ++ base destination) = + Function.update base destination (base source ++ base destination) := by + funext k + by_cases hs : k = source + · subst k + simp [forkTapes, sourceDestination] + · by_cases hd : k = destination + · subst k; simp [forkTapes] + · by_cases ht : k = scratch + · subst k + simp [forkTapes, Ne.symm sourceScratch, Ne.symm destinationScratch, scratchEmpty] + · simp [forkTapes, drainedTapes, Reduction.MachineTransfer.tapesAt, hs, hd, ht] + +theorem copyTrace (source destination scratch : K) + (sourceDestination : source ≠ destination) (sourceScratch : source ≠ scratch) + (destinationScratch : destination ≠ scratch) + (fallback : β) (firstLabel secondLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atFirst : program firstLabel = + Reduction.MachineTransfer.loopAt source scratch id fallback firstLabel (some secondLabel)) + (atSecond : program secondLabel = forkLoop scratch source destination fallback secondLabel exit) + (base : K → List β) (scratchEmpty : base scratch = []) + (ambient : σ) (register : Option β) : + (MachineComposition.advance (TM2.step program))^[2 * ((base source).length + 1)] + (some ⟨some firstLabel, (ambient, register), base⟩) = + some ⟨exit, (ambient, none), + Function.update base destination (base source ++ base destination)⟩ := by + have first := Reduction.MachineTransfer.transferAt_fromTapes source scratch sourceScratch + id fallback firstLabel (some secondLabel) program atFirst base ambient register + change (MachineComposition.advance (TM2.step program))^[(base source).length + 1] + (some ⟨some firstLabel, (ambient, register), base⟩) = _ at first + simp only [List.map_id, scratchEmpty, List.append_nil] at first + have second := forkTrace scratch source destination (Ne.symm sourceScratch) + (Ne.symm destinationScratch) sourceDestination fallback secondLabel exit program atSecond + (drainedTapes source scratch base) + (drainedTapes source scratch base scratch) (drainedTapes source scratch base source) + (drainedTapes source scratch base destination) ambient none + simp only [forkTapes_self] at second + have scratchWord : drainedTapes source scratch base scratch = (base source).reverse := by + simp [drainedTapes] + have sourceWord : drainedTapes source scratch base source = [] := by + simp [drainedTapes, sourceScratch] + have destinationWord : drainedTapes source scratch base destination = base destination := by + simp [drainedTapes, Reduction.MachineTransfer.tapesAt, Ne.symm sourceDestination, + destinationScratch] + rw [scratchWord, sourceWord, destinationWord] at second + simp only [List.reverse_reverse, List.append_nil, List.length_reverse] at second + rw [restoredTapes source destination scratch sourceDestination sourceScratch destinationScratch + base scratchEmpty] at second + rw [show 2 * ((base source).length + 1) = + ((base source).length + 1) + ((base source).length + 1) by omega, + Function.iterate_add_apply, first] + exact second + +def copyInTime (source destination scratch : K) + (sourceDestination : source ≠ destination) (sourceScratch : source ≠ scratch) + (destinationScratch : destination ≠ scratch) + (fallback : β) (firstLabel secondLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K) β) Λ (σ × Option β)) + (atFirst : program firstLabel = + Reduction.MachineTransfer.loopAt source scratch id fallback firstLabel (some secondLabel)) + (atSecond : program secondLabel = forkLoop scratch source destination fallback secondLabel exit) + (base : K → List β) (scratchEmpty : base scratch = []) + (ambient : σ) (register : Option β) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some firstLabel, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), + Function.update base destination (base source ++ base destination)⟩) + (2 * ((base source).length + 1)) where + steps := 2 * ((base source).length + 1) + evals_in_steps := copyTrace source destination scratch sourceDestination sourceScratch + destinationScratch fallback firstLabel secondLabel exit program atFirst atSecond base + scratchEmpty ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineCopy + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrain.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrain.lean new file mode 100644 index 0000000000000000000000000000000000000000..c69e84497ba69f58a58293e6eb806b98439a4e96 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrain.lean @@ -0,0 +1,61 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineDrain + +open Turing + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def drain (source : K) (again : Λ) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.goto fun _ => again) + (.load (fun state => (state.1, none)) (Reduction.MachineTransfer.exitAt source exit))) + +theorem drainTrace (source : K) (again : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atDrain : program again = drain source again exit) + (base : K → List Bool) (word : List Bool) (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[word.length + 1] + (some ⟨some again, (ambient, register), Function.update base source word⟩) = + some ⟨exit, (ambient, none), Function.update base source []⟩ := by + induction word generalizing register with + | nil => + change some (TM2.stepAux (program again) (ambient, register) + (Function.update base source [])) = _ + rw [atDrain] + cases exit <;> simp [drain, TM2.stepAux, Reduction.MachineTransfer.exitAt] + | cons symbol word ih => + rw [List.length_cons, Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[word.length + 1] + (some (TM2.stepAux (program again) (ambient, register) + (Function.update base source (symbol :: word)))) = _ + rw [atDrain] + simpa [drain, TM2.stepAux] using ih (some symbol) + +def drainInTime (source : K) (again : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atDrain : program again = drain source again exit) + (base : K → List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some again, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), Function.update base source []⟩) + ((base source).length + 1) where + steps := (base source).length + 1 + evals_in_steps := by + change (MachineComposition.advance (TM2.step program))^[(base source).length + 1] + (some ⟨some again, (ambient, register), base⟩) = _ + simpa only [Function.update_eq_self] using + drainTrace source again exit program atDrain base (base source) ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineDrain + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrainMany.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrainMany.lean new file mode 100644 index 0000000000000000000000000000000000000000..d24c488631f7a311b4c9dc7f0e651c5466f1d1d7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrainMany.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain +import OAI.Combinatorics.IndependentSets.Machines.MachineFiniteSequence + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineDrainMany + +open Turing MachineComposition + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool +abbrev Tapes (K : Type) := K → List Bool +abbrev LocalLabel (_ : K) := Unit +abbrev Label (chosen : List K) := MachineFiniteSequence.Label (LocalLabel (K := K)) chosen +abbrev Data (K : Type) := Tapes K × Option Bool + +def entry (chosen : List K) (labels : Label chosen → Λ) (exit : Option Λ) : Option Λ := + MachineFiniteSequence.entry (LocalLabel (K := K)) (fun _ => ()) chosen labels exit + +def localInstruction (source : K) (labels : Unit → Λ) (exit : Option Λ) (_ : Unit) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + MachineDrain.drain source (labels ()) exit + +def instruction (chosen : List K) (labels : Label chosen → Λ) (exit : Option Λ) : + Label chosen → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + MachineFiniteSequence.instruction (LocalLabel (K := K)) (fun _ => ()) + localInstruction chosen labels exit + +def result (source : K) (data : Data K) : Data K := + (Function.update data.1 source [], none) + +def cost (source : K) (data : Data K) : Nat := (data.1 source).length + 1 + +def finalTapes : List K → Tapes K → Tapes K + | [], base => base + | source :: chosen, base => finalTapes chosen (Function.update base source []) + +def finalRegister : List K → Option Bool → Option Bool + | [], register => register + | _ :: _, _ => none + +omit [DecidableEq K] in +@[simp] theorem finalRegister_none (chosen : List K) : finalRegister chosen none = none := by + cases chosen <;> rfl + +def steps : List K → Tapes K → Nat + | [], _ => 0 + | source :: chosen, base => (base source).length + 1 + + steps chosen (Function.update base source []) + +@[simp] theorem sequence_result (chosen : List K) (base : Tapes K) (register : Option Bool) : + MachineFiniteSequence.resultOf result chosen (base, register) = + (finalTapes chosen base, finalRegister chosen register) := by + induction chosen generalizing base register with + | nil => rfl + | cons source chosen ih => + change MachineFiniteSequence.resultOf result chosen (Function.update base source [], none) = + (finalTapes chosen (Function.update base source []), none) + rw [ih, finalRegister_none] + +@[simp] theorem sequence_steps (chosen : List K) (base : Tapes K) (register : Option Bool) : + MachineFiniteSequence.steps result cost chosen (base, register) = steps chosen base := by + induction chosen generalizing base register with + | nil => rfl + | cons source chosen ih => + simp only [MachineFiniteSequence.steps, result, cost, steps, ih] + +theorem finalTapes_apply (chosen : List K) (base : Tapes K) (k : K) : + finalTapes chosen base k = if k ∈ chosen then [] else base k := by + induction chosen generalizing base with + | nil => simp [finalTapes] + | cons source chosen ih => + rw [finalTapes, ih] + by_cases h : k = source + · subst k + simp + · simp [List.mem_cons, h] + +theorem finalTapes_mem (chosen : List K) (base : Tapes K) (k : K) (h : k ∈ chosen) : + finalTapes chosen base k = [] := by rw [finalTapes_apply, ite_eq_left h] + +theorem finalTapes_not_mem (chosen : List K) (base : Tapes K) (k : K) (h : k ∉ chosen) : + finalTapes chosen base k = base k := by rw [finalTapes_apply, ite_eq_right h] + +def lengthSum (chosen : List K) (base : Tapes K) : Nat := + (chosen.map (fun k => (base k).length)).sum + +omit [DecidableEq K] in +theorem lengthSum_mono (chosen : List K) (first second : Tapes K) + (h : ∀ k, (first k).length ≤ (second k).length) : + lengthSum chosen first ≤ lengthSum chosen second := by + induction chosen with + | nil => exact Nat.le_refl 0 + | cons source chosen ih => + simp only [lengthSum, List.map_cons, List.sum_cons] at ih ⊢ + exact Nat.add_le_add (h source) ih + +theorem steps_le (chosen : List K) (base : Tapes K) : + steps chosen base ≤ lengthSum chosen base + chosen.length := by + induction chosen generalizing base with + | nil => simp [steps, lengthSum] + | cons source chosen ih => + have hshort : ∀ k, ((Function.update base source []) k).length ≤ (base k).length := by + intro k + by_cases h : k = source + · subst k + simp + · simp [Function.update_of_ne h] + have hsum := lengthSum_mono chosen (Function.update base source []) base hshort + have htail := ih (Function.update base source []) + simp only [steps, lengthSum, List.map_cons, List.sum_cons, List.length_cons] at hsum htail ⊢ + omega + +theorem steps_le_uniform (chosen : List K) (base : Tapes K) (bound : Nat) + (h : ∀ k, (base k).length ≤ bound) : + steps chosen base ≤ chosen.length * (bound + 1) := by + have hsum : lengthSum chosen base ≤ chosen.length * bound := by + induction chosen with + | nil => simp [lengthSum] + | cons source chosen ih => + simp only [lengthSum, List.map_cons, List.sum_cons, List.length_cons, Nat.add_mul, + Nat.one_mul] at ih ⊢ + have hs := h source + omega + have hc := steps_le chosen base + rw [Nat.mul_add, Nat.mul_one] + omega + +theorem trace (chosen : List K) (labels : Label chosen → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ l, program (labels l) = instruction chosen labels exit l) + (base : Tapes K) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps chosen base] + (some ⟨entry chosen labels exit, (ambient, register), base⟩) = + some ⟨exit, (ambient, finalRegister chosen register), finalTapes chosen base⟩ := by + have run := MachineFiniteSequence.trace + (LocalLabel := LocalLabel (K := K)) (main := fun _ => ()) + (localInstruction := localInstruction (σ := σ)) (result := result) (cost := cost) + program (fun _ : Data K => True) (fun data => (ambient, data.2)) (fun data => data.1) + chosen (by intros; trivial) + (by + intro source _ localLabels localExit atLocal data _ + rcases data with ⟨tapes, reg⟩ + simpa only [cost, result, Function.update_eq_self] using + MachineDrain.drainTrace source (localLabels ()) localExit program (atLocal ()) + tapes (tapes source) ambient reg) + labels exit atLabels (base, register) trivial + simpa only [sequence_steps, sequence_result, entry] using run + +def execution (chosen : List K) (labels : Label chosen → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ l, program (labels l) = instruction chosen labels exit l) + (base : Tapes K) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨entry chosen labels exit, (ambient, register), base⟩ + (some ⟨exit, (ambient, finalRegister chosen register), finalTapes chosen base⟩) + (lengthSum chosen base + chosen.length) where + steps := steps chosen base + evals_in_steps := trace chosen labels exit program atLabels base ambient register + steps_le_m := steps_le chosen base + +def workTapes {N : Nat} (enumeration : Fin N ≃ K) (output : K) : List K := + (List.ofFn (fun i => enumeration i)).filter (fun k => decide (k ≠ output)) + +@[simp] theorem mem_workTapes {N : Nat} (enumeration : Fin N ≃ K) (output k : K) : + k ∈ workTapes enumeration output ↔ k ≠ output := by + have hmem : k ∈ List.ofFn (fun i => enumeration i) := by + apply List.mem_ofFn.mpr + exact ⟨enumeration.symm k, enumeration.apply_symm_apply k⟩ + simp [workTapes, hmem] + +theorem workTapes_length_le {N : Nat} (enumeration : Fin N ≃ K) (output : K) : + (workTapes enumeration output).length ≤ N := by + simpa only [workTapes, List.length_ofFn] using + List.length_filter_le (fun k => decide (k ≠ output)) (List.ofFn (fun i => enumeration i)) + +def haltTapes (output : K) (word : List Bool) : Tapes K := + fun k => if k = output then word else [] + +theorem finalTapes_workTapes {N : Nat} (enumeration : Fin N ≃ K) (output : K) + (base : Tapes K) : + finalTapes (workTapes enumeration output) base = haltTapes output (base output) := by + funext k + rw [finalTapes_apply] + by_cases h : k = output + · subst k + simp [haltTapes] + · simp [haltTapes, h] + +theorem cleanupTrace {N : Nat} (enumeration : Fin N ≃ K) (output : K) + (labels : Label (workTapes enumeration output) → Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ l, program (labels l) = + instruction (workTapes enumeration output) labels none l) + (base : Tapes K) (ambient : σ) : + (advance (TM2.step program))^[steps (workTapes enumeration output) base] + (some ⟨entry (workTapes enumeration output) labels none, (ambient, none), base⟩) = + some ⟨none, (ambient, none), haltTapes output (base output)⟩ := by + simpa only [finalRegister_none, finalTapes_workTapes] using + trace (workTapes enumeration output) labels none program atLabels base ambient none + +end IndependentSetsGames.Foundations.Complexity.MachineDrainMany + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDummyRows.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDummyRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..35773796e18e31ca53389e8c4d38418101ad0b97 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDummyRows.lean @@ -0,0 +1,328 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PushWord +import OAI.Combinatorics.IndependentSets.Machines.MachineTableRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineDummyRows + +open Turing +open PCP.GraphTables +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +def trueRelation : RelationTable := Vector.replicate 4096 true + +def trueBits : List Bool := encodeWords (relationWords trueRelation) + +theorem trueBits_length : trueBits.length = 8192 := by + simp only [trueBits, encodeWords_length, relationWords, trueRelation, + Vector.toList_replicate, List.map_replicate, List.sum_replicate_nat, + List.length_replicate] + rfl + +def rowBits (v e : Nat) : List Bool := encodeWord v ++ encodeWord e ++ trueBits + +theorem rowBits_length (v e : Nat) : (rowBits v e).length = v + e + 8194 := by + simp [rowBits, trueBits_length, encodeWord_length] + omega + +theorem rowBits_eq_graph_row {n m : Nat} (v : Fin n) (e : Fin m) : + rowBits v.val e.val = encodeWords (rowWords (⟨v, e, trueRelation⟩ : DartRow n m)) := by + rw [MachineTableRows.rowBits_eq] + rfl + +def rowsBits (v e : Nat) : Nat → List Bool + | 0 => [] + | count + 1 => rowBits v e ++ rowsBits v (e + 1) count + +abbrev Label (d : Nat) := Unit ⊕ (Fin d × (MachineTableRows.Label ⊕ Unit)) + +def start (d : Nat) : Label d := .inl () +def rowLabel {d : Nat} (p : Fin d) (stage : MachineTableRows.Label) : Label d := + .inr (p, .inl stage) +def bumpLabel {d : Nat} (p : Fin d) : Label d := .inr (p, .inr ()) + +def fields : Fin 3 → Fin 6 := fun i => i.castLE (by decide) + +def afterPort {d : Nat} (p : Fin d) : Option (Label d) := + if h : p.val + 1 < d then some (rowLabel ⟨p.val + 1, h⟩ .relationRead) else none + +def entry (d : Nat) : Option (Label d) := + if h : 0 < d then some (rowLabel ⟨0, h⟩ .relationRead) else none + +variable {σ : Type} + +abbrev Alphabet (_ : Fin 6) := Bool + +def continueAt {d : Nat} (exit : Option (Label d)) : + TM2.Stmt Alphabet (Label d) (σ × Option Bool) := + match exit with + | none => .halt + | some label => .goto fun _ => label + +theorem stepAux_continueAt {d : Nat} (exit : Option (Label d)) + (state : σ × Option Bool) (tapes : Fin 6 → List Bool) : + TM2.stepAux (continueAt exit) state tapes = ⟨exit, state, tapes⟩ := by + cases exit <;> rfl + +def program (d : Nat) : Label d → TM2.Stmt Alphabet (Label d) (σ × Option Bool) + | .inl () => pushWord 2 trueBits.reverse + (.load (fun state => (state.1, none)) (continueAt (entry d))) + | .inr (p, .inl stage) => MachineTableRows.routine fields 3 4 5 + (rowLabel p) (some (bumpLabel p)) stage + | .inr (p, .inr ()) => .push 1 (fun _ => true) (continueAt (afterPort p)) + +def fieldTapes (v e : Nat) (output : List Bool) : Fin 6 → List Bool := + ![encodeWord v, encodeWord e, trueBits, [], output, []] + +def initialTapes (v e : Nat) (output : List Bool) : Fin 6 → List Bool := + Function.update (fieldTapes v e output) 2 [] + +theorem initializeStep (d v e : Nat) (output : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (program d) ⟨some (start d), (ambient, register), initialTapes v e output⟩ = + some ⟨entry d, (ambient, none), fieldTapes v e output⟩ := by + change some (TM2.stepAux (program d (start d)) (ambient, register) + (initialTapes v e output)) = _ + simp only [start, program, stepAux_pushWord, List.reverse_reverse, TM2.stepAux, + initialTapes, Function.update_self, List.append_nil, Function.update_idem] + have ht : Function.update (fieldTapes v e output) 2 trueBits = fieldTapes v e output := by + funext i + fin_cases i <;> simp [fieldTapes] + rw [ht, stepAux_continueAt] + +theorem rowTrace {d : Nat} (p : Fin d) (v e : Nat) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step (program d)))^[ + 4 * (v + e + 8194) + 2 * output.length + 9] + (some ⟨some (rowLabel p .relationRead), (ambient, register), fieldTapes v e output⟩) = + some ⟨some (bumpLabel p), (ambient, none), fieldTapes v e (output ++ rowBits v e)⟩ := by + have hfields (i : Fin 3) : fields i ≠ (3 : Fin 6) ∧ fields i ≠ (5 : Fin 6) := by + fin_cases i <;> decide + have h := MachineTableRows.appendTrace fields (3 : Fin 6) 4 5 hfields + (by decide) (by decide) (by decide) (rowLabel p) (some (bumpLabel p)) + (program d) (fun _ => rfl) (fieldTapes v e output) rfl rfl ambient register + have hbits : MachineTableRows.fieldBits fields (fieldTapes v e output) = rowBits v e := by + rfl + have hsize : MachineTableRows.fieldSize fields (fieldTapes v e output) = v + e + 8194 := by + rw [← MachineTableRows.fieldBits_length, hbits, rowBits_length] + have ht : Function.update (fieldTapes v e output) 4 (output ++ rowBits v e) = + fieldTapes v e (output ++ rowBits v e) := by + funext i + fin_cases i <;> simp [fieldTapes] + simpa only [hsize, hbits, show fieldTapes v e output 4 = output from rfl, ht] using h + +theorem bumpStep {d : Nat} (p : Fin d) (v e : Nat) (output : List Bool) (ambient : σ) : + TM2.step (program d) ⟨some (bumpLabel p), (ambient, none), fieldTapes v e output⟩ = + some ⟨afterPort p, (ambient, none), fieldTapes v (e + 1) output⟩ := by + change some (TM2.stepAux (program d (bumpLabel p)) (ambient, none) + (fieldTapes v e output)) = _ + simp only [bumpLabel, program, TM2.stepAux] + rw [stepAux_continueAt] + congr 2 + funext i + fin_cases i <;> simp [fieldTapes, encodeWord, List.replicate_succ] + +theorem rowAndBumpTrace {d : Nat} (p : Fin d) (v e : Nat) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step (program d)))^[ + 4 * (v + e + 8194) + 2 * output.length + 10] + (some ⟨some (rowLabel p .relationRead), (ambient, register), fieldTapes v e output⟩) = + some ⟨afterPort p, (ambient, none), fieldTapes v (e + 1) (output ++ rowBits v e)⟩ := by + rw [show 4 * (v + e + 8194) + 2 * output.length + 10 = + (4 * (v + e + 8194) + 2 * output.length + 9) + 1 by omega, + Function.iterate_succ_apply', rowTrace, MachineComposition.advance_some] + exact bumpStep p v e (output ++ rowBits v e) ambient + +def steps (v e : Nat) (output : List Bool) : Nat → Nat + | 0 => 0 + | count + 1 => (4 * (v + e + 8194) + 2 * output.length + 10) + + steps v (e + 1) (output ++ rowBits v e) count + +theorem suffixTrace {d : Nat} (count : Nat) (p : Fin d) (hp : p.val + count = d) + (v e : Nat) (output : List Bool) (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step (program d)))^[steps v e output count] + (some ⟨some (rowLabel p .relationRead), (ambient, register), fieldTapes v e output⟩) = + some ⟨none, (ambient, none), fieldTapes v (e + count) (output ++ rowsBits v e count)⟩ := by + induction count generalizing p v e output register with + | zero => + have hlt := p.isLt + omega + | succ count ih => + rw [steps, Nat.add_comm (4 * (v + e + 8194) + 2 * output.length + 10), + Function.iterate_add_apply, rowAndBumpTrace] + by_cases hc : count = 0 + · subst count + have hlast : ¬ p.val + 1 < d := by omega + simp [afterPort, hlast, steps, rowsBits] + · have hnext : p.val + 1 < d := by omega + rw [afterPort, dite_eq_left hnext] + have hh := ih ⟨p.val + 1, hnext⟩ (by change (p.val + 1) + count = d; omega) + v (e + 1) (output ++ rowBits v e) none + have he : (e + 1) + count = e + (count + 1) := by omega + simpa only [rowsBits, List.append_assoc, he] using hh + +theorem allTrace (d v e : Nat) (output : List Bool) (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step (program d)))^[steps v e output d + 1] + (some ⟨some (start d), (ambient, register), initialTapes v e output⟩) = + some ⟨none, (ambient, none), fieldTapes v (e + d) (output ++ rowsBits v e d)⟩ := by + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step (program d)))^[steps v e output d] + (TM2.step (program d) ⟨some (start d), (ambient, register), initialTapes v e output⟩) = _ + rw [initializeStep] + by_cases hd : 0 < d + · rw [entry, dite_eq_left hd] + exact suffixTrace d ⟨0, hd⟩ (by simp) v e output ambient none + · have hz : d = 0 := by omega + subst d + simp [entry, steps, rowsBits] + +def graphRows {n m : Nat} (v : Fin n) (e : Nat) : + (count : Nat) → e + count ≤ m → List (DartRow n m) + | 0, _ => [] + | count + 1, h => + ⟨v, ⟨e, by omega⟩, trueRelation⟩ :: + graphRows v (e + 1) count (by omega) + +theorem graphRows_length {n m : Nat} (v : Fin n) (e count : Nat) (h : e + count ≤ m) : + (graphRows v e count h).length = count := by + induction count generalizing e with + | zero => rfl + | succ count ih => simp [graphRows, ih] + +theorem rowsBits_eq_graphRows {n m : Nat} (v : Fin n) (e count : Nat) + (h : e + count ≤ m) : + rowsBits v.val e count = encodeWords ((graphRows v e count h).flatMap rowWords) := by + induction count generalizing e with + | zero => rfl + | succ count ih => + simp [rowsBits, graphRows, encodeWords_append, MachineTableRows.rowBits_eq, + rowBits, trueBits] + exact ih (e + 1) (by omega) + +def dummyRows {n : Nat} (d : Nat) (v : Fin n) : List (DartRow n (n * d)) := + graphRows v (d * v.val) d (by + have h := Nat.mul_le_mul_right d (Nat.succ_le_of_lt v.isLt) + simpa only [Nat.succ_mul, Nat.mul_comm] using h) + +theorem dummyRows_length {n : Nat} (d : Nat) (v : Fin n) : + (dummyRows d v).length = d := graphRows_length _ _ _ _ + +theorem dummyRowsTrace {n : Nat} (d : Nat) (v : Fin n) (output : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step (program d)))^[steps v.val (d * v.val) output d + 1] + (some ⟨some (start d), (ambient, register), initialTapes v.val (d * v.val) output⟩) = + some ⟨none, (ambient, none), fieldTapes v.val (d * v.val + d) + (output ++ encodeWords ((dummyRows d v).flatMap rowWords))⟩ := by + have h := allTrace d v.val (d * v.val) output ambient register + rw [rowsBits_eq_graphRows v (d * v.val) d (by + have h := Nat.mul_le_mul_right d (Nat.succ_le_of_lt v.isLt) + simpa only [Nat.succ_mul, Nat.mul_comm] using h)] at h + exact h + +theorem steps_le_bound (v e : Nat) (output : List Bool) (count : Nat) : + steps v e output count ≤ count * + (4 * (v + e + count + 8194) + + 2 * (output.length + count * (v + e + count + 8194)) + 10) := by + induction count generalizing e output with + | zero => simp [steps] + | succ count ih => + let B := v + e + (count + 1) + 8194 + let C := 4 * B + 2 * (output.length + (count + 1) * B) + 10 + have hb : v + (e + 1) + count + 8194 = B := by dsimp [B]; omega + have hi := ih (e + 1) (output ++ rowBits v e) + rw [List.length_append, rowBits_length, hb] at hi + have hrow : v + e + 8194 ≤ B := by dsimp [B]; omega + have hout : output.length + (v + e + 8194) + count * B ≤ + output.length + (count + 1) * B := by + calc + _ ≤ output.length + B + count * B := + Nat.add_le_add_right (Nat.add_le_add_left hrow output.length) _ + _ = _ := by simp only [Nat.add_mul, Nat.one_mul]; omega + have hconstant : 4 * B + 2 * (output.length + (v + e + 8194) + count * B) + 10 ≤ C := by + exact Nat.add_le_add_right + (Nat.add_le_add_left (Nat.mul_le_mul_left 2 hout) (4 * B)) 10 + have hremaining := hi.trans (Nat.mul_le_mul_left count hconstant) + have hbody : 4 * (v + e + 8194) + 2 * output.length + 10 ≤ C := by + exact Nat.add_le_add_right (Nat.add_le_add (Nat.mul_le_mul_left 4 hrow) + (Nat.mul_le_mul_left 2 (Nat.le_add_right output.length ((count + 1) * B)))) 10 + change (4 * (v + e + 8194) + 2 * output.length + 10) + + steps v (e + 1) (output ++ rowBits v e) count ≤ (count + 1) * C + calc + _ ≤ C + count * C := Nat.add_le_add hbody hremaining + _ = (count + 1) * C := by rw [Nat.add_mul, Nat.one_mul]; omega + +def inputSize (v e : Nat) (output : List Bool) : Nat := + (encodeWord v).length + (encodeWord e).length + output.length + +noncomputable def timePolynomial (d : Nat) : Polynomial Nat := + Polynomial.C d * + (Polynomial.C 4 * (Polynomial.X + Polynomial.C (d + 8192)) + + Polynomial.C 2 * (Polynomial.X + Polynomial.C d * + (Polynomial.X + Polynomial.C (d + 8192))) + Polynomial.C 10) + 1 + +theorem timePolynomial_bounds (d v e : Nat) (output : List Bool) : + steps v e output d + 1 ≤ (timePolynomial d).eval (inputSize v e output) := by + have h := steps_le_bound v e output d + have hB : v + e + d + 8194 ≤ inputSize v e output + d + 8192 := by + simp only [inputSize, encodeWord_length] + omega + have hO : output.length ≤ inputSize v e output := by + simp only [inputSize, encodeWord_length] + omega + have hm := Nat.mul_le_mul_left d hB + have hinner : + 4 * (v + e + d + 8194) + 2 * (output.length + d * (v + e + d + 8194)) + 10 ≤ + 4 * (inputSize v e output + d + 8192) + + 2 * (inputSize v e output + d * (inputSize v e output + d + 8192)) + 10 := by + exact Nat.add_le_add_right (Nat.add_le_add (Nat.mul_le_mul_left 4 hB) + (Nat.mul_le_mul_left 2 (Nat.add_le_add hO hm))) 10 + have htotal := h.trans (Nat.mul_le_mul_left d hinner) + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_one] + simpa only [Nat.add_assoc] using Nat.add_le_add_right htotal 1 + +def machine (d : Nat) : FinTM2 where + K := Fin 6 + k₀ := 0 + k₁ := 4 + Γ _ := Bool + Λ := Label d + main := start d + σ := Unit × Option Bool + initialState := ((), none) + m := program d + +def machineInTime (d v e : Nat) (output : List Bool) (register : Option Bool) : + StateTransition.EvalsToInTime (machine d).step + ⟨some (start d), ((), register), initialTapes v e output⟩ + (some ⟨none, ((), none), fieldTapes v (e + d) (output ++ rowsBits v e d)⟩) + ((timePolynomial d).eval (inputSize v e output)) where + steps := steps v e output d + 1 + evals_in_steps := by + convert allTrace d v e output () register using 1 + rfl + steps_le_m := timePolynomial_bounds d v e output + +def machineDummyInTime {n : Nat} (d : Nat) (v : Fin n) + (output : List Bool) (register : Option Bool) : + StateTransition.EvalsToInTime (machine d).step + ⟨some (start d), ((), register), initialTapes v.val (d * v.val) output⟩ + (some ⟨none, ((), none), fieldTapes v.val (d * v.val + d) + (output ++ encodeWords ((dummyRows d v).flatMap rowWords))⟩) + ((timePolynomial d).eval (inputSize v.val (d * v.val) output)) where + steps := steps v.val (d * v.val) output d + 1 + evals_in_steps := by + convert dummyRowsTrace d v output () register using 1 + rfl + steps_le_m := timePolynomial_bounds d v.val (d * v.val) output + +theorem finalFrame (v e : Nat) (output : List Bool) : + fieldTapes v e output 0 = encodeWord v ∧ + fieldTapes v e output 2 = trueBits ∧ + fieldTapes v e output 3 = [] ∧ fieldTapes v e output 5 = [] := + ⟨rfl, rfl, rfl, rfl⟩ + +end IndependentSetsGames.Foundations.Complexity.MachineDummyRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineEmbedding.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineEmbedding.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5351347ecb4a3cb4ddaeb45184b0ba3a1cb5307 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineEmbedding.lean @@ -0,0 +1,147 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineEmbedding + +open Turing.TM2 + +variable {K E Λ Λextra σ τ : Type} {Γ : K → Type} {Δ : E → Type} + +abbrev Alphabet (Γ : K → Type) (Δ : E → Type) : K ⊕ E → Type + | .inl k => Γ k + | .inr e => Δ e + +def tapes (source : ∀ k, List (Γ k)) (extra : ∀ e, List (Δ e)) : + ∀ j, List (Alphabet Γ Δ j) + | .inl k => source k + | .inr e => extra e + +@[simp] theorem tapes_inl (source : ∀ k, List (Γ k)) (extra : ∀ e, List (Δ e)) + (k : K) : tapes source extra (.inl k) = source k := rfl + +@[simp] theorem tapes_inr (source : ∀ k, List (Γ k)) (extra : ∀ e, List (Δ e)) + (e : E) : tapes source extra (.inr e) = extra e := rfl + +def label (haltTarget : Option (Λ ⊕ Λextra)) : Option Λ → Option (Λ ⊕ Λextra) + | none => haltTarget + | some l => some (.inl l) + +def configuration (haltTarget : Option (Λ ⊕ Λextra)) (extraState : τ) + (extraTapes : ∀ e, List (Δ e)) (c : Cfg Γ Λ σ) : + Cfg (Alphabet Γ Δ) (Λ ⊕ Λextra) (σ × τ) where + l := label haltTarget c.l + var := (c.var, extraState) + stk := tapes c.stk extraTapes + +def statement (haltTarget : Option (Λ ⊕ Λextra)) : + Stmt Γ Λ σ → Stmt (Alphabet Γ Δ) (Λ ⊕ Λextra) (σ × τ) + | .push k f next => .push (.inl k) (fun st => f st.1) (statement haltTarget next) + | .peek k f next => .peek (.inl k) (fun st v => (f st.1 v, st.2)) + (statement haltTarget next) + | .pop k f next => .pop (.inl k) (fun st v => (f st.1 v, st.2)) + (statement haltTarget next) + | .load f next => .load (fun st => (f st.1, st.2)) (statement haltTarget next) + | .branch f yes no => .branch (fun st => f st.1) + (statement haltTarget yes) (statement haltTarget no) + | .goto f => .goto (fun st => .inl (f st.1)) + | .halt => match haltTarget with + | none => .halt + | some l => .goto (fun _ => l) + +variable [DecidableEq K] [DecidableEq E] + +theorem tapes_update (source : ∀ k, List (Γ k)) (extra : ∀ e, List (Δ e)) + (k : K) (value : List (Γ k)) : + tapes (Function.update source k value) extra = + Function.update (tapes source extra) (.inl k) value := by + funext j + cases j with + | inl j => + by_cases h : j = k + · subst j + simp [Function.update] + · simp [Function.update, h] + | inr e => simp [Function.update] + +theorem stepAux_simulation (haltTarget : Option (Λ ⊕ Λextra)) + (extraState : τ) (extraTapes : ∀ e, List (Δ e)) + (q : Stmt Γ Λ σ) (state : σ) (source : ∀ k, List (Γ k)) : + stepAux (statement haltTarget q) (state, extraState) (tapes source extraTapes) = + configuration haltTarget extraState extraTapes (stepAux q state source) := by + induction q generalizing state source with + | push k f next ih => + simp only [statement, stepAux, tapes_inl] + rw [← tapes_update] + exact ih state (Function.update source k (f state :: source k)) + | peek k f next ih => + simpa only [statement, stepAux, tapes_inl] using + ih (f state (source k).head?) source + | pop k f next ih => + simp only [statement, stepAux, tapes_inl] + rw [← tapes_update] + exact ih (f state (source k).head?) (Function.update source k (source k).tail) + | load f next ih => + simpa only [statement, stepAux] using ih (f state) source + | branch f yes no ihYes ihNo => + cases h : f state with + | false => simpa only [statement, stepAux, h, Bool.cond_false] using ihNo state source + | true => simpa only [statement, stepAux, h, Bool.cond_true] using ihYes state source + | goto f => rfl + | halt => cases haltTarget <;> rfl + +theorem stepAux_preserves_extra_state (haltTarget : Option (Λ ⊕ Λextra)) + (extraState : τ) (extraTapes : ∀ e, List (Δ e)) + (q : Stmt Γ Λ σ) (state : σ) (source : ∀ k, List (Γ k)) : + (stepAux (statement haltTarget q) (state, extraState) + (tapes source extraTapes)).var.2 = extraState := by + rw [stepAux_simulation] + rfl + +theorem stepAux_preserves_extra_tape (haltTarget : Option (Λ ⊕ Λextra)) + (extraState : τ) (extraTapes : ∀ e, List (Δ e)) + (q : Stmt Γ Λ σ) (state : σ) (source : ∀ k, List (Γ k)) (e : E) : + (stepAux (statement haltTarget q) (state, extraState) + (tapes source extraTapes)).stk (.inr e) = extraTapes e := by + rw [stepAux_simulation] + rfl + +def program (haltTarget : Option (Λ ⊕ Λextra)) (source : Λ → Stmt Γ Λ σ) + (extra : Λextra → Stmt (Alphabet Γ Δ) (Λ ⊕ Λextra) (σ × τ)) : + Λ ⊕ Λextra → Stmt (Alphabet Γ Δ) (Λ ⊕ Λextra) (σ × τ) + | .inl l => statement haltTarget (source l) + | .inr l => extra l + +theorem step_running (haltTarget : Option (Λ ⊕ Λextra)) + (extraState : τ) (extraTapes : ∀ e, List (Δ e)) + (source : Λ → Stmt Γ Λ σ) + (extra : Λextra → Stmt (Alphabet Γ Δ) (Λ ⊕ Λextra) (σ × τ)) + (l : Λ) (state : σ) (sourceTapes : ∀ k, List (Γ k)) : + step (program haltTarget source extra) + (configuration haltTarget extraState extraTapes ⟨some l, state, sourceTapes⟩) = + some (configuration haltTarget extraState extraTapes + (stepAux (source l) state sourceTapes)) := by + change some (stepAux (statement haltTarget (source l)) (state, extraState) + (tapes sourceTapes extraTapes)) = _ + rw [stepAux_simulation] + +theorem step_simulation (haltTarget : Option (Λ ⊕ Λextra)) + (extraState : τ) (extraTapes : ∀ e, List (Δ e)) + (source : Λ → Stmt Γ Λ σ) + (extra : Λextra → Stmt (Alphabet Γ Δ) (Λ ⊕ Λextra) (σ × τ)) + (a b : Cfg Γ Λ σ) (h : step source a = some b) : + step (program haltTarget source extra) + (configuration haltTarget extraState extraTapes a) = + some (configuration haltTarget extraState extraTapes b) := by + cases a with + | mk l state sourceTapes => + cases l with + | none => simp [step] at h + | some l => + have hb : stepAux (source l) state sourceTapes = b := Option.some.inj h + rw [← hb] + exact step_running haltTarget extraState extraTapes source extra l state sourceTapes + +end IndependentSetsGames.Foundations.Complexity.MachineEmbedding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyAffine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f7c92cdf2b18f7e79aaa2f157fe0d98f0335ac6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyAffine.lean @@ -0,0 +1,160 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyTransfer + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +open Turing MachineComposition +open PCP.ExpanderTables PCP.ExpanderRowControl + +theorem affine_source_ne_scratch (phase : AffinePhase) : + affineSource phase ≠ .inr .unaryScratch := by cases phase <;> decide + +theorem affine_source_ne_destination (phase : AffinePhase) : + affineSource phase ≠ affineDestination phase := by cases phase <;> decide + +theorem affine_scratch_ne_destination (phase : AffinePhase) : + (.inr .unaryScratch : Tape) ≠ affineDestination phase := by cases phase <;> decide + +def affineResultTapes (d : Nat) (phase : AffinePhase) + (base : (tape : Tape) → List (Alphabet tape)) (n : Nat) : + (tape : Tape) → List (Alphabet tape) := + Function.update base (affineDestination phase) + (boolWord (affineDestination phase) + (encodeWord (affineCoefficient d phase * n) ++ toBoolTapes base (affineDestination phase))) + +theorem affineResultTapes_other (d : Nat) (phase : AffinePhase) + (base : (tape : Tape) → List (Alphabet tape)) (n : Nat) (tape : Tape) + (different : tape ≠ affineDestination phase) : + affineResultTapes d phase base n tape = base tape := by + simp [affineResultTapes, different] + +theorem affineResultTapes_source (d : Nat) (phase : AffinePhase) + (base : (tape : Tape) → List (Alphabet tape)) (n : Nat) : + affineResultTapes d phase base n (affineSource phase) = base (affineSource phase) := + affineResultTapes_other d phase base n _ (affine_source_ne_destination phase) + +theorem affineResultTapes_scratch (d : Nat) (phase : AffinePhase) + (base : (tape : Tape) → List (Alphabet tape)) (n : Nat) : + affineResultTapes d phase base n (.inr .unaryScratch) = base (.inr .unaryScratch) := + affineResultTapes_other d phase base n _ (affine_scratch_ne_destination phase) + +theorem affineResultTapes_destination (d : Nat) (phase : AffinePhase) + (base : (tape : Tape) → List (Alphabet tape)) (n : Nat) : + toBoolTapes (affineResultTapes d phase base n) (affineDestination phase) = + encodeWord (affineCoefficient d phase * n) ++ toBoolTapes base (affineDestination phase) := by + simp [affineResultTapes, toBoolTapes] + +variable {ρ : Type} [Fintype ρ] {d : Nat} + +theorem affinePhaseBoolTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (phase : AffinePhase) (base : Tape → List Bool) + (n : Nat) (suffix : List Bool) + (sourceWord : base (affineSource phase) = encodeWord n ++ suffix) + (scratchEmpty : base (.inr .unaryScratch) = []) (state : State ρ d) : + (advance (TM2.step (boolView positive H growth)))^[2 * (n + 1) + 1] + (some ⟨some (.inr (.affine phase .seed)), state, base⟩) = + some ⟨some (affineExit d phase), clearRegister state, + Function.update base (affineDestination phase) + (encodeWord (affineCoefficient d phase * n) ++ base (affineDestination phase))⟩ := by + let states := registerStates ρ d + let target := boolView (ρ := ρ) positive H growth + let sourceProgram := MachineControl.program (Equiv.refl (Label d)) states.symm target + have atSeed : sourceProgram (.inr (.affine phase .seed)) = + MachineUnaryAffineAt.seed (affineDestination phase) 0 (.inr (.affine phase .scan)) := by + change MachineControl.statement id states.symm + (boolView positive H growth (.inr (.affine phase .seed))) = _ + rw [boolView_outer] + exact controlStatementInverse states _ + have atScan : sourceProgram (.inr (.affine phase .scan)) = + MachineUnaryAffineAt.scan (affineSource phase) (.inr .unaryScratch) + (affineDestination phase) (affineCoefficient d phase) + (.inr (.affine phase .scan)) (.inr (.affine phase .restore)) := by + change MachineControl.statement id states.symm + (boolView positive H growth (.inr (.affine phase .scan))) = _ + rw [boolView_outer] + exact controlStatementInverse states _ + have atRestore : sourceProgram (.inr (.affine phase .restore)) = + Reduction.MachineTransfer.loopAt (.inr .unaryScratch) (affineSource phase) id false + (.inr (.affine phase .restore)) (some (affineExit d phase)) := by + change MachineControl.statement id states.symm + (boolView positive H growth (.inr (.affine phase .restore))) = _ + rw [boolView_outer] + exact controlStatementInverse states _ + have raw := MachineUnaryAffineAt.seededAffineTrace + (affineSource phase) (.inr .unaryScratch) (affineDestination phase) + (affine_source_ne_scratch phase) (affine_source_ne_destination phase) + (affine_scratch_ne_destination phase) (affineCoefficient d phase) 0 + (.inr (.affine phase .seed)) (.inr (.affine phase .scan)) (.inr (.affine phase .restore)) + (some (affineExit d phase)) sourceProgram atSeed atScan atRestore base n suffix + sourceWord scratchEmpty (states.symm state).1 (states.symm state).2 + have run := controlTrace states target (2 * (n + 1) + 1) _ _ raw + simpa only [states, target, MachineControl.configuration, Option.map_some, id_eq, Prod.mk.eta, + Equiv.apply_symm_apply, Nat.add_zero, registerStates_reset] using run + +theorem affinePhaseTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (phase : AffinePhase) + (base : (tape : Tape) → List (Alphabet tape)) (n : Nat) (suffix : List Bool) + (sourceWord : toBoolTapes base (affineSource phase) = encodeWord n ++ suffix) + (scratchEmpty : base (.inr .unaryScratch) = []) (state : State ρ d) : + (advance (TM2.step (program positive H growth)))^[2 * (n + 1) + 1] + (some ⟨some (.inr (.affine phase .seed)), state, base⟩) = + some ⟨some (affineExit d phase), clearRegister state, + affineResultTapes d phase base n⟩ := by + have raw := affinePhaseBoolTrace positive H growth phase (toBoolTapes base) n suffix + sourceWord scratchEmpty state + have transported := boolTraceActual positive H growth (2 * (n + 1) + 1) _ _ raw + simpa only [configuration_fromBool, fromBoolTapes_update, fromBool_toBool, + affineResultTapes] using transported + +def affinePhaseInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (phase : AffinePhase) + (base : (tape : Tape) → List (Alphabet tape)) (n : Nat) (suffix : List Bool) + (sourceWord : toBoolTapes base (affineSource phase) = encodeWord n ++ suffix) + (scratchEmpty : base (.inr .unaryScratch) = []) (state : State ρ d) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr (.affine phase .seed)), state, base⟩ + (some ⟨some (affineExit d phase), clearRegister state, + affineResultTapes d phase base n⟩) (2 * (n + 1) + 1) where + steps := 2 * (n + 1) + 1 + evals_in_steps := affinePhaseTrace positive H growth phase base n suffix sourceWord scratchEmpty state + steps_le_m := Nat.le_refl _ + +def copyCountInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : (tape : Tape) → List (Alphabet tape)) + (n : Nat) (sourceWord : base (.inr .currentSize) = encodeWord n) + (scratchEmpty : base (.inr .unaryScratch) = []) + (destinationEmpty : base vertexCountTape = []) (state : State ρ d) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr (.affine .copyCount .seed)), state, base⟩ + (some ⟨some (.inl (.inr .initialize)), clearRegister state, + Function.update base vertexCountTape (encodeWord n)⟩) (2 * (n + 1) + 1) := by + have run := affinePhaseInTime positive H growth .copyCount base n [] + (by simpa only [affineSource, toBoolTapes, toBoolWord, List.append_nil] using sourceWord) + scratchEmpty state + change base (.inl (.inr .vertexCount)) = [] at destinationEmpty + simpa only [affineExit, affineResultTapes, affineDestination, affineCoefficient, + Nat.one_mul, vertexCountTape, boolWord, toBoolTapes, toBoolWord, + destinationEmpty, List.append_nil] using run + +def multiplySizeInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : (tape : Tape) → List (Alphabet tape)) + (n : Nat) (sourceWord : base inputVertexTape = encodeWord n) + (scratchEmpty : base (.inr .unaryScratch) = []) + (destinationEmpty : base (.inr .currentSize) = []) (state : State ρ d) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr (.affine .multiplySize .seed)), state, base⟩ + (some ⟨some (.inr .drainInputVertex), clearRegister state, + Function.update base (.inr .currentSize) (encodeWord (cloudSize d * n))⟩) + (2 * (n + 1) + 1) := by + have run := affinePhaseInTime positive H growth .multiplySize base n [] + (by simpa only [affineSource, inputVertexTape, toBoolTapes, toBoolWord, + List.append_nil] using sourceWord) + scratchEmpty state + simpa only [affineExit, affineResultTapes, affineDestination, affineCoefficient, + boolWord, toBoolTapes, toBoolWord, destinationEmpty, List.append_nil] using run + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyBounds.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fcdf1e9e3e3ec95bfd0e0663fabddc4e4e7890b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyBounds.lean @@ -0,0 +1,194 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingLevels +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderTable + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamilyBounds + +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords + +noncomputable def resizeCost {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) : Nat := + (MachineExpanderTable.timePolynomial d).eval (MachineExpanderTable.oldTableWord G).length + + 6 * v + (MachineExpanderTable.oldTableWord G).length + + 2 * (encodeWords (rotationWords (step G H))).length + 15 + +def resizeCoefficient (d : Nat) : Nat := + MachineExpanderTable.timeCoefficient d * (degree d + 1) ^ 4 + + 3 * (degree d + 1) ^ 2 + 21 + +theorem wordLength_add_one_le {v q N : Nat} (G : Table v q) (hv : v ≤ N) : + (encodeWords (rotationWords G)).length + 1 ≤ (q + 1)^2 * (N + 1)^2 := by + have hlength := encode_rotationWords_length_le G + have hrow : v * q + 1 ≤ (q + 1) * (N + 1) := by + have h := Nat.mul_le_mul_right q hv + nlinarith + calc + _ ≤ (v * q + 1)^2 := by nlinarith + _ ≤ ((q + 1) * (N + 1))^2 := Nat.pow_le_pow_left hrow 2 + _ = _ := by ring + +theorem resizeCost_le {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) (N : Nat) (hv : v ≤ N) + (hnext : v * cloudSize d ≤ N) : + resizeCost G H ≤ resizeCoefficient d * (N + 1)^4 := by + let oldL := (MachineExpanderTable.oldTableWord G).length + let newL := (encodeWords (rotationWords (step G H))).length + have oldBound : oldL + 1 ≤ (degree d + 1)^2 * (N + 1)^2 := + wordLength_add_one_le G hv + have newBound : newL + 1 ≤ (degree d + 1)^2 * (N + 1)^2 := + wordLength_add_one_le (step G H) hnext + have timeBound : (MachineExpanderTable.timePolynomial d).eval oldL ≤ + MachineExpanderTable.timeCoefficient d * (degree d + 1)^4 * (N + 1)^4 := by + simp only [MachineExpanderTable.timePolynomial, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_add, + Polynomial.eval_X, Polynomial.eval_one] + calc + _ ≤ MachineExpanderTable.timeCoefficient d * + ((degree d + 1)^2 * (N + 1)^2)^2 := + Nat.mul_le_mul_left _ (Nat.pow_le_pow_left oldBound 2) + _ = _ := by ring + have pow24 : (N + 1)^2 ≤ (N + 1)^4 := + Nat.pow_le_pow_right (Nat.succ_pos N) (by decide) + have overheadBound : oldL + 2 * newL ≤ + 3 * (degree d + 1)^2 * (N + 1)^4 := by + have h := Nat.mul_le_mul_left ((degree d + 1)^2) pow24 + calc + _ ≤ 3 * ((degree d + 1)^2 * (N + 1)^2) := by omega + _ ≤ 3 * ((degree d + 1)^2 * (N + 1)^4) := Nat.mul_le_mul_left 3 h + _ = _ := by ring + have npow : N + 1 ≤ (N + 1)^4 := by + simpa only [pow_one] using + Nat.pow_le_pow_right (Nat.succ_pos N) (show 1 ≤ 4 by decide) + have linearBound : 6 * v + 15 ≤ 21 * (N + 1)^4 := by omega + change (MachineExpanderTable.timePolynomial d).eval oldL + 6 * v + oldL + + 2 * newL + 15 ≤ _ + unfold resizeCoefficient + nlinarith only [timeBound, overheadBound, linearBound] + +theorem vertexCount_monotone {q : Nat} (positive : 0 < q) : + Monotone (vertexCount q) := by + intro m n hmn + rw [vertexCount_eq, vertexCount_eq] + exact Nat.pow_le_pow_right (Nat.mul_pos positive positive) hmn + +theorem level_le_vertexCount {q : Nat} (growth : 1 < q * q) (level : Nat) : + level ≤ vertexCount q level := by + have positive : 0 < q := by nlinarith + induction level with + | zero => exact Nat.zero_le _ + | succ level ih => + have hpos := vertexCount_positive positive level + have hmul := Nat.mul_le_mul_left (vertexCount q level) + (show 2 ≤ q * q by omega) + change level + 1 ≤ vertexCount q level * (q * q) + nlinarith + +noncomputable def resizeSum {d : Nat} (H : Table (cloudSize d) d) (level : Nat) : Nat := + ∑ i ∈ Finset.range level, resizeCost (family H i) H + +@[simp] theorem resizeSum_zero {d : Nat} (H : Table (cloudSize d) d) : + resizeSum H 0 = 0 := by simp [resizeSum] + +theorem resizeSum_succ {d : Nat} (H : Table (cloudSize d) d) (level : Nat) : + resizeSum H (level + 1) = resizeSum H level + resizeCost (family H level) H := by + simp only [resizeSum, Finset.sum_range_succ] + +theorem resizeSum_add {d : Nat} (H : Table (cloudSize d) d) (start count : Nat) : + resizeSum H (start + count) = resizeSum H start + + ∑ i ∈ Finset.range count, resizeCost (family H (start + i)) H := + Finset.sum_range_add (fun i => resizeCost (family H i) H) start count + +noncomputable def familyBudget {d : Nat} (H : Table (cloudSize d) d) (level : Nat) : Nat := + resizeSum H level + level + 3 + +@[simp] theorem familyBudget_zero {d : Nat} (H : Table (cloudSize d) d) : + familyBudget H 0 = 3 := by simp [familyBudget] + +theorem familyBudget_succ {d : Nat} (H : Table (cloudSize d) d) (level : Nat) : + familyBudget H (level + 1) = + familyBudget H level + resizeCost (family H level) H + 1 := by + simp only [familyBudget, resizeSum_succ] + omega + +theorem resizeSum_le {d : Nat} (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (level : Nat) : + resizeSum H level ≤ resizeCoefficient d * (vertexCount (degree d) level + 1)^5 := by + let N := vertexCount (degree d) level + have positive : 0 < degree d := by + have h : 1 < degree d * degree d := growth + nlinarith + have hmono := vertexCount_monotone positive + have hlevel : level ≤ N := level_le_vertexCount growth level + have eachBound : ∀ i ∈ Finset.range level, + resizeCost (family H i) H ≤ resizeCoefficient d * (N + 1)^4 := by + intro i hi + have hi' : i < level := Finset.mem_range.mp hi + apply resizeCost_le (family H i) H N + · exact hmono (by omega) + · exact hmono (show i + 1 ≤ level by omega) + have sumBound : resizeSum H level ≤ level * (resizeCoefficient d * (N + 1)^4) := by + calc + _ ≤ ∑ _i ∈ Finset.range level, resizeCoefficient d * (N + 1)^4 := + Finset.sum_le_sum eachBound + _ = _ := by simp + calc + _ ≤ level * (resizeCoefficient d * (N + 1)^4) := sumBound + _ ≤ (N + 1) * (resizeCoefficient d * (N + 1)^4) := + Nat.mul_le_mul_right _ (hlevel.trans (Nat.le_succ N)) + _ = _ := by ring + +theorem familyBudget_le {d : Nat} (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (level : Nat) : + familyBudget H level ≤ + (resizeCoefficient d + 4) * (vertexCount (degree d) level + 1)^5 := by + have hsum := resizeSum_le H growth level + have hlevel := level_le_vertexCount growth level + have hpow : vertexCount (degree d) level + 1 ≤ + (vertexCount (degree d) level + 1)^5 := by + simpa only [pow_one] using Nat.pow_le_pow_right + (Nat.succ_pos (vertexCount (degree d) level)) (show 1 ≤ 5 by decide) + have overhead : level + 3 ≤ 4 * (vertexCount (degree d) level + 1)^5 := by omega + unfold familyBudget + nlinarith only [hsum, overhead] + +theorem paddedSize_le_succ_input (k : Nat) : + PCP.PreprocessingLevels.paddedSize k ≤ PCP.ExpanderFamily.growth * (k + 1) := by + by_cases hk : k = 0 + · subst k + have h := PCP.ExpanderFamily.growth_gt_one + simp only [PCP.PreprocessingLevels.paddedSize_zero, Nat.zero_add, Nat.mul_one] + omega + · exact (PCP.PreprocessingLevels.paddedSize_bounds (Nat.pos_of_ne_zero hk)).2.trans + (Nat.mul_le_mul_left _ (Nat.le_succ k)) + +def inputCoefficient : Nat := + (resizeCoefficient PCP.Expanders.baseDegree + 4) * (PCP.ExpanderFamily.growth + 1)^5 + +theorem familyBudget_at_boundedLevel_le + (H : Table (cloudSize PCP.Expanders.baseDegree) PCP.Expanders.baseDegree) (k : Nat) : + familyBudget H (PCP.PreprocessingLevels.boundedLevel k) ≤ inputCoefficient * (k + 1)^5 := by + have hg : cloudSize PCP.Expanders.baseDegree = PCP.ExpanderFamily.growth := by + unfold cloudSize degree PCP.ExpanderFamily.growth + ring + have growth : 1 < cloudSize PCP.Expanders.baseDegree := by + rw [hg] + exact PCP.ExpanderFamily.growth_gt_one + have bound := familyBudget_le H growth (PCP.PreprocessingLevels.boundedLevel k) + rw [PCP.PreprocessingLevels.table_vertexCount_eq_paddedSize] at bound + have sizeBound : PCP.PreprocessingLevels.paddedSize k + 1 ≤ + (PCP.ExpanderFamily.growth + 1) * (k + 1) := by + have h := paddedSize_le_succ_input k + nlinarith + calc + _ ≤ (resizeCoefficient PCP.Expanders.baseDegree + 4) * + (PCP.PreprocessingLevels.paddedSize k + 1)^5 := bound + _ ≤ (resizeCoefficient PCP.Expanders.baseDegree + 4) * + ((PCP.ExpanderFamily.growth + 1) * (k + 1))^5 := + Nat.mul_le_mul_left _ (Nat.pow_le_pow_left sizeBound 5) + _ = _ := by unfold inputCoefficient; ring + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamilyBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyCycle.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyCycle.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbc3b99e4892fe656b0700ae7a606e7f7506fb5a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyCycle.lean @@ -0,0 +1,309 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyAffine +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyBounds + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +section + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords +open MachineExpanderFamilyBounds + +theorem installed_returnFrame (remaining current : Nat) (oldWord newWord suffix : List Bool) : + fromBoolTapes (installedTapes (toBoolTapes (returnFrame remaining current oldWord newWord suffix)) + newWord) = installedFrame remaining current newWord suffix := by + rw [returnFrame_eq_cycleTapes, toBool_cycleTapes] + funext tape + rcases tape with tape | tape + · rcases tape with row | extra + · cases row <;> rfl + · cases extra <;> rfl + · cases tape <;> rfl + +theorem cleaned_multipliedFrame (d remaining current : Nat) (newWord suffix : List Bool) : + fromBoolTapes (cleanedCounterTapes + (toBoolTapes (multipliedFrame d remaining current newWord suffix))) = + boundaryTapes remaining (current * cloudSize d) newWord suffix := by + rw [boundaryTapes_eq_cycleTapes] + unfold multipliedFrame + rw [toBool_cycleTapes] + have multiply : cloudSize d * current = current * cloudSize d := Nat.mul_comm _ _ + rw [multiply] + funext tape + rcases tape with tape | tape + · rcases tape with row | extra + · cases row <;> rfl + · cases extra <;> rfl + · cases tape <;> rfl + +structure ResizeRun {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (G : Table v (degree d)) (remaining : Nat) (state : State ρ d) (suffix : List Bool) where + finalState : State ρ d + caller_preserved : caller finalState = caller state + execution : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr (.affine .copyCount .seed)), state, + boundaryTapes remaining v (MachineExpanderTable.oldTableWord G) suffix⟩ + (some ⟨some (.inr .levelGuard), finalState, + boundaryTapes remaining (v * cloudSize d) + (encodeWords (rotationWords (step G H))) suffix⟩) + (resizeCost G H) + +noncomputable def resizeInTime {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (G : Table v (degree d)) (remaining : Nat) (state : State ρ d) (suffix : List Bool) : + ResizeRun positive H growth G remaining state suffix := by + let oldWord := MachineExpanderTable.oldTableWord G + let newWord := encodeWords (rotationWords (step G H)) + have copy := copyCountInTime positive H growth + (boundaryTapes remaining v oldWord suffix) v rfl rfl rfl state + rw [copyFrame_eq_update] at copy + let called := MachineExpanderTable.tableInTime positive G H (clearRegister state).1 [] + let returned : State ρ d := (called.finalState, ()) + have eta : ((clearRegister state).1, ()) = clearRegister state := by + rcases state with ⟨state, extra⟩ + cases extra + rfl + have call : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inl (.inr .initialize)), clearRegister state, + copyFrame remaining v oldWord suffix⟩ + (some ⟨some (.inr .clearOldTable), returned, + returnFrame remaining v oldWord newWord suffix⟩) + ((MachineExpanderTable.timePolynomial d).eval oldWord.length) := by + simpa only [MachineEmbedding.configuration, MachineEmbedding.label, tableReturn, eta, + copyFrame, returnFrame, oldWord, newWord, returned] using + tableExecution positive H growth (extraFrame remaining v suffix) called.execution + have install := installTableInTime positive H growth + (returnFrame remaining v oldWord newWord suffix) newWord + (by rw [returnFrame_eq_cycleTapes, toBool_cycleTapes]; rfl) + (by rw [returnFrame_eq_cycleTapes, toBool_cycleTapes]; rfl) returned + rw [installed_returnFrame] at install + have installRun : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .clearOldTable), returned, returnFrame remaining v oldWord newWord suffix⟩ + (some ⟨some (.inr (.affine .multiplySize .seed)), clearRegister returned, + installedFrame remaining v newWord suffix⟩) + (oldWord.length + 2 * newWord.length + (v + 1) + 4) := by + simpa only [returnFrame_eq_cycleTapes, toBool_cycleTapes, cycleWords, tableTape, + encodeWord_length] using install + have multiply := multiplySizeInTime positive H growth + (installedFrame remaining v newWord suffix) v rfl rfl rfl (clearRegister returned) + rw [clearRegister_idempotent, multipliedFrame_eq_update] at multiply + have clean := cleanupCountersInTime positive H growth + (multipliedFrame d remaining v newWord suffix) (clearRegister returned) + rw [clearRegister_idempotent, cleaned_multipliedFrame] at clean + have cleanRun : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .drainInputVertex), clearRegister returned, + multipliedFrame d remaining v newWord suffix⟩ + (some ⟨some (.inr .levelGuard), clearRegister returned, + boundaryTapes remaining (v * cloudSize d) newWord suffix⟩) (v + 4) := by + simpa only [multipliedFrame, toBool_cycleTapes, cycleWords, inputVertexTape, + vertexCountTape, encodeWord_length, Nat.zero_add, Nat.add_assoc] using clean + let a := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ copy call + let b := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ a installRun + let c := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ b multiply + let all := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ c cleanRun + refine ⟨clearRegister returned, ?_, ?_⟩ + · exact (caller_clearRegister returned).trans + (called.caller_preserved.trans (caller_clearRegister state)) + · refine { toEvalsTo := all.toEvalsTo, steps_le_m := ?_ } + have bound := all.steps_le_m + unfold resizeCost + change _ ≤ (MachineExpanderTable.timePolynomial d).eval oldWord.length + + 6 * v + oldWord.length + 2 * newWord.length + 15 + omega + +end + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl + +variable {ρ : Type} {d : Nat} + +@[simp] theorem caller_initialState (positive : 0 < d) (H : Table (cloudSize d) d) + (ambient : ρ) : caller (initialState positive H ambient) = ambient := rfl + +@[simp] theorem caller_normalizeState (positive : 0 < d) (H : Table (cloudSize d) d) + (state : State ρ d) : caller (normalizeState positive H state) = caller state := rfl + +@[simp] theorem clearRegister_initialState (positive : 0 < d) + (H : Table (cloudSize d) d) (ambient : ρ) : + clearRegister (initialState positive H ambient) = initialState positive H ambient := rfl + +theorem boundaryTapes_update_level (remaining current next : Nat) + (word suffix : List Bool) : + Function.update (boundaryTapes remaining current word suffix) + (.inr .remainingLevel) (encodeWord next ++ suffix) = + boundaryTapes next current word suffix := by + funext tape + rcases tape with tape | extra + · rcases tape with row | extra + · cases row <;> simp [boundaryTapes, tableFrame, MachineEmbedding.tapes, Function.update] + · cases extra <;> simp [boundaryTapes, tableFrame, MachineEmbedding.tapes, Function.update] + · cases extra <;> simp [boundaryTapes, extraFrame, MachineEmbedding.tapes, Function.update] + +theorem initialTapes_initialize (level : Nat) (suffix : List Bool) : + Function.update + (Function.update (initialTapes level suffix) tableTape (initialEncoding d)) + (.inr .currentSize) (encodeWord 1) = + boundaryTapes level 1 (initialEncoding d) suffix := by + funext tape + rcases tape with tape | extra + · rcases tape with row | extra + · cases row <;> simp [initialTapes, boundaryTapes, tableFrame, + MachineEmbedding.tapes, Function.update, tableTape] + · cases extra <;> simp [initialTapes, boundaryTapes, tableFrame, + MachineEmbedding.tapes, Function.update, tableTape] + · cases extra <;> simp [initialTapes, boundaryTapes, extraFrame, + MachineEmbedding.tapes, Function.update, tableTape] + +variable [Fintype ρ] + +theorem actualStep_of_boolStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) + (start finish : TM2.Cfg BoolAlphabet (Label d) (State ρ d)) + (run : TM2.step (boolView positive H growth) start = some finish) : + TM2.step (program positive H growth) + (MachineAlphabetTransport.configuration alphabet_eq.symm start) = + some (MachineAlphabetTransport.configuration alphabet_eq.symm finish) := by + have h := MachineAlphabetTransport.step_simulation alphabet_eq.symm + (boolView positive H growth) start + rw [run] at h + simpa only [boolView, MachineAlphabetTransport.program_symm_roundtrip, + Option.map_some] using h + +theorem bool_initializeStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : Tape → List Bool) (state : State ρ d) : + TM2.step (boolView positive H growth) ⟨some (.inr .initialize), state, base⟩ = + some ⟨some (.inr .levelGuard), normalizeState positive H state, + Function.update + (Function.update base tableTape (initialEncoding d ++ base (.inl (.inl .table)))) + (.inr .currentSize) (encodeWord 1 ++ base (.inr .currentSize))⟩ := by + change some (TM2.stepAux (boolView positive H growth (.inr .initialize)) state base) = _ + rw [boolView_outer] + simp only [boolOuterStatement, Reduction.MachineSubstitution.stepAux_pushWord, + List.reverse_reverse, TM2.stepAux] + rfl + +theorem bool_levelGuard_succStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : Tape → List Bool) (state : State ρ d) + (remaining : Nat) (suffix : List Bool) + (counter : base (.inr .remainingLevel) = encodeWord (remaining + 1) ++ suffix) : + TM2.step (boolView positive H growth) ⟨some (.inr .levelGuard), state, base⟩ = + some ⟨some (.inr (.affine .copyCount .seed)), clearRegister state, + Function.update base (.inr .remainingLevel) (encodeWord remaining ++ suffix)⟩ := by + change some (TM2.stepAux (boolView positive H growth (.inr .levelGuard)) state base) = _ + rw [boolView_outer] + simp [boolOuterStatement, MachineControl.statement, MachineUnaryCounter.guard, + TM2.stepAux, registerStates, clearRegister, MachineExpanderTable.clearRegister, + counter, encodeWord, List.replicate_succ] + +theorem bool_levelGuard_zeroStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : Tape → List Bool) (state : State ρ d) + (suffix : List Bool) + (counter : base (.inr .remainingLevel) = encodeWord 0 ++ suffix) : + TM2.step (boolView positive H growth) ⟨some (.inr .levelGuard), state, base⟩ = + some ⟨some (.inr .done), clearRegister state, base⟩ := by + change some (TM2.stepAux (boolView positive H growth (.inr .levelGuard)) state base) = _ + rw [boolView_outer] + simp [boolOuterStatement, MachineControl.statement, MachineUnaryCounter.guard, + TM2.stepAux, registerStates, clearRegister, MachineExpanderTable.clearRegister, + counter, encodeWord] + +theorem bool_doneStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : Tape → List Bool) (state : State ρ d) : + TM2.step (boolView positive H growth) ⟨some (.inr .done), state, base⟩ = + some ⟨none, normalizeState positive H state, base⟩ := by + change some (TM2.stepAux (boolView positive H growth (.inr .done)) state base) = _ + rw [boolView_outer] + rfl + +theorem initializeStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) : + TM2.step (program positive H growth) ⟨some (.inr .initialize), state, base⟩ = + some ⟨some (.inr .levelGuard), normalizeState positive H state, + Function.update + (Function.update base tableTape (initialEncoding d ++ base (.inl (.inl .table)))) + (.inr .currentSize) (encodeWord 1 ++ base (.inr .currentSize))⟩ := by + have h := actualStep_of_boolStep positive H growth _ _ + (bool_initializeStep positive H growth (toBoolTapes base) state) + simp only [configuration_fromBool, fromBoolTapes_update, fromBool_toBool] at h + exact h + +theorem levelGuard_succStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (remaining : Nat) (suffix : List Bool) + (counter : base (.inr .remainingLevel) = encodeWord (remaining + 1) ++ suffix) : + TM2.step (program positive H growth) ⟨some (.inr .levelGuard), state, base⟩ = + some ⟨some (.inr (.affine .copyCount .seed)), clearRegister state, + Function.update base (.inr .remainingLevel) (encodeWord remaining ++ suffix)⟩ := by + have h := actualStep_of_boolStep positive H growth _ _ + (bool_levelGuard_succStep positive H growth (toBoolTapes base) state + remaining suffix counter) + simpa only [configuration_fromBool, fromBoolTapes_update, fromBool_toBool, + boolWord] using h + +theorem levelGuard_zeroStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (suffix : List Bool) + (counter : base (.inr .remainingLevel) = encodeWord 0 ++ suffix) : + TM2.step (program positive H growth) ⟨some (.inr .levelGuard), state, base⟩ = + some ⟨some (.inr .done), clearRegister state, base⟩ := by + have h := actualStep_of_boolStep positive H growth _ _ + (bool_levelGuard_zeroStep positive H growth (toBoolTapes base) state suffix counter) + simpa only [configuration_fromBool, fromBool_toBool] using h + +theorem doneStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) : + TM2.step (program positive H growth) ⟨some (.inr .done), state, base⟩ = + some ⟨none, normalizeState positive H state, base⟩ := by + have h := actualStep_of_boolStep positive H growth _ _ + (bool_doneStep positive H growth (toBoolTapes base) state) + simpa only [configuration_fromBool, fromBool_toBool] using h + +theorem initialize_boundaryStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (level : Nat) (suffix : List Bool) (state : State ρ d) : + TM2.step (program positive H growth) + ⟨some (.inr .initialize), state, initialTapes level suffix⟩ = + some ⟨some (.inr .levelGuard), initialState positive H (caller state), + boundaryTapes level 1 (initialEncoding d) suffix⟩ := by + have h := initializeStep positive H growth (initialTapes level suffix) state + have ht : initialTapes level suffix (.inl (.inl .table)) = [] := rfl + have hc : initialTapes level suffix (.inr .currentSize) = [] := rfl + simp only [ht, hc, List.append_nil, normalizeState] at h + exact h.trans (congrArg + (fun tapes : ∀ tape, List (Alphabet tape) => + (some ⟨some (.inr .levelGuard), initialState positive H (caller state), tapes⟩ : + Option (TM2.Cfg Alphabet (Label d) (State ρ d)))) + (initialTapes_initialize level suffix)) + +theorem levelGuard_boundary_succStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (remaining current : Nat) + (word suffix : List Bool) (state : State ρ d) : + TM2.step (program positive H growth) + ⟨some (.inr .levelGuard), state, boundaryTapes (remaining + 1) current word suffix⟩ = + some ⟨some (.inr (.affine .copyCount .seed)), clearRegister state, + boundaryTapes remaining current word suffix⟩ := by + simpa only [boundaryTapes_update_level] using + levelGuard_succStep positive H growth + (boundaryTapes (remaining + 1) current word suffix) state remaining suffix rfl + +theorem levelGuard_boundary_zeroStep (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (current : Nat) + (word suffix : List Bool) (state : State ρ d) : + TM2.step (program positive H growth) + ⟨some (.inr .levelGuard), state, boundaryTapes 0 current word suffix⟩ = + some ⟨some (.inr .done), clearRegister state, + boundaryTapes 0 current word suffix⟩ := + levelGuard_zeroStep positive H growth + (boundaryTapes 0 current word suffix) state suffix rfl + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyLoop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..b31b7c3adbdcb40b75e8b3fb316b4170c847dece --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyLoop.lean @@ -0,0 +1,182 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyCycle + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords +open MachineExpanderFamilyBounds + +noncomputable def levelLoopCost {d : Nat} (H : Table (cloudSize d) d) : Nat → Nat → Nat + | _, 0 => 1 + | start, remaining + 1 => 1 + resizeCost (family H start) H + + levelLoopCost H (start + 1) remaining + +theorem levelLoopCost_prefix {d : Nat} (H : Table (cloudSize d) d) (start remaining : Nat) : + levelLoopCost H start remaining + resizeSum H start = + resizeSum H (start + remaining) + remaining + 1 := by + induction remaining generalizing start with + | zero => simp [levelLoopCost, Nat.add_comm] + | succ remaining ih => + have h := ih (start + 1) + rw [resizeSum_succ] at h + have index : start + 1 + remaining = start + (remaining + 1) := by omega + rw [index] at h + simp only [levelLoopCost] + omega + +theorem levelLoopCost_zero_start {d : Nat} (H : Table (cloudSize d) d) (remaining : Nat) : + levelLoopCost H 0 remaining = resizeSum H remaining + remaining + 1 := by + simpa only [resizeSum_zero, Nat.add_zero, Nat.zero_add] using + levelLoopCost_prefix H 0 remaining + +def levelLoopTapes {d : Nat} (H : Table (cloudSize d) d) + (completed remaining : Nat) (suffix : List Bool) : ∀ tape, List (Alphabet tape) := + boundaryTapes remaining (vertexCount (degree d) completed) + (encodeWords (rotationWords (family H completed))) suffix + +structure LevelLoopRun {d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (completed remaining : Nat) (state : State ρ d) (suffix : List Bool) where + finalState : State ρ d + caller_preserved : caller finalState = caller state + execution : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .levelGuard), state, levelLoopTapes H completed remaining suffix⟩ + (some ⟨some (.inr .done), finalState, familyTapes H (completed + remaining) suffix⟩) + (levelLoopCost H completed remaining) + +private def familySingleStep {S : Type*} (f : S → Option S) (a b : S) + (h : f a = some b) : StateTransition.EvalsToInTime f a (some b) 1 where + steps := 1 + evals_in_steps := by change f a = some b; exact h + steps_le_m := Nat.le_refl _ + +noncomputable def levelLoopInTime {d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (completed remaining : Nat) (state : State ρ d) (suffix : List Bool) : + LevelLoopRun positive H growth completed remaining state suffix := by + induction remaining generalizing completed state with + | zero => + refine ⟨clearRegister state, caller_clearRegister state, ?_⟩ + simpa only [levelLoopCost, levelLoopTapes, familyTapes, Nat.add_zero] using + familySingleStep _ _ _ (levelGuard_boundary_zeroStep positive H growth + (vertexCount (degree d) completed) (encodeWords (rotationWords (family H completed))) + suffix state) + | succ remaining ih => + let cycle := resizeInTime positive H growth (family H completed) remaining + (clearRegister state) suffix + let rest := ih (completed + 1) cycle.finalState + let guard := familySingleStep _ _ _ (levelGuard_boundary_succStep positive H growth + remaining (vertexCount (degree d) completed) + (encodeWords (rotationWords (family H completed))) suffix state) + have cycleRun : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr (.affine .copyCount .seed)), clearRegister state, + levelLoopTapes H completed remaining suffix⟩ + (some ⟨some (.inr .levelGuard), cycle.finalState, + levelLoopTapes H (completed + 1) remaining suffix⟩) + (resizeCost (family H completed) H) := cycle.execution + let first := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ guard cycleRun + let all := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ first rest.execution + have index : completed + 1 + remaining = completed + (remaining + 1) := by omega + refine ⟨rest.finalState, ?_, ?_⟩ + · exact rest.caller_preserved.trans + (cycle.caller_preserved.trans (caller_clearRegister state)) + · rw [index] at all + refine { toEvalsTo := all.toEvalsTo, steps_le_m := ?_ } + have bound := all.steps_le_m + simp only [levelLoopCost] + omega + +private def singleFamilyStep {S : Type*} (f : S → Option S) (a b : S) + (h : f a = some b) : StateTransition.EvalsToInTime f a (some b) 1 where + steps := 1 + evals_in_steps := by change f a = some b; exact h + steps_le_m := Nat.le_refl _ + +noncomputable def familyInTime {d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (level : Nat) (state : State ρ d) (suffix : List Bool) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .initialize), state, initialTapes level suffix⟩ + (some ⟨none, initialState positive H (caller state), familyTapes H level suffix⟩) + (familyBudget H level) := by + let loop := levelLoopInTime positive H growth 0 level + (initialState positive H (caller state)) suffix + have initialRun : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .initialize), state, initialTapes level suffix⟩ + (some ⟨some (.inr .levelGuard), initialState positive H (caller state), + levelLoopTapes H 0 level suffix⟩) 1 := + singleFamilyStep _ _ _ (initialize_boundaryStep positive H growth level suffix state) + have finalCaller : caller loop.finalState = caller state := loop.caller_preserved + have done : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .done), loop.finalState, familyTapes H level suffix⟩ + (some ⟨none, initialState positive H (caller state), familyTapes H level suffix⟩) 1 := by + simpa only [normalizeState, finalCaller] using + singleFamilyStep _ _ _ (doneStep positive H growth (familyTapes H level suffix) + loop.finalState) + have loopRun : StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .levelGuard), initialState positive H (caller state), + levelLoopTapes H 0 level suffix⟩ + (some ⟨some (.inr .done), loop.finalState, familyTapes H level suffix⟩) + (levelLoopCost H 0 level) := by simpa only [Nat.zero_add] using loop.execution + let first := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ initialRun loopRun + let all := StateTransition.EvalsToInTime.trans (TM2.step (program positive H growth)) + _ _ _ _ _ first done + refine { toEvalsTo := all.toEvalsTo, steps_le_m := ?_ } + have bound := all.steps_le_m + have costEquality := levelLoopCost_zero_start H level + unfold familyBudget + omega + +noncomputable def familyInOutputSizeTime {d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (level : Nat) (state : State ρ d) (suffix : List Bool) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .initialize), state, initialTapes level suffix⟩ + (some ⟨none, initialState positive H (caller state), familyTapes H level suffix⟩) + ((resizeCoefficient d + 4) * (vertexCount (degree d) level + 1)^5) where + toEvalsTo := (familyInTime positive H growth level state suffix).toEvalsTo + steps_le_m := (familyInTime positive H growth level state suffix).steps_le_m.trans + (familyBudget_le H growth level) + +theorem baseDegree_cloud_growth : + cloudSize PCP.Expanders.baseDegree = PCP.ExpanderFamily.growth := by + unfold cloudSize degree PCP.ExpanderFamily.growth + ring + +theorem baseDegree_cloud_gt_one : 1 < cloudSize PCP.Expanders.baseDegree := by + rw [baseDegree_cloud_growth] + exact PCP.ExpanderFamily.growth_gt_one + +theorem baseDegree_positive : 0 < PCP.Expanders.baseDegree := by + have h := baseDegree_cloud_gt_one + unfold cloudSize degree at h + by_contra hn + have hz : PCP.Expanders.baseDegree = 0 := by omega + rw [hz] at h + norm_num at h + +noncomputable def paddedFamilyInTime {ρ : Type} [Fintype ρ] + (H : Table (cloudSize PCP.Expanders.baseDegree) PCP.Expanders.baseDegree) + (requested : Nat) (state : State ρ PCP.Expanders.baseDegree) (suffix : List Bool) : + StateTransition.EvalsToInTime + (TM2.step (program baseDegree_positive H baseDegree_cloud_gt_one)) + ⟨some (.inr .initialize), state, + initialTapes (PCP.PreprocessingLevels.boundedLevel requested) suffix⟩ + (some ⟨none, initialState baseDegree_positive H (caller state), + familyTapes H (PCP.PreprocessingLevels.boundedLevel requested) suffix⟩) + (inputCoefficient * (requested + 1)^5) where + toEvalsTo := (familyInTime baseDegree_positive H baseDegree_cloud_gt_one + (PCP.PreprocessingLevels.boundedLevel requested) state suffix).toEvalsTo + steps_le_m := (familyInTime baseDegree_positive H baseDegree_cloud_gt_one + (PCP.PreprocessingLevels.boundedLevel requested) state suffix).steps_le_m.trans + (familyBudget_at_boundedLevel_le H requested) + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyProgram.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..5315dc83a45047240cf4ae26617dcf25cff75afa --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyProgram.lean @@ -0,0 +1,257 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAffine +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableWords +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderTableProgram +import OAI.Combinatorics.IndependentSets.Machines.MachineAlphabetTransport + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords + +inductive ExtraTape + | remainingLevel | currentSize | unaryScratch | tableReverse + deriving DecidableEq + +instance : Fintype ExtraTape where + elems := {.remainingLevel, .currentSize, .unaryScratch, .tableReverse} + complete tape := by cases tape <;> simp + +abbrev Tape := MachineExpanderTable.Tape ⊕ ExtraTape +abbrev Alphabet : Tape → Type := + MachineEmbedding.Alphabet MachineExpanderTable.Alphabet (fun _ : ExtraTape => Bool) +abbrev BoolAlphabet (_ : Tape) := Bool + +theorem alphabet_eq : Alphabet = BoolAlphabet := by + funext tape + cases tape with + | inl tape => cases tape <;> rfl + | inr tape => rfl + +instance alphabetFintype (tape : Tape) : Fintype (Alphabet tape) := by + rw [alphabet_eq] + exact inferInstanceAs (Fintype Bool) + +inductive AffinePhase + | copyCount | multiplySize + deriving DecidableEq + +instance : Fintype AffinePhase where + elems := {.copyCount, .multiplySize} + complete phase := by cases phase <;> simp + +inductive AffineLabel + | seed | scan | restore + deriving DecidableEq + +instance : Fintype AffineLabel where + elems := {.seed, .scan, .restore} + complete label := by cases label <;> simp + +inductive OuterLabel + | initialize + | levelGuard + | affine (phase : AffinePhase) (label : AffineLabel) + | clearOldTable | reverseResult | reverseTable | clearCurrentSize + | drainInputVertex | drainVertexCount | done + deriving DecidableEq, Fintype + +abbrev Label (d : Nat) := MachineExpanderTable.Label d ⊕ OuterLabel +abbrev State (ρ : Type) (d : Nat) := MachineExpanderTable.State ρ d × Unit +abbrev RegisterAmbient (ρ : Type) (d : Nat) := + (MachineExpanderTable.RowStatePrefix ρ d × MachineExpanderTable.Position d) × Unit + +def registerStates (ρ : Type) (d : Nat) : + (RegisterAmbient ρ d × Option Bool) ≃ State ρ d where + toFun s := (((s.1.1.1, s.2), s.1.1.2), s.1.2) + invFun s := (((s.1.1.1, s.1.2), s.2), s.1.1.2) + left_inv := by rintro ⟨⟨⟨a, p⟩, u⟩, b⟩; rfl + right_inv := by rintro ⟨⟨⟨a, b⟩, p⟩, u⟩; rfl + +@[simp] theorem registerStates_apply (ρ : Type) (d : Nat) + (s : RegisterAmbient ρ d × Option Bool) : + registerStates ρ d s = (((s.1.1.1, s.2), s.1.1.2), s.1.2) := rfl + +@[simp] theorem registerStates_symm_apply (ρ : Type) (d : Nat) (s : State ρ d) : + (registerStates ρ d).symm s = (((s.1.1.1, s.1.2), s.2), s.1.1.2) := rfl + +def caller {ρ : Type} {d : Nat} (s : State ρ d) : ρ := + MachineExpanderTable.caller s.1 + +def initialState {ρ : Type} {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (ambient : ρ) : State ρ d := + (MachineExpanderTable.initialState positive H ambient, ()) + +def normalizeState {ρ : Type} {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (s : State ρ d) : State ρ d := + initialState positive H (caller s) + +def initialEncoding (d : Nat) : List Bool := encodeWords (rotationWords (initial d)) + +theorem initialEncoding_eq_family {d : Nat} (H : Table (cloudSize d) d) : + initialEncoding d = encodeWords (rotationWords (family H 0)) := rfl + +def tableTape : Tape := .inl (.inl .table) +def inputVertexTape : Tape := .inl (.inl .inputVertex) +def vertexCountTape : Tape := .inl (.inr .vertexCount) +def resultTape : Tape := .inl (.inr .result) + +def affineSource : AffinePhase → Tape + | .copyCount => .inr .currentSize + | .multiplySize => inputVertexTape + +def affineDestination : AffinePhase → Tape + | .copyCount => vertexCountTape + | .multiplySize => .inr .currentSize + +def affineCoefficient (d : Nat) : AffinePhase → Nat + | .multiplySize => cloudSize d + | .copyCount => 1 + +def affineExit (d : Nat) : AffinePhase → Label d + | .copyCount => .inl (.inr .initialize) + | .multiplySize => .inr .drainInputVertex + +def affineStatement {ρ : Type} {d : Nat} (phase : AffinePhase) : + AffineLabel → TM2.Stmt BoolAlphabet (Label d) (State ρ d) + | .seed => + MachineControl.statement id (registerStates ρ d) + (MachineUnaryAffineAt.seed (Λ := Label d) (σ := RegisterAmbient ρ d) + (affineDestination phase) 0 (.inr (.affine phase .scan))) + | .scan => + MachineControl.statement id (registerStates ρ d) + (MachineUnaryAffineAt.scan (Λ := Label d) (σ := RegisterAmbient ρ d) + (affineSource phase) (.inr .unaryScratch) + (affineDestination phase) (affineCoefficient d phase) + (.inr (.affine phase .scan)) (.inr (.affine phase .restore))) + | .restore => + MachineControl.statement id (registerStates ρ d) + (Reduction.MachineTransfer.loopAt (Γ := BoolAlphabet) (Λ := Label d) + (σ := RegisterAmbient ρ d) (.inr .unaryScratch) (affineSource phase) id false + (.inr (.affine phase .restore)) (some (affineExit d phase))) + +def drainStatement {ρ : Type} {d : Nat} (tape : Tape) (again next : OuterLabel) : + TM2.Stmt BoolAlphabet (Label d) (State ρ d) := + MachineControl.statement id (registerStates ρ d) + (MachineDrain.drain (Λ := Label d) (σ := RegisterAmbient ρ d) + tape (.inr again) (some (.inr next))) + +variable {ρ : Type} [Fintype ρ] + +def boolOuterStatement {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) : + OuterLabel → TM2.Stmt BoolAlphabet (Label d) (State ρ d) + | .initialize => + Reduction.MachineSubstitution.pushWord tableTape (initialEncoding d).reverse + (Reduction.MachineSubstitution.pushWord (.inr .currentSize) (encodeWord 1).reverse + (.load (normalizeState positive H) + (.goto fun _ => .inr .levelGuard))) + | .levelGuard => + MachineControl.statement id (registerStates ρ d) + (MachineUnaryCounter.guard (K := Tape) (Λ := Label d) (σ := RegisterAmbient ρ d) + (.inr .remainingLevel) (.inr (.affine .copyCount .seed)) (.inr .done)) + | .affine phase label => affineStatement phase label + | .clearOldTable => drainStatement tableTape .clearOldTable .reverseResult + | .reverseResult => + MachineControl.statement id (registerStates ρ d) + (Reduction.MachineTransfer.loopAt (Γ := BoolAlphabet) (Λ := Label d) + (σ := RegisterAmbient ρ d) resultTape (.inr .tableReverse) id false + (.inr .reverseResult) (some (.inr .reverseTable))) + | .reverseTable => + MachineControl.statement id (registerStates ρ d) + (Reduction.MachineTransfer.loopAt (Γ := BoolAlphabet) (Λ := Label d) + (σ := RegisterAmbient ρ d) (.inr .tableReverse) tableTape id false + (.inr .reverseTable) (some (.inr .clearCurrentSize))) + | .clearCurrentSize => + drainStatement (.inr .currentSize) .clearCurrentSize (.affine .multiplySize .seed) + | .drainInputVertex => drainStatement inputVertexTape .drainInputVertex .drainVertexCount + | .drainVertexCount => drainStatement vertexCountTape .drainVertexCount .levelGuard + | .done => .load (normalizeState positive H) .halt + +def outerStatement {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (label : OuterLabel) : TM2.Stmt Alphabet (Label d) (State ρ d) := + MachineAlphabetTransport.statement alphabet_eq.symm (boolOuterStatement positive H label) + +def tableReturn (d : Nat) : Option (Label d) := some (.inr .clearOldTable) + +def program {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (_growth : 1 < cloudSize d) : Label d → TM2.Stmt Alphabet (Label d) (State ρ d) := + MachineEmbedding.program (tableReturn d) (MachineExpanderTable.program positive H) + (outerStatement positive H) + +@[simp] theorem program_table {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (label : MachineExpanderTable.Label d) : + program (ρ := ρ) positive H growth (.inl label) = + MachineEmbedding.statement (tableReturn d) + (MachineExpanderTable.program positive H label) := rfl + +@[simp] theorem program_outer {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) (label : OuterLabel) : + program (ρ := ρ) positive H growth (.inr label) = outerStatement positive H label := rfl + +def boolView {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) : Label d → TM2.Stmt BoolAlphabet (Label d) (State ρ d) := + MachineAlphabetTransport.program alphabet_eq (program positive H growth) + +@[simp] theorem boolView_outer {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) (label : OuterLabel) : + boolView (ρ := ρ) positive H growth (.inr label) = + boolOuterStatement positive H label := by + change MachineAlphabetTransport.statement alphabet_eq + (MachineAlphabetTransport.statement alphabet_eq.symm + (boolOuterStatement positive H label)) = _ + exact MachineAlphabetTransport.statement_roundtrip alphabet_eq _ + +def tableExecution {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (extra : ExtraTape → List Bool) + {a b : TM2.Cfg MachineExpanderTable.Alphabet (MachineExpanderTable.Label d) + (MachineExpanderTable.State ρ d)} {budget : Nat} + (execution : StateTransition.EvalsToInTime + (TM2.step (MachineExpanderTable.program positive H)) a (some b) budget) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + (MachineEmbedding.configuration (tableReturn d) () extra a) + (some (MachineEmbedding.configuration (tableReturn d) () extra b)) budget := + MachineComposition.embeddedExecution (tableReturn d) () extra + (MachineExpanderTable.program positive H) (outerStatement positive H) execution + +@[simp] theorem tableExecution_steps {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (growth : 1 < cloudSize d) + (extra : ExtraTape → List Bool) + {a b : TM2.Cfg MachineExpanderTable.Alphabet (MachineExpanderTable.Label d) + (MachineExpanderTable.State ρ d)} {budget : Nat} + (execution : StateTransition.EvalsToInTime + (TM2.step (MachineExpanderTable.program positive H)) a (some b) budget) : + (tableExecution positive H growth extra execution).steps = execution.steps := rfl + +def tableFrame (word : List Bool) : (tape : MachineExpanderTable.Tape) → + List (MachineExpanderTable.Alphabet tape) + | .inl .table => word + | .inl _ => [] + | .inr _ => [] + +def extraFrame (remaining current : Nat) (levelSuffix : List Bool) : ExtraTape → List Bool + | .remainingLevel => encodeWord remaining ++ levelSuffix + | .currentSize => encodeWord current + | _ => [] + +def boundaryTapes (remaining current : Nat) (word levelSuffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + MachineEmbedding.tapes (tableFrame word) (extraFrame remaining current levelSuffix) + +def initialTapes (level : Nat) (levelSuffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + MachineEmbedding.tapes (tableFrame []) + (fun tape => match tape with + | .remainingLevel => encodeWord level ++ levelSuffix + | _ => []) + +def familyTapes {d : Nat} (H : Table (cloudSize d) d) (level : Nat) + (levelSuffix : List Bool) : (tape : Tape) → List (Alphabet tape) := + boundaryTapes 0 (vertexCount (degree d) level) + (encodeWords (rotationWords (family H level))) levelSuffix + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyTapes.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyTapes.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4571392bf56a122b2467b4c4d3ac24dbb2d00e0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyTapes.lean @@ -0,0 +1,104 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyProgram + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +open Turing + +def boolWord : (tape : Tape) → List Bool → List (Alphabet tape) + | .inl (.inl _), word => word + | .inl (.inr _), word => word + | .inr _, word => word + +def toBoolWord : (tape : Tape) → List (Alphabet tape) → List Bool + | .inl (.inl _), word => word + | .inl (.inr _), word => word + | .inr _, word => word + +def fromBoolTapes (base : Tape → List Bool) : (tape : Tape) → List (Alphabet tape) := + fun tape => boolWord tape (base tape) + +def toBoolTapes (base : (tape : Tape) → List (Alphabet tape)) : Tape → List Bool := + fun tape => toBoolWord tape (base tape) + +@[simp] theorem toBoolWord_boolWord (tape : Tape) (word : List Bool) : + toBoolWord tape (boolWord tape word) = word := by + rcases tape with tape | tape + · cases tape <;> rfl + · rfl + +@[simp] theorem boolWord_toBoolWord (tape : Tape) (word : List (Alphabet tape)) : + boolWord tape (toBoolWord tape word) = word := by + rcases tape with tape | tape + · cases tape <;> rfl + · rfl + +@[simp] theorem toBool_fromBool (base : Tape → List Bool) : + toBoolTapes (fromBoolTapes base) = base := by + funext tape + exact toBoolWord_boolWord tape (base tape) + +@[simp] theorem fromBool_toBool (base : (tape : Tape) → List (Alphabet tape)) : + fromBoolTapes (toBoolTapes base) = base := by + funext tape + exact boolWord_toBoolWord tape (base tape) + +theorem transport_tapes_apply {K : Type} {Γ Δ : K → Type} + (h : Γ = Δ) (base : (k : K) → List (Γ k)) (k : K) : + MachineAlphabetTransport.tapes h base k = + Eq.mp (congrArg (fun alphabet => List (alphabet k)) h) (base k) := by + cases h + rfl + +theorem toBoolTapes_eq_transport (base : (tape : Tape) → List (Alphabet tape)) : + toBoolTapes base = MachineAlphabetTransport.tapes alphabet_eq base := by + funext tape + rw [transport_tapes_apply] + rcases tape with tape | tape + · cases tape <;> rfl + · rfl + +theorem fromBoolTapes_eq_transport (base : Tape → List Bool) : + fromBoolTapes base = MachineAlphabetTransport.tapes alphabet_eq.symm base := by + funext tape + rw [transport_tapes_apply] + rcases tape with tape | tape + · cases tape <;> rfl + · rfl + +@[simp] theorem fromBoolTapes_update (base : Tape → List Bool) (tape : Tape) (word : List Bool) : + fromBoolTapes (Function.update base tape word) = + Function.update (fromBoolTapes base) tape (boolWord tape word) := by + funext k + by_cases h : k = tape + · subst k + simp [fromBoolTapes] + · simp [fromBoolTapes, h] + +@[simp] theorem toBoolTapes_update (base : (tape : Tape) → List (Alphabet tape)) + (tape : Tape) (word : List (Alphabet tape)) : + toBoolTapes (Function.update base tape word) = + Function.update (toBoolTapes base) tape (toBoolWord tape word) := by + funext k + by_cases h : k = tape + · subst k + simp [toBoolTapes] + · simp [toBoolTapes, h] + +theorem configuration_fromBool {ρ : Type} {d : Nat} (label : Option (Label d)) + (state : State ρ d) (base : Tape → List Bool) : + MachineAlphabetTransport.configuration alphabet_eq.symm ⟨label, state, base⟩ = + ⟨label, state, fromBoolTapes base⟩ := by + rw [MachineAlphabetTransport.configuration_mk, fromBoolTapes_eq_transport] + +theorem configuration_toBool {ρ : Type} {d : Nat} (label : Option (Label d)) + (state : State ρ d) (base : (tape : Tape) → List (Alphabet tape)) : + MachineAlphabetTransport.configuration alphabet_eq ⟨label, state, base⟩ = + ⟨label, state, toBoolTapes base⟩ := by + rw [MachineAlphabetTransport.configuration_mk, toBoolTapes_eq_transport] + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyTransfer.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7fcd3e0af13a8ed136354e79df19cf08d8ee438 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderFamilyTransfer.lean @@ -0,0 +1,298 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyTapes + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +open Turing MachineComposition +open PCP.ExpanderTables PCP.ExpanderRowControl + +theorem controlStatementInverse {K Λ σ τ : Type} {Γ : K → Type} + (states : σ ≃ τ) (q : TM2.Stmt Γ Λ σ) : + MachineControl.statement id states.symm (MachineControl.statement id states q) = q := by + induction q <;> + simp_all only [MachineControl.statement, Equiv.apply_symm_apply, + Equiv.symm_apply_apply, id_eq] + +theorem controlTrace {K Λ σ τ : Type} {Γ : K → Type} [DecidableEq K] + (states : σ ≃ τ) (target : Λ → TM2.Stmt Γ Λ τ) + (n : Nat) (start finish : TM2.Cfg Γ Λ σ) + (run : (advance (TM2.step (MachineControl.program (Equiv.refl Λ) states.symm target)))^[n] + (some start) = some finish) : + (advance (TM2.step target))^[n] + (some (MachineControl.configuration id states start)) = + some (MachineControl.configuration id states finish) := by + let source := MachineControl.program (Equiv.refl Λ) states.symm target + have roundtrip : MachineControl.program (Equiv.refl Λ) states source = target := by + funext label + change MachineControl.statement id states + (MachineControl.statement id states.symm (target label)) = target label + exact controlStatementInverse states.symm _ + have simulation : ∀ a b, TM2.step source a = some b → + TM2.step target (MachineControl.configuration id states a) = + some (MachineControl.configuration id states b) := by + intro a b hab + have h := MachineControl.step_simulation (Equiv.refl Λ) states source a + rw [roundtrip, hab] at h + exact h + exact liftSuccessfulTrace (TM2.step source) (TM2.step target) + (MachineControl.configuration id states) simulation n start finish run + +theorem controlDrainTrace {K Λ σ τ : Type} [DecidableEq K] + (states : (σ × Option Bool) ≃ τ) (source : K) (again : Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ τ) + (code : target again = MachineControl.statement id states + (MachineDrain.drain source again exit)) + (base : K → List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step target))^[(base source).length + 1] + (some ⟨some again, states (ambient, register), base⟩) = + some ⟨exit, states (ambient, none), Function.update base source []⟩ := by + let raw := MachineControl.program (Equiv.refl Λ) states.symm target + have atRaw : raw again = MachineDrain.drain source again exit := by + change MachineControl.statement id states.symm (target again) = _ + rw [code] + exact controlStatementInverse states _ + have run := MachineDrain.drainTrace source again exit raw atRaw base (base source) ambient register + simp only [Function.update_eq_self] at run + simpa only [MachineControl.configuration, Option.map_some, id_eq, Option.map_id] using + controlTrace states target ((base source).length + 1) _ _ run + +theorem controlTransferTrace {K Λ σ τ : Type} [DecidableEq K] + (states : (σ × Option Bool) ≃ τ) (source destination : K) + (distinct : source ≠ destination) (again : Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ τ) + (code : target again = MachineControl.statement id states + (Reduction.MachineTransfer.loopAt source destination id false again exit)) + (base : K → List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step target))^[(base source).length + 1] + (some ⟨some again, states (ambient, register), base⟩) = + some ⟨exit, states (ambient, none), + Reduction.MachineTransfer.tapesAt source destination base [] + ((base source).reverse ++ base destination)⟩ := by + let raw := MachineControl.program (Equiv.refl Λ) states.symm target + have atRaw : raw again = Reduction.MachineTransfer.loopAt source destination id false again exit := by + change MachineControl.statement id states.symm (target again) = _ + rw [code] + exact controlStatementInverse states _ + have run := Reduction.MachineTransfer.transferAt_fromTapes source destination distinct id false + again exit raw atRaw base ambient register + unfold Reduction.MachineTransfer.nextAt at run + simpa only [MachineControl.configuration, Option.map_some, id_eq, Option.map_id, + List.map_id] using controlTrace states target ((base source).length + 1) _ _ run + +variable {ρ : Type} {d : Nat} + +def clearRegister (state : State ρ d) : State ρ d := + (MachineExpanderTable.clearRegister state.1, state.2) + +@[simp] theorem registerStates_reset (state : State ρ d) : + registerStates ρ d (((registerStates ρ d).symm state).1, none) = + clearRegister state := rfl + +@[simp] theorem clearRegister_idempotent (state : State ρ d) : + clearRegister (clearRegister state) = clearRegister state := rfl + +@[simp] theorem caller_clearRegister (state : State ρ d) : + caller (clearRegister state) = caller state := rfl + +@[simp] theorem clearRegister_position (state : State ρ d) : + (clearRegister state).1.2 = state.1.2 := rfl + +@[simp] theorem clearRegister_register (state : State ρ d) : + (clearRegister state).1.1.2 = none := rfl + +variable [Fintype ρ] + +theorem boolTraceActual (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (n : Nat) + (start finish : TM2.Cfg BoolAlphabet (Label d) (State ρ d)) + (run : (advance (TM2.step (boolView positive H growth)))^[n] (some start) = some finish) : + (advance (TM2.step (program positive H growth)))^[n] + (some (MachineAlphabetTransport.configuration alphabet_eq.symm start)) = + some (MachineAlphabetTransport.configuration alphabet_eq.symm finish) := by + have h := MachineAlphabetTransport.successfulTrace alphabet_eq.symm + (boolView positive H growth) n start finish run + simpa only [boolView, MachineAlphabetTransport.program_symm_roundtrip] using h + +theorem drainBoolTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (source : Tape) (again next : OuterLabel) + (code : boolOuterStatement (ρ := ρ) positive H again = drainStatement source again next) + (base : Tape → List Bool) (state : State ρ d) : + (advance (TM2.step (boolView positive H growth)))^[(base source).length + 1] + (some ⟨some (.inr again), state, base⟩) = + some ⟨some (.inr next), clearRegister state, Function.update base source []⟩ := by + have atLoop : boolView (ρ := ρ) positive H growth (.inr again) = + MachineControl.statement id (registerStates ρ d) + (MachineDrain.drain source (.inr again) (some (.inr next))) := by + rw [boolView_outer, code] + rfl + have h := controlDrainTrace (registerStates ρ d) source (.inr again) (some (.inr next)) + (boolView positive H growth) atLoop base + ((registerStates ρ d).symm state).1 ((registerStates ρ d).symm state).2 + simpa only [Prod.mk.eta, Equiv.apply_symm_apply, registerStates_reset] using h + +theorem transferBoolTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (source destination : Tape) (distinct : source ≠ destination) + (again next : OuterLabel) + (code : boolOuterStatement (ρ := ρ) positive H again = + MachineControl.statement id (registerStates ρ d) + (Reduction.MachineTransfer.loopAt (Γ := BoolAlphabet) source destination id false + (.inr again) (some (.inr next)))) + (base : Tape → List Bool) (state : State ρ d) : + (advance (TM2.step (boolView positive H growth)))^[(base source).length + 1] + (some ⟨some (.inr again), state, base⟩) = + some ⟨some (.inr next), clearRegister state, + Reduction.MachineTransfer.tapesAt source destination base [] + ((base source).reverse ++ base destination)⟩ := by + have atLoop : boolView (ρ := ρ) positive H growth (.inr again) = + MachineControl.statement id (registerStates ρ d) + (Reduction.MachineTransfer.loopAt source destination id false + (.inr again) (some (.inr next))) := by + rw [boolView_outer, code] + have h := controlTransferTrace (registerStates ρ d) source destination distinct + (.inr again) (some (.inr next)) (boolView positive H growth) atLoop base + ((registerStates ρ d).symm state).1 ((registerStates ρ d).symm state).2 + simpa only [Prod.mk.eta, Equiv.apply_symm_apply, registerStates_reset] using h + +def installedTapes (base : Tape → List Bool) (newWord : List Bool) : Tape → List Bool := + Function.update + (Function.update + (Function.update (Function.update base tableTape newWord) resultTape []) + (.inr .tableReverse) []) + (.inr .currentSize) [] + +def cleanedCounterTapes (base : Tape → List Bool) : Tape → List Bool := + Function.update (Function.update base inputVertexTape []) vertexCountTape [] + +theorem installTableBoolTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : Tape → List Bool) (newWord : List Bool) + (resultWord : base resultTape = newWord) (reverseEmpty : base (.inr .tableReverse) = []) + (state : State ρ d) : + (advance (TM2.step (boolView positive H growth)))^[ + (base tableTape).length + 2 * newWord.length + (base (.inr .currentSize)).length + 4] + (some ⟨some (.inr .clearOldTable), state, base⟩) = + some ⟨some (.inr (.affine .multiplySize .seed)), clearRegister state, + installedTapes base newWord⟩ := by + let b0 := Function.update base tableTape [] + let b1 := Function.update (Function.update b0 resultTape []) (.inr .tableReverse) newWord.reverse + let b2 := Function.update (Function.update b1 (.inr .tableReverse) []) tableTape newWord + let b3 := Function.update b2 (.inr .currentSize) [] + have h0 := drainBoolTrace positive H growth tableTape .clearOldTable .reverseResult rfl base state + have b0Result : b0 resultTape = newWord := by + simpa [b0, tableTape, resultTape] using resultWord + have b0Reverse : b0 (.inr .tableReverse) = [] := by + simpa [b0, tableTape] using reverseEmpty + have h1 : (advance (TM2.step (boolView positive H growth)))^[newWord.length + 1] + (some ⟨some (.inr .reverseResult), clearRegister state, b0⟩) = + some ⟨some (.inr .reverseTable), clearRegister state, b1⟩ := by + simpa only [b0Result, b0Reverse, List.append_nil, Reduction.MachineTransfer.tapesAt, + clearRegister_idempotent] using + transferBoolTrace positive H growth resultTape (.inr .tableReverse) (by decide) + .reverseResult .reverseTable rfl b0 (clearRegister state) + have b1Reverse : b1 (.inr .tableReverse) = newWord.reverse := by simp [b1] + have b1Table : b1 tableTape = [] := by simp [b1, b0, tableTape, resultTape] + have h2 : (advance (TM2.step (boolView positive H growth)))^[newWord.length + 1] + (some ⟨some (.inr .reverseTable), clearRegister state, b1⟩) = + some ⟨some (.inr .clearCurrentSize), clearRegister state, b2⟩ := by + simpa only [b1Reverse, b1Table, List.reverse_reverse, List.length_reverse, + List.append_nil, Reduction.MachineTransfer.tapesAt, clearRegister_idempotent] using + transferBoolTrace positive H growth (.inr .tableReverse) tableTape (by decide) + .reverseTable .clearCurrentSize rfl b1 (clearRegister state) + have b2Current : b2 (.inr .currentSize) = base (.inr .currentSize) := by + simp [b2, b1, b0, tableTape, resultTape] + have h3 : (advance (TM2.step (boolView positive H growth)))^[ + (base (.inr .currentSize)).length + 1] + (some ⟨some (.inr .clearCurrentSize), clearRegister state, b2⟩) = + some ⟨some (.inr (.affine .multiplySize .seed)), clearRegister state, b3⟩ := by + simpa only [b2Current, clearRegister_idempotent] using + drainBoolTrace positive H growth (.inr .currentSize) .clearCurrentSize + (.affine .multiplySize .seed) rfl b2 (clearRegister state) + have final : b3 = installedTapes base newWord := by + funext tape + rcases tape with table | extra + · rcases table with row | tableExtra + · cases row <;> simp [b3, b2, b1, b0, installedTapes, tableTape, resultTape] + · cases tableExtra <;> simp [b3, b2, b1, b0, installedTapes, tableTape, resultTape] + · cases extra <;> simp [b3, b2, b1, b0, installedTapes, tableTape, resultTape] + rw [show (base tableTape).length + 2 * newWord.length + + (base (.inr .currentSize)).length + 4 = + ((base (.inr .currentSize)).length + 1) + + ((newWord.length + 1) + ((newWord.length + 1) + ((base tableTape).length + 1))) by omega, + Function.iterate_add_apply _ ((base (.inr .currentSize)).length + 1), + Function.iterate_add_apply _ (newWord.length + 1) ((newWord.length + 1) + ((base tableTape).length + 1)), + Function.iterate_add_apply _ (newWord.length + 1) ((base tableTape).length + 1), + h0, h1, h2, h3, final] + +theorem cleanupCountersBoolTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : Tape → List Bool) (state : State ρ d) : + (advance (TM2.step (boolView positive H growth)))^[ + (base inputVertexTape).length + (base vertexCountTape).length + 2] + (some ⟨some (.inr .drainInputVertex), state, base⟩) = + some ⟨some (.inr .levelGuard), clearRegister state, cleanedCounterTapes base⟩ := by + have h0 := drainBoolTrace positive H growth inputVertexTape .drainInputVertex .drainVertexCount + rfl base state + have count : (Function.update base inputVertexTape []) vertexCountTape = base vertexCountTape := by + simp [inputVertexTape, vertexCountTape] + have h1 := drainBoolTrace positive H growth vertexCountTape .drainVertexCount .levelGuard + rfl (Function.update base inputVertexTape []) (clearRegister state) + simp only [count, clearRegister_idempotent] at h1 + rw [show (base inputVertexTape).length + (base vertexCountTape).length + 2 = + ((base vertexCountTape).length + 1) + ((base inputVertexTape).length + 1) by omega, + Function.iterate_add_apply, h0] + exact h1 + +theorem installTableTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : (tape : Tape) → List (Alphabet tape)) + (newWord : List Bool) (resultWord : toBoolTapes base resultTape = newWord) + (reverseEmpty : toBoolTapes base (.inr .tableReverse) = []) (state : State ρ d) : + (advance (TM2.step (program positive H growth)))^[ + (toBoolTapes base tableTape).length + 2 * newWord.length + + (toBoolTapes base (.inr .currentSize)).length + 4] + (some ⟨some (.inr .clearOldTable), state, base⟩) = + some ⟨some (.inr (.affine .multiplySize .seed)), clearRegister state, + fromBoolTapes (installedTapes (toBoolTapes base) newWord)⟩ := by + have h := installTableBoolTrace positive H growth (toBoolTapes base) newWord resultWord reverseEmpty state + simpa only [configuration_fromBool, fromBool_toBool] using boolTraceActual positive H growth _ _ _ h + +theorem cleanupCountersTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : (tape : Tape) → List (Alphabet tape)) + (state : State ρ d) : + (advance (TM2.step (program positive H growth)))^[ + (toBoolTapes base inputVertexTape).length + (toBoolTapes base vertexCountTape).length + 2] + (some ⟨some (.inr .drainInputVertex), state, base⟩) = + some ⟨some (.inr .levelGuard), clearRegister state, + fromBoolTapes (cleanedCounterTapes (toBoolTapes base))⟩ := by + have h := cleanupCountersBoolTrace positive H growth (toBoolTapes base) state + simpa only [configuration_fromBool, fromBool_toBool] using boolTraceActual positive H growth _ _ _ h + +def installTableInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : (tape : Tape) → List (Alphabet tape)) + (newWord : List Bool) (resultWord : toBoolTapes base resultTape = newWord) + (reverseEmpty : toBoolTapes base (.inr .tableReverse) = []) (state : State ρ d) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .clearOldTable), state, base⟩ + (some ⟨some (.inr (.affine .multiplySize .seed)), clearRegister state, + fromBoolTapes (installedTapes (toBoolTapes base) newWord)⟩) + ((toBoolTapes base tableTape).length + 2 * newWord.length + + (toBoolTapes base (.inr .currentSize)).length + 4) where + steps := (toBoolTapes base tableTape).length + 2 * newWord.length + + (toBoolTapes base (.inr .currentSize)).length + 4 + evals_in_steps := installTableTrace positive H growth base newWord resultWord reverseEmpty state + steps_le_m := Nat.le_refl _ + +def cleanupCountersInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (growth : 1 < cloudSize d) (base : (tape : Tape) → List (Alphabet tape)) + (state : State ρ d) : + StateTransition.EvalsToInTime (TM2.step (program positive H growth)) + ⟨some (.inr .drainInputVertex), state, base⟩ + (some ⟨some (.inr .levelGuard), clearRegister state, + fromBoolTapes (cleanedCounterTapes (toBoolTapes base))⟩) + ((toBoolTapes base inputVertexTape).length + (toBoolTapes base vertexCountTape).length + 2) where + steps := (toBoolTapes base inputVertexTape).length + (toBoolTapes base vertexCountTape).length + 2 + evals_in_steps := cleanupCountersTrace positive H growth base state + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRow.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..72bd253e7de367b41a8f2bcc0ac12974537eafcf --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRow.lean @@ -0,0 +1,201 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowFrames + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +open Turing MachineComposition +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords PCP.AlphabetTable + +private theorem concatenate {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +def rowSteps {v d : Nat} (r : RowData v d) (output : List Bool) : Nat := + 1 + emitSteps r.inputVertex.val + (r.query1 + 2) + + MachinePreservingLookupClean.steps (rotationWords r.oldTable) r.firstRow.val + + (r.firstValue + 2) + 1 + emitSteps r.firstVertex.val + (r.query2 + 2) + + MachinePreservingLookupClean.steps (rotationWords r.oldTable) r.secondRow.val + + (r.secondValue + 2) + emitSteps r.secondVertex.val + + (cleanupSteps id (frame11 r output) + 1) + +section Execution + +variable {v d : Nat} {ρ Λ : Type} [Fintype ρ] + (positive : 0 < d) (r : RowData v d) (output : List Bool) (ambient : ρ) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : Tape => Bool) Λ (State ρ d)) + (code : ∀ l, target (labels l) = statement positive r.smallTable id labels exit l) + +include code + +theorem rowTraceAt : + (advance (TM2.step target))^[rowSteps r output] + (some ⟨some (labels .initialize), divisionState positive ambient r.control0 none, + frame0 r output⟩) = + some ⟨exit, divisionState positive ambient r.control2 none, + emittedWord .output (frame0 r output) r.finalValue⟩ := by + let zero := MachineFixedDivMod.residue (degree d) (Nat.mul_pos positive positive) 0 + have h0 : (advance (TM2.step target))^[1] + (some ⟨some (labels .initialize), divisionState positive ambient r.control0 none, + frame0 r output⟩) = + some ⟨some (labels (.firstEmit (Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient r.control0 none, frame1 r output⟩ := by + simpa only [Function.iterate_one, advance_some, divisionState, frame1] using + initializeStepAt positive r.smallTable id Function.injective_id labels exit target code + (frame0 r output) (divisionState positive ambient r.control0 none) + have h1 := firstEmitTraceAt positive r.smallTable id Function.injective_id + labels exit target code r.inputVertex.val (frame1 r output) + (by simp) (by simp) ((ambient,r.control0),zero) + change (advance (TM2.step target))^[emitSteps r.inputVertex.val] + (some ⟨some (labels (.firstEmit (Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient r.control0 none, frame1 r output⟩) = + some ⟨some (labels .firstReverse), divisionState positive ambient r.control0 none, + frame2 r output⟩ at h1 + have h2 := reversePhaseTrace_unary false positive r.smallTable id Function.injective_id + labels exit target code (frame2 r output) (((ambient,r.control0),zero),()) none + r.query1 [] (by simp) (by simp) + simp only [List.append_nil] at h2 + change (advance (TM2.step target))^[r.query1 + 2] + (some ⟨some (labels .firstReverse), divisionState positive ambient r.control0 none, + frame2 r output⟩) = + some ⟨some (labels (.firstLookup (.run .copyFirst))), + divisionState positive ambient r.control0 none, frame3 r output⟩ at h2 + have h3 := lookupPhaseTrace false positive r.smallTable id Function.injective_id + labels exit target code (frame3 r output) r.oldTable + (by simp) (by simp) + (r.inputVertex, firstOffset r.control0) [] + (by simpa [frameContents, RowData.firstRow] using + congrArg encodeWord r.query1_eq_firstRow) + (by simp) (((ambient,r.control0),zero),()) none + change (advance (TM2.step target))^[MachinePreservingLookupClean.steps + (rotationWords r.oldTable) r.firstRow.val] + (some ⟨some (labels (.firstLookup (.run .copyFirst))), + divisionState positive ambient r.control0 none, frame3 r output⟩) = + some ⟨some (labels .firstScan), divisionState positive ambient r.control0 none, + frame4 r output⟩ at h3 + have h4 := firstDivisionTrace positive r.smallTable id Function.injective_id labels exit + target code (frame4 r output) r.firstValue [] [] [] + (by simp) (by simp) (by simp) + ambient r.control0 none + rw [← r.firstReturn_eq_residue positive] at h4 + change (advance (TM2.step target))^[r.firstValue + 2] + (some ⟨some (labels .firstScan), divisionState positive ambient r.control0 none, + frame4 r output⟩) = + some ⟨some (labels .clearQuery), divisionState positive ambient r.control1 none, + frame5 r output⟩ at h4 + have h5 : (advance (TM2.step target))^[1] + (some ⟨some (labels .clearQuery), divisionState positive ambient r.control1 none, + frame5 r output⟩) = + some ⟨some (labels (.secondEmit (Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient r.control1 none, frame6 r output⟩ := by + simpa only [Function.iterate_one, advance_some, frame6] using + clearQueryStepAt positive r.smallTable id Function.injective_id labels exit target code + (frame5 r output) (divisionState positive ambient r.control1 none) + have h6 := secondEmitTraceAt positive r.smallTable id Function.injective_id + labels exit target code r.firstVertex.val (frame6 r output) + (by simp) (by simp) ((ambient,r.control1),zero) + change (advance (TM2.step target))^[emitSteps r.firstVertex.val] + (some ⟨some (labels (.secondEmit (Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient r.control1 none, frame6 r output⟩) = + some ⟨some (labels .secondReverse), divisionState positive ambient r.control1 none, + frame7 r output⟩ at h6 + have h7 := reversePhaseTrace_unary true positive r.smallTable id Function.injective_id + labels exit target code (frame7 r output) (((ambient,r.control1),zero),()) none + r.query2 [] (by simp) (by simp) + simp only [List.append_nil] at h7 + change (advance (TM2.step target))^[r.query2 + 2] + (some ⟨some (labels .secondReverse), divisionState positive ambient r.control1 none, + frame7 r output⟩) = + some ⟨some (labels (.secondLookup (.run .copyFirst))), + divisionState positive ambient r.control1 none, frame8 r output⟩ at h7 + have h8 := lookupPhaseTrace true positive r.smallTable id Function.injective_id + labels exit target code (frame8 r output) r.oldTable + (by simp) (by simp) + (r.firstVertex, secondOffset r.control1) [] + (by simpa [frameContents, RowData.secondRow] using + congrArg encodeWord r.query2_eq_secondRow) + (by simp) (((ambient,r.control1),zero),()) none + change (advance (TM2.step target))^[MachinePreservingLookupClean.steps + (rotationWords r.oldTable) r.secondRow.val] + (some ⟨some (labels (.secondLookup (.run .copyFirst))), + divisionState positive ambient r.control1 none, frame8 r output⟩) = + some ⟨some (labels .secondScan), divisionState positive ambient r.control1 none, + frame9 r output⟩ at h8 + have h9 := secondDivisionTrace positive r.smallTable id Function.injective_id labels exit + target code (frame9 r output) r.secondValue [] [] [] + (by simp) (by simp) (by simp) + ambient r.control1 none + rw [← r.secondReturn_eq_residue positive] at h9 + change (advance (TM2.step target))^[r.secondValue + 2] + (some ⟨some (labels .secondScan), divisionState positive ambient r.control1 none, + frame9 r output⟩) = + some ⟨some (labels (.outputEmit (Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient r.control2 none, frame10 r output⟩ at h9 + have h10 := outputEmitTraceAt positive r.smallTable id Function.injective_id + labels exit target code r.secondVertex.val (frame10 r output) + (by simp) (by simp) ((ambient,r.control2),zero) + change (advance (TM2.step target))^[emitSteps r.secondVertex.val] + (some ⟨some (labels (.outputEmit (Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient r.control2 none, frame10 r output⟩) = + some ⟨some (labels (.cleanup 0)), divisionState positive ambient r.control2 none, + frame11 r output⟩ at h10 + have h11 := cleanupExitTraceAt positive r.smallTable id Function.injective_id + labels exit target code (frame11 r output) (divisionState positive ambient r.control2 none) + change (advance (TM2.step target))^[cleanupSteps id (frame11 r output) + 1] + (some ⟨some (labels (.cleanup 0)), divisionState positive ambient r.control2 none, + frame11 r output⟩) = + some ⟨exit, divisionState positive ambient r.control2 none, frame12 r output⟩ at h11 + rw [final_frame_eq] at h11 + exact concatenate (concatenate (concatenate (concatenate (concatenate + (concatenate (concatenate (concatenate (concatenate (concatenate + (concatenate h0 h1) h2) h3) h4) h5) h6) h7) h8) h9) h10) h11 + +end Execution + +theorem rowSteps_le {v d : Nat} (r : RowData v d) (output : List Bool) : + rowSteps r output ≤ 80 * (r.tableLength + 1) := by + have lookup1 := MachinePreservingLookupClean.steps_le (rotationWords r.oldTable) + r.firstRow.val r.firstValue (rotationWords_getElem? r.oldTable r.firstRow) + have lookup2 := MachinePreservingLookupClean.steps_le (rotationWords r.oldTable) + r.secondRow.val r.secondValue (rotationWords_getElem? r.oldTable r.secondRow) + have h0 := r.inputVertex_le_tableLength + have h1 := r.query1_le_tableLength + have h2 := r.firstValue_le_tableLength + have h3 := r.firstVertex_le_tableLength + have h4 := r.query2_le_tableLength + have h5 := r.secondValue_le_tableLength + have h6 := r.secondVertex_le_tableLength + have clean := cleanupSteps_le_tableLength r output + change _ ≤ 6 * r.tableLength + 4 at lookup1 lookup2 + simp only [rowSteps, emitSteps] + omega + +def rowInTimeAt {v d : Nat} {ρ Λ : Type} [Fintype ρ] + (positive : 0 < d) (r : RowData v d) (output : List Bool) (ambient : ρ) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : Tape => Bool) Λ (State ρ d)) + (code : ∀ l, target (labels l) = statement positive r.smallTable id labels exit l) : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels .initialize), divisionState positive ambient r.control0 none, + frame0 r output⟩ + (some ⟨exit, divisionState positive ambient r.control2 none, + emittedWord .output (frame0 r output) r.finalValue⟩) + (80 * (r.tableLength + 1)) where + steps := rowSteps r output + evals_in_steps := rowTraceAt positive r output ambient labels exit target code + steps_le_m := rowSteps_le r output + +def rowInTime {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (r : RowData v d) (output : List Bool) (ambient : ρ) : + StateTransition.EvalsToInTime (TM2.step (program positive r.smallTable)) + ⟨some .initialize, divisionState positive ambient r.control0 none, frame0 r output⟩ + (some ⟨none, divisionState positive ambient r.control2 none, + emittedWord .output (frame0 r output) r.finalValue⟩) + (80 * (r.tableLength + 1)) := + rowInTimeAt positive r output ambient id none (program positive r.smallTable) (fun _ => rfl) + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowDivision.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowDivision.lean new file mode 100644 index 0000000000000000000000000000000000000000..299dbb9f8d7607af5c148e474e59788ac9bc7e0e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowDivision.lean @@ -0,0 +1,266 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowProgram + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl + +private theorem controlStatement_inverse {K Λ σ τ : Type} {Γ : K → Type} + (e : σ ≃ τ) (q : TM2.Stmt Γ Λ σ) : + MachineControl.statement id e.symm (MachineControl.statement id e q) = q := by + induction q <;> + simp_all only [MachineControl.statement, Equiv.apply_symm_apply, + Equiv.symm_apply_apply, id_eq] + +private theorem transportedDivision {K Λ σ τ : Type} [DecidableEq K] [Fintype σ] + (q : Nat) (positive : 0 < q) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) + (states : MachineFixedDivMod.State σ q ≃ τ) + (scanLabel : Λ) (emitterLabel : Fin q → Λ) (exit : Option Λ) + (finish : σ → Fin q → σ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ τ) + (atScan : target scanLabel = MachineControl.statement id states + (MachineFixedDivMod.scanLoop q positive source quotient scanLabel emitterLabel)) + (atEmitter : ∀ r, target (emitterLabel r) = MachineControl.statement id states + (MachineFixedDivMod.emitterWithFinish q positive remainder exit finish r)) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base source = encodeWord n ++ sourceSuffix) + (quotientInput : base quotient = encodeWord 0 ++ quotientSuffix) + (remainderInput : base remainder = encodeWord 0 ++ remainderSuffix) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step target))^[n + 2] + (some (MachineControl.configuration id states + ⟨some scanLabel, ((ambient, MachineFixedDivMod.residue q positive 0), register), base⟩)) = + some (MachineControl.configuration id states + ⟨exit, ((finish ambient (MachineFixedDivMod.residue q positive n), + MachineFixedDivMod.residue q positive 0), none), + MachineFixedDivMod.unaryTapes source quotient remainder base 0 (n / q) (n % q) + sourceSuffix quotientSuffix remainderSuffix⟩) := by + let sourceProgram := MachineControl.program (Equiv.refl Λ) states.symm target + have sourceScan : sourceProgram scanLabel = + MachineFixedDivMod.scanLoop q positive source quotient scanLabel emitterLabel := by + change MachineControl.statement id states.symm (target scanLabel) = _ + rw [atScan] + exact controlStatement_inverse states _ + have sourceEmit : ∀ r, sourceProgram (emitterLabel r) = + MachineFixedDivMod.emitterWithFinish q positive remainder exit finish r := by + intro r + change MachineControl.statement id states.symm (target (emitterLabel r)) = _ + rw [atEmitter] + exact controlStatement_inverse states _ + have htrace := MachineFixedDivMod.divModFromTapesWithFinish q positive source quotient + remainder sourceQuotient sourceRemainder quotientRemainder scanLabel emitterLabel exit + finish sourceProgram sourceScan sourceEmit base n sourceSuffix quotientSuffix remainderSuffix + sourceInput quotientInput remainderInput ambient register + have roundtrip : MachineControl.program (Equiv.refl Λ) states sourceProgram = target := by + funext label + change MachineControl.statement id states + (MachineControl.statement id states.symm (target label)) = target label + exact controlStatement_inverse states.symm _ + have simulation : ∀ a b, TM2.step sourceProgram a = some b → + TM2.step target (MachineControl.configuration id states a) = + some (MachineControl.configuration id states b) := by + intro a b hab + have h := MachineControl.step_simulation (Equiv.refl Λ) states sourceProgram a + rw [roundtrip, hab] at h + exact h + exact MachineComposition.liftSuccessfulTrace (TM2.step sourceProgram) (TM2.step target) + (MachineControl.configuration id states) simulation (n + 2) _ _ htrace + +variable {K Λ ρ : Type} [DecidableEq K] [Fintype ρ] + +@[simp] theorem divisionStates_apply (ρ : Type) (d : Nat) + (s : MachineFixedDivMod.State (Ambient ρ d × Unit) (degree d)) : + divisionStates ρ d s = (((s.1.1.1, s.1.2), ()), s.2) := rfl + +def divisionState {d : Nat} (positive : 0 < d) (ambient : ρ) (control : Control d) + (register : Option Bool) : State ρ d := + ((((ambient, control), + MachineFixedDivMod.residue (degree d) (Nat.mul_pos positive positive) 0), ()), register) + +def divisionOutput (d : Nat) (ports : Tape → K) (quotient remainder : Tape) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : K → List Bool := + MachineFixedDivMod.unaryTapes (ports .lookupOutput) (ports quotient) (ports remainder) + base 0 (n / degree d) (n % degree d) sourceSuffix quotientSuffix remainderSuffix + +theorem firstDivisionTrace {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atProgram : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base (ports .lookupOutput) = encodeWord n ++ sourceSuffix) + (quotientInput : base (ports .quotientFirst) = encodeWord 0 ++ quotientSuffix) + (remainderInput : base (ports .remainderFirst) = encodeWord 0 ++ remainderSuffix) + (ambient : ρ) (control : Control d) (register : Option Bool) : + (MachineComposition.advance (TM2.step target))^[n + 2] + (some ⟨some (labels .firstScan), divisionState positive ambient control register, base⟩) = + some ⟨some (labels .clearQuery), divisionState positive ambient + (receiveFirst control (MachineFixedDivMod.residue (degree d) + (Nat.mul_pos positive positive) n)) none, + divisionOutput d ports .quotientFirst .remainderFirst base n + sourceSuffix quotientSuffix remainderSuffix⟩ := by + have hsq : ports .lookupOutput ≠ ports .quotientFirst := + fun h => Tape.noConfusion (portsInjective h) + have hsr : ports .lookupOutput ≠ ports .remainderFirst := + fun h => Tape.noConfusion (portsInjective h) + have hqr : ports .quotientFirst ≠ ports .remainderFirst := + fun h => Tape.noConfusion (portsInjective h) + have hs : target (labels .firstScan) = MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.scanLoop (degree d) (Nat.mul_pos positive positive) + (ports .lookupOutput) (ports .quotientFirst) (labels .firstScan) + (fun r => labels (.firstResidue r))) := atProgram .firstScan + have he : ∀ r, target (labels (.firstResidue r)) = + MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.emitterWithFinish (degree d) (Nat.mul_pos positive positive) + (ports .remainderFirst) (some (labels .clearQuery)) firstFinish r) := + fun r => atProgram (.firstResidue r) + have h := transportedDivision (degree d) (Nat.mul_pos positive positive) + (ports .lookupOutput) (ports .quotientFirst) (ports .remainderFirst) hsq hsr hqr + (divisionStates ρ d) (labels .firstScan) (fun r => labels (.firstResidue r)) + (some (labels .clearQuery)) firstFinish target hs he base n sourceSuffix quotientSuffix + remainderSuffix sourceInput quotientInput remainderInput ((ambient, control), ()) register + simpa only [MachineControl.configuration, divisionStates_apply, firstFinish, divisionState, + divisionOutput, Option.map_some, id_eq] using h + +theorem secondDivisionTrace {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atProgram : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base (ports .lookupOutput) = encodeWord n ++ sourceSuffix) + (quotientInput : base (ports .quotientSecond) = encodeWord 0 ++ quotientSuffix) + (remainderInput : base (ports .remainderSecond) = encodeWord 0 ++ remainderSuffix) + (ambient : ρ) (control : Control d) (register : Option Bool) : + (MachineComposition.advance (TM2.step target))^[n + 2] + (some ⟨some (labels .secondScan), divisionState positive ambient control register, base⟩) = + some ⟨some (labels (.outputEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient + (receiveSecond H control (MachineFixedDivMod.residue (degree d) + (Nat.mul_pos positive positive) n)) none, + divisionOutput d ports .quotientSecond .remainderSecond base n + sourceSuffix quotientSuffix remainderSuffix⟩ := by + have hsq : ports .lookupOutput ≠ ports .quotientSecond := + fun h => Tape.noConfusion (portsInjective h) + have hsr : ports .lookupOutput ≠ ports .remainderSecond := + fun h => Tape.noConfusion (portsInjective h) + have hqr : ports .quotientSecond ≠ ports .remainderSecond := + fun h => Tape.noConfusion (portsInjective h) + have hs : target (labels .secondScan) = MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.scanLoop (degree d) (Nat.mul_pos positive positive) + (ports .lookupOutput) (ports .quotientSecond) (labels .secondScan) + (fun r => labels (.secondResidue r))) := atProgram .secondScan + have he : ∀ r, target (labels (.secondResidue r)) = + MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.emitterWithFinish (degree d) (Nat.mul_pos positive positive) + (ports .remainderSecond) + (some (labels (.outputEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry)))) + (secondFinish H) r) := fun r => atProgram (.secondResidue r) + have h := transportedDivision (degree d) (Nat.mul_pos positive positive) + (ports .lookupOutput) (ports .quotientSecond) (ports .remainderSecond) hsq hsr hqr + (divisionStates ρ d) (labels .secondScan) (fun r => labels (.secondResidue r)) + (some (labels (.outputEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry)))) + (secondFinish H) target hs he base n sourceSuffix quotientSuffix remainderSuffix + sourceInput quotientInput remainderInput ((ambient, control), ()) register + simpa only [MachineControl.configuration, divisionStates_apply, secondFinish, divisionState, + divisionOutput, Option.map_some, id_eq] using h + +@[simp] theorem divisionOutput_source (d : Nat) (ports : Tape → K) + (portsInjective : Function.Injective ports) (quotient remainder : Tape) + (notSourceQuotient : Tape.lookupOutput ≠ quotient) + (notSourceRemainder : Tape.lookupOutput ≠ remainder) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : + divisionOutput d ports quotient remainder base n sourceSuffix quotientSuffix remainderSuffix + (ports .lookupOutput) = encodeWord 0 ++ sourceSuffix := by + exact MachineFixedDivMod.unaryTapes_source _ _ _ + (fun h => notSourceQuotient (portsInjective h)) + (fun h => notSourceRemainder (portsInjective h)) _ _ _ _ _ _ _ + +@[simp] theorem divisionOutput_quotient (d : Nat) (ports : Tape → K) + (portsInjective : Function.Injective ports) (quotient remainder : Tape) + (distinct : quotient ≠ remainder) (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : + divisionOutput d ports quotient remainder base n sourceSuffix quotientSuffix remainderSuffix + (ports quotient) = encodeWord (n / degree d) ++ quotientSuffix := by + exact MachineFixedDivMod.unaryTapes_quotient _ _ _ + (fun h => distinct (portsInjective h)) _ _ _ _ _ _ _ + +@[simp] theorem divisionOutput_remainder (d : Nat) (ports : Tape → K) + (quotient remainder : Tape) (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : + divisionOutput d ports quotient remainder base n sourceSuffix quotientSuffix remainderSuffix + (ports remainder) = encodeWord (n % degree d) ++ remainderSuffix := by + exact MachineFixedDivMod.unaryTapes_remainder _ _ _ _ _ _ _ _ _ _ + +theorem divisionOutput_other (d : Nat) (ports : Tape → K) (quotient remainder : Tape) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) (other : K) + (notSource : other ≠ ports .lookupOutput) (notQuotient : other ≠ ports quotient) + (notRemainder : other ≠ ports remainder) : + divisionOutput d ports quotient remainder base n sourceSuffix quotientSuffix remainderSuffix + other = base other := by + exact MachineFixedDivMod.unaryTapes_other _ _ _ other notSource notQuotient notRemainder + _ _ _ _ _ _ _ + +def firstDivisionInTime {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atProgram : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base (ports .lookupOutput) = encodeWord n ++ sourceSuffix) + (quotientInput : base (ports .quotientFirst) = encodeWord 0 ++ quotientSuffix) + (remainderInput : base (ports .remainderFirst) = encodeWord 0 ++ remainderSuffix) + (ambient : ρ) (control : Control d) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels .firstScan), divisionState positive ambient control register, base⟩ + (some ⟨some (labels .clearQuery), divisionState positive ambient + (receiveFirst control (MachineFixedDivMod.residue (degree d) + (Nat.mul_pos positive positive) n)) none, + divisionOutput d ports .quotientFirst .remainderFirst base n + sourceSuffix quotientSuffix remainderSuffix⟩) (n + 2) where + steps := n + 2 + evals_in_steps := firstDivisionTrace positive H ports portsInjective labels exit target atProgram + base n sourceSuffix quotientSuffix remainderSuffix sourceInput quotientInput remainderInput + ambient control register + steps_le_m := Nat.le_refl _ + +def secondDivisionInTime {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atProgram : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base (ports .lookupOutput) = encodeWord n ++ sourceSuffix) + (quotientInput : base (ports .quotientSecond) = encodeWord 0 ++ quotientSuffix) + (remainderInput : base (ports .remainderSecond) = encodeWord 0 ++ remainderSuffix) + (ambient : ρ) (control : Control d) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels .secondScan), divisionState positive ambient control register, base⟩ + (some ⟨some (labels (.outputEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry))), + divisionState positive ambient + (receiveSecond H control (MachineFixedDivMod.residue (degree d) + (Nat.mul_pos positive positive) n)) none, + divisionOutput d ports .quotientSecond .remainderSecond base n + sourceSuffix quotientSuffix remainderSuffix⟩) (n + 2) where + steps := n + 2 + evals_in_steps := secondDivisionTrace positive H ports portsInjective labels exit target atProgram + base n sourceSuffix quotientSuffix remainderSuffix sourceInput quotientInput remainderInput + ambient control register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowEmit.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowEmit.lean new file mode 100644 index 0000000000000000000000000000000000000000..17705718aec85c54b90c6b0a51d91742164a981e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowEmit.lean @@ -0,0 +1,293 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowProgram + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.AlphabetTable + +def emitSteps (n : Nat) : Nat := 3 * (n + 1) + 6 + +theorem affinePlan_bits {σ : Type} {bound : Nat} (coefficient : Nat) + (offset : σ → Fin bound) (n : Nat) (ambient : σ) : + Emitter.prefixBits (affinePlan coefficient offset) (fun _ : Fin 1 => n) ambient 3 = + encodeWord (coefficient * n + (offset ambient).val) := by + change Emitter.prefixBits + (Emitter.listCommands (Emitter.affineCommands [((0 : Fin 1), coefficient)] offset)) + (fun _ : Fin 1 => n) ambient + (Emitter.affineCommands [((0 : Fin 1), coefficient)] offset).length = _ + rw [Emitter.bits_listCommands, Emitter.affineCommands_bits] + simp [Emitter.affineValue] + +theorem affinePlan_steps {σ : Type} {bound : Nat} (coefficient : Nat) + (offset : σ → Fin bound) (n : Nat) : + Emitter.prefixSteps (affinePlan coefficient offset) (fun _ : Fin 1 => n) 3 + 1 = + emitSteps n := by + simp [affinePlan, Emitter.prefixSteps, Emitter.commandAt, Emitter.listCommands, + Emitter.affineCommands, Emitter.commandSteps, emitSteps] + +def emittedWord {K : Type} [DecidableEq K] + (target : K) (base : K → List Bool) (value : Nat) : K → List Bool := + Function.update base target ((encodeWord value).reverse ++ base target) + +@[simp] theorem emittedWord_target {K : Type} [DecidableEq K] + (target : K) (base : K → List Bool) (value : Nat) : + emittedWord target base value target = (encodeWord value).reverse ++ base target := by + simp [emittedWord] + +theorem emittedWord_other {K : Type} [DecidableEq K] + (target : K) (base : K → List Bool) (value : Nat) + (tape : K) (different : tape ≠ target) : + emittedWord target base value tape = base tape := by + simp [emittedWord, different] + +variable {ρ : Type} [Fintype ρ] {d : Nat} + +@[simp] theorem program_firstEmit (positive : 0 < d) (H : Table (cloudSize d) d) + (label : Emitter.Label 3 (degree d)) : + program (ρ := ρ) positive H (.firstEmit label) = + Emitter.statement (firstPlan ρ d) (fun _ : Fin 1 => Tape.inputVertex) + .emitScratch .queryReverse Label.firstEmit (some Label.firstReverse) label := rfl + +@[simp] theorem program_secondEmit (positive : 0 < d) (H : Table (cloudSize d) d) + (label : Emitter.Label 3 (degree d)) : + program (ρ := ρ) positive H (.secondEmit label) = + Emitter.statement (secondPlan ρ d) (fun _ : Fin 1 => Tape.quotientFirst) + .emitScratch .queryReverse Label.secondEmit (some Label.secondReverse) label := rfl + +@[simp] theorem program_outputEmit (positive : 0 < d) (H : Table (cloudSize d) d) + (label : Emitter.Label 3 (rowFactor d)) : + program (ρ := ρ) positive H (.outputEmit label) = + Emitter.statement (outputPlan ρ d) (fun _ : Fin 1 => Tape.quotientSecond) + .emitScratch .output Label.outputEmit (some (Label.cleanup 0)) label := rfl + +section Embedded + +variable {K Λ : Type} [DecidableEq K] + +theorem firstEmitTraceAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atLabels : ∀ l, target (labels l) = statement positive H ports labels exit l) + (n : Nat) (base : K → List Bool) + (source : base (ports .inputVertex) = encodeWord n) + (scratch : base (ports .emitScratch) = []) + (ambient : Ambient ρ d × Fin (degree d)) : + (MachineComposition.advance (TM2.step target))^[emitSteps n] + (some ⟨some (labels (.firstEmit (Emitter.labelAt 3 _ 0 .entry))), + ((ambient, ()), none), base⟩) = + some ⟨some (labels .firstReverse), ((ambient, ()), none), + emittedWord (ports .queryReverse) base (firstAddress n ambient.1.2)⟩ := by + have code : ∀ l, target (labels (.firstEmit l)) = + Emitter.statement (firstPlan ρ d) (fun _ : Fin 1 => ports .inputVertex) + (ports .emitScratch) (ports .queryReverse) (fun k => labels (.firstEmit k)) + (some (labels .firstReverse)) l := by + intro l + rw [atLabels] + rfl + have run := Emitter.planTrace (firstPlan ρ d) (fun _ : Fin 1 => ports .inputVertex) + (ports .emitScratch) (ports .queryReverse) + (by intro i h; have h' := portsInjective h; cases h') + (by intro i h; have h' := portsInjective h; cases h') + (by intro h; have h' := portsInjective h; cases h') + (fun k => labels (.firstEmit k)) (some (labels .firstReverse)) target code + (fun _ : Fin 1 => n) base (fun _ => source) scratch ambient + simpa only [firstPlan, affinePlan_steps, affinePlan_bits, Emitter.resultTapes, + emittedWord, firstAddress] using run + +theorem secondEmitTraceAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atLabels : ∀ l, target (labels l) = statement positive H ports labels exit l) + (n : Nat) (base : K → List Bool) + (source : base (ports .quotientFirst) = encodeWord n) + (scratch : base (ports .emitScratch) = []) + (ambient : Ambient ρ d × Fin (degree d)) : + (MachineComposition.advance (TM2.step target))^[emitSteps n] + (some ⟨some (labels (.secondEmit (Emitter.labelAt 3 _ 0 .entry))), + ((ambient, ()), none), base⟩) = + some ⟨some (labels .secondReverse), ((ambient, ()), none), + emittedWord (ports .queryReverse) base (secondAddress n ambient.1.2)⟩ := by + have code : ∀ l, target (labels (.secondEmit l)) = + Emitter.statement (secondPlan ρ d) (fun _ : Fin 1 => ports .quotientFirst) + (ports .emitScratch) (ports .queryReverse) (fun k => labels (.secondEmit k)) + (some (labels .secondReverse)) l := by + intro l + rw [atLabels] + rfl + have run := Emitter.planTrace (secondPlan ρ d) (fun _ : Fin 1 => ports .quotientFirst) + (ports .emitScratch) (ports .queryReverse) + (by intro i h; have h' := portsInjective h; cases h') + (by intro i h; have h' := portsInjective h; cases h') + (by intro h; have h' := portsInjective h; cases h') + (fun k => labels (.secondEmit k)) (some (labels .secondReverse)) target code + (fun _ : Fin 1 => n) base (fun _ => source) scratch ambient + simpa only [secondPlan, affinePlan_steps, affinePlan_bits, Emitter.resultTapes, + emittedWord, secondAddress] using run + +theorem outputEmitTraceAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atLabels : ∀ l, target (labels l) = statement positive H ports labels exit l) + (n : Nat) (base : K → List Bool) + (source : base (ports .quotientSecond) = encodeWord n) + (scratch : base (ports .emitScratch) = []) + (ambient : Ambient ρ d × Fin (degree d)) : + (MachineComposition.advance (TM2.step target))^[emitSteps n] + (some ⟨some (labels (.outputEmit (Emitter.labelAt 3 _ 0 .entry))), + ((ambient, ()), none), base⟩) = + some ⟨some (labels (.cleanup 0)), ((ambient, ()), none), + emittedWord (ports .output) base (outputAddress n ambient.1.2)⟩ := by + have code : ∀ l, target (labels (.outputEmit l)) = + Emitter.statement (outputPlan ρ d) (fun _ : Fin 1 => ports .quotientSecond) + (ports .emitScratch) (ports .output) (fun k => labels (.outputEmit k)) + (some (labels (.cleanup 0))) l := by + intro l + rw [atLabels] + rfl + have run := Emitter.planTrace (outputPlan ρ d) (fun _ : Fin 1 => ports .quotientSecond) + (ports .emitScratch) (ports .output) + (by intro i h; have h' := portsInjective h; cases h') + (by intro i h; have h' := portsInjective h; cases h') + (by intro h; have h' := portsInjective h; cases h') + (fun k => labels (.outputEmit k)) (some (labels (.cleanup 0))) target code + (fun _ : Fin 1 => n) base (fun _ => source) scratch ambient + simpa only [outputPlan, affinePlan_steps, affinePlan_bits, Emitter.resultTapes, + emittedWord, outputAddress] using run + +def firstEmitInTimeAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atLabels : ∀ l, target (labels l) = statement positive H ports labels exit l) + (n : Nat) (base : K → List Bool) + (source : base (ports .inputVertex) = encodeWord n) + (scratch : base (ports .emitScratch) = []) + (ambient : Ambient ρ d × Fin (degree d)) : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels (.firstEmit (Emitter.labelAt 3 _ 0 .entry))), ((ambient, ()), none), base⟩ + (some ⟨some (labels .firstReverse), ((ambient, ()), none), + emittedWord (ports .queryReverse) base (firstAddress n ambient.1.2)⟩) (emitSteps n) where + steps := emitSteps n + evals_in_steps := firstEmitTraceAt positive H ports portsInjective labels exit target atLabels + n base source scratch ambient + steps_le_m := Nat.le_refl _ + +def secondEmitInTimeAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atLabels : ∀ l, target (labels l) = statement positive H ports labels exit l) + (n : Nat) (base : K → List Bool) + (source : base (ports .quotientFirst) = encodeWord n) + (scratch : base (ports .emitScratch) = []) + (ambient : Ambient ρ d × Fin (degree d)) : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels (.secondEmit (Emitter.labelAt 3 _ 0 .entry))), ((ambient, ()), none), base⟩ + (some ⟨some (labels .secondReverse), ((ambient, ()), none), + emittedWord (ports .queryReverse) base (secondAddress n ambient.1.2)⟩) (emitSteps n) where + steps := emitSteps n + evals_in_steps := secondEmitTraceAt positive H ports portsInjective labels exit target atLabels + n base source scratch ambient + steps_le_m := Nat.le_refl _ + +def outputEmitInTimeAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (portsInjective : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (atLabels : ∀ l, target (labels l) = statement positive H ports labels exit l) + (n : Nat) (base : K → List Bool) + (source : base (ports .quotientSecond) = encodeWord n) + (scratch : base (ports .emitScratch) = []) + (ambient : Ambient ρ d × Fin (degree d)) : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels (.outputEmit (Emitter.labelAt 3 _ 0 .entry))), ((ambient, ()), none), base⟩ + (some ⟨some (labels (.cleanup 0)), ((ambient, ()), none), + emittedWord (ports .output) base (outputAddress n ambient.1.2)⟩) (emitSteps n) where + steps := emitSteps n + evals_in_steps := outputEmitTraceAt positive H ports portsInjective labels exit target atLabels + n base source scratch ambient + steps_le_m := Nat.le_refl _ + +end Embedded + +theorem firstEmitTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (n : Nat) (base : Tape → List Bool) + (source : base .inputVertex = encodeWord n) (scratch : base .emitScratch = []) + (ambient : Ambient ρ d × Fin (degree d)) : + (MachineComposition.advance (TM2.step (program positive H)))^[emitSteps n] + (some ⟨some (.firstEmit (Emitter.labelAt 3 _ 0 .entry)), + ((ambient, ()), none), base⟩) = + some ⟨some .firstReverse, ((ambient, ()), none), + emittedWord .queryReverse base (firstAddress n ambient.1.2)⟩ := by + exact firstEmitTraceAt positive H id Function.injective_id id none (program positive H) + (fun _ => rfl) n base source scratch ambient + +theorem secondEmitTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (n : Nat) (base : Tape → List Bool) + (source : base .quotientFirst = encodeWord n) (scratch : base .emitScratch = []) + (ambient : Ambient ρ d × Fin (degree d)) : + (MachineComposition.advance (TM2.step (program positive H)))^[emitSteps n] + (some ⟨some (.secondEmit (Emitter.labelAt 3 _ 0 .entry)), + ((ambient, ()), none), base⟩) = + some ⟨some .secondReverse, ((ambient, ()), none), + emittedWord .queryReverse base (secondAddress n ambient.1.2)⟩ := by + exact secondEmitTraceAt positive H id Function.injective_id id none (program positive H) + (fun _ => rfl) n base source scratch ambient + +theorem outputEmitTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (n : Nat) (base : Tape → List Bool) + (source : base .quotientSecond = encodeWord n) (scratch : base .emitScratch = []) + (ambient : Ambient ρ d × Fin (degree d)) : + (MachineComposition.advance (TM2.step (program positive H)))^[emitSteps n] + (some ⟨some (.outputEmit (Emitter.labelAt 3 _ 0 .entry)), + ((ambient, ()), none), base⟩) = + some ⟨some (.cleanup 0), ((ambient, ()), none), + emittedWord .output base (outputAddress n ambient.1.2)⟩ := by + exact outputEmitTraceAt positive H id Function.injective_id id none (program positive H) + (fun _ => rfl) n base source scratch ambient + +def firstEmitInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (n : Nat) (base : Tape → List Bool) + (source : base .inputVertex = encodeWord n) (scratch : base .emitScratch = []) + (ambient : Ambient ρ d × Fin (degree d)) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.firstEmit (Emitter.labelAt 3 _ 0 .entry)), ((ambient, ()), none), base⟩ + (some ⟨some .firstReverse, ((ambient, ()), none), + emittedWord .queryReverse base (firstAddress n ambient.1.2)⟩) (emitSteps n) where + steps := emitSteps n + evals_in_steps := firstEmitTrace positive H n base source scratch ambient + steps_le_m := Nat.le_refl _ + +def secondEmitInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (n : Nat) (base : Tape → List Bool) + (source : base .quotientFirst = encodeWord n) (scratch : base .emitScratch = []) + (ambient : Ambient ρ d × Fin (degree d)) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.secondEmit (Emitter.labelAt 3 _ 0 .entry)), ((ambient, ()), none), base⟩ + (some ⟨some .secondReverse, ((ambient, ()), none), + emittedWord .queryReverse base (secondAddress n ambient.1.2)⟩) (emitSteps n) where + steps := emitSteps n + evals_in_steps := secondEmitTrace positive H n base source scratch ambient + steps_le_m := Nat.le_refl _ + +def outputEmitInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (n : Nat) (base : Tape → List Bool) + (source : base .quotientSecond = encodeWord n) (scratch : base .emitScratch = []) + (ambient : Ambient ρ d × Fin (degree d)) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.outputEmit (Emitter.labelAt 3 _ 0 .entry)), ((ambient, ()), none), base⟩ + (some ⟨some (.cleanup 0), ((ambient, ()), none), + emittedWord .output base (outputAddress n ambient.1.2)⟩) (emitSteps n) where + steps := emitSteps n + evals_in_steps := outputEmitTrace positive H n base source scratch ambient + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowFrames.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowFrames.lean new file mode 100644 index 0000000000000000000000000000000000000000..584cc4d90469832d12cb314de12de2140eeeb0af --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowFrames.lean @@ -0,0 +1,383 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowDivision +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowEmit +import OAI.Combinatorics.IndependentSets.Machines.Reverse + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords + +structure RowData (v d : Nat) where + oldTable : Table v (degree d) + smallTable : Table (cloudSize d) d + inputVertex : Fin v + inputCloud : Fin (cloudSize d) + inputPort : Fin (degree d) + +def rowData {v d : Nat} (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (cloud : Fin (cloudSize d)) (port : Fin (degree d)) : RowData v d := + ⟨G, H, vertex, cloud, port⟩ + +namespace RowData + +variable {v d : Nat} (r : RowData v d) + +def control0 : Control d := start r.smallTable r.inputCloud r.inputPort +def firstRow : Fin (v * degree d) := rowIndex v (degree d) (r.inputVertex, firstOffset r.control0) +def firstValue : Nat := (reverseIndex r.oldTable r.firstRow).val +def firstPair : Fin v × Fin (degree d) := lookup r.oldTable (r.inputVertex, firstOffset r.control0) +def firstVertex : Fin v := r.firstPair.1 +def firstReturn : Fin (degree d) := r.firstPair.2 +def control1 : Control d := receiveFirst r.control0 r.firstReturn +def secondRow : Fin (v * degree d) := rowIndex v (degree d) (r.firstVertex, secondOffset r.control1) +def secondValue : Nat := (reverseIndex r.oldTable r.secondRow).val +def secondPair : Fin v × Fin (degree d) := lookup r.oldTable (r.firstVertex, secondOffset r.control1) +def secondVertex : Fin v := r.secondPair.1 +def secondReturn : Fin (degree d) := r.secondPair.2 +def control2 : Control d := receiveSecond r.smallTable r.control1 r.secondReturn +def query1 : Nat := firstAddress r.inputVertex.val r.control0 +def query2 : Nat := secondAddress r.firstVertex.val r.control1 +def finalValue : Nat := outputAddress r.secondVertex.val r.control2 +def tableLength : Nat := (encodeWords (rotationWords r.oldTable)).length + +theorem query1_eq_firstRow : r.query1 = r.firstRow.val := + firstAddress_eq_rowIndex r.inputVertex r.control0 + +theorem query2_eq_secondRow : r.query2 = r.secondRow.val := + secondAddress_eq_rowIndex r.firstVertex r.control1 + +@[simp] theorem firstValue_div_degree : r.firstValue / degree d = r.firstVertex.val := rfl +@[simp] theorem firstValue_mod_degree : r.firstValue % degree d = r.firstReturn.val := rfl +@[simp] theorem secondValue_div_degree : r.secondValue / degree d = r.secondVertex.val := rfl +@[simp] theorem secondValue_mod_degree : r.secondValue % degree d = r.secondReturn.val := rfl + +theorem firstReturn_eq_residue (positive : 0 < d) : + r.firstReturn = MachineFixedDivMod.residue (degree d) (Nat.mul_pos positive positive) + r.firstValue := Fin.ext rfl + +theorem secondReturn_eq_residue (positive : 0 < d) : + r.secondReturn = MachineFixedDivMod.residue (degree d) (Nat.mul_pos positive positive) + r.secondValue := Fin.ext rfl + +theorem receiveFirst_residue_eq_control1 (positive : 0 < d) : + receiveFirst r.control0 (MachineFixedDivMod.residue (degree d) + (Nat.mul_pos positive positive) r.firstValue) = r.control1 := by + rw [← r.firstReturn_eq_residue positive] + rfl + +theorem receiveSecond_residue_eq_control2 (positive : 0 < d) : + receiveSecond r.smallTable r.control1 (MachineFixedDivMod.residue (degree d) + (Nat.mul_pos positive positive) r.secondValue) = r.control2 := by + rw [← r.secondReturn_eq_residue positive] + rfl + +theorem firstSelected : (rotationWords r.oldTable)[r.query1]? = some r.firstValue := by + rw [query1_eq_firstRow] + exact rotationWords_getElem? r.oldTable r.firstRow + +theorem secondSelected : (rotationWords r.oldTable)[r.query2]? = some r.secondValue := by + rw [query2_eq_secondRow] + exact rotationWords_getElem? r.oldTable r.secondRow + +theorem evaluateRow_eq : evaluateRow r.oldTable r.smallTable r.inputVertex r.inputCloud r.inputPort = + (r.secondVertex, r.control2) := rfl + +theorem finalValue_eq_step_reverseIndex : + r.finalValue = (reverseIndex (step r.oldTable r.smallTable) + (rowIndex (v * cloudSize d) (degree d) + (rowIndex v (cloudSize d) (r.inputVertex, r.inputCloud), r.inputPort))).val := by + simpa only [evaluateRow_eq, finalValue] using outputAddress_eq_step_reverseIndex + r.oldTable r.smallTable r.inputVertex r.inputCloud r.inputPort + +theorem rows_le_tableLength : v * degree d ≤ r.tableLength := by + simp only [tableLength, encodeWords_length, rotationWords_length] + omega + +theorem query1_le_tableLength : r.query1 ≤ r.tableLength := by + rw [query1_eq_firstRow] + exact r.firstRow.isLt.le.trans r.rows_le_tableLength + +theorem query2_le_tableLength : r.query2 ≤ r.tableLength := by + rw [query2_eq_secondRow] + exact r.secondRow.isLt.le.trans r.rows_le_tableLength + +theorem firstValue_le_tableLength : r.firstValue ≤ r.tableLength := + (reverseIndex r.oldTable r.firstRow).isLt.le.trans r.rows_le_tableLength + +theorem secondValue_le_tableLength : r.secondValue ≤ r.tableLength := + (reverseIndex r.oldTable r.secondRow).isLt.le.trans r.rows_le_tableLength + +theorem inputVertex_le_tableLength : r.inputVertex.val ≤ r.tableLength := by + have hq : 1 ≤ degree d := Nat.zero_lt_of_lt r.inputPort.isLt + have hv : v ≤ v * degree d := by simpa using Nat.mul_le_mul_left v hq + exact r.inputVertex.isLt.le.trans (hv.trans r.rows_le_tableLength) + +theorem firstVertex_le_tableLength : r.firstVertex.val ≤ r.tableLength := by + rw [← firstValue_div_degree] + exact (Nat.div_le_self r.firstValue (degree d)).trans r.firstValue_le_tableLength + +theorem secondVertex_le_tableLength : r.secondVertex.val ≤ r.tableLength := by + rw [← secondValue_div_degree] + exact (Nat.div_le_self r.secondValue (degree d)).trans r.secondValue_le_tableLength + +theorem firstReturn_le_tableLength : r.firstReturn.val ≤ r.tableLength := by + rw [← firstValue_mod_degree] + exact (Nat.mod_le r.firstValue (degree d)).trans r.firstValue_le_tableLength + +theorem secondReturn_le_tableLength : r.secondReturn.val ≤ r.tableLength := by + rw [← secondValue_mod_degree] + exact (Nat.mod_le r.secondValue (degree d)).trans r.secondValue_le_tableLength + +end RowData + +variable {v d : Nat} + +def frameContents (r : RowData v d) (output : List Bool) + (qr qi lo q1 q2 r1 r2 : List Bool) : Tape → List Bool + | .inputVertex => encodeWord r.inputVertex.val + | .table => encodeWords (rotationWords r.oldTable) + | .output => output + | .queryReverse => qr + | .queryIndex => qi + | .lookupOutput => lo + | .quotientFirst => q1 + | .quotientSecond => q2 + | .remainderFirst => r1 + | .remainderSecond => r2 + | _ => [] + +def frame0 (r : RowData v d) (output : List Bool) : Tape → List Bool := + frameContents r output [] [] [] [] [] [] [] +def frame1 (r : RowData v d) (output : List Bool) : Tape → List Bool := + initializedTapes id (frame0 r output) +def frame2 (r : RowData v d) (output : List Bool) : Tape → List Bool := + emittedWord .queryReverse (frame1 r output) r.query1 +def frame3 (r : RowData v d) (output : List Bool) : Tape → List Bool := + Reduction.MachineTransfer.tapesAt .queryReverse .queryIndex (frame2 r output) [] + (encodeWord r.query1) +def frame4 (r : RowData v d) (output : List Bool) : Tape → List Bool := + lookupResultTapes id (frame3 r output) r.firstValue [] +def frame5 (r : RowData v d) (output : List Bool) : Tape → List Bool := + divisionOutput d id .quotientFirst .remainderFirst (frame4 r output) r.firstValue [] [] [] +def frame6 (r : RowData v d) (output : List Bool) : Tape → List Bool := + clearedQueryTapes id (frame5 r output) +def frame7 (r : RowData v d) (output : List Bool) : Tape → List Bool := + emittedWord .queryReverse (frame6 r output) r.query2 +def frame8 (r : RowData v d) (output : List Bool) : Tape → List Bool := + Reduction.MachineTransfer.tapesAt .queryReverse .queryIndex (frame7 r output) [] + (encodeWord r.query2) +def frame9 (r : RowData v d) (output : List Bool) : Tape → List Bool := + lookupResultTapes id (frame8 r output) r.secondValue [] +def frame10 (r : RowData v d) (output : List Bool) : Tape → List Bool := + divisionOutput d id .quotientSecond .remainderSecond (frame9 r output) r.secondValue [] [] [] +def frame11 (r : RowData v d) (output : List Bool) : Tape → List Bool := + emittedWord .output (frame10 r output) r.finalValue +def frame12 (r : RowData v d) (output : List Bool) : Tape → List Bool := + cleanupTapes id (frame11 r output) + +private theorem lookupResultTapes_id_eq (base : Tape → List Bool) + (value : Nat) (suffix : List Bool) : + lookupResultTapes id base value suffix = + Function.update + (Function.update (Function.update base .queryIndex (encodeWord 0 ++ suffix)) + .lookupWork []) + .lookupOutput (encodeWord value ++ base .lookupOutput) := rfl + +@[simp] theorem frame1_eq (r : RowData v d) (output : List Bool) : + frame1 r output = frameContents r output [] [] [] + (encodeWord 0) (encodeWord 0) (encodeWord 0) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame1, frame0, frameContents, initializedTapes, encodeWord] + +@[simp] theorem frame2_eq (r : RowData v d) (output : List Bool) : + frame2 r output = frameContents r output (encodeWord r.query1).reverse [] [] + (encodeWord 0) (encodeWord 0) (encodeWord 0) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame2, frameContents, emittedWord] + +@[simp] theorem frame3_eq (r : RowData v d) (output : List Bool) : + frame3 r output = frameContents r output [] (encodeWord r.query1) [] + (encodeWord 0) (encodeWord 0) (encodeWord 0) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame3, frameContents, Reduction.MachineTransfer.tapesAt] + +@[simp] theorem frame4_eq (r : RowData v d) (output : List Bool) : + frame4 r output = frameContents r output [] (encodeWord 0) (encodeWord r.firstValue) + (encodeWord 0) (encodeWord 0) (encodeWord 0) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame4, lookupResultTapes_id_eq, frameContents] + +@[simp] theorem frame5_eq (r : RowData v d) (output : List Bool) : + frame5 r output = frameContents r output [] (encodeWord 0) (encodeWord 0) + (encodeWord r.firstVertex.val) (encodeWord 0) + (encodeWord r.firstReturn.val) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame5, divisionOutput, MachineFixedDivMod.unaryTapes, + MachineFixedDivMod.tapes, MachineCopy.forkTapes, frameContents] + +@[simp] theorem frame6_eq (r : RowData v d) (output : List Bool) : + frame6 r output = frameContents r output [] [] [] (encodeWord r.firstVertex.val) + (encodeWord 0) (encodeWord r.firstReturn.val) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame6, clearedQueryTapes, frameContents, encodeWord] + +@[simp] theorem frame7_eq (r : RowData v d) (output : List Bool) : + frame7 r output = frameContents r output (encodeWord r.query2).reverse [] [] + (encodeWord r.firstVertex.val) (encodeWord 0) + (encodeWord r.firstReturn.val) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame7, emittedWord, frameContents] + +@[simp] theorem frame8_eq (r : RowData v d) (output : List Bool) : + frame8 r output = frameContents r output [] (encodeWord r.query2) [] + (encodeWord r.firstVertex.val) (encodeWord 0) + (encodeWord r.firstReturn.val) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame8, Reduction.MachineTransfer.tapesAt, frameContents] + +@[simp] theorem frame9_eq (r : RowData v d) (output : List Bool) : + frame9 r output = frameContents r output [] (encodeWord 0) (encodeWord r.secondValue) + (encodeWord r.firstVertex.val) (encodeWord 0) + (encodeWord r.firstReturn.val) (encodeWord 0) := by + funext tape + cases tape <;> simp [frame9, lookupResultTapes_id_eq, frameContents] + +@[simp] theorem frame10_eq (r : RowData v d) (output : List Bool) : + frame10 r output = frameContents r output [] (encodeWord 0) (encodeWord 0) + (encodeWord r.firstVertex.val) (encodeWord r.secondVertex.val) + (encodeWord r.firstReturn.val) (encodeWord r.secondReturn.val) := by + funext tape + cases tape <;> simp [frame10, divisionOutput, MachineFixedDivMod.unaryTapes, + MachineFixedDivMod.tapes, MachineCopy.forkTapes, frameContents] + +@[simp] theorem frame11_eq (r : RowData v d) (output : List Bool) : + frame11 r output = frameContents r ((encodeWord r.finalValue).reverse ++ output) + [] (encodeWord 0) (encodeWord 0) + (encodeWord r.firstVertex.val) (encodeWord r.secondVertex.val) + (encodeWord r.firstReturn.val) (encodeWord r.secondReturn.val) := by + funext tape + cases tape <;> simp [frame11, emittedWord, frameContents] + +@[simp] theorem frame12_eq (r : RowData v d) (output : List Bool) : + frame12 r output = frameContents r ((encodeWord r.finalValue).reverse ++ output) + [] [] [] [] [] [] [] := by + funext tape + cases tape <;> simp [frame12, cleanupTapes, frameContents] + +theorem final_frame_eq (r : RowData v d) (output : List Bool) : + frame12 r output = emittedWord .output (frame0 r output) r.finalValue := by + funext tape + cases tape <;> simp [frame0, emittedWord, frameContents] + +@[simp] theorem frame0_inputVertex (r : RowData v d) (output : List Bool) : + frame0 r output .inputVertex = encodeWord r.inputVertex.val := rfl + +@[simp] theorem frame0_table (r : RowData v d) (output : List Bool) : + frame0 r output .table = encodeWords (rotationWords r.oldTable) := rfl + +@[simp] theorem frame0_output (r : RowData v d) (output : List Bool) : + frame0 r output .output = output := rfl + +@[simp] theorem frame1_inputVertex (r : RowData v d) (output : List Bool) : + frame1 r output .inputVertex = encodeWord r.inputVertex.val := by simp [frameContents] + +@[simp] theorem frame1_emitScratch (r : RowData v d) (output : List Bool) : + frame1 r output .emitScratch = [] := by simp [frameContents] + +@[simp] theorem frame2_queryReverse (r : RowData v d) (output : List Bool) : + frame2 r output .queryReverse = (encodeWord r.query1).reverse := by simp [frameContents] + +@[simp] theorem frame2_queryIndex (r : RowData v d) (output : List Bool) : + frame2 r output .queryIndex = [] := by simp [frameContents] + +@[simp] theorem frame3_table (r : RowData v d) (output : List Bool) : + frame3 r output .table = encodeWords (rotationWords r.oldTable) := by simp [frameContents] + +@[simp] theorem frame3_lookupRestore (r : RowData v d) (output : List Bool) : + frame3 r output .lookupRestore = [] := by simp [frameContents] + +@[simp] theorem frame3_lookupWork (r : RowData v d) (output : List Bool) : + frame3 r output .lookupWork = [] := by simp [frameContents] + +@[simp] theorem frame3_lookupOutput (r : RowData v d) (output : List Bool) : + frame3 r output .lookupOutput = [] := by simp [frameContents] + +@[simp] theorem frame3_queryIndex (r : RowData v d) (output : List Bool) : + frame3 r output .queryIndex = encodeWord r.query1 := by simp [frameContents] + +@[simp] theorem frame4_lookupOutput (r : RowData v d) (output : List Bool) : + frame4 r output .lookupOutput = encodeWord r.firstValue := by simp [frameContents] + +@[simp] theorem frame4_quotientFirst (r : RowData v d) (output : List Bool) : + frame4 r output .quotientFirst = encodeWord 0 := by simp [frameContents] + +@[simp] theorem frame4_remainderFirst (r : RowData v d) (output : List Bool) : + frame4 r output .remainderFirst = encodeWord 0 := by simp [frameContents] + +@[simp] theorem frame6_quotientFirst (r : RowData v d) (output : List Bool) : + frame6 r output .quotientFirst = encodeWord r.firstVertex.val := by simp [frameContents] + +@[simp] theorem frame6_emitScratch (r : RowData v d) (output : List Bool) : + frame6 r output .emitScratch = [] := by simp [frameContents] + +@[simp] theorem frame7_queryReverse (r : RowData v d) (output : List Bool) : + frame7 r output .queryReverse = (encodeWord r.query2).reverse := by simp [frameContents] + +@[simp] theorem frame7_queryIndex (r : RowData v d) (output : List Bool) : + frame7 r output .queryIndex = [] := by simp [frameContents] + +@[simp] theorem frame8_table (r : RowData v d) (output : List Bool) : + frame8 r output .table = encodeWords (rotationWords r.oldTable) := by simp [frameContents] + +@[simp] theorem frame8_lookupRestore (r : RowData v d) (output : List Bool) : + frame8 r output .lookupRestore = [] := by simp [frameContents] + +@[simp] theorem frame8_lookupWork (r : RowData v d) (output : List Bool) : + frame8 r output .lookupWork = [] := by simp [frameContents] + +@[simp] theorem frame8_lookupOutput (r : RowData v d) (output : List Bool) : + frame8 r output .lookupOutput = [] := by simp [frameContents] + +@[simp] theorem frame8_queryIndex (r : RowData v d) (output : List Bool) : + frame8 r output .queryIndex = encodeWord r.query2 := by simp [frameContents] + +@[simp] theorem frame9_lookupOutput (r : RowData v d) (output : List Bool) : + frame9 r output .lookupOutput = encodeWord r.secondValue := by simp [frameContents] + +@[simp] theorem frame9_quotientSecond (r : RowData v d) (output : List Bool) : + frame9 r output .quotientSecond = encodeWord 0 := by simp [frameContents] + +@[simp] theorem frame9_remainderSecond (r : RowData v d) (output : List Bool) : + frame9 r output .remainderSecond = encodeWord 0 := by simp [frameContents] + +@[simp] theorem frame10_quotientSecond (r : RowData v d) (output : List Bool) : + frame10 r output .quotientSecond = encodeWord r.secondVertex.val := by simp [frameContents] + +@[simp] theorem frame10_emitScratch (r : RowData v d) (output : List Bool) : + frame10 r output .emitScratch = [] := by simp [frameContents] + +@[simp] theorem frame10_output (r : RowData v d) (output : List Bool) : + frame10 r output .output = output := by simp [frameContents] + +theorem final_dirty_word_length_le (r : RowData v d) (output : List Bool) (i : Fin 6) : + ((frame11 r output) (dirtyTape i)).length ≤ r.tableLength + 1 := by + have h1 := r.firstVertex_le_tableLength + have h2 := r.secondVertex_le_tableLength + have h3 := r.firstReturn_le_tableLength + have h4 := r.secondReturn_le_tableLength + fin_cases i <;> simp only [frame11_eq, dirtyTape, frameContents, encodeWord_length] <;> omega + +theorem cleanupSteps_le_tableLength (r : RowData v d) (output : List Bool) : + cleanupSteps id (frame11 r output) ≤ 6 * (r.tableLength + 1) + 6 := by + have h1 := r.firstVertex_le_tableLength + have h2 := r.secondVertex_le_tableLength + have h3 := r.firstReturn_le_tableLength + have h4 := r.secondReturn_le_tableLength + simp only [cleanupSteps, frame11_eq, id_eq, frameContents, encodeWord_length] + omega + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowLookup.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowLookup.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9ed36e465471721662fd0b1ac6e6c0e085ab031 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowLookup.lean @@ -0,0 +1,140 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableWords +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowProgram + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords +open MachineComposition + +def lookupPhaseLabel {d : Nat} (second : Bool) + (l : MachinePreservingLookupClean.Label) : Label d := + if second then .secondLookup l else .firstLookup l + +def scanPhaseLabel {d : Nat} (second : Bool) : Label d := + if second then .secondScan else .firstScan + +def reversePhaseLabel {d : Nat} (second : Bool) : Label d := + if second then .secondReverse else .firstReverse + +def lookupPhasePort {d : Nat} (second : Bool) (control : Control d) : Fin (degree d) := + if second then secondOffset control else firstOffset control + +def lookupPhaseAddress {d : Nat} (second : Bool) (vertex : Nat) (control : Control d) : Nat := + if second then secondAddress vertex control else firstAddress vertex control + +theorem lookupPhaseAddress_eq_rowIndex {v d : Nat} (second : Bool) + (vertex : Fin v) (control : Control d) : + lookupPhaseAddress second vertex.val control = + (rowIndex v (degree d) (vertex, lookupPhasePort second control)).val := by + cases second + · exact firstAddress_eq_rowIndex vertex control + · exact secondAddress_eq_rowIndex vertex control + +theorem lookupTape_injective : Function.Injective lookupTape := by decide + +variable {K Λ ρ : Type} [DecidableEq K] [Fintype ρ] + +def lookupResultTapes (ports : Tape → K) (base : K → List Bool) + (value : Nat) (indexSuffix : List Bool) : K → List Bool := + MachinePreservingLookup.initialTapes (ports ∘ lookupTape) base 0 indexSuffix [] + (encodeWord value ++ base (ports .lookupOutput)) + +theorem lookupResultTapes_index (ports : Tape → K) (distinct : Function.Injective ports) + (base : K → List Bool) (value : Nat) (indexSuffix : List Bool) : + lookupResultTapes ports base value indexSuffix (ports .queryIndex) = + encodeWord 0 ++ indexSuffix := by + apply MachineLookup.tapes_index + · exact fun h => (by decide : Tape.queryIndex ≠ .lookupWork) (distinct h) + · exact fun h => (by decide : Tape.queryIndex ≠ .lookupOutput) (distinct h) + +theorem lookupResultTapes_work (ports : Tape → K) (distinct : Function.Injective ports) + (base : K → List Bool) (value : Nat) (indexSuffix : List Bool) : + lookupResultTapes ports base value indexSuffix (ports .lookupWork) = [] := by + apply MachineLookup.tapes_source + exact fun h => (by decide : Tape.lookupWork ≠ .lookupOutput) (distinct h) + +theorem lookupResultTapes_output (ports : Tape → K) + (base : K → List Bool) (value : Nat) (indexSuffix : List Bool) : + lookupResultTapes ports base value indexSuffix (ports .lookupOutput) = + encodeWord value ++ base (ports .lookupOutput) := by + apply MachineLookup.tapes_destination + +theorem lookupResultTapes_other (ports : Tape → K) (base : K → List Bool) + (value : Nat) (indexSuffix : List Bool) (p : K) + (hi : p ≠ ports .queryIndex) (hw : p ≠ ports .lookupWork) + (ho : p ≠ ports .lookupOutput) : + lookupResultTapes ports base value indexSuffix p = base p := by + exact MachineLookup.tapes_other _ _ _ p hi hw ho _ _ _ _ + +theorem lookupResultTapes_table (ports : Tape → K) (distinct : Function.Injective ports) + (base : K → List Bool) (value : Nat) (indexSuffix : List Bool) : + lookupResultTapes ports base value indexSuffix (ports .table) = base (ports .table) := by + apply lookupResultTapes_other + all_goals intro h; have := distinct h; cases this + +theorem lookupResultTapes_restore (ports : Tape → K) (distinct : Function.Injective ports) + (base : K → List Bool) (value : Nat) (indexSuffix : List Bool) : + lookupResultTapes ports base value indexSuffix (ports .lookupRestore) = + base (ports .lookupRestore) := by + apply lookupResultTapes_other + all_goals intro h; have := distinct h; cases this + +variable {v d : Nat} (second : Bool) (positive : 0 < d) + (H : Table (cloudSize d) d) (ports : Tape → K) + (distinct : Function.Injective ports) (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ l, target (labels l) = statement positive H ports labels exit l) + (base : K → List Bool) (G : Table v (degree d)) + (tableWord : base (ports .table) = encodeWords (rotationWords G)) + (scratchEmpty : base (ports .lookupRestore) = []) + (x : Fin v × Fin (degree d)) (indexSuffix : List Bool) + (counterWord : base (ports .queryIndex) = + encodeWord (rowIndex v (degree d) x).val ++ indexSuffix) + (workEmpty : base (ports .lookupWork) = []) + (ambient : (Ambient ρ d × Fin (degree d)) × Unit) (register : Option Bool) + +include positive H distinct exit code tableWord scratchEmpty counterWord workEmpty + +theorem lookupPhaseTrace : + (advance (TM2.step target))^[MachinePreservingLookupClean.steps + (rotationWords G) (rowIndex v (degree d) x).val] + (some ⟨some (labels (lookupPhaseLabel second (.run .copyFirst))), + (ambient, register), base⟩) = + some ⟨some (labels (scanPhaseLabel second)), (ambient, none), + lookupResultTapes ports base (reverseIndex G (rowIndex v (degree d) x)).val + indexSuffix⟩ := by + apply MachinePreservingLookupClean.traceAt_fromTapes (ports ∘ lookupTape) + (distinct.comp lookupTape_injective) + (fun l => labels (lookupPhaseLabel second l)) (some (labels (scanPhaseLabel second))) + target + · intro l + cases second + · exact code (.firstLookup l) + · exact code (.secondLookup l) + · exact tableWord + · exact scratchEmpty + · exact rotationWords_getElem? G (rowIndex v (degree d) x) + · exact counterWord + · exact workEmpty + +def lookupPhaseInTime : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels (lookupPhaseLabel second (.run .copyFirst))), + (ambient, register), base⟩ + (some ⟨some (labels (scanPhaseLabel second)), (ambient, none), + lookupResultTapes ports base (reverseIndex G (rowIndex v (degree d) x)).val + indexSuffix⟩) + (6 * (encodeWords (rotationWords G)).length + 4) where + steps := MachinePreservingLookupClean.steps (rotationWords G) (rowIndex v (degree d) x).val + evals_in_steps := lookupPhaseTrace second positive H ports distinct labels exit target code + base G tableWord scratchEmpty x indexSuffix counterWord workEmpty ambient register + steps_le_m := MachinePreservingLookupClean.steps_le (rotationWords G) _ _ + (rotationWords_getElem? G (rowIndex v (degree d) x)) + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowProgram.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b2a0ba7d93f24f79f4097c9e888d39c8c9063b9 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderRowProgram.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Emitter +import OAI.Combinatorics.IndependentSets.Machines.MachinePreservingLookupClean +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderRowControl +import OAI.Combinatorics.IndependentSets.Machines.MachineFixedDivMod + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl + +inductive Tape + | inputVertex | table | output + | emitScratch | queryReverse | queryIndex + | lookupOutput | lookupWork | lookupRestore + | quotientFirst | quotientSecond | remainderFirst | remainderSecond + deriving DecidableEq + +instance : Fintype Tape where + elems := {.inputVertex, .table, .output, .emitScratch, .queryReverse, .queryIndex, + .lookupOutput, .lookupWork, .lookupRestore, .quotientFirst, .quotientSecond, + .remainderFirst, .remainderSecond} + complete tape := by cases tape <;> simp + +inductive Label (d : Nat) + | initialize + | firstEmit (label : PCP.AlphabetTable.Emitter.Label 3 (degree d)) + | firstReverse + | firstLookup (label : MachinePreservingLookupClean.Label) + | firstScan + | firstResidue (r : Fin (degree d)) + | clearQuery + | secondEmit (label : PCP.AlphabetTable.Emitter.Label 3 (degree d)) + | secondReverse + | secondLookup (label : MachinePreservingLookupClean.Label) + | secondScan + | secondResidue (r : Fin (degree d)) + | outputEmit (label : PCP.AlphabetTable.Emitter.Label 3 (rowFactor d)) + | cleanup (i : Fin 6) + | done + deriving DecidableEq, Fintype + +abbrev Ambient (ρ : Type) (d : Nat) := ρ × Control d +abbrev State (ρ : Type) (d : Nat) := + PCP.AlphabetTable.Emitter.State (Ambient ρ d × Fin (degree d)) + +def divisionStates (ρ : Type) (d : Nat) : + MachineFixedDivMod.State (Ambient ρ d × Unit) (degree d) ≃ State ρ d where + toFun s := (((s.1.1.1, s.1.2), ()), s.2) + invFun s := (((s.1.1.1, ()), s.1.1.2), s.2) + left_inv := by rintro ⟨⟨⟨a, u⟩, r⟩, b⟩; cases u; rfl + right_inv := by rintro ⟨⟨⟨a, r⟩, u⟩, b⟩; cases u; rfl + +def firstFinish {ρ : Type} {d : Nat} (s : Ambient ρ d × Unit) + (r : Fin (degree d)) : Ambient ρ d × Unit := + ((s.1.1, receiveFirst s.1.2 r), ()) + +def secondFinish {ρ : Type} {d : Nat} (H : Table (cloudSize d) d) + (s : Ambient ρ d × Unit) (r : Fin (degree d)) : Ambient ρ d × Unit := + ((s.1.1, receiveSecond H s.1.2 r), ()) + +def affinePlan {σ : Type} {bound : Nat} (coefficient : Nat) (offset : σ → Fin bound) : + Fin 3 → PCP.AlphabetTable.Emitter.Command 1 σ bound := + PCP.AlphabetTable.Emitter.listCommands + (PCP.AlphabetTable.Emitter.affineCommands [(0, coefficient)] offset) + +def firstPlan (ρ : Type) (d : Nat) : + Fin 3 → PCP.AlphabetTable.Emitter.Command 1 (Ambient ρ d × Fin (degree d)) (degree d) := + affinePlan (degree d) (fun s => firstOffset s.1.2) + +def secondPlan (ρ : Type) (d : Nat) : + Fin 3 → PCP.AlphabetTable.Emitter.Command 1 (Ambient ρ d × Fin (degree d)) (degree d) := + affinePlan (degree d) (fun s => secondOffset s.1.2) + +def outputPlan (ρ : Type) (d : Nat) : + Fin 3 → PCP.AlphabetTable.Emitter.Command 1 (Ambient ρ d × Fin (degree d)) (rowFactor d) := + affinePlan (rowFactor d) (fun s => outputOffset s.1.2) + +def lookupTape : Fin 5 → Tape + | ⟨0, _⟩ => .table + | ⟨1, _⟩ => .queryIndex + | ⟨2, _⟩ => .lookupWork + | ⟨3, _⟩ => .lookupOutput + | _ => .lookupRestore + +def dirtyTape : Fin 6 → Tape + | ⟨0, _⟩ => .queryIndex + | ⟨1, _⟩ => .lookupOutput + | ⟨2, _⟩ => .quotientFirst + | ⟨3, _⟩ => .quotientSecond + | ⟨4, _⟩ => .remainderFirst + | _ => .remainderSecond + +variable {K Λ ρ : Type} [DecidableEq K] [Fintype ρ] + +def statement {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (labels : Label d → Λ) (exit : Option Λ) : + Label d → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d) + | .initialize => + .push (ports .quotientFirst) (fun _ => false) + (.push (ports .quotientSecond) (fun _ => false) + (.push (ports .remainderFirst) (fun _ => false) + (.push (ports .remainderSecond) (fun _ => false) + (.load (fun s => (s.1, none)) + (.goto fun _ => labels (.firstEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry))))))) + | .firstEmit l => + PCP.AlphabetTable.Emitter.statement (firstPlan ρ d) (fun _ => ports .inputVertex) + (ports .emitScratch) (ports .queryReverse) (fun k => labels (.firstEmit k)) + (some (labels .firstReverse)) l + | .firstReverse => + Reduction.MachineTransfer.loopAt (ports .queryReverse) (ports .queryIndex) + id false (labels .firstReverse) + (some (labels (.firstLookup (.run .copyFirst)))) + | .firstLookup l => + MachinePreservingLookupClean.statement (ports ∘ lookupTape) + (fun k => labels (.firstLookup k)) (some (labels .firstScan)) l + | .firstScan => + MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.scanLoop (degree d) (Nat.mul_pos positive positive) + (ports .lookupOutput) (ports .quotientFirst) (labels .firstScan) + (fun r => labels (.firstResidue r))) + | .firstResidue r => + MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.emitterWithFinish (degree d) (Nat.mul_pos positive positive) + (ports .remainderFirst) (some (labels .clearQuery)) firstFinish r) + | .clearQuery => + .pop (ports .queryIndex) (fun s _ => s) + (.pop (ports .lookupOutput) (fun s _ => s) + (.goto fun _ => labels (.secondEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry)))) + | .secondEmit l => + PCP.AlphabetTable.Emitter.statement (secondPlan ρ d) (fun _ => ports .quotientFirst) + (ports .emitScratch) (ports .queryReverse) (fun k => labels (.secondEmit k)) + (some (labels .secondReverse)) l + | .secondReverse => + Reduction.MachineTransfer.loopAt (ports .queryReverse) (ports .queryIndex) + id false (labels .secondReverse) + (some (labels (.secondLookup (.run .copyFirst)))) + | .secondLookup l => + MachinePreservingLookupClean.statement (ports ∘ lookupTape) + (fun k => labels (.secondLookup k)) (some (labels .secondScan)) l + | .secondScan => + MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.scanLoop (degree d) (Nat.mul_pos positive positive) + (ports .lookupOutput) (ports .quotientSecond) (labels .secondScan) + (fun r => labels (.secondResidue r))) + | .secondResidue r => + MachineControl.statement id (divisionStates ρ d) + (MachineFixedDivMod.emitterWithFinish (degree d) (Nat.mul_pos positive positive) + (ports .remainderSecond) + (some (labels (.outputEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry)))) + (secondFinish H) r) + | .outputEmit l => + PCP.AlphabetTable.Emitter.statement (outputPlan ρ d) (fun _ => ports .quotientSecond) + (ports .emitScratch) (ports .output) (fun k => labels (.outputEmit k)) + (some (labels (.cleanup 0))) l + | .cleanup i => + MachineDrain.drain (ports (dirtyTape i)) (labels (.cleanup i)) + (some (if hi : i.val + 1 < 6 then labels (.cleanup ⟨i.val + 1, hi⟩) else labels .done)) + | .done => Reduction.MachineTransfer.exitAt (ports .output) exit + +def program {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) : + Label d → TM2.Stmt (fun _ : Tape => Bool) (Label d) (State ρ d) := + statement positive H id id none + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTable.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTable.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6ad70e9f1d30d02ed3f6172c7e61835bd4e92d7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTable.lean @@ -0,0 +1,226 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyTransfer +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderTableLoop + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +open Turing MachineComposition +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords +open PCP.ExpanderTableEnumeration + +def completeBudget {v d : Nat} (G : Table v (degree d)) (H : Table (cloudSize d) d) : Nat := + 1 + vertexLoopBudget G v + ((encodeWords (rotationWords (step G H))).length + 2) + +def timeCoefficient (d : Nat) : Nat := + rowFactor d * (rowFactor d + 1) + 82 * rowFactor d + 5 + +noncomputable def timePolynomial (d : Nat) : Polynomial Nat := + Polynomial.C (timeCoefficient d) * (Polynomial.X + 1) ^ 2 + +theorem vertices_le_word_length {v d : Nat} (positive : 0 < d) + (G : Table v (degree d)) : v ≤ (oldTableWord G).length := by + have hq : 1 ≤ degree d := Nat.mul_pos positive positive + have hv : v ≤ v * degree d := by simpa using Nat.mul_le_mul_left v hq + have hr : v * degree d ≤ (oldTableWord G).length := by + simp only [oldTableWord, encodeWords_length, rotationWords_length] + omega + exact hv.trans hr + +theorem completeBudget_le {v d : Nat} (positive : 0 < d) + (G : Table v (degree d)) (H : Table (cloudSize d) d) : + completeBudget G H ≤ (timePolynomial d).eval (oldTableWord G).length := by + let L := (oldTableWord G).length + let M := rowFactor d + have vBound : v ≤ L + 1 := (vertices_le_word_length positive G).trans (Nat.le_succ L) + have emitBound : 80 * (L + 1) + 2 ≤ 82 * (L + 1) := by omega + have bodyBound : vertexBodyBudget G + 1 ≤ (82 * M + 1) * (L + 1) := by + have mulBound := Nat.mul_le_mul_left M emitBound + change M * (80 * (L + 1) + 2) + 1 ≤ _ + nlinarith + have iterations := Nat.mul_le_mul vBound bodyBound + have loopBound : v * (vertexBodyBudget G + 1) ≤ (82 * M + 1) * (L + 1)^2 := by + calc + _ ≤ (L + 1) * ((82 * M + 1) * (L + 1)) := iterations + _ = _ := by ring + have rowBound : v * M ≤ M * (L + 1) := by + simpa only [Nat.mul_comm v M] using Nat.mul_le_mul_left M vBound + have rowSuccBound : v * M + 1 ≤ (M + 1) * (L + 1) := by nlinarith + have productBound := Nat.mul_le_mul rowBound rowSuccBound + have lengthBound : (encodeWords (rotationWords (step G H))).length ≤ + M * (M + 1) * (L + 1)^2 := by + calc + _ ≤ (v * M) * (v * M + 1) := by + simpa only [generatedWords_eq_rotationWords] using encode_generatedWords_length_le G H + _ ≤ (M * (L + 1)) * ((M + 1) * (L + 1)) := productBound + _ = _ := by ring + have oneBound : 1 ≤ (L + 1)^2 := by nlinarith + have combined := Nat.add_le_add loopBound lengthBound + simp only [timePolynomial, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow, + Polynomial.eval_add, Polynomial.eval_X, Polynomial.eval_one] + change completeBudget G H ≤ (M * (M + 1) + 82 * M + 5) * (L + 1)^2 + unfold completeBudget vertexLoopBudget + nlinarith + +structure TableRun {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (G : Table v (degree d)) (H : Table (cloudSize d) d) + (state : State ρ d) (suffix : List Bool) where + finalState : State ρ d + caller_preserved : caller finalState = caller state + position_zero : finalState.2 = zeroPosition positive + execution : StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .initialize), state, initialTapes v (oldTableWord G) suffix⟩ + (some ⟨none, finalState, + finalTapes v (oldTableWord G) (encodeWords (rotationWords (step G H))) suffix⟩) + ((timePolynomial d).eval (oldTableWord G).length) + +private def initializeInTime {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (G : Table v (degree d)) (H : Table (cloudSize d) d) + (state : State ρ d) (suffix : List Bool) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .initialize), state, initialTapes v (oldTableWord G) suffix⟩ + (some ⟨some (.inr .vertexGuard), initialState positive H (caller state), + vertexLoopTapes G H 0 v suffix⟩) 1 where + steps := 1 + evals_in_steps := by + change TM2.step (program (ρ := ρ) positive H) + ⟨some (.inr .initialize), state, initialTapes v (oldTableWord G) suffix⟩ = + some ⟨some (.inr .vertexGuard), initialState positive H (caller state), + vertexLoopTapes G H 0 v suffix⟩ + simpa only [vertexLoopTapes, accumulatedVertices_zero] using + initialize_boundaryStep positive H v (oldTableWord G) suffix state + steps_le_m := Nat.le_refl _ + +def tableInTime {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (G : Table v (degree d)) (H : Table (cloudSize d) d) + (state : State ρ d) (suffix : List Bool) : TableRun positive G H state suffix := by + let loop := vertexLoopInTime positive G H 0 v + (initialState positive H (caller state)) suffix (by omega) rfl + let initialRun := initializeInTime positive G H state suffix + have finish : StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .reverseOutput), loop.finalState, vertexLoopTapes G H v 0 suffix⟩ + (some ⟨none, clearRegister loop.finalState, + finalTapes v (oldTableWord G) (encodeWords (rotationWords (step G H))) suffix⟩) + ((encodeWords (rotationWords (step G H))).length + 2) := by + simpa only [vertexLoopTapes, finalTapes, accumulatedVertices_full, List.reverse_reverse, + List.append_nil, List.length_reverse] using + reverseOutputHaltInTime positive H v 0 (oldTableWord G) + (accumulatedVertices G H v) suffix [] loop.finalState + let first := StateTransition.EvalsToInTime.trans (TM2.step (program positive H)) + _ _ _ _ _ initialRun loop.execution + let all := StateTransition.EvalsToInTime.trans (TM2.step (program positive H)) + _ _ _ _ _ first finish + refine ⟨clearRegister loop.finalState, ?_, ?_, ?_⟩ + · exact (caller_clearRegister loop.finalState).trans loop.caller_preserved + · simpa only [clearRegister] using loop.position_zero + · refine { toEvalsTo := all.toEvalsTo, steps_le_m := ?_ } + have bound := all.steps_le_m + have polynomialBound := completeBudget_le positive G H + unfold completeBudget at polynomialBound + omega + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderTable +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords + +def cycleWords (remaining : Nat) (word current vertex count result suffix : List Bool) : + Tape → List Bool + | .inl (.inl .table) => word + | .inl (.inl .inputVertex) => vertex + | .inl (.inr .vertexCount) => count + | .inl (.inr .result) => result + | .inr .remainingLevel => encodeWord remaining ++ suffix + | .inr .currentSize => current + | _ => [] + +def cycleTapes (remaining : Nat) (word current vertex count result suffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + fromBoolTapes (cycleWords remaining word current vertex count result suffix) + +@[simp] theorem toBool_cycleTapes (remaining : Nat) + (word current vertex count result suffix : List Bool) : + toBoolTapes (cycleTapes remaining word current vertex count result suffix) = + cycleWords remaining word current vertex count result suffix := toBool_fromBool _ + +theorem boundaryTapes_eq_cycleTapes (remaining current : Nat) (word suffix : List Bool) : + boundaryTapes remaining current word suffix = + cycleTapes remaining word (encodeWord current) [] [] [] suffix := by + funext tape + rcases tape with tape | tape + · rcases tape with row | extra + · cases row <;> rfl + · cases extra <;> rfl + · cases tape <;> rfl + +def copyFrame (remaining current : Nat) (word suffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + MachineEmbedding.tapes (MachineExpanderTable.initialTapes current word []) + (extraFrame remaining current suffix) + +def returnFrame (remaining current : Nat) (oldWord newWord suffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + MachineEmbedding.tapes (MachineExpanderTable.finalTapes current oldWord newWord []) + (extraFrame remaining current suffix) + +def installedFrame (remaining current : Nat) (newWord suffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + cycleTapes remaining newWord [] (encodeWord current) (encodeWord 0) [] suffix + +def multipliedFrame (d remaining current : Nat) (newWord suffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + cycleTapes remaining newWord (encodeWord (cloudSize d * current)) + (encodeWord current) (encodeWord 0) [] suffix + +theorem copyFrame_eq_cycleTapes (remaining current : Nat) (word suffix : List Bool) : + copyFrame remaining current word suffix = + cycleTapes remaining word (encodeWord current) [] (encodeWord current) [] suffix := by + funext tape + rcases tape with tape | tape + · rcases tape with row | extra + · cases row <;> rfl + · cases extra <;> simp [copyFrame, MachineEmbedding.tapes, + MachineExpanderTable.initialTapes, MachineExpanderTable.extraTapes, + cycleTapes, fromBoolTapes, boolWord, cycleWords] + · cases tape <;> rfl + +theorem returnFrame_eq_cycleTapes (remaining current : Nat) + (oldWord newWord suffix : List Bool) : + returnFrame remaining current oldWord newWord suffix = + cycleTapes remaining oldWord (encodeWord current) (encodeWord current) + (encodeWord 0) newWord suffix := by + funext tape + rcases tape with tape | tape + · rcases tape with row | extra + · cases row <;> rfl + · cases extra <;> simp [returnFrame, MachineEmbedding.tapes, + MachineExpanderTable.finalTapes, MachineExpanderTable.boundaryTapes, + MachineExpanderTable.extraTapes, cycleTapes, fromBoolTapes, boolWord, cycleWords] + · cases tape <;> rfl + +theorem copyFrame_eq_update (remaining current : Nat) (word suffix : List Bool) : + Function.update (boundaryTapes remaining current word suffix) + vertexCountTape (encodeWord current) = copyFrame remaining current word suffix := by + rw [boundaryTapes_eq_cycleTapes, copyFrame_eq_cycleTapes] + funext tape + rcases tape with tape | tape + · rcases tape with row | extra + · cases row <;> rfl + · cases extra <;> rfl + · cases tape <;> rfl + +theorem multipliedFrame_eq_update (d remaining current : Nat) (word suffix : List Bool) : + Function.update (installedFrame remaining current word suffix) + (.inr .currentSize) (encodeWord (cloudSize d * current)) = + multipliedFrame d remaining current word suffix := by + funext tape + rcases tape with tape | tape + · rcases tape with row | extra + · cases row <;> rfl + · cases extra <;> rfl + · cases tape <;> rfl + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableBoundary.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..29c90a4966552320c444f2eddb8186c15092bae4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableBoundary.lean @@ -0,0 +1,233 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderTableProgram + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl + +variable {ρ : Type} {d : Nat} + +@[simp] theorem caller_boundaryState (positive : 0 < d) (H : Table (cloudSize d) d) + (ambient : ρ) (position : Position d) : + caller (boundaryState positive H ambient position) = ambient := rfl + +@[simp] theorem prepareState_boundaryState (positive : 0 < d) (H : Table (cloudSize d) d) + (ambient : ρ) (position : Position d) : + prepareState positive H (boundaryState positive H ambient position) = + boundaryState positive H ambient position := rfl + +@[simp] theorem clearRegister_boundaryState (positive : 0 < d) (H : Table (cloudSize d) d) + (ambient : ρ) (position : Position d) : + clearRegister (boundaryState positive H ambient position) = + boundaryState positive H ambient position := rfl + +@[simp] theorem caller_prepareState (positive : 0 < d) (H : Table (cloudSize d) d) + (state : State ρ d) : caller (prepareState positive H state) = caller state := rfl + +@[simp] theorem caller_resetState (positive : 0 < d) (H : Table (cloudSize d) d) + (state : State ρ d) : caller (resetState positive H state) = caller state := rfl + +@[simp] theorem caller_clearRegister (state : State ρ d) : + caller (clearRegister state) = caller state := rfl + +@[simp] theorem caller_advancePositionState (positive : 0 < d) (state : State ρ d) : + caller (advancePositionState positive state) = caller state := rfl + +@[simp] theorem caller_resetPositionState (positive : 0 < d) (state : State ρ d) : + caller (resetPositionState positive state) = caller state := rfl + +theorem nextPosition_val_of_lt (positive : 0 < d) (position : Position d) + (more : position.val + 1 < rowFactor d) : + (nextPosition positive position).val = position.val + 1 := Nat.mod_eq_of_lt more + +theorem boundaryTapes_update_count (vertex remaining next : Nat) + (oldTable output countSuffix result : List Bool) : + Function.update (boundaryTapes vertex remaining oldTable output countSuffix result) + (.inr .vertexCount) (encodeWord next ++ countSuffix) = + boundaryTapes vertex next oldTable output countSuffix result := by + funext tape + rcases tape with row | extra + · cases row <;> simp [boundaryTapes, rowTapes, MachineEmbedding.tapes, Function.update] + · cases extra <;> simp [boundaryTapes, extraTapes, MachineEmbedding.tapes, Function.update] + +theorem boundaryTapes_increment_vertex (vertex remaining : Nat) + (oldTable output countSuffix result : List Bool) : + Function.update (boundaryTapes vertex remaining oldTable output countSuffix result) + (.inl .inputVertex) (true :: encodeWord vertex) = + boundaryTapes (vertex + 1) remaining oldTable output countSuffix result := by + funext tape + rcases tape with row | extra + · cases row <;> + simp [boundaryTapes, rowTapes, MachineEmbedding.tapes, Function.update, + encodeWord, List.replicate_succ] + · cases extra <;> + simp [boundaryTapes, extraTapes, MachineEmbedding.tapes, Function.update] + +theorem initialTapes_initialize (vertices : Nat) (oldTable countSuffix : List Bool) : + Function.update (initialTapes vertices oldTable countSuffix) (.inl .inputVertex) [false] = + boundaryTapes 0 vertices oldTable [] countSuffix [] := by + funext tape + rcases tape with row | extra + · cases row <;> + simp [initialTapes, boundaryTapes, rowTapes, MachineEmbedding.tapes, + Function.update, encodeWord] + · cases extra <;> + simp [initialTapes, boundaryTapes, extraTapes, MachineEmbedding.tapes, + Function.update] + +variable [Fintype ρ] + +theorem initializeStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) : + TM2.step (program positive H) ⟨some (.inr .initialize), state, base⟩ = + some ⟨some (.inr .vertexGuard), resetState positive H state, + Function.update base (.inl .inputVertex) (false :: base (.inl .inputVertex))⟩ := by + change some (TM2.stepAux (program positive H (.inr .initialize)) state base) = _ + rw [program_outer] + rfl + +theorem initialize_boundaryStep (positive : 0 < d) (H : Table (cloudSize d) d) + (vertices : Nat) (oldTable countSuffix : List Bool) (state : State ρ d) : + TM2.step (program positive H) + ⟨some (.inr .initialize), state, initialTapes vertices oldTable countSuffix⟩ = + some ⟨some (.inr .vertexGuard), initialState positive H (caller state), + boundaryTapes 0 vertices oldTable [] countSuffix []⟩ := by + have h := initializeStep positive H (initialTapes vertices oldTable countSuffix) state + have input : initialTapes vertices oldTable countSuffix (.inl .inputVertex) = [] := rfl + simp only [input, resetState] at h + exact h.trans (congrArg + (fun tapes : ∀ tape, List (Alphabet tape) => + (some ⟨some (.inr .vertexGuard), initialState positive H (caller state), tapes⟩ : + Option (TM2.Cfg Alphabet (Label d) (State ρ d)))) + (initialTapes_initialize vertices oldTable countSuffix)) + +theorem vertexGuard_succStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (remaining : Nat) (suffix : List Bool) + (counter : base (.inr .vertexCount) = encodeWord (remaining + 1) ++ suffix) : + TM2.step (program positive H) ⟨some (.inr .vertexGuard), state, base⟩ = + some ⟨some (.inr .prepareRow), clearRegister state, + Function.update base (.inr .vertexCount) (encodeWord remaining ++ suffix)⟩ := by + change some (TM2.stepAux (program positive H (.inr .vertexGuard)) state base) = _ + rw [program_outer] + simp [outerStatement, MachineControl.statement, vertexGuardCore, TM2.stepAux, + guardStates, clearRegister, counter, encodeWord, List.replicate_succ] + +theorem vertexGuard_zeroStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (suffix : List Bool) + (counter : base (.inr .vertexCount) = encodeWord 0 ++ suffix) : + TM2.step (program positive H) ⟨some (.inr .vertexGuard), state, base⟩ = + some ⟨some (.inr .reverseOutput), clearRegister state, base⟩ := by + change some (TM2.stepAux (program positive H (.inr .vertexGuard)) state base) = _ + rw [program_outer] + simp [outerStatement, MachineControl.statement, vertexGuardCore, TM2.stepAux, + guardStates, clearRegister, counter, encodeWord] + +theorem vertexGuard_boundary_succStep (positive : 0 < d) (H : Table (cloudSize d) d) + (vertex remaining : Nat) (oldTable output countSuffix result : List Bool) + (state : State ρ d) : + TM2.step (program positive H) + ⟨some (.inr .vertexGuard), state, + boundaryTapes vertex (remaining + 1) oldTable output countSuffix result⟩ = + some ⟨some (.inr .prepareRow), clearRegister state, + boundaryTapes vertex remaining oldTable output countSuffix result⟩ := by + simpa only [boundaryTapes_update_count] using + vertexGuard_succStep positive H + (boundaryTapes vertex (remaining + 1) oldTable output countSuffix result) + state remaining countSuffix rfl + +theorem vertexGuard_boundary_zeroStep (positive : 0 < d) (H : Table (cloudSize d) d) + (vertex : Nat) (oldTable output countSuffix result : List Bool) (state : State ρ d) : + TM2.step (program positive H) + ⟨some (.inr .vertexGuard), state, + boundaryTapes vertex 0 oldTable output countSuffix result⟩ = + some ⟨some (.inr .reverseOutput), clearRegister state, + boundaryTapes vertex 0 oldTable output countSuffix result⟩ := + vertexGuard_zeroStep positive H + (boundaryTapes vertex 0 oldTable output countSuffix result) state countSuffix rfl + +theorem prepareRowStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) : + TM2.step (program positive H) ⟨some (.inr .prepareRow), state, base⟩ = + some ⟨some (.inl .initialize), prepareState positive H state, base⟩ := by + change some (TM2.stepAux (program positive H (.inr .prepareRow)) state base) = _ + rw [program_outer] + rfl + +theorem afterRow_moreStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (more : state.2.val + 1 < rowFactor d) : + TM2.step (program positive H) ⟨some (.inr .afterRow), state, base⟩ = + some ⟨some (.inr .prepareRow), advancePositionState positive state, base⟩ := by + change some (TM2.stepAux (program positive H (.inr .afterRow)) state base) = _ + rw [program_outer] + simp [outerStatement, TM2.stepAux, more] + +theorem afterRow_lastStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (last : ¬ state.2.val + 1 < rowFactor d) : + TM2.step (program positive H) ⟨some (.inr .afterRow), state, base⟩ = + some ⟨some (.inr .vertexGuard), resetPositionState positive state, + Function.update base (.inl .inputVertex) (true :: base (.inl .inputVertex))⟩ := by + change some (TM2.stepAux (program positive H (.inr .afterRow)) state base) = _ + rw [program_outer] + simp [outerStatement, TM2.stepAux, last] + +theorem afterRow_last_boundaryStep (positive : 0 < d) (H : Table (cloudSize d) d) + (vertex remaining : Nat) (oldTable output countSuffix result : List Bool) + (state : State ρ d) (last : ¬ state.2.val + 1 < rowFactor d) : + TM2.step (program positive H) + ⟨some (.inr .afterRow), state, + boundaryTapes vertex remaining oldTable output countSuffix result⟩ = + some ⟨some (.inr .vertexGuard), resetPositionState positive state, + boundaryTapes (vertex + 1) remaining oldTable output countSuffix result⟩ := by + have input : boundaryTapes vertex remaining oldTable output countSuffix result + (.inl .inputVertex) = encodeWord vertex := rfl + have h := afterRow_lastStep positive H + (boundaryTapes vertex remaining oldTable output countSuffix result) state last + simp only [input] at h + exact h.trans (congrArg + (fun tapes : ∀ tape, List (Alphabet tape) => + (some ⟨some (.inr .vertexGuard), resetPositionState positive state, tapes⟩ : + Option (TM2.Cfg Alphabet (Label d) (State ρ d)))) + (boundaryTapes_increment_vertex vertex remaining oldTable output countSuffix result)) + +theorem reverseOutput_consStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (symbol : Bool) (word : List Bool) (source : base (.inl .output) = symbol :: word) : + TM2.step (program positive H) ⟨some (.inr .reverseOutput), state, base⟩ = + some ⟨some (.inr .reverseOutput), ((state.1.1, some symbol), state.2), + Function.update (Function.update base (.inl .output) word) + (.inr .result) (symbol :: base (.inr .result))⟩ := by + change some (TM2.stepAux (program positive H (.inr .reverseOutput)) state base) = _ + rw [program_outer] + simp [outerStatement, MachineControl.statement, Reduction.MachineTransfer.loopAt, + Reduction.MachineTransfer.exitAt, TM2.stepAux, guardStates, source] + +theorem reverseOutput_nilStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) + (source : base (.inl .output) = []) : + TM2.step (program positive H) ⟨some (.inr .reverseOutput), state, base⟩ = + some ⟨some (.inr .done), clearRegister state, base⟩ := by + have same : Function.update base (.inl .output) [] = base := by + simpa only [source] using Function.update_eq_self (.inl .output) base + change some (TM2.stepAux (program positive H (.inr .reverseOutput)) state base) = _ + rw [program_outer] + simp [outerStatement, MachineControl.statement, Reduction.MachineTransfer.loopAt, + Reduction.MachineTransfer.exitAt, TM2.stepAux, guardStates, clearRegister, source, same] + +theorem doneStep (positive : 0 < d) (H : Table (cloudSize d) d) + (base : ∀ tape, List (Alphabet tape)) (state : State ρ d) : + TM2.step (program positive H) ⟨some (.inr .done), state, base⟩ = + some ⟨none, state, base⟩ := by + change some (TM2.stepAux (program positive H (.inr .done)) state base) = _ + rw [program_outer] + rfl + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableLoop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..4acaeba51144d9f9d07de6cc0098240724cb7c2a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableLoop.lean @@ -0,0 +1,219 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderTableRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +section + +open Turing MachineComposition +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords +open PCP.ExpanderTableEnumeration + +def oldTableWord {v d : Nat} (G : Table v (degree d)) : List Bool := + encodeWords (rotationWords G) + +def accumulatedVertices {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) (current : Nat) : List Bool := + accumulate (priorVertices G H current) [] + +@[simp] theorem accumulatedVertices_zero {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) : accumulatedVertices G H 0 = [] := by + simp [accumulatedVertices, accumulate] + +theorem accumulatedVertices_succ {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) (current : Nat) (valid : current < v) : + accumulatedVertices G H (current + 1) = + accumulate (vertexWords G H ⟨current, valid⟩) (accumulatedVertices G H current) := by + simp only [accumulatedVertices, priorVertices_succ G H current valid, accumulate_append] + +theorem accumulatedVertices_full {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) : accumulatedVertices G H v = + (encodeWords (rotationWords (step G H))).reverse := by + simp [accumulatedVertices, accumulate_generatedWords] + +def vertexBodyBudget {v d : Nat} (G : Table v (degree d)) : Nat := + rowFactor d * (80 * ((oldTableWord G).length + 1) + 2) + +def vertexLoopBudget {v d : Nat} (G : Table v (degree d)) (remaining : Nat) : Nat := + remaining * (vertexBodyBudget G + 1) + 1 + +def vertexLoopTapes {v d : Nat} (G : Table v (degree d)) (H : Table (cloudSize d) d) + (current remaining : Nat) (suffix : List Bool) : ∀ tape, List (Alphabet tape) := + boundaryTapes current remaining (oldTableWord G) (accumulatedVertices G H current) suffix [] + +structure VertexLoopRun {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (G : Table v (degree d)) (H : Table (cloudSize d) d) + (current remaining : Nat) (state : State ρ d) (suffix : List Bool) where + finalState : State ρ d + caller_preserved : caller finalState = caller state + position_zero : finalState.2 = zeroPosition positive + execution : StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .vertexGuard), state, vertexLoopTapes G H current remaining suffix⟩ + (some ⟨some (.inr .reverseOutput), finalState, vertexLoopTapes G H v 0 suffix⟩) + (vertexLoopBudget G remaining) + +private def boundarySingleStep {S : Type*} (f : S → Option S) (a b : S) + (h : f a = some b) : StateTransition.EvalsToInTime f a (some b) 1 where + steps := 1 + evals_in_steps := by change f a = some b; exact h + steps_le_m := Nat.le_refl _ + +def vertexLoopInTime {v d : Nat} {ρ : Type} [Fintype ρ] + (positive : 0 < d) (G : Table v (degree d)) (H : Table (cloudSize d) d) + (current remaining : Nat) (state : State ρ d) (suffix : List Bool) + (count : current + remaining = v) (position : state.2 = zeroPosition positive) : + VertexLoopRun positive G H current remaining state suffix := by + induction remaining generalizing current state with + | zero => + have hc : current = v := by omega + subst current + refine ⟨clearRegister state, caller_clearRegister state, ?_, ?_⟩ + · simpa only [clearRegister] using position + · simpa only [vertexLoopBudget, Nat.zero_mul, Nat.zero_add, vertexLoopTapes] using + boundarySingleStep _ _ _ (vertexGuard_boundary_zeroStep positive H v (oldTableWord G) + (accumulatedVertices G H v) suffix [] state) + | succ remaining ih => + have valid : current < v := by omega + let vertex : Fin v := ⟨current, valid⟩ + let body := vertexInTime positive G H vertex (clearRegister state) + (by simpa only [clearRegister] using position) remaining + (accumulatedVertices G H current) suffix [] + have nextCount : current + 1 + remaining = v := by omega + let rest := ih (current + 1) body.finalState nextCount body.position_zero + have output_eq : accumulate (vertexWords G H vertex) + (accumulatedVertices G H current) = accumulatedVertices G H (current + 1) := + (accumulatedVertices_succ G H current valid).symm + let guard := boundarySingleStep _ _ _ + (vertexGuard_boundary_succStep positive H current remaining (oldTableWord G) + (accumulatedVertices G H current) suffix [] state) + have bodyRun : StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .prepareRow), clearRegister state, + boundaryTapes current remaining (oldTableWord G) + (accumulatedVertices G H current) suffix []⟩ + (some ⟨some (.inr .vertexGuard), body.finalState, + vertexLoopTapes G H (current + 1) remaining suffix⟩) + (vertexBodyBudget G) := by + simpa only [vertexLoopTapes, vertexBodyBudget, oldTableWord, output_eq] using body.execution + let first := StateTransition.EvalsToInTime.trans (TM2.step (program positive H)) + _ _ _ _ _ guard bodyRun + let all := StateTransition.EvalsToInTime.trans (TM2.step (program positive H)) + _ _ _ _ _ first rest.execution + refine ⟨rest.finalState, ?_, rest.position_zero, ?_⟩ + · exact rest.caller_preserved.trans + (body.caller_preserved.trans (caller_clearRegister state)) + · refine { toEvalsTo := all.toEvalsTo, steps_le_m := ?_ } + have bound := all.steps_le_m + simp only [vertexLoopBudget, Nat.succ_mul] at bound ⊢ + omega + +end + +open Turing +open MachineComposition +open PCP.ExpanderTables PCP.ExpanderRowControl + +variable {ρ : Type} {d : Nat} + +@[simp] theorem clearRegister_position (state : State ρ d) : + (clearRegister state).2 = state.2 := rfl + +@[simp] theorem clearRegister_register (state : State ρ d) : + (clearRegister state).1.2 = none := rfl + +@[simp] theorem clearRegister_idempotent (state : State ρ d) : + clearRegister (clearRegister state) = clearRegister state := rfl + +theorem boundaryTapes_reverse_update (vertex remaining : Nat) + (oldTable output countSuffix result nextOutput nextResult : List Bool) : + Function.update + (Function.update (boundaryTapes vertex remaining oldTable output countSuffix result) + (.inl .output) nextOutput) + (.inr .result) nextResult = + boundaryTapes vertex remaining oldTable nextOutput countSuffix nextResult := by + funext tape + rcases tape with row | extra + · cases row <;> + simp [boundaryTapes, rowTapes, MachineEmbedding.tapes, Function.update] + · cases extra <;> + simp [boundaryTapes, extraTapes, MachineEmbedding.tapes, Function.update] + +variable [Fintype ρ] + +theorem reverseOutputTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (vertex remaining : Nat) (oldTable output countSuffix result : List Bool) + (state : State ρ d) : + (advance (TM2.step (program positive H)))^[output.length + 1] + (some ⟨some (.inr .reverseOutput), state, + boundaryTapes vertex remaining oldTable output countSuffix result⟩) = + some ⟨some (.inr .done), clearRegister state, + boundaryTapes vertex remaining oldTable [] countSuffix (output.reverse ++ result)⟩ := by + induction output generalizing result state with + | nil => + simpa only [List.length_nil, Nat.zero_add, Function.iterate_one, advance_some, + List.reverse_nil, List.nil_append] using + reverseOutput_nilStep positive H + (boundaryTapes vertex remaining oldTable [] countSuffix result) state rfl + | cons symbol output ih => + rw [List.length_cons, Function.iterate_succ_apply] + simp only [advance_some] + rw [reverseOutput_consStep positive H + (boundaryTapes vertex remaining oldTable (symbol :: output) countSuffix result) + state symbol output rfl] + change (advance (TM2.step (program positive H)))^[output.length + 1] + (some ⟨some (.inr .reverseOutput), ((state.1.1, some symbol), state.2), + Function.update + (Function.update + (boundaryTapes vertex remaining oldTable (symbol :: output) countSuffix result) + (.inl .output) output) + (.inr .result) (symbol :: result)⟩) = _ + rw [boundaryTapes_reverse_update] + simpa only [clearRegister, List.reverse_cons, List.append_assoc, + List.singleton_append] using + ih (symbol :: result) ((state.1.1, some symbol), state.2) + +theorem reverseOutputHaltTrace (positive : 0 < d) (H : Table (cloudSize d) d) + (vertex remaining : Nat) (oldTable output countSuffix result : List Bool) + (state : State ρ d) : + (advance (TM2.step (program positive H)))^[output.length + 2] + (some ⟨some (.inr .reverseOutput), state, + boundaryTapes vertex remaining oldTable output countSuffix result⟩) = + some ⟨none, clearRegister state, + boundaryTapes vertex remaining oldTable [] countSuffix (output.reverse ++ result)⟩ := by + rw [show output.length + 2 = (output.length + 1) + 1 by omega, + Function.iterate_succ_apply', + reverseOutputTrace positive H vertex remaining oldTable output countSuffix result state] + exact doneStep positive H + (boundaryTapes vertex remaining oldTable [] countSuffix (output.reverse ++ result)) + (clearRegister state) + +def reverseOutputInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (vertex remaining : Nat) (oldTable output countSuffix result : List Bool) + (state : State ρ d) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .reverseOutput), state, + boundaryTapes vertex remaining oldTable output countSuffix result⟩ + (some ⟨some (.inr .done), clearRegister state, + boundaryTapes vertex remaining oldTable [] countSuffix (output.reverse ++ result)⟩) + (output.length + 1) where + steps := output.length + 1 + evals_in_steps := reverseOutputTrace positive H vertex remaining oldTable output countSuffix result state + steps_le_m := Nat.le_refl _ + +def reverseOutputHaltInTime (positive : 0 < d) (H : Table (cloudSize d) d) + (vertex remaining : Nat) (oldTable output countSuffix result : List Bool) + (state : State ρ d) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .reverseOutput), state, + boundaryTapes vertex remaining oldTable output countSuffix result⟩ + (some ⟨none, clearRegister state, + boundaryTapes vertex remaining oldTable [] countSuffix (output.reverse ++ result)⟩) + (output.length + 2) where + steps := output.length + 2 + evals_in_steps := reverseOutputHaltTrace positive H vertex remaining oldTable output countSuffix result state + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableProgram.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..491c0eaa4260d73b7209d0da5b51f0f1da0df935 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableProgram.lean @@ -0,0 +1,190 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowDivision + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl + +inductive ExtraTape + | vertexCount | result + deriving DecidableEq + +instance : Fintype ExtraTape where + elems := {.vertexCount, .result} + complete tape := by cases tape <;> simp + +abbrev Tape := MachineExpanderRow.Tape ⊕ ExtraTape + +abbrev Alphabet : Tape → Type := + MachineEmbedding.Alphabet (fun _ : MachineExpanderRow.Tape => Bool) + (fun _ : ExtraTape => Bool) + +instance alphabetFintype (tape : Tape) : Fintype (Alphabet tape) := by + cases tape <;> exact inferInstanceAs (Fintype Bool) + +inductive OuterLabel + | initialize | vertexGuard | prepareRow | afterRow | reverseOutput | done + deriving DecidableEq + +instance : Fintype OuterLabel where + elems := {.initialize, .vertexGuard, .prepareRow, .afterRow, .reverseOutput, .done} + complete label := by cases label <;> simp + +abbrev Label (d : Nat) := MachineExpanderRow.Label d ⊕ OuterLabel +abbrev Position (d : Nat) := Fin (rowFactor d) +abbrev State (ρ : Type) (d : Nat) := MachineExpanderRow.State ρ d × Position d +abbrev RowStatePrefix (ρ : Type) (d : Nat) := + (MachineExpanderRow.Ambient ρ d × Fin (degree d)) × Unit + +def guardStates (ρ : Type) (d : Nat) : + ((RowStatePrefix ρ d × Position d) × Option Bool) ≃ State ρ d where + toFun s := ((s.1.1, s.2), s.1.2) + invFun s := ((s.1.1, s.2), s.1.2) + left_inv := by rintro ⟨⟨a, p⟩, b⟩; rfl + right_inv := by rintro ⟨⟨a, b⟩, p⟩; rfl + +@[simp] theorem guardStates_apply (ρ : Type) (d : Nat) + (s : (RowStatePrefix ρ d × Position d) × Option Bool) : + guardStates ρ d s = ((s.1.1, s.2), s.1.2) := rfl + +@[simp] theorem guardStates_symm_apply (ρ : Type) (d : Nat) (s : State ρ d) : + (guardStates ρ d).symm s = ((s.1.1, s.2), s.1.2) := rfl + +theorem rowFactor_pos {d : Nat} (positive : 0 < d) : 0 < rowFactor d := by + have hq : 0 < degree d := Nat.mul_pos positive positive + exact Nat.mul_pos (Nat.mul_pos hq hq) hq + +def zeroPosition {d : Nat} (positive : 0 < d) : Position d := + ⟨0, rowFactor_pos positive⟩ + +def nextPosition {d : Nat} (positive : 0 < d) (p : Position d) : Position d := + ⟨(p.val + 1) % rowFactor d, Nat.mod_lt _ (rowFactor_pos positive)⟩ + +def positionPair {d : Nat} (p : Position d) : Fin (cloudSize d) × Fin (degree d) := + (rowIndex (cloudSize d) (degree d)).symm p + +def caller {ρ : Type} {d : Nat} (s : State ρ d) : ρ := s.1.1.1.1.1 + +def boundaryState {ρ : Type} {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (ambient : ρ) (p : Position d) : State ρ d := + (MachineExpanderRow.divisionState positive ambient + (start H (positionPair p).1 (positionPair p).2) none, p) + +def initialState {ρ : Type} {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (ambient : ρ) : State ρ d := + boundaryState positive H ambient (zeroPosition positive) + +def prepareState {ρ : Type} {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (s : State ρ d) : State ρ d := + boundaryState positive H (caller s) s.2 + +def resetState {ρ : Type} {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (s : State ρ d) : State ρ d := + initialState positive H (caller s) + +def clearRegister {ρ : Type} {d : Nat} (s : State ρ d) : State ρ d := + ((s.1.1, none), s.2) + +def advancePositionState {ρ : Type} {d : Nat} (positive : 0 < d) + (s : State ρ d) : State ρ d := (s.1, nextPosition positive s.2) + +def resetPositionState {ρ : Type} {d : Nat} (positive : 0 < d) + (s : State ρ d) : State ρ d := (s.1, zeroPosition positive) + +def vertexGuardCore {ρ : Type} {d : Nat} : + TM2.Stmt Alphabet (Label d) ((RowStatePrefix ρ d × Position d) × Option Bool) := + .peek (.inr .vertexCount) (fun s head => (s.1, head)) + (.branch (fun s => s.2.getD false) + (.pop (.inr .vertexCount) (fun s _ => (s.1, none)) + (.goto fun _ => .inr .prepareRow)) + (.load (fun s => (s.1, none)) (.goto fun _ => .inr .reverseOutput))) + +variable {ρ : Type} [Fintype ρ] + +def outerStatement {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) : + OuterLabel → TM2.Stmt Alphabet (Label d) (State ρ d) + | .initialize => + .push (.inl .inputVertex) (fun _ => false) + (.load (resetState positive H) (.goto fun _ => .inr .vertexGuard)) + | .vertexGuard => MachineControl.statement id (guardStates ρ d) vertexGuardCore + | .prepareRow => + .load (prepareState positive H) (.goto fun _ => .inl .initialize) + | .afterRow => + .branch (fun s => decide (s.2.val + 1 < rowFactor d)) + (.load (advancePositionState positive) (.goto fun _ => .inr .prepareRow)) + (.push (.inl .inputVertex) (fun _ => true) + (.load (resetPositionState positive) (.goto fun _ => .inr .vertexGuard))) + | .reverseOutput => + MachineControl.statement id (guardStates ρ d) + (Reduction.MachineTransfer.loopAt (Γ := Alphabet) (Λ := Label d) + (σ := RowStatePrefix ρ d × Position d) (.inl .output) (.inr .result) id false + (.inr .reverseOutput) (some (.inr .done))) + | .done => .halt + +def rowReturn (d : Nat) : Option (Label d) := some (.inr .afterRow) + +def program {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) : + Label d → TM2.Stmt Alphabet (Label d) (State ρ d) := + MachineEmbedding.program (rowReturn d) (MachineExpanderRow.program positive H) + (outerStatement positive H) + +@[simp] theorem program_row {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (label : MachineExpanderRow.Label d) : + program (ρ := ρ) positive H (.inl label) = + MachineEmbedding.statement (rowReturn d) + (MachineExpanderRow.program positive H label) := rfl + +@[simp] theorem program_outer {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (label : OuterLabel) : + program (ρ := ρ) positive H (.inr label) = outerStatement positive H label := rfl + +def rowExecution {d : Nat} (positive : 0 < d) (H : Table (cloudSize d) d) + (position : Position d) (extra : ExtraTape → List Bool) + {a b : TM2.Cfg (fun _ : MachineExpanderRow.Tape => Bool) + (MachineExpanderRow.Label d) (MachineExpanderRow.State ρ d)} {budget : Nat} + (execution : StateTransition.EvalsToInTime + (TM2.step (MachineExpanderRow.program positive H)) a (some b) budget) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + (MachineEmbedding.configuration (rowReturn d) position extra a) + (some (MachineEmbedding.configuration (rowReturn d) position extra b)) budget := + MachineComposition.embeddedExecution (rowReturn d) position extra + (MachineExpanderRow.program positive H) (outerStatement positive H) execution + +@[simp] theorem rowExecution_steps {d : Nat} (positive : 0 < d) + (H : Table (cloudSize d) d) (position : Position d) (extra : ExtraTape → List Bool) + {a b : TM2.Cfg (fun _ : MachineExpanderRow.Tape => Bool) + (MachineExpanderRow.Label d) (MachineExpanderRow.State ρ d)} {budget : Nat} + (execution : StateTransition.EvalsToInTime + (TM2.step (MachineExpanderRow.program positive H)) a (some b) budget) : + (rowExecution positive H position extra execution).steps = execution.steps := rfl + +def rowTapes (vertex : Nat) (oldTable output : List Bool) : MachineExpanderRow.Tape → List Bool + | .inputVertex => encodeWord vertex + | .table => oldTable + | .output => output + | _ => [] + +def extraTapes (remaining : Nat) (countSuffix result : List Bool) : ExtraTape → List Bool + | .vertexCount => encodeWord remaining ++ countSuffix + | .result => result + +def boundaryTapes (vertex remaining : Nat) (oldTable output countSuffix result : List Bool) : + (tape : Tape) → List (Alphabet tape) := + MachineEmbedding.tapes (rowTapes vertex oldTable output) (extraTapes remaining countSuffix result) + +def initialTapes (vertices : Nat) (oldTable countSuffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + MachineEmbedding.tapes + (fun tape => match tape with | .table => oldTable | _ => []) + (extraTapes vertices countSuffix []) + +def finalTapes (vertices : Nat) (oldTable output countSuffix : List Bool) : + (tape : Tape) → List (Alphabet tape) := + boundaryTapes vertices 0 oldTable [] countSuffix output + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableRows.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..aca8784cab7634dd6e6623391b638276ef49b3ec --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineExpanderTableRows.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRow +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderTableBoundary +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderTableEnumeration + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords +open PCP.ExpanderTableEnumeration + +private def singleStep {α : Type*} (step : α → Option α) (a b : α) + (h : step a = some b) : StateTransition.EvalsToInTime step a (some b) 1 where + steps := 1 + evals_in_steps := by change step a = some b; exact h + steps_le_m := Nat.le_refl _ + +private def sequence {α : Type*} {step : α → Option α} {a b c : α} {m n : Nat} + (first : StateTransition.EvalsToInTime step a (some b) m) + (second : StateTransition.EvalsToInTime step b (some c) n) : + StateTransition.EvalsToInTime step a (some c) (m + n) := by + simpa only [Nat.add_comm n m] using + StateTransition.EvalsToInTime.trans step m n a b (some c) first second + +private def widen {α : Type*} {step : α → Option α} {a : α} {b : Option α} {m n : Nat} + (run : StateTransition.EvalsToInTime step a b m) (bound : m ≤ n) : + StateTransition.EvalsToInTime step a b n where + toEvalsTo := run.toEvalsTo + steps_le_m := run.steps_le_m.trans bound + +def tableRowData {v d : Nat} (G : Table v (degree d)) (H : Table (cloudSize d) d) + (vertex : Fin v) (position : Position d) : MachineExpanderRow.RowData v d := + MachineExpanderRow.rowData G H vertex (positionPair position).1 (positionPair position).2 + +theorem tableRowData_finalValue {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (position : Position d) : + (tableRowData G H vertex position).finalValue = rowValue G H vertex position := rfl + +theorem tableRowData_frame0 {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (position : Position d) (output : List Bool) : + MachineExpanderRow.frame0 (tableRowData G H vertex position) output = + rowTapes vertex.val (encodeWords (rotationWords G)) output := by + funext tape + cases tape <;> rfl + +theorem tableRowData_finalFrame {v d : Nat} (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (position : Position d) (output : List Bool) : + MachineExpanderRow.emittedWord .output + (MachineExpanderRow.frame0 (tableRowData G H vertex position) output) + (tableRowData G H vertex position).finalValue = + rowTapes vertex.val (encodeWords (rotationWords G)) + ((encodeWord (rowValue G H vertex position)).reverse ++ output) := by + rw [tableRowData_frame0, tableRowData_finalValue] + funext tape + cases tape <;> simp [MachineExpanderRow.emittedWord, rowTapes] + +variable {ρ : Type} [Fintype ρ] {v d : Nat} + +def rowAfterState (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) : State ρ d := + (MachineExpanderRow.divisionState positive (caller state) + (tableRowData G H vertex state.2).control2 none, state.2) + +omit [Fintype ρ] in +@[simp] theorem rowAfterState_position (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) : + (rowAfterState positive G H vertex state).2 = state.2 := rfl + +omit [Fintype ρ] in +@[simp] theorem caller_rowAfterState (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) : + caller (rowAfterState positive G H vertex state) = caller state := rfl + +def preparedRowInTime (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) + (remaining : Nat) (output countSuffix result : List Bool) : + StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .prepareRow), state, + boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) output countSuffix result⟩ + (some ⟨some (.inr .afterRow), rowAfterState positive G H vertex state, + boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) + ((encodeWord (rowValue G H vertex state.2)).reverse ++ output) countSuffix result⟩) + (1 + 80 * ((encodeWords (rotationWords G)).length + 1)) := by + have raw := rowExecution positive H state.2 (extraTapes remaining countSuffix result) + (MachineExpanderRow.rowInTime positive (tableRowData G H vertex state.2) output (caller state)) + have run : StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inl .initialize), prepareState positive H state, + boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) output countSuffix result⟩ + (some ⟨some (.inr .afterRow), rowAfterState positive G H vertex state, + boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) + ((encodeWord (rowValue G H vertex state.2)).reverse ++ output) countSuffix result⟩) + (80 * ((encodeWords (rotationWords G)).length + 1)) := by + rw [tableRowData_finalFrame, tableRowData_frame0] at raw + simpa only [MachineEmbedding.configuration, MachineEmbedding.label, rowReturn, + prepareState, boundaryState, rowAfterState, boundaryTapes, + MachineExpanderRow.RowData.tableLength, MachineExpanderRow.RowData.control0, + tableRowData, MachineExpanderRow.rowData] using raw + exact sequence + (singleStep _ _ _ (prepareRowStep positive H + (boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) output countSuffix result) + state)) run + +structure VertexSuffixRun (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) + (remaining : Nat) (output countSuffix result : List Bool) where + finalState : State ρ d + caller_preserved : caller finalState = caller state + position_zero : finalState.2 = zeroPosition positive + execution : StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .prepareRow), state, + boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) output countSuffix result⟩ + (some ⟨some (.inr .vertexGuard), finalState, + boundaryTapes (vertex.val + 1) remaining (encodeWords (rotationWords G)) + (accumulate ((vertexWords G H vertex).drop state.2.val) output) countSuffix result⟩) + ((rowFactor d - state.2.val) * (80 * ((encodeWords (rotationWords G)).length + 1) + 2)) + +private def suffixRun_aux (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (remaining : Nat) + (countSuffix result : List Bool) (n : Nat) : + (state : State ρ d) → state.2.val + n = rowFactor d → (output : List Bool) → + VertexSuffixRun positive G H vertex state remaining output countSuffix result := by + induction n with + | zero => + intro state count output + have hp := state.2.isLt + exact False.elim (by omega) + | succ n ih => + intro state count output + let after := rowAfterState positive G H vertex state + let nextOutput := (encodeWord (rowValue G H vertex state.2)).reverse ++ output + have row := preparedRowInTime positive G H vertex state remaining output countSuffix result + by_cases last : n = 0 + · have hp : state.2.val + 1 = rowFactor d := by omega + have finish := singleStep _ _ _ (afterRow_last_boundaryStep positive H vertex.val remaining + (encodeWords (rotationWords G)) nextOutput countSuffix result after (by + change ¬ state.2.val + 1 < rowFactor d + omega)) + refine ⟨resetPositionState positive after, ?_, rfl, ?_⟩ + · rfl + · have all := sequence row finish + have words : accumulate ((vertexWords G H vertex).drop state.2.val) output = + nextOutput := by + rw [vertexWords_drop_last G H vertex state.2 hp] + rfl + have budget : rowFactor d - state.2.val = 1 := by omega + rw [words, budget, Nat.one_mul] + exact widen all (by omega) + · have more : state.2.val + 1 < rowFactor d := by omega + let next := advancePositionState positive after + have nextPositionValue : next.2.val = state.2.val + 1 := + nextPosition_val_of_lt positive state.2 more + have nextCount : next.2.val + n = rowFactor d := by omega + let tail := ih next nextCount nextOutput + have advance := singleStep _ _ _ (afterRow_moreStep positive H + (boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) + nextOutput countSuffix result) after more) + have all := sequence (sequence row advance) tail.execution + refine ⟨tail.finalState, ?_, tail.position_zero, ?_⟩ + · exact tail.caller_preserved + · have words : accumulate ((vertexWords G H vertex).drop state.2.val) output = + accumulate ((vertexWords G H vertex).drop next.2.val) nextOutput := by + rw [vertexWords_drop_succ G H vertex state.2, nextPositionValue] + rfl + rw [words] + apply widen all + have hcount : rowFactor d - state.2.val = n + 1 := by omega + have hnext : rowFactor d - next.2.val = n := by omega + rw [hcount, hnext, Nat.add_mul, Nat.one_mul] + omega + +def suffixInTime (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) + (remaining : Nat) (output countSuffix result : List Bool) : + VertexSuffixRun positive G H vertex state remaining output countSuffix result := + suffixRun_aux positive G H vertex remaining countSuffix result + (rowFactor d - state.2.val) state (by have h := state.2.isLt; omega) output + +structure VertexRun (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) + (remaining : Nat) (output countSuffix result : List Bool) where + finalState : State ρ d + caller_preserved : caller finalState = caller state + position_zero : finalState.2 = zeroPosition positive + execution : StateTransition.EvalsToInTime (TM2.step (program positive H)) + ⟨some (.inr .prepareRow), state, + boundaryTapes vertex.val remaining (encodeWords (rotationWords G)) output countSuffix result⟩ + (some ⟨some (.inr .vertexGuard), finalState, + boundaryTapes (vertex.val + 1) remaining (encodeWords (rotationWords G)) + (accumulate (vertexWords G H vertex) output) countSuffix result⟩) + (rowFactor d * (80 * ((encodeWords (rotationWords G)).length + 1) + 2)) + +def vertexInTime (positive : 0 < d) (G : Table v (degree d)) + (H : Table (cloudSize d) d) (vertex : Fin v) (state : State ρ d) + (position : state.2 = zeroPosition positive) + (remaining : Nat) (output countSuffix result : List Bool) : + VertexRun positive G H vertex state remaining output countSuffix result := by + let run := suffixInTime positive G H vertex state remaining output countSuffix result + refine ⟨run.finalState, run.caller_preserved, run.position_zero, ?_⟩ + have zero : state.2.val = 0 := congrArg Fin.val position + simpa only [zero, List.drop_zero, Nat.sub_zero] using run.execution + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFieldProfile.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFieldProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..f911a7a1409485474140cf7ee0a0faba3ec3648f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFieldProfile.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.MachineControl + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineFieldProfile + +open Turing + +abbrev Profile (q : Nat) := Fin q → Fin q → Bool + +def equalityProfile {q : Nat} (words : Fin q → List Bool) : Profile q := + fun i j => decide (words i = words j) + +theorem equalityProfile_encodeWord {q : Nat} (names : Fin q → Nat) (i j : Fin q) : + equalityProfile (fun k => encodeWord (names k)) i j = decide (names i = names j) := by + have h : encodeWord (names i) = encodeWord (names j) ↔ names i = names j := by + constructor + · intro heq + have hh := congrArg List.length heq + simpa only [encodeWord_length, Nat.add_right_cancel_iff] using hh + · rintro heq + rw [heq] + simp only [equalityProfile, h] + +section Transport +variable {K Λ σ τ : Type} [DecidableEq K] + +omit [DecidableEq K] in +theorem statement_roundtrip (e : σ ≃ τ) + (q : TM2.Stmt (fun _ : K => Bool) Λ τ) : + MachineControl.statement id e (MachineControl.statement id e.symm q) = q := by + induction q <;> simp_all [MachineControl.statement] + +def copyStateEquiv (σ : Type) : + ((σ × Bool × Option Bool) × Option Bool) ≃ MachineCompare.State σ where + toFun s := (s.1.1, s.1.2.1, s.1.2.2, s.2) + invFun s := ((s.1, s.2.1, s.2.2.1), s.2.2.2) + left_inv _ := rfl + right_inv _ := rfl + +def normalState (ambient : σ) : MachineCompare.State σ := (ambient, false, none, none) + +def copyStatement (q : TM2.Stmt (fun _ : K => Bool) Λ + ((σ × Bool × Option Bool) × Option Bool)) : + TM2.Stmt (fun _ : K => Bool) Λ (MachineCompare.State σ) := + MachineControl.statement id (copyStateEquiv σ) q + +def copyInCompareState (source destination scratch : K) + (hSD : source ≠ destination) (hST : source ≠ scratch) (hDT : destination ≠ scratch) + (firstLabel secondLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (MachineCompare.State σ)) + (atFirst : program firstLabel = copyStatement + (Reduction.MachineTransfer.loopAt source scratch id false firstLabel (some secondLabel))) + (atSecond : program secondLabel = copyStatement + (MachineCopy.forkLoop scratch source destination false secondLabel exit)) + (base : K → List Bool) (hScratch : base scratch = []) (ambient : σ) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some firstLabel, normalState ambient, base⟩ + (some ⟨exit, normalState ambient, + Function.update base destination (base source ++ base destination)⟩) + (2 * ((base source).length + 1)) := by + let e := copyStateEquiv σ + let view := MachineControl.program (Equiv.refl Λ) e.symm program + have hfirst : view firstLabel = + Reduction.MachineTransfer.loopAt source scratch id false firstLabel (some secondLabel) := by + dsimp [view, MachineControl.program] + rw [atFirst] + exact statement_roundtrip e.symm _ + have hsecond : view secondLabel = + MachineCopy.forkLoop scratch source destination false secondLabel exit := by + dsimp [view, MachineControl.program] + rw [atSecond] + exact statement_roundtrip e.symm _ + let run := MachineCopy.copyInTime source destination scratch hSD hST hDT false + firstLabel secondLabel exit view hfirst hsecond base hScratch (ambient, false, none) none + have hprogram : MachineControl.program (Equiv.refl Λ) e view = program := by + funext label + exact statement_roundtrip e (program label) + have hsim (a b : TM2.Cfg (fun _ : K => Bool) Λ ((σ × Bool × Option Bool) × Option Bool)) + (hab : TM2.step view a = some b) : + TM2.step program (MachineControl.configuration id e a) = + some (MachineControl.configuration id e b) := by + have hh := MachineControl.step_simulation (Equiv.refl Λ) e view a + rw [hprogram, hab] at hh + exact hh + have lifted := MachineComposition.liftExecutionInTime (TM2.step view) (TM2.step program) + (MachineControl.configuration id e) hsim run + simpa [MachineControl.configuration, copyStateEquiv, normalState, e] using lifted + +end Transport + +variable {K Λ σ : Type} [DecidableEq K] + +def nonDestructiveCompareInTime (left right workLeft workRight scratch : K) + (hleft : left ≠ workLeft ∧ left ≠ workRight ∧ left ≠ scratch) + (hright : right ≠ workLeft ∧ right ≠ workRight ∧ right ≠ scratch) + (hwork : workLeft ≠ workRight ∧ workLeft ≠ scratch ∧ workRight ≠ scratch) + (leftFirst leftSecond rightFirst rightSecond compareLabel : Λ) + (equalExit differentExit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (MachineCompare.State σ)) + (atLeftFirst : program leftFirst = copyStatement + (Reduction.MachineTransfer.loopAt left scratch id false leftFirst (some leftSecond))) + (atLeftSecond : program leftSecond = copyStatement + (MachineCopy.forkLoop scratch left workLeft false leftSecond (some rightFirst))) + (atRightFirst : program rightFirst = copyStatement + (Reduction.MachineTransfer.loopAt right scratch id false rightFirst (some rightSecond))) + (atRightSecond : program rightSecond = copyStatement + (MachineCopy.forkLoop scratch right workRight false rightSecond (some compareLabel))) + (atCompare : program compareLabel = + MachineCompare.loop workLeft workRight compareLabel equalExit differentExit) + (base : K → List Bool) (hWL : base workLeft = []) (hWR : base workRight = []) + (hScratch : base scratch = []) (ambient : σ) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some leftFirst, normalState ambient, base⟩ + (some ⟨if base left = base right then equalExit else differentExit, + normalState ambient, base⟩) + (2 * ((base left).length + 1) + 2 * ((base right).length + 1) + + max (base left).length (base right).length + 1) := by + let t₁ := Function.update base workLeft (base left) + let t₂ := Function.update t₁ workRight (base right) + have h₁ := copyInCompareState left workLeft scratch hleft.1 hleft.2.2 hwork.2.1 + leftFirst leftSecond (some rightFirst) program atLeftFirst atLeftSecond base hScratch ambient + simp only [hWL, List.append_nil] at h₁ + have hSR : t₁ right = base right := by simp [t₁, hright.1] + have hDR : t₁ workRight = [] := by simp [t₁, Ne.symm hwork.1, hWR] + have hTR : t₁ scratch = [] := by simp [t₁, Ne.symm hwork.2.1, hScratch] + have h₂ := copyInCompareState right workRight scratch hright.2.1 hright.2.2 hwork.2.2 + rightFirst rightSecond (some compareLabel) program atRightFirst atRightSecond t₁ hTR ambient + rw [hSR, hDR] at h₂ + simp only [List.append_nil] at h₂ + have hL : t₂ workLeft = base left := by simp [t₂, t₁, hwork.1] + have hR : t₂ workRight = base right := by simp [t₂] + have hrestore : Reduction.MachineTransfer.tapesAt workLeft workRight t₂ [] [] = base := by + funext p + by_cases hl : p = workLeft + · subst p + simp [Reduction.MachineTransfer.tapesAt, hwork.1, hWL] + · by_cases hr : p = workRight + · subst p + simp [Reduction.MachineTransfer.tapesAt, hWR] + · simp [Reduction.MachineTransfer.tapesAt, t₂, t₁, hl, hr] + have h₃ := MachineCompare.compareInTime workLeft workRight hwork.1 compareLabel + equalExit differentExit program atCompare t₂ ambient none none + rw [hL, hR, hrestore] at h₃ + let h₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ h₁ h₂ + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ h₁₂ h₃ + exact { toEvalsTo := run.toEvalsTo, steps_le_m := by have h := run.steps_le_m; omega } + +end IndependentSetsGames.Foundations.Complexity.MachineFieldProfile + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteAlphabet.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteAlphabet.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d239afb3582ac61eec6b91d5fb705eaa1196764 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteAlphabet.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Runtime +import OAI.Combinatorics.IndependentSets.Machines.MachineRepeat + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineFiniteAlphabet + +open Turing + +def FiniteAlphabet (M : FinTM2) : Prop := ∀ k, Finite (M.Γ k) + +theorem input_finite (M : FinTM2) : Finite (M.Γ M.k₀) := by + let := M.Γk₀Fin + infer_instance + +theorem of_homogeneous (M : FinTM2) {α : Type} [Finite α] + (alphabet : ∀ k, M.Γ k = α) : FiniteAlphabet M := by + intro k + rw [alphabet k] + infer_instance + +theorem of_bool (M : FinTM2) (alphabet : ∀ k, M.Γ k = Bool) : FiniteAlphabet M := + of_homogeneous M alphabet + +theorem of_equiv (M : FinTM2) {α : Type} [Finite α] + (alphabet : ∀ k, M.Γ k ≃ α) : FiniteAlphabet M := by + intro k + exact Finite.of_equiv α (alphabet k).symm + +theorem symbols_finite (M : FinTM2) (finiteAlphabet : FiniteAlphabet M) : + Finite (Σ k, M.Γ k) := by + let := M.kFin + let : ∀ k, Finite (M.Γ k) := finiteAlphabet + infer_instance + +theorem sequential_machine (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) + (hfirst : FiniteAlphabet first) (hsecond : FiniteAlphabet second) : + FiniteAlphabet (MachineSequential.machine first second relabel fallback) := by + intro tape + rcases tape with tape | tape | tape + · exact hfirst tape + · exact hsecond tape + · exact input_finite second + +theorem compose {α β γ αΓ βΓ γΓ : Type} + {ea : α → List αΓ} {eb : β → List βΓ} {ec : γ → List γΓ} + {f : α → β} {g : β → γ} + (first : TM2ComputableInPolyTime ea eb f) + (second : TM2ComputableInPolyTime eb ec g) (fallback : βΓ) + (hfirst : FiniteAlphabet first.tm) (hsecond : FiniteAlphabet second.tm) : + FiniteAlphabet (MachineSequential.compose first second fallback).tm := by + exact sequential_machine first.tm second.tm + (fun symbol => second.inputAlphabet.symm (first.outputAlphabet symbol)) + (second.inputAlphabet.symm fallback) hfirst hsecond + +theorem composeBits {α β γ : Type} + {ea : α → List Bool} {eb : β → List Bool} {ec : γ → List Bool} + {f : α → β} {g : β → γ} + (first : TM2ComputableInPolyTime ea eb f) + (second : TM2ComputableInPolyTime eb ec g) + (hfirst : FiniteAlphabet first.tm) (hsecond : FiniteAlphabet second.tm) : + FiniteAlphabet (MachineSequential.composeBits first second).tm := + compose first second false hfirst hsecond + +theorem repeat_machine (body : FinTM2) + (input : body.Γ body.k₀ ≃ Bool) (output : body.Γ body.k₁ ≃ Bool) + (hbody : FiniteAlphabet body) : + FiniteAlphabet (MachineRepeat.machine body input output) := by + intro tape + cases tape with + | inl tape => exact hbody tape + | inr _ => exact input_finite body + +end IndependentSetsGames.Foundations.Complexity.MachineFiniteAlphabet +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable + +open IndependentSetsGames.Foundations.Complexity + +theorem Driver.finiteAlphabet (q : Nat) : + MachineFiniteAlphabet.FiniteAlphabet (Driver.machine q) := by + intro k + change Finite Bool + infer_instance + +theorem Runtime.finiteAlphabet (q : Nat) : + MachineFiniteAlphabet.FiniteAlphabet (Runtime.tablePolynomialTime q).tm := + Driver.finiteAlphabet q + +end IndependentSetsGames.Foundations.PCP.AlphabetTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteSequence.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..da3d57777533aa804c2b6b9c510de4dfa137ca2c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteSequence.lean @@ -0,0 +1,225 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringFieldPlan +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineField + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineFiniteSequence + +open Turing MachineComposition + +variable {Command : Type} (LocalLabel : Command → Type) + +def Label : List Command → Type + | [] => Empty + | command :: commands => LocalLabel command ⊕ Label commands + +instance labelFintype [∀ command, Fintype (LocalLabel command)] + (commands : List Command) : Fintype (Label LocalLabel commands) := by + induction commands with + | nil => exact inferInstanceAs (Fintype Empty) + | cons command commands ih => + letI := ih + exact inferInstanceAs (Fintype (LocalLabel command ⊕ Label LocalLabel commands)) + +instance labelDecidableEq [∀ command, DecidableEq (LocalLabel command)] + (commands : List Command) : DecidableEq (Label LocalLabel commands) := by + induction commands with + | nil => exact inferInstanceAs (DecidableEq Empty) + | cons command commands ih => + letI := ih + exact inferInstanceAs (DecidableEq (LocalLabel command ⊕ Label LocalLabel commands)) + +variable (main : ∀ command, LocalLabel command) +variable {K Λ σ : Type} {Γ : K → Type} + +def entry : (commands : List Command) → (Label LocalLabel commands → Λ) → Option Λ → Option Λ + | [], _, exit => exit + | command :: _, labels, _ => some (labels (.inl (main command))) + +variable (localInstruction : ∀ command, (LocalLabel command → Λ) → Option Λ → + LocalLabel command → TM2.Stmt Γ Λ σ) + +def instruction : (commands : List Command) → (Label LocalLabel commands → Λ) → Option Λ → + Label LocalLabel commands → TM2.Stmt Γ Λ σ + | [], _, _, label => nomatch label + | command :: commands, labels, exit, .inl label => + localInstruction command (fun l => labels (.inl l)) + (entry LocalLabel main commands (fun l => labels (.inr l)) exit) label + | _ :: commands, labels, exit, .inr label => + instruction commands (fun l => labels (.inr l)) exit label + +variable {Data : Type} (result : Command → Data → Data) (cost : Command → Data → Nat) + +def resultOf : List Command → Data → Data + | [], data => data + | command :: commands, data => resultOf commands (result command data) + +def steps : List Command → Data → Nat + | [], _ => 0 + | command :: commands, data => cost command data + steps commands (result command data) + +variable [DecidableEq K] + +theorem trace (program : Λ → TM2.Stmt Γ Λ σ) + (invariant : Data → Prop) (state : Data → σ) (tapes : Data → ∀ k, List (Γ k)) + (commands : List Command) + (localInvariant : ∀ command ∈ commands, ∀ data, invariant data → + invariant (result command data)) + (localTrace : ∀ command ∈ commands, ∀ (labels : LocalLabel command → Λ) (exit : Option Λ), + (∀ l, program (labels l) = localInstruction command labels exit l) → + ∀ data, invariant data → + (advance (TM2.step program))^[cost command data] + (some ⟨some (labels (main command)), state data, tapes data⟩) = + some ⟨exit, state (result command data), tapes (result command data)⟩) + (labels : Label LocalLabel commands → Λ) (exit : Option Λ) + (atLabels : ∀ l, program (labels l) = + instruction LocalLabel main localInstruction commands labels exit l) + (data : Data) (valid : invariant data) : + (advance (TM2.step program))^[steps result cost commands data] + (some ⟨entry LocalLabel main commands labels exit, state data, tapes data⟩) = + some ⟨exit, state (resultOf result commands data), tapes (resultOf result commands data)⟩ := by + induction commands generalizing data with + | nil => rfl + | cons command commands ih => + have firstRun := localTrace command (by simp) + (fun l => labels (.inl l)) + (entry LocalLabel main commands (fun l => labels (.inr l)) exit) + (fun l => atLabels (.inl l)) data valid + have nextValid := localInvariant command (by simp) data valid + have tailRun := ih + (fun c hc d hd => localInvariant c (by simp [hc]) d hd) + (fun c hc => localTrace c (by simp [hc])) + (fun l => labels (.inr l)) (fun l => atLabels (.inr l)) + (result command data) nextValid + rw [steps, Nat.add_comm, Function.iterate_add_apply] + change (advance (TM2.step program))^[steps result cost commands (result command data)] + ((advance (TM2.step program))^[cost command data] + (some ⟨some (labels (.inl (main command))), state data, tapes data⟩)) = _ + rw [firstRun] + exact tailRun + +end IndependentSetsGames.Foundations.Complexity.MachineFiniteSequence +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachinePlan + +open Turing MachineComposition PCP PoweringFieldPlan + +variable {K Λ A : Type} [DecidableEq K] {vertices d max : Nat} + +abbrev Command (d max : Nat) := {op : Instruction d // op.radius ≤ max} +abbrev LocalLabel (op : Command d max) := PoweringMachineField.Label op.val +abbrev Label (commands : List (Command d max)) := MachineFiniteSequence.Label LocalLabel commands + +def entry (commands : List (Command d max)) (labels : Label commands → Λ) (exit : Option Λ) : Option Λ := + MachineFiniteSequence.entry LocalLabel (fun op => PoweringMachineField.entry op.val) + commands labels exit + +def instruction (placement : PoweringMachineTapes.Tape max → K) + (commands : List (Command d max)) (labels : Label commands → Λ) (exit : Option Λ) : + Label commands → TM2.Stmt (fun _ : K => Bool) Λ (MachineUnaryEqualityBit.State A) := + MachineFiniteSequence.instruction LocalLabel (fun op => PoweringMachineField.entry op.val) + (fun op => PoweringMachineField.instruction placement op.val op.property) + commands labels exit + +def result (graph : PortTables.Table vertices d) (placement : PoweringMachineTapes.Tape max → K) + (vertex : Fin vertices) (op : Command d max) (base : K → List Bool) : K → List Bool := + PoweringMachineField.finalTapes graph placement vertex op.val op.property base + +def finalTapes (graph : PortTables.Table vertices d) (placement : PoweringMachineTapes.Tape max → K) + (vertex : Fin vertices) (commands : List (Command d max)) (base : K → List Bool) : K → List Bool := + MachineFiniteSequence.resultOf (result graph placement vertex) commands base + +def steps (graph : PortTables.Table vertices d) (placement : PoweringMachineTapes.Tape max → K) + (vertex : Fin vertices) (commands : List (Command d max)) (base : K → List Bool) : Nat := + MachineFiniteSequence.steps (result graph placement vertex) + (fun op _ => PoweringMachineField.steps graph vertex op.val) commands base + +theorem planTrace (graph : PortTables.Table vertices d) + (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin vertices) (commands : List (Command d max)) + (labels : Label commands → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (MachineUnaryEqualityBit.State A)) + (atLabels : ∀ l, program (labels l) = instruction placement commands labels exit l) + (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineField.Ready graph placement vertex suffix base) (ambient : A) : + (advance (TM2.step program))^[steps graph placement vertex commands base] + (some ⟨entry commands labels exit, MachineUnaryEqualityBit.clean ambient, base⟩) = + some ⟨exit, MachineUnaryEqualityBit.clean ambient, + finalTapes graph placement vertex commands base⟩ := by + apply MachineFiniteSequence.trace LocalLabel (fun op => PoweringMachineField.entry op.val) + (fun op => PoweringMachineField.instruction placement op.val op.property) + (result graph placement vertex) (fun op _ => PoweringMachineField.steps graph vertex op.val) + program (PoweringMachineField.Ready graph placement vertex suffix) + (fun _ => MachineUnaryEqualityBit.clean ambient) id commands + · intro op _ tapes good + exact PoweringMachineField.ready_finalTapes graph placement distinct vertex op.val + op.property tapes suffix good + · intro op _ localLabels localExit atLocal tapes good + exact PoweringMachineField.fieldTrace graph placement distinct vertex op.val op.property + localLabels localExit program atLocal tapes suffix good ambient + · exact atLabels + · exact ready + +theorem ready_finalTapes (graph : PortTables.Table vertices d) + (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin vertices) (commands : List (Command d max)) (base : K → List Bool) + (suffix : List Bool) (ready : PoweringMachineField.Ready graph placement vertex suffix base) : + PoweringMachineField.Ready graph placement vertex suffix + (finalTapes graph placement vertex commands base) := by + induction commands generalizing base with + | nil => exact ready + | cons op commands ih => + apply ih + exact PoweringMachineField.ready_finalTapes graph placement distinct vertex op.val + op.property base suffix ready + +theorem finalTapes_output (graph : PortTables.Table vertices d) + (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin vertices) (commands : List (Command d max)) (base : K → List Bool) + (suffix : List Bool) (ready : PoweringMachineField.Ready graph placement vertex suffix base) : + finalTapes graph placement vertex commands base (placement (.inl 10)) = + PoweringMachineRow.encodeBits ((commands.map (fun op => evaluate graph vertex op.val)).reverse) ++ + base (placement (.inl 10)) := by + induction commands generalizing base with + | nil => rfl + | cons op commands ih => + have nextReady := PoweringMachineField.ready_finalTapes graph placement distinct vertex + op.val op.property base suffix ready + change finalTapes graph placement vertex commands + (result graph placement vertex op base) (placement (.inl 10)) = _ + dsimp only [result] + rw [ih _ nextReady, PoweringMachineField.finalTapes_output graph placement distinct vertex + op.val op.property base suffix ready] + simp only [List.map_cons, List.reverse_cons, PoweringMachineRow.encodeBits_append, + PoweringMachineRow.encodeBits, List.append_nil, + List.append_assoc] + +def boundedRowPlan (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + List (Command d (2 * (n + 1))) := + List.ofFn fun i : Fin (PoweringMachineRow.inputSize (n + 1) (PoweringRowData.slotCount d n)) => + let pair := (PoweringMachineRow.inputEquiv (n + 1) (PoweringRowData.slotCount d n)).symm i + ⟨directedFieldPlan n ports direction pair.1 pair.2, + directedFieldPlan_radius n ports direction pair.1 pair.2⟩ + +theorem boundedRowPlan_values (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + (boundedRowPlan n ports direction).map Subtype.val = rowPlan n ports direction := by + rw [boundedRowPlan, rowPlan, List.map_ofFn] + rfl + +theorem rowPlan_output (graph : PortTables.Table vertices d) + (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) + (placement : PoweringMachineTapes.Tape (2 * (n + 1)) → K) + (distinct : Function.Injective placement) (vertex : Fin vertices) (base : K → List Bool) + (suffix : List Bool) (ready : PoweringMachineField.Ready graph placement vertex suffix base) : + finalTapes graph placement vertex (boundedRowPlan n ports direction).reverse base + (placement (.inl 10)) = + PoweringRowData.dataTape graph n (direction, vertex, ports) ++ base (placement (.inl 10)) := by + rw [finalTapes_output graph placement distinct vertex _ base suffix ready] + rw [List.map_reverse, List.reverse_reverse, PoweringFieldPlan.dataTape_eq_plan] + have h := congrArg (List.map (evaluate graph vertex)) (boundedRowPlan_values n ports direction) + simpa only [List.map_map, Function.comp_def] using + congrArg (fun bits => PoweringMachineRow.encodeBits bits ++ base (placement (.inl 10))) h + +end IndependentSetsGames.Foundations.Complexity.PoweringMachinePlan + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteTable.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteTable.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fcc75203d76ae98b3b8c92bf869949fd0ff41d3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFiniteTable.lean @@ -0,0 +1,252 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Machine +import OAI.Combinatorics.IndependentSets.PCP.GraphIterationBounds +import OAI.Combinatorics.IndependentSets.Machines.MachineInitialHeaders + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineFiniteTable + +open Turing +open IndependentSetsGames.Reduction.MachineSubstitution + +variable {K Λ σ : Type} [DecidableEq K] [DecidableEq σ] +variable {Γ : K → Type} + +def dispatch (dst : K) (table : σ → List (Γ dst)) + (next : TM2.Stmt Γ Λ σ) : List σ → TM2.Stmt Γ Λ σ + | [] => next + | key :: rest => + .branch (fun state => decide (state = key)) + (pushWord dst (table key).reverse next) (dispatch dst table next rest) + +theorem stepAux_dispatch (dst : K) (table : σ → List (Γ dst)) + (next : TM2.Stmt Γ Λ σ) (keys : List σ) (state : σ) + (hstate : state ∈ keys) (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (dispatch dst table next keys) state tapes = + TM2.stepAux next state (Function.update tapes dst (table state ++ tapes dst)) := by + induction keys with + | nil => simp at hstate + | cons key rest ih => + by_cases h : state = key + · subst state + simp only [dispatch, TM2.stepAux, decide_true, Bool.cond_true] + simpa only [List.reverse_reverse] using + stepAux_pushWord dst (table key).reverse next key tapes + · have hm : state ∈ rest := (List.mem_cons.mp hstate).resolve_left h + simpa only [dispatch, TM2.stepAux, h, decide_false, Bool.cond_false] using ih hm + +omit [DecidableEq K] in + +theorem dispatch_push_bound (dst : K) (table : σ → List (Γ dst)) + (next : TM2.Stmt Γ Λ σ) (keys : List σ) : + Runtime.statementPushBound (dispatch dst table next keys) ≤ + (keys.map (fun state => (table state).length)).sum + + Runtime.statementPushBound next := by + induction keys with + | nil => simp [dispatch] + | cons key rest ih => + simp only [dispatch, Runtime.statementPushBound, statementPushBound_pushWord, + List.length_reverse, List.map_cons, List.sum_cons] + apply max_le <;> omega + +def emit (dst : K) (table : σ → List (Γ dst)) (keys : List σ) + (next : TM2.Stmt Γ Λ σ) : TM2.Stmt Γ Λ σ := + dispatch dst table next keys + +def tableBound (dst : K) (table : σ → List (Γ dst)) (keys : List σ) : ℕ := + (keys.map (fun state => (table state).length)).sum + +theorem stepAux_emit (dst : K) (table : σ → List (Γ dst)) + (keys : List σ) (hkeys : ∀ state, state ∈ keys) (next : TM2.Stmt Γ Λ σ) (state : σ) (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (emit dst table keys next) state tapes = + TM2.stepAux next state (Function.update tapes dst (table state ++ tapes dst)) := + stepAux_dispatch dst table next keys state (hkeys state) tapes + +omit [DecidableEq K] in +theorem emit_push_bound (dst : K) (table : σ → List (Γ dst)) + (keys : List σ) (next : TM2.Stmt Γ Λ σ) : + Runtime.statementPushBound (emit dst table keys next) ≤ + tableBound dst table keys + Runtime.statementPushBound next := + dispatch_push_bound dst table next _ + +def emitInTime (dst : K) (table : σ → List (Γ dst)) + (keys : List σ) (hkeys : ∀ state, state ∈ keys) + (program : Λ → TM2.Stmt Γ Λ σ) (label exitLabel : Λ) + (atLabel : program label = emit dst table keys (.goto (fun _ => exitLabel))) + (state : σ) (tapes : ∀ k, List (Γ k)) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some label, state, tapes⟩ + (some ⟨some exitLabel, state, + Function.update tapes dst (table state ++ tapes dst)⟩) 1 where + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (program label) state tapes) = _ + rw [atLabel, stepAux_emit dst table keys hkeys] + rfl + steps_le_m := Nat.le_refl _ + +omit [DecidableEq σ] in +theorem output_frame (dst : K) (table : σ → List (Γ dst)) + (state : σ) (tapes : ∀ k, List (Γ k)) (k : K) (h : k ≠ dst) : + (Function.update tapes dst (table state ++ tapes dst)) k = tapes k := by + simp [Function.update, h] + +end IndependentSetsGames.Foundations.Complexity.MachineFiniteTable + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineModel + +open Turing Complexity Hastad + +inductive Tape + | input | «variables» | counter | index | field (slot : Fin 6) + | scratch | reversed | output + deriving DecidableEq + +deriving instance Fintype for Tape + +abbrev Signs := Bool × Bool × Bool +abbrev State := Signs × Option Bool +abbrev Alphabet (_ : Tape) := Bool + +inductive CopyPhase + | tailVariables (slot : Fin 3) + | tailIndex (slot : Fin 3) + | variableName (slot : Fin 3) + | reverseIndex (slot : Fin 3) (orientation : Bool) + | dummyVariables | dummyIndex | dummyReverse + deriving DecidableEq + +deriving instance Fintype for CopyPhase + +inductive Label + | headerStart (slot : Fin 2) | headerLoop (slot : Fin 2) + | scanN | restoreN | scanM1 | restoreM1 | closeFirst + | scanM6 | restoreM6 | closeSecond | initializeIndex | guard + | fieldStart (slot : Fin 6) | fieldLoop (slot : Fin 6) | loadSigns + | scan (phase : CopyPhase) | restore (phase : CopyPhase) + | closeTail (slot : Fin 3) (orientation : Bool) + | closeReverse (slot : Fin 3) (orientation : Bool) + | relation (slot : Fin 3) (orientation : Bool) + | cleanupField (slot : Fin 6) | incrementIndex + | closeDummyTail | closeDummyReverse | dummyRelation + | cleanupFinal (slot : Fin 3) | reset | finalReverse + deriving DecidableEq + +deriving instance Fintype for Label + +def initialState : State := ((false, false, false), none) + +def stateKeys : List State := + [false, true].flatMap fun a => [false, true].flatMap fun b => + [false, true].flatMap fun c => + [none, some false, some true].map fun register => ((a, b, c), register) + +theorem stateKeys_complete (state : State) : state ∈ stateKeys := by + rcases state with ⟨⟨a, b, c⟩, register⟩ + cases a <;> cases b <;> cases c <;> cases register with + | none => simp [stateKeys] + | some bit => cases bit <;> simp [stateKeys] + +def nameField (slot : Fin 3) : Fin 6 := ⟨2 * slot.val, by omega⟩ + +def copySource : CopyPhase → Tape + | .tailVariables _ | .dummyVariables => .«variables» + | .variableName slot => .field (nameField slot) + | _ => .index + +def copyScale : CopyPhase → Nat + | .reverseIndex _ _ | .dummyReverse => 6 + | _ => 1 + +def copyNext : CopyPhase → Label + | .tailVariables slot => .scan (.tailIndex slot) + | .tailIndex slot => .closeTail slot false + | .variableName slot => .closeTail slot true + | .reverseIndex slot orientation => .closeReverse slot orientation + | .dummyVariables => .scan .dummyIndex + | .dummyIndex => .closeDummyTail + | .dummyReverse => .closeDummyReverse + +def relationNext (slot : Fin 3) (orientation : Bool) : Label := + if orientation then + if h : slot.val + 1 < 3 then .scan (.tailVariables ⟨slot.val + 1, h⟩) + else .cleanupField 0 + else .scan (.variableName slot) + +def finalTape (slot : Fin 3) : Tape := + if slot.val = 0 then .«variables» else if slot.val = 1 then .counter else .index + +def drain (tape : Tape) (again next : Label) : TM2.Stmt Alphabet Label State := + MachineDrain.drain tape again (some next) + +def headerTape (slot : Fin 2) : Tape := if slot.val = 0 then .«variables» else .counter + +def relationOutput (slot : Fin 3) (orientation : Bool) (state : State) : List Bool := + (encodeWords (RawInitialRows.relationWordsFor state.1 + (RawInitialTables.slotOrder.symm slot) orientation)).reverse + +def program : Label → TM2.Stmt Alphabet Label State + | .headerStart slot => SourceMachine.fieldStart (headerTape slot) (.headerLoop slot) + | .headerLoop slot => SourceMachine.fieldLoop .input (headerTape slot) (.headerLoop slot) + (if slot.val = 0 then some (.headerStart 1) else some .scanN) + | .scanN => MachineInitialHeaders.prefixScan .«variables» .scratch .reversed 1 .scanN .restoreN + | .restoreN => Reduction.MachineTransfer.loopAt .scratch .«variables» id false .restoreN (some .scanM1) + | .scanM1 => MachineInitialHeaders.prefixScan .counter .scratch .reversed 1 .scanM1 .restoreM1 + | .restoreM1 => Reduction.MachineTransfer.loopAt .scratch .counter id false .restoreM1 (some .closeFirst) + | .closeFirst => Reduction.MachineSubstitution.pushWord .reversed [true, false] + (.goto fun _ => .scanM6) + | .scanM6 => MachineInitialHeaders.prefixScan .counter .scratch .reversed 6 .scanM6 .restoreM6 + | .restoreM6 => Reduction.MachineTransfer.loopAt .scratch .counter id false .restoreM6 (some .closeSecond) + | .closeSecond => Reduction.MachineSubstitution.pushWord .reversed [true, false] + (.goto fun _ => .initializeIndex) + | .initializeIndex => .push .index (fun _ => false) (.goto fun _ => .guard) + | .guard => MachineUnaryCounter.guard .counter (.fieldStart 0) (.scan .dummyVariables) + | .fieldStart slot => SourceMachine.fieldStart (.field slot) (.fieldLoop slot) + | .fieldLoop slot => SourceMachine.fieldLoop .input (.field slot) (.fieldLoop slot) + (if h : slot.val + 1 < 6 then some (.fieldStart ⟨slot.val + 1, h⟩) + else some .loadSigns) + | .loadSigns => + .peek (.field 1) (fun state head => ((head.getD false, state.1.2), state.2)) + (.peek (.field 3) (fun state head => ((state.1.1, head.getD false, state.1.2.2), state.2)) + (.peek (.field 5) (fun state head => ((state.1.1, state.1.2.1, head.getD false), state.2)) + (.load (fun state => (state.1, none)) (.goto fun _ => .scan (.tailVariables 0))))) + | .scan phase => MachineInitialHeaders.prefixScan (copySource phase) .scratch .reversed + (copyScale phase) (.scan phase) (.restore phase) + | .restore phase => Reduction.MachineTransfer.loopAt .scratch (copySource phase) id false + (.restore phase) (some (copyNext phase)) + | .closeTail slot orientation => .push .reversed (fun _ => false) + (.goto fun _ => .scan (.reverseIndex slot orientation)) + | .closeReverse slot orientation => Reduction.MachineSubstitution.pushWord .reversed + (encodeWord (2 * slot.val + if orientation then 0 else 1)) + (.goto fun _ => .relation slot orientation) + | .relation slot orientation => MachineFiniteTable.emit .reversed + (relationOutput slot orientation) + stateKeys (.goto fun _ => relationNext slot orientation) + | .cleanupField slot => drain (.field slot) (.cleanupField slot) + (if h : slot.val + 1 < 6 then .cleanupField ⟨slot.val + 1, h⟩ else .incrementIndex) + | .incrementIndex => .push .index (fun _ => true) (.goto fun _ => .guard) + | .closeDummyTail => .push .reversed (fun _ => false) (.goto fun _ => .scan .dummyReverse) + | .closeDummyReverse => .push .reversed (fun _ => false) (.goto fun _ => .dummyRelation) + | .dummyRelation => Reduction.MachineSubstitution.pushWord .reversed + (encodeWords (GraphTables.relationWords (GraphTables.relationOf (fun _ _ => true)))) + (.goto fun _ => .cleanupFinal 0) + | .cleanupFinal slot => drain (finalTape slot) (.cleanupFinal slot) + (if h : slot.val + 1 < 3 then .cleanupFinal ⟨slot.val + 1, h⟩ else .reset) + | .reset => .load (fun _ => initialState) (.goto fun _ => .finalReverse) + | .finalReverse => Reduction.MachineTransfer.loopAt .reversed .output id false .finalReverse none + +def machine : FinTM2 where + K := Tape + k₀ := .input + k₁ := .output + Γ := Alphabet + Λ := Label + main := .headerStart 0 + σ := State + initialState := initialState + m := program + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineModel + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFixedBlockMap.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFixedBlockMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d5a862da6681586b8537510f8f77ebdba41cb83 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFixedBlockMap.lean @@ -0,0 +1,212 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineFixedBlockMap + +open Turing + +abbrev Buffer (N : Nat) := Fin N → Bool + +def emptyBuffer (N : Nat) : Buffer N := fun _ => false + +section Chains + +variable {K Λ σ : Type} {N : Nat} + +def readSlots (src : K) : List (Fin N) → + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) → + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) + | [], next => next + | i :: slots, next => + .pop src (fun state head => + (state.1, Function.update state.2 i (head.getD false))) + (readSlots src slots next) + +def fill (slots : List (Fin N)) (bits buffer : Buffer N) : Buffer N := + slots.foldl (fun buffer i => Function.update buffer i (bits i)) buffer + +theorem fill_apply (slots : List (Fin N)) (bits buffer : Buffer N) (i : Fin N) : + fill slots bits buffer i = if i ∈ slots then bits i else buffer i := by + induction slots generalizing buffer with + | nil => simp [fill] + | cons j slots ih => + change fill slots bits (Function.update buffer j (bits j)) i = _ + rw [ih] + by_cases hm : i ∈ slots + · simp [hm] + · by_cases he : i = j <;> simp [hm, he] + +@[simp] theorem fill_all (bits buffer : Buffer N) : + fill (List.ofFn id) bits buffer = bits := by + funext i + simp [fill_apply, List.mem_ofFn] + +variable [DecidableEq K] + +theorem stepAux_readSlots (src : K) (slots : List (Fin N)) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (ambient : σ) (bits buffer : Buffer N) (tapes : K → List Bool) + (suffix : List Bool) : + TM2.stepAux (readSlots src slots next) (ambient, buffer) + (Function.update tapes src (slots.map bits ++ suffix)) = + TM2.stepAux next (ambient, fill slots bits buffer) + (Function.update tapes src suffix) := by + induction slots generalizing buffer tapes with + | nil => simp [readSlots, fill] + | cons i slots ih => + simpa only [readSlots, List.map_cons, List.cons_append, TM2.stepAux, + Function.update_self, List.head?_cons, Option.getD_some, List.tail_cons, + Function.update_idem, fill, List.foldl_cons] using + ih (Function.update buffer i (bits i)) tapes + +theorem stepAux_readAll (src : K) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (state : σ × Buffer N) (bits : Buffer N) (tapes : K → List Bool) + (suffix : List Bool) (hinput : tapes src = List.ofFn bits ++ suffix) : + TM2.stepAux (readSlots src (List.ofFn id) next) state tapes = + TM2.stepAux next (state.1, bits) (Function.update tapes src suffix) := by + have h := stepAux_readSlots src (List.ofFn id) next state.1 bits state.2 tapes suffix + have hin : Function.update tapes src ((List.ofFn id).map bits ++ suffix) = tapes := by + simpa only [List.map_ofFn, Function.comp_id, ← hinput] using + Function.update_eq_self src tapes + rw [hin, fill_all] at h + exact h + +omit [DecidableEq K] in +theorem statementPushBound_readSlots (src : K) (slots : List (Fin N)) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) : + Runtime.statementPushBound (readSlots src slots next) = + Runtime.statementPushBound next := by + induction slots with + | nil => rfl + | cons i slots ih => exact ih + +def writeSlots {M : Nat} (dst : K) (emit : σ → Buffer M) : List (Fin M) → + TM2.Stmt (fun _ : K => Bool) Λ σ → TM2.Stmt (fun _ : K => Bool) Λ σ + | [], next => next + | i :: slots, next => .push dst (fun state => emit state i) (writeSlots dst emit slots next) + +theorem stepAux_writeSlots {M : Nat} (dst : K) (emit : σ → Buffer M) + (slots : List (Fin M)) (next : TM2.Stmt (fun _ : K => Bool) Λ σ) + (state : σ) (tapes : K → List Bool) : + TM2.stepAux (writeSlots dst emit slots next) state tapes = + TM2.stepAux next state + (Function.update tapes dst ((slots.map (emit state)).reverse ++ tapes dst)) := by + induction slots generalizing tapes with + | nil => simp [writeSlots] + | cons i slots ih => + simp only [writeSlots, TM2.stepAux] + rw [ih] + simp only [Function.update_self, Function.update_idem, List.map_cons, + List.reverse_cons, List.append_assoc, List.singleton_append] + +omit [DecidableEq K] in +theorem statementPushBound_writeSlots {M : Nat} (dst : K) (emit : σ → Buffer M) + (slots : List (Fin M)) (next : TM2.Stmt (fun _ : K => Bool) Λ σ) : + Runtime.statementPushBound (writeSlots dst emit slots next) = + slots.length + Runtime.statementPushBound next := by + induction slots with + | nil => simp [writeSlots] + | cons i slots ih => + simp only [writeSlots, Runtime.statementPushBound, ih, List.length_cons] + omega + +end Chains + +section Block + +variable {K Λ σ : Type} {N M : Nat} + +def blockStmt (src dst : K) (F : Buffer N → Buffer M) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) : + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) := + readSlots src (List.ofFn id) + (writeSlots dst (fun state => F state.2) (List.ofFn id).reverse + (.load (fun state => (state.1, emptyBuffer N)) next)) + +def finishAt (exit : Option Λ) : TM2.Stmt (fun _ : K => Bool) Λ σ := + match exit with + | none => .halt + | some label => .goto fun _ => label + +def blockMapAt (src dst : K) (F : Buffer N → Buffer M) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) := + blockStmt src dst F (finishAt exit) + +theorem statementPushBound_blockStmt (src dst : K) (F : Buffer N → Buffer M) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) : + Runtime.statementPushBound (blockStmt src dst F next) = + M + Runtime.statementPushBound next := by + simp only [blockStmt, statementPushBound_readSlots, statementPushBound_writeSlots, + Runtime.statementPushBound, List.length_reverse, List.length_ofFn] + +theorem statementPushBound_blockMapAt (src dst : K) (F : Buffer N → Buffer M) + (exit : Option Λ) : + Runtime.statementPushBound (blockMapAt (σ := σ) src dst F exit) = M := by + cases exit <;> simp [blockMapAt, statementPushBound_blockStmt, finishAt, + Runtime.statementPushBound] + +variable [DecidableEq K] + +theorem stepAux_blockStmt (src dst : K) (F : Buffer N → Buffer M) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : σ × Buffer N) (tapes : K → List Bool) + (hinput : tapes src = List.ofFn bits ++ suffix) : + TM2.stepAux (blockStmt src dst F next) state tapes = + TM2.stepAux next (state.1, emptyBuffer N) + (Function.update (Function.update tapes src suffix) dst + (List.ofFn (F bits) ++ tapes dst)) := by + unfold blockStmt + rw [stepAux_readAll src _ state bits tapes suffix hinput, stepAux_writeSlots] + simp only [List.map_reverse, List.map_ofFn, Function.comp_id, List.reverse_reverse, + Function.update_of_ne (Ne.symm hne), TM2.stepAux] + +theorem stepAux_blockMapAt (src dst : K) (F : Buffer N → Buffer M) + (exit : Option Λ) (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : σ × Buffer N) (tapes : K → List Bool) + (hinput : tapes src = List.ofFn bits ++ suffix) : + TM2.stepAux (blockMapAt src dst F exit) state tapes = + { l := exit, var := (state.1, emptyBuffer N), + stk := Function.update (Function.update tapes src suffix) dst + (List.ofFn (F bits) ++ tapes dst) } := by + rw [blockMapAt, stepAux_blockStmt src dst F _ hne bits suffix state tapes hinput] + cases exit <;> rfl + +theorem step_blockMapAt (src dst : K) (F : Buffer N → Buffer M) + (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (label : Λ) (hprogram : program label = blockMapAt src dst F exit) + (hne : src ≠ dst) (bits : Buffer N) (suffix : List Bool) + (state : σ × Buffer N) (tapes : K → List Bool) + (hinput : tapes src = List.ofFn bits ++ suffix) : + TM2.step program { l := some label, var := state, stk := tapes } = + some { l := exit + var := (state.1, emptyBuffer N) + stk := Function.update (Function.update tapes src suffix) dst + (List.ofFn (F bits) ++ tapes dst) } := by + simp only [TM2.step, hprogram, + stepAux_blockMapAt src dst F exit hne bits suffix state tapes hinput] + +end Block + +def machine {N M : Nat} (F : Buffer N → Buffer M) : FinTM2 where + K := Bool + k₀ := false + k₁ := true + Γ _ := Bool + Λ := Unit + main := () + σ := Unit × Buffer N + initialState := ((), emptyBuffer N) + m _ := blockMapAt false true F none + +theorem machine_statementPushBound {N M : Nat} (F : Buffer N → Buffer M) : + Runtime.statementPushBound ((machine F).m ()) = M := + statementPushBound_blockMapAt false true F none + +end IndependentSetsGames.Foundations.Complexity.MachineFixedBlockMap + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFixedDivMod.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFixedDivMod.lean new file mode 100644 index 0000000000000000000000000000000000000000..1162eaee08a7d3774c1328508aa6b18e7128f9c0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineFixedDivMod.lean @@ -0,0 +1,486 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.PushWord + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineFixedDivMod + +open Turing +open Reduction.MachineSubstitution (pushWord stepAux_pushWord statementPushBound_pushWord) + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool +abbrev State (σ : Type) (d : Nat) := (σ × Fin d) × Option Bool + +def residue (d : Nat) (positive : 0 < d) (n : Nat) : Fin d := + ⟨n % d, Nat.mod_lt n positive⟩ + +def nextResidue (d : Nat) (positive : 0 < d) (r : Fin d) : Fin d := + residue d positive (r.val + 1) + +theorem nextResidue_residue (d : Nat) (positive : 0 < d) (n : Nat) : + nextResidue d positive (residue d positive n) = residue d positive (n + 1) := by + apply Fin.ext + change (n % d + 1) % d = (n + 1) % d + simp only [Nat.add_mod, Nat.mod_mod] + +def scanLoop (d : Nat) (positive : 0 < d) (source quotient : K) + (scanLabel : Λ) (emitterLabel : Fin d → Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ d) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.branch (fun state => decide ((nextResidue d positive state.1.2).val = 0)) + (.push quotient (fun _ => true) + (.load (fun state => ((state.1.1, nextResidue d positive state.1.2), state.2)) + (.goto fun _ => scanLabel))) + (.load (fun state => ((state.1.1, nextResidue d positive state.1.2), state.2)) + (.goto fun _ => scanLabel))) + (.push source (fun _ => false) (.goto fun state => emitterLabel state.1.2))) + +def emitter (d : Nat) (positive : 0 < d) (remainder : K) (exit : Option Λ) + (r : Fin d) : TM2.Stmt (Alphabet (K := K)) Λ (State σ d) := + pushWord remainder (List.replicate r.val true) + (.load (fun state => ((state.1.1, residue d positive 0), none)) + (Reduction.MachineTransfer.exitAt remainder exit)) + +omit [DecidableEq K] in +theorem scanPushBound (d : Nat) (positive : 0 < d) (source quotient : K) + (scanLabel : Λ) (emitterLabel : Fin d → Λ) : + Runtime.statementPushBound (scanLoop (σ := σ) d positive source quotient scanLabel + emitterLabel) = 1 := rfl + +omit [DecidableEq K] in +theorem emitterPushBound (d : Nat) (positive : 0 < d) (remainder : K) + (exit : Option Λ) (r : Fin d) : + Runtime.statementPushBound (emitter (σ := σ) d positive remainder exit r) = r.val := by + cases exit <;> + simp [emitter, statementPushBound_pushWord, Runtime.statementPushBound, + Reduction.MachineTransfer.exitAt] + +abbrev tapes (source quotient remainder : K) (base : K → List Bool) + (input quotientWord remainderWord : List Bool) : K → List Bool := + MachineCopy.forkTapes source quotient remainder base input quotientWord remainderWord + +def unaryTapes (source quotient remainder : K) (base : K → List Bool) + (n q r : Nat) (sourceSuffix quotientSuffix remainderSuffix : List Bool) : K → List Bool := + tapes source quotient remainder base (encodeWord n ++ sourceSuffix) + (encodeWord q ++ quotientSuffix) (encodeWord r ++ remainderSuffix) + +@[simp] theorem unaryTapes_source (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (base : K → List Bool) (n q r : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : + unaryTapes source quotient remainder base n q r sourceSuffix quotientSuffix + remainderSuffix source = encodeWord n ++ sourceSuffix := by + simp [unaryTapes, sourceQuotient, sourceRemainder] + +@[simp] theorem unaryTapes_quotient (source quotient remainder : K) + (quotientRemainder : quotient ≠ remainder) (base : K → List Bool) (n q r : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : + unaryTapes source quotient remainder base n q r sourceSuffix quotientSuffix + remainderSuffix quotient = encodeWord q ++ quotientSuffix := by + simp [unaryTapes, quotientRemainder] + +@[simp] theorem unaryTapes_remainder (source quotient remainder : K) + (base : K → List Bool) (n q r : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : + unaryTapes source quotient remainder base n q r sourceSuffix quotientSuffix + remainderSuffix remainder = encodeWord r ++ remainderSuffix := by + simp [unaryTapes] + +theorem unaryTapes_other (source quotient remainder other : K) + (notSource : other ≠ source) (notQuotient : other ≠ quotient) + (notRemainder : other ≠ remainder) (base : K → List Bool) (n q r : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) : + unaryTapes source quotient remainder base n q r sourceSuffix quotientSuffix + remainderSuffix other = base other := by + simp [unaryTapes, tapes, MachineCopy.forkTapes, notSource, notQuotient, notRemainder] + +theorem update_source (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (base : K → List Bool) + (input quotientWord remainderWord replacement : List Bool) : + Function.update (tapes source quotient remainder base input quotientWord remainderWord) + source replacement = tapes source quotient remainder base replacement quotientWord remainderWord := by + funext k + by_cases hs : k = source + · subst k + simp [tapes, MachineCopy.forkTapes, sourceQuotient, sourceRemainder] + · by_cases hq : k = quotient + · subst k + simp [tapes, MachineCopy.forkTapes, Ne.symm sourceQuotient, quotientRemainder] + · by_cases hr : k = remainder + · subst k + simp [tapes, MachineCopy.forkTapes, Ne.symm sourceRemainder] + · simp [tapes, MachineCopy.forkTapes, hs, hq, hr] + +private theorem update_quotient (source quotient remainder : K) + (quotientRemainder : quotient ≠ remainder) (base : K → List Bool) + (input quotientWord remainderWord replacement : List Bool) : + Function.update (tapes source quotient remainder base input quotientWord remainderWord) + quotient replacement = tapes source quotient remainder base input replacement remainderWord := by + funext k + by_cases hq : k = quotient + · subst k + simp [tapes, MachineCopy.forkTapes, quotientRemainder] + · by_cases hr : k = remainder + · subst k + simp [tapes, MachineCopy.forkTapes, Ne.symm quotientRemainder] + · simp [tapes, MachineCopy.forkTapes, hq, hr] + +private theorem update_remainder (source quotient remainder : K) (base : K → List Bool) + (input quotientWord remainderWord replacement : List Bool) : + Function.update (tapes source quotient remainder base input quotientWord remainderWord) + remainder replacement = tapes source quotient remainder base input quotientWord replacement := by + simp [tapes, MachineCopy.forkTapes] + +theorem scanAux_true (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (base : K → List Bool) (input quotientWord remainderWord : List Bool) + (ambient : σ) (r : Fin d) (register : Option Bool) : + TM2.stepAux (scanLoop d positive source quotient scanLabel emitterLabel) + ((ambient, r), register) + (tapes source quotient remainder base (true :: input) quotientWord remainderWord) = + ⟨some scanLabel, ((ambient, nextResidue d positive r), some true), + tapes source quotient remainder base input + (if (nextResidue d positive r).val = 0 then true :: quotientWord else quotientWord) + remainderWord⟩ := by + by_cases hcarry : (nextResidue d positive r).val = 0 <;> + simp [scanLoop, TM2.stepAux, sourceQuotient, sourceRemainder, quotientRemainder, + update_source, update_quotient, hcarry] + +theorem scanAux_false (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (base : K → List Bool) (input quotientWord remainderWord : List Bool) + (ambient : σ) (r : Fin d) (register : Option Bool) : + TM2.stepAux (scanLoop d positive source quotient scanLabel emitterLabel) + ((ambient, r), register) + (tapes source quotient remainder base (false :: input) quotientWord remainderWord) = + ⟨some (emitterLabel r), ((ambient, r), some false), + tapes source quotient remainder base (false :: input) quotientWord remainderWord⟩ := by + simp [scanLoop, TM2.stepAux, sourceQuotient, sourceRemainder, quotientRemainder, + update_source] + +theorem scanStep_succ (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (base : K → List Bool) (n k : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step program ⟨some scanLabel, ((ambient, residue d positive k), register), + unaryTapes source quotient remainder base (n + 1) (k / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩ = + some ⟨some scanLabel, ((ambient, residue d positive (k + 1)), some true), + unaryTapes source quotient remainder base n ((k + 1) / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩ := by + change some (TM2.stepAux (program scanLabel) ((ambient, residue d positive k), register) + (unaryTapes source quotient remainder base (n + 1) (k / d) 0 + sourceSuffix quotientSuffix remainderSuffix)) = _ + rw [atScan] + simp only [unaryTapes, encodeWord, List.replicate_succ, List.cons_append] + rw [scanAux_true d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder, nextResidue_residue] + by_cases hmod : (k + 1) % d = 0 + · rw [Nat.succ_div_of_mod_eq_zero hmod] + simp [residue, hmod, List.replicate_succ] + · rw [Nat.succ_div_of_mod_ne_zero hmod] + simp [residue, hmod] + +theorem scanStep_zero (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (base : K → List Bool) (q : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (r : Fin d) (register : Option Bool) : + TM2.step program ⟨some scanLabel, ((ambient, r), register), + unaryTapes source quotient remainder base 0 q 0 + sourceSuffix quotientSuffix remainderSuffix⟩ = + some ⟨some (emitterLabel r), ((ambient, r), some false), + unaryTapes source quotient remainder base 0 q 0 + sourceSuffix quotientSuffix remainderSuffix⟩ := by + change some (TM2.stepAux (program scanLabel) ((ambient, r), register) + (unaryTapes source quotient remainder base 0 q 0 + sourceSuffix quotientSuffix remainderSuffix)) = _ + rw [atScan] + simp only [unaryTapes, encodeWord, List.replicate_zero, List.nil_append, + List.singleton_append] + rw [scanAux_false d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder] + +theorem emitterStep (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (emitterLabel : Fin d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atEmitter : ∀ r, program (emitterLabel r) = emitter d positive remainder exit r) + (base : K → List Bool) (n q : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (r : Fin d) (register : Option Bool) : + TM2.step program ⟨some (emitterLabel r), ((ambient, r), register), + unaryTapes source quotient remainder base n q 0 + sourceSuffix quotientSuffix remainderSuffix⟩ = + some ⟨exit, ((ambient, residue d positive 0), none), + unaryTapes source quotient remainder base n q r.val + sourceSuffix quotientSuffix remainderSuffix⟩ := by + change some (TM2.stepAux (program (emitterLabel r)) ((ambient, r), register) + (unaryTapes source quotient remainder base n q 0 + sourceSuffix quotientSuffix remainderSuffix)) = _ + rw [atEmitter] + unfold emitter + rw [stepAux_pushWord] + simp only [unaryTapes, MachineCopy.forkTapes_right, List.reverse_replicate] + rw [update_remainder] + cases exit <;> + simp [TM2.stepAux, Reduction.MachineTransfer.exitAt, encodeWord, List.append_assoc] + +theorem trace_fromCount (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (exit : Option Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (atEmitter : ∀ r, program (emitterLabel r) = emitter d positive remainder exit r) + (base : K → List Bool) (n k : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 2] + (some ⟨some scanLabel, ((ambient, residue d positive k), register), + unaryTapes source quotient remainder base n (k / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩) = + some ⟨exit, ((ambient, residue d positive 0), none), + unaryTapes source quotient remainder base 0 ((k + n) / d) ((k + n) % d) + sourceSuffix quotientSuffix remainderSuffix⟩ := by + induction n generalizing k register with + | zero => + change (TM2.step program ⟨some scanLabel, ((ambient, residue d positive k), register), + unaryTapes source quotient remainder base 0 (k / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩).bind (TM2.step program) = _ + rw [scanStep_zero d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder scanLabel emitterLabel program atScan, Option.bind_some] + simpa only [residue, Nat.add_zero] using + emitterStep d positive source quotient remainder emitterLabel exit program atEmitter + base 0 (k / d) sourceSuffix quotientSuffix remainderSuffix ambient + (residue d positive k) (some false) + | succ n ih => + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[n + 2] + (TM2.step program ⟨some scanLabel, ((ambient, residue d positive k), register), + unaryTapes source quotient remainder base (n + 1) (k / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩) = _ + rw [scanStep_succ d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder scanLabel emitterLabel program atScan] + simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using ih (k + 1) (some true) + +theorem divModTrace (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (exit : Option Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (atEmitter : ∀ r, program (emitterLabel r) = emitter d positive remainder exit r) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 2] + (some ⟨some scanLabel, ((ambient, residue d positive 0), register), + unaryTapes source quotient remainder base n 0 0 + sourceSuffix quotientSuffix remainderSuffix⟩) = + some ⟨exit, ((ambient, residue d positive 0), none), + unaryTapes source quotient remainder base 0 (n / d) (n % d) + sourceSuffix quotientSuffix remainderSuffix⟩ := by + simpa only [Nat.zero_add, Nat.zero_div] using + trace_fromCount d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder scanLabel emitterLabel exit program atScan atEmitter base n 0 + sourceSuffix quotientSuffix remainderSuffix ambient register + +theorem divModFromTapes (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (exit : Option Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (atEmitter : ∀ r, program (emitterLabel r) = emitter d positive remainder exit r) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base source = encodeWord n ++ sourceSuffix) + (quotientInput : base quotient = encodeWord 0 ++ quotientSuffix) + (remainderInput : base remainder = encodeWord 0 ++ remainderSuffix) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 2] + (some ⟨some scanLabel, ((ambient, residue d positive 0), register), base⟩) = + some ⟨exit, ((ambient, residue d positive 0), none), + unaryTapes source quotient remainder base 0 (n / d) (n % d) + sourceSuffix quotientSuffix remainderSuffix⟩ := by + have hbase : unaryTapes source quotient remainder base n 0 0 sourceSuffix quotientSuffix + remainderSuffix = base := by + simp only [unaryTapes, ← sourceInput, ← quotientInput, ← remainderInput, + MachineCopy.forkTapes_self] + have h := divModTrace d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder scanLabel emitterLabel exit program atScan atEmitter base n + sourceSuffix quotientSuffix remainderSuffix ambient register + rw [hbase] at h + exact h + +def divModInTime (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (exit : Option Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (atEmitter : ∀ r, program (emitterLabel r) = emitter d positive remainder exit r) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base source = encodeWord n ++ sourceSuffix) + (quotientInput : base quotient = encodeWord 0 ++ quotientSuffix) + (remainderInput : base remainder = encodeWord 0 ++ remainderSuffix) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some scanLabel, ((ambient, residue d positive 0), register), base⟩ + (some ⟨exit, ((ambient, residue d positive 0), none), + unaryTapes source quotient remainder base 0 (n / d) (n % d) + sourceSuffix quotientSuffix remainderSuffix⟩) (n + 2) where + steps := n + 2 + evals_in_steps := divModFromTapes d positive source quotient remainder sourceQuotient + sourceRemainder quotientRemainder scanLabel emitterLabel exit program atScan atEmitter + base n sourceSuffix quotientSuffix remainderSuffix sourceInput quotientInput remainderInput + ambient register + steps_le_m := Nat.le_refl _ + +theorem scanTrace_fromCount (d : Nat) (positive : 0 < d) (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (base : K → List Bool) (n k : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 1] + (some ⟨some scanLabel, ((ambient, residue d positive k), register), + unaryTapes source quotient remainder base n (k / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩) = + some ⟨some (emitterLabel (residue d positive (k + n))), + ((ambient, residue d positive (k + n)), some false), + unaryTapes source quotient remainder base 0 ((k + n) / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩ := by + induction n generalizing k register with + | zero => + simpa only [Nat.zero_add, Nat.add_zero, Function.iterate_one, + MachineComposition.advance_some] using + scanStep_zero d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder scanLabel emitterLabel program atScan base (k / d) + sourceSuffix quotientSuffix remainderSuffix ambient (residue d positive k) register + | succ n ih => + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[n + 1] + (TM2.step program ⟨some scanLabel, ((ambient, residue d positive k), register), + unaryTapes source quotient remainder base (n + 1) (k / d) 0 + sourceSuffix quotientSuffix remainderSuffix⟩) = _ + rw [scanStep_succ d positive source quotient remainder sourceQuotient sourceRemainder + quotientRemainder scanLabel emitterLabel program atScan] + simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using ih (k + 1) (some true) + +def emitterWithFinish [Fintype σ] (d : Nat) (positive : 0 < d) (remainder : K) + (exit : Option Λ) (finish : σ → Fin d → σ) (r : Fin d) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ d) := + pushWord remainder (List.replicate r.val true) + (.load (fun state => ((finish state.1.1 r, residue d positive 0), none)) + (Reduction.MachineTransfer.exitAt remainder exit)) + +omit [DecidableEq K] in +theorem emitterWithFinishPushBound [Fintype σ] (d : Nat) (positive : 0 < d) + (remainder : K) (exit : Option Λ) (finish : σ → Fin d → σ) (r : Fin d) : + Runtime.statementPushBound (emitterWithFinish d positive remainder exit finish r) = + r.val := by + cases exit <;> + simp [emitterWithFinish, statementPushBound_pushWord, Runtime.statementPushBound, + Reduction.MachineTransfer.exitAt] + +theorem emitterWithFinishStep [Fintype σ] (d : Nat) (positive : 0 < d) + (source quotient remainder : K) (emitterLabel : Fin d → Λ) (exit : Option Λ) + (finish : σ → Fin d → σ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atEmitter : ∀ r, program (emitterLabel r) = + emitterWithFinish d positive remainder exit finish r) + (base : K → List Bool) (n q : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (r : Fin d) (register : Option Bool) : + TM2.step program ⟨some (emitterLabel r), ((ambient, r), register), + unaryTapes source quotient remainder base n q 0 + sourceSuffix quotientSuffix remainderSuffix⟩ = + some ⟨exit, ((finish ambient r, residue d positive 0), none), + unaryTapes source quotient remainder base n q r.val + sourceSuffix quotientSuffix remainderSuffix⟩ := by + change some (TM2.stepAux (program (emitterLabel r)) ((ambient, r), register) + (unaryTapes source quotient remainder base n q 0 + sourceSuffix quotientSuffix remainderSuffix)) = _ + rw [atEmitter] + unfold emitterWithFinish + rw [stepAux_pushWord] + simp only [unaryTapes, MachineCopy.forkTapes_right, List.reverse_replicate] + rw [update_remainder] + cases exit <;> + simp [TM2.stepAux, Reduction.MachineTransfer.exitAt, encodeWord, List.append_assoc] + +theorem divModTraceWithFinish [Fintype σ] (d : Nat) (positive : 0 < d) + (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (exit : Option Λ) (finish : σ → Fin d → σ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (atEmitter : ∀ r, program (emitterLabel r) = + emitterWithFinish d positive remainder exit finish r) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 2] + (some ⟨some scanLabel, ((ambient, residue d positive 0), register), + unaryTapes source quotient remainder base n 0 0 + sourceSuffix quotientSuffix remainderSuffix⟩) = + some ⟨exit, ((finish ambient (residue d positive n), residue d positive 0), none), + unaryTapes source quotient remainder base 0 (n / d) (n % d) + sourceSuffix quotientSuffix remainderSuffix⟩ := by + have hscan := scanTrace_fromCount d positive source quotient remainder + sourceQuotient sourceRemainder quotientRemainder scanLabel emitterLabel program atScan + base n 0 sourceSuffix quotientSuffix remainderSuffix ambient register + simp only [Nat.zero_add, Nat.zero_div] at hscan + rw [Function.iterate_succ_apply', hscan, MachineComposition.advance_some] + exact emitterWithFinishStep d positive source quotient remainder emitterLabel exit finish + program atEmitter base 0 (n / d) sourceSuffix quotientSuffix remainderSuffix ambient + (residue d positive n) (some false) + +theorem divModFromTapesWithFinish [Fintype σ] (d : Nat) (positive : 0 < d) + (source quotient remainder : K) + (sourceQuotient : source ≠ quotient) (sourceRemainder : source ≠ remainder) + (quotientRemainder : quotient ≠ remainder) (scanLabel : Λ) (emitterLabel : Fin d → Λ) + (exit : Option Λ) (finish : σ → Fin d → σ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ d)) + (atScan : program scanLabel = scanLoop d positive source quotient scanLabel emitterLabel) + (atEmitter : ∀ r, program (emitterLabel r) = + emitterWithFinish d positive remainder exit finish r) + (base : K → List Bool) (n : Nat) + (sourceSuffix quotientSuffix remainderSuffix : List Bool) + (sourceInput : base source = encodeWord n ++ sourceSuffix) + (quotientInput : base quotient = encodeWord 0 ++ quotientSuffix) + (remainderInput : base remainder = encodeWord 0 ++ remainderSuffix) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 2] + (some ⟨some scanLabel, ((ambient, residue d positive 0), register), base⟩) = + some ⟨exit, ((finish ambient (residue d positive n), residue d positive 0), none), + unaryTapes source quotient remainder base 0 (n / d) (n % d) + sourceSuffix quotientSuffix remainderSuffix⟩ := by + have hbase : unaryTapes source quotient remainder base n 0 0 sourceSuffix quotientSuffix + remainderSuffix = base := by + simp only [unaryTapes, ← sourceInput, ← quotientInput, ← remainderInput, + MachineCopy.forkTapes_self] + have h := divModTraceWithFinish d positive source quotient remainder sourceQuotient + sourceRemainder quotientRemainder scanLabel emitterLabel exit finish program atScan + atEmitter base n sourceSuffix quotientSuffix remainderSuffix ambient register + rw [hbase] at h + exact h + +end IndependentSetsGames.Foundations.Complexity.MachineFixedDivMod + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineInitialHeaders.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineInitialHeaders.lean new file mode 100644 index 0000000000000000000000000000000000000000..5232979fd23d2d56bf4471d0a26416eef5d7ac31 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineInitialHeaders.lean @@ -0,0 +1,330 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineTransfer +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.PushWord + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineInitialHeaders + +open Turing +open Reduction.MachineTransfer +open Reduction.MachineSubstitution +open MachineCopy + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def prefixScan (source scratch output : K) (scale : ℕ) (again restore : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.push scratch (fun _ => true) + (pushWord output (List.replicate scale true) (.goto fun _ => again))) + (.branch (fun state => state.2.isSome) + (.push source (fun _ => false) + (.load (fun state => (state.1, none)) (.goto fun _ => restore))) + (.load (fun state => (state.1, none)) (.goto fun _ => restore)))) + +private theorem update_source (source scratch output : K) + (hst : source ≠ scratch) (hso : source ≠ output) (hto : scratch ≠ output) + (base : K → List Bool) (input saved emitted replacement : List Bool) : + Function.update (forkTapes source scratch output base input saved emitted) + source replacement = forkTapes source scratch output base replacement saved emitted := by + funext k + by_cases hs : k = source + · subst k; simp [forkTapes, hst, hso] + · by_cases ht : k = scratch + · subst k; simp [forkTapes, Ne.symm hst, hto] + · by_cases ho : k = output + · subst k; simp [forkTapes, Ne.symm hso] + · simp [forkTapes, hs, ht, ho] + +private theorem update_scratch (source scratch output : K) (hto : scratch ≠ output) + (base : K → List Bool) (input saved emitted replacement : List Bool) : + Function.update (forkTapes source scratch output base input saved emitted) + scratch replacement = forkTapes source scratch output base input replacement emitted := by + funext k + by_cases ht : k = scratch + · subst k; simp [forkTapes, hto] + · by_cases ho : k = output + · subst k; simp [forkTapes, Ne.symm hto] + · simp [forkTapes, ht, ho] + +private theorem update_output (source scratch output : K) + (base : K → List Bool) (input saved emitted replacement : List Bool) : + Function.update (forkTapes source scratch output base input saved emitted) + output replacement = forkTapes source scratch output base input saved replacement := by + simp [forkTapes] + +theorem prefixStep_true (source scratch output : K) + (hst : source ≠ scratch) (hso : source ≠ output) (hto : scratch ≠ output) + (scale : ℕ) (again restore : Λ) (base : K → List Bool) + (input saved emitted : List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (prefixScan source scratch output scale again restore) + (ambient, register) (forkTapes source scratch output base (true :: input) saved emitted) = + ⟨some again, (ambient, some true), forkTapes source scratch output base input + (true :: saved) (List.replicate scale true ++ emitted)⟩ := by + simp [prefixScan, TM2.stepAux, hst, hso, hto, update_source, update_scratch, + stepAux_pushWord, update_output] + +theorem prefixStep_false (source scratch output : K) + (hst : source ≠ scratch) (hso : source ≠ output) (hto : scratch ≠ output) + (scale : ℕ) (again restore : Λ) (base : K → List Bool) + (suffix saved emitted : List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (prefixScan source scratch output scale again restore) + (ambient, register) (forkTapes source scratch output base (false :: suffix) saved emitted) = + ⟨some restore, (ambient, none), + forkTapes source scratch output base (false :: suffix) saved emitted⟩ := by + simp [prefixScan, TM2.stepAux, hst, hso, hto, update_source] + +private theorem replicate_append_cons (n : ℕ) (xs : List Bool) : + List.replicate n true ++ true :: xs = List.replicate (n + 1) true ++ xs := by + rw [List.replicate_add] + simp + +theorem prefixScanTrace (source scratch output : K) + (hst : source ≠ scratch) (hso : source ≠ output) (hto : scratch ≠ output) + (scale : ℕ) (again restore : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program again = prefixScan source scratch output scale again restore) + (base : K → List Bool) (n : ℕ) (suffix saved emitted : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 1] + (some ⟨some again, (ambient, register), + forkTapes source scratch output base (encodeWord n ++ suffix) saved emitted⟩) = + some ⟨some restore, (ambient, none), + forkTapes source scratch output base (false :: suffix) + (List.replicate n true ++ saved) (List.replicate (scale * n) true ++ emitted)⟩ := by + induction n generalizing saved emitted register with + | zero => + simp only [Nat.zero_add, Function.iterate_one, MachineComposition.advance_some, + encodeWord, List.replicate_zero, List.nil_append, List.singleton_append, + Nat.mul_zero] + change some (TM2.stepAux (program again) _ _) = _ + rw [atScan, prefixStep_false source scratch output hst hso hto] + | succ n ih => + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[n + 1] + (some (TM2.stepAux (program again) _ _)) = _ + rw [atScan] + simp only [encodeWord, List.replicate_succ, List.cons_append] + rw [prefixStep_true source scratch output hst hso hto] + change (MachineComposition.advance (TM2.step program))^[n + 1] + (some ⟨some again, (ambient, some true), + forkTapes source scratch output base (encodeWord n ++ suffix) + (true :: saved) (List.replicate scale true ++ emitted)⟩) = _ + rw [ih] + have hs : List.replicate n true ++ true :: saved = + true :: (List.replicate n true ++ saved) := by + rw [replicate_append_cons, List.replicate_succ, List.cons_append] + simp only [hs, Nat.mul_succ, List.replicate_add, List.append_assoc] + +theorem prefixTrace (source scratch output : K) + (hst : source ≠ scratch) (hso : source ≠ output) (hto : scratch ≠ output) + (scale : ℕ) (again restore : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program again = prefixScan source scratch output scale again restore) + (atRestore : program restore = loopAt scratch source id false restore exit) + (base : K → List Bool) (n : ℕ) (suffix : List Bool) + (hsource : base source = encodeWord n ++ suffix) (scratchEmpty : base scratch = []) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[2 * n + 2] + (some ⟨some again, (ambient, register), base⟩) = + some ⟨exit, (ambient, none), Function.update base output + (List.replicate (scale * n) true ++ base output)⟩ := by + have scan := prefixScanTrace source scratch output hst hso hto scale again restore + program atScan base n suffix [] (base output) ambient register + have hstart : forkTapes source scratch output base (encodeWord n ++ suffix) [] + (base output) = base := by + rw [← hsource, ← scratchEmpty] + exact forkTapes_self source scratch output base + rw [hstart] at scan + simp only [List.append_nil] at scan + let emitted := List.replicate (scale * n) true ++ base output + let scanned := forkTapes source scratch output base (false :: suffix) + (List.replicate n true) emitted + have restoreTrace := transferAt_fromTapes scratch source (Ne.symm hst) id false + restore exit program atRestore scanned ambient none + change (MachineComposition.advance (TM2.step program))^[(scanned scratch).length + 1] + (some ⟨some restore, (ambient, none), scanned⟩) = _ at restoreTrace + have hs : scanned scratch = List.replicate n true := by simp [scanned, hto] + have hi : scanned source = false :: suffix := by simp [scanned, hst, hso] + rw [hs, hi] at restoreTrace + simp only [List.length_replicate, List.reverse_replicate, List.map_id] at restoreTrace + have hrestored : tapesAt scratch source scanned [] + (List.replicate n true ++ false :: suffix) = Function.update base output emitted := by + funext k + by_cases hks : k = source + · subst k + simp [tapesAt, hso, hsource, encodeWord] + · by_cases hkt : k = scratch + · subst k + simp [tapesAt, Ne.symm hst, hto, scratchEmpty] + · by_cases hko : k = output + · subst k + simp [tapesAt, scanned, forkTapes, Ne.symm hso, Ne.symm hto] + · simp [tapesAt, scanned, forkTapes, hks, hkt, hko] + rw [hrestored] at restoreTrace + rw [show 2 * n + 2 = (n + 1) + (n + 1) by omega, + Function.iterate_add_apply, scan] + exact restoreTrace + +def prefixInTime (source scratch output : K) + (hst : source ≠ scratch) (hso : source ≠ output) (hto : scratch ≠ output) + (scale : ℕ) (again restore : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program again = prefixScan source scratch output scale again restore) + (atRestore : program restore = loopAt scratch source id false restore exit) + (base : K → List Bool) (n : ℕ) (suffix : List Bool) + (hsource : base source = encodeWord n ++ suffix) (scratchEmpty : base scratch = []) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some again, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), Function.update base output + (List.replicate (scale * n) true ++ base output)⟩) (2 * n + 2) where + steps := 2 * n + 2 + evals_in_steps := prefixTrace source scratch output hst hso hto scale again restore exit + program atScan atRestore base n suffix hsource scratchEmpty ambient register + steps_le_m := Nat.le_refl _ + +omit [DecidableEq K] in +theorem prefixScan_pushBound (source scratch output : K) (scale : ℕ) (again restore : Λ) : + Runtime.statementPushBound (prefixScan (σ := σ) source scratch output scale again restore) = + scale + 1 := by + simp only [prefixScan, Runtime.statementPushBound, statementPushBound_pushWord, + List.length_replicate] + omega + +theorem literalTrace (output : K) (word : List Bool) (label : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabel : program label = pushWord output word (exitAt output exit)) + (base : K → List Bool) (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some label, (ambient, register), base⟩) = + some ⟨exit, (ambient, register), + Function.update base output (word.reverse ++ base output)⟩ := by + simp only [Function.iterate_one, MachineComposition.advance_some] + change some (TM2.stepAux (program label) _ _) = _ + rw [atLabel, stepAux_pushWord] + cases exit <;> rfl + +theorem trace_trans {α : Type*} (f : α → α) {a b : ℕ} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem headerTrace (nTape mTape scratch output : K) + (_hnm : nTape ≠ mTape) (hnt : nTape ≠ scratch) (hno : nTape ≠ output) + (hmt : mTape ≠ scratch) (hmo : mTape ≠ output) (hto : scratch ≠ output) + (scanN restoreN scanM1 restoreM1 closeFirst scanM6 restoreM6 closeSecond : Λ) + (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScanN : program scanN = prefixScan nTape scratch output 1 scanN restoreN) + (atRestoreN : program restoreN = loopAt scratch nTape id false restoreN (some scanM1)) + (atScanM1 : program scanM1 = prefixScan mTape scratch output 1 scanM1 restoreM1) + (atRestoreM1 : program restoreM1 = loopAt scratch mTape id false restoreM1 (some closeFirst)) + (atCloseFirst : program closeFirst = pushWord output [true, false] + (exitAt output (some scanM6))) + (atScanM6 : program scanM6 = prefixScan mTape scratch output 6 scanM6 restoreM6) + (atRestoreM6 : program restoreM6 = loopAt scratch mTape id false restoreM6 (some closeSecond)) + (atCloseSecond : program closeSecond = pushWord output [true, false] (exitAt output exit)) + (base : K → List Bool) (n m : ℕ) (nSuffix mSuffix : List Bool) + (hn : base nTape = encodeWord n ++ nSuffix) + (hm : base mTape = encodeWord m ++ mSuffix) (ht : base scratch = []) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[2 * n + 4 * m + 8] + (some ⟨some scanN, (ambient, register), base⟩) = + some ⟨exit, (ambient, none), Function.update base output + ((encodeWords [n + m + 1, 6 * m + 1]).reverse ++ base output)⟩ := by + let out1 := List.replicate n true ++ base output + let out2 := List.replicate m true ++ out1 + let out3 := [false, true] ++ out2 + let out4 := List.replicate (6 * m) true ++ out3 + let out5 := [false, true] ++ out4 + let b1 := Function.update base output out1 + let b2 := Function.update base output out2 + let b3 := Function.update base output out3 + let b4 := Function.update base output out4 + let b5 := Function.update base output out5 + have first := prefixTrace nTape scratch output hnt hno hto 1 scanN restoreN + (some scanM1) program atScanN atRestoreN base n nSuffix hn ht ambient register + simp only [Nat.one_mul] at first + change (MachineComposition.advance (TM2.step program))^[2 * n + 2] + (some ⟨some scanN, (ambient, register), base⟩) = + some ⟨some scanM1, (ambient, none), b1⟩ at first + have second := prefixTrace mTape scratch output hmt hmo hto 1 scanM1 restoreM1 + (some closeFirst) program atScanM1 atRestoreM1 b1 m mSuffix + (by simp [b1, hmo, hm]) (by simp [b1, hto, ht]) ambient none + simp only [Nat.one_mul, b1, Function.update_self, Function.update_idem] at second + change (MachineComposition.advance (TM2.step program))^[2 * m + 2] + (some ⟨some scanM1, (ambient, none), b1⟩) = + some ⟨some closeFirst, (ambient, none), b2⟩ at second + have third := literalTrace output [true, false] closeFirst (some scanM6) + program atCloseFirst b2 ambient none + simp only [b2, Function.update_self, Function.update_idem] at third + change (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some closeFirst, (ambient, none), b2⟩) = + some ⟨some scanM6, (ambient, none), b3⟩ at third + have fourth := prefixTrace mTape scratch output hmt hmo hto 6 scanM6 restoreM6 + (some closeSecond) program atScanM6 atRestoreM6 b3 m mSuffix + (by simp [b3, hmo, hm]) (by simp [b3, hto, ht]) ambient none + simp only [b3, Function.update_self, Function.update_idem] at fourth + change (MachineComposition.advance (TM2.step program))^[2 * m + 2] + (some ⟨some scanM6, (ambient, none), b3⟩) = + some ⟨some closeSecond, (ambient, none), b4⟩ at fourth + have fifth := literalTrace output [true, false] closeSecond exit + program atCloseSecond b4 ambient none + simp only [b4, Function.update_self, Function.update_idem] at fifth + change (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some closeSecond, (ambient, none), b4⟩) = + some ⟨exit, (ambient, none), b5⟩ at fifth + have total := trace_trans _ (trace_trans _ (trace_trans _ (trace_trans _ first second) + third) fourth) fifth + have hsteps : (((2 * n + 2) + (2 * m + 2)) + 1 + (2 * m + 2)) + 1 = + 2 * n + 4 * m + 8 := by omega + rw [hsteps] at total + have hout : out5 = (encodeWords [n + m + 1, 6 * m + 1]).reverse ++ base output := by + simp only [out5, out4, out3, out2, out1, encodeWords, encodeWord, + List.reverse_append, List.reverse_replicate, List.reverse_cons, List.reverse_nil, + List.append_nil, List.nil_append, List.append_assoc, List.singleton_append] + rw [show n + m + 1 = 1 + m + n by omega, + show 6 * m + 1 = 1 + 6 * m by omega] + simp only [List.replicate_add, List.replicate_one, List.cons_append, + List.nil_append, List.append_assoc] + simpa only [b5, hout] using total + +def headerInTime (nTape mTape scratch output : K) + (hnm : nTape ≠ mTape) (hnt : nTape ≠ scratch) (hno : nTape ≠ output) + (hmt : mTape ≠ scratch) (hmo : mTape ≠ output) (hto : scratch ≠ output) + (scanN restoreN scanM1 restoreM1 closeFirst scanM6 restoreM6 closeSecond : Λ) + (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScanN : program scanN = prefixScan nTape scratch output 1 scanN restoreN) + (atRestoreN : program restoreN = loopAt scratch nTape id false restoreN (some scanM1)) + (atScanM1 : program scanM1 = prefixScan mTape scratch output 1 scanM1 restoreM1) + (atRestoreM1 : program restoreM1 = loopAt scratch mTape id false restoreM1 (some closeFirst)) + (atCloseFirst : program closeFirst = pushWord output [true, false] + (exitAt output (some scanM6))) + (atScanM6 : program scanM6 = prefixScan mTape scratch output 6 scanM6 restoreM6) + (atRestoreM6 : program restoreM6 = loopAt scratch mTape id false restoreM6 (some closeSecond)) + (atCloseSecond : program closeSecond = pushWord output [true, false] (exitAt output exit)) + (base : K → List Bool) (n m : ℕ) (nSuffix mSuffix : List Bool) + (hn : base nTape = encodeWord n ++ nSuffix) + (hm : base mTape = encodeWord m ++ mSuffix) (ht : base scratch = []) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some scanN, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), Function.update base output + ((encodeWords [n + m + 1, 6 * m + 1]).reverse ++ base output)⟩) + (2 * n + 4 * m + 8) where + steps := 2 * n + 4 * m + 8 + evals_in_steps := headerTrace nTape mTape scratch output hnm hnt hno hmt hmo hto + scanN restoreN scanM1 restoreM1 closeFirst scanM6 restoreM6 closeSecond exit + program atScanN atRestoreN atScanM1 atRestoreM1 atCloseFirst atScanM6 atRestoreM6 + atCloseSecond base n m nSuffix mSuffix hn hm ht ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineInitialHeaders + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLazyTableRuntime.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLazyTableRuntime.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef84aff0c6c0296ffc0f760a2f70ed43a70374ca --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLazyTableRuntime.lean @@ -0,0 +1,123 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Remaining2 + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLazyTableRuntime + +open Turing PCP +open MachineLazyTable (Tape Label State) + +def rawProgram (d : Nat) (positive : 0 < d) : + MachineCanonicalOutput.Program Tape (Label d) (State d) where + input := .input + output := .output + main := .split .copyFirst + initial := MachineLazyTable.clean d positive + code := MachineLazyTable.program d positive + +theorem sourceMachine_eq (d : Nat) (positive : 0 < d) : + MachineCanonicalOutput.sourceMachine (rawProgram d positive) = + MachineLazyTable.machine d positive := rfl + +def cleanupTapes : List Tape := + [.input, .source, .vertices, .darts, .fuel, .vertex, .reverse, + .tail, .old, .relation, .scratch, .divided, .quotient, .newReverse, .rowBuffer] + +theorem cleanup_complete (d : Nat) (positive : 0 < d) (k : Tape) : + k ∈ cleanupTapes ↔ k ≠ (rawProgram d positive).output := by + cases k <;> simp [cleanupTapes, rawProgram] + +def terminalRun (d : Nat) (positive : 0 < d) (a : PortTables.Input d) : + MachineCanonicalOutput.TerminalRun (rawProgram d positive) (PortTables.inputBits a) + (PortTables.inputBits (PreprocessingStageMaps.lazy d a)) + ((MachineLazyTable.timePolynomial d).eval (PortTables.inputBits a).length) where + state := MachineLazyTable.clean d positive + tapes := MachineLazyTable.finalTapes (PortTables.inputBits a) + (PortTables.inputBits (PreprocessingStageMaps.lazy d a)) + execution := MachineLazyTable.machineInTime a.2 positive + output_eq := rfl + +noncomputable def computableInPolyTime (d : Nat) (positive : 0 < d) : + TM2ComputableInPolyTime (PortTables.inputBits (ports := d)) + (PortTables.inputBits (ports := 2 * d)) (PreprocessingStageMaps.lazy d) := + MachineCanonicalOutput.computableInPolyTime (rawProgram d positive) cleanupTapes + (cleanup_complete d positive) PortTables.inputBits PortTables.inputBits + (PreprocessingStageMaps.lazy d) (MachineLazyTable.timePolynomial d) (terminalRun d positive) + +theorem finite_alphabet (d : Nat) (positive : 0 < d) : + ∀ k, Finite ((computableInPolyTime d positive).tm.Γ k) := + MachineCanonicalOutput.computableInPolyTime_finite_alphabet (rawProgram d positive) cleanupTapes + (cleanup_complete d positive) PortTables.inputBits PortTables.inputBits + (PreprocessingStageMaps.lazy d) (MachineLazyTable.timePolynomial d) (terminalRun d positive) + +end IndependentSetsGames.Foundations.Complexity.MachineLazyTableRuntime +namespace IndependentSetsGames.Foundations.PCP.PreprocessingFinishRuntime + +open Turing IndependentSetsGames.Foundations.Complexity +open PreprocessingRegularTables + +def finish (H : PreprocessingTables.BaseTable) (d : Nat) (input : PortTables.Input d) : + PortTables.Input (2 * (d + internalDegree)) := + PreprocessingStageMaps.lazy (d + internalDegree) + (PreprocessingStageMaps.paddedOverlay H d input) + +theorem output_eq_finish (H : PreprocessingTables.BaseTable) (t : GraphTables.Table) : + PreprocessingTables.output H t = + finish H (internalDegree + 1) (PreprocessingStageMaps.regular H t) := rfl + +theorem finish_degree_positive (d : Nat) (hd : 0 < d) : 0 < d + internalDegree := + hd.trans_le (Nat.le_add_right d internalDegree) + +noncomputable def computableInPolyTime (H : PreprocessingTables.BaseTable) + (d : Nat) (hd : 0 < d) : + TM2ComputableInPolyTime (PortTables.inputBits (ports := d)) + (PortTables.inputBits (ports := 2 * (d + internalDegree))) (finish H d) := by + change TM2ComputableInPolyTime _ _ + (fun input => PreprocessingStageMaps.lazy (d + internalDegree) + (PreprocessingStageMaps.paddedOverlay H d input)) + exact MachineSequential.composeBits (MachinePaddedOverlayRuntime.computableInPolyTime H d hd) + (MachineLazyTableRuntime.computableInPolyTime (d + internalDegree) + (finish_degree_positive d hd)) + +theorem finite_alphabet (H : PreprocessingTables.BaseTable) (d : Nat) (hd : 0 < d) : + MachineFiniteAlphabet.FiniteAlphabet (computableInPolyTime H d hd).tm := + MachineFiniteAlphabet.composeBits + (MachinePaddedOverlayRuntime.computableInPolyTime H d hd) + (MachineLazyTableRuntime.computableInPolyTime (d + internalDegree) + (finish_degree_positive d hd)) + (MachinePaddedOverlayRuntime.finite_alphabet H d hd) + (MachineLazyTableRuntime.finite_alphabet (d + internalDegree) + (finish_degree_positive d hd)) + +end IndependentSetsGames.Foundations.PCP.PreprocessingFinishRuntime +namespace IndependentSetsGames.Foundations.PCP.PreprocessingRuntime +open Turing IndependentSetsGames.Foundations.Complexity +open PreprocessingRegularTables + +noncomputable def tablePolynomialTime (H : PreprocessingTables.BaseTable) : + TM2ComputableInPolyTime GraphTables.tableBits + (PortTables.inputBits (ports := PreprocessingTables.degree)) + (PreprocessingTables.output H) := by + change TM2ComputableInPolyTime GraphTables.tableBits + (PortTables.inputBits (ports := 2 * ((internalDegree + 1) + internalDegree))) + (fun t => PreprocessingFinishRuntime.finish H (internalDegree + 1) + (PreprocessingStageMaps.regular H t)) + exact MachineSequential.composeBits + (MachineRegularTableRuntime.computableInPolyTime H) + (PreprocessingFinishRuntime.computableInPolyTime H (internalDegree + 1) + (Nat.succ_pos internalDegree)) + +theorem finiteAlphabet (H : PreprocessingTables.BaseTable) : + MachineFiniteAlphabet.FiniteAlphabet (tablePolynomialTime H).tm := + MachineFiniteAlphabet.composeBits + (MachineRegularTableRuntime.computableInPolyTime H) + (PreprocessingFinishRuntime.computableInPolyTime H (internalDegree + 1) + (Nat.succ_pos internalDegree)) + (MachineRegularTableRuntime.finite_alphabet H) + (PreprocessingFinishRuntime.finite_alphabet H (internalDegree + 1) + (Nat.succ_pos internalDegree)) + +end IndependentSetsGames.Foundations.PCP.PreprocessingRuntime + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLogCounter.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLogCounter.lean new file mode 100644 index 0000000000000000000000000000000000000000..7eeed4fba8cfa1b26ea6dd27667e1cf0a0a55458 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLogCounter.lean @@ -0,0 +1,376 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.PatternInvariant +import OAI.Combinatorics.IndependentSets.Encoding.Target +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLogCounter + +open Turing + +def bitLength (n : Nat) : Nat := if n = 0 then 0 else n.log2 + 1 + +@[simp] theorem bitLength_zero : bitLength 0 = 0 := rfl + +theorem bitLength_positive {n : Nat} (h : n ≠ 0) : bitLength n = n.log2 + 1 := by + simp [bitLength, h] + +theorem bitLength_half {n : Nat} (h : n ≠ 0) : bitLength n = bitLength (n / 2) + 1 := by + by_cases hone : n = 1 + · subst n; rfl + have hn : 2 ≤ n := by omega + have hh : n / 2 ≠ 0 := by omega + rw [bitLength_positive h, bitLength_positive hh, Nat.log2_def n, ite_eq_left hn] + +def increments (n : Nat) (started : Bool) : Nat := + if n = 0 then (if started then 0 else 1) else bitLength n + +@[simp] theorem increments_true (n : Nat) : increments n true = bitLength n := by + by_cases hn : n = 0 <;> simp [increments, hn] + +theorem increments_half {n : Nat} (h : n ≠ 0) (started : Bool) : + increments n started = increments (n / 2) true + 1 := by + rw [increments, ite_eq_right h, increments_true, bitLength_half h] + +theorem increments_false (n : Nat) : increments n false = n.log2 + 1 := by + by_cases hn : n = 0 + · subst n; rfl + · simp [increments, bitLength, hn] + +def coreTime (n : Nat) : Nat := + if h : n = 0 then 1 else n + n / 2 + 3 + coreTime (n / 2) +termination_by n +decreasing_by omega + +@[simp] theorem coreTime_zero : coreTime 0 = 1 := by rw [coreTime]; rfl + +theorem coreTime_positive {n : Nat} (h : n ≠ 0) : + coreTime n = n + n / 2 + 3 + coreTime (n / 2) := by + rw [coreTime, dite_eq_right h] + +theorem coreTime_bound (n : Nat) : coreTime n ≤ 6 * n + 1 := by + induction n using Nat.strong_induction_on with + | h n ih => + by_cases hn : n = 0 + · subst n; simp + · rw [coreTime_positive hn] + have smaller : n / 2 < n := by omega + have bound := ih (n / 2) smaller + omega + +abbrev Alphabet (_ : Fin 3) := Bool +abbrev State := (Bool × Bool) × Option Bool + +def initialState : State := ((false, false), none) + +def rawTapes (input scratch output : List Bool) : Fin 3 → List Bool + | 0 => input + | 1 => scratch + | 2 => output + +private theorem update_input (input scratch output replacement : List Bool) : + Function.update (rawTapes input scratch output) 0 replacement = rawTapes replacement scratch output := by + funext k + fin_cases k <;> rfl + +theorem update_scratch (input scratch output replacement : List Bool) : + Function.update (rawTapes input scratch output) 1 replacement = rawTapes input replacement output := by + funext k + fin_cases k <;> rfl + +theorem update_output (input scratch output replacement : List Bool) : + Function.update (rawTapes input scratch output) 2 replacement = rawTapes input scratch replacement := by + funext k + fin_cases k <;> rfl + +def stripLoop : TM2.Stmt Alphabet (Fin 5) State := + .pop 0 (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.push 1 (fun _ => true) (.goto fun _ => (1 : Fin 5))) + (.load (fun _ => initialState) (.goto fun _ => 4))) + +def guardLoop : TM2.Stmt Alphabet (Fin 5) State := + .peek 0 (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.push 2 (fun _ => true) + (.load (fun _ => ((false, true), none)) (.goto fun _ => 3))) + (.branch (fun state => state.1.2) + (.load (fun _ => initialState) .halt) + (.push 2 (fun _ => true) (.load (fun _ => initialState) .halt)))) + +def halfLoop : TM2.Stmt Alphabet (Fin 5) State := + .pop 0 (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.branch (fun state => state.1.1) + (.push 1 (fun _ => true) + (.load (fun state => ((false, state.1.2), state.2)) (.goto fun _ => 3))) + (.load (fun state => ((true, state.1.2), state.2)) (.goto fun _ => 3))) + (.load (fun state => ((false, state.1.2), none)) (.goto fun _ => 4))) + +def program : Fin 5 → TM2.Stmt Alphabet (Fin 5) State + | 0 => .push 2 (fun _ => false) (.goto fun _ => 1) + | 1 => stripLoop + | 2 => guardLoop + | 3 => halfLoop + | 4 => Reduction.MachineTransfer.loopAt 1 0 id false 4 (some 2) + +def machine : FinTM2 where + K := Fin 3 + k₀ := 0 + k₁ := 2 + Γ := Alphabet + Λ := Fin 5 + main := 0 + σ := State + initialState := initialState + m := program + +def configuration (label : Option (Fin 5)) (state : State) + (input scratch output : List Bool) : machine.Cfg := + ⟨label, state, rawTapes input scratch output⟩ + +def next := MachineComposition.advance machine.step + +theorem stripStep_true (input scratch output : List Bool) (state : State) : + machine.step (configuration (some 1) state (true :: input) scratch output) = + some (configuration (some 1) (state.1, some true) input (true :: scratch) output) := by + change some (TM2.stepAux stripLoop state (rawTapes (true :: input) scratch output)) = _ + simp [stripLoop, TM2.stepAux, rawTapes, configuration] + rw [update_input, update_scratch] + rfl + +theorem stripStep_false (scratch output : List Bool) (state : State) : + machine.step (configuration (some 1) state [false] scratch output) = + some (configuration (some 4) initialState [] scratch output) := by + change some (TM2.stepAux stripLoop state (rawTapes [false] scratch output)) = _ + simp [stripLoop, TM2.stepAux, rawTapes, configuration] + rw [update_input] + rfl + +theorem stripTrace (n : Nat) (scratch output : List Bool) (state : State) : + next^[n + 1] (some (configuration (some 1) state (encodeWord n) scratch output)) = + some (configuration (some 4) initialState [] (List.replicate n true ++ scratch) output) := by + induction n generalizing scratch state with + | zero => + simpa only [encodeWord, List.replicate_zero, List.nil_append, Nat.zero_add, + Function.iterate_one, next, MachineComposition.advance_some] using + stripStep_false scratch output state + | succ n ih => + rw [Function.iterate_succ_apply] + change next^[n + 1] + (machine.step (configuration (some 1) state (true :: encodeWord n) scratch output)) = _ + rw [stripStep_true, ih] + congr 2 + simp only [List.replicate_add, List.replicate_one, List.append_assoc, List.singleton_append] + +theorem halfStep_nil (scratch output : List Bool) (parity started : Bool) (register : Option Bool) : + machine.step (configuration (some 3) ((parity, started), register) [] scratch output) = + some (configuration (some 4) ((false, started), none) [] scratch output) := by + change some (TM2.stepAux halfLoop ((parity, started), register) (rawTapes [] scratch output)) = _ + simp [halfLoop, TM2.stepAux, rawTapes, configuration] + rw [update_input] + rfl + +theorem halfStep_false (input scratch output : List Bool) (started : Bool) (register : Option Bool) : + machine.step (configuration (some 3) ((false, started), register) (true :: input) scratch output) = + some (configuration (some 3) ((true, started), some true) input scratch output) := by + change some (TM2.stepAux halfLoop ((false, started), register) + (rawTapes (true :: input) scratch output)) = _ + simp [halfLoop, TM2.stepAux, rawTapes, configuration] + rw [update_input] + rfl + +theorem halfStep_true (input scratch output : List Bool) (started : Bool) (register : Option Bool) : + machine.step (configuration (some 3) ((true, started), register) (true :: input) scratch output) = + some (configuration (some 3) ((false, started), some true) input (true :: scratch) output) := by + change some (TM2.stepAux halfLoop ((true, started), register) + (rawTapes (true :: input) scratch output)) = _ + simp [halfLoop, TM2.stepAux, rawTapes, configuration] + rw [update_input, update_scratch] + rfl + +theorem halfTrace (n m : Nat) (output : List Bool) (parity started : Bool) + (register : Option Bool) : + next^[n + 1] (some (configuration (some 3) ((parity, started), register) + (List.replicate n true) (List.replicate m true) output)) = + some (configuration (some 4) ((false, started), none) [] + (List.replicate (m + (n + if parity then 1 else 0) / 2) true) output) := by + induction n generalizing m parity register with + | zero => + cases parity <;> + simpa only [Nat.zero_add, Function.iterate_one, next, MachineComposition.advance_some, + List.replicate_zero, Bool.false_eq_true, ite_false, ite_true, Nat.zero_div, + Nat.add_zero, Nat.reduceDiv] using + halfStep_nil (List.replicate m true) output _ started register + | succ n ih => + rw [Function.iterate_succ_apply] + change next^[n + 1] + (machine.step (configuration (some 3) ((parity, started), register) + (true :: List.replicate n true) (List.replicate m true) output)) = _ + cases parity with + | false => + rw [halfStep_false, ih] + congr 2 + | true => + rw [halfStep_true] + change next^[n + 1] (some (configuration (some 3) ((false, started), some true) + (List.replicate n true) (List.replicate (m + 1) true) output)) = _ + rw [ih] + congr 2 + congr 1 + change m + 1 + n / 2 = m + (n + 1 + 1) / 2 + omega + +theorem restoreTrace (n : Nat) (output : List Bool) (started : Bool) : + next^[n + 1] (some (configuration (some 4) ((false, started), none) + [] (List.replicate n true) output)) = + some (configuration (some 2) ((false, started), none) (List.replicate n true) [] output) := by + have run := Reduction.MachineTransfer.transferAt_fromTapes (1 : Fin 3) 0 (by decide) + id false (4 : Fin 5) (some 2) program rfl + (rawTapes [] (List.replicate n true) output) (false, started) none + simp only [rawTapes, List.length_replicate, List.reverse_replicate, List.map_id, + List.append_nil] at run + have tapesEq : Reduction.MachineTransfer.tapesAt (1 : Fin 3) 0 + (rawTapes [] (List.replicate n true) output) [] (List.replicate n true) = + rawTapes (List.replicate n true) [] output := by + funext k + fin_cases k <;> rfl + rw [tapesEq] at run + exact run + +theorem guardStep_zero (output : List Bool) (started : Bool) : + machine.step (configuration (some 2) ((false, started), none) [] [] output) = + some (configuration none initialState [] [] (if started then output else true :: output)) := by + change some (TM2.stepAux guardLoop ((false, started), none) (rawTapes [] [] output)) = _ + cases started <;> simp [guardLoop, TM2.stepAux, rawTapes, configuration] + · rw [update_output] + rfl + · rfl + +theorem guardStep_positive (n : Nat) (output : List Bool) (started : Bool) : + machine.step (configuration (some 2) ((false, started), none) + (List.replicate (n + 1) true) [] output) = + some (configuration (some 3) ((false, true), none) + (List.replicate (n + 1) true) [] (true :: output)) := by + change some (TM2.stepAux guardLoop ((false, started), none) + (rawTapes (true :: List.replicate n true) [] output)) = _ + simp [guardLoop, TM2.stepAux, rawTapes, configuration] + rw [update_output] + simp only [List.replicate_succ] + rfl + +theorem coreTrace (n : Nat) (output : List Bool) (started : Bool) : + next^[coreTime n] (some (configuration (some 2) ((false, started), none) + (List.replicate n true) [] output)) = + some (configuration none initialState [] [] + (List.replicate (increments n started) true ++ output)) := by + induction n using Nat.strong_induction_on generalizing output started with + | h n ih => + cases n with + | zero => + cases started with + | false => + simp [increments, next] + exact guardStep_zero output false + | true => + simp [increments, next] + exact guardStep_zero output true + | succ n => + have nonzero : n + 1 ≠ 0 := by omega + have smaller : (n + 1) / 2 < n + 1 := by omega + have recursive := ih ((n + 1) / 2) smaller (true :: output) true + have half := halfTrace (n + 1) 0 (true :: output) false true none + simp only [Bool.false_eq_true, ↓reduceIte, Nat.add_zero, Nat.zero_add, + List.replicate_zero] at half + have restore := restoreTrace ((n + 1) / 2) (true :: output) true + rw [coreTime_positive nonzero] + rw [show n + 1 + (n + 1) / 2 + 3 + coreTime ((n + 1) / 2) = + (coreTime ((n + 1) / 2) + ((n + 1) / 2 + 1) + (n + 1 + 1)) + 1 by omega, + Function.iterate_succ_apply] + change next^[coreTime ((n + 1) / 2) + ((n + 1) / 2 + 1) + (n + 1 + 1)] + (machine.step (configuration (some 2) ((false, started), none) + (List.replicate (n + 1) true) [] output)) = _ + rw [guardStep_positive, Function.iterate_add_apply, half, + Function.iterate_add_apply, restore, recursive] + rw [increments_half nonzero started] + simp only [List.replicate_add, List.replicate_one, List.append_assoc, List.singleton_append] + +theorem initList_eq (input : List Bool) : + initList machine input = configuration (some 0) initialState input [] [] := by + unfold initList configuration + congr 1 + funext k + change Fin 3 at k + fin_cases k <;> rfl + +theorem haltList_eq (output : List Bool) : + haltList machine output = configuration none initialState [] [] output := by + unfold haltList configuration + congr 1 + funext k + change Fin 3 at k + fin_cases k <;> rfl + +theorem initialStep (input : List Bool) : + machine.step (configuration (some 0) initialState input [] []) = + some (configuration (some 1) initialState input [] [false]) := by + change some (TM2.stepAux (.push (2 : Fin 3) (fun _ : State => false) (.goto fun _ => (1 : Fin 5))) + initialState (rawTapes input [] [])) = _ + simp only [TM2.stepAux, rawTapes] + rw [update_output] + rfl + +def totalTime (n : Nat) : Nat := 2 * n + 3 + coreTime n + +theorem totalTime_bound (n : Nat) : totalTime n ≤ 8 * n + 4 := by + have bound := coreTime_bound n + unfold totalTime + omega + +theorem machineTrace (n : Nat) : + next^[totalTime n] (some (initList machine (encodeWord n))) = + some (haltList machine (encodeWord (n.log2 + 1))) := by + rw [initList_eq, haltList_eq] + rw [show totalTime n = (coreTime n + (n + 1) + (n + 1)) + 1 by + unfold totalTime; omega, Function.iterate_succ_apply] + change next^[coreTime n + (n + 1) + (n + 1)] + (machine.step (configuration (some 0) initialState (encodeWord n) [] [])) = _ + rw [initialStep, Function.iterate_add_apply, stripTrace] + simp only [List.append_nil] + rw [Function.iterate_add_apply] + dsimp only [initialState] + rw [restoreTrace n [false] false, coreTrace, increments_false] + rfl + +def outputsInTime (n : Nat) : + TM2OutputsInTime machine (encodeWord n) (some (encodeWord (n.log2 + 1))) (8 * n + 4) where + steps := totalTime n + evals_in_steps := machineTrace n + steps_le_m := totalTime_bound n + +noncomputable def computableInPolyTime : + TM2ComputableInPolyTime encodeWord encodeWord (fun n => n.log2 + 1) where + tm := machine + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := 8 * Polynomial.X + 4 + outputsFun n := by + change TM2OutputsInTime machine ((encodeWord n).map id) + (some ((encodeWord (n.log2 + 1)).map id)) + ((8 * Polynomial.X + 4 : Polynomial Nat).eval (encodeWord n).length) + have hi := @List.map_id (machine.Γ machine.k₀) (encodeWord n) + have ho := @List.map_id (machine.Γ machine.k₁) (encodeWord (n.log2 + 1)) + rw [hi, ho] + have execution := outputsInTime n + refine { + toEvalsTo := execution.toEvalsTo + steps_le_m := Nat.le_trans execution.steps_le_m ?_ + } + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, Polynomial.eval_X] + simp [encodeWord] + +end IndependentSetsGames.Foundations.Complexity.MachineLogCounter + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookup.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookup.lean new file mode 100644 index 0000000000000000000000000000000000000000..cdc9c0214f7af043a58587b50611060447a9dbdb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookup.lean @@ -0,0 +1,318 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupSpec +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupDiscard + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLookup + +open Turing +open MachineComposition + +variable {K σ : Type} [DecidableEq K] + +theorem guard_step_succ (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) + (base : K → List Bool) (i : Nat) (indexSuffix input output : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (program index source destination) + ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord (i + 1) ++ indexSuffix) input output⟩ = + some ⟨some .skip, (ambient, none), tapes index source destination base + (encodeWord i ++ indexSuffix) input output⟩ := by + change some (TM2.stepAux (program index source destination .guard) _ _) = _ + simp [program, MachineUnaryCounter.guard, TM2.stepAux, + tapes_index, his, hid, encodeWord, List.replicate_succ, update_index] + +theorem guard_step_zero (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) + (base : K → List Bool) (indexSuffix input output : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (program index source destination) + ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord 0 ++ indexSuffix) input output⟩ = + some ⟨some .select, (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) input output⟩ := by + change some (TM2.stepAux (program index source destination .guard) _ _) = _ + simp [program, MachineUnaryCounter.guard, TM2.stepAux, + tapes_index, his, hid, encodeWord] + +theorem select_step_nonempty (index source destination : K) + (hsd : source ≠ destination) (base : K → List Bool) + (counter input output : List Bool) (hinput : input ≠ []) + (ambient : σ) (register : Option Bool) : + TM2.step (program index source destination) + ⟨some .select, (ambient, register), + tapes index source destination base counter input output⟩ = + some ⟨some .copy, (ambient, input.head?), + tapes index source destination base counter input (false :: output)⟩ := by + change some (TM2.stepAux (program index source destination .select) _ _) = _ + cases input with + | nil => exact (hinput rfl).elim + | cons head tail => + simp [program, select, Hastad.SourceMachine.fieldStart, TM2.stepAux, + tapes_source, hsd, update_destination] + +theorem select_step_empty (index source destination : K) + (hsd : source ≠ destination) (base : K → List Bool) + (counter output : List Bool) (ambient : σ) (register : Option Bool) : + TM2.step (program index source destination) + ⟨some .select, (ambient, register), + tapes index source destination base counter [] output⟩ = + some ⟨some .rejected, (ambient, none), + tapes index source destination base counter [] output⟩ := by + change some (TM2.stepAux (program index source destination .select) _ _) = _ + simp [program, select, TM2.stepAux, tapes_source, hsd] + +theorem copyTrace (index source destination : K) + (hsd : source ≠ destination) (base : K → List Bool) + (counter : List Bool) (n : Nat) (suffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[n + 1] + (some ⟨some .copy, (ambient, register), tapes index source destination base + counter (encodeWord n ++ suffix) (false :: output)⟩) = + some ⟨some .accepted, (ambient, none), tapes index source destination base + counter suffix (encodeWord n ++ output)⟩ := by + have h := Hastad.SourceMachine.fieldLoopTrace source destination hsd + Label.copy (some Label.accepted) (program index source destination) rfl + (Function.update base index counter) n suffix (false :: output) ambient register + simpa only [Hastad.SourceMachine.fieldTapes, tapes, encodeWord, + List.append_assoc, List.singleton_append] using h + +theorem selectTrace (index source destination : K) + (hsd : source ≠ destination) (base : K → List Bool) + (counter : List Bool) (n : Nat) (suffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[n + 2] + (some ⟨some .select, (ambient, register), tapes index source destination base + counter (encodeWord n ++ suffix) output⟩) = + some ⟨some .accepted, (ambient, none), tapes index source destination base + counter suffix (encodeWord n ++ output)⟩ := by + rw [show n + 2 = (n + 1) + 1 by omega, Function.iterate_succ_apply] + simp only [advance_some] + rw [select_step_nonempty index source destination hsd base counter + (encodeWord n ++ suffix) output (by simp [encodeWord]) ambient register] + exact copyTrace index source destination hsd base counter n suffix output ambient _ + +theorem skipCycleTrace (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (i n : Nat) (indexSuffix suffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[n + 2] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord (i + 1) ++ indexSuffix) (encodeWord n ++ suffix) output⟩) = + some ⟨some .guard, (ambient, none), tapes index source destination base + (encodeWord i ++ indexSuffix) suffix output⟩ := by + rw [show n + 2 = (n + 1) + 1 by omega, Function.iterate_succ_apply] + simp only [advance_some] + rw [guard_step_succ index source destination his hid] + have h := discardTrace source Label.skip Label.guard + (program index source destination) rfl + (tapes index source destination base (encodeWord i ++ indexSuffix) + (encodeWord n ++ suffix) output) n suffix (by simp [hsd]) ambient none + simpa only [update_source index source destination hsd] using h + +theorem emptyCycleTrace (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (i : Nat) (indexSuffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[2] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord (i + 1) ++ indexSuffix) [] output⟩) = + some ⟨some .guard, (ambient, none), tapes index source destination base + (encodeWord i ++ indexSuffix) [] output⟩ := by + rw [show 2 = 1 + 1 from rfl, Function.iterate_succ_apply] + simp only [Function.iterate_one, advance_some] + rw [guard_step_succ index source destination his hid] + exact discard_empty_step source Label.skip Label.guard (program index source destination) + rfl (tapes index source destination base (encodeWord i ++ indexSuffix) [] output) + (by simp [hsd]) ambient none + +theorem successPrefixTrace (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (prior : List Nat) (value : Nat) + (indexSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[ + (encodeWords prior).length + prior.length + value + 3] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord prior.length ++ indexSuffix) + (encodeWords prior ++ (encodeWord value ++ suffix)) output⟩) = + some ⟨some .accepted, (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) suffix (encodeWord value ++ output)⟩ := by + induction prior generalizing register with + | nil => + simp only [encodeWords, List.length_nil, Nat.zero_add, List.nil_append] + rw [show value + 3 = (value + 2) + 1 by omega, Function.iterate_succ_apply] + simp only [advance_some] + rw [guard_step_zero index source destination his hid] + exact selectTrace index source destination hsd base _ value suffix output ambient none + | cons n prior ih => + simp only [encodeWords, List.length_cons, List.length_append, encodeWord_length] + rw [show n + 1 + (encodeWords prior).length + (prior.length + 1) + value + 3 = + ((encodeWords prior).length + prior.length + value + 3) + (n + 2) by omega, + Function.iterate_add_apply] + rw [List.append_assoc, + skipCycleTrace index source destination his hid hsd base prior.length n] + exact ih none + +theorem lookupTrace_some (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (values : List Nat) (i value : Nat) + (selected : values[i]? = some value) + (indexSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord i ++ indexSuffix) (encodeWords values ++ suffix) output⟩) = + some ⟨some .accepted, (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1)) ++ suffix) + (encodeWord value ++ output)⟩ := by + have hi := (List.getElem?_eq_some_iff.mp selected).1 + have hlength : (values.take i).length = i := by + simp [List.length_take, Nat.min_eq_left (Nat.le_of_lt hi)] + have hsource : encodeWords (values.take i) ++ + (encodeWord value ++ (encodeWords (values.drop (i + 1)) ++ suffix)) = + encodeWords values ++ suffix := by + rw [MachineLookupSpec.encoded_selected_split values i value selected] + simp only [List.append_assoc] + have htime : MachineLookupSpec.steps values i = + (encodeWords (values.take i)).length + i + value + 3 := by + rw [MachineLookupSpec.steps_eq_scannedBits_of_some values i value selected, + MachineLookupSpec.scannedBits_of_some values i value selected] + omega + have h := successPrefixTrace index source destination his hid hsd base (values.take i) + value indexSuffix (encodeWords (values.drop (i + 1)) ++ suffix) output ambient register + rw [hlength, hsource] at h + simpa only [htime] using h + +theorem emptyTrace (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (i : Nat) (indexSuffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[2 * i + 2] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord i ++ indexSuffix) [] output⟩) = + some ⟨some .rejected, (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) [] output⟩ := by + induction i generalizing register with + | zero => + simp only [Nat.mul_zero, Nat.zero_add] + rw [show 2 = 1 + 1 from rfl, Function.iterate_succ_apply] + simp only [Function.iterate_one, advance_some] + rw [guard_step_zero index source destination his hid] + exact select_step_empty index source destination hsd base _ output ambient none + | succ i ih => + rw [show 2 * (i + 1) + 2 = (2 * i + 2) + 2 by omega, + Function.iterate_add_apply, emptyCycleTrace index source destination his hid hsd] + exact ih none + +theorem lookupTrace_invalid (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (values : List Nat) (i : Nat) (invalid : values.length ≤ i) + (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord i ++ indexSuffix) (encodeWords values) output⟩) = + some ⟨some .rejected, (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) [] output⟩ := by + induction values generalizing i register with + | nil => + simpa only [MachineLookupSpec.steps, encodeWords] using + emptyTrace index source destination his hid hsd base i indexSuffix output ambient register + | cons n values ih => + cases i with + | zero => simp at invalid + | succ i => + simp only [MachineLookupSpec.steps, encodeWords] + rw [Nat.add_comm (n + 2), Function.iterate_add_apply, + skipCycleTrace index source destination his hid hsd] + exact ih i (by simpa using invalid) none + +def resultLabel (values : List Nat) (i : Nat) : Label := + match values[i]? with + | some _ => .accepted + | none => .rejected + +def resultOutput (values : List Nat) (i : Nat) (output : List Bool) : List Bool := + match values[i]? with + | some value => encodeWord value ++ output + | none => output + +theorem lookupTrace (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (values : List Nat) (i : Nat) + (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord i ++ indexSuffix) (encodeWords values) output⟩) = + some ⟨some (resultLabel values i), (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1))) + (resultOutput values i output)⟩ := by + cases selected : values[i]? with + | some value => + simpa only [List.append_nil, resultLabel, resultOutput, selected] using + lookupTrace_some index source destination his hid hsd base values i value selected + indexSuffix [] output ambient register + | none => + have invalid : values.length ≤ i := List.getElem?_eq_none_iff.mp selected + have hdrop : values.drop (i + 1) = [] := List.drop_eq_nil_of_le (by omega) + simpa only [resultLabel, resultOutput, selected, hdrop, encodeWords] using + lookupTrace_invalid index source destination his hid hsd base values i invalid + indexSuffix output ambient register + +def lookupInTime (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (values : List Nat) (i : Nat) + (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program index source destination)) + ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord i ++ indexSuffix) (encodeWords values) output⟩ + (some ⟨some (resultLabel values i), (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1))) + (resultOutput values i output)⟩) + ((encodeWords values).length + 2 * (encodeWord i).length) where + steps := MachineLookupSpec.steps values i + evals_in_steps := lookupTrace index source destination his hid hsd base values i + indexSuffix output ambient register + steps_le_m := MachineLookupSpec.steps_le_input_encoding_size values i + +theorem lookupHaltTrace (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (values : List Nat) (i : Nat) + (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i + 1] + (some ⟨some .guard, (ambient, register), tapes index source destination base + (encodeWord i ++ indexSuffix) (encodeWords values) output⟩) = + some ⟨none, (ambient, none), tapes index source destination base + (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1))) + (resultOutput values i output)⟩ := by + rw [Function.iterate_succ_apply', lookupTrace index source destination his hid hsd] + simp only [advance_some] + cases selected : values[i]? <;> simp [resultLabel, selected, TM2.step, program, TM2.stepAux] + +noncomputable def timePolynomial : Polynomial Nat := Polynomial.C 2 * Polynomial.X + 1 + +theorem timePolynomial_bounds (values : List Nat) (i : Nat) : + MachineLookupSpec.steps values i + 1 ≤ + timePolynomial.eval ((encodeWords values).length + (encodeWord i).length) := by + have h := MachineLookupSpec.steps_le_input_encoding_size values i + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_X, Polynomial.eval_one] + omega + +def machineInTime (base : Fin 3 → List Bool) (values : List Nat) (i : Nat) + (indexSuffix output : List Bool) (register : Option Bool) : + StateTransition.EvalsToInTime machine.step + ⟨some .guard, ((), register), tapes (K := Fin 3) 0 1 2 base + (encodeWord i ++ indexSuffix) (encodeWords values) output⟩ + (some ⟨none, ((), none), tapes (K := Fin 3) 0 1 2 base + (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1))) + (resultOutput values i output)⟩) + (timePolynomial.eval ((encodeWords values).length + (encodeWord i).length)) where + steps := MachineLookupSpec.steps values i + 1 + evals_in_steps := lookupHaltTrace (0 : Fin 3) 1 2 (by decide) (by decide) (by decide) + base values i indexSuffix output () register + steps_le_m := timePolynomial_bounds values i + +end IndependentSetsGames.Foundations.Complexity.MachineLookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupCore.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8774d6cb5960b38d8bff345160916dcc5eda8db --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupCore.lean @@ -0,0 +1,125 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Machine +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryCounter + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLookup + +open Turing + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def discard (source : K) (loopLabel returnLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.goto fun _ => loopLabel) + (.load (fun state => (state.1, none)) (.goto fun _ => returnLabel))) + +def select (source destination : K) (copyLabel rejected : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .peek source (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (Hastad.SourceMachine.fieldStart destination copyLabel) + (.load (fun state => (state.1, none)) (.goto fun _ => rejected))) + +inductive Label + | guard | skip | select | copy | accepted | rejected + deriving DecidableEq + +instance : Fintype Label where + elems := {.guard, .skip, .select, .copy, .accepted, .rejected} + complete label := by cases label <;> simp + +def program (index source destination : K) : + Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) + | .guard => MachineUnaryCounter.guard index .skip .select + | .skip => discard source .skip .guard + | .select => select source destination .copy .rejected + | .copy => Hastad.SourceMachine.fieldLoop source destination .copy (some .accepted) + | .accepted => .halt + | .rejected => .halt + +def tapes (index source destination : K) (base : K → List Bool) + (counter input output : List Bool) : K → List Bool := + Function.update (Function.update (Function.update base index counter) source input) + destination output + +@[simp] theorem tapes_index (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) + (base : K → List Bool) (counter input output : List Bool) : + tapes index source destination base counter input output index = counter := by + simp [tapes, his, hid] + +@[simp] theorem tapes_source (index source destination : K) + (hsd : source ≠ destination) (base : K → List Bool) + (counter input output : List Bool) : + tapes index source destination base counter input output source = input := by + simp [tapes, hsd] + +@[simp] theorem tapes_destination (index source destination : K) + (base : K → List Bool) (counter input output : List Bool) : + tapes index source destination base counter input output destination = output := by + simp [tapes] + +theorem tapes_other (index source destination p : K) + (hi : p ≠ index) (hs : p ≠ source) (hd : p ≠ destination) + (base : K → List Bool) (counter input output : List Bool) : + tapes index source destination base counter input output p = base p := by + simp [tapes, hi, hs, hd] + +theorem update_index (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) + (base : K → List Bool) (counter input output replacement : List Bool) : + Function.update (tapes index source destination base counter input output) index replacement = + tapes index source destination base replacement input output := by + funext p + by_cases hi : p = index + · subst p; simp [tapes, his, hid] + · by_cases hs : p = source + · subst p; by_cases hs : source = destination <;> simp [tapes, hi, hs, Ne.symm hid] + · by_cases hd : p = destination + · subst p; simp [tapes, hi] + · simp [tapes, hi, hs, hd] + +theorem update_source (index source destination : K) (hsd : source ≠ destination) + (base : K → List Bool) (counter input output replacement : List Bool) : + Function.update (tapes index source destination base counter input output) source replacement = + tapes index source destination base counter replacement output := by + funext p + by_cases hs : p = source + · subst p; simp [tapes, hsd] + · by_cases hd : p = destination + · subst p; simp [tapes, hs] + · simp [tapes, hs, hd] + +theorem update_destination (index source destination : K) + (base : K → List Bool) (counter input output replacement : List Bool) : + Function.update (tapes index source destination base counter input output) + destination replacement = tapes index source destination base counter input replacement := by + simp [tapes] + +theorem fieldTapes_eq (index source destination : K) (hsd : source ≠ destination) + (base : K → List Bool) (counter input output input' output' : List Bool) : + Hastad.SourceMachine.fieldTapes source destination + (tapes index source destination base counter input output) input' output' = + tapes index source destination base counter input' output' := by + rw [Hastad.SourceMachine.fieldTapes, update_source _ _ _ hsd, update_destination] + +def machine : FinTM2 where + K := Fin 3 + k₀ := 1 + k₁ := 2 + Γ _ := Bool + Λ := Label + main := .guard + σ := Unit × Option Bool + initialState := ((), none) + m := program 0 1 2 + +end IndependentSetsGames.Foundations.Complexity.MachineLookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupDiscard.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupDiscard.lean new file mode 100644 index 0000000000000000000000000000000000000000..23b9aec078aec569c26e5eb286debd60be100789 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupDiscard.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupCore + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLookup + +open Turing + +variable {K Λ σ : Type} [DecidableEq K] + +private theorem discard_update_twice (source : K) (base : K → List Bool) + (input replacement : List Bool) : + Function.update (Function.update base source input) source replacement = + Function.update base source replacement := by + funext p + by_cases hp : p = source + · subst p; simp + · simp [hp] + +theorem discardStep_delimiter (source : K) (loopLabel returnLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = discard source loopLabel returnLabel) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) + (register : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, register), Function.update base source (false :: suffix)⟩ = + some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (Function.update base source (false :: suffix))) = _ + rw [atLoop] + simp [discard, TM2.stepAux] + +theorem discardStep_true (source : K) (loopLabel returnLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = discard source loopLabel returnLabel) + (base : K → List Bool) (input : List Bool) (ambient : σ) + (register : Option Bool) : + TM2.step program + ⟨some loopLabel, (ambient, register), Function.update base source (true :: input)⟩ = + some ⟨some loopLabel, (ambient, some true), Function.update base source input⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (Function.update base source (true :: input))) = _ + rw [atLoop] + simp [discard, TM2.stepAux] + +theorem discard_empty_step (source : K) (loopLabel returnLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = discard source loopLabel returnLabel) + (base : K → List Bool) (hinput : base source = []) + (ambient : σ) (register : Option Bool) : + TM2.step program ⟨some loopLabel, (ambient, register), base⟩ = + some ⟨some returnLabel, (ambient, none), base⟩ := by + have hupdate : Function.update base source [] = base := by + funext p + by_cases hp : p = source + · subst p; simp [hinput] + · simp [hp] + change some (TM2.stepAux (program loopLabel) (ambient, register) base) = _ + rw [atLoop] + simp [discard, TM2.stepAux, hinput, hupdate] + +theorem discardTrace_update (source : K) (loopLabel returnLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = discard source loopLabel returnLabel) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 1] + (some ⟨some loopLabel, (ambient, register), + Function.update base source (encodeWord n ++ suffix)⟩) = + some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩ := by + induction n generalizing register with + | zero => + simpa only [Nat.zero_add, Function.iterate_one, MachineComposition.advance_some, + encodeWord, List.replicate_zero, List.nil_append, List.singleton_append] using + discardStep_delimiter source loopLabel returnLabel program atLoop + base suffix ambient register + | succ n ih => + rw [Function.iterate_succ_apply] + simp only [encodeWord, List.replicate_succ, List.cons_append] + change (MachineComposition.advance (TM2.step program))^[n + 1] + (TM2.step program ⟨some loopLabel, (ambient, register), + Function.update base source (true :: (encodeWord n ++ suffix))⟩) = _ + rw [discardStep_true source loopLabel returnLabel program atLoop, ih] + +theorem discardTrace (source : K) (loopLabel returnLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = discard source loopLabel returnLabel) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (hinput : base source = encodeWord n ++ suffix) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[n + 1] + (some ⟨some loopLabel, (ambient, register), base⟩) = + some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩ := by + have hbase : Function.update base source (encodeWord n ++ suffix) = base := by + funext p + by_cases hp : p = source + · subst p; simp [hinput] + · simp [hp] + have h := discardTrace_update source loopLabel returnLabel program atLoop + base n suffix ambient register + rw [hbase] at h + exact h + +def discardInTime (source : K) (loopLabel returnLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = discard source loopLabel returnLabel) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (hinput : base source = encodeWord n ++ suffix) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some loopLabel, (ambient, register), base⟩ + (some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩) + (n + 1) where + steps := n + 1 + evals_in_steps := discardTrace source loopLabel returnLabel program atLoop + base n suffix hinput ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineLookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupSpec.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupSpec.lean new file mode 100644 index 0000000000000000000000000000000000000000..5dca6a175b10c5387012be1b7347620aa69eefd2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineLookupSpec.lean @@ -0,0 +1,209 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.Target + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLookupSpec + +def skipWord : List Bool → List Bool + | [] => [] + | true :: bs => skipWord bs + | false :: bs => bs + +@[simp] theorem skipWord_encodeWord (n : Nat) (bs : List Bool) : + skipWord (encodeWord n ++ bs) = bs := by + induction n with + | zero => simp [encodeWord, skipWord] + | succ n ih => + simpa [encodeWord, List.replicate_succ, skipWord] using ih + +theorem skipWord_iterate_encodeWords (i : Nat) (values : List Nat) : + (skipWord^[i]) (encodeWords values) = encodeWords (values.drop i) := by + induction i generalizing values with + | zero => rfl + | succ i ih => + rw [Function.iterate_succ_apply] + cases values with + | nil => simpa [encodeWords, skipWord] using ih [] + | cons n ns => + simpa only [encodeWords, skipWord_encodeWord, List.drop_succ_cons] using ih ns + +def headWord : List Bool → Option (List Bool) + | [] => none + | false :: _ => some [false] + | true :: bs => (headWord bs).map (true :: ·) + +@[simp] theorem headWord_encodeWord (n : Nat) (bs : List Bool) : + headWord (encodeWord n ++ bs) = some (encodeWord n) := by + induction n with + | zero => simp [encodeWord, headWord] + | succ n ih => + simpa [encodeWord, List.replicate_succ, headWord] using + congrArg (Option.map (true :: ·)) ih + +@[simp] theorem headWord_encodeWords (values : List Nat) : + headWord (encodeWords values) = values.head?.map encodeWord := by + cases values with + | nil => rfl + | cons n ns => exact headWord_encodeWord n (encodeWords ns) + +def lookupBits (i : Nat) (table : List Bool) : Option (List Bool) := + headWord ((skipWord^[i]) table) + +@[simp] theorem lookupBits_encodeWords (i : Nat) (values : List Nat) : + lookupBits i (encodeWords values) = values[i]?.map encodeWord := by + rw [lookupBits, skipWord_iterate_encodeWords, headWord_encodeWords, + List.head?_drop] + +def lookupEncoded (index table : List Bool) : Option (List Bool) := + match decodeWords index with + | some [i] => lookupBits i table + | _ => none + +@[simp] theorem decodeWords_encodeWord (i : Nat) : + decodeWords (encodeWord i) = some [i] := by + simpa [encodeWords] using decodeWords_encodeWords [i] + +@[simp] theorem lookupEncoded_encode (i : Nat) (values : List Nat) : + lookupEncoded (encodeWord i) (encodeWords values) = + values[i]?.map encodeWord := by + simp [lookupEncoded] + +theorem lookupEncoded_some (i value : Nat) (values : List Nat) + (h : values[i]? = some value) : + lookupEncoded (encodeWord i) (encodeWords values) = some (encodeWord value) := by + simp [h] + +theorem lookupEncoded_none (i : Nat) (values : List Nat) + (h : values.length ≤ i) : + lookupEncoded (encodeWord i) (encodeWords values) = none := by + simp [List.getElem?_eq_none h] + +theorem encoded_selected_split (values : List Nat) (i value : Nat) + (h : values[i]? = some value) : + encodeWords values = encodeWords (values.take i) ++ encodeWord value ++ + encodeWords (values.drop (i + 1)) := by + rcases List.getElem?_eq_some_iff.mp h with ⟨hi, hv⟩ + have hs : values = values.take i ++ value :: values.drop (i + 1) := by + calc + values = values.take i ++ values.drop i := (List.take_append_drop i values).symm + _ = _ := by rw [List.drop_eq_getElem_cons hi, hv] + simpa only [encodeWords_append, encodeWords, List.append_assoc] using + congrArg encodeWords hs + +def scannedBits (values : List Nat) (i : Nat) : Nat := + (encodeWords (values.take (i + 1))).length + +theorem encoded_prefix_length_le (values : List Nat) (i : Nat) : + (encodeWords (values.take i)).length ≤ (encodeWords values).length := by + have hs : encodeWords (values.take i) ++ encodeWords (values.drop i) = + encodeWords values := by + rw [← encodeWords_append, List.take_append_drop] + have hl := congrArg List.length hs + simp only [List.length_append] at hl + omega + +theorem scannedBits_le (values : List Nat) (i : Nat) : + scannedBits values i ≤ (encodeWords values).length := + encoded_prefix_length_le values (i + 1) + +theorem scannedBits_of_some (values : List Nat) (i value : Nat) + (h : values[i]? = some value) : + scannedBits values i = (encodeWords (values.take i)).length + value + 1 := by + rcases List.getElem?_eq_some_iff.mp h with ⟨hi, hv⟩ + simp [scannedBits, List.take_succ_eq_append_getElem hi, hv, encodeWords, + Nat.add_assoc] + +theorem selected_scan_length_le (values : List Nat) (i value : Nat) + (h : values[i]? = some value) : + (encodeWords (values.take i)).length + value + 1 ≤ + (encodeWords values).length := by + rw [← scannedBits_of_some values i value h] + exact scannedBits_le values i + +theorem output_length_le (values : List Nat) (i value : Nat) + (h : values[i]? = some value) : + (encodeWord value).length ≤ (encodeWords values).length := by + have hs := selected_scan_length_le values i value h + rw [encodeWord_length] + omega + +theorem index_length_le (values : List Nat) (i value : Nat) + (h : values[i]? = some value) : + (encodeWord i).length ≤ (encodeWords values).length := by + rcases List.getElem?_eq_some_iff.mp h with ⟨hi, _⟩ + have hp : i ≤ (encodeWords (values.take i)).length := by + simp only [encodeWords_length, List.length_take, Nat.min_eq_left (Nat.le_of_lt hi)] + omega + have hs := selected_scan_length_le values i value h + rw [encodeWord_length] + omega + +def steps : List Nat → Nat → Nat + | [], i => 2 * i + 2 + | n :: _, 0 => n + 3 + | n :: ns, i + 1 => n + 2 + steps ns i + +theorem steps_le_encoded_length_strong (values : List Nat) (i : Nat) : + steps values i ≤ (encodeWords values).length + 2 * i + 2 := by + induction values generalizing i with + | nil => simp [steps, encodeWords] + | cons n ns ih => + cases i with + | zero => + simp only [steps, encodeWords, List.length_append, encodeWord_length] + omega + | succ i => + have ht := ih i + simp only [steps, encodeWords, List.length_append, encodeWord_length] + omega + +theorem steps_le_encoded_length (values : List Nat) (i : Nat) : + steps values i ≤ (encodeWords values).length + 2 * i + 3 := by + have h := steps_le_encoded_length_strong values i + omega + +theorem steps_eq_scannedBits_of_lt (values : List Nat) (i : Nat) + (h : i < values.length) : + steps values i = scannedBits values i + i + 2 := by + induction values generalizing i with + | nil => simp at h + | cons n ns ih => + cases i with + | zero => simp [steps, scannedBits, encodeWords, Nat.add_assoc] + | succ i => + have ht := ih i (by simpa using h) + simp only [scannedBits] at ht + simp only [steps, scannedBits, List.take_succ_cons, encodeWords, + List.length_append, encodeWord_length] + omega + +theorem steps_eq_scannedBits_of_some (values : List Nat) (i value : Nat) + (h : values[i]? = some value) : + steps values i = scannedBits values i + i + 2 := by + rcases List.getElem?_eq_some_iff.mp h with ⟨hi, _⟩ + exact steps_eq_scannedBits_of_lt values i hi + +theorem steps_add_length_of_invalid (values : List Nat) (i : Nat) + (h : values.length ≤ i) : + steps values i + values.length = (encodeWords values).length + 2 * i + 2 := by + induction values generalizing i with + | nil => simp [steps, encodeWords] + | cons n ns ih => + cases i with + | zero => simp at h + | succ i => + have ht := ih i (by simpa using h) + simp only [steps, encodeWords, List.length_append, encodeWord_length, + List.length_cons] + omega + +theorem steps_le_input_encoding_size (values : List Nat) (i : Nat) : + steps values i ≤ (encodeWords values).length + 2 * (encodeWord i).length := by + have h := steps_le_encoded_length_strong values i + rw [encodeWord_length] + omega + +end IndependentSetsGames.Foundations.Complexity.MachineLookupSpec + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineOverlayRows.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineOverlayRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..32b557b262ab2fbf226ec73c9a8c6be9b57baa1e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineOverlayRows.lean @@ -0,0 +1,487 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Label +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingOverlayWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineOverlayRows + +open Turing MachineComposition +open PCP.GraphTables PCP.PreprocessingOverlayWords +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +variable {K Λ A : Type} [DecidableEq K] + +abbrev State (A : Type) (e : Nat) := MachinePortReindex.State A e + +inductive Label (e : Nat) + | loadStart | loadLoop | seedRelation + | row (stage : MachineLazyRows.Label e) + | drainOld | drainNew | drainRelation + deriving DecidableEq, Fintype + +def bodyIndex (i : Fin 9) : Fin 10 := i.castSucc + +theorem bodyIndex_injective : Function.Injective bodyIndex := by + intro i j h + exact Fin.castSucc_injective 9 h + +def trueBits : List Bool := encodeWords (relationWords trueRelation) + +def instruction (d e : Nat) (positive : 0 < e) (tape : Fin 10 → K) + (labels : Label e → Λ) (exit : Option Λ) : + Label e → TM2.Stmt (fun _ : K => Bool) Λ (State A e) + | .loadStart => Hastad.SourceMachine.fieldStart (tape 1) (labels .loadLoop) + | .loadLoop => Hastad.SourceMachine.fieldLoop (tape 9) (tape 1) + (labels .loadLoop) (some (labels .seedRelation)) + | .seedRelation => pushWord (tape 2) trueBits.reverse + (.goto fun _ => labels (.row (.inl .copySeed))) + | .row stage => MachineLazyRows.reindexInstruction e positive (d + e) d + (tape ∘ bodyIndex) (fun stage => labels (.row stage)) + (some (labels .drainOld)) stage + | .drainOld => MachineDrain.drain (tape 1) (labels .drainOld) (some (labels .drainNew)) + | .drainNew => MachineDrain.drain (tape 6) (labels .drainNew) (some (labels .drainRelation)) + | .drainRelation => MachineDrain.drain (tape 2) (labels .drainRelation) exit + +def rowBits (d e v j : Nat) : List Bool := + MachineLazyRows.reindexRowBits e (d + e) d v j trueRelation + +def rowSteps (d e v j : Nat) (output : List Bool) : Nat := + (j + 2) + 1 + MachineLazyRows.reindexSteps e (d + e) d v j trueRelation output + + (j + 2) + (MachinePortReindex.value e (d + e) d j + 2) + (trueBits.length + 1) + +def resultTapes (d e v j : Nat) (tape : Fin 10 → K) (base : K → List Bool) + (suffix : List Bool) : K → List Bool := + Function.update (Function.update base (tape 9) suffix) (tape 7) + (base (tape 7) ++ rowBits d e v j) + +theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {n m : Nat} + (first : f^[n] a = b) (second : f^[m] b = c) : f^[n + m] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem rowTrace (d e : Nat) (positive : 0 < e) (tape : Fin 10 → K) + (distinct : Function.Injective tape) (labels : Label e → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A e)) + (atLabels : ∀ l, program (labels l) = instruction d e positive tape labels exit l) + (base : K → List Bool) (v j : Nat) (suffix : List Bool) + (tailWord : base (tape 0) = encodeWord v) + (inputWord : base (tape 9) = encodeWord j ++ suffix) + (empty : ∀ i : Fin 10, i ≠ 0 → i ≠ 7 → i ≠ 9 → base (tape i) = []) + (ambient : A) : + (advance (TM2.step program))^[rowSteps d e v j (base (tape 7))] + (some ⟨some (labels .loadStart), MachinePortReindex.clean e positive ambient, base⟩) = + some ⟨exit, MachinePortReindex.clean e positive ambient, + resultTapes d e v j tape base suffix⟩ := by + have hd (i k : Fin 10) (h : i ≠ k) : tape i ≠ tape k := fun x => h (distinct x) + have h₁ := empty 1 (by decide) (by decide) (by decide) + have h₂ := empty 2 (by decide) (by decide) (by decide) + have h₃ := empty 3 (by decide) (by decide) (by decide) + have h₄ := empty 4 (by decide) (by decide) (by decide) + have h₅ := empty 5 (by decide) (by decide) (by decide) + have h₆ := empty 6 (by decide) (by decide) (by decide) + have h₈ := empty 8 (by decide) (by decide) (by decide) + have hi0 : bodyIndex 0 = 0 := rfl + have hi3 : bodyIndex 3 = 3 := rfl + have hi4 : bodyIndex 4 = 4 := rfl + have hi5 : bodyIndex 5 = 5 := rfl + have hi6 : bodyIndex 6 = 6 := rfl + have hi8 : bodyIndex 8 = 8 := rfl + let loaded := Function.update (Function.update base (tape 9) suffix) (tape 1) (encodeWord j) + let seeded := Function.update loaded (tape 2) trueBits + let rowed := MachineLazyRows.reindexResultTapes e (d + e) d v j trueRelation + (tape ∘ bodyIndex) seeded + let oldCleared := Function.update rowed (tape 1) [] + let newCleared := Function.update oldCleared (tape 6) [] + have loadRun : (advance (TM2.step program))^[j + 2] + (some ⟨some (labels .loadStart), MachinePortReindex.clean e positive ambient, base⟩) = + some ⟨some (labels .seedRelation), MachinePortReindex.clean e positive ambient, loaded⟩ := by + have h := (Hastad.SourceMachine.fieldInTime (tape 9) (tape 1) (hd 9 1 (by decide)) + (labels .loadStart) (labels .loadLoop) (some (labels .seedRelation)) program + (atLabels .loadStart) (atLabels .loadLoop) base j suffix inputWord + (ambient, MachineFixedDivMod.residue e positive 0) none).evals_in_steps + change (advance (TM2.step program))^[j + 2] + (some ⟨some (labels .loadStart), MachinePortReindex.clean e positive ambient, base⟩) = + some ⟨some (labels .seedRelation), MachinePortReindex.clean e positive ambient, + Hastad.SourceMachine.fieldTapes (tape 9) (tape 1) base suffix + (encodeWord j ++ base (tape 1))⟩ at h + simpa only [Hastad.SourceMachine.fieldTapes, + h₁, List.append_nil, MachinePortReindex.clean, loaded] using h + have seedRun : (advance (TM2.step program))^[1] + (some ⟨some (labels .seedRelation), MachinePortReindex.clean e positive ambient, loaded⟩) = + some ⟨some (labels (.row (.inl .copySeed))), + MachinePortReindex.clean e positive ambient, seeded⟩ := by + change some (TM2.stepAux (program (labels .seedRelation)) _ _) = _ + rw [atLabels] + simp [instruction, stepAux_pushWord, TM2.stepAux, seeded, loaded, + hd 2 1 (by decide), hd 2 9 (by decide), h₂] + have hs (i : Fin 10) (hi : i ≠ 1) (hi' : i ≠ 2) (hi'' : i ≠ 9) : + seeded (tape i) = base (tape i) := by + simp [seeded, loaded, hd i 1 hi, hd i 2 hi', hd i 9 hi''] + have bodyRun := MachineLazyRows.reindexRowTrace e positive (d + e) d + (tape ∘ bodyIndex) (distinct.comp bodyIndex_injective) (fun s => labels (.row s)) + (some (labels .drainOld)) program (fun s => atLabels (.row s)) seeded v j trueRelation + (by simpa only [Function.comp_apply, hi0] using + (hs 0 (by decide) (by decide) (by decide)).trans tailWord) + (by simp [seeded, loaded, Function.comp_apply, bodyIndex, hd 1 2 (by decide)]) + (by simp [seeded, Function.comp_apply, bodyIndex, trueBits]) + (by simpa only [Function.comp_apply, hi3] using + (hs 3 (by decide) (by decide) (by decide)).trans h₃) + (by simpa only [Function.comp_apply, hi4] using + (hs 4 (by decide) (by decide) (by decide)).trans h₄) + (by simpa only [Function.comp_apply, hi5] using + (hs 5 (by decide) (by decide) (by decide)).trans h₅) + (by simpa only [Function.comp_apply, hi6] using + (hs 6 (by decide) (by decide) (by decide)).trans h₆) + (by simpa only [Function.comp_apply, hi8] using + (hs 8 (by decide) (by decide) (by decide)).trans h₈) ambient + have hout : seeded ((tape ∘ bodyIndex) 7) = base (tape 7) := + hs 7 (by decide) (by decide) (by decide) + rw [hout] at bodyRun + change (advance (TM2.step program))^[MachineLazyRows.reindexSteps e (d + e) d v j + trueRelation (base (tape 7))] + (some ⟨some (labels (.row (.inl .copySeed))), MachinePortReindex.clean e positive ambient, seeded⟩) = + some ⟨some (labels .drainOld), MachinePortReindex.clean e positive ambient, rowed⟩ at bodyRun + have rowedOld : rowed (tape 1) = encodeWord j := by + simp [rowed, MachineLazyRows.reindexResultTapes, MachineLazyRows.reindexMappedTapes, + Function.comp_apply, bodyIndex, seeded, loaded, hd 1 7 (by decide), + hd 1 6 (by decide), hd 1 2 (by decide)] + have rowedNew : oldCleared (tape 6) = encodeWord (MachinePortReindex.value e (d + e) d j) := by + simp [oldCleared, rowed, MachineLazyRows.reindexResultTapes, + MachineLazyRows.reindexMappedTapes, Function.comp_apply, bodyIndex, + hd 6 1 (by decide), hd 6 7 (by decide)] + have rowedRelation : newCleared (tape 2) = trueBits := by + simp [newCleared, oldCleared, rowed, MachineLazyRows.reindexResultTapes, + MachineLazyRows.reindexMappedTapes, Function.comp_apply, bodyIndex, seeded, + hd 2 6 (by decide), hd 2 1 (by decide), hd 2 7 (by decide)] + have drainOld := (MachineDrain.drainInTime (tape 1) (labels .drainOld) + (some (labels .drainNew)) program (atLabels .drainOld) rowed + (ambient, MachineFixedDivMod.residue e positive 0) none).evals_in_steps + change (advance (TM2.step program))^[(rowed (tape 1)).length + 1] + (some ⟨some (labels .drainOld), MachinePortReindex.clean e positive ambient, rowed⟩) = + some ⟨some (labels .drainNew), MachinePortReindex.clean e positive ambient, oldCleared⟩ at drainOld + rw [rowedOld, encodeWord_length] at drainOld + have drainNew := (MachineDrain.drainInTime (tape 6) (labels .drainNew) + (some (labels .drainRelation)) program (atLabels .drainNew) oldCleared + (ambient, MachineFixedDivMod.residue e positive 0) none).evals_in_steps + change (advance (TM2.step program))^[(oldCleared (tape 6)).length + 1] + (some ⟨some (labels .drainNew), MachinePortReindex.clean e positive ambient, oldCleared⟩) = + some ⟨some (labels .drainRelation), MachinePortReindex.clean e positive ambient, newCleared⟩ at drainNew + rw [rowedNew, encodeWord_length] at drainNew + have drainRelation := (MachineDrain.drainInTime (tape 2) (labels .drainRelation) + exit program (atLabels .drainRelation) newCleared + (ambient, MachineFixedDivMod.residue e positive 0) none).evals_in_steps + change (advance (TM2.step program))^[(newCleared (tape 2)).length + 1] + (some ⟨some (labels .drainRelation), MachinePortReindex.clean e positive ambient, newCleared⟩) = + some ⟨exit, MachinePortReindex.clean e positive ambient, + Function.update newCleared (tape 2) []⟩ at drainRelation + rw [rowedRelation] at drainRelation + have finalFrame : Function.update newCleared (tape 2) [] = resultTapes d e v j tape base suffix := by + funext k + by_cases h2 : k = tape 2 + · subst k + simp [resultTapes, hd 2 7 (by decide), hd 2 9 (by decide), h₂] + · by_cases h6 : k = tape 6 + · subst k + simp [newCleared, resultTapes, hd 6 2 (by decide), hd 6 7 (by decide), + hd 6 9 (by decide), h₆] + · by_cases h1 : k = tape 1 + · subst k + simp [newCleared, oldCleared, resultTapes, hd 1 2 (by decide), + hd 1 6 (by decide), hd 1 7 (by decide), hd 1 9 (by decide), h₁] + · by_cases h7 : k = tape 7 + · subst k + simp [newCleared, oldCleared, rowed, MachineLazyRows.reindexResultTapes, + MachineLazyRows.reindexMappedTapes, Function.comp_apply, bodyIndex, + resultTapes, rowBits, seeded, loaded, hd 7 2 (by decide), + hd 7 6 (by decide), hd 7 1 (by decide), hd 7 9 (by decide)] + · simp [newCleared, oldCleared, rowed, MachineLazyRows.reindexResultTapes, + MachineLazyRows.reindexMappedTapes, Function.comp_apply, bodyIndex, + seeded, loaded, resultTapes, h2, h6, h1, h7] + rw [finalFrame] at drainRelation + exact joinTrace (joinTrace (joinTrace (joinTrace (joinTrace loadRun seedRun) bodyRun) + drainOld) drainNew) drainRelation + +theorem rowBits_eq_expanderRow {n degree : Nat} (d : Nat) + (H : PCP.ExpanderTables.Table n degree) (v : Fin n) (p : Fin degree) : + rowBits d degree v.val (PCP.ExpanderTables.reverseIndex H + (PCP.ExpanderTables.rowIndex n degree (v, p))).val = + encodeWords (rowWords (expanderRow d H v p)) := by + rw [expanderRow_words] + have h (j : Nat) : MachinePortReindex.value degree (d + degree) d j = + expanderReverseMap d degree j := by + unfold MachinePortReindex.value expanderReverseMap + omega + simp only [rowBits, MachineLazyRows.reindexRowBits, h, + PCP.PreprocessingLazyWords.relationWords_true, List.cons_append, + List.nil_append, encodeWords, List.append_assoc] + +def machine (d e : Nat) (positive : 0 < e) : FinTM2 where + K := Fin 10 + k₀ := 9 + k₁ := 7 + Γ _ := Bool + Λ := Label e + main := .loadStart + σ := State Unit e + initialState := MachinePortReindex.clean e positive () + m := instruction d e positive id id none + +abbrev VertexLabel (e : Nat) := Fin (e + 1) × Option (Label e) + +def vertexInstruction (d e : Nat) (positive : 0 < e) (tape : Fin 10 → K) + (labels : VertexLabel e → Λ) (exit : Option Λ) : + VertexLabel e → TM2.Stmt (fun _ : K => Bool) Λ (State A e) + | (i, none) => if i.val < e then .goto fun _ => labels (i, some .loadStart) + else MachinePortReindex.exitAt exit + | (i, some stage) => if h : i.val < e then + instruction d e positive tape (fun stage => labels (i, some stage)) + (some (labels (⟨i.val + 1, by omega⟩, none))) stage + else MachinePortReindex.exitAt exit + +def streamFrame (tape : Fin 10 → K) (base : K → List Bool) + (words : List Nat) (output : List Bool) : K → List Bool := + Function.update (Function.update base (tape 9) (encodeWords words ++ base (tape 9))) + (tape 7) output + +def streamOutput (d e v : Nat) (words : List Nat) : List Bool := + words.flatMap (rowBits d e v) + +def vertexSteps (d e v : Nat) : List Nat → List Bool → Nat + | [], _ => 1 + | j :: words, output => 1 + rowSteps d e v j output + + vertexSteps d e v words (output ++ rowBits d e v j) + +def valueBound (d e B : Nat) : Nat := (d + e) * B + B + d +def rowSizeBound (d e v B : Nat) : Nat := v + valueBound d e B + trueBits.length + 2 +def rowCostBound (d e v B : Nat) : Nat := + 8 * B + 4 * rowSizeBound d e v B + valueBound d e B + trueBits.length + 28 + +theorem value_le (d e j B : Nat) (hj : j ≤ B) : + MachinePortReindex.value e (d + e) d j ≤ valueBound d e B := by + have hdiv := (Nat.div_le_self j e).trans hj + have hmod := (Nat.mod_le j e).trans hj + have hmul := Nat.mul_le_mul_left (d + e) hdiv + unfold MachinePortReindex.value valueBound + omega + +theorem rowBits_length (d e v j : Nat) : + (rowBits d e v j).length = v + MachinePortReindex.value e (d + e) d j + trueBits.length + 2 := by + simp only [rowBits, MachineLazyRows.reindexRowBits, List.length_append, encodeWord_length, + trueBits] + omega + +theorem rowBits_length_le (d e v j B : Nat) (hj : j ≤ B) : + (rowBits d e v j).length ≤ rowSizeBound d e v B := by + rw [rowBits_length] + have h := value_le d e j B hj + unfold rowSizeBound + omega + +theorem rowSteps_le (d e v j B : Nat) (hj : j ≤ B) (output : List Bool) : + rowSteps d e v j output ≤ rowCostBound d e v B + 2 * output.length := by + have hdiv := (Nat.div_le_self j e).trans hj + have hval := value_le d e j B hj + have hsize := rowBits_length_le d e v j B hj + change (MachineLazyRows.reindexRowBits e (d + e) d v j trueRelation).length ≤ + rowSizeBound d e v B at hsize + unfold rowSteps MachineLazyRows.reindexSteps MachinePortReindex.steps rowCostBound + omega + +private theorem vertexSteps_le_capacity (d e v B capacity : Nat) + (words : List Nat) (bounded : ∀ j ∈ words, j ≤ B) (output : List Bool) + (room : output.length + words.length * rowSizeBound d e v B ≤ capacity) : + vertexSteps d e v words output ≤ + words.length * (rowCostBound d e v B + 2 * capacity + 1) + 1 := by + induction words generalizing output with + | nil => simp [vertexSteps] + | cons j words ih => + have hj := bounded j (by simp) + have hb : ∀ k ∈ words, k ≤ B := fun k hk => bounded k (by simp [hk]) + have hsize := rowBits_length_le d e v j B hj + have hcost := rowSteps_le d e v j B hj output + have hout : output.length ≤ capacity := by omega + have hroom : (output ++ rowBits d e v j).length + + words.length * rowSizeBound d e v B ≤ capacity := by + rw [List.length_append] + simp only [List.length_cons, Nat.succ_mul] at room + omega + have htail := ih hb (output ++ rowBits d e v j) hroom + change 1 + rowSteps d e v j output + + vertexSteps d e v words (output ++ rowBits d e v j) ≤ + (words.length + 1) * (rowCostBound d e v B + 2 * capacity + 1) + 1 + rw [Nat.add_mul, Nat.one_mul] + omega + +theorem vertexSteps_le (d e v B : Nat) (words : List Nat) + (bounded : ∀ j ∈ words, j ≤ B) (output : List Bool) : + vertexSteps d e v words output ≤ + words.length * (rowCostBound d e v B + + 2 * (output.length + words.length * rowSizeBound d e v B) + 1) + 1 := + vertexSteps_le_capacity d e v B _ words bounded output (Nat.le_refl _) + +private theorem streamFrame_afterRow (d e v j : Nat) (tape : Fin 10 → K) + (distinct : Function.Injective tape) (base : K → List Bool) + (words : List Nat) (output : List Bool) : + resultTapes d e v j tape (streamFrame tape base (j :: words) output) + (encodeWords words ++ base (tape 9)) = + streamFrame tape base words (output ++ rowBits d e v j) := by + have h79 : tape 7 ≠ tape 9 := fun h => (by decide : (7 : Fin 10) ≠ 9) (distinct h) + funext k + by_cases h7 : k = tape 7 + · subst k + simp [resultTapes, streamFrame] + · by_cases h9 : k = tape 9 + · subst k + simp [resultTapes, streamFrame, Ne.symm h79] + · simp [resultTapes, streamFrame, h7, h9] + +theorem vertexSuffixTrace (d e : Nat) (positive : 0 < e) (tape : Fin 10 → K) + (distinct : Function.Injective tape) (labels : VertexLabel e → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A e)) + (atLabels : ∀ l, program (labels l) = vertexInstruction d e positive tape labels exit l) + (base : K → List Bool) (v : Nat) (values : Fin e → Nat) + (tailWord : base (tape 0) = encodeWord v) + (empty : ∀ i : Fin 10, i ≠ 0 → i ≠ 7 → i ≠ 9 → base (tape i) = []) + (ambient : A) (remaining : Nat) (i : Fin (e + 1)) (count : i.val + remaining = e) + (output : List Bool) : + (advance (TM2.step program))^[vertexSteps d e v ((List.ofFn values).drop i.val) output] + (some ⟨some (labels (i, none)), MachinePortReindex.clean e positive ambient, + streamFrame tape base ((List.ofFn values).drop i.val) output⟩) = + some ⟨exit, MachinePortReindex.clean e positive ambient, + streamFrame tape base [] (output ++ streamOutput d e v ((List.ofFn values).drop i.val))⟩ := by + have hd (a b : Fin 10) (h : a ≠ b) : tape a ≠ tape b := fun x => h (distinct x) + induction remaining generalizing i output with + | zero => + have hi : i.val = e := by omega + have hdrop : (List.ofFn values).drop i.val = [] := by + apply List.drop_eq_nil_of_le + simp only [List.length_ofFn, hi, le_refl] + rw [hdrop] + simp only [vertexSteps, streamOutput, List.flatMap_nil, List.append_nil] + change some (TM2.stepAux (program (labels (i, none))) _ _) = _ + rw [atLabels] + cases exit <;> simp [vertexInstruction, hi, MachinePortReindex.exitAt, TM2.stepAux] + | succ remaining ih => + have hi : i.val < e := by omega + let port : Fin e := ⟨i.val, hi⟩ + let next : Fin (e + 1) := ⟨i.val + 1, by omega⟩ + let rest := (List.ofFn values).drop (i.val + 1) + have split : (List.ofFn values).drop i.val = values port :: rest := by + have h := List.getElem_cons_drop (as := List.ofFn values) + (i := i.val) (by simpa only [List.length_ofFn] using hi) + simpa only [List.getElem_ofFn, port, rest] using h.symm + let initial := streamFrame tape base (values port :: rest) output + have boundary : (advance (TM2.step program))^[1] + (some ⟨some (labels (i, none)), MachinePortReindex.clean e positive ambient, initial⟩) = + some ⟨some (labels (i, some .loadStart)), MachinePortReindex.clean e positive ambient, initial⟩ := by + change some (TM2.stepAux (program (labels (i, none))) _ _) = _ + rw [atLabels] + simp [vertexInstruction, hi, TM2.stepAux] + have body := rowTrace d e positive tape distinct (fun stage => labels (i, some stage)) + (some (labels (next, none))) program + (by + intro stage + simpa only [vertexInstruction, hi, dite_true, next] using + (atLabels (i, some stage))) initial v (values port) + (encodeWords rest ++ base (tape 9)) + (by simp [initial, streamFrame, hd 0 7 (by decide), hd 0 9 (by decide), tailWord]) + (by simp [initial, streamFrame, hd 9 7 (by decide), encodeWords, List.append_assoc]) + (by + intro k hk0 hk7 hk9 + simp [initial, streamFrame, hd k 7 hk7, hd k 9 hk9, empty k hk0 hk7 hk9]) ambient + have initialOutput : initial (tape 7) = output := by simp [initial, streamFrame] + rw [initialOutput] at body + change (advance (TM2.step program))^[rowSteps d e v (values port) output] + (some ⟨some (labels (i, some .loadStart)), MachinePortReindex.clean e positive ambient, initial⟩) = + some ⟨some (labels (next, none)), MachinePortReindex.clean e positive ambient, + resultTapes d e v (values port) tape initial (encodeWords rest ++ base (tape 9))⟩ at body + rw [show resultTapes d e v (values port) tape initial (encodeWords rest ++ base (tape 9)) = + streamFrame tape base rest (output ++ rowBits d e v (values port)) from + streamFrame_afterRow d e v (values port) tape distinct base rest output] at body + have nextCount : next.val + remaining = e := by dsimp [next]; omega + have tail := ih next nextCount (output ++ rowBits d e v (values port)) + change (advance (TM2.step program))^[vertexSteps d e v rest (output ++ rowBits d e v (values port))] + (some ⟨some (labels (next, none)), MachinePortReindex.clean e positive ambient, + streamFrame tape base rest (output ++ rowBits d e v (values port))⟩) = + some ⟨exit, MachinePortReindex.clean e positive ambient, + streamFrame tape base [] ((output ++ rowBits d e v (values port)) ++ streamOutput d e v rest)⟩ at tail + rw [split] + have all := joinTrace (joinTrace boundary body) tail + simpa only [vertexSteps, initial, streamOutput, List.flatMap_cons, List.append_assoc] using all + +theorem vertexTrace (d e : Nat) (positive : 0 < e) (tape : Fin 10 → K) + (distinct : Function.Injective tape) (labels : VertexLabel e → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A e)) + (atLabels : ∀ l, program (labels l) = vertexInstruction d e positive tape labels exit l) + (base : K → List Bool) (v : Nat) (values : Fin e → Nat) + (tailWord : base (tape 0) = encodeWord v) + (empty : ∀ i : Fin 10, i ≠ 0 → i ≠ 7 → i ≠ 9 → base (tape i) = []) + (ambient : A) (output : List Bool) : + (advance (TM2.step program))^[vertexSteps d e v (List.ofFn values) output] + (some ⟨some (labels (0, none)), MachinePortReindex.clean e positive ambient, + streamFrame tape base (List.ofFn values) output⟩) = + some ⟨exit, MachinePortReindex.clean e positive ambient, + streamFrame tape base [] (output ++ streamOutput d e v (List.ofFn values))⟩ := by + simpa only [Fin.val_zero, List.drop_zero] using vertexSuffixTrace d e positive tape distinct + labels exit program atLabels base v values tailWord empty ambient e 0 (by simp) output + +def vertexInTime (d e : Nat) (positive : 0 < e) (tape : Fin 10 → K) + (distinct : Function.Injective tape) (labels : VertexLabel e → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A e)) + (atLabels : ∀ l, program (labels l) = vertexInstruction d e positive tape labels exit l) + (base : K → List Bool) (v B : Nat) (values : Fin e → Nat) + (bounded : ∀ p, values p ≤ B) + (tailWord : base (tape 0) = encodeWord v) + (empty : ∀ i : Fin 10, i ≠ 0 → i ≠ 7 → i ≠ 9 → base (tape i) = []) + (ambient : A) (output : List Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels (0, none)), MachinePortReindex.clean e positive ambient, + streamFrame tape base (List.ofFn values) output⟩ + (some ⟨exit, MachinePortReindex.clean e positive ambient, + streamFrame tape base [] (output ++ streamOutput d e v (List.ofFn values))⟩) + (e * (rowCostBound d e v B + 2 * (output.length + e * rowSizeBound d e v B) + 1) + 1) where + steps := vertexSteps d e v (List.ofFn values) output + evals_in_steps := vertexTrace d e positive tape distinct labels exit program atLabels + base v values tailWord empty ambient output + steps_le_m := by + simpa only [List.length_ofFn] using vertexSteps_le d e v B (List.ofFn values) + (by intro j hj; obtain ⟨p, rfl⟩ := List.mem_ofFn.mp hj; exact bounded p) output + +theorem encodeWords_flatMap {α : Type*} (items : List α) (words : α → List Nat) : + encodeWords (items.flatMap words) = items.flatMap (fun x => encodeWords (words x)) := by + induction items with + | nil => rfl + | cons item items ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem streamOutput_expanderRows {n degree : Nat} (d : Nat) + (H : PCP.ExpanderTables.Table n degree) (v : Fin n) : + streamOutput d degree v.val (List.ofFn fun p : Fin degree => + (PCP.ExpanderTables.reverseIndex H (PCP.ExpanderTables.rowIndex n degree (v, p))).val) = + encodeWords ((List.ofFn (expanderRow d H v)).flatMap rowWords) := by + rw [encodeWords_flatMap] + simp only [streamOutput, List.flatMap_def, List.map_ofFn] + apply congrArg List.flatten + apply congrArg List.ofFn + funext p + exact rowBits_eq_expanderRow d H v p + +theorem expanderValues_bounded {n degree : Nat} (H : PCP.ExpanderTables.Table n degree) + (v : Fin n) (p : Fin degree) : + (PCP.ExpanderTables.reverseIndex H (PCP.ExpanderTables.rowIndex n degree (v, p))).val ≤ + n * degree := + (PCP.ExpanderTables.reverseIndex H (PCP.ExpanderTables.rowIndex n degree (v, p))).isLt.le + +def vertexMachine (d e : Nat) (positive : 0 < e) : FinTM2 where + K := Fin 10 + k₀ := 9 + k₁ := 7 + Γ _ := Bool + Λ := VertexLabel e + main := (0, none) + σ := State Unit e + initialState := MachinePortReindex.clean e positive () + m := vertexInstruction d e positive id id none + +end IndependentSetsGames.Foundations.Complexity.MachineOverlayRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyBounds.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..6890afa97b654513d6d5965a66eef2f44f8b8486 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyBounds.lean @@ -0,0 +1,176 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddedExpanderFamilyFrames + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamilyBounds + +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords + +def timeCoefficient : Nat := + MachineExpanderFamilyBounds.inputCoefficient + PCP.ExpanderFamily.growth + 29 + +noncomputable def timePolynomial : Polynomial Nat := + Polynomial.C timeCoefficient * Polynomial.X^5 + +theorem timePolynomial_encoding (k : Nat) : + timePolynomial.eval (encodeWord k).length = timeCoefficient * (k + 1)^5 := by + simp only [timePolynomial, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_pow, Polynomial.eval_X, encodeWord_length] + +theorem ceilingCost_le (g k : Nat) : + (MachineCeilingPower.timePolynomial g).eval (encodeWord k).length ≤ + (g + 29) * (k + 1)^5 := by + rw [MachineCeilingPower.timePolynomial_encoding] + have squareBound : (k + 1)^2 ≤ (k + 1)^5 := + Nat.pow_le_pow_right (Nat.succ_pos k) (by decide) + have linearBound : k + 1 ≤ (k + 1)^5 := by + simpa only [pow_one] using Nat.pow_le_pow_right + (Nat.succ_pos k) (show 1 ≤ 5 by decide) + have constantBound : 1 ≤ (k + 1)^5 := by omega + have squareCost := Nat.mul_le_mul_left (g + 8) squareBound + have linearCost := Nat.mul_le_mul_left 18 linearBound + have constantCost := Nat.mul_le_mul_left 3 constantBound + unfold MachineCeilingPower.timeBound + nlinarith only [squareCost, linearCost, constantCost] + +theorem combinedCost_le (k : Nat) : + (MachineCeilingPower.timePolynomial PCP.ExpanderFamily.growth).eval + (encodeWord k).length + + MachineExpanderFamilyBounds.inputCoefficient * (k + 1)^5 ≤ + timePolynomial.eval (encodeWord k).length := by + rw [timePolynomial_encoding] + have h := ceilingCost_le PCP.ExpanderFamily.growth k + unfold timeCoefficient + nlinarith only [h] + +theorem familyCost_le + (H : Table (cloudSize PCP.Expanders.baseDegree) PCP.Expanders.baseDegree) (k : Nat) : + (MachineCeilingPower.timePolynomial PCP.ExpanderFamily.growth).eval + (encodeWord k).length + + MachineExpanderFamilyBounds.familyBudget H (PCP.PreprocessingLevels.boundedLevel k) ≤ + timePolynomial.eval (encodeWord k).length := by + exact (Nat.add_le_add_left + (MachineExpanderFamilyBounds.familyBudget_at_boundedLevel_le H k) _).trans + (combinedCost_le k) + +def outputWord + (H : Table (cloudSize PCP.Expanders.baseDegree) PCP.Expanders.baseDegree) (k : Nat) : + List Bool := + encodeWords (rotationWords (family H (PCP.PreprocessingLevels.boundedLevel k))) + +def outputCoefficient : Nat := + (PCP.ExpanderFamily.growth * degree PCP.Expanders.baseDegree + 1)^2 + +theorem outputWord_length_le + (H : Table (cloudSize PCP.Expanders.baseDegree) PCP.Expanders.baseDegree) (k : Nat) : + (outputWord H k).length ≤ outputCoefficient * (k + 1)^2 := by + let q := degree PCP.Expanders.baseDegree + let N := vertexCount q (PCP.PreprocessingLevels.boundedLevel k) + have sizeBound : N ≤ PCP.ExpanderFamily.growth * (k + 1) := by + change vertexCount (PCP.Expanders.baseDegree * PCP.Expanders.baseDegree) + (PCP.PreprocessingLevels.boundedLevel k) ≤ _ + rw [PCP.PreprocessingLevels.table_vertexCount_eq_paddedSize] + exact MachineExpanderFamilyBounds.paddedSize_le_succ_input k + have rowBound := Nat.mul_le_mul_right q sizeBound + have rowSuccBound : N * q + 1 ≤ (PCP.ExpanderFamily.growth * q + 1) * (k + 1) := by + nlinarith only [rowBound, Nat.zero_le k] + have lengthBound : (outputWord H k).length ≤ (N * q) * (N * q + 1) := + encode_rotationWords_length_le (family H (PCP.PreprocessingLevels.boundedLevel k)) + calc + _ ≤ (N * q + 1)^2 := by nlinarith only [lengthBound, Nat.zero_le (N * q)] + _ ≤ ((PCP.ExpanderFamily.growth * q + 1) * (k + 1))^2 := + Nat.pow_le_pow_left rowSuccBound 2 + _ = _ := by unfold outputCoefficient; dsimp [q]; ring + +end IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamilyBounds + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamily + +open Turing +open MachineCloudPadding +open MachineComposition + +variable {ρ : Type} [Fintype ρ] + +noncomputable def ceilingInTime (H : SmallTable) (requested : Nat) + (state : MachineExpanderFamily.State ρ fixedDegree) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program H)) + ⟨some main, initialState state register, initialTapes requested⟩ + (some ⟨some familyEntry, (state, (false, none)), handoffTapes requested⟩) + ((MachineCeilingPower.timePolynomial PCP.ExpanderFamily.growth).eval + (encodeWord requested).length) := by + let original := MachineCeilingPower.paddingInTime requested state register + let renamed := MachineStateEquiv.execution (ceilingStates ρ) + (MachineCeilingPower.program PCP.ExpanderFamily.growth) original + let placed := liftExecutionInTime (TM2.step (ceilingSource (ρ := ρ))) + (TM2.step (program H)) + (Placement.configuration ceilingView ceilingLabel (some familyEntry) (fun _ => [])) + (Placement.step_simulation ceilingTape ceilingView ceilingView_left ceilingView_right + ceilingLabel (some familyEntry) (fun _ => []) (ceilingSource (ρ := ρ)) + (program H) (program_ceiling H)) renamed + have initialEq := ceiling_initial_configuration requested state register + have finalEq := ceiling_handoff_configuration requested state + unfold ceilingInput at initialEq + unfold ceilingOutput at finalEq + simpa only [initialEq, finalEq] using placed + +noncomputable def materializeInTime (H : SmallTable) (requested : Nat) + (state : MachineExpanderFamily.State ρ fixedDegree) : + StateTransition.EvalsToInTime (TM2.step (program H)) + ⟨some familyEntry, (state, (false, none)), handoffTapes requested⟩ + (some ⟨none, finalState H state, finalTapes H requested⟩) + (MachineExpanderFamilyBounds.inputCoefficient * (requested + 1)^5) := by + let original := MachineExpanderFamily.paddedFamilyInTime H requested state [] + let boolean := MachineAlphabetTransport.executionInTime MachineExpanderFamily.alphabet_eq + (MachineExpanderFamily.program MachineExpanderFamily.baseDegree_positive H + MachineExpanderFamily.baseDegree_cloud_gt_one) original + let framed := MachineStateFrame.frameExecution + (MachineExpanderFamily.boolView MachineExpanderFamily.baseDegree_positive H + MachineExpanderFamily.baseDegree_cloud_gt_one) (false, (none : Option Bool)) boolean + let placed := liftExecutionInTime (TM2.step (familySource H)) (TM2.step (program H)) + (Placement.configuration familyView familyLabel none (retainedFrame requested)) + (Placement.step_simulation familyTape familyView familyView_left familyView_right + familyLabel none (retainedFrame requested) (familySource H) (program H) + (program_family H)) framed + simpa only [family_initial_configuration, family_final_configuration] using placed + +noncomputable def paddedInTime (H : SmallTable) (requested : Nat) + (state : MachineExpanderFamily.State ρ fixedDegree) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program H)) + ⟨some main, initialState state register, initialTapes requested⟩ + (some ⟨none, finalState H state, finalTapes H requested⟩) + (MachinePaddedExpanderFamilyBounds.timePolynomial.eval (encodeWord requested).length) := by + let first := ceilingInTime H requested state register + let second := materializeInTime H requested state + let all := StateTransition.EvalsToInTime.trans (TM2.step (program H)) + _ _ _ _ _ first second + exact + { toEvalsTo := all.toEvalsTo + steps_le_m := all.steps_le_m.trans + (by simpa only [Nat.add_comm] using + MachinePaddedExpanderFamilyBounds.combinedCost_le requested) } + +noncomputable def placedInTime {K Λ : Type} [DecidableEq K] + (tape : Tape → K) (view : K → Option Tape) + (left : ∀ t, view (tape t) = some t) + (right : ∀ j t, view j = some t → tape t = j) + (labels : Label → Λ) (exit : Option Λ) (extra : K → List Bool) + (H : SmallTable) (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ)) + (code : ∀ l, target (labels l) = Placement.statement tape labels exit (program H l)) + (requested : Nat) (state : MachineExpanderFamily.State ρ fixedDegree) + (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step target) + (Placement.configuration view labels exit extra + ⟨some main, initialState state register, initialTapes requested⟩) + (some (Placement.configuration view labels exit extra + ⟨none, finalState H state, finalTapes H requested⟩)) + (MachinePaddedExpanderFamilyBounds.timePolynomial.eval (encodeWord requested).length) := + liftExecutionInTime (TM2.step (program H)) (TM2.step target) + (Placement.configuration view labels exit extra) + (Placement.step_simulation tape view left right labels exit extra (program H) target code) + (paddedInTime H requested state register) + +end IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyFrames.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyFrames.lean new file mode 100644 index 0000000000000000000000000000000000000000..a37d0992cc9f9c5fffd82d8e6ed9dd219e9eabd9 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyFrames.lean @@ -0,0 +1,143 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddedExpanderFamilyProgram + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamily + +open Turing +open MachineCloudPadding +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords + +def ceilingInput (requested : Nat) : MachineCeilingPower.Tape → List Bool := + MachineCeilingPower.memory (encodeWord requested) [] [] [] [] [] [] [] + +def ceilingOutput (requested : Nat) : MachineCeilingPower.Tape → List Bool := + MachineCeilingPower.memory (encodeWord requested) [] + (encodeWord (PCP.PreprocessingLevels.paddedSize requested)) [] + (encodeWord (PCP.PreprocessingLevels.boundedLevel requested)) [] [] [] + +def retainedFrame (requested : Nat) : Tape → List Bool + | .inl _ => [] + | .inr tape => retainedCeilingTapes requested tape + +theorem ceiling_initial_tapes (requested : Nat) : + Placement.tapes ceilingView (ceilingInput requested) (fun _ => []) = + initialTapes requested := by + funext tape + rcases tape with tape | tape + · rcases tape with tape | tape + · rfl + · cases tape <;> rfl + · cases tape <;> rfl + +theorem ceiling_handoff_tapes (requested : Nat) : + Placement.tapes ceilingView (ceilingOutput requested) (fun _ => []) = + handoffTapes requested := by + funext tape + rcases tape with tape | tape + · rcases tape with tape | tape + · rcases tape with tape | tape + · cases tape <;> rfl + · cases tape <;> rfl + · cases tape <;> + simp [Placement.tapes, ceilingView, ceilingOutput, handoffTapes, + MachineExpanderFamily.toBoolTapes, MachineExpanderFamily.toBoolWord, + MachineExpanderFamily.initialTapes, MachineEmbedding.tapes, + MachineCeilingPower.memory] + · cases tape <;> rfl + +theorem family_initial_tapes (requested : Nat) : + Placement.tapes familyView + (MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.initialTapes (PCP.PreprocessingLevels.boundedLevel requested) [])) + (retainedFrame requested) = handoffTapes requested := by + funext tape + cases tape <;> rfl + +theorem family_final_tapes (H : SmallTable) (requested : Nat) : + Placement.tapes familyView + (MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.familyTapes H (PCP.PreprocessingLevels.boundedLevel requested) [])) + (retainedFrame requested) = finalTapes H requested := by + funext tape + cases tape <;> rfl + +theorem ceiling_initial_configuration {ρ : Type} (requested : Nat) + (state : MachineExpanderFamily.State ρ fixedDegree) (register : Option Bool) : + Placement.configuration ceilingView ceilingLabel (some familyEntry) (fun _ => []) + (MachineStateEquiv.configuration (ceilingStates ρ) + ⟨some .init, ((state, false), register), ceilingInput requested⟩) = + ⟨some main, initialState state register, initialTapes requested⟩ := by + simp only [Placement.configuration, Placement.label, MachineStateEquiv.configuration, + ceilingStates_apply, ceiling_initial_tapes, ceilingLabel, main, initialState] + +theorem ceiling_handoff_configuration {ρ : Type} (requested : Nat) + (state : MachineExpanderFamily.State ρ fixedDegree) : + Placement.configuration ceilingView ceilingLabel (some familyEntry) (fun _ => []) + (MachineStateEquiv.configuration (ceilingStates ρ) + ⟨none, ((state, false), none), ceilingOutput requested⟩) = + ⟨some familyEntry, (state, (false, none)), handoffTapes requested⟩ := by + simp only [Placement.configuration, Placement.label, MachineStateEquiv.configuration, + ceilingStates_apply, ceiling_handoff_tapes] + +theorem family_initial_configuration {ρ : Type} (requested : Nat) + (state : MachineExpanderFamily.State ρ fixedDegree) (metadata : Bool × Option Bool) : + Placement.configuration familyView familyLabel none (retainedFrame requested) + (MachineStateFrame.frameConfiguration metadata + (MachineAlphabetTransport.configuration MachineExpanderFamily.alphabet_eq + ⟨some (.inr .initialize), state, + MachineExpanderFamily.initialTapes (PCP.PreprocessingLevels.boundedLevel requested) []⟩)) = + ⟨some familyEntry, (state, metadata), handoffTapes requested⟩ := by + rw [MachineExpanderFamily.configuration_toBool] + simp only [MachineStateFrame.frameConfiguration, Placement.configuration, Placement.label, + family_initial_tapes, familyEntry, familyLabel] + +theorem family_final_configuration {ρ : Type} (H : SmallTable) (requested : Nat) + (state : MachineExpanderFamily.State ρ fixedDegree) : + Placement.configuration familyView familyLabel none (retainedFrame requested) + (MachineStateFrame.frameConfiguration (false, none) + (MachineAlphabetTransport.configuration MachineExpanderFamily.alphabet_eq + ⟨none, + MachineExpanderFamily.initialState MachineExpanderFamily.baseDegree_positive H + (MachineExpanderFamily.caller state), + MachineExpanderFamily.familyTapes H (PCP.PreprocessingLevels.boundedLevel requested) []⟩)) = + ⟨none, finalState H state, finalTapes H requested⟩ := by + rw [MachineExpanderFamily.configuration_toBool] + simp only [MachineStateFrame.frameConfiguration, Placement.configuration, Placement.label, + family_final_tapes, finalState] + +@[simp] theorem handoffTapes_level (requested : Nat) : + handoffTapes requested (ceilingTape .level) = + encodeWord (PCP.PreprocessingLevels.boundedLevel requested) := by + simp [handoffTapes, ceilingTape, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.initialTapes, + MachineEmbedding.tapes] + +@[simp] theorem handoffTapes_level_shadow (requested : Nat) : + handoffTapes requested (.inr .level) = [] := rfl + +@[simp] theorem finalTapes_level_shadow (H : SmallTable) (requested : Nat) : + finalTapes H requested (.inr .level) = [] := rfl + +@[simp] theorem finalTapes_remainingLevel (H : SmallTable) (requested : Nat) : + finalTapes H requested (ceilingTape .level) = encodeWord 0 := by + simp [finalTapes, ceilingTape, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.familyTapes, + MachineExpanderFamily.boundaryTapes, MachineExpanderFamily.extraFrame, + MachineEmbedding.tapes] + +theorem finalTapes_currentSize (H : SmallTable) (requested : Nat) : + finalTapes H requested (familyTape (.inr .currentSize)) = + encodeWord (PCP.PreprocessingLevels.paddedSize requested) := by + change encodeWord (vertexCount (degree fixedDegree) + (PCP.PreprocessingLevels.boundedLevel requested)) = _ + exact congrArg encodeWord (PCP.PreprocessingLevels.table_vertexCount_eq_paddedSize requested) + +theorem finalTapes_table (H : SmallTable) (requested : Nat) : + finalTapes H requested (familyTape MachineExpanderFamily.tableTape) = + encodeWords (rotationWords (family H (PCP.PreprocessingLevels.boundedLevel requested))) := rfl + +end IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyProgram.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d9ae0bc0f8de72a48253fe2a0fe058fdac08106 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedExpanderFamilyProgram.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineStateEquiv +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudPadding +import OAI.Combinatorics.IndependentSets.Machines.MachineStateFrame +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderFamilyLoop + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamily + +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl + +abbrev fixedDegree := PCP.Expanders.baseDegree +abbrev SmallTable := Table (cloudSize fixedDegree) fixedDegree +abbrev Tape := MachineExpanderFamily.Tape ⊕ MachineCeilingPower.Tape +abbrev Alphabet (_ : Tape) := Bool +abbrev Label := MachineExpanderFamily.Label fixedDegree ⊕ MachineCeilingPower.Label +abbrev State (ρ : Type) := MachineExpanderFamily.State ρ fixedDegree × (Bool × Option Bool) + +def familyTape (tape : MachineExpanderFamily.Tape) : Tape := .inl tape + +def familyView : Tape → Option MachineExpanderFamily.Tape + | .inl tape => some tape + | .inr _ => none + +@[simp] theorem familyView_left (tape : MachineExpanderFamily.Tape) : + familyView (familyTape tape) = some tape := rfl + +theorem familyView_right (j : Tape) (tape : MachineExpanderFamily.Tape) + (h : familyView j = some tape) : familyTape tape = j := by + cases j with + | inl j => + have hj : j = tape := Option.some.inj h + subst tape + rfl + | inr j => simp [familyView] at h + +def ceilingTape : MachineCeilingPower.Tape → Tape + | .level => .inl (.inr .remainingLevel) + | tape => .inr tape + +def ceilingView : Tape → Option MachineCeilingPower.Tape + | .inl (.inr .remainingLevel) => some .level + | .inl _ => none + | .inr .level => none + | .inr tape => some tape + +@[simp] theorem ceilingView_left (tape : MachineCeilingPower.Tape) : + ceilingView (ceilingTape tape) = some tape := by + cases tape <;> rfl + +theorem ceilingView_right (j : Tape) (tape : MachineCeilingPower.Tape) + (h : ceilingView j = some tape) : ceilingTape tape = j := by + cases j with + | inl j => + cases j with + | inl j => simp [ceilingView] at h + | inr tape => + cases tape <;> simp_all [ceilingView, ceilingTape] + cases h + rfl + | inr j => cases j <;> simp_all [ceilingView, ceilingTape] <;> cases h <;> rfl + +def familyLabel (label : MachineExpanderFamily.Label fixedDegree) : Label := .inl label +def ceilingLabel (label : MachineCeilingPower.Label) : Label := .inr label +def main : Label := .inr .init +def familyEntry : Label := .inl (.inr .initialize) + +def ceilingStates (ρ : Type) : + MachineCeilingPower.State (MachineExpanderFamily.State ρ fixedDegree) ≃ State ρ := + Equiv.prodAssoc _ _ _ + +@[simp] theorem ceilingStates_apply (ρ : Type) + (state : MachineCeilingPower.State (MachineExpanderFamily.State ρ fixedDegree)) : + ceilingStates ρ state = (state.1.1, (state.1.2, state.2)) := rfl + +variable {ρ : Type} [Fintype ρ] + +def familySource (H : SmallTable) : MachineExpanderFamily.Label fixedDegree → + TM2.Stmt MachineExpanderFamily.BoolAlphabet + (MachineExpanderFamily.Label fixedDegree) (State ρ) := + MachineStateFrame.frameProgram (τ := Bool × Option Bool) + (MachineExpanderFamily.boolView MachineExpanderFamily.baseDegree_positive H + MachineExpanderFamily.baseDegree_cloud_gt_one) + +def ceilingSource : MachineCeilingPower.Label → + TM2.Stmt MachineCeilingPower.Alphabet MachineCeilingPower.Label (State ρ) := + MachineStateEquiv.program (ceilingStates ρ) + (MachineCeilingPower.program PCP.ExpanderFamily.growth) + +def program (H : SmallTable) : Label → TM2.Stmt Alphabet Label (State ρ) + | .inl label => + MachineCloudPadding.Placement.statement familyTape familyLabel none (familySource H label) + | .inr label => + MachineCloudPadding.Placement.statement ceilingTape ceilingLabel (some familyEntry) + (ceilingSource (ρ := ρ) label) + +@[simp] theorem program_family (H : SmallTable) + (label : MachineExpanderFamily.Label fixedDegree) : + program (ρ := ρ) H (familyLabel label) = + MachineCloudPadding.Placement.statement familyTape familyLabel none + (familySource H label) := rfl + +@[simp] theorem program_ceiling (H : SmallTable) (label : MachineCeilingPower.Label) : + program (ρ := ρ) H (ceilingLabel label) = + MachineCloudPadding.Placement.statement ceilingTape ceilingLabel (some familyEntry) + (ceilingSource (ρ := ρ) label) := rfl + +def initialState (state : MachineExpanderFamily.State ρ fixedDegree) + (register : Option Bool) : State ρ := (state, (false, register)) + +def finalState (H : SmallTable) (state : MachineExpanderFamily.State ρ fixedDegree) : State ρ := + (MachineExpanderFamily.initialState MachineExpanderFamily.baseDegree_positive H + (MachineExpanderFamily.caller state), (false, none)) + +def initialTapes (requested : Nat) : Tape → List Bool + | .inr .input => encodeWord requested + | _ => [] + +def retainedCeilingTapes (requested : Nat) : MachineCeilingPower.Tape → List Bool := + MachineCeilingPower.memory (encodeWord requested) [] + (encodeWord (PCP.PreprocessingLevels.paddedSize requested)) [] [] [] [] [] + +def handoffTapes (requested : Nat) : Tape → List Bool + | .inl tape => MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.initialTapes (PCP.PreprocessingLevels.boundedLevel requested) []) tape + | .inr tape => retainedCeilingTapes requested tape + +def finalTapes (H : SmallTable) (requested : Nat) : Tape → List Bool + | .inl tape => MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.familyTapes H (PCP.PreprocessingLevels.boundedLevel requested) []) tape + | .inr tape => retainedCeilingTapes requested tape + +@[simp] theorem initialTapes_input (requested : Nat) : + initialTapes requested (.inr .input) = encodeWord requested := rfl + +@[simp] theorem finalTapes_input (H : SmallTable) (requested : Nat) : + finalTapes H requested (.inr .input) = encodeWord requested := rfl + +@[simp] theorem finalTapes_power (H : SmallTable) (requested : Nat) : + finalTapes H requested (.inr .power) = + encodeWord (PCP.PreprocessingLevels.paddedSize requested) := rfl + +end IndependentSetsGames.Foundations.Complexity.MachinePaddedExpanderFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedOverlay.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedOverlay.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfe715dc2d140ec43a348feebae5c0835922235a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedOverlay.lean @@ -0,0 +1,513 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineVertexPadding +import OAI.Combinatorics.IndependentSets.Machines.PhasePolynomial + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddedOverlay + +open Turing MachineComposition MachineCloudPadding +open PCP + +abbrev BaseTable := PreprocessingStageMaps.BaseTable +abbrev baseDegree := Expanders.baseDegree +abbrev overlayDegree := PreprocessingRegularTables.internalDegree +abbrev Tape := MachineVertexPadding.Tape ⊕ (MachineExpanderFamily.Tape ⊕ MachineOverlayTable.Tape) +abbrev Alphabet (_ : Tape) := Bool +abbrev Label (d : Nat) := MachineVertexPadding.Label d ⊕ (MachineExpanderFamily.Label baseDegree ⊕ MachineOverlayTable.Label d overlayDegree) +abbrev State (d : Nat) := MachineVertexPadding.State (MachineExpanderFamily.State Unit baseDegree × MachineOverlayTable.State Unit d overlayDegree) + +theorem overlayDegree_positive : 0 < overlayDegree := + Nat.mul_pos MachineExpanderFamily.baseDegree_positive MachineExpanderFamily.baseDegree_positive + +def paddingTape (k : MachineVertexPadding.Tape) : Tape := .inl k + +def paddingView : Tape → Option MachineVertexPadding.Tape + | .inl k => some k + | .inr _ => none + +@[simp] theorem paddingView_left (k : MachineVertexPadding.Tape) : paddingView (paddingTape k) = some k := rfl + +theorem paddingView_right (j : Tape) (k : MachineVertexPadding.Tape) + (h : paddingView j = some k) : paddingTape k = j := by + cases j with + | inl j => cases Option.some.inj h; rfl + | inr j => simp [paddingView] at h + +def familyTape (k : MachineExpanderFamily.Tape) : Tape := + if k = .inr .remainingLevel then .inl .level else .inr (.inl k) + +def familyView : Tape → Option MachineExpanderFamily.Tape + | .inl .level => some (.inr .remainingLevel) + | .inr (.inl k) => if k = .inr .remainingLevel then none else some k + | _ => none + +@[simp] theorem familyView_left (k : MachineExpanderFamily.Tape) : familyView (familyTape k) = some k := by + by_cases h : k = .inr .remainingLevel + · subst k; rfl + · simp [familyTape, familyView, h] + +theorem familyView_right (j : Tape) (k : MachineExpanderFamily.Tape) + (h : familyView j = some k) : familyTape k = j := by + rcases j with j | j + · cases j <;> simp_all [familyView, familyTape] + · rcases j with j | j + · by_cases hj : j = .inr .remainingLevel <;> simp_all [familyView, familyTape] + · simp [familyView] at h + +def overlayTape (k : MachineOverlayTable.Tape) : Tape := + if k = MachineOverlayTable.graphArchive then .inl .output + else if k = MachineOverlayTable.expanderArchive then .inr (.inl MachineExpanderFamily.tableTape) + else .inr (.inr k) + +def overlayView : Tape → Option MachineOverlayTable.Tape + | .inl .output => some MachineOverlayTable.graphArchive + | .inr (.inl k) => if k = MachineExpanderFamily.tableTape then some MachineOverlayTable.expanderArchive else none + | .inr (.inr k) => + if k = MachineOverlayTable.graphArchive ∨ k = MachineOverlayTable.expanderArchive then none else some k + | _ => none + +@[simp] theorem overlayView_left (k : MachineOverlayTable.Tape) : overlayView (overlayTape k) = some k := by + by_cases hg : k = MachineOverlayTable.graphArchive + · subst k; rfl + · by_cases he : k = MachineOverlayTable.expanderArchive + · subst k; rfl + · simp [overlayTape, overlayView, hg, he] + +theorem overlayView_right (j : Tape) (k : MachineOverlayTable.Tape) + (h : overlayView j = some k) : overlayTape k = j := by + rcases j with j | j + · cases j <;> simp_all [overlayView, overlayTape, MachineOverlayTable.graphArchive] + · rcases j with j | j + · by_cases hj : j = MachineExpanderFamily.tableTape + · subst j + have hk : MachineOverlayTable.expanderArchive = k := by + simpa [overlayView] using h + subst k + rfl + · simp [overlayView, hj] at h + · by_cases hg : j = MachineOverlayTable.graphArchive + · simp [overlayView, hg] at h + · by_cases he : j = MachineOverlayTable.expanderArchive + · simp [overlayView, he] at h + · simp_all [overlayView, overlayTape] + +variable {d : Nat} + +def paddingLabel (l : MachineVertexPadding.Label d) : Label d := .inl l +def familyLabel (l : MachineExpanderFamily.Label baseDegree) : Label d := .inr (.inl l) +def overlayLabel (l : MachineOverlayTable.Label d overlayDegree) : Label d := .inr (.inr l) +def main : Label d := paddingLabel (.splitCode .copyFirst) +def familyEntry : Label d := familyLabel (.inr .initialize) +def overlayEntry : Label d := overlayLabel (.inl .copyFirst) + +def familyStates (d : Nat) : + (MachineExpanderFamily.State Unit baseDegree × ((MachineOverlayTable.State Unit d overlayDegree × Bool) × Option Bool)) ≃ + State d where + toFun s := (((s.1, s.2.1.1), s.2.1.2), s.2.2) + invFun s := (s.1.1.1, ((s.1.1.2, s.1.2), s.2)) + left_inv := by rintro ⟨f, ⟨⟨o, b⟩, r⟩⟩; rfl + right_inv := by rintro ⟨⟨⟨f, o⟩, b⟩, r⟩; rfl + +def overlayStates (d : Nat) : + (MachineOverlayTable.State Unit d overlayDegree × ((MachineExpanderFamily.State Unit baseDegree × Bool) × Option Bool)) ≃ + State d where + toFun s := (((s.2.1.1, s.1), s.2.1.2), s.2.2) + invFun s := (s.1.1.2, ((s.1.1.1, s.1.2), s.2)) + left_inv := by rintro ⟨o, ⟨⟨f, b⟩, r⟩⟩; rfl + right_inv := by rintro ⟨⟨⟨f, o⟩, b⟩, r⟩; rfl + +def familySource (H : BaseTable) (d : Nat) : MachineExpanderFamily.Label baseDegree → + TM2.Stmt MachineExpanderFamily.BoolAlphabet (MachineExpanderFamily.Label baseDegree) (State d) := + MachineStateEquiv.program (familyStates d) (MachineStateFrame.frameProgram + (MachineExpanderFamily.boolView MachineExpanderFamily.baseDegree_positive H MachineExpanderFamily.baseDegree_cloud_gt_one)) + +def overlaySource (d : Nat) (hd : 0 < d) : MachineOverlayTable.Label d overlayDegree → + TM2.Stmt (fun _ : MachineOverlayTable.Tape => Bool) (MachineOverlayTable.Label d overlayDegree) (State d) := + MachineStateEquiv.program (overlayStates d) (MachineStateFrame.frameProgram + (MachineOverlayTable.program d overlayDegree hd overlayDegree_positive)) + +def program (H : BaseTable) (d : Nat) (hd : 0 < d) : + Label d → TM2.Stmt Alphabet (Label d) (State d) + | .inl l => Placement.statement paddingTape paddingLabel (some familyEntry) (MachineVertexPadding.program d hd l) + | .inr (.inl l) => Placement.statement familyTape familyLabel (some overlayEntry) + (familySource H d l) + | .inr (.inr l) => Placement.statement overlayTape overlayLabel none (overlaySource d hd l) + +def clean (H : BaseTable) (d : Nat) (hd : 0 < d) : State d := + (((MachineExpanderFamily.initialState MachineExpanderFamily.baseDegree_positive H (), + MachineOverlayTable.clean d overlayDegree hd overlayDegree_positive ()), false), none) + +def memory (input padded level rotor count output : List Bool) : Tape → List Bool + | .inl k => MachineVertexPadding.memory input padded [] [] [] level [] [] k + | .inr (.inl (.inl (.inl .table))) => rotor + | .inr (.inl (.inr .currentSize)) => count + | .inr (.inl _) => [] + | .inr (.inr k) => if k = MachineOverlayTable.output then output else [] + +def padded {n d : Nat} (t : PortTables.Table n d) := + PreprocessingPaddingTables.pad t (PreprocessingLevels.le_paddedSize n) + +def rotor (H : BaseTable) (n : Nat) : List Bool := + encodeWords (ExpanderTableWords.rotationWords + (ExpanderTables.family H (PreprocessingLevels.boundedLevel n))) + +def initialTapes {n d : Nat} (t : PortTables.Table n d) : Tape → List Bool := + memory (PortTables.tableBits t) [] [] [] [] [] + +def paddedTapes {n d : Nat} (t : PortTables.Table n d) : Tape → List Bool := + memory (PortTables.tableBits t) (PortTables.tableBits (padded t)) + (encodeWord (PreprocessingLevels.boundedLevel n)) [] [] [] + +def familyTapes (H : BaseTable) {n d : Nat} (t : PortTables.Table n d) : Tape → List Bool := + memory (PortTables.tableBits t) (PortTables.tableBits (padded t)) + (encodeWord 0) (rotor H n) (encodeWord (PreprocessingLevels.paddedSize n)) [] + +def finalTapes (H : BaseTable) {n d : Nat} (t : PortTables.Table n d) : Tape → List Bool := + memory (PortTables.tableBits t) (PortTables.tableBits (padded t)) + (encodeWord 0) (rotor H n) (encodeWord (PreprocessingLevels.paddedSize n)) + (PortTables.tableBits (PreprocessingStageMaps.paddedOverlay H d ⟨n, t⟩).2) + +private def placeExecution {K Λ S : Type} [DecidableEq K] + (tape : K → Tape) (view : Tape → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (labels : Λ → Label d) (exit : Option (Label d)) (extra : Tape → List Bool) + (source : Λ → TM2.Stmt (fun _ : K => Bool) Λ S) + (target : Label d → TM2.Stmt Alphabet (Label d) S) + (atLabels : ∀ l, target (labels l) = Placement.statement tape labels exit (source l)) + {a b : TM2.Cfg (fun _ : K => Bool) Λ S} {budget : Nat} + (run : StateTransition.EvalsToInTime (TM2.step source) a (some b) budget) : + StateTransition.EvalsToInTime (TM2.step target) + (Placement.configuration view labels exit extra a) + (some (Placement.configuration view labels exit extra b)) budget := + liftExecutionInTime _ _ _ + (Placement.step_simulation tape view left right labels exit extra source target atLabels) run + +theorem padding_initial_memory (input : List Bool) : + Placement.tapes paddingView (MachineVertexPadding.memory input [] [] [] [] [] [] []) (fun _ => []) = + memory input [] [] [] [] [] := by + funext k + rcases k with k | k + · rfl + · rcases k with k | k + · rcases k with k | k + · rcases k with k | k <;> cases k <;> rfl + · cases k <;> rfl + · simp [Placement.tapes, paddingView, memory] + +theorem padding_final_memory (input output level : List Bool) : + Placement.tapes paddingView (MachineVertexPadding.memory input output [] [] [] level [] []) (fun _ => []) = + memory input output level [] [] [] := by + funext k + rcases k with k | k + · rfl + · rcases k with k | k + · rcases k with k | k + · rcases k with k | k <;> cases k <;> rfl + · cases k <;> rfl + · simp [Placement.tapes, paddingView, memory] + +noncomputable def paddingInTime (H : BaseTable) {n d : Nat} (hd : 0 < d) (t : PortTables.Table n d) : + StateTransition.EvalsToInTime (TM2.step (program H d hd)) + ⟨some main, clean H d hd, initialTapes t⟩ + (some ⟨some familyEntry, clean H d hd, paddedTapes t⟩) + ((MachineVertexPadding.timePolynomial d).eval (PortTables.tableBits t).length) := by + let ambient := (MachineExpanderFamily.initialState MachineExpanderFamily.baseDegree_positive H (), + MachineOverlayTable.clean d overlayDegree hd overlayDegree_positive ()) + have run := placeExecution paddingTape paddingView paddingView_left paddingView_right + paddingLabel (some familyEntry) (fun _ => []) (MachineVertexPadding.program d hd) (program H d hd) + (fun _ => rfl) (MachineVertexPadding.vertexPaddingInTime hd t ambient none) + simpa only [Placement.configuration, Placement.label, padding_initial_memory, + padding_final_memory, initialTapes, paddedTapes, padded, main, clean, ambient] using run + +theorem family_initial_memory (input output : List Bool) (level : Nat) : + Placement.tapes familyView + (MachineExpanderFamily.toBoolTapes (MachineExpanderFamily.initialTapes level [])) + (memory input output (encodeWord level) [] [] []) = + memory input output (encodeWord level) [] [] [] := by + funext k + rcases k with k | k + · cases k <;> simp [Placement.tapes, familyView, memory, + MachineVertexPadding.memory, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.initialTapes, + MachineEmbedding.tapes] + · rcases k with k | k + · rcases k with k | k + · rcases k with k | k <;> cases k <;> + simp [Placement.tapes, familyView, memory, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.initialTapes, + MachineExpanderFamily.tableFrame, MachineEmbedding.tapes] + · cases k <;> + simp [Placement.tapes, familyView, memory, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.initialTapes, + MachineEmbedding.tapes] + · rfl + +theorem family_final_memory (H : BaseTable) (input output : List Bool) (level : Nat) : + Placement.tapes familyView + (MachineExpanderFamily.toBoolTapes (MachineExpanderFamily.familyTapes H level [])) + (memory input output (encodeWord level) [] [] []) = + memory input output (encodeWord 0) + (encodeWords (ExpanderTableWords.rotationWords (ExpanderTables.family H level))) + (encodeWord (ExpanderTables.vertexCount overlayDegree level)) [] := by + funext k + rcases k with k | k + · cases k <;> simp [Placement.tapes, familyView, memory, + MachineVertexPadding.memory, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.familyTapes, + MachineExpanderFamily.boundaryTapes, MachineExpanderFamily.extraFrame, + MachineEmbedding.tapes] + · rcases k with k | k + · rcases k with k | k + · rcases k with k | k <;> cases k <;> + simp [Placement.tapes, familyView, memory, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.familyTapes, + MachineExpanderFamily.boundaryTapes, MachineExpanderFamily.tableFrame, + MachineEmbedding.tapes] + · cases k <;> + simp [Placement.tapes, familyView, memory, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.familyTapes, + MachineExpanderFamily.boundaryTapes, MachineExpanderFamily.extraFrame, + MachineEmbedding.tapes, overlayDegree, PreprocessingRegularTables.internalDegree, + ExpanderRowControl.degree] + · simp [Placement.tapes, familyView, memory] + +noncomputable def familyInTime (H : BaseTable) {n d : Nat} (hd : 0 < d) + (t : PortTables.Table n d) : + StateTransition.EvalsToInTime (TM2.step (program H d hd)) + ⟨some familyEntry, clean H d hd, paddedTapes t⟩ + (some ⟨some overlayEntry, clean H d hd, familyTapes H t⟩) + (MachineExpanderFamilyBounds.inputCoefficient * (n + 1)^5) := by + let f := MachineExpanderFamily.initialState MachineExpanderFamily.baseDegree_positive H () + let o := MachineOverlayTable.clean d overlayDegree hd overlayDegree_positive () + have caller : MachineExpanderFamily.caller f = () := Subsingleton.elim _ _ + have castRun := MachineAlphabetTransport.successfulExecutionInTime + MachineExpanderFamily.alphabet_eq + (MachineExpanderFamily.program MachineExpanderFamily.baseDegree_positive H + MachineExpanderFamily.baseDegree_cloud_gt_one) + (MachineExpanderFamily.paddedFamilyInTime H n f []) + have boolRun : StateTransition.EvalsToInTime + (TM2.step (MachineExpanderFamily.boolView MachineExpanderFamily.baseDegree_positive H + MachineExpanderFamily.baseDegree_cloud_gt_one)) + ⟨some (.inr .initialize), f, MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.initialTapes (PreprocessingLevels.boundedLevel n) [])⟩ + (some ⟨none, f, MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.familyTapes H (PreprocessingLevels.boundedLevel n) [])⟩) + (MachineExpanderFamilyBounds.inputCoefficient * (n + 1)^5) := by + simpa only [MachineExpanderFamily.boolView, MachineExpanderFamily.configuration_toBool, + caller] using castRun + have framed := MachineStateFrame.frameExecution + (MachineExpanderFamily.boolView MachineExpanderFamily.baseDegree_positive H + MachineExpanderFamily.baseDegree_cloud_gt_one) ((o, false), (none : Option Bool)) boolRun + have transported := MachineStateEquiv.execution (familyStates d) + (MachineStateFrame.frameProgram + (MachineExpanderFamily.boolView MachineExpanderFamily.baseDegree_positive H + MachineExpanderFamily.baseDegree_cloud_gt_one)) framed + have sourceRun : StateTransition.EvalsToInTime (TM2.step (familySource H d)) + ⟨some (.inr .initialize), clean H d hd, MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.initialTapes (PreprocessingLevels.boundedLevel n) [])⟩ + (some ⟨none, clean H d hd, MachineExpanderFamily.toBoolTapes + (MachineExpanderFamily.familyTapes H (PreprocessingLevels.boundedLevel n) [])⟩) + (MachineExpanderFamilyBounds.inputCoefficient * (n + 1)^5) := by + simpa only [familySource, MachineStateEquiv.configuration, + MachineStateFrame.frameConfiguration, Option.map_some, familyStates, + Equiv.coe_fn_mk, clean, f, o] + using transported + have run := placeExecution familyTape familyView familyView_left familyView_right + familyLabel (some overlayEntry) (paddedTapes t) (familySource H d) (program H d hd) + (fun _ => rfl) sourceRun + have finishRaw := family_final_memory H (PortTables.tableBits t) + (PortTables.tableBits (padded t)) (PreprocessingLevels.boundedLevel n) + have hsize : ExpanderTables.vertexCount overlayDegree (PreprocessingLevels.boundedLevel n) = + PreprocessingLevels.paddedSize n := PreprocessingLevels.table_vertexCount_eq_paddedSize n + have count : memory (PortTables.tableBits t) (PortTables.tableBits (padded t)) + (encodeWord 0) (rotor H n) + (encodeWord (ExpanderTables.vertexCount overlayDegree (PreprocessingLevels.boundedLevel n))) [] = + familyTapes H t := + congrArg (fun size => memory (PortTables.tableBits t) (PortTables.tableBits (padded t)) + (encodeWord 0) (rotor H n) (encodeWord size) []) hsize + have finish := finishRaw.trans count + simpa only [Placement.configuration, Placement.label, paddedTapes, + family_initial_memory, finish, familyEntry] using run + +theorem rotationWords_resize {n m q : Nat} (h : n = m) (H : ExpanderTables.Table n q) : + ExpanderTableWords.rotationWords (PreprocessingRegularTables.resizeTable h H) = + ExpanderTableWords.rotationWords H := by + cases h + rfl + +theorem rotor_familyAt (H : BaseTable) (n : Nat) : + MachineOverlayTable.rawExpander (PreprocessingStageMaps.familyAt H n) = rotor H n := by + unfold MachineOverlayTable.rawExpander PreprocessingStageMaps.familyAt rotor + exact congrArg encodeWords (rotationWords_resize _ _) + +theorem overlay_memory (input graph raw count output : List Bool) : + Placement.tapes overlayView + (MachineOverlayTable.memory graph raw [] [] [] [] [] [] [] output) + (memory input graph (encodeWord 0) raw count []) = + memory input graph (encodeWord 0) raw count output := by + funext k + rcases k with k | k + · cases k <;> simp [Placement.tapes, overlayView, memory, MachineVertexPadding.memory, + MachineOverlayTable.memory, MachineOverlayTable.graphArchive] + · rcases k with k | k + · rcases k with k | k + · rcases k with k | k <;> cases k <;> + simp [Placement.tapes, overlayView, memory, MachineExpanderFamily.tableTape, + MachineOverlayTable.memory, MachineOverlayTable.expanderArchive] + · cases k <;> + simp [Placement.tapes, overlayView, memory, MachineExpanderFamily.tableTape] + · rcases k with k | k <;> fin_cases k <;> + simp [Placement.tapes, overlayView, memory, MachineOverlayTable.memory, + MachineOverlayTable.graphArchive, MachineOverlayTable.expanderArchive, + MachineOverlayTable.output] + +noncomputable def overlayInTime (H : BaseTable) {n d : Nat} (hd : 0 < d) + (t : PortTables.Table n d) : + StateTransition.EvalsToInTime (TM2.step (program H d hd)) + ⟨some overlayEntry, clean H d hd, familyTapes H t⟩ + (some ⟨none, clean H d hd, finalTapes H t⟩) + ((MachineOverlayTable.timePolynomial d overlayDegree).eval + ((PortTables.tableBits (padded t)).length + (rotor H n).length)) := by + let f := MachineExpanderFamily.initialState MachineExpanderFamily.baseDegree_positive H () + have original := MachineOverlayTable.tableInTime d overlayDegree hd overlayDegree_positive + (padded t) (PreprocessingStageMaps.familyAt H n) () + have framed := MachineStateFrame.frameExecution + (MachineOverlayTable.program d overlayDegree hd overlayDegree_positive) + ((f, false), (none : Option Bool)) + original + have transported := MachineStateEquiv.execution (overlayStates d) + (MachineStateFrame.frameProgram + (MachineOverlayTable.program d overlayDegree hd overlayDegree_positive)) framed + have sourceRun : StateTransition.EvalsToInTime (TM2.step (overlaySource d hd)) + ⟨some (.inl .copyFirst), clean H d hd, + MachineOverlayTable.initialTapes (PortTables.tableBits (padded t)) (rotor H n)⟩ + (some ⟨none, clean H d hd, + MachineOverlayTable.memory (PortTables.tableBits (padded t)) (rotor H n) + [] [] [] [] [] [] [] + (PortTables.tableBits (PreprocessingStageMaps.paddedOverlay H d ⟨n, t⟩).2)⟩) + ((MachineOverlayTable.timePolynomial d overlayDegree).eval + ((PortTables.tableBits (padded t)).length + (rotor H n).length)) := by + simpa only [overlaySource, MachineStateEquiv.configuration, + MachineStateFrame.frameConfiguration, Option.map_some, overlayStates, Equiv.coe_fn_mk, clean, f, + rotor_familyAt, PreprocessingStageMaps.paddedOverlay, PreprocessingStageMaps.padding, + padded] using transported + have run := placeExecution overlayTape overlayView overlayView_left overlayView_right + overlayLabel none (familyTapes H t) (overlaySource d hd) (program H d hd) + (fun _ => rfl) sourceRun + simpa only [Placement.configuration, Placement.label, familyTapes, finalTapes, + MachineOverlayTable.initialTapes_memory, overlay_memory, overlayEntry] using run + +noncomputable def sizePolynomial : Polynomial Nat := + Polynomial.C ExpanderFamily.growth * (Polynomial.X + 1) + +noncomputable def archivePolynomial (d : Nat) : Polynomial Nat := + let s := sizePolynomial + s + s * Polynomial.C d + 2 + + (s * Polynomial.C d) * (s + s * Polynomial.C d + 8192) + + (s * Polynomial.C overlayDegree) * (s * Polynomial.C overlayDegree + 1) + +theorem archive_length_le (H : BaseTable) {n d : Nat} (t : PortTables.Table n d) : + (PortTables.tableBits (padded t)).length + (rotor H n).length ≤ + (archivePolynomial d).eval (PortTables.tableBits t).length := by + let m := PreprocessingLevels.paddedSize n + let s := ExpanderFamily.growth * ((PortTables.tableBits t).length + 1) + have hm : m ≤ s := MachineVertexPadding.power_length_bound t + have hmd : m*d ≤ s*d := Nat.mul_le_mul_right d hm + have hmq : m*overlayDegree ≤ s*overlayDegree := Nat.mul_le_mul_right overlayDegree hm + have hg := GraphTables.tableBits_length_le (PortTables.graphTable (padded t)) + change (PortTables.tableBits (padded t)).length ≤ + m + m*d + 2 + m*d*(m + m*d + 8192) at hg + have hg' := hg.trans (Nat.add_le_add + (Nat.add_le_add_right (Nat.add_le_add hm hmd) 2) + (Nat.mul_le_mul hmd (Nat.add_le_add_right (Nat.add_le_add hm hmd) 8192))) + have hr := ExpanderTableWords.encode_rotationWords_length_le + (PreprocessingStageMaps.familyAt H n) + change (MachineOverlayTable.rawExpander (PreprocessingStageMaps.familyAt H n)).length ≤ + (m*overlayDegree)*(m*overlayDegree+1) at hr + rw [rotor_familyAt] at hr + have hr' := hr.trans (Nat.mul_le_mul hmq (Nat.add_le_add_right hmq 1)) + have h := Nat.add_le_add hg' hr' + simpa only [archivePolynomial, sizePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_one, Polynomial.eval_ofNat, + s] using h + +noncomputable def familyPolynomial : Polynomial Nat := + Polynomial.C MachineExpanderFamilyBounds.inputCoefficient * (Polynomial.X + 1)^5 + +noncomputable def timePolynomial (d : Nat) : Polynomial Nat := + MachineVertexPadding.timePolynomial d + familyPolynomial + + (MachineOverlayTable.timePolynomial d overlayDegree).comp (archivePolynomial d) + +noncomputable def execution (H : BaseTable) {n d : Nat} (hd : 0 < d) + (t : PortTables.Table n d) : + StateTransition.EvalsToInTime (TM2.step (program H d hd)) + ⟨some main, clean H d hd, initialTapes t⟩ + (some ⟨none, clean H d hd, finalTapes H t⟩) + ((timePolynomial d).eval (PortTables.tableBits t).length) := by + let first := paddingInTime H hd t + let second := familyInTime H hd t + let third := overlayInTime H hd t + let firstTwo := StateTransition.EvalsToInTime.trans (TM2.step (program H d hd)) + _ _ _ _ _ first second + let all := StateTransition.EvalsToInTime.trans (TM2.step (program H d hd)) + _ _ _ _ _ firstTwo third + refine { toEvalsTo := all.toEvalsTo, steps_le_m := all.steps_le_m.trans ?_ } + have hn := PortTables.vertices_le_tableBits_length t + have hf := Nat.mul_le_mul_left MachineExpanderFamilyBounds.inputCoefficient + (Nat.pow_le_pow_left (Nat.add_le_add_right hn 1) 5) + have ho := natPolynomial_eval_mono (MachineOverlayTable.timePolynomial d overlayDegree) + (archive_length_le H t) + have h := Nat.add_le_add + (Nat.add_le_add (Nat.le_refl ((MachineVertexPadding.timePolynomial d).eval + (PortTables.tableBits t).length)) hf) ho + simpa only [timePolynomial, familyPolynomial, Polynomial.eval_add, Polynomial.eval_comp, + Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X, + Polynomial.eval_one, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using h + +def machine (H : BaseTable) (d : Nat) (hd : 0 < d) : FinTM2 where + K := Tape + k₀ := .inl .original + k₁ := .inr (.inr MachineOverlayTable.output) + Γ := Alphabet + Λ := Label d + main := main + σ := State d + initialState := clean H d hd + m := program H d hd + +theorem alphabet_finite (H : BaseTable) (d : Nat) (hd : 0 < d) : + ∀ k, Finite ((machine H d hd).Γ k) := by + intro k + change Finite Bool + infer_instance + +theorem initial_configuration (H : BaseTable) {n d : Nat} (hd : 0 < d) + (t : PortTables.Table n d) : + initList (machine H d hd) (PortTables.tableBits t) = + ⟨some main, clean H d hd, initialTapes t⟩ := by + have ht : (initList (machine H d hd) (PortTables.tableBits t)).stk = initialTapes t := by + funext k + rcases k with k | k + · cases k <;> rfl + · rcases k with k | k + · rcases k with k | k + · rcases k with k | k <;> cases k <;> + simp [initList, machine, initialTapes, memory] + · cases k <;> simp [initList, machine, initialTapes, memory] + · simp [initList, machine, initialTapes, memory] + exact congrArg (TM2.Cfg.mk _ _) ht + +theorem final_output (H : BaseTable) {n d : Nat} (hd : 0 < d) + (t : PortTables.Table n d) : + finalTapes H t (machine H d hd).k₁ = + PortTables.inputBits (PreprocessingStageMaps.paddedOverlay H d ⟨n, t⟩) := by + simp [finalTapes, machine, memory, PortTables.inputBits] + +theorem original_preserved (H : BaseTable) {n d : Nat} (t : PortTables.Table n d) : + finalTapes H t (.inl .original) = PortTables.tableBits t := rfl + +end IndependentSetsGames.Foundations.Complexity.MachinePaddedOverlay + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedOverlayRuntime.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedOverlayRuntime.lean new file mode 100644 index 0000000000000000000000000000000000000000..a619fcf82c8287526d91feaa33c69cdbd29a2111 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddedOverlayRuntime.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddedOverlay + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddedOverlayRuntime + +open Turing +open PCP +open MachinePaddedOverlay (BaseTable Tape Label State) + +def rawProgram (H : BaseTable) (d : Nat) (hd : 0 < d) : + MachineCanonicalOutput.Program Tape (Label d) (State d) where + input := .inl .original + output := .inr (.inr MachineOverlayTable.output) + main := MachinePaddedOverlay.main + initial := MachinePaddedOverlay.clean H d hd + code := MachinePaddedOverlay.program H d hd + +theorem sourceMachine_eq (H : BaseTable) (d : Nat) (hd : 0 < d) : + MachineCanonicalOutput.sourceMachine (rawProgram H d hd) = + MachinePaddedOverlay.machine H d hd := rfl + +noncomputable def cleanupTapes : List Tape := + (Finset.univ.erase (.inr (.inr MachineOverlayTable.output) : Tape)).toList + +theorem cleanup_complete (H : BaseTable) (d : Nat) (hd : 0 < d) (k : Tape) : + k ∈ cleanupTapes ↔ k ≠ (rawProgram H d hd).output := by + simp [cleanupTapes, rawProgram] + +theorem initial_configuration (H : BaseTable) (d : Nat) (hd : 0 < d) + (a : PortTables.Input d) : + initList (MachineCanonicalOutput.sourceMachine (rawProgram H d hd)) + (PortTables.inputBits a) = + ⟨some MachinePaddedOverlay.main, MachinePaddedOverlay.clean H d hd, + MachinePaddedOverlay.initialTapes a.2⟩ := by + change initList (MachinePaddedOverlay.machine H d hd) (PortTables.tableBits a.2) = _ + exact MachinePaddedOverlay.initial_configuration H hd a.2 + +noncomputable def terminalRun (H : BaseTable) (d : Nat) (hd : 0 < d) + (a : PortTables.Input d) : + MachineCanonicalOutput.TerminalRun (rawProgram H d hd) (PortTables.inputBits a) + (PortTables.inputBits (PreprocessingStageMaps.paddedOverlay H d a)) + ((MachinePaddedOverlay.timePolynomial d).eval (PortTables.inputBits a).length) where + state := MachinePaddedOverlay.clean H d hd + tapes := MachinePaddedOverlay.finalTapes H a.2 + execution := by + rw [initial_configuration] + exact MachinePaddedOverlay.execution H hd a.2 + output_eq := MachinePaddedOverlay.final_output H hd a.2 + +noncomputable def computableInPolyTime (H : BaseTable) (d : Nat) (hd : 0 < d) : + TM2ComputableInPolyTime (PortTables.inputBits (ports := d)) + (PortTables.inputBits (ports := d + MachinePaddedOverlay.overlayDegree)) + (PreprocessingStageMaps.paddedOverlay H d) := + MachineCanonicalOutput.computableInPolyTime (rawProgram H d hd) cleanupTapes + (cleanup_complete H d hd) PortTables.inputBits PortTables.inputBits + (PreprocessingStageMaps.paddedOverlay H d) (MachinePaddedOverlay.timePolynomial d) + (terminalRun H d hd) + +theorem finite_alphabet (H : BaseTable) (d : Nat) (hd : 0 < d) : + ∀ k, Finite ((computableInPolyTime H d hd).tm.Γ k) := + MachineCanonicalOutput.computableInPolyTime_finite_alphabet (rawProgram H d hd) cleanupTapes + (cleanup_complete H d hd) PortTables.inputBits PortTables.inputBits + (PreprocessingStageMaps.paddedOverlay H d) (MachinePaddedOverlay.timePolynomial d) + (terminalRun H d hd) + +end IndependentSetsGames.Foundations.Complexity.MachinePaddedOverlayRuntime +namespace IndependentSetsGames.Foundations.Complexity.MachineLazyCodec +open PCP.GraphTables PCP.PreprocessingLazyWords + +theorem rowsBits_ofFn (v e count : Nat) : + MachineDummyRows.rowsBits v e count = + (List.ofFn fun p : Fin count => MachineDummyRows.rowBits v (e + p.val)).flatten := by + induction count generalizing e with + | zero => rfl + | succ count ih => + rw [MachineDummyRows.rowsBits, List.ofFn_succ, List.flatten_cons] + simp only [Fin.val_zero, Nat.add_zero] + apply congrArg (MachineDummyRows.rowBits v e ++ ·) + rw [ih] + apply congrArg List.flatten + congr 1 + funext p + simp only [Fin.val_succ] + congr 1 + omega + +theorem encodeWords_flatMap {α : Type*} (items : List α) (words : α → List Nat) : + encodeWords (items.flatMap words) = items.flatMap (fun x => encodeWords (words x)) := by + induction items with + | nil => rfl + | cons item items ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem rowBits_stay {n d : Nat} (v : Fin n) (p : Fin d) : + MachineDummyRows.rowBits v.val (2 * d * v.val + p.val) = + encodeWords (rowWords (stayRow d v p)) := by + have h := MachineDummyRows.rowBits_eq_graph_row v (stayRow d v p).reverseIndex + rw [stayRow_reverse_val] at h + exact h + +theorem rowsBits_stay {n d : Nat} (v : Fin n) : + MachineDummyRows.rowsBits v.val (2 * d * v.val) d = + encodeWords ((List.ofFn (stayRow d v)).flatMap rowWords) := by + rw [rowsBits_ofFn, encodeWords_flatMap] + simp only [List.flatMap_def, List.map_ofFn] + apply congrArg List.flatten + congr 1 + funext p + exact rowBits_stay v p + +end IndependentSetsGames.Foundations.Complexity.MachineLazyCodec + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingBounds.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ad447d02c91eea476fcfc6f77e31b8e512ca5bd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingBounds.lean @@ -0,0 +1,134 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddingRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddingBounds + +theorem rowsBits_length_le (v e count : Nat) : + (MachineDummyRows.rowsBits v e count).length ≤ count * (v + e + count + 8194) := by + induction count generalizing e with + | zero => simp [MachineDummyRows.rowsBits] + | succ count ih => + have hi := ih (e + 1) + have hb : v + (e + 1) + count + 8194 = v + e + (count + 1) + 8194 := by omega + rw [hb] at hi + have hr : v + e + 8194 ≤ v + e + (count + 1) + 8194 := by omega + simp only [MachineDummyRows.rowsBits, List.length_append, MachineDummyRows.rowBits_length] + calc + _ ≤ (v + e + (count + 1) + 8194) + + count * (v + e + (count + 1) + 8194) := Nat.add_le_add hr hi + _ = _ := by rw [Nat.add_mul, Nat.one_mul]; omega + +def rowBound (d v e count : Nat) : Nat := v + count + e + (count + 1) * d + 8194 + +theorem rowBound_next (d v e count : Nat) : + rowBound d (v + 1) (e + d) count = rowBound d v e (count + 1) := by + simp only [rowBound, Nat.add_mul, Nat.one_mul] + omega + +theorem blockRow_le_rowBound (d v e count : Nat) : + v + e + d + 8194 ≤ rowBound d v e (count + 1) := by + simp only [rowBound, Nat.add_mul, Nat.one_mul] + omega + +theorem steps_le_bound (d v e : Nat) (output : List Bool) (count : Nat) : + MachinePaddingRows.steps d v e output count ≤ + count * (d * (4 * rowBound d v e count + + 2 * (output.length + count * d * rowBound d v e count) + 10) + 2) + 1 := by + induction count generalizing v e output with + | zero => simp [MachinePaddingRows.steps] + | succ count ih => + let B := rowBound d v e (count + 1) + let C := d * (4 * B + 2 * (output.length + (count + 1) * d * B) + 10) + 2 + have hb : rowBound d (v + 1) (e + d) count = B := rowBound_next d v e count + have hr : v + e + d + 8194 ≤ B := blockRow_le_rowBound d v e count + have hlen : (MachineDummyRows.rowsBits v e d).length ≤ d * B := + (rowsBits_length_le v e d).trans (Nat.mul_le_mul_left d hr) + have hout : (output ++ MachineDummyRows.rowsBits v e d).length + count * d * B ≤ + output.length + (count + 1) * d * B := by + rw [List.length_append] + calc + _ ≤ output.length + d * B + count * d * B := + Nat.add_le_add_right (Nat.add_le_add_left hlen output.length) _ + _ = _ := by simp only [Nat.add_mul, Nat.one_mul]; omega + have hi := ih (v + 1) (e + d) (output ++ MachineDummyRows.rowsBits v e d) + rw [hb] at hi + have hconstant : + d * (4 * B + 2 * ((output ++ MachineDummyRows.rowsBits v e d).length + + count * d * B) + 10) + 2 ≤ C := by + exact Nat.add_le_add_right (Nat.mul_le_mul_left d + (Nat.add_le_add_right (Nat.add_le_add_left (Nat.mul_le_mul_left 2 hout) (4 * B)) 10)) 2 + have hremaining := hi.trans + (Nat.add_le_add_right (Nat.mul_le_mul_left count hconstant) 1) + have hcount : d * B ≤ (count + 1) * d * B := by + simpa only [Nat.one_mul, Nat.mul_assoc] using + Nat.mul_le_mul_right (d * B) (Nat.succ_le_succ (Nat.zero_le count)) + have hbodyOutput : output.length + d * (v + e + d + 8194) ≤ + output.length + (count + 1) * d * B := + Nat.add_le_add_left ((Nat.mul_le_mul_left d hr).trans hcount) output.length + have hbodyInner : 4 * (v + e + d + 8194) + + 2 * (output.length + d * (v + e + d + 8194)) + 10 ≤ + 4 * B + 2 * (output.length + (count + 1) * d * B) + 10 := by + exact Nat.add_le_add_right (Nat.add_le_add (Nat.mul_le_mul_left 4 hr) + (Nat.mul_le_mul_left 2 hbodyOutput)) 10 + have hbody : MachineDummyRows.steps v e output d + 2 ≤ C := + Nat.add_le_add_right ((MachineDummyRows.steps_le_bound v e output d).trans + (Nat.mul_le_mul_left d hbodyInner)) 2 + change (MachineDummyRows.steps v e output d + 2) + + MachinePaddingRows.steps d (v + 1) (e + d) + (output ++ MachineDummyRows.rowsBits v e d) count ≤ (count + 1) * C + 1 + calc + _ ≤ C + (count * C + 1) := Nat.add_le_add hbody hremaining + _ = _ := by rw [Nat.add_mul, Nat.one_mul]; omega + +def inputSize (v e count : Nat) (output : List Bool) : Nat := + (encodeWord v).length + (encodeWord e).length + (encodeWord count).length + output.length + +def rowCap (d size : Nat) : Nat := size + (size + 1) * d + 8194 + +theorem rowBound_le_cap (d v e count : Nat) (output : List Bool) : + rowBound d v e count ≤ rowCap d (inputSize v e count output) := by + have hbase : v + e + count ≤ inputSize v e count output := by + simp only [inputSize, encodeWord_length] + omega + have hcount : count ≤ inputSize v e count output := by + simp only [inputSize, encodeWord_length] + omega + have hmul := Nat.mul_le_mul_right d (Nat.succ_le_succ hcount) + have h := Nat.add_le_add_right (Nat.add_le_add hbase hmul) 8194 + simpa only [rowBound, rowCap, Nat.succ_eq_add_one, Nat.add_assoc, + Nat.add_comm, Nat.add_left_comm] using h + +noncomputable def rowPolynomial (d : Nat) : Polynomial Nat := + Polynomial.X + (Polynomial.X + 1) * Polynomial.C d + Polynomial.C 8194 + +noncomputable def timePolynomial (d : Nat) : Polynomial Nat := + Polynomial.X * (Polynomial.C d * + (Polynomial.C 4 * rowPolynomial d + + Polynomial.C 2 * (Polynomial.X + Polynomial.X * Polynomial.C d * rowPolynomial d) + + Polynomial.C 10) + Polynomial.C 2) + 1 + +theorem timePolynomial_bounds (d v e count : Nat) (output : List Bool) : + MachinePaddingRows.steps d v e output count ≤ + (timePolynomial d).eval (inputSize v e count output) := by + have hc : count ≤ inputSize v e count output := by + simp only [inputSize, encodeWord_length] + omega + have ho : output.length ≤ inputSize v e count output := by + simp only [inputSize, encodeWord_length] + omega + have hb := rowBound_le_cap d v e count output + have hp := Nat.mul_le_mul (Nat.mul_le_mul_right d hc) hb + have hout := Nat.add_le_add ho hp + have hinner := Nat.add_le_add_right + (Nat.add_le_add (Nat.mul_le_mul_left 4 hb) (Nat.mul_le_mul_left 2 hout)) 10 + have hbody := Nat.add_le_add_right (Nat.mul_le_mul_left d hinner) 2 + have h := (steps_le_bound d v e output count).trans + (Nat.add_le_add_right (Nat.mul_le_mul hc hbody) 1) + simpa only [timePolynomial, rowPolynomial, rowCap, Polynomial.eval_add, + Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_one] using h + +end IndependentSetsGames.Foundations.Complexity.MachinePaddingBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingCertificate.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c207025dbd9bd0814721ad3eb315fa48b5f9218 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingCertificate.lean @@ -0,0 +1,64 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingPaddingWords +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddingBounds + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddingCertificate + +open MachinePaddingRows + +noncomputable def timePolynomial (d : Nat) : Polynomial Nat := + MachinePaddingBounds.timePolynomial d + 1 + +def execution (d : Nat) (hd : 0 < d) (count v e : Nat) (output : List Bool) : + StateTransition.EvalsToInTime (machine d hd).step + ⟨some (.inr .initialize), (((), none), ()), initialTapes v e count output⟩ + (some (cfg d none (v + count) (e + count * d) 0 + (output ++ paddingBits d v e count))) + ((timePolynomial d).eval (MachinePaddingBounds.inputSize v e count output)) where + steps := steps d v e output count + 1 + evals_in_steps := by + convert paddingTrace d hd count v e output using 1 + rfl + steps_le_m := by + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_one] + exact Nat.add_le_add_right + (MachinePaddingBounds.timePolynomial_bounds d v e count output) 1 + +end IndependentSetsGames.Foundations.Complexity.MachinePaddingCertificate +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddingTable + +open PCP MachinePaddingRows + +def initialOutput {n d m : Nat} (table : PortTables.Table n d) : List Bool := + encodeWords [m, m * d] ++ PreprocessingPaddingWords.rowsBits table + +def execution {n d m : Nat} (table : PortTables.Table n d) (h : n ≤ m) (hd : 0 < d) : + StateTransition.EvalsToInTime (machine d hd).step + ⟨some (.inr .initialize), (((), none), ()), + initialTapes n (n * d) (m - n) (initialOutput (m := m) table)⟩ + (some (cfg d none m (m * d) 0 + (PortTables.tableBits (PreprocessingPaddingTables.pad table h)))) + ((MachinePaddingCertificate.timePolynomial d).eval + (MachinePaddingBounds.inputSize n (n * d) (m - n) (initialOutput (m := m) table))) where + steps := steps d n (n * d) (initialOutput (m := m) table) (m - n) + 1 + evals_in_steps := by + have run := paddingTrace d hd (m - n) n (n * d) (initialOutput (m := m) table) + have hv : n + (m - n) = m := Nat.add_sub_of_le h + have he : n * d + (m - n) * d = m * d := by rw [← Nat.add_mul, hv] + have hout : initialOutput (m := m) table ++ paddingBits d n (n * d) (m - n) = + PortTables.tableBits (PreprocessingPaddingTables.pad table h) := by + rw [PreprocessingPaddingWords.tableBits_pad] + rfl + rw [hv, he, hout] at run + convert run using 1 + rfl + steps_le_m := by + simp only [MachinePaddingCertificate.timePolynomial, Polynomial.eval_add, Polynomial.eval_one] + exact Nat.add_le_add_right + (MachinePaddingBounds.timePolynomial_bounds d n (n * d) (m - n) (initialOutput (m := m) table)) 1 + +end IndependentSetsGames.Foundations.Complexity.MachinePaddingTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingRows.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8137723e5c68f8b2288da29f417d6e51cad3273 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePaddingRows.lean @@ -0,0 +1,181 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDummyRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePaddingRows + +open Turing MachineComposition + +inductive Control | initialize | guard | bump + deriving DecidableEq + +instance : Fintype Control where + elems := {.initialize, .guard, .bump} + complete control := by cases control <;> simp + +abbrev Tape := Fin 6 ⊕ Unit +abbrev Label (d : Nat) := MachineDummyRows.Label d ⊕ Control +abbrev Alphabet : Tape → Type := MachineEmbedding.Alphabet + (fun _ : Fin 6 => Bool) (fun _ : Unit => Bool) +abbrev State := (Unit × Option Bool) × Unit + +def bodyEntry (d : Nat) (hd : 0 < d) : Label d := + .inl (MachineDummyRows.rowLabel ⟨0, hd⟩ .relationRead) + +def extra (d : Nat) (hd : 0 < d) : Control → TM2.Stmt Alphabet (Label d) State + | .initialize => Reduction.MachineSubstitution.pushWord (.inl 2) + MachineDummyRows.trueBits.reverse + (.load (fun _ => (((), none), ())) (.goto (fun _ => .inr .guard))) + | .guard => .pop (.inr ()) (fun _ bit => (((), bit), ())) + (.branch (fun s => s.1.2.getD false) + (.load (fun _ => (((), none), ())) (.goto (fun _ => bodyEntry d hd))) + (.push (.inr ()) (fun _ => false) + (.load (fun _ => (((), none), ())) .halt))) + | .bump => .push (.inl 0) (fun _ => true) (.goto (fun _ => .inr .guard)) + +def program (d : Nat) (hd : 0 < d) : Label d → TM2.Stmt Alphabet (Label d) State := + MachineEmbedding.program (some (.inr .bump)) (MachineDummyRows.program d) (extra d hd) + +def tapes (v e fuel : Nat) (output : List Bool) : ∀ k, List (Alphabet k) := + MachineEmbedding.tapes (MachineDummyRows.fieldTapes v e output) + (fun _ : Unit => encodeWord fuel) + +def cfg (d : Nat) (label : Option (Label d)) (v e fuel : Nat) + (output : List Bool) : TM2.Cfg Alphabet (Label d) State := + ⟨label, (((), none), ()), tapes v e fuel output⟩ + +theorem bodyTrace (d : Nat) (hd : 0 < d) (v e fuel : Nat) (output : List Bool) : + (advance (TM2.step (program d hd)))^[MachineDummyRows.steps v e output d] + (some (cfg d (some (bodyEntry d hd)) v e fuel output)) = + some (cfg d (some (.inr .bump)) v (e + d) fuel + (output ++ MachineDummyRows.rowsBits v e d)) := by + have run := MachineDummyRows.suffixTrace d ⟨0, hd⟩ (by simp) + v e output () none + have lifted := liftSuccessfulTrace + (TM2.step (MachineDummyRows.program d)) (TM2.step (program d hd)) + (MachineEmbedding.configuration (some (.inr .bump)) () + (fun _ : Unit => encodeWord fuel)) + (by + intro a b h + exact MachineEmbedding.step_simulation (some (.inr Control.bump)) () + (fun _ : Unit => encodeWord fuel) (MachineDummyRows.program d) (extra d hd) a b h) + (MachineDummyRows.steps v e output d) _ _ run + exact lifted + +theorem guard_succ (d : Nat) (hd : 0 < d) (v e fuel : Nat) (output : List Bool) : + TM2.step (program d hd) (cfg d (some (.inr .guard)) v e (fuel + 1) output) = + some (cfg d (some (bodyEntry d hd)) v e fuel output) := by + change some (TM2.stepAux (extra d hd .guard) _ _) = _ + simp only [extra, TM2.stepAux, tapes, MachineEmbedding.tapes_inr, + encodeWord, List.replicate_succ, List.cons_append, List.head?_cons, + List.tail_cons, Option.getD_some, Bool.cond_true] + congr 2 + funext k + cases k <;> simp [tapes, MachineEmbedding.tapes, Function.update, encodeWord] + +theorem guard_zero (d : Nat) (hd : 0 < d) (v e : Nat) (output : List Bool) : + TM2.step (program d hd) (cfg d (some (.inr .guard)) v e 0 output) = + some (cfg d none v e 0 output) := by + change some (TM2.stepAux (extra d hd .guard) _ _) = _ + simp only [extra, TM2.stepAux, tapes, MachineEmbedding.tapes_inr, + encodeWord, List.replicate_zero, List.nil_append, List.head?_cons, + List.tail_cons, Option.getD_some, Bool.cond_false] + congr 2 + funext k + cases k <;> simp [tapes, MachineEmbedding.tapes, Function.update, encodeWord] + +theorem bump_step (d : Nat) (hd : 0 < d) (v e fuel : Nat) (output : List Bool) : + TM2.step (program d hd) (cfg d (some (.inr .bump)) v e fuel output) = + some (cfg d (some (.inr .guard)) (v + 1) e fuel output) := by + change some (TM2.stepAux (extra d hd .bump) _ _) = _ + simp only [extra, TM2.stepAux] + congr 2 + funext k + cases k with + | inl k => fin_cases k <;> simp [tapes, MachineEmbedding.tapes, + MachineDummyRows.fieldTapes, encodeWord, List.replicate_succ] + | inr k => simp [tapes, MachineEmbedding.tapes] + +def paddingBits (d v e : Nat) : Nat → List Bool + | 0 => [] + | count + 1 => MachineDummyRows.rowsBits v e d ++ paddingBits d (v + 1) (e + d) count + +def steps (d v e : Nat) (output : List Bool) : Nat → Nat + | 0 => 1 + | count + 1 => (MachineDummyRows.steps v e output d + 2) + + steps d (v + 1) (e + d) (output ++ MachineDummyRows.rowsBits v e d) count + +theorem loopTrace (d : Nat) (hd : 0 < d) (count v e : Nat) (output : List Bool) : + (advance (TM2.step (program d hd)))^[steps d v e output count] + (some (cfg d (some (.inr .guard)) v e count output)) = + some (cfg d none (v + count) (e + count * d) 0 + (output ++ paddingBits d v e count)) := by + induction count generalizing v e output with + | zero => simpa [steps, paddingBits] using guard_zero d hd v e output + | succ count ih => + rw [steps, Nat.add_comm (MachineDummyRows.steps v e output d + 2), + Function.iterate_add_apply] + have hb : (advance (TM2.step (program d hd)))^[MachineDummyRows.steps v e output d + 2] + (some (cfg d (some (.inr .guard)) v e (count + 1) output)) = + some (cfg d (some (.inr .guard)) (v + 1) (e + d) count + (output ++ MachineDummyRows.rowsBits v e d)) := by + rw [show MachineDummyRows.steps v e output d + 2 = + (MachineDummyRows.steps v e output d + 1) + 1 by omega, + Function.iterate_succ_apply, advance_some, guard_succ, + Function.iterate_succ_apply', bodyTrace, advance_some, bump_step] + rw [hb, ih] + simp only [paddingBits, List.append_assoc, Nat.succ_mul] + congr 2 <;> omega + +def initialTapes (v e fuel : Nat) (output : List Bool) : ∀ k, List (Alphabet k) := + Function.update (tapes v e fuel output) (.inl 2) [] + +theorem initialize_step (d : Nat) (hd : 0 < d) (v e fuel : Nat) (output : List Bool) : + TM2.step (program d hd) + ⟨some (.inr .initialize), (((), none), ()), initialTapes v e fuel output⟩ = + some (cfg d (some (.inr .guard)) v e fuel output) := by + change some (TM2.stepAux (extra d hd .initialize) _ _) = _ + simp only [extra, Reduction.MachineSubstitution.stepAux_pushWord, + List.reverse_reverse, initialTapes, Function.update_self, List.append_nil, + Function.update_idem, TM2.stepAux] + congr 2 + funext k + cases k with + | inl k => fin_cases k <;> simp [tapes, MachineEmbedding.tapes, + MachineDummyRows.fieldTapes] + | inr k => simp [tapes, MachineEmbedding.tapes] + +theorem paddingTrace (d : Nat) (hd : 0 < d) (count v e : Nat) (output : List Bool) : + (advance (TM2.step (program d hd)))^[steps d v e output count + 1] + (some ⟨some (.inr .initialize), (((), none), ()), initialTapes v e count output⟩) = + some (cfg d none (v + count) (e + count * d) 0 + (output ++ paddingBits d v e count)) := by + rw [Function.iterate_succ_apply, advance_some, initialize_step, loopTrace] + +def machine (d : Nat) (hd : 0 < d) : FinTM2 where + K := Tape + k₀ := .inl 0 + k₁ := .inl 4 + Γ := Alphabet + Λ := Label d + main := .inr .initialize + σ := State + initialState := (((), none), ()) + m := program d hd + +def execution (d : Nat) (hd : 0 < d) (count v e : Nat) (output : List Bool) : + StateTransition.EvalsToInTime (machine d hd).step + ⟨some (.inr .initialize), (((), none), ()), initialTapes v e count output⟩ + (some (cfg d none (v + count) (e + count * d) 0 + (output ++ paddingBits d v e count))) + (steps d v e output count + 1) where + steps := steps d v e output count + 1 + evals_in_steps := by + convert paddingTrace d hd count v e output using 1 + rfl + steps_le_m := le_rfl + +end IndependentSetsGames.Foundations.Complexity.MachinePaddingRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePortReindex.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePortReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ba2b9788fc41e3233e650bdea600ecf87f6c76e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePortReindex.lean @@ -0,0 +1,289 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAffine +import OAI.Combinatorics.IndependentSets.Machines.MachineFixedDivMod + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePortReindex + +open Turing MachineComposition +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +variable {K Λ A : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool +abbrev State (A : Type) (d : Nat) := MachineFixedDivMod.State A d + +def clean (d : Nat) (positive : 0 < d) (ambient : A) : State A d := + ((ambient, MachineFixedDivMod.residue d positive 0), none) + +inductive Label (d : Nat) + | copySeed | copyScan | copyRestore | initialize | divide + | emit (r : Fin d) + | affineScan | affineRestore | drainQuotient | finish + deriving DecidableEq, Fintype + +def exitAt {modulus : Nat} (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (State A modulus) := + match exit with + | none => .halt + | some label => .goto fun _ => label + +def emit (d : Nat) (positive : 0 < d) (output : K) (b : Nat) + (r : Fin d) (next : Λ) : TM2.Stmt (Alphabet (K := K)) Λ (State A d) := + pushWord output (List.replicate (r.val + b) true) + (.load (fun s => clean d positive s.1.1) (.goto fun _ => next)) + +def instruction (d : Nat) (positive : 0 < d) (c b : Nat) + (tape : Fin 5 → K) (labels : Label d → Λ) (exit : Option Λ) : + Label d → TM2.Stmt (Alphabet (K := K)) Λ (State A d) + | .copySeed => MachineUnaryAffineAt.seed (tape 2) 0 (labels .copyScan) + | .copyScan => MachineUnaryAffineAt.scan (tape 0) (tape 1) (tape 2) 1 + (labels .copyScan) (labels .copyRestore) + | .copyRestore => Reduction.MachineTransfer.loopAt (tape 1) (tape 0) id false + (labels .copyRestore) (some (labels .initialize)) + | .initialize => .push (tape 3) (fun _ => false) + (.push (tape 4) (fun _ => false) (.goto fun _ => labels .divide)) + | .divide => MachineFixedDivMod.scanLoop d positive (tape 2) (tape 3) + (labels .divide) (fun r => labels (.emit r)) + | .emit r => emit d positive (tape 4) b r (labels .affineScan) + | .affineScan => MachineUnaryAffineAt.scan (tape 3) (tape 1) (tape 4) c + (labels .affineScan) (labels .affineRestore) + | .affineRestore => Reduction.MachineTransfer.loopAt (tape 1) (tape 3) id false + (labels .affineRestore) (some (labels .drainQuotient)) + | .drainQuotient => MachineDrain.drain (tape 3) (labels .drainQuotient) + (some (labels .finish)) + | .finish => .pop (tape 2) (fun s _ => clean d positive s.1.1) (exitAt exit) + +def steps (d j : Nat) : Nat := 3 * j + 3 * (j / d) + 11 + +theorem steps_le (d j : Nat) : steps d j ≤ 6 * j + 11 := by + have h := Nat.div_le_self j d + unfold steps + omega + +theorem steps_le_encodedLength (d j : Nat) : + steps d j ≤ 6 * (encodeWord j).length + 5 := by + have h := steps_le d j + rw [encodeWord_length] + omega + +def value (d c b j : Nat) : Nat := c * (j / d) + (j % d) + b + +def frame (tape : Fin 5 → K) (base : K → List Bool) + (work quotient output : List Bool) : K → List Bool := + MachineCopy.forkTapes (tape 2) (tape 3) (tape 4) base work quotient output + +theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {n m : Nat} + (first : f^[n] a = b) (second : f^[m] b = c) : f^[n + m] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem reindexTrace (d : Nat) (positive : 0 < d) (c b : Nat) + (tape : Fin 5 → K) (distinct : Function.Injective tape) + (labels : Label d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A d)) + (atLabels : ∀ l, program (labels l) = instruction d positive c b tape labels exit l) + (base : K → List Bool) (j : Nat) (suffix : List Bool) + (sourceWord : base (tape 0) = encodeWord j ++ suffix) + (scratchEmpty : base (tape 1) = []) (workEmpty : base (tape 2) = []) + (quotientEmpty : base (tape 3) = []) (ambient : A) : + (advance (TM2.step program))^[steps d j] + (some ⟨some (labels .copySeed), clean d positive ambient, base⟩) = + some ⟨exit, clean d positive ambient, + Function.update base (tape 4) (encodeWord (value d c b j) ++ base (tape 4))⟩ := by + have hd (i k : Fin 5) (h : i ≠ k) : tape i ≠ tape k := fun e => h (distinct e) + let q := j / d + let r := MachineFixedDivMod.residue d positive j + let copied := Function.update base (tape 2) (encodeWord j) + let initialized := frame tape base (encodeWord j) (encodeWord 0) + (encodeWord 0 ++ base (tape 4)) + let divided := frame tape base (encodeWord 0) (encodeWord q) + (encodeWord 0 ++ base (tape 4)) + let emitted := frame tape base (encodeWord 0) (encodeWord q) + (encodeWord (r.val + b) ++ base (tape 4)) + let computed := frame tape base (encodeWord 0) (encodeWord q) + (encodeWord (c * q + (r.val + b)) ++ base (tape 4)) + let drained := frame tape base (encodeWord 0) [] + (encodeWord (c * q + (r.val + b)) ++ base (tape 4)) + have copyRun : (advance (TM2.step program))^[2 * (j + 1) + 1] + (some ⟨some (labels .copySeed), clean d positive ambient, base⟩) = + some ⟨some (labels .initialize), clean d positive ambient, copied⟩ := by + simpa only [clean, copied, Nat.one_mul, Nat.add_zero, workEmpty, List.append_nil] using + MachineUnaryAffineAt.seededAffineTrace (tape 0) (tape 1) (tape 2) + (hd 0 1 (by decide)) (hd 0 2 (by decide)) (hd 1 2 (by decide)) 1 0 + (labels .copySeed) (labels .copyScan) (labels .copyRestore) + (some (labels .initialize)) program (atLabels .copySeed) (atLabels .copyScan) + (atLabels .copyRestore) base j suffix sourceWord scratchEmpty + (ambient, MachineFixedDivMod.residue d positive 0) none + have initRun : (advance (TM2.step program))^[1] + (some ⟨some (labels .initialize), clean d positive ambient, copied⟩) = + some ⟨some (labels .divide), clean d positive ambient, initialized⟩ := by + change some (TM2.stepAux (program (labels .initialize)) _ _) = _ + rw [atLabels] + simp [instruction, TM2.stepAux, copied, initialized, frame, MachineCopy.forkTapes, + hd 3 2 (by decide), hd 4 2 (by decide), hd 4 3 (by decide), quotientEmpty, encodeWord] + have divisionInput : MachineFixedDivMod.unaryTapes (tape 2) (tape 3) (tape 4) + base j 0 0 [] [] (base (tape 4)) = initialized := by + simp only [MachineFixedDivMod.unaryTapes, MachineFixedDivMod.tapes, + List.append_nil, initialized, frame] + have divisionOutput : MachineFixedDivMod.unaryTapes (tape 2) (tape 3) (tape 4) + base 0 q 0 [] [] (base (tape 4)) = divided := by + simp only [MachineFixedDivMod.unaryTapes, MachineFixedDivMod.tapes, + List.append_nil, divided, frame] + have divideRun : (advance (TM2.step program))^[j + 1] + (some ⟨some (labels .divide), clean d positive ambient, initialized⟩) = + some ⟨some (labels (.emit r)), ((ambient, r), some false), divided⟩ := by + have h := MachineFixedDivMod.scanTrace_fromCount d positive (tape 2) (tape 3) (tape 4) + (hd 2 3 (by decide)) (hd 2 4 (by decide)) (hd 3 4 (by decide)) + (labels .divide) (fun a => labels (.emit a)) program (atLabels .divide) + base j 0 [] [] (base (tape 4)) ambient none + simpa only [Nat.zero_div, Nat.zero_add, divisionInput, divisionOutput, clean, r, q] using h + have emitRun : (advance (TM2.step program))^[1] + (some ⟨some (labels (.emit r)), ((ambient, r), some false), divided⟩) = + some ⟨some (labels .affineScan), clean d positive ambient, emitted⟩ := by + change some (TM2.stepAux (program (labels (.emit r))) _ _) = _ + rw [atLabels] + simp [instruction, emit, stepAux_pushWord, TM2.stepAux, divided, emitted, frame, + MachineCopy.forkTapes, List.reverse_replicate, encodeWord, List.append_assoc] + have affineInput : MachineUnaryAffineAt.tapes (tape 3) (tape 1) (tape 4) + emitted (encodeWord q ++ []) [] (encodeWord (r.val + b) ++ base (tape 4)) = emitted := by + have heq : emitted (tape 3) = encodeWord q := by + simp [emitted, frame, MachineCopy.forkTapes, hd 3 4 (by decide)] + have hempty : emitted (tape 1) = [] := by + simp [emitted, frame, MachineCopy.forkTapes, hd 1 2 (by decide), + hd 1 3 (by decide), hd 1 4 (by decide), scratchEmpty] + have hout : emitted (tape 4) = encodeWord (r.val + b) ++ base (tape 4) := by + simp [emitted, frame, MachineCopy.forkTapes] + rw [List.append_nil, ← heq, ← hempty, ← hout] + exact MachineCopy.forkTapes_self _ _ _ _ + have affineOutput : MachineUnaryAffineAt.tapes (tape 3) (tape 1) (tape 4) + emitted (encodeWord q ++ []) [] (encodeWord (c * q + (r.val + b)) ++ base (tape 4)) = + computed := by + funext k + by_cases h1 : k = tape 1 + · subst k + simp [MachineUnaryAffineAt.tapes, emitted, computed, frame, MachineCopy.forkTapes, + hd 1 2 (by decide), hd 1 3 (by decide), hd 1 4 (by decide), scratchEmpty] + · by_cases h3 : k = tape 3 + · subst k + simp [MachineUnaryAffineAt.tapes, emitted, computed, frame, MachineCopy.forkTapes, + hd 3 1 (by decide), hd 3 4 (by decide)] + · by_cases h4 : k = tape 4 + · subst k; simp [MachineUnaryAffineAt.tapes, computed, frame, MachineCopy.forkTapes] + · simp [MachineUnaryAffineAt.tapes, emitted, computed, frame, MachineCopy.forkTapes, + h1, h3, h4] + have affineRun : (advance (TM2.step program))^[2 * (q + 1)] + (some ⟨some (labels .affineScan), clean d positive ambient, emitted⟩) = + some ⟨some (labels .drainQuotient), clean d positive ambient, computed⟩ := by + have h := MachineUnaryAffineAt.affineTrace (tape 3) (tape 1) (tape 4) + (hd 3 1 (by decide)) (hd 3 4 (by decide)) (hd 1 4 (by decide)) c + (labels .affineScan) (labels .affineRestore) (some (labels .drainQuotient)) + program (atLabels .affineScan) (atLabels .affineRestore) emitted q (r.val + b) + [] (base (tape 4)) (ambient, MachineFixedDivMod.residue d positive 0) none + simpa only [affineInput, affineOutput, clean] using h + have quotientWord : computed (tape 3) = encodeWord q := by + simp [computed, frame, MachineCopy.forkTapes, hd 3 4 (by decide)] + have drainOutput : Function.update computed (tape 3) [] = drained := by + funext k + by_cases h3 : k = tape 3 + · subst k + simp [drained, frame, MachineCopy.forkTapes, hd 3 4 (by decide)] + · by_cases h4 : k = tape 4 + · subst k + simp [computed, drained, frame, MachineCopy.forkTapes, hd 4 3 (by decide)] + · simp [computed, drained, frame, MachineCopy.forkTapes, h3, h4] + have drainRun : (advance (TM2.step program))^[q + 2] + (some ⟨some (labels .drainQuotient), clean d positive ambient, computed⟩) = + some ⟨some (labels .finish), clean d positive ambient, drained⟩ := by + have h := MachineDrain.drainTrace (tape 3) (labels .drainQuotient) + (some (labels .finish)) program (atLabels .drainQuotient) + computed (computed (tape 3)) (ambient, MachineFixedDivMod.residue d positive 0) none + rw [Function.update_eq_self, drainOutput, quotientWord, encodeWord_length] at h + exact h + have finishOutput : Function.update drained (tape 2) [] = + Function.update base (tape 4) (encodeWord (value d c b j) ++ base (tape 4)) := by + have hv : c * q + (r.val + b) = value d c b j := by + simp [value, q, r, MachineFixedDivMod.residue, Nat.add_assoc] + funext k + by_cases h2 : k = tape 2 + · subst k + simp [hd 2 4 (by decide), workEmpty] + · by_cases h3 : k = tape 3 + · subst k + simp [drained, frame, MachineCopy.forkTapes, hd 3 2 (by decide), + hd 3 4 (by decide), quotientEmpty] + · by_cases h4 : k = tape 4 + · subst k + simp [drained, frame, MachineCopy.forkTapes, hd 4 2 (by decide), hv] + · simp [drained, frame, MachineCopy.forkTapes, h2, h3, h4] + have finishRun : (advance (TM2.step program))^[1] + (some ⟨some (labels .finish), clean d positive ambient, drained⟩) = + some ⟨exit, clean d positive ambient, + Function.update base (tape 4) (encodeWord (value d c b j) ++ base (tape 4))⟩ := by + have hw : drained (tape 2) = encodeWord 0 := by + simp [drained, frame, MachineCopy.forkTapes, hd 2 3 (by decide), hd 2 4 (by decide)] + change some (TM2.stepAux (program (labels .finish)) _ _) = _ + rw [atLabels] + cases exit <;> simp [instruction, TM2.stepAux, exitAt, hw, encodeWord, finishOutput, clean] + have total := joinTrace (joinTrace (joinTrace (joinTrace (joinTrace + (joinTrace copyRun initRun) divideRun) emitRun) affineRun) drainRun) finishRun + have hsteps : steps d j = + (((((2 * (j + 1) + 1) + 1) + (j + 1)) + 1) + 2 * (q + 1)) + (q + 2) + 1 := by + dsimp [steps, q] + omega + rw [hsteps] + exact total + +def reindexInTime (d : Nat) (positive : 0 < d) (c b : Nat) + (tape : Fin 5 → K) (distinct : Function.Injective tape) + (labels : Label d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A d)) + (atLabels : ∀ l, program (labels l) = instruction d positive c b tape labels exit l) + (base : K → List Bool) (j : Nat) (suffix : List Bool) + (sourceWord : base (tape 0) = encodeWord j ++ suffix) + (scratchEmpty : base (tape 1) = []) (workEmpty : base (tape 2) = []) + (quotientEmpty : base (tape 3) = []) (ambient : A) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .copySeed), clean d positive ambient, base⟩ + (some ⟨exit, clean d positive ambient, + Function.update base (tape 4) (encodeWord (value d c b j) ++ base (tape 4))⟩) + (6 * j + 11) where + steps := steps d j + evals_in_steps := reindexTrace d positive c b tape distinct labels exit program atLabels + base j suffix sourceWord scratchEmpty workEmpty quotientEmpty ambient + steps_le_m := steps_le d j + +def machine (d : Nat) (positive : 0 < d) (c b : Nat) : FinTM2 where + K := Fin 5 + k₀ := 0 + k₁ := 4 + Γ _ := Bool + Λ := Label d + main := .copySeed + σ := State Unit d + initialState := clean d positive () + m := instruction d positive c b id id none + +def machineInTime (d : Nat) (positive : 0 < d) (c b : Nat) + (base : Fin 5 → List Bool) (j : Nat) (suffix : List Bool) + (sourceWord : base 0 = encodeWord j ++ suffix) + (scratchEmpty : base 1 = []) (workEmpty : base 2 = []) + (quotientEmpty : base 3 = []) : + StateTransition.EvalsToInTime (machine d positive c b).step + ⟨some .copySeed, clean d positive (), base⟩ + (some ⟨none, clean d positive (), + Function.update base (4 : Fin 5) (encodeWord (value d c b j) ++ base 4)⟩) + (6 * j + 11) := + reindexInTime d positive c b id (fun _ _ h => h) id none + (instruction d positive c b id id none) (fun _ => rfl) + base j suffix sourceWord scratchEmpty workEmpty quotientEmpty () + +theorem lazy_value (d j : Nat) : value d (2 * d) d j = + 2 * d * (j / d) + d + (j % d) := by + unfold value + omega + +end IndependentSetsGames.Foundations.Complexity.MachinePortReindex + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePreservingLookupClean.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePreservingLookupClean.lean new file mode 100644 index 0000000000000000000000000000000000000000..0125b9eccea44dcaf15aeb2ec04dea3051dcfeb2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachinePreservingLookupClean.lean @@ -0,0 +1,192 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain +import OAI.Combinatorics.IndependentSets.Machines.MachineSubroutine + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachinePreservingLookupClean + +open Turing +open MachineComposition + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +inductive Label + | run (label : MachinePreservingLookup.Label) + | cleanup + deriving DecidableEq, Fintype + +def statement (tape : Fin 5 → K) (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .run label => MachineSubroutine.statement (fun label => labels (.run label)) + (some (labels .cleanup)) (MachinePreservingLookup.program tape label) + | .cleanup => MachineDrain.drain (tape 2) (labels .cleanup) exit + +def program (tape : Fin 5 → K) : + Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) := + statement tape id none + +def steps (values : List Nat) (index : Nat) : Nat := + (2 * ((encodeWords values).length + 1) + MachineLookupSpec.steps values index + 1) + + ((encodeWords (values.drop (index + 1))).length + 1) + +theorem remaining_length_le (values : List Nat) (index : Nat) : + (encodeWords (values.drop (index + 1))).length ≤ (encodeWords values).length := by + have h := congrArg (fun words : List Nat => (encodeWords words).length) + (List.take_append_drop (index + 1) values) + simp only [encodeWords_append, List.length_append] at h + omega + +theorem steps_le (values : List Nat) (index value : Nat) + (selected : values[index]? = some value) : + steps values index ≤ 6 * (encodeWords values).length + 4 := by + have hc := MachinePreservingLookup.preservingLookup_steps_le values index value selected + have hd := remaining_length_le values index + unfold steps + omega + +noncomputable def timePolynomial : Polynomial Nat := 6 * Polynomial.X + 4 + +theorem steps_le_timePolynomial (values : List Nat) (index value : Nat) + (selected : values[index]? = some value) : + steps values index ≤ timePolynomial.eval (encodeWords values).length := by + simpa only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_ofNat, Polynomial.eval_X] using steps_le values index value selected + +theorem traceAt (tape : Fin 5 → K) (distinct : Function.Injective tape) + (labels : Label → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (code : ∀ label, target (labels label) = statement tape labels exit label) + (base : K → List Bool) (values : List Nat) + (tableWord : base (tape 0) = encodeWords values) + (scratchEmpty : base (tape 4) = []) + (index value : Nat) (selected : values[index]? = some value) + (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step target))^[steps values index] + (some ⟨some (labels (.run .copyFirst)), (ambient, register), + MachinePreservingLookup.initialTapes tape base index indexSuffix [] output⟩) = + some ⟨exit, (ambient, none), + MachinePreservingLookup.initialTapes tape base 0 indexSuffix [] + (encodeWord value ++ output)⟩ := by + have hd (a b : Fin 5) (hne : a ≠ b) : tape a ≠ tape b := + fun h => hne (distinct h) + have raw := MachinePreservingLookup.preservingLookupTrace tape distinct + MachinePreservingLookup.Label.copyFirst MachinePreservingLookup.Label.copySecond + MachinePreservingLookup.Label.lookup none (MachinePreservingLookup.program tape) + rfl rfl (fun _ => rfl) base values tableWord scratchEmpty index value selected + indexSuffix [] output ambient register + have run := MachineSubroutine.trace (fun label => labels (.run label)) + (some (labels .cleanup)) (MachinePreservingLookup.program tape) target + (fun label => code (.run label)) + (2 * ((encodeWords values).length + 1) + MachineLookupSpec.steps values index + 1) + _ _ raw + simp only [MachineSubroutine.configuration, MachineSubroutine.label] at run + have cleanup := MachineDrain.drainTrace (tape 2) (labels .cleanup) exit target + (code .cleanup) + (MachinePreservingLookup.finalTapes tape base values index value indexSuffix [] output) + (encodeWords (values.drop (index + 1))) ambient none + have word : MachinePreservingLookup.finalTapes tape base values index value + indexSuffix [] output (tape 2) = encodeWords (values.drop (index + 1)) := by + simp only [MachinePreservingLookup.finalTapes, + MachineLookup.tapes_source _ _ _ (hd 2 3 (by decide)), List.append_nil] + have start : Function.update + (MachinePreservingLookup.finalTapes tape base values index value indexSuffix [] output) + (tape 2) (encodeWords (values.drop (index + 1))) = + MachinePreservingLookup.finalTapes tape base values index value indexSuffix [] output := by + rw [← word, Function.update_eq_self] + have finish : Function.update + (MachinePreservingLookup.finalTapes tape base values index value indexSuffix [] output) + (tape 2) [] = MachinePreservingLookup.initialTapes tape base 0 indexSuffix [] + (encodeWord value ++ output) := by + unfold MachinePreservingLookup.finalTapes MachinePreservingLookup.initialTapes + rw [MachineLookup.update_source _ _ _ (hd 2 3 (by decide))] + rw [start, finish] at cleanup + rw [show steps values index = + ((encodeWords (values.drop (index + 1))).length + 1) + + (2 * ((encodeWords values).length + 1) + MachineLookupSpec.steps values index + 1) by + unfold steps + omega, + Function.iterate_add_apply, run] + exact cleanup + +def inTimeAt (tape : Fin 5 → K) (distinct : Function.Injective tape) + (labels : Label → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (code : ∀ label, target (labels label) = statement tape labels exit label) + (base : K → List Bool) (values : List Nat) + (tableWord : base (tape 0) = encodeWords values) + (scratchEmpty : base (tape 4) = []) + (index value : Nat) (selected : values[index]? = some value) + (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels (.run .copyFirst)), (ambient, register), + MachinePreservingLookup.initialTapes tape base index indexSuffix [] output⟩ + (some ⟨exit, (ambient, none), + MachinePreservingLookup.initialTapes tape base 0 indexSuffix [] + (encodeWord value ++ output)⟩) + (timePolynomial.eval (encodeWords values).length) where + steps := steps values index + evals_in_steps := traceAt tape distinct labels exit target code base values tableWord + scratchEmpty index value selected indexSuffix output ambient register + steps_le_m := steps_le_timePolynomial values index value selected + +theorem initialTapes_eq (tape : Fin 5 → K) (base : K → List Bool) + (index : Nat) (indexSuffix : List Bool) + (counterWord : base (tape 1) = encodeWord index ++ indexSuffix) + (workEmpty : base (tape 2) = []) : + MachinePreservingLookup.initialTapes tape base index indexSuffix [] (base (tape 3)) = + base := by + simp only [MachinePreservingLookup.initialTapes, MachineLookup.tapes, + ← counterWord, ← workEmpty, Function.update_eq_self] + +theorem traceAt_fromTapes (tape : Fin 5 → K) (distinct : Function.Injective tape) + (labels : Label → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (code : ∀ label, target (labels label) = statement tape labels exit label) + (base : K → List Bool) (values : List Nat) + (tableWord : base (tape 0) = encodeWords values) + (scratchEmpty : base (tape 4) = []) + (index value : Nat) (selected : values[index]? = some value) + (indexSuffix : List Bool) + (counterWord : base (tape 1) = encodeWord index ++ indexSuffix) + (workEmpty : base (tape 2) = []) (ambient : σ) (register : Option Bool) : + (advance (TM2.step target))^[steps values index] + (some ⟨some (labels (.run .copyFirst)), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), + MachinePreservingLookup.initialTapes tape base 0 indexSuffix [] + (encodeWord value ++ base (tape 3))⟩ := by + have h := traceAt tape distinct labels exit target code base values tableWord scratchEmpty + index value selected indexSuffix (base (tape 3)) ambient register + rw [initialTapes_eq tape base index indexSuffix counterWord workEmpty] at h + exact h + +def machine : FinTM2 where + K := Fin 5 + k₀ := 0 + k₁ := 3 + Γ _ := Bool + Λ := Label + main := .run .copyFirst + σ := Unit × Option Bool + initialState := ((), none) + m := program id + +def machineInTime (base : Fin 5 → List Bool) (values : List Nat) + (tableWord : base 0 = encodeWords values) (scratchEmpty : base 4 = []) + (index value : Nat) (selected : values[index]? = some value) + (indexSuffix output : List Bool) (register : Option Bool) : + StateTransition.EvalsToInTime machine.step + ⟨some (.run .copyFirst), ((), register), + MachinePreservingLookup.initialTapes id base index indexSuffix [] output⟩ + (some ⟨none, ((), none), + MachinePreservingLookup.initialTapes id base 0 indexSuffix [] + (encodeWord value ++ output)⟩) + (timePolynomial.eval (encodeWords values).length) := + inTimeAt id (fun _ _ h => h) id none (program id) (fun _ => rfl) + base values tableWord scratchEmpty index value selected indexSuffix output () register + +end IndependentSetsGames.Foundations.Complexity.MachinePreservingLookupClean + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularDummyRow.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularDummyRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..632bed2684154baec28c67b87d19244e5453bd05 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularDummyRow.lean @@ -0,0 +1,187 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAffine +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudPadding +import OAI.Combinatorics.IndependentSets.Machines.MachineDummyRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularDummyRow + +open Turing MachineComposition PCP.GraphTables + +abbrev Tape := Fin 6 +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := σ × Option Bool + +inductive Label + | affine (stage : MachineUnaryAffineAt.Label) + | row (stage : MachineDummyRows.Label 1) + | reverse | relation + deriving DecidableEq, Fintype + +def reverseIndex (q x : Nat) : Nat := (q + 1) * x + q + +def emittedBits (q x : Nat) : List Bool := + MachineDummyRows.rowBits x (reverseIndex q x) + +def instruction {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt Alphabet Λ (State σ) + | .affine .seed => MachineUnaryAffineAt.seed 1 q (labels (.affine .scan)) + | .affine .scan => MachineUnaryAffineAt.scan 0 3 1 (q + 1) + (labels (.affine .scan)) (labels (.affine .restore)) + | .affine .restore => Reduction.MachineTransfer.loopAt 3 0 id false + (labels (.affine .restore)) (some (labels (.row (MachineDummyRows.start 1)))) + | .row stage => MachineCloudPadding.Placement.statement (id : Tape → Tape) + (fun l => labels (.row l)) (some (labels .reverse)) + (MachineDummyRows.program 1 stage) + | .reverse => MachineDrain.drain 1 (labels .reverse) (some (labels .relation)) + | .relation => MachineDrain.drain 2 (labels .relation) exit + +structure Input (x : Nat) (base : Tape → List Bool) : Prop where + source : base 0 = encodeWord x + reverseEmpty : base 1 = [] + relationEmpty : base 2 = [] + scratchEmpty : base 3 = [] + rowEmpty : base 5 = [] + +def memory (x : Nat) (output : List Bool) : Tape → List Bool := + ![encodeWord x, [], [], [], output, []] + +theorem memory_input (x : Nat) (output : List Bool) : Input x (memory x output) := + ⟨rfl, rfl, rfl, rfl, rfl⟩ + +private theorem join_trace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +theorem affine_frame (x e : Nat) (base : Tape → List Bool) (input : Input x base) : + Function.update base 1 (encodeWord e) = + MachineDummyRows.initialTapes x e (base 4) := by + funext k + fin_cases k <;> + simp [MachineDummyRows.initialTapes, MachineDummyRows.fieldTapes, + input.source, input.relationEmpty, input.scratchEmpty, input.rowEmpty] + +theorem cleanup_frame (x e : Nat) (output : List Bool) + (base : Tape → List Bool) (input : Input x base) : + Function.update (Function.update (MachineDummyRows.fieldTapes x e output) 1 []) 2 [] = + Function.update base 4 output := by + funext k + fin_cases k <;> + simp [MachineDummyRows.fieldTapes, input.source, input.reverseEmpty, + input.relationEmpty, input.scratchEmpty, input.rowEmpty] + +theorem rowTraceAt {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (x e : Nat) (output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[MachineDummyRows.steps x e output 1 + 1] + (some ⟨some (labels (.row (MachineDummyRows.start 1))), (ambient, register), + MachineDummyRows.initialTapes x e output⟩) = + some ⟨some (labels .reverse), (ambient, none), + MachineDummyRows.fieldTapes x (e + 1) (output ++ MachineDummyRows.rowBits x e)⟩ := by + have run := MachineDummyRows.allTrace 1 x e output ambient register + have placed := MachineCloudPadding.Placement.trace (id : Tape → Tape) (fun k => some k) + (fun _ => rfl) (fun _ _ h => (Option.some.inj h).symm) + (fun l => labels (.row l)) (some (labels .reverse)) (fun _ => []) + (MachineDummyRows.program 1) program + (fun l => code (.row l)) _ _ _ run + have identityTapes (source : Tape → List Bool) : + MachineCloudPadding.Placement.tapes (fun k : Tape => some k) source + (fun _ : Tape => []) = source := rfl + simpa only [MachineCloudPadding.Placement.configuration, + MachineCloudPadding.Placement.label, identityTapes, + MachineDummyRows.rowsBits, List.append_nil] using placed + +theorem cleanupTraceAt {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (x e : Nat) (output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[ + ((encodeWord e).length + 1) + (MachineDummyRows.trueBits.length + 1)] + (some ⟨some (labels .reverse), (ambient, register), + MachineDummyRows.fieldTapes x e output⟩) = + some ⟨exit, (ambient, none), + Function.update (Function.update (MachineDummyRows.fieldTapes x e output) 1 []) 2 []⟩ := by + let base := MachineDummyRows.fieldTapes x e output + let mid := Function.update base (1 : Tape) [] + have first := MachineDrain.drainTrace (1 : Tape) (labels .reverse) + (some (labels .relation)) program (code .reverse) base (base 1) ambient register + have second := MachineDrain.drainTrace (2 : Tape) (labels .relation) + exit program (code .relation) mid (mid 2) ambient none + simp only [Function.update_eq_self] at first second + have hreverse : base 1 = encodeWord e := rfl + have hrelation : mid 2 = MachineDummyRows.trueBits := by + simp only [mid, Function.update_of_ne (by decide : (2 : Tape) ≠ 1)] + rfl + rw [hreverse] at first + rw [hrelation] at second + exact join_trace first second + +def steps (q x : Nat) (output : List Bool) : Nat := + ((2 * (x + 1) + 1) + (MachineDummyRows.steps x (reverseIndex q x) output 1 + 1)) + + (((encodeWord (reverseIndex q x + 1)).length + 1) + + (MachineDummyRows.trueBits.length + 1)) + +def timeBound (q x outputLength : Nat) : Nat := + (5 * q + 11) * x + 2 * outputLength + 5 * q + 40986 + +theorem steps_eq (q x : Nat) (output : List Bool) : + steps q x output = timeBound q x output.length := by + simp only [steps, MachineDummyRows.steps, encodeWord_length, MachineDummyRows.trueBits_length, + reverseIndex, timeBound] + ring + +theorem traceAt {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (x : Nat) (base : Tape → List Bool) (input : Input x base) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps q x (base 4)] + (some ⟨some (labels (.affine .seed)), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), Function.update base 4 (base 4 ++ emittedBits q x)⟩ := by + have affine := MachineUnaryAffineAt.seededAffineTrace (0 : Tape) 3 1 + (by decide) (by decide) (by decide) (q + 1) q + (labels (.affine .seed)) (labels (.affine .scan)) (labels (.affine .restore)) + (some (labels (.row (MachineDummyRows.start 1)))) program + (code (.affine .seed)) (code (.affine .scan)) (code (.affine .restore)) + base x [] (by simpa only [List.append_nil] using input.source) + input.scratchEmpty ambient register + simp only [input.reverseEmpty, List.append_nil] at affine + change (advance (TM2.step program))^[2 * (x + 1) + 1] + (some ⟨some (labels (.affine .seed)), (ambient, register), base⟩) = + some ⟨some (labels (.row (MachineDummyRows.start 1))), (ambient, none), + Function.update base 1 (encodeWord (reverseIndex q x))⟩ at affine + rw [affine_frame x (reverseIndex q x) base input] at affine + have row := rowTraceAt q labels exit program code x (reverseIndex q x) (base 4) ambient none + have clean := cleanupTraceAt q labels exit program code x (reverseIndex q x + 1) + (base 4 ++ MachineDummyRows.rowBits x (reverseIndex q x)) ambient none + rw [cleanup_frame x (reverseIndex q x + 1) _ base input] at clean + exact join_trace (join_trace affine row) clean + +def machine (q : Nat) : FinTM2 where + K := Tape + k₀ := 0 + k₁ := 4 + Γ := Alphabet + Λ := Label + main := .affine .seed + σ := State Unit + initialState := ((), none) + m := instruction q id none + +def machineInTime (q x : Nat) (base : Tape → List Bool) (input : Input x base) + (register : Option Bool) : + StateTransition.EvalsToInTime (machine q).step + ⟨some (.affine .seed), ((), register), base⟩ + (some ⟨none, ((), none), Function.update base (4 : Tape) + (base 4 ++ emittedBits q x)⟩) + (timeBound q x (base 4).length) where + steps := steps q x (base 4) + evals_in_steps := traceAt q id none (instruction q id none) + (fun _ => rfl) x base input () register + steps_le_m := (steps_eq q x (base 4)).le + +end IndependentSetsGames.Foundations.Complexity.MachineRegularDummyRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularExecutionBounds.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularExecutionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..167dd55bd349f4e47f117d583ad0c7184ac190aa --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularExecutionBounds.lean @@ -0,0 +1,282 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalBody +import OAI.Combinatorics.IndependentSets.Machines.Machine2 + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularExecutionBounds + +open Turing MachineComposition PCP PCP.PreprocessingRegularTables PCP.PreprocessingCloudIndex +open PCP.PreprocessingMachineBounds MachineRegularInternalRow + +theorem coreTimeBound_mono (q L R x v i k o m O L' R' x' v' i' k' o' m' O' : Nat) + (hL : L ≤ L') (hR : R ≤ R') (hx : x ≤ x') (hv : v ≤ v') (hi : i ≤ i') + (hk : k ≤ k') (ho : o ≤ o') (hm : m ≤ m') (hO : O ≤ O') : + coreTimeBound q L R x v i k o m O ≤ coreTimeBound q L' R' x' v' i' k' o' m' O' := by + unfold coreTimeBound + gcongr + +noncomputable def corePolynomial (q : Nat) : Polynomial Nat := + Polynomial.C (5*q+32) * rotorPolynomial q + 10 * Polynomial.X + + 2 * (Polynomial.C ExpanderFamily.growth * Polynomial.X) + 13 * Polynomial.X + + 5 * Polynomial.X + Polynomial.C (5*q+10) * + (Polynomial.X + Polynomial.C ExpanderFamily.growth * Polynomial.X) + + 4 * (Polynomial.C ExpanderFamily.growth * Polynomial.X) + + 2 * regularPolynomial + Polynomial.C (8*q+41066) + +theorem corePolynomial_eval (q L : Nat) : + (corePolynomial q).eval L = + coreTimeBound q L ((rotorPolynomial q).eval L) + (ExpanderFamily.growth*L) L (ExpanderFamily.growth*L) L + (ExpanderFamily.growth*L) L (regularPolynomial.eval L) := by + simp only [corePolynomial, coreTimeBound, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat] + omega + +theorem internal_steps_le (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding t v) q) + (v : Fin t.vertices) (x : PaddedCloud t (padding t) v) (p : Fin q) + (outputLength : Nat) (houtput : outputLength ≤ regularPolynomial.eval (inputLength t)) : + coreSteps t (padding t) tables v x p outputLength ≤ + (corePolynomial q).eval (inputLength t) := by + have hx : (vertexOrder t (padding t) x.val).val ≤ ExpanderFamily.growth * inputLength t := + (vertexOrder t (padding t) x.val).isLt.le.trans (regularVertices_le_input t) + have hi : (paddedCloudRank t (padding t) v x).val ≤ ExpanderFamily.growth * inputLength t := + (paddedCloudRank t (padding t) v x).isLt.le.trans (cloudTotal_le_input t v) + have hv : v.val ≤ inputLength t := + v.isLt.le.trans (GraphTables.vertices_le_tableBits_length t) + have hm : t.darts ≤ inputLength t := GraphTables.darts_le_tableBits_length t + rw [corePolynomial_eval] + exact (coreSteps_le q positive t (padding t) tables v x p outputLength).trans + (coreTimeBound_mono q _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ le_rfl + (cloudRotorBits_le t v (tables v)) hx hv hi (cloudSize_le_input t v) + (prefix_le_input t v.val) hm houtput) + +noncomputable def familyPolynomial : Polynomial Nat := + MachinePaddedExpanderFamilyBounds.timePolynomial.comp (Polynomial.X + 1) + + Polynomial.C (2 * ExpanderFamily.growth) * (Polynomial.X + 1) + 7 + +theorem family_budget_le (t : GraphTables.Table) (v : Fin t.vertices) : + MachinePaddedExpanderFamilyBounds.timePolynomial.eval (cloudSize t v + 1) + + 2 * ExpanderFamily.growth * (cloudSize t v + 1) + 7 ≤ + familyPolynomial.eval (inputLength t) := by + have h := Nat.add_le_add_right (cloudSize_le_input t v) 1 + have hp := natPolynomial_eval_mono MachinePaddedExpanderFamilyBounds.timePolynomial h + have hm := Nat.mul_le_mul_left (2 * ExpanderFamily.growth) h + simp only [familyPolynomial, Polynomial.eval_add, Polynomial.eval_comp, + Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_one, + Polynomial.eval_ofNat] + omega + +noncomputable def rowPolynomial (q : Nat) : Polynomial Nat := + Polynomial.C ExpanderFamily.growth * Polynomial.X + + (Polynomial.C ExpanderFamily.growth * Polynomial.X) * Polynomial.C (q + 1) + 8192 + +theorem rowPolynomial_eval (q L : Nat) : + (rowPolynomial q).eval L = + ExpanderFamily.growth * L + (ExpanderFamily.growth * L) * (q + 1) + 8192 := by + simp only [rowPolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat] + +theorem actual_row_bound_le (q : Nat) (t : GraphTables.Table) : + vertexCount t (padding t) + vertexCount t (padding t) * (q + 1) + 8192 ≤ + (rowPolynomial q).eval (inputLength t) := by + rw [rowPolynomial_eval] + have h := regularVertices_le_input t + exact Nat.add_le_add_right (Nat.add_le_add h (Nat.mul_le_mul_right _ h)) _ + +noncomputable def blockCorePolynomial (q : Nat) : Polynomial Nat := + corePolynomial q + Polynomial.C (2*q) * rowPolynomial q + +theorem coreTimeBound_add_output (q L R x v i k o m O A : Nat) : + coreTimeBound q L R x v i k o m (O + A) = + coreTimeBound q L R x v i k o m O + 2*A := by + unfold coreTimeBound + omega + +theorem block_core_bound_le (q : Nat) (t : GraphTables.Table) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding t v) q) + (v : Fin t.vertices) (x : PaddedCloud t (padding t) v) + (initialOutput : Nat) (houtput : initialOutput ≤ regularPolynomial.eval (inputLength t)) : + coreTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + (vertexOrder t (padding t) x.val).val v.val (paddedCloudRank t (padding t) v x).val + (cloudSize t v) (PreprocessingPaddingOffsets.offset (padding t) v.val) t.darts + (initialOutput + q * + (vertexCount t (padding t) + vertexCount t (padding t) * (q + 1) + 8192)) ≤ + (blockCorePolynomial q).eval (inputLength t) := by + have hx : (vertexOrder t (padding t) x.val).val ≤ ExpanderFamily.growth * inputLength t := + (vertexOrder t (padding t) x.val).isLt.le.trans (regularVertices_le_input t) + have hi : (paddedCloudRank t (padding t) v x).val ≤ ExpanderFamily.growth * inputLength t := + (paddedCloudRank t (padding t) v x).isLt.le.trans (cloudTotal_le_input t v) + have hv : v.val ≤ inputLength t := + v.isLt.le.trans (GraphTables.vertices_le_tableBits_length t) + have hm : t.darts ≤ inputLength t := GraphTables.darts_le_tableBits_length t + have hr := Nat.mul_le_mul_left q (actual_row_bound_le q t) + have hO := Nat.add_le_add houtput hr + have h := coreTimeBound_mono q (inputLength t) _ _ _ _ _ _ _ _ + (inputLength t) _ _ _ _ _ _ _ _ le_rfl + (cloudRotorBits_le t v (tables v)) hx hv hi (cloudSize_le_input t v) + (prefix_le_input t v.val) hm hO + simp only [coreTimeBound_add_output] at h ⊢ + rw [← corePolynomial_eval] at h + simpa only [inputLength, blockCorePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Nat.mul_assoc] using h + +end IndependentSetsGames.Foundations.Complexity.MachineRegularExecutionBounds +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalBodyBounds + +open Turing MachineComposition PCP PreprocessingCloudIndex PreprocessingRegularTables +open PreprocessingMachineBounds MachineRegularOriginalBody + +noncomputable def wide : Polynomial Nat := Polynomial.C (ExpanderFamily.growth + 1) * Polynomial.X +noncomputable def rowPolynomial (q : Nat) : Polynomial Nat := + wide + wide * Polynomial.C (q + 1) + 8192 +noncomputable def outputPolynomial (q : Nat) : Polynomial Nat := + wide + Polynomial.C q * rowPolynomial q +noncomputable def corePolynomial (q : Nat) : Polynomial Nat := + Polynomial.C (5*q+32) * rotorPolynomial q + 10*wide + 2*wide + 13*wide + 5*wide + + Polynomial.C (5*q+10)*(wide+wide) + 4*wide + 2*outputPolynomial q + + Polynomial.C (8*q+41066) +noncomputable def blockPolynomial (q : Nat) : Polynomial Nat := + Polynomial.C q * corePolynomial q + Polynomial.C (5*q+20)*wide + + 2*outputPolynomial q + Polynomial.C (5*q+40995) +noncomputable def cleanupPolynomial (q : Nat) : Polynomial Nat := 6*wide + rotorPolynomial q + 13 +noncomputable def timePolynomial : Polynomial Nat := + MachineRegularMetadata.timePolynomial + MachineRegularExecutionBounds.familyPolynomial + + blockPolynomial internalDegree + cleanupPolynomial internalDegree + +def bodySize (t : GraphTables.Table) (output : List Bool) : Nat := + inputLength t + output.length + +theorem blockPolynomial_eval (q L : Nat) : + (blockPolynomial q).eval L = + MachineRegularVertexBlock.originalTimeBound q + ((ExpanderFamily.growth+1)*L) ((rotorPolynomial q).eval L) + ((ExpanderFamily.growth+1)*L) ((ExpanderFamily.growth+1)*L) + ((ExpanderFamily.growth+1)*L) ((ExpanderFamily.growth+1)*L) + ((ExpanderFamily.growth+1)*L) ((ExpanderFamily.growth+1)*L) + ((ExpanderFamily.growth+1)*L) ((ExpanderFamily.growth+1)*L) := by + simp only [blockPolynomial, corePolynomial, outputPolynomial, rowPolynomial, wide, + Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_ofNat, MachineRegularVertexBlock.originalTimeBound, + MachineRegularVertexBlock.portTimeBound, MachineRegularInternalRow.coreTimeBound, + MachineRegularOriginalClean.timeBound, MachineRegularVertexBlock.rowSizeBound] + ring + +theorem originalTimeBound_le (q L R x v i k o m O V W R' : Nat) + (hL : L ≤ W) (hR : R ≤ R') (hx : x ≤ W) (hv : v ≤ W) + (hi : i ≤ W) (hk : k ≤ W) (ho : o ≤ W) (hm : m ≤ W) + (hO : O ≤ W) (hV : V ≤ W) : + MachineRegularVertexBlock.originalTimeBound q L R x v i k o m O V ≤ + MachineRegularVertexBlock.originalTimeBound q W R' W W W W W W W W := by + unfold MachineRegularVertexBlock.originalTimeBound MachineRegularVertexBlock.portTimeBound + MachineRegularInternalRow.coreTimeBound MachineRegularOriginalClean.timeBound + MachineRegularVertexBlock.rowSizeBound + gcongr + +theorem wide_le (t : GraphTables.Table) (output : List Bool) : + inputLength t ≤ (ExpanderFamily.growth+1)*bodySize t output ∧ + ExpanderFamily.growth*inputLength t ≤ (ExpanderFamily.growth+1)*bodySize t output ∧ + output.length ≤ (ExpanderFamily.growth+1)*bodySize t output := by + have hN : inputLength t ≤ bodySize t output := Nat.le_add_right _ _ + have hO : output.length ≤ bodySize t output := Nat.le_add_left _ _ + have hg := Nat.mul_le_mul_left ExpanderFamily.growth hN + rw [Nat.add_mul, Nat.one_mul] + omega + +theorem vertexSteps_le (H : PreprocessingRegularTables.BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + MachineRegularOriginalBody.vertexSteps H t e output ≤ + (blockPolynomial internalDegree).eval (bodySize t output) := by + let v := t.rows[e].tail + let W := (ExpanderFamily.growth+1)*bodySize t output + have bounds := wide_le t output + have hx := e.isLt.le.trans (GraphTables.darts_le_tableBits_length t) + have hv := v.isLt.le.trans (GraphTables.vertices_le_tableBits_length t) + have hk := cloudSize_le_input t v + have hi := (cloudRank t v (MachineRegularMetadata.originalMember t e)).isLt.le.trans hk + have hm := GraphTables.darts_le_tableBits_length t + have ho := prefix_le_input t v.val + have hV := regularVertices_le_input t + have hR := (cloudRotorBits_le t v (familyCloudTable H t v)).trans + (natPolynomial_eval_mono (rotorPolynomial internalDegree) + (Nat.le_add_right (inputLength t) output.length)) + have raw := MachineRegularVertexBlock.originalSteps_le internalDegree degree_positive + t (padding t) (familyCloudTable H t) e output.length + have bound := originalTimeBound_le internalDegree _ _ _ _ _ _ _ _ _ _ W _ + bounds.1 hR (hx.trans bounds.1) (hv.trans bounds.1) (hi.trans bounds.1) + (hk.trans bounds.1) (ho.trans bounds.2.1) (hm.trans bounds.1) bounds.2.2 + (hV.trans bounds.2.1) + rw [blockPolynomial_eval] + exact raw.trans bound + +theorem clearSteps_frame (data : Data) : + clearSteps (frame data) 7 = data.owner.length + data.localRank.length + + data.count.length + data.offset.length + data.rotor.length + data.padding.length + + data.level.length + 7 := by + simp [clearSteps, clearMemory, clearTape, frame, MachineRegularMetadata.frame] + omega + +theorem cleanupSteps_le (H : PreprocessingRegularTables.BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + clearSteps (frame (emittedData H t e output)) 7 ≤ + (cleanupPolynomial internalDegree).eval (bodySize t output) := by + let v := t.rows[e].tail + have bounds := wide_le t output + have hv := v.isLt.le.trans (GraphTables.vertices_le_tableBits_length t) + have hk := cloudSize_le_input t v + have hi := (cloudRank t v (MachineRegularMetadata.originalMember t e)).isLt.le.trans hk + have ho := prefix_le_input t v.val + have hp := cloudTotal_le_input t v + have hl := level_le_input t v + have hrotor := PreprocessingFamilyBridge.familyRotor_eq_familyCloudTable H t v + (PreprocessingFamilyBridge.cloudSize_pos_of_dart t e) + change MachineRegularFamily.rotor H (cloudSize t v) = _ at hrotor + have hR := (cloudRotorBits_le t v (familyCloudTable H t v)).trans + (natPolynomial_eval_mono (rotorPolynomial internalDegree) + (Nat.le_add_right (inputLength t) output.length)) + rw [← hrotor] at hR + rw [clearSteps_frame] + simp only [emittedData, familyData, metadataData, MachineRegularMetadata.originalData, + MachineRegularMetadata.cloudData, MachineRegularMetadata.prefixData, + MachineRegularMetadata.rankData, MachineRegularMetadata.ownerData, initialData, + encodeWord_length, cleanupPolynomial, wide, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat] + change _ ≤ 6*((ExpanderFamily.growth+1)*bodySize t output) + + (rotorPolynomial internalDegree).eval (bodySize t output)+13 + change cloudSize t v + MachineCloudPadding.padding (cloudSize t v) ≤ _ at hp + dsimp only [v, bodySize, inputLength] at * + omega + +theorem totalSteps_le (H : PreprocessingRegularTables.BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + totalSteps H t e output ≤ timePolynomial.eval (bodySize t output) := by + have hsize : inputLength t ≤ bodySize t output := Nat.le_add_right _ _ + have hm := (MachineRegularMetadata.totalTime_le t e).trans + (natPolynomial_eval_mono MachineRegularMetadata.timePolynomial hsize) + have hf := (familyExecution H t e output).steps_le_m + have hfb := MachineRegularExecutionBounds.family_budget_le t t.rows[e].tail + simp only [MachineRegularFamily.timePolynomial, encodeWord_length, + Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_ofNat] at hf + have hf' := (hf.trans hfb).trans + (natPolynomial_eval_mono MachineRegularExecutionBounds.familyPolynomial hsize) + have hv := vertexSteps_le H t e output + have hc := cleanupSteps_le H t e output + simp only [totalSteps, familySteps, timePolynomial, Polynomial.eval_add] + omega + +noncomputable def originalInTime (H : PreprocessingRegularTables.BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + StateTransition.EvalsToInTime (TM2.step (program H)) + (cfg H (some entry) (initialData t e output)) + (some (cfg H none (initialData t e (output ++ emittedBits H t e)))) + (timePolynomial.eval (bodySize t output)) where + steps := totalSteps H t e output + evals_in_steps := originalTrace H t e output + steps_le_m := totalSteps_le H t e output + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalBodyBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularFamily.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..4faa98a3499a65a4f90f2ac1fdbf821068cc03a2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularFamily.lean @@ -0,0 +1,380 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddedExpanderFamilyBounds + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularFamily + +open Turing MachineComposition +open MachineCloudPadding + +abbrev CoreTape := Fin 27 +abbrev NativeTape := MachinePaddedExpanderFamily.Tape +abbrev Tape := CoreTape ⊕ NativeTape +abbrev Alphabet (_ : Tape) := Bool +abbrev SmallTable := MachinePaddedExpanderFamily.SmallTable +abbrev FamilyState := MachineExpanderFamily.State Unit MachinePaddedExpanderFamily.fixedDegree +abbrev State := (FamilyState × Bool) × Option Bool + +def inputNative : NativeTape := .inr .input +def outputNative : NativeTape := .inl MachineExpanderFamily.tableTape +def powerNative : NativeTape := .inr .power +def sizeNative : NativeTape := .inl (.inr .currentSize) +def levelNative : NativeTape := .inl (.inr .remainingLevel) + +def powerTape : Tape := .inr powerNative +def sizeTape : Tape := .inr sizeNative +def levelTape : Tape := .inr levelNative + +def familyTape (t : NativeTape) : Tape := + if t = inputNative then .inl 4 else if t = outputNative then .inl 7 else .inr t + +def familyView : Tape → Option NativeTape + | .inl i => if i = 4 then some inputNative else if i = 7 then some outputNative else none + | .inr t => if t = inputNative then none else if t = outputNative then none else some t + +theorem familyView_left (t : NativeTape) : familyView (familyTape t) = some t := by + by_cases hi : t = inputNative + · subst t; simp [familyTape, familyView] + · by_cases ho : t = outputNative + · subst t; simp [familyTape, familyView, hi] + · simp [familyTape, familyView, hi, ho] + +theorem familyView_right (j : Tape) (t : NativeTape) + (h : familyView j = some t) : familyTape t = j := by + cases j with + | inl i => + by_cases hi : i = 4 + · subst i + have ht : inputNative = t := by simpa [familyView] using h + subst t; simp [familyTape] + · by_cases ho : i = 7 + · subst i + have ht : outputNative = t := by simpa [familyView] using h + subst t; simp [familyTape, inputNative, outputNative] + · simp [familyView, hi, ho] at h + | inr j => + by_cases hi : j = inputNative + · simp [familyView, hi] at h + · by_cases ho : j = outputNative + · simp [familyView, ho] at h + · have ht : j = t := by simpa [familyView, hi, ho] using h + subst t; simp [familyTape, hi, ho] + +def stateEquiv : MachinePaddedExpanderFamily.State Unit ≃ State := + (Equiv.prodAssoc FamilyState Bool (Option Bool)).symm + +def seedState (H : SmallTable) : FamilyState := + MachineExpanderFamily.initialState MachineExpanderFamily.baseDegree_positive H () + +def readyState (H : SmallTable) : State := ((seedState H, false), none) + +def sourceProgram (H : SmallTable) : MachinePaddedExpanderFamily.Label → + TM2.Stmt (fun _ : NativeTape => Bool) MachinePaddedExpanderFamily.Label State := + MachineStateEquiv.program stateEquiv (MachinePaddedExpanderFamily.program (ρ := Unit) H) + +inductive Label + | start + | family (label : MachinePaddedExpanderFamily.Label) + | drainPower | drainSize | drainLevel + deriving DecidableEq, Fintype + +def program (H : SmallTable) : Label → TM2.Stmt Alphabet Label State + | .start => .load (fun _ => readyState H) (.goto fun _ => .family MachinePaddedExpanderFamily.main) + | .family l => Placement.statement familyTape Label.family (some .drainPower) (sourceProgram H l) + | .drainPower => MachineDrain.drain powerTape .drainPower (some .drainSize) + | .drainSize => MachineDrain.drain sizeTape .drainSize (some .drainLevel) + | .drainLevel => MachineDrain.drain levelTape .drainLevel none + +def frame (core : CoreTape → List Bool) : Tape → List Bool + | .inl i => core i + | .inr _ => [] + +def rotor (H : SmallTable) (k : Nat) : List Bool := + MachinePaddedExpanderFamilyBounds.outputWord H k + +def resultCore (H : SmallTable) (k : Nat) (core : CoreTape → List Bool) : + CoreTape → List Bool := Function.update core 7 (rotor H k) + +def working (core : CoreTape → List Bool) (power size level : List Bool) : Tape → List Bool + | .inl i => core i + | .inr t => if t = powerNative then power + else if t = sizeNative then size else if t = levelNative then level else [] + +@[simp] theorem working_power (core : CoreTape → List Bool) (p s l : List Bool) : + working core p s l powerTape = p := by simp [working, powerTape] + +@[simp] theorem working_size (core : CoreTape → List Bool) (p s l : List Bool) : + working core p s l sizeTape = s := by + simp [working, sizeTape, powerNative, sizeNative] + +@[simp] theorem working_level (core : CoreTape → List Bool) (p s l : List Bool) : + working core p s l levelTape = l := by + simp [working, levelTape, powerNative, sizeNative, levelNative] + +theorem update_working_power (core : CoreTape → List Bool) (p s l p' : List Bool) : + Function.update (working core p s l) powerTape p' = working core p' s l := by + funext t + cases t with + | inl i => simp [working, powerTape] + | inr t => by_cases h : t = powerNative <;> simp [working, powerTape, h] + +theorem update_working_size (core : CoreTape → List Bool) (p s l s' : List Bool) : + Function.update (working core p s l) sizeTape s' = working core p s' l := by + funext t + cases t with + | inl i => simp [working, sizeTape] + | inr t => + by_cases h : t = sizeNative + · subst t; simp [working, sizeTape, powerNative, sizeNative] + · simp [working, sizeTape, h] + +theorem update_working_level (core : CoreTape → List Bool) (p s l l' : List Bool) : + Function.update (working core p s l) levelTape l' = working core p s l' := by + funext t + cases t with + | inl i => simp [working, levelTape] + | inr t => + by_cases h : t = levelNative + · subst t; simp [working, levelTape, powerNative, sizeNative, levelNative] + · simp [working, levelTape, h] + +@[simp] theorem working_empty (core : CoreTape → List Bool) : + working core [] [] [] = frame core := by + funext t; cases t <;> simp [working, frame] + +private theorem initial_other (k : Nat) (t : NativeTape) (h : t ≠ inputNative) : + MachinePaddedExpanderFamily.initialTapes k t = [] := by + cases t with + | inl t => rfl + | inr t => cases t <;> simp_all [MachinePaddedExpanderFamily.initialTapes, inputNative] + +private theorem final_other (H : SmallTable) (k : Nat) (t : NativeTape) + (hi : t ≠ inputNative) (ho : t ≠ outputNative) (hp : t ≠ powerNative) + (hs : t ≠ sizeNative) (hl : t ≠ levelNative) : + MachinePaddedExpanderFamily.finalTapes H k t = [] := by + rcases t with ((row | tableExtra) | familyExtra) | ceiling + · cases row <;> + simp_all [inputNative, outputNative, MachineExpanderFamily.tableTape, + MachinePaddedExpanderFamily.finalTapes, MachineExpanderFamily.toBoolTapes, + MachineExpanderFamily.toBoolWord, MachineExpanderFamily.familyTapes, + MachineExpanderFamily.boundaryTapes, MachineExpanderFamily.tableFrame, + MachineEmbedding.tapes] + · cases tableExtra <;> rfl + · cases familyExtra <;> + simp_all [sizeNative, levelNative, MachinePaddedExpanderFamily.finalTapes, + MachineExpanderFamily.toBoolTapes, MachineExpanderFamily.toBoolWord, + MachineExpanderFamily.familyTapes, MachineExpanderFamily.boundaryTapes, + MachineExpanderFamily.extraFrame, MachineEmbedding.tapes] + · cases ceiling <;> + simp_all [inputNative, powerNative, MachinePaddedExpanderFamily.finalTapes, + MachinePaddedExpanderFamily.retainedCeilingTapes, MachineCeilingPower.memory] + +theorem initial_placement (k : Nat) (core : CoreTape → List Bool) + (hinput : core 4 = encodeWord k) (houtput : core 7 = []) : + Placement.tapes familyView (MachinePaddedExpanderFamily.initialTapes k) (frame core) = + frame core := by + funext t + cases t with + | inl i => + by_cases hi : i = 4 + · subst i; simp [Placement.tapes, familyView, frame, inputNative, hinput] + · by_cases ho : i = 7 + · subst i + simp [Placement.tapes, familyView, frame, outputNative, + MachinePaddedExpanderFamily.initialTapes, houtput] + · simp [Placement.tapes, familyView, frame, hi, ho] + | inr t => + by_cases hi : t = inputNative + · simp [Placement.tapes, familyView, frame, hi] + · by_cases ho : t = outputNative + · simp [Placement.tapes, familyView, frame, ho] + · simp [Placement.tapes, familyView, frame, hi, ho, initial_other k t hi] + +theorem final_placement (H : SmallTable) (k : Nat) (core : CoreTape → List Bool) + (hinput : core 4 = encodeWord k) : + Placement.tapes familyView (MachinePaddedExpanderFamily.finalTapes H k) (frame core) = + working (resultCore H k core) + (encodeWord (PCP.PreprocessingLevels.paddedSize k)) + (encodeWord (PCP.PreprocessingLevels.paddedSize k)) (encodeWord 0) := by + funext t + cases t with + | inl i => + by_cases hi : i = 4 + · subst i + simp [Placement.tapes, familyView, working, resultCore, inputNative, hinput] + · by_cases ho : i = 7 + · subst i + simp [Placement.tapes, familyView, working, resultCore, outputNative, + rotor, MachinePaddedExpanderFamilyBounds.outputWord] + change MachinePaddedExpanderFamily.finalTapes H k + (MachinePaddedExpanderFamily.familyTape MachineExpanderFamily.tableTape) = _ + exact MachinePaddedExpanderFamily.finalTapes_table H k + · simp [Placement.tapes, familyView, working, resultCore, frame, hi, ho] + | inr t => + by_cases hi : t = inputNative + · subst t + simp [Placement.tapes, familyView, working, frame, + inputNative, powerNative, sizeNative, levelNative] + · by_cases ho : t = outputNative + · subst t + simp [Placement.tapes, familyView, working, frame, + outputNative, MachineExpanderFamily.tableTape, inputNative, + powerNative, sizeNative, levelNative] + · by_cases hp : t = powerNative + · subst t + simp [Placement.tapes, familyView, working, powerNative, inputNative, outputNative] + · by_cases hs : t = sizeNative + · subst t + simpa [Placement.tapes, familyView, working, sizeNative, + powerNative, inputNative, outputNative, MachineExpanderFamily.tableTape, + MachinePaddedExpanderFamily.familyTape] using + MachinePaddedExpanderFamily.finalTapes_currentSize H k + · by_cases hl : t = levelNative + · subst t + simpa [Placement.tapes, familyView, working, levelNative, + sizeNative, powerNative, inputNative, outputNative, + MachineExpanderFamily.tableTape, MachinePaddedExpanderFamily.ceilingTape] using + MachinePaddedExpanderFamily.finalTapes_remainingLevel H k + · simp [Placement.tapes, familyView, working, hi, ho, hp, hs, hl, + final_other H k t hi ho hp hs hl] + +@[simp] theorem source_initial_state (H : SmallTable) : + stateEquiv (MachinePaddedExpanderFamily.initialState (seedState H) none) = + readyState H := rfl + +@[simp] theorem source_final_state (H : SmallTable) : + stateEquiv (MachinePaddedExpanderFamily.finalState H (seedState H)) = + readyState H := by + simp [stateEquiv, MachinePaddedExpanderFamily.finalState, readyState, seedState] + +noncomputable def familyInTime (H : SmallTable) (k : Nat) (core : CoreTape → List Bool) + (hinput : core 4 = encodeWord k) (houtput : core 7 = []) : + StateTransition.EvalsToInTime (TM2.step (program H)) + ⟨some (.family MachinePaddedExpanderFamily.main), readyState H, frame core⟩ + (some ⟨some .drainPower, readyState H, + working (resultCore H k core) + (encodeWord (PCP.PreprocessingLevels.paddedSize k)) + (encodeWord (PCP.PreprocessingLevels.paddedSize k)) (encodeWord 0)⟩) + (MachinePaddedExpanderFamilyBounds.timePolynomial.eval (encodeWord k).length) := by + let raw := MachinePaddedExpanderFamily.paddedInTime H k (seedState H) none + let renamed := MachineStateEquiv.execution stateEquiv + (MachinePaddedExpanderFamily.program (ρ := Unit) H) raw + let placed := liftExecutionInTime (TM2.step (sourceProgram H)) (TM2.step (program H)) + (Placement.configuration familyView Label.family (some .drainPower) (frame core)) + (Placement.step_simulation familyTape familyView familyView_left familyView_right + Label.family (some .drainPower) (frame core) (sourceProgram H) (program H) + (fun _ => rfl)) renamed + simpa only [MachineStateEquiv.configuration, Placement.configuration, Placement.label, + source_initial_state, source_final_state, initial_placement k core hinput houtput, + final_placement H k core hinput] using placed + +theorem appendTrace {α : Type} (f : α → α) {a b : Nat} {x y z : α} + (hs : f^[a] x = y) (ht : f^[b] y = z) : f^[a+b] x = z := by + rw [Nat.add_comm a b, Function.iterate_add_apply, hs, ht] + +theorem cleanupTrace (H : SmallTable) (m : Nat) (core : CoreTape → List Bool) : + (advance (TM2.step (program H)))^[2*m+6] + (some ⟨some .drainPower, readyState H, + working core (encodeWord m) (encodeWord m) (encodeWord 0)⟩) = + some ⟨none, readyState H, frame core⟩ := by + have first := (MachineDrain.drainInTime powerTape .drainPower (some .drainSize) + (program H) rfl (working core (encodeWord m) (encodeWord m) (encodeWord 0)) + (seedState H, false) none).evals_in_steps + have second := (MachineDrain.drainInTime sizeTape .drainSize (some .drainLevel) + (program H) rfl (working core [] (encodeWord m) (encodeWord 0)) + (seedState H, false) none).evals_in_steps + have third := (MachineDrain.drainInTime levelTape .drainLevel none + (program H) rfl (working core [] [] (encodeWord 0)) + (seedState H, false) none).evals_in_steps + simp only [MachineDrain.drainInTime, working_power, working_size, working_level, + encodeWord_length, update_working_power, update_working_size, + update_working_level, working_empty] at first second third + have all := appendTrace _ (appendTrace _ first second) third + have count : 2*m+6 = (m+1+1)+(m+1+1)+(0+1+1) := by omega + rw [count] + exact all + +def cleanupInTime (H : SmallTable) (m : Nat) (core : CoreTape → List Bool) : + StateTransition.EvalsToInTime (TM2.step (program H)) + ⟨some .drainPower, readyState H, + working core (encodeWord m) (encodeWord m) (encodeWord 0)⟩ + (some ⟨none, readyState H, frame core⟩) (2*m+6) where + steps := 2*m+6 + evals_in_steps := cleanupTrace H m core + steps_le_m := le_rfl + +def startInTime (H : SmallTable) (core : CoreTape → List Bool) (state : State) : + StateTransition.EvalsToInTime (TM2.step (program H)) + ⟨some .start, state, frame core⟩ + (some ⟨some (.family MachinePaddedExpanderFamily.main), readyState H, frame core⟩) 1 where + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (program H .start) state (frame core)) = _ + rfl + steps_le_m := le_rfl + +noncomputable def timePolynomial : Polynomial Nat := + MachinePaddedExpanderFamilyBounds.timePolynomial + + Polynomial.C (2 * PCP.ExpanderFamily.growth) * Polynomial.X + 7 + +theorem totalBudget_le (k : Nat) : + 1 + MachinePaddedExpanderFamilyBounds.timePolynomial.eval (encodeWord k).length + + (2 * PCP.PreprocessingLevels.paddedSize k + 6) ≤ + timePolynomial.eval (encodeWord k).length := by + have hs := MachineExpanderFamilyBounds.paddedSize_le_succ_input k + have hm := Nat.mul_le_mul_left 2 hs + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat, encodeWord_length] + simp only [Nat.mul_assoc] at hm ⊢ + omega + +noncomputable def familyCleanInTime (H : SmallTable) (k : Nat) + (core : CoreTape → List Bool) (hinput : core 4 = encodeWord k) + (houtput : core 7 = []) (state : State) : + StateTransition.EvalsToInTime (TM2.step (program H)) + ⟨some .start, state, frame core⟩ + (some ⟨none, readyState H, frame (resultCore H k core)⟩) + (timePolynomial.eval (encodeWord k).length) := by + let first := startInTime H core state + let second := familyInTime H k core hinput houtput + let third := cleanupInTime H (PCP.PreprocessingLevels.paddedSize k) (resultCore H k core) + let pair := StateTransition.EvalsToInTime.trans (TM2.step (program H)) _ _ _ _ _ first second + let all := StateTransition.EvalsToInTime.trans (TM2.step (program H)) _ _ _ _ _ pair third + refine { toEvalsTo := all.toEvalsTo, steps_le_m := ?_ } + exact all.steps_le_m.trans + (by simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using totalBudget_le k) + +@[simp] theorem result_output (H : SmallTable) (k : Nat) (core : CoreTape → List Bool) : + frame (resultCore H k core) (.inl 7) = rotor H k := by simp [frame, resultCore] + +theorem result_preserves_core (H : SmallTable) (k : Nat) (core : CoreTape → List Bool) + (i : CoreTape) (hi : i ≠ 7) : frame (resultCore H k core) (.inl i) = core i := by + simp [frame, resultCore, hi] + +@[simp] theorem result_private_empty (H : SmallTable) (k : Nat) + (core : CoreTape → List Bool) (t : NativeTape) : + frame (resultCore H k core) (.inr t) = [] := rfl + +noncomputable def placedInTime {K Λ : Type} [DecidableEq K] + (tape : Tape → K) (view : K → Option Tape) + (left : ∀ t, view (tape t) = some t) + (right : ∀ j t, view j = some t → tape t = j) + (labels : Label → Λ) (exit : Option Λ) (extra : K → List Bool) + (H : SmallTable) (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ State) + (code : ∀ l, target (labels l) = Placement.statement tape labels exit (program H l)) + (k : Nat) (core : CoreTape → List Bool) (hinput : core 4 = encodeWord k) + (houtput : core 7 = []) (state : State) : + StateTransition.EvalsToInTime (TM2.step target) + (Placement.configuration view labels exit extra ⟨some .start, state, frame core⟩) + (some (Placement.configuration view labels exit extra + ⟨none, readyState H, frame (resultCore H k core)⟩)) + (timePolynomial.eval (encodeWord k).length) := + liftExecutionInTime (TM2.step (program H)) (TM2.step target) + (Placement.configuration view labels exit extra) + (Placement.step_simulation tape view left right labels exit extra (program H) target code) + (familyCleanInTime H k core hinput houtput state) + +end IndependentSetsGames.Foundations.Complexity.MachineRegularFamily + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularLift.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..3048395072b797d20d8777352ba3d36e78a9ccfb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularLift.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineStateEquiv +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudPadding +import OAI.Combinatorics.IndependentSets.Machines.MachineStateFrame + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTable + +open Turing MachineComposition + +namespace Lift + +open MachineCloudPadding + +variable {K K' Λ Λ' σ τ υ : Type} + +def statement (tape : K → K') (labels : Λ → Λ') (exit : Option Λ') + (registers : (σ × τ) ≃ υ) (q : TM2.Stmt (fun _ : K => Bool) Λ σ) : + TM2.Stmt (fun _ : K' => Bool) Λ' υ := + MachineStateEquiv.statement registers + (MachineStateFrame.frameStatement (Placement.statement tape labels exit q)) + +def configuration (view : K' → Option K) (labels : Λ → Λ') (exit : Option Λ') + (registers : (σ × τ) ≃ υ) (ambient : τ) (extra : K' → List Bool) + (c : TM2.Cfg (fun _ : K => Bool) Λ σ) : TM2.Cfg (fun _ : K' => Bool) Λ' υ := + ⟨Placement.label labels exit c.l, registers (c.var, ambient), + Placement.tapes view c.stk extra⟩ + +variable [DecidableEq K] [DecidableEq K'] + +theorem stepAux (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (labels : Λ → Λ') (exit : Option Λ') (registers : (σ × τ) ≃ υ) + (ambient : τ) (extra : K' → List Bool) + (q : TM2.Stmt (fun _ : K => Bool) Λ σ) (state : σ) (source : K → List Bool) : + TM2.stepAux (statement tape labels exit registers q) (registers (state, ambient)) + (Placement.tapes view source extra) = + configuration view labels exit registers ambient extra (TM2.stepAux q state source) := by + rw [statement, MachineStateEquiv.stepAux_transport, MachineStateFrame.frame_stepAux, + Placement.stepAux_simulation tape view left right] + rfl + +theorem step (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (labels : Λ → Λ') (exit : Option Λ') (registers : (σ × τ) ≃ υ) + (ambient : τ) (extra : K' → List Bool) + (source : Λ → TM2.Stmt (fun _ : K => Bool) Λ σ) + (target : Λ' → TM2.Stmt (fun _ : K' => Bool) Λ' υ) + (code : ∀ l, target (labels l) = statement tape labels exit registers (source l)) + (a b : TM2.Cfg (fun _ : K => Bool) Λ σ) (h : TM2.step source a = some b) : + TM2.step target (configuration view labels exit registers ambient extra a) = + some (configuration view labels exit registers ambient extra b) := by + cases a with + | mk label state sourceTapes => + cases label with + | none => simp [TM2.step] at h + | some label => + have hb : TM2.stepAux (source label) state sourceTapes = b := Option.some.inj h + rw [← hb] + change some (TM2.stepAux (target (labels label)) (registers (state, ambient)) + (Placement.tapes view sourceTapes extra)) = _ + rw [code, stepAux tape view left right] + +theorem trace (tape : K → K') (view : K' → Option K) + (left : ∀ k, view (tape k) = some k) + (right : ∀ j k, view j = some k → tape k = j) + (labels : Λ → Λ') (exit : Option Λ') (registers : (σ × τ) ≃ υ) + (ambient : τ) (extra : K' → List Bool) + (source : Λ → TM2.Stmt (fun _ : K => Bool) Λ σ) + (target : Λ' → TM2.Stmt (fun _ : K' => Bool) Λ' υ) + (code : ∀ l, target (labels l) = statement tape labels exit registers (source l)) + (steps : Nat) (a b : TM2.Cfg (fun _ : K => Bool) Λ σ) + (run : (advance (TM2.step source))^[steps] (some a) = some b) : + (advance (TM2.step target))^[steps] + (some (configuration view labels exit registers ambient extra a)) = + some (configuration view labels exit registers ambient extra b) := + liftSuccessfulTrace _ _ _ + (step tape view left right labels exit registers ambient extra source target code) steps a b run + +end Lift + +end IndependentSetsGames.Foundations.Complexity.MachineRegularTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularMetadata.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularMetadata.lean new file mode 100644 index 0000000000000000000000000000000000000000..b83fb6800ee588f95484c4a126262cc95f0f8ece --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularMetadata.lean @@ -0,0 +1,656 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudPrefix +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudRank +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalRow + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularMetadata + +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP + +inductive Extra | padding | level + deriving DecidableEq + +instance : Fintype Extra where + elems := {.padding, .level} + complete value := by cases value <;> simp + +abbrev Tape := Fin 27 ⊕ Extra +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := (σ × Bool) × Option Bool + +inductive Label + | owner (l : MachineAffineLookup.Label) + | ownerClearQuery | ownerClearWork + | copyXFirst | copyXSecond | copyOwnerFirst | copyOwnerSecond | rankInit + | rank (l : MachineCloudRank.RankLabel) + | rankClearQuery | rankClearWork | rankClearFuel + | prefixCode (l : MachineCloudPrefix.Label) + | prefixClearQuery | prefixClearFuel + | cloud (l : MachineCloudPadding.Label) + deriving DecidableEq, Fintype + +def ownerTapes : Fin 5 → Tape := ![.inl 0, .inl 9, .inl 10, .inl 2, .inl 11] + +def rankTape : MachineCloudCount.Tape → Tape + | .original => .inl 0 + | .work => .inl 10 + | .target => .inl 9 + | .scratch => .inl 11 + | .count => .inl 3 + | .spare => .inl 12 + +def prefixTape : MachineCloudPrefix.Tape → Tape + | .inner .table => .inl 0 + | .inner .query => .inl 9 + | .inner .count => .inl 10 + | .inner .work => .inl 11 + | .inner .scratch => .inl 12 + | .inner .spare => .inl 13 + | .inner .power => .inl 14 + | .inner .level => .inl 15 + | .inner .fuel => .inl 16 + | .inner .product => .inl 17 + | .bound => .inl 2 + | .remaining => .inl 18 + | .total => .inl 5 + +def cloudTape : MachineCloudPadding.Tape → Tape + | .table => .inl 0 + | .query => .inl 2 + | .count => .inl 4 + | .work => .inl 9 + | .scratch => .inl 10 + | .spare => .inl 11 + | .power => .inr .padding + | .level => .inr .level + | .fuel => .inl 12 + | .product => .inl 13 + +variable {σ : Type} + +def program : Label → TM2.Stmt Alphabet Label (State σ) + | .owner l => MachineAffineLookup.instruction (.inl 1) ownerTapes 4098 2 + Label.owner (some .ownerClearQuery) l + | .ownerClearQuery => MachineDrain.drain (.inl 9) .ownerClearQuery (some .ownerClearWork) + | .ownerClearWork => MachineDrain.drain (.inl 10) .ownerClearWork (some .copyXFirst) + | .copyXFirst => Reduction.MachineTransfer.loopAt (.inl 1) (.inl 10) id false + .copyXFirst (some .copyXSecond) + | .copyXSecond => MachineCopy.forkLoop (.inl 10) (.inl 1) (.inl 9) false + .copyXSecond (some .copyOwnerFirst) + | .copyOwnerFirst => Reduction.MachineTransfer.loopAt (.inl 2) (.inl 10) id false + .copyOwnerFirst (some .copyOwnerSecond) + | .copyOwnerSecond => MachineCopy.forkLoop (.inl 10) (.inl 2) (.inl 9) false + .copyOwnerSecond (some .rankInit) + | .rankInit => .push (.inl 3) (fun _ => false) (.goto fun _ => .rank .queryFirst) + | .rank l => MachineCloudPadding.Placement.statement rankTape Label.rank + (some .rankClearQuery) (MachineCloudRank.rankProgram l) + | .rankClearQuery => MachineDrain.drain (.inl 9) .rankClearQuery (some .rankClearWork) + | .rankClearWork => MachineDrain.drain (.inl 10) .rankClearWork (some .rankClearFuel) + | .rankClearFuel => MachineDrain.drain (.inl 12) .rankClearFuel (some (.prefixCode .init)) + | .prefixCode l => MachineCloudPadding.Placement.statement prefixTape Label.prefixCode + (some .prefixClearQuery) (MachineCloudPrefix.program l) + | .prefixClearQuery => MachineDrain.drain (.inl 9) .prefixClearQuery (some .prefixClearFuel) + | .prefixClearFuel => MachineDrain.drain (.inl 18) .prefixClearFuel (some (.cloud .init)) + | .cloud l => MachineCloudPadding.Placement.statement cloudTape Label.cloud none + (MachineCloudPadding.program l) + +def rankView : Tape → Option MachineCloudCount.Tape + | .inl i => match i.val with + | 0 => some .original + | 10 => some .work + | 9 => some .target + | 11 => some .scratch + | 3 => some .count + | 12 => some .spare + | _ => none + | .inr _ => none + +def prefixView : Tape → Option MachineCloudPrefix.Tape + | .inl i => match i.val with + | 0 => some (.inner .table) + | 9 => some (.inner .query) + | 10 => some (.inner .count) + | 11 => some (.inner .work) + | 12 => some (.inner .scratch) + | 13 => some (.inner .spare) + | 14 => some (.inner .power) + | 15 => some (.inner .level) + | 16 => some (.inner .fuel) + | 17 => some (.inner .product) + | 2 => some .bound + | 18 => some .remaining + | 5 => some .total + | _ => none + | .inr _ => none + +def cloudView : Tape → Option MachineCloudPadding.Tape + | .inl i => match i.val with + | 0 => some .table + | 2 => some .query + | 4 => some .count + | 9 => some .work + | 10 => some .scratch + | 11 => some .spare + | 12 => some .fuel + | 13 => some .product + | _ => none + | .inr .padding => some .power + | .inr .level => some .level + +theorem rankView_left (k : MachineCloudCount.Tape) : rankView (rankTape k) = some k := by + cases k <;> rfl +theorem rankView_right (j : Tape) (k : MachineCloudCount.Tape) + (h : rankView j = some k) : rankTape k = j := by + cases j with + | inl j => fin_cases j <;> simp_all [rankView, rankTape] <;> subst k <;> rfl + | inr j => simp_all [rankView] + +theorem prefixView_left (k : MachineCloudPrefix.Tape) : prefixView (prefixTape k) = some k := by + cases k with + | inner k => cases k <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl +theorem prefixView_right (j : Tape) (k : MachineCloudPrefix.Tape) + (h : prefixView j = some k) : prefixTape k = j := by + cases j with + | inl j => fin_cases j <;> simp_all [prefixView, prefixTape] <;> subst k <;> rfl + | inr j => simp_all [prefixView] + +theorem cloudView_left (k : MachineCloudPadding.Tape) : cloudView (cloudTape k) = some k := by + cases k <;> rfl +theorem cloudView_right (j : Tape) (k : MachineCloudPadding.Tape) + (h : cloudView j = some k) : cloudTape k = j := by + cases j with + | inl j => fin_cases j <;> simp_all [cloudView, cloudTape] <;> subst k <;> rfl + | inr j => cases j <;> simp_all [cloudView, cloudTape] <;> subst k <;> rfl + +structure Data where + table : List Bool + globalIndex : List Bool + owner : List Bool + localRank : List Bool + count : List Bool + offset : List Bool + darts : List Bool + rotor : List Bool + output : List Bool + padding : List Bool + level : List Bool + +def frame (data : Data) : Tape → List Bool + | .inl i => match i.val with + | 0 => data.table + | 1 => data.globalIndex + | 2 => data.owner + | 3 => data.localRank + | 4 => data.count + | 5 => data.offset + | 6 => data.darts + | 7 => data.rotor + | 8 => data.output + | _ => [] + | .inr .padding => data.padding + | .inr .level => data.level + +@[simp] theorem frame_index (data : Data) : + frame data (.inl 1) = data.globalIndex := rfl + +@[simp] theorem frame_query_empty (data : Data) : + frame data (.inl 9) = [] := rfl + +def cfg (label : Option Label) (data : Data) (ambient : σ) (register : Option Bool) : + TM2.Cfg Alphabet Label (State σ) := + ⟨label, ((ambient, false), register), frame data⟩ + +def cloudData (t : GraphTables.Table) (v : Fin t.vertices) (data : Data) : Data := + { data with + count := encodeWord (PreprocessingCloudIndex.cloudSize t v) + padding := encodeWord (MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t v)) + level := encodeWord (PreprocessingLevels.boundedLevel (PreprocessingCloudIndex.cloudSize t v)) } + +theorem cloudTrace (t : GraphTables.Table) (v : Fin t.vertices) (data : Data) + (htable : data.table = GraphTables.tableBits t) (howner : data.owner = encodeWord v.val) + (hcount : data.count = []) (hpadding : data.padding = []) (hlevel : data.level = []) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[MachineCloudPadding.totalTime t v] + (some (cfg (some (.cloud .init)) data ambient register)) = + some (cfg none (cloudData t v data) ambient none) := by + have raw := MachineCloudPadding.cloudPaddingTrace t v [] ambient register + simp only [List.append_nil] at raw + have placed := MachineCloudPadding.Placement.trace cloudTape cloudView cloudView_left cloudView_right + Label.cloud none (frame data) MachineCloudPadding.program program (fun _ => rfl) + (MachineCloudPadding.totalTime t v) _ _ raw + have hstart : MachineCloudPadding.Placement.tapes cloudView + (MachineCloudPadding.memory (GraphTables.tableBits t) (encodeWord v.val) + [] [] [] [] [] [] [] []) (frame data) = frame data := by + funext j + cases j with + | inl j => fin_cases j <;> + simp_all [MachineCloudPadding.Placement.tapes, cloudView, frame, MachineCloudPadding.memory] + | inr j => cases j <;> + simp_all [MachineCloudPadding.Placement.tapes, cloudView, frame, MachineCloudPadding.memory] + have hfinish : MachineCloudPadding.Placement.tapes cloudView + (MachineCloudPadding.memory (GraphTables.tableBits t) (encodeWord v.val) + (encodeWord (PreprocessingCloudIndex.cloudSize t v)) [] [] [] + (encodeWord (MachineCloudPadding.padding (PreprocessingCloudIndex.cloudSize t v))) + (encodeWord (PreprocessingLevels.boundedLevel (PreprocessingCloudIndex.cloudSize t v))) [] []) + (frame data) = frame (cloudData t v data) := by + funext j + cases j with + | inl j => fin_cases j <;> + simp_all [MachineCloudPadding.Placement.tapes, cloudView, frame, cloudData, MachineCloudPadding.memory] + | inr j => cases j <;> + simp_all [MachineCloudPadding.Placement.tapes, cloudView, frame, cloudData, MachineCloudPadding.memory] + simpa only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, + hstart, hfinish, cfg] using placed + +theorem join_trace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +private theorem drainAt (source : Tape) (again : Label) (exit : Option Label) + (code : program (σ := σ) again = MachineDrain.drain source again exit) + (base : Tape → List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[(base source).length + 1] + (some ⟨some again, ((ambient, false), register), base⟩) = + some ⟨exit, ((ambient, false), none), Function.update base source []⟩ := by + simpa only [Function.update_eq_self] using + MachineDrain.drainTrace source again exit program code base (base source) + (ambient, false) register + +def prefixData (t : GraphTables.Table) (v : Fin t.vertices) (data : Data) : Data := + { data with offset := encodeWord (PreprocessingPaddingOffsets.offset + (PreprocessingRegularTables.padding t) v.val) } + +def prefixSteps (t : GraphTables.Table) (v : Fin t.vertices) : Nat := + MachineCloudPrefix.totalTime t v.val [] + (v.val + 2) + 2 + +theorem prefixTrace (t : GraphTables.Table) (v : Fin t.vertices) (data : Data) + (htable : data.table = GraphTables.tableBits t) (howner : data.owner = encodeWord v.val) + (hoffset : data.offset = []) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[prefixSteps t v] + (some (cfg (some (.prefixCode .init)) data ambient register)) = + some (cfg (some (.cloud .init)) (prefixData t v data) ambient none) := by + have raw := MachineCloudPrefix.prefixTrace t v.val v.isLt.le [] ambient register + simp only [List.append_nil] at raw + let mid := MachineCloudPadding.Placement.tapes prefixView + (MachineCloudPrefix.frame (GraphTables.tableBits t) (encodeWord v.val) [] [] [] + (encodeWord v.val) (encodeWord 0) + (encodeWord (PreprocessingPaddingOffsets.offset + (PreprocessingRegularTables.padding t) v.val))) (frame data) + have placed := MachineCloudPadding.Placement.trace prefixTape prefixView prefixView_left + prefixView_right Label.prefixCode (some .prefixClearQuery) (frame data) + MachineCloudPrefix.program program (fun _ => rfl) + (MachineCloudPrefix.totalTime t v.val []) _ _ raw + have hstart : MachineCloudPadding.Placement.tapes prefixView + (MachineCloudPrefix.frame (GraphTables.tableBits t) [] [] [] [] (encodeWord v.val) [] []) + (frame data) = frame data := by + funext j + cases j with + | inl j => fin_cases j <;> + simp [htable, howner, hoffset, MachineCloudPadding.Placement.tapes, prefixView, frame, + MachineCloudPrefix.frame, MachineCloudPrefix.memory, MachineCloudPadding.memory] + | inr j => cases j <;> rfl + have phase : (advance (TM2.step program))^[MachineCloudPrefix.totalTime t v.val []] + (some (cfg (some (.prefixCode .init)) data ambient register)) = + some ⟨some .prefixClearQuery, ((ambient, false), none), mid⟩ := by + simpa only [MachineCloudPadding.Placement.configuration, + MachineCloudPadding.Placement.label, hstart, cfg, mid] using placed + have first := drainAt (.inl 9) .prefixClearQuery (some .prefixClearFuel) rfl mid ambient none + have second := drainAt (.inl 18) .prefixClearFuel (some (.cloud .init)) rfl + (Function.update mid (.inl 9) []) ambient none + have hquery : (mid (.inl 9)).length + 1 = v.val + 2 := by + simp [mid, MachineCloudPadding.Placement.tapes, prefixView, MachineCloudPrefix.frame, MachineCloudPrefix.memory, + MachineCloudPadding.memory, encodeWord_length] + have hfuel : ((Function.update mid (.inl 9) []) (.inl 18)).length + 1 = 2 := by + simp [mid, MachineCloudPadding.Placement.tapes, prefixView, MachineCloudPrefix.frame, MachineCloudPrefix.memory, + encodeWord_length] + have hfinish : Function.update (Function.update mid (.inl 9) []) (.inl 18) [] = + frame (prefixData t v data) := by + funext j + cases j with + | inl j => fin_cases j <;> + simp [htable, howner, mid, MachineCloudPadding.Placement.tapes, prefixView, frame, prefixData, + MachineCloudPrefix.frame, MachineCloudPrefix.memory, MachineCloudPadding.memory] + | inr j => cases j <;> rfl + rw [hquery] at first + rw [hfuel, hfinish] at second + exact join_trace (join_trace phase first) second + +theorem selected_owner (t : GraphTables.Table) (e : Fin t.darts) : + (GraphTables.tableWords t)[4098 * e.val + 2]? = some t.rows[e].tail.val := by + have h := congrArg (fun words : List Nat => words[0]?) + (MachineRegularOriginalRow.tableWords_drop_row t e) + simp only [List.getElem?_drop, Nat.add_zero] at h + rw [show 2 + 4098 * e.val = 4098 * e.val + 2 by omega] at h + simpa [GraphTables.rowWords] using h + +def ownerData (t : GraphTables.Table) (e : Fin t.darts) (data : Data) : Data := + { data with owner := encodeWord t.rows[e].tail.val } + +def ownerRemainder (t : GraphTables.Table) (e : Fin t.darts) : List Bool := + encodeWords ((GraphTables.tableWords t).drop (4098 * e.val + 2 + 1)) + +def ownerSteps (t : GraphTables.Table) (e : Fin t.darts) : Nat := + MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 2 + 2 + + ((ownerRemainder t e).length + 1) + +theorem ownerTrace (t : GraphTables.Table) (e : Fin t.darts) (data : Data) + (htable : data.table = GraphTables.tableBits t) + (hindex : data.globalIndex = encodeWord e.val) (howner : data.owner = []) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[ownerSteps t e] + (some (cfg (some (.owner .seed)) data ambient register)) = + some (cfg (some .copyXFirst) (ownerData t e data) ambient none) := by + have distinct : Function.Injective ownerTapes := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [ownerTapes] + have outside : ∀ i, (.inl 1 : Tape) ≠ ownerTapes i := by + intro i + fin_cases i <;> decide + let mid := MachineAffineLookup.finalTapes ownerTapes (frame data) + (GraphTables.tableWords t) (4098 * e.val + 2) t.rows[e].tail.val + have phase : (advance (TM2.step program))^[ + MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 2] + (some (cfg (some (.owner .seed)) data ambient register)) = + some ⟨some .ownerClearQuery, ((ambient, false), none), mid⟩ := by + exact MachineAffineLookup.affineLookupTrace (.inl 1) ownerTapes distinct outside 4098 2 + Label.owner (some .ownerClearQuery) program (fun _ => rfl) (frame data) + (GraphTables.tableWords t) htable rfl e.val [] + (by change data.globalIndex = encodeWord e.val ++ []; + simpa only [List.append_nil] using hindex) + t.rows[e].tail.val (selected_owner t e) (ambient, false) register + have first := drainAt (.inl 9) .ownerClearQuery (some .ownerClearWork) rfl mid ambient none + have second := drainAt (.inl 10) .ownerClearWork (some .copyXFirst) rfl + (Function.update mid (.inl 9) []) ambient none + have hquery : (mid (.inl 9)).length + 1 = 2 := by + simp [mid, MachineAffineLookup.finalTapes, MachinePreservingLookup.finalTapes, + MachineLookup.tapes, ownerTapes, frame, encodeWord_length] + have hwork : (Function.update mid (.inl 9) []) (.inl 10) = ownerRemainder t e := by + simp [mid, MachineAffineLookup.finalTapes, MachinePreservingLookup.finalTapes, + MachineLookup.tapes, ownerTapes, frame, ownerRemainder] + have hfinish : Function.update (Function.update mid (.inl 9) []) (.inl 10) [] = + frame (ownerData t e data) := by + funext j + cases j with + | inl j => fin_cases j <;> + simp [howner, mid, MachineAffineLookup.finalTapes, MachinePreservingLookup.finalTapes, + MachineLookup.tapes, ownerTapes, frame, ownerData] + | inr j => cases j <;> rfl + rw [hquery] at first + rw [hwork, hfinish] at second + exact join_trace (join_trace phase first) second + +def rankQuery (v x : Nat) : List Bool := MachineCloudRank.queryWord v x [] + +def queryFrame (data : Data) (v x : Nat) : Tape → List Bool := + Function.update (Function.update (frame data) (.inl 9) (rankQuery v x)) + (.inl 3) (encodeWord 0) + +def querySteps (v x : Nat) : Nat := 2 * (x + 2) + 2 * (v + 2) + 1 + +theorem queryTrace (data : Data) (v x : Nat) + (howner : data.owner = encodeWord v) (hindex : data.globalIndex = encodeWord x) + (hrank : data.localRank = []) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[querySteps v x] + (some (cfg (some .copyXFirst) data ambient register)) = + some ⟨some (.rank .queryFirst), ((ambient, false), none), queryFrame data v x⟩ := by + let first := Function.update (frame data) (.inl 9) data.globalIndex + let second := Function.update first (.inl 9) (data.owner ++ data.globalIndex) + have copyX := MachineCopy.copyTrace (.inl 1 : Tape) (.inl 9) (.inl 10) + (by decide) (by decide) (by decide) false Label.copyXFirst Label.copyXSecond + (some .copyOwnerFirst) program rfl rfl (frame data) rfl (ambient, false) register + have copyOwner := MachineCopy.copyTrace (.inl 2 : Tape) (.inl 9) (.inl 10) + (by decide) (by decide) (by decide) false Label.copyOwnerFirst Label.copyOwnerSecond + (some .rankInit) program rfl rfl first (by simp [first, frame]) (ambient, false) none + have firstRun : (advance (TM2.step program))^[2 * (x + 2)] + (some (cfg (some .copyXFirst) data ambient register)) = + some ⟨some .copyOwnerFirst, ((ambient, false), none), first⟩ := by + simpa only [frame_index, frame_query_empty, hindex, encodeWord_length, + List.append_nil, cfg, first] using copyX + have secondRun : (advance (TM2.step program))^[2 * (v + 2)] + (some ⟨some .copyOwnerFirst, ((ambient, false), none), first⟩) = + some ⟨some .rankInit, ((ambient, false), none), second⟩ := by + simpa [first, frame, howner, encodeWord_length, second] using copyOwner + have init : (advance (TM2.step program))^[1] + (some ⟨some .rankInit, ((ambient, false), none), second⟩) = + some ⟨some (.rank .queryFirst), ((ambient, false), none), queryFrame data v x⟩ := by + have ht : Function.update second (.inl 3) (false :: second (.inl 3)) = + queryFrame data v x := by + funext j + cases j with + | inl j => fin_cases j <;> + simp_all [queryFrame, second, first, frame, rankQuery, + MachineCloudRank.queryWord, encodeWord] + | inr j => cases j <;> rfl + simp only [Function.iterate_one, advance_some, TM2.step, program, TM2.stepAux, ht] + exact join_trace (join_trace firstRun secondRun) init + +def rankData (t : GraphTables.Table) (v : Fin t.vertices) + (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) (data : Data) : Data := + { data with localRank := encodeWord (PreprocessingCloudIndex.cloudRank t v e).val } + +def rankRemainder (t : GraphTables.Table) + (v : Fin t.vertices) (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) : List Bool := + encodeWords (((MachineCloudCount.tableRows t).drop e.val.val).flatMap MachineCloudCount.rowWords) + +def rankSteps (t : GraphTables.Table) (v : Fin t.vertices) + (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) : Nat := + querySteps v.val e.val.val + + MachineCloudRank.rankSteps t.vertices t.darts v.val e.val.val (MachineCloudCount.tableRows t) [] + + ((rankQuery v.val e.val.val).length + 1) + ((rankRemainder t v e).length + 1) + 2 + +theorem rankTrace (t : GraphTables.Table) (v : Fin t.vertices) + (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) (data : Data) + (htable : data.table = GraphTables.tableBits t) + (howner : data.owner = encodeWord v.val) (hindex : data.globalIndex = encodeWord e.val.val) + (hrank : data.localRank = []) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[rankSteps t v e] + (some (cfg (some .copyXFirst) data ambient register)) = + some (cfg (some (.prefixCode .init)) (rankData t v e data) ambient none) := by + have query := queryTrace data v.val e.val.val howner hindex hrank ambient register + have raw := MachineCloudRank.cloudRankTrace t v e [] [] ambient none + simp only [List.append_nil] at raw + let mid := MachineCloudPadding.Placement.tapes rankView + (MachineCloudCount.memory (GraphTables.tableBits t) (rankRemainder t v e) + (rankQuery v.val e.val.val) [] + (encodeWord (PreprocessingCloudIndex.cloudRank t v e).val) (encodeWord 0)) (frame data) + have placed := MachineCloudPadding.Placement.trace rankTape rankView rankView_left + rankView_right Label.rank (some .rankClearQuery) (frame data) + MachineCloudRank.rankProgram program (fun _ => rfl) + (MachineCloudRank.rankSteps t.vertices t.darts v.val e.val.val (MachineCloudCount.tableRows t) []) + _ _ raw + have hstart : MachineCloudPadding.Placement.tapes rankView + (MachineCloudCount.memory (GraphTables.tableBits t) [] + (rankQuery v.val e.val.val) [] (encodeWord 0) []) (frame data) = + queryFrame data v.val e.val.val := by + funext j + cases j with + | inl j => fin_cases j <;> + simp_all [MachineCloudPadding.Placement.tapes, rankView, frame, + queryFrame, MachineCloudCount.memory] + | inr j => cases j <;> rfl + simp only [rankQuery] at hstart + have phase : (advance (TM2.step program))^[ + MachineCloudRank.rankSteps t.vertices t.darts v.val e.val.val (MachineCloudCount.tableRows t) []] + (some ⟨some (.rank .queryFirst), ((ambient, false), none), queryFrame data v.val e.val.val⟩) = + some ⟨some .rankClearQuery, ((ambient, false), none), mid⟩ := by + simpa only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, + hstart, mid, rankQuery, rankRemainder] using placed + have first := drainAt (.inl 9) .rankClearQuery (some .rankClearWork) rfl mid ambient none + have second := drainAt (.inl 10) .rankClearWork (some .rankClearFuel) rfl + (Function.update mid (.inl 9) []) ambient none + have third := drainAt (.inl 12) .rankClearFuel (some (.prefixCode .init)) rfl + (Function.update (Function.update mid (.inl 9) []) (.inl 10) []) ambient none + have hquery : mid (.inl 9) = rankQuery v.val e.val.val := rfl + have hwork : Function.update mid (.inl 9) [] (.inl 10) = rankRemainder t v e := by + simp [mid, MachineCloudPadding.Placement.tapes, rankView, MachineCloudCount.memory] + have hfuel : ((Function.update (Function.update mid (.inl 9) []) (.inl 10) []) + (.inl 12)).length + 1 = 2 := by + simp [mid, MachineCloudPadding.Placement.tapes, rankView, MachineCloudCount.memory, + encodeWord_length] + have hfinish : Function.update + (Function.update (Function.update mid (.inl 9) []) (.inl 10) []) (.inl 12) [] = + frame (rankData t v e data) := by + funext j + cases j with + | inl j => fin_cases j <;> + simp [mid, MachineCloudPadding.Placement.tapes, rankView, frame, rankData, + MachineCloudCount.memory, htable, howner, hindex] + | inr j => cases j <;> rfl + rw [hquery] at first + rw [hwork] at second + rw [hfuel, hfinish] at third + exact join_trace (join_trace (join_trace (join_trace query phase) first) second) third + +def originalMember (t : GraphTables.Table) (e : Fin t.darts) : + DegreeReplacement.Cloud (GraphTables.semantics t) t.rows[e].tail := ⟨e, rfl⟩ + +def originalData (t : GraphTables.Table) (e : Fin t.darts) (data : Data) : Data := + cloudData t t.rows[e].tail (prefixData t t.rows[e].tail + (rankData t t.rows[e].tail (originalMember t e) (ownerData t e data))) + +def totalTime (t : GraphTables.Table) (e : Fin t.darts) : Nat := + ownerSteps t e + rankSteps t t.rows[e].tail (originalMember t e) + + prefixSteps t t.rows[e].tail + MachineCloudPadding.totalTime t t.rows[e].tail + +theorem originalTrace (t : GraphTables.Table) (e : Fin t.darts) (data : Data) + (htable : data.table = GraphTables.tableBits t) + (hindex : data.globalIndex = encodeWord e.val) + (howner : data.owner = []) (hrank : data.localRank = []) (hcount : data.count = []) + (hoffset : data.offset = []) (hpadding : data.padding = []) (hlevel : data.level = []) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[totalTime t e] + (some (cfg (some (.owner .seed)) data ambient register)) = + some (cfg none (originalData t e data) ambient none) := by + have own := ownerTrace t e data htable hindex howner ambient register + have rank := rankTrace t t.rows[e].tail (originalMember t e) (ownerData t e data) + htable rfl hindex hrank ambient none + have pref := prefixTrace t t.rows[e].tail + (rankData t t.rows[e].tail (originalMember t e) (ownerData t e data)) + htable rfl hoffset ambient none + have cloud := cloudTrace t t.rows[e].tail + (prefixData t t.rows[e].tail + (rankData t t.rows[e].tail (originalMember t e) (ownerData t e data))) + htable rfl hcount hpadding hlevel ambient none + exact join_trace (join_trace (join_trace own rank) pref) cloud + +private theorem encodeWords_drop_length_le (values : List Nat) (n : Nat) : + (encodeWords (values.drop n)).length ≤ (encodeWords values).length := by + have h := congrArg (fun words : List Nat => (encodeWords words).length) + (List.take_append_drop n values) + simp only [encodeWords_append, List.length_append] at h + omega + +theorem ownerRemainder_length_le (t : GraphTables.Table) (e : Fin t.darts) : + (ownerRemainder t e).length ≤ (GraphTables.tableBits t).length := + encodeWords_drop_length_le _ _ + +theorem rankRemainder_length_le (t : GraphTables.Table) (v : Fin t.vertices) + (e : DegreeReplacement.Cloud (GraphTables.semantics t) v) : + (rankRemainder t v e).length ≤ (GraphTables.tableBits t).length := by + have split := congrArg List.length + (MachineCloudRank.encoded_rows_split (MachineCloudCount.tableRows t) e.val.val) + have input := MachineCloudCount.inputWord_length t.vertices t.darts (MachineCloudCount.tableRows t) + rw [MachineCloudCount.tableRows_input] at input + simp only [List.length_append] at split + unfold rankRemainder + omega + +noncomputable def timePolynomial : Polynomial Nat := + (MachineCloudPrefix.timePolynomial + MachineCloudPadding.timePolynomial).comp + (2 * Polynomial.X) + 40 * (Polynomial.X + 1) + +def overhead (N x v : Nat) : Nat := + (2*x + 5*N + 6) + 2 + (N+1) + 2*(x+2) + 2*(v+2) + 1 + + (5*N + 3*(v+x+2) + 6) + (v+x+3) + (N+1) + 2 + (v+2) + 2 + +theorem overhead_le (N x v : Nat) (hx : x ≤ N) (hv : v ≤ N) : + overhead N x v ≤ 40*(N+1) := by + unfold overhead + omega + +theorem totalTime_le (t : GraphTables.Table) (e : Fin t.darts) : + totalTime t e ≤ timePolynomial.eval (GraphTables.tableBits t).length := by + let v := t.rows[e].tail + let c := originalMember t e + let N := (GraphTables.tableBits t).length + have hn := GraphTables.vertices_le_tableBits_length t + have hm := GraphTables.darts_le_tableBits_length t + have hv : v.val < N := lt_of_lt_of_le v.isLt hn + have hx : e.val ≤ N := e.isLt.le.trans hm + have ownerBound := MachineAffineLookup.steps_le (GraphTables.tableWords t) + e.val 4098 2 t.rows[e].tail.val (selected_owner t e) + have ownerRest := ownerRemainder_length_le t e + have rankBound := MachineCloudRank.rankSteps_le t.vertices t.darts v.val e.val + (MachineCloudCount.tableRows t) [] + rw [MachineCloudCount.tableRows_input] at rankBound + have rankRest := rankRemainder_length_le t v c + have hpIn : MachineCloudPrefix.inputLength t v.val [] ≤ 2*N := by + simp only [MachineCloudPrefix.inputLength, List.append_nil, encodeWord_length] + omega + have hcIn : MachineCloudPadding.inputLength t v [] ≤ 2*N := by + simp only [MachineCloudPadding.inputLength, List.append_nil, encodeWord_length] + omega + have hp := (MachineCloudPrefix.totalTime_le t v.val v.isLt.le []).trans + (natPolynomial_eval_mono MachineCloudPrefix.timePolynomial hpIn) + have hc := (MachineCloudPadding.totalTime_le t v []).trans + (natPolynomial_eval_mono MachineCloudPadding.timePolynomial hcIn) + have ho := overhead_le N e.val v.val hx hv.le + have hsmall : ownerSteps t e + rankSteps t v c + (v.val+2) + 2 ≤ + overhead N e.val v.val := by + simp only [MachineCloudRank.queryWord, List.length_append, encodeWord_length, + List.length_nil] at rankBound + simp only [ownerSteps, rankSteps, querySteps, rankQuery, MachineCloudRank.queryWord, + List.length_append, encodeWord_length, List.length_nil, overhead] + change _ ≤ _ at ownerBound + dsimp only [c, originalMember] at rankRest ⊢ + change MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 2 ≤ + 2*e.val+5*N+6 at ownerBound + omega + have htotal : totalTime t e = ownerSteps t e + rankSteps t v c + + MachineCloudPrefix.totalTime t v.val [] + (v.val+2) + 2 + + MachineCloudPadding.totalTime t v := by + simp only [totalTime, prefixSteps, v, c] + omega + rw [htotal] + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_comp, + Polynomial.eval_mul, Polynomial.eval_ofNat, Polynomial.eval_X, Polynomial.eval_one] + change _ ≤ MachineCloudPrefix.timePolynomial.eval (2*N) + + MachineCloudPadding.timePolynomial.eval (2*N) + 40*(N+1) + omega + +def originalInTime (t : GraphTables.Table) (e : Fin t.darts) (data : Data) + (htable : data.table = GraphTables.tableBits t) + (hindex : data.globalIndex = encodeWord e.val) + (howner : data.owner = []) (hrank : data.localRank = []) (hcount : data.count = []) + (hoffset : data.offset = []) (hpadding : data.padding = []) (hlevel : data.level = []) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + (cfg (some (.owner .seed)) data ambient register) + (some (cfg none (originalData t e data) ambient none)) + (timePolynomial.eval (GraphTables.tableBits t).length) where + steps := totalTime t e + evals_in_steps := originalTrace t e data htable hindex howner hrank hcount hoffset + hpadding hlevel ambient register + steps_le_m := totalTime_le t e + +def cloudInTime (t : GraphTables.Table) (v : Fin t.vertices) (data : Data) + (htable : data.table = GraphTables.tableBits t) (howner : data.owner = encodeWord v.val) + (hcount : data.count = []) (hpadding : data.padding = []) (hlevel : data.level = []) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + (cfg (some (.cloud .init)) data ambient register) + (some (cfg none (cloudData t v data) ambient none)) + (MachineCloudPadding.timePolynomial.eval (MachineCloudPadding.inputLength t v [])) where + steps := MachineCloudPadding.totalTime t v + evals_in_steps := cloudTrace t v data htable howner hcount hpadding hlevel ambient register + steps_le_m := MachineCloudPadding.totalTime_le t v [] + +end IndependentSetsGames.Foundations.Complexity.MachineRegularMetadata + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalBody.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..1055fa58c35a46e521d01c1dfc4c04b6c4bdee9e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalBody.lean @@ -0,0 +1,401 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularLift +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularMetadata +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularFamily +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularVertexBlock +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingFamilyBridge + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalBody + +open Turing MachineComposition PCP +open PreprocessingCloudIndex PreprocessingRegularTables +open MachineRegularTable + +abbrev Tape := Fin 27 ⊕ (MachineRegularMetadata.Extra ⊕ MachinePaddedExpanderFamily.Tape) +abbrev Alphabet (_ : Tape) := Bool +abbrev CoreState := MachineRegularInternalRow.CoreState Unit internalDegree +abbrev MetaState := MachineRegularMetadata.State Unit +abbrev FamilyState := MachineRegularFamily.State +abbrev State := (CoreState × MetaState) × FamilyState +abbrev Data := MachineRegularMetadata.Data +abbrev BaseTable := PreprocessingRegularTables.BaseTable + +theorem degree_positive : 0 < internalDegree := + Nat.mul_pos MachineExpanderFamily.baseDegree_positive MachineExpanderFamily.baseDegree_positive + +def readyState (H : BaseTable) : State := + ((MachineRegularInternalRow.coreInitialState internalDegree degree_positive (), + (((), false), none)), MachineRegularFamily.readyState H) + +def metadataTape : MachineRegularMetadata.Tape → Tape + | .inl i => .inl i + | .inr e => .inr (.inl e) + +def metadataView : Tape → Option MachineRegularMetadata.Tape + | .inl i => some (.inl i) + | .inr (.inl e) => some (.inr e) + | .inr (.inr _) => none + +def familyTape : MachineRegularFamily.Tape → Tape + | .inl i => .inl i + | .inr e => .inr (.inr e) + +def familyView : Tape → Option MachineRegularFamily.Tape + | .inl i => some (.inl i) + | .inr (.inl _) => none + | .inr (.inr e) => some (.inr e) + +def vertexView : Tape → Option (Fin 27) + | .inl i => some i + | .inr _ => none + +theorem metadataView_left (k : MachineRegularMetadata.Tape) : + metadataView (metadataTape k) = some k := by cases k <;> rfl + +theorem metadataView_right (j : Tape) (k : MachineRegularMetadata.Tape) + (h : metadataView j = some k) : metadataTape k = j := by + cases j with + | inl i => cases h; rfl + | inr j => cases j with + | inl e => cases h; rfl + | inr e => cases h + +theorem familyView_left (k : MachineRegularFamily.Tape) : + familyView (familyTape k) = some k := by cases k <;> rfl + +theorem familyView_right (j : Tape) (k : MachineRegularFamily.Tape) + (h : familyView j = some k) : familyTape k = j := by + cases j with + | inl i => cases h; rfl + | inr j => cases j with + | inl e => cases h + | inr e => cases h; rfl + +theorem vertexView_left (k : Fin 27) : vertexView (.inl k) = some k := rfl + +theorem vertexView_right (j : Tape) (k : Fin 27) + (h : vertexView j = some k) : Sum.inl k = j := by + cases j with + | inl i => cases h; rfl + | inr e => cases h + +def metadataStates : (MetaState × (CoreState × FamilyState)) ≃ State where + toFun p := ((p.2.1, p.1), p.2.2) + invFun p := (p.1.2, (p.1.1, p.2)) + left_inv _ := rfl + right_inv _ := rfl + +def familyStates : (FamilyState × (CoreState × MetaState)) ≃ State := Equiv.prodComm _ _ +def vertexStates : (CoreState × (MetaState × FamilyState)) ≃ State := + (Equiv.prodAssoc _ _ _).symm + +inductive Label + | metadata (l : MachineRegularMetadata.Label) + | family (l : MachineRegularFamily.Label) + | vertex (l : MachineRegularVertexBlock.Label internalDegree) + | clear (i : Fin 7) + deriving DecidableEq, Fintype + +def entry : Label := .metadata (.owner .seed) + +def clearTape : Fin 7 → Tape := + ![.inl 2, .inl 3, .inl 4, .inl 5, .inl 7, + .inr (.inl .padding), .inr (.inl .level)] + +def clearEntry (k : Nat) : Option Label := + if h : k < 7 then some (.clear ⟨k, h⟩) else none + +def clearSource (source : Tape) : Unit → TM2.Stmt Alphabet Unit MetaState := + fun _ => MachineDrain.drain source () none + +def vertexSource : MachineRegularVertexBlock.Label internalDegree → + TM2.Stmt (fun _ : Fin 27 => Bool) (MachineRegularVertexBlock.Label internalDegree) CoreState := + MachineRegularVertexBlock.instruction internalDegree degree_positive id none + +def program (H : BaseTable) : Label → TM2.Stmt Alphabet Label State + | .metadata l => Lift.statement metadataTape Label.metadata (some (.family .start)) + metadataStates (MachineRegularMetadata.program l) + | .family l => Lift.statement familyTape Label.family + (some (.vertex (MachineRegularVertexBlock.originalEntry internalDegree degree_positive))) + familyStates (MachineRegularFamily.program H l) + | .vertex l => Lift.statement Sum.inl Label.vertex (clearEntry 0) + vertexStates (vertexSource l) + | .clear i => Lift.statement id (fun _ : Unit => .clear i) (clearEntry (i.val + 1)) + metadataStates (clearSource (clearTape i) ()) + +def frame (data : Data) : Tape → List Bool + | .inl i => MachineRegularMetadata.frame data (.inl i) + | .inr (.inl e) => MachineRegularMetadata.frame data (.inr e) + | .inr (.inr _) => [] + +def coreFrame (data : Data) (i : Fin 27) : List Bool := + MachineRegularMetadata.frame data (.inl i) + +def cfg (H : BaseTable) (label : Option Label) (data : Data) : TM2.Cfg Alphabet Label State := + ⟨label, readyState H, frame data⟩ + +def initialData (t : GraphTables.Table) (e : Fin t.darts) (output : List Bool) : Data where + table := GraphTables.tableBits t + globalIndex := encodeWord e.val + owner := [] + localRank := [] + count := [] + offset := [] + darts := encodeWord t.darts + rotor := [] + output := output + padding := [] + level := [] + +def metadataData (t : GraphTables.Table) (e : Fin t.darts) (output : List Bool) : Data := + MachineRegularMetadata.originalData t e (initialData t e output) + +def familyData (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : Data := + { metadataData t e output with + rotor := MachineRegularFamily.rotor H (cloudSize t t.rows[e].tail) } + +def emittedBits (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) : List Bool := + PreprocessingRegularWords.originalVertexBits t (padding t) (familyCloudTable H t) e + +def emittedData (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : Data := + { familyData H t e output with output := output ++ emittedBits H t e } + +theorem joinTrace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +theorem metadataPlacement (data extra : Data) : + MachineCloudPadding.Placement.tapes metadataView (MachineRegularMetadata.frame data) + (frame extra) = frame data := by + funext j + cases j with + | inl i => rfl + | inr j => cases j <;> rfl + +theorem metadataTrace (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + (advance (TM2.step (program H)))^[MachineRegularMetadata.totalTime t e] + (some (cfg H (some entry) (initialData t e output))) = + some (cfg H (some (.family .start)) (metadataData t e output)) := by + have raw := MachineRegularMetadata.originalTrace t e (initialData t e output) + rfl rfl rfl rfl rfl rfl rfl rfl () none + have placed := Lift.trace metadataTape metadataView metadataView_left metadataView_right + Label.metadata (some (.family .start)) metadataStates + (MachineRegularInternalRow.coreInitialState internalDegree degree_positive (), + MachineRegularFamily.readyState H) (frame (initialData t e output)) + MachineRegularMetadata.program (program H) (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, + metadataPlacement, MachineRegularMetadata.cfg, metadataData, cfg, readyState, + metadataStates, Equiv.coe_fn_mk, entry] using placed + +theorem familyPlacement (data : Data) : + MachineCloudPadding.Placement.tapes familyView (MachineRegularFamily.frame (coreFrame data)) + (frame data) = frame data := by + funext j + cases j with + | inl i => rfl + | inr j => cases j <;> rfl + +theorem familyResultPlacement (H : BaseTable) (k : Nat) (data : Data) : + MachineCloudPadding.Placement.tapes familyView + (MachineRegularFamily.frame (MachineRegularFamily.resultCore H k (coreFrame data))) + (frame data) = frame { data with rotor := MachineRegularFamily.rotor H k } := by + funext j + cases j with + | inl i => fin_cases i <;> + simp [MachineCloudPadding.Placement.tapes, familyView, MachineRegularFamily.frame, + MachineRegularFamily.resultCore, coreFrame, frame, MachineRegularMetadata.frame] + | inr j => cases j with + | inl e => cases e <;> rfl + | inr e => rfl + +noncomputable def familyExecution (H : BaseTable) (t : GraphTables.Table) + (e : Fin t.darts) (output : List Bool) := + MachineRegularFamily.familyCleanInTime H (cloudSize t t.rows[e].tail) + (coreFrame (metadataData t e output)) rfl rfl (MachineRegularFamily.readyState H) + +noncomputable def familySteps (H : BaseTable) (t : GraphTables.Table) + (e : Fin t.darts) (output : List Bool) : Nat := + (familyExecution H t e output).steps + +theorem familyTrace (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + (advance (TM2.step (program H)))^[familySteps H t e output] + (some (cfg H (some (.family .start)) (metadataData t e output))) = + some (cfg H (some (.vertex (MachineRegularVertexBlock.originalEntry + internalDegree degree_positive))) (familyData H t e output)) := by + have raw := (familyExecution H t e output).evals_in_steps + have placed := Lift.trace familyTape familyView familyView_left familyView_right + Label.family (some (.vertex (MachineRegularVertexBlock.originalEntry internalDegree degree_positive))) + familyStates + (MachineRegularInternalRow.coreInitialState internalDegree degree_positive (), + ((((), false), none) : MetaState)) (frame (metadataData t e output)) + (MachineRegularFamily.program H) (program H) (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, + familyPlacement, familyResultPlacement, familyData, familySteps, cfg, readyState, + familyStates, Equiv.prodComm_apply, Prod.swap_prod_mk] using placed + +def clearMemory (base : Tape → List Bool) : Nat → Tape → List Bool + | 0 => base + | k + 1 => if h : k < 7 then + Function.update (clearMemory base k) (clearTape ⟨k, h⟩) [] else clearMemory base k + +def clearSteps (base : Tape → List Bool) : Nat → Nat + | 0 => 0 + | k + 1 => clearSteps base k + if h : k < 7 then + ((clearMemory base k) (clearTape ⟨k, h⟩)).length + 1 else 0 + +private theorem identityPlacement (base extra : Tape → List Bool) : + MachineCloudPadding.Placement.tapes some base extra = base := rfl + +theorem drainTrace (H : BaseTable) (i : Fin 7) (base : Tape → List Bool) : + (advance (TM2.step (program H)))^[(base (clearTape i)).length + 1] + (some ⟨some (.clear i), readyState H, base⟩) = + some ⟨clearEntry (i.val + 1), readyState H, Function.update base (clearTape i) []⟩ := by + have raw := MachineDrain.drainTrace (clearTape i) () none (clearSource (clearTape i)) rfl + base (base (clearTape i)) ((), false) none + simp only [Function.update_eq_self] at raw + have placed := Lift.trace id some (fun _ => rfl) + (fun j k h => (Option.some.inj h).symm) + (fun _ : Unit => Label.clear i) (clearEntry (i.val + 1)) metadataStates + (MachineRegularInternalRow.coreInitialState internalDegree degree_positive (), + MachineRegularFamily.readyState H) base (clearSource (clearTape i)) (program H) + (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, + identityPlacement, metadataStates, Equiv.coe_fn_mk, readyState] using placed + +theorem clearPrefixTrace (H : BaseTable) (base : Tape → List Bool) + (k : Nat) (hk : k ≤ 7) : + (advance (TM2.step (program H)))^[clearSteps base k] + (some ⟨clearEntry 0, readyState H, base⟩) = + some ⟨clearEntry k, readyState H, clearMemory base k⟩ := by + induction k with + | zero => rfl + | succ k ih => + have h : k < 7 := by omega + have first := ih (by omega) + have second := drainTrace H ⟨k, h⟩ (clearMemory base k) + have atEntry : clearEntry k = some (.clear ⟨k, h⟩) := by simp only [clearEntry, dite_eq_left h] + rw [atEntry] at first + simpa only [clearSteps, clearMemory, dite_eq_left h] using joinTrace first second + +theorem clearTrace (H : BaseTable) (base : Tape → List Bool) : + (advance (TM2.step (program H)))^[clearSteps base 7] + (some ⟨clearEntry 0, readyState H, base⟩) = + some ⟨none, readyState H, clearMemory base 7⟩ := by + simpa only [clearEntry, lt_self_iff_false, dite_false] using clearPrefixTrace H base 7 le_rfl + +theorem clearFrame (data : Data) : clearMemory (frame data) 7 = + frame { data with + owner := [] + localRank := [] + count := [] + offset := [] + rotor := [] + padding := [] + level := [] } := by + funext j + cases j with + | inl i => fin_cases i <;> + simp [clearMemory, clearTape, frame, MachineRegularMetadata.frame] + | inr j => cases j with + | inl e => cases e <;> + simp [clearMemory, clearTape, frame, MachineRegularMetadata.frame] + | inr e => simp [clearMemory, clearTape, frame] + +theorem coreFrame_eq (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + coreFrame (familyData H t e output) = + MachineRegularInternalRow.coreInputTapes t (padding t) (familyCloudTable H t) + t.rows[e].tail (MachineRegularVertexBlock.oldCloud t (padding t) e) output := by + have rotor : MachineRegularFamily.rotor H (cloudSize t t.rows[e].tail) = + encodeWords (ExpanderTableWords.rotationWords (familyCloudTable H t t.rows[e].tail)) := + PreprocessingFamilyBridge.familyRotor_eq_familyCloudTable H t t.rows[e].tail + (PreprocessingFamilyBridge.cloudSize_pos_of_dart t e) + funext i + fin_cases i <;> + simp [coreFrame, familyData, metadataData, MachineRegularMetadata.originalData, + MachineRegularMetadata.cloudData, MachineRegularMetadata.prefixData, + MachineRegularMetadata.rankData, MachineRegularMetadata.ownerData, + MachineRegularMetadata.frame, initialData, + MachineRegularInternalRow.coreInputTapes, MachineRegularInternalRow.coreMemory, + MachineRegularVertexBlock.oldCloud, paddedOld, + MachineRegularMetadata.originalMember] + all_goals first | exact rotor | rfl + +theorem emittedData_eq (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : emittedData H t e output = + familyData H t e (output ++ emittedBits H t e) := rfl + +theorem vertexPlacement (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output output' : List Bool) : + MachineCloudPadding.Placement.tapes vertexView (coreFrame (familyData H t e output')) + (frame (familyData H t e output)) = frame (familyData H t e output') := by + funext j + cases j with + | inl i => rfl + | inr j => cases j with + | inl e => cases e <;> rfl + | inr e => rfl + +def vertexSteps (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : Nat := + MachineRegularVertexBlock.originalSteps t (padding t) (familyCloudTable H t) e output.length + +theorem vertexTrace (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + (advance (TM2.step (program H)))^[vertexSteps H t e output] + (some (cfg H (some (.vertex (MachineRegularVertexBlock.originalEntry + internalDegree degree_positive))) (familyData H t e output))) = + some (cfg H (clearEntry 0) (emittedData H t e output)) := by + have raw := MachineRegularVertexBlock.originalTraceAt internalDegree degree_positive id none + vertexSource (fun _ => rfl) t (padding t) (familyCloudTable H t) e output () + have finished := coreFrame_eq H t e (output ++ emittedBits H t e) + simp only [emittedBits] at finished + rw [← coreFrame_eq H t e output, ← finished] at raw + have placed := Lift.trace Sum.inl vertexView vertexView_left vertexView_right + Label.vertex (clearEntry 0) vertexStates + (((((), false), none) : MetaState), MachineRegularFamily.readyState H) + (frame (familyData H t e output)) vertexSource (program H) (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, vertexPlacement, + emittedData_eq, cfg, readyState, vertexStates, Equiv.prodAssoc_symm_apply, + vertexSteps, emittedBits, id_eq] using placed + +noncomputable def totalSteps (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : Nat := + MachineRegularMetadata.totalTime t e + familySteps H t e output + vertexSteps H t e output + + clearSteps (frame (emittedData H t e output)) 7 + +theorem originalTrace (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + (advance (TM2.step (program H)))^[totalSteps H t e output] + (some (cfg H (some entry) (initialData t e output))) = + some (cfg H none (initialData t e (output ++ emittedBits H t e))) := by + have metadata := metadataTrace H t e output + have family := familyTrace H t e output + have vertex := vertexTrace H t e output + have cleanup := clearTrace H (frame (emittedData H t e output)) + have final : clearMemory (frame (emittedData H t e output)) 7 = + frame (initialData t e (output ++ emittedBits H t e)) := by + rw [clearFrame] + rfl + rw [final] at cleanup + exact joinTrace (joinTrace (joinTrace metadata family) vertex) cleanup + +noncomputable def originalExecution (H : BaseTable) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + StateTransition.EvalsToInTime (TM2.step (program H)) + (cfg H (some entry) (initialData t e output)) + (some (cfg H none (initialData t e (output ++ emittedBits H t e)))) + (totalSteps H t e output) where + steps := totalSteps H t e output + evals_in_steps := originalTrace H t e output + steps_le_m := le_rfl + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalBody + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalClean.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalClean.lean new file mode 100644 index 0000000000000000000000000000000000000000..98ef1b253a52d9cbe60d9cce234d058eccb88372 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalClean.lean @@ -0,0 +1,226 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain +import OAI.Combinatorics.IndependentSets.Machines.Execution + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalClean + +open Turing MachineComposition PCP PCP.GraphTables PCP.PreprocessingRegularTables + +abbrev Tape := MachineRegularOriginalRow.Tape +abbrev Alphabet := MachineRegularOriginalRow.Alphabet +abbrev State := MachineRegularOriginalRow.State + +inductive Label + | row (label : MachineRegularOriginalRow.Label) + | query | scan | rawReverse | computedReverse | relation + deriving DecidableEq, Fintype + +def instruction {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt Alphabet Λ (State σ) + | .row l => MachineRegularOriginalRow.instruction q (fun l => labels (.row l)) + (some (labels .query)) l + | .query => MachineDrain.drain 2 (labels .query) (some (labels .scan)) + | .scan => MachineDrain.drain 3 (labels .scan) (some (labels .rawReverse)) + | .rawReverse => MachineDrain.drain 4 (labels .rawReverse) (some (labels .computedReverse)) + | .computedReverse => MachineDrain.drain 6 (labels .computedReverse) (some (labels .relation)) + | .relation => MachineDrain.drain 7 (labels .relation) exit + +def cleanupTapes (base : Tape → List Bool) : Tape → List Bool := + Function.update (Function.update (Function.update (Function.update + (Function.update base 2 []) 3 []) 4 []) 6 []) 7 [] + +def cleanupSteps (base : Tape → List Bool) : Nat := + ((base 2).length + 1) + ((base 3).length + 1) + ((base 4).length + 1) + + ((base 6).length + 1) + ((base 7).length + 1) + +theorem join_trace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +theorem cleanupTraceAt {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (base : Tape → List Bool) (state : State σ) : + (advance (TM2.step program))^[cleanupSteps base] + (some ⟨some (labels .query), state, base⟩) = + some ⟨exit, (state.1, none), cleanupTapes base⟩ := by + let t1 := Function.update base (2 : Tape) [] + let t2 := Function.update t1 (3 : Tape) [] + let t3 := Function.update t2 (4 : Tape) [] + let t4 := Function.update t3 (6 : Tape) [] + have h0 := MachineDrain.drainTrace (2 : Tape) (labels .query) (some (labels .scan)) + program (code .query) base (base 2) state.1 state.2 + have h1 := MachineDrain.drainTrace (3 : Tape) (labels .scan) (some (labels .rawReverse)) + program (code .scan) t1 (t1 3) state.1 none + have h2 := MachineDrain.drainTrace (4 : Tape) (labels .rawReverse) (some (labels .computedReverse)) + program (code .rawReverse) t2 (t2 4) state.1 none + have h3 := MachineDrain.drainTrace (6 : Tape) (labels .computedReverse) (some (labels .relation)) + program (code .computedReverse) t3 (t3 6) state.1 none + have h4 := MachineDrain.drainTrace (7 : Tape) (labels .relation) exit + program (code .relation) t4 (t4 7) state.1 none + simp only [Function.update_eq_self] at h0 h1 h2 h3 h4 + simp only [t1, t2, t3, t4, Function.update_of_ne (by decide : (3 : Tape) ≠ 2), + Function.update_of_ne (by decide : (4 : Tape) ≠ 3), + Function.update_of_ne (by decide : (4 : Tape) ≠ 2), + Function.update_of_ne (by decide : (6 : Tape) ≠ 4), + Function.update_of_ne (by decide : (6 : Tape) ≠ 3), + Function.update_of_ne (by decide : (6 : Tape) ≠ 2), + Function.update_of_ne (by decide : (7 : Tape) ≠ 6), + Function.update_of_ne (by decide : (7 : Tape) ≠ 4), + Function.update_of_ne (by decide : (7 : Tape) ≠ 3), + Function.update_of_ne (by decide : (7 : Tape) ≠ 2)] at h1 h2 h3 h4 + exact join_trace (join_trace (join_trace (join_trace h0 h1) h2) h3) h4 + +structure Input (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : Prop + extends MachineRegularOriginalRow.Input t e base where + queryEmpty : base 2 = [] + scanEmpty : base 3 = [] + +theorem cleanup_frame (q : Nat) (t : Table) (e : Fin t.darts) + (base : Tape → List Bool) (input : Input t e base) : + cleanupTapes (MachineRegularOriginalRow.finalTapes q t e base) = + Function.update base 9 + (base 9 ++ encodeWords (MachineRegularOriginalRow.emittedWords q t e)) := by + funext k + fin_cases k <;> + simp [cleanupTapes, MachineRegularOriginalRow.finalTapes, + MachineRegularOriginalRow.affined, MachineRegularOriginalRow.copied, + MachineRegularOriginalRow.looked, MachineAffineLookup.finalTapes, + MachinePreservingLookup.finalTapes, MachineLookup.tapes, + MachineRegularOriginalRow.lookupTape, input.queryEmpty, input.scanEmpty, + input.reverseEmpty, input.computedEmpty, input.relationEmpty] + +theorem suffix_length_le (t : Table) (e : Fin t.darts) : + (encodeWords (MachineRegularOriginalRow.suffixWords t e)).length ≤ (tableBits t).length := by + have hlength : (tableBits t).length = + (encodeWords (MachineRegularOriginalRow.prefixWords t e)).length + + ((encodeWords (rowWords t.rows[e])).length + + (encodeWords (MachineRegularOriginalRow.suffixWords t e)).length) := by + rw [tableBits, MachineRegularOriginalRow.tableWords_at_row, + encodeWords_append, encodeWords_append, List.length_append, List.length_append] + omega + +theorem cleanupSteps_eq (q : Nat) (t : Table) (e : Fin t.darts) + (base : Tape → List Bool) (input : Input t e base) : + cleanupSteps (MachineRegularOriginalRow.finalTapes q t e base) = + (encodeWords (MachineRegularOriginalRow.suffixWords t e)).length + + (q + 2) * t.rows[e].reverseIndex.val + q + + (encodeWords (relationWords t.rows[e].relation)).length + 8 := by + have hquery : MachineRegularOriginalRow.finalTapes q t e base 2 = encodeWord 0 := by + simp only [MachineRegularOriginalRow.finalTapes, + Function.update_of_ne (by decide : (2 : Tape) ≠ 9), MachineRegularOriginalRow.affined, + Function.update_of_ne (by decide : (2 : Tape) ≠ 6), MachineRegularOriginalRow.copied, + Function.update_of_ne (by decide : (2 : Tape) ≠ 7), + Function.update_of_ne (by decide : (2 : Tape) ≠ 3)] + change MachineLookup.tapes (2 : Tape) 3 4 base + (encodeWord 0 ++ base 2) + (encodeWords ((GraphTables.tableWords t).drop (4098 * e.val + 3 + 1)) ++ base 3) + (encodeWord t.rows[e].reverseIndex.val ++ base 4) 2 = _ + rw [MachineLookup.tapes_index _ _ _ (by decide) (by decide), input.queryEmpty, + List.append_nil] + have hscan : MachineRegularOriginalRow.finalTapes q t e base 3 = + encodeWords (MachineRegularOriginalRow.suffixWords t e) := by + simp only [MachineRegularOriginalRow.finalTapes, + Function.update_of_ne (by decide : (3 : Tape) ≠ 9), MachineRegularOriginalRow.affined, + Function.update_of_ne (by decide : (3 : Tape) ≠ 6), MachineRegularOriginalRow.copied, + Function.update_of_ne (by decide : (3 : Tape) ≠ 7), Function.update_self, + input.scanEmpty, List.append_nil] + have hraw : MachineRegularOriginalRow.finalTapes q t e base 4 = + encodeWord t.rows[e].reverseIndex.val := by + simp only [MachineRegularOriginalRow.finalTapes, + Function.update_of_ne (by decide : (4 : Tape) ≠ 9), MachineRegularOriginalRow.affined, + Function.update_of_ne (by decide : (4 : Tape) ≠ 6), MachineRegularOriginalRow.copied_reverse, + input.reverseEmpty, List.append_nil] + have hcomputed : MachineRegularOriginalRow.finalTapes q t e base 6 = + encodeWord ((q + 1) * t.rows[e].reverseIndex.val + q) := by + simp only [MachineRegularOriginalRow.finalTapes, + Function.update_of_ne (by decide : (6 : Tape) ≠ 9), MachineRegularOriginalRow.affined_reverse, + input.computedEmpty, List.append_nil] + have hrelation : MachineRegularOriginalRow.finalTapes q t e base 7 = + encodeWords (relationWords t.rows[e].relation) := by + simp only [MachineRegularOriginalRow.finalTapes, + Function.update_of_ne (by decide : (7 : Tape) ≠ 9), MachineRegularOriginalRow.affined_relation, + input.relationEmpty, List.append_nil] + simp only [cleanupSteps, hquery, hscan, hraw, hcomputed, hrelation, encodeWord_length] + ring + +theorem cleanupSteps_le (q : Nat) (t : Table) (e : Fin t.darts) + (base : Tape → List Bool) (input : Input t e base) : + cleanupSteps (MachineRegularOriginalRow.finalTapes q t e base) ≤ + (q + 3) * (tableBits t).length + q + 8200 := by + rw [cleanupSteps_eq q t e base input] + have hsuffix := suffix_length_le t e + have htable := tableWords_length_le_bits t + have hr : t.rows[e].reverseIndex.val ≤ (tableBits t).length := by + have hrlt := t.rows[e].reverseIndex.isLt + omega + have hmul := Nat.mul_le_mul_left (q + 2) hr + have hrel := relationBits_length_le t.rows[e].relation + nlinarith + +def steps (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : Nat := + MachineRegularOriginalRow.steps q t e base + + cleanupSteps (MachineRegularOriginalRow.finalTapes q t e base) + +def timeBound (q inputLength outputLength : Nat) : Nat := + (5 * q + 20) * inputLength + 2 * outputLength + 5 * q + 40995 + +theorem steps_le (q : Nat) (t : Table) (e : Fin t.darts) + (base : Tape → List Bool) (input : Input t e base) : + steps q t e base ≤ timeBound q (tableBits t).length (base 9).length := by + have hrow := MachineRegularOriginalRow.steps_le q t e base + have hclean := cleanupSteps_le q t e base input + unfold steps timeBound MachineRegularOriginalRow.timeBound at * + nlinarith + +theorem traceAt {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State σ)) + (code : ∀ l, program (labels l) = instruction q labels exit l) + (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps q t e base] + (some ⟨some (labels (.row (.lookup .seed))), + ((ambient, MachineRegularOriginalRow.zeroBuffer), register), base⟩) = + some ⟨exit, ((ambient, MachineRegularOriginalRow.zeroBuffer), none), + Function.update base 9 + (base 9 ++ encodeWords (MachineRegularOriginalRow.emittedWords q t e))⟩ := by + have row := MachineRegularOriginalRow.traceAt q (fun l => labels (.row l)) + (some (labels .query)) program (fun l => code (.row l)) t e base input.toInput ambient register + have clean := cleanupTraceAt q labels exit program code + (MachineRegularOriginalRow.finalTapes q t e base) + ((ambient, MachineRegularOriginalRow.zeroBuffer), none) + rw [cleanup_frame q t e base input] at clean + exact join_trace row clean + +def machine (q : Nat) : FinTM2 where + K := Tape + k₀ := 1 + k₁ := 9 + Γ := Alphabet + Λ := Label + main := .row (.lookup .seed) + σ := State Unit + initialState := (((), MachineRegularOriginalRow.zeroBuffer), none) + m := instruction q id none + +def machineInTime (H : BaseTable) (t : Table) (e : Fin t.darts) + (base : Tape → List Bool) (input : Input t e base) (register : Option Bool) : + StateTransition.EvalsToInTime (machine internalDegree).step + ⟨some (.row (.lookup .seed)), (((), MachineRegularOriginalRow.zeroBuffer), register), base⟩ + (some ⟨none, (((), MachineRegularOriginalRow.zeroBuffer), none), + Function.update base (9 : Tape) + (base (9 : Tape) ++ encodeWords (rowWords (MachineRegularOriginalRow.inheritedRow H t e)))⟩) + (timeBound internalDegree (tableBits t).length (base (9 : Tape)).length) where + steps := steps internalDegree t e base + evals_in_steps := by + change (advance (TM2.step (instruction internalDegree id none)))^[_] _ = _ + rw [MachineRegularOriginalRow.inheritedRow_words] + exact traceAt internalDegree id none (instruction internalDegree id none) + (fun _ => rfl) t e base input () register + steps_le_m := steps_le internalDegree t e base input + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalClean + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalRow.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..86a4dd5a9f02a1bbd8f239fe66066dd57a393b55 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOriginalRow.lean @@ -0,0 +1,331 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularTables +import OAI.Combinatorics.IndependentSets.Machines.MachineStateEquiv +import OAI.Combinatorics.IndependentSets.Machines.Block +import OAI.Combinatorics.IndependentSets.Machines.MachineAffineLookup +import OAI.Combinatorics.IndependentSets.Machines.MachineTableRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalRow + +open Turing MachineComposition +open PCP PCP.GraphTables PCP.PreprocessingRegularTables + +def inheritedIndex (_H : BaseTable) (t : Table) (e : Fin t.darts) : + Fin (vertexCount t (padding t) * (internalDegree + 1)) := + PortTables.rowIndex _ _ + (vertexOrder t (padding t) (.inl e), portOrder internalDegree (.inr ())) + +def inheritedRow (H : BaseTable) (t : Table) (e : Fin t.darts) : + DartRow (vertexCount t (padding t)) + (vertexCount t (padding t) * (internalDegree + 1)) := + (PortTables.flatRows (regularize H t))[inheritedIndex H t e] + +theorem inheritedRow_eq (H : BaseTable) (t : Table) (e : Fin t.darts) : + inheritedRow H t e = + ⟨((PortTables.rowIndex _ _).symm (inheritedIndex H t e)).1, + (regularize H t).reverseIndex[inheritedIndex H t e], + (regularize H t).relations[inheritedIndex H t e]⟩ := by + simp only [inheritedRow, PortTables.flatRows, Fin.getElem_fin, + Vector.getElem_ofFn, Fin.eta] + +@[simp] theorem inheritedRow_tail (H : BaseTable) (t : Table) (e : Fin t.darts) : + (inheritedRow H t e).tail.val = e.val := by + simp only [inheritedRow_eq, inheritedIndex, Equiv.symm_apply_apply, + vertexOrder_original] + +@[simp] theorem inheritedRow_reverse (H : BaseTable) (t : Table) (e : Fin t.darts) : + (inheritedRow H t e).reverseIndex.val = + (internalDegree + 1) * t.rows[e].reverseIndex.val + internalDegree := by + rw [inheritedRow_eq] + change ((regularize H t).reverseIndex[PortTables.rowIndex _ _ + (vertexOrder t (padding t) (.inl e), portOrder internalDegree (.inr ()))]).val = _ + rw [← PortTables.rowIndex_rotation, regularize, rotation_ofCloudTables] + change (PortTables.rowIndex _ _ + (vertexOrder t (padding t) (.inl (reverseAt t.rows e)), + portOrder internalDegree (.inr ()))).val = _ + rw [PortTables.rowIndex_val, vertexOrder_original, portOrder_inherited] + exact Nat.add_comm _ _ + +@[simp] theorem inheritedRow_relation (H : BaseTable) (t : Table) (e : Fin t.darts) : + (inheritedRow H t e).relation = t.rows[e].relation := by + rw [inheritedRow_eq] + apply Vector.ext + intro i hi + let j : Fin 4096 := ⟨i, hi⟩ + let ab := relationIndex.symm j + have h := accepts_original t (padding t) (familyCloudTable H t) e ab.1 ab.2 + change relationAt ((regularize H t).relations[inheritedIndex H t e]) ab.1 ab.2 = + relationAt t.rows[e].relation ab.1 ab.2 at h + have hj : relationIndex (ab.1, ab.2) = j := relationIndex.apply_symm_apply j + simpa only [relationAt, hj, Fin.getElem_fin, j] using h + +theorem inheritedRow_words (H : BaseTable) (t : Table) (e : Fin t.darts) : + rowWords (inheritedRow H t e) = e.val :: + ((internalDegree + 1) * t.rows[e].reverseIndex.val + internalDegree) :: + relationWords t.rows[e].relation := by + simp only [rowWords, inheritedRow_tail, inheritedRow_reverse, inheritedRow_relation, + List.cons_append, List.nil_append] + +def prefixWords (t : Table) (e : Fin t.darts) : List Nat := + [t.vertices, t.darts] ++ ((rowList t).take e.val).flatMap rowWords + +def suffixWords (t : Table) (e : Fin t.darts) : List Nat := + ((rowList t).drop (e.val + 1)).flatMap rowWords + +theorem prefixWords_length (t : Table) (e : Fin t.darts) : + (prefixWords t e).length = 2 + 4098 * e.val := by + simp only [prefixWords, List.length_append, List.length_cons, List.length_nil, + rowsWords_length, List.length_take, rowList_length, Nat.min_eq_left e.isLt.le] + +theorem tableWords_at_row (t : Table) (e : Fin t.darts) : + GraphTables.tableWords t = prefixWords t e ++ (rowWords t.rows[e] ++ suffixWords t e) := by + have he : e.val < (rowList t).length := by simpa only [rowList_length] using e.isLt + have hs : (rowList t).take e.val ++ (rowList t)[e.val] :: + (rowList t).drop (e.val + 1) = rowList t := by + rw [List.getElem_cons_drop he, List.take_append_drop] + have hw := congrArg (fun rs : List (DartRow t.vertices t.darts) => rs.flatMap rowWords) hs + simp only [List.flatMap_append, List.flatMap_cons, rowList, Vector.getElem_toList] at hw + unfold GraphTables.tableWords prefixWords suffixWords rowList + rw [← hw] + simp only [List.append_assoc, Fin.getElem_fin] + +theorem tableWords_drop_row (t : Table) (e : Fin t.darts) : + (GraphTables.tableWords t).drop (2 + 4098 * e.val) = rowWords t.rows[e] ++ suffixWords t e := by + rw [tableWords_at_row] + exact List.drop_left' (l₂ := rowWords t.rows[e] ++ suffixWords t e) + (prefixWords_length t e) + +theorem selected_reverse (t : Table) (e : Fin t.darts) : + (GraphTables.tableWords t)[4098 * e.val + 3]? = some t.rows[e].reverseIndex.val := by + have h := congrArg (fun words : List Nat => words[1]?) (tableWords_drop_row t e) + simp only [List.getElem?_drop] at h + rw [show 2 + 4098 * e.val + 1 = 4098 * e.val + 3 by omega] at h + simpa [rowWords] using h + +theorem remaining_relation (t : Table) (e : Fin t.darts) : + (GraphTables.tableWords t).drop (4098 * e.val + 3 + 1) = + relationWords t.rows[e].relation ++ suffixWords t e := by + rw [show 4098 * e.val + 3 + 1 = (2 + 4098 * e.val) + 2 by omega, + ← List.drop_drop, tableWords_drop_row] + simp only [rowWords, List.cons_append, List.drop_succ_cons, List.drop_zero, List.nil_append] + +abbrev Tape := Fin 10 +abbrev Buffer := MachineFixedBlockMap.Buffer 4096 +abbrev State (σ : Type) := (σ × Buffer) × Option Bool +abbrev Alphabet (_ : Tape) := Bool + +def zeroBuffer : Buffer := MachineFixedBlockMap.emptyBuffer 4096 + +def lookupTape (i : Fin 5) : Tape := ⟨i.val + 1, by omega⟩ + +theorem lookupTape_injective : Function.Injective lookupTape := by + intro i j h + apply Fin.ext + have hv := congrArg Fin.val h + simp only [lookupTape] at hv + omega + +theorem source_outside (i : Fin 5) : (0 : Tape) ≠ lookupTape i := by + intro h + have hv := congrArg Fin.val h + simp only [lookupTape] at hv + omega + +def fields : Fin 3 → Tape := Fin.cases 0 (Fin.cases 6 (fun _ => 7)) + +@[simp] theorem fields_zero : fields 0 = 0 := rfl +@[simp] theorem fields_one : fields 1 = 6 := rfl +@[simp] theorem fields_two : fields 2 = 7 := rfl + +theorem fields_separate (i : Fin 3) : fields i ≠ 8 ∧ fields i ≠ 5 := by + fin_cases i <;> decide + +def copyStateEquiv (σ : Type) : ((σ × Option Bool) × Buffer) ≃ State σ where + toFun s := ((s.1.1, s.2), s.1.2) + invFun s := ((s.1.1, s.2), s.1.2) + left_inv _ := rfl + right_inv _ := rfl + +inductive Label + | lookup (label : MachineAffineLookup.Label) + | copyRelation | reverseSeed | reverseScan | reverseRestore + | emit (label : MachineTableRows.Label) + deriving DecidableEq, Fintype + +def relationCopyAt {K σ Λ : Type} (src dst : K) (exit : Option Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (State σ) := + MachineStateEquiv.statement (copyStateEquiv σ) + (PoweringMachineRow.encodedBlockAt src dst (id : Buffer → Buffer) exit) + +def instruction {σ Λ : Type} (q : Nat) (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt Alphabet Λ (State σ) + | .lookup l => MachineAffineLookup.instruction 0 lookupTape 4098 3 + (fun l => labels (.lookup l)) (some (labels .copyRelation)) l + | .copyRelation => relationCopyAt 3 7 (some (labels .reverseSeed)) + | .reverseSeed => MachineUnaryAffineAt.seed 6 q (labels .reverseScan) + | .reverseScan => MachineUnaryAffineAt.scan 4 5 6 (q + 1) + (labels .reverseScan) (labels .reverseRestore) + | .reverseRestore => Reduction.MachineTransfer.loopAt 5 4 id false + (labels .reverseRestore) (some (labels (.emit .relationRead))) + | .emit l => MachineTableRows.routine fields 8 9 5 (fun l => labels (.emit l)) exit l + +def machine (q : Nat) : FinTM2 where + K := Tape + k₀ := 1 + k₁ := 9 + Γ := Alphabet + Λ := Label + main := .lookup .seed + σ := State Unit + initialState := (((), zeroBuffer), none) + m := instruction q id none + +def looked (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : Tape → List Bool := + MachineAffineLookup.finalTapes lookupTape base (GraphTables.tableWords t) (4098 * e.val + 3) + t.rows[e].reverseIndex.val + +def copied (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : Tape → List Bool := + Function.update (Function.update (looked t e base) 3 + (encodeWords (suffixWords t e) ++ base 3)) 7 + (encodeWords (relationWords t.rows[e].relation) ++ base 7) + +def affined (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + Tape → List Bool := + Function.update (copied t e base) 6 + (encodeWord ((q + 1) * t.rows[e].reverseIndex.val + q) ++ base 6) + +theorem looked_other (t : Table) (e : Fin t.darts) (base : Tape → List Bool) + (k : Tape) (h₂ : k ≠ 2) (h₃ : k ≠ 3) (h₄ : k ≠ 4) : + looked t e base k = base k := + MachineAffineLookup.finalTapes_other lookupTape base _ _ _ k h₂ h₃ h₄ + +theorem looked_reverse (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + looked t e base 4 = encodeWord t.rows[e].reverseIndex.val ++ base 4 := + MachineAffineLookup.finalTapes_output lookupTape base _ _ _ + +theorem looked_relation (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + looked t e base 3 = encodeWords (relationWords t.rows[e].relation) ++ + (encodeWords (suffixWords t e) ++ base 3) := by + change MachineLookup.tapes (2 : Tape) 3 4 base + (encodeWord 0 ++ base 2) + (encodeWords ((GraphTables.tableWords t).drop (4098 * e.val + 3 + 1)) ++ base 3) + (encodeWord t.rows[e].reverseIndex.val ++ base 4) 3 = _ + rw [MachineLookup.tapes_source _ _ _ (by decide), remaining_relation, encodeWords_append] + exact List.append_assoc _ _ _ + +theorem vectorBits_eq_encodedBlock {n : Nat} (relation : Vector Bool n) : + PoweringMachineRow.encodeBits (List.ofFn (fun i : Fin n => relation[i])) = + encodeWords (relation.toList.map GraphTables.bitWord) := by + rw [PoweringMachineRow.encodeBits_graphWords] + congr 1 + congr 1 + have hvec : Vector.ofFn (fun i : Fin n => relation[i]) = relation := by + apply Vector.ext + intro i hi + simp only [Vector.getElem_ofFn, Fin.getElem_fin] + exact Vector.toList_ofFn.symm.trans (congrArg Vector.toList hvec) + +theorem relationBits_eq_encodedBlock (relation : RelationTable) : + PoweringMachineRow.encodeBits (List.ofFn (fun i : Fin 4096 => relation[i])) = + encodeWords (relationWords relation) := vectorBits_eq_encodedBlock relation + +theorem relationCopy_step {K Λ σ : Type} [DecidableEq K] + (src dst : K) (hne : src ≠ dst) (label : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State σ)) + (code : program label = relationCopyAt src dst exit) + (relation : RelationTable) (suffix : List Bool) (base : K → List Bool) + (input : base src = encodeWords (relationWords relation) ++ suffix) + (ambient : σ) (buffer : Buffer) (register : Option Bool) : + TM2.step program ⟨some label, ((ambient, buffer), register), base⟩ = + some ⟨exit, ((ambient, zeroBuffer), register), + Function.update (Function.update base src suffix) dst + (encodeWords (relationWords relation) ++ base dst)⟩ := by + change some (TM2.stepAux (program label) _ base) = _ + rw [code] + unfold relationCopyAt + rw [MachineStateEquiv.stepAux_transport_symm] + change some (MachineStateEquiv.configuration (copyStateEquiv σ) + (TM2.stepAux (PoweringMachineRow.encodedBlockAt src dst (id : Buffer → Buffer) exit) + ((ambient, register), buffer) base)) = _ + have hinput : base src = PoweringMachineRow.encodeBits + (List.ofFn (fun i : Fin 4096 => relation[i])) ++ suffix := by + rw [relationBits_eq_encodedBlock] + exact input + rw [PoweringMachineRow.stepAux_encodedBlockAt src dst (id : Buffer → Buffer) + exit hne (fun i : Fin 4096 => relation[i]) suffix + ((ambient, register), buffer) base hinput] + simp only [id_eq, relationBits_eq_encodedBlock, MachineStateEquiv.configuration, + copyStateEquiv, zeroBuffer] + rfl + +theorem relationCopy_pushBound {K Λ σ : Type} (src dst : K) (exit : Option Λ) : + Runtime.statementPushBound (relationCopyAt (σ := σ) src dst exit) = 8192 := by + rw [relationCopyAt, MachineStateEquiv.statementPushBound, + PoweringMachineRow.statementPushBound_encodedBlockAt] + +theorem copied_other (t : Table) (e : Fin t.darts) (base : Tape → List Bool) + (k : Tape) (h₂ : k ≠ 2) (h₃ : k ≠ 3) (h₄ : k ≠ 4) (h₇ : k ≠ 7) : + copied t e base k = base k := by + simp only [copied, Function.update_of_ne h₇, Function.update_of_ne h₃, + looked_other t e base k h₂ h₃ h₄] + +theorem copied_reverse (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + copied t e base 4 = encodeWord t.rows[e].reverseIndex.val ++ base 4 := by + simp only [copied, Function.update_of_ne (by decide : (4 : Tape) ≠ 7), + Function.update_of_ne (by decide : (4 : Tape) ≠ 3), looked_reverse] + +theorem copied_relation (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + copied t e base 7 = encodeWords (relationWords t.rows[e].relation) ++ base 7 := by + simp only [copied, Function.update_self] + +theorem affined_other (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) + (k : Tape) (h₂ : k ≠ 2) (h₃ : k ≠ 3) (h₄ : k ≠ 4) (h₆ : k ≠ 6) (h₇ : k ≠ 7) : + affined q t e base k = base k := by + simp only [affined, Function.update_of_ne h₆, copied_other t e base k h₂ h₃ h₄ h₇] + +theorem affined_reverse (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + affined q t e base 6 = encodeWord ((q + 1) * t.rows[e].reverseIndex.val + q) ++ base 6 := by + simp only [affined, Function.update_self] + +theorem affined_relation (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + affined q t e base 7 = encodeWords (relationWords t.rows[e].relation) ++ base 7 := by + simp only [affined, Function.update_of_ne (by decide : (7 : Tape) ≠ 6), copied_relation] + +structure Input (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : Prop where + indexWord : base 0 = encodeWord e.val + tableWord : base 1 = tableBits t + reverseEmpty : base 4 = [] + scratchEmpty : base 5 = [] + computedEmpty : base 6 = [] + relationEmpty : base 7 = [] + rowEmpty : base 8 = [] + +def emittedWords (q : Nat) (t : Table) (e : Fin t.darts) : List Nat := + e.val :: ((q + 1) * t.rows[e].reverseIndex.val + q) :: relationWords t.rows[e].relation + +theorem affined_fields (q : Nat) (t : Table) (e : Fin t.darts) + (base : Tape → List Bool) (input : Input t e base) : + MachineTableRows.fieldBits fields (affined q t e base) = encodeWords (emittedWords q t e) := by + have htail := affined_other q t e base 0 (by decide) (by decide) (by decide) + (by decide) (by decide) + simp only [MachineTableRows.fieldBits, fields_zero, fields_one, fields_two, + htail, input.indexWord, affined_reverse, input.computedEmpty, + affined_relation, input.relationEmpty, List.append_nil, + emittedWords, encodeWords, List.append_assoc] + +def rowSteps (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : Nat := + 4 * (encodeWords (emittedWords q t e)).length + 2 * (base 9).length + 9 + +def steps (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : Nat := + MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 3 + 1 + + (2 * (t.rows[e].reverseIndex.val + 1) + 1) + rowSteps q t e base + +def finalTapes (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : + Tape → List Bool := + Function.update (affined q t e base) 9 (base 9 ++ encodeWords (emittedWords q t e)) + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerBody.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c11583af1a0a6a77baf2a76e4a70c09e4b33f36 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerBody.lean @@ -0,0 +1,522 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularLoopWords +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOwnerProgram + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerBody + +open Turing MachineComposition PCP +open PreprocessingCloudIndex PreprocessingRegularTables +open MachineRegularTable PreprocessingRegularLoopWords + +theorem joinTrace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +private theorem oneStep {A : Type} {f : A → Option A} {a b : A} + (h : f a = some b) : (advance f)^[1] (some a) = some b := by + simpa only [Function.iterate_one, advance_some] using h + +theorem metadataPlacement (data extra : Data) : + MachineCloudPadding.Placement.tapes metadataView (MachineRegularMetadata.frame data) + (frame extra) = frame data := by + funext j + cases j with + | inl j => cases j with + | inl i => rfl + | inr j => cases j <;> rfl + | inr i => rfl + +theorem metadataTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[MachineCloudPadding.totalTime t v] + (some (cfg H (some entry) (initialData t v output))) = + some (cfg H (some (.copyCount .seed)) (metadataData t v output)) := by + have raw := MachineRegularMetadata.cloudTrace t v (initialData t v output) + rfl rfl rfl rfl rfl () none + have placed := Lift.trace metadataTape metadataView metadataView_left metadataView_right + Label.metadata (some (.copyCount .seed)) metadataStates + ((MachineRegularInternalRow.coreInitialState internalDegree + MachineRegularOriginalBody.degree_positive (), MachineRegularFamily.readyState H), none) + (frame (initialData t v output)) MachineRegularMetadata.program (program H) + (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, + metadataPlacement, MachineRegularMetadata.cfg, metadataData, cfg, readyState, + MachineRegularOriginalBody.readyState, metadataStates, Equiv.coe_fn_mk, entry] using placed + +theorem working_update_local (data : Data) (fuel saved word : List Bool) : + Function.update (working data fuel saved) (core 3) word = + working { data with localRank := word } fuel saved := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> + simp [working, core, MachineRegularOriginalBody.frame, MachineRegularMetadata.frame] + | inr j => cases j with + | inl e => cases e <;> + simp [working, core, MachineRegularOriginalBody.frame, MachineRegularMetadata.frame] + | inr e => simp [working, core, MachineRegularOriginalBody.frame] + | inr i => simp [working, core] + +theorem working_update_fuel (data : Data) (fuel saved word : List Bool) : + Function.update (working data fuel saved) dummyFuel word = working data word saved := by + funext j + cases j with + | inl j => simp [working, dummyFuel] + | inr i => fin_cases i <;> simp [working, dummyFuel] + +theorem working_update_global (data : Data) (fuel saved word : List Bool) : + Function.update (working data fuel saved) (core 1) word = + working { data with globalIndex := word } fuel saved := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> + simp [working, core, MachineRegularOriginalBody.frame, MachineRegularMetadata.frame] + | inr j => cases j with + | inl e => cases e <;> + simp [working, core, MachineRegularOriginalBody.frame, MachineRegularMetadata.frame] + | inr e => simp [working, core, MachineRegularOriginalBody.frame] + | inr i => simp [working, core] + +theorem working_update_output (data : Data) (fuel saved word : List Bool) : + Function.update (working data fuel saved) (core 8) word = + working { data with output := word } fuel saved := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> + simp [working, core, MachineRegularOriginalBody.frame, MachineRegularMetadata.frame] + | inr j => cases j with + | inl e => cases e <;> + simp [working, core, MachineRegularOriginalBody.frame, MachineRegularMetadata.frame] + | inr e => simp [working, core, MachineRegularOriginalBody.frame] + | inr i => simp [working, core] + +theorem copyCountTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[2 * (cloudSize t v + 1) + 1] + (some (cfg H (some (.copyCount .seed)) (metadataData t v output))) = + some (cfg H (some (.copyFuel .seed)) (seededData t v output)) := by + have run := MachineUnaryAffineAt.seededAffineTrace (core 4) scratch (core 3) + (by decide) (by decide) (by decide) 1 0 + (.copyCount .seed) (.copyCount .scan) (.copyCount .restore) (some (.copyFuel .seed)) + (program H) rfl rfl rfl (frame (metadataData t v output)) (cloudSize t v) [] + (by simp only [List.append_nil]; rfl) rfl + (MachineRegularOriginalBody.readyState H) none + have hempty : frame (metadataData t v output) (core 3) = [] := rfl + rw [hempty, List.append_nil] at run + simpa only [Nat.one_mul, Nat.add_zero, List.append_nil, cfg, readyState, + frame, working_update_local, seededData] using run + +theorem copyFuelTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[2 * (padding t v + 1) + 1] + (some (cfg H (some (.copyFuel .seed)) (seededData t v output))) = + some ⟨some .guard, readyState H, + working (seededData t v output) (encodeWord (padding t v)) []⟩ := by + have run := MachineUnaryAffineAt.seededAffineTrace paddingTape scratch dummyFuel + (by decide) (by decide) (by decide) 1 0 + (.copyFuel .seed) (.copyFuel .scan) (.copyFuel .restore) (some .guard) + (program H) rfl rfl rfl (frame (seededData t v output)) (padding t v) [] + (by simp only [List.append_nil]; rfl) rfl + (MachineRegularOriginalBody.readyState H) none + have hempty : frame (seededData t v output) dummyFuel = [] := rfl + rw [hempty, List.append_nil] at run + simpa only [Nat.one_mul, Nat.add_zero, List.append_nil, cfg, readyState, + frame, working_update_fuel] using run + +theorem guardZeroStep (H : BaseTable) (data : Data) : + TM2.step (program H) ⟨some .guard, readyState H, working data (encodeWord 0) []⟩ = + some ⟨some (.cleanup MachineRegularOwnerCleanup.entry), readyState H, + working data (encodeWord 0) []⟩ := by + rfl + +theorem guardPositiveStep (H : BaseTable) (data : Data) (d : Nat) (hd : 0 < d) : + TM2.step (program H) ⟨some .guard, readyState H, working data (encodeWord d) []⟩ = + some ⟨some (.family .start), readyState H, working data (encodeWord d) []⟩ := by + cases d with + | zero => omega + | succ d => + simp [TM2.step, program, TM2.stepAux, working, dummyFuel, encodeWord, + List.replicate_succ, readyState] + +def dummyBits (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) : + Fin (padding t v) → List Bool := + PreprocessingRegularWords.dummyVertexBits t (padding t) (familyCloudTable H t) v + +def vertexData (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (n : Nat) (output : List Bool) : Data := + { seededData t v output with + globalIndex := encodeWord (t.darts + PreprocessingPaddingOffsets.offset (padding t) v.val + n) + localRank := encodeWord (cloudSize t v + n) + rotor := MachineRegularFamily.rotor H (cloudSize t v) } + +def loopData (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (n : Nat) : Data := + vertexData H t v n (output ++ blocksPrefix (dummyBits H t v) n) + +def loopFrame (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (n : Nat) : Tape → List Bool := + working (loopData H t v output n) (encodeWord (padding t v - n)) [] + +def preSteps (t : GraphTables.Table) (v : Fin t.vertices) : Nat := + MachineCloudPadding.totalTime t v + (2 * (cloudSize t v + 1) + 1) + + (2 * (padding t v + 1) + 1) + +def loopSteps (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : (n : Nat) → n ≤ padding t v → Nat + | 0, _ => 0 + | n + 1, hn => loopSteps H t v output n (by omega) + + (1 + MachineRegularVertexBlock.dummySteps t (padding t) (familyCloudTable H t) + v ⟨n, by omega⟩ (output ++ blocksPrefix (dummyBits H t v) n).length + 1) + +def cleanupCost (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : Nat := + if padding t v = 0 then + MachineRegularOwnerCleanup.steps (working (seededData t v output) (encodeWord 0) []) (padding t v) + else MachineRegularOwnerCleanup.steps (loopFrame H t v output (padding t v)) (padding t v) + +noncomputable def ownerTime (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : Nat := + preSteps t v + 1 + (if padding t v = 0 then 0 else + MachineRegularFamily.timePolynomial.eval (encodeWord (cloudSize t v)).length + + loopSteps H t v output (padding t v) le_rfl + 1) + cleanupCost H t v output + +theorem familyPlacement (data : Data) (fuel saved : List Bool) : + MachineCloudPadding.Placement.tapes familyView + (MachineRegularFamily.frame (MachineRegularOriginalBody.coreFrame data)) + (working data fuel saved) = working data fuel saved := by + funext j + cases j with + | inl j => exact congrFun (MachineRegularOriginalBody.familyPlacement data) j + | inr i => rfl + +theorem familyResultPlacement (H : BaseTable) (k : Nat) (data : Data) (fuel saved : List Bool) : + MachineCloudPadding.Placement.tapes familyView + (MachineRegularFamily.frame (MachineRegularFamily.resultCore H k + (MachineRegularOriginalBody.coreFrame data))) + (working data fuel saved) = + working { data with rotor := MachineRegularFamily.rotor H k } fuel saved := by + funext j + cases j with + | inl j => exact congrFun (MachineRegularOriginalBody.familyResultPlacement H k data) j + | inr i => rfl + +noncomputable def familyExecution (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (output : List Bool) := + MachineRegularFamily.familyCleanInTime H (cloudSize t v) + (MachineRegularOriginalBody.coreFrame (seededData t v output)) rfl rfl + (MachineRegularFamily.readyState H) + +noncomputable def familySteps (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (output : List Bool) : Nat := + (familyExecution H t v output).steps + +theorem familyTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[familySteps H t v output] + (some ⟨some (.family .start), readyState H, + working (seededData t v output) (encodeWord (padding t v)) []⟩) = + some ⟨some .loop, readyState H, loopFrame H t v output 0⟩ := by + have raw := (familyExecution H t v output).evals_in_steps + have placed := Lift.trace familyTape familyView familyView_left familyView_right + Label.family (some .loop) familyStates + ((MachineRegularInternalRow.coreInitialState internalDegree + MachineRegularOriginalBody.degree_positive (), ((((), false), none) : MetaState)), none) + (working (seededData t v output) (encodeWord (padding t v)) []) + (MachineRegularFamily.program H) (program H) (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, + familyPlacement, familyResultPlacement, familySteps, readyState, + MachineRegularOriginalBody.readyState, familyStates, Equiv.coe_fn_mk, + loopFrame, loopData, vertexData, blocksPrefix_zero, List.append_nil, Nat.sub_zero, + Nat.add_zero, seededData, metadataData, MachineRegularMetadata.cloudData, + initialData] using placed + +theorem coreFrame_eq (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (j : Fin (padding t v)) (output : List Bool) : + MachineRegularOriginalBody.coreFrame (vertexData H t v j.val output) = + MachineRegularInternalRow.coreInputTapes t (padding t) (familyCloudTable H t) + v (paddedNew t (padding t) v j) output := by + have rotor : MachineRegularFamily.rotor H (cloudSize t v) = + encodeWords (ExpanderTableWords.rotationWords (familyCloudTable H t v)) := + PreprocessingFamilyBridge.familyRotor_eq_familyCloudTable H t v + (PreprocessingFamilyBridge.cloudSize_pos_of_dummy t v j) + funext i + fin_cases i <;> + simp [MachineRegularOriginalBody.coreFrame, vertexData, seededData, metadataData, + MachineRegularMetadata.cloudData, MachineRegularMetadata.frame, initialData, + MachineRegularInternalRow.coreInputTapes, MachineRegularInternalRow.coreMemory, + paddedNew, + PreprocessingPaddingOffsets.paddingOrder_val, Nat.add_assoc] + all_goals first | exact rotor | rfl + +theorem vertexPlacement (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (n : Nat) (output output' fuel : List Bool) : + MachineCloudPadding.Placement.tapes vertexView + (MachineRegularOriginalBody.coreFrame (vertexData H t v n output')) + (working (vertexData H t v n output) fuel []) = + working (vertexData H t v n output') fuel [] := by + funext j + cases j with + | inl j => cases j with + | inl i => rfl + | inr j => cases j with + | inl e => cases e <;> rfl + | inr e => rfl + | inr i => rfl + +theorem vertexTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (j : Fin (padding t v)) (output fuel : List Bool) : + (advance (TM2.step (program H)))^[ + MachineRegularVertexBlock.dummySteps t (padding t) (familyCloudTable H t) v j output.length] + (some ⟨some (.vertex (MachineRegularVertexBlock.dummyEntry internalDegree + MachineRegularOriginalBody.degree_positive)), readyState H, + working (vertexData H t v j.val output) fuel []⟩) = + some ⟨some .bump, readyState H, + working (vertexData H t v j.val (output ++ dummyBits H t v j)) fuel []⟩ := by + have raw := MachineRegularVertexBlock.dummyTraceAt internalDegree + MachineRegularOriginalBody.degree_positive id none MachineRegularOriginalBody.vertexSource + (fun _ => rfl) t (padding t) (familyCloudTable H t) v j output () + have finished := coreFrame_eq H t v j (output ++ dummyBits H t v j) + simp only [dummyBits] at finished + rw [← coreFrame_eq H t v j output, ← finished] at raw + have placed := Lift.trace core vertexView vertexView_left vertexView_right + Label.vertex (some .bump) vertexStates + ((((((), false), none) : MetaState), MachineRegularFamily.readyState H), none) + (working (vertexData H t v j.val output) fuel []) + MachineRegularOriginalBody.vertexSource (program H) (fun _ => rfl) _ _ _ raw + simpa only [Lift.configuration, MachineCloudPadding.Placement.label, vertexPlacement, + readyState, MachineRegularOriginalBody.readyState, vertexStates, Equiv.coe_fn_mk, + dummyBits, id_eq] using placed + +@[simp] theorem working_fuel (data : Data) (fuel saved : List Bool) : + working data fuel saved dummyFuel = fuel := rfl + +@[simp] theorem working_scratch (data : Data) (fuel saved : List Bool) : + working data fuel saved scratch = saved := rfl + +theorem loopPositiveStep (H : BaseTable) (data : Data) (d : Nat) : + TM2.step (program H) ⟨some .loop, readyState H, working data (encodeWord (d + 1)) []⟩ = + some ⟨some (.vertex (MachineRegularVertexBlock.dummyEntry internalDegree + MachineRegularOriginalBody.degree_positive)), readyState H, + working data (encodeWord d) []⟩ := by + change some (TM2.stepAux (program H .loop) _ _) = _ + simp only [program, TM2.stepAux, working_fuel, encodeWord, List.replicate_succ, + List.cons_append, List.head?_cons, Option.getD_some, Bool.cond_true, + List.tail_cons, working_update_fuel] + rfl + +theorem loopZeroStep (H : BaseTable) (data : Data) : + TM2.step (program H) ⟨some .loop, readyState H, working data (encodeWord 0) []⟩ = + some ⟨some (.cleanup MachineRegularOwnerCleanup.entry), readyState H, + working data (encodeWord 0) []⟩ := by rfl + +theorem bumpStep (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (n : Nat) (output fuel : List Bool) : + TM2.step (program H) ⟨some .bump, readyState H, working (vertexData H t v n output) fuel []⟩ = + some ⟨some .loop, readyState H, working (vertexData H t v (n + 1) output) fuel []⟩ := by + change some (TM2.stepAux (program H .bump) _ _) = _ + simp only [program, TM2.stepAux, + Function.update_of_ne (by decide : core 3 ≠ core 1), + working_update_global, working_update_local] + congr 2 + +theorem loopPrefixTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (n : Nat) (hn : n ≤ padding t v) : + (advance (TM2.step (program H)))^[loopSteps H t v output n hn] + (some ⟨some .loop, readyState H, loopFrame H t v output 0⟩) = + some ⟨some .loop, readyState H, loopFrame H t v output n⟩ := by + induction n with + | zero => rfl + | succ n ih => + have h : n < padding t v := by omega + have first := ih (by omega) + have hremaining : padding t v - n = (padding t v - (n + 1)) + 1 := by omega + have guard := loopPositiveStep H (loopData H t v output n) (padding t v - (n + 1)) + rw [← hremaining] at guard + have guardRun : (advance (TM2.step (program H)))^[1] + (some ⟨some .loop, readyState H, loopFrame H t v output n⟩) = + some ⟨some (.vertex (MachineRegularVertexBlock.dummyEntry internalDegree + MachineRegularOriginalBody.degree_positive)), readyState H, + working (loopData H t v output n) (encodeWord (padding t v - (n + 1))) []⟩ := oneStep guard + have vertex := vertexTrace H t v ⟨n, h⟩ + (output ++ blocksPrefix (dummyBits H t v) n) (encodeWord (padding t v - (n + 1))) + have bump := bumpStep H t v n + ((output ++ blocksPrefix (dummyBits H t v) n) ++ dummyBits H t v ⟨n, h⟩) + (encodeWord (padding t v - (n + 1))) + have bumpRun := oneStep bump + have all := joinTrace (joinTrace (joinTrace first guardRun) vertex) bumpRun + simpa only [loopSteps, loopFrame, loopData, blocksPrefix_succ _ n h, + List.append_assoc, Nat.add_assoc] using all + +theorem preparationTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[preSteps t v] + (some (cfg H (some entry) (initialData t v output))) = + some ⟨some .guard, readyState H, + working (seededData t v output) (encodeWord (padding t v)) []⟩ := + joinTrace (joinTrace (metadataTrace H t v output) (copyCountTrace H t v output)) + (copyFuelTrace H t v output) + +theorem cleanupFrame (data : Data) (fuel : List Bool) (d o : Nat) : + MachineRegularOwnerCleanup.finalTapes (working data fuel []) d o = + frame { data with + localRank := [] + count := [] + rotor := [] + padding := [] + level := [] + offset := encodeWord (d + o) } := by + funext j + rw [MachineRegularOwnerCleanup.finalTapes_apply] + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> + simp [MachineRegularOwnerCleanup.cleanupTapes, MachineRegularOwnerCleanup.localRank, + MachineRegularOwnerCleanup.count, MachineRegularOwnerCleanup.rotor, + MachineRegularOwnerCleanup.padding, MachineRegularOwnerCleanup.level, + MachineRegularOwnerCleanup.dummyFuel, MachineRegularOwnerCleanup.prefixTape, + MachineRegularOwnerCleanup.core, frame, working, MachineRegularOriginalBody.frame, + MachineRegularMetadata.frame] + | inr j => cases j with + | inl e => cases e <;> + simp [MachineRegularOwnerCleanup.cleanupTapes, MachineRegularOwnerCleanup.localRank, + MachineRegularOwnerCleanup.count, MachineRegularOwnerCleanup.rotor, + MachineRegularOwnerCleanup.padding, MachineRegularOwnerCleanup.level, + MachineRegularOwnerCleanup.dummyFuel, + MachineRegularOwnerCleanup.core, frame, working, MachineRegularOriginalBody.frame, + MachineRegularMetadata.frame] + | inr e => + simp [MachineRegularOwnerCleanup.cleanupTapes, MachineRegularOwnerCleanup.localRank, + MachineRegularOwnerCleanup.count, MachineRegularOwnerCleanup.rotor, + MachineRegularOwnerCleanup.padding, MachineRegularOwnerCleanup.level, + MachineRegularOwnerCleanup.dummyFuel, MachineRegularOwnerCleanup.prefixTape, + MachineRegularOwnerCleanup.core, frame, working, MachineRegularOriginalBody.frame] + | inr i => fin_cases i <;> + simp [MachineRegularOwnerCleanup.cleanupTapes, MachineRegularOwnerCleanup.localRank, + MachineRegularOwnerCleanup.count, MachineRegularOwnerCleanup.rotor, + MachineRegularOwnerCleanup.padding, MachineRegularOwnerCleanup.level, + MachineRegularOwnerCleanup.dummyFuel, MachineRegularOwnerCleanup.prefixTape, + MachineRegularOwnerCleanup.core, frame, working] + +theorem ownerBits_zero (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (hp : padding t v = 0) : ownerBits H t v = [] := by + have hnil : List.ofFn (dummyBits H t v) = [] := by + apply List.length_eq_zero_iff.mp + simpa only [List.length_ofFn] using hp + exact congrArg List.flatten hnil + +theorem cleanupZeroFrame (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (hp : padding t v = 0) : + MachineRegularOwnerCleanup.finalTapes + (working (seededData t v output) (encodeWord 0) []) (padding t v) + (PreprocessingPaddingOffsets.offset (padding t) v.val) = frame (finalData H t v output) := by + rw [cleanupFrame] + apply congrArg frame + simp only [seededData, metadataData, MachineRegularMetadata.cloudData, initialData, + finalData, hp, ownerBits_zero H t v hp, List.append_nil, Nat.add_zero, Nat.zero_add] + +theorem cleanupLoopFrame (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + MachineRegularOwnerCleanup.finalTapes (loopFrame H t v output (padding t v)) + (padding t v) (PreprocessingPaddingOffsets.offset (padding t) v.val) = + frame (finalData H t v output) := by + rw [loopFrame, cleanupFrame] + apply congrArg frame + simp only [loopData, vertexData, seededData, metadataData, MachineRegularMetadata.cloudData, + initialData, finalData, blocksPrefix_all, dummyBits, ownerBits, + Nat.add_comm (padding t v) (PreprocessingPaddingOffsets.offset (padding t) v.val)] + +theorem cleanupZeroTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (hp : padding t v = 0) : + (advance (TM2.step (program H)))^[MachineRegularOwnerCleanup.steps + (working (seededData t v output) (encodeWord 0) []) (padding t v)] + (some ⟨some (.cleanup MachineRegularOwnerCleanup.entry), readyState H, + working (seededData t v output) (encodeWord 0) []⟩) = + some (cfg H none (finalData H t v output)) := by + have run := MachineRegularOwnerCleanup.traceAt Label.cleanup none (program H) (fun _ => rfl) + (working (seededData t v output) (encodeWord 0) []) (padding t v) + (PreprocessingPaddingOffsets.offset (padding t) v.val) rfl rfl rfl + (MachineRegularOriginalBody.readyState H) none + rw [cleanupZeroFrame H t v output hp] at run + exact run + +theorem cleanupLoopTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[MachineRegularOwnerCleanup.steps + (loopFrame H t v output (padding t v)) (padding t v)] + (some ⟨some (.cleanup MachineRegularOwnerCleanup.entry), readyState H, + loopFrame H t v output (padding t v)⟩) = + some (cfg H none (finalData H t v output)) := by + have run := MachineRegularOwnerCleanup.traceAt Label.cleanup none (program H) (fun _ => rfl) + (loopFrame H t v output (padding t v)) (padding t v) + (PreprocessingPaddingOffsets.offset (padding t) v.val) rfl rfl rfl + (MachineRegularOriginalBody.readyState H) none + rw [cleanupLoopFrame] at run + exact run + +theorem loopTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[loopSteps H t v output (padding t v) le_rfl + 1] + (some ⟨some .loop, readyState H, loopFrame H t v output 0⟩) = + some ⟨some (.cleanup MachineRegularOwnerCleanup.entry), readyState H, + loopFrame H t v output (padding t v)⟩ := by + have first := loopPrefixTrace H t v output (padding t v) le_rfl + have last : (advance (TM2.step (program H)))^[1] + (some ⟨some .loop, readyState H, loopFrame H t v output (padding t v)⟩) = + some ⟨some (.cleanup MachineRegularOwnerCleanup.entry), readyState H, + loopFrame H t v output (padding t v)⟩ := by + simpa only [loopFrame, Nat.sub_self] using + oneStep (loopZeroStep H (loopData H t v output (padding t v))) + exact joinTrace first last + +noncomputable def ownerInTime (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (output : List Bool) : + StateTransition.EvalsToInTime (TM2.step (program H)) + (cfg H (some entry) (initialData t v output)) + (some (cfg H none (finalData H t v output))) (ownerTime H t v output) := by + have prepared := preparationTrace H t v output + by_cases hp : padding t v = 0 + · have gate : (advance (TM2.step (program H)))^[1] + (some ⟨some .guard, readyState H, + working (seededData t v output) (encodeWord (padding t v)) []⟩) = + some ⟨some (.cleanup MachineRegularOwnerCleanup.entry), readyState H, + working (seededData t v output) (encodeWord 0) []⟩ := by + simpa only [hp] using oneStep (guardZeroStep H (seededData t v output)) + have all := joinTrace (joinTrace prepared gate) (cleanupZeroTrace H t v output hp) + refine { steps := _, evals_in_steps := all, steps_le_m := ?_ } + simp only [ownerTime, cleanupCost, ite_eq_left hp, Nat.add_zero, le_refl] + · have gate : (advance (TM2.step (program H)))^[1] + (some ⟨some .guard, readyState H, + working (seededData t v output) (encodeWord (padding t v)) []⟩) = + some ⟨some (.family .start), readyState H, + working (seededData t v output) (encodeWord (padding t v)) []⟩ := + oneStep (guardPositiveStep H (seededData t v output) (padding t v) (Nat.pos_of_ne_zero hp)) + have all := joinTrace + (joinTrace (joinTrace (joinTrace prepared gate) (familyTrace H t v output)) + (loopTrace H t v output)) (cleanupLoopTrace H t v output) + refine { steps := _, evals_in_steps := all, steps_le_m := ?_ } + have hb : familySteps H t v output ≤ + MachineRegularFamily.timePolynomial.eval (encodeWord (cloudSize t v)).length := + (familyExecution H t v output).steps_le_m + simp only [ownerTime, cleanupCost, ite_eq_right hp] + omega + +noncomputable def totalSteps (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (output : List Bool) : Nat := (ownerInTime H t v output).steps + +theorem ownerTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + (advance (TM2.step (program H)))^[totalSteps H t v output] + (some (cfg H (some entry) (initialData t v output))) = + some (cfg H none (finalData H t v output)) := (ownerInTime H t v output).evals_in_steps + +theorem totalSteps_le (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : totalSteps H t v output ≤ ownerTime H t v output := + (ownerInTime H t v output).steps_le_m + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerBody + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerBodyBounds.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerBodyBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..de2efd50c031b64e496578d13192eca8ed642c01 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerBodyBounds.lean @@ -0,0 +1,263 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOwnerBody +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularBounds +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularExecutionBounds + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerBodyBounds + +open Turing MachineComposition PCP PreprocessingCloudIndex PreprocessingRegularTables +open PreprocessingMachineBounds PreprocessingRegularLoopWords + +def bodySize (t : GraphTables.Table) (output : List Bool) : Nat := + inputLength t + output.length + +noncomputable def wide : Polynomial Nat := Polynomial.C (ExpanderFamily.growth + 1) * Polynomial.X + +noncomputable def rowPolynomial (q : Nat) : Polynomial Nat := + wide + wide * Polynomial.C (q + 1) + 8192 + +noncomputable def outputPolynomial (q : Nat) : Polynomial Nat := + wide + regularPolynomial + Polynomial.C q * rowPolynomial q + +noncomputable def corePolynomial (q : Nat) : Polynomial Nat := + Polynomial.C (5*q+32) * rotorPolynomial q + 10*wide + 2*wide + 13*wide + 5*wide + + Polynomial.C (5*q+10)*(wide+wide) + 4*wide + 2*outputPolynomial q + + Polynomial.C (8*q+41066) + +noncomputable def blockPolynomial (q : Nat) : Polynomial Nat := + Polynomial.C q * corePolynomial q + Polynomial.C (5*q+11)*wide + + 2*outputPolynomial q + Polynomial.C (5*q+40986) + +theorem blockPolynomial_eval (q L : Nat) : + (blockPolynomial q).eval L = + MachineRegularVertexBlock.dummyTimeBound q + ((ExpanderFamily.growth+1)*L) ((rotorPolynomial q).eval L) + ((ExpanderFamily.growth+1)*L) ((ExpanderFamily.growth+1)*L) + ((ExpanderFamily.growth+1)*L) ((ExpanderFamily.growth+1)*L) + ((ExpanderFamily.growth+1)*L) ((ExpanderFamily.growth+1)*L) + (((ExpanderFamily.growth+1)*L) + regularPolynomial.eval L) + ((ExpanderFamily.growth+1)*L) := by + simp only [blockPolynomial, corePolynomial, outputPolynomial, rowPolynomial, wide, + Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_ofNat, MachineRegularVertexBlock.dummyTimeBound, + MachineRegularVertexBlock.portTimeBound, MachineRegularInternalRow.coreTimeBound, + MachineRegularDummyRow.timeBound, MachineRegularVertexBlock.rowSizeBound] + simp only [Nat.add_assoc] + +theorem dummyTimeBound_le (q L R x v i k o m O V W R' O' : Nat) + (hL : L ≤ W) (hR : R ≤ R') (hx : x ≤ W) (hv : v ≤ W) + (hi : i ≤ W) (hk : k ≤ W) (ho : o ≤ W) (hm : m ≤ W) + (hO : O ≤ O') (hV : V ≤ W) : + MachineRegularVertexBlock.dummyTimeBound q L R x v i k o m O V ≤ + MachineRegularVertexBlock.dummyTimeBound q W R' W W W W W W O' W := by + unfold MachineRegularVertexBlock.dummyTimeBound MachineRegularVertexBlock.portTimeBound + MachineRegularInternalRow.coreTimeBound MachineRegularDummyRow.timeBound + MachineRegularVertexBlock.rowSizeBound + gcongr + +theorem wide_le (t : GraphTables.Table) (output : List Bool) : + inputLength t ≤ (ExpanderFamily.growth+1)*bodySize t output ∧ + ExpanderFamily.growth*inputLength t ≤ (ExpanderFamily.growth+1)*bodySize t output ∧ + output.length ≤ (ExpanderFamily.growth+1)*bodySize t output := by + have hN : inputLength t ≤ bodySize t output := Nat.le_add_right _ _ + have hO : output.length ≤ bodySize t output := Nat.le_add_left _ _ + have hg := Nat.mul_le_mul_left ExpanderFamily.growth hN + rw [Nat.add_mul, Nat.one_mul] + omega + +theorem ownerPrefix_length_le (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (n : Nat) : + (blocksPrefix (PreprocessingRegularWords.dummyVertexBits t (padding t) + (familyCloudTable H t) v) n).length ≤ regularPolynomial.eval (inputLength t) := by + have h := PreprocessingRegularBounds.regular_dummyPrefix_le t H v n + simp only [PreprocessingRegularBounds.dummyPrefix, List.length_append] at h + omega + +theorem growingOutput_length_le (H : BaseTable) (t : GraphTables.Table) + (v : Fin t.vertices) (n : Nat) (output : List Bool) : + (output ++ blocksPrefix (PreprocessingRegularWords.dummyVertexBits t (padding t) + (familyCloudTable H t) v) n).length ≤ + (ExpanderFamily.growth+1)*bodySize t output + regularPolynomial.eval (bodySize t output) := by + have h := (ownerPrefix_length_le H t v n).trans + (natPolynomial_eval_mono regularPolynomial (Nat.le_add_right (inputLength t) output.length)) + have hO := (wide_le t output).2.2 + rw [List.length_append] + exact Nat.add_le_add hO h + +theorem dummySteps_le (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (j : Fin (padding t v)) (n : Nat) (output : List Bool) : + MachineRegularVertexBlock.dummySteps t (padding t) (familyCloudTable H t) v j + (output ++ blocksPrefix (PreprocessingRegularWords.dummyVertexBits t (padding t) + (familyCloudTable H t) v) n).length ≤ + (blockPolynomial internalDegree).eval (bodySize t output) := by + let x := paddedNew t (padding t) v j + let W := (ExpanderFamily.growth+1)*bodySize t output + have bounds := wide_le t output + have hx := (vertexOrder t (padding t) x.val).isLt.le.trans (regularVertices_le_input t) + have hv := v.isLt.le.trans (GraphTables.vertices_le_tableBits_length t) + have hi := (paddedCloudRank t (padding t) v x).isLt.le.trans (cloudTotal_le_input t v) + have hk := cloudSize_le_input t v + have hm := GraphTables.darts_le_tableBits_length t + have ho := prefix_le_input t v.val + have hV := regularVertices_le_input t + have hR := (cloudRotorBits_le t v (familyCloudTable H t v)).trans + (natPolynomial_eval_mono (rotorPolynomial internalDegree) + (Nat.le_add_right (inputLength t) output.length)) + have hO := growingOutput_length_le H t v n output + have raw := MachineRegularVertexBlock.dummySteps_le internalDegree + MachineRegularOriginalBody.degree_positive t (padding t) (familyCloudTable H t) v j + (output ++ blocksPrefix (PreprocessingRegularWords.dummyVertexBits t (padding t) + (familyCloudTable H t) v) n).length + have bound := dummyTimeBound_le internalDegree _ _ _ _ _ _ _ _ _ _ W _ _ + bounds.1 hR (hx.trans bounds.2.1) (hv.trans bounds.1) (hi.trans bounds.2.1) + (hk.trans bounds.1) (ho.trans bounds.2.1) (hm.trans bounds.1) hO + (hV.trans bounds.2.1) + rw [blockPolynomial_eval] + exact raw.trans bound + +noncomputable def prePolynomial : Polynomial Nat := + MachineCloudPadding.timePolynomial.comp (2*Polynomial.X+1) + 4*wide + 6 + +noncomputable def loopPolynomial : Polynomial Nat := + wide * (blockPolynomial internalDegree + 2) + +noncomputable def cleanupPolynomial : Polynomial Nat := + 6*wide + rotorPolynomial internalDegree + 13 + +noncomputable def timePolynomial : Polynomial Nat := + prePolynomial + MachineRegularExecutionBounds.familyPolynomial + loopPolynomial + + cleanupPolynomial + 2 + +theorem preSteps_le (t : GraphTables.Table) (v : Fin t.vertices) (output : List Bool) : + MachineRegularOwnerBody.preSteps t v ≤ prePolynomial.eval (bodySize t output) := by + have bounds := wide_le t output + have hk := cloudSize_le_input t v + have hd := cloudTotal_le_input t v + have hv := v.isLt.le.trans (GraphTables.vertices_le_tableBits_length t) + change v.val ≤ inputLength t at hv + have hN : inputLength t ≤ bodySize t output := Nat.le_add_right _ _ + have hinput : MachineCloudPadding.inputLength t v [] ≤ 2*bodySize t output+1 := by + simp only [MachineCloudPadding.inputLength, List.append_nil, encodeWord_length] + change inputLength t + (v.val+1) ≤ _ + omega + have hm := (MachineCloudPadding.totalTime_le t v []).trans + (natPolynomial_eval_mono MachineCloudPadding.timePolynomial hinput) + simp only [MachineRegularOwnerBody.preSteps, prePolynomial, wide, Polynomial.eval_add, + Polynomial.eval_mul, Polynomial.eval_comp, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_ofNat, Polynomial.eval_one] + omega + +theorem loopSteps_le (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (n : Nat) (hn : n ≤ padding t v) : + MachineRegularOwnerBody.loopSteps H t v output n hn ≤ + n * ((blockPolynomial internalDegree).eval (bodySize t output) + 2) := by + induction n with + | zero => simp only [MachineRegularOwnerBody.loopSteps, Nat.zero_mul, le_refl] + | succ n ih => + have h : n < padding t v := by omega + have first := ih (by omega) + have second := dummySteps_le H t v ⟨n, h⟩ n output + rw [MachineRegularOwnerBody.loopSteps, Nat.succ_mul] + change MachineRegularOwnerBody.loopSteps H t v output n _ + + (1 + MachineRegularVertexBlock.dummySteps t (padding t) (familyCloudTable H t) v ⟨n, h⟩ + (output ++ blocksPrefix (PreprocessingRegularWords.dummyVertexBits t (padding t) + (familyCloudTable H t) v) n).length + 1) ≤ _ + omega + +theorem allLoopSteps_le (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + MachineRegularOwnerBody.loopSteps H t v output (padding t v) le_rfl ≤ + loopPolynomial.eval (bodySize t output) := by + have hd := (cloudTotal_le_input t v).trans (wide_le t output).2.1 + have hp : padding t v ≤ (ExpanderFamily.growth+1)*bodySize t output := by omega + have h := (loopSteps_le H t v output (padding t v) le_rfl).trans + (Nat.mul_le_mul_right _ hp) + simpa only [loopPolynomial, wide, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat] using h + +theorem cleanupSteps_working (data : MachineRegularOwnerBody.Data) + (fuel saved : List Bool) (d : Nat) : + MachineRegularOwnerCleanup.steps (MachineRegularOwnerBody.working data fuel saved) d = + 2*(d+1) + data.localRank.length + data.count.length + data.rotor.length + + data.padding.length + data.level.length + fuel.length + 6 := by + change 2*(d+1) + ((data.localRank.length+1) + ((data.count.length+1) + + ((data.rotor.length+1) + ((data.padding.length+1) + ((data.level.length+1) + + ((fuel.length+1)+0)))))) = _ + omega + +theorem cleanupCost_le (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + MachineRegularOwnerBody.cleanupCost H t v output ≤ + cleanupPolynomial.eval (bodySize t output) := by + have bounds := wide_le t output + have hk := (cloudSize_le_input t v).trans bounds.1 + have htotal := (cloudTotal_le_input t v).trans bounds.2.1 + have hl := (level_le_input t v).trans bounds.1 + have hp : MachineCloudPadding.padding (cloudSize t v) = padding t v := rfl + by_cases hd : padding t v = 0 + · rw [MachineRegularOwnerBody.cleanupCost, ite_eq_left hd, cleanupSteps_working] + simp only [MachineRegularOwnerBody.seededData, MachineRegularOwnerBody.metadataData, + MachineRegularMetadata.cloudData, MachineRegularOwnerBody.initialData, + hp, encodeWord_length, List.length_nil, cleanupPolynomial, wide, + Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_ofNat] + omega + · have hpositive : 0 < padding t v := by omega + have hkpos := PreprocessingFamilyBridge.cloudSize_pos_of_dummy t v ⟨0, hpositive⟩ + have hrotor := PreprocessingFamilyBridge.familyRotor_eq_familyCloudTable H t v hkpos + change MachineRegularFamily.rotor H (cloudSize t v) = _ at hrotor + have hR := (cloudRotorBits_le t v (familyCloudTable H t v)).trans + (natPolynomial_eval_mono (rotorPolynomial internalDegree) + (Nat.le_add_right (inputLength t) output.length)) + rw [← hrotor] at hR + change (MachineRegularFamily.rotor H (cloudSize t v)).length ≤ + (rotorPolynomial internalDegree).eval (bodySize t output) at hR + rw [MachineRegularOwnerBody.cleanupCost, ite_eq_right hd, + MachineRegularOwnerBody.loopFrame, cleanupSteps_working] + simp only [MachineRegularOwnerBody.loopData, MachineRegularOwnerBody.vertexData, + MachineRegularOwnerBody.seededData, MachineRegularOwnerBody.metadataData, + MachineRegularMetadata.cloudData, MachineRegularOwnerBody.initialData, + hp, encodeWord_length, Nat.sub_self, cleanupPolynomial, wide, + Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_ofNat] + omega + +theorem ownerTime_le (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + MachineRegularOwnerBody.ownerTime H t v output ≤ timePolynomial.eval (bodySize t output) := by + have hp := preSteps_le t v output + have hc := cleanupCost_le H t v output + have hl := allLoopSteps_le H t v output + have hf := (MachineRegularExecutionBounds.family_budget_le t v).trans + (natPolynomial_eval_mono MachineRegularExecutionBounds.familyPolynomial + (Nat.le_add_right (inputLength t) output.length)) + have hfamily : MachineRegularFamily.timePolynomial.eval (encodeWord (cloudSize t v)).length ≤ + MachineRegularExecutionBounds.familyPolynomial.eval (bodySize t output) := by + simpa only [bodySize, MachineRegularFamily.timePolynomial, encodeWord_length, Polynomial.eval_add, + Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_ofNat] using hf + simp only [MachineRegularOwnerBody.ownerTime, timePolynomial, Polynomial.eval_add, + Polynomial.eval_ofNat] + split_ifs <;> omega + +theorem totalSteps_le (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + MachineRegularOwnerBody.totalSteps H t v output ≤ timePolynomial.eval (bodySize t output) := + (MachineRegularOwnerBody.totalSteps_le H t v output).trans (ownerTime_le H t v output) + +noncomputable def ownerInTime (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : + StateTransition.EvalsToInTime (TM2.step (MachineRegularOwnerBody.program H)) + (MachineRegularOwnerBody.cfg H (some MachineRegularOwnerBody.entry) + (MachineRegularOwnerBody.initialData t v output)) + (some (MachineRegularOwnerBody.cfg H none + (MachineRegularOwnerBody.finalData H t v output))) + (timePolynomial.eval (bodySize t output)) where + steps := MachineRegularOwnerBody.totalSteps H t v output + evals_in_steps := MachineRegularOwnerBody.ownerTrace H t v output + steps_le_m := totalSteps_le H t v output + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerBodyBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerCleanup.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerCleanup.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc934efb3856df288fa6ad7f98da2c2ff6def373 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerCleanup.lean @@ -0,0 +1,191 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrainMany +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalBody + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerCleanup + +open Turing MachineComposition + +variable {Λ : Type} + +abbrev Tape := MachineRegularOriginalBody.Tape ⊕ Fin 2 +abbrev State := MachineRegularOriginalBody.State × Option Bool +abbrev Alphabet (_ : Tape) := Bool + +def sumDecidableEq {A B : Type} (left : DecidableEq A) (right : DecidableEq B) : + DecidableEq (A ⊕ B) + | .inl a, .inl b => match left a b with + | .isTrue h => .isTrue (congrArg (Sum.inl : A → A ⊕ B) h) + | .isFalse h => .isFalse (fun e => h (Sum.inl.inj e)) + | .inr a, .inr b => match right a b with + | .isTrue h => .isTrue (congrArg (Sum.inr : B → A ⊕ B) h) + | .isFalse h => .isFalse (fun e => h (Sum.inr.inj e)) + | .inl _, .inr _ => .isFalse (by intro h; cases h) + | .inr _, .inl _ => .isFalse (by intro h; cases h) + +instance tapeDecidableEq : DecidableEq Tape := + sumDecidableEq + (sumDecidableEq (inferInstanceAs (DecidableEq (Fin 27))) + (sumDecidableEq (inferInstanceAs (DecidableEq MachineRegularMetadata.Extra)) + (sumDecidableEq + (sumDecidableEq + (sumDecidableEq (inferInstanceAs (DecidableEq MachineExpanderRow.Tape)) + (inferInstanceAs (DecidableEq MachineExpanderTable.ExtraTape))) + (inferInstanceAs (DecidableEq MachineExpanderFamily.ExtraTape))) + (inferInstanceAs (DecidableEq MachineCeilingPower.Tape))))) + (inferInstanceAs (DecidableEq (Fin 2))) + +instance tapeBEq : BEq Tape where + beq a b := decide (a = b) + +instance tapeLawfulBEq : LawfulBEq Tape where + eq_of_beq := of_decide_eq_true + rfl := of_decide_eq_self_eq_true _ + +instance tapeFintype : Fintype Tape := by + change Fintype + ((Fin 27 ⊕ (MachineRegularMetadata.Extra ⊕ + (((MachineExpanderRow.Tape ⊕ MachineExpanderTable.ExtraTape) ⊕ + MachineExpanderFamily.ExtraTape) ⊕ MachineCeilingPower.Tape))) ⊕ Fin 2) + infer_instance + +def core (k : Fin 27) : Tape := .inl (.inl k) +def localRank : Tape := core 3 +def count : Tape := core 4 +def prefixTape : Tape := core 5 +def rotor : Tape := core 7 +def padding : Tape := .inl (.inr (.inl .padding)) +def level : Tape := .inl (.inr (.inl .level)) +def dummyFuel : Tape := .inr 0 +def scratch : Tape := .inr 1 + +def cleanupTapes : List Tape := [localRank, count, rotor, padding, level, dummyFuel] + +inductive Label + | scan + | restore + | drain (l : MachineDrainMany.Label cleanupTapes) + deriving DecidableEq, Fintype + +def entry : Label := .scan + +def cleanupEntry (labels : Label → Λ) (exit : Option Λ) : Option Λ := + MachineDrainMany.entry cleanupTapes (fun l => labels (.drain l)) exit + +def instruction (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt Alphabet Λ State + | .scan => MachineUnaryAffineAt.scan padding scratch prefixTape 1 + (labels .scan) (labels .restore) + | .restore => Reduction.MachineTransfer.loopAt scratch padding id false + (labels .restore) (cleanupEntry labels exit) + | .drain l => MachineDrainMany.instruction cleanupTapes + (fun l => labels (.drain l)) exit l + +def afterAddition (base : Tape → List Bool) (d o : Nat) : Tape → List Bool := + Function.update base prefixTape (encodeWord (d + o)) + +def finalTapes (base : Tape → List Bool) (d o : Nat) : Tape → List Bool := + MachineDrainMany.finalTapes cleanupTapes (afterAddition base d o) + +def steps (base : Tape → List Bool) (d : Nat) : Nat := + 2 * (d + 1) + (cleanupTapes.map (fun k => (base k).length + 1)).sum + +theorem finalTapes_apply (base : Tape → List Bool) (d o : Nat) (k : Tape) : + finalTapes base d o k = + if k ∈ cleanupTapes then [] + else if k = prefixTape then encodeWord (d + o) else base k := by + simp only [finalTapes, MachineDrainMany.finalTapes_apply, afterAddition, + Function.update_apply] + +@[simp] theorem finalTapes_prefix (base : Tape → List Bool) (d o : Nat) : + finalTapes base d o prefixTape = encodeWord (d + o) := by + simp [finalTapes_apply, cleanupTapes, prefixTape, localRank, count, rotor, + padding, level, dummyFuel, core] + +theorem finalTapes_empty (base : Tape → List Bool) (d o : Nat) (k : Tape) + (hk : k ∈ cleanupTapes) : finalTapes base d o k = [] := by + rw [finalTapes_apply, ite_eq_left hk] + +theorem finalTapes_other (base : Tape → List Bool) (d o : Nat) (k : Tape) + (hk : k ∉ cleanupTapes) (hp : k ≠ prefixTape) : + finalTapes base d o k = base k := by + rw [finalTapes_apply, ite_eq_right hk, ite_eq_right hp] + +@[simp] theorem finalTapes_scratch (base : Tape → List Bool) (d o : Nat) : + finalTapes base d o scratch = base scratch := by + apply finalTapes_other + · simp [cleanupTapes, scratch, localRank, count, rotor, padding, level, dummyFuel, core] + · decide + +theorem drainSteps_eq (base : Tape → List Bool) (d o : Nat) : + MachineDrainMany.steps cleanupTapes (afterAddition base d o) = + (cleanupTapes.map (fun k => (base k).length + 1)).sum := by + simp [MachineDrainMany.steps, cleanupTapes, afterAddition, prefixTape, + localRank, count, rotor, padding, level, dummyFuel, core] + +theorem additionTraceAt (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ State) + (code : ∀ l, program (labels l) = instruction labels exit l) + (base : Tape → List Bool) (d o : Nat) + (paddingWord : base padding = encodeWord d) + (prefixWord : base prefixTape = encodeWord o) + (scratchEmpty : base scratch = []) + (ambient : MachineRegularOriginalBody.State) (register : Option Bool) : + (advance (TM2.step program))^[2 * (d + 1)] + (some ⟨some (labels entry), (ambient, register), base⟩) = + some ⟨cleanupEntry labels exit, (ambient, none), afterAddition base d o⟩ := by + have frame (word : List Bool) : + MachineUnaryAffineAt.tapes padding scratch prefixTape base (encodeWord d) [] word = + Function.update base prefixTape word := by + rw [← paddingWord, ← scratchEmpty] + simp only [MachineUnaryAffineAt.tapes, MachineCopy.forkTapes, Function.update_eq_self] + have initial : MachineUnaryAffineAt.tapes padding scratch prefixTape base + (encodeWord d) [] (encodeWord o) = base := by + rw [frame, ← prefixWord, Function.update_eq_self] + have run := MachineUnaryAffineAt.affineTrace padding scratch prefixTape + (by decide) (by decide) (by decide) 1 (labels .scan) (labels .restore) + (cleanupEntry labels exit) program (code .scan) (code .restore) + base d o [] [] ambient register + simpa only [List.append_nil, Nat.one_mul, initial, frame, entry, afterAddition] using run + +theorem traceAt (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ State) + (code : ∀ l, program (labels l) = instruction labels exit l) + (base : Tape → List Bool) (d o : Nat) + (paddingWord : base padding = encodeWord d) + (prefixWord : base prefixTape = encodeWord o) + (scratchEmpty : base scratch = []) + (ambient : MachineRegularOriginalBody.State) (register : Option Bool) : + (advance (TM2.step program))^[steps base d] + (some ⟨some (labels entry), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), finalTapes base d o⟩ := by + have first := additionTraceAt labels exit program code base d o + paddingWord prefixWord scratchEmpty ambient register + have second := MachineDrainMany.trace cleanupTapes (fun l => labels (.drain l)) exit + program (fun l => code (.drain l)) (afterAddition base d o) ambient none + simp only [MachineDrainMany.finalRegister_none, drainSteps_eq] at second + unfold steps + rw [Nat.add_comm, Function.iterate_add_apply, first] + exact second + +def executionAt (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Alphabet Λ State) + (code : ∀ l, program (labels l) = instruction labels exit l) + (base : Tape → List Bool) (d o : Nat) + (paddingWord : base padding = encodeWord d) + (prefixWord : base prefixTape = encodeWord o) + (scratchEmpty : base scratch = []) + (ambient : MachineRegularOriginalBody.State) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels entry), (ambient, register), base⟩ + (some ⟨exit, (ambient, none), finalTapes base d o⟩) (steps base d) where + steps := steps base d + evals_in_steps := traceAt labels exit program code base d o + paddingWord prefixWord scratchEmpty ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerCleanup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerProgram.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2aebeb52594baa3d14e994c2a693c40c4a39deb1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularOwnerProgram.lean @@ -0,0 +1,181 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOwnerCleanup + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerBody + +open Turing MachineComposition PCP +open PreprocessingCloudIndex PreprocessingRegularTables +open MachineRegularTable + +abbrev Tape := MachineRegularOriginalBody.Tape ⊕ Fin 2 +abbrev Alphabet (_ : Tape) := Bool +abbrev State := MachineRegularOriginalBody.State × Option Bool +abbrev Data := MachineRegularMetadata.Data +abbrev CoreState := MachineRegularOriginalBody.CoreState +abbrev MetaState := MachineRegularOriginalBody.MetaState +abbrev FamilyState := MachineRegularOriginalBody.FamilyState +abbrev BaseTable := PreprocessingRegularTables.BaseTable + +instance : DecidableEq Tape := MachineRegularOwnerCleanup.tapeDecidableEq +instance : Fintype Tape := MachineRegularOwnerCleanup.tapeFintype + +def core (k : Fin 27) : Tape := .inl (.inl k) +def paddingTape : Tape := .inl (.inr (.inl .padding)) +def levelTape : Tape := .inl (.inr (.inl .level)) +def dummyFuel : Tape := .inr 0 +def scratch : Tape := .inr 1 + +def readyState (H : BaseTable) : State := (MachineRegularOriginalBody.readyState H, none) + +def metadataTape (k : MachineRegularMetadata.Tape) : Tape := + .inl (MachineRegularOriginalBody.metadataTape k) + +def metadataView : Tape → Option MachineRegularMetadata.Tape + | .inl k => MachineRegularOriginalBody.metadataView k + | .inr _ => none + +def familyTape (k : MachineRegularFamily.Tape) : Tape := + .inl (MachineRegularOriginalBody.familyTape k) + +def familyView : Tape → Option MachineRegularFamily.Tape + | .inl k => MachineRegularOriginalBody.familyView k + | .inr _ => none + +def vertexView : Tape → Option (Fin 27) + | .inl k => MachineRegularOriginalBody.vertexView k + | .inr _ => none + +theorem metadataView_left (k : MachineRegularMetadata.Tape) : + metadataView (metadataTape k) = some k := MachineRegularOriginalBody.metadataView_left k + +theorem metadataView_right (j : Tape) (k : MachineRegularMetadata.Tape) + (h : metadataView j = some k) : metadataTape k = j := by + cases j with + | inl j => exact congrArg Sum.inl (MachineRegularOriginalBody.metadataView_right j k h) + | inr j => cases h + +theorem familyView_left (k : MachineRegularFamily.Tape) : + familyView (familyTape k) = some k := MachineRegularOriginalBody.familyView_left k + +theorem familyView_right (j : Tape) (k : MachineRegularFamily.Tape) + (h : familyView j = some k) : familyTape k = j := by + cases j with + | inl j => exact congrArg Sum.inl (MachineRegularOriginalBody.familyView_right j k h) + | inr j => cases h + +theorem vertexView_left (k : Fin 27) : vertexView (core k) = some k := rfl + +theorem vertexView_right (j : Tape) (k : Fin 27) + (h : vertexView j = some k) : core k = j := by + cases j with + | inl j => exact congrArg Sum.inl (MachineRegularOriginalBody.vertexView_right j k h) + | inr j => cases h + +def metadataStates : (MetaState × ((CoreState × FamilyState) × Option Bool)) ≃ State where + toFun p := (((p.2.1.1, p.1), p.2.1.2), p.2.2) + invFun p := (p.1.1.2, ((p.1.1.1, p.1.2), p.2)) + left_inv _ := rfl + right_inv _ := rfl + +def familyStates : (FamilyState × ((CoreState × MetaState) × Option Bool)) ≃ State where + toFun p := ((p.2.1, p.1), p.2.2) + invFun p := (p.1.2, (p.1.1, p.2)) + left_inv _ := rfl + right_inv _ := rfl + +def vertexStates : (CoreState × ((MetaState × FamilyState) × Option Bool)) ≃ State where + toFun p := (((p.1, p.2.1.1), p.2.1.2), p.2.2) + invFun p := (p.1.1.1, ((p.1.1.2, p.1.2), p.2)) + left_inv _ := rfl + right_inv _ := rfl + +inductive Label + | metadata (l : MachineRegularMetadata.Label) + | copyCount (l : MachineUnaryAffineAt.Label) + | copyFuel (l : MachineUnaryAffineAt.Label) + | guard + | family (l : MachineRegularFamily.Label) + | loop + | vertex (l : MachineRegularVertexBlock.Label internalDegree) + | bump + | cleanup (l : MachineRegularOwnerCleanup.Label) + deriving DecidableEq, Fintype + +def entry : Label := .metadata (.cloud .init) + +def program (H : BaseTable) : Label → TM2.Stmt Alphabet Label State + | .metadata l => Lift.statement metadataTape Label.metadata (some (.copyCount .seed)) + metadataStates (MachineRegularMetadata.program l) + | .copyCount .seed => MachineUnaryAffineAt.seed (core 3) 0 (.copyCount .scan) + | .copyCount .scan => MachineUnaryAffineAt.scan (core 4) scratch (core 3) 1 + (.copyCount .scan) (.copyCount .restore) + | .copyCount .restore => Reduction.MachineTransfer.loopAt scratch (core 4) id false + (.copyCount .restore) (some (.copyFuel .seed)) + | .copyFuel .seed => MachineUnaryAffineAt.seed dummyFuel 0 (.copyFuel .scan) + | .copyFuel .scan => MachineUnaryAffineAt.scan paddingTape scratch dummyFuel 1 + (.copyFuel .scan) (.copyFuel .restore) + | .copyFuel .restore => Reduction.MachineTransfer.loopAt scratch paddingTape id false + (.copyFuel .restore) (some .guard) + | .guard => .peek dummyFuel (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.load (fun state => (state.1, none)) (.goto fun _ => .family .start)) + (.load (fun state => (state.1, none)) + (.goto fun _ => .cleanup MachineRegularOwnerCleanup.entry))) + | .family l => Lift.statement familyTape Label.family (some .loop) + familyStates (MachineRegularFamily.program H l) + | .loop => .peek dummyFuel (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.pop dummyFuel (fun state _ => (state.1, none)) + (.goto fun _ => .vertex (MachineRegularVertexBlock.dummyEntry internalDegree + MachineRegularOriginalBody.degree_positive))) + (.load (fun state => (state.1, none)) + (.goto fun _ => .cleanup MachineRegularOwnerCleanup.entry))) + | .vertex l => Lift.statement core Label.vertex (some .bump) + vertexStates (MachineRegularOriginalBody.vertexSource l) + | .bump => .push (core 1) (fun _ => true) + (.push (core 3) (fun _ => true) (.goto fun _ => .loop)) + | .cleanup l => MachineRegularOwnerCleanup.instruction Label.cleanup none l + +def working (data : Data) (fuel saved : List Bool) : Tape → List Bool + | .inl k => MachineRegularOriginalBody.frame data k + | .inr i => if i = 0 then fuel else saved + +def frame (data : Data) : Tape → List Bool := working data [] [] + +def cfg (H : BaseTable) (label : Option Label) (data : Data) : TM2.Cfg Alphabet Label State := + ⟨label, readyState H, frame data⟩ + +def initialData (t : GraphTables.Table) (v : Fin t.vertices) (output : List Bool) : Data where + table := GraphTables.tableBits t + globalIndex := encodeWord (t.darts + PreprocessingPaddingOffsets.offset (padding t) v.val) + owner := encodeWord v.val + localRank := [] + count := [] + offset := encodeWord (PreprocessingPaddingOffsets.offset (padding t) v.val) + darts := encodeWord t.darts + rotor := [] + output := output + padding := [] + level := [] + +def metadataData (t : GraphTables.Table) (v : Fin t.vertices) (output : List Bool) : Data := + MachineRegularMetadata.cloudData t v (initialData t v output) + +def seededData (t : GraphTables.Table) (v : Fin t.vertices) (output : List Bool) : Data := + { metadataData t v output with localRank := encodeWord (cloudSize t v) } + +def ownerBits (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) : List Bool := + (List.ofFn (PreprocessingRegularWords.dummyVertexBits t (padding t) (familyCloudTable H t) v)).flatten + +def finalData (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) : Data := + { initialData t v output with + globalIndex := encodeWord (t.darts + PreprocessingPaddingOffsets.offset (padding t) v.val + padding t v) + offset := encodeWord (PreprocessingPaddingOffsets.offset (padding t) v.val + padding t v) + output := output ++ ownerBits H t v } + +end IndependentSetsGames.Foundations.Complexity.MachineRegularOwnerBody + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableBounds.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..d65e6b88373761059107e90efdf1610600fa1a8d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableBounds.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularTableTrace +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOwnerBodyBounds + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTable.Top + +open Turing MachineComposition PCP PreprocessingRegularTables +open PreprocessingRegularBounds PreprocessingMachineBounds + +noncomputable def oldLoopPolynomial : Polynomial Nat := + Polynomial.X * + (MachineRegularOriginalBodyBounds.timePolynomial.comp + (Polynomial.X + regularPolynomial) + 2) + +noncomputable def ownerLoopPolynomial : Polynomial Nat := + Polynomial.X * + (MachineRegularOwnerBodyBounds.timePolynomial.comp + (Polynomial.X + regularPolynomial) + 2) + +noncomputable def timePolynomial : Polynomial Nat := + Header.timePolynomial internalDegree + oldLoopPolynomial + ownerLoopPolynomial + + 4 * Polynomial.X + 12 + + Polynomial.C (7 * (ExpanderFamily.growth * (internalDegree + 4) + 4)) * + (Polynomial.X + 1) + +theorem oldElapsed_prefix_le (H : BaseTable) (t : GraphTables.Table) (k : Nat) : + oldElapsed H t (Header.headerBits internalDegree t) k ≤ + k * (MachineRegularOriginalBodyBounds.timePolynomial.eval + (inputLength t + regularPolynomial.eval (inputLength t)) + 2) := by + induction k with + | zero => simp [oldElapsed] + | succ k ih => + simp only [oldElapsed] + split_ifs with hk + · have raw := MachineRegularOriginalBodyBounds.totalSteps_le H t ⟨k, hk⟩ + (Header.headerBits internalDegree t ++ oldPrefix H t k) + have hprefix : + (Header.headerBits internalDegree t ++ oldPrefix H t k).length ≤ + regularPolynomial.eval (inputLength t) := by + exact regular_originalPrefix_le t H k + have hcall := raw.trans (natPolynomial_eval_mono + MachineRegularOriginalBodyBounds.timePolynomial (Nat.add_le_add_left hprefix _)) + rw [Nat.succ_mul] + omega + · rw [Nat.succ_mul] + omega + +theorem oldElapsed_le (H : BaseTable) (t : GraphTables.Table) : + oldElapsed H t (Header.headerBits internalDegree t) t.darts ≤ + oldLoopPolynomial.eval (inputLength t) := by + have bound := (oldElapsed_prefix_le H t t.darts).trans + (Nat.mul_le_mul_right _ (GraphTables.darts_le_tableBits_length t)) + simpa only [oldLoopPolynomial, inputLength, Polynomial.eval_mul, Polynomial.eval_X, + Polynomial.eval_add, Polynomial.eval_comp, Polynomial.eval_ofNat] using bound + +theorem ownerElapsed_prefix_le (H : BaseTable) (t : GraphTables.Table) (k : Nat) : + ownerElapsed H t + (Header.headerBits internalDegree t ++ oldPrefix H t t.darts) k ≤ + k * (MachineRegularOwnerBodyBounds.timePolynomial.eval + (inputLength t + regularPolynomial.eval (inputLength t)) + 2) := by + induction k with + | zero => simp [ownerElapsed] + | succ k ih => + simp only [ownerElapsed] + split_ifs with hk + · have raw := MachineRegularOwnerBodyBounds.totalSteps_le H t ⟨k, hk⟩ + ((Header.headerBits internalDegree t ++ oldPrefix H t t.darts) ++ ownerPrefix H t k) + have hprefix : + ((Header.headerBits internalDegree t ++ oldPrefix H t t.darts) ++ + ownerPrefix H t k).length ≤ regularPolynomial.eval (inputLength t) := by + rw [owner_output_eq_ownerPrefix] + exact regular_ownerPrefix_le t H k + have hcall := raw.trans (natPolynomial_eval_mono + MachineRegularOwnerBodyBounds.timePolynomial (Nat.add_le_add_left hprefix _)) + rw [Nat.succ_mul] + omega + · rw [Nat.succ_mul] + omega + +theorem ownerElapsed_le (H : BaseTable) (t : GraphTables.Table) : + ownerElapsed H t + (Header.headerBits internalDegree t ++ oldPrefix H t t.darts) t.vertices ≤ + ownerLoopPolynomial.eval (inputLength t) := by + have bound := (ownerElapsed_prefix_le H t t.vertices).trans + (Nat.mul_le_mul_right _ (GraphTables.vertices_le_tableBits_length t)) + simpa only [ownerLoopPolynomial, inputLength, Polynomial.eval_mul, Polynomial.eval_X, + Polynomial.eval_add, Polynomial.eval_comp, Polynomial.eval_ofNat] using bound + +theorem totalTime_le (H : BaseTable) (t : GraphTables.Table) : + totalTime H t ≤ timePolynomial.eval (inputLength t) := by + have header := Header.totalTime_le internalDegree t [] + simp only [List.length_nil, Nat.add_zero] at header + change Header.totalTime internalDegree t [] ≤ + (Header.timePolynomial internalDegree).eval (inputLength t) at header + have old := oldElapsed_le H t + have owners := ownerElapsed_le H t + have cleanup := cleanupTime_final_le t (finalOutput H t) + have hm : t.darts ≤ inputLength t := GraphTables.darts_le_tableBits_length t + have hn : t.vertices ≤ inputLength t := GraphTables.vertices_le_tableBits_length t + simp only [totalTime, headerOutput, oldOutput, timePolynomial, + Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_ofNat, Polynomial.eval_one] + omega + +noncomputable def machineInTime (H : BaseTable) (t : GraphTables.Table) : + StateTransition.EvalsToInTime (TM2.step (program H)) + (initList (machine H) (GraphTables.tableBits t)) + (some ⟨none, readyState H, + Function.update (initList (machine H) (GraphTables.tableBits t)).stk + (coreTape 8) (PortTables.tableBits (regularize H t))⟩) + (timePolynomial.eval (inputLength t)) where + steps := totalTime H t + evals_in_steps := trace H t + steps_le_m := totalTime_le H t + +end IndependentSetsGames.Foundations.Complexity.MachineRegularTable.Top +namespace IndependentSetsGames.Foundations.Complexity.MachineCanonicalOutput + +open Turing MachineComposition + +structure Program (K Λ σ : Type) where + input : K + output : K + main : Λ + initial : σ + code : Λ → TM2.Stmt (fun _ : K => Bool) Λ σ + +end IndependentSetsGames.Foundations.Complexity.MachineCanonicalOutput + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableRuntime.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableRuntime.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7070c8a9658e7c9e25ac0737355060004c6e5ae --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableRuntime.lean @@ -0,0 +1,253 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Structural +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingStageMaps + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTableRuntime + +open Turing +open PCP +open MachineRegularTable.Top (Tape Label State coreTape readyState) + +def rawProgram (H : PreprocessingRegularTables.BaseTable) : + MachineCanonicalOutput.Program Tape Label State where + input := coreTape 0 + output := coreTape 8 + main := .header .init + initial := readyState H + code := MachineRegularTable.Top.program H + +theorem sourceMachine_eq (H : PreprocessingRegularTables.BaseTable) : + MachineCanonicalOutput.sourceMachine (rawProgram H) = + MachineRegularTable.Top.machine H := rfl + +noncomputable def cleanupTapes : List Tape := + (Finset.univ : Finset Tape).toList.filter (fun k => decide (k ≠ coreTape 8)) + +theorem cleanup_complete (H : PreprocessingRegularTables.BaseTable) (k : Tape) : + k ∈ cleanupTapes ↔ k ≠ (rawProgram H).output := by + simp [cleanupTapes, rawProgram] + +noncomputable def terminalRun (H : PreprocessingRegularTables.BaseTable) + (t : GraphTables.Table) : + MachineCanonicalOutput.TerminalRun (rawProgram H) (GraphTables.tableBits t) + (PortTables.inputBits (PreprocessingStageMaps.regular H t)) + (MachineRegularTable.Top.timePolynomial.eval (GraphTables.tableBits t).length) where + state := readyState H + tapes := Function.update + (initList (MachineRegularTable.Top.machine H) (GraphTables.tableBits t)).stk + (coreTape 8) (PortTables.inputBits (PreprocessingStageMaps.regular H t)) + execution := by + change StateTransition.EvalsToInTime (TM2.step (MachineRegularTable.Top.program H)) + (initList (MachineRegularTable.Top.machine H) (GraphTables.tableBits t)) + (some ⟨none, readyState H, + Function.update (initList (MachineRegularTable.Top.machine H) + (GraphTables.tableBits t)).stk (coreTape 8) + (PortTables.tableBits (PreprocessingRegularTables.regularize H t))⟩) + (MachineRegularTable.Top.timePolynomial.eval (PreprocessingMachineBounds.inputLength t)) + exact MachineRegularTable.Top.machineInTime H t + output_eq := Function.update_self _ _ _ + +noncomputable def computableInPolyTime (H : PreprocessingRegularTables.BaseTable) : + TM2ComputableInPolyTime GraphTables.tableBits + (PortTables.inputBits (ports := PreprocessingRegularTables.internalDegree + 1)) + (PreprocessingStageMaps.regular H) := + MachineCanonicalOutput.computableInPolyTime (rawProgram H) cleanupTapes + (cleanup_complete H) GraphTables.tableBits PortTables.inputBits + (PreprocessingStageMaps.regular H) MachineRegularTable.Top.timePolynomial (terminalRun H) + +theorem finite_alphabet (H : PreprocessingRegularTables.BaseTable) : + ∀ k, Finite ((computableInPolyTime H).tm.Γ k) := + MachineCanonicalOutput.computableInPolyTime_finite_alphabet (rawProgram H) cleanupTapes + (cleanup_complete H) GraphTables.tableBits PortTables.inputBits + (PreprocessingStageMaps.regular H) MachineRegularTable.Top.timePolynomial (terminalRun H) + +end IndependentSetsGames.Foundations.Complexity.MachineRegularTableRuntime +namespace IndependentSetsGames.Foundations.Complexity.MachineTableSplit + +open Turing MachineComposition + +abbrev Tape := Fin 5 +abbrev State (σ : Type) := σ × Option Bool + +inductive Label + | copyFirst | copySecond | startVertices | readVertices | startDarts | readDarts + deriving DecidableEq + +instance : Fintype Label where + elems := {.copyFirst, .copySecond, .startVertices, .readVertices, .startDarts, .readDarts} + complete value := by cases value <;> simp + +def tapes (original work vertices darts : List Bool) : Tape → List Bool := + fun k => if k = 0 then original else if k = 1 then work + else if k = 3 then vertices else if k = 4 then darts else [] + +def initialTapes (input : List Bool) : Tape → List Bool := tapes input [] [] [] + +def resultTapes (n m : Nat) (rowsBits : List Bool) : Tape → List Bool := + tapes (encodeWords [n, m] ++ rowsBits) rowsBits (encodeWord n) (encodeWord m) + +@[simp] theorem resultTapes_original (n m : Nat) (rowsBits : List Bool) : + resultTapes n m rowsBits 0 = encodeWords [n, m] ++ rowsBits := by + simp [resultTapes, tapes] + +@[simp] theorem resultTapes_work (n m : Nat) (rowsBits : List Bool) : + resultTapes n m rowsBits 1 = rowsBits := by simp [resultTapes, tapes] + +@[simp] theorem resultTapes_scratch (n m : Nat) (rowsBits : List Bool) : + resultTapes n m rowsBits 2 = [] := by simp [resultTapes, tapes] + +@[simp] theorem resultTapes_vertices (n m : Nat) (rowsBits : List Bool) : + resultTapes n m rowsBits 3 = encodeWord n := by simp [resultTapes, tapes] + +@[simp] theorem resultTapes_darts (n m : Nat) (rowsBits : List Bool) : + resultTapes n m rowsBits 4 = encodeWord m := by simp [resultTapes, tapes] + +def program {σ : Type} : Label → TM2.Stmt (fun _ : Tape => Bool) Label (State σ) + | .copyFirst => Reduction.MachineTransfer.loopAt 0 2 id false .copyFirst (some .copySecond) + | .copySecond => MachineCopy.forkLoop 2 0 1 false .copySecond (some .startVertices) + | .startVertices => Hastad.SourceMachine.fieldStart 3 .readVertices + | .readVertices => Hastad.SourceMachine.fieldLoop 1 3 .readVertices (some .startDarts) + | .startDarts => Hastad.SourceMachine.fieldStart 4 .readDarts + | .readDarts => Hastad.SourceMachine.fieldLoop 1 4 .readDarts none + +def exactSteps (n m : Nat) (rowsBits : List Bool) : Nat := + 2 * (encodeWords [n, m] ++ rowsBits).length + n + m + 6 + +theorem splitTrace {σ : Type} (n m : Nat) (rowsBits : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program (σ := σ))))^[exactSteps n m rowsBits] + (some ⟨some .copyFirst, (ambient, register), + initialTapes (encodeWords [n, m] ++ rowsBits)⟩) = + some ⟨none, (ambient, none), resultTapes n m rowsBits⟩ := by + let word := encodeWords [n, m] ++ rowsBits + let b₀ := initialTapes word + let b₁ := tapes word word [] [] + let b₂ := tapes word (encodeWord m ++ rowsBits) (encodeWord n) [] + let b₃ := resultTapes n m rowsBits + have h₀ : Function.update b₀ (1 : Tape) (b₀ 0 ++ b₀ 1) = b₁ := by + funext k; fin_cases k <;> simp [b₀, b₁, initialTapes, tapes] + have h₁ : Hastad.SourceMachine.fieldTapes (1 : Tape) 3 b₁ + (encodeWord m ++ rowsBits) (encodeWord n ++ b₁ 3) = b₂ := by + funext k; fin_cases k <;> simp [b₁, b₂, tapes, Hastad.SourceMachine.fieldTapes] + have h₂ : Hastad.SourceMachine.fieldTapes (1 : Tape) 4 b₂ + rowsBits (encodeWord m ++ b₂ 4) = b₃ := by + funext k; fin_cases k <;> + simp [b₂, b₃, resultTapes, tapes, word, Hastad.SourceMachine.fieldTapes] + have copy := MachineCopy.copyTrace (0 : Tape) 1 2 + (by decide) (by decide) (by decide) false .copyFirst .copySecond (some .startVertices) + (program (σ := σ)) rfl rfl b₀ (by simp [b₀, initialTapes, tapes]) ambient register + rw [h₀] at copy + have c₀ : (advance (TM2.step (program (σ := σ))))^[2 * (word.length + 1)] + (some ⟨some .copyFirst, (ambient, register), b₀⟩) = + some ⟨some .startVertices, (ambient, none), b₁⟩ := by + simpa only [show b₀ 0 = word by simp [b₀, initialTapes, tapes]] using copy + have scan₁ := (Hastad.SourceMachine.fieldInTime (1 : Tape) 3 (by decide) + .startVertices .readVertices (some .startDarts) (program (σ := σ)) rfl rfl + b₁ n (encodeWord m ++ rowsBits) + (by simp [b₁, tapes, word, encodeWords, List.append_assoc]) ambient none).evals_in_steps + have c₁ : (advance (TM2.step (program (σ := σ))))^[n + 2] + (some ⟨some .startVertices, (ambient, none), b₁⟩) = + some ⟨some .startDarts, (ambient, none), b₂⟩ := by + dsimp only [Hastad.SourceMachine.fieldInTime] at scan₁ + change (advance (TM2.step (program (σ := σ))))^[n + 2] + (some ⟨some .startVertices, (ambient, none), b₁⟩) = + some ⟨some .startDarts, (ambient, none), + Hastad.SourceMachine.fieldTapes (1 : Tape) 3 b₁ (encodeWord m ++ rowsBits) + (encodeWord n ++ b₁ 3)⟩ at scan₁ + simpa only [h₁] using scan₁ + have scan₂ := (Hastad.SourceMachine.fieldInTime (1 : Tape) 4 (by decide) + .startDarts .readDarts none (program (σ := σ)) rfl rfl + b₂ m rowsBits (by simp [b₂, tapes]) ambient none).evals_in_steps + have c₂ : (advance (TM2.step (program (σ := σ))))^[m + 2] + (some ⟨some .startDarts, (ambient, none), b₂⟩) = + some ⟨none, (ambient, none), b₃⟩ := by + dsimp only [Hastad.SourceMachine.fieldInTime] at scan₂ + change (advance (TM2.step (program (σ := σ))))^[m + 2] + (some ⟨some .startDarts, (ambient, none), b₂⟩) = + some ⟨none, (ambient, none), + Hastad.SourceMachine.fieldTapes (1 : Tape) 4 b₂ rowsBits + (encodeWord m ++ b₂ 4)⟩ at scan₂ + simpa only [h₂] using scan₂ + have c₀₁ : (advance (TM2.step (program (σ := σ))))^[(n + 2) + 2 * (word.length + 1)] + (some ⟨some .copyFirst, (ambient, register), b₀⟩) = + some ⟨some .startDarts, (ambient, none), b₂⟩ := by + rw [Function.iterate_add_apply, c₀, c₁] + have c₀₁₂ : (advance (TM2.step (program (σ := σ))))^[(m + 2) + + ((n + 2) + 2 * (word.length + 1))] + (some ⟨some .copyFirst, (ambient, register), b₀⟩) = + some ⟨none, (ambient, none), b₃⟩ := by + rw [Function.iterate_add_apply, c₀₁, c₂] + have count : exactSteps n m rowsBits = (m + 2) + ((n + 2) + 2 * (word.length + 1)) := by + dsimp [exactSteps, word] + omega + rw [count] + exact c₀₁₂ + +noncomputable def timePolynomial : Polynomial Nat := Polynomial.C 4 * Polynomial.X + Polynomial.C 6 + +@[simp] theorem timePolynomial_eval (length : Nat) : + timePolynomial.eval length = 4 * length + 6 := by simp [timePolynomial] + +theorem exactSteps_le (n m : Nat) (rowsBits : List Bool) : + exactSteps n m rowsBits ≤ timePolynomial.eval (encodeWords [n, m] ++ rowsBits).length := by + rw [timePolynomial_eval] + simp only [exactSteps, List.length_append, encodeWords_length, List.sum_cons, + List.sum_nil, List.length_cons, List.length_nil] + omega + +def splitInTime {σ : Type} (n m : Nat) (rowsBits : List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program (σ := σ))) + ⟨some .copyFirst, (ambient, register), initialTapes (encodeWords [n, m] ++ rowsBits)⟩ + (some ⟨none, (ambient, none), resultTapes n m rowsBits⟩) + (timePolynomial.eval (encodeWords [n, m] ++ rowsBits).length) where + steps := exactSteps n m rowsBits + evals_in_steps := splitTrace n m rowsBits ambient register + steps_le_m := exactSteps_le n m rowsBits + +def machine : FinTM2 where + K := Tape + k₀ := 0 + k₁ := 1 + Γ _ := Bool + Λ := Label + main := .copyFirst + σ := State Unit + initialState := ((), none) + m := program + +theorem initial_configuration (input : List Bool) : + initList machine input = ⟨some .copyFirst, ((), none), initialTapes input⟩ := by + have ht : (initList machine input).stk = initialTapes input := by + change (fun tape : Tape => if tape = 0 then input else []) = initialTapes input + funext tape + fin_cases tape <;> simp [initialTapes, tapes] + exact congrArg (TM2.Cfg.mk _ _) ht + +def rowsBits (table : PCP.GraphTables.Table) : List Bool := + encodeWords ((PCP.GraphTables.rowList table).flatMap PCP.GraphTables.rowWords) + +theorem tableBits_header_rows (table : PCP.GraphTables.Table) : + PCP.GraphTables.tableBits table = encodeWords [table.vertices, table.darts] ++ rowsBits table := by + simp only [PCP.GraphTables.tableBits, PCP.GraphTables.tableWords, encodeWords_append, rowsBits] + +theorem tableTrace {σ : Type} (table : PCP.GraphTables.Table) (ambient : σ) + (register : Option Bool) : + (advance (TM2.step (program (σ := σ))))^[exactSteps table.vertices table.darts (rowsBits table)] + (some ⟨some .copyFirst, (ambient, register), initialTapes (PCP.GraphTables.tableBits table)⟩) = + some ⟨none, (ambient, none), resultTapes table.vertices table.darts (rowsBits table)⟩ := by + rw [tableBits_header_rows] + exact splitTrace table.vertices table.darts (rowsBits table) ambient register + +def initializedTableInTime (table : PCP.GraphTables.Table) : + StateTransition.EvalsToInTime machine.step (initList machine (PCP.GraphTables.tableBits table)) + (some ⟨none, ((), none), resultTapes table.vertices table.darts (rowsBits table)⟩) + (timePolynomial.eval (PCP.GraphTables.tableBits table).length) := by + rw [initial_configuration, tableBits_header_rows] + exact splitInTime table.vertices table.darts (rowsBits table) () none + +end IndependentSetsGames.Foundations.Complexity.MachineTableSplit + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableTrace.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea68e52e1fae1a89691b0c36fe29e05114fb7485 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularTableTrace.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.OwnerData + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTable.Top + +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP + +private theorem joinTraceTopFinal {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +private theorem normalizeEmptyAppend {A : Type*} (output : List Bool → A) + (bits : List Bool) : output ([] ++ bits) = output bits := + congrArg output (List.nil_append bits) + +theorem headerStartTrace (H : BaseTable) (t : GraphTables.Table) : + (advance (TM2.step (program H)))^[Header.totalTime PreprocessingRegularTables.internalDegree t []] + (some (cfg H (some (.header .init)) (inputData t []) (fun _ => []) + (counterStacks [] [] [] []))) = + some (cfg H (some .oldSeed) (headerData t (headerOutput t)) (headerStacks t) + (counterStacks [] [] [] [])) := by + have run := headerTrace H t [] (counterStacks [] [] [] []) + exact run.trans (normalizeEmptyAppend + (fun output : List Bool => some (cfg H (some Label.oldSeed) + (headerData t output) (headerStacks t) (counterStacks [] [] [] []))) + (Header.headerBits PreprocessingRegularTables.internalDegree t)) + +theorem headerOldTrace (H : BaseTable) (t : GraphTables.Table) : + (advance (TM2.step (program H)))^[ + Header.totalTime PreprocessingRegularTables.internalDegree t [] + + (1+2*(t.darts+2)+(oldElapsed H t (headerOutput t) t.darts+1))] + (some (cfg H (some (.header .init)) (inputData t []) (fun _ => []) + (counterStacks [] [] [] []))) = + some (cfg H (some .ownerSeed) (oldData t t.darts (oldOutput H t)) (headerStacks t) + (counterStacks [] [] [] [])) := by + have first := headerStartTrace H t + have second := oldStageTrace H t (headerOutput t) (headerStacks t) + have joined := joinTraceTopFinal (f := advance (TM2.step (program H))) first second + have output_eq : headerOutput t ++ oldPrefix H t t.darts = oldOutput H t := rfl + exact joined.trans (congrArg + (fun output : List Bool => some (cfg H (some Label.ownerSeed) + (oldData t t.darts output) (headerStacks t) (counterStacks [] [] [] []))) output_eq) + +theorem beforeCleanupTrace (H : BaseTable) (t : GraphTables.Table) : + (advance (TM2.step (program H)))^[ + Header.totalTime PreprocessingRegularTables.internalDegree t [] + + (1+2*(t.darts+2)+(oldElapsed H t (headerOutput t) t.darts+1)) + + (1+2*(t.vertices+2)+(ownerElapsed H t (oldOutput H t) t.vertices+1))] + (some (cfg H (some (.header .init)) (inputData t []) (fun _ => []) + (counterStacks [] [] [] []))) = + some ⟨clearEntry 0, readyState H, finalStacks t (finalOutput H t)⟩ := by + have first := headerOldTrace H t + have second := ownerStageTrace H t (oldOutput H t) + have joined := joinTraceTopFinal (f := advance (TM2.step (program H))) first second + have output_eq : oldOutput H t ++ ownerPrefix H t t.vertices = finalOutput H t := rfl + exact joined.trans (congrArg + (fun output : List Bool => some (cfg H (clearEntry 0) + (ownerData t t.vertices output) (headerStacks t) (counterStacks [] [] [] []))) output_eq) + +theorem cleanupFinalTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) : + (advance (TM2.step (program H)))^[cleanupTime (finalStacks t output) 7] + (some ⟨clearEntry 0, readyState H, finalStacks t output⟩) = + some (cfg H none (inputData t output) (fun _ => []) (counterStacks [] [] [] [])) := + (cleanupTrace H (finalStacks t output)).trans + (congrArg (fun terminalStacks => some (⟨none, readyState H, terminalStacks⟩ : TM2.Cfg Alphabet Label State)) + (cleaned_finalStacks t output)) + +theorem fullTrace (H : BaseTable) (t : GraphTables.Table) : + (advance (TM2.step (program H)))^[totalTime H t] + (some (cfg H (some (.header .init)) (inputData t []) (fun _ => []) + (counterStacks [] [] [] []))) = + some (cfg H none (inputData t (finalOutput H t)) (fun _ => []) + (counterStacks [] [] [] [])) := + joinTraceTopFinal (f := advance (TM2.step (program H))) (beforeCleanupTrace H t) (cleanupFinalTrace H t (finalOutput H t)) + +@[simp] theorem update_frame_output (data : Data) (header : Header.Tape → List Bool) + (counters : Fin 4 → List Bool) (replacement : List Bool) : + Function.update (frame data header counters) (coreTape 8) replacement = + frame { data with output := replacement } header counters := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> rfl + | inr e => cases e with + | inl e => cases e <;> rfl + | inr e => rfl + | inr j => cases j <;> rfl + +theorem input_stacks_eq (H : BaseTable) (t : GraphTables.Table) : + frame (inputData t []) (fun _ => []) (counterStacks [] [] [] []) = + (Turing.initList (machine H) (GraphTables.tableBits t)).stk := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> rfl + | inr e => cases e with + | inl e => cases e <;> + simp [Turing.initList, machine, coreTape, frame, inputData, + MachineRegularOriginalBody.frame, MachineRegularMetadata.frame] + | inr e => + simp [Turing.initList, machine, coreTape, frame, + MachineRegularOriginalBody.frame] + | inr j => cases j with + | inl j => simp [Turing.initList, machine, coreTape, frame] + | inr j => fin_cases j <;> simp [Turing.initList, machine, coreTape, frame, counterStacks] + +theorem initial_cfg_eq (H : BaseTable) (t : GraphTables.Table) : + cfg H (some (.header .init)) (inputData t []) (fun _ => []) (counterStacks [] [] [] []) = + Turing.initList (machine H) (GraphTables.tableBits t) := by + change (⟨some (.header .init), readyState H, + frame (inputData t []) (fun _ => []) (counterStacks [] [] [] [])⟩ : TM2.Cfg Alphabet Label State) = + ⟨some (.header .init), readyState H, (Turing.initList (machine H) (GraphTables.tableBits t)).stk⟩ + rw [input_stacks_eq] + +theorem trace (H : BaseTable) (t : GraphTables.Table) : + (advance (TM2.step (program H)))^[totalTime H t] + (some (Turing.initList (machine H) (GraphTables.tableBits t))) = + some ⟨none, readyState H, + Function.update (Turing.initList (machine H) (GraphTables.tableBits t)).stk + (coreTape 8) (PortTables.tableBits (PreprocessingRegularTables.regularize H t))⟩ := by + have full := fullTrace H t + rw [initial_cfg_eq, finalOutput_eq] at full + have final_stacks : + frame (inputData t (PortTables.tableBits (PreprocessingRegularTables.regularize H t))) + (fun _ => []) (counterStacks [] [] [] []) = + Function.update (Turing.initList (machine H) (GraphTables.tableBits t)).stk (coreTape 8) + (PortTables.tableBits (PreprocessingRegularTables.regularize H t)) := by + exact (update_frame_output (inputData t []) (fun _ => []) + (counterStacks [] [] [] []) + (PortTables.tableBits (PreprocessingRegularTables.regularize H t))).symm.trans + (congrArg (fun stk : Tape → List Bool => Function.update stk (coreTape 8) + (PortTables.tableBits (PreprocessingRegularTables.regularize H t))) + (input_stacks_eq H t)) + change (advance (TM2.step (program H)))^[totalTime H t] + (some (Turing.initList (machine H) (GraphTables.tableBits t))) = + some ⟨none, readyState H, + frame (inputData t (PortTables.tableBits (PreprocessingRegularTables.regularize H t))) + (fun _ => []) (counterStacks [] [] [] [])⟩ at full + rw [final_stacks] at full + exact full + +end IndependentSetsGames.Foundations.Complexity.MachineRegularTable.Top + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularVertexBlock.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularVertexBlock.lean new file mode 100644 index 0000000000000000000000000000000000000000..75fa9ead4812aaeedcc9de28953ffec0f348d223 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRegularVertexBlock.lean @@ -0,0 +1,599 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.CoreInputTapes +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalClean +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularDummyRow +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularWords + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularVertexBlock + +open Turing MachineComposition PCP MachineRegularInternalRow +open PreprocessingCloudIndex PreprocessingRegularTables + +variable {σ Λ : Type} + +abbrev PortLabel (q : Nat) := Fin q × CoreLabel q + +def portEntry (q : Nat) (labels : PortLabel q → Λ) (exit : Option Λ) (k : Nat) : + Option Λ := + if h : k < q then some (labels (⟨k, h⟩, coreEntry q)) else exit + +def portInstruction (q : Nat) (positive : 0 < q) (labels : PortLabel q → Λ) + (exit : Option Λ) (l : PortLabel q) : + TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q) := + coreInstruction q positive l.1 (fun s => labels (l.1, s)) + (portEntry q labels exit (l.1.val + 1)) l.2 + +def portBits {q : Nat} (bits : Fin q → List Bool) : Nat → List Bool + | 0 => [] + | k + 1 => portBits bits k ++ if h : k < q then bits ⟨k, h⟩ else [] + +theorem portBits_eq {q : Nat} (bits : Fin q → List Bool) (k : Nat) (hk : k ≤ q) : + portBits bits k = (List.ofFn (fun p : Fin k => bits ⟨p.val, lt_of_lt_of_le p.isLt hk⟩)).flatten := by + induction k with + | zero => rfl + | succ k ih => + have h : k < q := by omega + rw [portBits, dite_eq_left h, ih (by omega), List.ofFn_succ_last, List.flatten_append] + simp only [List.flatten_cons, List.flatten_nil, List.append_nil] + rfl + +theorem portBits_all {q : Nat} (bits : Fin q → List Bool) : + portBits bits q = (List.ofFn bits).flatten := by + simpa only [Fin.eta] using portBits_eq bits q (Nat.le_refl q) + +def rowBits (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : List Bool := + encodeWords (GraphTables.rowWords (PreprocessingInternalRows.row t padding tables v x p)) + +def portSteps (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) (outputLength : Nat) : Nat → Nat + | 0 => 0 + | k + 1 => portSteps t padding tables v x outputLength k + + if h : k < q then coreSteps t padding tables v x ⟨k, h⟩ + (outputLength + (portBits (rowBits t padding tables v x) k).length) else 0 + +theorem joinTrace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +theorem portPrefixTrace (q : Nat) (positive : 0 < q) + (labels : PortLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = portInstruction q positive labels exit l) + (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) (output : List Bool) (ambient : σ) + (k : Nat) (hk : k ≤ q) : + (advance (TM2.step program))^[portSteps t padding tables v x output.length k] + (some ⟨portEntry q labels exit 0, coreInitialState q positive ambient, + coreInputTapes t padding tables v x output⟩) = + some ⟨portEntry q labels exit k, coreInitialState q positive ambient, + coreInputTapes t padding tables v x + (output ++ portBits (rowBits t padding tables v x) k)⟩ := by + induction k with + | zero => simp only [portSteps, portBits, List.append_nil, Function.iterate_zero, id_eq] + | succ k ih => + have h : k < q := by omega + have first := ih (by omega) + have second := coreTrace q positive ⟨k, h⟩ (fun s => labels (⟨k, h⟩, s)) + (portEntry q labels exit (k + 1)) program (fun s => code (⟨k, h⟩, s)) + t padding tables v x (output ++ portBits (rowBits t padding tables v x) k) ambient + have he : portEntry q labels exit k = some (labels (⟨k, h⟩, coreEntry q)) := by + simp only [portEntry, dite_eq_left h] + rw [he] at first + have total := joinTrace first second + simpa only [portSteps, dite_eq_left h, List.length_append, portBits, rowBits, + List.append_assoc] using total + +theorem portTrace (q : Nat) (positive : 0 < q) + (labels : PortLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = portInstruction q positive labels exit l) + (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) (output : List Bool) (ambient : σ) : + (advance (TM2.step program))^[portSteps t padding tables v x output.length q] + (some ⟨portEntry q labels exit 0, coreInitialState q positive ambient, + coreInputTapes t padding tables v x output⟩) = + some ⟨exit, coreInitialState q positive ambient, + coreInputTapes t padding tables v x + (output ++ (List.ofFn (rowBits t padding tables v x)).flatten)⟩ := by + simpa only [portEntry, lt_self_iff_false, dite_false, portBits_all] using + portPrefixTrace q positive labels exit program code t padding tables v x output ambient q le_rfl + +def originalTapes : MachineRegularOriginalClean.Tape → CoreTape := + ![1, 0, 10, 11, 12, 9, 24, 25, 26, 8] + +def originalView : CoreTape → Option MachineRegularOriginalClean.Tape := + ![some 1, some 0, none, none, none, none, none, none, some 9, some 5, + some 2, some 3, some 4, none, none, none, none, none, none, none, + none, none, none, none, some 6, some 7, some 8] + +theorem originalView_left (k : MachineRegularOriginalClean.Tape) : + originalView (originalTapes k) = some k := by fin_cases k <;> rfl + +theorem originalView_right (j : CoreTape) (k : MachineRegularOriginalClean.Tape) + (h : originalView j = some k) : originalTapes k = j := by + fin_cases j <;> simp [originalView] at h + all_goals subst k; rfl + +def originalStateEquiv (σ : Type) (q : Nat) : + MachineRegularOriginalClean.State (σ × (Fin q × (Bool × MachineCloudSelect.Phase))) ≃ + CoreState σ q where + toFun s := ((s.1.1.1, (s.1.2, s.1.1.2)), s.2) + invFun s := (((s.1.1, s.1.2.2), s.1.2.1), s.2) + left_inv s := by rcases s with ⟨⟨⟨a,b⟩,c⟩,d⟩; rfl + right_inv s := by rcases s with ⟨⟨a,⟨b,c⟩⟩,d⟩; rfl + +def originalCoreInstruction (q : Nat) (labels : MachineRegularOriginalClean.Label → Λ) + (exit : Option Λ) (l : MachineRegularOriginalClean.Label) : + TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q) := + MachineCloudPadding.Placement.statement originalTapes labels exit + (MachineStateEquiv.statement (originalStateEquiv σ q) + (MachineRegularOriginalClean.instruction q id none l)) + +def originalMemory (graph : List Bool) (x : Nat) (output : List Bool) : + MachineRegularOriginalClean.Tape → List Bool := + ![encodeWord x, graph, [], [], [], [], [], [], [], output] + +theorem originalMemory_input (t : GraphTables.Table) (e : Fin t.darts) (output : List Bool) : + MachineRegularOriginalClean.Input t e (originalMemory (GraphTables.tableBits t) e.val output) := + ⟨⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩, rfl, rfl⟩ + +theorem originalMemory_update (graph : List Bool) (x : Nat) (output output' : List Bool) : + Function.update (originalMemory graph x output) (9 : MachineRegularOriginalClean.Tape) output' = + originalMemory graph x output' := by funext j; fin_cases j <;> rfl + +theorem originalFrame (graph : List Bool) (x v i k o m : Nat) (rotor output output' : List Bool) : + MachineCloudPadding.Placement.tapes originalView (originalMemory graph x output') + (coreMemory graph x v i k o m rotor output [] [] [] [] [] []) = + coreMemory graph x v i k o m rotor output' [] [] [] [] [] [] := by + funext j; fin_cases j <;> rfl + +theorem originalCoreTrace (q : Nat) (positive : 0 < q) + (labels : MachineRegularOriginalClean.Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = originalCoreInstruction q labels exit l) + (t : GraphTables.Table) (e : Fin t.darts) (v i k o m : Nat) + (rotor output : List Bool) (ambient : σ) : + (advance (TM2.step program))^[MachineRegularOriginalClean.steps q t e + (originalMemory (GraphTables.tableBits t) e.val output)] + (some ⟨some (labels (.row (.lookup .seed))), coreInitialState q positive ambient, + coreMemory (GraphTables.tableBits t) e.val v i k o m rotor output [] [] [] [] [] []⟩) = + some ⟨exit, coreInitialState q positive ambient, + coreMemory (GraphTables.tableBits t) e.val v i k o m rotor + (output ++ encodeWords (MachineRegularOriginalRow.emittedWords q t e)) + [] [] [] [] [] []⟩ := by + let state := (ambient, (MachineFixedDivMod.residue q positive 0, + (false, MachineCloudSelect.Phase.checking))) + have run := MachineRegularOriginalClean.traceAt q id none + (MachineRegularOriginalClean.instruction q id none) (fun _ => rfl) t e + (originalMemory (GraphTables.tableBits t) e.val output) + (originalMemory_input t e output) state none + rw [originalMemory_update] at run + have moved := MachineStateEquiv.trace (originalStateEquiv σ q) + (MachineRegularOriginalClean.instruction q id none) _ _ _ run + have placed := MachineCloudPadding.Placement.trace originalTapes originalView + originalView_left originalView_right labels exit + (coreMemory (GraphTables.tableBits t) e.val v i k o m rotor output [] [] [] [] [] []) + (MachineStateEquiv.program (originalStateEquiv σ q) + (MachineRegularOriginalClean.instruction q id none)) program code _ _ _ moved + simp only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, + MachineStateEquiv.configuration, originalFrame] at placed + convert placed using 1 <;> rfl + +def dummyTapes : MachineRegularDummyRow.Tape → CoreTape := ![1, 24, 25, 9, 8, 26] + +def dummyView : CoreTape → Option MachineRegularDummyRow.Tape := + ![none, some 0, none, none, none, none, none, none, some 4, some 3, + none, none, none, none, none, none, none, none, none, none, + none, none, none, none, some 1, some 2, some 5] + +theorem dummyView_left (k : MachineRegularDummyRow.Tape) : + dummyView (dummyTapes k) = some k := by fin_cases k <;> rfl + +theorem dummyView_right (j : CoreTape) (k : MachineRegularDummyRow.Tape) + (h : dummyView j = some k) : dummyTapes k = j := by + fin_cases j <;> simp [dummyView] at h + all_goals subst k; rfl + +def dummyCoreInstruction (q : Nat) (labels : MachineRegularDummyRow.Label → Λ) + (exit : Option Λ) (l : MachineRegularDummyRow.Label) : + TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q) := + MachineCloudPadding.Placement.statement dummyTapes labels exit + (MachineRegularDummyRow.instruction q id none l) + +theorem dummyMemory_update (x : Nat) (output output' : List Bool) : + Function.update (MachineRegularDummyRow.memory x output) + (4 : MachineRegularDummyRow.Tape) output' = MachineRegularDummyRow.memory x output' := by + funext j; fin_cases j <;> rfl + +theorem dummyFrame (graph : List Bool) (x v i k o m : Nat) (rotor output output' : List Bool) : + MachineCloudPadding.Placement.tapes dummyView (MachineRegularDummyRow.memory x output') + (coreMemory graph x v i k o m rotor output [] [] [] [] [] []) = + coreMemory graph x v i k o m rotor output' [] [] [] [] [] [] := by + funext j; fin_cases j <;> rfl + +theorem dummyCoreTrace (q : Nat) (positive : 0 < q) + (labels : MachineRegularDummyRow.Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = dummyCoreInstruction q labels exit l) + (graph : List Bool) (x v i k o m : Nat) (rotor output : List Bool) (ambient : σ) : + (advance (TM2.step program))^[MachineRegularDummyRow.timeBound q x output.length] + (some ⟨some (labels (.affine .seed)), coreInitialState q positive ambient, + coreMemory graph x v i k o m rotor output [] [] [] [] [] []⟩) = + some ⟨exit, coreInitialState q positive ambient, + coreMemory graph x v i k o m rotor + (output ++ MachineRegularDummyRow.emittedBits q x) [] [] [] [] [] []⟩ := by + let state := (ambient, (MachineFixedBlockMap.emptyBuffer 4096, + (MachineFixedDivMod.residue q positive 0, (false, MachineCloudSelect.Phase.checking)))) + have run := MachineRegularDummyRow.traceAt q id none + (MachineRegularDummyRow.instruction q id none) (fun _ => rfl) x + (MachineRegularDummyRow.memory x output) (MachineRegularDummyRow.memory_input x output) state none + rw [dummyMemory_update] at run + have placed := MachineCloudPadding.Placement.trace dummyTapes dummyView + dummyView_left dummyView_right labels exit + (coreMemory graph x v i k o m rotor output [] [] [] [] [] []) + (MachineRegularDummyRow.instruction q id none) program code _ _ _ run + simp only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, + dummyFrame] at placed + have hs : MachineRegularDummyRow.steps q x output = + MachineRegularDummyRow.timeBound q x output.length := MachineRegularDummyRow.steps_eq q x output + change (advance (TM2.step program))^[MachineRegularDummyRow.steps q x output] _ = _ at placed + rw [hs] at placed + exact placed + +inductive Label (q : Nat) + | originalPort (l : PortLabel q) + | dummyPort (l : PortLabel q) + | original (l : MachineRegularOriginalClean.Label) + | dummy (l : MachineRegularDummyRow.Label) + deriving DecidableEq, Fintype + +def originalEntry (q : Nat) (positive : 0 < q) : Label q := + .originalPort (⟨0, positive⟩, coreEntry q) + +def dummyEntry (q : Nat) (positive : 0 < q) : Label q := + .dummyPort (⟨0, positive⟩, coreEntry q) + +def instruction (q : Nat) (positive : 0 < q) (labels : Label q → Λ) (exit : Option Λ) : + Label q → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q) + | .originalPort l => portInstruction q positive (fun p => labels (.originalPort p)) + (some (labels (.original (.row (.lookup .seed))))) l + | .dummyPort l => portInstruction q positive (fun p => labels (.dummyPort p)) + (some (labels (.dummy (.affine .seed)))) l + | .original l => originalCoreInstruction q (fun s => labels (.original s)) exit l + | .dummy l => dummyCoreInstruction q (fun s => labels (.dummy s)) exit l + +def oldCloud (t : GraphTables.Table) (padding : Fin t.vertices → Nat) (e : Fin t.darts) : + PaddedCloud t padding t.rows[e].tail := paddedOld t padding t.rows[e].tail ⟨e, rfl⟩ + +def originalRowSteps (q : Nat) (t : GraphTables.Table) (e : Fin t.darts) (outputLength : Nat) : Nat := + MachineRegularOriginalClean.steps q t e + (originalMemory (GraphTables.tableBits t) e.val (List.replicate outputLength false)) + +theorem originalRowSteps_eq (q : Nat) (t : GraphTables.Table) (e : Fin t.darts) + (output : List Bool) : + MachineRegularOriginalClean.steps q t e (originalMemory (GraphTables.tableBits t) e.val output) = + originalRowSteps q t e output.length := by + unfold originalRowSteps MachineRegularOriginalClean.steps + rw [MachineRegularOriginalClean.cleanupSteps_eq q t e _ (originalMemory_input t e output), + MachineRegularOriginalClean.cleanupSteps_eq q t e _ + (originalMemory_input t e (List.replicate output.length false))] + simp only [MachineRegularOriginalRow.steps, MachineRegularOriginalRow.rowSteps, + originalMemory, Matrix.cons_val, List.length_replicate] + +theorem encodeWords_flatMap {A : Type*} (xs : List A) (words : A → List Nat) : + encodeWords (xs.flatMap words) = xs.flatMap (fun x => encodeWords (words x)) := by + induction xs with + | nil => rfl + | cons x xs ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +private theorem encodeWords_pair (a b : Nat) (rest : List Nat) : + encodeWords ([a, b] ++ rest) = encodeWord a ++ (encodeWord b ++ encodeWords rest) := rfl + +theorem vertexBits_split (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) : + PreprocessingRegularWords.vertexBits t padding tables x.val = + (List.ofFn (rowBits t padding tables v x)).flatten ++ + encodeWords (GraphTables.rowWords + (PreprocessingRegularWords.actualRow t padding tables x.val (.inr ()))) := by + unfold PreprocessingRegularWords.vertexBits PreprocessingRegularWords.vertexRows + rw [List.flatMap_append, encodeWords_append] + simp only [List.flatMap_cons, List.flatMap_nil, List.append_nil] + rw [encodeWords_flatMap, List.flatMap_def, List.map_ofFn] + rfl + +def originalSteps (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (e : Fin t.darts) (outputLength : Nat) : Nat := + portSteps t padding tables t.rows[e].tail (oldCloud t padding e) outputLength q + + originalRowSteps q t e (outputLength + + (List.ofFn (rowBits t padding tables t.rows[e].tail (oldCloud t padding e))).flatten.length) + +theorem originalTraceAt (q : Nat) (positive : 0 < q) + (labels : Label q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = instruction q positive labels exit l) + (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (e : Fin t.darts) (output : List Bool) (ambient : σ) : + (advance (TM2.step program))^[originalSteps t padding tables e output.length] + (some ⟨some (labels (originalEntry q positive)), coreInitialState q positive ambient, + coreInputTapes t padding tables t.rows[e].tail (oldCloud t padding e) output⟩) = + some ⟨exit, coreInitialState q positive ambient, + coreInputTapes t padding tables t.rows[e].tail (oldCloud t padding e) + (output ++ PreprocessingRegularWords.originalVertexBits t padding tables e)⟩ := by + let x := oldCloud t padding e + let bits := (List.ofFn (rowBits t padding tables t.rows[e].tail x)).flatten + have ports := portTrace q positive (fun l => labels (.originalPort l)) + (some (labels (.original (.row (.lookup .seed))))) program + (fun l => code (.originalPort l)) t padding tables t.rows[e].tail x output ambient + have inherited := originalCoreTrace q positive (fun l => labels (.original l)) exit program + (fun l => code (.original l)) t e t.rows[e].tail.val + (paddedCloudRank t padding t.rows[e].tail x).val (cloudSize t t.rows[e].tail) + (PreprocessingPaddingOffsets.offset padding t.rows[e].tail.val) t.darts + (encodeWords (ExpanderTableWords.rotationWords (tables t.rows[e].tail))) (output ++ bits) ambient + rw [originalRowSteps_eq] at inherited + change (advance (TM2.step program))^[originalRowSteps q t e (output ++ bits).length] + (some ⟨some (labels (.original (.row (.lookup .seed)))), coreInitialState q positive ambient, + coreInputTapes t padding tables t.rows[e].tail x (output ++ bits)⟩) = + some ⟨exit, coreInitialState q positive ambient, + coreInputTapes t padding tables t.rows[e].tail x + ((output ++ bits) ++ encodeWords (MachineRegularOriginalRow.emittedWords q t e))⟩ at inherited + have total := joinTrace ports inherited + have hbits : PreprocessingRegularWords.originalVertexBits t padding tables e = + bits ++ encodeWords (MachineRegularOriginalRow.emittedWords q t e) := by + have h := vertexBits_split t padding tables t.rows[e].tail x + change PreprocessingRegularWords.originalVertexBits t padding tables e = + bits ++ encodeWords (GraphTables.rowWords + (PreprocessingRegularWords.actualRow t padding tables (.inl e) (.inr ()))) at h + rw [PreprocessingRegularWords.inherited_original_words] at h + exact h + rw [hbits] + simpa only [originalSteps, portEntry, dite_eq_left positive, originalEntry, + List.length_append, List.append_assoc, x, bits] using total + +def dummySteps (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (j : Fin (padding v)) (outputLength : Nat) : Nat := + portSteps t padding tables v (paddedNew t padding v j) outputLength q + + MachineRegularDummyRow.timeBound q (vertexOrder t padding (.inr ⟨v, j⟩)).val + (outputLength + (List.ofFn (rowBits t padding tables v (paddedNew t padding v j))).flatten.length) + +theorem dummyTraceAt (q : Nat) (positive : 0 < q) + (labels : Label q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = instruction q positive labels exit l) + (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (j : Fin (padding v)) (output : List Bool) (ambient : σ) : + (advance (TM2.step program))^[dummySteps t padding tables v j output.length] + (some ⟨some (labels (dummyEntry q positive)), coreInitialState q positive ambient, + coreInputTapes t padding tables v (paddedNew t padding v j) output⟩) = + some ⟨exit, coreInitialState q positive ambient, + coreInputTapes t padding tables v (paddedNew t padding v j) + (output ++ PreprocessingRegularWords.dummyVertexBits t padding tables v j)⟩ := by + let x := paddedNew t padding v j + let bits := (List.ofFn (rowBits t padding tables v x)).flatten + have ports := portTrace q positive (fun l => labels (.dummyPort l)) + (some (labels (.dummy (.affine .seed)))) program + (fun l => code (.dummyPort l)) t padding tables v x output ambient + have inherited := dummyCoreTrace q positive (fun l => labels (.dummy l)) exit program + (fun l => code (.dummy l)) (GraphTables.tableBits t) (vertexOrder t padding x.val).val v.val + (paddedCloudRank t padding v x).val (cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts + (encodeWords (ExpanderTableWords.rotationWords (tables v))) (output ++ bits) ambient + have total := joinTrace ports inherited + have hbits : PreprocessingRegularWords.dummyVertexBits t padding tables v j = + bits ++ MachineRegularDummyRow.emittedBits q (vertexOrder t padding x.val).val := by + have h := vertexBits_split t padding tables v x + change PreprocessingRegularWords.dummyVertexBits t padding tables v j = + bits ++ encodeWords (GraphTables.rowWords + (PreprocessingRegularWords.actualRow t padding tables (.inr ⟨v, j⟩) (.inr ()))) at h + rw [PreprocessingRegularWords.inherited_dummy_words] at h + rw [encodeWords_pair] at h + rw [show (vertexOrder t padding x.val).val = + t.darts + PreprocessingPaddingOffsets.offset padding v.val + j.val from + PreprocessingPaddingOffsets.vertexOrder_dummy_val t padding v j] + simpa only [MachineRegularDummyRow.emittedBits, MachineRegularDummyRow.reverseIndex, + MachineDummyRows.rowBits, MachineDummyRows.trueBits, List.append_assoc] using h + rw [hbits] + simp only [dummySteps, portEntry, dite_eq_left positive, dummyEntry, + List.length_append, List.append_assoc, x, bits] at total ⊢ + convert total using 1 <;> rfl + +def rowSizeBound (q vertices : Nat) : Nat := vertices + vertices * (q + 1) + 8192 + +theorem rowBits_length_le (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) : + (rowBits t padding tables v x p).length ≤ rowSizeBound q (vertexCount t padding) := + GraphTables.rowBits_length_le _ + +theorem portBits_length_le {q : Nat} (bits : Fin q → List Bool) (bound : Nat) + (hbits : ∀ p, (bits p).length ≤ bound) (k : Nat) : + (portBits bits k).length ≤ k * bound := by + induction k with + | zero => simp only [portBits, List.length_nil, Nat.zero_mul, le_refl] + | succ k ih => + rw [portBits, List.length_append] + split_ifs with h + · have hp := hbits ⟨k, h⟩ + rw [Nat.succ_mul] + exact Nat.add_le_add ih hp + · simp only [List.length_nil, Nat.add_zero] + exact ih.trans (Nat.mul_le_mul_right bound (by omega)) + +theorem allRowBits_length_le (t : GraphTables.Table) (padding : Fin t.vertices → Nat) {q : Nat} + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) : + (List.ofFn (rowBits t padding tables v x)).flatten.length ≤ + q * rowSizeBound q (vertexCount t padding) := by + rw [← portBits_all] + exact portBits_length_le _ _ (rowBits_length_le t padding tables v x) q + +def portTimeBound (q graphLength rotorLength x v i k o m outputLength vertices : Nat) : Nat := + q * coreTimeBound q graphLength rotorLength x v i k o m + (outputLength + q * rowSizeBound q vertices) + +theorem portSteps_le (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (x : PaddedCloud t padding v) (outputLength : Nat) (n : Nat) (hn : n ≤ q) : + portSteps t padding tables v x outputLength n ≤ + n * coreTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + (vertexOrder t padding x.val).val v.val (paddedCloudRank t padding v x).val + (cloudSize t v) (PreprocessingPaddingOffsets.offset padding v.val) t.darts + (outputLength + q * rowSizeBound q (vertexCount t padding)) := by + induction n with + | zero => simp only [portSteps, Nat.zero_mul, le_refl] + | succ n ih => + have h : n < q := by omega + have first := ih (by omega) + have second := coreSteps_le q positive t padding tables v x ⟨n, h⟩ + (outputLength + (portBits (rowBits t padding tables v x) n).length) + have hlen := portBits_length_le (rowBits t padding tables v x) + (rowSizeBound q (vertexCount t padding)) (rowBits_length_le t padding tables v x) n + have hmul := Nat.mul_le_mul_right (rowSizeBound q (vertexCount t padding)) (Nat.le_of_lt h) + have hcost : coreSteps t padding tables v x ⟨n, h⟩ + (outputLength + (portBits (rowBits t padding tables v x) n).length) ≤ + coreTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + (vertexOrder t padding x.val).val v.val (paddedCloudRank t padding v x).val + (cloudSize t v) (PreprocessingPaddingOffsets.offset padding v.val) t.darts + (outputLength + q * rowSizeBound q (vertexCount t padding)) := by + unfold coreTimeBound at second ⊢ + omega + rw [portSteps, dite_eq_left h, Nat.succ_mul] + exact Nat.add_le_add first hcost + +def originalTimeBound (q graphLength rotorLength x v i k o m outputLength vertices : Nat) : Nat := + portTimeBound q graphLength rotorLength x v i k o m outputLength vertices + + MachineRegularOriginalClean.timeBound q graphLength + (outputLength + q * rowSizeBound q vertices) + +def dummyTimeBound (q graphLength rotorLength x v i k o m outputLength vertices : Nat) : Nat := + portTimeBound q graphLength rotorLength x v i k o m outputLength vertices + + MachineRegularDummyRow.timeBound q x (outputLength + q * rowSizeBound q vertices) + +theorem originalSteps_le (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (e : Fin t.darts) (outputLength : Nat) : + originalSteps t padding tables e outputLength ≤ + originalTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables t.rows[e].tail))).length + e.val t.rows[e].tail.val (paddedCloudRank t padding t.rows[e].tail (oldCloud t padding e)).val + (cloudSize t t.rows[e].tail) (PreprocessingPaddingOffsets.offset padding t.rows[e].tail.val) + t.darts outputLength (vertexCount t padding) := by + let v := t.rows[e].tail + let x := oldCloud t padding e + let extra := (List.ofFn (rowBits t padding tables v x)).flatten.length + have hp := portSteps_le q positive t padding tables v x outputLength q le_rfl + have hi := MachineRegularOriginalClean.steps_le q t e + (originalMemory (GraphTables.tableBits t) e.val (List.replicate (outputLength + extra) false)) + (originalMemory_input t e (List.replicate (outputLength + extra) false)) + have hl := allRowBits_length_le t padding tables v x + change originalRowSteps q t e (outputLength + extra) ≤ + MachineRegularOriginalClean.timeBound q (GraphTables.tableBits t).length + (List.replicate (outputLength + extra) false).length at hi + rw [List.length_replicate] at hi + change portSteps t padding tables v x outputLength q + + originalRowSteps q t e (outputLength + extra) ≤ _ + unfold originalTimeBound portTimeBound MachineRegularOriginalClean.timeBound at * + have hx : (vertexOrder t padding x.val).val = e.val := rfl + rw [hx] at hp + dsimp only [v, x, extra] at * + omega + +theorem dummySteps_le (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (j : Fin (padding v)) (outputLength : Nat) : + dummySteps t padding tables v j outputLength ≤ + dummyTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + (vertexOrder t padding (.inr ⟨v, j⟩)).val v.val + (paddedCloudRank t padding v (paddedNew t padding v j)).val + (cloudSize t v) (PreprocessingPaddingOffsets.offset padding v.val) + t.darts outputLength (vertexCount t padding) := by + have hp := portSteps_le q positive t padding tables v (paddedNew t padding v j) outputLength q le_rfl + have hl := allRowBits_length_le t padding tables v (paddedNew t padding v j) + unfold dummySteps dummyTimeBound portTimeBound MachineRegularDummyRow.timeBound + have hx : (paddedNew t padding v j).val = Sum.inr ⟨v, j⟩ := rfl + rw [hx] at hp + omega + +def originalMachine (q : Nat) (positive : 0 < q) : FinTM2 where + K := CoreTape + k₀ := 0 + k₁ := 8 + Γ _ := Bool + Λ := Label q + main := originalEntry q positive + σ := CoreState Unit q + initialState := coreInitialState q positive () + m := instruction q positive id none + +def dummyMachine (q : Nat) (positive : 0 < q) : FinTM2 where + K := CoreTape + k₀ := 0 + k₁ := 8 + Γ _ := Bool + Λ := Label q + main := dummyEntry q positive + σ := CoreState Unit q + initialState := coreInitialState q positive () + m := instruction q positive id none + +def originalMachineInTime (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (e : Fin t.darts) (output : List Bool) : + StateTransition.EvalsToInTime (originalMachine q positive).step + ⟨some (originalEntry q positive), coreInitialState q positive (), + coreInputTapes t padding tables t.rows[e].tail (oldCloud t padding e) output⟩ + (some ⟨none, coreInitialState q positive (), + coreInputTapes t padding tables t.rows[e].tail (oldCloud t padding e) + (output ++ PreprocessingRegularWords.originalVertexBits t padding tables e)⟩) + (originalTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables t.rows[e].tail))).length + e.val t.rows[e].tail.val (paddedCloudRank t padding t.rows[e].tail (oldCloud t padding e)).val + (cloudSize t t.rows[e].tail) (PreprocessingPaddingOffsets.offset padding t.rows[e].tail.val) + t.darts output.length (vertexCount t padding)) where + steps := originalSteps t padding tables e output.length + evals_in_steps := originalTraceAt q positive id none (instruction q positive id none) + (fun _ => rfl) t padding tables e output () + steps_le_m := originalSteps_le q positive t padding tables e output.length + +def dummyMachineInTime (q : Nat) (positive : 0 < q) (t : GraphTables.Table) + (padding : Fin t.vertices → Nat) + (tables : ∀ v, ExpanderTables.Table (cloudSize t v + padding v) q) + (v : Fin t.vertices) (j : Fin (padding v)) (output : List Bool) : + StateTransition.EvalsToInTime (dummyMachine q positive).step + ⟨some (dummyEntry q positive), coreInitialState q positive (), + coreInputTapes t padding tables v (paddedNew t padding v j) output⟩ + (some ⟨none, coreInitialState q positive (), + coreInputTapes t padding tables v (paddedNew t padding v j) + (output ++ PreprocessingRegularWords.dummyVertexBits t padding tables v j)⟩) + (dummyTimeBound q (GraphTables.tableBits t).length + (encodeWords (ExpanderTableWords.rotationWords (tables v))).length + (vertexOrder t padding (.inr ⟨v, j⟩)).val v.val + (paddedCloudRank t padding v (paddedNew t padding v j)).val + (cloudSize t v) (PreprocessingPaddingOffsets.offset padding v.val) + t.darts output.length (vertexCount t padding)) where + steps := dummySteps t padding tables v j output.length + evals_in_steps := dummyTraceAt q positive id none (instruction q positive id none) + (fun _ => rfl) t padding tables v j output () + steps_le_m := dummySteps_le q positive t padding tables v j output.length + +end IndependentSetsGames.Foundations.Complexity.MachineRegularVertexBlock + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRepeat.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRepeat.lean new file mode 100644 index 0000000000000000000000000000000000000000..24442ac60e23bd9255a7aafd56521d070ce1c58b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineRepeat.lean @@ -0,0 +1,471 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.PatternInvariant +import OAI.Combinatorics.IndependentSets.Encoding.Target +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRepeat +open Turing + +inductive ExtraTape | counter | temporary | output + deriving DecidableEq + +instance : Fintype ExtraTape where + elems := {.counter, .temporary, .output} + complete tape := by cases tape <;> simp + +inductive Phase | parse | guard | bodyToTemp | tempToBody | finalToTemp | tempToOutput + deriving DecidableEq + +instance : Fintype Phase where + elems := {.parse, .guard, .bodyToTemp, .tempToBody, .finalToTemp, .tempToOutput} + complete phase := by cases phase <;> simp + +abbrev Tape (M : FinTM2) := M.K ⊕ ExtraTape +abbrev Symbols (M : FinTM2) := MachineEmbedding.Alphabet M.Γ (fun _ : ExtraTape => M.Γ M.k₀) +abbrev Label (M : FinTM2) := M.Λ ⊕ Phase +abbrev State (M : FinTM2) := M.σ × Option (M.Γ M.k₀) + +def extraTapes (M : FinTM2) (counter temporary output : List (M.Γ M.k₀)) : + ExtraTape → List (M.Γ M.k₀) + | .counter => counter + | .temporary => temporary + | .output => output + +def auxProgram (M : FinTM2) (input : M.Γ M.k₀ ≃ Bool) (output : M.Γ M.k₁ ≃ Bool) : + Phase → TM2.Stmt (Symbols M) (Label M) (State M) + | .parse => .pop (.inl M.k₀) (fun s v => (s.1,v)) + (.branch (fun s => input (s.2.getD (input.symm false))) + (.push (.inr .counter) (fun _ => input.symm true) + (.load (fun s => (s.1,none)) (.goto (fun _ => .inr .parse)))) + (.load (fun s => (s.1,none)) (.goto (fun _ => .inr .guard)))) + | .guard => .pop (.inr .counter) (fun s v => (s.1,v)) + (.branch (fun s => s.2.isSome) + (.load (fun s => (s.1,none)) (.goto (fun _ => .inl M.main))) + (.load (fun s => (s.1,none)) (.goto (fun _ => .inr .finalToTemp)))) + | .bodyToTemp => Reduction.MachineTransfer.loopAt (Γ := Symbols M) (Λ := Label M) (.inl M.k₁) (.inr .temporary) + (fun b => input.symm (output b)) (input.symm false) + (.inr .bodyToTemp) (some (.inr .tempToBody)) + | .tempToBody => Reduction.MachineTransfer.loopAt (Γ := Symbols M) (Λ := Label M) (.inr .temporary) (.inl M.k₀) + id (input.symm false) (.inr .tempToBody) (some (.inr .guard)) + | .finalToTemp => Reduction.MachineTransfer.loopAt (Γ := Symbols M) (Λ := Label M) (.inl M.k₀) (.inr .temporary) + id (input.symm false) (.inr .finalToTemp) (some (.inr .tempToOutput)) + | .tempToOutput => Reduction.MachineTransfer.loopAt (Γ := Symbols M) (Λ := Label M) (.inr .temporary) (.inr .output) + id (input.symm false) (.inr .tempToOutput) none + +def program (M : FinTM2) (input : M.Γ M.k₀ ≃ Bool) (output : M.Γ M.k₁ ≃ Bool) : + Label M → TM2.Stmt (Symbols M) (Label M) (State M) := + MachineEmbedding.program (some (.inr .bodyToTemp)) M.m (auxProgram M input output) + +def machine (M : FinTM2) (input : M.Γ M.k₀ ≃ Bool) (output : M.Γ M.k₁ ≃ Bool) : FinTM2 where + K := Tape M + kFin := by letI := M.kFin; exact inferInstanceAs (Fintype (Tape M)) + k₀ := .inl M.k₀ + k₁ := .inr .output + Γ := Symbols M + Λ := Label M + ΛFin := by letI := M.ΛFin; exact inferInstanceAs (Fintype (Label M)) + main := .inr .parse + σ := State M + σFin := by + letI := M.σFin + letI := M.Γk₀Fin + exact inferInstanceAs (Fintype (State M)) + initialState := (M.initialState,none) + Γk₀Fin := M.Γk₀Fin + m := program M input output + +def inputTapes (M : FinTM2) (word counter : List (M.Γ M.k₀)) : ∀k, List (Symbols M k) := + MachineEmbedding.tapes (initList M word).stk (extraTapes M counter [] []) + +@[simp] theorem inputTapes_input (M : FinTM2) (word counter : List (M.Γ M.k₀)) : + inputTapes M word counter (.inl M.k₀) = word := by + simp [inputTapes, initList] + +@[simp] theorem inputTapes_counter (M : FinTM2) (word counter : List (M.Γ M.k₀)) : + inputTapes M word counter (.inr .counter) = counter := rfl + +def inputConfig (M : FinTM2) (phase : Phase) (word counter : List (M.Γ M.k₀)) : + TM2.Cfg (Symbols M) (Label M) (State M) := + ⟨some (.inr phase),(M.initialState,none),inputTapes M word counter⟩ + +def embedded (M : FinTM2) (counter : List (M.Γ M.k₀)) (c : M.Cfg) : + TM2.Cfg (Symbols M) (Label M) (State M) := + MachineEmbedding.configuration (some (.inr .bodyToTemp)) (none : Option (M.Γ M.k₀)) + (extraTapes M counter [] []) c + +def temporaryTapes (M : FinTM2) (word counter : List (M.Γ M.k₀)) : ∀k, List (Symbols M k) := + MachineEmbedding.tapes (fun _ => []) (extraTapes M counter word []) + +def temporaryConfig (M : FinTM2) (phase : Phase) (word counter : List (M.Γ M.k₀)) : + TM2.Cfg (Symbols M) (Label M) (State M) := + ⟨some (.inr phase),(M.initialState,none),temporaryTapes M word counter⟩ + +private theorem inputTapes_update_input (M : FinTM2) + (word counter replacement : List (M.Γ M.k₀)) : + Function.update (inputTapes M word counter) (.inl M.k₀) replacement = + inputTapes M replacement counter := by + funext k + cases k with + | inl k => + by_cases h : k = M.k₀ + · subst k; simp [inputTapes, initList] + · simp [inputTapes, initList, h] + | inr k => simp [inputTapes] + +private theorem inputTapes_update_counter (M : FinTM2) + (word counter replacement : List (M.Γ M.k₀)) : + Function.update (inputTapes M word counter) (.inr .counter) replacement = + inputTapes M word replacement := by + funext k + cases k with + | inl k => simp [inputTapes] + | inr k => cases k <;> simp [inputTapes, extraTapes] + +def oneStep {α : Type*} (step : α → Option α) (a b : α) + (h : step a = some b) : StateTransition.EvalsToInTime step a (some b) 1 where + steps := 1 + evals_in_steps := by change step a = some b; exact h + steps_le_m := le_refl _ + +variable (M : FinTM2) (input : M.Γ M.k₀ ≃ Bool) (output : M.Γ M.k₁ ≃ Bool) + +theorem parseStep_true (word counter : List (M.Γ M.k₀)) : + (machine M input output).step + (inputConfig M .parse (input.symm true :: word) counter) = + some (inputConfig M .parse word (input.symm true :: counter)) := by + change some (TM2.stepAux (auxProgram M input output .parse) + (M.initialState,none) (inputTapes M (input.symm true :: word) counter)) = _ + simp [auxProgram, TM2.stepAux, inputTapes_update_input, inputTapes_update_counter, + inputConfig] + +theorem parseStep_false (word counter : List (M.Γ M.k₀)) : + (machine M input output).step + (inputConfig M .parse (input.symm false :: word) counter) = + some (inputConfig M .guard word counter) := by + change some (TM2.stepAux (auxProgram M input output .parse) + (M.initialState,none) (inputTapes M (input.symm false :: word) counter)) = _ + simp [auxProgram, TM2.stepAux, inputTapes_update_input, inputTapes_update_counter, + inputConfig] + +theorem parseTrace (count : Nat) (word counter : List (M.Γ M.k₀)) : + (MachineComposition.advance (machine M input output).step)^[count+1] + (some (inputConfig M .parse ((encodeWord count).map input.symm ++ word) counter)) = + some (inputConfig M .guard word (List.replicate count (input.symm true) ++ counter)) := by + induction count generalizing counter with + | zero => + simp only [encodeWord, List.replicate_zero, List.nil_append, List.map_singleton, + List.singleton_append, Nat.zero_add, Function.iterate_one] + exact parseStep_false M input output word counter + | succ count ih => + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (machine M input output).step)^[count+1] + ((machine M input output).step + (inputConfig M .parse ((encodeWord (count+1)).map input.symm ++ word) counter)) = _ + simp only [encodeWord, List.replicate_succ, List.cons_append, List.map_cons, + List.map_append, List.map_replicate, List.map_nil, List.append_assoc, List.nil_append] + rw [parseStep_true] + have h := ih (input.symm true :: counter) + have hc : List.replicate count (input.symm true) ++ input.symm true :: counter = + input.symm true :: (List.replicate count (input.symm true) ++ counter) := by + rw [← List.singleton_append, ← List.append_assoc, + ← List.replicate_succ', List.replicate_succ, List.cons_append] + rw [hc] at h + simp only [encodeWord, List.map_append, List.map_replicate, List.map_singleton, + List.singleton_append, List.append_assoc] at h + exact h + +theorem guardStep_some (word counter : List (M.Γ M.k₀)) (symbol : M.Γ M.k₀) : + (machine M input output).step (inputConfig M .guard word (symbol :: counter)) = + some (embedded M counter (initList M word)) := by + change some (TM2.stepAux (auxProgram M input output .guard) + (M.initialState,none) (inputTapes M word (symbol :: counter))) = _ + simp [auxProgram, TM2.stepAux, inputTapes_update_counter, + embedded, MachineEmbedding.configuration] + exact ⟨rfl,rfl,rfl⟩ + +theorem guardStep_none (word : List (M.Γ M.k₀)) : + (machine M input output).step (inputConfig M .guard word []) = + some (inputConfig M .finalToTemp word []) := by + change some (TM2.stepAux (auxProgram M input output .guard) + (M.initialState,none) (inputTapes M word [])) = _ + simp [auxProgram, TM2.stepAux, inputTapes_update_counter, inputConfig] + +def bodyExecution (counter : List (M.Γ M.k₀)) + (word : List (M.Γ M.k₀)) (result : List (M.Γ M.k₁)) (budget : Nat) + (run : TM2OutputsInTime M word (some result) budget) : + StateTransition.EvalsToInTime (machine M input output).step + (embedded M counter (initList M word)) + (some (embedded M counter (haltList M result))) budget := + MachineComposition.embeddedExecution (some (.inr .bodyToTemp : Label M)) + (none : Option (M.Γ M.k₀)) (extraTapes M counter [] []) M.m + (auxProgram M input output) run + +private theorem bodyToTemp_tapes (result : List (M.Γ M.k₁)) (counter : List (M.Γ M.k₀)) : + Reduction.MachineTransfer.tapesAt (.inl M.k₁) (.inr .temporary) + (embedded M counter (haltList M result)).stk [] + (result.reverse.map (fun b => input.symm (output b))) = + temporaryTapes M (result.reverse.map (fun b => input.symm (output b))) counter := by + funext k + cases k with + | inl k => + by_cases h : k = M.k₁ + · subst k; simp [Reduction.MachineTransfer.tapesAt, temporaryTapes] + · simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, embedded, + MachineEmbedding.configuration, haltList, h] + | inr k => + cases k <;> simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, embedded, + MachineEmbedding.configuration, extraTapes] + +private theorem tempToBody_tapes (word counter : List (M.Γ M.k₀)) : + Reduction.MachineTransfer.tapesAt (Γ := Symbols M) (.inr .temporary) (.inl M.k₀) + (temporaryTapes M word counter) [] word.reverse = inputTapes M word.reverse counter := by + funext k + cases k with + | inl k => + by_cases h : k = M.k₀ + · subst k; simp [Reduction.MachineTransfer.tapesAt, inputTapes, initList] + · simp [Reduction.MachineTransfer.tapesAt, inputTapes, temporaryTapes, initList, h] + | inr k => + cases k <;> simp [Reduction.MachineTransfer.tapesAt, inputTapes, temporaryTapes, extraTapes] + +private theorem finalToTemp_tapes (word : List (M.Γ M.k₀)) : + Reduction.MachineTransfer.tapesAt (Γ := Symbols M) (.inl M.k₀) (.inr .temporary) + (inputTapes M word []) [] word.reverse = temporaryTapes M word.reverse [] := by + funext k + cases k with + | inl k => + by_cases h : k = M.k₀ + · subst k; simp [Reduction.MachineTransfer.tapesAt, temporaryTapes] + · simp [Reduction.MachineTransfer.tapesAt, inputTapes, temporaryTapes, initList, h] + | inr k => + cases k <;> simp [Reduction.MachineTransfer.tapesAt, inputTapes, temporaryTapes, extraTapes] + +private theorem tempToOutput_tapes (word : List (M.Γ M.k₀)) : + Reduction.MachineTransfer.tapesAt (Γ := Symbols M) (.inr .temporary) (.inr .output) + (temporaryTapes M word []) [] word.reverse = + (haltList (machine M input output) word.reverse).stk := by + funext k + cases k with + | inl k => simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, haltList, machine] + | inr k => + cases k <;> simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, haltList, + machine, extraTapes] + rfl + +def bodyToTemp (result : List (M.Γ M.k₁)) (counter : List (M.Γ M.k₀)) : + StateTransition.EvalsToInTime (machine M input output).step + (embedded M counter (haltList M result)) + (some (temporaryConfig M .tempToBody + (result.reverse.map (fun b => input.symm (output b))) counter)) (result.length+1) := by + have run := Reduction.MachineTransfer.transferAtInTime + (Γ := Symbols M) (.inl M.k₁) (.inr .temporary) (by intro h; cases h) + (fun b => input.symm (output b)) (input.symm false) + (.inr .bodyToTemp) (some (.inr .tempToBody)) (program M input output) rfl + (embedded M counter (haltList M result)).stk M.initialState none + have hs : (embedded M counter (haltList M result)).stk (.inl M.k₁) = result := by + simp [embedded, MachineEmbedding.configuration, haltList] + have hd : (embedded M counter (haltList M result)).stk (.inr .temporary) = [] := rfl + rw [hs,hd,List.append_nil,bodyToTemp_tapes] at run + exact run + +def tempToBody (word counter : List (M.Γ M.k₀)) : + StateTransition.EvalsToInTime (machine M input output).step + (temporaryConfig M .tempToBody word counter) + (some (inputConfig M .guard word.reverse counter)) (word.length+1) := by + have run := Reduction.MachineTransfer.transferAtInTime + (Γ := Symbols M) (.inr .temporary) (.inl M.k₀) (by intro h; cases h) + id (input.symm false) (.inr .tempToBody) (some (.inr .guard)) + (program M input output) rfl (temporaryTapes M word counter) M.initialState none + simp only [temporaryTapes, MachineEmbedding.tapes, extraTapes, + List.map_id, List.append_nil] at run + rw [show Reduction.MachineTransfer.tapesAt (Γ := Symbols M) (.inr .temporary) (.inl M.k₀) + (MachineEmbedding.tapes (fun _ => []) (extraTapes M counter word [])) [] word.reverse = + inputTapes M word.reverse counter from tempToBody_tapes M word counter] at run + exact run + +def finalToTemp (word : List (M.Γ M.k₀)) : + StateTransition.EvalsToInTime (machine M input output).step + (inputConfig M .finalToTemp word []) + (some (temporaryConfig M .tempToOutput word.reverse [])) (word.length+1) := by + have run := Reduction.MachineTransfer.transferAtInTime + (Γ := Symbols M) (.inl M.k₀) (.inr .temporary) (by intro h; cases h) + id (input.symm false) (.inr .finalToTemp) (some (.inr .tempToOutput)) + (program M input output) rfl (inputTapes M word []) M.initialState none + have hd : inputTapes M word [] (.inr .temporary) = [] := rfl + rw [inputTapes_input,hd,List.map_id,List.append_nil,finalToTemp_tapes] at run + exact run + +def tempToOutput (word : List (M.Γ M.k₀)) : + StateTransition.EvalsToInTime (machine M input output).step + (temporaryConfig M .tempToOutput word []) + (some (haltList (machine M input output) word.reverse)) (word.length+1) := by + have run := Reduction.MachineTransfer.transferAtInTime + (Γ := Symbols M) (.inr .temporary) (.inr .output) (by intro h; cases h) + id (input.symm false) (.inr .tempToOutput) none + (program M input output) rfl (temporaryTapes M word []) M.initialState none + have hs : temporaryTapes M word [] (.inr .temporary) = word := rfl + have hd : temporaryTapes M word [] (.inr .output) = [] := rfl + rw [hs,hd,List.map_id,List.append_nil,tempToOutput_tapes] at run + exact run + +def bodyReturn (result : List (M.Γ M.k₁)) (counter : List (M.Γ M.k₀)) : + StateTransition.EvalsToInTime (machine M input output).step + (embedded M counter (haltList M result)) + (some (inputConfig M .guard (result.map (fun b => input.symm (output b))) counter)) + (2*(result.length+1)) := by + have first := bodyToTemp M input output result counter + have second := tempToBody M input output (result.reverse.map (fun b => input.symm (output b))) counter + simp only [List.map_reverse,List.reverse_reverse,List.length_reverse,List.length_map] at first second + have full := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first second + exact { toEvalsTo := full.toEvalsTo, steps_le_m := by have h := full.steps_le_m; omega } + +def finish (word : List (M.Γ M.k₀)) : + StateTransition.EvalsToInTime (machine M input output).step + (inputConfig M .guard word []) (some (haltList (machine M input output) word)) + (2*word.length+3) := by + have guard := oneStep _ _ _ (guardStep_none M input output word) + have first := finalToTemp M input output word + have second := tempToOutput M input output word.reverse + simp only [List.reverse_reverse,List.length_reverse] at second + have gfirst := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ guard first + have full := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ gfirst second + exact { toEvalsTo := full.toEvalsTo, steps_le_m := by have h := full.steps_le_m; omega } + +def loopBudget : Nat → (Nat → List Bool) → (Nat → Nat) → Nat + | 0, words, _ => 2*(words 0).length+3 + | count+1, words, budgets => budgets 0 + 2*(words 1).length+3 + + loopBudget count (fun i => words (i+1)) (fun i => budgets (i+1)) + +def loopExecution (count : Nat) (words : Nat → List Bool) (budgets : Nat → Nat) + (runs : ∀ i, i < count → TM2OutputsInTime M ((words i).map input.symm) + (some ((words (i+1)).map output.symm)) (budgets i)) : + StateTransition.EvalsToInTime (machine M input output).step + (inputConfig M .guard ((words 0).map input.symm) + (List.replicate count (input.symm true))) + (some (haltList (machine M input output) ((words count).map input.symm))) + (loopBudget count words budgets) := by + induction count generalizing words budgets with + | zero => + simp only [loopBudget, List.replicate_zero] + have finished := finish M input output ((words 0).map input.symm) + simp only [List.length_map] at finished + exact finished + | succ count ih => + rw [List.replicate_succ] + have guard := oneStep _ _ _ (guardStep_some M input output ((words 0).map input.symm) + (List.replicate count (input.symm true)) (input.symm true)) + have body := bodyExecution M input output (List.replicate count (input.symm true)) + ((words 0).map input.symm) ((words 1).map output.symm) (budgets 0) + (runs 0 (Nat.zero_lt_succ count)) + have returned := bodyReturn M input output ((words 1).map output.symm) + (List.replicate count (input.symm true)) + have handoff : ((words 1).map output.symm).map (fun b => input.symm (output b)) = + (words 1).map input.symm := by + simp only [List.map_map,Function.comp_def,Equiv.apply_symm_apply] + rw [handoff,List.length_map] at returned + have tail := ih (fun i => words (i+1)) (fun i => budgets (i+1)) + (fun i hi => runs (i+1) (Nat.succ_lt_succ hi)) + have first := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ guard body + have second := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first returned + have full := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ second tail + exact { + toEvalsTo := full.toEvalsTo + steps_le_m := by + have h := full.steps_le_m + simp only [loopBudget] + omega + } + +private theorem inputConfig_init (word : List (M.Γ M.k₀)) : + inputConfig M .parse word [] = initList (machine M input output) word := by + unfold inputConfig initList + congr 1 + funext k + cases k with + | inl k => + by_cases h : k = M.k₀ + · subst k; simp [inputTapes,initList,machine]; rfl + · simp [inputTapes,initList,machine,h] + | inr k => cases k <;> simp [inputTapes,initList,machine,extraTapes] + +def executeSequence (count : Nat) (words : Nat → List Bool) (budgets : Nat → Nat) + (runs : ∀ i, i < count → TM2OutputsInTime M ((words i).map input.symm) + (some ((words (i+1)).map output.symm)) (budgets i)) : + TM2OutputsInTime (machine M input output) + ((encodeWord count ++ words 0).map input.symm) + (some ((words count).map input.symm)) + (count+1 + loopBudget count words budgets) := by + let parsed : StateTransition.EvalsToInTime (machine M input output).step + (inputConfig M .parse ((encodeWord count).map input.symm ++ (words 0).map input.symm) []) + (some (inputConfig M .guard ((words 0).map input.symm) + (List.replicate count (input.symm true)))) (count+1) := { + steps := count+1 + evals_in_steps := by + change (MachineComposition.advance (machine M input output).step)^[count+1] + (some (inputConfig M .parse ((encodeWord count).map input.symm ++ (words 0).map input.symm) [])) = _ + have parsedTrace := parseTrace M input output count + ((words 0).map input.symm) [] + simp only [List.append_nil] at parsedTrace + exact parsedTrace + steps_le_m := le_refl _ + } + have body := loopExecution M input output count words budgets runs + have full := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ parsed body + rw [inputConfig_init M input output] at full + simp only [TM2OutputsInTime, Option.map_some] + erw [List.map_append] + rw [Nat.add_comm (loopBudget count words budgets)] at full + exact full + +omit M input output in + +theorem loopBudget_eq_sum (count : Nat) (words : Nat → List Bool) (budgets : Nat → Nat) : + loopBudget count words budgets = + (∑ i ∈ Finset.range count, (budgets i + 2*(words (i+1)).length+3)) + + 2*(words count).length+3 := by + induction count generalizing words budgets with + | zero => simp [loopBudget] + | succ count ih => + rw [loopBudget, ih, Finset.sum_range_succ'] + simp only [Nat.zero_add] + omega + +def executeSequenceSum (count : Nat) (words : Nat → List Bool) (budgets : Nat → Nat) + (runs : ∀ i, i < count → TM2OutputsInTime M ((words i).map input.symm) + (some ((words (i+1)).map output.symm)) (budgets i)) : + TM2OutputsInTime (machine M input output) + ((encodeWord count ++ words 0).map input.symm) + (some ((words count).map input.symm)) + (count+1 + ((∑ i ∈ Finset.range count, (budgets i+2*(words (i+1)).length+3)) + + 2*(words count).length+3)) := by + rw [← loopBudget_eq_sum] + exact executeSequence M input output count words budgets runs + +omit M input output in + +theorem loopBudget_le (count : Nat) (words : Nat → List Bool) (budgets : Nat → Nat) + (bodyBound lengthBound : Nat) + (hb : ∀i, i Bool) Unit (Option Bool) := + .pop false (fun _ head => head) + (.branch Option.isSome + (.push true (fun state => state.getD false) (.goto fun _ => ())) + .halt) + +def machine : FinTM2 where + K := Bool + k₀ := false + k₁ := true + Γ _ := Bool + Λ := Unit + main := () + σ := Option Bool + initialState := none + m _ := loop + +def tapeStacks (input output : List Bool) : Bool → List Bool := + fun side => if side then output else input + +def running (input output : List Bool) (state : Option Bool) : machine.Cfg := + ⟨some (), state, tapeStacks input output⟩ + +def halted (output : List Bool) : machine.Cfg := + ⟨none, none, tapeStacks [] output⟩ + +theorem update_input (input output replacement : List Bool) : + Function.update (tapeStacks input output) false replacement = tapeStacks replacement output := by + funext side + cases side <;> simp [tapeStacks] + +theorem update_output (input output replacement : List Bool) : + Function.update (tapeStacks input output) true replacement = tapeStacks input replacement := by + funext side + cases side <;> simp [tapeStacks] + +theorem step_empty (output : List Bool) (state : Option Bool) : + machine.step (running [] output state) = some (halted output) := by + change some (TM2.stepAux loop state (tapeStacks [] output)) = some (halted output) + simp [loop, TM2.stepAux, tapeStacks, halted, Function.update] + rw [update_input] + rfl + +theorem step_cons (head : Bool) (input output : List Bool) (state : Option Bool) : + machine.step (running (head :: input) output state) = + some (running input (head :: output) (some head)) := by + change some (TM2.stepAux loop state (tapeStacks (head :: input) output)) = _ + simp [loop, TM2.stepAux, tapeStacks, running, Function.update] + rw [update_input, update_output] + rfl + +def next (configuration : Option machine.Cfg) : Option machine.Cfg := + configuration.bind machine.step + +theorem reverse_steps (input output : List Bool) (state : Option Bool) : + next^[input.length + 1] (some (running input output state)) = + some (halted (input.reverse ++ output)) := by + induction input generalizing output state with + | nil => + simpa only [List.length_nil, Nat.zero_add, Function.iterate_one, next, + Option.bind_some, List.reverse_nil, List.nil_append] using step_empty output state + | cons head input ih => + rw [List.length_cons, Function.iterate_succ_apply] + change next^[input.length + 1] + (machine.step (running (head :: input) output state)) = _ + rw [step_cons, ih] + simp only [List.reverse_cons, List.append_assoc, List.singleton_append] + +theorem initList_eq (input : List Bool) : + initList machine input = running input [] none := by + unfold initList running + congr 1 + funext side + cases side <;> rfl + +theorem haltList_eq (output : List Bool) : haltList machine output = halted output := by + unfold haltList halted + congr 1 + +theorem reverse_init_steps (input : List Bool) : + next^[input.length + 1] (some (initList machine input)) = + some (haltList machine input.reverse) := by + rw [initList_eq, haltList_eq] + simpa only [List.append_nil] using reverse_steps input [] none + +def outputsInTime (input : List Bool) : + TM2OutputsInTime machine input (some input.reverse) (input.length + 1) where + steps := input.length + 1 + evals_in_steps := reverse_init_steps input + steps_le_m := Nat.le_refl _ + +@[simp] theorem outputsInTime_steps (input : List Bool) : + (outputsInTime input).steps = input.length + 1 := rfl + +noncomputable def computableInPolyTime : + TM2ComputableInPolyTime (id : List Bool → List Bool) id List.reverse where + tm := machine + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := Polynomial.X + 1 + outputsFun input := by + change TM2OutputsInTime machine (input.map id) (some (input.reverse.map id)) + ((Polynomial.X + 1 : Polynomial Nat).eval input.length) + have hi := @List.map_id (machine.Γ machine.k₀) input + have ho := @List.map_id (machine.Γ machine.k₁) input.reverse + rw [hi, ho] + simpa only [Polynomial.eval_add, Polynomial.eval_X, Polynomial.eval_one] + using outputsInTime input + +end IndependentSetsGames.Reduction.MachineReverse +namespace IndependentSetsGames.Foundations.Complexity.MachineStackSwap + +open Turing.TM2 + +variable {A B C Λ σ : Type} + {ΓA : A → Type} {ΓB : B → Type} {ΓC : C → Type} + +abbrev Alphabet (ΓA : A → Type) (ΓB : B → Type) (ΓC : C → Type) := + MachineEmbedding.Alphabet ΓA (MachineEmbedding.Alphabet ΓB ΓC) + +def tapes (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) : + ∀ j, List (Alphabet ΓB ΓA ΓC j) + | .inl b => source (.inr (.inl b)) + | .inr (.inl a) => source (.inl a) + | .inr (.inr c) => source (.inr (.inr c)) + +@[simp] theorem tapes_first (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) (a : A) : + tapes source (.inr (.inl a)) = source (.inl a) := rfl +@[simp] theorem tapes_second (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) (b : B) : + tapes source (.inl b) = source (.inr (.inl b)) := rfl +@[simp] theorem tapes_third (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) (c : C) : + tapes source (.inr (.inr c)) = source (.inr (.inr c)) := rfl + +theorem tapes_involutive (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) : + tapes (tapes source) = source := by + funext k + rcases k with a | b | c <;> rfl + +def configuration (c : Cfg (Alphabet ΓA ΓB ΓC) Λ σ) : + Cfg (Alphabet ΓB ΓA ΓC) Λ σ where + l := c.l + var := c.var + stk := tapes c.stk + +def statement : Stmt (Alphabet ΓA ΓB ΓC) Λ σ → Stmt (Alphabet ΓB ΓA ΓC) Λ σ + | .push (.inl a) f next => .push (.inr (.inl a)) f (statement next) + | .push (.inr (.inl b)) f next => .push (.inl b) f (statement next) + | .push (.inr (.inr c)) f next => .push (.inr (.inr c)) f (statement next) + | .peek (.inl a) f next => .peek (.inr (.inl a)) f (statement next) + | .peek (.inr (.inl b)) f next => .peek (.inl b) f (statement next) + | .peek (.inr (.inr c)) f next => .peek (.inr (.inr c)) f (statement next) + | .pop (.inl a) f next => .pop (.inr (.inl a)) f (statement next) + | .pop (.inr (.inl b)) f next => .pop (.inl b) f (statement next) + | .pop (.inr (.inr c)) f next => .pop (.inr (.inr c)) f (statement next) + | .load f next => .load f (statement next) + | .branch f yes no => .branch f (statement yes) (statement no) + | .goto f => .goto f + | .halt => .halt + +variable [DecidableEq A] [DecidableEq B] [DecidableEq C] + +theorem tapes_update_first (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) + (a : A) (value : List (ΓA a)) : + tapes (Function.update source (.inl a) value) = + Function.update (tapes source) (.inr (.inl a)) value := by + funext j + rcases j with b | a' | c + · simp [Function.update] + · by_cases h : a' = a + · subst a'; simp [Function.update] + · simp [Function.update, h] + · simp [Function.update] + +theorem tapes_update_second (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) + (b : B) (value : List (ΓB b)) : + tapes (Function.update source (.inr (.inl b)) value) = + Function.update (tapes source) (.inl b) value := by + funext j + rcases j with b' | a | c + · by_cases h : b' = b + · subst b'; simp [Function.update] + · simp [Function.update, h] + · simp [Function.update] + · simp [Function.update] + +theorem tapes_update_third (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) + (c : C) (value : List (ΓC c)) : + tapes (Function.update source (.inr (.inr c)) value) = + Function.update (tapes source) (.inr (.inr c)) value := by + funext j + rcases j with b | a | c' + · simp [Function.update] + · simp [Function.update] + · by_cases h : c' = c + · subst c'; simp [Function.update] + · simp [Function.update, h] + +theorem stepAux_simulation (q : Stmt (Alphabet ΓA ΓB ΓC) Λ σ) + (state : σ) (source : ∀ k, List (Alphabet ΓA ΓB ΓC k)) : + stepAux (statement q) state (tapes source) = + configuration (stepAux q state source) := by + induction q generalizing state source with + | push k f next ih => + rcases k with a | b | c + · simp only [statement, stepAux, tapes_first] + rw [← tapes_update_first] + exact ih state (Function.update source (.inl a) (f state :: source (.inl a))) + · simp only [statement, stepAux, tapes_second] + rw [← tapes_update_second] + exact ih state (Function.update source (.inr (.inl b)) + (f state :: source (.inr (.inl b)))) + · simp only [statement, stepAux, tapes_third] + rw [← tapes_update_third] + exact ih state (Function.update source (.inr (.inr c)) + (f state :: source (.inr (.inr c)))) + | peek k f next ih => + rcases k with a | b | c + · simpa only [statement, stepAux, tapes_first] using + ih (f state (source (.inl a)).head?) source + · simpa only [statement, stepAux, tapes_second] using + ih (f state (source (.inr (.inl b))).head?) source + · simpa only [statement, stepAux, tapes_third] using + ih (f state (source (.inr (.inr c))).head?) source + | pop k f next ih => + rcases k with a | b | c + · simp only [statement, stepAux, tapes_first] + rw [← tapes_update_first] + exact ih (f state (source (.inl a)).head?) + (Function.update source (.inl a) (source (.inl a)).tail) + · simp only [statement, stepAux, tapes_second] + rw [← tapes_update_second] + exact ih (f state (source (.inr (.inl b))).head?) + (Function.update source (.inr (.inl b)) (source (.inr (.inl b))).tail) + · simp only [statement, stepAux, tapes_third] + rw [← tapes_update_third] + exact ih (f state (source (.inr (.inr c))).head?) + (Function.update source (.inr (.inr c)) (source (.inr (.inr c))).tail) + | load f next ih => simpa only [statement, stepAux] using ih (f state) source + | branch f yes no ihYes ihNo => + cases h : f state with + | false => simpa only [statement, stepAux, h, Bool.cond_false] using ihNo state source + | true => simpa only [statement, stepAux, h, Bool.cond_true] using ihYes state source + | goto f => rfl + | halt => rfl + +def program (source : Λ → Stmt (Alphabet ΓA ΓB ΓC) Λ σ) : + Λ → Stmt (Alphabet ΓB ΓA ΓC) Λ σ := fun l => statement (source l) + +theorem step_simulation (source : Λ → Stmt (Alphabet ΓA ΓB ΓC) Λ σ) + (c : Cfg (Alphabet ΓA ΓB ΓC) Λ σ) : + step (program source) (configuration c) = (step source c).map configuration := by + cases c with + | mk l state sourceTapes => + cases l with + | none => rfl + | some l => + change some (stepAux (statement (source l)) state (tapes sourceTapes)) = _ + rw [stepAux_simulation] + rfl + +end IndependentSetsGames.Foundations.Complexity.MachineStackSwap + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineSequential.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineSequential.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3537f469bece32683c339f2916db1832da09ade --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineSequential.lean @@ -0,0 +1,381 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget +import OAI.Combinatorics.IndependentSets.Machines.MachineControl +import OAI.Combinatorics.IndependentSets.Machines.MachineReverse + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineSequential + +open Turing + +abbrev Tape (first second : FinTM2) := first.K ⊕ (second.K ⊕ Unit) +abbrev Symbols (first second : FinTM2) : Tape first second → Type := + MachineEmbedding.Alphabet first.Γ + (MachineEmbedding.Alphabet second.Γ (fun _ : Unit => second.Γ second.k₀)) +abbrev Label (first second : FinTM2) := first.Λ ⊕ (Bool ⊕ second.Λ) +abbrev Register (second : FinTM2) := Option (second.Γ second.k₀) +abbrev State (first second : FinTM2) := (first.σ × second.σ) × Register second + +def firstStates (first second : FinTM2) : + first.σ × (second.σ × Register second) ≃ State first second where + toFun st := ((st.1, st.2.1), st.2.2) + invFun st := (st.1.1, (st.1.2, st.2)) + left_inv _ := rfl + right_inv _ := rfl + +def secondStates (first second : FinTM2) : + second.σ × (first.σ × Register second) ≃ State first second where + toFun st := ((st.2.1, st.1), st.2.2) + invFun st := (st.1.2, (st.1.1, st.2)) + left_inv _ := rfl + right_inv _ := rfl + +def secondLabels (first second : FinTM2) : + second.Λ ⊕ (Bool ⊕ first.Λ) → Label first second + | .inl label => .inr (.inr label) + | .inr (.inl bit) => .inr (.inl bit) + | .inr (.inr label) => .inl label + +def bridgeLabel (first second : FinTM2) (bit : Bool) : Label first second := + .inr (.inl bit) + +def firstStatement (first second : FinTM2) (q : first.Stmt) : + TM2.Stmt (Symbols first second) (Label first second) (State first second) := + MachineControl.statement id (firstStates first second) + (MachineEmbedding.statement (some (bridgeLabel first second false)) q) + +def secondStatement (first second : FinTM2) (q : second.Stmt) : + TM2.Stmt (Symbols first second) (Label first second) (State first second) := + MachineControl.statement (secondLabels first second) (secondStates first second) + (MachineStackSwap.statement + (MachineEmbedding.statement + (Δ := MachineEmbedding.Alphabet first.Γ (fun _ : Unit => second.Γ second.k₀)) + (Λextra := Bool ⊕ first.Λ) none q)) + +def program (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) : + Label first second → TM2.Stmt (Symbols first second) (Label first second) + (State first second) + | .inl label => firstStatement first second (first.m label) + | .inr (.inr label) => secondStatement first second (second.m label) + | .inr (.inl false) => + Reduction.MachineTransfer.loopAt (Γ := Symbols first second) + (.inl first.k₁) (.inr (.inr ())) relabel fallback + (bridgeLabel first second false) (some (bridgeLabel first second true)) + | .inr (.inl true) => + Reduction.MachineTransfer.loopAt (Γ := Symbols first second) + (.inr (.inr ())) (.inr (.inl second.k₀)) id fallback + (bridgeLabel first second true) (some (.inr (.inr second.main))) + +def machine (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) : FinTM2 where + K := Tape first second + kFin := by + letI := first.kFin + letI := second.kFin + exact inferInstanceAs (Fintype (first.K ⊕ (second.K ⊕ Unit))) + k₀ := .inl first.k₀ + k₁ := .inr (.inl second.k₁) + Γ := Symbols first second + Λ := Label first second + ΛFin := by + letI := first.ΛFin + letI := second.ΛFin + exact inferInstanceAs (Fintype (first.Λ ⊕ (Bool ⊕ second.Λ))) + main := .inl first.main + σ := State first second + σFin := by + letI := first.σFin + letI := second.σFin + letI := second.Γk₀Fin + exact inferInstanceAs (Fintype ((first.σ × second.σ) × Option (second.Γ second.k₀))) + initialState := ((first.initialState, second.initialState), none) + Γk₀Fin := first.Γk₀Fin + m := program first second relabel fallback + +def firstConfiguration (first second : FinTM2) (c : first.Cfg) : + TM2.Cfg (Symbols first second) (Label first second) (State first second) := + MachineControl.configuration id (firstStates first second) + (MachineEmbedding.configuration (some (bridgeLabel first second false)) + (second.initialState, (none : Register second)) (fun _ => []) c) + +def secondConfiguration (first second : FinTM2) (c : second.Cfg) : + TM2.Cfg (Symbols first second) (Label first second) (State first second) := + MachineControl.configuration (secondLabels first second) (secondStates first second) + (MachineStackSwap.configuration + (MachineEmbedding.configuration + (Δ := MachineEmbedding.Alphabet first.Γ (fun _ : Unit => second.Γ second.k₀)) + (Λextra := Bool ⊕ first.Λ) none + (first.initialState, (none : Register second)) (fun _ => []) c)) + +theorem firstStep (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) (a b : first.Cfg) + (transition : first.step a = some b) : + (machine first second relabel fallback).step (firstConfiguration first second a) = + some (firstConfiguration first second b) := by + cases a with + | mk label state tapes => + cases label with + | none => cases transition + | some label => + have hb := Option.some.inj transition + subst b + change some (TM2.stepAux + (MachineControl.statement id (firstStates first second) + (MachineEmbedding.statement (some (bridgeLabel first second false)) (first.m label))) + ((firstStates first second) (state, (second.initialState, none))) + (MachineEmbedding.tapes tapes (fun _ => []))) = _ + have controlled := MachineControl.stepAux_simulation id (firstStates first second) + (MachineEmbedding.statement + (Δ := MachineEmbedding.Alphabet second.Γ (fun _ : Unit => second.Γ second.k₀)) + (some (bridgeLabel first second false)) (first.m label)) + (state, (second.initialState, none)) (MachineEmbedding.tapes tapes (fun _ => [])) + have embedded := MachineEmbedding.stepAux_simulation + (Δ := MachineEmbedding.Alphabet second.Γ (fun _ : Unit => second.Γ second.k₀)) + (some (bridgeLabel first second false)) (second.initialState, (none : Register second)) + (fun _ => []) (first.m label) state tapes + exact congrArg some (controlled.trans + (congrArg (MachineControl.configuration id (firstStates first second)) embedded)) + +theorem secondStep (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) (a b : second.Cfg) + (transition : second.step a = some b) : + (machine first second relabel fallback).step (secondConfiguration first second a) = + some (secondConfiguration first second b) := by + cases a with + | mk label state tapes => + cases label with + | none => cases transition + | some label => + have hb := Option.some.inj transition + subst b + change some (TM2.stepAux + (MachineControl.statement (secondLabels first second) (secondStates first second) + (MachineStackSwap.statement + (MachineEmbedding.statement + (Δ := MachineEmbedding.Alphabet first.Γ (fun _ : Unit => second.Γ second.k₀)) + (Λextra := Bool ⊕ first.Λ) none (second.m label)))) + ((secondStates first second) (state, (first.initialState, none))) + (MachineStackSwap.tapes (MachineEmbedding.tapes tapes (fun _ => [])))) = _ + rw [MachineControl.stepAux_simulation, MachineStackSwap.stepAux_simulation, + MachineEmbedding.stepAux_simulation] + rfl + +theorem firstConfiguration_init (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) (input : List (first.Γ first.k₀)) : + firstConfiguration first second (initList first input) = + initList (machine first second relabel fallback) input := by + unfold firstConfiguration MachineControl.configuration MachineEmbedding.configuration initList + congr 1 + funext k + rcases k with k | k | k + · by_cases h : k = first.k₀ + · subst k + simp [machine, MachineEmbedding.tapes] + rfl + · simp [machine, MachineEmbedding.tapes, h] + · simp [machine, MachineEmbedding.tapes] + · simp [machine, MachineEmbedding.tapes] + +theorem secondConfiguration_halt (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) (output : List (second.Γ second.k₁)) : + secondConfiguration first second (haltList second output) = + haltList (machine first second relabel fallback) output := by + unfold secondConfiguration MachineControl.configuration MachineStackSwap.configuration + MachineEmbedding.configuration haltList + congr 1 + funext k + rcases k with k | k | k + · simp [machine, MachineStackSwap.tapes, MachineEmbedding.tapes] + · by_cases h : k = second.k₁ + · subst k + simp [machine, MachineStackSwap.tapes, MachineEmbedding.tapes] + rfl + · simp [machine, MachineStackSwap.tapes, MachineEmbedding.tapes, h] + · simp [machine, MachineStackSwap.tapes, MachineEmbedding.tapes] + +def temporaryTapes (first second : FinTM2) (word : List (second.Γ second.k₀)) : + ∀ k, List (Symbols first second k) + | .inl _ => [] + | .inr (.inl _) => [] + | .inr (.inr _) => word + +def temporaryConfiguration (first second : FinTM2) (word : List (second.Γ second.k₀)) : + TM2.Cfg (Symbols first second) (Label first second) (State first second) := + ⟨some (bridgeLabel first second true), + ((first.initialState, second.initialState), none), temporaryTapes first second word⟩ + +theorem firstTransfer_tapes (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (word : List (first.Γ first.k₁)) : + Reduction.MachineTransfer.tapesAt (.inl first.k₁) (.inr (.inr ())) + (firstConfiguration first second (haltList first word)).stk [] (word.reverse.map relabel) = + temporaryTapes first second (word.reverse.map relabel) := by + funext k + rcases k with k | k | k + · by_cases h : k = first.k₁ + · subst k + simp [Reduction.MachineTransfer.tapesAt, temporaryTapes] + · simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, firstConfiguration, + MachineControl.configuration, MachineEmbedding.configuration, MachineEmbedding.tapes, + haltList, h] + · simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, firstConfiguration, + MachineControl.configuration, MachineEmbedding.configuration, MachineEmbedding.tapes] + · cases k + simp [Reduction.MachineTransfer.tapesAt, temporaryTapes] + +theorem secondTransfer_tapes (first second : FinTM2) (word : List (second.Γ second.k₀)) : + Reduction.MachineTransfer.tapesAt (Γ := Symbols first second) + (.inr (.inr ())) (.inr (.inl second.k₀)) + (temporaryTapes first second word) [] word.reverse = + (secondConfiguration first second (initList second word.reverse)).stk := by + funext k + rcases k with k | k | k + · simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, secondConfiguration, + MachineControl.configuration, MachineStackSwap.configuration, MachineStackSwap.tapes, + MachineEmbedding.configuration, MachineEmbedding.tapes] + · by_cases h : k = second.k₀ + · subst k + simp [Reduction.MachineTransfer.tapesAt, secondConfiguration, + MachineControl.configuration, MachineStackSwap.configuration, MachineStackSwap.tapes, + MachineEmbedding.configuration, MachineEmbedding.tapes, initList] + · simp [Reduction.MachineTransfer.tapesAt, temporaryTapes, secondConfiguration, + MachineControl.configuration, MachineStackSwap.configuration, MachineStackSwap.tapes, + MachineEmbedding.configuration, MachineEmbedding.tapes, initList, h] + · cases k + simp [Reduction.MachineTransfer.tapesAt, secondConfiguration, + MachineControl.configuration, MachineStackSwap.configuration, MachineStackSwap.tapes, + MachineEmbedding.configuration, MachineEmbedding.tapes] + +def firstTransfer (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) (word : List (first.Γ first.k₁)) : + StateTransition.EvalsToInTime (machine first second relabel fallback).step + (firstConfiguration first second (haltList first word)) + (some (temporaryConfiguration first second (word.reverse.map relabel))) + (word.length + 1) := by + let run := Reduction.MachineTransfer.transferAtInTime + (.inl first.k₁ : Tape first second) (.inr (.inr ())) (by intro h; cases h) + relabel fallback (bridgeLabel first second false) + (some (bridgeLabel first second true)) (program first second relabel fallback) rfl + (firstConfiguration first second (haltList first word)).stk + (first.initialState, second.initialState) none + have inputTape : (firstConfiguration first second (haltList first word)).stk (.inl first.k₁) = + word := by simp [firstConfiguration, MachineControl.configuration, + MachineEmbedding.configuration, MachineEmbedding.tapes, haltList] + have outputTape : + (firstConfiguration first second (haltList first word)).stk (.inr (.inr ())) = [] := rfl + rw [inputTape, outputTape, List.append_nil, firstTransfer_tapes] at run + exact run + +def secondTransfer (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) (word : List (second.Γ second.k₀)) : + StateTransition.EvalsToInTime (machine first second relabel fallback).step + (temporaryConfiguration first second word) + (some (secondConfiguration first second (initList second word.reverse))) + (word.length + 1) := by + let run := Reduction.MachineTransfer.transferAtInTime + (.inr (.inr ()) : Tape first second) (.inr (.inl second.k₀)) (by intro h; cases h) + id fallback (bridgeLabel first second true) (some (.inr (.inr second.main))) + (program first second relabel fallback) rfl (temporaryTapes first second word) + (first.initialState, second.initialState) none + simp only [temporaryTapes, List.map_id, List.append_nil] at run + rw [secondTransfer_tapes] at run + exact run + +def execute (first second : FinTM2) + (relabel : first.Γ first.k₁ → second.Γ second.k₀) + (fallback : second.Γ second.k₀) + (input : List (first.Γ first.k₀)) (middle : List (first.Γ first.k₁)) + (output : List (second.Γ second.k₁)) (firstBudget secondBudget : Nat) + (runFirst : TM2OutputsInTime first input (some middle) firstBudget) + (runSecond : TM2OutputsInTime second (middle.map relabel) (some output) secondBudget) : + TM2OutputsInTime (machine first second relabel fallback) input (some output) + (firstBudget + 2 * (middle.length + 1) + secondBudget) := by + let start := MachineComposition.liftExecutionInTime first.step + (machine first second relabel fallback).step (firstConfiguration first second) + (firstStep first second relabel fallback) runFirst + let bridge₁ := firstTransfer first second relabel fallback middle + have bridge₂ := secondTransfer first second relabel fallback (middle.reverse.map relabel) + have reversal : (middle.reverse.map relabel).reverse = middle.map relabel := by + simp only [List.map_reverse, List.reverse_reverse] + rw [reversal] at bridge₂ + simp only [List.length_map, List.length_reverse] at bridge₂ + let finish := MachineComposition.liftExecutionInTime second.step + (machine first second relabel fallback).step (secondConfiguration first second) + (secondStep first second relabel fallback) runSecond + let phase₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ start bridge₁ + let phase₁₂₃ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ phase₁₂ bridge₂ + have full := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ phase₁₂₃ finish + rw [firstConfiguration_init, secondConfiguration_halt] at full + exact { + toEvalsTo := full.toEvalsTo + steps_le_m := by have h := full.steps_le_m; omega + } + +noncomputable def compose {α β γ αΓ βΓ γΓ : Type} + {ea : α → List αΓ} {eb : β → List βΓ} {ec : γ → List γΓ} + {f : α → β} {g : β → γ} + (first : TM2ComputableInPolyTime ea eb f) + (second : TM2ComputableInPolyTime eb ec g) (fallback : βΓ) : + TM2ComputableInPolyTime ea ec (fun a => g (f a)) := by + let relabel : first.tm.Γ first.tm.k₁ → second.tm.Γ second.tm.k₀ := + fun symbol => second.inputAlphabet.symm (first.outputAlphabet symbol) + let defaultSymbol := second.inputAlphabet.symm fallback + let intermediate : Polynomial Nat := Polynomial.X + + Polynomial.C (Runtime.programPushBound first.tm) * first.time + refine { + tm := machine first.tm second.tm relabel defaultSymbol + inputAlphabet := first.inputAlphabet + outputAlphabet := second.outputAlphabet + time := MachineComposition.compositionPolynomial first.time second.time intermediate + outputsFun := ?_ + } + intro a + let input := (ea a).map first.inputAlphabet.invFun + let middle := (eb (f a)).map first.outputAlphabet.invFun + let output := (ec (g (f a))).map second.outputAlphabet.invFun + have handoff : middle.map relabel = (eb (f a)).map second.inputAlphabet.invFun := by + dsimp only [middle, relabel] + simp only [List.map_map] + apply List.map_congr_left + intro symbol _ + exact congrArg second.inputAlphabet.symm (first.outputAlphabet.apply_symm_apply symbol) + have runSecond : TM2OutputsInTime second.tm (middle.map relabel) (some output) + (second.time.eval (eb (f a)).length) := by + rw [handoff] + exact second.outputsFun (f a) + have full := execute first.tm second.tm relabel defaultSymbol input middle output + (first.time.eval (ea a).length) (second.time.eval (eb (f a)).length) + (first.outputsFun a) runSecond + have intermediateBound : (eb (f a)).length ≤ intermediate.eval (ea a).length := + Runtime.encodedOutputLength first a + have totalBound := MachineComposition.compositionBudget_le first.time second.time + intermediate (ea a).length (eb (f a)).length intermediateBound + have middleLength : middle.length = (eb (f a)).length := by simp only [middle, List.length_map] + exact { + toEvalsTo := full.toEvalsTo + steps_le_m := by + apply Nat.le_trans full.steps_le_m + simpa only [middleLength] using totalBound + } + +noncomputable def composeBits {α β γ : Type} + {ea : α → List Bool} {eb : β → List Bool} {ec : γ → List Bool} + {f : α → β} {g : β → γ} + (first : TM2ComputableInPolyTime ea eb f) + (second : TM2ComputableInPolyTime eb ec g) : + TM2ComputableInPolyTime ea ec (fun a => g (f a)) := + compose first second false + +end IndependentSetsGames.Foundations.Complexity.MachineSequential + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineStateEquiv.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineStateEquiv.lean new file mode 100644 index 0000000000000000000000000000000000000000..a52cca24aeb0d9cb07cc5e3d1b9c40ccc98209f2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineStateEquiv.lean @@ -0,0 +1,221 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget +import OAI.Combinatorics.IndependentSets.Machines.MachineControl + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineStateEquiv + +open Turing.TM2 + +variable {K Λ σ τ : Type} {Γ : K → Type} + +abbrev statement (e : σ ≃ τ) : Stmt Γ Λ σ → Stmt Γ Λ τ := + MachineControl.statement (id : Λ → Λ) e + +@[simp] theorem statement_symm_statement (e : σ ≃ τ) (q : Stmt Γ Λ σ) : + statement e.symm (statement e q) = q := by + induction q <;> + simp_all only [statement, MachineControl.statement, Equiv.symm_symm, + Equiv.symm_apply_apply, id_eq] + +def configuration (e : σ ≃ τ) (c : Cfg Γ Λ σ) : Cfg Γ Λ τ := + ⟨c.l, e c.var, c.stk⟩ + +@[simp] theorem configuration_label (e : σ ≃ τ) (c : Cfg Γ Λ σ) : + (configuration e c).l = c.l := rfl + +@[simp] theorem configuration_state (e : σ ≃ τ) (c : Cfg Γ Λ σ) : + (configuration e c).var = e c.var := rfl + +@[simp] theorem configuration_tapes (e : σ ≃ τ) (c : Cfg Γ Λ σ) : + (configuration e c).stk = c.stk := rfl + +@[simp] theorem configuration_symm_configuration (e : σ ≃ τ) (c : Cfg Γ Λ σ) : + configuration e.symm (configuration e c) = c := by + cases c + simp only [configuration, Equiv.symm_apply_apply] + +@[simp] theorem configuration_configuration_symm (e : σ ≃ τ) (c : Cfg Γ Λ τ) : + configuration e (configuration e.symm c) = c := by + cases c + simp only [configuration, Equiv.apply_symm_apply] + +def configurationEquiv (e : σ ≃ τ) : Cfg Γ Λ σ ≃ Cfg Γ Λ τ where + toFun := configuration e + invFun := configuration e.symm + left_inv := configuration_symm_configuration e + right_inv := configuration_configuration_symm e + +@[simp] theorem configurationEquiv_apply (e : σ ≃ τ) (c : Cfg Γ Λ σ) : + configurationEquiv e c = configuration e c := rfl + +@[simp] theorem control_configuration (e : σ ≃ τ) (c : Cfg Γ Λ σ) : + MachineControl.configuration (id : Λ → Λ) e c = configuration e c := by + cases c + simp [MachineControl.configuration, configuration] + +def program (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) : Λ → Stmt Γ Λ τ := + fun l => statement e (source l) + +@[simp] theorem program_symm_program (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) : + program e.symm (program e source) = source := by + funext l + exact statement_symm_statement e (source l) + +theorem statementPushBound (e : σ ≃ τ) (q : Stmt Γ Λ σ) : + Runtime.statementPushBound (statement e q) = Runtime.statementPushBound q := by + induction q <;> + simp_all only [statement, MachineControl.statement, Runtime.statementPushBound] + +theorem supportsStmt_iff (e : σ ≃ τ) (S : Finset Λ) (q : Stmt Γ Λ σ) : + SupportsStmt S (statement e q) ↔ SupportsStmt S q := by + induction q with + | push k f next ih => + simpa only [statement, MachineControl.statement, SupportsStmt] using ih + | peek k f next ih => + simpa only [statement, MachineControl.statement, SupportsStmt] using ih + | pop k f next ih => + simpa only [statement, MachineControl.statement, SupportsStmt] using ih + | load f next ih => + simpa only [statement, MachineControl.statement, SupportsStmt] using ih + | branch f yes no ihYes ihNo => + simp only [statement, MachineControl.statement, SupportsStmt, ihYes, ihNo] + | goto f => + change (∀ state : τ, f (e.symm state) ∈ S) ↔ ∀ state : σ, f state ∈ S + constructor + · intro h state + simpa only [Equiv.symm_apply_apply] using h (e state) + · intro h state + exact h (e.symm state) + | halt => rfl + +theorem supports_iff [Inhabited Λ] (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) + (S : Finset Λ) : Supports (program e source) S ↔ Supports source S := by + simp only [Supports, program, supportsStmt_iff] + +variable [DecidableEq K] + +theorem stepAux_transport (e : σ ≃ τ) (q : Stmt Γ Λ σ) (state : σ) + (tapes : ∀ k, List (Γ k)) : + stepAux (statement e q) (e state) tapes = + configuration e (stepAux q state tapes) := by + simpa only [statement, control_configuration] using + MachineControl.stepAux_simulation (id : Λ → Λ) e q state tapes + +theorem stepAux_transport_symm (e : σ ≃ τ) (q : Stmt Γ Λ σ) (state : τ) + (tapes : ∀ k, List (Γ k)) : + stepAux (statement e q) state tapes = + configuration e (stepAux q (e.symm state) tapes) := by + simpa only [Equiv.apply_symm_apply] using + stepAux_transport e q (e.symm state) tapes + +theorem step_transport (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) (c : Cfg Γ Λ σ) : + step (program e source) (configuration e c) = + (step source c).map (configuration e) := by + cases c with + | mk l state tapes => + cases l with + | none => rfl + | some l => + change some (stepAux (statement e (source l)) (e state) tapes) = _ + rw [stepAux_transport] + rfl + +theorem step_iff (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) (a b : Cfg Γ Λ σ) : + step (program e source) (configuration e a) = some (configuration e b) ↔ + step source a = some b := by + rw [step_transport] + change (step source a).map (configuration e) = (some b).map (configuration e) ↔ _ + constructor + · intro h + apply Option.map_injective (configurationEquiv e).injective + change (step source a).map (configuration e) = (some b).map (configuration e) + exact h + · exact congrArg (Option.map (configuration e)) + +theorem advance_transport (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) + (c : Option (Cfg Γ Λ σ)) : + MachineComposition.advance (step (program e source)) (c.map (configuration e)) = + (MachineComposition.advance (step source) c).map (configuration e) := by + cases c with + | none => rfl + | some c => exact step_transport e source c + +theorem iterate_transport (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) (n : Nat) + (c : Option (Cfg Γ Λ σ)) : + (MachineComposition.advance (step (program e source)))^[n] + (c.map (configuration e)) = + ((MachineComposition.advance (step source))^[n] c).map (configuration e) := by + induction n with + | zero => rfl + | succ n ih => + rw [Function.iterate_succ_apply', ih, advance_transport, + Function.iterate_succ_apply'] + +theorem trace_iff (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) (n : Nat) + (a b : Cfg Γ Λ σ) : + (MachineComposition.advance (step (program e source)))^[n] + (some (configuration e a)) = some (configuration e b) ↔ + (MachineComposition.advance (step source))^[n] (some a) = some b := by + change (MachineComposition.advance (step (program e source)))^[n] + ((some a).map (configuration e)) = (some b).map (configuration e) ↔ _ + rw [iterate_transport] + constructor + · intro h + apply Option.map_injective (configurationEquiv e).injective + change ((MachineComposition.advance (step source))^[n] (some a)).map (configuration e) = + (some b).map (configuration e) + exact h + · exact congrArg (Option.map (configuration e)) + +theorem trace (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) (n : Nat) + (a b : Cfg Γ Λ σ) + (run : (MachineComposition.advance (step source))^[n] (some a) = some b) : + (MachineComposition.advance (step (program e source)))^[n] + (some (configuration e a)) = some (configuration e b) := + (trace_iff e source n a b).2 run + +def execution (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) + {start : Cfg Γ Λ σ} {finish : Option (Cfg Γ Λ σ)} {budget : Nat} + (run : StateTransition.EvalsToInTime (step source) start finish budget) : + StateTransition.EvalsToInTime (step (program e source)) + (configuration e start) (finish.map (configuration e)) budget where + steps := run.steps + evals_in_steps := by + have h := run.evals_in_steps + change (MachineComposition.advance (step source))^[run.steps] (some start) = finish at h + change (MachineComposition.advance (step (program e source)))^[run.steps] + ((some start).map (configuration e)) = finish.map (configuration e) + rw [iterate_transport, h] + steps_le_m := run.steps_le_m + +@[simp] theorem execution_steps (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) + {start : Cfg Γ Λ σ} {finish : Option (Cfg Γ Λ σ)} {budget : Nat} + (run : StateTransition.EvalsToInTime (step source) start finish budget) : + (execution e source run).steps = run.steps := rfl + +def execution_reflect (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) + {start : Cfg Γ Λ σ} {finish : Option (Cfg Γ Λ σ)} {budget : Nat} + (run : StateTransition.EvalsToInTime (step (program e source)) + (configuration e start) (finish.map (configuration e)) budget) : + StateTransition.EvalsToInTime (step source) start finish budget where + steps := run.steps + evals_in_steps := by + change (MachineComposition.advance (step source))^[run.steps] (some start) = finish + apply Option.map_injective (configurationEquiv e).injective + change ((MachineComposition.advance (step source))^[run.steps] (some start)).map + (configuration e) = finish.map (configuration e) + rw [← iterate_transport] + exact run.evals_in_steps + steps_le_m := run.steps_le_m + +@[simp] theorem execution_reflect_steps (e : σ ≃ τ) (source : Λ → Stmt Γ Λ σ) + {start : Cfg Γ Λ σ} {finish : Option (Cfg Γ Λ σ)} {budget : Nat} + (run : StateTransition.EvalsToInTime (step (program e source)) + (configuration e start) (finish.map (configuration e)) budget) : + (execution_reflect e source run).steps = run.steps := rfl + +end IndependentSetsGames.Foundations.Complexity.MachineStateEquiv + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineStateFrame.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineStateFrame.lean new file mode 100644 index 0000000000000000000000000000000000000000..e50085e83631a0e6511bd6c2b2034008fdf9a429 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineStateFrame.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineSubroutine + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineStateFrame + +open Turing + +variable {K Λ Λ' σ τ : Type} {Γ : K → Type} + +def frameStatement : TM2.Stmt Γ Λ σ → TM2.Stmt Γ Λ (σ × τ) + | .push k f next => .push k (fun state => f state.1) (frameStatement next) + | .peek k f next => .peek k (fun state bit => (f state.1 bit, state.2)) + (frameStatement next) + | .pop k f next => .pop k (fun state bit => (f state.1 bit, state.2)) + (frameStatement next) + | .load f next => .load (fun state => (f state.1, state.2)) (frameStatement next) + | .branch f yes no => .branch (fun state => f state.1) + (frameStatement yes) (frameStatement no) + | .goto f => .goto (fun state => f state.1) + | .halt => .halt + +def frameConfiguration (ambient : τ) (c : TM2.Cfg Γ Λ σ) : TM2.Cfg Γ Λ (σ × τ) := + ⟨c.l, (c.var, ambient), c.stk⟩ + +def frameProgram (source : Λ → TM2.Stmt Γ Λ σ) : Λ → TM2.Stmt Γ Λ (σ × τ) := + fun label => frameStatement (source label) + +@[simp] theorem frameConfiguration_state (ambient : τ) (c : TM2.Cfg Γ Λ σ) : + (frameConfiguration ambient c).var.1 = c.var := rfl + +@[simp] theorem frameConfiguration_metadata (ambient : τ) (c : TM2.Cfg Γ Λ σ) : + (frameConfiguration ambient c).var.2 = ambient := rfl + +@[simp] theorem frameConfiguration_tapes (ambient : τ) (c : TM2.Cfg Γ Λ σ) : + (frameConfiguration ambient c).stk = c.stk := rfl + +theorem frameStatement_pushBound (q : TM2.Stmt Γ Λ σ) : + Runtime.statementPushBound (frameStatement (τ := τ) q) = Runtime.statementPushBound q := by + induction q <;> simp_all only [frameStatement, Runtime.statementPushBound] + +def statement (labels : Λ → Λ') (exit : Option Λ') (q : TM2.Stmt Γ Λ σ) : + TM2.Stmt Γ Λ' (σ × τ) := + MachineSubroutine.statement labels exit (frameStatement q) + +def configuration (labels : Λ → Λ') (exit : Option Λ') (ambient : τ) + (c : TM2.Cfg Γ Λ σ) : TM2.Cfg Γ Λ' (σ × τ) := + MachineSubroutine.configuration labels exit (frameConfiguration ambient c) + +@[simp] theorem configuration_state (labels : Λ → Λ') (exit : Option Λ') + (ambient : τ) (c : TM2.Cfg Γ Λ σ) : + (configuration labels exit ambient c).var.1 = c.var := rfl + +@[simp] theorem configuration_metadata (labels : Λ → Λ') (exit : Option Λ') + (ambient : τ) (c : TM2.Cfg Γ Λ σ) : + (configuration labels exit ambient c).var.2 = ambient := rfl + +@[simp] theorem configuration_tapes (labels : Λ → Λ') (exit : Option Λ') + (ambient : τ) (c : TM2.Cfg Γ Λ σ) : + (configuration labels exit ambient c).stk = c.stk := rfl + +theorem statement_pushBound (labels : Λ → Λ') (exit : Option Λ') + (q : TM2.Stmt Γ Λ σ) : + Runtime.statementPushBound (statement (τ := τ) labels exit q) = + Runtime.statementPushBound q := by + induction q <;> simp_all only [statement, frameStatement, + MachineSubroutine.statement, Runtime.statementPushBound] + cases exit <;> rfl + +variable [DecidableEq K] + +theorem frame_stepAux (q : TM2.Stmt Γ Λ σ) (state : σ) (ambient : τ) + (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (frameStatement q) (state, ambient) tapes = + frameConfiguration ambient (TM2.stepAux q state tapes) := by + induction q generalizing state tapes with + | push k f next ih => + simpa only [frameStatement, TM2.stepAux] using + ih state (Function.update tapes k (f state :: tapes k)) + | peek k f next ih => + simpa only [frameStatement, TM2.stepAux] using ih (f state (tapes k).head?) tapes + | pop k f next ih => + simpa only [frameStatement, TM2.stepAux] using + ih (f state (tapes k).head?) (Function.update tapes k (tapes k).tail) + | load f next ih => simpa only [frameStatement, TM2.stepAux] using ih (f state) tapes + | branch f yes no ihYes ihNo => + cases h : f state with + | false => simpa only [frameStatement, TM2.stepAux, h, Bool.cond_false] using ihNo state tapes + | true => simpa only [frameStatement, TM2.stepAux, h, Bool.cond_true] using ihYes state tapes + | goto f => rfl + | halt => rfl + +theorem frame_step (source : Λ → TM2.Stmt Γ Λ σ) (ambient : τ) + (c : TM2.Cfg Γ Λ σ) : + TM2.step (frameProgram source) (frameConfiguration ambient c) = + (TM2.step source c).map (frameConfiguration ambient) := by + rcases c with ⟨label, state, tapes⟩ + cases label with + | none => rfl + | some label => + change some (TM2.stepAux (frameStatement (source label)) (state, ambient) tapes) = _ + rw [frame_stepAux] + rfl + +theorem frame_advance (source : Λ → TM2.Stmt Γ Λ σ) (ambient : τ) + (c : Option (TM2.Cfg Γ Λ σ)) : + MachineComposition.advance (TM2.step (frameProgram source)) + (c.map (frameConfiguration ambient)) = + (MachineComposition.advance (TM2.step source) c).map (frameConfiguration ambient) := by + cases c with + | none => rfl + | some c => exact frame_step source ambient c + +theorem frame_iterate (source : Λ → TM2.Stmt Γ Λ σ) (ambient : τ) + (steps : ℕ) (c : Option (TM2.Cfg Γ Λ σ)) : + (MachineComposition.advance (TM2.step (frameProgram source)))^[steps] + (c.map (frameConfiguration ambient)) = + ((MachineComposition.advance (TM2.step source))^[steps] c).map + (frameConfiguration ambient) := by + induction steps with + | zero => rfl + | succ steps ih => + rw [Function.iterate_succ_apply', Function.iterate_succ_apply', ih] + exact frame_advance source ambient _ + +def frameExecution (source : Λ → TM2.Stmt Γ Λ σ) (ambient : τ) + {start : TM2.Cfg Γ Λ σ} {finish : Option (TM2.Cfg Γ Λ σ)} {budget : ℕ} + (run : StateTransition.EvalsToInTime (TM2.step source) start finish budget) : + StateTransition.EvalsToInTime (TM2.step (frameProgram source)) + (frameConfiguration ambient start) (finish.map (frameConfiguration ambient)) budget where + steps := run.steps + evals_in_steps := by + have h := run.evals_in_steps + change (MachineComposition.advance (TM2.step source))^[run.steps] (some start) = finish at h + change (MachineComposition.advance (TM2.step (frameProgram source)))^[run.steps] + ((some start).map (frameConfiguration ambient)) = finish.map (frameConfiguration ambient) + rw [frame_iterate, h] + steps_le_m := run.steps_le_m + +@[simp] theorem frameExecution_steps (source : Λ → TM2.Stmt Γ Λ σ) (ambient : τ) + {start : TM2.Cfg Γ Λ σ} {finish : Option (TM2.Cfg Γ Λ σ)} {budget : ℕ} + (run : StateTransition.EvalsToInTime (TM2.step source) start finish budget) : + (frameExecution source ambient run).steps = run.steps := rfl + +theorem stepAux_simulation (labels : Λ → Λ') (exit : Option Λ') + (q : TM2.Stmt Γ Λ σ) (state : σ) (ambient : τ) (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (statement labels exit q) (state, ambient) tapes = + configuration labels exit ambient (TM2.stepAux q state tapes) := by + rw [statement, MachineSubroutine.stepAux_simulation, frame_stepAux] + rfl + +theorem step_simulation (labels : Λ → Λ') (exit : Option Λ') (ambient : τ) + (source : Λ → TM2.Stmt Γ Λ σ) (target : Λ' → TM2.Stmt Γ Λ' (σ × τ)) + (atLabels : ∀ l, target (labels l) = statement labels exit (source l)) + (a b : TM2.Cfg Γ Λ σ) (h : TM2.step source a = some b) : + TM2.step target (configuration labels exit ambient a) = + some (configuration labels exit ambient b) := by + have framed : TM2.step (frameProgram source) (frameConfiguration ambient a) = + some (frameConfiguration ambient b) := by + rw [frame_step, h] + rfl + exact MachineSubroutine.step_simulation labels exit (frameProgram source) target + atLabels _ _ framed + +theorem trace (labels : Λ → Λ') (exit : Option Λ') (ambient : τ) + (source : Λ → TM2.Stmt Γ Λ σ) (target : Λ' → TM2.Stmt Γ Λ' (σ × τ)) + (atLabels : ∀ l, target (labels l) = statement labels exit (source l)) + (steps : ℕ) (a b : TM2.Cfg Γ Λ σ) + (run : (MachineComposition.advance (TM2.step source))^[steps] (some a) = some b) : + (MachineComposition.advance (TM2.step target))^[steps] + (some (configuration labels exit ambient a)) = some (configuration labels exit ambient b) := + MachineComposition.liftSuccessfulTrace (TM2.step source) (TM2.step target) + (configuration labels exit ambient) (step_simulation labels exit ambient source target atLabels) + steps a b run + +def execution (labels : Λ → Λ') (exit : Option Λ') (ambient : τ) + (source : Λ → TM2.Stmt Γ Λ σ) (target : Λ' → TM2.Stmt Γ Λ' (σ × τ)) + (atLabels : ∀ l, target (labels l) = statement labels exit (source l)) + {a b : TM2.Cfg Γ Λ σ} {budget : ℕ} + (run : StateTransition.EvalsToInTime (TM2.step source) a (some b) budget) : + StateTransition.EvalsToInTime (TM2.step target) + (configuration labels exit ambient a) (some (configuration labels exit ambient b)) budget := + MachineComposition.liftExecutionInTime (TM2.step source) (TM2.step target) + (configuration labels exit ambient) (step_simulation labels exit ambient source target atLabels) run + +@[simp] theorem execution_steps (labels : Λ → Λ') (exit : Option Λ') (ambient : τ) + (source : Λ → TM2.Stmt Γ Λ σ) (target : Λ' → TM2.Stmt Γ Λ' (σ × τ)) + (atLabels : ∀ l, target (labels l) = statement labels exit (source l)) + {a b : TM2.Cfg Γ Λ σ} {budget : ℕ} + (run : StateTransition.EvalsToInTime (TM2.step source) a (some b) budget) : + (execution labels exit ambient source target atLabels run).steps = run.steps := rfl + +end IndependentSetsGames.Foundations.Complexity.MachineStateFrame + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineSubroutine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineSubroutine.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb4a29e748b5a732f5f932b76540438c16ab830b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineSubroutine.lean @@ -0,0 +1,235 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.MachineLookup + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineSubroutine + +open Turing + +variable {K Λ Λ' σ : Type} {Γ : K → Type} + +def label (labels : Λ → Λ') (exit : Option Λ') : Option Λ → Option Λ' + | none => exit + | some l => some (labels l) + +def configuration (labels : Λ → Λ') (exit : Option Λ') (c : TM2.Cfg Γ Λ σ) : + TM2.Cfg Γ Λ' σ := ⟨label labels exit c.l, c.var, c.stk⟩ + +def statement (labels : Λ → Λ') (exit : Option Λ') : + TM2.Stmt Γ Λ σ → TM2.Stmt Γ Λ' σ + | .push k f next => .push k f (statement labels exit next) + | .peek k f next => .peek k f (statement labels exit next) + | .pop k f next => .pop k f (statement labels exit next) + | .load f next => .load f (statement labels exit next) + | .branch f yes no => .branch f (statement labels exit yes) (statement labels exit no) + | .goto f => .goto (fun s => labels (f s)) + | .halt => match exit with + | none => .halt + | some l => .goto (fun _ => l) + +variable [DecidableEq K] + +theorem stepAux_simulation (labels : Λ → Λ') (exit : Option Λ') + (q : TM2.Stmt Γ Λ σ) (state : σ) (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (statement labels exit q) state tapes = + configuration labels exit (TM2.stepAux q state tapes) := by + induction q generalizing state tapes with + | push k f next ih => + simpa only [statement, TM2.stepAux] using + ih state (Function.update tapes k (f state :: tapes k)) + | peek k f next ih => + simpa only [statement, TM2.stepAux] using ih (f state (tapes k).head?) tapes + | pop k f next ih => + simpa only [statement, TM2.stepAux] using + ih (f state (tapes k).head?) (Function.update tapes k (tapes k).tail) + | load f next ih => simpa only [statement, TM2.stepAux] using ih (f state) tapes + | branch f yes no ihYes ihNo => + cases h : f state with + | false => simpa only [statement, TM2.stepAux, h, Bool.cond_false] using ihNo state tapes + | true => simpa only [statement, TM2.stepAux, h, Bool.cond_true] using ihYes state tapes + | goto f => rfl + | halt => cases exit <;> rfl + +theorem step_simulation (labels : Λ → Λ') (exit : Option Λ') + (source : Λ → TM2.Stmt Γ Λ σ) (target : Λ' → TM2.Stmt Γ Λ' σ) + (atLabels : ∀ l, target (labels l) = statement labels exit (source l)) + (a b : TM2.Cfg Γ Λ σ) (h : TM2.step source a = some b) : + TM2.step target (configuration labels exit a) = + some (configuration labels exit b) := by + cases a with + | mk l state tapes => + cases l with + | none => simp [TM2.step] at h + | some l => + have hb : TM2.stepAux (source l) state tapes = b := Option.some.inj h + rw [← hb] + change some (TM2.stepAux (target (labels l)) state tapes) = _ + rw [atLabels, stepAux_simulation] + +theorem trace (labels : Λ → Λ') (exit : Option Λ') + (source : Λ → TM2.Stmt Γ Λ σ) (target : Λ' → TM2.Stmt Γ Λ' σ) + (atLabels : ∀ l, target (labels l) = statement labels exit (source l)) + (steps : Nat) (a b : TM2.Cfg Γ Λ σ) + (run : (MachineComposition.advance (TM2.step source))^[steps] (some a) = some b) : + (MachineComposition.advance (TM2.step target))^[steps] + (some (configuration labels exit a)) = some (configuration labels exit b) := + MachineComposition.liftSuccessfulTrace (TM2.step source) (TM2.step target) + (configuration labels exit) (step_simulation labels exit source target atLabels) steps a b run + +def execution (labels : Λ → Λ') (exit : Option Λ') + (source : Λ → TM2.Stmt Γ Λ σ) (target : Λ' → TM2.Stmt Γ Λ' σ) + (atLabels : ∀ l, target (labels l) = statement labels exit (source l)) + {a b : TM2.Cfg Γ Λ σ} {budget : Nat} + (run : StateTransition.EvalsToInTime (TM2.step source) a (some b) budget) : + StateTransition.EvalsToInTime (TM2.step target) + (configuration labels exit a) (some (configuration labels exit b)) budget := + MachineComposition.liftExecutionInTime (TM2.step source) (TM2.step target) + (configuration labels exit) (step_simulation labels exit source target atLabels) run + +end IndependentSetsGames.Foundations.Complexity.MachineSubroutine +namespace IndependentSetsGames.Foundations.Complexity.MachinePreservingLookup + +open Turing +open MachineComposition + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def initialTapes (tape : Fin 5 → K) (base : K → List Bool) + (index : Nat) (indexSuffix workSuffix output : List Bool) : K → List Bool := + MachineLookup.tapes (tape 1) (tape 2) (tape 3) base + (encodeWord index ++ indexSuffix) workSuffix output + +def finalTapes (tape : Fin 5 → K) (base : K → List Bool) + (values : List Nat) (index value : Nat) + (indexSuffix workSuffix output : List Bool) : K → List Bool := + MachineLookup.tapes (tape 1) (tape 2) (tape 3) base + (encodeWord 0 ++ indexSuffix) + (encodeWords (values.drop (index + 1)) ++ workSuffix) (encodeWord value ++ output) + +theorem lookupFramedHaltTrace_some (index source destination : K) + (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (values : List Nat) (i value : Nat) + (selected : values[i]? = some value) (indexSuffix suffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (MachineLookup.program index source destination)))^[ + MachineLookupSpec.steps values i + 1] + (some ⟨some MachineLookup.Label.guard, (ambient,register), + MachineLookup.tapes index source destination base (encodeWord i ++ indexSuffix) + (encodeWords values ++ suffix) output⟩) = + some ⟨none, (ambient,none), MachineLookup.tapes index source destination base + (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1)) ++ suffix) + (encodeWord value ++ output)⟩ := by + rw [Function.iterate_succ_apply', + MachineLookup.lookupTrace_some index source destination his hid hsd + base values i value selected indexSuffix suffix output ambient register] + simp only [advance_some, TM2.step, MachineLookup.program, TM2.stepAux] + +theorem preservingLookupTrace (tape : Fin 5 → K) (distinct : Function.Injective tape) + (firstLabel secondLabel : Λ) (lookupLabels : MachineLookup.Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atFirst : program firstLabel = Reduction.MachineTransfer.loopAt + (tape 0) (tape 4) id false firstLabel (some secondLabel)) + (atSecond : program secondLabel = MachineCopy.forkLoop + (tape 4) (tape 0) (tape 2) false secondLabel (some (lookupLabels .guard))) + (atLookup : ∀ l, program (lookupLabels l) = + MachineSubroutine.statement lookupLabels exit (MachineLookup.program (tape 1) (tape 2) (tape 3) l)) + (base : K → List Bool) (values : List Nat) (tableWord : base (tape 0) = encodeWords values) + (scratchEmpty : base (tape 4) = []) (i value : Nat) (selected : values[i]? = some value) + (indexSuffix workSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[ + 2 * ((encodeWords values).length + 1) + MachineLookupSpec.steps values i + 1] + (some ⟨some firstLabel, (ambient,register), + initialTapes tape base i indexSuffix workSuffix output⟩) = + some ⟨exit, (ambient,none), finalTapes tape base values i value indexSuffix workSuffix output⟩ := by + have hd (a b : Fin 5) (hne : a ≠ b) : tape a ≠ tape b := fun h => hne (distinct h) + let start := initialTapes tape base i indexSuffix workSuffix output + have htable : start (tape 0) = encodeWords values := by + simpa only [start, initialTapes, MachineLookup.tapes_other _ _ _ _ + (hd 0 1 (by decide)) (hd 0 2 (by decide)) (hd 0 3 (by decide))] using tableWord + have hs : start (tape 4) = [] := by + simpa only [start, initialTapes, MachineLookup.tapes_other _ _ _ _ + (hd 4 1 (by decide)) (hd 4 2 (by decide)) (hd 4 3 (by decide))] using scratchEmpty + have hwork : start (tape 2) = workSuffix := by + simp only [start, initialTapes, MachineLookup.tapes_source _ _ _ (hd 2 3 (by decide))] + have hcopy := MachineCopy.copyTrace (tape 0) (tape 2) (tape 4) + (hd 0 2 (by decide)) (hd 0 4 (by decide)) (hd 2 4 (by decide)) false + firstLabel secondLabel (some (lookupLabels .guard)) program atFirst atSecond start hs ambient register + rw [htable, hwork] at hcopy + simp only [start, initialTapes, MachineLookup.update_source _ _ _ (hd 2 3 (by decide))] at hcopy + have hlookup := MachineSubroutine.trace lookupLabels exit + (MachineLookup.program (tape 1) (tape 2) (tape 3)) program atLookup + (MachineLookupSpec.steps values i + 1) _ _ + (lookupFramedHaltTrace_some (tape 1) (tape 2) (tape 3) + (hd 1 2 (by decide)) (hd 1 3 (by decide)) (hd 2 3 (by decide)) + base values i value selected indexSuffix workSuffix output ambient none) + simp only [MachineSubroutine.configuration, MachineSubroutine.label] at hlookup + rw [show 2 * ((encodeWords values).length + 1) + MachineLookupSpec.steps values i + 1 = + (MachineLookupSpec.steps values i + 1) + 2 * ((encodeWords values).length + 1) by omega, + Function.iterate_add_apply] + change (advance (TM2.step program))^[MachineLookupSpec.steps values i + 1] + ((advance (TM2.step program))^[2 * ((encodeWords values).length + 1)] + (some ⟨some firstLabel, (ambient,register), + MachineLookup.tapes (tape 1) (tape 2) (tape 3) base + (encodeWord i ++ indexSuffix) workSuffix output⟩)) = _ + rw [hcopy] + exact hlookup + +theorem preservingLookup_steps_le (values : List Nat) (i value : Nat) + (selected : values[i]? = some value) : + 2 * ((encodeWords values).length + 1) + MachineLookupSpec.steps values i + 1 ≤ + 5 * (encodeWords values).length + 3 := by + have ht := MachineLookupSpec.steps_le_input_encoding_size values i + have hi := MachineLookupSpec.index_length_le values i value selected + omega + +def preservingLookupInTime (tape : Fin 5 → K) (distinct : Function.Injective tape) + (firstLabel secondLabel : Λ) (lookupLabels : MachineLookup.Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atFirst : program firstLabel = Reduction.MachineTransfer.loopAt + (tape 0) (tape 4) id false firstLabel (some secondLabel)) + (atSecond : program secondLabel = MachineCopy.forkLoop + (tape 4) (tape 0) (tape 2) false secondLabel (some (lookupLabels .guard))) + (atLookup : ∀ l, program (lookupLabels l) = + MachineSubroutine.statement lookupLabels exit (MachineLookup.program (tape 1) (tape 2) (tape 3) l)) + (base : K → List Bool) (values : List Nat) (tableWord : base (tape 0) = encodeWords values) + (scratchEmpty : base (tape 4) = []) (i value : Nat) (selected : values[i]? = some value) + (indexSuffix workSuffix output : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some firstLabel, (ambient,register), initialTapes tape base i indexSuffix workSuffix output⟩ + (some ⟨exit, (ambient,none), finalTapes tape base values i value indexSuffix workSuffix output⟩) + (5 * (encodeWords values).length + 3) where + steps := 2 * ((encodeWords values).length + 1) + MachineLookupSpec.steps values i + 1 + evals_in_steps := preservingLookupTrace tape distinct firstLabel secondLabel lookupLabels exit + program atFirst atSecond atLookup base values tableWord scratchEmpty i value selected + indexSuffix workSuffix output ambient register + steps_le_m := preservingLookup_steps_le values i value selected + +inductive Label + | copyFirst | copySecond | lookup (l : MachineLookup.Label) + deriving DecidableEq, Fintype + +def program (tape : Fin 5 → K) : + Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) + | .copyFirst => Reduction.MachineTransfer.loopAt (tape 0) (tape 4) id false .copyFirst (some .copySecond) + | .copySecond => MachineCopy.forkLoop (tape 4) (tape 0) (tape 2) false .copySecond (some (.lookup .guard)) + | .lookup l => MachineSubroutine.statement Label.lookup none + (MachineLookup.program (tape 1) (tape 2) (tape 3) l) + +def machine : FinTM2 where + K := Fin 5 + k₀ := 0 + k₁ := 3 + Γ _ := Bool + Λ := Label + main := .copyFirst + σ := Unit × Option Bool + initialState := ((),none) + m := program id + +end IndependentSetsGames.Foundations.Complexity.MachinePreservingLookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTableRows.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTableRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..a593312bd7d65e0bde1a4f55cbbaafac4f2bd794 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTableRows.lean @@ -0,0 +1,255 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GraphTables +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.MachineAppend + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineTableRows + +open Turing +open PCP.GraphTables + +inductive Label + | relationRead | relationRestore | reverseRead | reverseRestore + | tailRead | tailRestore | appendOld | appendRow | appendBack + deriving DecidableEq + +instance : Fintype Label where + elems := {.relationRead, .relationRestore, .reverseRead, .reverseRestore, .tailRead, + .tailRestore, .appendOld, .appendRow, .appendBack} + complete value := by cases value <;> simp + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def routine (fields : Fin 3 → K) (row output scratch : K) + (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .relationRead => Reduction.MachineTransfer.loopAt (fields 2) scratch id false + (labels .relationRead) (some (labels .relationRestore)) + | .relationRestore => MachineCopy.forkLoop scratch (fields 2) row false + (labels .relationRestore) (some (labels .reverseRead)) + | .reverseRead => Reduction.MachineTransfer.loopAt (fields 1) scratch id false + (labels .reverseRead) (some (labels .reverseRestore)) + | .reverseRestore => MachineCopy.forkLoop scratch (fields 1) row false + (labels .reverseRestore) (some (labels .tailRead)) + | .tailRead => Reduction.MachineTransfer.loopAt (fields 0) scratch id false + (labels .tailRead) (some (labels .tailRestore)) + | .tailRestore => MachineCopy.forkLoop scratch (fields 0) row false + (labels .tailRestore) (some (labels .appendOld)) + | .appendOld => Reduction.MachineTransfer.loopAt output scratch id false + (labels .appendOld) (some (labels .appendRow)) + | .appendRow => Reduction.MachineTransfer.loopAt row scratch id false + (labels .appendRow) (some (labels .appendBack)) + | .appendBack => Reduction.MachineTransfer.loopAt scratch output id false + (labels .appendBack) exit + +def fieldBits (fields : Fin 3 → K) (base : K → List Bool) : List Bool := + base (fields 0) ++ base (fields 1) ++ base (fields 2) + +def fieldSize (fields : Fin 3 → K) (base : K → List Bool) : Nat := + (base (fields 0)).length + (base (fields 1)).length + (base (fields 2)).length + +omit [DecidableEq K] in +@[simp] theorem fieldBits_length (fields : Fin 3 → K) (base : K → List Bool) : + (fieldBits fields base).length = fieldSize fields base := by + simp [fieldBits, fieldSize, Nat.add_assoc] + +def prefixTapes (fields : Fin 3 → K) (row : K) (base : K → List Bool) : K → List Bool := + Function.update base row (fieldBits fields base ++ base row) + +theorem prefixTrace (fields : Fin 3 → K) (row output scratch : K) + (hfields : ∀ i, fields i ≠ row ∧ fields i ≠ scratch) + (hrowScratch : row ≠ scratch) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (hprogram : ∀ label, program (labels label) = routine fields row output scratch labels exit label) + (base : K → List Bool) (hscratch : base scratch = []) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[2 * (fieldSize fields base + 3)] + (some ⟨some (labels .relationRead), (ambient, register), base⟩) = + some ⟨some (labels .appendOld), (ambient, none), prefixTapes fields row base⟩ := by + let afterRelation := Function.update base row (base (fields 2) ++ base row) + let afterReverse := Function.update afterRelation row + (base (fields 1) ++ afterRelation row) + have hfirst := MachineCopy.copyTrace (fields 2) row scratch + (hfields 2).1 (hfields 2).2 hrowScratch false + (labels .relationRead) (labels .relationRestore) (some (labels .reverseRead)) + program (hprogram .relationRead) (hprogram .relationRestore) base hscratch ambient register + change (MachineComposition.advance (TM2.step program))^[2 * ((base (fields 2)).length + 1)] + (some ⟨some (labels .relationRead), (ambient, register), base⟩) = + some ⟨some (labels .reverseRead), (ambient, none), afterRelation⟩ at hfirst + have hsecond := MachineCopy.copyTrace (fields 1) row scratch + (hfields 1).1 (hfields 1).2 hrowScratch false + (labels .reverseRead) (labels .reverseRestore) (some (labels .tailRead)) + program (hprogram .reverseRead) (hprogram .reverseRestore) afterRelation + (by simp [afterRelation, Ne.symm hrowScratch, hscratch]) ambient none + have hrev : afterRelation (fields 1) = base (fields 1) := by + simp [afterRelation, (hfields 1).1] + rw [hrev] at hsecond + change (MachineComposition.advance (TM2.step program))^[2 * ((base (fields 1)).length + 1)] + (some ⟨some (labels .reverseRead), (ambient, none), afterRelation⟩) = + some ⟨some (labels .tailRead), (ambient, none), afterReverse⟩ at hsecond + have hthird := MachineCopy.copyTrace (fields 0) row scratch + (hfields 0).1 (hfields 0).2 hrowScratch false + (labels .tailRead) (labels .tailRestore) (some (labels .appendOld)) + program (hprogram .tailRead) (hprogram .tailRestore) afterReverse + (by simp [afterReverse, afterRelation, Ne.symm hrowScratch, hscratch]) ambient none + have htail : afterReverse (fields 0) = base (fields 0) := by + simp [afterReverse, afterRelation, (hfields 0).1] + rw [htail] at hthird + have hfinal : Function.update afterReverse row + (base (fields 0) ++ afterReverse row) = prefixTapes fields row base := by + simp [afterReverse, afterRelation, prefixTapes, fieldBits, List.append_assoc] + rw [hfinal] at hthird + rw [show 2 * (fieldSize fields base + 3) = + 2 * ((base (fields 0)).length + 1) + + (2 * ((base (fields 1)).length + 1) + 2 * ((base (fields 2)).length + 1)) by + simp only [fieldSize]; omega, + Function.iterate_add_apply, + Function.iterate_add_apply (m := 2 * ((base (fields 1)).length + 1)) + (n := 2 * ((base (fields 2)).length + 1)), hfirst, hsecond] + exact hthird + +theorem appendTrace (fields : Fin 3 → K) (row output scratch : K) + (hfields : ∀ i, fields i ≠ row ∧ fields i ≠ scratch) + (hrowOutput : row ≠ output) (hrowScratch : row ≠ scratch) + (houtputScratch : output ≠ scratch) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (hprogram : ∀ label, program (labels label) = routine fields row output scratch labels exit label) + (base : K → List Bool) (hrow : base row = []) (hscratch : base scratch = []) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[ + 4 * fieldSize fields base + 2 * (base output).length + 9] + (some ⟨some (labels .relationRead), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), + Function.update base output (base output ++ fieldBits fields base)⟩ := by + have hprefix := prefixTrace fields row output scratch hfields hrowScratch + labels exit program hprogram base hscratch ambient register + have happend := MachineAppendAt.appendTrace row output scratch hrowOutput hrowScratch + houtputScratch false (labels .appendOld) (labels .appendRow) (labels .appendBack) + exit program (hprogram .appendOld) (hprogram .appendRow) (hprogram .appendBack) + (prefixTapes fields row base) + (by simp [prefixTapes, Ne.symm hrowScratch, hscratch]) ambient none + have hrowbits : prefixTapes fields row base row = fieldBits fields base := by + simp [prefixTapes, hrow] + have hout : prefixTapes fields row base output = base output := by + simp [prefixTapes, Ne.symm hrowOutput] + rw [hrowbits, hout, fieldBits_length] at happend + have hfinal : MachineAppendAt.appendTapes row output (prefixTapes fields row base) = + Function.update base output (base output ++ fieldBits fields base) := by + funext k + by_cases ho : k = output + · subst k + simp [MachineAppendAt.appendTapes, hrowbits, hout] + · by_cases hr : k = row + · subst k + simp [MachineAppendAt.appendTapes, Reduction.MachineTransfer.tapesAt, + prefixTapes, hrowOutput, hrow] + · simp [MachineAppendAt.appendTapes, Reduction.MachineTransfer.tapesAt, + prefixTapes, ho, hr] + rw [hfinal] at happend + rw [show 4 * fieldSize fields base + 2 * (base output).length + 9 = + (2 * (fieldSize fields base + (base output).length) + 3) + + 2 * (fieldSize fields base + 3) by omega, + Function.iterate_add_apply, hprefix] + exact happend + +theorem rowBits_eq {n m : Nat} (r : DartRow n m) : + encodeWords (rowWords r) = encodeWord r.tail.val ++ + encodeWord r.reverseIndex.val ++ encodeWords (relationWords r.relation) := by + simp [rowWords, encodeWords] + +omit [DecidableEq K] in +theorem fieldBits_eq_rowBits {n m : Nat} (r : DartRow n m) + (fields : Fin 3 → K) (base : K → List Bool) + (htail : base (fields 0) = encodeWord r.tail.val) + (hreverse : base (fields 1) = encodeWord r.reverseIndex.val) + (hrelation : base (fields 2) = encodeWords (relationWords r.relation)) : + fieldBits fields base = encodeWords (rowWords r) := by + rw [fieldBits, htail, hreverse, hrelation, rowBits_eq] + +noncomputable def timePolynomial : Polynomial Nat := Polynomial.C 4 * Polynomial.X + Polynomial.C 9 + +omit [DecidableEq K] in +theorem timePolynomial_bounds (fields : Fin 3 → K) (base : K → List Bool) (output : K) : + 4 * fieldSize fields base + 2 * (base output).length + 9 ≤ + timePolynomial.eval (fieldSize fields base + (base output).length) := by + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_X] + omega + +def rowAppendInTime {n m : Nat} (r : DartRow n m) + (fields : Fin 3 → K) (row output scratch : K) + (hfields : ∀ i, fields i ≠ row ∧ fields i ≠ scratch) + (hrowOutput : row ≠ output) (hrowScratch : row ≠ scratch) + (houtputScratch : output ≠ scratch) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (hprogram : ∀ label, program (labels label) = routine fields row output scratch labels exit label) + (base : K → List Bool) (hrow : base row = []) (hscratch : base scratch = []) + (htail : base (fields 0) = encodeWord r.tail.val) + (hreverse : base (fields 1) = encodeWord r.reverseIndex.val) + (hrelation : base (fields 2) = encodeWords (relationWords r.relation)) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .relationRead), (ambient, register), base⟩ + (some ⟨exit, (ambient, none), + Function.update base output (base output ++ encodeWords (rowWords r))⟩) + (timePolynomial.eval (fieldSize fields base + (base output).length)) where + steps := 4 * fieldSize fields base + 2 * (base output).length + 9 + evals_in_steps := by + change (MachineComposition.advance (TM2.step program))^[_] _ = _ + rw [← fieldBits_eq_rowBits r fields base htail hreverse hrelation] + exact appendTrace fields row output scratch hfields hrowOutput hrowScratch + houtputScratch labels exit program hprogram base hrow hscratch ambient register + steps_le_m := timePolynomial_bounds fields base output + +def machine : FinTM2 where + K := Fin 6 + k₀ := 0 + k₁ := 4 + Γ _ := Bool + Λ := Label + main := .relationRead + σ := Unit × Option Bool + initialState := ((), none) + m := routine (fun i : Fin 3 => i.castLE (by decide)) 3 4 5 id none + +def machineRowInTime {n m : Nat} (r : DartRow n m) (base : Fin 6 → List Bool) + (hrow : base 3 = []) (hscratch : base 5 = []) + (htail : base 0 = encodeWord r.tail.val) + (hreverse : base 1 = encodeWord r.reverseIndex.val) + (hrelation : base 2 = encodeWords (relationWords r.relation)) (register : Option Bool) : + StateTransition.EvalsToInTime machine.step + ⟨some .relationRead, ((), register), base⟩ + (some ⟨none, ((), none), + Function.update base (4 : Fin 6) (base 4 ++ encodeWords (rowWords r))⟩) + (timePolynomial.eval ((encodeWords (rowWords r)).length + (base 4).length)) := by + let fields : Fin 3 → Fin 6 := fun i => i.castLE (by decide) + have hfields (i : Fin 3) : fields i ≠ 3 ∧ fields i ≠ 5 := by + constructor + · intro h + have he := congrArg Fin.val h + change i.val = 3 at he + omega + · intro h + have he := congrArg Fin.val h + change i.val = 5 at he + omega + have hsize : fieldSize fields base = (encodeWords (rowWords r)).length := by + rw [← fieldBits_length, fieldBits_eq_rowBits r fields base htail hreverse hrelation] + have run := rowAppendInTime r fields (3 : Fin 6) 4 5 hfields (by decide) (by decide) + (by decide) id none machine.m (fun _ => rfl) base hrow hscratch + htail hreverse hrelation () register + rw [hsize] at run + convert run using 1; rfl + +theorem outputFrame (base : K → List Bool) (output k : K) (hk : k ≠ output) + (bits : List Bool) : + Function.update base output (base output ++ bits) k = base k := by + simp [hk] + +end IndependentSetsGames.Foundations.Complexity.MachineTableRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransducer.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransducer.lean new file mode 100644 index 0000000000000000000000000000000000000000..d59a05ce74e9d3c0ff4b7cfaa14db5d7626429ff --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransducer.lean @@ -0,0 +1,245 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PushWord +import OAI.Combinatorics.IndependentSets.Machines.MachineSequential + +namespace OAI + +namespace IndependentSetsGames.Reduction.MachineTransducer + +open Turing +open IndependentSetsGames.Foundations.Complexity +open MachineSubstitution (pushWord stepAux_pushWord statementPushBound_pushWord) + +def tapeStacks (input output : List Bool) : Bool → List Bool := + fun side => if side then output else input + +theorem update_input (input output replacement : List Bool) : + Function.update (tapeStacks input output) false replacement = tapeStacks replacement output := by + funext side + cases side <;> simp [tapeStacks] + +theorem update_output (input output replacement : List Bool) : + Function.update (tapeStacks input output) true replacement = tapeStacks input replacement := by + funext side + cases side <;> simp [tapeStacks] + +variable {Q : Type} [Fintype Q] + +def output (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) : + Q → List Bool → List Bool + | _, [] => [] + | state, symbol :: input => + emit state symbol ++ output transition emit (transition state symbol) input + +def loop (initial : Q) : + TM2.Stmt (fun _ : Bool => Bool) (Option (Q × Bool)) (Q × Option Bool) := + .pop false (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.goto fun state => some (state.1, state.2.getD false)) + (.load (fun _ => (initial, none)) .halt)) + +def program (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) : + Option (Q × Bool) → + TM2.Stmt (fun _ : Bool => Bool) (Option (Q × Bool)) (Q × Option Bool) + | none => loop initial + | some (state, symbol) => + .load (fun register => (transition state symbol, register.2)) + (pushWord true (emit state symbol) (.goto fun _ => none)) + +def machine (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) : + FinTM2 where + K := Bool + k₀ := false + k₁ := true + Γ _ := Bool + Λ := Option (Q × Bool) + main := none + σ := Q × Option Bool + initialState := (initial, none) + m := program initial transition emit + +noncomputable def maxEmission (emit : Q → Bool → List Bool) : Nat := + Finset.univ.sup (fun pair : Q × Bool => (emit pair.1 pair.2).length) + +theorem emission_le (emit : Q → Bool → List Bool) (state : Q) (symbol : Bool) : + (emit state symbol).length ≤ maxEmission emit := by + exact Finset.le_sup (f := fun pair : Q × Bool => (emit pair.1 pair.2).length) + (Finset.mem_univ (state, symbol)) + +theorem statementPushBound_le (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (label : Option (Q × Bool)) : + Runtime.statementPushBound (program initial transition emit label) ≤ maxEmission emit := by + cases label with + | none => simp [program, loop, Runtime.statementPushBound] + | some pair => + simpa only [program, Runtime.statementPushBound, statementPushBound_pushWord, + Nat.add_zero] using emission_le emit pair.1 pair.2 + +theorem programPushBound_le (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) : + Runtime.programPushBound (machine initial transition emit) ≤ maxEmission emit := by + have allLabels (labels : List (Option (Q × Bool))) : + Runtime.maxLabelPushes (program initial transition emit) labels ≤ maxEmission emit := by + induction labels with + | nil => exact Nat.zero_le _ + | cons label rest ih => + exact max_le (statementPushBound_le initial transition emit label) ih + exact allLabels (machine initial transition emit).ΛFin.elems.toList + +def running (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (state : Q) (input accumulator : List Bool) (register : Option Bool) : + (machine initial transition emit).Cfg := + ⟨some none, (state, register), tapeStacks input accumulator⟩ + +def emitting (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (oldState : Q) (symbol : Bool) (input accumulator : List Bool) + (state : Q × Option Bool) : (machine initial transition emit).Cfg := + ⟨some (some (oldState, symbol)), state, tapeStacks input accumulator⟩ + +def halted (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (accumulator : List Bool) : (machine initial transition emit).Cfg := + ⟨none, (initial, none), tapeStacks [] accumulator⟩ + +theorem step_empty (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (state : Q) (accumulator : List Bool) + (register : Option Bool) : + (machine initial transition emit).step + (running initial transition emit state [] accumulator register) = + some (halted initial transition emit accumulator) := by + change some (TM2.stepAux (loop initial) (state, register) (tapeStacks [] accumulator)) = _ + simp [loop, TM2.stepAux, tapeStacks, halted] + rw [update_input] + rfl + +theorem step_cons (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (state : Q) (symbol : Bool) + (input accumulator : List Bool) (register : Option Bool) : + (machine initial transition emit).step + (running initial transition emit state (symbol :: input) accumulator register) = + some (emitting initial transition emit state symbol input accumulator (state, some symbol)) := by + change some (TM2.stepAux (loop initial) (state, register) + (tapeStacks (symbol :: input) accumulator)) = _ + simp [loop, TM2.stepAux, tapeStacks, emitting] + rw [update_input] + rfl + +theorem step_emit (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (oldState : Q) (symbol : Bool) + (input accumulator : List Bool) (state : Q × Option Bool) : + (machine initial transition emit).step + (emitting initial transition emit oldState symbol input accumulator state) = + some (running initial transition emit (transition oldState symbol) input + ((emit oldState symbol).reverse ++ accumulator) state.2) := by + change some (TM2.stepAux (pushWord true (emit oldState symbol) (.goto fun _ => none)) + (transition oldState symbol, state.2) (tapeStacks input accumulator)) = _ + rw [stepAux_pushWord] + simp only [TM2.stepAux] + change some (⟨some none, (transition oldState symbol, state.2), + Function.update (tapeStacks input accumulator) true + ((emit oldState symbol).reverse ++ accumulator)⟩ : + (machine initial transition emit).Cfg) = _ + erw [update_output] + rfl + +def next (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (configuration : Option (machine initial transition emit).Cfg) : + Option (machine initial transition emit).Cfg := + configuration.bind (machine initial transition emit).step + +theorem two_steps_cons (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (state : Q) (symbol : Bool) + (input accumulator : List Bool) (register : Option Bool) : + (next initial transition emit)^[2] + (some (running initial transition emit state (symbol :: input) accumulator register)) = + some (running initial transition emit (transition state symbol) input + ((emit state symbol).reverse ++ accumulator) (some symbol)) := by + change (machine initial transition emit).step + (running initial transition emit state (symbol :: input) accumulator register) >>= + (machine initial transition emit).step = _ + rw [step_cons] + exact step_emit initial transition emit state symbol input accumulator (state, some symbol) + +theorem transduce_steps (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (state : Q) (input accumulator : List Bool) + (register : Option Bool) : + (next initial transition emit)^[2 * input.length + 1] + (some (running initial transition emit state input accumulator register)) = + some (halted initial transition emit ((output transition emit state input).reverse ++ accumulator)) := by + induction input generalizing state accumulator register with + | nil => + simpa only [List.length_nil, Nat.mul_zero, Nat.zero_add, Function.iterate_one, next, + Option.bind_some, output, List.reverse_nil, List.nil_append] + using step_empty initial transition emit state accumulator register + | cons symbol input ih => + rw [List.length_cons] + rw [show 2 * (input.length + 1) + 1 = (2 * input.length + 1) + 2 by omega] + rw [Function.iterate_add_apply, two_steps_cons, ih] + simp only [output, List.reverse_append, List.append_assoc] + +theorem initList_eq (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (input : List Bool) : + initList (machine initial transition emit) input = + running initial transition emit initial input [] none := by + unfold initList running + congr 1 + funext side + cases side <;> rfl + +theorem haltList_eq (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (accumulator : List Bool) : + haltList (machine initial transition emit) accumulator = + halted initial transition emit accumulator := by + unfold haltList halted + congr 1 + +theorem transduce_init_steps (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (input : List Bool) : + (next initial transition emit)^[2 * input.length + 1] + (some (initList (machine initial transition emit) input)) = + some (haltList (machine initial transition emit) (output transition emit initial input).reverse) := by + rw [initList_eq, haltList_eq] + simpa only [List.append_nil] using transduce_steps initial transition emit initial input [] none + +def outputsInTime (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (input : List Bool) : + TM2OutputsInTime (machine initial transition emit) input + (some (output transition emit initial input).reverse) (2 * input.length + 1) where + steps := 2 * input.length + 1 + evals_in_steps := transduce_init_steps initial transition emit input + steps_le_m := Nat.le_refl _ + +@[simp] theorem outputsInTime_steps (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (input : List Bool) : + (outputsInTime initial transition emit input).steps = 2 * input.length + 1 := rfl + +noncomputable def reversedComputableInPolyTime (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) : + TM2ComputableInPolyTime (id : List Bool → List Bool) id + (fun input => (output transition emit initial input).reverse) where + tm := machine initial transition emit + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := 2 * Polynomial.X + 1 + outputsFun input := by + change TM2OutputsInTime (machine initial transition emit) (input.map id) + (some ((output transition emit initial input).reverse.map id)) + ((2 * Polynomial.X + 1 : Polynomial Nat).eval input.length) + have hi := @List.map_id ((machine initial transition emit).Γ + (machine initial transition emit).k₀) input + have ho := @List.map_id ((machine initial transition emit).Γ + (machine initial transition emit).k₁) (output transition emit initial input).reverse + rw [hi, ho] + simpa only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_X, + Polynomial.eval_ofNat, Polynomial.eval_one] using outputsInTime initial transition emit input + +noncomputable def computableInPolyTime (initial : Q) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) : + TM2ComputableInPolyTime (id : List Bool → List Bool) id + (output transition emit initial) := by + simpa only [List.reverse_reverse] using + MachineSequential.composeBits (reversedComputableInPolyTime initial transition emit) + MachineReverse.computableInPolyTime + +end IndependentSetsGames.Reduction.MachineTransducer + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransducerCopy.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransducerCopy.lean new file mode 100644 index 0000000000000000000000000000000000000000..27e972bb4d5deb8b8e210a74f514eaebed78d8aa --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransducerCopy.lean @@ -0,0 +1,291 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.MachineTransducer + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineTransducerCopy + +open Turing +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +variable {K Λ σ Q : Type} [DecidableEq K] + +abbrev Alphabet (K : Type) (_ : K) := Bool +abbrev State (σ Q : Type) := (σ × Q) × Option Bool + +def scanLoop (source scratch : K) (initial : Q) + (emitterLabel : Q → Bool → Λ) (restoreLabel : Λ) : + TM2.Stmt (Alphabet K) Λ (State σ Q) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.isSome) + (.push scratch (fun state => state.2.getD false) + (.goto fun state => emitterLabel state.1.2 (state.2.getD false))) + (.load (fun state => ((state.1.1, initial), none)) (.goto fun _ => restoreLabel))) + +def emitter (destination : K) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (scanLabel : Λ) (control : Q) (symbol : Bool) : + TM2.Stmt (Alphabet K) Λ (State σ Q) := + .load (fun state => ((state.1.1, transition control symbol), state.2)) + (pushWord destination (emit control symbol) (.goto fun _ => scanLabel)) + +abbrev tapes (source scratch destination : K) (base : K → List Bool) + (input scratchWord outputWord : List Bool) : K → List Bool := + MachineCopy.forkTapes source scratch destination base input scratchWord outputWord + +theorem update_source (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) (base : K → List Bool) + (input scratchWord outputWord replacement : List Bool) : + Function.update (tapes source scratch destination base input scratchWord outputWord) + source replacement = tapes source scratch destination base replacement scratchWord outputWord := by + funext k + by_cases hs : k = source + · subst k; simp [tapes, MachineCopy.forkTapes, sourceScratch, sourceDestination] + · by_cases ht : k = scratch + · subst k; simp [tapes, MachineCopy.forkTapes, Ne.symm sourceScratch, scratchDestination] + · by_cases hd : k = destination + · subst k; simp [tapes, MachineCopy.forkTapes, Ne.symm sourceDestination] + · simp [tapes, MachineCopy.forkTapes, hs, ht, hd] + +theorem update_scratch (source scratch destination : K) + (scratchDestination : scratch ≠ destination) (base : K → List Bool) + (input scratchWord outputWord replacement : List Bool) : + Function.update (tapes source scratch destination base input scratchWord outputWord) + scratch replacement = tapes source scratch destination base input replacement outputWord := by + funext k + by_cases ht : k = scratch + · subst k; simp [tapes, MachineCopy.forkTapes, scratchDestination] + · by_cases hd : k = destination + · subst k; simp [tapes, MachineCopy.forkTapes, Ne.symm scratchDestination] + · simp [tapes, MachineCopy.forkTapes, ht, hd] + +theorem update_output (source scratch destination : K) (base : K → List Bool) + (input scratchWord outputWord replacement : List Bool) : + Function.update (tapes source scratch destination base input scratchWord outputWord) + destination replacement = tapes source scratch destination base input scratchWord replacement := by + simp [tapes, MachineCopy.forkTapes] + +theorem scanStep_empty (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) + (initial : Q) (scanLabel restoreLabel : Λ) (emitterLabel : Q → Bool → Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ Q)) + (atScan : program scanLabel = scanLoop source scratch initial emitterLabel restoreLabel) + (base : K → List Bool) (scratchWord outputWord : List Bool) + (ambient : σ) (control : Q) (register : Option Bool) : + TM2.step program ⟨some scanLabel, ((ambient, control), register), + tapes source scratch destination base [] scratchWord outputWord⟩ = + some ⟨some restoreLabel, ((ambient, initial), none), + tapes source scratch destination base [] scratchWord outputWord⟩ := by + change some (TM2.stepAux (program scanLabel) ((ambient, control), register) + (tapes source scratch destination base [] scratchWord outputWord)) = _ + rw [atScan] + simp [scanLoop, TM2.stepAux, sourceScratch, sourceDestination, scratchDestination, + update_source] + +theorem scanStep_cons (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) + (initial : Q) (scanLabel restoreLabel : Λ) (emitterLabel : Q → Bool → Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ Q)) + (atScan : program scanLabel = scanLoop source scratch initial emitterLabel restoreLabel) + (base : K → List Bool) (symbol : Bool) (input scratchWord outputWord : List Bool) + (ambient : σ) (control : Q) (register : Option Bool) : + TM2.step program ⟨some scanLabel, ((ambient, control), register), + tapes source scratch destination base (symbol :: input) scratchWord outputWord⟩ = + some ⟨some (emitterLabel control symbol), ((ambient, control), some symbol), + tapes source scratch destination base input (symbol :: scratchWord) outputWord⟩ := by + change some (TM2.stepAux (program scanLabel) ((ambient, control), register) + (tapes source scratch destination base (symbol :: input) scratchWord outputWord)) = _ + rw [atScan] + simp [scanLoop, TM2.stepAux, sourceScratch, sourceDestination, scratchDestination, + update_source, update_scratch] + +theorem emitterStep (source scratch destination : K) + (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (scanLabel : Λ) (emitterLabel : Q → Bool → Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ Q)) + (atEmitter : ∀ control symbol, program (emitterLabel control symbol) = + emitter destination transition emit scanLabel control symbol) + (base : K → List Bool) (input scratchWord outputWord : List Bool) + (ambient : σ) (control : Q) (symbol : Bool) : + TM2.step program ⟨some (emitterLabel control symbol), ((ambient, control), some symbol), + tapes source scratch destination base input scratchWord outputWord⟩ = + some ⟨some scanLabel, ((ambient, transition control symbol), some symbol), + tapes source scratch destination base input scratchWord + ((emit control symbol).reverse ++ outputWord)⟩ := by + change some (TM2.stepAux (program (emitterLabel control symbol)) ((ambient, control), some symbol) + (tapes source scratch destination base input scratchWord outputWord)) = _ + rw [atEmitter] + simp only [emitter, TM2.stepAux] + rw [stepAux_pushWord] + simp only [TM2.stepAux, MachineCopy.forkTapes_right] + rw [update_output] + +theorem twoSteps_cons (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) + (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (scanLabel restoreLabel : Λ) (emitterLabel : Q → Bool → Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ Q)) + (atScan : program scanLabel = scanLoop source scratch initial emitterLabel restoreLabel) + (atEmitter : ∀ control symbol, program (emitterLabel control symbol) = + emitter destination transition emit scanLabel control symbol) + (base : K → List Bool) (symbol : Bool) (input scratchWord outputWord : List Bool) + (ambient : σ) (control : Q) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[2] + (some ⟨some scanLabel, ((ambient, control), register), + tapes source scratch destination base (symbol :: input) scratchWord outputWord⟩) = + some ⟨some scanLabel, ((ambient, transition control symbol), some symbol), + tapes source scratch destination base input (symbol :: scratchWord) + ((emit control symbol).reverse ++ outputWord)⟩ := by + change (TM2.step program ⟨some scanLabel, ((ambient, control), register), + tapes source scratch destination base (symbol :: input) scratchWord outputWord⟩).bind + (TM2.step program) = _ + rw [scanStep_cons source scratch destination sourceScratch sourceDestination scratchDestination + initial scanLabel restoreLabel emitterLabel program atScan base symbol input scratchWord + outputWord ambient control register] + exact emitterStep source scratch destination transition emit scanLabel emitterLabel program + atEmitter base input (symbol :: scratchWord) outputWord ambient control symbol + +theorem scanTrace (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) + (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (scanLabel restoreLabel : Λ) (emitterLabel : Q → Bool → Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ Q)) + (atScan : program scanLabel = scanLoop source scratch initial emitterLabel restoreLabel) + (atEmitter : ∀ control symbol, program (emitterLabel control symbol) = + emitter destination transition emit scanLabel control symbol) + (base : K → List Bool) (input scratchWord outputWord : List Bool) + (ambient : σ) (control : Q) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[2 * input.length + 1] + (some ⟨some scanLabel, ((ambient, control), register), + tapes source scratch destination base input scratchWord outputWord⟩) = + some ⟨some restoreLabel, ((ambient, initial), none), + tapes source scratch destination base [] (input.reverse ++ scratchWord) + ((Reduction.MachineTransducer.output transition emit control input).reverse ++ outputWord)⟩ := by + induction input generalizing control scratchWord outputWord register with + | nil => + simpa only [List.length_nil, Nat.mul_zero, Nat.zero_add, Function.iterate_one, + MachineComposition.advance_some, Reduction.MachineTransducer.output, List.reverse_nil, + List.nil_append] using + scanStep_empty source scratch destination sourceScratch sourceDestination scratchDestination + initial scanLabel restoreLabel emitterLabel program atScan base scratchWord outputWord + ambient control register + | cons symbol input ih => + rw [List.length_cons, show 2 * (input.length + 1) + 1 = (2 * input.length + 1) + 2 by omega, + Function.iterate_add_apply] + rw [twoSteps_cons source scratch destination sourceScratch sourceDestination scratchDestination + initial transition emit scanLabel restoreLabel emitterLabel program atScan atEmitter base + symbol input scratchWord outputWord ambient control register, ih] + simp only [Reduction.MachineTransducer.output, List.reverse_append, List.reverse_cons, + List.append_assoc, List.singleton_append] + +theorem restoreTapes (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) + (base : K → List Bool) (scratchEmpty : base scratch = []) (outputWord : List Bool) : + Reduction.MachineTransfer.tapesAt scratch source + (tapes source scratch destination base [] (base source).reverse outputWord) + [] (base source) = Function.update base destination outputWord := by + funext k + by_cases hs : k = source + · subst k; simp [Reduction.MachineTransfer.tapesAt, sourceDestination] + · by_cases ht : k = scratch + · subst k + simp [Reduction.MachineTransfer.tapesAt, Ne.symm sourceScratch, scratchDestination, scratchEmpty] + · by_cases hd : k = destination + · subst k + simp [Reduction.MachineTransfer.tapesAt, tapes, MachineCopy.forkTapes, + Ne.symm sourceDestination, Ne.symm scratchDestination] + · simp [Reduction.MachineTransfer.tapesAt, tapes, MachineCopy.forkTapes, hs, ht, hd] + +theorem transduceCopyTrace (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) + (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (scanLabel restoreLabel : Λ) (emitterLabel : Q → Bool → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ Q)) + (atScan : program scanLabel = scanLoop source scratch initial emitterLabel restoreLabel) + (atEmitter : ∀ control symbol, program (emitterLabel control symbol) = + emitter destination transition emit scanLabel control symbol) + (atRestore : program restoreLabel = + Reduction.MachineTransfer.loopAt scratch source id false restoreLabel exit) + (base : K → List Bool) (scratchEmpty : base scratch = []) + (ambient : σ) (control : Q) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[3 * (base source).length + 2] + (some ⟨some scanLabel, ((ambient, control), register), base⟩) = + some ⟨exit, ((ambient, initial), none), + Function.update base destination + ((Reduction.MachineTransducer.output transition emit control (base source)).reverse ++ + base destination)⟩ := by + have scan := scanTrace source scratch destination sourceScratch sourceDestination scratchDestination + initial transition emit scanLabel restoreLabel emitterLabel program atScan atEmitter base + (base source) (base scratch) (base destination) ambient control register + have tapesSelf : tapes source scratch destination base (base source) (base scratch) + (base destination) = base := MachineCopy.forkTapes_self source scratch destination base + rw [tapesSelf] at scan + simp only [scratchEmpty, List.append_nil] at scan + let outputWord := + (Reduction.MachineTransducer.output transition emit control (base source)).reverse ++ base destination + let scanned := tapes source scratch destination base [] (base source).reverse outputWord + have restore := Reduction.MachineTransfer.transferAt_fromTapes scratch source (Ne.symm sourceScratch) + id false restoreLabel exit program atRestore scanned (ambient, initial) none + change (MachineComposition.advance (TM2.step program))^[(scanned scratch).length + 1] + (some ⟨some restoreLabel, ((ambient, initial), none), scanned⟩) = _ at restore + have scratchWord : scanned scratch = (base source).reverse := by + simp [scanned, scratchDestination] + have sourceWord : scanned source = [] := by + simp [scanned, sourceScratch, sourceDestination] + rw [scratchWord, sourceWord] at restore + simp only [List.map_id, List.reverse_reverse, List.append_nil, List.length_reverse] at restore + rw [restoreTapes source scratch destination sourceScratch sourceDestination scratchDestination + base scratchEmpty outputWord] at restore + rw [show 3 * (base source).length + 2 = + ((base source).length + 1) + (2 * (base source).length + 1) by omega, + Function.iterate_add_apply, scan] + exact restore + +def transduceCopyInTime (source scratch destination : K) + (sourceScratch : source ≠ scratch) (sourceDestination : source ≠ destination) + (scratchDestination : scratch ≠ destination) + (initial : Q) (transition : Q → Bool → Q) (emit : Q → Bool → List Bool) + (scanLabel restoreLabel : Λ) (emitterLabel : Q → Bool → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ Q)) + (atScan : program scanLabel = scanLoop source scratch initial emitterLabel restoreLabel) + (atEmitter : ∀ control symbol, program (emitterLabel control symbol) = + emitter destination transition emit scanLabel control symbol) + (atRestore : program restoreLabel = + Reduction.MachineTransfer.loopAt scratch source id false restoreLabel exit) + (base : K → List Bool) (scratchEmpty : base scratch = []) + (ambient : σ) (control : Q) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some scanLabel, ((ambient, control), register), base⟩ + (some ⟨exit, ((ambient, initial), none), Function.update base destination + ((Reduction.MachineTransducer.output transition emit control (base source)).reverse ++ + base destination)⟩) + (3 * (base source).length + 2) where + steps := 3 * (base source).length + 2 + evals_in_steps := transduceCopyTrace source scratch destination sourceScratch sourceDestination + scratchDestination initial transition emit scanLabel restoreLabel emitterLabel exit program + atScan atEmitter atRestore base scratchEmpty ambient control register + steps_le_m := Nat.le_refl _ + +omit [DecidableEq K] in +theorem scanLoop_pushBound (source scratch : K) (initial : Q) + (emitterLabel : Q → Bool → Λ) (restoreLabel : Λ) : + Runtime.statementPushBound (scanLoop (σ := σ) source scratch initial emitterLabel restoreLabel) = 1 := by + simp [scanLoop, Runtime.statementPushBound] + +omit [DecidableEq K] in +theorem emitter_pushBound (destination : K) (transition : Q → Bool → Q) + (emit : Q → Bool → List Bool) (scanLabel : Λ) (control : Q) (symbol : Bool) : + Runtime.statementPushBound (emitter (σ := σ) destination transition emit scanLabel control symbol) = + (emit control symbol).length := by + simp [emitter, Runtime.statementPushBound, Reduction.MachineSubstitution.statementPushBound_pushWord] + +end IndependentSetsGames.Foundations.Complexity.MachineTransducerCopy + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransfer.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..07c4f94973b2411bfa8ce3c47c847770eddbc230 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineTransfer.lean @@ -0,0 +1,146 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.PatternInvariant + +namespace OAI + +namespace IndependentSetsGames.Reduction.MachineTransfer + +open Turing + +abbrev alphabet (α β : Type) : Bool → Type + | false => α + | true => β + +variable {α β : Type} [Fintype α] [Fintype β] + +def loop (f : α → β) (fallback : β) : + TM2.Stmt (alphabet α β) Unit (Option β) := + .pop false (fun _ head => head.map f) + (.branch Option.isSome + (.push true (fun state => state.getD fallback) (.goto fun _ => ())) + .halt) + +def machine (f : α → β) (fallback : β) : FinTM2 where + K := Bool + k₀ := false + k₁ := true + Γ := alphabet α β + Λ := Unit + main := () + σ := Option β + initialState := none + Γk₀Fin := inferInstanceAs (Fintype α) + m _ := loop f fallback + +def tapeStacks (input : List α) (output : List β) : + (side : Bool) → List (alphabet α β side) + | false => input + | true => output + +def running (f : α → β) (fallback : β) (input : List α) (output : List β) + (state : Option β) : (machine f fallback).Cfg := + ⟨some (), state, tapeStacks input output⟩ + +def halted (f : α → β) (fallback : β) (output : List β) : (machine f fallback).Cfg := + ⟨none, none, tapeStacks (α := α) [] output⟩ + +omit [Fintype α] [Fintype β] in +theorem update_input (input replacement : List α) (output : List β) : + Function.update (tapeStacks input output) false replacement = tapeStacks replacement output := by + funext side + cases side <;> rfl + +omit [Fintype α] [Fintype β] in +theorem update_output (input : List α) (output replacement : List β) : + Function.update (tapeStacks input output) true replacement = tapeStacks input replacement := by + funext side + cases side <;> rfl + +theorem step_empty (f : α → β) (fallback : β) (output : List β) (state : Option β) : + (machine f fallback).step (running f fallback [] output state) = + some (halted f fallback output) := by + change some (TM2.stepAux (loop f fallback) state (tapeStacks (α := α) [] output)) = _ + simp [loop, TM2.stepAux, tapeStacks, halted, Function.update] + rw [update_input] + rfl + +theorem step_cons (f : α → β) (fallback : β) (head : α) (input : List α) + (output : List β) (state : Option β) : + (machine f fallback).step (running f fallback (head :: input) output state) = + some (running f fallback input (f head :: output) (some (f head))) := by + change some (TM2.stepAux (loop f fallback) state (tapeStacks (head :: input) output)) = _ + simp [loop, TM2.stepAux, tapeStacks, running, Function.update] + rw [update_input, update_output] + rfl + +def next (f : α → β) (fallback : β) (configuration : Option (machine f fallback).Cfg) : + Option (machine f fallback).Cfg := configuration.bind (machine f fallback).step + +theorem transfer_steps (f : α → β) (fallback : β) (input : List α) (output : List β) + (state : Option β) : + (next f fallback)^[input.length + 1] (some (running f fallback input output state)) = + some (halted f fallback (input.reverse.map f ++ output)) := by + induction input generalizing output state with + | nil => + simpa only [List.length_nil, Nat.zero_add, Function.iterate_one, next, + Option.bind_some, List.reverse_nil, List.map_nil, List.nil_append] + using step_empty f fallback output state + | cons head input ih => + rw [List.length_cons, Function.iterate_succ_apply] + change (next f fallback)^[input.length + 1] + ((machine f fallback).step (running f fallback (head :: input) output state)) = _ + rw [step_cons, ih] + simp only [List.reverse_cons, List.map_append, List.map_singleton, + List.append_assoc, List.singleton_append] + +theorem initList_eq (f : α → β) (fallback : β) (input : List α) : + initList (machine f fallback) input = running f fallback input [] none := by + unfold initList running + congr 1 + funext side + cases side <;> rfl + +theorem haltList_eq (f : α → β) (fallback : β) (output : List β) : + haltList (machine f fallback) output = halted f fallback output := by + unfold haltList halted + congr 1 + funext side + cases side <;> rfl + +theorem transfer_init_steps (f : α → β) (fallback : β) (input : List α) : + (next f fallback)^[input.length + 1] (some (initList (machine f fallback) input)) = + some (haltList (machine f fallback) (input.reverse.map f)) := by + erw [initList_eq (α := α) (β := β) f fallback input, + haltList_eq (α := α) (β := β) f fallback (input.reverse.map f)] + simpa only [List.append_nil] using transfer_steps f fallback input [] none + +def outputsInTime (f : α → β) (fallback : β) (input : List α) : + TM2OutputsInTime (machine f fallback) input (some (input.reverse.map f)) + (input.length + 1) where + steps := input.length + 1 + evals_in_steps := transfer_init_steps f fallback input + steps_le_m := Nat.le_refl _ + +@[simp] theorem outputsInTime_steps (f : α → β) (fallback : β) (input : List α) : + (outputsInTime f fallback input).steps = input.length + 1 := rfl + +noncomputable def computableInPolyTime (f : α → β) (fallback : β) : + TM2ComputableInPolyTime (id : List α → List α) (id : List β → List β) + (fun input => input.reverse.map f) where + tm := machine f fallback + inputAlphabet := Equiv.refl α + outputAlphabet := Equiv.refl β + time := Polynomial.X + 1 + outputsFun input := by + change TM2OutputsInTime (machine f fallback) (input.map id) + (some ((input.reverse.map f).map id)) + ((Polynomial.X + 1 : Polynomial Nat).eval input.length) + have hi := @List.map_id ((machine f fallback).Γ (machine f fallback).k₀) input + have ho := @List.map_id ((machine f fallback).Γ (machine f fallback).k₁) (input.reverse.map f) + erw [hi, ho] + simpa only [Polynomial.eval_add, Polynomial.eval_X, Polynomial.eval_one] + using outputsInTime f fallback input + +end IndependentSetsGames.Reduction.MachineTransfer + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryAdd.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryAdd.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a1a9aa91020b0896a615230a18b283d79d11bfd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryAdd.lean @@ -0,0 +1,227 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition +import OAI.Combinatorics.IndependentSets.Machines.MachineTransfer +import OAI.Combinatorics.IndependentSets.Machines.Placement + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineUnaryAddAt + +open Turing +open Reduction.MachineTransfer + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def finish (destination : K) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .load (fun state => (state.1, none)) (exitAt destination exit) + +def loop (source destination : K) (loopLabel : Λ) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.push destination (fun _ => true) (.goto fun _ => loopLabel)) + (.branch (fun state => state.2.isSome) + (.push source (fun _ => false) (finish destination exit)) + (finish destination exit))) + +omit [DecidableEq K] in +theorem loopPushBound (source destination : K) (loopLabel : Λ) (exit : Option Λ) : + Runtime.statementPushBound (loop (σ := σ) source destination loopLabel exit) = 1 := by + cases exit <;> rfl + +def unaryTapes (source destination : K) (base : K → List Bool) (a b : Nat) + (sourceSuffix destinationSuffix : List Bool) : K → List Bool := + tapesAt source destination base (encodeWord a ++ sourceSuffix) + (encodeWord b ++ destinationSuffix) + +@[simp] theorem unaryTapes_source (source destination : K) (distinct : source ≠ destination) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) : + unaryTapes source destination base a b sourceSuffix destinationSuffix source = + encodeWord a ++ sourceSuffix := by + simp [unaryTapes, distinct] + +@[simp] theorem unaryTapes_destination (source destination : K) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) : + unaryTapes source destination base a b sourceSuffix destinationSuffix destination = + encodeWord b ++ destinationSuffix := by + simp [unaryTapes] + +theorem unaryTapes_other (source destination other : K) + (notSource : other ≠ source) (notDestination : other ≠ destination) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) : + unaryTapes source destination base a b sourceSuffix destinationSuffix other = + base other := by + simp [unaryTapes, tapesAt, notSource, notDestination] + +theorem update_source (source destination : K) (distinct : source ≠ destination) + (base : K → List Bool) (input output replacement : List Bool) : + Function.update (tapesAt source destination base input output) source replacement = + tapesAt source destination base replacement output := by + funext k + by_cases hs : k = source + · subst k + simp [tapesAt, distinct] + · by_cases hd : k = destination + · subst k + simp [tapesAt, Ne.symm distinct] + · simp [tapesAt, hs, hd] + +private theorem update_destination (source destination : K) + (base : K → List Bool) (input output replacement : List Bool) : + Function.update (tapesAt source destination base input output) destination replacement = + tapesAt source destination base input replacement := by + funext k + by_cases hd : k = destination + · subst k + simp [tapesAt] + · simp [tapesAt, hd] + +theorem stepAux_true (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) (base : K → List Bool) + (input output : List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (loop source destination loopLabel exit) (ambient, register) + (tapesAt source destination base (true :: input) output) = + ⟨some loopLabel, (ambient, some true), + tapesAt source destination base input (true :: output)⟩ := by + simp [loop, TM2.stepAux, distinct, update_source, update_destination] + +theorem stepAux_false (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) (base : K → List Bool) + (input output : List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (loop source destination loopLabel exit) (ambient, register) + (tapesAt source destination base (false :: input) output) = + ⟨exit, (ambient, none), tapesAt source destination base (false :: input) output⟩ := by + cases exit <;> simp [loop, finish, exitAt, TM2.stepAux, distinct, update_source] + +theorem stepAux_succ (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) (base : K → List Bool) (a b : Nat) + (sourceSuffix destinationSuffix : List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (loop source destination loopLabel exit) (ambient, register) + (unaryTapes source destination base (a + 1) b sourceSuffix destinationSuffix) = + ⟨some loopLabel, (ambient, some true), + unaryTapes source destination base a (b + 1) sourceSuffix destinationSuffix⟩ := by + simpa only [unaryTapes, encodeWord, List.replicate_succ, List.cons_append] using + stepAux_true source destination distinct loopLabel exit base + (encodeWord a ++ sourceSuffix) (encodeWord b ++ destinationSuffix) ambient register + +theorem stepAux_zero (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) (base : K → List Bool) (b : Nat) + (sourceSuffix destinationSuffix : List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (loop source destination loopLabel exit) (ambient, register) + (unaryTapes source destination base 0 b sourceSuffix destinationSuffix) = + ⟨exit, (ambient, none), + unaryTapes source destination base 0 b sourceSuffix destinationSuffix⟩ := by + simpa only [unaryTapes, encodeWord, List.replicate_zero, List.nil_append, + List.singleton_append] using + stepAux_false source destination distinct loopLabel exit base sourceSuffix + (encodeWord b ++ destinationSuffix) ambient register + +theorem step_succ (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = loop source destination loopLabel exit) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step program ⟨some loopLabel, (ambient, register), + unaryTapes source destination base (a + 1) b sourceSuffix destinationSuffix⟩ = + some ⟨some loopLabel, (ambient, some true), + unaryTapes source destination base a (b + 1) sourceSuffix destinationSuffix⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (unaryTapes source destination base (a + 1) b sourceSuffix destinationSuffix)) = _ + rw [atLoop, stepAux_succ source destination distinct] + +theorem step_zero (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = loop source destination loopLabel exit) + (base : K → List Bool) (b : Nat) (sourceSuffix destinationSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step program ⟨some loopLabel, (ambient, register), + unaryTapes source destination base 0 b sourceSuffix destinationSuffix⟩ = + some ⟨exit, (ambient, none), + unaryTapes source destination base 0 b sourceSuffix destinationSuffix⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (unaryTapes source destination base 0 b sourceSuffix destinationSuffix)) = _ + rw [atLoop, stepAux_zero source destination distinct] + +theorem addTrace (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = loop source destination loopLabel exit) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[a + 1] + (some ⟨some loopLabel, (ambient, register), + unaryTapes source destination base a b sourceSuffix destinationSuffix⟩) = + some ⟨exit, (ambient, none), + unaryTapes source destination base 0 (a + b) sourceSuffix destinationSuffix⟩ := by + induction a generalizing b register with + | zero => + simpa only [Nat.zero_add, Function.iterate_one, MachineComposition.advance_some] using + step_zero source destination distinct loopLabel exit program atLoop + base b sourceSuffix destinationSuffix ambient register + | succ a ih => + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step program))^[a + 1] + (TM2.step program ⟨some loopLabel, (ambient, register), + unaryTapes source destination base (a + 1) b sourceSuffix destinationSuffix⟩) = _ + rw [step_succ source destination distinct loopLabel exit program atLoop] + simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using ih (b + 1) (some true) + +theorem addFromTapes (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = loop source destination loopLabel exit) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) + (sourceInput : base source = encodeWord a ++ sourceSuffix) + (destinationInput : base destination = encodeWord b ++ destinationSuffix) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[a + 1] + (some ⟨some loopLabel, (ambient, register), base⟩) = + some ⟨exit, (ambient, none), + unaryTapes source destination base 0 (a + b) sourceSuffix destinationSuffix⟩ := by + have hbase : unaryTapes source destination base a b sourceSuffix destinationSuffix = + base := by + simp only [unaryTapes, ← sourceInput, ← destinationInput, tapesAt_self] + have h := addTrace source destination distinct loopLabel exit program atLoop + base a b sourceSuffix destinationSuffix ambient register + rw [hbase] at h + exact h + +def addInTime (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = loop source destination loopLabel exit) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) + (sourceInput : base source = encodeWord a ++ sourceSuffix) + (destinationInput : base destination = encodeWord b ++ destinationSuffix) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some loopLabel, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), + unaryTapes source destination base 0 (a + b) sourceSuffix destinationSuffix⟩) + (a + 1) where + steps := a + 1 + evals_in_steps := addFromTapes source destination distinct loopLabel exit program atLoop + base a b sourceSuffix destinationSuffix sourceInput destinationInput ambient register + steps_le_m := Nat.le_refl _ + +@[simp] theorem addInTime_steps (source destination : K) (distinct : source ≠ destination) + (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLoop : program loopLabel = loop source destination loopLabel exit) + (base : K → List Bool) (a b : Nat) (sourceSuffix destinationSuffix : List Bool) + (sourceInput : base source = encodeWord a ++ sourceSuffix) + (destinationInput : base destination = encodeWord b ++ destinationSuffix) + (ambient : σ) (register : Option Bool) : + (addInTime source destination distinct loopLabel exit program atLoop base a b + sourceSuffix destinationSuffix sourceInput destinationInput ambient register).steps = + a + 1 := rfl + +end IndependentSetsGames.Foundations.Complexity.MachineUnaryAddAt + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryAffine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..b26e334d2aa93b185cae73eebcac6eb748709b6b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryAffine.lean @@ -0,0 +1,293 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.PushWord + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineUnaryAffineAt + +open Turing +open MachineComposition +open Reduction.MachineSubstitution + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def finish (restoreLabel : Λ) : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .load (fun s => (s.1,none)) (.goto (fun _ => restoreLabel)) + +def scan (source scratch destination : K) (coefficient : Nat) (scanLabel restoreLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .pop source (fun s head => (s.1,head)) + (.branch (fun s => s.2.getD false) + (.push scratch (fun _ => true) + (pushWord destination (List.replicate coefficient true) (.goto (fun _ => scanLabel)))) + (.branch (fun s => s.2.isSome) + (.push source (fun _ => false) (finish restoreLabel)) + (finish restoreLabel))) + +def seed (destination : K) (offset : Nat) (scanLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + pushWord destination (encodeWord offset).reverse (.goto (fun _ => scanLabel)) + +def tapes (source scratch destination : K) (base : K → List Bool) + (input saved output : List Bool) : K → List Bool := + MachineCopy.forkTapes source scratch destination base input saved output + +@[simp] theorem tapes_source (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) + (base : K → List Bool) (input saved output : List Bool) : + tapes source scratch destination base input saved output source = input := + MachineCopy.forkTapes_source source scratch destination hs hd base input saved output + +@[simp] theorem tapes_scratch (source scratch destination : K) (hsd : scratch ≠ destination) + (base : K → List Bool) (input saved output : List Bool) : + tapes source scratch destination base input saved output scratch = saved := + MachineCopy.forkTapes_left source scratch destination hsd base input saved output + +@[simp] theorem tapes_destination (source scratch destination : K) + (base : K → List Bool) (input saved output : List Bool) : + tapes source scratch destination base input saved output destination = output := + MachineCopy.forkTapes_right source scratch destination base input saved output + +theorem update_source (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (base : K → List Bool) (input saved output replacement : List Bool) : + Function.update (tapes source scratch destination base input saved output) source replacement = + tapes source scratch destination base replacement saved output := by + funext k + by_cases h₀ : k = source + · subst k; simp [tapes, MachineCopy.forkTapes, hs, hd] + · by_cases h₁ : k = scratch + · subst k; simp [tapes, MachineCopy.forkTapes, h₀, hsd] + · by_cases h₂ : k = destination + · subst k; simp [tapes, MachineCopy.forkTapes, h₀] + · simp [tapes, MachineCopy.forkTapes, h₀, h₁, h₂] + +theorem update_scratch (source scratch destination : K) (hsd : scratch ≠ destination) + (base : K → List Bool) (input saved output replacement : List Bool) : + Function.update (tapes source scratch destination base input saved output) scratch replacement = + tapes source scratch destination base input replacement output := by + funext k + by_cases h : k = scratch + · subst k; simp [tapes, MachineCopy.forkTapes, hsd] + · by_cases h' : k = destination + · subst k; simp [tapes, MachineCopy.forkTapes, h] + · simp [tapes, MachineCopy.forkTapes, h, h'] + +theorem update_destination (source scratch destination : K) + (base : K → List Bool) (input saved output replacement : List Bool) : + Function.update (tapes source scratch destination base input saved output) destination replacement = + tapes source scratch destination base input saved replacement := by + simp [tapes, MachineCopy.forkTapes] + +theorem prepend_replicate_word (c b : Nat) (suffix : List Bool) : + List.replicate c true ++ (encodeWord b ++ suffix) = + encodeWord (c + b) ++ suffix := by + simp only [encodeWord, List.replicate_add, List.append_assoc] + +theorem scan_step_succ (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (coefficient : Nat) (scanLabel restoreLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program scanLabel = scan source scratch destination coefficient scanLabel restoreLabel) + (base : K → List Bool) (a b : Nat) (suffix saved output : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step program ⟨some scanLabel, (ambient,register), tapes source scratch destination base + (encodeWord (a + 1) ++ suffix) saved (encodeWord b ++ output)⟩ = + some ⟨some scanLabel, (ambient,some true), tapes source scratch destination base + (encodeWord a ++ suffix) (true :: saved) (encodeWord (coefficient + b) ++ output)⟩ := by + change some (TM2.stepAux (program scanLabel) _ _) = _ + rw [atScan] + rw [show encodeWord (a + 1) ++ suffix = true :: (encodeWord a ++ suffix) by + simp [encodeWord, List.replicate_succ]] + simp [scan, TM2.stepAux, tapes_source _ _ _ hs hd, + update_source source scratch destination hs hd hsd, tapes_scratch _ _ _ hsd, + update_scratch _ _ _ hsd, stepAux_pushWord, tapes_destination, + prepend_replicate_word, update_destination] + +theorem scan_step_zero (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (coefficient : Nat) (scanLabel restoreLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program scanLabel = scan source scratch destination coefficient scanLabel restoreLabel) + (base : K → List Bool) (b : Nat) (suffix saved output : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step program ⟨some scanLabel, (ambient,register), tapes source scratch destination base + (encodeWord 0 ++ suffix) saved (encodeWord b ++ output)⟩ = + some ⟨some restoreLabel, (ambient,none), tapes source scratch destination base + (encodeWord 0 ++ suffix) saved (encodeWord b ++ output)⟩ := by + change some (TM2.stepAux (program scanLabel) _ _) = _ + rw [atScan] + rw [show encodeWord 0 ++ suffix = false :: suffix from rfl] + simp [scan, finish, TM2.stepAux, tapes_source _ _ _ hs hd, + update_source source scratch destination hs hd hsd] + +theorem scanTrace (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (coefficient : Nat) (scanLabel restoreLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program scanLabel = scan source scratch destination coefficient scanLabel restoreLabel) + (base : K → List Bool) (a b : Nat) (suffix saved output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[a + 1] + (some ⟨some scanLabel, (ambient,register), tapes source scratch destination base + (encodeWord a ++ suffix) saved (encodeWord b ++ output)⟩) = + some ⟨some restoreLabel, (ambient,none), tapes source scratch destination base + (encodeWord 0 ++ suffix) (List.replicate a true ++ saved) + (encodeWord (coefficient * a + b) ++ output)⟩ := by + induction a generalizing b saved register with + | zero => + simpa using scan_step_zero source scratch destination hs hd hsd coefficient scanLabel + restoreLabel program atScan base b suffix saved output ambient register + | succ a ih => + rw [Function.iterate_succ_apply] + simp only [advance_some] + rw [scan_step_succ source scratch destination hs hd hsd coefficient scanLabel restoreLabel + program atScan] + rw [ih] + have hval : coefficient * a + (coefficient + b) = coefficient * (a + 1) + b := by + rw [Nat.mul_succ]; omega + rw [hval] + have hsave : List.replicate a true ++ true :: saved = List.replicate (a + 1) true ++ saved := by + simp only [List.replicate_add, List.replicate_one, List.append_assoc, List.singleton_append] + rw [hsave] + +theorem restoreTapes (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (base : K → List Bool) (a value : Nat) (suffix output : List Bool) : + Reduction.MachineTransfer.tapesAt scratch source + (tapes source scratch destination base (encodeWord 0 ++ suffix) + (List.replicate a true) (encodeWord value ++ output)) + [] (encodeWord a ++ suffix) = + tapes source scratch destination base (encodeWord a ++ suffix) [] (encodeWord value ++ output) := by + funext k + by_cases h₀ : k = source + · subst k; simp [tapes, MachineCopy.forkTapes, Reduction.MachineTransfer.tapesAt, hs, hd] + · by_cases h₁ : k = scratch + · subst k + simp [tapes, MachineCopy.forkTapes, Reduction.MachineTransfer.tapesAt, Ne.symm hs, hsd] + · by_cases h₂ : k = destination + · subst k + simp [tapes, MachineCopy.forkTapes, Reduction.MachineTransfer.tapesAt, Ne.symm hd, Ne.symm hsd] + · simp [tapes, MachineCopy.forkTapes, Reduction.MachineTransfer.tapesAt, h₀, h₁, h₂] + +theorem affineTrace (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (coefficient : Nat) (scanLabel restoreLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program scanLabel = scan source scratch destination coefficient scanLabel restoreLabel) + (atRestore : program restoreLabel = Reduction.MachineTransfer.loopAt + scratch source id false restoreLabel exit) + (base : K → List Bool) (a b : Nat) (suffix output : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[2 * (a + 1)] + (some ⟨some scanLabel, (ambient,register), tapes source scratch destination base + (encodeWord a ++ suffix) [] (encodeWord b ++ output)⟩) = + some ⟨exit, (ambient,none), tapes source scratch destination base + (encodeWord a ++ suffix) [] (encodeWord (coefficient * a + b) ++ output)⟩ := by + have hscan := scanTrace source scratch destination hs hd hsd coefficient scanLabel restoreLabel + program atScan base a b suffix [] output ambient register + simp only [List.append_nil] at hscan + let mid := tapes source scratch destination base (encodeWord 0 ++ suffix) + (List.replicate a true) (encodeWord (coefficient * a + b) ++ output) + have hrestore := Reduction.MachineTransfer.transferAt_fromTapes scratch source (Ne.symm hs) + id false restoreLabel exit program atRestore mid ambient none + change (advance (TM2.step program))^[(mid scratch).length + 1] + (some ⟨some restoreLabel,(ambient,none),mid⟩) = _ at hrestore + have hsaved : mid scratch = List.replicate a true := by + simp [mid, tapes, hsd] + have hsource : mid source = encodeWord 0 ++ suffix := by + simp [mid, tapes, hs, hd] + rw [hsaved, hsource] at hrestore + simp only [List.length_replicate, List.reverse_replicate, List.map_id] at hrestore + have hword : List.replicate a true ++ (encodeWord 0 ++ suffix) = encodeWord a ++ suffix := by + simp [encodeWord, List.append_assoc] + rw [hword] at hrestore + simp only [mid, restoreTapes source scratch destination hs hd hsd] at hrestore + rw [show 2 * (a + 1) = (a + 1) + (a + 1) by omega, Function.iterate_add_apply, hscan] + exact hrestore + +def affineInTime (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (coefficient : Nat) (scanLabel restoreLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atScan : program scanLabel = scan source scratch destination coefficient scanLabel restoreLabel) + (atRestore : program restoreLabel = Reduction.MachineTransfer.loopAt + scratch source id false restoreLabel exit) + (base : K → List Bool) (a b : Nat) (suffix output : List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some scanLabel, (ambient,register), tapes source scratch destination base + (encodeWord a ++ suffix) [] (encodeWord b ++ output)⟩ + (some ⟨exit, (ambient,none), tapes source scratch destination base + (encodeWord a ++ suffix) [] (encodeWord (coefficient * a + b) ++ output)⟩) + (2 * (a + 1)) where + steps := 2 * (a + 1) + evals_in_steps := affineTrace source scratch destination hs hd hsd coefficient scanLabel + restoreLabel exit program atScan atRestore base a b suffix output ambient register + steps_le_m := Nat.le_refl _ + +theorem seededAffineTrace (source scratch destination : K) + (hs : source ≠ scratch) (hd : source ≠ destination) (hsd : scratch ≠ destination) + (coefficient offset : Nat) (seedLabel scanLabel restoreLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atSeed : program seedLabel = seed destination offset scanLabel) + (atScan : program scanLabel = scan source scratch destination coefficient scanLabel restoreLabel) + (atRestore : program restoreLabel = Reduction.MachineTransfer.loopAt + scratch source id false restoreLabel exit) + (base : K → List Bool) (a : Nat) (suffix : List Bool) + (sourceWord : base source = encodeWord a ++ suffix) (scratchEmpty : base scratch = []) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[2 * (a + 1) + 1] + (some ⟨some seedLabel, (ambient,register), base⟩) = + some ⟨exit, (ambient,none), + Function.update base destination (encodeWord (coefficient * a + offset) ++ base destination)⟩ := by + have hseed : TM2.step program ⟨some seedLabel,(ambient,register),base⟩ = + some ⟨some scanLabel,(ambient,register), + Function.update base destination (encodeWord offset ++ base destination)⟩ := by + change some (TM2.stepAux (program seedLabel) _ _) = _ + rw [atSeed, seed, stepAux_pushWord] + simp only [List.reverse_reverse, TM2.stepAux] + have hrun := affineTrace source scratch destination hs hd hsd coefficient scanLabel restoreLabel + exit program atScan atRestore base a offset suffix (base destination) ambient register + have hframe (word : List Bool) : + tapes source scratch destination base (encodeWord a ++ suffix) [] word = + Function.update base destination word := by + rw [← sourceWord, ← scratchEmpty] + simp only [tapes, MachineCopy.forkTapes, Function.update_eq_self] + rw [hframe, hframe] at hrun + rw [Function.iterate_succ_apply] + simp only [advance_some] + rw [hseed] + exact hrun + +inductive Label + | seed | scan | restore + deriving DecidableEq + +instance : Fintype Label where + elems := {.seed, .scan, .restore} + complete value := by cases value <;> simp + +def program (source scratch destination : K) (coefficient offset : Nat) : + Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) + | .seed => seed destination offset .scan + | .scan => scan source scratch destination coefficient .scan .restore + | .restore => Reduction.MachineTransfer.loopAt scratch source id false .restore none + +def machine (coefficient offset : Nat) : FinTM2 where + K := Fin 3 + k₀ := 0 + k₁ := 2 + Γ _ := Bool + Λ := Label + main := .seed + σ := Unit × Option Bool + initialState := ((),none) + m := program 0 1 2 coefficient offset + +end IndependentSetsGames.Foundations.Complexity.MachineUnaryAffineAt + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryCounter.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryCounter.lean new file mode 100644 index 0000000000000000000000000000000000000000..d23924fc30c5500f6d38020b555d02d6e4099778 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryCounter.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineUnaryCounter + +open Turing + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def guard (counter : K) (bodyLabel exitLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .peek counter (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.pop counter (fun state _ => (state.1, none)) (.goto fun _ => bodyLabel)) + (.load (fun state => (state.1, none)) (.goto fun _ => exitLabel))) + +def counterTapes (counter : K) (base : K → List Bool) (n : Nat) + (suffix : List Bool) : K → List Bool := + Function.update base counter (encodeWord n ++ suffix) + +@[simp] theorem counterTapes_counter (counter : K) (base : K → List Bool) + (n : Nat) (suffix : List Bool) : + counterTapes counter base n suffix counter = encodeWord n ++ suffix := by + simp [counterTapes] + +theorem counterTapes_other (counter other : K) (hne : other ≠ counter) + (base : K → List Bool) (n : Nat) (suffix : List Bool) : + counterTapes counter base n suffix other = base other := by + simp [counterTapes, hne] + +omit [DecidableEq K] in +theorem guardPushBound (counter : K) (bodyLabel exitLabel : Λ) : + Runtime.statementPushBound (guard (σ := σ) counter bodyLabel exitLabel) = 0 := by + rfl + +theorem stepAux_succ (counter : K) (bodyLabel exitLabel : Λ) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.stepAux (guard counter bodyLabel exitLabel) (ambient, register) + (counterTapes counter base (n + 1) suffix) = + ⟨some bodyLabel, (ambient, none), counterTapes counter base n suffix⟩ := by + simp [guard, TM2.stepAux, counterTapes, encodeWord, List.replicate_succ] + +theorem stepAux_zero (counter : K) (bodyLabel exitLabel : Λ) + (base : K → List Bool) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.stepAux (guard counter bodyLabel exitLabel) (ambient, register) + (counterTapes counter base 0 suffix) = + ⟨some exitLabel, (ambient, none), counterTapes counter base 0 suffix⟩ := by + simp [guard, TM2.stepAux, counterTapes, encodeWord] + +theorem guardStep_succ (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some guardLabel, (ambient, register), counterTapes counter base (n + 1) suffix⟩ = + some ⟨some bodyLabel, (ambient, none), counterTapes counter base n suffix⟩ := by + change some (TM2.stepAux (program guardLabel) (ambient, register) + (counterTapes counter base (n + 1) suffix)) = _ + rw [atGuard, stepAux_succ] + +theorem guardStep_zero (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (base : K → List Bool) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step program + ⟨some guardLabel, (ambient, register), counterTapes counter base 0 suffix⟩ = + some ⟨some exitLabel, (ambient, none), counterTapes counter base 0 suffix⟩ := by + change some (TM2.stepAux (program guardLabel) (ambient, register) + (counterTapes counter base 0 suffix)) = _ + rw [atGuard, stepAux_zero] + +theorem guardTrace_succ (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some guardLabel, (ambient, register), + counterTapes counter base (n + 1) suffix⟩) = + some ⟨some bodyLabel, (ambient, none), counterTapes counter base n suffix⟩ := by + simpa only [Function.iterate_one, MachineComposition.advance_some] using + guardStep_succ counter guardLabel bodyLabel exitLabel program atGuard + base n suffix ambient register + +theorem guardTrace_zero (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (base : K → List Bool) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some guardLabel, (ambient, register), counterTapes counter base 0 suffix⟩) = + some ⟨some exitLabel, (ambient, none), counterTapes counter base 0 suffix⟩ := by + simpa only [Function.iterate_one, MachineComposition.advance_some] using + guardStep_zero counter guardLabel bodyLabel exitLabel program atGuard + base suffix ambient register + +def guardInTime_succ (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some guardLabel, (ambient, register), counterTapes counter base (n + 1) suffix⟩ + (some ⟨some bodyLabel, (ambient, none), counterTapes counter base n suffix⟩) 1 where + steps := 1 + evals_in_steps := by + change (MachineComposition.advance (TM2.step program))^[1] _ = _ + exact guardTrace_succ counter guardLabel bodyLabel exitLabel program atGuard + base n suffix ambient register + steps_le_m := Nat.le_refl _ + +def guardInTime_zero (counter : K) (guardLabel bodyLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atGuard : program guardLabel = guard counter bodyLabel exitLabel) + (base : K → List Bool) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some guardLabel, (ambient, register), counterTapes counter base 0 suffix⟩ + (some ⟨some exitLabel, (ambient, none), counterTapes counter base 0 suffix⟩) 1 where + steps := 1 + evals_in_steps := by + change (MachineComposition.advance (TM2.step program))^[1] _ = _ + exact guardTrace_zero counter guardLabel bodyLabel exitLabel program atGuard + base suffix ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.Complexity.MachineUnaryCounter + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryEqualityBit.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryEqualityBit.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f015f7cd123e2dfff02d050b136bc3d7724ef50 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryEqualityBit.lean @@ -0,0 +1,246 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineStateEquiv +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAffine + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineUnaryEqualityBit + +open Turing +open MachineComposition + +variable {K Λ A : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool +abbrev State (A : Type) := (A × Bool × Option Bool) × Option Bool + +def clean (ambient : A) : State A := ((ambient, false, none), none) + +def compareStateEquiv (A : Type) : MachineCompare.State A ≃ State A where + toFun s := ((s.1, s.2.1, s.2.2.1), s.2.2.2) + invFun s := (s.1.1, s.1.2.1, s.1.2.2, s.2) + left_inv := by rintro ⟨a, b, c, d⟩; rfl + right_inv := by rintro ⟨⟨a, b, c⟩, d⟩; rfl + +inductive Label + | seedLeft | scanLeft | restoreLeft + | seedRight | scanRight | restoreRight + | compare | equal | different + deriving DecidableEq + +instance : Fintype Label where + elems := {.seedLeft, .scanLeft, .restoreLeft, .seedRight, .scanRight, .restoreRight, .compare, + .equal, .different} + complete value := by cases value <;> simp + +def exitAt (exit : Option Λ) : TM2.Stmt (Alphabet (K := K)) Λ (State A) := + match exit with + | none => .halt + | some label => .goto fun _ => label + +def bitEncoding (bit : Bool) : List Bool := encodeWord (if bit then 1 else 0) + +def emit (destination : K) (bit : Bool) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (State A) := + .push destination (fun _ => false) + (if bit then .push destination (fun _ => true) (exitAt exit) else exitAt exit) + +def instruction (tape : Fin 6 → K) (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt (Alphabet (K := K)) Λ (State A) + | .seedLeft => MachineUnaryAffineAt.seed (tape 2) 0 (labels .scanLeft) + | .scanLeft => MachineUnaryAffineAt.scan (tape 0) (tape 4) (tape 2) 1 + (labels .scanLeft) (labels .restoreLeft) + | .restoreLeft => Reduction.MachineTransfer.loopAt (tape 4) (tape 0) id false + (labels .restoreLeft) (some (labels .seedRight)) + | .seedRight => MachineUnaryAffineAt.seed (tape 3) 0 (labels .scanRight) + | .scanRight => MachineUnaryAffineAt.scan (tape 1) (tape 4) (tape 3) 1 + (labels .scanRight) (labels .restoreRight) + | .restoreRight => Reduction.MachineTransfer.loopAt (tape 4) (tape 1) id false + (labels .restoreRight) (some (labels .compare)) + | .compare => MachineStateEquiv.statement (compareStateEquiv A) + (MachineCompare.loop (tape 2) (tape 3) (labels .compare) + (some (labels .equal)) (some (labels .different))) + | .equal => emit (tape 5) true exit + | .different => emit (tape 5) false exit + +def copySteps (n : Nat) : Nat := 2 * (n + 1) + 1 +def compareSteps (a b : Nat) : Nat := max (a + 1) (b + 1) + 1 +def steps (a b : Nat) : Nat := copySteps a + copySteps b + compareSteps a b + 1 + +theorem steps_le (a b : Nat) : steps a b ≤ 3 * (a + b) + 9 := by + unfold steps copySteps compareSteps + omega + +theorem encodeWord_eq_iff (a b : Nat) : encodeWord a = encodeWord b ↔ a = b := by + constructor + · intro h + have hlength := congrArg List.length h + simp only [encodeWord_length] at hlength + omega + · rintro rfl + rfl + +theorem emit_step (destination : K) (bit : Bool) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A)) + (label : Λ) (atEmit : program label = emit destination bit exit) + (state : State A) (base : K → List Bool) : + TM2.step program ⟨some label, state, base⟩ = + some ⟨exit, state, + Function.update base destination (bitEncoding bit ++ base destination)⟩ := by + change some (TM2.stepAux (program label) state base) = _ + rw [atEmit] + cases bit <;> cases exit <;> + simp [emit, exitAt, TM2.stepAux, bitEncoding, encodeWord, Function.update_idem] + +theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {n m : Nat} + (first : f^[n] a = b) (second : f^[m] b = c) : f^[n + m] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem equalityTrace (tape : Fin 6 → K) (distinct : Function.Injective tape) + (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A)) + (atLabels : ∀ l, program (labels l) = instruction tape labels exit l) + (base : K → List Bool) (a b : Nat) (leftSuffix rightSuffix : List Bool) + (leftWord : base (tape 0) = encodeWord a ++ leftSuffix) + (rightWord : base (tape 1) = encodeWord b ++ rightSuffix) + (leftEmpty : base (tape 2) = []) (rightEmpty : base (tape 3) = []) + (scratchEmpty : base (tape 4) = []) (ambient : A) : + (advance (TM2.step program))^[steps a b] + (some ⟨some (labels .seedLeft), clean ambient, base⟩) = + some ⟨exit, clean ambient, + Function.update base (tape 5) (bitEncoding (decide (a = b)) ++ base (tape 5))⟩ := by + have hd (i j : Fin 6) (hne : i ≠ j) : tape i ≠ tape j := + fun h => hne (distinct h) + let midLeft := Function.update base (tape 2) (encodeWord a) + let midBoth := Function.update midLeft (tape 3) (encodeWord b) + have leftRun : (advance (TM2.step program))^[copySteps a] + (some ⟨some (labels .seedLeft), clean ambient, base⟩) = + some ⟨some (labels .seedRight), clean ambient, midLeft⟩ := by + simpa only [copySteps, clean, midLeft, Nat.one_mul, Nat.add_zero, + leftEmpty, List.append_nil] using + MachineUnaryAffineAt.seededAffineTrace (tape 0) (tape 4) (tape 2) + (hd 0 4 (by decide)) (hd 0 2 (by decide)) (hd 4 2 (by decide)) 1 0 + (labels .seedLeft) (labels .scanLeft) (labels .restoreLeft) + (some (labels .seedRight)) program (atLabels .seedLeft) + (atLabels .scanLeft) (atLabels .restoreLeft) + base a leftSuffix leftWord scratchEmpty (ambient, false, none) none + have rightSource : midLeft (tape 1) = encodeWord b ++ rightSuffix := by + simpa [midLeft, hd 1 2 (by decide)] using rightWord + have scratchAfterLeft : midLeft (tape 4) = [] := by + simpa [midLeft, hd 4 2 (by decide)] using scratchEmpty + have rightCopyAfterLeft : midLeft (tape 3) = [] := by + simpa [midLeft, hd 3 2 (by decide)] using rightEmpty + have rightRun : (advance (TM2.step program))^[copySteps b] + (some ⟨some (labels .seedRight), clean ambient, midLeft⟩) = + some ⟨some (labels .compare), clean ambient, midBoth⟩ := by + simpa only [copySteps, clean, midBoth, Nat.one_mul, Nat.add_zero, + rightCopyAfterLeft, List.append_nil] using + MachineUnaryAffineAt.seededAffineTrace (tape 1) (tape 4) (tape 3) + (hd 1 4 (by decide)) (hd 1 3 (by decide)) (hd 4 3 (by decide)) 1 0 + (labels .seedRight) (labels .scanRight) (labels .restoreRight) + (some (labels .compare)) program (atLabels .seedRight) + (atLabels .scanRight) (atLabels .restoreRight) + midLeft b rightSuffix rightSource scratchAfterLeft (ambient, false, none) none + have copyLeftWord : midBoth (tape 2) = encodeWord a := by + simp [midBoth, midLeft, hd 2 3 (by decide)] + have copyRightWord : midBoth (tape 3) = encodeWord b := by simp [midBoth] + have restored : Reduction.MachineTransfer.tapesAt (tape 2) (tape 3) midBoth [] [] = base := by + funext k + by_cases hl : k = tape 2 + · subst k + simp [Reduction.MachineTransfer.tapesAt, midBoth, midLeft, + hd 2 3 (by decide), leftEmpty] + · by_cases hr : k = tape 3 + · subst k + simp [Reduction.MachineTransfer.tapesAt, midBoth, midLeft, rightEmpty] + · simp [Reduction.MachineTransfer.tapesAt, midBoth, midLeft, hl, hr] + let back := MachineStateEquiv.program (compareStateEquiv A).symm program + have atCompare : back (labels .compare) = + MachineCompare.loop (tape 2) (tape 3) (labels .compare) + (some (labels .equal)) (some (labels .different)) := by + change MachineStateEquiv.statement (compareStateEquiv A).symm + (program (labels .compare)) = _ + rw [atLabels .compare] + exact MachineStateEquiv.statement_symm_statement (compareStateEquiv A) _ + have backForward : MachineStateEquiv.program (compareStateEquiv A) back = program := by + funext l + change MachineStateEquiv.statement (compareStateEquiv A) + (MachineStateEquiv.statement (compareStateEquiv A).symm (program l)) = program l + simpa only [Equiv.symm_symm] using + MachineStateEquiv.statement_symm_statement (compareStateEquiv A).symm (program l) + have compareRun : (advance (TM2.step program))^[compareSteps a b] + (some ⟨some (labels .compare), clean ambient, midBoth⟩) = + some ⟨if a = b then some (labels .equal) else some (labels .different), + clean ambient, base⟩ := by + have native := MachineCompare.compareTrace_fromTapes (tape 2) (tape 3) + (hd 2 3 (by decide)) (labels .compare) (some (labels .equal)) + (some (labels .different)) back atCompare midBoth ambient none none + rw [copyLeftWord, copyRightWord, restored] at native + simp only [encodeWord_eq_iff, encodeWord_length] at native + have transported := MachineStateEquiv.trace (compareStateEquiv A) back _ _ _ native + rw [backForward] at transported + simpa [MachineStateEquiv.configuration, compareStateEquiv, clean, compareSteps] using + transported + have emitRun : TM2.step program + ⟨if a = b then some (labels .equal) else some (labels .different), + clean ambient, base⟩ = + some ⟨exit, clean ambient, + Function.update base (tape 5) (bitEncoding (decide (a = b)) ++ base (tape 5))⟩ := by + by_cases heq : a = b + · simpa only [heq, ite_true, decide_true] using + emit_step (tape 5) true exit program (labels .equal) (atLabels .equal) + (clean ambient) base + · simpa only [heq, ite_false, decide_false] using + emit_step (tape 5) false exit program (labels .different) (atLabels .different) + (clean ambient) base + have copied := joinTrace leftRun rightRun + have compared := joinTrace copied compareRun + rw [steps, Function.iterate_succ_apply', compared, advance_some] + exact emitRun + +def equalityInTime (tape : Fin 6 → K) (distinct : Function.Injective tape) + (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A)) + (atLabels : ∀ l, program (labels l) = instruction tape labels exit l) + (base : K → List Bool) (a b : Nat) (leftSuffix rightSuffix : List Bool) + (leftWord : base (tape 0) = encodeWord a ++ leftSuffix) + (rightWord : base (tape 1) = encodeWord b ++ rightSuffix) + (leftEmpty : base (tape 2) = []) (rightEmpty : base (tape 3) = []) + (scratchEmpty : base (tape 4) = []) (ambient : A) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .seedLeft), clean ambient, base⟩ + (some ⟨exit, clean ambient, + Function.update base (tape 5) (bitEncoding (decide (a = b)) ++ base (tape 5))⟩) + (3 * (a + b) + 9) where + steps := steps a b + evals_in_steps := equalityTrace tape distinct labels exit program atLabels base a b + leftSuffix rightSuffix leftWord rightWord leftEmpty rightEmpty scratchEmpty ambient + steps_le_m := steps_le a b + +def machine : FinTM2 where + K := Fin 6 + k₀ := 0 + k₁ := 5 + Γ _ := Bool + Λ := Label + main := .seedLeft + σ := State Unit + initialState := clean () + m := instruction id id none + +def machineInTime (base : Fin 6 → List Bool) (a b : Nat) + (leftSuffix rightSuffix : List Bool) + (leftWord : base 0 = encodeWord a ++ leftSuffix) + (rightWord : base 1 = encodeWord b ++ rightSuffix) + (leftEmpty : base 2 = []) (rightEmpty : base 3 = []) (scratchEmpty : base 4 = []) : + StateTransition.EvalsToInTime machine.step + ⟨some .seedLeft, clean (), base⟩ + (some ⟨none, clean (), + Function.update base (5 : Fin 6) (bitEncoding (decide (a = b)) ++ base (5 : Fin 6))⟩) + (3 * (a + b) + 9) := + equalityInTime id (fun _ _ h => h) id none (instruction id id none) (fun _ => rfl) + base a b leftSuffix rightSuffix leftWord rightWord leftEmpty rightEmpty scratchEmpty () + +end IndependentSetsGames.Foundations.Complexity.MachineUnaryEqualityBit + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryLess.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryLess.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1aa9ec54611e6a7c6b6050d7ac8abb625ccab6e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineUnaryLess.lean @@ -0,0 +1,327 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryAffine + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineUnaryLessAt + +open Turing MachineComposition + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool +abbrev State (σ : Type) := (σ × Bool) × Option Bool + +def zeroTest (operand : K) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ) := + .peek operand (fun s head => (s.1, head)) + (.load (fun s => ((s.1.1, !(s.2.getD false)), none)) + (Reduction.MachineTransfer.exitAt operand exit)) + +theorem zeroTestTrace (operand : K) (testLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atTest : program testLabel = zeroTest operand exit) + (base : K → List Bool) (n : Nat) (suffix : List Bool) + (word : base operand = encodeWord n ++ suffix) + (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step program))^[1] + (some ⟨some testLabel, ((ambient, flag), register), base⟩) = + some ⟨exit, ((ambient, decide (n = 0)), none), base⟩ := by + change some (TM2.stepAux (program testLabel) _ _) = _ + rw [atTest] + cases n <;> cases exit <;> + simp [zeroTest, TM2.stepAux, word, encodeWord, List.replicate_succ, + Reduction.MachineTransfer.exitAt] + +def tapes (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight : List Bool) : K → List Bool := + Function.update (Function.update (Function.update (Function.update base + (slots 0) left) (slots 1) right) (slots 2) savedLeft) (slots 3) savedRight + +@[simp] theorem tapes_left (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight : List Bool) : + tapes slots base left right savedLeft savedRight (slots 0) = left := by + simp [tapes, slots.injective.eq_iff] + +@[simp] theorem tapes_right (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight : List Bool) : + tapes slots base left right savedLeft savedRight (slots 1) = right := by + simp [tapes, slots.injective.eq_iff] + +@[simp] theorem tapes_savedLeft (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight : List Bool) : + tapes slots base left right savedLeft savedRight (slots 2) = savedLeft := by + simp [tapes, slots.injective.eq_iff] + +@[simp] theorem tapes_savedRight (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight : List Bool) : + tapes slots base left right savedLeft savedRight (slots 3) = savedRight := by + simp [tapes] + +@[simp] theorem update_tapes (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight replacement : List Bool) (i : Fin 4) : + Function.update (tapes slots base left right savedLeft savedRight) (slots i) replacement = + tapes slots base (if i = 0 then replacement else left) + (if i = 1 then replacement else right) (if i = 2 then replacement else savedLeft) + (if i = 3 then replacement else savedRight) := by + fin_cases i <;> funext k + all_goals + by_cases h₀ : k = slots 0 + · subst k; simp [tapes, slots.injective.eq_iff] + · by_cases h₁ : k = slots 1 + · subst k; simp [tapes, slots.injective.eq_iff] + · by_cases h₂ : k = slots 2 + · subst k; simp [tapes, slots.injective.eq_iff] + · by_cases h₃ : k = slots 3 + · subst k; simp [tapes, slots.injective.eq_iff] + · simp [tapes, h₀, h₁, h₂, h₃] + +@[simp] theorem tapes_self (slots : Fin 4 ↪ K) (base : K → List Bool) : + tapes slots base (base (slots 0)) (base (slots 1)) (base (slots 2)) (base (slots 3)) = base := by + simp [tapes] + +def stop (result : Bool) (restoreLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ) := + .load (fun s => ((s.1.1, result), none)) (.goto fun _ => restoreLabel) + +def scan (slots : Fin 4 ↪ K) (scanLabel restoreLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ) := + .peek (slots 0) (fun s head => (s.1, head)) + (.branch (fun s => s.2.getD false) + (.peek (slots 1) (fun s head => (s.1, head)) + (.branch (fun s => s.2.getD false) + (.pop (slots 0) (fun s _ => s) + (.pop (slots 1) (fun s _ => s) + (.push (slots 2) (fun _ => true) + (.push (slots 3) (fun _ => true) (.goto fun _ => scanLabel))))) + (stop false restoreLabel))) + (.peek (slots 1) (fun s head => (s.1, head)) + (.branch (fun s => s.2.getD false) + (stop true restoreLabel) (stop false restoreLabel)))) + +theorem scan_step_zero_left (slots : Fin 4 ↪ K) (scanLabel restoreLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atScan : program scanLabel = scan slots scanLabel restoreLabel) + (base : K → List Bool) (b : Nat) (leftSuffix rightSuffix savedLeft savedRight : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step program ⟨some scanLabel, ((ambient, flag), register), + tapes slots base (encodeWord 0 ++ leftSuffix) (encodeWord b ++ rightSuffix) savedLeft savedRight⟩ = + some ⟨some restoreLabel, ((ambient, decide (0 < b)), none), + tapes slots base (encodeWord 0 ++ leftSuffix) (encodeWord b ++ rightSuffix) savedLeft savedRight⟩ := by + change some (TM2.stepAux (program scanLabel) _ _) = _ + rw [atScan] + cases b <;> simp [scan, stop, TM2.stepAux, encodeWord, List.replicate_succ] + +theorem scan_step_zero_right (slots : Fin 4 ↪ K) (scanLabel restoreLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atScan : program scanLabel = scan slots scanLabel restoreLabel) + (base : K → List Bool) (a : Nat) (leftSuffix rightSuffix savedLeft savedRight : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step program ⟨some scanLabel, ((ambient, flag), register), + tapes slots base (encodeWord (a + 1) ++ leftSuffix) (encodeWord 0 ++ rightSuffix) savedLeft savedRight⟩ = + some ⟨some restoreLabel, ((ambient, false), none), + tapes slots base (encodeWord (a + 1) ++ leftSuffix) (encodeWord 0 ++ rightSuffix) savedLeft savedRight⟩ := by + change some (TM2.stepAux (program scanLabel) _ _) = _ + rw [atScan] + simp [scan, stop, TM2.stepAux, encodeWord, List.replicate_succ] + +theorem scan_step_succ (slots : Fin 4 ↪ K) (scanLabel restoreLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atScan : program scanLabel = scan slots scanLabel restoreLabel) + (base : K → List Bool) (a b : Nat) (leftSuffix rightSuffix savedLeft savedRight : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + TM2.step program ⟨some scanLabel, ((ambient, flag), register), + tapes slots base (encodeWord (a + 1) ++ leftSuffix) (encodeWord (b + 1) ++ rightSuffix) + savedLeft savedRight⟩ = + some ⟨some scanLabel, ((ambient, flag), some true), + tapes slots base (encodeWord a ++ leftSuffix) (encodeWord b ++ rightSuffix) + (true :: savedLeft) (true :: savedRight)⟩ := by + change some (TM2.stepAux (program scanLabel) _ _) = _ + rw [atScan] + simp [scan, TM2.stepAux, encodeWord, List.replicate_succ] + +theorem scanTrace (slots : Fin 4 ↪ K) (scanLabel restoreLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atScan : program scanLabel = scan slots scanLabel restoreLabel) + (base : K → List Bool) (a b : Nat) (leftSuffix rightSuffix savedLeft savedRight : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step program))^[min a b + 1] + (some ⟨some scanLabel, ((ambient, flag), register), + tapes slots base (encodeWord a ++ leftSuffix) (encodeWord b ++ rightSuffix) savedLeft savedRight⟩) = + some ⟨some restoreLabel, ((ambient, decide (a < b)), none), + tapes slots base (encodeWord (a - b) ++ leftSuffix) (encodeWord (b - a) ++ rightSuffix) + (List.replicate (min a b) true ++ savedLeft) (List.replicate (min a b) true ++ savedRight)⟩ := by + induction a generalizing b savedLeft savedRight register with + | zero => + simpa using scan_step_zero_left slots scanLabel restoreLabel program atScan base b + leftSuffix rightSuffix savedLeft savedRight ambient flag register + | succ a ih => + cases b with + | zero => + simpa using scan_step_zero_right slots scanLabel restoreLabel program atScan base a + leftSuffix rightSuffix savedLeft savedRight ambient flag register + | succ b => + have hm : min (a + 1) (b + 1) = min a b + 1 := by omega + rw [hm, Function.iterate_succ_apply] + simp only [advance_some] + rw [scan_step_succ slots scanLabel restoreLabel program atScan, ih] + have hsave (xs : List Bool) : + List.replicate (min a b) true ++ true :: xs = + List.replicate (min a b + 1) true ++ xs := by + simp [List.replicate_add, List.append_assoc] + simp only [hsave, Nat.add_sub_add_right, Nat.add_lt_add_iff_right] + +@[simp] theorem transferLeft_tapes (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight replacementSaved replacementLeft : List Bool) : + Reduction.MachineTransfer.tapesAt (slots 2) (slots 0) + (tapes slots base left right savedLeft savedRight) replacementSaved replacementLeft = + tapes slots base replacementLeft right replacementSaved savedRight := by + simp [Reduction.MachineTransfer.tapesAt] + +@[simp] theorem transferRight_tapes (slots : Fin 4 ↪ K) (base : K → List Bool) + (left right savedLeft savedRight replacementSaved replacementRight : List Bool) : + Reduction.MachineTransfer.tapesAt (slots 3) (slots 1) + (tapes slots base left right savedLeft savedRight) replacementSaved replacementRight = + tapes slots base left replacementRight savedLeft replacementSaved := by + simp [Reduction.MachineTransfer.tapesAt] + +inductive Label where + | scan + | restoreLeft + | restoreRight + deriving DecidableEq + +instance : Fintype Label where + elems := { .scan, .restoreLeft, .restoreRight } + complete l := by cases l <;> simp + +def statement (slots : Fin 4 ↪ K) (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt (Alphabet (K := K)) Λ (State σ) + | .scan => scan slots (labels .scan) (labels .restoreLeft) + | .restoreLeft => Reduction.MachineTransfer.loopAt (slots 2) (slots 0) id false + (labels .restoreLeft) (some (labels .restoreRight)) + | .restoreRight => Reduction.MachineTransfer.loopAt (slots 3) (slots 1) id false + (labels .restoreRight) exit + +def steps (a b : Nat) : Nat := 3 * (min a b + 1) + +theorem comparisonTrace (slots : Fin 4 ↪ K) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ l, program (labels l) = statement slots labels exit l) + (base : K → List Bool) (a b : Nat) (leftSuffix rightSuffix : List Bool) + (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step program))^[steps a b] + (some ⟨some (labels .scan), ((ambient, flag), register), + tapes slots base (encodeWord a ++ leftSuffix) (encodeWord b ++ rightSuffix) [] []⟩) = + some ⟨exit, ((ambient, decide (a < b)), none), + tapes slots base (encodeWord a ++ leftSuffix) (encodeWord b ++ rightSuffix) [] []⟩ := by + have hscan := scanTrace slots (labels .scan) (labels .restoreLeft) program (atLabels .scan) + base a b leftSuffix rightSuffix [] [] ambient flag register + simp only [List.append_nil] at hscan + have hwordLeft : List.replicate (min a b) true ++ (encodeWord (a - b) ++ leftSuffix) = + encodeWord a ++ leftSuffix := by + rw [MachineUnaryAffineAt.prepend_replicate_word, + show min a b + (a - b) = a by omega] + have hwordRight : List.replicate (min a b) true ++ (encodeWord (b - a) ++ rightSuffix) = + encodeWord b ++ rightSuffix := by + rw [MachineUnaryAffineAt.prepend_replicate_word, + show min a b + (b - a) = b by omega] + let middle := tapes slots base (encodeWord (a - b) ++ leftSuffix) + (encodeWord (b - a) ++ rightSuffix) (List.replicate (min a b) true) (List.replicate (min a b) true) + have hleft := Reduction.MachineTransfer.transferAt_fromTapes + (Γ := fun _ : K => Bool) (σ := σ × Bool) (slots 2) (slots 0) + (slots.injective.ne (by decide)) id false (labels .restoreLeft) (some (labels .restoreRight)) + program (by simpa only [statement] using atLabels .restoreLeft) + middle (ambient, decide (a < b)) none + change (advance (TM2.step program))^[(middle (slots 2)).length + 1] + (some ⟨some (labels .restoreLeft), ((ambient, decide (a < b)), none), middle⟩) = _ at hleft + simp only [middle, tapes_savedLeft, tapes_left, List.length_replicate, List.reverse_replicate, + List.map_id, hwordLeft, transferLeft_tapes] at hleft + let afterLeft := tapes slots base (encodeWord a ++ leftSuffix) + (encodeWord (b - a) ++ rightSuffix) [] (List.replicate (min a b) true) + have hright := Reduction.MachineTransfer.transferAt_fromTapes + (Γ := fun _ : K => Bool) (σ := σ × Bool) (slots 3) (slots 1) + (slots.injective.ne (by decide)) id false (labels .restoreRight) exit + program (by simpa only [statement] using atLabels .restoreRight) + afterLeft (ambient, decide (a < b)) none + change (advance (TM2.step program))^[(afterLeft (slots 3)).length + 1] + (some ⟨some (labels .restoreRight), ((ambient, decide (a < b)), none), afterLeft⟩) = _ at hright + simp only [afterLeft, tapes_savedRight, tapes_right, List.length_replicate, List.reverse_replicate, + List.map_id, hwordRight, transferRight_tapes] at hright + have hfirst : (advance (TM2.step program))^[(min a b + 1) + (min a b + 1)] + (some ⟨some (labels .scan), ((ambient, flag), register), + tapes slots base (encodeWord a ++ leftSuffix) (encodeWord b ++ rightSuffix) [] []⟩) = + some ⟨some (labels .restoreRight), ((ambient, decide (a < b)), none), afterLeft⟩ := by + rw [Function.iterate_add_apply, hscan] + exact hleft + rw [show steps a b = (min a b + 1) + ((min a b + 1) + (min a b + 1)) by + unfold steps; omega, Function.iterate_add_apply, hfirst] + exact hright + +theorem lessThanTrace (slots : Fin 4 ↪ K) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ l, program (labels l) = statement slots labels exit l) + (base : K → List Bool) (a b : Nat) (leftSuffix rightSuffix : List Bool) + (leftWord : base (slots 0) = encodeWord a ++ leftSuffix) + (rightWord : base (slots 1) = encodeWord b ++ rightSuffix) + (leftEmpty : base (slots 2) = []) (rightEmpty : base (slots 3) = []) + (ambient : σ) (flag : Bool) (register : Option Bool) : + (advance (TM2.step program))^[steps a b] + (some ⟨some (labels .scan), ((ambient, flag), register), base⟩) = + some ⟨exit, ((ambient, decide (a < b)), none), base⟩ := by + have h := comparisonTrace slots labels exit program atLabels base a b leftSuffix rightSuffix + ambient flag register + have hframe := tapes_self slots base + rw [leftWord, rightWord, leftEmpty, rightEmpty] at hframe + rw [hframe] at h + exact h + +noncomputable def timePolynomial : Polynomial Nat := Polynomial.C 3 * Polynomial.X + Polynomial.C 3 + +theorem steps_le_time (a b : Nat) : steps a b ≤ timePolynomial.eval (a + b) := by + simp only [steps, timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X] + have := Nat.min_le_left a b + omega + +def lessThanInPolynomialTime (slots : Fin 4 ↪ K) (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ l, program (labels l) = statement slots labels exit l) + (base : K → List Bool) (a b : Nat) (leftSuffix rightSuffix : List Bool) + (leftWord : base (slots 0) = encodeWord a ++ leftSuffix) + (rightWord : base (slots 1) = encodeWord b ++ rightSuffix) + (leftEmpty : base (slots 2) = []) (rightEmpty : base (slots 3) = []) + (ambient : σ) (flag : Bool) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .scan), ((ambient, flag), register), base⟩ + (some ⟨exit, ((ambient, decide (a < b)), none), base⟩) (timePolynomial.eval (a + b)) where + steps := steps a b + evals_in_steps := lessThanTrace slots labels exit program atLabels base a b leftSuffix rightSuffix + leftWord rightWord leftEmpty rightEmpty ambient flag register + steps_le_m := steps_le_time a b + +abbrev machine : Turing.FinTM2 where + K := Fin 4 + k₀ := 0 + k₁ := 1 + Γ _ := Bool + Λ := Label + main := .scan + σ := State Unit + initialState := (((), false), none) + m := statement (Function.Embedding.refl _) id none + +def machineInPolynomialTime (base : Fin 4 → List Bool) (a b : Nat) + (leftSuffix rightSuffix : List Bool) + (leftWord : base 0 = encodeWord a ++ leftSuffix) + (rightWord : base 1 = encodeWord b ++ rightSuffix) + (leftEmpty : base 2 = []) (rightEmpty : base 3 = []) : + StateTransition.EvalsToInTime machine.step + ⟨some .scan, (((), false), none), base⟩ + (some ⟨none, (((), decide (a < b)), none), base⟩) (timePolynomial.eval (a + b)) := + lessThanInPolynomialTime (Function.Embedding.refl _) id none machine.m (fun _ => rfl) + base a b leftSuffix rightSuffix leftWord rightWord leftEmpty rightEmpty () false none + +end IndependentSetsGames.Foundations.Complexity.MachineUnaryLessAt + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/MachineVertexPadding.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineVertexPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..40c2e79e6e3b8a51df5bfe8039886ea24aa85f41 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/MachineVertexPadding.lean @@ -0,0 +1,628 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularTableRuntime +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddingCertificate + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineVertexPadding + +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP +open MachineCloudPadding + +inductive Tape + | original | output | vertex | edge | power | level | fuel | relation + | scratch | work | saved | product | rowWork | rowSpare + deriving DecidableEq + +instance : Fintype Tape where + elems := {.original, .output, .vertex, .edge, .power, .level, .fuel, .relation, .scratch, .work, + .saved, .product, .rowWork, .rowSpare} + complete value := by cases value <;> simp + +inductive Label (d : Nat) + | splitCode (l : MachineTableSplit.Label) + | powerCode (l : MachineCeilingPower.Label) + | dartSeed | dartScan | dartRestore | vertexSeed | vertexScan | vertexRestore + | copyFirst | copySecond | subtractCode (l : MachineCloudPadding.Label) + | rowsCode (l : MachinePaddingRows.Label d) + | cleanVertex | cleanEdge | cleanPower | cleanRelation | cleanFuel + deriving DecidableEq, Fintype + +abbrev Alphabet (_ : Tape) := Bool +abbrev State (σ : Type) := (σ × Bool) × Option Bool + +def memory (input output vertex edge power level fuel relation : List Bool) : Tape → List Bool + | .original => input + | .output => output + | .vertex => vertex + | .edge => edge + | .power => power + | .level => level + | .fuel => fuel + | .relation => relation + | _ => [] + +@[simp] theorem update_output (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .output x = memory a x c d e f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_vertex (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .vertex x = memory a b x d e f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_edge (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .edge x = memory a b c x e f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_power (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .power x = memory a b c d x f g h := by + funext k; cases k <;> rfl +@[simp] theorem update_fuel (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .fuel x = memory a b c d e f x h := by + funext k; cases k <;> rfl +@[simp] theorem update_relation (a b c d e f g h x : List Bool) : + Function.update (memory a b c d e f g h) .relation x = memory a b c d e f g x := by + funext k; cases k <;> rfl + +def splitTape : MachineTableSplit.Tape → Tape := ![.original, .output, .scratch, .vertex, .edge] +def splitView : Tape → Option MachineTableSplit.Tape + | .original => some 0 + | .output => some 1 + | .scratch => some 2 + | .vertex => some 3 + | .edge => some 4 + | _ => none + +theorem splitView_left (k : MachineTableSplit.Tape) : splitView (splitTape k) = some k := by + fin_cases k <;> rfl +theorem splitView_right (j : Tape) (k : MachineTableSplit.Tape) + (h : splitView j = some k) : splitTape k = j := by + cases j <;> fin_cases k <;> simp_all [splitView, splitTape] + +def powerTape : MachineCeilingPower.Tape → Tape + | .input => .vertex + | .work => .work + | .power => .power + | .saved => .saved + | .level => .level + | .fuel => .fuel + | .spare => .scratch + | .product => .product +def powerView : Tape → Option MachineCeilingPower.Tape + | .vertex => some .input + | .work => some .work + | .power => some .power + | .saved => some .saved + | .level => some .level + | .fuel => some .fuel + | .scratch => some .spare + | .product => some .product + | _ => none + +theorem powerView_left (k : MachineCeilingPower.Tape) : powerView (powerTape k) = some k := by + cases k <;> rfl +theorem powerView_right (j : Tape) (k : MachineCeilingPower.Tape) + (h : powerView j = some k) : powerTape k = j := by + cases j <;> cases k <;> simp_all [powerView, powerTape] + +def subtractTape : MachineCloudPadding.Tape → Tape + | .table => .original + | .query => .output + | .count => .vertex + | .work => .work + | .scratch => .saved + | .spare => .scratch + | .power => .fuel + | .level => .level + | .fuel => .product + | .product => .rowSpare +def subtractView : Tape → Option MachineCloudPadding.Tape + | .original => some .table + | .output => some .query + | .vertex => some .count + | .work => some .work + | .saved => some .scratch + | .scratch => some .spare + | .fuel => some .power + | .level => some .level + | .product => some .fuel + | .rowSpare => some .product + | _ => none + +theorem subtractView_left (k : MachineCloudPadding.Tape) : + subtractView (subtractTape k) = some k := by cases k <;> rfl +theorem subtractView_right (j : Tape) (k : MachineCloudPadding.Tape) + (h : subtractView j = some k) : subtractTape k = j := by + cases j <;> cases k <;> simp_all [subtractView, subtractTape] + +def rowTape : MachinePaddingRows.Tape → Tape + | .inl k => (![.vertex, .edge, .relation, .rowWork, .output, .rowSpare] : Fin 6 → Tape) k + | .inr _ => .fuel +def rowView : Tape → Option MachinePaddingRows.Tape + | .vertex => some (.inl 0) + | .edge => some (.inl 1) + | .relation => some (.inl 2) + | .rowWork => some (.inl 3) + | .output => some (.inl 4) + | .rowSpare => some (.inl 5) + | .fuel => some (.inr ()) + | _ => none + +theorem rowView_left (k : MachinePaddingRows.Tape) : rowView (rowTape k) = some k := by + rcases k with k | k + · fin_cases k <;> rfl + · cases k; rfl +theorem rowView_right (j : Tape) (k : MachinePaddingRows.Tape) + (h : rowView j = some k) : rowTape k = j := by + rcases k with k | k + · cases j <;> fin_cases k <;> simp_all [rowView, rowTape] + · cases k; cases j <;> simp_all [rowView, rowTape] + +theorem rowAlphabet_eq : MachinePaddingRows.Alphabet = (fun _ : MachinePaddingRows.Tape => Bool) := by + funext k; cases k <;> rfl + +def rowStateEquiv (σ : Type) : (MachinePaddingRows.State × (σ × Bool)) ≃ State σ where + toFun x := (x.2, x.1.1.2) + invFun x := ((((), x.2), ()), x.1) + left_inv := by rintro ⟨⟨⟨⟨⟩, r⟩, ⟨⟩⟩, a⟩; rfl + right_inv := by rintro ⟨a, r⟩; rfl + +def rowProgram {σ : Type} (d : Nat) (hd : 0 < d) : + MachinePaddingRows.Label d → + TM2.Stmt (fun _ : MachinePaddingRows.Tape => Bool) (MachinePaddingRows.Label d) (State σ) := + MachineStateEquiv.program (rowStateEquiv σ) + (MachineStateFrame.frameProgram + (MachineAlphabetTransport.program rowAlphabet_eq (MachinePaddingRows.program d hd))) + +def program {σ : Type} (d : Nat) (hd : 0 < d) : Label d → TM2.Stmt Alphabet (Label d) (State σ) + | .splitCode l => Placement.statement splitTape Label.splitCode (some (.powerCode .init)) + (MachineTableSplit.program l) + | .powerCode l => Placement.statement powerTape Label.powerCode (some .dartSeed) + (MachineCeilingPower.program ExpanderFamily.growth l) + | .dartSeed => MachineUnaryAffineAt.seed .output 0 .dartScan + | .dartScan => MachineUnaryAffineAt.scan .power .scratch .output d .dartScan .dartRestore + | .dartRestore => Reduction.MachineTransfer.loopAt + .scratch .power id false .dartRestore (some .vertexSeed) + | .vertexSeed => MachineUnaryAffineAt.seed .output 0 .vertexScan + | .vertexScan => MachineUnaryAffineAt.scan .power .scratch .output 1 .vertexScan .vertexRestore + | .vertexRestore => Reduction.MachineTransfer.loopAt + .scratch .power id false .vertexRestore (some .copyFirst) + | .copyFirst => Reduction.MachineTransfer.loopAt + .power .scratch id false .copyFirst (some .copySecond) + | .copySecond => MachineCopy.forkLoop + .scratch .power .fuel false .copySecond (some (.subtractCode .subtract)) + | .subtractCode l => Placement.statement subtractTape Label.subtractCode + (some (.rowsCode (.inr .initialize))) (MachineCloudPadding.program l) + | .rowsCode l => Placement.statement rowTape Label.rowsCode (some .cleanVertex) (rowProgram d hd l) + | .cleanVertex => MachineDrain.drain .vertex .cleanVertex (some .cleanEdge) + | .cleanEdge => MachineDrain.drain .edge .cleanEdge (some .cleanPower) + | .cleanPower => MachineDrain.drain .power .cleanPower (some .cleanRelation) + | .cleanRelation => MachineDrain.drain .relation .cleanRelation (some .cleanFuel) + | .cleanFuel => MachineDrain.drain .fuel .cleanFuel none + +private theorem appendTrace {α : Type} (f : α → α) {a b : Nat} {x y z : α} + (hs : f^[a] x = y) (ht : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm a b, Function.iterate_add_apply, hs, ht] + +theorem tableBits_split {n d : Nat} (t : PortTables.Table n d) : + PortTables.tableBits t = encodeWords [n, n * d] ++ PreprocessingPaddingWords.rowsBits t := by + change encodeWords (PortTables.tableWords t) = _ + rw [PortTables.tableWords_eq, encodeWords_append] + rfl + +theorem splitInitialTapes (word : List Bool) : + Placement.tapes splitView (MachineTableSplit.initialTapes word) (fun _ => []) = + memory word [] [] [] [] [] [] [] := by + funext k; cases k <;> simp [Placement.tapes, splitView, MachineTableSplit.initialTapes, + MachineTableSplit.tapes, memory] + +theorem splitResultTapes (n e : Nat) (rows : List Bool) : + Placement.tapes splitView (MachineTableSplit.resultTapes n e rows) (fun _ => []) = + memory (encodeWords [n, e] ++ rows) rows (encodeWord n) (encodeWord e) [] [] [] [] := by + funext k; cases k <;> simp [Placement.tapes, splitView, MachineTableSplit.resultTapes, + MachineTableSplit.tapes, memory] + +theorem splitTrace {σ : Type} {n d : Nat} (hd : 0 < d) (t : PortTables.Table n d) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program d hd)))^[MachineTableSplit.exactSteps n (n * d) + (PreprocessingPaddingWords.rowsBits t)] + (some ⟨some (.splitCode .copyFirst), ((ambient, false), register), + memory (PortTables.tableBits t) [] [] [] [] [] [] []⟩) = + some ⟨some (.powerCode .init), ((ambient, false), none), + memory (PortTables.tableBits t) (PreprocessingPaddingWords.rowsBits t) + (encodeWord n) (encodeWord (n * d)) [] [] [] []⟩ := by + have h := Placement.trace splitTape splitView splitView_left splitView_right + (Label.splitCode (d := d)) (some (.powerCode .init)) (fun _ => []) + (MachineTableSplit.program (σ := σ × Bool)) (program d hd) (fun _ => rfl) _ _ _ + (MachineTableSplit.splitTrace n (n * d) (PreprocessingPaddingWords.rowsBits t) + (ambient, false) register) + simpa only [Placement.configuration, Placement.label, splitInitialTapes, splitResultTapes, + ← tableBits_split] using h + +theorem powerTapes (input output vertex edge power level : List Bool) : + Placement.tapes powerView (MachineCeilingPower.memory vertex [] power [] level [] [] []) + (memory input output [] edge [] [] [] []) = memory input output vertex edge power level [] [] := by + funext k; cases k <;> rfl + +theorem powerTrace {σ : Type} (d : Nat) (hd : 0 < d) + (input output edge : List Bool) (n : Nat) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program d hd)))^[MachineCeilingPower.totalTime ExpanderFamily.growth n] + (some ⟨some (.powerCode .init), ((ambient, false), register), + memory input output (encodeWord n) edge [] [] [] []⟩) = + some ⟨some .dartSeed, ((ambient, false), none), + memory input output (encodeWord n) edge (encodeWord (PreprocessingLevels.paddedSize n)) + (encodeWord (PreprocessingLevels.boundedLevel n)) [] []⟩ := by + have h := Placement.trace powerTape powerView powerView_left powerView_right + (Label.powerCode (d := d)) (some .dartSeed) (memory input output [] edge [] [] [] []) + (MachineCeilingPower.program ExpanderFamily.growth (σ := σ)) (program d hd) + (fun _ => rfl) _ _ _ (MachineCeilingPower.paddingTrace n ambient register) + simpa only [Placement.configuration, Placement.label, powerTapes] using h + +theorem affineTapes (input output vertex edge power level fuel relation : List Bool) : + MachineUnaryAffineAt.tapes Tape.power Tape.scratch Tape.output + (memory input output vertex edge power level fuel relation) power [] output = + memory input output vertex edge power level fuel relation := by + funext k + cases k <;> simp [MachineUnaryAffineAt.tapes, MachineCopy.forkTapes, memory] + +theorem affineOutputTrace {σ : Type} (d : Nat) (hd : 0 < d) + (coefficient : Nat) (seed scan restore : Label d) (exit : Option (Label d)) + (atSeed : program (σ := σ) d hd seed = MachineUnaryAffineAt.seed (σ := σ × Bool) .output 0 scan) + (atScan : program (σ := σ) d hd scan = MachineUnaryAffineAt.scan (σ := σ × Bool) .power .scratch .output + coefficient scan restore) + (atRestore : program (σ := σ) d hd restore = Reduction.MachineTransfer.loopAt (σ := σ × Bool) + .scratch .power id false restore exit) + (input output vertex edge level fuel relation : List Bool) (m : Nat) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program d hd)))^[1 + 2 * (m + 1)] + (some ⟨some seed, ((ambient, false), register), + memory input output vertex edge (encodeWord m) level fuel relation⟩) = + some ⟨exit, ((ambient, false), none), + memory input (encodeWord (coefficient * m) ++ output) vertex edge + (encodeWord m) level fuel relation⟩ := by + have hs : (advance (TM2.step (program d hd)))^[1] + (some ⟨some seed, ((ambient, false), register), + memory input output vertex edge (encodeWord m) level fuel relation⟩) = + some ⟨some scan, ((ambient, false), register), + memory input (encodeWord 0 ++ output) vertex edge (encodeWord m) level fuel relation⟩ := by + change some (TM2.stepAux (program d hd seed) _ _) = _ + rw [atSeed] + simp [MachineUnaryAffineAt.seed, Reduction.MachineSubstitution.stepAux_pushWord, + TM2.stepAux, encodeWord, memory] + let base := memory input output vertex edge (encodeWord m) level fuel relation + have ht := MachineUnaryAffineAt.affineTrace Tape.power Tape.scratch Tape.output + (by decide) (by decide) (by decide) coefficient scan restore exit (program d hd) + atScan atRestore base m 0 [] output (ambient, false) register + have hstart : MachineUnaryAffineAt.tapes Tape.power Tape.scratch Tape.output base + (encodeWord m ++ []) [] (encodeWord 0 ++ output) = + memory input (encodeWord 0 ++ output) vertex edge (encodeWord m) level fuel relation := by + funext k + cases k <;> simp [MachineUnaryAffineAt.tapes, MachineCopy.forkTapes, base, memory] + have hfinish : MachineUnaryAffineAt.tapes Tape.power Tape.scratch Tape.output base + (encodeWord m ++ []) [] (encodeWord (coefficient * m + 0) ++ output) = + memory input (encodeWord (coefficient * m) ++ output) vertex edge + (encodeWord m) level fuel relation := by + funext k + cases k <;> simp [MachineUnaryAffineAt.tapes, MachineCopy.forkTapes, base, memory] + rw [hstart, hfinish] at ht + exact appendTrace _ hs ht + +theorem headersTrace {σ : Type} (d : Nat) (hd : 0 < d) + (input output vertex edge level : List Bool) (m : Nat) (ambient : σ) + (register : Option Bool) : + (advance (TM2.step (program d hd)))^[4 * (m + 1) + 2] + (some ⟨some .dartSeed, ((ambient, false), register), + memory input output vertex edge (encodeWord m) level [] []⟩) = + some ⟨some .copyFirst, ((ambient, false), none), + memory input (encodeWords [m, m * d] ++ output) vertex edge (encodeWord m) level [] []⟩ := by + have h₁ := affineOutputTrace d hd d .dartSeed .dartScan .dartRestore (some .vertexSeed) + rfl rfl rfl input output vertex edge level [] [] m ambient register + have h₂ := affineOutputTrace d hd 1 .vertexSeed .vertexScan .vertexRestore (some .copyFirst) + rfl rfl rfl input (encodeWord (d * m) ++ output) vertex edge level [] [] m ambient none + have h := appendTrace _ h₁ h₂ + simpa only [Nat.one_mul, Nat.mul_comm d m, encodeWords, List.append_nil, List.append_assoc, + show (1 + 2 * (m + 1)) + (1 + 2 * (m + 1)) = 4 * (m + 1) + 2 by omega] using h + +theorem copyPowerTrace {σ : Type} (d : Nat) (hd : 0 < d) + (input output vertex edge level : List Bool) (m : Nat) (ambient : σ) + (register : Option Bool) : + (advance (TM2.step (program d hd)))^[2 * (m + 2)] + (some ⟨some .copyFirst, ((ambient, false), register), + memory input output vertex edge (encodeWord m) level [] []⟩) = + some ⟨some (.subtractCode .subtract), ((ambient, false), none), + memory input output vertex edge (encodeWord m) level (encodeWord m) []⟩ := by + have h := MachineCopy.copyTrace Tape.power Tape.fuel Tape.scratch + (by decide) (by decide) (by decide) false (Label.copyFirst (d := d)) .copySecond + (some (.subtractCode .subtract)) (program d hd) rfl rfl + (memory input output vertex edge (encodeWord m) level [] []) rfl (ambient, false) register + simpa only [memory, encodeWord_length, List.append_nil, update_fuel] using h + +theorem subtractTapes (input output vertex edge power level fuel : List Bool) : + Placement.tapes subtractView + (MachineCloudPadding.memory input output vertex [] [] [] fuel level [] []) + (memory [] [] [] edge power [] [] []) = + memory input output vertex edge power level fuel [] := by + funext k; cases k <;> rfl + +theorem subtractTrace {σ : Type} (d : Nat) (hd : 0 < d) + (input output edge power level : List Bool) (n m : Nat) (hnm : n ≤ m) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program d hd)))^[2 * n + 2] + (some ⟨some (.subtractCode .subtract), ((ambient, false), register), + memory input output (encodeWord n) edge power level (encodeWord m) []⟩) = + some ⟨some (.rowsCode (.inr .initialize)), ((ambient, false), none), + memory input output (encodeWord n) edge power level (encodeWord (m - n)) []⟩ := by + have h := Placement.trace subtractTape subtractView subtractView_left subtractView_right + (Label.subtractCode (d := d)) (some (.rowsCode (.inr .initialize))) + (memory [] [] [] edge power [] [] []) + (MachineCloudPadding.program (σ := σ)) (program d hd) (fun _ => rfl) _ _ _ + (MachineCloudPadding.subtractTrace input output level n m hnm ambient register) + simpa only [Placement.configuration, Placement.label, subtractTapes] using h + +def rowBoolTapes (base : (k : MachinePaddingRows.Tape) → List (MachinePaddingRows.Alphabet k)) : + MachinePaddingRows.Tape → List Bool + | .inl k => base (.inl k) + | .inr k => base (.inr k) + +private theorem transport_tapes_apply {K : Type} {Γ Δ : K → Type} + (h : Γ = Δ) (base : (k : K) → List (Γ k)) (k : K) : + MachineAlphabetTransport.tapes h base k = + Eq.mp (congrArg (fun alphabet => List (alphabet k)) h) (base k) := by + cases h + rfl + +theorem rowCastTapes (base : (k : MachinePaddingRows.Tape) → List (MachinePaddingRows.Alphabet k)) : + MachineAlphabetTransport.tapes rowAlphabet_eq base = rowBoolTapes base := by + funext k + rw [transport_tapes_apply] + cases k <;> rfl + +theorem rowInitialTapes (input power level output : List Bool) (v e fuel : Nat) : + Placement.tapes rowView (rowBoolTapes (MachinePaddingRows.initialTapes v e fuel output)) + (memory input [] [] [] power level [] []) = + memory input output (encodeWord v) (encodeWord e) power level (encodeWord fuel) [] := by + funext k + cases k <;> rfl + +theorem rowFinalTapes (input power level output : List Bool) (v e fuel : Nat) : + Placement.tapes rowView (rowBoolTapes (MachinePaddingRows.tapes v e fuel output)) + (memory input [] [] [] power level [] []) = + memory input output (encodeWord v) (encodeWord e) power level (encodeWord fuel) + MachineDummyRows.trueBits := by + funext k + cases k <;> rfl + +def rowTime {n d m : Nat} (t : PortTables.Table n d) : Nat := + MachinePaddingRows.steps d n (n * d) (MachinePaddingTable.initialOutput (m := m) t) (m - n) + 1 + +private theorem frameTrace {K Λ σ τ : Type} {Γ : K → Type} [DecidableEq K] + (source : Λ → TM2.Stmt Γ Λ σ) (ambient : τ) (n : Nat) + (a b : TM2.Cfg Γ Λ σ) (run : (advance (TM2.step source))^[n] (some a) = some b) : + (advance (TM2.step (MachineStateFrame.frameProgram source)))^[n] + (some (MachineStateFrame.frameConfiguration ambient a)) = + some (MachineStateFrame.frameConfiguration ambient b) := by + have h := MachineStateFrame.frame_iterate source ambient n (some a) + simpa only [Option.map_some, run] using h + +theorem rowsTrace {σ : Type} {n d m : Nat} (hd : 0 < d) (t : PortTables.Table n d) + (hnm : n ≤ m) (input power level : List Bool) (ambient : σ) : + (advance (TM2.step (program d hd)))^[rowTime (m := m) t] + (some ⟨some (.rowsCode (.inr .initialize)), ((ambient, false), none), + memory input (MachinePaddingTable.initialOutput (m := m) t) + (encodeWord n) (encodeWord (n * d)) power level (encodeWord (m - n)) []⟩) = + some ⟨some .cleanVertex, ((ambient, false), none), + memory input (PortTables.tableBits (PreprocessingPaddingTables.pad t hnm)) + (encodeWord m) (encodeWord (m * d)) power level (encodeWord 0) + MachineDummyRows.trueBits⟩ := by + have hraw := (MachinePaddingTable.execution t hnm hd).evals_in_steps + change (advance (TM2.step (MachinePaddingRows.program d hd)))^[rowTime (m := m) t] + (some ⟨some (.inr .initialize), (((), none), ()), + MachinePaddingRows.initialTapes n (n * d) (m - n) + (MachinePaddingTable.initialOutput (m := m) t)⟩) = + some (MachinePaddingRows.cfg d none m (m * d) 0 + (PortTables.tableBits (PreprocessingPaddingTables.pad t hnm))) at hraw + have hb := MachineAlphabetTransport.successfulTrace rowAlphabet_eq + (MachinePaddingRows.program d hd) _ _ _ hraw + have hf := frameTrace + (MachineAlphabetTransport.program rowAlphabet_eq (MachinePaddingRows.program d hd)) + (ambient, false) _ _ _ hb + have hs := MachineStateEquiv.trace (rowStateEquiv σ) + (MachineStateFrame.frameProgram + (MachineAlphabetTransport.program rowAlphabet_eq (MachinePaddingRows.program d hd))) + _ _ _ hf + have hp := Placement.trace rowTape rowView rowView_left rowView_right + (Label.rowsCode (d := d)) (some .cleanVertex) (memory input [] [] [] power level [] []) + (rowProgram d hd (σ := σ)) (program d hd) (fun _ => rfl) _ _ _ hs + simpa only [Placement.configuration, Placement.label, MachineStateEquiv.configuration, + MachineStateFrame.frameConfiguration, MachineAlphabetTransport.configuration_mk, + rowCastTapes, MachinePaddingRows.cfg, rowStateEquiv, Equiv.coe_fn_mk, + rowInitialTapes, rowFinalTapes] using hp + +def cleanupTime (d m : Nat) : Nat := 2 * m + m * d + 8201 + +theorem cleanupTrace {σ : Type} (d : Nat) (hd : 0 < d) + (input output level : List Bool) (m : Nat) (ambient : σ) : + (advance (TM2.step (program d hd)))^[cleanupTime d m] + (some ⟨some .cleanVertex, ((ambient, false), none), + memory input output (encodeWord m) (encodeWord (m * d)) (encodeWord m) level + (encodeWord 0) MachineDummyRows.trueBits⟩) = + some ⟨none, ((ambient, false), none), memory input output [] [] [] level [] []⟩ := by + have h₁ := (MachineDrain.drainInTime Tape.vertex (Label.cleanVertex (d := d)) (some .cleanEdge) + (program d hd) rfl + (memory input output (encodeWord m) (encodeWord (m * d)) (encodeWord m) level + (encodeWord 0) MachineDummyRows.trueBits) (ambient, false) none).evals_in_steps + have h₂ := (MachineDrain.drainInTime Tape.edge (Label.cleanEdge (d := d)) (some .cleanPower) + (program d hd) rfl + (memory input output [] (encodeWord (m * d)) (encodeWord m) level + (encodeWord 0) MachineDummyRows.trueBits) (ambient, false) none).evals_in_steps + have h₃ := (MachineDrain.drainInTime Tape.power (Label.cleanPower (d := d)) (some .cleanRelation) + (program d hd) rfl + (memory input output [] [] (encodeWord m) level (encodeWord 0) MachineDummyRows.trueBits) + (ambient, false) none).evals_in_steps + have h₄ := (MachineDrain.drainInTime Tape.relation (Label.cleanRelation (d := d)) (some .cleanFuel) + (program d hd) rfl + (memory input output [] [] [] level (encodeWord 0) MachineDummyRows.trueBits) + (ambient, false) none).evals_in_steps + have h₅ := (MachineDrain.drainInTime Tape.fuel (Label.cleanFuel (d := d)) none + (program d hd) rfl (memory input output [] [] [] level (encodeWord 0) []) + (ambient, false) none).evals_in_steps + simp only [MachineDrain.drainInTime, memory, encodeWord_length, MachineDummyRows.trueBits_length, + update_vertex, update_edge, update_power, update_relation, update_fuel] at h₁ h₂ h₃ h₄ h₅ + have h := appendTrace _ (appendTrace _ (appendTrace _ (appendTrace _ h₁ h₂) h₃) h₄) h₅ + have ht : cleanupTime d m = (((m + 2 + (m * d + 2)) + (m + 2)) + 8193) + 2 := by + unfold cleanupTime + omega + rw [ht] + exact h + +def otherTime {n d : Nat} (t : PortTables.Table n d) : Nat := + MachineTableSplit.exactSteps n (n * d) (PreprocessingPaddingWords.rowsBits t) + + MachineCeilingPower.totalTime ExpanderFamily.growth n + + (4 * (PreprocessingLevels.paddedSize n + 1) + 2) + + (2 * (PreprocessingLevels.paddedSize n + 2)) + (2 * n + 2) + + cleanupTime d (PreprocessingLevels.paddedSize n) + +def totalTime {n d : Nat} (t : PortTables.Table n d) : Nat := + otherTime t + rowTime (m := PreprocessingLevels.paddedSize n) t + +theorem vertexPaddingTrace {σ : Type} {n d : Nat} (hd : 0 < d) (t : PortTables.Table n d) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program d hd)))^[totalTime t] + (some ⟨some (.splitCode .copyFirst), ((ambient, false), register), + memory (PortTables.tableBits t) [] [] [] [] [] [] []⟩) = + some ⟨none, ((ambient, false), none), + memory (PortTables.tableBits t) + (PortTables.tableBits (PreprocessingPaddingTables.pad t (PreprocessingLevels.le_paddedSize n))) + [] [] [] (encodeWord (PreprocessingLevels.boundedLevel n)) [] []⟩ := by + let m := PreprocessingLevels.paddedSize n + let level := encodeWord (PreprocessingLevels.boundedLevel n) + let input := PortTables.tableBits t + let rows := PreprocessingPaddingWords.rowsBits t + let initialOutput := MachinePaddingTable.initialOutput (m := m) t + have h₁ := splitTrace hd t ambient register + have h₂ := powerTrace d hd input rows (encodeWord (n * d)) n ambient none + have h₃ := headersTrace d hd input rows (encodeWord n) (encodeWord (n * d)) level m ambient none + have h₄ := copyPowerTrace d hd input initialOutput (encodeWord n) (encodeWord (n * d)) + level m ambient none + have h₅ := subtractTrace d hd input initialOutput (encodeWord (n * d)) (encodeWord m) + level n m (PreprocessingLevels.le_paddedSize n) ambient none + have h₆ := rowsTrace hd t (PreprocessingLevels.le_paddedSize n) input (encodeWord m) level ambient + have h₇ := cleanupTrace d hd input + (PortTables.tableBits (PreprocessingPaddingTables.pad t (PreprocessingLevels.le_paddedSize n))) + level m ambient + have h := appendTrace _ (appendTrace _ (appendTrace _ (appendTrace _ + (appendTrace _ (appendTrace _ h₁ h₂) h₃) h₄) h₅) h₆) h₇ + have ht : totalTime t = + (((((MachineTableSplit.exactSteps n (n * d) rows + + MachineCeilingPower.totalTime ExpanderFamily.growth n) + (4 * (m + 1) + 2)) + + (2 * (m + 2))) + (2 * n + 2)) + rowTime (m := m) t) + cleanupTime d m := by + dsimp only [totalTime, otherTime, m, rows] + omega + rw [ht] + exact h + +theorem rows_length_le {n d : Nat} (t : PortTables.Table n d) : + (PreprocessingPaddingWords.rowsBits t).length ≤ (PortTables.tableBits t).length := by + rw [tableBits_split, List.length_append] + omega + +theorem darts_length_le {n d : Nat} (t : PortTables.Table n d) : + n * d ≤ (PortTables.tableBits t).length := + GraphTables.darts_le_tableBits_length (PortTables.graphTable t) + +theorem power_length_bound {n d : Nat} (t : PortTables.Table n d) : + PreprocessingLevels.paddedSize n ≤ ExpanderFamily.growth * ((PortTables.tableBits t).length + 1) := + (MachineCeilingPower.paddingOutput_bounds n).2.2.trans + (Nat.mul_le_mul_left _ (Nat.add_le_add_right (PortTables.vertices_le_tableBits_length t) 1)) + +theorem initialOutput_length {n d m : Nat} (t : PortTables.Table n d) : + (MachinePaddingTable.initialOutput (m := m) t).length = + m + m * d + 2 + (PreprocessingPaddingWords.rowsBits t).length := by + simp only [MachinePaddingTable.initialOutput, List.length_append, encodeWords_length, + List.sum_cons, List.sum_nil, List.length_cons, List.length_nil] + omega + +def intermediateCoefficient (d : Nat) : Nat := (d + 2) * ExpanderFamily.growth + 8 + +noncomputable def intermediatePolynomial (d : Nat) : Polynomial Nat := + Polynomial.C (intermediateCoefficient d) * (Polynomial.X + 1) + +theorem intermediate_bound {n d : Nat} (t : PortTables.Table n d) : + MachinePaddingBounds.inputSize n (n * d) (PreprocessingLevels.paddedSize n - n) + (MachinePaddingTable.initialOutput (m := PreprocessingLevels.paddedSize n) t) ≤ + (intermediatePolynomial d).eval (PortTables.tableBits t).length := by + have hn := PortTables.vertices_le_tableBits_length t + have he := darts_length_le t + have hr := rows_length_le t + have hm := power_length_bound t + have hs := Nat.sub_le (PreprocessingLevels.paddedSize n) n + have hmul := Nat.mul_le_mul_left (d + 2) hm + simp only [MachinePaddingBounds.inputSize, encodeWord_length, initialOutput_length, + intermediatePolynomial, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_add, + Polynomial.eval_X, Polynomial.eval_one, intermediateCoefficient] + nlinarith + +noncomputable def otherPolynomial (d : Nat) : Polynomial Nat := + Polynomial.C (ExpanderFamily.growth + 8) * (Polynomial.X + 1) ^ 2 + + Polynomial.C ((d + 8) * ExpanderFamily.growth + 24) * (Polynomial.X + 1) + 8222 + +theorem otherTime_le {n d : Nat} (t : PortTables.Table n d) : + otherTime t ≤ (otherPolynomial d).eval (PortTables.tableBits t).length := by + have hs := MachineTableSplit.exactSteps_le n (n * d) (PreprocessingPaddingWords.rowsBits t) + rw [← tableBits_split, MachineTableSplit.timePolynomial_eval] at hs + have hc := MachineCeilingPower.totalTime_le ExpanderFamily.growth n + have hn := PortTables.vertices_le_tableBits_length t + have hm := power_length_bound t + have hsq := Nat.mul_le_mul_left (ExpanderFamily.growth + 8) + (Nat.pow_le_pow_left (Nat.add_le_add_right hn 1) 2) + have hmul := Nat.mul_le_mul_left (d + 8) hm + simp only [otherPolynomial, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_one, Polynomial.eval_ofNat] + unfold otherTime cleanupTime + unfold MachineCeilingPower.timeBound at hc + nlinarith + +noncomputable def timePolynomial (d : Nat) : Polynomial Nat := + otherPolynomial d + (MachinePaddingCertificate.timePolynomial d).comp (intermediatePolynomial d) + +theorem totalTime_le {n d : Nat} (hd : 0 < d) (t : PortTables.Table n d) : + totalTime t ≤ (timePolynomial d).eval (PortTables.tableBits t).length := by + have hrow := (MachinePaddingTable.execution t (PreprocessingLevels.le_paddedSize n) hd).steps_le_m + change rowTime (m := PreprocessingLevels.paddedSize n) t ≤ + (MachinePaddingCertificate.timePolynomial d).eval + (MachinePaddingBounds.inputSize n (n * d) (PreprocessingLevels.paddedSize n - n) + (MachinePaddingTable.initialOutput (m := PreprocessingLevels.paddedSize n) t)) at hrow + have hmono := natPolynomial_eval_mono (MachinePaddingCertificate.timePolynomial d) (intermediate_bound t) + have h := Nat.add_le_add (otherTime_le t) (hrow.trans hmono) + simpa only [totalTime, timePolynomial, Polynomial.eval_add, Polynomial.eval_comp] using h + +def vertexPaddingInTime {σ : Type} {n d : Nat} (hd : 0 < d) (t : PortTables.Table n d) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program d hd)) + ⟨some (.splitCode .copyFirst), ((ambient, false), register), + memory (PortTables.tableBits t) [] [] [] [] [] [] []⟩ + (some ⟨none, ((ambient, false), none), + memory (PortTables.tableBits t) + (PortTables.tableBits (PreprocessingPaddingTables.pad t (PreprocessingLevels.le_paddedSize n))) + [] [] [] (encodeWord (PreprocessingLevels.boundedLevel n)) [] []⟩) + ((timePolynomial d).eval (PortTables.tableBits t).length) where + steps := totalTime t + evals_in_steps := vertexPaddingTrace hd t ambient register + steps_le_m := totalTime_le hd t + +def machine (d : Nat) (hd : 0 < d) : FinTM2 where + K := Tape + k₀ := .original + k₁ := .output + Γ := Alphabet + Λ := Label d + main := .splitCode .copyFirst + σ := State Unit + initialState := (((), false), none) + m := program d hd + +theorem alphabet_finite (d : Nat) (hd : 0 < d) : ∀ k, Finite ((machine d hd).Γ k) := by + intro k + exact inferInstanceAs (Finite Bool) + +end IndependentSetsGames.Foundations.Complexity.MachineVertexPadding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/OldSelectSteps.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/OldSelectSteps.lean new file mode 100644 index 0000000000000000000000000000000000000000..2da28743f7163a6e04da7663d0e4dc02e6a00910 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/OldSelectSteps.lean @@ -0,0 +1,428 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineCloudPadding +import OAI.Combinatorics.IndependentSets.Machines.SelectAlphabet + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow +open Turing MachineComposition +open PCP +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) +variable {K Λ σ : Type} [DecidableEq K] + +def oldSelectSteps (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) : Nat := + (2 * (i.val + 1) + 1) + (2 * (v.val + 1) + 1) + + MachineCloudSelect.cloudSelectSteps t v i [] + (v.val + i.val + 7) + +theorem selectOldTrace (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) (o : Nat) (ambient : σ) : + (advance (TM2.step selectProgram))^[oldSelectSteps t v i] + (some ⟨some (.inr (.copy .oldLocal .seed)), selectCleanState ambient none, + selectMemory (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) o t.darts [] [] [] [] [] []⟩) = + some ⟨none, selectCleanState ambient none, + selectMemory (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) o t.darts [] + (encodeWord (PreprocessingCloudIndex.cloudSelect t v i).val.val) [] [] [] []⟩ := by + let graph := GraphTables.tableBits t + let k := PreprocessingCloudIndex.cloudSize t v + have hi := selectCopyTrace .oldLocal + (selectMemory graph i.val v.val k o t.darts [] [] [] [] [] []) + i.val rfl rfl ambient none + simp only [copyDestination, afterCopy, selectMemory_query, update_selectMemory_query, List.append_nil] at hi + have hv := selectCopyTrace .oldOwner + (selectMemory graph i.val v.val k o t.darts (encodeWord i.val) [] [] [] [] []) + v.val rfl rfl ambient none + simp only [copyDestination, afterCopy, selectMemory_query, update_selectMemory_query] at hv + have hc := selectCloudTrace t v i (selectExtraMemory i.val v.val k o t.darts [] [] [] []) + ambient none + have hq : MachineCloudSelect.queryWord v.val i.val [] = + encodeWord v.val ++ encodeWord i.val := by + simp only [MachineCloudSelect.queryWord, MachineCloudRank.queryWord, List.append_nil] + change (advance (TM2.step selectProgram))^[MachineCloudSelect.cloudSelectSteps t v i []] + (some ⟨some (.inl (.inr .initialize)), selectCleanState ambient none, + selectMemory graph i.val v.val k o t.darts + (MachineCloudSelect.queryWord v.val i.val []) [] [] [] [] []⟩) = + some ⟨some (.inr (.cleanup 0)), selectCleanState ambient none, + selectMemory graph i.val v.val k o t.darts + (MachineCloudSelect.queryWord v.val i.val []) + (encodeWord (PreprocessingCloudIndex.cloudSelect t v i).val.val) [] [] [] []⟩ at hc + rw [hq] at hc + have hd := selectCleanupTrace graph i.val v.val k o t.darts + (encodeWord v.val ++ encodeWord i.val) + (encodeWord (PreprocessingCloudIndex.cloudSelect t v i).val.val) [] [] [] [] ambient + have hn : (encodeWord v.val ++ encodeWord i.val).length + ([] : List Bool).length + ([] : List Bool).length + + ([] : List Bool).length + ([] : List Bool).length + 5 = v.val + i.val + 7 := by + simp only [List.length_append, encodeWord_length, List.length_nil] + omega + rw [hn] at hd + exact joinTrace (joinTrace (joinTrace hi hv) hc) hd + +def dummySelectSteps (j k o m : Nat) : Nat := + (2 * (j + 1) + 1) + (2 * (k + 1) + 1) + (k + 1) + + (2 * (j - k + 1) + 1) + 2 * (o + 1) + 2 * (m + 1) + (j + k + 7) + +theorem dummySelectSteps_eq (j k o m : Nat) (h : k ≤ j) : + dummySelectSteps j k o m = 5 * j + 2 * k + 2 * o + 2 * m + 21 := by + unfold dummySelectSteps + omega + +theorem selectDummyTrace (graph : List Bool) (j v k o m : Nat) (hk : k ≤ j) + (ambient : σ) : + (advance (TM2.step selectProgram))^[dummySelectSteps j k o m] + (some ⟨some (.inr (.copy .dummyLocal .seed)), selectCleanState ambient none, + selectMemory graph j v k o m [] [] [] [] [] []⟩) = + some ⟨none, selectCleanState ambient none, + selectMemory graph j v k o m [] (encodeWord (m + o + (j - k))) [] [] [] []⟩ := by + have hjcopy := selectCopyTrace .dummyLocal + (selectMemory graph j v k o m [] [] [] [] [] []) j rfl rfl ambient none + simp only [copyDestination, afterCopy, selectMemory_extra, selectExtraMemory, + update_selectMemory_local, List.append_nil] at hjcopy + have hkcopy := selectCopyTrace .dummySize + (selectMemory graph j v k o m [] [] [] [] (encodeWord j) []) k rfl rfl ambient none + simp only [copyDestination, afterCopy, selectMemory_extra, selectExtraMemory, + update_selectMemory_size, List.append_nil] at hkcopy + have scanFrame (left right savedLeft savedRight : List Bool) : + MachineUnaryLessAt.tapes subtractSlots + (selectMemory graph j v k o m [] [] [] [] [] []) + left right savedLeft savedRight = + selectMemory graph j v k o m [] [] savedLeft savedRight left right := by + simp only [MachineUnaryLessAt.tapes, + show subtractSlots 0 = .inr .localWork from rfl, + show subtractSlots 1 = .inr .sizeWork from rfl, + show subtractSlots 2 = .inr .savedLeft from rfl, + show subtractSlots 3 = .inr .savedRight from rfl, + update_selectMemory_local, update_selectMemory_size, + update_selectMemory_left, update_selectMemory_right] + have hscan := MachineUnaryLessAt.scanTrace subtractSlots (.inr .subtract) + (.inr (.copy .dummyDifference .seed)) selectProgram + (by rw [selectProgram_control]; rfl) + (selectMemory graph j v k o m [] [] [] [] [] []) + j k [] [] [] [] (ambient, MachineCloudSelect.Phase.checking) false none + simp only [List.append_nil, scanFrame, Nat.min_eq_right hk, Nat.sub_eq_zero_of_le hk, + show ¬ j < k from Nat.not_lt_of_ge hk, decide_false] at hscan + have hdiffcopy := selectCopyTrace .dummyDifference + (selectMemory graph j v k o m [] [] (List.replicate k true) (List.replicate k true) + (encodeWord (j - k)) (encodeWord 0)) (j - k) rfl rfl ambient none + simp only [copyDestination, afterCopy, selectMemory_output, update_selectMemory_output, List.append_nil] at hdiffcopy + have hprefix := selectAddTrace .prefixOffset + (selectMemory graph j v k o m [] (encodeWord (j - k)) + (List.replicate k true) (List.replicate k true) (encodeWord (j - k)) (encodeWord 0)) + o (j - k) rfl rfl rfl ambient + simp only [afterAdd, update_selectMemory_output] at hprefix + have hm := selectAddTrace .darts + (selectMemory graph j v k o m [] (encodeWord (o + (j - k))) + (List.replicate k true) (List.replicate k true) (encodeWord (j - k)) (encodeWord 0)) + m (o + (j - k)) rfl rfl rfl ambient + simp only [afterAdd, update_selectMemory_output, ← Nat.add_assoc] at hm + have hcleanup := selectCleanupTrace graph j v k o m [] + (encodeWord (m + o + (j - k))) (List.replicate k true) (List.replicate k true) + (encodeWord (j - k)) (encodeWord 0) ambient + have hcleanSteps : ([] : List Bool).length + (encodeWord (j - k)).length + (encodeWord 0).length + + (List.replicate k true).length + (List.replicate k true).length + 5 = j + k + 7 := by + simp only [List.length_nil, encodeWord_length, List.length_replicate] + omega + rw [hcleanSteps] at hcleanup + exact joinTrace (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace + hjcopy hkcopy) hscan) hdiffcopy) hprefix) hm) hcleanup + +def selectionSteps (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (PreprocessingCloudIndex.cloudSize t v + padding v)) : Nat := + MachineUnaryLessAt.steps i.val (PreprocessingCloudIndex.cloudSize t v) + 1 + + if hi : i.val < PreprocessingCloudIndex.cloudSize t v then + oldSelectSteps t v ⟨i.val, hi⟩ + else dummySelectSteps i.val (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts + +theorem selectionTrace (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (PreprocessingCloudIndex.cloudSize t v + padding v)) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step selectProgram))^[selectionSteps t padding v i] + (some ⟨some (.inr (.compare .scan)), selectCleanState ambient register, + selectMemory (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts [] [] [] [] [] []⟩) = + some ⟨none, selectCleanState ambient none, + selectMemory (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts [] + (encodeWord (PreprocessingInternalRows.selectedIndex t padding v i)) [] [] [] []⟩ := by + have hc := selectComparisonTrace + (selectMemory (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts [] [] [] [] [] []) + i.val (PreprocessingCloudIndex.cloudSize t v) rfl rfl rfl rfl ambient register + by_cases hi : i.val < PreprocessingCloudIndex.cloudSize t v + · simp only [ite_eq_left hi] at hc + have hb := selectOldTrace t v ⟨i.val, hi⟩ + (PreprocessingPaddingOffsets.offset padding v.val) ambient + simpa only [selectionSteps, dite_eq_left hi, + PreprocessingInternalRows.selectedIndex_old t padding v i hi] using joinTrace hc hb + · simp only [ite_eq_right hi] at hc + have hb := selectDummyTrace (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts (Nat.le_of_not_gt hi) ambient + simpa only [selectionSteps, dite_eq_right hi, + PreprocessingInternalRows.selectedIndex_dummy t padding v i (Nat.le_of_not_gt hi)] + using joinTrace hc hb + +theorem selectionSteps_le (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (PreprocessingCloudIndex.cloudSize t v + padding v)) : + selectionSteps t padding v i ≤ + 10 * (GraphTables.tableBits t).length + 16 * i.val + 13 * v.val + + 5 * PreprocessingCloudIndex.cloudSize t v + + 2 * PreprocessingPaddingOffsets.offset padding v.val + 2 * t.darts + 57 := by + unfold selectionSteps + split + · rename_i hi + have hb := MachineCloudSelect.cloudSelectSteps_le t v ⟨i.val, hi⟩ [] + have hmin : min i.val (PreprocessingCloudIndex.cloudSize t v) = i.val := Nat.min_eq_left hi.le + simp only [oldSelectSteps, MachineUnaryLessAt.steps, hmin] + simp only [MachineCloudSelect.queryWord, MachineCloudRank.queryWord, + List.length_append, encodeWord_length, List.length_nil] at hb + omega + · rename_i hi + rw [dummySelectSteps_eq _ _ _ _ (Nat.le_of_not_gt hi)] + have hmin := Nat.min_le_right i.val (PreprocessingCloudIndex.cloudSize t v) + unfold MachineUnaryLessAt.steps + omega + +def selectorMachine : FinTM2 where + K := SelectTape + k₀ := .inl (.inl .original) + k₁ := selectOutput + Γ := SelectAlphabet + Λ := SelectLabel + main := .inr (.compare .scan) + σ := SelectState Unit + initialState := selectCleanState () none + m := selectProgram + +def selectionInTime (t : GraphTables.Table) (padding : Fin t.vertices → Nat) + (v : Fin t.vertices) (i : Fin (PreprocessingCloudIndex.cloudSize t v + padding v)) + (register : Option Bool) : + StateTransition.EvalsToInTime selectorMachine.step + ⟨some (.inr (.compare .scan)), selectCleanState () register, + selectMemory (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts [] [] [] [] [] []⟩ + (some ⟨none, selectCleanState () none, + selectMemory (GraphTables.tableBits t) i.val v.val + (PreprocessingCloudIndex.cloudSize t v) + (PreprocessingPaddingOffsets.offset padding v.val) t.darts [] + (encodeWord (PreprocessingInternalRows.selectedIndex t padding v i)) [] [] [] []⟩) + (10 * (GraphTables.tableBits t).length + 16 * i.val + 13 * v.val + + 5 * PreprocessingCloudIndex.cloudSize t v + + 2 * PreprocessingPaddingOffsets.offset padding v.val + 2 * t.darts + 57) where + steps := selectionSteps t padding v i + evals_in_steps := selectionTrace t padding v i () register + steps_le_m := selectionSteps_le t padding v i + +def coreRotorTapes : Fin 8 → CoreTape := ![3, 7, 10, 11, 12, 9, 13, 14] + +def coreFinishTapes : Fin 8 → CoreTape := ![1, 15, 14, 9, 24, 25, 26, 8] + +def coreSelectTape : SelectTape → CoreTape + | .inl (.inl .original) => 0 + | .inl (.inl .work) => 17 + | .inl (.inl .target) => 16 + | .inl (.inl .scratch) => 9 + | .inl (.inl .count) => 18 + | .inl (.inl .spare) => 19 + | .inl (.inr ()) => 15 + | .inr .localIndex => 13 + | .inr .owner => 2 + | .inr .cloudSize => 4 + | .inr .prefixOffset => 5 + | .inr .darts => 6 + | .inr .savedLeft => 20 + | .inr .savedRight => 21 + | .inr .localWork => 22 + | .inr .sizeWork => 23 + +def coreSelectView : CoreTape → Option SelectTape := + ![some (.inl (.inl .original)), none, some (.inr .owner), none, + some (.inr .cloudSize), some (.inr .prefixOffset), some (.inr .darts), none, none, + some (.inl (.inl .scratch)), none, none, none, some (.inr .localIndex), none, + some (.inl (.inr ())), some (.inl (.inl .target)), some (.inl (.inl .work)), + some (.inl (.inl .count)), some (.inl (.inl .spare)), + some (.inr .savedLeft), some (.inr .savedRight), + some (.inr .localWork), some (.inr .sizeWork), none, none, none] + +theorem coreSelectView_left (k : SelectTape) : coreSelectView (coreSelectTape k) = some k := by + cases k with + | inl k => + cases k with + | inl k => cases k <;> rfl + | inr k => cases k; rfl + | inr k => cases k <;> rfl + +theorem coreSelectView_right (j : CoreTape) (k : SelectTape) + (h : coreSelectView j = some k) : coreSelectTape k = j := by + fin_cases j <;> simp [coreSelectView] at h + all_goals subst k; rfl + +def coreCleanupTape : Fin 10 → CoreTape := ![10, 11, 12, 13, 14, 15, 9, 16, 17, 18] + +def coreRotorStateEquiv (σ : Type) (q : Nat) : + MachineFixedDivMod.State + ((σ × MachineFixedBlockMap.Buffer 4096) × (Bool × MachineCloudSelect.Phase)) q ≃ + CoreState σ q where + toFun s := ((s.1.1.1.1, (s.1.1.1.2, (s.1.2, s.1.1.2))), s.2) + invFun s := ((((s.1.1, s.1.2.1), s.1.2.2.2), s.1.2.2.1), s.2) + left_inv s := by rcases s with ⟨⟨⟨⟨a,b⟩,⟨c,d⟩⟩,e⟩,f⟩; rfl + right_inv s := by rcases s with ⟨⟨a,⟨b,⟨c,⟨d,e⟩⟩⟩⟩,f⟩; rfl + +def coreSelectStateEquiv (σ : Type) (q : Nat) : + SelectState (σ × (MachineFixedBlockMap.Buffer 4096 × Fin q)) ≃ CoreState σ q where + toFun s := ((s.1.1.1.1, (s.1.1.1.2.1, (s.1.1.1.2.2, (s.1.2, s.1.1.2)))), s.2) + invFun s := ((((s.1.1, (s.1.2.1, s.1.2.2.1)), s.1.2.2.2.2), s.1.2.2.2.1), s.2) + left_inv s := by rcases s with ⟨⟨⟨⟨a,⟨b,c⟩⟩,d⟩,e⟩,f⟩; rfl + right_inv s := by rcases s with ⟨⟨a,⟨b,⟨c,⟨d,e⟩⟩⟩⟩,f⟩; rfl + +def coreAfterCleanup {q : Nat} (labels : CoreLabel q → Λ) (exit : Option Λ) (i : Fin 10) : + Option Λ := + if h : i.val + 1 < 10 then some (labels (.cleanup ⟨i.val + 1,h⟩)) else exit + +def coreInstruction (q : Nat) (positive : 0 < q) (p : Fin q) + (labels : CoreLabel q → Λ) (exit : Option Λ) : + CoreLabel q → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q) + | .rotor stage => MachineStateEquiv.statement (coreRotorStateEquiv σ q) + (rotorInstruction q positive p coreRotorTapes + (fun l => labels (.rotor l)) (some (labels (.select (.inr (.compare .scan))))) stage) + | .select stage => MachineCloudPadding.Placement.statement coreSelectTape + (fun l => labels (.select l)) (some (labels (.finish .seedReturn))) + (MachineStateEquiv.statement (coreSelectStateEquiv σ q) (selectProgram stage)) + | .finish stage => finishInstruction q coreFinishTapes + (fun l => labels (.finish l)) (some (labels (.cleanup 0))) stage + | .cleanup i => MachineDrain.drain (coreCleanupTape i) (labels (.cleanup i)) + (coreAfterCleanup labels exit i) + +def coreInitialState (q : Nat) (positive : 0 < q) (ambient : σ) : CoreState σ q := + ((ambient, (MachineFixedBlockMap.emptyBuffer 4096, + (MachineFixedDivMod.residue q positive 0, (false, MachineCloudSelect.Phase.checking)))), none) + +def coreMachine (q : Nat) (positive : 0 < q) (p : Fin q) : FinTM2 where + K := CoreTape + k₀ := 0 + k₁ := 8 + Γ _ := Bool + Λ := CoreLabel q + main := coreEntry q + σ := CoreState Unit q + initialState := coreInitialState q positive () + m := coreInstruction q positive p id none + +def coreMemory (graph : List Bool) (x v i k o m : Nat) (rotor output : List Bool) + (query scan flat localIndex returnPort selected : List Bool) : CoreTape → List Bool := + ![graph, encodeWord x, encodeWord v, encodeWord i, encodeWord k, encodeWord o, + encodeWord m, rotor, output, [], query, scan, flat, localIndex, returnPort, selected, + [], [], [], [], [], [], [], [], [], [], []] + +@[simp] theorem coreMemory_update_output (graph : List Bool) (x v i k o m : Nat) + (rotor output query scan flat localIndex returnPort selected newOutput : List Bool) : + Function.update (coreMemory graph x v i k o m rotor output query scan flat + localIndex returnPort selected) (8 : CoreTape) newOutput = + coreMemory graph x v i k o m rotor newOutput query scan flat localIndex returnPort selected := by + funext z + fin_cases z <;> rfl + +theorem coreRotorTapes_injective : Function.Injective coreRotorTapes := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [coreRotorTapes] + +theorem coreFinishTapes_injective : Function.Injective coreFinishTapes := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [coreFinishTapes] + +def coreCleaned (base : CoreTape → List Bool) : CoreTape → List Bool := + Function.update (Function.update (Function.update (Function.update (Function.update + (Function.update (Function.update (Function.update (Function.update + (Function.update base 10 []) 11 []) 12 []) 13 []) 14 []) 15 []) 9 []) 16 []) 17 []) 18 [] + +def coreCleanupSteps (base : CoreTape → List Bool) : Nat := + (base 10).length + (base 11).length + (base 12).length + (base 13).length + + (base 14).length + (base 15).length + (base 9).length + (base 16).length + + (base 17).length + (base 18).length + 10 + +theorem coreCleanupTrace (q : Nat) (positive : 0 < q) (p : Fin q) + (labels : CoreLabel q → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : CoreTape => Bool) Λ (CoreState σ q)) + (code : ∀ l, program (labels l) = coreInstruction q positive p labels exit l) + (base : CoreTape → List Bool) + (ambient : σ × (MachineFixedBlockMap.Buffer 4096 × + (Fin q × (Bool × MachineCloudSelect.Phase)))) : + (advance (TM2.step program))^[coreCleanupSteps base] + (some ⟨some (labels (.cleanup 0)), (ambient, none), base⟩) = + some ⟨exit, (ambient, none), coreCleaned base⟩ := by + let b1 := Function.update base (10 : CoreTape) [] + have h0 := MachineDrain.drainTrace (10 : CoreTape) (labels (.cleanup 0)) + (some (labels (.cleanup 1))) program (code (.cleanup 0)) base (base 10) ambient none + rw [Function.update_eq_self] at h0 + let b2 := Function.update b1 (11 : CoreTape) [] + have h1 := MachineDrain.drainTrace (11 : CoreTape) (labels (.cleanup 1)) + (some (labels (.cleanup 2))) program (code (.cleanup 1)) b1 (b1 11) ambient none + rw [Function.update_eq_self] at h1 + have hw1 : b1 11 = base 11 := by simp [b1] + rw [hw1] at h1 + let b3 := Function.update b2 (12 : CoreTape) [] + have h2 := MachineDrain.drainTrace (12 : CoreTape) (labels (.cleanup 2)) + (some (labels (.cleanup 3))) program (code (.cleanup 2)) b2 (b2 12) ambient none + rw [Function.update_eq_self] at h2 + have hw2 : b2 12 = base 12 := by simp [b1, b2] + rw [hw2] at h2 + let b4 := Function.update b3 (13 : CoreTape) [] + have h3 := MachineDrain.drainTrace (13 : CoreTape) (labels (.cleanup 3)) + (some (labels (.cleanup 4))) program (code (.cleanup 3)) b3 (b3 13) ambient none + rw [Function.update_eq_self] at h3 + have hw3 : b3 13 = base 13 := by simp [b1, b2, b3] + rw [hw3] at h3 + let b5 := Function.update b4 (14 : CoreTape) [] + have h4 := MachineDrain.drainTrace (14 : CoreTape) (labels (.cleanup 4)) + (some (labels (.cleanup 5))) program (code (.cleanup 4)) b4 (b4 14) ambient none + rw [Function.update_eq_self] at h4 + have hw4 : b4 14 = base 14 := by simp [b1, b2, b3, b4] + rw [hw4] at h4 + let b6 := Function.update b5 (15 : CoreTape) [] + have h5 := MachineDrain.drainTrace (15 : CoreTape) (labels (.cleanup 5)) + (some (labels (.cleanup 6))) program (code (.cleanup 5)) b5 (b5 15) ambient none + rw [Function.update_eq_self] at h5 + have hw5 : b5 15 = base 15 := by simp [b1, b2, b3, b4, b5] + rw [hw5] at h5 + let b7 := Function.update b6 (9 : CoreTape) [] + have h6 := MachineDrain.drainTrace (9 : CoreTape) (labels (.cleanup 6)) + (some (labels (.cleanup 7))) program (code (.cleanup 6)) b6 (b6 9) ambient none + rw [Function.update_eq_self] at h6 + have hw6 : b6 9 = base 9 := by simp [b1, b2, b3, b4, b5, b6] + rw [hw6] at h6 + let b8 := Function.update b7 (16 : CoreTape) [] + have h7 := MachineDrain.drainTrace (16 : CoreTape) (labels (.cleanup 7)) + (some (labels (.cleanup 8))) program (code (.cleanup 7)) b7 (b7 16) ambient none + rw [Function.update_eq_self] at h7 + have hw7 : b7 16 = base 16 := by simp [b1, b2, b3, b4, b5, b6, b7] + rw [hw7] at h7 + let b9 := Function.update b8 (17 : CoreTape) [] + have h8 := MachineDrain.drainTrace (17 : CoreTape) (labels (.cleanup 8)) + (some (labels (.cleanup 9))) program (code (.cleanup 8)) b8 (b8 17) ambient none + rw [Function.update_eq_self] at h8 + have hw8 : b8 17 = base 17 := by simp [b1, b2, b3, b4, b5, b6, b7, b8] + rw [hw8] at h8 + let b10 := Function.update b9 (18 : CoreTape) [] + have h9 := MachineDrain.drainTrace (18 : CoreTape) (labels (.cleanup 9)) + exit program (code (.cleanup 9)) b9 (b9 18) ambient none + rw [Function.update_eq_self] at h9 + have hw9 : b9 18 = base 18 := by simp [b1, b2, b3, b4, b5, b6, b7, b8, b9] + rw [hw9] at h9 + have total := (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace h0 h1) h2) h3) h4) h5) h6) h7) h8) h9) + have hn : coreCleanupSteps base = + (base 10).length + 1 + ((base 11).length + 1) + ((base 12).length + 1) + + ((base 13).length + 1) + ((base 14).length + 1) + ((base 15).length + 1) + + ((base 9).length + 1) + ((base 16).length + 1) + ((base 17).length + 1) + + ((base 18).length + 1) := by unfold coreCleanupSteps; omega + rw [hn] + exact total + +end IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/OwnerData.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/OwnerData.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9a0bc3722cd9e0cb87fbeb0e6d50aa4db440814 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/OwnerData.lean @@ -0,0 +1,402 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOwnerBody +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingRegularBounds +import OAI.Combinatorics.IndependentSets.Machines.HeaderStates + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularTable +open Turing MachineComposition +open IndependentSetsGames.Foundations.PCP +namespace Top + +def ownerData (t : GraphTables.Table) (index : Nat) (output : List Bool) : Data := + { headerData t output with + globalIndex := encodeWord (t.darts + PreprocessingPaddingOffsets.offset + (PreprocessingRegularTables.padding t) index) + owner := encodeWord index + offset := encodeWord (PreprocessingPaddingOffsets.offset + (PreprocessingRegularTables.padding t) index) } + +theorem ownerSeedStep (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) (counters : Fin 4 → List Bool) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some Label.ownerSeed) (oldData t t.darts output) header counters)) = + some (cfg H (some (.copyFirst .owner)) (ownerData t 0 output) header counters) := by + change some (TM2.stepAux + (.push (coreTape 2) (fun _ => false) (.push (coreTape 5) (fun _ => false) + (.goto fun _ => Label.copyFirst CopyPhase.owner))) (readyState H) + (frame (oldData t t.darts output) header counters)) = _ + simp only [TM2.stepAux, frame_core] + change some (⟨some (Label.copyFirst CopyPhase.owner), readyState H, + Function.update (Function.update (frame (oldData t t.darts output) header counters) + (coreTape 2) [false]) (coreTape 5) [false]⟩ : + TM2.Cfg (fun _ : Tape => Bool) Label State) = _ + rw [update_frame_owner, update_frame_offset] + simp only [cfg, ownerData, oldData, PreprocessingPaddingOffsets.offset_zero, Nat.add_zero, + encodeWord, List.replicate_zero, List.nil_append] + +theorem copyOwnerTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) : + (advance (TM2.step (program H)))^[2*(t.vertices+2)] + (some (cfg H (some (.copyFirst .owner)) (ownerData t 0 output) (headerStacks t) + (counterStacks [] [] [] []))) = + some (cfg H (some .ownerGuard) (ownerData t 0 output) (headerStacks t) + (counterStacks [] (encodeWord t.vertices) [] [])) := by + have h := MachineCopy.copyTrace (headerTape Header.nTape) ownerFuel scratch + (by decide) (by decide) (by decide) false (.copyFirst .owner) (.copySecond .owner) + (some .ownerGuard) (program H) rfl rfl + (frame (ownerData t 0 output) (headerStacks t) (counterStacks [] [] [] [])) rfl + (MachineRegularOriginalBody.readyState H) none + simpa only [headerStacks, frame_header_n, encodeWord_length, frame_ownerFuel, + List.append_nil, update_frame_ownerFuel, cfg, readyState, Nat.add_assoc] using h + +theorem ownerPlacement (data extra : Data) (header : Header.Tape → List Bool) + (old owners : List Bool) : + MachineCloudPadding.Placement.tapes ownerView (MachineRegularOwnerBody.frame data) + (frame extra header (counterStacks old owners [] [])) = + frame data header (counterStacks old owners [] []) := by + funext j + cases j with + | inl j => rfl + | inr j => cases j with + | inl j => rfl + | inr i => fin_cases i <;> rfl + +theorem ownerInitialData_eq (t : GraphTables.Table) (v : Fin t.vertices) (output : List Bool) : + MachineRegularOwnerBody.initialData t v output = ownerData t v.val output := rfl + +theorem ownerBodyTrace (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (header : Header.Tape → List Bool) (owners : List Bool) : + (advance (TM2.step (program H)))^[MachineRegularOwnerBody.totalSteps H t v output] + (some (cfg H (some (.ownerBody MachineRegularOwnerBody.entry)) + (ownerData t v.val output) header (counterStacks [] owners [] []))) = + some (cfg H (some .ownerIncrement) (MachineRegularOwnerBody.finalData H t v output) + header (counterStacks [] owners [] [])) := by + have raw := MachineRegularOwnerBody.ownerTrace H t v output + have placed := MachineCloudPadding.Placement.trace ownerTape ownerView ownerView_left ownerView_right + Label.ownerBody (some .ownerIncrement) + (frame (ownerData t v.val output) header (counterStacks [] owners [] [])) + (MachineRegularOwnerBody.program H) (program H) (fun _ => rfl) _ _ _ raw + simpa only [MachineCloudPadding.Placement.configuration, MachineCloudPadding.Placement.label, + ownerPlacement, MachineRegularOwnerBody.cfg, MachineRegularOwnerBody.readyState, + ownerInitialData_eq, cfg, readyState] using placed + +theorem ownerGuardStep (H : BaseTable) (data : Data) (header : Header.Tape → List Bool) + (remaining : Nat) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some .ownerGuard) data header + (counterStacks [] (encodeWord (remaining+1)) [] []))) = + some (cfg H (some (.ownerBody MachineRegularOwnerBody.entry)) data header + (counterStacks [] (encodeWord remaining) [] [])) := by + change some (TM2.stepAux (Fuel.guard ownerFuel (.ownerBody MachineRegularOwnerBody.entry) + (clearEntry 0)) (readyState H) _) = _ + simp only [Fuel.guard, TM2.stepAux, frame_ownerFuel, encodeWord, List.replicate_succ, + List.cons_append, List.head?_cons, List.tail_cons, Option.getD_some, + Bool.cond_true, update_frame_ownerFuel] + rfl + +theorem ownerGuardExit (H : BaseTable) (data : Data) (header : Header.Tape → List Bool) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some .ownerGuard) data header (counterStacks [] (encodeWord 0) [] []))) = + some (cfg H (clearEntry 0) data header (counterStacks [] [] [] [])) := by + change some (TM2.stepAux (Fuel.guard ownerFuel (.ownerBody MachineRegularOwnerBody.entry) + (clearEntry 0)) (readyState H) _) = _ + simp only [Fuel.guard, TM2.stepAux, frame_ownerFuel, encodeWord, List.replicate_zero, + List.nil_append, List.head?_cons, List.tail_cons, Option.getD_some, + Bool.cond_false, update_frame_ownerFuel] + rfl + +theorem ownerIncrementStep (H : BaseTable) (t : GraphTables.Table) (v : Fin t.vertices) + (output : List Bool) (header : Header.Tape → List Bool) (counters : Fin 4 → List Bool) : + (advance (TM2.step (program H)))^[1] + (some (cfg H (some .ownerIncrement) (MachineRegularOwnerBody.finalData H t v output) + header counters)) = + some (cfg H (some .ownerGuard) + (ownerData t (v.val+1) (output ++ MachineRegularOwnerBody.ownerBits H t v)) header counters) := by + change some (TM2.stepAux (Fuel.increment (coreTape 2) Label.ownerGuard) (readyState H) + (frame (MachineRegularOwnerBody.finalData H t v output) header counters)) = _ + simp only [Fuel.increment, TM2.stepAux, frame_core] + change some (⟨some Label.ownerGuard, readyState H, + Function.update (frame (MachineRegularOwnerBody.finalData H t v output) header counters) + (coreTape 2) (true :: encodeWord v.val)⟩ : + TM2.Cfg (fun _ : Tape => Bool) Label State) = _ + rw [update_frame_owner] + have offset := PreprocessingRegularBounds.offset_succ (PreprocessingRegularTables.padding t) v.val v.isLt + simp only [cfg, ownerData, headerData, inputData, MachineRegularOwnerBody.finalData, + MachineRegularOwnerBody.initialData, offset, encodeWord, List.replicate_succ, + List.cons_append, Nat.add_assoc] + +def ownerPrefix (H : BaseTable) (t : GraphTables.Table) (k : Nat) : List Bool := + PreprocessingRegularLoopWords.blocksPrefix (MachineRegularOwnerBody.ownerBits H t) k + +noncomputable def ownerElapsed (H : BaseTable) (t : GraphTables.Table) (output : List Bool) : Nat → Nat + | 0 => 0 + | k+1 => ownerElapsed H t output k + + if h : k < t.vertices then + 1 + MachineRegularOwnerBody.totalSteps H t ⟨k,h⟩ (output ++ ownerPrefix H t k) + 1 + else 0 + +theorem ownerPrefixTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) (k : Nat) : k ≤ t.vertices → + (advance (TM2.step (program H)))^[ownerElapsed H t output k] + (some (cfg H (some .ownerGuard) (ownerData t 0 output) header + (counterStacks [] (encodeWord t.vertices) [] []))) = + some (cfg H (some .ownerGuard) (ownerData t k (output ++ ownerPrefix H t k)) header + (counterStacks [] (encodeWord (t.vertices-k)) [] [])) := by + induction k with + | zero => + intro _ + simp [ownerElapsed, ownerPrefix] + | succ k ih => + intro hk + have hlt : k < t.vertices := by omega + have hremaining : t.vertices-k = (t.vertices-(k+1))+1 := by omega + have previous := ih (by omega) + have guard := ownerGuardStep H (ownerData t k (output ++ ownerPrefix H t k)) header + (t.vertices-(k+1)) + rw [← hremaining] at guard + have body := ownerBodyTrace H t ⟨k,hlt⟩ (output ++ ownerPrefix H t k) header + (encodeWord (t.vertices-(k+1))) + have increment := ownerIncrementStep H t ⟨k,hlt⟩ (output ++ ownerPrefix H t k) header + (counterStacks [] (encodeWord (t.vertices-(k+1))) [] []) + have combined := joinTrace (joinTrace (joinTrace previous guard) body) increment + have bits := PreprocessingRegularLoopWords.blocksPrefix_succ + (MachineRegularOwnerBody.ownerBits H t) k hlt + change ownerPrefix H t (k+1) = ownerPrefix H t k ++ + MachineRegularOwnerBody.ownerBits H t ⟨k,hlt⟩ at bits + simpa only [ownerElapsed, dite_eq_left hlt, bits, List.append_assoc, Nat.add_assoc] using combined + +theorem ownerLoopTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) + (header : Header.Tape → List Bool) : + (advance (TM2.step (program H)))^[ownerElapsed H t output t.vertices+1] + (some (cfg H (some .ownerGuard) (ownerData t 0 output) header + (counterStacks [] (encodeWord t.vertices) [] []))) = + some (cfg H (clearEntry 0) + (ownerData t t.vertices (output ++ ownerPrefix H t t.vertices)) header + (counterStacks [] [] [] [])) := by + have prefixRun := ownerPrefixTrace H t output header t.vertices (Nat.le_refl _) + simp only [Nat.sub_self] at prefixRun + exact joinTrace prefixRun (ownerGuardExit H _ header) + +theorem ownerStageTrace (H : BaseTable) (t : GraphTables.Table) (output : List Bool) : + (advance (TM2.step (program H)))^[1+2*(t.vertices+2)+(ownerElapsed H t output t.vertices+1)] + (some (cfg H (some Label.ownerSeed) (oldData t t.darts output) (headerStacks t) + (counterStacks [] [] [] []))) = + some (cfg H (clearEntry 0) + (ownerData t t.vertices (output ++ ownerPrefix H t t.vertices)) (headerStacks t) + (counterStacks [] [] [] [])) := + joinTrace (joinTrace (ownerSeedStep H t output (headerStacks t) _) (copyOwnerTrace H t output)) + (ownerLoopTrace H t output (headerStacks t)) + +theorem owner_output_eq_ownerPrefix (H : BaseTable) (t : GraphTables.Table) (k : Nat) : + (Header.headerBits PreprocessingRegularTables.internalDegree t ++ oldPrefix H t t.darts) ++ + ownerPrefix H t k = + PreprocessingRegularBounds.ownerPrefix t (PreprocessingRegularTables.padding t) + (PreprocessingRegularTables.familyCloudTable H t) k := by + have oldBits : MachineRegularOriginalBody.emittedBits H t = + PreprocessingRegularWords.originalVertexBits t (PreprocessingRegularTables.padding t) + (PreprocessingRegularTables.familyCloudTable H t) := rfl + have ownerBits : MachineRegularOwnerBody.ownerBits H t = + PreprocessingRegularBounds.ownerBits t (PreprocessingRegularTables.padding t) + (PreprocessingRegularTables.familyCloudTable H t) := rfl + simp only [Header.headerBits, Header.vertexTotal, Header.dartTotal, oldPrefix, + ownerPrefix, PreprocessingRegularLoopWords.blocksPrefix_all, + PreprocessingRegularBounds.ownerPrefix, PreprocessingRegularBounds.header] + rw [oldBits, ownerBits] + +def cleaned (base : Tape → List Bool) : Nat → Tape → List Bool + | 0 => base + | k+1 => if h : k < 7 then Function.update (cleaned base k) (clearTape ⟨k,h⟩) [] + else cleaned base k + +def cleanupTime (base : Tape → List Bool) : Nat → Nat + | 0 => 0 + | k+1 => cleanupTime base k + if h : k < 7 then + ((cleaned base k) (clearTape ⟨k,h⟩)).length+1 else 0 + +theorem drainTrace (H : BaseTable) (i : Fin 7) (base : Tape → List Bool) : + (advance (TM2.step (program H)))^[(base (clearTape i)).length+1] + (some ⟨some (.clear i), readyState H, base⟩) = + some ⟨clearEntry (i.val+1), readyState H, Function.update base (clearTape i) []⟩ := by + have h := MachineDrain.drainTrace (clearTape i) (.clear i) (clearEntry (i.val+1)) + (program H) rfl base (base (clearTape i)) (MachineRegularOriginalBody.readyState H) none + simpa only [Function.update_eq_self, readyState] using h + +theorem cleanupPrefixTrace (H : BaseTable) (base : Tape → List Bool) (k : Nat) (hk : k ≤ 7) : + (advance (TM2.step (program H)))^[cleanupTime base k] + (some ⟨clearEntry 0, readyState H, base⟩) = + some ⟨clearEntry k, readyState H, cleaned base k⟩ := by + induction k with + | zero => rfl + | succ k ih => + have h : k < 7 := by omega + have first := ih (by omega) + have second := drainTrace H ⟨k,h⟩ (cleaned base k) + have atEntry : clearEntry k = some (.clear ⟨k,h⟩) := by simp only [clearEntry, dite_eq_left h] + rw [atEntry] at first + simpa only [cleanupTime, cleaned, dite_eq_left h] using joinTrace first second + +theorem cleanupTrace (H : BaseTable) (base : Tape → List Bool) : + (advance (TM2.step (program H)))^[cleanupTime base 7] + (some ⟨clearEntry 0, readyState H, base⟩) = + some ⟨none, readyState H, cleaned base 7⟩ := by + simpa only [clearEntry, lt_self_iff_false, dite_false] using cleanupPrefixTrace H base 7 le_rfl + +def finalStacks (t : GraphTables.Table) (output : List Bool) : Tape → List Bool := + frame (ownerData t t.vertices output) (headerStacks t) (counterStacks [] [] [] []) + +theorem cleaned_finalStacks (t : GraphTables.Table) (output : List Bool) : + cleaned (finalStacks t output) 7 = + frame (inputData t output) (fun _ => []) (counterStacks [] [] [] []) := by + funext j + cases j with + | inl j => cases j with + | inl i => fin_cases i <;> rfl + | inr e => cases e with + | inl e => cases e <;> rfl + | inr e => rfl + | inr j => cases j with + | inl k => cases k with + | inl k => cases k with + | inner k => cases k <;> rfl + | bound => rfl + | remaining => rfl + | total => rfl + | inr k => cases k <;> rfl + | inr i => fin_cases i <;> rfl + +theorem cleaned_length_le (base : Tape → List Bool) (k : Nat) : + ∀ j, (cleaned base k j).length ≤ (base j).length := by + induction k with + | zero => intro j; exact Nat.le_refl _ + | succ k ih => + intro j + simp only [cleaned] + split + · rename_i hk + by_cases hj : j = clearTape ⟨k,hk⟩ + · simp [hj] + · simpa only [Function.update_of_ne hj] using ih j + · exact ih j + +theorem cleanupTime_le (base : Tape → List Bool) (cap : Nat) + (bounded : ∀ i : Fin 7, (base (clearTape i)).length ≤ cap) (k : Nat) : + cleanupTime base k ≤ k*(cap+1) := by + induction k with + | zero => simp [cleanupTime] + | succ k ih => + simp only [cleanupTime] + split + · rename_i hk + have hword := (cleaned_length_le base k (clearTape ⟨k,hk⟩)).trans (bounded ⟨k,hk⟩) + calc + cleanupTime base k + ((cleaned base k (clearTape ⟨k,hk⟩)).length+1) ≤ + k*(cap+1)+(cap+1) := by omega + _ = (k+1)*(cap+1) := by simp only [Nat.add_mul, one_mul] + · exact ih.trans (Nat.mul_le_mul_right _ (by omega)) + +theorem cleanupTime_final_le (t : GraphTables.Table) (output : List Bool) : + cleanupTime (finalStacks t output) 7 ≤ + (7*(ExpanderFamily.growth*(PreprocessingRegularTables.internalDegree+4)+4)) * + (PreprocessingMachineBounds.inputLength t+1) := by + let L := PreprocessingMachineBounds.inputLength t + let g := ExpanderFamily.growth + let q := PreprocessingRegularTables.internalDegree + let C := g*(q+4)+4 + have hm : t.darts ≤ L := GraphTables.darts_le_tableBits_length t + have hn : t.vertices ≤ L := GraphTables.vertices_le_tableBits_length t + have hs : PreprocessingPaddingOffsets.offset (PreprocessingRegularTables.padding t) t.vertices ≤ g*L := + PreprocessingMachineBounds.prefix_le_input t t.vertices + have hN : Header.vertexTotal t ≤ g*L := PreprocessingMachineBounds.regularVertices_le_input t + have hone : 1 ≤ C := by dsimp [C]; omega + have hg : g ≤ C := by + have h := Nat.mul_le_mul_left g (show 1 ≤ q+4 by omega) + dsimp [C] + omega + have hgp : g+1 ≤ C := by + have h := Nat.mul_le_mul_left g (show 1 ≤ q+4 by omega) + dsimp [C] + omega + have hgq : g*(q+1) ≤ C := by + have h := Nat.mul_le_mul_left g (show q+1 ≤ q+4 by omega) + dsimp [C] + omega + have hmC : t.darts ≤ C*L := hm.trans (by simpa using Nat.mul_le_mul_right L hone) + have hnC : t.vertices ≤ C*L := hn.trans (by simpa using Nat.mul_le_mul_right L hone) + have hsC : PreprocessingPaddingOffsets.offset (PreprocessingRegularTables.padding t) t.vertices ≤ C*L := + hs.trans (Nat.mul_le_mul_right L hg) + have hNC : Header.vertexTotal t ≤ C*L := hN.trans (Nat.mul_le_mul_right L hg) + have hxC : t.darts + + PreprocessingPaddingOffsets.offset (PreprocessingRegularTables.padding t) t.vertices ≤ C*L := by + calc + _ ≤ L+g*L := Nat.add_le_add hm hs + _ = (g+1)*L := by simp only [Nat.add_mul, one_mul, Nat.add_comm] + _ ≤ C*L := Nat.mul_le_mul_right L hgp + have hRC : Header.dartTotal q t ≤ C*L := by + calc + _ ≤ (g*L)*(q+1) := Nat.mul_le_mul_right _ hN + _ = (g*(q+1))*L := by ac_rfl + _ ≤ C*L := Nat.mul_le_mul_right L hgq + have bounds : ∀ i : Fin 7, (finalStacks t output (clearTape i)).length ≤ C*L+1 := by + intro i + fin_cases i + · change (encodeWord _).length ≤ _ + simpa only [encodeWord_length] using Nat.add_le_add_right hxC 1 + · change (encodeWord _).length ≤ _ + simpa only [encodeWord_length] using Nat.add_le_add_right hnC 1 + · change (encodeWord _).length ≤ _ + simpa only [encodeWord_length] using Nat.add_le_add_right hsC 1 + · change (encodeWord _).length ≤ _ + simpa only [encodeWord_length] using Nat.add_le_add_right hmC 1 + · change (encodeWord _).length ≤ _ + simpa only [encodeWord_length] using Nat.add_le_add_right hnC 1 + · change (encodeWord _).length ≤ _ + simpa only [encodeWord_length] using Nat.add_le_add_right hNC 1 + · change (encodeWord _).length ≤ _ + simpa only [encodeWord_length] using Nat.add_le_add_right hRC 1 + have actual := cleanupTime_le (finalStacks t output) (C*L+1) bounds 7 + have hC : 2 ≤ C := by dsimp [C]; omega + change cleanupTime (finalStacks t output) 7 ≤ (7*C)*(L+1) + nlinarith + +def headerOutput (t : GraphTables.Table) : List Bool := + Header.headerBits PreprocessingRegularTables.internalDegree t + +def oldOutput (H : BaseTable) (t : GraphTables.Table) : List Bool := + headerOutput t ++ oldPrefix H t t.darts + +def finalOutput (H : BaseTable) (t : GraphTables.Table) : List Bool := + oldOutput H t ++ ownerPrefix H t t.vertices + +noncomputable def totalTime (H : BaseTable) (t : GraphTables.Table) : Nat := + Header.totalTime PreprocessingRegularTables.internalDegree t [] + + (1+2*(t.darts+2)+(oldElapsed H t (headerOutput t) t.darts+1)) + + (1+2*(t.vertices+2)+(ownerElapsed H t (oldOutput H t) t.vertices+1)) + + cleanupTime (finalStacks t (finalOutput H t)) 7 + +theorem old_output_eq_originalPrefix (H : BaseTable) (t : GraphTables.Table) (k : Nat) : + Header.headerBits PreprocessingRegularTables.internalDegree t ++ oldPrefix H t k = + PreprocessingRegularBounds.originalPrefix t (PreprocessingRegularTables.padding t) + (PreprocessingRegularTables.familyCloudTable H t) k := rfl + +theorem finalOutput_eq (H : BaseTable) (t : GraphTables.Table) : + finalOutput H t = PortTables.tableBits (PreprocessingRegularTables.regularize H t) := by + change finalOutput H t = PortTables.tableBits (PreprocessingRegularTables.ofCloudTables t + (PreprocessingRegularTables.padding t) (PreprocessingRegularTables.familyCloudTable H t)) + rw [PreprocessingRegularWords.tableBits_ofCloudTables] + have oldBits : MachineRegularOriginalBody.emittedBits H t = + PreprocessingRegularWords.originalVertexBits t (PreprocessingRegularTables.padding t) + (PreprocessingRegularTables.familyCloudTable H t) := rfl + have ownerBits : MachineRegularOwnerBody.ownerBits H t = + (fun v => (List.ofFn (PreprocessingRegularWords.dummyVertexBits t + (PreprocessingRegularTables.padding t) (PreprocessingRegularTables.familyCloudTable H t) v)).flatten) := rfl + simp only [finalOutput, oldOutput, headerOutput, Header.headerBits, Header.vertexTotal, + Header.dartTotal, oldPrefix, ownerPrefix, PreprocessingRegularLoopWords.blocksPrefix_all, + List.append_assoc] + rw [oldBits, ownerBits] + +end Top + +end IndependentSetsGames.Foundations.Complexity.MachineRegularTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PCPGapMachine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PCPGapMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..cdc92321e3597c645a903d5cacaf7f4a00ba22c7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PCPGapMachine.lean @@ -0,0 +1,248 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.RoundComputation +import OAI.Combinatorics.IndependentSets.Encoding.BinaryNormalize +import OAI.Combinatorics.IndependentSets.Reduction.IndexedBlocks +import OAI.Combinatorics.IndependentSets.Machines.MachineLazyTableRuntime + +namespace OAI + +namespace LargeIndependentSets.PCPGapMachine +open IndependentSetsGames.Foundations +open Complexity PCP + +noncomputable def round (H : RoundTables.BaseTable) := + RoundComputation.tablePolynomialTime H (PreprocessingRuntime.tablePolynomialTime H) + +lemma round_finiteAlphabet (H : RoundTables.BaseTable) : + MachineFiniteAlphabet.FiniteAlphabet (round H).tm := + RoundComputation.tablePolynomialTime_finite_alphabet H + (PreprocessingRuntime.tablePolynomialTime H) (PreprocessingRuntime.finiteAlphabet H) + +noncomputable def certificate (H : RoundTables.BaseTable) : + Turing.TM2ComputableInPolyTime Complexity.formulaBits Complexity.formulaBits + (TableIteration.gapMap H) := + MachineTableIteration.gapMapCertificate H (round H) + +lemma finiteAlphabet (H : RoundTables.BaseTable) : + MachineFiniteAlphabet.FiniteAlphabet (certificate H).tm := + TableIterationFiniteAlphabet.gapMap H (round H) (round_finiteAlphabet H) +end LargeIndependentSets.PCPGapMachine +namespace LargeIndependentSets.BinaryNormalize +open BinarySyntax BinaryNames +open IndependentSetsGames.Foundations +open IndependentSetsCut.CounterMachine +open scoped BigOperators + +@[simp] lemma annotated_input (s : List Bool) : (annotated s).input = s := + FiniteScan.iterate_input _ _ _ _ + +def eventCode : Option Mark → ℕ + | none => 0 + | some .empty => 1 + | some (.first r) => 2+r.val + +def sourcePosition (s : List Bool) (p r j : ℕ) : ℕ := + if j=1 ∧ 1 ≤ r then next s p else + if j=2 ∧ 2 ≤ r then next s (next s p) else p + +def blockValue (s : List Bool) (p i : ℕ) : ℕ := + let tag := eventCode (eventAt s p) + let slot := (i/2)%3 + if 2 ≤ tag ∧ i<6 then + let pos := sourcePosition s p (tag-2) slot + if i%2=0 then key s pos else if raw s pos then 1 else 0 + else if i%2=0 then 0 + else if tag=1 then (if 6 ≤ i then 1 else 0) + else if slot=1 then 0 else 1 + +lemma blockValue_spec (s : List Bool) (p : ℕ) : + (List.range 12).map (blockValue s p) = + Complexity.clauseWords (row s p false) ++ Complexity.clauseWords (row s p true) := by + cases he : eventAt s p with + | none => simp [blockValue,he,eventCode,row,tautology,constant,triple, + Complexity.clauseWords,Complexity.literalWords,List.range_succ] + | some e => + cases e with + | empty => simp [blockValue,he,eventCode,row,unitClause,constant,triple, + Complexity.clauseWords,Complexity.literalWords,List.range_succ] + | first r => + fin_cases r <;> simp [blockValue,he,eventCode,row,sourceClause,sourcePosition,dense, + tautology,constant,triple,Complexity.clauseWords,Complexity.literalWords,List.range_succ] + +lemma clauses_length (s : List Bool) : (normalize s).clauses.length=2*s.length := by + simp [normalize,List.length_flatMap,Nat.mul_comm] + +def tableCount (s : List Bool) : ℕ := 2+12*s.length + +def tableValue (s : List Bool) (w : ℕ) : ℕ := + if w=0 then s.length+1 else if w=1 then 2*s.length + else blockValue s ((w-2)/12) ((w-2)%12) + +lemma tableValue_spec (s : List Bool) : + (List.range (tableCount s)).map (tableValue s) = Complexity.formulaWords (normalize s) := by + rw [tableCount,List.range_add,List.map_append] + have h0 : (List.range 2).map (tableValue s)=[s.length+1,2*s.length] := by + simp [List.range_succ,tableValue] + rw [h0] + have h1 : ((List.range (12*s.length)).map (fun x => 2+x)).map (tableValue s) = + (List.range (12*s.length)).map (fun i => blockValue s (i/12) (i%12)) := by + rw [List.map_map] + apply List.map_congr_left + intro i _ + simp [tableValue,show 2+i≠1 by omega] + rw [h1,IndexedBlocks.range_blocks _ 12 (by omega)] + unfold Complexity.formulaWords + rw [clauses_length] + congr 1 + change (List.range s.length).flatMap (fun p => (List.range 12).map (blockValue s p)) = + ((List.range s.length).flatMap (fun p => [row s p false,row s p true])).flatMap + (@Complexity.clauseWords (varCount s)) + rw [List.flatMap_assoc] + apply List.flatMap_congr + intro p _ + simpa using blockValue_spec s p + +lemma encodeWords_flatMap (xs : List ℕ) : + Complexity.encodeWords xs=xs.flatMap (fun v => List.replicate v true++[false]) := by + induction xs with + | nil => rfl + | cons v xs ih => simp [Complexity.encodeWords,Complexity.encodeWord,ih] + +lemma tableWords_spec (s : List Bool) : + UnaryTables.words (tableValue s) (tableCount s) = Complexity.formulaBits (normalize s) := by + rw [UnaryTables.words,tableValue_spec,Complexity.formulaBits,encodeWords_flatMap] + +def finiteTableExpr {m : ℕ} (f : Fin m → Bool → ℕ) (q b : Expr) : Expr := + Expr.listSum (List.finRange m) (fun i => .mul (Expr.equal q (.const i.val)) + (Expr.cond b (.const (f i true)) (.const (f i false)))) + +lemma finiteTableExpr_eval {m : ℕ} (f : Fin m → Bool → ℕ) (q b : Expr) + (s : List Bool) (a : ℕ → ℕ) (i : Fin m) (c : Bool) + (hq : q.eval s a=i.val) (hb : b.eval s a=if c then 1 else 0) : + (finiteTableExpr f q b).eval s a=f i c := by + simp only [finiteTableExpr,Expr.listSum_eval,Expr.eval,Expr.equal_eval,Expr.cond_eval,hq,hb] + cases c <;> simp only [Bool.false_eq_true,↓reduceIte,ne_eq,not_true_eq_false, + one_ne_zero,not_false_eq_true] + all_goals + rw [← List.ofFn_eq_map,List.sum_ofFn] + simp [Fin.val_inj] + +noncomputable def tagExpr (p : Expr) : Expr := + finiteTableExpr (fun q b => eventCode (event (phaseEquiv.symm q) b)) + (FiniteScan.historyExpr p) (rawExpr p) + +lemma tagExpr_eval (s : List Bool) (p : Expr) (a : ℕ → ℕ) + (hp : p.eval (annotated s).bits a ≤ s.length) : + (tagExpr p).eval (annotated s).bits a=eventCode (eventAt s (p.eval (annotated s).bits a)) := by + unfold tagExpr + rw [finiteTableExpr_eval _ _ _ _ _ + (phaseEquiv (run .headerMark (s.take (p.eval (annotated s).bits a)))) + (raw s (p.eval (annotated s).bits a))] + · simp [eventAt] + · simp only [FiniteScan.historyExpr_eval,FiniteScan.nExpr_eval,annotated_input] + have hr := FiniteScan.read_history (annotated s) (p.eval (annotated s).bits a) + (by simpa only [annotated_input] using hp) + simpa only [annotated_input,annotated_history _ _ hp] using hr + · simpa only [annotated_input] using rawExpr_eval (annotated s) p a + +def sourcePositionExpr (p r j : Expr) : Expr := + Expr.cond (.mul (Expr.equal j (.const 1)) (Expr.le (.const 1) r)) (nextExpr p) + (Expr.cond (.mul (Expr.equal j (.const 2)) (Expr.le (.const 2) r)) + (nextExpr (nextExpr p)) p) + +lemma sourcePositionExpr_eval {m : ℕ} (s : FiniteScan.State m) (p r j : Expr) (a : ℕ → ℕ) : + (sourcePositionExpr p r j).eval s.bits a = + sourcePosition s.input (p.eval s.bits a) (r.eval s.bits a) (j.eval s.bits a) := by + simp only [sourcePositionExpr,Expr.cond_eval,Expr.eval,Expr.equal_eval,Expr.le_eval, + nextExpr_eval,sourcePosition] + by_cases h1 : j.eval s.bits a=1 <;> by_cases h2 : j.eval s.bits a=2 <;> + by_cases hr1 : 1 ≤ r.eval s.bits a <;> by_cases hr2 : 2 ≤ r.eval s.bits a <;> + simp [h1,h2,hr1,hr2] + +def blockExpr (p i tag : Expr) : Expr := + let slot := Expr.remainder (Expr.quotient i (.const 2)) (.const 3) + let pos := sourcePositionExpr p (.sub tag (.const 2)) slot + Expr.cond (.mul (Expr.le (.const 2) tag) (Expr.lt i (.const 6))) + (Expr.cond (Expr.equal (Expr.remainder i (.const 2)) (.const 0)) (keyExpr pos) (rawExpr pos)) + (Expr.cond (Expr.equal (Expr.remainder i (.const 2)) (.const 0)) (.const 0) + (Expr.cond (Expr.equal tag (.const 1)) (Expr.le (.const 6) i) + (Expr.cond (Expr.equal slot (.const 1)) (.const 0) (.const 1)))) + +lemma blockExpr_eval (s : List Bool) (p i : Expr) (a : ℕ → ℕ) + (hp : p.eval (annotated s).bits a ≤ s.length) : + (blockExpr p i (tagExpr p)).eval (annotated s).bits a= + blockValue s (p.eval (annotated s).bits a) (i.eval (annotated s).bits a) := by + simp only [blockExpr,Expr.cond_eval,Expr.eval,Expr.le_eval,Expr.lt_eval,Expr.equal_eval, + tagExpr_eval s p a hp,keyExpr_eval,rawExpr_eval,sourcePositionExpr_eval, + Expr.quotient_eval,Expr.remainder_eval,annotated_input] + unfold blockValue + by_cases ht : 2 ≤ eventCode (eventAt s (p.eval (annotated s).bits a)) <;> + by_cases hi : i.eval (annotated s).bits a < 6 <;> + by_cases hr : i.eval (annotated s).bits a % 2 = 0 <;> + by_cases he : eventCode (eventAt s (p.eval (annotated s).bits a)) = 1 <;> + by_cases hs : (i.eval (annotated s).bits a / 2) % 3 = 1 <;> + simp [ht,hi,hr,he,hs,show (6 ≤ i.eval (annotated s).bits a) ↔ + ¬i.eval (annotated s).bits a < 6 by omega] + +def countExpr : Expr := .add (.const 2) (.mul (.const 12) FiniteScan.nExpr) +noncomputable def valueExpr : Expr := + let p := Expr.quotient (.sub (.arg 0) (.const 2)) (.const 12) + let i := Expr.remainder (.sub (.arg 0) (.const 2)) (.const 12) + Expr.cond (Expr.equal (.arg 0) (.const 0)) (.add FiniteScan.nExpr (.const 1)) + (Expr.cond (Expr.equal (.arg 0) (.const 1)) (.mul (.const 2) FiniteScan.nExpr) + (blockExpr p i (tagExpr p))) + +lemma countExpr_eval (s : List Bool) (a : ℕ → ℕ) : + countExpr.eval (annotated s).bits a=tableCount s := by + simp [countExpr,Expr.eval,tableCount] + +lemma valueExpr_eval (s : List Bool) (w : ℕ) (hw : w w)=tableValue s w := by + have hp : (w-2)/12 ≤ s.length := by unfold tableCount at hw; omega + have hb := blockExpr_eval s (Expr.quotient (.sub (.arg 0) (.const 2)) (.const 12)) + (Expr.remainder (.sub (.arg 0) (.const 2)) (.const 12)) (fun _ => w) (by simpa [Expr.eval] using hp) + simp only [valueExpr,Expr.cond_eval,Expr.equal_eval,Expr.eval,hb,FiniteScan.nExpr_eval,annotated_input,Expr.quotient_eval,Expr.remainder_eval] + by_cases h0 : w=0 <;> by_cases h1 : w=1 <;> simp [tableValue,h0,h1] + +lemma serializer_spec (s : List Bool) : + UnaryTables.words (fun w => valueExpr.eval (annotated s).bits (fun _ => w)) + (countExpr.eval (annotated s).bits (fun _ => 0))=Complexity.formulaBits (normalize s) := by + rw [countExpr_eval,← tableWords_spec] + exact UnaryTables.words_congr (valueExpr_eval s) + +noncomputable def serializer : Turing.TM2ComputableInPolyTime + (fun s => (annotated s).bits) Complexity.formulaBits normalize := + UnaryTables.encodedComputer _ _ _ countExpr valueExpr serializer_spec + +lemma serializer_finiteAlphabet : Complexity.MachineFiniteAlphabet.FiniteAlphabet serializer.tm := + UnaryTables.encodedComputer_finiteAlphabet _ _ _ _ _ _ + +noncomputable def annotator : Turing.TM2ComputableInPolyTime + (id : List Bool → List Bool) (fun s => (annotated s).bits) id where + tm := BinarySyntax.certificate.tm + inputAlphabet := BinarySyntax.certificate.inputAlphabet + outputAlphabet := BinarySyntax.certificate.outputAlphabet + time := BinarySyntax.certificate.time + outputsFun := BinarySyntax.certificate.outputsFun + +noncomputable def certificate : Turing.TM2ComputableInPolyTime + (id : List Bool → List Bool) Complexity.formulaBits normalize := + Complexity.MachineSequential.composeBits annotator serializer + +lemma finiteAlphabet : Complexity.MachineFiniteAlphabet.FiniteAlphabet certificate.tm := + Complexity.MachineFiniteAlphabet.composeBits annotator serializer + BinarySyntax.finiteAlphabet serializer_finiteAlphabet + +noncomputable def gapCertificate (H : PCP.RoundTables.BaseTable) : + Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) Complexity.formulaBits + (fun s => PCP.TableIteration.gapMap H (normalize s)) := + Complexity.MachineSequential.composeBits certificate (PCPGapMachine.certificate H) + +lemma gap_finiteAlphabet (H : PCP.RoundTables.BaseTable) : + Complexity.MachineFiniteAlphabet.FiniteAlphabet (gapCertificate H).tm := + Complexity.MachineFiniteAlphabet.composeBits certificate (PCPGapMachine.certificate H) + finiteAlphabet (PCPGapMachine.finiteAlphabet H) + +end LargeIndependentSets.BinaryNormalize + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PhasePolynomial.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PhasePolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..762cf08f18d50880ed39d473b98e707baa83b862 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PhasePolynomial.lean @@ -0,0 +1,93 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Remaining + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineOverlayTable +open Turing MachineComposition +open PCP PCP.GraphTables PCP.PreprocessingOverlayWords +open MachineCloudPadding + +variable {A : Type} + +theorem loopSteps_le {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) : + MachineCountedLoop.totalSteps (loopCost G H) n ≤ n * (pairBudget d e n + 1) + 1 := by + apply MachineCountedLoop.totalSteps_le + intro r hr + rw [loopCost, dite_eq_left hr] + exact pairSteps_le G H _ _ (outputPrefix_length_le G H _) + +noncomputable def phasePolynomial (d e : Nat) : Polynomial Nat := + let x := Polynomial.X + let C := Polynomial.C (R := Nat) + let oldValue := C (d + e) * (x * C d) + x * C d + C 0 + let os := x + oldValue + C 8194 + let newValue := C (d + e) * (x * C e) + x * C e + C d + let es := x + newValue + C MachineOverlayRows.trueBits.length + C 2 + let block := C d * os + C e * es + let cap := x + x * C (d + e) + C 2 + x * block + let oldCost := C 2 * x + C 8 * (x * C d) + oldValue + C 4 * os + C 8224 + let newCost := C 8 * (x * C e) + C 4 * es + newValue + C MachineOverlayRows.trueBits.length + C 28 + let pair := (C d * (oldCost + C 2 * (cap + C d * os) + C 1) + C 1) + + (C e * (newCost + C 2 * (cap + C d * os + C e * es) + C 1) + C 1) + + (C 3 * x + C 6) + x * (pair + C 1) + C 1 + (C 2 * x + x * C d + C 8) + +@[simp] theorem phasePolynomial_eval (d e n : Nat) : + (phasePolynomial d e).eval n = n * (pairBudget d e n + 1) + 1 + cleanupSteps n (n * d) := by + simp only [phasePolynomial, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_X, pairBudget, outputCapacity, blockSize, oldSize, expanderSize, + MachineLazyRows.rowSizeBound, MachineLazyRows.rowCostBound, MachineLazyRows.valueBound, + MachineOverlayRows.rowSizeBound, MachineOverlayRows.rowCostBound, + MachineOverlayRows.valueBound, cleanupSteps] + +noncomputable def timePolynomial (d e : Nat) : Polynomial Nat := + Polynomial.C 12 * Polynomial.X + Polynomial.C 18 + phasePolynomial d e + +theorem tableSteps_le {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) : + tableSteps G H ≤ (timePolynomial d e).eval ((PortTables.tableBits G).length + (rawExpander H).length) := by + have hsplit := MachineTableSplit.exactSteps_le n (n * d) + (MachineTableSplit.rowsBits (PortTables.graphTable G)) + have header : encodeWords [n, n * d] ++ MachineTableSplit.rowsBits (PortTables.graphTable G) = + PortTables.tableBits G := (MachineTableSplit.tableBits_header_rows (PortTables.graphTable G)).symm + rw [header, MachineTableSplit.timePolynomial_eval] at hsplit + have hn := PortTables.vertices_le_tableBits_length G + have hloop := loopSteps_le G H + have hmono := natPolynomial_eval_mono (phasePolynomial d e) + (show n ≤ (PortTables.tableBits G).length + (rawExpander H).length by omega) + rw [phasePolynomial_eval] at hmono + simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_X] + unfold tableSteps preparationSteps + omega + +def tableInTime {n : Nat} (d e : Nat) (hd : 0 < d) (he : 0 < e) + (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (a : A) : + StateTransition.EvalsToInTime (TM2.step (program d e hd he)) + ⟨some (.inl .copyFirst), clean d e hd he a, + initialTapes (PortTables.tableBits G) (rawExpander H)⟩ + (some ⟨none, clean d e hd he a, + memory (PortTables.tableBits G) (rawExpander H) [] [] [] [] [] [] [] + (PortTables.tableBits (PreprocessingOverlayTables.overlay G H))⟩) + ((timePolynomial d e).eval ((PortTables.tableBits G).length + (rawExpander H).length)) where + steps := tableSteps G H + evals_in_steps := tableTrace d e hd he G H a + steps_le_m := tableSteps_le G H + +def machine (d e : Nat) (hd : 0 < d) (he : 0 < e) : FinTM2 where + K := Tape + k₀ := graphArchive + k₁ := output + Γ _ := Bool + Λ := Label d e + main := .inl .copyFirst + σ := State Unit d e + initialState := clean d e hd he () + m := program d e hd he + +theorem machine_alphabet_finite (d e : Nat) (hd : 0 < d) (he : 0 < e) : + ∀ k, Finite ((machine d e hd he).Γ k) := fun _ => inferInstanceAs (Finite Bool) + +end IndependentSetsGames.Foundations.Complexity.MachineOverlayTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Placement.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Placement.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d32b3f5c91ccff6fc80027260a7996d83685552 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Placement.lean @@ -0,0 +1,160 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Reduction.MachineTransfer +open Turing +variable {α β : Type} [Fintype α] [Fintype β] + +variable {K Λ σ : Type} {Γ : K → Type} [DecidableEq K] + +def exitAt (dst : K) (exit : Option Λ) : TM2.Stmt Γ Λ (σ × Option (Γ dst)) := + match exit with + | none => .halt + | some label => .goto fun _ => label + +def loopAt (src dst : K) (f : Γ src → Γ dst) (fallback : Γ dst) + (loopLabel : Λ) (exit : Option Λ) : TM2.Stmt Γ Λ (σ × Option (Γ dst)) := + .pop src (fun state head => (state.1, head.map f)) + (.branch (fun state => state.2.isSome) + (.push dst (fun state => state.2.getD fallback) (.goto fun _ => loopLabel)) + (exitAt dst exit)) + +def tapesAt (src dst : K) (base : (k : K) → List (Γ k)) + (input : List (Γ src)) (output : List (Γ dst)) : (k : K) → List (Γ k) := + Function.update (Function.update base src input) dst output + +@[simp] theorem tapesAt_src (src dst : K) (distinct : src ≠ dst) + (base : (k : K) → List (Γ k)) (input : List (Γ src)) (output : List (Γ dst)) : + tapesAt src dst base input output src = input := by + simp [tapesAt, distinct] + +@[simp] theorem tapesAt_dst (src dst : K) + (base : (k : K) → List (Γ k)) (input : List (Γ src)) (output : List (Γ dst)) : + tapesAt src dst base input output dst = output := by + simp [tapesAt] + +theorem tapesAt_other (src dst k : K) (notSrc : k ≠ src) (notDst : k ≠ dst) + (base : (k : K) → List (Γ k)) (input : List (Γ src)) (output : List (Γ dst)) : + tapesAt src dst base input output k = base k := by + simp [tapesAt, notSrc, notDst] + +@[simp] theorem tapesAt_self (src dst : K) (base : (k : K) → List (Γ k)) : + tapesAt src dst base (base src) (base dst) = base := by + simp [tapesAt] + +private theorem update_tapesAt_src (src dst : K) (distinct : src ≠ dst) + (base : (k : K) → List (Γ k)) (input replacement : List (Γ src)) + (output : List (Γ dst)) : + Function.update (tapesAt src dst base input output) src replacement = + tapesAt src dst base replacement output := by + funext k + by_cases hs : k = src + · subst k + simp [tapesAt, distinct] + · by_cases hd : k = dst + · subst k + simp [tapesAt, Ne.symm distinct] + · simp [tapesAt, hs, hd] + +private theorem update_tapesAt_dst (src dst : K) + (base : (k : K) → List (Γ k)) (input : List (Γ src)) + (output replacement : List (Γ dst)) : + Function.update (tapesAt src dst base input output) dst replacement = + tapesAt src dst base input replacement := by + funext k + by_cases hd : k = dst + · subst k + simp [tapesAt] + · simp [tapesAt, hd] + +def nextAt (dst : K) (program : Λ → TM2.Stmt Γ Λ (σ × Option (Γ dst))) + (configuration : Option (TM2.Cfg Γ Λ (σ × Option (Γ dst)))) : + Option (TM2.Cfg Γ Λ (σ × Option (Γ dst))) := + configuration.bind (TM2.step program) + +theorem stepAt_empty (src dst : K) (distinct : src ≠ dst) + (f : Γ src → Γ dst) (fallback : Γ dst) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option (Γ dst))) + (atLoop : program loopLabel = loopAt src dst f fallback loopLabel exit) + (base : (k : K) → List (Γ k)) (output : List (Γ dst)) + (ambient : σ) (register : Option (Γ dst)) : + TM2.step program ⟨some loopLabel, (ambient, register), tapesAt src dst base [] output⟩ = + some ⟨exit, (ambient, none), tapesAt src dst base [] output⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (tapesAt src dst base [] output)) = _ + rw [atLoop] + cases exit <;> + simp [loopAt, exitAt, TM2.stepAux, tapesAt_src, distinct, update_tapesAt_src] + +theorem stepAt_cons (src dst : K) (distinct : src ≠ dst) + (f : Γ src → Γ dst) (fallback : Γ dst) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option (Γ dst))) + (atLoop : program loopLabel = loopAt src dst f fallback loopLabel exit) + (base : (k : K) → List (Γ k)) (head : Γ src) (input : List (Γ src)) + (output : List (Γ dst)) (ambient : σ) (register : Option (Γ dst)) : + TM2.step program + ⟨some loopLabel, (ambient, register), tapesAt src dst base (head :: input) output⟩ = + some ⟨some loopLabel, (ambient, some (f head)), + tapesAt src dst base input (f head :: output)⟩ := by + change some (TM2.stepAux (program loopLabel) (ambient, register) + (tapesAt src dst base (head :: input) output)) = _ + rw [atLoop] + simp [loopAt, TM2.stepAux, tapesAt_src, tapesAt_dst, distinct, + update_tapesAt_src, update_tapesAt_dst] + +theorem transferAt_steps (src dst : K) (distinct : src ≠ dst) + (f : Γ src → Γ dst) (fallback : Γ dst) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option (Γ dst))) + (atLoop : program loopLabel = loopAt src dst f fallback loopLabel exit) + (base : (k : K) → List (Γ k)) (input : List (Γ src)) (output : List (Γ dst)) + (ambient : σ) (register : Option (Γ dst)) : + (nextAt dst program)^[input.length + 1] + (some ⟨some loopLabel, (ambient, register), tapesAt src dst base input output⟩) = + some ⟨exit, (ambient, none), tapesAt src dst base [] (input.reverse.map f ++ output)⟩ := by + induction input generalizing output register with + | nil => + simpa only [List.length_nil, Nat.zero_add, Function.iterate_one, nextAt, + Option.bind_some, List.reverse_nil, List.map_nil, List.nil_append] + using stepAt_empty src dst distinct f fallback loopLabel exit program atLoop base output + ambient register + | cons head input ih => + rw [List.length_cons, Function.iterate_succ_apply] + change (nextAt dst program)^[input.length + 1] + (TM2.step program + ⟨some loopLabel, (ambient, register), tapesAt src dst base (head :: input) output⟩) = _ + rw [stepAt_cons src dst distinct f fallback loopLabel exit program atLoop, ih] + simp only [List.reverse_cons, List.map_append, List.map_singleton, + List.append_assoc, List.singleton_append] + +theorem transferAt_fromTapes (src dst : K) (distinct : src ≠ dst) + (f : Γ src → Γ dst) (fallback : Γ dst) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option (Γ dst))) + (atLoop : program loopLabel = loopAt src dst f fallback loopLabel exit) + (base : (k : K) → List (Γ k)) (ambient : σ) (register : Option (Γ dst)) : + (nextAt dst program)^[(base src).length + 1] + (some ⟨some loopLabel, (ambient, register), base⟩) = + some ⟨exit, (ambient, none), + tapesAt src dst base [] ((base src).reverse.map f ++ base dst)⟩ := by + simpa only [tapesAt_self] using + transferAt_steps src dst distinct f fallback loopLabel exit program atLoop base + (base src) (base dst) ambient register + +def transferAtInTime (src dst : K) (distinct : src ≠ dst) + (f : Γ src → Γ dst) (fallback : Γ dst) (loopLabel : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option (Γ dst))) + (atLoop : program loopLabel = loopAt src dst f fallback loopLabel exit) + (base : (k : K) → List (Γ k)) (ambient : σ) (register : Option (Γ dst)) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some loopLabel, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), + tapesAt src dst base [] ((base src).reverse.map f ++ base dst)⟩) + ((base src).length + 1) where + steps := (base src).length + 1 + evals_in_steps := transferAt_fromTapes src dst distinct f fallback loopLabel exit + program atLoop base ambient register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Reduction.MachineTransfer + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringGlobalEnumeration.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringGlobalEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbd4020b393e1328b0bd2a29f073c6e999ed4801 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringGlobalEnumeration.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineInitialize + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringGlobalEnumeration + +open PoweringMachineLoop PoweringMachineInitialize + +def headerTapeEquiv : HeaderTape ≃ Fin 4 where + toFun + | .source => 0 + | .counter => 1 + | .vertices => 2 + | .darts => 3 + invFun i := if i = 0 then .source else if i = 1 then .counter + else if i = 2 then .vertices else .darts + left_inv tape := by cases tape <;> rfl + right_inv i := by fin_cases i <;> rfl + +def unitTapeEquiv : Unit ≃ Fin 1 where + toFun _ := 0 + invFun _ := () + left_inv u := by cases u; rfl + right_inv i := (Fin.eq_zero i).symm + +def sharedTapeEquiv (max : Nat) : PoweringMachineTapes.Tape max ≃ Fin (11 + max) := + finSumFinEquiv + +def extraTapeEquiv (max : Nat) : ExtraTape max ≃ Fin (11 + max + 1) := + (Equiv.sumCongr (sharedTapeEquiv max) unitTapeEquiv).trans finSumFinEquiv + +def globalTapeEquiv (max : Nat) : GlobalTape max ≃ Fin (4 + (11 + max + 1)) := + (Equiv.sumCongr headerTapeEquiv (extraTapeEquiv max)).trans finSumFinEquiv + +def enumeration (max : Nat) : Fin (4 + (11 + max + 1)) ≃ GlobalTape max := + (globalTapeEquiv max).symm + +@[simp] theorem globalTapeEquiv_enumeration (max : Nat) (i : Fin (4 + (11 + max + 1))) : + globalTapeEquiv max (enumeration max i) = i := + (globalTapeEquiv max).apply_symm_apply i + +@[simp] theorem enumeration_globalTapeEquiv (max : Nat) (tape : GlobalTape max) : + enumeration max (globalTapeEquiv max tape) = tape := + (globalTapeEquiv max).symm_apply_apply tape + +@[simp] theorem source_index (max : Nat) : + (globalTapeEquiv max (.inl .source)).val = 0 := rfl + +@[simp] theorem counter_index (max : Nat) : + (globalTapeEquiv max (.inl .counter)).val = 1 := rfl + +@[simp] theorem vertices_index (max : Nat) : + (globalTapeEquiv max (.inl .vertices)).val = 2 := rfl + +@[simp] theorem darts_index (max : Nat) : + (globalTapeEquiv max (.inl .darts)).val = 3 := rfl + +theorem sharedRole_index (max : Nat) (i : Fin 11) : + (globalTapeEquiv max (.inr (.inl (.inl i)))).val = 4 + i.val := rfl + +theorem trajectory_index (max : Nat) (i : Fin max) : + (globalTapeEquiv max (.inr (.inl (.inr i)))).val = 4 + (11 + i.val) := rfl + +@[simp] theorem finalOutput_index (max : Nat) : + (globalTapeEquiv max (finalOutput max)).val = 4 + (11 + max) := rfl + +theorem card_globalTape (max : Nat) : + Fintype.card (GlobalTape max) = 4 + (11 + max + 1) := by + simpa only [Fintype.card_fin] using Fintype.card_congr (globalTapeEquiv max) + +theorem natCard_globalTape (max : Nat) : + Nat.card (GlobalTape max) = 4 + (11 + max + 1) := by + simpa only [Nat.card_fin] using Nat.card_congr (globalTapeEquiv max) + +def allTapes (max : Nat) : List (GlobalTape max) := List.ofFn (enumeration max) + +theorem allTapes_length (max : Nat) : (allTapes max).length = 4 + (11 + max + 1) := by + simpa only [allTapes] using (List.length_ofFn (f := enumeration max)) + +theorem mem_allTapes (max : Nat) (tape : GlobalTape max) : tape ∈ allTapes max := by + change tape ∈ List.ofFn (enumeration max) + apply List.mem_ofFn.mpr + exact ⟨globalTapeEquiv max tape, enumeration_globalTapeEquiv max tape⟩ + +end IndependentSetsGames.Foundations.Complexity.PoweringGlobalEnumeration +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRelation + +open Turing +open MachineComposition +open PCP + +variable {K Λ σ : Type} [DecidableEq K] +variable {n d : Nat} + +abbrev Alphabet (_ : K) := Bool + +def address (vertex : Fin n) (port : Fin d) (position : Fin 4096) : Nat := + (4098 * d) * vertex.val + (4098 * port.val + 4 + position.val) + +def value (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) + (position : Fin 4096) : Nat := + GraphTables.bitWord table.relations[PortTables.rowIndex n d (vertex, port)][position] + +theorem selected (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) + (position : Fin 4096) : + (PortTables.tableWords table)[address vertex port position]? = + some (value table vertex port position) := by + have h := PortTableLookup.relation_word table (PortTables.rowIndex n d (vertex, port)) position + have hindex : address vertex port position = + 4 + 4098 * (PortTables.rowIndex n d (vertex, port)).val + position.val := by + simp only [address, PortTables.rowIndex_val, Nat.mul_add, Nat.mul_assoc] + omega + rw [hindex] + exact h + +def instruction (source : K) (tape : Fin 5 → K) (port : Fin d) (position : Fin 4096) + (labels : MachineAffineLookup.Label → Λ) (exit : Option Λ) : + MachineAffineLookup.Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + MachineAffineLookup.instruction source tape (4098 * d) + (4098 * port.val + 4 + position.val) labels exit + +theorem relationTrace (source : K) (tape : Fin 5 → K) + (distinct : Function.Injective tape) (outside : ∀ i, source ≠ tape i) + (port : Fin d) (position : Fin 4096) + (labels : MachineAffineLookup.Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ l, program (labels l) = instruction source tape port position labels exit l) + (table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) + (tableWord : base (tape 0) = PortTables.tableBits table) (scratchEmpty : base (tape 4) = []) + (suffix : List Bool) (sourceWord : base source = encodeWord vertex.val ++ suffix) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[MachineAffineLookup.steps (PortTables.tableWords table) + vertex.val (4098 * d) (4098 * port.val + 4 + position.val)] + (some ⟨some (labels .seed), (ambient,register), base⟩) = + some ⟨exit, (ambient,none), MachineAffineLookup.finalTapes tape base + (PortTables.tableWords table) (address vertex port position) (value table vertex port position)⟩ := + MachineAffineLookup.affineLookupTrace source tape distinct outside + (4098 * d) (4098 * port.val + 4 + position.val) labels exit program atLabels + base (PortTables.tableWords table) tableWord scratchEmpty vertex.val suffix sourceWord + (value table vertex port position) (selected table vertex port position) ambient register + +theorem steps_le (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) + (position : Fin 4096) : + MachineAffineLookup.steps (PortTables.tableWords table) vertex.val + (4098 * d) (4098 * port.val + 4 + position.val) ≤ + 7 * (PortTables.tableBits table).length + 6 := + MachineAffineLookup.steps_le_table (PortTables.tableWords table) vertex.val + (4098 * d) (4098 * port.val + 4 + position.val) (value table vertex port position) + (selected table vertex port position) + (Nat.le_trans (Nat.le_of_lt vertex.isLt) (PortTables.vertices_le_tableBits_length table)) + +theorem value_eq_accepts (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) + (left right : PortTables.Label) : + value table vertex port (GraphTables.relationIndex (left, right)) = + GraphTables.bitWord (PortTables.accepts table (vertex, port) left right) := rfl + +def machine (degree : Nat) (port : Fin degree) (position : Fin 4096) : FinTM2 := + MachineAffineLookup.machine (4098 * degree) (4098 * port.val + 4 + position.val) + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRelation + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineEqualityField.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineEqualityField.lean new file mode 100644 index 0000000000000000000000000000000000000000..85006a859bb05f3900caeb5bf07ba04380e64fd5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineEqualityField.lean @@ -0,0 +1,310 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryEqualityBit +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineTapes + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineEqualityField + +open Turing +open MachineComposition +open PCP + +variable {K Λ A : Type} [DecidableEq K] +variable {max l r n d : Nat} + +abbrev Alphabet (_ : K) := Bool +abbrev Tape := PoweringMachineTapes.Tape +abbrev State := MachineUnaryEqualityBit.State +abbrev Label (l r : Nat) := + PoweringMachineWord.Label l ⊕ PoweringMachineWord.Label r ⊕ MachineUnaryEqualityBit.Label + +def entry (l r : Nat) : Label l r := .inl (PoweringMachineWord.entry l) + +def instruction (hl : l ≤ max) (hr : r ≤ max) (placement : Tape max → K) + (left : Fin l → Fin d) (right : Fin r → Fin d) + (labels : Label l r → Λ) (exit : Option Λ) : + Label l r → TM2.Stmt (Alphabet (K := K)) Λ (State A) + | .inl q => PoweringMachineWord.instruction l + (placement ∘ PoweringMachineTapes.wordPlacement hl false) left + (fun z => labels (.inl z)) + (some (labels (.inr (.inl (PoweringMachineWord.entry r))))) q + | .inr (.inl q) => PoweringMachineWord.instruction r + (placement ∘ PoweringMachineTapes.wordPlacement hr true) right + (fun z => labels (.inr (.inl z))) + (some (labels (.inr (.inr .seedLeft)))) q + | .inr (.inr q) => MachineUnaryEqualityBit.instruction + (placement ∘ PoweringMachineTapes.equalityPlacement max) + (fun z => labels (.inr (.inr z))) exit q + +def endpoint (graph : PortTables.Table n d) {t : Nat} (vertex : Fin n) + (ports : Fin t → Fin d) : Fin n := + PoweringWalks.wordEnd (PortTables.portGraph graph) t vertex ports + +def resultBit (graph : PortTables.Table n d) (vertex : Fin n) + (left : Fin l → Fin d) (right : Fin r → Fin d) : Bool := + decide (endpoint graph vertex left = endpoint graph vertex right) + +def wordTapes (graph : PortTables.Table n d) {t : Nat} (h : t ≤ max) + (placement : Tape max → K) (target : Bool) (vertex : Fin n) + (ports : Fin t → Fin d) (base : K → List Bool) : K → List Bool := + PoweringMachineWord.finalTapes graph t + (placement ∘ PoweringMachineTapes.wordPlacement h target) vertex ports base + +def finalTapes (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max) + (placement : Tape max → K) (vertex : Fin n) + (left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool) : + K → List Bool := + let afterLeft := wordTapes graph hl placement false vertex left base + let afterBoth := wordTapes graph hr placement true vertex right afterLeft + Function.update afterBoth (placement (.inl 10)) + (MachineUnaryEqualityBit.bitEncoding (resultBit graph vertex left right) ++ + afterBoth (placement (.inl 10))) + +def steps (graph : PortTables.Table n d) (vertex : Fin n) + (left : Fin l → Fin d) (right : Fin r → Fin d) : Nat := + PoweringMachineWord.steps graph l vertex left + + PoweringMachineWord.steps graph r vertex right + + MachineUnaryEqualityBit.steps (endpoint graph vertex left).val + (endpoint graph vertex right).val + +theorem steps_le (graph : PortTables.Table n d) (vertex : Fin n) + (left : Fin l → Fin d) (right : Fin r → Fin d) : + steps graph vertex left right ≤ + (14 * (l + r) + 10) * (PortTables.tableBits graph).length + 12 * (l + r) + 15 := by + have hl := PoweringMachineWord.steps_le graph l vertex left + have hr := PoweringMachineWord.steps_le graph r vertex right + have he := MachineUnaryEqualityBit.steps_le + (endpoint graph vertex left).val (endpoint graph vertex right).val + have hleft := Nat.le_trans (Nat.le_of_lt (endpoint graph vertex left).isLt) + (PortTables.vertices_le_tableBits_length graph) + have hright := Nat.le_trans (Nat.le_of_lt (endpoint graph vertex right).isLt) + (PortTables.vertices_le_tableBits_length graph) + unfold steps + simp only [Nat.mul_add, Nat.add_mul, Nat.mul_assoc] at hl hr ⊢ + omega + +theorem wordTapes_other (graph : PortTables.Table n d) {t : Nat} (h : t ≤ max) + (placement : Tape max → K) (target : Bool) (vertex : Fin n) + (ports : Fin t → Fin d) (base : K → List Bool) (k : K) + (hquery : k ≠ placement (.inl 2)) (hscan : k ≠ placement (.inl 3)) + (hreverse : k ≠ placement (.inl 4)) + (houtput : k ≠ placement (PoweringMachineTapes.endpoint max target)) + (hpositions : ∀ i : Fin max, k ≠ placement (.inr i)) : + wordTapes graph h placement target vertex ports base k = base k := by + apply PoweringMachineWord.finalTapes_other + · simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_one, + PoweringMachineTapes.query] using hquery + · simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_two, + PoweringMachineTapes.scan] using hscan + · simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_three, + PoweringMachineTapes.reverse] using hreverse + · simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five] using houtput + · intro i + simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_succ] using + hpositions (Fin.castLE h i) + +theorem wordTapes_role (graph : PortTables.Table n d) {t : Nat} (h : t ≤ max) + (placement : Tape max → K) (distinct : Function.Injective placement) + (target : Bool) (vertex : Fin n) (ports : Fin t → Fin d) + (base : K → List Bool) (j : Fin 11) + (hquery : j ≠ 2) (hscan : j ≠ 3) (hreverse : j ≠ 4) + (houtput : j ≠ if target then 7 else 6) : + wordTapes graph h placement target vertex ports base (placement (.inl j)) = + base (placement (.inl j)) := by + apply wordTapes_other + · intro he + exact hquery (Sum.inl.inj (distinct he)) + · intro he + exact hscan (Sum.inl.inj (distinct he)) + · intro he + exact hreverse (Sum.inl.inj (distinct he)) + · intro he + apply houtput + cases target <;> exact Sum.inl.inj (distinct he) + · intro i he + cases distinct he + +theorem finalTapes_other (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max) + (placement : Tape max → K) (vertex : Fin n) + (left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool) (k : K) + (hquery : k ≠ placement (.inl 2)) (hscan : k ≠ placement (.inl 3)) + (hreverse : k ≠ placement (.inl 4)) (hleft : k ≠ placement (.inl 6)) + (hright : k ≠ placement (.inl 7)) (hrow : k ≠ placement (.inl 10)) + (hpositions : ∀ i : Fin max, k ≠ placement (.inr i)) : + finalTapes graph hl hr placement vertex left right base k = base k := by + unfold finalTapes + rw [Function.update_of_ne hrow] + rw [wordTapes_other graph hr placement true vertex right _ k + hquery hscan hreverse hright hpositions] + exact wordTapes_other graph hl placement false vertex left base k + hquery hscan hreverse hleft hpositions + +theorem finalTapes_role (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max) + (placement : Tape max → K) (distinct : Function.Injective placement) (vertex : Fin n) + (left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool) + (j : Fin 11) (hrole : j = 0 ∨ j = 1 ∨ j = 5 ∨ j = 8 ∨ j = 9) : + finalTapes graph hl hr placement vertex left right base (placement (.inl j)) = + base (placement (.inl j)) := by + apply finalTapes_other + all_goals first + | (intro he; have hij := Sum.inl.inj (distinct he); rcases hrole with rfl | rfl | rfl | rfl | rfl <;> simp at hij) + | (intro i he; cases distinct he) + +theorem finalTapes_output (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max) + (placement : Tape max → K) (distinct : Function.Injective placement) (vertex : Fin n) + (left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool) : + finalTapes graph hl hr placement vertex left right base (placement (.inl 10)) = + MachineUnaryEqualityBit.bitEncoding (resultBit graph vertex left right) ++ + base (placement (.inl 10)) := by + unfold finalTapes + rw [Function.update_self, + wordTapes_role graph hr placement distinct true vertex right _ 10 + (by decide) (by decide) (by decide) (by decide), + wordTapes_role graph hl placement distinct false vertex left base 10 + (by decide) (by decide) (by decide) (by decide)] + +theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {u v : Nat} + (first : f^[u] a = b) (second : f^[v] b = c) : f^[u + v] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem fieldTrace (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max) + (placement : Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin n) (left : Fin l → Fin d) (right : Fin r → Fin d) + (labels : Label l r → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A)) + (atLabels : ∀ q, program (labels q) = instruction hl hr placement left right labels exit q) + (base : K → List Bool) + (tableWord : base (placement (.inl 0)) = PortTables.tableBits graph) + (scratchEmpty : base (placement (.inl 5)) = []) + (leftCopyEmpty : base (placement (.inl 8)) = []) + (rightCopyEmpty : base (placement (.inl 9)) = []) + (suffix : List Bool) (sourceWord : base (placement (.inl 1)) = encodeWord vertex.val ++ suffix) + (ambient : A) : + (advance (TM2.step program))^[steps graph vertex left right] + (some ⟨some (labels (entry l r)), MachineUnaryEqualityBit.clean ambient, base⟩) = + some ⟨exit, MachineUnaryEqualityBit.clean ambient, + finalTapes graph hl hr placement vertex left right base⟩ := by + let afterLeft := wordTapes graph hl placement false vertex left base + let afterBoth := wordTapes graph hr placement true vertex right afterLeft + have leftFrame (j : Fin 11) (h2 : j ≠ 2) (h3 : j ≠ 3) (h4 : j ≠ 4) (h6 : j ≠ 6) : + afterLeft (placement (.inl j)) = base (placement (.inl j)) := + wordTapes_role graph hl placement distinct false vertex left base j h2 h3 h4 h6 + have rightFrame (j : Fin 11) (h2 : j ≠ 2) (h3 : j ≠ 3) (h4 : j ≠ 4) (h7 : j ≠ 7) : + afterBoth (placement (.inl j)) = afterLeft (placement (.inl j)) := + wordTapes_role graph hr placement distinct true vertex right afterLeft j h2 h3 h4 h7 + have bothFrame (j : Fin 11) (h2 : j ≠ 2) (h3 : j ≠ 3) (h4 : j ≠ 4) + (h6 : j ≠ 6) (h7 : j ≠ 7) : + afterBoth (placement (.inl j)) = base (placement (.inl j)) := + (rightFrame j h2 h3 h4 h7).trans (leftFrame j h2 h3 h4 h6) + have leftRun := PoweringMachineWord.wordTrace graph l + (placement ∘ PoweringMachineTapes.wordPlacement hl false) + (distinct.comp (PoweringMachineTapes.wordPlacement_injective hl false)) vertex left + (fun q => labels (.inl q)) + (some (labels (.inr (.inl (PoweringMachineWord.entry r))))) program + (fun q => atLabels (.inl q)) base + (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_zero, + PoweringMachineTapes.table] using tableWord) + (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_four, + PoweringMachineTapes.scratch] using scratchEmpty) + suffix (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_first, + PoweringMachineTapes.start] using sourceWord) + (ambient, false, none) none + have rightTable : afterLeft (placement (.inl 0)) = PortTables.tableBits graph := + (leftFrame 0 (by decide) (by decide) (by decide) (by decide)).trans tableWord + have rightScratch : afterLeft (placement (.inl 5)) = [] := + (leftFrame 5 (by decide) (by decide) (by decide) (by decide)).trans scratchEmpty + have rightSource : afterLeft (placement (.inl 1)) = encodeWord vertex.val ++ suffix := + (leftFrame 1 (by decide) (by decide) (by decide) (by decide)).trans sourceWord + have rightRun := PoweringMachineWord.wordTrace graph r + (placement ∘ PoweringMachineTapes.wordPlacement hr true) + (distinct.comp (PoweringMachineTapes.wordPlacement_injective hr true)) vertex right + (fun q => labels (.inr (.inl q))) (some (labels (.inr (.inr .seedLeft)))) program + (fun q => atLabels (.inr (.inl q))) afterLeft + (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_zero, + PoweringMachineTapes.table] using rightTable) + (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_four, + PoweringMachineTapes.scratch] using rightScratch) + suffix (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_first, + PoweringMachineTapes.start] using rightSource) + (ambient, false, none) none + have leftEndpoint : afterBoth (placement (.inl 6)) = + encodeWord (endpoint graph vertex left).val ++ base (placement (.inl 6)) := by + rw [rightFrame 6 (by decide) (by decide) (by decide) (by decide)] + dsimp only [afterLeft, wordTapes] + simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five, + PoweringMachineTapes.endpoint_false, PoweringMachineTapes.leftEndpoint, + wordTapes, endpoint] using leftRun.2 + have rightEndpoint : afterBoth (placement (.inl 7)) = + encodeWord (endpoint graph vertex right).val ++ afterLeft (placement (.inl 7)) := by + dsimp only [afterBoth, wordTapes] + simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five, + PoweringMachineTapes.endpoint_true, PoweringMachineTapes.rightEndpoint, + wordTapes, endpoint] using rightRun.2 + have copiesLeft : afterBoth (placement (.inl 8)) = [] := + (bothFrame 8 (by decide) (by decide) (by decide) (by decide) (by decide)).trans leftCopyEmpty + have copiesRight : afterBoth (placement (.inl 9)) = [] := + (bothFrame 9 (by decide) (by decide) (by decide) (by decide) (by decide)).trans rightCopyEmpty + have scratchBoth : afterBoth (placement (.inl 5)) = [] := + (bothFrame 5 (by decide) (by decide) (by decide) (by decide) (by decide)).trans scratchEmpty + have equalityRun := MachineUnaryEqualityBit.equalityTrace + (placement ∘ PoweringMachineTapes.equalityPlacement max) + (distinct.comp (PoweringMachineTapes.equalityPlacement_injective max)) + (fun q => labels (.inr (.inr q))) exit program (fun q => atLabels (.inr (.inr q))) + afterBoth (endpoint graph vertex left).val (endpoint graph vertex right).val + (base (placement (.inl 6))) (afterLeft (placement (.inl 7))) + (by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_zero, + PoweringMachineTapes.leftEndpoint] using leftEndpoint) + (by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_one, + PoweringMachineTapes.rightEndpoint] using rightEndpoint) + (by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_two, + PoweringMachineTapes.leftCopy] using copiesLeft) + (by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_three, + PoweringMachineTapes.rightCopy] using copiesRight) + (by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_four, + PoweringMachineTapes.scratch] using scratchBoth) + ambient + have joined := joinTrace (joinTrace leftRun.1 rightRun.1) equalityRun + simpa only [steps, entry, MachineUnaryEqualityBit.clean, Function.comp_apply, + PoweringMachineTapes.equalityPlacement_five, PoweringMachineTapes.rowOutput, + finalTapes, resultBit, Fin.ext_iff, + afterLeft, afterBoth, wordTapes] using joined + +def fieldInTime (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max) + (placement : Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin n) (left : Fin l → Fin d) (right : Fin r → Fin d) + (labels : Label l r → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A)) + (atLabels : ∀ q, program (labels q) = instruction hl hr placement left right labels exit q) + (base : K → List Bool) + (tableWord : base (placement (.inl 0)) = PortTables.tableBits graph) + (scratchEmpty : base (placement (.inl 5)) = []) + (leftCopyEmpty : base (placement (.inl 8)) = []) + (rightCopyEmpty : base (placement (.inl 9)) = []) + (suffix : List Bool) (sourceWord : base (placement (.inl 1)) = encodeWord vertex.val ++ suffix) + (ambient : A) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels (entry l r)), MachineUnaryEqualityBit.clean ambient, base⟩ + (some ⟨exit, MachineUnaryEqualityBit.clean ambient, + finalTapes graph hl hr placement vertex left right base⟩) + ((14 * (l + r) + 10) * (PortTables.tableBits graph).length + 12 * (l + r) + 15) where + steps := steps graph vertex left right + evals_in_steps := fieldTrace graph hl hr placement distinct vertex left right labels exit program + atLabels base tableWord scratchEmpty leftCopyEmpty rightCopyEmpty suffix sourceWord ambient + steps_le_m := steps_le graph vertex left right + +def machine (degree : Nat) (hl : l ≤ max) (hr : r ≤ max) + (left : Fin l → Fin degree) (right : Fin r → Fin degree) : FinTM2 where + K := Tape max + k₀ := .inl 0 + k₁ := .inl 10 + Γ _ := Bool + Λ := Label l r + main := entry l r + σ := State Unit + initialState := MachineUnaryEqualityBit.clean () + m := instruction hl hr id left right id none + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineEqualityField + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineField.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineField.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee018758a63c8c8bdff0e3e78b16317030214131 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineField.lean @@ -0,0 +1,155 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineRelationField +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineEqualityField +import OAI.Combinatorics.IndependentSets.Expansion.PoweringFieldPlan + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineField + +open Turing MachineComposition PCP PoweringFieldPlan + +variable {K Λ A : Type} [DecidableEq K] {n d max : Nat} + +abbrev Tape := PoweringMachineTapes.Tape +abbrev State := MachineUnaryEqualityBit.State + +def Label : Instruction d → Type + | .relation path _ _ _ => PoweringMachineRelationField.Label path + | .equal left right => PoweringMachineEqualityField.Label left.length right.length + +instance labelFintype (op : Instruction d) : Fintype (Label op) := by + cases op <;> dsimp only [Label] <;> infer_instance + +instance labelDecidableEq (op : Instruction d) : DecidableEq (Label op) := by + cases op <;> dsimp only [Label] <;> infer_instance + +def entry : (op : Instruction d) → Label op + | .relation path _ _ _ => .inl (PoweringMachineWord.entry path.length) + | .equal left right => PoweringMachineEqualityField.entry left.length right.length + +def instruction (placement : Tape max → K) : (op : Instruction d) → op.radius ≤ max → + (Label op → Λ) → Option Λ → Label op → TM2.Stmt (fun _ : K => Bool) Λ (State A) + | .relation path port a b, bounded, labels, exit => + PoweringMachineRelationField.instruction placement path bounded port a b labels exit + | .equal left right, bounded, labels, exit => + PoweringMachineEqualityField.instruction + ((le_max_left _ _).trans bounded) ((le_max_right _ _).trans bounded) + placement left.get right.get labels exit + +def finalTapes (graph : PortTables.Table n d) (placement : Tape max → K) + (vertex : Fin n) : (op : Instruction d) → op.radius ≤ max → + (K → List Bool) → K → List Bool + | .relation path port a b, bounded, base => + PoweringMachineRelationField.finalTapes placement path bounded port a b graph vertex base + | .equal left right, bounded, base => + PoweringMachineEqualityField.finalTapes graph + ((le_max_left _ _).trans bounded) ((le_max_right _ _).trans bounded) + placement vertex left.get right.get base + +def steps (graph : PortTables.Table n d) (vertex : Fin n) : Instruction d → Nat + | .relation path port a b => PoweringMachineRelationField.steps path port a b graph vertex + | .equal left right => PoweringMachineEqualityField.steps graph vertex left.get right.get + +structure Ready (graph : PortTables.Table n d) (placement : Tape max → K) + (vertex : Fin n) (suffix : List Bool) (tapes : K → List Bool) : Prop where + table : tapes (placement (.inl 0)) = PortTables.tableBits graph + source : tapes (placement (.inl 1)) = encodeWord vertex.val ++ suffix + scratch : tapes (placement (.inl 5)) = [] + leftCopy : tapes (placement (.inl 8)) = [] + rightCopy : tapes (placement (.inl 9)) = [] + +theorem finalTapes_role (graph : PortTables.Table n d) (placement : Tape max → K) + (distinct : Function.Injective placement) (vertex : Fin n) + (op : Instruction d) (bounded : op.radius ≤ max) (base : K → List Bool) + (j : Fin 11) (role : j = 0 ∨ j = 1 ∨ j = 5 ∨ j = 8 ∨ j = 9) : + finalTapes graph placement vertex op bounded base (placement (.inl j)) = + base (placement (.inl j)) := by + cases op with + | relation path port a b => + apply PoweringMachineRelationField.finalTapes_frame placement distinct path bounded + port a b graph vertex base j + all_goals rcases role with rfl | rfl | rfl | rfl | rfl <;> decide + | equal left right => + exact PoweringMachineEqualityField.finalTapes_role graph _ _ placement distinct + vertex left.get right.get base j role + +theorem ready_finalTapes (graph : PortTables.Table n d) (placement : Tape max → K) + (distinct : Function.Injective placement) (vertex : Fin n) + (op : Instruction d) (bounded : op.radius ≤ max) (base : K → List Bool) + (suffix : List Bool) (ready : Ready graph placement vertex suffix base) : + Ready graph placement vertex suffix (finalTapes graph placement vertex op bounded base) := by + constructor + · rw [finalTapes_role graph placement distinct vertex op bounded base 0 (by simp)] + exact ready.table + · rw [finalTapes_role graph placement distinct vertex op bounded base 1 (by simp)] + exact ready.source + · rw [finalTapes_role graph placement distinct vertex op bounded base 5 (by simp)] + exact ready.scratch + · rw [finalTapes_role graph placement distinct vertex op bounded base 8 (by simp)] + exact ready.leftCopy + · rw [finalTapes_role graph placement distinct vertex op bounded base 9 (by simp)] + exact ready.rightCopy + +theorem finalTapes_other (graph : PortTables.Table n d) (placement : Tape max → K) + (vertex : Fin n) (op : Instruction d) (bounded : op.radius ≤ max) + (base : K → List Bool) (k : K) (outside : ∀ i, k ≠ placement i) : + finalTapes graph placement vertex op bounded base k = base k := by + cases op with + | relation path port a b => + exact PoweringMachineRelationField.finalTapes_other placement path bounded port a b + graph vertex base k outside + | equal left right => + exact PoweringMachineEqualityField.finalTapes_other graph _ _ placement vertex + left.get right.get base k (outside _) (outside _) (outside _) (outside _) + (outside _) (outside _) (fun i => outside _) + +theorem fieldTrace (graph : PortTables.Table n d) (placement : Tape max → K) + (distinct : Function.Injective placement) (vertex : Fin n) + (op : Instruction d) (bounded : op.radius ≤ max) + (labels : Label op → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A)) + (atLabels : ∀ l, program (labels l) = instruction placement op bounded labels exit l) + (base : K → List Bool) (suffix : List Bool) + (ready : Ready graph placement vertex suffix base) (ambient : A) : + (advance (TM2.step program))^[steps graph vertex op] + (some ⟨some (labels (entry op)), MachineUnaryEqualityBit.clean ambient, base⟩) = + some ⟨exit, MachineUnaryEqualityBit.clean ambient, + finalTapes graph placement vertex op bounded base⟩ := by + cases op with + | relation path port a b => + exact (PoweringMachineRelationField.fieldTrace placement distinct path bounded port a b + labels exit program atLabels graph vertex base ready.table ready.scratch suffix + ready.source ambient).1 + | equal left right => + exact PoweringMachineEqualityField.fieldTrace graph _ _ placement distinct + vertex left.get right.get labels exit program atLabels base ready.table ready.scratch + ready.leftCopy ready.rightCopy suffix ready.source ambient + +theorem finalTapes_output (graph : PortTables.Table n d) (placement : Tape max → K) + (distinct : Function.Injective placement) (vertex : Fin n) + (op : Instruction d) (bounded : op.radius ≤ max) (base : K → List Bool) + (suffix : List Bool) (ready : Ready graph placement vertex suffix base) : + finalTapes graph placement vertex op bounded base (placement (.inl 10)) = + PoweringMachineRow.encodeBit (evaluate graph vertex op) ++ base (placement (.inl 10)) := by + cases op with + | relation path port a b => + have h := (PoweringMachineRelationField.fieldTrace placement distinct path bounded port a b + id none (PoweringMachineRelationField.instruction placement path bounded port a b id none) + (fun _ => rfl) graph vertex base ready.table ready.scratch suffix ready.source ()).2 + have he : ∀ bit : Bool, encodeWord (GraphTables.bitWord bit) = + PoweringMachineRow.encodeBit bit := by intro bit; cases bit <;> rfl + simpa only [finalTapes, PoweringMachineRelationField.bit, PoweringMachineRelationField.endpoint, + evaluate, he] using h + | equal left right => + have h := PoweringMachineEqualityField.finalTapes_output graph + ((le_max_left _ _).trans bounded) ((le_max_right _ _).trans bounded) placement distinct + vertex left.get right.get base + have he : ∀ bit : Bool, MachineUnaryEqualityBit.bitEncoding bit = + PoweringMachineRow.encodeBit bit := by intro bit; cases bit <;> rfl + simpa only [finalTapes, PoweringMachineEqualityField.resultBit, PoweringMachineEqualityField.endpoint, + PoweringReach.wordEnd_eq_walkEnd_ofFn, List.ofFn_get, evaluate, he] using h + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineField + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineFinish.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineFinish.lean new file mode 100644 index 0000000000000000000000000000000000000000..96c07340ce401d11bcd118609edf6489d95525b9 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineFinish.lean @@ -0,0 +1,191 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrainMany + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineFinish + +open Turing MachineComposition + +variable {K Λ σ : Type} [DecidableEq K] {N : Nat} + +abbrev Alphabet (_ : K) := Bool + +abbrev Label (enumeration : Fin N ≃ K) (output : K) := + MachineUnaryAffineAt.Label ⊕ (MachineUnaryAffineAt.Label ⊕ + MachineDrainMany.Label (MachineDrainMany.workTapes enumeration output)) + +def copyInstruction (source scratch output : K) + (labels : MachineUnaryAffineAt.Label → Λ) (exit : Option Λ) : + MachineUnaryAffineAt.Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .seed => MachineUnaryAffineAt.seed output 0 (labels .scan) + | .scan => MachineUnaryAffineAt.scan source scratch output 1 (labels .scan) (labels .restore) + | .restore => Reduction.MachineTransfer.loopAt scratch source id false (labels .restore) exit + +def instruction (enumeration : Fin N ≃ K) (headerV headerD output scratch : K) + (labels : Label enumeration output → Λ) : + Label enumeration output → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .inl l => copyInstruction headerD scratch output (fun q => labels (.inl q)) + (some (labels (.inr (.inl .seed)))) l + | .inr (.inl l) => copyInstruction headerV scratch output + (fun q => labels (.inr (.inl q))) + (MachineDrainMany.entry (MachineDrainMany.workTapes enumeration output) + (fun q => labels (.inr (.inr q))) none) l + | .inr (.inr l) => MachineDrainMany.instruction + (MachineDrainMany.workTapes enumeration output) (fun q => labels (.inr (.inr q))) none l + +def program (enumeration : Fin N ≃ K) (headerV headerD output scratch : K) : + Label enumeration output → + TM2.Stmt (Alphabet (K := K)) (Label enumeration output) (σ × Option Bool) := + instruction enumeration headerV headerD output scratch id + +def afterD (output : K) (base : K → List Bool) (m : Nat) : K → List Bool := + Function.update base output (encodeWord m ++ base output) + +def afterHeaders (output : K) (base : K → List Bool) (n m : Nat) : K → List Bool := + Function.update base output (encodeWords [n, m] ++ base output) + +@[simp] theorem afterHeaders_output (output : K) (base : K → List Bool) (n m : Nat) : + afterHeaders output base n m output = encodeWords [n, m] ++ base output := by + simp only [afterHeaders, Function.update_self] + +theorem afterHeaders_other (output : K) (base : K → List Bool) (n m : Nat) + (k : K) (hk : k ≠ output) : afterHeaders output base n m k = base k := + Function.update_of_ne hk _ _ + +def copySteps (n m : Nat) : Nat := (2 * (m + 1) + 1) + (2 * (n + 1) + 1) + +theorem copySteps_eq (n m : Nat) : copySteps n m = 2 * (n + m) + 6 := by + unfold copySteps + omega + +def steps (enumeration : Fin N ≃ K) (output : K) (base : K → List Bool) (n m : Nat) : Nat := + copySteps n m + MachineDrainMany.steps (MachineDrainMany.workTapes enumeration output) + (afterHeaders output base n m) + +def budget (enumeration : Fin N ≃ K) (output : K) (base : K → List Bool) (n m : Nat) : Nat := + copySteps n m + (MachineDrainMany.lengthSum (MachineDrainMany.workTapes enumeration output) + (afterHeaders output base n m) + (MachineDrainMany.workTapes enumeration output).length) + +theorem trace_trans {α : Type*} (f : α → α) {a b : Nat} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem traceAt (enumeration : Fin N ≃ K) (headerV headerD output scratch : K) + (hvs : headerV ≠ scratch) (hvo : headerV ≠ output) + (hds : headerD ≠ scratch) (hdo : headerD ≠ output) (hso : scratch ≠ output) + (labels : Label enumeration output → Λ) + (target : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ l, target (labels l) = + instruction enumeration headerV headerD output scratch labels l) + (base : K → List Bool) (n m : Nat) (suffixV suffixD : List Bool) + (wordV : base headerV = encodeWord n ++ suffixV) + (wordD : base headerD = encodeWord m ++ suffixD) + (scratchEmpty : base scratch = []) (ambient : σ) (register : Option Bool) : + (advance (TM2.step target))^[steps enumeration output base n m] + (some ⟨some (labels (.inl .seed)), (ambient, register), base⟩) = + some ⟨none, (ambient, none), + MachineDrainMany.haltTapes output (encodeWords [n, m] ++ base output)⟩ := by + have hd := MachineUnaryAffineAt.seededAffineTrace headerD scratch output hds hdo hso 1 0 + (labels (.inl .seed)) (labels (.inl .scan)) (labels (.inl .restore)) + (some (labels (.inr (.inl .seed)))) target + (atLabels (.inl .seed)) (atLabels (.inl .scan)) (atLabels (.inl .restore)) + base m suffixD wordD scratchEmpty ambient register + simp only [Nat.one_mul, Nat.add_zero] at hd + change (advance (TM2.step target))^[2 * (m + 1) + 1] + (some ⟨some (labels (.inl .seed)), (ambient, register), base⟩) = + some ⟨some (labels (.inr (.inl .seed))), (ambient, none), afterD output base m⟩ at hd + have wordV' : afterD output base m headerV = encodeWord n ++ suffixV := by + simpa only [afterD, Function.update_of_ne hvo] using wordV + have scratchEmpty' : afterD output base m scratch = [] := by + simpa only [afterD, Function.update_of_ne hso] using scratchEmpty + have hv := MachineUnaryAffineAt.seededAffineTrace headerV scratch output hvs hvo hso 1 0 + (labels (.inr (.inl .seed))) (labels (.inr (.inl .scan))) + (labels (.inr (.inl .restore))) + (MachineDrainMany.entry (MachineDrainMany.workTapes enumeration output) + (fun q => labels (.inr (.inr q))) none) + target (atLabels (.inr (.inl .seed))) (atLabels (.inr (.inl .scan))) + (atLabels (.inr (.inl .restore))) (afterD output base m) n suffixV + wordV' scratchEmpty' ambient none + simp only [Nat.one_mul, Nat.add_zero] at hv + have copied : Function.update (afterD output base m) output + (encodeWord n ++ afterD output base m output) = afterHeaders output base n m := by + simp only [afterD, afterHeaders, Function.update_self, Function.update_idem, + encodeWords, List.append_nil, List.append_assoc] + rw [copied] at hv + have cleaned := MachineDrainMany.cleanupTrace enumeration output + (fun q => labels (.inr (.inr q))) target (fun l => atLabels (.inr (.inr l))) + (afterHeaders output base n m) ambient + rw [afterHeaders_output] at cleaned + have total := trace_trans _ (trace_trans _ hd hv) cleaned + simpa only [steps, copySteps] using total + +theorem trace (enumeration : Fin N ≃ K) (headerV headerD output scratch : K) + (hvs : headerV ≠ scratch) (hvo : headerV ≠ output) + (hds : headerD ≠ scratch) (hdo : headerD ≠ output) (hso : scratch ≠ output) + (base : K → List Bool) (n m : Nat) (suffixV suffixD : List Bool) + (wordV : base headerV = encodeWord n ++ suffixV) + (wordD : base headerD = encodeWord m ++ suffixD) + (scratchEmpty : base scratch = []) (ambient : σ) (register : Option Bool) : + (advance (TM2.step (program enumeration headerV headerD output scratch)))^[ + steps enumeration output base n m] + (some ⟨some (.inl .seed), (ambient, register), base⟩) = + some ⟨none, (ambient, none), + MachineDrainMany.haltTapes output (encodeWords [n, m] ++ base output)⟩ := + traceAt enumeration headerV headerD output scratch hvs hvo hds hdo hso id + (program enumeration headerV headerD output scratch) (fun _ => rfl) + base n m suffixV suffixD wordV wordD scratchEmpty ambient register + +theorem steps_le_budget (enumeration : Fin N ≃ K) (output : K) + (base : K → List Bool) (n m : Nat) : + steps enumeration output base n m ≤ budget enumeration output base n m := + Nat.add_le_add_left (MachineDrainMany.steps_le + (MachineDrainMany.workTapes enumeration output) (afterHeaders output base n m)) _ + +theorem afterHeaders_length_le (output : K) (base : K → List Bool) (n m bound : Nat) + (bounded : ∀ k, (base k).length ≤ bound) (k : K) : + (afterHeaders output base n m k).length ≤ bound + n + m + 2 := by + by_cases hk : k = output + · subst k + rw [afterHeaders_output] + have hb := bounded output + simp only [List.length_append, encodeWords, encodeWord_length, List.length_nil] + omega + · rw [afterHeaders_other output base n m k hk] + have hb := bounded k + omega + +theorem steps_le_uniform (enumeration : Fin N ≃ K) (output : K) + (base : K → List Bool) (n m bound : Nat) + (bounded : ∀ k, (base k).length ≤ bound) : + steps enumeration output base n m ≤ 2 * (n + m) + 6 + N * (bound + n + m + 3) := by + have hc := MachineDrainMany.steps_le_uniform (MachineDrainMany.workTapes enumeration output) + (afterHeaders output base n m) (bound + n + m + 2) + (afterHeaders_length_le output base n m bound bounded) + have hl := MachineDrainMany.workTapes_length_le enumeration output + have hm := Nat.mul_le_mul_right (bound + n + m + 3) hl + rw [show bound + n + m + 2 + 1 = bound + n + m + 3 by omega] at hc + unfold steps + rw [copySteps_eq] + exact Nat.add_le_add_left (hc.trans hm) _ + +def execution (enumeration : Fin N ≃ K) (headerV headerD output scratch : K) + (hvs : headerV ≠ scratch) (hvo : headerV ≠ output) + (hds : headerD ≠ scratch) (hdo : headerD ≠ output) (hso : scratch ≠ output) + (base : K → List Bool) (n m : Nat) (suffixV suffixD : List Bool) + (wordV : base headerV = encodeWord n ++ suffixV) + (wordD : base headerD = encodeWord m ++ suffixD) + (scratchEmpty : base scratch = []) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (program enumeration headerV headerD output scratch)) + ⟨some (.inl .seed), (ambient, register), base⟩ + (some ⟨none, (ambient, none), + MachineDrainMany.haltTapes output (encodeWords [n, m] ++ base output)⟩) + (budget enumeration output base n m) where + steps := steps enumeration output base n m + evals_in_steps := trace enumeration headerV headerD output scratch hvs hvo hds hdo hso + base n m suffixV suffixD wordV wordD scratchEmpty ambient register + steps_le_m := steps_le_budget enumeration output base n m + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineFinish + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineGlobal.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineGlobal.lean new file mode 100644 index 0000000000000000000000000000000000000000..44f56d8b498685e2881a0ac9dc1ee3015f9ca3d5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineGlobal.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineOuterLoop +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineFinish + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineGlobal + +open Turing + +abbrev Tape (n : Nat) := + PoweringMachineInitialize.GlobalTape (PoweringMachineRowBody.capacity n) + +abbrev State (d n : Nat) := + PoweringMasterState.Master (PoweringMachineRowBody.bufferSize d n) + +def placement (n : Nat) : + PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → Tape n := + PoweringMachineInitialize.commonPlacement (PoweringMachineRowBody.capacity n) + +def inputTape (n : Nat) : Tape n := + placement n (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n)) + +def outputTape (n : Nat) : Tape n := + PoweringMachineInitialize.finalOutput (PoweringMachineRowBody.capacity n) + +def headerVertices (n : Nat) : Tape n := .inl PoweringMachineLoop.HeaderTape.vertices +def headerDarts (n : Nat) : Tape n := .inl PoweringMachineLoop.HeaderTape.darts + +def enumeration (n : Nat) : + Fin (4 + (11 + PoweringMachineRowBody.capacity n + 1)) ≃ Tape n := + PoweringGlobalEnumeration.enumeration (PoweringMachineRowBody.capacity n) + +abbrev FinishLabel (n : Nat) := PoweringMachineFinish.Label (enumeration n) (outputTape n) + +abbrev Label (d n : Nat) := PoweringMachineInitialize.Label ⊕ + (Bool ⊕ (PoweringMachineVertex.Label d n ⊕ FinishLabel n)) + +instance labelFintype (d n : Nat) : Fintype (Label d n) := + inferInstanceAs (Fintype (PoweringMachineInitialize.Label ⊕ + (Bool ⊕ (PoweringMachineVertex.Label d n ⊕ FinishLabel n)))) + +def initLabels (d n : Nat) : PoweringMachineInitialize.Label → Label d n := Sum.inl +def guardLabel (d n : Nat) : Label d n := .inr (.inl false) +def bridgeLabel (d n : Nat) : Label d n := .inr (.inl true) + +def vertexLabels (d n : Nat) (label : PoweringMachineVertex.Label d n) : Label d n := + .inr (.inr (.inl label)) + +def finishLabels (d n : Nat) (label : FinishLabel n) : Label d n := + .inr (.inr (.inr label)) + +def finishEntry (d n : Nat) : Label d n := finishLabels d n (.inl .seed) + +def main (d n : Nat) : Label d n := initLabels d n (.inr .seed) + +def program (d n : Nat) : + Label d n → TM2.Stmt (fun _ : Tape n => Bool) (Label d n) (State d n) + | .inl label => PoweringMachineInitialize.instruction + (PoweringMachineRowBody.capacity n) (PoweringMachineRowBody.bufferSize d n) + (PCP.PoweringTableLayout.blockSize d n) (initLabels d n) (some (guardLabel d n)) label + | .inr (.inl false) => MachineUnaryCounter.guard + (placement n (PoweringMachineTapes.start (PoweringMachineRowBody.capacity n))) + (bridgeLabel d n) (finishEntry d n) + | .inr (.inl true) => PoweringMachineOuterLoop.bridge d n (vertexLabels d n) (guardLabel d n) + | .inr (.inr (.inl label)) => PoweringMachineVertex.instruction n (placement n) (outputTape n) + (vertexLabels d n) (some (guardLabel d n)) label + | .inr (.inr (.inr label)) => PoweringMachineFinish.instruction (enumeration n) + (headerVertices n) (headerDarts n) (outputTape n) + (placement n (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n))) + (finishLabels d n) label + +@[simp] theorem atInit (d n : Nat) (label : PoweringMachineInitialize.Label) : + program d n (initLabels d n label) = PoweringMachineInitialize.instruction + (PoweringMachineRowBody.capacity n) (PoweringMachineRowBody.bufferSize d n) + (PCP.PoweringTableLayout.blockSize d n) (initLabels d n) (some (guardLabel d n)) label := rfl + +@[simp] theorem atGuard (d n : Nat) : + program d n (guardLabel d n) = MachineUnaryCounter.guard + (placement n (PoweringMachineTapes.start (PoweringMachineRowBody.capacity n))) + (bridgeLabel d n) (finishEntry d n) := rfl + +@[simp] theorem atBridge (d n : Nat) : + program d n (bridgeLabel d n) = + PoweringMachineOuterLoop.bridge d n (vertexLabels d n) (guardLabel d n) := rfl + +@[simp] theorem atVertex (d n : Nat) (label : PoweringMachineVertex.Label d n) : + program d n (vertexLabels d n label) = PoweringMachineVertex.instruction n + (placement n) (outputTape n) (vertexLabels d n) (some (guardLabel d n)) label := rfl + +@[simp] theorem atFinish (d n : Nat) (label : FinishLabel n) : + program d n (finishLabels d n label) = PoweringMachineFinish.instruction (enumeration n) + (headerVertices n) (headerDarts n) (outputTape n) + (placement n (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n))) + (finishLabels d n) label := rfl + +def machine (d n : Nat) : FinTM2 where + K := Tape n + k₀ := inputTape n + k₁ := outputTape n + Γ _ := Bool + Λ := Label d n + main := main d n + σ := State d n + initialState := PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n) + m := program d n + +@[simp] theorem machine_code (d n : Nat) (label : Label d n) : + (machine d n).m label = program d n label := rfl + +@[simp] theorem machine_main (d n : Nat) : (machine d n).main = main d n := rfl + +@[simp] theorem machine_initialState (d n : Nat) : + (machine d n).initialState = PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n) := rfl + +theorem input_ne_output (n : Nat) : inputTape n ≠ outputTape n := + PoweringMachineInitialize.commonPlacement_ne_finalOutput (PoweringMachineRowBody.capacity n) + (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n)) + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineGlobal + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineInitialize.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineInitialize.lean new file mode 100644 index 0000000000000000000000000000000000000000..dae87d8848198e7ff27d925374a6076b28165719 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineInitialize.lean @@ -0,0 +1,328 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Enumeration +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineTapes + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineInitialize + +open Turing +open PoweringMachineLoop PoweringMasterState + +abbrev ExtraTape (max : Nat) := PoweringMachineTapes.Tape max ⊕ Unit +abbrev GlobalTape (max : Nat) := HeaderTape ⊕ ExtraTape max +abbrev Label := HeaderLabel ⊕ MachineUnaryAffineAt.Label + +def finalOutput (max : Nat) : GlobalTape max := .inr (.inr ()) + +def commonPlacement (max : Nat) (tape : PoweringMachineTapes.Tape max) : GlobalTape max := + if tape = PoweringMachineTapes.start max then .inl .counter else .inr (.inl tape) + +theorem commonPlacement_injective (max : Nat) : Function.Injective (commonPlacement max) := by + intro a b h + by_cases ha : a = PoweringMachineTapes.start max <;> + by_cases hb : b = PoweringMachineTapes.start max <;> + simp_all [commonPlacement] + +@[simp] theorem commonPlacement_start (max : Nat) : + commonPlacement max (PoweringMachineTapes.start max) = .inl .counter := by + simp [commonPlacement] + +@[simp] theorem commonPlacement_table (max : Nat) : + commonPlacement max (PoweringMachineTapes.table max) = + .inr (.inl (PoweringMachineTapes.table max)) := by + simp [commonPlacement, PoweringMachineTapes.table, PoweringMachineTapes.start] + +@[simp] theorem commonPlacement_scratch (max : Nat) : + commonPlacement max (PoweringMachineTapes.scratch max) = + .inr (.inl (PoweringMachineTapes.scratch max)) := by + simp [commonPlacement, PoweringMachineTapes.scratch, PoweringMachineTapes.start] + +@[simp] theorem commonPlacement_rowOutput (max : Nat) : + commonPlacement max (PoweringMachineTapes.rowOutput max) = + .inr (.inl (PoweringMachineTapes.rowOutput max)) := by + simp [commonPlacement, PoweringMachineTapes.rowOutput, PoweringMachineTapes.start] + +theorem commonPlacement_ne_finalOutput (max : Nat) (tape : PoweringMachineTapes.Tape max) : + commonPlacement max tape ≠ finalOutput max := by + by_cases h : tape = PoweringMachineTapes.start max <;> + simp [commonPlacement, finalOutput, h] + +theorem commonPlacement_ne_header (max : Nat) (tape : PoweringMachineTapes.Tape max) + (field : HeaderTape) (hne : field ≠ .counter) : + commonPlacement max tape ≠ .inl field := by + by_cases h : tape = PoweringMachineTapes.start max <;> + simp [commonPlacement, h, Ne.symm hne] + +def headerPlacement (max : Nat) (tape : PoweringMachineTapes.Tape max) : GlobalTape max := + if tape = PoweringMachineTapes.rowOutput max then finalOutput max + else commonPlacement max tape + +theorem headerPlacement_injective (max : Nat) : Function.Injective (headerPlacement max) := by + intro a b h + by_cases ha : a = PoweringMachineTapes.rowOutput max + · subst a + by_cases hb : b = PoweringMachineTapes.rowOutput max + · exact hb.symm + · simp only [headerPlacement, ite_eq_right hb] at h + exact False.elim (commonPlacement_ne_finalOutput max b h.symm) + · by_cases hb : b = PoweringMachineTapes.rowOutput max + · subst b + simp only [headerPlacement, ite_eq_right ha] at h + exact False.elim (commonPlacement_ne_finalOutput max a h) + · simp only [headerPlacement, ite_eq_right ha, ite_eq_right hb] at h + exact commonPlacement_injective max h + +@[simp] theorem headerPlacement_rowOutput (max : Nat) : + headerPlacement max (PoweringMachineTapes.rowOutput max) = finalOutput max := by + simp [headerPlacement] + +theorem headerPlacement_eq_common (max : Nat) (tape : PoweringMachineTapes.Tape max) + (hne : tape ≠ PoweringMachineTapes.rowOutput max) : + headerPlacement max tape = commonPlacement max tape := by simp [headerPlacement, hne] + +theorem headerPlacement_ne_data (max : Nat) (tape : PoweringMachineTapes.Tape max) : + headerPlacement max tape ≠ commonPlacement max (PoweringMachineTapes.rowOutput max) := by + by_cases h : tape = PoweringMachineTapes.rowOutput max + · simp only [headerPlacement, ite_eq_left h] + exact Ne.symm (commonPlacement_ne_finalOutput max _) + · rw [headerPlacement_eq_common max tape h] + exact fun heq => h (commonPlacement_injective max heq) + +theorem headerPlacement_ne_header (max : Nat) (tape : PoweringMachineTapes.Tape max) + (field : HeaderTape) (hne : field ≠ .counter) : + headerPlacement max tape ≠ .inl field := by + by_cases h : tape = PoweringMachineTapes.rowOutput max + · simp [headerPlacement, h, finalOutput] + · rw [headerPlacement_eq_common max tape h] + exact commonPlacement_ne_header max tape field hne + +private def castTapes {K : Type} {Γ Δ : K → Type} (h : Γ = Δ) + (tapes : ∀ k, List (Γ k)) : ∀ k, List (Δ k) := h ▸ tapes + +def castStatement {K Λ σ : Type} {Γ Δ : K → Type} (h : Γ = Δ) + (q : TM2.Stmt Γ Λ σ) : TM2.Stmt Δ Λ σ := h ▸ q + +def castConfiguration {K Λ σ : Type} {Γ Δ : K → Type} (h : Γ = Δ) + (c : TM2.Cfg Γ Λ σ) : TM2.Cfg Δ Λ σ := h ▸ c + +private theorem castTapes_apply {K : Type} {Γ Δ : K → Type} (h : Γ = Δ) + (tapes : ∀ k, List (Γ k)) (k : K) : + castTapes h tapes k = cast (congrArg (fun alphabet => List (alphabet k)) h) (tapes k) := by + cases h + rfl + +private theorem castConfiguration_mk {K Λ σ : Type} {Γ Δ : K → Type} (h : Γ = Δ) + (label : Option Λ) (state : σ) (tapes : ∀ k, List (Γ k)) : + castConfiguration h ⟨label, state, tapes⟩ = ⟨label, state, castTapes h tapes⟩ := by + cases h + rfl + +private theorem stepAux_cast {K Λ σ : Type} [DecidableEq K] + {Γ Δ : K → Type} (h : Γ = Δ) (q : TM2.Stmt Γ Λ σ) + (state : σ) (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (castStatement h q) state (castTapes h tapes) = + castConfiguration h (TM2.stepAux q state tapes) := by + cases h + rfl + +private theorem boolAlphabet_eq (max : Nat) : + MachineEmbedding.Alphabet HeaderAlphabet (fun _ : ExtraTape max => Bool) = + (fun _ : GlobalTape max => Bool) := by + funext tape + cases tape <;> rfl + +def mergeTapes {max : Nat} (header : HeaderTape → List Bool) + (extra : ExtraTape max → List Bool) : GlobalTape max → List Bool + | .inl k => header k + | .inr e => extra e + +private theorem castTapes_embedding {max : Nat} (header : HeaderTape → List Bool) + (extra : ExtraTape max → List Bool) : + castTapes (boolAlphabet_eq max) (MachineEmbedding.tapes header extra) = + mergeTapes header extra := by + funext tape + rw [castTapes_apply] + cases tape <;> rfl + +private def dropUnit (N : Nat) : (Master N × Unit) ≃ Master N where + toFun := Prod.fst + invFun state := (state, ()) + left_inv := by rintro ⟨state, ⟨⟩⟩; rfl + right_inv := by intro state; rfl + +def headerStatement (max N B : Nat) (label : HeaderLabel) : + TM2.Stmt (fun _ : GlobalTape max => Bool) Label (Master N) := + MachineStateEquiv.statement (dropUnit N) + (castStatement (boolAlphabet_eq max) + (MachineEmbedding.statement (Λextra := MachineUnaryAffineAt.Label) + (τ := Unit) none (headerProgram (σ := OtherRegisters N) B label))) + +def headerConfiguration {max N : Nat} (extra : ExtraTape max → List Bool) + (c : TM2.Cfg HeaderAlphabet HeaderLabel (Master N)) : + TM2.Cfg (fun _ : GlobalTape max => Bool) Label (Master N) := + ⟨c.l.map Sum.inl, c.var, mergeTapes c.stk extra⟩ + +private theorem headerConfiguration_eq {max N : Nat} (extra : ExtraTape max → List Bool) + (c : TM2.Cfg HeaderAlphabet HeaderLabel (Master N)) : + headerConfiguration extra c = + MachineStateEquiv.configuration (dropUnit N) + (castConfiguration (boolAlphabet_eq max) + (MachineEmbedding.configuration (Λextra := MachineUnaryAffineAt.Label) + none () extra c)) := by + cases c with + | mk label state tapes => + simp only [MachineEmbedding.configuration, castConfiguration_mk, + MachineStateEquiv.configuration, castTapes_embedding, dropUnit, + Equiv.coe_fn_mk, headerConfiguration] + cases label <;> rfl + +theorem stepAux_headerStatement (max N B : Nat) (label : HeaderLabel) + (state : Master N) (header : HeaderTape → List Bool) + (extra : ExtraTape max → List Bool) : + TM2.stepAux (headerStatement max N B label) state (mergeTapes header extra) = + headerConfiguration extra (TM2.stepAux (headerProgram B label) state header) := by + rw [headerStatement, MachineStateEquiv.stepAux_transport_symm] + change MachineStateEquiv.configuration (dropUnit N) + (TM2.stepAux (castStatement (boolAlphabet_eq max) + (MachineEmbedding.statement none (headerProgram B label))) (state, ()) + (mergeTapes header extra)) = _ + rw [← castTapes_embedding, stepAux_cast, MachineEmbedding.stepAux_simulation] + exact (headerConfiguration_eq extra _).symm + +def program (max N B : Nat) : Label → + TM2.Stmt (fun _ : GlobalTape max => Bool) Label (Master N) + | .inl label => headerStatement max N B label + | .inr .seed => MachineUnaryAffineAt.seed (.inl .source) 0 (.inr .scan) + | .inr .scan => MachineUnaryAffineAt.scan + (commonPlacement max (PoweringMachineTapes.table max)) + (commonPlacement max (PoweringMachineTapes.scratch max)) + (.inl .source) 1 (.inr .scan) (.inr .restore) + | .inr .restore => Reduction.MachineTransfer.loopAt + (commonPlacement max (PoweringMachineTapes.scratch max)) + (commonPlacement max (PoweringMachineTapes.table max)) + id false (.inr .restore) (some (.inl .initialize)) + +theorem headerStep (max N B : Nat) (extra : ExtraTape max → List Bool) + (a b : TM2.Cfg HeaderAlphabet HeaderLabel (Master N)) + (run : TM2.step (headerProgram B) a = some b) : + TM2.step (program max N B) (headerConfiguration extra a) = + some (headerConfiguration extra b) := by + cases a with + | mk label state tapes => + cases label with + | none => simp [TM2.step] at run + | some label => + have hb : TM2.stepAux (headerProgram B label) state tapes = b := Option.some.inj run + rw [← hb] + change some (TM2.stepAux (headerStatement max N B label) state + (mergeTapes tapes extra)) = _ + rw [stepAux_headerStatement] + +theorem headerTrace (max N B vertices : Nat) (extra : ExtraTape max → List Bool) + (state : Master N) : + (MachineComposition.advance (TM2.step (program max N B)))^[vertices + 2] + (some ⟨some (.inl .initialize), state, + mergeTapes (initialTapes vertices []) extra⟩) = + some ⟨none, (state.1, none), mergeTapes (finalTapes B vertices []) extra⟩ := by + exact MachineComposition.liftSuccessfulTrace (TM2.step (headerProgram B)) + (TM2.step (program max N B)) (headerConfiguration extra) + (headerStep max N B extra) (vertices + 2) _ _ + (PoweringMachineLoop.headerTrace B vertices [] state.1 state.2) + +def initialGlobalTapes {max : Nat} (extra : ExtraTape max → List Bool) : + GlobalTape max → List Bool := mergeTapes (fun _ => []) extra + +theorem copyFirstTrace (max N B vertices : Nat) (extra : ExtraTape max → List Bool) + (suffix : List Bool) + (input : extra (.inl (PoweringMachineTapes.table max)) = encodeWord vertices ++ suffix) + (scratch : extra (.inl (PoweringMachineTapes.scratch max)) = []) + (state : Master N) : + (MachineComposition.advance (TM2.step (program max N B)))^[2 * (vertices + 1) + 1] + (some ⟨some (.inr .seed), state, initialGlobalTapes extra⟩) = + some ⟨some (.inl .initialize), (state.1, none), + mergeTapes (initialTapes vertices []) extra⟩ := by + have copied := MachineUnaryAffineAt.seededAffineTrace + (commonPlacement max (PoweringMachineTapes.table max)) + (commonPlacement max (PoweringMachineTapes.scratch max)) (.inl HeaderTape.source) + (by + intro heq + have hroles := commonPlacement_injective max heq + simp [PoweringMachineTapes.table, PoweringMachineTapes.scratch] at hroles) + (by simp) (by simp) 1 0 (.inr .seed) (.inr .scan) (.inr .restore) + (some (.inl .initialize)) (program max N B) rfl rfl rfl + (initialGlobalTapes extra) vertices suffix + (by simpa [initialGlobalTapes, mergeTapes] using input) + (by simpa [initialGlobalTapes, mergeTapes] using scratch) state.1 state.2 + have handoff : Function.update (initialGlobalTapes extra) (.inl HeaderTape.source) + (encodeWord (1 * vertices + 0) ++ initialGlobalTapes extra (.inl .source)) = + mergeTapes (initialTapes vertices []) extra := by + funext tape + cases tape with + | inl field => cases field <;> simp [initialGlobalTapes, mergeTapes, initialTapes] + | inr field => simp [initialGlobalTapes, mergeTapes] + rw [handoff] at copied + exact copied + +theorem initializeTrace (max N B vertices : Nat) (extra : ExtraTape max → List Bool) + (suffix : List Bool) + (input : extra (.inl (PoweringMachineTapes.table max)) = encodeWord vertices ++ suffix) + (scratch : extra (.inl (PoweringMachineTapes.scratch max)) = []) + (state : Master N) : + (MachineComposition.advance (TM2.step (program max N B)))^[3 * vertices + 5] + (some ⟨some (.inr .seed), state, initialGlobalTapes extra⟩) = + some ⟨none, (state.1, none), mergeTapes (finalTapes B vertices []) extra⟩ := by + rw [show 3 * vertices + 5 = (vertices + 2) + (2 * (vertices + 1) + 1) by omega, + Function.iterate_add_apply, copyFirstTrace max N B vertices extra suffix input scratch state] + exact headerTrace max N B vertices extra (state.1, none) + +def initializeInTime (max N B vertices : Nat) (extra : ExtraTape max → List Bool) + (suffix : List Bool) + (input : extra (.inl (PoweringMachineTapes.table max)) = encodeWord vertices ++ suffix) + (scratch : extra (.inl (PoweringMachineTapes.scratch max)) = []) + (state : Master N) : + StateTransition.EvalsToInTime (TM2.step (program max N B)) + ⟨some (.inr .seed), state, initialGlobalTapes extra⟩ + (some ⟨none, (state.1, none), mergeTapes (finalTapes B vertices []) extra⟩) + (3 * vertices + 5) where + steps := 3 * vertices + 5 + evals_in_steps := initializeTrace max N B vertices extra suffix input scratch state + steps_le_m := Nat.le_refl _ + +def instruction {Λ : Type} (max N B : Nat) (labels : Label → Λ) (exit : Option Λ) + (label : Label) : TM2.Stmt (fun _ : GlobalTape max => Bool) Λ (Master N) := + MachineSubroutine.statement labels exit (program max N B label) + +def initializeAtInTime {Λ : Type} (max N B vertices : Nat) + (labels : Label → Λ) (exit : Option Λ) + (caller : Λ → TM2.Stmt (fun _ : GlobalTape max => Bool) Λ (Master N)) + (atLabels : ∀ label, caller (labels label) = instruction max N B labels exit label) + (extra : ExtraTape max → List Bool) (suffix : List Bool) + (input : extra (.inl (PoweringMachineTapes.table max)) = encodeWord vertices ++ suffix) + (scratch : extra (.inl (PoweringMachineTapes.scratch max)) = []) + (state : Master N) : + StateTransition.EvalsToInTime (TM2.step caller) + ⟨some (labels (.inr .seed)), state, initialGlobalTapes extra⟩ + (some ⟨exit, (state.1, none), mergeTapes (finalTapes B vertices []) extra⟩) + (3 * vertices + 5) := + MachineSubroutine.execution labels exit (program max N B) caller atLabels + (initializeInTime max N B vertices extra suffix input scratch state) + +@[simp] theorem final_counter (max B vertices : Nat) (extra : ExtraTape max → List Bool) : + mergeTapes (finalTapes B vertices []) extra + (commonPlacement max (PoweringMachineTapes.start max)) = encodeWord vertices := by + simp [mergeTapes, finalTapes] + +@[simp] theorem final_vertices (max B vertices : Nat) (extra : ExtraTape max → List Bool) : + mergeTapes (finalTapes B vertices []) extra (.inl .vertices) = encodeWord vertices := rfl + +@[simp] theorem final_darts (max B vertices : Nat) (extra : ExtraTape max → List Bool) : + mergeTapes (finalTapes B vertices []) extra (.inl .darts) = encodeWord (B * vertices) := rfl + +@[simp] theorem final_extra (max B vertices : Nat) (extra : ExtraTape max → List Bool) + (tape : ExtraTape max) : + mergeTapes (finalTapes B vertices []) extra (.inr tape) = extra tape := rfl + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineInitialize + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineLoop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..f22cf6a930e0e3d86a2b392849522e36a9046cf0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineLoop.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineLoop + +open Turing + +inductive HeaderTape + | source | counter | vertices | darts + deriving DecidableEq + +instance : Fintype HeaderTape where + elems := {.source, .counter, .vertices, .darts} + complete value := by cases value <;> simp + +inductive HeaderLabel + | initialize | scan + deriving DecidableEq + +instance : Fintype HeaderLabel where + elems := {.initialize, .scan} + complete value := by cases value <;> simp + +abbrev HeaderAlphabet (_ : HeaderTape) := Bool +abbrev HeaderState (σ : Type) := σ × Option Bool + +def pushTrue {K Λ σ : Type} (destination : K) : Nat → + TM2.Stmt (fun _ : K => Bool) Λ σ → TM2.Stmt (fun _ : K => Bool) Λ σ + | 0, next => next + | count + 1, next => pushTrue destination count (.push destination (fun _ => true) next) + +theorem stepAux_pushTrue {K Λ σ : Type} [DecidableEq K] + (destination : K) (count : Nat) (next : TM2.Stmt (fun _ : K => Bool) Λ σ) + (state : σ) (tapes : K → List Bool) : + TM2.stepAux (pushTrue destination count next) state tapes = + TM2.stepAux next state + (Function.update tapes destination (List.replicate count true ++ tapes destination)) := by + induction count generalizing next with + | zero => simp [pushTrue] + | succ count ih => + rw [pushTrue, ih] + simp [TM2.stepAux, List.replicate_succ, Function.update_idem] + +theorem pushTrue_pushBound {K Λ σ : Type} (destination : K) (count : Nat) + (next : TM2.Stmt (fun _ : K => Bool) Λ σ) : + Runtime.statementPushBound (pushTrue destination count next) = + count + Runtime.statementPushBound next := by + induction count generalizing next with + | zero => simp [pushTrue] + | succ count ih => simp only [pushTrue, ih, Runtime.statementPushBound]; omega + +def headerProgram {σ : Type} (B : Nat) : + HeaderLabel → TM2.Stmt HeaderAlphabet HeaderLabel (HeaderState σ) + | .initialize => + .push .counter (fun _ => false) + (.push .vertices (fun _ => false) + (.push .darts (fun _ => false) + (.load (fun state => (state.1, none)) (.goto fun _ => .scan)))) + | .scan => + .pop .source (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.push .counter (fun _ => true) + (.push .vertices (fun _ => true) + (pushTrue .darts B + (.load (fun state => (state.1, none)) (.goto fun _ => .scan))))) + (.load (fun state => (state.1, none)) .halt)) + +def headerMachine (B : Nat) : FinTM2 where + K := HeaderTape + k₀ := .source + k₁ := .darts + Γ := HeaderAlphabet + Λ := HeaderLabel + main := .initialize + σ := HeaderState Unit + initialState := ((), none) + m := headerProgram B + +def initialTapes (n : Nat) (suffix : List Bool) : HeaderTape → List Bool + | .source => encodeWord n ++ suffix + | _ => [] + +def scanTapes (B remaining processed : Nat) (suffix : List Bool) : HeaderTape → List Bool + | .source => encodeWord remaining ++ suffix + | .counter => encodeWord processed + | .vertices => encodeWord processed + | .darts => encodeWord (B * processed) + +def finalTapes (B n : Nat) (suffix : List Bool) : HeaderTape → List Bool + | .source => suffix + | .counter => encodeWord n + | .vertices => encodeWord n + | .darts => encodeWord (B * n) + +def scanConfiguration {σ : Type} (B remaining processed : Nat) + (suffix : List Bool) (ambient : σ) (register : Option Bool) : + TM2.Cfg HeaderAlphabet HeaderLabel (HeaderState σ) := + ⟨some .scan, (ambient, register), scanTapes B remaining processed suffix⟩ + +def finalConfiguration {σ : Type} (B n : Nat) (suffix : List Bool) (ambient : σ) : + TM2.Cfg HeaderAlphabet HeaderLabel (HeaderState σ) := + ⟨none, (ambient, none), finalTapes B n suffix⟩ + +theorem initializeStep {σ : Type} (B n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (headerProgram B) + ⟨some .initialize, (ambient, register), initialTapes n suffix⟩ = + some (scanConfiguration B n 0 suffix ambient none) := by + simp only [TM2.step, headerProgram, TM2.stepAux] + congr 2 + funext tape + cases tape <;> simp [initialTapes, scanTapes, encodeWord] + +theorem scanStep_zero {σ : Type} (B processed : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (headerProgram B) (scanConfiguration B 0 processed suffix ambient register) = + some (finalConfiguration B processed suffix ambient) := by + simp only [TM2.step, scanConfiguration, headerProgram, TM2.stepAux, + scanTapes, encodeWord, List.replicate_zero, List.nil_append, List.singleton_append, + List.head?_cons, List.tail_cons, Option.getD_some, Bool.cond_false] + congr 2 + funext tape + cases tape <;> simp [finalTapes, scanTapes] + +theorem scanStep_succ {σ : Type} (B remaining processed : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + TM2.step (headerProgram B) + (scanConfiguration B (remaining + 1) processed suffix ambient register) = + some (scanConfiguration B remaining (processed + 1) suffix ambient none) := by + simp only [TM2.step, scanConfiguration, headerProgram, TM2.stepAux, + scanTapes, encodeWord, List.replicate_succ, List.cons_append, + List.head?_cons, List.tail_cons, Option.getD_some, Bool.cond_true] + rw [stepAux_pushTrue] + simp only [TM2.stepAux] + congr 2 + funext tape + cases tape <;> + simp [scanTapes, encodeWord, Nat.mul_add, List.replicate_add, + List.replicate_succ, List.append_assoc, Nat.add_comm, + -List.replicate_append_replicate] + +theorem scanTrace {σ : Type} (B remaining processed : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step (headerProgram B)))^[remaining + 1] + (some (scanConfiguration B remaining processed suffix ambient register)) = + some (finalConfiguration B (processed + remaining) suffix ambient) := by + induction remaining generalizing processed register with + | zero => + simpa only [Nat.add_zero, Nat.zero_add, Function.iterate_one, MachineComposition.advance_some] using + scanStep_zero B processed suffix ambient register + | succ remaining ih => + rw [Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step (headerProgram B)))^[remaining + 1] + (TM2.step (headerProgram B) + (scanConfiguration B (remaining + 1) processed suffix ambient register)) = _ + rw [scanStep_succ, ih] + simp only [Nat.add_comm, Nat.add_left_comm] + +theorem headerTrace {σ : Type} (B n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step (headerProgram B)))^[n + 2] + (some ⟨some .initialize, (ambient, register), initialTapes n suffix⟩) = + some (finalConfiguration B n suffix ambient) := by + rw [show n + 2 = (n + 1) + 1 by omega, Function.iterate_succ_apply] + change (MachineComposition.advance (TM2.step (headerProgram B)))^[n + 1] + (TM2.step (headerProgram B) + ⟨some .initialize, (ambient, register), initialTapes n suffix⟩) = _ + rw [initializeStep] + simpa only [Nat.zero_add] using scanTrace B n 0 suffix ambient none + +def headerInTime {σ : Type} (B n : Nat) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step (headerProgram B)) + ⟨some .initialize, (ambient, register), initialTapes n suffix⟩ + (some (finalConfiguration B n suffix ambient)) (n + 2) where + steps := n + 2 + evals_in_steps := headerTrace B n suffix ambient register + steps_le_m := Nat.le_refl _ + +def remainingRows (rowBlock : Nat → List Bool) (n r : Nat) : List Bool := + (List.range' r (n - r)).flatMap rowBlock + +@[simp] theorem remainingRows_top (rowBlock : Nat → List Bool) (n : Nat) : + remainingRows rowBlock n n = [] := by simp [remainingRows] + +theorem remainingRows_step (rowBlock : Nat → List Bool) (n r : Nat) (hr : r < n) : + remainingRows rowBlock n r = rowBlock r ++ remainingRows rowBlock n (r + 1) := by + have h : n - r = (n - (r + 1)) + 1 := by omega + simp only [remainingRows, h, List.range'_succ, List.flatMap_cons] + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineLoop + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineOuterLoop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineOuterLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..ead505ac763a11f8d86a43ad425162abeb7f71c7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineOuterLoop.lean @@ -0,0 +1,292 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineVertex + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineOuterLoop + +open Turing MachineComposition PCP + +variable {K Λ : Type} [DecidableEq K] {vertices d n : Nat} + +abbrev Placement (K : Type) (n : Nat) := PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K +abbrev State := PoweringMachineVertex.State + +structure Ready (graph : PortTables.Table vertices d) (n : Nat) (placement : Placement K n) + (base : K → List Bool) : Prop where + table : base (placement (.inl 0)) = PortTables.tableBits graph + scratch : base (placement (.inl 5)) = [] + leftCopy : base (placement (.inl 8)) = [] + rightCopy : base (placement (.inl 9)) = [] + data : base (placement (.inl 10)) = [] + +def counter (placement : Placement K n) (base : K → List Bool) (remaining : Nat) : K → List Bool := + MachineUnaryCounter.counterTapes (placement (.inl 1)) base remaining [] + +theorem counter_other (placement : Placement K n) (distinct : Function.Injective placement) + (base : K → List Bool) (remaining : Nat) (j : Fin 11) (hj : j ≠ 1) : + counter placement base remaining (placement (.inl j)) = base (placement (.inl j)) := by + apply MachineUnaryCounter.counterTapes_other + intro h + exact hj (Sum.inl.inj (distinct h)) + +theorem ready_vertex (graph : PortTables.Table vertices d) (n : Nat) + (placement : Placement K n) (distinct : Function.Injective placement) + (base : K → List Bool) (ready : Ready graph n placement base) (vertex : Fin vertices) : + PoweringMachineRowBody.Ready graph n placement vertex [] (counter placement base vertex.val) := by + constructor + · constructor + · rw [counter_other placement distinct base vertex.val 0 (by decide)] + exact ready.table + · simp only [counter, MachineUnaryCounter.counterTapes_counter] + · rw [counter_other placement distinct base vertex.val 5 (by decide)] + exact ready.scratch + · rw [counter_other placement distinct base vertex.val 8 (by decide)] + exact ready.leftCopy + · rw [counter_other placement distinct base vertex.val 9 (by decide)] + exact ready.rightCopy + · rw [counter_other placement distinct base vertex.val 10 (by decide)] + exact ready.data + +omit [DecidableEq K] in +theorem ready_of_vertex (graph : PortTables.Table vertices d) (n : Nat) + (placement : Placement K n) (base : K → List Bool) (vertex : Fin vertices) + (ready : PoweringMachineRowBody.Ready graph n placement vertex [] base) : + Ready graph n placement base := + ⟨ready.1.table, ready.1.scratch, ready.1.leftCopy, ready.1.rightCopy, ready.2⟩ + +def vertexStart (d n : Nat) (labels : PoweringMachineVertex.Label d n → Λ) (guardLabel : Λ) : Λ := + (PoweringMachineVertex.entry d n labels (some guardLabel)).getD guardLabel + +theorem vertexEntry (d n : Nat) (labels : PoweringMachineVertex.Label d n → Λ) (guardLabel : Λ) : + PoweringMachineVertex.entry d n labels (some guardLabel) = + some (vertexStart d n labels guardLabel) := by + unfold vertexStart PoweringMachineVertex.entry PoweringMachineVertex.sequenceEntry + have h : ∀ (commands : List (PoweringMachineVertex.Command d n)) + (labels : MachineFiniteSequence.Label PoweringMachineVertex.LocalLabel commands → Λ), + MachineFiniteSequence.entry PoweringMachineVertex.LocalLabel + (fun j => PoweringMachineRowBody.entry n + (PoweringMachineVertex.ports j) (PoweringMachineVertex.direction j)) + commands labels (some guardLabel) = + some ((MachineFiniteSequence.entry PoweringMachineVertex.LocalLabel + (fun j => PoweringMachineRowBody.entry n + (PoweringMachineVertex.ports j) (PoweringMachineVertex.direction j)) + commands labels (some guardLabel)).getD guardLabel) := by + intro commands labels + cases commands <;> rfl + exact h _ labels + +def bridge (d n : Nat) (labels : PoweringMachineVertex.Label d n → Λ) (guardLabel : Λ) : + TM2.Stmt (fun _ : K => Bool) Λ (State d n) := + .goto (fun _ => vertexStart d n labels guardLabel) + +def finalTapes (graph : PortTables.Table vertices d) (n : Nat) (placement : Placement K n) + (output : K) : (remaining : Nat) → remaining ≤ vertices → (K → List Bool) → K → List Bool + | 0, _, base => counter placement base 0 + | r + 1, bounded, base => + finalTapes graph n placement output r (by omega) + (PoweringMachineVertex.finalTapes graph n placement output ⟨r, by omega⟩ + (counter placement base r)) + +def steps (graph : PortTables.Table vertices d) (n : Nat) : + (remaining : Nat) → remaining ≤ vertices → Nat + | 0, _ => 1 + | r + 1, bounded => + 2 + PoweringMachineVertex.steps graph ⟨r, by omega⟩ n + steps graph n r (by omega) + +theorem steps_le (graph : PortTables.Table vertices d) (n remaining : Nat) + (bounded : remaining ≤ vertices) : + steps graph n remaining bounded ≤ + remaining * (PoweringMachineVertex.budget d n (PortTables.tableBits graph).length + 2) + 1 := by + induction remaining with + | zero => simp [steps] + | succ r ih => + have hv := PoweringMachineVertex.steps_le graph (⟨r, by omega⟩ : Fin vertices) n + have hi := ih (by omega) + simp only [steps, Nat.add_mul, Nat.one_mul] + omega + +theorem finalTapes_ready (graph : PortTables.Table vertices d) (n : Nat) + (placement : Placement K n) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) + (remaining : Nat) (bounded : remaining ≤ vertices) (base : K → List Bool) + (ready : Ready graph n placement base) : + Ready graph n placement (finalTapes graph n placement output remaining bounded base) := by + induction remaining generalizing base with + | zero => + constructor + · rw [finalTapes, counter_other placement distinct base 0 0 (by decide)] + exact ready.table + · rw [finalTapes, counter_other placement distinct base 0 5 (by decide)] + exact ready.scratch + · rw [finalTapes, counter_other placement distinct base 0 8 (by decide)] + exact ready.leftCopy + · rw [finalTapes, counter_other placement distinct base 0 9 (by decide)] + exact ready.rightCopy + · rw [finalTapes, counter_other placement distinct base 0 10 (by decide)] + exact ready.data + | succ r ih => + apply ih + apply ready_of_vertex graph n placement _ (⟨r, by omega⟩ : Fin vertices) + exact PoweringMachineVertex.finalTapes_ready graph n placement distinct output outside + ⟨r, by omega⟩ _ [] (ready_vertex graph n placement distinct base ready _) + +def prefixRows (graph : PortTables.Table vertices d) (n : Nat) : Nat → List Bool + | 0 => [] + | r + 1 => prefixRows graph n r ++ + if h : r < vertices then PoweringTableLayout.vertexRowBits graph n ⟨r, h⟩ else [] + +theorem prefixRows_ofFn (graph : PortTables.Table vertices d) (n remaining : Nat) + (bounded : remaining ≤ vertices) : + prefixRows graph n remaining = + (List.ofFn (fun i : Fin remaining => + PoweringTableLayout.vertexRowBits graph n (Fin.castLE bounded i))).flatten := by + induction remaining with + | zero => rfl + | succ r ih => + have hr : r < vertices := by omega + rw [prefixRows, dite_eq_left hr, List.ofFn_succ_last, List.flatten_append] + simp only [List.flatten_cons, List.flatten_nil, List.append_nil] + change prefixRows graph n r ++ PoweringTableLayout.vertexRowBits graph n ⟨r, hr⟩ = + (List.ofFn (fun i : Fin r => PoweringTableLayout.vertexRowBits graph n + (Fin.castLE (show r ≤ vertices by omega) i))).flatten ++ + PoweringTableLayout.vertexRowBits graph n ⟨r, hr⟩ + rw [ih] + +theorem prefixRows_all (graph : PortTables.Table vertices d) (n : Nat) : + prefixRows graph n vertices = + (List.finRange vertices).flatMap (PoweringTableLayout.vertexRowBits graph n) := by + rw [prefixRows_ofFn graph n vertices (Nat.le_refl _)] + simp only [List.finRange, List.flatMap_def, List.map_ofFn] + rfl + +theorem finalTapes_output (graph : PortTables.Table vertices d) (n : Nat) + (placement : Placement K n) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) + (remaining : Nat) (bounded : remaining ≤ vertices) (base : K → List Bool) + (ready : Ready graph n placement base) : + finalTapes graph n placement output remaining bounded base output = + prefixRows graph n remaining ++ base output := by + induction remaining generalizing base with + | zero => + exact MachineUnaryCounter.counterTapes_other (placement (.inl 1)) output (outside _) + base 0 [] + | succ r ih => + let vertex : Fin vertices := ⟨r, by omega⟩ + let current := counter placement base r + have vertexReady := ready_vertex graph n placement distinct base ready vertex + have nextReady := PoweringMachineVertex.finalTapes_ready graph n placement distinct + output outside vertex current [] vertexReady + change finalTapes graph n placement output r (by omega) + (PoweringMachineVertex.finalTapes graph n placement output vertex current) output = _ + rw [ih (by omega) _ (ready_of_vertex graph n placement _ vertex nextReady), + PoweringMachineVertex.finalTapes_output graph n placement distinct output outside + vertex current [] vertexReady] + have hc : current output = base output := + MachineUnaryCounter.counterTapes_other (placement (.inl 1)) output (outside _) base r [] + rw [hc, prefixRows, dite_eq_left vertex.isLt, List.append_assoc] + +theorem finalTapes_other (graph : PortTables.Table vertices d) (n : Nat) + (placement : Placement K n) (output : K) (remaining : Nat) + (bounded : remaining ≤ vertices) (base : K → List Bool) + (k : K) (hout : k ≠ output) (outside : ∀ i, k ≠ placement i) : + finalTapes graph n placement output remaining bounded base k = base k := by + induction remaining generalizing base with + | zero => exact MachineUnaryCounter.counterTapes_other _ _ (outside _) base 0 [] + | succ r ih => + rw [finalTapes, ih, PoweringMachineVertex.finalTapes_other graph n placement output + ⟨r, by omega⟩ _ k hout outside] + exact MachineUnaryCounter.counterTapes_other _ _ (outside _) base r [] + +theorem loopTrace (graph : PortTables.Table vertices d) (n : Nat) + (placement : Placement K n) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) + (guardLabel bridgeLabel exitLabel : Λ) (labels : PoweringMachineVertex.Label d n → Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State d n)) + (atGuard : program guardLabel = + MachineUnaryCounter.guard (placement (.inl 1)) bridgeLabel exitLabel) + (atBridge : program bridgeLabel = bridge d n labels guardLabel) + (atVertex : ∀ l, program (labels l) = + PoweringMachineVertex.instruction n placement output labels (some guardLabel) l) + (remaining : Nat) (bounded : remaining ≤ vertices) (base : K → List Bool) + (ready : Ready graph n placement base) : + (advance (TM2.step program))^[steps graph n remaining bounded] + (some ⟨some guardLabel, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + counter placement base remaining⟩) = + some ⟨some exitLabel, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + finalTapes graph n placement output remaining bounded base⟩ := by + let initial := PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n) + induction remaining generalizing base with + | zero => + simpa only [steps, finalTapes, counter, initial, PoweringMasterState.clean, + PoweringMasterState.withBuffer] using + MachineUnaryCounter.guardTrace_zero (placement (.inl 1)) guardLabel bridgeLabel exitLabel + program atGuard base [] initial.1 none + | succ r ih => + let vertex : Fin vertices := ⟨r, by omega⟩ + let current := counter placement base r + let next := PoweringMachineVertex.finalTapes graph n placement output vertex current + have vertexReady : PoweringMachineRowBody.Ready graph n placement vertex [] current := + ready_vertex graph n placement distinct base ready vertex + have nextVertexReady := PoweringMachineVertex.finalTapes_ready graph n placement distinct + output outside vertex current [] vertexReady + have nextReady : Ready graph n placement next := + ready_of_vertex graph n placement next vertex nextVertexReady + have sameCounter : counter placement next r = next := by + have hs := nextVertexReady.1.source + change next (placement (.inl 1)) = encodeWord r ++ [] at hs + unfold counter MachineUnaryCounter.counterTapes + rw [← hs] + exact Function.update_eq_self _ _ + have tailRun := ih (by omega) next nextReady + rw [sameCounter] at tailRun + have guardRun : advance (TM2.step program) + (some ⟨some guardLabel, initial, counter placement base (r + 1)⟩) = + some ⟨some bridgeLabel, initial, current⟩ := by + simpa only [advance_some, current, counter, initial, PoweringMasterState.clean, + PoweringMasterState.withBuffer] using + MachineUnaryCounter.guardStep_succ (placement (.inl 1)) guardLabel bridgeLabel exitLabel + program atGuard base r [] initial.1 none + have bridgeRun : advance (TM2.step program) + (some ⟨some bridgeLabel, initial, current⟩) = + some ⟨PoweringMachineVertex.entry d n labels (some guardLabel), initial, current⟩ := by + change some (TM2.stepAux (program bridgeLabel) initial current) = _ + rw [atBridge, vertexEntry] + rfl + have vertexRun := PoweringMachineVertex.vertexTrace graph n placement distinct output outside + vertex labels (some guardLabel) program atVertex current [] vertexReady + change (advance (TM2.step program))^[2 + PoweringMachineVertex.steps graph vertex n + + steps graph n r (by omega)] + (some ⟨some guardLabel, initial, counter placement base (r + 1)⟩) = _ + rw [show 2 + PoweringMachineVertex.steps graph vertex n + steps graph n r (by omega) = + (steps graph n r (by omega) + PoweringMachineVertex.steps graph vertex n) + 1 + 1 by omega, + Function.iterate_succ_apply, guardRun, Function.iterate_succ_apply, bridgeRun, + Function.iterate_add_apply, vertexRun] + exact tailRun + +def loopInTime (graph : PortTables.Table vertices d) (n : Nat) + (placement : Placement K n) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) + (guardLabel bridgeLabel exitLabel : Λ) (labels : PoweringMachineVertex.Label d n → Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State d n)) + (atGuard : program guardLabel = + MachineUnaryCounter.guard (placement (.inl 1)) bridgeLabel exitLabel) + (atBridge : program bridgeLabel = bridge d n labels guardLabel) + (atVertex : ∀ l, program (labels l) = + PoweringMachineVertex.instruction n placement output labels (some guardLabel) l) + (remaining : Nat) (bounded : remaining ≤ vertices) (base : K → List Bool) + (ready : Ready graph n placement base) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some guardLabel, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + counter placement base remaining⟩ + (some ⟨some exitLabel, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + finalTapes graph n placement output remaining bounded base⟩) + (remaining * (PoweringMachineVertex.budget d n (PortTables.tableBits graph).length + 2) + 1) where + steps := steps graph n remaining bounded + evals_in_steps := loopTrace graph n placement distinct output outside guardLabel bridgeLabel + exitLabel labels program atGuard atBridge atVertex remaining bounded base ready + steps_le_m := steps_le graph n remaining bounded + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineOuterLoop + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRelationField.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRelationField.lean new file mode 100644 index 0000000000000000000000000000000000000000..8455cde585e5740344325cf5b84188a171316808 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRelationField.lean @@ -0,0 +1,197 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringOpinions +import OAI.Combinatorics.IndependentSets.Machines.PoweringGlobalEnumeration + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRelationField + +open Turing +open MachineComposition +open PCP + +variable {K Λ A : Type} [DecidableEq K] +variable {n d max : Nat} + +abbrev Alphabet (_ : K) := Bool +abbrev State (A : Type) := MachineUnaryEqualityBit.State A +abbrev Label (path : List (Fin d)) := PoweringMachineWord.Label path.length ⊕ MachineAffineLookup.Label + +def lookupTapes (placement : PoweringMachineTapes.Tape max → K) (i : Fin 5) : K := + placement (PoweringMachineTapes.relationPlacement max i.succ) + +omit [DecidableEq K] in +theorem lookupTapes_injective (placement : PoweringMachineTapes.Tape max → K) + (distinct : Function.Injective placement) : Function.Injective (lookupTapes placement) := by + intro i j h + exact (Fin.succ_injective _) ((PoweringMachineTapes.relationPlacement_injective max) (distinct h)) + +omit [DecidableEq K] in +theorem source_outside_lookup (placement : PoweringMachineTapes.Tape max → K) + (distinct : Function.Injective placement) : + ∀ i, placement (.inl 6) ≠ lookupTapes placement i := by + intro i h + have heq : PoweringMachineTapes.relationPlacement max 0 = PoweringMachineTapes.relationPlacement max i.succ := by + simpa [PoweringMachineTapes.leftEndpoint] using distinct h + have hi := (PoweringMachineTapes.relationPlacement_injective max) heq + have hv := congrArg Fin.val hi + simp at hv + +def endpoint (table : PortTables.Table n d) (vertex : Fin n) (path : List (Fin d)) : Fin n := + PoweringWalks.walkEnd (PortTables.portGraph table) vertex path + +theorem endpoint_eq_wordEnd (table : PortTables.Table n d) (vertex : Fin n) + (path : List (Fin d)) : + endpoint table vertex path = + PoweringWalks.wordEnd (PortTables.portGraph table) path.length vertex path.get := by + rw [PoweringReach.wordEnd_eq_walkEnd_ofFn, List.ofFn_get] + rfl + +def bit (table : PortTables.Table n d) (vertex : Fin n) (path : List (Fin d)) + (port : Fin d) (left right : PortTables.Label) : Nat := + GraphTables.bitWord (PortTables.accepts table (endpoint table vertex path, port) left right) + +def instruction (placement : PoweringMachineTapes.Tape max → K) (path : List (Fin d)) + (lengthBound : path.length ≤ max) (port : Fin d) (left right : PortTables.Label) + (labels : Label path → Λ) (exit : Option Λ) : + Label path → TM2.Stmt (Alphabet (K := K)) Λ (State A) + | .inl q => PoweringMachineWord.instruction path.length (placement ∘ PoweringMachineTapes.wordPlacement lengthBound false) + path.get (fun z => labels (.inl z)) (some (labels (.inr .seed))) q + | .inr q => PoweringMachineRelation.instruction (placement (.inl 6)) (lookupTapes placement) + port (GraphTables.relationIndex (left, right)) (fun z => labels (.inr z)) exit q + +def afterWord (placement : PoweringMachineTapes.Tape max → K) (path : List (Fin d)) + (lengthBound : path.length ≤ max) (table : PortTables.Table n d) + (vertex : Fin n) (base : K → List Bool) : K → List Bool := + PoweringMachineWord.finalTapes table path.length (placement ∘ PoweringMachineTapes.wordPlacement lengthBound false) + vertex path.get base + +def finalTapes (placement : PoweringMachineTapes.Tape max → K) (path : List (Fin d)) + (lengthBound : path.length ≤ max) (port : Fin d) (left right : PortTables.Label) + (table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) : K → List Bool := + MachineAffineLookup.finalTapes (lookupTapes placement) + (afterWord placement path lengthBound table vertex base) (PortTables.tableWords table) + (PoweringMachineRelation.address (endpoint table vertex path) port + (GraphTables.relationIndex (left, right))) (bit table vertex path port left right) + +def steps (path : List (Fin d)) (port : Fin d) (left right : PortTables.Label) + (table : PortTables.Table n d) (vertex : Fin n) : Nat := + PoweringMachineWord.steps table path.length vertex path.get + + MachineAffineLookup.steps (PortTables.tableWords table) (endpoint table vertex path).val + (4098 * d) (4098 * port.val + 4 + (GraphTables.relationIndex (left, right)).val) + +theorem afterWord_frame (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (path : List (Fin d)) (lengthBound : path.length ≤ max) + (table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) + (role : Fin 11) (h₂ : role ≠ 2) (h₃ : role ≠ 3) (h₄ : role ≠ 4) (h₆ : role ≠ 6) : + afterWord placement path lengthBound table vertex base (placement (.inl role)) = + base (placement (.inl role)) := by + apply PoweringMachineWord.finalTapes_other + · intro h; exact h₂ (by simpa [PoweringMachineTapes.query] using distinct h) + · intro h; exact h₃ (by simpa [PoweringMachineTapes.scan] using distinct h) + · intro h; exact h₄ (by simpa [PoweringMachineTapes.reverse] using distinct h) + · intro h; exact h₆ (by simpa [PoweringMachineTapes.leftEndpoint] using distinct h) + · intro i h + have heq := distinct h + simp at heq + +theorem finalTapes_frame (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (path : List (Fin d)) (lengthBound : path.length ≤ max) + (port : Fin d) (left right : PortTables.Label) + (table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) + (role : Fin 11) (h₂ : role ≠ 2) (h₃ : role ≠ 3) (h₄ : role ≠ 4) + (h₆ : role ≠ 6) (h₁₀ : role ≠ 10) : + finalTapes placement path lengthBound port left right table vertex base (placement (.inl role)) = + base (placement (.inl role)) := by + calc + finalTapes placement path lengthBound port left right table vertex base (placement (.inl role)) = + afterWord placement path lengthBound table vertex base (placement (.inl role)) := by + apply MachineAffineLookup.finalTapes_other + · intro h; exact h₂ (by simpa [lookupTapes, PoweringMachineTapes.query] using distinct h) + · intro h; exact h₃ (by simpa [lookupTapes, PoweringMachineTapes.scan] using distinct h) + · intro h; exact h₁₀ (by simpa [lookupTapes, PoweringMachineTapes.rowOutput] using distinct h) + _ = _ := afterWord_frame placement distinct path lengthBound table vertex base role h₂ h₃ h₄ h₆ + +theorem finalTapes_other (placement : PoweringMachineTapes.Tape max → K) + (path : List (Fin d)) (lengthBound : path.length ≤ max) + (port : Fin d) (left right : PortTables.Label) + (table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) + (k : K) (outside : ∀ i, k ≠ placement i) : + finalTapes placement path lengthBound port left right table vertex base k = base k := by + calc + finalTapes placement path lengthBound port left right table vertex base k = + afterWord placement path lengthBound table vertex base k := + MachineAffineLookup.finalTapes_other _ _ _ _ _ _ (outside _) (outside _) (outside _) + _ = base k := PoweringMachineWord.finalTapes_other _ _ _ _ _ _ _ + (outside _) (outside _) (outside _) (outside _) (fun i => outside _) + +theorem fieldTrace (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (path : List (Fin d)) (lengthBound : path.length ≤ max) + (port : Fin d) (left right : PortTables.Label) + (labels : Label path → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A)) + (atLabels : ∀ l, program (labels l) = instruction placement path lengthBound port left right labels exit l) + (table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) + (tableWord : base (placement (.inl 0)) = PortTables.tableBits table) + (scratchEmpty : base (placement (.inl 5)) = []) (suffix : List Bool) + (sourceWord : base (placement (.inl 1)) = encodeWord vertex.val ++ suffix) (ambient : A) : + (advance (TM2.step program))^[steps path port left right table vertex] + (some ⟨some (labels (.inl (PoweringMachineWord.entry path.length))), MachineUnaryEqualityBit.clean ambient, base⟩) = + some ⟨exit, MachineUnaryEqualityBit.clean ambient, + finalTapes placement path lengthBound port left right table vertex base⟩ ∧ + finalTapes placement path lengthBound port left right table vertex base (placement (.inl 10)) = + encodeWord (bit table vertex path port left right) ++ base (placement (.inl 10)) := by + have hword := PoweringMachineWord.wordTrace table path.length (placement ∘ PoweringMachineTapes.wordPlacement lengthBound false) + (distinct.comp (PoweringMachineTapes.wordPlacement_injective lengthBound false)) vertex path.get + (fun q => labels (.inl q)) (some (labels (.inr .seed))) program + (fun q => atLabels (.inl q)) base (by simpa [PoweringMachineTapes.table] using tableWord) + (by simpa [PoweringMachineTapes.scratch] using scratchEmpty) suffix + (by simpa [PoweringMachineTapes.start] using sourceWord) (ambient, false, none) none + let mid := afterWord placement path lengthBound table vertex base + have hmidTable : mid (placement (.inl 0)) = PortTables.tableBits table := by + dsimp only [mid] + rw [afterWord_frame placement distinct path lengthBound table vertex base 0 + (by decide) (by decide) (by decide) (by decide)] + exact tableWord + have hmidScratch : mid (placement (.inl 5)) = [] := by + dsimp only [mid] + rw [afterWord_frame placement distinct path lengthBound table vertex base 5 + (by decide) (by decide) (by decide) (by decide)] + exact scratchEmpty + have hmidOutput : mid (placement (.inl 10)) = base (placement (.inl 10)) := + afterWord_frame placement distinct path lengthBound table vertex base 10 + (by decide) (by decide) (by decide) (by decide) + have hmidEndpoint : mid (placement (.inl 6)) = encodeWord (endpoint table vertex path).val ++ + base (placement (.inl 6)) := by + dsimp only [mid, afterWord] + simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five, PoweringMachineTapes.endpoint_false, + PoweringMachineTapes.leftEndpoint, ← endpoint_eq_wordEnd] using hword.2 + have hrelation := PoweringMachineRelation.relationTrace (placement (.inl 6)) (lookupTapes placement) + (lookupTapes_injective placement distinct) (source_outside_lookup placement distinct) + port (GraphTables.relationIndex (left, right)) (fun q => labels (.inr q)) exit program + (fun q => atLabels (.inr q)) table (endpoint table vertex path) mid + (by simpa [lookupTapes, PoweringMachineTapes.table] using hmidTable) + (by simpa [lookupTapes, PoweringMachineTapes.scratch] using hmidScratch) + (base (placement (.inl 6))) hmidEndpoint (ambient, false, none) none + constructor + · simp only [MachineUnaryEqualityBit.clean] + rw [steps, Nat.add_comm, Function.iterate_add_apply, hword.1] + exact hrelation + · change MachineAffineLookup.finalTapes (lookupTapes placement) _ _ _ _ (lookupTapes placement 3) = _ + rw [MachineAffineLookup.finalTapes_output] + change encodeWord (bit table vertex path port left right) ++ mid (placement (.inl 10)) = _ + rw [hmidOutput] + +theorem steps_le (path : List (Fin d)) (port : Fin d) (left right : PortTables.Label) + (table : PortTables.Table n d) (vertex : Fin n) : + steps path port left right table vertex ≤ + (14 * path.length + 9) * (PortTables.tableBits table).length + 12 * path.length + 9 := by + have hw := PoweringMachineWord.steps_le table path.length vertex path.get + have hr := PoweringMachineRelation.steps_le table (endpoint table vertex path) port + (GraphTables.relationIndex (left, right)) + simp only [steps, Nat.add_mul, Nat.mul_assoc] at hw ⊢ + omega + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRelationField + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRotor.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRotor.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbc3631867a7554156cf95d909f6840eb67c1b3d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRotor.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineAffineLookup +import OAI.Combinatorics.IndependentSets.Expansion.PortTableLookup + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRotor + +open Turing +open MachineComposition +open PCP + +variable {K Λ σ : Type} [DecidableEq K] +variable {n d : Nat} + +abbrev Alphabet (_ : K) := Bool + +def reverseRole (i : Fin 5) : Fin 7 := + if i = 0 then 0 else if i = 1 then 2 else if i = 2 then 3 else if i = 3 then 4 else 6 + +def endpointRole (i : Fin 5) : Fin 7 := + if i = 0 then 0 else if i = 1 then 2 else if i = 2 then 3 else if i = 3 then 5 else 6 + +theorem reverseRole_injective : Function.Injective reverseRole := by decide +theorem endpointRole_injective : Function.Injective endpointRole := by decide +theorem source_outside_reverse : ∀ i, (1 : Fin 7) ≠ reverseRole i := by decide +theorem reverse_outside_endpoint : ∀ i, (4 : Fin 7) ≠ endpointRole i := by decide + +def reverseTapes (tape : Fin 7 → K) : Fin 5 → K := tape ∘ reverseRole +def endpointTapes (tape : Fin 7 → K) : Fin 5 → K := tape ∘ endpointRole + +inductive Label + | reverse (l : MachineAffineLookup.Label) + | endpoint (l : MachineAffineLookup.Label) + deriving DecidableEq, Fintype + +def instruction (tape : Fin 7 → K) (degree port : Nat) + (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .reverse l => MachineAffineLookup.instruction (tape 1) (reverseTapes tape) + (4098 * degree) (4098 * port + 3) (fun q => labels (.reverse q)) + (some (labels (.endpoint .seed))) l + | .endpoint l => MachineAffineLookup.instruction (tape 4) (endpointTapes tape) + 4098 2 (fun q => labels (.endpoint q)) exit l + +def reverseId (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) : Nat := + table.reverseIndex[PortTables.rowIndex n d (vertex, port)].val + +def reverseAddress (vertex : Fin n) (port : Fin d) : Nat := + (4098 * d) * vertex.val + (4098 * port.val + 3) + +def endpointAddress (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) : Nat := + 4098 * reverseId table vertex port + 2 + +theorem reverse_selected (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) : + (PortTables.tableWords table)[reverseAddress vertex port]? = + some (reverseId table vertex port) := by + have h := PortTableLookup.reverse_word table (PortTables.rowIndex n d (vertex, port)) + have hindex : reverseAddress vertex port = 3 + 4098 * (PortTables.rowIndex n d (vertex, port)).val := by + simp only [reverseAddress, PortTables.rowIndex_val, Nat.mul_add, Nat.mul_assoc] + omega + rw [hindex] + exact h + +theorem endpoint_selected (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) : + (PortTables.tableWords table)[endpointAddress table vertex port]? = + some ((PortTables.rotation table (vertex, port)).1.val) := by + have h := PortTableLookup.rotation_head_word table (vertex, port) + simpa only [endpointAddress, reverseId, Nat.add_comm] using h + +def afterReverse (tape : Fin 7 → K) (table : PortTables.Table n d) + (vertex : Fin n) (port : Fin d) (base : K → List Bool) : K → List Bool := + MachineAffineLookup.finalTapes (reverseTapes tape) base (PortTables.tableWords table) + (reverseAddress vertex port) (reverseId table vertex port) + +def finalTapes (tape : Fin 7 → K) (table : PortTables.Table n d) + (vertex : Fin n) (port : Fin d) (base : K → List Bool) : K → List Bool := + MachineAffineLookup.finalTapes (endpointTapes tape) + (afterReverse tape table vertex port base) (PortTables.tableWords table) + (endpointAddress table vertex port) ((PortTables.rotation table (vertex, port)).1.val) + +def steps (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) : Nat := + MachineAffineLookup.steps (PortTables.tableWords table) vertex.val (4098 * d) (4098 * port.val + 3) + + MachineAffineLookup.steps (PortTables.tableWords table) (reverseId table vertex port) 4098 2 + +theorem rotorTrace (tape : Fin 7 → K) (distinct : Function.Injective tape) + (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (port : Fin d) + (atLabels : ∀ l, program (labels l) = instruction tape d port.val labels exit l) + (table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) + (tableWord : base (tape 0) = PortTables.tableBits table) + (scratchEmpty : base (tape 6) = []) (suffix : List Bool) + (sourceWord : base (tape 1) = encodeWord vertex.val ++ suffix) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps table vertex port] + (some ⟨some (labels (.reverse .seed)), (ambient,register), base⟩) = + some ⟨exit, (ambient,none), finalTapes tape table vertex port base⟩ := by + have hd (i j : Fin 7) (hne : i ≠ j) : tape i ≠ tape j := fun h => hne (distinct h) + have hrDistinct : Function.Injective (reverseTapes tape) := distinct.comp reverseRole_injective + have heDistinct : Function.Injective (endpointTapes tape) := distinct.comp endpointRole_injective + have hrOutside : ∀ i, tape 1 ≠ reverseTapes tape i := fun i => + hd 1 (reverseRole i) (source_outside_reverse i) + have heOutside : ∀ i, tape 4 ≠ endpointTapes tape i := fun i => + hd 4 (endpointRole i) (reverse_outside_endpoint i) + have hreverse := MachineAffineLookup.affineLookupTrace (tape 1) (reverseTapes tape) + hrDistinct hrOutside (4098 * d) (4098 * port.val + 3) + (fun q => labels (.reverse q)) (some (labels (.endpoint .seed))) + program (fun q => atLabels (.reverse q)) base (PortTables.tableWords table) + tableWord scratchEmpty vertex.val suffix sourceWord (reverseId table vertex port) + (reverse_selected table vertex port) ambient register + let mid := afterReverse tape table vertex port base + have hmidTable : mid (tape 0) = PortTables.tableBits table := by + calc + mid (tape 0) = base (tape 0) := + MachineAffineLookup.finalTapes_other _ _ _ _ _ _ + (hd 0 2 (by decide)) (hd 0 3 (by decide)) (hd 0 4 (by decide)) + _ = _ := tableWord + have hmidScratch : mid (tape 6) = [] := by + calc + mid (tape 6) = base (tape 6) := + MachineAffineLookup.finalTapes_other _ _ _ _ _ _ + (hd 6 2 (by decide)) (hd 6 3 (by decide)) (hd 6 4 (by decide)) + _ = _ := scratchEmpty + have hmidSource : mid (tape 4) = encodeWord (reverseId table vertex port) ++ base (tape 4) := + MachineAffineLookup.finalTapes_output _ _ _ _ _ + have hendpoint := MachineAffineLookup.affineLookupTrace (tape 4) (endpointTapes tape) + heDistinct heOutside 4098 2 (fun q => labels (.endpoint q)) exit + program (fun q => atLabels (.endpoint q)) mid (PortTables.tableWords table) + hmidTable hmidScratch (reverseId table vertex port) (base (tape 4)) hmidSource + ((PortTables.rotation table (vertex, port)).1.val) + (endpoint_selected table vertex port) ambient none + rw [steps, Nat.add_comm, Function.iterate_add_apply, hreverse] + exact hendpoint + +theorem finalTapes_endpoint (tape : Fin 7 → K) (distinct : Function.Injective tape) + (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) (base : K → List Bool) : + finalTapes tape table vertex port base (tape 5) = + encodeWord ((PortTables.rotation table (vertex, port)).1.val) ++ base (tape 5) := by + have hd (i j : Fin 7) (hne : i ≠ j) : tape i ≠ tape j := fun h => hne (distinct h) + change MachineAffineLookup.finalTapes (endpointTapes tape) _ _ _ _ (endpointTapes tape 3) = _ + rw [MachineAffineLookup.finalTapes_output] + congr 1 + exact MachineAffineLookup.finalTapes_other _ _ _ _ _ _ + (hd 5 2 (by decide)) (hd 5 3 (by decide)) (hd 5 4 (by decide)) + +theorem finalTapes_other (tape : Fin 7 → K) (table : PortTables.Table n d) + (vertex : Fin n) (port : Fin d) (base : K → List Bool) (k : K) + (h₂ : k ≠ tape 2) (h₃ : k ≠ tape 3) (h₄ : k ≠ tape 4) (h₅ : k ≠ tape 5) : + finalTapes tape table vertex port base k = base k := by + calc + finalTapes tape table vertex port base k = afterReverse tape table vertex port base k := + MachineAffineLookup.finalTapes_other _ _ _ _ _ _ h₂ h₃ h₅ + _ = base k := MachineAffineLookup.finalTapes_other _ _ _ _ _ _ h₂ h₃ h₄ + +theorem steps_le (table : PortTables.Table n d) (vertex : Fin n) (port : Fin d) : + steps table vertex port ≤ 14 * (PortTables.tableBits table).length + 12 := by + have hvertex : vertex.val ≤ (encodeWords (PortTables.tableWords table)).length := + Nat.le_trans (Nat.le_of_lt vertex.isLt) (PortTables.vertices_le_tableBits_length table) + have hreverse := MachineLookupSpec.output_length_le (PortTables.tableWords table) + (reverseAddress vertex port) (reverseId table vertex port) (reverse_selected table vertex port) + rw [encodeWord_length] at hreverse + have hr := MachineAffineLookup.steps_le_table (PortTables.tableWords table) + vertex.val (4098 * d) (4098 * port.val + 3) (reverseId table vertex port) + (reverse_selected table vertex port) hvertex + have he := MachineAffineLookup.steps_le_table (PortTables.tableWords table) + (reverseId table vertex port) 4098 2 ((PortTables.rotation table (vertex, port)).1.val) + (endpoint_selected table vertex port) (by omega) + change _ ≤ 14 * (encodeWords (PortTables.tableWords table)).length + 12 + unfold steps + omega + +def machine (degree port : Nat) : FinTM2 where + K := Fin 7 + k₀ := 0 + k₁ := 5 + Γ _ := Bool + Λ := Label + main := .reverse .seed + σ := Unit × Option Bool + initialState := ((),none) + m := instruction id degree port id none + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRotor + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRow.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..85a8bb993e10a7f1694c57e227fd19d66d34994e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRow.lean @@ -0,0 +1,217 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFixedBlockMap + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRow + +open Turing +open MachineFixedBlockMap +open IndependentSetsGames.Foundations.PCP + +abbrev Field (S : Nat) := (GraphTables.Label × GraphTables.Label) ⊕ (Fin S ⊕ Fin S) + +def inputSize (t S : Nat) : Nat := t * (4096 + (S + S)) + +def fieldEquiv (S : Nat) : Field S ≃ Fin (4096 + (S + S)) := + (Equiv.sumCongr GraphTables.relationIndex + (finSumFinEquiv : (Fin S ⊕ Fin S) ≃ Fin (S + S))).trans finSumFinEquiv + +def inputEquiv (t S : Nat) : (Fin t × Field S) ≃ Fin (inputSize t S) := + (Equiv.prodCongr (Equiv.refl (Fin t)) (fieldEquiv S)).trans finProdFinEquiv + +def packData {t S : Nat} (data : Fin t → Field S → Bool) : Buffer (inputSize t S) := + fun i => data ((inputEquiv t S).symm i).1 ((inputEquiv t S).symm i).2 + +@[simp] theorem packData_inputEquiv {t S : Nat} + (data : Fin t → Field S → Bool) (k : Fin t) (f : Field S) : + packData data (inputEquiv t S (k, f)) = data k f := by + simp [packData] + +def basePredicate {t S : Nat} (bits : Buffer (inputSize t S)) + (k : Fin t) (a b : GraphTables.Label) : Bool := + bits (inputEquiv t S (k, .inl (a, b))) + +def leftMatches {t S : Nat} (bits : Buffer (inputSize t S)) + (k : Fin t) (i : Fin S) : Bool := + bits (inputEquiv t S (k, .inr (.inl i))) + +def rightMatches {t S : Nat} (bits : Buffer (inputSize t S)) + (k : Fin t) (i : Fin S) : Bool := + bits (inputEquiv t S (k, .inr (.inr i))) + +def firstMatch {S : Nat} (mask : Fin S → Bool) : Option (Fin S) := + (List.ofFn id).find? mask + +theorem firstMatch_spec {S : Nat} (mask : Fin S → Bool) (i : Fin S) : + firstMatch mask = some i ↔ + mask i = true ∧ ∃ before after, + List.ofFn id = before ++ i :: after ∧ ∀ j ∈ before, mask j = false := by + simpa only [firstMatch, Bool.not_eq_eq_eq_not, Bool.not_true] using + (List.find?_eq_some_iff_append (xs := List.ofFn id) (p := mask) (b := i)) + +theorem firstMatch_none {S : Nat} (mask : Fin S → Bool) : + firstMatch mask = none ↔ ∀ i, mask i = false := by + simp [firstMatch, List.find?_eq_none, List.mem_ofFn] + +def edgeAccept {t S q : Nat} (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (k : Fin t) (a b : Fin q) : Bool := + match firstMatch (leftMatches bits k), firstMatch (rightMatches bits k) with + | some i, some j => basePredicate bits k (labelAt a i) (labelAt b j) + | _, _ => false + +theorem edgeAccept_of_matches {t S q : Nat} + (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (k : Fin t) (a b : Fin q) (i j : Fin S) + (hl : firstMatch (leftMatches bits k) = some i) + (hr : firstMatch (rightMatches bits k) = some j) : + edgeAccept labelAt bits k a b = basePredicate bits k (labelAt a i) (labelAt b j) := by + simp [edgeAccept, hl, hr] + +def rowAccept {t S q : Nat} (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (a b : Fin q) : Bool := + (List.ofFn id).all (fun k : Fin t => edgeAccept labelAt bits k a b) + +theorem rowAccept_eq_true {t S q : Nat} + (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (a b : Fin q) : + rowAccept labelAt bits a b = true ↔ ∀ k, edgeAccept labelAt bits k a b = true := by + simp [rowAccept, List.all_eq_true, List.mem_ofFn] + +def rowBlock {t S q : Nat} (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) : Buffer (q * q) := + fun i => rowAccept labelAt bits + ((GenericGraphTables.relationIndex q).symm i).1 + ((GenericGraphTables.relationIndex q).symm i).2 + +@[simp] theorem rowBlock_at {t S q : Nat} + (labelAt : Fin q → Fin S → GraphTables.Label) + (bits : Buffer (inputSize t S)) (a b : Fin q) : + rowBlock labelAt bits (GenericGraphTables.relationIndex q (a, b)) = + rowAccept labelAt bits a b := by + simp [rowBlock] + +def encodeBit (b : Bool) : List Bool := if b then [true, false] else [false] + +def encodeBits : List Bool → List Bool + | [] => [] + | b :: bits => encodeBit b ++ encodeBits bits + +@[simp] theorem encodeBits_append (xs ys : List Bool) : + encodeBits (xs ++ ys) = encodeBits xs ++ encodeBits ys := by + induction xs with + | nil => rfl + | cons b xs ih => simp [encodeBits, ih, List.append_assoc] + +theorem encodeBits_graphWords (bits : List Bool) : + encodeBits bits = encodeWords (bits.map GraphTables.bitWord) := by + induction bits with + | nil => rfl + | cons b bits ih => cases b <;> simp [encodeBits, encodeBit, encodeWords, + GraphTables.bitWord, encodeWord, ih] + +theorem encodeBits_length_le (bits : List Bool) : + (encodeBits bits).length ≤ 2 * bits.length := by + induction bits with + | nil => simp [encodeBits] + | cons b bits ih => + cases b <;> simp only [encodeBits, encodeBit, Bool.false_eq_true, + ite_false, ite_true, List.length_append, List.length_cons, List.length_nil] <;> omega + +variable {K Λ σ : Type} {N : Nat} + +def readEncodedSlots (src : K) : List (Fin N) → + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) → + TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N) + | [], next => next + | i :: slots, next => + .pop src (fun state head => + (state.1, Function.update state.2 i (head.getD false))) + (.branch (fun state => state.2 i) + (.pop src (fun state _ => state) (readEncodedSlots src slots next)) + (readEncodedSlots src slots next)) + +variable [DecidableEq K] + +theorem stepAux_readEncodedSlots (src : K) (slots : List (Fin N)) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (ambient : σ) (bits buffer : Buffer N) (tapes : K → List Bool) + (suffix : List Bool) : + TM2.stepAux (readEncodedSlots src slots next) (ambient, buffer) + (Function.update tapes src (encodeBits (slots.map bits) ++ suffix)) = + TM2.stepAux next (ambient, fill slots bits buffer) + (Function.update tapes src suffix) := by + induction slots generalizing buffer tapes with + | nil => simp [readEncodedSlots, encodeBits, fill] + | cons i slots ih => + cases hb : bits i <;> + simpa only [readEncodedSlots, List.map_cons, encodeBits, encodeBit, hb, + Bool.false_eq_true, ite_false, ite_true, List.cons_append, + List.nil_append, TM2.stepAux, Function.update_self, List.head?_cons, + Option.getD_some, List.tail_cons, Function.update_idem, Bool.cond_false, + Bool.cond_true, fill, List.foldl_cons] using + ih (Function.update buffer i (bits i)) tapes + +theorem stepAux_readEncodedAll (src : K) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) + (state : σ × Buffer N) (bits : Buffer N) (tapes : K → List Bool) + (suffix : List Bool) (hinput : tapes src = encodeBits (List.ofFn bits) ++ suffix) : + TM2.stepAux (readEncodedSlots src (List.ofFn id) next) state tapes = + TM2.stepAux next (state.1, bits) (Function.update tapes src suffix) := by + have h := stepAux_readEncodedSlots src (List.ofFn id) next + state.1 bits state.2 tapes suffix + have hin : Function.update tapes src + (encodeBits ((List.ofFn id).map bits) ++ suffix) = tapes := by + simpa only [List.map_ofFn, Function.comp_id, ← hinput] using + Function.update_eq_self src tapes + rw [hin, fill_all] at h + exact h + +omit [DecidableEq K] in +theorem statementPushBound_readEncodedSlots (src : K) (slots : List (Fin N)) + (next : TM2.Stmt (fun _ : K => Bool) Λ (σ × Buffer N)) : + Runtime.statementPushBound (readEncodedSlots src slots next) = + Runtime.statementPushBound next := by + induction slots with + | nil => rfl + | cons i slots ih => simp [readEncodedSlots, Runtime.statementPushBound, ih] + +def writeEncodedSlots {M : Nat} (dst : K) (emit : σ → Buffer M) : List (Fin M) → + TM2.Stmt (fun _ : K => Bool) Λ σ → TM2.Stmt (fun _ : K => Bool) Λ σ + | [], next => next + | i :: slots, next => .push dst (fun _ => false) + (.branch (fun state => emit state i) + (.push dst (fun _ => true) (writeEncodedSlots dst emit slots next)) + (writeEncodedSlots dst emit slots next)) + +theorem stepAux_writeEncodedSlots {M : Nat} (dst : K) (emit : σ → Buffer M) + (slots : List (Fin M)) (next : TM2.Stmt (fun _ : K => Bool) Λ σ) + (state : σ) (tapes : K → List Bool) : + TM2.stepAux (writeEncodedSlots dst emit slots next) state tapes = + TM2.stepAux next state + (Function.update tapes dst + (encodeBits ((slots.map (emit state)).reverse) ++ tapes dst)) := by + induction slots generalizing tapes with + | nil => simp [writeEncodedSlots, encodeBits] + | cons i slots ih => + cases hb : emit state i <;> + simp only [writeEncodedSlots, TM2.stepAux, hb, Bool.cond_false, Bool.cond_true] + all_goals rw [ih] + all_goals simp [Function.update_idem, List.map_cons, List.reverse_cons, + encodeBits_append, encodeBits, encodeBit, hb, List.append_assoc] + +omit [DecidableEq K] in +theorem statementPushBound_writeEncodedSlots {M : Nat} + (dst : K) (emit : σ → Buffer M) (slots : List (Fin M)) + (next : TM2.Stmt (fun _ : K => Bool) Λ σ) : + Runtime.statementPushBound (writeEncodedSlots dst emit slots next) = + 2 * slots.length + Runtime.statementPushBound next := by + induction slots with + | nil => simp [writeEncodedSlots] + | cons i slots ih => + simp only [writeEncodedSlots, Runtime.statementPushBound, ih, List.length_cons] + omega + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRowBody.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRowBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d5818328ecc0e8221dfd88945f89762fb5d64d1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRowBody.lean @@ -0,0 +1,394 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.Row +import OAI.Combinatorics.IndependentSets.Expansion.PoweringPlanBudget +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineRowHeaders + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRowBody + +open Turing MachineComposition PCP +open MachineFixedBlockMap + +variable {K Λ : Type} {vertices d : Nat} + +abbrev capacity (n : Nat) := 2 * (n + 1) +abbrev bufferSize (d n : Nat) := PoweringMachineRow.inputSize (n + 1) (PoweringRowData.slotCount d n) +abbrev State (d n : Nat) := PoweringMasterState.Master (bufferSize d n) + +def commands (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) := + (PoweringMachinePlan.boundedRowPlan n ports direction).reverse + +abbrev Label (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) := + PoweringMachinePlan.Label (commands n ports direction) ⊕ + (Unit ⊕ PoweringMachineRowHeaders.Label n) + +def planMain {max : Nat} {E : Type} + (ops : List (PoweringMachinePlan.Command d max)) (fallback : E) : + PoweringMachinePlan.Label ops ⊕ E := + match ops with + | [] => .inr fallback + | op :: _ => .inl (.inl (PoweringMachineField.entry op.val)) + +theorem plan_entry_eq {max : Nat} {E : Type} + (ops : List (PoweringMachinePlan.Command d max)) (fallback : E) + (labels : PoweringMachinePlan.Label ops ⊕ E → Λ) : + PoweringMachinePlan.entry ops (fun l => labels (.inl l)) + (some (labels (.inr fallback))) = some (labels (planMain ops fallback)) := by + cases ops <;> rfl + +def entry (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : Label n ports direction := + planMain (commands n ports direction) (.inl ()) + +def headerPlacement {max : Nat} (placement : PoweringMachineTapes.Tape max → K) + (output : K) (i : PoweringMachineTapes.Tape max) : K := + if i = .inl 10 then output else placement i + +@[simp] theorem headerPlacement_output {max : Nat} + (placement : PoweringMachineTapes.Tape max → K) (output : K) : + headerPlacement placement output (.inl 10) = output := by simp [headerPlacement] + +theorem headerPlacement_other {max : Nat} + (placement : PoweringMachineTapes.Tape max → K) (output : K) + (i : PoweringMachineTapes.Tape max) (hi : i ≠ .inl 10) : + headerPlacement placement output i = placement i := by simp [headerPlacement, hi] + +theorem headerPlacement_injective {max : Nat} + (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) : + Function.Injective (headerPlacement placement output) := by + intro i j h + by_cases hi : i = .inl 10 + · subst i + by_cases hj : j = .inl 10 + · exact hj.symm + · exact False.elim (outside j (by simpa [headerPlacement, hj] using h)) + · by_cases hj : j = .inl 10 + · subst j + exact False.elim (outside i (by simpa [headerPlacement, hi] using h.symm)) + · exact distinct (by simpa [headerPlacement, hi, hj] using h) + +theorem headerPlacement_excludes_data {max : Nat} + (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) : + ∀ i, placement (.inl 10) ≠ headerPlacement placement output i := by + intro i h + by_cases hi : i = .inl 10 + · subst i + exact outside _ (by simpa only [headerPlacement_output] using h.symm) + · have heq : (.inl 10 : PoweringMachineTapes.Tape max) = i := + distinct (by simpa [headerPlacement, hi] using h) + exact hi heq.symm + +variable [DecidableEq K] + +def instruction (n : Nat) (placement : PoweringMachineTapes.Tape (capacity n) → K) + (output : K) (ports : Fin (n + 1) → Fin d) (direction : Bool) + (labels : Label n ports direction → Λ) (exit : Option Λ) : + Label n ports direction → TM2.Stmt (fun _ : K => Bool) Λ (State d n) + | .inl q => PoweringMachinePlan.instruction placement (commands n ports direction) + (fun z => labels (.inl z)) (some (labels (.inr (.inl ())))) q + | .inr (.inl _) => PoweringMasterState.rowAt (t := n + 1) (placement (.inl 10)) output + (PoweringRowData.fixedLabelAt d n) (some (labels (.inr (.inr (PoweringMachineRowHeaders.entry n))))) + | .inr (.inr q) => PoweringMachineRowHeaders.instruction n (by unfold capacity; omega) + (headerPlacement placement output) ports direction (fun z => labels (.inr (.inr z))) exit q + +def afterPlan (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) : K → List Bool := + PoweringMachinePlan.finalTapes graph placement vertex (commands n ports direction) base + +def rowRelation (graph : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : List Bool := + encodeWords (GenericGraphTables.relationWords (PoweringTables.table graph n).rows[ + PoweringEnumeration.encodeDart vertices d n (direction, vertex, ports)].relation) + +def rowWords (graph : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : List Nat := + GenericGraphTables.rowWords (PoweringTables.table graph n).rows[ + PoweringEnumeration.encodeDart vertices d n (direction, vertex, ports)] + +def afterEmit (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (output : K) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) : K → List Bool := + let mid := afterPlan graph n placement vertex ports direction base + Function.update (Function.update mid (placement (.inl 10)) []) output + (rowRelation graph n vertex ports direction ++ mid output) + +def finalTapes (graph : PortTables.Table vertices d) + (n : Nat) (placement : PoweringMachineTapes.Tape (capacity n) → K) (output : K) + (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) + (base : K → List Bool) : K → List Bool := + PoweringMachineRowHeaders.finalTapes graph n (by unfold capacity; omega) + (headerPlacement placement output) vertex ports direction + (afterEmit graph n placement output vertex ports direction base) + +def planSteps {max : Nat} (graph : PortTables.Table vertices d) (vertex : Fin vertices) : + List (PoweringMachinePlan.Command d max) → Nat + | [] => 0 + | op :: ops => PoweringMachineField.steps graph vertex op.val + planSteps graph vertex ops + +theorem planSteps_eq {max : Nat} (graph : PortTables.Table vertices d) + (placement : PoweringMachineTapes.Tape max → K) (vertex : Fin vertices) + (ops : List (PoweringMachinePlan.Command d max)) (base : K → List Bool) : + PoweringMachinePlan.steps graph placement vertex ops base = planSteps graph vertex ops := by + induction ops generalizing base with + | nil => rfl + | cons op ops ih => + change PoweringMachineField.steps graph vertex op.val + + PoweringMachinePlan.steps graph placement vertex ops + (PoweringMachinePlan.result graph placement vertex op base) = _ + rw [ih] + rfl + +def steps (graph : PortTables.Table vertices d) (vertex : Fin vertices) + (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : Nat := + planSteps graph vertex (commands n ports direction) + 1 + + PoweringMachineRowHeaders.steps graph n vertex ports direction + +def Ready (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (vertex : Fin vertices) + (suffix : List Bool) (base : K → List Bool) : Prop := + PoweringMachineField.Ready graph placement vertex suffix base ∧ base (placement (.inl 10)) = [] + +private theorem plan_other {max : Nat} (graph : PortTables.Table vertices d) + (placement : PoweringMachineTapes.Tape max → K) (vertex : Fin vertices) + (ops : List (PoweringMachinePlan.Command d max)) (base : K → List Bool) + (k : K) (outside : ∀ i, k ≠ placement i) : + PoweringMachinePlan.finalTapes graph placement vertex ops base k = base k := by + induction ops generalizing base with + | nil => rfl + | cons op ops ih => + change PoweringMachinePlan.finalTapes graph placement vertex ops + (PoweringMachinePlan.result graph placement vertex op base) k = _ + rw [ih] + exact PoweringMachineField.finalTapes_other graph placement vertex op.val op.property base k outside + +theorem afterEmit_data (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (output : K) + (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) : + afterEmit graph n placement output vertex ports direction base (placement (.inl 10)) = [] := by + simp only [afterEmit, Function.update_of_ne (Ne.symm (outside _)), Function.update_self] + +theorem afterEmit_role (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) + (j : Fin 11) (hj : j ≠ 10) : + afterEmit graph n placement output vertex ports direction base (placement (.inl j)) = + afterPlan graph n placement vertex ports direction base (placement (.inl j)) := by + have hdata : placement (.inl j) ≠ placement (.inl 10) := fun h => hj (Sum.inl.inj (distinct h)) + simp only [afterEmit, Function.update_of_ne (Ne.symm (outside _)), Function.update_of_ne hdata] + +theorem afterEmit_ready (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) + (suffix : List Bool) (ready : Ready graph n placement vertex suffix base) : + Ready graph n placement vertex suffix (afterEmit graph n placement output vertex ports direction base) := by + have hp := PoweringMachinePlan.ready_finalTapes graph placement distinct vertex + (commands n ports direction) base suffix ready.1 + constructor + · constructor + · rw [afterEmit_role graph n placement distinct output outside vertex ports direction base 0 (by decide)] + exact hp.table + · rw [afterEmit_role graph n placement distinct output outside vertex ports direction base 1 (by decide)] + exact hp.source + · rw [afterEmit_role graph n placement distinct output outside vertex ports direction base 5 (by decide)] + exact hp.scratch + · rw [afterEmit_role graph n placement distinct output outside vertex ports direction base 8 (by decide)] + exact hp.leftCopy + · rw [afterEmit_role graph n placement distinct output outside vertex ports direction base 9 (by decide)] + exact hp.rightCopy + · exact afterEmit_data graph n placement output outside vertex ports direction base + +theorem finalTapes_data (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) : + finalTapes graph n placement output vertex ports direction base (placement (.inl 10)) = [] := by + have hother := headerPlacement_excludes_data placement distinct output outside + calc + finalTapes graph n placement output vertex ports direction base (placement (.inl 10)) = + afterEmit graph n placement output vertex ports direction base (placement (.inl 10)) := + PoweringMachineRowHeaders.finalTapes_other _ _ _ _ _ _ _ _ _ + (hother _) (hother _) (hother _) (hother _) (fun i => hother _) + _ = [] := afterEmit_data graph n placement output outside vertex ports direction base + +theorem finalTapes_ready (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) + (suffix : List Bool) (ready : Ready graph n placement vertex suffix base) : + Ready graph n placement vertex suffix (finalTapes graph n placement output vertex ports direction base) := by + have hm := afterEmit_ready graph n placement distinct output outside vertex ports direction base suffix ready + have hrole (j : Fin 11) (h₂ : j ≠ 2) (h₃ : j ≠ 3) (h₄ : j ≠ 4) (h₁₀ : j ≠ 10) : + finalTapes graph n placement output vertex ports direction base (placement (.inl j)) = + afterEmit graph n placement output vertex ports direction base (placement (.inl j)) := by + have h := PoweringMachineRowHeaders.finalTapes_shared graph n (by unfold capacity; omega) + (headerPlacement placement output) (headerPlacement_injective placement distinct output outside) + vertex ports direction (afterEmit graph n placement output vertex ports direction base) j h₂ h₃ h₄ h₁₀ + dsimp only [finalTapes] + simpa only [headerPlacement, ite_eq_right (show (Sum.inl j : PoweringMachineTapes.Tape (capacity n)) ≠ .inl 10 from + fun heq => h₁₀ (Sum.inl.inj heq))] using h + constructor + · constructor + · rw [hrole 0 (by decide) (by decide) (by decide) (by decide)]; exact hm.1.table + · rw [hrole 1 (by decide) (by decide) (by decide) (by decide)]; exact hm.1.source + · rw [hrole 5 (by decide) (by decide) (by decide) (by decide)]; exact hm.1.scratch + · rw [hrole 8 (by decide) (by decide) (by decide) (by decide)]; exact hm.1.leftCopy + · rw [hrole 9 (by decide) (by decide) (by decide) (by decide)]; exact hm.1.rightCopy + · exact finalTapes_data graph n placement distinct output outside vertex ports direction base + +theorem finalTapes_other (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (output : K) + (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) + (base : K → List Bool) (k : K) (hout : k ≠ output) (outside : ∀ i, k ≠ placement i) : + finalTapes graph n placement output vertex ports direction base k = base k := by + have hh : ∀ i, k ≠ headerPlacement placement output i := by + intro i + by_cases hi : i = .inl 10 + · simpa [headerPlacement, hi] using hout + · simpa [headerPlacement, hi] using outside i + calc + finalTapes graph n placement output vertex ports direction base k = + afterEmit graph n placement output vertex ports direction base k := + PoweringMachineRowHeaders.finalTapes_other _ _ _ _ _ _ _ _ _ + (hh _) (hh _) (hh _) (hh _) (fun i => hh _) + _ = afterPlan graph n placement vertex ports direction base k := by + simp only [afterEmit, Function.update_of_ne hout, Function.update_of_ne (outside _)] + _ = base k := plan_other graph placement vertex _ base k outside + +theorem rowBlock_eq_rowRelation (graph : PortTables.Table vertices d) (n : Nat) + (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + PoweringMachineRow.encodeBits (List.ofFn (PoweringMachineRow.rowBlock + (PoweringRowData.fixedLabelAt d n) (PoweringRowData.rowBits graph n (direction, vertex, ports)))) = + rowRelation graph n vertex ports direction := by + calc + _ = encodeWords (GenericGraphTables.relationWords + (PoweringRowData.emittedRelation graph n (direction, vertex, ports))) := + PoweringRowData.rowBlock_unary graph n (direction, vertex, ports) + _ = _ := by + have h := PoweringRowData.emittedRelation_table graph n + (PoweringEnumeration.encodeDart vertices d n (direction, vertex, ports)) + rw [PoweringEnumeration.decodeDart_encodeDart] at h + exact congrArg (fun relation : GenericGraphTables.RelationTable (PoweringTables.labelCount d n) => + encodeWords (GenericGraphTables.relationWords relation)) h + +theorem finalTapes_output (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) + (suffix : List Bool) (ready : Ready graph n placement vertex suffix base) : + finalTapes graph n placement output vertex ports direction base output = + encodeWords (rowWords graph n vertex ports direction) ++ base output := by + have hm := afterEmit_ready graph n placement distinct output outside vertex ports direction base suffix ready + have hh := (PoweringMachineRowHeaders.headerTrace graph n (by unfold capacity; omega) + (headerPlacement placement output) (headerPlacement_injective placement distinct output outside) + vertex ports direction id none + (PoweringMachineRowHeaders.instruction n (by unfold capacity; omega) + (headerPlacement placement output) ports direction id none) (fun _ => rfl) + (afterEmit graph n placement output vertex ports direction base) + (by simpa [headerPlacement, PoweringMachineTapes.table] using hm.1.table) + (by simpa [headerPlacement, PoweringMachineTapes.scratch] using hm.1.scratch) suffix + (by simpa [headerPlacement, PoweringMachineTapes.start] using hm.1.source) () none).2 + simp only [PoweringMachineTapes.rowOutput, headerPlacement_output] at hh + calc + finalTapes graph n placement output vertex ports direction base output = + encodeWords (PoweringRowHeaderSemantics.headerWords graph n vertex ports direction) ++ + afterEmit graph n placement output vertex ports direction base output := hh + _ = encodeWords (PoweringRowHeaderSemantics.headerWords graph n vertex ports direction) ++ + (rowRelation graph n vertex ports direction ++ base output) := by + simp only [afterEmit, Function.update_self] + rw [show afterPlan graph n placement vertex ports direction base output = base output from + plan_other graph placement vertex _ base output outside] + _ = _ := PoweringRowHeaderSemantics.header_relation_bits graph n vertex ports direction (base output) + +theorem rowTrace (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) + (labels : Label n ports direction → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State d n)) + (atLabels : ∀ l, program (labels l) = instruction n placement output ports direction labels exit l) + (base : K → List Bool) (suffix : List Bool) (ready : Ready graph n placement vertex suffix base) : + (advance (TM2.step program))^[steps graph vertex n ports direction] + (some ⟨some (labels (entry n ports direction)), PoweringMasterState.clean (bufferSize d n), base⟩) = + some ⟨exit, PoweringMasterState.clean (bufferSize d n), + finalTapes graph n placement output vertex ports direction base⟩ := by + have hp := PoweringMachinePlan.planTrace graph placement distinct vertex (commands n ports direction) + (fun q => labels (.inl q)) (some (labels (.inr (.inl ())))) program + (fun q => atLabels (.inl q)) base suffix ready.1 (emptyBuffer (bufferSize d n)) + rw [planSteps_eq, plan_entry_eq] at hp + let mid := afterPlan graph n placement vertex ports direction base + have hinput : mid (placement (.inl 10)) = PoweringMachineRow.encodeBits + (List.ofFn (PoweringRowData.rowBits graph n (direction, vertex, ports))) ++ [] := by + dsimp only [mid, afterPlan, commands] + have h := PoweringMachinePlan.rowPlan_output graph n ports direction placement distinct vertex base suffix ready.1 + simpa only [ready.2, List.append_nil, PoweringRowData.dataTape_eq] using h + have hr := PoweringMasterState.step_rowAt_clean (t := n + 1) (placement (.inl 10)) output + (PoweringRowData.fixedLabelAt d n) + (some (labels (.inr (.inr (PoweringMachineRowHeaders.entry n))))) program (labels (.inr (.inl ()))) + (atLabels (.inr (.inl ()))) (Ne.symm (outside _)) + (PoweringRowData.rowBits graph n (direction, vertex, ports)) + (emptyBuffer (bufferSize d n)) [] mid hinput + rw [rowBlock_eq_rowRelation] at hr + have hm := afterEmit_ready graph n placement distinct output outside vertex ports direction base suffix ready + have hh := (PoweringMachineRowHeaders.headerTrace graph n (by unfold capacity; omega) + (headerPlacement placement output) (headerPlacement_injective placement distinct output outside) + vertex ports direction (fun q => labels (.inr (.inr q))) exit program + (fun q => atLabels (.inr (.inr q))) + (afterEmit graph n placement output vertex ports direction base) + (by simpa [headerPlacement, PoweringMachineTapes.table] using hm.1.table) + (by simpa [headerPlacement, PoweringMachineTapes.scratch] using hm.1.scratch) suffix + (by simpa [headerPlacement, PoweringMachineTapes.start] using hm.1.source) + (emptyBuffer (bufferSize d n), false, none) none).1 + rw [steps, Nat.add_comm, Function.iterate_add_apply, Function.iterate_succ_apply'] + change (advance (TM2.step program))^[PoweringMachineRowHeaders.steps graph n vertex ports direction] + (advance (TM2.step program) ((advance (TM2.step program))^[planSteps graph vertex (commands n ports direction)] + (some ⟨some (labels (planMain (commands n ports direction) (.inl ()))), + MachineUnaryEqualityBit.clean (emptyBuffer (bufferSize d n)), base⟩))) = _ + rw [hp] + simp only [advance_some] + change (advance (TM2.step program))^[PoweringMachineRowHeaders.steps graph n vertex ports direction] + (TM2.step program ⟨some (labels (.inr (.inl ()))), + PoweringMasterState.withBuffer (emptyBuffer (bufferSize d n)), mid⟩) = _ + rw [hr] + exact hh + +def budget (d n inputLength : Nat) : Nat := + PoweringPlanBudget.rowBudget d n inputLength + 1 + + ((14 * (n + 1) + 4) * inputLength + 12 * (n + 1) + 6) + +theorem steps_le (graph : PortTables.Table vertices d) (vertex : Fin vertices) + (n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : + steps graph vertex n ports direction ≤ budget d n (PortTables.tableBits graph).length := by + have hp := PoweringPlanBudget.rowPlan_steps_le graph n ports direction id vertex (fun _ => []) + rw [planSteps_eq] at hp + have hh := PoweringMachineRowHeaders.steps_le graph n vertex ports direction + change planSteps graph vertex (commands n ports direction) ≤ + PoweringPlanBudget.rowBudget d n (PortTables.tableBits graph).length at hp + unfold steps budget + omega + +def rowInTime (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (capacity n) → K) (distinct : Function.Injective placement) + (output : K) (outside : ∀ i, output ≠ placement i) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) + (labels : Label n ports direction → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State d n)) + (atLabels : ∀ l, program (labels l) = instruction n placement output ports direction labels exit l) + (base : K → List Bool) (suffix : List Bool) (ready : Ready graph n placement vertex suffix base) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels (entry n ports direction)), PoweringMasterState.clean (bufferSize d n), base⟩ + (some ⟨exit, PoweringMasterState.clean (bufferSize d n), + finalTapes graph n placement output vertex ports direction base⟩) + (budget d n (PortTables.tableBits graph).length) where + steps := steps graph vertex n ports direction + evals_in_steps := rowTrace graph n placement distinct output outside vertex ports direction + labels exit program atLabels base suffix ready + steps_le_m := steps_le graph vertex n ports direction + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRowBody + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRowHeaders.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRowHeaders.lean new file mode 100644 index 0000000000000000000000000000000000000000..f26cd35fe3a832012278b398f1a9807a3b57e866 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRowHeaders.lean @@ -0,0 +1,241 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringPlanBudget +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineTapes + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRowHeaders + +open Turing MachineComposition +open PCP PoweringRowHeaderSemantics +open PoweringMachineTapes + +variable {K Λ σ : Type} [DecidableEq K] +variable {vertices d max : Nat} + +def headerPlacement {t max : Nat} (h : t ≤ max) : PoweringMachineWord.Tape t → Tape max := + (Equiv.swap (leftEndpoint max) (rowOutput max)) ∘ wordPlacement h false + +theorem headerPlacement_injective {t max : Nat} (h : t ≤ max) : + Function.Injective (headerPlacement h) := + (Equiv.swap (leftEndpoint max) (rowOutput max)).injective.comp (wordPlacement_injective h false) + +@[simp] theorem headerPlacement_table {t max : Nat} (h : t ≤ max) : + headerPlacement h (.inl 0) = table max := by + simp [headerPlacement, table, leftEndpoint, rowOutput, Equiv.swap_apply_def] + +@[simp] theorem headerPlacement_query {t max : Nat} (h : t ≤ max) : + headerPlacement h (.inl 1) = query max := by + simp [headerPlacement, query, leftEndpoint, rowOutput, Equiv.swap_apply_def] + +@[simp] theorem headerPlacement_scan {t max : Nat} (h : t ≤ max) : + headerPlacement h (.inl 2) = scan max := by + simp [headerPlacement, scan, leftEndpoint, rowOutput, Equiv.swap_apply_def] + +@[simp] theorem headerPlacement_reverse {t max : Nat} (h : t ≤ max) : + headerPlacement h (.inl 3) = reverse max := by + simp [headerPlacement, reverse, leftEndpoint, rowOutput, Equiv.swap_apply_def] + +@[simp] theorem headerPlacement_scratch {t max : Nat} (h : t ≤ max) : + headerPlacement h (.inl 4) = scratch max := by + simp [headerPlacement, scratch, leftEndpoint, rowOutput, Equiv.swap_apply_def] + +@[simp] theorem headerPlacement_output {t max : Nat} (h : t ≤ max) : + headerPlacement h (.inl 5) = rowOutput max := by + simp [headerPlacement] + +@[simp] theorem headerPlacement_start {t max : Nat} (h : t ≤ max) : + headerPlacement h (.inr (PoweringMachineWord.first t)) = start max := by + simp [headerPlacement, start, leftEndpoint, rowOutput, Equiv.swap_apply_def] + +@[simp] theorem headerPlacement_succ {t max : Nat} (h : t ≤ max) (i : Fin t) : + headerPlacement h (.inr i.succ) = .inr (Fin.castLE h i) := by + simp [headerPlacement, leftEndpoint, rowOutput, Equiv.swap_apply_def] + +abbrev Label (n : Nat) := MachineUnaryAffineAt.Label ⊕ + (MachineUnaryAffineAt.Label ⊕ PoweringMachineWord.Label (n + 1)) + +def entry (n : Nat) : Label n := .inl .seed + +def tailEntry (n : Nat) (direction : Bool) : Label n := + if direction then .inr (.inr (PoweringMachineWord.entry (n + 1))) else .inr (.inl .seed) + +def affineInstruction (source work output : K) (coefficient offset : Nat) + (labels : MachineUnaryAffineAt.Label → Λ) (exit : Option Λ) : + MachineUnaryAffineAt.Label → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool) + | .seed => MachineUnaryAffineAt.seed output offset (labels .scan) + | .scan => MachineUnaryAffineAt.scan source work output coefficient (labels .scan) (labels .restore) + | .restore => Reduction.MachineTransfer.loopAt work source id false (labels .restore) exit + +def instruction (n : Nat) (h : n + 1 ≤ max) (placement : Tape max → K) + (ports : Fin (n + 1) → Fin d) (direction : Bool) + (labels : Label n → Λ) (exit : Option Λ) : + Label n → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool) + | .inl q => affineInstruction (placement (start max)) (placement (scratch max)) + (placement (rowOutput max)) (blockSize d n) (reverseOffset d n ports direction) + (fun z => labels (.inl z)) (some (labels (tailEntry n direction))) q + | .inr (.inl q) => PoweringMachineWord.copyInstruction + (placement (start max)) (placement (scratch max)) (placement (rowOutput max)) + (fun z => labels (.inr (.inl z))) exit q + | .inr (.inr q) => PoweringMachineWord.instruction (n + 1) + (placement ∘ headerPlacement h) ports (fun z => labels (.inr (.inr z))) exit q + +def afterReverse (n : Nat) (placement : Tape max → K) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) (base : K → List Bool) : K → List Bool := + Function.update base (placement (rowOutput max)) + (encodeWord (reverseValue d n vertex ports direction) ++ base (placement (rowOutput max))) + +def finalTapes (input : PortTables.Table vertices d) (n : Nat) (h : n + 1 ≤ max) + (placement : Tape max → K) (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) + (direction : Bool) (base : K → List Bool) : K → List Bool := + let mid := afterReverse n placement vertex ports direction base + if direction then + PoweringMachineWord.finalTapes input (n + 1) (placement ∘ headerPlacement h) vertex ports mid + else Function.update mid (placement (rowOutput max)) + (encodeWord vertex.val ++ mid (placement (rowOutput max))) + +def steps (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : Nat := + (2 * (vertex.val + 1) + 1) + + if direction then PoweringMachineWord.steps input (n + 1) vertex ports + else 2 * (vertex.val + 1) + 1 + +theorem headerTrace (input : PortTables.Table vertices d) (n : Nat) (h : n + 1 ≤ max) + (placement : Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) + (labels : Label n → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) + (atLabels : ∀ l, program (labels l) = instruction n h placement ports direction labels exit l) + (base : K → List Bool) (tableWord : base (placement (table max)) = PortTables.tableBits input) + (scratchEmpty : base (placement (scratch max)) = []) (suffix : List Bool) + (sourceWord : base (placement (start max)) = encodeWord vertex.val ++ suffix) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps input n vertex ports direction] + (some ⟨some (labels (entry n)), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), finalTapes input n h placement vertex ports direction base⟩ ∧ + finalTapes input n h placement vertex ports direction base (placement (rowOutput max)) = + encodeWords (headerWords input n vertex ports direction) ++ base (placement (rowOutput max)) := by + have hd (i j : Tape max) (hne : i ≠ j) : placement i ≠ placement j := + fun eq => hne (distinct eq) + have hsourceOut : placement (start max) ≠ placement (rowOutput max) := + hd _ _ (by simp [start, rowOutput]) + have hscratchOut : placement (scratch max) ≠ placement (rowOutput max) := + hd _ _ (by simp [scratch, rowOutput]) + have htableOut : placement (table max) ≠ placement (rowOutput max) := + hd _ _ (by simp [table, rowOutput]) + let mid := afterReverse n placement vertex ports direction base + have hrev := MachineUnaryAffineAt.seededAffineTrace + (placement (start max)) (placement (scratch max)) (placement (rowOutput max)) + (hd _ _ (by simp [start, scratch])) hsourceOut hscratchOut + (blockSize d n) (reverseOffset d n ports direction) + (labels (.inl .seed)) (labels (.inl .scan)) (labels (.inl .restore)) + (some (labels (tailEntry n direction))) program + (atLabels (.inl .seed)) (atLabels (.inl .scan)) (atLabels (.inl .restore)) + base vertex.val suffix sourceWord scratchEmpty ambient register + have hreverseTrace : (advance (TM2.step program))^[2 * (vertex.val + 1) + 1] + (some ⟨some (labels (entry n)), (ambient, register), base⟩) = + some ⟨some (labels (tailEntry n direction)), (ambient, none), mid⟩ := by + simpa only [entry, mid, afterReverse, reverseValue] using hrev + have hmidSource : mid (placement (start max)) = encodeWord vertex.val ++ suffix := by + simpa only [mid, afterReverse, Function.update_of_ne hsourceOut] using sourceWord + have hmidScratch : mid (placement (scratch max)) = [] := by + simpa only [mid, afterReverse, Function.update_of_ne hscratchOut] using scratchEmpty + have hmidTable : mid (placement (table max)) = PortTables.tableBits input := by + simpa only [mid, afterReverse, Function.update_of_ne htableOut] using tableWord + cases direction with + | false => + have hcopy := MachineUnaryAffineAt.seededAffineTrace + (placement (start max)) (placement (scratch max)) (placement (rowOutput max)) + (hd _ _ (by simp [start, scratch])) hsourceOut hscratchOut 1 0 + (labels (.inr (.inl .seed))) (labels (.inr (.inl .scan))) + (labels (.inr (.inl .restore))) exit program + (atLabels (.inr (.inl .seed))) (atLabels (.inr (.inl .scan))) + (atLabels (.inr (.inl .restore))) mid vertex.val suffix hmidSource hmidScratch ambient none + constructor + · rw [steps, ite_eq_right Bool.false_ne_true, Function.iterate_add_apply, hreverseTrace] + simpa only [tailEntry, Bool.false_eq_true, ite_false, finalTapes, Nat.one_mul, + Nat.add_zero] using hcopy + · simp only [finalTapes, Bool.false_eq_true, ite_false, Function.update_self, + afterReverse, headerWords, tailVertex, encodeWords, List.append_nil, List.append_assoc] + | true => + have hword := PoweringMachineWord.wordTrace input (n + 1) + (placement ∘ headerPlacement h) (distinct.comp (headerPlacement_injective h)) vertex ports + (fun z => labels (.inr (.inr z))) exit program (fun z => atLabels (.inr (.inr z))) mid + (by simpa only [Function.comp_apply, headerPlacement_table] using hmidTable) + (by simpa only [Function.comp_apply, headerPlacement_scratch] using hmidScratch) + suffix (by simpa only [Function.comp_apply, headerPlacement_start] using hmidSource) ambient none + constructor + · rw [steps, ite_eq_left rfl, Nat.add_comm, Function.iterate_add_apply, hreverseTrace] + simpa only [tailEntry, ite_true, finalTapes] using hword.1 + · have hout := hword.2 + simp only [Function.comp_apply, headerPlacement_output] at hout + simpa only [finalTapes, ite_true, mid, afterReverse, Function.update_self, + headerWords, tailVertex, encodeWords, List.append_nil, List.append_assoc] using hout + +theorem finalTapes_other (input : PortTables.Table vertices d) (n : Nat) (h : n + 1 ≤ max) + (placement : Tape max → K) (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) + (direction : Bool) (base : K → List Bool) (k : K) + (hquery : k ≠ placement (query max)) (hscan : k ≠ placement (scan max)) + (hreverse : k ≠ placement (reverse max)) (houtput : k ≠ placement (rowOutput max)) + (hpositions : ∀ i : Fin (n + 1), k ≠ placement (.inr (Fin.castLE h i))) : + finalTapes input n h placement vertex ports direction base k = base k := by + cases direction with + | false => simp only [finalTapes, Bool.false_eq_true, ite_false, + Function.update_of_ne houtput, afterReverse] + | true => + let mid := afterReverse n placement vertex ports true base + have hw := PoweringMachineWord.finalTapes_other input (n + 1) + (placement ∘ headerPlacement h) vertex ports mid k + (by simpa only [Function.comp_apply, headerPlacement_query] using hquery) + (by simpa only [Function.comp_apply, headerPlacement_scan] using hscan) + (by simpa only [Function.comp_apply, headerPlacement_reverse] using hreverse) + (by simpa only [Function.comp_apply, headerPlacement_output] using houtput) + (fun i => by simpa only [Function.comp_apply, headerPlacement_succ] using hpositions i) + calc + _ = mid k := hw + _ = base k := by simp only [mid, afterReverse, Function.update_of_ne houtput] + +theorem finalTapes_shared (input : PortTables.Table vertices d) (n : Nat) (h : n + 1 ≤ max) + (placement : Tape max → K) (distinct : Function.Injective placement) + (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) + (direction : Bool) (base : K → List Bool) (i : Fin 11) + (hquery : i ≠ 2) (hscan : i ≠ 3) (hreverse : i ≠ 4) (houtput : i ≠ 10) : + finalTapes input n h placement vertex ports direction base (placement (.inl i)) = + base (placement (.inl i)) := by + apply finalTapes_other input n h placement vertex ports direction base + · intro heq; exact hquery (Sum.inl.inj (distinct heq)) + · intro heq; exact hscan (Sum.inl.inj (distinct heq)) + · intro heq; exact hreverse (Sum.inl.inj (distinct heq)) + · intro heq; exact houtput (Sum.inl.inj (distinct heq)) + · intro j heq; cases distinct heq + +theorem steps_le (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (ports : Fin (n + 1) → Fin d) (direction : Bool) : + steps input n vertex ports direction ≤ + (14 * (n + 1) + 4) * (PortTables.tableBits input).length + 12 * (n + 1) + 6 := by + have hv : vertex.val ≤ (PortTables.tableBits input).length := + Nat.le_trans (Nat.le_of_lt vertex.isLt) (PortTables.vertices_le_tableBits_length input) + have hw := PoweringMachineWord.steps_le input (n + 1) vertex ports + cases direction <;> simp only [steps, Bool.false_eq_true, ite_false, ite_true] + · simp only [Nat.add_mul] + omega + · calc + _ ≤ (2 * (PortTables.tableBits input).length + 3) + + ((14 * (n + 1) + 2) * (PortTables.tableBits input).length + 12 * (n + 1) + 3) := + Nat.add_le_add (by omega) hw + _ = _ := by simp only [Nat.add_mul]; omega + +def machine (degree n : Nat) (ports : Fin (n + 1) → Fin degree) (direction : Bool) : FinTM2 where + K := PoweringMachineTapes.Tape (n + 1) + k₀ := table (n + 1) + k₁ := rowOutput (n + 1) + Γ _ := Bool + Λ := Label n + main := entry n + σ := (Unit × Bool × Option Bool) × Option Bool + initialState := (((), false, none), none) + m := instruction n (Nat.le_refl (n + 1)) id ports direction id none + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRowHeaders + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRuntime.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRuntime.lean new file mode 100644 index 0000000000000000000000000000000000000000..166ea02e1d3a26782b2ebe27db13cf509fc2ce81 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineRuntime.lean @@ -0,0 +1,180 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PoweringInitializeFrame +import OAI.Combinatorics.IndependentSets.Expansion.PoweringGlobalConfiguration +import OAI.Combinatorics.IndependentSets.Machines.PoweringRuntimeBudget +import OAI.Combinatorics.IndependentSets.Expansion.PoweringPolynomialBudget + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineRuntime + +open Turing MachineComposition PCP PoweringMachineGlobal + +variable {vertices d : Nat} + +def beforeFinish (graph : PortTables.Table vertices d) (n : Nat) : Tape n → List Bool := + PoweringMachineOuterLoop.finalTapes graph n (placement n) (outputTape n) + vertices (Nat.le_refl _) (PoweringInitializeFrame.preparedTapes graph n) + +def finishConfiguration (graph : PortTables.Table vertices d) (n : Nat) : (machine d n).Cfg := + ⟨some (finishEntry d n), PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + beforeFinish graph n⟩ + +def beforeFinishBudget (graph : PortTables.Table vertices d) (n : Nat) : Nat := + (3 * vertices + 5) + (vertices * + (PoweringMachineVertex.budget d n (PortTables.tableBits graph).length + 2) + 1) + +theorem beforeFinish_ready (graph : PortTables.Table vertices d) (n : Nat) : + PoweringMachineOuterLoop.Ready graph n (placement n) (beforeFinish graph n) := + PoweringMachineOuterLoop.finalTapes_ready graph n (placement n) + (PoweringMachineInitialize.commonPlacement_injective _) + (outputTape n) (fun i => Ne.symm (PoweringMachineInitialize.commonPlacement_ne_finalOutput _ i)) + vertices (Nat.le_refl _) (PoweringInitializeFrame.preparedTapes graph n) + (PoweringInitializeFrame.prepared_ready graph n) + +theorem beforeFinish_output (graph : PortTables.Table vertices d) (n : Nat) : + beforeFinish graph n (outputTape n) = + (List.finRange vertices).flatMap (PoweringTableLayout.vertexRowBits graph n) := by + rw [beforeFinish, PoweringMachineOuterLoop.finalTapes_output graph n (placement n) + (PoweringMachineInitialize.commonPlacement_injective _) (outputTape n) + (fun i => Ne.symm (PoweringMachineInitialize.commonPlacement_ne_finalOutput _ i)) + vertices (Nat.le_refl _) (PoweringInitializeFrame.preparedTapes graph n) + (PoweringInitializeFrame.prepared_ready graph n), + PoweringMachineOuterLoop.prefixRows_all, PoweringInitializeFrame.prepared_output, + List.append_nil] + +theorem beforeFinish_vertices (graph : PortTables.Table vertices d) (n : Nat) : + beforeFinish graph n (headerVertices n) = encodeWord vertices := by + rw [beforeFinish, PoweringMachineOuterLoop.finalTapes_other graph n (placement n) + (outputTape n) vertices (Nat.le_refl _) (PoweringInitializeFrame.preparedTapes graph n) + (headerVertices n) (PoweringGlobalConfiguration.headerVertices_ne_output n) + (fun i => Ne.symm (PoweringMachineInitialize.commonPlacement_ne_header _ i .vertices (by decide)))] + exact PoweringInitializeFrame.prepared_vertices graph n + +theorem beforeFinish_darts (graph : PortTables.Table vertices d) (n : Nat) : + beforeFinish graph n (headerDarts n) = + encodeWord (PoweringTableLayout.blockSize d n * vertices) := by + rw [beforeFinish, PoweringMachineOuterLoop.finalTapes_other graph n (placement n) + (outputTape n) vertices (Nat.le_refl _) (PoweringInitializeFrame.preparedTapes graph n) + (headerDarts n) (PoweringGlobalConfiguration.headerDarts_ne_output n) + (fun i => Ne.symm (PoweringMachineInitialize.commonPlacement_ne_header _ i .darts (by decide)))] + exact PoweringInitializeFrame.prepared_darts graph n + +theorem serialized_eq (graph : PortTables.Table vertices d) (n : Nat) : + encodeWords [vertices, PoweringTableLayout.blockSize d n * vertices] ++ + beforeFinish graph n (outputTape n) = PoweringTables.outputBits graph n := by + rw [beforeFinish_output, PoweringTableLayout.outputBits_vertexRows] + congr 2 + rw [PoweringTableLayout.dartCount_eq_vertex_blocks, Nat.mul_comm] + +def beforeFinishExecution (graph : PortTables.Table vertices d) (n : Nat) : + StateTransition.EvalsToInTime (machine d n).step + (initList (machine d n) (PortTables.tableBits graph)) + (some (finishConfiguration graph n)) (beforeFinishBudget graph n) := by + have initialRun := PoweringInitializeFrame.initializeInTime graph n + have loop := PoweringMachineOuterLoop.loopInTime graph n (placement n) + (PoweringMachineInitialize.commonPlacement_injective _) (outputTape n) + (fun i => Ne.symm (PoweringMachineInitialize.commonPlacement_ne_finalOutput _ i)) + (guardLabel d n) (bridgeLabel d n) (finishEntry d n) (vertexLabels d n) + (program d n) (atGuard d n) (atBridge d n) (atVertex d n) + vertices (Nat.le_refl _) (PoweringInitializeFrame.preparedTapes graph n) + (PoweringInitializeFrame.prepared_ready graph n) + rw [PoweringInitializeFrame.prepared_counter] at loop + simpa only [beforeFinishBudget, Nat.add_comm] using + (StateTransition.EvalsToInTime.trans (machine d n).step + (3 * vertices + 5) + (vertices * (PoweringMachineVertex.budget d n (PortTables.tableBits graph).length + 2) + 1) + (initList (machine d n) (PortTables.tableBits graph)) + (PoweringInitializeFrame.preparedCfg graph n) (some (finishConfiguration graph n)) + initialRun loop) + +def finishSteps (graph : PortTables.Table vertices d) (n : Nat) : Nat := + PoweringMachineFinish.steps (enumeration n) (outputTape n) (beforeFinish graph n) + vertices (PoweringTableLayout.blockSize d n * vertices) + +def finishExecution (graph : PortTables.Table vertices d) (n : Nat) : + StateTransition.EvalsToInTime (machine d n).step (finishConfiguration graph n) + (some (haltList (machine d n) (PoweringTables.outputBits graph n))) + (finishSteps graph n) := by + have run := PoweringMachineFinish.traceAt (enumeration n) + (headerVertices n) (headerDarts n) (outputTape n) + (placement n (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n))) + (PoweringGlobalConfiguration.headerVertices_ne_scratch n) + (PoweringGlobalConfiguration.headerVertices_ne_output n) + (PoweringGlobalConfiguration.headerDarts_ne_scratch n) + (PoweringGlobalConfiguration.headerDarts_ne_output n) + (PoweringMachineInitialize.commonPlacement_ne_finalOutput _ _) + (finishLabels d n) (program d n) (atFinish d n) + (beforeFinish graph n) vertices (PoweringTableLayout.blockSize d n * vertices) [] [] + (by simpa only [List.append_nil] using beforeFinish_vertices graph n) + (by simpa only [List.append_nil] using beforeFinish_darts graph n) + (beforeFinish_ready graph n).scratch + (PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n)).1 none + rw [serialized_eq] at run + refine { steps := finishSteps graph n, evals_in_steps := ?_, steps_le_m := Nat.le_refl _ } + change (advance (TM2.step (program d n)))^[finishSteps graph n] + (some (finishConfiguration graph n)) = _ + rw [PoweringGlobalConfiguration.haltList_eq] + exact run + +def execution (graph : PortTables.Table vertices d) (n : Nat) : + TM2OutputsInTime (machine d n) (PortTables.tableBits graph) + (some (PoweringTables.outputBits graph n)) + (beforeFinishBudget graph n + finishSteps graph n) := by + rw [Nat.add_comm (beforeFinishBudget graph n) (finishSteps graph n)] + exact StateTransition.EvalsToInTime.trans (machine d n).step + (beforeFinishBudget graph n) (finishSteps graph n) + (initList (machine d n) (PortTables.tableBits graph)) + (finishConfiguration graph n) + (some (haltList (machine d n) (PoweringTables.outputBits graph n))) + (beforeFinishExecution graph n) (finishExecution graph n) + +theorem finishSteps_le (graph : PortTables.Table vertices d) (n : Nat) : + finishSteps graph n ≤ + 2 * (vertices + PoweringTableLayout.blockSize d n * vertices) + 6 + + PoweringRuntimeBudget.tapeCount n * + ((PortTables.tableBits graph).length + beforeFinishBudget graph n * + Runtime.programPushBound (machine d n) + vertices + + PoweringTableLayout.blockSize d n * vertices + 3) := + PoweringRuntimeBudget.finish_steps_le_of_execution d n (PortTables.tableBits graph) + (finishConfiguration graph n) (beforeFinishBudget graph n) vertices + (PoweringTableLayout.blockSize d n * vertices) (beforeFinishExecution graph n) + +theorem execution_budget_le (graph : PortTables.Table vertices d) (n : Nat) : + beforeFinishBudget graph n + finishSteps graph n ≤ + (PoweringPolynomialBudget.time d n (Runtime.programPushBound (machine d n)) + (PoweringRuntimeBudget.tapeCount n)).eval (PortTables.tableBits graph).length := by + exact PoweringPolynomialBudget.execution_budget_le_time d n + (Runtime.programPushBound (machine d n)) (PoweringRuntimeBudget.tapeCount n) + vertices (PortTables.tableBits graph).length (PortTables.vertices_le_tableBits_length graph) + (Nat.le_refl _) (finishSteps_le graph n) + +noncomputable def computableInPolyTime (d n : Nat) : + TM2ComputableInPolyTime (@PortTables.inputBits d) GenericGraphTables.tableBits + (PoweringTables.transform d n) where + tm := machine d n + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := PoweringPolynomialBudget.time d n (Runtime.programPushBound (machine d n)) + (PoweringRuntimeBudget.tapeCount n) + outputsFun input := by + rcases input with ⟨vertices, graph⟩ + have run := execution graph n + let bounded : TM2OutputsInTime (machine d n) (PortTables.tableBits graph) + (some (PoweringTables.outputBits graph n)) + ((PoweringPolynomialBudget.time d n (Runtime.programPushBound (machine d n)) + (PoweringRuntimeBudget.tapeCount n)).eval (PortTables.tableBits graph).length) := + ⟨run.toEvalsTo, run.steps_le_m.trans (execution_budget_le graph n)⟩ + change TM2OutputsInTime (machine d n) ((PortTables.tableBits graph).map id) + (some ((PoweringTables.outputBits graph n).map id)) _ + simpa only [machine, List.map_id, PortTables.inputBits] using bounded + +theorem computableInPolyTime_finite_alphabet (d n : Nat) : + ∀ k, Finite ((computableInPolyTime d n).tm.Γ k) := by + intro k + change Finite Bool + infer_instance + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineRuntime + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineTapes.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineTapes.lean new file mode 100644 index 0000000000000000000000000000000000000000..8aa4166a3efd0deb9dfe7e2058319049f9778da6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineTapes.lean @@ -0,0 +1,174 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineWord + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineTapes + +abbrev Tape (max : Nat) := Fin 11 ⊕ Fin max + +def table (max : Nat) : Tape max := .inl 0 +def start (max : Nat) : Tape max := .inl 1 +def query (max : Nat) : Tape max := .inl 2 +def scan (max : Nat) : Tape max := .inl 3 +def reverse (max : Nat) : Tape max := .inl 4 +def scratch (max : Nat) : Tape max := .inl 5 +def leftEndpoint (max : Nat) : Tape max := .inl 6 +def rightEndpoint (max : Nat) : Tape max := .inl 7 +def leftCopy (max : Nat) : Tape max := .inl 8 +def rightCopy (max : Nat) : Tape max := .inl 9 +def rowOutput (max : Nat) : Tape max := .inl 10 + +def endpoint (max : Nat) (target : Bool) : Tape max := + if target then rightEndpoint max else leftEndpoint max + +@[simp] theorem endpoint_false (max : Nat) : endpoint max false = leftEndpoint max := rfl +@[simp] theorem endpoint_true (max : Nat) : endpoint max true = rightEndpoint max := rfl + +def wordSharedRole (target : Bool) (i : Fin 6) : Fin 11 := + if i = 0 then 0 else if i = 1 then 2 else if i = 2 then 3 else + if i = 3 then 4 else if i = 4 then 5 else if target then 7 else 6 + +def trajectoryPlacement {t max : Nat} (h : t ≤ max) : Fin (t + 1) → Tape max := + Fin.cases (start max) (fun i => .inr (Fin.castLE h i)) + +def wordPlacement {t max : Nat} (h : t ≤ max) (target : Bool) : + PoweringMachineWord.Tape t → Tape max + | .inl i => .inl (wordSharedRole target i) + | .inr i => trajectoryPlacement h i + +@[simp] theorem wordPlacement_inl_zero {t max : Nat} (h : t ≤ max) (target : Bool) : + wordPlacement h target (.inl 0) = table max := rfl +@[simp] theorem wordPlacement_inl_one {t max : Nat} (h : t ≤ max) (target : Bool) : + wordPlacement h target (.inl 1) = query max := rfl +@[simp] theorem wordPlacement_inl_two {t max : Nat} (h : t ≤ max) (target : Bool) : + wordPlacement h target (.inl 2) = scan max := rfl +@[simp] theorem wordPlacement_inl_three {t max : Nat} (h : t ≤ max) (target : Bool) : + wordPlacement h target (.inl 3) = reverse max := rfl +@[simp] theorem wordPlacement_inl_four {t max : Nat} (h : t ≤ max) (target : Bool) : + wordPlacement h target (.inl 4) = scratch max := rfl +@[simp] theorem wordPlacement_inl_five {t max : Nat} (h : t ≤ max) (target : Bool) : + wordPlacement h target (.inl 5) = endpoint max target := by cases target <;> rfl +@[simp] theorem wordPlacement_first {t max : Nat} (h : t ≤ max) (target : Bool) : + wordPlacement h target (.inr (PoweringMachineWord.first t)) = start max := rfl +@[simp] theorem wordPlacement_succ {t max : Nat} (h : t ≤ max) (target : Bool) (i : Fin t) : + wordPlacement h target (.inr i.succ) = .inr (Fin.castLE h i) := rfl + +def relationPlacement (max : Nat) (i : Fin 6) : Tape max := + .inl (if i = 0 then 6 else if i = 1 then 0 else if i = 2 then 2 else + if i = 3 then 3 else if i = 4 then 10 else 5) + +@[simp] theorem relationPlacement_zero (max : Nat) : relationPlacement max 0 = leftEndpoint max := rfl +@[simp] theorem relationPlacement_one (max : Nat) : relationPlacement max 1 = table max := rfl +@[simp] theorem relationPlacement_two (max : Nat) : relationPlacement max 2 = query max := rfl +@[simp] theorem relationPlacement_three (max : Nat) : relationPlacement max 3 = scan max := rfl +@[simp] theorem relationPlacement_four (max : Nat) : relationPlacement max 4 = rowOutput max := rfl +@[simp] theorem relationPlacement_five (max : Nat) : relationPlacement max 5 = scratch max := rfl + +def equalityPlacement (max : Nat) (i : Fin 6) : Tape max := + .inl (if i = 0 then 6 else if i = 1 then 7 else if i = 2 then 8 else + if i = 3 then 9 else if i = 4 then 5 else 10) + +@[simp] theorem equalityPlacement_zero (max : Nat) : equalityPlacement max 0 = leftEndpoint max := rfl +@[simp] theorem equalityPlacement_one (max : Nat) : equalityPlacement max 1 = rightEndpoint max := rfl +@[simp] theorem equalityPlacement_two (max : Nat) : equalityPlacement max 2 = leftCopy max := rfl +@[simp] theorem equalityPlacement_three (max : Nat) : equalityPlacement max 3 = rightCopy max := rfl +@[simp] theorem equalityPlacement_four (max : Nat) : equalityPlacement max 4 = scratch max := rfl +@[simp] theorem equalityPlacement_five (max : Nat) : equalityPlacement max 5 = rowOutput max := rfl + +theorem wordSharedRole_injective (target : Bool) : Function.Injective (wordSharedRole target) := by + cases target <;> decide + +theorem wordSharedRole_ne_start (target : Bool) : + ∀ i : Fin 6, wordSharedRole target i ≠ 1 := by + cases target <;> decide + +theorem wordSharedRole_ne_rowOutput (target : Bool) : + ∀ i : Fin 6, wordSharedRole target i ≠ 10 := by + cases target <;> decide + +theorem trajectoryPlacement_injective {t max : Nat} (ht : t ≤ max) : + Function.Injective (trajectoryPlacement ht) := by + intro a b + refine Fin.cases ?_ (fun i => ?_) a + · refine Fin.cases ?_ (fun j => ?_) b + · intro _ + rfl + · intro h + change (Sum.inl (1 : Fin 11) : Tape max) = .inr (Fin.castLE ht j) at h + cases h + · refine Fin.cases ?_ (fun j => ?_) b + · intro h + change (Sum.inr (Fin.castLE ht i) : Tape max) = .inl (1 : Fin 11) at h + cases h + · intro h + change (Sum.inr (Fin.castLE ht i) : Tape max) = .inr (Fin.castLE ht j) at h + have hc : Fin.castLE ht i = Fin.castLE ht j := Sum.inr.inj h + have hv : i.val = j.val := congrArg (fun x : Fin max => x.val) hc + have hij : i = j := Fin.ext hv + exact congrArg Fin.succ hij + +theorem wordShared_ne_trajectory {t max : Nat} (ht : t ≤ max) (target : Bool) + (i : Fin 6) : + ∀ j : Fin (t + 1), + (Sum.inl (wordSharedRole target i) : Tape max) ≠ trajectoryPlacement ht j := by + intro j + refine Fin.cases ?_ (fun k => ?_) j + · intro h + change (Sum.inl (wordSharedRole target i) : Tape max) = .inl (1 : Fin 11) at h + exact wordSharedRole_ne_start target i (Sum.inl.inj h) + · intro h + change (Sum.inl (wordSharedRole target i) : Tape max) = .inr (Fin.castLE ht k) at h + cases h + +theorem wordPlacement_injective {t max : Nat} (ht : t ≤ max) (target : Bool) : + Function.Injective (wordPlacement ht target) := by + intro a b h + cases a with + | inl i => + cases b with + | inl j => + exact congrArg Sum.inl (wordSharedRole_injective target (Sum.inl.inj h)) + | inr j => + exact False.elim (wordShared_ne_trajectory ht target i j h) + | inr i => + cases b with + | inl j => + exact False.elim (wordShared_ne_trajectory ht target j i h.symm) + | inr j => + exact congrArg Sum.inr (trajectoryPlacement_injective ht h) + +theorem relationPlacement_injective (max : Nat) : Function.Injective (relationPlacement max) := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [relationPlacement] + +theorem equalityPlacement_injective (max : Nat) : Function.Injective (equalityPlacement max) := by + intro i j h + fin_cases i <;> fin_cases j <;> simp_all [equalityPlacement] + +theorem wordPlacement_ne_rowOutput {t max : Nat} (ht : t ≤ max) (target : Bool) + (i : PoweringMachineWord.Tape t) : wordPlacement ht target i ≠ rowOutput max := by + cases i with + | inl i => + intro h + exact wordSharedRole_ne_rowOutput target i (Sum.inl.inj h) + | inr j => + refine Fin.cases ?_ (fun i => ?_) j + · intro h + change (Sum.inl (1 : Fin 11) : Tape max) = .inl (10 : Fin 11) at h + have hne : (1 : Fin 11) ≠ 10 := by decide + exact hne (Sum.inl.inj h) + · intro h + change (Sum.inr (Fin.castLE ht i) : Tape max) = .inl (10 : Fin 11) at h + cases h + +theorem shared_ne_wordPlacement_succ {t max : Nat} (ht : t ≤ max) (target : Bool) + (role : Fin 11) (i : Fin t) : + (Sum.inl role : Tape max) ≠ wordPlacement ht target (.inr i.succ) := by + intro h + change (Sum.inl role : Tape max) = .inr (Fin.castLE ht i) at h + cases h + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineTapes + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineVertex.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineVertex.lean new file mode 100644 index 0000000000000000000000000000000000000000..04d414d9cfff7944846c28b45142614cced7bbde --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineVertex.lean @@ -0,0 +1,314 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineRowBody +import OAI.Combinatorics.IndependentSets.Expansion.PoweringTableLayout + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineVertex + +open Turing MachineComposition PCP + +variable {K Λ : Type} [DecidableEq K] {vertices d n : Nat} + +abbrev Command (d n : Nat) := Fin (PoweringTableLayout.blockSize d n) + +def ports {d n : Nat} (j : Command d n) : Fin (n + 1) → Fin d := + ((PoweringEnumeration.dartBlockEquiv d n).symm j).1 + +def direction {d n : Nat} (j : Command d n) : Bool := + ((PoweringEnumeration.dartBlockEquiv d n).symm j).2 + +def commands (d n : Nat) : List (Command d n) := (List.ofFn id).reverse + +@[simp] theorem commands_length (d n : Nat) : + (commands d n).length = PoweringTableLayout.blockSize d n := by + simp only [commands, List.length_reverse, List.length_ofFn] + +abbrev LocalLabel (j : Command d n) := PoweringMachineRowBody.Label n (ports j) (direction j) +abbrev SequenceLabel (ops : List (Command d n)) := MachineFiniteSequence.Label LocalLabel ops +abbrev Label (d n : Nat) := SequenceLabel (commands d n) +abbrev State (d n : Nat) := PoweringMachineRowBody.State d n + +def sequenceEntry (ops : List (Command d n)) (labels : SequenceLabel ops → Λ) + (exit : Option Λ) : Option Λ := + MachineFiniteSequence.entry LocalLabel + (fun j => PoweringMachineRowBody.entry n (ports j) (direction j)) ops labels exit + +def entry (d n : Nat) (labels : Label d n → Λ) (exit : Option Λ) : Option Λ := + sequenceEntry (commands d n) labels exit + +def sequenceInstruction (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (ops : List (Command d n)) (labels : SequenceLabel ops → Λ) + (exit : Option Λ) : SequenceLabel ops → TM2.Stmt (fun _ : K => Bool) Λ (State d n) := + MachineFiniteSequence.instruction LocalLabel + (fun j => PoweringMachineRowBody.entry n (ports j) (direction j)) + (fun j => PoweringMachineRowBody.instruction n placement output (ports j) (direction j)) + ops labels exit + +def instruction (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (labels : Label d n → Λ) (exit : Option Λ) : + Label d n → TM2.Stmt (fun _ : K => Bool) Λ (State d n) := + sequenceInstruction n placement output (commands d n) labels exit + +def result (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (vertex : Fin vertices) (j : Command d n) (base : K → List Bool) : + K → List Bool := + PoweringMachineRowBody.finalTapes graph n placement output vertex (ports j) (direction j) base + +def sequenceTapes (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (vertex : Fin vertices) (ops : List (Command d n)) (base : K → List Bool) : + K → List Bool := + MachineFiniteSequence.resultOf (result graph n placement output vertex) ops base + +def finalTapes (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (vertex : Fin vertices) (base : K → List Bool) : K → List Bool := + sequenceTapes graph n placement output vertex (commands d n) base + +def sequenceSteps (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (vertex : Fin vertices) (ops : List (Command d n)) (base : K → List Bool) : Nat := + MachineFiniteSequence.steps (result graph n placement output vertex) + (fun j _ => PoweringMachineRowBody.steps graph vertex n (ports j) (direction j)) ops base + +def costSum (graph : PortTables.Table vertices d) (vertex : Fin vertices) (n : Nat) : + List (Command d n) → Nat + | [] => 0 + | j :: ops => PoweringMachineRowBody.steps graph vertex n (ports j) (direction j) + + costSum graph vertex n ops + +theorem sequenceSteps_eq (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (vertex : Fin vertices) (ops : List (Command d n)) (base : K → List Bool) : + sequenceSteps graph n placement output vertex ops base = costSum graph vertex n ops := by + induction ops generalizing base with + | nil => rfl + | cons j ops ih => + change PoweringMachineRowBody.steps graph vertex n (ports j) (direction j) + + sequenceSteps graph n placement output vertex ops + (result graph n placement output vertex j base) = _ + rw [ih] + rfl + +def steps (graph : PortTables.Table vertices d) (vertex : Fin vertices) (n : Nat) : Nat := + costSum graph vertex n (commands d n) + +def budget (d n inputLength : Nat) : Nat := + PoweringTableLayout.blockSize d n * PoweringMachineRowBody.budget d n inputLength + +theorem costSum_le (graph : PortTables.Table vertices d) (vertex : Fin vertices) + (n : Nat) (ops : List (Command d n)) : + costSum graph vertex n ops ≤ + ops.length * PoweringMachineRowBody.budget d n (PortTables.tableBits graph).length := by + induction ops with + | nil => simp only [costSum, List.length_nil, Nat.zero_mul, Nat.le_refl] + | cons j ops ih => + have hfirst := PoweringMachineRowBody.steps_le graph vertex n (ports j) (direction j) + change PoweringMachineRowBody.steps graph vertex n (ports j) (direction j) + + costSum graph vertex n ops ≤ _ + simpa only [List.length_cons, Nat.add_mul, Nat.one_mul, Nat.add_comm] using + Nat.add_le_add hfirst ih + +theorem steps_le (graph : PortTables.Table vertices d) (vertex : Fin vertices) (n : Nat) : + steps graph vertex n ≤ budget d n (PortTables.tableBits graph).length := by + simpa only [steps, budget, commands_length] using costSum_le graph vertex n (commands d n) + +theorem sequenceTrace (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (distinct : Function.Injective placement) (output : K) (outside : ∀ i, output ≠ placement i) + (vertex : Fin vertices) (ops : List (Command d n)) + (labels : SequenceLabel ops → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State d n)) + (atLabels : ∀ l, program (labels l) = sequenceInstruction n placement output ops labels exit l) + (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineRowBody.Ready graph n placement vertex suffix base) : + (advance (TM2.step program))^[sequenceSteps graph n placement output vertex ops base] + (some ⟨sequenceEntry ops labels exit, + PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), base⟩) = + some ⟨exit, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + sequenceTapes graph n placement output vertex ops base⟩ := by + apply MachineFiniteSequence.trace LocalLabel + (fun j => PoweringMachineRowBody.entry n (ports j) (direction j)) + (fun j => PoweringMachineRowBody.instruction n placement output (ports j) (direction j)) + (result graph n placement output vertex) + (fun j _ => PoweringMachineRowBody.steps graph vertex n (ports j) (direction j)) + program (PoweringMachineRowBody.Ready graph n placement vertex suffix) + (fun _ => PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n)) id ops + · intro j _ tapes good + exact PoweringMachineRowBody.finalTapes_ready graph n placement distinct output outside + vertex (ports j) (direction j) tapes suffix good + · intro j _ localLabels localExit atLocal tapes good + exact PoweringMachineRowBody.rowTrace graph n placement distinct output outside vertex + (ports j) (direction j) localLabels localExit program atLocal tapes suffix good + · exact atLabels + · exact ready + +theorem vertexTrace (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (distinct : Function.Injective placement) (output : K) (outside : ∀ i, output ≠ placement i) + (vertex : Fin vertices) (labels : Label d n → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State d n)) + (atLabels : ∀ l, program (labels l) = instruction n placement output labels exit l) + (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineRowBody.Ready graph n placement vertex suffix base) : + (advance (TM2.step program))^[steps graph vertex n] + (some ⟨entry d n labels exit, + PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), base⟩) = + some ⟨exit, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + finalTapes graph n placement output vertex base⟩ := by + have h := sequenceTrace graph n placement distinct output outside vertex (commands d n) + labels exit program atLabels base suffix ready + rw [sequenceSteps_eq] at h + exact h + +theorem sequenceTapes_ready (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (distinct : Function.Injective placement) (output : K) (outside : ∀ i, output ≠ placement i) + (vertex : Fin vertices) (ops : List (Command d n)) (base : K → List Bool) + (suffix : List Bool) (ready : PoweringMachineRowBody.Ready graph n placement vertex suffix base) : + PoweringMachineRowBody.Ready graph n placement vertex suffix + (sequenceTapes graph n placement output vertex ops base) := by + induction ops generalizing base with + | nil => exact ready + | cons j ops ih => + apply ih + exact PoweringMachineRowBody.finalTapes_ready graph n placement distinct output outside + vertex (ports j) (direction j) base suffix ready + +theorem finalTapes_ready (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (distinct : Function.Injective placement) (output : K) (outside : ∀ i, output ≠ placement i) + (vertex : Fin vertices) (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineRowBody.Ready graph n placement vertex suffix base) : + PoweringMachineRowBody.Ready graph n placement vertex suffix + (finalTapes graph n placement output vertex base) := + sequenceTapes_ready graph n placement distinct output outside vertex (commands d n) base suffix ready + +theorem sequenceTapes_other (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (vertex : Fin vertices) (ops : List (Command d n)) (base : K → List Bool) + (k : K) (hout : k ≠ output) (outside : ∀ i, k ≠ placement i) : + sequenceTapes graph n placement output vertex ops base k = base k := by + induction ops generalizing base with + | nil => rfl + | cons j ops ih => + change sequenceTapes graph n placement output vertex ops + (result graph n placement output vertex j base) k = _ + rw [ih] + exact PoweringMachineRowBody.finalTapes_other graph n placement output vertex + (ports j) (direction j) base k hout outside + +theorem finalTapes_other (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (output : K) (vertex : Fin vertices) (base : K → List Bool) + (k : K) (hout : k ≠ output) (outside : ∀ i, k ≠ placement i) : + finalTapes graph n placement output vertex base k = base k := + sequenceTapes_other graph n placement output vertex (commands d n) base k hout outside + +def rowBits (graph : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (j : Command d n) : List Bool := + encodeWords (PoweringMachineRowBody.rowWords graph n vertex (ports j) (direction j)) + +theorem blockIndex_eq_encodeDart (n : Nat) (vertex : Fin vertices) (j : Command d n) : + PoweringTableLayout.blockIndex d n vertex j = + PoweringEnumeration.encodeDart vertices d n (direction j, vertex, ports j) := by + have h : PoweringEnumeration.dartBlockEquiv d n (ports j, direction j) = j := + (PoweringEnumeration.dartBlockEquiv d n).apply_symm_apply j + exact (congrArg (PoweringTableLayout.blockIndex d n vertex) h).symm.trans + (PoweringTableLayout.blockIndex_eq_encodeDart d n vertex (ports j) (direction j)) + +theorem rowBits_eq (graph : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) + (j : Command d n) : + rowBits graph n vertex j = encodeWords (GenericGraphTables.rowWords + (PoweringTables.table graph n).rows[PoweringTableLayout.blockIndex d n vertex j]) := by + rw [blockIndex_eq_encodeDart] + rfl + +theorem encodeWords_flatMap {X : Type*} (xs : List X) (f : X → List Nat) : + encodeWords (xs.flatMap f) = xs.flatMap (fun x => encodeWords (f x)) := by + induction xs with + | nil => rfl + | cons x xs ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem rows_eq_vertexRowBits (graph : PortTables.Table vertices d) (n : Nat) + (vertex : Fin vertices) : + (List.ofFn id : List (Command d n)).flatMap (rowBits graph n vertex) = + PoweringTableLayout.vertexRowBits graph n vertex := by + have hrows : (List.ofFn id : List (Command d n)).map + (fun j => (PoweringTables.table graph n).rows[PoweringTableLayout.blockIndex d n vertex j]) = + List.ofFn (fun j : Command d n => + (PoweringTables.table graph n).rows[PoweringTableLayout.blockIndex d n vertex j]) := by + simp only [List.map_ofFn, Function.comp_id] + calc + _ = (List.ofFn id : List (Command d n)).flatMap (fun j => encodeWords + (GenericGraphTables.rowWords + (PoweringTables.table graph n).rows[PoweringTableLayout.blockIndex d n vertex j])) := by + apply congrArg (List.flatMap · (List.ofFn id)) + funext j + exact rowBits_eq graph n vertex j + _ = PoweringTableLayout.vertexRowBits graph n vertex := by + unfold PoweringTableLayout.vertexRowBits PoweringTableLayout.vertexRowWords + PoweringTableLayout.vertexRows + rw [encodeWords_flatMap] + exact (List.flatMap_map + (fun j : Command d n => + (PoweringTables.table graph n).rows[PoweringTableLayout.blockIndex d n vertex j]) + (fun row => encodeWords (GenericGraphTables.rowWords row)) (List.ofFn id)).symm.trans + (congrArg (List.flatMap (fun row => encodeWords (GenericGraphTables.rowWords row))) hrows) + +theorem sequenceTapes_output (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (distinct : Function.Injective placement) (output : K) (outside : ∀ i, output ≠ placement i) + (vertex : Fin vertices) (ops : List (Command d n)) (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineRowBody.Ready graph n placement vertex suffix base) : + sequenceTapes graph n placement output vertex ops base output = + ops.reverse.flatMap (rowBits graph n vertex) ++ base output := by + induction ops generalizing base with + | nil => rfl + | cons j ops ih => + have nextReady := PoweringMachineRowBody.finalTapes_ready graph n placement distinct + output outside vertex (ports j) (direction j) base suffix ready + change sequenceTapes graph n placement output vertex ops + (result graph n placement output vertex j base) output = _ + dsimp only [result] + rw [ih _ nextReady, PoweringMachineRowBody.finalTapes_output graph n placement distinct + output outside vertex (ports j) (direction j) base suffix ready] + simp only [List.reverse_cons, List.flatMap_append, List.flatMap_cons, + List.flatMap_nil, List.append_nil, List.append_assoc, rowBits] + +theorem finalTapes_output (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (distinct : Function.Injective placement) (output : K) (outside : ∀ i, output ≠ placement i) + (vertex : Fin vertices) (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineRowBody.Ready graph n placement vertex suffix base) : + finalTapes graph n placement output vertex base output = + PoweringTableLayout.vertexRowBits graph n vertex ++ base output := by + rw [finalTapes, sequenceTapes_output graph n placement distinct output outside vertex + (commands d n) base suffix ready] + simp only [commands, List.reverse_reverse, rows_eq_vertexRowBits] + +def vertexInTime (graph : PortTables.Table vertices d) (n : Nat) + (placement : PoweringMachineTapes.Tape (PoweringMachineRowBody.capacity n) → K) + (distinct : Function.Injective placement) (output : K) (outside : ∀ i, output ≠ placement i) + (vertex : Fin vertices) (labels : Label d n → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State d n)) + (atLabels : ∀ l, program (labels l) = instruction n placement output labels exit l) + (base : K → List Bool) (suffix : List Bool) + (ready : PoweringMachineRowBody.Ready graph n placement vertex suffix base) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨entry d n labels exit, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), base⟩ + (some ⟨exit, PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), + finalTapes graph n placement output vertex base⟩) + (budget d n (PortTables.tableBits graph).length) where + steps := steps graph vertex n + evals_in_steps := vertexTrace graph n placement distinct output outside vertex labels exit + program atLabels base suffix ready + steps_le_m := steps_le graph vertex n + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineVertex + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineWord.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineWord.lean new file mode 100644 index 0000000000000000000000000000000000000000..411a1ca02017a476f4b2ba27782f5476203cf9a1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringMachineWord.lean @@ -0,0 +1,213 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineRotor + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringMachineWord + +open Turing +open MachineComposition +open PCP + +variable {K Λ σ : Type} [DecidableEq K] +variable {n d : Nat} + +abbrev Alphabet (_ : K) := Bool +abbrev Tape (t : Nat) := Fin 6 ⊕ Fin (t + 1) + +def first (t : Nat) : Fin (t + 1) := ⟨0, by omega⟩ + +def shift (t : Nat) : Tape t → Tape (t + 1) := Sum.map id Fin.succ + +theorem shift_injective (t : Nat) : Function.Injective (shift t) := by + intro a b h + cases a <;> cases b <;> simp_all [shift] + +def rotorRole (t : Nat) (i : Fin 7) : Tape (t + 1) := + if i = 0 then .inl 0 else if i = 1 then .inr (first (t + 1)) else + if i = 2 then .inl 1 else if i = 3 then .inl 2 else + if i = 4 then .inl 3 else if i = 5 then .inr (first t).succ else .inl 4 + +theorem rotorRole_injective (t : Nat) : Function.Injective (rotorRole t) := by + intro a b h + fin_cases a <;> fin_cases b <;> simp_all [rotorRole, first, Fin.ext_iff] + +def Label : Nat → Type + | 0 => MachineUnaryAffineAt.Label + | t + 1 => PoweringMachineRotor.Label ⊕ Label t + +instance labelFintype (t : Nat) : Fintype (Label t) := by + induction t with + | zero => exact inferInstanceAs (Fintype MachineUnaryAffineAt.Label) + | succ t ih => + letI := ih + exact inferInstanceAs (Fintype (PoweringMachineRotor.Label ⊕ Label t)) + +instance labelDecidableEq (t : Nat) : DecidableEq (Label t) := by + induction t with + | zero => exact inferInstanceAs (DecidableEq MachineUnaryAffineAt.Label) + | succ t ih => + letI := ih + exact inferInstanceAs (DecidableEq (PoweringMachineRotor.Label ⊕ Label t)) + +def entry : (t : Nat) → Label t + | 0 => .seed + | _ + 1 => .inl (.reverse .seed) + +def copyInstruction (source scratch output : K) + (labels : MachineUnaryAffineAt.Label → Λ) (exit : Option Λ) : + MachineUnaryAffineAt.Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .seed => MachineUnaryAffineAt.seed output 0 (labels .scan) + | .scan => MachineUnaryAffineAt.scan source scratch output 1 (labels .scan) (labels .restore) + | .restore => Reduction.MachineTransfer.loopAt scratch source id false (labels .restore) exit + +def instruction : (t : Nat) → (Tape t → K) → (Fin t → Fin d) → + (Label t → Λ) → Option Λ → Label t → + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | 0, placement, _, labels, exit => + copyInstruction (placement (.inr (first 0))) (placement (.inl 4)) + (placement (.inl 5)) labels exit + | t + 1, placement, ports, labels, exit => fun l => + match l with + | .inl q => PoweringMachineRotor.instruction (placement ∘ rotorRole t) d (ports 0).val + (fun z => labels (.inl z)) (some (labels (.inr (entry t)))) q + | .inr q => instruction t (placement ∘ shift t) (fun j => ports j.succ) + (fun z => labels (.inr z)) exit q + +def steps (table : PortTables.Table n d) : + (t : Nat) → Fin n → (Fin t → Fin d) → Nat + | 0, vertex, _ => 2 * (vertex.val + 1) + 1 + | t + 1, vertex, ports => PoweringMachineRotor.steps table vertex (ports 0) + + steps table t (PortTables.rotation table (vertex, ports 0)).1 (fun j => ports j.succ) + +def finalTapes (table : PortTables.Table n d) : + (t : Nat) → (Tape t → K) → Fin n → (Fin t → Fin d) → (K → List Bool) → K → List Bool + | 0, placement, vertex, _, base => + Function.update base (placement (.inl 5)) (encodeWord vertex.val ++ base (placement (.inl 5))) + | t + 1, placement, vertex, ports, base => + finalTapes table t (placement ∘ shift t) (PortTables.rotation table (vertex, ports 0)).1 + (fun j => ports j.succ) + (PoweringMachineRotor.finalTapes (placement ∘ rotorRole t) table vertex (ports 0) base) + +theorem finalTapes_other (table : PortTables.Table n d) (t : Nat) + (placement : Tape t → K) (vertex : Fin n) (ports : Fin t → Fin d) + (base : K → List Bool) (k : K) + (hquery : k ≠ placement (.inl 1)) (hscan : k ≠ placement (.inl 2)) + (hreverse : k ≠ placement (.inl 3)) (houtput : k ≠ placement (.inl 5)) + (hpositions : ∀ i : Fin t, k ≠ placement (.inr i.succ)) : + finalTapes table t placement vertex ports base k = base k := by + induction t generalizing vertex base with + | zero => simp only [finalTapes, Function.update_of_ne houtput] + | succ t ih => + let mid := PoweringMachineRotor.finalTapes (placement ∘ rotorRole t) table vertex (ports 0) base + calc + finalTapes table (t + 1) placement vertex ports base k = mid k := + ih (placement ∘ shift t) (PortTables.rotation table (vertex, ports 0)).1 + (fun j => ports j.succ) mid hquery hscan hreverse houtput + (fun i => hpositions i.succ) + _ = base k := PoweringMachineRotor.finalTapes_other _ _ _ _ _ k + hquery hscan hreverse (hpositions (first t)) + +theorem wordTrace (table : PortTables.Table n d) (t : Nat) + (placement : Tape t → K) (distinct : Function.Injective placement) + (vertex : Fin n) (ports : Fin t → Fin d) + (labels : Label t → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ l, program (labels l) = instruction t placement ports labels exit l) + (base : K → List Bool) (tableWord : base (placement (.inl 0)) = PortTables.tableBits table) + (scratchEmpty : base (placement (.inl 4)) = []) (suffix : List Bool) + (sourceWord : base (placement (.inr (first t))) = encodeWord vertex.val ++ suffix) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step program))^[steps table t vertex ports] + (some ⟨some (labels (entry t)), (ambient,register), base⟩) = + some ⟨exit, (ambient,none), finalTapes table t placement vertex ports base⟩ ∧ + finalTapes table t placement vertex ports base (placement (.inl 5)) = + encodeWord (PoweringWalks.wordEnd (PortTables.portGraph table) t vertex ports).val ++ + base (placement (.inl 5)) := by + induction t generalizing vertex base suffix register with + | zero => + have hd (i j : Tape 0) (hne : i ≠ j) : placement i ≠ placement j := fun h => hne (distinct h) + have hrun := MachineUnaryAffineAt.seededAffineTrace + (placement (.inr (first 0))) (placement (.inl 4)) (placement (.inl 5)) + (hd _ _ (by simp [first])) (hd _ _ (by simp [first])) (hd _ _ (by simp)) + 1 0 (labels .seed) (labels .scan) (labels .restore) exit program + (atLabels .seed) (atLabels .scan) (atLabels .restore) + base vertex.val suffix sourceWord scratchEmpty ambient register + constructor + · simpa only [steps, entry, finalTapes, Nat.one_mul, Nat.add_zero] using hrun + · simp only [finalTapes, Function.update_self, PoweringWalks.wordEnd] + | succ t ih => + have hd (i j : Tape (t + 1)) (hne : i ≠ j) : placement i ≠ placement j := + fun h => hne (distinct h) + have hrotor := PoweringMachineRotor.rotorTrace (placement ∘ rotorRole t) + (distinct.comp (rotorRole_injective t)) (fun q => labels (.inl q)) + (some (labels (.inr (entry t)))) program (ports 0) (fun q => atLabels (.inl q)) + table vertex base tableWord scratchEmpty suffix sourceWord ambient register + let mid := PoweringMachineRotor.finalTapes (placement ∘ rotorRole t) table vertex (ports 0) base + have hmidTable : mid (placement (.inl 0)) = PortTables.tableBits table := by + calc + mid (placement (.inl 0)) = base (placement (.inl 0)) := + PoweringMachineRotor.finalTapes_other _ _ _ _ _ _ + (hd _ _ (by simp [rotorRole])) (hd _ _ (by simp [rotorRole])) + (hd _ _ (by simp [rotorRole])) (hd _ _ (by simp [rotorRole, first])) + _ = _ := tableWord + have hmidScratch : mid (placement (.inl 4)) = [] := by + calc + mid (placement (.inl 4)) = base (placement (.inl 4)) := + PoweringMachineRotor.finalTapes_other _ _ _ _ _ _ + (hd _ _ (by simp [rotorRole])) (hd _ _ (by simp [rotorRole])) + (hd _ _ (by simp [rotorRole])) (hd _ _ (by simp [rotorRole, first])) + _ = _ := scratchEmpty + have hmidOutput : mid (placement (.inl 5)) = base (placement (.inl 5)) := + PoweringMachineRotor.finalTapes_other _ _ _ _ _ _ + (hd _ _ (by simp [rotorRole])) (hd _ _ (by simp [rotorRole])) + (hd _ _ (by simp [rotorRole])) (hd _ _ (by simp [rotorRole, first])) + have hmidSource : mid (placement (.inr (first t).succ)) = + encodeWord (PortTables.rotation table (vertex, ports 0)).1.val ++ + base (placement (.inr (first t).succ)) := + PoweringMachineRotor.finalTapes_endpoint _ (distinct.comp (rotorRole_injective t)) _ _ _ _ + have htail := ih (placement ∘ shift t) (distinct.comp (shift_injective t)) + (PortTables.rotation table (vertex, ports 0)).1 (fun j => ports j.succ) + (fun q => labels (.inr q)) (fun q => atLabels (.inr q)) mid hmidTable hmidScratch + (base (placement (.inr (first t).succ))) hmidSource none + constructor + · rw [steps, Nat.add_comm, Function.iterate_add_apply] + simp only [entry] + rw [hrotor] + exact htail.1 + · change finalTapes table t (placement ∘ shift t) + (PortTables.rotation table (vertex, ports 0)).1 (fun j => ports j.succ) mid + ((placement ∘ shift t) (.inl 5)) = _ + rw [htail.2] + change _ ++ mid (placement (.inl 5)) = _ + rw [hmidOutput] + rfl + +theorem steps_le (table : PortTables.Table n d) (t : Nat) + (vertex : Fin n) (ports : Fin t → Fin d) : + steps table t vertex ports ≤ (14 * t + 2) * (PortTables.tableBits table).length + 12 * t + 3 := by + induction t generalizing vertex with + | zero => + have h := Nat.le_trans (Nat.le_of_lt vertex.isLt) (PortTables.vertices_le_tableBits_length table) + simp only [steps, Nat.mul_zero, Nat.zero_add] + omega + | succ t ih => + have hr := PoweringMachineRotor.steps_le table vertex (ports 0) + have ht := ih (PortTables.rotation table (vertex, ports 0)).1 (fun j => ports j.succ) + simp only [steps, Nat.mul_add, Nat.add_mul, Nat.mul_one, Nat.mul_assoc] at ht ⊢ + omega + +def machine (degree t : Nat) (ports : Fin t → Fin degree) : FinTM2 where + K := Tape t + k₀ := .inl 0 + k₁ := .inl 5 + Γ _ := Bool + Λ := Label t + main := entry t + σ := Unit × Option Bool + initialState := ((),none) + m := instruction t id ports id none + +end IndependentSetsGames.Foundations.Complexity.PoweringMachineWord + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringRuntimeBudget.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringRuntimeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..f88ad24135b88d932d88a6e57c7c1eaf4158b91a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PoweringRuntimeBudget.lean @@ -0,0 +1,61 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.PoweringMachineGlobal + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.PoweringRuntimeBudget + +open Turing + +theorem stackLength_le_of_execution (tm : FinTM2) (start finish : tm.Cfg) + (initialBound priorBudget : Nat) + (initial : ∀ k, (start.stk k).length ≤ initialBound) + (prior : StateTransition.EvalsToInTime tm.step start (some finish) priorBudget) + (k : tm.K) : + (finish.stk k).length ≤ initialBound + priorBudget * Runtime.programPushBound tm := by + have grown := Runtime.executionSizeBound tm.step (fun cfg => (cfg.stk k).length) + (Runtime.programPushBound tm) (Runtime.stepStackLength tm k) prior + exact grown.trans (Nat.add_le_add_right (initial k) _) + +theorem stackLength_le_from_input (tm : FinTM2) (input : List (tm.Γ tm.k₀)) + (finish : tm.Cfg) (priorBudget : Nat) + (prior : StateTransition.EvalsToInTime tm.step (initList tm input) + (some finish) priorBudget) (k : tm.K) : + (finish.stk k).length ≤ input.length + priorBudget * Runtime.programPushBound tm := + stackLength_le_of_execution tm (initList tm input) finish input.length priorBudget + (Runtime.initialStackLength tm input) prior k + +abbrev tapeCount (radius : Nat) : Nat := + 4 + (11 + PoweringMachineRowBody.capacity radius + 1) + +theorem finish_steps_le_of_execution (d radius : Nat) (input : List Bool) + (before : (PoweringMachineGlobal.machine d radius).Cfg) + (priorBudget vertices darts : Nat) + (prior : StateTransition.EvalsToInTime (PoweringMachineGlobal.machine d radius).step + (initList (PoweringMachineGlobal.machine d radius) input) (some before) priorBudget) : + PoweringMachineFinish.steps (PoweringMachineGlobal.enumeration radius) + (PoweringMachineGlobal.outputTape radius) before.stk vertices darts ≤ + 2 * (vertices + darts) + 6 + tapeCount radius * + (input.length + priorBudget * Runtime.programPushBound + (PoweringMachineGlobal.machine d radius) + vertices + darts + 3) := by + exact PoweringMachineFinish.steps_le_uniform (PoweringMachineGlobal.enumeration radius) + (PoweringMachineGlobal.outputTape radius) before.stk vertices darts + (input.length + priorBudget * Runtime.programPushBound (PoweringMachineGlobal.machine d radius)) + (stackLength_le_from_input (PoweringMachineGlobal.machine d radius) input before priorBudget prior) + +theorem total_steps_le_of_execution (d radius : Nat) (input : List Bool) + (before : (PoweringMachineGlobal.machine d radius).Cfg) + (priorBudget vertices darts : Nat) + (prior : StateTransition.EvalsToInTime (PoweringMachineGlobal.machine d radius).step + (initList (PoweringMachineGlobal.machine d radius) input) (some before) priorBudget) : + prior.steps + PoweringMachineFinish.steps (PoweringMachineGlobal.enumeration radius) + (PoweringMachineGlobal.outputTape radius) before.stk vertices darts ≤ + priorBudget + (2 * (vertices + darts) + 6 + tapeCount radius * + (input.length + priorBudget * Runtime.programPushBound + (PoweringMachineGlobal.machine d radius) + vertices + darts + 3)) := + Nat.add_le_add prior.steps_le_m + (finish_steps_le_of_execution d radius input before priorBudget vertices darts prior) + +end IndependentSetsGames.Foundations.Complexity.PoweringRuntimeBudget + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Printer.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Printer.lean new file mode 100644 index 0000000000000000000000000000000000000000..55ae1fad8c8dfbbb86405a1fcd0b035f1b1552cf --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Printer.lean @@ -0,0 +1,205 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.ValuePolynomial +import OAI.Combinatorics.IndependentSets.Machines.Restrict + +namespace OAI + +namespace IndependentSetsCut.CounterMachine +open Turing Polynomial Command + +def printer (len bit : Expr) : Command ℕ := .seq (print len bit) eraseInput + +noncomputable def printerTime (len bit : Expr) : Polynomial ℕ := + len.timePolynomial+len.valuePolynomial* + (bit.timePolynomial.comp (X+len.valuePolynomial)+ + 2*bit.valuePolynomial.comp (X+len.valuePolynomial)+4)+1+7*X+8 + + theorem printer_evaluates (len bit : Expr) (input : List Bool) : + Within (printer len bit) (initial input) + ⟨fun _ => 0, [], [], table len bit input⟩ ((printerTime len bit).eval input.length-1) := by + have hp := print_evaluates len bit input + have he := eraseInput_evaluates {initial input with output := table len bit input} + (by intro r hr; rfl) rfl + have h := hp.seq he + apply h.mono + simp only [printerTime, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, + Polynomial.eval_X, Polynomial.eval_one, Polynomial.eval_comp, Expr.timePolynomial_eval, Expr.valuePolynomial_eval] + + simp only [initial] at * + omega + + theorem halted_eq {R : Type} [DecidableEq R] [Fintype R] (c : Command R) (out : List Bool) : + embed (⟨⟨fun _ => 0, [], [], out⟩, none⟩ : Configuration R c.FinalLabel) = + haltList c.finiteMachine out := by + unfold embed haltList + congr 1 + funext k + cases k <;> simp [tapes, finiteMachine, machine] + rfl + +noncomputable def tableComputer (len bit : Expr) : + TM2ComputableInPolyTime (id : List Bool → List Bool) id (table len bit) where + tm := (printer len bit).finite.finiteMachine + inputAlphabet := Equiv.refl _ + outputAlphabet := Equiv.refl _ + time := printerTime len bit + outputsFun input := by + let h := printer_evaluates len bit input + let n := Classical.choose h + have hn := Classical.choose_spec h + have he := Command.finite_evaluates hn.2 + change Evaluates _ (initial input) ⟨fun _ => 0, [], [], table len bit input⟩ n at he + have run := machine_run he + have hout := halted_eq (printer len bit).finite (table len bit input) + have run' : StateTransition.EvalsToInTime (printer len bit).finite.finiteMachine.step + (initList (printer len bit).finite.finiteMachine input) + (some (haltList (printer len bit).finite.finiteMachine (table len bit input))) (n+1) := by + convert run using 1 + congr 1 + unfold haltList embed + congr 1 + funext k + cases k <;> simp [tapes, finiteMachine, machine] + rfl + let run := run' + refine ⟨⟨run.steps, ?_⟩, ?_⟩ + · change (flip Option.bind (printer len bit).finite.finiteMachine.step)^[run.steps] + (some (initList (printer len bit).finite.finiteMachine (input.map (id : Bool → Bool)))) = + some (haltList (printer len bit).finite.finiteMachine ((table len bit input).map (id : Bool → Bool))) + erw [List.map_id, List.map_id] + exact run.evals_in_steps + · have hs := run.steps_le_m + have hb := hn.1 + have hp : 0 < (printerTime len bit).eval input.length := by + simp only [printerTime, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, + Polynomial.eval_X, Polynomial.eval_one, Polynomial.eval_comp, Expr.timePolynomial_eval, Expr.valuePolynomial_eval] + omega + change run.steps ≤ (printerTime len bit).eval input.length + omega + + theorem tableComputer_finiteAlphabet (len bit : Expr) (k : (tableComputer len bit).tm.K) : + Finite ((tableComputer len bit).tm.Γ k) := inferInstanceAs (Finite Bool) + +end IndependentSetsCut.CounterMachine + +namespace IndependentSetsCut.CounterMachine.Expr +open scoped BigOperators +open Finset + +def rename (ρ : ℕ → ℕ) : Expr → Expr + | .const n => .const n + | .arg i => .arg (ρ i) + | .length => .length + | .bit e => .bit (rename ρ e) + | .add a b => .add (rename ρ a) (rename ρ b) + | .sub a b => .sub (rename ρ a) (rename ρ b) + | .mul a b => .mul (rename ρ a) (rename ρ b) + | .zero a => .zero (rename ρ a) + | .sum b f => .sum (rename ρ b) (rename (bind (fun i => ρ i+1) 0) f) + +@[simp] theorem rename_eval (e : Expr) (ρ : ℕ → ℕ) (input : List Bool) (args : ℕ → ℕ) : + (e.rename ρ).eval input args = e.eval input (fun i => args (ρ i)) := by + induction e generalizing ρ args <;> simp only [rename, eval] at * + all_goals try simp_all + case sum b f ib iF => + apply sum_congr rfl + intro i hi + congr 1 + funext j + cases j <;> rfl + +def bindExpr (σ : ℕ → Expr) (e : Expr) : ℕ → Expr + | 0 => e + | i+1 => σ i + +def subst (σ : ℕ → Expr) : Expr → Expr + | .const n => .const n + | .arg i => σ i + | .length => .length + | .bit e => .bit (subst σ e) + | .add a b => .add (subst σ a) (subst σ b) + | .sub a b => .sub (subst σ a) (subst σ b) + | .mul a b => .mul (subst σ a) (subst σ b) + | .zero a => .zero (subst σ a) + | .sum b f => .sum (subst σ b) (subst (bindExpr (fun i => (σ i).rename Nat.succ) (.arg 0)) f) + +@[simp] theorem subst_eval (e : Expr) (σ : ℕ → Expr) (input : List Bool) (args : ℕ → ℕ) : + (e.subst σ).eval input args = e.eval input (fun i => (σ i).eval input args) := by + induction e generalizing σ args <;> simp only [subst, eval] at * + all_goals try simp_all + case sum b f ib iF => + apply sum_congr rfl + intro i hi + congr 1 + funext j + cases j with + | zero => rfl + | succ j => simp [bindExpr, bind] + +def positive (a : Expr) : Expr := .zero (.zero a) +def equal (a b : Expr) : Expr := .zero (.add (.sub a b) (.sub b a)) +def le (a b : Expr) : Expr := .zero (.sub a b) +def lt (a b : Expr) : Expr := le (.add a (.const 1)) b + +@[simp] theorem positive_eval (a : Expr) (input : List Bool) (args : ℕ → ℕ) : + (positive a).eval input args = if a.eval input args ≠ 0 then 1 else 0 := by + simp [positive, eval] + +@[simp] theorem equal_eval (a b : Expr) (input : List Bool) (args : ℕ → ℕ) : + (equal a b).eval input args = if a.eval input args = b.eval input args then 1 else 0 := by + by_cases h : a.eval input args = b.eval input args + · simp only [equal, eval, h, Nat.sub_self, Nat.zero_add, ↓reduceIte] + · have hn : a.eval input args-b.eval input args+(b.eval input args-a.eval input args) ≠ 0 := by omega + simp only [equal, eval, h, hn, ↓reduceIte] + +@[simp] theorem le_eval (a b : Expr) (input : List Bool) (args : ℕ → ℕ) : + (le a b).eval input args = if a.eval input args ≤ b.eval input args then 1 else 0 := by + simp [le, eval, Nat.sub_eq_zero_iff_le] + +@[simp] theorem lt_eval (a b : Expr) (input : List Bool) (args : ℕ → ℕ) : + (lt a b).eval input args = if a.eval input args < b.eval input args then 1 else 0 := by + simp [lt, eval] + +def cond (c a b : Expr) : Expr := .add (.mul (positive c) a) (.mul (.zero c) b) +@[simp] theorem cond_eval (c a b : Expr) (input : List Bool) (args : ℕ → ℕ) : + (cond c a b).eval input args = if c.eval input args ≠ 0 then a.eval input args else b.eval input args := by + simp only [cond, eval, positive_eval]; split_ifs <;> simp_all + +def quotient (a b : Expr) : Expr := + .mul (positive b) (.sum a (le (.mul (.add (.arg 0) (.const 1)) (b.rename Nat.succ)) (a.rename Nat.succ))) + + theorem quotient_sum (a b : ℕ) (hb : 0 < b) : + (∑ i ∈ range a, if (i+1)*b ≤ a then (1:ℕ) else 0) = a/b := by + have hcond (i : ℕ) : (i+1)*b ≤ a ↔ i < a/b := by + rw [← Nat.le_div_iff_mul_le hb, Nat.add_one_le_iff] + simp_rw [hcond] + rw [sum_boole] + have hs : {i ∈ range a | i < a/b} = range (a/b) := by + ext i; simp only [mem_filter, mem_range] + exact and_iff_right_of_imp (fun hi => hi.trans_le (Nat.div_le_self _ _)) + simp only [hs, card_range, Nat.cast_id] + +@[simp] theorem quotient_eval (a b : Expr) (input : List Bool) (args : ℕ → ℕ) : + (quotient a b).eval input args = a.eval input args / b.eval input args := by + simp only [quotient, eval, positive_eval, le_eval, rename_eval, bind] + by_cases hb : b.eval input args = 0 + · simp [hb] + · simp only [hb, ne_eq, not_false_eq_true, ↓reduceIte, one_mul] + simpa using quotient_sum (a.eval input args) (b.eval input args) (by omega) + +def remainder (a b : Expr) : Expr := .sub a (.mul (quotient a b) b) +@[simp] theorem remainder_eval (a b : Expr) (input : List Bool) (args : ℕ → ℕ) : + (remainder a b).eval input args = a.eval input args % b.eval input args := by + simp only [remainder, eval, quotient_eval] + exact Nat.mod_eq_sub_div_mul.symm + +def power (a : Expr) : ℕ → Expr + | 0 => .const 1 + | n+1 => .mul (power a n) a +@[simp] theorem power_eval (a : Expr) (n : ℕ) (input : List Bool) (args : ℕ → ℕ) : + (power a n).eval input args = (a.eval input args)^n := by + induction n <;> simp [power, eval, pow_succ, *] + +end IndependentSetsCut.CounterMachine.Expr + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/ProfileMachine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/ProfileMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..a51f24cf616cef63346427897296aac530bcb22e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/ProfileMachine.lean @@ -0,0 +1,249 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFieldProfile + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineFieldProfile +open Turing + +def setEntry {q : Nat} (profile : Profile q) (pair : Fin q × Fin q) (bit : Bool) : Profile q := + Function.update profile pair.1 (Function.update (profile pair.1) pair.2 bit) + +theorem setEntry_apply {q : Nat} (profile : Profile q) (pair : Fin q × Fin q) + (bit : Bool) (i j : Fin q) : + setEntry profile pair bit i j = if (i, j) = pair then bit else profile i j := by + rcases pair with ⟨a, b⟩ + by_cases hi : i = a <;> by_cases hj : j = b <;> simp [setEntry, hi, hj] + +def setExpected {q : Nat} (words : Fin q → List Bool) (profile : Profile q) + (pair : Fin q × Fin q) : Profile q := + setEntry profile pair (equalityProfile words pair.1 pair.2) + +def foldProfile {q : Nat} (words : Fin q → List Bool) (initial : Profile q) + (cells : List (Fin q × Fin q)) : Profile q := cells.foldl (setExpected words) initial + +theorem foldProfile_apply {q : Nat} (words : Fin q → List Bool) (initial : Profile q) + (cells : List (Fin q × Fin q)) (i j : Fin q) : + foldProfile words initial cells i j = + if (i, j) ∈ cells then equalityProfile words i j else initial i j := by + induction cells generalizing initial with + | nil => rfl + | cons pair rest ih => + change foldProfile words (setExpected words initial pair) rest i j = _ + rw [ih] + by_cases hrest : (i, j) ∈ rest + · simp [hrest] + · by_cases hpair : (i, j) = pair + · subst pair + simp [hrest, setExpected, setEntry_apply] + · simp [hrest, hpair, setExpected, setEntry_apply] + +abbrev Tape (q : Nat) := Fin q ⊕ Fin 3 +abbrev Label {q : Nat} (cells : List (Fin q × Fin q)) := Fin (cells.length + 1) × Fin 7 + +def labelAt {q : Nat} (cells : List (Fin q × Fin q)) (r : Nat) (phase : Fin 7) : Label cells := + (⟨min r cells.length, by omega⟩, phase) + +def storePair {q : Nat} (pair : Fin q × Fin q) (bit : Bool) + {Λ : Type} (nextLabel : Λ) : + TM2.Stmt (fun _ : Tape q => Bool) Λ (MachineCompare.State (Profile q)) := + .load (fun state => normalState (setEntry state.1 pair bit)) (.goto fun _ => nextLabel) + +def profileProgram {q : Nat} (cells : List (Fin q × Fin q)) (label : Label cells) : + TM2.Stmt (fun _ : Tape q => Bool) (Label cells) (MachineCompare.State (Profile q)) := + if h : label.1.val < cells.length then + let pair := cells[label.1.val] + let r := label.1.val + match label.2.val with + | 0 => copyStatement (Reduction.MachineTransfer.loopAt (.inl pair.1) (.inr 2) id false + (labelAt cells r 0) (some (labelAt cells r 1))) + | 1 => copyStatement (MachineCopy.forkLoop (.inr 2) (.inl pair.1) (.inr 0) false + (labelAt cells r 1) (some (labelAt cells r 2))) + | 2 => copyStatement (Reduction.MachineTransfer.loopAt (.inl pair.2) (.inr 2) id false + (labelAt cells r 2) (some (labelAt cells r 3))) + | 3 => copyStatement (MachineCopy.forkLoop (.inr 2) (.inl pair.2) (.inr 1) false + (labelAt cells r 3) (some (labelAt cells r 4))) + | 4 => MachineCompare.loop (.inr 0) (.inr 1) (labelAt cells r 4) + (some (labelAt cells r 5)) (some (labelAt cells r 6)) + | 5 => storePair pair true (labelAt cells (r + 1) 0) + | _ => storePair pair false (labelAt cells (r + 1) 0) + else .halt + +def pairTime {q : Nat} (words : Fin q → List Bool) (pair : Fin q × Fin q) : Nat := + 2 * ((words pair.1).length + 1) + 2 * ((words pair.2).length + 1) + + max (words pair.1).length (words pair.2).length + 2 + +def prefixProfile {q : Nat} (words : Fin q → List Bool) (initial : Profile q) + (cells : List (Fin q × Fin q)) (r : Nat) : Profile q := + foldProfile words initial (cells.take r) + +def prefixTime {q : Nat} (words : Fin q → List Bool) + (cells : List (Fin q × Fin q)) (r : Nat) : Nat := + ((cells.take r).map (pairTime words)).sum + +theorem prefixProfile_succ {q : Nat} (words : Fin q → List Bool) (initial : Profile q) + (cells : List (Fin q × Fin q)) (r : Nat) (hr : r < cells.length) : + prefixProfile words initial cells (r + 1) = + setExpected words (prefixProfile words initial cells r) cells[r] := by + unfold prefixProfile foldProfile + rw [List.take_succ_eq_append_getElem hr, List.foldl_append] + rfl + +theorem prefixTime_succ {q : Nat} (words : Fin q → List Bool) + (cells : List (Fin q × Fin q)) (r : Nat) (hr : r < cells.length) : + prefixTime words cells (r + 1) = prefixTime words cells r + pairTime words cells[r] := by + unfold prefixTime + rw [List.take_succ_eq_append_getElem hr, List.map_append, List.sum_append] + rfl + +def stageInTime {q : Nat} (cells : List (Fin q × Fin q)) (r : Nat) (hr : r < cells.length) + (base : Tape q → List Bool) (hwork : ∀ w : Fin 3, base (.inr w) = []) (profile : Profile q) : + StateTransition.EvalsToInTime (TM2.step (profileProgram cells)) + ⟨some (labelAt cells r 0), normalState profile, base⟩ + (some ⟨some (labelAt cells (r + 1) 0), + normalState (setExpected (fun i => base (.inl i)) profile cells[r]), base⟩) + (pairTime (fun i => base (.inl i)) cells[r]) := by + let pair := cells[r] + have copied := nonDestructiveCompareInTime (.inl pair.1) (.inl pair.2) + (.inr 0 : Tape q) (.inr 1) (.inr 2) (by simp) (by simp) (by simp) + (labelAt cells r 0) (labelAt cells r 1) (labelAt cells r 2) (labelAt cells r 3) + (labelAt cells r 4) (some (labelAt cells r 5)) (some (labelAt cells r 6)) + (profileProgram cells) + (by simp [profileProgram, labelAt, Nat.min_eq_left hr.le, hr, pair]) + (by simp [profileProgram, labelAt, Nat.min_eq_left hr.le, hr, pair]) + (by simp [profileProgram, labelAt, Nat.min_eq_left hr.le, hr, pair]) + (by simp [profileProgram, labelAt, Nat.min_eq_left hr.le, hr, pair]) + (by simp [profileProgram, labelAt, Nat.min_eq_left hr.le, hr]) + base (hwork 0) (hwork 1) (hwork 2) profile + have stored : StateTransition.EvalsToInTime (TM2.step (profileProgram cells)) + ⟨if base (.inl pair.1) = base (.inl pair.2) then some (labelAt cells r 5) + else some (labelAt cells r 6), normalState profile, base⟩ + (some ⟨some (labelAt cells (r + 1) 0), + normalState (setExpected (fun i => base (.inl i)) profile pair), base⟩) 1 := { + steps := 1 + evals_in_steps := by + change TM2.step (profileProgram cells) + ⟨if base (.inl pair.1) = base (.inl pair.2) then some (labelAt cells r 5) + else some (labelAt cells r 6), normalState profile, base⟩ = _ + by_cases heq : base (.inl pair.1) = base (.inl pair.2) + · simp [heq, TM2.step, profileProgram, labelAt, + Nat.min_eq_left hr.le, hr, storePair, TM2.stepAux, normalState, + setExpected, equalityProfile, pair] + · simp [heq, TM2.step, profileProgram, labelAt, + Nat.min_eq_left hr.le, hr, storePair, TM2.stepAux, normalState, + setExpected, equalityProfile, pair] + steps_le_m := Nat.le_refl _ + } + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ copied stored + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have h := run.steps_le_m + dsimp only [pair] at h + dsimp only [pairTime] + omega + +def prefixInTime {q : Nat} (cells : List (Fin q × Fin q)) + (base : Tape q → List Bool) (hwork : ∀ w : Fin 3, base (.inr w) = []) (initial : Profile q) + (r : Nat) (hr : r ≤ cells.length) : + StateTransition.EvalsToInTime (TM2.step (profileProgram cells)) + ⟨some (labelAt cells 0 0), normalState initial, base⟩ + (some ⟨some (labelAt cells r 0), + normalState (prefixProfile (fun i => base (.inl i)) initial cells r), base⟩) + (prefixTime (fun i => base (.inl i)) cells r) := by + induction r with + | zero => + exact { steps := 0, evals_in_steps := rfl, steps_le_m := Nat.le_refl _ } + | succ r ih => + have hrl : r < cells.length := by omega + let first := ih (by omega) + let second := stageInTime cells r hrl base hwork + (prefixProfile (fun i => base (.inl i)) initial cells r) + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first second + rw [prefixProfile_succ _ _ _ _ hrl, prefixTime_succ _ _ _ hrl] + exact { toEvalsTo := run.toEvalsTo, steps_le_m := by have h := run.steps_le_m; omega } + +def allPairs (q : Nat) : List (Fin q × Fin q) := + (List.finRange q).flatMap fun i => (List.finRange q).map fun j => (i, j) + +theorem mem_allPairs {q : Nat} (i j : Fin q) : (i, j) ∈ allPairs q := by + simp [allPairs] + +theorem length_allPairs (q : Nat) : (allPairs q).length = q * q := by + simp [allPairs, List.length_flatMap] + +theorem foldProfile_allPairs {q : Nat} (words : Fin q → List Bool) (initial : Profile q) : + foldProfile words initial (allPairs q) = equalityProfile words := by + funext i j + simp [foldProfile_apply, mem_allPairs] + +def profileMachine (q : Nat) : FinTM2 where + K := Tape q + k₀ := .inr 0 + k₁ := .inr 0 + Γ _ := Bool + Λ := Label (allPairs q) + main := labelAt (allPairs q) 0 0 + σ := MachineCompare.State (Profile q) + initialState := normalState (fun _ _ => false) + m := profileProgram (allPairs q) + +def profileInTime (q : Nat) (base : Tape q → List Bool) + (hwork : ∀ w : Fin 3, base (.inr w) = []) (initial : Profile q) : + StateTransition.EvalsToInTime (profileMachine q).step + ⟨some (labelAt (allPairs q) 0 0), normalState initial, base⟩ + (some ⟨none, normalState (equalityProfile (fun i => base (.inl i))), base⟩) + (((allPairs q).map (pairTime (fun i => base (.inl i)))).sum + 1) := by + let cells := allPairs q + have first := prefixInTime cells base hwork initial cells.length (Nat.le_refl _) + have last : StateTransition.EvalsToInTime (TM2.step (profileProgram cells)) + ⟨some (labelAt cells cells.length 0), + normalState (prefixProfile (fun i => base (.inl i)) initial cells cells.length), base⟩ + (some ⟨none, normalState (equalityProfile (fun i => base (.inl i))), base⟩) 1 := { + steps := 1 + evals_in_steps := by + change TM2.step (profileProgram cells) + ⟨some (labelAt cells cells.length 0), + normalState (prefixProfile (fun i => base (.inl i)) initial cells cells.length), base⟩ = _ + simp [TM2.step, profileProgram, labelAt, TM2.stepAux, + prefixProfile, cells, foldProfile_allPairs] + steps_le_m := Nat.le_refl _ + } + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first last + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have h := run.steps_le_m + simpa [prefixTime, cells, Nat.add_comm] using h + +theorem pairTime_le {q : Nat} (words : Fin q → List Bool) (L : Nat) + (hL : ∀ i, (words i).length ≤ L) (pair : Fin q × Fin q) : + pairTime words pair ≤ 5 * L + 6 := by + have hi := hL pair.1 + have hj := hL pair.2 + have hm := max_le hi hj + dsimp only [pairTime] + omega + +theorem totalTime_le {q : Nat} (words : Fin q → List Bool) (L : Nat) + (hL : ∀ i, (words i).length ≤ L) (cells : List (Fin q × Fin q)) : + (cells.map (pairTime words)).sum ≤ cells.length * (5 * L + 6) := by + induction cells with + | nil => simp + | cons pair rest ih => + have hp := pairTime_le words L hL pair + simp only [List.map_cons, List.sum_cons, List.length_cons, Nat.add_mul, Nat.one_mul] + omega + +def profileInTime_bounded (q : Nat) (base : Tape q → List Bool) + (hwork : ∀ w : Fin 3, base (.inr w) = []) (initial : Profile q) + (L : Nat) (hL : ∀ i, (base (.inl i)).length ≤ L) : + StateTransition.EvalsToInTime (profileMachine q).step + ⟨some (labelAt (allPairs q) 0 0), normalState initial, base⟩ + (some ⟨none, normalState (equalityProfile (fun i => base (.inl i))), base⟩) + (q * q * (5 * L + 6) + 1) := by + let run := profileInTime q base hwork initial + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + apply run.steps_le_m.trans + apply Nat.add_le_add_right + simpa only [length_allPairs] using totalTime_le (fun i => base (.inl i)) L hL (allPairs q) + +end IndependentSetsGames.Foundations.Complexity.MachineFieldProfile + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/PushWord.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/PushWord.lean new file mode 100644 index 0000000000000000000000000000000000000000..831ff4097c2853566c73711c1e2edf08a2c6a911 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/PushWord.lean @@ -0,0 +1,222 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.PatternInvariant +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget + +namespace OAI + +namespace IndependentSetsGames.Reduction.MachineSubstitution + +open Turing + +open IndependentSetsGames.Foundations.Complexity + +section PushWord + +variable {K Λ σ : Type} {Γ : K → Type} [DecidableEq K] + +def pushWord (dst : K) : List (Γ dst) → TM2.Stmt Γ Λ σ → TM2.Stmt Γ Λ σ + | [], continuation => continuation + | symbol :: word, continuation => + .push dst (fun _ => symbol) (pushWord dst word continuation) + +theorem stepAux_pushWord (dst : K) (word : List (Γ dst)) + (continuation : TM2.Stmt Γ Λ σ) (state : σ) (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (pushWord dst word continuation) state tapes = + TM2.stepAux continuation state + (Function.update tapes dst (word.reverse ++ tapes dst)) := by + induction word generalizing tapes with + | nil => simp [pushWord] + | cons symbol word ih => + simp only [pushWord, TM2.stepAux] + rw [ih] + simp only [Function.update_self, Function.update_idem, List.reverse_cons, + List.append_assoc, List.singleton_append] + +omit [DecidableEq K] in +theorem statementPushBound_pushWord (dst : K) (word : List (Γ dst)) + (continuation : TM2.Stmt Γ Λ σ) : + Runtime.statementPushBound (pushWord dst word continuation) = + word.length + Runtime.statementPushBound continuation := by + induction word with + | nil => simp [pushWord] + | cons symbol word ih => + simp only [pushWord, Runtime.statementPushBound, ih, List.length_cons] + omega + +end PushWord + +def loop : TM2.Stmt (fun _ : Bool => Bool) (Option Bool) (Option Bool) := + .pop false (fun _ head => head) + (.branch Option.isSome + (.goto fun state => some (state.getD false)) + .halt) + +def program (emit : Bool → List Bool) : + Option Bool → TM2.Stmt (fun _ : Bool => Bool) (Option Bool) (Option Bool) + | none => loop + | some symbol => pushWord true (emit symbol) (.goto fun _ => none) + +def machine (emit : Bool → List Bool) : FinTM2 where + K := Bool + k₀ := false + k₁ := true + Γ _ := Bool + Λ := Option Bool + main := none + σ := Option Bool + initialState := none + m := program emit + +def maxEmission (emit : Bool → List Bool) : Nat := + max (emit false).length (emit true).length + +theorem statementPushBound_le (emit : Bool → List Bool) (label : Option Bool) : + Runtime.statementPushBound (program emit label) ≤ maxEmission emit := by + cases label with + | none => simp [program, loop, Runtime.statementPushBound] + | some symbol => + simp only [program, statementPushBound_pushWord, Runtime.statementPushBound, Nat.add_zero] + cases symbol + · exact Nat.le_max_left _ _ + · exact Nat.le_max_right _ _ + +theorem programPushBound_le (emit : Bool → List Bool) : + Runtime.programPushBound (machine emit) ≤ maxEmission emit := by + have allLabels (labels : List (Option Bool)) : + Runtime.maxLabelPushes (program emit) labels ≤ maxEmission emit := by + induction labels with + | nil => exact Nat.zero_le _ + | cons label rest ih => + exact max_le (statementPushBound_le emit label) ih + exact allLabels (machine emit).ΛFin.elems.toList + +def tapeStacks (input output : List Bool) : Bool → List Bool := + fun side => if side then output else input + +def running (emit : Bool → List Bool) (input output : List Bool) (state : Option Bool) : + (machine emit).Cfg := + ⟨some none, state, tapeStacks input output⟩ + +def emitting (emit : Bool → List Bool) (symbol : Bool) + (input output : List Bool) (state : Option Bool) : (machine emit).Cfg := + ⟨some (some symbol), state, tapeStacks input output⟩ + +def halted (emit : Bool → List Bool) (output : List Bool) : (machine emit).Cfg := + ⟨none, none, tapeStacks [] output⟩ + +theorem update_input (input output replacement : List Bool) : + Function.update (tapeStacks input output) false replacement = tapeStacks replacement output := by + funext side + cases side <;> simp [tapeStacks] + +theorem update_output (input output replacement : List Bool) : + Function.update (tapeStacks input output) true replacement = tapeStacks input replacement := by + funext side + cases side <;> simp [tapeStacks] + +theorem step_empty (emit : Bool → List Bool) (output : List Bool) (state : Option Bool) : + (machine emit).step (running emit [] output state) = some (halted emit output) := by + change some (TM2.stepAux loop state (tapeStacks [] output)) = some (halted emit output) + simp [loop, TM2.stepAux, tapeStacks, halted] + rw [update_input] + rfl + +theorem step_cons (emit : Bool → List Bool) (symbol : Bool) + (input output : List Bool) (state : Option Bool) : + (machine emit).step (running emit (symbol :: input) output state) = + some (emitting emit symbol input output (some symbol)) := by + change some (TM2.stepAux loop state (tapeStacks (symbol :: input) output)) = _ + simp [loop, TM2.stepAux, tapeStacks, emitting] + rw [update_input] + rfl + +theorem step_emit (emit : Bool → List Bool) (symbol : Bool) + (input output : List Bool) (state : Option Bool) : + (machine emit).step (emitting emit symbol input output state) = + some (running emit input ((emit symbol).reverse ++ output) state) := by + change some (TM2.stepAux (pushWord true (emit symbol) (.goto fun _ => none)) + state (tapeStacks input output)) = _ + rw [stepAux_pushWord] + simp only [TM2.stepAux] + change some (⟨some none, state, + Function.update (tapeStacks input output) true ((emit symbol).reverse ++ output)⟩ : + (machine emit).Cfg) = _ + erw [update_output] + rfl + +def next (emit : Bool → List Bool) (configuration : Option (machine emit).Cfg) : + Option (machine emit).Cfg := + configuration.bind (machine emit).step + +theorem two_steps_cons (emit : Bool → List Bool) (symbol : Bool) + (input output : List Bool) (state : Option Bool) : + (next emit)^[2] (some (running emit (symbol :: input) output state)) = + some (running emit input ((emit symbol).reverse ++ output) (some symbol)) := by + change (machine emit).step (running emit (symbol :: input) output state) >>= + (machine emit).step = _ + rw [step_cons] + exact step_emit emit symbol input output (some symbol) + +theorem substitution_steps (emit : Bool → List Bool) + (input output : List Bool) (state : Option Bool) : + (next emit)^[2 * input.length + 1] (some (running emit input output state)) = + some (halted emit ((input.flatMap emit).reverse ++ output)) := by + induction input generalizing output state with + | nil => + simpa only [List.length_nil, Nat.mul_zero, Nat.zero_add, Function.iterate_one, next, + Option.bind_some, List.flatMap_nil, List.reverse_nil, List.nil_append] + using step_empty emit output state + | cons symbol input ih => + rw [List.length_cons] + rw [show 2 * (input.length + 1) + 1 = (2 * input.length + 1) + 2 by omega] + rw [Function.iterate_add_apply, two_steps_cons, ih] + simp only [List.flatMap_cons, List.reverse_append, List.append_assoc] + +theorem initList_eq (emit : Bool → List Bool) (input : List Bool) : + initList (machine emit) input = running emit input [] none := by + unfold initList running + congr 1 + funext side + cases side <;> rfl + +theorem haltList_eq (emit : Bool → List Bool) (output : List Bool) : + haltList (machine emit) output = halted emit output := by + unfold haltList halted + congr 1 + +theorem substitution_init_steps (emit : Bool → List Bool) (input : List Bool) : + (next emit)^[2 * input.length + 1] (some (initList (machine emit) input)) = + some (haltList (machine emit) (input.flatMap emit).reverse) := by + rw [initList_eq, haltList_eq] + simpa only [List.append_nil] using substitution_steps emit input [] none + +def outputsInTime (emit : Bool → List Bool) (input : List Bool) : + TM2OutputsInTime (machine emit) input (some (input.flatMap emit).reverse) + (2 * input.length + 1) where + steps := 2 * input.length + 1 + evals_in_steps := substitution_init_steps emit input + steps_le_m := Nat.le_refl _ + +@[simp] theorem outputsInTime_steps (emit : Bool → List Bool) (input : List Bool) : + (outputsInTime emit input).steps = 2 * input.length + 1 := rfl + +noncomputable def computableInPolyTime (emit : Bool → List Bool) : + TM2ComputableInPolyTime (id : List Bool → List Bool) id + (fun input => (input.flatMap emit).reverse) where + tm := machine emit + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := 2 * Polynomial.X + 1 + outputsFun input := by + change TM2OutputsInTime (machine emit) (input.map id) + (some ((input.flatMap emit).reverse.map id)) + ((2 * Polynomial.X + 1 : Polynomial Nat).eval input.length) + have hi := @List.map_id ((machine emit).Γ (machine emit).k₀) input + have ho := @List.map_id ((machine emit).Γ (machine emit).k₁) (input.flatMap emit).reverse + rw [hi, ho] + simpa only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_X, + Polynomial.eval_ofNat, Polynomial.eval_one] using outputsInTime emit input + +end IndependentSetsGames.Reduction.MachineSubstitution + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineBudget.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbaff47abcdf509f9893e3568fe76ce22be97511 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineBudget.lean @@ -0,0 +1,263 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.RawInitialTables +import OAI.Combinatorics.IndependentSets.Encoding.GraphTableComplexity + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineBudget + +open Target Complexity + +def nameSum {n : Nat} (c : Clause n) : Nat := + (c)[0].variableIndex.val + (c)[1].variableIndex.val + (c)[2].variableIndex.val + +def bodyTime {n : Nat} (i : Nat) (c : Clause n) : Nat := + 6 * n + 18 * i + 2 * nameSum c + + 2 * (encodeWords (Complexity.clauseWords c)).length + 63 + +def loopTime {n : Nat} (i : Nat) : List (Clause n) → Nat + | [] => 1 + | c :: cs => bodyTime i c + loopTime (i + 1) cs + +theorem nameSum_le {n : Nat} (c : Clause n) : nameSum c ≤ 3 * n := by + have h0 := (c)[0].variableIndex.isLt + have h1 := (c)[1].variableIndex.isLt + have h2 := (c)[2].variableIndex.isLt + unfold nameSum + omega + +theorem bodyTime_le {n : Nat} (i : Nat) (c : Clause n) : + bodyTime i c ≤ 18 * n + 18 * i + 81 := by + have hn := nameSum_le c + have hb := clauseBits_length_le c + unfold bodyTime + omega + +theorem loopTime_le {n : Nat} (i : Nat) (cs : List (Clause n)) : + loopTime i cs ≤ cs.length * (18 * n + 18 * (i + cs.length) + 81) + 1 := by + induction cs generalizing i with + | nil => simp [loopTime] + | cons c cs ih => + have hc := bodyTime_le i c + have ht := ih (i + 1) + have hbound : bodyTime i c ≤ 18 * n + 18 * (i + (c :: cs).length) + 81 := by + simp only [List.length_cons] + omega + have hsame : 18 * n + 18 * (i + 1 + cs.length) + 81 = + 18 * n + 18 * (i + (c :: cs).length) + 81 := by + simp only [List.length_cons] + omega + rw [hsame] at ht + rw [loopTime] + calc + _ ≤ (18 * n + 18 * (i + (c :: cs).length) + 81) + + (cs.length * (18 * n + 18 * (i + (c :: cs).length) + 81) + 1) := + Nat.add_le_add hbound ht + _ = _ := by rw [List.length_cons]; ring + +theorem input_header_bound (F : Formula) : + F.«variables» + F.clauses.length + 2 ≤ (formulaBits F).length := by + simp only [formulaBits, formulaWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +theorem graph_size_bound (F : Formula) : + (RawInitialTables.table F).vertices + (RawInitialTables.table F).darts ≤ + 7 * (formulaBits F).length := by + rw [RawInitialTables.initial_size] + have h := input_header_bound F + omega + +def fullBudget (F : Formula) : Nat := + 6 * F.«variables» + 10 * F.clauses.length + 30 + loopTime 0 F.clauses + + (GraphTables.tableBits (RawInitialTables.table F)).length + +noncomputable def timePolynomial : Polynomial Nat := + Polynomial.C 100 * Polynomial.X ^ 2 + Polynomial.C 60000 * Polynomial.X + + Polynomial.C 100 + +theorem timePolynomial_eval (N : Nat) : + timePolynomial.eval N = 100 * N ^ 2 + 60000 * N + 100 := by + simp [timePolynomial] + +theorem fullBudget_le (F : Formula) : + fullBudget F ≤ timePolynomial.eval (formulaBits F).length := by + have hinput := input_header_bound F + have hloop := loopTime_le 0 F.clauses + have hout := GraphTableComplexity.bits_le_of_size_le (RawInitialTables.table F) + (graph_size_bound F) + rw [GraphTableComplexity.encodingPolynomial_eval] at hout + simp only [Nat.zero_add] at hloop + have hm : F.clauses.length ≤ (formulaBits F).length := by omega + have hcoefficient : 18 * F.«variables» + 18 * F.clauses.length + 81 ≤ + 18 * (formulaBits F).length + 81 := by omega + have hproduct := Nat.mul_le_mul hm hcoefficient + rw [timePolynomial_eval] + unfold fullBudget + nlinarith + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineBudget +namespace IndependentSetsGames.Foundations.Complexity.Runtime + +def statementPushBound {K : Type} {Γ : K → Type} {Λ σ : Type} : + Turing.TM2.Stmt Γ Λ σ → Nat + | .push _ _ next => statementPushBound next + 1 + | .peek _ _ next => statementPushBound next + | .pop _ _ next => statementPushBound next + | .load _ next => statementPushBound next + | .branch _ yes no => max (statementPushBound yes) (statementPushBound no) + | .goto _ => 0 + | .halt => 0 + +def maxLabelPushes {K : Type} {Γ : K → Type} {Λ σ : Type} + (program : Λ → Turing.TM2.Stmt Γ Λ σ) : List Λ → Nat + | [] => 0 + | label :: rest => max (statementPushBound (program label)) (maxLabelPushes program rest) + +theorem maxLabelPushes_ge {K : Type} {Γ : K → Type} {Λ σ : Type} + (program : Λ → Turing.TM2.Stmt Γ Λ σ) (labels : List Λ) (label : Λ) + (member : label ∈ labels) : + statementPushBound (program label) ≤ maxLabelPushes program labels := by + induction labels with + | nil => simp at member + | cons first rest ih => + simp only [List.mem_cons] at member + rcases member with rfl | member + · exact Nat.le_max_left _ _ + · exact Nat.le_trans (ih member) (Nat.le_max_right _ _) + +noncomputable def programPushBound (tm : Turing.FinTM2) : Nat := + maxLabelPushes tm.m tm.ΛFin.elems.toList + +theorem statement_le_programPushBound (tm : Turing.FinTM2) (label : tm.Λ) : + statementPushBound (tm.m label) ≤ programPushBound tm := by + apply maxLabelPushes_ge + simpa using tm.ΛFin.complete label + +theorem stepAuxStackLength {K : Type} {Γ : K → Type} {Λ σ : Type} [DecidableEq K] + (stmt : Turing.TM2.Stmt Γ Λ σ) (state : σ) (tapes : ∀ k, List (Γ k)) (k : K) : + ((Turing.TM2.stepAux stmt state tapes).stk k).length ≤ + (tapes k).length + statementPushBound stmt := by + induction stmt generalizing state tapes with + | push j f next ih => + have changed : ((Function.update tapes j (f state :: tapes j)) k).length ≤ + (tapes k).length + 1 := by + by_cases same : k = j + · subst k; simp + · simp [Function.update, same] + have h := ih state (Function.update tapes j (f state :: tapes j)) + simp only [Turing.TM2.stepAux, statementPushBound] + omega + | peek j f next ih => + simpa only [Turing.TM2.stepAux, statementPushBound] using + ih (f state (tapes j).head?) tapes + | pop j f next ih => + have changed : ((Function.update tapes j (tapes j).tail) k).length ≤ + (tapes k).length := by + by_cases same : k = j + · subst k; simp + · simp [Function.update, same] + have h := ih (f state (tapes j).head?) (Function.update tapes j (tapes j).tail) + simp only [Turing.TM2.stepAux, statementPushBound] + omega + | load f next ih => + simpa only [Turing.TM2.stepAux, statementPushBound] using ih (f state) tapes + | branch condition yes no ihYes ihNo => + cases decision : condition state with + | false => + have h := ihNo state tapes + have hm := Nat.le_max_right (statementPushBound yes) (statementPushBound no) + simp only [Turing.TM2.stepAux, statementPushBound, decision, Bool.cond_false] + omega + | true => + have h := ihYes state tapes + have hm := Nat.le_max_left (statementPushBound yes) (statementPushBound no) + simp only [Turing.TM2.stepAux, statementPushBound, decision, Bool.cond_true] + omega + | goto f => simp [Turing.TM2.stepAux, statementPushBound] + | halt => simp [Turing.TM2.stepAux, statementPushBound] + +private theorem iterateSizeBound {α : Type} (f : α → α) (size : α → Nat) (C : Nat) + (oneStep : ∀ x, size (f x) ≤ size x + C) (n : Nat) (x : α) : + size ((f^[n]) x) ≤ size x + n * C := by + induction n with + | zero => simp + | succ n ih => + have hs := oneStep ((f^[n]) x) + have bound : size (f ((f^[n]) x)) ≤ size x + (n + 1) * C := by + rw [Nat.add_mul, Nat.one_mul] + omega + simpa only [Function.iterate_succ_apply'] using bound + +theorem executionSizeBound {σ : Type} (step : σ → Option σ) (size : σ → Nat) (C : Nat) + (oneStep : ∀ a b, step a = some b → size b ≤ size a + C) + {start finish : σ} {budget : Nat} + (execution : StateTransition.EvalsToInTime step start (some finish) budget) : + size finish ≤ size start + budget * C := by + let liftedSize : Option σ → Nat := fun state => (state.map size).getD 0 + have liftedStep : ∀ state : Option σ, + liftedSize (state.bind step) ≤ liftedSize state + C := by + intro state + cases state with + | none => simp [liftedSize] + | some a => + cases transition : step a with + | none => simp [liftedSize, transition] + | some b => simpa [liftedSize, transition] using oneStep a b transition + have bound := iterateSizeBound (fun state : Option σ => state.bind step) + liftedSize C liftedStep execution.steps (some start) + change liftedSize ((flip bind step)^[execution.steps] (some start)) ≤ _ at bound + rw [execution.evals_in_steps] at bound + simp only [liftedSize, Option.map_some, Option.getD_some] at bound + exact Nat.le_trans bound (Nat.add_le_add_left + (Nat.mul_le_mul_right C execution.steps_le_m) _) + +theorem stepStackLength (tm : Turing.FinTM2) (k : tm.K) (a b : tm.Cfg) + (transition : tm.step a = some b) : + (b.stk k).length ≤ (a.stk k).length + programPushBound tm := by + cases a with + | mk label state tapes => + cases label with + | none => simp [Turing.FinTM2.step, Turing.TM2.step] at transition + | some label => + have result := Option.some.inj transition + rw [← result] + exact Nat.le_trans (stepAuxStackLength _ _ _ _) + (Nat.add_le_add_left (statement_le_programPushBound tm label) _) + +theorem initialStackLength (tm : Turing.FinTM2) (input : List (tm.Γ tm.k₀)) (k : tm.K) : + ((Turing.initList tm input).stk k).length ≤ input.length := by + simp only [Turing.initList] + split + next same => subst k; exact Nat.le_refl _ + next _ => simp + +@[simp] theorem haltedOutputLength (tm : Turing.FinTM2) (output : List (tm.Γ tm.k₁)) : + ((Turing.haltList tm output).stk tm.k₁).length = output.length := by + simp [Turing.haltList] + +theorem outputLength_le (tm : Turing.FinTM2) (input : List (tm.Γ tm.k₀)) + (output : List (tm.Γ tm.k₁)) (budget : Nat) + (execution : Turing.TM2OutputsInTime tm input (some output) budget) : + output.length ≤ input.length + budget * programPushBound tm := by + have bound := executionSizeBound tm.step (fun cfg => (cfg.stk tm.k₁).length) + (programPushBound tm) (stepStackLength tm tm.k₁) execution + calc + output.length = ((Turing.haltList tm output).stk tm.k₁).length := (haltedOutputLength tm output).symm + _ ≤ ((Turing.initList tm input).stk tm.k₁).length + budget * programPushBound tm := bound + _ ≤ input.length + budget * programPushBound tm := + Nat.add_le_add_right (initialStackLength tm input tm.k₁) _ + +theorem encodedOutputLength {α β αΓ βΓ : Type} + {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β} + (certificate : Turing.TM2ComputableInPolyTime ea eb f) (a : α) : + (eb (f a)).length ≤ + (Polynomial.X + Polynomial.C (programPushBound certificate.tm) * certificate.time).eval + (ea a).length := by + have bound := outputLength_le certificate.tm _ _ _ (certificate.outputsFun a) + simpa only [List.length_map, Polynomial.eval_add, Polynomial.eval_X, + Polynomial.eval_mul, Polynomial.eval_C, Nat.mul_comm] using bound + +end IndependentSetsGames.Foundations.Complexity.Runtime + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineCleanup.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineCleanup.lean new file mode 100644 index 0000000000000000000000000000000000000000..a01ee064719b53bbc676af7345d6b50a793952fb --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineCleanup.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineReadClause +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineCleanup + +open Turing Complexity RawInitialMachineModel RawInitialMachineReadClause + +theorem trace_trans {α : Type*} (f : α → α) {a b : ℕ} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem incrementIndexTrace (base : Tape → List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .incrementIndex, state, base⟩) = + some ⟨some .guard, state, Function.update base .index (true :: base .index)⟩ := by + rfl + +theorem cleanupTrace {n : ℕ} (base : Tape → List Bool) (c : Target.Clause n) + (suffix : List Bool) (i : ℕ) + (hempty : ∀ j, base (.field j) = []) (hindex : base .index = encodeWord i) + (incoming : State) : + (MachineComposition.advance (TM2.step program))^[ + (encodeWords (Complexity.clauseWords c)).length + 7] + (some ⟨some (.cleanupField 0), incoming, recordTapes base c suffix⟩) = + some ⟨some .guard, (incoming.1, none), + Function.update (Function.update base .input suffix) .index (encodeWord (i + 1))⟩ := by + let r := recordTapes base c suffix + let t1 := Function.update r (.field 0) [] + let t2 := Function.update t1 (.field 1) [] + let t3 := Function.update t2 (.field 2) [] + let t4 := Function.update t3 (.field 3) [] + let t5 := Function.update t4 (.field 4) [] + let t6 := Function.update t5 (.field 5) [] + have h1 := (RawInitialMachinePhases.cleanupFieldInTime 0 r incoming).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[ + (encodeWord (fieldValue c 0)).length + 1] + (some ⟨some (.cleanupField 0), incoming, r⟩) = + some ⟨some (.cleanupField 1), (incoming.1, none), t1⟩ at h1 + have h2 := (RawInitialMachinePhases.cleanupFieldInTime 1 t1 (incoming.1, none)).evals_in_steps + have hf2 : t1 (.field 1) = encodeWord (fieldValue c 1) := by + simp [t1, r] + change (MachineComposition.advance (TM2.step program))^[(t1 (.field 1)).length + 1] + (some ⟨some (.cleanupField 1), (incoming.1, none), t1⟩) = + some ⟨some (.cleanupField 2), (incoming.1, none), t2⟩ at h2 + rw [hf2] at h2 + have h3 := (RawInitialMachinePhases.cleanupFieldInTime 2 t2 (incoming.1, none)).evals_in_steps + have hf3 : t2 (.field 2) = encodeWord (fieldValue c 2) := by + simp [t2, t1, r] + change (MachineComposition.advance (TM2.step program))^[(t2 (.field 2)).length + 1] + (some ⟨some (.cleanupField 2), (incoming.1, none), t2⟩) = + some ⟨some (.cleanupField 3), (incoming.1, none), t3⟩ at h3 + rw [hf3] at h3 + have h4 := (RawInitialMachinePhases.cleanupFieldInTime 3 t3 (incoming.1, none)).evals_in_steps + have hf4 : t3 (.field 3) = encodeWord (fieldValue c 3) := by + simp [t3, t2, t1, r] + change (MachineComposition.advance (TM2.step program))^[(t3 (.field 3)).length + 1] + (some ⟨some (.cleanupField 3), (incoming.1, none), t3⟩) = + some ⟨some (.cleanupField 4), (incoming.1, none), t4⟩ at h4 + rw [hf4] at h4 + have h5 := (RawInitialMachinePhases.cleanupFieldInTime 4 t4 (incoming.1, none)).evals_in_steps + have hf5 : t4 (.field 4) = encodeWord (fieldValue c 4) := by + simp [t4, t3, t2, t1, r] + change (MachineComposition.advance (TM2.step program))^[(t4 (.field 4)).length + 1] + (some ⟨some (.cleanupField 4), (incoming.1, none), t4⟩) = + some ⟨some (.cleanupField 5), (incoming.1, none), t5⟩ at h5 + rw [hf5] at h5 + have h6 := (RawInitialMachinePhases.cleanupFieldInTime 5 t5 (incoming.1, none)).evals_in_steps + have hf6 : t5 (.field 5) = encodeWord (fieldValue c 5) := by + simp [t5, t4, t3, t2, t1, r] + change (MachineComposition.advance (TM2.step program))^[(t5 (.field 5)).length + 1] + (some ⟨some (.cleanupField 5), (incoming.1, none), t5⟩) = + some ⟨some .incrementIndex, (incoming.1, none), t6⟩ at h6 + rw [hf6] at h6 + have last := incrementIndexTrace t6 (incoming.1, none) + have total := trace_trans _ (trace_trans _ (trace_trans _ (trace_trans _ + (trace_trans _ (trace_trans _ h1 h2) h3) h4) h5) h6) last + have htime : + ((((((encodeWord (fieldValue c 0)).length + 1 + + ((encodeWord (fieldValue c 1)).length + 1)) + + ((encodeWord (fieldValue c 2)).length + 1)) + + ((encodeWord (fieldValue c 3)).length + 1)) + + ((encodeWord (fieldValue c 4)).length + 1)) + + ((encodeWord (fieldValue c 5)).length + 1)) + 1 = + (encodeWords (Complexity.clauseWords c)).length + 7 := by + simp [fieldValue, Complexity.clauseWords, Complexity.literalWords, encodeWords] + omega + rw [htime] at total + have frame : Function.update t6 .index (true :: t6 .index) = + Function.update (Function.update base .input suffix) .index (encodeWord (i + 1)) := by + funext k + cases k with + | field j => + fin_cases j <;> simp [t6, t5, t4, t3, t2, t1, r, recordTapes, hempty] + | index => + simp [t6, t5, t4, t3, t2, t1, r, recordTapes, hindex, + encodeWord, List.replicate_succ] + | _ => simp [t6, t5, t4, t3, t2, t1, r, recordTapes] + rw [frame] at total + exact total + +def cleanupInTime {n : ℕ} (base : Tape → List Bool) (c : Target.Clause n) + (suffix : List Bool) (i : ℕ) + (hempty : ∀ j, base (.field j) = []) (hindex : base .index = encodeWord i) + (incoming : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.cleanupField 0), incoming, recordTapes base c suffix⟩ + (some ⟨some .guard, (incoming.1, none), + Function.update (Function.update base .input suffix) .index (encodeWord (i + 1))⟩) + ((encodeWords (Complexity.clauseWords c)).length + 7) where + steps := (encodeWords (Complexity.clauseWords c)).length + 7 + evals_in_steps := cleanupTrace base c suffix i hempty hindex incoming + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineCleanup + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineBody + +open Turing Target Complexity RawInitialMachineModel RawInitialMachineLoopData +open RawInitialMachineReadClause RawInitialMachineRows RawInitialMachineBudget + +theorem trace_trans {α : Type*} (f : α → α) {a b : Nat} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem guardTrace_succ (n i remaining : Nat) (input reversed : List Bool) + (state : State) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .guard, state, loopTapes n i (remaining + 1) input reversed⟩) = + some ⟨some (.fieldStart 0), (state.1, none), + loopTapes n i remaining input reversed⟩ := by + have h := MachineUnaryCounter.guardTrace_succ Tape.counter Label.guard + (.fieldStart 0) (.scan .dummyVariables) program rfl + (loopTapes n i remaining input reversed) remaining [] state.1 state.2 + have heq (r : Nat) : MachineUnaryCounter.counterTapes Tape.counter + (loopTapes n i remaining input reversed) r [] = loopTapes n i r input reversed := by + funext tape + cases tape <;> simp [MachineUnaryCounter.counterTapes, loopTapes] + simpa only [heq, Prod.mk.eta] using h + +theorem guardTrace_zero (n i : Nat) (input reversed : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .guard, state, loopTapes n i 0 input reversed⟩) = + some ⟨some (.scan .dummyVariables), (state.1, none), + loopTapes n i 0 input reversed⟩ := by + have h := MachineUnaryCounter.guardTrace_zero Tape.counter Label.guard + (.fieldStart 0) (.scan .dummyVariables) program rfl + (loopTapes n i 0 input reversed) [] state.1 state.2 + have heq : MachineUnaryCounter.counterTapes Tape.counter + (loopTapes n i 0 input reversed) 0 [] = loopTapes n i 0 input reversed := by + funext tape + cases tape <;> simp [MachineUnaryCounter.counterTapes, loopTapes] + simpa only [heq, Prod.mk.eta] using h + +theorem bodyTrace {n : Nat} (i remaining : Nat) (c : Clause n) + (suffix reversed : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[bodyTime i c] + (some ⟨some .guard, state, + loopTapes n i (remaining + 1) + (encodeWords (Complexity.clauseWords c) ++ suffix) reversed⟩) = + some ⟨some .guard, (RawInitialRows.clauseSigns c, none), + loopTapes n (i + 1) remaining suffix + ((encodeWords (RawInitialRows.clauseWords n i + (RawInitialRows.clauseNames c) (RawInitialRows.clauseSigns c))).reverse ++ reversed)⟩ := by + let input := encodeWords (Complexity.clauseWords c) ++ suffix + let base := loopTapes n i remaining input reversed + let chunk := (encodeWords (RawInitialRows.clauseWords n i + (RawInitialRows.clauseNames c) (RawInitialRows.clauseSigns c))).reverse + let emitted := loopTapes n i remaining input (chunk ++ reversed) + have first := guardTrace_succ n i remaining input reversed state + have read := readClauseTrace base c suffix rfl (fun _ => rfl) (state.1, none) + have rows := rowsTrace (recordTapes base c suffix) n i + (RawInitialRows.clauseNames c) (RawInitialRows.clauseSigns c) + rfl rfl rfl rfl rfl rfl + have frame : outputTapes (recordTapes base c suffix) chunk = + recordTapes emitted c suffix := by + funext tape + cases tape <;> simp [outputTapes, recordTapes, emitted, base, loopTapes] + change (MachineComposition.advance (TM2.step program))^[6 * n + 18 * i + + 2 * nameSum c + 48] + (some ⟨some (.scan (.tailVariables 0)), (RawInitialRows.clauseSigns c, none), + recordTapes base c suffix⟩) = + some ⟨some (.cleanupField 0), (RawInitialRows.clauseSigns c, none), + outputTapes (recordTapes base c suffix) chunk⟩ at rows + rw [frame] at rows + have cleanup := RawInitialMachineCleanup.cleanupTrace emitted c suffix i + (fun _ => rfl) rfl (RawInitialRows.clauseSigns c, none) + have finalFrame : Function.update (Function.update emitted .input suffix) + .index (encodeWord (i + 1)) = + loopTapes n (i + 1) remaining suffix (chunk ++ reversed) := by + funext tape + cases tape <;> simp [emitted, loopTapes] + rw [finalFrame] at cleanup + have total := trace_trans _ (trace_trans _ (trace_trans _ first read) rows) cleanup + have time : 1 + ((encodeWords (Complexity.clauseWords c)).length + 7) + + (6 * n + 18 * i + 2 * nameSum c + 48) + + ((encodeWords (Complexity.clauseWords c)).length + 7) = bodyTime i c := by + simp only [bodyTime, nameSum] + omega + simpa only [time] using total + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineBody + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineFinish.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineFinish.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca0867674103a11a1c466e3ea9f4dd840dab09f1 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineFinish.lean @@ -0,0 +1,246 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineLoopData + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineFinish + +open Turing Complexity RawInitialMachineModel RawInitialMachinePhases + +def tapes (varsWord counter index reversed output : List Bool) : Tape → List Bool + | .«variables» => varsWord + | .counter => counter + | .index => index + | .reversed => reversed + | .output => output + | _ => [] + +def finishTapes (n m : Nat) (rev : List Bool) : Tape → List Bool := + tapes (encodeWord n) [false] (encodeWord m) rev [] + +theorem trace_trans {α : Type*} (f : α → α) {a b : Nat} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem trueRelationWords : + GraphTables.relationWords (GraphTables.relationOf (fun _ _ => true)) = + List.replicate 4096 1 := by + unfold GraphTables.relationWords + rw [GraphTables.relationOf, Vector.toList_ofFn, List.map_ofFn] + exact List.ofFn_const 4096 1 + +theorem dummyBits_length (n m : Nat) : + (encodeWords (RawInitialRows.dummyWords n m)).length = n + 7 * m + 8194 := by + rw [encodeWords_length] + simp only [RawInitialRows.dummyWords, List.sum_append, List.sum_cons, + List.sum_nil, List.length_append, List.length_cons, List.length_nil, + List.sum_replicate, List.length_replicate, nsmul_eq_mul, Nat.mul_one] + omega + +private theorem update_reversed (varsWord counter index rev out word : List Bool) : + Function.update (tapes varsWord counter index rev out) .reversed word = + tapes varsWord counter index word out := by + funext k + cases k <;> simp [tapes] + +private theorem cleanupTrace (n m : Nat) (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[n + m + 6] + (some ⟨some (.cleanupFinal 0), state, finishTapes n m rev⟩) = + some ⟨some .reset, (state.1, none), tapes [] [] [] rev []⟩ := by + have h0 := (cleanupFinalInTime 0 (finishTapes n m rev) state).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[(encodeWord n).length + 1] + (some ⟨some (.cleanupFinal 0), state, finishTapes n m rev⟩) = _ at h0 + rw [encodeWord_length] at h0 + have f0 : Function.update (finishTapes n m rev) .«variables» [] = + tapes [] [false] (encodeWord m) rev [] := by + funext k + cases k <;> simp [finishTapes, tapes] + change (MachineComposition.advance (TM2.step program))^[n + 2] + (some ⟨some (.cleanupFinal 0), state, finishTapes n m rev⟩) = + some ⟨some (.cleanupFinal 1), (state.1, none), + Function.update (finishTapes n m rev) .«variables» []⟩ at h0 + rw [f0] at h0 + have h1 := (cleanupFinalInTime 1 (tapes [] [false] (encodeWord m) rev []) + (state.1, none)).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[2] + (some ⟨some (.cleanupFinal 1), (state.1, none), + tapes [] [false] (encodeWord m) rev []⟩) = _ at h1 + have f1 : Function.update (tapes [] [false] (encodeWord m) rev []) .counter [] = + tapes [] [] (encodeWord m) rev [] := by + funext k + cases k <;> simp [tapes] + change (MachineComposition.advance (TM2.step program))^[2] + (some ⟨some (.cleanupFinal 1), (state.1, none), tapes [] [false] (encodeWord m) rev []⟩) = + some ⟨some (.cleanupFinal 2), (state.1, none), + Function.update (tapes [] [false] (encodeWord m) rev []) .counter []⟩ at h1 + rw [f1] at h1 + have h2 := (cleanupFinalInTime 2 (tapes [] [] (encodeWord m) rev []) + (state.1, none)).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[(encodeWord m).length + 1] + (some ⟨some (.cleanupFinal 2), (state.1, none), + tapes [] [] (encodeWord m) rev []⟩) = _ at h2 + rw [encodeWord_length] at h2 + have f2 : Function.update (tapes [] [] (encodeWord m) rev []) .index [] = + tapes [] [] [] rev [] := by + funext k + cases k <;> simp [tapes] + change (MachineComposition.advance (TM2.step program))^[m + 2] + (some ⟨some (.cleanupFinal 2), (state.1, none), tapes [] [] (encodeWord m) rev []⟩) = + some ⟨some .reset, (state.1, none), + Function.update (tapes [] [] (encodeWord m) rev []) .index []⟩ at h2 + rw [f2] at h2 + have total := trace_trans _ (trace_trans _ h0 h1) h2 + simpa only [show (n + 2) + 2 + (m + 2) = n + m + 6 by omega] using total + +private theorem resetReverseTrace (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[rev.length + 2] + (some ⟨some .reset, state, tapes [] [] [] rev []⟩) = + some (haltList machine rev.reverse) := by + have reset : (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .reset, state, tapes [] [] [] rev []⟩) = + some ⟨some .finalReverse, initialState, tapes [] [] [] rev []⟩ := rfl + have transfer := (Reduction.MachineTransfer.transferAtInTime + .reversed .output (by decide) id false .finalReverse none program rfl + (tapes [] [] [] rev []) (false, false, false) none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[rev.length + 1] + (some ⟨some .finalReverse, initialState, tapes [] [] [] rev []⟩) = _ at transfer + have frame : Reduction.MachineTransfer.tapesAt .reversed .output + (tapes [] [] [] rev []) [] (rev.reverse.map id ++ []) = + (haltList machine rev.reverse).stk := by + funext k + change Tape at k + cases k <;> simp [Reduction.MachineTransfer.tapesAt, tapes, haltList, machine] + rfl + change (MachineComposition.advance (TM2.step program))^[rev.length + 1] + (some ⟨some .finalReverse, initialState, tapes [] [] [] rev []⟩) = + some ⟨none, initialState, Reduction.MachineTransfer.tapesAt .reversed .output + (tapes [] [] [] rev []) [] (rev.reverse.map id ++ [])⟩ at transfer + rw [frame] at transfer + have total := trace_trans _ reset transfer + rw [show 1 + (rev.length + 1) = rev.length + 2 by omega] at total + change (MachineComposition.advance (TM2.step program))^[rev.length + 2] + (some ⟨some .reset, state, tapes [] [] [] rev []⟩) = + some ⟨none, initialState, (haltList machine rev.reverse).stk⟩ + exact total + +private theorem update_finish (n m : Nat) (rev word : List Bool) : + Function.update (finishTapes n m rev) .reversed word = finishTapes n m word := + update_reversed _ _ _ _ _ _ + +private theorem copyFinishTrace (n m r : Nat) (rev : List Bool) (phase : CopyPhase) + (hsource : finishTapes n m rev (copySource phase) = encodeWord r) (state : State) : + (MachineComposition.advance (TM2.step program))^[2 * r + 2] + (some ⟨some (.scan phase), state, finishTapes n m rev⟩) = + some ⟨some (copyNext phase), (state.1, none), + finishTapes n m (List.replicate (copyScale phase * r) true ++ rev)⟩ := by + have h := (copyInTime phase (finishTapes n m rev) r [] + (by simpa only [List.append_nil] using hsource) rfl state).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[2 * r + 2] + (some ⟨some (.scan phase), state, finishTapes n m rev⟩) = + some ⟨some (copyNext phase), (state.1, none), + Function.update (finishTapes n m rev) .reversed + (List.replicate (copyScale phase * r) true ++ rev)⟩ at h + rw [update_finish] at h + exact h + +private theorem closeDummyTailTrace (n m : Nat) (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .closeDummyTail, state, finishTapes n m rev⟩) = + some ⟨some (.scan .dummyReverse), state, finishTapes n m (false :: rev)⟩ := by + change some (TM2.stepAux (program .closeDummyTail) state (finishTapes n m rev)) = _ + simp only [program, TM2.stepAux] + congr 2 + exact update_finish _ _ _ _ + +private theorem closeDummyReverseTrace (n m : Nat) (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .closeDummyReverse, state, finishTapes n m rev⟩) = + some ⟨some .dummyRelation, state, finishTapes n m (false :: rev)⟩ := by + change some (TM2.stepAux (program .closeDummyReverse) state (finishTapes n m rev)) = _ + simp only [program, TM2.stepAux] + congr 2 + exact update_finish _ _ _ _ + +private theorem dummyRelationTrace (n m : Nat) (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .dummyRelation, state, finishTapes n m rev⟩) = + some ⟨some (.cleanupFinal 0), state, + finishTapes n m ((encodeWords (List.replicate 4096 1)).reverse ++ rev)⟩ := by + change some (TM2.stepAux (program .dummyRelation) state (finishTapes n m rev)) = _ + rw [program, Reduction.MachineSubstitution.stepAux_pushWord, trueRelationWords] + simp only [TM2.stepAux] + congr 2 + exact update_finish _ _ _ _ + +theorem dummyTrace (n m : Nat) (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[2 * n + 4 * m + 9] + (some ⟨some (.scan .dummyVariables), state, finishTapes n m rev⟩) = + some ⟨some (.cleanupFinal 0), (state.1, none), + finishTapes n m ((encodeWords (RawInitialRows.dummyWords n m)).reverse ++ rev)⟩ := by + let a := List.replicate n true ++ rev + let b := List.replicate m true ++ a + let c := false :: b + let d := List.replicate (6 * m) true ++ c + let e := false :: d + have h0 := copyFinishTrace n m n rev .dummyVariables rfl state + simp only [copyScale, copyNext, Nat.one_mul] at h0 + have h1 := copyFinishTrace n m m a .dummyIndex rfl (state.1, none) + simp only [copyScale, copyNext, Nat.one_mul] at h1 + have h2 := closeDummyTailTrace n m b (state.1, none) + have h3 := copyFinishTrace n m m c .dummyReverse rfl (state.1, none) + simp only [copyScale, copyNext] at h3 + have h4 := closeDummyReverseTrace n m d (state.1, none) + have h5 := dummyRelationTrace n m e (state.1, none) + have total := trace_trans _ (trace_trans _ (trace_trans _ + (trace_trans _ (trace_trans _ h0 h1) h2) h3) h4) h5 + have output : (encodeWords (List.replicate 4096 1)).reverse ++ e = + (encodeWords (RawInitialRows.dummyWords n m)).reverse ++ rev := by + have rep : List.replicate m true ++ (List.replicate n true ++ rev) = + List.replicate (n + m) true ++ rev := by + rw [← List.append_assoc, ← List.replicate_add, Nat.add_comm m n] + simp only [RawInitialRows.dummyWords, encodeWords_append, encodeWords, + List.append_nil, List.reverse_append, + encodeWord, List.reverse_cons, + List.reverse_replicate, List.append_assoc, List.singleton_append, + a, b, c, d, e] + rw [rep] + simp only [List.reverse_nil, List.nil_append, List.cons_append] + rw [output] at total + simpa only [show (((((2 * n + 2) + (2 * m + 2)) + 1) + (2 * m + 2)) + 1) + 1 = + 2 * n + 4 * m + 9 by omega] using total + +theorem finishTrace (n m : Nat) (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[ + 3 * n + 5 * m + 17 + (encodeWords (RawInitialRows.dummyWords n m)).length + rev.length] + (some ⟨some (.scan .dummyVariables), state, finishTapes n m rev⟩) = + some (haltList machine (rev.reverse ++ encodeWords (RawInitialRows.dummyWords n m))) := by + let emitted := (encodeWords (RawInitialRows.dummyWords n m)).reverse ++ rev + have total := trace_trans _ (trace_trans _ (dummyTrace n m rev state) + (cleanupTrace n m emitted (state.1, none))) + (resetReverseTrace emitted (state.1, none)) + have hout : emitted.reverse = rev.reverse ++ encodeWords (RawInitialRows.dummyWords n m) := by + simp only [emitted, List.reverse_append, List.reverse_reverse] + rw [hout] at total + have htime : (2 * n + 4 * m + 9) + (n + m + 6) + (emitted.length + 2) = + 3 * n + 5 * m + 17 + (encodeWords (RawInitialRows.dummyWords n m)).length + rev.length := by + simp only [emitted, List.length_append, List.length_reverse] + omega + rwa [htime] at total + +def finishInTime (n m : Nat) (rev : List Bool) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.scan .dummyVariables), state, finishTapes n m rev⟩ + (some (haltList machine (rev.reverse ++ encodeWords (RawInitialRows.dummyWords n m)))) + (4 * n + 12 * m + 8211 + rev.length) where + steps := 4 * n + 12 * m + 8211 + rev.length + evals_in_steps := by + have h := finishTrace n m rev state + rw [dummyBits_length] at h + rw [show 3 * n + 5 * m + 17 + (n + 7 * m + 8194) + rev.length = + 4 * n + 12 * m + 8211 + rev.length by omega] at h + exact h + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineFinish + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineLoop.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4438bd5cdb5c31eba3746aed4c85b33ee1424b0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineLoop.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Machine2 +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineCleanup +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineFinish + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineLoop + +open Turing Target Complexity RawInitialMachineModel RawInitialMachineLoopData +open RawInitialMachineBudget RawInitialMachineBody RawInitialMachineFinish + +def finalSigns {n : Nat} (incoming : RawInitialMachineModel.Signs) : + List (Clause n) → RawInitialMachineModel.Signs + | [] => incoming + | c :: cs => finalSigns (RawInitialRows.clauseSigns c) cs + +private theorem trace_trans {α : Type*} (f : α → α) {a b : Nat} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem empty_loopTapes (n i : Nat) (rev : List Bool) : + loopTapes n i 0 [] rev = finishTapes n i rev := by + funext tape + cases tape <;> rfl + +theorem loopTrace {n : Nat} (i : Nat) (cs : List (Clause n)) + (rev : List Bool) (state : State) : + (MachineComposition.advance (TM2.step program))^[loopTime i cs] + (some ⟨some .guard, state, loopTapes n i cs.length (clauseInput cs) rev⟩) = + some ⟨some (.scan .dummyVariables), (finalSigns state.1 cs, none), + finishTapes n (i + cs.length) ((encodeWords (clauseOutput n i cs)).reverse ++ rev)⟩ := by + induction cs generalizing i rev state with + | nil => + have h := RawInitialMachineBody.guardTrace_zero n i [] rev state + rw [empty_loopTapes] at h + simpa only [loopTime, List.length_nil, clauseInput_nil, clauseOutput_nil, + finalSigns, encodeWords, List.reverse_nil, List.nil_append, Nat.add_zero, + empty_loopTapes] using h + | cons c cs ih => + have first := bodyTrace i cs.length c (clauseInput cs) rev state + have rest := ih (i + 1) + ((encodeWords (RawInitialRows.clauseWords n i + (RawInitialRows.clauseNames c) (RawInitialRows.clauseSigns c))).reverse ++ rev) + (RawInitialRows.clauseSigns c, none) + have total := trace_trans _ first rest + have hi : i + 1 + cs.length = i + (cs.length + 1) := by omega + simpa only [loopTime, List.length_cons, clauseInput_cons, clauseOutput_cons, + encodeWords_append, List.reverse_append, List.append_assoc, finalSigns, hi] using total + +def loopInTime {n : Nat} (i : Nat) (cs : List (Clause n)) + (rev : List Bool) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some .guard, state, loopTapes n i cs.length (clauseInput cs) rev⟩ + (some ⟨some (.scan .dummyVariables), (finalSigns state.1 cs, none), + finishTapes n (i + cs.length) ((encodeWords (clauseOutput n i cs)).reverse ++ rev)⟩) + (loopTime i cs) where + steps := loopTime i cs + evals_in_steps := loopTrace i cs rev state + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineLoop +namespace IndependentSetsGames.Foundations.PCP.MachineRawInitialTable + +open Turing Target Complexity RawInitialMachineModel RawInitialMachineLoopData +open RawInitialMachineBudget RawInitialMachineLoop + +private theorem trace_trans {α : Type*} (f : α → α) {a b : Nat} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +def prefixBits (F : Formula) : List Bool := + encodeWords ([F.«variables» + F.clauses.length + 1, 6 * F.clauses.length + 1] ++ + clauseOutput F.«variables» 0 F.clauses) + +theorem outputBits (F : Formula) : + GraphTables.tableBits (RawInitialTables.table F) = prefixBits F ++ + encodeWords (RawInitialRows.dummyWords F.«variables» F.clauses.length) := by + change encodeWords (GraphTables.tableWords (RawInitialTables.table F)) = _ + rw [tableWords_decomposition, encodeWords_append] + rfl + +theorem machineTrace (F : Formula) : + (MachineComposition.advance (TM2.step program))^[fullBudget F] + (some (initList machine (formulaBits F))) = + some (haltList machine (GraphTables.tableBits (RawInitialTables.table F))) := by + have startup := RawInitialMachineStart.formulaStartTrace F + rw [startTapes_eq] at startup + have loop := loopTrace 0 F.clauses + (encodeWords [F.«variables» + F.clauses.length + 1, 6 * F.clauses.length + 1]).reverse + initialState + have hprefix : (encodeWords (clauseOutput F.«variables» 0 F.clauses)).reverse ++ + (encodeWords [F.«variables» + F.clauses.length + 1, 6 * F.clauses.length + 1]).reverse = + (prefixBits F).reverse := by + simp only [prefixBits, encodeWords_append, List.reverse_append] + rw [hprefix, Nat.zero_add] at loop + have finish := RawInitialMachineFinish.finishTrace F.«variables» F.clauses.length + (prefixBits F).reverse (finalSigns initialState.1 F.clauses, none) + rw [List.reverse_reverse, ← outputBits F] at finish + have total := trace_trans _ (trace_trans _ startup loop) finish + have time : (3 * F.«variables» + 5 * F.clauses.length + 13 + loopTime 0 F.clauses) + + (3 * F.«variables» + 5 * F.clauses.length + 17 + + (encodeWords (RawInitialRows.dummyWords F.«variables» F.clauses.length)).length + + (prefixBits F).reverse.length) = fullBudget F := by + rw [fullBudget, outputBits, List.length_append, List.length_reverse] + omega + simpa only [time] using total + +def outputsInTime (F : Formula) : + TM2OutputsInTime machine (formulaBits F) + (some (GraphTables.tableBits (RawInitialTables.table F))) + (timePolynomial.eval (formulaBits F).length) where + steps := fullBudget F + evals_in_steps := machineTrace F + steps_le_m := fullBudget_le F + +noncomputable def computableInPolyTime : + TM2ComputableInPolyTime formulaEncoding.encode GraphTables.encoding.encode + RawInitialTables.table where + tm := machine + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := timePolynomial + outputsFun F := by + change TM2OutputsInTime machine ((formulaBits F).map id) + (some ((GraphTables.tableBits (RawInitialTables.table F)).map id)) + (timePolynomial.eval (formulaBits F).length) + have hi := @List.map_id (machine.Γ machine.k₀) (formulaBits F) + have ho := @List.map_id (machine.Γ machine.k₁) + (GraphTables.tableBits (RawInitialTables.table F)) + rw [hi, ho] + exact outputsInTime F + +end IndependentSetsGames.Foundations.PCP.MachineRawInitialTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineLoopData.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineLoopData.lean new file mode 100644 index 0000000000000000000000000000000000000000..c53f05a059b92fb55506d256d119c635eaf0fc04 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineLoopData.lean @@ -0,0 +1,162 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineStart + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineLoopData + +open Target Complexity RawInitialMachineModel + +def clauseInput {n : Nat} (clauses : List (Clause n)) : List Bool := + encodeWords (clauses.flatMap Complexity.clauseWords) + +@[simp] theorem clauseInput_nil (n : Nat) : clauseInput ([] : List (Clause n)) = [] := rfl + +@[simp] theorem clauseInput_cons {n : Nat} (c : Clause n) (cs : List (Clause n)) : + clauseInput (c :: cs) = encodeWords (Complexity.clauseWords c) ++ clauseInput cs := by + simp only [clauseInput, List.flatMap_cons, encodeWords_append] + +def clauseOutput (n i : Nat) (clauses : List (Clause n)) : List Nat := + (clauses.mapIdx fun offset c => RawInitialRows.clauseWords n (i + offset) + (RawInitialRows.clauseNames c) (RawInitialRows.clauseSigns c)).flatten + +private theorem mapIdx_ofFn {α β : Type} (xs : List α) (f : Nat → α → β) : + xs.mapIdx f = List.ofFn (fun i : Fin xs.length => f i.val (xs.get i)) := by + induction xs generalizing f with + | nil => simp + | cons x xs ih => simp [ih] + +@[simp] theorem clauseOutput_nil (n i : Nat) : clauseOutput n i [] = [] := rfl + +@[simp] theorem clauseOutput_cons (n i : Nat) (c : Clause n) (cs : List (Clause n)) : + clauseOutput n i (c :: cs) = + RawInitialRows.clauseWords n i (RawInitialRows.clauseNames c) + (RawInitialRows.clauseSigns c) ++ clauseOutput n (i + 1) cs := by + simp only [clauseOutput, List.mapIdx_cons, Nat.add_zero, List.flatten_cons, + Nat.add_comm, Nat.add_left_comm] + +theorem clauseOutput_numbered (F : Formula) : + clauseOutput F.«variables» 0 F.clauses = + (List.finRange F.clauses.length).flatMap (fun i => + RawInitialRows.clauseWords F.«variables» i.val + (RawInitialRows.clauseNames (clauseAt F i)) + (RawInitialRows.clauseSigns (clauseAt F i))) := by + simp only [clauseOutput, mapIdx_ofFn, List.ofFn_eq_map, + Nat.zero_add, clauseAt] + rfl + +theorem tableWords_decomposition (F : Formula) : + GraphTables.tableWords (RawInitialTables.table F) = + [F.«variables» + F.clauses.length + 1, 6 * F.clauses.length + 1] ++ + clauseOutput F.«variables» 0 F.clauses ++ + RawInitialRows.dummyWords F.«variables» F.clauses.length := by + rw [RawInitialRows.tableWords_eq, clauseOutput_numbered] + +def loopTapes (n i remaining : Nat) (input reversed : List Bool) : Tape → List Bool + | .input => input + | .«variables» => encodeWord n + | .counter => encodeWord remaining + | .index => encodeWord i + | .reversed => reversed + | _ => [] + +theorem startTapes_eq (n m : Nat) (input : List Bool) : + RawInitialMachineStart.startTapes n m input = + loopTapes n 0 m input (encodeWords [n + m + 1, 6 * m + 1]).reverse := by + funext tape + cases tape <;> rfl + +theorem decrement_counter (n i remaining : Nat) (input reversed : List Bool) : + Function.update (loopTapes n i (remaining + 1) input reversed) + Tape.counter (encodeWord remaining) = loopTapes n i remaining input reversed := by + funext tape + cases tape <;> simp [loopTapes] + +theorem increment_index (n i remaining : Nat) (input reversed : List Bool) : + Function.update (loopTapes n i remaining input reversed) + Tape.index (true :: encodeWord i) = loopTapes n (i + 1) remaining input reversed := by + funext tape + cases tape <;> simp [loopTapes, encodeWord, List.replicate_succ] + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineLoopData +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachinePhases + +open Turing Complexity RawInitialMachineModel + +theorem copySource_ne_scratch (phase : CopyPhase) : copySource phase ≠ Tape.scratch := by + cases phase <;> simp [copySource] + +theorem copySource_ne_reversed (phase : CopyPhase) : copySource phase ≠ Tape.reversed := by + cases phase <;> simp [copySource] + +def copyInTime (phase : CopyPhase) (base : Tape → List Bool) + (n : Nat) (suffix : List Bool) + (hsource : base (copySource phase) = encodeWord n ++ suffix) + (hscratch : base .scratch = []) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.scan phase), state, base⟩ + (some ⟨some (copyNext phase), (state.1, none), + Function.update base .reversed + (List.replicate (copyScale phase * n) true ++ base .reversed)⟩) + (2 * n + 2) := + MachineInitialHeaders.prefixInTime (copySource phase) Tape.scratch Tape.reversed + (copySource_ne_scratch phase) (copySource_ne_reversed phase) (by decide) + (copyScale phase) (.scan phase) (.restore phase) (some (copyNext phase)) + program rfl rfl base n suffix hsource hscratch state.1 state.2 + +def relationInTime (slot : Fin 3) (orientation : Bool) + (base : Tape → List Bool) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.relation slot orientation), state, base⟩ + (some ⟨some (relationNext slot orientation), state, + Function.update base .reversed + (relationOutput slot orientation state ++ base .reversed)⟩) 1 := + MachineFiniteTable.emitInTime (K := Tape) (Λ := Label) (σ := State) (Γ := Alphabet) + Tape.reversed + (relationOutput slot orientation) + stateKeys stateKeys_complete program (.relation slot orientation) + (relationNext slot orientation) rfl state base + +private theorem bitWord_head (b : Bool) : + (encodeWord (if b then 1 else 0)).head? = some b := by + cases b <;> rfl + +theorem loadSigns_step (base : Tape → List Bool) (a b c : Bool) + (ha : base (.field 1) = encodeWord (if a then 1 else 0)) + (hb : base (.field 3) = encodeWord (if b then 1 else 0)) + (hc : base (.field 5) = encodeWord (if c then 1 else 0)) (state : State) : + (TM2.step program) ⟨some .loadSigns, state, base⟩ = + some ⟨some (.scan (.tailVariables 0)), ((a, b, c), none), base⟩ := by + change some (TM2.stepAux (program .loadSigns) state base) = _ + simp only [program, TM2.stepAux, ha, hb, hc, bitWord_head, Option.getD_some] + +def loadSignsInTime (base : Tape → List Bool) (a b c : Bool) + (ha : base (.field 1) = encodeWord (if a then 1 else 0)) + (hb : base (.field 3) = encodeWord (if b then 1 else 0)) + (hc : base (.field 5) = encodeWord (if c then 1 else 0)) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some .loadSigns, state, base⟩ + (some ⟨some (.scan (.tailVariables 0)), ((a, b, c), none), base⟩) 1 where + steps := 1 + evals_in_steps := loadSigns_step base a b c ha hb hc state + steps_le_m := Nat.le_refl _ + +def cleanupFieldInTime (slot : Fin 6) (base : Tape → List Bool) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.cleanupField slot), state, base⟩ + (some ⟨some (if h : slot.val + 1 < 6 then .cleanupField ⟨slot.val + 1, h⟩ + else .incrementIndex), (state.1, none), Function.update base (.field slot) []⟩) + ((base (.field slot)).length + 1) := + MachineDrain.drainInTime (.field slot) (.cleanupField slot) _ program rfl base state.1 state.2 + +def cleanupFinalInTime (slot : Fin 3) (base : Tape → List Bool) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.cleanupFinal slot), state, base⟩ + (some ⟨some (if h : slot.val + 1 < 3 then .cleanupFinal ⟨slot.val + 1, h⟩ + else .reset), (state.1, none), Function.update base (finalTape slot) []⟩) + ((base (finalTape slot)).length + 1) := + MachineDrain.drainInTime (finalTape slot) (.cleanupFinal slot) _ program rfl base state.1 state.2 + +end IndependentSetsGames.Foundations.PCP.RawInitialMachinePhases + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineReadClause.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineReadClause.lean new file mode 100644 index 0000000000000000000000000000000000000000..539b5dff5f9eedb7c4c5fa24c6d5e4f152551668 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineReadClause.lean @@ -0,0 +1,178 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineLoopData + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineReadClause + +open Turing Complexity Hastad RawInitialMachineModel + +def fieldValue {n : ℕ} (c : Target.Clause n) (j : Fin 6) : ℕ := + (Complexity.clauseWords c)[j.val]'(by + rw [Complexity.clauseWords_length] + exact j.isLt) + +def recordTapes {n : ℕ} (base : Tape → List Bool) (c : Target.Clause n) + (suffix : List Bool) : Tape → List Bool + | .input => suffix + | .field j => encodeWord (fieldValue c j) + | k => base k + +@[simp] theorem recordTapes_input {n : ℕ} (base : Tape → List Bool) + (c : Target.Clause n) (suffix : List Bool) : + recordTapes base c suffix .input = suffix := rfl + +@[simp] theorem recordTapes_field {n : ℕ} (base : Tape → List Bool) + (c : Target.Clause n) (suffix : List Bool) (j : Fin 6) : + recordTapes base c suffix (.field j) = encodeWord (fieldValue c j) := rfl + +theorem recordTapes_other {n : ℕ} (base : Tape → List Bool) + (c : Target.Clause n) (suffix : List Bool) (k : Tape) + (hi : k ≠ .input) (hf : ∀ j, k ≠ .field j) : + recordTapes base c suffix k = base k := by + cases k <;> try rfl + · exact (hi rfl).elim + · exact (hf _ rfl).elim + +@[simp] theorem recordTapes_name {n : ℕ} (base : Tape → List Bool) + (c : Target.Clause n) (suffix : List Bool) (j : Fin 3) : + recordTapes base c suffix (.field (nameField j)) = + encodeWord ((c)[j].variableIndex.val) := by + fin_cases j <;> rfl + +theorem trace_trans {α : Type*} (f : α → α) {a b : ℕ} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem fieldsTrace {n : ℕ} (base : Tape → List Bool) (c : Target.Clause n) + (suffix : List Bool) + (hinput : base .input = encodeWords (Complexity.clauseWords c) ++ suffix) + (hempty : ∀ j, base (.field j) = []) (state : State) : + (MachineComposition.advance (TM2.step program))^[ + (encodeWords (Complexity.clauseWords c)).length + 6] + (some ⟨some (.fieldStart 0), state, base⟩) = + some ⟨some .loadSigns, (state.1, none), recordTapes base c suffix⟩ := by + let a := fieldValue c 0 + let b := fieldValue c 1 + let d := fieldValue c 2 + let e := fieldValue c 3 + let f := fieldValue c 4 + let g := fieldValue c 5 + have hwords : Complexity.clauseWords c = [a, b, d, e, f, g] := rfl + have hin : base .input = encodeWord a ++ (encodeWords [b, d, e, f, g] ++ suffix) := by + rw [hinput, hwords] + simp only [encodeWords, List.append_assoc] + let t1 := SourceMachine.afterField .input (.field 0) base a + (encodeWords [b, d, e, f, g] ++ suffix) + let t2 := SourceMachine.afterField .input (.field 1) t1 b + (encodeWords [d, e, f, g] ++ suffix) + let t3 := SourceMachine.afterField .input (.field 2) t2 d + (encodeWords [e, f, g] ++ suffix) + let t4 := SourceMachine.afterField .input (.field 3) t3 e + (encodeWords [f, g] ++ suffix) + let t5 := SourceMachine.afterField .input (.field 4) t4 f + (encodeWords [g] ++ suffix) + let t6 := SourceMachine.afterField .input (.field 5) t5 g suffix + have h1 := (SourceMachine.fieldInTime .input (.field 0) (by decide) + (.fieldStart 0) (.fieldLoop 0) (some (.fieldStart 1)) program rfl rfl + base a (encodeWords [b, d, e, f, g] ++ suffix) hin state.1 state.2).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[a + 2] + (some ⟨some (.fieldStart 0), state, base⟩) = + some ⟨some (.fieldStart 1), (state.1, none), t1⟩ at h1 + have h2 := (SourceMachine.fieldInTime .input (.field 1) (by decide) + (.fieldStart 1) (.fieldLoop 1) (some (.fieldStart 2)) program rfl rfl + t1 b (encodeWords [d, e, f, g] ++ suffix) + (by simp [t1, SourceMachine.afterField, encodeWords, List.append_assoc]) + state.1 none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[b + 2] + (some ⟨some (.fieldStart 1), (state.1, none), t1⟩) = + some ⟨some (.fieldStart 2), (state.1, none), t2⟩ at h2 + have h3 := (SourceMachine.fieldInTime .input (.field 2) (by decide) + (.fieldStart 2) (.fieldLoop 2) (some (.fieldStart 3)) program rfl rfl + t2 d (encodeWords [e, f, g] ++ suffix) + (by simp [t2, SourceMachine.afterField, encodeWords, List.append_assoc]) + state.1 none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[d + 2] + (some ⟨some (.fieldStart 2), (state.1, none), t2⟩) = + some ⟨some (.fieldStart 3), (state.1, none), t3⟩ at h3 + have h4 := (SourceMachine.fieldInTime .input (.field 3) (by decide) + (.fieldStart 3) (.fieldLoop 3) (some (.fieldStart 4)) program rfl rfl + t3 e (encodeWords [f, g] ++ suffix) + (by simp [t3, SourceMachine.afterField, encodeWords, List.append_assoc]) + state.1 none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[e + 2] + (some ⟨some (.fieldStart 3), (state.1, none), t3⟩) = + some ⟨some (.fieldStart 4), (state.1, none), t4⟩ at h4 + have h5 := (SourceMachine.fieldInTime .input (.field 4) (by decide) + (.fieldStart 4) (.fieldLoop 4) (some (.fieldStart 5)) program rfl rfl + t4 f (encodeWords [g] ++ suffix) + (by simp [t4, SourceMachine.afterField, encodeWords, List.append_assoc]) + state.1 none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[f + 2] + (some ⟨some (.fieldStart 4), (state.1, none), t4⟩) = + some ⟨some (.fieldStart 5), (state.1, none), t5⟩ at h5 + have h6 := (SourceMachine.fieldInTime .input (.field 5) (by decide) + (.fieldStart 5) (.fieldLoop 5) (some .loadSigns) program rfl rfl + t5 g suffix + (by simp [t5, SourceMachine.afterField, encodeWords]) + state.1 none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[g + 2] + (some ⟨some (.fieldStart 5), (state.1, none), t5⟩) = + some ⟨some .loadSigns, (state.1, none), t6⟩ at h6 + have total := trace_trans _ (trace_trans _ (trace_trans _ + (trace_trans _ (trace_trans _ h1 h2) h3) h4) h5) h6 + have htime : (((((a + 2) + (b + 2)) + (d + 2)) + (e + 2)) + (f + 2)) + (g + 2) = + (encodeWords (Complexity.clauseWords c)).length + 6 := by + rw [hwords, encodeWords_length] + simp + omega + rw [htime] at total + have frame : t6 = recordTapes base c suffix := by + funext k + cases k with + | field j => + fin_cases j <;> + simp [t6, t5, t4, t3, t2, t1, SourceMachine.afterField, SourceMachine.fieldTapes, + recordTapes, hempty, a, b, d, e, f, g] + | _ => + simp [t6, t5, t4, t3, t2, t1, SourceMachine.afterField, SourceMachine.fieldTapes, + recordTapes] + rw [frame] at total + exact total + +theorem readClauseTrace {n : ℕ} (base : Tape → List Bool) (c : Target.Clause n) + (suffix : List Bool) + (hinput : base .input = encodeWords (Complexity.clauseWords c) ++ suffix) + (hempty : ∀ j, base (.field j) = []) (state : State) : + (MachineComposition.advance (TM2.step program))^[ + (encodeWords (Complexity.clauseWords c)).length + 7] + (some ⟨some (.fieldStart 0), state, base⟩) = + some ⟨some (.scan (.tailVariables 0)), (RawInitialRows.clauseSigns c, none), + recordTapes base c suffix⟩ := by + have first := fieldsTrace base c suffix hinput hempty state + have last := RawInitialMachinePhases.loadSigns_step (recordTapes base c suffix) + (c)[0].positive (c)[1].positive (c)[2].positive rfl rfl rfl (state.1, none) + have lastTrace : (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .loadSigns, (state.1, none), recordTapes base c suffix⟩) = + some ⟨some (.scan (.tailVariables 0)), (RawInitialRows.clauseSigns c, none), + recordTapes base c suffix⟩ := last + have total := trace_trans _ first lastTrace + simpa only [show (encodeWords (Complexity.clauseWords c)).length + 6 + 1 = + (encodeWords (Complexity.clauseWords c)).length + 7 by omega] using total + +def readClauseInTime {n : ℕ} (base : Tape → List Bool) (c : Target.Clause n) + (suffix : List Bool) + (hinput : base .input = encodeWords (Complexity.clauseWords c) ++ suffix) + (hempty : ∀ j, base (.field j) = []) (state : State) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.fieldStart 0), state, base⟩ + (some ⟨some (.scan (.tailVariables 0)), (RawInitialRows.clauseSigns c, none), + recordTapes base c suffix⟩) + ((encodeWords (Complexity.clauseWords c)).length + 7) where + steps := (encodeWords (Complexity.clauseWords c)).length + 7 + evals_in_steps := readClauseTrace base c suffix hinput hempty state + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineReadClause + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineRows.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..98997fe1746f4892f76ab2f56e4fcdae95337183 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineRows.lean @@ -0,0 +1,275 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineLoopData + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineRows + +open Turing Complexity RawInitialMachineModel RawInitialMachinePhases + +attribute [local irreducible] relationOutput RawInitialRows.relationWordsFor + +abbrev advance := MachineComposition.advance (TM2.step program) + +def outputTapes (base : Tape → List Bool) (bits : List Bool) : Tape → List Bool := + Function.update base .reversed (bits ++ base .reversed) + +@[simp] theorem outputTapes_reversed (base : Tape → List Bool) (bits : List Bool) : + outputTapes base bits .reversed = bits ++ base .reversed := by simp [outputTapes] + +theorem outputTapes_other (base : Tape → List Bool) (bits : List Bool) + (tape : Tape) (h : tape ≠ .reversed) : outputTapes base bits tape = base tape := by + simp [outputTapes, h] + +@[simp] theorem outputTapes_twice (base : Tape → List Bool) (first second : List Bool) : + outputTapes (outputTapes base first) second = outputTapes base (second ++ first) := by + funext tape + by_cases h : tape = .reversed + · subst tape; simp [List.append_assoc] + · simp [outputTapes, h] + +theorem trace_trans {α : Type*} (f : α → α) {a b : ℕ} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +private theorem copyTrace (phase : CopyPhase) (base : Tape → List Bool) + (n : ℕ) (hsource : base (copySource phase) = encodeWord n) + (hscratch : base .scratch = []) (signs : Signs) : + advance^[2 * n + 2] (some ⟨some (.scan phase), (signs, none), base⟩) = + some ⟨some (copyNext phase), (signs, none), + outputTapes base (List.replicate (copyScale phase * n) true)⟩ := + (copyInTime phase base n [] (by simpa using hsource) hscratch (signs, none)).evals_in_steps + +private theorem closeTailTrace (slot : Fin 3) (orientation : Bool) + (base : Tape → List Bool) (signs : Signs) : + advance^[1] (some ⟨some (.closeTail slot orientation), (signs, none), base⟩) = + some ⟨some (.scan (.reverseIndex slot orientation)), (signs, none), + outputTapes base [false]⟩ := by + change some (TM2.stepAux (program (.closeTail slot orientation)) (signs, none) base) = _ + rfl + +private theorem closeReverseTrace (slot : Fin 3) (orientation : Bool) + (base : Tape → List Bool) (signs : Signs) : + advance^[1] (some ⟨some (.closeReverse slot orientation), (signs, none), base⟩) = + some ⟨some (.relation slot orientation), (signs, none), + outputTapes base (encodeWord (2 * slot.val + if orientation then 0 else 1)).reverse⟩ := + MachineInitialHeaders.literalTrace .reversed + (encodeWord (2 * slot.val + if orientation then 0 else 1)) + (.closeReverse slot orientation) (some (.relation slot orientation)) + program rfl base signs none + +private theorem reverse_encodeWord_add (a b : ℕ) : + (encodeWord b).reverse ++ List.replicate a true = (encodeWord (a + b)).reverse := by + simp only [encodeWord, List.reverse_append, List.reverse_replicate, List.reverse_singleton] + rw [Nat.add_comm a b, List.replicate_add] + simp only [List.append_assoc] + +def rowEndBits (slot : Fin 3) (orientation : Bool) (i : ℕ) (signs : Signs) : List Bool := + relationOutput slot orientation (signs, none) ++ + (encodeWord (6 * i + 2 * slot.val + if orientation then 0 else 1)).reverse ++ [false] + +private theorem rowEndTrace (slot : Fin 3) (orientation : Bool) (base : Tape → List Bool) + (i : ℕ) (hindex : base .index = encodeWord i) (hscratch : base .scratch = []) + (signs : Signs) : + advance^[2 * i + 5] (some ⟨some (.closeTail slot orientation), (signs, none), base⟩) = + some ⟨some (relationNext slot orientation), (signs, none), + outputTapes base (rowEndBits slot orientation i signs)⟩ := by + let first := outputTapes base [false] + let second := outputTapes first (List.replicate (6 * i) true) + let third := outputTapes second + (encodeWord (2 * slot.val + if orientation then 0 else 1)).reverse + have h1 := closeTailTrace slot orientation base signs + have h2 := copyTrace (.reverseIndex slot orientation) first i + (by simpa [first, outputTapes, copySource] using hindex) + (by simpa [first, outputTapes] using hscratch) signs + change advance^[2 * i + 2] + (some ⟨some (.scan (.reverseIndex slot orientation)), (signs, none), first⟩) = + some ⟨some (.closeReverse slot orientation), (signs, none), second⟩ at h2 + have h3 := closeReverseTrace slot orientation second signs + have h4 := (relationInTime slot orientation third (signs, none)).evals_in_steps + change advance^[1] (some ⟨some (.relation slot orientation), (signs, none), third⟩) = + some ⟨some (relationNext slot orientation), (signs, none), + outputTapes third (relationOutput slot orientation (signs, none))⟩ at h4 + have total := trace_trans _ (trace_trans _ (trace_trans _ h1 h2) h3) h4 + have hout : outputTapes third (relationOutput slot orientation (signs, none)) = + outputTapes base (rowEndBits slot orientation i signs) := by + simp only [third, second, first, outputTapes_twice] + apply congrArg (outputTapes base) + rw [reverse_encodeWord_add] + simp only [rowEndBits, Nat.add_assoc, List.append_assoc] + rw [hout] at total + simpa only [show 1 + (2 * i + 2) + 1 + 1 = 2 * i + 5 by omega] using total + +private theorem rowEndBits_append (slot : Fin 3) (orientation : Bool) + (tail i : ℕ) (signs : Signs) : + rowEndBits slot orientation i signs ++ List.replicate tail true = + (encodeWords ([tail, 6 * i + 2 * slot.val + if orientation then 0 else 1] ++ + RawInitialRows.relationWordsFor signs (RawInitialTables.slotOrder.symm slot) orientation)).reverse := by + simp only [rowEndBits, relationOutput, encodeWords_append, encodeWords, + List.append_nil, List.reverse_append, encodeWord, + List.reverse_replicate, List.reverse_singleton, List.append_assoc] + +theorem falseRowTrace (slot : Fin 3) (base : Tape → List Bool) (n i : ℕ) + (names : RawInitialRows.Names) (signs : Signs) + (hvariables : base .«variables» = encodeWord n) (hindex : base .index = encodeWord i) + (hscratch : base .scratch = []) : + advance^[2 * n + 4 * i + 9] + (some ⟨some (.scan (.tailVariables slot)), (signs, none), base⟩) = + some ⟨some (.scan (.variableName slot)), (signs, none), + outputTapes base (encodeWords (RawInitialRows.incidenceWords n i names signs + (RawInitialTables.slotOrder.symm slot) false)).reverse⟩ := by + let first := outputTapes base (List.replicate n true) + let second := outputTapes first (List.replicate i true) + have h1 := copyTrace (.tailVariables slot) base n hvariables hscratch signs + have h2 := copyTrace (.tailIndex slot) first i + (by simpa [first, outputTapes, copySource] using hindex) + (by simpa [first, outputTapes] using hscratch) signs + simp only [copyScale, Nat.one_mul, copyNext] at h1 h2 + change advance^[2 * n + 2] + (some ⟨some (.scan (.tailVariables slot)), (signs, none), base⟩) = + some ⟨some (.scan (.tailIndex slot)), (signs, none), first⟩ at h1 + change advance^[2 * i + 2] + (some ⟨some (.scan (.tailIndex slot)), (signs, none), first⟩) = + some ⟨some (.closeTail slot false), (signs, none), second⟩ at h2 + have h3 := rowEndTrace slot false second i + (by simpa [second, first, outputTapes] using hindex) + (by simpa [second, first, outputTapes] using hscratch) signs + have total := trace_trans _ (trace_trans _ h1 h2) h3 + have hout : outputTapes second (rowEndBits slot false i signs) = + outputTapes base (encodeWords (RawInitialRows.incidenceWords n i names signs + (RawInitialTables.slotOrder.symm slot) false)).reverse := by + simp only [second, first, outputTapes_twice] + apply congrArg (outputTapes base) + rw [← List.replicate_add, Nat.add_comm i n, rowEndBits_append] + simp only [RawInitialRows.incidenceWords, Bool.false_eq_true, ↓reduceIte, + Equiv.apply_symm_apply] + rw [hout] at total + simpa only [relationNext, Bool.false_eq_true, ↓reduceIte, + show (2 * n + 2) + (2 * i + 2) + (2 * i + 5) = 2 * n + 4 * i + 9 by omega] using total + +theorem trueRowTrace (slot : Fin 3) (base : Tape → List Bool) (n i : ℕ) + (names : RawInitialRows.Names) (signs : Signs) + (hname : base (.field (nameField slot)) = + encodeWord (RawInitialRows.nameWord names (RawInitialTables.slotOrder.symm slot))) + (hindex : base .index = encodeWord i) (hscratch : base .scratch = []) : + advance^[2 * RawInitialRows.nameWord names (RawInitialTables.slotOrder.symm slot) + 2 * i + 7] + (some ⟨some (.scan (.variableName slot)), (signs, none), base⟩) = + some ⟨some (relationNext slot true), (signs, none), + outputTapes base (encodeWords (RawInitialRows.incidenceWords n i names signs + (RawInitialTables.slotOrder.symm slot) true)).reverse⟩ := by + let value := RawInitialRows.nameWord names (RawInitialTables.slotOrder.symm slot) + let first := outputTapes base (List.replicate value true) + have h1 := copyTrace (.variableName slot) base value hname hscratch signs + simp only [copyScale, Nat.one_mul, copyNext] at h1 + change advance^[2 * value + 2] + (some ⟨some (.scan (.variableName slot)), (signs, none), base⟩) = + some ⟨some (.closeTail slot true), (signs, none), first⟩ at h1 + have h2 := rowEndTrace slot true first i + (by simpa [first, outputTapes] using hindex) + (by simpa [first, outputTapes] using hscratch) signs + have total := trace_trans _ h1 h2 + have hout : outputTapes first (rowEndBits slot true i signs) = + outputTapes base (encodeWords (RawInitialRows.incidenceWords n i names signs + (RawInitialTables.slotOrder.symm slot) true)).reverse := by + simp only [first, outputTapes_twice, rowEndBits_append, value, + RawInitialRows.incidenceWords, ↓reduceIte, Equiv.apply_symm_apply] + rw [hout] at total + simpa only [value, show (2 * value + 2) + (2 * i + 5) = 2 * value + 2 * i + 7 by omega] using total + +def pairWords (slot : Fin 3) (n i : ℕ) (names : RawInitialRows.Names) + (signs : Signs) : List ℕ := + RawInitialRows.incidenceWords n i names signs (RawInitialTables.slotOrder.symm slot) false ++ + RawInitialRows.incidenceWords n i names signs (RawInitialTables.slotOrder.symm slot) true + +theorem pairTrace (slot : Fin 3) (base : Tape → List Bool) (n i : ℕ) + (names : RawInitialRows.Names) (signs : Signs) + (hvariables : base .«variables» = encodeWord n) (hindex : base .index = encodeWord i) + (hname : base (.field (nameField slot)) = + encodeWord (RawInitialRows.nameWord names (RawInitialTables.slotOrder.symm slot))) + (hscratch : base .scratch = []) : + advance^[2 * n + 6 * i + + 2 * RawInitialRows.nameWord names (RawInitialTables.slotOrder.symm slot) + 16] + (some ⟨some (.scan (.tailVariables slot)), (signs, none), base⟩) = + some ⟨some (relationNext slot true), (signs, none), + outputTapes base (encodeWords (pairWords slot n i names signs)).reverse⟩ := by + let first := outputTapes base (encodeWords (RawInitialRows.incidenceWords n i names signs + (RawInitialTables.slotOrder.symm slot) false)).reverse + have h1 := falseRowTrace slot base n i names signs hvariables hindex hscratch + have h2 := trueRowTrace slot first n i names signs + (by simpa [first, outputTapes] using hname) + (by simpa [first, outputTapes] using hindex) + (by simpa [first, outputTapes] using hscratch) + have total := trace_trans _ h1 h2 + simpa only [first, outputTapes_twice, pairWords, encodeWords_append, List.reverse_append, + show (2 * n + 4 * i + 9) + + (2 * RawInitialRows.nameWord names (RawInitialTables.slotOrder.symm slot) + 2 * i + 7) = + 2 * n + 6 * i + + 2 * RawInitialRows.nameWord names (RawInitialTables.slotOrder.symm slot) + 16 by omega] + using total + +theorem rowsTrace (base : Tape → List Bool) (n i : ℕ) + (names : RawInitialRows.Names) (signs : Signs) + (hvariables : base .«variables» = encodeWord n) (hindex : base .index = encodeWord i) + (hname0 : base (.field 0) = encodeWord names.1) + (hname2 : base (.field 2) = encodeWord names.2.1) + (hname4 : base (.field 4) = encodeWord names.2.2) + (hscratch : base .scratch = []) : + advance^[6 * n + 18 * i + 2 * (names.1 + names.2.1 + names.2.2) + 48] + (some ⟨some (.scan (.tailVariables 0)), (signs, none), base⟩) = + some ⟨some (.cleanupField 0), (signs, none), + outputTapes base (encodeWords (RawInitialRows.clauseWords n i names signs)).reverse⟩ := by + let first := outputTapes base (encodeWords (pairWords 0 n i names signs)).reverse + let second := outputTapes first (encodeWords (pairWords 1 n i names signs)).reverse + have h0 := pairTrace 0 base n i names signs hvariables hindex hname0 hscratch + have h1 := pairTrace 1 first n i names signs + (by simpa [first, outputTapes] using hvariables) + (by simpa [first, outputTapes] using hindex) + (by simpa [first, outputTapes, nameField, RawInitialRows.nameWord, + RawInitialTables.slotOrder] using hname2) + (by simpa [first, outputTapes] using hscratch) + have h2 := pairTrace 2 second n i names signs + (by simpa [second, first, outputTapes] using hvariables) + (by simpa [second, first, outputTapes] using hindex) + (by simpa [second, first, outputTapes, nameField, RawInitialRows.nameWord, + RawInitialTables.slotOrder] using hname4) + (by simpa [second, first, outputTapes] using hscratch) + change advance^[2 * n + 6 * i + 2 * names.1 + 16] + (some ⟨some (.scan (.tailVariables 0)), (signs, none), base⟩) = + some ⟨some (.scan (.tailVariables 1)), (signs, none), first⟩ at h0 + change advance^[2 * n + 6 * i + 2 * names.2.1 + 16] + (some ⟨some (.scan (.tailVariables 1)), (signs, none), first⟩) = + some ⟨some (.scan (.tailVariables 2)), (signs, none), second⟩ at h1 + change advance^[2 * n + 6 * i + 2 * names.2.2 + 16] + (some ⟨some (.scan (.tailVariables 2)), (signs, none), second⟩) = + some ⟨some (.cleanupField 0), (signs, none), + outputTapes second (encodeWords (pairWords 2 n i names signs)).reverse⟩ at h2 + have total := trace_trans _ (trace_trans _ h0 h1) h2 + have hout : outputTapes second (encodeWords (pairWords 2 n i names signs)).reverse = + outputTapes base (encodeWords (RawInitialRows.clauseWords n i names signs)).reverse := by + simp only [second, first, outputTapes_twice, RawInitialRows.clauseWords, + encodeWords_append, List.reverse_append, pairWords, List.append_assoc] + rfl + rw [hout] at total + simpa only [show (2 * n + 6 * i + 2 * names.1 + 16) + + (2 * n + 6 * i + 2 * names.2.1 + 16) + (2 * n + 6 * i + 2 * names.2.2 + 16) = + 6 * n + 18 * i + 2 * (names.1 + names.2.1 + names.2.2) + 48 by omega] using total + +def rowsInTime (base : Tape → List Bool) (n i : ℕ) + (names : RawInitialRows.Names) (signs : Signs) + (hvariables : base .«variables» = encodeWord n) (hindex : base .index = encodeWord i) + (hname0 : base (.field 0) = encodeWord names.1) + (hname2 : base (.field 2) = encodeWord names.2.1) + (hname4 : base (.field 4) = encodeWord names.2.2) + (hscratch : base .scratch = []) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (.scan (.tailVariables 0)), (signs, none), base⟩ + (some ⟨some (.cleanupField 0), (signs, none), + outputTapes base (encodeWords (RawInitialRows.clauseWords n i names signs)).reverse⟩) + (6 * n + 18 * i + 2 * (names.1 + names.2.1 + names.2.2) + 48) where + steps := 6 * n + 18 * i + 2 * (names.1 + names.2.1 + names.2.2) + 48 + evals_in_steps := rowsTrace base n i names signs hvariables hindex hname0 hname2 hname4 hscratch + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineStart.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineStart.lean new file mode 100644 index 0000000000000000000000000000000000000000..439e0d0d0e97ce685075e0d9af251c8578a94d48 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/RawInitialMachineStart.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFiniteTable + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialMachineStart + +open Turing Complexity Hastad RawInitialMachineModel + +def inputTapes (bits : List Bool) : Tape → List Bool + | .input => bits + | _ => [] + +private def firstTapes (n m : ℕ) (clauseBits : List Bool) : Tape → List Bool + | .input => encodeWord m ++ clauseBits + | .«variables» => encodeWord n + | _ => [] + +def counterTapes (n m : ℕ) (clauseBits : List Bool) : Tape → List Bool + | .input => clauseBits + | .«variables» => encodeWord n + | .counter => encodeWord m + | _ => [] + +private def headerTapes (n m : ℕ) (clauseBits : List Bool) : Tape → List Bool + | .input => clauseBits + | .«variables» => encodeWord n + | .counter => encodeWord m + | .reversed => (encodeWords [n + m + 1, 6 * m + 1]).reverse + | _ => [] + +def startTapes (n m : ℕ) (clauseBits : List Bool) : Tape → List Bool + | .input => clauseBits + | .«variables» => encodeWord n + | .counter => encodeWord m + | .index => [false] + | .reversed => (encodeWords [n + m + 1, 6 * m + 1]).reverse + | _ => [] + +theorem initList_eq (bits : List Bool) : + initList machine bits = + ⟨some (.headerStart 0), initialState, inputTapes bits⟩ := by + unfold initList + congr 1 + funext k + change Tape at k + cases k <;> rfl + +theorem trace_trans {α : Type*} (f : α → α) {a b : ℕ} {x y z : α} + (first : f^[a] x = y) (second : f^[b] y = z) : f^[a + b] x = z := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem readCountersTrace (n m : ℕ) (clauseBits : List Bool) : + (MachineComposition.advance (TM2.step program))^[n + m + 4] + (some (initList machine (encodeWords [n, m] ++ clauseBits))) = + some ⟨some .scanN, initialState, counterTapes n m clauseBits⟩ := by + let t0 := inputTapes (encodeWords [n, m] ++ clauseBits) + have first := (SourceMachine.fieldInTime .input .«variables» (by decide) + (.headerStart 0) (.headerLoop 0) (some (.headerStart 1)) program rfl rfl + t0 n (encodeWord m ++ clauseBits) + (by simp [t0, inputTapes, encodeWords, List.append_assoc]) + (false, false, false) none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[n + 2] + (some ⟨some (.headerStart 0), initialState, t0⟩) = _ at first + have firstFrame : SourceMachine.fieldTapes .input .«variables» t0 + (encodeWord m ++ clauseBits) (encodeWord n ++ t0 .«variables») = + firstTapes n m clauseBits := by + funext k + cases k <;> simp [SourceMachine.fieldTapes, t0, inputTapes, firstTapes] + rw [firstFrame] at first + have second := (SourceMachine.fieldInTime .input .counter (by decide) + (.headerStart 1) (.headerLoop 1) (some .scanN) program rfl rfl + (firstTapes n m clauseBits) m clauseBits rfl (false, false, false) none).evals_in_steps + change (MachineComposition.advance (TM2.step program))^[m + 2] + (some ⟨some (.headerStart 1), initialState, firstTapes n m clauseBits⟩) = _ at second + have secondFrame : SourceMachine.fieldTapes .input .counter (firstTapes n m clauseBits) + clauseBits (encodeWord m ++ firstTapes n m clauseBits .counter) = + counterTapes n m clauseBits := by + funext k + cases k <;> simp [SourceMachine.fieldTapes, firstTapes, counterTapes] + rw [secondFrame] at second + have total := trace_trans _ first second + rw [show (n + 2) + (m + 2) = n + m + 4 by omega] at total + rw [initList_eq] + exact total + +theorem headersTrace (n m : ℕ) (clauseBits : List Bool) : + (MachineComposition.advance (TM2.step program))^[2 * n + 4 * m + 8] + (some ⟨some .scanN, initialState, counterTapes n m clauseBits⟩) = + some ⟨some .initializeIndex, initialState, headerTapes n m clauseBits⟩ := by + have h := MachineInitialHeaders.headerTrace .«variables» .counter .scratch .reversed + (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + .scanN .restoreN .scanM1 .restoreM1 .closeFirst .scanM6 .restoreM6 .closeSecond + (some .initializeIndex) program rfl rfl rfl rfl rfl rfl rfl rfl + (counterTapes n m clauseBits) n m [] [] + (by simp [counterTapes]) (by simp [counterTapes]) rfl + (false, false, false) none + have frame : Function.update (counterTapes n m clauseBits) .reversed + ((encodeWords [n + m + 1, 6 * m + 1]).reverse ++ + counterTapes n m clauseBits .reversed) = headerTapes n m clauseBits := by + funext k + cases k <;> simp [counterTapes, headerTapes] + rw [frame] at h + exact h + +theorem initializeIndexTrace (n m : ℕ) (clauseBits : List Bool) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some .initializeIndex, initialState, headerTapes n m clauseBits⟩) = + some ⟨some .guard, initialState, startTapes n m clauseBits⟩ := by + simp only [Function.iterate_one, MachineComposition.advance_some] + change some (TM2.stepAux (program .initializeIndex) initialState + (headerTapes n m clauseBits)) = _ + simp only [program, TM2.stepAux] + congr 2 + funext k + cases k <;> simp [headerTapes, startTapes] + +theorem startTrace (n m : ℕ) (clauseBits : List Bool) : + (MachineComposition.advance (TM2.step program))^[3 * n + 5 * m + 13] + (some (initList machine (encodeWords [n, m] ++ clauseBits))) = + some ⟨some .guard, initialState, startTapes n m clauseBits⟩ := by + have total := trace_trans _ + (trace_trans _ (readCountersTrace n m clauseBits) (headersTrace n m clauseBits)) + (initializeIndexTrace n m clauseBits) + simpa only [show (n + m + 4) + (2 * n + 4 * m + 8) + 1 = + 3 * n + 5 * m + 13 by omega] using total + +theorem formulaStartTrace (F : Target.Formula) : + (MachineComposition.advance (TM2.step program))^[ + 3 * F.«variables» + 5 * F.clauses.length + 13] + (some (initList machine (formulaBits F))) = + some ⟨some .guard, initialState, + startTapes F.«variables» F.clauses.length + (encodeWords (F.clauses.flatMap clauseWords))⟩ := by + simpa only [formulaBits, formulaWords, encodeWords_append] using + startTrace F.«variables» F.clauses.length (encodeWords (F.clauses.flatMap clauseWords)) + +def startInTime (n m : ℕ) (clauseBits : List Bool) : + StateTransition.EvalsToInTime (TM2.step program) + (initList machine (encodeWords [n, m] ++ clauseBits)) + (some ⟨some .guard, initialState, startTapes n m clauseBits⟩) + (3 * n + 5 * m + 13) where + steps := 3 * n + 5 * m + 13 + evals_in_steps := startTrace n m clauseBits + steps_le_m := Nat.le_refl _ + +def formulaStartInTime (F : Target.Formula) : + StateTransition.EvalsToInTime (TM2.step program) (initList machine (formulaBits F)) + (some ⟨some .guard, initialState, + startTapes F.«variables» F.clauses.length + (encodeWords (F.clauses.flatMap clauseWords))⟩) + (3 * F.«variables» + 5 * F.clauses.length + 13) where + steps := 3 * F.«variables» + 5 * F.clauses.length + 13 + evals_in_steps := formulaStartTrace F + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.PCP.RawInitialMachineStart + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Remaining.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Remaining.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e3ff68d6a69610bbb9c71549fc3bc0ff107b489 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Remaining.lean @@ -0,0 +1,456 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Tape2 + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineOverlayTable +open Turing MachineComposition +open PCP PCP.GraphTables PCP.PreprocessingOverlayWords +open MachineCloudPadding + +variable {A : Type} + +def remaining {n : Nat} (block : Fin n → List Bool) (k : Nat) : List Bool := + ((List.ofFn block).drop k).flatten +def emittedPrefix {n : Nat} (block : Fin n → List Bool) (k : Nat) : List Bool := + ((List.ofFn block).take k).flatten + +theorem remaining_step {n : Nat} (block : Fin n → List Bool) (v : Fin n) : + remaining block v.val = block v ++ remaining block (v.val + 1) := by + have hs := List.getElem_cons_drop (as := List.ofFn block) (i := v.val) + (by simpa only [List.length_ofFn] using v.isLt) + unfold remaining + rw [← hs] + simp only [List.flatten_cons, List.getElem_ofFn, Fin.eta] + +theorem prefix_step {n : Nat} (block : Fin n → List Bool) (v : Fin n) : + emittedPrefix block (v.val + 1) = emittedPrefix block v.val ++ block v := by + unfold emittedPrefix + rw [List.take_succ_eq_append_getElem (by simpa only [List.length_ofFn] using v.isLt)] + simp only [List.flatten_append, List.flatten_cons, List.flatten_nil, List.append_nil, + List.getElem_ofFn, Fin.eta] + +@[simp] theorem remaining_zero {n : Nat} (block : Fin n → List Bool) : + remaining block 0 = (List.ofFn block).flatten := by simp [remaining] +@[simp] theorem remaining_end {n : Nat} (block : Fin n → List Bool) : + remaining block n = [] := by + unfold remaining + rw [List.drop_eq_nil_iff.mpr (by simpa only [List.length_ofFn] using (Nat.le_refl n)), List.flatten_nil] +@[simp] theorem prefix_zero {n : Nat} (block : Fin n → List Bool) : emittedPrefix block 0 = [] := by + simp [emittedPrefix] +@[simp] theorem prefix_end {n : Nat} (block : Fin n → List Bool) : + emittedPrefix block n = (List.ofFn block).flatten := by + unfold emittedPrefix + have ht : (List.ofFn block).take n = List.ofFn block := + List.take_of_length_le (by simpa only [List.length_ofFn] using (Nat.le_refl n)) + rw [ht] + +theorem oldFrame {n m : Nat} (g h gs hs nv mv f v out : List Bool) + (rows : List (DartRow n m)) : + MachineLazyRows.streamFrame oldTapes (memory g h gs hs nv mv f v [] []) rows out = + memory g h (MachineLazyRows.recordsInput rows ++ gs) hs nv mv f v [] out := by + funext k + rcases k with i | i <;> fin_cases i <;> + simp [MachineLazyRows.streamFrame, oldTapes, memory, tail, oldReverse, relation, + scratch, dividedCopy, quotient, newReverse, output, rowBuffer, graphStream] + +theorem expanderFrame (g h gs hs nv mv f v t out : List Bool) (words : List Nat) : + MachineOverlayRows.streamFrame expanderTapes (memory g h gs hs nv mv f v t []) words out = + memory g h gs (encodeWords words ++ hs) nv mv f v t out := by + funext k + rcases k with i | i <;> fin_cases i <;> + simp [MachineOverlayRows.streamFrame, expanderTapes, memory, tail, oldReverse, + relation, scratch, dividedCopy, quotient, newReverse, output, rowBuffer, expanderStream] + +theorem oldVertexTrace {n : Nat} (d e : Nat) (hd : 0 < d) (he : 0 < e) + (G : PortTables.Table n d) (v : Fin n) (g h gs hs nv mv f current out : List Bool) (a : A) : + (advance (TM2.step (program d e hd he)))^[MachineLazyRows.vertexSteps d (d + e) 0 (oldRows G v) out] + (some ⟨next (.old (0, none)), clean d e hd he a, + memory g h (oldBlock G v ++ gs) hs nv mv f current [] out⟩) = + some ⟨next .tailSeed, clean d e hd he a, + memory g h gs hs nv mv f current [] (out ++ oldOutput G e v)⟩ := by + have hrun := MachineLazyRows.vertexTrace d hd (d + e) 0 oldTapes oldTapes_injective + (fun stage => .inr (.old stage)) (next .tailSeed) (program d e hd he) (fun _ => rfl) + (memory g h gs hs nv mv f current [] []) (row G v) + (by + intro i hi7 hi9 + fin_cases i <;> simp_all [oldTapes, memory, tail, oldReverse, relation, scratch, + dividedCopy, quotient, newReverse, output, rowBuffer, graphStream]) + (a, MachineFixedDivMod.residue e he 0) out + simpa only [next, oldFrame, MachineLazyRows.recordsInput, List.flatMap_nil, List.nil_append, + clean, oldBlock, oldRows, oldOutput] using hrun + +theorem expanderVertexTrace {n : Nat} (d e : Nat) (hd : 0 < d) (he : 0 < e) + (H : ExpanderTables.Table n e) (v : Fin n) (g h gs hs nv mv f current out : List Bool) (a : A) : + (advance (TM2.step (program d e hd he)))^[MachineOverlayRows.vertexSteps d e v.val + (List.ofFn (expanderValues H v)) out] + (some ⟨next (.expander (0, none)), clean d e hd he a, + memory g h gs (expanderBlock H v ++ hs) nv mv f current (encodeWord v.val) out⟩) = + some ⟨next .drainTail, clean d e hd he a, + memory g h gs hs nv mv f current (encodeWord v.val) (out ++ expanderOutput d H v)⟩ := by + let source := MachineStateEquiv.program (expanderState A d e).symm (program d e hd he) + have code (stage : MachineOverlayRows.VertexLabel e) : source (.inr (.expander stage)) = + MachineOverlayRows.vertexInstruction d e he expanderTapes + (fun stage => .inr (.expander stage)) (next .drainTail) stage := by + change MachineStateEquiv.statement (expanderState A d e).symm + (MachineStateEquiv.statement (expanderState A d e) _) = _ + exact MachineStateEquiv.statement_symm_statement _ _ + have native := MachineOverlayRows.vertexTrace d e he expanderTapes expanderTapes_injective + (fun stage => .inr (.expander stage)) (next .drainTail) source code + (memory g h gs hs nv mv f current (encodeWord v.val) []) v.val (expanderValues H v) + rfl + (by + intro i hi0 hi7 hi9 + fin_cases i <;> simp_all [expanderTapes, memory, tail, oldReverse, relation, scratch, + dividedCopy, quotient, newReverse, output, rowBuffer, expanderStream]) + ((a, MachineRegularOriginalRow.zeroBuffer), MachineFixedDivMod.residue d hd 0) out + have transported := MachineStateEquiv.trace (expanderState A d e) source _ _ _ native + have back : MachineStateEquiv.program (expanderState A d e) source = program d e hd he := + MachineStateEquiv.program_symm_program (expanderState A d e).symm _ + rw [back] at transported + simpa only [next, MachineStateEquiv.configuration, expanderState_clean, expanderFrame, + encodeWords, List.nil_append, expanderBlock, expanderOutput] using transported + +theorem tailCopyTrace (d e : Nat) (hd : 0 < d) (he : 0 < e) + (g h gs hs nv mv f out : List Bool) (k : Nat) (a : A) : + (advance (TM2.step (program d e hd he)))^[2 * (k + 1) + 1] + (some ⟨next .tailSeed, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord k) [] out⟩) = + some ⟨next (.expander (0, none)), clean d e hd he a, + memory g h gs hs nv mv f (encodeWord k) (encodeWord k) out⟩ := by + let ambient := (clean d e hd he a).1 + have hrun := MachineUnaryAffineAt.seededAffineTrace vertex scratch tail + (by decide) (by decide) (by decide) 1 0 + (.inr .tailSeed) (.inr .tailScan) (.inr .tailRestore) (next (.expander (0, none))) + (program d e hd he) rfl rfl rfl + (memory g h gs hs nv mv f (encodeWord k) [] out) k [] + (by simp [memory, vertex]) rfl ambient none + simpa only [memory_tail, next, List.append_nil, Nat.one_mul, Nat.add_zero, update_tail, + ambient, clean, MachineLazyRows.streamClean, MachinePortReindex.clean] using hrun + +theorem tailFinishTrace (d e : Nat) (hd : 0 < d) (he : 0 < e) + (g h gs hs nv mv f out : List Bool) (k : Nat) (a : A) : + (advance (TM2.step (program d e hd he)))^[k + 3] + (some ⟨next .drainTail, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord k) (encodeWord k) out⟩) = + some ⟨next .guard, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord (k + 1)) [] out⟩ := by + let ambient := (clean d e hd he a).1 + have hd₀ := MachineDrain.drainTrace tail (.inr .drainTail) (next .increment) + (program d e hd he) rfl (memory g h gs hs nv mv f (encodeWord k) [] out) + (encodeWord k) ambient none + have drain : (advance (TM2.step (program d e hd he)))^[k + 2] + (some ⟨next .drainTail, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord k) (encodeWord k) out⟩) = + some ⟨next .increment, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord k) [] out⟩ := by + simpa only [next, encodeWord_length, Nat.add_assoc, update_tail, ambient, clean, + MachineLazyRows.streamClean, MachinePortReindex.clean] using hd₀ + have increment : (advance (TM2.step (program d e hd he)))^[1] + (some ⟨next .increment, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord k) [] out⟩) = + some ⟨next .guard, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord (k + 1)) [] out⟩ := by + change some (TM2.stepAux (program d e hd he (.inr .increment)) _ _) = _ + simp only [program, mainInstruction, TM2.stepAux, memory_vertex, next, + update_vertex, encodeWord, List.replicate_succ, List.cons_append] + have all := joinTrace drain increment + simpa only [Nat.add_assoc] using all + +def pairSteps {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (v : Fin n) (out : List Bool) : Nat := + MachineLazyRows.vertexSteps d (d + e) 0 (oldRows G v) out + (2 * (v.val + 1) + 1) + + MachineOverlayRows.vertexSteps d e v.val (List.ofFn (expanderValues H v)) + (out ++ oldOutput G e v) + (v.val + 3) + +theorem pairTrace {n : Nat} (d e : Nat) (hd : 0 < d) (he : 0 < e) + (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (v : Fin n) + (g h gs hs nv mv f out : List Bool) (a : A) : + (advance (TM2.step (program d e hd he)))^[pairSteps G H v out] + (some ⟨next (.old (0, none)), clean d e hd he a, + memory g h (oldBlock G v ++ gs) (expanderBlock H v ++ hs) + nv mv f (encodeWord v.val) [] out⟩) = + some ⟨next .guard, clean d e hd he a, + memory g h gs hs nv mv f (encodeWord (v.val + 1)) [] (out ++ outputBlock G H v)⟩ := by + have h₁ := oldVertexTrace d e hd he G v g h gs (expanderBlock H v ++ hs) + nv mv f (encodeWord v.val) out a + have h₂ := tailCopyTrace d e hd he g h gs (expanderBlock H v ++ hs) + nv mv f (out ++ oldOutput G e v) v.val a + have h₃ := expanderVertexTrace d e hd he H v g h gs hs nv mv f + (encodeWord v.val) (out ++ oldOutput G e v) a + have h₄ := tailFinishTrace d e hd he g h gs hs nv mv f + ((out ++ oldOutput G e v) ++ expanderOutput d H v) v.val a + simpa only [pairSteps, outputBlock, List.append_assoc] using + joinTrace (joinTrace (joinTrace h₁ h₂) h₃) h₄ + +def cleanupSteps (n m : Nat) : Nat := 2 * n + m + 8 + +theorem cleanupTrace (d e : Nat) (hd : 0 < d) (he : 0 < e) + (g h out : List Bool) (n m : Nat) (a : A) : + (advance (TM2.step (program d e hd he)))^[cleanupSteps n m] + (some ⟨next .drainFuel, clean d e hd he a, + memory g h [] [] (encodeWord n) (encodeWord m) (encodeWord 0) (encodeWord n) [] out⟩) = + some ⟨none, clean d e hd he a, memory g h [] [] [] [] [] [] [] out⟩ := by + let ambient := (clean d e hd he a).1 + have h₁ := MachineDrain.drainTrace fuel (.inr .drainFuel) (next .drainVertex) + (program d e hd he) rfl + (memory g h [] [] (encodeWord n) (encodeWord m) [] (encodeWord n) [] out) + (encodeWord 0) ambient none + have h₂ := MachineDrain.drainTrace vertex (.inr .drainVertex) (next .drainVertexCount) + (program d e hd he) rfl + (memory g h [] [] (encodeWord n) (encodeWord m) [] [] [] out) + (encodeWord n) ambient none + have h₃ := MachineDrain.drainTrace vertexCount (.inr .drainVertexCount) (next .drainDartCount) + (program d e hd he) rfl (memory g h [] [] [] (encodeWord m) [] [] [] out) + (encodeWord n) ambient none + have h₄ := MachineDrain.drainTrace dartCount (.inr .drainDartCount) none + (program d e hd he) rfl (memory g h [] [] [] [] [] [] [] out) + (encodeWord m) ambient none + simp only [encodeWord_length, update_fuel, update_vertex, update_vertexCount, update_dartCount] at h₁ h₂ h₃ h₄ + have all := joinTrace (joinTrace (joinTrace h₁ h₂) h₃) h₄ + have hsteps : cleanupSteps n m = ((0 + 1 + 1 + (n + 1 + 1)) + (n + 1 + 1)) + (m + 1 + 1) := by + unfold cleanupSteps + omega + rw [hsteps] + exact all + +def rawExpander {n e : Nat} (H : ExpanderTables.Table n e) : List Bool := + encodeWords (ExpanderTableWords.rotationWords H) + +def outputPrefix {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (k : Nat) : List Bool := encodeWords [n, n * (d + e)] ++ emittedPrefix (outputBlock G H) k + +theorem outputPrefix_step {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) : + outputPrefix G H (v.val + 1) = outputPrefix G H v.val ++ outputBlock G H v := by + simp only [outputPrefix, prefix_step, List.append_assoc] + +def loopBase {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (r : Nat) : Tape → List Bool := + memory (PortTables.tableBits G) (rawExpander H) + (remaining (oldBlock G) (n - r)) (remaining (expanderBlock H) (n - r)) + (encodeWord n) (encodeWord (n * d)) [] (encodeWord (n - r)) [] (outputPrefix G H (n - r)) + +def loopCost {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (r : Nat) : Nat := + if hr : r < n then + pairSteps G H ⟨n - (r + 1), by omega⟩ (outputPrefix G H (n - (r + 1))) + else 0 + +theorem loopBodyTraces {n : Nat} (d e : Nat) (hd : 0 < d) (he : 0 < e) + (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (a : A) : + MachineCountedLoop.BodyTraces fuel (.inr .guard) (.inr (.old (0, none))) + (program d e hd he) [] (fun _ => (clean d e hd he a).1) (fun _ => none) + (loopBase G H) (loopCost G H) n := by + intro r hr + let v : Fin n := ⟨n - (r + 1), by omega⟩ + have hv : v.val + 1 = n - r := by dsimp [v]; omega + have hinput : MachineUnaryCounter.counterTapes fuel (loopBase G H (r + 1)) r [] = + memory (PortTables.tableBits G) (rawExpander H) + (oldBlock G v ++ remaining (oldBlock G) (v.val + 1)) + (expanderBlock H v ++ remaining (expanderBlock H) (v.val + 1)) + (encodeWord n) (encodeWord (n * d)) (encodeWord r) (encodeWord v.val) [] + (outputPrefix G H v.val) := by + simp only [MachineUnaryCounter.counterTapes, loopBase, List.append_nil, update_fuel] + change memory _ _ (remaining (oldBlock G) v.val) (remaining (expanderBlock H) v.val) + _ _ _ _ _ _ = _ + rw [remaining_step (oldBlock G) v, remaining_step (expanderBlock H) v] + have houtput : MachineUnaryCounter.counterTapes fuel (loopBase G H r) r [] = + memory (PortTables.tableBits G) (rawExpander H) + (remaining (oldBlock G) (v.val + 1)) (remaining (expanderBlock H) (v.val + 1)) + (encodeWord n) (encodeWord (n * d)) (encodeWord r) (encodeWord (v.val + 1)) [] + (outputPrefix G H v.val ++ outputBlock G H v) := by + simp only [MachineUnaryCounter.counterTapes, loopBase, List.append_nil, update_fuel] + rw [← hv, outputPrefix_step] + have run := pairTrace d e hd he G H v (PortTables.tableBits G) (rawExpander H) + (remaining (oldBlock G) (v.val + 1)) (remaining (expanderBlock H) (v.val + 1)) + (encodeWord n) (encodeWord (n * d)) (encodeWord r) (outputPrefix G H v.val) a + change (advance (TM2.step (program d e hd he)))^[loopCost G H r] + (some ⟨next (.old (0, none)), clean d e hd he a, + MachineUnaryCounter.counterTapes fuel (loopBase G H (r + 1)) r []⟩) = + some ⟨next .guard, clean d e hd he a, + MachineUnaryCounter.counterTapes fuel (loopBase G H r) r []⟩ + rw [hinput, houtput] + simpa only [loopCost, dite_eq_left hr, v] using run + +theorem loopTrace {n : Nat} (d e : Nat) (hd : 0 < d) (he : 0 < e) + (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (a : A) : + (advance (TM2.step (program d e hd he)))^[MachineCountedLoop.totalSteps (loopCost G H) n] + (some ⟨next .guard, clean d e hd he a, + memory (PortTables.tableBits G) (rawExpander H) + (MachineTableSplit.rowsBits (PortTables.graphTable G)) (rawExpander H) + (encodeWord n) (encodeWord (n * d)) (encodeWord n) (encodeWord 0) [] + (encodeWords [n, n * (d + e)])⟩) = + some ⟨next .drainFuel, clean d e hd he a, + memory (PortTables.tableBits G) (rawExpander H) [] [] + (encodeWord n) (encodeWord (n * d)) (encodeWord 0) (encodeWord n) [] + (PortTables.tableBits (PreprocessingOverlayTables.overlay G H))⟩ := by + have run := MachineCountedLoop.loopTrace fuel (.inr .guard) (.inr (.old (0, none))) + (.inr .drainFuel) (program d e hd he) rfl [] + (fun _ => (clean d e hd he a).1) (fun _ => none) (loopBase G H) (loopCost G H) n + (loopBodyTraces d e hd he G H a) + have startFrame : MachineUnaryCounter.counterTapes fuel (loopBase G H n) n [] = + memory (PortTables.tableBits G) (rawExpander H) + (MachineTableSplit.rowsBits (PortTables.graphTable G)) (rawExpander H) + (encodeWord n) (encodeWord (n * d)) (encodeWord n) (encodeWord 0) [] + (encodeWords [n, n * (d + e)]) := by + simp only [MachineUnaryCounter.counterTapes, loopBase, List.append_nil, update_fuel, + Nat.sub_self, remaining_zero, outputPrefix, prefix_zero] + simp only [graphRows_blocks, rawExpander, expanderRows_blocks] + have endFrame : MachineUnaryCounter.counterTapes fuel (loopBase G H 0) 0 [] = + memory (PortTables.tableBits G) (rawExpander H) [] [] + (encodeWord n) (encodeWord (n * d)) (encodeWord 0) (encodeWord n) [] + (PortTables.tableBits (PreprocessingOverlayTables.overlay G H)) := by + simp only [MachineUnaryCounter.counterTapes, loopBase, List.append_nil, update_fuel, + Nat.sub_zero, remaining_end, outputPrefix, prefix_end, tableBits_blocks] + simp only [MachineCountedLoop.guardConfiguration, MachineCountedLoop.exitConfiguration] at run + rw [startFrame, endFrame] at run + simpa only [next, clean, MachineLazyRows.streamClean, MachinePortReindex.clean] using run + +def tableSteps {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) : Nat := + MachineTableSplit.exactSteps n (n * d) (MachineTableSplit.rowsBits (PortTables.graphTable G)) + + preparationSteps n (rawExpander H) + MachineCountedLoop.totalSteps (loopCost G H) n + + cleanupSteps n (n * d) + +theorem tableTrace {n : Nat} (d e : Nat) (hd : 0 < d) (he : 0 < e) + (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (a : A) : + (advance (TM2.step (program d e hd he)))^[tableSteps G H] + (some ⟨some (.inl .copyFirst), clean d e hd he a, + initialTapes (PortTables.tableBits G) (rawExpander H)⟩) = + some ⟨none, clean d e hd he a, + memory (PortTables.tableBits G) (rawExpander H) [] [] [] [] [] [] [] + (PortTables.tableBits (PreprocessingOverlayTables.overlay G H))⟩ := by + have h₁ := splitTrace d e hd he (PortTables.graphTable G) (rawExpander H) a + rw [splitTapes_memory] at h₁ + have header : encodeWords [n, n * d] ++ MachineTableSplit.rowsBits (PortTables.graphTable G) = + PortTables.tableBits G := (MachineTableSplit.tableBits_header_rows (PortTables.graphTable G)).symm + change (advance (TM2.step (program d e hd he)))^[MachineTableSplit.exactSteps n (n * d) + (MachineTableSplit.rowsBits (PortTables.graphTable G))] + (some ⟨some (.inl .copyFirst), clean d e hd he a, + initialTapes (PortTables.tableBits G) (rawExpander H)⟩) = + some ⟨next .copyHFirst, clean d e hd he a, + memory (encodeWords [n, n * d] ++ MachineTableSplit.rowsBits (PortTables.graphTable G)) + (rawExpander H) (MachineTableSplit.rowsBits (PortTables.graphTable G)) [] + (encodeWord n) (encodeWord (n * d)) [] [] [] []⟩ at h₁ + rw [header] at h₁ + have h₂ := preparationTrace d e hd he (PortTables.tableBits G) (rawExpander H) + (MachineTableSplit.rowsBits (PortTables.graphTable G)) n (n * d) a + have h₃ := loopTrace d e hd he G H a + have h₄ := cleanupTrace d e hd he (PortTables.tableBits G) (rawExpander H) + (PortTables.tableBits (PreprocessingOverlayTables.overlay G H)) n (n * d) a + exact joinTrace (joinTrace (joinTrace h₁ h₂) h₃) h₄ + +private theorem flatMap_length_le {α : Type*} (items : List α) (f : α → List Bool) + (B : Nat) (bounded : ∀ x ∈ items, (f x).length ≤ B) : + (items.flatMap f).length ≤ items.length * B := by + induction items with + | nil => simp + | cons x xs ih => + have hx := bounded x (by simp) + have ht := ih (fun y hy => bounded y (by simp [hy])) + simp only [List.flatMap_cons, List.length_append, List.length_cons] + rw [Nat.add_mul, Nat.one_mul] + omega + +private theorem flatten_length_le (items : List (List Bool)) (B : Nat) + (bounded : ∀ x ∈ items, x.length ≤ B) : items.flatten.length ≤ items.length * B := by + simpa only [List.flatMap_id] using flatMap_length_le items id B bounded + +def oldSize (d e n : Nat) : Nat := MachineLazyRows.rowSizeBound (d + e) 0 n (n * d) +def expanderSize (d e n : Nat) : Nat := MachineOverlayRows.rowSizeBound d e n (n * e) +def blockSize (d e n : Nat) : Nat := d * oldSize d e n + e * expanderSize d e n + +theorem oldOutput_length_le {n d : Nat} (G : PortTables.Table n d) (e : Nat) (v : Fin n) : + (oldOutput G e v).length ≤ d * oldSize d e n := by + have bound := flatMap_length_le (oldRows G v) + (fun r => MachineLazyRows.reindexRowBits d (d + e) 0 r.tail.val r.reverseIndex.val r.relation) + (oldSize d e n) (fun r _ => MachineLazyRows.reindexRowBits_length_le d (d + e) 0 r) + simpa only [oldOutput, MachineLazyRows.recordsOutput, oldRows, List.length_ofFn] using bound + +theorem expanderOutput_length_le {n e : Nat} (d : Nat) (H : ExpanderTables.Table n e) + (v : Fin n) : (expanderOutput d H v).length ≤ e * expanderSize d e n := by + have bound := flatMap_length_le (List.ofFn (expanderValues H v)) + (MachineOverlayRows.rowBits d e v.val) (expanderSize d e n) (by + intro j hj + obtain ⟨p, rfl⟩ := List.mem_ofFn.mp hj + have hrow := MachineOverlayRows.rowBits_length_le d e v.val (expanderValues H v p) + (n * e) (MachineOverlayRows.expanderValues_bounded H v p) + have hv := v.isLt.le + unfold expanderSize MachineOverlayRows.rowSizeBound at * + omega) + simpa only [expanderOutput, MachineOverlayRows.streamOutput, List.length_ofFn] using bound + +theorem outputBlock_length_le {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) : + (outputBlock G H v).length ≤ blockSize d e n := by + have hg := oldOutput_length_le G e v + have hh := expanderOutput_length_le d H v + simp only [outputBlock, List.length_append, blockSize] + omega + +def outputCapacity (d e n : Nat) : Nat := n + n * (d + e) + 2 + n * blockSize d e n + +theorem outputPrefix_length_le {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (k : Nat) : + (outputPrefix G H k).length ≤ outputCapacity d e n := by + have hblocks := flatten_length_le ((List.ofFn (outputBlock G H)).take k) + (blockSize d e n) (by + intro xs hx + have hm := List.mem_of_mem_take hx + obtain ⟨v, rfl⟩ := List.mem_ofFn.mp hm + exact outputBlock_length_le G H v) + have hlen : ((List.ofFn (outputBlock G H)).take k).length ≤ n := by + simp only [List.length_take, List.length_ofFn] + exact Nat.min_le_right _ _ + have hcap := Nat.mul_le_mul_right (blockSize d e n) hlen + simp only [outputPrefix, emittedPrefix, List.length_append, encodeWords_length, + List.sum_cons, List.sum_nil, List.length_cons, List.length_nil, Nat.add_zero, outputCapacity] + omega + +def pairBudget (d e n : Nat) : Nat := + (d * (MachineLazyRows.rowCostBound (d + e) 0 n (n * d) + + 2 * (outputCapacity d e n + d * oldSize d e n) + 1) + 1) + + (e * (MachineOverlayRows.rowCostBound d e n (n * e) + + 2 * (outputCapacity d e n + d * oldSize d e n + e * expanderSize d e n) + 1) + 1) + + (3 * n + 6) + +theorem pairSteps_le {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) (out : List Bool) + (hout : out.length ≤ outputCapacity d e n) : pairSteps G H v out ≤ pairBudget d e n := by + have hold := MachineLazyRows.vertexSteps_le d (d + e) 0 (oldRows G v) out + simp only [oldRows, List.length_ofFn] at hold + have hgsize := oldOutput_length_le G e v + have hnew := MachineOverlayRows.vertexSteps_le d e v.val (n * e) + (List.ofFn (expanderValues H v)) (by + intro j hj + obtain ⟨p, rfl⟩ := List.mem_ofFn.mp hj + exact MachineOverlayRows.expanderValues_bounded H v p) (out ++ oldOutput G e v) + simp only [List.length_ofFn, List.length_append] at hnew + have hv := v.isLt.le + have hsize : MachineOverlayRows.rowSizeBound d e v.val (n * e) ≤ expanderSize d e n := by + unfold expanderSize MachineOverlayRows.rowSizeBound + omega + have hcost : MachineOverlayRows.rowCostBound d e v.val (n * e) ≤ + MachineOverlayRows.rowCostBound d e n (n * e) := by + unfold MachineOverlayRows.rowCostBound + change _ ≤ 8 * (n * e) + 4 * expanderSize d e n + _ + _ + 28 + omega + have hsizeMul := Nat.mul_le_mul_left e hsize + have holdBudget := Nat.mul_le_mul_left d + (show MachineLazyRows.rowCostBound (d + e) 0 n (n * d) + + 2 * (out.length + d * MachineLazyRows.rowSizeBound (d + e) 0 n (n * d)) + 1 ≤ + MachineLazyRows.rowCostBound (d + e) 0 n (n * d) + + 2 * (outputCapacity d e n + d * oldSize d e n) + 1 by + unfold oldSize + omega) + have hnewBudget := Nat.mul_le_mul_left e + (show MachineOverlayRows.rowCostBound d e v.val (n * e) + + 2 * (out.length + (oldOutput G e v).length + e * MachineOverlayRows.rowSizeBound d e v.val (n * e)) + 1 ≤ + MachineOverlayRows.rowCostBound d e n (n * e) + + 2 * (outputCapacity d e n + d * oldSize d e n + e * expanderSize d e n) + 1 by omega) + unfold pairSteps pairBudget oldRows + omega + +end IndependentSetsGames.Foundations.Complexity.MachineOverlayTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Remaining2.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Remaining2.lean new file mode 100644 index 0000000000000000000000000000000000000000..8439d92959ed8297bad36a949fc8555985d21fac --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Remaining2.lean @@ -0,0 +1,408 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachinePaddedOverlayRuntime +import OAI.Combinatorics.IndependentSets.Machines.Tape3 + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLazyTable +open Turing MachineComposition PCP +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +def remaining (n r : Nat) : List (Fin n) := (List.finRange n).drop r + +@[simp] theorem remaining_zero (n : Nat) : remaining n 0 = List.finRange n := by simp [remaining] +@[simp] theorem remaining_done (n : Nat) : remaining n n = [] := by simp [remaining] + +theorem remaining_cons (n r : Nat) (h : r < n) : + remaining n r = ⟨r, h⟩ :: remaining n (r + 1) := by + unfold remaining + rw [List.drop_eq_getElem_cons (l := List.finRange n) (i := r) (by simpa using h)] + simp + +def inputBlocks {n d : Nat} (table : PortTables.Table n d) (events : List (Fin n)) : List Bool := + events.flatMap (fun v => MachineLazyRows.recordsInput (List.ofFn (PreprocessingLazyWords.row table v))) + +def outputBlocks {n d : Nat} (table : PortTables.Table n d) (events : List (Fin n)) : List Bool := + events.flatMap (fun v => vertexBlock d v.val (PreprocessingLazyWords.row table v)) + +theorem vertexBlock_codec {n d : Nat} (table : PortTables.Table n d) (v : Fin n) : + vertexBlock d v.val (PreprocessingLazyWords.row table v) = + encodeWords ((PreprocessingLazyWords.vertexRows table v).flatMap GraphTables.rowWords) := by + rw [vertexBlock, MachineLazyCodec.rowsBits_stay, MachineLazyRows.recordsOutput_lazy, + PreprocessingLazyWords.vertexRows, List.flatMap_append, encodeWords_append] + +theorem encodeWords_flatMap {α : Type} (xs : List α) (f : α → List Nat) : + encodeWords (xs.flatMap f) = xs.flatMap (fun x => encodeWords (f x)) := by + induction xs with + | nil => rfl + | cons x xs ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem inputBlocks_codec {n d : Nat} (table : PortTables.Table n d) (events : List (Fin n)) : + inputBlocks table events = encodeWords + ((events.flatMap (fun v => List.ofFn (PreprocessingLazyWords.row table v))).flatMap + GraphTables.rowWords) := by + rw [List.flatMap_assoc, encodeWords_flatMap] + simp only [inputBlocks, MachineLazyRows.recordsInput_eq_codec] + +theorem outputBlocks_codec {n d : Nat} (table : PortTables.Table n d) (events : List (Fin n)) : + outputBlocks table events = encodeWords + ((events.flatMap (PreprocessingLazyWords.vertexRows table)).flatMap GraphTables.rowWords) := by + rw [List.flatMap_assoc, encodeWords_flatMap] + simp only [outputBlocks, vertexBlock_codec] + +theorem input_table_codec {n d : Nat} (table : PortTables.Table n d) : + PortTables.tableBits table = encodeWords [n, n * d] ++ inputBlocks table (List.finRange n) := by + rw [inputBlocks_codec] + change encodeWords (PortTables.tableWords table) = _ + rw [PortTables.tableWords_eq, PreprocessingLazyWords.flatRows_list, encodeWords_append] + have hrows : (List.ofFn (fun v => List.ofFn (PreprocessingLazyWords.row table v))).flatten = + (List.finRange n).flatMap (fun v => List.ofFn (PreprocessingLazyWords.row table v)) := by + rw [List.ofFn_eq_map] + rfl + rw [hrows] + +theorem output_table_codec {n d : Nat} (table : PortTables.Table n d) : + PortTables.tableBits (PreprocessingOverlayTables.lazy table) = + encodeWords [n, 2 * (n * d)] ++ outputBlocks table (List.finRange n) := by + rw [outputBlocks_codec, PreprocessingLazyWords.tableBits_lazy, encodeWords_append] + have hm : n * (2 * d) = 2 * (n * d) := by ac_rfl + have hrows : (List.ofFn (PreprocessingLazyWords.vertexRows table)).flatten = + (List.finRange n).flatMap (PreprocessingLazyWords.vertexRows table) := by + rw [List.ofFn_eq_map] + rfl + exact congrArg₂ List.append (congrArg (fun k => encodeWords [n, k]) hm) + (congrArg (fun rows => encodeWords (rows.flatMap GraphTables.rowWords)) hrows) + +def loopSteps {n d : Nat} (table : PortTables.Table n d) (r : Nat) : Nat → List Bool → Nat + | 0, _ => finishSteps d n (n * d) r + | count + 1, output => if h : r < n then + (1 + bodySteps d r (PreprocessingLazyWords.row table ⟨r, h⟩) output) + + loopSteps table (r + 1) count + (output ++ vertexBlock d r (PreprocessingLazyWords.row table ⟨r, h⟩)) + else 0 + +theorem loopTrace {n d : Nat} (table : PortTables.Table n d) (positive : 0 < d) + (input : List Bool) (count r : Nat) (hsum : r + count = n) (output : List Bool) : + (advance (TM2.step (program d positive)))^[loopSteps table r count output] + (some ⟨some .guard, clean d positive, + loopTapes d input n (n * d) count r (inputBlocks table (remaining n r)) output⟩) = + some ⟨none, clean d positive, + finalTapes input (output ++ outputBlocks table (remaining n r))⟩ := by + induction count generalizing r output with + | zero => + have hr : r = n := by omega + subst r + simpa only [loopSteps, remaining_done, inputBlocks, outputBlocks, List.flatMap_nil, + List.append_nil] using finishTrace d positive input output n (n * d) n + | succ count ih => + have hr : r < n := by omega + let rows := PreprocessingLazyWords.row table (⟨r, hr⟩ : Fin n) + let rest := inputBlocks table (remaining n (r + 1)) + let source := MachineLazyRows.recordsInput (List.ofFn rows) ++ rest + let b₀ := loopTapes d input n (n * d) (count + 1) r source output + let b₁ := loopTapes d input n (n * d) count r source output + have hguard (k : Nat) : MachineUnaryCounter.counterTapes Tape.fuel b₀ k [] = + loopTapes d input n (n * d) k r source output := by + funext t; cases t <;> simp [MachineUnaryCounter.counterTapes, b₀, loopTapes, frame] + have guard := MachineUnaryCounter.guardTrace_succ Tape.fuel .guard .copyVertexFirst + .clearVertices (program d positive) rfl b₀ count [] (clean d positive).1 none + have c₀ : (advance (TM2.step (program d positive)))^[1] + (some ⟨some .guard, clean d positive, b₀⟩) = + some ⟨some .copyVertexFirst, clean d positive, b₁⟩ := by + simpa only [hguard, clean_pair] using guard + have c₁ := bodyTrace d positive input count r rows rest output + have c₂ := ih (r + 1) (by omega) (output ++ vertexBlock d r rows) + have all := joinTrace (joinTrace c₀ c₁) c₂ + have hi : inputBlocks table (remaining n r) = source := by + rw [remaining_cons n r hr] + rfl + have ho : outputBlocks table (remaining n r) = + vertexBlock d r rows ++ outputBlocks table (remaining n (r + 1)) := by + rw [remaining_cons n r hr] + rfl + simpa only [loopSteps, dite_eq_left hr, hi, ho, List.append_assoc] using all + +def totalSteps {n d : Nat} (table : PortTables.Table n d) : Nat := + prefixSteps n (n * d) (inputBlocks table (List.finRange n)) + + loopSteps table 0 n (encodeWords [n, 2 * (n * d)]) + +theorem tableTrace {n d : Nat} (table : PortTables.Table n d) (positive : 0 < d) : + (advance (TM2.step (program d positive)))^[totalSteps table] + (some ⟨some (.split .copyFirst), clean d positive, initialTapes (PortTables.tableBits table)⟩) = + some ⟨none, clean d positive, + finalTapes (PortTables.tableBits table) + (PortTables.tableBits (PreprocessingOverlayTables.lazy table))⟩ := by + have prefixRun := prefixTrace d positive n (n * d) (inputBlocks table (List.finRange n)) + rw [← input_table_codec table] at prefixRun + have loop := loopTrace table positive (PortTables.tableBits table) n 0 (by omega) + (encodeWords [n, 2 * (n * d)]) + simp only [remaining_zero] at loop + have all := joinTrace prefixRun loop + rw [← output_table_codec table] at all + exact all + +private theorem dummyRows_length_le (v e count : Nat) : + (MachineDummyRows.rowsBits v e count).length ≤ count * (v + e + count + 8194) := by + induction count generalizing e with + | zero => simp [MachineDummyRows.rowsBits] + | succ count ih => + simp only [MachineDummyRows.rowsBits, List.length_append, MachineDummyRows.rowBits_length] + have h := ih (e + 1) + have he : v + (e + 1) + count + 8194 = v + e + (count + 1) + 8194 := by omega + rw [he] at h + nlinarith only [h] + +theorem bodySteps_le {n d : Nat} (rows : Fin d → GraphTables.DartRow n (n * d)) + (v L : Nat) (output : List Bool) (hv : v ≤ n) (hn : n ≤ L) (hm : n * d ≤ L) + (ho : output.length ≤ 20000 * (L + 1) ^ 2) : + bodySteps d v rows output ≤ 1000000 * (d + 1) ^ 3 * (L + 1) ^ 2 := by + let D := d + 1 + let N := L + 1 + let P := D * N + let Q := P * P + let S := v + 2 * d * v + d + 8194 + let V := (2 * d) * (n * d) + n * d + d + let R := n + V + 8194 + let C := 2 * n + 8 * (n * d) + V + 4 * R + 8224 + let dummy := MachineDummyRows.rowsBits v (2 * d * v) d + let after := output ++ dummy + have hD : 1 ≤ D := by dsimp [D]; omega + have hN : 1 ≤ N := by dsimp [N]; omega + have hdD : d ≤ D := by dsimp [D]; omega + have hLN : L ≤ N := by dsimp [N]; omega + have hDP : D ≤ P := by + have h := Nat.mul_le_mul_left D hN + simpa [P] using h + have hNP : N ≤ P := by + have h := Nat.mul_le_mul_right N hD + simpa [P] using h + have hP : 1 ≤ P := hN.trans hNP + have hPQ : P ≤ Q := by + have h := Nat.mul_le_mul_right P hP + simpa [Q] using h + have hQ : 1 ≤ Q := hP.trans hPQ + have hdP : d ≤ P := hdD.trans hDP + have hvN : v ≤ N := hv.trans (hn.trans hLN) + have hvP : v ≤ P := hvN.trans hNP + have hnP : n ≤ P := hn.trans (hLN.trans hNP) + have hmN : n * d ≤ N := hm.trans hLN + have hmP : n * d ≤ P := hmN.trans hNP + have hdv : d * v ≤ P := by simpa [P] using Nat.mul_le_mul hdD hvN + have hdm : d * (n * d) ≤ P := by simpa [P] using Nat.mul_le_mul hdD hmN + have hdPQ : d * P ≤ Q := by simpa [Q] using Nat.mul_le_mul_right P hdP + have hNQ : N ^ 2 ≤ Q := by simpa [pow_two, Q] using Nat.mul_le_mul hNP hNP + have hS : S ≤ 10000 * P := by + have hconst := Nat.mul_le_mul_left 8194 hP + dsimp [S] + nlinarith only [hvP, hdP, hdv, hconst, hP] + have hV : V ≤ 4 * P := by + dsimp [V] + nlinarith only [hdm, hmP, hdP] + have hR : R ≤ 10000 * P := by + have hconst := Nat.mul_le_mul_left 8194 hP + dsimp [R] + nlinarith only [hnP, hV, hconst, hP] + have hC : C ≤ 50000 * P := by + have hconst := Nat.mul_le_mul_left 8224 hP + dsimp [C] + nlinarith only [hnP, hmP, hV, hR, hconst, hP] + have hSQ : S ≤ 10000 * Q := hS.trans (Nat.mul_le_mul_left 10000 hPQ) + have hCQ : C ≤ 50000 * Q := hC.trans (Nat.mul_le_mul_left 50000 hPQ) + have hdSQ : d * S ≤ 10000 * Q := by + calc + d * S ≤ d * (10000 * P) := Nat.mul_le_mul_left d hS + _ = 10000 * (d * P) := by ring + _ ≤ 10000 * Q := Nat.mul_le_mul_left 10000 hdPQ + have hdRQ : d * R ≤ 10000 * Q := by + calc + d * R ≤ d * (10000 * P) := Nat.mul_le_mul_left d hR + _ = 10000 * (d * P) := by ring + _ ≤ 10000 * Q := Nat.mul_le_mul_left 10000 hdPQ + have hOut : output.length ≤ 20000 * Q := by + change output.length ≤ 20000 * N ^ 2 at ho + exact ho.trans (Nat.mul_le_mul_left 20000 hNQ) + have hDummyLength : dummy.length ≤ 10000 * Q := by + have h := dummyRows_length_le v (2 * d * v) d + change dummy.length ≤ d * S at h + exact h.trans hdSQ + have hAfter : after.length ≤ 30000 * Q := by + dsimp [after] + rw [List.length_append] + omega + have hDummyInside : 4 * S + 2 * (output.length + d * S) + 10 ≤ 100010 * Q := by + have hconst := Nat.mul_le_mul_left 10 hQ + nlinarith only [hSQ, hOut, hdSQ, hconst] + have hDummySteps : MachineDummyRows.steps v (2 * d * v) output d ≤ 100010 * d * Q := by + calc + MachineDummyRows.steps v (2 * d * v) output d ≤ + d * (4 * S + 2 * (output.length + d * S) + 10) := by + simpa only [S] using MachineDummyRows.steps_le_bound v (2 * d * v) output d + _ ≤ d * (100010 * Q) := Nat.mul_le_mul_left d hDummyInside + _ = 100010 * d * Q := by ring + have hOldInside : C + 2 * (after.length + d * R) + 1 ≤ 130001 * Q := by + nlinarith only [hCQ, hAfter, hdRQ, hQ] + have hOldSteps : MachineLazyRows.vertexSteps d (2 * d) d (List.ofFn rows) after ≤ + 130001 * d * Q + 1 := by + have h := MachineLazyRows.vertexSteps_le d (2 * d) d (List.ofFn rows) after + simp only [List.length_ofFn] at h + change MachineLazyRows.vertexSteps d (2 * d) d (List.ofFn rows) after ≤ + d * (C + 2 * (after.length + d * R) + 1) + 1 at h + calc + MachineLazyRows.vertexSteps d (2 * d) d (List.ofFn rows) after ≤ + d * (C + 2 * (after.length + d * R) + 1) + 1 := h + _ ≤ d * (130001 * Q) + 1 := + Nat.add_le_add_right (Nat.mul_le_mul_left d hOldInside) 1 + _ = 130001 * d * Q + 1 := by ring + have hvQ : v ≤ Q := hvP.trans hPQ + have hOverhead : 3 * v + 8201 ≤ 10000 * Q := by + have hconst := Nat.mul_le_mul_left 8201 hQ + nlinarith only [hvQ, hconst, hQ] + have hBody : bodySteps d v rows output ≤ 230011 * d * Q + 10000 * Q + 1 := by + change 2 * (v + 2) + (MachineDummyRows.steps v (2 * d * v) output d + 1) + + (v + 2) + 8193 + MachineLazyRows.vertexSteps d (2 * d) d (List.ofFn rows) after + 1 ≤ _ + nlinarith only [hDummySteps, hOldSteps, hOverhead] + have hdQQ : d * Q ≤ D * Q := Nat.mul_le_mul_right Q hdD + have hQQ : Q ≤ D * Q := by simpa using Nat.mul_le_mul_right Q hD + have hDQ : 1 ≤ D * Q := hQ.trans hQQ + have hCoarse : bodySteps d v rows output ≤ 300000 * D * Q := by + nlinarith only [hBody, hdQQ, hQQ, hDQ] + calc + bodySteps d v rows output ≤ 300000 * D * Q := hCoarse + _ ≤ 1000000 * D * Q := by + have h := Nat.mul_le_mul_right (D * Q) (by norm_num : (300000 : Nat) ≤ 1000000) + simpa only [Nat.mul_assoc] using h + _ = 1000000 * (d + 1) ^ 3 * (L + 1) ^ 2 := by dsimp [D, N, P, Q]; ring + +theorem output_length_le {n d : Nat} (table : PortTables.Table n d) : + (PortTables.tableBits (PreprocessingOverlayTables.lazy table)).length ≤ + 20000 * ((PortTables.tableBits table).length + 1) ^ 2 := by + let L := (PortTables.tableBits table).length + have hn : n ≤ L := PortTables.vertices_le_tableBits_length table + have hm : n * d ≤ L := GraphTables.darts_le_tableBits_length (PortTables.graphTable table) + have h := GraphTables.tableBits_length_le + (PortTables.graphTable (PreprocessingOverlayTables.lazy table)) + change (PortTables.tableBits (PreprocessingOverlayTables.lazy table)).length ≤ + n + n * (2 * d) + 2 + n * (2 * d) * (n + n * (2 * d) + 8192) at h + have hdouble : n * (2 * d) = 2 * (n * d) := by ac_rfl + rw [hdouble] at h + have hmul := Nat.mul_le_mul (Nat.mul_le_mul_left 2 hm) + (Nat.add_le_add_right (Nat.add_le_add hn (Nat.mul_le_mul_left 2 hm)) 8192) + change _ ≤ 20000 * (L + 1) ^ 2 + nlinarith only [h, hn, hm, hmul] + +theorem loopSteps_le {n d : Nat} (table : PortTables.Table n d) (L count r : Nat) + (hsum : r + count = n) (hn : n ≤ L) (hm : n * d ≤ L) (output : List Bool) + (hout : (output ++ outputBlocks table (remaining n r)).length ≤ 20000 * (L + 1) ^ 2) : + loopSteps table r count output ≤ + count * (1 + 1000000 * (d + 1) ^ 3 * (L + 1) ^ 2) + 5 * L + 11 := by + induction count generalizing r output with + | zero => + have hr : r = n := by omega + subst r + have hdouble : 2 * d * n = 2 * (n * d) := by ac_rfl + simp only [loopSteps, finishSteps, Nat.zero_mul, Nat.zero_add, hdouble] + omega + | succ count ih => + have hr : r < n := by omega + let rows := PreprocessingLazyWords.row table (⟨r, hr⟩ : Fin n) + have ho : output.length ≤ 20000 * (L + 1) ^ 2 := by + rw [List.length_append] at hout + omega + have hb := bodySteps_le rows r L output hr.le hn hm ho + have hs : outputBlocks table (remaining n r) = + vertexBlock d r rows ++ outputBlocks table (remaining n (r + 1)) := by + rw [remaining_cons n r hr] + rfl + have hout' : ((output ++ vertexBlock d r rows) ++ + outputBlocks table (remaining n (r + 1))).length ≤ 20000 * (L + 1) ^ 2 := by + simpa only [hs, List.append_assoc] using hout + have ht := ih (r + 1) (by omega) (output ++ vertexBlock d r rows) hout' + simp only [loopSteps, dite_eq_left hr] + change (1 + bodySteps d r rows output) + + loopSteps table (r + 1) count (output ++ vertexBlock d r rows) ≤ _ + nlinarith only [hb, ht] + +noncomputable def timePolynomial (d : Nat) : Polynomial Nat := + Polynomial.C (1000000 * (d + 1) ^ 3 + 100) * (Polynomial.X + 1) ^ 3 + +@[simp] theorem timePolynomial_eval (d L : Nat) : + (timePolynomial d).eval L = (1000000 * (d + 1) ^ 3 + 100) * (L + 1) ^ 3 := by + simp [timePolynomial] + +theorem totalSteps_le {n d : Nat} (table : PortTables.Table n d) : + totalSteps table ≤ (timePolynomial d).eval (PortTables.tableBits table).length := by + let L := (PortTables.tableBits table).length + let N := L + 1 + let C := 1000000 * (d + 1) ^ 3 + have hn : n ≤ L := PortTables.vertices_le_tableBits_length table + have hm : n * d ≤ L := GraphTables.darts_le_tableBits_length (PortTables.graphTable table) + have hout : (encodeWords [n, 2 * (n * d)] ++ + outputBlocks table (remaining n 0)).length ≤ 20000 * (L + 1) ^ 2 := by + rw [remaining_zero, ← output_table_codec] + exact output_length_le table + have hl := loopSteps_le table L n 0 (by omega) hn hm _ hout + have hp : prefixSteps n (n * d) (inputBlocks table (List.finRange n)) ≤ 10 * L + 17 := by + unfold prefixSteps + rw [← input_table_codec table] + change 2 * L + 5 * n + 3 * (n * d) + 17 ≤ _ + omega + have hN : 1 ≤ N := by dsimp [N]; omega + have hnN : n ≤ N := by dsimp [N]; omega + have hN2 : 1 ≤ N ^ 2 := by nlinarith only [hN] + have hN3 : N ≤ N ^ 3 := by + have h := Nat.mul_le_mul_left N hN2 + nlinarith only [h] + have hc := Nat.mul_le_mul_right (1 + C * N ^ 2) hnN + change loopSteps table 0 n (encodeWords [n, 2 * (n * d)]) ≤ n * (1 + C * N ^ 2) + 5 * L + 11 at hl + rw [timePolynomial_eval] + change totalSteps table ≤ (C + 100) * N ^ 3 + unfold totalSteps + have hLN : L + 1 = N := rfl + nlinarith only [hp, hl, hc, hN, hN3, hLN] + +def machine (d : Nat) (positive : 0 < d) : FinTM2 where + K := Tape + k₀ := .input + k₁ := .output + Γ _ := Bool + Λ := Label d + main := .split .copyFirst + σ := State d + initialState := clean d positive + m := program d positive + +theorem machine_alphabet_finite (d : Nat) (positive : 0 < d) : + ∀ k, Finite ((machine d positive).Γ k) := by + intro k + change Finite Bool + infer_instance + +theorem initial_configuration (d : Nat) (positive : 0 < d) (input : List Bool) : + initList (machine d positive) input = + ⟨some (.split .copyFirst), clean d positive, initialTapes input⟩ := by + have ht : (initList (machine d positive) input).stk = initialTapes input := by + funext tape; cases tape <;> rfl + exact congrArg (TM2.Cfg.mk _ _) ht + +@[simp] theorem finalTapes_input (input output : List Bool) : finalTapes input output .input = input := rfl +@[simp] theorem finalTapes_output (input output : List Bool) : finalTapes input output .output = output := rfl + +theorem finalTapes_work_empty (input output : List Bool) (t : Tape) + (hi : t ≠ .input) (ho : t ≠ .output) : finalTapes input output t = [] := by + cases t <;> simp_all [finalTapes, frame] + +def machineInTime {n d : Nat} (table : PortTables.Table n d) (positive : 0 < d) : + StateTransition.EvalsToInTime (machine d positive).step + (initList (machine d positive) (PortTables.tableBits table)) + (some ⟨none, clean d positive, finalTapes (PortTables.tableBits table) + (PortTables.tableBits (PreprocessingOverlayTables.lazy table))⟩) + ((timePolynomial d).eval (PortTables.tableBits table).length) where + steps := totalSteps table + evals_in_steps := by + rw [initial_configuration] + exact tableTrace table positive + steps_le_m := totalSteps_le table + +end IndependentSetsGames.Foundations.Complexity.MachineLazyTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Represented.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Represented.lean new file mode 100644 index 0000000000000000000000000000000000000000..04fac09b351d9333916eb4ae319cadb687b02cb7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Represented.lean @@ -0,0 +1,222 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.FramedLen + +namespace OAI + +namespace IndependentSetsCut.CounterMachine.Expr +open scoped BigOperators +open Finset +attribute [local instance] Classical.propDecidable + +def Represented (f : List Bool → (ℕ → ℕ) → ℕ) : Prop := + ∃ e : Expr, ∀ input args, e.eval input args = f input args + +namespace Represented +variable {f g h : List Bool → (ℕ → ℕ) → ℕ} +theorem const (n : ℕ) : Represented (fun _ _ => n) := ⟨.const n, by intros; rfl⟩ +theorem arg (k : ℕ) : Represented (fun _ a => a k) := ⟨.arg k, by intros; rfl⟩ +theorem word (hf : Represented f) : Represented (fun s a => wordValue s (f s a)) := by + obtain ⟨e,he⟩ := hf; exact ⟨Expr.word e, by intros; simp [he]⟩ +theorem add (hf : Represented f) (hg : Represented g) : Represented (fun s a => f s a+g s a) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg; exact ⟨.add e d, by intros; simp [eval,he,hd]⟩ +theorem sub (hf : Represented f) (hg : Represented g) : Represented (fun s a => f s a-g s a) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg; exact ⟨.sub e d, by intros; simp [eval,he,hd]⟩ +theorem mul (hf : Represented f) (hg : Represented g) : Represented (fun s a => f s a*g s a) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg; exact ⟨.mul e d, by intros; simp [eval,he,hd]⟩ +theorem div (hf : Represented f) (hg : Represented g) : Represented (fun s a => f s a/g s a) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg; exact ⟨quotient e d, by intros; simp [he,hd]⟩ +theorem mod (hf : Represented f) (hg : Represented g) : Represented (fun s a => f s a%g s a) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg; exact ⟨remainder e d, by intros; simp [he,hd]⟩ +theorem pow (hf : Represented f) (n : ℕ) : Represented (fun s a => f s a^n) := by + obtain ⟨e,he⟩ := hf; exact ⟨power e n, by intros; simp [he]⟩ +theorem eq (hf : Represented f) (hg : Represented g) : + Represented (fun s a => if f s a=g s a then 1 else 0) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg; exact ⟨equal e d, by intros; simp [he,hd]⟩ +theorem lt (hf : Represented f) (hg : Represented g) : + Represented (fun s a => if f s a if f s a ≠ 0 then g s a else h s a) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg; obtain ⟨c,hc⟩ := hh + exact ⟨Expr.cond e d c, by intros; simp [he,hd,hc]⟩ +theorem sum (hf : Represented f) (hg : Represented g) : + Represented (fun s a => ∑ i ∈ range (f s a), g s (bind a i)) := by + obtain ⟨e,he⟩ := hf; obtain ⟨d,hd⟩ := hg + exact ⟨.sum e d, by intros; simp [eval,he,hd]⟩ +theorem finiteSum {I : Type} [Fintype I] {f : I → List Bool → (ℕ → ℕ) → ℕ} + (hf : ∀ i, Represented (f i)) : Represented (fun s a => ∑ i, f i s a) := by + choose e he using hf + exact ⟨Expr.finiteSum e, by intros; simp [he]⟩ +theorem rename (hf : Represented f) (r : ℕ → ℕ) : + Represented (fun s a => f s (fun k => a (r k))) := by + obtain ⟨e,he⟩ := hf + exact ⟨e.rename r, by intros; simp [he]⟩ +theorem subst (hf : Represented f) {v : ℕ → List Bool → (ℕ → ℕ) → ℕ} + (hv : ∀ k, Represented (v k)) : Represented (fun s a => f s (fun k => v k s a)) := by + obtain ⟨e,he⟩ := hf; choose d hd using hv + exact ⟨e.subst d, by intros; simp [he,hd]⟩ +theorem congr (hf : Represented f) (h : ∀ s a, f s a=g s a) : Represented g := by + obtain ⟨e,he⟩ := hf; exact ⟨e, fun s a => (he s a).trans (h s a)⟩ +end Represented +end IndependentSetsCut.CounterMachine.Expr +namespace IndependentSetsCut.CounterMachine.UnaryTables + +section +open scoped BigOperators +open Finset + +def offset (f : ℕ → ℕ) (n : ℕ) : ℕ := ∑ j ∈ range n, (f j + 1) + +def words (f : ℕ → ℕ) (n : ℕ) : List Bool := + ((List.range n).map f).flatMap (fun v => List.replicate v true ++ [false]) + +lemma offset_succ (f : ℕ → ℕ) (n : ℕ) : + offset f (n+1) = offset f n + (f n+1) := by simp [offset, sum_range_succ] + +lemma offset_mono (f : ℕ → ℕ) : Monotone (offset f) := by + apply monotone_nat_of_le_succ + intro n + rw [offset_succ] + omega + +lemma words_succ (f : ℕ → ℕ) (n : ℕ) : + words f (n+1) = words f n ++ (List.replicate (f n) true ++ [false]) := by + simp [words,List.range_succ,List.flatMap_append] + +lemma words_length (f : ℕ → ℕ) (n : ℕ) : (words f n).length = offset f n := by + induction n with + | zero => simp [words,offset] + | succ n ih => simp [words_succ,ih,offset_succ] + +lemma get_word (v i : ℕ) : + ((List.replicate v true ++ [false])[i]?).getD false = true ↔ i < v := by + by_cases h : i < v + · rw [List.getElem?_append_left (by simpa using h)] + simp [h] + · rw [List.getElem?_append_right (by simpa using Nat.le_of_not_gt h)] + simp only [List.length_replicate] + cases e : i-v with + | zero => simp [h] + | succ j => simp [h] + +lemma words_bit (f : ℕ → ℕ) (n i : ℕ) : + ((words f n)[i]?).getD false = true ↔ + ∃ j < n, offset f j ≤ i ∧ i < offset f j + f j := by + induction n with + | zero => simp [words] + | succ n ih => + rw [words_succ] + by_cases h : i < offset f n + · rw [List.getElem?_append_left (by simpa [words_length] using h),ih] + constructor + · rintro ⟨j,hj,hl,hu⟩; exact ⟨j,Nat.lt_succ_of_lt hj,hl,hu⟩ + · rintro ⟨j,hj,hl,hu⟩ + have hj' : j < n := by + by_contra hn + have : j = n := by omega + subst j + omega + exact ⟨j,hj',hl,hu⟩ + · rw [List.getElem?_append_right (by simpa [words_length] using Nat.le_of_not_gt h), + words_length,get_word] + constructor + · intro hi; exact ⟨n,by omega,by omega,by omega⟩ + · rintro ⟨j,hj,hl,hu⟩ + have hjn : j = n := by + by_contra hne + have hj' : j+1 ≤ n := by omega + have hp := offset_mono f hj' + rw [offset_succ] at hp + omega + subst j + omega + +lemma indicator_exists (p : ℕ → Prop) [DecidablePred p] (n : ℕ) : + (∑ j ∈ range n, if p j then 1 else 0) ≠ 0 ↔ ∃ j < n, p j := by + rw [← Nat.pos_iff_ne_zero,Finset.sum_pos_iff_of_nonneg (fun _ _ => Nat.zero_le _)] + simp only [Finset.mem_range] + constructor + · rintro ⟨j,hj,hv⟩ + exact ⟨j,hj,by by_contra hp; simp [hp] at hv⟩ + · rintro ⟨j,hj,hp⟩ + exact ⟨j,hj,by simp [hp]⟩ + +open scoped BigOperators +open Finset +open IndependentSetsCut.CounterMachine.Expr + +def atIndex (v i : Expr) : Expr := v.subst (fun _ => i) +def closed (n : Expr) : Expr := atIndex n (.const 0) +def totalLength (n v : Expr) : Expr := + .sum (closed n) (.add (atIndex v (.arg 0)) (.const 1)) +def startOffset (v : Expr) : Expr := + .sum (.arg 0) (.add (atIndex v (.arg 0)) (.const 1)) +def wordBit (n v : Expr) : Expr := + .sum (closed n) (.mul (Expr.le (startOffset v) (.arg 1)) + (Expr.lt (.arg 1) (.add (startOffset v) (atIndex v (.arg 0))))) + +@[simp] lemma atIndex_eval (v i : Expr) (s : List Bool) (a : ℕ → ℕ) : + (atIndex v i).eval s a = v.eval s (fun _ => i.eval s a) := by + simp [atIndex] +@[simp] lemma closed_eval (n : Expr) (s : List Bool) (a : ℕ → ℕ) : + (closed n).eval s a = n.eval s (fun _ => 0) := by simp [closed,Expr.eval] +@[simp] lemma totalLength_eval (n v : Expr) (s : List Bool) (a : ℕ → ℕ) : + (totalLength n v).eval s a = offset (fun j => v.eval s (fun _ => j)) + (n.eval s (fun _ => 0)) := by + simp [totalLength,Expr.eval,Expr.bind,offset] +@[simp] lemma startOffset_eval (v : Expr) (s : List Bool) (a : ℕ → ℕ) : + (startOffset v).eval s a = offset (fun j => v.eval s (fun _ => j)) (a 0) := by + simp [startOffset,Expr.eval,Expr.bind,offset] +lemma wordBit_eval (n v : Expr) (s : List Bool) (a : ℕ → ℕ) : + (wordBit n v).eval s a = ∑ j ∈ range (n.eval s (fun _ => 0)), + if offset (fun j => v.eval s (fun _ => j)) j ≤ a 0 ∧ + a 0 < offset (fun j => v.eval s (fun _ => j)) j + v.eval s (fun _ => j) + then 1 else 0 := by + simp only [wordBit,Expr.eval,closed_eval,Expr.le_eval,Expr.lt_eval, + startOffset_eval,atIndex_eval,Expr.bind,Expr.indicator_and] + +lemma table_eq_words (n v : Expr) (s : List Bool) : + table (totalLength n v) (wordBit n v) s = + words (fun j => v.eval s (fun _ => j)) (n.eval s (fun _ => 0)) := by + apply List.ext_getElem + · simp [table,words_length] + · intro i hi hj + simp only [table,List.getElem_ofFn] + have hw := words_bit (fun j => v.eval s (fun _ => j)) (n.eval s (fun _ => 0)) i + rw [List.getElem?_eq_getElem hj,Option.getD_some] at hw + apply Bool.eq_iff_iff.mpr + simpa only [decide_eq_true_eq,wordBit_eval,indicator_exists] using hw.symm + +noncomputable def computer (n v : Expr) : + Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) id + (fun s => words (fun j => v.eval s (fun _ => j)) (n.eval s (fun _ => 0))) where + tm := (tableComputer (totalLength n v) (wordBit n v)).tm + inputAlphabet := (tableComputer (totalLength n v) (wordBit n v)).inputAlphabet + outputAlphabet := (tableComputer (totalLength n v) (wordBit n v)).outputAlphabet + time := (tableComputer (totalLength n v) (wordBit n v)).time + outputsFun s := by + simpa only [table_eq_words] using + (tableComputer (totalLength n v) (wordBit n v)).outputsFun s + +lemma computer_finiteAlphabet (n v : Expr) (k : (computer n v).tm.K) : + Finite ((computer n v).tm.Γ k) := by + exact tableComputer_finiteAlphabet (totalLength n v) (wordBit n v) k +end + +noncomputable def encodedComputer {α β : Type} (ea : α → List Bool) (eb : β → List Bool) + (f : α → β) (n v : Expr) + (spec : ∀ a, words (fun j => v.eval (ea a) (fun _ => j)) + (n.eval (ea a) (fun _ => 0)) = eb (f a)) : + Turing.TM2ComputableInPolyTime ea eb f where + tm := (computer n v).tm + inputAlphabet := (computer n v).inputAlphabet + outputAlphabet := (computer n v).outputAlphabet + time := (computer n v).time + outputsFun a := by simpa only [spec, id_eq] using (computer n v).outputsFun (ea a) + +lemma encodedComputer_finiteAlphabet {α β : Type} (ea : α → List Bool) (eb : β → List Bool) + (f : α → β) (n v : Expr) (spec) (k : (encodedComputer ea eb f n v spec).tm.K) : + Finite ((encodedComputer ea eb f n v spec).tm.Γ k) := computer_finiteAlphabet n v k +end IndependentSetsCut.CounterMachine.UnaryTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Restrict.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Restrict.lean new file mode 100644 index 0000000000000000000000000000000000000000..643ce07730ba174e695e8142e0af4feef631f05c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Restrict.lean @@ -0,0 +1,225 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.LengthLoop +import OAI.Combinatorics.IndependentSets.Machines.ValuePolynomial + +namespace OAI + +namespace IndependentSetsCut.CounterMachine + + def Data.restrict (N : ℕ) (d : Data ℕ) : Data (Fin N) := + ⟨fun r => d.reg r.val, d.input, d.backup, d.output⟩ + +namespace Command + + def Bounded (N : ℕ) : Command ℕ → Prop + | .skip | .write _ | .discard | .rewind => True + | .inc r | .dec r => r < N + | .seq a b => Bounded N a ∧ Bounded N b + | .test r a b => r < N ∧ Bounded N a ∧ Bounded N b + | .read a b c => Bounded N a ∧ Bounded N b ∧ Bounded N c + | .loop r b => r < N ∧ Bounded N b + + def regCount : Command ℕ → ℕ + | .skip | .write _ | .discard | .rewind => 0 + | .inc r | .dec r => r+1 + | .seq a b => max a.regCount b.regCount + | .test r a b => max (r+1) (max a.regCount b.regCount) + | .read a b c => max a.regCount (max b.regCount c.regCount) + | .loop r b => max (r+1) b.regCount + + theorem bounded_of_count (c : Command ℕ) (N : ℕ) (h : c.regCount ≤ N) : c.Bounded N := by + induction c <;> simp_all [Bounded, regCount] + + def restrict (N : ℕ) : (c : Command ℕ) → Bounded N c → Command (Fin N) + | .skip, _ => .skip + | .inc r, h => .inc ⟨r,h⟩ + | .dec r, h => .dec ⟨r,h⟩ + | .write b, _ => .write b + | .discard, _ => .discard + | .rewind, _ => .rewind + | .seq a b, h => .seq (restrict N a h.1) (restrict N b h.2) + | .test r a b, h => .test ⟨r,h.1⟩ (restrict N a h.2.1) (restrict N b h.2.2) + | .read a b c, h => .read (restrict N a h.1) (restrict N b h.2.1) (restrict N c h.2.2) + | .loop r b, h => .loop ⟨r,h.1⟩ (restrict N b h.2) + + theorem restrict_inc (N : ℕ) (d : Data ℕ) (r : ℕ) (h : r hu (congrArg Fin.val he) + simp [hu, he] + all_goals rfl + + theorem restrict_dec (N : ℕ) (d : Data ℕ) (r : ℕ) (h : r hu (congrArg Fin.val he) + simp [hu, he] + all_goals rfl + + theorem Evaluates.restrict {c : Command ℕ} {d e : Data ℕ} {n : ℕ} + (he : Evaluates c d e n) (N : ℕ) (h : Bounded N c) : + Evaluates (c.restrict N h) (d.restrict N) (e.restrict N) n := by + induction he with + | skip d => exact Evaluates.skip _ + | inc d r => simpa only [Command.restrict, restrict_inc N d r h] using Evaluates.inc (d.restrict N) ⟨r,h⟩ + | dec d r => simpa only [Command.restrict, restrict_dec N d r h] using Evaluates.dec (d.restrict N) ⟨r,h⟩ + | write d b => exact Evaluates.write _ _ + | discard d => exact Evaluates.discard _ + | rewind_empty hh => exact Evaluates.rewind_empty hh + | rewind_cons hh he ih => exact Evaluates.rewind_cons hh (ih trivial) + | seq h1 h2 i1 i2 => exact (i1 h.1).seq (i2 h.2) + | test_zero hr he ih => exact Evaluates.test_zero hr (ih h.2.1) + | test_pos hr he ih => exact Evaluates.test_pos hr (ih h.2.2) + | read_one hr he ih => exact Evaluates.read_one hr (ih h.1) + | read_zero hr he ih => exact Evaluates.read_zero hr (ih h.2.1) + | read_empty hr he ih => exact Evaluates.read_empty hr (ih h.2.2) + | loop_zero hr => exact Evaluates.loop_zero hr + | @loop_pos r b d e f n m hr h1 h2 i1 i2 => + exact Evaluates.loop_pos hr (by simpa only [restrict_dec N d r h.1] using i1 h.2) (i2 h) + + def finite (c : Command ℕ) : Command (Fin c.regCount) := + c.restrict c.regCount (c.bounded_of_count _ le_rfl) + + theorem finite_evaluates {c : Command ℕ} {d e : Data ℕ} {n : ℕ} + (h : Evaluates c d e n) : Evaluates c.finite (d.restrict c.regCount) (e.restrict c.regCount) n := + h.restrict _ _ + +end Command + +open scoped BigOperators +open Command + +def table (len bit : Expr) (input : List Bool) : List Bool := + List.ofFn (fun i : Fin (len.eval input (fun _ => 0)) => + decide (bit.eval input (fun _ => i.val) ≠ 0)) + + def emit (r : ℕ) : Command ℕ := .test r (.write false) (.seq (clear r) (.write true)) + + theorem emit_evaluates (d : Data ℕ) (r : ℕ) : + Within (emit r) d (writeData (d.set r 0) (decide (d.reg r ≠ 0))) (2*d.reg r+3) := by + by_cases hr : d.reg r = 0 + · refine ⟨2, by omega, ?_⟩ + have h := Evaluates.test_zero (r := r) (b := .seq (clear r) (.write true)) hr + (Evaluates.write d false) + have hd : d.set r 0 = d := by rw [← hr, Data.set_self] + simpa [emit, hr, hd] using h + · have h := Evaluates.test_pos (a := .write false) hr + ((clear_evaluates d r).seq (Evaluates.write (d.set r 0) true)) + exact ⟨1+(2*d.reg r+1+1), by omega, by simpa [emit, hr] using h⟩ + + def print (len bit : Expr) : Command ℕ := + .seq (len.compile (fun _ => 0) 1) + (.loop 1 (.seq (bit.compile (fun _ => 1) 2) (emit 2))) + + theorem print_evaluates (len bit : Expr) (input : List Bool) : + Within (print len bit) (initial input) + {initial input with output := table len bit input} + (len.timeBudget input.length+len.valueBudget input.length* + (bit.timeBudget (input.length+len.valueBudget input.length)+ + 2*bit.valueBudget (input.length+len.valueBudget input.length)+4)+1) := by + let d : Data ℕ := initial input + let L := len.eval input (fun _ => 0) + let V := len.valueBudget input.length + let M := input.length+V + let T := bit.timeBudget M + let W := bit.valueBudget M + let out := table len bit input + have hL : L ≤ V := len.eval_le input _ _ le_rfl (by simp) + have holen : out.length = L := by simp [out, table, L] + let state : ℕ → Data ℕ := fun i => {d.set 1 i with output := out.drop i} + have hlen := len.correct (fun _ => 0) 1 d input.length (by omega) + (by intro r hr; rfl) rfl le_rfl (by simp [d, initial]) + have hstart : state L = d.set 1 L := by + simp [state, ← holen, d, initial, Data.set] + have hloop : Within (.loop 1 (.seq (bit.compile (fun _ => 1) 2) (emit 2))) + (state L) (state 0) (L*(T+2*W+4)+1) := by + apply Within.loop 1 _ state L (T+2*W+3) + · intro i hi; simp [state] + · intro i hi + let e := decData (state (i+1)) 1 + have heReg : e.reg = Function.update (fun _ => 0) 1 i := by + simp [e, state, decData, Data.set, d, initial] + have heClean : e.Clean 2 := by + intro r hr + rw [heReg] + simp [show r ≠ 1 by omega] + have heAt : e.reg 1 = i := by simp [heReg] + have heArg : (fun u : ℕ => e.reg ((fun _ => 1) u)) = (fun _ => i) := by + funext u; simp [heReg] + have hc := bit.correct (fun _ => 1) 2 e M (by omega) heClean rfl + (by change input.length ≤ M; dsimp [M]; omega) + (by intro u; rw [heAt]; dsimp [M]; omega) + rw [heArg] at hc + let B := bit.eval input (fun _ => i) + change Within _ e (e.set 2 B) T at hc + have hemit := emit_evaluates (e.set 2 B) 2 + have hd : (e.set 2 B).set 2 0 = e := by + rw [Data.set_set, Data.set_clean_zero heClean le_rfl] + simp only [hd, Data.set_reg_same] at hemit + have hh := hc.seq hemit + have hdrop : decide (B ≠ 0) :: out.drop (i+1) = out.drop i := by + have hi' : i < out.length := by omega + rw [← List.getElem_cons_drop hi'] + congr 1 + simp [out, table, B] + have hout : writeData e (decide (B ≠ 0)) = state i := by + apply Data.ext + · simp [writeData, heReg, state, d, initial, Data.set] + · rfl + · rfl + · exact hdrop + rw [hout] at hh + apply hh.mono + have hB : B ≤ W := bit.eval_le input _ M (by dsimp [M]; omega) (by intro u; dsimp [M]; omega) + omega + rw [hstart] at hloop + have zend : state 0 = {initial input with output := table len bit input} := by + simp [state, d, Data.set, initial, out] + rw [zend] at hloop + exact (hlen.seq hloop).mono (by + + change _ ≤ len.timeBudget input.length+V*(T+2*W+4)+1 + have := Nat.mul_le_mul_right (T+2*W+4) hL + omega) + +def eraseInput : Command ℕ := .seq (inputLength 1 0) (.loop 0 .discard) + + theorem eraseInput_evaluates (d : Data ℕ) (hz : d.Clean 0) (hb : d.backup = []) : + Within eraseInput d {d with input := []} (7*d.input.length+7) := by + have hl := inputLength_evaluates d 1 0 (by omega) (hz 1 (by omega)) (hz 0 le_rfl) hb + let state : ℕ → Data ℕ := fun i => {d.set 0 i with input := d.input.drop (d.input.length-i)} + have hs : state d.input.length = d.set 0 d.input.length := by simp [state, Data.set] + have hf : state 0 = {d with input := []} := by + simp [state, Data.set_clean_zero hz le_rfl] + have hloop : Within (.loop 0 .discard) (state d.input.length) (state 0) (2*d.input.length+1) := by + have h := Within.loop 0 (.discard : Command ℕ) state d.input.length 1 + have heq : 2*d.input.length+1 = d.input.length*(1+1)+1 := by omega + rw [heq] + apply h + · intro i hi; simp [state] + · intro i hi + have he : discardData (decData (state (i+1)) 0) = state i := by + apply Data.ext + · simp [state, discardData, decData, Data.set] + · simp only [discardData, decData, state, Data.set] + rw [List.tail_drop] + congr 1 + omega + all_goals rfl + exact ⟨1,le_rfl, by rw [← he]; exact Evaluates.discard _⟩ + rw [hs, hf] at hloop + exact (hl.seq hloop).mono (by omega) + +end IndependentSetsCut.CounterMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Reverse.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Reverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..51d5d163a5b982ee33163f216768524e2790d83b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Reverse.lean @@ -0,0 +1,260 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderRowLookup + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +section +open Turing +open PCP.ExpanderTables PCP.ExpanderRowControl PCP.ExpanderTableWords +open MachineComposition +variable {K Λ ρ : Type} [DecidableEq K] [Fintype ρ] + +variable {d : Nat} (second : Bool) (positive : 0 < d) + (H : Table (cloudSize d) d) (ports : Tape → K) + (distinct : Function.Injective ports) (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ l, target (labels l) = statement positive H ports labels exit l) + (base : K → List Bool) + (ambient : (Ambient ρ d × Fin (degree d)) × Unit) (register : Option Bool) + +include positive H distinct exit code + +theorem reversePhaseTrace : + (advance (TM2.step target))^[(base (ports .queryReverse)).length + 1] + (some ⟨some (labels (reversePhaseLabel second)), (ambient, register), base⟩) = + some ⟨some (labels (lookupPhaseLabel second (.run .copyFirst))), (ambient, none), + Reduction.MachineTransfer.tapesAt (ports .queryReverse) (ports .queryIndex) base [] + ((base (ports .queryReverse)).reverse ++ base (ports .queryIndex))⟩ := by + have h := Reduction.MachineTransfer.transferAt_fromTapes + (ports .queryReverse) (ports .queryIndex) + (fun h => (by decide : Tape.queryReverse ≠ .queryIndex) (distinct h)) + id false (labels (reversePhaseLabel second)) + (some (labels (lookupPhaseLabel second (.run .copyFirst)))) target + (by cases second <;> exact code _) base ambient register + unfold Reduction.MachineTransfer.nextAt at h + unfold advance + simpa only [List.map_id] using h + +def reversePhaseInTime : + StateTransition.EvalsToInTime (TM2.step target) + ⟨some (labels (reversePhaseLabel second)), (ambient, register), base⟩ + (some ⟨some (labels (lookupPhaseLabel second (.run .copyFirst))), (ambient, none), + Reduction.MachineTransfer.tapesAt (ports .queryReverse) (ports .queryIndex) base [] + ((base (ports .queryReverse)).reverse ++ base (ports .queryIndex))⟩) + ((base (ports .queryReverse)).length + 1) where + steps := (base (ports .queryReverse)).length + 1 + evals_in_steps := reversePhaseTrace second positive H ports distinct labels exit target code + base ambient register + steps_le_m := Nat.le_refl _ + +theorem reversePhaseTrace_unary (index : Nat) (suffix : List Bool) + (queryWord : base (ports .queryReverse) = (encodeWord index).reverse) + (indexWord : base (ports .queryIndex) = suffix) : + (advance (TM2.step target))^[index + 2] + (some ⟨some (labels (reversePhaseLabel second)), (ambient, register), base⟩) = + some ⟨some (labels (lookupPhaseLabel second (.run .copyFirst))), (ambient, none), + Reduction.MachineTransfer.tapesAt (ports .queryReverse) (ports .queryIndex) base [] + (encodeWord index ++ suffix)⟩ := by + have h := reversePhaseTrace second positive H ports distinct labels exit target code + base ambient register + simpa only [queryWord, indexWord, List.length_reverse, encodeWord_length, + List.reverse_reverse, Nat.add_assoc] using h + +end + +open Turing MachineComposition +open PCP.ExpanderTables PCP.ExpanderRowControl + +@[simp] private theorem dirtyTape_zero : dirtyTape 0 = .queryIndex := rfl +@[simp] private theorem dirtyTape_one : dirtyTape 1 = .lookupOutput := rfl +@[simp] private theorem dirtyTape_two : dirtyTape 2 = .quotientFirst := rfl +@[simp] private theorem dirtyTape_three : dirtyTape 3 = .quotientSecond := rfl +@[simp] private theorem dirtyTape_four : dirtyTape 4 = .remainderFirst := rfl +@[simp] private theorem dirtyTape_five : dirtyTape 5 = .remainderSecond := rfl + +variable {K Λ ρ : Type} [DecidableEq K] + +def cleanupTapes (ports : Tape → K) (base : K → List Bool) : K → List Bool := + Function.update + (Function.update + (Function.update + (Function.update + (Function.update + (Function.update base (ports .queryIndex) []) + (ports .lookupOutput) []) + (ports .quotientFirst) []) + (ports .quotientSecond) []) + (ports .remainderFirst) []) + (ports .remainderSecond) [] + +def cleanupSteps (ports : Tape → K) (base : K → List Bool) : Nat := + ((base (ports .queryIndex)).length + 1) + + ((base (ports .lookupOutput)).length + 1) + + ((base (ports .quotientFirst)).length + 1) + + ((base (ports .quotientSecond)).length + 1) + + ((base (ports .remainderFirst)).length + 1) + + ((base (ports .remainderSecond)).length + 1) + +omit [DecidableEq K] in +theorem cleanupSteps_eq_sum (ports : Tape → K) (base : K → List Bool) : + cleanupSteps ports base = ∑ i : Fin 6, ((base (ports (dirtyTape i))).length + 1) := by + simp [cleanupSteps, Fin.sum_univ_succ, Nat.add_assoc] + +@[simp] theorem cleanupTapes_dirty (ports : Tape → K) (distinct : Function.Injective ports) + (base : K → List Bool) (i : Fin 6) : + cleanupTapes ports base (ports (dirtyTape i)) = [] := by + fin_cases i <;> + simp [cleanupTapes, distinct.eq_iff] + +theorem cleanupTapes_other (ports : Tape → K) (base : K → List Bool) (k : K) + (outside : ∀ i : Fin 6, k ≠ ports (dirtyTape i)) : + cleanupTapes ports base k = base k := by + have h0 := outside 0 + have h1 := outside 1 + have h2 := outside 2 + have h3 := outside 3 + have h4 := outside 4 + have h5 := outside 5 + change k ≠ ports .queryIndex at h0 + change k ≠ ports .lookupOutput at h1 + change k ≠ ports .quotientFirst at h2 + change k ≠ ports .quotientSecond at h3 + change k ≠ ports .remainderFirst at h4 + change k ≠ ports .remainderSecond at h5 + simp [cleanupTapes, h0, h1, h2, h3, h4, h5] + +@[simp] theorem cleanupTapes_table (ports : Tape → K) (distinct : Function.Injective ports) + (base : K → List Bool) : + cleanupTapes ports base (ports .table) = base (ports .table) := by + simp [cleanupTapes, distinct.eq_iff] + +@[simp] theorem cleanupTapes_inputVertex (ports : Tape → K) + (distinct : Function.Injective ports) (base : K → List Bool) : + cleanupTapes ports base (ports .inputVertex) = base (ports .inputVertex) := by + simp [cleanupTapes, distinct.eq_iff] + +@[simp] theorem cleanupTapes_output (ports : Tape → K) (distinct : Function.Injective ports) + (base : K → List Bool) : + cleanupTapes ports base (ports .output) = base (ports .output) := by + simp [cleanupTapes, distinct.eq_iff] + +theorem join_trace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} + (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by + rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] + +variable [Fintype ρ] {d : Nat} + +theorem cleanupOneTraceAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ label, target (labels label) = statement positive H ports labels exit label) + (i : Fin 6) (base : K → List Bool) (state : State ρ d) : + (advance (TM2.step target))^[((base (ports (dirtyTape i))).length + 1)] + (some ⟨some (labels (.cleanup i)), state, base⟩) = + some ⟨some (if hi : i.val + 1 < 6 then labels (.cleanup ⟨i.val + 1, hi⟩) + else labels .done), + (state.1, none), Function.update base (ports (dirtyTape i)) []⟩ := by + have run := MachineDrain.drainTrace (ports (dirtyTape i)) (labels (.cleanup i)) + (some (if hi : i.val + 1 < 6 then labels (.cleanup ⟨i.val + 1, hi⟩) + else labels .done)) target + (by simpa only [statement] using code (.cleanup i)) + base (base (ports (dirtyTape i))) state.1 state.2 + simpa only [Function.update_eq_self] using run + +theorem cleanupTraceAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (distinct : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (state : State ρ d) : + (advance (TM2.step target))^[cleanupSteps ports base] + (some ⟨some (labels (.cleanup 0)), state, base⟩) = + some ⟨some (labels .done), (state.1, none), cleanupTapes ports base⟩ := by + let t1 := Function.update base (ports .queryIndex) [] + let t2 := Function.update t1 (ports .lookupOutput) [] + let t3 := Function.update t2 (ports .quotientFirst) [] + let t4 := Function.update t3 (ports .quotientSecond) [] + let t5 := Function.update t4 (ports .remainderFirst) [] + have h0 := cleanupOneTraceAt positive H ports labels exit target code 0 base state + have h1 := cleanupOneTraceAt positive H ports labels exit target code 1 t1 (state.1, none) + have h2 := cleanupOneTraceAt positive H ports labels exit target code 2 t2 (state.1, none) + have h3 := cleanupOneTraceAt positive H ports labels exit target code 3 t3 (state.1, none) + have h4 := cleanupOneTraceAt positive H ports labels exit target code 4 t4 (state.1, none) + have h5 := cleanupOneTraceAt positive H ports labels exit target code 5 t5 (state.1, none) + simp [t1, t2, t3, t4, t5, distinct.eq_iff, + -Function.iterate_succ] at h0 h1 h2 h3 h4 h5 + have finished := join_trace (join_trace (join_trace (join_trace (join_trace h0 h1) h2) h3) h4) h5 + simpa only [cleanupSteps, cleanupTapes] using finished + +theorem doneStepAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (state : State ρ d) : + TM2.step target ⟨some (labels .done), state, base⟩ = some ⟨exit, state, base⟩ := by + change some (TM2.stepAux (target (labels .done)) state base) = _ + rw [code] + cases exit <;> rfl + +theorem cleanupExitTraceAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (distinct : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (state : State ρ d) : + (advance (TM2.step target))^[cleanupSteps ports base + 1] + (some ⟨some (labels (.cleanup 0)), state, base⟩) = + some ⟨exit, (state.1, none), cleanupTapes ports base⟩ := by + have cleaned := cleanupTraceAt positive H ports distinct labels exit target code base state + have done : (advance (TM2.step target))^[1] + (some ⟨some (labels .done), (state.1, none), cleanupTapes ports base⟩) = + some ⟨exit, (state.1, none), cleanupTapes ports base⟩ := by + simpa only [Function.iterate_one, advance_some] using + doneStepAt positive H ports labels exit target code (cleanupTapes ports base) (state.1, none) + exact join_trace cleaned done + +def initializedTapes (ports : Tape → K) (base : K → List Bool) : K → List Bool := + Function.update + (Function.update + (Function.update + (Function.update base (ports .quotientFirst) (false :: base (ports .quotientFirst))) + (ports .quotientSecond) (false :: base (ports .quotientSecond))) + (ports .remainderFirst) (false :: base (ports .remainderFirst))) + (ports .remainderSecond) (false :: base (ports .remainderSecond)) + +theorem initializeStepAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (distinct : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (state : State ρ d) : + TM2.step target ⟨some (labels .initialize), state, base⟩ = + some ⟨some (labels (.firstEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry))), + (state.1, none), initializedTapes ports base⟩ := by + change some (TM2.stepAux (target (labels .initialize)) state base) = _ + rw [code] + simp [statement, TM2.stepAux, initializedTapes, distinct.eq_iff] + +def clearedQueryTapes (ports : Tape → K) (base : K → List Bool) : K → List Bool := + Function.update + (Function.update base (ports .queryIndex) (base (ports .queryIndex)).tail) + (ports .lookupOutput) (base (ports .lookupOutput)).tail + +theorem clearQueryStepAt (positive : 0 < d) (H : Table (cloudSize d) d) + (ports : Tape → K) (distinct : Function.Injective ports) + (labels : Label d → Λ) (exit : Option Λ) + (target : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State ρ d)) + (code : ∀ label, target (labels label) = statement positive H ports labels exit label) + (base : K → List Bool) (state : State ρ d) : + TM2.step target ⟨some (labels .clearQuery), state, base⟩ = + some ⟨some (labels (.secondEmit (PCP.AlphabetTable.Emitter.labelAt 3 _ 0 .entry))), + state, clearedQueryTapes ports base⟩ := by + change some (TM2.stepAux (target (labels .clearQuery)) state base) = _ + rw [code] + simp [statement, TM2.stepAux, clearedQueryTapes, distinct.eq_iff] + +end IndependentSetsGames.Foundations.Complexity.MachineExpanderRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Runtime.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Runtime.lean new file mode 100644 index 0000000000000000000000000000000000000000..505d4d32883388a2b323590ad008fed56c9d1424 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Runtime.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.LoopInitialization +import OAI.Combinatorics.IndependentSets.PCP.Finish + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Runtime + +open Turing +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel + +noncomputable def prefixPolynomial (q : Nat) : Polynomial Nat := + Polynomial.C 27 * Polynomial.X + Polynomial.C 54 + + Polynomial.X * + (Polynomial.C (32 + 8 * (Enumeration.localCount q * (6 * (2 * 4104)))) * + (Polynomial.X + Polynomial.C 1)) + Polynomial.C 1 + +theorem prefixPolynomial_eval (q N : Nat) : + (prefixPolynomial q).eval N = Loop.prefixTime q N := by + simp only [prefixPolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Loop.prefixTime, + Initialization.time, Body.bodyTime] + ring + +noncomputable def time (q : Nat) : Polynomial Nat := + Finish.completedPolynomial q (prefixPolynomial q) + +noncomputable def tableOutputsInTime {q : Nat} (input : GenericGraphTables.Table q) : + TM2OutputsInTime (Driver.machine q) (GenericGraphTables.tableBits input) + (some (GraphTables.tableBits (Table.build input))) + ((time q).eval (GenericGraphTables.tableBits input).length) := by + let prefixRun := Loop.runPrefix input + have hrun : StateTransition.EvalsToInTime (Driver.machine q).step + (initList (Driver.machine q) (GenericGraphTables.tableBits input)) + (some ⟨some .reverseOutput, normal prefixRun.relation prefixRun.flag, prefixRun.tapes⟩) + ((prefixPolynomial q).eval (GenericGraphTables.tableBits input).length) := by + rw [prefixPolynomial_eval] + exact prefixRun.run + exact Finish.finishAfterPolynomialPrefix q (GenericGraphTables.tableBits input) + prefixRun.tapes (GraphTables.tableBits (Table.build input)) + (normal prefixRun.relation prefixRun.flag) (prefixPolynomial q) hrun + prefixRun.ready.reversed_at_end prefixRun.ready.output + +noncomputable def tablePolynomialTime (q : Nat) : + TM2ComputableInPolyTime (GenericGraphTables.tableBits (q := q)) + GraphTables.tableBits (Table.build (q := q)) where + tm := Driver.machine q + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := time q + outputsFun input := by + change TM2OutputsInTime (Driver.machine q) + ((GenericGraphTables.tableBits input).map id) + (some ((GraphTables.tableBits (Table.build input)).map id)) + ((time q).eval (GenericGraphTables.tableBits input).length) + convert! tableOutputsInTime input using 1 + · exact congrArg (TM2OutputsInTime (Driver.machine q)) (List.map_id _) + · exact congrArg some (List.map_id _) + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Runtime + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/SelectAlphabet.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/SelectAlphabet.lean new file mode 100644 index 0000000000000000000000000000000000000000..81485ca68a3ba493f33fb9fb7092eb0535323f24 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/SelectAlphabet.lean @@ -0,0 +1,445 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFixedBlockMap +import OAI.Combinatorics.IndependentSets.Machines.MachineStateEquiv +import OAI.Combinatorics.IndependentSets.Machines.MachineAlphabetTransport +import OAI.Combinatorics.IndependentSets.Machines.MachineUnaryLess +import OAI.Combinatorics.IndependentSets.Machines.Alphabet + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow +open Turing MachineComposition +open PCP +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) +variable {K Λ σ : Type} [DecidableEq K] +abbrev SelectAlphabet (_ : SelectTape) := Bool + +theorem selectAlphabet_eq : RawSelectAlphabet = SelectAlphabet := by + funext k + cases k with + | inl k => cases k <;> rfl + | inr k => rfl + +def selectToBoolWord : (k : SelectTape) → List (RawSelectAlphabet k) → List Bool + | .inl (.inl _), word => word + | .inl (.inr _), word => word + | .inr _, word => word + +def selectToBoolTapes (base : ∀ k, List (RawSelectAlphabet k)) : SelectTape → List Bool := + fun k => selectToBoolWord k (base k) + +private theorem alphabet_tapes_apply {K : Type} {Γ Δ : K → Type} + (h : Γ = Δ) (base : ∀ k, List (Γ k)) (k : K) : + MachineAlphabetTransport.tapes h base k = + Eq.mp (congrArg (fun alphabet => List (alphabet k)) h) (base k) := by + cases h + rfl + +theorem selectToBoolTapes_eq (base : ∀ k, List (RawSelectAlphabet k)) : + selectToBoolTapes base = MachineAlphabetTransport.tapes selectAlphabet_eq base := by + funext k + rw [alphabet_tapes_apply] + cases k with + | inl k => cases k <;> rfl + | inr k => rfl + +abbrev SelectState (σ : Type) := MachineUnaryLessAt.State (σ × MachineCloudSelect.Phase) + +def selectStateEquiv (σ : Type) : (MachineCloudSelect.State σ × Unit) ≃ SelectState σ where + toFun s := (((s.1.1.1.1, s.1.2), s.1.1.1.2), s.1.1.2) + invFun s := ((((s.1.1.1, s.1.2), s.2), s.1.1.2), ()) + left_inv s := by rcases s with ⟨⟨⟨⟨a, b⟩, c⟩, d⟩, ⟨⟩⟩; rfl + right_inv s := by rcases s with ⟨⟨⟨a, b⟩, c⟩, d⟩; rfl + +def selectScratch : SelectTape := .inl (.inl .scratch) +def selectQuery : SelectTape := .inl (.inl .target) +def selectOutput : SelectTape := .inl (.inr ()) + +def compareSlots : Fin 4 ↪ SelectTape where + toFun i := ![.inr .localIndex, .inr .cloudSize, .inr .savedLeft, .inr .savedRight] i + inj' := by intro i j h; fin_cases i <;> fin_cases j <;> simp_all + +def subtractSlots : Fin 4 ↪ SelectTape where + toFun i := ![.inr .localWork, .inr .sizeWork, .inr .savedLeft, .inr .savedRight] i + inj' := by intro i j h; fin_cases i <;> fin_cases j <;> simp_all + +inductive SelectCopy + | oldLocal | oldOwner | dummyLocal | dummySize | dummyDifference + deriving DecidableEq + +instance : Fintype SelectCopy where + elems := {.oldLocal, .oldOwner, .dummyLocal, .dummySize, .dummyDifference} + complete kind := by cases kind <;> simp + +inductive SelectAdd + | prefixOffset | darts + deriving DecidableEq + +instance : Fintype SelectAdd where + elems := {.prefixOffset, .darts} + complete kind := by cases kind <;> simp + +inductive SelectAddStage | scan | restore + deriving DecidableEq + +instance : Fintype SelectAddStage where + elems := {.scan, .restore} + complete stage := by cases stage <;> simp + +inductive SelectControl + | compare (stage : MachineUnaryLessAt.Label) + | choose + | copy (kind : SelectCopy) (stage : MachineUnaryAffineAt.Label) + | subtract + | add (kind : SelectAdd) (stage : SelectAddStage) + | cleanup (i : Fin 5) + deriving DecidableEq, Fintype + +abbrev SelectLabel := MachineCloudSelect.Label ⊕ SelectControl + +def copySource : SelectCopy → SelectTape + | .oldLocal | .dummyLocal => .inr .localIndex + | .oldOwner => .inr .owner + | .dummySize => .inr .cloudSize + | .dummyDifference => .inr .localWork + +def copyDestination : SelectCopy → SelectTape + | .oldLocal | .oldOwner => selectQuery + | .dummyLocal => .inr .localWork + | .dummySize => .inr .sizeWork + | .dummyDifference => selectOutput + +def afterCopy : SelectCopy → SelectLabel + | .oldLocal => .inr (.copy .oldOwner .seed) + | .oldOwner => .inl (.inr .initialize) + | .dummyLocal => .inr (.copy .dummySize .seed) + | .dummySize => .inr .subtract + | .dummyDifference => .inr (.add .prefixOffset .scan) + +def addSource : SelectAdd → SelectTape + | .prefixOffset => .inr .prefixOffset + | .darts => .inr .darts + +def afterAdd : SelectAdd → SelectLabel + | .prefixOffset => .inr (.add .darts .scan) + | .darts => .inr (.cleanup 0) + +def cleanupTape (i : Fin 5) : SelectTape := + ![selectQuery, .inr .localWork, .inr .sizeWork, .inr .savedLeft, .inr .savedRight] i + +def afterCleanup (i : Fin 5) : Option SelectLabel := + if h : i.val + 1 < 5 then some (.inr (.cleanup ⟨i.val + 1, h⟩)) else none + +def selectControl : SelectControl → TM2.Stmt SelectAlphabet SelectLabel (SelectState σ) + | .compare stage => MachineUnaryLessAt.statement compareSlots + (fun s => .inr (.compare s)) (some (.inr .choose)) stage + | .choose => .branch (fun s => s.1.2) + (.load (fun s => ((s.1.1, false), none)) + (.goto fun _ => .inr (.copy .oldLocal .seed))) + (.load (fun s => ((s.1.1, false), none)) + (.goto fun _ => .inr (.copy .dummyLocal .seed))) + | .copy kind .seed => MachineUnaryAffineAt.seed (copyDestination kind) 0 + (.inr (.copy kind .scan)) + | .copy kind .scan => MachineUnaryAffineAt.scan (copySource kind) selectScratch + (copyDestination kind) 1 (.inr (.copy kind .scan)) (.inr (.copy kind .restore)) + | .copy kind .restore => Reduction.MachineTransfer.loopAt selectScratch (copySource kind) + id false (.inr (.copy kind .restore)) (some (afterCopy kind)) + | .subtract => MachineUnaryLessAt.scan subtractSlots (.inr .subtract) + (.inr (.copy .dummyDifference .seed)) + | .add kind .scan => MachineUnaryAffineAt.scan (addSource kind) selectScratch selectOutput 1 + (.inr (.add kind .scan)) (.inr (.add kind .restore)) + | .add kind .restore => Reduction.MachineTransfer.loopAt selectScratch (addSource kind) + id false (.inr (.add kind .restore)) (some (afterAdd kind)) + | .cleanup i => MachineDrain.drain (cleanupTape i) (.inr (.cleanup i)) (afterCleanup i) + +def rawSelectProgram : SelectLabel → TM2.Stmt RawSelectAlphabet SelectLabel (SelectState σ) := + MachineStateEquiv.program (selectStateEquiv σ) + (MachineEmbedding.program (some (.inr (.cleanup 0))) MachineCloudSelect.program + (fun control => MachineStateEquiv.statement (selectStateEquiv σ).symm + (MachineAlphabetTransport.statement selectAlphabet_eq.symm (selectControl control)))) + +def selectProgram : SelectLabel → TM2.Stmt SelectAlphabet SelectLabel (SelectState σ) := + MachineAlphabetTransport.program selectAlphabet_eq rawSelectProgram + +@[simp] theorem selectProgram_control (l : SelectControl) : + selectProgram (σ := σ) (.inr l) = selectControl l := by + change MachineAlphabetTransport.statement selectAlphabet_eq + (MachineStateEquiv.statement (selectStateEquiv σ) + (MachineStateEquiv.statement (selectStateEquiv σ).symm + (MachineAlphabetTransport.statement selectAlphabet_eq.symm (selectControl l)))) = _ + have h := MachineStateEquiv.statement_symm_statement (selectStateEquiv σ).symm + (MachineAlphabetTransport.statement selectAlphabet_eq.symm (selectControl (σ := σ) l)) + simp only [Equiv.symm_symm] at h + rw [h] + exact MachineAlphabetTransport.statement_roundtrip selectAlphabet_eq _ + +def selectCleanState (ambient : σ) (register : Option Bool) : SelectState σ := + (((ambient, .checking), false), register) + +theorem selectComparisonTrace (base : SelectTape → List Bool) (j k : Nat) + (hj : base (.inr .localIndex) = encodeWord j) + (hk : base (.inr .cloudSize) = encodeWord k) + (hl : base (.inr .savedLeft) = []) (hr : base (.inr .savedRight) = []) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step selectProgram))^[MachineUnaryLessAt.steps j k + 1] + (some ⟨some (.inr (.compare .scan)), selectCleanState ambient register, base⟩) = + some ⟨some (.inr (.copy (if j < k then .oldLocal else .dummyLocal) .seed)), + selectCleanState ambient none, base⟩ := by + have h := MachineUnaryLessAt.lessThanTrace compareSlots + (fun l => .inr (.compare l)) (some (.inr .choose)) selectProgram + (fun l => by rw [selectProgram_control]; rfl) + base j k [] [] (by change base (.inr .localIndex) = _; simpa only [List.append_nil] using hj) + (by change base (.inr .cloudSize) = _; simpa only [List.append_nil] using hk) hl hr + (ambient, MachineCloudSelect.Phase.checking) false register + simp only [selectCleanState] + rw [Function.iterate_succ_apply', h, advance_some] + change some (TM2.stepAux (selectProgram (.inr .choose)) _ _) = _ + rw [selectProgram_control] + by_cases hlt : j < k <;> simp [selectControl, TM2.stepAux, hlt] + +theorem selectCopyTrace (kind : SelectCopy) (base : SelectTape → List Bool) + (a : Nat) (hword : base (copySource kind) = encodeWord a) + (hscratch : base selectScratch = []) (ambient : σ) (register : Option Bool) : + (advance (TM2.step selectProgram))^[2 * (a + 1) + 1] + (some ⟨some (.inr (.copy kind .seed)), selectCleanState ambient register, base⟩) = + some ⟨some (afterCopy kind), selectCleanState ambient none, + Function.update base (copyDestination kind) + (encodeWord a ++ base (copyDestination kind))⟩ := by + have h₁ : copySource kind ≠ selectScratch := by cases kind <;> decide + have h₂ : copySource kind ≠ copyDestination kind := by cases kind <;> decide + have h₃ : selectScratch ≠ copyDestination kind := by cases kind <;> decide + simpa only [Nat.one_mul, Nat.add_zero, selectCleanState] using + MachineUnaryAffineAt.seededAffineTrace (copySource kind) selectScratch (copyDestination kind) + h₁ h₂ h₃ 1 0 (.inr (.copy kind .seed)) (.inr (.copy kind .scan)) + (.inr (.copy kind .restore)) (some (afterCopy kind)) selectProgram + (by rw [selectProgram_control]; rfl) (by rw [selectProgram_control]; rfl) + (by rw [selectProgram_control]; rfl) base a [] (by simpa using hword) hscratch + ((ambient, MachineCloudSelect.Phase.checking), false) register + +theorem selectAddTrace (kind : SelectAdd) (base : SelectTape → List Bool) + (a b : Nat) (hword : base (addSource kind) = encodeWord a) + (houtput : base selectOutput = encodeWord b) (hscratch : base selectScratch = []) + (ambient : σ) : + (advance (TM2.step selectProgram))^[2 * (a + 1)] + (some ⟨some (.inr (.add kind .scan)), selectCleanState ambient none, base⟩) = + some ⟨some (afterAdd kind), selectCleanState ambient none, + Function.update base selectOutput (encodeWord (a + b))⟩ := by + have h₁ : addSource kind ≠ selectScratch := by cases kind <;> decide + have h₂ : addSource kind ≠ selectOutput := by cases kind <;> decide + have h₃ : selectScratch ≠ selectOutput := by decide + have frame (n : Nat) : MachineUnaryAffineAt.tapes (addSource kind) selectScratch selectOutput + base (encodeWord a ++ []) [] (encodeWord n ++ []) = + Function.update base selectOutput (encodeWord n) := by + simp only [List.append_nil] + rw [← hword, ← hscratch] + simp only [MachineUnaryAffineAt.tapes, MachineCopy.forkTapes, Function.update_eq_self] + have h := MachineUnaryAffineAt.affineTrace (addSource kind) selectScratch selectOutput + h₁ h₂ h₃ 1 (.inr (.add kind .scan)) (.inr (.add kind .restore)) + (some (afterAdd kind)) selectProgram + (by rw [selectProgram_control]; rfl) (by rw [selectProgram_control]; rfl) + base a b [] [] ((ambient, MachineCloudSelect.Phase.checking), false) none + rw [frame, frame] at h + rw [← houtput, Function.update_eq_self] at h + simpa only [Nat.one_mul, selectCleanState] using h + +abbrev CoreTape := Fin 27 +abbrev CoreState (σ : Type) (q : Nat) := + (σ × (MachineFixedBlockMap.Buffer 4096 × + (Fin q × (Bool × MachineCloudSelect.Phase)))) × Option Bool + +inductive CoreLabel (q : Nat) + | rotor (stage : RotorLabel q) + | select (stage : SelectLabel) + | finish (stage : FinishLabel) + | cleanup (i : Fin 10) + deriving DecidableEq, Fintype + +def coreEntry (q : Nat) : CoreLabel q := .rotor (.lookup .seed) + +theorem selectCloudTrace (t : GraphTables.Table) (v : Fin t.vertices) + (i : Fin (PreprocessingCloudIndex.cloudSize t v)) + (extra : SelectExtraTape → List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step selectProgram))^[MachineCloudSelect.cloudSelectSteps t v i []] + (some ⟨some (.inl (.inr .initialize)), selectCleanState ambient register, + selectToBoolTapes (MachineEmbedding.tapes + (MachineCloudSelect.memory (GraphTables.tableBits t) [] + (MachineCloudSelect.queryWord v.val i.val []) [] [] [] []) extra)⟩) = + some ⟨some (.inr (.cleanup 0)), selectCleanState ambient none, + selectToBoolTapes (MachineEmbedding.tapes + (MachineCloudSelect.memory (GraphTables.tableBits t) [] + (MachineCloudSelect.queryWord v.val i.val []) [] [] [] + (encodeWord (PreprocessingCloudIndex.cloudSelect t v i).val.val)) extra)⟩ := by + let source := MachineCloudSelect.program (σ := σ) + let more := fun c => MachineStateEquiv.statement (selectStateEquiv σ).symm + (MachineAlphabetTransport.statement selectAlphabet_eq.symm (selectControl (σ := σ) c)) + let caller := MachineEmbedding.program (some (.inr (.cleanup 0))) source more + let embed := MachineEmbedding.configuration (K := MachineCloudSelect.Tape) + (Γ := MachineCloudSelect.Alphabet) (σ := MachineCloudSelect.State σ) + (some (Sum.inr (SelectControl.cleanup 0)) : Option SelectLabel) () extra + have sourceRun := MachineCloudSelect.cloudSelectTrace t v i [] [] ambient register + have lifted := liftSuccessfulTrace (TM2.step source) (TM2.step caller) embed + (MachineEmbedding.step_simulation (some (.inr (.cleanup 0))) () extra source more) + _ _ _ sourceRun + have transported := MachineStateEquiv.trace (selectStateEquiv σ) caller _ _ _ lifted + have boolean := MachineAlphabetTransport.successfulTrace selectAlphabet_eq + (MachineStateEquiv.program (selectStateEquiv σ) caller) _ _ _ transported + simp only [embed, MachineCloudSelect.cfg, MachineStateEquiv.configuration, MachineEmbedding.configuration, + MachineEmbedding.label, selectStateEquiv, List.append_nil, + MachineAlphabetTransport.configuration_mk, ← selectToBoolTapes_eq] at boolean + convert boolean using 1 <;> rfl + +def selectExtraMemory (j v k offset m : Nat) + (savedLeft savedRight localWork sizeWork : List Bool) : + SelectExtraTape → List Bool + | .localIndex => encodeWord j + | .owner => encodeWord v + | .cloudSize => encodeWord k + | .prefixOffset => encodeWord offset + | .darts => encodeWord m + | .savedLeft => savedLeft + | .savedRight => savedRight + | .localWork => localWork + | .sizeWork => sizeWork + +def selectMemory (graph : List Bool) (j v k offset m : Nat) + (query output savedLeft savedRight localWork sizeWork : List Bool) : + SelectTape → List Bool := + selectToBoolTapes (MachineEmbedding.tapes + (MachineCloudSelect.memory graph [] query [] [] [] output) + (selectExtraMemory j v k offset m savedLeft savedRight localWork sizeWork)) + +@[simp] theorem selectMemory_query (graph : List Bool) (j v k o m : Nat) + (query output a b c d : List Bool) : + selectMemory graph j v k o m query output a b c d selectQuery = query := rfl + +@[simp] theorem selectMemory_output (graph : List Bool) (j v k o m : Nat) + (query output a b c d : List Bool) : + selectMemory graph j v k o m query output a b c d selectOutput = output := rfl + +@[simp] theorem selectMemory_scratch (graph : List Bool) (j v k o m : Nat) + (query output a b c d : List Bool) : + selectMemory graph j v k o m query output a b c d selectScratch = [] := rfl + +@[simp] theorem selectMemory_extra (graph : List Bool) (j v k o m : Nat) + (query output a b c d : List Bool) (z : SelectExtraTape) : + selectMemory graph j v k o m query output a b c d (.inr z) = + selectExtraMemory j v k o m a b c d z := rfl + +@[simp] theorem update_selectMemory_query (graph : List Bool) (j v k o m : Nat) + (query output a b c d word : List Bool) : + Function.update (selectMemory graph j v k o m query output a b c d) selectQuery word = + selectMemory graph j v k o m word output a b c d := by + funext z + cases z with + | inl z => + cases z with + | inl z => cases z <;> rfl + | inr z => cases z; rfl + | inr z => cases z <;> rfl + +@[simp] theorem update_selectMemory_output (graph : List Bool) (j v k o m : Nat) + (query output a b c d word : List Bool) : + Function.update (selectMemory graph j v k o m query output a b c d) selectOutput word = + selectMemory graph j v k o m query word a b c d := by + funext z + cases z with + | inl z => + cases z with + | inl z => cases z <;> rfl + | inr z => cases z; rfl + | inr z => cases z <;> rfl + +@[simp] theorem update_selectMemory_local (graph : List Bool) (j v k o m : Nat) + (query output a b c d word : List Bool) : + Function.update (selectMemory graph j v k o m query output a b c d) (.inr .localWork) word = + selectMemory graph j v k o m query output a b word d := by + funext z + cases z with + | inl z => + cases z with + | inl z => cases z <;> rfl + | inr z => cases z; rfl + | inr z => cases z <;> rfl + +@[simp] theorem update_selectMemory_size (graph : List Bool) (j v k o m : Nat) + (query output a b c d word : List Bool) : + Function.update (selectMemory graph j v k o m query output a b c d) (.inr .sizeWork) word = + selectMemory graph j v k o m query output a b c word := by + funext z + cases z with + | inl z => + cases z with + | inl z => cases z <;> rfl + | inr z => cases z; rfl + | inr z => cases z <;> rfl + +@[simp] theorem update_selectMemory_left (graph : List Bool) (j v k o m : Nat) + (query output a b c d word : List Bool) : + Function.update (selectMemory graph j v k o m query output a b c d) (.inr .savedLeft) word = + selectMemory graph j v k o m query output word b c d := by + funext z + cases z with + | inl z => + cases z with + | inl z => cases z <;> rfl + | inr z => cases z; rfl + | inr z => cases z <;> rfl + +@[simp] theorem update_selectMemory_right (graph : List Bool) (j v k o m : Nat) + (query output a b c d word : List Bool) : + Function.update (selectMemory graph j v k o m query output a b c d) (.inr .savedRight) word = + selectMemory graph j v k o m query output a word c d := by + funext z + cases z with + | inl z => + cases z with + | inl z => cases z <;> rfl + | inr z => cases z; rfl + | inr z => cases z <;> rfl + +theorem selectCleanupTrace (graph : List Bool) (j v k o m : Nat) + (query output a b c d : List Bool) (ambient : σ) : + (advance (TM2.step selectProgram))^[query.length + c.length + d.length + a.length + b.length + 5] + (some ⟨some (.inr (.cleanup 0)), selectCleanState ambient none, + selectMemory graph j v k o m query output a b c d⟩) = + some ⟨none, selectCleanState ambient none, + selectMemory graph j v k o m [] output [] [] [] []⟩ := by + have h0 := MachineDrain.drainTrace selectQuery (.inr (.cleanup 0)) + (some (.inr (.cleanup 1))) selectProgram + (by rw [selectProgram_control]; rfl) + (selectMemory graph j v k o m query output a b c d) query + ((ambient, MachineCloudSelect.Phase.checking), false) none + simp only [update_selectMemory_query] at h0 + have h1 := MachineDrain.drainTrace (.inr .localWork) (.inr (.cleanup 1)) + (some (.inr (.cleanup 2))) selectProgram + (by rw [selectProgram_control]; rfl) + (selectMemory graph j v k o m [] output a b c d) c + ((ambient, MachineCloudSelect.Phase.checking), false) none + simp only [update_selectMemory_local] at h1 + have h2 := MachineDrain.drainTrace (.inr .sizeWork) (.inr (.cleanup 2)) + (some (.inr (.cleanup 3))) selectProgram + (by rw [selectProgram_control]; rfl) + (selectMemory graph j v k o m [] output a b [] d) d + ((ambient, MachineCloudSelect.Phase.checking), false) none + simp only [update_selectMemory_size] at h2 + have h3 := MachineDrain.drainTrace (.inr .savedLeft) (.inr (.cleanup 3)) + (some (.inr (.cleanup 4))) selectProgram + (by rw [selectProgram_control]; rfl) + (selectMemory graph j v k o m [] output a b [] []) a + ((ambient, MachineCloudSelect.Phase.checking), false) none + simp only [update_selectMemory_left] at h3 + have h4 := MachineDrain.drainTrace (.inr .savedRight) (.inr (.cleanup 4)) + none selectProgram (by rw [selectProgram_control]; rfl) + (selectMemory graph j v k o m [] output [] b [] []) b + ((ambient, MachineCloudSelect.Phase.checking), false) none + simp only [update_selectMemory_right] at h4 + have total := joinTrace (joinTrace (joinTrace (joinTrace h0 h1) h2) h3) h4 + have hn : query.length + c.length + d.length + a.length + b.length + 5 = + ((((query.length + 1) + (c.length + 1)) + (d.length + 1)) + (a.length + 1)) + + (b.length + 1) := by omega + rw [hn] + exact total + +end IndependentSetsGames.Foundations.Complexity.MachineRegularInternalRow + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Structural.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Structural.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9a4e175d28d96260a0bf596ac70fe25e68403f8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Structural.lean @@ -0,0 +1,270 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFiniteAlphabet +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularTableBounds + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineCanonicalOutput +open Turing MachineComposition +section Structural + +variable {K Λ Λ' σ : Type} [DecidableEq K] + +def extendedLabel (labels : Λ → Λ') (haltTarget : Option Λ') : Option Λ → Option Λ' + | none => haltTarget + | some label => some (labels label) + +def extendedCfg (labels : Λ → Λ') (haltTarget : Option Λ') (register : Option Bool) + (cfg : TM2.Cfg (fun _ : K => Bool) Λ σ) : + TM2.Cfg (fun _ : K => Bool) Λ' (σ × Option Bool) := + ⟨extendedLabel labels haltTarget cfg.l, (cfg.var, register), cfg.stk⟩ + +def extendedStmt (labels : Λ → Λ') (haltTarget : Option Λ') : + TM2.Stmt (fun _ : K => Bool) Λ σ → + TM2.Stmt (fun _ : K => Bool) Λ' (σ × Option Bool) + | .push k f next => .push k (fun state => f state.1) + (extendedStmt labels haltTarget next) + | .peek k f next => .peek k (fun state symbol => (f state.1 symbol, state.2)) + (extendedStmt labels haltTarget next) + | .pop k f next => .pop k (fun state symbol => (f state.1 symbol, state.2)) + (extendedStmt labels haltTarget next) + | .load f next => .load (fun state => (f state.1, state.2)) + (extendedStmt labels haltTarget next) + | .branch test yes no => .branch (fun state => test state.1) + (extendedStmt labels haltTarget yes) (extendedStmt labels haltTarget no) + | .goto label => .goto (fun state => labels (label state.1)) + | .halt => match haltTarget with + | none => .halt + | some label => .goto (fun _ => label) + +theorem stepAux_extended (labels : Λ → Λ') (haltTarget : Option Λ') + (stmt : TM2.Stmt (fun _ : K => Bool) Λ σ) (state : σ) + (register : Option Bool) (tapes : K → List Bool) : + TM2.stepAux (extendedStmt labels haltTarget stmt) (state, register) tapes = + extendedCfg labels haltTarget register (TM2.stepAux stmt state tapes) := by + induction stmt generalizing state tapes with + | push k f next ih => exact ih state (Function.update tapes k (f state :: tapes k)) + | peek k f next ih => exact ih (f state (tapes k).head?) tapes + | pop k f next ih => + exact ih (f state (tapes k).head?) (Function.update tapes k (tapes k).tail) + | load f next ih => exact ih (f state) tapes + | branch test yes no ihYes ihNo => + cases h : test state with + | false => + simpa only [extendedStmt, TM2.stepAux, h, Bool.cond_false] using ihNo state tapes + | true => + simpa only [extendedStmt, TM2.stepAux, h, Bool.cond_true] using ihYes state tapes + | goto label => rfl + | halt => cases haltTarget <;> rfl + +end Structural + +variable {K Λ σ : Type} [DecidableEq K] [Fintype K] [Fintype Λ] [Fintype σ] + +def sourceMachine (P : Program K Λ σ) : FinTM2 where + K := K + k₀ := P.input + k₁ := P.output + Γ _ := Bool + Λ := Λ + main := P.main + σ := σ + initialState := P.initial + m := P.code + +abbrev Label (Λ : Type) (chosen : List K) := Λ ⊕ (MachineDrainMany.Label chosen ⊕ Unit) + +def cleanupLabel (chosen : List K) : MachineDrainMany.Label chosen → Label Λ chosen := + fun label => .inr (.inl label) + +def resetLabel (chosen : List K) : Label Λ chosen := .inr (.inr ()) + +def cleanupEntry (chosen : List K) : Option (Label Λ chosen) := + MachineDrainMany.entry chosen (cleanupLabel chosen) (some (resetLabel chosen)) + +def completedProgram (P : Program K Λ σ) (chosen : List K) : + Label Λ chosen → TM2.Stmt (fun _ : K => Bool) (Label Λ chosen) (σ × Option Bool) + | .inl label => extendedStmt Sum.inl (cleanupEntry chosen) (P.code label) + | .inr (.inl label) => MachineDrainMany.instruction chosen (cleanupLabel chosen) + (some (resetLabel chosen)) label + | .inr (.inr _) => .load (fun _ => (P.initial, none)) .halt + +def completedMachine (P : Program K Λ σ) (chosen : List K) : FinTM2 where + K := K + k₀ := P.input + k₁ := P.output + Γ _ := Bool + Λ := Label Λ chosen + main := .inl P.main + σ := σ × Option Bool + initialState := (P.initial, none) + m := completedProgram P chosen + +theorem finiteAlphabet (P : Program K Λ σ) (chosen : List K) : + MachineFiniteAlphabet.FiniteAlphabet (completedMachine P chosen) := by + intro k + exact inferInstanceAs (Finite Bool) + +def embeddedCfg (P : Program K Λ σ) (chosen : List K) + (cfg : (sourceMachine P).Cfg) : (completedMachine P chosen).Cfg := + extendedCfg Sum.inl (cleanupEntry chosen) none cfg + +theorem step_simulation (P : Program K Λ σ) (chosen : List K) + (a b : (sourceMachine P).Cfg) (step : (sourceMachine P).step a = some b) : + (completedMachine P chosen).step (embeddedCfg P chosen a) = + some (embeddedCfg P chosen b) := by + cases a with + | mk label state tapes => + cases label with + | none => simp [FinTM2.step, TM2.step] at step + | some label => + have hb : TM2.stepAux (P.code label) state tapes = b := Option.some.inj step + rw [← hb] + change some (TM2.stepAux + (extendedStmt Sum.inl (cleanupEntry chosen) (P.code label)) (state, none) tapes) = _ + exact congrArg some (stepAux_extended Sum.inl (cleanupEntry chosen) + (P.code label) state none tapes) + +@[simp] theorem embedded_init (P : Program K Λ σ) (chosen : List K) (input : List Bool) : + embeddedCfg P chosen (initList (sourceMachine P) input) = + initList (completedMachine P chosen) input := rfl + +omit [Fintype K] [Fintype Λ] [Fintype σ] in +theorem finalTapes_eq (P : Program K Λ σ) (chosen : List K) + (complete : ∀ k, k ∈ chosen ↔ k ≠ P.output) (base : K → List Bool) : + MachineDrainMany.finalTapes chosen base = + MachineDrainMany.haltTapes P.output (base P.output) := by + funext k + rw [MachineDrainMany.finalTapes_apply] + by_cases h : k = P.output + · subst k + simp [MachineDrainMany.haltTapes, complete] + · simp [MachineDrainMany.haltTapes, complete, h] + +theorem haltList_eq (P : Program K Λ σ) (chosen : List K) (output : List Bool) : + haltList (completedMachine P chosen) output = + ⟨none, (P.initial, none), MachineDrainMany.haltTapes P.output output⟩ := by + congr 1 + +def cleanupExecution (P : Program K Λ σ) (chosen : List K) + (complete : ∀ k, k ∈ chosen ↔ k ≠ P.output) (state : σ) + (register : Option Bool) (base : K → List Bool) : + StateTransition.EvalsToInTime (completedMachine P chosen).step + ⟨cleanupEntry chosen, (state, register), base⟩ + (some (haltList (completedMachine P chosen) (base P.output))) + (MachineDrainMany.steps chosen base + 1) := by + let after : (completedMachine P chosen).Cfg := + ⟨some (resetLabel chosen), (state, MachineDrainMany.finalRegister chosen register), + MachineDrainMany.finalTapes chosen base⟩ + have drains : StateTransition.EvalsToInTime (completedMachine P chosen).step + ⟨cleanupEntry chosen, (state, register), base⟩ (some after) + (MachineDrainMany.steps chosen base) := { + steps := MachineDrainMany.steps chosen base + evals_in_steps := MachineDrainMany.trace chosen (cleanupLabel chosen) + (some (resetLabel chosen)) (completedProgram P chosen) (fun _ => rfl) base state register + steps_le_m := le_rfl } + have reset : StateTransition.EvalsToInTime (completedMachine P chosen).step + after (some (haltList (completedMachine P chosen) (base P.output))) 1 := { + steps := 1 + evals_in_steps := by + change some (⟨none, (P.initial, none), MachineDrainMany.finalTapes chosen base⟩ : + (completedMachine P chosen).Cfg) = + some (haltList (completedMachine P chosen) (base P.output)) + exact congrArg some ((congrArg (fun tapes => + (⟨none, (P.initial, none), tapes⟩ : (completedMachine P chosen).Cfg)) + (finalTapes_eq P chosen complete base)).trans + (haltList_eq P chosen (base P.output)).symm) + steps_le_m := le_rfl } + simpa only [Nat.add_comm] using + StateTransition.EvalsToInTime.trans _ (MachineDrainMany.steps chosen base) 1 + _ after _ drains reset + +def outputsInTime (P : Program K Λ σ) (chosen : List K) + (complete : ∀ k, k ∈ chosen ↔ k ≠ P.output) + (input output : List Bool) (state : σ) (base : K → List Bool) (budget : Nat) + (raw : StateTransition.EvalsToInTime (sourceMachine P).step + (initList (sourceMachine P) input) (some ⟨none, state, base⟩) budget) + (correctOutput : base P.output = output) : + TM2OutputsInTime (completedMachine P chosen) input (some output) + (budget + chosen.length * + (input.length + budget * Runtime.programPushBound (sourceMachine P) + 1) + 1) := by + let lifted := liftExecutionInTime (sourceMachine P).step + (completedMachine P chosen).step (embeddedCfg P chosen) (step_simulation P chosen) raw + have joined := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ lifted + (cleanupExecution P chosen complete state none base) + have stackBound : ∀ k, (base k).length ≤ + input.length + budget * Runtime.programPushBound (sourceMachine P) := by + intro k + have h := Runtime.executionSizeBound (sourceMachine P).step + (fun cfg => (cfg.stk k).length) (Runtime.programPushBound (sourceMachine P)) + (Runtime.stepStackLength (sourceMachine P) k) raw + exact h.trans (Nat.add_le_add_right (Runtime.initialStackLength (sourceMachine P) input k) _) + have cleanupBound := MachineDrainMany.steps_le_uniform chosen base _ stackBound + rw [embedded_init, correctOutput] at joined + exact { toEvalsTo := joined.toEvalsTo + steps_le_m := joined.steps_le_m.trans (by omega) } + +noncomputable def completedTime (P : Program K Λ σ) (chosen : List K) + (rawTime : Polynomial Nat) : Polynomial Nat := + rawTime + Polynomial.C chosen.length * + (Polynomial.X + rawTime * Polynomial.C (Runtime.programPushBound (sourceMachine P)) + 1) + 1 + +theorem completedTime_eval (P : Program K Λ σ) (chosen : List K) + (rawTime : Polynomial Nat) (n : Nat) : + (completedTime P chosen rawTime).eval n = + rawTime.eval n + chosen.length * + (n + rawTime.eval n * Runtime.programPushBound (sourceMachine P) + 1) + 1 := by + simp [completedTime] + +structure TerminalRun (P : Program K Λ σ) (input output : List Bool) (budget : Nat) where + state : σ + tapes : K → List Bool + execution : StateTransition.EvalsToInTime (sourceMachine P).step + (initList (sourceMachine P) input) (some ⟨none, state, tapes⟩) budget + output_eq : tapes P.output = output + +noncomputable def computableInPolyTime {α β : Type} + (P : Program K Λ σ) (chosen : List K) + (complete : ∀ k, k ∈ chosen ↔ k ≠ P.output) + (encodeIn : α → List Bool) (encodeOut : β → List Bool) (f : α → β) + (rawTime : Polynomial Nat) + (run : ∀ a, TerminalRun P (encodeIn a) (encodeOut (f a)) + (rawTime.eval (encodeIn a).length)) : + TM2ComputableInPolyTime encodeIn encodeOut f where + tm := completedMachine P chosen + inputAlphabet := Equiv.refl Bool + outputAlphabet := Equiv.refl Bool + time := completedTime P chosen rawTime + outputsFun a := by + change TM2OutputsInTime (completedMachine P chosen) ((encodeIn a).map id) + (some ((encodeOut (f a)).map id)) ((completedTime P chosen rawTime).eval _) + dsimp only [completedMachine] + rw [List.map_id, List.map_id, completedTime_eval] + exact outputsInTime P chosen complete _ _ (run a).state (run a).tapes _ + (run a).execution (run a).output_eq + +theorem computableInPolyTime_finite_alphabet {α β : Type} + (P : Program K Λ σ) (chosen : List K) + (complete : ∀ k, k ∈ chosen ↔ k ≠ P.output) + (encodeIn : α → List Bool) (encodeOut : β → List Bool) (f : α → β) + (rawTime : Polynomial Nat) + (run : ∀ a, TerminalRun P (encodeIn a) (encodeOut (f a)) + (rawTime.eval (encodeIn a).length)) : + MachineFiniteAlphabet.FiniteAlphabet + (computableInPolyTime P chosen complete encodeIn encodeOut f rawTime run).tm := + finiteAlphabet P chosen + +noncomputable def computableInPolyTimeOfEnumeration {α β : Type} {N : Nat} + (P : Program K Λ σ) (enumeration : Fin N ≃ K) + (encodeIn : α → List Bool) (encodeOut : β → List Bool) (f : α → β) + (rawTime : Polynomial Nat) + (run : ∀ a, TerminalRun P (encodeIn a) (encodeOut (f a)) + (rawTime.eval (encodeIn a).length)) : + TM2ComputableInPolyTime encodeIn encodeOut f := + computableInPolyTime P (MachineDrainMany.workTapes enumeration P.output) + (fun k => MachineDrainMany.mem_workTapes enumeration P.output k) + encodeIn encodeOut f rawTime run + +end IndependentSetsGames.Foundations.Complexity.MachineCanonicalOutput + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/TableIterationFiniteAlphabet.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/TableIterationFiniteAlphabet.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e21a64f590fac05cee6e3a8584ead91f096d0a3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/TableIterationFiniteAlphabet.lean @@ -0,0 +1,234 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFiniteAlphabet +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFComputation + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.TableIterationFiniteAlphabet + +open PCP MachineFiniteAlphabet + +theorem initial : FiniteAlphabet MachineRawInitialTable.computableInPolyTime.tm := by + intro k + change Finite Bool + infer_instance + +theorem finalCNF : FiniteAlphabet FinalCNFMachine.Program.computableInPolyTime.tm := by + intro k + change Finite Bool + infer_instance + +theorem counter : FiniteAlphabet MachineTableIteration.counterCertificate.tm := by + intro k + change Finite Bool + infer_instance + +variable (H : RoundTables.BaseTable) + (body : Turing.TM2ComputableInPolyTime GraphTables.tableBits GraphTables.tableBits + (RoundTables.build H)) + (finiteBody : FiniteAlphabet body.tm) + +include finiteBody + +theorem counted : FiniteAlphabet (MachineTableIteration.countedCertificate H body).tm := + repeat_machine body.tm body.inputAlphabet body.outputAlphabet finiteBody + +theorem iteration : FiniteAlphabet (MachineTableIteration.computableInPolyTime H body).tm := + composeBits MachineTableIteration.counterCertificate + (MachineTableIteration.countedCertificate H body) counter (counted H body finiteBody) + +theorem table : FiniteAlphabet (MachineTableIteration.tableCertificate H body).tm := + composeBits MachineTableIteration.initialCertificate + (MachineTableIteration.computableInPolyTime H body) initial (iteration H body finiteBody) + +theorem gapMap : FiniteAlphabet (MachineTableIteration.gapMapCertificate H body).tm := + composeBits (MachineTableIteration.tableCertificate H body) + FinalCNFMachine.Program.computableInPolyTime (table H body finiteBody) finalCNF + +end IndependentSetsGames.Foundations.Complexity.TableIterationFiniteAlphabet + +namespace IndependentSetsCut.CounterMachine +open Turing + +inductive Tape (R : Type) where + | input | backup | output | reg (r : R) + deriving DecidableEq, Fintype + +inductive Instruction (R L : Type) where + | inc (r : R) (next : L) + | dec (r : R) (positive zero : L) + | test (r : R) (zero positive : L) + | read (one zero empty : L) + | back (nonempty empty : L) + | write (b : Bool) (next : L) + | discard (next : L) + | jump (next : L) + | halt + +structure Data (R : Type) where + reg : R → ℕ + input : List Bool + backup : List Bool + output : List Bool + +structure Configuration (R L : Type) extends Data R where + label : Option L + +variable {R L : Type} [DecidableEq R] + +def Instruction.execute (i : Instruction R L) (d : Data R) : Configuration R L := + match i with + | .inc r next => ⟨{ d with reg := Function.update d.reg r (d.reg r + 1) }, some next⟩ + | .dec r positive zero => + ⟨{ d with reg := Function.update d.reg r (d.reg r - 1) }, + some (if d.reg r = 0 then zero else positive)⟩ + | .test r zero positive => ⟨d, some (if d.reg r = 0 then zero else positive)⟩ + | .read one zero empty => + ⟨{ d with input := d.input.tail, backup := d.input.take 1 ++ d.backup }, some (match d.input with + | [] => empty | true :: _ => one | false :: _ => zero)⟩ + | .back nonempty empty => + ⟨{ d with input := d.backup.take 1 ++ d.input, backup := d.backup.tail }, + some (if d.backup = [] then empty else nonempty)⟩ + | .write b next => ⟨{ d with output := b :: d.output }, some next⟩ + | .discard next => ⟨{d with input := d.input.tail}, some next⟩ + | .jump next => ⟨d, some next⟩ + | .halt => ⟨d, none⟩ + +def step (p : L → Instruction R L) (c : Configuration R L) : Option (Configuration R L) := + c.label.map (fun l => (p l).execute c.toData) + +def tapes (d : Data R) : Tape R → List Bool + | .input => d.input + | .backup => d.backup + | .output => d.output + | .reg r => List.replicate (d.reg r) true + +def embed (c : Configuration R L) : TM2.Cfg (fun _ : Tape R => Bool) L (Option Bool) := + ⟨c.label, none, tapes c.toData⟩ + +def goto (l : L) : TM2.Stmt (fun _ : Tape R => Bool) L (Option Bool) := + .load (fun _ => none) (.goto (fun _ => l)) + +def Instruction.code : Instruction R L → TM2.Stmt (fun _ : Tape R => Bool) L (Option Bool) + | .inc r next => .push (.reg r) (fun _ => true) (goto next) + | .dec r positive zero => .pop (.reg r) (fun _ b => b) + (.branch (fun b => b.isSome) (goto positive) (goto zero)) + | .test r zero positive => .peek (.reg r) (fun _ b => b) + (.branch (fun b => b.isSome) (goto positive) (goto zero)) + | .read one zero empty => .pop .input (fun _ b => b) + (.branch (fun b => b.isSome) + (.push .backup (fun b => b.getD false) + (.branch (fun b => b.getD false) (goto one) (goto zero))) (goto empty)) + | .back nonempty empty => .pop .backup (fun _ b => b) + (.branch (fun b => b.isSome) + (.push .input (fun b => b.getD false) (goto nonempty)) (goto empty)) + | .write b next => .push .output (fun _ => b) (goto next) + | .discard next => .pop .input (fun _ _ => none) (goto next) + | .jump next => goto next + | .halt => .halt + + theorem tapes_inc (d : Data R) (r : R) : + tapes { d with reg := Function.update d.reg r (d.reg r + 1) } = + Function.update (tapes d) (.reg r) (true :: tapes d (.reg r)) := by + funext k + cases k with + | input => simp [tapes] + | output => simp [tapes] + | backup => simp [tapes] + | reg s => by_cases h : s = r <;> simp [tapes, h, List.replicate_succ] + + theorem tapes_dec (d : Data R) (r : R) : + tapes { d with reg := Function.update d.reg r (d.reg r - 1) } = + Function.update (tapes d) (.reg r) (tapes d (.reg r)).tail := by + funext k + cases k with + | input => simp [tapes] + | output => simp [tapes] + | backup => simp [tapes] + | reg s => by_cases h : s = r <;> simp [tapes, h] + + theorem tapes_read (d : Data R) : + tapes { d with input := d.input.tail, backup := d.input.take 1 ++ d.backup } = + Function.update (Function.update (tapes d) .input d.input.tail) .backup + (d.input.take 1 ++ d.backup) := by + funext k; cases k <;> simp [tapes] + + theorem tapes_back (d : Data R) : + tapes { d with input := d.backup.take 1 ++ d.input, backup := d.backup.tail } = + Function.update (Function.update (tapes d) .backup d.backup.tail) .input + (d.backup.take 1 ++ d.input) := by + funext k; cases k <;> simp [tapes] + + theorem tapes_write (d : Data R) (b : Bool) : + tapes { d with output := b :: d.output } = + Function.update (tapes d) .output (b :: d.output) := by + funext k; cases k <;> simp [tapes] + + theorem instruction_simulation (i : Instruction R L) (d : Data R) : + TM2.stepAux i.code none (tapes d) = embed (i.execute d) := by + cases i with + | inc r next => simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes_inc] + | dec r pos zero => + cases h : d.reg r with + | zero => + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes, h] + simpa [h, tapes] using (tapes_dec d r).symm + | succ n => + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, + tapes, h, List.replicate_succ] + simpa [h, tapes] using (tapes_dec d r).symm + | test r zero pos => + cases h : d.reg r <;> + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes, h, List.replicate_succ] + | read one zero empty => + cases h : d.input with + | nil => + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes, h] + funext k; cases k <;> simp [tapes] + | cons b rest => + cases b <;> + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes, h] <;> + simpa [h] using (tapes_read d).symm + | back nonempty empty => + cases h : d.backup with + | nil => + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes, h] + funext k; cases k <;> simp [tapes] + | cons b rest => + cases b <;> + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes, h] <;> + simpa [h] using (tapes_back d).symm + | write b next => + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed, tapes_write, tapes] + | discard next => + simp [Instruction.code, Instruction.execute, goto, TM2.stepAux, embed] + funext k; cases k <;> simp [tapes] + | jump next => rfl + | halt => rfl + + theorem step_simulation (p : L → Instruction R L) (c : Configuration R L) : + TM2.step (fun l => (p l).code) (embed c) = (step p c).map embed := by + cases c with + | mk d l => + cases l with + | none => rfl + | some l => simpa [TM2.step, step, embed] using congrArg some (instruction_simulation (p l) d) + +def machine [Fintype R] [Fintype L] (p : L → Instruction R L) (main : L) : FinTM2 where + K := Tape R + k₀ := .input + k₁ := .output + Γ _ := Bool + Λ := L + main := main + σ := Option Bool + initialState := none + m l := (p l).code + + theorem finite_tape_alphabet [Fintype R] [Fintype L] + (p : L → Instruction R L) (main : L) (k : (machine p main).K) : + Finite ((machine p main).Γ k) := inferInstanceAs (Finite Bool) + +end IndependentSetsCut.CounterMachine + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Tape.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Tape.lean new file mode 100644 index 0000000000000000000000000000000000000000..37c047418c244ed497014c4e34e6c8bf9fe1efc7 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Tape.lean @@ -0,0 +1,229 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Bits +import OAI.Combinatorics.IndependentSets.Fourier.HonestTest + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.Hastad.SourceTape + +open scoped BigOperators +open IndependentSetsGames.Reduction.FiniteNoise + +abbrev TestTape (I J : Type*) (D : ℕ) := + Cube I × ((J → Fin D) × Cube J) + +abbrev FairTestTape (I J : Type*) (D : ℕ) := TestTape I J D × Bool + +section Expectations + +variable {X Y : Type*} [Fintype X] [Fintype Y] + +theorem expect_prod (H : X × Y → ℝ) : + (𝔼 p : X × Y, H p) = 𝔼 x : X, 𝔼 y : Y, H (x, y) := by + simpa only [Finset.univ_product_univ] using + (Finset.expect_product (Finset.univ : Finset X) (Finset.univ : Finset Y) H) + +end Expectations + +section Tape + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] {D : ℕ} + +theorem card_testTape : + Fintype.card (TestTape I J D) = + 2 ^ Fintype.card I * (D ^ Fintype.card J * 2 ^ Fintype.card J) := by + simp [TestTape, Cube] + +theorem card_fairTestTape : + Fintype.card (FairTestTape I J D) = + (2 ^ Fintype.card I * (D ^ Fintype.card J * 2 ^ Fintype.card J)) * 2 := by + rw [Fintype.card_prod, card_testTape] + rfl + +theorem expect_testTape (H : TestTape I J D → ℝ) : + (𝔼 t : TestTape I J D, H t) = + 𝔼 f : Cube I, 𝔼 z : J → Fin D, 𝔼 g : Cube J, H (f, z, g) := by + rw [expect_prod] + apply Finset.expect_congr rfl + intro f _ + exact expect_prod _ + +theorem expect_equivTape {E : Type*} [Fintype E] + (e : E ≃ TestTape I J D) (H : TestTape I J D → ℝ) : + (𝔼 s : E, H (e s)) = 𝔼 t : TestTape I J D, H t := + Fintype.expect_equiv e _ _ (fun _ => rfl) + +theorem expect_fairTestTape (H : FairTestTape I J D → ℝ) : + (𝔼 t : FairTestTape I J D, H t) = + 𝔼 t : TestTape I J D, (H (t, false) + H (t, true)) / 2 := by + rw [expect_prod] + apply Finset.expect_congr rfl + intro t _ + rw [Fintype.expect_eq_sum_div_card] + simp [add_comm] + +theorem expect_fairTestTape_ignore (H : TestTape I J D → ℝ) : + (𝔼 t : FairTestTape I J D, H t.1) = 𝔼 t : TestTape I J D, H t := by + rw [expect_prod] + simp only [Fintype.expect_const] + +def tapeQueries (π : J → I) (t : TestTape I J D) : Cube I × Cube J × Cube J := + (t.1, t.2.2, thirdQuery π t.1 t.2.2 (realizedNoise t.2.1)) + +theorem expect_tapeQueries (positive : 0 < D) (π : J → I) + (H : Cube I × Cube J × Cube J → ℝ) : + (𝔼 t : TestTape I J D, H (tapeQueries π t)) = + 𝔼 f : Cube I, ∑ μ : Cube J, noiseWeight ((D : ℝ)⁻¹) μ * + (𝔼 g : Cube J, H (f, g, thirdQuery π f g μ)) := by + rw [expect_testTape] + apply Finset.expect_congr rfl + intro f _ + exact expect_realizedNoise positive + (fun μ => 𝔼 g : Cube J, H (f, g, thirdQuery π f g μ)) + +def tapeAcceptance (D : ℕ) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : ℝ := + 𝔼 t : TestTape I J D, + if A t.1 ^^ B t.2.2 ^^ B (thirdQuery π t.1 t.2.2 (realizedNoise t.2.1)) + then 0 else 1 + +theorem tapeAcceptance_eq_realizedTestAcceptance (D : ℕ) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : + tapeAcceptance D π A B = realizedTestAcceptance D π A B := + expect_testTape _ + +theorem tapeAcceptance_eq_testAcceptance (positive : 0 < D) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : + tapeAcceptance D π A B = testAcceptance ((D : ℝ)⁻¹) π A B := by + rw [tapeAcceptance_eq_realizedTestAcceptance, + realizedTestAcceptance_eq_testAcceptance positive] + +theorem tapeAcceptance_eq_sum_div_card (D : ℕ) (π : J → I) + (A : Cube I → Bool) (B : Cube J → Bool) : + tapeAcceptance D π A B = + (∑ t : TestTape I J D, + if A t.1 ^^ B t.2.2 ^^ B (thirdQuery π t.1 t.2.2 (realizedNoise t.2.1)) + then (0 : ℝ) else 1) / Fintype.card (TestTape I J D) := + Fintype.expect_eq_sum_div_card _ + +end Tape + +variable {X Λ : Type*} + +def restrictFunction (P : X → Prop) (f : X → Λ) : {x : X // P x} → Λ := + fun x => f x.val + +theorem expect_restrictFunction [Fintype X] [DecidableEq X] [Fintype Λ] [Nonempty Λ] + (P : X → Prop) [DecidablePred P] (H : ({x : X // P x} → Λ) → ℝ) : + (𝔼 f : X → Λ, H (restrictFunction P f)) = + 𝔼 g : {x : X // P x} → Λ, H g := by + classical + calc + _ = 𝔼 p : ({x : X // P x} → Λ) × ({x : X // ¬ P x} → Λ), H p.1 := + Fintype.expect_equiv (Equiv.piEquivPiSubtypeProd P (fun _ => Λ)) _ _ + (fun _ => rfl) + _ = _ := by + rw [expect_prod] + simp only [Fintype.expect_const] + +variable {I J : Type*} + +def restrictTape (P : I → Prop) (Q : J → Prop) {D : ℕ} + (t : TestTape I J D) : TestTape {i : I // P i} {j : J // Q j} D := + (restrictFunction P t.1, restrictFunction Q t.2.1, restrictFunction Q t.2.2) + +theorem expect_restrictTape [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (P : I → Prop) (Q : J → Prop) [DecidablePred P] [DecidablePred Q] + {D : ℕ} (positive : 0 < D) + (H : TestTape {i : I // P i} {j : J // Q j} D → ℝ) : + (𝔼 t : TestTape I J D, H (restrictTape P Q t)) = + 𝔼 t : TestTape {i : I // P i} {j : J // Q j} D, H t := by + let : Nonempty (Fin D) := ⟨⟨0, positive⟩⟩ + rw [expect_testTape, expect_testTape] + change (𝔼 f : Cube I, 𝔼 z : J → Fin D, 𝔼 g : Cube J, + H (restrictFunction P f, restrictFunction Q z, restrictFunction Q g)) = _ + have hg (f : Cube I) (z : J → Fin D) : + (𝔼 g : Cube J, + H (restrictFunction P f, restrictFunction Q z, restrictFunction Q g)) = + 𝔼 g : Cube {j : J // Q j}, H (restrictFunction P f, restrictFunction Q z, g) := + expect_restrictFunction (Λ := Bool) Q + (fun g => H (restrictFunction P f, restrictFunction Q z, g)) + simp_rw [hg] + have hz (f : Cube I) : + (𝔼 z : J → Fin D, 𝔼 g : Cube {j : J // Q j}, + H (restrictFunction P f, restrictFunction Q z, g)) = + 𝔼 z : {j : J // Q j} → Fin D, 𝔼 g : Cube {j : J // Q j}, + H (restrictFunction P f, z, g) := + expect_restrictFunction (Λ := Fin D) Q + (fun z => 𝔼 g : Cube {j : J // Q j}, H (restrictFunction P f, z, g)) + simp_rw [hz] + exact expect_restrictFunction (Λ := Bool) P + (fun f => 𝔼 z : {j : J // Q j} → Fin D, 𝔼 g : Cube {j : J // Q j}, H (f, z, g)) + +def restrictedProjection (P : I → Prop) (Q : J → Prop) (π : J → I) + (hπ : ∀ j, Q j → P (π j)) : {j : J // Q j} → {i : I // P i} := + fun j => ⟨π j.val, hπ j.val j.property⟩ + +theorem restrict_realizedNoise (Q : J → Prop) {D : ℕ} (z : J → Fin D) : + restrictFunction Q (realizedNoise z) = realizedNoise (restrictFunction Q z) := rfl + +theorem restrict_thirdQuery (P : I → Prop) (Q : J → Prop) (π : J → I) + (hπ : ∀ j, Q j → P (π j)) (f : Cube I) (g μ : Cube J) : + restrictFunction Q (thirdQuery π f g μ) = + thirdQuery (restrictedProjection P Q π hπ) + (restrictFunction P f) (restrictFunction Q g) (restrictFunction Q μ) := rfl + +theorem expect_restricted_queries [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (P : I → Prop) (Q : J → Prop) [DecidablePred P] [DecidablePred Q] + (π : J → I) (hπ : ∀ j, Q j → P (π j)) {D : ℕ} (positive : 0 < D) + (H : Cube {i : I // P i} × Cube {j : J // Q j} × Cube {j : J // Q j} → ℝ) : + (𝔼 t : TestTape I J D, + H (restrictFunction P t.1, restrictFunction Q t.2.2, + restrictFunction Q (thirdQuery π t.1 t.2.2 (realizedNoise t.2.1)))) = + 𝔼 t : TestTape {i : I // P i} {j : J // Q j} D, + H (tapeQueries (restrictedProjection P Q π hπ) t) := by + exact expect_restrictTape P Q positive + (fun t => H (tapeQueries (restrictedProjection P Q π hπ) t)) + +def restrictRightTape (Q : J → Prop) {D : ℕ} (t : TestTape I J D) : + TestTape I {j : J // Q j} D := + (t.1, restrictFunction Q t.2.1, restrictFunction Q t.2.2) + +theorem expect_restrictRightTape [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] (Q : J → Prop) [DecidablePred Q] + {D : ℕ} (positive : 0 < D) (H : TestTape I {j : J // Q j} D → ℝ) : + (𝔼 t : TestTape I J D, H (restrictRightTape Q t)) = + 𝔼 t : TestTape I {j : J // Q j} D, H t := by + let : Nonempty (Fin D) := ⟨⟨0, positive⟩⟩ + rw [expect_testTape, expect_testTape] + apply Finset.expect_congr rfl + intro f _ + change (𝔼 z : J → Fin D, 𝔼 g : Cube J, + H (f, restrictFunction Q z, restrictFunction Q g)) = _ + have hg (z : J → Fin D) : + (𝔼 g : Cube J, H (f, restrictFunction Q z, restrictFunction Q g)) = + 𝔼 g : Cube {j : J // Q j}, H (f, restrictFunction Q z, g) := + expect_restrictFunction (Λ := Bool) Q (fun g => H (f, restrictFunction Q z, g)) + simp_rw [hg] + exact expect_restrictFunction (Λ := Fin D) Q + (fun z => 𝔼 g : Cube {j : J // Q j}, H (f, z, g)) + +theorem expect_rightRestricted_queries [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] (Q : J → Prop) [DecidablePred Q] + (π : J → I) {D : ℕ} (positive : 0 < D) + (H : Cube I × Cube {j : J // Q j} × Cube {j : J // Q j} → ℝ) : + (𝔼 t : TestTape I J D, + H (t.1, restrictFunction Q t.2.2, + restrictFunction Q (thirdQuery π t.1 t.2.2 (realizedNoise t.2.1)))) = + 𝔼 t : TestTape I {j : J // Q j} D, + H (tapeQueries (fun j => π j.val) t) := by + exact expect_restrictRightTape Q positive + (fun t => H (tapeQueries (fun j => π j.val) t)) + +end IndependentSetsGames.Foundations.Hastad.SourceTape + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Tape2.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Tape2.lean new file mode 100644 index 0000000000000000000000000000000000000000..368f8f070210a4afc455f5f284fd9562dda992a5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Tape2.lean @@ -0,0 +1,425 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularTableRuntime +import OAI.Combinatorics.IndependentSets.Machines.VertexLabel +import OAI.Combinatorics.IndependentSets.Machines.MachineOverlayRows + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineOverlayTable + +open Turing MachineComposition +open PCP PCP.GraphTables PCP.PreprocessingOverlayWords +open MachineCloudPadding + +variable {A : Type} {d e : Nat} + +abbrev Tape := Fin 5 ⊕ Fin 12 +abbrev Ambient (A : Type) (d e : Nat) := ((A × Fin e) × MachineLazyRows.Buffer) × Fin d +abbrev State (A : Type) (d e : Nat) := Ambient A d e × Option Bool + +def graphArchive : Tape := .inl 0 +def graphStream : Tape := .inl 1 +def scratch : Tape := .inl 2 +def vertexCount : Tape := .inl 3 +def dartCount : Tape := .inl 4 +def expanderArchive : Tape := .inr 0 +def expanderStream : Tape := .inr 1 +def fuel : Tape := .inr 2 +def vertex : Tape := .inr 3 +def tail : Tape := .inr 4 +def oldReverse : Tape := .inr 5 +def relation : Tape := .inr 6 +def dividedCopy : Tape := .inr 7 +def quotient : Tape := .inr 8 +def newReverse : Tape := .inr 9 +def rowBuffer : Tape := .inr 10 +def output : Tape := .inr 11 + +def oldTapes : Fin 10 → Tape := + ![tail, oldReverse, relation, scratch, dividedCopy, quotient, newReverse, + output, rowBuffer, graphStream] + +def expanderTapes : Fin 10 → Tape := + ![tail, oldReverse, relation, scratch, dividedCopy, quotient, newReverse, + output, rowBuffer, expanderStream] + +theorem oldTapes_injective : Function.Injective oldTapes := by + intro i j h + fin_cases i <;> fin_cases j <;> + simp_all [oldTapes, tail, oldReverse, relation, scratch, dividedCopy, quotient, + newReverse, output, rowBuffer, graphStream] + +theorem expanderTapes_injective : Function.Injective expanderTapes := by + intro i j h + fin_cases i <;> fin_cases j <;> + simp_all [expanderTapes, tail, oldReverse, relation, scratch, dividedCopy, quotient, + newReverse, output, rowBuffer, expanderStream] + +def clean (d e : Nat) (hd : 0 < d) (he : 0 < e) (a : A) : State A d e := + MachineLazyRows.streamClean d hd (a, MachineFixedDivMod.residue e he 0) + +def expanderState (A : Type) (d e : Nat) : + MachineOverlayRows.State ((A × MachineLazyRows.Buffer) × Fin d) e ≃ State A d e where + toFun + | ((((a, buffer), rd), re), bit) => ((((a, re), buffer), rd), bit) + invFun + | ((((a, re), buffer), rd), bit) => ((((a, buffer), rd), re), bit) + left_inv := by rintro ⟨⟨⟨⟨a, buffer⟩, rd⟩, re⟩, bit⟩; rfl + right_inv := by rintro ⟨⟨⟨⟨a, re⟩, buffer⟩, rd⟩, bit⟩; rfl + +theorem expanderState_clean (d e : Nat) (hd : 0 < d) (he : 0 < e) (a : A) : + expanderState A d e (MachinePortReindex.clean e he + ((a, MachineRegularOriginalRow.zeroBuffer), MachineFixedDivMod.residue d hd 0)) = + clean d e hd he a := rfl + +inductive MainLabel (d e : Nat) + | copyHFirst | copyHSecond + | countSeed | countScan | countRestore + | headerSeed | headerScan | headerRestore + | fuelSeed | fuelScan | fuelRestore | vertexSeed | guard + | old (stage : MachineLazyRows.VertexLabel d) + | tailSeed | tailScan | tailRestore + | expander (stage : MachineOverlayRows.VertexLabel e) + | drainTail | increment + | drainFuel | drainVertex | drainVertexCount | drainDartCount + deriving DecidableEq, Fintype + +abbrev Label (d e : Nat) := MachineTableSplit.Label ⊕ MainLabel d e + +def next (l : MainLabel d e) : Option (Label d e) := some (.inr l) + +def mainInstruction (d e : Nat) (hd : 0 < d) (he : 0 < e) : + MainLabel d e → TM2.Stmt (fun _ : Tape => Bool) (Label d e) (State A d e) + | .copyHFirst => Reduction.MachineTransfer.loopAt expanderArchive scratch id false + (.inr .copyHFirst) (next .copyHSecond) + | .copyHSecond => MachineCopy.forkLoop scratch expanderArchive expanderStream false + (.inr .copyHSecond) (next .countSeed) + | .countSeed => MachineUnaryAffineAt.seed output 0 (.inr .countScan) + | .countScan => MachineUnaryAffineAt.scan vertexCount scratch output (d + e) + (.inr .countScan) (.inr .countRestore) + | .countRestore => Reduction.MachineTransfer.loopAt scratch vertexCount id false + (.inr .countRestore) (next .headerSeed) + | .headerSeed => MachineUnaryAffineAt.seed output 0 (.inr .headerScan) + | .headerScan => MachineUnaryAffineAt.scan vertexCount scratch output 1 + (.inr .headerScan) (.inr .headerRestore) + | .headerRestore => Reduction.MachineTransfer.loopAt scratch vertexCount id false + (.inr .headerRestore) (next .fuelSeed) + | .fuelSeed => MachineUnaryAffineAt.seed fuel 0 (.inr .fuelScan) + | .fuelScan => MachineUnaryAffineAt.scan vertexCount scratch fuel 1 + (.inr .fuelScan) (.inr .fuelRestore) + | .fuelRestore => Reduction.MachineTransfer.loopAt scratch vertexCount id false + (.inr .fuelRestore) (next .vertexSeed) + | .vertexSeed => .push vertex (fun _ => false) (.goto fun _ => .inr .guard) + | .guard => MachineUnaryCounter.guard fuel (.inr (.old (0, none))) (.inr .drainFuel) + | .old stage => MachineLazyRows.vertexInstruction d hd (d + e) 0 oldTapes + (fun stage => .inr (.old stage)) (next .tailSeed) stage + | .tailSeed => MachineUnaryAffineAt.seed tail 0 (.inr .tailScan) + | .tailScan => MachineUnaryAffineAt.scan vertex scratch tail 1 + (.inr .tailScan) (.inr .tailRestore) + | .tailRestore => Reduction.MachineTransfer.loopAt scratch vertex id false + (.inr .tailRestore) (next (.expander (0, none))) + | .expander stage => MachineStateEquiv.statement (expanderState A d e) + (MachineOverlayRows.vertexInstruction d e he expanderTapes + (fun stage => .inr (.expander stage)) (next .drainTail) stage) + | .drainTail => MachineDrain.drain tail (.inr .drainTail) (next .increment) + | .increment => .push vertex (fun _ => true) (.goto fun _ => .inr .guard) + | .drainFuel => MachineDrain.drain fuel (.inr .drainFuel) (next .drainVertex) + | .drainVertex => MachineDrain.drain vertex (.inr .drainVertex) (next .drainVertexCount) + | .drainVertexCount => MachineDrain.drain vertexCount (.inr .drainVertexCount) (next .drainDartCount) + | .drainDartCount => MachineDrain.drain dartCount (.inr .drainDartCount) none + +def program (d e : Nat) (hd : 0 < d) (he : 0 < e) : + Label d e → TM2.Stmt (fun _ : Tape => Bool) (Label d e) (State A d e) + | .inl l => Placement.statement Sum.inl Sum.inl (next .copyHFirst) + (MachineTableSplit.program l) + | .inr l => mainInstruction d e hd he l + +theorem program_main (d e : Nat) (hd : 0 < d) (he : 0 < e) (l : MainLabel d e) : + program (A := A) d e hd he (.inr l) = mainInstruction d e hd he l := rfl + +def extraTapes (rawH : List Bool) : Fin 12 → List Bool := + fun i => if i = 0 then rawH else [] + +def splitView : Tape → Option (Fin 5) + | .inl i => some i + | .inr _ => none + +def combine (left : Fin 5 → List Bool) (rawH : List Bool) : Tape → List Bool + | .inl i => left i + | .inr i => extraTapes rawH i + +def initialTapes (graph rawH : List Bool) : Tape → List Bool := + combine (MachineTableSplit.initialTapes graph) rawH + +def splitTapes (n m : Nat) (rows rawH : List Bool) : Tape → List Bool := + combine (MachineTableSplit.resultTapes n m rows) rawH + +theorem placedTapes (left : Fin 5 → List Bool) (rawH : List Bool) : + Placement.tapes splitView left (initialTapes [] rawH) = combine left rawH := by + funext k + cases k <;> rfl + +theorem splitTrace (d e : Nat) (hd : 0 < d) (he : 0 < e) + (table : GraphTables.Table) (rawH : List Bool) (a : A) : + (advance (TM2.step (program d e hd he)))^[MachineTableSplit.exactSteps + table.vertices table.darts (MachineTableSplit.rowsBits table)] + (some ⟨some (.inl .copyFirst), clean d e hd he a, + initialTapes (GraphTables.tableBits table) rawH⟩) = + some ⟨next .copyHFirst, clean d e hd he a, + splitTapes table.vertices table.darts (MachineTableSplit.rowsBits table) rawH⟩ := by + let ambient := (clean d e hd he a).1 + have source := MachineTableSplit.tableTrace table ambient none + have placed := Placement.trace (Sum.inl : Fin 5 → Tape) splitView (fun _ => rfl) + (by intro j k h; cases j <;> simp_all [splitView]) + (Sum.inl : MachineTableSplit.Label → Label d e) (next .copyHFirst) + (initialTapes [] rawH) MachineTableSplit.program (program d e hd he) (fun _ => rfl) + _ _ _ source + simp only [Placement.configuration, Placement.label] at placed + rw [placedTapes, placedTapes] at placed + simpa only [initialTapes, + splitTapes, ambient, clean, MachineLazyRows.streamClean, MachinePortReindex.clean] using placed + +def memory (g h gs hs n m f v t out : List Bool) : Tape → List Bool + | .inl i => ![g, gs, [], n, m] i + | .inr i => ![h, hs, f, v, t, [], [], [], [], [], [], out] i + +@[simp] theorem memory_graphArchive (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out graphArchive = g := rfl +@[simp] theorem memory_graphStream (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out graphStream = gs := rfl +@[simp] theorem memory_scratch (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out scratch = [] := rfl +@[simp] theorem memory_vertexCount (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out vertexCount = n := rfl +@[simp] theorem memory_dartCount (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out dartCount = m := rfl +@[simp] theorem memory_expanderArchive (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out expanderArchive = h := rfl +@[simp] theorem memory_expanderStream (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out expanderStream = hs := rfl +@[simp] theorem memory_fuel (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out fuel = f := rfl +@[simp] theorem memory_vertex (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out vertex = v := rfl +@[simp] theorem memory_tail (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out tail = t := rfl +@[simp] theorem memory_oldReverse (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out oldReverse = [] := rfl +@[simp] theorem memory_relation (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out relation = [] := rfl +@[simp] theorem memory_dividedCopy (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out dividedCopy = [] := rfl +@[simp] theorem memory_quotient (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out quotient = [] := rfl +@[simp] theorem memory_newReverse (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out newReverse = [] := rfl +@[simp] theorem memory_rowBuffer (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out rowBuffer = [] := rfl +@[simp] theorem memory_output (g h gs hs n m f v t out : List Bool) : + memory g h gs hs n m f v t out output = out := rfl + +@[simp] theorem update_output (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) output x = memory g h gs hs n m f v t x := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl +@[simp] theorem update_expanderStream (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) expanderStream x = + memory g h gs x n m f v t out := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl +@[simp] theorem update_graphStream (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) graphStream x = + memory g h x hs n m f v t out := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl +@[simp] theorem update_fuel (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) fuel x = memory g h gs hs n m x v t out := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl +@[simp] theorem update_vertex (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) vertex x = memory g h gs hs n m f x t out := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl +@[simp] theorem update_tail (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) tail x = memory g h gs hs n m f v x out := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl +@[simp] theorem update_vertexCount (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) vertexCount x = memory g h gs hs x m f v t out := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl +@[simp] theorem update_dartCount (g h gs hs n m f v t out x : List Bool) : + Function.update (memory g h gs hs n m f v t out) dartCount x = memory g h gs hs n x f v t out := by + funext k; rcases k with i | i <;> fin_cases i <;> rfl + +theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {n m : Nat} + (first : f^[n] a = b) (second : f^[m] b = c) : f^[n + m] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem initialTapes_memory (g h : List Bool) : + initialTapes g h = memory g h [] [] [] [] [] [] [] [] := by + funext k + rcases k with i | i <;> fin_cases i <;> + simp [initialTapes, combine, extraTapes, MachineTableSplit.initialTapes, + MachineTableSplit.tapes, memory] + +theorem splitTapes_memory (n m : Nat) (rows rawH : List Bool) : + splitTapes n m rows rawH = memory (encodeWords [n, m] ++ rows) rawH rows [] + (encodeWord n) (encodeWord m) [] [] [] [] := by + funext k + rcases k with i | i <;> fin_cases i <;> + simp [splitTapes, combine, extraTapes, MachineTableSplit.resultTapes, + MachineTableSplit.tapes, memory] + +def preparationSteps (n : Nat) (h : List Bool) : Nat := 2 * (h.length + 1) + 6 * (n + 1) + 4 + +theorem preparationTrace (d e : Nat) (hd : 0 < d) (he : 0 < e) + (g h gs : List Bool) (n m : Nat) (a : A) : + (advance (TM2.step (program d e hd he)))^[preparationSteps n h] + (some ⟨next .copyHFirst, clean d e hd he a, + memory g h gs [] (encodeWord n) (encodeWord m) [] [] [] []⟩) = + some ⟨next .guard, clean d e hd he a, + memory g h gs h (encodeWord n) (encodeWord m) (encodeWord n) (encodeWord 0) [] + (encodeWords [n, n * (d + e)])⟩ := by + let b0 := memory g h gs [] (encodeWord n) (encodeWord m) [] [] [] [] + let b1 := memory g h gs h (encodeWord n) (encodeWord m) [] [] [] [] + let b2 := memory g h gs h (encodeWord n) (encodeWord m) [] [] [] (encodeWord ((d + e) * n)) + let b3 := memory g h gs h (encodeWord n) (encodeWord m) [] [] [] + (encodeWords [n, n * (d + e)]) + let b4 := memory g h gs h (encodeWord n) (encodeWord m) (encodeWord n) [] [] + (encodeWords [n, n * (d + e)]) + let ambient := (clean d e hd he a).1 + have hcopy := MachineCopy.copyTrace expanderArchive expanderStream scratch + (by decide) (by decide) (by decide) false (.inr .copyHFirst) (.inr .copyHSecond) + (next .countSeed) (program d e hd he) rfl rfl b0 rfl ambient none + have copyRun : (advance (TM2.step (program d e hd he)))^[2 * (h.length + 1)] + (some ⟨next .copyHFirst, clean d e hd he a, b0⟩) = + some ⟨next .countSeed, clean d e hd he a, b1⟩ := by + simpa only [b0, b1, memory_expanderArchive, memory_expanderStream, next, List.append_nil, + update_expanderStream, ambient, clean, MachineLazyRows.streamClean, + MachinePortReindex.clean] using hcopy + have hcount := MachineUnaryAffineAt.seededAffineTrace vertexCount scratch output + (by decide) (by decide) (by decide) (d + e) 0 + (.inr .countSeed) (.inr .countScan) (.inr .countRestore) (next .headerSeed) + (program d e hd he) rfl rfl rfl b1 n [] (by simp [b1, memory, vertexCount]) rfl ambient none + have countRun : (advance (TM2.step (program d e hd he)))^[2 * (n + 1) + 1] + (some ⟨next .countSeed, clean d e hd he a, b1⟩) = + some ⟨next .headerSeed, clean d e hd he a, b2⟩ := by + simpa only [b1, b2, memory_output, next, List.append_nil, Nat.add_zero, update_output, + ambient, clean, MachineLazyRows.streamClean, MachinePortReindex.clean] using hcount + have hheader := MachineUnaryAffineAt.seededAffineTrace vertexCount scratch output + (by decide) (by decide) (by decide) 1 0 + (.inr .headerSeed) (.inr .headerScan) (.inr .headerRestore) (next .fuelSeed) + (program d e hd he) rfl rfl rfl b2 n [] (by simp [b2, memory, vertexCount]) rfl ambient none + have headerRun : (advance (TM2.step (program d e hd he)))^[2 * (n + 1) + 1] + (some ⟨next .headerSeed, clean d e hd he a, b2⟩) = + some ⟨next .fuelSeed, clean d e hd he a, b3⟩ := by + simpa only [b2, b3, memory_output, next, Nat.one_mul, Nat.add_zero, update_output, + Nat.mul_comm (d + e) n, encodeWords, List.append_nil, + ambient, clean, MachineLazyRows.streamClean, MachinePortReindex.clean] using hheader + have hfuel := MachineUnaryAffineAt.seededAffineTrace vertexCount scratch fuel + (by decide) (by decide) (by decide) 1 0 + (.inr .fuelSeed) (.inr .fuelScan) (.inr .fuelRestore) (next .vertexSeed) + (program d e hd he) rfl rfl rfl b3 n [] (by simp [b3, memory, vertexCount]) rfl ambient none + have fuelRun : (advance (TM2.step (program d e hd he)))^[2 * (n + 1) + 1] + (some ⟨next .fuelSeed, clean d e hd he a, b3⟩) = + some ⟨next .vertexSeed, clean d e hd he a, b4⟩ := by + simpa only [b3, b4, memory_fuel, next, List.append_nil, Nat.one_mul, Nat.add_zero, + update_fuel, ambient, clean, MachineLazyRows.streamClean, MachinePortReindex.clean] using hfuel + have seedRun : (advance (TM2.step (program d e hd he)))^[1] + (some ⟨next .vertexSeed, clean d e hd he a, b4⟩) = + some ⟨next .guard, clean d e hd he a, + memory g h gs h (encodeWord n) (encodeWord m) (encodeWord n) (encodeWord 0) [] + (encodeWords [n, n * (d + e)])⟩ := by + change some (TM2.stepAux (program d e hd he (.inr .vertexSeed)) _ _) = _ + simp only [program, mainInstruction, TM2.stepAux, b4, memory_vertex, + update_vertex, next, encodeWord, List.replicate_zero, List.nil_append] + have all := joinTrace (joinTrace (joinTrace (joinTrace copyRun countRun) headerRun) fuelRun) seedRun + have count : preparationSteps n h = + (((2 * (h.length + 1) + (2 * (n + 1) + 1)) + (2 * (n + 1) + 1)) + + (2 * (n + 1) + 1)) + 1 := by unfold preparationSteps; omega + rw [count] + exact all + +theorem encodeWords_flatMap {α : Type*} (items : List α) (words : α → List Nat) : + encodeWords (items.flatMap words) = items.flatMap (fun x => encodeWords (words x)) := by + induction items with + | nil => rfl + | cons item items ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +private theorem encodeWords_flatten (items : List (List Nat)) : + encodeWords items.flatten = (items.map encodeWords).flatten := by + induction items with + | nil => rfl + | cons item items ih => simp only [List.flatten_cons, List.map_cons, encodeWords_append, ih] + +private theorem encodeWords_flatten_flatMap {α : Type*} (items : List (List α)) + (words : α → List Nat) : + encodeWords (items.flatten.flatMap words) = + (items.map fun xs => encodeWords (xs.flatMap words)).flatten := by + induction items with + | nil => rfl + | cons item items ih => + simp only [List.flatten_cons, List.flatMap_append, encodeWords_append, List.map_cons, ih] + +def oldRows {n d : Nat} (G : PortTables.Table n d) (v : Fin n) := List.ofFn (row G v) +def expanderValues {n e : Nat} (H : ExpanderTables.Table n e) (v : Fin n) (p : Fin e) : Nat := + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val + +def oldBlock {n d : Nat} (G : PortTables.Table n d) (v : Fin n) : List Bool := + MachineLazyRows.recordsInput (oldRows G v) +def expanderBlock {n e : Nat} (H : ExpanderTables.Table n e) (v : Fin n) : List Bool := + encodeWords (List.ofFn (expanderValues H v)) + +def oldOutput {n d : Nat} (G : PortTables.Table n d) (e : Nat) (v : Fin n) : List Bool := + MachineLazyRows.recordsOutput d (d + e) 0 (oldRows G v) +def expanderOutput {n e : Nat} (d : Nat) (H : ExpanderTables.Table n e) (v : Fin n) : List Bool := + MachineOverlayRows.streamOutput d e v.val (List.ofFn (expanderValues H v)) +def outputBlock {n d e : Nat} (G : PortTables.Table n d) (H : ExpanderTables.Table n e) + (v : Fin n) : List Bool := oldOutput G e v ++ expanderOutput d H v + +theorem oldOutput_eq {n d : Nat} (G : PortTables.Table n d) (e : Nat) (v : Fin n) : + oldOutput G e v = encodeWords ((List.ofFn (oldRow G e v)).flatMap rowWords) := by + rw [encodeWords_flatMap] + simp only [oldOutput, oldRows, MachineLazyRows.recordsOutput, List.flatMap_def, List.map_ofFn] + apply congrArg List.flatten + apply congrArg List.ofFn + funext p + change MachineLazyRows.reindexRowBits d (d + e) 0 (row G v p).tail.val + (row G v p).reverseIndex.val (row G v p).relation = encodeWords (rowWords (oldRow G e v p)) + rw [oldRow_words] + simp only [MachineLazyRows.reindexRowBits, MachinePortReindex.value, Nat.add_zero, + oldReverseMap, row, PreprocessingLazyWords.row, List.cons_append, List.nil_append, + encodeWords, List.append_assoc] + +theorem expanderOutput_eq {n e : Nat} (d : Nat) (H : ExpanderTables.Table n e) (v : Fin n) : + expanderOutput d H v = encodeWords ((List.ofFn (expanderRow d H v)).flatMap rowWords) := + MachineOverlayRows.streamOutput_expanderRows d H v + +theorem outputBlock_eq {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) (v : Fin n) : + outputBlock G H v = encodeWords ((vertexRows G H v).flatMap rowWords) := by + rw [outputBlock, oldOutput_eq, expanderOutput_eq] + simp only [vertexRows, List.flatMap_append, encodeWords_append] + +theorem graphRows_blocks {n d : Nat} (G : PortTables.Table n d) : + MachineTableSplit.rowsBits (PortTables.graphTable G) = (List.ofFn (oldBlock G)).flatten := by + change encodeWords ((PortTables.flatRows G).toList.flatMap rowWords) = _ + rw [PreprocessingLazyWords.flatRows_list, encodeWords_flatten_flatMap, List.map_ofFn] + apply congrArg List.flatten + apply congrArg List.ofFn + funext v + exact (MachineLazyRows.recordsInput_eq_codec (oldRows G v)).symm + +theorem expanderRows_blocks {n e : Nat} (H : ExpanderTables.Table n e) : + encodeWords (ExpanderTableWords.rotationWords H) = (List.ofFn (expanderBlock H)).flatten := by + rw [rotationWords_vertices, encodeWords_flatten, List.map_ofFn] + rfl + +theorem tableBits_blocks {n d e : Nat} (G : PortTables.Table n d) + (H : ExpanderTables.Table n e) : + PortTables.tableBits (PreprocessingOverlayTables.overlay G H) = + encodeWords [n, n * (d + e)] ++ (List.ofFn (outputBlock G H)).flatten := by + rw [tableBits_overlay, encodeWords_append, encodeWords_flatten_flatMap, List.map_ofFn] + congr 1 + apply congrArg List.flatten + apply congrArg List.ofFn + funext v + exact (outputBlock_eq G H v).symm + +end IndependentSetsGames.Foundations.Complexity.MachineOverlayTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/Tape3.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/Tape3.lean new file mode 100644 index 0000000000000000000000000000000000000000..4242eb70f62ce257f634c98ae1463c2464147880 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/Tape3.lean @@ -0,0 +1,466 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineRegularTableRuntime +import OAI.Combinatorics.IndependentSets.Machines.VertexLabel + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLazyTable + +open Turing MachineComposition PCP +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +inductive Tape + | input | output | source | vertices | darts | fuel | vertex | reverse + | tail | old | relation | scratch | divided | quotient | newReverse | rowBuffer + deriving DecidableEq + +instance : Fintype Tape where + elems := {.input, .output, .source, .vertices, .darts, .fuel, .vertex, .reverse, + .tail, .old, .relation, .scratch, .divided, .quotient, .newReverse, .rowBuffer} + complete tape := by cases tape <;> simp + +abbrev State (d : Nat) := MachineLazyRows.StreamState Unit d + +def clean (d : Nat) (positive : 0 < d) : State d := + MachineLazyRows.streamClean d positive () + +theorem clean_pair (d : Nat) (positive : 0 < d) : + ((clean d positive).1, (none : Option Bool)) = clean d positive := rfl + +def splitRoles : Fin 5 → Tape := ![.input, .source, .scratch, .vertices, .darts] +def splitView : Tape → Option (Fin 5) + | .input => some 0 | .source => some 1 | .scratch => some 2 + | .vertices => some 3 | .darts => some 4 | _ => none + +def dummyRoles : Fin 6 → Tape := ![.tail, .reverse, .relation, .rowBuffer, .output, .scratch] +def dummyView : Tape → Option (Fin 6) + | .tail => some 0 | .reverse => some 1 | .relation => some 2 + | .rowBuffer => some 3 | .output => some 4 | .scratch => some 5 | _ => none + +def oldRoles : Fin 10 → Tape := + ![.tail, .old, .relation, .scratch, .divided, .quotient, .newReverse, + .output, .rowBuffer, .source] + +theorem splitRoles_left (i : Fin 5) : splitView (splitRoles i) = some i := by + fin_cases i <;> rfl + +theorem splitRoles_right (t : Tape) (i : Fin 5) (h : splitView t = some i) : splitRoles i = t := by + cases t <;> fin_cases i <;> simp_all [splitView, splitRoles] + +theorem dummyRoles_left (i : Fin 6) : dummyView (dummyRoles i) = some i := by + fin_cases i <;> rfl + +theorem dummyRoles_right (t : Tape) (i : Fin 6) (h : dummyView t = some i) : dummyRoles i = t := by + cases t <;> fin_cases i <;> simp_all [dummyView, dummyRoles] + +theorem oldRoles_injective : Function.Injective oldRoles := by decide + +inductive Label (d : Nat) + | split (label : MachineTableSplit.Label) + | dartSeed | dartScan | dartRestore | vertexSeed | vertexScan | vertexRestore + | fuelFirst | fuelSecond | seedCounters | guard | copyVertexFirst | copyVertexSecond + | dummy (label : MachineDummyRows.Label d) + | clearDummyTail | clearDummyRelation + | oldRows (label : MachineLazyRows.VertexLabel d) + | nextVertex | clearVertices | clearDarts | clearFuel | clearVertex | clearReverse + deriving DecidableEq, Fintype + +def program (d : Nat) (positive : 0 < d) : + Label d → TM2.Stmt (fun _ : Tape => Bool) (Label d) (State d) + | .split label => MachineCloudPadding.Placement.statement splitRoles Label.split + (some .dartSeed) (MachineTableSplit.program label) + | .dartSeed => MachineUnaryAffineAt.seed .output 0 .dartScan + | .dartScan => MachineUnaryAffineAt.scan .darts .scratch .output 2 .dartScan .dartRestore + | .dartRestore => Reduction.MachineTransfer.loopAt .scratch .darts id false + .dartRestore (some .vertexSeed) + | .vertexSeed => MachineUnaryAffineAt.seed .output 0 .vertexScan + | .vertexScan => MachineUnaryAffineAt.scan .vertices .scratch .output 1 .vertexScan .vertexRestore + | .vertexRestore => Reduction.MachineTransfer.loopAt .scratch .vertices id false + .vertexRestore (some .fuelFirst) + | .fuelFirst => Reduction.MachineTransfer.loopAt .vertices .scratch id false + .fuelFirst (some .fuelSecond) + | .fuelSecond => MachineCopy.forkLoop .scratch .vertices .fuel false + .fuelSecond (some .seedCounters) + | .seedCounters => .push .vertex (fun _ => false) + (.push .reverse (fun _ => false) (.goto fun _ => .guard)) + | .guard => MachineUnaryCounter.guard .fuel .copyVertexFirst .clearVertices + | .copyVertexFirst => Reduction.MachineTransfer.loopAt .vertex .scratch id false + .copyVertexFirst (some .copyVertexSecond) + | .copyVertexSecond => MachineCopy.forkLoop .scratch .vertex .tail false + .copyVertexSecond (some (.dummy (MachineDummyRows.start d))) + | .dummy label => MachineCloudPadding.Placement.statement dummyRoles Label.dummy + (some .clearDummyTail) (MachineDummyRows.program d label) + | .clearDummyTail => MachineDrain.drain .tail .clearDummyTail (some .clearDummyRelation) + | .clearDummyRelation => MachineDrain.drain .relation .clearDummyRelation (some (.oldRows (0, none))) + | .oldRows label => MachineLazyRows.vertexInstruction d positive (2 * d) d oldRoles + Label.oldRows (some .nextVertex) label + | .nextVertex => pushWord .reverse (List.replicate d true) + (.push .vertex (fun _ => true) (.goto fun _ => .guard)) + | .clearVertices => MachineDrain.drain .vertices .clearVertices (some .clearDarts) + | .clearDarts => MachineDrain.drain .darts .clearDarts (some .clearFuel) + | .clearFuel => MachineDrain.drain .fuel .clearFuel (some .clearVertex) + | .clearVertex => MachineDrain.drain .vertex .clearVertex (some .clearReverse) + | .clearReverse => MachineDrain.drain .reverse .clearReverse none + +def frame (input source output vertices darts fuel vertex reverse : List Bool) : Tape → List Bool + | .input => input | .source => source | .output => output + | .vertices => vertices | .darts => darts | .fuel => fuel + | .vertex => vertex | .reverse => reverse | _ => [] + +def initialTapes (input : List Bool) : Tape → List Bool := frame input [] [] [] [] [] [] [] + +def loopTapes (d : Nat) (input : List Bool) (n m left v : Nat) + (source output : List Bool) : Tape → List Bool := + frame input source output (encodeWord n) (encodeWord m) (encodeWord left) + (encodeWord v) (encodeWord (2 * d * v)) + +def finalTapes (input output : List Bool) : Tape → List Bool := frame input [] output [] [] [] [] [] + +theorem joinTrace {X : Type} {f : X → X} {a b c : X} {s t : Nat} + (first : f^[s] a = b) (second : f^[t] b = c) : f^[s + t] a = c := by + rw [Nat.add_comm, Function.iterate_add_apply, first, second] + +theorem dummyTrace (d : Nat) (positive : 0 < d) (base : Tape → List Bool) (v e : Nat) + (ht : base .tail = encodeWord v) (he : base .reverse = encodeWord e) + (hr : base .relation = []) (hb : base .rowBuffer = []) (hs : base .scratch = []) : + (advance (TM2.step (program d positive)))^[MachineDummyRows.steps v e (base .output) d + 1] + (some ⟨some (.dummy (MachineDummyRows.start d)), clean d positive, base⟩) = + some ⟨some .clearDummyTail, clean d positive, + Function.update (Function.update (Function.update base .reverse (encodeWord (e + d))) + .relation MachineDummyRows.trueBits) + .output (base .output ++ MachineDummyRows.rowsBits v e d)⟩ := by + have initial : MachineCloudPadding.Placement.tapes dummyView + (MachineDummyRows.initialTapes v e (base .output)) base = base := by + funext t + cases t <;> simp [MachineCloudPadding.Placement.tapes, dummyView, + MachineDummyRows.initialTapes, MachineDummyRows.fieldTapes, ht, he, hr, hb, hs] + have final : MachineCloudPadding.Placement.tapes dummyView + (MachineDummyRows.fieldTapes v (e + d) (base .output ++ MachineDummyRows.rowsBits v e d)) + base = Function.update (Function.update (Function.update base .reverse (encodeWord (e + d))) + .relation MachineDummyRows.trueBits) + .output (base .output ++ MachineDummyRows.rowsBits v e d) := by + funext t + cases t <;> simp [MachineCloudPadding.Placement.tapes, dummyView, + MachineDummyRows.fieldTapes, ht, hb, hs] + have run := MachineCloudPadding.Placement.trace dummyRoles dummyView + dummyRoles_left dummyRoles_right Label.dummy (some .clearDummyTail) base + (MachineDummyRows.program d) (program d positive) (fun _ => rfl) _ _ _ + (MachineDummyRows.allTrace d v e (base .output) (clean d positive).1 none) + simpa only [clean_pair, MachineCloudPadding.Placement.configuration, + MachineCloudPadding.Placement.label, initial, final] using run + +theorem oldTrace {n m : Nat} (d : Nat) (positive : 0 < d) + (base : Tape → List Bool) (rows : Fin d → GraphTables.DartRow n m) (rest : List Bool) + (hi : base .source = MachineLazyRows.recordsInput (List.ofFn rows) ++ rest) + (empty : ∀ i : Fin 10, i ≠ 7 → i ≠ 9 → base (oldRoles i) = []) : + (advance (TM2.step (program d positive)))^[MachineLazyRows.vertexSteps d (2 * d) d + (List.ofFn rows) (base .output)] + (some ⟨some (.oldRows (0, none)), clean d positive, base⟩) = + some ⟨some .nextVertex, clean d positive, + Function.update (Function.update base .source rest) .output + (base .output ++ MachineLazyRows.recordsOutput d (2 * d) d (List.ofFn rows))⟩ := by + let tailBase := Function.update base Tape.source rest + have cleanBase : ∀ i : Fin 10, i ≠ 7 → i ≠ 9 → tailBase (oldRoles i) = [] := by + intro i h7 h9 + have hn : oldRoles i ≠ Tape.source := by + intro h + have h' : oldRoles i = oldRoles 9 := h + exact h9 (oldRoles_injective h') + simpa only [tailBase, Function.update_of_ne hn] using empty i h7 h9 + have initial : MachineLazyRows.streamFrame oldRoles tailBase (List.ofFn rows) (base .output) = base := by + funext t + cases t <;> simp [MachineLazyRows.streamFrame, tailBase, oldRoles, hi] + have final : MachineLazyRows.streamFrame (n := n) (m := m) oldRoles tailBase [] + (base .output ++ MachineLazyRows.recordsOutput d (2 * d) d (List.ofFn rows)) = + Function.update (Function.update base .source rest) .output + (base .output ++ MachineLazyRows.recordsOutput d (2 * d) d (List.ofFn rows)) := by + funext t + cases t <;> simp [MachineLazyRows.streamFrame, MachineLazyRows.recordsInput, tailBase, oldRoles] + have run := MachineLazyRows.vertexTrace d positive (2 * d) d oldRoles oldRoles_injective + Label.oldRows (some .nextVertex) (program d positive) (fun _ => rfl) + tailBase rows cleanBase () (base .output) + simpa only [initial, final, clean] using run + +def prefixSteps (n m : Nat) (rows : List Bool) : Nat := + 2 * (encodeWords [n, m] ++ rows).length + 5 * n + 3 * m + 17 + +theorem prefixTrace (d : Nat) (positive : 0 < d) (n m : Nat) (rows : List Bool) : + (advance (TM2.step (program d positive)))^[prefixSteps n m rows] + (some ⟨some (.split .copyFirst), clean d positive, + initialTapes (encodeWords [n, m] ++ rows)⟩) = + some ⟨some .guard, clean d positive, + loopTapes d (encodeWords [n, m] ++ rows) n m n 0 rows (encodeWords [n, 2 * m])⟩ := by + let word := encodeWords [n, m] ++ rows + let header := encodeWords [n, 2 * m] + let b₁ := frame word rows [] (encodeWord n) (encodeWord m) [] [] [] + let b₂ := frame word rows (encodeWord (2 * m)) (encodeWord n) (encodeWord m) [] [] [] + let b₃ := frame word rows header (encodeWord n) (encodeWord m) [] [] [] + let b₄ := frame word rows header (encodeWord n) (encodeWord m) (encodeWord n) [] [] + have hstart : MachineCloudPadding.Placement.tapes splitView + (MachineTableSplit.initialTapes word) (fun _ => []) = initialTapes word := by + funext t + cases t <;> simp [MachineCloudPadding.Placement.tapes, splitView, + MachineTableSplit.initialTapes, MachineTableSplit.tapes, initialTapes, frame] + have hend : MachineCloudPadding.Placement.tapes splitView + (MachineTableSplit.resultTapes n m rows) (fun _ => []) = b₁ := by + funext t + cases t <;> simp [MachineCloudPadding.Placement.tapes, splitView, + MachineTableSplit.resultTapes, MachineTableSplit.tapes, b₁, frame, word] + have split := MachineCloudPadding.Placement.trace splitRoles splitView + splitRoles_left splitRoles_right Label.split (some .dartSeed) (fun _ => []) + MachineTableSplit.program (program d positive) (fun _ => rfl) _ _ _ + (MachineTableSplit.splitTrace n m rows (clean d positive).1 none) + have c₀ : (advance (TM2.step (program d positive)))^[MachineTableSplit.exactSteps n m rows] + (some ⟨some (.split .copyFirst), clean d positive, initialTapes word⟩) = + some ⟨some .dartSeed, clean d positive, b₁⟩ := by + simp only [MachineCloudPadding.Placement.configuration, + MachineCloudPadding.Placement.label] at split + rw [hstart, hend] at split + simpa only [clean_pair] using split + have hdart : Function.update b₁ Tape.output (encodeWord (2 * m + 0) ++ b₁ .output) = b₂ := by + funext t; cases t <;> simp [b₁, b₂, frame] + have dart := MachineUnaryAffineAt.seededAffineTrace Tape.darts .scratch .output + (by decide) (by decide) (by decide) 2 0 .dartSeed .dartScan .dartRestore + (some .vertexSeed) (program d positive) rfl rfl rfl b₁ m [] + (by simp [b₁, frame]) rfl (clean d positive).1 none + have c₁ : (advance (TM2.step (program d positive)))^[2 * (m + 1) + 1] + (some ⟨some .dartSeed, clean d positive, b₁⟩) = + some ⟨some .vertexSeed, clean d positive, b₂⟩ := by + simpa only [hdart, clean_pair] using dart + have hv : Function.update b₂ Tape.output (encodeWord (1 * n + 0) ++ b₂ .output) = b₃ := by + funext t; cases t <;> simp [b₂, b₃, frame, header, encodeWords] + have vertex := MachineUnaryAffineAt.seededAffineTrace Tape.vertices .scratch .output + (by decide) (by decide) (by decide) 1 0 .vertexSeed .vertexScan .vertexRestore + (some .fuelFirst) (program d positive) rfl rfl rfl b₂ n [] + (by simp [b₂, frame]) rfl (clean d positive).1 none + have c₂ : (advance (TM2.step (program d positive)))^[2 * (n + 1) + 1] + (some ⟨some .vertexSeed, clean d positive, b₂⟩) = + some ⟨some .fuelFirst, clean d positive, b₃⟩ := by + simpa only [hv, clean_pair] using vertex + have hf : Function.update b₃ Tape.fuel (b₃ .vertices ++ b₃ .fuel) = b₄ := by + funext t; cases t <;> simp [b₃, b₄, frame] + have fuel := MachineCopy.copyTrace Tape.vertices .fuel .scratch + (by decide) (by decide) (by decide) false .fuelFirst .fuelSecond + (some .seedCounters) (program d positive) rfl rfl b₃ rfl (clean d positive).1 none + rw [hf] at fuel + have c₃ : (advance (TM2.step (program d positive)))^[2 * (n + 2)] + (some ⟨some .fuelFirst, clean d positive, b₃⟩) = + some ⟨some .seedCounters, clean d positive, b₄⟩ := by + simpa only [clean_pair, show b₃ .vertices = encodeWord n from rfl, encodeWord_length, + Nat.add_assoc] using fuel + have c₄ : (advance (TM2.step (program d positive)))^[1] + (some ⟨some .seedCounters, clean d positive, b₄⟩) = + some ⟨some .guard, clean d positive, + loopTapes d word n m n 0 rows header⟩ := by + have ht : Function.update (Function.update b₄ Tape.vertex [false]) Tape.reverse [false] = + loopTapes d word n m n 0 rows header := by + funext t; cases t <;> simp [b₄, loopTapes, frame, encodeWord] + simp only [Function.iterate_one, advance_some, TM2.step, program, TM2.stepAux] + apply congrArg some + exact congrArg (TM2.Cfg.mk _ _) ht + have all := joinTrace (joinTrace (joinTrace (joinTrace c₀ c₁) c₂) c₃) c₄ + have hc : MachineTableSplit.exactSteps n m rows + (2 * (m + 1) + 1) + + (2 * (n + 1) + 1) + 2 * (n + 2) + 1 = prefixSteps n m rows := by + dsimp [MachineTableSplit.exactSteps, prefixSteps] + omega + rw [hc] at all + exact all + +def vertexBlock {n m : Nat} (d v : Nat) (rows : Fin d → GraphTables.DartRow n m) : List Bool := + MachineDummyRows.rowsBits v (2 * d * v) d ++ + MachineLazyRows.recordsOutput d (2 * d) d (List.ofFn rows) + +def bodySteps {n m : Nat} (d v : Nat) (rows : Fin d → GraphTables.DartRow n m) + (output : List Bool) : Nat := + 2 * (v + 2) + (MachineDummyRows.steps v (2 * d * v) output d + 1) + (v + 2) + 8193 + + MachineLazyRows.vertexSteps d (2 * d) d (List.ofFn rows) + (output ++ MachineDummyRows.rowsBits v (2 * d * v) d) + 1 + +theorem frame_old_empty (input source output vertices darts fuel vertex reverse : List Bool) + (i : Fin 10) (h7 : i ≠ 7) (h9 : i ≠ 9) : + frame input source output vertices darts fuel vertex reverse (oldRoles i) = [] := by + fin_cases i <;> simp_all [frame, oldRoles] + +theorem bodyTrace {n m : Nat} (d : Nat) (positive : 0 < d) (input : List Bool) + (left v : Nat) (rows : Fin d → GraphTables.DartRow n m) (rest output : List Bool) : + (advance (TM2.step (program d positive)))^[bodySteps d v rows output] + (some ⟨some .copyVertexFirst, clean d positive, + loopTapes d input n m left v (MachineLazyRows.recordsInput (List.ofFn rows) ++ rest) output⟩) = + some ⟨some .guard, clean d positive, + loopTapes d input n m left (v + 1) rest (output ++ vertexBlock d v rows)⟩ := by + let source := MachineLazyRows.recordsInput (List.ofFn rows) ++ rest + let dummy := MachineDummyRows.rowsBits v (2 * d * v) d + let moving := MachineLazyRows.recordsOutput d (2 * d) d (List.ofFn rows) + let b₀ := loopTapes d input n m left v source output + let b₁ := Function.update b₀ Tape.tail (encodeWord v) + let b₄ := frame input source (output ++ dummy) (encodeWord n) (encodeWord m) + (encodeWord left) (encodeWord v) (encodeWord (2 * d * v + d)) + let b₂ := Function.update (Function.update b₄ Tape.tail (encodeWord v)) + Tape.relation MachineDummyRows.trueBits + let b₃ := Function.update b₄ Tape.relation MachineDummyRows.trueBits + let b₅ := frame input rest ((output ++ dummy) ++ moving) (encodeWord n) (encodeWord m) + (encodeWord left) (encodeWord v) (encodeWord (2 * d * v + d)) + have hcopy : Function.update b₀ Tape.tail (b₀ .vertex ++ b₀ .tail) = b₁ := by + simp [b₀, b₁, loopTapes, frame] + have copy := MachineCopy.copyTrace Tape.vertex .tail .scratch + (by decide) (by decide) (by decide) false .copyVertexFirst .copyVertexSecond + (some (.dummy (MachineDummyRows.start d))) (program d positive) rfl rfl b₀ rfl + (clean d positive).1 none + rw [hcopy] at copy + have c₀ : (advance (TM2.step (program d positive)))^[2 * (v + 2)] + (some ⟨some .copyVertexFirst, clean d positive, b₀⟩) = + some ⟨some (.dummy (MachineDummyRows.start d)), clean d positive, b₁⟩ := by + simpa only [clean_pair, show b₀ .vertex = encodeWord v from rfl, encodeWord_length, + Nat.add_assoc] using copy + have hdummy : Function.update (Function.update (Function.update b₁ Tape.reverse + (encodeWord (2 * d * v + d))) Tape.relation MachineDummyRows.trueBits) + Tape.output (b₁ .output ++ dummy) = b₂ := by + funext t; cases t <;> simp [b₀, b₁, b₂, b₄, loopTapes, frame] + have dummies := dummyTrace d positive b₁ v (2 * d * v) + (by simp [b₁]) (by simp [b₁, b₀, loopTapes, frame]) + (by simp [b₁, b₀, loopTapes, frame]) (by simp [b₁, b₀, loopTapes, frame]) + (by simp [b₁, b₀, loopTapes, frame]) + have c₁ : (advance (TM2.step (program d positive)))^[MachineDummyRows.steps v + (2 * d * v) output d + 1] + (some ⟨some (.dummy (MachineDummyRows.start d)), clean d positive, b₁⟩) = + some ⟨some .clearDummyTail, clean d positive, b₂⟩ := by + change (advance (TM2.step (program d positive)))^[_] _ = + some ⟨some .clearDummyTail, clean d positive, + Function.update (Function.update (Function.update b₁ Tape.reverse + (encodeWord (2 * d * v + d))) Tape.relation MachineDummyRows.trueBits) + Tape.output (b₁ .output ++ dummy)⟩ at dummies + rw [hdummy] at dummies + simpa only [show b₁ .output = output by simp [b₁, b₀, loopTapes, frame]] using dummies + have ht : Function.update b₂ Tape.tail [] = b₃ := by + funext t; cases t <;> simp [b₂, b₃, b₄, frame] + have drainTail := MachineDrain.drainTrace Tape.tail .clearDummyTail (some .clearDummyRelation) + (program d positive) rfl b₂ (b₂ .tail) (clean d positive).1 none + simp only [Function.update_eq_self, ht] at drainTail + have c₂ : (advance (TM2.step (program d positive)))^[v + 2] + (some ⟨some .clearDummyTail, clean d positive, b₂⟩) = + some ⟨some .clearDummyRelation, clean d positive, b₃⟩ := by + simpa only [clean_pair, show b₂ .tail = encodeWord v by simp [b₂], encodeWord_length, + Nat.add_assoc] using drainTail + have hr : Function.update b₃ Tape.relation [] = b₄ := by + funext t; cases t <;> simp [b₃, b₄, frame] + have drainRelation := MachineDrain.drainTrace Tape.relation .clearDummyRelation + (some (.oldRows (0, none))) (program d positive) rfl b₃ (b₃ .relation) + (clean d positive).1 none + simp only [Function.update_eq_self, hr] at drainRelation + have c₃ : (advance (TM2.step (program d positive)))^[8193] + (some ⟨some .clearDummyRelation, clean d positive, b₃⟩) = + some ⟨some (.oldRows (0, none)), clean d positive, b₄⟩ := by + simpa only [clean_pair, show b₃ .relation = MachineDummyRows.trueBits by simp [b₃], + MachineDummyRows.trueBits_length] using drainRelation + have hmoving : Function.update (Function.update b₄ Tape.source rest) Tape.output + (b₄ .output ++ moving) = b₅ := by + funext t; cases t <;> simp [b₄, b₅, frame] + have old := oldTrace d positive b₄ rows rest rfl + (fun i h7 h9 => frame_old_empty _ _ _ _ _ _ _ _ i h7 h9) + have c₄ : (advance (TM2.step (program d positive)))^[MachineLazyRows.vertexSteps d (2 * d) d + (List.ofFn rows) (output ++ dummy)] + (some ⟨some (.oldRows (0, none)), clean d positive, b₄⟩) = + some ⟨some .nextVertex, clean d positive, b₅⟩ := by + change (advance (TM2.step (program d positive)))^[_] _ = + some ⟨some .nextVertex, clean d positive, + Function.update (Function.update b₄ Tape.source rest) Tape.output + (b₄ .output ++ moving)⟩ at old + rw [hmoving] at old + exact old + have c₅ : (advance (TM2.step (program d positive)))^[1] + (some ⟨some .nextVertex, clean d positive, b₅⟩) = + some ⟨some .guard, clean d positive, + loopTapes d input n m left (v + 1) rest (output ++ vertexBlock d v rows)⟩ := by + have hrev : List.replicate d true ++ encodeWord (2 * d * v + d) = + encodeWord (2 * d * (v + 1)) := by + have hw := MachineUnaryAffineAt.prepend_replicate_word d (2 * d * v + d) [] + simp only [List.append_nil] at hw + rw [hw] + exact congrArg encodeWord (show d + (2 * d * v + d) = 2 * d * (v + 1) by + simp only [Nat.mul_add, Nat.mul_one] + omega) + have ht : Function.update (Function.update b₅ Tape.reverse + ((List.replicate d true).reverse ++ b₅ .reverse)) Tape.vertex (true :: b₅ .vertex) = + loopTapes d input n m left (v + 1) rest (output ++ vertexBlock d v rows) := by + funext t + cases t <;> simp [b₅, frame, loopTapes, vertexBlock, dummy, moving, + hrev, List.append_assoc] + simp [encodeWord, List.replicate_succ] + simp only [Function.iterate_one, advance_some, TM2.step, program, + stepAux_pushWord, TM2.stepAux] + apply congrArg some + exact congrArg (TM2.Cfg.mk _ _) ht + have all := joinTrace (joinTrace (joinTrace (joinTrace (joinTrace c₀ c₁) c₂) c₃) c₄) c₅ + exact all + +theorem drainPhase (d : Nat) (positive : 0 < d) (tape : Tape) (label : Label d) + (exit : Option (Label d)) + (atLabel : program d positive label = MachineDrain.drain tape label exit) + (base : Tape → List Bool) : + (advance (TM2.step (program d positive)))^[(base tape).length + 1] + (some ⟨some label, clean d positive, base⟩) = + some ⟨exit, clean d positive, Function.update base tape []⟩ := by + simpa only [Function.update_eq_self, clean_pair] using + MachineDrain.drainTrace tape label exit (program d positive) atLabel base + (base tape) (clean d positive).1 none + +def finishSteps (d n m v : Nat) : Nat := n + m + v + 2 * d * v + 11 + +theorem finishTrace (d : Nat) (positive : 0 < d) (input output : List Bool) (n m v : Nat) : + (advance (TM2.step (program d positive)))^[finishSteps d n m v] + (some ⟨some .guard, clean d positive, loopTapes d input n m 0 v [] output⟩) = + some ⟨none, clean d positive, finalTapes input output⟩ := by + let b₀ := loopTapes d input n m 0 v [] output + let b₁ := Function.update b₀ Tape.vertices [] + let b₂ := Function.update b₁ Tape.darts [] + let b₃ := Function.update b₂ Tape.fuel [] + let b₄ := Function.update b₃ Tape.vertex [] + have hframe : MachineUnaryCounter.counterTapes Tape.fuel b₀ 0 [] = b₀ := by + funext t; cases t <;> simp [MachineUnaryCounter.counterTapes, b₀, loopTapes, frame] + have guard := MachineUnaryCounter.guardTrace_zero Tape.fuel .guard .copyVertexFirst + .clearVertices (program d positive) rfl b₀ [] (clean d positive).1 none + have c₀ : (advance (TM2.step (program d positive)))^[1] + (some ⟨some .guard, clean d positive, b₀⟩) = + some ⟨some .clearVertices, clean d positive, b₀⟩ := by + simpa only [hframe, clean_pair] using guard + have c₁ : (advance (TM2.step (program d positive)))^[n + 2] + (some ⟨some .clearVertices, clean d positive, b₀⟩) = + some ⟨some .clearDarts, clean d positive, b₁⟩ := by + simpa only [show b₀ .vertices = encodeWord n from rfl, encodeWord_length, Nat.add_assoc] using + drainPhase d positive .vertices .clearVertices (some .clearDarts) rfl b₀ + have c₂ : (advance (TM2.step (program d positive)))^[m + 2] + (some ⟨some .clearDarts, clean d positive, b₁⟩) = + some ⟨some .clearFuel, clean d positive, b₂⟩ := by + have hv : b₁ .darts = encodeWord m := by simp [b₁, b₀, loopTapes, frame] + simpa only [hv, encodeWord_length, Nat.add_assoc] using + drainPhase d positive .darts .clearDarts (some .clearFuel) rfl b₁ + have c₃ : (advance (TM2.step (program d positive)))^[2] + (some ⟨some .clearFuel, clean d positive, b₂⟩) = + some ⟨some .clearVertex, clean d positive, b₃⟩ := by + have hv : b₂ .fuel = encodeWord 0 := by simp [b₂, b₁, b₀, loopTapes, frame] + simpa only [hv, encodeWord_length] using + drainPhase d positive .fuel .clearFuel (some .clearVertex) rfl b₂ + have c₄ : (advance (TM2.step (program d positive)))^[v + 2] + (some ⟨some .clearVertex, clean d positive, b₃⟩) = + some ⟨some .clearReverse, clean d positive, b₄⟩ := by + have hv : b₃ .vertex = encodeWord v := by simp [b₃, b₂, b₁, b₀, loopTapes, frame] + simpa only [hv, encodeWord_length, Nat.add_assoc] using + drainPhase d positive .vertex .clearVertex (some .clearReverse) rfl b₃ + have hend : Function.update b₄ Tape.reverse [] = finalTapes input output := by + funext t; cases t <;> simp [b₄, b₃, b₂, b₁, b₀, loopTapes, finalTapes, frame] + have c₅ : (advance (TM2.step (program d positive)))^[2 * d * v + 2] + (some ⟨some .clearReverse, clean d positive, b₄⟩) = + some ⟨none, clean d positive, finalTapes input output⟩ := by + have hv : b₄ .reverse = encodeWord (2 * d * v) := by + simp [b₄, b₃, b₂, b₁, b₀, loopTapes, frame] + simpa only [hv, encodeWord_length, Nat.add_assoc, hend] using + drainPhase d positive .reverse .clearReverse none rfl b₄ + have all := joinTrace (joinTrace (joinTrace (joinTrace (joinTrace c₀ c₁) c₂) c₃) c₄) c₅ + have hc : 1 + (n + 2) + (m + 2) + 2 + (v + 2) + (2 * d * v + 2) = + finishSteps d n m v := by dsimp [finishSteps]; omega + rw [hc] at all + exact all + +end IndependentSetsGames.Foundations.Complexity.MachineLazyTable + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/TargetLCMachine.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/TargetLCMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9dc0b89c7f22bdc5026762854624dc8da3f440a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/TargetLCMachine.lean @@ -0,0 +1,76 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.TargetLCExpr + +namespace OAI + +namespace LargeIndependentSets.TargetLC +open IndependentSetsGames.Foundations IndependentSetsGames.Foundations.Complexity +open IndependentSetsCut.CounterMachine +open Target PCP Hastad.SourceContexts Hastad.SourceGame UniformLC +open TargetRead TargetRepair +open scoped Classical BigOperators +noncomputable section +variable (u : ℕ) + +def edgesExpr : Expr := Expr.power (.mul clausesExpr (.const 3)) u +def countExpr : Expr := .add (.const 3) (.mul (.const 3) (edgesExpr u)) +def valueExpr : Expr := + let x := Expr.quotient (.sub (.arg 0) (.const 3)) (.const 3) + let j := Expr.remainder (.sub (.arg 0) (.const 3)) (.const 3) + Expr.cond (Expr.equal (.arg 0) (.const 0)) (Expr.power clausesExpr u) + (Expr.cond (Expr.equal (.arg 0) (.const 1)) (Expr.power varsExpr u) + (Expr.cond (Expr.equal (.arg 0) (.const 2)) (edgesExpr u) + (Expr.cond (Expr.lt x (edgesExpr u)) + (Expr.cond (Expr.equal j (.const 0)) (leftExpr u x) + (Expr.cond (Expr.equal j (.const 1)) (rightExpr u x) (projectExpr u x))) (.const 0)))) + +@[simp] lemma edgesExpr_eval (F : Input) (a : ℕ → ℕ) : + (edgesExpr u).eval (Complexity.formulaBits F.val) a=(table u F).ne := by + simp only [edgesExpr,Expr.power_eval,Expr.eval,clausesExpr_eval] + rfl +@[simp] lemma countExpr_eval (F : Input) (a : ℕ → ℕ) : + (countExpr u).eval (Complexity.formulaBits F.val) a=3+3*(table u F).ne := by + simp only [countExpr,Expr.eval,edgesExpr_eval] + +lemma valueExpr_eval (F : Input) (w : ℕ) : + (valueExpr u).eval (Complexity.formulaBits F.val) (fun _ => w)=(table u F).value w := by + let x := Expr.quotient (.sub (.arg 0) (.const 3)) (.const 3) + have hx : x.eval (Complexity.formulaBits F.val) (fun _ => w)=(w-3)/3 := by + simp [x,Expr.quotient_eval,Expr.eval] + simp only [valueExpr,Expr.cond_eval,Expr.equal_eval,Expr.eval,Expr.power_eval, + clausesExpr_eval,varsExpr_eval,edgesExpr_eval,Table.value] + by_cases h0 : w=0 + · simp only [h0]; rfl + by_cases h1 : w=1 + · simp only [h1]; rfl + by_cases h2 : w=2 + · simp [h2] + simp only [h0,h1,h2] + simp only [Expr.lt_eval,Expr.quotient_eval,Expr.remainder_eval,Expr.eval,edgesExpr_eval,indicator_ne] + by_cases he : (w-3)/3 < (table u F).ne + · simp only [he,ite_eq_left,dite_eq_left] + have hl := leftExpr_eval u F x (fun _ => w) ⟨(w-3)/3,he⟩ hx + have hr := rightExpr_eval u F x (fun _ => w) ⟨(w-3)/3,he⟩ hx + have hp := projectExpr_eval u F x (fun _ => w) ⟨(w-3)/3,he⟩ hx + rw [hl,hr,hp] + rfl + · simp only [he] + rfl + +lemma serializer_spec (F : Input) : + UnaryTables.words (fun w => (valueExpr u).eval (Complexity.formulaBits F.val) (fun _ => w)) + ((countExpr u).eval (Complexity.formulaBits F.val) (fun _ => 0))=(table u F).bits := by + rw [countExpr_eval,Table.bits] + exact UnaryTables.words_congr (fun w _ => valueExpr_eval u F w) + +def certificate : Turing.TM2ComputableInPolyTime (fun F : Input => Complexity.formulaBits F.val) + Table.bits (table u) := + UnaryTables.encodedComputer _ _ _ (countExpr u) (valueExpr u) (serializer_spec u) + +lemma finiteAlphabet (k : (certificate u).tm.K) : Finite ((certificate u).tm.Γ k) := + UnaryTables.encodedComputer_finiteAlphabet _ _ _ _ _ _ k + +end +end LargeIndependentSets.TargetLC + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/ValuePolynomial.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/ValuePolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..6677222561d702fad4900419f1a5ebb0c4afb96e --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/ValuePolynomial.lean @@ -0,0 +1,168 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Correct + +namespace OAI + +namespace IndependentSetsCut.CounterMachine.Expr + +section +open Polynomial + + noncomputable def valuePolynomial : Expr → Polynomial ℕ + | .const n => C n + | .arg _ | .length => X + | .bit _ | .zero _ => 1 + | .add a b => valuePolynomial a+valuePolynomial b + | .sub a _ => valuePolynomial a + | .mul a b => valuePolynomial a*valuePolynomial b + | .sum b f => valuePolynomial b*(valuePolynomial f).comp (X+valuePolynomial b) + + theorem valuePolynomial_eval (e : Expr) (M : ℕ) : + e.valuePolynomial.eval M = e.valueBudget M := by + induction e generalizing M <;> + simp_all [valuePolynomial, valueBudget, Polynomial.eval_comp] + + noncomputable def timePolynomial : Expr → Polynomial ℕ + | .const n => C (n+1) + | .arg _ => 5*X+2 + | .length => 5*X+6 + | .bit e => timePolynomial e+3*valuePolynomial e+X+7 + | .add a b | .sub a b => timePolynomial a+timePolynomial b+2*valuePolynomial b+1 + | .mul a b => timePolynomial a+timePolynomial b+ + valuePolynomial b*(5*valuePolynomial a+3)+1+2*valuePolynomial a+1+ + 2*(valuePolynomial a*valuePolynomial b)+1 + | .zero a => timePolynomial a+2*valuePolynomial a+2 + | .sum b f => timePolynomial b+valuePolynomial b* + ((timePolynomial f).comp (X+valuePolynomial b)+ + 2*(valuePolynomial f).comp (X+valuePolynomial b)+3)+2*valuePolynomial b+2 + + theorem timePolynomial_eval (e : Expr) (M : ℕ) : + e.timePolynomial.eval M = e.timeBudget M := by + induction e generalizing M <;> + simp_all [timePolynomial, timeBudget, valuePolynomial_eval, Polynomial.eval_comp] + +end + +open scoped BigOperators +open Finset Command + + theorem correct_sum {b f : Expr} (hcb : Correct b) (hcf : Correct f) : Correct (.sum b f) := by + intro vars k d M hv hc hb hi ha + let args := fun i => d.reg (vars i) + let B := b.eval d.input args + let F := fun i => f.eval d.input (bind args i) + let V := b.valueBudget M + let W := f.valueBudget (M+V) + let T := f.timeBudget (M+V) + have hB : B ≤ V := b.eval_le d.input args M hi ha + have hF : ∀ i < B, F i ≤ W := by + intro i hi' + apply f.eval_le + · omega + · intro j; cases j with + | zero => dsimp [bind]; omega + | succ j => exact (ha j).trans (by omega) + let state : ℕ → Data ℕ := fun i => + ((d.set k (∑ j ∈ range (B-i), F j)).set (k+1) i).set (k+2) (B-i) + have hz : ∀ r, k ≤ r → d.reg r = 0 := hc + have hbnd := hcb vars (k+1) d M (fun i => by have := hv i; omega) + (hc.mono (by omega)) hb hi ha + have hstart : state B = d.set (k+1) B := by + simp only [state, Nat.sub_self, range_zero, sum_empty] + rw [Data.set_clean_zero hc le_rfl] + exact Data.set_clean_zero ((hc.mono (by omega)).set_succ B) le_rfl + have hloop : Within (.loop (k+1) (.seq (compile (bind vars (k+2)) (k+3) f) + (.seq (move (k+3) k) (.inc (k+2))))) (state B) (state 0) (B*(T+2*W+3)+1) := by + apply (Within.loop (k+1) _ state B (T+2*W+2)) + · intro i hi' + simp [state, Data.set] + · intro i hi' + let j := B-(i+1) + let e := decData (state (i+1)) (k+1) + have hj : j < B := by dsimp [j]; omega + have hindex : B-i = j+1 := by dsimp [j]; omega + have heclean : e.Clean (k+3) := by + intro r hr + have h0 : r ≠ k := by omega + have h1 : r ≠ k+1 := by omega + have h2 : r ≠ k+2 := by omega + simp [e, decData, state, Data.set, h0, h1, h2, hc r (by omega)] + have henv : (fun u => e.reg (bind vars (k+2) u)) = bind args j := by + funext u + cases u with + | zero => simp [e, decData, state, Data.set, bind, j] + | succ u => + have h0 : vars u ≠ k := by have := hv u; omega + have h1 : vars u ≠ k+1 := by have := hv u; omega + have h2 : vars u ≠ k+2 := by have := hv u; omega + simp [e, decData, state, Data.set, bind, args, h0, h1, h2] + have heargs : ∀ u, e.reg (bind vars (k+2) u) ≤ M+V := by + intro u + change (fun u => e.reg (bind vars (k+2) u)) u ≤ M+V + rw [henv] + cases u with + | zero => dsimp [bind]; omega + | succ u => exact (ha u).trans (by omega) + have hf := hcf (bind vars (k+2)) (k+3) e (M+V) + (fun u => by cases u with + | zero => dsimp [bind]; omega + | succ u => dsimp [bind]; have := hv u; omega) heclean hb (by exact hi.trans (by omega)) heargs + rw [henv] at hf + change Within _ e (e.set (k+3) (F j)) T at hf + have hm := Within.move (e.set (k+3) (F j)) (k+3) k (by omega) + let out := (((e.set (k+3) (F j)).set (k+3) 0).set k + ((e.set (k+3) (F j)).reg k+(e.set (k+3) (F j)).reg (k+3))) + have hh := hf.seq (hm.seq (Within.inc out (k+2))) + have hsum : (∑ u ∈ range (B-i), F u) = (∑ u ∈ range j, F u)+F j := by + rw [hindex, sum_range_succ] + have hout : incData out (k+2) = state i := by + apply Data.ext + · ext u + have hz3 := hc (k+3) (by omega) + by_cases h0 : u = k <;> by_cases h1 : u = k+1 <;> + by_cases h2 : u = k+2 <;> by_cases h3 : u = k+3 <;> + simp [out, e, state, Data.set, incData, decData, + h0, h1, h2, h3, j, hsum, hz3] <;> omega + all_goals rfl + rw [hout] at hh + apply hh.mono + simp only [Data.set_reg_same] + have := hF j hj + omega + rw [hstart] at hloop + have hclear := Within.clear (state 0) (k+2) + have hout : (state 0).set (k+2) 0 = d.set k (∑ j ∈ range B, F j) := by + dsimp only [state] + rw [Data.set_set] + apply Data.ext + · ext u + have hz1 := hc (k+1) (by omega) + have hz2 := hc (k+2) (by omega) + by_cases h0 : u = k <;> by_cases h1 : u = k+1 <;> by_cases h2 : u = k+2 <;> + simp [Data.set, h0, h1, h2, hz1, hz2] + all_goals rfl + rw [hout] at hclear + have hclear' : Within (clear (k+2)) (state 0) (d.set k (∑ j ∈ range B, F j)) (2*B+1) := by + simpa [state, Data.set] using hclear + have hh := hbnd.seq (hloop.seq hclear') + apply hh.mono + + change _ ≤ b.timeBudget M+V*(T+2*W+3)+2*V+2 + have ht := Nat.mul_le_mul_right (T+2*W+3) hB + omega + + theorem correct (e : Expr) : Correct e := by + induction e with + | const n => exact correct_const n + | arg i => exact correct_arg i + | length => exact correct_length + | bit a ih => exact correct_bit ih + | add a b ia ib => exact correct_add ia ib + | sub a b ia ib => exact correct_sub ia ib + | mul a b ia ib => exact correct_mul ia ib + | zero a ih => exact correct_zero ih + | sum b f ib iF => exact correct_sum ib iF + +end IndependentSetsCut.CounterMachine.Expr + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Machines/VertexLabel.lean b/lean/OAI/Combinatorics/IndependentSets/Machines/VertexLabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..699e86eba01207bf02c465bf2dadd1c0c384ec65 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Machines/VertexLabel.lean @@ -0,0 +1,288 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.Label + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.MachineLazyRows +open Turing MachineComposition PCP.GraphTables +open PCP.PreprocessingLazyWords (reverseMap moveRow moveRow_words) +variable {K Λ A : Type} [DecidableEq K] + +abbrev VertexLabel (d : Nat) := Fin (d + 1) × Option (StreamLabel d) + +def vertexInstruction (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 10 → K) + (labels : VertexLabel d → Λ) (exit : Option Λ) : + VertexLabel d → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d) + | (i, none) => if i.val < d then .goto fun _ => labels (i, some .tailStart) + else MachinePortReindex.exitAt exit + | (i, some stage) => if h : i.val < d then + streamInstruction d positive c b tape (fun stage => labels (i, some stage)) + (some (labels (⟨i.val + 1, by omega⟩, none))) stage + else MachinePortReindex.exitAt exit + +def recordsInput {n m : Nat} (rows : List (DartRow n m)) : List Bool := + rows.flatMap (fun r => inputRowBits r.tail.val r.reverseIndex.val r.relation) + +def recordsOutput {n m : Nat} (d c b : Nat) (rows : List (DartRow n m)) : List Bool := + rows.flatMap (fun r => reindexRowBits d c b r.tail.val r.reverseIndex.val r.relation) + +def streamFrame {n m : Nat} (tape : Fin 10 → K) (base : K → List Bool) + (rows : List (DartRow n m)) (output : List Bool) : K → List Bool := + Function.update (Function.update base (tape 9) (recordsInput rows ++ base (tape 9))) + (tape 7) output + +def vertexSteps {n m : Nat} (d c b : Nat) : List (DartRow n m) → List Bool → Nat + | [], _ => 1 + | r :: rows, output => 1 + streamRowSteps d c b r.tail.val r.reverseIndex.val r.relation output + + vertexSteps d c b rows + (output ++ reindexRowBits d c b r.tail.val r.reverseIndex.val r.relation) + +theorem recordsInput_eq_codec {n m : Nat} (rows : List (DartRow n m)) : + recordsInput rows = encodeWords (rows.flatMap rowWords) := by + induction rows with + | nil => rfl + | cons r rows ih => + simp only [recordsInput, List.flatMap_cons, encodeWords_append, + MachineTableRows.rowBits_eq, inputRowBits] at ih ⊢ + rw [ih] + +theorem streamFrame_afterRow {n m : Nat} (d c b : Nat) (r : DartRow n m) + (tape : Fin 10 → K) (distinct : Function.Injective tape) (base : K → List Bool) + (rows : List (DartRow n m)) (output : List Bool) : + streamResultTapes d c b r.tail.val r.reverseIndex.val r.relation tape + (streamFrame tape base (r :: rows) output) (recordsInput rows ++ base (tape 9)) = + streamFrame tape base rows + (output ++ reindexRowBits d c b r.tail.val r.reverseIndex.val r.relation) := by + have h79 : tape 7 ≠ tape 9 := fun h => (by decide : (7 : Fin 10) ≠ 9) (distinct h) + funext k + by_cases h7 : k = tape 7 + · subst k + simp [streamResultTapes, streamFrame] + · by_cases h9 : k = tape 9 + · subst k + simp [streamResultTapes, streamFrame, Ne.symm h79] + · simp [streamResultTapes, streamFrame, h7, h9] + +theorem vertexSuffixTrace {n m : Nat} (d : Nat) (positive : 0 < d) (c b : Nat) + (tape : Fin 10 → K) (distinct : Function.Injective tape) + (labels : VertexLabel d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d)) + (atLabels : ∀ l, program (labels l) = vertexInstruction d positive c b tape labels exit l) + (base : K → List Bool) (rows : Fin d → DartRow n m) + (empty : ∀ i : Fin 10, i ≠ 7 → i ≠ 9 → base (tape i) = []) (ambient : A) + (remaining : Nat) (i : Fin (d + 1)) (count : i.val + remaining = d) (output : List Bool) : + (advance (TM2.step program))^[vertexSteps d c b ((List.ofFn rows).drop i.val) output] + (some ⟨some (labels (i, none)), streamClean d positive ambient, + streamFrame tape base ((List.ofFn rows).drop i.val) output⟩) = + some ⟨exit, streamClean d positive ambient, + streamFrame (n := n) (m := m) tape base [] + (output ++ recordsOutput d c b ((List.ofFn rows).drop i.val))⟩ := by + have hd (a k : Fin 10) (h : a ≠ k) : tape a ≠ tape k := fun x => h (distinct x) + induction remaining generalizing i output with + | zero => + have hi : i.val = d := by omega + have hdrop : (List.ofFn rows).drop i.val = [] := by + apply List.drop_eq_nil_of_le + simp only [List.length_ofFn, hi, le_refl] + rw [hdrop] + simp only [vertexSteps, recordsOutput, List.flatMap_nil, List.append_nil] + change some (TM2.stepAux (program (labels (i, none))) _ _) = _ + rw [atLabels] + cases exit <;> simp [vertexInstruction, hi, MachinePortReindex.exitAt, TM2.stepAux] + | succ remaining ih => + have hi : i.val < d := by omega + let port : Fin d := ⟨i.val, hi⟩ + let next : Fin (d + 1) := ⟨i.val + 1, by omega⟩ + let rest := (List.ofFn rows).drop (i.val + 1) + have split : (List.ofFn rows).drop i.val = rows port :: rest := by + have h := List.getElem_cons_drop (as := List.ofFn rows) + (i := i.val) (by simpa only [List.length_ofFn] using hi) + simpa only [List.getElem_ofFn, port, rest] using h.symm + let initial := streamFrame tape base (rows port :: rest) output + have boundary : (advance (TM2.step program))^[1] + (some ⟨some (labels (i, none)), streamClean d positive ambient, initial⟩) = + some ⟨some (labels (i, some .tailStart)), streamClean d positive ambient, initial⟩ := by + change some (TM2.stepAux (program (labels (i, none))) _ _) = _ + rw [atLabels] + simp [vertexInstruction, hi, TM2.stepAux] + have body := streamRowTrace d positive c b tape distinct + (fun stage => labels (i, some stage)) (some (labels (next, none))) program + (by + intro stage + simpa only [vertexInstruction, hi, dite_true, next] using (atLabels (i, some stage))) + initial (rows port).tail.val (rows port).reverseIndex.val (rows port).relation + (recordsInput rest ++ base (tape 9)) + (by simp [initial, streamFrame, hd 9 7 (by decide), recordsInput, List.append_assoc]) + (by + intro k hk7 hk9 + simp [initial, streamFrame, hd k 7 hk7, hd k 9 hk9, empty k hk7 hk9]) ambient + have initialOutput : initial (tape 7) = output := by simp [initial, streamFrame] + rw [initialOutput] at body + change (advance (TM2.step program))^[streamRowSteps d c b + (rows port).tail.val (rows port).reverseIndex.val (rows port).relation output] + (some ⟨some (labels (i, some .tailStart)), streamClean d positive ambient, initial⟩) = + some ⟨some (labels (next, none)), streamClean d positive ambient, + streamResultTapes d c b (rows port).tail.val (rows port).reverseIndex.val + (rows port).relation tape initial (recordsInput rest ++ base (tape 9))⟩ at body + rw [show streamResultTapes d c b (rows port).tail.val (rows port).reverseIndex.val + (rows port).relation tape initial (recordsInput rest ++ base (tape 9)) = + streamFrame tape base rest + (output ++ reindexRowBits d c b (rows port).tail.val + (rows port).reverseIndex.val (rows port).relation) from + streamFrame_afterRow d c b (rows port) tape distinct base rest output] at body + have nextCount : next.val + remaining = d := by dsimp [next]; omega + have tail := ih next nextCount + (output ++ reindexRowBits d c b (rows port).tail.val + (rows port).reverseIndex.val (rows port).relation) + change (advance (TM2.step program))^[vertexSteps d c b rest + (output ++ reindexRowBits d c b (rows port).tail.val + (rows port).reverseIndex.val (rows port).relation)] + (some ⟨some (labels (next, none)), streamClean d positive ambient, + streamFrame tape base rest (output ++ reindexRowBits d c b (rows port).tail.val + (rows port).reverseIndex.val (rows port).relation)⟩) = + some ⟨exit, streamClean d positive ambient, + streamFrame (n := n) (m := m) tape base [] ((output ++ reindexRowBits d c b (rows port).tail.val + (rows port).reverseIndex.val (rows port).relation) ++ recordsOutput d c b rest)⟩ at tail + rw [split] + have all := joinTrace (joinTrace boundary body) tail + simpa only [vertexSteps, initial, recordsOutput, List.flatMap_cons, List.append_assoc] using all + +theorem vertexTrace {n m : Nat} (d : Nat) (positive : 0 < d) (c b : Nat) + (tape : Fin 10 → K) (distinct : Function.Injective tape) + (labels : VertexLabel d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d)) + (atLabels : ∀ l, program (labels l) = vertexInstruction d positive c b tape labels exit l) + (base : K → List Bool) (rows : Fin d → DartRow n m) + (empty : ∀ i : Fin 10, i ≠ 7 → i ≠ 9 → base (tape i) = []) + (ambient : A) (output : List Bool) : + (advance (TM2.step program))^[vertexSteps d c b (List.ofFn rows) output] + (some ⟨some (labels (0, none)), streamClean d positive ambient, + streamFrame tape base (List.ofFn rows) output⟩) = + some ⟨exit, streamClean d positive ambient, + streamFrame (n := n) (m := m) tape base [] (output ++ recordsOutput d c b (List.ofFn rows))⟩ := by + simpa only [Fin.val_zero, List.drop_zero] using vertexSuffixTrace d positive c b tape distinct + labels exit program atLabels base rows empty ambient d 0 (by simp) output + +theorem encodeWords_flatMap {α : Type*} (items : List α) (words : α → List Nat) : + encodeWords (items.flatMap words) = items.flatMap (fun x => encodeWords (words x)) := by + induction items with + | nil => rfl + | cons item items ih => simp only [List.flatMap_cons, encodeWords_append, ih] + +theorem recordsOutput_lazy {n d : Nat} (table : PCP.PortTables.Table n d) (v : Fin n) : + recordsOutput d (2 * d) d (List.ofFn (PCP.PreprocessingLazyWords.row table v)) = + encodeWords ((List.ofFn (moveRow table v)).flatMap rowWords) := by + rw [encodeWords_flatMap] + simp only [recordsOutput, List.flatMap_def, List.map_ofFn] + apply congrArg List.flatten + apply congrArg List.ofFn + funext p + change reindexRowBits d (2 * d) d v.val + (PCP.PreprocessingLazyWords.row table v p).reverseIndex.val + (PCP.PreprocessingLazyWords.row table v p).relation = + encodeWords (rowWords (moveRow table v p)) + have h := rowBits_eq_moveRow table v p + simpa only [rowBits, reindexRowBits, MachinePortReindex.lazy_value, reverseMap] using h + +def valueBound (c b m : Nat) : Nat := c * m + m + b +def rowSizeBound (c b n m : Nat) : Nat := n + valueBound c b m + 8194 +def rowCostBound (c b n m : Nat) : Nat := + 2 * n + 8 * m + valueBound c b m + 4 * rowSizeBound c b n m + 8224 + +theorem reindexValue_le {n m : Nat} (d c b : Nat) (r : DartRow n m) : + MachinePortReindex.value d c b r.reverseIndex.val ≤ valueBound c b m := by + have hj := r.reverseIndex.isLt.le + have hdiv := (Nat.div_le_self r.reverseIndex.val d).trans hj + have hmod := (Nat.mod_le r.reverseIndex.val d).trans hj + have hmul := Nat.mul_le_mul_left c hdiv + unfold MachinePortReindex.value valueBound + omega + +theorem reindexRowBits_length_le {n m : Nat} (d c b : Nat) (r : DartRow n m) : + (reindexRowBits d c b r.tail.val r.reverseIndex.val r.relation).length ≤ + rowSizeBound c b n m := by + have htail := r.tail.isLt.le + have hvalue := reindexValue_le d c b r + have hrelation := relationBits_length_le r.relation + simp only [reindexRowBits, List.length_append, encodeWord_length] + unfold rowSizeBound + omega + +theorem streamRowSteps_le {n m : Nat} (d c b : Nat) (r : DartRow n m) (output : List Bool) : + streamRowSteps d c b r.tail.val r.reverseIndex.val r.relation output ≤ + rowCostBound c b n m + 2 * output.length := by + have htail := r.tail.isLt.le + have hj := r.reverseIndex.isLt.le + have hdiv := (Nat.div_le_self r.reverseIndex.val d).trans hj + have hvalue := reindexValue_le d c b r + have hrelation := relationBits_length_le r.relation + have hsize := reindexRowBits_length_le d c b r + unfold streamRowSteps reindexSteps MachinePortReindex.steps rowCostBound + omega + +theorem vertexSteps_le_capacity {n m : Nat} (d c b capacity : Nat) + (rows : List (DartRow n m)) (output : List Bool) + (room : output.length + rows.length * rowSizeBound c b n m ≤ capacity) : + vertexSteps d c b rows output ≤ + rows.length * (rowCostBound c b n m + 2 * capacity + 1) + 1 := by + induction rows generalizing output with + | nil => simp [vertexSteps] + | cons r rows ih => + have hsize := reindexRowBits_length_le d c b r + have hcost := streamRowSteps_le d c b r output + have hout : output.length ≤ capacity := by omega + have hroom : (output ++ reindexRowBits d c b r.tail.val r.reverseIndex.val r.relation).length + + rows.length * rowSizeBound c b n m ≤ capacity := by + rw [List.length_append] + simp only [List.length_cons, Nat.succ_mul] at room + omega + have htail := ih + (output ++ reindexRowBits d c b r.tail.val r.reverseIndex.val r.relation) hroom + change 1 + streamRowSteps d c b r.tail.val r.reverseIndex.val r.relation output + + vertexSteps d c b rows + (output ++ reindexRowBits d c b r.tail.val r.reverseIndex.val r.relation) ≤ + (rows.length + 1) * (rowCostBound c b n m + 2 * capacity + 1) + 1 + rw [Nat.add_mul, Nat.one_mul] + omega + +theorem vertexSteps_le {n m : Nat} (d c b : Nat) (rows : List (DartRow n m)) + (output : List Bool) : + vertexSteps d c b rows output ≤ rows.length * (rowCostBound c b n m + + 2 * (output.length + rows.length * rowSizeBound c b n m) + 1) + 1 := + vertexSteps_le_capacity d c b _ rows output (Nat.le_refl _) + +def vertexInTime {n m : Nat} (d : Nat) (positive : 0 < d) (c b : Nat) + (tape : Fin 10 → K) (distinct : Function.Injective tape) + (labels : VertexLabel d → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d)) + (atLabels : ∀ l, program (labels l) = vertexInstruction d positive c b tape labels exit l) + (base : K → List Bool) (rows : Fin d → DartRow n m) + (empty : ∀ i : Fin 10, i ≠ 7 → i ≠ 9 → base (tape i) = []) + (ambient : A) (output : List Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels (0, none)), streamClean d positive ambient, + streamFrame tape base (List.ofFn rows) output⟩ + (some ⟨exit, streamClean d positive ambient, + streamFrame (n := n) (m := m) tape base [] + (output ++ recordsOutput d c b (List.ofFn rows))⟩) + (d * (rowCostBound c b n m + 2 * (output.length + d * rowSizeBound c b n m) + 1) + 1) where + steps := vertexSteps d c b (List.ofFn rows) output + evals_in_steps := vertexTrace d positive c b tape distinct labels exit program atLabels + base rows empty ambient output + steps_le_m := by + simpa only [List.length_ofFn] using vertexSteps_le d c b (List.ofFn rows) output + +def vertexMachine (d : Nat) (positive : 0 < d) (c b : Nat) : FinTM2 where + K := Fin 10 + k₀ := 9 + k₁ := 7 + Γ _ := Bool + Λ := VertexLabel d + main := (0, none) + σ := StreamState Unit d + initialState := streamClean d positive () + m := vertexInstruction d positive c b id id none + +end IndependentSetsGames.Foundations.Complexity.MachineLazyRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Main.lean b/lean/OAI/Combinatorics/IndependentSets/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa8afd648a8a28b9f51549a72b9180919b0287cd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Main.lean @@ -0,0 +1,152 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.GraphReduction +import OAI.Combinatorics.IndependentSets.Reduction.ClampCube +import OAI.Combinatorics.IndependentSets.PCP.FinalCNF +import OAI.Combinatorics.IndependentSets.Reduction.MapEquiv +import OAI.Combinatorics.IndependentSets.Machines.ProfileMachine +import OAI.Combinatorics.IndependentSets.Encoding.PortTableEncoding +import OAI.Combinatorics.IndependentSets.Machines.MachineLazyTableRuntime +import OAI.Combinatorics.IndependentSets.Machines.PCPGapMachine +import OAI.Combinatorics.IndependentSets.Machines.TargetLCMachine +import OAI.Combinatorics.IndependentSets.Geometry.GeometryOutput + +namespace OAI + +namespace LargeIndependentSets +open IndependentSetsGames.Foundations +open scoped Classical +noncomputable section + +namespace CompleteReduction +open PCP Hastad.SourceContexts Hastad.SourceGame +open Complexity + +def gapInput (H : RoundTables.BaseTable) (b : List Bool) : TargetLC.Input := + ⟨TableIteration.gapMap H (BinaryNormalize.normalize b),TableIteration.gapMap_nonempty H _⟩ + +def gapView (H : RoundTables.BaseTable) : + Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) + (fun F : TargetLC.Input => Complexity.formulaBits F.val) (gapInput H) where + tm := (BinaryNormalize.gapCertificate H).tm + inputAlphabet := (BinaryNormalize.gapCertificate H).inputAlphabet + outputAlphabet := (BinaryNormalize.gapCertificate H).outputAlphabet + time := (BinaryNormalize.gapCertificate H).time + outputsFun := (BinaryNormalize.gapCertificate H).outputsFun + +def lcComputer (H : RoundTables.BaseTable) (u : ℕ) : + Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) UniformLC.Table.bits + (fun b => TargetLC.table u (gapInput H b)) := + MachineSequential.composeBits (gapView H) (TargetLC.certificate u) + +lemma lcComputer_finiteAlphabet (H : RoundTables.BaseTable) (u : ℕ) : + MachineFiniteAlphabet.FiniteAlphabet (lcComputer H u).tm := + MachineFiniteAlphabet.composeBits (gapView H) (TargetLC.certificate u) + (BinaryNormalize.gap_finiteAlphabet H) (TargetLC.finiteAlphabet u) + +def reduce (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 TargetLC.table u (gapInput H b)) + (g := GeometryNames.output (J u) (I u) p q hq) + (lcComputer H u) (GeometryNames.graphComputer (J u) (I u) p q hq) + +lemma finiteAlphabet (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 hF ((BinaryNormalize.satisfiable_iff F).mp h)) + have hs := TargetLC.sound u (CompleteReduction.gapInput H (formulaBits F)) (hrep _ hg) + have hout := (hp _ _ _ _ _ (TargetLC.table u (CompleteReduction.gapInput H (formulaBits F))).lc).2 hs + exact (GeometryNames.outputRenaming (Hastad.SourceContexts.J u) (Hastad.SourceContexts.I u) p q hq + (TargetLC.table u (CompleteReduction.gapInput H (formulaBits F)))).symm.strict_density hout + +end +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Model.lean b/lean/OAI/Combinatorics/IndependentSets/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba021530311cf316bfbf1e80976733c8ceaa0849 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Model.lean @@ -0,0 +1,79 @@ +import Mathlib + +namespace OAI + +namespace LargeIndependentSets + +structure Literal where + name : ℕ + positive : Bool + deriving DecidableEq + +structure Formula where + clauses : List (List Literal) + width : ∀ C ∈ clauses, C.length ≤ 3 + +def Formula.Satisfiable (φ : Formula) : Prop := + ∃ assignment : ℕ → Bool, ∀ C ∈ φ.clauses, + ∃ l ∈ C, assignment l.name = l.positive + +/-- Binary framing: `true,b` for a payload bit and `false` as terminator. -/ +def frame : List Bool → List Bool + | [] => [false] + | b :: bs => true :: b :: frame bs + +def nameBits (n : ℕ) : List Bool := frame n.bits + +def literalBits (l : Literal) : List Bool := l.positive :: nameBits l.name + +def clauseBits (C : List Literal) : List Bool := + nameBits C.length ++ C.flatMap literalBits + +def formulaBits (φ : Formula) : List Bool := + nameBits φ.clauses.length ++ φ.clauses.flatMap clauseBits + +/-- A nonempty, finite, simple, undirected, unweighted graph. -/ +structure Graph where + vertices : ℕ + nonempty : 0 < vertices + adj : Fin vertices → Fin vertices → Bool + symm : ∀ u v, adj u v = adj v u + loopless : ∀ u, adj u u = false + +def Graph.Independent (G : Graph) (S : Finset (Fin G.vertices)) : Prop := + ∀ u ∈ S, ∀ v ∈ S, u ≠ v → G.adj u v = false + +instance (G : Graph) (S : Finset (Fin G.vertices)) : Decidable (G.Independent S) := + inferInstanceAs (Decidable (∀ u ∈ S, ∀ v ∈ S, u ≠ v → G.adj u v = false)) + +def Graph.independenceNumber (G : Graph) : ℕ := + ((Finset.univ : Finset (Fin G.vertices)).powerset.filter G.Independent).sup Finset.card + +def Graph.ThreeColorable (G : Graph) : Prop := + ∃ color : Fin G.vertices → Fin 3, + ∀ u v, G.adj u v = true → color u ≠ color v + +/-- Full explicit adjacency matrix, row-major, with binary vertex count. -/ +def graphBits (G : Graph) : List Bool := + nameBits G.vertices ++ (List.finRange G.vertices).flatMap + (fun u => (List.finRange G.vertices).map (G.adj u)) + +open scoped Classical +noncomputable section + +/-- Polynomial-time graph reduction with a real independence-ratio threshold. -/ +structure RealGraphReduction (δ : ℝ) where + reduce : List Bool → Graph + computation : Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) graphBits reduce + finiteAlphabets : ∀ k : computation.tm.K, Finite (computation.tm.Γ k) + outputBound : Polynomial ℕ + outputSize : ∀ b, (graphBits (reduce b)).length ≤ outputBound.eval b.length + completeness : ∀ φ : Formula, φ.Satisfiable → (reduce (formulaBits φ)).ThreeColorable + soundness : ∀ φ : Formula, ¬φ.Satisfiable → + ((reduce (formulaBits φ)).independenceNumber : ℝ) < + δ * (reduce (formulaBits φ)).vertices + +end +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Addresses.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Addresses.lean new file mode 100644 index 0000000000000000000000000000000000000000..67dfcef020d5d9dae938910891ae695e58c2460b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Addresses.lean @@ -0,0 +1,294 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Queries +import OAI.Combinatorics.IndependentSets.PCP.Emitter + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Addresses + +open IndependentSetsGames.Foundations.Hastad +open Enumeration + +abbrev Terms := List (Fin 5 × Nat) + +structure Field (bound : Nat) where + terms : Terms + offset : Fin bound + +def values (n m edge tail head : Nat) : Fin 5 → Nat := ![n, m, edge, tail, head] + +def eval {bound : Nat} (field : Field bound) (inputs : Fin 5 → Nat) : Nat := + Emitter.affineValue field.terms inputs field.offset.val + +def fieldBound (q : Nat) : Nat := + 12 * localCount q + tapeCount q + pairTapeCount q + 1 + +theorem fieldBound_pos (q : Nat) : 0 < fieldBound q := by + unfold fieldBound + omega + +theorem tapeCount_lt_bound (q : Nat) : tapeCount q < fieldBound q := by + unfold fieldBound + omega + +theorem pairTapeCount_lt_bound (q : Nat) : pairTapeCount q < fieldBound q := by + unfold fieldBound + omega + +theorem localCount_lt_bound (q : Nat) : localCount q < fieldBound q := by + unfold fieldBound + omega + +theorem local_add_pair_lt_bound (q : Nat) : localCount q + pairTapeCount q < fieldBound q := by + unfold fieldBound + omega + +theorem twelve_local_lt_bound (q : Nat) : 12 * localCount q < fieldBound q := by + unfold fieldBound + omega + +def zeroOffset (q : Nat) : Fin (fieldBound q) := ⟨0, fieldBound_pos q⟩ + +def eventOffset (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) : Fin (fieldBound q) := + ⟨(localEventEquiv q event).val, + (localEventEquiv q event).isLt.trans (localCount_lt_bound q)⟩ + +def rawQueryOffset (q : Nat) : Queries.RawQuery q → Fin (fieldBound q) + | .inl (_, tape) => + ⟨(cubeEquiv q tape).val, (cubeEquiv q tape).isLt.trans (tapeCount_lt_bound q)⟩ + | .inr tape => + ⟨(pairCubeEquiv q tape).val, (pairCubeEquiv q tape).isLt.trans (pairTapeCount_lt_bound q)⟩ + +def reverseOffset (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : Fin (fieldBound q) := + ⟨(localEventEquiv q event).val * 12 + slot.val * 2 + bitValue (!orientation), by + have he := (localEventEquiv q event).isLt + have hs := slot.isLt + have hb : bitValue (!orientation) < 2 := by + simpa only [boolEquiv_val] using (boolEquiv (!orientation)).isLt + have hbound := twelve_local_lt_bound q + omega⟩ + +def headerVertices (q : Nat) : Field (fieldBound q) := + ⟨[(0, tapeCount q), (1, localCount q + pairTapeCount q)], zeroOffset q⟩ + +def headerDarts (q : Nat) : Field (fieldBound q) := + ⟨[(1, 12 * localCount q)], zeroOffset q⟩ + +def eventVertexField (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) : + Field (fieldBound q) := + ⟨[(2, localCount q)], eventOffset q event⟩ + +def vertexQueryTerms (q : Nat) (side : Bool) : Terms := + [(1, localCount q), (if side then 4 else 3, tapeCount q)] + +def edgeQueryTerms (q : Nat) : Terms := + [(1, localCount q), (0, tapeCount q), (2, pairTapeCount q)] + +def rawQueryTerms (q : Nat) : Queries.RawQuery q → Terms + | .inl (side, _) => vertexQueryTerms q side + | .inr _ => edgeQueryTerms q + +def rawQueryField (q : Nat) (query : Queries.RawQuery q) : Field (fieldBound q) := + ⟨rawQueryTerms q query, rawQueryOffset q query⟩ + +def reverseDartField (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : Field (fieldBound q) := + ⟨[(2, 12 * localCount q)], reverseOffset q event slot orientation⟩ + +theorem headerVertices_eval (q n m edge tail head : Nat) : + eval (headerVertices q) (values n m edge tail head) = vertexCount n m q := by + simp [eval, headerVertices, values, zeroOffset, Emitter.affineValue, + vertexCount, eventCount, addressCount, Nat.mul_add, + Nat.mul_comm, Nat.add_comm, Nat.add_assoc] + +theorem headerDarts_eval (q n m edge tail head : Nat) : + eval (headerDarts q) (values n m edge tail head) = dartCount m q := by + simp [eval, headerDarts, values, zeroOffset, Emitter.affineValue, + dartCount, eventCount, Nat.mul_comm, Nat.mul_assoc] + +theorem eventVertexField_eval (n m q : Nat) (edge : Fin m) + (event : AlphabetGraph.LocalEvent (Fin q)) (tail head : Nat) : + eval (eventVertexField q event) (values n m edge.val tail head) = + (vertexEquiv n m q (.inl (edge, event))).val := by + rw [vertexEquiv_event_val, eventEquiv_val] + simp [eval, eventVertexField, eventOffset, values, Emitter.affineValue, Nat.mul_comm] + +theorem rawQueryField_eval (n m q : Nat) (edge : Fin m) (tail head : Fin n) + (query : Queries.RawQuery q) : + eval (rawQueryField q query) (values n m edge.val tail.val head.val) = + (vertexEquiv n m q (.inr (Queries.globalize tail head edge query))).val := by + cases query with + | inl query => + rcases query with ⟨side, tape⟩ + cases side <;> + simp [eval, rawQueryField, rawQueryTerms, vertexQueryTerms, rawQueryOffset, + values, Emitter.affineValue, Queries.globalize, eventCount, + Nat.mul_comm, Nat.add_assoc] + | inr tape => + simp [eval, rawQueryField, rawQueryTerms, edgeQueryTerms, rawQueryOffset, + values, Emitter.affineValue, Queries.globalize, eventCount, + Nat.mul_comm, Nat.add_assoc] + +theorem reverseDartField_eval (n m q : Nat) (edge : Fin m) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) + (tail head : Nat) : + eval (reverseDartField q event slot orientation) (values n m edge.val tail head) = + (dartEquiv m q (QueryIncidence.reverse (((edge, event), slot), orientation))).val := by + rw [dartEquiv_reverse_val, eventEquiv_val] + simp [eval, reverseDartField, reverseOffset, values, Emitter.affineValue, + Nat.mul_add, Nat.mul_comm, Nat.mul_assoc, + Nat.add_assoc] + +def queryEventTerms (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) : Terms := + rawQueryTerms q (Queries.query (fun _ _ => false) event slot) + +theorem rawQueryTerms_query (q : Nat) (P : Fin q → Fin q → Bool) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) : + rawQueryTerms q (Queries.query P event slot) = queryEventTerms q event slot := by + rcases event with ⟨kind, ⟨side, tape⟩, f, g, r₀, r₁, r₂⟩ + by_cases hk₀ : kind = 0 <;> by_cases hk₁ : kind = 1 <;> by_cases hk₂ : kind = 2 <;> + simp only [queryEventTerms, Queries.query, hk₀, hk₁, hk₂, ite_true, ite_false] + all_goals split_ifs <;> rfl + +def queryEventOffset (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (P : Fin q → Fin q → Bool) : Fin (fieldBound q) := + rawQueryOffset q (Queries.query P event slot) + +def fieldForQueryEvent (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (P : Fin q → Fin q → Bool) : Field (fieldBound q) := + ⟨queryEventTerms q event slot, queryEventOffset q event slot P⟩ + +theorem fieldForQueryEvent_eq_rawQueryField (q : Nat) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) + (P : Fin q → Fin q → Bool) : + fieldForQueryEvent q event slot P = rawQueryField q (Queries.query P event slot) := by + unfold fieldForQueryEvent queryEventOffset rawQueryField + rw [rawQueryTerms_query] + +theorem fieldForQueryEvent_eval (n m q : Nat) (edge : Fin m) (tail head : Fin n) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) + (P : Fin q → Fin q → Bool) : + eval (fieldForQueryEvent q event slot P) (values n m edge.val tail.val head.val) = + (vertexEquiv n m q + (.inr (Queries.globalize tail head edge (Queries.query P event slot)))).val := by + rw [fieldForQueryEvent_eq_rawQueryField] + exact rawQueryField_eval n m q edge tail head _ + +theorem fieldForQueryEvent_eval_verifier (n m q : Nat) + (G : ConstraintGraph (Fin n) (Fin m) (Fin q)) (edge : Fin m) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) : + eval (fieldForQueryEvent q event slot (G.accepts edge)) + (values n m edge.val (G.tail edge).val (G.head edge).val) = + (vertexEquiv n m q (.inr ((AlphabetGraph.verifier G).query (edge, event) slot))).val := by + rw [← Queries.globalize_query G edge event slot] + exact fieldForQueryEvent_eval n m q edge (G.tail edge) (G.head edge) event slot _ + +def dartTailTerms (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : Terms := + if orientation then queryEventTerms q event slot else [(2, localCount q)] + +def dartTailOffset (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) (P : Fin q → Fin q → Bool) : Fin (fieldBound q) := + if orientation then queryEventOffset q event slot P else eventOffset q event + +def fieldForDartTail (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) (P : Fin q → Fin q → Bool) : Field (fieldBound q) := + ⟨dartTailTerms q event slot orientation, dartTailOffset q event slot orientation P⟩ + +theorem fieldForDartTail_eval (n m q : Nat) (edge : Fin m) (tail head : Fin n) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) + (P : Fin q → Fin q → Bool) : + eval (fieldForDartTail q event slot orientation P) + (values n m edge.val tail.val head.val) = + (vertexEquiv n m q (if orientation then + .inr (Queries.globalize tail head edge (Queries.query P event slot)) + else .inl (edge, event))).val := by + cases orientation with + | false => exact eventVertexField_eval n m q edge event tail.val head.val + | true => exact fieldForQueryEvent_eval n m q edge tail head event slot P + +def CoefficientsBounded (q : Nat) (terms : Terms) : Prop := + ∀ term ∈ terms, term.2 < fieldBound q + +theorem headerVertices_coefficients (q : Nat) : CoefficientsBounded q (headerVertices q).terms := by + simp only [CoefficientsBounded, headerVertices, List.mem_cons, List.not_mem_nil, or_false] + intro term h + rcases h with rfl | rfl + · exact tapeCount_lt_bound q + · exact local_add_pair_lt_bound q + +theorem headerDarts_coefficients (q : Nat) : CoefficientsBounded q (headerDarts q).terms := by + intro term h + have heq : term = (1, 12 * localCount q) := by simpa [headerDarts] using h + subst term + exact twelve_local_lt_bound q + +theorem eventVertexField_coefficients (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) : + CoefficientsBounded q (eventVertexField q event).terms := by + intro term h + have heq : term = (2, localCount q) := by simpa [eventVertexField] using h + subst term + exact localCount_lt_bound q + +theorem rawQueryTerms_coefficients (q : Nat) (query : Queries.RawQuery q) : + CoefficientsBounded q (rawQueryTerms q query) := by + cases query with + | inl query => + rcases query with ⟨side, tape⟩ + intro term h + simp only [rawQueryTerms, vertexQueryTerms, List.mem_cons, List.not_mem_nil, or_false] at h + rcases h with rfl | rfl + · exact localCount_lt_bound q + · exact tapeCount_lt_bound q + | inr tape => + intro term h + simp only [rawQueryTerms, edgeQueryTerms, List.mem_cons, List.not_mem_nil, or_false] at h + rcases h with rfl | rfl | rfl + · exact localCount_lt_bound q + · exact tapeCount_lt_bound q + · exact pairTapeCount_lt_bound q + +theorem queryEventTerms_coefficients (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) : CoefficientsBounded q (queryEventTerms q event slot) := + rawQueryTerms_coefficients q _ + +theorem reverseDartField_coefficients (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : + CoefficientsBounded q (reverseDartField q event slot orientation).terms := by + intro term h + have heq : term = (2, 12 * localCount q) := by simpa [reverseDartField] using h + subst term + exact twelve_local_lt_bound q + +theorem rawQueryTerms_length_le (q : Nat) (query : Queries.RawQuery q) : + (rawQueryTerms q query).length ≤ 3 := by + cases query with + | inl query => rcases query with ⟨side, tape⟩; simp [rawQueryTerms, vertexQueryTerms] + | inr tape => simp [rawQueryTerms, edgeQueryTerms] + +theorem queryEventTerms_length_le (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) : (queryEventTerms q event slot).length ≤ 3 := + rawQueryTerms_length_le q _ + +theorem dartTailTerms_coefficients (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : + CoefficientsBounded q (dartTailTerms q event slot orientation) := by + cases orientation with + | false => exact eventVertexField_coefficients q event + | true => exact queryEventTerms_coefficients q event slot + +theorem dartTailTerms_length_le (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : + (dartTailTerms q event slot orientation).length ≤ 3 := by + cases orientation with + | false => simp [dartTailTerms] + | true => exact queryEventTerms_length_le q event slot + +theorem offset_lt {bound : Nat} (field : Field bound) : field.offset.val < bound := + field.offset.isLt + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Addresses + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetGraph.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..a904f906ba2caf2c5dd256500b43ef2b7d996851 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetGraph.lean @@ -0,0 +1,343 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.QueryIncidence +import OAI.Combinatorics.IndependentSets.PCP.AlphabetReduction + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.AlphabetGraph + +open IndependentSetsGames.Foundations.Hastad +open scoped BigOperators + +abbrev Address (V E A : Type*) := (V × Cube A) ⊕ (E × Cube (A × A)) + +abbrev LocalEvent (A : Type*) := Fin 4 × AlphabetReduction.InputCoordinate A × + Cube (A × A) × Cube (A × A) × Cube (A × A) × Cube (A × A) × Cube (A × A) + +abbrev Event (E A : Type*) := E × LocalEvent A + +variable {V E A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + +abbrev legal (G : ConstraintGraph V E A) (e : E) (p : A × A) : Prop := + G.accepts e p.1 p.2 = true + +instance legalDecidable (G : ConstraintGraph V E A) (e : E) : + DecidablePred (legal G e) := + fun p => inferInstanceAs (Decidable (G.accepts e p.1 p.2 = true)) + +def restrictTape (G : ConstraintGraph V E A) (e : E) (f : Cube (A × A)) : + Cube (AlphabetReduction.LegalPair (G.accepts e)) := UniformRestriction.restrict (legal G e) f + +def extendTape (G : ConstraintGraph V E A) (e : E) + (f : Cube (AlphabetReduction.LegalPair (G.accepts e))) : Cube (A × A) := + UniformRestriction.extend (legal G e) f + +def globalizeQuery (G : ConstraintGraph V E A) (e : E) : + AlphabetReduction.InputCoordinate A ⊕ Cube (AlphabetReduction.LegalPair (G.accepts e)) → Address V E A + | .inl (side, tape) => .inl ((if side then G.head e else G.tail e), tape) + | .inr tape => .inr (e, extendTape G e tape) + +def verifier (G : ConstraintGraph V E A) : QueryIncidence.Verifier (Event E A) (Address V E A) 6 where + query := fun (e, kind, k, f, g, r₀, r₁, r₂) slot => + globalizeQuery G e (AssignmentTester.eventQueries (AlphabetReduction.pairEncoding (G.accepts e)) kind k + (restrictTape G e f) (restrictTape G e g) (restrictTape G e r₀) + (restrictTape G e r₁) (restrictTape G e r₂) slot) + accepts := fun (_, kind, _, _, _, _, _, _) b => AssignmentTester.eventAccepts kind b + +def vertexBlock (assignment : Address V E A → Bool) (v : V) : Cube A → Bool := + fun tape => assignment (.inl (v, tape)) + +def edgeOracle (G : ConstraintGraph V E A) (assignment : Address V E A → Bool) (e : E) : + Cube (AlphabetReduction.LegalPair (G.accepts e)) → Bool := + fun tape => assignment (.inr (e, extendTape G e tape)) + +omit [Fintype A] [DecidableEq A] [Nonempty A] in +theorem oracleAnswer_globalize (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) (e : E) + (x : AlphabetReduction.InputCoordinate A ⊕ Cube (AlphabetReduction.LegalPair (G.accepts e))) : + assignment (globalizeQuery G e x) = + AssignmentTester.oracleAnswer + (CodeComposition.pairWord (vertexBlock assignment (G.tail e)) + (vertexBlock assignment (G.head e))) (edgeOracle G assignment e) x := by + rcases x with ⟨side, tape⟩ | tape + · cases side <;> rfl + · rfl + +omit [Fintype A] [DecidableEq A] [Nonempty A] in +theorem response_eq_local (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) (e : E) (kind : Fin 4) + (k : AlphabetReduction.InputCoordinate A) (f g r₀ r₁ r₂ : Cube (A × A)) : + QueryIncidence.response (verifier G) assignment (e, kind, k, f, g, r₀, r₁, r₂) = + fun slot => AssignmentTester.oracleAnswer + (CodeComposition.pairWord (vertexBlock assignment (G.tail e)) + (vertexBlock assignment (G.head e))) (edgeOracle G assignment e) + (AssignmentTester.eventQueries (AlphabetReduction.pairEncoding (G.accepts e)) kind k + (restrictTape G e f) (restrictTape G e g) (restrictTape G e r₀) + (restrictTape G e r₁) (restrictTape G e r₂) slot) := by + funext slot + exact oracleAnswer_globalize G assignment e _ + +def eventReject (G : ConstraintGraph V E A) (assignment : Address V E A → Bool) + (event : Event E A) : ℝ := + AssignmentTester.truth (!((verifier G).accepts event (QueryIncidence.response (verifier G) assignment event))) + +omit [Fintype A] [DecidableEq A] [Nonempty A] in +theorem eventReject_eq_local (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) (e : E) (kind : Fin 4) + (k : AlphabetReduction.InputCoordinate A) (f g r₀ r₁ r₂ : Cube (A × A)) : + eventReject G assignment (e, kind, k, f, g, r₀, r₁, r₂) = + AssignmentTester.eventReject (AlphabetReduction.pairEncoding (G.accepts e)) + (CodeComposition.pairWord (vertexBlock assignment (G.tail e)) + (vertexBlock assignment (G.head e))) (edgeOracle G assignment e) kind k + (restrictTape G e f) (restrictTape G e g) (restrictTape G e r₀) + (restrictTape G e r₁) (restrictTape G e r₂) := by + unfold eventReject + rw [response_eq_local] + rfl + +theorem expect_prod {I J : Type*} [Fintype I] [Fintype J] (f : I × J → ℝ) : + (𝔼 z : I × J, f z) = 𝔼 i : I, 𝔼 j : J, f (i, j) := by + simpa only [Finset.univ_product_univ] using + Finset.expect_product (Finset.univ : Finset I) (Finset.univ : Finset J) f + +def localAverage (G : ConstraintGraph V E A) (assignment : Address V E A → Bool) + (e : E) : ℝ := 𝔼 sample : LocalEvent A, eventReject G assignment (e, sample) + +theorem expect_restrict_five {B : Type*} [Fintype B] [DecidableEq B] + (p : B → Prop) [DecidablePred p] + (h : ({b // p b} → Bool) → ({b // p b} → Bool) → ({b // p b} → Bool) → + ({b // p b} → Bool) → ({b // p b} → Bool) → ℝ) : + (𝔼 f : B → Bool, 𝔼 g : B → Bool, 𝔼 r₀ : B → Bool, + 𝔼 r₁ : B → Bool, 𝔼 r₂ : B → Bool, + h (UniformRestriction.restrict p f) (UniformRestriction.restrict p g) + (UniformRestriction.restrict p r₀) (UniformRestriction.restrict p r₁) + (UniformRestriction.restrict p r₂)) = + 𝔼 f : {b // p b} → Bool, 𝔼 g : {b // p b} → Bool, + 𝔼 r₀ : {b // p b} → Bool, 𝔼 r₁ : {b // p b} → Bool, + 𝔼 r₂ : {b // p b} → Bool, h f g r₀ r₁ r₂ := by + rw [UniformRestriction.expect_restrict p + (fun f => 𝔼 g : B → Bool, 𝔼 r₀ : B → Bool, 𝔼 r₁ : B → Bool, + 𝔼 r₂ : B → Bool, h f (UniformRestriction.restrict p g) + (UniformRestriction.restrict p r₀) (UniformRestriction.restrict p r₁) + (UniformRestriction.restrict p r₂))] + apply Finset.expect_congr rfl + intro f _ + rw [UniformRestriction.expect_restrict p + (fun g => 𝔼 r₀ : B → Bool, 𝔼 r₁ : B → Bool, 𝔼 r₂ : B → Bool, + h f g (UniformRestriction.restrict p r₀) (UniformRestriction.restrict p r₁) + (UniformRestriction.restrict p r₂))] + apply Finset.expect_congr rfl + intro g _ + rw [UniformRestriction.expect_restrict p + (fun r₀ => 𝔼 r₁ : B → Bool, 𝔼 r₂ : B → Bool, + h f g r₀ (UniformRestriction.restrict p r₁) (UniformRestriction.restrict p r₂))] + apply Finset.expect_congr rfl + intro r₀ _ + rw [UniformRestriction.expect_restrict p + (fun r₁ => 𝔼 r₂ : B → Bool, h f g r₀ r₁ (UniformRestriction.restrict p r₂))] + apply Finset.expect_congr rfl + intro r₁ _ + exact UniformRestriction.expect_restrict p (h f g r₀ r₁) + +omit [Nonempty A] in +theorem localAverage_eq_tester (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) (e : E) : + localAverage G assignment e = AlphabetReduction.edgeTesterReject (G.accepts e) + (vertexBlock assignment (G.tail e)) (vertexBlock assignment (G.head e)) + (edgeOracle G assignment e) := by + unfold localAverage AlphabetReduction.edgeTesterReject AssignmentTester.explicitTesterReject + simp only [LocalEvent, expect_prod, eventReject_eq_local, restrictTape] + apply Finset.expect_congr rfl + intro kind _ + apply Finset.expect_congr rfl + intro side _ + apply Finset.expect_congr rfl + intro tape _ + exact expect_restrict_five (legal G e) + (AssignmentTester.eventReject (AlphabetReduction.pairEncoding (G.accepts e)) + (CodeComposition.pairWord (vertexBlock assignment (G.tail e)) + (vertexBlock assignment (G.head e))) (edgeOracle G assignment e) kind (side, tape)) + +def average [Fintype E] (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) : ℝ := + 𝔼 event : Event E A, eventReject G assignment event + +omit [Nonempty A] in +theorem average_eq_testers [Fintype E] (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) : + average G assignment = 𝔼 e : E, AlphabetReduction.edgeTesterReject (G.accepts e) + (vertexBlock assignment (G.tail e)) (vertexBlock assignment (G.head e)) + (edgeOracle G assignment e) := by + unfold average + rw [expect_prod] + exact Finset.expect_congr rfl (fun e _ => localAverage_eq_tester G assignment e) + +def decodedLabeling (assignment : Address V E A → Bool) : V → A := + fun v => CodeComposition.nearest (vertexBlock assignment v) + +theorem local_gap (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) (e : E) : + AssignmentTester.truth (!(G.edgeSatisfied (decodedLabeling assignment) e)) / 2048 ≤ + localAverage G assignment e := by + cases h : G.edgeSatisfied (decodedLabeling assignment) e with + | false => + rw [localAverage_eq_tester] + simpa [AssignmentTester.truth] using + AlphabetReduction.rejected_edge_tester_bound (G.accepts e) + (vertexBlock assignment (G.tail e)) (vertexBlock assignment (G.head e)) + (edgeOracle G assignment e) h + | true => + simp only [Bool.not_true, AssignmentTester.truth, Bool.false_eq_true, ite_false, zero_div] + apply Finset.expect_nonneg + intro sample _ + exact AssignmentTester.truth_nonneg _ + +theorem average_gap [Fintype E] (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) : + (𝔼 e : E, AssignmentTester.truth (!(G.edgeSatisfied (decodedLabeling assignment) e))) / 2048 ≤ + average G assignment := by + unfold average + rw [expect_prod, Finset.expect_div] + exact Finset.expect_le_expect (fun e _ => local_gap G assignment e) + +theorem expect_rejection_eq_count {I : Type*} [Fintype I] (b : I → Bool) : + (𝔼 i : I, AssignmentTester.truth (!(b i))) = + ((Finset.univ.filter (fun i => b i = false)).card : ℝ) / Fintype.card I := by + rw [Fintype.expect_eq_sum_div_card] + congr 1 + calc + (∑ i : I, AssignmentTester.truth (!(b i))) = ∑ i : I, if b i = false then (1 : ℝ) else 0 := by + apply Finset.sum_congr rfl + intro i _ + cases b i <;> norm_num [AssignmentTester.truth] + _ = _ := Finset.sum_boole _ _ + +omit [Nonempty A] in +theorem average_eq_count [Fintype E] (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) : + average G assignment = (QueryIncidence.verifierRejectionCount (verifier G) assignment : ℝ) / + Fintype.card (Event E A) := + expect_rejection_eq_count _ + +omit [Nonempty A] in +@[simp] theorem card_event [Fintype E] : + Fintype.card (Event E A) = Fintype.card E * Fintype.card (LocalEvent A) := + Fintype.card_prod _ _ + +omit [Nonempty A] in +theorem card_localEvent : + Fintype.card (LocalEvent A) = + 4 * (2 * 2 ^ Fintype.card A) * (2 ^ (Fintype.card A * Fintype.card A)) ^ 5 := by + simp [LocalEvent, AlphabetReduction.InputCoordinate, Cube, Fintype.card_prod, + pow_succ, Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm] + +omit [Nonempty A] in +theorem card_address [Fintype V] [Fintype E] : + Fintype.card (Address V E A) = + Fintype.card V * 2 ^ Fintype.card A + + Fintype.card E * 2 ^ (Fintype.card A * Fintype.card A) := by + simp [Address, Cube, Fintype.card_sum, Fintype.card_prod] + +theorem rejection_count_bound [Fintype E] (G : ConstraintGraph V E A) + (assignment : Address V E A → Bool) : + Fintype.card (LocalEvent A) * G.rejectionCount (decodedLabeling assignment) ≤ + 2048 * QueryIncidence.verifierRejectionCount (verifier G) assignment := by + classical + cases isEmpty_or_nonempty E with + | inl empty => + let := empty + simp [ConstraintGraph.rejectionCount, ConstraintGraph.rejectedDarts] + | inr inhabited => + let := inhabited + have h := average_gap G assignment + rw [average_eq_count, expect_rejection_eq_count, card_event, Nat.cast_mul, + div_div] at h + have he : (0 : ℝ) < Fintype.card E := by exact_mod_cast Fintype.card_pos + have hl : (0 : ℝ) < Fintype.card (LocalEvent A) := by + exact_mod_cast Fintype.card_pos + have hc := (div_le_div_iff₀ (mul_pos he (by norm_num)) (mul_pos he hl)).mp h + have hc' : + ((Fintype.card (LocalEvent A) : ℝ) * + (G.rejectionCount (decodedLabeling assignment) : ℝ)) * Fintype.card E ≤ + (2048 * (QueryIncidence.verifierRejectionCount (verifier G) assignment : ℝ)) * Fintype.card E := by + simpa only [ConstraintGraph.rejectionCount, ConstraintGraph.rejectedDarts, + mul_assoc, mul_comm, mul_left_comm] using hc + have result := (mul_le_mul_iff_left₀ he).mp hc' + exact_mod_cast result + +def honestAssignment (G : ConstraintGraph V E A) (labeling : V → A) : Address V E A → Bool + | .inl (v, tape) => tape (labeling v) + | .inr (e, tape) => tape (labeling (G.tail e), labeling (G.head e)) + +omit [Fintype A] [DecidableEq A] [Nonempty A] in +@[simp] theorem honest_vertexBlock (G : ConstraintGraph V E A) (labeling : V → A) (v : V) : + vertexBlock (honestAssignment G labeling) v = CodeComposition.codeword (labeling v) := rfl + +omit [Fintype A] [DecidableEq A] [Nonempty A] in +theorem honest_edgeOracle (G : ConstraintGraph V E A) (labeling : V → A) (e : E) + (h : G.edgeSatisfied labeling e = true) : + edgeOracle G (honestAssignment G labeling) e = + fun tape => tape ⟨(labeling (G.tail e), labeling (G.head e)), h⟩ := by + funext tape + exact UniformRestriction.extend_apply_of_mem (legal G e) tape + (labeling (G.tail e), labeling (G.head e)) h + +omit [Fintype A] [DecidableEq A] [Nonempty A] in +theorem honest_event (G : ConstraintGraph V E A) (labeling : V → A) + (satisfied : ∀ e, G.edgeSatisfied labeling e = true) (event : Event E A) : + (verifier G).accepts event (QueryIncidence.response (verifier G) (honestAssignment G labeling) event) = + true := by + rcases event with ⟨e, kind, k, f, g, r₀, r₁, r₂⟩ + rw [response_eq_local, honest_edgeOracle G labeling e (satisfied e)] + simp only [honest_vertexBlock] + exact AssignmentTester.event_perfect_completeness (AlphabetReduction.pairEncoding (G.accepts e)) + ⟨(labeling (G.tail e), labeling (G.head e)), satisfied e⟩ kind k + (restrictTape G e f) (restrictTape G e g) (restrictTape G e r₀) + (restrictTape G e r₁) (restrictTape G e r₂) + +def graph [DecidableEq V] [DecidableEq E] (G : ConstraintGraph V E A) : + ConstraintGraph (QueryIncidence.Vertex (Event E A) (Address V E A)) + (QueryIncidence.Dart (Event E A) 6) (QueryIncidence.Label 6) := QueryIncidence.graph (verifier G) (by omega) + +omit [DecidableEq A] [Nonempty A] in +theorem perfect_completeness [DecidableEq V] [DecidableEq E] (G : ConstraintGraph V E A) + (satisfied : G.Satisfiable) : (graph G).Satisfiable := by + obtain ⟨labeling, h⟩ := satisfied + exact QueryIncidence.satisfiable_of_verifier_satisfiable (verifier G) (by omega) + ⟨honestAssignment G labeling, honest_event G labeling h⟩ + +theorem gap_transfer [Fintype E] [DecidableEq V] [DecidableEq E] + (G : ConstraintGraph V E A) (a b : Nat) + (source : ∀ labeling : V → A, + a * Fintype.card E ≤ b * G.rejectionCount labeling) + (labeling : QueryIncidence.Vertex (Event E A) (Address V E A) → QueryIncidence.Label 6) : + a * Fintype.card (QueryIncidence.Dart (Event E A) 6) ≤ + (b * 12288) * (graph G).rejectionCount labeling := by + have verifierGap (assignment : Address V E A → Bool) : + a * Fintype.card (Event E A) ≤ + (b * 2048) * QueryIncidence.verifierRejectionCount (verifier G) assignment := by + rw [card_event] + calc + a * (Fintype.card E * Fintype.card (LocalEvent A)) = + Fintype.card (LocalEvent A) * (a * Fintype.card E) := by ac_rfl + _ ≤ Fintype.card (LocalEvent A) * (b * G.rejectionCount (decodedLabeling assignment)) := + Nat.mul_le_mul_left _ (source (decodedLabeling assignment)) + _ = b * (Fintype.card (LocalEvent A) * G.rejectionCount (decodedLabeling assignment)) := by + ac_rfl + _ ≤ b * (2048 * QueryIncidence.verifierRejectionCount (verifier G) assignment) := + Nat.mul_le_mul_left _ (rejection_count_bound G assignment) + _ = (b * 2048) * QueryIncidence.verifierRejectionCount (verifier G) assignment := by ac_rfl + have h := QueryIncidence.gap_transfer (verifier G) (by omega) a (b * 2048) verifierGap labeling + have hcoef : b * 2048 * 6 = b * 12288 := by omega + rw [hcoef] at h + exact h + +theorem alphabet_card : Fintype.card (QueryIncidence.Label 6) = 64 := QueryIncidence.six_query_alphabet + +end IndependentSetsGames.Foundations.PCP.AlphabetGraph + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetGraphBounds.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetGraphBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..22dcb7b8aff46c01d3b8f5c4d4d03acbdc2d6490 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetGraphBounds.lean @@ -0,0 +1,212 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Semantics2 + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetGraphBounds + +open scoped BigOperators + +abbrev OutputVertex (V E A : Type*) := + QueryIncidence.Vertex (AlphabetGraph.Event E A) (AlphabetGraph.Address V E A) + +abbrev OutputDart (E A : Type*) := QueryIncidence.Dart (AlphabetGraph.Event E A) 6 + +def localEventFactor (q : Nat) : Nat := + 4 * (2 * 2 ^ q) * (2 ^ (q * q)) ^ 5 + +def vertexFactor (q : Nat) : Nat := localEventFactor q + 2 ^ (q * q) + +def dartFactor (q : Nat) : Nat := 12 * localEventFactor q + +def sizeFactor (q : Nat) : Nat := 2 ^ q + vertexFactor q + dartFactor q + +theorem sizeFactor_positive (q : Nat) : 0 < sizeFactor q := by + have hp : (0 : Nat) < 2 ^ q := pow_pos (by decide) q + unfold sizeFactor + omega + +variable {V E A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + +theorem gap_transfer_real [Fintype E] [DecidableEq V] [DecidableEq E] + (G : ConstraintGraph V E A) (eps : ℝ) (_eps_nonnegative : 0 ≤ eps) + (source : ∀ labeling : V → A, + eps * (Fintype.card E : ℝ) ≤ (G.rejectionCount labeling : ℝ)) + (labeling : OutputVertex V E A → QueryIncidence.Label 6) : + (eps / 12288) * (Fintype.card (OutputDart E A) : ℝ) ≤ + ((AlphabetGraph.graph G).rejectionCount labeling : ℝ) := by + let assignment := QueryIncidence.decodedAssignment (by decide : 0 < 6) labeling + have htest : + (Fintype.card (AlphabetGraph.LocalEvent A) : ℝ) * + (G.rejectionCount (AlphabetGraph.decodedLabeling assignment) : ℝ) ≤ + 2048 * (QueryIncidence.verifierRejectionCount (AlphabetGraph.verifier G) assignment : ℝ) := by + exact_mod_cast AlphabetGraph.rejection_count_bound G assignment + have hinc : + 2 * (QueryIncidence.verifierRejectionCount (AlphabetGraph.verifier G) assignment : ℝ) ≤ + ((AlphabetGraph.graph G).rejectionCount labeling : ℝ) := by + exact_mod_cast QueryIncidence.rejection_count_bound + (AlphabetGraph.verifier G) (by decide : 0 < 6) labeling + have hscaled : + eps * (Fintype.card E : ℝ) * (Fintype.card (AlphabetGraph.LocalEvent A) : ℝ) ≤ + 2048 * (QueryIncidence.verifierRejectionCount (AlphabetGraph.verifier G) assignment : ℝ) := by + calc + _ = (Fintype.card (AlphabetGraph.LocalEvent A) : ℝ) * + (eps * (Fintype.card E : ℝ)) := by ring + _ ≤ (Fintype.card (AlphabetGraph.LocalEvent A) : ℝ) * + (G.rejectionCount (AlphabetGraph.decodedLabeling assignment) : ℝ) := + mul_le_mul_of_nonneg_left (source (AlphabetGraph.decodedLabeling assignment)) + (Nat.cast_nonneg _) + _ ≤ _ := htest + change (eps / 12288) * + (Fintype.card (QueryIncidence.Dart (AlphabetGraph.Event E A) 6) : ℝ) ≤ _ + rw [QueryIncidence.card_dart, AlphabetGraph.card_event] + push_cast + nlinarith + +omit [Nonempty A] + +variable [Fintype V] [Fintype E] + +theorem card_output_vertex : + Fintype.card (OutputVertex V E A) = + Fintype.card V * 2 ^ Fintype.card A + + Fintype.card E * vertexFactor (Fintype.card A) := by + rw [QueryIncidence.card_vertex, AlphabetGraph.card_event, + AlphabetGraph.card_address, AlphabetGraph.card_localEvent] + unfold vertexFactor localEventFactor + ring + +theorem card_output_dart : + Fintype.card (OutputDart E A) = Fintype.card E * dartFactor (Fintype.card A) := by + rw [QueryIncidence.card_dart, AlphabetGraph.card_event, AlphabetGraph.card_localEvent] + unfold dartFactor localEventFactor + ring + +theorem card_output_total : + Fintype.card (OutputVertex V E A) + Fintype.card (OutputDart E A) = + Fintype.card V * 2 ^ Fintype.card A + + Fintype.card E * (vertexFactor (Fintype.card A) + dartFactor (Fintype.card A)) := by + rw [card_output_vertex, card_output_dart] + ring + +theorem card_output_total_le : + Fintype.card (OutputVertex V E A) + Fintype.card (OutputDart E A) ≤ + sizeFactor (Fintype.card A) * (Fintype.card V + Fintype.card E) := by + rw [card_output_total] + have hv : 2 ^ Fintype.card A ≤ sizeFactor (Fintype.card A) := by + unfold sizeFactor + omega + have he : vertexFactor (Fintype.card A) + dartFactor (Fintype.card A) ≤ + sizeFactor (Fintype.card A) := by + unfold sizeFactor + exact Nat.add_le_add_right (Nat.le_add_left _ _) _ + calc + _ ≤ Fintype.card V * sizeFactor (Fintype.card A) + + Fintype.card E * sizeFactor (Fintype.card A) := + Nat.add_le_add (Nat.mul_le_mul_left _ hv) (Nat.mul_le_mul_left _ he) + _ = _ := by ring + +theorem card_output_vertex_le : + Fintype.card (OutputVertex V E A) ≤ + sizeFactor (Fintype.card A) * (Fintype.card V + Fintype.card E) := + (Nat.le_add_right _ _).trans card_output_total_le + +theorem card_output_dart_le : + Fintype.card (OutputDart E A) ≤ + sizeFactor (Fintype.card A) * (Fintype.card V + Fintype.card E) := + (Nat.le_add_left _ _).trans card_output_total_le + +end IndependentSetsGames.Foundations.PCP.AlphabetGraphBounds + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTableBounds + +open AlphabetTable + +variable {q : Nat} + +theorem gap_transfer_real (hq : 0 < q) (input : GenericGraphTables.Table q) + (eps : ℝ) (eps_nonnegative : 0 ≤ eps) + (source : ∀ labeling : Fin input.vertices → Fin q, + eps * (input.darts : ℝ) ≤ + ((GenericGraphTables.semantics input).rejectionCount labeling : ℝ)) + (labeling : Fin (Table.build input).vertices → GraphTables.Label) : + (eps / 12288) * ((Table.build input).darts : ℝ) ≤ + ((GraphTables.semantics (Table.build input)).rejectionCount labeling : ℝ) := by + classical + let : Nonempty (Fin q) := ⟨⟨0, hq⟩⟩ + let lifted := fun vertex => Enumeration.labelEquiv.symm + (labeling (Enumeration.vertexEquiv input.vertices input.darts q vertex)) + have h := AlphabetGraphBounds.gap_transfer_real + (GenericGraphTables.semantics input) eps eps_nonnegative + (by simpa only [Fintype.card_fin] using source) lifted + rw [Enumeration.card_dart] at h + have counts := Table.rejectionCount_build input lifted + have restored : (fun v : Fin (Table.build input).vertices => Enumeration.labelEquiv + (lifted ((Enumeration.vertexEquiv input.vertices input.darts q).symm v))) = labeling := by + funext v + dsimp only [lifted] + rw [Enumeration.labelEquiv.apply_symm_apply] + exact congrArg labeling + ((Enumeration.vertexEquiv input.vertices input.darts q).apply_symm_apply v) + rw [restored] at counts + rw [← counts] at h + exact h + +theorem build_vertices (input : GenericGraphTables.Table q) : + (Table.build input).vertices = input.vertices * 2 ^ q + + input.darts * AlphabetGraphBounds.vertexFactor q := by + rw [Table.build_vertices] + simp only [Enumeration.vertexCount, Enumeration.eventCount, Enumeration.addressCount, + Enumeration.localCount, Enumeration.tapeCount, Enumeration.pairTapeCount, + Enumeration.fiveTapeCount, AlphabetGraphBounds.vertexFactor, + AlphabetGraphBounds.localEventFactor] + ring + +theorem build_darts (input : GenericGraphTables.Table q) : + (Table.build input).darts = input.darts * AlphabetGraphBounds.dartFactor q := by + rw [Table.build_darts] + simp only [Enumeration.dartCount, Enumeration.eventCount, Enumeration.localCount, + Enumeration.tapeCount, Enumeration.pairTapeCount, Enumeration.fiveTapeCount, + AlphabetGraphBounds.dartFactor, AlphabetGraphBounds.localEventFactor] + ring + +theorem build_total (input : GenericGraphTables.Table q) : + (Table.build input).vertices + (Table.build input).darts = + input.vertices * 2 ^ q + input.darts * + (AlphabetGraphBounds.vertexFactor q + AlphabetGraphBounds.dartFactor q) := by + rw [build_vertices, build_darts] + ring + +theorem build_total_le (input : GenericGraphTables.Table q) : + (Table.build input).vertices + (Table.build input).darts ≤ + AlphabetGraphBounds.sizeFactor q * (input.vertices + input.darts) := by + rw [build_total] + have hv : 2 ^ q ≤ AlphabetGraphBounds.sizeFactor q := by + unfold AlphabetGraphBounds.sizeFactor + omega + have he : AlphabetGraphBounds.vertexFactor q + AlphabetGraphBounds.dartFactor q ≤ + AlphabetGraphBounds.sizeFactor q := by + unfold AlphabetGraphBounds.sizeFactor + exact Nat.add_le_add_right (Nat.le_add_left _ _) _ + calc + _ ≤ input.vertices * AlphabetGraphBounds.sizeFactor q + + input.darts * AlphabetGraphBounds.sizeFactor q := + Nat.add_le_add (Nat.mul_le_mul_left _ hv) (Nat.mul_le_mul_left _ he) + _ = _ := by ring + +theorem build_vertices_le (input : GenericGraphTables.Table q) : + (Table.build input).vertices ≤ + AlphabetGraphBounds.sizeFactor q * (input.vertices + input.darts) := + (Nat.le_add_right _ _).trans (build_total_le input) + +theorem build_darts_le (input : GenericGraphTables.Table q) : + (Table.build input).darts ≤ + AlphabetGraphBounds.sizeFactor q * (input.vertices + input.darts) := + (Nat.le_add_left _ _).trans (build_total_le input) + +theorem sizeFactor_positive : 0 < AlphabetGraphBounds.sizeFactor q := + AlphabetGraphBounds.sizeFactor_positive q + +end IndependentSetsGames.Foundations.PCP.AlphabetTableBounds + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetReduction.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4841d023f2e652176ea4deceb58df9c75faa3e6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetReduction.lean @@ -0,0 +1,148 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Bits +import OAI.Combinatorics.IndependentSets.PCP.AssignmentTester +import OAI.Combinatorics.IndependentSets.PCP.CodeComposition + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.AlphabetReduction + +open IndependentSetsGames.Foundations.Hastad +open CodeComposition + +variable {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + +abbrev LegalPair (accepts : A → A → Bool) := + {p : A × A // accepts p.1 p.2 = true} + +abbrev InputCoordinate (A : Type*) := Bool × Cube A + +def pairEncoding (accepts : A → A → Bool) (p : LegalPair accepts) : + InputCoordinate A → Bool := + pairWord (codeword p.1.1) (codeword p.1.2) + +def edgeTesterReject (accepts : A → A → Bool) (left right : Cube A → Bool) + (F : Cube (LegalPair accepts) → Bool) : ℝ := + AssignmentTester.explicitTesterReject (pairEncoding accepts) (pairWord left right) F + +theorem rejected_edge_tester_bound (accepts : A → A → Bool) + (left right : Cube A → Bool) + (F : Cube (LegalPair accepts) → Bool) + (hbad : accepts (nearest left) (nearest right) = false) : + 1 / 2048 ≤ edgeTesterReject accepts left right F := by + have hfar (p : LegalPair accepts) : + (1 / 8 : ℝ) ≤ AssignmentTester.distance (pairWord left right) (pairEncoding accepts p) := by + have h := rejected_pair_far accepts left right hbad p.1.1 p.1.2 p.2 + convert h using 1 + rfl + have h := AssignmentTester.explicit_proximity_soundness (pairEncoding accepts) + (pairWord left right) F (δ := 1 / 8) (by norm_num) (by norm_num) hfar + norm_num at h + exact h + +omit [Nonempty A] in +theorem honest_edge_tester (accepts : A → A → Bool) (a b : A) + (hab : accepts a b = true) : + edgeTesterReject accepts (codeword a) (codeword b) + (fun f => f ⟨(a, b), hab⟩) = 0 := by + unfold edgeTesterReject + rw [AssignmentTester.explicitTesterReject_eq] + exact AssignmentTester.tester_perfect_completeness + (pairEncoding accepts) ⟨(a, b), hab⟩ + +end IndependentSetsGames.Foundations.PCP.AlphabetReduction +end +namespace IndependentSetsGames.Foundations.PCP.UniformRestriction + +open scoped BigOperators + +variable {B : Type*} (p : B → Prop) + +def restrict (f : B → Bool) : {b // p b} → Bool := fun b => f b.1 + +variable [DecidablePred p] + +def extend (g : {b // p b} → Bool) : B → Bool := + fun b => if hb : p b then g ⟨b, hb⟩ else false + +def canonicalize (f : B → Bool) : B → Bool := extend p (restrict p f) + +omit [DecidablePred p] in +@[simp] theorem restrict_apply (f : B → Bool) (b : {b // p b}) : + restrict p f b = f b.1 := rfl + +@[simp] theorem extend_apply_of_mem (g : {b // p b} → Bool) (b : B) (hb : p b) : + extend p g b = g ⟨b, hb⟩ := by + simp [extend, hb] + +@[simp] theorem extend_apply_of_not_mem (g : {b // p b} → Bool) (b : B) + (hb : ¬ p b) : extend p g b = false := by + simp [extend, hb] + +@[simp] theorem restrict_extend (g : {b // p b} → Bool) : + restrict p (extend p g) = g := by + funext b + simp [restrict, extend, b.property] + +@[simp] theorem canonicalize_apply_of_mem (f : B → Bool) (b : B) (hb : p b) : + canonicalize p f b = f b := by + simp [canonicalize, hb] + +@[simp] theorem canonicalize_apply_of_not_mem (f : B → Bool) (b : B) + (hb : ¬ p b) : canonicalize p f b = false := by + simp [canonicalize, hb] + +@[simp] theorem restrict_canonicalize (f : B → Bool) : + restrict p (canonicalize p f) = restrict p f := by + exact restrict_extend p (restrict p f) + +@[simp] theorem canonicalize_idempotent (f : B → Bool) : + canonicalize p (canonicalize p f) = canonicalize p f := by + simp only [canonicalize, restrict_extend] + +theorem canonicalize_eq_iff (f g : B → Bool) : + canonicalize p f = canonicalize p g ↔ restrict p f = restrict p g := by + constructor + · intro h + simpa only [restrict_canonicalize] using congrArg (restrict p) h + · intro h + exact congrArg (extend p) h + +variable [Fintype B] [DecidableEq B] + +theorem expect_restrict (h : ({b // p b} → Bool) → ℝ) : + (𝔼 f : B → Bool, h (restrict p f)) = 𝔼 g : {b // p b} → Bool, h g := by + calc + (𝔼 f : B → Bool, h (restrict p f)) = + 𝔼 g : ({b // p b} → Bool) × ({b // ¬ p b} → Bool), h g.1 := + Fintype.expect_equiv (Equiv.piEquivPiSubtypeProd p (fun _ => Bool)) + _ _ (fun _ => rfl) + _ = 𝔼 g : {b // p b} → Bool, 𝔼 _k : {b // ¬ p b} → Bool, h g := by + simpa only [Finset.univ_product_univ] using + Finset.expect_product + (Finset.univ : Finset ({b // p b} → Bool)) + (Finset.univ : Finset ({b // ¬ p b} → Bool)) + (fun g : ({b // p b} → Bool) × ({b // ¬ p b} → Bool) => h g.1) + _ = 𝔼 g : {b // p b} → Bool, h g := by + simp only [Fintype.expect_const] + +theorem expect_canonicalize (h : (B → Bool) → ℝ) : + (𝔼 f : B → Bool, h (canonicalize p f)) = + 𝔼 g : {b // p b} → Bool, h (extend p g) := + expect_restrict p (fun g => h (extend p g)) + +theorem expect_restrict_pair (h : ({b // p b} → Bool) → ({b // p b} → Bool) → ℝ) : + (𝔼 f : B → Bool, 𝔼 g : B → Bool, h (restrict p f) (restrict p g)) = + 𝔼 f : {b // p b} → Bool, 𝔼 g : {b // p b} → Bool, h f g := by + calc + _ = 𝔼 f : B → Bool, 𝔼 g : {b // p b} → Bool, h (restrict p f) g := by + apply Finset.expect_congr rfl + intro f _ + exact expect_restrict p (h (restrict p f)) + _ = _ := expect_restrict p (fun f => 𝔼 g : {b // p b} → Bool, h f g) + +end IndependentSetsGames.Foundations.PCP.UniformRestriction + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetRetraction.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetRetraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..0080f1f7ca46d409d0cc8f843bb2bf23dd6adc79 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/AlphabetRetraction.lean @@ -0,0 +1,72 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.QueryIncidence +import OAI.Combinatorics.IndependentSets.PCP.InitialGraph + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetRetraction + +variable {V E A B : Type*} + +def pullback (G : ConstraintGraph V E A) (decode : B → A) : ConstraintGraph V E B where + reverse := G.reverse + reverse_involutive := G.reverse_involutive + tail := G.tail + accepts := fun e b c => G.accepts e (decode b) (decode c) + reverse_accepts := fun e b c => G.reverse_accepts e (decode b) (decode c) + +@[simp] theorem edgeSatisfied_pullback (G : ConstraintGraph V E A) + (decode : B → A) (labeling : V → B) (e : E) : + (pullback G decode).edgeSatisfied labeling e = + G.edgeSatisfied (decode ∘ labeling) e := rfl + +@[simp] theorem rejectionCount_pullback [Fintype E] (G : ConstraintGraph V E A) + (decode : B → A) (labeling : V → B) : + (pullback G decode).rejectionCount labeling = + G.rejectionCount (decode ∘ labeling) := rfl + +theorem satisfiable_pullback_iff (G : ConstraintGraph V E A) + (decode : B → A) (encode : A → B) (sectionLaw : ∀ a, decode (encode a) = a) : + (pullback G decode).Satisfiable ↔ G.Satisfiable := by + constructor + · rintro ⟨labeling, h⟩ + exact ⟨decode ∘ labeling, h⟩ + · rintro ⟨labeling, h⟩ + refine ⟨encode ∘ labeling, fun e => ?_⟩ + change G.accepts e (decode (encode (labeling (G.tail e)))) + (decode (encode (labeling (G.head e)))) = true + simpa only [ConstraintGraph.edgeSatisfied, sectionLaw] using h e + +abbrev Label64 := QueryIncidence.Label 6 + +def decode64 (label : Label64) : InitialGraph.Label := (label 0, label 1, label 2) + +def encode64 (label : InitialGraph.Label) : Label64 := + fun i => if i = 0 then label.1 else if i = 1 then label.2.1 else label.2.2 + +@[simp] theorem decode_encode64 (label : InitialGraph.Label) : + decode64 (encode64 label) = label := by + rcases label with ⟨a, b, c⟩ + rfl + +def initial64 (F : IndependentSetsGames.Foundations.Target.Formula) : + ConstraintGraph (InitialGraph.CompactVertex F) (InitialGraph.CompactDart F) Label64 := + pullback (InitialGraph.build F) decode64 + +theorem initial64_satisfiable_iff (F : IndependentSetsGames.Foundations.Target.Formula) : + (initial64 F).Satisfiable ↔ F.Satisfiable := + (satisfiable_pullback_iff (InitialGraph.build F) decode64 encode64 decode_encode64).trans + (InitialGraph.build_satisfiable_iff F) + +theorem initial64_alphabet : Fintype.card Label64 = 64 := + QueryIncidence.six_query_alphabet + +theorem initial64_inverse_size_gap (F : IndependentSetsGames.Foundations.Target.Formula) + (unsat : ¬ F.Satisfiable) (labeling : InitialGraph.CompactVertex F → Label64) : + Fintype.card (InitialGraph.CompactDart F) ≤ + (6 * F.clauses.length + 1) * (initial64 F).rejectionCount labeling := + InitialGraph.build_inverse_size_gap F unsat (decode64 ∘ labeling) + +end IndependentSetsGames.Foundations.PCP.AlphabetRetraction + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Ambient.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Ambient.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b105c0a7ba2615a4a281309617a015c854f50e4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Ambient.lean @@ -0,0 +1,584 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Input +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.PCP.ReadRelation +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupDiscard +import OAI.Combinatorics.IndependentSets.PCP.Lookup + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Lookup +open Turing +open IndependentSetsGames.Foundations.Complexity +open MachineComposition GenericGraphTables +variable {K Λ σ : Type} [DecidableEq K] +section Ambient + +variable {q n m : Nat} (counter source destination : K) (labels : Label → Λ) + (exit : Option Λ) + (P : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atStatement : ∀ label, P (labels label) = statement q counter source destination labels exit label) + +include atStatement + +theorem skipRowTrace (base : K → List Bool) (row : DartRow q n m) (suffix : List Bool) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step P))^[row.tail.val + row.reverseIndex.val + 3] + (some ⟨some (labels .skipTail), (ambient, register), + Function.update base source (rowBits row ++ suffix)⟩) = + some ⟨some (labels .guard), (ambient, none), Function.update base source suffix⟩ := by + have ht := MachineLookup.discardTrace_update source (labels .skipTail) (labels .skipReverse) + P (atStatement .skipTail) base row.tail.val + (encodeWord row.reverseIndex.val ++ (encodeWords (relationWords row.relation) ++ suffix)) + ambient register + have hr := MachineLookup.discardTrace_update source (labels .skipReverse) (labels .skipPredicate) + P (atStatement .skipReverse) base row.reverseIndex.val + (encodeWords (relationWords row.relation) ++ suffix) ambient none + have hp : TM2.step P + ⟨some (labels .skipPredicate), (ambient, none), Function.update base source + (encodeWords (relationWords row.relation) ++ suffix)⟩ = + some ⟨some (labels .guard), (ambient, none), Function.update base source suffix⟩ := by + change some (TM2.stepAux (P (labels .skipPredicate)) _ _) = _ + rw [atStatement .skipPredicate] + have h := congrArg some (stepAux_skipBits source row.relation.toList + (.goto fun _ => labels .guard) base suffix ambient none) + simpa only [statement, Vector.length_toList, relationWords, TM2.stepAux] using h + rw [rowBits_eq] + simp only [List.append_assoc] + rw [show row.tail.val + row.reverseIndex.val + 3 = + 1 + ((row.reverseIndex.val + 1) + (row.tail.val + 1)) by omega, + Function.iterate_add_apply, Function.iterate_add_apply, ht, hr, + Function.iterate_one, advance_some, hp] + +theorem skipRowTrace_fromTapes (base : K → List Bool) (row : DartRow q n m) + (suffix : List Bool) (hinput : base source = rowBits row ++ suffix) + (ambient : σ) (register : Option Bool) : + (advance (TM2.step P))^[row.tail.val + row.reverseIndex.val + 3] + (some ⟨some (labels .skipTail), (ambient, register), base⟩) = + some ⟨some (labels .guard), (ambient, none), Function.update base source suffix⟩ := by + have h := skipRowTrace counter source destination labels exit P atStatement + base row suffix ambient register + have hb : Function.update base source (rowBits row ++ suffix) = base := by + rw [← hinput] + exact Function.update_eq_self source base + rw [hb] at h + exact h + +theorem selectTrace (hsd : source ≠ destination) (base : K → List Bool) + (row : DartRow q n m) (suffix : List Bool) + (hinput : base source = rowBits row ++ suffix) (ambient : σ) (register : Option Bool) : + (advance (TM2.step P))^[row.tail.val + 2] + (some ⟨some (labels .select), (ambient, register), base⟩) = + some ⟨exit, (ambient, none), Hastad.SourceMachine.fieldTapes source destination base + (encodeWord row.reverseIndex.val ++ (encodeWords (relationWords row.relation) ++ suffix)) + (encodeWord row.tail.val ++ base destination)⟩ := by + let ht := Hastad.SourceMachine.fieldInTime source destination hsd + (labels .select) (labels .copy) exit P (atStatement .select) (atStatement .copy) + base row.tail.val + (encodeWord row.reverseIndex.val ++ (encodeWords (relationWords row.relation) ++ suffix)) + (by simpa only [rowBits_eq, List.append_assoc] using hinput) ambient register + have hsteps : ht.steps = row.tail.val + 2 := rfl + have htrace := ht.evals_in_steps + rw [hsteps] at htrace + exact htrace + +theorem lookupTailTrace + (hcs : counter ≠ source) (hcd : counter ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (prior : List (DartRow q n m)) (row : DartRow q n m) + (counterSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step P))^[lookupCost prior row] + (some ⟨some (labels .guard), (ambient, register), + MachineLookup.tapes counter source destination base + (encodeWord prior.length ++ counterSuffix) + (rowsBits prior ++ (rowBits row ++ suffix)) output⟩) = + some ⟨exit, (ambient, none), + MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) + (encodeWord row.reverseIndex.val ++ (encodeWords (relationWords row.relation) ++ suffix)) + (encodeWord row.tail.val ++ output)⟩ := by + induction prior generalizing register with + | nil => + simp only [lookupCost, prefixCost, List.map_nil, List.sum_nil, Nat.zero_add, + List.length_nil, rowsBits_nil, List.nil_append] + rw [show row.tail.val + 3 = (row.tail.val + 2) + 1 by omega, + Function.iterate_succ_apply] + have hg := MachineUnaryCounter.guardStep_zero counter (labels .guard) + (labels .skipTail) (labels .select) P (atStatement .guard) + (MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) (rowBits row ++ suffix) output) + counterSuffix ambient register + have hcounter : MachineUnaryCounter.counterTapes counter + (MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) (rowBits row ++ suffix) output) 0 counterSuffix = + MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) (rowBits row ++ suffix) output := by + simp only [MachineUnaryCounter.counterTapes, MachineLookup.update_index _ _ _ hcs hcd] + rw [hcounter] at hg + simp only [advance_some] + rw [hg] + have hs := selectTrace counter source destination labels exit P atStatement hsd + (MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) (rowBits row ++ suffix) output) + row suffix (by simp [hsd]) ambient none + simpa only [MachineLookup.tapes_destination, + MachineLookup.fieldTapes_eq _ _ _ hsd] using hs + | cons first prior ih => + simp only [lookupCost, prefixCost, List.map_cons, List.sum_cons, List.length_cons, + rowsBits_cons, List.append_assoc] + rw [show skipCost first + (prior.map skipCost).sum + row.tail.val + 3 = + ((prior.map skipCost).sum + row.tail.val + 3) + + (first.tail.val + first.reverseIndex.val + 3) + 1 by simp only [skipCost]; omega, + Function.iterate_succ_apply] + have hg := MachineUnaryCounter.guardStep_succ counter (labels .guard) + (labels .skipTail) (labels .select) P (atStatement .guard) + (MachineLookup.tapes counter source destination base + (encodeWord prior.length ++ counterSuffix) + (rowBits first ++ (rowsBits prior ++ (rowBits row ++ suffix))) output) + prior.length counterSuffix ambient register + simp only [MachineUnaryCounter.counterTapes, + MachineLookup.update_index _ _ _ hcs hcd] at hg + simp only [advance_some] + rw [hg, Function.iterate_add_apply] + have hs := skipRowTrace_fromTapes counter source destination labels exit P atStatement + (MachineLookup.tapes counter source destination base + (encodeWord prior.length ++ counterSuffix) + (rowBits first ++ (rowsBits prior ++ (rowBits row ++ suffix))) output) + first (rowsBits prior ++ (rowBits row ++ suffix)) (by simp [hsd]) ambient none + rw [hs] + simp only [MachineLookup.update_source _ _ _ hsd] + exact ih none + +end Ambient + +theorem lookupCost_le {q n m : Nat} (prior : List (DartRow q n m)) (row : DartRow q n m) : + lookupCost prior row ≤ (rowsBits prior ++ rowBits row).length + + 2 * (encodeWord prior.length).length + 1 := by + have hp : prefixCost prior ≤ (rowsBits prior).length + 2 * prior.length := by + induction prior with + | nil => simp [prefixCost] + | cons first prior ih => + have hb : skipCost first ≤ (rowBits first).length + 2 := by + simp only [skipCost, rowBits_eq, List.length_append, encodeWord_length] + omega + simp only [prefixCost, List.map_cons, List.sum_cons, rowsBits_cons, + List.length_append, List.length_cons] at * + omega + have hr : row.tail.val + 1 ≤ (rowBits row).length := by + simp only [rowBits_eq, List.length_append, encodeWord_length] + omega + simp only [lookupCost, List.length_append, encodeWord_length] + omega + +def lookupTailInTime {q n m : Nat} + (counter source destination : K) (labels : Label → Λ) (exit : Option Λ) + (P : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atStatement : ∀ label, P (labels label) = statement q counter source destination labels exit label) + (hcs : counter ≠ source) (hcd : counter ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (prior : List (DartRow q n m)) (row : DartRow q n m) + (counterSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step P) + ⟨some (labels .guard), (ambient, register), + MachineLookup.tapes counter source destination base + (encodeWord prior.length ++ counterSuffix) + (rowsBits prior ++ (rowBits row ++ suffix)) output⟩ + (some ⟨exit, (ambient, none), + MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) + (encodeWord row.reverseIndex.val ++ (encodeWords (relationWords row.relation) ++ suffix)) + (encodeWord row.tail.val ++ output)⟩) + ((rowsBits prior ++ rowBits row).length + 2 * (encodeWord prior.length).length + 1) where + steps := lookupCost prior row + evals_in_steps := lookupTailTrace counter source destination labels exit P atStatement + hcs hcd hsd base prior row counterSuffix suffix output ambient register + steps_le_m := lookupCost_le prior row + +theorem tableTailTrace {q : Nat} + (counter source destination : K) (labels : Label → Λ) (exit : Option Λ) + (P : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atStatement : ∀ label, P (labels label) = statement q counter source destination labels exit label) + (hcs : counter ≠ source) (hcd : counter ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (table : Table q) (e : Fin table.darts) + (counterSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step P))^[lookupCost ((rowList table).take e.val) table.rows[e]] + (some ⟨some (labels .guard), (ambient, register), + MachineLookup.tapes counter source destination base + (encodeWord e.val ++ counterSuffix) (rowsBits (rowList table) ++ suffix) output⟩) = + some ⟨exit, (ambient, none), + MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) + (encodeWord table.rows[e].reverseIndex.val ++ + (encodeWords (relationWords table.rows[e].relation) ++ + (rowsBits ((rowList table).drop (e.val + 1)) ++ suffix))) + (encodeWord table.rows[e].tail.val ++ output)⟩ := by + have h := lookupTailTrace counter source destination labels exit P atStatement + hcs hcd hsd base ((rowList table).take e.val) table.rows[e] counterSuffix + (rowsBits ((rowList table).drop (e.val + 1)) ++ suffix) output ambient register + have hlength : ((rowList table).take e.val).length = e.val := by + simp only [List.length_take, rowList_length, Nat.min_eq_left (Nat.le_of_lt e.isLt)] + have hsplit : rowsBits (rowList table) ++ suffix = + rowsBits ((rowList table).take e.val) ++ + (rowBits table.rows[e] ++ (rowsBits ((rowList table).drop (e.val + 1)) ++ suffix)) := by + have hrow : table.rows[e.val] = table.rows[e] := rfl + simpa only [rowsBits, rowBits, rowList, Vector.getElem_toList, hrow] using + Input.rowsBits_append_split (rowList table) e.val (by simp) suffix + rw [hlength, ← hsplit] at h + exact h + +theorem fullTableTailTrace {q : Nat} + (counter source destination : K) (labels : Label → Λ) (exit : Option Λ) + (headerVertices headerDarts : Λ) + (P : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atStatement : ∀ label, P (labels label) = statement q counter source destination labels exit label) + (atVertices : P headerVertices = MachineLookup.discard source headerVertices headerDarts) + (atDarts : P headerDarts = MachineLookup.discard source headerDarts (labels .guard)) + (hcs : counter ≠ source) (hcd : counter ≠ destination) (hsd : source ≠ destination) + (base : K → List Bool) (table : Table q) (e : Fin table.darts) + (counterSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : + (advance (TM2.step P))^[lookupCost ((rowList table).take e.val) table.rows[e] + + (table.darts + 1) + (table.vertices + 1)] + (some ⟨some headerVertices, (ambient, register), + MachineLookup.tapes counter source destination base + (encodeWord e.val ++ counterSuffix) (tableBits table ++ suffix) output⟩) = + some ⟨exit, (ambient, none), + MachineLookup.tapes counter source destination base + (encodeWord 0 ++ counterSuffix) + (encodeWord table.rows[e].reverseIndex.val ++ + (encodeWords (relationWords table.rows[e].relation) ++ + (rowsBits ((rowList table).drop (e.val + 1)) ++ suffix))) + (encodeWord table.rows[e].tail.val ++ output)⟩ := by + have hv := MachineLookup.discardTrace source headerVertices headerDarts P atVertices + (MachineLookup.tapes counter source destination base + (encodeWord e.val ++ counterSuffix) (tableBits table ++ suffix) output) + table.vertices (encodeWord table.darts ++ (rowsBits (rowList table) ++ suffix)) + (by simp only [MachineLookup.tapes_source _ _ _ hsd, Input.tableBits_header, + rowsBits, List.append_assoc]) ambient register + rw [Function.iterate_add_apply, hv] + simp only [MachineLookup.update_source _ _ _ hsd] + have hd := MachineLookup.discardTrace source headerDarts (labels .guard) P atDarts + (MachineLookup.tapes counter source destination base + (encodeWord e.val ++ counterSuffix) + (encodeWord table.darts ++ (rowsBits (rowList table) ++ suffix)) output) + table.darts (rowsBits (rowList table) ++ suffix) (by simp [hsd]) ambient none + rw [Function.iterate_add_apply, hd] + simp only [MachineLookup.update_source _ _ _ hsd] + exact tableTailTrace counter source destination labels exit P atStatement hcs hcd hsd + base table e counterSuffix suffix output ambient none + +theorem lookup_frame (counter source destination other : K) + (hc : other ≠ counter) (hs : other ≠ source) (hd : other ≠ destination) + (base : K → List Bool) (counterBits input output : List Bool) : + MachineLookup.tapes counter source destination base counterBits input output other = base other := + MachineLookup.tapes_other counter source destination other hc hs hd base counterBits input output + +def tableTailCost {q : Nat} (table : Table q) (e : Fin table.darts) : Nat := + lookupCost ((rowList table).take e.val) table.rows[e] + + (table.darts + 1) + (table.vertices + 1) + +theorem tableTailCost_le {q : Nat} (table : Table q) (e : Fin table.darts) : + tableTailCost table e ≤ (tableBits table).length + 2 * (encodeWord e.val).length + 1 := by + have htake : ((rowList table).take e.val).length = e.val := by + simp only [List.length_take, rowList_length, Nat.min_eq_left (Nat.le_of_lt e.isLt)] + have hrow : table.rows[e.val] = table.rows[e] := rfl + have hsplit : rowsBits (rowList table) = rowsBits ((rowList table).take e.val) ++ + (rowBits table.rows[e] ++ rowsBits ((rowList table).drop (e.val + 1))) := by + simpa only [rowsBits, rowBits, rowList, Vector.getElem_toList, hrow] using + Input.rowsBits_split (rowList table) e.val (by simp) + have hp : (rowsBits ((rowList table).take e.val) ++ rowBits table.rows[e]).length ≤ + (rowsBits (rowList table)).length := by + rw [hsplit] + simp only [List.length_append] + omega + have hb := lookupCost_le ((rowList table).take e.val) table.rows[e] + rw [htake] at hb + have hh := congrArg List.length (Input.tableBits_header table) + change (tableBits table).length = + (encodeWord table.vertices ++ (encodeWord table.darts ++ rowsBits (rowList table))).length at hh + simp only [List.length_append, encodeWord_length] at hh + unfold tableTailCost + omega + +def headIndex {q : Nat} (table : Table q) (e : Fin table.darts) : Fin table.darts := + table.rows[e].reverseIndex + +def headValue {q : Nat} (table : Table q) (e : Fin table.darts) : Nat := + table.rows[headIndex table e].tail.val + +theorem headValue_eq_semantics {q : Nat} (table : Table q) (e : Fin table.darts) : + headValue table e = ((semantics table).head e).val := rfl + +abbrev HeadTapes (K : Type) := Fin 6 → K + +def headLookupTapes {q : Nat} (tape : HeadTapes K) (base : K → List Bool) + (table : Table q) (e : Fin table.darts) : K → List Bool := + MachineLookup.tapes (tape 3) (tape 2) (tape 4) base + (encodeWord 0 ++ base (tape 3)) + (encodeWord table.rows[headIndex table e].reverseIndex.val ++ + (encodeWords (relationWords table.rows[headIndex table e].relation) ++ + (rowsBits ((rowList table).drop ((headIndex table e).val + 1)) ++ base (tape 2)))) + (encodeWord (headValue table e)) + +def headLookupCost {q : Nat} (table : Table q) (e : Fin table.darts) : Nat := + 2 * ((tableBits table).length + 1) + + 2 * ((encodeWord (headIndex table e).val).length + 1) + tableTailCost table (headIndex table e) + +theorem headLookupCost_le {q : Nat} (table : Table q) (e : Fin table.darts) : + headLookupCost table e ≤ 7 * (tableBits table).length + 5 := by + have hi : (encodeWord (headIndex table e).val).length ≤ (tableBits table).length := by + rw [encodeWord_length] + exact (Nat.succ_le_of_lt (headIndex table e).isLt).trans (darts_le_tableBits_length table) + have hl := tableTailCost_le table (headIndex table e) + unfold headLookupCost + omega + +noncomputable def headTimePolynomial : Polynomial Nat := + Polynomial.C 7 * Polynomial.X + Polynomial.C 5 + +def headLookupInTime {q : Nat} + (tape : HeadTapes K) (hinj : Function.Injective tape) + (tableFirst tableSecond indexFirst indexSecond headerVertices headerDarts : Λ) + (labels : Label → Λ) (exit : Option Λ) + (P : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atTableFirst : P tableFirst = Reduction.MachineTransfer.loopAt + (tape 0) (tape 5) id false tableFirst (some tableSecond)) + (atTableSecond : P tableSecond = MachineCopy.forkLoop + (tape 5) (tape 0) (tape 2) false tableSecond (some indexFirst)) + (atIndexFirst : P indexFirst = Reduction.MachineTransfer.loopAt + (tape 1) (tape 5) id false indexFirst (some indexSecond)) + (atIndexSecond : P indexSecond = MachineCopy.forkLoop + (tape 5) (tape 1) (tape 3) false indexSecond (some headerVertices)) + (atVertices : P headerVertices = MachineLookup.discard (tape 2) headerVertices headerDarts) + (atDarts : P headerDarts = MachineLookup.discard (tape 2) headerDarts (labels .guard)) + (atStatement : ∀ label, + P (labels label) = statement q (tape 3) (tape 2) (tape 4) labels exit label) + (base : K → List Bool) (table : Table q) (e : Fin table.darts) + (hTable : base (tape 0) = tableBits table) + (hReverse : base (tape 1) = encodeWord (headIndex table e).val) + (hHead : base (tape 4) = []) (hScratch : base (tape 5) = []) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step P) + ⟨some tableFirst, (ambient, register), base⟩ + (some ⟨exit, (ambient, none), headLookupTapes tape base table e⟩) + (headTimePolynomial.eval (tableBits table).length) := by + have hne (i j : Fin 6) (h : i ≠ j) : tape i ≠ tape j := fun heq => h (hinj heq) + let t₁ := Function.update base (tape 2) (tableBits table ++ base (tape 2)) + let t₂ := Function.update t₁ (tape 3) (encodeWord (headIndex table e).val ++ base (tape 3)) + have run₁ : StateTransition.EvalsToInTime (TM2.step P) + ⟨some tableFirst, (ambient, register), base⟩ + (some ⟨some indexFirst, (ambient, none), t₁⟩) + (2 * ((tableBits table).length + 1)) := by + simpa only [hTable, t₁] using MachineCopy.copyInTime (tape 0) (tape 2) (tape 5) + (hne 0 2 (by decide)) (hne 0 5 (by decide)) (hne 2 5 (by decide)) false + tableFirst tableSecond (some indexFirst) P atTableFirst atTableSecond + base hScratch ambient register + have hsrc : t₁ (tape 1) = encodeWord (headIndex table e).val := by + simp only [t₁, Function.update_of_ne (hne 1 2 (by decide)), hReverse] + have hdst : t₁ (tape 3) = base (tape 3) := by + simp only [t₁, Function.update_of_ne (hne 3 2 (by decide))] + have hscratch₁ : t₁ (tape 5) = [] := by + simp only [t₁, Function.update_of_ne (hne 5 2 (by decide)), hScratch] + have run₂ : StateTransition.EvalsToInTime (TM2.step P) + ⟨some indexFirst, (ambient, none), t₁⟩ + (some ⟨some headerVertices, (ambient, none), t₂⟩) + (2 * ((encodeWord (headIndex table e).val).length + 1)) := by + simpa only [hsrc, hdst, t₂] using MachineCopy.copyInTime (tape 1) (tape 3) (tape 5) + (hne 1 3 (by decide)) (hne 1 5 (by decide)) (hne 3 5 (by decide)) false + indexFirst indexSecond (some headerVertices) P atIndexFirst atIndexSecond + t₁ hscratch₁ ambient none + have ht₂ : t₂ = MachineLookup.tapes (tape 3) (tape 2) (tape 4) base + (encodeWord (headIndex table e).val ++ base (tape 3)) + (tableBits table ++ base (tape 2)) [] := by + funext k + by_cases hi : k = tape 3 + · subst k + simp [t₂, MachineLookup.tapes, hne 3 2 (by decide), hne 3 4 (by decide)] + · by_cases hs : k = tape 2 + · subst k + simp [t₂, t₁, MachineLookup.tapes, hne 2 3 (by decide), hne 2 4 (by decide)] + · by_cases hh : k = tape 4 + · subst k + simp [t₂, t₁, MachineLookup.tapes, hne 4 3 (by decide), + hne 4 2 (by decide), hHead] + · simp [t₂, t₁, MachineLookup.tapes, hi, hs, hh] + let run₃ : StateTransition.EvalsToInTime (TM2.step P) + ⟨some headerVertices, (ambient, none), t₂⟩ + (some ⟨exit, (ambient, none), headLookupTapes tape base table e⟩) + (tableTailCost table (headIndex table e)) := { + steps := tableTailCost table (headIndex table e) + evals_in_steps := by + change (advance (TM2.step P))^[tableTailCost table (headIndex table e)] + (some ⟨some headerVertices, (ambient, none), t₂⟩) = + some ⟨exit, (ambient, none), headLookupTapes tape base table e⟩ + rw [ht₂] + simpa only [headLookupTapes, headValue, tableTailCost, List.append_nil] using + fullTableTailTrace (tape 3) (tape 2) (tape 4) labels exit + headerVertices headerDarts P atStatement atVertices atDarts + (hne 3 2 (by decide)) (hne 3 4 (by decide)) (hne 2 4 (by decide)) + base table (headIndex table e) (base (tape 3)) (base (tape 2)) [] ambient none + steps_le_m := Nat.le_refl _ } + let run₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁ run₂ + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁₂ run₃ + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have ht := run.steps_le_m + have hb := headLookupCost_le table e + simp only [headTimePolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X] + unfold headLookupCost at hb + omega + +theorem headLookupTapes_head {q : Nat} (tape : HeadTapes K) (base : K → List Bool) + (table : Table q) (e : Fin table.darts) : + headLookupTapes tape base table e (tape 4) = encodeWord (headValue table e) := by + simp [headLookupTapes] + +theorem headLookupTapes_frame {q : Nat} (tape : HeadTapes K) (base : K → List Bool) + (table : Table q) (e : Fin table.darts) (other : K) + (hc : other ≠ tape 3) (hs : other ≠ tape 2) (hh : other ≠ tape 4) : + headLookupTapes tape base table e other = base other := + lookup_frame (tape 3) (tape 2) (tape 4) other hc hs hh base _ _ _ + +def readRowTapes {q n m : Nat} (source tail reverse : K) (base : K → List Bool) + (row : DartRow q n m) (suffix : List Bool) : K → List Bool := + Function.update (Function.update (Function.update base source suffix) + tail (encodeWord row.tail.val)) reverse (encodeWord row.reverseIndex.val) + +theorem readRowTapes_source {q n m : Nat} (source tail reverse : K) + (hst : source ≠ tail) (hsr : source ≠ reverse) + (base : K → List Bool) (row : DartRow q n m) (suffix : List Bool) : + readRowTapes source tail reverse base row suffix source = suffix := by + simp [readRowTapes, hst, hsr] + +theorem readRowTapes_tail {q n m : Nat} (source tail reverse : K) + (htr : tail ≠ reverse) (base : K → List Bool) + (row : DartRow q n m) (suffix : List Bool) : + readRowTapes source tail reverse base row suffix tail = encodeWord row.tail.val := by + simp [readRowTapes, htr] + +theorem readRowTapes_reverse {q n m : Nat} (source tail reverse : K) + (base : K → List Bool) (row : DartRow q n m) (suffix : List Bool) : + readRowTapes source tail reverse base row suffix reverse = + encodeWord row.reverseIndex.val := by + simp [readRowTapes] + +theorem readRowTapes_frame {q n m : Nat} (source tail reverse other : K) + (hs : other ≠ source) (ht : other ≠ tail) (hr : other ≠ reverse) + (base : K → List Bool) (row : DartRow q n m) (suffix : List Bool) : + readRowTapes source tail reverse base row suffix other = base other := by + simp [readRowTapes, hs, ht, hr] + +def readRowCost {q n m : Nat} (row : DartRow q n m) : Nat := + row.tail.val + row.reverseIndex.val + 5 + +theorem readRowCost_le {q n m : Nat} (row : DartRow q n m) : + readRowCost row ≤ (rowBits row).length + 3 := by + rw [rowBits_eq] + simp only [List.length_append, encodeWord_length] + unfold readRowCost + omega + +theorem readRowCost_table_le {q : Nat} (table : Table q) (e : Fin table.darts) : + readRowCost table.rows[e] ≤ 2 * (tableBits table).length + 5 := by + have ht := (Nat.le_of_lt table.rows[e].tail.isLt).trans + (vertices_le_tableBits_length table) + have hr := (Nat.le_of_lt table.rows[e].reverseIndex.isLt).trans + (darts_le_tableBits_length table) + unfold readRowCost + omega + +def readRowInTime {q n m : Nat} (source tail reverse : K) + (hst : source ≠ tail) (hsr : source ≠ reverse) (htr : tail ≠ reverse) + (tailStart tailLoop reverseStart reverseLoop readLabel exitLabel : Λ) + (P : Λ → TM2.Stmt (Alphabet (K := K)) Λ (ReadRelation.State σ q)) + (atTailStart : P tailStart = Hastad.SourceMachine.fieldStart tail tailLoop) + (atTailLoop : P tailLoop = + Hastad.SourceMachine.fieldLoop source tail tailLoop (some reverseStart)) + (atReverseStart : P reverseStart = Hastad.SourceMachine.fieldStart reverse reverseLoop) + (atReverseLoop : P reverseLoop = + Hastad.SourceMachine.fieldLoop source reverse reverseLoop (some readLabel)) + (atRead : P readLabel = ReadRelation.parser source exitLabel) + (base : K → List Bool) (row : DartRow q n m) (suffix : List Bool) + (hinput : base source = rowBits row ++ suffix) + (hTail : base tail = []) (hReverse : base reverse = []) + (ambient : σ) (initial : RelationTable q) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step P) + ⟨some tailStart, ((ambient, initial), register), base⟩ + (some ⟨some exitLabel, ((ambient, row.relation), none), + readRowTapes source tail reverse base row suffix⟩) + (readRowCost row) := by + let relationInput := encodeWords (relationWords row.relation) ++ suffix + let reverseInput := encodeWord row.reverseIndex.val ++ relationInput + let t₁ := Hastad.SourceMachine.fieldTapes source tail base reverseInput + (encodeWord row.tail.val) + let t₂ := Hastad.SourceMachine.fieldTapes source reverse t₁ relationInput + (encodeWord row.reverseIndex.val) + have hinput₁ : base source = encodeWord row.tail.val ++ reverseInput := by + simpa only [rowBits_eq, List.append_assoc, reverseInput, relationInput] using hinput + have run₁ : StateTransition.EvalsToInTime (TM2.step P) + ⟨some tailStart, ((ambient, initial), register), base⟩ + (some ⟨some reverseStart, ((ambient, initial), none), t₁⟩) + (row.tail.val + 2) := by + simpa only [hTail, List.append_nil, t₁] using + Hastad.SourceMachine.fieldInTime source tail hst tailStart tailLoop + (some reverseStart) P atTailStart atTailLoop base row.tail.val reverseInput + hinput₁ (ambient, initial) register + have hinput₂ : t₁ source = encodeWord row.reverseIndex.val ++ relationInput := by + simp only [t₁, Hastad.SourceMachine.fieldTapes_source source tail hst, reverseInput] + have hreverse₁ : t₁ reverse = [] := by + simp [t₁, Hastad.SourceMachine.fieldTapes, Ne.symm hsr, Ne.symm htr, hReverse] + have run₂ : StateTransition.EvalsToInTime (TM2.step P) + ⟨some reverseStart, ((ambient, initial), none), t₁⟩ + (some ⟨some readLabel, ((ambient, initial), none), t₂⟩) + (row.reverseIndex.val + 2) := by + simpa only [hreverse₁, List.append_nil, t₂] using + Hastad.SourceMachine.fieldInTime source reverse hsr reverseStart reverseLoop + (some readLabel) P atReverseStart atReverseLoop t₁ row.reverseIndex.val relationInput + hinput₂ (ambient, initial) none + have hinput₃ : t₂ source = encodeWords (relationWords row.relation) ++ suffix := by + simp only [t₂, Hastad.SourceMachine.fieldTapes_source source reverse hsr, relationInput] + have hrestore : Function.update t₂ source + (encodeWords (relationWords row.relation) ++ suffix) = t₂ := by + rw [← hinput₃] + exact Function.update_eq_self source t₂ + have hfinal : Function.update t₂ source suffix = + readRowTapes source tail reverse base row suffix := by + funext k + by_cases hs : k = source + · subst k + simp [readRowTapes, hst, hsr] + · by_cases ht : k = tail + · subst k + simp [t₂, t₁, Hastad.SourceMachine.fieldTapes, readRowTapes, hs, htr] + · by_cases hr : k = reverse + · subst k + simp [t₂, Hastad.SourceMachine.fieldTapes, readRowTapes, hs] + · simp [t₂, t₁, Hastad.SourceMachine.fieldTapes, readRowTapes, hs, ht, hr] + have run₃ : StateTransition.EvalsToInTime (TM2.step P) + ⟨some readLabel, ((ambient, initial), none), t₂⟩ + (some ⟨some exitLabel, ((ambient, row.relation), none), + readRowTapes source tail reverse base row suffix⟩) 1 := { + steps := 1 + evals_in_steps := by + change (advance (TM2.step P))^[1] _ = _ + simpa only [hrestore, hfinal] using ReadRelation.parserTrace source readLabel exitLabel + P atRead t₂ row.relation suffix ambient initial none + steps_le_m := Nat.le_refl _ } + let run₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁ run₂ + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁₂ run₃ + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have ht := run.steps_le_m + unfold readRowCost + omega + +def machine (q : Nat) : FinTM2 where + K := Fin 3 + k₀ := 1 + k₁ := 2 + Γ _ := Bool + Λ := Label + main := .guard + σ := Unit × Option Bool + initialState := ((), none) + m := program q 0 1 2 + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Lookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/AmplificationIteration.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/AmplificationIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..083ac7414cece32f844e5319d54866b35a34b2ed --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/AmplificationIteration.lean @@ -0,0 +1,90 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AmplificationIteration + +def run {X : Type*} (step : X → X) : Nat → X → X + | 0, x => x + | n + 1, x => step (run step n x) + +private theorem min_double_min (u cap : ℝ) (hc : 0 ≤ cap) : + min (2 * min u cap) cap = min (2 * u) cap := by + by_cases hu : u ≤ cap + · rw [min_eq_left hu] + · have hcu : cap ≤ u := le_of_not_ge hu + rw [min_eq_right hcu, min_eq_right (by linarith : cap ≤ 2 * cap), + min_eq_right (by linarith : cap ≤ 2 * u)] + +theorem run_gap {X : Type*} (step : X → X) (gap : X → ℝ) + (cap : ℝ) (hc : 0 ≤ cap) + (amplifies : ∀ x, min (2 * gap x) cap ≤ gap (step x)) + (n : Nat) (x : X) : + min (2 ^ n * gap x) cap ≤ gap (run step n x) := by + induction n with + | zero => simp [run] + | succ n ih => + have hm : min (2 * min (2 ^ n * gap x) cap) cap ≤ + min (2 * gap (run step n x)) cap := + min_le_min (mul_le_mul_of_nonneg_left ih (by norm_num)) le_rfl + rw [min_double_min _ _ hc] at hm + have h := hm.trans (amplifies (run step n x)) + simpa [run, pow_succ, mul_assoc, mul_left_comm, mul_comm] using h + +theorem run_preserves {X : Type*} (step : X → X) (P : X → Prop) + (preserves : ∀ x, P x → P (step x)) (n : Nat) (x : X) (hx : P x) : + P (run step n x) := by + induction n with + | zero => exact hx + | succ n ih => exact preserves _ ih + +theorem run_size {X : Type*} (step : X → X) (size : X → Nat) (C : Nat) + (blowup : ∀ x, size (step x) ≤ C * size x) (n : Nat) (x : X) : + size (run step n x) ≤ C ^ n * size x := by + induction n with + | zero => simp [run] + | succ n ih => + have h := (blowup (run step n x)).trans (Nat.mul_le_mul_left C ih) + simpa [run, pow_succ, Nat.mul_assoc, Nat.mul_left_comm, Nat.mul_comm] using h + +def rounds (n : Nat) : Nat := Nat.log2 n + 1 + +theorem rounds_large (n : Nat) : n < 2 ^ rounds n := by + simpa [rounds, Nat.log2_eq_log_two] using + (Nat.lt_pow_succ_log_self (by decide : 1 < 2) n) + +theorem rounds_power_le {n : Nat} (hn : 0 < n) : 2 ^ rounds n ≤ 2 * n := by + have h := Nat.pow_log_le_self 2 (Nat.ne_of_gt hn) + simpa [rounds, Nat.log2_eq_log_two, pow_succ, Nat.mul_comm] using + (Nat.mul_le_mul_right 2 h) + +theorem blowup_rounds_le {C degree n : Nat} (hn : 0 < n) (hC : C ≤ 2 ^ degree) : + C ^ rounds n ≤ (2 * n) ^ degree := by + calc + C ^ rounds n ≤ (2 ^ degree) ^ rounds n := Nat.pow_le_pow_left hC _ + _ = (2 ^ rounds n) ^ degree := by + rw [← pow_mul, ← pow_mul, Nat.mul_comm degree (rounds n)] + _ ≤ (2 * n) ^ degree := Nat.pow_le_pow_left (rounds_power_le hn) _ + +theorem run_size_polynomial {X : Type*} (step : X → X) (size : X → Nat) + {C degree n : Nat} (hn : 0 < n) (hC : C ≤ 2 ^ degree) + (blowup : ∀ x, size (step x) ≤ C * size x) (x : X) : + size (run step (rounds n) x) ≤ (2 * n) ^ degree * size x := + (run_size step size C blowup (rounds n) x).trans + (Nat.mul_le_mul_right _ (blowup_rounds_le hn hC)) + +theorem run_reaches_cap {X : Type*} (step : X → X) (gap : X → ℝ) + (cap : ℝ) (hc : 0 ≤ cap) (hc1 : cap ≤ 1) + (amplifies : ∀ x, min (2 * gap x) cap ≤ gap (step x)) + (n : Nat) (x : X) (hg : 0 ≤ gap x) (hstart : 1 ≤ (n : ℝ) * gap x) : + cap ≤ gap (run step (rounds n) x) := by + have hp : (n : ℝ) ≤ (2 : ℝ) ^ rounds n := by + exact_mod_cast (Nat.le_of_lt (rounds_large n)) + have hcap : cap ≤ (2 : ℝ) ^ rounds n * gap x := + hc1.trans (hstart.trans (mul_le_mul_of_nonneg_right hp hg)) + have h := run_gap step gap cap hc amplifies (rounds n) x + rwa [min_eq_right hcap] at h + +end IndependentSetsGames.Foundations.PCP.AmplificationIteration + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/AmplificationRound.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/AmplificationRound.lean new file mode 100644 index 0000000000000000000000000000000000000000..839671f423b630d1bb900ae7744274b2abb74b2b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/AmplificationRound.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Gap + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.AmplificationRound + +abbrev Label := QueryIncidence.Label 6 +abbrev Addresses := PoweringLabels.PortWords Preprocessing.Port FinalConstants.walkLength +abbrev PoweredAlphabet := + PoweringLabels.PaddedLabel Preprocessing.Port FinalConstants.walkLength Label + +instance : Fintype PoweredAlphabet := Fintype.ofFinite _ +instance : DecidableEq PoweredAlphabet := Classical.decEq _ + +variable {V E : Type*} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] + [Nonempty E] + +abbrev PoweredDart (G : ConstraintGraph V E Label) := + PoweringTest.Dart (Preprocessing.Vertex G) Preprocessing.Port + (2 * FinalConstants.endpointLength) + +instance (G : ConstraintGraph V E Label) : DecidableEq (PoweredDart G) := Classical.decEq _ + +def selectors (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (G : ConstraintGraph V E Label) (v : Preprocessing.Vertex G) : + PoweringLabels.AddressSelector (Preprocessing.portGraph G) + FinalConstants.walkLength v := + PoweringLabels.listSelector (Preprocessing.portGraph G) FinalConstants.walkLength + v addresses complete + +def powered (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (G : ConstraintGraph V E Label) : + ConstraintGraph (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet := + PoweringTest.poweredGraph (Preprocessing.portGraph G) (Preprocessing.graph G).accepts + (2 * FinalConstants.endpointLength) (selectors addresses complete G) + +abbrev Vertex (G : ConstraintGraph V E Label) := + QueryIncidence.Vertex + (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet) + (AlphabetGraph.Address (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet) + +abbrev Dart (G : ConstraintGraph V E Label) := + QueryIncidence.Dart (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet) 6 + +instance (G : ConstraintGraph V E Label) : Fintype (Vertex G) := by + letI : Fintype (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet) := inferInstance + letI : Fintype + (AlphabetGraph.Address (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet) := + inferInstance + change Fintype + (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet ⊕ + AlphabetGraph.Address (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet) + infer_instance +instance (G : ConstraintGraph V E Label) : Fintype (Dart G) := by + change Fintype ((AlphabetGraph.Event (PoweredDart G) PoweredAlphabet × Fin 6) × Bool) + infer_instance +instance (G : ConstraintGraph V E Label) : DecidableEq (Vertex G) := Classical.decEq _ + +def graph (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (G : ConstraintGraph V E Label) : ConstraintGraph (Vertex G) (Dart G) Label := + AlphabetGraph.graph (powered addresses complete G) + +omit [Nonempty E] in +theorem powered_completeness (addresses : List Addresses) + (complete : ∀ w, w ∈ addresses) (G : ConstraintGraph V E Label) + (satisfied : G.Satisfiable) : (powered addresses complete G).Satisfiable := by + obtain ⟨assignment, hassignment⟩ := Preprocessing.completeness G satisfied + refine ⟨PoweringOpinions.honestLabels (Preprocessing.portGraph G) + FinalConstants.walkLength assignment, ?_⟩ + apply PoweringTest.perfect_completeness (Preprocessing.portGraph G) + (Preprocessing.graph G).accepts (2 * FinalConstants.endpointLength) + (selectors addresses complete G) assignment + intro e + exact hassignment e + +omit [Nonempty E] in +theorem completeness (addresses : List Addresses) + (complete : ∀ w, w ∈ addresses) (G : ConstraintGraph V E Label) + (satisfied : G.Satisfiable) : (graph addresses complete G).Satisfiable := + AlphabetGraph.perfect_completeness _ + (powered_completeness addresses complete G satisfied) + +end IndependentSetsGames.Foundations.PCP.AmplificationRound +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/AssignmentTester.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/AssignmentTester.lean new file mode 100644 index 0000000000000000000000000000000000000000..60ae5b00bd95926c657b0f17fd7d743373bb208a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/AssignmentTester.lean @@ -0,0 +1,571 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Decoder + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.AssignmentTester + +open IndependentSetsGames.Foundations.Hastad +open scoped BigOperators +open Finset + +variable {A : Type*} [Fintype A] [DecidableEq A] + +def truth (b : Bool) : ℝ := if b then 1 else 0 + +def disagree (a b : Bool) : ℝ := if a = b then 0 else 1 + +theorem truth_nonneg (b : Bool) : 0 ≤ truth b := by cases b <;> norm_num [truth] + +theorem disagree_nonneg (a b : Bool) : 0 ≤ disagree a b := by + cases a <;> cases b <;> norm_num [disagree] + +theorem disagree_eq (a b : Bool) : + disagree a b = (1 - bitSign a * bitSign b) / 2 := by + cases a <;> cases b <;> norm_num [disagree, bitSign] + +theorem disagree_xor_le (a b c d : Bool) : + disagree (a ^^ b) (c ^^ d) ≤ disagree a c + disagree b d := by + cases a <;> cases b <;> cases c <;> cases d <;> norm_num [disagree] + +def parity (s f : Cube A) : Bool := + decide (Odd ((Finset.univ.filter fun a => s a && f a = true).card)) + +theorem bitSign_parity (s f : Cube A) : bitSign (parity s f) = walsh s f := by + have hw : walsh s f = (-1 : ℝ) ^ + (Finset.univ.filter fun a => s a && f a = true).card := by + simp [walsh, bitSign, Finset.prod_ite] + rw [hw] + simpa [parity, bitSign] using + (sign_power_parity true (Finset.univ.filter fun a => s a && f a = true).card).symm + +theorem bitSign_injective : Function.Injective bitSign := by + intro a b h + cases a <;> cases b <;> simp_all [bitSign] <;> linarith + +theorem parity_xor (s f g : Cube A) : + parity s (cubeXor f g) = (parity s f ^^ parity s g) := by + apply bitSign_injective + rw [bitSign_parity, bitSign_xor, bitSign_parity, bitSign_parity, walsh_xor] + +omit [Fintype A] [DecidableEq A] in +theorem cubeXor_comm (f g : Cube A) : cubeXor f g = cubeXor g f := by + funext a + simp [cubeXor, Bool.xor_comm] + +omit [Fintype A] [DecidableEq A] in +@[simp] theorem cubeXor_right_twice (f g : Cube A) : + cubeXor (cubeXor f g) g = f := by + funext a + change ((f a ^^ g a) ^^ g a) = f a + cases f a <;> cases g a <;> rfl + +theorem expect_cubeXor (F : Cube A → ℝ) (g : Cube A) : + (𝔼 f, F (cubeXor f g)) = 𝔼 f, F f := by + rw [Fintype.expect_eq_sum_div_card, Fintype.expect_eq_sum_div_card] + congr 1 + refine Finset.sum_bij (fun f _ => cubeXor f g) ?_ ?_ ?_ ?_ + · intro f _ + exact Finset.mem_univ _ + · intro f _ h _ heq + have hh := congrArg (fun x => cubeXor x g) heq + simpa only [cubeXor_right_twice] using hh + · intro f _ + exact ⟨cubeXor f g, Finset.mem_univ _, cubeXor_right_twice f g⟩ + · intro f _ + rfl + +def distance {K : Type*} [Fintype K] (f g : K → Bool) : ℝ := + 𝔼 k, disagree (f k) (g k) + +theorem distance_nonneg {K : Type*} [Fintype K] (f g : K → Bool) : + 0 ≤ distance f g := by + apply Finset.expect_nonneg + intro k _ + exact disagree_nonneg _ _ + +theorem distance_parity (F : Cube A → Bool) (s : Cube A) : + distance F (parity s) = (1 - coefficient (fun f => bitSign (F f)) s) / 2 := by + unfold distance + simp_rw [disagree_eq, bitSign_parity, div_eq_mul_inv, + ← Finset.expect_mul, Finset.expect_sub_distrib] + simp only [Fintype.expect_const] + rfl + +def blrReject (F : Cube A → Bool) : ℝ := + 𝔼 f, 𝔼 g, disagree (F f ^^ F g) (F (cubeXor f g)) + +theorem blrReject_nonneg (F : Cube A → Bool) : 0 ≤ blrReject F := by + apply Finset.expect_nonneg + intro f _ + apply Finset.expect_nonneg + intro g _ + exact disagree_nonneg _ _ + +theorem blr_correlation (F : Cube A → Bool) : + (𝔼 f, 𝔼 g, bitSign (F f) * bitSign (F g) * bitSign (F (cubeXor f g))) = + ∑ s, coefficient (fun f => bitSign (F f)) s ^ 3 := by + simp_rw [mul_assoc, ← Finset.mul_expect] + conv_lhs => + enter [2, f, 2, 2, g, 2, 1] + rw [cubeXor_comm] + simp_rw [walsh_autocorrelation, Finset.mul_sum] + rw [Finset.expect_sum_comm] + apply Finset.sum_congr rfl + intro s _ + have heq (f : Cube A) : bitSign (F f) * + (coefficient (fun f => bitSign (F f)) s ^ 2 * walsh s f) = + coefficient (fun f => bitSign (F f)) s ^ 2 * (bitSign (F f) * walsh s f) := by ring + simp_rw [heq, ← Finset.mul_expect] + change coefficient (fun f => bitSign (F f)) s ^ 2 * + coefficient (fun f => bitSign (F f)) s = _ + ring + +theorem blrReject_fourier (F : Cube A → Bool) : + blrReject F = (1 - ∑ s, coefficient (fun f => bitSign (F f)) s ^ 3) / 2 := by + unfold blrReject + simp_rw [disagree_eq, bitSign_xor, div_eq_mul_inv, + ← Finset.expect_mul, Finset.expect_sub_distrib] + simp only [Fintype.expect_const] + rw [blr_correlation] + +theorem blr_near_parity (F : Cube A → Bool) : + ∃ s : Cube A, distance F (parity s) ≤ blrReject F := by + classical + let c := coefficient (fun f => bitSign (F f)) + have hmass : (∑ s, c s ^ 2) = 1 := sign_parseval F + have hlarge : ∃ s, (∑ t, c t ^ 3) ≤ c s := by + by_contra hn + push Not at hn + have hpos : ∃ s, 0 < c s ^ 2 := by + by_contra hh + push Not at hh + have hz := Finset.sum_nonpos (s := Finset.univ) (fun s _ => hh s) + linarith + obtain ⟨s₀, hs₀⟩ := hpos + have hle (s : Cube A) (_ : s ∈ Finset.univ) : + c s ^ 3 ≤ (∑ t, c t ^ 3) * c s ^ 2 := by + have h := mul_le_mul_of_nonneg_right (hn s).le (sq_nonneg (c s)) + nlinarith + have hlt : c s₀ ^ 3 < (∑ t, c t ^ 3) * c s₀ ^ 2 := by + have h := mul_lt_mul_of_pos_right (hn s₀) hs₀ + nlinarith + have hsum := Finset.sum_lt_sum hle ⟨s₀, Finset.mem_univ _, hlt⟩ + rw [← Finset.mul_sum, hmass, mul_one] at hsum + exact (lt_irrefl _ hsum) + obtain ⟨s, hs⟩ := hlarge + refine ⟨s, ?_⟩ + rw [distance_parity, blrReject_fourier] + dsimp [c] at hs + linarith + +def selfCorrect (F : Cube A → Bool) (x r : Cube A) : Bool := + F r ^^ F (cubeXor r x) + +theorem parity_selfCorrect (s x r : Cube A) : + (parity s r ^^ parity s (cubeXor r x)) = parity s x := by + rw [parity_xor] + cases parity s r <;> cases parity s x <;> rfl + +theorem selfCorrect_error (F : Cube A → Bool) (s x : Cube A) : + (𝔼 r, disagree (selfCorrect F x r) (parity s x)) ≤ 2 * distance F (parity s) := by + have hle (r : Cube A) : + disagree (selfCorrect F x r) (parity s x) ≤ + disagree (F r) (parity s r) + + disagree (F (cubeXor r x)) (parity s (cubeXor r x)) := by + rw [← parity_selfCorrect s x r] + exact disagree_xor_le _ _ _ _ + have h := Finset.expect_le_expect (s := Finset.univ) (fun r _ => hle r) + rw [Finset.expect_add_distrib, + expect_cubeXor (fun r => disagree (F r) (parity s r)) x] at h + change _ ≤ distance F (parity s) + distance F (parity s) at h + linarith + +def singleMask (i : A) : Cube A := fun j => decide (j = i) + +def flipAt (i : A) (f : Cube A) : Cube A := + fun j => if j = i then !(f j) else f j + +omit [Fintype A] in +@[simp] theorem flipAt_twice (i : A) (f : Cube A) : flipAt i (flipAt i f) = f := by + funext j + by_cases h : j = i <;> simp [flipAt, h] + +omit [Fintype A] in +theorem flipAt_eq_xor (i : A) (f : Cube A) : flipAt i f = cubeXor f (singleMask i) := by + funext j + by_cases h : j = i <;> simp [flipAt, cubeXor, singleMask, h] + +theorem expect_flipAt (F : Cube A → ℝ) (i : A) : + (𝔼 f, F (flipAt i f)) = 𝔼 f, F f := by + simp_rw [flipAt_eq_xor] + exact expect_cubeXor F _ + +theorem walsh_singleMask (s : Cube A) (i : A) : + walsh s (singleMask i) = bitSign (s i) := by + unfold walsh + rw [Finset.prod_eq_single i] + · simp [singleMask] + · intro j _ hj + simp [singleMask, hj, bitSign] + · intro h + exact False.elim (h (Finset.mem_univ _)) + +theorem parity_singleMask (s : Cube A) (i : A) : parity s (singleMask i) = s i := by + apply bitSign_injective + rw [bitSign_parity, walsh_singleMask] + +theorem parity_flipAt (s : Cube A) (i : A) (f : Cube A) (hs : s i = true) : + parity s (flipAt i f) = !(parity s f) := by + rw [flipAt_eq_xor, parity_xor, parity_singleMask, hs] + cases parity s f <;> rfl + +def cubeAnd (f g : Cube A) : Cube A := fun a => f a && g a + +def andLawFailure (s f g : Cube A) : Bool := + parity s (cubeAnd f g) ^^ (parity s f && parity s g) + +theorem andLawFailure_flipAt_second (s : Cube A) (i : A) (f g : Cube A) + (hi : s i = true) : + andLawFailure s f (flipAt i g) = + (andLawFailure s f g ^^ (parity s f ^^ f i)) := by + have hAnd : cubeAnd f (flipAt i g) = + (if f i then flipAt i (cubeAnd f g) else cubeAnd f g) := by + funext a + by_cases ha : a = i + · subst a + cases hfi : f i <;> simp [cubeAnd, flipAt, hfi] + · cases hfi : f i <;> simp [cubeAnd, flipAt, ha] + have hg := parity_flipAt s i g hi + have hfg := parity_flipAt s i (cubeAnd f g) hi + cases hfi : f i <;> cases hf : parity s f <;> + cases hg₀ : parity s g <;> cases ha : parity s (cubeAnd f g) <;> + simp [andLawFailure, hAnd, hg, hfg, hfi, hf, hg₀, ha] + +private theorem four_truth_lower (e₀ e₁ d : Bool) : + (1 : ℝ) ≤ truth e₀ + truth (e₀ ^^ d) + truth e₁ + truth (e₁ ^^ (!d)) := by + cases e₀ <;> cases e₁ <;> cases d <;> norm_num [truth] + +theorem parity_and_rejection (s : Cube A) (i j : A) + (hi : s i = true) (hj : s j = true) (hij : i ≠ j) : + (1 : ℝ) / 4 ≤ 𝔼 f, 𝔼 g, truth (andLawFailure s f g) := by + have hpoint (f g : Cube A) : (1 : ℝ) ≤ + truth (andLawFailure s f g) + truth (andLawFailure s f (flipAt i g)) + + truth (andLawFailure s (flipAt j f) g) + + truth (andLawFailure s (flipAt j f) (flipAt i g)) := by + rw [andLawFailure_flipAt_second s i f g hi, + andLawFailure_flipAt_second s i (flipAt j f) g hi] + have hD : (parity s (flipAt j f) ^^ (flipAt j f) i) = + !(parity s f ^^ f i) := by + rw [parity_flipAt s j f hj] + simp only [flipAt, ite_eq_right hij] + cases hf : parity s f <;> cases hfi : f i <;> simp + rw [hD] + exact four_truth_lower _ _ _ + have havg := Finset.expect_le_expect (s := Finset.univ) (fun f _ => + Finset.expect_le_expect (s := Finset.univ) (fun g _ => hpoint f g)) + simp only [Finset.expect_add_distrib, Fintype.expect_const] at havg + have hinner (f : Cube A) : + (𝔼 g, truth (andLawFailure s f (flipAt i g))) = + 𝔼 g, truth (andLawFailure s f g) := + expect_flipAt (fun g => truth (andLawFailure s f g)) i + have houter : (𝔼 f, 𝔼 g, truth (andLawFailure s (flipAt j f) g)) = + 𝔼 f, 𝔼 g, truth (andLawFailure s f g) := + expect_flipAt (fun f => 𝔼 g, truth (andLawFailure s f g)) j + simp only [hinner, houter] at havg + linarith + +theorem truth_xor (a b : Bool) : truth (a ^^ b) = disagree a b := by + cases a <;> cases b <;> norm_num [truth, disagree] + +theorem disagree_triangle (a b c : Bool) : + disagree a c ≤ disagree a b + disagree b c := by + cases a <;> cases b <;> cases c <;> norm_num [disagree] + +theorem and_disagree_transfer (p₀ p₁ p₂ q₀ q₁ q₂ : Bool) : + disagree p₀ (p₁ && p₂) ≤ disagree q₀ (q₁ && q₂) + + disagree q₀ p₀ + disagree q₁ p₁ + disagree q₂ p₂ := by + cases p₀ <;> cases p₁ <;> cases p₂ <;> + cases q₀ <;> cases q₁ <;> cases q₂ <;> norm_num [disagree] + +def andReject (F : Cube A → Bool) : ℝ := + 𝔼 f, 𝔼 g, 𝔼 r₀, 𝔼 r₁, 𝔼 r₂, + disagree (selfCorrect F (cubeAnd f g) r₀) + (selfCorrect F f r₁ && selfCorrect F g r₂) + +def unitReject (F : Cube A → Bool) : ℝ := + 𝔼 r, disagree (selfCorrect F (fun _ => true) r) true + +variable {K : Type*} [Fintype K] [Nonempty K] + +def inputReject (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) : ℝ := + 𝔼 k, 𝔼 r, disagree (σ k) (selfCorrect F (fun a => label a k) r) + +def testerReject (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) : ℝ := + (blrReject F + andReject F + unitReject F + inputReject label σ F) / 4 + +theorem andReject_nonneg (F : Cube A → Bool) : 0 ≤ andReject F := by + apply Finset.expect_nonneg + intro f _ + apply Finset.expect_nonneg + intro g _ + apply Finset.expect_nonneg + intro r₀ _ + apply Finset.expect_nonneg + intro r₁ _ + apply Finset.expect_nonneg + intro r₂ _ + exact disagree_nonneg _ _ + +theorem unitReject_nonneg (F : Cube A → Bool) : 0 ≤ unitReject F := by + apply Finset.expect_nonneg + intro r _ + exact disagree_nonneg _ _ + +omit [Nonempty K] in +theorem inputReject_nonneg (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) : + 0 ≤ inputReject label σ F := by + apply Finset.expect_nonneg + intro k _ + apply Finset.expect_nonneg + intro r _ + exact disagree_nonneg _ _ + +theorem andReject_transfer (F : Cube A → Bool) (s : Cube A) : + (𝔼 f, 𝔼 g, truth (andLawFailure s f g)) ≤ + andReject F + 6 * distance F (parity s) := by + have hlocal (f g : Cube A) : truth (andLawFailure s f g) ≤ + (𝔼 r₀, 𝔼 r₁, 𝔼 r₂, + disagree (selfCorrect F (cubeAnd f g) r₀) + (selfCorrect F f r₁ && selfCorrect F g r₂)) + + 6 * distance F (parity s) := by + have hp (r₀ r₁ r₂ : Cube A) := and_disagree_transfer + (parity s (cubeAnd f g)) (parity s f) (parity s g) + (selfCorrect F (cubeAnd f g) r₀) (selfCorrect F f r₁) (selfCorrect F g r₂) + have havg := Finset.expect_le_expect (s := Finset.univ) (fun r₀ _ => + Finset.expect_le_expect (s := Finset.univ) (fun r₁ _ => + Finset.expect_le_expect (s := Finset.univ) (fun r₂ _ => hp r₀ r₁ r₂))) + simp only [Finset.expect_add_distrib, Fintype.expect_const] at havg + have h₀ := selfCorrect_error F s (cubeAnd f g) + have h₁ := selfCorrect_error F s f + have h₂ := selfCorrect_error F s g + rw [andLawFailure, truth_xor] + linarith + have h := Finset.expect_le_expect (s := Finset.univ) (fun f _ => + Finset.expect_le_expect (s := Finset.univ) (fun g _ => hlocal f g)) + simpa only [Finset.expect_add_distrib, Fintype.expect_const, andReject] using h + +theorem parity_zero (f : Cube A) : parity (fun _ => false) f = false := by + apply bitSign_injective + rw [bitSign_parity] + simp [walsh, bitSign] + +theorem unitReject_zero_parity (F : Cube A → Bool) : + 1 - 2 * distance F (parity (fun _ => false)) ≤ unitReject F := by + have herr := selfCorrect_error F (fun _ => false) (fun _ => true) + simp only [parity_zero] at herr + have heq : unitReject F + + (𝔼 r, disagree (selfCorrect F (fun _ => true) r) false) = 1 := by + unfold unitReject + rw [← Finset.expect_add_distrib] + have hp (b : Bool) : disagree b true + disagree b false = 1 := by + cases b <;> norm_num [disagree] + simp only [hp, Fintype.expect_const] + linarith + +theorem parity_singleMask_eval (a : A) (f : Cube A) : + parity (singleMask a) f = f a := by + apply bitSign_injective + rw [bitSign_parity, walsh_symm, walsh_singleMask] + +theorem inputReject_transfer (label : A → K → Bool) (σ : K → Bool) + (F : Cube A → Bool) (a : A) : + distance σ (label a) ≤ inputReject label σ F + + 2 * distance F (parity (singleMask a)) := by + have hlocal (k : K) : disagree (σ k) (label a k) ≤ + (𝔼 r, disagree (σ k) (selfCorrect F (fun a => label a k) r)) + + 2 * distance F (parity (singleMask a)) := by + have hp (r : Cube A) := disagree_triangle (σ k) + (selfCorrect F (fun a => label a k) r) (label a k) + have havg := Finset.expect_le_expect (s := Finset.univ) (fun r _ => hp r) + simp only [Fintype.expect_const, Finset.expect_add_distrib] at havg + have herr := selfCorrect_error F (singleMask a) (fun a => label a k) + simp only [parity_singleMask_eval] at herr + linarith + have h := Finset.expect_le_expect (s := Finset.univ) (fun k _ => hlocal k) + simpa only [Finset.expect_add_distrib, Fintype.expect_const, inputReject, distance] using h + +theorem tester_proximity_soundness (label : A → K → Bool) (σ : K → Bool) + (F : Cube A → Bool) {δ : ℝ} (hδ : 0 < δ) (hδ' : δ ≤ 1 / 4) + (hfar : ∀ a, δ ≤ distance σ (label a)) : + δ / 256 ≤ testerReject label σ F := by + have hblr := blrReject_nonneg F + have hand := andReject_nonneg F + have hunit := unitReject_nonneg F + have hin := inputReject_nonneg label σ F + by_cases hb : δ / 64 ≤ blrReject F + · unfold testerReject + linarith + obtain ⟨s, hs⟩ := blr_near_parity F + by_cases hz : s = fun _ => false + · subst s + have hu := unitReject_zero_parity F + unfold testerReject + linarith + have hsome : ∃ i, s i = true := by + by_contra hh + push Not at hh + apply hz + funext i + have h := hh i + cases hi : s i <;> simp_all + obtain ⟨i, hi⟩ := hsome + by_cases htwo : ∃ j, i ≠ j ∧ s j = true + · obtain ⟨j, hij, hj⟩ := htwo + have ha := parity_and_rejection s i j hi hj hij + have ht := andReject_transfer F s + unfold testerReject + linarith + · have heq : s = singleMask i := by + funext j + by_cases hji : j = i + · subst j + simp [singleMask, hi] + · have hj : s j = false := by + cases hv : s j + · rfl + · exact False.elim (htwo ⟨j, Ne.symm hji, hv⟩) + simp [singleMask, hji, hj] + subst s + have ht := inputReject_transfer label σ F i + have hf := hfar i + unfold testerReject + linarith + +omit [Fintype A] [DecidableEq A] in +theorem selfCorrect_dictator (a : A) (x r : Cube A) : + selfCorrect (fun f => f a) x r = x a := by + change (r a ^^ (r a ^^ x a)) = x a + cases r a <;> cases x a <;> rfl + +omit [Nonempty K] in +theorem tester_perfect_completeness (label : A → K → Bool) (a : A) : + testerReject label (label a) (fun f => f a) = 0 := by + have hb : blrReject (fun f : Cube A => f a) = 0 := by + simp [blrReject, cubeXor, disagree] + have ha : andReject (fun f : Cube A => f a) = 0 := by + simp [andReject, selfCorrect_dictator, cubeAnd, disagree] + have hu : unitReject (fun f : Cube A => f a) = 0 := by + simp [unitReject, selfCorrect_dictator, disagree] + have hi : inputReject label (label a) (fun f => f a) = 0 := by + simp [inputReject, selfCorrect_dictator, disagree] + simp [testerReject, hb, ha, hu, hi] + +def eventQueries (label : A → K → Bool) (kind : Fin 4) (k : K) + (f g r₀ r₁ r₂ : Cube A) (slot : Fin 6) : K ⊕ Cube A := + if kind = 0 then + if slot = 0 then .inr f else if slot = 1 then .inr g else .inr (cubeXor f g) + else if kind = 1 then + if slot = 0 then .inr r₀ else + if slot = 1 then .inr (cubeXor r₀ (cubeAnd f g)) else + if slot = 2 then .inr r₁ else + if slot = 3 then .inr (cubeXor r₁ f) else + if slot = 4 then .inr r₂ else .inr (cubeXor r₂ g) + else if kind = 2 then + if slot = 0 then .inr r₀ else .inr (cubeXor r₀ (fun _ => true)) + else + if slot = 0 then .inl k else + if slot = 1 then .inr r₀ else .inr (cubeXor r₀ (fun a => label a k)) + +def eventAccepts (kind : Fin 4) (b : Fin 6 → Bool) : Bool := + if kind = 0 then decide ((b 0 ^^ b 1) = b 2) + else if kind = 1 then decide ((b 0 ^^ b 1) = ((b 2 ^^ b 3) && (b 4 ^^ b 5))) + else if kind = 2 then (b 0 ^^ b 1) + else decide (b 0 = (b 1 ^^ b 2)) + +def oracleAnswer (σ : K → Bool) (F : Cube A → Bool) : K ⊕ Cube A → Bool := + Sum.elim σ F + +def eventReject (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) + (kind : Fin 4) (k : K) (f g r₀ r₁ r₂ : Cube A) : ℝ := + truth (!(eventAccepts kind (fun slot => + oracleAnswer σ F (eventQueries label kind k f g r₀ r₁ r₂ slot)))) + +theorem truth_not_decide_eq (a b : Bool) : truth (!(decide (a = b))) = disagree a b := by + cases a <;> cases b <;> norm_num [truth, disagree] + +omit [Fintype A] [DecidableEq A] [Fintype K] [Nonempty K] in +theorem eventReject_blr (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) + (k : K) (f g r₀ r₁ r₂ : Cube A) : + eventReject label σ F 0 k f g r₀ r₁ r₂ = + disagree (F f ^^ F g) (F (cubeXor f g)) := by + simp [eventReject, eventAccepts, eventQueries, oracleAnswer, truth_not_decide_eq] + +omit [Fintype A] [DecidableEq A] [Fintype K] [Nonempty K] in +theorem eventReject_and (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) + (k : K) (f g r₀ r₁ r₂ : Cube A) : + eventReject label σ F 1 k f g r₀ r₁ r₂ = + disagree (selfCorrect F (cubeAnd f g) r₀) + (selfCorrect F f r₁ && selfCorrect F g r₂) := by + simp [eventReject, eventAccepts, eventQueries, oracleAnswer, + truth_not_decide_eq, selfCorrect] + +omit [Fintype A] [DecidableEq A] [Fintype K] [Nonempty K] in +theorem eventReject_unit (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) + (k : K) (f g r₀ r₁ r₂ : Cube A) : + eventReject label σ F 2 k f g r₀ r₁ r₂ = + disagree (selfCorrect F (fun _ => true) r₀) true := by + simp only [eventReject, eventAccepts, eventQueries, oracleAnswer] + norm_num + change truth (!(selfCorrect F (fun _ => true) r₀)) = + disagree (selfCorrect F (fun _ => true) r₀) true + cases selfCorrect F (fun _ => true) r₀ <;> norm_num [truth, disagree] + +omit [Fintype A] [DecidableEq A] [Fintype K] [Nonempty K] in +theorem eventReject_input (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) + (k : K) (f g r₀ r₁ r₂ : Cube A) : + eventReject label σ F 3 k f g r₀ r₁ r₂ = + disagree (σ k) (selfCorrect F (fun a => label a k) r₀) := by + simp [eventReject, eventAccepts, eventQueries, oracleAnswer, + truth_not_decide_eq, selfCorrect] + +omit [Fintype A] [DecidableEq A] [Fintype K] [Nonempty K] in +theorem event_perfect_completeness (label : A → K → Bool) (a : A) + (kind : Fin 4) (k : K) (f g r₀ r₁ r₂ : Cube A) : + eventAccepts kind (fun slot => oracleAnswer (label a) (fun x => x a) + (eventQueries label kind k f g r₀ r₁ r₂ slot)) = true := by + have hkind : kind = 0 ∨ kind = 1 ∨ kind = 2 ∨ kind = 3 := by omega + have hreject : eventReject label (label a) (fun x => x a) kind k f g r₀ r₁ r₂ = 0 := by + rcases hkind with h | h | h | h <;> subst kind + · simp [eventReject_blr, cubeXor, disagree] + · simp [eventReject_and, selfCorrect_dictator, cubeAnd, disagree] + · simp [eventReject_unit, selfCorrect_dictator, disagree] + · simp [eventReject_input, selfCorrect_dictator, disagree] + unfold eventReject at hreject + cases h : eventAccepts kind (fun slot => oracleAnswer (label a) (fun x => x a) + (eventQueries label kind k f g r₀ r₁ r₂ slot)) <;> simp_all [truth] + +def explicitTesterReject (label : A → K → Bool) (σ : K → Bool) (F : Cube A → Bool) : ℝ := + 𝔼 kind : Fin 4, 𝔼 k, 𝔼 f, 𝔼 g, 𝔼 r₀, 𝔼 r₁, 𝔼 r₂, + eventReject label σ F kind k f g r₀ r₁ r₂ + +theorem explicitTesterReject_eq (label : A → K → Bool) (σ : K → Bool) + (F : Cube A → Bool) : explicitTesterReject label σ F = testerReject label σ F := by + unfold explicitTesterReject + rw [Fintype.expect_eq_sum_div_card] + simp [Fin.sum_univ_succ, eventReject_blr, eventReject_and, eventReject_unit, + eventReject_input, testerReject, blrReject, andReject, unitReject, inputReject, add_assoc] + +theorem explicit_proximity_soundness (label : A → K → Bool) (σ : K → Bool) + (F : Cube A → Bool) {δ : ℝ} (hδ : 0 < δ) (hδ' : δ ≤ 1 / 4) + (hfar : ∀ a, δ ≤ distance σ (label a)) : + δ / 256 ≤ explicitTesterReject label σ F := by + rw [explicitTesterReject_eq] + exact tester_proximity_soundness label σ F hδ hδ' hfar + +end IndependentSetsGames.Foundations.PCP.AssignmentTester +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Body.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Body.lean new file mode 100644 index 0000000000000000000000000000000000000000..6dce0ff1fc6254ce3f86c0b9fb34062e3d8b997a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Body.lean @@ -0,0 +1,326 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Ambient +import OAI.Combinatorics.IndependentSets.PCP.Driver + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Body + +open Turing +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel + +variable {q : Nat} + +def bodyTime (q N : Nat) : Nat := + (32 + 8 * (Enumeration.localCount q * (6 * (2 * 4104)))) * (N + 1) + +structure RowStepResult (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) (oldRelation : GenericGraphTables.RelationTable q) + (oldFlag : Bool) where + tapes : Tape → List Bool + ready : LoopState.Ready input (e.val + 1) tapes + run : StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some .guard, normal oldRelation oldFlag, base⟩ + (some ⟨some .guard, CompareLoop.rowState input e, tapes⟩) + (bodyTime q (LoopState.inputBits input).length) + +def guardTapes (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) : Tape → List Bool := + Function.update base .counter (encodeWord (input.darts - (e.val + 1))) + +def parsedTapes (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) : Tape → List Bool := + Lookup.readRowTapes .cursor .tail .reverseIndex (guardTapes input e base) + input.rows[e] (LoopState.cursorBits input (e.val + 1)) + +def workingTapes (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) : Tape → List Bool := + Lookup.headLookupTapes headPorts (parsedTapes input e base) input e + +def emittedTapes (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) : Tape → List Bool := + Emitter.resultTapes .reversed (workingTapes input e base) + (encodeWords (EmitRows.blockWords input e)) + +def clearFieldsTapes (base : Tape → List Bool) : Tape → List Bool := + Function.update (Function.update (Function.update base .tail []) .reverseIndex []) .head [] + +def resultTapes (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) : Tape → List Bool := + Function.update (clearFieldsTapes (emittedTapes input e base)) .edge + (encodeWord (e.val + 1)) + +private theorem workingTapes_other (input : GenericGraphTables.Table q) + (e : Fin input.darts) (base : Tape → List Bool) (other : Tape) + (hcounter : other ≠ .counter) (hcursor : other ≠ .cursor) + (htail : other ≠ .tail) (hreverse : other ≠ .reverseIndex) + (hscan : other ≠ .scan) (hindex : other ≠ .indexScan) (hhead : other ≠ .head) : + workingTapes input e base other = base other := by + simp [workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + parsedTapes, Lookup.readRowTapes, guardTapes, hcounter, hcursor, htail, + hreverse, hscan, hindex, hhead] + +private theorem workingTapes_counter (input : GenericGraphTables.Table q) + (e : Fin input.darts) (base : Tape → List Bool) : + workingTapes input e base .counter = encodeWord (input.darts - (e.val + 1)) := by + simp [workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + parsedTapes, Lookup.readRowTapes, guardTapes] + +private theorem workingTapes_cursor (input : GenericGraphTables.Table q) + (e : Fin input.darts) (base : Tape → List Bool) : + workingTapes input e base .cursor = LoopState.cursorBits input (e.val + 1) := by + simp [workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + parsedTapes, Lookup.readRowTapes] + +private theorem workingTapes_tail (input : GenericGraphTables.Table q) + (e : Fin input.darts) (base : Tape → List Bool) : + workingTapes input e base .tail = encodeWord input.rows[e].tail.val := by + simp [workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + parsedTapes, Lookup.readRowTapes] + +private theorem workingTapes_reverse (input : GenericGraphTables.Table q) + (e : Fin input.darts) (base : Tape → List Bool) : + workingTapes input e base .reverseIndex = encodeWord input.rows[e].reverseIndex.val := by + simp [workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + parsedTapes, Lookup.readRowTapes] + +private theorem workingTapes_head (input : GenericGraphTables.Table q) + (e : Fin input.darts) (base : Tape → List Bool) : + workingTapes input e base .head = + encodeWord input.rows[input.rows[e].reverseIndex].tail.val := by + simp [workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + Lookup.headValue, Lookup.headIndex] + +def clearFieldsInTime (base : Tape → List Bool) (ambient : Ambient q) : + StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some (.clearField 0), (ambient, none), base⟩ + (some ⟨some .increment, (ambient, none), clearFieldsTapes base⟩) + ((base .tail).length + (base .reverseIndex).length + (base .head).length + 3) := by + let first := MachineDrain.drainInTime Tape.tail (Driver.Label.clearField 0) + (some (.clearField 1)) (Driver.program q) (by rfl) base ambient none + let second := MachineDrain.drainInTime Tape.reverseIndex (Driver.Label.clearField 1) + (some (.clearField 2)) (Driver.program q) (by rfl) + (Function.update base .tail []) ambient none + let third := MachineDrain.drainInTime Tape.head (Driver.Label.clearField 2) + (some .increment) (Driver.program q) (by rfl) + (Function.update (Function.update base .tail []) .reverseIndex []) ambient none + let firstTwo := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first second + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ firstTwo third + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have h := run.steps_le_m + simp only [Function.update_of_ne (by decide : Tape.reverseIndex ≠ .tail), + Function.update_of_ne (by decide : Tape.head ≠ .reverseIndex), + Function.update_of_ne (by decide : Tape.head ≠ .tail)] at h + omega + +def incrementInTime (base : Tape → List Bool) (ambient : Ambient q) + (e : Nat) (he : base .edge = encodeWord e) : + StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some .increment, (ambient, none), base⟩ + (some ⟨some .guard, (ambient, none), Function.update base .edge (encodeWord (e + 1))⟩) + 1 where + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (nextRow (Driver.Label.guard : Driver.Label q)) + (ambient, none) base) = _ + simpa only [List.append_nil] using congrArg some + (stepAux_nextRow (Driver.Label.guard : Driver.Label q) (ambient, none) base e [] + (by simpa only [List.append_nil] using he)) + steps_le_m := Nat.le_refl _ + +private theorem emitterView_at (label : + Emitter.Label (Driver.rowPlan q).length (Addresses.fieldBound q)) : + (MachineControl.program (Equiv.refl (Driver.Label q)) (emitterEquiv q).symm + (Driver.program q)) (.emit label) = + Emitter.statement (Emitter.listCommands (Driver.rowPlan q)) rowSources + Tape.scratch Tape.reversed Driver.Label.emit (some (.clearField 0)) label := by + change MachineControl.statement id (emitterEquiv q).symm + (MachineControl.statement id (emitterEquiv q) _) = _ + exact MachineFieldProfile.statement_roundtrip (emitterEquiv q).symm _ + +private theorem context_rowState (input : GenericGraphTables.Table q) + (e : Fin input.darts) : + context (CompareLoop.rowState input e).1 = EmitRows.rowContext input e := by + change (input.rows[e].relation, + decide (input.rows[e].tail.val = input.rows[input.rows[e].reverseIndex].tail.val)) = + (input.rows[e].relation, + decide (input.rows[e].tail = input.rows[input.rows[e].reverseIndex].tail)) + simp only [Fin.val_inj] + +def emitInTime (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) + (operands : ∀ i, base (rowSources i) = encodeWord (EmitRows.rowValues input e i)) + (scratchEmpty : base .scratch = []) : + StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some (Driver.rowEntry q), CompareLoop.rowState input e, base⟩ + (some ⟨some (.clearField 0), CompareLoop.rowState input e, + Emitter.resultTapes .reversed base (encodeWords (EmitRows.blockWords input e))⟩) + (Enumeration.localCount q * (6 * (2 * 4104)) * + (3 * ((LoopState.inputBits input).length + 1) + 3) + 1) := by + let view := MachineControl.program (Equiv.refl (Driver.Label q)) (emitterEquiv q).symm + (Driver.program q) + have sourceScratch : ∀ i : Fin 5, rowSources i ≠ Tape.scratch := by + intro i; fin_cases i <;> decide + have sourceOutput : ∀ i : Fin 5, rowSources i ≠ Tape.reversed := by + intro i; fin_cases i <;> decide + have bounded : ∀ i, EmitRows.rowValues input e i ≤ (LoopState.inputBits input).length := by + have hn := GenericGraphTables.vertices_le_tableBits_length input + have hm := GenericGraphTables.darts_le_tableBits_length input + have he := e.isLt + have ht := input.rows[e].tail.isLt + have hh := input.rows[input.rows[e].reverseIndex].tail.isLt + intro i + fin_cases i <;> simp [EmitRows.rowValues, Addresses.values, LoopState.inputBits] <;> omega + have run := EmitRows.blockInTimeAmbient input e (@context q) + (CompareLoop.rowState input e).1 (context_rowState input e) + rowSources Tape.scratch Tape.reversed sourceScratch sourceOutput (by decide) + Driver.Label.emit (some (.clearField 0)) view emitterView_at base operands + scratchEmpty (LoopState.inputBits input).length bounded + have restored : MachineControl.program (Equiv.refl (Driver.Label q)) (emitterEquiv q) view = + Driver.program q := by + funext label + exact MachineFieldProfile.statement_roundtrip (emitterEquiv q) (Driver.program q label) + have transported := transportInTime (emitterEquiv q) view run + rw [restored] at transported + simpa [MachineControl.configuration, emitterEquiv, Option.map_some, id_eq, + Driver.rowEntry, Driver.rowPlan, CompareLoop.rowState, normal] using transported + +private theorem result_ready (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) (ready : LoopState.Ready input e.val base) : + LoopState.Ready input (e.val + 1) (resultTapes input e base) := by + constructor + · exact Nat.succ_le_of_lt e.isLt + all_goals simp [resultTapes, clearFieldsTapes, emittedTapes, Emitter.resultTapes, + workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + parsedTapes, Lookup.readRowTapes, guardTapes, ready.original, ready.vertices, + ready.darts, ready.scratch, ready.compareLeft, ready.compareRight, ready.output, + ready.reversed, LoopState.prefixBits_reverse_succ input e.val e.isLt] + +private theorem workingOperands (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) (ready : LoopState.Ready input e.val base) : + ∀ i, workingTapes input e base (rowSources i) = + encodeWord (EmitRows.rowValues input e i) := by + intro i + fin_cases i <;> simp [rowSources, EmitRows.rowValues, Addresses.values, + workingTapes, Lookup.headLookupTapes, MachineLookup.tapes, headPorts, + parsedTapes, Lookup.readRowTapes, guardTapes, Lookup.headValue, Lookup.headIndex, + ready.vertices, ready.darts, ready.edge] + +def rowStep (input : GenericGraphTables.Table q) (e : Fin input.darts) + (base : Tape → List Bool) (ready : LoopState.Ready input e.val base) + (oldRelation : GenericGraphTables.RelationTable q) (oldFlag : Bool) : + RowStepResult input e base oldRelation oldFlag := by + let N := (LoopState.inputBits input).length + have guarded : StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some .guard, normal oldRelation oldFlag, base⟩ + (some ⟨some .tailStart, normal oldRelation oldFlag, guardTapes input e base⟩) 1 := by + have hbase : MachineUnaryCounter.counterTapes .counter base + (input.darts - (e.val + 1) + 1) [] = base := by + simp only [MachineUnaryCounter.counterTapes, List.append_nil, + ← ready.counter_succ e.isLt, Function.update_eq_self] + have run := MachineUnaryCounter.guardInTime_succ Tape.counter Driver.Label.guard + .tailStart .reverseOutput (Driver.program q) (by rfl) base + (input.darts - (e.val + 1)) [] (normal oldRelation oldFlag).1 none + rw [hbase] at run + simpa only [MachineUnaryCounter.counterTapes, List.append_nil, guardTapes, + normal] using run + have parsed : StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some .tailStart, normal oldRelation oldFlag, guardTapes input e base⟩ + (some ⟨some .headCopyFirst, normal input.rows[e].relation oldFlag, + parsedTapes input e base⟩) (Lookup.readRowCost input.rows[e]) := by + have hcursor : guardTapes input e base .cursor = Lookup.rowBits input.rows[e] ++ + LoopState.cursorBits input (e.val + 1) := by + simpa only [guardTapes, Function.update_of_ne (by decide : Tape.cursor ≠ .counter), + Lookup.rowBits] using ready.cursor.trans (LoopState.cursorBits_succ input e.val e.isLt) + have htail : guardTapes input e base .tail = [] := by simp [guardTapes, ready.tail] + have hreverse : guardTapes input e base .reverseIndex = [] := by + simp [guardTapes, ready.reverseIndex] + simpa only [normal, parsedTapes] using + Lookup.readRowInTime Tape.cursor Tape.tail Tape.reverseIndex + (by decide) (by decide) (by decide) Driver.Label.tailStart .tailLoop + .reverseStart .reverseLoop .readPredicate .headCopyFirst (Driver.program q) + (by rfl) (by rfl) (by rfl) (by rfl) (by rfl) + (guardTapes input e base) input.rows[e] (LoopState.cursorBits input (e.val + 1)) + hcursor htail hreverse (oldFlag, false, none) oldRelation none + have looked : StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some .headCopyFirst, normal input.rows[e].relation oldFlag, parsedTapes input e base⟩ + (some ⟨some (.compare .leftFirst), normal input.rows[e].relation oldFlag, + workingTapes input e base⟩) (7 * N + 5) := by + have htable : parsedTapes input e base (headPorts 0) = GenericGraphTables.tableBits input := by + simpa [headPorts, parsedTapes, Lookup.readRowTapes, guardTapes, + LoopState.inputBits] using ready.original + have hreverse : parsedTapes input e base (headPorts 1) = + encodeWord (Lookup.headIndex input e).val := by + simp [headPorts, parsedTapes, Lookup.readRowTapes, Lookup.headIndex] + have hhead : parsedTapes input e base (headPorts 4) = [] := by + simp [headPorts, parsedTapes, Lookup.readRowTapes, guardTapes, ready.head] + have hscratch : parsedTapes input e base (headPorts 5) = [] := by + simp [headPorts, parsedTapes, Lookup.readRowTapes, guardTapes, ready.scratch] + have run := Lookup.headLookupInTime headPorts headPorts_injective + Driver.Label.headCopyFirst .headCopySecond .indexCopyFirst .indexCopySecond + .headVertices .headDarts Driver.Label.headLookup (some (.compare .leftFirst)) + (Driver.program q) (by rfl) (by rfl) (by rfl) (by rfl) (by rfl) (by rfl) + (fun _ => rfl) (parsedTapes input e base) input e htable hreverse hhead hscratch + (normal input.rows[e].relation oldFlag).1 none + simpa only [workingTapes, normal, N, LoopState.inputBits, Lookup.headTimePolynomial, + Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X] using run + have hleft : workingTapes input e base .compareLeft = [] := + (workingTapes_other input e base .compareLeft (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide)).trans ready.compareLeft + have hright : workingTapes input e base .compareRight = [] := + (workingTapes_other input e base .compareRight (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide)).trans ready.compareRight + have hscratch : workingTapes input e base .scratch = [] := + (workingTapes_other input e base .scratch (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide)).trans ready.scratch + let compared := CompareLoop.compareRowInTime Driver.Label.compare (Driver.rowEntry q) + (Driver.program q) (fun _ => rfl) input e (workingTapes input e base) + (workingTapes_tail input e base) (workingTapes_head input e base) + hleft hright hscratch oldFlag + let emitted := emitInTime input e (workingTapes input e base) + (workingOperands input e base ready) hscratch + let cleared := clearFieldsInTime (emittedTapes input e base) (CompareLoop.rowState input e).1 + have hedge : clearFieldsTapes (emittedTapes input e base) .edge = encodeWord e.val := by + simp [clearFieldsTapes, emittedTapes, Emitter.resultTapes, workingTapes, + Lookup.headLookupTapes, MachineLookup.tapes, headPorts, parsedTapes, + Lookup.readRowTapes, guardTapes, ready.edge] + let incremented := incrementInTime (clearFieldsTapes (emittedTapes input e base)) + (CompareLoop.rowState input e).1 e.val hedge + let run₁ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ guarded parsed + let run₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₁ looked + let run₃ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₂ compared + let run₄ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₃ emitted + let run₅ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₄ cleared + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₅ incremented + refine { + tapes := resultTapes input e base + ready := result_ready input e base ready + run := { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + } + have hn : input.vertices ≤ N := GenericGraphTables.vertices_le_tableBits_length input + have hm : input.darts ≤ N := GenericGraphTables.darts_le_tableBits_length input + have hr : Lookup.readRowCost input.rows[e] ≤ 2 * N + 5 := + Lookup.readRowCost_table_le input e + have ht : (emittedTapes input e base .tail).length ≤ N := by + simp only [emittedTapes, Emitter.resultTapes, + Function.update_of_ne (by decide : Tape.tail ≠ .reversed), workingTapes_tail, + encodeWord_length] + exact (Nat.succ_le_of_lt input.rows[e].tail.isLt).trans hn + have hv : (emittedTapes input e base .reverseIndex).length ≤ N := by + simp only [emittedTapes, Emitter.resultTapes, + Function.update_of_ne (by decide : Tape.reverseIndex ≠ .reversed), workingTapes_reverse, + encodeWord_length] + exact (Nat.succ_le_of_lt input.rows[e].reverseIndex.isLt).trans hm + have hh : (emittedTapes input e base .head).length ≤ N := by + simp only [emittedTapes, Emitter.resultTapes, + Function.update_of_ne (by decide : Tape.head ≠ .reversed), workingTapes_head, + encodeWord_length] + exact (Nat.succ_le_of_lt input.rows[input.rows[e].reverseIndex].tail.isLt).trans hn + have budget := run.steps_le_m + change run.steps ≤ (32 + 8 * (Enumeration.localCount q * (6 * (2 * 4104)))) * (N + 1) + nlinarith + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Body + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/BoundedIteration.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/BoundedIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbb1c4f2fad9a7b328651947aa1dac6207d2b746 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/BoundedIteration.lean @@ -0,0 +1,73 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineFiniteAlphabet +import OAI.Combinatorics.IndependentSets.Machines.GraphCounterFinish + +namespace OAI + +namespace LargeIndependentSets.BoundedIteration +open Turing +open IndependentSetsGames.Foundations.Complexity + +variable {α β : Type} + +def counted (count : α → ℕ) (enc : β → List Bool) (start : α → β) (a : α) : List Bool := + encodeWord (count a) ++ enc (start a) + +lemma count_le (count : α → ℕ) (enc : β → List Bool) (start : α → β) (a : α) : + count a ≤ (counted count enc start a).length := by + simp [counted,encodeWord] + +noncomputable def runtime (body length : Polynomial ℕ) : Polynomial ℕ := + Polynomial.X*(body.comp length + 2*length + 4) + 2*length + 4 + +lemma runtime_eval (body length : Polynomial ℕ) (n : ℕ) : + (runtime body length).eval n = n*(body.eval (length.eval n)+2*length.eval n+4)+2*length.eval n+4 := by + simp [runtime] + +noncomputable def certificate (enc : β → List Bool) (step : β → β) (start : α → β) + (count : α → ℕ) (body : TM2ComputableInPolyTime enc enc step) (length : Polynomial ℕ) + (growth : ∀ a i, i≤count a → (enc (step^[i] (start a))).length ≤ + length.eval (counted count enc start a).length) : + TM2ComputableInPolyTime (counted count enc start) enc + (fun a => step^[count a] (start a)) where + tm := MachineRepeat.machine body.tm body.inputAlphabet body.outputAlphabet + inputAlphabet := body.inputAlphabet + outputAlphabet := body.inputAlphabet + time := runtime body.time length + outputsFun a := by + let words : ℕ → List Bool := fun i => enc (step^[i] (start a)) + let budgets : ℕ → ℕ := fun i => body.time.eval (words i).length + have runs (i : ℕ) (_hi : i x k + ((D / 2 : ℕ) : ZMod D)) (torusGrid_antipode hD) + · intro x y + have h := hl q x y + change |gridBump S (location '' A) ⟨q, x⟩ - gridBump S (location '' A) ⟨q, y⟩| ≤ + (64 : ℝ) * dist (torusGrid x) (torusGrid y) + have hh : ENNReal.ofReal |gridBump S (location '' A) ⟨q, x⟩ - gridBump S (location '' A) ⟨q, y⟩| ≤ + ENNReal.ofReal (64 * dist (torusGrid x) (torusGrid y)) := by + convert h using 1 <;> simp [edist_dist, Real.dist_eq, ENNReal.ofReal_mul] + rfl + exact (ENNReal.ofReal_le_ofReal_iff (mul_nonneg (by norm_num : (0 : ℝ) ≤ 64) dist_nonneg)).mp hh + · intro x + exact hb ⟨q, x⟩ + · intro x + exact ho ⟨q, x⟩ + +lemma circle_dist_coe_le (x y : ℝ) : + dist (x : UnitAddCircle) (y : UnitAddCircle) ≤ |x - y| := by + have h := QuotientAddGroup.norm_mk_le_norm + (S := AddSubgroup.zmultiples (1 : ℝ)) (m := x - y) + simpa only [← AddCircle.coe_sub, dist_eq_norm, Real.norm_eq_abs] using h + +noncomputable def circleRound (D : ℕ) (x : UnitAddCircle) : ZMod D := + (⌊(D : ℝ) * circleRep x⌋₊ : ZMod D) + +lemma circleRound_close (D : ℕ) [NeZero D] (x : UnitAddCircle) : + dist x (ZMod.toAddCircle (circleRound D x)) < 1 / (D : ℝ) := by + have hD : (0 : ℝ) < D := by exact_mod_cast (NeZero.pos D) + have h₁ := Nat.floor_le (mul_nonneg hD.le (circleRep_nonneg x)) + have h₂ := Nat.lt_floor_add_one ((D : ℝ) * circleRep x) + have ha : (⌊(D : ℝ) * circleRep x⌋₊ : ℝ) / D ≤ circleRep x := by + apply (div_le_iff₀ hD).mpr + nlinarith + have hb : circleRep x - (⌊(D : ℝ) * circleRep x⌋₊ : ℝ) / D < 1 / D := by + apply (lt_div_iff₀ hD).mpr + rw [sub_mul, div_mul_cancel₀ _ (ne_of_gt hD)] + nlinarith + unfold circleRound + rw [ZMod.toAddCircle_natCast] + calc + _ = dist (circleRep x : UnitAddCircle) + (((⌊(D : ℝ) * circleRep x⌋₊ : ℝ) / (D : ℝ) : ℝ) : UnitAddCircle) := by rw [circleRep_coe] + _ ≤ |circleRep x - (⌊(D : ℝ) * circleRep x⌋₊ : ℝ) / D| := circle_dist_coe_le _ _ + _ < 1 / (D : ℝ) := by rw [abs_of_nonneg (sub_nonneg.mpr ha)]; exact hb + +noncomputable def torusRound {ι : Type*} (D : ℕ) (x : ι → UnitAddCircle) : ι → ZMod D := + fun k => circleRound D (x k) + +lemma torusRound_close {ι : Type*} [Fintype ι] (D : ℕ) [NeZero D] + (x : ι → UnitAddCircle) : dist x (torusGrid (torusRound D x)) ≤ 1 / (D : ℝ) := by + apply (dist_pi_le_iff (by positivity : (0 : ℝ) ≤ 1 / (D : ℝ))).mpr + intro k + exact (circleRound_close D (x k)).le + +lemma pullback_dist_le {ι κ : Type*} [Fintype ι] [Fintype κ] + (π : ι → κ) (x y : κ → UnitAddCircle) : dist (x ∘ π) (y ∘ π) ≤ dist x y := by + apply (dist_pi_le_iff dist_nonneg).mpr + intro k + exact dist_le_pi_dist x y (π k) + +theorem tupleExtension_compatibility {Q : Type*} {M : Q → Type*} [∀ q, Fintype (M q)] + (S : ProjectionSystem Q M) {D : ℕ} [NeZero D] (hD : Even D) + (hnoclique : ∀ x : GridLocation M D, + ¬pathDistance S.linkLength x (gridAntipode x) ≤ ENNReal.ofReal (1 / 8)) + {V : Type*} (location : V → GridLocation M D) (A : Set V) + (hA : (gridGraph S hD location).IsIndepSet A) + {q q' : Q} (π : M q → M q') + (hpath : ∀ v : M q' → ZMod D, + pathDistance S.linkLength ⟨q, v ∘ π⟩ ⟨q', v⟩ = 0) + (x : M q' → UnitAddCircle) : + |tupleExtension S (location '' A) q' x - tupleExtension S (location '' A) q (x ∘ π)| ≤ + 2 * 64 / (D : ℝ) := by + let y := torusRound D x + have hy := torusRound_close D x + have hπ := (pullback_dist_le π x (torusGrid y)).trans hy + have heq : tupleExtension S (location '' A) q (torusGrid y ∘ π) = + tupleExtension S (location '' A) q' (torusGrid y) := by + rw [show torusGrid y ∘ π = torusGrid (y ∘ π) from rfl, + tupleExtension_on_grid S hD hnoclique location A hA, + tupleExtension_on_grid S hD hnoclique location A hA] + let := linkPseudoEMetric (S.linkLength (D := D)) (linkLength_self S) (linkLength_symm S) + have hT : Isometry (gridAntipode : GridLocation M D → GridLocation M D) := + pathDistance_invariant S.linkLength gridAntipode (gridAntipode_involutive hD) + (linkLength_antipode S hD) + have hf : LipschitzWith 64 (gridBump S (location '' A)) := + oddBump_lipschitz gridAntipode hT (location '' A) + have h := hf ⟨q, y ∘ π⟩ ⟨q', y⟩ + change edist _ _ ≤ (64 : ℝ≥0∞) * pathDistance S.linkLength _ _ at h + rw [hpath y, mul_zero] at h + exact edist_eq_zero.mp (le_antisymm h bot_le) + have h₁ := ((tupleExtension_lipschitz S (location '' A) q').dist_le_mul x (torusGrid y)).trans + (mul_le_mul_of_nonneg_left hy (by norm_num : (0 : ℝ) ≤ 64)) + have h₂ := ((tupleExtension_lipschitz S (location '' A) q).dist_le_mul (x ∘ π) (torusGrid y ∘ π)).trans + (mul_le_mul_of_nonneg_left hπ (by norm_num : (0 : ℝ) ≤ 64)) + rw [heq] at h₂ + simp only [Real.dist_eq, NNReal.coe_ofNat] at h₁ h₂ + have h := abs_sub_le (tupleExtension S (location '' A) q' x) + (tupleExtension S (location '' A) q' (torusGrid y)) + (tupleExtension S (location '' A) q (x ∘ π)) + rw [abs_sub_comm (tupleExtension S (location '' A) q' (torusGrid y))] at h + calc + _ ≤ _ := h.trans (add_le_add h₁ h₂) + _ = 2 * 64 / (D : ℝ) := by ring + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/ClausePolynomial.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/ClausePolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..3808cf5969003cb6375ac1f33308a19089be0029 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/ClausePolynomial.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.GapFormula + +namespace OAI + +namespace LargeIndependentSets +open IndependentSetsGames.Foundations +open scoped Classical +noncomputable section + +lemma frame_length (b : List Bool) : (frame b).length = 2*b.length+1 := by + induction b with + | nil => rfl + | cons b bs ih => simp only [frame,List.length_cons,ih]; omega + +lemma graphBits_length (G : Graph) : (graphBits G).length = 2*G.vertices.bits.length+1+G.vertices^2 := by + have h : ∀ vs : List (Fin G.vertices), + (vs.flatMap (fun u => (List.finRange G.vertices).map (G.adj u))).length = + vs.length*G.vertices := by + intro vs + induction vs with + | nil => simp + | cons v vs ih => simp only [List.flatMap_cons,List.length_append,List.length_map, + List.length_finRange,ih,List.length_cons]; nlinarith + simp only [graphBits,nameBits,List.length_append,frame_length,h,List.length_finRange,pow_two] + +lemma graphBits_bound (G : Graph) : (graphBits G).length ≤ 4*(G.vertices+1)^2 := by + have h : G.vertices.bits.length ≤ G.vertices := by + rw [Nat.size_eq_bits_len] + exact Nat.size_le.mpr G.vertices.lt_two_pow_self + rw [graphBits_length] + nlinarith + +namespace SemanticReduction +open Target PCP Hastad.SourceContexts Hastad.SourceGame + +def clausePolynomial : Polynomial ℕ := TableIteration.formulaBitsPolynomial.comp + (Polynomial.C 100*(Polynomial.X+Polynomial.C 1)^2) + +lemma clauses_bound (H : RoundTables.BaseTable) (F : LargeIndependentSets.Formula) : + (gapFormula H F).clauses.length ≤ clausePolynomial.eval (LargeIndependentSets.formulaBits F).length := by + have h0 := Hastad.SourceBounds.formulaBits_length_ge_clauses (gapFormula H F) + have h1 := TableIteration.gapMap_bits_le H (Normalization.normalize F) + have h2 := Complexity.MachineComposition.natPolynomial_eval_mono + TableIteration.formulaBitsPolynomial (Normalization.normalize_bits F) + apply h0.trans (h1.trans _) + simpa only [clausePolynomial,Polynomial.eval_comp,Polynomial.eval_mul,Polynomial.eval_C, + Polynomial.eval_pow,Polynomial.eval_add,Polynomial.eval_X] using h2 + +def vertexPolynomial (p : SamplerParameters) (u q : ℕ) : Polynomial ℕ := + Polynomial.C q + (Polynomial.C 3 * clausePolynomial)^(u*p.n) * + Polynomial.C (p.law (J u) (I u)).denominator + +lemma vertices_polynomial (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 answer.first + | .second => answer.second + | .third => answer.third + +def nameAt {n : Nat} (clause : Clause n) : Slot → Fin n + | .first => clause[0].variableIndex + | .second => clause[1].variableIndex + | .third => clause[2].variableIndex + +def literalValue (positive value : Bool) : Bool := + if positive then value else !value + +def localSatisfies {n : Nat} (clause : Clause n) (answer : ClauseAnswer) : Bool := + (literalValue clause[0].positive answer.first || + literalValue clause[1].positive answer.second) || + literalValue clause[2].positive answer.third + +def honestAnswer {n : Nat} (clause : Clause n) (assignment : Fin n → Bool) : ClauseAnswer := + ⟨assignment clause[0].variableIndex, assignment clause[1].variableIndex, + assignment clause[2].variableIndex⟩ + +theorem honest_satisfies {n : Nat} (clause : Clause n) (assignment : Fin n → Bool) : + localSatisfies clause (honestAnswer clause assignment) = clause.eval assignment := rfl + +theorem honest_answerAt {n : Nat} (clause : Clause n) (assignment : Fin n → Bool) + (slot : Slot) : answerAt (honestAnswer clause assignment) slot = + assignment (nameAt clause slot) := by + cases slot <;> rfl + +def matchingSlots (a b : ClauseAnswer) : Nat := + (if a.first = b.first then 1 else 0) + + (if a.second = b.second then 1 else 0) + + (if a.third = b.third then 1 else 0) + +theorem matchingSlots_le (a b : ClauseAnswer) : matchingSlots a b ≤ 3 := by + rcases a with ⟨a₁,a₂,a₃⟩ + rcases b with ⟨b₁,b₂,b₃⟩ + cases a₁ <;> cases a₂ <;> cases a₃ <;> cases b₁ <;> cases b₂ <;> cases b₃ <;> decide + +theorem matchingSlots_eq_three (a b : ClauseAnswer) : matchingSlots a b = 3 ↔ a = b := by + rcases a with ⟨a₁,a₂,a₃⟩ + rcases b with ⟨b₁,b₂,b₃⟩ + cases a₁ <;> cases a₂ <;> cases a₃ <;> cases b₁ <;> cases b₂ <;> cases b₃ <;> decide + +def acceptedSlots {n : Nat} (clause : Clause n) (alice bob : ClauseAnswer) : Nat := + if localSatisfies clause alice then matchingSlots alice bob else 0 + +def clauseFailure {n : Nat} (clause : Clause n) (assignment : Fin n → Bool) : Nat := + if clause.eval assignment then 0 else 1 + +theorem local_rejection_bound {n : Nat} (clause : Clause n) (alice : ClauseAnswer) + (bob : Fin n → Bool) : + acceptedSlots clause alice (honestAnswer clause bob) + clauseFailure clause bob ≤ 3 := by + have hle := matchingSlots_le alice (honestAnswer clause bob) + by_cases hb : clause.eval bob = true + · simp only [clauseFailure, hb, ↓reduceIte, Nat.add_zero] + unfold acceptedSlots + split <;> omega + · have hfailure : clauseFailure clause bob = 1 := by simp [clauseFailure, hb] + rw [hfailure] + by_cases ha : localSatisfies clause alice = true + · have hne : alice ≠ honestAnswer clause bob := by + intro h + subst alice + exact hb ((honest_satisfies clause bob).symm.trans ha) + have hlt : matchingSlots alice (honestAnswer clause bob) ≠ 3 := by + intro h + exact hne ((matchingSlots_eq_three _ _).mp h) + simp only [acceptedSlots, ha, ↓reduceIte] + omega + · simp [acceptedSlots, ha] + +def clauseAt (formula : Formula) (index : Fin formula.clauses.length) : + Clause formula.«variables» := formula.clauses[index.val] + +abbrev RandomEvent (formula : Formula) := Fin formula.clauses.length × Slot +abbrev AliceStrategy (formula : Formula) := Fin formula.clauses.length → ClauseAnswer +abbrev BobStrategy (formula : Formula) := Fin formula.«variables» → Bool + +def accepts (formula : Formula) (alice : AliceStrategy formula) (bob : BobStrategy formula) + (event : RandomEvent formula) : Bool := + localSatisfies (clauseAt formula event.1) (alice event.1) && + decide (answerAt (alice event.1) event.2 = bob (nameAt (clauseAt formula event.1) event.2)) + +def acceptedCount (formula : Formula) (alice : AliceStrategy formula) + (bob : BobStrategy formula) : List (Fin formula.clauses.length) → Nat + | [] => 0 + | i :: rest => acceptedSlots (clauseAt formula i) (alice i) + (honestAnswer (clauseAt formula i) bob) + acceptedCount formula alice bob rest + +def failureCount (formula : Formula) (bob : BobStrategy formula) : + List (Fin formula.clauses.length) → Nat + | [] => 0 + | i :: rest => clauseFailure (clauseAt formula i) bob + failureCount formula bob rest + +theorem total_rejection_bound (formula : Formula) (alice : AliceStrategy formula) + (bob : BobStrategy formula) (indices : List (Fin formula.clauses.length)) : + acceptedCount formula alice bob indices + failureCount formula bob indices ≤ + 3 * indices.length := by + induction indices with + | nil => simp [acceptedCount, failureCount] + | cons i rest ih => + have h := local_rejection_bound (clauseAt formula i) (alice i) bob + simp only [acceptedCount, failureCount, List.length_cons] + omega + +def allIndices (formula : Formula) : List (Fin formula.clauses.length) := + List.finRange formula.clauses.length + +theorem hastad_basic_verifier_soundness (formula : Formula) (a b : Nat) + (sourceGap : ∀ bob : BobStrategy formula, + a * formula.clauses.length ≤ b * failureCount formula bob (allIndices formula)) + (alice : AliceStrategy formula) (bob : BobStrategy formula) : + b * acceptedCount formula alice bob (allIndices formula) + a * formula.clauses.length ≤ + b * (3 * formula.clauses.length) := by + have ht := Nat.mul_le_mul_left b (total_rejection_bound formula alice bob (allIndices formula)) + have hg := sourceGap bob + simp only [allIndices, List.length_finRange, Nat.mul_add] at * + omega + +theorem honest_accepts (formula : Formula) (assignment : BobStrategy formula) + (satisfies : ∀ clause ∈ formula.clauses, clause.eval assignment = true) + (event : RandomEvent formula) : + accepts formula (fun i => honestAnswer (clauseAt formula i) assignment) assignment event = true := by + have hc : (clauseAt formula event.1).eval assignment = true := + satisfies _ (List.getElem_mem _) + simp [accepts, honest_satisfies, honest_answerAt, hc] + +theorem verifier_completeness (formula : Formula) (sat : formula.Satisfiable) : + ∃ (alice : AliceStrategy formula) (bob : BobStrategy formula), + ∀ event : RandomEvent formula, accepts formula alice bob event = true := by + rcases sat with ⟨assignment, hs⟩ + exact ⟨fun i => honestAnswer (clauseAt formula i) assignment, assignment, + honest_accepts formula assignment hs⟩ + +abbrev LeftLabel (formula : Formula) (i : Fin formula.clauses.length) := + { answer : ClauseAnswer // localSatisfies (clauseAt formula i) answer = true } + +def edgeProjection (formula : Formula) (event : RandomEvent formula) + (label : LeftLabel formula event.1) : Bool := answerAt label.val event.2 + +theorem verifier_eq_projection (formula : Formula) + (alice : ∀ i, LeftLabel formula i) (bob : BobStrategy formula) (event : RandomEvent formula) : + accepts formula (fun i => (alice i).val) bob event = + decide (edgeProjection formula event (alice event.1) = + bob (nameAt (clauseAt formula event.1) event.2)) := by + simp [accepts, (alice event.1).property, edgeProjection] + rfl + +def eventsAt (formula : Formula) (i : Fin formula.clauses.length) : List (RandomEvent formula) := + [(i, .first), (i, .second), (i, .third)] + +def enumerateEvents (formula : Formula) : List (Fin formula.clauses.length) → + List (RandomEvent formula) + | [] => [] + | i :: rest => eventsAt formula i ++ enumerateEvents formula rest + +theorem length_enumerateEvents (formula : Formula) (indices : List (Fin formula.clauses.length)) : + (enumerateEvents formula indices).length = 3 * indices.length := by + induction indices with + | nil => simp [enumerateEvents] + | cons i rest ih => + simp only [enumerateEvents, eventsAt, List.length_append, List.length_cons, + List.length_nil, ih] + omega + +theorem accepted_eventsAt (formula : Formula) (alice : AliceStrategy formula) + (bob : BobStrategy formula) (i : Fin formula.clauses.length) : + ((eventsAt formula i).filter (accepts formula alice bob)).length = + acceptedSlots (clauseAt formula i) (alice i) (honestAnswer (clauseAt formula i) bob) := by + by_cases hs : localSatisfies (clauseAt formula i) (alice i) = true + · by_cases h₁ : (alice i).first = bob (clauseAt formula i)[0].variableIndex <;> + by_cases h₂ : (alice i).second = bob (clauseAt formula i)[1].variableIndex <;> + by_cases h₃ : (alice i).third = bob (clauseAt formula i)[2].variableIndex <;> + simp [eventsAt, accepts, acceptedSlots, matchingSlots, honestAnswer, + answerAt, nameAt, hs, h₁, h₂, h₃] + · simp [eventsAt, accepts, acceptedSlots, hs] + +theorem accepted_enumerateEvents (formula : Formula) (alice : AliceStrategy formula) + (bob : BobStrategy formula) (indices : List (Fin formula.clauses.length)) : + ((enumerateEvents formula indices).filter (accepts formula alice bob)).length = + acceptedCount formula alice bob indices := by + induction indices with + | nil => simp [enumerateEvents, acceptedCount] + | cons i rest ih => + simp only [enumerateEvents, List.filter_append, List.length_append, + accepted_eventsAt, ih, acceptedCount] + +def allEvents (formula : Formula) : List (RandomEvent formula) := + enumerateEvents formula (allIndices formula) + +theorem length_allEvents (formula : Formula) : + (allEvents formula).length = 3 * formula.clauses.length := by + simp [allEvents, length_enumerateEvents, allIndices] + +theorem allEvents_nonempty (formula : Formula) (hne : formula.clauses ≠ []) : + allEvents formula ≠ [] := by + intro he + have hl := length_allEvents formula + rw [he] at hl + have hpos : 0 < formula.clauses.length := List.length_pos_iff.mpr hne + simp only [List.length_nil] at hl + omega + +theorem verifier_event_soundness (formula : Formula) (a b : Nat) + (sourceGap : ∀ bob : BobStrategy formula, + a * formula.clauses.length ≤ b * failureCount formula bob (allIndices formula)) + (alice : AliceStrategy formula) (bob : BobStrategy formula) : + b * ((allEvents formula).filter (accepts formula alice bob)).length + + a * formula.clauses.length ≤ b * (allEvents formula).length := by + rw [length_allEvents] + simp only [allEvents, accepted_enumerateEvents] + exact hastad_basic_verifier_soundness formula a b sourceGap alice bob + +def occurrencesAt {n : Nat} (clause : Clause n) (v : Fin n) : Nat := + (if clause[0].variableIndex = v then 1 else 0) + + (if clause[1].variableIndex = v then 1 else 0) + + (if clause[2].variableIndex = v then 1 else 0) + +def occurrenceCount (formula : Formula) (v : Fin formula.«variables») : + List (Fin formula.clauses.length) → Nat + | [] => 0 + | i :: rest => occurrencesAt (clauseAt formula i) v + occurrenceCount formula v rest + +theorem variable_eventsAt (formula : Formula) (v : Fin formula.«variables») + (i : Fin formula.clauses.length) : + ((eventsAt formula i).filter (fun event => + decide (nameAt (clauseAt formula event.1) event.2 = v))).length = + occurrencesAt (clauseAt formula i) v := by + by_cases h₁ : (clauseAt formula i)[0].variableIndex = v <;> + by_cases h₂ : (clauseAt formula i)[1].variableIndex = v <;> + by_cases h₃ : (clauseAt formula i)[2].variableIndex = v <;> + simp [eventsAt, nameAt, occurrencesAt, h₁, h₂, h₃] + +theorem variable_enumerateEvents (formula : Formula) (v : Fin formula.«variables») + (indices : List (Fin formula.clauses.length)) : + ((enumerateEvents formula indices).filter (fun event => + decide (nameAt (clauseAt formula event.1) event.2 = v))).length = + occurrenceCount formula v indices := by + induction indices with + | nil => simp [enumerateEvents, occurrenceCount] + | cons i rest ih => + simp only [enumerateEvents, List.filter_append, List.length_append, + variable_eventsAt, ih, occurrenceCount] + +theorem regular_bob_marginal (formula : Formula) (degree : Nat) + (regular : ∀ v : Fin formula.«variables», + occurrenceCount formula v (allIndices formula) = degree) + (v : Fin formula.«variables») : + ((allEvents formula).filter (fun event => + decide (nameAt (clauseAt formula event.1) event.2 = v))).length = degree := by + rw [allEvents, variable_enumerateEvents] + exact regular v + +end IndependentSetsGames.Foundations.PCP + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Cleanup.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Cleanup.lean new file mode 100644 index 0000000000000000000000000000000000000000..de8776c05359ba8244829d9e68a478b30f6e771f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Cleanup.lean @@ -0,0 +1,192 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrain + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Cleanup + +open Turing +open Complexity +open scoped BigOperators + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def finish (initial : σ) (exit : Option Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + .load (fun _ => (initial, none)) + (match exit with | none => .halt | some label => .goto fun _ => label) + +def instruction {n : Nat} (selected : Fin n → K) (labels : Fin (n + 1) → Λ) + (initial : σ) (exit : Option Λ) (phase : Fin (n + 1)) : + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := + if h : phase.val < n then + MachineDrain.drain (selected ⟨phase.val, h⟩) (labels phase) + (some (labels ⟨phase.val + 1, Nat.succ_lt_succ h⟩)) + else finish initial exit + +omit [DecidableEq K] in +@[simp] theorem instruction_drain {n : Nat} (selected : Fin n → K) + (labels : Fin (n + 1) → Λ) (initial : σ) (exit : Option Λ) (i : Fin n) : + instruction selected labels initial exit i.castSucc = + MachineDrain.drain (selected i) (labels i.castSucc) (some (labels i.succ)) := by + simp [instruction, i.isLt] + rfl + +omit [DecidableEq K] in +@[simp] theorem instruction_finish {n : Nat} (selected : Fin n → K) + (labels : Fin (n + 1) → Λ) (initial : σ) (exit : Option Λ) : + instruction selected labels initial exit (Fin.last n) = finish initial exit := by + simp [instruction] + +def clearTapes : {n : Nat} → (Fin n → K) → (K → List Bool) → K → List Bool + | 0, _, base => base + | n + 1, selected, base => + clearTapes (fun i : Fin n => selected i.succ) (Function.update base (selected 0) []) + +def actualCost : {n : Nat} → (Fin n → K) → (K → List Bool) → Nat + | 0, _, _ => 1 + | n + 1, selected, base => + actualCost (fun i : Fin n => selected i.succ) (Function.update base (selected 0) []) + + ((base (selected 0)).length + 1) + +theorem clearTapes_apply {n : Nat} (selected : Fin n → K) (base : K → List Bool) (k : K) : + clearTapes selected base k = if ∃ i, selected i = k then [] else base k := by + induction n generalizing base with + | zero => simp [clearTapes] + | succ n ih => + rw [clearTapes, ih] + by_cases first : selected 0 = k + · subst k + simp [Function.update] + · have notFirst : k ≠ selected 0 := Ne.symm first + by_cases later : ∃ i : Fin n, selected i.succ = k <;> + simp [Fin.exists_fin_succ, first, later, Function.update, notFirst] + +@[simp] theorem clearTapes_selected {n : Nat} (selected : Fin n → K) + (base : K → List Bool) (i : Fin n) : clearTapes selected base (selected i) = [] := by + rw [clearTapes_apply, ite_eq_left ⟨i, rfl⟩] + +theorem clearTapes_unselected {n : Nat} (selected : Fin n → K) + (base : K → List Bool) (k : K) (notSelected : ∀ i, selected i ≠ k) : + clearTapes selected base k = base k := by + rw [clearTapes_apply] + simp [notSelected] + +theorem actualCost_le {n : Nat} (selected : Fin n → K) (base : K → List Bool) : + actualCost selected base ≤ (∑ i, (base (selected i)).length) + n + 1 := by + induction n generalizing base with + | zero => simp [actualCost] + | succ n ih => + have tailBound := ih (fun i : Fin n => selected i.succ) + (Function.update base (selected 0) []) + have sumBound : + (∑ i : Fin n, ((Function.update base (selected 0) []) (selected i.succ)).length) ≤ + ∑ i : Fin n, (base (selected i.succ)).length := by + apply Finset.sum_le_sum + intro i _ + by_cases h : selected i.succ = selected 0 <;> simp [h] + rw [actualCost, Fin.sum_univ_succ] + omega + +theorem cleanupTrace {n : Nat} (selected : Fin n → K) (labels : Fin (n + 1) → Λ) + (initial : σ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atDrain : ∀ i : Fin n, program (labels i.castSucc) = + MachineDrain.drain (selected i) (labels i.castSucc) (some (labels i.succ))) + (atFinish : program (labels (Fin.last n)) = finish initial exit) + (base : K → List Bool) (ambient : σ) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[actualCost selected base] + (some ⟨some (labels 0), (ambient, register), base⟩) = + some ⟨exit, (initial, none), clearTapes selected base⟩ := by + induction n generalizing base ambient register with + | zero => + change some (TM2.stepAux (program (labels 0)) (ambient, register) base) = _ + rw [show program (labels 0) = finish initial exit from atFinish] + cases exit <;> rfl + | succ n ih => + rw [actualCost, Function.iterate_add_apply] + have first := MachineDrain.drainTrace (selected 0) (labels (0 : Fin (n + 1)).castSucc) + (some (labels (0 : Fin (n + 1)).succ)) program (atDrain 0) + base (base (selected 0)) ambient register + simp only [Function.update_eq_self, Fin.castSucc_zero] at first + rw [first] + exact ih (fun i : Fin n => selected i.succ) (fun i => labels i.succ) + (fun i => atDrain i.succ) atFinish (Function.update base (selected 0) []) ambient none + +def cleanupInTime {n : Nat} (selected : Fin n → K) (labels : Fin (n + 1) → Λ) + (initial : σ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atDrain : ∀ i : Fin n, program (labels i.castSucc) = + MachineDrain.drain (selected i) (labels i.castSucc) (some (labels i.succ))) + (atFinish : program (labels (Fin.last n)) = finish initial exit) + (base : K → List Bool) (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels 0), (ambient, register), base⟩ + (some ⟨exit, (initial, none), clearTapes selected base⟩) + ((∑ i, (base (selected i)).length) + n + 1) where + steps := actualCost selected base + evals_in_steps := cleanupTrace selected labels initial exit program atDrain atFinish + base ambient register + steps_le_m := actualCost_le selected base + +def program {n : Nat} (selected : Fin n → K) (initial : σ) : + Fin (n + 1) → TM2.Stmt (Alphabet (K := K)) (Fin (n + 1)) (σ × Option Bool) := + instruction selected id initial none + +def machine [Fintype K] [Fintype σ] {n : Nat} (selected : Fin n → K) + (input output : K) (initial : σ) : FinTM2 where + K := K + k₀ := input + k₁ := output + Γ := Alphabet + Λ := Fin (n + 1) + main := 0 + σ := σ × Option Bool + initialState := (initial, none) + m := program selected initial + +def machineInTime [Fintype K] [Fintype σ] {n : Nat} (selected : Fin n → K) + (input output : K) (initial : σ) (base : K → List Bool) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (machine selected input output initial).step + ⟨some (0 : Fin (n + 1)), (ambient, register), base⟩ + (some ⟨none, (initial, none), clearTapes selected base⟩) + ((∑ i, (base (selected i)).length) + n + 1) := + cleanupInTime selected id initial none (program selected initial) + (fun i => instruction_drain selected id initial none i) + (instruction_finish selected id initial none) base ambient register + +theorem clearTapes_outputOnly {n : Nat} (selected : Fin n → K) + (output : K) (base : K → List Bool) + (excludesOutput : ∀ i, selected i ≠ output) + (coversOther : ∀ k, k ≠ output → ∃ i, selected i = k) : + clearTapes selected base = fun k => if k = output then base output else [] := by + funext k + by_cases h : k = output + · subst k + simp [clearTapes_unselected selected base output excludesOutput] + · rw [clearTapes_apply] + simp [h, coversOther k h] + +def machineHaltInTime [Fintype K] [Fintype σ] {n : Nat} (selected : Fin n → K) + (input output : K) (initial : σ) (base : K → List Bool) + (ambient : σ) (register : Option Bool) + (excludesOutput : ∀ i, selected i ≠ output) + (coversOther : ∀ k, k ≠ output → ∃ i, selected i = k) : + StateTransition.EvalsToInTime (machine selected input output initial).step + ⟨some (0 : Fin (n + 1)), (ambient, register), base⟩ + (some (haltList (machine selected input output initial) (base output))) + ((∑ i, (base (selected i)).length) + n + 1) := by + have tapeEq := clearTapes_outputOnly selected output base excludesOutput coversOther + have haltEq : (⟨none, (initial, none), clearTapes selected base⟩ : + (machine selected input output initial).Cfg) = + haltList (machine selected input output initial) (base output) := by + congr 1 + rw [← haltEq] + exact machineInTime selected input output initial base ambient register + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Cleanup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/CloneGap.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/CloneGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cc767cf78427ab638c3965f77d735d827117e11 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/CloneGap.lean @@ -0,0 +1,289 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Reduction.CloneGap + +variable {α β : Type*} + +def cart (xs : List α) (ys : List β) : List (α × β) := + xs.flatMap fun x => ys.map fun y => (x, y) + +theorem count_const (xs : List α) (b : Bool) : + xs.countP (fun _ => b) = if b then xs.length else 0 := by + cases b <;> simp + +theorem count_cart (xs : List α) (ys : List β) (p : α → Bool) (q : β → Bool) : + (cart xs ys).countP (fun z => p z.1 && q z.2) = + xs.countP p * ys.countP q := by + induction xs with + | nil => simp [cart] + | cons x xs ih => + simp only [cart, List.flatMap_cons, List.countP_append] at * + rw [ih] + cases h : p x <;> + simp [List.countP_map, Function.comp_def, h, Nat.add_mul, Nat.add_comm] + +theorem length_cart (xs : List α) (ys : List β) : + (cart xs ys).length = xs.length * ys.length := by + have := count_cart xs ys (fun _ => true) (fun _ => true) + simpa using this + +theorem count_cart_left (xs : List α) (ys : List β) (p : α → Bool) : + (cart xs ys).countP (fun z => p z.1) = xs.countP p * ys.length := by + simpa using count_cart xs ys p (fun _ => true) + +theorem count_cart_right (xs : List α) (ys : List β) (p : β → Bool) : + (cart xs ys).countP (fun z => p z.2) = xs.length * ys.countP p := by + simpa using count_cart xs ys (fun _ => true) p + +theorem count_cart_le (xs : List α) (ys : List β) (p : α × β → Bool) + (bound : Nat) (h : ∀ x ∈ xs, ys.countP (fun y => p (x, y)) ≤ bound) : + (cart xs ys).countP p ≤ xs.length * bound := by + induction xs with + | nil => simp [cart] + | cons x xs ih => + have hx := h x (by simp) + have ht := ih (fun y hy => h y (by simp [hy])) + simp only [cart, List.flatMap_cons, List.countP_append, List.countP_map, + Function.comp_def] at * + simp only [List.length_cons, Nat.add_mul] + omega + +theorem count_union_le (xs : List α) (p q : α → Bool) : + xs.countP (fun x => p x || q x) ≤ xs.countP p + xs.countP q := by + induction xs with + | nil => simp + | cons x xs ih => + cases hp : p x <;> cases hq : q x <;> + simp [hp, hq] at * <;> omega + +theorem count_remove (xs : List α) (p q : α → Bool) : + xs.countP p ≤ xs.countP (fun x => p x && !q x) + xs.countP q := by + induction xs with + | nil => simp + | cons x xs ih => + cases hp : p x <;> cases hq : q x <;> + simp [hp, hq] at * <;> omega + +abbrev Index := Nat +def indices : List Index := List.range 48 +def triples : List (Index × Index × Index) := cart indices (cart indices indices) +def collision (t : Index × Index × Index) : Bool := + (t.1 == t.2.1) || (t.1 == t.2.2) || (t.2.1 == t.2.2) +def distinctTriples : List (Index × Index × Index) := triples.filter (fun t => !collision t) + +theorem length_indices : indices.length = 48 := by simp [indices] +theorem length_triples : triples.length = 110592 := by + simp [triples, length_cart, length_indices] + +theorem count_index_eq_le (i : Index) : indices.countP (fun j => i == j) ≤ 1 := by + have h := List.count_range (a := i) (n := 48) + have heq : (fun j => i == j) = (fun j => j == i) := by + funext j + exact Bool.beq_comm + rw [heq] + change (List.range 48).count i ≤ 1 + rw [h] + split <;> omega + +theorem count_collision_le : triples.countP collision ≤ 6912 := by + have h12 : triples.countP (fun t => t.1 == t.2.1) ≤ 2304 := by + apply count_cart_le indices (cart indices indices) _ 48 + intro i _ + change (cart indices indices).countP (fun y => i == y.1) ≤ 48 + rw [count_cart_left indices indices (fun j => i == j), length_indices] + have := count_index_eq_le i + omega + have h13 : triples.countP (fun t => t.1 == t.2.2) ≤ 2304 := by + apply count_cart_le indices (cart indices indices) _ 48 + intro i _ + change (cart indices indices).countP (fun y => i == y.2) ≤ 48 + rw [count_cart_right indices indices (fun j => i == j), length_indices] + have := count_index_eq_le i + omega + have h23 : triples.countP (fun t => t.2.1 == t.2.2) ≤ 2304 := by + change (cart indices (cart indices indices)).countP (fun t => t.2.1 == t.2.2) ≤ 2304 + rw [count_cart_right indices (cart indices indices) (fun t => t.1 == t.2), length_indices] + have h : (cart indices indices).countP (fun t => t.1 == t.2) ≤ 48 := by + apply count_cart_le indices indices _ 1 + intro i _ + exact count_index_eq_le i + omega + have hA := count_union_le triples (fun t => t.1 == t.2.1) (fun t => t.1 == t.2.2) + have hB := count_union_le triples + (fun t => (t.1 == t.2.1) || (t.1 == t.2.2)) (fun t => t.2.1 == t.2.2) + unfold collision + omega + +theorem majority_exists (g : Index → Bool) : + ∃ b : Bool, 24 ≤ indices.countP (fun i => g i == b) := by + have h := List.length_eq_countP_add_countP g (l := indices) + have hn : (fun i => decide (¬g i = true)) = (fun i => !g i) := by + funext i + cases g i <;> rfl + rw [hn] at h + rw [length_indices] at h + by_cases ht : 24 ≤ indices.countP g + · exact ⟨true, by simpa using ht⟩ + · refine ⟨false, ?_⟩ + have : 24 ≤ indices.countP (fun i => !g i) := by omega + simpa using this + +def allAgree (p q r : Index → Bool) (t : Index × Index × Index) : Bool := + p t.1 && (q t.2.1 && r t.2.2) + +theorem count_agree_distinct (p q r : Index → Bool) + (hp : 24 ≤ indices.countP p) (hq : 24 ≤ indices.countP q) + (hr : 24 ≤ indices.countP r) : + 6912 ≤ distinctTriples.countP (allAgree p q r) := by + have hprod := count_cart indices (cart indices indices) p + (fun t => q t.1 && r t.2) + rw [count_cart] at hprod + have h1 : 24 * 24 ≤ indices.countP q * indices.countP r := Nat.mul_le_mul hq hr + have h2 : 24 * (24 * 24) ≤ indices.countP p * + (indices.countP q * indices.countP r) := Nat.mul_le_mul hp h1 + have hremove := count_remove triples (allAgree p q r) collision + have hcollision := count_collision_le + change triples.countP (allAgree p q r) = _ at hprod + unfold distinctTriples + rw [List.countP_filter] + omega + +structure Equation (Name : Type) where + first : Name + second : Name + third : Name + rhs : Bool + +variable {Name : Type} + +def satisfied (e : Equation Name) (g : Name → Bool) : Bool := + (xor (xor (g e.first) (g e.second)) (g e.third)) == e.rhs + +def clone (e : Equation Name) (t : Index × Index × Index) : Equation (Name × Index) := + ⟨(e.first, t.1), (e.second, t.2.1), (e.third, t.2.2), e.rhs⟩ + +theorem lift_preserves (e : Equation Name) (t : Index × Index × Index) (g : Name → Bool) : + satisfied (clone e t) (fun z => g z.1) = satisfied e g := rfl + +theorem clone_names_distinct (e : Equation Name) (t : Index × Index × Index) + (h : collision t = false) : + (clone e t).first ≠ (clone e t).second ∧ + (clone e t).first ≠ (clone e t).third ∧ + (clone e t).second ≠ (clone e t).third := by + simp only [collision, Bool.or_eq_false_iff, beq_eq_false_iff_ne] at h + dsimp [clone] + exact ⟨fun he => h.1.1 (congrArg Prod.snd he), + fun he => h.1.2 (congrArg Prod.snd he), + fun he => h.2 (congrArg Prod.snd he)⟩ + +theorem agree_failure (e : Equation Name) (g : Name × Index → Bool) + (majority : Name → Bool) (t : Index × Index × Index) + (hfail : satisfied e majority = false) + (h : allAgree (fun i => g (e.first, i) == majority e.first) + (fun i => g (e.second, i) == majority e.second) + (fun i => g (e.third, i) == majority e.third) t = true) : + satisfied (clone e t) g = false := by + simp only [allAgree, Bool.and_eq_true, beq_iff_eq] at h + simpa [satisfied, clone, h.1, h.2.1, h.2.2] using hfail + +theorem failed_occurrence_clones (e : Equation Name) (g : Name × Index → Bool) + (majority : Name → Bool) + (hmaj : ∀ v, 24 ≤ indices.countP (fun i => g (v, i) == majority v)) + (hfail : satisfied e majority = false) : + 6912 ≤ distinctTriples.countP (fun t => !satisfied (clone e t) g) := by + have h := count_agree_distinct + (fun i => g (e.first, i) == majority e.first) + (fun i => g (e.second, i) == majority e.second) + (fun i => g (e.third, i) == majority e.third) + (hmaj _) (hmaj _) (hmaj _) + apply Nat.le_trans h + apply List.countP_mono_left + intro t _ ht + have hf := agree_failure e g majority t hfail ht + simp [hf] + +def majorityBit (g : Index → Bool) : Bool := decide (24 ≤ indices.countP g) + +theorem majorityBit_count (g : Index → Bool) : + 24 ≤ indices.countP (fun i => g i == majorityBit g) := by + have h := List.length_eq_countP_add_countP g (l := indices) + have hn : (fun i => decide (¬g i = true)) = (fun i => !g i) := by + funext i + cases g i <;> rfl + rw [hn, length_indices] at h + by_cases ht : 24 ≤ indices.countP g + · simp [majorityBit, ht] + · have hn : 24 ≤ indices.countP (fun i => !g i) := by omega + simpa [majorityBit, ht] using hn + +def cloneList (source : List (Equation Name)) : List (Equation (Name × Index)) := + source.flatMap fun e => distinctTriples.map (clone e) + +theorem length_cloneList (source : List (Equation Name)) : + (cloneList source).length = source.length * distinctTriples.length := by + induction source with + | nil => simp [cloneList] + | cons e es ih => + simp only [cloneList, List.flatMap_cons, List.length_append, List.length_map] at * + rw [ih] + simp [Nat.add_mul, Nat.add_comm] + +theorem cloneList_failure_lower (source : List (Equation Name)) + (g : Name × Index → Bool) (majority : Name → Bool) + (hmaj : ∀ v, 24 ≤ indices.countP (fun i => g (v, i) == majority v)) : + 6912 * source.countP (fun e => !satisfied e majority) ≤ + (cloneList source).countP (fun e => !satisfied e g) := by + induction source with + | nil => simp [cloneList] + | cons e es ih => + simp only [cloneList, List.flatMap_cons, List.countP_append, + List.countP_map, Function.comp_def] at * + cases hf : satisfied e majority with + | false => + have he := failed_occurrence_clones e g majority hmaj hf + simp [hf, Nat.mul_add] at * + omega + | true => + simp [hf] + omega + +theorem clone_gap (source : List (Equation Name)) + (source_gap : ∀ A : Name → Bool, + source.length ≤ 4 * source.countP (fun e => !satisfied e A)) + (g : Name × Index → Bool) : + (cloneList source).length ≤ + 64 * (cloneList source).countP (fun e => !satisfied e g) := by + let majority : Name → Bool := fun v => majorityBit (fun i => g (v, i)) + have hmaj : ∀ v, 24 ≤ indices.countP (fun i => g (v, i) == majority v) := + fun v => majorityBit_count (fun i => g (v, i)) + have hlocal := cloneList_failure_lower source g majority hmaj + have hsource := source_gap majority + have hd : distinctTriples.length ≤ 110592 := by + exact Nat.le_trans (List.length_filter_le _ triples) (by simp [length_triples]) + rw [length_cloneList] + have hlength := Nat.mul_le_mul_left source.length hd + have hs := Nat.mul_le_mul_right 27648 hsource + have hc := Nat.mul_le_mul_left 64 hlocal + omega + +theorem clone_completeness_count (source : List (Equation Name)) (A : Name → Bool) : + (cloneList source).countP (fun e => satisfied e (fun z => A z.1)) = + source.countP (fun e => satisfied e A) * distinctTriples.length := by + induction source with + | nil => simp [cloneList] + | cons e es ih => + simp only [cloneList, List.flatMap_cons, List.countP_append, + List.countP_map, Function.comp_def] at * + rw [ih] + have he : (fun t => satisfied (clone e t) (fun z => A z.1)) = + (fun _ => satisfied e A) := by + funext t + exact lift_preserves e t A + rw [he, count_const] + cases h : satisfied e A <;> simp [h, Nat.add_mul, Nat.add_comm] + +end IndependentSetsGames.Reduction.CloneGap + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/CodeComposition.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/CodeComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e12d9207f0593e46210163d65dcabe0977bfc85 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/CodeComposition.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Walsh + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.CodeComposition + +open scoped BigOperators +open IndependentSetsGames.Foundations.Hastad + +def disagreement (a b : Bool) : ℝ := if a = b then 0 else 1 + +@[simp] theorem disagreement_self (a : Bool) : disagreement a a = 0 := by + simp [disagreement] + +theorem disagreement_nonnegative (a b : Bool) : 0 ≤ disagreement a b := by + cases a <;> cases b <;> norm_num [disagreement] + +theorem disagreement_le_one (a b : Bool) : disagreement a b ≤ 1 := by + cases a <;> cases b <;> norm_num [disagreement] + +theorem disagreement_comm (a b : Bool) : disagreement a b = disagreement b a := by + simp [disagreement, eq_comm] + +theorem disagreement_triangle (a b c : Bool) : + disagreement a c ≤ disagreement a b + disagreement b c := by + cases a <;> cases b <;> cases c <;> norm_num [disagreement] + +theorem disagreement_eq_sign (a b : Bool) : + disagreement a b = (1 - bitSign a * bitSign b) / 2 := by + cases a <;> cases b <;> norm_num [disagreement, bitSign] + +def relativeDistance {X : Type*} [Fintype X] (f g : X → Bool) : ℝ := + 𝔼 x, disagreement (f x) (g x) + +@[simp] theorem relativeDistance_self {X : Type*} [Fintype X] (f : X → Bool) : + relativeDistance f f = 0 := by + simp [relativeDistance] + +theorem relativeDistance_nonnegative {X : Type*} [Fintype X] (f g : X → Bool) : + 0 ≤ relativeDistance f g := + Finset.expect_nonneg (fun _ _ => disagreement_nonnegative _ _) + +theorem relativeDistance_comm {X : Type*} [Fintype X] (f g : X → Bool) : + relativeDistance f g = relativeDistance g f := by + simp only [relativeDistance, disagreement_comm] + +theorem relativeDistance_triangle {X : Type*} [Fintype X] (f g h : X → Bool) : + relativeDistance f h ≤ relativeDistance f g + relativeDistance g h := by + rw [relativeDistance, relativeDistance, relativeDistance, + ← Finset.expect_add_distrib] + exact Finset.expect_le_expect (fun _ _ => disagreement_triangle _ _ _) + +theorem relativeDistance_eq_sign {X : Type*} [Fintype X] [Nonempty X] + (f g : X → Bool) : + relativeDistance f g = (1 - 𝔼 x, bitSign (f x) * bitSign (g x)) / 2 := by + simp only [relativeDistance, disagreement_eq_sign] + rw [← Finset.expect_div, Finset.expect_sub_distrib] + simp + +def codeword {A : Type*} (a : A) : Cube A → Bool := fun x => x a + +private def singletonMask {A : Type*} [DecidableEq A] (a : A) : Cube A := + fun i => decide (i = a) + +private theorem walsh_singletonMask {A : Type*} [Fintype A] [DecidableEq A] + (a : A) (x : Cube A) : walsh (singletonMask a) x = bitSign (x a) := by + classical + unfold walsh singletonMask + rw [Finset.prod_eq_single a] + · simp + · intro b _ hba + simp [hba, bitSign] + · simp + +private theorem singletonMask_ne {A : Type*} [DecidableEq A] {a b : A} (hab : a ≠ b) : + singletonMask a ≠ singletonMask b := by + intro h + have he := congrFun h a + simp [singletonMask, hab] at he + +theorem codeword_distance {A : Type*} [Fintype A] [DecidableEq A] + {a b : A} (hab : a ≠ b) : + relativeDistance (codeword a) (codeword b) = 1 / 2 := by + rw [relativeDistance_eq_sign] + have horth := walsh_orthogonality (singletonMask a) (singletonMask b) + rw [ite_eq_right (singletonMask_ne hab)] at horth + simp_rw [walsh_singletonMask] at horth + change (1 - 𝔼 x : Cube A, bitSign (x a) * bitSign (x b)) / 2 = 1 / 2 + rw [horth] + norm_num + +theorem exists_nearest {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + (f : Cube A → Bool) : + ∃ a : A, ∀ b : A, relativeDistance f (codeword a) ≤ relativeDistance f (codeword b) := by + classical + obtain ⟨a, _, ha⟩ := Finset.exists_min_image Finset.univ + (fun a : A => relativeDistance f (codeword a)) Finset.univ_nonempty + exact ⟨a, fun b => ha b (Finset.mem_univ b)⟩ + +def nearest {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] (f : Cube A → Bool) : A := + Classical.choose (exists_nearest f) + +theorem nearest_minimal {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + (f : Cube A → Bool) (a : A) : + relativeDistance f (codeword (nearest f)) ≤ relativeDistance f (codeword a) := + Classical.choose_spec (exists_nearest f) a + +theorem distance_from_other_codeword {A : Type*} [Fintype A] [DecidableEq A] + [Nonempty A] (f : Cube A → Bool) {a : A} (ha : a ≠ nearest f) : + 1 / 4 ≤ relativeDistance f (codeword a) := by + have htri := relativeDistance_triangle (codeword (nearest f)) f (codeword a) + rw [codeword_distance (Ne.symm ha), relativeDistance_comm (codeword (nearest f)) f] at htri + have hmin := nearest_minimal f a + linarith + +def pairWord {X : Type*} (left right : X → Bool) : Bool × X → Bool := + fun p => if p.1 then right p.2 else left p.2 + +theorem pairWord_distance {X : Type*} [Fintype X] [Nonempty X] + (left right left' right' : X → Bool) : + relativeDistance (pairWord left right) (pairWord left' right') = + (relativeDistance left left' + relativeDistance right right') / 2 := by + classical + simp [relativeDistance, Fintype.expect_eq_sum_div_card, Fintype.card_prod, + Fintype.sum_prod_type, pairWord] + ring + +theorem rejected_pair_far {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + (accepts : A → A → Bool) (left right : Cube A → Bool) + (hbad : accepts (nearest left) (nearest right) = false) + (a b : A) (hgood : accepts a b = true) : + 1 / 8 ≤ relativeDistance (pairWord left right) + (pairWord (codeword a) (codeword b)) := by + rw [pairWord_distance] + have hleft := relativeDistance_nonnegative left (codeword a) + have hright := relativeDistance_nonnegative right (codeword b) + by_cases ha : a = nearest left + · have hb : b ≠ nearest right := by + intro hb + rw [ha, hb, hbad] at hgood + cases hgood + have hsep := distance_from_other_codeword right hb + linarith + · have hsep := distance_from_other_codeword left ha + linarith + +end IndependentSetsGames.Foundations.PCP.CodeComposition +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/CompareLoop.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/CompareLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..c144f6614ca07b37f76099391d1e5dc40073a848 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/CompareLoop.lean @@ -0,0 +1,225 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Semantics +import OAI.Combinatorics.IndependentSets.PCP.ClauseVerifier +import OAI.Combinatorics.IndependentSets.Machines.MachineFieldProfile + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.CompareLoop + +open Turing +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel + +inductive Label + | leftFirst | leftSecond | rightFirst | rightSecond | compare + | equalStore | differentStore + deriving DecidableEq + +instance : Fintype Label where + elems := {.leftFirst, .leftSecond, .rightFirst, .rightSecond, .compare, + .equalStore, .differentStore} + complete label := by cases label <;> simp + +variable {q : Nat} {Λ : Type} + +def statement (labels : Label → Λ) (next : Λ) : + Label → TM2.Stmt Alphabet Λ (State q) + | .leftFirst => compareStatement (MachineFieldProfile.copyStatement + (Reduction.MachineTransfer.loopAt .tail .scratch id false + (labels .leftFirst) (some (labels .leftSecond)))) + | .leftSecond => compareStatement (MachineFieldProfile.copyStatement + (MachineCopy.forkLoop .scratch .tail .compareLeft false + (labels .leftSecond) (some (labels .rightFirst)))) + | .rightFirst => compareStatement (MachineFieldProfile.copyStatement + (Reduction.MachineTransfer.loopAt .head .scratch id false + (labels .rightFirst) (some (labels .rightSecond)))) + | .rightSecond => compareStatement (MachineFieldProfile.copyStatement + (MachineCopy.forkLoop .scratch .head .compareRight false + (labels .rightSecond) (some (labels .compare)))) + | .compare => compareStatement (MachineCompare.loop .compareLeft .compareRight + (labels .compare) (some (labels .equalStore)) (some (labels .differentStore))) + | .equalStore => storeLoop true next + | .differentStore => storeLoop false next + +private theorem compareProgram_at + (program : Λ → TM2.Stmt Alphabet Λ (State q)) (label : Λ) + (stmt : TM2.Stmt Alphabet Λ + (MachineCompare.State (GenericGraphTables.RelationTable q × Bool))) + (atLabel : program label = compareStatement stmt) : + (MachineControl.program (Equiv.refl Λ) (compareEquiv q) program) label = stmt := by + change MachineControl.statement id (compareEquiv q) (program label) = stmt + rw [atLabel] + exact MachineFieldProfile.statement_roundtrip (compareEquiv q) stmt + +def compareWordsInTime (labels : Label → Λ) (next : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State q)) + (atLabel : ∀ label, program (labels label) = statement labels next label) + (base : Tape → List Bool) + (hLeft : base .compareLeft = []) (hRight : base .compareRight = []) + (hScratch : base .scratch = []) + (relation : GenericGraphTables.RelationTable q) (oldLoop : Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .leftFirst), normal relation oldLoop, base⟩ + (some ⟨some next, normal relation (decide (base .tail = base .head)), base⟩) + (2 * ((base .tail).length + 1) + 2 * ((base .head).length + 1) + + max (base .tail).length (base .head).length + 2) := by + let view := MachineControl.program (Equiv.refl Λ) (compareEquiv q) program + have compared := MachineFieldProfile.nonDestructiveCompareInTime + Tape.tail Tape.head Tape.compareLeft Tape.compareRight Tape.scratch + (by decide) (by decide) (by decide) + (labels .leftFirst) (labels .leftSecond) (labels .rightFirst) + (labels .rightSecond) (labels .compare) + (some (labels .equalStore)) (some (labels .differentStore)) view + (compareProgram_at program _ _ (atLabel .leftFirst)) + (compareProgram_at program _ _ (atLabel .leftSecond)) + (compareProgram_at program _ _ (atLabel .rightFirst)) + (compareProgram_at program _ _ (atLabel .rightSecond)) + (compareProgram_at program _ _ (atLabel .compare)) + base hLeft hRight hScratch (relation, oldLoop) + have restoredProgram : + MachineControl.program (Equiv.refl Λ) (compareEquiv q).symm view = program := by + funext label + exact MachineFieldProfile.statement_roundtrip (compareEquiv q).symm (program label) + have transported := transportInTime (compareEquiv q).symm view compared + rw [restoredProgram] at transported + have copied : StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .leftFirst), normal relation oldLoop, base⟩ + (some ⟨if base .tail = base .head then some (labels .equalStore) + else some (labels .differentStore), normal relation oldLoop, base⟩) + (2 * ((base .tail).length + 1) + 2 * ((base .head).length + 1) + + max (base .tail).length (base .head).length + 1) := by + simpa [MachineControl.configuration, compareEquiv, MachineFieldProfile.normalState, + normal] using transported + have stored : StateTransition.EvalsToInTime (TM2.step program) + ⟨if base .tail = base .head then some (labels .equalStore) + else some (labels .differentStore), normal relation oldLoop, base⟩ + (some ⟨some next, normal relation (decide (base .tail = base .head)), base⟩) 1 := { + steps := 1 + evals_in_steps := by + change TM2.step program + ⟨if base .tail = base .head then some (labels .equalStore) + else some (labels .differentStore), normal relation oldLoop, base⟩ = _ + by_cases heq : base .tail = base .head + · simp [heq, TM2.step, atLabel, statement, stepAux_storeLoop, normal] + · simp [heq, TM2.step, atLabel, statement, stepAux_storeLoop, normal] + steps_le_m := Nat.le_refl _ + } + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ copied stored + exact { toEvalsTo := run.toEvalsTo, steps_le_m := by have h := run.steps_le_m; omega } + +def comparisonTime (tailName headName : Nat) : Nat := + 2 * (tailName + 2) + 2 * (headName + 2) + max (tailName + 1) (headName + 1) + 2 + +theorem encodeWord_eq_iff (left right : Nat) : + encodeWord left = encodeWord right ↔ left = right := by + constructor + · intro h + have hh := congrArg List.length h + simpa only [encodeWord_length, Nat.add_right_cancel_iff] using hh + · rintro rfl + rfl + +def compareInTime (labels : Label → Λ) (next : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State q)) + (atLabel : ∀ label, program (labels label) = statement labels next label) + (base : Tape → List Bool) (tailName headName : Nat) + (hTail : base .tail = encodeWord tailName) (hHead : base .head = encodeWord headName) + (hLeft : base .compareLeft = []) (hRight : base .compareRight = []) + (hScratch : base .scratch = []) + (relation : GenericGraphTables.RelationTable q) (oldLoop : Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .leftFirst), normal relation oldLoop, base⟩ + (some ⟨some next, normal relation (decide (tailName = headName)), base⟩) + (comparisonTime tailName headName) := by + have run := compareWordsInTime labels next program atLabel base hLeft hRight hScratch + relation oldLoop + simpa only [hTail, hHead, encodeWord_eq_iff, encodeWord_length, comparisonTime, + Nat.add_assoc] using run + +theorem comparisonTime_le (tailName headName N : Nat) + (hTail : tailName ≤ N) (hHead : headName ≤ N) : + comparisonTime tailName headName ≤ 5 * N + 11 := by + have hm : max (tailName + 1) (headName + 1) ≤ N + 1 := max_le (by omega) (by omega) + unfold comparisonTime + omega + +theorem comparisonTime_le_of_lt (tailName headName N : Nat) + (hTail : tailName < N) (hHead : headName < N) : + comparisonTime tailName headName ≤ 5 * N + 6 := by + have hm : max (tailName + 1) (headName + 1) ≤ N := max_le (by omega) (by omega) + unfold comparisonTime + omega + +def compareWordsInTime_bounded (labels : Label → Λ) (next : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State q)) + (atLabel : ∀ label, program (labels label) = statement labels next label) + (base : Tape → List Bool) + (hLeft : base .compareLeft = []) (hRight : base .compareRight = []) + (hScratch : base .scratch = []) + (relation : GenericGraphTables.RelationTable q) (oldLoop : Bool) + (N : Nat) (hTail : (base .tail).length ≤ N) (hHead : (base .head).length ≤ N) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .leftFirst), normal relation oldLoop, base⟩ + (some ⟨some next, normal relation (decide (base .tail = base .head)), base⟩) + (5 * N + 6) := by + let run := compareWordsInTime labels next program atLabel base hLeft hRight hScratch + relation oldLoop + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have hm := max_le hTail hHead + have h := run.steps_le_m + omega + +def rowLoop (table : GenericGraphTables.Table q) (e : Fin table.darts) : Bool := + decide (table.rows[e].tail.val = table.rows[table.rows[e].reverseIndex].tail.val) + +def rowState (table : GenericGraphTables.Table q) (e : Fin table.darts) : State q := + normal table.rows[e].relation (rowLoop table e) + +theorem rowLoop_eq_graph (table : GenericGraphTables.Table q) (e : Fin table.darts) : + rowLoop table e = decide ((GenericGraphTables.semantics table).tail e = + (GenericGraphTables.semantics table).head e) := by + unfold rowLoop + exact Bool.decide_congr Fin.val_inj + +theorem rowContext_eq (table : GenericGraphTables.Table q) (e : Fin table.darts) : + context (rowState table e).1 = + (table.rows[e].relation, decide ((GenericGraphTables.semantics table).tail e = + (GenericGraphTables.semantics table).head e)) := by + change (table.rows[e].relation, rowLoop table e) = _ + rw [rowLoop_eq_graph] + +def compareRowInTime (labels : Label → Λ) (next : Λ) + (program : Λ → TM2.Stmt Alphabet Λ (State q)) + (atLabel : ∀ label, program (labels label) = statement labels next label) + (table : GenericGraphTables.Table q) (e : Fin table.darts) + (base : Tape → List Bool) + (hTail : base .tail = encodeWord table.rows[e].tail.val) + (hHead : base .head = encodeWord table.rows[table.rows[e].reverseIndex].tail.val) + (hLeft : base .compareLeft = []) (hRight : base .compareRight = []) + (hScratch : base .scratch = []) (oldLoop : Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .leftFirst), normal table.rows[e].relation oldLoop, base⟩ + (some ⟨some next, rowState table e, base⟩) (5 * table.vertices + 6) := by + let run := compareInTime labels next program atLabel base _ _ hTail hHead + hLeft hRight hScratch table.rows[e].relation oldLoop + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + exact run.steps_le_m.trans (comparisonTime_le_of_lt _ _ _ + table.rows[e].tail.isLt table.rows[table.rows[e].reverseIndex].tail.isLt) + +theorem relationFromRowState (table : GenericGraphTables.Table q) (e : Fin table.darts) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) + (a b : GraphTables.Label) : + GraphTables.relationAt + (Relations.relationFromTable (context (rowState table e).1).1 + (context (rowState table e).1).2 event slot orientation) a b = + (AlphabetGraph.graph (GenericGraphTables.semantics table)).accepts + (((e, event), slot), orientation) + (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b) := by + rw [rowContext_eq] + exact Relations.relationAt_relation_graph (GenericGraphTables.semantics table) + e event slot orientation a b + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.CompareLoop + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/ConstraintGraph.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/ConstraintGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..67c3a544ac131fe374b5e2ab2403a73498d845ce --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/ConstraintGraph.lean @@ -0,0 +1,73 @@ +import Mathlib + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP + +structure ConstraintGraph (V E A : Type*) where + reverse : E ≃ E + reverse_involutive : Function.Involutive reverse + tail : E → V + accepts : E → A → A → Bool + reverse_accepts : ∀ e a b, accepts (reverse e) b a = accepts e a b + +namespace ConstraintGraph + +variable {V E A : Type*} + +def head (G : ConstraintGraph V E A) (e : E) : V := G.tail (G.reverse e) + +@[simp] theorem head_reverse (G : ConstraintGraph V E A) (e : E) : + G.head (G.reverse e) = G.tail e := by + simp only [head, G.reverse_involutive e] + +def edgeSatisfied (G : ConstraintGraph V E A) (labeling : V → A) (e : E) : Bool := + G.accepts e (labeling (G.tail e)) (labeling (G.head e)) + +@[simp] theorem edgeSatisfied_reverse (G : ConstraintGraph V E A) + (labeling : V → A) (e : E) : + G.edgeSatisfied labeling (G.reverse e) = G.edgeSatisfied labeling e := by + simpa only [edgeSatisfied, head, G.reverse_involutive e] using + G.reverse_accepts e (labeling (G.tail e)) (labeling (G.tail (G.reverse e))) + +def Satisfiable (G : ConstraintGraph V E A) : Prop := + ∃ labeling : V → A, ∀ e, G.edgeSatisfied labeling e = true + +def rejectedDarts [Fintype E] (G : ConstraintGraph V E A) (labeling : V → A) : + Finset E := Finset.univ.filter (fun e => G.edgeSatisfied labeling e = false) + +def rejectionCount [Fintype E] (G : ConstraintGraph V E A) (labeling : V → A) : Nat := + (G.rejectedDarts labeling).card + +theorem mem_rejectedDarts [Fintype E] (G : ConstraintGraph V E A) + (labeling : V → A) (e : E) : + e ∈ G.rejectedDarts labeling ↔ G.edgeSatisfied labeling e = false := by + simp [rejectedDarts] + +theorem rejectionCount_le [Fintype E] (G : ConstraintGraph V E A) + (labeling : V → A) : G.rejectionCount labeling ≤ Fintype.card E := by + exact Finset.card_le_card (Finset.filter_subset _ _) + +theorem rejected_exists_of_not_satisfiable (G : ConstraintGraph V E A) + (unsat : ¬ G.Satisfiable) (labeling : V → A) : + ∃ e, G.edgeSatisfied labeling e = false := by + classical + by_contra none + apply unsat + refine ⟨labeling, fun e => ?_⟩ + have notFalse : G.edgeSatisfied labeling e ≠ false := by + intro h + exact none ⟨e, h⟩ + cases h : G.edgeSatisfied labeling e <;> simp_all + +theorem rejectionCount_positive [Fintype E] (G : ConstraintGraph V E A) + (unsat : ¬ G.Satisfiable) (labeling : V → A) : + 1 ≤ G.rejectionCount labeling := by + obtain ⟨e, he⟩ := G.rejected_exists_of_not_satisfiable unsat labeling + exact Finset.one_le_card.mpr ⟨e, (G.mem_rejectedDarts labeling e).mpr he⟩ + +end ConstraintGraph + +end IndependentSetsGames.Foundations.PCP + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Driver.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Driver.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb210fe9f8c426fb1a2cedc8ab3081a92638a6b5 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Driver.lean @@ -0,0 +1,290 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Setup +import OAI.Combinatorics.IndependentSets.PCP.ReadRelation +import OAI.Combinatorics.IndependentSets.PCP.Lookup +import OAI.Combinatorics.IndependentSets.PCP.CompareLoop +import OAI.Combinatorics.IndependentSets.PCP.EmitRows +import OAI.Combinatorics.IndependentSets.PCP.Cleanup + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Driver + +open Turing +open IndependentSetsGames.Foundations.Complexity +open IndependentSetsGames.Foundations.Hastad +open RuntimeModel + +def headerPlan (q : Nat) := EmitRows.headerCommands q (Ambient q) +def rowPlan (q : Nat) := EmitRows.blockCommandsIn q (@context q) + +inductive Label (q : Nat) + | setup (label : Setup.Label) + | header (label : Emitter.Label (headerPlan q).length (Addresses.fieldBound q)) + | guard | tailStart | tailLoop | reverseStart | reverseLoop | readPredicate + | headCopyFirst | headCopySecond | indexCopyFirst | indexCopySecond + | headVertices | headDarts | headLookup (label : Lookup.Label) + | compare (label : CompareLoop.Label) + | emit (label : Emitter.Label (rowPlan q).length (Addresses.fieldBound q)) + | clearField (slot : Fin 3) + | increment | reverseOutput | cleanup (slot : Fin 16) + deriving DecidableEq, Fintype + +def headerEntry (q : Nat) : Label q := + .header (Emitter.labelAt (headerPlan q).length (Addresses.fieldBound q) 0 .entry) + +def rowEntry (q : Nat) : Label q := + .emit (Emitter.labelAt (rowPlan q).length (Addresses.fieldBound q) 0 .entry) + +def clearNext {q : Nat} (slot : Fin 3) : Label q := + if h : slot.val < 2 then .clearField ⟨slot.val + 1, by omega⟩ else .increment + +def program (q : Nat) : Label q → TM2.Stmt Alphabet (Label q) (State q) + | .setup label => Setup.statement setupPorts Label.setup (some (headerEntry q)) label + | .header label => emitterStatement + (Emitter.statement (Emitter.listCommands (headerPlan q)) headerSources .scratch .reversed + Label.header (some .guard) label) + | .guard => MachineUnaryCounter.guard .counter .tailStart .reverseOutput + | .tailStart => SourceMachine.fieldStart .tail .tailLoop + | .tailLoop => SourceMachine.fieldLoop .cursor .tail .tailLoop (some .reverseStart) + | .reverseStart => SourceMachine.fieldStart .reverseIndex .reverseLoop + | .reverseLoop => SourceMachine.fieldLoop .cursor .reverseIndex .reverseLoop (some .readPredicate) + | .readPredicate => ReadRelation.parser .cursor .headCopyFirst + | .headCopyFirst => Reduction.MachineTransfer.loopAt .original .scratch id false + .headCopyFirst (some .headCopySecond) + | .headCopySecond => MachineCopy.forkLoop .scratch .original .scan false + .headCopySecond (some .indexCopyFirst) + | .indexCopyFirst => Reduction.MachineTransfer.loopAt .reverseIndex .scratch id false + .indexCopyFirst (some .indexCopySecond) + | .indexCopySecond => MachineCopy.forkLoop .scratch .reverseIndex .indexScan false + .indexCopySecond (some .headVertices) + | .headVertices => MachineLookup.discard .scan .headVertices .headDarts + | .headDarts => MachineLookup.discard .scan .headDarts (.headLookup .guard) + | .headLookup label => Lookup.statement q .indexScan .scan .head Label.headLookup + (some (.compare .leftFirst)) label + | .compare label => CompareLoop.statement Label.compare (rowEntry q) label + | .emit label => emitterStatement + (Emitter.statement (Emitter.listCommands (rowPlan q)) rowSources .scratch .reversed + Label.emit (some (.clearField 0)) label) + | .clearField slot => MachineDrain.drain (fieldPorts slot) (.clearField slot) + (some (clearNext slot)) + | .increment => nextRow .guard + | .reverseOutput => Reduction.MachineTransfer.loopAt .reversed .output id false + .reverseOutput (some (.cleanup 0)) + | .cleanup slot => Cleanup.instruction cleanupPorts Label.cleanup (initial q).1 none slot + +def machine (q : Nat) : FinTM2 := by + letI := ReadRelation.stateFintype Flags q + exact { + K := Tape + k₀ := .original + k₁ := .output + Γ := Alphabet + Λ := Label q + main := .setup .copyFirst + σ := State q + initialState := initial q + m := program q } + +@[simp] theorem program_setup (q : Nat) (label : Setup.Label) : + program q (.setup label) = + Setup.statement setupPorts Label.setup (some (headerEntry q)) label := rfl + +@[simp] theorem program_guard (q : Nat) : program q .guard = + MachineUnaryCounter.guard .counter .tailStart .reverseOutput := rfl + +@[simp] theorem program_headLookup (q : Nat) (label : Lookup.Label) : + program q (.headLookup label) = Lookup.statement q .indexScan .scan .head + Label.headLookup (some (.compare .leftFirst)) label := rfl + +@[simp] theorem program_compare (q : Nat) (label : CompareLoop.Label) : + program q (.compare label) = CompareLoop.statement Label.compare (rowEntry q) label := rfl + +@[simp] theorem program_increment (q : Nat) : program q .increment = nextRow .guard := rfl + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Driver +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.LoopState + +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel + +variable {q : Nat} + +def inputBits (input : GenericGraphTables.Table q) : List Bool := + GenericGraphTables.tableBits input + +def prefixWords (input : GenericGraphTables.Table q) (e : Nat) : List Nat := + [Enumeration.vertexCount input.vertices input.darts q, + Enumeration.dartCount input.darts q] ++ + ((List.finRange input.darts).take e).flatMap (EmitRows.blockWords input) + +def prefixBits (input : GenericGraphTables.Table q) (e : Nat) : List Bool := + encodeWords (prefixWords input e) + +def cursorWords (input : GenericGraphTables.Table q) (e : Nat) : List Nat := + ((GenericGraphTables.rowList input).drop e).flatMap GenericGraphTables.rowWords + +def cursorBits (input : GenericGraphTables.Table q) (e : Nat) : List Bool := + encodeWords (cursorWords input e) + +@[simp] theorem prefixWords_zero (input : GenericGraphTables.Table q) : + prefixWords input 0 = + [Enumeration.vertexCount input.vertices input.darts q, + Enumeration.dartCount input.darts q] := by + simp [prefixWords] + +@[simp] theorem prefixBits_zero (input : GenericGraphTables.Table q) : + prefixBits input 0 = encodeWords + [Enumeration.vertexCount input.vertices input.darts q, + Enumeration.dartCount input.darts q] := by + rw [prefixBits, prefixWords_zero] + +theorem prefixWords_succ (input : GenericGraphTables.Table q) (e : Nat) + (he : e < input.darts) : + prefixWords input (e + 1) = + prefixWords input e ++ EmitRows.blockWords input ⟨e, he⟩ := by + have bound : e < (List.finRange input.darts).length := by simpa using he + have take := List.take_succ_eq_append_getElem bound + have atIndex : (List.finRange input.darts)[e]'bound = (⟨e, he⟩ : Fin input.darts) := by + simp + rw [atIndex] at take + unfold prefixWords + rw [take, List.flatMap_append] + simp only [List.flatMap_cons, List.flatMap_nil, List.append_nil, List.append_assoc] + +theorem prefixBits_succ (input : GenericGraphTables.Table q) (e : Nat) + (he : e < input.darts) : + prefixBits input (e + 1) = + prefixBits input e ++ encodeWords (EmitRows.blockWords input ⟨e, he⟩) := by + rw [prefixBits, prefixWords_succ input e he, encodeWords_append] + rfl + +theorem prefixBits_reverse_succ (input : GenericGraphTables.Table q) (e : Nat) + (he : e < input.darts) : + (prefixBits input (e + 1)).reverse = + (encodeWords (EmitRows.blockWords input ⟨e, he⟩)).reverse ++ + (prefixBits input e).reverse := by + rw [prefixBits_succ input e he, List.reverse_append] + +theorem prefixWords_full (input : GenericGraphTables.Table q) : + prefixWords input input.darts = GraphTables.tableWords (Table.build input) := by + have allRows : (List.finRange input.darts).take input.darts = List.finRange input.darts := by + apply List.take_of_length_le + simp + unfold prefixWords + rw [allRows] + exact (EmitRows.tableWords_eq_blocks input).symm + +theorem prefixBits_full (input : GenericGraphTables.Table q) : + prefixBits input input.darts = GraphTables.tableBits (Table.build input) := by + rw [prefixBits, prefixWords_full] + rfl + +@[simp] theorem cursorBits_zero (input : GenericGraphTables.Table q) : + cursorBits input 0 = + encodeWords ((GenericGraphTables.rowList input).flatMap GenericGraphTables.rowWords) := by + simp [cursorBits, cursorWords] + +theorem cursorWords_succ (input : GenericGraphTables.Table q) (e : Nat) + (he : e < input.darts) : + cursorWords input e = + GenericGraphTables.rowWords input.rows[(⟨e, he⟩ : Fin input.darts)] ++ + cursorWords input (e + 1) := by + have bound : e < (GenericGraphTables.rowList input).length := by + simpa only [GenericGraphTables.rowList_length] using he + unfold cursorWords + rw [List.drop_eq_getElem_cons bound, List.flatMap_cons] + simp only [GenericGraphTables.rowList, Vector.getElem_toList, Fin.getElem_fin] + +theorem cursorBits_succ (input : GenericGraphTables.Table q) (e : Nat) + (he : e < input.darts) : + cursorBits input e = + encodeWords (GenericGraphTables.rowWords input.rows[(⟨e, he⟩ : Fin input.darts)]) ++ + cursorBits input (e + 1) := by + rw [cursorBits, cursorWords_succ input e he, encodeWords_append] + rfl + +@[simp] theorem cursorBits_full (input : GenericGraphTables.Table q) : + cursorBits input input.darts = [] := by + have finished := List.drop_length (l := GenericGraphTables.rowList input) + rw [GenericGraphTables.rowList_length] at finished + unfold cursorBits cursorWords + rw [finished] + rfl + +structure Ready (input : GenericGraphTables.Table q) (e : Nat) + (base : Tape → List Bool) : Prop where + le_darts : e ≤ input.darts + original : base .original = inputBits input + cursor : base .cursor = cursorBits input e + vertices : base .vertices = encodeWord input.vertices + darts : base .darts = encodeWord input.darts + counter : base .counter = encodeWord (input.darts - e) + edge : base .edge = encodeWord e + tail : base .tail = [] + reverseIndex : base .reverseIndex = [] + head : base .head = [] + scratch : base .scratch = [] + compareLeft : base .compareLeft = [] + compareRight : base .compareRight = [] + output : base .output = [] + reversed : base .reversed = (prefixBits input e).reverse + +theorem Ready.of_agree {input : GenericGraphTables.Table q} {e : Nat} + {base next : Tape → List Bool} (ready : Ready input e base) + (agree : ∀ tape, tape ≠ .scan → tape ≠ .indexScan → next tape = base tape) : + Ready input e next where + le_darts := ready.le_darts + original := (agree .original (by decide) (by decide)).trans ready.original + cursor := (agree .cursor (by decide) (by decide)).trans ready.cursor + vertices := (agree .vertices (by decide) (by decide)).trans ready.vertices + darts := (agree .darts (by decide) (by decide)).trans ready.darts + counter := (agree .counter (by decide) (by decide)).trans ready.counter + edge := (agree .edge (by decide) (by decide)).trans ready.edge + tail := (agree .tail (by decide) (by decide)).trans ready.tail + reverseIndex := (agree .reverseIndex (by decide) (by decide)).trans ready.reverseIndex + head := (agree .head (by decide) (by decide)).trans ready.head + scratch := (agree .scratch (by decide) (by decide)).trans ready.scratch + compareLeft := (agree .compareLeft (by decide) (by decide)).trans ready.compareLeft + compareRight := (agree .compareRight (by decide) (by decide)).trans ready.compareRight + output := (agree .output (by decide) (by decide)).trans ready.output + reversed := (agree .reversed (by decide) (by decide)).trans ready.reversed + +theorem Ready.update_scan {input : GenericGraphTables.Table q} {e : Nat} + {base : Tape → List Bool} (ready : Ready input e base) (word : List Bool) : + Ready input e (Function.update base .scan word) := by + apply ready.of_agree + intro tape notScan _ + simp [notScan] + +theorem Ready.update_indexScan {input : GenericGraphTables.Table q} {e : Nat} + {base : Tape → List Bool} (ready : Ready input e base) (word : List Bool) : + Ready input e (Function.update base .indexScan word) := by + apply ready.of_agree + intro tape _ notIndexScan + simp [notIndexScan] + +theorem Ready.counter_succ {input : GenericGraphTables.Table q} {e : Nat} + {base : Tape → List Bool} (ready : Ready input e base) (he : e < input.darts) : + base .counter = encodeWord (input.darts - (e + 1) + 1) := by + rw [ready.counter] + congr 1 + omega + +theorem Ready.counter_at_end {input : GenericGraphTables.Table q} + {base : Tape → List Bool} (ready : Ready input input.darts base) : + base .counter = encodeWord 0 := by + simpa only [Nat.sub_self] using ready.counter + +theorem Ready.cursor_at_end {input : GenericGraphTables.Table q} + {base : Tape → List Bool} (ready : Ready input input.darts base) : + base .cursor = [] := ready.cursor.trans (cursorBits_full input) + +theorem Ready.reversed_at_end {input : GenericGraphTables.Table q} + {base : Tape → List Bool} (ready : Ready input input.darts base) : + base .reversed = (GraphTables.tableBits (Table.build input)).reverse := by + rw [ready.reversed, prefixBits_full] + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.LoopState + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/EmitRows.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/EmitRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f9dfd006a228118f650f82a4e290d0c2c827a36 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/EmitRows.lean @@ -0,0 +1,288 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Semantics2 +import OAI.Combinatorics.IndependentSets.PCP.Addresses + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.EmitRows + +open Turing +open IndependentSetsGames.Foundations.Complexity +open Emitter + +abbrev Context (q : Nat) := Vector Bool (q * q) × Bool +abbrev RowCommand (q : Nat) := Command 5 (Context q) (Addresses.fieldBound q) + +def relationBits (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : List (Context q → Bool) := + List.ofFn fun index : Fin 4096 => fun context => + (Relations.relationFromTable context.1 context.2 event slot orientation)[index] + +private theorem vector_list_ofFn {α : Type} {n : Nat} (vector : Vector α n) : + List.ofFn (fun index : Fin n => vector[index]) = vector.toList := by + have equality := congrArg Vector.toList (Vector.ofFn_getElem (xs := vector)) + simpa only [Vector.toList_ofFn, Fin.getElem_fin] using equality + +private theorem bitValues_ofFn {σ : Type} {n : Nat} + (relation : σ → Vector Bool n) (context : σ) : + (List.ofFn (fun index : Fin n => fun state => (relation state)[index])).map + (fun bit => if bit context then 1 else 0) = + (relation context).toList.map GraphTables.bitWord := by + rw [← vector_list_ofFn (relation context)] + simp only [List.map_ofFn] + rfl + +theorem relationBits_values (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) (context : Context q) : + (relationBits q event slot orientation).map (fun bit => if bit context then 1 else 0) = + GraphTables.relationWords + (Relations.relationFromTable context.1 context.2 event slot orientation) := by + exact bitValues_ofFn (fun state : Context q => + Relations.relationFromTable state.1 state.2 event slot orientation) context + +def rowCommands (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : List (RowCommand q) := + affineCommands (Addresses.dartTailTerms q event slot orientation) + (fun context => Addresses.dartTailOffset q event slot orientation + (Relations.oldPredicate context.1)) ++ + affineCommands (Addresses.reverseDartField q event slot orientation).terms + (fun _ => (Addresses.reverseDartField q event slot orientation).offset) ++ + bitCommands (relationBits q event slot orientation) + +def rowContext {q : Nat} (input : GenericGraphTables.Table q) (edge : Fin input.darts) : Context q := + let old := input.rows[edge] + (old.relation, decide (old.tail = input.rows[old.reverseIndex].tail)) + +def rowValues {q : Nat} (input : GenericGraphTables.Table q) + (edge : Fin input.darts) : Fin 5 → Nat := + let old := input.rows[edge] + Addresses.values input.vertices input.darts edge.val old.tail.val + input.rows[old.reverseIndex].tail.val + +private theorem encodedRow {n m : Nat} (row : GraphTables.DartRow n m) : + encodeWords (GraphTables.rowWords row) = + encodeWord row.tail.val ++ (encodeWord row.reverseIndex.val ++ + encodeWords (GraphTables.relationWords row.relation)) := by + simp only [GraphTables.rowWords, List.cons_append, List.nil_append, encodeWords] + +theorem rowCommands_bits {q : Nat} (input : GenericGraphTables.Table q) + (edge : Fin input.darts) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : + (rowCommands q event slot orientation).flatMap + (commandBits (rowValues input edge) (rowContext input edge)) = + encodeWords (GraphTables.rowWords + (Table.rowFromDart input (((edge, event), slot), orientation))) := by + rw [rowCommands, List.flatMap_append, List.flatMap_append, + affineCommands_bits, affineCommands_bits, bitCommands_bits, relationBits_values] + have htail := Addresses.fieldForDartTail_eval input.vertices input.darts q edge + input.rows[edge].tail input.rows[input.rows[edge].reverseIndex].tail event slot orientation + (Relations.oldPredicate input.rows[edge].relation) + have hreverse := Addresses.reverseDartField_eval input.vertices input.darts q edge + event slot orientation input.rows[edge].tail.val + input.rows[input.rows[edge].reverseIndex].tail.val + let row := Table.rowFromDart input (((edge, event), slot), orientation) + have tailEq : affineValue (Addresses.dartTailTerms q event slot orientation) + (rowValues input edge) (Addresses.dartTailOffset q event slot orientation + (Relations.oldPredicate (rowContext input edge).1)).val = row.tail.val := htail + have reverseEq : affineValue (Addresses.reverseDartField q event slot orientation).terms + (rowValues input edge) (Addresses.reverseDartField q event slot orientation).offset.val = + row.reverseIndex.val := hreverse + have relationEq : Relations.relationFromTable (rowContext input edge).1 + (rowContext input edge).2 event slot orientation = row.relation := rfl + rw [encodedRow] + have combined := congrArg₂ (fun a b : List Bool => a ++ b) + (congrArg encodeWord tailEq) + (congrArg₂ (fun a b : List Bool => a ++ b) (congrArg encodeWord reverseEq) + (congrArg (fun relation => encodeWords (GraphTables.relationWords relation)) relationEq)) + simpa only [List.append_assoc] using combined + +def blockCommands (q : Nat) : List (RowCommand q) := + (Enumeration.localEvents q).flatMap fun event => + (List.finRange 6).flatMap fun slot => + [false, true].flatMap fun orientation => rowCommands q event slot orientation + +def blockWords {q : Nat} (input : GenericGraphTables.Table q) + (edge : Fin input.darts) : List Nat := + (Enumeration.localEvents q).flatMap fun event => + (List.finRange 6).flatMap fun slot => + [false, true].flatMap fun orientation => + GraphTables.rowWords (Table.rowFromDart input (((edge, event), slot), orientation)) + +theorem tableWords_eq_blocks {q : Nat} + (input : GenericGraphTables.Table q) : + GraphTables.tableWords (Table.build input) = + [Enumeration.vertexCount input.vertices input.darts q, + Enumeration.dartCount input.darts q] ++ + (List.finRange input.darts).flatMap (blockWords input) := by + rw [Table.tableWords_eq_ordered, Enumeration.ordered_dart] + unfold blockWords + simp only [List.flatMap_assoc, List.flatMap_cons, List.flatMap_nil, + List.append_nil] + +def headerCommands (q : Nat) (σ : Type) : List (Command 2 σ (Addresses.fieldBound q)) := + affineCommands [(0, Enumeration.tapeCount q), + (1, Enumeration.localCount q + Enumeration.pairTapeCount q)] + (fun _ => Addresses.zeroOffset q) ++ + affineCommands [(1, 12 * Enumeration.localCount q)] (fun _ => Addresses.zeroOffset q) + +theorem headerCommands_bits {σ : Type} (q n m : Nat) (ambient : σ) : + (headerCommands q σ).flatMap (commandBits ![n, m] ambient) = + encodeWords [Enumeration.vertexCount n m q, Enumeration.dartCount m q] := by + rw [headerCommands, List.flatMap_append, affineCommands_bits, affineCommands_bits] + have vertices : affineValue + [(0, Enumeration.tapeCount q), (1, Enumeration.localCount q + Enumeration.pairTapeCount q)] + ![n, m] (Addresses.zeroOffset q).val = Enumeration.vertexCount n m q := by + exact Addresses.headerVertices_eval q n m 0 0 0 + have darts : affineValue [(1, 12 * Enumeration.localCount q)] ![n, m] + (Addresses.zeroOffset q).val = Enumeration.dartCount m q := by + exact Addresses.headerDarts_eval q n m 0 0 0 + rw [vertices, darts] + simp [encodeWords] + +@[simp] theorem headerCommands_length (q : Nat) (σ : Type) : + (headerCommands q σ).length = 7 := by + simp [headerCommands, affineCommands_length] + +def headerInTime {K Λ σ : Type} [DecidableEq K] (q n m : Nat) + (sources : Fin 2 → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Label (headerCommands q σ).length (Addresses.fieldBound q) → Λ) (exit : Option Λ) + (p : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ label, p (labels label) = statement (listCommands (headerCommands q σ)) + sources scratch output labels exit label) + (base : K → List Bool) (operands : ∀ i, base (sources i) = encodeWord (![n, m] i)) + (scratchEmpty : base scratch = []) (ambient : σ) (N : Nat) (hn : n ≤ N) (hm : m ≤ N) : + StateTransition.EvalsToInTime (TM2.step p) + ⟨some (labels (labelAt (headerCommands q σ).length (Addresses.fieldBound q) 0 .entry)), + ((ambient, ()), none), base⟩ + (some ⟨exit, ((ambient, ()), none), resultTapes output base + (encodeWords [Enumeration.vertexCount n m q, Enumeration.dartCount m q])⟩) + (7 * (3 * (N + 1) + 3) + 1) := by + have bounded : ∀ i : Fin 2, ![n, m] i ≤ N := by + intro i + fin_cases i <;> simp [hn, hm] + have run := planInTime (listCommands (headerCommands q σ)) sources scratch output + sourceScratch sourceOutput scratchOutput labels exit p atLabels ![n, m] base operands + scratchEmpty ambient N bounded + rw [bits_listCommands, headerCommands_bits] at run + simpa only [headerCommands_length] using run + +theorem encodeWords_flatMap {α : Type} (items : List α) (words : α → List Nat) : + encodeWords (items.flatMap words) = items.flatMap (fun item => encodeWords (words item)) := by + induction items with + | nil => rfl + | cons item items ih => simp [encodeWords_append, ih] + +theorem blockCommands_bits {q : Nat} (input : GenericGraphTables.Table q) + (edge : Fin input.darts) : + (blockCommands q).flatMap (commandBits (rowValues input edge) (rowContext input edge)) = + encodeWords (blockWords input edge) := by + simp only [blockCommands, blockWords, List.flatMap_assoc, encodeWords_flatMap, + rowCommands_bits] + +theorem rowCommands_length_le (q : Nat) (event : AlphabetGraph.LocalEvent (Fin q)) + (slot : Fin 6) (orientation : Bool) : (rowCommands q event slot orientation).length ≤ 4104 := by + have htail := Addresses.dartTailTerms_length_le q event slot orientation + simp only [rowCommands, List.length_append, affineCommands_length, + Addresses.reverseDartField, List.length_cons, List.length_nil, + bitCommands, List.length_map, relationBits, List.length_ofFn] + omega + +theorem flatMap_length_le {α β : Type} (items : List α) (f : α → List β) + (bound : Nat) (bounded : ∀ item ∈ items, (f item).length ≤ bound) : + (items.flatMap f).length ≤ items.length * bound := by + induction items with + | nil => simp + | cons item items ih => + have hh := bounded item (by simp) + have ht := ih (fun x hx => bounded x (by simp [hx])) + simp only [List.flatMap_cons, List.length_append, List.length_cons, Nat.succ_mul] + omega + +theorem blockCommands_length_le (q : Nat) : + (blockCommands q).length ≤ Enumeration.localCount q * (6 * (2 * 4104)) := by + unfold blockCommands + apply le_trans (flatMap_length_le _ _ (6 * (2 * 4104)) ?_) (by simp) + intro event _ + apply le_trans (flatMap_length_le _ _ (2 * 4104) ?_) (by simp) + intro slot _ + apply le_trans (flatMap_length_le _ _ 4104 ?_) (by simp) + intro orientation _ + exact rowCommands_length_le q event slot orientation + +def blockInTime {K Λ : Type} [DecidableEq K] {q : Nat} + (input : GenericGraphTables.Table q) (edge : Fin input.darts) + (sources : Fin 5 → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Label (blockCommands q).length (Addresses.fieldBound q) → Λ) (exit : Option Λ) + (p : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State (Context q))) + (atLabels : ∀ label, p (labels label) = statement (listCommands (blockCommands q)) + sources scratch output labels exit label) + (base : K → List Bool) + (operands : ∀ i, base (sources i) = encodeWord (rowValues input edge i)) + (scratchEmpty : base scratch = []) (N : Nat) + (bounded : ∀ i, rowValues input edge i ≤ N) : + StateTransition.EvalsToInTime (TM2.step p) + ⟨some (labels (labelAt (blockCommands q).length (Addresses.fieldBound q) 0 .entry)), + ((rowContext input edge, ()), none), base⟩ + (some ⟨exit, ((rowContext input edge, ()), none), + resultTapes output base (encodeWords (blockWords input edge))⟩) + (Enumeration.localCount q * (6 * (2 * 4104)) * (3 * (N + 1) + 3) + 1) := by + let run := planInTime (listCommands (blockCommands q)) sources scratch output sourceScratch + sourceOutput scratchOutput labels exit p atLabels (rowValues input edge) base operands + scratchEmpty (rowContext input edge) N bounded + have hbits := bits_listCommands (blockCommands q) (rowValues input edge) (rowContext input edge) + rw [blockCommands_bits] at hbits + rw [hbits] at run + exact { toEvalsTo := run.toEvalsTo, steps_le_m := + run.steps_le_m.trans (Nat.add_le_add_right + (Nat.mul_le_mul_right _ (blockCommands_length_le q)) 1) } + +def blockCommandsIn {σ : Type} (q : Nat) (context : σ → Context q) : + List (Command 5 σ (Addresses.fieldBound q)) := + (blockCommands q).map (fun command => command.mapAmbient context) + +theorem blockCommandsIn_bits {σ : Type} {q : Nat} + (input : GenericGraphTables.Table q) (edge : Fin input.darts) + (context : σ → Context q) (ambient : σ) (hcontext : context ambient = rowContext input edge) : + (blockCommandsIn q context).flatMap (commandBits (rowValues input edge) ambient) = + encodeWords (blockWords input edge) := by + simp only [blockCommandsIn, List.flatMap_map, commandBits_mapAmbient] + rw [hcontext] + exact blockCommands_bits input edge + +def blockInTimeAmbient {K Λ σ : Type} [DecidableEq K] {q : Nat} + (input : GenericGraphTables.Table q) (edge : Fin input.darts) + (context : σ → Context q) (ambient : σ) (hcontext : context ambient = rowContext input edge) + (sources : Fin 5 → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Label (blockCommandsIn q context).length (Addresses.fieldBound q) → Λ) + (exit : Option Λ) (p : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ label, p (labels label) = statement (listCommands (blockCommandsIn q context)) + sources scratch output labels exit label) + (base : K → List Bool) + (operands : ∀ i, base (sources i) = encodeWord (rowValues input edge i)) + (scratchEmpty : base scratch = []) (N : Nat) + (bounded : ∀ i, rowValues input edge i ≤ N) : + StateTransition.EvalsToInTime (TM2.step p) + ⟨some (labels (labelAt (blockCommandsIn q context).length (Addresses.fieldBound q) 0 .entry)), + ((ambient, ()), none), base⟩ + (some ⟨exit, ((ambient, ()), none), + resultTapes output base (encodeWords (blockWords input edge))⟩) + (Enumeration.localCount q * (6 * (2 * 4104)) * (3 * (N + 1) + 3) + 1) := by + have run := planInTime (listCommands (blockCommandsIn q context)) sources scratch output + sourceScratch sourceOutput scratchOutput labels exit p atLabels (rowValues input edge) + base operands scratchEmpty ambient N bounded + rw [bits_listCommands, blockCommandsIn_bits input edge context ambient hcontext] at run + have lengthBound : (blockCommandsIn q context).length ≤ + Enumeration.localCount q * (6 * (2 * 4104)) := by + simpa only [blockCommandsIn, List.length_map] using blockCommands_length_le q + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + exact run.steps_le_m.trans (Nat.add_le_add_right (Nat.mul_le_mul_right _ lengthBound) 1) + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.EmitRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Emitter.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Emitter.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa528f78b4fa853a1be2ed611c4cd7597b1a6818 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Emitter.lean @@ -0,0 +1,439 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineTransducerCopy + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Emitter + +open Turing +open IndependentSetsGames.Foundations.Complexity +open Reduction.MachineSubstitution (pushWord stepAux_pushWord) + +inductive Command (h : Nat) (σ : Type) (bound : Nat) + | literal (word : List Bool) + | bit (value : σ → Bool) + | bounded (value : σ → Fin bound) + | scaled (source : Fin h) (coefficient : Nat) + | scaledIf (source : Fin h) (coefficient : Nat) (active : σ → Bool) + +inductive Phase (bound : Nat) + | entry | emit (symbol : Bool) | restore | offset (value : Fin bound) + | scanIf (active : Bool) | emitIf (active symbol : Bool) + deriving DecidableEq, Fintype + +abbrev Alphabet {K : Type} (_ : K) := Bool +abbrev State (σ : Type) := (σ × Unit) × Option Bool + +def transition (_ : Unit) (_ : Bool) : Unit := () +def payload (coefficient : Nat) (_ : Unit) (symbol : Bool) : List Bool := + if symbol then List.replicate coefficient true else [] + +def commandBits {h bound : Nat} {σ : Type} (values : Fin h → Nat) (ambient : σ) : + Command h σ bound → List Bool + | .literal word => word + | .bit value => encodeWord (if value ambient then 1 else 0) + | .bounded value => List.replicate (value ambient).val true + | .scaled source coefficient => List.replicate (coefficient * values source) true + | .scaledIf source coefficient active => + List.replicate ((if active ambient then coefficient else 0) * values source) true + +def commandSteps {h bound : Nat} {σ : Type} (values : Fin h → Nat) : + Command h σ bound → Nat + | .literal _ | .bit _ => 1 + | .bounded _ => 2 + | .scaled source _ => 3 * (values source + 1) + 2 + | .scaledIf source _ _ => 3 * (values source + 1) + 3 + +variable {K Λ σ : Type} {h bound : Nat} [DecidableEq K] + +def commandStatement (sources : Fin h → K) (scratch output : K) + (labels : Phase bound → Λ) (next : Λ) (command : Command h σ bound) : + Phase bound → TM2.Stmt (Alphabet (K := K)) Λ (State σ) + | .entry => match command with + | .literal word => pushWord output word + (.load (fun state => (state.1, none)) (.goto fun _ => next)) + | .bit value => .branch (fun state => value state.1.1) + (pushWord output [true, false] + (.load (fun state => (state.1, none)) (.goto fun _ => next))) + (pushWord output [false] + (.load (fun state => (state.1, none)) (.goto fun _ => next))) + | .bounded value => .goto fun state => labels (.offset (value state.1.1)) + | .scaled source _ => MachineTransducerCopy.scanLoop (sources source) scratch () + (fun _ symbol => labels (.emit symbol)) (labels .restore) + | .scaledIf _ _ active => .goto fun state => labels (.scanIf (active state.1.1)) + | .emit symbol => match command with + | .scaled _ coefficient => MachineTransducerCopy.emitter output transition + (payload coefficient) (labels .entry) () symbol + | _ => .goto fun _ => next + | .restore => match command with + | .scaled source _ | .scaledIf source _ _ => Reduction.MachineTransfer.loopAt scratch (sources source) + id false (labels .restore) (some next) + | _ => .goto fun _ => next + | .offset value => pushWord output (List.replicate value.val true) + (.load (fun state => (state.1, none)) (.goto fun _ => next)) + | .scanIf active => match command with + | .scaledIf source _ _ => MachineTransducerCopy.scanLoop (sources source) scratch () + (fun _ symbol => labels (.emitIf active symbol)) (labels .restore) + | _ => .goto fun _ => next + | .emitIf active symbol => match command with + | .scaledIf _ coefficient _ => MachineTransducerCopy.emitter output transition + (payload (if active then coefficient else 0)) (labels (.scanIf active)) () symbol + | _ => .goto fun _ => next + +private theorem output_encodeWord (coefficient n : Nat) : + Reduction.MachineTransducer.output transition (payload coefficient) () (encodeWord n) = + List.replicate (coefficient * n) true := by + induction n with + | zero => simp [encodeWord, Reduction.MachineTransducer.output, payload] + | succ n ih => + simp only [encodeWord, List.replicate_succ, List.cons_append, + Reduction.MachineTransducer.output, payload, ite_true, transition] + change List.replicate coefficient true ++ + Reduction.MachineTransducer.output transition (payload coefficient) () (encodeWord n) = _ + rw [ih, ← List.replicate_add] + congr 1 + simp [Nat.mul_succ, Nat.add_comm] + +theorem commandTrace (sources : Fin h → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Phase bound → Λ) (next : Λ) (command : Command h σ bound) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ phase, + program (labels phase) = commandStatement sources scratch output labels next command phase) + (values : Fin h → Nat) (base : K → List Bool) + (operands : ∀ i, base (sources i) = encodeWord (values i)) + (scratchEmpty : base scratch = []) (ambient : σ) : + (MachineComposition.advance (TM2.step program))^[commandSteps values command] + (some ⟨some (labels .entry), ((ambient, ()), none), base⟩) = + some ⟨some next, ((ambient, ()), none), + Function.update base output ((commandBits values ambient command).reverse ++ base output)⟩ := by + cases command with + | literal word => + change some (TM2.stepAux (program (labels .entry)) ((ambient, ()), none) base) = _ + rw [atLabels] + simp only [commandStatement, stepAux_pushWord, TM2.stepAux, commandBits] + | bit value => + change some (TM2.stepAux (program (labels .entry)) ((ambient, ()), none) base) = _ + rw [atLabels] + cases hb : value ambient <;> + simp [commandStatement, TM2.stepAux, pushWord, commandBits, hb, encodeWord] + | bounded value => + change (TM2.step program ⟨some (labels .entry), ((ambient, ()), none), base⟩).bind + (TM2.step program) = _ + have first : TM2.step program ⟨some (labels .entry), ((ambient, ()), none), base⟩ = + some ⟨some (labels (.offset (value ambient))), ((ambient, ()), none), base⟩ := by + change some (TM2.stepAux (program (labels .entry)) _ _) = _ + rw [atLabels] + rfl + rw [first] + change some (TM2.stepAux (program (labels (.offset (value ambient)))) _ _) = _ + rw [atLabels] + simp only [commandStatement, stepAux_pushWord, TM2.stepAux, commandBits] + | scaled source coefficient => + have emitAt : ∀ control symbol, program (labels (.emit symbol)) = + MachineTransducerCopy.emitter output transition (payload coefficient) + (labels .entry) control symbol := by + intro control symbol + cases control + exact atLabels (.emit symbol) + have run := MachineTransducerCopy.transduceCopyTrace (sources source) scratch output + (sourceScratch source) (sourceOutput source) scratchOutput () transition (payload coefficient) + (labels .entry) (labels .restore) (fun _ symbol => labels (.emit symbol)) (some next) + program (atLabels .entry) emitAt (atLabels .restore) base scratchEmpty ambient () none + rw [operands source, encodeWord_length, output_encodeWord] at run + exact run + | scaledIf source coefficient active => + have first : TM2.step program ⟨some (labels .entry), ((ambient, ()), none), base⟩ = + some ⟨some (labels (.scanIf (active ambient))), ((ambient, ()), none), base⟩ := by + change some (TM2.stepAux (program (labels .entry)) _ _) = _ + rw [atLabels] + rfl + have emitAt : ∀ control symbol, program (labels (.emitIf (active ambient) symbol)) = + MachineTransducerCopy.emitter output transition + (payload (if active ambient then coefficient else 0)) + (labels (.scanIf (active ambient))) control symbol := by + intro control symbol + cases control + exact atLabels (.emitIf (active ambient) symbol) + have run := MachineTransducerCopy.transduceCopyTrace (sources source) scratch output + (sourceScratch source) (sourceOutput source) scratchOutput () transition + (payload (if active ambient then coefficient else 0)) + (labels (.scanIf (active ambient))) (labels .restore) + (fun _ symbol => labels (.emitIf (active ambient) symbol)) (some next) + program (atLabels (.scanIf (active ambient))) emitAt (atLabels .restore) + base scratchEmpty ambient () none + rw [operands source, encodeWord_length, output_encodeWord] at run + change (MachineComposition.advance (TM2.step program))^[ + (3 * (values source + 1) + 2) + 1] _ = _ + rw [Function.iterate_succ_apply] + simp only [MachineComposition.advance_some] + rw [first] + exact run + +abbrev Label (count bound : Nat) := Fin (count + 1) × Phase bound + +def labelAt (count bound r : Nat) (phase : Phase bound) : Label count bound := + (⟨min r count, by omega⟩, phase) + +def commandAt {count : Nat} (commands : Fin count → Command h σ bound) (r : Nat) : + Command h σ bound := + if hr : r < count then commands ⟨r, hr⟩ else .literal [] + +def statement {count : Nat} (commands : Fin count → Command h σ bound) + (sources : Fin h → K) (scratch output : K) + (labels : Label count bound → Λ) (exit : Option Λ) (label : Label count bound) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ) := + if label.1.val < count then + commandStatement sources scratch output (fun phase => labels (labelAt count bound label.1.val phase)) + (labels (labelAt count bound (label.1.val + 1) .entry)) + (commandAt commands label.1.val) label.2 + else Reduction.MachineTransfer.exitAt output exit + +def program {count : Nat} (commands : Fin count → Command h σ bound) + (sources : Fin h → K) (scratch output : K) : + Label count bound → TM2.Stmt (Alphabet (K := K)) (Label count bound) (State σ) := + statement commands sources scratch output id none + +def machine [Fintype K] [Fintype σ] {count : Nat} + (commands : Fin count → Command h σ bound) (sources : Fin h → K) + (scratch output input : K) (ambient : σ) : FinTM2 where + K := K + k₀ := input + k₁ := output + Γ _ := Bool + Λ := Label count bound + main := labelAt count bound 0 .entry + σ := State σ + initialState := ((ambient, ()), none) + m := program commands sources scratch output + +def prefixBits {count : Nat} (commands : Fin count → Command h σ bound) + (values : Fin h → Nat) (ambient : σ) : Nat → List Bool + | 0 => [] + | r + 1 => prefixBits commands values ambient r ++ + commandBits values ambient (commandAt commands r) + +def prefixSteps {count : Nat} (commands : Fin count → Command h σ bound) + (values : Fin h → Nat) : Nat → Nat + | 0 => 0 + | r + 1 => prefixSteps commands values r + commandSteps values (commandAt commands r) + +def resultTapes (output : K) (base : K → List Bool) (bits : List Bool) : K → List Bool := + Function.update base output (bits.reverse ++ base output) + +@[simp] theorem resultTapes_output (output : K) (base : K → List Bool) (bits : List Bool) : + resultTapes output base bits output = bits.reverse ++ base output := by + simp [resultTapes] + +theorem resultTapes_other (output : K) (base : K → List Bool) (bits : List Bool) + (k : K) (hk : k ≠ output) : resultTapes output base bits k = base k := by + simp [resultTapes, hk] + +theorem prefixTrace {count : Nat} (commands : Fin count → Command h σ bound) + (sources : Fin h → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Label count bound → Λ) (exit : Option Λ) + (p : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ label, p (labels label) = statement commands sources scratch output labels exit label) + (values : Fin h → Nat) (base : K → List Bool) + (operands : ∀ i, base (sources i) = encodeWord (values i)) + (scratchEmpty : base scratch = []) (ambient : σ) (r : Nat) (hr : r ≤ count) : + (MachineComposition.advance (TM2.step p))^[prefixSteps commands values r] + (some ⟨some (labels (labelAt count bound 0 .entry)), ((ambient, ()), none), base⟩) = + some ⟨some (labels (labelAt count bound r .entry)), ((ambient, ()), none), + resultTapes output base (prefixBits commands values ambient r)⟩ := by + induction r with + | zero => simp [prefixSteps, prefixBits, resultTapes] + | succ r ih => + have hrc : r < count := by omega + let prior := resultTapes output base (prefixBits commands values ambient r) + have priorOperands : ∀ i, prior (sources i) = encodeWord (values i) := by + intro i + simpa [prior, resultTapes, sourceOutput i] using operands i + have priorScratch : prior scratch = [] := by + simpa [prior, resultTapes, scratchOutput] using scratchEmpty + have commandAtLabels : ∀ phase, p (labels (labelAt count bound r phase)) = + commandStatement sources scratch output (fun phase => labels (labelAt count bound r phase)) + (labels (labelAt count bound (r + 1) .entry)) (commandAt commands r) phase := by + intro phase + rw [atLabels] + simp only [statement, labelAt, Nat.min_eq_left (Nat.le_of_lt hrc), hrc, ite_true] + have one := commandTrace sources scratch output sourceScratch sourceOutput scratchOutput + (fun phase => labels (labelAt count bound r phase)) + (labels (labelAt count bound (r + 1) .entry)) (commandAt commands r) + p commandAtLabels values prior priorOperands priorScratch ambient + rw [prefixSteps, Nat.add_comm, Function.iterate_add_apply, ih (by omega)] + rw [one] + congr 2 + simp [prior, prefixBits, resultTapes, List.reverse_append, List.append_assoc] + +theorem planTrace {count : Nat} (commands : Fin count → Command h σ bound) + (sources : Fin h → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Label count bound → Λ) (exit : Option Λ) + (p : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ label, p (labels label) = statement commands sources scratch output labels exit label) + (values : Fin h → Nat) (base : K → List Bool) + (operands : ∀ i, base (sources i) = encodeWord (values i)) + (scratchEmpty : base scratch = []) (ambient : σ) : + (MachineComposition.advance (TM2.step p))^[prefixSteps commands values count + 1] + (some ⟨some (labels (labelAt count bound 0 .entry)), ((ambient, ()), none), base⟩) = + some ⟨exit, ((ambient, ()), none), + resultTapes output base (prefixBits commands values ambient count)⟩ := by + rw [Function.iterate_succ_apply', prefixTrace commands sources scratch output sourceScratch + sourceOutput scratchOutput labels exit p atLabels values base operands scratchEmpty ambient count + (Nat.le_refl _)] + change some (TM2.stepAux (p (labels (labelAt count bound count .entry))) _ _) = _ + rw [atLabels] + cases exit <;> simp [statement, labelAt, Reduction.MachineTransfer.exitAt, TM2.stepAux] + +theorem prefixSteps_le {count : Nat} (commands : Fin count → Command h σ bound) + (values : Fin h → Nat) (N : Nat) (bounded : ∀ i, values i ≤ N) + (r : Nat) : prefixSteps commands values r ≤ r * (3 * (N + 1) + 3) := by + induction r with + | zero => simp [prefixSteps] + | succ r ih => + have one : commandSteps values (commandAt commands r) ≤ 3 * (N + 1) + 3 := by + cases commandAt commands r with + | literal _ => simp only [commandSteps]; omega + | bit _ => simp only [commandSteps]; omega + | bounded _ => simp only [commandSteps]; omega + | scaled source _ => have hs := bounded source; simp only [commandSteps]; omega + | scaledIf source _ _ => have hs := bounded source; simp only [commandSteps]; omega + calc + prefixSteps commands values (r + 1) = + prefixSteps commands values r + commandSteps values (commandAt commands r) := rfl + _ ≤ r * (3 * (N + 1) + 3) + (3 * (N + 1) + 3) := Nat.add_le_add ih one + _ = (r + 1) * (3 * (N + 1) + 3) := (Nat.succ_mul r _).symm + +def planInTime {count : Nat} (commands : Fin count → Command h σ bound) + (sources : Fin h → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Label count bound → Λ) (exit : Option Λ) + (p : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ label, p (labels label) = statement commands sources scratch output labels exit label) + (values : Fin h → Nat) (base : K → List Bool) + (operands : ∀ i, base (sources i) = encodeWord (values i)) + (scratchEmpty : base scratch = []) (ambient : σ) + (N : Nat) (bounded : ∀ i, values i ≤ N) : + StateTransition.EvalsToInTime (TM2.step p) + ⟨some (labels (labelAt count bound 0 .entry)), ((ambient, ()), none), base⟩ + (some ⟨exit, ((ambient, ()), none), + resultTapes output base (prefixBits commands values ambient count)⟩) + (count * (3 * (N + 1) + 3) + 1) where + steps := prefixSteps commands values count + 1 + evals_in_steps := planTrace commands sources scratch output sourceScratch sourceOutput + scratchOutput labels exit p atLabels values base operands scratchEmpty ambient + steps_le_m := Nat.add_le_add_right (prefixSteps_le commands values N bounded count) 1 + +def listCommands (commands : List (Command h σ bound)) : + Fin commands.length → Command h σ bound := fun i => commands[i] + +theorem prefixBits_listCommands (commands : List (Command h σ bound)) + (values : Fin h → Nat) (ambient : σ) (r : Nat) (hr : r ≤ commands.length) : + prefixBits (listCommands commands) values ambient r = + (commands.take r).flatMap (commandBits values ambient) := by + induction r with + | zero => simp [prefixBits] + | succ r ih => + have hrc : r < commands.length := by omega + rw [prefixBits, ih (by omega), List.take_succ_eq_append_getElem hrc, + List.flatMap_append] + simp [commandAt, hrc, listCommands] + +theorem bits_listCommands (commands : List (Command h σ bound)) + (values : Fin h → Nat) (ambient : σ) : + prefixBits (listCommands commands) values ambient commands.length = + commands.flatMap (commandBits values ambient) := by + simpa using prefixBits_listCommands commands values ambient commands.length (Nat.le_refl _) + +def affineCommands (terms : List (Fin h × Nat)) (offset : σ → Fin bound) : + List (Command h σ bound) := + terms.map (fun term => .scaled term.1 term.2) ++ [.bounded offset, .literal [false]] + +def affineValue (terms : List (Fin h × Nat)) (values : Fin h → Nat) (offset : Nat) : Nat := + (terms.map (fun term => term.2 * values term.1)).sum + offset + +private theorem scaleBits (terms : List (Fin h × Nat)) (values : Fin h → Nat) (ambient : σ) : + (terms.map (fun term => (Command.scaled term.1 term.2 : Command h σ bound))).flatMap + (commandBits values ambient) = + List.replicate ((terms.map (fun term => term.2 * values term.1)).sum) true := by + induction terms with + | nil => rfl + | cons term terms ih => + simp only [List.map_cons, List.flatMap_cons, commandBits, List.sum_cons] + rw [ih, List.replicate_add] + +theorem affineCommands_bits (terms : List (Fin h × Nat)) (offset : σ → Fin bound) + (values : Fin h → Nat) (ambient : σ) : + (affineCommands terms offset).flatMap (commandBits values ambient) = + encodeWord (affineValue terms values (offset ambient).val) := by + simp only [affineCommands, List.flatMap_append, scaleBits, List.flatMap_cons, + List.flatMap_nil, commandBits, List.append_nil, affineValue, encodeWord, + List.replicate_add, List.append_assoc] + +@[simp] theorem affineCommands_length (terms : List (Fin h × Nat)) (offset : σ → Fin bound) : + (affineCommands terms offset).length = terms.length + 2 := by + simp [affineCommands] + +def bitCommands (bits : List (σ → Bool)) : List (Command h σ bound) := bits.map .bit + +theorem bitCommands_bits (bits : List (σ → Bool)) (values : Fin h → Nat) (ambient : σ) : + (bitCommands (h := h) (bound := bound) bits).flatMap (commandBits values ambient) = + encodeWords (bits.map (fun bit => if bit ambient then 1 else 0)) := by + induction bits with + | nil => rfl + | cons bit bits ih => + simpa only [bitCommands, List.map_cons, List.flatMap_cons, commandBits, encodeWords] + using congrArg (encodeWord (if bit ambient then 1 else 0) ++ ·) ih + +def affineInTime (terms : List (Fin h × Nat)) (offset : σ → Fin bound) + (sources : Fin h → K) (scratch output : K) + (sourceScratch : ∀ i, sources i ≠ scratch) + (sourceOutput : ∀ i, sources i ≠ output) (scratchOutput : scratch ≠ output) + (labels : Label (affineCommands terms offset).length bound → Λ) (exit : Option Λ) + (p : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ)) + (atLabels : ∀ label, p (labels label) = + statement (listCommands (affineCommands terms offset)) sources scratch output labels exit label) + (values : Fin h → Nat) (base : K → List Bool) + (operands : ∀ i, base (sources i) = encodeWord (values i)) + (scratchEmpty : base scratch = []) (ambient : σ) + (N : Nat) (bounded : ∀ i, values i ≤ N) : + StateTransition.EvalsToInTime (TM2.step p) + ⟨some (labels (labelAt (affineCommands terms offset).length bound 0 .entry)), + ((ambient, ()), none), base⟩ + (some ⟨exit, ((ambient, ()), none), + resultTapes output base (encodeWord (affineValue terms values (offset ambient).val))⟩) + ((terms.length + 2) * (3 * (N + 1) + 3) + 1) := by + have run := planInTime (listCommands (affineCommands terms offset)) sources scratch output + sourceScratch sourceOutput scratchOutput labels exit p atLabels values base operands + scratchEmpty ambient N bounded + rw [bits_listCommands, affineCommands_bits] at run + simpa only [affineCommands_length] using run + +def Command.mapAmbient {τ : Type} (view : σ → τ) : + Command h τ bound → Command h σ bound + | .literal word => .literal word + | .bit value => .bit (value ∘ view) + | .bounded value => .bounded (value ∘ view) + | .scaled source coefficient => .scaled source coefficient + | .scaledIf source coefficient active => .scaledIf source coefficient (active ∘ view) + +@[simp] theorem commandBits_mapAmbient {τ : Type} (view : σ → τ) + (command : Command h τ bound) (values : Fin h → Nat) (ambient : σ) : + commandBits values ambient (command.mapAmbient view) = + commandBits values (view ambient) command := by + cases command <;> rfl + +@[simp] theorem commandSteps_mapAmbient {τ : Type} (view : σ → τ) + (command : Command h τ bound) (values : Fin h → Nat) : + commandSteps values (command.mapAmbient view) = commandSteps values command := by + cases command <;> rfl + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Emitter + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Enumeration.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Enumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..8af87a0918e18e75285e8cb2392a8ca91d8aa7bd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Enumeration.lean @@ -0,0 +1,342 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.AlphabetGraph + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Enumeration + +open IndependentSetsGames.Foundations.Hastad +open scoped BigOperators + +def bitValue (bit : Bool) : Nat := if bit then 1 else 0 + +def boolEquiv : Bool ≃ Fin 2 := finTwoEquiv.symm + +@[simp] theorem boolEquiv_val (bit : Bool) : (boolEquiv bit).val = bitValue bit := by + cases bit <;> rfl + +def productEquiv {A B : Type*} {a b : Nat} (left : A ≃ Fin a) (right : B ≃ Fin b) : + A × B ≃ Fin (a * b) := + (Equiv.prodCongr left right).trans finProdFinEquiv + +@[simp] theorem productEquiv_val {A B : Type*} {a b : Nat} + (left : A ≃ Fin a) (right : B ≃ Fin b) (x : A) (y : B) : + (productEquiv left right (x, y)).val = (left x).val * b + (right y).val := by + change (right y).val + b * (left x).val = _ + simp [Nat.mul_comm, Nat.add_comm] + +def sumEquiv {A B : Type*} {a b : Nat} (left : A ≃ Fin a) (right : B ≃ Fin b) : + A ⊕ B ≃ Fin (a + b) := + (Equiv.sumCongr left right).trans finSumFinEquiv + +@[simp] theorem sumEquiv_inl_val {A B : Type*} {a b : Nat} + (left : A ≃ Fin a) (right : B ≃ Fin b) (x : A) : + (sumEquiv left right (.inl x)).val = (left x).val := rfl + +@[simp] theorem sumEquiv_inr_val {A B : Type*} {a b : Nat} + (left : A ≃ Fin a) (right : B ≃ Fin b) (y : B) : + (sumEquiv left right (.inr y)).val = a + (right y).val := rfl + +def tapeCount (q : Nat) : Nat := 2 ^ q +def pairTapeCount (q : Nat) : Nat := 2 ^ (q * q) +def fiveTapeCount (q : Nat) : Nat := pairTapeCount q ^ 5 +def localCount (q : Nat) : Nat := 4 * (2 * tapeCount q) * fiveTapeCount q +def eventCount (m q : Nat) : Nat := m * localCount q +def addressCount (n m q : Nat) : Nat := n * tapeCount q + m * pairTapeCount q +def vertexCount (n m q : Nat) : Nat := eventCount m q + addressCount n m q +def dartCount (m q : Nat) : Nat := eventCount m q * 12 + +def cubeEquiv (q : Nat) : Cube (Fin q) ≃ Fin (tapeCount q) := + (Equiv.arrowCongr (Equiv.refl (Fin q)) boolEquiv).trans finFunctionFinEquiv + +def cubeRank {q : Nat} (tape : Cube (Fin q)) : Fin (tapeCount q) := cubeEquiv q tape +def cubeUnrank {q : Nat} (index : Fin (tapeCount q)) : Cube (Fin q) := + (cubeEquiv q).symm index + +@[simp] theorem cubeUnrank_cubeRank {q : Nat} (tape : Cube (Fin q)) : + cubeUnrank (cubeRank tape) = tape := (cubeEquiv q).symm_apply_apply tape + +@[simp] theorem cubeRank_cubeUnrank {q : Nat} (index : Fin (tapeCount q)) : + cubeRank (cubeUnrank index) = index := (cubeEquiv q).apply_symm_apply index + +theorem cubeUnrank_digit {q : Nat} (index : Fin (tapeCount q)) (i : Fin q) : + bitValue (cubeUnrank index i) = index.val / 2 ^ i.val % 2 := by + have digit : boolEquiv (cubeUnrank index i) = + (⟨index.val / 2 ^ i.val % 2, Nat.mod_lt _ (by decide)⟩ : Fin 2) := by + change boolEquiv (boolEquiv.symm _) = _ + exact boolEquiv.apply_symm_apply _ + simpa only [boolEquiv_val] using congrArg Fin.val digit + +theorem cubeEquiv_val (q : Nat) (tape : Cube (Fin q)) : + (cubeEquiv q tape).val = ∑ i : Fin q, bitValue (tape i) * 2 ^ i.val := by + change (finFunctionFinEquiv (fun i => boolEquiv (tape i))).val = _ + rw [finFunctionFinEquiv_apply] + simp only [boolEquiv_val] + +def pairIndex (q : Nat) : Fin q × Fin q ≃ Fin (q * q) := finProdFinEquiv + +theorem pairIndex_val (q : Nat) (i j : Fin q) : + (pairIndex q (i, j)).val = i.val * q + j.val := by + change j.val + q * i.val = _ + simp [Nat.mul_comm, Nat.add_comm] + +def pairCubeEquiv (q : Nat) : Cube (Fin q × Fin q) ≃ Fin (pairTapeCount q) := + (Equiv.arrowCongr (pairIndex q) (Equiv.refl Bool)).trans (cubeEquiv (q * q)) + +def pairCubeRank {q : Nat} (tape : Cube (Fin q × Fin q)) : Fin (pairTapeCount q) := + pairCubeEquiv q tape + +def pairCubeUnrank {q : Nat} (index : Fin (pairTapeCount q)) : Cube (Fin q × Fin q) := + (pairCubeEquiv q).symm index + +@[simp] theorem pairCubeUnrank_pairCubeRank {q : Nat} (tape : Cube (Fin q × Fin q)) : + pairCubeUnrank (pairCubeRank tape) = tape := (pairCubeEquiv q).symm_apply_apply tape + +@[simp] theorem pairCubeRank_pairCubeUnrank {q : Nat} (index : Fin (pairTapeCount q)) : + pairCubeRank (pairCubeUnrank index) = index := (pairCubeEquiv q).apply_symm_apply index + +theorem pairCubeEquiv_val (q : Nat) (tape : Cube (Fin q × Fin q)) : + (pairCubeEquiv q tape).val = + ∑ i : Fin (q * q), bitValue (tape ((pairIndex q).symm i)) * 2 ^ i.val := + cubeEquiv_val (q * q) _ + +def inputCoordinateEquiv (q : Nat) : + AlphabetReduction.InputCoordinate (Fin q) ≃ Fin (2 * tapeCount q) := + productEquiv boolEquiv (cubeEquiv q) + +def fivePairTapesEquiv (q : Nat) : + (Cube (Fin q × Fin q) × Cube (Fin q × Fin q) × Cube (Fin q × Fin q) × + Cube (Fin q × Fin q) × Cube (Fin q × Fin q)) ≃ Fin (fiveTapeCount q) := + (productEquiv (pairCubeEquiv q) + (productEquiv (pairCubeEquiv q) + (productEquiv (pairCubeEquiv q) + (productEquiv (pairCubeEquiv q) (pairCubeEquiv q))))).trans + (finCongr (by simp [fiveTapeCount, pow_succ, Nat.mul_assoc])) + +def localEventEquiv (q : Nat) : AlphabetGraph.LocalEvent (Fin q) ≃ Fin (localCount q) := + (productEquiv (Equiv.refl (Fin 4)) + (productEquiv (inputCoordinateEquiv q) (fivePairTapesEquiv q))).trans + (finCongr (by simp [localCount, Nat.mul_assoc])) + +def eventEquiv (m q : Nat) : + AlphabetGraph.Event (Fin m) (Fin q) ≃ Fin (eventCount m q) := + productEquiv (Equiv.refl (Fin m)) (localEventEquiv q) + +def addressEquiv (n m q : Nat) : + AlphabetGraph.Address (Fin n) (Fin m) (Fin q) ≃ Fin (addressCount n m q) := + sumEquiv (productEquiv (Equiv.refl (Fin n)) (cubeEquiv q)) + (productEquiv (Equiv.refl (Fin m)) (pairCubeEquiv q)) + +def vertexEquiv (n m q : Nat) : + QueryIncidence.Vertex (AlphabetGraph.Event (Fin m) (Fin q)) + (AlphabetGraph.Address (Fin n) (Fin m) (Fin q)) ≃ Fin (vertexCount n m q) := + sumEquiv (eventEquiv m q) (addressEquiv n m q) + +def dartEquiv (m q : Nat) : + QueryIncidence.Dart (AlphabetGraph.Event (Fin m) (Fin q)) 6 ≃ Fin (dartCount m q) := + (productEquiv (productEquiv (eventEquiv m q) (Equiv.refl (Fin 6))) boolEquiv).trans + (finCongr (by simp [dartCount, Nat.mul_assoc])) + +def labelEquiv : QueryIncidence.Label 6 ≃ Fin 64 := cubeEquiv 6 + +theorem labelEquiv_val (label : QueryIncidence.Label 6) : + (labelEquiv label).val = ∑ i : Fin 6, bitValue (label i) * 2 ^ i.val := + cubeEquiv_val 6 label + +@[simp] theorem inputCoordinateEquiv_val (q : Nat) (side : Bool) (tape : Cube (Fin q)) : + (inputCoordinateEquiv q (side, tape)).val = + bitValue side * tapeCount q + (cubeEquiv q tape).val := by + simp [inputCoordinateEquiv] + +theorem fivePairTapesEquiv_val (q : Nat) (f g r₀ r₁ r₂ : Cube (Fin q × Fin q)) : + (fivePairTapesEquiv q (f, g, r₀, r₁, r₂)).val = + (pairCubeEquiv q f).val * pairTapeCount q ^ 4 + + (pairCubeEquiv q g).val * pairTapeCount q ^ 3 + + (pairCubeEquiv q r₀).val * pairTapeCount q ^ 2 + + (pairCubeEquiv q r₁).val * pairTapeCount q + (pairCubeEquiv q r₂).val := by + simp [fivePairTapesEquiv, productEquiv_val, pow_succ, Nat.mul_assoc, Nat.add_assoc] + +theorem localEventEquiv_val (q : Nat) (kind : Fin 4) + (coordinate : AlphabetReduction.InputCoordinate (Fin q)) + (f g r₀ r₁ r₂ : Cube (Fin q × Fin q)) : + (localEventEquiv q (kind, coordinate, f, g, r₀, r₁, r₂)).val = + kind.val * (2 * tapeCount q * fiveTapeCount q) + + (inputCoordinateEquiv q coordinate).val * fiveTapeCount q + + (fivePairTapesEquiv q (f, g, r₀, r₁, r₂)).val := by + simp [localEventEquiv, productEquiv_val, Nat.add_assoc] + +@[simp] theorem eventEquiv_val (m q : Nat) (edge : Fin m) + (sample : AlphabetGraph.LocalEvent (Fin q)) : + (eventEquiv m q (edge, sample)).val = edge.val * localCount q + + (localEventEquiv q sample).val := by + change (localEventEquiv q sample).val + localCount q * edge.val = _ + simp [Nat.mul_comm, Nat.add_comm] + +@[simp] theorem addressEquiv_inl_val (n m q : Nat) (vertex : Fin n) + (tape : Cube (Fin q)) : + (addressEquiv n m q (.inl (vertex, tape))).val = + vertex.val * tapeCount q + (cubeEquiv q tape).val := by + change (cubeEquiv q tape).val + tapeCount q * vertex.val = _ + simp [Nat.mul_comm, Nat.add_comm] + +@[simp] theorem addressEquiv_inr_val (n m q : Nat) (edge : Fin m) + (tape : Cube (Fin q × Fin q)) : + (addressEquiv n m q (.inr (edge, tape))).val = + n * tapeCount q + (edge.val * pairTapeCount q + (pairCubeEquiv q tape).val) := by + change n * tapeCount q + ((pairCubeEquiv q tape).val + pairTapeCount q * edge.val) = _ + simp [Nat.mul_comm, Nat.add_comm] + +@[simp] theorem vertexEquiv_event_val (n m q : Nat) + (event : AlphabetGraph.Event (Fin m) (Fin q)) : + (vertexEquiv n m q (.inl event)).val = (eventEquiv m q event).val := rfl + +@[simp] theorem vertexEquiv_vertexAddress_val (n m q : Nat) (vertex : Fin n) + (tape : Cube (Fin q)) : + (vertexEquiv n m q (.inr (.inl (vertex, tape)))).val = + eventCount m q + (vertex.val * tapeCount q + (cubeEquiv q tape).val) := by + change eventCount m q + (addressEquiv n m q (.inl (vertex, tape))).val = _ + rw [addressEquiv_inl_val] + +@[simp] theorem vertexEquiv_edgeAddress_val (n m q : Nat) (edge : Fin m) + (tape : Cube (Fin q × Fin q)) : + (vertexEquiv n m q (.inr (.inr (edge, tape)))).val = + eventCount m q + (n * tapeCount q + + (edge.val * pairTapeCount q + (pairCubeEquiv q tape).val)) := by + change eventCount m q + (addressEquiv n m q (.inr (edge, tape))).val = _ + rw [addressEquiv_inr_val] + +@[simp] theorem dartEquiv_val (m q : Nat) + (event : AlphabetGraph.Event (Fin m) (Fin q)) (slot : Fin 6) (orientation : Bool) : + (dartEquiv m q ((event, slot), orientation)).val = + (eventEquiv m q event).val * 12 + slot.val * 2 + bitValue orientation := by + change (boolEquiv orientation).val + 2 * (slot.val + 6 * (eventEquiv m q event).val) = _ + rw [boolEquiv_val] + omega + +theorem dartEquiv_reverse_val (m q : Nat) + (event : AlphabetGraph.Event (Fin m) (Fin q)) (slot : Fin 6) (orientation : Bool) : + (dartEquiv m q (QueryIncidence.reverse ((event, slot), orientation))).val = + (eventEquiv m q event).val * 12 + slot.val * 2 + bitValue (!orientation) := + dartEquiv_val m q event slot (!orientation) + +def ordered {A : Type*} {count : Nat} (order : A ≃ Fin count) : List A := + List.ofFn order.symm + +@[simp] theorem ordered_length {A : Type*} {count : Nat} (order : A ≃ Fin count) : + (ordered order).length = count := by simp [ordered] + +theorem mem_ordered {A : Type*} {count : Nat} (order : A ≃ Fin count) (x : A) : + x ∈ ordered order := by + simp only [ordered, List.mem_ofFn] + exact ⟨order x, order.symm_apply_apply x⟩ + +theorem ordered_nodup {A : Type*} {count : Nat} (order : A ≃ Fin count) : + (ordered order).Nodup := by + rw [ordered, List.nodup_ofFn] + exact order.symm.injective + +@[simp] theorem ordered_refl (n : Nat) : ordered (Equiv.refl (Fin n)) = List.finRange n := rfl + +@[simp] theorem ordered_bool : ordered boolEquiv = [false, true] := rfl + +theorem ordered_trans_finCongr {A : Type*} {a b : Nat} + (order : A ≃ Fin a) (sameCount : a = b) : + ordered (order.trans (finCongr sameCount)) = ordered order := by + cases sameCount + rfl + +theorem ordered_product {A B : Type*} {a b : Nat} + (left : A ≃ Fin a) (right : B ≃ Fin b) : + ordered (productEquiv left right) = + (ordered left).flatMap (fun x => (ordered right).map (fun y => (x, y))) := by + have atIndex (i : Fin a) (j : Fin b) (h : i.val * b + j.val < a * b) : + (productEquiv left right).symm ⟨i.val * b + j.val, h⟩ = + (left.symm i, right.symm j) := by + have same : (⟨i.val * b + j.val, h⟩ : Fin (a * b)) = finProdFinEquiv (i, j) := by + apply Fin.ext + simp [finProdFinEquiv, Nat.mul_comm, Nat.add_comm] + rw [same] + simp [productEquiv] + unfold ordered + rw [List.ofFn_mul] + simp only [atIndex, List.flatMap_def, List.map_ofFn, Function.comp_def] + +theorem ordered_sum {A B : Type*} {a b : Nat} + (left : A ≃ Fin a) (right : B ≃ Fin b) : + ordered (sumEquiv left right) = + (ordered left).map Sum.inl ++ (ordered right).map Sum.inr := by + have atLeft (i : Fin a) : + (sumEquiv left right).symm (i.castLE (Nat.le_add_right a b)) = + Sum.inl (left.symm i) := by + change (Equiv.sumCongr left right).symm + (finSumFinEquiv.symm (Fin.castAdd b i)) = _ + rw [finSumFinEquiv_symm_apply_castAdd] + rfl + have atRight (j : Fin b) : + (sumEquiv left right).symm (j.natAdd a) = Sum.inr (right.symm j) := by + change (Equiv.sumCongr left right).symm (finSumFinEquiv.symm (j.natAdd a)) = _ + rw [finSumFinEquiv_symm_apply_natAdd] + rfl + unfold ordered + rw [List.ofFn_add] + simp only [atLeft, atRight, List.map_ofFn, Function.comp_def] + +def localEvents (q : Nat) : List (AlphabetGraph.LocalEvent (Fin q)) := + ordered (localEventEquiv q) + +@[simp] theorem localEvents_length (q : Nat) : (localEvents q).length = localCount q := + ordered_length _ + +theorem ordered_event (m q : Nat) : + ordered (eventEquiv m q) = + (List.finRange m).flatMap (fun edge => (localEvents q).map (fun event => (edge, event))) := by + change ordered (productEquiv (Equiv.refl (Fin m)) (localEventEquiv q)) = _ + rw [ordered_product, ordered_refl] + rfl + +theorem ordered_dart (m q : Nat) : + ordered (dartEquiv m q) = + (List.finRange m).flatMap (fun edge => + (localEvents q).flatMap (fun event => + (List.finRange 6).flatMap (fun slot => + [(((edge, event), slot), false), (((edge, event), slot), true)]))) := by + unfold dartEquiv dartCount + rw [ordered_trans_finCongr, ordered_product, ordered_product, ordered_event] + simp only [ordered_refl, ordered_bool, List.flatMap_assoc, List.flatMap_map, + List.map_cons, List.map_nil] + +@[simp] theorem card_cube (q : Nat) : Fintype.card (Cube (Fin q)) = tapeCount q := by + simpa using Fintype.card_congr (cubeEquiv q) + +@[simp] theorem card_pairCube (q : Nat) : + Fintype.card (Cube (Fin q × Fin q)) = pairTapeCount q := by + simpa using Fintype.card_congr (pairCubeEquiv q) + +@[simp] theorem card_localEvent (q : Nat) : + Fintype.card (AlphabetGraph.LocalEvent (Fin q)) = localCount q := by + simpa using Fintype.card_congr (localEventEquiv q) + +@[simp] theorem card_event (m q : Nat) : + Fintype.card (AlphabetGraph.Event (Fin m) (Fin q)) = eventCount m q := by + simpa using Fintype.card_congr (eventEquiv m q) + +@[simp] theorem card_address (n m q : Nat) : + Fintype.card (AlphabetGraph.Address (Fin n) (Fin m) (Fin q)) = addressCount n m q := by + simpa using Fintype.card_congr (addressEquiv n m q) + +@[simp] theorem card_vertex (n m q : Nat) : + Fintype.card (QueryIncidence.Vertex (AlphabetGraph.Event (Fin m) (Fin q)) + (AlphabetGraph.Address (Fin n) (Fin m) (Fin q))) = vertexCount n m q := by + simpa using Fintype.card_congr (vertexEquiv n m q) + +@[simp] theorem card_dart (m q : Nat) : + Fintype.card (QueryIncidence.Dart (AlphabetGraph.Event (Fin m) (Fin q)) 6) = + dartCount m q := by + simpa using Fintype.card_congr (dartEquiv m q) + +@[simp] theorem localCount_formula (q : Nat) : + localCount q = 4 * (2 * 2 ^ q) * (2 ^ (q * q)) ^ 5 := rfl + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Enumeration + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/FinalBooleanVerifier.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalBooleanVerifier.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f188efa3bd647478c76875e975bf1629562d9b9 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalBooleanVerifier.lean @@ -0,0 +1,244 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.AlphabetGraph +import OAI.Combinatorics.IndependentSets.PCP.VerifierCNF + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.FinalBooleanVerifier + +open Target + +abbrev Label := Fin 6 → Bool + +variable {V E : Type*} {n m : Nat} + +def bitIndex (vertices : V ≃ Fin n) (v : V) (j : Fin 6) : Fin (n * 6) := + finProdFinEquiv (vertices v, j) + +def labelsOfBits (vertices : V ≃ Fin n) (assignment : Fin (n * 6) → Bool) : V → Label := + fun v j => assignment (bitIndex vertices v j) + +def bitsOfLabels (vertices : V ≃ Fin n) (labeling : V → Label) : Fin (n * 6) → Bool := + fun k => + let pair : Fin n × Fin 6 := finProdFinEquiv.symm k + labeling (vertices.symm pair.1) pair.2 + +@[simp] theorem labelsOfBits_bitsOfLabels (vertices : V ≃ Fin n) (labeling : V → Label) : + labelsOfBits vertices (bitsOfLabels vertices labeling) = labeling := by + funext v j + simp only [labelsOfBits, bitsOfLabels, bitIndex, Equiv.symm_apply_apply] + +@[simp] theorem bitsOfLabels_labelsOfBits (vertices : V ≃ Fin n) + (assignment : Fin (n * 6) → Bool) : bitsOfLabels vertices (labelsOfBits vertices assignment) = assignment := by + funext k + simp only [bitsOfLabels, labelsOfBits, bitIndex, Equiv.apply_symm_apply, Prod.eta] + +abbrev verifier (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) (edges : E ≃ Fin m) : + VerifierToCNF.FiniteVerifier 12 where + «variables» := n * 6 + events := m + query := fun e i => Fin.addCases (motive := fun _ : Fin (6 + 6) => Fin (n * 6)) + (fun j : Fin 6 => bitIndex vertices (G.tail (edges.symm e)) j) + (fun j : Fin 6 => bitIndex vertices (G.head (edges.symm e)) j) i + accepts := fun e bits => G.accepts (edges.symm e) + (fun j => bits (Fin.castAdd 6 j)) (fun j => bits (Fin.natAdd 6 j)) + +theorem query_tail (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (e : Fin m) (j : Fin 6) : + (verifier G vertices edges).query e (Fin.castAdd 6 j) = + bitIndex vertices (G.tail (edges.symm e)) j := by + simp only [verifier, Fin.addCases_left] + +theorem query_head (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (e : Fin m) (j : Fin 6) : + (verifier G vertices edges).query e (Fin.natAdd 6 j) = + bitIndex vertices (G.head (edges.symm e)) j := by + simp only [verifier, Fin.addCases_right] + +theorem eventValue_eq (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (assignment : Fin (n * 6) → Bool) (e : Fin m) : + VerifierToCNF.eventValue (verifier G vertices edges) assignment e = + G.edgeSatisfied (labelsOfBits vertices assignment) (edges.symm e) := by + simp only [VerifierToCNF.eventValue, Fin.addCases_left, Fin.addCases_right, + ConstraintGraph.edgeSatisfied] + rfl + +theorem count_false_map_filter {α : Type*} (xs : List α) (f : α → Bool) : + (xs.map f).count false = (xs.filter (fun x => decide (f x = false))).length := by + induction xs with + | nil => rfl + | cons x xs ih => cases h : f x <;> simp [h, ih, Nat.add_comm] + +theorem count_false_finRange (f : Fin m → Bool) : + ((List.finRange m).map f).count false = + (Finset.univ.filter (fun e : Fin m => f e = false)).card := by + classical + calc + _ = ((List.finRange m).filter (fun e => decide (f e = false))).length := + count_false_map_filter _ _ + _ = (((List.finRange m).filter (fun e => decide (f e = false))).toFinset).card := + (List.toFinset_card_of_nodup ((List.nodup_finRange m).filter _)).symm + _ = _ := by + congr 1 + ext e + simp + +theorem rejection_count_eq [Fintype E] (G : ConstraintGraph V E Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) (assignment : Fin (n * 6) → Bool) : + VerifierToCNF.rejectedEventCount (verifier G vertices edges) assignment = + G.rejectionCount (labelsOfBits vertices assignment) := by + classical + change ((List.finRange m).map + (VerifierToCNF.eventValue (verifier G vertices edges) assignment)).count false = _ + rw [count_false_finRange] + change (Finset.univ.filter (fun e : Fin m => + VerifierToCNF.eventValue (verifier G vertices edges) assignment e = false)).card = + (G.rejectedDarts (labelsOfBits vertices assignment)).card + apply Finset.card_equiv edges.symm + intro e + simp only [Finset.mem_filter, Finset.mem_univ, true_and, + ConstraintGraph.rejectedDarts, eventValue_eq] + +theorem verifier_completeness (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (labeling : V → Label) + (satisfied : ∀ e, G.edgeSatisfied labeling e = true) : + ∀ e, VerifierToCNF.eventValue (verifier G vertices edges) + (bitsOfLabels vertices labeling) e = true := by + intro e + rw [eventValue_eq, labelsOfBits_bitsOfLabels] + exact satisfied (edges.symm e) + +theorem verifier_reflects (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (assignment : Fin (n * 6) → Bool) + (accepted : ∀ e, VerifierToCNF.eventValue (verifier G vertices edges) assignment e = true) : + ∀ e, G.edgeSatisfied (labelsOfBits vertices assignment) e = true := by + intro e + have h := accepted (edges e) + simpa only [eventValue_eq, Equiv.symm_apply_apply] using h + +def cnf (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) (edges : E ≃ Fin m) : Formula := + VerifierToCNF.convert (verifier G vertices edges) (by decide) + +abbrev OutputAssignment (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) := + Fin (VerifierToCNF.outputVariables (verifier G vertices edges)) → Bool + +def extractLabeling (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (assignment : OutputAssignment G vertices edges) : V → Label := + labelsOfBits vertices (VerifierToCNF.restrictAssignment (verifier G vertices edges) assignment) + +theorem cnf_completeness (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (sat : G.Satisfiable) : (cnf G vertices edges).Satisfiable := by + obtain ⟨labeling, satisfied⟩ := sat + exact VerifierToCNF.convert_completeness (verifier G vertices edges) (by decide) + (bitsOfLabels vertices labeling) (verifier_completeness G vertices edges labeling satisfied) + +theorem cnf_count_bridge [Fintype E] (G : ConstraintGraph V E Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) (assignment : OutputAssignment G vertices edges) : + G.rejectionCount (extractLabeling G vertices edges assignment) ≤ + NameCompaction.failedCount (cnf G vertices edges) assignment := by + have h := VerifierToCNF.convert_count_bridge (verifier G vertices edges) (by decide) assignment + rw [rejection_count_eq] at h + exact h + +theorem failedCount_zero_of_satisfied (F : Formula) (assignment : Fin F.«variables» → Bool) + (satisfied : ∀ c ∈ F.clauses, c.eval assignment = true) : + NameCompaction.failedCount F assignment = 0 := by + apply (VerifierToCNF.zero_false_count_iff_all _).mpr + have h := List.all_eq_true.mpr satisfied + simpa only [NameCompaction.evaluationList, List.all_map, Function.comp_def, id_eq] using h + +theorem all_satisfied_of_rejectionCount_zero [Fintype E] (G : ConstraintGraph V E Label) + (labeling : V → Label) (zero : G.rejectionCount labeling = 0) : + ∀ e, G.edgeSatisfied labeling e = true := by + intro e + cases h : G.edgeSatisfied labeling e with + | true => rfl + | false => + have member : e ∈ G.rejectedDarts labeling := (G.mem_rejectedDarts labeling e).mpr h + have positive : 0 < G.rejectionCount labeling := Finset.card_pos.mpr ⟨e, member⟩ + omega + +theorem cnf_reflects [Fintype E] (G : ConstraintGraph V E Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) (sat : (cnf G vertices edges).Satisfiable) : + G.Satisfiable := by + obtain ⟨assignment, satisfied⟩ := sat + have zero := failedCount_zero_of_satisfied (cnf G vertices edges) assignment satisfied + have bound := cnf_count_bridge G vertices edges assignment + have graphZero : G.rejectionCount (extractLabeling G vertices edges assignment) = 0 := by omega + exact ⟨extractLabeling G vertices edges assignment, + all_satisfied_of_rejectionCount_zero G _ graphZero⟩ + +theorem cnf_satisfiable_iff [Fintype E] (G : ConstraintGraph V E Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) : + (cnf G vertices edges).Satisfiable ↔ G.Satisfiable := + ⟨cnf_reflects G vertices edges, cnf_completeness G vertices edges⟩ + +theorem cnf_clause_count (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) : (cnf G vertices edges).clauses.length = m * 40960 := + VerifierToCNF.twelve_query_clause_count (verifier G vertices edges) + +theorem twelve_query_auxiliary_factor : 2 ^ 12 * (12 - 3) = 36864 := by decide + +theorem cnf_variable_count (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) : (cnf G vertices edges).«variables» = n * 6 + m * 36864 := by + change n * 6 + m * (VerifierToCNF.patterns 12).length * (12 - 3) = _ + rw [VerifierToCNF.patterns_length, Nat.mul_assoc, twelve_query_auxiliary_factor] + +theorem cnf_nonempty (G : ConstraintGraph V E Label) (vertices : V ≃ Fin n) + (edges : E ≃ Fin m) (nonempty : 0 < m) : (cnf G vertices edges).clauses ≠ [] := + VerifierToCNF.convert_nonempty (verifier G vertices edges) (by decide) nonempty + +theorem cnf_gap [Fintype E] (G : ConstraintGraph V E Label) + (vertices : V ≃ Fin n) (edges : E ≃ Fin m) (a b : Nat) + (source : ∀ labeling : V → Label, a * Fintype.card E ≤ b * G.rejectionCount labeling) + (assignment : OutputAssignment G vertices edges) : + a * (cnf G vertices edges).clauses.length ≤ + (b * 40960) * NameCompaction.failedCount (cnf G vertices edges) assignment := by + have cardEdges : Fintype.card E = m := by simpa using Fintype.card_congr edges + have testGap (bits : Fin (n * 6) → Bool) : + a * m ≤ b * VerifierToCNF.rejectedEventCount (verifier G vertices edges) bits := by + rw [rejection_count_eq] + simpa only [cardEdges] using source (labelsOfBits vertices bits) + simpa only [cnf, VerifierToCNF.twelve_query_factor] using + VerifierToCNF.convert_gap (verifier G vertices edges) (by decide) a b testGap assignment + +abbrev ReducedVertex (V E A : Type*) := + QueryIncidence.Vertex (AlphabetGraph.Event E A) (AlphabetGraph.Address V E A) + +abbrev ReducedDart (E A : Type*) := QueryIncidence.Dart (AlphabetGraph.Event E A) 6 + +variable {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + [DecidableEq V] [DecidableEq E] + +noncomputable def alphabetCNF (G : ConstraintGraph V E A) + (vertices : ReducedVertex V E A ≃ Fin n) (edges : ReducedDart E A ≃ Fin m) : Formula := + cnf (AlphabetGraph.graph G) vertices edges + +omit [DecidableEq A] [Nonempty A] in +theorem alphabetCNF_completeness (G : ConstraintGraph V E A) + (vertices : ReducedVertex V E A ≃ Fin n) (edges : ReducedDart E A ≃ Fin m) + (sat : G.Satisfiable) : (alphabetCNF G vertices edges).Satisfiable := + cnf_completeness (AlphabetGraph.graph G) vertices edges (AlphabetGraph.perfect_completeness G sat) + +omit [DecidableEq A] [Nonempty A] in +theorem alphabetCNF_clause_count (G : ConstraintGraph V E A) + (vertices : ReducedVertex V E A ≃ Fin n) (edges : ReducedDart E A ≃ Fin m) : + (alphabetCNF G vertices edges).clauses.length = m * 40960 := + cnf_clause_count (AlphabetGraph.graph G) vertices edges + +theorem alphabetCNF_gap [Fintype E] (G : ConstraintGraph V E A) + (vertices : ReducedVertex V E A ≃ Fin n) (edges : ReducedDart E A ≃ Fin m) + (a b : Nat) + (source : ∀ labeling : V → A, a * Fintype.card E ≤ b * G.rejectionCount labeling) + (assignment : OutputAssignment (AlphabetGraph.graph G) vertices edges) : + a * (alphabetCNF G vertices edges).clauses.length ≤ + (b * 503316480) * NameCompaction.failedCount (alphabetCNF G vertices edges) assignment := by + have h := cnf_gap (AlphabetGraph.graph G) vertices edges a (b * 12288) + (AlphabetGraph.gap_transfer G a b source) assignment + have factor : (b * 12288) * 40960 = b * 503316480 := by omega + simpa only [alphabetCNF, factor] using h + +end IndependentSetsGames.Foundations.PCP.FinalBooleanVerifier + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNF.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNF.lean new file mode 100644 index 0000000000000000000000000000000000000000..425a81f239329881693b0d7e4ca6906687725f5d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNF.lean @@ -0,0 +1,86 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Fourier.Gap +import OAI.Combinatorics.IndependentSets.PCP.PCPIteration + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.PCP.PCPIteration +open FiniteGraph + +variable (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) {n m : Nat} + (vertices : (output addresses complete F).Vertex ≃ Fin n) + (darts : (output addresses complete F).Dart ≃ Fin m) + +def finalCNF : Target.Formula := + FinalBooleanVerifier.cnf (output addresses complete F).graph vertices darts + +theorem finalCNF_satisfiable_iff : + (finalCNF addresses complete F vertices darts).Satisfiable ↔ F.Satisfiable := + (FinalBooleanVerifier.cnf_satisfiable_iff _ vertices darts).trans + (output_satisfiable_iff addresses complete F) + +theorem finalCNF_clause_count : + (finalCNF addresses complete F vertices darts).clauses.length = m * 40960 := + FinalBooleanVerifier.cnf_clause_count _ vertices darts + +theorem finalCNF_variable_count : + (finalCNF addresses complete F vertices darts).«variables» = n * 6 + m * 36864 := + FinalBooleanVerifier.cnf_variable_count _ vertices darts + +theorem finalCNF_nonempty : (finalCNF addresses complete F vertices darts).clauses ≠ [] := by + have hm : Fintype.card (output addresses complete F).Dart = m := by + simpa only [Fintype.card_fin] using Fintype.card_congr darts + have hpositive : 0 < m := hm ▸ (Fintype.card_pos : + 0 < Fintype.card (output addresses complete F).Dart) + exact FinalBooleanVerifier.cnf_nonempty _ vertices darts hpositive + +theorem finalCNF_gap (unsat : ¬ F.Satisfiable) + (assignment : Fin (finalCNF addresses complete F vertices darts).«variables» → Bool) : + (finalCNF addresses complete F vertices darts).clauses.length ≤ + (FinalConstants.walkLength * 40960) * + NameCompaction.failedCount (finalCNF addresses complete F vertices darts) assignment := by + have source (labeling : (output addresses complete F).Vertex → Label) : + 1 * Fintype.card (output addresses complete F).Dart ≤ + FinalConstants.walkLength * (output addresses complete F).graph.rejectionCount labeling := by + simpa only [one_mul, Bundle.rejectionCount] using output_count_gap addresses complete F unsat labeling + simpa only [one_mul, finalCNF] using FinalBooleanVerifier.cnf_gap + (output addresses complete F).graph vertices darts 1 FinalConstants.walkLength source assignment + +theorem finalCNF_clauseGap (unsat : ¬ F.Satisfiable) : + Hastad.SourceGap.ClauseGap (finalCNF addresses complete F vertices darts) finalClauseGap := + Hastad.SourceNonempty.cnf_clauseGap_unit (output addresses complete F).graph + vertices darts FinalConstants.walkLength FinalConstants.walkLength_positive + (output_count_gap addresses complete F unsat) + +theorem finalCNF_total_size : + (finalCNF addresses complete F vertices darts).«variables» + + (finalCNF addresses complete F vertices darts).clauses.length ≤ + 77824 * (output addresses complete F).size := by + have hn : Fintype.card (output addresses complete F).Vertex = n := by + simpa only [Fintype.card_fin] using Fintype.card_congr vertices + have hm : Fintype.card (output addresses complete F).Dart = m := by + simpa only [Fintype.card_fin] using Fintype.card_congr darts + have hsize : (output addresses complete F).size = n + m := congrArg₂ Nat.add hn hm + calc + _ = n * 6 + m * 36864 + m * 40960 := + congrArg₂ Nat.add (finalCNF_variable_count addresses complete F vertices darts) + (finalCNF_clause_count addresses complete F vertices darts) + _ ≤ 77824 * (n + m) := by omega + _ = 77824 * (output addresses complete F).size := + congrArg (fun k => 77824 * k) hsize.symm + +theorem finalCNF_polynomial_size : + (finalCNF addresses complete F vertices darts).«variables» + + (finalCNF addresses complete F vertices darts).clauses.length ≤ + 77824 * ((2 * (10 * F.clauses.length + 2)) ^ polynomialDegree * + (10 * F.clauses.length + 2)) := + (finalCNF_total_size addresses complete F vertices darts).trans + (Nat.mul_le_mul_left _ (output_size_clause_bound addresses complete F)) + +end IndependentSetsGames.Foundations.PCP.PCPIteration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFPattern.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFPattern.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2f65f1ece257d7bbd7b362dd419e66dc23504b6 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFPattern.lean @@ -0,0 +1,103 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GraphTables +import OAI.Combinatorics.IndependentSets.PCP.Enumeration +import OAI.Combinatorics.IndependentSets.PCP.FinalBooleanVerifier +import OAI.Combinatorics.IndependentSets.PCP.Minimum + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFPattern + +open PCP +open scoped BigOperators + +abbrev Label := FinalBooleanVerifier.Label + +abbrev labelEquiv : Label ≃ Fin 64 := AlphabetTable.Enumeration.labelEquiv + +theorem labelEquiv_val (label : Label) : + (labelEquiv label).val = + ∑ i : Fin 6, AlphabetTable.Enumeration.bitValue (label i) * 2 ^ i.val := + AlphabetTable.Enumeration.labelEquiv_val label + +def labelIndex (label : Label) : Fin 64 := labelEquiv label + +def labelBits (index : Fin 64) : Label := labelEquiv.symm index + +@[simp] theorem labelBits_labelIndex (label : Label) : + labelBits (labelIndex label) = label := labelEquiv.symm_apply_apply label + +@[simp] theorem labelIndex_labelBits (index : Fin 64) : + labelIndex (labelBits index) = index := labelEquiv.apply_symm_apply index + +def leftHalf (bits : VerifierToCNF.Pattern 12) : Label := + fun j => bits (Fin.castAdd 6 j) + +def rightHalf (bits : VerifierToCNF.Pattern 12) : Label := + fun j => bits (Fin.natAdd 6 j) + +def relationAddress (bits : VerifierToCNF.Pattern 12) : Fin 4096 := + GraphTables.relationIndex (labelIndex (leftHalf bits), labelIndex (rightHalf bits)) + +theorem relationAddress_val (bits : VerifierToCNF.Pattern 12) : + (relationAddress bits).val = + 64 * (labelIndex (leftHalf bits)).val + (labelIndex (rightHalf bits)).val := by + rw [relationAddress, GraphTables.relationIndex_val, Nat.add_comm] + +def patternRelationIndex (p : VerifierToCNF.PatternIndex 12) : Fin 4096 := + relationAddress (VerifierToCNF.patternAt 12 p) + +@[simp] theorem patternRelationIndex_eq (p : VerifierToCNF.PatternIndex 12) : + patternRelationIndex p = relationAddress (VerifierToCNF.patternAt 12 p) := rfl + +def tableGraph (table : GraphTables.Table) : + ConstraintGraph (Fin table.vertices) (Fin table.darts) Label := + (GraphTables.semantics table).reindex (Equiv.refl _) (Equiv.refl _) labelEquiv.symm + +@[simp] theorem tableGraph_tail (table : GraphTables.Table) (e : Fin table.darts) : + (tableGraph table).tail e = table.rows[e].tail := rfl + +@[simp] theorem tableGraph_reverse (table : GraphTables.Table) (e : Fin table.darts) : + (tableGraph table).reverse e = table.rows[e].reverseIndex := rfl + +@[simp] theorem tableGraph_accepts (table : GraphTables.Table) (e : Fin table.darts) + (a b : Label) : + (tableGraph table).accepts e a b = + GraphTables.relationAt table.rows[e].relation (labelIndex a) (labelIndex b) := rfl + +abbrev tableVerifier (table : GraphTables.Table) : VerifierToCNF.FiniteVerifier 12 := + FinalBooleanVerifier.verifier (tableGraph table) (Equiv.refl _) (Equiv.refl _) + +theorem relation_lookup_eq_verifier_accepts (table : GraphTables.Table) + (e : Fin table.darts) (bits : VerifierToCNF.Pattern 12) : + table.rows[e].relation[relationAddress bits] = + (tableVerifier table).accepts e bits := rfl + +theorem pattern_lookup_eq_verifier_accepts (table : GraphTables.Table) + (e : Fin table.darts) (p : VerifierToCNF.PatternIndex 12) : + table.rows[e].relation[patternRelationIndex p] = + (tableVerifier table).accepts e (VerifierToCNF.patternAt 12 p) := rfl + +theorem verifier_accepts_eq_lookup (table : GraphTables.Table) + (e : Fin table.darts) (bits : VerifierToCNF.Pattern 12) : + (tableVerifier table).accepts e bits = + table.rows[e].relation[relationAddress bits] := rfl + +theorem buffer_lookup_eq_verifier_accepts (table : GraphTables.Table) + (e : Fin table.darts) (buffer : Fin 4096 → Bool) + (read_correct : ∀ i, buffer i = table.rows[e].relation[i]) + (bits : VerifierToCNF.Pattern 12) : + buffer (relationAddress bits) = (tableVerifier table).accepts e bits := + (read_correct _).trans (relation_lookup_eq_verifier_accepts table e bits) + +theorem pattern_buffer_lookup_eq_verifier_accepts (table : GraphTables.Table) + (e : Fin table.darts) (buffer : Fin 4096 → Bool) + (read_correct : ∀ i, buffer i = table.rows[e].relation[i]) + (p : VerifierToCNF.PatternIndex 12) : + buffer (patternRelationIndex p) = + (tableVerifier table).accepts e (VerifierToCNF.patternAt 12 p) := + buffer_lookup_eq_verifier_accepts table e buffer read_correct _ + +end IndependentSetsGames.Foundations.Complexity.FinalCNFPattern + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFTableAdapter.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFTableAdapter.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2a24c0631367c04856f7f22cd6bfa4c8b83ac7b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFTableAdapter.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.FinalCNFPattern +import OAI.Combinatorics.IndependentSets.PCP.Ambient + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFTableAdapter + +open PCP + +def genericRow {n m : Nat} (row : GraphTables.DartRow n m) : + GenericGraphTables.DartRow 64 n m := + ⟨row.tail, row.reverseIndex, row.relation⟩ + +@[simp] theorem genericRow_tail {n m : Nat} (row : GraphTables.DartRow n m) : + (genericRow row).tail = row.tail := rfl + +@[simp] theorem genericRow_reverseIndex {n m : Nat} (row : GraphTables.DartRow n m) : + (genericRow row).reverseIndex = row.reverseIndex := rfl + +@[simp] theorem genericRow_relation {n m : Nat} (row : GraphTables.DartRow n m) : + (genericRow row).relation = row.relation := rfl + +def genericRows {n m : Nat} (rows : GraphTables.Rows n m) : + GenericGraphTables.Rows 64 n m := rows.map genericRow + +@[simp] theorem genericRows_get {n m : Nat} (rows : GraphTables.Rows n m) (e : Fin m) : + (genericRows rows)[e] = genericRow rows[e] := by + simp [genericRows] + +@[simp] theorem genericRows_reverseAt {n m : Nat} (rows : GraphTables.Rows n m) + (e : Fin m) : + GenericGraphTables.reverseAt (genericRows rows) e = GraphTables.reverseAt rows e := by + change (genericRows rows)[e].reverseIndex = rows[e].reverseIndex + rw [genericRows_get] + rfl + +@[simp] theorem genericRows_acceptsAt {n m : Nat} (rows : GraphTables.Rows n m) + (e : Fin m) (a b : Fin 64) : + GenericGraphTables.acceptsAt (genericRows rows) e a b = + GraphTables.acceptsAt rows e a b := by + simp only [GenericGraphTables.acceptsAt, genericRows_get, genericRow_relation] + rfl + +theorem genericRows_valid {n m : Nat} (rows : GraphTables.Rows n m) + (valid : GraphTables.Valid rows) : GenericGraphTables.Valid (genericRows rows) := by + constructor + · intro e + simpa only [genericRows_reverseAt] using valid.1 e + · intro e a b + simpa only [genericRows_reverseAt, genericRows_acceptsAt] using valid.2 e a b + +def genericTable (table : GraphTables.Table) : GenericGraphTables.Table 64 where + vertices := table.vertices + darts := table.darts + rows := genericRows table.rows + valid := genericRows_valid table.rows table.valid + +@[simp] theorem genericTable_vertices (table : GraphTables.Table) : + (genericTable table).vertices = table.vertices := rfl + +@[simp] theorem genericTable_darts (table : GraphTables.Table) : + (genericTable table).darts = table.darts := rfl + +@[simp] theorem genericTable_row (table : GraphTables.Table) (e : Fin table.darts) : + (genericTable table).rows[e] = genericRow table.rows[e] := genericRows_get _ _ + +@[simp] theorem genericTable_tail (table : GraphTables.Table) (e : Fin table.darts) : + (genericTable table).rows[e].tail = table.rows[e].tail := by + rw [genericTable_row] + rfl + +@[simp] theorem genericTable_reverseIndex (table : GraphTables.Table) (e : Fin table.darts) : + (genericTable table).rows[e].reverseIndex = table.rows[e].reverseIndex := by + rw [genericTable_row] + rfl + +@[simp] theorem genericTable_relation (table : GraphTables.Table) (e : Fin table.darts) : + (genericTable table).rows[e].relation = table.rows[e].relation := by + rw [genericTable_row] + rfl + +@[simp] theorem genericRow_words {n m : Nat} (row : GraphTables.DartRow n m) : + GenericGraphTables.rowWords (genericRow row) = GraphTables.rowWords row := rfl + +theorem genericTable_rowList (table : GraphTables.Table) : + GenericGraphTables.rowList (genericTable table) = + (GraphTables.rowList table).map genericRow := by + simp only [GenericGraphTables.rowList, GraphTables.rowList, genericTable, + genericRows, Vector.toList_map] + +@[simp] theorem genericTable_tableWords (table : GraphTables.Table) : + GenericGraphTables.tableWords (genericTable table) = GraphTables.tableWords table := by + simp only [GenericGraphTables.tableWords, GraphTables.tableWords, + genericTable_vertices, genericTable_darts, genericTable_rowList, List.flatMap_map, + genericRow_words] + +@[simp] theorem genericTable_tableBits (table : GraphTables.Table) : + GenericGraphTables.tableBits (genericTable table) = GraphTables.tableBits table := by + simp only [GenericGraphTables.tableBits, GraphTables.tableBits, genericTable_tableWords] + +@[simp] theorem genericTable_semantics_tail (table : GraphTables.Table) (e : Fin table.darts) : + (GenericGraphTables.semantics (genericTable table)).tail e = + (GraphTables.semantics table).tail e := genericTable_tail table e + +@[simp] theorem genericTable_semantics_reverse (table : GraphTables.Table) + (e : Fin table.darts) : + (GenericGraphTables.semantics (genericTable table)).reverse e = + (GraphTables.semantics table).reverse e := genericTable_reverseIndex table e + +@[simp] theorem genericTable_semantics_head (table : GraphTables.Table) (e : Fin table.darts) : + (GenericGraphTables.semantics (genericTable table)).head e = + (GraphTables.semantics table).head e := by + exact (genericTable_semantics_tail table _).trans + (congrArg (GraphTables.semantics table).tail (genericTable_semantics_reverse table e)) + +@[simp] theorem genericTable_semantics_accepts (table : GraphTables.Table) + (e : Fin table.darts) (a b : Fin 64) : + (GenericGraphTables.semantics (genericTable table)).accepts e a b = + (GraphTables.semantics table).accepts e a b := genericRows_acceptsAt _ _ _ _ + +@[simp] theorem genericTable_headIndex (table : GraphTables.Table) (e : Fin table.darts) : + AlphabetTable.Lookup.headIndex (genericTable table) e = table.rows[e].reverseIndex := + genericTable_reverseIndex table e + +@[simp] theorem genericTable_headValue (table : GraphTables.Table) (e : Fin table.darts) : + AlphabetTable.Lookup.headValue (genericTable table) e = + ((GraphTables.semantics table).head e).val := by + exact (AlphabetTable.Lookup.headValue_eq_semantics (genericTable table) e).trans + (congrArg Fin.val (genericTable_semantics_head table e)) + +theorem genericTable_headValue_tableGraph (table : GraphTables.Table) (e : Fin table.darts) : + AlphabetTable.Lookup.headValue (genericTable table) e = + ((FinalCNFPattern.tableGraph table).head e).val := by + rw [genericTable_headValue] + rfl + +theorem genericTable_pattern_relation (table : GraphTables.Table) (e : Fin table.darts) + (p : VerifierToCNF.PatternIndex 12) : + (genericTable table).rows[e].relation[FinalCNFPattern.patternRelationIndex p] = + (FinalCNFPattern.tableVerifier table).accepts e (VerifierToCNF.patternAt 12 p) := by + rw [genericTable_relation] + exact FinalCNFPattern.pattern_lookup_eq_verifier_accepts table e p + +end IndependentSetsGames.Foundations.Complexity.FinalCNFTableAdapter + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFTemplate.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFTemplate.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd95c60dab2ad449fa5f496c58328072b49a1f6d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/FinalCNFTemplate.lean @@ -0,0 +1,167 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.VerifierCNF + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFTemplate + +open Target PCP + +inductive Reference where + | query : Fin 12 → Reference + | auxiliary : Fin 9 → Reference + deriving DecidableEq + +structure LiteralTemplate where + reference : Reference + positive : Bool + deriving DecidableEq + +abbrev ClauseTemplate := Vector LiteralTemplate 3 + +def queryLiteral (bits : Fin 12 → Bool) (i : Fin 12) : LiteralTemplate := + ⟨.query i, !(bits i)⟩ + +def auxiliaryLiteral (j : Fin 9) (positive : Bool) : LiteralTemplate := + ⟨.auxiliary j, positive⟩ + +def tautologyTemplate : ClauseTemplate := + #v[⟨.query 0, true⟩, ⟨.query 0, false⟩, ⟨.query 0, true⟩] + +def chainTemplates (bits : Fin 12 → Bool) : Vector ClauseTemplate 10 := + #v[ + #v[queryLiteral bits 0, queryLiteral bits 1, auxiliaryLiteral 0 true], + #v[auxiliaryLiteral 0 false, queryLiteral bits 2, auxiliaryLiteral 1 true], + #v[auxiliaryLiteral 1 false, queryLiteral bits 3, auxiliaryLiteral 2 true], + #v[auxiliaryLiteral 2 false, queryLiteral bits 4, auxiliaryLiteral 3 true], + #v[auxiliaryLiteral 3 false, queryLiteral bits 5, auxiliaryLiteral 4 true], + #v[auxiliaryLiteral 4 false, queryLiteral bits 6, auxiliaryLiteral 5 true], + #v[auxiliaryLiteral 5 false, queryLiteral bits 7, auxiliaryLiteral 6 true], + #v[auxiliaryLiteral 6 false, queryLiteral bits 8, auxiliaryLiteral 7 true], + #v[auxiliaryLiteral 7 false, queryLiteral bits 9, auxiliaryLiteral 8 true], + #v[auxiliaryLiteral 8 false, queryLiteral bits 10, queryLiteral bits 11]] + +def blockTemplates (accepted : Bool) (bits : Fin 12 → Bool) : Vector ClauseTemplate 10 := + if accepted then Vector.replicate 10 tautologyTemplate else chainTemplates bits + +def templates (accepted : Bool) (bits : Fin 12 → Bool) : List ClauseTemplate := + (blockTemplates accepted bits).toList + +def literalAt (accepted : Bool) (bits : Fin 12 → Bool) + (clause : Fin 10) (slot : Fin 3) : LiteralTemplate := + (blockTemplates accepted bits)[clause][slot] + +@[simp] theorem templates_length (accepted : Bool) (bits : Fin 12 → Bool) : + (templates accepted bits).length = 10 := Vector.length_toList + +theorem templates_true (bits : Fin 12 → Bool) : + templates true bits = List.replicate 10 tautologyTemplate := by rfl + +theorem templates_false (bits : Fin 12 → Bool) : + templates false bits = (chainTemplates bits).toList := by rfl + +def literalTemplates (accepted : Bool) (bits : Fin 12 → Bool) : List LiteralTemplate := + (templates accepted bits).flatMap fun c => [(c)[0], (c)[1], (c)[2]] + +theorem literalTemplates_length (accepted : Bool) (bits : Fin 12 → Bool) : + (literalTemplates accepted bits).length = 30 := by + unfold literalTemplates + rw [VerifierToCNF.length_flatMap_constant _ _ 3 (by intro c hc; rfl), templates_length] + +def literalWords (index : Reference → Nat) (literal : LiteralTemplate) : List Nat := + [index literal.reference, if literal.positive then 1 else 0] + +def clauseWords (index : Reference → Nat) (clause : ClauseTemplate) : List Nat := + literalWords index clause[0] ++ literalWords index clause[1] ++ literalWords index clause[2] + +def words (accepted : Bool) (bits : Fin 12 → Bool) (index : Reference → Nat) : List Nat := + (templates accepted bits).flatMap (clauseWords index) + +theorem words_length (accepted : Bool) (bits : Fin 12 → Bool) (index : Reference → Nat) : + (words accepted bits index).length = 60 := by + unfold words + rw [VerifierToCNF.length_flatMap_constant _ _ 6 + (by intro c hc; simp [clauseWords, literalWords]), templates_length] + +variable (V : VerifierToCNF.FiniteVerifier 12) (e : Fin V.events) + (p : VerifierToCNF.PatternIndex 12) + +def resolve : Reference → Fin (VerifierToCNF.outputVariables V) + | .query i => VerifierToCNF.oldIndex V (V.query e i) + | .auxiliary j => VerifierToCNF.freshIndex V e p j + +theorem resolve_query_value (i : Fin 12) : + (resolve V e p (.query i)).val = (V.query e i).val := by + simp only [resolve, VerifierToCNF.oldIndex, Fin.val_castAdd] + +theorem resolve_auxiliary_value (j : Fin 9) : + (resolve V e p (.auxiliary j)).val = + V.«variables» + ((e.val * 4096 + p.val) * 9 + j.val) := by + change (VerifierToCNF.freshIndex V e p j).val = _ + exact (VerifierToCNF.freshIndex_value V e p j).trans + (congrArg (fun k : Nat => V.«variables» + ((e.val * k + p.val) * 9 + j.val)) + (show (VerifierToCNF.patterns 12).length = 4096 from VerifierToCNF.patterns_length 12)) + +def instantiateLiteral (literal : LiteralTemplate) : Literal (VerifierToCNF.outputVariables V) := + ⟨resolve V e p literal.reference, literal.positive⟩ + +def instantiateClause (clause : ClauseTemplate) : Clause (VerifierToCNF.outputVariables V) := + #v[instantiateLiteral V e p clause[0], instantiateLiteral V e p clause[1], + instantiateLiteral V e p clause[2]] + +theorem splitLong_twelve {n : Nat} (ls : Fin 12 → Literal n) (ys : Fin 9 → Fin n) : + VerifierToCNF.splitLong (List.ofFn ls) (List.ofFn ys) = + [#v[ls 0, ls 1, ⟨ys 0, true⟩], + #v[⟨ys 0, false⟩, ls 2, ⟨ys 1, true⟩], + #v[⟨ys 1, false⟩, ls 3, ⟨ys 2, true⟩], + #v[⟨ys 2, false⟩, ls 4, ⟨ys 3, true⟩], + #v[⟨ys 3, false⟩, ls 5, ⟨ys 4, true⟩], + #v[⟨ys 4, false⟩, ls 6, ⟨ys 5, true⟩], + #v[⟨ys 5, false⟩, ls 7, ⟨ys 6, true⟩], + #v[⟨ys 6, false⟩, ls 8, ⟨ys 7, true⟩], + #v[⟨ys 7, false⟩, ls 9, ⟨ys 8, true⟩], + #v[⟨ys 8, false⟩, ls 10, ls 11]] := by + simp only [List.ofFn_succ, List.ofFn_zero, VerifierToCNF.splitLong] + rfl + +theorem instantiate_templates : + (templates (V.accepts e (VerifierToCNF.patternAt 12 p)) + (VerifierToCNF.patternAt 12 p)).map (instantiateClause V e p) = + VerifierToCNF.block V (by decide) e p := by + cases h : V.accepts e (VerifierToCNF.patternAt 12 p) with + | false => + simp only [h, templates_false, VerifierToCNF.block, Bool.false_eq_true, ↓reduceIte, + VerifierToCNF.forbiddenClause, VerifierToCNF.auxiliaryNames] + rw [splitLong_twelve] + rfl + | true => + simp only [h, templates_true, VerifierToCNF.block, ↓reduceIte, List.map_replicate] + rfl + +theorem instantiate_templates_of_acceptance (accepted : Bool) + (h : V.accepts e (VerifierToCNF.patternAt 12 p) = accepted) : + (templates accepted (VerifierToCNF.patternAt 12 p)).map (instantiateClause V e p) = + VerifierToCNF.block V (by decide) e p := by + rw [← h] + exact instantiate_templates V e p + +theorem instantiateClause_words (clause : ClauseTemplate) : + Complexity.clauseWords (instantiateClause V e p clause) = + clauseWords (fun r => (resolve V e p r).val) clause := rfl + +theorem words_eq_block : + words (V.accepts e (VerifierToCNF.patternAt 12 p)) (VerifierToCNF.patternAt 12 p) + (fun r => (resolve V e p r).val) = + (VerifierToCNF.block V (by decide) e p).flatMap Complexity.clauseWords := by + rw [← instantiate_templates V e p] + simp only [List.flatMap_map, instantiateClause_words] + rfl + +theorem block_words_length : + ((VerifierToCNF.block V (by decide) e p).flatMap Complexity.clauseWords).length = 60 := by + rw [← words_eq_block V e p] + exact words_length _ _ _ + +end IndependentSetsGames.Foundations.Complexity.FinalCNFTemplate + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Finish.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Finish.lean new file mode 100644 index 0000000000000000000000000000000000000000..07b5a820ef357e6acec8628caabcb5a40c594b84 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Finish.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Driver + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Finish + +open Turing +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel +open scoped BigOperators + +def afterReversal (base : Tape → List Bool) (word : List Bool) : Tape → List Bool := + Reduction.MachineTransfer.tapesAt .reversed .output base [] word + +@[simp] theorem afterReversal_output (base : Tape → List Bool) (word : List Bool) : + afterReversal base word .output = word := by + simp [afterReversal, Reduction.MachineTransfer.tapesAt] + +@[simp] theorem afterReversal_reversed (base : Tape → List Bool) (word : List Bool) : + afterReversal base word .reversed = [] := by + simp [afterReversal, Reduction.MachineTransfer.tapesAt] + +def finishBudget (base : Tape → List Bool) (word : List Bool) : Nat := + word.length + 1 + (∑ i : Fin 15, (afterReversal base word (cleanupPorts i)).length) + 16 + +def reverseInTime (q : Nat) (base : Tape → List Bool) (word : List Bool) + (state : State q) (hreversed : base .reversed = word.reverse) + (houtput : base .output = []) : + StateTransition.EvalsToInTime (Driver.machine q).step + ⟨some .reverseOutput, state, base⟩ + (some ⟨some (.cleanup 0), (state.1, none), afterReversal base word⟩) + (word.length + 1) := by + have run := Reduction.MachineTransfer.transferAtInTime + (σ := Ambient q) Tape.reversed Tape.output (by decide) id false + Driver.Label.reverseOutput (some (.cleanup 0)) (Driver.program q) rfl + base state.1 state.2 + simpa only [hreversed, houtput, List.length_reverse, List.reverse_reverse, + List.map_id, List.append_nil, afterReversal, Driver.machine, FinTM2.step] using! run + +theorem cleared_eq_haltList (q : Nat) (base : Tape → List Bool) : + (⟨none, initial q, Cleanup.clearTapes cleanupPorts base⟩ : (Driver.machine q).Cfg) = + haltList (Driver.machine q) (base .output) := by + have tapes := Cleanup.clearTapes_outputOnly cleanupPorts Tape.output base + cleanupPorts_ne_output cleanupPorts_cover + congr 1 + +def cleanupInTime (q : Nat) (base : Tape → List Bool) (state : State q) : + StateTransition.EvalsToInTime (Driver.machine q).step + ⟨some (.cleanup 0), state, base⟩ + (some (haltList (Driver.machine q) (base .output))) + ((∑ i : Fin 15, (base (cleanupPorts i)).length) + 16) := by + have run := Cleanup.cleanupInTime cleanupPorts Driver.Label.cleanup (initial q).1 none + (Driver.program q) + (fun i => by simp only [Driver.program, Cleanup.instruction_drain]) + (by simp only [Driver.program, Cleanup.instruction_finish]) base state.1 state.2 + change StateTransition.EvalsToInTime (Driver.machine q).step + ⟨some (.cleanup 0), state, base⟩ + (some ⟨none, initial q, Cleanup.clearTapes cleanupPorts base⟩) + ((∑ i : Fin 15, (base (cleanupPorts i)).length) + 15 + 1) at run + rw [cleared_eq_haltList] at run + simpa only [Nat.add_assoc] using run + +def finishInTime (q : Nat) (base : Tape → List Bool) (word : List Bool) + (state : State q) (hreversed : base .reversed = word.reverse) + (houtput : base .output = []) : + StateTransition.EvalsToInTime (Driver.machine q).step + ⟨some .reverseOutput, state, base⟩ + (some (haltList (Driver.machine q) word)) (finishBudget base word) := by + have first := reverseInTime q base word state hreversed houtput + have last := cleanupInTime q (afterReversal base word) (state.1, none) + rw [afterReversal_output] at last + have run := StateTransition.EvalsToInTime.trans (Driver.machine q).step _ _ + ⟨some .reverseOutput, state, base⟩ + ⟨some (.cleanup 0), (state.1, none), afterReversal base word⟩ + (some (haltList (Driver.machine q) word)) first last + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have budgetEq : ((∑ i : Fin 15, (afterReversal base word (cleanupPorts i)).length) + 16) + + (word.length + 1) = + finishBudget base word := by + dsimp only [finishBudget] + omega + exact run.steps_le_m.trans (Nat.le_of_eq budgetEq) + +theorem afterReversal_selected_length_le (base : Tape → List Bool) (word : List Bool) + (i : Fin 15) : + (afterReversal base word (cleanupPorts i)).length ≤ (base (cleanupPorts i)).length := by + have ho := cleanupPorts_ne_output i + by_cases hr : cleanupPorts i = .reversed <;> + simp [afterReversal, Reduction.MachineTransfer.tapesAt, ho, hr] + +theorem stackLength_after_prefix (q : Nat) (input : List Bool) + (base : Tape → List Bool) (state : State q) (budget : Nat) + (prefixRun : StateTransition.EvalsToInTime (Driver.machine q).step + (initList (Driver.machine q) input) (some ⟨some .reverseOutput, state, base⟩) budget) + (k : Tape) : + (base k).length ≤ input.length + budget * Runtime.programPushBound (Driver.machine q) := by + have bound := Runtime.executionSizeBound (Driver.machine q).step + (fun cfg => (cfg.stk k).length) (Runtime.programPushBound (Driver.machine q)) + (Runtime.stepStackLength (Driver.machine q) k) prefixRun + exact bound.trans (Nat.add_le_add_right + (Runtime.initialStackLength (Driver.machine q) input k) _) + +theorem finishBudget_le_of_prefix (q : Nat) (input : List Bool) + (base : Tape → List Bool) (word : List Bool) (state : State q) (budget : Nat) + (prefixRun : StateTransition.EvalsToInTime (Driver.machine q).step + (initList (Driver.machine q) input) (some ⟨some .reverseOutput, state, base⟩) budget) + (hreversed : base .reversed = word.reverse) : + finishBudget base word ≤ + 16 * (input.length + budget * Runtime.programPushBound (Driver.machine q)) + 17 := by + let B := input.length + budget * Runtime.programPushBound (Driver.machine q) + have wordBound : word.length ≤ B := by + simpa only [hreversed, List.length_reverse] using + stackLength_after_prefix q input base state budget prefixRun .reversed + have sumBound : (∑ i : Fin 15, (afterReversal base word (cleanupPorts i)).length) ≤ 15 * B := by + calc + _ ≤ ∑ _i : Fin 15, B := by + apply Finset.sum_le_sum + intro i _ + exact (afterReversal_selected_length_le base word i).trans + (stackLength_after_prefix q input base state budget prefixRun (cleanupPorts i)) + _ = 15 * B := by simp + dsimp only [finishBudget] + omega + +noncomputable def completedPolynomial (q : Nat) (prefixTime : Polynomial Nat) : Polynomial Nat := + prefixTime + Polynomial.C 16 * + (Polynomial.X + Polynomial.C (Runtime.programPushBound (Driver.machine q)) * prefixTime) + + Polynomial.C 17 + +def finishAfterPrefix (q : Nat) (input : List Bool) (base : Tape → List Bool) + (word : List Bool) (state : State q) (budget : Nat) + (prefixRun : StateTransition.EvalsToInTime (Driver.machine q).step + (initList (Driver.machine q) input) (some ⟨some .reverseOutput, state, base⟩) budget) + (hreversed : base .reversed = word.reverse) (houtput : base .output = []) : + TM2OutputsInTime (Driver.machine q) input (some word) + (budget + 16 * (input.length + budget * Runtime.programPushBound (Driver.machine q)) + 17) := by + have last := finishInTime q base word state hreversed houtput + let run := StateTransition.EvalsToInTime.trans (Driver.machine q).step _ _ + (initList (Driver.machine q) input) ⟨some .reverseOutput, state, base⟩ + (some (haltList (Driver.machine q) word)) prefixRun last + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + have finishBound := finishBudget_le_of_prefix q input base word state budget prefixRun hreversed + have allBound := run.steps_le_m + omega + +def finishAfterPolynomialPrefix (q : Nat) (input : List Bool) (base : Tape → List Bool) + (word : List Bool) (state : State q) (prefixTime : Polynomial Nat) + (prefixRun : StateTransition.EvalsToInTime (Driver.machine q).step + (initList (Driver.machine q) input) (some ⟨some .reverseOutput, state, base⟩) + (prefixTime.eval input.length)) + (hreversed : base .reversed = word.reverse) (houtput : base .output = []) : + TM2OutputsInTime (Driver.machine q) input (some word) + ((completedPolynomial q prefixTime).eval input.length) := by + have run := finishAfterPrefix q input base word state (prefixTime.eval input.length) + prefixRun hreversed houtput + refine { toEvalsTo := run.toEvalsTo, steps_le_m := ?_ } + simpa only [completedPolynomial, Polynomial.eval_add, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_X, Nat.mul_comm] using run.steps_le_m + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Finish + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Gap.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Gap.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd795e5fe2e1716abd3c66a824b7b1475a56af07 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Gap.lean @@ -0,0 +1,265 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingTableSpectral +import OAI.Combinatorics.IndependentSets.Expansion.PoweringTableSemantics +import OAI.Combinatorics.IndependentSets.PCP.AlphabetGraphBounds +import OAI.Combinatorics.IndependentSets.PCP.RawInitialTables + +namespace OAI + +noncomputable section +namespace IndependentSetsGames.Foundations.PCP.FiniteGraph +namespace Bundle +variable {A : Type} + +variable [Fintype A] [Nonempty A] + +def minimumRejections (G : Bundle A) : Nat := G.graph.minimumRejections + +def gap (G : Bundle A) : ℝ := G.graph.gap + +theorem exists_minimizer (G : Bundle A) : + ∃ labeling : G.Vertex → A, G.rejectionCount labeling = G.minimumRejections := + G.graph.exists_minimizer + +theorem gap_nonnegative (G : Bundle A) : 0 ≤ G.gap := G.graph.gap_nonnegative + +theorem gap_le_one (G : Bundle A) : G.gap ≤ 1 := G.graph.gap_le_one + +theorem gap_eq_zero_iff (G : Bundle A) : G.gap = 0 ↔ G.Satisfiable := + G.graph.gap_eq_zero_iff + +theorem le_gap_iff (G : Bundle A) (ε : ℝ) : + ε ≤ G.gap ↔ ∀ labeling : G.Vertex → A, + ε * Fintype.card G.Dart ≤ (G.rejectionCount labeling : ℝ) := + G.graph.le_gap_iff ε + +theorem inverse_card_le_gap_of_unsatisfiable (G : Bundle A) (unsat : ¬ G.Satisfiable) : + 1 / (Fintype.card G.Dart : ℝ) ≤ G.gap := + G.graph.inverse_card_le_gap_of_unsatisfiable unsat + +theorem one_le_dartCard_mul_gap (G : Bundle A) (unsat : ¬ G.Satisfiable) : + 1 ≤ (Fintype.card G.Dart : ℝ) * G.gap := by + have he : (0 : ℝ) < Fintype.card G.Dart := by exact_mod_cast Fintype.card_pos + have h := (div_le_iff₀ he).mp (G.inverse_card_le_gap_of_unsatisfiable unsat) + simpa only [mul_comm] using h + +theorem one_le_size_mul_gap (G : Bundle A) (unsat : ¬ G.Satisfiable) : + 1 ≤ (G.size : ℝ) * G.gap := by + have hsize : (Fintype.card G.Dart : ℝ) ≤ (G.size : ℝ) := by + exact_mod_cast G.dartCard_le_size + exact (G.one_le_dartCard_mul_gap unsat).trans + (mul_le_mul_of_nonneg_right hsize G.gap_nonnegative) + +@[simp] theorem ofGraph_minimumRejections {V E : Type} [Fintype V] [Fintype E] + [DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) : + (ofGraph G).minimumRejections = G.minimumRejections := rfl + +@[simp] theorem ofGraph_gap {V E : Type} [Fintype V] [Fintype E] + [DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) : + (ofGraph G).gap = G.gap := rfl + +end Bundle + +end IndependentSetsGames.Foundations.PCP.FiniteGraph + +end +namespace IndependentSetsGames.Foundations.PCP.FinalConstants + +def alphabet : Nat := 64 +def compositionLoss : Nat := 12288 +def denominator : Nat := 16 * alphabet ^ 4 * 66 * compositionLoss +def windowHalf : Nat := denominator * Preprocessing.sizeFactor +def windowSize : Nat := 2 * windowHalf + 1 +def smoothingScale : Nat := 4 * alphabet * windowHalf +def endpointLength : Nat := smoothingScale ^ 2 +def walkLength : Nat := 2 * endpointLength + 1 + +noncomputable def gain : ℝ := (windowSize : ℝ) / denominator +noncomputable def cap : ℝ := 1 / (walkLength : ℝ) + +theorem denominator_positive : 0 < denominator := by + norm_num [denominator, alphabet, compositionLoss] + +theorem windowHalf_positive : 0 < windowHalf := + Nat.mul_pos denominator_positive Preprocessing.sizeFactor_positive + +theorem walkLength_positive : 0 < walkLength := by + simp [walkLength] + +theorem gain_large : 2 * (Preprocessing.sizeFactor : ℝ) ≤ gain := by + have hd : (0 : ℝ) < denominator := by exact_mod_cast denominator_positive + apply (le_div_iff₀ hd).2 + simp only [windowSize, windowHalf, Nat.cast_add, Nat.cast_mul, + Nat.cast_ofNat] + nlinarith + +theorem cap_positive : 0 < cap := by + exact one_div_pos.mpr (by exact_mod_cast walkLength_positive) + +theorem cap_le_one : cap ≤ 1 := by + apply (div_le_one (by exact_mod_cast walkLength_positive)).2 + exact_mod_cast walkLength_positive + +theorem composed_gap (epsilon : ℝ) (he : 0 ≤ epsilon) : + min (2 * epsilon) cap ≤ + gain * min (epsilon / (Preprocessing.sizeFactor : ℝ)) + (1 / (walkLength : ℝ)) := by + have hs : (0 : ℝ) < Preprocessing.sizeFactor := by + exact_mod_cast Preprocessing.sizeFactor_positive + have hs1 : (1 : ℝ) ≤ Preprocessing.sizeFactor := by + exact_mod_cast Preprocessing.sizeFactor_positive + have hg : 0 ≤ gain := le_trans (by positivity) gain_large + rw [mul_min_of_nonneg _ _ hg] + apply min_le_min + · calc + 2 * epsilon = (2 * (Preprocessing.sizeFactor : ℝ)) * + (epsilon / (Preprocessing.sizeFactor : ℝ)) := by field_simp + _ ≤ gain * (epsilon / (Preprocessing.sizeFactor : ℝ)) := + mul_le_mul_of_nonneg_right gain_large (div_nonneg he hs.le) + · change cap ≤ gain * cap + have hgain : 1 ≤ gain := by linarith [gain_large] + simpa only [one_mul] using mul_le_mul_of_nonneg_right hgain cap_positive.le + +end IndependentSetsGames.Foundations.PCP.FinalConstants +namespace IndependentSetsGames.Foundations.PCP.RoundTables + +abbrev BaseTable := PreprocessingTables.BaseTable + +opaque fixedWalkParameter : {n : Nat // n = 2 * FinalConstants.endpointLength} := + ⟨2 * FinalConstants.endpointLength, rfl⟩ + +def walkParameter : Nat := fixedWalkParameter.val + +theorem walkParameter_eq : walkParameter = 2 * FinalConstants.endpointLength := + fixedWalkParameter.property + +def alphabet : Nat := PoweringTables.labelCount PreprocessingTables.degree walkParameter + +theorem alphabet_positive : 0 < alphabet := by + unfold alphabet PoweringTables.labelCount + exact Nat.pow_pos (by decide) + +def powered (H : BaseTable) (table : GraphTables.Table) : GenericGraphTables.Table alphabet := + PoweringTables.table (PreprocessingTables.preprocess H table) walkParameter + +def build (H : BaseTable) (table : GraphTables.Table) : GraphTables.Table := + AlphabetTable.Table.build (powered H table) + +def sizeFactor : Nat := AlphabetGraphBounds.sizeFactor alphabet * + (ExpanderFamily.growth ^ 2 * (1 + 2 * PreprocessingTables.degree ^ (walkParameter + 1))) + +theorem degree_positive : 0 < PreprocessingTables.degree := by + unfold PreprocessingTables.degree + omega + +theorem dartFactor_positive (q : Nat) : 0 < AlphabetGraphBounds.dartFactor q := by + unfold AlphabetGraphBounds.dartFactor AlphabetGraphBounds.localEventFactor + positivity + +theorem sizeFactor_positive : 0 < sizeFactor := by + unfold sizeFactor + apply Nat.mul_pos (AlphabetGraphBounds.sizeFactor_positive alphabet) + apply Nat.mul_pos + · exact Nat.pow_pos (Nat.zero_lt_one.trans ExpanderFamily.growth_gt_one) + · omega + +theorem powered_vertices (H : BaseTable) (table : GraphTables.Table) : + (powered H table).vertices = PreprocessingTables.vertices table := rfl + +theorem powered_darts (H : BaseTable) (table : GraphTables.Table) : + (powered H table).darts = 2 * PreprocessingTables.vertices table * + PreprocessingTables.degree ^ (walkParameter + 1) := rfl + +theorem build_darts_positive (H : BaseTable) (table : GraphTables.Table) : + 0 < (build H table).darts := by + change 0 < (AlphabetTable.Table.build (powered H table)).darts + rw [AlphabetTableBounds.build_darts, powered_darts] + exact Nat.mul_pos (Nat.mul_pos + (Nat.mul_pos (by decide) (PreprocessingTables.vertices_positive table)) + (Nat.pow_pos degree_positive)) (dartFactor_positive alphabet) + +theorem build_size_le (H : BaseTable) (table : GraphTables.Table) + (ht : 0 < table.darts) : + (build H table).vertices + (build H table).darts ≤ + sizeFactor * (table.vertices + table.darts) := by + have hv := PreprocessingTables.vertices_le_of_positive table ht + have he : (powered H table).vertices + (powered H table).darts = + PreprocessingTables.vertices table * + (1 + 2 * PreprocessingTables.degree ^ (walkParameter + 1)) := by + rw [powered_vertices, powered_darts] + ring + have hp := Nat.mul_le_mul_right + (1 + 2 * PreprocessingTables.degree ^ (walkParameter + 1)) hv + calc + _ ≤ AlphabetGraphBounds.sizeFactor alphabet * + ((powered H table).vertices + (powered H table).darts) := + AlphabetTableBounds.build_total_le (powered H table) + _ = AlphabetGraphBounds.sizeFactor alphabet * + (PreprocessingTables.vertices table * + (1 + 2 * PreprocessingTables.degree ^ (walkParameter + 1))) := by rw [he] + _ ≤ AlphabetGraphBounds.sizeFactor alphabet * + ((ExpanderFamily.growth ^ 2 * table.darts) * + (1 + 2 * PreprocessingTables.degree ^ (walkParameter + 1))) := + Nat.mul_le_mul_left _ hp + _ = sizeFactor * table.darts := by unfold sizeFactor; ring + _ ≤ sizeFactor * (table.vertices + table.darts) := + Nat.mul_le_mul_left _ (Nat.le_add_left _ _) + +theorem build_completeness (H : BaseTable) (table : GraphTables.Table) + (sat : (GraphTables.semantics table).Satisfiable) : + (GraphTables.semantics (build H table)).Satisfiable := by + let : Nonempty (Fin alphabet) := ⟨⟨0, alphabet_positive⟩⟩ + exact AlphabetTable.Table.perfect_completeness (powered H table) + (PoweringTableSemantics.preserves_satisfiability + (PreprocessingTables.preprocess H table) walkParameter + (PreprocessingGuarantees.completeness H table sat)) + +abbrev Input := {table : GraphTables.Table // 0 < table.darts} + +instance (input : Input) : Nonempty (Fin input.val.darts) := ⟨⟨0, input.property⟩⟩ + +def step (H : BaseTable) (input : Input) : Input := + ⟨build H input.val, build_darts_positive H input.val⟩ + +def initial (F : Target.Formula) : Input := + ⟨RawInitialTables.table F, RawInitialTables.table_darts_positive F⟩ + +def size (input : Input) : Nat := input.val.vertices + input.val.darts + +def Satisfiable (input : Input) : Prop := (GraphTables.semantics input.val).Satisfiable + +noncomputable def gap (input : Input) : ℝ := (GraphTables.semantics input.val).gap + +theorem size_positive (input : Input) : 0 < size input := + input.property.trans_le (Nat.le_add_left _ _) + +theorem gap_nonnegative (input : Input) : 0 ≤ gap input := + (GraphTables.semantics input.val).gap_nonnegative + +theorem gap_eq_zero_iff (input : Input) : gap input = 0 ↔ Satisfiable input := + (GraphTables.semantics input.val).gap_eq_zero_iff + +theorem one_le_size_mul_gap (input : Input) (unsat : ¬ Satisfiable input) : + 1 ≤ (size input : ℝ) * gap input := by + have h := (GraphTables.semantics input.val).inverse_card_le_gap_of_unsatisfiable unsat + have hp : (0 : ℝ) < input.val.darts := Nat.cast_pos.mpr input.property + simp only [Fintype.card_fin] at h + have hd := (div_le_iff₀ hp).mp h + have hsize : (input.val.darts : ℝ) ≤ (size input : ℝ) := by + exact_mod_cast (Nat.le_add_left input.val.darts input.val.vertices) + exact (show 1 ≤ (input.val.darts : ℝ) * gap input by + simpa only [gap, mul_comm] using hd).trans + (mul_le_mul_of_nonneg_right hsize (gap_nonnegative input)) + +theorem initial_satisfiable_iff (F : Target.Formula) : Satisfiable (initial F) ↔ F.Satisfiable := + RawInitialTables.table_satisfiable_iff F + +theorem step_completeness (H : BaseTable) (input : Input) : + Satisfiable input → Satisfiable (step H input) := build_completeness H input.val + +theorem step_size (H : BaseTable) (input : Input) : + size (step H input) ≤ sizeFactor * size input := build_size_le H input.val input.property + +end IndependentSetsGames.Foundations.PCP.RoundTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/GenericGraphTables.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/GenericGraphTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3d724db7410a4852dd15ac81e2890a9b0551d98 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/GenericGraphTables.lean @@ -0,0 +1,375 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ConstraintGraph +import OAI.Combinatorics.IndependentSets.Encoding.GameEncoding +import OAI.Combinatorics.IndependentSets.Expansion.PoweringLabels + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.GenericGraphTables + +open IndependentSetsGames.Foundations.Complexity + +abbrev Label (q : Nat) := Fin q +abbrev RelationTable (q : Nat) := Vector Bool (q * q) + +variable {q : Nat} + +def relationIndex (q : Nat) : (Label q) × (Label q) ≃ Fin (q * q) := finProdFinEquiv + +theorem relationIndex_val (a b : (Label q)) : + ((relationIndex q) (a, b)).val = b.val + q * a.val := rfl + +def relationAt (table : (RelationTable q)) (a b : (Label q)) : Bool := + table[(relationIndex q) (a, b)] + +def relationOf (predicate : (Label q) → (Label q) → Bool) : (RelationTable q) := + Vector.ofFn (fun i => predicate ((relationIndex q).symm i).1 ((relationIndex q).symm i).2) + +@[simp] theorem relationAt_relationOf (predicate : (Label q) → (Label q) → Bool) (a b : (Label q)) : + relationAt (relationOf predicate) a b = predicate a b := by + simp [relationAt, relationOf] + +structure DartRow (q vertices darts : Nat) where + tail : Fin vertices + reverseIndex : Fin darts + relation : (RelationTable q) + +abbrev Rows (q vertices darts : Nat) := Vector (DartRow q vertices darts) darts + +def reverseAt {n m : Nat} (rows : Rows q n m) (e : Fin m) : Fin m := + rows[e].reverseIndex + +def acceptsAt {n m : Nat} (rows : Rows q n m) (e : Fin m) (a b : (Label q)) : Bool := + relationAt rows[e].relation a b + +def Valid {n m : Nat} (rows : Rows q n m) : Prop := + (∀ e, reverseAt rows (reverseAt rows e) = e) ∧ + (∀ e a b, acceptsAt rows (reverseAt rows e) b a = acceptsAt rows e a b) + +instance {n m : Nat} (rows : Rows q n m) : Decidable (Valid rows) := by + unfold Valid + infer_instance + +structure Table (q : Nat) where + vertices : Nat + darts : Nat + rows : Rows q vertices darts + valid : Valid rows + +def rowList (table : (Table q)) : List (DartRow q table.vertices table.darts) := table.rows.toList + +@[simp] theorem rowList_length (table : (Table q)) : (rowList table).length = table.darts := by + simp [rowList] + +def semantics (table : (Table q)) : ConstraintGraph (Fin table.vertices) (Fin table.darts) (Label q) where + reverse := + { toFun := reverseAt table.rows + invFun := reverseAt table.rows + left_inv := table.valid.1 + right_inv := table.valid.1 } + reverse_involutive := table.valid.1 + tail e := table.rows[e].tail + accepts := acceptsAt table.rows + reverse_accepts := table.valid.2 + +@[simp] theorem semantics_reverse (table : (Table q)) (e : Fin table.darts) : + (semantics table).reverse e = table.rows[e].reverseIndex := rfl + +@[simp] theorem semantics_tail (table : (Table q)) (e : Fin table.darts) : + (semantics table).tail e = table.rows[e].tail := rfl + +@[simp] theorem semantics_accepts (table : (Table q)) (e : Fin table.darts) (a b : (Label q)) : + (semantics table).accepts e a b = relationAt table.rows[e].relation a b := rfl + +def graphRows {n m : Nat} (G : ConstraintGraph (Fin n) (Fin m) (Label q)) : Rows q n m := + Vector.ofFn (fun e => ⟨G.tail e, G.reverse e, relationOf (G.accepts e)⟩) + +@[simp] theorem reverseAt_graphRows {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) (e : Fin m) : + reverseAt (graphRows G) e = G.reverse e := by + simp [reverseAt, graphRows] + +@[simp] theorem acceptsAt_graphRows {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) (e : Fin m) (a b : (Label q)) : + acceptsAt (graphRows G) e a b = G.accepts e a b := by + simp [acceptsAt, graphRows] + +theorem graphRows_valid {n m : Nat} (G : ConstraintGraph (Fin n) (Fin m) (Label q)) : + Valid (graphRows G) := by + constructor + · intro e + simpa using G.reverse_involutive e + · intro e a b + simpa using G.reverse_accepts e a b + +def ofGraph {n m : Nat} (G : ConstraintGraph (Fin n) (Fin m) (Label q)) : (Table q) := + ⟨n, m, graphRows G, graphRows_valid G⟩ + +@[simp] theorem semantics_ofGraph_reverse {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) (e : Fin m) : + (semantics (ofGraph G)).reverse e = G.reverse e := by + exact reverseAt_graphRows G e + +@[simp] theorem semantics_ofGraph_tail {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) (e : Fin m) : + (semantics (ofGraph G)).tail e = G.tail e := by + change (graphRows G)[e.val].tail = G.tail e + simp only [graphRows, Vector.getElem_ofFn] + +@[simp] theorem semantics_ofGraph_accepts {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) (e : Fin m) (a b : (Label q)) : + (semantics (ofGraph G)).accepts e a b = G.accepts e a b := by + exact acceptsAt_graphRows G e a b + +@[simp] theorem semantics_ofGraph_edgeSatisfied {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) (labeling : Fin n → (Label q)) (e : Fin m) : + (semantics (ofGraph G)).edgeSatisfied labeling e = G.edgeSatisfied labeling e := by + simp [ConstraintGraph.edgeSatisfied, ConstraintGraph.head] + +private theorem constraintGraph_ext {V E A : Type*} {G H : ConstraintGraph V E A} + (hr : ∀ e, G.reverse e = H.reverse e) (ht : G.tail = H.tail) + (hp : G.accepts = H.accepts) : G = H := by + cases G with + | mk reverse hinv tail accepts htranspose => + cases H with + | mk reverse' hinv' tail' accepts' htranspose' => + dsimp only at hr ht hp + have he : reverse = reverse' := Equiv.ext hr + cases he + cases ht + cases hp + rfl + +@[simp] theorem semantics_ofGraph {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) : semantics (ofGraph G) = G := by + apply constraintGraph_ext + · exact semantics_ofGraph_reverse G + · funext e + exact semantics_ofGraph_tail G e + · funext e a b + exact semantics_ofGraph_accepts G e a b + +@[simp] theorem semantics_ofGraph_rejectionCount {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) (Label q)) (labeling : Fin n → (Label q)) : + (semantics (ofGraph G)).rejectionCount labeling = G.rejectionCount labeling := by + rw [semantics_ofGraph] + rfl + +def enumeratedGraph {V E A : Type*} {n m : Nat} (G : ConstraintGraph V E A) + (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) (labelOrder : A ≃ (Label q)) : + ConstraintGraph (Fin n) (Fin m) (Label q) where + reverse := (dartOrder.symm.trans G.reverse).trans dartOrder + reverse_involutive e := by + change dartOrder (G.reverse (dartOrder.symm + (dartOrder (G.reverse (dartOrder.symm e))))) = e + rw [dartOrder.symm_apply_apply, G.reverse_involutive, dartOrder.apply_symm_apply] + tail e := vertexOrder (G.tail (dartOrder.symm e)) + accepts e a b := G.accepts (dartOrder.symm e) (labelOrder.symm a) (labelOrder.symm b) + reverse_accepts e a b := by + change G.accepts (dartOrder.symm (dartOrder (G.reverse (dartOrder.symm e)))) + (labelOrder.symm b) (labelOrder.symm a) = _ + rw [dartOrder.symm_apply_apply] + exact G.reverse_accepts _ _ _ + +theorem enumeratedGraph_edgeSatisfied {V E A : Type*} {n m : Nat} + (G : ConstraintGraph V E A) (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) + (labelOrder : A ≃ (Label q)) (labeling : V → A) (e : E) : + (enumeratedGraph G vertexOrder dartOrder labelOrder).edgeSatisfied + (fun v => labelOrder (labeling (vertexOrder.symm v))) (dartOrder e) = + G.edgeSatisfied labeling e := by + simp [ConstraintGraph.edgeSatisfied, ConstraintGraph.head, enumeratedGraph] + +theorem enumeratedGraph_rejectionCount {V E A : Type*} [Fintype E] {n m : Nat} + (G : ConstraintGraph V E A) (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) + (labelOrder : A ≃ (Label q)) (labeling : V → A) : + (enumeratedGraph G vertexOrder dartOrder labelOrder).rejectionCount + (fun v => labelOrder (labeling (vertexOrder.symm v))) = G.rejectionCount labeling := by + classical + unfold ConstraintGraph.rejectionCount + symm + apply Finset.card_equiv dartOrder + intro e + simp only [ConstraintGraph.mem_rejectedDarts, enumeratedGraph_edgeSatisfied] + +def ofEnumeratedGraph {V E A : Type*} {n m : Nat} (G : ConstraintGraph V E A) + (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) (labelOrder : A ≃ (Label q)) : (Table q) := + ofGraph (enumeratedGraph G vertexOrder dartOrder labelOrder) + +def bitWord (b : Bool) : Nat := if b then 1 else 0 + +def parseBit : Nat → Option Bool + | 0 => some false + | 1 => some true + | _ => none + +@[simp] theorem parseBit_bitWord (b : Bool) : parseBit (bitWord b) = some b := by + cases b <;> rfl + +@[simp] theorem parseBits_bitWords (bits : List Bool) : + (bits.map bitWord).mapM parseBit = some bits := by + induction bits with + | nil => rfl + | cons bit bits ih => simp [ih] + +def relationWords (relation : (RelationTable q)) : List Nat := relation.toList.map bitWord + +@[simp] theorem relationWords_length (relation : (RelationTable q)) : + (relationWords relation).length = (q * q) := by simp [relationWords] + +def parseRelation (q : Nat) (words : List Nat) : Option (RelationTable q) := do + let bits ← words.mapM parseBit + if length_ok : bits.length = (q * q) then + some ⟨bits.toArray, by simpa using length_ok⟩ + else none + +@[simp] theorem parseRelation_encoded (relation : (RelationTable q)) : + (parseRelation q) (relationWords relation) = some relation := by + unfold parseRelation relationWords + rw [parseBits_bitWords] + simp + exact Vector.toArray_toList + +def rowWords {n m : Nat} (row : DartRow q n m) : List Nat := + [row.tail.val, row.reverseIndex.val] ++ relationWords row.relation + +def parseRow (q : Nat) (vertices darts : Nat) : List Nat → Option (DartRow q vertices darts × List Nat) + | tail :: reverseIndex :: words => do + let tail ← parseLabel vertices tail + let reverseIndex ← parseLabel darts reverseIndex + let relation ← (parseRelation q) (words.take (q * q)) + return (⟨tail, reverseIndex, relation⟩, words.drop (q * q)) + | _ => none + +@[simp] theorem parseRow_encoded {n m : Nat} (row : DartRow q n m) (rest : List Nat) : + (parseRow q) n m (rowWords row ++ rest) = some (row, rest) := by + cases row with + | mk tail reverseIndex relation => + have taken := List.take_left' (l₂ := rest) (relationWords_length relation) + have dropped := List.drop_left' (l₂ := rest) (relationWords_length relation) + simp [rowWords, parseRow, taken, dropped] + +def parseRows (q : Nat) (vertices darts : Nat) : + Nat → List Nat → Option (List (DartRow q vertices darts) × List Nat) + | 0, words => some ([], words) + | count + 1, words => do + let (row, words) ← (parseRow q) vertices darts words + let (rows, words) ← (parseRows q) vertices darts count words + return (row :: rows, words) + +@[simp] theorem parseRows_encoded {n m : Nat} (rows : List (DartRow q n m)) (rest : List Nat) : + (parseRows q) n m rows.length (rows.flatMap rowWords ++ rest) = some (rows, rest) := by + induction rows with + | nil => rfl + | cons row rows ih => simp [parseRows, List.append_assoc, ih] + +def tableWords (table : (Table q)) : List Nat := + [table.vertices, table.darts] ++ (rowList table).flatMap rowWords + +def tableBits (table : (Table q)) : List Bool := encodeWords (tableWords table) + +def decodeTableWords (q : Nat) : List Nat → Option (Table q) + | vertices :: darts :: words => do + let (parsed, trailing) ← (parseRows q) vertices darts darts words + if trailing = [] then + if length_ok : parsed.length = darts then + let rows : Rows q vertices darts := ⟨parsed.toArray, by simpa using length_ok⟩ + if valid : Valid rows then some ⟨vertices, darts, rows, valid⟩ else none + else none + else none + | _ => none + +@[simp] theorem decodeTableWords_encoded (table : (Table q)) : + (decodeTableWords q) (tableWords table) = some table := by + cases table with + | mk vertices darts rows valid => + have parsed := parseRows_encoded rows.toList [] + simp only [Vector.length_toList, List.append_nil] at parsed + simp [tableWords, rowList, decodeTableWords, parsed, valid, Vector.toArray_toList] + +def decodeTableBits (q : Nat) (bits : List Bool) : Option (Table q) := + decodeWords bits >>= (decodeTableWords q) + +@[simp] theorem decodeTableBits_encoded (table : (Table q)) : + (decodeTableBits q) (tableBits table) = some table := by + simp [decodeTableBits, tableBits] + +def encoding (q : Nat) : Computability.Encoding (Table q) Bool where + encode := tableBits + decode := (decodeTableBits q) + decode_encode := decodeTableBits_encoded + +theorem tableBits_injective : Function.Injective (tableBits (q := q)) := (encoding q).encode_injective + +@[simp] theorem rowWords_length {n m : Nat} (row : DartRow q n m) : + (rowWords row).length = (q * q + 2) := by + simp only [rowWords, List.length_append, List.length_cons, List.length_nil, + relationWords_length] + omega + +theorem rowsWords_length {n m : Nat} (rows : List (DartRow q n m)) : + (rows.flatMap rowWords).length = (q * q + 2) * rows.length := by + induction rows with + | nil => rfl + | cons row rows ih => simp [ih, Nat.mul_add, Nat.add_comm] + +@[simp] theorem tableWords_length (table : (Table q)) : + (tableWords table).length = 2 + (q * q + 2) * table.darts := by + simp only [tableWords, List.length_append, List.length_cons, List.length_nil, + rowsWords_length, rowList_length] + +theorem tableWords_length_le_bits (table : (Table q)) : + 2 + (q * q + 2) * table.darts ≤ (tableBits table).length := by + rw [tableBits, encodeWords_length, ← tableWords_length] + omega + +theorem relationBits_length_le (relation : (RelationTable q)) : + (encodeWords (relationWords relation)).length ≤ (2 * (q * q)) := by + have h := encodeWords_length_le (relationWords relation) 1 (by + intro word hword + obtain ⟨bit, _, rfl⟩ := List.mem_map.mp hword + cases bit <;> decide) + simpa only [relationWords_length, Nat.mul_comm] using h + +theorem rowBits_length_le {n m : Nat} (row : DartRow q n m) : + (encodeWords (rowWords row)).length ≤ n + m + (2 * (q * q)) := by + have ht := row.tail.isLt + have hr := row.reverseIndex.isLt + have hp := relationBits_length_le row.relation + simp only [rowWords, encodeWords_append, List.length_append, encodeWords, + encodeWord_length, List.length_nil] at ⊢ + omega + +theorem rowsBits_length_le {n m : Nat} (rows : List (DartRow q n m)) : + (encodeWords (rows.flatMap rowWords)).length ≤ rows.length * (n + m + (2 * (q * q))) := by + induction rows with + | nil => simp [encodeWords] + | cons row rows ih => + have hrow := rowBits_length_le row + simp only [List.flatMap_cons, encodeWords_append, List.length_append, + List.length_cons, Nat.add_mul, Nat.one_mul] + omega + +theorem tableBits_length_le (table : (Table q)) : + (tableBits table).length ≤ table.vertices + table.darts + 2 + + table.darts * (table.vertices + table.darts + (2 * (q * q))) := by + have hrows := rowsBits_length_le (rowList table) + rw [rowList_length] at hrows + simp only [tableBits, tableWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +theorem vertices_le_tableBits_length (table : (Table q)) : + table.vertices ≤ (tableBits table).length := by + simp only [tableBits, tableWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +theorem darts_le_tableBits_length (table : (Table q)) : + table.darts ≤ (tableBits table).length := by + simp only [tableBits, tableWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +end IndependentSetsGames.Foundations.PCP.GenericGraphTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/GeometryPointTable.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/GeometryPointTable.lean new file mode 100644 index 0000000000000000000000000000000000000000..b522e6fe4a2efed6b0c767fc4a93411df25aa915 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/GeometryPointTable.lean @@ -0,0 +1,37 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.GeometryExpr + +namespace OAI + +namespace LargeIndependentSets.GeometryNames +open IndependentSetsCut.CounterMachine UniformLC +open scoped Classical +noncomputable section +variable (L R : Type) [Fintype L] [Fintype R] (n D : ℕ) [NeZero D] + +def pointEquiv : StaticPoint L R n D ≃ Fin (staticCount L R n D) := + Fintype.equivFin (StaticPoint L R n D) + +lemma nodeEquiv_val {nu nv : ℕ} (x : Node L R n D nu nv) : + (nodeEquiv L R n D nu nv x).val= + (pointEquiv L R n D x.2).val+staticCount L R n D* + ((finFunctionFinEquiv x.1.2).val+nv^n*(finFunctionFinEquiv x.1.1).val) := rfl + +def pointLookup (f : StaticPoint L R n D → ℕ) (x : Expr) : Expr := + Expr.finLookup (fun i => f ((pointEquiv L R n D).symm i)) x + +lemma pointLookup_eval (f : StaticPoint L R n D → ℕ) (x : Expr) (s : List Bool) (a : ℕ → ℕ) + (v : StaticPoint L R n D) (hv : x.eval s a=(pointEquiv L R n D v).val) : + (pointLookup L R n D f x).eval s a=f v := by + rw [pointLookup,Expr.finLookup_eval _ _ _ _ (pointEquiv L R n D v) hv,Equiv.symm_apply_apply] + +lemma pointExpr_code (t : Table L R) (x : Expr) (a : ℕ → ℕ) (i : Fin (size L R n D t)) + (hi : x.eval t.bits a=i.val) : + (pointExpr L R n D x).eval t.bits a= + (pointEquiv L R n D ((nodeEquiv L R n D t.nu t.nv).symm i).2).val := + pointExpr_eval L R n D t x a i hi + +end +end LargeIndependentSets.GeometryNames + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/GraphIterationBounds.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/GraphIterationBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c32256aa6effb45fa4a58ba223cd762c45f79741 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/GraphIterationBounds.lean @@ -0,0 +1,258 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.TableIteration +import OAI.Combinatorics.IndependentSets.Machines.GraphCounterPrefix + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.GraphIterationBounds + +open PCP RoundTables + +def inputBits (input : Input) : List Bool := GraphTables.tableBits input.val + +def countedBits (input : Input) : List Bool := GraphCounterPrefix.output input.val + +def words (H : BaseTable) (input : Input) (i : Nat) : List Bool := + GraphTables.tableBits (TableIteration.runTables H i input.val) + +def count (input : Input) : Nat := GraphCounterPrefix.count input.val + +noncomputable def lengthPolynomial : Polynomial Nat := + (GraphTableComplexity.encodingPolynomial 64).comp (PCPIterationMachine.sizePolynomial sizeFactor) + +theorem inputBits_le_countedBits (input : Input) : (inputBits input).length ≤ (countedBits input).length := by + simp only [inputBits, countedBits, GraphCounterPrefix.output, List.length_append] + omega + +theorem size_le_inputBits (input : Input) : size input ≤ (inputBits input).length := by + have h := GraphTableComplexity.size_add_two_le_bits input.val + unfold size inputBits + omega + +theorem count_le (input : Input) : count input ≤ (countedBits input).length + 1 := + (PCPIterationMachine.rounds_le (size input)).trans + (Nat.add_le_add_right ((size_le_inputBits input).trans (inputBits_le_countedBits input)) 1) + +theorem intermediate_size (H : BaseTable) (input : Input) (i : Nat) (hi : i ≤ count input) : + size (TableIteration.run H i input) ≤ PCPIterationMachine.sizeEnvelope sizeFactor (size input) := by + apply PCPIterationMachine.semanticSize_bound + (fun j => size (TableIteration.run H j input)) sizeFactor (size input) + sizeFactor_positive (Nat.le_succ _) _ i hi + intro j _ + exact step_size H (TableIteration.run H j input) + +theorem intermediate_bits (H : BaseTable) (input : Input) (i : Nat) (hi : i ≤ count input) : + (words H input i).length ≤ lengthPolynomial.eval (countedBits input).length := by + have hsize := intermediate_size H input i hi + have hinput := (size_le_inputBits input).trans (inputBits_le_countedBits input) + have heval := MachineComposition.natPolynomial_eval_mono + (PCPIterationMachine.sizePolynomial sizeFactor) hinput + rw [PCPIterationMachine.sizePolynomial_eval, PCPIterationMachine.sizePolynomial_eval] at heval + have hs := hsize.trans heval + have htable : (TableIteration.runTables H i input.val).vertices + + (TableIteration.runTables H i input.val).darts ≤ + PCPIterationMachine.sizeEnvelope sizeFactor (countedBits input).length := by + rw [← TableIteration.run_val] + exact hs + rw [lengthPolynomial, Polynomial.eval_comp, PCPIterationMachine.sizePolynomial_eval] + exact GraphTableComplexity.bits_le_of_size_le _ htable + +noncomputable def runtimePolynomial (bodyTime : Polynomial Nat) : Polynomial Nat := + (Polynomial.X + 1) * (bodyTime.comp lengthPolynomial + 2 * lengthPolynomial + 4) + + 2 * lengthPolynomial + 4 + +theorem runtimePolynomial_eval (bodyTime : Polynomial Nat) (N : Nat) : + (runtimePolynomial bodyTime).eval N = + (N + 1) * (bodyTime.eval (lengthPolynomial.eval N) + 2 * lengthPolynomial.eval N + 4) + + 2 * lengthPolynomial.eval N + 4 := by + simp only [runtimePolynomial, Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_X, + Polynomial.eval_one, Polynomial.eval_ofNat, Polynomial.eval_comp] + +end IndependentSetsGames.Foundations.Complexity.GraphIterationBounds + +namespace IndependentSetsGames.Foundations.PCP.RawInitialRows + +open Target GraphTables RawInitialTables + +abbrev Signs := Bool × Bool × Bool +abbrev Names := Nat × Nat × Nat + +def clauseSigns {n : Nat} (c : Clause n) : Signs := + ((c)[0].positive, (c)[1].positive, (c)[2].positive) + +def clauseNames {n : Nat} (c : Clause n) : Names := + ((c)[0].variableIndex.val, (c)[1].variableIndex.val, (c)[2].variableIndex.val) + +def nameWord (names : Names) : Slot → Nat + | .first => names.1 + | .second => names.2.1 + | .third => names.2.2 + +def decodedLabel (a : GraphTables.Label) : InitialGraph.Label := + AlphabetRetraction.decode64 (labelOrder.symm a) + +def incidencePredicate (signs : Signs) (slot : Slot) + (clauseLabel variableLabel : InitialGraph.Label) : Bool := + InitialGraph.variableValid variableLabel && + (((literalValue signs.1 clauseLabel.1 || + literalValue signs.2.1 clauseLabel.2.1) || + literalValue signs.2.2 clauseLabel.2.2) && + decide (answerAt (InitialGraph.toClauseAnswer clauseLabel) slot = variableLabel.1)) + +def relationPredicate (signs : Signs) (slot : Slot) : + Bool → GraphTables.Label → GraphTables.Label → Bool + | false, a, b => incidencePredicate signs slot (decodedLabel a) (decodedLabel b) + | true, a, b => incidencePredicate signs slot (decodedLabel b) (decodedLabel a) + +def relationWordsFor (signs : Signs) (slot : Slot) (orientation : Bool) : List Nat := + relationWords (relationOf (relationPredicate signs slot orientation)) + +@[simp] theorem relationWordsFor_length (signs : Signs) (slot : Slot) (orientation : Bool) : + (relationWordsFor signs slot orientation).length = 4096 := by + exact relationWords_length _ + +def incidenceWords (n i : Nat) (names : Names) (signs : Signs) + (slot : Slot) (orientation : Bool) : List Nat := + [if orientation then nameWord names slot else n + i, + 6 * i + 2 * (slotOrder slot).val + (if orientation then 0 else 1)] ++ + relationWordsFor signs slot orientation + +def clauseWords (n i : Nat) (names : Names) (signs : Signs) : List Nat := + incidenceWords n i names signs .first false ++ + incidenceWords n i names signs .first true ++ + incidenceWords n i names signs .second false ++ + incidenceWords n i names signs .second true ++ + incidenceWords n i names signs .third false ++ + incidenceWords n i names signs .third true + +def dummyWords (n m : Nat) : List Nat := + [n + m, 6 * m] ++ List.replicate 4096 1 + +def orderedList {α : Type*} {n : Nat} (e : α ≃ Fin n) : List α := + List.ofFn e.symm + +theorem orderedList_cast {α : Type*} {m n : Nat} (e : α ≃ Fin m) (h : m = n) : + orderedList (e.trans (finCongr h)) = orderedList e := by + subst n + rfl + +theorem orderedList_prod {α β : Type*} {m n : Nat} + (e : α ≃ Fin m) (f : β ≃ Fin n) : + orderedList ((e.prodCongr f).trans finProdFinEquiv) = + (orderedList e).flatMap (fun a => (orderedList f).map (fun b => (a, b))) := by + change List.ofFn (fun q : Fin (m * n) => + (e.symm (finProdFinEquiv.symm q).1, f.symm (finProdFinEquiv.symm q).2)) = _ + rw [List.ofFn_mul] + simp only [orderedList, List.flatMap_def, List.map_ofFn] + apply congrArg List.flatten + apply congrArg List.ofFn + funext i + apply congrArg List.ofFn + funext j + have h : (⟨i.val * n + j.val, by + calc + i.val * n + j.val < (i.val + 1) * n := + (Nat.add_lt_add_left j.isLt _).trans_eq (by rw [Nat.add_mul, Nat.one_mul]) + _ ≤ m * n := Nat.mul_le_mul_right _ i.isLt⟩ : Fin (m * n)) = + finProdFinEquiv (i, j) := by + apply Fin.ext + simp [finProdFinEquiv, Nat.add_comm, Nat.mul_comm] + rw [h, Equiv.symm_apply_apply] + rfl + +theorem orderedList_sum {α β : Type*} {m n : Nat} + (e : α ≃ Fin m) (f : β ≃ Fin n) : + orderedList ((e.sumCongr f).trans finSumFinEquiv) = + (orderedList e).map Sum.inl ++ (orderedList f).map Sum.inr := by + change List.ofFn (fun q : Fin (m + n) => + (e.sumCongr f).symm (finSumFinEquiv.symm q)) = _ + rw [List.ofFn_add] + change (List.ofFn (fun i : Fin m => + (e.sumCongr f).symm (finSumFinEquiv.symm (i.castAdd n)))) ++ + (List.ofFn (fun i : Fin n => + (e.sumCongr f).symm (finSumFinEquiv.symm (i.natAdd m)))) = _ + simp [orderedList, List.map_ofFn] + rfl + +def clauseDarts (F : Formula) (i : Fin F.clauses.length) : List (InitialGraph.Dart F) := + [.inl ((i, .first), false), .inl ((i, .first), true), + .inl ((i, .second), false), .inl ((i, .second), true), + .inl ((i, .third), false), .inl ((i, .third), true)] + +theorem orderedList_dartOrder (F : Formula) : + orderedList (dartOrder F) = + (List.finRange F.clauses.length).flatMap (clauseDarts F) ++ [.inr ()] := by + rw [dartOrder, orderedList_cast, orderedList_sum, orderedList_prod] + rw [eventOrder, orderedList_prod] + have hs : orderedList slotOrder = [.first, .second, .third] := rfl + have hb : orderedList finTwoEquiv.symm = [false, true] := rfl + have hu : orderedList unitOrder = [()] := rfl + rw [hs, hb, hu] + simp [orderedList, List.finRange, List.flatMap_assoc, List.map_flatMap, + ] + rfl + +def rowFor (F : Formula) (d : InitialGraph.Dart F) : + DartRow (F.«variables» + F.clauses.length + 1) (6 * F.clauses.length + 1) where + tail := vertexOrder F (InitialGraph.tail F d) + reverseIndex := dartOrder F (InitialGraph.reverse F d) + relation := relationOf (fun a b => InitialGraph.predicate F d (decodedLabel a) (decodedLabel b)) + +theorem rowList_table (F : Formula) : + rowList (table F) = (orderedList (dartOrder F)).map (rowFor F) := by + simp only [rowList, table, ofEnumeratedGraph, ofGraph, graphRows, Vector.toList_ofFn, + orderedList, List.map_ofFn] + rfl + +theorem rowWords_incidence (F : Formula) (i : Fin F.clauses.length) + (slot : Slot) (orientation : Bool) : + rowWords (rowFor F (.inl ((i, slot), orientation))) = + incidenceWords F.«variables» i.val (clauseNames (clauseAt F i)) + (clauseSigns (clauseAt F i)) slot orientation := by + have ht : (rowFor F (.inl ((i, slot), orientation))).tail.val = + if orientation then nameWord (clauseNames (clauseAt F i)) slot else F.«variables» + i.val := by + cases orientation <;> cases slot <;> rfl + have hr : (rowFor F (.inl ((i, slot), orientation))).reverseIndex.val = + 6 * i.val + 2 * (slotOrder slot).val + (if orientation then 0 else 1) := by + cases orientation <;> cases slot <;> + simp [rowFor, InitialGraph.reverse, dartOrder, eventOrder, slotOrder, unitOrder, + finProdFinEquiv, finSumFinEquiv, finTwoEquiv, Nat.mul_add, + Nat.mul_comm, Nat.mul_left_comm, Nat.add_comm] + have hp : (rowFor F (.inl ((i, slot), orientation))).relation = + relationOf (relationPredicate (clauseSigns (clauseAt F i)) slot orientation) := by + cases orientation <;> rfl + unfold rowWords incidenceWords relationWordsFor + rw [ht, hr, hp] + +theorem rowWords_dummy (F : Formula) : + rowWords (rowFor F (.inr ())) = dummyWords F.«variables» F.clauses.length := by + have ht : (rowFor F (.inr ())).tail.val = F.«variables» + F.clauses.length := rfl + have hr : (rowFor F (.inr ())).reverseIndex.val = 6 * F.clauses.length := by + simp [rowFor, InitialGraph.reverse, dartOrder, unitOrder, finSumFinEquiv] + have hp : (rowFor F (.inr ())).relation = relationOf (fun _ _ => true) := rfl + have hw : relationWords (relationOf (fun _ _ => true)) = List.replicate 4096 1 := by + unfold relationWords + rw [relationOf, Vector.toList_ofFn, List.map_ofFn] + exact List.ofFn_const 4096 1 + unfold rowWords dummyWords + rw [ht, hr, hp, hw] + +theorem clauseDarts_rowWords (F : Formula) (i : Fin F.clauses.length) : + (clauseDarts F i).flatMap (fun d => rowWords (rowFor F d)) = + clauseWords F.«variables» i.val (clauseNames (clauseAt F i)) + (clauseSigns (clauseAt F i)) := by + simp [clauseDarts, rowWords_incidence, clauseWords, List.append_assoc] + +theorem tableWords_eq (F : Formula) : + tableWords (table F) = + [F.«variables» + F.clauses.length + 1, 6 * F.clauses.length + 1] ++ + (List.finRange F.clauses.length).flatMap (fun i => + clauseWords F.«variables» i.val (clauseNames (clauseAt F i)) + (clauseSigns (clauseAt F i))) ++ dummyWords F.«variables» F.clauses.length := by + rw [tableWords, rowList_table, orderedList_dartOrder] + simp [List.flatMap_map, List.flatMap_append, List.flatMap_assoc, clauseDarts_rowWords, + rowWords_dummy] + +end IndependentSetsGames.Foundations.PCP.RawInitialRows + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/GraphTables.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/GraphTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d53ef3caefc32ae837e8b4aaea7e275048d398c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/GraphTables.lean @@ -0,0 +1,369 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ConstraintGraph +import OAI.Combinatorics.IndependentSets.Encoding.GameEncoding + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.GraphTables + +open IndependentSetsGames.Foundations.Complexity + +abbrev Label := Fin 64 +abbrev RelationTable := Vector Bool 4096 + +def relationIndex : Label × Label ≃ Fin 4096 := finProdFinEquiv + +theorem relationIndex_val (a b : Label) : + (relationIndex (a, b)).val = b.val + 64 * a.val := rfl + +def relationAt (table : RelationTable) (a b : Label) : Bool := + table[relationIndex (a, b)] + +def relationOf (predicate : Label → Label → Bool) : RelationTable := + Vector.ofFn (fun i => predicate (relationIndex.symm i).1 (relationIndex.symm i).2) + +@[simp] theorem relationAt_relationOf (predicate : Label → Label → Bool) (a b : Label) : + relationAt (relationOf predicate) a b = predicate a b := by + simp [relationAt, relationOf] + +structure DartRow (vertices darts : Nat) where + tail : Fin vertices + reverseIndex : Fin darts + relation : RelationTable + +abbrev Rows (vertices darts : Nat) := Vector (DartRow vertices darts) darts + +def reverseAt {n m : Nat} (rows : Rows n m) (e : Fin m) : Fin m := + rows[e].reverseIndex + +def acceptsAt {n m : Nat} (rows : Rows n m) (e : Fin m) (a b : Label) : Bool := + relationAt rows[e].relation a b + +def Valid {n m : Nat} (rows : Rows n m) : Prop := + (∀ e, reverseAt rows (reverseAt rows e) = e) ∧ + (∀ e a b, acceptsAt rows (reverseAt rows e) b a = acceptsAt rows e a b) + +instance {n m : Nat} (rows : Rows n m) : Decidable (Valid rows) := by + unfold Valid + infer_instance + +structure Table where + vertices : Nat + darts : Nat + rows : Rows vertices darts + valid : Valid rows + +def rowList (table : Table) : List (DartRow table.vertices table.darts) := table.rows.toList + +@[simp] theorem rowList_length (table : Table) : (rowList table).length = table.darts := by + simp [rowList] + +def semantics (table : Table) : ConstraintGraph (Fin table.vertices) (Fin table.darts) Label where + reverse := + { toFun := reverseAt table.rows + invFun := reverseAt table.rows + left_inv := table.valid.1 + right_inv := table.valid.1 } + reverse_involutive := table.valid.1 + tail e := table.rows[e].tail + accepts := acceptsAt table.rows + reverse_accepts := table.valid.2 + +@[simp] theorem semantics_reverse (table : Table) (e : Fin table.darts) : + (semantics table).reverse e = table.rows[e].reverseIndex := rfl + +@[simp] theorem semantics_tail (table : Table) (e : Fin table.darts) : + (semantics table).tail e = table.rows[e].tail := rfl + +@[simp] theorem semantics_accepts (table : Table) (e : Fin table.darts) (a b : Label) : + (semantics table).accepts e a b = relationAt table.rows[e].relation a b := rfl + +def graphRows {n m : Nat} (G : ConstraintGraph (Fin n) (Fin m) Label) : Rows n m := + Vector.ofFn (fun e => ⟨G.tail e, G.reverse e, relationOf (G.accepts e)⟩) + +@[simp] theorem reverseAt_graphRows {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) (e : Fin m) : + reverseAt (graphRows G) e = G.reverse e := by + simp [reverseAt, graphRows] + +@[simp] theorem acceptsAt_graphRows {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) (e : Fin m) (a b : Label) : + acceptsAt (graphRows G) e a b = G.accepts e a b := by + simp [acceptsAt, graphRows] + +theorem graphRows_valid {n m : Nat} (G : ConstraintGraph (Fin n) (Fin m) Label) : + Valid (graphRows G) := by + constructor + · intro e + simpa using G.reverse_involutive e + · intro e a b + simpa using G.reverse_accepts e a b + +def ofGraph {n m : Nat} (G : ConstraintGraph (Fin n) (Fin m) Label) : Table := + ⟨n, m, graphRows G, graphRows_valid G⟩ + +@[simp] theorem semantics_ofGraph_reverse {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) (e : Fin m) : + (semantics (ofGraph G)).reverse e = G.reverse e := by + exact reverseAt_graphRows G e + +@[simp] theorem semantics_ofGraph_tail {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) (e : Fin m) : + (semantics (ofGraph G)).tail e = G.tail e := by + change (graphRows G)[e.val].tail = G.tail e + simp only [graphRows, Vector.getElem_ofFn] + +@[simp] theorem semantics_ofGraph_accepts {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) (e : Fin m) (a b : Label) : + (semantics (ofGraph G)).accepts e a b = G.accepts e a b := by + exact acceptsAt_graphRows G e a b + +@[simp] theorem semantics_ofGraph_edgeSatisfied {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) (labeling : Fin n → Label) (e : Fin m) : + (semantics (ofGraph G)).edgeSatisfied labeling e = G.edgeSatisfied labeling e := by + simp [ConstraintGraph.edgeSatisfied, ConstraintGraph.head] + +theorem constraintGraph_ext {V E A : Type*} {G H : ConstraintGraph V E A} + (hr : ∀ e, G.reverse e = H.reverse e) (ht : G.tail = H.tail) + (hp : G.accepts = H.accepts) : G = H := by + cases G with + | mk reverse hinv tail accepts htranspose => + cases H with + | mk reverse' hinv' tail' accepts' htranspose' => + dsimp only at hr ht hp + have he : reverse = reverse' := Equiv.ext hr + cases he + cases ht + cases hp + rfl + +@[simp] theorem semantics_ofGraph {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) : semantics (ofGraph G) = G := by + apply constraintGraph_ext + · exact semantics_ofGraph_reverse G + · funext e + exact semantics_ofGraph_tail G e + · funext e a b + exact semantics_ofGraph_accepts G e a b + +@[simp] theorem semantics_ofGraph_rejectionCount {n m : Nat} + (G : ConstraintGraph (Fin n) (Fin m) Label) (labeling : Fin n → Label) : + (semantics (ofGraph G)).rejectionCount labeling = G.rejectionCount labeling := by + rw [semantics_ofGraph] + rfl + +def enumeratedGraph {V E A : Type*} {n m : Nat} (G : ConstraintGraph V E A) + (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) (labelOrder : A ≃ Label) : + ConstraintGraph (Fin n) (Fin m) Label where + reverse := (dartOrder.symm.trans G.reverse).trans dartOrder + reverse_involutive e := by + change dartOrder (G.reverse (dartOrder.symm + (dartOrder (G.reverse (dartOrder.symm e))))) = e + rw [dartOrder.symm_apply_apply, G.reverse_involutive, dartOrder.apply_symm_apply] + tail e := vertexOrder (G.tail (dartOrder.symm e)) + accepts e a b := G.accepts (dartOrder.symm e) (labelOrder.symm a) (labelOrder.symm b) + reverse_accepts e a b := by + change G.accepts (dartOrder.symm (dartOrder (G.reverse (dartOrder.symm e)))) + (labelOrder.symm b) (labelOrder.symm a) = _ + rw [dartOrder.symm_apply_apply] + exact G.reverse_accepts _ _ _ + +theorem enumeratedGraph_edgeSatisfied {V E A : Type*} {n m : Nat} + (G : ConstraintGraph V E A) (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) + (labelOrder : A ≃ Label) (labeling : V → A) (e : E) : + (enumeratedGraph G vertexOrder dartOrder labelOrder).edgeSatisfied + (fun v => labelOrder (labeling (vertexOrder.symm v))) (dartOrder e) = + G.edgeSatisfied labeling e := by + simp [ConstraintGraph.edgeSatisfied, ConstraintGraph.head, enumeratedGraph] + +theorem enumeratedGraph_rejectionCount {V E A : Type*} [Fintype E] {n m : Nat} + (G : ConstraintGraph V E A) (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) + (labelOrder : A ≃ Label) (labeling : V → A) : + (enumeratedGraph G vertexOrder dartOrder labelOrder).rejectionCount + (fun v => labelOrder (labeling (vertexOrder.symm v))) = G.rejectionCount labeling := by + classical + unfold ConstraintGraph.rejectionCount + symm + apply Finset.card_equiv dartOrder + intro e + simp only [ConstraintGraph.mem_rejectedDarts, enumeratedGraph_edgeSatisfied] + +def ofEnumeratedGraph {V E A : Type*} {n m : Nat} (G : ConstraintGraph V E A) + (vertexOrder : V ≃ Fin n) (dartOrder : E ≃ Fin m) (labelOrder : A ≃ Label) : Table := + ofGraph (enumeratedGraph G vertexOrder dartOrder labelOrder) + +def bitWord (b : Bool) : Nat := if b then 1 else 0 + +def parseBit : Nat → Option Bool + | 0 => some false + | 1 => some true + | _ => none + +@[simp] theorem parseBit_bitWord (b : Bool) : parseBit (bitWord b) = some b := by + cases b <;> rfl + +@[simp] theorem parseBits_bitWords (bits : List Bool) : + (bits.map bitWord).mapM parseBit = some bits := by + induction bits with + | nil => rfl + | cons bit bits ih => simp [ih] + +def relationWords (relation : RelationTable) : List Nat := relation.toList.map bitWord + +@[simp] theorem relationWords_length (relation : RelationTable) : + (relationWords relation).length = 4096 := by simp [relationWords] + +def parseRelation (words : List Nat) : Option RelationTable := do + let bits ← words.mapM parseBit + if length_ok : bits.length = 4096 then + some ⟨bits.toArray, by simpa using length_ok⟩ + else none + +@[simp] theorem parseRelation_encoded (relation : RelationTable) : + parseRelation (relationWords relation) = some relation := by + unfold parseRelation relationWords + rw [parseBits_bitWords] + simp + exact Vector.toArray_toList + +def rowWords {n m : Nat} (row : DartRow n m) : List Nat := + [row.tail.val, row.reverseIndex.val] ++ relationWords row.relation + +def parseRow (vertices darts : Nat) : List Nat → Option (DartRow vertices darts × List Nat) + | tail :: reverseIndex :: words => do + let tail ← parseLabel vertices tail + let reverseIndex ← parseLabel darts reverseIndex + let relation ← parseRelation (words.take 4096) + return (⟨tail, reverseIndex, relation⟩, words.drop 4096) + | _ => none + +@[simp] theorem parseRow_encoded {n m : Nat} (row : DartRow n m) (rest : List Nat) : + parseRow n m (rowWords row ++ rest) = some (row, rest) := by + cases row with + | mk tail reverseIndex relation => + have taken := List.take_left' (l₂ := rest) (relationWords_length relation) + have dropped := List.drop_left' (l₂ := rest) (relationWords_length relation) + simp [rowWords, parseRow, taken, dropped] + +def parseRows (vertices darts : Nat) : + Nat → List Nat → Option (List (DartRow vertices darts) × List Nat) + | 0, words => some ([], words) + | count + 1, words => do + let (row, words) ← parseRow vertices darts words + let (rows, words) ← parseRows vertices darts count words + return (row :: rows, words) + +@[simp] theorem parseRows_encoded {n m : Nat} (rows : List (DartRow n m)) (rest : List Nat) : + parseRows n m rows.length (rows.flatMap rowWords ++ rest) = some (rows, rest) := by + induction rows with + | nil => rfl + | cons row rows ih => simp [parseRows, List.append_assoc, ih] + +def tableWords (table : Table) : List Nat := + [table.vertices, table.darts] ++ (rowList table).flatMap rowWords + +def tableBits (table : Table) : List Bool := encodeWords (tableWords table) + +def decodeTableWords : List Nat → Option Table + | vertices :: darts :: words => do + let (parsed, trailing) ← parseRows vertices darts darts words + if trailing = [] then + if length_ok : parsed.length = darts then + let rows : Rows vertices darts := ⟨parsed.toArray, by simpa using length_ok⟩ + if valid : Valid rows then some ⟨vertices, darts, rows, valid⟩ else none + else none + else none + | _ => none + +@[simp] theorem decodeTableWords_encoded (table : Table) : + decodeTableWords (tableWords table) = some table := by + cases table with + | mk vertices darts rows valid => + have parsed := parseRows_encoded rows.toList [] + simp only [Vector.length_toList, List.append_nil] at parsed + simp [tableWords, rowList, decodeTableWords, parsed, valid, Vector.toArray_toList] + +def decodeTableBits (bits : List Bool) : Option Table := + decodeWords bits >>= decodeTableWords + +@[simp] theorem decodeTableBits_encoded (table : Table) : + decodeTableBits (tableBits table) = some table := by + simp [decodeTableBits, tableBits] + +def encoding : Computability.Encoding Table Bool where + encode := tableBits + decode := decodeTableBits + decode_encode := decodeTableBits_encoded + +theorem tableBits_injective : Function.Injective tableBits := encoding.encode_injective + +@[simp] theorem rowWords_length {n m : Nat} (row : DartRow n m) : + (rowWords row).length = 4098 := by simp [rowWords] + +theorem rowsWords_length {n m : Nat} (rows : List (DartRow n m)) : + (rows.flatMap rowWords).length = 4098 * rows.length := by + induction rows with + | nil => rfl + | cons row rows ih => simp [ih, Nat.mul_add, Nat.add_comm] + +@[simp] theorem tableWords_length (table : Table) : + (tableWords table).length = 2 + 4098 * table.darts := by + simp only [tableWords, List.length_append, List.length_cons, List.length_nil, + rowsWords_length, rowList_length] + +theorem tableWords_length_le_bits (table : Table) : + 2 + 4098 * table.darts ≤ (tableBits table).length := by + rw [tableBits, encodeWords_length, ← tableWords_length] + omega + +theorem relationBits_length_le (relation : RelationTable) : + (encodeWords (relationWords relation)).length ≤ 8192 := by + have h := encodeWords_length_le (relationWords relation) 1 (by + intro word hword + obtain ⟨bit, _, rfl⟩ := List.mem_map.mp hword + cases bit <;> decide) + simpa only [relationWords_length] using h + +theorem rowBits_length_le {n m : Nat} (row : DartRow n m) : + (encodeWords (rowWords row)).length ≤ n + m + 8192 := by + have ht := row.tail.isLt + have hr := row.reverseIndex.isLt + have hp := relationBits_length_le row.relation + simp only [rowWords, encodeWords_append, List.length_append, encodeWords, + encodeWord_length, List.length_nil] at ⊢ + omega + +theorem rowsBits_length_le {n m : Nat} (rows : List (DartRow n m)) : + (encodeWords (rows.flatMap rowWords)).length ≤ rows.length * (n + m + 8192) := by + induction rows with + | nil => simp [encodeWords] + | cons row rows ih => + have hrow := rowBits_length_le row + simp only [List.flatMap_cons, encodeWords_append, List.length_append, + List.length_cons, Nat.add_mul, Nat.one_mul] + omega + +theorem tableBits_length_le (table : Table) : + (tableBits table).length ≤ table.vertices + table.darts + 2 + + table.darts * (table.vertices + table.darts + 8192) := by + have hrows := rowsBits_length_le (rowList table) + rw [rowList_length] at hrows + simp only [tableBits, tableWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +theorem vertices_le_tableBits_length (table : Table) : + table.vertices ≤ (tableBits table).length := by + simp only [tableBits, tableWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +theorem darts_le_tableBits_length (table : Table) : + table.darts ≤ (tableBits table).length := by + simp only [tableBits, tableWords, encodeWords_append, List.length_append, + encodeWords, encodeWord_length, List.length_nil] + omega + +end IndependentSetsGames.Foundations.PCP.GraphTables + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/InitialGraph.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/InitialGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..0349a7c74652bd58c4aeab77b5a6b71782c53c04 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/InitialGraph.lean @@ -0,0 +1,195 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ConstraintGraph +import OAI.Combinatorics.IndependentSets.PCP.NameCompaction + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.InitialGraph + +open Target + +abbrev Label := Bool × Bool × Bool +abbrev Vertex (F : Formula) := (Fin F.«variables» ⊕ Fin F.clauses.length) ⊕ Unit +abbrev Dart (F : Formula) := (RandomEvent F × Bool) ⊕ Unit + +instance slotFintype : Fintype Slot where + elems := {Slot.first, Slot.second, Slot.third} + complete := by intro s; cases s <;> simp + +@[simp] theorem card_slot : Fintype.card Slot = 3 := by decide +@[simp] theorem card_label : Fintype.card Label = 8 := by + simp [Label, Fintype.card_prod] + +def variableVertex (F : Formula) (v : Fin F.«variables») : Vertex F := .inl (.inl v) +def clauseVertex (F : Formula) (i : Fin F.clauses.length) : Vertex F := .inl (.inr i) +def dummyVertex (F : Formula) : Vertex F := .inr () +def dummyDart (F : Formula) : Dart F := .inr () + +instance vertexNonempty (F : Formula) : Nonempty (Vertex F) := ⟨dummyVertex F⟩ +instance dartNonempty (F : Formula) : Nonempty (Dart F) := ⟨dummyDart F⟩ + +def reverse (F : Formula) : Dart F → Dart F + | .inl (event, orientation) => .inl (event, !orientation) + | .inr _ => .inr () + +theorem reverse_involutive (F : Formula) : Function.Involutive (reverse F) := by + intro d + cases d with + | inl pair => rcases pair with ⟨e, b⟩; cases b <;> rfl + | inr u => cases u; rfl + +def reverseEquiv (F : Formula) : Dart F ≃ Dart F where + toFun := reverse F + invFun := reverse F + left_inv := reverse_involutive F + right_inv := reverse_involutive F + +def tail (F : Formula) : Dart F → Vertex F + | .inl (event, false) => clauseVertex F event.1 + | .inl (event, true) => variableVertex F (nameAt (clauseAt F event.1) event.2) + | .inr _ => dummyVertex F + +def toClauseAnswer (label : Label) : ClauseAnswer := ⟨label.1, label.2.1, label.2.2⟩ +def fromClauseAnswer (answer : ClauseAnswer) : Label := (answer.first, answer.second, answer.third) +def variableLabel (value : Bool) : Label := (value, false, false) + +@[simp] theorem to_fromClauseAnswer (answer : ClauseAnswer) : + toClauseAnswer (fromClauseAnswer answer) = answer := by + cases answer; rfl + +def variableValid (label : Label) : Bool := + decide (label.2.1 = false ∧ label.2.2 = false) + +def incidenceAccept (F : Formula) (event : RandomEvent F) + (clauseLabel variableAnswer : Label) : Bool := + variableValid variableAnswer && + (localSatisfies (clauseAt F event.1) (toClauseAnswer clauseLabel) && + decide (answerAt (toClauseAnswer clauseLabel) event.2 = variableAnswer.1)) + +def predicate (F : Formula) : Dart F → Label → Label → Bool + | .inl (event, false), a, b => incidenceAccept F event a b + | .inl (event, true), a, b => incidenceAccept F event b a + | .inr _, _, _ => true + +def raw (F : Formula) : ConstraintGraph (Vertex F) (Dart F) Label where + reverse := reverseEquiv F + reverse_involutive := reverse_involutive F + tail := tail F + accepts := predicate F + reverse_accepts := by + intro d a b + cases d with + | inl pair => rcases pair with ⟨event, orientation⟩; cases orientation <;> rfl + | inr u => rfl + +theorem raw_forward (F : Formula) (labeling : Vertex F → Label) (event : RandomEvent F) : + (raw F).edgeSatisfied labeling (.inl (event, false)) = + incidenceAccept F event (labeling (clauseVertex F event.1)) + (labeling (variableVertex F (nameAt (clauseAt F event.1) event.2))) := rfl + +theorem incidenceAccept_true (F : Formula) (event : RandomEvent F) (a b : Label) + (h : incidenceAccept F event a b = true) : + localSatisfies (clauseAt F event.1) (toClauseAnswer a) = true ∧ + answerAt (toClauseAnswer a) event.2 = b.1 := by + simp only [incidenceAccept, Bool.and_eq_true, decide_eq_true_eq] at h + exact h.2 + +def honestLabeling (F : Formula) (A : Fin F.«variables» → Bool) : Vertex F → Label + | .inl (.inl v) => variableLabel (A v) + | .inl (.inr i) => fromClauseAnswer (honestAnswer (clauseAt F i) A) + | .inr _ => variableLabel false + +theorem incidence_honest (F : Formula) (A : Fin F.«variables» → Bool) + (sat : ∀ c ∈ F.clauses, c.eval A = true) (event : RandomEvent F) : + incidenceAccept F event (honestLabeling F A (clauseVertex F event.1)) + (honestLabeling F A (variableVertex F (nameAt (clauseAt F event.1) event.2))) = true := by + have hc : (clauseAt F event.1).eval A = true := sat _ (List.getElem_mem _) + simp [incidenceAccept, honestLabeling, clauseVertex, variableVertex, variableLabel, + variableValid, honest_satisfies, honest_answerAt, hc] + +theorem raw_completeness (F : Formula) (sat : F.Satisfiable) : (raw F).Satisfiable := by + rcases sat with ⟨A, hA⟩ + refine ⟨honestLabeling F A, fun d => ?_⟩ + cases d with + | inl pair => + rcases pair with ⟨event, orientation⟩ + cases orientation <;> exact incidence_honest F A hA event + | inr u => rfl + +theorem clauseAnswer_eq_of_slots (a b : ClauseAnswer) + (h : ∀ s, answerAt a s = answerAt b s) : a = b := by + rcases a with ⟨a₀, a₁, a₂⟩ + rcases b with ⟨b₀, b₁, b₂⟩ + have h₀ : a₀ = b₀ := h .first + have h₁ : a₁ = b₁ := h .second + have h₂ : a₂ = b₂ := h .third + cases h₀; cases h₁; cases h₂; rfl + +theorem raw_reflects (F : Formula) (sat : (raw F).Satisfiable) : F.Satisfiable := by + rcases sat with ⟨labeling, hlabeling⟩ + let A : Fin F.«variables» → Bool := fun v => (labeling (variableVertex F v)).1 + have slot_correct (i : Fin F.clauses.length) (s : Slot) : + localSatisfies (clauseAt F i) (toClauseAnswer (labeling (clauseVertex F i))) = true ∧ + answerAt (toClauseAnswer (labeling (clauseVertex F i))) s = + A (nameAt (clauseAt F i) s) := by + exact incidenceAccept_true F (i, s) _ _ (hlabeling (.inl ((i, s), false))) + have clause_correct (i : Fin F.clauses.length) : (clauseAt F i).eval A = true := by + have equal : toClauseAnswer (labeling (clauseVertex F i)) = honestAnswer (clauseAt F i) A := + clauseAnswer_eq_of_slots _ _ (fun s => by + simpa only [honest_answerAt] using (slot_correct i s).2) + have satisfied := (slot_correct i .first).1 + rw [equal, honest_satisfies] at satisfied + exact satisfied + refine ⟨A, fun c hc => ?_⟩ + obtain ⟨i, hi, heq⟩ := List.getElem_of_mem hc + simpa only [clauseAt, heq] using clause_correct ⟨i, hi⟩ + +theorem raw_satisfiable_iff (F : Formula) : (raw F).Satisfiable ↔ F.Satisfiable := + ⟨raw_reflects F, raw_completeness F⟩ + +@[simp] theorem card_vertex (F : Formula) : + Fintype.card (Vertex F) = F.«variables» + F.clauses.length + 1 := by + simp [Vertex, Fintype.card_sum] + +@[simp] theorem card_dart (F : Formula) : + Fintype.card (Dart F) = 6 * F.clauses.length + 1 := by + simp [Dart, RandomEvent, Fintype.card_sum, Fintype.card_prod] + omega + +abbrev CompactVertex (F : Formula) := Vertex (NameCompaction.compact F) +abbrev CompactDart (F : Formula) := Dart (NameCompaction.compact F) + +def build (F : Formula) : ConstraintGraph (CompactVertex F) (CompactDart F) Label := + raw (NameCompaction.compact F) + +theorem build_satisfiable_iff (F : Formula) : (build F).Satisfiable ↔ F.Satisfiable := by + exact (raw_satisfiable_iff (NameCompaction.compact F)).trans + (NameCompaction.compact_satisfiable_iff F) + +theorem build_vertex_bound (F : Formula) : + Fintype.card (CompactVertex F) ≤ 4 * F.clauses.length + 1 := by + have h := NameCompaction.compact_active_bound F + simp only [CompactVertex, card_vertex, NameCompaction.compact_clause_count] + omega + +theorem build_dart_count (F : Formula) : + Fintype.card (CompactDart F) = 6 * F.clauses.length + 1 := by + simp only [CompactDart, card_dart, NameCompaction.compact_clause_count] + +theorem build_initial_gap (F : Formula) (unsat : ¬ F.Satisfiable) + (labeling : CompactVertex F → Label) : 1 ≤ (build F).rejectionCount labeling := by + apply ConstraintGraph.rejectionCount_positive + intro h + exact unsat ((build_satisfiable_iff F).mp h) + +theorem build_inverse_size_gap (F : Formula) (unsat : ¬ F.Satisfiable) + (labeling : CompactVertex F → Label) : + Fintype.card (CompactDart F) ≤ + (6 * F.clauses.length + 1) * (build F).rejectionCount labeling := by + rw [build_dart_count] + simpa only [Nat.mul_one] using + Nat.mul_le_mul_left (6 * F.clauses.length + 1) (build_initial_gap F unsat labeling) + +end IndependentSetsGames.Foundations.PCP.InitialGraph + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Input.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Input.lean new file mode 100644 index 0000000000000000000000000000000000000000..6540d410ea7c114fbb230f639b23605432446be4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Input.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.GameEncoding +import OAI.Combinatorics.IndependentSets.PCP.ClauseVerifier +import OAI.Combinatorics.IndependentSets.PCP.GenericGraphTables + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Input + +open IndependentSetsGames.Foundations.Complexity + +export GenericGraphTables (Label RelationTable DartRow Rows Valid Table + relationIndex relationIndex_val relationAt relationOf relationAt_relationOf + reverseAt acceptsAt rowList rowList_length semantics semantics_reverse + semantics_tail semantics_accepts ofGraph semantics_ofGraph ofEnumeratedGraph + bitWord relationWords relationWords_length rowWords rowWords_length + rowsWords_length tableWords tableWords_length tableBits encoding + parseRelation parseRow parseRows decodeTableWords decodeTableBits + parseRelation_encoded parseRow_encoded parseRows_encoded + decodeTableWords_encoded decodeTableBits_encoded tableBits_injective + relationBits_length_le rowBits_length_le rowsBits_length_le tableWords_length_le_bits + tableBits_length_le vertices_le_tableBits_length darts_le_tableBits_length) + +variable {q n m : Nat} + +abbrev rowWidth (q : Nat) : Nat := q * q + 2 + +def rowOffset (q e : Nat) : Nat := 2 + rowWidth q * e + +theorem rowsWords_split (rows : List (DartRow q n m)) (e : Nat) + (he : e < rows.length) : + rows.flatMap rowWords = (rows.take e).flatMap rowWords ++ + (rowWords rows[e] ++ (rows.drop (e + 1)).flatMap rowWords) := by + have hs : rows.take e ++ rows[e] :: rows.drop (e + 1) = rows := by + rw [List.getElem_cons_drop he, List.take_append_drop] + have hw := congrArg (fun rs : List (DartRow q n m) => rs.flatMap rowWords) hs + simpa only [List.flatMap_append, List.flatMap_cons, List.append_assoc] using hw.symm + +theorem rowsBits_split (rows : List (DartRow q n m)) (e : Nat) + (he : e < rows.length) : + encodeWords (rows.flatMap rowWords) = + encodeWords ((rows.take e).flatMap rowWords) ++ + (encodeWords (rowWords rows[e]) ++ + encodeWords ((rows.drop (e + 1)).flatMap rowWords)) := by + rw [rowsWords_split rows e he] + simp only [encodeWords_append] + +theorem rowsBits_append_split (rows : List (DartRow q n m)) (e : Nat) + (he : e < rows.length) (suffix : List Bool) : + encodeWords (rows.flatMap rowWords) ++ suffix = + encodeWords ((rows.take e).flatMap rowWords) ++ + (encodeWords (rowWords rows[e]) ++ + (encodeWords ((rows.drop (e + 1)).flatMap rowWords) ++ suffix)) := by + rw [rowsBits_split rows e he] + simp only [List.append_assoc] + +def prefixWords (table : Table q) (e : Fin table.darts) : List Nat := + [table.vertices, table.darts] ++ ((rowList table).take e.val).flatMap rowWords + +def suffixWords (table : Table q) (e : Fin table.darts) : List Nat := + ((rowList table).drop (e.val + 1)).flatMap rowWords + +theorem prefixWords_length (table : Table q) (e : Fin table.darts) : + (prefixWords table e).length = rowOffset q e.val := by + simp [prefixWords, rowOffset, rowWidth, Nat.mul_comm, Nat.add_comm] + omega + +theorem tableWords_at_row (table : Table q) (e : Fin table.darts) : + tableWords table = prefixWords table e ++ + (rowWords table.rows[e] ++ suffixWords table e) := by + have hs := rowsWords_split (rowList table) e.val (by simpa only [rowList_length] using e.isLt) + simp only [rowList, Vector.getElem_toList] at hs + unfold tableWords prefixWords suffixWords rowList + rw [hs] + simp only [List.append_assoc, Fin.getElem_fin] + +theorem tableBits_at_row (table : Table q) (e : Fin table.darts) : + tableBits table = encodeWords (prefixWords table e) ++ + (encodeWords (rowWords table.rows[e]) ++ encodeWords (suffixWords table e)) := by + rw [tableBits, tableWords_at_row table e] + simp only [encodeWords_append] + +theorem tableBits_header (table : Table q) : + tableBits table = encodeWord table.vertices ++ + (encodeWord table.darts ++ encodeWords ((rowList table).flatMap rowWords)) := by + simp [tableBits, tableWords, encodeWords] + +theorem tableWords_drop_row (table : Table q) (e : Fin table.darts) : + (tableWords table).drop (rowOffset q e.val) = + rowWords table.rows[e] ++ suffixWords table e := by + rw [tableWords_at_row table e] + exact List.drop_left' (l₂ := rowWords table.rows[e] ++ suffixWords table e) + (prefixWords_length table e) + +theorem tableWords_take_row (table : Table q) (e : Fin table.darts) : + ((tableWords table).drop (rowOffset q e.val)).take (rowWidth q) = + rowWords table.rows[e] := by + rw [tableWords_drop_row] + exact List.take_left' (l₂ := suffixWords table e) (rowWords_length table.rows[e]) + +theorem tableWords_get_tail (table : Table q) (e : Fin table.darts) : + (tableWords table)[rowOffset q e.val]? = some table.rows[e].tail.val := by + have h := congrArg (fun words : List Nat => words[0]?) (tableWords_drop_row table e) + simpa [List.getElem?_drop, rowWords] using h + +theorem tableWords_get_reverse (table : Table q) (e : Fin table.darts) : + (tableWords table)[rowOffset q e.val + 1]? = some table.rows[e].reverseIndex.val := by + have h := congrArg (fun words : List Nat => words[1]?) (tableWords_drop_row table e) + simpa [List.getElem?_drop, rowWords] using h + +theorem tableWords_drop_relation (table : Table q) (e : Fin table.darts) : + (tableWords table).drop (rowOffset q e.val + 2) = + relationWords table.rows[e].relation ++ suffixWords table e := by + rw [← List.drop_drop, tableWords_drop_row] + simp [rowWords] + +theorem relationWords_get (relation : RelationTable q) (j : Fin (q * q)) : + (relationWords relation)[j.val]? = some (bitWord relation[j]) := by + rw [List.getElem?_eq_getElem (by simpa only [relationWords_length] using j.isLt)] + simp [relationWords] + +theorem tableWords_get_relation (table : Table q) (e : Fin table.darts) + (j : Fin (q * q)) : + (tableWords table)[rowOffset q e.val + 2 + j.val]? = + some (bitWord table.rows[e].relation[j]) := by + have h := congrArg (fun words : List Nat => words[j.val]?) + (tableWords_drop_relation table e) + rw [List.getElem?_drop, + List.getElem?_append_left (by simpa only [relationWords_length] using j.isLt), relationWords_get] at h + exact h + +theorem tableWords_get_predicate (table : Table q) (e : Fin table.darts) + (a b : Label q) : + (tableWords table)[rowOffset q e.val + 2 + (b.val + q * a.val)]? = + some (bitWord ((semantics table).accepts e a b)) := by + simpa only [relationIndex_val, semantics_accepts, relationAt] using + tableWords_get_relation table e ((relationIndex q) (a, b)) + +theorem rowOffset_lt_length (table : Table q) (e : Fin table.darts) : + rowOffset q e.val < (tableWords table).length := by + rw [tableWords_length] + have h := Nat.mul_le_mul_left (rowWidth q) (Nat.succ_le_of_lt e.isLt) + rw [Nat.mul_succ] at h + unfold rowOffset rowWidth at * + omega + +theorem relationOffset_lt_length (table : Table q) (e : Fin table.darts) + (j : Fin (q * q)) : + rowOffset q e.val + 2 + j.val < (tableWords table).length := by + rw [tableWords_length] + have h := Nat.mul_le_mul_left (rowWidth q) (Nat.succ_le_of_lt e.isLt) + rw [Nat.mul_succ] at h + have hj := j.isLt + unfold rowOffset rowWidth at * + omega + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Input + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/LCTable.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/LCTable.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc240350ab090227619ccd32c35a9bb2b71fb6b4 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/LCTable.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.StoredFloyd + +namespace OAI + +namespace LargeIndependentSets.UniformLC +open IndependentSetsCut.CounterMachine +open scoped Classical BigOperators +noncomputable section + +structure Table (L R : Type) where + nu : ℕ + nv : ℕ + ne : ℕ + hu : 0 < nu + hv : 0 < nv + he : 0 < ne + left : Fin ne → Fin nu + right : Fin ne → Fin nv + project : Fin ne → L → R + +def Table.lc {L R : Type} (t : Table L R) : LabelCoverData (Fin t.nu) (Fin t.nv) L R (Fin t.ne) := + ⟨t.left,t.right,t.project⟩ + +instance {L R : Type} (t : Table L R) : Nonempty (Fin t.ne) := ⟨⟨0,t.he⟩⟩ + +variable {L R : Type} [Fintype L] [Fintype R] + +def projectCode (f : L → R) : ℕ := (Fintype.equivFin (L → R) f).val + +def Table.value (t : Table L R) (w : ℕ) : ℕ := + if w=0 then t.nu else if w=1 then t.nv else if w=2 then t.ne else + if h : (w-3)/3 < t.ne then + if (w-3)%3=0 then (t.left ⟨(w-3)/3,h⟩).val + else if (w-3)%3=1 then (t.right ⟨(w-3)/3,h⟩).val + else projectCode (t.project ⟨(w-3)/3,h⟩) + else 0 + +def Table.bits (t : Table L R) := UnaryTables.words t.value (3+3*t.ne) + +@[simp] lemma read_nu (t : Table L R) : Expr.wordValue t.bits 0=t.nu := by + rw [Table.bits,UnaryTables.wordValue_words _ _ _ (by omega)] + simp [Table.value] +@[simp] lemma read_nv (t : Table L R) : Expr.wordValue t.bits 1=t.nv := by + rw [Table.bits,UnaryTables.wordValue_words _ _ _ (by omega)] + simp [Table.value] +@[simp] lemma read_ne (t : Table L R) : Expr.wordValue t.bits 2=t.ne := by + rw [Table.bits,UnaryTables.wordValue_words _ _ _ (by omega)] + simp [Table.value] + +lemma read_field (t : Table L R) (c : Fin t.ne) (j : Fin 3) : + Expr.wordValue t.bits (3+3*c.val+j.val) = + if j.val=0 then (t.left c).val else if j.val=1 then (t.right c).val else projectCode (t.project c) := by + rw [Table.bits,UnaryTables.wordValue_words _ _ _ (by have := c.isLt; have := j.isLt; omega)] + have hsub : 3+3*c.val+j.val-3=3*c.val+j.val := by omega + have hdiv : (3*c.val+j.val)/3=c.val := by omega + have hmod : (3*c.val+j.val)%3=j.val := by omega + simp [Table.value,show 3+3*c.val+j.val≠1 by omega, + show 3+3*c.val+j.val≠2 by omega,hsub,hdiv,hmod,c.isLt] + +def nuExpr : Expr := Expr.word (.const 0) +def nvExpr : Expr := Expr.word (.const 1) +def neExpr : Expr := Expr.word (.const 2) +def fieldExpr (c : Expr) (j : ℕ) : Expr := Expr.word (.add (.add (.const 3) (.mul (.const 3) c)) (.const j)) + +@[simp] lemma nuExpr_eval (t : Table L R) (a : ℕ → ℕ) : nuExpr.eval t.bits a=t.nu := by simp [nuExpr,Expr.eval] +@[simp] lemma nvExpr_eval (t : Table L R) (a : ℕ → ℕ) : nvExpr.eval t.bits a=t.nv := by simp [nvExpr,Expr.eval] +@[simp] lemma neExpr_eval (t : Table L R) (a : ℕ → ℕ) : neExpr.eval t.bits a=t.ne := by simp [neExpr,Expr.eval] + +lemma fieldExpr_eval (t : Table L R) (a : ℕ → ℕ) (c : Expr) (e : Fin t.ne) + (hc : c.eval t.bits a=e.val) (j : Fin 3) : + (fieldExpr c j.val).eval t.bits a = + if j.val=0 then (t.left e).val else if j.val=1 then (t.right e).val else projectCode (t.project e) := by + simp only [fieldExpr,Expr.word_eval,Expr.eval,hc,read_field] + +end +end LargeIndependentSets.UniformLC + +namespace IndependentSetsCut.CounterMachine.Expr +open scoped BigOperators + +def finLookup {m : ℕ} (f : Fin m → ℕ) (x : Expr) : Expr := + listSum (List.finRange m) (fun i => .mul (equal x (.const i.val)) (.const (f i))) + +lemma finLookup_eval {m : ℕ} (f : Fin m → ℕ) (x : Expr) (s : List Bool) (a : ℕ → ℕ) + (i : Fin m) (hi : x.eval s a=i.val) : + (finLookup f x).eval s a=f i := by + simp only [finLookup,listSum_eval,eval,equal_eval,hi,ite_mul,one_mul,zero_mul] + rw [← List.ofFn_eq_map,List.sum_ofFn] + simp [Fin.val_inj] + +noncomputable def staticLookup {α : Type} [Fintype α] (f : α → ℕ) (x : Expr) : Expr := + finLookup (fun i => f ((Fintype.equivFin α).symm i)) x + +lemma staticLookup_eval {α : Type} [Fintype α] (f : α → ℕ) (x : Expr) + (s : List Bool) (a : ℕ → ℕ) (v : α) (hv : x.eval s a=(Fintype.equivFin α v).val) : + (staticLookup f x).eval s a=f v := by + rw [staticLookup,finLookup_eval _ _ _ _ _ hv,Equiv.symm_apply_apply] + +def listAll {α : Type} (xs : List α) (f : α → Expr) : Expr := + .zero (listSum xs (fun a => .zero (f a))) + +lemma listAll_eval {α : Type} (xs : List α) (f : α → Expr) (s : List Bool) (a : ℕ → ℕ) : + (listAll xs f).eval s a = if ∀ x ∈ xs, (f x).eval s a≠0 then 1 else 0 := by + simp only [listAll,eval,listSum_eval] + congr 1 + simp only [List.sum_eq_zero_iff,List.mem_map,forall_exists_index,and_imp] + simp + +end IndependentSetsCut.CounterMachine.Expr + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/LabelCoverData.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/LabelCoverData.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7e530880e95909e87245140aa22e3392ac40872 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/LabelCoverData.lean @@ -0,0 +1,400 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.WalkLength + +namespace OAI + +namespace LargeIndependentSets +open scoped ENNReal NNReal + +structure LabelCoverData (U V L R C : Type*) where + left : C → U + right : C → V + project : C → L → R + +def LabelCoverData.Satisfied {U V L R C : Type*} (lc : LabelCoverData U V L R C) + (ℓ : U → L) (ρ : V → R) : Prop := + ∀ c, lc.project c (ℓ (lc.left c)) = ρ (lc.right c) + +def MixedTuple (A B : Type*) (n i : ℕ) := + {x : Fin n → B ⊕ A // ∀ h, (x h).isLeft = decide (h.val < i)} + +noncomputable def MixedTuple.map {A B A' B' : Type*} {n i : ℕ} + (l : A → A') (r : B → B') (x : MixedTuple A B n i) : MixedTuple A' B' n i := + ⟨fun h => Sum.map r l (x.val h), by + intro h + simpa only [Sum.isLeft_map] using x.property h⟩ + +def mixedProject {L R : Type*} {n : ℕ} (h : Fin n) (π : L → R) + (x : MixedTuple L R n h.val) : MixedTuple L R n (h.val + 1) := + ⟨fun k => if k = h then Sum.inl ((x.val k).elim id π) else x.val k, by + intro k + by_cases hk : k = h + · subst k + simp + · simp only [ite_eq_right hk, x.property k] + have hne : k.val ≠ h.val := fun e => hk (Fin.ext e) + have he : (k.val < h.val) = (k.val < h.val + 1) := propext (by omega) + simp only [he]⟩ + +abbrev LayerQuestion (U V : Type*) (n : ℕ) := + Σ i : Fin (n + 1), MixedTuple U V n i.val + +abbrev LayerAnswer {U V : Type*} (L R : Type*) {n : ℕ} + (q : LayerQuestion U V n) := MixedTuple L R n q.1.val + +inductive LayerImposed {U V L R C : Type*} (lc : LabelCoverData U V L R C) (n : ℕ) : + (q q' : LayerQuestion U V n) → (LayerAnswer L R q → LayerAnswer L R q') → Prop + | adjacent (h : Fin n) (q : MixedTuple U V n h.val) + (q' : MixedTuple U V n (h.val + 1)) (c : C) + (hleft : q.val h = Sum.inr (lc.left c)) + (hright : q'.val h = Sum.inl (lc.right c)) + (houtside : ∀ k, k ≠ h → q.val k = q'.val k) : + LayerImposed lc n ⟨h.castSucc, q⟩ ⟨h.succ, q'⟩ (mixedProject h (lc.project c)) + +def layeredSystem {U V L R C : Type*} (lc : LabelCoverData U V L R C) (n : ℕ) : + ProjectionSystem (LayerQuestion U V n) (LayerAnswer L R) where + imposed := LayerImposed lc n + +noncomputable def productLabeling {U V L R : Type*} {n : ℕ} + (ℓ : U → L) (ρ : V → R) (q : LayerQuestion U V n) : LayerAnswer L R q := + MixedTuple.map ℓ ρ q.2 + +theorem productLabeling_consistent {U V L R C : Type*} + (lc : LabelCoverData U V L R C) (n : ℕ) (ℓ : U → L) (ρ : V → R) + (hsat : lc.Satisfied ℓ ρ) : + (layeredSystem lc n).Consistent (productLabeling ℓ ρ) := by + intro q q' π hπ + cases hπ with + | adjacent h q q' c hleft hright houtside => + apply Subtype.ext + funext k + by_cases hk : k = h + · subst k + simp [mixedProject, productLabeling, MixedTuple.map, + hleft, hright, hsat c] + · simp only [mixedProject, productLabeling, MixedTuple.map, ite_eq_right hk, + houtside k hk] + +theorem layered_completeness {U V L R C : Type*} + (lc : LabelCoverData U V L R C) (n : ℕ) (ℓ : U → L) (ρ : V → R) + (hsat : lc.Satisfied ℓ ρ) {D : ℕ} [NeZero D] (hD : Even D) : + (∀ x : GridLocation (LayerAnswer L R (U := U) (V := V) (n := n)) D, + ¬pathDistance (layeredSystem lc n).linkLength x (gridAntipode x) ≤ + ENNReal.ofReal (1 / 8)) ∧ + (∀ (W : Type*) (location : W → GridLocation (LayerAnswer L R + (U := U) (V := V) (n := n)) D), + ∃ color : W → Fin 3, ∀ u v, (gridGraph (layeredSystem lc n) hD location).Adj u v → + color u ≠ color v) := by + have h := productLabeling_consistent lc n ℓ ρ hsat + exact ⟨(projection_grid_completeness.{_, _, 0} (layeredSystem lc n) hD _ h).1, + fun W location => gridGraph_three_coloring (layeredSystem lc n) hD _ h location⟩ + +noncomputable def distanceBump (d : ℝ≥0∞) : ℝ := + if d = ⊤ then 0 else max (1 - 32 * d.toReal) 0 + +lemma distanceBump_bounds (d : ℝ≥0∞) : 0 ≤ distanceBump d ∧ distanceBump d ≤ 1 := by + unfold distanceBump + split_ifs + · norm_num + · refine ⟨le_max_right _ _, max_le ?_ (by norm_num)⟩ + have := ENNReal.toReal_nonneg (a := d) + linarith + +@[simp] lemma distanceBump_zero : distanceBump 0 = 1 := by + norm_num [distanceBump] + +lemma distanceBump_vanish {d : ℝ≥0∞} (hd : ENNReal.ofReal (1 / 32) ≤ d) : + distanceBump d = 0 := by + unfold distanceBump + split_ifs with htop + · rfl + · have hr := ENNReal.toReal_mono htop hd + norm_num at hr + exact max_eq_right (by linarith) + +lemma distanceBump_difference {a b c : ℝ≥0∞} (hc : c ≠ ⊤) + (hab : a ≤ c + b) (hba : b ≤ c + a) : + |distanceBump a - distanceBump b| ≤ 32 * c.toReal := by + by_cases ha : a = ⊤ + · by_cases hb : b = ⊤ + · simp only [distanceBump, ha, hb, ite_eq_left, sub_self, abs_zero] + exact mul_nonneg (by norm_num) ENNReal.toReal_nonneg + · have htop : c + b = ⊤ := top_le_iff.mp (ha ▸ hab) + exact False.elim ((ENNReal.add_ne_top.mpr ⟨hc, hb⟩) htop) + · by_cases hb : b = ⊤ + · have htop : c + a = ⊤ := top_le_iff.mp (hb ▸ hba) + exact False.elim ((ENNReal.add_ne_top.mpr ⟨hc, ha⟩) htop) + · have har := (ENNReal.toReal_le_toReal ha (ENNReal.add_ne_top.mpr ⟨hc, hb⟩)).mpr hab + have hbr := (ENNReal.toReal_le_toReal hb (ENNReal.add_ne_top.mpr ⟨hc, ha⟩)).mpr hba + rw [ENNReal.toReal_add hc hb] at har + rw [ENNReal.toReal_add hc ha] at hbr + simp only [distanceBump, ite_eq_right ha, ite_eq_right hb] + calc + _ ≤ max |(1 - 32 * a.toReal) - (1 - 32 * b.toReal)| |(0 : ℝ) - 0| := + abs_max_sub_max_le_max _ _ _ _ + _ = |(1 - 32 * a.toReal) - (1 - 32 * b.toReal)| := by simp + _ ≤ 32 * c.toReal := by + rw [abs_le] + constructor <;> linarith + +noncomputable def setBump {X : Type*} [PseudoEMetricSpace X] (A : Set X) (x : X) : ℝ := + distanceBump (Metric.infEDist x A) + +lemma setBump_lipschitz {X : Type*} [PseudoEMetricSpace X] (A : Set X) : + LipschitzWith 32 (setBump A) := by + intro x y + by_cases hc : edist x y = ⊤ + · simp [hc] + · have h := distanceBump_difference hc + (Metric.infEDist_le_edist_add_infEDist (x := x) (y := y) (s := A)) + (by simpa only [edist_comm x y] using + (Metric.infEDist_le_edist_add_infEDist (x := y) (y := x) (s := A))) + have hh := ENNReal.ofReal_le_ofReal h + simpa only [setBump, edist_dist, Real.dist_eq, ENNReal.ofReal_mul (by norm_num : (0 : ℝ) ≤ 32), + ENNReal.ofReal_toReal hc, ENNReal.ofReal_ofNat, ENNReal.coe_ofNat] using hh + +noncomputable def oddBump {X : Type*} [PseudoEMetricSpace X] + (T : X → X) (A : Set X) (x : X) : ℝ := setBump A x - setBump A (T x) + +lemma oddBump_bounds {X : Type*} [PseudoEMetricSpace X] + (T : X → X) (A : Set X) (x : X) : -1 ≤ oddBump T A x ∧ oddBump T A x ≤ 1 := by + have hx := distanceBump_bounds (Metric.infEDist x A) + have htx := distanceBump_bounds (Metric.infEDist (T x) A) + unfold oddBump setBump + constructor <;> linarith + +lemma oddBump_odd {X : Type*} [PseudoEMetricSpace X] (T : X → X) + (hT : Function.Involutive T) (A : Set X) (x : X) : + oddBump T A (T x) = -oddBump T A x := by + simp only [oddBump, hT x] + ring + +lemma oddBump_lipschitz {X : Type*} [PseudoEMetricSpace X] + (T : X → X) (hT : Isometry T) (A : Set X) : LipschitzWith 64 (oddBump T A) := by + have h := (setBump_lipschitz A).sub ((setBump_lipschitz A).comp hT.lipschitzWith) + norm_num only [mul_one, Nat.reduceAdd] at h + exact h + +lemma oddBump_eq_one {X : Type*} [PseudoEMetricSpace X] + (T : X → X) (A : Set X) + (hsep : ∀ x ∈ A, ∀ y ∈ A, ENNReal.ofReal (1 / 8) < edist x (T y)) + {x : X} (hx : x ∈ A) : oddBump T A x = 1 := by + have hdist : ENNReal.ofReal (1 / 32) ≤ Metric.infEDist (T x) A := by + apply Metric.le_infEDist.mpr + intro y hy + rw [edist_comm] + exact (by norm_num : ENNReal.ofReal (1 / 32) ≤ ENNReal.ofReal (1 / 8)).trans + (hsep y hy x hx).le + simp only [oddBump, setBump, Metric.infEDist_zero_of_mem hx, + distanceBump_zero, distanceBump_vanish hdist, sub_zero] + +lemma linkLength_le_copyLength {Q : Type*} {M : Q → Type*} + (S : ProjectionSystem Q M) {D : ℕ} [NeZero D] (x y : GridLocation M D) : + S.linkLength x y ≤ copyLength x y := by + classical + unfold ProjectionSystem.linkLength + split_ifs <;> simp + +lemma grid_independent_separation {Q : Type*} {M : Q → Type*} + (S : ProjectionSystem Q M) {D : ℕ} [NeZero D] (hD : Even D) + (hnoclique : ∀ x : GridLocation M D, + ¬pathDistance S.linkLength x (gridAntipode x) ≤ ENNReal.ofReal (1 / 8)) + {V : Type*} (location : V → GridLocation M D) (A : Set V) + (hA : (gridGraph S hD location).IsIndepSet A) : + ∀ x ∈ location '' A, ∀ y ∈ location '' A, + ENNReal.ofReal (1 / 8) < pathDistance S.linkLength x (gridAntipode y) := by + rintro x ⟨u, hu, rfl⟩ y ⟨v, hv, rfl⟩ + by_contra hn + have hle := le_of_not_gt hn + by_cases h : u = v + · subst v + exact hnoclique (location u) hle + · exact ((gridGraph S hD location).isIndepSet_iff.mp hA) hu hv h ⟨h, hle⟩ + +noncomputable def gridBump {Q : Type*} {M : Q → Type*} + (S : ProjectionSystem Q M) {D : ℕ} [NeZero D] + (A : Set (GridLocation M D)) (x : GridLocation M D) : ℝ := by + letI := linkPseudoEMetric (S.linkLength (D := D)) (linkLength_self S) (linkLength_symm S) + exact oddBump gridAntipode A x + +theorem grid_independent_bump {Q : Type*} {M : Q → Type*} [∀ q, Fintype (M q)] + (S : ProjectionSystem Q M) {D : ℕ} [NeZero D] (hD : Even D) + (hnoclique : ∀ x : GridLocation M D, + ¬pathDistance S.linkLength x (gridAntipode x) ≤ ENNReal.ofReal (1 / 8)) + {V : Type*} (location : V → GridLocation M D) (A : Set V) + (hA : (gridGraph S hD location).IsIndepSet A) : + let f := gridBump S (location '' A) + (∀ x, -1 ≤ f x ∧ f x ≤ 1) ∧ + (∀ x, f (gridAntipode x) = -f x) ∧ + (∀ v ∈ A, f (location v) = 1) ∧ + (∀ x y, S.ZeroLink D x y → f x = f y) ∧ + (∀ q (u v : M q → ZMod D), + edist (f ⟨q, u⟩) (f ⟨q, v⟩) ≤ (64 : ℝ≥0∞) * + edist (fun k => ZMod.toAddCircle (u k)) (fun k => ZMod.toAddCircle (v k))) := by + let := linkPseudoEMetric (S.linkLength (D := D)) (linkLength_self S) (linkLength_symm S) + have hT : Isometry (gridAntipode : GridLocation M D → GridLocation M D) := + pathDistance_invariant S.linkLength gridAntipode (gridAntipode_involutive hD) + (linkLength_antipode S hD) + have hf : LipschitzWith 64 (gridBump S (location '' A)) := + oddBump_lipschitz gridAntipode hT (location '' A) + refine ⟨oddBump_bounds gridAntipode (location '' A), + oddBump_odd gridAntipode (gridAntipode_involutive hD) (location '' A), ?_, ?_, ?_⟩ + · intro v hv + exact oddBump_eq_one gridAntipode (location '' A) + (grid_independent_separation S hD hnoclique location A hA) ⟨v, hv, rfl⟩ + · intro x y hxy + have hpath : pathDistance S.linkLength x y = 0 := by + apply le_antisymm _ bot_le + apply (pathDistance_le_link S.linkLength x y).trans + simp [ProjectionSystem.linkLength, hxy] + have h := hf x y + change edist (gridBump S (location '' A) x) (gridBump S (location '' A) y) ≤ + (64 : ℝ≥0∞) * pathDistance S.linkLength x y at h + rw [hpath, mul_zero] at h + exact edist_eq_zero.mp (le_antisymm h bot_le) + · intro q u v + apply (hf ⟨q, u⟩ ⟨q, v⟩).trans + simp only [ENNReal.coe_ofNat] + apply mul_le_mul_right + change pathDistance S.linkLength ⟨q, u⟩ ⟨q, v⟩ ≤ _ + apply (pathDistance_le_link S.linkLength _ _).trans + apply (linkLength_le_copyLength S _ _).trans_eq + rw [copyLength_same, edist_pi_def] + simp only [Finset.sup_univ_eq_iSup] + +noncomputable def finiteMcShane {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) (x : X) : ℝ := + Finset.univ.inf' Finset.univ_nonempty (fun y => f y + L * dist x (e y)) + +lemma finiteMcShane_le {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) (x : X) (y : G) : + finiteMcShane e f L x ≤ f y + L * dist x (e y) := + Finset.inf'_le _ (Finset.mem_univ y) + +lemma finiteMcShane_on_grid {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) + (hf : ∀ x y, |f x - f y| ≤ L * dist (e x) (e y)) (x : G) : + finiteMcShane e f L (e x) = f x := by + apply le_antisymm + · simpa using finiteMcShane_le e f L (e x) x + · apply Finset.le_inf' + intro y _ + have := (abs_le.mp (hf x y)).2 + linarith + +lemma finiteMcShane_lipschitz {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) : + LipschitzWith L (finiteMcShane e f L) := by + have hle (x y : X) : finiteMcShane e f L x ≤ finiteMcShane e f L y + L * dist x y := by + obtain ⟨g, _, hg⟩ := Finset.exists_mem_eq_inf' (s := (Finset.univ : Finset G)) + Finset.univ_nonempty (fun g => f g + L * dist y (e g)) + change finiteMcShane e f L y = _ at hg + have hm := mul_le_mul_of_nonneg_left (dist_triangle x y (e g)) L.coe_nonneg + have h := finiteMcShane_le e f L x g + rw [hg] + linarith + apply LipschitzWith.of_dist_le_mul + intro x y + rw [Real.dist_eq, abs_le] + have h₁ := hle x y + have h₂ := hle y x + rw [dist_comm y x] at h₂ + constructor <;> linarith + +def clipUnit (x : ℝ) : ℝ := max (-1) (min 1 x) + +lemma clipUnit_bounds (x : ℝ) : -1 ≤ clipUnit x ∧ clipUnit x ≤ 1 := by + exact ⟨le_max_left _ _, max_le (by norm_num) (min_le_left _ _)⟩ + +lemma clipUnit_eq {x : ℝ} (hx : -1 ≤ x ∧ x ≤ 1) : clipUnit x = x := by + simp [clipUnit, min_eq_right hx.2, max_eq_right hx.1] + +lemma clipUnit_lipschitz : LipschitzWith 1 clipUnit := + (LipschitzWith.id.const_min 1).const_max (-1) + +noncomputable def finiteOddExtension {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) (T : X → X) (x : X) : ℝ := + (clipUnit (finiteMcShane e f L x) - clipUnit (finiteMcShane e f L (T x))) / 2 + +lemma finiteOddExtension_bounds {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) (T : X → X) (x : X) : + -1 ≤ finiteOddExtension e f L T x ∧ finiteOddExtension e f L T x ≤ 1 := by + have hx := clipUnit_bounds (finiteMcShane e f L x) + have htx := clipUnit_bounds (finiteMcShane e f L (T x)) + unfold finiteOddExtension + constructor <;> linarith + +lemma finiteOddExtension_odd {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) (T : X → X) + (hT : Function.Involutive T) (x : X) : + finiteOddExtension e f L T (T x) = -finiteOddExtension e f L T x := by + simp only [finiteOddExtension, hT x] + ring + +lemma finiteOddExtension_on_grid {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) (T : X → X) (Tg : G → G) + (hT : ∀ x, T (e x) = e (Tg x)) + (hf : ∀ x y, |f x - f y| ≤ L * dist (e x) (e y)) + (hb : ∀ x, -1 ≤ f x ∧ f x ≤ 1) (ho : ∀ x, f (Tg x) = -f x) (x : G) : + finiteOddExtension e f L T (e x) = f x := by + simp only [finiteOddExtension, hT x, finiteMcShane_on_grid e f L hf, + clipUnit_eq (hb x), clipUnit_eq (hb (Tg x))] + rw [ho x] + ring + +lemma finiteOddExtension_lipschitz {G X : Type*} [Fintype G] [Nonempty G] + [PseudoMetricSpace X] (e : G → X) (f : G → ℝ) (L : ℝ≥0) (T : X → X) + (hT : Isometry T) : LipschitzWith L (finiteOddExtension e f L T) := by + have hg : LipschitzWith L (fun x => clipUnit (finiteMcShane e f L x)) := by + simpa only [one_mul, Function.comp_def] using clipUnit_lipschitz.comp (finiteMcShane_lipschitz e f L) + apply LipschitzWith.of_dist_le_mul + intro x y + have h₁ := hg.dist_le_mul x y + have h₂ := hg.dist_le_mul (T x) (T y) + rw [hT.dist_eq] at h₂ + simp only [Real.dist_eq] at h₁ h₂ ⊢ + unfold finiteOddExtension + rw [abs_le] at h₁ h₂ ⊢ + constructor <;> linarith + +noncomputable def torusAntipode {ι : Type*} (x : ι → UnitAddCircle) : ι → UnitAddCircle := + fun k => x k + ((1 / 2 : ℝ) : UnitAddCircle) + +lemma torusAntipode_involutive {ι : Type*} : + Function.Involutive (torusAntipode : (ι → UnitAddCircle) → (ι → UnitAddCircle)) := by + intro x + funext k + simp only [torusAntipode, add_assoc, ← AddCircle.coe_add] + norm_num + +lemma torusAntipode_isometry {ι : Type*} [Fintype ι] : + Isometry (torusAntipode : (ι → UnitAddCircle) → (ι → UnitAddCircle)) := by + intro x y + simp only [edist_pi_def, torusAntipode, edist_add_right] + +noncomputable def torusGrid {ι : Type*} {D : ℕ} [NeZero D] + (x : ι → ZMod D) : ι → UnitAddCircle := fun k => ZMod.toAddCircle (x k) + +lemma torusGrid_antipode {ι : Type*} {D : ℕ} [NeZero D] (hD : Even D) + (x : ι → ZMod D) : + torusAntipode (torusGrid x) = torusGrid (fun k => x k + ((D / 2 : ℕ) : ZMod D)) := by + funext k + simp only [torusAntipode, torusGrid, map_add, ZMod.toAddCircle_natCast, + grid_half_real D hD] + +noncomputable def tupleExtension {Q : Type*} {M : Q → Type*} [∀ q, Fintype (M q)] + (S : ProjectionSystem Q M) {D : ℕ} [NeZero D] + (A : Set (GridLocation M D)) (q : Q) (x : M q → UnitAddCircle) : ℝ := by + classical + exact finiteOddExtension torusGrid (fun u => gridBump S A ⟨q, u⟩) 64 torusAntipode x + +lemma tupleExtension_bounds {Q : Type*} {M : Q → Type*} [∀ q, Fintype (M q)] + (S : ProjectionSystem Q M) {D : ℕ} [NeZero D] + (A : Set (GridLocation M D)) (q : Q) (x : M q → UnitAddCircle) : + -1 ≤ tupleExtension S A q x ∧ tupleExtension S A q x ≤ 1 := by + classical + exact finiteOddExtension_bounds _ _ _ _ _ + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Lookup.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Lookup.lean new file mode 100644 index 0000000000000000000000000000000000000000..d28be3e5bf4e97e41e5dd3c14e1699d9e2a6b8ba --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Lookup.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineLookupCore + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Lookup + +open Turing +open IndependentSetsGames.Foundations.Complexity +open MachineComposition GenericGraphTables + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +def skipBits (source : K) : Nat → + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) → + TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | 0, next => .load (fun state => (state.1, none)) next + | count + 1, next => + let rest := skipBits source count next + .pop source (fun state head => (state.1, head)) + (.branch (fun state => state.2.getD false) + (.pop source (fun state _ => (state.1, none)) rest) + (.load (fun state => (state.1, none)) rest)) + +theorem stepAux_skipBits (source : K) (bits : List Bool) + (next : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) (register : Option Bool) : + TM2.stepAux (skipBits source bits.length next) (ambient, register) + (Function.update base source (encodeWords (bits.map bitWord) ++ suffix)) = + TM2.stepAux next (ambient, none) (Function.update base source suffix) := by + induction bits generalizing register with + | nil => simp [skipBits, encodeWords, TM2.stepAux] + | cons bit bits ih => + cases bit <;> + simpa only [List.length_cons, skipBits, List.map_cons, bitWord, Bool.false_eq_true, + ite_false, ite_true, encodeWords, encodeWord, List.replicate_zero, + List.replicate_succ, List.nil_append, List.cons_append, List.singleton_append, + TM2.stepAux, Function.update_self, List.head?_cons, List.tail_cons, + Option.getD_some, Bool.cond_false, Bool.cond_true, Function.update_idem] using + ih none + +theorem stepAux_skipBits_fromTapes (source : K) (bits : List Bool) + (next : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (base : K → List Bool) (suffix : List Bool) + (hinput : base source = encodeWords (bits.map bitWord) ++ suffix) + (ambient : σ) (register : Option Bool) : + TM2.stepAux (skipBits source bits.length next) (ambient, register) base = + TM2.stepAux next (ambient, none) (Function.update base source suffix) := by + have h := stepAux_skipBits source bits next base suffix ambient register + have hbase : Function.update base source (encodeWords (bits.map bitWord) ++ suffix) = + base := by rw [← hinput]; exact Function.update_eq_self source base + rw [hbase] at h + exact h + +omit [DecidableEq K] in +theorem skipBits_pushBound (source : K) (count : Nat) + (next : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) : + Runtime.statementPushBound (skipBits source count next) = + Runtime.statementPushBound next := by + induction count with + | zero => rfl + | succ count ih => simp only [skipBits, Runtime.statementPushBound, ih, max_self] + +inductive Label + | guard | skipTail | skipReverse | skipPredicate | select | copy + deriving DecidableEq + +instance : Fintype Label where + elems := {.guard, .skipTail, .skipReverse, .skipPredicate, .select, .copy} + complete label := by cases label <;> simp + +def statement (q : Nat) (counter source destination : K) (labels : Label → Λ) + (exit : Option Λ) : Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .guard => MachineUnaryCounter.guard counter (labels .skipTail) (labels .select) + | .skipTail => MachineLookup.discard source (labels .skipTail) (labels .skipReverse) + | .skipReverse => MachineLookup.discard source (labels .skipReverse) (labels .skipPredicate) + | .skipPredicate => skipBits source (q * q) (.goto fun _ => labels .guard) + | .select => Hastad.SourceMachine.fieldStart destination (labels .copy) + | .copy => Hastad.SourceMachine.fieldLoop source destination (labels .copy) exit + +def program (q : Nat) (counter source destination : K) : + Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) := + statement q counter source destination id none + +def rowBits {q n m : Nat} (row : DartRow q n m) : List Bool := encodeWords (rowWords row) + +theorem rowBits_eq {q n m : Nat} (row : DartRow q n m) : + rowBits row = encodeWord row.tail.val ++ + (encodeWord row.reverseIndex.val ++ encodeWords (relationWords row.relation)) := by + simp [rowBits, rowWords, encodeWords] + +def rowsBits {q n m : Nat} (rows : List (DartRow q n m)) : List Bool := + encodeWords (rows.flatMap rowWords) + +@[simp] theorem rowsBits_nil {q n m : Nat} : rowsBits ([] : List (DartRow q n m)) = [] := rfl + +@[simp] theorem rowsBits_cons {q n m : Nat} (row : DartRow q n m) + (rows : List (DartRow q n m)) : rowsBits (row :: rows) = rowBits row ++ rowsBits rows := by + simp only [rowsBits, List.flatMap_cons, encodeWords_append, rowBits] + +def skipCost {q n m : Nat} (row : DartRow q n m) : Nat := + row.tail.val + row.reverseIndex.val + 4 + +def prefixCost {q n m : Nat} (rows : List (DartRow q n m)) : Nat := + (rows.map skipCost).sum + +def lookupCost {q n m : Nat} (prior : List (DartRow q n m)) (row : DartRow q n m) : Nat := + prefixCost prior + row.tail.val + 3 + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Lookup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/LoopInitialization.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/LoopInitialization.lean new file mode 100644 index 0000000000000000000000000000000000000000..b830c3787b6f472f4e5fa535432cc517241528b8 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/LoopInitialization.lean @@ -0,0 +1,148 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Body +import OAI.Combinatorics.IndependentSets.Machines.Initialization + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.LoopInitialization + +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel LoopState + +theorem initialization_ready {q : Nat} (input : GenericGraphTables.Table q) : + Ready input 0 (Initialization.loopTapes input) where + le_darts := Nat.zero_le _ + original := rfl + cursor := by + change Initialization.rowsBits input = cursorBits input 0 + rw [cursorBits_zero] + rfl + vertices := rfl + darts := rfl + counter := by simp [Initialization.loopTapes] + edge := rfl + tail := rfl + reverseIndex := rfl + head := rfl + scratch := rfl + compareLeft := rfl + compareRight := rfl + output := rfl + reversed := by + change (Initialization.headerBits input).reverse = (prefixBits input 0).reverse + rw [prefixBits_zero] + rfl + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.LoopInitialization +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Loop + +open Turing +open IndependentSetsGames.Foundations.Complexity +open RuntimeModel + +variable {q : Nat} + +def zeroGuardInTime (input : GenericGraphTables.Table q) (base : Tape → List Bool) + (ready : LoopState.Ready input input.darts base) + (relation : GenericGraphTables.RelationTable q) (flag : Bool) : + StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some .guard, normal relation flag, base⟩ + (some ⟨some .reverseOutput, normal relation flag, base⟩) 1 := by + have counterSelf : MachineUnaryCounter.counterTapes Tape.counter base 0 [] = base := by + simp only [MachineUnaryCounter.counterTapes, List.append_nil, + ← ready.counter_at_end, Function.update_eq_self] + have run := MachineUnaryCounter.guardInTime_zero Tape.counter + (Driver.Label.guard : Driver.Label q) .tailStart .reverseOutput + (Driver.program q) (Driver.program_guard q) base [] (normal relation flag).1 none + simpa only [counterSelf, normal] using run + +structure LoopResult (input : GenericGraphTables.Table q) (e remaining : Nat) + (base : Tape → List Bool) (oldRelation : GenericGraphTables.RelationTable q) + (oldFlag : Bool) where + tapes : Tape → List Bool + relation : GenericGraphTables.RelationTable q + flag : Bool + ready : LoopState.Ready input input.darts tapes + run : StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + ⟨some .guard, normal oldRelation oldFlag, base⟩ + (some ⟨some .reverseOutput, normal relation flag, tapes⟩) + (remaining * Body.bodyTime q (LoopState.inputBits input).length + 1) + +def runRemaining (input : GenericGraphTables.Table q) : + (remaining e : Nat) → e + remaining = input.darts → + (base : Tape → List Bool) → LoopState.Ready input e base → + (oldRelation : GenericGraphTables.RelationTable q) → (oldFlag : Bool) → + LoopResult input e remaining base oldRelation oldFlag + | 0, e, finished, base, ready, oldRelation, oldFlag => by + have atEnd : e = input.darts := by omega + subst e + exact { + tapes := base + relation := oldRelation + flag := oldFlag + ready := ready + run := by + simpa only [Nat.zero_mul, Nat.zero_add] using + zeroGuardInTime input base ready oldRelation oldFlag } + | remaining + 1, e, finished, base, ready, oldRelation, oldFlag => by + have beforeEnd : e < input.darts := by omega + let edge : Fin input.darts := ⟨e, beforeEnd⟩ + let one := Body.rowStep input edge base ready oldRelation oldFlag + let rest := runRemaining input remaining (e + 1) (by omega) one.tapes one.ready + input.rows[edge].relation (CompareLoop.rowLoop input edge) + let composed := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ one.run rest.run + refine { + tapes := rest.tapes + relation := rest.relation + flag := rest.flag + ready := rest.ready + run := { toEvalsTo := composed.toEvalsTo, steps_le_m := ?_ } } + have budget := composed.steps_le_m + simpa only [Nat.succ_mul, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using budget + +def prefixTime (q N : Nat) : Nat := + Initialization.time N + N * Body.bodyTime q N + 1 + +structure PrefixResult (input : GenericGraphTables.Table q) where + tapes : Tape → List Bool + relation : GenericGraphTables.RelationTable q + flag : Bool + ready : LoopState.Ready input input.darts tapes + run : StateTransition.EvalsToInTime (TM2.step (Driver.program q)) + (initList (Driver.machine q) (GenericGraphTables.tableBits input)) + (some ⟨some .reverseOutput, normal relation flag, tapes⟩) + (prefixTime q (LoopState.inputBits input).length) + +def runPrefix (input : GenericGraphTables.Table q) : PrefixResult input := by + let rows := runRemaining input input.darts 0 (by simp) + (Initialization.loopTapes input) (LoopInitialization.initialization_ready input) + (Vector.replicate (q * q) false) false + let composed := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ + (Initialization.initializeInTime input) rows.run + refine { + tapes := rows.tapes + relation := rows.relation + flag := rows.flag + ready := rows.ready + run := { toEvalsTo := composed.toEvalsTo, steps_le_m := ?_ } } + have budget := composed.steps_le_m + change composed.steps ≤ + input.darts * Body.bodyTime q (LoopState.inputBits input).length + 1 + + Initialization.time (LoopState.inputBits input).length at budget + have rowCount : input.darts ≤ (LoopState.inputBits input).length := + GenericGraphTables.darts_le_tableBits_length input + have rowBudget := Nat.mul_le_mul_right (Body.bodyTime q (LoopState.inputBits input).length) + rowCount + unfold prefixTime + omega + +theorem PrefixResult.reversed {input : GenericGraphTables.Table q} (result : PrefixResult input) : + result.tapes .reversed = (GraphTables.tableBits (Table.build input)).reverse := + result.ready.reversed_at_end + +theorem PrefixResult.output {input : GenericGraphTables.Table q} (result : PrefixResult input) : + result.tapes .output = [] := result.ready.output + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Loop + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Minimum.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Minimum.lean new file mode 100644 index 0000000000000000000000000000000000000000..f299f6cc23bb196f8ac38145f8add028d64f3808 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Minimum.lean @@ -0,0 +1,217 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ConstraintGraph + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.ConstraintGraph + +variable {V E A : Type*} + +section Minimum + +variable [Fintype V] [Fintype E] [Fintype A] [Nonempty A] + +def rejectionCounts (G : ConstraintGraph V E A) : Finset Nat := by + classical + exact Finset.univ.image G.rejectionCount + +theorem rejectionCounts_nonempty (G : ConstraintGraph V E A) : + G.rejectionCounts.Nonempty := by + classical + exact Finset.univ_nonempty.image G.rejectionCount + +def minimumRejections (G : ConstraintGraph V E A) : Nat := + G.rejectionCounts.min' G.rejectionCounts_nonempty + +theorem minimumRejections_le (G : ConstraintGraph V E A) (labeling : V → A) : + G.minimumRejections ≤ G.rejectionCount labeling := by + classical + exact Finset.min'_le _ _ (Finset.mem_image.mpr ⟨labeling, Finset.mem_univ _, rfl⟩) + +theorem exists_minimizer (G : ConstraintGraph V E A) : + ∃ labeling : V → A, G.rejectionCount labeling = G.minimumRejections := by + classical + have h := Finset.min'_mem G.rejectionCounts G.rejectionCounts_nonempty + obtain ⟨labeling, _, heq⟩ := Finset.mem_image.mp h + exact ⟨labeling, heq⟩ + +theorem le_minimumRejections_iff (G : ConstraintGraph V E A) (bound : Nat) : + bound ≤ G.minimumRejections ↔ ∀ labeling : V → A, bound ≤ G.rejectionCount labeling := by + constructor + · intro h labeling + exact h.trans (G.minimumRejections_le labeling) + · intro h + obtain ⟨labeling, heq⟩ := G.exists_minimizer + rw [← heq] + exact h labeling + +theorem minimumRejections_le_card (G : ConstraintGraph V E A) : + G.minimumRejections ≤ Fintype.card E := by + obtain ⟨labeling, heq⟩ := G.exists_minimizer + rw [← heq] + exact G.rejectionCount_le labeling + +omit [Fintype V] [Fintype A] [Nonempty A] in +theorem rejectionCount_eq_zero_iff (G : ConstraintGraph V E A) (labeling : V → A) : + G.rejectionCount labeling = 0 ↔ ∀ e, G.edgeSatisfied labeling e = true := by + classical + constructor + · intro h e + have hempty : G.rejectedDarts labeling = ∅ := Finset.card_eq_zero.mp h + cases he : G.edgeSatisfied labeling e with + | false => + have hm := (G.mem_rejectedDarts labeling e).mpr he + rw [hempty] at hm + simp at hm + | true => rfl + · intro h + simp [rejectionCount, rejectedDarts, h] + +theorem minimumRejections_eq_zero_iff (G : ConstraintGraph V E A) : + G.minimumRejections = 0 ↔ G.Satisfiable := by + constructor + · intro h + obtain ⟨labeling, heq⟩ := G.exists_minimizer + exact ⟨labeling, (G.rejectionCount_eq_zero_iff labeling).mp (heq.trans h)⟩ + · rintro ⟨labeling, h⟩ + have hc := (G.rejectionCount_eq_zero_iff labeling).mpr h + exact Nat.eq_zero_of_le_zero (hc ▸ G.minimumRejections_le labeling) + +def gap (G : ConstraintGraph V E A) : ℝ := + (G.minimumRejections : ℝ) / Fintype.card E + +theorem gap_nonnegative (G : ConstraintGraph V E A) : 0 ≤ G.gap := + div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + +theorem gap_le_one [Nonempty E] (G : ConstraintGraph V E A) : G.gap ≤ 1 := by + have he : (0 : ℝ) < Fintype.card E := by exact_mod_cast Fintype.card_pos + apply (div_le_iff₀ he).mpr + simpa only [one_mul] using (Nat.cast_le.mpr G.minimumRejections_le_card : + (G.minimumRejections : ℝ) ≤ (Fintype.card E : ℝ)) + +theorem gap_eq_zero_iff [Nonempty E] (G : ConstraintGraph V E A) : + G.gap = 0 ↔ G.Satisfiable := by + have he : (Fintype.card E : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + simp only [gap, div_eq_zero_iff, he, or_false, Nat.cast_eq_zero] + exact G.minimumRejections_eq_zero_iff + +theorem le_gap_iff [Nonempty E] (G : ConstraintGraph V E A) (ε : ℝ) : + ε ≤ G.gap ↔ ∀ labeling : V → A, + ε * Fintype.card E ≤ (G.rejectionCount labeling : ℝ) := by + have he : (0 : ℝ) < Fintype.card E := by exact_mod_cast Fintype.card_pos + change ε ≤ (G.minimumRejections : ℝ) / Fintype.card E ↔ _ + rw [le_div_iff₀ he] + constructor + · intro h labeling + exact h.trans (Nat.cast_le.mpr (G.minimumRejections_le labeling)) + · intro h + obtain ⟨labeling, heq⟩ := G.exists_minimizer + simpa only [heq] using h labeling + +theorem inverse_card_le_gap_of_unsatisfiable [Nonempty E] + (G : ConstraintGraph V E A) (unsat : ¬ G.Satisfiable) : + 1 / (Fintype.card E : ℝ) ≤ G.gap := by + apply (G.le_gap_iff _).mpr + intro labeling + have he : (Fintype.card E : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + have hc : (1 : ℝ) ≤ (G.rejectionCount labeling : ℝ) := by + exact_mod_cast G.rejectionCount_positive unsat labeling + simpa only [div_mul_cancel₀ _ he] using hc + +end Minimum + +variable {W D B : Type*} + +def reindex (G : ConstraintGraph V E A) (vertices : V ≃ W) (darts : E ≃ D) + (labels : A ≃ B) : ConstraintGraph W D B where + reverse := darts.symm.trans (G.reverse.trans darts) + reverse_involutive := by + intro d + change darts (G.reverse (darts.symm (darts (G.reverse (darts.symm d))))) = d + rw [darts.symm_apply_apply, G.reverse_involutive, darts.apply_symm_apply] + tail := fun d => vertices (G.tail (darts.symm d)) + accepts := fun d a b => G.accepts (darts.symm d) (labels.symm a) (labels.symm b) + reverse_accepts := by + intro d a b + simpa only [Equiv.trans_apply, darts.symm_apply_apply] using + G.reverse_accepts (darts.symm d) (labels.symm a) (labels.symm b) + +def labelingEquiv (vertices : V ≃ W) (labels : A ≃ B) : (V → A) ≃ (W → B) where + toFun := fun labeling w => labels (labeling (vertices.symm w)) + invFun := fun labeling v => labels.symm (labeling (vertices v)) + left_inv := by intro labeling; funext v; simp + right_inv := by intro labeling; funext w; simp + +theorem reindex_edgeSatisfied (G : ConstraintGraph V E A) + (vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) + (labeling : V → A) (e : E) : + (G.reindex vertices darts labels).edgeSatisfied (labelingEquiv vertices labels labeling) + (darts e) = G.edgeSatisfied labeling e := by + simp [reindex, labelingEquiv, edgeSatisfied, head, Equiv.trans_apply] + +theorem reindex_rejectionCount [Fintype E] [Fintype D] (G : ConstraintGraph V E A) + (vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) (labeling : V → A) : + (G.reindex vertices darts labels).rejectionCount (labelingEquiv vertices labels labeling) = + G.rejectionCount labeling := by + classical + unfold rejectionCount + symm + apply Finset.card_bij (fun e _ => darts e) + · intro e he + rw [mem_rejectedDarts, reindex_edgeSatisfied] + exact (G.mem_rejectedDarts labeling e).mp he + · intro e _ f _ h + exact darts.injective h + · intro d hd + refine ⟨darts.symm d, ?_, darts.apply_symm_apply d⟩ + rw [mem_rejectedDarts] + rw [← reindex_edgeSatisfied G vertices darts labels labeling (darts.symm d)] + rw [darts.apply_symm_apply] + exact (mem_rejectedDarts _ _ _).mp hd + +variable [Fintype V] [Fintype E] [Fintype A] [Nonempty A] + [Fintype W] [Fintype D] [Fintype B] [Nonempty B] + +omit [Nonempty A] [Nonempty B] in +theorem rejectionCounts_reindex (G : ConstraintGraph V E A) + (vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) : + (G.reindex vertices darts labels).rejectionCounts = G.rejectionCounts := by + classical + ext n + simp only [rejectionCounts, Finset.mem_image, Finset.mem_univ, true_and] + constructor + · rintro ⟨labeling, hn⟩ + refine ⟨(labelingEquiv vertices labels).symm labeling, ?_⟩ + rw [← reindex_rejectionCount G vertices darts labels, + Equiv.apply_symm_apply] + exact hn + · rintro ⟨labeling, hn⟩ + refine ⟨labelingEquiv vertices labels labeling, ?_⟩ + rw [reindex_rejectionCount] + exact hn + +theorem minimumRejections_reindex (G : ConstraintGraph V E A) + (vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) : + (G.reindex vertices darts labels).minimumRejections = G.minimumRejections := by + unfold minimumRejections + simp only [rejectionCounts_reindex] + +theorem gap_reindex (G : ConstraintGraph V E A) + (vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) : + (G.reindex vertices darts labels).gap = G.gap := by + unfold gap + rw [minimumRejections_reindex, Fintype.card_congr darts] + +theorem satisfiable_reindex (G : ConstraintGraph V E A) + (vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) : + (G.reindex vertices darts labels).Satisfiable ↔ G.Satisfiable := by + rw [← minimumRejections_eq_zero_iff, minimumRejections_reindex, + minimumRejections_eq_zero_iff] + +end IndependentSetsGames.Foundations.PCP.ConstraintGraph + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/NameCompaction.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/NameCompaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed037b09894e71b2b8ac4ce1d2fbbe61754610a0 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/NameCompaction.lean @@ -0,0 +1,245 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ClauseVerifier + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.NameCompaction + +open IndependentSetsGames.Foundations.Target + +def clauseNames {n : Nat} (c : Clause n) : List (Fin n) := + [(c)[0].variableIndex, (c)[1].variableIndex, (c)[2].variableIndex] + +def sourceNames (F : Formula) : List (Fin F.«variables») := + F.clauses.flatMap clauseNames + +def activeNames (F : Formula) : List (Fin F.«variables») := + (sourceNames F).eraseDups + +theorem literal_mem_active (F : Formula) (c : Clause F.«variables») + (hc : c ∈ F.clauses) (i : Fin 3) : + (c)[i].variableIndex ∈ activeNames F := by + simp only [activeNames, List.mem_eraseDups] + apply List.mem_flatMap.mpr + refine ⟨c, hc, ?_⟩ + have hi : i = 0 ∨ i = 1 ∨ i = 2 := by omega + rcases hi with rfl | rfl | rfl <;> simp [clauseNames] + +def compactIndex (F : Formula) (v : Fin F.«variables») + (hv : v ∈ activeNames F) : Fin (activeNames F).length := + ⟨(activeNames F).idxOf v, List.idxOf_lt_length_iff.mpr hv⟩ + +def decodeName (F : Formula) (v : Fin (activeNames F).length) : Fin F.«variables» := + (activeNames F)[v.val] + +def compactLiteral (F : Formula) (l : Literal F.«variables») + (hl : l.variableIndex ∈ activeNames F) : Literal (activeNames F).length := + ⟨compactIndex F l.variableIndex hl, l.positive⟩ + +def compactClause (F : Formula) (c : Clause F.«variables») + (hc : c ∈ F.clauses) : Clause (activeNames F).length := + #v[compactLiteral F (c)[0] (literal_mem_active F c hc 0), + compactLiteral F (c)[1] (literal_mem_active F c hc 1), + compactLiteral F (c)[2] (literal_mem_active F c hc 2)] + +def compactClauses (F : Formula) : List (Clause (activeNames F).length) := + F.clauses.attach.map (fun c => compactClause F c.val c.property) + +def compact (F : Formula) : Formula where + «variables» := (activeNames F).length + clauses := compactClauses F + +def restrictAssignment (F : Formula) (A : Fin F.«variables» → Bool) : + Fin (activeNames F).length → Bool := fun v => A (decodeName F v) + +def extendAssignment (F : Formula) (B : Fin (activeNames F).length → Bool) + (v : Fin F.«variables») : Bool := + if hv : v ∈ activeNames F then B (compactIndex F v hv) else false + +@[simp] theorem decode_compactIndex (F : Formula) (v : Fin F.«variables») + (hv : v ∈ activeNames F) : decodeName F (compactIndex F v hv) = v := by + exact List.getElem_idxOf (List.idxOf_lt_length_iff.mpr hv) + +@[simp] theorem eval_compact_restrict (F : Formula) (c : Clause F.«variables») + (hc : c ∈ F.clauses) (A : Fin F.«variables» → Bool) : + (compactClause F c hc).eval (restrictAssignment F A) = c.eval A := by + simp [compactClause, compactLiteral, Clause.eval, Literal.eval, + restrictAssignment, decode_compactIndex] + +@[simp] theorem eval_compact_extend (F : Formula) (c : Clause F.«variables») + (hc : c ∈ F.clauses) (B : Fin (activeNames F).length → Bool) : + (compactClause F c hc).eval B = c.eval (extendAssignment F B) := by + have h₀ : (c)[0].variableIndex ∈ activeNames F := literal_mem_active F c hc 0 + have h₁ : (c)[1].variableIndex ∈ activeNames F := literal_mem_active F c hc 1 + have h₂ : (c)[2].variableIndex ∈ activeNames F := literal_mem_active F c hc 2 + simp [compactClause, compactLiteral, Clause.eval, Literal.eval, extendAssignment, + h₀, h₁, h₂] + rfl + +theorem map_attach_val {α β : Type} (xs : List α) (f : α → β) : + xs.attach.map (fun x => f x.val) = xs.map f := by + exact List.attach_map_val + +def evaluationList (F : Formula) (A : Fin F.«variables» → Bool) : List Bool := + F.clauses.map (fun c => c.eval A) + +def satisfiedCount (F : Formula) (A : Fin F.«variables» → Bool) : Nat := + (evaluationList F A).count true + +def failedCount (F : Formula) (A : Fin F.«variables» → Bool) : Nat := + (evaluationList F A).count false + +theorem evaluationList_restrict (F : Formula) (A : Fin F.«variables» → Bool) : + evaluationList (compact F) (restrictAssignment F A) = evaluationList F A := by + simp only [evaluationList, compact, compactClauses, List.map_map] + simpa only [Function.comp_def, eval_compact_restrict] using + map_attach_val F.clauses (fun c => c.eval A) + +theorem evaluationList_extend (F : Formula) (B : Fin (compact F).«variables» → Bool) : + evaluationList (compact F) B = evaluationList F (extendAssignment F B) := by + simp only [evaluationList, compact, compactClauses, List.map_map] + change F.clauses.attach.map (fun c => (compactClause F c.val c.property).eval B) = _ + calc + _ = F.clauses.attach.map (fun c => c.val.eval (extendAssignment F B)) := by + apply List.map_congr_left + intro c _ + exact eval_compact_extend F c.val c.property B + _ = _ := map_attach_val F.clauses (fun c => c.eval (extendAssignment F B)) + +theorem satisfiedCount_restrict (F : Formula) (A : Fin F.«variables» → Bool) : + satisfiedCount (compact F) (restrictAssignment F A) = satisfiedCount F A := by + simp only [satisfiedCount, evaluationList_restrict] + +theorem failedCount_restrict (F : Formula) (A : Fin F.«variables» → Bool) : + failedCount (compact F) (restrictAssignment F A) = failedCount F A := by + simp only [failedCount, evaluationList_restrict] + +theorem satisfiedCount_extend (F : Formula) (B : Fin (compact F).«variables» → Bool) : + satisfiedCount (compact F) B = satisfiedCount F (extendAssignment F B) := by + simp only [satisfiedCount, evaluationList_extend] + +theorem failedCount_extend (F : Formula) (B : Fin (compact F).«variables» → Bool) : + failedCount (compact F) B = failedCount F (extendAssignment F B) := by + simp only [failedCount, evaluationList_extend] + +theorem clauseNames_flat_length {n : Nat} (cs : List (Clause n)) : + (cs.flatMap clauseNames).length = 3 * cs.length := by + induction cs with + | nil => simp + | cons c cs ih => + simp only [List.flatMap_cons, List.length_append, clauseNames, + List.length_cons, List.length_nil, ih] + omega + +@[simp] theorem compact_clause_count (F : Formula) : + (compact F).clauses.length = F.clauses.length := by + simp [compact, compactClauses] + +theorem length_eraseDups_le {α : Type} [BEq α] (xs : List α) : + xs.eraseDups.length ≤ xs.length := by + match xs with + | [] => simp + | a :: rest => + rw [List.eraseDups_cons] + have filtered := List.length_filter_le (fun b => !(b == a)) rest + have ih := length_eraseDups_le (rest.filter (fun b => !(b == a))) + simp only [List.length_cons] + omega +termination_by xs.length +decreasing_by + exact Nat.lt_succ_of_le (List.length_filter_le _ _) + +theorem compact_active_bound (F : Formula) : + (compact F).«variables» ≤ 3 * F.clauses.length := by + have h := length_eraseDups_le (sourceNames F) + simpa only [sourceNames, clauseNames_flat_length, compact, activeNames] using h + +theorem compact_completeness (F : Formula) (hs : F.Satisfiable) : + (compact F).Satisfiable := by + rcases hs with ⟨A, hA⟩ + refine ⟨restrictAssignment F A, ?_⟩ + intro d hd + change d ∈ F.clauses.attach.map (fun c => compactClause F c.val c.property) at hd + rcases List.mem_map.mp hd with ⟨c, _, rfl⟩ + exact (eval_compact_restrict F c.val c.property A).trans (hA c.val c.property) + +theorem compact_reflects (F : Formula) (hs : (compact F).Satisfiable) : + F.Satisfiable := by + rcases hs with ⟨B, hB⟩ + refine ⟨extendAssignment F B, ?_⟩ + intro c hc + have hm : compactClause F c hc ∈ (compact F).clauses := by + change _ ∈ F.clauses.attach.map (fun d => compactClause F d.val d.property) + exact List.mem_map.mpr ⟨⟨c, hc⟩, by simp, rfl⟩ + rw [← eval_compact_extend F c hc B] + exact hB _ hm + +theorem compact_satisfiable_iff (F : Formula) : + (compact F).Satisfiable ↔ F.Satisfiable := + ⟨compact_reflects F, compact_completeness F⟩ + +theorem compact_preserves_gap (F : Formula) (a b : Nat) + (gap : ∀ A, a * F.clauses.length ≤ b * failedCount F A) + (B : Fin (compact F).«variables» → Bool) : + a * (compact F).clauses.length ≤ b * failedCount (compact F) B := by + rw [compact_clause_count, failedCount_extend] + exact gap (extendAssignment F B) + +theorem compact_encoding_bound (F : Formula) : + (Complexity.formulaBits (compact F)).length ≤ + 9 * F.clauses.length * F.clauses.length + 10 * F.clauses.length + 2 := by + have enc := Complexity.formulaBits_length_le (compact F) + rw [compact_clause_count] at enc + have active := compact_active_bound F + have h₁ := Nat.add_le_add_right active (F.clauses.length + 2) + have h₂ := Nat.mul_le_mul_left F.clauses.length + (Nat.mul_le_mul_left 3 (Nat.add_le_add_right active 2)) + have total := Nat.add_le_add h₁ h₂ + have polynomial : 3 * F.clauses.length + (F.clauses.length + 2) + + F.clauses.length * (3 * (3 * F.clauses.length + 2)) = + 9 * F.clauses.length * F.clauses.length + 10 * F.clauses.length + 2 := by + simp [Nat.mul_add, Nat.mul_comm, Nat.mul_left_comm] + omega + rw [polynomial] at total + omega + +theorem failureCount_evaluations (F : Formula) (A : Fin F.«variables» → Bool) + (indices : List (Fin F.clauses.length)) : + failureCount F A indices = + (indices.map (fun i => (clauseAt F i).eval A)).count false := by + induction indices with + | nil => simp [failureCount] + | cons i rest ih => + cases h : (clauseAt F i).eval A <;> + simp [failureCount, clauseFailure, h, ih, Nat.add_comm] + +theorem evaluations_allIndices (F : Formula) (A : Fin F.«variables» → Bool) : + ((allIndices F).map (fun i => (clauseAt F i).eval A)) = evaluationList F A := by + calc + _ = (List.ofFn (fun i : Fin F.clauses.length => F.clauses[i.val])).map + (fun c => c.eval A) := by + simp only [allIndices, List.finRange, clauseAt, List.map_ofFn, Function.comp_def] + _ = _ := by rw [List.ofFn_getElem]; rfl + +theorem verifier_failureCount (F : Formula) (A : Fin F.«variables» → Bool) : + failureCount F A (allIndices F) = failedCount F A := by + rw [failureCount_evaluations, evaluations_allIndices] + rfl + +theorem compact_verifier_soundness (F : Formula) (a b : Nat) + (gap : ∀ A, a * F.clauses.length ≤ b * failedCount F A) + (alice : AliceStrategy (compact F)) (bob : BobStrategy (compact F)) : + b * ((allEvents (compact F)).filter (accepts (compact F) alice bob)).length + + a * F.clauses.length ≤ b * (3 * F.clauses.length) := by + have sourceGap : ∀ A : BobStrategy (compact F), + a * (compact F).clauses.length ≤ + b * failureCount (compact F) A (allIndices (compact F)) := by + intro A + rw [verifier_failureCount] + exact compact_preserves_gap F a b gap A + have h := verifier_event_soundness (compact F) a b sourceGap alice bob + simpa only [length_allEvents, compact_clause_count] using h + +end IndependentSetsGames.Foundations.PCP.NameCompaction + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/PCPIteration.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/PCPIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..34db93cdca7f2baa5e5afb9c86385da82f3d0b7c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/PCPIteration.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.AmplificationIteration +import OAI.Combinatorics.IndependentSets.PCP.RoundGap + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.PCPIteration + +open FiniteGraph + +abbrev Label := AlphabetRetraction.Label64 +abbrev Graph := Bundle Label +abbrev Addresses := AmplificationRound.Addresses + +def step (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) (G : Graph) : Graph := by + classical + exact Bundle.ofGraph (AmplificationRound.graph addresses complete G.graph) + +def run (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) : Nat → Graph → Graph := + AmplificationIteration.run (step addresses complete) + +def initial (F : Target.Formula) : Graph := Bundle.ofGraph (AlphabetRetraction.initial64 F) + +def iterationCount (F : Target.Formula) : Nat := AmplificationIteration.rounds (initial F).size + +def output (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) : Graph := run addresses complete (iterationCount F) (initial F) + +def polynomialDegree : Nat := AmplificationIteration.rounds RoundSize.sizeFactor + +def finalClauseGap : ℚ := 1 / (40960 * (FinalConstants.walkLength : ℚ)) + +theorem finalClauseGap_positive : 0 < finalClauseGap := by + apply one_div_pos.mpr + exact mul_pos (by norm_num) (by exact_mod_cast FinalConstants.walkLength_positive) + +theorem sizeFactor_le_power : RoundSize.sizeFactor ≤ 2 ^ polynomialDegree := + (AmplificationIteration.rounds_large RoundSize.sizeFactor).le + +theorem initial_satisfiable_iff (F : Target.Formula) : + (initial F).Satisfiable ↔ F.Satisfiable := + AlphabetRetraction.initial64_satisfiable_iff F + +theorem initial_size_positive (F : Target.Formula) : 0 < (initial F).size := + (initial F).size_positive + +theorem initial_size_bound (F : Target.Formula) : + (initial F).size ≤ 10 * F.clauses.length + 2 := by + change Fintype.card (InitialGraph.CompactVertex F) + + Fintype.card (InitialGraph.CompactDart F) ≤ _ + rw [InitialGraph.build_dart_count] + have h := InitialGraph.build_vertex_bound F + omega + +theorem step_completeness (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (G : Graph) (satisfied : G.Satisfiable) : (step addresses complete G).Satisfiable := + AmplificationRound.completeness addresses complete G.graph satisfied + +theorem step_gap (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) (G : Graph) : + min (2 * G.gap) FinalConstants.cap ≤ (step addresses complete G).gap := + RoundGap.amplifies addresses complete G.graph + +theorem step_size (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) (G : Graph) : + (step addresses complete G).size ≤ RoundSize.sizeFactor * G.size := + RoundSize.output_total_le G.graph + +theorem run_completeness (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (n : Nat) (G : Graph) (satisfied : G.Satisfiable) : + (run addresses complete n G).Satisfiable := + AmplificationIteration.run_preserves (step addresses complete) Bundle.Satisfiable + (step_completeness addresses complete) n G satisfied + +theorem run_gap (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (n : Nat) (G : Graph) : + min (2 ^ n * G.gap) FinalConstants.cap ≤ (run addresses complete n G).gap := + AmplificationIteration.run_gap (step addresses complete) Bundle.gap + FinalConstants.cap FinalConstants.cap_positive.le (step_gap addresses complete) n G + +theorem run_size (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (n : Nat) (G : Graph) : + (run addresses complete n G).size ≤ RoundSize.sizeFactor ^ n * G.size := + AmplificationIteration.run_size (step addresses complete) Bundle.size RoundSize.sizeFactor + (step_size addresses complete) n G + +theorem output_completeness (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) (satisfied : F.Satisfiable) : + (output addresses complete F).Satisfiable := + run_completeness addresses complete (iterationCount F) (initial F) + ((initial_satisfiable_iff F).mpr satisfied) + +theorem output_gap (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) (unsat : ¬ F.Satisfiable) : + FinalConstants.cap ≤ (output addresses complete F).gap := by + have hinitial : ¬ (initial F).Satisfiable := + fun h => unsat ((initial_satisfiable_iff F).mp h) + exact AmplificationIteration.run_reaches_cap (step addresses complete) Bundle.gap + FinalConstants.cap FinalConstants.cap_positive.le FinalConstants.cap_le_one + (step_gap addresses complete) (initial F).size (initial F) + (initial F).gap_nonnegative ((initial F).one_le_size_mul_gap hinitial) + +theorem output_satisfiable_iff (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) : (output addresses complete F).Satisfiable ↔ F.Satisfiable := by + constructor + · intro satisfied + by_contra unsat + have hgap := output_gap addresses complete F unsat + rw [(output addresses complete F).gap_eq_zero_iff.mpr satisfied] at hgap + exact (not_le_of_gt FinalConstants.cap_positive) hgap + · exact output_completeness addresses complete F + +theorem output_size_polynomial (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) : + (output addresses complete F).size ≤ + (2 * (initial F).size) ^ polynomialDegree * (initial F).size := + AmplificationIteration.run_size_polynomial (step addresses complete) Bundle.size + (initial_size_positive F) sizeFactor_le_power (step_size addresses complete) (initial F) + +theorem output_size_clause_bound (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) : + (output addresses complete F).size ≤ + (2 * (10 * F.clauses.length + 2)) ^ polynomialDegree * (10 * F.clauses.length + 2) := by + have h := initial_size_bound F + exact (output_size_polynomial addresses complete F).trans + (Nat.mul_le_mul (Nat.pow_le_pow_left (Nat.mul_le_mul_left 2 h) _) h) + +theorem output_count_gap (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (F : Target.Formula) (unsat : ¬ F.Satisfiable) + (labeling : (output addresses complete F).Vertex → Label) : + Fintype.card (output addresses complete F).Dart ≤ + FinalConstants.walkLength * (output addresses complete F).rejectionCount labeling := by + have h := ((output addresses complete F).le_gap_iff FinalConstants.cap).mp + (output_gap addresses complete F unsat) labeling + have ht : (0 : ℝ) < FinalConstants.walkLength := by + exact_mod_cast FinalConstants.walkLength_positive + have h' : (Fintype.card (output addresses complete F).Dart : ℝ) / + FinalConstants.walkLength ≤ + ((output addresses complete F).rejectionCount labeling : ℝ) := by + simpa only [FinalConstants.cap, one_div_mul_eq_div] using h + have h'' := (div_le_iff₀ ht).mp h' + exact_mod_cast (show (Fintype.card (output addresses complete F).Dart : ℝ) ≤ + (FinalConstants.walkLength : ℝ) * + ((output addresses complete F).rejectionCount labeling : ℝ) by + simpa only [mul_comm] using h'') + +end IndependentSetsGames.Foundations.PCP.PCPIteration +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Queries.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Queries.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb5762251b2b9d583980542337350d6ed4e4e3fe --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Queries.lean @@ -0,0 +1,226 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GraphTables +import OAI.Combinatorics.IndependentSets.PCP.Enumeration + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Queries + +open IndependentSetsGames.Foundations.Hastad + +abbrev RawQuery (q : Nat) := + (Bool × Cube (Fin q)) ⊕ Cube (Fin q × Fin q) + +abbrev LocalEvent (q : Nat) := AlphabetGraph.LocalEvent (Fin q) + +def mask {q : Nat} (P : Fin q → Fin q → Bool) (f : Cube (Fin q × Fin q)) : + Cube (Fin q × Fin q) := fun p => if P p.1 p.2 then f p else false + +def xorTape {A : Type*} (f g : Cube A) : Cube A := fun a => f a ^^ g a + +def andTape {A : Type*} (f g : Cube A) : Cube A := fun a => f a && g a + +def inputPairTape {q : Nat} (k : Bool × Cube (Fin q)) : Cube (Fin q × Fin q) := + fun p => if k.1 then k.2 p.2 else k.2 p.1 + +def query {q : Nat} (P : Fin q → Fin q → Bool) (event : LocalEvent q) + (slot : Fin 6) : RawQuery q := + match event with + | (kind, k, f, g, r₀, r₁, r₂) => + if kind = 0 then + if slot = 0 then .inr (mask P f) else + if slot = 1 then .inr (mask P g) else .inr (mask P (xorTape f g)) + else if kind = 1 then + if slot = 0 then .inr (mask P r₀) else + if slot = 1 then .inr (mask P (xorTape r₀ (andTape f g))) else + if slot = 2 then .inr (mask P r₁) else + if slot = 3 then .inr (mask P (xorTape r₁ f)) else + if slot = 4 then .inr (mask P r₂) else .inr (mask P (xorTape r₂ g)) + else if kind = 2 then + if slot = 0 then .inr (mask P r₀) else + .inr (mask P (xorTape r₀ (fun _ => true))) + else + if slot = 0 then .inl k else + if slot = 1 then .inr (mask P r₀) else + .inr (mask P (xorTape r₀ (inputPairTape k))) + +def globalize {q : Nat} {V E : Type*} (tail head : V) (edge : E) : + RawQuery q → AlphabetGraph.Address V E (Fin q) + | .inl (side, tape) => .inl ((if side then head else tail), tape) + | .inr tape => .inr (edge, tape) + +@[simp] theorem mask_idempotent {q : Nat} (P : Fin q → Fin q → Bool) + (f : Cube (Fin q × Fin q)) : mask P (mask P f) = mask P f := by + funext p + cases hp : P p.1 p.2 <;> simp [mask, hp] + +theorem mask_of_empty {q : Nat} (P : Fin q → Fin q → Bool) + (empty : ∀ a b, P a b = false) (f : Cube (Fin q × Fin q)) : + mask P f = fun _ => false := by + funext p + simp [mask, empty] + +theorem query_is_masked {q : Nat} (P : Fin q → Fin q → Bool) + (event : LocalEvent q) (slot : Fin 6) : + match query P event slot with + | .inl _ => True + | .inr tape => mask P tape = tape := by + rcases event with ⟨kind, k, f, g, r₀, r₁, r₂⟩ + by_cases hk₀ : kind = 0 <;> by_cases hk₁ : kind = 1 <;> by_cases hk₂ : kind = 2 <;> + simp only [query, hk₀, hk₁, hk₂, ite_true, ite_false] <;> + split_ifs <;> simp + +def extendQuery {q : Nat} (P : Fin q → Fin q → Bool) : + AlphabetReduction.InputCoordinate (Fin q) ⊕ Cube (AlphabetReduction.LegalPair P) → + RawQuery q + | .inl k => .inl k + | .inr tape => .inr (UniformRestriction.extend (fun p : Fin q × Fin q => P p.1 p.2 = true) tape) + +theorem query_eq_extend_eventQueries {q : Nat} (P : Fin q → Fin q → Bool) + (kind : Fin 4) (k : AlphabetReduction.InputCoordinate (Fin q)) + (f g r₀ r₁ r₂ : Cube (Fin q × Fin q)) (slot : Fin 6) : + query P (kind, k, f, g, r₀, r₁, r₂) slot = + extendQuery P (AssignmentTester.eventQueries (AlphabetReduction.pairEncoding P) kind k + (UniformRestriction.restrict (fun p : Fin q × Fin q => P p.1 p.2 = true) f) + (UniformRestriction.restrict (fun p : Fin q × Fin q => P p.1 p.2 = true) g) + (UniformRestriction.restrict (fun p : Fin q × Fin q => P p.1 p.2 = true) r₀) + (UniformRestriction.restrict (fun p : Fin q × Fin q => P p.1 p.2 = true) r₁) + (UniformRestriction.restrict (fun p : Fin q × Fin q => P p.1 p.2 = true) r₂) slot) := by + by_cases hk₀ : kind = 0 <;> by_cases hk₁ : kind = 1 <;> by_cases hk₂ : kind = 2 <;> + simp only [query, AssignmentTester.eventQueries, hk₀, hk₁, hk₂, ite_true, ite_false] + all_goals split_ifs <;> simp_all only [extendQuery] + all_goals rfl + +theorem globalize_extendQuery {q : Nat} {V E : Type*} + (G : ConstraintGraph V E (Fin q)) (e : E) + (x : AlphabetReduction.InputCoordinate (Fin q) ⊕ + Cube (AlphabetReduction.LegalPair (G.accepts e))) : + globalize (G.tail e) (G.head e) e (extendQuery (G.accepts e) x) = + AlphabetGraph.globalizeQuery G e x := by + cases x with + | inl k => cases k; rfl + | inr tape => rfl + +theorem globalize_query {q : Nat} {V E : Type*} + (G : ConstraintGraph V E (Fin q)) (e : E) (event : LocalEvent q) (slot : Fin 6) : + globalize (G.tail e) (G.head e) e (query (G.accepts e) event slot) = + (AlphabetGraph.verifier G).query (e, event) slot := by + rcases event with ⟨kind, k, f, g, r₀, r₁, r₂⟩ + rw [query_eq_extend_eventQueries] + exact globalize_extendQuery G e _ + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Queries +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Relations + +open Hastad +open Queries + +variable {q : Nat} + +def sameAddress (selfLoop : Bool) : RawQuery q → RawQuery q → Bool + | .inl (side, f), .inl (side', g) => ((side == side') || selfLoop) && decide (f = g) + | .inr f, .inr g => decide (f = g) + | _, _ => false + +@[simp] theorem sameAddress_refl (selfLoop : Bool) (x : RawQuery q) : + sameAddress selfLoop x x = true := by + rcases x with ⟨side, f⟩ | f <;> simp [sameAddress] + +theorem globalize_eq_iff {V E : Type*} [DecidableEq V] + (tail head : V) (edge : E) (selfLoop : Bool) + (hloop : selfLoop = decide (tail = head)) (x y : RawQuery q) : + globalize tail head edge x = globalize tail head edge y ↔ + sameAddress selfLoop x y = true := by + rcases x with ⟨side, f⟩ | f <;> rcases y with ⟨side', g⟩ | g + · cases side <;> cases side' + · simp [globalize, sameAddress] + · simp [globalize, sameAddress, hloop] + · simp [globalize, sameAddress, hloop, + show head = tail ↔ tail = head from eq_comm] + · simp [globalize, sameAddress] + · simp [globalize, sameAddress] + · simp [globalize, sameAddress] + · simp [globalize, sameAddress] + +def eqProfile (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (i j : Fin 6) : Bool := sameAddress selfLoop (queries i) (queries j) + +@[simp] theorem eqProfile_refl (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (i : Fin 6) : eqProfile selfLoop queries i i = true := sameAddress_refl _ _ + +def canonicalSlot (selfLoop : Bool) (queries : Fin 6 → RawQuery q) (i : Fin 6) : Fin 6 := + Fin.find (fun j => eqProfile selfLoop queries j i = true) ⟨i, eqProfile_refl _ _ _⟩ + +theorem canonicalSlot_profile (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (i : Fin 6) : eqProfile selfLoop queries (canonicalSlot selfLoop queries i) i = true := by + unfold canonicalSlot + exact Fin.find_spec (p := fun j => eqProfile selfLoop queries j i = true) + ⟨i, eqProfile_refl _ _ _⟩ + +theorem canonicalSlot_le (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (i j : Fin 6) (h : eqProfile selfLoop queries j i = true) : + canonicalSlot selfLoop queries i ≤ j := + Fin.find_le_of_pos ⟨i, eqProfile_refl _ _ _⟩ h + +def RepeatedConsistent (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (label : QueryIncidence.Label 6) : Prop := + ∀ i j, eqProfile selfLoop queries i j = true → label i = label j + +instance repeatedConsistentDecidable (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (label : QueryIncidence.Label 6) : Decidable (RepeatedConsistent selfLoop queries label) := by + unfold RepeatedConsistent + infer_instance + +def incidenceAccept (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (accept : QueryIncidence.Label 6 → Bool) (slot : Fin 6) + (left right : QueryIncidence.Label 6) : Bool := + decide (accept left = true ∧ RepeatedConsistent selfLoop queries left) && + decide (left (canonicalSlot selfLoop queries slot) = right 0) + +def predicate (selfLoop : Bool) (queries : Fin 6 → RawQuery q) + (accept : QueryIncidence.Label 6 → Bool) (slot : Fin 6) (orientation : Bool) + (a b : QueryIncidence.Label 6) : Bool := + if orientation then incidenceAccept selfLoop queries accept slot b a + else incidenceAccept selfLoop queries accept slot a b + +def relation (P : Fin q → Fin q → Bool) (selfLoop : Bool) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) : + GraphTables.RelationTable := + GraphTables.relationOf fun a b => + predicate selfLoop (query P event) (AssignmentTester.eventAccepts event.1) + slot orientation (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b) + +@[simp] theorem relationAt_relation (P : Fin q → Fin q → Bool) (selfLoop : Bool) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) + (a b : GraphTables.Label) : + GraphTables.relationAt (relation P selfLoop event slot orientation) a b = + predicate selfLoop (query P event) (AssignmentTester.eventAccepts event.1) + slot orientation (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b) := by + exact GraphTables.relationAt_relationOf _ _ _ + +theorem relation_reverse (P : Fin q → Fin q → Bool) (selfLoop : Bool) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) + (a b : GraphTables.Label) : + GraphTables.relationAt (relation P selfLoop event slot (!orientation)) b a = + GraphTables.relationAt (relation P selfLoop event slot orientation) a b := by + simp only [relationAt_relation] + cases orientation <;> rfl + +def oldPredicate (old : Vector Bool (q * q)) (a b : Fin q) : Bool := + old[(finProdFinEquiv (a, b) : Fin (q * q))] + +def relationFromTable (old : Vector Bool (q * q)) (selfLoop : Bool) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) : + GraphTables.RelationTable := relation (oldPredicate old) selfLoop event slot orientation + +@[simp] theorem oldPredicate_relationAt (old : GraphTables.RelationTable) + (a b : GraphTables.Label) : oldPredicate old a b = GraphTables.relationAt old a b := rfl + +theorem relationFromTable_eq (old : GraphTables.RelationTable) (selfLoop : Bool) + (event : AlphabetGraph.LocalEvent (Fin 64)) (slot : Fin 6) (orientation : Bool) : + relationFromTable old selfLoop event slot orientation = + relation (GraphTables.relationAt old) selfLoop event slot orientation := rfl + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Relations + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/QueryIncidence.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/QueryIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea60a7b88aad129bed7e2fdcc58fa40ecb1e7496 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/QueryIncidence.lean @@ -0,0 +1,248 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.ConstraintGraph + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.QueryIncidence + +structure Verifier (E X : Type*) (q : Nat) where + query : E → Fin q → X + accepts : E → (Fin q → Bool) → Bool + +abbrev Label (q : Nat) := Fin q → Bool +abbrev Vertex (E X : Type*) := E ⊕ X +abbrev Dart (E : Type*) (q : Nat) := (E × Fin q) × Bool + +variable {E X : Type*} {q : Nat} + +def response (T : Verifier E X q) (assignment : X → Bool) (event : E) : Label q := + fun i => assignment (T.query event i) + +def zeroSlot (positive : 0 < q) : Fin q := ⟨0, positive⟩ + +def decodeRight (positive : 0 < q) (label : Label q) : Bool := label (zeroSlot positive) + +def encodeRight (bit : Bool) : Label q := fun _ => bit + +@[simp] theorem decode_encodeRight (positive : 0 < q) (bit : Bool) : + decodeRight positive (encodeRight bit) = bit := rfl + +def canonicalSlot [DecidableEq X] (T : Verifier E X q) (event : E) (i : Fin q) : Fin q := + Fin.find (fun j => T.query event j = T.query event i) ⟨i, rfl⟩ + +theorem canonicalSlot_query [DecidableEq X] (T : Verifier E X q) (event : E) (i : Fin q) : + T.query event (canonicalSlot T event i) = T.query event i := + Fin.find_spec (p := fun j => T.query event j = T.query event i) ⟨i, rfl⟩ + +def RepeatedConsistent (T : Verifier E X q) (event : E) (label : Label q) : Prop := + ∀ i j, T.query event i = T.query event j → label i = label j + +instance repeatedConsistentDecidable [DecidableEq X] + (T : Verifier E X q) (event : E) (label : Label q) : + Decidable (RepeatedConsistent T event label) := by + unfold RepeatedConsistent + infer_instance + +def LeftValid (T : Verifier E X q) (event : E) (label : Label q) : Prop := + T.accepts event label = true ∧ RepeatedConsistent T event label + +instance leftValidDecidable [DecidableEq X] + (T : Verifier E X q) (event : E) (label : Label q) : + Decidable (LeftValid T event label) := by + unfold LeftValid + infer_instance + +def incidenceAccept [DecidableEq X] (T : Verifier E X q) (positive : 0 < q) + (event : E) (slot : Fin q) (left right : Label q) : Bool := + decide (LeftValid T event left) && + decide (left (canonicalSlot T event slot) = decodeRight positive right) + +def reverse : Dart E q → Dart E q := fun d => (d.1, !d.2) + +theorem reverse_involutive : Function.Involutive (reverse : Dart E q → Dart E q) := by + rintro ⟨⟨event, slot⟩, orientation⟩ + cases orientation <;> rfl + +def reverseEquiv : Dart E q ≃ Dart E q where + toFun := reverse + invFun := reverse + left_inv := reverse_involutive + right_inv := reverse_involutive + +def tail (T : Verifier E X q) : Dart E q → Vertex E X + | ((event, _), false) => .inl event + | ((event, slot), true) => .inr (T.query event slot) + +def predicate [DecidableEq X] (T : Verifier E X q) (positive : 0 < q) : + Dart E q → Label q → Label q → Bool + | ((event, slot), false), a, b => incidenceAccept T positive event slot a b + | ((event, slot), true), a, b => incidenceAccept T positive event slot b a + +def graph [DecidableEq X] (T : Verifier E X q) (positive : 0 < q) : + ConstraintGraph (Vertex E X) (Dart E q) (Label q) where + reverse := reverseEquiv + reverse_involutive := reverse_involutive + tail := tail T + accepts := predicate T positive + reverse_accepts := by + rintro ⟨⟨event, slot⟩, orientation⟩ a b + cases orientation <;> rfl + +theorem edgeSatisfied_eq_incidence [DecidableEq X] (T : Verifier E X q) + (positive : 0 < q) (labeling : Vertex E X → Label q) + (event : E) (slot : Fin q) (orientation : Bool) : + (graph T positive).edgeSatisfied labeling ((event, slot), orientation) = + incidenceAccept T positive event slot (labeling (.inl event)) + (labeling (.inr (T.query event slot))) := by + cases orientation <;> rfl + +def honestLabeling (T : Verifier E X q) (assignment : X → Bool) : Vertex E X → Label q + | .inl event => response T assignment event + | .inr address => encodeRight (assignment address) + +theorem honest_leftValid (T : Verifier E X q) (assignment : X → Bool) (event : E) + (accepted : T.accepts event (response T assignment event) = true) : + LeftValid T event (response T assignment event) := by + refine ⟨accepted, ?_⟩ + intro i j hij + exact congrArg assignment hij + +theorem honest_incidence [DecidableEq X] (T : Verifier E X q) (positive : 0 < q) + (assignment : X → Bool) (event : E) + (accepted : T.accepts event (response T assignment event) = true) (slot : Fin q) : + incidenceAccept T positive event slot + (honestLabeling T assignment (.inl event)) + (honestLabeling T assignment (.inr (T.query event slot))) = true := by + simp only [incidenceAccept, Bool.and_eq_true, honestLabeling, + decode_encodeRight] + refine ⟨_root_.decide_eq_true (honest_leftValid T assignment event accepted), ?_⟩ + exact _root_.decide_eq_true (congrArg assignment (canonicalSlot_query T event slot)) + +theorem perfect_completeness [DecidableEq X] (T : Verifier E X q) (positive : 0 < q) + (assignment : X → Bool) + (accepted : ∀ event, T.accepts event (response T assignment event) = true) : + ∀ dart, (graph T positive).edgeSatisfied (honestLabeling T assignment) dart = true := by + rintro ⟨⟨event, slot⟩, orientation⟩ + rw [edgeSatisfied_eq_incidence] + exact honest_incidence T positive assignment event (accepted event) slot + +theorem satisfiable_of_verifier_satisfiable [DecidableEq X] (T : Verifier E X q) + (positive : 0 < q) + (sat : ∃ assignment : X → Bool, + ∀ event, T.accepts event (response T assignment event) = true) : + (graph T positive).Satisfiable := by + obtain ⟨assignment, h⟩ := sat + exact ⟨honestLabeling T assignment, perfect_completeness T positive assignment h⟩ + +def decodedAssignment (positive : 0 < q) (labeling : Vertex E X → Label q) : X → Bool := + fun address => decodeRight positive (labeling (.inr address)) + +theorem incidenceAccept_true [DecidableEq X] (T : Verifier E X q) (positive : 0 < q) + (event : E) (slot : Fin q) (left right : Label q) + (accepted : incidenceAccept T positive event slot left right = true) : + T.accepts event left = true ∧ RepeatedConsistent T event left ∧ + left (canonicalSlot T event slot) = decodeRight positive right := by + simp only [incidenceAccept, Bool.and_eq_true] at accepted + have hvalid : LeftValid T event left := _root_.of_decide_eq_true accepted.1 + exact ⟨hvalid.1, hvalid.2, _root_.of_decide_eq_true accepted.2⟩ + +theorem all_incidences_imply_event [DecidableEq X] (T : Verifier E X q) + (positive : 0 < q) (labeling : Vertex E X → Label q) (event : E) + (accepted : ∀ slot, incidenceAccept T positive event slot (labeling (.inl event)) + (labeling (.inr (T.query event slot))) = true) : + T.accepts event (response T (decodedAssignment positive labeling) event) = true := by + have first := incidenceAccept_true T positive event (zeroSlot positive) _ _ + (accepted (zeroSlot positive)) + have labels_equal : labeling (.inl event) = response T (decodedAssignment positive labeling) event := by + funext slot + have info := incidenceAccept_true T positive event slot _ _ (accepted slot) + exact (first.2.1 slot (canonicalSlot T event slot) + (canonicalSlot_query T event slot).symm).trans info.2.2 + rw [← labels_equal] + exact first.1 + +theorem rejected_event_forces_slot [DecidableEq X] (T : Verifier E X q) + (positive : 0 < q) (labeling : Vertex E X → Label q) (event : E) + (rejected : T.accepts event (response T (decodedAssignment positive labeling) event) = false) : + ∃ slot, incidenceAccept T positive event slot (labeling (.inl event)) + (labeling (.inr (T.query event slot))) = false := by + classical + by_contra none + have all : ∀ slot, incidenceAccept T positive event slot (labeling (.inl event)) + (labeling (.inr (T.query event slot))) = true := by + intro slot + cases h : incidenceAccept T positive event slot (labeling (.inl event)) + (labeling (.inr (T.query event slot))) with + | false => exact False.elim (none ⟨slot, h⟩) + | true => rfl + have h := all_incidences_imply_event T positive labeling event all + rw [rejected] at h + cases h + +def rejectedEvents [Fintype E] (T : Verifier E X q) (assignment : X → Bool) : Finset E := + Finset.univ.filter (fun event => T.accepts event (response T assignment event) = false) + +def verifierRejectionCount [Fintype E] (T : Verifier E X q) (assignment : X → Bool) : Nat := + (rejectedEvents T assignment).card + +theorem rejection_count_bound [Fintype E] [DecidableEq X] + (T : Verifier E X q) (positive : 0 < q) (labeling : Vertex E X → Label q) : + 2 * verifierRejectionCount T (decodedAssignment positive labeling) ≤ + (graph T positive).rejectionCount labeling := by + classical + let failed := rejectedEvents T (decodedAssignment positive labeling) + have witnesses : ∀ event, event ∈ failed → + ∃ slot, incidenceAccept T positive event slot (labeling (.inl event)) + (labeling (.inr (T.query event slot))) = false := by + intro event he + apply rejected_event_forces_slot T positive labeling event + simpa [failed, rejectedEvents] using he + let chosen := fun event he => Classical.choose (witnesses event he) + let inject : (failed.product (Finset.univ : Finset Bool)) → + (graph T positive).rejectedDarts labeling := fun p => + ⟨((p.val.1, chosen p.val.1 (Finset.mem_product.mp p.property).1), p.val.2), by + apply (ConstraintGraph.mem_rejectedDarts _ _ _).mpr + rw [edgeSatisfied_eq_incidence] + exact Classical.choose_spec (witnesses p.val.1 (Finset.mem_product.mp p.property).1)⟩ + have injective : Function.Injective inject := by + intro a b h + apply Subtype.ext + apply Prod.ext + · exact congrArg (fun d => d.val.1.1) h + · exact congrArg (fun d => d.val.2) h + have bound := Finset.card_le_card_of_injective injective + simpa [failed, verifierRejectionCount, ConstraintGraph.rejectionCount, + Finset.card_product, Nat.mul_comm] using bound + +@[simp] theorem card_label (q : Nat) : Fintype.card (Label q) = 2 ^ q := by + simp [Label] + +@[simp] theorem card_vertex [Fintype E] [Fintype X] : + Fintype.card (Vertex E X) = Fintype.card E + Fintype.card X := by + simp [Vertex, Fintype.card_sum] + +@[simp] theorem card_dart [Fintype E] : + Fintype.card (Dart E q) = 2 * q * Fintype.card E := by + simp [Dart, Fintype.card_prod, Nat.mul_comm, Nat.mul_left_comm, Nat.mul_assoc] + +theorem gap_transfer [Fintype E] [DecidableEq X] (T : Verifier E X q) + (positive : 0 < q) (a b : Nat) + (sourceGap : ∀ assignment : X → Bool, + a * Fintype.card E ≤ b * verifierRejectionCount T assignment) + (labeling : Vertex E X → Label q) : + a * Fintype.card (Dart E q) ≤ (b * q) * (graph T positive).rejectionCount labeling := by + have source := Nat.mul_le_mul_left (2 * q) (sourceGap (decodedAssignment positive labeling)) + have incidences := Nat.mul_le_mul_left (b * q) (rejection_count_bound T positive labeling) + rw [card_dart] + calc + a * (2 * q * Fintype.card E) = (2 * q) * (a * Fintype.card E) := by ac_rfl + _ ≤ (2 * q) * (b * verifierRejectionCount T (decodedAssignment positive labeling)) := source + _ = (b * q) * (2 * verifierRejectionCount T (decodedAssignment positive labeling)) := by ac_rfl + _ ≤ (b * q) * (graph T positive).rejectionCount labeling := incidences + +theorem six_query_alphabet : Fintype.card (Label 6) = 64 := by + simp + +end IndependentSetsGames.Foundations.PCP.QueryIncidence + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/RawInitialTables.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/RawInitialTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1d06d6f85ff8611098ec3d85d1c16b1658db8a2 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/RawInitialTables.lean @@ -0,0 +1,173 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GraphTables +import OAI.Combinatorics.IndependentSets.PCP.Minimum +import OAI.Combinatorics.IndependentSets.PCP.AlphabetRetraction +import OAI.Combinatorics.IndependentSets.Encoding.BinaryCoordinates + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RawInitialTables + +open Target GraphTables + +def unitOrder : Unit ≃ Fin 1 where + toFun _ := 0 + invFun _ := () + left_inv _ := rfl + right_inv i := by fin_cases i; rfl + +def slotOrder : Slot ≃ Fin 3 where + toFun + | .first => 0 + | .second => 1 + | .third => 2 + invFun i := if i = 0 then .first else if i = 1 then .second else .third + left_inv s := by cases s <;> rfl + right_inv i := by fin_cases i <;> rfl + +def binaryOrder (n : Nat) : (Fin n → Bool) ≃ Fin (2 ^ n) where + toFun bits := (IndependentSetsGames.Integration.BinaryCoordinates.pack bits).toFin + invFun index := IndependentSetsGames.Integration.BinaryCoordinates.unpack (BitVec.ofFin index) + left_inv bits := IndependentSetsGames.Integration.BinaryCoordinates.unpack_pack bits + right_inv index := by + change (IndependentSetsGames.Integration.BinaryCoordinates.pack + (IndependentSetsGames.Integration.BinaryCoordinates.unpack (BitVec.ofFin index))).toFin = index + rw [IndependentSetsGames.Integration.BinaryCoordinates.pack_unpack] + +def labelOrder : AlphabetRetraction.Label64 ≃ GraphTables.Label := binaryOrder 6 + +def vertexOrder (F : Formula) : + InitialGraph.Vertex F ≃ Fin (F.«variables» + F.clauses.length + 1) := + ((finSumFinEquiv.sumCongr unitOrder).trans finSumFinEquiv) + +def eventOrder (F : Formula) : RandomEvent F ≃ Fin (F.clauses.length * 3) := + ((Equiv.refl (Fin F.clauses.length)).prodCongr slotOrder).trans finProdFinEquiv + +def dartOrder (F : Formula) : InitialGraph.Dart F ≃ Fin (6 * F.clauses.length + 1) := + (((((eventOrder F).prodCongr finTwoEquiv.symm).trans finProdFinEquiv).sumCongr + unitOrder).trans finSumFinEquiv).trans (finCongr (by omega)) + +def raw64 (F : Formula) : ConstraintGraph (InitialGraph.Vertex F) + (InitialGraph.Dart F) AlphabetRetraction.Label64 := + AlphabetRetraction.pullback (InitialGraph.raw F) AlphabetRetraction.decode64 + +def table (F : Formula) : GraphTables.Table := + GraphTables.ofEnumeratedGraph (raw64 F) (vertexOrder F) (dartOrder F) labelOrder + +@[simp] theorem table_vertices (F : Formula) : + (table F).vertices = F.«variables» + F.clauses.length + 1 := rfl + +@[simp] theorem table_darts (F : Formula) : (table F).darts = 6 * F.clauses.length + 1 := rfl + +theorem table_vertices_positive (F : Formula) : 0 < (table F).vertices := by + rw [table_vertices]; omega + +theorem table_darts_positive (F : Formula) : 0 < (table F).darts := by + rw [table_darts]; omega + +theorem raw64_satisfiable_iff (F : Formula) : (raw64 F).Satisfiable ↔ F.Satisfiable := + (AlphabetRetraction.satisfiable_pullback_iff (InitialGraph.raw F) + AlphabetRetraction.decode64 AlphabetRetraction.encode64 + AlphabetRetraction.decode_encode64).trans (InitialGraph.raw_satisfiable_iff F) + +theorem table_semantics (F : Formula) : + GraphTables.semantics (table F) = + (raw64 F).reindex (vertexOrder F) (dartOrder F) labelOrder := by + change GraphTables.semantics (GraphTables.ofGraph + (GraphTables.enumeratedGraph (raw64 F) (vertexOrder F) (dartOrder F) labelOrder)) = _ + rw [GraphTables.semantics_ofGraph] + rfl + +theorem table_satisfiable_iff (F : Formula) : + (GraphTables.semantics (table F)).Satisfiable ↔ F.Satisfiable := by + rw [table_semantics] + exact ((raw64 F).satisfiable_reindex (vertexOrder F) (dartOrder F) labelOrder).trans + (raw64_satisfiable_iff F) + +theorem initial_rejection (F : Formula) (unsat : ¬ F.Satisfiable) + (labeling : Fin (table F).vertices → GraphTables.Label) : + 1 ≤ (GraphTables.semantics (table F)).rejectionCount labeling := + ConstraintGraph.rejectionCount_positive _ + (fun h => unsat ((table_satisfiable_iff F).mp h)) labeling + +theorem initial_size (F : Formula) : + (table F).vertices + (table F).darts = F.«variables» + 7 * F.clauses.length + 2 := by + rw [table_vertices, table_darts] + omega + +end IndependentSetsGames.Foundations.PCP.RawInitialTables +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.FiniteGraph + +structure Bundle (A : Type) where + Vertex : Type + Dart : Type + vertexFintype : Fintype Vertex + dartFintype : Fintype Dart + vertexDecidableEq : DecidableEq Vertex + dartDecidableEq : DecidableEq Dart + dartNonempty : Nonempty Dart + graph : ConstraintGraph Vertex Dart A + +namespace Bundle + +variable {A : Type} + +instance instFintypeVertex (G : Bundle A) : Fintype G.Vertex := G.vertexFintype +instance instFintypeDart (G : Bundle A) : Fintype G.Dart := G.dartFintype +instance instDecidableEqVertex (G : Bundle A) : DecidableEq G.Vertex := G.vertexDecidableEq +instance instDecidableEqDart (G : Bundle A) : DecidableEq G.Dart := G.dartDecidableEq +instance instNonemptyDart (G : Bundle A) : Nonempty G.Dart := G.dartNonempty + +instance instNonemptyVertex (G : Bundle A) : Nonempty G.Vertex := by + obtain ⟨d⟩ := G.dartNonempty + exact ⟨G.graph.tail d⟩ + +def ofGraph {V E : Type} [Fintype V] [Fintype E] + [DecidableEq V] [DecidableEq E] [Nonempty E] + (G : ConstraintGraph V E A) : Bundle A where + Vertex := V + Dart := E + vertexFintype := inferInstance + dartFintype := inferInstance + vertexDecidableEq := inferInstance + dartDecidableEq := inferInstance + dartNonempty := inferInstance + graph := G + +def size (G : Bundle A) : Nat := Fintype.card G.Vertex + Fintype.card G.Dart + +def Satisfiable (G : Bundle A) : Prop := G.graph.Satisfiable + +def rejectionCount (G : Bundle A) (labeling : G.Vertex → A) : Nat := + G.graph.rejectionCount labeling + +theorem size_positive (G : Bundle A) : 0 < G.size := + lt_of_lt_of_le (Fintype.card_pos : 0 < Fintype.card G.Dart) (Nat.le_add_left _ _) + +theorem dartCard_le_size (G : Bundle A) : Fintype.card G.Dart ≤ G.size := + Nat.le_add_left _ _ + +@[simp] theorem ofGraph_graph {V E : Type} [Fintype V] [Fintype E] + [DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) : + (ofGraph G).graph = G := rfl + +@[simp] theorem ofGraph_size {V E : Type} [Fintype V] [Fintype E] + [DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) : + (ofGraph G).size = Fintype.card V + Fintype.card E := rfl + +@[simp] theorem ofGraph_satisfiable {V E : Type} [Fintype V] [Fintype E] + [DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) : + (ofGraph G).Satisfiable ↔ G.Satisfiable := Iff.rfl + +@[simp] theorem ofGraph_rejectionCount {V E : Type} [Fintype V] [Fintype E] + [DecidableEq V] [DecidableEq E] [Nonempty E] + (G : ConstraintGraph V E A) (labeling : V → A) : + (ofGraph G).rejectionCount labeling = G.rejectionCount labeling := rfl + +end Bundle +end IndependentSetsGames.Foundations.PCP.FiniteGraph +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/ReadRelation.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/ReadRelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..27bfca5de82f0cdd850508296b9c9c6e637d4b4a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/ReadRelation.lean @@ -0,0 +1,226 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.ReadRelation + +open Turing +open IndependentSetsGames.Foundations.Complexity +open GenericGraphTables + +variable {K Λ σ : Type} [DecidableEq K] {q : Nat} + +abbrev Alphabet (_ : K) := Bool +abbrev State (σ : Type) (q : Nat) := (σ × RelationTable q) × Option Bool + +def relationEquiv (q : Nat) : RelationTable q ≃ (Fin (q * q) → Bool) where + toFun relation i := relation[i.val] + invFun := Vector.ofFn + left_inv relation := Vector.ofFn_getElem + right_inv bits := by funext i; simp + +@[instance_reducible] def relationFintype (q : Nat) : Fintype (RelationTable q) := + Fintype.ofEquiv (Fin (q * q) → Bool) (relationEquiv q).symm + +@[instance_reducible] def stateFintype (σ : Type) (q : Nat) [Fintype σ] : + Fintype (State σ q) := by + letI := relationFintype q + exact inferInstance + +def readSlot (source : K) (i : Fin (q * q)) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ q) := + .pop source + (fun state head => + ((state.1.1, state.1.2.set i.val (head.getD false) i.isLt), head)) + (.branch (fun state => state.2.getD false) + (.pop source (fun state _ => (state.1, none)) next) + (.load (fun state => (state.1, none)) next)) + +theorem stepAux_readSlot (source : K) (i : Fin (q * q)) (bit : Bool) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) + (initial : RelationTable q) (register : Option Bool) : + TM2.stepAux (readSlot source i next) ((ambient, initial), register) + (Function.update base source (encodeWord (bitWord bit) ++ suffix)) = + TM2.stepAux next ((ambient, initial.set i.val bit i.isLt), none) + (Function.update base source suffix) := by + cases bit <;> simp [readSlot, TM2.stepAux, bitWord, encodeWord] + +def readSlots (source : K) : List (Fin (q * q)) → + TM2.Stmt (Alphabet (K := K)) Λ (State σ q) → + TM2.Stmt (Alphabet (K := K)) Λ (State σ q) + | [], next => .load (fun state => (state.1, none)) next + | i :: indices, next => readSlot source i (readSlots source indices next) + +def indexedWords (relation : RelationTable q) (indices : List (Fin (q * q))) : List Nat := + indices.map (fun i => bitWord relation[i.val]) + +def fillSlots (relation : RelationTable q) : List (Fin (q * q)) → + RelationTable q → RelationTable q + | [], initial => initial + | i :: indices, initial => + fillSlots relation indices (initial.set i.val relation[i.val] i.isLt) + +theorem fillSlots_preserves_correct (relation : RelationTable q) + (indices : List (Fin (q * q))) (initial : RelationTable q) (i : Fin (q * q)) + (hcorrect : initial[i.val] = relation[i.val]) : + (fillSlots relation indices initial)[i.val] = relation[i.val] := by + induction indices generalizing initial with + | nil => exact hcorrect + | cons j indices ih => + apply ih + by_cases hji : j.val = i.val + · simp [hji] + · simp [hji, hcorrect] + +theorem fillSlots_mem (relation : RelationTable q) (indices : List (Fin (q * q))) + (initial : RelationTable q) (i : Fin (q * q)) (hi : i ∈ indices) : + (fillSlots relation indices initial)[i.val] = relation[i.val] := by + induction indices generalizing initial with + | nil => simp at hi + | cons j indices ih => + change (fillSlots relation indices (initial.set j.val relation[j.val] j.isLt))[i.val] = _ + rcases List.mem_cons.mp hi with h | h + · subst j + apply fillSlots_preserves_correct + simp + · exact ih _ h + +theorem fillSlots_finRange (relation initial : RelationTable q) : + fillSlots relation (List.finRange (q * q)) initial = relation := by + apply Vector.ext + intro i hi + exact fillSlots_mem relation (List.finRange (q * q)) initial ⟨i, hi⟩ + (List.mem_finRange _) + +theorem indexedWords_finRange (relation : RelationTable q) : + indexedWords relation (List.finRange (q * q)) = relationWords relation := by + have h : (List.finRange (q * q)).map (fun i => relation[i.val]) = relation.toList := by + rw [List.finRange, List.map_ofFn] + change List.ofFn (fun i : Fin (q * q) => relation[i.val]) = relation.toList + rw [← Vector.toList_ofFn, Vector.ofFn_getElem] + calc + _ = ((List.finRange (q * q)).map (fun i => relation[i.val])).map bitWord := by + simp only [indexedWords, List.map_map, Function.comp_def] + _ = relation.toList.map bitWord := congrArg (fun bits : List Bool => bits.map bitWord) h + _ = _ := rfl + +theorem stepAux_readSlots (source : K) (indices : List (Fin (q * q))) + (relation : RelationTable q) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) + (initial : RelationTable q) (register : Option Bool) : + TM2.stepAux (readSlots source indices next) ((ambient, initial), register) + (Function.update base source (encodeWords (indexedWords relation indices) ++ suffix)) = + TM2.stepAux next ((ambient, fillSlots relation indices initial), none) + (Function.update base source suffix) := by + induction indices generalizing initial register with + | nil => simp [readSlots, fillSlots, indexedWords, encodeWords, TM2.stepAux] + | cons i indices ih => + simp only [readSlots, indexedWords, List.map_cons, encodeWords, List.append_assoc, fillSlots] + rw [stepAux_readSlot] + exact ih _ none + +def readRelation (source : K) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ q) := + readSlots source (List.finRange (q * q)) next + +theorem stepAux_readRelation (source : K) (relation : RelationTable q) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) + (base : K → List Bool) (suffix : List Bool) (ambient : σ) + (initial : RelationTable q) (register : Option Bool) : + TM2.stepAux (readRelation source next) ((ambient, initial), register) + (Function.update base source (encodeWords (relationWords relation) ++ suffix)) = + TM2.stepAux next ((ambient, relation), none) (Function.update base source suffix) := by + simpa only [readRelation, indexedWords_finRange, fillSlots_finRange] using + stepAux_readSlots source (List.finRange (q * q)) relation next + base suffix ambient initial register + +theorem stepAux_readRelation_fromTapes (source : K) (relation : RelationTable q) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) + (base : K → List Bool) (suffix : List Bool) + (hinput : base source = encodeWords (relationWords relation) ++ suffix) + (ambient : σ) (initial : RelationTable q) (register : Option Bool) : + TM2.stepAux (readRelation source next) ((ambient, initial), register) base = + TM2.stepAux next ((ambient, relation), none) (Function.update base source suffix) := by + have h := stepAux_readRelation source relation next base suffix ambient initial register + have hbase : Function.update base source (encodeWords (relationWords relation) ++ suffix) = + base := by rw [← hinput]; exact Function.update_eq_self source base + rw [hbase] at h + exact h + +omit [DecidableEq K] in +theorem readSlots_pushBound (source : K) (indices : List (Fin (q * q))) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) : + Runtime.statementPushBound (readSlots source indices next) = + Runtime.statementPushBound next := by + induction indices with + | nil => rfl + | cons i indices ih => + simp only [readSlots, readSlot, Runtime.statementPushBound, ih, max_self] + +omit [DecidableEq K] in +theorem readRelation_pushBound (source : K) + (next : TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) : + Runtime.statementPushBound (readRelation source next) = + Runtime.statementPushBound next := + readSlots_pushBound source (List.finRange (q * q)) next + +def parser (source : K) (exitLabel : Λ) : + TM2.Stmt (Alphabet (K := K)) Λ (State σ q) := + readRelation source (.goto fun _ => exitLabel) + +omit [DecidableEq K] in +theorem parser_pushBound (source : K) (exitLabel : Λ) : + Runtime.statementPushBound (parser (σ := σ) (q := q) source exitLabel) = 0 := by + rw [parser, readRelation_pushBound] + rfl + +theorem parserStep (source : K) (readLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) + (atRead : program readLabel = parser source exitLabel) + (base : K → List Bool) (relation : RelationTable q) (suffix : List Bool) + (ambient : σ) (initial : RelationTable q) (register : Option Bool) : + TM2.step program + ⟨some readLabel, ((ambient, initial), register), + Function.update base source (encodeWords (relationWords relation) ++ suffix)⟩ = + some ⟨some exitLabel, ((ambient, relation), none), Function.update base source suffix⟩ := by + change some (TM2.stepAux (program readLabel) ((ambient, initial), register) + (Function.update base source (encodeWords (relationWords relation) ++ suffix))) = _ + rw [atRead, parser, stepAux_readRelation] + rfl + +theorem parserTrace (source : K) (readLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) + (atRead : program readLabel = parser source exitLabel) + (base : K → List Bool) (relation : RelationTable q) (suffix : List Bool) + (ambient : σ) (initial : RelationTable q) (register : Option Bool) : + (MachineComposition.advance (TM2.step program))^[1] + (some ⟨some readLabel, ((ambient, initial), register), + Function.update base source (encodeWords (relationWords relation) ++ suffix)⟩) = + some ⟨some exitLabel, ((ambient, relation), none), Function.update base source suffix⟩ := by + simpa only [Function.iterate_one, MachineComposition.advance_some] using + parserStep source readLabel exitLabel program atRead base relation suffix ambient initial register + +def parserInTime (source : K) (readLabel exitLabel : Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State σ q)) + (atRead : program readLabel = parser source exitLabel) + (base : K → List Bool) (relation : RelationTable q) (suffix : List Bool) + (ambient : σ) (initial : RelationTable q) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some readLabel, ((ambient, initial), register), + Function.update base source (encodeWords (relationWords relation) ++ suffix)⟩ + (some ⟨some exitLabel, ((ambient, relation), none), Function.update base source suffix⟩) 1 where + steps := 1 + evals_in_steps := by + change (MachineComposition.advance (TM2.step program))^[1] _ = _ + exact parserTrace source readLabel exitLabel program atRead base relation suffix ambient initial register + steps_le_m := Nat.le_refl _ + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.ReadRelation + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Redirect.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Redirect.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a2556937f3a0c3fa898b8872fb31a4fe31fed4d --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Redirect.lean @@ -0,0 +1,218 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Machines.MachineDrainMany +import OAI.Combinatorics.IndependentSets.Machines.FinalCNFRowPlan + +namespace OAI + +namespace IndependentSetsGames.Foundations.Complexity.FinalCNFCleanup + +open Turing MachineComposition +open FinalCNFMachine (State) +open FinalCNFMachine.Program (Tape Plan) + +section Redirect + +variable {K Λ Λ' σ : Type} {Γ : K → Type} [DecidableEq K] + +def redirectLabel (labels : Λ → Λ') (haltTarget : Option Λ') : Option Λ → Option Λ' + | none => haltTarget + | some label => some (labels label) + +def redirectCfg (labels : Λ → Λ') (haltTarget : Option Λ') (cfg : TM2.Cfg Γ Λ σ) : + TM2.Cfg Γ Λ' σ := + ⟨redirectLabel labels haltTarget cfg.l, cfg.var, cfg.stk⟩ + +def redirectStmt (labels : Λ → Λ') (haltTarget : Option Λ') : + TM2.Stmt Γ Λ σ → TM2.Stmt Γ Λ' σ + | .push k f next => .push k f (redirectStmt labels haltTarget next) + | .peek k f next => .peek k f (redirectStmt labels haltTarget next) + | .pop k f next => .pop k f (redirectStmt labels haltTarget next) + | .load f next => .load f (redirectStmt labels haltTarget next) + | .branch test yes no => .branch test + (redirectStmt labels haltTarget yes) (redirectStmt labels haltTarget no) + | .goto label => .goto (fun state => labels (label state)) + | .halt => match haltTarget with + | none => .halt + | some label => .goto (fun _ => label) + +theorem stepAux_redirect (labels : Λ → Λ') (haltTarget : Option Λ') + (stmt : TM2.Stmt Γ Λ σ) (state : σ) (tapes : ∀ k, List (Γ k)) : + TM2.stepAux (redirectStmt labels haltTarget stmt) state tapes = + redirectCfg labels haltTarget (TM2.stepAux stmt state tapes) := by + induction stmt generalizing state tapes with + | push k f next ih => exact ih state (Function.update tapes k (f state :: tapes k)) + | peek k f next ih => exact ih (f state (tapes k).head?) tapes + | pop k f next ih => + exact ih (f state (tapes k).head?) (Function.update tapes k (tapes k).tail) + | load f next ih => exact ih (f state) tapes + | branch test yes no ihYes ihNo => + cases h : test state with + | false => simpa only [redirectStmt, TM2.stepAux, h, Bool.cond_false] using ihNo state tapes + | true => simpa only [redirectStmt, TM2.stepAux, h, Bool.cond_true] using ihYes state tapes + | goto label => rfl + | halt => cases haltTarget <;> rfl + +end Redirect + +def chosen : List Tape := + [.input, .accumulator, .scratch, .vertices, .darts, .tail, .head, + .rowIndex, .archive, .reverseIndex, .scanWork, .indexWork] + +@[simp] theorem chosen_length : chosen.length = 12 := rfl + +@[simp] theorem mem_chosen (tape : Tape) : tape ∈ chosen ↔ tape ≠ .output := by + cases tape <;> simp [chosen] + +abbrev Label (headerPlan rowPlan : Plan) := + FinalCNFMachine.Program.Label headerPlan.length rowPlan.length ⊕ + (MachineDrainMany.Label chosen ⊕ Unit) + +def cleanupLabel (headerPlan rowPlan : Plan) : MachineDrainMany.Label chosen → Label headerPlan rowPlan := + fun label => .inr (.inl label) + +def resetLabel (headerPlan rowPlan : Plan) : Label headerPlan rowPlan := .inr (.inr ()) + +def cleanupEntry (headerPlan rowPlan : Plan) : Option (Label headerPlan rowPlan) := + MachineDrainMany.entry chosen (cleanupLabel headerPlan rowPlan) (some (resetLabel headerPlan rowPlan)) + +def completedProgram (headerPlan rowPlan : Plan) : Label headerPlan rowPlan → + TM2.Stmt (fun _ : Tape => Bool) (Label headerPlan rowPlan) (State Unit) + | .inl label => redirectStmt Sum.inl (cleanupEntry headerPlan rowPlan) + (FinalCNFMachine.Program.program headerPlan rowPlan label) + | .inr (.inl label) => MachineDrainMany.instruction chosen (cleanupLabel headerPlan rowPlan) + (some (resetLabel headerPlan rowPlan)) label + | .inr (.inr _) => .load (fun _ => (FinalCNFMachine.Program.machine headerPlan rowPlan).initialState) .halt + +def completedMachine (headerPlan rowPlan : Plan) : FinTM2 where + K := Tape + k₀ := .input + k₁ := .output + Γ _ := Bool + Λ := Label headerPlan rowPlan + main := .inl .copyFirst + σ := State Unit + initialState := (FinalCNFMachine.Program.machine headerPlan rowPlan).initialState + m := completedProgram headerPlan rowPlan + +def embeddedCfg (headerPlan rowPlan : Plan) + (cfg : (FinalCNFMachine.Program.machine headerPlan rowPlan).Cfg) : + (completedMachine headerPlan rowPlan).Cfg := + redirectCfg Sum.inl (cleanupEntry headerPlan rowPlan) cfg + +theorem step_simulation (headerPlan rowPlan : Plan) + (a b : (FinalCNFMachine.Program.machine headerPlan rowPlan).Cfg) + (step : (FinalCNFMachine.Program.machine headerPlan rowPlan).step a = some b) : + (completedMachine headerPlan rowPlan).step (embeddedCfg headerPlan rowPlan a) = + some (embeddedCfg headerPlan rowPlan b) := by + cases a with + | mk label state tapes => + cases label with + | none => simp [FinTM2.step, TM2.step] at step + | some label => + have hb : TM2.stepAux (FinalCNFMachine.Program.program headerPlan rowPlan label) + state tapes = b := Option.some.inj step + rw [← hb] + change some (TM2.stepAux + (redirectStmt Sum.inl (cleanupEntry headerPlan rowPlan) + (FinalCNFMachine.Program.program headerPlan rowPlan label)) state tapes) = _ + exact congrArg some (stepAux_redirect Sum.inl (cleanupEntry headerPlan rowPlan) + (FinalCNFMachine.Program.program headerPlan rowPlan label) state tapes) + +@[simp] theorem embedded_init (headerPlan rowPlan : Plan) (input : List Bool) : + embeddedCfg headerPlan rowPlan (initList (FinalCNFMachine.Program.machine headerPlan rowPlan) input) = + initList (completedMachine headerPlan rowPlan) input := rfl + +theorem finalTapes_eq (base : Tape → List Bool) : + MachineDrainMany.finalTapes chosen base = MachineDrainMany.haltTapes .output (base .output) := by + funext tape + rw [MachineDrainMany.finalTapes_apply] + simp only [mem_chosen] + by_cases h : tape = .output + · subst tape + simp [MachineDrainMany.haltTapes] + · simp [MachineDrainMany.haltTapes, h] + +theorem haltList_eq (headerPlan rowPlan : Plan) (output : List Bool) : + haltList (completedMachine headerPlan rowPlan) output = + ⟨none, (FinalCNFMachine.Program.machine headerPlan rowPlan).initialState, + MachineDrainMany.haltTapes .output output⟩ := by + congr 1 + +def cleanupExecution (headerPlan rowPlan : Plan) (state : State Unit) (base : Tape → List Bool) : + StateTransition.EvalsToInTime (completedMachine headerPlan rowPlan).step + ⟨cleanupEntry headerPlan rowPlan, state, base⟩ + (some (haltList (completedMachine headerPlan rowPlan) (base .output))) + (MachineDrainMany.steps chosen base + 1) := by + let after : (completedMachine headerPlan rowPlan).Cfg := + ⟨some (resetLabel headerPlan rowPlan), + (state.1, MachineDrainMany.finalRegister chosen state.2), + MachineDrainMany.finalTapes chosen base⟩ + have drains : StateTransition.EvalsToInTime (completedMachine headerPlan rowPlan).step + ⟨cleanupEntry headerPlan rowPlan, state, base⟩ (some after) + (MachineDrainMany.steps chosen base) := { + steps := MachineDrainMany.steps chosen base + evals_in_steps := MachineDrainMany.trace chosen (cleanupLabel headerPlan rowPlan) + (some (resetLabel headerPlan rowPlan)) (completedProgram headerPlan rowPlan) + (fun _ => rfl) base state.1 state.2 + steps_le_m := le_rfl } + have reset : StateTransition.EvalsToInTime (completedMachine headerPlan rowPlan).step + after (some (haltList (completedMachine headerPlan rowPlan) (base .output))) 1 := { + steps := 1 + evals_in_steps := by + change some (⟨none, (FinalCNFMachine.Program.machine headerPlan rowPlan).initialState, + MachineDrainMany.finalTapes chosen base⟩ : (completedMachine headerPlan rowPlan).Cfg) = + some (haltList (completedMachine headerPlan rowPlan) (base .output)) + exact congrArg some ((congrArg (fun tapes => + (⟨none, (FinalCNFMachine.Program.machine headerPlan rowPlan).initialState, tapes⟩ : + (completedMachine headerPlan rowPlan).Cfg)) (finalTapes_eq base)).trans + (haltList_eq headerPlan rowPlan (base .output)).symm) + steps_le_m := le_rfl } + simpa only [Nat.add_comm] using + StateTransition.EvalsToInTime.trans _ (MachineDrainMany.steps chosen base) 1 + _ after _ drains reset + +def outputsInTime (headerPlan rowPlan : Plan) (input output : List Bool) + (state : State Unit) (base : Tape → List Bool) (budget : Nat) + (raw : StateTransition.EvalsToInTime + (FinalCNFMachine.Program.machine headerPlan rowPlan).step + (initList (FinalCNFMachine.Program.machine headerPlan rowPlan) input) + (some ⟨none, state, base⟩) budget) + (correctOutput : base .output = output) : + TM2OutputsInTime (completedMachine headerPlan rowPlan) input (some output) + (budget + 12 * (input.length + budget * + Runtime.programPushBound (FinalCNFMachine.Program.machine headerPlan rowPlan) + 1) + 1) := by + let lifted := liftExecutionInTime + (FinalCNFMachine.Program.machine headerPlan rowPlan).step + (completedMachine headerPlan rowPlan).step (embeddedCfg headerPlan rowPlan) + (step_simulation headerPlan rowPlan) raw + have joined := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ lifted + (cleanupExecution headerPlan rowPlan state base) + have stackBound : ∀ tape, (base tape).length ≤ input.length + budget * + Runtime.programPushBound (FinalCNFMachine.Program.machine headerPlan rowPlan) := by + intro tape + have h := Runtime.executionSizeBound + (FinalCNFMachine.Program.machine headerPlan rowPlan).step + (fun cfg => (cfg.stk tape).length) + (Runtime.programPushBound (FinalCNFMachine.Program.machine headerPlan rowPlan)) + (Runtime.stepStackLength (FinalCNFMachine.Program.machine headerPlan rowPlan) tape) raw + exact h.trans (Nat.add_le_add_right + (Runtime.initialStackLength (FinalCNFMachine.Program.machine headerPlan rowPlan) input tape) _) + have cleanupBound := MachineDrainMany.steps_le_uniform chosen base _ stackBound + rw [chosen_length] at cleanupBound + rw [embedded_init, correctOutput] at joined + exact { toEvalsTo := joined.toEvalsTo + steps_le_m := joined.steps_le_m.trans (by omega) } + +noncomputable def completedTime (headerPlan rowPlan : Plan) (rawTime : Polynomial Nat) : Polynomial Nat := + rawTime + Polynomial.C 12 * (Polynomial.X + rawTime * + Polynomial.C (Runtime.programPushBound (FinalCNFMachine.Program.machine headerPlan rowPlan)) + 1) + 1 + +theorem completedTime_eval (headerPlan rowPlan : Plan) (rawTime : Polynomial Nat) (n : Nat) : + (completedTime headerPlan rowPlan rawTime).eval n = + rawTime.eval n + 12 * (n + rawTime.eval n * + Runtime.programPushBound (FinalCNFMachine.Program.machine headerPlan rowPlan) + 1) + 1 := by + simp [completedTime] + +end IndependentSetsGames.Foundations.Complexity.FinalCNFCleanup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/RoundGap.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/RoundGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..1bcc9312f653985d7c437b058dc06dcb12eb410a --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/RoundGap.lean @@ -0,0 +1,236 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.AmplificationRound +import OAI.Combinatorics.IndependentSets.Expansion.PoweringGap + +namespace OAI + +noncomputable section + +namespace IndependentSetsGames.Foundations.PCP.RoundGap + +open AmplificationRound + +variable {V E : Type*} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] + [Nonempty E] + +def poweredLower (epsilon : ℝ) : ℝ := + PoweringSoundness.gain (Fintype.card Label) FinalConstants.windowHalf (31 / 32) * + min (epsilon / (Preprocessing.sizeFactor : ℝ)) FinalConstants.cap + +theorem poweredLower_nonnegative (epsilon : ℝ) (he : 0 ≤ epsilon) : + 0 ≤ poweredLower epsilon := by + have hg := PoweringGap.gain_nonneg (Fintype.card Label) + FinalConstants.windowHalf (31 / 32) (by norm_num) + have hs : (0 : ℝ) < Preprocessing.sizeFactor := by + exact_mod_cast Preprocessing.sizeFactor_positive + exact mul_nonneg hg (le_min (div_nonneg he hs.le) FinalConstants.cap_positive.le) + +theorem powered_count_gap (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (G : ConstraintGraph V E Label) + (labeling : Preprocessing.Vertex G → PoweredAlphabet) : + poweredLower G.gap * (Fintype.card (PoweredDart G) : ℝ) ≤ + ((powered addresses complete G).rejectionCount labeling : ℝ) := by + let H := Overlay.originalPortGraph (Preprocessing.overlayGraph G) + have certificate : SpectralReturn.SpectralCertificate + (PoweringWalks.lazyGraph H) (31 / 32 : ℝ) := + Preprocessing.spectral_certificate G + have lower : ∀ assignment : Preprocessing.Vertex G → Label, + (G.gap / (Preprocessing.sizeFactor : ℝ)) * + (Fintype.card (Preprocessing.Vertex G × Preprocessing.Port) : ℝ) ≤ + ((Preprocessing.graph G).rejectionCount assignment : ℝ) := + Preprocessing.gap_transfer_real G G.gap G.gap_nonnegative + ((G.le_gap_iff G.gap).mp le_rfl) + have hs : (0 : ℝ) < Preprocessing.sizeFactor := by + exact_mod_cast Preprocessing.sizeFactor_positive + have h := PoweringGap.uniform_count_gap H (31 / 32) certificate + (Preprocessing.graph G).accepts (Preprocessing.accepts_reverse G) + FinalConstants.windowHalf FinalConstants.windowHalf_positive + (selectors addresses complete G) + (G.gap / (Preprocessing.sizeFactor : ℝ)) (div_nonneg G.gap_nonnegative hs.le) + lower labeling + convert h using 1 <;> + simp only [poweredLower, powered, FinalConstants.cap, FinalConstants.walkLength, + PoweringFinalConstants.center_eq] + rfl + +theorem amplifies (addresses : List Addresses) (complete : ∀ w, w ∈ addresses) + (G : ConstraintGraph V E Label) : + min (2 * G.gap) FinalConstants.cap ≤ (graph addresses complete G).gap := by + apply ((graph addresses complete G).le_gap_iff _).mpr + intro labeling + have hcount := AlphabetGraphBounds.gap_transfer_real (powered addresses complete G) + (poweredLower G.gap) (poweredLower_nonnegative G.gap G.gap_nonnegative) + (powered_count_gap addresses complete G) labeling + have hscalar : min (2 * G.gap) FinalConstants.cap ≤ poweredLower G.gap / 12288 := by + simpa only [poweredLower, FinalConstants.cap, FinalConstants.walkLength, + PoweringFinalConstants.center_eq] using + PoweringFinalConstants.composed_scaled_gap G.gap G.gap_nonnegative + exact (mul_le_mul_of_nonneg_right hscalar (Nat.cast_nonneg _)).trans hcount + +end IndependentSetsGames.Foundations.PCP.RoundGap +namespace IndependentSetsGames.Foundations.PCP.RoundSize + +open scoped BigOperators + +theorem card_padded_alphabet {D A : Type*} [Fintype D] [DecidableEq D] + [Fintype A] (t : Nat) : + Fintype.card (PoweringLabels.PaddedLabel D t A) = + Fintype.card A ^ (∑ k : Fin (t + 1), Fintype.card D ^ k.val) := by + simpa only [Nat.card_eq_fintype_card] using + PoweringLabels.card_paddedLabel (D := D) (A := A) t + +theorem card_powered_dart {V D : Type*} [Fintype V] [Fintype D] + (n : Nat) : Fintype.card (PoweringTest.Dart V D n) = + Fintype.card V * (2 * Fintype.card D ^ (n + 1)) := by + simp only [PoweringTest.Dart, PoweringWalks.Walk, Fintype.card_prod, + Fintype.card_bool, Fintype.card_fun, Fintype.card_fin] + ring + +private opaque lockedNat (n : Nat) : {m : Nat // m = n} := ⟨n, rfl⟩ + +def poweredAlphabetSize : Nat := + (lockedNat (64 ^ (∑ k : Fin (FinalConstants.walkLength + 1), + Preprocessing.degree ^ k.val))).val + +def poweredDartFactor : Nat := + (lockedNat (2 * Preprocessing.degree ^ (2 * FinalConstants.endpointLength + 1))).val + +def sizeFactor : Nat := + (lockedNat (AlphabetGraphBounds.sizeFactor poweredAlphabetSize * + (1 + poweredDartFactor) * ExpanderFamily.growth ^ 2)).val + +theorem poweredAlphabetSize_eq : poweredAlphabetSize = + 64 ^ (∑ k : Fin (FinalConstants.walkLength + 1), Preprocessing.degree ^ k.val) := + (lockedNat _).property + +theorem poweredDartFactor_eq : poweredDartFactor = + 2 * Preprocessing.degree ^ (2 * FinalConstants.endpointLength + 1) := + (lockedNat _).property + +theorem sizeFactor_eq : sizeFactor = AlphabetGraphBounds.sizeFactor poweredAlphabetSize * + (1 + poweredDartFactor) * ExpanderFamily.growth ^ 2 := + (lockedNat _).property + +private theorem coefficient_positive (q d g : Nat) (hg : 0 < g) : + 0 < AlphabetGraphBounds.sizeFactor q * (1 + d) * g ^ 2 := by + exact Nat.mul_pos (Nat.mul_pos (AlphabetGraphBounds.sizeFactor_positive q) + (Nat.zero_lt_one.trans_le (Nat.le_add_right 1 d))) (pow_pos hg 2) + +theorem poweredAlphabet_card : Fintype.card AmplificationRound.PoweredAlphabet = + poweredAlphabetSize := by + have h := PoweringLabels.card_paddedLabel (D := Preprocessing.Port) + (A := QueryIncidence.Label 6) FinalConstants.walkLength + change Nat.card AmplificationRound.PoweredAlphabet = _ at h + simp only [Nat.card_eq_fintype_card, ← Preprocessing.degree_eq_card, + QueryIncidence.six_query_alphabet] at h + exact h.trans poweredAlphabetSize_eq.symm + +theorem sizeFactor_positive : 0 < sizeFactor := by + have hG : 0 < ExpanderFamily.growth := + Nat.zero_lt_one.trans ExpanderFamily.growth_gt_one + rw [sizeFactor_eq] + exact coefficient_positive _ _ _ hG + +private theorem factor_total (c v d : Nat) : c * (v + v * d) = c * (1 + d) * v := by + ring + +private theorem nat_card_output_vertex {V E A : Type*} + [Fintype V] [Fintype E] [Fintype A] [DecidableEq A] [Nonempty A] : + Nat.card (AlphabetGraphBounds.OutputVertex V E A) = + Nat.card V * 2 ^ Nat.card A + + Nat.card E * AlphabetGraphBounds.vertexFactor (Nat.card A) := by + simpa only [← Nat.card_eq_fintype_card] using + AlphabetGraphBounds.card_output_vertex (V := V) (E := E) (A := A) + +private theorem nat_card_output_dart {E A : Type*} + [Fintype E] [Fintype A] [DecidableEq A] [Nonempty A] : + Nat.card (AlphabetGraphBounds.OutputDart E A) = + Nat.card E * AlphabetGraphBounds.dartFactor (Nat.card A) := by + simpa only [← Nat.card_eq_fintype_card] using + AlphabetGraphBounds.card_output_dart (E := E) (A := A) + +private theorem nat_card_output_total_le {V E A : Type*} + [Fintype V] [Fintype E] [Fintype A] [DecidableEq A] [Nonempty A] : + Nat.card (AlphabetGraphBounds.OutputVertex V E A) + + Nat.card (AlphabetGraphBounds.OutputDart E A) ≤ + AlphabetGraphBounds.sizeFactor (Nat.card A) * (Nat.card V + Nat.card E) := by + simpa only [← Nat.card_eq_fintype_card] using + AlphabetGraphBounds.card_output_total_le (V := V) (E := E) (A := A) + +variable {V E : Type*} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] + [Nonempty E] + +omit [DecidableEq E] [Nonempty E] in +theorem poweredDart_card (G : ConstraintGraph V E AmplificationRound.Label) : + Fintype.card (AmplificationRound.PoweredDart G) = + Fintype.card (Preprocessing.Vertex G) * poweredDartFactor := by + have h := card_powered_dart (V := Preprocessing.Vertex G) (D := Preprocessing.Port) + (2 * FinalConstants.endpointLength) + rw [← Preprocessing.degree_eq_card] at h + exact h.trans (congrArg (fun d => Fintype.card (Preprocessing.Vertex G) * d) + poweredDartFactor_eq.symm) + +omit [DecidableEq E] [Nonempty E] in + +theorem output_vertex_card (G : ConstraintGraph V E AmplificationRound.Label) : + Fintype.card (AmplificationRound.Vertex G) = + Fintype.card (Preprocessing.Vertex G) * 2 ^ poweredAlphabetSize + + (Fintype.card (Preprocessing.Vertex G) * poweredDartFactor) * + AlphabetGraphBounds.vertexFactor poweredAlphabetSize := by + have h := nat_card_output_vertex (V := Preprocessing.Vertex G) + (E := AmplificationRound.PoweredDart G) (A := AmplificationRound.PoweredAlphabet) + change Nat.card (AmplificationRound.Vertex G) = + Nat.card (Preprocessing.Vertex G) * 2 ^ Nat.card AmplificationRound.PoweredAlphabet + + Nat.card (AmplificationRound.PoweredDart G) * + AlphabetGraphBounds.vertexFactor (Nat.card AmplificationRound.PoweredAlphabet) at h + simpa only [Nat.card_eq_fintype_card, poweredAlphabet_card, poweredDart_card] using h + +omit [DecidableEq E] [Nonempty E] in + +theorem output_dart_card (G : ConstraintGraph V E AmplificationRound.Label) : + Fintype.card (AmplificationRound.Dart G) = + (Fintype.card (Preprocessing.Vertex G) * poweredDartFactor) * + AlphabetGraphBounds.dartFactor poweredAlphabetSize := by + have h := nat_card_output_dart (E := AmplificationRound.PoweredDart G) + (A := AmplificationRound.PoweredAlphabet) + change Nat.card (AmplificationRound.Dart G) = Nat.card (AmplificationRound.PoweredDart G) * + AlphabetGraphBounds.dartFactor (Nat.card AmplificationRound.PoweredAlphabet) at h + simpa only [Nat.card_eq_fintype_card, poweredAlphabet_card, poweredDart_card] using h + +omit [DecidableEq E] in +theorem output_total_le_darts (G : ConstraintGraph V E AmplificationRound.Label) : + Fintype.card (AmplificationRound.Vertex G) + Fintype.card (AmplificationRound.Dart G) ≤ + sizeFactor * Fintype.card E := by + have h := nat_card_output_total_le + (V := Preprocessing.Vertex G) (E := AmplificationRound.PoweredDart G) + (A := AmplificationRound.PoweredAlphabet) + change Nat.card (AmplificationRound.Vertex G) + Nat.card (AmplificationRound.Dart G) ≤ + AlphabetGraphBounds.sizeFactor (Nat.card AmplificationRound.PoweredAlphabet) * + (Nat.card (Preprocessing.Vertex G) + Nat.card (AmplificationRound.PoweredDart G)) at h + simp only [Nat.card_eq_fintype_card] at h + rw [poweredAlphabet_card, poweredDart_card] at h + calc + _ ≤ AlphabetGraphBounds.sizeFactor poweredAlphabetSize * + (Fintype.card (Preprocessing.Vertex G) + + Fintype.card (Preprocessing.Vertex G) * poweredDartFactor) := h + _ = (AlphabetGraphBounds.sizeFactor poweredAlphabetSize * + (1 + poweredDartFactor)) * Fintype.card (Preprocessing.Vertex G) := + factor_total _ _ _ + _ ≤ (AlphabetGraphBounds.sizeFactor poweredAlphabetSize * + (1 + poweredDartFactor)) * (ExpanderFamily.growth ^ 2 * Fintype.card E) := + Nat.mul_le_mul_left _ (Preprocessing.vertex_count_le G) + _ = sizeFactor * Fintype.card E := by + rw [sizeFactor_eq] + exact (Nat.mul_assoc _ _ _).symm + +omit [DecidableEq E] in +theorem output_total_le (G : ConstraintGraph V E AmplificationRound.Label) : + Fintype.card (AmplificationRound.Vertex G) + Fintype.card (AmplificationRound.Dart G) ≤ + sizeFactor * (Fintype.card V + Fintype.card E) := + (output_total_le_darts G).trans (Nat.mul_le_mul_left _ (Nat.le_add_left _ _)) + +end IndependentSetsGames.Foundations.PCP.RoundSize + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/RoundTableGap.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/RoundTableGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4eaca0287c39d3b24e7aa7eea1236ec826d6684 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/RoundTableGap.lean @@ -0,0 +1,144 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.TableIteration +import OAI.Combinatorics.IndependentSets.Expansion.PoweringPortReindex + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.RoundTableGap + +open RoundTables +open PoweringWalks SpectralReturn + +variable (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + +include certificate + +theorem powered_count_gap (input : Input) + (labeling : Fin (powered H input.val).vertices → Fin alphabet) : + RoundGap.poweredLower (gap input) * ((powered H input.val).darts : ℝ) ≤ + ((GenericGraphTables.semantics (powered H input.val)).rejectionCount labeling : ℝ) := by + let old := PreprocessingOverlayTables.overlay + (PreprocessingTables.padded H input.val) (PreprocessingTables.overlayFamily H input.val) + have hd : 0 < (PreprocessingRegularTables.internalDegree + 1) + + PreprocessingRegularTables.internalDegree := by omega + let : Nonempty (Fin ((PreprocessingRegularTables.internalDegree + 1) + + PreprocessingRegularTables.internalDegree)) := ⟨⟨0, hd⟩⟩ + have spectral : SpectralCertificate (lazyGraph (PortTables.portGraph old)) (31 / 32 : ℝ) := + LazySpectral.lazy_certificate_31_32 (PortTables.portGraph old) + (PreprocessingGuarantees.overlay_certificate H certificate input.val) + have lower := PreprocessingGuarantees.gap_transfer_real H certificate input.val input.property + (gap input) (gap_nonnegative input) + (by simpa only [Fintype.card_fin] using + ((GraphTables.semantics input.val).le_gap_iff (gap input)).mp le_rfl) + have hs : (0 : ℝ) < Preprocessing.sizeFactor := Nat.cast_pos.mpr Preprocessing.sizeFactor_positive + have hn : walkParameter = 2 * PoweringSoundness.center 64 FinalConstants.windowHalf := + walkParameter_eq + have bound := PoweringPortReindex.lazy_table_uniform_count_gap_at old + (PreprocessingTables.vertices_positive input.val) hd (31 / 32) spectral + FinalConstants.windowHalf FinalConstants.windowHalf_positive walkParameter hn + (gap input / Preprocessing.sizeFactor) (div_nonneg (gap_nonnegative input) hs.le) + lower labeling + have hw : walkParameter + 1 = FinalConstants.walkLength := by + rw [walkParameter_eq] + rfl + rw [hw] at bound + simp only [RoundGap.poweredLower, PoweringFinalConstants.card_alphabet, FinalConstants.cap] + exact bound + +theorem build_count_gap (input : Input) + (labeling : Fin (build H input.val).vertices → GraphTables.Label) : + min (2 * gap input) FinalConstants.cap * ((build H input.val).darts : ℝ) ≤ + ((GraphTables.semantics (build H input.val)).rejectionCount labeling : ℝ) := by + have h := AlphabetTableBounds.gap_transfer_real alphabet_positive (powered H input.val) + (RoundGap.poweredLower (gap input)) + (RoundGap.poweredLower_nonnegative (gap input) (gap_nonnegative input)) + (powered_count_gap H certificate input) labeling + have scalar : min (2 * gap input) FinalConstants.cap ≤ + RoundGap.poweredLower (gap input) / 12288 := by + simpa only [RoundGap.poweredLower, FinalConstants.cap, FinalConstants.walkLength, + PoweringFinalConstants.center_eq] using + PoweringFinalConstants.composed_scaled_gap (gap input) (gap_nonnegative input) + exact (mul_le_mul_of_nonneg_right scalar (Nat.cast_nonneg _)).trans h + +theorem step_gap (input : Input) : + min (2 * gap input) FinalConstants.cap ≤ gap (step H input) := by + apply ((GraphTables.semantics (step H input).val).le_gap_iff _).mpr + intro labeling + rw [Fintype.card_fin] + exact build_count_gap H certificate input labeling + +end IndependentSetsGames.Foundations.PCP.RoundTableGap + +namespace IndependentSetsGames.Foundations.PCP.TableGapReduction + +open RoundTables TableIteration SpectralReturn Target + +variable (H : BaseTable) + (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) + +include certificate + +theorem run_gap (n : Nat) (input : Input) : + min (2 ^ n * gap input) FinalConstants.cap ≤ gap (TableIteration.run H n input) := + AmplificationIteration.run_gap (step H) gap FinalConstants.cap FinalConstants.cap_positive.le + (RoundTableGap.step_gap H certificate) n input + +theorem output_gap (F : Formula) (unsat : ¬ F.Satisfiable) : + FinalConstants.cap ≤ gap (TableIteration.output H F) := by + have hu : ¬ Satisfiable (initial F) := fun sat => unsat ((initial_satisfiable_iff F).mp sat) + exact AmplificationIteration.run_reaches_cap (step H) gap FinalConstants.cap + FinalConstants.cap_positive.le FinalConstants.cap_le_one (RoundTableGap.step_gap H certificate) + (size (initial F)) (initial F) (gap_nonnegative (initial F)) + (one_le_size_mul_gap (initial F) hu) + +theorem output_satisfiable_iff (F : Formula) : + Satisfiable (TableIteration.output H F) ↔ F.Satisfiable := by + constructor + · intro sat + by_contra unsat + have bound := output_gap H certificate F unsat + rw [(gap_eq_zero_iff (TableIteration.output H F)).mpr sat] at bound + exact (not_le_of_gt FinalConstants.cap_positive) bound + · exact TableIteration.output_completeness H F + +theorem gapMap_satisfiable_iff (F : Formula) : (gapMap H F).Satisfiable ↔ F.Satisfiable := by + rw [gapMap, FinalTableFormula.satisfiable_iff, ← output_val] + exact output_satisfiable_iff H certificate F + +theorem output_count_gap (F : Formula) (unsat : ¬ F.Satisfiable) + (labeling : Fin (outputTable H F).vertices → GraphTables.Label) : + (outputTable H F).darts ≤ FinalConstants.walkLength * + (GraphTables.semantics (outputTable H F)).rejectionCount labeling := by + have hp := output_darts_positive H F + let : Nonempty (Fin (outputTable H F).darts) := ⟨⟨0, hp⟩⟩ + have bound := output_gap H certificate F unsat + change FinalConstants.cap ≤ (GraphTables.semantics (TableIteration.output H F).val).gap at bound + rw [output_val] at bound + have count := ((GraphTables.semantics (outputTable H F)).le_gap_iff FinalConstants.cap).mp bound labeling + simp only [Fintype.card_fin] at count + have ht : (0 : ℝ) < FinalConstants.walkLength := Nat.cast_pos.mpr FinalConstants.walkLength_positive + have divided : ((outputTable H F).darts : ℝ) / FinalConstants.walkLength ≤ + ((GraphTables.semantics (outputTable H F)).rejectionCount labeling : ℝ) := by + simpa only [FinalConstants.cap, one_div_mul_eq_div] using count + have multiplied := (div_le_iff₀ ht).mp divided + exact_mod_cast (show ((outputTable H F).darts : ℝ) ≤ (FinalConstants.walkLength : ℝ) * + ((GraphTables.semantics (outputTable H F)).rejectionCount labeling : ℝ) by + simpa only [mul_comm] using multiplied) + +theorem gapMap_clauseGap (F : Formula) (unsat : ¬ F.Satisfiable) : + Hastad.SourceGap.ClauseGap (gapMap H F) PCPIteration.finalClauseGap := + FinalTableFormula.clauseGap (outputTable H F) (output_darts_positive H F) + (output_count_gap H certificate F unsat) + +omit certificate in +theorem finalClauseGap_le_one : PCPIteration.finalClauseGap ≤ 1 := by + have hw : (1 : ℚ) ≤ (FinalConstants.walkLength : ℚ) := by + exact_mod_cast FinalConstants.walkLength_positive + have hd : (0 : ℚ) < 40960 * (FinalConstants.walkLength : ℚ) := by positivity + rw [PCPIteration.finalClauseGap, div_le_one hd] + linarith + +end IndependentSetsGames.Foundations.PCP.TableGapReduction + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Semantics.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Semantics.lean new file mode 100644 index 0000000000000000000000000000000000000000..12972ad6ef4c7c4b806a38d28f6bdad208f5293b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Semantics.lean @@ -0,0 +1,139 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GenericGraphTables +import OAI.Combinatorics.IndependentSets.PCP.Queries + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Relations +open Hastad +open Queries +variable {q : Nat} + +variable {V E : Type*} [DecidableEq V] [DecidableEq E] + +omit [DecidableEq E] in +theorem eqProfile_query_iff (G : ConstraintGraph V E (Fin q)) (e : E) + (event : AlphabetGraph.LocalEvent (Fin q)) (i j : Fin 6) : + eqProfile (decide (G.tail e = G.head e)) (query (G.accepts e) event) i j = true ↔ + (AlphabetGraph.verifier G).query (e, event) i = + (AlphabetGraph.verifier G).query (e, event) j := by + rw [← globalize_query G e event i, ← globalize_query G e event j] + exact (globalize_eq_iff (G.tail e) (G.head e) e _ rfl _ _).symm + +theorem canonicalSlot_eq (G : ConstraintGraph V E (Fin q)) (e : E) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) : + canonicalSlot (decide (G.tail e = G.head e)) (query (G.accepts e) event) slot = + QueryIncidence.canonicalSlot (AlphabetGraph.verifier G) (e, event) slot := by + unfold canonicalSlot QueryIncidence.canonicalSlot + apply Fin.find_congr' + exact eqProfile_query_iff G e event _ slot + +omit [DecidableEq E] in +theorem repeatedConsistent_iff (G : ConstraintGraph V E (Fin q)) (e : E) + (event : AlphabetGraph.LocalEvent (Fin q)) (label : QueryIncidence.Label 6) : + RepeatedConsistent (decide (G.tail e = G.head e)) (query (G.accepts e) event) label ↔ + QueryIncidence.RepeatedConsistent (AlphabetGraph.verifier G) (e, event) label := by + constructor + · intro h i j hij + exact h i j ((eqProfile_query_iff G e event i j).mpr hij) + · intro h i j hij + exact h i j ((eqProfile_query_iff G e event i j).mp hij) + +omit [DecidableEq V] [DecidableEq E] in +theorem verifier_accepts (G : ConstraintGraph V E (Fin q)) (e : E) + (event : AlphabetGraph.LocalEvent (Fin q)) (label : QueryIncidence.Label 6) : + (AlphabetGraph.verifier G).accepts (e, event) label = + AssignmentTester.eventAccepts event.1 label := by + rcases event with ⟨kind, k, f, g, r₀, r₁, r₂⟩ + rfl + +theorem incidenceAccept_eq (G : ConstraintGraph V E (Fin q)) (e : E) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) + (left right : QueryIncidence.Label 6) : + incidenceAccept (decide (G.tail e = G.head e)) (query (G.accepts e) event) + (AssignmentTester.eventAccepts event.1) slot left right = + QueryIncidence.incidenceAccept (AlphabetGraph.verifier G) (by decide) (e, event) slot + left right := by + simp only [incidenceAccept, QueryIncidence.incidenceAccept, QueryIncidence.LeftValid, + verifier_accepts, repeatedConsistent_iff, canonicalSlot_eq, + QueryIncidence.decodeRight, QueryIncidence.zeroSlot] + rfl + +theorem relationAt_relation_graph (G : ConstraintGraph V E (Fin q)) (e : E) + (event : AlphabetGraph.LocalEvent (Fin q)) (slot : Fin 6) (orientation : Bool) + (a b : GraphTables.Label) : + GraphTables.relationAt + (relation (G.accepts e) (decide (G.tail e = G.head e)) event slot orientation) a b = + (AlphabetGraph.graph G).accepts (((e, event), slot), orientation) + (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b) := by + rw [relationAt_relation] + cases orientation <;> + exact incidenceAccept_eq G e event slot _ _ + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Relations +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Table + +variable {q : Nat} + +def rowFromDart (input : GenericGraphTables.Table q) + (dart : QueryIncidence.Dart (AlphabetGraph.Event (Fin input.darts) (Fin q)) 6) : + GraphTables.DartRow (Enumeration.vertexCount input.vertices input.darts q) + (Enumeration.dartCount input.darts q) := + let edge := dart.1.1.1 + let event := dart.1.1.2 + let slot := dart.1.2 + let old := input.rows[edge] + let head := input.rows[old.reverseIndex].tail + { tail := Enumeration.vertexEquiv input.vertices input.darts q + (if dart.2 then + .inr (Queries.globalize old.tail head edge + (Queries.query (GenericGraphTables.relationAt old.relation) event slot)) + else .inl (edge, event)) + reverseIndex := Enumeration.dartEquiv input.darts q (dart.1, !dart.2) + relation := Relations.relationFromTable old.relation (decide (old.tail = head)) + event slot dart.2 } + +def rows (input : GenericGraphTables.Table q) : + GraphTables.Rows (Enumeration.vertexCount input.vertices input.darts q) + (Enumeration.dartCount input.darts q) := + Vector.ofFn (fun index => + rowFromDart input ((Enumeration.dartEquiv input.darts q).symm index)) + +@[simp] theorem rows_at (input : GenericGraphTables.Table q) + (index : Fin (Enumeration.dartCount input.darts q)) : + (rows input)[index] = + rowFromDart input ((Enumeration.dartEquiv input.darts q).symm index) := by + simp [rows] + +theorem rows_reverseIndex (input : GenericGraphTables.Table q) + (index : Fin (Enumeration.dartCount input.darts q)) : + (rows input)[index].reverseIndex = + Enumeration.dartEquiv input.darts q + (((Enumeration.dartEquiv input.darts q).symm index).1, + !((Enumeration.dartEquiv input.darts q).symm index).2) := by + simp [rows, rowFromDart] + +theorem dartRow_ext {n m : Nat} {left right : GraphTables.DartRow n m} + (ht : left.tail = right.tail) (hr : left.reverseIndex = right.reverseIndex) + (hp : left.relation = right.relation) : left = right := by + cases left + cases right + cases ht + cases hr + cases hp + rfl + +theorem relation_ext {left right : GraphTables.RelationTable} + (h : ∀ a b, GraphTables.relationAt left a b = GraphTables.relationAt right a b) : + left = right := by + apply Vector.ext + intro i hi + let labels := GraphTables.relationIndex.symm (⟨i, hi⟩ : Fin 4096) + have index : GraphTables.relationIndex labels = (⟨i, hi⟩ : Fin 4096) := + GraphTables.relationIndex.apply_symm_apply _ + have point := h labels.1 labels.2 + simpa only [GraphTables.relationAt, index, Fin.getElem_fin] using point + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Table + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Semantics2.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Semantics2.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4e8018c766290efbaf6251d38472aa3955685fd --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Semantics2.lean @@ -0,0 +1,205 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.Semantics + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Table +variable {q : Nat} + +theorem rowFromDart_eq_graphRow (input : GenericGraphTables.Table q) + (dart : QueryIncidence.Dart (AlphabetGraph.Event (Fin input.darts) (Fin q)) 6) : + rowFromDart input dart = + { tail := Enumeration.vertexEquiv input.vertices input.darts q + ((AlphabetGraph.graph (GenericGraphTables.semantics input)).tail dart) + reverseIndex := Enumeration.dartEquiv input.darts q + ((AlphabetGraph.graph (GenericGraphTables.semantics input)).reverse dart) + relation := GraphTables.relationOf (fun a b => + (AlphabetGraph.graph (GenericGraphTables.semantics input)).accepts dart + (Enumeration.labelEquiv.symm a) (Enumeration.labelEquiv.symm b)) } := by + rcases dart with ⟨⟨⟨edge, event⟩, slot⟩, orientation⟩ + apply dartRow_ext + · cases orientation with + | false => rfl + | true => + have query := Queries.globalize_query (GenericGraphTables.semantics input) + edge event slot + have predicate : (GenericGraphTables.semantics input).accepts edge = + GenericGraphTables.relationAt input.rows[edge].relation := rfl + rw [predicate] at query + simpa only [rowFromDart, AlphabetGraph.graph, QueryIncidence.graph, + QueryIncidence.tail, GenericGraphTables.semantics_tail, + ConstraintGraph.head, GenericGraphTables.semantics_reverse, + ite_true] using + congrArg (fun address => Enumeration.vertexEquiv input.vertices input.darts q + (.inr address)) query + · rfl + · apply relation_ext + intro a b + rw [GraphTables.relationAt_relationOf] + exact Relations.relationAt_relation_graph (GenericGraphTables.semantics input) + edge event slot orientation a b + +theorem rows_eq_graphRows (input : GenericGraphTables.Table q) : + rows input = GraphTables.graphRows + (GraphTables.enumeratedGraph (AlphabetGraph.graph (GenericGraphTables.semantics input)) + (Enumeration.vertexEquiv input.vertices input.darts q) + (Enumeration.dartEquiv input.darts q) Enumeration.labelEquiv) := by + apply Vector.ext + intro i hi + simp only [rows, GraphTables.graphRows, Vector.getElem_ofFn] + exact rowFromDart_eq_graphRow input + ((Enumeration.dartEquiv input.darts q).symm ⟨i, hi⟩) + +theorem rows_valid (input : GenericGraphTables.Table q) : GraphTables.Valid (rows input) := by + rw [rows_eq_graphRows] + exact GraphTables.graphRows_valid _ + +def build (input : GenericGraphTables.Table q) : GraphTables.Table where + vertices := Enumeration.vertexCount input.vertices input.darts q + darts := Enumeration.dartCount input.darts q + rows := rows input + valid := rows_valid input + +@[simp] theorem build_vertices (input : GenericGraphTables.Table q) : + (build input).vertices = Enumeration.vertexCount input.vertices input.darts q := rfl + +@[simp] theorem build_darts (input : GenericGraphTables.Table q) : + (build input).darts = Enumeration.dartCount input.darts q := rfl + +private theorem table_rows_congr {n m : Nat} {left right : GraphTables.Rows n m} + (h : left = right) (hl : GraphTables.Valid left) (hr : GraphTables.Valid right) : + (⟨n, m, left, hl⟩ : GraphTables.Table) = ⟨n, m, right, hr⟩ := by + subst right + rfl + +private theorem semantics_rows_congr {n m : Nat} {left right : GraphTables.Rows n m} + (h : left = right) (hl : GraphTables.Valid left) (hr : GraphTables.Valid right) : + GraphTables.semantics (⟨n, m, left, hl⟩ : GraphTables.Table) = + GraphTables.semantics (⟨n, m, right, hr⟩ : GraphTables.Table) := by + subst right + rfl + +theorem build_eq_ofEnumeratedGraph (input : GenericGraphTables.Table q) : + build input = + GraphTables.ofEnumeratedGraph (AlphabetGraph.graph (GenericGraphTables.semantics input)) + (Enumeration.vertexEquiv input.vertices input.darts q) + (Enumeration.dartEquiv input.darts q) Enumeration.labelEquiv := by + exact table_rows_congr (rows_eq_graphRows input) (rows_valid input) + (GraphTables.graphRows_valid _) + +theorem semantics_build (input : GenericGraphTables.Table q) : + GraphTables.semantics (build input) = + GraphTables.enumeratedGraph (AlphabetGraph.graph (GenericGraphTables.semantics input)) + (Enumeration.vertexEquiv input.vertices input.darts q) + (Enumeration.dartEquiv input.darts q) Enumeration.labelEquiv := by + exact (semantics_rows_congr (rows_eq_graphRows input) (rows_valid input) + (GraphTables.graphRows_valid _)).trans (GraphTables.semantics_ofGraph _) + +theorem decode_build (input : GenericGraphTables.Table q) : + GraphTables.decodeTableBits (GraphTables.tableBits (build input)) = + some (GraphTables.ofEnumeratedGraph + (AlphabetGraph.graph (GenericGraphTables.semantics input)) + (Enumeration.vertexEquiv input.vertices input.darts q) + (Enumeration.dartEquiv input.darts q) Enumeration.labelEquiv) := by + rw [GraphTables.decodeTableBits_encoded, build_eq_ofEnumeratedGraph] + +theorem edgeSatisfied_build (input : GenericGraphTables.Table q) + (labeling : QueryIncidence.Vertex (AlphabetGraph.Event (Fin input.darts) (Fin q)) + (AlphabetGraph.Address (Fin input.vertices) (Fin input.darts) (Fin q)) → + QueryIncidence.Label 6) + (dart : QueryIncidence.Dart (AlphabetGraph.Event (Fin input.darts) (Fin q)) 6) : + (GraphTables.semantics (build input)).edgeSatisfied + (fun v => Enumeration.labelEquiv + (labeling ((Enumeration.vertexEquiv input.vertices input.darts q).symm v))) + (Enumeration.dartEquiv input.darts q dart) = + (AlphabetGraph.graph (GenericGraphTables.semantics input)).edgeSatisfied labeling dart := by + rw [semantics_build] + exact GraphTables.enumeratedGraph_edgeSatisfied _ _ _ _ labeling dart + +theorem rejectionCount_build (input : GenericGraphTables.Table q) + (labeling : QueryIncidence.Vertex (AlphabetGraph.Event (Fin input.darts) (Fin q)) + (AlphabetGraph.Address (Fin input.vertices) (Fin input.darts) (Fin q)) → + QueryIncidence.Label 6) : + (GraphTables.semantics (build input)).rejectionCount + (fun v => Enumeration.labelEquiv + (labeling ((Enumeration.vertexEquiv input.vertices input.darts q).symm v))) = + (AlphabetGraph.graph (GenericGraphTables.semantics input)).rejectionCount labeling := by + rw [semantics_build] + exact GraphTables.enumeratedGraph_rejectionCount _ _ _ _ labeling + +theorem perfect_completeness [Nonempty (Fin q)] (input : GenericGraphTables.Table q) + (satisfied : (GenericGraphTables.semantics input).Satisfiable) : + (GraphTables.semantics (build input)).Satisfiable := by + obtain ⟨labeling, accepted⟩ := + AlphabetGraph.perfect_completeness (GenericGraphTables.semantics input) satisfied + refine ⟨fun v => Enumeration.labelEquiv + (labeling ((Enumeration.vertexEquiv input.vertices input.darts q).symm v)), ?_⟩ + intro index + have h := edgeSatisfied_build input labeling + ((Enumeration.dartEquiv input.darts q).symm index) + have index_eq := (Enumeration.dartEquiv input.darts q).apply_symm_apply index + rw [index_eq] at h + exact h.trans (accepted _) + +theorem gap_transfer [Nonempty (Fin q)] (input : GenericGraphTables.Table q) (a b : Nat) + (source : ∀ labeling : Fin input.vertices → Fin q, + a * input.darts ≤ b * (GenericGraphTables.semantics input).rejectionCount labeling) + (labeling : Fin (build input).vertices → GraphTables.Label) : + a * (build input).darts ≤ + (b * 12288) * (GraphTables.semantics (build input)).rejectionCount labeling := by + classical + let lifted := fun vertex => Enumeration.labelEquiv.symm + (labeling (Enumeration.vertexEquiv input.vertices input.darts q vertex)) + have h := AlphabetGraph.gap_transfer (GenericGraphTables.semantics input) a b + (by simpa only [Fintype.card_fin] using source) lifted + rw [Enumeration.card_dart] at h + have counts := rejectionCount_build input lifted + have restored : (fun v : Fin (build input).vertices => Enumeration.labelEquiv + (lifted ((Enumeration.vertexEquiv input.vertices input.darts q).symm v))) = labeling := by + funext v + dsimp only [lifted] + rw [Enumeration.labelEquiv.apply_symm_apply] + exact congrArg labeling + ((Enumeration.vertexEquiv input.vertices input.darts q).apply_symm_apply v) + rw [restored] at counts + rw [← counts] at h + exact h + +theorem rowList_eq_ordered (input : GenericGraphTables.Table q) : + GraphTables.rowList (build input) = + (Enumeration.ordered (Enumeration.dartEquiv input.darts q)).map + (rowFromDart input) := by + change (Vector.ofFn (fun index => rowFromDart input + ((Enumeration.dartEquiv input.darts q).symm index))).toList = + (List.ofFn (Enumeration.dartEquiv input.darts q).symm).map (rowFromDart input) + simp only [Vector.toList_ofFn, List.map_ofFn, Function.comp_def] + +theorem tableWords_eq_ordered (input : GenericGraphTables.Table q) : + GraphTables.tableWords (build input) = + [Enumeration.vertexCount input.vertices input.darts q, + Enumeration.dartCount input.darts q] ++ + (Enumeration.ordered (Enumeration.dartEquiv input.darts q)).flatMap + (fun dart => GraphTables.rowWords (rowFromDart input dart)) := by + simp only [GraphTables.tableWords, rowList_eq_ordered, build_vertices, build_darts, + List.flatMap_map] + +@[simp] theorem rowList_length (input : GenericGraphTables.Table q) : + (GraphTables.rowList (build input)).length = Enumeration.dartCount input.darts q := by + exact GraphTables.rowList_length (build input) + +theorem tableWords_length (input : GenericGraphTables.Table q) : + (GraphTables.tableWords (build input)).length = + 2 + 4098 * Enumeration.dartCount input.darts q := by + exact GraphTables.tableWords_length (build input) + +theorem tableBits_length_le (input : GenericGraphTables.Table q) : + (GraphTables.tableBits (build input)).length ≤ + Enumeration.vertexCount input.vertices input.darts q + + Enumeration.dartCount input.darts q + 2 + Enumeration.dartCount input.darts q * + (Enumeration.vertexCount input.vertices input.darts q + + Enumeration.dartCount input.darts q + 8192) := by + exact GraphTables.tableBits_length_le (build input) + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Table + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/Setup.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/Setup.lean new file mode 100644 index 0000000000000000000000000000000000000000..6888c7bf8a4a5502e66d93b85e06a32866574240 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/Setup.lean @@ -0,0 +1,198 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.GenericGraphTables +import OAI.Combinatorics.IndependentSets.PCP.Input +import OAI.Combinatorics.IndependentSets.Machines.MachineCopy +import OAI.Combinatorics.IndependentSets.Machines.Machine + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.AlphabetTable.Setup + +open Turing +open IndependentSetsGames.Foundations.Complexity +open IndependentSetsGames.Foundations.Hastad + +variable {K Λ σ : Type} [DecidableEq K] + +abbrev Alphabet (_ : K) := Bool + +abbrev Ports (K : Type) := Fin 7 → K + +inductive Label + | copyFirst | copySecond | verticesStart | verticesLoop + | dartsStart | dartsLoop | counterFirst | counterSecond | initialize + deriving DecidableEq + +instance : Fintype Label where + elems := {.copyFirst, .copySecond, .verticesStart, .verticesLoop, + .dartsStart, .dartsLoop, .counterFirst, .counterSecond, .initialize} + complete label := by cases label <;> simp + +def statement (ports : Ports K) (labels : Label → Λ) (exit : Option Λ) : + Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) + | .copyFirst => Reduction.MachineTransfer.loopAt (ports 0) (ports 5) id false + (labels .copyFirst) (some (labels .copySecond)) + | .copySecond => MachineCopy.forkLoop (ports 5) (ports 0) (ports 1) false + (labels .copySecond) (some (labels .verticesStart)) + | .verticesStart => SourceMachine.fieldStart (ports 2) (labels .verticesLoop) + | .verticesLoop => SourceMachine.fieldLoop (ports 1) (ports 2) + (labels .verticesLoop) (some (labels .dartsStart)) + | .dartsStart => SourceMachine.fieldStart (ports 3) (labels .dartsLoop) + | .dartsLoop => SourceMachine.fieldLoop (ports 1) (ports 3) + (labels .dartsLoop) (some (labels .counterFirst)) + | .counterFirst => Reduction.MachineTransfer.loopAt (ports 3) (ports 5) id false + (labels .counterFirst) (some (labels .counterSecond)) + | .counterSecond => MachineCopy.forkLoop (ports 5) (ports 3) (ports 4) false + (labels .counterSecond) (some (labels .initialize)) + | .initialize => .push (ports 6) (fun _ => false) + (.load (fun state => (state.1, none)) (Reduction.MachineTransfer.exitAt (ports 6) exit)) + +def resultTapes (ports : Ports K) (base : K → List Bool) + (n m : Nat) (rows : List Bool) : K → List Bool := + Function.update + (Function.update + (Function.update + (Function.update (Function.update base (ports 1) rows) + (ports 2) (encodeWord n)) (ports 3) (encodeWord m)) + (ports 4) (encodeWord m)) (ports 6) (encodeWord 0) + +theorem resultTapes_other (ports : Ports K) (base : K → List Bool) + (n m : Nat) (rows : List Bool) (tape : K) + (h : ∀ i : Fin 7, i ≠ 0 → i ≠ 5 → tape ≠ ports i) : + resultTapes ports base n m rows tape = base tape := by + simp [resultTapes, h] + +def setupInTime (ports : Ports K) (distinct : Function.Injective ports) + (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ label, program (labels label) = statement ports labels exit label) + (base : K → List Bool) (n m : Nat) (rows : List Bool) + (initial : ∀ i : Fin 7, base (ports i) = + if i = 0 then encodeWord n ++ (encodeWord m ++ rows) else []) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .copyFirst), (ambient, register), base⟩ + (some ⟨exit, (ambient, none), resultTapes ports base n m rows⟩) + (2 * (encodeWord n ++ (encodeWord m ++ rows)).length + n + 3 * m + 11) := by + let input := encodeWord n ++ (encodeWord m ++ rows) + let t₀ := Function.update base (ports 1) input + let t₁ := SourceMachine.afterField (ports 1) (ports 2) t₀ n (encodeWord m ++ rows) + let t₂ := SourceMachine.afterField (ports 1) (ports 3) t₁ m rows + let t₃ := Function.update t₂ (ports 4) (encodeWord m) + have hne {i j : Fin 7} (h : i ≠ j) : ports i ≠ ports j := fun e => h (distinct e) + have run₀ := MachineCopy.copyInTime (ports 0) (ports 1) (ports 5) + (hne (by decide)) (hne (by decide)) (hne (by decide)) false + (labels .copyFirst) (labels .copySecond) (some (labels .verticesStart)) + program (atLabels .copyFirst) (atLabels .copySecond) base + (by simp [initial]) ambient register + have hb0 : base (ports 0) = input := by simpa [input] using initial 0 + have hb1 : base (ports 1) = [] := by simpa using initial 1 + rw [hb0, hb1, List.append_nil] at run₀ + change StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .copyFirst), (ambient, register), base⟩ + (some ⟨some (labels .verticesStart), (ambient, none), t₀⟩) + (2 * (input.length + 1)) at run₀ + have run₁ := SourceMachine.fieldInTime (ports 1) (ports 2) (hne (by decide)) + (labels .verticesStart) (labels .verticesLoop) (some (labels .dartsStart)) + program (atLabels .verticesStart) (atLabels .verticesLoop) + t₀ n (encodeWord m ++ rows) (by simp [t₀, input]) ambient none + have run₂ := SourceMachine.fieldInTime (ports 1) (ports 3) (hne (by decide)) + (labels .dartsStart) (labels .dartsLoop) (some (labels .counterFirst)) + program (atLabels .dartsStart) (atLabels .dartsLoop) + t₁ m rows (by simp [t₁, SourceMachine.afterField, distinct.eq_iff]) ambient none + have h₂m : t₂ (ports 3) = encodeWord m := by + simp [t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, + distinct.eq_iff, initial] + have h₂c : t₂ (ports 4) = [] := by + simp [t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, + distinct.eq_iff, initial] + have h₂s : t₂ (ports 5) = [] := by + simp [t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, + distinct.eq_iff, initial] + have run₃ := MachineCopy.copyInTime (ports 3) (ports 4) (ports 5) + (hne (by decide)) (hne (by decide)) (hne (by decide)) false + (labels .counterFirst) (labels .counterSecond) (some (labels .initialize)) + program (atLabels .counterFirst) (atLabels .counterSecond) t₂ h₂s ambient none + rw [h₂m, h₂c, List.append_nil, encodeWord_length] at run₃ + have h₃e : t₃ (ports 6) = [] := by + simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, + distinct.eq_iff, initial] + have hresult : Function.update t₃ (ports 6) [false] = + resultTapes ports base n m rows := by + funext tape + by_cases h1 : tape = ports 1 + · subst tape; simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, + SourceMachine.fieldTapes, resultTapes, distinct.eq_iff] + · by_cases h2 : tape = ports 2 + · subst tape; simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, + SourceMachine.fieldTapes, resultTapes, distinct.eq_iff, initial] + · by_cases h3 : tape = ports 3 + · subst tape; simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, + SourceMachine.fieldTapes, resultTapes, distinct.eq_iff, initial] + · simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, + resultTapes, Function.update_apply, h1, h2, h3, encodeWord] + have run₄ : StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .initialize), (ambient, none), t₃⟩ + (some ⟨exit, (ambient, none), resultTapes ports base n m rows⟩) 1 := { + steps := 1 + evals_in_steps := by + change some (TM2.stepAux (program (labels .initialize)) (ambient, none) t₃) = _ + rw [atLabels] + cases exit <;> simp [statement, TM2.stepAux, Reduction.MachineTransfer.exitAt, + h₃e, hresult] + steps_le_m := Nat.le_refl _ } + let r₀₁ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₀ run₁ + let r₀₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₀₁ run₂ + let r₀₁₂₃ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₀₁₂ run₃ + let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₀₁₂₃ run₄ + exact { + toEvalsTo := run.toEvalsTo + steps_le_m := by + have h := run.steps_le_m + dsimp [input] at h + omega } + +def tableSetupInTime {q : Nat} (ports : Ports K) (distinct : Function.Injective ports) + (labels : Label → Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) + (atLabels : ∀ label, program (labels label) = statement ports labels exit label) + (base : K → List Bool) (table : GenericGraphTables.Table q) + (initial : ∀ i : Fin 7, base (ports i) = + if i = 0 then GenericGraphTables.tableBits table else []) + (ambient : σ) (register : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some (labels .copyFirst), (ambient, register), base⟩ + (some ⟨exit, (ambient, none), resultTapes ports base table.vertices table.darts + (encodeWords ((GenericGraphTables.rowList table).flatMap GenericGraphTables.rowWords))⟩) + (6 * (GenericGraphTables.tableBits table).length + 11) := by + have hb := Input.tableBits_header table + let run := setupInTime ports distinct labels exit program atLabels base + table.vertices table.darts + (encodeWords ((GenericGraphTables.rowList table).flatMap GenericGraphTables.rowWords)) + (by intro i; rw [initial i, hb]) ambient register + have hn := GenericGraphTables.vertices_le_tableBits_length table + have hm := GenericGraphTables.darts_le_tableBits_length table + exact { + toEvalsTo := run.toEvalsTo + steps_le_m := by + have h := run.steps_le_m + have hlen := congrArg List.length hb + omega } + +def program (ports : Ports K) : Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) := + statement ports id none + +def machine : FinTM2 where + K := Fin 7 + k₀ := 0 + k₁ := 1 + Γ _ := Bool + Λ := Label + main := .copyFirst + σ := Unit × Option Bool + initialState := ((), none) + m := program id + +end IndependentSetsGames.Foundations.PCP.AlphabetTable.Setup + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/TableIteration.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/TableIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc39c4025385c49c17d767c29d77307cd6d1bb49 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/TableIteration.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Encoding.FinalTableFormula +import OAI.Combinatorics.IndependentSets.Machines.RawInitialMachineBudget +import OAI.Combinatorics.IndependentSets.Machines.MachineComposition + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.TableIteration + +open RoundTables +open Target Complexity + +def run (H : BaseTable) : Nat → Input → Input := AmplificationIteration.run (step H) + +def runTables (H : BaseTable) : Nat → GraphTables.Table → GraphTables.Table := + AmplificationIteration.run (build H) + +theorem run_val (H : BaseTable) (n : Nat) (input : Input) : + (run H n input).val = runTables H n input.val := by + induction n with + | zero => rfl + | succ n ih => + change build H (run H n input).val = build H (runTables H n input.val) + rw [ih] + +def iterationCount (F : Formula) : Nat := AmplificationIteration.rounds (size (initial F)) + +def output (H : BaseTable) (F : Formula) : Input := run H (iterationCount F) (initial F) + +def outputTable (H : BaseTable) (F : Formula) : GraphTables.Table := + runTables H (iterationCount F) (RawInitialTables.table F) + +theorem output_val (H : BaseTable) (F : Formula) : (output H F).val = outputTable H F := + run_val H (iterationCount F) (initial F) + +def gapMap (H : BaseTable) (F : Formula) : Formula := FinalTableFormula.output (outputTable H F) + +opaque degreeData : {n : Nat // sizeFactor ≤ 2 ^ n} := + ⟨AmplificationIteration.rounds sizeFactor, (AmplificationIteration.rounds_large sizeFactor).le⟩ + +def polynomialDegree : Nat := degreeData.val + +theorem sizeFactor_le_power : sizeFactor ≤ 2 ^ polynomialDegree := + degreeData.property + +theorem run_completeness (H : BaseTable) (n : Nat) (input : Input) + (sat : Satisfiable input) : Satisfiable (run H n input) := + AmplificationIteration.run_preserves (step H) Satisfiable (step_completeness H) n input sat + +theorem output_completeness (H : BaseTable) (F : Formula) (sat : F.Satisfiable) : + Satisfiable (output H F) := + run_completeness H _ _ ((initial_satisfiable_iff F).mpr sat) + +theorem gapMap_completeness (H : BaseTable) (F : Formula) (sat : F.Satisfiable) : + (gapMap H F).Satisfiable := by + apply (FinalTableFormula.satisfiable_iff (outputTable H F)).mpr + rw [← output_val] + exact output_completeness H F sat + +theorem output_darts_positive (H : BaseTable) (F : Formula) : 0 < (outputTable H F).darts := by + rw [← output_val] + exact (output H F).property + +theorem gapMap_nonempty (H : BaseTable) (F : Formula) : (gapMap H F).clauses ≠ [] := + FinalTableFormula.nonempty (outputTable H F) (output_darts_positive H F) + +theorem run_size (H : BaseTable) (n : Nat) (input : Input) : + size (run H n input) ≤ sizeFactor ^ n * size input := + AmplificationIteration.run_size (step H) size sizeFactor (step_size H) n input + +theorem output_size (H : BaseTable) (F : Formula) : + size (output H F) ≤ (2 * size (initial F)) ^ polynomialDegree * size (initial F) := + AmplificationIteration.run_size_polynomial (step H) size (size_positive (initial F)) + sizeFactor_le_power (step_size H) (initial F) + +theorem initial_size_le (F : Formula) : size (initial F) ≤ 7 * (formulaBits F).length := + RawInitialMachineBudget.graph_size_bound F + +theorem output_size_le_input (H : BaseTable) (F : Formula) : + (outputTable H F).vertices + (outputTable H F).darts ≤ + (14 * (formulaBits F).length) ^ polynomialDegree * (7 * (formulaBits F).length) := by + rw [← output_val] + have h := initial_size_le F + exact (output_size H F).trans + (Nat.mul_le_mul (Nat.pow_le_pow_left (by omega) _) h) + +noncomputable def tableSizePolynomial : Polynomial Nat := + (Polynomial.C 14 * Polynomial.X) ^ polynomialDegree * (Polynomial.C 7 * Polynomial.X) + +theorem tableSizePolynomial_eval (N : Nat) : + tableSizePolynomial.eval N = (14 * N) ^ polynomialDegree * (7 * N) := by + simp only [tableSizePolynomial, Polynomial.eval_mul, Polynomial.eval_pow, + Polynomial.eval_C, Polynomial.eval_X] + +noncomputable def tableBitsPolynomial : Polynomial Nat := + (GraphTableComplexity.encodingPolynomial 64).comp tableSizePolynomial + +theorem output_bits_le (H : BaseTable) (F : Formula) : + (GraphTables.tableBits (outputTable H F)).length ≤ tableBitsPolynomial.eval (formulaBits F).length := by + rw [tableBitsPolynomial, Polynomial.eval_comp, tableSizePolynomial_eval] + exact GraphTableComplexity.bits_le_of_size_le _ (output_size_le_input H F) + +noncomputable def formulaBitsPolynomial : Polynomial Nat := + FinalTableFormula.sizePolynomial.comp tableBitsPolynomial + +theorem gapMap_bits_le (H : BaseTable) (F : Formula) : + (formulaBits (gapMap H F)).length ≤ formulaBitsPolynomial.eval (formulaBits F).length := by + rw [formulaBitsPolynomial, Polynomial.eval_comp] + exact (FinalTableFormula.formulaBits_length_le_polynomial (outputTable H F)).trans + (MachineComposition.natPolynomial_eval_mono _ (output_bits_le H F)) + +end IndependentSetsGames.Foundations.PCP.TableIteration + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/TargetLC.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/TargetLC.lean new file mode 100644 index 0000000000000000000000000000000000000000..e61e61e830e984e8b4a2e6766cc367a80b457aef --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/TargetLC.lean @@ -0,0 +1,99 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.LCTable + +namespace OAI + +noncomputable section + +namespace LargeIndependentSets.LabelCoverData +open scoped Classical +variable {U V L R C U' V' C' : Type} + +def reindex (lc : LabelCoverData U V L R C) (eu : U ≃ U') (ev : V ≃ V') (ec : C ≃ C') : + LabelCoverData U' V' L R C' where + left c := eu (lc.left (ec.symm c)) + right c := ev (lc.right (ec.symm c)) + project c := lc.project (ec.symm c) + +lemma reindex_complete (lc : LabelCoverData U V L R C) (eu : U ≃ U') (ev : V ≃ V') (ec : C ≃ C') + (h : ∃ l r, lc.Satisfied l r) : ∃ l r, (lc.reindex eu ev ec).Satisfied l r := by + obtain ⟨l,r,hr⟩ := h + refine ⟨fun u => l (eu.symm u),fun v => r (ev.symm v),?_⟩ + intro c + simpa only [reindex,Equiv.symm_apply_apply] using hr (ec.symm c) + +lemma reindex_sound [Fintype C] [Fintype C'] (lc : LabelCoverData U V L R C) + (eu : U ≃ U') (ev : V ≃ V') (ec : C ≃ C') {σ : ℝ} (h : lc.Sound σ) : + (lc.reindex eu ev ec).Sound σ := by + intro l r + have hs := h (fun u => l (eu u)) (fun v => r (ev v)) + have he : (Finset.univ.filter (fun c : C => lc.project c (l (eu (lc.left c)))=r (ev (lc.right c)))).card = + (Finset.univ.filter (fun c : C' => (lc.reindex eu ev ec).project c (l ((lc.reindex eu ev ec).left c))= + r ((lc.reindex eu ev ec).right c))).card := by + apply Finset.card_bij (fun c _ => ec c) + · intro c hc + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _,?_⟩ + change lc.project (ec.symm (ec c)) (l (eu (lc.left (ec.symm (ec c))))) = + r (ev (lc.right (ec.symm (ec c)))) + simpa only [Equiv.symm_apply_apply] using (Finset.mem_filter.mp hc).2 + · intro c hc d hd he; exact ec.injective he + · intro c hc + refine ⟨ec.symm c,?_,Equiv.apply_symm_apply _ _⟩ + apply Finset.mem_filter.mpr + exact ⟨Finset.mem_univ _,(Finset.mem_filter.mp hc).2⟩ + simpa only [he,Fintype.card_congr ec] using hs + +end LargeIndependentSets.LabelCoverData + +namespace LargeIndependentSets.TargetLC +open IndependentSetsGames.Foundations IndependentSetsGames.Foundations.Complexity +open IndependentSetsCut.CounterMachine +open Target PCP Hastad.SourceContexts Hastad.SourceGame UniformLC +open scoped Classical BigOperators + +abbrev Input := {F : Target.Formula // F.clauses≠[]} + +lemma clauses_pos (F : Input) : 0 RawInitialTables.eventOrder F)).trans finFunctionFinEquiv + +def table (F : Input) : Table (J u) (I u) where + nu := F.val.clauses.length^u + nv := F.val.«variables»^u + ne := (F.val.clauses.length*3)^u + hu := pow_pos (clauses_pos F) _ + hv := pow_pos (vars_pos F) _ + he := pow_pos (Nat.mul_pos (clauses_pos F) (by decide)) _ + left e := finFunctionFinEquiv ((LCInput.labelCover F.val u).left ((eventEquiv u F.val).symm e)) + right e := finFunctionFinEquiv ((LCInput.labelCover F.val u).right ((eventEquiv u F.val).symm e)) + project e := (LCInput.labelCover F.val u).project ((eventEquiv u F.val).symm e) + +lemma table_lc (F : Input) : (table u F).lc = + (LCInput.labelCover F.val u).reindex finFunctionFinEquiv finFunctionFinEquiv (eventEquiv u F.val) := rfl + +lemma complete (F : Input) (h : F.val.Satisfiable) : ∃ l r, (table u F).lc.Satisfied l r := by + rw [table_lc] + exact LabelCoverData.reindex_complete _ _ _ _ (LCInput.complete F.val u h) + +lemma sound (F : Input) {σ : ℝ} (h : (LCInput.labelCover F.val u).Sound σ) : (table u F).lc.Sound σ := by + rw [table_lc] + exact LabelCoverData.reindex_sound _ _ _ _ h + +lemma project_apply (F : Target.Formula) (e : Fin u → RandomEvent F) (j : J u) (k : Fin u) : + (LCInput.labelCover F u).project e j k= + answerAt (LCInput.repair (clauseAt F (e k).1) (j k)) (e k).2 := by + change answerAt (LCInput.repair (clauseAt F (e k).1) (j k)) + (canonicalSlot (clauseAt F (e k).1) (nameAt (clauseAt F (e k).1) (e k).2)) = _ + apply (localConsistent_eq_true_iff _ _).mp (LCInput.repair_spec _ _).2 + exact canonicalSlot_name _ _ ⟨(e k).2,rfl⟩ + +end LargeIndependentSets.TargetLC + +end + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/VerifierCNF.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/VerifierCNF.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b077daed63410fc0f41f6c3068430f2f68811ac --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/VerifierCNF.lean @@ -0,0 +1,639 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.PCP.NameCompaction + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.VerifierToCNF + +open Target + +abbrev BoolTriple := Bool × Bool × Bool + +def tripleValue (t : BoolTriple) : Bool := (t.1 || t.2.1) || t.2.2 + +def chainView : List Bool → List Bool → List BoolTriple + | [a, b, c], [] => [(a, b, c)] + | a :: b :: rest, y :: ys => (a, b, y) :: chainView ((!y) :: rest) ys + | _, _ => [] + +def fillBits (bits : List Bool) : List Bool := + match bits with + | a :: b :: c :: d :: rest => + (!(a || b)) :: fillBits ((a || b) :: c :: d :: rest) + | _ => [] +termination_by bits.length +decreasing_by simp_wf + +theorem chainView_length (bits ys : List Bool) + (size : bits.length = ys.length + 3) : + (chainView bits ys).length = ys.length + 1 := by + induction ys generalizing bits with + | nil => + match bits with + | [a, b, c] => rfl + | [] => simp at size + | [_] => simp at size + | [_, _] => simp at size + | _ :: _ :: _ :: _ :: rest => + simp only [List.length_cons, List.length_nil] at size + omega + | cons y ys ih => + match bits with + | [] => simp at size + | [_] => simp only [List.length_cons, List.length_nil] at size; omega + | a :: b :: rest => + have smaller : ((!y) :: rest).length = ys.length + 3 := by + simp only [List.length_cons] at * + omega + have h := ih ((!y) :: rest) smaller + simpa only [chainView, List.length_cons] using congrArg (fun n => n + 1) h + +theorem chainView_sound (bits ys : List Bool) + (size : bits.length = ys.length + 3) + (accepted : (chainView bits ys).all tripleValue = true) : bits.any id = true := by + induction ys generalizing bits with + | nil => + match bits with + | [a, b, c] => simpa [chainView, tripleValue, Bool.or_assoc] using accepted + | [] => simp at size + | [_] => simp at size + | [_, _] => simp at size + | _ :: _ :: _ :: _ :: rest => + simp only [List.length_cons, List.length_nil] at size + omega + | cons y ys ih => + match bits with + | [] => simp at size + | [_] => simp only [List.length_cons, List.length_nil] at size; omega + | a :: b :: rest => + have smaller : ((!y) :: rest).length = ys.length + 3 := by + simp only [List.length_cons] at * + omega + have accepted' : tripleValue (a, b, y) = true ∧ + (chainView ((!y) :: rest) ys).all tripleValue = true := by + simpa only [chainView, List.all_cons, Bool.and_eq_true] using accepted + have tailAccepted := ih ((!y) :: rest) smaller accepted'.2 + cases a <;> cases b <;> cases y <;> simp_all [tripleValue] + +theorem fillBits_length (bits : List Bool) (size : 3 ≤ bits.length) : + (fillBits bits).length + 3 = bits.length := by + match bits with + | [] => simp at size + | [_] => simp at size + | [_, _] => simp at size + | [a, b, c] => simp [fillBits] + | a :: b :: c :: d :: rest => + have ih := fillBits_length ((a || b) :: c :: d :: rest) (by simp) + rw [fillBits] + change (fillBits ((a || b) :: c :: d :: rest)).length + 1 + 3 = rest.length + 4 + simp only [List.length_cons] at ih + omega +termination_by bits.length +decreasing_by simp_wf + +theorem fillBits_correct (bits : List Bool) (size : 3 ≤ bits.length) : + (chainView bits (fillBits bits)).all tripleValue = true ↔ bits.any id = true := by + match bits with + | [] => simp at size + | [_] => simp at size + | [_, _] => simp at size + | [a, b, c] => simp [fillBits, chainView, tripleValue, Bool.or_assoc] + | a :: b :: c :: d :: rest => + have ih := fillBits_correct ((a || b) :: c :: d :: rest) (by simp) + have tautology : tripleValue (a, b, !(a || b)) = true := by + cases a <;> cases b <;> rfl + rw [fillBits] + simp only [chainView, List.all_cons, Bool.not_not] + rw [tautology] + simp only [Bool.true_and] + simpa [Bool.or_assoc] using ih +termination_by bits.length +decreasing_by simp_wf + +theorem zero_false_count_iff_all (bits : List Bool) : + bits.count false = 0 ↔ bits.all id = true := by + induction bits with + | nil => simp + | cons b bits ih => cases b <;> simp [ih] + +theorem chainView_failed (bits ys : List Bool) + (size : bits.length = ys.length + 3) (failed : bits.any id = false) : + 1 ≤ ((chainView bits ys).map tripleValue).count false := by + by_contra none + have zero : ((chainView bits ys).map tripleValue).count false = 0 := by omega + have all := (zero_false_count_iff_all _).mp zero + have accepted : (chainView bits ys).all tripleValue = true := by + simpa only [List.all_map, Function.comp_def, id_eq] using all + have impossible := chainView_sound bits ys size accepted + rw [failed] at impossible + contradiction + +abbrev Pattern (q : Nat) := Fin q → Bool + +def patterns : (q : Nat) → List (Pattern q) + | 0 => [Fin.elim0] + | q + 1 => (patterns q).flatMap (fun p => [Fin.cases false p, Fin.cases true p]) + +theorem flatMap_pair_length {α β : Type*} (xs : List α) (f g : α → β) : + (xs.flatMap (fun x => [f x, g x])).length = 2 * xs.length := by + induction xs with + | nil => rfl + | cons x xs ih => + simp only [List.flatMap_cons, List.length_append, List.length_cons, + List.length_nil, ih] + omega + +theorem patterns_length (q : Nat) : (patterns q).length = 2 ^ q := by + induction q with + | zero => rfl + | succ q ih => + rw [patterns, flatMap_pair_length, ih, Nat.pow_succ] + exact Nat.mul_comm _ _ + +theorem mem_patterns (q : Nat) (p : Pattern q) : p ∈ patterns q := by + induction q with + | zero => + have h : p = Fin.elim0 := by funext i; exact Fin.elim0 i + simp [patterns, h] + | succ q ih => + let tail : Pattern q := fun i => p i.succ + have htail : tail ∈ patterns q := ih tail + have prefixEquality : Fin.cases (p 0) tail = p := by + funext i + exact Fin.cases rfl (fun _ => rfl) i + apply List.mem_flatMap.mpr + refine ⟨tail, htail, ?_⟩ + cases h : p 0 with + | false => + have hp : Fin.cases false tail = p := by simpa only [h] using prefixEquality + exact List.mem_cons.mpr (Or.inl hp.symm) + | true => + have hp : Fin.cases true tail = p := by simpa only [h] using prefixEquality + exact List.mem_cons.mpr (Or.inr (List.mem_cons.mpr (Or.inl hp.symm))) + +abbrev PatternIndex (q : Nat) := Fin (patterns q).length +def patternAt (q : Nat) (p : PatternIndex q) : Pattern q := (patterns q)[p.val] + +theorem patternAt_surjective (q : Nat) (bits : Pattern q) : + ∃ p : PatternIndex q, patternAt q p = bits := by + obtain ⟨i, hi, h⟩ := List.getElem_of_mem (mem_patterns q bits) + exact ⟨⟨i, hi⟩, h⟩ + +structure FiniteVerifier (q : Nat) where + «variables» : Nat + events : Nat + query : Fin events → Fin q → Fin «variables» + accepts : Fin events → Pattern q → Bool + +def eventValue {q : Nat} (V : FiniteVerifier q) (A : Fin V.«variables» → Bool) + (e : Fin V.events) : Bool := V.accepts e (fun i => A (V.query e i)) + +def rejectedEventCount {q : Nat} (V : FiniteVerifier q) (A : Fin V.«variables» → Bool) : Nat := + ((List.finRange V.events).map (eventValue V A)).count false + +def auxiliaryCount {q : Nat} (V : FiniteVerifier q) : Nat := + V.events * (patterns q).length * (q - 3) + +def outputVariables {q : Nat} (V : FiniteVerifier q) : Nat := V.«variables» + auxiliaryCount V + +def oldIndex {q : Nat} (V : FiniteVerifier q) (v : Fin V.«variables») : Fin (outputVariables V) := + Fin.castAdd (auxiliaryCount V) v + +def freshIndex {q : Nat} (V : FiniteVerifier q) (e : Fin V.events) + (p : PatternIndex q) (j : Fin (q - 3)) : Fin (outputVariables V) := + Fin.natAdd V.«variables» (finProdFinEquiv (finProdFinEquiv (e, p), j)) + +theorem freshIndex_value {q : Nat} (V : FiniteVerifier q) (e : Fin V.events) + (p : PatternIndex q) (j : Fin (q - 3)) : + (freshIndex V e p j).val = + V.«variables» + ((e.val * (patterns q).length + p.val) * (q - 3) + j.val) := by + simp [freshIndex, Fin.natAdd, finProdFinEquiv, Nat.mul_comm, Nat.add_comm] + +def liftLiteral {q : Nat} (V : FiniteVerifier q) (l : Literal V.«variables») : + Literal (outputVariables V) := ⟨oldIndex V l.variableIndex, l.positive⟩ + +def forbiddenLiteral {q : Nat} (V : FiniteVerifier q) (e : Fin V.events) + (p : PatternIndex q) (i : Fin q) : Literal V.«variables» := + ⟨V.query e i, !(patternAt q p i)⟩ + +def forbiddenClause {q : Nat} (V : FiniteVerifier q) (e : Fin V.events) + (p : PatternIndex q) : List (Literal (outputVariables V)) := + List.ofFn (fun i => liftLiteral V (forbiddenLiteral V e p i)) + +def auxiliaryNames {q : Nat} (V : FiniteVerifier q) (e : Fin V.events) + (p : PatternIndex q) : List (Fin (outputVariables V)) := + List.ofFn (freshIndex V e p) + +def splitLong {n : Nat} : List (Literal n) → List (Fin n) → List (Clause n) + | [a, b, c], [] => [#v[a, b, c]] + | a :: b :: rest, y :: ys => + #v[a, b, ⟨y, true⟩] :: splitLong (⟨y, false⟩ :: rest) ys + | _, _ => [] + +def tautology {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) (e : Fin V.events) : + Clause (outputVariables V) := + let v := oldIndex V (V.query e ⟨0, by omega⟩) + #v[⟨v, true⟩, ⟨v, false⟩, ⟨v, true⟩] + +def block {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) (e : Fin V.events) + (p : PatternIndex q) : List (Clause (outputVariables V)) := + if V.accepts e (patternAt q p) then List.replicate (q - 2) (tautology V hq e) + else splitLong (forbiddenClause V e p) (auxiliaryNames V e p) + +def eventBlock {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) (e : Fin V.events) : + List (Clause (outputVariables V)) := + (List.finRange (patterns q).length).flatMap (block V hq e) + +def convert {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) : Formula where + «variables» := outputVariables V + clauses := (List.finRange V.events).flatMap (eventBlock V hq) + +def clauseFailures {n : Nat} (clauses : List (Clause n)) (A : Fin n → Bool) : Nat := + (clauses.map (fun c => c.eval A)).count false + +theorem splitLong_values {n : Nat} (ls : List (Literal n)) (ys : List (Fin n)) + (A : Fin n → Bool) : + (splitLong ls ys).map (fun c => c.eval A) = + (chainView (ls.map (fun l => l.eval A)) (ys.map A)).map tripleValue := by + induction ys generalizing ls with + | nil => + match ls with + | [] => rfl + | [_] => rfl + | [_, _] => rfl + | [a, b, c] => rfl + | _ :: _ :: _ :: _ :: _ => rfl + | cons y ys ih => + match ls with + | [] => rfl + | [_] => rfl + | a :: b :: rest => + have h := ih (⟨y, false⟩ :: rest) + simp only [splitLong, List.map_cons, chainView] + apply congrArg₂ List.cons + · rfl + · simpa only [List.map_cons, Literal.eval, Bool.false_eq_true, ↓reduceIte] using h + +theorem splitLong_length {n : Nat} (ls : List (Literal n)) (ys : List (Fin n)) + (size : ls.length = ys.length + 3) : (splitLong ls ys).length = ys.length + 1 := by + have values := congrArg List.length (splitLong_values ls ys (fun _ => false)) + simp only [List.length_map] at values + rw [values] + have h := chainView_length (ls.map (fun l => l.eval (fun _ => false))) + (ys.map (fun _ => false)) (by simpa only [List.length_map] using size) + simpa only [List.length_map] using h + +def restrictAssignment {q : Nat} (V : FiniteVerifier q) + (B : Fin (outputVariables V) → Bool) : Fin V.«variables» → Bool := + fun v => B (oldIndex V v) + +def mismatchBits {q : Nat} (V : FiniteVerifier q) (A : Fin V.«variables» → Bool) + (e : Fin V.events) (p : PatternIndex q) : List Bool := + List.ofFn (fun i => (forbiddenLiteral V e p i).eval A) + +@[simp] theorem mismatchBits_length {q : Nat} (V : FiniteVerifier q) + (A : Fin V.«variables» → Bool) (e : Fin V.events) (p : PatternIndex q) : + (mismatchBits V A e p).length = q := by simp [mismatchBits] + +theorem forbiddenLiteral_false {q : Nat} (V : FiniteVerifier q) (A : Fin V.«variables» → Bool) + (e : Fin V.events) (p : PatternIndex q) (i : Fin q) : + (forbiddenLiteral V e p i).eval A = false ↔ A (V.query e i) = patternAt q p i := by + cases hp : patternAt q p i <;> cases ha : A (V.query e i) <;> + simp [forbiddenLiteral, Literal.eval, hp, ha] + +theorem forbiddenClause_values {q : Nat} (V : FiniteVerifier q) + (B : Fin (outputVariables V) → Bool) (e : Fin V.events) (p : PatternIndex q) : + (forbiddenClause V e p).map (fun l => l.eval B) = + mismatchBits V (restrictAssignment V B) e p := by + simp [forbiddenClause, mismatchBits, List.map_ofFn, Function.comp_def, liftLiteral, Literal.eval, + restrictAssignment] + +theorem mismatchBits_false {q : Nat} (V : FiniteVerifier q) (A : Fin V.«variables» → Bool) + (e : Fin V.events) (p : PatternIndex q) + (actual : ∀ i, A (V.query e i) = patternAt q p i) : + (mismatchBits V A e p).any id = false := by + apply List.any_eq_false.mpr + intro b hb + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp hb + have h := (forbiddenLiteral_false V A e p i).mpr (actual i) + simp [h] + +theorem mismatchBits_true {q : Nat} (V : FiniteVerifier q) (A : Fin V.«variables» → Bool) + (e : Fin V.events) (p : PatternIndex q) (honest : eventValue V A e = true) + (rejected : V.accepts e (patternAt q p) = false) : + (mismatchBits V A e p).any id = true := by + cases h : (mismatchBits V A e p).any id with + | true => rfl + | false => + have none := List.any_eq_false.mp h + have equal : (fun i => A (V.query e i)) = patternAt q p := by + funext i + apply (forbiddenLiteral_false V A e p i).mp + have hi := none ((forbiddenLiteral V e p i).eval A) + (List.mem_ofFn.mpr ⟨i, rfl⟩) + cases hv : (forbiddenLiteral V e p i).eval A <;> simp_all + have impossible : V.accepts e (patternAt q p) = true := by + simpa only [eventValue, equal] using honest + rw [rejected] at impossible + contradiction + +theorem mismatchFill_length {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) (e : Fin V.events) (p : PatternIndex q) : + (fillBits (mismatchBits V A e p)).length = q - 3 := by + have h := fillBits_length (mismatchBits V A e p) (by simpa using hq) + rw [mismatchBits_length] at h + omega + +def mismatchFill {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) (e : Fin V.events) (p : PatternIndex q) + (j : Fin (q - 3)) : Bool := + (fillBits (mismatchBits V A e p))[j.val]'(by + rw [mismatchFill_length V hq A e p] + exact j.isLt) + +def extendAssignment {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) : Fin (outputVariables V) → Bool := + Fin.addCases A (fun k : Fin (auxiliaryCount V) => + let pair : Fin (V.events * (patterns q).length) × Fin (q - 3) := finProdFinEquiv.symm k + let ep : Fin V.events × PatternIndex q := finProdFinEquiv.symm pair.1 + mismatchFill V hq A ep.1 ep.2 pair.2) + +@[simp] theorem extend_old {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) (v : Fin V.«variables») : + extendAssignment V hq A (oldIndex V v) = A v := by + simp [extendAssignment, oldIndex] + +@[simp] theorem extend_fresh {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) (e : Fin V.events) (p : PatternIndex q) + (j : Fin (q - 3)) : + extendAssignment V hq A (freshIndex V e p j) = mismatchFill V hq A e p j := by + unfold extendAssignment freshIndex auxiliaryCount + rw [Fin.addCases_right] + simp only [Equiv.symm_apply_apply] + +@[simp] theorem restrict_extend {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) : restrictAssignment V (extendAssignment V hq A) = A := by + funext v + exact extend_old V hq A v + +theorem ofFn_getElem_of_length {α : Type*} (xs : List α) (n : Nat) (h : xs.length = n) : + List.ofFn (fun i : Fin n => xs[i.val]'(by rw [h]; exact i.isLt)) = xs := by + subst n + exact List.ofFn_getElem + +theorem extended_auxiliary_values {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) (e : Fin V.events) (p : PatternIndex q) : + (auxiliaryNames V e p).map (extendAssignment V hq A) = fillBits (mismatchBits V A e p) := by + simp only [auxiliaryNames, List.map_ofFn, Function.comp_def, extend_fresh, mismatchFill] + exact ofFn_getElem_of_length _ _ (mismatchFill_length V hq A e p) + +theorem tautology_satisfied {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (e : Fin V.events) (B : Fin (outputVariables V) → Bool) : + (tautology V hq e).eval B = true := by + simp [tautology, Clause.eval, Literal.eval] + +theorem block_length {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (e : Fin V.events) (p : PatternIndex q) : (block V hq e p).length = q - 2 := by + by_cases accepted : V.accepts e (patternAt q p) = true + · simp [block, accepted] + · simp only [block, accepted, Bool.false_eq_true, ↓reduceIte] + have size : (forbiddenClause V e p).length = (auxiliaryNames V e p).length + 3 := by + simp only [forbiddenClause, auxiliaryNames, List.length_ofFn] + omega + have h := splitLong_length (forbiddenClause V e p) (auxiliaryNames V e p) size + have auxLength : (auxiliaryNames V e p).length = q - 3 := by simp [auxiliaryNames] + rw [auxLength] at h + omega + +theorem block_honest {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) (e : Fin V.events) (p : PatternIndex q) + (honest : eventValue V A e = true) : + (block V hq e p).all (fun c => c.eval (extendAssignment V hq A)) = true := by + cases accepted : V.accepts e (patternAt q p) with + | true => simp [block, accepted, tautology_satisfied] + | false => + have good := (fillBits_correct (mismatchBits V A e p) (by simpa using hq)).mpr + (mismatchBits_true V A e p honest accepted) + have values := splitLong_values (forbiddenClause V e p) (auxiliaryNames V e p) + (extendAssignment V hq A) + rw [forbiddenClause_values, restrict_extend, extended_auxiliary_values] at values + have all := congrArg (fun bs : List Bool => bs.all id) values + simp only [List.all_map, Function.comp_def, id_eq] at all + simpa only [block, accepted, Bool.false_eq_true, ↓reduceIte] using all.trans good + +theorem length_flatMap_constant {α β : Type*} (xs : List α) (f : α → List β) (k : Nat) + (lengths : ∀ x ∈ xs, (f x).length = k) : (xs.flatMap f).length = xs.length * k := by + induction xs with + | nil => simp + | cons x xs ih => + have hx := lengths x (by simp) + have ht := ih (fun y hy => lengths y (by simp [hy])) + simp only [List.flatMap_cons, List.length_append, List.length_cons, hx, ht, + Nat.add_mul, Nat.one_mul] + omega + +theorem eventBlock_length {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (e : Fin V.events) : (eventBlock V hq e).length = 2 ^ q * (q - 2) := by + rw [eventBlock, length_flatMap_constant _ _ (q - 2) (fun p _ => block_length V hq e p)] + simp only [List.length_finRange, patterns_length] + +theorem convert_clause_count {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) : + (convert V hq).clauses.length = V.events * (2 ^ q * (q - 2)) := by + change ((List.finRange V.events).flatMap (eventBlock V hq)).length = _ + rw [length_flatMap_constant _ _ _ (fun e _ => eventBlock_length V hq e)] + rw [List.length_finRange] + +theorem convert_nonempty {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (eventsPositive : 0 < V.events) : (convert V hq).clauses ≠ [] := by + have p : 0 < (convert V hq).clauses.length := by + rw [convert_clause_count] + exact Nat.mul_pos eventsPositive (Nat.mul_pos (Nat.pow_pos (by decide)) (by omega)) + intro empty + simp only [empty, List.length_nil] at p + omega + +theorem convert_completeness {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (A : Fin V.«variables» → Bool) (honest : ∀ e, eventValue V A e = true) : + (convert V hq).Satisfiable := by + refine ⟨extendAssignment V hq A, fun c hc => ?_⟩ + obtain ⟨e, _, hc⟩ := List.mem_flatMap.mp hc + obtain ⟨p, _, hc⟩ := List.mem_flatMap.mp hc + exact List.all_eq_true.mp (block_honest V hq A e p (honest e)) c hc + +theorem clauseFailures_append {n : Nat} (xs ys : List (Clause n)) (A : Fin n → Bool) : + clauseFailures (xs ++ ys) A = clauseFailures xs A + clauseFailures ys A := by + simp [clauseFailures, List.map_append, List.count_append] + +theorem clauseFailures_le_flatMap {α : Type*} {n : Nat} (xs : List α) + (f : α → List (Clause n)) (A : Fin n → Bool) (x : α) (hx : x ∈ xs) : + clauseFailures (f x) A ≤ clauseFailures (xs.flatMap f) A := by + induction xs with + | nil => simp at hx + | cons y ys ih => + simp only [List.mem_cons] at hx + rcases hx with rfl | hx + · simp only [List.flatMap_cons, clauseFailures_append] + omega + · have h := ih hx + simp only [List.flatMap_cons, clauseFailures_append] + omega + +theorem block_failed {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (B : Fin (outputVariables V) → Bool) (e : Fin V.events) (p : PatternIndex q) + (rejected : V.accepts e (patternAt q p) = false) + (actual : ∀ i, restrictAssignment V B (V.query e i) = patternAt q p i) : + 1 ≤ clauseFailures (block V hq e p) B := by + have bitsFalse := mismatchBits_false V (restrictAssignment V B) e p actual + have size : ((forbiddenClause V e p).map (fun l => l.eval B)).length = + ((auxiliaryNames V e p).map B).length + 3 := by + simp only [List.length_map, forbiddenClause, auxiliaryNames, List.length_ofFn] + omega + have failed := chainView_failed ((forbiddenClause V e p).map (fun l => l.eval B)) + ((auxiliaryNames V e p).map B) size (by + rw [forbiddenClause_values] + exact bitsFalse) + simpa only [block, rejected, Bool.false_eq_true, ↓reduceIte, clauseFailures, + splitLong_values] using failed + +theorem eventBlock_failed {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (B : Fin (outputVariables V) → Bool) (e : Fin V.events) + (rejected : eventValue V (restrictAssignment V B) e = false) : + 1 ≤ clauseFailures (eventBlock V hq e) B := by + obtain ⟨p, hp⟩ := patternAt_surjective q (fun i => restrictAssignment V B (V.query e i)) + have rejectedPattern : V.accepts e (patternAt q p) = false := by + rw [hp] + exact rejected + have failed := block_failed V hq B e p rejectedPattern (fun i => (congrFun hp i).symm) + exact failed.trans (clauseFailures_le_flatMap (List.finRange (patterns q).length) + (block V hq e) B p (by simp)) + +theorem count_false_map_sum {α : Type*} (xs : List α) (f : α → Bool) : + (xs.map f).count false = (xs.map (fun x => if f x then 0 else 1)).sum := by + induction xs with + | nil => simp + | cons x xs ih => cases h : f x <;> simp [h, ih, Nat.add_comm] + +theorem clauseFailures_flatMap {α : Type*} {n : Nat} (xs : List α) + (f : α → List (Clause n)) (A : Fin n → Bool) : + clauseFailures (xs.flatMap f) A = (xs.map (fun x => clauseFailures (f x) A)).sum := by + induction xs with + | nil => rfl + | cons x xs ih => + simp only [List.flatMap_cons, clauseFailures_append, List.map_cons, List.sum_cons, ih] + +theorem nat_sum_map_le {α : Type*} (xs : List α) (f g : α → Nat) + (bound : ∀ x ∈ xs, f x ≤ g x) : (xs.map f).sum ≤ (xs.map g).sum := by + induction xs with + | nil => exact Nat.le_refl 0 + | cons x xs ih => + simp only [List.map_cons, List.sum_cons] + exact Nat.add_le_add (bound x (by simp)) (ih (fun y hy => bound y (by simp [hy]))) + +theorem convert_count_bridge {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) + (B : Fin (outputVariables V) → Bool) : + rejectedEventCount V (restrictAssignment V B) ≤ NameCompaction.failedCount (convert V hq) B := by + change ((List.finRange V.events).map (eventValue V (restrictAssignment V B))).count false ≤ + clauseFailures ((List.finRange V.events).flatMap (eventBlock V hq)) B + rw [count_false_map_sum, clauseFailures_flatMap] + apply nat_sum_map_le + intro e _ + cases rejected : eventValue V (restrictAssignment V B) e with + | false => simpa only [rejected, Bool.false_eq_true, ↓reduceIte] using + eventBlock_failed V hq B e rejected + | true => simp only [↓reduceIte, Nat.zero_le] + +theorem convert_gap {q : Nat} (V : FiniteVerifier q) (hq : 3 ≤ q) (a b : Nat) + (gap : ∀ A, a * V.events ≤ b * rejectedEventCount V A) + (B : Fin (outputVariables V) → Bool) : + a * (convert V hq).clauses.length ≤ + (b * (2 ^ q * (q - 2))) * NameCompaction.failedCount (convert V hq) B := by + have eventGap := gap (restrictAssignment V B) + have countBound := Nat.mul_le_mul_left b (convert_count_bridge V hq B) + rw [convert_clause_count] + calc + a * (V.events * (2 ^ q * (q - 2))) = (a * V.events) * (2 ^ q * (q - 2)) := by + rw [Nat.mul_assoc] + _ ≤ (b * NameCompaction.failedCount (convert V hq) B) * (2 ^ q * (q - 2)) := + Nat.mul_le_mul_right _ (eventGap.trans countBound) + _ = (b * (2 ^ q * (q - 2))) * NameCompaction.failedCount (convert V hq) B := by ac_rfl + +theorem twelve_query_factor : 2 ^ 12 * (12 - 2) = 40960 := by decide + +theorem twelve_query_clause_count (V : FiniteVerifier 12) : + (convert V (by decide)).clauses.length = V.events * 40960 := by + simpa only [twelve_query_factor] using convert_clause_count V (by decide) + +def padLiteral {n : Nat} (l : Literal n) : Literal (n + 1) := + ⟨Fin.castAdd 1 l.variableIndex, l.positive⟩ + +def padClause {n : Nat} (c : Clause n) : Clause (n + 1) := + #v[padLiteral (c)[0], padLiteral (c)[1], padLiteral (c)[2]] + +def padTautology (n : Nat) : Clause (n + 1) := + let v := Fin.natAdd n (0 : Fin 1) + #v[⟨v, true⟩, ⟨v, false⟩, ⟨v, true⟩] + +def padInput (F : Formula) : Formula where + «variables» := F.«variables» + 1 + clauses := F.clauses.map padClause ++ [padTautology F.«variables»] + +theorem padClause_eval {n : Nat} (c : Clause n) (B : Fin (n + 1) → Bool) : + (padClause c).eval B = c.eval (fun v => B (Fin.castAdd 1 v)) := rfl + +theorem padTautology_satisfied (n : Nat) (B : Fin (n + 1) → Bool) : + (padTautology n).eval B = true := by + simp [padTautology, Clause.eval, Literal.eval] + +theorem padInput_satisfiable_iff (F : Formula) : (padInput F).Satisfiable ↔ F.Satisfiable := by + change (∃ B : Fin (F.«variables» + 1) → Bool, + ∀ c ∈ F.clauses.map padClause ++ [padTautology F.«variables»], c.eval B = true) ↔ _ + constructor + · rintro ⟨B, hB⟩ + refine ⟨fun v => B (Fin.castAdd 1 v), fun c hc => ?_⟩ + have hmem : padClause c ∈ (padInput F).clauses := by + apply List.mem_append.mpr + exact Or.inl (List.mem_map.mpr ⟨c, hc, rfl⟩) + exact (padClause_eval c B).symm.trans (hB _ hmem) + · rintro ⟨A, hA⟩ + let B : Fin (F.«variables» + 1) → Bool := Fin.addCases A (fun _ => false) + refine ⟨B, fun c hc => ?_⟩ + rcases List.mem_append.mp hc with original | padding + · obtain ⟨d, hd, rfl⟩ := List.mem_map.mp original + have h := hA d hd + simpa only [padClause_eval, B, Fin.addCases_left] using h + · have hc : c = padTautology F.«variables» := by simpa using padding + subst c + exact padTautology_satisfied F.«variables» B + +@[simp] theorem padInput_clause_count (F : Formula) : + (padInput F).clauses.length = F.clauses.length + 1 := by simp [padInput] + +theorem padInput_nonempty (F : Formula) : (padInput F).clauses ≠ [] := by + intro empty + have size := padInput_clause_count F + rw [empty, List.length_nil] at size + omega + +def prepareInput (F : Formula) : Formula := NameCompaction.compact (padInput F) + +theorem prepareInput_satisfiable_iff (F : Formula) : + (prepareInput F).Satisfiable ↔ F.Satisfiable := + (NameCompaction.compact_satisfiable_iff (padInput F)).trans (padInput_satisfiable_iff F) + +theorem prepareInput_clause_count (F : Formula) : + (prepareInput F).clauses.length = F.clauses.length + 1 := by + simp only [prepareInput, NameCompaction.compact_clause_count, padInput_clause_count] + +theorem prepareInput_nonempty (F : Formula) : (prepareInput F).clauses ≠ [] := by + intro empty + have h := prepareInput_clause_count F + rw [empty, List.length_nil] at h + omega + +theorem prepareInput_variable_bound (F : Formula) : + (prepareInput F).«variables» ≤ 3 * (F.clauses.length + 1) := by + simpa only [prepareInput, padInput_clause_count] using NameCompaction.compact_active_bound (padInput F) + +end IndependentSetsGames.Foundations.PCP.VerifierToCNF + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/PCP/VertexPadding.lean b/lean/OAI/Combinatorics/IndependentSets/PCP/VertexPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a2cd9299c6ccb76ac978a61ab4037865db7c305 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/PCP/VertexPadding.lean @@ -0,0 +1,188 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Expansion.ExpanderFamily + +namespace OAI + +namespace IndependentSetsGames.Foundations.PCP.VertexPadding + +open scoped BigOperators + +variable {V D A : Type*} + +def reverseFunction (G : ConstraintGraph V (V × D) A) (extra : ℕ) : + (V ⊕ Fin extra) × D → (V ⊕ Fin extra) × D + | (Sum.inl v, d) => (Sum.inl (G.reverse (v, d)).1, (G.reverse (v, d)).2) + | (Sum.inr w, d) => (Sum.inr w, d) + +theorem reverseFunction_involutive (G : ConstraintGraph V (V × D) A) (extra : ℕ) : + Function.Involutive (reverseFunction G extra) := by + rintro ⟨v | w, d⟩ + · change (Sum.inl (G.reverse (G.reverse (v, d))).1, + (G.reverse (G.reverse (v, d))).2) = (Sum.inl v, d) + rw [G.reverse_involutive] + · rfl + +def pad (G : ConstraintGraph V (V × D) A) (extra : ℕ) : + ConstraintGraph (V ⊕ Fin extra) ((V ⊕ Fin extra) × D) A where + reverse := { + toFun := reverseFunction G extra + invFun := reverseFunction G extra + left_inv := reverseFunction_involutive G extra + right_inv := reverseFunction_involutive G extra } + reverse_involutive := reverseFunction_involutive G extra + tail := Prod.fst + accepts := fun e a b => match e.1 with + | Sum.inl v => G.accepts (v, e.2) a b + | Sum.inr _ => true + reverse_accepts := by + rintro ⟨v | w, d⟩ a b + · change G.accepts (G.reverse (v, d)) b a = G.accepts (v, d) a b + exact G.reverse_accepts (v, d) a b + · rfl + +@[simp] theorem pad_tail (G : ConstraintGraph V (V × D) A) (extra : ℕ) : + (pad G extra).tail = Prod.fst := rfl + +@[simp] theorem pad_reverse_inl (G : ConstraintGraph V (V × D) A) (extra : ℕ) + (v : V) (d : D) : + (pad G extra).reverse (Sum.inl v, d) = + (Sum.inl (G.reverse (v, d)).1, (G.reverse (v, d)).2) := rfl + +@[simp] theorem pad_reverse_inr (G : ConstraintGraph V (V × D) A) (extra : ℕ) + (w : Fin extra) (d : D) : + (pad G extra).reverse (Sum.inr w, d) = (Sum.inr w, d) := rfl + +@[simp] theorem edgeSatisfied_inl (G : ConstraintGraph V (V × D) A) + (htail : G.tail = Prod.fst) (extra : ℕ) (labeling : V ⊕ Fin extra → A) + (v : V) (d : D) : + (pad G extra).edgeSatisfied labeling (Sum.inl v, d) = + G.edgeSatisfied (fun v => labeling (Sum.inl v)) (v, d) := by + change G.accepts (v, d) (labeling (Sum.inl v)) + (labeling (Sum.inl (G.reverse (v, d)).1)) = + G.accepts (v, d) (labeling (Sum.inl (G.tail (v, d)))) + (labeling (Sum.inl (G.tail (G.reverse (v, d))))) + rw [htail] + +@[simp] theorem edgeSatisfied_inr (G : ConstraintGraph V (V × D) A) (extra : ℕ) + (labeling : V ⊕ Fin extra → A) (w : Fin extra) (d : D) : + (pad G extra).edgeSatisfied labeling (Sum.inr w, d) = true := rfl + +def extendLabeling (extra : ℕ) (defaultA : A) (labeling : V → A) : V ⊕ Fin extra → A := + Sum.elim labeling (fun _ => defaultA) + +@[simp] theorem extendLabeling_inl (extra : ℕ) (defaultA : A) (labeling : V → A) + (v : V) : extendLabeling extra defaultA labeling (Sum.inl v) = labeling v := rfl + +@[simp] theorem extendLabeling_inr (extra : ℕ) (defaultA : A) (labeling : V → A) + (w : Fin extra) : extendLabeling extra defaultA labeling (Sum.inr w) = defaultA := rfl + +theorem pad_satisfiable (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (extra : ℕ) (defaultA : A) (hG : G.Satisfiable) : (pad G extra).Satisfiable := by + obtain ⟨labeling, hlabeling⟩ := hG + refine ⟨extendLabeling extra defaultA labeling, ?_⟩ + rintro ⟨v | w, d⟩ + · simpa only [edgeSatisfied_inl G htail, extendLabeling_inl] using hlabeling (v, d) + · rfl + +theorem satisfiable_of_pad (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (extra : ℕ) (hG : (pad G extra).Satisfiable) : G.Satisfiable := by + obtain ⟨labeling, hlabeling⟩ := hG + refine ⟨fun v => labeling (Sum.inl v), ?_⟩ + rintro ⟨v, d⟩ + simpa only [edgeSatisfied_inl G htail] using hlabeling (Sum.inl v, d) + +theorem rejectionCount_eq_sum {U E : Type*} [Fintype E] + (G : ConstraintGraph U E A) (labeling : U → A) : + G.rejectionCount labeling = ∑ e, if G.edgeSatisfied labeling e = false then 1 else 0 := by + simp [ConstraintGraph.rejectionCount, ConstraintGraph.rejectedDarts] + +theorem pad_rejectionCount [Fintype V] [Fintype D] + (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) (extra : ℕ) + (labeling : V ⊕ Fin extra → A) : + (pad G extra).rejectionCount labeling = + G.rejectionCount (fun v => labeling (Sum.inl v)) := by + classical + simp only [rejectionCount_eq_sum, Fintype.sum_prod_type, Fintype.sum_sum_type] + simp only [edgeSatisfied_inl G htail, edgeSatisfied_inr] + simp + +variable (V : Type*) [Fintype V] + +def extraVertices : ℕ := ExpanderFamily.size (Fintype.card V) - Fintype.card V + +abbrev Vertex := V ⊕ Fin (extraVertices V) + +theorem card_vertex : Fintype.card (Vertex V) = ExpanderFamily.size (Fintype.card V) := by + rw [Fintype.card_sum, Fintype.card_fin] + exact Nat.add_sub_of_le (ExpanderFamily.le_size _) + +theorem le_card_vertex : Fintype.card V ≤ Fintype.card (Vertex V) := by + rw [card_vertex] + exact ExpanderFamily.le_size _ + +theorem card_vertex_le [Nonempty V] : + Fintype.card (Vertex V) ≤ ExpanderFamily.growth * Fintype.card V := by + rw [card_vertex] + exact ExpanderFamily.size_le_mul Fintype.card_pos + +noncomputable def familyVertexEquiv : + Vertex V ≃ ExpanderFamily.Vertex (ExpanderFamily.level (Fintype.card V)) := + Fintype.equivOfCardEq (by + rw [card_vertex, ExpanderFamily.card_vertex] + rfl) + +variable {V} + +def paddedG (G : ConstraintGraph V (V × D) A) : ConstraintGraph (Vertex V) (Vertex V × D) A := + pad G (extraVertices V) + +@[simp] theorem paddedG_tail (G : ConstraintGraph V (V × D) A) : + (paddedG G).tail = Prod.fst := rfl + +theorem paddedG_rejectionCount [Fintype D] + (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (labeling : Vertex V → A) : + (paddedG G).rejectionCount labeling = + G.rejectionCount (fun v => labeling (Sum.inl v)) := + pad_rejectionCount G htail (extraVertices V) labeling + +theorem rejectionCount_eq [Fintype D] + (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (labeling : Vertex V → A) : + (paddedG G).rejectionCount labeling = + G.rejectionCount (fun v => labeling (Sum.inl v)) := + paddedG_rejectionCount G htail labeling + +def liftLabel (defaultA : A) (labeling : V → A) : Vertex V → A := + extendLabeling (extraVertices V) defaultA labeling + +@[simp] theorem liftLabel_inl (defaultA : A) (labeling : V → A) (v : V) : + liftLabel defaultA labeling (Sum.inl v) = labeling v := rfl + +@[simp] theorem liftLabel_inr (defaultA : A) (labeling : V → A) + (w : Fin (extraVertices V)) : + liftLabel defaultA labeling (Sum.inr w) = defaultA := rfl + +theorem rejectionCount_liftLabel [Fintype D] + (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (defaultA : A) (labeling : V → A) : + (paddedG G).rejectionCount (liftLabel defaultA labeling) = G.rejectionCount labeling := by + simpa only [liftLabel_inl] using + paddedG_rejectionCount G htail (liftLabel defaultA labeling) + +theorem paddedG_satisfiable (G : ConstraintGraph V (V × D) A) (htail : G.tail = Prod.fst) + (defaultA : A) (hG : G.Satisfiable) : (paddedG G).Satisfiable := + pad_satisfiable G htail (extraVertices V) defaultA hG + +theorem card_padded_darts [Fintype D] : + Fintype.card (Vertex V × D) = ExpanderFamily.size (Fintype.card V) * Fintype.card D := by + rw [Fintype.card_prod, card_vertex] + +theorem card_padded_darts_le [Fintype D] [Nonempty V] : + Fintype.card (Vertex V × D) ≤ ExpanderFamily.growth * Fintype.card (V × D) := by + rw [Fintype.card_prod, Fintype.card_prod, ← Nat.mul_assoc] + exact Nat.mul_le_mul_right (Fintype.card D) (card_vertex_le V) + +end IndependentSetsGames.Foundations.PCP.VertexPadding + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/ArbitraryRealJunta.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/ArbitraryRealJunta.lean new file mode 100644 index 0000000000000000000000000000000000000000..f93b7bfcef04a571a972e70927ccd97008051eb9 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/ArbitraryRealJunta.lean @@ -0,0 +1,165 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Geometry.PatternInvariant +import OAI.Combinatorics.IndependentSets.Reduction.Circle + +namespace OAI + +namespace LargeIndependentSets +open MeasureTheory Set ProductAveraging +open scoped BigOperators Classical NNReal + +theorem arbitrary_real_junta (L : ℝ≥0) {u : ℝ} (hu : 0 < u) : + ∃ J : ℕ, 1 ≤ J ∧ ∀ (ι : Type) [Fintype ι] [DecidableEq ι], + ∀ f : (ι → ℝ) → ℝ, LipschitzWith L f → (∀ x, |f x| ≤ 1) → + ∃ S : Finset ι, S.card ≤ J ∧ + (∫ x, (f x-average BooleanJunta.unitLaw S f x)^2 + ∂Measure.pi (fun _ : ι => BooleanJunta.unitLaw)) < u := by + obtain ⟨J,hJ,H⟩ := BooleanJunta.real_cube_junta_uniform L hu + refine ⟨J,hJ,?_⟩ + intro ι _ _ f hf hb + let e : Fin (Fintype.card ι) ≃ ι := (Fintype.equivFin ι).symm + let g := f ∘ reindex (α:=ℝ) e + have hg : LipschitzWith L g := by simpa only [mul_one] using hf.comp (reindex_lipschitz e) + obtain ⟨S,hS,hi,he⟩ := H _ g hg (fun x => hb _) + refine ⟨S.image e,(Finset.card_image_le).trans hS,?_⟩ + have ham := average_measurable BooleanJunta.unitLaw (S.image e) hf.continuous.measurable + have h := integral_preserving (reindex_preserving BooleanJunta.unitLaw e) + ((hf.continuous.measurable.sub ham).pow_const 2).aestronglyMeasurable + have hp (x : Fin (Fintype.card ι) → ℝ) : + (f (reindex e x)-average BooleanJunta.unitLaw (S.image e) f (reindex e x))^2 = + (g x-average BooleanJunta.unitLaw S g x)^2 := by + rw [← average_reindex BooleanJunta.unitLaw e S hf.continuous.measurable] + rfl + change (∫ x, (f (reindex e x)-average BooleanJunta.unitLaw (S.image e) f (reindex e x))^2 + ∂Measure.pi (fun _ : Fin (Fintype.card ι) => BooleanJunta.unitLaw)) = + (∫ x, (f x-average BooleanJunta.unitLaw (S.image e) f x)^2 + ∂Measure.pi (fun _ : ι => BooleanJunta.unitLaw)) at h + simp only [hp] at h + rw [← h] + exact he +end LargeIndependentSets + +namespace LargeIndependentSets.PhaseTest +open MeasureTheory Set +open scoped BigOperators Classical NNReal +abbrev Circle := AddCircle (1:ℝ) +instance circleProbability : IsProbabilityMeasure (volume : Measure Circle) where + measure_univ := by simp [Circle] +noncomputable def rotationLaw : Measure ℝ := volume.restrict (Ico 0 1) +instance rotationProbability : IsProbabilityMeasure rotationLaw where + measure_univ := by simp [rotationLaw] +noncomputable def representative (x : Circle) : ℝ := (AddCircle.equivIco (1:ℝ) 0 x).val +lemma representative_mem (x : Circle) : representative x ∈ Ico (0:ℝ) 1 := by + simpa [representative] using (AddCircle.equivIco (1:ℝ) 0 x).property +lemma representative_measurable : Measurable representative := + measurable_subtype_coe.comp (AddCircle.measurableEquivIco (1:ℝ) 0).measurable +lemma representative_coe (x : Circle) : (representative x : Circle) = x := AddCircle.coe_equivIco +lemma representative_eq {x : ℝ} (hx : x ∈ Ico (0:ℝ) 1) : representative (x : Circle) = x := by + have h := AddCircle.equivIco_coe_eq (p:=(1:ℝ)) (a:=0) (x:=x) (by simpa using hx) + exact congrArg Subtype.val h +lemma quotient_preserving : MeasurePreserving (fun x : ℝ => (x : Circle)) rotationLaw volume := by + have h := AddCircle.measurePreserving_mk (1:ℝ) 0 + simpa only [zero_add, restrict_Ioc_eq_restrict_Icc, rotationLaw, + restrict_Ico_eq_restrict_Icc] using h +lemma representative_preserving : MeasurePreserving representative volume rotationLaw := by + refine ⟨representative_measurable,?_⟩ + rw [← quotient_preserving.map_eq, Measure.map_map representative_measurable quotient_preserving.measurable] + have he : (fun x : ℝ => representative (x : Circle)) =ᵐ[rotationLaw] id := by + filter_upwards [ae_restrict_mem measurableSet_Ico] with x hx + exact representative_eq hx + change Measure.map (fun x : ℝ => representative (x : Circle)) rotationLaw = rotationLaw + rw [Measure.map_congr he, Measure.map_id] +noncomputable def rotate (z : Circle) (x : ℝ) : ℝ := representative ((x : Circle)+z) +lemma rotate_preserving (z : Circle) : MeasurePreserving (rotate z) rotationLaw rotationLaw := + representative_preserving.comp ((measurePreserving_add_right volume z).comp quotient_preserving) +lemma rotate_coe (z : Circle) (x : ℝ) : ((rotate z x : ℝ) : Circle) = (x : Circle)+z := representative_coe _ + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +variable {M : ι → Type*} [∀ i, Fintype (M i)] +variable {κ τ : Type*} + +noncomputable def phase (p : ∀ j, κ → M j) (t : ι → ℝ) (θ : (Sigma M) → ℝ) : κ → Circle := + fun k => ∑ j, ((t j * θ ⟨j,p j k⟩ : ℝ) : Circle) +noncomputable def auxiliary (p : ∀ j, κ → M j) (r : κ → τ) (a : τ → ι) + (t : ι → ℝ) (θ : Sigma M → ℝ) (z : ι → Circle) : κ → Circle := + fun k => z (a (r k)) + phase p t θ k +noncomputable def blockShift (q : ∀ j, M j → τ) (a : τ → ι) (j : ι) + (z : ι → Circle) (θ : Sigma M → ℝ) : Sigma M → ℝ := + fun c => if c.1 = j then rotate (z (a (q c.1 c.2))) (θ c) else θ c + +lemma blockShift_preserving (q : ∀ j, M j → τ) (a : τ → ι) (j : ι) (z : ι → Circle) : + MeasurePreserving (blockShift q a j z) + (Measure.pi (fun _ : Sigma M => rotationLaw)) (Measure.pi (fun _ : Sigma M => rotationLaw)) := by + apply measurePreserving_pi (fun _ : Sigma M => rotationLaw) (fun _ : Sigma M => rotationLaw) + (f:=fun c x => if c.1 = j then rotate (z (a (q c.1 c.2))) x else x) + intro c + by_cases hc : c.1 = j + · simpa only [blockShift, hc, ↓reduceIte] using rotate_preserving (z (a (q c.1 c.2))) + · simp only [hc, ↓reduceIte] + exact ⟨measurable_id, Measure.map_id⟩ + +omit [∀ index, Fintype (M index)] in +lemma full_block_absorption (p : ∀ j, κ → M j) (q : ∀ j, M j → τ) (r : κ → τ) + (hc : ∀ j k, q j (p j k) = r k) (a : τ → ι) (j : ι) + (t : ι → ℝ) (ht : t j = 1) (θ : Sigma M → ℝ) (z : ι → Circle) : + phase p t (blockShift q a j z θ) = auxiliary p r a t θ z := by + funext k + unfold phase auxiliary + change (∑ l, ((t l * blockShift q a j z θ ⟨l,p l k⟩ : ℝ) : Circle)) = + z (a (r k)) + ∑ l, ((t l * θ ⟨l,p l k⟩ : ℝ) : Circle) + calc + _ = ∑ l, (((t l * θ ⟨l,p l k⟩ : ℝ) : Circle) + if l=j then z (a (r k)) else 0) := by + apply Finset.sum_congr rfl + intro l _ + by_cases hl : l = j + · subst l + simp only [blockShift, ↓reduceIte, ht, one_mul, rotate_coe, hc] + · simp only [blockShift, hl, ↓reduceIte, add_zero] + _ = _ := by rw [Finset.sum_add_distrib]; simp [add_comm] + +lemma absorption_integral [Fintype κ] (p : ∀ j, κ → M j) (q : ∀ j, M j → τ) (r : κ → τ) + (hc : ∀ j k, q j (p j k) = r k) (a : τ → ι) (j : ι) + (t : ι → ℝ) (ht : t j = 1) (z : ι → Circle) + (F : (κ → Circle) → ℝ) (hF : Measurable F) : + (∫ θ, F (auxiliary p r a t θ z) ∂Measure.pi (fun _ : Sigma M => rotationLaw)) = + ∫ θ, F (phase p t θ) ∂Measure.pi (fun _ : Sigma M => rotationLaw) := by + have hp : Measurable (phase p t) := by + apply Measurable.of_eval + intro k + exact Finset.measurable_sum _ (fun l _ => quotient_preserving.measurable.comp + (measurable_const.mul (measurable_pi_apply (⟨l,p l k⟩ : Sigma M)))) + have he (θ : Sigma M → ℝ) : F (auxiliary p r a t θ z) = F (phase p t (blockShift q a j z θ)) := by + rw [full_block_absorption p q r hc a j t ht] + simp_rw [he] + exact ProductAveraging.integral_preserving (blockShift_preserving q a j z) (hF.comp hp).aestronglyMeasurable + +omit [DecidableEq ι] [∀ index, Fintype (M index)] in +lemma auxiliary_lipschitz [Fintype κ] (p : ∀ j, κ → M j) (r : κ → τ) (a : τ → ι) + (t : ι → ℝ) (θ : Sigma M → ℝ) : LipschitzWith 1 (auxiliary p r a t θ) := by + apply LipschitzWith.of_dist_le_mul + intro z w + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro k + simpa only [auxiliary, dist_add_right] using dist_le_pi_dist z w (a (r k)) + +omit [DecidableEq ι] [∀ index, Fintype (M index)] in +lemma auxiliary_mean_zero [Fintype κ] (p : ∀ j, κ → M j) (r : κ → τ) (a : τ → ι) + (t : ι → ℝ) (θ : Sigma M → ℝ) (F : (κ → Circle) → ℝ) + (hF : Measurable F) (hodd : ∀ x, F (fun k => x k + ((1/2:ℝ):Circle)) = -F x) : + (∫ z, F (auxiliary p r a t θ z)) = 0 := by + let v : ι → Circle := fun _ => ((1/2:ℝ):Circle) + have hm := hF.comp (auxiliary_lipschitz p r a t θ).continuous.measurable + have he (z : ι → Circle) : F (auxiliary p r a t θ (z+v)) = -F (auxiliary p r a t θ z) := by + convert hodd (auxiliary p r a t θ z) using 1 + congr 1 + funext k + simp [auxiliary, v, add_assoc, add_comm, add_left_comm] + have hp := ProductAveraging.integral_preserving (measurePreserving_add_right (volume : Measure (ι→Circle)) v) + hm.aestronglyMeasurable + change (∫ z, F (auxiliary p r a t θ (z+v))) = (∫ z, F (auxiliary p r a t θ z)) at hp + simp only [he, integral_neg] at hp + linarith +end LargeIndependentSets.PhaseTest + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/AuxiliaryJointMeasurable.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/AuxiliaryJointMeasurable.lean new file mode 100644 index 0000000000000000000000000000000000000000..01df9316d11cc437f3bd895bb8e88bf0537313b3 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/AuxiliaryJointMeasurable.lean @@ -0,0 +1,249 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.SquareNorm +import OAI.Combinatorics.IndependentSets.Reduction.InfluenceSqParamMeasurable +import OAI.Combinatorics.IndependentSets.Reduction.Full + +namespace OAI + +namespace LargeIndependentSets.PhaseTest +open MeasureTheory Set ProductAveraging +open scoped BigOperators Classical NNReal +variable {ι : Type} [Fintype ι] [DecidableEq ι] +variable {M : ι → Type} [∀ j, Fintype (M j)] +variable {κ κ' τ : Type} [Fintype κ] [Fintype κ'] + +omit [DecidableEq ι] [∀ index, Fintype (M index)] [Fintype κ] in +lemma auxiliary_joint_measurable (p : ∀ j, κ → M j) (r : κ → τ) (a : τ → ι) + (t : ι → ℝ) : + Measurable (fun v : (Sigma M → ℝ) × (ι → Circle) => auxiliary p r a t v.1 v.2) := by + apply Measurable.of_eval + intro k + exact ((measurable_pi_apply (a (r k))).comp measurable_snd).add + ((measurable_pi_apply k).comp ((phase_measurable p t).comp measurable_fst)) + +omit [Fintype κ] [Fintype κ'] in +theorem deleted_zero_from_junta (i j : ι) (p : ∀ j, κ → M j) + (p' : ∀ j : {j : ι // j ≠ i}, κ' → M j.val) (e : κ → κ') + (hp : ∀ j k, p j.val k = p' j (e k)) + (q : ∀ j, M j → τ) (r : κ → τ) (hq : ∀ j k, q j (p j k) = r k) + (a : τ → ι) (t : ι → ℝ) (hi : t i = 0) (hj : t j = 1) + (F : (κ → Circle) → ℝ) (F' : (κ' → Circle) → ℝ) + (hFm : Measurable F) (hF'm : Measurable F') + (hFb : ∀ x, |F x| ≤ 1) (hF'b : ∀ x, |F' x| ≤ 1) + {c γ : ℝ} (hc : 0 ≤ c) (hγ : c < γ) + (hcompat : ∀ y, |F (y ∘ e)-F' y| ≤ c) + (S : Finset (Sigma fun k : {k : ι // k ≠ i} => M k.val)) + (halign : ∀ d ∈ S, d.1.val = j → a (q d.1.val d.2) ≠ i) + (herr : (∫ θ, + (F' (phase p' (fun k => t k.val) θ) - + average rotationLaw S (fun φ => F' (phase p' (fun k => t k.val) φ)) θ)^2 + ∂Measure.pi (fun _ : Sigma (fun k : {k : ι // k ≠ i} => M k.val) => rotationLaw)) < γ^2) : + (∫ θ, influenceSq volume i (fun z => F (auxiliary p r a t θ z)) + ∂Measure.pi (fun _ : Sigma M => rotationLaw)) < (2*γ)^2 := by + let h : (Sigma (fun k : {k : ι // k ≠ i} => M k.val) → ℝ) → ℝ := + fun θ => F' (phase p' (fun k => t k.val) θ) + let g := average rotationLaw S h + let R := restrictRotations (M:=M) i + have hR := restriction_preserving rotationLaw (eraseCoord (M:=M) i) (eraseCoord_injective i) + have hhm : Measurable h := hF'm.comp (phase_measurable p' _) + have hgm : Measurable g := average_measurable rotationLaw S hhm + have hhb : ∀ θ, |h θ| ≤ 1 := fun θ => hF'b _ + have hgb : ∀ θ, |g θ| ≤ 1 := average_bound rotationLaw S hhb + have he : (∫ θ, (h (R θ)-g (R θ))^2 ∂Measure.pi (fun _ : Sigma M => rotationLaw)) < γ^2 := by + have htransfer := integral_preserving hR ((hhm.sub hgm).pow_const 2).aestronglyMeasurable + change (∫ θ, (h (R θ)-g (R θ))^2 ∂Measure.pi (fun _ : Sigma M => rotationLaw)) = + (∫ θ, (h θ-g θ)^2 ∂Measure.pi (fun _ : Sigma (fun k : {k : ι // k ≠ i} => M k.val) => rotationLaw)) at htransfer + rw [htransfer] + exact herr + apply zero_influence_bound q a j i (S.image (eraseCoord i)) (h ∘ R) (g ∘ R) + (fun v => F (auxiliary p r a t v.1 v.2)) + (hhm.comp hR.measurable) (hgm.comp hR.measurable) + (hFm.comp (auxiliary_joint_measurable p r a t)) + (fun θ => hhb _) (fun θ => hgb _) (fun v => hFb _) + ?_ ?_ hc hγ ?_ he + · intro x y hxy + apply average_depends + intro d hd + exact hxy (eraseCoord i d) (Finset.mem_image.mpr ⟨d,hd,rfl⟩) + · intro d hd hdj + obtain ⟨d',hd',rfl⟩ := Finset.mem_image.mp hd + exact halign d' hd' hdj + · intro θ z + dsimp only [Function.comp_def, h, R] + rw [deleted_auxiliary i j p p' e hp q r hq a t hi hj θ z] + exact hcompat _ +end LargeIndependentSets.PhaseTest + +namespace LargeIndependentSets.Coefficient +open scoped Classical +noncomputable def value {m : ℕ} (k : Fin (m+1)) : ℝ := k.val / (m:ℝ) +lemma value_nonneg {m : ℕ} (k : Fin (m+1)) : 0 ≤ value k := by unfold value; positivity +lemma value_le_one {m : ℕ} (hm : 0 < m) (k : Fin (m+1)) : value k ≤ 1 := by + rw [value, div_le_one (by exact_mod_cast hm)] + exact_mod_cast (show k.val ≤ m by omega) +lemma value_abs_le_one {m : ℕ} (hm : 0 < m) (k : Fin (m+1)) : |value k| ≤ 1 := by + rw [abs_of_nonneg (value_nonneg k)]; exact value_le_one hm k +lemma value_zero {m : ℕ} (k : Fin (m+1)) (hk : k.val=0) : value k=0 := by simp [value,hk] +lemma value_full {m : ℕ} (hm : 0 < m) (k : Fin (m+1)) (hk : k.val=m) : value k=1 := by + have hmR : (m : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hm) + simpa only [value,hk] using div_self hmR +lemma value_lower {ι : Type*} [DecidableEq ι] {m : ℕ} (hm : 0 < m) + (i : ι) (t : ι → Fin (m+1)) (ht : 0 < (t i).val) : + |value (t i)-value (lower i t i)| = 1/(m:ℝ) := by + have hcast : (((t i).val-1 : ℕ):ℝ) = (t i).val-1 := by rw [Nat.cast_sub (by omega)]; norm_num + simp only [value, lower, Function.update_self, hcast] + rw [show ((t i).val : ℝ)/(m:ℝ)-((t i).val-1)/(m:ℝ) = 1/(m:ℝ) by ring, + abs_of_nonneg (by positivity : 0 ≤ 1/(m:ℝ))] +end LargeIndependentSets.Coefficient + +namespace LargeIndependentSets.PhaseTest + +section +open MeasureTheory Set ProductAveraging +open scoped BigOperators Classical NNReal + +theorem subchain_juntas (L : ℝ≥0) (s : ℕ) {γ : ℝ} (hγ : 0 < γ) : + ∃ J : ℕ, 1 ≤ J ∧ ∀ (ι : Type) [Fintype ι] [DecidableEq ι], + Fintype.card ι ≤ s → ∀ (M : ι → Type) [∀ j, Fintype (M j)], + ∀ (κ : Type) [Fintype κ], ∀ (p : ∀ j, κ → M j) + (F : (κ → Circle) → ℝ), LipschitzWith L F → (∀ x, |F x| ≤ 1) → + ∀ m : ℕ, 0 < m → ∃ S : (ι → Fin (m+1)) → Finset (Sigma M), + (∀ t, (S t).card ≤ J ∧ + (∫ θ, (F (phase p (fun j => Coefficient.value (t j)) θ) - + average rotationLaw (S t) (fun φ => F (phase p (fun j => Coefficient.value (t j)) φ)) θ)^2 + ∂Measure.pi (fun _ : Sigma M => rotationLaw)) < γ^2) ∧ + (Finset.univ.biUnion S).card ≤ J*(m+1)^s := by + obtain ⟨J,hJ,HJ⟩ := arbitrary_real_junta (L*s) (sq_pos_of_pos hγ) + refine ⟨J,hJ,?_⟩ + intro ι _ _ hs M _ κ _ p F hF hb m hm + have hrot : rotationLaw = BooleanJunta.unitLaw := by + simp only [rotationLaw, BooleanJunta.unitLaw, restrict_Ico_eq_restrict_Icc] + have hchoice (t : ι → Fin (m+1)) : ∃ S : Finset (Sigma M), S.card ≤ J ∧ + (∫ θ, (F (phase p (fun j => Coefficient.value (t j)) θ)- + average rotationLaw S (fun φ => F (phase p (fun j => Coefficient.value (t j)) φ)) θ)^2 + ∂Measure.pi (fun _ : Sigma M => rotationLaw)) < γ^2 := by + have hphase := phase_lipschitz p (fun j => Coefficient.value (t j)) + (fun j => Coefficient.value_abs_le_one hm _) + have hprod : L*(Fintype.card ι : ℝ≥0) ≤ L*s := mul_le_mul_of_nonneg_left (by exact_mod_cast hs) (by positivity : (0 : ℝ≥0) ≤ L) + have hf := (hF.comp hphase).weaken hprod + simpa only [hrot, Function.comp_def] using HJ (Sigma M) _ hf (fun θ => hb _) + choose S hS using hchoice + refine ⟨S,hS,?_⟩ + calc + _ ≤ ∑ t : ι → Fin (m+1), (S t).card := Finset.card_biUnion_le + _ ≤ ∑ _t : ι → Fin (m+1), J := Finset.sum_le_sum (fun t _ => (hS t).1) + _ = (m+1)^Fintype.card ι * J := by simp + _ ≤ (m+1)^s * J := Nat.mul_le_mul_right J (Nat.pow_le_pow_right (by omega) hs) + _ = _ := Nat.mul_comm _ _ + +lemma terminal_list_card {ι τ : Type*} [Fintype ι] [DecidableEq τ] + {M : ι → Type*} [∀ j, Fintype (M j)] {m s J : ℕ} + (S : (ι → Fin (m+1)) → Finset (Sigma M)) (q : ∀ j, M j → τ) + (hS : (Finset.univ.biUnion S).card ≤ J*(m+1)^s) : + ((Finset.univ.biUnion S).image (fun c => q c.1 c.2)).card ≤ J*(m+1)^s := + Finset.card_image_le.trans hS +end + +open MeasureTheory Set ProductAveraging Coefficient +open scoped BigOperators Classical NNReal + +lemma rotations_bounded_ae {C : Type*} [Fintype C] : + ∀ᵐ θ ∂Measure.pi (fun _ : C => rotationLaw), ∀ c, |θ c| ≤ 1 := by + have hrs : ∀ᵐ y ∂rotationLaw, y ∈ Ico (0:ℝ) 1 := ae_restrict_mem measurableSet_Ico + rw [ae_all_iff] + intro c + have hp := measurePreserving_eval (fun _ : C => rotationLaw) c + filter_upwards [hp.quasiMeasurePreserving.ae hrs] with θ hθ + rw [abs_of_nonneg hθ.1] + exact hθ.2.le + +theorem actual_coefficient_mean_square (L : ℝ≥0) {ε : ℝ} (hε : 0 < ε) : + ∃ β : ℝ, 0 < β ∧ ∃ K : ℕ, 1 ≤ K ∧ + ∀ (s m : ℕ) (hm : 0 < m) (ρ γ c : ℝ), + 0 ≤ ρ → 0 ≤ c → c < γ → + (L:ℝ)/m < β/2 → + (1-levelMass m ρ ⟨m,by omega⟩)^s < ε → + ρ*K < ε → (s:ℝ)*(2*γ)^2/β^2 < ε → + ∀ (M : Fin s → Type) [∀ j, Fintype (M j)] + (κ τ : Type) [Fintype κ], + ∀ (p : ∀ j, κ → M j) (q : ∀ j, M j → τ) (r : κ → τ), + (∀ j k, q j (p j k) = r k) → + ∀ (F : (κ → Circle) → ℝ), LipschitzWith L F → + (∀ x, |F x| ≤ 1) → + (∀ x, F (fun k => x k + ((1/2:ℝ):Circle)) = -F x) → + ∀ (κ' : Fin s → Type) [∀ i, Fintype (κ' i)] + (p' : ∀ i, ∀ j : {j : Fin s // j ≠ i}, κ' i → M j.val) + (e : ∀ i, κ → κ' i), + (∀ i j k, p j.val k = p' i j (e i k)) → + ∀ (F' : ∀ i, (κ' i → Circle) → ℝ), + (∀ i, Measurable (F' i)) → (∀ i x, |F' i x| ≤ 1) → + (∀ i y, |F (y ∘ e i)-F' i y| ≤ c) → + ∀ (S : ∀ i, ({j : Fin s // j ≠ i} → Fin (m+1)) → + Finset (Sigma fun j : {j : Fin s // j ≠ i} => M j.val)), + (∀ i t, (∫ θ, + (F' i (phase (p' i) (fun j => value (t j)) θ) - + average rotationLaw (S i t) (fun φ => F' i (phase (p' i) (fun j => value (t j)) φ)) θ)^2 + ∂Measure.pi (fun _ : Sigma (fun j : {j : Fin s // j ≠ i} => M j.val) => rotationLaw)) < γ^2) → + ∀ (a : τ → Fin s), + (∀ i t d, d ∈ S i t → a (q d.1.val d.2) ≠ i) → + (∑ t : Fin s → Fin (m+1), mass m ρ t * + ∫ θ, ∫ z, (F (auxiliary p r a (fun j => value (t j)) θ z))^2 + ∂(volume : Measure (Fin s → Circle)) + ∂Measure.pi (fun _ : Sigma M => rotationLaw)) < 4*ε := by + obtain ⟨β,hβ,K,hK,HT⟩ := torus_influences L hε + refine ⟨β,hβ,K,hK,?_⟩ + intro s m hm ρ γ c hρ hc hcγ hstep hrare hpos hzero + M _ κ τ _ p q r hq F hF hb hodd κ' _ p' e hp F' hF'm hF'b hcompat S hjunta a halign + let H (t : Fin s → Fin (m+1)) (θ : Sigma M → ℝ) (z : Fin s → Circle) := + F (auxiliary p r a (fun j => value (t j)) θ z) + let X (t : Fin s → Fin (m+1)) (θ : Sigma M → ℝ) := ∫ z, (H t θ z)^2 + let D (t : Fin s → Fin (m+1)) (θ : Sigma M → ℝ) (i : Fin s) := + influenceNorm volume i (H t θ) + have hHlip (t : Fin s → Fin (m+1)) (θ : Sigma M → ℝ) : LipschitzWith L (H t θ) := by + simpa only [H, Function.comp_def, mul_one] using hF.comp (auxiliary_lipschitz p r a (fun j => value (t j)) θ) + have hHm (t : Fin s → Fin (m+1)) : Measurable (fun v : (Sigma M → ℝ) × (Fin s → Circle) => H t v.1 v.2) := + hF.continuous.measurable.comp (auxiliary_joint_measurable p r a _) + have hXB (t : Fin s → Fin (m+1)) (θ : Sigma M → ℝ) : 0 ≤ X t θ ∧ X t θ ≤ 1 := by + constructor + · exact integral_nonneg (fun z => sq_nonneg _) + · calc + _ ≤ ∫ _ : Fin s → Circle, (1:ℝ) := + integral_mono (bounded_sq_integrable (hHlip t θ).continuous.measurable (fun z => hb _)) + (integrable_const _) (fun z => by + have hh : |H t θ z| ≤ 1 := hb _ + nlinarith [sq_abs (H t θ z), abs_nonneg (H t θ z)]) + _ = 1 := by simp + apply coefficient_mean_square_ae (Measure.pi (fun _ : Sigma M => rotationLaw)) hρ hβ (hc.trans_lt hcγ) hε + (by simpa using hrare) hpos (by simpa using hzero) X D + · intro t + exact ((hHm t).pow_const 2).stronglyMeasurable.integral_prod_right'.measurable + · exact hXB + · intro t i + exact (influenceSq_param_measurable volume i (hHm t)).sqrt + · intro t θ i + dsimp only [D, influenceNorm] + rw [abs_of_nonneg (Real.sqrt_nonneg _)] + exact (Real.sqrt_le_iff).mpr ⟨by norm_num, by + simpa using influenceSq_le_bound volume i (hHlip t θ).continuous.measurable (fun z => hb (auxiliary p r a (fun j => value (t j)) θ z))⟩ + · intro t θ hx + exact (HT s (H t θ) (hHlip t θ) (fun z => hb _)).1 + ⟨auxiliary_mean_zero p r a _ θ F hF.continuous.measurable hodd,hx⟩ + · filter_upwards [rotations_bounded_ae (C:=Sigma M)] with θ hθ + intro t i hti + have h := auxiliary_influence_step p r a (fun j => value (t j)) + (fun j => value (lower i t j)) i + (fun j hji => by simp [lower, hji]) θ hθ + (by positivity : 0 ≤ 1/(m:ℝ)) (le_of_eq (value_lower hm i t hti)) F hF hb + exact h.trans_lt (by simpa [div_eq_mul_inv] using hstep) + · intro t θ + exact_mod_cast (HT s (H t θ) (hHlip t θ) (fun z => hb _)).2 + · intro t i ht hi + obtain ⟨j,hj⟩ := ht + have hz := deleted_zero_from_junta i j p (p' i) (e i) (hp i) q r hq a + (fun k => value (t k)) (value_zero _ hi) (value_full hm _ hj) + F (F' i) hF.continuous.measurable (hF'm i) hb (hF'b i) hc hcγ (hcompat i) + (S i (fun k => t k.val)) (fun d hd _ => halign i _ d hd) (hjunta i (fun k => t k.val)) + simpa only [D, influenceNorm, Real.sq_sqrt (influenceSq_nonneg _ _ _)] using hz +end LargeIndependentSets.PhaseTest + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/Bits.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/Bits.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf1361c9684fdbc7aebee1da795bfcac134a715b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/Bits.lean @@ -0,0 +1,146 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Heavy + +namespace OAI + +namespace LargeIndependentSets.BooleanJunta +open scoped BigOperators Classical + +def ofBits : {n : ℕ} → (Fin n → Bool) → Cube n + | 0, _ => () + | _+1, x => (x 0, ofBits (fun i => x i.succ)) + +@[simp] lemma bit_ofBits {n : ℕ} (x : Fin n → Bool) : bit (ofBits x) = x := by + induction n with + | zero => funext i; exact Fin.elim0 i + | succ n ih => + funext i + refine Fin.cases ?_ (fun j => ?_) i + · rfl + · simp only [ofBits, bit, Fin.cases_succ, ih] + +@[simp] lemma ofBits_bit {n : ℕ} (x : Cube n) : ofBits (bit x) = x := by + induction n with + | zero => cases x; rfl + | succ n ih => + obtain ⟨b,x⟩ := x + simp only [ofBits, bit, Fin.cases_zero, Fin.cases_succ, ih] + +def bitEquiv (n : ℕ) : Cube n ≃ (Fin n → Bool) where + toFun := bit + invFun := ofBits + left_inv := ofBits_bit + right_inv := bit_ofBits + +lemma bit_flip {n : ℕ} (i : Fin n) (x : Cube n) : + bit (flip i x) = Function.update (bit x) i (!(bit x i)) := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + obtain ⟨b,x⟩ := x + funext j + refine Fin.cases ?_ (fun k => ?_) i + · refine Fin.cases ?_ (fun l => ?_) j <;> simp [flip, bit] + · refine Fin.cases ?_ (fun l => ?_) j + · simp [flip, bit, Function.update_of_ne (Fin.succ_ne_zero k).symm] + · by_cases h : l = k + · subst l; simpa [flip, bit] using congrFun (ih k x) k + · simpa [flip, bit, h, Function.update_of_ne h, Function.update_of_ne (fun he => h (Fin.succ_inj.mp he))] using congrFun (ih k x) l + +lemma expect_equiv {α β : Type*} [Fintype α] [Fintype β] + (e : α ≃ β) (f : β → ℝ) : (𝔼 x, f (e x)) = 𝔼 y, f y := by + simp only [Finset.expect_eq_sum_div_card, Finset.card_univ] + rw [Fintype.card_congr e] + congr 1 + exact Fintype.sum_equiv e _ _ (fun _ => rfl) + +lemma mean_bit {n : ℕ} (f : (Fin n → Bool) → ℝ) : + mean (fun x : Cube n => f (bit x)) = 𝔼 x, f x := + expect_equiv (bitEquiv n) f + +noncomputable def bitInfluence {ι : Type*} [Fintype ι] [DecidableEq ι] + (f : (ι → Bool) → ℝ) (i : ι) : ℝ := + 𝔼 x, |(f x - f (Function.update x i (!(x i))))/2| + +lemma influence_bit {n : ℕ} (f : (Fin n → Bool) → ℝ) (i : Fin n) : + influence (fun x : Cube n => f (bit x)) i = bitInfluence f i := by + simp only [influence, diff, bit_flip] + exact mean_bit (fun x => |(f x - f (Function.update x i (!(x i))))/2|) + +theorem bits_junta_uniform {L u : ℝ} (hL : 0 ≤ L) (hu : 0 < u) : + ∃ J : ℕ, 1 ≤ J ∧ ∀ n : ℕ, ∀ f : (Fin n → Bool) → ℝ, + (∀ x, |f x| ≤ 1) → (∑ i, bitInfluence f i) ≤ L → + ∃ S : Finset (Fin n), S.card ≤ J ∧ ∃ g : (Fin n → Bool) → ℝ, + (∀ x, |g x| ≤ 1) ∧ + (∀ x y, (∀ i ∈ S, x i = y i) → g x = g y) ∧ + (𝔼 x, (f x - g x)^2) < u := by + obtain ⟨J,hJ,h⟩ := boolean_junta_uniform hL hu + refine ⟨J,hJ,?_⟩ + intro n f hf hI + let f' : Cube n → ℝ := fun x => f (bit x) + have hI' : (∑ i, influence f' i) ≤ L := by simpa only [f', influence_bit] using hI + obtain ⟨S,hS,he⟩ := h n f' (fun x => hf _) hI' + let g : (Fin n → Bool) → ℝ := fun x => truncate S f' (ofBits x) + refine ⟨S,hS,g,?_,?_,?_⟩ + · intro x + exact truncate_bounded S f' (fun x => hf _) _ + · intro x y hxy + apply truncate_depends + simpa only [bit_ofBits] using hxy + · have heq : (𝔼 x, (f x-g x)^2) = mean (fun x : Cube n => (f' x-truncate S f' x)^2) := by + rw [← mean_bit] + simp only [f', g, ofBits_bit] + rwa [heq] + +def reindexBits {ι κ : Type*} (e : ι ≃ κ) : (κ → Bool) ≃ (ι → Bool) where + toFun := fun x i => x (e i) + invFun := fun x j => x (e.symm j) + left_inv := by intro x; funext j; simp + right_inv := by intro x; funext i; simp + +lemma reindexBits_update {ι κ : Type*} [DecidableEq ι] [DecidableEq κ] + (e : ι ≃ κ) (x : κ → Bool) (i : ι) : + reindexBits e (Function.update x (e i) (!(x (e i)))) = + Function.update (reindexBits e x) i (!(reindexBits e x i)) := by + funext j + by_cases h : j = i + · subst j; simp [reindexBits] + · simp [reindexBits, Function.update_of_ne h, Function.update_of_ne (e.injective.ne h)] + +lemma bitInfluence_reindex {ι κ : Type*} [Fintype ι] [Fintype κ] + [DecidableEq ι] [DecidableEq κ] (e : ι ≃ κ) (f : (ι → Bool) → ℝ) (i : ι) : + bitInfluence (fun x => f (reindexBits e x)) (e i) = bitInfluence f i := by + simp only [bitInfluence, reindexBits_update] + exact expect_equiv (reindexBits e) (fun x => |(f x - f (Function.update x i (!(x i))))/2|) + +theorem arbitrary_bits_junta_uniform {L u : ℝ} (hL : 0 ≤ L) (hu : 0 < u) : + ∃ J : ℕ, 1 ≤ J ∧ ∀ (ι : Type) [Fintype ι] [DecidableEq ι], + ∀ f : (ι → Bool) → ℝ, (∀ x, |f x| ≤ 1) → (∑ i, bitInfluence f i) ≤ L → + ∃ S : Finset ι, S.card ≤ J ∧ ∃ g : (ι → Bool) → ℝ, + (∀ x, |g x| ≤ 1) ∧ + (∀ x y, (∀ i ∈ S, x i = y i) → g x = g y) ∧ + (𝔼 x, (f x - g x)^2) < u := by + obtain ⟨J,hJ,h⟩ := bits_junta_uniform hL hu + refine ⟨J,hJ,?_⟩ + intro ι _ _ f hf hI + let e : ι ≃ Fin (Fintype.card ι) := Fintype.equivFin ι + let f' : (Fin (Fintype.card ι) → Bool) → ℝ := fun x => f (reindexBits e x) + have hI' : (∑ i, bitInfluence f' i) ≤ L := by + rw [← e.sum_comp (fun j => bitInfluence f' j)] + simpa only [f', bitInfluence_reindex] using hI + obtain ⟨S,hS,g,hg,hdep,he⟩ := h (Fintype.card ι) f' (fun x => hf _) hI' + let T : Finset ι := S.map e.symm.toEmbedding + let g' : (ι → Bool) → ℝ := fun x => g ((reindexBits e).symm x) + refine ⟨T, by simpa [T] using hS, g', (fun x => hg _), ?_, ?_⟩ + · intro x y hxy + apply hdep + intro j hj + exact hxy (e.symm j) (Finset.mem_map.mpr ⟨j,hj,rfl⟩) + · have heq : (𝔼 x, (f x-g' x)^2) = 𝔼 x, (f' x-g x)^2 := by + rw [← expect_equiv (reindexBits e)] + simp only [g', Equiv.symm_apply_apply, f'] + rwa [heq] + +end LargeIndependentSets.BooleanJunta + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/CellLaw.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/CellLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..aea42b9bb6ea6c0227667af4c901c495d5eec41b --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/CellLaw.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Mix + +namespace OAI + +namespace LargeIndependentSets.BooleanJunta +open MeasureTheory Set +open scoped BigOperators Classical NNReal ENNReal + +lemma uniformLaw_singleton {α : Type*} [Fintype α] [Nonempty α] + [MeasurableSpace α] [MeasurableSingletonClass α] (a : α) : + uniformLaw α {a} = (Fintype.card α : ℝ≥0∞)⁻¹ := by + simp only [uniformLaw, PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton _), + PMF.uniformOfFintype_apply] + +lemma uniformLaw_pi {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] [Nonempty α] + [MeasurableSpace α] [MeasurableSingletonClass α] : + uniformLaw (ι → α) = Measure.pi (fun _ : ι => uniformLaw α) := by + apply Measure.ext_of_singleton + intro x + simp only [uniformLaw_singleton, Measure.pi_singleton, Finset.prod_const, + Finset.card_univ, Fintype.card_fun, Nat.cast_pow, ENNReal.inv_pow] + +noncomputable def cellLaw (n m : ℕ) : Measure (Fin n → Cube m) := uniformLaw (Fin n → Cube m) +instance cellLaw_probability (n m : ℕ) : IsProbabilityMeasure (cellLaw n m) := + inferInstanceAs (IsProbabilityMeasure (uniformLaw (Fin n → Cube m))) + +noncomputable def mergeSeed {n m : ℕ} (p : (Fin n → Cube m) × (Fin n → ℝ)) : + Fin n → Cube m × ℝ := fun i => (p.1 i,p.2 i) + +lemma mergeSeed_preserving (n m : ℕ) : + MeasurePreserving (mergeSeed (n:=n) (m:=m)) + ((cellLaw n m).prod (unitCubeLaw n)) (seedCubeLaw n m) := by + have h := (measurePreserving_arrowProdEquivProdArrow (Cube m) ℝ (Fin n) + (fun _ => uniformLaw (Cube m)) (fun _ => unitLaw)).symm + change MeasurePreserving _ ((uniformLaw (Fin n → Cube m)).prod _) _ + rw [uniformLaw_pi (ι:=Fin n) (α:=Cube m)] + exact h + +lemma cells_preserving (n m : ℕ) : + MeasurePreserving (fun p : Fin n → Cube m × ℝ => fun i => (p i).1) + (seedCubeLaw n m) (cellLaw n m) := by + have h := measurePreserving_pi (fun _ : Fin n => seedLaw m) (fun _ : Fin n => uniformLaw (Cube m)) + (fun _ => measurePreserving_fst (μ:=uniformLaw (Cube m)) (ν:=unitLaw)) + change MeasurePreserving _ _ (uniformLaw (Fin n → Cube m)) + rw [uniformLaw_pi (ι:=Fin n) (α:=Cube m)] + exact h + +noncomputable def cellPoint {n m : ℕ} (q : Fin n → Cube m) : Fin n → ℝ := + fun i => scalarCell (q i) 0 + +lemma scalarCell_distance {m : ℕ} (q : Cube m) {y : ℝ} (hy : y ∈ Icc (0:ℝ) 1) : + dist (scalarCell q y) (scalarCell q 0) ≤ (1/2:ℝ)^m := by + have h := (scalarCell_lipschitz q).dist_le_mul y 0 + have hd : dist y 0 ≤ 1 := by simpa only [Real.dist_eq, sub_zero, abs_of_nonneg hy.1] using hy.2 + exact h.trans (by simpa using mul_le_mul_of_nonneg_left hd (show 0 ≤ ((1/2:ℝ≥0)^m:ℝ) from pow_nonneg (NNReal.coe_nonneg _) _)) + +lemma sample_cell_distance {n m : ℕ} (p : Fin n → Cube m × ℝ) + (hp : ∀ i, (p i).2 ∈ Icc (0:ℝ) 1) : + dist (cubeSampler p) (cellPoint (fun i => (p i).1)) ≤ (1/2:ℝ)^m := by + apply (dist_pi_le_iff (pow_nonneg (by norm_num) _)).mpr + intro i + exact scalarCell_distance _ (hp i) + +lemma seeds_in_unit (n m : ℕ) : + ∀ᵐ p ∂seedCubeLaw n m, ∀ i, (p i).2 ∈ Icc (0:ℝ) 1 := by + have hu : ∀ᵐ x ∂unitLaw, x ∈ Icc (0:ℝ) 1 := ae_restrict_mem measurableSet_Icc + have hs : ∀ᵐ t ∂seedLaw m, t.2 ∈ Icc (0:ℝ) 1 := + (measurePreserving_snd (μ:=uniformLaw (Cube m)) (ν:=unitLaw)).quasiMeasurePreserving.ae hu + rw [ae_all_iff] + intro i + exact (measurePreserving_eval (fun _ : Fin n => seedLaw m) i).quasiMeasurePreserving.ae hs + +lemma sample_cell_error {n m : ℕ} {L : ℝ≥0} {f : (Fin n → ℝ) → ℝ} + (hf : LipschitzWith L f) : + ∀ᵐ p ∂seedCubeLaw n m, + |f (cubeSampler p) - f (cellPoint (fun i => (p i).1))| ≤ L * (1/2:ℝ)^m := by + filter_upwards [seeds_in_unit n m] with p hp + simpa only [Real.dist_eq] using (hf.dist_le_mul _ _).trans + (mul_le_mul_of_nonneg_left (sample_cell_distance p hp) L.coe_nonneg) + +noncomputable def rowFlip {n m : ℕ} (i : Fin n) (k : Fin m) (q : Fin n → Cube m) : + Fin n → Cube m := Function.update q i (flip k (q i)) +noncomputable def rowInfluence {n m : ℕ} (h : (Fin n → Cube m) → ℝ) + (i : Fin n) (k : Fin m) : ℝ := 𝔼 q, |(h q-h (rowFlip i k q))/2| + +lemma cells_update_flip {n m : ℕ} (p : Fin n → Cube m × ℝ) (i : Fin n) (k : Fin m) : + (fun j => (Function.update p i (flipSeed k (p i)) j).1) = + rowFlip i k (fun j => (p j).1) := by + funext j + by_cases hj : j = i + · subst j; simp [rowFlip, flipSeed] + · simp [rowFlip, hj] + +lemma rowInfluence_eq_integral {n m : ℕ} (h : (Fin n → Cube m) → ℝ) + (i : Fin n) (k : Fin m) : + rowInfluence h i k = ∫ p, |(h (fun j => (p j).1)- + h (rowFlip i k (fun j => (p j).1)))/2| ∂seedCubeLaw n m := by + symm + calc + _ = ∫ q, |(h q-h (rowFlip i k q))/2| ∂cellLaw n m := + ProductAveraging.integral_preserving (cells_preserving n m) Integrable.of_finite.aestronglyMeasurable + _ = _ := integral_uniformLaw _ + +lemma rowInfluence_cell_bound {n m : ℕ} {L : ℝ≥0} {f : (Fin n → ℝ) → ℝ} + (hf : LipschitzWith L f) (hb : ∀ x, |f x| ≤ 1) (i : Fin n) (k : Fin m) : + rowInfluence (f ∘ cellPoint) i k ≤ + (∫ p, sampledDiff f i k p ∂seedCubeLaw n m) + L*(1/2:ℝ)^m := by + rw [rowInfluence_eq_integral] + have hcell : Integrable (fun p : Fin n → Cube m × ℝ => + |((f ∘ cellPoint) (fun j => (p j).1)-(f ∘ cellPoint) (rowFlip i k (fun j => (p j).1)))/2|) + (seedCubeLaw n m) := by + have hfin : Integrable (fun q => |((f ∘ cellPoint) q-(f ∘ cellPoint) (rowFlip i k q))/2|) + (cellLaw n m) := Integrable.of_finite + exact (cells_preserving n m).integrable_comp_of_integrable hfin + have hi := sampledDiff_integrable hf.continuous.measurable hb i k + have he : (∫ p, sampledDiff f i k p + L*(1/2:ℝ)^m ∂seedCubeLaw n m) = + (∫ p, sampledDiff f i k p ∂seedCubeLaw n m)+L*(1/2:ℝ)^m := by + rw [integral_add hi (integrable_const _)]; simp + rw [← he] + have his : Integrable (fun p => sampledDiff f i k p + L*(1/2:ℝ)^m) (seedCubeLaw n m) := + hi.add (integrable_const _) + apply integral_mono_ae hcell his + filter_upwards [seeds_in_unit n m] with p hp + have hup : ∀ j, (Function.update p i (flipSeed k (p i)) j).2 ∈ Icc (0:ℝ) 1 := by + intro j + by_cases hj : j = i + · subst j; simpa [flipSeed] using hp i + · simpa [hj] using hp j + have ha : |f (cubeSampler p)-f (cellPoint (fun j => (p j).1))| ≤ L*(1/2:ℝ)^m := by + simpa only [Real.dist_eq] using (hf.dist_le_mul _ _).trans + (mul_le_mul_of_nonneg_left (sample_cell_distance p hp) L.coe_nonneg) + have hb' : |f (cubeSampler (Function.update p i (flipSeed k (p i))))- + f (cellPoint (rowFlip i k (fun j => (p j).1)))| ≤ L*(1/2:ℝ)^m := by + have h := (hf.dist_le_mul _ _).trans + (mul_le_mul_of_nonneg_left (sample_cell_distance _ hup) L.coe_nonneg) + simpa only [Real.dist_eq, cells_update_flip] using h + dsimp only [sampledDiff, Function.comp_def] + rw [abs_div, abs_div, abs_of_pos (by norm_num : (0:ℝ)<2)] + have hx (a b c d : ℝ) : |a-b| ≤ |c-d| + |c-a| + |d-b| := by + calc + _ = |(a-c)+(c-d)+(d-b)| := by congr 1; ring + _ ≤ |a-c|+|c-d|+|d-b| := by linarith [abs_add_le (a-c) (c-d), abs_add_le ((a-c)+(c-d)) (d-b)] + _ = _ := by rw [abs_sub_comm a c]; ring + have hh := hx (f (cellPoint (fun j => (p j).1))) + (f (cellPoint (rowFlip i k (fun j => (p j).1)))) (f (cubeSampler p)) + (f (cubeSampler (Function.update p i (flipSeed k (p i))))) + linarith + +lemma total_rowInfluence_cell_bound {n m : ℕ} {L : ℝ≥0} {f : (Fin n → ℝ) → ℝ} + (hf : LipschitzWith L f) (hb : ∀ x, |f x| ≤ 1) : + (∑ i, ∑ k, rowInfluence (f ∘ cellPoint (n:=n) (m:=m)) i k) ≤ + L + (n:ℝ)*m*(L*(1/2:ℝ)^m) := by + have h := Finset.sum_le_sum (s:=Finset.univ) (fun (i : Fin n) _ => + Finset.sum_le_sum (s:=Finset.univ) (fun (k : Fin m) _ => rowInfluence_cell_bound hf hb i k)) + simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + nsmul_eq_mul] at h + have ht := total_sampled_influence (n:=n) (m:=m) hf hb + nlinarith + +end LargeIndependentSets.BooleanJunta + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/Circle.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/Circle.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d9579c57bcbbea53d9e2bccc60d0977ae8bac63 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/Circle.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.DyadicPrecision +import OAI.Combinatorics.IndependentSets.Reduction.PairEnergy + +namespace OAI + +namespace LargeIndependentSets +open MeasureTheory Set +open scoped BigOperators Classical NNReal + +abbrev Circle := AddCircle (1:ℝ) +instance circleProbability : IsProbabilityMeasure (volume : Measure Circle) where + measure_univ := by simp [Circle] +noncomputable def realToTorus {n : ℕ} (x : Fin n → ℝ) : Fin n → Circle := fun i => (x i : Circle) + +lemma circle_quotient_lipschitz : LipschitzWith 1 (fun x : ℝ => (x : Circle)) := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [NNReal.coe_one, one_mul, dist_eq_norm, ← AddCircle.coe_sub] + exact QuotientAddGroup.norm_mk_le_norm + +lemma realToTorus_lipschitz (n : ℕ) : LipschitzWith 1 (@realToTorus n) := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro i + exact (circle_quotient_lipschitz.dist_le_mul (x i) (y i)).trans + (by simpa using dist_le_pi_dist x y i) + +lemma circle_quotient_preserving : MeasurePreserving (fun x : ℝ => (x : Circle)) BooleanJunta.unitLaw volume := by + have h := AddCircle.measurePreserving_mk (1:ℝ) 0 + simpa only [zero_add, restrict_Ioc_eq_restrict_Icc, BooleanJunta.unitLaw] using h + +lemma realToTorus_preserving (n : ℕ) : MeasurePreserving (@realToTorus n) (BooleanJunta.unitCubeLaw n) volume := + measurePreserving_pi (fun _ => BooleanJunta.unitLaw) (fun _ => (volume : Measure Circle)) + (fun _ => circle_quotient_preserving) + +lemma torus_average_lift {n : ℕ} (S : Finset (Fin n)) {H : (Fin n → Circle) → ℝ} + (hH : Measurable H) (x : Fin n → ℝ) : + ProductAveraging.average BooleanJunta.unitLaw S (H ∘ realToTorus) x = + ProductAveraging.average (volume : Measure Circle) S H (realToTorus x) := by + unfold ProductAveraging.average + have he (y : Fin n → ℝ) : realToTorus (ProductAveraging.mix S (x,y)) = + ProductAveraging.mix S (realToTorus x,realToTorus y) := by + funext i + by_cases hi : i ∈ S <;> simp [realToTorus, ProductAveraging.mix, hi] + simp only [Function.comp_def, he] + have hm : Measurable (fun y : Fin n → Circle => H (ProductAveraging.mix S (realToTorus x,y))) := + hH.comp ((ProductAveraging.mix_measurable S).comp (measurable_const.prodMk measurable_id)) + exact ProductAveraging.integral_preserving (realToTorus_preserving n) hm.aestronglyMeasurable + +theorem torus_junta_uniform (L : ℝ≥0) {u : ℝ} (hu : 0 < u) : + ∃ J : ℕ, 1 ≤ J ∧ ∀ n : ℕ, ∀ H : (Fin n → Circle) → ℝ, + LipschitzWith L H → (∀ x, |H x| ≤ 1) → + ∃ S : Finset (Fin n), S.card ≤ J ∧ + (∫ x, (H x-ProductAveraging.average (volume : Measure Circle) S H x)^2) < u := by + obtain ⟨J,hJ,hall⟩ := BooleanJunta.real_cube_junta_uniform L hu + refine ⟨J,hJ,?_⟩ + intro n H hH hb + have hf : LipschitzWith L (H ∘ realToTorus (n:=n)) := by simpa using hH.comp (realToTorus_lipschitz n) + obtain ⟨S,hS,hi,he⟩ := hall n _ hf (fun x => hb _) + refine ⟨S,hS,?_⟩ + simp only [torus_average_lift S hH.continuous.measurable] at he + have ham := ProductAveraging.average_measurable (volume : Measure Circle) S hH.continuous.measurable + have hm : AEStronglyMeasurable (fun x => (H x-ProductAveraging.average (volume : Measure Circle) S H x)^2) volume := + ((hH.continuous.measurable.sub ham).pow_const 2).aestronglyMeasurable + have ha := ProductAveraging.integral_preserving (realToTorus_preserving n) hm + change (∫ x, ((H ∘ realToTorus) x- + ProductAveraging.average (volume : Measure Circle) S H (realToTorus x))^2 ∂BooleanJunta.unitCubeLaw n) = _ at ha + rw [ha] at he + exact he + +noncomputable def circleInfluence {n : ℕ} (i : Fin n) (H : (Fin n → Circle) → ℝ) : ℝ := + Real.sqrt (ProductAveraging.influenceSq (volume : Measure Circle) i H) + +theorem torus_influences (L : ℝ≥0) {ε : ℝ} (hε : 0 < ε) : + ∃ β : ℝ, 0 < β ∧ ∃ K : ℕ, 1 ≤ K ∧ + ∀ n : ℕ, ∀ H : (Fin n → Circle) → ℝ, + LipschitzWith L H → (∀ x, |H x| ≤ 1) → + (((∫ x, H x) = 0 ∧ ε < ∫ x, (H x)^2) → ∃ i, β ≤ circleInfluence i H) ∧ + (Finset.univ.filter (fun i => β/2 ≤ circleInfluence i H)).card ≤ K := by + obtain ⟨J,hJ,HJ⟩ := torus_junta_uniform L (u:=ε/12) (by positivity) + let b : ℝ := ε/(4*(4:ℝ)^J*J) + have hJp : (0:ℝ) β/2 ≤ circleInfluence i H) ⊆ + Finset.univ.filter (fun i => (β/2)^2 ≤ ProductAveraging.influenceSq (volume : Measure Circle) i H) := by + intro i hi + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _,?_⟩ + have h := (Finset.mem_filter.mp hi).2 + have hsq := (sq_le_sq₀ (by positivity : 0≤β/2) (Real.sqrt_nonneg _)).mpr h + simpa only [circleInfluence, Real.sq_sqrt (ProductAveraging.influenceSq_nonneg _ _ _)] using hsq + exact (Finset.card_le_card hsub).trans (hcard.trans hS) + +end LargeIndependentSets + +namespace LargeIndependentSets.ProductAveraging +open MeasureTheory Set +open scoped BigOperators Classical NNReal +noncomputable def reindex {ι κ α : Type*} (e : ι ≃ κ) (x : ι → α) : κ → α := x ∘ e.symm +lemma reindex_preserving {ι κ α : Type*} [Fintype ι] [Fintype κ] [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (e : ι ≃ κ) : + MeasurePreserving (reindex (α:=α) e) (Measure.pi (fun _ : ι => μ)) (Measure.pi (fun _ : κ => μ)) := by + convert measurePreserving_piCongrLeft (fun _ : κ => μ) e using 1 + funext x i + simp [reindex, MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply] +lemma reindex_lipschitz {ι κ α : Type*} [Fintype ι] [Fintype κ] [PseudoMetricSpace α] + (e : ι ≃ κ) : LipschitzWith 1 (reindex (α:=α) e) := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro i + exact dist_le_pi_dist x y (e.symm i) +lemma reindex_mix {ι κ α : Type*} [DecidableEq ι] [DecidableEq κ] + (e : ι ≃ κ) (S : Finset ι) (x y : ι → α) : + reindex e (mix S (x,y)) = mix (S.image e) (reindex e x,reindex e y) := by + funext i + have hi : i ∈ S.image e ↔ e.symm i ∈ S := by + constructor + · rintro h + obtain ⟨j,hj,he⟩ := Finset.mem_image.mp h + simpa [← he] using hj + · intro h + exact Finset.mem_image.mpr ⟨e.symm i,h,e.apply_symm_apply i⟩ + simp only [reindex,Function.comp_def,mix,hi] + +lemma average_reindex {ι κ α : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] (e : ι ≃ κ) + (S : Finset ι) {f : (κ → α) → ℝ} (hf : Measurable f) (x : ι → α) : + average μ S (f ∘ reindex e) x = average μ (S.image e) f (reindex e x) := by + have hm : Measurable (fun y => f (mix (S.image e) (reindex e x,y))) := + hf.comp ((mix_measurable _).comp (measurable_const.prodMk measurable_id)) + have h := integral_preserving (reindex_preserving μ e) hm.aestronglyMeasurable + unfold average + rw [← h] + apply integral_congr_ae + filter_upwards [] with y + simp only [Function.comp_def, reindex_mix] + +end LargeIndependentSets.ProductAveraging + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/CircleCost.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/CircleCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..85491e904c2b8fbd6dc042a785405843a78dca98 --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/CircleCost.lean @@ -0,0 +1,157 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.Total + +namespace OAI + +namespace LargeIndependentSets +namespace ShortestPaths +open scoped ENNReal + +def circleCost {D : ℕ} (x y : ZMod D) : ℕ := + min (x-y).val (D-(x-y).val) + +lemma circleCost_dist {D : ℕ} [NeZero D] (x y : ZMod D) : + dist (ZMod.toAddCircle x) (ZMod.toAddCircle y) = (circleCost x y : ℝ)/D := by + rw [dist_eq_norm,← map_sub,ZMod.toAddCircle_apply] + have hh := AddCircle.norm_div_natCast (p:=(1:ℝ)) (m:=(x-y).val) (n:=D) + simpa only [mul_one,one_mul,Nat.mod_eq_of_lt (ZMod.val_lt _),circleCost] using hh + +lemma circleCost_edist {D : ℕ} [NeZero D] (x y : ZMod D) : + edist (ZMod.toAddCircle x) (ZMod.toAddCircle y) = (circleCost x y : ℝ≥0∞)/D := by + have hd : 0 < (D:ℝ) := by exact_mod_cast (NeZero.pos D) + rw [edist_dist,circleCost_dist,ENNReal.ofReal_div_of_pos hd] + simp only [ENNReal.ofReal_natCast] + +lemma natSupCast {α : Type*} (s : Finset α) (f : α → ℕ) : + ((s.sup f : ℕ) : ℝ≥0∞) = s.sup (fun a => (f a : ℝ≥0∞)) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert a s ha ih => + rw [Finset.sup_insert,Finset.sup_insert,← ih] + by_cases h : f a ≤ s.sup f + · have hc : (f a : ℝ≥0∞) ≤ ((s.sup f : ℕ) : ℝ≥0∞) := by exact_mod_cast h + simp only [max_eq_right h,max_eq_right hc] + · have h' := le_of_lt (lt_of_not_ge h) + have hc : ((s.sup f : ℕ) : ℝ≥0∞) ≤ (f a : ℝ≥0∞) := by exact_mod_cast h' + simp only [max_eq_left h',max_eq_left hc] + +def copyCost {Q : Type*} [DecidableEq Q] {M : Q → Type*} [∀ q, Fintype (M q)] + {D : ℕ} (x y : GridLocation M D) : ℕ∞ := + if h : x.1 = y.1 then + (Finset.univ.sup (fun k : M x.1 => circleCost (x.2 k) (y.2 (h ▸ k))) : ℕ) + else ⊤ + +lemma copyCost_exact {Q : Type*} [DecidableEq Q] {M : Q → Type*} [∀ q, Fintype (M q)] + {D : ℕ} [NeZero D] (x y : GridLocation M D) : + (copyCost x y : ℝ≥0∞)/(D:ℝ≥0∞) = copyLength x y := by + unfold copyCost copyLength + split_ifs with h + · simp only [ENat.toENNReal_coe,natSupCast,Finset.sup_eq_iSup,Finset.mem_univ, + iSup_pos,ENNReal.iSup_div,circleCost_edist] + · exact ENNReal.top_div_of_ne_top (ENNReal.natCast_ne_top D) + +lemma forwardZero_iff {Q : Type*} {M : Q → Type*} (S : ProjectionSystem Q M) + {D : ℕ} (x y : GridLocation M D) : + S.ForwardZero D x y ↔ ∃ π : M x.1 → M y.1, S.imposed x.1 y.1 π ∧ x.2 = y.2 ∘ π := by + constructor + · intro h + cases h with + | link q q' π h v => exact ⟨π,h,rfl⟩ + · rintro ⟨π,hπ,h⟩ + rcases x with ⟨q,x⟩ + rcases y with ⟨q',y⟩ + dsimp at * + rw [h] + exact .link q q' π hπ y + +instance forwardZero_decidable {Q : Type*} {M : Q → Type*} + [∀ q, Fintype (M q)] [∀ q, DecidableEq (M q)] + (S : ProjectionSystem Q M) [∀ q q' π, Decidable (S.imposed q q' π)] + {D : ℕ} [NeZero D] (x y : GridLocation M D) : Decidable (S.ForwardZero D x y) := + decidable_of_iff _ (forwardZero_iff S x y).symm + +instance zeroLink_decidable {Q : Type*} {M : Q → Type*} + [∀ q, Fintype (M q)] [∀ q, DecidableEq (M q)] + (S : ProjectionSystem Q M) [∀ q q' π, Decidable (S.imposed q q' π)] + {D : ℕ} [NeZero D] (x y : GridLocation M D) : Decidable (S.ZeroLink D x y) := + inferInstanceAs (Decidable (S.ForwardZero D x y ∨ S.ForwardZero D y x)) + +def linkCost {Q : Type*} [DecidableEq Q] {M : Q → Type*} + [∀ q, Fintype (M q)] [∀ q, DecidableEq (M q)] + (S : ProjectionSystem Q M) [∀ q q' π, Decidable (S.imposed q q' π)] + {D : ℕ} [NeZero D] (x y : GridLocation M D) : ℕ∞ := + if S.ZeroLink D x y then 0 else copyCost x y + +lemma linkCost_exact {Q : Type*} [DecidableEq Q] {M : Q → Type*} + [∀ q, Fintype (M q)] [∀ q, DecidableEq (M q)] + (S : ProjectionSystem Q M) [∀ q q' π, Decidable (S.imposed q q' π)] + {D : ℕ} [NeZero D] (x y : GridLocation M D) : + (linkCost S x y : ℝ≥0∞)/(D:ℝ≥0∞) = S.linkLength x y := by + unfold linkCost ProjectionSystem.linkLength + split_ifs + · simp + · exact copyCost_exact x y + +lemma scaled_min (d : ℝ≥0∞) (a b : ℕ∞) : + ((min a b : ℕ∞) : ℝ≥0∞)/d = min ((a:ℝ≥0∞)/d) ((b:ℝ≥0∞)/d) := by + rcases le_total a b with h | h + · have hh := ENNReal.div_le_div_right (ENat.toENNReal_le.mpr h) d + simp only [min_eq_left h,min_eq_left hh] + · have hh := ENNReal.div_le_div_right (ENat.toENNReal_le.mpr h) d + simp only [min_eq_right h,min_eq_right hh] + +lemma Matrix.scaled_allPairs_exact {n : ℕ} (a : Matrix n) (D : ℕ) (i j : Fin n) : + (a.allPairs.get i j : ℝ≥0∞)/(D:ℝ≥0∞) = + pathDistance (fun x y => (a.get x y : ℝ≥0∞)/(D:ℝ≥0∞)) i j := by + rw [Matrix.allPairs,Matrix.run_get] + have hm := congrFun (congrFun (closure_map (fun z : ℕ∞ => (z:ℝ≥0∞)/(D:ℝ≥0∞)) + (scaled_min _) (fun a b => by rw [ENat.toENNReal_add,ENNReal.add_div]) + a.get (List.finRange n)) i) j + rw [hm] + exact closure_eq_distance _ _ (fun z => List.mem_finRange z) i j + +lemma walkLength_reindex {X Y : Type*} (e : X → Y) (w : Y → Y → ℝ≥0∞) (x : X) + (zs : List X) (y : X) : + walkLength (fun x y => w (e x) (e y)) x zs y = walkLength w (e x) (zs.map e) (e y) := by + induction zs generalizing x with + | nil => rfl + | cons z zs ih => simp only [walkLength,List.map_cons,ih] + +lemma pathDistance_reindex {X Y : Type*} (e : X ≃ Y) (w : Y → Y → ℝ≥0∞) (x y : X) : + pathDistance (fun x y => w (e x) (e y)) x y = pathDistance w (e x) (e y) := by + unfold pathDistance + apply le_antisymm + · apply le_iInf + intro zs + apply iInf_le_of_le (zs.map e.symm) + rw [walkLength_reindex] + simp + · apply le_iInf + intro zs + rw [walkLength_reindex] + exact iInf_le_of_le (zs.map e) le_rfl + +def gridMatrix {Q : Type*} [DecidableEq Q] {M : Q → Type*} + [∀ q, Fintype (M q)] [∀ q, DecidableEq (M q)] + (S : ProjectionSystem Q M) [∀ q q' π, Decidable (S.imposed q q' π)] + {D : ℕ} [NeZero D] {n : ℕ} (e : Fin n ≃ GridLocation M D) : Matrix n := + Vector.ofFn (fun i => Vector.ofFn (fun j => linkCost S (e i) (e j))) + +theorem grid_allPairs_exact {Q : Type*} [DecidableEq Q] {M : Q → Type*} + [∀ q, Fintype (M q)] [∀ q, DecidableEq (M q)] + (S : ProjectionSystem Q M) [∀ q q' π, Decidable (S.imposed q q' π)] + {D : ℕ} [NeZero D] {n : ℕ} (e : Fin n ≃ GridLocation M D) (i j : Fin n) : + ((gridMatrix S e).allPairs.get i j : ℝ≥0∞)/(D:ℝ≥0∞) = + pathDistance S.linkLength (e i) (e j) := by + rw [Matrix.scaled_allPairs_exact] + have hh : (fun x y => ((gridMatrix S e).get x y : ℝ≥0∞)/(D:ℝ≥0∞)) = + (fun x y => S.linkLength (e x) (e y)) := by + funext x y + simpa only [gridMatrix,Matrix.get,Vector.getElem_ofFn] using linkCost_exact S (e x) (e y) + rw [hh,pathDistance_reindex] + +end ShortestPaths +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/ClampCube.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/ClampCube.lean new file mode 100644 index 0000000000000000000000000000000000000000..df74b1495509501414cc35e5504870cefbd3776f --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/ClampCube.lean @@ -0,0 +1,77 @@ +import Mathlib +import OAI.Combinatorics.IndependentSets.Reduction.DyadicPrecision +import OAI.Combinatorics.IndependentSets.Geometry.CoordinateAverage + +namespace OAI + +namespace LargeIndependentSets +open MeasureTheory Set +open scoped BigOperators Classical unitInterval NNReal + +noncomputable def clampCube {n : ℕ} (x : Fin n → ℝ) : Fin n → I := + fun i => projIcc 0 1 (by norm_num) (x i) + +lemma clampCube_lipschitz (n : ℕ) : LipschitzWith 1 (@clampCube n) := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff (dist_nonneg)).mpr + intro i + exact ((LipschitzWith.projIcc (by norm_num : (0:ℝ) ≤ 1)).dist_le_mul (x i) (y i)).trans + (by simpa using (dist_le_pi_dist x y i)) + +lemma clampCube_coe {n : ℕ} (x : Fin n → I) : clampCube (fun i => (x i : ℝ)) = x := by + funext i + exact projIcc_of_mem (by norm_num) (x i).property + +lemma cube_coe_preserving (n : ℕ) : + MeasurePreserving (fun x : Fin n → I => fun i => (x i : ℝ)) + volume (BooleanJunta.unitCubeLaw n) := by + exact measurePreserving_pi (fun _ => (volume : Measure I)) + (fun _ => BooleanJunta.unitLaw) (fun _ => unitInterval.measurePreserving_coe) + +lemma cube_average_clamp {n : ℕ} (S : Finset (Fin n)) + {f : (Fin n → I) → ℝ} (hf : Measurable f) (x : Fin n → I) : + ProductAveraging.average BooleanJunta.unitLaw S (f ∘ clampCube) (fun i => (x i : ℝ)) = + coordinateAverage S f x := by + let g : (Fin n → ℝ) → ℝ := fun y => f (clampCube (ProductAveraging.mix S ((fun i => (x i : ℝ)),y))) + have hg : Measurable g := hf.comp ((clampCube_lipschitz n).continuous.measurable.comp + ((ProductAveraging.mix_measurable S).comp (measurable_const.prodMk measurable_id))) + have h := ProductAveraging.integral_preserving (cube_coe_preserving n) hg.aestronglyMeasurable + change (∫ y, g y ∂BooleanJunta.unitCubeLaw n) = _ + rw [← h] + unfold coordinateAverage + apply integral_congr_ae + filter_upwards [] with y + dsimp [g] + congr 1 + funext i + by_cases hi : i ∈ S <;> simp [clampCube, ProductAveraging.mix, hi, projIcc_of_mem, (x i).property, (y i).property] + +theorem cubeJunta : CubeJuntaStatement := by + intro L τ hτ + obtain ⟨J,hJ,H⟩ := BooleanJunta.real_cube_junta_uniform L (sq_pos_of_pos hτ) + refine ⟨J,hJ,?_⟩ + intro n hn f hf hb + have he : LipschitzWith L (f ∘ clampCube (n:=n)) := by + simpa using hf.comp (clampCube_lipschitz n) + obtain ⟨S,hS,hi,herr⟩ := H n (f ∘ clampCube) he (fun x => hb _) + have hpoint (x : Fin n → I) : + ((f ∘ clampCube) (fun i => (x i : ℝ)) - + ProductAveraging.average BooleanJunta.unitLaw S (f ∘ clampCube) (fun i => (x i : ℝ)))^2 = + (f x-coordinateAverage S f x)^2 := by + rw [cube_average_clamp S hf.continuous.measurable] + simp only [Function.comp_def, clampCube_coe] + have hi' := (cube_coe_preserving n).integrable_comp_of_integrable hi + refine ⟨S,hS,?_,?_⟩ + · change Integrable (fun x => (f x-coordinateAverage S f x)^2) volume + convert hi' using 1 + funext x + exact (hpoint x).symm + · have ht := ProductAveraging.integral_preserving (cube_coe_preserving n) hi.aestronglyMeasurable + simp only [hpoint] at ht + exact ht.trans_lt herr + +end LargeIndependentSets + +end OAI diff --git a/lean/OAI/Combinatorics/IndependentSets/Reduction/Cube.lean b/lean/OAI/Combinatorics/IndependentSets/Reduction/Cube.lean new file mode 100644 index 0000000000000000000000000000000000000000..9602d9ab4c673b2d38c56eef022ba2337ed4528c --- /dev/null +++ b/lean/OAI/Combinatorics/IndependentSets/Reduction/Cube.lean @@ -0,0 +1,224 @@ +import Mathlib + +namespace OAI + +namespace LargeIndependentSets.BooleanJunta +open scoped BigOperators + +@[reducible] def Cube : ℕ → Type + | 0 => Unit + | n+1 => Bool × Cube n + +instance cubeFintype : (n : ℕ) → Fintype (Cube n) + | 0 => inferInstanceAs (Fintype Unit) + | n+1 => by + letI := cubeFintype n + exact inferInstanceAs (Fintype (Bool × Cube n)) + +instance cubeNonempty : (n : ℕ) → Nonempty (Cube n) + | 0 => inferInstanceAs (Nonempty Unit) + | n+1 => @instNonemptyProd Bool (Cube n) _ (cubeNonempty n) + +noncomputable def mean {n : ℕ} (f : Cube n → ℝ) : ℝ := 𝔼 x, f x + +lemma mean_zero (f : Cube 0 → ℝ) : mean f = f () := by + change (𝔼 x : Unit, f x) = f () + simp [Finset.expect_eq_sum_div_card] + +lemma mean_succ {n : ℕ} (f : Cube (n+1) → ℝ) : + mean f = (mean (fun x => f (false,x)) + mean (fun x => f (true,x))) / 2 := by + change (𝔼 x : Bool × Cube n, f x) = _ + rw [show (Finset.univ : Finset (Bool × Cube n)) = Finset.univ ×ˢ Finset.univ from rfl, + Finset.expect_product] + simp [Finset.expect_eq_sum_div_card, mean, add_comm] + +lemma mean_add {n : ℕ} (f g : Cube n → ℝ) : + mean (fun x => f x + g x) = mean f + mean g := Finset.expect_add_distrib _ _ _ + +lemma mean_sub {n : ℕ} (f g : Cube n → ℝ) : + mean (fun x => f x - g x) = mean f - mean g := Finset.expect_sub_distrib _ _ _ + +lemma mean_mul {n : ℕ} (a : ℝ) (f : Cube n → ℝ) : + mean (fun x => a * f x) = a * mean f := (Finset.mul_expect _ _ _).symm + +lemma mean_nonneg {n : ℕ} {f : Cube n → ℝ} (hf : ∀ x, 0 ≤ f x) : 0 ≤ mean f := + Finset.expect_nonneg (fun x _ => hf x) + +lemma mean_mono {n : ℕ} {f g : Cube n → ℝ} (h : ∀ x, f x ≤ g x) : mean f ≤ mean g := + Finset.expect_le_expect (fun x _ => h x) + +lemma mean_cauchy {n : ℕ} (f g : Cube n → ℝ) : + (mean (fun x => f x * g x))^2 ≤ mean (fun x => f x^2) * mean (fun x => g x^2) := + Finset.expect_mul_sq_le_sq_mul_sq _ _ _ + +noncomputable def evenPart {n : ℕ} (f : Cube (n+1) → ℝ) (x : Cube n) := + (f (false,x) + f (true,x)) / 2 + +noncomputable def oddPart {n : ℕ} (f : Cube (n+1) → ℝ) (x : Cube n) := + (f (false,x) - f (true,x)) / 2 + +noncomputable def noise (ρ : ℝ) : {n : ℕ} → (Cube n → ℝ) → Cube n → ℝ + | 0, f, x => f x + | _+1, f, (b,x) => noise ρ (evenPart f) x + (if b then -ρ else ρ) * noise ρ (oddPart f) x + +lemma mean_square_split {n : ℕ} (f : Cube (n+1) → ℝ) : + mean (fun x => f x^2) = mean (fun x => evenPart f x^2) + mean (fun x => oddPart f x^2) := by + rw [mean_succ, ← mean_add] + rw [← mean_add, div_eq_mul_inv, mul_comm _ (2⁻¹), ← mean_mul] + congr 1 + funext x + dsimp [evenPart, oddPart] + ring + +lemma mean_noise_fourth {n : ℕ} (ρ : ℝ) (f : Cube (n+1) → ℝ) : + mean (fun x => noise ρ f x ^ 4) = + mean (fun x => noise ρ (evenPart f) x ^ 4) + + 6 * ρ^2 * mean (fun x => (noise ρ (evenPart f) x)^2 * (noise ρ (oddPart f) x)^2) + + ρ^4 * mean (fun x => noise ρ (oddPart f) x ^ 4) := by + rw [mean_succ, ← mean_add, div_eq_mul_inv, mul_comm _ (2⁻¹), ← mean_mul, ← mean_mul, ← mean_add, + ← mean_mul, ← mean_add] + congr 1 + funext x + dsimp [noise] + ring + +theorem hypercontractive_two_four {n : ℕ} (f : Cube n → ℝ) : + mean (fun x => noise (1/2) f x ^ 4) ≤ (mean (fun x => f x^2))^2 := by + induction n with + | zero => + simp only [mean_zero, noise] + nlinarith + | succ n ih => + let a := evenPart f + let b := oddPart f + let A := mean (fun x => a x^2) + let B := mean (fun x => b x^2) + let C := mean (fun x => noise (1/2) a x^4) + let D := mean (fun x => noise (1/2) b x^4) + let E := mean (fun x => (noise (1/2) a x)^2 * (noise (1/2) b x)^2) + have hA : 0 ≤ A := mean_nonneg (fun x => sq_nonneg _) + have hB : 0 ≤ B := mean_nonneg (fun x => sq_nonneg _) + have hC : 0 ≤ C := mean_nonneg (fun x => by positivity) + have hD : 0 ≤ D := mean_nonneg (fun x => by positivity) + have hE : 0 ≤ E := mean_nonneg (fun x => mul_nonneg (sq_nonneg _) (sq_nonneg _)) + have hCA : C ≤ A^2 := ih a + have hDB : D ≤ B^2 := ih b + have hEC : E^2 ≤ C*D := by + have hc := mean_cauchy (fun x => (noise (1/2) a x)^2) (fun x => (noise (1/2) b x)^2) + have hpow (x : ℝ) : (x^2)^2 = x^4 := by ring + simp only [hpow] at hc + exact hc + have hmul : C*D ≤ A^2*B^2 := mul_le_mul hCA hDB hD (sq_nonneg A) + have hEAB : E ≤ A*B := by + nlinarith [hEC.trans hmul, mul_nonneg hA hB] + rw [mean_noise_fourth, mean_square_split] + change C + 6*(1/2:ℝ)^2*E + (1/2:ℝ)^4*D ≤ (A+B)^2 + nlinarith [mul_nonneg hA hB] + +lemma evenPart_noise {n : ℕ} (ρ : ℝ) (f : Cube (n+1) → ℝ) : + evenPart (noise ρ f) = noise ρ (evenPart f) := by + funext x + dsimp [evenPart, noise] + ring + +lemma oddPart_noise {n : ℕ} (ρ : ℝ) (f : Cube (n+1) → ℝ) : + oddPart (noise ρ f) = fun x => ρ * noise ρ (oddPart f) x := by + funext x + dsimp [oddPart, noise] + ring + +lemma mean_product_split {n : ℕ} (f g : Cube (n+1) → ℝ) : + mean (fun x => f x * g x) = + mean (fun x => evenPart f x * evenPart g x) + + mean (fun x => oddPart f x * oddPart g x) := by + rw [mean_succ, ← mean_add, div_eq_mul_inv, mul_comm _ (2⁻¹), ← mean_mul, + ← mean_add] + congr 1 + funext x + dsimp [evenPart, oddPart] + ring + +lemma noise_selfadjoint {n : ℕ} (ρ : ℝ) (f g : Cube n → ℝ) : + mean (fun x => f x * noise ρ g x) = mean (fun x => noise ρ f x * g x) := by + induction n with + | zero => simp only [mean_zero, noise] + | succ n ih => + rw [mean_product_split, mean_product_split, evenPart_noise, oddPart_noise, + evenPart_noise, oddPart_noise, ih] + have h₁ : mean (fun x => oddPart f x * (ρ * noise ρ (oddPart g) x)) = + ρ * mean (fun x => oddPart f x * noise ρ (oddPart g) x) := by + rw [← mean_mul] + congr 1; funext x; ring + have h₂ : mean (fun x => ρ * noise ρ (oddPart f) x * oddPart g x) = + ρ * mean (fun x => noise ρ (oddPart f) x * oddPart g x) := by + rw [← mean_mul] + congr 1; funext x; ring + rw [h₁, h₂, ih] + +lemma mean_holder_four {n : ℕ} (g h : Cube n → ℝ) : + (mean (fun x => g x * h x))^4 ≤ + (mean (fun x => |g x|))^2 * mean (fun x => g x^2) * mean (fun x => h x^4) := by + let G := mean (fun x => |g x|) + let U := mean (fun x => |g x| * |h x|) + let V := mean (fun x => |g x| * h x^2) + have hG : 0 ≤ G := mean_nonneg (fun x => abs_nonneg _) + have hU : 0 ≤ U := mean_nonneg (fun x => mul_nonneg (abs_nonneg _) (abs_nonneg _)) + have hV : 0 ≤ V := mean_nonneg (fun x => mul_nonneg (abs_nonneg _) (sq_nonneg _)) + have huv : U^2 ≤ G*V := by + have hc := mean_cauchy (fun x => Real.sqrt |g x|) (fun x => Real.sqrt |g x| * |h x|) + have he₁ : (fun x => Real.sqrt |g x| * (Real.sqrt |g x| * |h x|)) = + (fun x => |g x| * |h x|) := by + funext x + rw [← mul_assoc, Real.mul_self_sqrt (abs_nonneg _)] + have he₂ : (fun x => (Real.sqrt |g x|)^2) = (fun x => |g x|) := by + funext x; exact Real.sq_sqrt (abs_nonneg _) + have he₃ : (fun x => (Real.sqrt |g x| * |h x|)^2) = (fun x => |g x| * h x^2) := by + funext x + rw [mul_pow, Real.sq_sqrt (abs_nonneg _), sq_abs] + simpa only [he₁, he₂, he₃] using hc + have hv : V^2 ≤ mean (fun x => g x^2) * mean (fun x => h x^4) := by + have hc := mean_cauchy (fun x => |g x|) (fun x => h x^2) + have hpow (x : ℝ) : (x^2)^2 = x^4 := by ring + simp only [sq_abs, hpow] at hc + exact hc + have habs : |mean (fun x => g x * h x)| ≤ U := by + have hh := Finset.abs_expect_le Finset.univ (fun x => g x*h x) + simp only [abs_mul] at hh + exact hh + have hs : (mean (fun x => g x * h x))^2 ≤ U^2 := by + have ha := abs_nonneg (mean (fun x => g x*h x)) + nlinarith [sq_abs (mean (fun x => g x*h x))] + have hsq : (mean (fun x => g x * h x))^4 ≤ (G*V)^2 := by + nlinarith [hs.trans huv, sq_nonneg (mean (fun x => g x*h x))] + have hm := mul_le_mul_of_nonneg_left hv (sq_nonneg G) + nlinarith + +theorem noise_small_l1 {n : ℕ} (g : Cube n → ℝ) (hg : ∀ x, |g x| ≤ 1) : + (mean (fun x => noise (1/2) g x^2))^2 ≤ (mean (fun x => |g x|))^3 := by + let u := noise (1/2) g + let A := mean (fun x => u x^2) + let I := mean (fun x => |g x|) + have hA : 0 ≤ A := mean_nonneg (fun x => sq_nonneg _) + have hI : 0 ≤ I := mean_nonneg (fun x => abs_nonneg _) + have hgs : mean (fun x => g x^2) ≤ I := by + apply mean_mono + intro x + nlinarith [hg x, abs_nonneg (g x), sq_abs (g x)] + have he : mean (fun x => g x * noise (1/2) u x) = A := by + rw [noise_selfadjoint] + congr 1; funext x; simp only [u, pow_two] + have h := mean_holder_four g (noise (1/2) u) + rw [he] at h + have hh := hypercontractive_two_four u + have hp : 0 ≤ I^2 * mean (fun x => g x^2) := + mul_nonneg (sq_nonneg _) (mean_nonneg (fun x => sq_nonneg _)) + have h₂ := mul_le_mul_of_nonneg_left hh hp + have h₃ := mul_le_mul_of_nonneg_left hgs (sq_nonneg I) + have h₄ := mul_le_mul_of_nonneg_right h₃ (sq_nonneg A) + change A^2 ≤ I^3 + change _ ≤ _ * A^2 at h₂ + nlinarith [h.trans h₂] + +end LargeIndependentSets.BooleanJunta + +end OAI

F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin n,IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + 0 < (-1:ℝ)^n*(flagCharacteristic n F G w).eval 0 := by + have hW:=flagGram_det_pos F G w hF hG hw hi + have hX:=flagPencil_zero_det_pos F G w hF hG hw h2 + have he:=flagCharacteristic_eval F G w 0 hW.ne' hi h2 + have hs : (-1:ℝ)^n*(-1:ℝ)^n=1 := by rw [←pow_add,show n+n=2*n by omega,pow_mul];norm_num + have he' : (flagGram n F G w).det*((-1:ℝ)^n*(flagCharacteristic n F G w).eval 0)= + (flagPencil n F G w 0).det := by + calc + _ = (-1:ℝ)^n*((flagGram n F G w).det*(flagCharacteristic n F G w).eval 0) := by ring + _ = _ := by rw [he,←mul_assoc,hs,one_mul] + exact pos_of_mul_pos_right (he'.symm ▸ hX) hW.le +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset +lemma monic_eq_root_product {n : ℕ} (p : ℝ[X]) (r : Fin n → ℝ) + (hp : p.Monic) (hd : p.natDegree=n) (hr : Function.Injective r) + (hz : ∀ i,p.eval (r i)=0) : p=∏ i : Fin n,(X-Polynomial.C (r i)) := by + apply eq_of_monic_of_dvd_of_natDegree_le (monic_prod_X_sub_C r univ) hp + · exact Fintype.prod_dvd_of_coprime (pairwise_coprime_X_sub_C hr) + (fun i=>dvd_iff_isRoot.mpr (hz i)) + · simp [hd] +lemma product_cut_sign {n : ℕ} (r : Fin n → ℝ) (x : ℝ) (k : ℕ) (hk : k≤n) + (hl : ∀ i : Fin n,i.val simp + | succ n ih => + rw [Fin.prod_univ_castSucc] + by_cases he : k=n+1 + · subst k + simp only [Nat.sub_self,pow_zero,one_mul] + apply mul_pos + · apply prod_pos + intro i _ + exact sub_pos.mpr (hl i.castSucc (by omega)) + · exact sub_pos.mpr (hl (Fin.last n) (by simp)) + · have hk' : k≤n := by omega + have h := ih (fun i=>r i.castSucc) k hk' (fun i h=>hl i.castSucc h) (fun i h=>hu i.castSucc h) + have ht := hu (Fin.last n) (by simpa using hk') + have hn : n+1-k=(n-k)+1 := by omega + rw [hn,pow_succ] + nlinarith only [mul_neg_of_pos_of_neg h (sub_neg.mpr ht)] +lemma interlacing_product_sign {n : ℕ} (a : Fin n → ℝ) (r : Fin (n+1) → ℝ) + (hr : StrictMono r) (ha : ∀ i,a i exact False.elim (not_lt_of_ge (Fin.le_last _) hij) + | cast i => + cases j using Fin.lastCases with + | last => simpa using hR i + | cast j => simpa only [Fin.lastCases_castSucc] using hc (by simpa using hij) +lemma continuous_root_between (f : ℝ → ℝ) (a b : ℝ) (hc : Continuous f) + (hab : ap.eval x) (b j.castSucc) (b j.succ) + p.continuous (hb (Fin.castSucc_lt_succ (i:=j))) (hs j) + choose r hr using he + refine ⟨r,?_,fun j=>⟨(hr j).1,(hr j).2.1⟩,fun j=>(hr j).2.2⟩ + intro i j hij + exact (hr i).2.1.trans_le (hb.monotone (show i.succ ≤ j.castSucc from hij)) |>.trans (hr j).1 +lemma alternating_sign_opposite (a b : ℝ) (k : ℕ) + (ha : 0 < (-1:ℝ)^(k+1)*a) (hb : 0 < (-1:ℝ)^k*b) : a*b<0 := by + have hh:=mul_pos ha hb + have hp : (-1:ℝ)^k*(-1:ℝ)^k=1 := by + rw [←pow_add,show k+k=2*k by omega,pow_mul] + norm_num + rw [pow_succ] at hh + have he : ((-1:ℝ)^k*(-1)*a)*((-1:ℝ)^k*b)= -(((-1:ℝ)^k*(-1:ℝ)^k)*(a*b)) := by ring + rw [he,hp,one_mul] at hh + linarith +/-- A polynomial with the Sturm signs at a positive ordered node vector has a +root in each intervening interval, including the first and last. -/ +theorem polynomial_sturm_intervals {n : ℕ} (p : ℝ[X]) (r : Fin n → ℝ) + (hr : StrictMono r) (hr0 : ∀ i,0p.eval x) atTop atTop) : + ∃ s : Fin (n+1) → ℝ,StrictMono s ∧ (∀ i,0?_) j + · simpa [c] using hzero + · simpa [c,Nat.succ_sub_succ_eq_sub] using hrootSigns i + obtain ⟨R,hR0,hR⟩ := ((htop.eventually (eventually_gt_atTop 0)).and + (eventually_gt_atTop (c (Fin.last n)))).exists + have hRc (i : Fin (n+1)) : c i?_) j + · have hh:=hcs (Fin.last n) + have hh' : p.eval (c (Fin.last n))<0 := by simpa using hh + simpa [b] using mul_neg_of_neg_of_pos hh' hR0 + · have h1:=hcs i.castSucc + have h2:=hcs i.succ + have hn : n+1-i.castSucc.val=(n+1-i.succ.val)+1 := by simp;omega + rw [hn] at h1 + have he:=alternating_sign_opposite _ _ _ h1 h2 + simpa only [b,←Fin.castSucc_succ,Fin.lastCases_castSucc] using he + obtain ⟨s,hs,hbounds,hz⟩ := root_between_each p b hb hbs + refine ⟨s,hs,?_,hz,?_⟩ + · intro i + have h0 : b 0=0 := by + change Fin.lastCases R c (Fin.castSucc (0:Fin (n+1)))=(0:ℝ) + simp only [Fin.lastCases_castSucc,c,Fin.cons_zero] + have hle : b 0 ≤ b i.castSucc := hb.monotone (Fin.zero_le _) + rw [h0] at hle + exact hle.trans_lt (hbounds i).1 + · intro i + have h1:=(hbounds i.castSucc).2 + have h2:=(hbounds i.succ).1 + exact ⟨by simpa only [b,c,←Fin.castSucc_succ,Fin.lastCases_castSucc,Fin.cons_succ] using h1,by simpa only [b,c,Fin.lastCases_castSucc,Fin.cons_succ] using h2⟩ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset Filter +/-- Strict positive interlacing, with the exact characteristic factorization. -/ +def PositiveInterlacing (p q : ℝ[X]) (n : ℕ) : Prop := + ∃ a : Fin n → ℝ,∃ r : Fin (n+1) → ℝ,StrictMono a ∧ StrictMono r ∧ + (∀ i,0p.eval x) atTop atTop := by + apply p.tendsto_atTop_of_leadingCoeff_nonneg + · exact natDegree_pos_iff_degree_pos.mp (by omega) + · rw [hp.leadingCoeff] + norm_num +/-- The sign relation for a one-dimensional oblique extension implies real, simple, positive, interlacing roots for every finite prefix. -/ +theorem polynomial_sturm_chain {N : ℕ} (p : ℕ → ℝ[X]) + (hm : ∀ k,k ≤ N → (p k).Monic) (hd : ∀ k,k ≤ N → (p k).natDegree=k) + (hzero : ∀ k,k ≤ N → 0 < (-1:ℝ)^k*(p k).eval 0) + (hstep : ∀ k,k+2 ≤ N → ∀ x,(p (k+1)).eval x=0 → + ∃ C : ℝ,0 + intro hn + let a : Fin 0 → ℝ := Fin.elim0 + have ha : StrictMono a := by intro i;exact Fin.elim0 i + have ha0 : ∀ i,0Fin.elim0 i + have hz : ∀ j : Fin 0,0 < (-1:ℝ)^(0-j.val)*(p 1).eval (a j) := fun i=>Fin.elim0 i + obtain ⟨r,hr,hr0,hrz,hra⟩ := polynomial_sturm_intervals (p 1) a ha ha0 hz (hzero _ hn) + (monic_polynomial_tendsto (p 1) (hm _ hn) (hd _ hn)) + refine ⟨a,r,ha,hr,ha0,hr0,?_,?_,fun i=>Fin.elim0 i⟩ + · exact monic_eq_root_product (p 0) a (hm _ (by omega)) (hd _ (by omega)) ha.injective (fun i=>Fin.elim0 i) + · exact monic_eq_root_product (p 1) r (hm _ hn) (hd _ hn) hr.injective hrz + | succ n ih => + intro hn + obtain ⟨a,r,ha,hr,ha0,hr0,hpa,hpr,hinter⟩ := ih (by omega) + have hrz (j : Fin (n+1)) : (p (n+1)).eval (r j)=0 := by + rw [hpr,eval_prod] + apply prod_eq_zero (mem_univ j) + simp + have hsign (j : Fin (n+1)) : 0 < (-1:ℝ)^(n+1-j.val)*(p (n+2)).eval (r j) := by + have hsmall := interlacing_product_sign a r hr (fun i=>(hinter i).2) (fun i=>(hinter i).1) j + have hse : (p n).eval (r j)=∏ i,(r j-a i) := by simp only [hpa,eval_prod,eval_sub,eval_X,eval_C] + rw [←hse] at hsmall + obtain ⟨C,hC,he⟩ := hstep n (by omega) (r j) (hrz j) + have hj : n+1-j.val=(n-j.val)+1 := by omega + rw [hj,pow_succ,he] + have he' : ((-1:ℝ)^(n-j.val)*(-1))*(-C*(p n).eval (r j))=C*((-1:ℝ)^(n-j.val)*(p n).eval (r j)) := by ring + rw [he'] + exact mul_pos hC hsmall + obtain ⟨s,hs,hs0,hsz,hsr⟩ := polynomial_sturm_intervals (p (n+2)) r hr hr0 hsign (hzero _ hn) + (monic_polynomial_tendsto _ (hm _ hn) (hd _ hn)) + exact ⟨r,s,hr,hs,hr0,hs0,hpr, + monic_eq_root_product _ s (hm _ hn) (hd _ hn) hs.injective hsz,hsr⟩ +end CriticalHoneycomb.FiniteFunctional.StripAsymptotic + +end + + +section +namespace CriticalHoneycomb.FiniteFunctional.StripAsymptotic +open Polynomial Finset +lemma positive_fraction_mono {A B x y : ℝ} (hA : 0(A+x)/(B+x) + have hf (x : ℝ) (hx : 0 ≤ x) : 0(hf _ (ha i).le).le)) (hf _ (hr 0).le).le + · have hprod : (∏ i : Fin n,f (r i.castSucc)) ≤ ∏ i : Fin n,f (a i) := by + apply prod_le_prod₀ + · intro i _;exact (hf _ (hr i.castSucc).le).le + · intro i _;exact positive_fraction_mono hA hAB (hr i.castSucc).le (hi i).1.le + change (∏ i : Fin (n+1),f (r i)) ≤ ∏ i : Fin n,f (a i) + rw [Fin.prod_univ_castSucc] + calc + _ ≤ (∏ i : Fin n,f (a i))*1 := mul_le_mul hprod (hf1 _ (hr _).le) (hf _ (hr _).le).le + (prod_nonneg (fun i _=>(hf _ (ha i).le).le)) + _ = _ := mul_one _ +lemma polynomial_product_negative_ratio {n : ℕ} (a : Fin n → ℝ) (A B : ℝ) : + (∏ i : Fin n,(X-Polynomial.C (a i))).eval (-A)/(∏ i : Fin n,(X-Polynomial.C (a i))).eval (-B)= + ∏ i : Fin n,(A+a i)/(B+a i) := by + simp only [eval_prod,eval_sub,eval_X,eval_C,←prod_div_distrib] + apply prod_congr rfl + intro i _ + rw [show -A-a i= -(A+a i) by ring,show -B-a i= -(B+a i) by ring,neg_div_neg_eq] +theorem positive_interlacing_ratio {n : ℕ} (p q : ℝ[X]) (hi : PositiveInterlacing p q n) + {A B : ℝ} (hA : 0F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) + (h2 : ∀ i j : Fin (n+2),IntegrableOn (fun p=>p^2*F i (p^2)*G j (p^2)*w p) (Set.Ioi 0)) : + ∃ C : ℝ,0hF k (by omega) + have hG' : PositiveFlag G (n+1) := fun k hk=>hG k (by omega) + have hFn : PositiveFlag F n := fun k hk=>hF k (by omega) + have hGn : PositiveFlag G n := fun k hk=>hG k (by omega) + have hW1:=flagGram_det_pos F G w hF' hG' hw (fun i j=>hi i.castSucc j.castSucc) + have hWn:=flagGram_det_pos F G w hFn hGn hw (fun i j=>hi i.castSucc.castSucc j.castSucc.castSucc) + have hWb:=flagGram_det_pos F G w hF hG hw hi + have hzp := (flagCharacteristic_eval_zero_iff F G w r hW1.ne' + (fun i j=>hi i.castSucc j.castSucc) (fun i j=>h2 i.castSucc j.castSucc)).mp hz + obtain ⟨_,L,R,hL,hR,hborder⟩ := flagPencil_sturm F G w r hzp hF hG hFc hGc hw (flagPencil_integrable F G w r hi h2) + have hen:=flagCharacteristic_eval F G w r hWn.ne' + (fun i j=>hi i.castSucc.castSucc j.castSucc.castSucc) (fun i j=>h2 i.castSucc.castSucc j.castSucc.castSucc) + have heb:=flagCharacteristic_eval F G w r hWb.ne' hi h2 + have hs : (-1:ℝ)^(n+2)=(-1:ℝ)^n := by rw [pow_add];norm_num + have he : (flagGram (n+2) F G w).det*(flagCharacteristic (n+2) F G w).eval r= + -((flagGram n F G w).det*(flagCharacteristic n F G w).eval r)*L*R := by + rw [heb,hs,hborder,hen] + ring + let C := (flagGram n F G w).det*L*R/(flagGram (n+2) F G w).det + refine ⟨C,div_pos (mul_pos (mul_pos hWn hL) hR) hWb,?_⟩ + apply mul_left_cancel₀ hWb.ne' + rw [he] + dsimp [C] + field_simp +/-- Finite moment pencils of two positive flags have real, strictly positive, interlacing roots. -/ +theorem flagCharacteristic_interlaces {N : ℕ} (F G : ℕ → ℝ → ℝ) (w : ℝ → ℝ) + (hF : PositiveFlag F N) (hG : PositiveFlag G N) + (hFc : ∀ i : Fin N,Continuous (F i)) (hGc : ∀ i : Fin N,Continuous (G i)) + (hw : ∀ p,0